#shadow-cljs

generated UTC: 2023-02-13 19:00
latest data: https://clojurians-log.clojureverse.org/shadow-cljs/2023-02-13
messages: 95350
pro tips:
* Double click on text to filter by it. (doubleclick + cmd-f for extra points).
* Click on date to keep day visible regardless of filter.
* Click on time to keep hour visible regardless of filter.
#2017-08-2816:34richiardiandrea@shaunlebron what's logbot 😄#2017-08-2816:40shaunlebronlots of discussions are lost in slack since we don’t have a premium account#2017-08-2816:40shaunlebronall channels with the logbot are logged here: https://clojurians-log.clojureverse.org/#2017-08-2816:40shaunlebron@richiardiandrea ^#2017-08-2816:41richiardiandreaoh ok thanks I did not know that#2017-08-2816:41richiardiandrea@shaunlebron see in #community-development as well, I submitted an idea there as well#2017-08-2816:43Jonso we have search engine for that?#2017-08-2816:44Jonwell https://www.google.com/search?newwindow=1&q=shadow-cljs+npm-deps+bug+site%3Ahttps%3A%2F%2Fclojurians-log.clojureverse.org%2F&oq=shadow-cljs+npm-deps+bug+site%3Ahttps%3A%2F%2Fclojurians-log.clojureverse.org%2F&gs_l=psy-ab.3...6542.6781.0.6933.4.4.0.0.0.0.0.0..0.0.foo%2Cnso-ehuqi%3D1%2Cnso-ehuui%3D1%2Cewh%3D0%2Cnso-mplt%3D2%2Cnso-enksa%3D0%2Cnso-enfk%3D1%2Cnso-usnt%3D1%2Cnso-qnt-npqp%3D0-1633%2Cnso-qnt-npdq%3D0-5608%2Cnso-qnt-npt%3D0-1229%2Cnso-qnt-ndc%3D2051%2Ccspa-dspm-nm-mnp%3D0-06145%2Ccspa-dspm-nm-mxp%3D0-153625%2Cnso-unt-npqp%3D0-1506%2Cnso-unt-npdq%3D0-4694%2Cnso-unt-npt%3D0-061%2Cnso-unt-ndc%3D300%2Ccspa-uipm-nm-mnp%3D0-007625%2Ccspa-uipm-nm-mxp%3D0-053375...0...1.1.64.psy-ab..4.0.0.98rUrdeg6LI#2017-08-2816:46richiardiandreayes there is one, but it is not super great#2017-08-2816:46richiardiandreacannot remember/find where now 😄#2017-08-2816:47thhellerslack or chat archives (in general) are terrible#2017-08-2816:48thhellerreally everything should be written down properly in some form even if just an example#2017-08-2816:48thhellerI personally hate trying to reconstruct something from a discussion in slack#2017-08-2816:49thhellerhttp://clojureverse.org maybe or even something like stackoverflow#2017-08-2816:49thhellerproblem is that someone needs to write it all down and I have a terrible track record of doing so 😛#2017-08-2816:54richiardiandreathat's where a bot comes in handy#2017-08-2816:54richiardiandreahere we mark a conversation after the fact#2017-08-2816:54richiardiandreathe bot asks if we want to paste it as part of a github issue#2017-08-2816:55richiardiandreathat's your Q&A, of course some refinement needs to be done, but we can build a simple "is this message relevant to the discussion?" UX and the bot adds it or not#2017-09-1210:51Jon
(defmacro <>
  ([el content] (<> &form &env el content nil))
  ([el content style] `(~el {:inner-text ~content, :style ~style})))
#2017-09-1210:51Jondoes shadow-cljs support multiple arity defmacro?#2017-09-1210:52Jon
cljs.user=> (ns foo.core$macros)
nil
foo.core$macros=>
foo.core$macros=> (defmacro <>
             #_=>   ([el content] (<> &form &env el content nil))
             #_=>   ([el content style] `(~el {:inner-text ~content, :style ~style})))
true
foo.core$macros=> (foo.core/<> 'a "a" nil)
nil
foo.core$macros=> (foo.core/<> 'a "a")
nil
foo.core$macros=> '(foo.core/<> 'a "a")
(foo.core/<> (quote a) "a")
foo.core$macros=> '(foo.core/<> 'a "a" nil)
(foo.core/<> (quote a) "a" nil)
foo.core$macros=> (macroexpand-1'(foo.core/<> 'a "a" nil))
WARNING: Use of undeclared Var foo.core$macros/macroexpand-1' at line 1
TypeError: Cannot read property 'call' of undefined
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a" nil))
((quote a) {:inner-text "a", :style nil})
foo.core$macros=> (macroexpand-1 '(foo.core/<> 'a "a"))
((quote a) {:inner-text "a", :style nil})
#2017-09-1210:52Jonit looks good in Lumo, but throw compilation errors in shadow-cljs#2017-09-1210:55Jonbased on https://stackoverflow.com/a/25569059/883571#2017-09-1211:50Jonjust guessing https://github.com/clojure/core.specs.alpha/commit/93f655c297f7a4e9d8fa7cd549ec08660130d925#commitcomment-24248628#2017-09-1212:23thheller@jiyinyiyong shadow-cljs is not self-hosted therefore macros need to be written in Clojure#2017-09-1212:23thhellercore.specs.alpha does not have anything to do with it#2017-09-1212:23thhelleryou simply cannot do defmacro in CLJS (only CLJ)#2017-09-1212:24thhelleruse shadow-cljs clj-repl and do the macro stuff there#2017-09-1212:25thhellercore.specs.alpha is for Clojure therefore it does not have :require-macros#2017-09-1212:44thhellerby the looks of it you are trying to use CLJS code from CLJ, that won’t work without some reader conditionals#2017-09-1213:16Joncljc files#2017-09-1213:17thhelleryes, in .cljc files#2017-09-1213:18thheller.cljc files can be loaded by CLJS and CLJ but when loading CLJ you can’t use CLJS code so you have to use reader conditionals#2017-09-1213:27JonI feel confused, none of my files uses .clj as extension name#2017-09-1213:28Jonit's mostly .cljc, with a main.cljs file#2017-09-1213:29thhellerso .cljc files are basically .clj and .cljs in one file#2017-09-1213:30thhellerif you :require-macros something that will be loaded by CLJ#2017-09-1213:30thhellerif that it turn does :require something that will also be loaded by CLJ#2017-09-1213:30thhellerand so on#2017-09-1213:31thhellerso if the file that was required then tries to :require-macros it fails because CLJ is the one loading it and not CLJS#2017-09-1213:32thhellertwo separate worlds#2017-09-1213:32Jon...which means in every .cljc file, I can't use :require-macros too?#2017-09-1213:33thhellerI think you misunderstand#2017-09-1213:33thhellerthe answer is it depends#2017-09-1213:33thhellerit matters who is loading the .cljc file. the CLJS compiler where :require-macros is fine OR Clojure where it is not fine#2017-09-1213:34Jonmy file is compiling with shadow-cljs and running in a browser, I can't see where is the .clj part#2017-09-1213:35thhellerif you :require-macros something that is loaded by clojure. everything macro related is clojure.#2017-09-1213:36JonSounds like something I didn't even noticed before. The same code was ok, but I saw compilation errors today.#2017-09-1213:36Jonnot playing with cljs for weeks... also I haven't updated my dependencies yet#2017-09-1213:36thhellerdoesn’t have anything to do with dependencies#2017-09-1213:37thhellermacros can be a bit confusing by themselves, they are extra confusing in CLJS#2017-09-1213:37JonI mean, the behaviors of the compiler just changed with the same copy of code. no new commits, not deps updates#2017-09-1213:38thhellerI doubt that#2017-09-1213:39thhellermaybe you added a :require somewhere?#2017-09-1213:40JonI don't think so#2017-09-1213:40thhellerif you have demo repo somewhere I can take a look#2017-09-1213:40Jonhttps://github.com/Respo/respo/commits/master#2017-09-1213:41Jonstill this repo, you may check the code on Aug#2017-09-1213:41thhellerwhich command produces the error?#2017-09-1213:41Jonyarn watch,#2017-09-1213:42Jonit starts shadow-cljs watch#2017-09-1213:42Jonthen I edit code, say in space.cljc, change value from 1 to 2#2017-09-1213:44thhellerah hmm#2017-09-1213:45thhellershadow-cljs attempts to load the file as a macro, not sure why it would#2017-09-1213:45JonI don't trust my code anymore since I introduced Macros...#2017-09-1213:46thhellerI would stay away from .cljc files personally, they just make things a lot more complicated#2017-09-1213:47thhellerthe macro reloading code in shadow-cljs is probably buggy with .cljc files#2017-09-1213:47Jonmaybe I should compile all my code to .cljs since I never really use Clojure(JVM)#2017-09-1213:48thhellerkeep the macros in .clj files and everything else in .cljs#2017-09-1213:48thhelleronly use .cljc when absolutely necessary#2017-09-1213:49thhellerthats what I do#2017-09-1213:49Jonhow to require .clj from .cljs by the way?#2017-09-1213:50thhelleryou can’t … other than :require-macros. thats the point#2017-09-1213:51JonI remembered you write a Gist before, or just a script? Do you still have it?#2017-09-1213:51Jonhttps://gist.github.com/thheller/405951452cf872eb16ba2d4e1fb5a117#2017-09-1213:51thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/macros#2017-09-1214:00thhellerbascially whenever you need a macro you create a .cljs files and a .clj file of the same name#2017-09-1214:00thhellerthe .cljs file then :require-macros the .clj files itself#2017-09-1214:01thhellereverything else just uses :require never :require-macros#2017-09-1214:02thhellerIMHO it is not a good idea to have a respo.macros namespace, puts too much emphasis on the macro part.#2017-09-1214:07JonI agree. But I don't have enough experience to decide which solution is best for my case. I still have to deal with the edge cases,#2017-09-1214:08thhellerwell that you are writing your own editor that has to deal with all the edge cases certainly adds a bit of complexity on top 😉#2017-09-1214:09thhellerotherwise it is not that complicated#2017-09-1214:10Jonkind of...#2017-09-1214:11JonI have a polyfill/ folder for bare ClojureScript code anyway.#2017-09-1214:12Jonmy current headache is, in the file I write Macros, I need to require code from my ClojureScript code written in .cljs.#2017-09-1214:12thhelleryeah, don’t do that. well keep it to an absolute minimum.#2017-09-1214:12Jonpreviously it's in .cljs, so it's okay. now it's .cljs.#2017-09-1214:13thhellerbtw do you know other JS build tools than rollup and webpack?#2017-09-1214:14thhellerI know there are others but can never remember their names#2017-09-1214:14Jontried, by barely use them. Webpack is the best.#2017-09-1214:15thhellerwebpack is horrible if you want to write plugins for it#2017-09-1214:15JonI used requirejs and browserify before. but switched to Webpack.#2017-09-1214:15thhelleralso does way too much suff I don’t need#2017-09-1214:16thhellercan requirejs bundle code together?#2017-09-1214:16Jonbut we need most of the features in Webpack, when we where trying to create single page apps.#2017-09-1214:17thhellerI need something for shadow-cljs as a fallback when closure does not work#2017-09-1214:17Jonyeah, requirejs has a command line called r.js, which bundles code. But it's using AMD format, which not as useful as CommonJS, so it's barely used now.#2017-09-1214:17thhellerwebpack is driving me crazy#2017-09-1214:17thhellerbuilding my own is not an option#2017-09-1214:17thhellermaybe browserify works, checking it now#2017-09-1214:18Jonheard that browserify is cleaner than Webpack.#2017-09-1214:19Jonwhy is Webpack so crazy to you?#2017-09-1214:19thhellerbecause I’m trying to do something it is not intended to do#2017-09-1214:20thhellerwell it sort of can do it if I combine DllPlugin and DllReferencePlugin but that whole setup is just crazy#2017-09-1214:21JonI never looked into Plugins.. 😨#2017-09-1214:22thhellerwell if I ignore code splitting everything is easy#2017-09-1214:22Jondo you think asking the maintainers can help?#2017-09-1214:22thhellermaybe, don’t know who to talk to or even how to describe what it is I’m trying to do#2017-09-1214:24Jonmaybe https://twitter.com/wSokra#2017-09-1214:25Jonit's his fault that Webpack gets so complicated. but people need those features anyway#2017-09-1214:25thhelleryeah he’s probably busy with other stuff#2017-09-1214:26thhellerI can just wait till Closure supports everything … which will happen eventually (hopefully)#2017-09-1214:27Jonhttps://medium.com/webpack/the-new-plugin-system-week-22-23-c24e3b22e95#2017-09-1214:27JonI remembered he is working in Webpack full-time#2017-09-1214:28thhelleryeah lots of stuff happening with webpack, getting more complicated with every change#2017-09-1214:29JonClojureScript is so complicated.#2017-09-1214:29thhellerhehe not to me 🙂#2017-09-1214:29Jondo you know about BuckleScript?#2017-09-1214:29thhellerknow yes, used it no#2017-09-1214:30Jonthe author is a Chinese, so he is active in Chinese tech communities too#2017-09-1214:30JonBuckleScript has runtime libraries like ClojureScript, but not Macros.#2017-09-1214:31JonI just feel that he is so happy the performance of compiler beat all other compilers of altjs languages.#2017-09-1214:32Jonand it doesn't run into traps like ClojureScript does, in using with Webpack#2017-09-1214:33thhellerwell it doesn’t have the Closure Compiler#2017-09-1214:34thhellerI personally care very little about the speed of the compiler when my compiled output is a lot smaller and optimized#2017-09-1214:35thhellerhmm browserify might work for what I want. seems easier than webpack at least 🙂#2017-09-1214:37JonI think people don't always care about the bundle size that much, for example some of my apps in my previous work, they are used internally. So the size the not important. My manager just want the websites get online really quickly.#2017-09-1214:37thhellerwell if you don’t care about the size then using webpack with shadow-cljs should just work fine?#2017-09-1214:37Jonwhile some of the sites do care about that. They just choose Vue.js and not even React.#2017-09-1214:38Jonyeah, if I can split ClojureScript libraries into another bundle, then it's acceptable in some scenarios.#2017-09-1214:40Jonanyway, the current problem of using ClojureScript in China is just too few people are using it. we would think about size after people start using it.#2017-09-1214:41thhellertoo few people are using it globally 😉#2017-09-1214:43thhellerlooks like browserify may actually work 🙂#2017-09-1214:43thhellerattempted to write the webpack plugin at least 4 times in the last month and always gave up#2017-09-1214:43thhellershould have looked at alternatives earlier 🙂#2017-09-1214:44Jonbut I didn't hear you complain about it on Twitter 😅#2017-09-1214:45thhellerno point in complaining if the problem is that I don’t understand it 😉#2017-09-1214:46JonI imagined there might be some chance that Webpack maintainers will help ClojureScript, although it's rare.#2017-09-1214:47thhellerwell by the looks of it all I need is browserify -r react -r react-dom and then something combined with -x=react#2017-09-1214:47Jonbeing a user of both tools, I just hope to see ClojureScript works in Webpack, just like TypeScript and BuckleScript. 🙂#2017-09-1214:47thhellerprobably won’t happen#2017-09-1214:47Jon😅#2017-09-1214:48thhellerwell works in webpack already but just not via a loader#2017-09-1214:48Jonyou are right#2017-09-1214:50thhellerthe loader part is problematic because clojurescript uses namespaces to organize code#2017-09-1214:50thhellerthe others just use files#2017-09-1214:51thhellerwhich looks similar but isn’t#2017-09-1214:53Jonnot even through compilation?#2017-09-1214:53thhellerI expect a whole lot more people using the Closure Compiler soon which should make things easier to use in CLJS as well#2017-09-1214:54thhellerGCC just needs a bit more tuning#2017-09-1214:54JonA lot of people are using React and Vue, which do not like Closure Compiler.#2017-09-1214:54thhellerdon’t the typescript people already use it?#2017-09-1214:54Jonnot heard about TypeScript.#2017-09-1214:55thhellerhttps://github.com/angular/tsickle#2017-09-1214:55Jonnot found much voices https://twitter.com/search?q=typescript%20closure%20compiler&amp;src=typd#2017-09-1214:56thhellerTsickle converts TypeScript code into a form acceptable to the Closure Compiler. #2017-09-1214:56thhellerthat means that its also directly useable by CLJS#2017-09-1214:56Jonwhile for webpack, there are much more https://twitter.com/search?q=typescript%20webpack&amp;src=typd#2017-09-1214:57thhelleryeah, well only because people talk about it more doesn’t mean that it is “better” 😉#2017-09-1214:58Jonmore popular~#2017-09-1214:59Jonpeople in JavaScript world rely on documents heavily. I don't think Closure Compiler team is good at documents#2017-09-1215:01thhelleryeah agreed. its mostly used by Google internally so I bet they have internal docs just nothing public#2017-09-1215:02Jonsigh#2017-09-1215:04thhellerbrowserify uglifyify envify … they went a little overboard with the ify#2017-09-1215:05Jonlike loaders#2017-09-1215:05Jonand coffeeify#2017-09-1215:08thhellerwell it does what I need so thats a good thing 🙂#2017-09-1215:08Jondoes this file has to be empty?#2017-09-1215:08thhellerno you can put any kind of CLJS code in there#2017-09-1215:09Jonbut.... code in lib.clj can not access those variables#2017-09-1215:09thhellerat compile time no, at runtime yes#2017-09-1215:11Jonany tricks to rescue?#2017-09-1215:11thhellerwhat do you want to do?#2017-09-1215:11Jonmy macros are wrapping create-element into div and span functions#2017-09-1215:12Jonso I want to access create-element from macro definitions#2017-09-1215:12thhelleruhm but you don’t actually want to CALL the function right?#2017-09-1215:13Jonnot, during the time macros are defined,#2017-09-1215:13thhellerthen its fine#2017-09-1215:13Jon
(defmacro meta' [props & children] `(create-element :meta ~props 
#2017-09-1215:13Jonluckily not called#2017-09-1215:14thhellerso whats the issue?#2017-09-1215:14Jon
(ns respo.alias (:require [respo.core :as core]) (:require-macros [respo.alias]))

(def create-element core/create-element)

(def create-comp core/create-comp)
#2017-09-1215:15Jonnow I put my code back in a file called alias.clj, but in alias.clj, I don't get the variables defined in alias.cljs.#2017-09-1215:15Jonthe snippet above is alias.cljs#2017-09-1215:16thhellerand alias.clj?#2017-09-1215:16Jonoh, there might be a trick#2017-09-1215:16thhellerwhy do you need the alias at all?#2017-09-1215:17thhellerin the macro just emit respo.core/create-element instead of create-element#2017-09-1215:25Jonall working now. thanks#2017-09-1215:26thhellerrequires some trickery but it seems browserify has solved the issue I was trying to solve for the last month using webpack#2017-09-1215:27thhelleryay for simple tools 🙂#2017-09-1215:28Joninteresting#2017-09-1215:28Jonis it bundling?#2017-09-1215:29thhellersort of#2017-09-1215:30thhellerI needed a way of packages JS together but still being able to require the packages by name#2017-09-1215:30thhellerie. want to bundle react and react-dom together (or separate) and then still use require to access them#2017-09-1215:30thhellertogether was simple in webpack as well#2017-09-1215:31thhellerseparate was nearly impossible#2017-09-1215:31thhellerwell it was hard not impossible#2017-09-1215:31thhellerbrowserify -r react-dom -x react > react.dom.js and done#2017-09-1215:31Jon🤔#2017-09-1215:32thhellerit will make more sense soon 😉#2017-09-1215:33Jonlooking forword#2017-09-1215:33Jonbut it sounds like Webpack users won't get the benefits#2017-09-1215:33thhellerwebpack users never needed it#2017-09-1215:34Jonwell? 🤔#2017-09-1215:34thhellerwell if you use webpack you already have something that can provide require("react")#2017-09-1215:35Jonit's by CommonJS, in Webpack#2017-09-1215:35thhelleryes#2017-09-1215:35thhellerbut I wanted a more lightweight way of being able to use require("react") without using webpack#2017-09-1215:36Jonso browserify is the alternative...#2017-09-1215:36thhellerwell the primary goal is to use the Closure Compiler#2017-09-1215:36thhellerbut in cases where it doesn’t work (yet) the fallback will be browserify#2017-09-1215:36Jonanyway it sounds good now 😅#2017-09-1215:37thhellerso you can still (:require ["react"]) but without webpack#2017-09-1215:38thhellerjust wish browserify was able to generate some kind of manifest 🙂#2017-09-1215:38Jonlike :npm-deps?#2017-09-1215:38thhellerI hate :npm-deps .. it is so misleading on what it actually does#2017-09-1215:38thhellerI call it :js-provider for now#2017-09-1215:39thhellerso if you set :js-provider :closure the (:require ["react"]) will attempt to import the npm react package via the closure compiler#2017-09-1215:39Jonin the old days, we have gulp-rev for browserify https://stackoverflow.com/a/33507199/883571#2017-09-1215:39thhellerif you set :js-provider :require it will just emit a require("react") call, which just works for node.js or when using webpack#2017-09-1215:40thhellerbut then also for the browser by using the browserify fallback#2017-09-1215:40thhellerbasically :js-provider covers how native JS is “provided” by the system#2017-09-1215:41thhellerso no need for cljsjs anymore#2017-09-1215:41Jonsounds like what Webpack does#2017-09-1215:41thhelleryes but inverted#2017-09-1215:42thhellernow its shadow-cljs, then that code is processed by webpack#2017-09-1215:42thhellerthen its just shadow-cljs, no additional step#2017-09-1215:42Jonare you adding browserify as a dependency in shadow-cljs?#2017-09-1215:42thhelleryes#2017-09-1215:42thhellerwell maybe#2017-09-1215:43Jonthat's 😄#2017-09-1215:43thhellerbut yes the goal is to only have shadow-cljs running and it managing everything#2017-09-1215:44thhellerfirst plan was using webpack in the background but that was way harder than I wanted it to be#2017-09-1215:44Jonyeah, it's cool. and it makes things a lot easier to learn#2017-09-1215:45thhellercool cool, thanks for suggesting browserify. I got further in the last hour than in the last 4 months trying to understand webpack 😛#2017-09-1215:46Jonglad it helps#2017-09-1215:47thhelleroh perfect it even has --list which does what I need 😉#2017-09-1215:48Joncool#2017-09-1215:52thhellergotta go … but this is exciting … I should finally be able to finish this beast of a branch 🙂#2017-09-1215:53Jonlooking forward to updates#2017-09-1215:54Jonalso late in Shanghai, going to clean all my tabs before sleep#2017-09-1315:16Jonhttps://medium.com/webpack/the-new-plugin-system-week-22-23-c24e3b22e95#2017-09-1315:16JonWebpack 4 is coming 😆#2017-09-1316:57thhellerbrowserify might not work out after all#2017-09-1316:58thhellerthis stuff really should not be this hard, I can’t be the only one trying to do this 😞#2017-09-1317:00thhellerI’ll finish this as it works ok enough but requires so god damn much tuning by hand it gets really annoying#2017-09-1317:02thhellerhttps://github.com/browserify/browserify/graphs/contributors also appears pretty much dead …#2017-09-1406:27thhellerhttps://twitter.com/jiyinyiyong/status/908170293079707649#2017-09-1406:27thheller@jiyinyiyong I have to ask: What doesn’t work well? I thought the support was pretty solid and working well?#2017-09-1406:28thhelleris it just the fact that you need to juggle webpack and shadow-cljs instead of just webpack?#2017-09-1406:28thhelleror is something else missing?#2017-09-1406:37thhellerI’m gonna be away all day but I’m really curious to hear your thoughts#2017-09-1408:28JonI have to say juggling could be a problem when I want to introduce cljs to others who haven't written cljs before.#2017-09-1408:29JonI was trying to draw attention from those people but it turned out they didn't even notice my tweet.#2017-09-1408:31Jonthere's not much window that I can get my ClojureScript code into production. feeling that I'm pushing it too recklessly. but anyway I can get very little attention from people.#2017-09-1421:05thhellerah ok thought you had something particular in mind 🙂#2017-09-1421:05thhellerI’ll probably do a write up of the JS related stuff I have done#2017-09-1421:05thhellermaybe someone on the JS side of things can help there as browserify doesn’t quite do want I want it to do#2017-09-1421:06thhellerit works well enough for now but not really a solution suitable for most production setups#2017-09-1502:37Jon😉#2017-09-1506:14thhellersaw you guys talking on twitter but can’t understand anything 😛#2017-09-1506:47bolasblackSorry about that, I can read english but bad at speak 😛#2017-09-1506:49bolasblackSo I always inclined to speak Chinese ...#2017-09-1513:47Jonhe complained shadow-cljs.edn is too tedious(?) to write#2017-09-1513:48Jonsometimes I think writing that file is boring too, although mostly I just copy from my minimal-xyz projects#2017-09-1513:49JonI found debugging macros is convenient with Lumo, easier compared to shadow-cljs, then I don't write shadow-cljs.edn when I have a REPL#2017-09-1513:57bolasblackI sometimes use lumo run a script to generate shadow-cljs.edn 😛#2017-09-1513:57bolasblackfor example:#2017-09-1514:11Jonso many exports#2017-09-1514:18thheller@bolasblack I don’t quite understand what the purpose of this script is, if you have many different namespaces you want to have accessible via require then use :npm-module#2017-09-1514:19thhellerby default it compiles file to you can require("shadow-cljs/your.app").some_function()#2017-09-1514:20thhellerthe purpose of :target :node-library (which you seem to be using behind shadow-clj-build/custom) is to condense all namespaces down a more manageable public “API”#2017-09-1514:23thhelleryou can compile all the files into a directory#2017-09-1514:24thhellerput a package.json in that directory with a "main":"./your.app.js" and publish that to npm#2017-09-1514:24thhellerthen users can require("your-package") or require("your-package/some.other.ns")#2017-09-1514:28thhelleror you can of course just require("./relative-path-to/your.app") by setting :output-dir so something other than node_modules/shadow-cljs#2017-09-1514:35thhellersorry that :npm-module isn’t documented better but it is the basis of all node/JS tool integration so you might want to use that#2017-09-1514:35thhellerhttps://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-JS-Devs#2017-09-1710:31thheller> 10,616 additions and 8,810 deletions.#2017-09-1710:31thhellerI just merged the changes I was working on the past month or so#2017-09-1710:32thhellernot quite done yet but I got really tired of juggling all the branches, best stay away from master for a while#2017-09-1710:32thhellerneed to work out a few kinks#2017-09-1710:34thhellerwill write some blog post to explain things#2017-09-1715:44bolasblackSorry for the late reply, I participated the RubyConf China, so I didn't check this slack team these two days 🙏#2017-09-1715:47bolasblackThanks for your reminding, the :npm-module is really better suited to my case#2017-09-1716:02bolasblack🎉 for the 2.0 😁 (although I didn't seen the document or blog, but I have read your chat record)#2017-09-1810:27thheller@jiyinyiyong https://github.com/thheller/shadow-cljs/issues/94 I don’t understand your question?#2017-09-1810:28thhellerrequire for the browser is the thing I’m working on so it isn’t ready#2017-09-1810:28thhellerbut what about cljsjs?#2017-09-1817:11Jondidn't check Slack, sorry.. turned out it has nothing to do with require#2017-09-2017:55Jonhttps://twitter.com/jiyinyiyong/status/910563010862653440#2017-09-2018:00thheller@jiyinyiyong the first CLJS namespace I ever wrote worked with some Shadow DOM (the old stuff)#2017-09-2018:00thhellerso I called it shadow.dom … the prefix stuck#2017-09-2018:00thhellerstill exists today#2017-09-2018:00thhellerhttps://github.com/thheller/shadow/blob/master/src/main/shadow/dom.cljs#2017-09-2018:00thhelleralthough nothing shadow dom related in it anymore 😉
#2017-09-2018:01thhelleralso I’m bad at naming things#2017-09-2018:47thhellerI’m totally up for a “shorter” name btw, just hard to find something “free” in npm#2017-09-2020:14thhellerstarted writing down some stuff about the work I’ve been doing#2017-09-2020:14thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-09-2020:15thhellerwasn’t sure where to start, could use some feedback#2017-09-2020:25thhellerI’m scared to make a new release since that will probably break everyones builds#2017-09-2020:25thhellerhow does that {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b5c6ddd4d1dac298d6d9dfc6f5dbd0cdc1"}, :content ("[email protected]")} thing work in npm?#2017-09-2021:45richiardiandrea@thheller next will not be seen on npm#2017-09-2021:45richiardiandreait is basically hidden, and won't be taken into consideration when upgrading for instance#2017-09-2021:46thhelleryeah thats what I need, so people still get the old version when installing#2017-09-2021:46thhellerbut can try the new one#2017-09-2021:46thhellerwithout messing with version numbers 😉#2017-09-2021:46thhellerwell I guess I could just do that#2017-09-2021:46richiardiandreayep in that case next is what you need#2017-09-2021:47thhellerwill look into it tomorrow, too tired, need sleep#2017-09-2021:47thhellergn8#2017-09-2103:23JonI used to name my projects with plant names, like opening a list of plants, pick a name with the leadings letters I want, and change it by 1 character to achieve better SEO...#2017-09-2103:24Jonlike in this list http://www.southernliving.com/plants/c#2017-09-2103:27Jonpicking "coleus", change it to "coleujs" but still pronounced like "coleus", while Google still shows "coleus" in image search#2017-09-2103:29Jonpicking "crossvine" as "clossvine" for same reason#2017-09-2103:44Jonthen it's algo easier to make a logo, just pick a picture from Google Images results, and turn it into a logo... at least simpler than drawing from nothing#2017-09-2103:47Jon
=>> npm search coleujs
No matches found for "coleujs"
=>> whois 
NOT FOUND
>>> Last update of WHOIS database: 2017-09-21T03:34:59Z <<<
#2017-09-2113:41bolasblackHi thheller, is there a way to change target folder name? I found :cache-root in code, but it seems only move aot-classes classpath.edn cli-repl.port http.port nrepl.port socket-repl.port to the new folder, left explorer jar-manifest library npm in target/shadow-cljs#2017-09-2114:14thheller@bolasblack it is not fully implemented yet but yes the goal is to allow changing :cache-root so target/shadow-cljs isn’t hard coded anymore#2017-09-2114:15thhellerso currently it is not possible, but should be in the future#2017-09-2114:40bolasblackLook forward to the implement of :cache-root 😁#2017-09-2202:23Jonhttps://twitter.com/anmonteiro90/status/910975858612899840#2017-09-2208:14thhellerhmm not sure where they are going with that, seems rather lumo specific#2017-09-2208:15thhellerand it doesn’t solve anything really#2017-09-2208:15thhellerthe problem is that we have to deal with 2 package managers#2017-09-2208:15thhellercurrently it is one for JS then one for CLJS#2017-09-2208:15thhellerwhen publishing to npm the problem gets worse because we can find JS and CLJS there#2017-09-2208:16thhellerbut still need the usual maven style for CLJS#2017-09-2208:16thhellerunless everyone agrees to publish to npm which is unlikely at this point#2017-09-2208:47JonI'm wondering if Lumo made it, shadow-cljs might need to support it as well...#2017-09-2208:48thhellerI’ll implement it if CLJS core does#2017-09-2208:49thhellerin any case we should agree on a standard first, just dumping stuff whereever just isn’t going to work#2017-09-2208:49thhellerwe probably should have a "cljs" property in package.json#2017-09-2208:50thhellerbut I don’t have the brain capacity to think about this now, too busy trying to work out the JS dependency stuff#2017-09-2208:50thhellerbrowserify is making me angry .. just like webpack#2017-09-2208:50Jon...as a standard in package.json#2017-09-2208:50Jon😅#2017-09-2208:51thhellerin fact all of js is making be so angry, why can’t they all agree on one way to do things …#2017-09-2208:51thhellercurrently trying to make jquery+bootstrap work#2017-09-2208:52thhellerbut bootstrap doesn’t declare any dependency on jquery .. it just expects it as a global#2017-09-2208:52Jonbecause js is not controlled by one single company#2017-09-2208:52thhellerwhich means we need shit like https://github.com/thlorenz/browserify-shim#2017-09-2208:52thhellerwhich in turn can only be configured by package.json#2017-09-2208:52thhelleras if I had a package.json for every build lying arround#2017-09-2208:53thhellergah 😠#2017-09-2208:53JonI think shadow-cljs does not have to support all things in js world. things like Bootstrap may be troublesome too even in Webpack.#2017-09-2208:53thhelleryeah but its one of those packages ppl expect to use#2017-09-2208:54thhellerjquery works, react works, most packages around react work#2017-09-2208:54thhellerbootstrap doesn’t#2017-09-2208:55Jonwell, then it's Bootstrap's problem#2017-09-2208:56thhellerhmm you might be right#2017-09-2208:56Jonsometimes we still use CDN for some of the libraries, even we have Webpack nowadays#2017-09-2208:56thhelleryeah but for that I need browserify-shim as well#2017-09-2208:56thhellerthe shim part is not the issue#2017-09-2208:56thhellerthat it can only be configured by package.json is#2017-09-2208:56thhellerI should just fork it I guess#2017-09-2208:57Jonfork browserify-shim?#2017-09-2208:57thhelleryeah#2017-09-2208:58thhellernot like its getting many updates these days#2017-09-2208:58Jonin the website I previously worked for view-source:https://h5.ele.me/msite/ lots of can be found#2017-09-2208:59thhelleryeah thats stuff I need to support anyways#2017-09-2208:59Jonsomehow sounds like you are creating your own bundler for CommonJS#2017-09-2208:59thhellerie. not using React from npm but from global in page via cdn#2017-09-2209:00Jonwell, React 😅#2017-09-2209:00thhellerjust using react as an example#2017-09-2209:00thhellerANYTHING from a cdn#2017-09-2209:00thhellerjquery, react, whatever#2017-09-2209:00JonReact is following CommonJS, Bootstrap isn't#2017-09-2209:01thhelleryou misunderstand me#2017-09-2209:01thhellerit doesn’t matter what the packages do#2017-09-2209:01Jonsupporting libraries from CDN?#2017-09-2209:01thhellersome projects will still have react via CDN in their page#2017-09-2209:01Jonhh, right..#2017-09-2209:01thhellerso I must use that and NOT the package from npm#2017-09-2209:01thhellerotherwise it would load react twice#2017-09-2209:02Jonyeah, there's a feature in Webpack doing that, many another loader..#2017-09-2209:03thhelleryeah .. shims … that is what I’m talking about with browserify-shim#2017-09-2209:03Jonright#2017-09-2209:03thhellerthe solution is there … it just isn’t configurable the way I’d like#2017-09-2209:03thhellerI can’t put config in package.json#2017-09-2209:03Jonit's so complicated, I always hope bundlers like Webpack can do it for me#2017-09-2209:03thhellerwell I can but I’d really like to avoid that 😛#2017-09-2209:04thhellerhttps://getbootstrap.com/docs/4.0/getting-started/webpack/#2017-09-2209:04thhellerProvidePlugin is basically equal to browserify-shim#2017-09-2209:04Jonpackage.json vs. shadow-cljs.edn?#2017-09-2209:04thhellerno#2017-09-2209:04thhellerforget about it, not important#2017-09-2209:05Jon🙂 hard for me to understand all of that anyway#2017-09-2209:05thhellerits impossible to understand#2017-09-2209:05thhellerevery package does its own quirky little thing#2017-09-2209:07thhellerwebpack is the worst offender of them all to be honest#2017-09-2209:07Jonyeah... js things always annoying. actually it has been a lot better since people using CommonJS and Webpack#2017-09-2209:07thhellerinstead of trying to find a “standard” way to do things#2017-09-2209:07thhellerit has workarounds for just about everything#2017-09-2209:07thhellerthats why configuring it is so painful#2017-09-2209:07Jon"wort offender" -> "worst offender"?#2017-09-2209:08thhelleryeah sry#2017-09-2209:09JonI guess that's one of the reasons js developers not picking ClojureScript... js world is so crazy, cljs is not prepared for it#2017-09-2209:10thhellerI don’t understand why some of the most popular packages still do their own shit#2017-09-2209:10thhellerat least they should have found some kind of agreement how to do things#2017-09-2209:11JonI don't get it, are you referring to npm?#2017-09-2209:11thhellerbootstrap in particular#2017-09-2209:11Jonmaybe it's for old websites?#2017-09-2209:11thhellerthe bootstrap npm package requires custom config in EVERY build tool#2017-09-2209:12thhellerwhy even publish to npm …#2017-09-2209:12JonI heard some developers just use it for websites, while they are backend developers#2017-09-2209:13thhellerit has 115K stars on github, surely there is someone that could fix their packaging?#2017-09-2209:14Jonsad fact 😥#2017-09-2209:15thhellerhttps://github.com/twbs/bootstrap/blob/v4-dev/js/src/index.js#L21-L32.#2017-09-2209:15JonI remembered that doing bundling for multi-pages websites is still difficult even with Webpack, plus new tech like Service Workers or somethings.#2017-09-2209:15thhellerthat code is the problem … so easy to fix#2017-09-2209:16thhellerwait what the actual f*#2017-09-2209:16thhellerhttps://github.com/twbs/bootstrap/blob/v4-dev/js/src/index.js#L1#2017-09-2209:17thhellerI give up … need to do other stuff or I’ll loose my sanity#2017-09-2209:17Jonwhat's happening now 😓#2017-09-2209:18thhellercan’t look at bootstrap anymore … it just won’t be supported for now#2017-09-2209:18Jonmaybe relying on Webpack for it is the best option#2017-09-2209:20thheller@jiyinyiyong the issue is not which build tool I use#2017-09-2209:20thhellerthe issue is that EVERY build tool requires special config just for bootstrap#2017-09-2209:20Jonoh...#2017-09-2209:25thhellerwell the good news is that many other packages just work#2017-09-2209:25thhellermight push a preview release today so you can start testing 😉#2017-09-2209:25Jonsounds nice!#2017-09-2209:26Jonsomehow most of my projects are using cljs code only due to the bad support for npm packages before 😂#2017-09-2209:27thhellerthat is not a bad thing, CLJS code is better than JS 😉#2017-09-2209:28Jon....trying to find projects that using npm packages..#2017-09-2210:39thhellerif anyone wants to try it I just published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cab9a2abaea5bde7a9a6a0b98aa4afb2be"}, :content ("[email protected]")}#2017-09-2210:40thhellerwill finish the blog post now#2017-09-2210:48thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-09-2210:49thhellerit will not compile anything that uses cljsjs packages … but I need some testers 😛#2017-09-2211:55thheller@bolasblack the {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "82f1eae3e6edf5afe1eee8f1c2ece7faf6"}, :content ("[email protected]")} release I just pushed should fully support :cache-root. It will probably break everything else though 😉#2017-09-2212:05Jon
=>> yarn watch
yarn watch v0.24.6
$ shadow-cljs watch app
shadow-cljs - config: /Users/chen/repo/minimal-xyz/minimal-shadow-cljs-browser/shadow-cljs.edn version: SNAPSHOT
shadow-cljs - updating dependencies
shadow-cljs - dependency update failed - Could not find artifact thheller:shadow-cljs:jar:SNAPSHOT in central ()
error Command failed with exit code 1.
#2017-09-2212:06Jonhttps://github.com/minimal-xyz/minimal-shadow-cljs-browser/tree/next#2017-09-2212:06thhellerhmm#2017-09-2212:07thhellerweird#2017-09-2212:10Jonis SNAPSHOT the correct version name?#2017-09-2212:13thhellerno, i broke closure-defines#2017-09-2212:13thhellerfixing now#2017-09-2212:18thheller@jiyinyiyong should be fixed#2017-09-2212:19JonRetrieving...#2017-09-2212:23Jonit's still retrieving >o<#2017-09-2212:25thhellerretrieving what?#2017-09-2212:25Jon
yarn watch v0.24.6
$ shadow-cljs watch app
shadow-cljs - config: /Users/chen/repo/minimal-xyz/minimal-shadow-cljs-browser/shadow-cljs.edn version: 2.0.0-alpha3
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.0.0-alpha3/shadow-cljs-2.0.0-alpha3.pom from 
Retrieving org/clojure/clojurescript/1.9.908/clojurescript-1.9.908.pom from 
Retrieving org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.pom from 
Retrieving org/clojure/google-closure-library-third-party/0.0-20170809-b9c14c6b/google-closure-library-third-party-0.0-20170809-b9c14c6b.pom from 
Retrieving org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.pom from 
Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.pom from 
Retrieving com/google/javascript/closure-compiler-main/v20170910/closure-compiler-main-v20170910.pom from 
Retrieving com/google/javascript/closure-compiler-parent/v20170910/closure-compiler-parent-v20170910.pom from 
Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.pom from 
Retrieving org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar from 
Retrieving org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.jar from 
Retrieving org/clojure/clojurescript/1.9.908/clojurescript-1.9.908.jar from 
Retrieving org/clojure/google-closure-library-third-party/0.0-20170809-b9c14c6b/google-closure-library-third-party-0.0-20170809-b9c14c6b.jar from 
Retrieving com/google/javascript/closure-compiler-unshaded/v20170910/closure-compiler-unshaded-v20170910.jar from 
Retrieving com/google/javascript/closure-compiler-externs/v20170910/closure-compiler-externs-v20170910.jar from 
#2017-09-2212:25thhellershould be fine to just kill the process and try again. maybe the connection died or something#2017-09-2212:25Jonand poor network from China mainland#2017-09-2212:25thhellerah ok#2017-09-2212:25thhellerthen just wait 😉#2017-09-2212:27thhellergreat just found the next bug 😉#2017-09-2212:28thhelleryou might get a Caused by: java.lang.IllegalArgumentException: No matching field found: close for class sun.net.www.protocol.jar.JarURLConnectio#2017-09-2212:30thhellerupgrade should fix it#2017-09-2212:37Jon
Retrieving thheller/shadow-cljs/2.0.0-alpha3/shadow-cljs-2.0.0-alpha3.jar from 
shadow-cljs - dependencies updated
shadow-cljs - re-building aot cache on startup, that will take some time.
shadow-cljs - starting ...
Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: close for class sun.net.www.protocol.jar.JarURLConnection, compiling:(compiler.clj:32:3)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3676)
	at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
	at clojure.lang.Compiler.compile1(Compiler.java:7552)
	at clojure.lang.Compiler.compile(Compiler.java:7619)
	at clojure.lang.RT.compile(RT.java:408)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:421)
	at clojure.core$load$fn__6368.invoke(core.clj:6008)
	at clojure.core$load.invokeStatic(core.clj:6007)
	at clojure.core$load.doInvoke(core.clj:5991)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5812)
	at clojure.core$load_one.invoke(core.clj:5807)
	at clojure.core$load_lib$fn__6313.invoke(core.clj:5852)
	at clojure.core$load_lib.invokeStatic(core.clj:5851)
#2017-09-2212:37Jonyep...#2017-09-2212:37thhellerfixed in alpha4#2017-09-2212:38Jonclosure compiler is so huge#2017-09-2212:39thhelleris it? should be 7mb or so?#2017-09-2212:40Jon
shadow-cljs - starting ...
failed to start service
{:id :dev-http}
ExceptionInfo: failed to start service
	clojure.core/ex-info (core.clj:4725)
	clojure.core/ex-info (core.clj:4725)
	shadow.runtime.services/start-many/fn--14458 (services.clj:135)
	shadow.runtime.services/start-many (services.clj:126)
	shadow.runtime.services/start-many (services.clj:105)
	shadow.runtime.services/start-all (services.clj:144)
	shadow.runtime.services/start-all (services.clj:139)
	shadow.cljs.devtools.server/start-system (server.clj:150)
	shadow.cljs.devtools.server/start-system (server.clj:94)
	shadow.cljs.devtools.server/start! (server.clj:180)
	shadow.cljs.devtools.server/start! (server.clj:172)
	shadow.cljs.devtools.server/start! (server.clj:175)
	shadow.cljs.devtools.server/start! (server.clj:172)
	shadow.cljs.devtools.server/from-cli (server.clj:260)
	shadow.cljs.devtools.server/from-cli (server.clj:251)
	shadow.cljs.devtools.cli/main (cli.clj:92)
	shadow.cljs.devtools.cli/main (cli.clj:74)
	clojure.core/apply (core.clj:657)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/-main (cli.clj:132)
	shadow.cljs.devtools.cli/-main (cli.clj:130)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.main/main-opt (main.clj:316)
	clojure.main/main-opt (main.clj:312)
	clojure.main/main (main.clj:423)
	clojure.main/main (main.clj:386)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.main.main (main.java:37)
Caused by:
invalid config
In: [:builds :npm 1] val: {:id :npm, :target :npm-module, :output-dir "node_modules/shadow-cljs"} fails spec: :shadow.build.config/build at: [:builds 1] predicate: (contains? % :build-id)

error Command failed with exit code 1.
=>>
#2017-09-2212:40Jonmany it's poor network, 7M is not large#2017-09-2212:41thhelleris that in your config?#2017-09-2212:41thhelleroh right the built-in config was broken#2017-09-2212:41Jon
{:source-paths ["src"]
 :dependencies []
 :builds {:app {:output-dir "target/"
                :asset-path "."
                :target :browser
                :modules {:main {:entries [app.main]}}
                :devtools {:after-load app.main/reload!}}}}
#2017-09-2212:41Jonno :npm-module#2017-09-2212:42thhellerlooks like you called shadow-cljs compile npm and not shadow-cljs compile app?#2017-09-2212:42Jonshould be "watch": "shadow-cljs watch app",#2017-09-2212:43Jonstrange, no npm found in my config or package.json#2017-09-2212:43thhelleryeah its the built-in config#2017-09-2212:43thhellerdammit I really need to test outside the project itself#2017-09-2212:43thhellernext version coming up 😉#2017-09-2212:44Jon😀#2017-09-2212:45thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "becdd6dfdad1c993ddd2d4cdfe8c908e908e93dfd2ced6df8b"}, :content ("[email protected]")} pushed#2017-09-2212:48Jon
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
Failed to run: ./node_modules/.bin/browserify -d -g envify -r hsl
{:tag :shadow.build.targets.browser/browserify, :command ["./node_modules/.bin/browserify" "-d" "-g" "envify" "-r" "hsl"]}
ExceptionInfo: Failed to run: ./node_modules/.bin/browserify -d -g envify -r hsl
	clojure.core/ex-info (core.clj:4725)
	clojure.core/ex-info (core.clj:4725)
	shadow.build.targets.browser/bundle-js/fn--25574/fn--25583 (browser.clj:461)
	shadow.build.targets.browser/bundle-js/fn--25574 (browser.clj:449)
#2017-09-2212:48Jon
Caused by:
IOException: Cannot run program "./node_modules/.bin/browserify": error=2, No such file or directory
	java.lang.ProcessBuilder.start (ProcessBuilder.java:1048)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
#2017-09-2212:49Jonbrowserify not installed, do I have to install it by myself?#2017-09-2212:50thhellerhmm no shadow-cljs should depend on it#2017-09-2212:50thhellerah hmm do you have shadow-cljs dependency in your project?#2017-09-2212:50thhelleror just the global?#2017-09-2212:50Jon
dependencies:
   { mkdirp: '^0.5.1',
     'readline-sync': '^1.4.7',
     'shadow-cljs-jar': '^0.10.0',
     'source-map-support': '^0.4.15',
     ws: '^3.0.0' },
#2017-09-2212:51Joninside project#2017-09-2212:51Jondid you put that in devDependencies?#2017-09-2212:51thhellerthats the old deps?#2017-09-2212:52JonI queried it from npm info shadow-cljs#2017-09-2212:52thheller
"dependencies": {
    "browserify": "^14.4.0",
    "envify": "^4.1.0",
    "mkdirp": "^0.5.1",
    "readline-sync": "^1.4.7",
    "shadow-cljs-jar": "^0.10.0",
    "source-map-support": "^0.4.15",
    "uglifyify": "^4.0.4",
    "ws": "^3.0.0"
  }
#2017-09-2212:52Jonstrange.#2017-09-2212:52Jonmine was from npm info shadow-cljs#2017-09-2212:52thhellernpm info #2017-09-2212:52thhellerthat @next thing is getting annoying already 🙂#2017-09-2212:54thhellerbut you need to have shadow-cljs added to your project so browserify gets installed into node_modules and not the global one#2017-09-2212:54JonI installed with yarn#2017-09-2212:55Jonthe package browserify is installed in node_modules/, but I got no .bin/browserify#2017-09-2212:55Jontrying to install locally first#2017-09-2212:56thhellerhmm looks like yarn doesn’t install bin entries from dependencies#2017-09-2212:58Jon
[:app] Build completed. (112 files, 1 compiled, 0 warnings, 9.15s)
Sep 22, 2017 8:57:29 PM clojure.tools.logging$eval486$fn__489 invoke
WARNING: build-update: [[:shadow.build.classpath/resource "app/main.cljs"]]
[:app] Compiling ...
[:app] Build completed. (112 files, 1 compiled, 0 warnings, 0.61s)
Sep 22, 2017 8:57:45 PM clojure.tools.logging$eval486$fn__489 invoke
WARNING: build-update: [[:shadow.build.classpath/resource "app/lib.cljs"]]
[:app] Compiling ...
[:app] Build completed. (112 files, 2 compiled, 0 warnings, 0.35s)
Sep 22, 2017 8:57:47 PM clojure.tools.logging$eval486$fn__489 invoke
WARNING: build-update: [[:shadow.build.classpath/resource "app/lib.cljs"]]
#2017-09-2212:58Jonand it does not call my reload! function this time#2017-09-2212:59thhellerhmm checking, might have messed that up#2017-09-2213:01Jonhttps://github.com/yarnpkg/yarn/pull/1210 yarn bug#2017-09-2213:01thhellerI was so busy with testing the npm stuff I never checked live-reloading 😛#2017-09-2213:02Jondo you have a todolist for bugs 😂#2017-09-2213:03thhellerI do, just on paper though#2017-09-2213:12thhellerhmm the yarn issue is marked as merged#2017-09-2213:12thhellerbut I don’t get the proper symlink either#2017-09-2213:14thhellerah lol it symlink into node_modules/shadow-cljs/node_modules/.bin/browserify#2017-09-2213:15thhellerguess I’ll change that#2017-09-2213:15thhellerI get npm does something else entirely .. this is gonna be fun#2017-09-2213:17thhelleryep npm links it directly into node_modules/.bin#2017-09-2213:17thhellergreat … another annoying thing I have to work around#2017-09-2213:26thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a2d1cac3c6cdd58fc1cec8d1e2908c928c928fc3ced2cac394"}, :content ("[email protected]")} should fix the reload issue#2017-09-2213:36Jonconfirmed reload..#2017-09-2213:40thhellerhmm dammit reload won’t work when you add JS deps#2017-09-2213:41thhellerah well can’t have everything#2017-09-2213:45thheller@jiyinyiyong did it work though? you are the first tester 😉#2017-09-2213:46Jondidn't try adding js deps#2017-09-2213:46thhellernah I mean did it work at all?#2017-09-2213:48Jonfor reload after file change, yes#2017-09-2213:48Jonfor adding new npm package, no:#2017-09-2213:48Jon
[:app] Compiling ...
[:app] Build failure:
Could not find js dependency "shortid", either install the npm package or define in :js-options
{}
ExceptionInfo: Could not find js dependency "shortid", either install the npm package or define in :js-options
	clojure.core/ex-info (core.clj:4725)
	clojure.core/ex-info (core.clj:4725)
	shadow.build.resolve/resolve-string-require (resolve.clj:127)
	shadow.build.resolve/resolve-string-require (resolve.clj:110)
	shadow.build.resolve/resolve-require (resolve.clj:227)
	shadow.build.resolve/resolve-require (resolve.clj:220)
	shadow.build.resolve/resolve-deps/fn--19695 (resolve.clj:56)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
#2017-09-2213:48thhellerdid you npm install shortid? or yarn#2017-09-2213:49Jon
success Saved 2 new dependencies.
├─ 
#2017-09-2213:49JonI did yarn add shortid#2017-09-2213:50thhellerhmm does it work after a restart?#2017-09-2213:50Jonnot even after restart#2017-09-2213:51Jon
=>> coffee
coffee> require 'shortid'
Expression assignment to _ now disabled.
{ [Function: generate]
  generate: [Circular],
  seed: [Function: seed],
  worker: [Function: worker],
  characters: [Function: characters],
  decode: [Function: decode],
  isValid: [Function: isShortId] }
#2017-09-2213:51Jonconfirmed installed#2017-09-2213:52thhellerand thats in the directory the project is in?#2017-09-2213:53Jonyes#2017-09-2213:53Jonvery strange#2017-09-2213:55Jon
'use strict';
module.exports = require('./lib/index');
#2017-09-2213:56Jonhttps://github.com/dylang/shortid#2017-09-2213:57Jon
=>> yarn --version
0.24.6
#2017-09-2213:57Jonmeanwhile my yarn is too old#2017-09-2213:57thhellerah .. hmm dammit#2017-09-2213:58thhellerI had hoped to get not having to deal with this issue for a while 😉#2017-09-2213:58thhellerhttps://github.com/dylang/shortid/blob/master/package.json#L31-L34#2017-09-2213:59Jonlooks like I have to use {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f38a92819db3c2ddc3ddc2"}, :content ("[email protected]")}#2017-09-2213:59thhellercurrently don’t support a map 😉#2017-09-2213:59Jona map?#2017-09-2213:59Jonbrowserify?#2017-09-2214:00thhellernah the package.json uses a map for "browser", I only support strings at the moment#2017-09-2214:00Jondidn't know that, what's it used for?#2017-09-2214:00thhellerto replace require calls#2017-09-2214:01Jonwell, unexpected#2017-09-2214:01thhelleranother wonderful thing from the js world 😉#2017-09-2214:01Jon😅 so I never realized Webpack handled that#2017-09-2214:01thhelleryeah the fun part is that a string is also allowed#2017-09-2214:02thhellerif you its a string its a replacement for "main", if its a map the functionality is completely different#2017-09-2214:02thhellerand instead redirects actual require calls#2017-09-2214:03thhellerguess I can’t ignore that 😞#2017-09-2214:04Jondidn't see docs or specs#2017-09-2214:04Jonhttps://github.com/defunctzombie/package-browser-field-spec#2017-09-2214:05Jonwell...#2017-09-2214:05thhelleroh there is actual “spec” for that#2017-09-2214:09thhellerguess it would have been to hard to use 2 separate keys …#2017-09-2214:10Jonmain and browser?#2017-09-2214:13thhellerbrowser and browser-overrides or so#2017-09-2214:13thhellerthat browser has 2 different functions is the annoying part#2017-09-2214:14Jonannoying...#2017-09-2214:30thhellerI’m always amazed that absolutely anything works in JS land#2017-09-2214:30thhellerthe code has a require for var clusterWorkerId = require('./util/cluster-worker-id')#2017-09-2214:30thhellerbut maps "./lib/util/cluster-worker-id.js": "./lib/util/cluster-worker-id-browser.js"#2017-09-2214:31thhellerso I have to first check is .js exists since .json is also allowed#2017-09-2214:32thhellerthen check if there is an override#2017-09-2214:32thhellertotally fun working through all this shit#2017-09-2214:40Jon😂 even amazing people making Webpack, Browserify, RequireJS, SeaJS for run#2017-09-2214:45thhellerI’m close to writing one myself .. they all just don’t do exactly what I need#2017-09-2214:45thhellerbut dealing with all those crazy edge cases would probably drive me crazy#2017-09-2214:45thhellereven more than it does now 😉#2017-09-2214:48Jonso it would be smart if a language just compiles to CommonJS/ES6 module...#2017-09-2214:53thhellerit would be a whole lot simpler if everything used ES6#2017-09-2214:54thhellerbut that won’t happen anytime soon#2017-09-2214:54thhellerand in the meantime there will probably be a billion other things people invent to do package management#2017-09-2214:55Jon
=>> yarn
yarn install v1.0.2
[1/4] 🔍  Resolving packages...
warning Lockfile has incorrect entry for "
#2017-09-2214:55Jonbrowserify command installed now#2017-09-2215:32thheller@jiyinyiyong did you try other npm packages or just shortid?#2017-09-2215:35Jonjust hsl and shortid#2017-09-2215:41thhellergot shortid working#2017-09-2215:43thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3c4f545d58534b115f50564f7c0e120c120c115d504c545d0b"}, :content ("[email protected]")}#2017-09-2215:45thhelleroops that contains a rogue prn statement 😉#2017-09-2215:45Jonhaha#2017-09-2215:45thhellerwell need to fix something else anyway#2017-09-2215:52Jonconfirmed~#2017-09-2309:35bolasblackHi thheller, :cache-root works very well! I encountered NullPointerException when I compiling a file which using clojure.pprint/pprint#2017-09-2309:36bolasblack
NullPointerException:
        clojure.lang.Numbers.ops (Numbers.java:1013)
        clojure.lang.Numbers.minus (Numbers.java:137)
        clojure.lang.Numbers.minus (Numbers.java:3712)
        shadow.build.warnings/get-source-excerpts/make-source-excerpt--19935 (warnings.clj:24)
        shadow.build.warnings/get-source-excerpts/iter--19937--19941/fn--19942/fn--19943 (warnings.clj:40)
        shadow.build.warnings/get-source-excerpts/iter--19937--19941/fn--19942 (warnings.clj:39)
        clojure.lang.LazySeq.sval (LazySeq.java:40)
        clojure.lang.LazySeq.seq (LazySeq.java:49)
        clojure.lang.RT.seq (RT.java:525)
        clojure.core/seq--4944 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--7648 (protocols.clj:75)
        clojure.core.protocols/fn--7648 (protocols.clj:75)
        clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
        clojure.core/reduce (core.clj:6704)
        clojure.core/into (core.clj:6771)
        clojure.core/into (core.clj:6763)
        shadow.build.warnings/get-source-excerpts (warnings.clj:41)
        shadow.build.warnings/get-source-excerpts (warnings.clj:6)
        shadow.build/enhance-warnings (build.clj:29)
        shadow.build/enhance-warnings (build.clj:16)
        shadow.build/extract-build-info/fn--21260 (build.clj:84)
        clojure.core/map/fn--5406 (core.clj:2733)
        clojure.lang.LazySeq.sval (LazySeq.java:40)
        clojure.lang.LazySeq.seq (LazySeq.java:49)
        clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
        clojure.core/chunk-next (core.clj:700)
        clojure.core.protocols/fn--7660 (protocols.clj:137)
        clojure.core.protocols/fn--7660 (protocols.clj:124)
        clojure.core.protocols/fn--7620/G--7615--7629 (protocols.clj:19)
        clojure.core.protocols/seq-reduce (protocols.clj:31)
        clojure.core.protocols/fn--7648 (protocols.clj:75)
        clojure.core.protocols/fn--7648 (protocols.clj:75)
        clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
        clojure.core/reduce (core.clj:6704)
        clojure.core/into (core.clj:6771)
        clojure.core/into (core.clj:6763)
        shadow.build/extract-build-info (build.clj:86)
        shadow.build/extract-build-info (build.clj:59)
        shadow.build/update-build-info-after-compile (build.clj:97)
        shadow.build/update-build-info-after-compile (build.clj:95)
        shadow.build/compile (build.clj:259)
        shadow.build/compile (build.clj:248)
        shadow.cljs.devtools.api/release* (api.clj:223)
        shadow.cljs.devtools.api/release* (api.clj:210)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:25)
        shadow.cljs.devtools.cli/do-build-commands/fn--538/fn--539 (cli.clj:66)
        clojure.core/binding-conveyor-fn/fn--5297 (core.clj:2027)
        java.util.concurrent.FutureTask.run (FutureTask.java:266)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
        java.lang.Thread.run (Thread.java:748)
#2017-09-2309:37bolasblackThis is stack#2017-09-2309:40bolasblack
[{:warning :dynamic, :line 776, :column 5, :msg cljs.pprint/*print-base* not declared ^:dynamic, :extra {:ev {:name cljs.pprint/*print-base*, :ns cljs.pprint}, :name cljs.pprint/*print-base*}} {:warning :dynamic, :line 776, :column 5, :msg cljs.pprint/*print-circle* not declared ^:dynamic, :extra {:ev {:name cljs.pprint/*print-circle*, :ns cljs.pprint}, :name cljs.pprint/*print-circle*}} ...
This is part warning
#2017-09-2309:40thhellerweird#2017-09-2309:42thhellerI’ll add a generic catch, failing to get a source excerpt for the warning shouldn’t fail a build 😛#2017-09-2309:42bolasblackAnd I found some message: dead/moved: null#2017-09-2309:43bolasblackWhen Flushing optimized modules#2017-09-2309:43thhellerah yeah that should not be null#2017-09-2309:43bolasblackLike this
-> Flushing optimized modules
Flushing: goog.base.js (99 bytes)
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
Flushing: goog.math.integer.js (3813 bytes)
dead/moved: null
dead/moved: null
dead/moved: null
Flushing: cljs.core.js (138248 bytes)
dead/moved: null
Flushing: cljs.core.async.impl.buffers.js (140 bytes)
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
Flushing: cljs.core.async.impl.timers.js (220 bytes)
dead/moved: null
Flushing: cljs.core.async.js (807 bytes)
Flushing: clojure.string.js (1508 bytes)
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
dead/moved: null
Flushing: module$axios.js (137 bytes)
dead/moved: null
Flushing: cljs.nodejs.js (151 bytes)
Flushing: hubot.utils.macro.js (4168 bytes)
Flushing: hubot.utils.js (513 bytes)
Flushing: hubot.notify.js (5460 bytes)
dead/moved: null
Flushing: hubot.todoist.js (1350 bytes)
Flushing: cljs.pprint.js (138907 bytes)
Flushing: module$fs.js (142 bytes)
Flushing: module$path.js (136 bytes)
Flushing: module$glob.js (136 bytes)
Flushing: build.js (2198 bytes)
Flushing: hubot.hello.js (1587 bytes)
Flushing: hubot.codebuild.js (11703 bytes)
<- Flushing optimized modules (11 ms)
#2017-09-2309:44thhelleryeah it displays the wrong name, it is supposed to display the name of the file that was completely removed as dead code#2017-09-2309:44bolasblackSo much dead code 😂#2017-09-2309:44thhellerwell maybe thats not all that interesting after all. maybe I’ll just remove the message 😛#2017-09-2309:45thhelleryeah thats the amazing part of the closure compiler .. it removes sooo much stuff#2017-09-2309:45thhellerwell some parts may just be moved to other files so its not entirely dead#2017-09-2309:45thhellerbut still#2017-09-2309:48bolasblackAnd I found the code will always be optimized, even though I set :optimizations :none in :builds
#2017-09-2309:49bolasblackIs that in the expectation?#2017-09-2309:55thhellershadow-cljs release will always optimize yes. thats the point 🙂#2017-09-2309:55thhellershadow-cljs compile or watch will never optimize, no need to set optimizations#2017-09-2309:56thhellerthe config in shadow-cljs is basically always 2in1 if you are used to other tools#2017-09-2309:57thhelleryou can use :simple if you don’t want :advanced#2017-09-2310:05bolasblackAha, that's truly my fault, I forgot I'm using shadow-cljs release#2017-09-2407:49bolasblackHi theller, I found target/shadow-cljs/cache/ana not work with :cache-root when I called shadow-cljs watch#2017-09-2414:43bolasblackHi theller, I encountered this error
IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: java.lang.Boolean
        clojure.core/-cache-protocol-fn (core_deftype.clj:583)
         (io.clj:35)
         (io.clj:413)
         (io.clj:426)
         (io.clj:418)
        shadow.build.npm/make-browser-overrides/fn--19590 (npm.clj:29)
        clojure.core/fn--7874/fn--7876 (core.clj:6716)
        clojure.core.protocols/iter-reduce (protocols.clj:49)
        clojure.core.protocols/fn--7652 (protocols.clj:75)
        clojure.core.protocols/fn--7652 (protocols.clj:75)
        clojure.core.protocols/fn--7594/G--7589--7607 (protocols.clj:13)
        clojure.core/reduce (core.clj:6704)
        clojure.core/fn--7874 (core.clj:6706)
        clojure.core/fn--7874 (core.clj:6706)
        clojure.core.protocols/fn--7673/G--7668--7682 (protocols.clj:174)
        clojure.core/reduce-kv (core.clj:6732)
        clojure.core/reduce-kv (core.clj:6723)
        shadow.build.npm/make-browser-overrides (npm.clj:22)
        shadow.build.npm/make-browser-overrides (npm.clj:21)
        shadow.build.npm/read-package-json (npm.clj:69)
        shadow.build.npm/read-package-json (npm.clj:42)
        shadow.build.npm/find-package* (npm.clj:149)
        shadow.build.npm/find-package* (npm.clj:126)
        shadow.build.npm/find-package (npm.clj:155)
        shadow.build.npm/find-package (npm.clj:151)
        shadow.build.resolve/fn--19721 (resolve.clj:104)
        shadow.build.resolve/fn--19721 (resolve.clj:81)
        clojure.lang.MultiFn.invoke (MultiFn.java:238)
        shadow.build.resolve/resolve-string-require (resolve.clj:122)
        shadow.build.resolve/resolve-string-require (resolve.clj:108)
        shadow.build.resolve/resolve-string-require (resolve.clj:108)
        shadow.build.resolve/resolve-require (resolve.clj:225)
        shadow.build.resolve/resolve-require (resolve.clj:218)
        shadow.build.resolve/resolve-deps/fn--19705 (resolve.clj:56)
        clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
        clojure.core/reduce (core.clj:6703)
        clojure.core/reduce (core.clj:6686)
        shadow.cljs.util/reduce-> (util.clj:46)
        shadow.cljs.util/reduce-> (util.clj:45)
        shadow.build.resolve/resolve-deps (resolve.clj:54)
        shadow.build.resolve/resolve-deps (resolve.clj:37)
        shadow.build.resolve/resolve-symbol-require (resolve.clj:215)
        shadow.build.resolve/resolve-symbol-require (resolve.clj:189)
        shadow.build.resolve/resolve-require (resolve.clj:222)
        shadow.build.resolve/resolve-require (resolve.clj:218)
        shadow.build.resolve/resolve-deps/fn--19705 (resolve.clj:56)
        clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
        clojure.core/reduce (core.clj:6703)
        clojure.core/reduce (core.clj:6686)
        shadow.cljs.util/reduce-> (util.clj:46)
        shadow.cljs.util/reduce-> (util.clj:45)
        shadow.build.resolve/resolve-deps (resolve.clj:54)
        shadow.build.resolve/resolve-deps (resolve.clj:37)
        shadow.build.resolve/resolve-symbol-require (resolve.clj:215)
        shadow.build.resolve/resolve-symbol-require (resolve.clj:189)
        shadow.build.resolve/resolve-require (resolve.clj:222)
        shadow.build.resolve/resolve-require (resolve.clj:218)
        shadow.build.resolve/resolve-entry (resolve.clj:232)
        shadow.build.resolve/resolve-entry (resolve.clj:231)
...
#2017-09-2414:44bolasblackBut I didn't found shadow.build.npm/make-browser-overrides in source code 😂#2017-09-2507:23thheller@bolasblack make-browser-overrides is new, will fix. it doesn’t support "foo":false yet which is used to “ignore” certain require calls in the browser#2017-09-2507:24thhellerthe cache issue I found and fixed#2017-09-2507:38thheller@bolasblack do you know which npm package caused that error? need to find a package I can test my fix with 😛#2017-09-2507:58thhellernvm found one#2017-09-2512:25bolasblackI think aws-sdk caused this issue#2017-09-2512:26bolasblackAnd I got another exception:
package airtable tries to map request but it doesn't exist
{:from "request", :to "xhr", :package-name "airtable"}
ExceptionInfo: package airtable tries to map request but it doesn't exist
        clojure.core/ex-info (core.clj:4725)
        clojure.core/ex-info (core.clj:4725)
        shadow.build.npm/make-browser-overrides/fn--19590 (npm.clj:33)
        clojure.core/fn--7874/fn--7876 (core.clj:6716)
#2017-09-2512:28bolasblackI'm trying to use the package airtable in nodejs, and current shadow-cljs.edn :target is :npm-module#2017-09-2512:28bolasblack@thheller#2017-09-2514:35thheller@bolasblack I think I fixed that, I’ll make a release now so you can test it#2017-09-2514:35thheller
"browser": {
    "lib/aws.js": "./lib/browser.js",
    "fs": false,
    "./global.js": "./browser.js",
    "./lib/node_loader.js": "./lib/browser_loader.js"
  },
#2017-09-2514:36thhellerfun times though … "lib/aws.js" should be "./lib/aws.js" 😛#2017-09-2514:37thhellerare you running node?#2017-09-2514:37thhelleror :js-provider :closure?#2017-09-2514:37thhellernvm :npm-module thats :js-provider :require#2017-09-2514:37thhelleryeah definitely fixed#2017-09-2514:40thheller@bolasblack try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9aab1b8bdb6aef4bab5b3aa99ebf7e9f7e9f4b8b5a9b1b8e1"}, :content ("[email protected]")}#2017-09-2603:03bolasblackHi thheller, https://github.com/bolasblack/airtable-notifier-temp this is the example project. I'm trying to create a project runing on nodejs, check records changing in Airtable per minutes#2017-09-2603:04bolasblackI tried 2.0.0-alpha8, and get the error:
java.lang.AssertionError: Assert failed: (cljs-util/is-file-instance? cache-root)
        at shadow.cljs.devtools.config$make_cache_dir.invokeStatic(config.clj:112)
        at shadow.cljs.devtools.config$make_cache_dir.invoke(config.clj:112)
        at shadow.cljs.devtools.server.worker.impl$build_configure.invokeStatic(impl.clj:116)
        at shadow.cljs.devtools.server.worker.impl$build_configure.invoke(impl.clj:90)
        at shadow.cljs.devtools.server.worker.impl$fn__21954.invokeStatic(impl.clj:207)
        at shadow.cljs.devtools.server.worker.impl$fn__21954.invoke(impl.clj:199)
        at clojure.lang.MultiFn.invoke(MultiFn.java:233)
        at shadow.cljs.devtools.server.util$server_thread$fn__21838$fn__21839$fn__21843.invoke(util.clj:159)
        at shadow.cljs.devtools.server.util$server_thread$fn__21838$fn__21839.invoke(util.clj:158)
        at shadow.cljs.devtools.server.util$server_thread$fn__21838.invoke(util.clj:143)
        at clojure.core.async$thread_call$fn__7981.invoke(async.clj:442)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
#2017-09-2515:13JonI got an idea,#2017-09-2515:14Jondo you think it's possible that we bundle ClojureScript projects with a shared library called clojure-x.x.x.js and put this file in CDN?#2017-09-2515:15Jonif people are building multiple page websites, they can share this library without bundling it into each project#2017-09-2515:15Jonmeanwhile, there might be people who want to try ClojureScript as a part of project, like using :target :npm-module.#2017-09-2515:17Jonnot sure about this part, but we have to make sure when he imports the package, he does not require ClojureScript multiple times#2017-09-2515:20thheller@jiyinyiyong this would only be possible without :advanced optimizations …#2017-09-2515:22thhelleralso wouldn’t solve any issues I’m aware off#2017-09-2515:26Jon😥 then how about multi pages website?#2017-09-2515:27Jonhow do you share common code?#2017-09-2515:27thhellercode splitting via webpack or :modules?#2017-09-2515:28JonI don't think code splitting is enough#2017-09-2515:28Jonsay you split module a.js and b.js into libs.js in project A,#2017-09-2515:28Jonnot assurance that in project B libs.js is the same#2017-09-2515:30thhellernot sure what you are after? cross project splitting is never safe#2017-09-2515:30thhellermulti page website is one project with multiple “entries”?#2017-09-2515:31Jonmay be several projects, not sure#2017-09-2515:31thhellerin CLJS for :browser target you can :modules {:shared {:entries [cljs.core]} :page-a {:entries [app.page-a] :depends-on #{:shared}}, ...}#2017-09-2515:31thhellerbut no you cannot create something like jquery.js that is included in every project and never changed#2017-09-2515:32thhellerwell you could with a whole bunch of effort and sacrificing :advanced .. so not sure that would be worth anything#2017-09-2515:33Jon🤔 getting more and more confused about scaling ClojureScript into multiple pages#2017-09-2515:34thheller:modules is the way to go for :browser#2017-09-2515:35Jonif we have a solution for hosting ClojureScript libraries on CDN, that would be another factor to convince others of using ClojureScript. Anyway...#2017-09-2515:36thhellerthat just isn’t feasible for cljs, it just doesn’t work with :advanced#2017-09-2515:36thhelleralso not really an issue to be honest#2017-09-2515:36thhellerCDN is not a selling argument#2017-09-2515:37thhellerplay with :modules, it does all the code splitting you could ever want#2017-09-2515:37Jonbut if some has like 10 websites, each using ClojureScript, what's the best solution to reduce the bundle sizes?#2017-09-2515:38Jonby compiling with a single instance of shadow-cljs and rely on :modules?#2017-09-2515:38thhellerif the 10 websites are in one CLJS build use :modules#2017-09-2515:38thhellerif by websites you mean different domains, they shouldn’t share anything anyways#2017-09-2515:39Jonbut we used to do it for jquery, react, vue, lots of them...#2017-09-2515:40thheller“used to do it” … do you still do it?#2017-09-2515:40thhellerand yes it works for those libs since they don’t do :advanced optimizations …#2017-09-2515:41thhelleryes, that pattern will not work with CLJS#2017-09-2515:41thhellerit could work but only without :advanced, which would mean you’d download MORE#2017-09-2515:42thhellerso the opposite of what you want to achieve#2017-09-2515:42Jon😅 how about :simple#2017-09-2515:42thhellerthat is without :advanced … anything that is not :advanced#2017-09-2515:43Jonalright...#2017-09-2515:43thhellerlook at it this way#2017-09-2515:43Jonso the cljs runtime library will be huge?#2017-09-2515:43thhelleryou can have a CDN/cljs.js that is 2mb#2017-09-2515:43thhelleror you can have your-site/cljs.js that is 50kb#2017-09-2515:43Jon😱 even gzipped?#2017-09-2515:44thhellerI don’t know the exact size … but it is a whole lot bigger#2017-09-2515:44Jon😱 can't imagine..#2017-09-2515:44thhelleralso your-site/cljs.js will only contain code that your-site uses. so no useless code is executed#2017-09-2515:44thhellerie. FASTER than generic builds#2017-09-2515:45thhellerdon’t think that something is the best solution in the world only because the JS world is doing it#2017-09-2515:45thhellerthere are other options. each with its own pros/cons#2017-09-2515:46JonI don't have numbers to compare, just have to believe old experience 😞#2017-09-2515:46thhellerI don’t buy the whole CDN argument either#2017-09-2515:47thhellerdo the files in the image above actually come from a CDN?#2017-09-2515:48thhellerbtw. google is using the closure compiler for pretty much all their public projects. I think they know a thing or two about optimizing download sizes#2017-09-2515:49thhellerservice worker … so no CDN#2017-09-2515:50Jonno CDN#2017-09-2515:50Jonfrom CDN... only the first time they are downloaded#2017-09-2515:50thhellerwhy are they using shadow? 😛#2017-09-2515:51thhellerreally I wouldn’t worry about it too much#2017-09-2515:51Jonwell, at least I'm convinced now...#2017-09-2515:51Jonwhat "shadow"?#2017-09-2515:51thhelleryou can still do react,vue,jquery as externals from a CDN#2017-09-2515:51thhellertheir domain is #2017-09-2515:52Jonwow... surprised me too, didn't notice#2017-09-2515:52Jonmany of us learn English at an older age, I guess#2017-09-2515:53Jonthen how about using ClojureScript partially in a Webpack projects?#2017-09-2515:53Jonlike creating a package with cljs, or packages... then require them in Webpack,#2017-09-2515:54Jonit seems that there will be multiple versions of runtime library, if the code are precompiled to js or somehow#2017-09-2516:10thhelleryou are free to do that if you want … it just won’t be optimal#2017-09-2516:11thhellerand no you are not supposed to use multiple “optimized” libs in one project#2017-09-2516:11thhellerthat is not “whole program optimization”#2017-09-2516:11Jonjavascript ecosystem is a mess 🙂#2017-09-2516:11thhellerI really don’t understand what problem you are trying to solve. is there an actual problem you have right now that is not just theoretical?#2017-09-2516:12thhelleronly because it is not what the JS world does doesn’t mean its better or worse#2017-09-2516:12thhellerits just different#2017-09-2516:13thheller:advanced is totally optional .. nobody forces you do use it#2017-09-2516:13Jonwhen I'm learning new things, I just want to use my old technology and try if it works well.. and I'm not alone.#2017-09-2516:13JonI think many people from js world would try it in those ways too.#2017-09-2516:13thhellerbut how do you learn new things if you expect them to be identical to old things?#2017-09-2516:14thhellerit is absolutely true that CLJS (and shadow-cljs) needs better documentation for these topics#2017-09-2516:14Jononly I tried then I realized it's just different#2017-09-2516:14thhellereven a comparison would be desirable showing the pros/cons of both#2017-09-2516:15Jonexamples I think 🙂#2017-09-2516:15thhellerits just hard making comparisons without good real world examples#2017-09-2516:15Jondo you create real world projects in cljs?#2017-09-2516:15thhellerits just rare to find someone that has experience with the JS solutions and the CLJS ones#2017-09-2516:16thhelleryes I do .. but they weren’t JS before#2017-09-2516:16Jonyeah... totally two languages and two ecosystems#2017-09-2516:17thhellerI have never used webpack in an actual project for example#2017-09-2516:17thhellerin my pre-CLJS days it didn’t exist#2017-09-2516:17JonI think webpack is older than you think#2017-09-2516:18Jon"Mar 4, 2012 – Sep 23, 2017"#2017-09-2516:19thhellerwell maybe it existed but I never heard of it back then#2017-09-2516:20thhellerI have been on my own CLJS tooling since mid-2013#2017-09-2516:20Jonme too..#2017-09-2516:20Jonthat's like four years#2017-09-2516:20thhellershadow-build had the first public release on 14 Dec 2013#2017-09-2516:20thhellerbut I had used it for a while before then#2017-09-2516:20thhellerand lein-cljsbuild before that#2017-09-2516:21Jon...almost 4#2017-09-2516:21thhellerso yeah .. safe to say webpack didn’t exist when I was doing pure JS work 😉#2017-09-2516:21thhellerI think I never used actual JS tools back then either#2017-09-2516:21thhellerjust a bunch of custom shell scripts + coffescript#2017-09-2516:21Jonhaha...#2017-09-2516:22thhellernode didn’t exist either … I’m old 😉#2017-09-2516:22JonI was using CoffeeScript too, it's like in Shanghai there's only one company choosing CoffeeScript as primary language. Now no company...#2017-09-2602:29bolasblackNot only one company, the company I'm working for is also worked with CoffeeScript as the main programming language in backend and frontend. After nodejs 6.x and react, we start use JavaScript because of ES6 feature#2017-09-2516:22thhellerI wouldn’t use it again either#2017-09-2516:22JonNode was born in 2009~#2017-09-2516:23thhellerI only used it because I was doing ruby at the time and coffeescript looked more like ruby than JS#2017-09-2516:23thhellerreally? ok guess it did exist then 😉#2017-09-2516:23Jonwell. CoffeeScript was my first language to create real world apps..#2017-09-2516:24thhellerit wasn’t commonly used though … all my tooling was ruby based#2017-09-2516:24Jonbefore that I learnt to write scripts in Python. learnt C in classes also but never really know how to use it.#2017-09-2516:24JonRuby was cool..#2017-09-2516:25Jonwe just have Ruby Conf in China a week a ago... however it was full of other languages#2017-09-2516:25thhellerI went from Pascal, Perl, PHP2, JS, Ruby, CoffeeScript, Erlang, Clojure#2017-09-2516:25thhellerwith a bit of C and python inbetween#2017-09-2516:25Jon😂 like Haskell, Elixir, Erlang. I heard they talked about that#2017-09-2516:25thhelleroh and I forgot Java for a very long time 🙂#2017-09-2516:26JonMuch longer history...#2017-09-2516:26thhelleryeah been doing (professionally) this since 1998 or so 😉#2017-09-2516:26Jonalmost 20 years, like several people I just met...#2017-09-2516:27thhellerlearned coding earlier#2017-09-2516:27Jonnot many people in China say they have written code for almost 20 years..#2017-09-2516:27Joncool#2017-09-2516:28thhellerwell it took me a couple of years to unlearn some crap, wish I started functional earlier 🙂#2017-09-2516:28thhellersoo much time wasted on OOP#2017-09-2516:29JonI'm not sure if you hate on the same parts of OOP as I do... I don't know much about OOP, although heard a lot.#2017-09-2516:29JonReact is using OOP even it learned a lot from FP. It appears OOP is still the mainstream#2017-09-2516:30thhellerwell it isn’t all bad, sometimes it is useful#2017-09-2516:31thhellerthe Clojure “data-first” approach is better though#2017-09-2516:32Jonagreed, but hard to explain it.#2017-09-2516:33JonI feel the most when people say Redux is so complicated. and I think it should not be like that.#2017-09-2516:34Jonoh, just old topic, actually someone told me he wants to use ClojureScript in his project, partially. and I recommended shadow-cljs somehow...#2017-09-2516:34Jonon WeChat, we have a group, chatty but half the topics are related to Clojure(Script)#2017-09-2516:35thhellerI see whenever someones “stars” shadow-cljs on github … most of the people are from your region#2017-09-2516:35Jonwell...#2017-09-2516:35thhellernot too many stars yet … once I finish the 2.0 release I will start blogging#2017-09-2516:36thhellerwith examples and stuff. need to get better documentation.#2017-09-2516:36thhellerjust have to finish the JS integration story since that has been bothering me for quite a while now#2017-09-2516:37Jononly people speaking Chinese are related to me. Too many languages in Asia#2017-09-2516:37Jonlike more then 3 months?#2017-09-2516:38thhellerwell since day #1 but cljsjs was a good enough fix for me since I basically only used cljsjs.react#2017-09-2516:38thhellereverything else I wrote myself instead of using JS libs#2017-09-2516:45Jonreinventing everything.#2017-09-2516:47thhelleryeah … good because you learn how everything works .. bad because it takes way too much time from doing actual useful stuff 😉#2017-09-2516:50Jonto he honest I don't like doing that#2017-09-2516:51Joneven though it's good to learn things in detail, but there are too many things to learn, and working in a startup company in my age, I feel not good#2017-09-2516:52Jonso most the time I spent just looking for solutions.#2017-09-2516:53thhelleryeah but sometimes the solution is 3 lines of code instead of some generic library#2017-09-2516:53Jonwhich means?#2017-09-2516:53thhellerthat using a library is not always the best solution#2017-09-2516:54Jonright... that happened a lot on npm#2017-09-2516:54Jon3 lines of code can be a nice solution sometimes ;D#2017-09-2516:55thhellerlots of code on npm is also written by inexperienced coders, so sometimes their solution may not be “good” either#2017-09-2516:55thhellervetting dependencies is sometimes more work than just writing it yourself#2017-09-2516:56thhellerblindly using dependencies often creates more issues than they solve#2017-09-2516:56thhellerprogramming is hard …#2017-09-2516:57JonI know that, many js programmers do not have computer science background. I'm one of them.#2017-09-2516:57thhellerI have no formal education either … I learned programming by reading a book when I was 14 or so#2017-09-2516:57thhellerlots of trial and error since then#2017-09-2516:58thhellerI still don’t know how to program really .. always amazed why anything works at all 😉#2017-09-2516:58JonI was learning math, but felt so boring, and taught myself using Linux and creating webpages.#2017-09-2516:59Jonprogramming like in the old days, can't image. papers and holes?#2017-09-2516:59Jonor tape?#2017-09-2517:00thhellerhehe I started on a 286sx with 6mhz#2017-09-2517:01thhellerI remember how upgrading to 8mb of RAM was huge#2017-09-2517:01JonWindows?#2017-09-2517:01thhellerthats so insane compared to today#2017-09-2517:01thhellerno. no windows back then, just DOS#2017-09-2517:01Jonoh, IBM...#2017-09-2517:02Jonguess I have never seen it#2017-09-2517:05Jonso late, going to bed. bye#2017-09-2517:06thhellerhttps://twitter.com/jcsrb/status/807242764438138884 thats how I started programming 😉#2017-09-2517:06thhellergn8 😉#2017-09-2604:33Jonin which city?#2017-09-2604:34JonCoffeeScript has not been updated for long time. Only released 2.0 very recently.#2017-09-2604:35Jonand by using CoffeeScript, it first compiles to ES2015+ , and it has to be compiled with Babel for old browsers.#2017-09-2604:50bolasblackIn Shanghai, Caohejing Development Zone#2017-09-2604:51bolasblackI know CoffeeScript released 2.0 recent, but we have given up using CoffeeScript now 😂#2017-09-2604:52bolasblackBecause of some JavaScript tools have poor support for CoffeeScript#2017-09-2604:54Jonwhen did you start using coffee#2017-09-2604:54Jonwell... teambition gave up coffee too, very recently#2017-09-2604:57bolasblackI start use coffee from at least 2012……Maybe more earlier, I didn't remember#2017-09-2604:57Jonthat's even earlier than teambition..#2017-09-2604:57Jonhow many people. why never heard of you#2017-09-2604:58bolasblackBut my current company start use coffee at 2015 I think...#2017-09-2604:59bolasblackI convince two company to use coffee 😛, include current company#2017-09-2604:59Jonteambition started using CoffeeScript in 2013, switched from Python#2017-09-2605:00bolasblackBut they are all startup company, so you have not heard of them is normal#2017-09-2605:00Jonbut it did not contribute back to the original project, only got to switch to ES6 when they found coffee pooly maintained#2017-09-2605:00Jonteambition was a startup too, at least in 2014, only 20+ people#2017-09-2605:01bolasblack😂 my two company only 10+- people both#2017-09-2605:02bolasblackI'm current working for Pomotodo/Duohui, I think you didn't heard#2017-09-2605:04Jonnever heard#2017-09-2605:04JonChinese name?#2017-09-2605:05bolasblack番茄土豆/多会#2017-09-2605:05Jonnever heard..#2017-09-2605:06bolasblackI have been hesitant to apply for http://ele.me employees 3 years ago, but I heard that they no longer use CoffeeScript, so I gave up#2017-09-2605:07JonI don't know..#2017-09-2605:07Jonat least sofish does not like CoffeeScript when I was there#2017-09-2605:08Jonin late 2016#2017-09-2605:09Jonare you in WeChat group? maybe we chat in WeChat...#2017-09-2605:09bolasblackI'm not in WeChat group#2017-09-2605:09bolasblack😂#2017-09-2605:09Jon200+ members already, although not many Clojure programmers#2017-09-2605:09Jonadd me by jiyinyiyong#2017-09-2608:30thheller@bolasblack sorry for the sketchy release quality, just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2b58434a4f445c06484741586b19051b051b064a475b434a1a1b"}, :content ("[email protected]")} which should fix your issues#2017-09-2608:31thhellerI compiled your project with the require comments removed#2017-09-2608:31thhelleraws-sdk and airtable now work afaict 😛#2017-09-2608:31bolasblackCool!#2017-09-2608:31thhelleralso fixed the cache-root properly#2017-09-2608:33thhellerone thing I’m not too sure about is whether or not I should check if a package exists, that seems somewhat limiting#2017-09-2608:33thhellerie. if you (:require ["airtable" :as ...]) the compiler checks whether node_modules/airtable exists#2017-09-2608:34thhellerthat really is not required and will break if you installed airtable to global or some other parent path#2017-09-2608:34thhellernode will happily find it#2017-09-2608:34thhellerI might add a :check-packages true|false option so its less strict#2017-09-2608:36bolasblackI think shadow-cljs needn't check it, because webpack/browserify/(or runtime? user will get an error) will check it ?#2017-09-2608:36thhelleryeah, exactly#2017-09-2608:37thhellerthe only reason it is checking is because CLJS core allows (:require [react ...]) which is a magical symbol that ONLY works if node_modules/react exists#2017-09-2608:37thhellerbut in case of a string I don’t need to check since I already know that it is a JS dependency#2017-09-2608:37thhellerso keep using strings 😉#2017-09-2608:38thhellerall the issues you had were due to the check not properly running on some package.json files#2017-09-2608:38bolasblackI even don't know CLJS core support that 😂#2017-09-2608:39bolasblackI tried alpha10, it works very well!#2017-09-2608:39thhellerphew finally 🙂#2017-09-2608:40bolasblackThanks for your work, shadow-cljs is much much much much better than lein-cljsbuild or boot-cljs for me 😉#2017-09-2608:41thhellerand we are just getting started#2017-09-2609:49thhellerupdated the blog post https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-09-2609:50thhellerstill need to finish some code before I’ll post it to the usual sources#2017-09-2609:50thhellerbut if you guys have some feedback I’m all ears 🙂#2017-09-2610:07thheller@jiyinyiyong webpack uses uglifyjs to minify things correct?#2017-09-2610:07thhellerah, found it. https://www.npmjs.com/package/uglifyjs-webpack-plugin#2017-09-2610:09Jonyep, https://webpack.js.org/plugins/uglifyjs-webpack-plugin/#usage#2017-09-2610:10Jondo you still prefer a shorter name for shadow-cljs?#2017-09-2610:11thhellernot sure, I think I used it too much already to change it#2017-09-2610:11thhellerbut since it is now able to compile pure JS projects we might need something more generic 😉#2017-09-2610:12Jonupdating packages and namespace would be huge work I think#2017-09-2610:12JonI was suggesting "coleujs" anyway..#2017-09-2610:15thhelleryeah I saw .. didn’t like it too much#2017-09-2610:17thhellerdo I seriously have to replace process.env.NODE_ENV? I thought uglify-js would be able to do that?#2017-09-2610:17thhellernot cool#2017-09-2614:29Jonplaying with my new Macbook... migrating configs#2017-09-2614:29Jonwhen I was configuring Webpack, I still have to replace that, during bundling for production#2017-09-2614:30JonOr maybe a name starts with s, I don't think it's as good as col.. though http://www.southernliving.com/plants/s#2017-09-2615:02thhellernot worried about the name too much … more important things to do 😉#2017-09-2615:26Jonwell, the name is the most interesting part, actually I don't like the "-" in the name.. we have lein-cljs boot-cljs, as a result shadow-cljs sounds like there's a thing called shadow. 😂#2017-09-2616:44thhellerhehe just ran react v16 through my bundler#2017-09-2616:44thheller
------ WARNING #1 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:1122:2

 unreachable code
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:1155:2

 unreachable code
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:2865:2

 unreachable code
--------------------------------------------------------------------------------

------ WARNING #4 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:12560:4

 unreachable code
--------------------------------------------------------------------------------

------ WARNING #5 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:16870:4

 unreachable code
--------------------------------------------------------------------------------

------ WARNING #6 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.development.js:16879:4

 unreachable code
--------------------------------------------------------------------------------
#2017-09-2616:44thhellerguess I should tell someone 😉#2017-09-2616:45thheller
// Flow needs the return null here, but ESLint complains about it.
  // eslint-disable-next-line no-unreachable
#2017-09-2616:45thhellerguess they know#2017-09-2616:53Jonflow looks good 😄#2017-09-2709:17thhellerI might have solved :externs by accident#2017-09-2709:17thhellerI did not expect the closure compiler to be this smart#2017-09-2709:18thhellerwell not fully but this is working far better than I expected 😛#2017-09-2709:49thhellerplease test {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "93e0fbf2f7fce4bef0fff9e0d3a1bda3bda3bef2ffe3fbf2a2a2"}, :content ("[email protected]")} with as many JS dependencies as you can find 😉#2017-09-2711:37thhellerdammit … guess we still need :externs#2017-09-2714:19Jon😉#2017-09-2715:03bolasblackHi @thheller, I got an error when I trying require core.async
The required namespace "cljs.core.async.macros" is not available, it was required by "notifier/core.cljs" {:tag :shadow.build.resolve/missing-ns, :stack [{:resource-id [:shadow.build.classpath/resource "notifier/core.cljs"], :deps #{[:shadow.build.classpath/resource "goog/base.js"] [:shadow.build.classpath/resource "cljs/core.cljs"]}}], :ns cljs.core.async.macros}
ExceptionInfo: The required namespace "cljs.core.async.macros" is not available, it was required by "notifier/core.cljs"
        clojure.core/ex-info (core.clj:4725)
        clojure.core/ex-info (core.clj:4725)
        shadow.build.resolve/resolve-symbol-require (resolve.clj:209)
It only exist when I want to require core.async, when I use [andare](https://github.com/mfikes/andare) (A fork of core.async ported for use with bootstrapped ClojureScript.), shadow-cljs works well, and notify me
duplicate resource cljs/core/async/impl/buffers.cljs on classpath, using jar:file:/Users/c4605/.m2/repository/org/clojure/co
re.async/0.3.443/core.async-0.3.443.jar!/cljs/core/async/impl/buffers.cljs over jar:file:/Users/c4605/.m2/repository/andare/andare
/0.7.0/andare-0.7.0.jar!/cljs/core/async/impl/buffers.cljs
#2017-09-2715:04bolasblackI updated code in https://github.com/bolasblack/airtable-notifier-temp#2017-09-2715:24bolasblackSeems this error caused by I'm using (:require [cljs.core.async.macros :refer-macros [...], when I switch to :require-macros, the compile passed#2017-09-2717:00thhellerwhy would you use andare? @bolasblack#2017-09-2801:52bolasblackBecause require core.async macro throw error, so I want to check out where the problem is...#2017-09-2801:52bolasblackSo I tried andare 😁#2017-09-2717:05thhelleralways use (:require-macros [cljs.core.async.macros ...]), :require is not valid in this case#2017-09-2800:11thhellerguess I’m ready for extended feedback#2017-09-2800:11thhellerhttps://www.reddit.com/r/Clojure/comments/72wf86/shadowcljs_js_dependencies_going_forward/#2017-09-2800:13thhellerhttps://twitter.com/thheller/status/913194903290761216#2017-09-2802:56shaunlebronjust wanted to chime in and say I’ve been using shadow-cljs happily for a few days#2017-09-2802:57shaunlebronjust been using a basic watch and repl setup for a web app#2017-09-2802:58shaunlebronerrors are good, and warnings survive across file saves
#2017-09-2802:59shaunlebronone thing I noticed is that ctrl+c exits the repl instead of exiting the current command, and running it with rlwrap doesn’t allow up-arrow to recall commands from previous session#2017-09-2803:00shaunlebronregarding externs, I’ve decided to avoid the problem and just use cljs-oops for all js-related interop#2017-09-2804:02Jonnot using REPL, how do you use REPL?#2017-09-2807:06thheller@shaunlebron I don’t think ctrl+c can work in a CLJS environment, there is nothing like Thread.interrupt in JS. not sure how to make history work.#2017-09-2818:03thhellerjust pushed a new version that properly caches the JS dependencies which should make incremental compilation fast again#2017-09-2905:47Jondid you mean "faster"?#2017-09-2907:29Jonhttps://github.com/thheller/shadow-cljs/issues/100#2017-09-2910:05Jonhttps://github.com/thheller/shadow-cljs/blame/57cb5bb02858165018c5631c1887bceecba2ae62/src/main/shadow/cljs/devtools/server/worker/impl.clj#L358#2017-09-2910:06Jondiffs too huge, but should this line be removed?#2017-09-2910:06Jon
Sep 29, 2017 5:51:17 PM clojure.tools.logging$eval334$fn__337 invoke
WARNING: build-update: [[:shadow.build.classpath/resource "respo_ui/comp/home.cljs"] [:shadow.build.classpath/resource "respo_ui/comp/widgets_page.cljs"]]
[:browser] Compiling ...
[:browser] Build completed. (172 files, 3 compiled, 0 warnings, 0.16s)
#2017-09-2910:06Jonthe logs I saw..#2017-09-2910:11thhellerright, that should be a debug log. fixed.#2017-09-2911:15thhellerreact+react-dom v15 is 49.8 kb gzipped when using the “offical” bundle#2017-09-2911:15thheller47.8 KB when bundled by shadow-cljs .. I think thats a solid result 🙂#2017-09-2911:16thhellerbetter than expected#2017-09-2911:17thhellerneed to compare to webpack still but I’m happy with the result#2017-09-2912:53JonClosure Compiler is great, although I don't like it 🙃#2017-09-2912:55thhellerthe imported JS deps only use :simple so its pretty much the same uglifyjs would do#2017-09-2912:55thhellerwithout the need to shell out to a node process#2017-09-2912:55thhellerI like the Closure Compiler a lot 😉#2017-09-2912:57Jonwell, to me, it's Java, and it's in Google rather than in the community#2017-09-2913:11thhellertrue, still open source though. the “community” is just small and inside google since not many people outside use it.#2017-09-2913:12thhellerAFAICT the CLJS compiler is still pretty much the only compile-to-JS language to embrace it#2017-09-2913:50JonI asked BuckleScript's author, he said it might be bad idea part of the compiler is not controlled by ClojureScript community itself.#2017-09-2913:51JonI see that like when you are using the core of cljs compiler, David got different ideas from yours.#2017-09-2913:55Jonsomehow immutable data is like a library to BuckleScript and it does not worry about the cost of immutable data, feeling strange. while in cljs it's a big thing.#2017-09-2913:59JonI just imagine, maybe when we get rid of closure compiler, then we may possible to do things we didn't notice before. like self-hosted cljs by removing dependency of Java.#2017-09-2914:04Jonback in 2014 when I was joined a company, they were using Closure Compiler at first, but as we tried to setup the toolchains of compiling the whole project including lots of Gulpfile, Require.js , Closure Compiler does don't work with it. it was not in the ecosystem, even though it was great, we just couldn't make use of it with JavaScript skills.#2017-09-2914:24thhellerwell Closure Compiler is only about the FINAL stage of a build, only the optimizing part. just like shadow-cljs watch doesn’t use it at all you only need it when you want to optimize.#2017-09-2914:24thhellerCLJS runs just fine without it#2017-09-2914:25thhellerbut … Closure already has pretty good ES6 support#2017-09-2914:25thhellerso if you write your code in ES6 chances are pretty good that it will just work#2017-09-2914:25thhellerits the non-ES6 part thats tricky#2017-09-2914:25thhellerbut once people start adopting ES6 more and more it will get easier to use the Closure Compiler for the final step#2017-09-2914:35Jonmuch better at this moment since it has CommonJS and ES6 support 😄#2017-09-2914:36Jonby the way do you feel like suppressing the logs even more?#2017-09-2914:38JonI mean, when I run shadow-cljs watch app, it's too much logs... not a big deal though, but I made some changes to my cumulo-editor, print some of the logs in grey, removed some logs, colorized some important one's. It quite much different as it looks.#2017-09-2914:39thhelleryeah it logs too much, I want to reduce it down the essentials#2017-09-2914:39thhellerjust didn’t get to it yet#2017-09-2914:40thhellerI still have this plan of building an actual UI for this so it isn’t all based on streaming a bunch of characters somewhere#2017-09-2914:41thhellerstep by step 😉#2017-09-2914:54JonI almost forgot you have some plan for UI...#2017-09-2921:54shaunlebron@jiyinyiyong to answer your earlier question. I use shadow-cljs cljs-repl <build-id>. it’s a browser connected repl you can run alongside watch.#2017-09-3002:03Jonin which cases will you use a REPL? you see, I never used the REPL since I started using shadow-cljs.#2017-09-3002:04Jon...only trying snippets in Lumo.#2017-09-3003:12Jonhttps://twitter.com/bobzhang1988/status/913961433305513984#2017-09-3003:12Jon😟#2017-09-3007:14Jontrying with my old project, turned out hot code swapping for :target :nodejs not working.#2017-09-3007:14Jonhttps://github.com/Cumulo/cumulo-workflow/blob/master/server/shadow-cljs.edn#2017-09-3014:06thheller@jiyinyiyong thx, fixed#2017-09-3014:08Jon😄 thx too#2017-09-3021:29ivanpierre@thheller I can grab and install the last git of shadow-cljs w/o problem? I'm testing with a double install, boot an shadow-cljs. Way easier with the later... 😉#2017-10-0108:03thheller@ivanpierre what do you mean? shouldn’t need git?#2017-10-0108:25ivanpierreNo, I mean I've installed the current version 1.0.20170803 on github. Is this the last preview ?#2017-10-0109:04thhellerno 2.0.2 is current, installable via {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f88b90999c978fd59b94928bb8969d808c"}, :content ("[email protected]")}.#2017-10-0109:05thhellerbut I’m dropping the @next in the next version#2017-10-0109:05thhellerdidn’t make much sense to use it anyways 😉#2017-10-0109:05thhellerare you trying to use shadow-cljs from within boot? or just standalone?#2017-10-0109:07Jonrequesting for a 2.0.3 with fix on nodejs hmr.#2017-10-0109:24thheller@jiyinyiyong working on it now, just one more fix I wanted to do#2017-10-0109:27thhellerpushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f6859e97929981db959a9c85b6c4d8c6d8c5"}, :content ("[email protected]")} no more next required#2017-10-0109:33thhellerhmm whats the proper way to tell npm that @next should not be used anymore?#2017-10-0109:42ivanpierreI have for now 2 compilations. One with boot and boot-cljs and one with shadow-cljs.#2017-10-0109:44thhellerah I thought you were trying shadow-cljs from within boot, which is possible but not all recommended 😉#2017-10-0109:44ivanpierreI've seen that 😄#2017-10-0109:52thhellerhttps://twitter.com/thheller/status/914427680690405378#2017-10-0109:53thhellerplease vote/share!#2017-10-0109:58thhellertrying to work out how important it would be to support things like .jsx#2017-10-0111:18JonI would develop my js code in a standalone project... and then import#2017-10-0111:18Jonmixing js code in cljs project is hard to maintain. I'm not ready for two js compilers...#2017-10-0205:47Jon
The required namespace "cljsjs.highlight" is not available, it was required by "respo_markdown/main.cljs".
#2017-10-0205:48Jonany changes to cljsjs packages?#2017-10-0205:49Jonmeanwhile there are quite some errors when I switched to highlight.js from npm.#2017-10-0205:49Jon
Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/actionscript.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$actionscript", function(require,module,exports) {module.exports = function(hljs) {
^^^^^^^^^^^^^^^^^^^^^^^^^

Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/ada.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$ada", function(require,module,exports) {module.exports = // We try to support full Ada2012
^^^^^^^^^^^^^^^^^^^^^^^^^

Oct 02, 2017 1:47:40 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/highlight.js/lib/languages/apache.js:1: ERROR - required "shadow.js" namespace never provided
goog.require("shadow.js");shadow.js.provide("module$node_modules$highlight_js$lib$languages$apache", function(require,module,exports) {module.exports = function(hljs) {
^^^^^^^^^^^^^^^^^^^^^^^^^
#2017-10-0206:15Jonhttp://clojureverse.org/t/how-to-import-dev-only-package-in-cljs-like-cljs-devtools/576#2017-10-0206:16Jonfor highlightjs issue, I end it up with https://cdnjs.com/libraries/highlight.js ...#2017-10-0208:20thheller@jiyinyiyong read BREAKING CHANGE section about :foreign-libs https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-10-0208:20thhellerI’ll check why highlight.js doesn’t work#2017-10-0208:21thhellerI think their packaging is weird#2017-10-0208:32thhellershould be fixed in 2.0.5. it is not ideal to use their npm package since that will unconditionally include support for ALL languages#2017-10-0208:32thhellerprobably best to build your own via https://highlightjs.org/download/#2017-10-0208:32thhellerand include that instead#2017-10-0208:33thhelleryou can include any .js files via#2017-10-0208:33thheller
:js-options
   {:resolve
    {"highlight.js"
     {:target :file
      :file "lib/highlight.pack.js"}}}
#2017-10-0208:34thhellerso whenever you ["highlight.js" :as hljs] in your code, it will include that file#2017-10-0208:35thhellerbut does matter for now the npm package should work, its just bigger than it needs to be#2017-10-0210:22JonNow I think CDN is a better choice for highlight.js ...#2017-10-0210:23Jonbuilding highlight.js locally is much more hard to maintain#2017-10-0210:24thhellerwell not much more work than using a CDN really#2017-10-0210:24Jonso huge...#2017-10-0210:25JonI guess I have to open another repo if I want to maintain my own bundle#2017-10-0210:25Jonhow would you build highlight.js BTW?#2017-10-0210:25thhelleron my site I just did this once https://highlightjs.org/download/#2017-10-0210:26thhelleradded the languages I want and done#2017-10-0210:26Jon...and save it locally in the same project?#2017-10-0210:26thhelleryep#2017-10-0210:26thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-10-0210:26Jonwell, sound cool... just I don't want to include it in my repo#2017-10-0210:27thhelleruses highlight.js 😉#2017-10-0210:27thhellerI don’t know what the webpack world does#2017-10-0210:27thhellerprobably some kind of custom management as well#2017-10-0210:27thhellerits really the way the highlight.js package is built#2017-10-0210:27thhellercljsjs is actually quite nice in this case#2017-10-0210:28Jonwell, on your blog, it's just highlight.js#2017-10-0210:28thhellerbut I can’t add support for :foreign-libs without creating more issues than its worth#2017-10-0210:28thhelleryeah it is. but its probably the way I would use it in a CLJS project as well#2017-10-0210:28thhellersince its really just a library, it doesn’t interact with anything else#2017-10-0210:28Jonyou are right about highlight.js , no idea how we custom build that in Webpack#2017-10-0210:29JonI think putting it on my server would be slow#2017-10-0210:29JonCDN is way faster#2017-10-0210:30thhellerbut CDN doesn’t have the customized package#2017-10-0210:30thhellerso you probably need more than one request#2017-10-0210:30thhellerwhich probably makes it slower#2017-10-0210:30thhellerdepends on the number of languages you want to support#2017-10-0210:31Jonfixing my example#2017-10-0210:32thhellergiven that it will probably be updated very infrequently I think the manual build is fine for now#2017-10-0210:32thhellerI do like what cljsjs has done in this case#2017-10-0210:33Jonwell....#2017-10-0210:33thhellerbut that is basically just a custom build 😉#2017-10-0210:33thhellerexterns#2017-10-0210:33JonI was wrong#2017-10-0210:34thhelleradd hljs.initHighlightingOnLoad; to an externs file#2017-10-0210:34thhellerassuming thats what you are calling#2017-10-0210:35Jonactually I never managed to create an extern file before#2017-10-0210:35Jontried when using Boot, but failed#2017-10-0210:36thhelleryou create a file with whatever name#2017-10-0210:36Jonhow does shadow-cljs discover that file?#2017-10-0210:36thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/externs.js#2017-10-0210:36thhellerbasically like that file#2017-10-0210:37thhellerfor every name that is “foreign” you add a property#2017-10-0210:37thhellerX.prototype.initHighlightingOnLoad; in your case#2017-10-0210:37thhellerthe X is not ideal but it works#2017-10-0210:37Jonyep...#2017-10-0210:37thhellerthat file you include in your build via#2017-10-0210:37Jonhot how is it recognized by the compiler?#2017-10-0210:37thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L36-L38#2017-10-0210:38thhellerso :compiler-options {:externs ["path/to/file.js"]}#2017-10-0210:38thhellershadow-cljs check your-build should tell you that initHighlightingOnLoad is an unknown property#2017-10-0210:39thhellerwhich means it needs externs#2017-10-0210:39Jonsounds cool..#2017-10-0210:39thhellerexterns basically just tell the closure compiler about names it is not allowed to remove or rename#2017-10-0210:39thhellerI’m still working out the details on how to generate that automatically#2017-10-0210:41thhellerthe danger is in overly generic externs since they might prevent code from being removed that you weren’t actually using#2017-10-0210:41thhellerwhich is why shadow-cljs check exists#2017-10-0210:43Jonis it really possible to generate externs automatically#2017-10-0210:44Jonin theory...#2017-10-0210:44thhellergenerating them yes, ensuring that they are accurate no#2017-10-0210:45thhellerthe problem is that externs prevent any kind of optimization#2017-10-0210:45thhellerso if you generate too much thats bad for filesize#2017-10-0210:46JonI think it's working now http://repo.respo.site/markdown/#2017-10-0210:46thhellerif you generate too little you get errors#2017-10-0210:46thhellerboth bad … but at this point I’d rather generate too much than deal with errors 😉#2017-10-0210:46Jonfirst make it work, second make it performant~#2017-10-0210:47thhellerit does work … manually 😉#2017-10-0210:48Jonexterns it's like magic. - -#2017-10-0210:48Jonit's so strange, I tried it before but it didn't work#2017-10-0210:49Jonhow about code like event.target? I notice Closure Compiler optimizes that too?#2017-10-0210:50thhellerdefault externs cover that#2017-10-0210:50thhellerit has built-in externs for all the web standards stuff#2017-10-0210:51JonI mean, when I access a DOM Element, define a local variable, and use (.-x el) to access it#2017-10-0210:51Jonthe code is optimized, and it was broken#2017-10-0210:53thhellerthen it wasn’t target? or the Closure Compiler thought it was not of type Event and renamed it#2017-10-0210:53JonI guess so.#2017-10-0210:57thhellerah no I misunderstood#2017-10-0210:57JonI never really understood how externs work though.#2017-10-0210:57thhelleryou can’t just define .-x#2017-10-0210:57Jonwell...#2017-10-0210:58thhellerbut anyways .. externs are really simple … it is just external names really. so if the closure compiler find a name it doesn’t recognize it know what to do with it#2017-10-0211:00Jonlike variables that can be accessed from global? (not local variables?)#2017-10-0211:01thhellerlocal variables do not need externs since they are always safe to rename#2017-10-0211:01thhellerI assume you mean property?#2017-10-0211:02Jonbut not properties..#2017-10-0211:02Jonyep#2017-10-0211:02thhellersee you example. it didn’t recognize hljs.initHighlightingOnLoad so it renamed it to hljs.Qc#2017-10-0211:03thhellerit didn’t rename hljs since it is a bit less aggressive with global vars#2017-10-0211:03Jonwhile hljs is actually window.hljs...#2017-10-0211:03thhellerbut properties on global vars will be renamed#2017-10-0211:04Jonexcept for ones with externs...#2017-10-0211:04thhelleryes, exactly#2017-10-0211:05thhellerexterns are the big stop sign that says “do not rename this”, “do not delete this”.#2017-10-0211:05Jonright...#2017-10-0211:07Jonbut still, for local variable of Event, if properties are renamed, it's bad#2017-10-0211:07thhellerI do not know what you mean by local variable#2017-10-0211:07Jonevent...#2017-10-0211:07thheller(let [x 1] ...) x is a local variable#2017-10-0211:08thhelleryou are talking about property which is different (I think)#2017-10-0211:08thhellerneed code example#2017-10-0211:08Jon
"input" {:type :input, :value (aget (.-target event) "value")}
        "change" {:type :change, :value (aget (.-target event) "value")}
#2017-10-0211:09Jonthat "value"#2017-10-0211:09thhellerdepends on what event is#2017-10-0211:10thhellerhttps://github.com/google/closure-compiler/tree/master/externs/browser#2017-10-0211:11thhellerthose are the default externs. things in there should be covered#2017-10-0211:19thheller> I noticed there was a formatter before. But it did not working recently.#2017-10-0211:20thhellercan you be more specific? what didn’t work? it should always work?#2017-10-0211:21Jonif I use (.-value (.-target event)) the value part will be renamed, but it should be event.target.value#2017-10-0211:21Jonso I switched to aget and string#2017-10-0211:23thhellerI have used that many times and never had issues with renaming#2017-10-0211:24thhellerbut as I said .. the compiler might get confused about event and not use the correct type#2017-10-0211:24Jonwell... not sure now, it was old codebase. I was trying to solve that with externs, but didn't managed to do it.#2017-10-0211:24thhellerhard to tell without all the code#2017-10-0211:24Jonanyway it's enough for my current problem.#2017-10-0211:24thhellerusing the :externs example from above X.prototype.value would have been enough#2017-10-0211:25thhellershadow-cljs check might have explained as well#2017-10-0211:25Jonthanks anyway...#2017-10-0211:29Jonat least I learnt externs today...#2017-10-0213:37geraldodevcan shadow-cljs co exist with figwheel ?#2017-10-0215:28thheller@geraldodev sure but it can do almost anything that figwheel does, so why would you want to? 🙂#2017-10-0215:29thhelleronly part thats missing is live reloading for css#2017-10-0215:29thhellerlive reloading of code and REPL just works#2017-10-0217:55geraldodev@thheller nice#2017-10-0300:21mhuebertI’m trying to get a project building with shadow-cljs, and running into a problem compiling tools.reader:#2017-10-0300:21mhuebert
failed to compile resource: [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"]
{:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"], :url #object[java.net.URL 0x2be3d771 "jar:file:/Users/MattPro/.m2/repository/org/clojure/tools.reader/1.0.5/tools.reader-1.0.5.jar!/cljs/tools/reader/reader_types.cljs"], :file nil, :line 43, :column 1, :source-excerpt {:start-idx 38, :before [";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ";; reader deftypes" ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ""], :line "(deftype StringReader", :after ["    [s s-len ^:mutable s-pos]" "  Reader" "  (read-char [reader]" "    (when (> s-len s-pos)" "      (let [r (.charAt s s-pos)]"]}}
ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "cljs/tools/reader/reader_types.cljs"]
...
Caused by:
ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
	clojure.core/symbol (core.clj:579)
	clojure.core/symbol (core.clj:574)
	cljs.analyzer/dep-has-global-exports? (analyzer.cljc:763)
	cljs.analyzer/dep-has-global-exports? (analyzer.cljc:759)
#2017-10-0300:21mhuebertfull stacktrace: https://gist.github.com/mhuebert/ea628936b0bccd8c3890c8ef4867880d#2017-10-0300:45mhuebertin shadow.cljs is [org.clojure/tools.reader "1.0.5"]#2017-10-0300:47mhuebertshadow-cljs version 2.0.6#2017-10-0307:55thheller@mhuebert very confusing error, not sure how it ends up on that path. it compiles fine for me. might be a case of broken metadata which causes it to report the wrong location. will look into it#2017-10-0309:10thhellerno idea what could cause this.#2017-10-0309:11thhellerjust released 2.0.7 which bumps the clj(s) versions, should not affect that error but who knows#2017-10-0310:21mhuebert@thheller is there any equivalent of lein clean to try in a case like this?#2017-10-0310:22mhuebertother than just removing the out directory#2017-10-0310:29mhueberttried with 2.0.7 and deleted tools.reader from my repository (to fetch again) and deleted the target folder. same error, but much nicer formatting. agree it is very weird.
File: nil
--------------------------------------------------------------------------------
...
  42 |
  43 | (deftype StringReader
-------^------------------------------------------------------------------------
  44 |     [s s-len ^:mutable s-pos]
  ...
--------------------------------------------------------------------------------
ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
	clojure.core/symbol (core.clj:579)
	clojure.core/symbol (core.clj:574)
	cljs.analyzer/dep-has-global-exports? (analyzer.cljc:763)
#2017-10-0310:30mhueberti believe i require these as clojure.tools.reader (w/o reader conditionals), could the aliasing have anything to do with it?#2017-10-0310:50thhellerI fixed the error format, guess I missed the File: nil 😉#2017-10-0310:50thhellershouldn’t have anything to do with the aliasing but might#2017-10-0310:51thhellerI’ll check that#2017-10-0310:52mhuebertafter switching all the tools.reader requires to reader conditionals, I get a different error, related to “cljs.repl” and ‘Unable to find static field: INFERRED_CONST_CHECKS’, full stacktrace: https://gist.github.com/mhuebert/263433cd01df6053f237d9671c3c6e41#2017-10-0310:52thheller [clojure.tools.reader.reader-types :as read]#2017-10-0310:53thhellerhmm weird, do you import cljs.closure somewhere?#2017-10-0310:54thhellerI made sure to never import that anywhere#2017-10-0310:54thhellerdo you use shadow-cljs standalone or embedded in lein or boot?#2017-10-0310:55thhellerah wait cljs.repl requires cljs.closure#2017-10-0310:56mhuebertstandalone#2017-10-0310:56thhellerthe weird thing is that I can compile everything just fine#2017-10-0310:56thhellermaybe some weird AOT artifact#2017-10-0310:57thhellercan you delete target/shadow-cljs completely and restart the shadow-cljs process?#2017-10-0310:58mhueberthave you tried compiling with a require to `[clojure.tools.reader.reader-types] (instead of cljs.tools.reader)?#2017-10-0310:58thheller
[clojure.tools.reader.reader-types :as read]
            [cljs.repl :as r]
#2017-10-0310:58mhueberttried deleting target & recompile, same thing#2017-10-0310:58thhellercompiled just fine#2017-10-0310:58thhellerwhat are your :dependencies? maybe there is an old version of closure in there somehow?#2017-10-0310:59thhellertry starting shadow-cljs clj-repl and then (require 'cljs.repl)#2017-10-0311:00thhellerthat should not fail#2017-10-0311:00mhuebertdoes shadow-cljs have a way to print the dep tree#2017-10-0311:00thhellershadow-cljs --cli-info#2017-10-0311:00mhuebertso that fails for me#2017-10-0311:00thhellernot a proper tree but it lists dependencies#2017-10-0311:00mhuebertthe repl#2017-10-0311:01mhuebert
mattpro:editor MattPro$ shadow-cljs clj-repl
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.7
shadow-cljs - starting ...
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
shadow-cljs - server running at 
shadow-cljs - socket repl running at localhost:62834
shadow-cljs - nrepl running at localhost/127.0.0.1:62836
shadow-cljs - REPL - see (help), :repl/quit to exit
[1:0]~shadow.user=> (require 'cljs.repl)
CompilerException java.lang.RuntimeException: Unable to find static field: INFERRED_CONST_CHECKS in class com.google.javascript.jscomp.DiagnosticGroups, compiling:(cljs/closure.clj:100:1)
#2017-10-0311:02thhellerwhat the heck … those boolean? warnings shouldn’t be there#2017-10-0311:02mhuebertin .lein/profiles.clj i have [lein-count "1.0.2"] [lein-clojars "0.9.1"] [lein-release "1.0.6"]#2017-10-0311:03thheller
[
#2017-10-0311:03thhellerthats how it supposed to look#2017-10-0311:03mhuebertthose boolean? warnings appear on my system no matter what tooling i use, and am unsure of why, even if i comment everything out in .lein/profiles#2017-10-0311:04thheller.lein/profiles doesn’t affect shadow-cljs#2017-10-0311:04thhellercan you paste shadow-cljs --cli-info?#2017-10-0311:04thhelleronly thing I can think of is deps conflict#2017-10-0311:05mhuebertcli-info: https://gist.github.com/mhuebert/92187cd721d5c2fbf23df158f60673d2#2017-10-0311:06thheller[maven] org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar how does that get there#2017-10-0311:06thhellerdo you have it in :dependencies?#2017-10-0311:07mhuebertyes#2017-10-0311:07mhuebertsorry i was going to paste that earlier.#2017-10-0311:07thhellerplease remove that. forgot to guard against that.#2017-10-0311:08mhuebertah ok. i had an error with the clojure dependency but not cljs, hence i thought cljs was required#2017-10-0311:08thhellerits fine in theory but there were some breaking changes in CLJS+Closure recently#2017-10-0311:08mhuebert
[1:0]~shadow.user=> (require 'cljs.repl)
CompilerException java.lang.RuntimeException: No such var: util/normalize-path, compiling:(cljs/closure.clj:1601:22)
#2017-10-0311:08thhellerthat might be AOT now#2017-10-0311:09thhellerdelete target/shadow-cljs just to be safe#2017-10-0311:09mhuebertok i’ll clear it out#2017-10-0311:09mhueberti still wonder why i get these WARNING‘s about boolean?.#2017-10-0311:09mhuebert🎉#2017-10-0311:09mhuebertok requiring ‘cljs.repl works now#2017-10-0311:09mhuebertgoing to try compiling the project again#2017-10-0311:10mhuebert
cljs/core.cljs [line 988, col 14] No reader function for tag Inf.
{:type :reader-exception, :ex-kind :reader-error, :file "cljs/core.cljs", :line 988, :col 14}
ExceptionInfo: cljs/core.cljs [line 988, col 14] No reader function for tag Inf.
#2017-10-0311:11thhellerhmm maybe tools.reader in your :dependencies still?#2017-10-0311:11thhellerI really need to make the whole dependencies resolution more robust#2017-10-0311:11mhuebertis the latest tools.reader included automatically? i need it for my app#2017-10-0311:11thhelleryes#2017-10-0311:12thhellerCLJS always ships with tools.reader#2017-10-0311:12thheller1.1.0 is the latest version that fixes the Inf issue above#2017-10-0311:12mhuebertah ok, i need to remove it from a bunch of things in my project then#2017-10-0311:13thhellerok the problem is that shadow-cljs already depends on those things but if you declare them in :dependencies they overwrite the version that shadow-cljs wants#2017-10-0311:14thhellerI need to fix that or at least warn#2017-10-0311:15mhuebertso shadow-cljs will ignore the project.clj in the current directory but still use the deps listed in the dependencies#2017-10-0311:16mhuebertsomewhere i have tools.reader-1.0.3 in clj-info#2017-10-0311:16thhellershadow-cljs does not use lein in any way unless you tell it to#2017-10-0311:16thhellerso project.clj might as well not exist#2017-10-0311:17thhellerdeps only whats listed in :dependencies in shadow-cljs.edn#2017-10-0311:17mhueberti mean transitive deps#2017-10-0311:18thhellerNot sure what you mean? it uses the same lib that lein uses to resolve dependencies, so the same rules apply#2017-10-0311:20thhellerin theory the tools.reader dep of shadow-cljs should be chosen since its 1.1.0#2017-10-0311:20mhueberti mean somewhere in a transitive dependency of my project, an old version of tools.reader is included, [maven] org/clojure/tools.reader/1.0.3/tools.reader-1.0.3.jar#2017-10-0311:20mhuebertit shows up when i run --cli-info and I am guessing that’s why i am still getting the Inf error#2017-10-0311:21thhellerah ok. yes thats the source of the Inf error#2017-10-0311:21mhuebertbut i am not sure yet where it is being included#2017-10-0311:21thhellercan you give me your :dependencies so I can track this down properly?#2017-10-0311:22mhueberti have a bunch of local libs unfortunately which might make that complicated because i’ve been makign changes to them during this debugging process so there are a bunch of undeployed snapshots#2017-10-0311:22mhuebertis there a way to see a tree of dependencies / see where a particular dep is coming from?#2017-10-0311:22thhellerah ok, you could try lein deps :tree if you have a project.clj anyways#2017-10-0311:23thhellerno but I will definitely add the tree visualizer, the flat list is kinda useless#2017-10-0311:24thhellereasy fix would be to just add [org.clojure/tools.reader "1.1.0"] to your deps (I think)
#2017-10-0311:27mhuebertso the only place 1.0.3 from tools.reader exists is in cljs 1.9.854#2017-10-0311:28mhuebertwhich is listed in several project.clj‘s of my dependencies#2017-10-0311:28thhellerdoes it still list 1.9.854 in --cli-info?#2017-10-0311:29thhellerI might be wrong in my understanding of how maven resolves dependency conflicts#2017-10-0311:29mhuebertno, it lists 1.9.946#2017-10-0311:30mhuebertbut i added [org.clojure/tools.reader "1.1.0"] to shadow-cljs.edn#2017-10-0311:30thhellerbtw libraries should always use [org.clojure/clojurescript "1.9.854" :scope :provided]#2017-10-0312:26mhuebert@thheller tiny correction, should be :scope "provided"#2017-10-0311:30mhuebertand that didn’t change#2017-10-0311:30mhuebertah ok, i didn’t know that#2017-10-0311:30thhellertry deleting the AOT cache#2017-10-0311:31thhellerI’m regretting a bit that I relaxed the AOT compiler to only recompile when the shadow-cljs version changes#2017-10-0311:31thhellermistakingly assumed that would be enough 😛#2017-10-0311:32mhuebertmaybe whenever deps change#2017-10-0311:32thhellerit was whenever deps changed but it doesn’t really need to re-compile AOT when you change the version of a CLJS lib#2017-10-0311:33mhueberti like how fast shadow-cljs usually give me feedback. more errors, earlier, than other tools i’ve used#2017-10-0311:33thhellerI don’t like that the errors are so hard to track though 😉#2017-10-0311:33mhuebertok, it is building, just a warning from transit
------ WARNING #1 --------------------------------------------------------------
 File: :332:1
--------------------------------------------------------------------------------
 328 |   "Construct a URI from a string."
 329 |   [s]
 330 |   (ty/uri s))
 331 |
 332 | (defn uri?
-------^------------------------------------------------------------------------
 uri? already refers to: cljs.core/uri? being replaced by: cognitect.transit/uri?
--------------------------------------------------------------------------------
 333 |   "Returns true if x is a transit URI value, false otherwise."
 334 |   [x]
 335 |   (ty/isURI x))
 336 |
 337 | (defn uuid
--------------------------------------------------------------------------------
#2017-10-0311:34thhellerold transit version probably 😛#2017-10-0311:34thhellerwhy the heck is File: always empty, I need to fix that#2017-10-0311:37thhellerah found it#2017-10-0311:37mhuebertah.. goog.require could not find: cljs.core$macros#2017-10-0311:37mhuebertmaybe this is related to self-host stuff#2017-10-0311:38thhelleryeah I still didn’t get to that#2017-10-0311:38thhellernot the slightest idea how self host works#2017-10-0311:38mhuebertok#2017-10-0311:38thhellerwhat do you use it for?#2017-10-0311:38mhueberthttps://www.maria.cloud, an editor environment#2017-10-0311:39thhellercool#2017-10-0311:39thhellerlet me check, maybe its just a property I forgot to set#2017-10-0311:41mhuebertso in the existing (non-shadow) build, window.cljs.core$macros is there, missing here#2017-10-0311:43mhueberthttps://github.com/clojure/clojurescript/blob/300e326b83ba4110657bb646a9d396c5cb666501/src/main/clojure/cljs/closure.clj#L690#2017-10-0311:43thhelleryeah I don’t compile the self hosted stuff properly#2017-10-0311:43thhellerthat just adds the dep, need to find where it compiles the macros#2017-10-0311:45thheller
(ns cljs.js
  (:refer-clojure :exclude [require])
  (:require-macros [cljs.js :refer [dump-core]]
                   [cljs.env.macros :as env])
  (:require [clojure.string :as string]
            [clojure.walk :as walk]
            [cljs.env :as env]
            [cljs.spec.alpha]
            [cljs.analyzer :as ana]
            [cljs.compiler :as comp]
            [cljs.tools.reader :as r]
            [cljs.tools.reader.reader-types :as rt]
            [cljs.tagged-literals :as tags]
            [goog.crypt.base64 :as base64]
            [cljs.source-map :as sm])
  (:import [goog.string StringBuffer]))

(js/goog.require "cljs.core$macros")
#2017-10-0311:45thhellerthis is just plain weird 😛#2017-10-0311:45mhuebertlast time I talked to dnolen about this he said that core$macros are handled as a special case, other macro files are not compiled, you have to provide them manually (which is a big PITA)#2017-10-0311:46mhuebertand yes, weird!#2017-10-0311:48thhellerstill trying to figure out where exactly it gets compiled, there a whole lot of special cases for cljs.core$macros#2017-10-0311:48thhellerhad hoped for a cljs.compiler.api/compile-macro-ns or so 🙂#2017-10-0311:51mhuebertyeah! that would be nice. there is the jira issue: https://dev.clojure.org/jira/browse/CLJS-2270#2017-10-0311:51mhuebertso there is openness to improving it#2017-10-0312:01thhellerNot enough time but I will look into it later today https://github.com/thheller/shadow-cljs/issues/103#2017-10-0312:01thhellerIt should not be hard, found a :macro-ns option that seems to control it#2017-10-0312:02thhellerjust a bunch of special cases in the code I don’t quite understand yet#2017-10-0312:02mhuebertok. i realize this may be a messy thing. if we can get it working i would be very happy to use shadow-cljs for all of Maria’s builds, i really prefer it in the small cases i’ve tried#2017-10-0312:02thhellerI definitely want to support this use case. It just scares me since I don’t really understand how self host works 🙂#2017-10-0312:03mhuebertplus i could probably use shadow-cljs to do the AOT macro compiles 🙂#2017-10-0312:03thhellermakes my head hurt just thinking about it 🙂#2017-10-0312:03thhellerif I figure out how to compile cljs.core it should be easy to extend it to others as well#2017-10-0312:03mhuebertyeah, this stuff is annoying.#2017-10-0314:30ivanpierreFeedback from my tests, definitively shadow is nice for node + electron... perhaps doc 😉 need help ?#2017-10-0314:34ivanpierreI looked on the lumo integration as repl, seems tedious. I have to look more on the whole ecosystem... coming from clojure.... 😉#2017-10-0316:09ivanpierreBut I have to put it on wheels with boot and lein. Big problems with boot pods that wipe the whole directory, hard to put your main.js in root of the project... well, not hard, but you loose the whole thing after compile 😄#2017-10-0316:17richiardiandrea@ivanpierre there has been some discussion about lumo repl integration in the lumo channel...I am very fond of the Language Server Protocol for that also seeing it is now supported everywhere but I haven't got around to doing it#2017-10-0320:10thheller@mhuebert can you give a minimal example cljs.js snippet so I can test if it works?#2017-10-0320:11thhellerI have never used it before and don’t know how to verify if the macro compile worked#2017-10-0320:38thhellernevermind found one#2017-10-0322:29mhuebertsorry just saw this now#2017-10-0407:44thheller@mhuebert do you know if the CLJS compiler will read macro files with :clj or :cljs conditionals?#2017-10-0407:44thhelleronly references I can find is :cljs but that does not seem correct to me?#2017-10-0408:20thheller@mhuebert mind if I take your site an example for why :foreign-libs are bad? 🙂#2017-10-0408:23thhelleryou do have 4 seperate react versions in your page at https://www.maria.cloud/intro#2017-10-0408:23thheller2 for iframe, 2 for main#2017-10-0409:11mhuebert@thheller :-). I don't mind at all. I noticed the duplicates a couple days ago and was one reason why I was trying to switch to your js system. (The duplicates between the two frames is another story though. One frame has to be advanced compiled, the other can't be, and they load from different domains for security reasons. I would need to load React separately, from the same domain in both frames, & only once. The only way I know how to do that is deps.clj with an empty js file 'providing' react with a :global-exports option. I have encountered so many troubles with this stuff)#2017-10-0409:12mhuebert@thheller that depends on if you are compiling from the self hosted compiler or not#2017-10-0409:12thhellerI think I have this self-host stuff almost figured out#2017-10-0409:13thhelleryeah not saying that my stuff would fix all your issues, just that :foreign-libs is bad 😉#2017-10-0409:14mhuebertI believe that if we AOT compile macros then it must take the :clj branch because it is java doing the compiling, but if you run macros from self-host it takes the :cljs branch #2017-10-0409:14thhellerbut at least in my version you can tell the compiler :js-options {:resolve {"react" {:target :global :global "React"}}} in config 😉#2017-10-0409:14mhuebert@thheller: that is exactly what I want to be able to specify with one of these fake empty js files #2017-10-0409:15mhuebertPlus it is a huge pain now that cljs will just magically decide whether to take my js from what i specify in deps.clj or go read from node_modules#2017-10-0409:16thhellerindeed, thats why my stuff is completely different. 🙂#2017-10-0409:16mhuebertSometimes to fix a build I have to 'yarn remove <pkg>'#2017-10-0409:16thhellerdoh#2017-10-0409:17thheller
(ns demo.selfhost
  (:require [cljs.js :as self]))

(defn compile-it []
  (js/console.log
    (self/compile-str
      (self/empty-state)
      "(ns my.user) (map inc [1 2 3])"
      ""
      {:eval self/js-eval}
      identity)))
#2017-10-0409:17thhellerI just compiled this and it worked#2017-10-0409:17thhelleronly weird thing I need to figure out is loading order since cljs.js has this weird hack for goog.require#2017-10-0409:18thhellerdo you have a bootstrap method for your stuff?#2017-10-0409:18thhellerie. before compiling anything load a bunch of stuff async?#2017-10-0409:19thhellerseems like that would be a better place to load cljs.core$macros and others#2017-10-0409:19thhellerdoing it via goog.require seems bad#2017-10-0409:19mhuebertHmm#2017-10-0409:19thhelleror do you just not have any other macros?#2017-10-0409:21thhellerI saw yourcljs-live stuff which seems to do that kind of thing#2017-10-0409:21mhuebertI AOT-compile everything into bundles which I load asynchronously yes#2017-10-0409:21mhuebertYes exactly, I think it's in the 'compile' namespace#2017-10-0409:21mhuebertI had to do an ugly hack around goog.require too#2017-10-0409:22thhellermy current thinking is to do a normal compile for your “build”, then do a second pass that just adds everything you want for self host#2017-10-0409:23thheller
{:build-id :selfhost
        :target :browser

        :output-dir "out/demo-selfhost/public/js"
        :asset-path "/js"

        :build-options
        {:self-host
         {:module :base
          :macros [cljs.core
                   cljs.spec.alpha]}}

        :modules
        {:base
         {:entries [demo.selfhost]}}}
#2017-10-0409:23mhuebertSo in that case macros are compiled using js / :cljs branch#2017-10-0409:23mhuebertYeah#2017-10-0409:23thhellerthe question then becomes bootstrapping the whole thing#2017-10-0409:24thhellerloading everything the way closure wants to is too slow#2017-10-0409:24thhellerwhich is why you build cljs-live I think#2017-10-0409:25thhellerproblem I have currently is that cljs.js does not really require cljs.core$macros when loading#2017-10-0409:25mhuebertYes, there is just one network request per bundle, organized as json file with classpath-like 'paths' as keys#2017-10-0409:25thhelleronly when actually using the compile/eval#2017-10-0409:25mhuebertThat's not bad tho?#2017-10-0409:26mhuebertEg with Maria I want things to load on-demand because otherwise start time is too slow#2017-10-0409:26thhellerthe issue is load order#2017-10-0409:27thhellerwell doesn’t matter much, I just need to patch the deps a bit#2017-10-0409:27thhellerthe issue is that goog.require usually is a no-op#2017-10-0409:27thhellerie. the goog loader will ensure that the deps were actually loaded BEFORE loading the actual file#2017-10-0409:28thhellerbut since cljs.js does not formally declare the dep on cljs.core$macros#2017-10-0409:28thhellerit will trigger the goog.require out-of-order#2017-10-0409:28mhuebert*Also analysis caches are necessary for anything one wants to use in self-host#2017-10-0409:29mhuebertHmm. I think I manually load macros before anything else #2017-10-0409:29thhelleryeah I saw, but thats just dumping the env data to a file. thats easy.#2017-10-0409:29mhuebert(Not all macros, just core)#2017-10-0409:32thhellerhow does your build config look currently?#2017-10-0409:33thhelleris it just a normal build and then a bunch of tooling to provide the self-host things you need?#2017-10-0409:33thhellersay if I just modify shadow-cljs to properly compile macro namespaces you could work with that?#2017-10-0409:34mhuebertby build config, do you mean like compiler options?#2017-10-0409:35thhellerlein-cljsbuild config or whatever you are using to build the live.js#2017-10-0409:35thhellerdo you do something special to the build itself#2017-10-0409:35thhelleror is all that done by a library outside the build#2017-10-0409:36thhellerAFAICT you need a way to compile macros and get the analyzer data#2017-10-0409:36mhueberthere is my cljs-live config where i package stuff to use for self-host: https://github.com/mhuebert/maria/blob/master/editor/live-deps.clj#L8#2017-10-0409:36mhuebertyes#2017-10-0409:36mhuebertso, if you added this ability to AOT compile macros, I would (attempt to) modify cljs-live to use shadow-cljs, and it would remove one step (manually doing a 2nd pass with self-host compiler).#2017-10-0409:37thhellerright so its a post-process step#2017-10-0409:37mhuebertyes. so I need a way to get access to analysis caches,#2017-10-0409:38thhellerso what I can do for you: a) compile a list of macro namespaces, dump them in a location of your choosing#2017-10-0409:38thhellerb) also dump analysis cache of certain namespaces#2017-10-0409:38thhellerc) provide dependency information so you know when to load what#2017-10-0409:38mhuebertcan it dump all analysis caches (w/o specifying which)#2017-10-0409:38mhuebertthat sounds good#2017-10-0409:39thhellersure it can dump everything#2017-10-0409:40thhellertransit is fine correct?#2017-10-0409:41mhuebertis it faster to spit edn?#2017-10-0409:41thhellerspit is almost the same. read is quite a lot faster with transit#2017-10-0409:41mhuebertok then yes transit’s good#2017-10-0409:42mhuebertre: dependencies, that would relate to this problem: https://github.com/braintripping/cljs-live/blob/master/src/cljs_live/compiler.cljs#L15#2017-10-0409:45thhellerhmm how does the self host compiler load resources?#2017-10-0409:45thhellerdoes it load resources?#2017-10-0409:46thhellerthe compile process in shadow-cljs is quite different so I actually don’t know how the cljs compiler does it 😛#2017-10-0409:47thhellerie. if you want to compile-str (ns my.demo (:require [something.foo :as x])) but something.foo is not yet loaded. what happens?#2017-10-0409:47mhuebertyou have to provide your own load function#2017-10-0409:47mhuebertmine is here: https://github.com/braintripping/cljs-live/blob/master/src/cljs_live/compiler.cljs#L93#2017-10-0409:48mhueberti am doing some manual tracking of loads in that namespace#2017-10-0409:49mhuebertcljs-live bundles include a “name-to-path” key which maps namespaces to file-paths#2017-10-0409:49thhellerare there any docs on this?#2017-10-0409:49thhellerkinda hard to tell whats going on#2017-10-0409:50mhuebertthere is the readme but i am not sure it goes into that level of detail: https://github.com/braintripping/cljs-live#2017-10-0409:54mhuebertso i think load-fn is always called when you (require) something. it is up to load-fn to (a) know if it has already been loaded or not, and if not, (b) provide a source file and analysis cache. the source file can be compiled js or uncompiled clj*#2017-10-0409:55thhellerok, I have a plan 😉#2017-10-0409:56mhuebertload-fn gets namespaces as input and must map that to source. so we need to know which names map to which “files”#2017-10-0409:56thhellerAFAICT you need 2 seperate builds#2017-10-0409:56thhellerone that ensures that your “app” itself can be loaded properly#2017-10-0409:57thhellerone that “bootstrap” the compiler with macro namespaces, analyzer data, etc#2017-10-0409:57thhellerbuild a then loads b#2017-10-0409:58mhuebertyes#2017-10-0409:59thhelleryeah I think that should work#2017-10-0410:00mhuebertand an important thing, certainly in my case but I think generally, is that these secondary builds, you might want to have a number of them and be able to load them independently / at a time of your choosing. Because they are quite large. cljs.core analysis cache + cljs.core$macros w/ cache is 900kb. the maria bundle is 1.5mb, clojure spec + deps is 1.8mb#2017-10-0410:00thhelleryou have done most of the work already#2017-10-0410:00thhelleryeah I have an idea for that#2017-10-0410:00mhuebert🙂#2017-10-0410:01thhelleryeah keeping it separate solves a whole bunch of issues#2017-10-0410:03mhuebertit is important that the self-host compiler / bootstrap loader does not re-evaluate stuff that was already loaded by the “app” build#2017-10-0410:04thhelleryeah, thats easy though#2017-10-0410:04mhuebertwith the right information at hand, yes 🙂#2017-10-0410:05thhellerInformation: I have it all! 😉#2017-10-0411:33thheller@mhuebert so far I create a “bootstrap.index.json” (transit) which contains infos like this#2017-10-0411:34thheller
{:type :cljs,
  :provides #{cljs.compiler},
  :requires
  #{cljs.tools.reader goog.string cljs.core goog cljs.env
    goog.string.StringBuffer clojure.set cljs.analyzer cljs.source-map
    clojure.string},
  :resource-name "cljs/compiler.cljc",
  :output-name "cljs.compiler.js"}
 {:type :cljs,
  :provides #{cljs.core$macros},
  :requires
  #{cljs.compiler cljs.core cljs.env clojure.set cljs.analyzer
    clojure.string clojure.walk},
  :resource-name "cljs/core$macros.cljc",
  :output-name "cljs.core$macros.js"}
 {:type :cljs,
  :provides #{cljs.analyzer.api},
  :requires #{cljs.core goog cljs.env cljs.analyzer},
  :resource-name "cljs/analyzer/api.cljc",
  :output-name "cljs.analyzer.api.js"}
 {:type :cljs,
  :provides #{cljs.spec.gen.alpha},
  :requires #{cljs.core goog},
  :resource-name "cljs/spec/gen/alpha.cljs",
  :output-name "cljs.spec.gen.alpha.js"}
 {:type :cljs,
  :provides #{cljs.spec.alpha$macros},
  :requires
  #{cljs.core goog cljs.analyzer.api cljs.env cljs.analyzer
    clojure.string clojure.walk cljs.spec.gen.alpha},
  :resource-name "cljs/spec/alpha$macros.cljc",
  :output-name "cljs.spec.alpha$macros.js"}
#2017-10-0411:34thhellerthe idea is to load this index on startup, build a runtime index out of the :requires/:provides#2017-10-0411:35thhellerthen either load the compiled :output-name files in :load or the :resource-name file and compile that#2017-10-0411:35thhellerdoes that sound useful?#2017-10-0411:35mhuebertyup#2017-10-0411:35thheller+ the compiler will add a list of namespaces that were already loaded by the build#2017-10-0411:36thhellerso you can keep track of it easily#2017-10-0411:36mhuebertby ‘the build’ you mean the 1st/app build#2017-10-0411:37thhelleryes#2017-10-0411:37thheller
'{:build-id :selfhost
        :target :browser

        :output-dir "out/demo-selfhost/public/js"
        :asset-path "/js"

        :bootstrap-options
        {:entries []
         :macros [cljs.spec.alpha]}

        :modules
        {:base
         {:entries [demo.selfhost]}}}
#2017-10-0411:37thhellerthis is how it looks for now#2017-10-0411:37thhellerin :bootstrap-options you declare which namespaces should be precompiled#2017-10-0411:38thhellerso if you want the user to be able to use reagent but you don’t use it yourself#2017-10-0411:38thhelleryou just add :entries [reagent.core]#2017-10-0411:38thhellersame for :macros#2017-10-0411:39thhellershould be about the same result as your cljs-live#2017-10-0411:40mhuebertdoes it follow macro dependencies? ie. if you require namespace x which requires x$macros#2017-10-0411:40thhellernot sure if it needs to pre-compile everything or just use :entries to copy the requires sources so cljs.js can compile it#2017-10-0411:40thhellernot yet but it will#2017-10-0411:41mhuebertcompiling is super slow in the browser, if things aren’t precompiled it can be multiple-second wait times#2017-10-0411:41mhueberton a fast computer#2017-10-0411:41thhellerah ok so pre-compile should be the default#2017-10-0411:41mhuebertin my opinion yes#2017-10-0411:43thhellerI think I have the basics now, I’ll try to put together something that actually works#2017-10-0411:44mhueberti remember encountering subtle issues with macros. normally if i wanted to use a namespace, i wanted to include the macros it uses as well. but some macros are not self-host compatible, so i added :entry/exclude and :entry/no-follow.#2017-10-0411:45thhellerhmm yeah didn’t deal with that yet#2017-10-0411:45mhuebertin your example - we specify explicitly which macro namespaces we want, and then shadow would ensure that those macro namespaces & their dependencies are loaded#2017-10-0411:46thhelleryes#2017-10-0411:46thhellerno, not loaded. available.#2017-10-0411:47mhuebertright#2017-10-0411:47thhellerit just copies everything required into a special folder#2017-10-0411:47thheller
(ns demo.selfhost
  (:require [cljs.js :as cljs]
            [shadow.bootstrap :as boot]))

(boot/init
  (fn []
    (cljs/compile-str
      (cljs/empty-state)
      "(ns my.user) (map inc [1 2 3])"
      ""
      {:eval cljs/js-eval
       :load boot/load}
      identity)))
#2017-10-0411:47thhellerlooks something like this now#2017-10-0411:48thhellerthe boot/init function basically is supposed the index from above#2017-10-0411:48mhuebertso boot/load will download files as necessary from the special folder#2017-10-0411:48thhelleryes#2017-10-0411:49thhellerinit is done async so the cljs.core analyzer data and macros can be loaded lazily#2017-10-0411:49thhellerstill working out the details but thats the plan#2017-10-0411:52mhuebertwould it be reasonable to ask that the original source + compiled source are both copied into this dir#2017-10-0411:53mhuebertmy own use case is source lookups from the editor. but since bootstrap is used commonly for tooling i probably wouldn’t be the only one#2017-10-0411:54thhelleryes all of it is copied#2017-10-0411:54thhellersource maps as well#2017-10-0411:57mhueberti am liking this a lot. for Maria I could put one big long list of things into :bootstrap-options and the only constant cost is a larger bootstrap.index.json. then users can require any of those namespaces and they will be loaded on demand.#2017-10-0412:02mhuebertis it necessary for the app that runs shadow.bootstrap/init (& /load) to be compiled together with all the stuff in :bootstrap-options, or could it ‘consume’ any bootstrap.index.json file, provided with a prefix path of where to load the files from?#2017-10-0412:08thhellerwell I haven’t actually written the bootstrap init fn#2017-10-0412:08thhellerbut no you could use whatever bootstrap mechanism you like#2017-10-0412:09thhellerjust need a small reference fn to show how its supposed to work#2017-10-0412:09thhellerits really just about properly discovering where to find stuff#2017-10-0412:09mhuebertyes#2017-10-0412:10mhuebertand the app that uses bootstrap/init or bootstrap/load knowing what has already been loaded (by itself)#2017-10-0412:10thhellerdo you have a :browser shadow-cljs build handy?#2017-10-0412:10mhuebertmm not at the moment#2017-10-0412:11thhellerok, let me finish this so I can show the actual example 😉#2017-10-0412:11mhuebertok 🙂#2017-10-0412:12thheller
[
#2017-10-0412:12thhellereek thats long#2017-10-0412:12thhellerwell, you get the idea /src are the actual sources. /js is the compiled code, /ana is analyzer data#2017-10-0412:13thhellerall in :output-dir + “boostrap”#2017-10-0412:13thhellerso if you app is in /js/foo.js the index will be in /js/bootstrap/index.transit.json#2017-10-0412:14thhellerprobably a bit too many files, not sure if you need the goog files#2017-10-0412:14thheller(since they are already loaded)#2017-10-0412:14mhuebertnot all of them#2017-10-0412:15mhueberteg. say you include quil.core under :bootstrap-options :entries, but you don’t have quil.core in your app itself#2017-10-0412:15mhuebertand then quil.core requires some goog namespaces that aren’t required anywhere else in your app#2017-10-0412:16thhellerI can test which files are loaded by the build and skip those#2017-10-0412:16thhellerfor now its fine to copy everything#2017-10-0412:17thhellerindex should be small enough#2017-10-0412:17mhuebertyes#2017-10-0412:17mhuebertbetter to start with all the info in the index#2017-10-0412:18thheller1.5kb gzip’d for the above#2017-10-0412:18mhuebertthe nice thing if you include everything is that this becomes decoupled from the app#2017-10-0412:19mhuebertso different apps using shadow.boot/init can consume these dependencies remotely#2017-10-0412:20thhelleryeah that could work .. could be problematic though#2017-10-0412:20thhellerit might have issues already since shadow-cljs may sometimes compile things slightly different#2017-10-0412:20mhueberthmm#2017-10-0412:20thhellerwell .. it basically only applies to JS deps#2017-10-0412:20thhellerno idea how that would work anyways 😉#2017-10-0412:21mhueberthmm#2017-10-0412:21thhellerlets finish this first then deal with the issues#2017-10-0412:21mhuebertright, because js deps is no longer a matter of just including source files#2017-10-0412:21mhuebertok#2017-10-0412:25mhuebertdoes shadow do its own parsing of ns dependencies?#2017-10-0412:25thhelleryes#2017-10-0412:28mhuebertok. IIRC the cljs.analyzer/parse-ns didn’t follow macro dependencies (because it was never including them in cljs builds) so i had to make my own modified version for that.#2017-10-0412:29thhellershadow.build.ns-form is the ns parser based on clojure.spec#2017-10-0412:29thhellernot using parse-ns at all, ever.#2017-10-0412:50thhellerwoho twbs/bootstrap should finally become usuable https://github.com/twbs/bootstrap/issues/24167 😉#2017-10-0412:50thhellerso much bootstrap goodness today 😉#2017-10-0412:52mhuebert🙂#2017-10-0413:03thheller@mhuebert I just pushed the first part that should cover the most basic examples#2017-10-0413:03thhellerif you want to try master the new :bootstrap-options config entry controls everything#2017-10-0413:04thheller
:bootstrap-options
        {:entries [reagent.core]
         :macros [cljs.spec.alpha]}
#2017-10-0413:04thhellerit does not yet properly follow the macros so it will only compile the macros you specify#2017-10-0413:04thhellerie. it would not include reagent macros#2017-10-0413:05thhelleralso missing is client bootstrap. maybe you can adjust yours#2017-10-0413:07thhellershadow.bootstrap.loaded-libs is an atom which is a set of symbols matching all goog.provided names that have been loaded#2017-10-0413:07thhellerthe :load fn should add to that set whenever it loads something#2017-10-0413:08thhellergotta take care of some stuff now, will do the reference init/load later#2017-10-0413:34mhuebertnoob question, i’ve been using shadow-cljs via npm, what would the simplest way to run master be?#2017-10-0413:38thhellerclone master and run lein install#2017-10-0413:38thhellermake sure the installed version matches the npm version#2017-10-0413:38thhellershould be if you are on the latest#2017-10-0413:49mhuebert
INFO: duplicate resource cljs/js.cljs on classpath, using jar:file:/Users/MattPro/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/js.cljs over jar:file:/Users/MattPro/.m2/repository/thheller/shadow-cljs/2.0.7/shadow-cljs-2.0.7.jar!/cljs/js.cljs
#2017-10-0413:52mhuebertnow, The required namespace "react" is not available, it was required by "re_view/render_loop.cljs".#2017-10-0413:53mhuebertthis is because react is a symbol and not a string#2017-10-0413:57mhuebert#2017-10-0414:04mhuebertthis still throws from cljs.js:
live.js:680 goog.require could not find: cljs.core$macros
goog.logToConsole_ @ live.js:680
live.js:714 Uncaught Error: goog.require could not find: cljs.core$macros
    at Object.goog.require (live.js:714)
    at cljs.js.js:15
#2017-10-0414:04mhuebertguessing this is because of that conflict?#2017-10-0416:22thhellerI’m back … ah hehe damn.#2017-10-0416:22thhelleryeah I had to make 2 small changes to cljs.js#2017-10-0416:23thhellerhttps://github.com/thheller/shadow-cljs/blob/4c92bad0c87d252cc81b954249bf999474b199cb/src/main/cljs/js.cljs#L27#2017-10-0416:23mhuebertis there a way to prefer shadow’s copy over clojure’s? (it would appear that shadow’s is being ignored?)#2017-10-0416:23thhellerhttps://github.com/thheller/shadow-cljs/blob/4c92bad0c87d252cc81b954249bf999474b199cb/src/main/cljs/js.cljs#L135-L139#2017-10-0416:24thhellersimplest way for now is to copy it to one of your :source-paths#2017-10-0416:25thhellerthats why I put mine there but forgot that .jar loading rules load clojurescript before shadow-cljs so that version wins over mine#2017-10-0416:25mhuebertie. copy the file itself#2017-10-0416:26thhellerhttps://raw.githubusercontent.com/thheller/shadow-cljs/4c92bad0c87d252cc81b954249bf999474b199cb/src/main/cljs/js.cljs#2017-10-0416:26thhelleryeah use that for now#2017-10-0416:26thhellerwanted to work it out first before I submit patches to cljs#2017-10-0416:27thhellerI believe :dump-core toggle already exists#2017-10-0416:29thhellersimplest way to test probably is inide the shadow-cljs checkout itself#2017-10-0416:29thhellerotherwise AOT will get in your way frequently#2017-10-0416:50mhuebertif I have this in shadow-cljs.edn:
:js-options   {:resolve {"react"      {:target :global
                                        :global "React"}
                          "react-dom"  {:target :global
                                        :global "ReactDOM"}
                          "codemirror" {:target :global
                                        :global "CodeMirror"}}}
then should i be able to just put react, react-dom and codemirror in separate script tags and (:require [codemirror :as CM])?
#2017-10-0416:51thheller(:require ["codemirror" :as CM])#2017-10-0416:51thhellerbut yes#2017-10-0416:51thhellersymbol is allowed but I prefer a string for JS deps#2017-10-0416:51thhellermakes it easier to separate the two#2017-10-0416:52mhueberti prefer it, i am just trying to get something that can work with both shadow-cljs and cljsbuild#2017-10-0416:52mhueberti am getting this error The required namespace "codemirror" is not available,#2017-10-0416:52thhellertechnically you can just ignore all that and just access the globals#2017-10-0416:53thhelleris :js-options part of your build?#2017-10-0416:53thhellerits per build not global#2017-10-0416:53mhuebertoh#2017-10-0416:53thhellerhaving said that I should totally support it as global too#2017-10-0416:59mhuebertUncaught TypeError: Cannot read property 'provide' of undefined in `shadow.js.provide(“module$codemirror”, function(require,module,exports) { module.exports=(CodeMirror); });`#2017-10-0417:07thhellerweird
#2017-10-0417:07thhelleroh oops#2017-10-0417:07thhellernot weird, bug#2017-10-0417:08thhellerfixed#2017-10-0417:08thhellermanually add shadow.js to the build for now#2017-10-0417:08thheller:module {:entries ...}#2017-10-0417:13mhuebert& require it from a namespace i suppose#2017-10-0417:17thhellerjust put it before your code#2017-10-0417:18thheller:modules {:main {:entries [shadow.js your.ns]}} should ensure its loaded before the codemirror include#2017-10-0417:21thhelleryou are really brave for testing it on your actual project 😛#2017-10-0417:21thhellerI struggle with my test-build specifically chosen for this without any other stuff going on 🙂#2017-10-0417:24mhuebertah yes#2017-10-0417:24mhuebertthat worked#2017-10-0417:25mhuebertok, one last thing. one of my dependencies (which i control) has a javascript file that i want to include. currently i do that via deps.cljs/foreign-lib. any idea how i can get that to work?#2017-10-0417:25mhuebertcodemirror et al is loading fine now 🙂.#2017-10-0417:26thhellerin the future it will just be (:require ["/path/to/file" :as x]) with relative path support#2017-10-0417:26thhellercurrently its (:require ["some-name" :as x]) and then in :resolve {"some-name" {:target :file :file "path/to/file.js"}}#2017-10-0417:27mhueberthmm. so, the file is in another project; do I put a shadow-cljs.edn file in there?#2017-10-0417:27thhellerah hmm#2017-10-0417:28thhellernah its all build config#2017-10-0417:28mhuebertalso this reinforces the idea that :js-options would frequently be a global thing#2017-10-0417:28mhuebertcan :file be anything on the classpath?#2017-10-0417:28thhellernot really global but global-ish#2017-10-0417:29thhellerno, need to add :target :resource which checks on the classpath#2017-10-0417:29thhellersec I can add that now#2017-10-0417:29mhuebertok#2017-10-0417:30thhellerhmm crap no I can’t 😛#2017-10-0417:30thhellerhmm I did not plan for that#2017-10-0417:30mhuebertbeing able to include arbitrary js file x as a dep is something i’ve done a few times#2017-10-0417:30thhellerthe JS deps stuff is all based on files, since npm uses all files and doesn’t have a classpath#2017-10-0417:31mhueberthmm#2017-10-0417:33thhelleryeah the issue is that the .js files are allowed to require others#2017-10-0417:33thhellersay you include a.js and that does require("./b")#2017-10-0417:34thhellerI need to package both#2017-10-0417:34thhellerwhat kind of JS file is it?#2017-10-0417:35mhueberti have a prosemirror package which has cljs code which is an interface on top of a slew of ProseMirror stuff which i have bundled up with webpack#2017-10-0417:35mhuebertso I have a deps.cljs:
{:foreign-libs [{:file     "js/pm.pack.js"
                 :provides ["pack.prosemirror"]}
                {:file     "js/pmMarkdown.pack.js"
                 :requires ["pack.prosemirror" "cljsjs.markdown-it"]
                 :provides ["pack.prosemirror-markdown"]}]
 :npm-deps {:prosemirror-markdown "^0.22.0"}}
#2017-10-0417:36thhellerhow do you bundle it togehter in webpack?#2017-10-0417:36mhuebertnow at some point I can get rid of the in-between step and just require this stuff directly from npm, however, i haven’t yet & am fairly certain that at least the non-shadow cljs stuff can’t support all the modules required by prosemirror#2017-10-0417:37mhuebertbabel-loader#2017-10-0417:37mhueberthttps://github.com/braintripping/re-view/blob/master/re_view_prosemirror/webpack.config.js#2017-10-0417:38mhuebertthe file is just a bunch of es6 exports:
export {EditorView, Decoration, DecorationSet} from "prosemirror-view"
export {EditorState, Selection, SelectionRange, TextSelection, NodeSelection, AllSelection, Transaction, Plugin, PluginKey} from "prosemirror-state"
export {keymap} from "prosemirror-keymap"

export {findWrapping, liftTarget, canSplit, canJoin, ReplaceAroundStep, ReplaceStep} from "prosemirror-transform"
export {wrapInList, splitListItem, liftListItem, sinkListItem} from "prosemirror-schema-list"
export {InputRule, wrappingInputRule, textblockTypeInputRule, inputRules, undoInputRule, allInputRules} from "prosemirror-inputrules"
export {Schema, Node, Mark, ResolvedPos, NodeRange, Fragment, Slice, MarkType, NodeType} from "prosemirror-model"

import * as commandsObj from "prosemirror-commands"
export const commands = commandsObj;

import * as historyObj from "prosemirror-history"
export const history = historyObj;

import * as modelObj from "prosemirror-model"
export const model = modelObj;
#2017-10-0417:38thhelleryeah, shadow can do that 😉#2017-10-0417:39mhuebertit’s just a lot to rewrite right now 🙂. maybe i can just manually copy the compiled files and link with script tags for now#2017-10-0417:39mhuebertlater i have to go through and change every single reference to these things#2017-10-0417:39thheller(:require ["prosemirror-transform" :refer (findWrapping, liftTarget, canSplit, canJoin, ReplaceAroundStep, ReplaceStep)])#2017-10-0417:40thhellerand so on#2017-10-0417:40thhellerbut yeah for now its probably easier to just copy the file into the project#2017-10-0417:40mhuebertyeah, it will be much better than it is now#2017-10-0417:40mhuebertit’s really awkward and messy as-is#2017-10-0417:40thhellerI did not yet account for js deps on the classpath#2017-10-0417:40mhueberti don’t think any js deps on classpath expect for require to work#2017-10-0417:40thhellerwell js deps written in goog compatible style#2017-10-0417:41mhuebertAFAIK cljs just copies them straight into the bundle#2017-10-0417:41thhelleryeah but I wanted require/`import` to work#2017-10-0417:42thhellerand it was too much work to build that on top of URL so its built on top of File#2017-10-0417:42thhellerbut classpath jars are urls#2017-10-0417:42thhelleranyways … copy it for now#2017-10-0417:42thhellerthen :resolve {"some-name" {:target :file :file "path/to/file.js"}}#2017-10-0417:43thhelleror include via script and :global#2017-10-0417:44mhuebertok we are making progress 🙂#2017-10-0417:44mhuebertCannot read property 'findInternedVar' of null at line 1 when i eval an expression#2017-10-0417:45thhellerthats because the bootstrap/init function doesn’t to anything yet#2017-10-0417:45thhellerthe macros are missing basically#2017-10-0417:45thhelleryou can fake it and load it via script tag#2017-10-0417:46mhuebertoh i am not using the bootstrap/* functions yet#2017-10-0417:46mhuebertthis is using my cljs-live bundles#2017-10-0417:46thhelleryeah you somehow need to load js/bootstrap/js/cljs.core$macros.js#2017-10-0417:47thhellerI took out the require that did that automatically#2017-10-0417:47thhellerbecause I wanted it to be part of bootstrap#2017-10-0417:47mhuebertah. hmm#2017-10-0417:48thhellerbootstrap fn is almost done#2017-10-0417:50mhueberti haven’t set :bootstrap-options at all yet#2017-10-0417:50thhellerah#2017-10-0417:51thhellerthen do it 😉#2017-10-0417:57mhuebertshadow is so fast#2017-10-0418:01thheller🙂#2017-10-0418:04mhuebertit works!#2017-10-0418:05mhuebertso I am not using any of the bootstrap loader code yet#2017-10-0418:05mhueberti just put the core macros file in a script tag#2017-10-0418:06mhuebertbut it works with my existing bundles/loader#2017-10-0418:06mhuebertI just had to create a namespace like so:
(ns shadow-init.init
  (:require shadow.js
            shadow.bootstrap))
#2017-10-0418:11thhellercool#2017-10-0418:12mhuebertby not including the macros in the build, it’s ~900kb lighter. of course we have to load that anyway, but that can happen after the page is visible & first things have started to work.#2017-10-0418:16thhellerI just pushed the barebones init fn I have in mind#2017-10-0418:16thhellerhttps://github.com/thheller/shadow-cljs/blob/83003b9306342a482e45a65e390a61663f59d293/src/main/shadow/bootstrap.cljs#L84-L97#2017-10-0418:16thhellerit does load the correct files, just need to hook them up into the proper places#2017-10-0418:17thhellerit just evals the macro js outright, not sure thats correct 😛#2017-10-0418:17thhellerbut it delays the macro and cljs.core analyzer load#2017-10-0418:18thhellerso it should be 600kb for cljs.core analyzer data, 800kb for cljs.core$macros.js#2017-10-0418:18thhellerit could be smarter and collect everything it needs to load by looking at the index data#2017-10-0418:19thhellerthen load them in parallel or something#2017-10-0418:19thhellercljs.core is easy since its just one file#2017-10-0418:19thhellerbut I suppose its possible to load 10+ files in order in that way#2017-10-0418:21thhellertry is by cloning master, then run shadow-cljs watch bootstrap#2017-10-0418:21thhellerin the project dir#2017-10-0418:21thheller#2017-10-0418:22thhellerhehe shit#2017-10-0418:22thhellernevermind#2017-10-0418:22thhellerI need to bump some deps … too many checkout deps 😛#2017-10-0418:24thhellernow its bumped#2017-10-0418:24mhuebertok i’ll be back in an hour or so#2017-10-0418:24thhellerttyl#2017-10-0418:49thhellerhehe I had no idea transit-cljs still have no uri? warning fix#2017-10-0418:49thhellernow that I’m using it I constantly get the warning#2017-10-0418:50thhellertime to fix https://github.com/thheller/shadow-cljs/issues/87#2017-10-0419:39mhuebertyeah, i checked yesterday and that’s the latest version#2017-10-0419:41mhuebertmaybe with http2 it is not a big deal to be fetching each dependency independently, since we have the index and can fetch all transitive deps in parallel.#2017-10-0419:41mhueberta naïve load-fn loads each dep, parses requires, then loads the next, takes forever#2017-10-0419:42thhellerthis stuff really is less documented than shadow-cljs#2017-10-0419:42mhuebertyeah#2017-10-0419:42thhellerI can’t figure out what load-fn is supposed to do exactly#2017-10-0419:42thhellerie. call the callback with some data?#2017-10-0419:43mhuebertyes#2017-10-0419:43thhellerhaha doh#2017-10-0419:44thhellerit is documented… just not where I was looking for it 😛#2017-10-0419:44mhueberta map of :cache, :source, :lang#2017-10-0419:44thheller
(defonce
  ^{:doc "Each runtime environment provides a different way to load a library.
  Whatever function *load-fn* is bound to will be passed two arguments - a
  map and a callback function: The map will have the following keys:

  :name   - the name of the library (a symbol)
  :macros - modifier signaling a macros namespace load
  :path   - munged relative library path (a string)

  It is up to the implementor to correctly resolve the corresponding .cljs,
  .cljc, or .js resource (the order must be respected). If :macros is true
  resolution should only consider .clj or .cljc resources (the order must be
  respected). Upon resolution the callback should be invoked with a map
  containing the following keys:

  :lang       - the language, :clj or :js
  :source     - the source of the library (a string)
  :file       - optional, the file path, it will be added to AST's :file keyword
                (but not in :meta)
  :cache      - optional, if a :clj namespace has been precompiled to :js, can
                give an analysis cache for faster loads.
  :source-map - optional, if a :clj namespace has been precompiled to :js, can
                give a V3 source map JSON

  If the resource could not be resolved, the callback should be invoked with
  nil."
    :dynamic true}
  *load-fn*
  (fn [m cb]
    (throw (js/Error. "No *load-fn* set"))))
#2017-10-0419:44thhellerI was searching ain cljs.compiler and cljs.analyzer 😛#2017-10-0419:46mhuebertit wasn’t documented much when i started cljs-live#2017-10-0419:47mhuebertdo you use cljs’s source-mapping functions during compile?#2017-10-0419:47thhellersome yes#2017-10-0419:49thhellerso if I understand this correctly#2017-10-0419:49thhellerassuming that nothing is precompiled and only the sources are available#2017-10-0419:50thhellerload-fn should load the source of something, parse it to load the deps, then load all deps (recursively), then finally call the callback#2017-10-0419:51thhellerah wait .. if you have the source I suppose you can call eval-str which will call back into the load-fn#2017-10-0419:52thhellerI’m so glad that everything is sync in shadow-cljs, doing stuff like this async hurts my brain#2017-10-0419:53thhellerbut since pre-compiled sources exist most of the work must still be done by us 😛#2017-10-0419:54thhellerindex to the rescue#2017-10-0419:54mhuebertthe append-source-map function includes the original source along with the source map, which all needs to be encoded/decoded/shipped. i have source-maps disabled for cljs-live, if we enable them here it would be worth seeing what the effect on speed and file size is with the source file left out#2017-10-0419:55mhueberthmm#2017-10-0419:56thhellerdidn’t do source maps yet#2017-10-0419:56thhellerwell the normal build has source maps#2017-10-0419:56mhuebertso, I think in that case load-fn does not have to parse deps, it can just return the thing for itself, but will then be called repeatedly as more calls to require() are evaluated in the source#2017-10-0419:56thhellerjust not the bootstrap stuff#2017-10-0419:56mhuebertyou don’t have to eval inside load-fn#2017-10-0419:57mhuebertyou just return that map, then cljs takes it from there. a file won’t actually be evaluated until its deps have been.#2017-10-0419:57mhuebertyeah there is absolutely no urgency on source maps, just wanted to mention that small thing#2017-10-0419:59thheller
(defn compile-it []
  (cljs/compile-str
    boot/compile-state-ref
    "(ns my.user (:require [reagent.core :as r])) (map inc [1 2 3])"
    ""
    {:eval cljs/js-eval
     :load boot/load}
    print-result))
#2017-10-0419:59thhellerthis is my test#2017-10-0419:59thhellerboot/load is called once, with reagent.core#2017-10-0420:00mhuebertand it is returning the compiled source?#2017-10-0420:00thhellerah nvm, set :type not :lang#2017-10-0420:02thhellerhmm no still only called once#2017-10-0420:02thhellermakes sense though#2017-10-0420:03thhellerit can’t extract deps from compiled js#2017-10-0420:04mhuebertis the ana cache being returned as well?#2017-10-0420:04thhelleryes#2017-10-0420:05thhellerah crap ..#2017-10-0420:05mhuebertbut the compiled js would contain goog.require statements#2017-10-0420:05thhelleryeah, buts thats not a viable way to load code#2017-10-0420:06thhellerah you extract the goog.require in cljs-live and load it right?#2017-10-0420:06thhellersaw something like that#2017-10-0420:07mhuebertonly for js files, i extract goog.provide#2017-10-0420:08mhuebertthat part is a bit of a hack:
(cond-> bundle
          (or (string/starts-with? v "goog")
              (string/starts-with? k "goog")
              (and (string/ends-with? k ".js")
                   ;; for a JS file, see if a goog.provide statement shows up
                   ;; in teh first 300 characters.
                   (some-> v (> (.indexOf (subs v 0 300) "goog.provide") -1))))


          ;;
          ;; parse google provide statements to enable dependency resolution
          ;; for arbitrary google closure modules.
          ;; this is a slow operation so we don't want to do it on all files.

          (update "name-to-path" merge (let [provides (parse-goog-provides v)]
                                         (when (empty? provides)
                                           (log k ": " provides "\n"))
                                         (apply hash-map (interleave provides (repeat k))))))
#2017-10-0420:08thhelleryes but you eval those files?#2017-10-0420:09thhellerah you patch goog.require and load there#2017-10-0420:10mhueberti think the ana cache is how it reads deps for cljs* files#2017-10-0420:11mhuebertthat parsing of goog.provide statements happens just when i download/load a ‘bundle’, nothing is eval’d there yet#2017-10-0420:13thhellerok. I’m just stupid … shouldn’t work so late, too many mistakes 🙂#2017-10-0420:14mhuebert🙂 the bright side is that these problems are far__ better solved with full access to the build/compile system, eg. shadow, than trying to peck at it from the outside like cljs-live#2017-10-0420:15thhelleror not … it doesn’t seem to load deps#2017-10-0420:15mhueberthm#2017-10-0420:15thhellerload gets called once#2017-10-0420:16thhellerI return the {:lang :js :source js-code :cache ana-data}#2017-10-0420:17thhellerlet me try returning the actual .cljs source#2017-10-0420:17thhellerit will probably attempt to load deps if I compile it#2017-10-0420:17thheller
(defn load [{:keys [name path macros] :as rc} cb]
  ;; check index build by init
  ;; find all dependencies
  ;; load js and ana data via xhr
  ;; maybe eval?
  ;; call cb

  ;; FIXME: needs to ensure that deps are loaded first
  (go (let [ana (<! (load-analyzer-data name))
            js (<! (load-js name))]
        (js/console.log "boot/load" name macros ana (count js))
        (cb {:lang :js :source js :cache ana}))
      ))
#2017-10-0420:18thhellergets called once with reagent.core#2017-10-0420:19thhellerbut it doesn’t even seem to eval the js#2017-10-0420:19mhueberti put this in for :eval during debugging:
(fn [{:keys [source cache lang name]}]
  (println "Eval" {:name   name
                   :lang   lang
                   :cache  (some-> cache (str) (subs 0 20))
                   :source (some-> source (subs 0 150))})
  (js/eval source))
#2017-10-0420:19mhuebertto see when/if that is called#2017-10-0420:22thhelleryeah doesn’t get called#2017-10-0420:22thheller
(defn compile-it []
  (cljs/compile-str
    boot/compile-state-ref
    "(ns my.user (:require [reagent.core :as r])) (map inc [1 2 3])"
    ""
    {:eval
     (fn [{:keys [source cache lang name]}]
       (js/console.log "Eval" name lang {:cache (some-> cache (str) (subs 0 20))
                                         :source (some-> source (subs 0 150))})
       (js/eval source))
     :load boot/load}
    print-result))
#2017-10-0420:23thhellerboot/load gets called once with reagent.core#2017-10-0420:23thhellercompile does finish since it doesn’t actually use the code#2017-10-0420:25mhuebertwhat is the shadow-cljs.edn you are using w/ that example?#2017-10-0420:27thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L139-L157#2017-10-0420:27thhellerclone master, shadow-cljs watch bootstrap, src/dev/demo/selfhost.cljs, open #2017-10-0420:29thhellerpushed my current state#2017-10-0420:30mhuebertThe required namespace "react" is not available, it was required by "reagent/core.cljs".#2017-10-0420:31mhuebertoh wait, for some reason version 2.0.6 is running#2017-10-0420:33thhellerrun yarn#2017-10-0420:33thhelleror npm install react#2017-10-0420:34thhellerI’m trying to pre-compile reagent for self-host using my JS deps#2017-10-0420:36mhuebertok. would be great if that error message could indicate if the missing thing is a javascript namespace#2017-10-0420:36mhuebert(which is possible because of the string convention?)#2017-10-0420:37thhellerhmm do you have reagent 0.8 alpha?#2017-10-0420:37thhellerIts supposed to say The required JS dependency "%s" is not available, ...#2017-10-0420:38thhellerhmm#2017-10-0420:39thhellerI should go to bed …#2017-10-0420:39thhellerI require reagent 0.8#2017-10-0420:40mhuebertit’s building now#2017-10-0420:41thhellerseriously .. how does anyone understand how the self host compile works#2017-10-0420:41mhueberthaha.#2017-10-0420:41mhuebertseriously.#2017-10-0420:42mhueberti will see if i can figure out why it’s not calling eval.#2017-10-0420:42thhellerhttps://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs#L427-L482#2017-10-0420:42thhellerI’ve been staring at this for an hour or so#2017-10-0420:42thhellerno idea what it does#2017-10-0420:43mhuebertoh#2017-10-0420:43mhuebertwe are calling compile-str, that’s why it won’t eval#2017-10-0420:44mhuebertchange to eval-str and we get a nice loop i think#2017-10-0420:45thhellerah nice infinite loop 😉#2017-10-0420:45thhellerloading reagent.core over and over#2017-10-0420:46mhuebert:macros is true, but we keep returning reagent.core, which then requests reagent.core$macros again?#2017-10-0420:46thhellerah I didn’t catch that#2017-10-0420:55mhuebertnext thing is $macros aren’t included#2017-10-0420:55thhellerok I got that loaded now#2017-10-0420:56thhellerbut now it tries to load cljs.core endlessly. damn I wish I could just say “its taken care of, just continue compilation”#2017-10-0420:57mhuebertyou can do that by returning a blank map, {:lang :js :source “”}#2017-10-0420:58mhuebertoh#2017-10-0420:58thhellerhaha I didn’t think of that#2017-10-0420:59mhuebertmaybe this gets into the thing, where we need to know which namespaces are loaded in the app__, ie. javascript exists on the window.namespace.variable, and return a blank map for those#2017-10-0420:59mhuebert*blank :source, but still include :cache#2017-10-0421:00mhueberttrue strife awaits those who eval an existing namespace twice. more than one late night because of that.#2017-10-0421:01thhellerI tried adding everything to cljs.js/*loaded*#2017-10-0421:01thhellerno effect#2017-10-0421:03mhueberti haven’t had time to look at the latest cljs resolve stuff#2017-10-0421:05mhuebertit looks like that should work.#2017-10-0421:05mhuebertwhich stuff were you adding to cljs.js/*loaded*?#2017-10-0421:06thheller
(defn set-loaded [namespaces]
  (let [loaded (into #{} (map symbol) namespaces)]
    (swap! loaded-ref set/union loaded)
    (swap! cljs/*loaded* set/union loaded)))
#2017-10-0421:07thhellerthats all namespaces the app uses#2017-10-0421:07thheller (swap! cljs/*loaded* conj ns)#2017-10-0421:07thhellerif I add to the load fn is seems to work#2017-10-0421:08thhellerhmm progress#2017-10-0421:09thhellerhmm crap#2017-10-0421:09mhuebertdidn’t see, where were the names that the app uses?#2017-10-0421:10thhellertake a look at out/demo-selfhost/public/js/base.js#2017-10-0421:10mhuebertoh nevermind, i am reading the comment#2017-10-0421:10thhellerlast line goog.require('shadow.module.base.append')#2017-10-0421:11thhellerwhich is cat out/demo-selfhost/public/js/cljs-runtime/shadow.module.base.append.js#2017-10-0421:12mhuebertwhen i log *loaded* it is empty#2017-10-0421:12thhellerok, I pushed latest state. seems to work properly now.#2017-10-0421:12thhelleruntil it gets to create-react-class node dep#2017-10-0421:13thhellerwhich can’t work since I do something totally different than what the self-host compiler knows and expects#2017-10-0421:14thhellerI’ll see if I can do something the using the :source "" trick#2017-10-0421:17mhuebertdid you push to github already?#2017-10-0421:17thhellerdoh, now#2017-10-0421:18thhellernot sure why it attempts to load 404 (Not Found)#2017-10-0421:18thhellerdammit .. because I’m …#2017-10-0421:18thhellerthat file is not CLJS so it has no analyzer data 😛#2017-10-0421:20mhuebert🙂 step by step#2017-10-0421:21mhuebertit’s so great that you can change build settings and not have to restart the build tool#2017-10-0421:24thhellerok one step closer#2017-10-0421:24thhellerbut as expected it fails to properly load JS deps#2017-10-0421:24thhellerit does load the entries but not the deps#2017-10-0421:25thhellerbut I can probably silently load those before giving control back to cljs.js#2017-10-0421:26thhellerbut really this is getting out of hand, I should just take the shortcut 🙂#2017-10-0421:31mhuebertsilent loading, when you have full knowledge of the deps tree, I think should be the path forward for all types once we get the basics working#2017-10-0421:31mhuebertotherwise we can’t load deps over the network in parallel#2017-10-0421:31thhellergiven the index I can find all deps without a network request#2017-10-0421:32mhueberti mean downloading the cache and source files#2017-10-0421:32thhellerthen load them all, eval in order, callback#2017-10-0421:32mhuebertyes exactly#2017-10-0421:32mhuebertfor cljs as well as js#2017-10-0421:34mhuebertso eg. the call to :load-fn with reagent.core will result in calculating all the transitive deps, downloading in parallel, eval’ing + putting into analysis cache, then returning; or, calculating + downloading all transitive deps, put in cache somewhere, then return to cljs, which will then recurse the :load-fn through all the transitive deps, but not downloading them sequentially#2017-10-0421:38mhueberti’m calling it a night.#2017-10-0421:38thhelleryeah I should too#2017-10-0421:38thhellergn8#2017-10-0421:38mhuebertg’night#2017-10-0423:38mhuebertseq, chunked-seq?, chunk-first, count & others undefined#2017-10-0423:39mhuebertin the shadow-cljs bootstrap demo, there were also :ns errors because the macros ns wasn’t being loaded in init, I tried adding that:
(let [idx (build-index data)
                ana-core (<! (load-analyzer-data 'cljs.core))
                ana-core$macros (<! (load-analyzer-data 'cljs.core$macros))]
            (cljs/load-analysis-cache! compile-state-ref 'cljs.core ana-core)
            (cljs/load-analysis-cache! compile-state-ref 'cljs.core$macros ana-core$macros)
            (js/eval (<! (load-macro-js 'cljs.core$macros)))
            (init-cb)
            )
#2017-10-0423:39mhuebertthat removed the :ns errors but there are still undeclared vars.#2017-10-0423:42mhuebertthen I remembered that the first thing we do in Maria, before evaluating anything, is run `(require ‘[cljs.core :include-macros true]). Then our :load function takes care of all that ^^ stuff, without us doing it manually. https://github.com/mhuebert/maria/blob/master/editor/src/maria/eval.cljs#L66#2017-10-0423:43mhuebertdefinitely heading to sleep now!#2017-10-0506:28thhellerah, right macros have analyzer data too#2017-10-0508:23thheller@mhuebert I finished the proper resource loading and that definitely works. can’t quite work out why it complains about those missing vars#2017-10-0508:23thhellerI suspect I generate macros incorrectly#2017-10-0508:23thhellerWARNING: Use of undeclared Var cljs.core$macros/seq at line 2 is the warning I get#2017-10-0508:25thhellerbut it should use cljs.core/seq as its not a macro but a fn#2017-10-0508:33thhellereither incorrect macros or not setting some compiler state properly#2017-10-0508:33thhelleranalyzer data for everything is definitely loaded#2017-10-0509:11mhuebertMacro loading can be weird. I think even self host macros can be in .clj files, as long as no java code is called#2017-10-0509:12thhellerI fixed all the macro stuff#2017-10-0509:12thhellerthey are defintely all loaded (including analyzer data)#2017-10-0509:12mhuebertHmm#2017-10-0509:12thhellerthey just generate weird code#2017-10-0509:12thhellermust be missing something I’m supposed to set#2017-10-0509:13mhuebertIs it happening at read time, syntax quote symbol resolution?#2017-10-0509:14thhellermaybe? haven’t tracked down the dynamic vars#2017-10-0509:16thhellercljs.js/patch-alias-map not quite sure what that does yet#2017-10-0509:26thheller
;; when compiling a macros namespace that requires itself, we need
              ;; to resolve calls to `my-ns.core/foo` to `my-ns.core$macros/foo`
              ;; to avoid undeclared variable warnings - António Monteiro
#2017-10-0509:26thhellercljs/analyzer.cljc#2017-10-0509:26thhellerthat sounds like the problem#2017-10-0509:33thhellerI’m a bit lost. Gotta do some other work stuff. will try more later#2017-10-0510:34mhuebert#2017-10-0510:41mhuebertre FIXME: actually load it all, not just core - loading analyzer caches on init - not sure I understand the intention exactly, but FWIW I think loading/decoding ana caches is something better done at the time the relevant source files are required vs. all at once. (because this can also be slow, these ana caches can be huge.) so for example, the ana cache for cljs.spec.alpha would be downloaded and loaded at the same time as cljs.spec.alpha is required by source code evaluated by the self-host compiler (even if cljs.spec.alpha is already in the app build)#2017-10-0511:00thhellerboot/load does not load namespaces that are already loaded#2017-10-0511:01thhellerthat also means it does not load analyzer data for those#2017-10-0511:01thhellerso basically boot/init needs to do one load for the “missing” analyzer data#2017-10-0511:04thhellerrun the bootstrap build from master, it should log quite a bit about whats happening#2017-10-0511:04thhellerit does load everything correctly (I think)#2017-10-0511:04thhellerI’m just not setting some analyzer data I’m supposed to set#2017-10-0511:05thhellerhttps://www.maria.cloud/intro#2017-10-0511:05thhellerdoes this expose the compiler state atom somewhere?#2017-10-0511:05thhelleror do you have a bootstrap example handy with just CLJS tooling?#2017-10-0511:06thhellerthe analyzer data looks correct to me but I have no idea what cljs.js/patch-alias-map does and cljs calls it all over the place#2017-10-0511:06thhellerI never do, so thats my prime suspect currently#2017-10-0511:14mhuebertyes, its at maria.eval/c-state#2017-10-0511:16mhueberthttps://dev.maria.cloud/gist/a7eb0b08359e4d50ca920b67564f2cd8?eval=true
#2017-10-0511:19mhuebertyeah I understand what’s happening & have it running locally, have been toying with cljs.analyzer#2017-10-0511:20thhellerah you have a data visualizer, cool#2017-10-0511:20mhuebertit is a work in progress, not perfect 🙂. but you can click the left-brackets to collapse#2017-10-0511:20thhellerone suggestion: for maps, attempt to sort the keys#2017-10-0511:20mhuebertoh, good idea#2017-10-0511:20thhellerI do it in devtools console stuff#2017-10-0511:20mhuebertwhat I meant is that instead of a no-op, load should load the ‘missing’ analyzer data only when a namespace is required#2017-10-0511:20thhellermakes a huge difference when debugging maps#2017-10-0511:21mhuebertthat way you don’t have to do it all in the beginning#2017-10-0511:21mhuebertso the load function, for namespaces that are already loaded, returns only the cache#2017-10-0511:21mhuebertor a blank js as source#2017-10-0511:21mhuebertin addition to the cache#2017-10-0511:21thhellerhmm yeah that could work as well#2017-10-0511:21mhuebertand then sets the namespace as ‘fully’ loaded, so the next time it runs, it is ignored#2017-10-0511:22thhellerneed to rewrite the loader a bit but possible#2017-10-0511:22mhuebertI’ve played with these settings back and forth. in a reasonably sized project this stuff really matters#2017-10-0511:22thhellerdelaying as much as possible makes sense#2017-10-0511:22thheller
;; FIXME: this should probably do something async
          ;; otherwise it will block the entire time 60 or so files
          ;; are eval'd or transit parsed
#2017-10-0511:22thhelleralready left a note there to turn the load into something that is async#2017-10-0511:22mhuebertyeah#2017-10-0511:23thhellerso the browser gets a chance to breathe#2017-10-0511:23thhellerin the demo it already loads 60 files in one go#2017-10-0511:23thhellerwell the download is parallel and async#2017-10-0511:23thhellerbut the eval isn’t#2017-10-0511:23mhuebertI believe Planck uses a lazy-map for cljs.analyzer/namespaces#2017-10-0511:24mhuebertso the ana cache is decoded hte first time it is read#2017-10-0511:24thhellerneed to finish this work stuff first#2017-10-0511:24thhellerbbl#2017-10-0511:25mhuebertok. i am setting up another project with shadow-cljs. a few of us are using maria at clojurebridge this weekend so it needs to be as stable as possible 🙂#2017-10-0512:05mhuebertcould these warnings/resolutions be related to clojure.core/cljs.core aliasing? (probably not, more likely related to self-require..)#2017-10-0517:34thhellerthat took way longer than expected 😛#2017-10-0517:34thhellerback from fighting some horrible css#2017-10-0518:10mhuebert🙂 i spent half the afternoon fighting with webpack trying to get sass and postcss autoprefixing to play together#2017-10-0518:11thhellerwebpack would be a delight. I have this legacy system some designer built that uses compass from like 100 years ago#2017-10-0518:12mhueberthehe. haven’t heard anyone mention compass in a long time#2017-10-0518:12thhellertoo much compass weirdness to use sass directly#2017-10-0518:12thhellerone day I’ll replace that sucker 😉#2017-10-0518:26mhuebertgetting an example project set up now but taking a break for dinner#2017-10-0518:27thhellerI have narrowed it down#2017-10-0518:27thhellerit must be the macro generation#2017-10-0518:27thhellerthe macro file is full of#2017-10-0518:27thhellernew cljs.core.Symbol("cljs.core$macros","seq","cljs.core$macros/seq",-1873195024,null) which should probably be cljs.core/seq#2017-10-0518:28mhuebertah#2017-10-0518:52thhellerso, I just set-up a test macro ns with a simple dummy macro#2017-10-0518:52thheller
(ns demo.macro)

(defmacro foo [& body]
  `(seq 
#2017-10-0518:53thhellerthat then contained new cljs.core.Symbol("demo.macro$macros","seq","demo.macro$macros/seq",-1873195024,null)#2017-10-0518:53thhellerrewrote that manually and it works#2017-10-0518:53thhellernow I need to figure out what controls that 😛#2017-10-0519:01thhellerwoho I might have it#2017-10-0519:16thhellerhttps://github.com/reagent-project/reagent/blob/master/examples/simple/src/simpleexample/core.cljs#2017-10-0519:16thhellerworks, with react via my JS deps 🙂#2017-10-0519:17thhelleronly one issue, reagent doesn’t declare that it uses clojure.string. gotta get that fixed.#2017-10-0519:22thhellerhmm weird. it has proper requires in master#2017-10-0519:23thhellernvm the demo doesn’t have the proper require 😛#2017-10-0519:25mhuebertspinning up a demo project, getting
[:browser] Build failure:
The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc".
#2017-10-0519:26mhuebertthats good news!#2017-10-0519:26thhellerhmm strange. now I’m scared to relaunch my process 😛#2017-10-0519:26mhuebertsorry not that project#2017-10-0519:26mhuebertmy own project#2017-10-0519:26thhellerah did you delete target/shadow-cljs before trying? it might just be AOT issues#2017-10-0519:27mhuebertah no#2017-10-0519:27mhuebertdidn’t do that#2017-10-0519:27thhellerstill need to fix some issues but I’m amazed that reagent just works#2017-10-0519:28mhuebertyeah that is fantastic#2017-10-0519:28mhueberthow does reagent require react?#2017-10-0519:28mhuebertah i see, just [react :as react]#2017-10-0519:29mhuebertso shadow is pulling that from node_modules#2017-10-0519:29thhelleryes#2017-10-0519:29thhellerno :foreign-lib involved#2017-10-0519:30thhellercode evaled in the browser probably will not be able to access those JS dependencies#2017-10-0519:30mhueberti’ve put mine here, https://github.com/mhuebert/shadow-eval.git#2017-10-0519:30mhuebertstill getting the same error#2017-10-0519:32thhellerI’ll check it out#2017-10-0519:36thhellermight be the missing cljs/js.cljs override?#2017-10-0519:36mhuebertoh wait#2017-10-0519:36mhuebertyes, i remembered to put it in the project but not in the entry#2017-10-0519:36mhuebertsorry#2017-10-0519:37thhellerdo you use yarn or npm?#2017-10-0519:37mhueberthmm#2017-10-0519:37mhuebertyarn usually#2017-10-0519:37thhellerhmm no the override is correct#2017-10-0519:38thhelleralways yarn add shadow-cljs to the project itself#2017-10-0519:38mhueberti am not using node_modules here for anything though#2017-10-0519:38mhuebertok#2017-10-0519:38thhellerI’m surprised it compiles at all#2017-10-0519:38thhellersince it won’t find any of the foreign libs#2017-10-0519:38mhuebertfrom a yarn global add ...#2017-10-0519:38mhuebertoh#2017-10-0519:39thhellerthe global install is just for convenience#2017-10-0519:39thhellerso you can use shadow-cljs CLI command with yarn run#2017-10-0519:39thhellerif its part of the project, it will always use the version from the project#2017-10-0519:39thhellerand ensure that the project has the proper dependencies available#2017-10-0519:40thhelleranyways .. not sure what the problem is#2017-10-0519:40thhellerdigging deeper#2017-10-0519:43mhuebertoh#2017-10-0519:43mhuebert#2017-10-0519:46thhellerah wait#2017-10-0519:46thheller:entries [shadow-eval.core]#2017-10-0519:46thhellerthis is not required, as the app will load it anways#2017-10-0519:46thhellerit just needs “extra” entries that the app doesn’t load on startup#2017-10-0519:47thhellerie. support files#2017-10-0519:47thhellerit should still find the macros though#2017-10-0519:47thhellerthere might be an issue with self-host using self-host 😛#2017-10-0519:48mhuebertwait, what do you mean about shadow-eval.core#2017-10-0519:48mhuebertdoesn’t every build need at least one entry point?#2017-10-0519:48mhueberterr every module#2017-10-0519:49mhuebertoooh#2017-10-0519:49mhuebertyou might be right about this self-host using self-host#2017-10-0519:50thhellertaking it out fixes it#2017-10-0519:50mhueberthere is my cljs-live entry for maria.user:
{:name            maria.user
                  :entry           #{maria.user}
                  :provided        #{maria.frames.live-frame}
                  :entry/no-follow #{maria.eval
                                     cljs-live.eval
                                     cljs.js
                                     cljs.compiler
                                     maria.editors.code
                                     maria.repl-specials
                                     cljs.core.match
                                     maria.views.repl-specials
                                     maria.live.analyze
                                     maria.live.source-lookups}
                  :entry/exclude   #{cljs.pprint}}
#2017-10-0519:51thhellerright I didn’t add the no-follow support yet#2017-10-0519:51mhueberti forgot about that.#2017-10-0519:51thhellerbasically the :bootstrap-options :entries just controls which namespaces are allowed to be used by self-host eval#2017-10-0519:52thhellerand that can’t use self-host itself it seems … would probably make my head explode if that worked 😛#2017-10-0519:53mhuebertyeah. so the :entry/no-follow excludes a thing, and does not look at its transitive deps at all (it does not specifically exclude all of its transitive deps, because they could be used elsewhere), there are some namespaces (like all those listed above) that I just found to be problematic with self-host#2017-10-0519:54thhellercljs.js is in there 😉#2017-10-0519:54mhuebertprecisely 🙂#2017-10-0519:54thhellerso I can probably add a :bootstrap-options {:exclude #{cljs.js other syms} to control that#2017-10-0519:55thhellerto prevent it from compiling those#2017-10-0519:55thhellerso the app fails with a bunch of React is not defined#2017-10-0519:56thhellerthat is because its still trying to use the React global#2017-10-0519:56thhellereg. (def ^:dynamic *create-element* js/React.createElement) in re-view-hiccup.hiccup#2017-10-0519:56thhellerthats not great.#2017-10-0519:57thhellerhmm I should add an option that lets expose some of my js deps as globals#2017-10-0519:57thhellerto ease the transition#2017-10-0519:57mhueberti ended up doing that because cljs compiler things have been changing so frequently, and the :foreign-libs was so unpredictable#2017-10-0519:57mhuebertfinally gave up#2017-10-0519:58thhelleryeah, totally understandable#2017-10-0519:58mhuebert^^ an option to expose js deps as globals would be super helpful i think, i was trying to figure out how to make all my libraries possible to compile with shadow-cljs and also cljsbuild et al#2017-10-0519:59thhellerwait ha#2017-10-0519:59thhelleryou already configured everything to use the global#2017-10-0519:59thhellerjust didn’t include it 😉#2017-10-0519:59mhuebertyep#2017-10-0519:59mhuebertbut#2017-10-0520:00mhuebertno nevermind. for now i will just include script tags.#2017-10-0520:00thhellerif you want something that is compatible with both tools#2017-10-0520:00thhelleryou should probably use ["react" :as react]#2017-10-0520:01thhellerBUT that needs updated cljsjs.react, I’m not sure those are available yet#2017-10-0520:02thhellerdo you have a script tag I can test with?#2017-10-0520:04thheller seems to work#2017-10-0520:08thhellerdoesn’t work quite right, init doesn’t seem to complete#2017-10-0520:08mhuebertthere are some other errors on that page, just a sec#2017-10-0520:08mhuebertcleaning it up#2017-10-0520:09mhuebertdo i still need to include :macros in bootstrap options#2017-10-0520:09thhellerno#2017-10-0520:09thhelleronly if you want macros that aren’t otherwise included#2017-10-0520:12thhellerah, the load fn just silently stops if a namespace is not available#2017-10-0520:12thhellerthats not great 😛#2017-10-0520:17mhuebertif you pull the demo, it works now#2017-10-0520:20mhuebertput in the value-viewer#2017-10-0520:21thhelleryes, works. 🙂#2017-10-0520:21mhuebertdid you fix the thing with for loops?#2017-10-0520:22thhelleryes#2017-10-0520:22mhuebert🙂#2017-10-0520:24thheller
(defonce _
         (boot/init #(swap! state assoc :ready true)))
#2017-10-0520:24mhuebertnow, if i run (require '[re-view.core :as v :refer [defview]]) it says :invalid-refer, but if I run (require-macros ...) first, it loads#2017-10-0520:24thhellerI’ll fix that so you can call init more than once without issue#2017-10-0520:24mhuebertok#2017-10-0520:24mhuebert(`defview` being a macro)#2017-10-0520:25thhellerright, thats the analyzer data issue#2017-10-0520:25thhellerthis one ;; FIXME: actually load it all, not just core#2017-10-0520:26thhellersince the shadow-eval.core namespace already uses re-view.core it doesn’t properly load the analyzer data for it#2017-10-0520:26thhellerat least I think so#2017-10-0520:28mhueberthmm. so currently we set cljs/*loaded* (or whatever) with the names of preloaded namespaces, so boot/load isn’t called at all for them#2017-10-0520:29thhelleryes, but it should only skip loading the JS. it should still load the analyzer data#2017-10-0520:29mhuebertbut if we don’t put all of those into *loaded*, but instead just keep that knowledge to ourselves, then when we see them for the first time in boot/load we return the cache + blank js#2017-10-0520:30thhellerbut that evals the JS#2017-10-0520:30mhuebertit only evals what we return, the blank helper js#2017-10-0520:30thhellerno I control the eval of the deps#2017-10-0520:31mhueberthm#2017-10-0520:31mhuebertand always return the blank helper?#2017-10-0520:31thhelleryes#2017-10-0520:31thhellerI load the JS and analyzer data, put it into the correct places, then callback#2017-10-0520:32thhellerit just stops too early in cases where the JS is loaded but the analyzer data is not#2017-10-0520:32thhellershould be an easy fix though#2017-10-0520:33thhellerthought for a moment I could drop init entirely#2017-10-0520:33mhuebertbut this is triggered by load and not init#2017-10-0520:33thhellerbut I can’t since cljs.js may not always call the load fn#2017-10-0520:33mhueberti think cljs.js will call the load fn if we don’t put all the app namespaces into *loaded*#2017-10-0520:33mhuebertthen we can get rid of init#2017-10-0520:34mhuebert(i think)#2017-10-0520:35mhuebertwell, still need init for the index#2017-10-0520:35thhellercan load the index in load if its not loaded#2017-10-0520:35mhuebertah right#2017-10-0520:37thhellerhmm nope#2017-10-0520:37thhellerif I just take out the init and then do something like (+ 1 2) I get an error#2017-10-0520:37thheller
[ 
:div "Error: " "#error {:message \"Could not eval [test]\", :data {:tag :cljs/analysis-error}, :cause #error {:message \"Cannot read property 'findInternedVar' of null at line 1 \", :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}"
 ] 
but no load is ever called
#2017-10-0520:37thhellerso definitely need init#2017-10-0520:38mhuebertwithout init do we need (require '[cljs.core :include-macros true])#2017-10-0520:38thhellerI think init is safer to ensure that everything is actually ready#2017-10-0520:40thhellershould be simple fix anyways, just really need to grab some food 🙂#2017-10-0521:02mhuebertis there a reason to use both loaded-ref and cljs/*loaded*?#2017-10-0521:10thhellerre, yes. will matter later.#2017-10-0521:13mhuebertok. i made a quick example https://github.com/thheller/shadow-cljs/compare/master...mhuebert:patch-1#2017-10-0521:14mhuebertignore the fact that loaded-ref was also taken out, i didn’t know its purpose#2017-10-0521:14mhuebertthis compiles/runs for me#2017-10-0521:14mhuebert(the bootstrap demo)#2017-10-0521:15mhuebertech i’ll put loaded-ref back in there#2017-10-0521:18mhueberthere is a much cleaner view: https://gist.github.com/mhuebert/4eaf8eef3f704f7905545e3530c3e519/revisions#2017-10-0521:19mhuebertit should never load the :js for a pre-loaded ns, but otherwise the compiler doesn’t need to know they exist until they are required#2017-10-0521:22thhellerpushed the fix#2017-10-0521:23thhellerthe loaded-ref is there because of code splitting, well thats the plan#2017-10-0521:23thhellerwill make sense if I actually enable it 😉#2017-10-0521:24thhellerright now there will be a problem if you use 2 modules and shadow.bootstrap ends up in the second module#2017-10-0521:24thhellerthe first will blindly call shadow.bootstrap.set_loaded without having declared a proper dependency on it#2017-10-0521:24thhellerso it will fail#2017-10-0521:24thhellernot important yet#2017-10-0521:25thhellerbut the fix should take care of all loading issues#2017-10-0521:25mhuebertok taking a look#2017-10-0521:25thhellerit might load a bit too much now in init#2017-10-0521:25thhellersince it loads analyzer data for everything loaded by the app#2017-10-0521:26thhellerbut that could be delayed until load#2017-10-0521:28thhellerah not its all correct#2017-10-0521:28thhellercljs.core$macros depends on all that stuff, not the app#2017-10-0521:31mhuebertwhere is it loading all of that?#2017-10-0521:31thhellerhmm something doesn’t quite work#2017-10-0521:32mhuebertdid you see the gist above? the demo totally worked without doing any extra loading in the beginning, just making sure not to load :js for the pre-loads#2017-10-0521:32thhellerit worked, but it was missing analyzer data for things like clojure.string#2017-10-0521:33mhueberthow so?#2017-10-0521:33mhuebertboot/load should be called for clojure.string, analyzer data loaded but no js evaled#2017-10-0521:35thhelleryou didn’t take out this check https://gist.github.com/mhuebert/4eaf8eef3f704f7905545e3530c3e519/revisions#diff-4ebb24b82089d1f69766f74ec1eed471R88#2017-10-0521:36thhellerso if something was loaded it never ended up in the list#2017-10-0521:36thhellerits correct now though#2017-10-0521:36mhuebertthat check stays#2017-10-0521:36mhuebertbut the ns doesn’t get put into loaded-ref until loaded#2017-10-0521:36thhellerbut (require '[re-view.core :as v]) doesn’t seem to do anything#2017-10-0521:38thhellerright .. *loaded*#2017-10-0521:38thhellersec#2017-10-0521:38thhellerright … now I get it#2017-10-0521:39mhuebertthe only reason i am focusing on this is because i used to have cljs-live behave like this and load everything up-front, and with a project that goes beyond tiny example, it can be really slow#2017-10-0521:39thhellerdon’t worry .. it will not be slow, doesn’t matter which size#2017-10-0521:39mhuebert🙂#2017-10-0521:40thhelleronce I make load async properly#2017-10-0521:40thhellerbut yes I get your point#2017-10-0521:41thhelleranalyzer data is now checked against the actual compiler state not the loaded-ref (or *loaded*)#2017-10-0521:42thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/bootstrap.cljs#L148#2017-10-0521:42thhellershould be far more accurate#2017-10-0521:43thhellerwould it make sense if I let you pass in the compiler state to init/load?#2017-10-0521:43mhuebertyes#2017-10-0521:44mhueberti think so#2017-10-0521:45thhelleryeah seems wrong to declare that global#2017-10-0521:45mhuebertyou can have multiple compiler states in an app, perform namespace surgery on namespaces, reset them, etc. so checking the compiler state for whether or not to load an analysis cache makes perfect sense#2017-10-0521:47mhuebertI’d have to do quite a refactor if I had to ‘move’ maria’s compiler state, it is referenced from so many places#2017-10-0521:52thhellerok (require '[re-view.core :as v :refer [defview]]) works now#2017-10-0521:54thhellerpushed the fix#2017-10-0521:55thhellerdoes a bit more work but should ensure that everthing is properly loaded#2017-10-0522:08mhueberthmm, I think there are still some funky things with syntax quote#2017-10-0522:10mhuebertthese are all in syntax quoted forms where i would expect them to resolve to cljs.core#2017-10-0522:10mhuebertactually that one, self i think is a function parameter#2017-10-0522:11mhuebertthis is the macro being called, in the cells.cell$macros namespace:
(defmacro cell
  "Returns an anonymous cell. ..."
  ([expr]
   `(~'cells.cell/cell nil ~expr))
  ([key expr]
   `(let ~lib-bindings
      (~'cells.cell/cell* ~(cell-name key) (fn [~'self] ~expr)))))
#2017-10-0522:13mhueberti’ve pushed the current state#2017-10-0522:13mhuebert(to shadow-eval)#2017-10-0522:13mhuebertheading to sleep now#2017-10-0522:15mhuebertoh…… AOT issue#2017-10-0522:15mhuebert🙂#2017-10-0522:15mhuebertit works!#2017-10-0522:17thhellerhehe cool#2017-10-0522:18thhellerwhats that? quil?#2017-10-0522:18mhueberta thing i wrote#2017-10-0522:18mhueberthttps://dev.maria.cloud/cells#2017-10-0522:19mhuebertwell i wrote the cells lib, friends wrote the shapes library and collaborated on that intro doc 🙂#2017-10-0522:19thhellerjust pushed a bit of cleanup, both boot/init and boot/load now take the compiler-state as their first argument#2017-10-0522:19thhelleralso did the first async run queue#2017-10-0522:19mhuebertexcellent#2017-10-0522:20thhellerbut its a bit too naive for our purposes#2017-10-0522:20mhuebertif code was written on paper, i would be preparing for a festive burning of the cljs-live repo 😉#2017-10-0522:20thhellerhehe#2017-10-0522:21thhellerthis maria.cloud stuff is seriously cool#2017-10-0522:22mhuebertsimple_smile#2017-10-0522:22thhellerI would hold off on the burning, not quite sure we covered everything yet#2017-10-0522:22thhellerstill missing the excludes#2017-10-0522:23thhelleralthough not sure they are actually needed#2017-10-0522:23mhueberthow would you approach it w/o them?#2017-10-0522:24mhueberteg. the reason that you can do (require [maria.eval :as e]) and inspect the compiler state is because I’m able to exclude cljs.js. I could attempt to reorganize the whole app around dividing lines based on which namespaces happen to not freak out in self-host, but that could get rather tedious#2017-10-0522:25thhellerhmm right#2017-10-0522:26thhelleryeah thats a good use case#2017-10-0522:26mhuebertthere are quite a few macro namespaces, for instance, which will never work in self-host (or not unless the authors make a serious effort), but namespaces that use those macros can nevertheless be used in self-host without problem (provided we can exclude those problematic ones)#2017-10-0522:26mhueberteg. you can have a namespace which uses core.async, and run those functions (compiled) in self-host no problem, because macroexpansion already happened, despite core.async not working in self-host. (mfikes has a fork that does, but many libs don’t use it)#2017-10-0522:27mhuebert*core.async macros#2017-10-0522:27thhellerhmm yeah but inside self-host you can’t use go#2017-10-0522:27thhelleryou can use the functions of cljs.core.async but not actually do anything without go#2017-10-0522:27mhuebertright. you can’t use the macro, but you can use a function that was defined using go, because it has already been expanded/compiled.#2017-10-0522:27thhelleryes#2017-10-0522:28mhuebert(maybe some day this will become obselete: https://github.com/mfikes/andare)#2017-10-0522:28thhellerok, I’ll add :exlude taking a set of namespace symbols for macros that won’t be included#2017-10-0522:29thhelleryeah problem with andare is that it uses the same namespaces#2017-10-0522:29thhellerso it overrides cljs.core.async#2017-10-0522:29thhellercan’t really do that#2017-10-0522:29thhellershould have used other namespaces#2017-10-0522:35thhellerhttps://github.com/mhuebert/shadow-eval/blob/master/src/shadow_eval/core.cljs#L38#2017-10-0522:36thhellerthat seems tedious, should I add an option to init that can load stuff?#2017-10-0522:36mhueberti was wondering about that#2017-10-0522:36mhuebertprobably would make sense#2017-10-0522:40mhuebertok, i am crashing. good night!#2017-10-0522:44thhellergn8 🙂#2017-10-0523:06thheller(shadow.bootstrap/init compile-state-ref {:load-on-init '[shadow-eval.user]} init-cb)#2017-10-0523:06thhellerdamn forgot about excludes again 😛#2017-10-0523:06thhellerafter sleep#2017-10-0608:20thheller@mhuebert I’m doing a bit of cleanup. shadow.bootstrap is now shadow.cljs.bootstrap.browser#2017-10-0608:21thhelleralso don’t need the cljs/js.cljs anymore, the default now works.
#2017-10-0608:32thhellerthe question now is whether the “bootstrap host” and “bootstrap support files” should be 2 separate builds#2017-10-0608:33thhellerthe 2-in-1 build has a couple of issues and in theory you could share the support files on multiple builds#2017-10-0608:36thheller“host” is the build that calls init and uses load#2017-10-0608:36thhellerthe support files are actually just files then used by the “host”#2017-10-0608:37thhellerbut they don’t really need to know anything about the host#2017-10-0613:55mhueberthmm#2017-10-0613:58mhuebertwhat are the issues with the 2-in-1 build?#2017-10-0613:58mhuebertyes the sharing of support files is a big win actually#2017-10-0613:58mhuebertwith the way this is shaping up, one could rather simply build a service that would precompile large numbers of libraries, and put them at versioned urls cached indefinitely#2017-10-0614:01mhuebertthe output of the “self-host” build is just a directory of files (the index, sources, all that) whereas the “host” build is going to be a typical :browser build with live-reload and so forth#2017-10-0616:47thhelleryeah exactly#2017-10-0616:47thhellerthe issue is that currently the self-host support files are an “afterthought”#2017-10-0616:48thhellerif you change one file that is not part of your actual build a re-compile will not be triggered#2017-10-0616:49thhellersame for macros, since they aren’t part of the actual build they will not trigger a rebuild#2017-10-0616:49thhellerthe only danger with 2 builds is that you might run into issues when using different compiler versions#2017-10-0616:50thhellerbut even then only if there were breaking changes to the analyzer data which is pretty rare#2017-10-0617:40mhuebertfor hosting/caching, as you allude the versioning should be by library+compiler (within ranges), this problem can be solved outside of shadow I think#2017-10-0617:40mhuebertI don’t think it’s worth worrying too much at this point about trying to get live reload of self-hosted-only namespaces#2017-10-0617:41mhuebertto me there is a big benefit in the basics just working reliably#2017-10-0617:41thhellernah I don’t want to live-reload those, that is far too much work indeed. just triggering a re-compile would be enough.#2017-10-0617:41mhuebertthis is a huge improvement over the status quo#2017-10-0617:42thhellerI’m making a new :target option now#2017-10-0617:42thhellerso you have one :browser build which is the “host” and one :bootstrap build thats just the support files#2017-10-0617:42mhuebertah that’s perfect, so no :bootstrap-options#2017-10-0617:42thhellerwhich can be shared accross many “hosts”#2017-10-0617:43thhellerright :bootstrap-options basically move to {:target :bootstrap :entries ... :macros ... :excludes ... :output-dir "..."}#2017-10-0617:43mhuebertyep#2017-10-0617:43thhellerand boot/init takes a new :path where to find those files#2017-10-0617:44mhueberti think we may end up revisiting the idea of a :no-follow option but let’s wait until doing real use cases and see what is actually necessary#2017-10-0617:45mhuebertyeah that’s perfect, so :path could be on a server somewhere#2017-10-0617:45thhellerexactly, I can build-in permanent caching if you’d like#2017-10-0617:46thhellereg. when compiling I can timestamp the files and then put the timestamped names into the index#2017-10-0617:46mhuebertoh, excellent#2017-10-0617:46thhellerso if you request cljs.core it resolves to cljs.core.123124123.js or so#2017-10-0617:46mhuebertthis stuff can make a big difference out in the field because large asset size is unavoidable with self-host. i shed a tear at the network tab of maria#2017-10-0617:47mhuebertwhen these files can be cached forever, that concern lessens#2017-10-0617:47thhelleryeah just need some proper http headers and it should cache very well#2017-10-0617:49thheller+ with h2 the request count doesn’t matter so the user really only downloads what is needed#2017-10-0617:49thhellernot pre-bundled stuff where maybe 50% is unused#2017-10-0617:50mhuebertyup#2017-10-0617:50thheller
:bootstrap-support
  {:target :bootstrap
   :output-dir "out/demo-selfhost/public/bootstrap"
   :entries [demo.macro reagent.core]
   :macros []}
#2017-10-0617:50thhellerlooks something like this then#2017-10-0617:50thhellerdoesn’t need any devtools config and I just preset all the useful compiler options#2017-10-0617:51thhellersince it never needs to be optimized or so anyways#2017-10-0617:51thhellercould even make special source adjustments should that ever be required#2017-10-0617:52thhellerthe “host” build shouldn’t need any special config#2017-10-0617:53thhellerwell I could put the :bootstrap-path option into the “host” build, rather than in code if that is useful?#2017-10-0618:22thhellerhmm#2017-10-0618:22thhellerone issue though .. the :js-options :resolve would really need to be shared#2017-10-0618:23thhellerhmm, maybe not#2017-10-0618:58mhuebertis the :macros option still necessary?#2017-10-0618:59mhuebertthe :js-options :resolve may need to be consistent but not necessarily shared?#2017-10-0618:59mhuebert(ie. if you publish a bootstrap build, it could have declared certain :resolves which it expects to be available?)#2017-10-0618:59mhuebertmay not fully understand the nuances there#2017-10-0619:01mhueberti’m not quite sure what the :bootstrap-path option means. i would expect to copy the output-dir path from my bootstrap build and use that with boot/init#2017-10-0619:16thheller:macros is not needed anymore no, only for very special cases probably#2017-10-0619:17thhellerthe issue with :resolve is that the names are not constant, so if you configure your build to use a global for "react" you get a variable module$react in your build#2017-10-0619:18thhellerbut if that resolves differently in the bootstrap support files it could be module$node_modules$react$react or so#2017-10-0619:18thhellerthat would load 2 different reacts again#2017-10-0619:18thhellersince the build provided module$react but not the other the loader would load it#2017-10-0619:19thhellerbut JS deps will be tricky regardless#2017-10-0619:19thhellerso I think I have everything#2017-10-0619:20thhellerre :bootstrap-path#2017-10-0619:20thhellerif you specify it in the config you don’t need to provide it to boot/init#2017-10-0619:20thhellerjust a matter of where to configure it really, in code or in build config#2017-10-0619:34thhellerok pushed the update#2017-10-0619:35thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L139-L159#2017-10-0619:36thheller:bootstrap-host would be your normal app which “hosts” the compiler#2017-10-0619:36thheller:bootstrap-support are the support files, all written into one directory#2017-10-0619:36thhellerthe shadow.cljs.bootstrap.browser ns has been updated accordingly#2017-10-0619:37thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/selfhost.cljs#2017-10-0619:37thhellerAPI is pretty much the same except for the :path option#2017-10-0619:38thheller:js-options should match for now, need to think about this more#2017-10-0619:38thhellerworst case is you load everything twice, which might be bad if you host interacts with it in any way#2017-10-0619:39thhellersay you detect if the returned value is something from react#2017-10-0619:39thhellerwatch for :target :bootstrap probably doesn’t work correctly yet#2017-10-0619:40thhellerneed to teach it about self-host macros first#2017-10-0619:46thhellerin shadow-cljs release mode the file names will be hashed#2017-10-0620:05thhellerhmm 2.1mb for the release host app with :simple, scary when used to :advanced 😉#2017-10-0708:22thheller@mhuebert did you ever experiment with running the compiler in a web worker but eval in the page? that would probably solve all performance concerns at the cost of slightly higher memory usage#2017-10-0709:26thhellerI modified my test impl to use a webworker to run the self host compiler, this offloads all the “slow” stuff to the worker#2017-10-0709:26thhellereval happens in the worker as well as the “host”#2017-10-0709:26thhellercould be optimized a ton but seems to have far better performance#2017-10-0709:27thhelleralthough it still locks up just from the eval, so overall its probably not worth it#2017-10-0711:52mhuebertNo, i hadn't tried that. Wasn't sure how complicated state sharing between the two environments would be#2017-10-0711:52mhuebertOr if only passing compiled strings is sufficient#2017-10-0711:54mhuebertIf a compiler state atom still available in evaluating, or if it needs to be#2017-10-0711:58mhuebertAt ClojureBridge today so not much time#2017-10-0714:35thhellerif you need access to the compiler state then web worker is not great#2017-10-0714:35thhellerforgot that the maria editor might need that#2017-10-0715:47mhuebertI guess depends on how big a difference it makes to performance. Does evaluation need to happen in the worker at all? Introspection maybe can be a special case#2017-10-0716:49mhuebertHave to try that and see.#2017-10-0809:53Jon
(ns reel.comp.container
  (:require-macros [respo.macros :refer [defcomp <> div span]])
  (:require [hsl.core :refer [hsl]]
            [respo-ui.style :as ui]
            [respo.core :refer [create-comp]]
            [respo.comp.space :refer [=<]]
            [reel.comp.reel :refer [comp-reel]]
            [reel.comp.todolist :refer [comp-todolist]]))
#2017-10-0809:53Jondependency tree: container.cljs -> reel.cljs -> records.cljs#2017-10-0809:54JonI thought container.cljs will be reloaded as well when records.cljs changed?#2017-10-0810:06thhellerno. only direct dependencies.#2017-10-0810:06thhellerno change in records.cljs can affect code in container.cljs, so it doesn’t need to be reloaded#2017-10-0810:08Jona.cljs
(def a 1)
b.cljs
; imports a

(def b (inc a))
c.cljs
; imports b

(def c (inc b))
#2017-10-0810:08Jonhow about this?#2017-10-0810:08thhellerwell yeah, don’t use global state 😛#2017-10-0810:10Jonfunctions may be more stable..#2017-10-0810:10JonI ran into a situation that I want to detect if a component and pure function are changed after HMR,#2017-10-0810:11JonI was doing that by comparing the references. Since they may not change, my code does not work sometimes.#2017-10-0810:15thhellernot sure, I would usually recommend to use the :before-load :after-load functions and avoid global state#2017-10-0810:17thhellerhmm but even in your example? a.cljs = container.cljs, b=reel, c=records#2017-10-0810:17thhellerchanging c does not affect b or a#2017-10-0810:17Jonc is the container, and a is changing#2017-10-0810:18thhellerah yeah, I had the wrong order in my mind 🙂#2017-10-0810:18JonI knew comparing the references is too tricky. I was trying to reduce some unnecessary recalculations.#2017-10-0820:48mhuebertAlrighty. I’ve updated https://www.github.com/mhuebert/shadow-eval to 2.0.8, added a :bootstrap build. It compiles, but the last example that I had working in 2.0.7 now throws an error when I try to use the macros that I’ve required/referred in the namespace: Cannot read property 'findInternedVar' of null at line 4 \", :data {:file nil, :line 4, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null] Other expressions, like circle and the for macro, work as expected. Update: if I (require-macros '[cells.cell]), then the other expressions work. Maybe the :load-on-init namespaces aren’t loading their dependencies? (or macro dependencies?) I have shadow-eval.user in :load-on-init.#2017-10-0820:55mhuebertI also made another attempt at a bootstrap build w/ maria, and got stuck on The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc". error in compile. I have tried adding cljs.js and cljs.js$macros and cljs.env.macros and cljs.env.macros$macros to an :exclude option in the build, didn’t seem to make a difference. I can also replicate this in shadow-eval.#2017-10-0908:44thheller@mhuebert I don’t think it will be possible to compile cljs.js with the bootstrap build#2017-10-0908:44thhellerits the bootstrap within bootstrap thing again#2017-10-0908:48thhellerI think I found the problem, the “host” loads cells.cell, the bootstrap then incorrectly assumes that the cells.cell$macros are loaded as well#2017-10-0908:57thhellerdoh nope … I just forgot to put the analyzer info about macros into the index#2017-10-0909:00thhellerbtw to make your testing easier: I suggest using lein#2017-10-0909:00thheller
:lein true
 :nrepl {:port 8703}
#2017-10-0909:00thhelleradd that do your shadow-cljs.edn#2017-10-0909:01thhellerthen use shadow-cljs as a checkout dependency#2017-10-0909:02thhellerthe nrepl port usually is random, adding one in the config makes it easier to use#2017-10-0909:02thhellerthen run shadow-cljs server once and leave running#2017-10-0909:03thhellershadow-cljs watch bootstrap browser then as usual#2017-10-0909:05thhellerusing lein via shadow-cljs allows using checkouts and bypasses all AOT headaches#2017-10-0909:05thhellerthe shadow-cljs command really is not well suited for testing master#2017-10-0909:10thhellerwith the pushed fixed to master everything works#2017-10-0909:31mhuebertAh great#2017-10-0909:32mhuebertSo for cljs.js this is really just about the exclude option#2017-10-0909:32mhuebertThat we talked about the other day#2017-10-0909:36thhellerdo you have an example where it is actually needed?#2017-10-0909:37thhellerI think you just added cljs.js in an attempt to fix the problem?#2017-10-0909:37thhelleror does it really end up somewhere in there naturally?#2017-10-0909:41mhuebertI added cljs.js just to replicate the issue i have with Maria.user#2017-10-0909:42thhellerthis one? https://github.com/mhuebert/maria/blob/master/editor/src/maria/user.cljs#2017-10-0909:42mhuebertYes#2017-10-0909:46mhuebertNow I have to look.. the repl-specials namespace is what is pulling that in. Maybe it is unnecessary #2017-10-0909:48thhellergeez why is that project split into 50 projects#2017-10-0909:48thhellerdo you hate yourself? 🙂#2017-10-0909:48thheller
:source-paths ["src"
                 "test"
                 "checkouts/re_view/src"
                 "checkouts/re_view_hiccup/src"
                 "checkouts/re_view_routing/src"
                 "checkouts/re_view_prosemirror/src"
                 "checkouts/re_db/src"
                 "checkouts/cljs_live/src"
                 "checkouts/shapes"
                 "checkouts/friendly"
                 "../../lark/cells/src"
                 "../../lark/commands/src"
                 "../../lark/structure/src"
                 "../../lark/editors/src"
                 "../../lark/tree/src"]
#2017-10-0909:49thheller😛#2017-10-0909:49mhuebertI currently have the compiler state and the eval functions all in maria.eval. I could potentially move the compiler state into another namespace#2017-10-0909:50thhelleradding the :excludes option really is not a big deal, afaict it only needs to ignore macros anyways#2017-10-0909:50mhuebertHaha. I was having trouble getting figwheel to reload in changes in checkouts and so tried putting that all in source paths#2017-10-0909:50thhellerjust want to make sure that we don’t accidentally break everything by running bootstrap inside bootstrap#2017-10-0909:51thhellerfor checkouts you don’t really need to add the :source-paths, lein will pick them up#2017-10-0909:51mhuebertYeah. Let me try a little refactoring to allow Maria.user access to compiler state without cljs.js#2017-10-0909:52thhellerdo you use cursive?#2017-10-0909:55mhuebertyes#2017-10-0909:55mhuebert^autocorrect had turned ‘figwheel’ into ‘together’ and couldn’t fix on my phone#2017-10-0909:55mhuebert“I was having trouble getting figwheel to reload in changes in checkouts and so tried putting that all in source paths”#2017-10-0909:56thhellerah ok#2017-10-0909:57mhuebertI don’t even know if it worked, I should clean that up#2017-10-0910:01mhuebertso with :lein true, should i just keep the dependencies in project.clj#2017-10-0910:03thhelleryes, :source-paths and :dependencies from lein will be used in that case#2017-10-0910:05mhuebertand it will ignore the clojurescript/clojure deps#2017-10-0910:06mhuebertor do i take those out, i got a bunch of warnings about cljs.core#2017-10-0910:06mhueberti thought cursive needed clojure(script) to be in project.clj to resolve things#2017-10-0910:06thhelleryeah I’m using cursive myself#2017-10-0910:07mhuebertok shadow-eval works for me now too simple_smile#2017-10-0910:07thhellerall :lein true means is that the JVM will be launched via lein run instead of java#2017-10-0910:08thhellerwhich warnings about cljs.core?#2017-10-0910:09thhelleryou can also set :lein {:profile "+cljs"} which will then use the :cljs profile when launching#2017-10-0910:10thhellerso you can create a :cljs profile in project.clj and put some dependencies there is needed#2017-10-0910:10thhellerI do that for shadow-cljs itself#2017-10-0910:10thhellerok I looked at maria.eval, seem like you really need the exclude option 😉#2017-10-0910:11mhuebertwarnings: https://gist.github.com/mhuebert/7673a2fef08903fe66376806ab0d9671#2017-10-0910:11mhuebertso i thought i did, but what if I just put compiler-state into a different namespace.#2017-10-0910:11mhuebertI think that’s all i really need for introspection#2017-10-0910:12thhelleryou can always access the code by just using js directly#2017-10-0910:12mhuebertso maria.live.state will just define a blank atom, then maria.eval will reset the atom to (empty-env) and use it#2017-10-0910:12thhellersay if you eval js/maria.eval.c_state#2017-10-0910:12mhuebertyeah that would work too#2017-10-0910:13thhellerbut maria.user.loaders also accesses eval#2017-10-0910:13thhelleris that code the user is supposed to be able to use?#2017-10-0910:13mhuebertyes#2017-10-0910:14mhuebert(load-gist ...) is a convenience function#2017-10-0910:15mhuebertright so being able to exclude cljs.js allows us to enable eval in self-host, because we can expose a namespace that references cljs.js without following it#2017-10-0910:16thhellerits ok to follow since the “host” will always have those loaded#2017-10-0910:17thhellerjust need to stop the compiler from trying to compile the macros#2017-10-0910:18mhuebertah right#2017-10-0910:19mhuebertif :lein true is set, can i still have :source-paths that are only in shadow-cljs.edn#2017-10-0910:19thhellerno, it is completely ignored in that case#2017-10-0910:19mhuebertok#2017-10-0910:19thhellerlein will manage the classpath, which means checkouts work#2017-10-0910:20thhellershadow-cljs itself doesn’t support checkouts#2017-10-0910:21thhellerhmm#2017-10-0910:22thheller:excludes #{cljs.js} would ignore ALL macros of that namespace#2017-10-0910:22thhelleror JUST that macro ns?#2017-10-0910:27thhelleradded :exclude in master#2017-10-0910:28thheller
(ns shadow-eval.user
  (:require re-view-hiccup.core
            [cells.cell :refer [cell defcell]]
            [cells.lib :as cell :refer [interval timeout fetch geo-location with-view wait]]
            [shapes.core :as shapes :refer [listen
                                            circle square rectangle triangle path text image
                                            position opacity rotate scale
                                            colorize stroke no-stroke fill no-fill
                                            color-names rgb hsl rescale
                                            layer beside above
                                            fish            ; for functional geometry demo
                                            ;; are these internal only? -jar
                                            assure-shape-seq shape-bounds bounds shape->vector]]
            [re-view.core]
            [cljs.js]))
#2017-10-0910:28thhellerthis compiled#2017-10-0910:30thhellerhmm it might be loading too many macros now though#2017-10-0910:39mhuebertyeah, if there is a namespace that you know isn’t wanted in self-host, it might be useful to essentially pretend it doesn’t exist as far as dependencies go.#2017-10-0910:39mhuebertalso it will just be downloading and loading a lot of unnecessary analyzer data#2017-10-0910:40thhellerif that namespace is loaded by the “host” it won’t be downloaded#2017-10-0910:40thhellerthe :bootstrap build still needs to compile everything to ensure everything is correct#2017-10-0910:40thhellerit seems to work alright as far as I can tell#2017-10-0910:42thheller (:require-macros [cljs.core.async.macros :as m]) this compiled with the proper :exclude 😉#2017-10-0910:43thhellerjust can’t use it but thats expected#2017-10-0910:43mhuebertgreat#2017-10-0910:44thhellerthats what I mean by too many macros though#2017-10-0910:44thhellerI don’t think the user will ever need those?#2017-10-0910:45thhellermight be worth adding to :exclude (without the $macros)#2017-10-0910:46thhellermaybe they are actually required, I can’t really tell#2017-10-0910:50thhellerah ok found one issue#2017-10-0910:50thhellerwhich explains the cljs.env.macros issue#2017-10-0910:50thhellerits a .clj file https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/env/macros.clj#2017-10-0910:51thhellerrequired by https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.clj#2017-10-0910:52thheller[ :as io] this is not required, not sure why its thee#2017-10-0910:52thhellerwhen compiling as a macro namespace#2017-10-0910:53thhellerI still resolve :require as CLJS#2017-10-0910:53thhellerso it tries to load cljs.env.macros as CLJS, which it can’t find since its a .clj file#2017-10-0910:53thhellermaybe should change it so :require in macro files actually resolves as a macro#2017-10-0910:54thhellerwould be fixed if it was macros.cljc and the io require removed in CLJS#2017-10-0910:54thhelleranyways .. exclude is fine#2017-10-0910:58mhuebertone sec#2017-10-0910:58mhuebertto me this is a bit mind bending:
Even though the macros are defined in ClojureScript, they are defined in *.clj files. You can, if you wish, also define macros in *.cljc files, but when they are processed, the :cljs branch of reader conditionals will be used.
#2017-10-0910:59mhuebert(from http://planck-repl.org/source-dev.html)#2017-10-0911:01mhuebertwe have started a conversation about macros in maria: https://github.com/mhuebert/maria/issues/151#2017-10-0911:02mhuebertso if we exclude cljs.js, does it serve any purpose to include transitive macro dependencies of it?#2017-10-0911:03thhellerit depends if the USER is actually going to use those macros directly#2017-10-0911:04mhuebertright. i think if they are, then you could include them as a direct dependency in the user namespace#2017-10-0911:04thhelleryou can use it just fine inside maria, just everything eval’d by the user can’t use them directly#2017-10-0911:04mhuebertbut if they are a transitive dep of an excluded namespace, ignore them#2017-10-0911:04thhelleryeah I think that should be fine#2017-10-0911:04thhellermacros are far more complicated than I thought in self host#2017-10-0911:04mhuebertthat way you don’t have to specifically exclude all the transitive macro deps of cljs.js in addition to excluding cljs.js#2017-10-0911:05mhuebertyup#2017-10-0911:05thhellerwell I only exclude those dependencies from https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.clj#2017-10-0911:06thhellerI do not ignore those deps https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs#2017-10-0911:08thhellerso really the only thing missing is [ :as io] which we can’t import anyways#2017-10-0911:11thhellerdunno the whole cljs.js namespace seems a bit hacky, it shouldn’t even attempt things like requiring cljs.core$macros or the cljs.core analyzer data#2017-10-0911:11thhellerdumping the cljs.core analzyer data into the code just seems like a bad idea to begin with#2017-10-0912:20mhuebertok, so with current, Maria can now compile and eval with a shadow-cljs build 🙂. of the basic tests I run (https://www.maria.cloud/gist/8d7dd5bb0294b9623af0bc7c607f46d2?eval=true), only one fails, and that is (require '[cljs.js :as cljs]). I forgot that I even do that. I’ve tried putting cljs.env.macros into the :exclude but it still throws The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc". on compile. I’m guessing this relates to your comment above: > it tries to load cljs.env.macros as CLJS, which it can’t find since its a .clj file#2017-10-0912:29thheller@mhuebert yeah, I need to look more into what CLJS does in this case#2017-10-0912:29thhellerwhen compiling a macro namespace I treat :require as a CLJS require, ie. it looks for .clj(s|c) files#2017-10-0912:30thhellerI’m not sure what is fully correct#2017-10-0912:31mhueberti’m also not sure#2017-10-0912:31mhuebertgoing out for food#2017-10-0913:47thhellerbtw @mhuebert one thing you might want to consider for maria: do the read yourself to split user input properly#2017-10-0913:47thhellereg. if I input 1 2 3 4 5 I only get one result#2017-10-0913:48thhellerif you read and split it, you could get all 5#2017-10-0913:48thhellerand if you read you can check for defmacro and do the namespace dance automatically#2017-10-0913:49thhellerright now there only seem to be *-str functions in cljs.js though#2017-10-0913:57mhuebert@thheller: we actually do that already in cljs-live.eval#2017-10-0914:04mhuebertI am thinking about that namespace dance. It would be nice if evaluating defmacro in a non-macros namespace would put that into :macros in the analyser state, and then 'get-expander' would also look in cljs namespaces for macros. Since defmacro isn't currently used for anything at all in cljs namespaces AFAIK, this wouldn't conflict with any existing code, only enable better macros in self-host#2017-10-0914:11mhuebertThis is just thinking aloud, how crazy is it to think of shadow-cljs supporting compiling cljs namespaces that use defmacro? I have no idea how your builds work. The current way of doing things is complicated and an understandable but unfortunate artifact of decisions made years ago#2017-10-0914:12mhuebertWe definitely can't reasonably teach macros in Maria without doing this somehow, so incompatibility with existing clojurescript seems inevitable#2017-10-0914:44thhellerI can’t really add support for that to shadow-cljs itself since its the JVM compiler, I avoid everything self-hosted when I can.#2017-10-0914:45thhelleradding support for your use-case is different since its still just a normal CLJS compile that just adds a few things on top#2017-10-0914:45thhellerbut I’m never actually running anything of the self-hosted code myself#2017-10-0914:46mhuebertI see. So this would mean using the self-host compiler itself as part of the build#2017-10-0914:46thhellerbut adding defmacro to self-hosted really should not be that hard, you just can’t use the default compile-str or other *-str fns#2017-10-0914:47thhellerin shadow-cljs macros are eval’d in the JVM#2017-10-0914:47thhellerin theory it is easy to just eval defmacro forms in the JVM instead of generating JS#2017-10-0914:47thhellerit however gets very complicated when the macros want to call non-clojure.core code#2017-10-0914:48thheller(def foo []) (defmacro bar [] (let [x (foo)] '(whatever ~x))#2017-10-0914:48thhellerhow do I syntax quote 😛#2017-10-0914:49thhellermacros are allowed to use functions normally, but they wouldn’t exist if there is only special case handling for defmacro#2017-10-0914:51thhellerI thought a lot about this before since I wanted to make defmacro easier#2017-10-0914:51thhellerhttps://dev.clojure.org/jira/browse/CLJS-948 is the best I could come up with#2017-10-0914:53thhellerbut really in self-hosted mode you do not have the issue of 2 separate runtimes#2017-10-0914:53thhellerso it should be possible#2017-10-0915:03thhelleris there a trick in maria to see the actual JS that gets eval’d by a block?#2017-10-0915:20mhuebertYes, try command-p and search for js#2017-10-0915:20mhuebertI forget the shortcut#2017-10-0915:21mhuebertThat was a nice improvement (refer of macros as normal)#2017-10-0915:22mhuebertSo the only way to get real clojure-style macros is to eval them in a JS environment#2017-10-0915:22mhuebertI did this with cljs-live, used Planck#2017-10-0915:30thhellernot to eval “them” in a JS env#2017-10-0915:30thhellereval everything in a JS env#2017-10-0915:31thhellerbut even then I’m not quite sure how to get around the namespace issue#2017-10-0915:40thhellerhmmm#2017-10-0915:55mhuebertso command-shift-J for view js source. i was on my phone before#2017-10-0915:56mhuebertright, it would have to eval everything in a JS env#2017-10-0915:56mhuebertwhich namespace issue?#2017-10-0915:57thhellersec testing something, it might be pretty easy#2017-10-0916:00mhuebertok#2017-10-0916:08thhellerhttps://www.maria.cloud/gist/aee5dfdb9418c4f0ebc306369facc793?eval=true#2017-10-0916:08thhellercan you see changes I made?#2017-10-0916:08thhellerI’m not logged in or anything#2017-10-0916:09thhellerbut it seems to work 😛#2017-10-0916:12thheller
(in-ns 'cljs.core)

(defn get-expander* [sym env]
  (when-not (or (some? (gets env :locals sym)) ; locals hide macros
                (and (excluded? env sym) (not (used? env sym))))
    (let [nstr (namespace sym)]
      (cond
        (some? nstr)
        (let [ns (get-expander-ns env nstr)]
          (when (some? ns)
            (.findInternedVar ^clojure.lang.Namespace ns (symbol (name sym)))))

        (some? (gets env :ns :rename-macros sym))
        (let [qualified-symbol (gets env :ns :rename-macros sym)
              nsym (symbol (namespace qualified-symbol))
              sym (symbol (name qualified-symbol))]
          (.findInternedVar ^clojure.lang.Namespace (find-macros-ns nsym) sym))

        :else
        (let [cur-ns (gets env :ns :name)]
          (or (when (get-in @env/*compiler* [::namespaces cur-ns :defs sym :macro])
                (.findInternedVar (find-ns cur-ns) sym))
              (let [nsym (gets env :ns :use-macros sym)]
                (if (and (some? nsym) (symbol? nsym))
                  (.findInternedVar ^clojure.lang.Namespace
                  (find-macros-ns nsym) sym)
                  (.findInternedVar ^clojure.lang.Namespace
                  (find-macros-ns CLJS_CORE_MACROS_SYM) sym)))))))))

(in-ns 'maria.user)
#2017-10-0916:12thhellerI just hacked the get-expander* fn :else case to also check in the current ns for macros#2017-10-0916:12thhellerhad to remove the reader conditionals that are there usually#2017-10-0916:13thhellerah you can’t see my changes#2017-10-0916:13thhellersec let me gist the whole thing#2017-10-0916:13mhuebertif you sign in, then you can ‘Duplicate’#2017-10-0916:14mhuebertand it will save to your own gist#2017-10-0916:14mhuebertyou can also Command-P > ‘Print to console’, it will spit the whole gist to the console as a string#2017-10-0916:15mhuebertah, cool!#2017-10-0916:15mhuebertI tried something like this yesterday but didn’t figure out get-expander* well enough to work#2017-10-0916:17thhellerhttps://www.maria.cloud/gist/e9f1ef4f77f8598a0cce7c07f0d6be7b?eval=true#2017-10-0916:17thhellerthe get-expander* hack would be something you do when bootstrapping#2017-10-0916:17thhellerbut with that macros in the current ns just work#2017-10-0916:19mhuebertthis is a great little patch 😀#2017-10-0916:21thhellerI understand why its not something core does by default#2017-10-0916:21thhellerbut for projects like maria it would totally make sense to support this#2017-10-0916:23mhuebertand because these are in the same namespace, macros can reference other things in the same namespace from within syntax quote, and it just works#2017-10-0916:25mhuebertwith the shadow bootstrap build, is :dump-core disabled? ie. avoids spitting the cljs core compiler state into cljs.js?#2017-10-0916:25thhelleryes always disabled, you can’t even enable it 😉
#2017-10-0916:28mhuebertgreat#2017-10-0916:30thhellerfun to hot patch the analyzer like that 😛#2017-10-0916:35mhuebertthat’s what is so great about a live environment#2017-10-0916:36mhuebertwas there a way to enable adding timestamps/hashes to the bootstrap outputs?#2017-10-0916:36thhelleralready done, shadow-cljs release bootstrap#2017-10-0916:36mhuebertahhh release#2017-10-0916:38thhellerdidn’t seem to make much sense for dev#2017-10-0916:38mhuebertcorrect#2017-10-0916:45mhueberta namespace that is :exclude‘d, I think I’d want to just load its analysis cache#2017-10-0916:47mhuebertbe back later#2017-10-0916:49thhellerwhat if you just (doc cljs.js/eval-str) without the require? I’m currently only excluding the cljs.js macro ns from compilation#2017-10-0916:50thhellerI do not remove the require for it#2017-10-0917:07mhuebertthat works. I see, so the analysis cache is already loaded.#2017-10-0917:08mhuebertso you could have it referred into precompiled namespaces, but not (require ...) it or put it in an (ns ..) form#2017-10-0917:08thhelleryes#2017-10-0917:09thhellerbut that could be fixed as well#2017-10-0917:15mhueberti think that would be useful, ensure that we can still use precompiled namespaces even if they have unfriendly macro deps?#2017-10-0917:16mhuebertthen all of the self-host-related code that i’m aware of us using with Maria will work#2017-10-0917:18mhuebertnext step will be for me to sort out the javascript deps + externs for the outer frame (an :advanced build, eval happens in a iframe isolated from auth tokens etc.) but that should be more straightforward 🙂#2017-10-0917:35thheller@mhuebert master should have a fix for the macro deps, didn’t test it but should work 😛#2017-10-0917:35mhuebert🙂#2017-10-0917:37thhellerit only removes the macro require info from the index#2017-10-0917:37thhellermight be useful to emit all excludes into the index itself but just pretending that it doesn’t require the macro should be fine#2017-10-0919:09thheller@mhuebert btw I wanted to build a UI for shadow-cljs for quite some time now. I might steal some ideas from Maria for the quick-start mode 😉#2017-10-0919:10thhellerlet users start playing with code immediately and then have some kind of UI widget guide them through generating a proper build config#2017-10-0920:07mhuebertSounds like a good idea#2017-10-0920:07mhuebertlet me know if you’d like help or feedback#2017-10-0920:13mhuebert@thheller I’ve pulled from master and attempted to (require '[cljs.js :as cljs]), still getting the same:
ns cljs.js$macros not available
Could not require cljs.js
#2017-10-0920:15thhellerok, I’m about finished with this other thing. will take a look after.#2017-10-0920:15mhuebertno rush#2017-10-0920:37thhellerweird#2017-10-0920:41thheller(require '[cljs.js :as cljs]) this works#2017-10-0920:43thhellerdid you try in https://github.com/mhuebert/shadow-eval? it works in my simple example but that doesn’t have to mean much.#2017-10-0920:44thheller
(ns my.foo (:require [cljs.js :as cljs]))
   (js/console.log cljs/eval-str)
also works
#2017-10-0920:52mhuebertstill seeing the long string of cljs.core warnings in shadow-eval#2017-10-0920:52mhuebertand ns cljs.js$macros not available#2017-10-0920:52mhuebertshadow-cljs still on 2.0.8?#2017-10-0920:53thhellerjust bumped to 2.0.9#2017-10-0920:54thhellerah right, totally forgot about those cljs.core warnings#2017-10-0920:54thhellernever saw them before, no idea whats going on#2017-10-0920:54mhuebertok#2017-10-0920:56mhueberttrying with 2.0.9, same errors#2017-10-0920:56mhueberti have to crash and have some meetings tomorrow so i won’t get back to this till later#2017-10-0920:58thhellerok, I’ll try to reproduce. might just be related to too much version mockery and bad AOT artifacts#2017-10-0920:58mhuebertyou have cljs.js directly in entries as well as in exclude, i only have it as a transitive dep of another entry. shouldn’t make a difference i don’t think#2017-10-0920:59thhelleryeah :exclude should correctly be called :exclude-macros as its only for excluding macros#2017-10-0920:59thhellerbut no if something else requires cljs.js thats basically the same as :entries [cljs.js]#2017-10-0921:00thhellerI’m not seeing those warnings#2017-10-0921:01thhellerin the shadow-eval project (or my own)#2017-10-0921:01thhellermaybe try deleting target/shadow-cljs?#2017-10-1007:37mhuebertI tried deleting all the caches#2017-10-1007:38mhuebertCould it be from having cljs in project.clj? #2017-10-1007:47thhellercan you track down which files causes those errors?#2017-10-1007:48thhellerFile: :477:1 this is totally weird#2017-10-1007:49thhellerah nvm, its actually cljs.core#2017-10-1007:50thhellerwhich makes this even weird since those warnings are actually correct#2017-10-1007:50thhellerwhy don’t they always appear 😛#2017-10-1007:52thhellerhmm no .. not correct .. nevermind#2017-10-1007:52thhellerdo you get them for the :bootstrap build?#2017-10-1008:05thhellerI don’t get it … I never get those warnings. with lein or without#2017-10-1016:04mhuebertwhat a mystery.#2017-10-1016:05mhuebertI just pushed an update to shadow-eval which adds the cljs.js example. It still fails for me.. I even tried cloning shadow-eval fresh, yarn install and then shadow-cljs watch bootstrap browser. this is after a lein install of shadow-cljs master.#2017-10-1016:06mhuebertand i see all the warnings.#2017-10-1016:14thhellerha! I got them now too#2017-10-1016:16thhellerand now they are gone … what the heck#2017-10-1016:23thhellercan you confirm that this only happens ONCE on the initial compile and only when compiling both builds at once?#2017-10-1016:24mhueberthmm#2017-10-1016:25mhuebertyes, that’s correct. when re-building, I only see the cljs.core/uri? warning#2017-10-1016:26mhueberthaven’t tried with only one build#2017-10-1016:26mhuebertby ‘initial compile’ do you mean after removing the target folder#2017-10-1016:27mhuebertremove target & watch bootstrap — no warning#2017-10-1016:29mhuebertremove target & watch browser — only uri? warning#2017-10-1016:29mhuebertremove target & watch browser bootstrap — all the warnings#2017-10-1016:29thhelleryes once the cache excists the warning disappears, which wis weird in itself since nothing is cached when warnings exist#2017-10-1016:30thhellerok, but now I can reproduce this#2017-10-1016:30thhellershouldn’t be long 😉#2017-10-1016:33mhuebert🙂. could the cljs.js require error be related to this?#2017-10-1016:33mhuebertwhen I compile the sample /dev project in shadow-cljs, it appears to work. but in shadow-eval I keep getting this error. staring at shadow-cljs.edn and the source, just can’t see anything of difference#2017-10-1016:34thhellereach build should be totally isolated, so no it should not be related#2017-10-1016:35thhellerbut it might be … I’m really confused here 😛#2017-10-1016:44thhellerhmm I fixed something seemingly unrelated but now it seems fixed#2017-10-1016:49thhellernope. restarting the process and its back#2017-10-1016:50thheller
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/zilence/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:673:1
--------------------------------------------------------------------------------
 669 |   "Protocol for accessing the metadata of an object."
 670 |   (^clj-or-nil -meta [o]
 671 |     "Returns the metadata of object o."))
 672 |
 673 | (defprotocol IWithMeta
-------^------------------------------------------------------------------------
 674 |   "Protocol for adding metadata to an object."
 675 |   (^clj -with-meta [o meta]
 676 |     "Returns a new object with value of o and metadata meta added to it."))
 677 |
 678 | (defprotocol IReduce
--------------------------------------------------------------------------------
Call to cljs.core/defn did not conform to spec
In: [1] val: G__34000 fails spec: :clojure.core.specs.alpha/arg-list at: [:args :bs :arity-1 :args] predicate: vector?
In: [1] val: G__34000 fails spec: :clojure.core.specs.alpha/args+body at: [:args :bs :arity-n :bodies] predicate: (cat :args :clojure.core.specs.alpha/arg-list :body (alt :prepost+body (cat :prepost map? :body (+ any?)) :body (* any?)))

--------------------------------------------------------------------------------
#2017-10-1016:50thhellerwhat the heck is going on 😛#2017-10-1017:05thhellerthere is definitely something going on with the threads, can’t quite figure it out yet#2017-10-1017:07thheller
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/zilence/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:693:1
--------------------------------------------------------------------------------
 689 |   (-kv-reduce [coll f init]
 690 |     "Reduces an associative collection and returns the result. f should be
 691 |      a function that takes three arguments."))
 692 |
 693 | (defprotocol IEquiv
-------^------------------------------------------------------------------------
 694 |   "Protocol for adding value comparison functionality to a type."
 695 |   (^boolean -equiv [o other]
 696 |     "Returns true if o and other are equal, false otherwise."))
 697 |
 698 | (defprotocol IHash
--------------------------------------------------------------------------------
Call to cljs.core/defn did not conform to spec
In: [1] val: G__32443 fails spec: :clojure.core.specs.alpha/arg-list at: [:args :bs :arity-1 :args] predicate: vector?
In: [1] val: G__32443 fails spec: :clojure.core.specs.alpha/args+body at: [:args :bs :arity-n :bodies] predicate: (cat :args :clojure.core.specs.alpha/arg-list :body (alt :prepost+body (cat :prepost map? :body (+ any?)) :body (* any?)))

--------------------------------------------------------------------------------
#2017-10-1017:07thhellerthis is not fun 😛#2017-10-1017:28mhuebertdoesn’t sound like it!#2017-10-1017:30thhellerthere must be some race condition when compiling cljs.core#2017-10-1017:30thhellersomething that should lock but doesn’t#2017-10-1017:34thhellerI’m absolutely lost … even if I lock and allow only compiling one form at a time I get this error#2017-10-1017:48thhellerI need a break, not the slightest idea what might be causing this.#2017-10-1017:52thheller@mhuebert since you just brought it up in #cljs-dev, I totally want to hear about your experience with JS deps. but not now, head is too full.#2017-10-1017:52thhellerbbl#2017-10-1020:18mhueberthappy to discuss whenever#2017-10-1020:20mhuebertI think I really like this ability to explicitly decide, for any given build, how to resolve a name#2017-10-1020:34thhellerfollowing the discussion in #cljs-dev you seem to have the experience I had#2017-10-1020:35thhellerunclear semantics, “magic” symbols, conflict between npm-deps+foreign-libs#2017-10-1020:37thhellerwhether or not something is in node_modules really shouldn’t have any impact on anything#2017-10-1020:39thhellerback to wrestling this race condition, can’t let that defeat me 😛#2017-10-1020:43thhelleronly happens when compiling cljs.core at the same time in multiple threads. which should not be an issue since each thread has its own compiler env binding and should be totally isolated.#2017-10-1020:43mhuebertweird#2017-10-1020:44mhuebertI unfortunately don’t know anything about working with threads 😕#2017-10-1020:45thhellerseems like I don’t either 🙃#2017-10-1020:47mhuebertis there a built-in way to init a new shadow-cljs project? not that it’s super necessary, as config is so simple, but 🙂#2017-10-1020:47thhellershadow-cljs init#2017-10-1020:47mhuebertoh should have looked!#2017-10-1020:48mhuebertah so this is done inside a fresh directory#2017-10-1020:48mhuebertmakes sense#2017-10-1020:48thhellerproblem also goes away if I add (Thread/sleep (rand-int 2000)) before starting the build … fun times 🙂#2017-10-1020:48mhuebertmadness#2017-10-1020:52thhellerre init: I thought about creating a few small templates to make quickstart easier. even with the simplified config it still a bit of work to get started.#2017-10-1020:53thhellerits still way too hard to get started IMHO#2017-10-1020:53mhuebertyeah, I am setting it up now and there are a few more steps than I remembered#2017-10-1020:54mhuebertto get a dev server going, basic index.html, etc#2017-10-1020:54thhelleryeah something like chestnut to get all that going#2017-10-1021:17mhuebertis there a way to specify in :js-options that react should be resolved to the node module?#2017-10-1021:19mhuebert
"react"
     {:target :npm
      :require "react/cjs/react.development.js"
      :require-min "react/cjs/react.production.min.js"}
#2017-10-1021:20mhuebertthat still leaves me with The required namespace "react" is not available, it was required by "re_view/util.cljc".… would all upstream apps need to use string-require syntax for something like this to work?#2017-10-1021:23thhellerthe symbols should work, I need to support that since CLJS supports it.#2017-10-1021:25thhellerdoes node_modules/react/cjs/react.development.js exist? I do not yet handle installing node deps#2017-10-1021:26thhellerso it might just be a bad error message?#2017-10-1021:26mhuebertthere is a note that React 16 is not yet supported#2017-10-1021:27mhuebertso I think I will just do the ‘resolve’ way for now#2017-10-1021:27mhuebertwith a script tag#2017-10-1021:27mhuebertor is that only if :js-provider :shadow is set?#2017-10-1021:27thhellernot yet supported by who? I tried it and will move my app into production with it tomorrow#2017-10-1021:28mhuebertin shadow-cljs builds there was a note that the React 16 NODE_ENV require (or sth like that) is not supported#2017-10-1021:28thhellerright yes, thats why you need the :require and :require-min.#2017-10-1021:29mhuebertah i see.#2017-10-1021:29thhellerotherwise they do this#2017-10-1021:29thheller
'use strict';

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./cjs/react.production.min.js');
} else {
  module.exports = require('./cjs/react.development.js');
}
#2017-10-1021:29thhellerwhich is a dynamic require which neither shadow or closure support#2017-10-1021:31thhellerthe :resolve {"react" ...} should work, regardless of whether you do (:require [react]) or (:require ["react" :as react])#2017-10-1021:31thhellerdid you verify that The required namespace "react" is not available, it was required by "re_view/util.cljc". has a node_modules/react/cjs/react.development.js in the project dir?#2017-10-1021:32thhellerif that file (and the other one) exists its a bad bug#2017-10-1021:32thhellerif if doesn’t exist its a bad error message#2017-10-1021:32thhellereither way something I want to fix#2017-10-1021:33thhellerverify that node_modules/react/package.json is from React v16 please#2017-10-1021:54mhuebertI had either not installed or uninstalled react/react-dom#2017-10-1021:55mhueberti think that was just my fault#2017-10-1021:55mhuebertit wasn’t in node_modules#2017-10-1021:55thhelleryeah, thats the issue with using react as a symbol#2017-10-1021:56thhellerI can’t decide if you mean a CLJS namespace or something that should be in node_modules#2017-10-1021:56thhellerif you use a string I KNOW that you are referring to a JS dependency#2017-10-1021:57mhuebertyes exactly. i would like some explicit indication of whether a thing will resolve to node_modules or classpath. a “string-name” or npm/namespaced or something else. but now I have a strange error, it seems to be loading an old version of clojurescript despite a fresh project.clj, yarn install of shadow-2.0.8#2017-10-1021:58richiardiandreaI have found using symbols for JS neat and confusing at the same time (pure personal feedback disclaimer)#2017-10-1021:58thhellerRuntimeException: Unable to find static field: INFERRED_CONST_CHECKS in class com.google.javascript.jscomp.DiagnosticGroups yes old version of something#2017-10-1021:58thhellerthe deps are way too brittle, I need to fix this#2017-10-1022:01thhellercan you give me your :dependencies? I need a list I can reproduce this with.#2017-10-1022:01mhueberthttps://github.com/mhuebert/keys-test#2017-10-1022:02thheller@richiardiandrea I prefer reliability over magic syntax sugar though 😉#2017-10-1022:02richiardiandreayeah agree#2017-10-1022:03thheller@mhuebert put shadow-cljs first in :dependencies#2017-10-1022:06mhuebertah, that was easy#2017-10-1022:06thhelleryeah, thats a lein thing I can’t do anything about 😞#2017-10-1022:07thhellerall libraries should use :scope "provided" when using clojurescript in :dependencies#2017-10-1022:07mhuebertyeah I didn’t know about that till you mentioned it#2017-10-1022:08thhelleryeah, its usually not a problem since projects will have clojurescript themselves in :dependencies#2017-10-1022:08thheller(which you could also do in this case)#2017-10-1022:08mhueberttiny feedback: if the dev server would print sth like localhost:THE_PORT when it starts, that’s a clickable link in my terminal#2017-10-1022:09thhellergood idea#2017-10-1022:10thheller
Oct 11, 2017 12:09:35 AM clojure.tools.logging$eval15877$fn__15880 invoke
INFO: :shadow.cljs.devtools.server.dev-http/http-serve {:http-port 8705, :http-root out/public, :build-id :browser}
#2017-10-1022:10thhellerthats supposed to be exactly that 😛#2017-10-1022:11thhellerneed to fix this ugly logging style#2017-10-1022:14mhuebertend of day for me. g’night#2017-10-1022:14thhellergn8#2017-10-1022:14thhellerstill fighting the threads 😛#2017-10-1022:44thhellerfound it, fixed it, reported it https://dev.clojure.org/jira/browse/CLJS-2381 😉#2017-10-1022:45thhellerluckily I can fix it without waiting for core to fix it#2017-10-1022:47thhellerreleased {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9aab1b8bdb6aef4bab5b3aa99ebf7e9f7e8e9"}, :content ("[email protected]")} with fix#2017-10-1023:10thheller@mhuebert btw I absolutely do not recommend using :lein true. that bypasses all optimizations I have done to improve startup times and makes everything way slower. makes sense when using a checkout dependency of shadow-cljs itself in a project but otherwise it should be avoided.#2017-10-1023:12thhellerIts a bit annoying that Cursive requires a project.clj to work properly. maybe I take care of https://github.com/thheller/shadow-cljs/issues/70 tomorrow.#2017-10-1108:58mhuebert@thheller ok, great to know re: :lein true#2017-10-1109:57mhuebertare :js-options documented?#2017-10-1110:00mhuebertwondering the best way to handle something like this:
[:browser] Build failure:
errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
{:js-requires ["events" "string_decoder"], :js-imports [], :js-invalid-requires [], :js-language "es3", :js-errors [{:line 374, :column 30, :message "Octal integer literals are not supported in strict mode."} {:line 375, :column 30, :message "Octal integer literals are not supported in strict mode."}], :js-warnings [{:line 36, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 76, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 104, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 117, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 130, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"}], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
#2017-10-1110:08mhuebertmy current workaround is to include the keypress lib in a <script> tag and then a :js-option {"keypress": {:target :global :global "keypress"}}#2017-10-1110:23thhellerinteresting error, I’ll check it out#2017-10-1110:26thhellerhmm that looks like a node package? are your building for the web or node?#2017-10-1110:26mhuebertweb#2017-10-1110:27mhuebertoh wait#2017-10-1110:27mhuebertsorry#2017-10-1110:27mhuebertnaming thing#2017-10-1110:27thhellervar EventEmitter = require('events').EventEmitter; events is a node built-in#2017-10-1110:27mhueberti thought this was a different library#2017-10-1110:28mhuebertthere is a popular library called “Keypress” and I just assumed#2017-10-1110:28thhellerhehe#2017-10-1110:28mhuebert🙄#2017-10-1110:28thhellerkeypress.js maybe?#2017-10-1110:29mhuebertthat would be it#2017-10-1110:30thhellerwill add a formatter for that error#2017-10-1110:30mhuebert
module without entry or suffix: keypress.js
{:package {:package-name "keypress.js", :package-dir #object[java.io.File 0x2e477178 "/Users/MattPro/Documents/sites2017/keys/node_modules/keypress.js"], :package-json {"name" "keypress.js", "version" "2.1.4", "main" "keypress.js", "description" "a robust keyboard input capturing Javascript utility focused on input for games. For details and documentation, please visit ", "devDependencies" {"jasmine" "1.3.0"}, "spm" {"main" "keypress.js", "ignore" ["compiler.jar"]}}, :version "2.1.4", :dependencies #{}}, :entry "keypress.js"}
ExceptionInfo: module without entry or suffix: keypress.js
#2017-10-1110:30mhueberti’ll try the react way#2017-10-1110:31thhellerits one of those weird packages#2017-10-1110:31thheller "main" : "keypress.js", yet there is no keypress.js file in the directory, only a keypress.coffee#2017-10-1110:33mhuebert
{:target  :npm
 :require "keypress.js/keypress-2.1.4.min.js"}
#2017-10-1110:33mhuebertthat works#2017-10-1110:33thhellerexactly, I was about to suggest that#2017-10-1110:33mhuebertit exports an object with {"keypress": <the-fn>}#2017-10-1110:33thhellerreally something that should be done by the package but oh well#2017-10-1110:34mhuebert
# Anonymous Module Definition
if typeof define is "function" and define.amd
    define [], ->
        return keypress
else if exports?
    exports.keypress = keypress
else
    window.keypress = keypress
#2017-10-1110:34thheller(:require ["keypress.js" :refer (keypress)])#2017-10-1110:35mhuebertyup just did that and it works#2017-10-1110:36thhellerhttps://github.com/dmauro/Keypress/issues/130 5 Dec 2016 still not fixed 😞#2017-10-1110:38mhuebertso string requires also work with the other cljs build tools - meaning i can switch all my libraries to (:require [“react” as react])?#2017-10-1110:39thhelleryes they should#2017-10-1114:30mhuebertmaybe out of scope, but is there a way to specify a fallback for the dev server? (eg. for pushstate routes, so /whatever/non/file/route returns index.html)#2017-10-1114:46richiardiandreaReading about resolve in #cljs-dev I had the feeling that :type should default to :npm most of the time (convention over configuration they say?) - just an idea @thheller #2017-10-1115:14thheller@richiardiandrea :type? you mean :target? :resolve is optional, the default is to look up :npm. you only specify :resolve if you want to override something.#2017-10-1115:17thheller@mhuebert I could allow specifying a custom ring handler if required#2017-10-1116:04mhueberthumm. hinting externs..#2017-10-1116:05mhuebert
(ns my.app (:require ["keypress.js" :refer [keypress]]))
(defonce Keypress (new (.-Listener keypress)))
#2017-10-1116:05mhuebertnew $module$node_modules$keypress_js$keypress_2_1_4_min$$.$keypress$.$Listener$; the referred keypress as well as Listener are renamed by the compiler & so it breaks#2017-10-1116:08mhuebertthe only way I currently know how to get this working is pretty ugly:
(ns my.app (:require ["keypress.js" :as KP] 
                     [goog.object :as gobj]))
(defonce Keypress (new (gobj/getValueByKeys KP "keypress" "Listener")))
#2017-10-1116:09mhuebertnot sure how one could add hints somewhere here, or write an externs file that references things brought in from node_modules#2017-10-1116:13richiardiandrea@thheller cool that's exactly what I would expect 😉#2017-10-1116:25thheller@mhuebert try running shadow-cljs check browser with the first version#2017-10-1116:27mhuebert
38 | (defonce Keypress (new (.-Listener keypress)))
-----------------------------------------^--------------------------------------
 Property keypress never defined on module$node_modules$keypress_js$keypress_2_1_4_min
#2017-10-1116:27thhellerotherwise create an externs.js file somewhere#2017-10-1116:27thheller
/**
 * @externs
 */


/** @constructor */
var X = function() {};

X.prototype.Listener;
X.prototype.keypress;
#2017-10-1116:27thhellerthen in the build config :compiler-options {:externs ["path/to/that-file.js"]}#2017-10-1116:28thhellerProperty keypress never defined on only this part is important#2017-10-1116:28thhellerthe property is unknown#2017-10-1116:28mhueberti haven’t written externs by hand in awhile.. so X can be anything, doesn’t have to match module$node_modules$keypress...#2017-10-1116:28thhelleryes, since CLJS is untyped X can be anything#2017-10-1116:28thhellerbut that “helps” us#2017-10-1116:29thhellerX.prototype.keypress basically tells the compiler that whenever it finds some.keypress property access and it doesn’t know the type of some to not rename it#2017-10-1116:30thhellerie. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/externs.js#2017-10-1116:30thhellerthose are all the externs I use for the shadow-cljs script itself#2017-10-1116:31thhellershadow-cljs check is meant as a quick way to find things that need externs#2017-10-1116:31thhellerbtw not sure if you know that but shadow-cljs release browser --pseudo-names enables pseudo names to help debugging issues such as this#2017-10-1116:31thhellerno need to fiddle with the config 😉#2017-10-1116:32thhelleralso shadow-cljs release browser --debug but source maps are currently not totally accurate once you use a JS dependency#2017-10-1116:32thhellerstill working out how to fix that#2017-10-1116:32mhuebertah that’s a handy flag#2017-10-1116:32thheller--debug is --source-maps + --pseudo-names#2017-10-1116:33thhellerI totally want to automate externs more … it should be possible to make it work automatically without additional config#2017-10-1116:34thhellerjust needs some work (and time)#2017-10-1116:35thhelleranyways .. externs are not scary … don’t do this gobj/getValueByKeys 😉#2017-10-1116:35thhellerI can totally fix the :refered names though. those should never need externs.#2017-10-1116:36mhuebertare there a lot of cases where externs files do more than list property names of the form you just showed?#2017-10-1116:37thhellerit depends on the goals. in my cases never.#2017-10-1116:38thhellerthe Closure Library is fully typed, CLJS is not. so there are going to be cases where closure will be unable to infer the type of a thing#2017-10-1116:38thhelleryou can typehint all externs but that only benefits you if everything is typed#2017-10-1116:39thhellerIMHO it is not necessary to typehint externs#2017-10-1116:39mhuebertso in many cases, a sufficient externs file could be generated from a vector of property strings#2017-10-1116:40thhelleryes, in fact I should totally add that 😉#2017-10-1116:40thhellerthe problem with externs is that they may actually hurt#2017-10-1116:41thhellerso if you have too many it might stop renaming things it could otherwise rename#2017-10-1116:41thhellersay if you have (defn render [] ...) in CLJS, the render name would usually be renamed#2017-10-1116:41thhellerbut if you have render ANYWHERE in the externs it will not be renamed#2017-10-1116:42thhellereven if you never have any native JS that has a render property#2017-10-1116:44thhellernot yet sure what the best course of action is for externs#2017-10-1116:44thhellerworst case is you keep a few extra KB of js if you have too many#2017-10-1116:46mhuebertyeah, and because these things are by definition repetitive, may not have a huge impact after gzip?#2017-10-1116:47thhellerthe problem is that it also stops DCE, not just the rename#2017-10-1116:47thhellerso even if you never use render it will stay.#2017-10-1116:48thhellerstill should not be a huge impact, could always let someone write specialized externs#2017-10-1116:48thhellerI will totally add support for an externs.txt, one string per line equals one property#2017-10-1116:49thhellernever thought of that before 🙂#2017-10-1116:49thhellernice idea#2017-10-1116:49thhellerafk, shopping#2017-10-1116:58mhuebertoh, i see.#2017-10-1210:59Jon
goog.require('shadow.js.shim.module$fs');
#2017-10-1210:59Jon
["fs" :as fs])
#2017-10-1211:00Jon
=>> node target/main.js
SHADOW import error /Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js

/Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js:19
})());
  ^
ReferenceError: fs is not defined
    at /Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server/main.cljs:14:10
    at Object.<anonymous> (/Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/server.main.js
#2017-10-1211:00Jonlooks strange. I thought it's compiled to require('fs')#2017-10-1211:54thhellercheck /Users/chen/repo/cumulo/cumulo-workflow/server/target/shadow-cljs/builds/app/dev/out/cljs-runtime/shadow.js.shim.module$fs.js#2017-10-1211:54thhellerI might have broken that accidentally#2017-10-1211:54thhellerit should contain shadow.js.shim.module$fs = require("fs");#2017-10-1211:55thheller+ goog.provide#2017-10-1211:57thhellerserver/main.cljs:14:10 whats there?#2017-10-1211:57thhellermaybe you do (js/fs.something ...)?#2017-10-1212:00thhellershould be (fs/something ...)#2017-10-1212:00thhellertested, not broken#2017-10-1212:01thhellerhttps://github.com/Cumulo/cumulo-workflow/blob/master/server/src/server/main.cljs#2017-10-1212:02thhelleryes, fs.existsSync is not valid .. use (fs/existsSync ...) (and the others)#2017-10-1212:02thhellerdoes that not produce a warning?#2017-10-1212:27mhuebertI don’t think we have covered this before.. I need to debug a javascript library that is included in my build. Is there a way to include a js file/package that is not in node_modules, but have it otherwise be treated the same? (somehow I need to include my own fork of Keypress.js with a minimum of fuss)#2017-10-1212:59Jon
goog.provide("shadow.js.shim.module$fs");
shadow.js.shim.module$fs = require("fs");
#2017-10-1212:59Joncode is there..#2017-10-1213:00Jon... my code was using fs.x...#2017-10-1213:07Jonworking now.. so it's fs/existsSync#2017-10-1213:23Jonshadow-eval?#2017-10-1213:28mhuebert@jiyinyiyong it’s just a sample project using the latest :bootstrap build ability of shadow-cljs#2017-10-1213:28Jonnow shadow-cljs bootstraps?#2017-10-1213:29mhuebertyes 🙂 it’s great. just working out the final bugs/limitations but it is already quite capable#2017-10-1213:29mhueberthttps://github.com/mhuebert/shadow-eval#2017-10-1213:29Jonnot see docs XD#2017-10-1213:31mhuebertI just added a readme to that repo#2017-10-1213:32mhuebert& updated the readme again.. I am not entirely sure if it will ‘just work’ but you can have a try#2017-10-1213:33mhuebertif you can follow the above directions & then see the same thing as the screenshot I posted, then it is working the same as on my machine#2017-10-1213:37Jonsounds cool anyway#2017-10-1213:40Jon
(defn eval-str [source cb]
  (cljs/eval-str
    c-state
    source
    "[test]"
    {:eval cljs/js-eval
     :load (partial boot/load c-state)
     :ns   (symbol "shadow-eval.user")}
    cb))
#2017-10-1213:40Jonwhat does "[test]" mean in this example?#2017-10-1213:41mhuebertthe cljs compiler just needs some string provided as a ‘name’ for the current thing being evaluated. in normal builds this would be the filename. in self-host, there is no “file” so you can specify this to be whatever you want. it will show up in stacktraces etc.#2017-10-1213:41Jonoh, a fake file name#2017-10-1214:06thheller@mhuebert :resolve {"keypress.js {:target :file :file "path/to/file/from/project-root.js"}}#2017-10-1214:07thhellerwill look into the other issue#2017-10-1214:14mhuebert@thheller oh great, that’s simple. Just had a friend test a fresh install (never had shadow-cljs installed before) using the new instructions in the shadow-eval readme. It all works exactly like on my machine 🙂 including the errors in the first two blocks.
#2017-10-1214:15mhuebertif shadow-cljs is installed globally, and not run using yarn run shadow-cljs .., does it still use the version specified in package.json?#2017-10-1214:15mhuebertor does one always have to use yarn run ... to get the specified version#2017-10-1214:16thheller
`------ ERROR -------------------------------------------------------------------
 File: /Users/zilence/code/tmp/shadow-eval/src/shadow_eval/user.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow-eval.user
-------^------------------------------------------------------------------------
   2 |   (:require re-view-hiccup.core
   3 |             [cells.cell :refer [cell]]
   4 |             [cells.lib :as cell
   5 |              :refer [interval timeout fetch geo-location with-view]
   6 |              :refer-macros [wait]]
--------------------------------------------------------------------------------
Invalid :refer, var shapes.core/fish does not exist
#2017-10-1214:17thhellershadow-cljs will use the version from the project IF installed, otherwise global#2017-10-1214:17thhellerit prints the version when starting#2017-10-1214:20thhellerok, I can just remove the fish then it compiles with the cljs.js errors at runtime#2017-10-1214:20thhellerinvestigating#2017-10-1214:22mhuebertoh i think i just pushed an update for that#2017-10-1214:22mhuebertmaybe a minute after you tried#2017-10-1214:22mhuebertfish was removed#2017-10-1214:22mhuebertfrom shadow-eval.user#2017-10-1214:25thhellerwhy do you require cljs.js in the first place?#2017-10-1214:26thhellerthe issue is that cljs/js.clj can never be loaded#2017-10-1214:27thhellerbut it seems like require tries to load it no matter what#2017-10-1214:27thhellernot sure why#2017-10-1214:28thhellerhttps://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.clj#L13 this line prevents it from ever being compilable#2017-10-1214:29mhueberti require cljs.js just because i want to use shadow-eval to sort out all these issues that are also present in maria, without all the complexity of maria at hand#2017-10-1214:30mhuebertand it is very useful to be able to use all the stuff in cljs.js#2017-10-1214:30thhellerbut why does maria need the require? the shadow-eval.user already ensures that it is loaded?#2017-10-1214:31thhellerthat works, its only the eval require that doesn’t work#2017-10-1214:31mhuebertthe user might create a namespace and want to refer it#2017-10-1214:31thhellerah#2017-10-1214:31mhuebert(require '[cljs.js :as cljsjs]) (cljsjs/eval-str ...)#2017-10-1214:31mhuebertor whatever#2017-10-1214:32mhuebertand i think this will happen with any namespace that requires macros which don’t work in self-host. but we still want to be able to use those namespaces.#2017-10-1214:32thhellerso bootstrap within boostrap, my head hurts already 😉#2017-10-1214:32thhellerso the only thing I can think of is to ignore the load request#2017-10-1214:33thhellerand just pretend that its loaded#2017-10-1214:33thhellerbut that just delays the problem until the user tries to use a macro from that namespace#2017-10-1214:33mhueberthehe yeah. i think this all comes down to functioning :exclude or :no-follow or :ana-only or whatever options, ways of somehow saying “i have these namespaces which are preloaded and i just want to load the cache”#2017-10-1214:34mhuebertbut that’s a transitive dep#2017-10-1214:34mhueberthmm#2017-10-1214:34mhuebertit’s not (require-macros cljs.js)#2017-10-1214:34thhellerdoesn’t matter, its asks for the macros since it has a self require#2017-10-1214:35mhueberti think the point of :no-follow or whatever is that the user doesn’t need transitive macro deps if cljs.js is already compiled?#2017-10-1214:35mhuebertit was compiled using those macros, but we don’t need those macros to use its compiled fns#2017-10-1214:36mhuebertjust like we should be able to use other compiled namespaces which used other non-selfhost-friendly macros at compile time?#2017-10-1214:36thhelleryes, :exclude is ignored in this case. I can fix that#2017-10-1214:37thhellerhowever .. if the user directly tries to use a macro#2017-10-1214:37thhellerthat will lead to an error#2017-10-1214:37mhuebertam wondering what exactly :exclude does or if that is the right name#2017-10-1214:37mhuebertyes#2017-10-1214:37thheller:exclude excludes a macro namespace from compilation#2017-10-1214:37thhellerit does NOT exclude it from loading (currently)#2017-10-1214:38thhellerit does exclude it when loading via transitive deps#2017-10-1214:38thhellerit does not exclude when loading directly#2017-10-1214:38thhellerand thats the issue here#2017-10-1214:38mhueberti think in cljs-live :exclude had the effect of only loading the analysis cache for the thing#2017-10-1214:38thhellerit has no problem with shadow-eval.user loading the cljs.js, it does the correct thing here#2017-10-1214:38thhellerthe issue is who tries to load#2017-10-1214:38mhuebertbut it does have a problem with (ns my.app (:require [cljs.js :as cljs]))#2017-10-1214:39thhelleryes, but that again is the self-host compiler trying to directly load it#2017-10-1214:40thhellershadow-eval.user is loaded by shadow.cljs.bootstrap.browser which is aware of the exclude#2017-10-1214:40thhellerlong story short. I can work around this easily#2017-10-1214:40thhellerbut it WILL fail if the user tries to use a macro#2017-10-1214:41mhuebertthat is unavoidable#2017-10-1214:41thhellerwell not unavoidable#2017-10-1214:41thhellerwe could just fix cljs/js.clj 😉#2017-10-1214:41mhuebertoh i mean for all the other use cases 🙂#2017-10-1214:41thhellerright#2017-10-1214:41mhueberti should set up an example of a namespace that uses the go macro#2017-10-1214:41mhuebertwith the right exclude, it should be usable#2017-10-1214:42thhellerno, that will never work#2017-10-1214:42mhuebert(the precompiled namespace, not go in self-host)#2017-10-1214:42thhellerright ok, precompiled yes#2017-10-1214:42thhellerlet me fix the exclude issue#2017-10-1215:01thhellerfixed in 2.0.11#2017-10-1215:36mhuebertfantastic 🎉#2017-10-1215:41mhuebertworks for me#2017-10-1216:50mhuebert@thheller re: webserver w/ ring handler - that would be great. i used that functionality of figwheel like so: https://github.com/mhuebert/figwheel-pushstate-server#2017-10-1217:29mhuebertone thing, with bootstrap’s release mode, i think it may need to be combined with a clean command of some kind. otherwise the bootstrap directory can’t really be deployed without deleting it / rebuilding manually, because it fills up with multiple versions#2017-10-1219:23thhellerin my experience thats not always a bad thing#2017-10-1219:24thhellerI used to delete all old versions too but sometimes someone would access my site with a badly implement cache#2017-10-1219:24thhellerthat had cached html but not cached js#2017-10-1219:24thhellerso they would attempt to download “old” js which had been deleted#2017-10-1219:25thhellernever figured out how that was caused but it happened often enough to make me keep old version forever#2017-10-1219:25thhellergranted forever is a bit extreme#2017-10-1219:26thhellerbut yeah some type of clean should probably exist#2017-10-1219:26thhellerI’m always hesitant to delete user files though#2017-10-1219:49mhuebertyeah I should probably just deploy these files on a different system than the main app. then it makes sense to be ‘additive’#2017-10-1220:40thheller@mhuebert 2.0.12 -> :devtools {:http-root ... :http-handler shadow.http.push-state/handle} always returns index.html if files don’t exist#2017-10-1220:41thhelleror point it to any other clojure fn you like#2017-10-1220:41thhellerfeels a bit rushed but maybe it works for you#2017-10-1220:41thhelleroff to bed, gn8#2017-10-1220:53mhuebert@thheller wow that was fast! 🙂 i think content-type headers need to be set to html, if i navigate to something like localhost:8702/intro it downloads as a file instead of opening#2017-10-1306:32thhellerah right. I only tested with foo.html which automatically sets content-type based on file ext 😛#2017-10-1307:09thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1b68737a7f746c36787771685b29352b352a28"}, :content ("[email protected]")}#2017-10-1309:15thhellerhaha … I had an idea for externs yesterday and it might actually work 🙂#2017-10-1309:16thhellerprobably a really bad idea but I’m gonna test the size difference on my work project to check how bad#2017-10-1309:34mhuebertcool!#2017-10-1309:36mhuebertone question, how do transitive JS deps work? eg. I have a commands library that will depend on keypress.js as a github dependency in package.json, and am wondering what I do in that library so that I can depend on it elsewhere#2017-10-1309:40thhelleryeah thats unsolved at the moment#2017-10-1309:41thhellerCLJS wants to do it this way: deps.cljs in your src root, {:npm-deps {"name-of-dep" "version"}]#2017-10-1309:41thhellershadow-cljs npm-deps will attempt to install them but that needs work, I’m not happy with how that works#2017-10-1309:42thhellerI’m sort of leaning towards including a package.json in your .jar#2017-10-1309:43thhellerbut deps.cljs is probably the way to go for now#2017-10-1309:45mhuebertok, fair enough#2017-10-1309:46mhuebertEver seen something like this? cljs.core.async is compiling with a trailing js.map:
cljs.core.async.partition_by.cljs$lang$maxFixedArity = 3;


//# sourceMappingURL=cljs.core.async.js.map
js.map
saw it for the first time now in 2.0.13
#2017-10-1309:46mhuebert(leading to Uncaught ReferenceError: js is not defined)#2017-10-1309:48thhellermaybe 2 shadow-cljs watches running?#2017-10-1309:48thhellerno clue otherwise#2017-10-1309:49mhuebertam watching 3 builds at once#2017-10-1309:50mhuebertwith one watch command unless there is something running i’m not seeing#2017-10-1309:51mhuebertis there a wiki page or sth where i should make notes of these JS related Q&A’s / stubs for documentation?#2017-10-1309:55mhueberti’ll just start a page in the shadow-eval repo wiki#2017-10-1310:06mhuebertfor now just my own notes to remember: https://github.com/mhuebert/shadow-eval/wiki#2017-10-1310:15thhelleryeah I haven’t written down anything yet#2017-10-1310:15thhellernice start#2017-10-1310:16thhellerhaha this externs stuff was waaaaaay easier to implement than I expected#2017-10-1310:16thhellerlooking good so far#2017-10-1310:28thhellerhaha it works#2017-10-1310:30mhuebertexcellent!#2017-10-1310:31thhellerthat should cover almost all externs … as long as you dont use :resolve :target :global#2017-10-1310:31thhellerand some dynamic programming things jquery and others do#2017-10-1310:33thhellerwhat I do is so simple .. for every JS dependency shadow-cljs imports#2017-10-1310:33thhellerit collects all assign property names, and creates externs for them#2017-10-1310:33thhellerexports.foo = 1; would collect the foo#2017-10-1310:34thhellerexports.thing = {a: 1}; would collect thing and a#2017-10-1310:34thhellerthats all#2017-10-1310:36mhuebertthat sounds great, i look forward to trying it#2017-10-1310:36mhuebertyou parse the js AST for this?#2017-10-1310:36thhelleryes#2017-10-1310:37thhellerbut I do this anyways to process the require in JS files#2017-10-1310:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure/ReplaceRequirePass.java#L22-L52#2017-10-1310:39thhellerquite simple actually#2017-10-1310:45mhuebertworking at the right depth in the stack / layer of abstraction can make things so simple#2017-10-1310:50thhellerneed to work out how to do this for node but for the browser it seems to actually work reasonably well#2017-10-1310:52thhellerstill doing a few tests to confirm#2017-10-1310:55thheller
/* @constructor */ function ShadowJS() {};
ShadowJS.prototype.$$typeof;
ShadowJS.prototype.Children;
ShadowJS.prototype.Component;
ShadowJS.prototype.PureComponent;
ShadowJS.prototype.ReactCurrentOwner;
ShadowJS.prototype.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
ShadowJS.prototype.__self;
ShadowJS.prototype.__source;
ShadowJS.prototype._owner;
ShadowJS.prototype.assign;
ShadowJS.prototype.children;
ShadowJS.prototype.cloneAndReplaceKey;
ShadowJS.prototype.cloneElement;
ShadowJS.prototype.constructor;
ShadowJS.prototype.context;
ShadowJS.prototype.count;
ShadowJS.prototype.createElement;
ShadowJS.prototype.createFactory;
ShadowJS.prototype.current;
ShadowJS.prototype.enqueueForceUpdate;
ShadowJS.prototype.enqueueReplaceState;
ShadowJS.prototype.enqueueSetState;
ShadowJS.prototype.forEach;
ShadowJS.prototype.forceUpdate;
ShadowJS.prototype.framesToPop;
ShadowJS.prototype.func;
ShadowJS.prototype.isMounted;
ShadowJS.prototype.isPureReactComponent;
ShadowJS.prototype.isReactComponent;
ShadowJS.prototype.isValidElement;
ShadowJS.prototype.key;
ShadowJS.prototype.keyPrefix;
ShadowJS.prototype.map;
ShadowJS.prototype.name;
ShadowJS.prototype.only;
ShadowJS.prototype.props;
ShadowJS.prototype.prototype;
ShadowJS.prototype.ref;
ShadowJS.prototype.refs;
ShadowJS.prototype.render;
ShadowJS.prototype.result;
ShadowJS.prototype.setState;
ShadowJS.prototype.thatReturns;
ShadowJS.prototype.thatReturnsArgument;
ShadowJS.prototype.thatReturnsFalse;
ShadowJS.prototype.thatReturnsNull;
ShadowJS.prototype.thatReturnsThis;
ShadowJS.prototype.thatReturnsTrue;
ShadowJS.prototype.toArray;
ShadowJS.prototype.type;
ShadowJS.prototype.unstable_AsyncComponent;
ShadowJS.prototype.unstable_isAsyncReactComponent;
ShadowJS.prototype.updater;
ShadowJS.prototype.version;
#2017-10-1310:56thhellerdoesn’t look all that bad, thats just React v16 and its deps#2017-10-1310:57thhellercrap its missing the lifecycle fns 😞#2017-10-1310:59thhellernevermind those are part of react-dom#2017-10-1310:59thhellerwoho#2017-10-1311:05thheller
;; auto
Flushing: base.js (181706 bytes)
Flushing: react.js (111923 bytes)
Flushing: demo.js (195720 bytes)
Flushing: extra.js (136 bytes)
Flushing: worker.js (75 bytes)

;; manual
Flushing: base.js (181233 bytes)
Flushing: react.js (111923 bytes)
Flushing: demo.js (195684 bytes)
Flushing: extra.js (136 bytes)
Flushing: worker.js (75 bytes)
#2017-10-1311:05thhellernot at all bad, auto is using the generated externs, manual is using the default react externs#2017-10-1311:05thhellerpretty much no diff#2017-10-1311:06thhellerI call this a success#2017-10-1311:12thheller@mhuebert {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8bf8e3eaefe4fca6e8e7e1f8cbb9a5bba5babf"}, :content ("[email protected]")} has this enabled by default, if you feel like testing.#2017-10-1311:12thhellerI’m gonna verify this on my work project now#2017-10-1312:03mhuebertcool, just in the middle of another thing atm but can try later#2017-10-1312:04mhuebertthat is remarkably similar#2017-10-1312:21mhuebertI can’t believe how fast these advanced builds are#2017-10-1312:28mhuebertdecided to try importing firebase, eg. yarn install firebase and then ["firebase/app" :as firebase]. it is supposed to work with webpack etc.; I get:
ExceptionInfo: no source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
#2017-10-1312:30mhuebertnot sure why it would be looking for constants.ts vs constants.js, which does exist#2017-10-1312:32mhuebertReact appears to work now without supplying any externs manually 🙂#2017-10-1312:46mhuebertadding something to :npm-deps in deps.cljs does not appear to have any effect, with or without :lein true#2017-10-1313:05thheller@mhuebert yes :npm-deps is not finished. you can try shadow-cljs npm-deps but it has some issues#2017-10-1313:05mhuebertok.#2017-10-1313:05thhelleruntil thats sorted out you need to trigger the install manually#2017-10-1313:06mhuebertdoes shadow look in the node_modules of dependencies?#2017-10-1313:07thhellerhmm?#2017-10-1313:07mhuebertso Maria depends on Commands which has an npm dependency keypress.js#2017-10-1313:08mhuebertdoes keypress.js need to be in the node_modules of Maria, or can it be in Commands#2017-10-1313:08thhellerI don’t understand#2017-10-1313:09mhuebert{:npm-deps {"keypress.js" "<version>"}} is in the deps.cljs of the commands project#2017-10-1313:09mhuebertit is only a transitive dep of Maria.#2017-10-1313:10mhuebertdoes it somehow need to end up being installed in maria/node_modules or would it also be picked up in commands/node_modules#2017-10-1313:10thhellershadow-cljs ONLY checks <project-root>/node_modules/.... never anywhere else#2017-10-1313:10mhuebertok#2017-10-1313:11mhuebertso ultimately shadow-cljs npm-deps could crawl other projects’ deps.cljs and install all the listed :npm-deps into the current project#2017-10-1313:11thhellerthats what it does yes#2017-10-1313:13mhuebertmakes sense.#2017-10-1313:14thhellerlooking at the firebase error#2017-10-1313:17thhellerhaha#2017-10-1313:17thhellerdoh 🙂#2017-10-1313:17thhellerits a bit too smart#2017-10-1313:20thhellerthe firebase files have source maps, which apparently causes it to return constants.ts instead of constants.js when asking which filename it is processing currently#2017-10-1313:21thhellerthats awesome and scary 😛#2017-10-1313:29thheller
SEVERE: node_modules/@firebase/util/dist/cjs/src/constants.js:26:
Originally at:
node_modules/@firebase/util/dist/cjs/src/constants.ts:26: ERROR - @define variable  assignment must be global

Oct 13, 2017 3:28:12 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/@firebase/util/dist/cjs/src/constants.js:30:
Originally at:
node_modules/@firebase/util/dist/cjs/src/constants.ts:31: ERROR - @define variable  assignment must be global
#2017-10-1313:29thhellerthis is the problem though#2017-10-1313:29thheller@define is a closure annotation, will disable that check if possible#2017-10-1313:53thheller@mhuebert should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c5b6ada4a1aab2e8a6a9afb685f7ebf5ebf4f0"}, :content ("[email protected]")}#2017-10-1313:53thhellercan you please check the line count of target/shadow-cljs/builds/browser/release/shadow.js.auto_externs.js?#2017-10-1313:54thhellertotal curious how many that generates for your project#2017-10-1313:59mhuebertdeleted target dir, still seem to be getting the same error with firebase#2017-10-1313:59mhuebertwith 2.0.15#2017-10-1313:59mhuebert
no source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
{:name "node_modules/@firebase/util/dist/cjs/src/constants.ts"}
ExceptionInfo: no source by name: node_modules/@firebase/util/dist/cjs/src/constants.ts
#2017-10-1314:00mhuebertwith
["firebase/app" :as firebase]
["firebase/auth"]
#2017-10-1314:00mhuebertnow.. wait#2017-10-1314:01mhuebertI had :lein true and had not updated the shadow-cljs version in project.clj#2017-10-1314:01mhuebertonly in package.json#2017-10-1314:01mhueberttrying again#2017-10-1314:01thheller🙂#2017-10-1314:01mhuebertit still says 2.0.15 when loading the script, this could be confusing, but maybe there is no way to easily catch if the version is different in project.clj#2017-10-1314:02mhuebert1569 lines in auto_externs#2017-10-1314:03mhuebertthis is just the ‘outer’ frame so not so many deps, firebase + react#2017-10-1314:03mhuebertlots of minified stuff in here#2017-10-1314:04thhellerthats odd#2017-10-1314:04mhuebertbuild went from 400 > 600 kb#2017-10-1314:04thhellerdamn 😛#2017-10-1314:04mhuebert🙂#2017-10-1314:05thhellerwonder where those minified props come from#2017-10-1314:08thhellercan you send me the target/shadow-cljs/builds/browser/release/shadow-js/* files zipped or so?#2017-10-1314:08thhellerthere is probably a closure minified thing in there, want to see if I can somehow detect that#2017-10-1314:09mhuebertcould it not be react, minified?#2017-10-1314:09thhellerno, JS deps usually do not minify property assigns#2017-10-1314:09thhelleronly locals#2017-10-1314:15thhellerhttps://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/auth.js#2017-10-1314:15thhellerweird, there is only the minified source available for this#2017-10-1314:15thhellerbut yeah that looks like it was minified by closure#2017-10-1314:17thhellerno fun#2017-10-1314:17thhellerthose things will need externs#2017-10-1314:18thhelleryour build probably gets so large because all the short names are taken#2017-10-1314:19thhellerthe externs file “claims” all the a, b, c, Aa, Ab, etc names#2017-10-1314:19thhellerso probably all vars in your build become 3 letter names instead of 2#2017-10-1314:20thhellerthat adds up quick#2017-10-1314:21mhuebertyeah exactly#2017-10-1314:21mhuebertit’s not a problem here, since firebase is a google thing they do maintain externs#2017-10-1314:22mhuebertprovided externs can be looked up directly from node_modules#2017-10-1314:22thhelleryeah but how do I protect the generator from extracting these#2017-10-1314:22mhuebertoh i see.#2017-10-1314:22thhelleronly thing I can think of is setting a “cap”#2017-10-1314:23thhellerso if a namespace has too many properties you get a warning or something#2017-10-1314:23thhellerand then add an exclude option to ignore properties from that file#2017-10-1314:23thhellerno normal file should export this many props#2017-10-1314:24mhuebertyeah firebase has often only released minified stuff#2017-10-1314:25thhelleror I just ignore the pattern of names#2017-10-1314:25thhellerah better idea#2017-10-1314:26mhuebertis there a way to disable this temporarily#2017-10-1314:26mhueberti’d like to compare the gzipped sizes of with / without#2017-10-1314:26thheller:js-options {:generate-externs false}#2017-10-1314:31mhueberti misspoke#2017-10-1314:31mhuebertsorry. it makes only a tiny difference in file size.#2017-10-1314:32thhellerit still seems wrong 🙂#2017-10-1314:32thhellerI have a quick fix#2017-10-1314:33thheller(set/superset? properties #{"a" "b" "c" "Aa" "Ab" "Ac"})#2017-10-1314:33thhellerif the file contains those properties, I strip out every 1/2 letter property#2017-10-1314:35thheller475 properties for firebase/app + firebase/auth after#2017-10-1314:36thhellerso over 1k removed. seems good.#2017-10-1314:38mhuebertso, an example to try#2017-10-1314:38mhuebertin a namespace with this required:
["firebase/app" :as firebase]
["firebase/auth"]
try (js/console.log (.auth firebase))
#2017-10-1314:39thhellerhmm?#2017-10-1314:39mhuebertfor me it mangled auth#2017-10-1314:40thhellerright. nothing I can do about that#2017-10-1314:40thhellerthe closure minified files use goog.exportSymbol calls to create the names#2017-10-1314:41thhellerthey look like this Z(a,"EmailAuthProvider",Ig,[]);#2017-10-1314:41thhellerthat is not a property assign#2017-10-1314:41thhellermeh I might scrap this whole idea#2017-10-1314:41thhellerCLJS already has a half-way working :infer-externs .. should just use that#2017-10-1314:42mhueberti think whatever they have + a simple way to add additional properties might be decent#2017-10-1314:42thhelleryeah#2017-10-1314:42mhuebertthis strikes me as extremely hard to get right#2017-10-1314:43thhellerthe automation part is hard yes, thats why I was surprised why the generation thing worked so well#2017-10-1314:43thhellerits still pretty good, just didn’t anticipate this 😛#2017-10-1314:44thhellerI’ll look at :infer-externs more, maybe I can combine that in some way#2017-10-1314:44thhellerthe only part I didn’t like about :infer-externs was that you sometimes have to annotate your code#2017-10-1314:44thhellerand often it would complain about things#2017-10-1314:45mhueberthmm. could it make sense that firebase’s externs don’t work when firebase is required via npm vs. included in a script tag#2017-10-1314:45thhelleris the firebase source available at all?#2017-10-1314:46thhelleroh you have the firebase externs included and they don’t work?#2017-10-1314:46mhuebertthey were recently open sourced: https://github.com/firebase/firebase-js-sdk#2017-10-1314:46mhuebertappears that way, checking again#2017-10-1314:47thhellerbut there is no source in there#2017-10-1314:47thhelleronly compiled things#2017-10-1314:47thhelleroh right .. typescript#2017-10-1314:47thhellernevermind 😉#2017-10-1314:48mhueberti wouldn’t worry too much about firebase in particular. i just thought it might be a good one to try because google usually annotates everything etc… but i guess that is more relevant for things handled by closure compiler#2017-10-1314:50thhellerremoving all the short names should fix most issues#2017-10-1314:51mhueberti guess externs on short names wouldn’t make a big file impact, because you can’t rename these things shorter anyway? its not preventing the closure compiler from reducing the size of $some_long_name$#2017-10-1314:52thhellerbut instead of turning some_long_name into a its forced to turn it into abc or whatever#2017-10-1314:52thheller2 extra bytes per name is quite a lot#2017-10-1314:53thhellerbut thats fixed now#2017-10-1314:53thhellerdid you try with the firebase externs?#2017-10-1314:53thhellerif they don’t work thats a problem#2017-10-1314:54mhueberthave to do a bit of code shuffling to try that properly#2017-10-1314:54mhuebertone sec#2017-10-1314:55thhellerwhere are those externs?#2017-10-1314:56mhuebertnode_modules/firebase/externs#2017-10-1314:57mhuebertno it works#2017-10-1314:57mhueberti had to move some initialization code into cljs to test properly#2017-10-1314:58thhellerok good#2017-10-1315:03thhellerI’ll test a few things with :infer-externs, maybe I can find a solution that is more reliable#2017-10-1315:03thhellershould have done that in the first place, just got too excited by this idea of collecting all properties 😛#2017-10-1315:05mhuebertI mean it’s a pretty big win that a library like React ‘just works’ with this generate-externs option#2017-10-1315:06thhelleryes but I think :infer-externs can cover this as well#2017-10-1315:06mhuebertand again after testing properly it does not appear to inflate sizes a lot#2017-10-1315:06mhuebertwith lots of type hints#2017-10-1315:06thhellerI used to be more strict about externs#2017-10-1315:07thhellertoo obsessed with file sizes over convenience#2017-10-1315:07thhellerbut should focus more on the user and :externs come up pretty much always#2017-10-1315:08thhellerso generated something good, then let user optimize when needed is better#2017-10-1315:08mhuebertyeah#2017-10-1315:13mhuebertwith React + Firebase, difference is only 2kb adding :generate-externs in addition to the ‘real’ externs for both libs#2017-10-1315:14thhellerthats reasonable#2017-10-1315:14mhuebertgenerated externs appear to totally solve ‘React’ but fail with firebase due to auth issue mentioned above#2017-10-1315:15mhuebertits a tiny percentage, 601 vs 603 kb#2017-10-1315:15thheller:infer-externs should cover that#2017-10-1315:20thhellerif you get a chance you could try master which has the naming fixes#2017-10-1315:20thhellerbut 2kb is ok enough already, probably doesn’t change much#2017-10-1315:21mhuebert0.3%, negligible#2017-10-1315:23mhuebertbut should try it on some more files#2017-10-1315:27mhuebertI agree this is an important thing though, and worth the effort. has been one of the most frustrating aspects of ClojureScript, this gulf between dev and production where suddenly new bugs appear, and extremely slow feedback cycles with advanced compilation. (well: i am very surprised/impressed at how much faster it is with shadow. i thought the slowness was somehow necessary part of the process)#2017-10-1315:33thhellerwell shadow-cljs caches more aggressively so the only thing you pay for is the actual :advanced compilation#2017-10-1315:33thhellerother CLJS tools do not cache at all for :advanced builds, so it always recompiles all CLJS as well#2017-10-1315:33thhellerwhich typically takes longer than the optimize part#2017-10-1316:18thhellergeez forgot how complicated this :infer-externs stuff is …#2017-10-1316:20thheller(js/console.log (firebase/auth)) got this part figured out#2017-10-1316:20thheller(js/console.log (.auth firebase)) is also valid but harder to track#2017-10-1318:51mhuebertsmall thing, if we could make the debugging statements in shadow.cljs.bootstrap.browser optional 🙂#2017-10-1320:48thheller@mhuebert oops yes, forgot to disable them
#2017-10-1320:50thheller@jiyinyiyong those things don’t really apply to shadow-cljs 😉#2017-10-1403:56JonI remembered you said you had some solutions#2017-10-1403:57JonI think we need to make sure that they are available on the docs#2017-10-1403:57Jonat least people can Google them#2017-10-1407:51thhellerwhat do you mean?#2017-10-1407:52thhellerthe loader? yeah that needs docs#2017-10-1408:04thhellerhttps://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#module-loader there is some old stuff but nothing has changed so still applies#2017-10-1409:18Jondoes shadow-cljs consume JavaScript code?#2017-10-1409:18thhellerhmm? I don’t understand the question#2017-10-1409:25Jonheard in the video, now ClojureScript compiler can load JavaScript files directly?#2017-10-1409:25Jonmaybe CommonJS files, via Closure Compiler#2017-10-1409:25Jonjust js files, but not in a npm package#2017-10-1409:25thhelleryes you can do that#2017-10-1409:26thheller(:require ["some-name" :as foo])#2017-10-1409:26Jonnot sure why I would write JavaScript in my project though...#2017-10-1409:26thheller:js-options {:resolve {"some-name" {:target :file :file "path/to/file.js"}}}#2017-10-1409:26thhellerthe part thats missing is the jsx support#2017-10-1409:26thhellerI have some ideas around that but its unfinished#2017-10-1409:27Jonsounds nice~#2017-10-1409:27thhellerjust ignore the video … most things just do not apply#2017-10-1409:27Jonconfigs much shorter in shadow-cljs#2017-10-1409:28Jondo not apply to shadow-cljs, or to current version of ClojureScript compiler?#2017-10-1409:28thhellerdo not apply to shadow-cljs#2017-10-1409:28thhellerwe do things differently#2017-10-1409:28thhellerthe CLJS stuff has way too many issues to be viable#2017-10-1409:28Jon😛 sounds like....#2017-10-1409:29Jondo you believe shadow-cljs's solutions are better?#2017-10-1409:29thhellerone thing I learned from antonios talk is that I need to blog more 🙂#2017-10-1409:29thhelleryes I do. well .. otherwise I wouldn’t have built them 😉#2017-10-1409:29JonI agree with that.#2017-10-1409:30Jonbeing a user, I just feel that, maybe I don't need those features, but when I need, I do hope they are there. switching to other languages can be hard choices#2017-10-1409:31thhellerI’ll try to write short blog posts about certain features I implemented#2017-10-1409:31thhellerbut often things are really not relevant to the user, just to someone interested in the compiler stuff#2017-10-1409:31Jonand Tweets 😉#2017-10-1409:32thhellerIMHO the JS integration is much more reliable in shadow-cljs, I even started some work yesterday to almost completely remove the need for :externs#2017-10-1409:34Jonreally, we can solve the problems that was solved by externs now?#2017-10-1409:34thhellernot totally no but good enough for most cases#2017-10-1409:35thhellerReact works completely without externs#2017-10-1409:35thhelleras will most other libs#2017-10-1409:35thhellerbut anyways .. its a bit too early, needs some tuning. first steps are promising though#2017-10-1409:36Jonbut how? is that part of code not processed by Google Closure Compiler?#2017-10-1409:36thhellerI just generate the externs …#2017-10-1409:36Jon😅#2017-10-1409:36thhellerso its still using externs .. but you don’t have to write them#2017-10-1409:36Joninteresting#2017-10-1409:37thhellerI’ll definitely write a longer post about that#2017-10-1409:37thhellerI sort of changed my mind on the whole subject recently#2017-10-1409:38thhellerit is much more important that users have a good experience and don’t run into as many :advanced issues#2017-10-1409:38thhellerthan it is to save a few KB of js#2017-10-1409:38Jonyeah, I think so... for people from JavaScript it's more important.#2017-10-1409:38thhellerI always was pretty obsessed with file sizes#2017-10-1409:38thhellerbut thats nonsense if your program doesn’t work#2017-10-1409:39thhellerso I’ll provide the automated way first … and let the user optimize if they want to#2017-10-1409:39JonUglify was not good years back, when Closure Compiler was good. but people chose Uglify..#2017-10-1409:39Jonagreed.#2017-10-1409:40thhellermhuerbert did a comparison yesterday in his app which went from 601kb with manual externs to 603kb with generated externs#2017-10-1409:40thhellerso its really not that bad#2017-10-1409:41thhellerI’ll finish a few things then you can help me test as well#2017-10-1409:41Jongzipped and the difference even smaller#2017-10-1409:41Jonokay 🙂#2017-10-1409:41thhellergotta go afk for a few, bbl#2017-10-1409:41Jonwait, I'm not sure I used much npm packages in existing projects...#2017-10-1409:42Jonbye..#2017-10-1409:42thhelleryou already ran into the shortid issue, which would be covered by the new stuff#2017-10-1409:43Jonmaybe time to use more npm packages now#2017-10-1411:19Jonhttps://github.com/minimal-xyz/minimal-shadow-cljs-loader/issues/1#2017-10-1411:25thhelleroops#2017-10-1411:25thhellerguess I broke it with the 2.0 and never updated#2017-10-1411:25thhellerwill fix#2017-10-1417:47thhellerI hate blogging#2017-10-1417:47thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2017-10-1419:31thhellerI just added support for generating externs from files such as this#2017-10-1419:31thhellerhttps://github.com/thheller/shadow-cljs/blob/master/externs/infer-externs.txt#2017-10-1419:32thheller
# untyped externs will be generated by this file
# the filename must match the <id-of-build>.txt

# properties are just listed one per line
propertyA
propertyB

# globals are prefixed by global:
global:someGlobal
#2017-10-1419:32thhellerexterns/<your-build-id>.txt#2017-10-1419:32thhellerI think that should cover the last remaining issues#2017-10-1419:33thhellerneeds some more testing, will write blog post sometime soon#2017-10-1421:06mhueberton a little vacation this weekend so not much keyboard time. re externs from a txt file: i think externs are more likely to be re-used on a per-library basis, vs. per-build. if i get the externs working for some JS lib once, i may want to re-use in other projects/builds.#2017-10-1421:10mhuebertnice post about bootstrap. i also want to do some writing yet about how useful this is for projects like maria#2017-10-1421:25mhuebertnot sure how many manual externs one will have to define, but could it also be included as a vector of strings in :js-options? ["propertyA" "propertyB"]#2017-10-1421:25mhuebertjust an idea, not sure of all the tradeoffs#2017-10-1510:12thheller@mhuebert I decided against putting the externs into the config because it might make the config “big”. I can allow it there as well though.#2017-10-1510:13thhellerideally there would be some sort of “library” where externs for packages are collected#2017-10-1510:13thhellersomething like cljsjs has done#2017-10-1510:14thhellerI just don’t want to maintain that#2017-10-1510:14thhellerbut something that maps npm packages names to their externs#2017-10-1513:05thhellerhttps://twitter.com/thheller/status/919547437479493632#2017-10-1513:05thhellerwrote that thing about externs#2017-10-1513:06thhellerhttps://www.reddit.com/r/Clojure/comments/76isfz/cljs_externs_the_bane_of_every_release_build/#2017-10-1519:32mhuebertResending messages failed while hiking...#2017-10-1519:32mhuebertfor file format, what about sth like an .edn file of {:globals [...] :properties [...]}?#2017-10-1519:32mhuebertthat can be referenced by any # of builds#2017-10-1519:33mhuebertAm wondering about reuse across builds, and inclusion in libraries#2017-10-1519:35mhuebertEg. I have a keyboard commands library that uses a JS lib, could I somehow include an externs file (txt or edn) that use picked up by downstream users?#2017-10-1520:03thhellerdidn’t choose edn since that seems like too much to write#2017-10-1520:04thhellerjust one identifier per line is enough, don’t need all the edn literals#2017-10-1520:04thhellerbut yeah sharing across builds and libraries needs to happen somehow#2017-10-1520:05thhelleryou can as always use the deps.cljs to ship :externs but that only works for the “real” externs. not the simplified version.#2017-10-1520:05thhellercan’t use the simplified version in libraries unless CLJS adopts it so it works for tools besides shadow-cljs#2017-10-1521:33mhuebertYeah, good point. Libraries can use the normal syntax#2017-10-1612:14mhuebertGetting some errors when with doing multiple :release builds at the same time. Does not happen if I release builds individually: https://gist.github.com/mhuebert/66fe536fa2f6c96b5e09d33deb6b8617#2017-10-1614:53mhuebertattempting to use google’s material-components-web, getting errors like:
Oct 16, 2017 4:51:23 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/@material/animation/index.js:143: ERROR - Parse error. '}' expected
export {transformStyleProperties, getCorrectEventName, getCorrectPropertyName};
^

Oct 16, 2017 4:51:23 PM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: node_modules/@material/base/component.js:19: ERROR - Parse error. '}' expected
import MDCFoundation from './foundation';
^

#2017-10-1614:57thheller@mhuebert the release errors: is it possible you are building the same build twice? shadow-cljs release browser browser?#2017-10-1614:58thhellerI only saw this error before when 2 compiles where trying to use the same cache#2017-10-1615:00thheller(:require ["@material/animation"]) works fine for me?#2017-10-1615:00thhelleroh no wait, got the same error#2017-10-1615:00thhellerchecking#2017-10-1615:02mhuebert@thheller there are some overlapping namespaces, but different builds. it’s the :live, :bootstrap and :trusted builds here: https://github.com/mhuebert/maria/blob/master/editor/shadow-cljs.edn#L36#2017-10-1615:02thhellerah doh, yeah @material is ES6. I haven’t finished that work yet#2017-10-1615:03thhellerI still need all the checkouts to compile Maria?#2017-10-1615:04mhuebertshouldn’t need the checkouts, they are just there to facilitate reloading during dev#2017-10-1615:07mhueberthowever i was working on updating deps earlier today and it is possible there are omissions. i think i do indeed have too many independent projects#2017-10-1615:07thhellerCould not find artifact cljs-live:cljs-live:jar:0.2.9-SNAPSHOT in clojars ()#2017-10-1615:08thhellercan I drop down to a non-SNAPSHOT version?#2017-10-1615:08mhuebertdeploying that now#2017-10-1615:08mhuebertdone#2017-10-1615:09thheller0.2.9?#2017-10-1615:09mhuebert-SNAPSHOT#2017-10-1615:09thhellerhmm can’t be found#2017-10-1615:09mhuebertor do you mean having a snapshot version is an issue#2017-10-1615:10mhuebertoh to be able to have git branch dependencies#2017-10-1615:10thhellerI can just add the checkouts#2017-10-1615:10mhueberti’ll try a 0.2.9 release#2017-10-1615:10mhuebertjust released 0.2.9#2017-10-1615:10thhellerthere is a bunch more -SNAPSHOT versions in there#2017-10-1615:11mhuebertdo those in general cause problems?#2017-10-1615:11thhellerweird, ok those work it seems#2017-10-1615:12thhellerThe required namespace "pack.prosemirror-markdown" is not available, it was required by "re_view_prosemirror/markdown.cljs".#2017-10-1615:12thhellershadow-cljs release live bootstrap trusted#2017-10-1615:13thhellerok I think I identified the issue#2017-10-1615:13thhellerit works if you run shadow-cljs server first#2017-10-1615:14thhellerbut that should not be a requirement, just an unhappy race condition. threads again. 😉#2017-10-1615:14mhuebertis there not an error if you run shadow-cljs server separately, and then shadow-cljs watch?#2017-10-1615:15thhellerthe server is in a bit of a weird state at the moment. there are several command that act as the server themselves if none is running#2017-10-1615:16thhellerotherwise they all connect to the server#2017-10-1615:16thhellergenerally I have one server or clj-repl instance running#2017-10-1615:16thhellerand all other commands run through it (automatically)#2017-10-1615:17mhuebertok, now that seems to work#2017-10-1615:18mhuebertis doc/shadow-repl.md intended to explain how to set up a repl? it seems to go in a lot of paths#2017-10-1615:18mhueberti wasn’t sure the most straightforward way to connect a repl with cursive#2017-10-1615:18mhuebertjust configuring a remote nrepl server didn’t seem to work#2017-10-1615:18thhellerin cursive just connect to “Remote NREPL` at localhost:7888#2017-10-1615:19thhelleror whichever port you have entered in shadow-cljs.edn#2017-10-1615:19thheller :nrepl {:port 7888}#2017-10-1615:19thhellerno need for further setup#2017-10-1615:20thhellerassuming that one server instance is running, which can either be server or watch#2017-10-1615:20thhellerdoc/shadow-repl.md is not about setup no.#2017-10-1615:21thhelleryou maybe didn’t try this before you you can drive all of shadow-cljs via the REPL#2017-10-1615:22thheller
shadow-cljs clj-repl
[1:0]~shadow.user=> (shadow/release :live)
[:live] Compiling ...
#2017-10-1615:22thhellerits the same as shadow-cljs release live#2017-10-1615:22thhellersee (help) at the repl#2017-10-1615:22thhellergeez thats outdated .. but still#2017-10-1615:23thhellershadow-cljs clj-repl is basically the same as lein repl#2017-10-1615:23thhelleryou get a REPL prompt but can connect to it remotely as well#2017-10-1615:24mhuebertnice#2017-10-1615:24thhellerto get a CLJS repl for your build#2017-10-1615:24thhellershadow-cljs cljs-repl live (while watch is running)#2017-10-1615:25thhellerin cursive (shadow/repl :live)#2017-10-1615:25thhellerlooks like you are connected? try to eval something#2017-10-1615:25thheller(help) or so#2017-10-1615:26thhellerI think its just missing the prompt, connect worked#2017-10-1615:26thhellerhttps://github.com/thheller/shadow-cljs/wiki/Cursive#2017-10-1615:26mhuebertCompilerException java.lang.RuntimeException: Unable to resolve symbol: help in this context, compiling:(null:1:1) #2017-10-1615:27thhellerdoh 😛#2017-10-1615:27thheller(shadow.cljs.devtools.api/help)?#2017-10-1615:27thhellerI don’t use nrepl much these days#2017-10-1615:27mhuebertah, the wiki.#2017-10-1615:29mhuebertok, now i understand. ’tis working.#2017-10-1615:29mhuebert(shadow.cljs.devtools.api/repl :live)#2017-10-1615:30thhellerthis switches the current REPL to CLJS, so every eval after that should happen in CLJS#2017-10-1615:30thhellerthe UI does not properly detect this so you might need to switch manually in Cursive clj/cljs#2017-10-1615:32mhuebertthe dev command looks handy#2017-10-1615:32mhuebertso for es6 - i should keep doing rollup/webpack for now?#2017-10-1615:33thhellerI did not expect people to put ES6 on npm#2017-10-1615:33thhellerI thought they all re-packaged it first#2017-10-1615:34thhellerI have a few ideas how to handle that but didn’t implement them yet#2017-10-1615:34mhuebertmaybe this particular package is better handled directly with Google Closure as it is a google thing#2017-10-1615:36thhelleryah#2017-10-1615:37mhuebertIIRC in shadow there is an option for that, it would then process all deps through closure?#2017-10-1615:37thhellerthe issue with that is that the closure thing is all or nothing kind of deal#2017-10-1615:37mhuebertright.#2017-10-1615:37thhellerbut not all npm deps survive closure#2017-10-1615:37thheller:js-options {:js-provider :closure} but that basically never works 😛#2017-10-1615:38thhellerI think material was one I tested which worked though#2017-10-1615:39mhueberti think anything made by google is fully annotated#2017-10-1615:39mhuebertfirebase probably is too#2017-10-1615:39thhelleryeah material-components-web works#2017-10-1615:44mhuebertcould closure be a :resolve option?#2017-10-1615:45thhellernot really as it rewrites the code quite heavily#2017-10-1615:45thhellerit might work for a few cases#2017-10-1615:46thhellerreally depends on if you rewrite the dependencies as well or not#2017-10-1615:46thhellereg. if material-components-web doesn’t depend on anything you’ll be fine#2017-10-1615:46thhellerbut if it depends on something and rewrites that#2017-10-1615:46thhellerbut something else is not rewritten but also attempts to use that dep#2017-10-1615:46thhellerboom#2017-10-1615:48mhuebertah i see#2017-10-1615:48thhellerthe plan currently is to use babel to transform ES6 code#2017-10-1615:48thhellersince that is what most other libs on npm use#2017-10-1615:49thhellerie. if you use material-ui you get ES3 which was transformed by babel and includes some of the babel-runtime#2017-10-1615:49thhellerif I use closure to rewrite that you have the babel runtime from some package and the closure runtime for others#2017-10-1615:50thhellerthats not so great#2017-10-1615:50thhellerbabel seems to be the most common ground and is actually fairly good#2017-10-1615:50thhellersince I also get jsx support for free#2017-10-1615:51thhellerI already did a few basic tests just didn’t get to implement it yet#2017-10-1615:51mhuebertin the short term, is there a way for me to expose my rollup’d pack of material-components-web in a way that would let me require things like how cljsjs/global-exports work?#2017-10-1615:51thheller:js-options {:resolve {"material-components-web" {:target :global :global "MDC"}}}#2017-10-1615:52thhellershould work?#2017-10-1615:52thheller:file might also work if they still ship a bundle?#2017-10-1615:53thheller{"material-components-web" {:target :npm :require "material-components-web/dist/material-components-web.js"}}#2017-10-1615:53thhellerthere is also a file for :require-min#2017-10-1615:54mhuebert:js-options do not flow through upstream though, do they? so then whatever consumes re-view-material also has to.. i’m not sure, copy over a JS file somewhere?#2017-10-1615:54mhueberti would rather not include their whole bundle#2017-10-1615:54mhuebertas i don’t use a lot of it#2017-10-1615:54thhellerhmm yeah its tricky#2017-10-1615:55thhellerI really don’t want to support cljsjs style packages because the chance of conflicts is so damn high#2017-10-1615:56thhellerwell its only an issue until I sort out the ES6 issue … I will do that tomorrow 😉#2017-10-1615:57mhuebert😉#2017-10-1616:16mhuebertalso - minor thing - getting the server to emit the URL would avoid some confusion others had trying to get maria running for dev#2017-10-1616:33thhellerthe http url? yes I forgot about that#2017-10-1616:38thheller
HTTP server for build :browser available at: 
HTTP server for build :bootstrap-host available at: 
#2017-10-1616:38thhellersuggestions? or good enough?#2017-10-1617:10mhuebertI think that’s great#2017-10-1617:16thhellersometimes you really have to wonder what google is doing#2017-10-1617:16thhellerconst el = windowObj['document']['createElement']('div');#2017-10-1617:16thhellerdon’t they know how to use externs? 😛#2017-10-1617:17mhueberthah#2017-10-1617:22thhellerfinished the ES6 support 😉#2017-10-1617:23thhellerit might not work at all {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c4b7aca5a0abb3e9a7a8aeb784f6eaf4eaf5fd"}, :content ("[email protected]")}#2017-10-1617:24thhellerits only 50% of the implementation I had planned initially but this should work, tested with "@material/animation" and it compiles#2017-10-1617:26thhelleroh doh, require('@material/checkbox/dist/mdc.checkbox'); they do ship commonjs as well#2017-10-1617:26thhellerwell .. screw that 😉#2017-10-1617:28thhellerhow do you use this stuff from JS anyways?#2017-10-1617:33thhellerhaha doh, stay away from 19#2017-10-1617:36thhellerrunning everything through babel was not the intent#2017-10-1617:37mhuebertmaterial-components-web is designed primarily as a low-level framework which requires ‘adapters’ to actually use, so i have a lot of ugly code which requires these namespaces and then maps them to react components appropriately#2017-10-1617:38thhellerreact?#2017-10-1617:38thhellerwhy not use material-ui instead then?#2017-10-1617:39thhelleror there was another react version for material I think#2017-10-1617:39thhellerhmm yeah as expected the babel transform is gonna be dog slow the way I did it now#2017-10-1617:39mhuebertlast i checked, which was not recently, material-ui did not use the latest version of material-components-web and was also very very heavy#2017-10-1617:40mhuebertlooking now, yes, material-ui is also not made by google#2017-10-1617:40mhuebertwhereas material-components-web is actually maintained/developed by google and intended to be a production quality reference implementation#2017-10-1617:40thhellertry {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "20534841444f570d434c4a5360120e100e1210"}, :content ("[email protected]")}#2017-10-1617:41thhelleras expected shelling out to babel per file is way too slow#2017-10-1617:41thhellergonna get that fixed next#2017-10-1617:41thhellerbut it should works as a test#2017-10-1617:41mhuebertmaterial-ui also did this inline-styles thing which was simultaneously slow and difficult to integrate with a project. however again i haven’t looked at it in months 🙂.#2017-10-1617:41mhuebertok#2017-10-1617:42thhellerI haven’t used either myself. just thought it was weird to use a web-components lib with react#2017-10-1617:42thhellerbut if it works why not#2017-10-1617:43thhellerI added a test and it seems to work, just missing the styles#2017-10-1617:44thheller(if (contains? #{"es3 es5"} js-language) spot the bug 😉#2017-10-1617:45thhellerit actually seems to work way better than expected, the babel transform that is#2017-10-1617:45thhellerjust need to fix the performance problem#2017-10-1617:46thhellerlet me know if it works … afk for a bit#2017-10-1618:04mhuebertoh it’s not web-components per se#2017-10-1618:05mhuebertthey did a bunch of the hard css/js stuff, and then you have to write an ‘adapter’ that maps it to whatever, can be web components or can be react#2017-10-1618:06mhuebertwhen i wrote re-view-material, material-components-web was at version 0.14 vs today 0.22, i don’t think they did the cjs dist back then#2017-10-1618:11mhuebert2.0.20 worked 🙂#2017-10-1618:11mhuebertslow but worked#2017-10-1618:12mhuebert1st build 57s, quite and built again, 38s#2017-10-1618:23mhuebertadvanced compilation 68sec#2017-10-1618:29mhuebertgot to do some externs debugging#2017-10-1618:31thhellerreally? damn shouldn’t need externs#2017-10-1618:31thheller38sec? what are you building?#2017-10-1618:32thheller68sec advanced is pretty darn slow#2017-10-1618:43thhellerwhere do you need externs?#2017-10-1618:43thhellerI think I found one thing I need to add to the externs generator#2017-10-1618:49thhelleryeah … dammit …#2017-10-1618:50thheller
_createClass(MDCCheckboxFoundation, [{
    key: 'init',
    value: function init() {
      this.adapter_.addClass(_constants.cssClasses.UPGRADED);
      this.adapter_.registerChangeHandler(this.changeHandler_);
      this.installPropertyChangeHooks_();
    }
  }, {
    key: 'destroy',
    value: function destroy() {
      this.adapter_.deregisterChangeHandler(this.changeHandler_);
      this.uninstallPropertyChangeHooks_();
    }

    /** @return {boolean} */

  }
#2017-10-1618:50thhellerbabel rewrites class MDCCheckboxFoundation this way#2017-10-1618:50thhellerit doesn’t detect that key: 'init' is the property we need#2017-10-1618:50thhellerneed to think about how to fix that#2017-10-1619:00thhellerI really did underestimate how much dynamic stuff might generate properties#2017-10-1619:01thhellermaybe I should also extern all calls done in the js? not just the assigns#2017-10-1619:08mhuebertmay have spoken too soon. this is really a tangle of stuff that has JS deps and I have to sort some out before i know if there are any real externs issues#2017-10-1619:08mhueberti don’t think 100% should be the goal, we can’t get around the dynamic stuff#2017-10-1619:09mhueberti’ve thought about that before, if one could detect any access of globals that aren’t part of your build#2017-10-1619:09mhuebertmake that stuff string requires#2017-10-1619:09mhuebertdon’t know#2017-10-1619:09thhelleryeah starting to believe its better to properly use :infer-externs and rely on that instead#2017-10-1619:09thhellerthe dynamic generation is ok but just doesn’t work in many cases#2017-10-1619:10thhellerwhat kind of errors do you see?#2017-10-1619:11thhellerall externs issues should be pretty easy to track down using shadow-cljs release build --pseudo-names#2017-10-1619:11mhuebertso i am building the http://re-view.io website, which contains examples of all the re-view-material components as well as re-view-prosemirror. i had forgotten that re-view-prosemirror also has a deps.clj foreign-lib that i have to include separately as a script tag#2017-10-1619:12thhellerforeign-lib because its not on npm or custom build?#2017-10-1619:13mhuebertcustom. but this is just another lib that was written in the old style (webpack of a .js file) before we could require stuff from node_modules#2017-10-1619:13mhuebertso my goal now is rewriting all of this stuff to not require these old bundles.#2017-10-1619:14thhellerah right. this thing https://github.com/braintripping/re-view/blob/master/re_view_prosemirror/src/js/pm.js#2017-10-1619:14mhuebertyeah, there is that and also one pmMarkdown#2017-10-1619:15mhuebertwhich depends on it#2017-10-1619:15mhuebertgoing to get rid of those now#2017-10-1619:15thhelleryeah thats the reason why foreign-libs is such a bad idea#2017-10-1619:16thhellerwell not super bad since prosemirror doesn’t have many dependencies but still#2017-10-1619:16mhuebertis support for checkouts something that will be hard to add?#2017-10-1619:16thhellerjust add the :source-paths, should be enough#2017-10-1619:32ivanpierreIs it possible to have different dependencies in different build. In fact I create two application : node + js. And some sources are common to both.#2017-10-1619:32thhellerhttps://github.com/braintripping/re-view/blob/master/re_view_prosemirror/example/re_view_prosemirror/example.cljs#L10-L12#2017-10-1619:32thhellerI see you already did externs annotations#2017-10-1619:33ivanpierreElectron, in fact...
#2017-10-1619:33thheller@ivanpierre put it all in one source-path, the build config will determine what goes into a build#2017-10-1619:34thhellerI put together an example for electron a while ago#2017-10-1619:34thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/electron#2017-10-1619:34ivanpierreYes, That's what I do. But I had some conflicts with reagent and node.#2017-10-1619:35thhelleryou might need to use the latest alpha release of reagent#2017-10-1619:35ivanpierreI did ,)#2017-10-1619:35thhellerwhat problems did you see?#2017-10-1619:36ivanpierreWell, perhaps a bug from mine... Il grab a little more... If it doesn't work I'll give you precise behaviour.... 😉#2017-10-1619:39thhelleryou might run into trouble if you include react-dom on the node side of things#2017-10-1619:40thhellerwould need to split that into a separate namespace that is only included for the web stuff#2017-10-1619:42mhuebert@thheller yeah I did a lot of those actually. but they were all based on the idea that my module wrote all of this stuff to a couple global objects, pm and pmMarkdown#2017-10-1619:43thhellerin my version of :infer-externs you currently only need to do ^js thing#2017-10-1619:44mhuebert@thheller i just got
failed to start service
{:id :dev-http}
ExceptionInfo: failed to start service
	clojure.core/ex-info (core.clj:4725)
	clojure.core/ex-info (core.clj:4725)
	shadow.runtime.services/start-many/fn--194 (services.clj:135)
...
Caused by:
BindException: Address already in use
from trying to run watch after an independent server
#2017-10-1619:44mhuebert@thheller that sounds much simpler. so just ^js some-symbol-from-javascript-land#2017-10-1619:44thhelleryes, skip the “typing”#2017-10-1619:44mhuebertif it works, i like this much better#2017-10-1619:45thhellerwell it would still be better to use the fully qualified thing but who wants to type annotate other people’s code#2017-10-1619:46thhellerdoh … will fix http#2017-10-1619:47thhellerhmm wait#2017-10-1619:47thhellerno that should not be an issue#2017-10-1619:47thhellerwhat did shadow-cljs watch thing say? connected to server?#2017-10-1619:47thhelleror did it start a new one?#2017-10-1619:48thhellersecond line should say connect#2017-10-1619:48thheller
shadow-cljs compile browser
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.18
shadow-cljs - connected to server
#2017-10-1619:49thhellerif it didn’t connect the target/shadow-cljs files may been deleted after starting the server#2017-10-1619:49thhellerlein tends to do that#2017-10-1619:49thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L4-L5#2017-10-1619:50mhuebertearlier today, it worked in another project. i have :lein true in this one#2017-10-1619:50mhuebertsomehow now it is connecting#2017-10-1619:50mhuebertam not sure what changed.#2017-10-1619:50thhellerregardless, starting the http server should not be a critical error#2017-10-1619:50thhellerI’ll just print a warning#2017-10-1619:51mhuebertif website requires prosemirror, which has {:npm-deps {...}} in deps.cljs, should shadow-cljs npm-deps inside the website project have the effect of installing those npm modules?#2017-10-1619:52thhellerhehe … maybe? it should yes#2017-10-1619:52thhellercan do a quick test#2017-10-1619:54thhellerI didn’t find any package that had deps.cljs when testing so its basically untested#2017-10-1619:54thhellerI can test with re-view-prosemirror now that I know one#2017-10-1619:55mhuebertwell, re-view-prosemirror may not be the best example at the moment as it is in transition#2017-10-1619:55thhellertested and it worked yes#2017-10-1619:56ivanpierreOk : /Users/ivan/.m2/repository/cljsjs/create-react-class/15.6.0-1/create-react-class-15.6.0-1.jar deps.cljs refers to file not in jar: cljsjs/create-react-class/production/create-react-class.min.inc.js {:tag :shadow.build.classpath/deps-cljs, :source-path #object[java.io.File 0x5da7cee2 "/Users/ivan/.m2/repository/cljsjs/create-react-class/15.6.0-1/create-react-class-15.6.0-1.jar"], :name "cljsjs/create-react-class/production/create-react-class.min.inc.js"} ExceptionInfo: /Users/ivan/.m2/repository/cljsjs/create-react-class/15.6.0-1/create-react-class-15.6.0-1.jar deps.cljs refers to file not in jar: cljsjs/create-react-class/production/create-react-class.min.inc.js problem with create-react-class. it search the jar in production and in .m2 there is only common and developement... But it's the last release. I'll go and see.#2017-10-1619:57thhellerah damn thats still not fixed#2017-10-1619:57ivanpierre^^#2017-10-1619:57thheller[reagent "0.8.0-alpha1" :exclusions [cljsjs/create-react-class]]#2017-10-1619:57thhelleruse that#2017-10-1619:57ivanpierreThanks#2017-10-1620:00thhellerI now realize that I’m far too strict in validating the deps.cljs files … 🙂#2017-10-1620:00thhellera warning should be enough#2017-10-1620:03thheller@mhuebert one thing missing for the npm-deps things is support for yarn, its currently just calling npm install --save #2017-10-1620:30mhuebertis there a way to add an annotation for a function call? eg. (.serialize this) where serialize shouldn’t be rewritten#2017-10-1620:30mhuebertor… does (.serialize ^js this) have that effect#2017-10-1620:30thhelleryes, well it should. did not test.#2017-10-1620:33thhellerconfirmed, works#2017-10-1620:38thheller@mhuebert btw I cannot guarantee that CLJS will accept the plain ^js tag, so that might not actually work with anything but shadow-cljs#2017-10-1620:38thhellerplain ^js has always been allowed, just not in combination with :infer-externs I think#2017-10-1620:46mhuebertweird Closure error only in :advanced -
-> Closure - Optimizing ...
IllegalStateException:  [GETPROP 14 [length: 31] [source_file: re_view_prosemirror.core.js], EXPR_RESULT 14 [length: 66] [source_file: re_view_prosemirror.core.js]]
	com.google.common.base.Preconditions.checkState (Preconditions.java:721)
	com.google.javascript.rhino.Node.replaceChild (Node.java:852)
	com.google.javascript.jscomp.AggressiveInlineAliases.inlineGlobalAliasIfPossible (AggressiveInlineAliases.java:309)
	com.google.javascript.jscomp.AggressiveInlineAliases.inlineAliases (AggressiveInlineAliases.java:162)
	com.google.javascript.jscomp.AggressiveInlineAliases.process (AggressiveInlineAliases.java:111)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:304)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:230)
	com.google.javascript.jscomp.Compiler.performOptimizations (Compiler.java:2457)
	com.google.javascript.jscomp.Compiler$3.call (Compiler.java:834)
	com.google.javascript.jscomp.Compiler$3.call (Compiler.java:830)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:128)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:862)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:829)
	com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:778)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:497)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
	shadow.build.closure/compile-js-modules (closure.clj:874)
	shadow.build.closure/compile-js-modules (closure.clj:865)
	shadow.build.closure/optimize/fn--24464 (closure.clj:1138)
	shadow.build.closure/optimize (closure.clj:1124)
	shadow.build.closure/optimize (closure.clj:1115)
	shadow.build/optimize (build.clj:288)
	shadow.build/optimize (build.clj:280)
	shadow.cljs.devtools.api/release* (api.clj:197)
	shadow.cljs.devtools.api/release* (api.clj:183)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:25)
	shadow.cljs.devtools.cli/do-build-commands/fn--30494/fn--30495 (cli.clj:66)
	clojure.core/binding-conveyor-fn/fn--5297 (core.clj:2027)
	java.util.concurrent.FutureTask.run (FutureTask.java:266)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
	java.lang.Thread.run (Thread.java:745)
#2017-10-1620:46mhuebert(oops i thought that would collapse into a snippet)#2017-10-1620:46thhellerwhat the heck#2017-10-1620:47thhellerAggressiveInlineAliases good name#2017-10-1620:47mhuebertthis is the file. but i don’t see a line number in the error? https://github.com/braintripping/re-view/blob/master/re_view_prosemirror/src/re_view_prosemirror/core.cljs#2017-10-1620:48thhellernothing immediately obvious, checking#2017-10-1620:50thhelleruhm there is no shadow-cljs.edn?#2017-10-1620:52mhueberti’m only using it from re-view/website#2017-10-1620:52mhuebertcan add one#2017-10-1620:53thhellerthats empty?#2017-10-1620:53thhellerhttps://github.com/braintripping/re-view/blob/master/website/shadow-cljs.edn#2017-10-1620:55thhellerhow come you def everything? (def EditorState prosemirror-state/EditorState)?#2017-10-1620:55thhellercould also do :refer in ns instead#2017-10-1620:55mhuebertjust to not break other libs that were referencing things the old way#2017-10-1620:56mhuebertpreviously I did all the messy JS object reading here, so that my other code wouldn’t have to do all kinds of (.-someProp js/pmMarkdown) junk#2017-10-1620:56thhellerah ok, shouldn’t be an issue. just checking#2017-10-1620:56mhueberti will be able to rewrite a lot of stuff in a nicer now that i can require directly from node_modules#2017-10-1620:59thhelleryeah some of the interop code before was really messy#2017-10-1620:59mhuebertbe back in a bit#2017-10-1620:59mhueberti can clean this up into an independently compiling thing if you want first#2017-10-1620:59mhueberthard to debug as it is now#2017-10-1621:00thhellerjust need something I can call to reproduce#2017-10-1621:00thhellerthe config in website should be enough but its empty#2017-10-1621:08thheller
re_view_prosemirror.core.keymap = re_view_prosemirror.core.keymap;
re_view_prosemirror.core.commands = re_view_prosemirror.core.commands;
re_view_prosemirror.core.model = re_view_prosemirror.core.model;
re_view_prosemirror.core.history = re_view_prosemirror.core.history;
#2017-10-1621:08thhellerthis is odd#2017-10-1621:09thheller
(def keymap keymap)
(def commands commands)
(def model model)
(def history history)
#2017-10-1621:10thhelleryeah, those are causing the issue#2017-10-1621:10thhellerresolves to itself#2017-10-1621:12thhellerprobably need to rename the :as in the ns if you want to keep those def#2017-10-1621:38mhuebertI see#2017-10-1621:38mhuebertseems strange that that would cause an error#2017-10-1621:38mhuebertx = x#2017-10-1621:38mhuebert(let [x x])#2017-10-1621:43mhuebertanyway i can get rid of those and change the references to use the node_modules stuff directly.#2017-10-1622:19mhuebertweird. somehow it is not picking up componentDidUpdate#2017-10-1622:19mhuebert$map__37705__$1_p__37704$$.$componentDidUpdate$ is not a function#2017-10-1622:19mhuebertdespite having react externs in one of the dependencies (re-view-hiccup)#2017-10-1622:19mhuebertand thought that componentDidUpdate would have been in the generated externs, but didn’t see it there either#2017-10-1623:13thhellerweird indeed, ShadowJS.prototype.componentDidUpdate it is in my test file for sure#2017-10-1700:04mhuebertcould it have anything to do with direct vs. transitive dependencies?#2017-10-1700:15thhellershouldn’t. might need some code I can look at.#2017-10-1700:15thhelleroff to bed, gn8#2017-10-1709:52mhuebert@thheller I think I have narrowed this down. when :lein true is set, shadow-cljs npm-deps does not appear to install transitive deps. I’ve pushed the config to /website in re-view: https://github.com/braintripping/re-view.git#2017-10-1709:54mhuebertIn the repo, :source-paths in shadow-cljs.edn is identical to :source-paths in project.clj, but commented out. I would expect there to be no difference between where :source-paths are specified when using :lein true. but if I run shadow-cljs npm-deps without specifying the deps in shadow-cljs.edn, they do not install. if I uncomment :source-paths in shadow-cljs.edn, then it works. (even if I keep :lein true)#2017-10-1710:03thhelleroh, yes. npm-deps does not use lein, so it doesn’t pickup the dependencies of that, since no :dependencies are listed in shadow-cljs.edn#2017-10-1710:04thhellerwill fix that so it also uses lein#2017-10-1710:04mhuebertah I see#2017-10-1710:06thhellerhow come you are sticking to lein? just because of the cursive integration or some other reasons?#2017-10-1710:07thhellerthere is about a 10sec startup time penalty when using lein#2017-10-1710:07mhuebertcursive yes.#2017-10-1710:07mhuebertcheckouts is also a minor thing. now i am switching to only source-paths, but then I have to remember to add :dependencies manually#2017-10-1710:08thhellerdependencies should work the same way as in lein#2017-10-1710:08mhuebertI just mean using :source-paths means it doesn’t pick up the transitive deps#2017-10-1710:08thhellerso you keep the thing dependency but also include checkouts/thing/src path#2017-10-1710:08mhuebertoh i see#2017-10-1710:09mhuebertyeah.#2017-10-1710:09mhuebertboth.#2017-10-1710:09thhellerthe src path will be picked over whats in the jar#2017-10-1710:09thhellerjust need to lein install if you change the dependencies of checkout#2017-10-1710:09thhellerI think lein behaves the same way#2017-10-1710:11thhellerhttps://github.com/cursive-ide/cursive/issues/1804#2017-10-1710:11thhellerColin said he is going to add support for deps.edn soon, when that comes I can take advantage of that too#2017-10-1710:12mhuebertso, I think it should work now without any lein install-ing, to try shadow-cljs release browser in re_view/website, and you can observe that if componentDidUpdate is not listed in browser.txt, the build breaks. I am not sure why it is not being included in the auto externs#2017-10-1710:13thhellerchecking#2017-10-1710:13mhuebertshadow-cljs npm-deps first should work#2017-10-1710:14thhelleryarn is enough since they are in there already https://github.com/braintripping/re-view/blob/master/website/package.json#2017-10-1710:14mhuebertI see, they were added there by shadow 🙂#2017-10-1710:15thhelleryeah I npm install --save#2017-10-1710:15mhueberti think thats fine#2017-10-1710:17thhellerok website build completed#2017-10-1710:18mhuebertso i assume if you run shadow-cljs server and open the page, it will load fine. but if you comment componentDidUpdate in externs/browser.txt and build again, then there is an externs error#2017-10-1710:18thhellerhehe this ES6 generation is really slow …#2017-10-1710:19thhellerthe faster version goes from about 500ms per file to 18ms#2017-10-1710:19mhuebertoh wow#2017-10-1710:20mhuebertso in target/shadow-cljs/builds/browser/release/externs.shadow.js I don’t see any lifecycle methods, but I do see isPureReactComponent, isValidElement, other React things#2017-10-1710:20thhellerall the component* fns are missing#2017-10-1710:21thhellerchecking#2017-10-1710:21mhuebertI use a lot of lifecycle methods so i don’t know why only this one is not working.#2017-10-1710:23thhellerI really need to fix this react workaround#2017-10-1710:23thhellerdev and release are both included 😞#2017-10-1710:24mhuebertwas react handled as a special case?#2017-10-1710:25thhellernoh, they are a special case#2017-10-1710:25thheller
'use strict';

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./cjs/react.production.min.js');
} else {
  module.exports = require('./cjs/react.development.js');
}
#2017-10-1710:26thhellerthey do this nonsense#2017-10-1710:26thhellernever saw any other package do this#2017-10-1710:27thhellermy inspector which extracts the require calls to collect the dependencies#2017-10-1710:27thhellerdoes not cover conditional includes#2017-10-1710:27mhuebertoh that does seem wrong#2017-10-1710:27thhellerwhich is why the :resolve {"react" ...} override must be done for react#2017-10-1710:27mhuebertI hesitate to draw conclusions yet, because I don’t know why or if something is wrong somewhere 😉, but the shadow-cljs advanced build using these direct node_modules requires vs. my old webpack stuff has led to a smaller build, 950kb vs 1.4mb#2017-10-1710:28thhellerwell if you included multiple separate bundles it should be smaller yes#2017-10-1710:28thhellerok, figured out why the lifecycles are missing#2017-10-1710:29thhellerthey are never actually assigned anywhere#2017-10-1710:29thheller
if (typeof instance.componentWillReceiveProps === 'function' && (oldProps !== newProps || oldContext !== newContext)) {
      callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
    }
#2017-10-1710:29mhuebert😞#2017-10-1710:29thhellerthats not something I can extract#2017-10-1710:29mhuebertright. ok.#2017-10-1710:30mhuebertseparately: in re_view/src/ the deps.cljs includes some :externs… are these not being picked up?#2017-10-1710:31mhuebertor did I include them wrong somehow#2017-10-1710:32thhellerah hmm, I might have deleted that part when I removed support for cljsjs#2017-10-1710:32thhellerexterns should still be picked up though#2017-10-1710:37thhellerhmm nope, should be picked up#2017-10-1710:38thhellerI have an idea but I hope its not related#2017-10-1710:48thhellerhaha the babel transform also bypasses all caching#2017-10-1710:48thhellerno wonder its so slow#2017-10-1710:48thhellerok found it, the deps.cljs externs are not included#2017-10-1710:54mhuebertre: earlier comment about react - do you mean that in this current advanced build, react + react-dom are being included twice?#2017-10-1710:54thhellerhmm yeah thats really a problem I need to solve, the problem really is that you are not supposed to include those externs#2017-10-1710:55thhellerif you include externs for react but not provide react#2017-10-1710:55thhellerand someone else does as well#2017-10-1710:55thhellerthey will cause a conflict and closure will complain and fail#2017-10-1710:55mhuebertso including react in :npm-deps doesn’t count as ‘providing’ react#2017-10-1710:55thhelleryes, react will be included twice. but release will remove the dev version so its not a big deal in release.#2017-10-1710:56thhellerno#2017-10-1710:56thhellernpm provides react, you just depend on it#2017-10-1710:56thhellerI should just start a repo collecting externs for certain npm packages#2017-10-1710:57thhellerso I can include the react externs if you (:require ["react" ...])#2017-10-1710:57thhellerthis automatic generation really isn’t working all too well 😞#2017-10-1710:57mhuebertso even for this it would make sense to have a way to map from npm module names to externs files, that way there isn’t duplication#2017-10-1710:57mhuebertif it was `:npm-externs {“react” “externs/react.ext.js”}#2017-10-1710:58mhuebertthen if multiple projects would declare them, one could de-dupe, without needing a global registry that is maintained#2017-10-1710:58mhueberti doubt it is particularly fun maintaining a thing like cljsjs 😕#2017-10-1710:58thhelleryeah but every lib depending on react would need to add :npm-externs#2017-10-1710:59thhelleryeah I really don’t want to maintain such a thing#2017-10-1710:59thhellerbut its far easier since its just about externs#2017-10-1710:59thhellernot about repackaging whole npm packages#2017-10-1711:00thhellerexterns is one thing cljsjs got right, its perfect for that#2017-10-1711:00thhellerbut I want to get rid of these cljsjs/react dependencies 😞#2017-10-1711:01mhuebertso closure compiler will complain if duplicate externs are provided?#2017-10-1711:01thhellerdamn this automatic generation#2017-10-1711:01thhelleryeah 😞#2017-10-1711:01mhuebertthat is unfortunate#2017-10-1711:02thhellerhttps://dev.clojure.org/jira/browse/CLJS-2344#2017-10-1711:02thhellerand one other issue I forgot the name of#2017-10-1711:02thhellerproblem is de-duping is not easy#2017-10-1711:02mhuebertis the error from duplicate file content, or file path?#2017-10-1711:02thhellerduplicate var name#2017-10-1711:03thhellerif one extern declares var React; no other is allowed to do that#2017-10-1711:03thhellerso even if you de-dupe based on the file content hash#2017-10-1711:03thhellerthere is no guarantee that they will have the same hash#2017-10-1711:04thhellerthere really should be one “source of truth” for externs#2017-10-1711:07thhellerhmm where do you use componentDidUpdate? maybe we can solve this by annotating the code?#2017-10-1711:07mhueberteven with source-maps I don’t seem to get pointed to direct usage#2017-10-1711:07mhuebertmaybe because of macros#2017-10-1711:08thheller(.componentDidUpdate this)#2017-10-1711:08thhellershould work with (.componentDidUpdate ^js this)#2017-10-1711:09thheller(fn [^react/SyntheticEvent e] I don’t think that is valid? should start with ^js/? i think#2017-10-1711:10mhuebertbut wouldn’t js/ imply that it is a global variable#2017-10-1711:10mhuebertwhereas here it is referred in as react#2017-10-1711:11thhellerno, tags are not resolved that way#2017-10-1711:11thhellerit checks if its a js-tag?, if so it uses the remainder to write externs#2017-10-1711:12mhuebertoh i found the .componentDidUpdate#2017-10-1711:12thheller
(defn js-tag? [x]
  (and (symbol? x)
       (or (= 'js x)
           (= "js" (namespace x)))))
#2017-10-1711:12mhuebertok, should be easy fix#2017-10-1711:12mhueberthmm#2017-10-1711:12thhellerbut for shadow-cljs all that matters is the ^js tag anyways, the type info is optional#2017-10-1711:13mhuebertso is it possible to annotate that e is an instance of my-referred-react-thing.SyntheticEvent#2017-10-1711:13thhellerno#2017-10-1711:13thhellerthey are not resolved I think#2017-10-1711:13thhellerdidn’t quite understand that part of the externs inference#2017-10-1711:14thhellerthey really can’t be resolved#2017-10-1711:14mhueberttbh i viewed those annotations as a form of necessary but poorly understood voodoo#2017-10-1711:14thhellerdefinitely#2017-10-1711:15mhuebertand with enough of them, things would compile#2017-10-1711:15thhellerthats why I simplified to just ^js, without the type structure#2017-10-1711:16thheller
(defn my-fn [^js/Foo.Bar x]
  (let [z (.baz x)]
    (.-wozz z)))
#2017-10-1711:16thhellerhttps://clojurescript.org/guides/externs#2017-10-1711:16mhuebertdamn, (.componentDidUpdate ^js this) does not appear to have worked#2017-10-1711:16thhellerthat would be totally accurate but who wants to write that#2017-10-1711:17thheller
(def kmap
  "Mapping of convenience keys to React lifecycle method keys."
  {:constructor             "constructor"
   :view/initial-state      "$initialState"
   :view/state              "$state"
   :view/did-catch          "componentDidCatch"
   :view/will-mount         "componentWillMount"
   :view/did-mount          "componentDidMount"
   :view/will-receive-props "componentWillReceiveProps"
   :view/will-receive-state "componentWillReceiveState"
   :view/should-update      "shouldComponentUpdate"
   :view/will-update        "componentWillUpdate"
   :view/did-update         "componentDidUpdate"
   :view/will-unmount       "componentWillUnmount"
   :view/render             "render"})
#2017-10-1711:17thhelleris that used in a macro or so?#2017-10-1711:19mhuebertno, that is used with a call to goog.object/set#2017-10-1711:19mhueberti don’t think that is the problem… I think it is line 100 of re-view.material.util#2017-10-1711:19thhellerhehe wow .. this babel thing is so super annoying#2017-10-1711:19thhellerI really need to fix that#2017-10-1711:20mhuebertsource-mapping is taking me all over the place but seems nowhere near the actual source of .componentDidUpdate#2017-10-1711:20thhellercan’t stand slow builds#2017-10-1711:20thhellersource mapping is currently completely broken when using JS deps#2017-10-1711:21mhuebertoh ok.#2017-10-1711:21thhellerunfortunate side effect of the hacking I had to do to get that working#2017-10-1711:21mhuebertin the javascript source near the error, one can see get-element and other things that make me believe it’s L#100 of that file. plus it is the only place in the project that uses .componentDidUpdate as a host interop call#2017-10-1711:22thhellerpseudo-names should still help#2017-10-1711:22thhellergod dammit … I’m fixing this now#2017-10-1711:23thhellertoo slow#2017-10-1711:23mhueberti remember now the macro stuff i was thinking of. i allow views to have custom methods included in the map, like {:my-method ...}, the macro writes these in host interop syntax so that you can use them like (.myMethod the-component) and closure will rewrite it all and it will still work, without any annotations.#2017-10-1711:23mhuebertbut all the :view/* stuff goes through that kmap you saw and is never rewritten with host interop syntax#2017-10-1711:24thheller(gobj/extend prototype (lifecycle-methods lifecycle-keys) this is most likely it#2017-10-1711:24mhuebertL#196 of re-view.core#2017-10-1711:24thhellerre-view.core/class*#2017-10-1711:25mhuebert
(doto obj
   (gobj/set (get kmap method-k) (wrap-methods method-k method)))
#2017-10-1711:30thhellerchecking if the annotation makes it through#2017-10-1711:30thhellergobj/set should be fine#2017-10-1712:07mhuebertif i move the ^js annotation into the arglist, it seems to work:
(fn [{:keys [view/state get-element] :as ^js this}]
  ...
  (.componentDidUpdate this))
`
#2017-10-1712:11mhuebertcan’t say I have ever understood exactly where these annotations are allowed to go. i recall quite a bit of trial and error when i first added them.#2017-10-1712:12mhuebertbut this is good, adding ^js there in the arglist fixes the .componentDidUpdate call and I tried adding a custom method to the component and calling it in the same place, also worked.#2017-10-1712:13thheller(.componentDidUpdate ^js this) should work as well, not sure why it wouldn’t#2017-10-1712:13mhuebertvoodoo#2017-10-1712:14thhellermust fix the babel speed issue first#2017-10-1712:14thhellercan’t debug when I have to wait a minute in every test 😛#2017-10-1712:14mhueberti appreciate this lack of patience 🙂#2017-10-1712:22thhellerslow tools are the worst#2017-10-1716:13thheller
-> Babel transform: node_modules/@material/animation/index.js
<- Babel transform: node_modules/@material/animation/index.js  (629 ms)
-> Babel transform: node_modules/@material/base/foundation.js
<- Babel transform: node_modules/@material/base/foundation.js  (34 ms)
-> Babel transform: node_modules/@material/base/component.js
<- Babel transform: node_modules/@material/base/component.js  (59 ms)
-> Babel transform: node_modules/@material/ripple/adapter.js
<- Babel transform: node_modules/@material/ripple/adapter.js  (17 ms)
-> Babel transform: node_modules/@material/ripple/constants.js
<- Babel transform: node_modules/@material/ripple/constants.js  (13 ms)
-> Babel transform: node_modules/@material/ripple/util.js
<- Babel transform: node_modules/@material/ripple/util.js  (44 ms)
-> Babel transform: node_modules/@material/ripple/foundation.js
<- Babel transform: node_modules/@material/ripple/foundation.js  (172 ms)
-> Babel transform: node_modules/@material/ripple/index.js
<- Babel transform: node_modules/@material/ripple/index.js  (48 ms)
-> Babel transform: node_modules/@material/selection-control/index.js
<- Babel transform: node_modules/@material/selection-control/index.js  (9 ms)
-> Babel transform: node_modules/@material/checkbox/adapter.js
<- Babel transform: node_modules/@material/checkbox/adapter.js  (12 ms)
-> Babel transform: node_modules/@material/checkbox/constants.js
<- Babel transform: node_modules/@material/checkbox/constants.js  (6 ms)
-> Babel transform: node_modules/@material/checkbox/foundation.js
<- Babel transform: node_modules/@material/checkbox/foundation.js  (68 ms)
-> Babel transform: node_modules/@material/checkbox/index.js
<- Babel transform: node_modules/@material/checkbox/index.js  (55 ms)
#2017-10-1716:14thhellerfirst one is always slow since it has to spin up the node process but after that its pretty smooth#2017-10-1716:14thhellerstill need to fix that it bypasses the cache and always calls out to babel#2017-10-1716:27mhuebertthat’s doing the same transform as before?#2017-10-1716:34thhelleryep#2017-10-1716:34thhellerjust not launching a new babel process per file 🙂#2017-10-1716:34thhellerjust pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "087b60696c677f256b64627b483a2638263a3a"}, :content ("[email protected]")}#2017-10-1716:34thhellerstill need to fix a few things, please test#2017-10-1716:35thhellernow requires that shadow-cljs is installed into the project#2017-10-1716:35thhellerwill add a check into the script that enforces that later#2017-10-1716:36thhellerre-view website [:browser] Build completed. (334 files, 233 compiled, 0 warnings, 22.40s) down from 47sec#2017-10-1716:36thhellerdecent start#2017-10-1716:39thhelleralmost ready to debug the actual issue 😉#2017-10-1716:52thhellerbtw I just saw this ^js/Element element (get-element this)#2017-10-1716:53thhelleryou should be able to annotate get-element for this#2017-10-1716:53thheller(defn get-element ^js/Element [args …])#2017-10-1716:53thhellerlooking into the missing .componentDidUpdate now#2017-10-1716:55thheller
(defn thing [{:keys [foo] :as this}]
  (.componentDidUpdate ^js this))
#2017-10-1716:56thhellerdesctructuring seems to lose the tag#2017-10-1717:12thhellerhttps://dev.maria.cloud/ parrot#2017-10-1717:20thhellerdid you do any comparisons yet?#2017-10-1717:34mhuebertNot yet. There are a bunch of bugs I have to work out#2017-10-1717:34mhuebertUnrelated to shadow#2017-10-1717:35mhuebertBut I am impressed it's all working, removed every foreign-lib I think#2017-10-1717:35mhuebertUsing Babel is a good path I think. Closure is a hard road at this point#2017-10-1717:36mhuebertWhereas this is how most JS libs expect to be used#2017-10-1717:41thhelleryeah, at this point I see the closure stuff as an optional optimization#2017-10-1717:41thhellerif someone really wants to get their hands dirty they can do it#2017-10-1717:41thhellerbut the default will work more reliably with acceptable results#2017-10-1717:42thhellerI did some comparisons with how webpack bundles code#2017-10-1717:42thhellerand we are about the same size with slightly better performance characteristics since not everything is wrapped into one big IIFE#2017-10-1717:43thhelleryou are the first to use such a vast amount of JS deps I think#2017-10-1717:43thhellerI’m amazed that it works 🙂#2017-10-1718:50thhellerI think I figured out the (.componentDidUpdate ^js this) issue#2017-10-1718:50thhellersince this is a destructured binding it is already tagged as clj#2017-10-1718:51thhellerI do think that you should probably be still allowed to tag it though#2017-10-1718:51thhellerI hacked a fix, no idea if thats correct though#2017-10-1719:54mhuebertadvanced build appears to have worked with 2.0.22#2017-10-1719:55mhueberthmm.#2017-10-1719:56mhuebertin ./editor, I have 2.0.22 in package.json, but when I run shadow-cljs server I see
mattpro:editor MattPro$ shadow-cljs server
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.7
#2017-10-1720:02mhuebertmaybe it was in project.clj in a dep#2017-10-1720:04mhuebertyeah, now unless I use yarn run ... it appears to use my old global version instead of local npm version#2017-10-1720:18mhuebertnot a big deal but seems like a regression#2017-10-1720:38thhellerupdate the global install#2017-10-1720:39thhellerI changed the way the package is bundled, the old one doesn’t pick that up correctly
#2017-10-1721:24mhuebertah ok. so after updating global install to 2.0.22, then it tracks the npm version?#2017-10-1721:26thhelleryes#2017-10-1721:26thhelleradded a fix for the next version just in case#2017-10-1721:27thhellerthe shadow-cljs script checks for <project>/node_modules/shadow-cljs/cli/lib.js which doesn’t exist anymore#2017-10-1721:28thhelleradded the file back which then requires the correct one#2017-10-1721:28thhellerkinda don’t like the way the global install is handled#2017-10-1721:28thhellerthinking it might be better to just recommend using npx shadow-cljs or yarn shadow-cljs to run things#2017-10-1721:29thhellerwe are at a point where the install really must be in the project, it was sort of optional before#2017-10-1721:35thhellerhttps://github.com/mhuebert/maria/blob/master/editor/package.json#L7 could be removed#2017-10-1721:37thhellerbrain is too fried, just checking out your configs and setup#2017-10-1721:37thhellerlooks good#2017-10-1721:39thhelleryou might consider getting rid of the :trusted build and just code-split the :live build. there might be tons of overlap … nevermind you are on two domains, so no sharing#2017-10-1721:41thhelleralso (enable-console-print!) is never required, shadow-cljs injects that so you don’t have to 😉#2017-10-1722:56mhuebertyeah, the :trusted build can be advanced compiled, whereas the :live build uses selfhost and so must remain :simple.#2017-10-1722:56mhuebertwhen I run npm-deps I am seeing:
[:npm-deps-conflict "codemirror" :using :a]
[:a "5.30.0" #object[java.net.URL 0x7f3a9c11 "file:/Users/MattPro/Documents/sites2017/lark/tools/src/deps.cljs"]]
[:b "5.30.0" #object[java.net.URL 0x7f888518 "jar:file:/Users/MattPro/.m2/repository/lark/tools/0.1.5/tools-0.1.5.jar!/deps.cljs"]]
I think because I am using these extra source-paths in lieu of checkouts
#2017-10-1807:00thhellerhmm this is supposed to warn about conflicts but only if the versions differ#2017-10-1807:01thhellerright, forgot to compare versions 😛#2017-10-1809:57thhellerjust published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6e1d060f0a0119430d02041d2e5c405e405c5d"}, :content ("[email protected]")}, wasn’t sure if I published the externs inference fix from yesterday already#2017-10-1813:21Jonhttps://github.com/JulianBirch/cljs-ajax/issues/197#issuecomment-337564344#2017-10-1813:21Jonsometimes I just found warnings in existing projects,#2017-10-1813:21Jonis shadow-cljs more strict to libraries?#2017-10-1813:43mhuebertalrighty. Is there a way watch a :release? I’m trying to debug keybindings stuff in a windows virtual machine. loading the page across this weird not-really-a-network-boundary is incredibly slow, 2.41 minutes to load the page with 700 requests. it would be faster to advance or simple compile and then have a much smaller bundle#2017-10-1813:47thheller@jiyinyiyong thats based on the clojurescript version you are using. shadow-cljs always uses the latest while other tools might use older versions. uri? was added recently.#2017-10-1813:47thheller@mhuebert haha doh, there is no watch for release no.#2017-10-1813:47thhellerI had a “compact” mode once, which was :none but one file#2017-10-1813:48thhellerremoved that since it didnt seem to make sense 😛#2017-10-1813:48thhellerI want to reduce the number of requests though#2017-10-1813:48mhuebertalright. i can just run releases and reload#2017-10-1813:48thhellerI’ll probably bundle all packages together at one point#2017-10-1813:48thhellerso that “react” is one request not many#2017-10-1813:49thhellerbut nothing available now#2017-10-1814:03thheller@jiyinyiyong curious what made you report that error to cljs-ajax?#2017-10-1915:20JonI guessed if cljs-ajax changes the code, they may fix the warning.#2017-10-1915:20Jonturned out not the case?#2017-10-1818:03mhuebertam encountering a bug where sometimes my Keypress fork (which is referenced as a github commit hash) is being overwritten by the one from npm#2017-10-1818:03mhueberthowever, after reproducing once, I can’t again#2017-10-1818:07mhuebertI think I will rename my fork so that it will never attempt to download from npm#2017-10-1818:17thhellerone thing that might be happening is a conflict#2017-10-1818:18mhuebertthere is that conflict where it thinks it has a conflict, but actually the versions are the same#2017-10-1818:18mhuebertbecause of source-paths#2017-10-1818:18thhellerno I mean npm conflict#2017-10-1818:18thhellershadow-cljs will ONLY look at node_modules/thing#2017-10-1818:19thhellerbut sometimes npm installed things like node_module/thing-a/node_modules/thing-b#2017-10-1818:19thhellerbecause a node_modules/thing-bg already exists, just with a different version#2017-10-1818:19thhelleror npm handles installed from git differently? never did that before#2017-10-1818:20mhuebertsomehow the wrong files are being written to node_modules/thing during install#2017-10-1818:21thhellerI have no idea how to resolve npm conflicts#2017-10-1818:22mhueberti had a watch run, all good, correct files. when i made a release, the wrong version overwrote it#2017-10-1818:23thhellerhmm? I don’t ever touch node_modules#2017-10-1818:23mhuebertduring the installing npm deps?#2017-10-1818:23mhuebertor that’s cljs handling that#2017-10-1818:24thhellerah ok you call npm-deps#2017-10-1818:25thhellerI added a fix this morning that does not attempt to install anything thats already listen in package.json#2017-10-1818:25thhellermaybe thats whats happening#2017-10-1818:25thhellernpm-deps just blindly called npm install#2017-10-1818:26thhellerbut this was part of the 2.0.23 release#2017-10-1818:26thhellerare you using that?#2017-10-1818:27mhuebertthe time when this happened was actually the first build after i had run yarn upgrade shadow-cljs#2017-10-1818:29thhellerhmm when I run yarn I do not get the github version?#2017-10-1818:30thheller[:deps-version-conflict "github:braintripping/Keypress#1442b0a" "braintripping/Keypress#1442b0a" #object[java.net.URL 0x5f9b22c1 "jar:file:/Users/zilence/.m2/repository/lark/tools/0.1.14/tools-0.1.14.jar!/deps.cljs"]]#2017-10-1818:30thhellerthis is when I run shadow-cljs npm-deps#2017-10-1818:30mhuebertis npm run the same as yarn run#2017-10-1818:30thhellerdo you use npm or yarn?#2017-10-1818:30thhellerI think you are supposed to use npx over npm run#2017-10-1818:31mhuebertwell i was using yarn, but since cljs is always using npm, i think i should be consistent#2017-10-1818:31thhellernono I just didn’t add yarn support yet#2017-10-1818:31thhellerI do use yarn as well#2017-10-1818:33thheller
[
#2017-10-1818:33thhellerI think thats missing the github:?#2017-10-1818:34mhueberthm didn’t think it was necessary#2017-10-1818:34mhuebertbut i’ll add that#2017-10-1818:34thhellerno idea?#2017-10-1818:34mhuebertmore explicit, better anyway#2017-10-1818:35thhellerits just complaining about it because the version in package.json is different from the one in deps.cljs#2017-10-1818:35thhellerit will then attmpt to install that#2017-10-1818:36thhellerno wait .. I don’t understand my own code#2017-10-1818:36thhellerit will SKIP installing#2017-10-1818:37thhellerI have no idea how npm works …#2017-10-1818:37thhellerI just did what CLJS does#2017-10-1818:38mhuebertin any case, I’ve changed this to a scoped npm dep, so it cannot ever default to fetching something from npm#2017-10-1818:38thhellerprobably a good idea yeah#2017-10-1818:39mhuebertso right now you can run dev.maria.cloud and www.maria.cloud and compare shadow vs. old build#2017-10-1818:40mhuebertthe shadow build is a bit smaller and loads slightly faster on my machine, despite being many x more files (so i guess http2 is working!)#2017-10-1818:40mhuebertwhile actually editing, the dev version is much faster but thats because i fixed some perf bugs#2017-10-1818:41thhelleryeah h2 is perfect for this#2017-10-1818:43thhellerhow come https://dev.maria.cloud/ already does all the init stuff?#2017-10-1818:43thhellerit doesn’t appear to use the compiler?#2017-10-1818:44thhelleroh wait nvm. thats also the live frame#2017-10-1818:45thheller1.3mb shadow vs 1.5mb#2017-10-1818:45thhellerseems like a win 😉#2017-10-1818:46thhellerI’ll see if I can find something that takes too long on slower devices#2017-10-1818:47thheller4x cpu throttle perf seems much better#2017-10-1818:49thhellertakes 19sec for page to load#2017-10-1818:50thhellershadow version 9sec#2017-10-1818:50mhuebertthat is a big diff.#2017-10-1818:50mhuebertobviously this is still a massive bundle but no escaping that for now#2017-10-1818:51thhellerI can improve that part so it doesn’t render block#2017-10-1818:51mhuebert1st time :release is about 1 minute, subsequents ~12sec, that is all 3 builds. that is __way____ faster than before.#2017-10-1818:52thhellerneat#2017-10-1818:53mhuebertplus it’s doing all this bootstrap stuff on top.#2017-10-1818:53mhuebertlive reloading works better than before, that is also because my cljs-live goog.require hacks did not play well with figwheel#2017-10-1818:54thhellerhehe yeah I can imagine#2017-10-1818:56thhellerhttps://github.com/braintripping/re-view/blob/master/re_view/src/re_view/render_loop.cljs#L73#2017-10-1818:56thhellerthat tag is incorrect, ^boolean not ^:boolean#2017-10-1818:58thhellerjust checking the render profile and it seems like re_view.render_loop.render_loop is actually called more than once per rAf#2017-10-1819:00thhellerno idea if its supposed to#2017-10-1819:06thhelleranyways, looks nice. don’t think I can do much more tuning of the bootstrap stuff#2017-10-1819:06thhellera bit maybe but not much#2017-10-1820:09mhuebert@thheller oh, thanks, it appears I’ve made that ^boolean mistake a number of times in other code bases too#2017-10-1820:10mhueberti don’t think it should be called more than once per rAf#2017-10-1820:14thhellerwoho .. I fixed the conditional requires react and apparently others do#2017-10-1820:15thheller
#{module$node_modules$object_assign$index
  module$node_modules$react$cjs$react_development shadow.js
  module$node_modules$fbjs$lib$invariant
  module$node_modules$fbjs$lib$emptyObject
  module$node_modules$prop_types$lib$ReactPropTypesSecret
  module$node_modules$fbjs$lib$emptyFunction
  module$node_modules$prop_types$checkPropTypes
  module$node_modules$fbjs$lib$warning}
#2017-10-1820:15thheller
#{module$node_modules$object_assign$index
  module$node_modules$react$cjs$react_production_min shadow.js
  module$node_modules$fbjs$lib$invariant
  module$node_modules$fbjs$lib$emptyObject
  module$node_modules$fbjs$lib$emptyFunction}
#2017-10-1820:15thhellerdev vs production#2017-10-1820:16thhellerthat looks way better#2017-10-1820:17thhellershould make packages a bit smaller and doesn’t require the custom react :resolve anymore#2017-10-1820:17thhellerI like#2017-10-1822:58thheller@mhuebert {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "15667d74717a623876797f6655273b253b2720"}, :content ("[email protected]")} should speed up your builds considerably since babel transformed files are now properly cached#2017-10-1908:45thheller@mhuebert I just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d1a2b9b0b5bea6fcb2bdbba291e3ffe1ffe3e7"}, :content ("[email protected]")} which adds a new :devtools {:async-require true} option. it will load files using window.fetch in :dev mode#2017-10-1908:46mhuebertwith 2.0.26, after cache is hot, yarn run watch with Maria’s 3 builds takes 1.62 seconds 🙂#2017-10-1908:46thhellerin my test build this cuts page load time dramatically. ~1sec -> 500ms#2017-10-1908:47thhellerbut its async, so it might not work for all setups#2017-10-1908:47mhuebert:release for all 3 takes 11s.#2017-10-1908:47thhellersweet 🙂#2017-10-1908:48mhuebertasync-require - does this only affect :dev mode?#2017-10-1908:48thhelleryes#2017-10-1908:48mhuebertso not for release?#2017-10-1908:48thhellerdon’t need it for release#2017-10-1908:48mhuebertoh right this is for those situations where one is loading 700 files#2017-10-1908:49thhelleryeah, the closure debug loader usually injects a bunch of script tags#2017-10-1908:49thhellerwhich is not very fast#2017-10-1908:49thhellerespecially at that number of files#2017-10-1908:50thhellerI did some experiments with this a while ago, your build seems like it might work with it#2017-10-1908:50thhellercan also do <script src="/js/compiled/shadow-trusted.js" type="text/javascript" defer></script> then, note the defer or async#2017-10-1908:52mhueberttoggling the devtools async-require doesn’t seem to make much of a difference in my normal setup, but maybe with the virtualbox setup#2017-10-1908:52thhellerreally? I would have expected a big difference at 700 files#2017-10-1908:58thhellerhmm doesn’t seem to work well in firefox#2017-10-1908:58thhellerwonder why#2017-10-1909:07thhellergeez firefox is slow loading :none builds#2017-10-1909:09thhellerbut also way faster with the fixed async-require#2017-10-1909:10thhellernext big perf win in dev will probably be ssl+http2 support for the dev server#2017-10-1909:22mhueberthttp2 in dev, yeah#2017-10-1909:58mhuebertthe simplicity of this is nice:
lein new re-view my-great-app;
cd my-great-app;
lein figwheel;
#2017-10-1909:59mhuebertI think the closest shadow equivalent I can think of is:
lein new re-view my-great-app;
cd my-great-app;
yarn install;
yarn run shadow-cljs npm-deps;
yarn run shadow-cljs watch browser;
#2017-10-1909:59mhuebertI put the first 2 yarn things into a deps command, and the last into watch, so
yarn run deps;
yarn run watch;
#2017-10-1910:00mhuebertwhich is not bad#2017-10-1910:00mhuebertbut requires yarn, I couldn’t get it to work with npm#2017-10-1910:00thhellerthe npm-deps will be called automatically soon#2017-10-1910:00thhellerjust needs more testing#2017-10-1910:01thhelleralso given the JS heavy side of things#2017-10-1910:01mhuebertok. calling npm install or yarn install directly is ok i think as the first step (to install shadow-cljs). but the npm-deps part is important because the template shouldn’t have to keep all its transitive deps in package.json.#2017-10-1910:02thhellerwe could also start building templates the yarn way#2017-10-1910:02thhelleryarn create re-view#2017-10-1910:02mhuebertoh, didn’t know about that#2017-10-1910:02thhellerhttps://yarnpkg.com/lang/en/docs/cli/create/#2017-10-1910:03mhuebertthat looks promising#2017-10-1910:05thhellerdidn’t look too closely into the template stuff yet, maybe just start with a few quickstart repos that you just clone#2017-10-1910:39mhuebertdoes shadow have any other dependencies, related to java/lein/maven/etc#2017-10-1910:39mhuebertthings that wouldn’t be on everyone’s computer#2017-10-1912:18thhellerjava#2017-10-1912:18thhellernode#2017-10-1912:19thhellernpm (or yarn)#2017-10-1912:19thhellerthats it#2017-10-1912:19thhellerjava8 minimum, java9 might have issues#2017-10-2014:19mhuebertcljsbuild is deleting stuff from node_modules#2017-10-2014:20thhellerhmm?#2017-10-2014:21mhuebert
lein new re-view xyz;
cd xyz;
yarn install;
# node_modules/shadow-cljs is correct
lein figwheel;
# node_modules/shadow-cljs is empty
#2017-10-2014:21thhellerwhy would they do that?#2017-10-2014:21mhuebertno idea!#2017-10-2014:21mhuebertseems crazy to me.#2017-10-2014:24thhellerindeed#2017-10-2014:24thhellerhmm do they maybe delete everything and then install :npm-deps from deps.cljs only?#2017-10-2014:24thhellerwhile totally ignoring package.json?#2017-10-2014:25mhuebertappears so#2017-10-2014:25mhueberti think i will post in #cljs-dev#2017-10-2014:26mhuebertif you run those lines above, do you see the same thing? would hope it is not something specific to my machine#2017-10-2014:26thhellerhmm nope#2017-10-2014:26thhellerits still there#2017-10-2014:27mhuebertshadow-cljs-jar too?#2017-10-2014:27mhuebertfor me shadow-cljs directory stays but is emptied#2017-10-2014:27thhellerwow yes its empty#2017-10-2014:28thhellerwhat the heck, shadow-cljs-jar is gone too#2017-10-2014:28mhuebertbut shadow-cljs-jar is totally removed#2017-10-2014:28mhuebertyeah#2017-10-2014:29thhellerI don’t get it#2017-10-2014:30mhueberti am trying with left-pad#2017-10-2014:31mhuebertdeleted left-pad, but did re-order package.json#2017-10-2014:32thhellerhmm it seems to be npm not lein#2017-10-2014:32thhelleryarn install then npm install react and its gone#2017-10-2014:33thhelleryeah its npm#2017-10-2014:35thhellerif you start with npm install then everything is fine#2017-10-2014:35thhellerso npm install instead of yarn install first#2017-10-2014:37thhelleryeah the problem is running npm install react without running npm install first#2017-10-2014:37thhellernpm install with package names does not install things from package.json first#2017-10-2014:39mhuebertso npm install with a package name uninstalls things?#2017-10-2014:39thhellerappears so#2017-10-2014:39mhuebertwhat on earth#2017-10-2014:39thhellerit works if you npm install first since then its in the package-lock.json#2017-10-2014:40thhellerseems like an npm bug#2017-10-2014:40mhueberthttps://github.com/npm/npm/issues/17929#issuecomment-319722758#2017-10-2014:42thhellerlol#2017-10-2014:43mhuebertgod. so.#2017-10-2014:44mhuebertnpm install instead of yarn install#2017-10-2014:44thhellerthats why shadow-cljs now detects if there is a yarn.lock and then uses yarn to install npm deps 😉#2017-10-2014:45mhueberti was hoping to be able to use this re-view template as a nice way to compare things between shadow and cljsbuild#2017-10-2014:46mhuebertbecause i want it to support both anyway#2017-10-2014:46thhelleryeah I was just looking at that 🙂 don’t actually know how those tools work#2017-10-2014:47thhellermight not be the best idea to have both in one template though#2017-10-2014:47thhellerthis stuff tends to stay there#2017-10-2014:47mhueberttrue#2017-10-2014:48mhuebertnpm run Error: missing script: shadow-cljs#2017-10-2014:48mhuebertyou had mentioned npx but i really wish another dep wasn’t necessary#2017-10-2014:48thhellernpx should come with npm5#2017-10-2014:48mhuebertoh#2017-10-2014:51mhueberti see, i can put npx commands into "scripts" in package.json so the user still just runs npm run ... to activate the script#2017-10-2014:52thhellerits a bit weird#2017-10-2014:52thhellernpm shadow-cljs help#2017-10-2014:52thhellerah no wait#2017-10-2014:53thhellernpx shadow-cljs help works#2017-10-2014:54thhellernpm run shadow-cljs help doesn’t work though?#2017-10-2014:54mhuebertnope#2017-10-2014:54mhuebert
"scripts": {
    "deps": "npm install; npx shadow-cljs npm-deps;",
    "watch": "npx shadow-cljs watch browser;",
    "release": "npx shadow-cljs release browser;"
  },
#2017-10-2014:54thhellerdidn’t it use to work like that before?#2017-10-2014:54mhueberti thought so yes#2017-10-2014:54thhellerguess they replaced that with npx#2017-10-2014:54mhuebertwith the above config i can run npm run deps/watch/release#2017-10-2014:55mhuebertso npm run looks at "scripts" but not other stuff#2017-10-2014:56mhuebertbit of formatting feedback, the website URL when running watch and so is a bit hidden in the stream, and the other urls (server/socket-repl/nrepl) more obvious. for a tutorial context it might be hard to explain where a user should look#2017-10-2014:58thhelleryeah all that could be better#2017-10-2014:58thhellerthe real idea is to have a UI for everything#2017-10-2014:58thhellerso you just open the UI and see all the important stuff#2017-10-2014:58thhellerjust didn’t build that yet#2017-10-2015:02JonI always use
yarn watch
#2017-10-2015:04thhellerthe whole package.json scripts situation seems rather developer-unfriendly#2017-10-2015:04thhelleryarn watch with "watch": "npx shadow-cljs watch browser;" then uses npx right? so only fake yarn 😛#2017-10-2015:05Jonno need npx in yarn. just watch: shadow-cljs watch browser#2017-10-2015:06Jondidn't know there is an npx XD#2017-10-2015:07thheller@mhuebert right, I do think that "watch": "shadow-cljs watch browser;" will use the correct thing as well. shouldn’t need npx#2017-10-2015:07mhueberteven if shadow-cljs is not installed globally?#2017-10-2015:07thhelleryarn is smart enough to use the local install, npm should too#2017-10-2015:08Jonas long as shadow-cljs in node_modules/.bin/#2017-10-2015:09mhuebertah that is simpler#2017-10-2015:11mhuebertworks#2017-10-2015:14thhellerFigwheel Says: Your code didn't compile.#2017-10-2015:14thhellerthats neat I should do that#2017-10-2015:14mhueberthaving errors pop up into the browser can be nice#2017-10-2015:15mhuebertbut would need to think about what to do with warnings that the user is not in control of#2017-10-2015:16thheller
Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react"
(symbol? dep)
#2017-10-2015:16thhellerI thought they support strings#2017-10-2015:17mhuebertthey do, that error comes up sometimes. i think you can get around it by deleting the out folder#2017-10-2015:17mhuebertwhatever teh out folder is for that build#2017-10-2015:18mhueberta shadow release is ~25sec vs 38.5sec for lein cljsbuild once prod but not really apples to apples because cljsbuild is running the JS through closure#2017-10-2015:19mhuebertalso why the closure build is 229 vs 260 kb#2017-10-2015:19mhuebert:js-provider :closure doesn’t work for me with shadow#2017-10-2015:20mhuebertnot that it’s high priority, i think closure still fails on many js libs#2017-10-2015:20thhelleryeah I didn’t touch the closure support in a long time#2017-10-2015:22mhuebertmaybe not worth touching until it is more reliable itself#2017-10-2015:22thheller 229 vs 260 kb is worth fixing it#2017-10-2015:22thhellerif it works for that build there is no reason not to use it#2017-10-2015:22mhueberttrue#2017-10-2015:23thhellerwhat am I doing wrong?#2017-10-2015:23thheller
[
#2017-10-2015:23thhellerit just doesn’t do anything?#2017-10-2015:24thhellerwait I seriously have to delete the files?#2017-10-2015:24mhuebertyou have to delete the previous base.js#2017-10-2015:24mhuebertit’s super awful#2017-10-2015:25mhueberti wasn’t sure if that happened just on my machine but apparently not 🙂#2017-10-2015:30thhellerthe cljsbuild prod build errors out#2017-10-2015:35thhellerEventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, Sh`.`#2017-10-2015:35thhellerI think the react externs are missing, which are required for react#2017-10-2015:44thhellercan’t figure it out .. even adding the externs doesnt fix it#2017-10-2015:45thhellerso the 229k is not quite accurate 😉#2017-10-2015:46thhellerat least the shadow-cljs release build works as expected. I happily trade 6kb gzip’d for that 🙂#2017-10-2016:20thhellerhehe .. yeah the closure support has long ways to go … I fixed the shadow-cljs side but it doesn’t work at all#2017-10-2016:20thhellercompiles fine but the the events don’t work (in the html)#2017-10-2016:22thhellerclosure compiled base.js (387838 bytes) vs shadow JS base.js (259697 bytes)#2017-10-2016:28thheller223K when compiled properly with closure and externs .. but doesn’t work at runtime#2017-10-2016:51thheller@mhuebert btw npm-deps is now automatic, no need to call it anymore#2017-10-2018:02mhuebert@thheller great, that simplifies instructions#2017-10-2022:24mhuebertthis is weird, i have never seen that inject-plugins error#2017-10-2022:24mhuebertbut now I get the same thing#2017-10-2022:27mhuebertalso with cljsbuild I get a JSC_MISSING_PROVIDE_ERROR unless I delete the out folder in-between builds#2017-10-2022:28mhuebertvery possible i have outdated externs#2017-10-2022:28mhuebertwith pseudo-names, EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, $SimpleEventPlugin$`.`#2017-10-2022:29mhueberti think that’s it. externs are from React 15. nothing newer that i can find anywhere#2017-10-2106:45thheller@mhuebert for react v16 and closure you need these externs I think#2017-10-2106:45thheller
var ResponderEventPlugin;
var SimpleEventPlugin;
var TapEventPlugin;
var EnterLeaveEventPlugin;
var ChangeEventPlugin;
var SelectEventPlugin;
var BeforeInputEventPlugin;
#2017-10-2106:45thhellerbut even when it compiles fine it doesn’t quite work, no event handlers ever trigger#2017-10-2106:46thhellerCLJSJS has the latest externs#2017-10-2107:32mhuebertoh, I see. The top of the file says React 15.xx but it has been updated.#2017-10-2107:42thhellerAFAICT only the plugins need externs for everything to compile properly#2017-10-2107:42thhellerwhat is needed to work I don’t know#2017-10-2107:42thhellersomeone in #cljs-dev probably knows#2017-10-2107:44mhuebertI updated the externs in re-view to the latest from CLJSJS and now it compiles and runs for me. pushed the updated template.#2017-10-2107:47thhelleruh nice#2017-10-2107:47mhuebertmust have been some symbols related to event handling that were munged but did not cause errors..#2017-10-2107:47thhelleryeah I just gave up but guess someone figured it out#2017-10-2107:48thhellerI tried the externs before but must have missed something#2017-10-2107:48thhellergood i can use this as a basis now#2017-10-2107:49mhuebertstill getting the externs error on shadow’s closure build
#2017-10-2107:51mhuebertthe working cljsbuild :advanced base.js is 229,603 bytes#2017-10-2107:51thhelleryeah I’ll fix the closure build#2017-10-2107:52mhuebertwould seem it is not picking up the externs#2017-10-2108:01thhellerstill trying to fix source maps for :advanced when JS deps are used. can’t quite figure it out.#2017-10-2109:06mhuebertdoes shadow support the :preloads compiler option?#2017-10-2109:07mhuebertlooks like yes, seeing examples.#2017-10-2109:07mhuebertah, but it’s in :devtools not :compiler-options#2017-10-2109:08thhelleryeah since its a dev only thing#2017-10-2109:19mhuebertmakes a lot of sense to have it in :devtools#2017-10-2109:19mhueberthave you ever tried to require “d3”?#2017-10-2109:20thhellerI think so yes#2017-10-2109:20thhellerdoesn’t work with :closure IIRC#2017-10-2109:23thhellerwhat the heck?#2017-10-2109:23thhellerns or shadow_re_frame/provide_js_deps.cljs?#2017-10-2109:26thhellerok got the error as well with just "d3"#2017-10-2109:28thhellerwhoops#2017-10-2109:29mhueberthttps://github.com/mhuebert/shadow-re-frame#2017-10-2109:29thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2a59424b4e455d07494640596a18041a041918"}, :content ("[email protected]")}#2017-10-2109:30mhuebertthis is the repo. shadow-re-frame/provide-js-deps + the :resolve options in shadow-cljs.edn are a workaround to use libs that require cljsjs stuff#2017-10-2109:30mhuebert🙂#2017-10-2109:30thhelleruhm what?#2017-10-2109:31mhuebertwas getting cljsjs... not provided errors#2017-10-2109:31thhellerright#2017-10-2109:31thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-10-2109:31thhellersee BREAKING CHANGE: Removing :foreign-libs support#2017-10-2109:32mhuebertbut i don’t have control over those libraries. so I require the same deps from node_modules in the provide-js-deps namespace and set the global var that the lib expects#2017-10-2109:32thhellerhmm right#2017-10-2109:33thhellerbut you are really abusing the system here, thats not a good idea#2017-10-2109:33thhelleralso use (js/goog.exportSymbol "React" react) not the set!#2017-10-2109:34thhellerbut the dummy cljsjs/react.cljs file really is a better option than resolve#2017-10-2109:35thhellerbut putting that into a library might not be a good idea 😞#2017-10-2109:35mhuebertI don’t think there is any good option because non-shadow build tools have no way to include libs that are not Closure compatible except via foreign libs?#2017-10-2109:35mhuebertin that case I can’t submit a PR to these libs#2017-10-2109:35thhellerwell the same way reagent fixed it in the alpha version#2017-10-2109:36mhuebertbut React is closure compatible#2017-10-2109:36mhuebertno idea if d3 is#2017-10-2109:36thhelleruhm yeah that part is not clear to me either#2017-10-2109:37thhellerbut react also works via :foreign-libs not just closure#2017-10-2109:37thheller
{:foreign-libs
 [{:file "cljsjs/react/development/react.inc.js",
   :provides ["react" "cljsjs.react"],
   :file-min "cljsjs/react/production/react.min.inc.js",
   :global-exports {react React}}],
 :externs ["cljsjs/react/common/react.ext.js"]}
#2017-10-2109:38thhellerthis is the cljsjs/react deps.cljs#2017-10-2109:38thhellerI think that it will use the :foreign-lib if node_modules/react doesn’t exist#2017-10-2109:39thhellerI honestly don’t know … I couldn’t figure it out from reading the CLJS code#2017-10-2109:40thhellerbut it is possible to compile without closure while still using (:require [react])#2017-10-2109:40mhuebertright. so if d3 would add :global-exports to cljsjs then maybe it works. i wonder if, given the “react” in :provides, the react in :global-exports is redundant?#2017-10-2109:42thhellerI have no idea really, it seemed confusing to me which is why I did the :resolve thing#2017-10-2109:42thhellergranted it solves a different problem#2017-10-2109:43thhellerd3 is also one of those packages that is actually split into many packages#2017-10-2109:47thhellerI’m open to ideas … I might just re-enable foreign-libs as a last resort but I really don’t want to 😞#2017-10-2109:47thhellerthe potential for conflicts is just too high#2017-10-2109:48mhuebertso this hack doesn’t work, in the end, because the :resolve stuff mapping cljsjs.* to global vars runs before the global var is defined#2017-10-2109:48mhuebertyeah it is not a pretty sight.#2017-10-2109:48thheller
(ns cljsjs.d3
  (:require ["d3" :as d3]))

(js/goog.exportSymbol "d3" d3)
#2017-10-2109:49thhellerI might just create a bunch of those and create a shadow-cljs-foreign-libs package or so#2017-10-2109:49mhuebertam getting this:
shadow.js.provide("module$cljsjs_d3", function(global,require,module,exports) {
module.exports=(d3);
});
#2017-10-2109:50mhueberterrors out because d3 has not been defined#2017-10-2119:02thheller@mhuebert you can get rid of a bunch of closure warnings by setting :compiler-options {:closure-warnings {:global-this :off}}#2017-10-2119:02thhellergot the :closure compile working again#2017-10-2119:09mhueberti haven’t looked at blessed before, this looks interesting#2017-10-2119:27thhellerok closure works fine again … until you want custom :resolve … not sure how I bring that into Closure yet#2017-10-2119:33mhueberthmm.#2017-10-2119:50thhellerThe required namespace "cljsjs.react.dom.server" is not available, it was required by "reagent/dom/server.cljs".#2017-10-2119:52thhellerwas trying to test with shadow-re-frame#2017-10-2119:56thhellertested with lein new re-view instead, works after bumping re-view to 0.4.6#2017-10-2119:57thhellerbase.js (233722 bytes) closure vs shadow base.js (259810 bytes)#2017-10-2119:58thhellernot a huge difference after gzip but when it works closure is definitely better#2017-10-2120:05mhuebertUhg ok I'll fix in a bit#2017-10-2120:10mhuebertupdated template to 0.4.6 (keep forgetting to update both project.clj and shadow-cljs.edn)#2017-10-2120:10mhuebertI could parameterize the version#2017-10-2120:10mhuebertsince the template stuff already makes that easy#2017-10-2120:16mhuebertlatest shadow-re-frame should work#2017-10-2120:16mhueberti was switching to some older versions of reagent while trying to get re-frame-trace to work. had to patch it to work with react 16.#2017-10-2120:20mhuebertshadow-re-frame is compiling for me with closure but i’ve got externs problems again#2017-10-2120:20mhuebertno externs problems with :release using shadow as js provider, but with closure, EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, mk`.` again#2017-10-2121:42mhuebertuser-options at command line: https://github.com/SBoudrias/Inquirer.js (less complex than a full-blown view layer -- this is what firebase-tools uses)#2017-10-2208:56mhuebert@thheller hah good timing, someone in #re-frame today was trying to get re-frame-trace to work with shadow-cljs. I posted an explanation of what we figured out yesterday: https://clojurians.slack.com/archives/C073DKH9P/p1508662534000031 feel free to correct/suggest alternatives#2017-10-2212:20mhuebert
:failed-to-compare "github:braintripping/Keypress#4477249" "github:braintripping/Keypress#4477249" #error {
 :cause "TypeError: Invalid SemVer Range: github:braintripping/Keypress#4477249"
#2017-10-2214:19thhellerhehe oops#2017-10-2214:40thheller@mhuebert one thing I noticed in the re-frame thing :closure-defines {re-frame.trace.trace-enabled? true}#2017-10-2214:40thhellerbut day8.re-frame.trace.preload#2017-10-2214:40thhelleris the define missing a day8.?#2017-10-2214:42thhellerhmm looking at the code no such goog-define exists?#2017-10-2214:42thhellerah nvm its not part of re-frame-trace#2017-10-2217:37richiardiandrea@thheller i don't thing you've seen it, but in lumo we were thinking about deploying Cljs to npm and how to put info in package.json. I think we are on the brink of needing it anyways 😄 #2017-10-2217:43richiardiandreahttps://github.com/anmonteiro/lumo/issues/130#2017-10-2218:47thheller@richiardiandrea not sure I understand the intent here. why would we “need” it?#2017-10-2218:48thhellerat this point I see more harm than benefit in that#2017-10-2218:56richiardiandreaHow do you load clj in shadow-cljs now? From maven?#2017-10-2219:51thhelleryes#2017-10-2219:55richiardiandreaSo that would allow to consume them from npm#2017-10-2219:56richiardiandreaSo companies don't have to have two mirrors, one for maven, one for npm#2017-10-2219:56richiardiandreaIf they work with ClojureScript#2017-10-2220:05thhellerI don’t see that changing anytime soon#2017-10-2220:05thhellernot really sure that it should either#2017-10-2220:07thhellerproblem with introducing a new package manager is that you will end up having packages that are only available in one#2017-10-2220:08thhellerso someone using only lumo will publish their package to npm naturally#2017-10-2220:09thhellerand then someone from the JVM side can’t consume it#2017-10-2220:10thhellerwe are already in a weird situation overall with JS packages#2017-10-2220:10thhellercljsjs vs npm and so on#2017-10-2220:12thhellerhaving CLJS packages declaring :npm-deps is already complicated, the reverse would make it even more complicated#2017-10-2220:20richiardiandreaGotcha, yeah, it will go the way you described anyways, because it is not feasible to do both, so Clojure package maintainers will eventually choose. Our tooling did not make the choice that other *Script languages have taken (use npm) so we carry this burden with us now. #2017-10-2220:23thhellerI’m not sure which problem you are trying to solve still#2017-10-2220:24thhellerpublish to npm is not a problem per se, as long as you keep JVM semantics (ie. classpath and namespaces)#2017-10-2220:24thhellerif you just want to allow require("some-cljs-thing/foo/bar") where that resolves to bar.cljs thats a problem#2017-10-2220:27thhelleranyways .. its good to explore alternatives … so just do it and see where it goes#2017-10-2220:33thhellerwould help to have a formal description of the goal and decisions made#2017-10-2302:43JonBeing a JavaScript developer I see this issue in a different angle. I don't use Java. So using Clojars is like "using two package managers", since I've been using npm for so long.#2017-10-2302:44JonLumo is moving away from JVM. And it sounds more natural to use npm as the package manager, just like all other compiled-to-js languages, despite that npm is far from perfect.#2017-10-2307:15thhellerseriously though: if there was a shadow-cljs publish command. would you care where it ended up?#2017-10-2307:16thheller“it is easier to deploy to npm” is not a valid argument to use it since 99% of the time you just want to USE the dependency not deploy it#2017-10-2314:54JonI should say it is "easier to learn to deploy to npm"#2017-10-2314:55Jonanother purpose of use phrasing npm is because I'm so familiar with npm, I can browse node_modules/ and manage it with yarn. I can hardly do anything when I'm not familiar with jar.#2017-10-2314:55Joneven though it's also able to extra jars from somewhere...#2017-10-2314:56Jonand I have many friends familiar with npm, here in China..#2017-10-2309:55mhuebert@thheller when a shadow server connects to the browser, is there a way for the browser’s code to ask the server questions like “what build am i” or issue commands like “build release”? (ie. building blocks for a UI)#2017-10-2309:56thhellershadow.cljs.devtools.client.env might already have everything you need?#2017-10-2309:57mhuebertok i’ll check there, wasnt sure where to look#2017-10-2309:57thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/env.cljs#2017-10-2309:57thhellershadow.cljs.devtools.client.env/build-id#2017-10-2309:57thhellerissuing commands is not yet possible#2017-10-2309:58thhellerbut I’m happy to create any kind of endpoint you need 🙂#2017-10-2309:58thhellercan’t really issue commands from the build itself#2017-10-2309:59mhuebertso repl-call is used to evaluate expressions that you are sending to the browser#2017-10-2309:59thhellerwell its for the REPL#2017-10-2310:00thhellerbut none of that should be used if you want to build an actual UI, ie. the UI should not become part of the build#2017-10-2310:00thhellerit should be standalone IMHO#2017-10-2310:00mhueberti am imagining the UI would be a :preload? like re-frame-trace#2017-10-2310:01thhellerthere is some prior art for the UI I have in mind#2017-10-2310:01thhellerhttps://github.com/oakmac/cuttle#2017-10-2310:02mhuebertsaw that the other week, it looked nice#2017-10-2310:02thhellerhttps://www.youtube.com/watch?v=hHruZtz62no#2017-10-2314:58Jonno able to access Youtube from mainland China these days. sigh...#2017-10-2310:02mhueberta benefit of something injected into a build is that you could show warnings/build status directly there, in the window that you’re looking at while developing#2017-10-2310:02mhuebertà la figwheel#2017-10-2310:02thhellera basic HUD already exists#2017-10-2310:02thhellerthat is a preload yes#2017-10-2310:03thhellerbut the UI that controls shadow-cljs should not be part of the build itself#2017-10-2310:03mhueberti see#2017-10-2310:03mhueberti don’t think I’ve noticed the hud#2017-10-2310:04thhellerits not enabled by default#2017-10-2310:04thheller:preloads [shadow.cljs.devtools.client.hud]#2017-10-2310:04thhellerits too ugly#2017-10-2310:04mhuebert🙂#2017-10-2310:04thhellermore or less just a test of how it could be done#2017-10-2310:04thhellerpretty sure it doesn’t work anymore#2017-10-2310:05mhuebertok#2017-10-2310:05thhellerlet me try and fix it#2017-10-2310:05thhellernot a good demo if it doesn’t work 😉#2017-10-2310:07thhellerah no it actually still works#2017-10-2310:07thhellerstill ugly but it works 😉#2017-10-2310:09thhellerah open in editor link is missing a name#2017-10-2310:10mhueberttransit really needs to fix that uri? issue#2017-10-2310:10mhuebertor did they…#2017-10-2310:11mhuebertthere is a new release! 🙂#2017-10-2310:11thhellerthey did, I bumped it in shadow-cljs already#2017-10-2310:11mhuebertah i had the old version in maria’s deps#2017-10-2310:14thhellerI don’t really like the HUD as a concept#2017-10-2310:14thhellerI want to see errors in my editor ASAP#2017-10-2310:14thhellerhaving to look at the browser for that is meh#2017-10-2310:15thhellerlike that … one day …#2017-10-2310:17thhellerthis could definitely become nicer looking#2017-10-2310:39mhueberterrors in the editor… is there a standard way to communicate stuff like that to an editor? (ie. something that would work with Cursive and emacs?)#2017-10-2310:40thhellershort answer: no.#2017-10-2310:40thhellerI spent quite a bit of time in that rabbit hole#2017-10-2310:40thhellerhttps://github.com/thheller/shadow-cljs/issues/2#2017-10-2310:40thhellerhttp://langserver.org/#2017-10-2310:41thhellerthats an attempt at some kind of “standard” for this#2017-10-2310:41thhellerquite a few editors support it#2017-10-2310:41thhellercursive or rather intellij doesn’t#2017-10-2310:46thhellerhttps://youtrack.jetbrains.com/issue/IDEABKL-7409#2017-10-2310:46thheller> Language server support cannot be combined with existing IDE tooling; it’s an either/or proposition. If IntelliJ used the language server for Java, it would lose 95% of its feature set for Java development.#2017-10-2310:46thhellerI don’t think its coming to IDEA anytime soon#2017-10-2311:12mhuebertdoes appear to be a rabbit hole 😞#2017-10-2311:12mhuebertwell, when developing for the browser, warnings/errors there will show up at essentially the same speed as if it was connected to the editor, if you have a side-by-side view on your screen#2017-10-2311:15thhellermy setup usually looks like this#2017-10-2311:17thheller“almost” in my editor#2017-10-2311:19thhellerneed to bug colin so I can send special nrepl messages the UI understands … but he is busy 🙂#2017-10-2313:02mhuebertLast night I was surprised to find that my parsing lib runs ~8x faster with :simple optimisations than in dev#2017-10-2313:03mhuebertAnything to do with perf tweaking/debugging might be another user case for watching release builds#2017-10-2313:03thhellerhmm#2017-10-2313:04thhellerthe issue with watch for release is that running it on every file change is too slow#2017-10-2313:04thhellerin dev thats non an issue since it usually takes less than a second#2017-10-2313:05thhellerbut say you are fixing a release bug and touch 3 files to “fix” it#2017-10-2313:05thhellerif those 3 files are not saved at once the watch may trigger early#2017-10-2313:06thhellerbut I can implement it regardless if you want. its not hard to do.#2017-10-2313:06thhellermy workflow typically consists of poking at it in the REPL#2017-10-2313:06thhellerthen when I’m done trigger release manually#2017-10-2313:07thhellerrelease is pretty expensive compared to watch#2017-10-2313:08thhellerin cursive you could create a custom REPL command to trigger a release build#2017-10-2313:30mhuebertI should into these custom REPL commands#2017-10-2314:16mhuebert*look into#2017-10-2314:16mhuebertCan't edit on a phone. Sigh.#2017-10-2314:17mhuebertI actually can't find what you mean by custom REPL commands#2017-10-2314:17thhellertools -> REPL -> edit REPL commands#2017-10-2314:18thhellerallows you to specify a string of text to send to the REPL#2017-10-2314:18thhellerand bind it to a key#2017-10-2314:18thhellerie bind (shadow.cljs.devtools.api/release :browser) to a key#2017-10-2314:22thhelleroh the tools -> REPL menu might only show up when connected to a REPL#2017-10-2314:22thhellerthere was something weird about that#2017-10-2314:26mhuebertI ignore probably 80% or more of IntelliJ.#2017-10-2314:28mhuebertI just discovered Preferences > Appearance & Behavior > Menus and Toolbars#2017-10-2314:28mhuebertLife will never be the same#2017-10-2314:47thhellerhehe#2017-10-2315:53mhuebertwould it make sense to apply :simple optimizations to bootstrap js?#2017-10-2316:05mhuebertthis is a great workflow, REPL command with shortcut#2017-10-2316:05mhuebertall the ^boolean type hints seem to have zero effect, in any kind of optimization mode#2017-10-2316:11thhelleryou can tell if they have an effect by the generated code#2017-10-2316:11thhellerhmm wonder if I broke that when I “fixed” the incorrect ^js tag behaviour?#2017-10-2316:13thhellernope not broken, you had me worried there 🙂#2017-10-2316:14thhellerall the ^boolean tag does is remove the cljs.core.truth_ call#2017-10-2316:14thhellerwithout you get if(cljs.core.truth_(demo.browser.thing)){...#2017-10-2316:15thhellerwith you get if(demo.browser.thing){ its only really needed in cases where closure is supposed to kill dead code#2017-10-2316:16thhellerand super critical loops maybe#2017-10-2316:17mhuebertis there a particular lib you use for cljs perf testing?#2017-10-2316:18mhuebertfor my parse lib, using sequential keyword-identical? comparisons vs. (contains? #{…} the-kw) results in a 2x overall speedup#2017-10-2316:22thhellerI use the chrome devtools occasionally to profile#2017-10-2316:22thheller(contains? #{…} the-kw)#2017-10-2316:22thhellerdid you try (contains? the-set-but-from-a-def the-kw)?#2017-10-2316:26mhuebertjust realized i was mistakenly using keyword-identical? with strings. still had correct result, but slightly faster i think to use identical?#2017-10-2316:26mhueberti did not#2017-10-2316:27thhellerbootstrap js and :simple no, then you’d lose the ability to load individuals namespaces#2017-10-2316:27mhuebertbut, this is in a really tight loop and i am not sure one can go faster than successive identical comparisons#2017-10-2316:27thhellercontains is a hash lookup#2017-10-2316:27thhellerjust re-creating the set on every call is not good#2017-10-2316:28mhuebertsomehow i imagined that a literal set wouldn’t be re-created#2017-10-2316:28thhelleryeah the compiler is not that smart#2017-10-2316:29mhuebertre: bootstrap :simple - would not have to pile all the files together?#2017-10-2316:29mhueberti am just surprised at this 10x speed up using :simple#2017-10-2316:29thhellerhmm true#2017-10-2316:30thheller10x might be from constants#2017-10-2316:30thhellerin :none constants are not optimized so every keyword or symbol is allocated#2017-10-2316:30thhellerin optimized code its allocated once and shared#2017-10-2316:31thhellerif you allocate too much you force a GC#2017-10-2316:31thhellertight loop with keywords might do that#2017-10-2316:32thheller:simple but still separate files gave me an idea#2017-10-2316:32thhellerthat might be worth doing yes#2017-10-2316:34thhellerSSL with self-signed certificates is so annoyingly complicated#2017-10-2317:01mhuebertwell, this is interesting. when the parsing lib and sample text are loaded by themselves, the :simple optimization mode makes a much smaller difference, maybe 20%#2017-10-2317:01mhuebertbut when the exact same test is loaded as part of Maria’s live build, then it slows down 10x when not in :simple#2017-10-2317:14thhellerhmm#2017-10-2317:14thheller:static-fns maybe?#2017-10-2317:16thhellerhmm not sure I understand. as part of the live build means loaded by the self-host?#2017-10-2317:17mhueberti don’t fully yet understand either. so the live build is :optimizations :simple, nothing fancy. It does load the bootstrap build but I am not using the compiler to perform this test#2017-10-2317:17mhueberti’m trying to reproduce and can’t yet. i thought maybe it had something to do with loading it in an iframe, but that doesn’t seem to be the case#2017-10-2317:19thhellerI do think iframes get a lower priority but not sure#2017-10-2317:20mhuebertmaybe it has something to do with memory usage#2017-10-2317:21thhellerhow do you guys feel about the shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.35 line?#2017-10-2317:21thhellershould I keep it?#2017-10-2317:22thhellertrying to trim some unnecessary output from commands#2017-10-2317:23mhueberti like seeing the version number#2017-10-2317:23mhuebertunsure if path is necessary#2017-10-2317:23thheller
echo :foo | shadow-cljs clj-eval --stdin
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.35
:foo
#2017-10-2317:24thhellercat script.clj | shadow-cljs clj-eval --stdin#2017-10-2317:24thhellernode packages/shadow-cljs/cli/runner.js clj-eval "(shadow/release :thing) (something-after-release)"#2017-10-2317:24thhellermight be useful#2017-10-2317:25thhelleroops#2017-10-2317:25thhellershadow-cljs clj-eval "(shadow/release :thing) (something-after-release)"#2017-10-2317:25thhellerlike this of course#2017-10-2317:28thhellerwanted something that lets me string together a few things … like calling rsync after release 😉#2017-10-2318:52thheller:simple for bootstrap is not so simple unfortunately#2017-10-2319:02mhueberthmm, how does it behave?#2017-10-2319:05thhellerthe closure compiler doesn’t like compiling like that 😛#2017-10-2319:06thhellerthought I can abuse the :npm-module stuff I have already but that doesn’t quite work#2017-10-2319:08thheller
------ WARNING #1 --------------------------------------------------------------
 File: cljs.core$macros.js:2

 namespace "clojure.walk" is required in module cljs.compiler.js but provided in module clojure.walk.js. Is module cljs.compiler.js missing a dependency on module clojure.walk.js?
--------------------------------------------------------------------------------
#2017-10-2319:08thheller
Closure compilation failed with 6 errors
--- cljs.js.js:2
namespace "cljs.core$macros" cannot be provided twice
#2017-10-2319:08thhellernot really sure what is happening … a bunch of weird stuff#2017-10-2319:09mhueberthmmmmm so, it appears that :async-require is what’s behind this weird slowdown#2017-10-2319:10thhellerreally? how does that happen?#2017-10-2319:11mhuebertabsolutely no idea! 🙂. but that’s a console log after reloading, only difference commenting out that part in devtools#2017-10-2319:11thhelleroh its loading the dead js deps#2017-10-2319:12thhellerthats not supposed to happen 🙂#2017-10-2319:12thhellercan you try to js/setTimeout the start of the test?#2017-10-2319:13thhelleror how do you trigger the test? just on load I assume?#2017-10-2319:13thhellercan you try in the :after-load fn?#2017-10-2319:14thhellerso its done after the code loading process finishes?#2017-10-2319:14mhuebertmy test code is:
(dotimes [n 5]
  (js/setTimeout
    #(time (tree/ast "..."))
    n))
#2017-10-2319:14thhellerah ok#2017-10-2319:16thhellerand if you remove the :async-require its normal?#2017-10-2319:18mhuebertyup#2017-10-2319:19thhellerhmm the async require loads code via xhr and then js/evals it#2017-10-2319:20thhellermaybe that doesn’t get optimized be the JIT?#2017-10-2319:20mhuebertappears so: https://github.com/turbolinks/turbolinks-classic/issues/135#2017-10-2319:20thhellerdid you try with compile and not watch?#2017-10-2319:22thhellerhmm 2012#2017-10-2319:22thhellerhttps://jsperf.com/tag-vs-eval-fn-construction#chart=bar#2017-10-2319:22thhelleryep still relevant#2017-10-2319:22thhellerbut I can probably do the script injection#2017-10-2319:24mhuebertalso slow#2017-10-2319:24mhuebert(compile)#2017-10-2319:26mhuebertwow, what weirdness#2017-10-2319:28thhellerindeed#2017-10-2319:34thhellerthis is so weird, append a script node and remove it directly after#2017-10-2319:34thhellercode still gets eval’d properly 🙂#2017-10-2319:34thhelleroh hmm#2017-10-2319:35thhelleryou are in an iframe right?#2017-10-2319:35thhellerI think eval(code) is window.eval(code)#2017-10-2319:36thhellermaybe its weird because of the iframe#2017-10-2319:38thhellercreate a shadow/build/async-closure-import.js in your project source path#2017-10-2319:38thhellerhttps://github.com/thheller/shadow-cljs/blob/9a6da82179dd789a7dc1d680139e530486cd27c0/src/main/shadow/build/async-closure-import.js#2017-10-2319:39mhuebertso this little trick they do:
var createScriptFunction = function(args, body) {
  var prevDash = window._,
      script = document.createElement('script'),
      sibling = document.scripts[0];

  script.text = 'var _ = function(' + args + ') {' + body + '\n}';
  sibling.parentNode.insertBefore(script, sibling).parentNode.removeChild(script);

  var result = window._;
  window._ = prevDash;
  return result;
};
maybe i should do this with all of the eval’d code from the bootstrapped compiler?
#2017-10-2319:39thhellerdon’t want to do a release if it doesn work
#2017-10-2319:39mhuebertok just a sec#2017-10-2319:39thheller
function scriptEval(code) {
    var node = document.createElement("script");
    node.appendChild(document.createTextNode(code));
    document.body.append(node);
    document.body.removeChild(node);
  }
#2017-10-2319:39thhellerinstead of straight eval#2017-10-2319:39thhellerpage loads just fine after#2017-10-2319:40thhellerdon’t have a benchmark handy I could use to test#2017-10-2319:41mhuebertcurrently building#2017-10-2319:44mhuebertseems to be somewehre in the middle, ~1800ms#2017-10-2319:44mhuebertbut wait#2017-10-2319:44mhueberti am not sure if things are compiling normally#2017-10-2319:55thhellermight be best to stay away from async-require if that fixes it#2017-10-2320:03thhellerdid quick benchmark myself. 6.5sec without async require, 6.5 sec with async require + script, still waiting for eval 😛#2017-10-2320:03thhellerstill waiting …#2017-10-2320:04thhellermight be a big boost for bootstrap as well if eval is really that slow#2017-10-2320:04thhellerstill waiting … geez#2017-10-2320:04mhuebertis this code supposed to be running on the shadow-cljs server?#2017-10-2320:05thhellerhmm?#2017-10-2320:05mhueberti mean shadow-cljs server — does that need to be restarted after adding this js code#2017-10-2320:06mhueberti have just got into a weird state where the same benchmark code is now running at the midpoint of slow and fast and nothing i do seems to change it.#2017-10-2320:06mhuebertlet me dig myself out of this hole 🙂#2017-10-2320:06thhellerno you just put the file into your classpath#2017-10-2320:06thhellerand trigger a compile#2017-10-2320:07thhellerit will basically just be prepended to your build .js file#2017-10-2320:08thhellerthe difference is crazy .. I had to kill the tab#2017-10-2320:08thhellerit just didn’t finish#2017-10-2320:08thheller140ms with scriptEval#2017-10-2320:08thheller11514ms with eval#2017-10-2320:09thhellerso crazy 😛#2017-10-2320:09mhuebertyeah#2017-10-2320:09mhuebertmadness#2017-10-2320:11thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a7d4cfc6c3c8d08ac4cbcdd4e7958997899491"}, :content ("[email protected]")}#2017-10-2320:15mhuebertis this Invalid SemVer Range something simple to fix?#2017-10-2320:16thhelleruh right .. I forgot about that#2017-10-2320:16thhellerwell I can fallback to just string compare in that case#2017-10-2320:25mhuebertoops typed description in image title#2017-10-2320:28thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "20534841444f570d434c4a5360120e100e1317"}, :content ("[email protected]")}#2017-10-2320:28thhelleralso has the faster script eval for things loaded by the devtools#2017-10-2320:28thhellerand the bootstrap/load#2017-10-2320:29thhellerhmm I should have done the benchmark in firefox as well#2017-10-2320:29thhelleryou never know 🙂#2017-10-2320:29thhelleralso fixed the semver thing#2017-10-2320:31thhellerfirefox doesn’t care at all#2017-10-2320:31thhellereval is the same speed#2017-10-2320:32thhellernah not quite the same speed#2017-10-2320:32thheller250ms vs 400ms#2017-10-2320:33thhellervs chrome 11sec 😛#2017-10-2320:35thhellerhow is this not a widely known thing?#2017-10-2321:09mhueberti don’t know but it’s nuts#2017-10-2321:15mhuebertand i don’t understand the logic. they don’t prevent dynamically supplied code from being optimized, they just make it awkward?#2017-10-2321:15mhuebertmaybe just a low priority thing.#2017-10-2321:15mhuebertnot really intentional.#2017-10-2321:15thhellerhttps://github.com/vhf/v8-bailout-reasons#2017-10-2321:15thhellereval is on that list without comment#2017-10-2321:16thhellerno idea what it means#2017-10-2321:17mhuebertwow, didn’t realize that about try-catch#2017-10-2321:17mhuebert
Don't put try/catch inside computationally intensive functions.
You could try { test() } catch
#2017-10-2321:20mhuebertoh, this page is more recent: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers Functions that contain a try-catch statement (Optimized in V8 commit 9aac80f / V8 5.3 / node 7.x)#2017-10-2321:20mhuebertsays that functions that call eval() are ‘likely never optimizable’#2017-10-2321:21thhelleryeah that I knew#2017-10-2321:21thhellerbut the eval’d code should still be optimizable#2017-10-2321:21mhuebertbut that the eval code itself is also not optimizable, is a separate thing#2017-10-2321:21mhuebertright#2017-10-2321:22thhellerits super weird#2017-10-2321:22thhelleralso very hard to google properly#2017-10-2321:22thhellertoo many “eval is evil” results#2017-10-2409:06thhellerhmm just found a rather big bug related to how npm requires are resolved#2017-10-2409:07thhellershould fix a whole bunch of packages#2017-10-2409:22thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "196a71787d766e347a75736a592b3729372a21"}, :content ("[email protected]")}#2017-10-2410:57mhuebertwhat were some that were affected?#2017-10-2411:01mhueberthmm, it apperas that shadow-cljs servers remain running when terminal windows are closed? not sure which java processes they are, they also don’t seem to respond to requests#2017-10-2411:02thhellerhmm is the node process controlling them still alive?#2017-10-2411:03mhuebertI don’t see any node processes#2017-10-2411:05mhuebertalso when i try to watch, it connects to server and then seems to hang:
mattpro:shadow-re-frame MattPro$ npx shadow-cljs watch browser
shadow-cljs - config: /Users/MattPro/Documents/sites2017/shadow-re-frame/shadow-cljs.edn version: 2.0.37
shadow-cljs - connected to server
#2017-10-2411:06thhellerthat might be because the watch is still running#2017-10-2411:06thhellershould get output once something happens#2017-10-2411:06mhuebertah ok#2017-10-2411:06thhellerah hmm#2017-10-2411:06thhelleryou are still using lein?#2017-10-2411:07mhuebertnot for this project#2017-10-2411:08thhellerthere is one bug I’m trying to track down#2017-10-2411:08thhelleris the java process consuming CPU? like 100% of one core?#2017-10-2411:10mhuebertno, all quiet#2017-10-2411:11mhuebertediting a file doesn’t appear to trigger anything#2017-10-2411:13thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b7c4dfd6d3d8c09ad4dbddc4f785998799848e"}, :content ("[email protected]")} fixes another issue related to npm requires with browser overrides#2017-10-2411:13thhelleralso fixed maybe one potential issue related to the java process staying alive#2017-10-2411:13mhueberti will just force quit the rest of these processes. i started doing that and now i’m in a state where nothing works at all#2017-10-2411:13mhuebertok#2017-10-2411:14thhelleris this reproducible by just closing the terminal?#2017-10-2411:15mhuebertnot sure, i am still in a broken state, force quitting seems to be not the nicest 🙂#2017-10-2411:15mhuebert
mattpro:shadow-re-frame MattPro$ npx shadow-cljs watch browser
shadow-cljs - config: /Users/MattPro/Documents/sites2017/shadow-re-frame/shadow-cljs.edn version: 2.0.39
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:58762
    at Object.exports._errnoException (util.js:1034:11)
    at exports._exceptionWithHostPort (util.js:1057:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1096:14)
#2017-10-2411:15mhuebertin activity monitor i can’t find any node or java processes at all#2017-10-2411:16thhellerdelete the target/shadow-cljs/*.port files#2017-10-2411:17thhellerusually those are removed when the jvm exits#2017-10-2411:17thhellerbut if you kill it that doesn’t happen#2017-10-2411:20mhuebertyeah, starting a new server/watch and closing the terminal reproduces it#2017-10-2411:21mhuebertweb server doesn’t return requests, can’t run a new server/build#2017-10-2411:21mhuebertwhen i force quit the java process then immediately the browser’s hung request stops and says “ERR_CONNECTION_REFUSED”#2017-10-2411:22thhellerok, got it reproduced#2017-10-2411:22thhellerodd#2017-10-2411:23thhellerhmm the jvm is properly shutdown, just doesn’t quit#2017-10-2411:24thhellerweird#2017-10-2411:32thhellerseems to be related to the node process launching the java process#2017-10-2411:32thhellerwhen I run it directly without the node process it exits properly#2017-10-2415:13mhuebert2.0.39 with maria:
[:live] Build failure:
NullPointerException:
	clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301)
	shadow.build.npm/find-package-json (npm.clj:78)
	shadow.build.npm/find-package-json (npm.clj:77)
	shadow.build.npm/find-package-for-file (npm.clj:90)
	shadow.build.npm/find-package-for-file (npm.clj:89)
	shadow.build.npm/find-resource* (npm.clj:604)
	shadow.build.npm/find-resource* (npm.clj:592)
	shadow.build.npm/find-resource (npm.clj:670)
	shadow.build.npm/find-resource (npm.clj:652)
	shadow.build.resolve/fn--20914 (resolve.clj:81)
	shadow.build.resolve/fn--20914 (resolve.clj:78)
	clojure.lang.MultiFn.invoke (MultiFn.java:238)
	shadow.build.resolve/find-resource-for-symbol (resolve.clj:191)
	shadow.build.resolve/find-resource-for-symbol (resolve.clj:157)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:205)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:201)
	shadow.build.resolve/resolve-require (resolve.clj:235)
	shadow.build.resolve/resolve-require (resolve.clj:231)
	shadow.build.resolve/resolve-deps/fn--20895 (resolve.clj:56)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6752)
	clojure.core/reduce (core.clj:6735)
#2017-10-2415:21thhelleroops#2017-10-2415:23thhellerhmm#2017-10-2415:27thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e405e4440"}, :content ("[email protected]")}#2017-10-2415:29thhellerthose damn symbols 😛#2017-10-2415:46thhellerseems like I need to restructure my whole CLI script just to fix those damn orphan java processes#2017-10-2415:50mhuebert😞#2017-10-2415:50thheller
var cp = require("child_process");

cp.spawnSync("java", ["-cp", "../target/classes", "Test"], {stdio: "inherit"});
#2017-10-2415:51thhellersimple java process that just reads from stdin .. doesn’t die#2017-10-2415:52thhellercan’t figure out why … simple programs like nc -l localhost 8001 exit after a bit#2017-10-2415:52thhellerseems like I really have to go down the async route now 😞#2017-10-2416:06mhueberthmm, somehow an error like this doesn’t display the filename alongside the error:
[:bootstrap] Build failure:
Invalid namespace declaration
In: [2] val: ((:require [clojure.walk :refer :all] [thi.ng.dstruct.core :as d] [thi.ng.xerror.core :as err])) fails spec: :shadow.build.ns-form/ns-form predicate: (cat :docstring (? string?) :meta (? map?) :clauses :shadow.build.ns-form/ns-clauses),  Extra input
#2017-10-2416:08thhellerthats the entire error?#2017-10-2416:08mhuebertyep#2017-10-2416:08thhellerapart from being a terrible spec error#2017-10-2416:09mhuebertyeah i am hoping that those will get better. https://github.com/bhb/expound/ looks interesting.#2017-10-2416:09mhuebertits surprisingly hard to read.#2017-10-2416:10thhelleryes, its absolutely terrible#2017-10-2416:10thhellerI can’t make it out#2017-10-2416:10thhellerI tried expound before, it didn’t seem to handle syntax all that well#2017-10-2416:11thhellerworked ok on maps in general#2017-10-2416:11thhellerbut complex specs like the ns form spec didn’t get any easier to read#2017-10-2416:11thhellerbut its been a while maybe its better now#2017-10-2416:12thhellernevertheless it should at least show a filename#2017-10-2416:13mhueberti know you’re busy with the process stuff now, just making note of this bootstrap thing i’m trying to get to work#2017-10-2416:14mhuebertafter that ns related error led me to thi.ng.geom.core.macros.vector, non-selfhost-friendly macros namespace, so I put that in :exclude. then it fails with this math namespace.#2017-10-2416:14mhuebertlib is [ "0.0.908"],` (:require [thi.ng.geom.svg.core :as svg])`#2017-10-2416:16thhellerchecking#2017-10-2416:18thhelleryikes#2017-10-2416:18thhellerRetrieving org/clojure/clojurescript/0.0-3117/clojurescript-0.0-3117.pom from central#2017-10-2416:18thhellerthey are some outdated dependencies in there 😛#2017-10-2416:18mhuebert🙂#2017-10-2416:18mhuebertyeah it is a bit old. but karsten has written some really good and high performance stuff#2017-10-2416:18thhellerwhich entries did you use for bootstrap?#2017-10-2416:19mhuebertm i just added [thi.ng.geom.svg.core :as svg] to the require of an entry that was in bootstrap#2017-10-2416:19mhueberti did it in the shadow-bootstrap-example, just added [ "0.0.908"] to deps plus that require#2017-10-2416:20thhelleryep got the error#2017-10-2416:32thheller
[:bootstrap-support] Compiling ...
failed to inspect cljs file: jar:file:/Users/zilence/.m2/repository/thi/ng/geom-core/0.0.908/geom-core-0.0.908.jar!/thi/ng/geom/core/macros/vector.clj
Invalid namespace declaration
In: [2] val: ((:require [clojure.walk :refer :all] [thi.ng.dstruct.core :as d] [thi.ng.xerror.core :as err])) fails spec: :shadow.build.ns-form/ns-form predicate: (cat :docstring (? string?) :meta (? map?) :clauses :shadow.build.ns-form/ns-clauses),  Extra input
#2017-10-2416:33thhellernot exactly better but at least contains the file that caused it 😛#2017-10-2416:33thhellerthe spec error is so terrible … its not even close to identifying the cause#2017-10-2416:34thheller:refer :all is the issue#2017-10-2416:34thhellermaybe I just wrote the specs wrong … but this has to be one of the worst errors yet#2017-10-2416:39thhellerwhy are all those things macros? or rather why are there so many 😛#2017-10-2416:46mhuebertthat is much more helpful actually 🙂#2017-10-2416:46thheller
-- Syntax error -------------------

Value has extra input

  (... ... (:require
            [clojure.walk :refer :all]
            [thi.ng.dstruct.core :as d]
            [thi.ng.xerror.core :as err]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- Relevant specs -------

:shadow.build.ns-form/ns-form:
  (clojure.spec.alpha/cat
   :ns
   '#{clojure.core/ns}
   :name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :meta
   (clojure.spec.alpha/? clojure.core/map?)
   :clauses
   :shadow.build.ns-form/ns-clauses)

-------------------------
Detected 1 error
#2017-10-2416:46mhuebertso lots of karsten’s stuff is designed for performance. that’s why all the macros.#2017-10-2416:46thhellerthats expound#2017-10-2416:47mhuebertI think he has an ongoing complaint that clojure does not pay enough attention to performance ’cause lots of his work demands it.#2017-10-2416:47mhuebertif the error is :refer :all how is that message relevant#2017-10-2416:48thhellerprobably because of the way I structured my specs for the ns-form#2017-10-2416:54thhellerthis org mode code is scary 😛#2017-10-2416:58mhueberttotally#2017-10-2416:58mhuebert
Closure compilation failed with 1 errors
--- EXTERNS:/Users/MattPro/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
#2017-10-2416:58mhueberti don’t remember seeing this before, trying an :advanced build in the re-frame demo#2017-10-2417:03thhellerhttps://github.com/cljsjs/packages/commit/d675025ee9194e536fd4cf2578ad0837c9bfd19d#diff-07cb41fdc598845710ebb9d47ab69d29#2017-10-2417:03thhellerwas fixed a while ago it seems#2017-10-2417:04mhueberthave you had an issue where shadow doesn’t recognize changed versions in shadow-cljs.edn?#2017-10-2417:04mhuebertin updating d3 it didn’t download the new dep until i deleted target#2017-10-2417:04thhellerare you sure you restarted the server process?#2017-10-2417:05mhuebertoh, no. i only started a new build.#2017-10-2417:05thhelleryeah I need to add a check for that#2017-10-2417:05thhellernew deps require a restart#2017-10-2417:10mhuebert8 seconds vs 40 or 60 or 80 is a massive diff. for debugging advanced compiles#2017-10-2417:14thhellerstill extern related bugs?#2017-10-2420:12mhueberti’m compiling a debugging-oriented thing in :advanced mode, so its just a bunch of weird things#2017-10-2420:25thhellerthis day is full of weird things#2017-10-2420:25thhellerfound this package https://www.npmjs.com/package/signal-exit#2017-10-2420:25thhellerliterally just including the example fixes the issue#2017-10-2420:25thheller
var onExit = require('signal-exit')
 
onExit(function (code, signal) {
  console.log('process exited!')
})
#2017-10-2420:25thhellerNOTHING else#2017-10-2420:25thhellerit just works after this#2017-10-2420:26thhellerthe process properly exits and everyone is happy#2017-10-2420:26thhellerI do not understand why#2017-10-2420:41mhuebertVoodoo is the new math#2017-10-2420:43thhellerShaun just ran into a unicode problem I have never seen before as well … and also didn’t happen when tested inside the shadow-cljs project#2017-10-2420:43thhellerI have no special unicode config in my project and the files were identical, verified by shasum#2017-10-2420:44thhellerguess its a good thing this day is almost over 😛#2017-10-2503:08Jon
(ns respo.test.html
  (:require-macros [respo.macros :refer [html
                                         head
                                         title
                                         script
                                         style
                                         meta'
                                         div
                                         link
                                         body]])
  (:require [cljs.test :refer-macros [deftest is testing run-tests]]
            [respo.test.comp.todolist :refer [comp-todolist]]
            [respo.render.html :refer [make-string]]))
#2017-10-2503:09Jonjust noticed in shadow-cljs :refer-macros works...#2017-10-2503:09JonI thought we have to use :require-macros always 😱#2017-10-2503:09Jonit seems :refer-macros is actually more robust.#2017-10-2507:37thhelleryou shouldn’t use this syntax at all#2017-10-2507:45thhellerI gave you this example before https://github.com/thheller/shadow-cljs-examples/tree/master/macros#2017-10-2514:39Jondid you mean I can use :refer directly?#2017-10-2507:46thhellerALWAYS do this … it just makes things unnecessary complicated otherwise#2017-10-2508:49mhuebertI’ve been looking at setting up an auto-generated changelog (from commit messages) for maria, to be performed on release. something like that might be nice for shadow-cljs too#2017-10-2508:50thhelleryeah … I’m not the greatest at maintaining that#2017-10-2508:50thhellerbut not great at writing commit messages either 🙂#2017-10-2511:20mhuebertyeah mine can be much improved too. but makes it feel more worthwhile when the format can produce a changelog without any extra work#2017-10-2511:22mhuebertdid you end up learning anything about thi.ng.math.macros namespace? i wonder if his libs may actually not be that useful unless they are modified to be supported by the self-host compiler directly. (but unsure if that is related to why that namespace can’t be found, seems like a different thing)#2017-10-2511:33mhuebertthe only problem i can see with thi.ng.geom.core.macros.vector is the :refer :all, that would be an easy PR if not for the org format#2017-10-2511:33thhellerhehe yeah#2017-10-2511:34thhellerafaict thatst he only issue#2017-10-2511:34mhuebertis the math.macros error related to that? it seems like a resolution error#2017-10-2511:35mhuebertmaybe the :exclude option is actively excluding the transitive macro deps of the entry instead of just ignoring them? subtle difference..#2017-10-2511:40mhuebertmaking a little test case to figure that one out.#2017-10-2511:46mhuebertseems it may have nothing to do with :exclude#2017-10-2511:47thhellerwhat was the problem again?#2017-10-2511:47mhuebertuploaded with a test case. if you uncomment this: https://github.com/mhuebert/shadow-bootstrap-example/blob/master/src/shadow_eval/user.cljs#L21#2017-10-2511:47mhuebertmacros namespace a tries to require macros namespace b, should this work?#2017-10-2511:48mhuebert
[:bootstrap] Build failure:
The required namespace "shadow-eval.b" is not available, it was required by "shadow_eval/a$macros.cljc".
#2017-10-2511:48thhellerright#2017-10-2511:48thhellerit must be a .cljc file currently#2017-10-2511:48thhellerbut that entire process is busted#2017-10-2511:48thhelleryeah transitive deps in macros are a problem#2017-10-2511:52mhuebertrenaming the dep to .cljc does work#2017-10-2511:53thhellerreally? it does compile it as shadow-eval.b$macros?#2017-10-2511:53thhellerI assume it will be shadow-eval.b after which is incorrect I think#2017-10-2511:53thhellerI really couldn’t figure this out from reading the analyzer#2017-10-2511:54mhuebertnow i have a.clj and b.cljc and it builds#2017-10-2511:59thhellerI think that might be incorrect behaviour though, it should find the b.clj when compiling as a macro#2017-10-2512:00thhellerbut really I couldn’t find any documentation on how this is supposed to be resolved#2017-10-2512:00mhuebertit would make intuitive sense if the same resolution algo that was used to find a was used to find b#2017-10-2512:00mhuebertsince they are both macros lookups#2017-10-2512:00thhellermove a.clj to a.cljc 😉#2017-10-2512:01mhuebertin my own code, sure 😉#2017-10-2512:01thhellerneed to check how lumo or planck would handle such a case#2017-10-2512:01thhelleror cljs.core for that matter#2017-10-2512:05mhueberthttps://groups.google.com/d/msg/clojurescript/ya0-38K4WVU/175Wy8B8BAAJ#2017-10-2512:07mhuebert
For bootstrapped ClojureScript you could have any of these arrangements:

Runtime Code   Macro Code
foo.cljs              foo.clj
foo.cljs              foo.cljc
foo.cljc              foo.clj
#2017-10-2512:08thhellerthats not about transitive deps?#2017-10-2512:08mhueberthmm#2017-10-2512:08mhueberti would guess it searches with [clj, cljc] preference order but not sure#2017-10-2512:08thhellerI do that for macros yes#2017-10-2512:09thhellerbut not for things the macros themselves require#2017-10-2512:09thhellerthe problem is if you say (:require [thing.b]) in a macro#2017-10-2512:10thhelleryou might actually mean thing.b as in a normal namespaces that just contains functions and not macros#2017-10-2512:10thhellerso if you have a thing/b.cljs that would work#2017-10-2512:10thhellerbut if you have include it as a macro it ends up as thing.b$macros#2017-10-2512:10mhueberti guess that would break compatibility with JVM clojurescript#2017-10-2512:10mhuebertwhere things are divided by “compilation stage”#2017-10-2512:11thhellerI don’t know .. AFAICT this behaviour is undefined#2017-10-2512:12mhuebertfor the same reason we can’t intermix defmacro into cljs files without breaking compatibility, we also couldn’t use any other .cljs files in macro compilation stage#2017-10-2512:12thhellerif you can confirm that (:require [thing.b]) in a macro should cause thing/b.clj to be compiled as thing.b$macro I can add that#2017-10-2512:12thhellerbut I’m not convinced that that would be correct behaviour?#2017-10-2512:12thhellerI never used any self hosted stuff#2017-10-2512:13thhellercan you maybe confirm in lumo or so?#2017-10-2512:13thhellerthe shadow-bootstrap-example with b.clj#2017-10-2512:19mhuebertsigh#2017-10-2512:19mhuebertyou are right#2017-10-2512:20mhuebert🙂. a.cljs :require-macros b.cljc requires c.clj, fail#2017-10-2512:21mhueberta.cljs requires b.clj requires c.clj, fail#2017-10-2512:22thhellerwhat did you try?#2017-10-2512:24mhueberthttps://github.com/mhuebert/shadow-bootstrap-example/tree/master/macro-require-test#2017-10-2512:25mhuebertfrom that dir, planck -i test/a.cljs#2017-10-2512:25mhuebertand then mixing and matching b and c file extensions#2017-10-2512:27thhelleryeah the problem is that we can’t tell what is what#2017-10-2512:28mhuebertIMO the moment it was decided to read macros written in ClojureScript (not Clojure) from .clj files, programming became a kind of spiritually elevated art form#2017-10-2512:28mhuebertfull of mystery and awe.#2017-10-2512:29thhellerhehe it totally makes sense though 🙂#2017-10-2512:29mhuebertfor compatibility reasons#2017-10-2512:29mhuebertor other reasons?#2017-10-2512:32thhellerif I try to explain it I’ll butcher every correct lisp term for this#2017-10-2512:32thhellerby splitting it the compiled code does not itself depend on the compiler or the macros#2017-10-2512:33thhellerso the compiled code is drastically smaller by sacrificing runtime eval#2017-10-2512:35mhuebertI think I get that part. but now in addition to using java-based clojure to write clojurescript macros, we also use JS-based clojure to write clojurescript macros with the same file extension… it would make more sense to me if tools like Planck did not support loading macros from .clj files at all, because planck does not support JVM clojure#2017-10-2512:36mhuebertwith planck you can write macros in .clj files that read from js/window or whatever#2017-10-2512:36mhuebertwell, planck doesn’t have js/window.#2017-10-2512:36mhuebertbut you can use js stuff.#2017-10-2512:37thhellerI can’t really say anything about self-hosted. I never use it and don’t know the particular details.#2017-10-2512:38thhellerbut I do think its important to keep compatibility to the JVM compiler#2017-10-2512:39thhellerhaving self-host-only CLJS libs doesn’t help the community overall#2017-10-2512:39thhellerwell … JVM only CLJS libs isn’t exactly great either#2017-10-2512:39thhellerbut those could maybe be fixed to also work in self-host#2017-10-2512:41thhellerI really don’t know about the state of self-host and how “rushed” it was#2017-10-2512:41thhellermaybe it would actually be simple if just a few things were changed#2017-10-2512:42mhueberti think compilation passes got intertwined with language choice, and now we have a system where “.clj” and “.cljc” file extensions can no longer be taken at face value#2017-10-2512:42mhuebertwell, .cljc can#2017-10-2512:42mhueberti really don’t know how both concerns can be adequately handled#2017-10-2512:44thhellerthe problem is that you need to split at every point#2017-10-2512:45thhelleryou can just create .clj with a .cljc file that :require-macros itself#2017-10-2512:45thhellerthat way there is no ambiguity whether you wanted to include a macro or just code#2017-10-2512:45mhuebertfrom that thread > Why can’t bootstrapped load this file with “macros: false” and ignore all defmacro to load only functions and then load it with “macros: true” and take only defmacro into account?#2017-10-2512:46thhellerbut that is annoying for the CLJ side#2017-10-2512:46thhellergood question#2017-10-2512:46thhellerI do not know#2017-10-2512:46mhuebertwould that make sense? we would still have the problem that functions could not use macros defined in the same namespace. but that seems like a reasonable limitation#2017-10-2512:47thhellerwell technically you need the macros before the code#2017-10-2512:49mhuebertoh, the rabbit hole 🙂. so for this library it looks like he needs to rename that file to .cljc, no real way around it#2017-10-2512:49thheller
(defmacro deffoo [& args])

(deffoo thing
  1 2 3)
#2017-10-2512:50thhelleryou cannot compile this#2017-10-2512:50thhelleractually that would work in clojure#2017-10-2512:51thheller
(defmacro deffoo [& args])

(deffoo thing
  (js/document.getElementById "foo"))
#2017-10-2512:51thhelleryou can’t compile this 🙂#2017-10-2512:51thhellerAFAICT the is just not self-host compatible#2017-10-2512:51mhuebertexactly. but probably not a lot of changes required for it to be.#2017-10-2512:52mhueberti didn’t realize how this macro resolution worked#2017-10-2512:52mhuebert*macro dependency resolution#2017-10-2512:52thhellerproblem is I really cannot tell how easy the fix would be because of the org-mode#2017-10-2512:52thhellerI do not understand that at all 🙂#2017-10-2512:52mhuebertme neither#2017-10-2512:54thhelleralso if the macros only exist because of some perf opts#2017-10-2512:54mhuebertbut from looking at the clj* source files (easy to follow with cursive) it doesn’t look complicated#2017-10-2512:55thhellersome of the perf opts might be solved a different way#2017-10-2514:36mhuebertdo you have a preference for whether i mention issues here vs. creating github issues?#2017-10-2514:54Jonlooks wonderful... is it valid syntax in shadow-cljs, or in ClojureScript itself?#2017-10-2514:55thhelleryou can use :refer directly yes, valid in all CLJS#2017-10-2515:02Jonwhen I was reading guide on clojurescript Wiki, I thought I should use :require-macros, didn't even noticed there was a :refer-macros.
#2017-10-2515:05thhelleryou should not use either ever#2017-10-2515:05thhellerthe only place you should be using :require-macros is in a file of the same name basically requireing itself#2017-10-2515:06thheller
(ns app.lib
  (:require-macros [app.lib]))
#2017-10-2515:06thhellerlike this#2017-10-2515:07thhellereverything that uses app.lib then only uses :refer#2017-10-2515:10Jongoing to migrate many of my projects...#2017-10-2602:37richiardiandreaNice re-frame example you've built @mhuebert (+ @thheller of course) #2017-10-2611:12mhuebert@richiardiandrea thanks! just pushed an update with some better explanations + a newer version of re-frame-trace https://mhuebert.github.io/shadow-re-frame/#2017-10-2616:35thhellergood news. I fixed source maps for :advanced finally#2017-10-2616:35thhellerbad news they get huge 🙂#2017-10-2616:36thheller486kb .js 4.3mb .map 🙂#2017-10-2617:25mhueberti imagine that’s unavoidable?#2017-10-2617:25mhuebert(the size)#2017-10-2617:25mhuebertgreat that its working!#2017-10-2617:26mhuebertare you including the source code inline in the source maps?#2017-10-2617:39thhelleryes#2017-10-2617:40thhellerseemed to be more reliable that way#2017-10-2617:55thhellerfunny thing is that a lot of JS deps on npm are already minified#2017-10-2617:55thhellerbut shadow-cljs can’t know that so it minifies again#2017-10-2617:55thhellerand creates a source-map in doing so#2017-10-2617:55thhellerso we have a source map from minified -> minified. not all that useful 😉#2017-10-2617:56thhellerbut yeah .. source maps for “foreign libs” .. yay, that didn’t work before 🙂#2017-10-2618:31mhuebertthat’s great!#2017-10-2618:32mhuebertoh, found a simple bug in bootstrap loader: https://dev.maria.cloud/gist/34d3fde5e062fe9ac9027386af588568?eval=true was going to make a PR but got tied up this afternoon#2017-10-2618:32mhueberti think it just needs to check of a namespace already exists in compiler state before looking in the index#2017-10-2618:33thhellerisn’t cljs supposed to do that?#2017-10-2618:34thhellerlooks like dev.maria.cloud needs to be compiled with source maps 😉#2017-10-2618:48thhellerwhen I do (contains? @cljs.js/*loaded* 'maria.user$macros) I get false#2017-10-2618:48thhellermaria.user exists though#2017-10-2618:48thhellernot sure why bootstrap would call the load fn when its already loaded?#2017-10-2618:49thhellerI can add a check for it but I thought cljs was doing that#2017-10-2618:51thhellerhmm wait I can’t add a check if its not in cljs.js/*loaded*#2017-10-2619:51mhuebertdoes cljs.js/*loaded* get updated when namespaces are created, repl-style?#2017-10-2619:52mhuebertone could check the compiler state, :cljs.analyzer/namespaces#2017-10-2619:52mhuebertre: source maps, i’ll try that soon!#2017-10-2620:07mhuebertin lumo:
cljs.user=> (ns )
nil
=> (contains? @cljs.js/*loaded* ')
false
=> (contains? (set (keys (:cljs.analyzer/namespaces @cljs.env/*compiler*))) ')
true
=> (require ')
No such namespace: , could not locate the_thing/me.cljs, the_thing/me.cljc, or Closure namespace ""
#2017-10-2620:12mhueberthave i gone mad. i totally thought this should work: (planck now)
cljs.user=> (ns a.core)
nil
a.core=> (ns b.core (:require [a.core]))
No such namespace: a.core, could not locate a/core.cljs, a/core.cljc, or Closure namespace "a.core"
#2017-10-2620:17mhuebertlumo again:
cljs.user=> (ns a.core)
nil
a.core=> (def x 10)
#'a.core/x
a.core=> (ns b.core)
nil
b.core=> a.core/x
10
b.core=> (require '[a.core :as a])
No such namespace: a.core, could not locate a/core.cljs, a/core.cljc, or Closure namespace "a.core"
#2017-10-2620:17mhueberthow is everything broken#2017-10-2620:17mhueberthttps://dev.clojure.org/jira/browse/CLJS-1473#2017-10-2620:34mhuebertfiled a PR#2017-10-2620:43thhellerhttps://dev.maria.cloud/gist/34d3fde5e062fe9ac9027386af588568?eval=true#2017-10-2620:43thhellerdo you have an example namespace that is available but not yet loaded?#2017-10-2620:44thheller(part of the bootstrap build I mean)#2017-10-2620:52thheller
shadow-cljs node-repl
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.42
shadow-cljs - connected to server
shadow-cljs - starting node-repl
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 11.63s)
[3:1]~cljs.user=> JS runtime connected.
[3:1]~cljs.user=> (ns a.core)
[3:1]~a.core=> (ns b.core (:require [a.core]))
[3:1]~b.core=>
#2017-10-2620:53thhellerI guess my REPL works 😉#2017-10-2621:15thheller@mhuebert I think this correctly mirrors clojure behaviour https://github.com/thheller/shadow-cljs/commit/492b4f0d1aa77746b97640715afaf276b81567cb#2017-10-2621:15thhellerdo you still have the checkout setup or should I release a new version?#2017-10-2621:15thhellernot quite easy for me to test since I don’t have that editor setup#2017-10-2621:19mhuebertstill have it set up#2017-10-2621:21mhuebertworks for me#2017-10-2621:23thhellerdo you have a namespace that is not yet loaded but available in the boostrap index?#2017-10-2621:24thhellerthis change probably just broke (require 'thing :reload)#2017-10-2621:29mhueberthmm#2017-10-2621:30mhuebertlet me see#2017-10-2621:30thheller
(ns reagent.core)
   (def x 1)
   (ns b.core (:require [reagent.core :as a]))
   (js/console.log "x" a/x)
   (require 'reagent.core :reload)
#2017-10-2621:31thhellertested it in my setup#2017-10-2621:31thhellerand yes it broke :reload#2017-10-2621:32thhellerthat should load reagent.core from disk but does nothing (since there is analyzer data)#2017-10-2621:32thhellerbut the reload flag is not passed to the callback, so its impossible to tell 😞#2017-10-2621:33mhuebertadding one#2017-10-2621:33mhuebertoh nvm#2017-10-2621:33mhueberti thought :reload was passed to :load-fn#2017-10-2621:36thhellerdoesn’t appear so no, logged the data thats passed in and its just#2017-10-2621:37mhuebertwell.#2017-10-2621:37thhellerI guess its safer to always load then?#2017-10-2621:38thhellermeh .. that should really be fixed on the CLJS side of things#2017-10-2621:39mhuebertso now :reload will modify *loaded* but not inform :load-fn#2017-10-2621:40thhellerit does modifiy *loaded*?#2017-10-2621:40mhuebertin cljs.js:
(defn require
  ([name cb]
    (require name nil cb))
  ([name opts cb]
    (require nil name opts cb))
  ([bound-vars name opts cb]
   (require bound-vars name nil opts cb))
  ([bound-vars name reload opts cb]
   (let [bound-vars (merge
                      {:*compiler*     (env/default-compiler-env)
                       :*data-readers* tags/*cljs-data-readers*
                       :*load-macros*  (:load-macros opts true)
                       :*analyze-deps* (:analyze-deps opts true)
                       :*load-fn*      (or (:load opts) *load-fn*)
                       :*eval-fn*      (or (:eval opts) *eval-fn*)}
                      bound-vars)
         aname (cond-> name (:macros-ns opts) ana/macro-ns-name)]
     (when (= :reload reload)
       (swap! *loaded* disj aname))
     (when (= :reload-all reload)
       (reset! *loaded* #{}))
...
#2017-10-2621:40mhueberti haven’t followed up the chain of how require is invoked#2017-10-2621:41thhellerah ok didn’t see that#2017-10-2621:41mhuebertwas assuming that this reload option is coming from the repl command#2017-10-2621:44mhueberthmm, so… an error should be thrown if the ns is not in compiler-state nor the index; but if it is in the index, always load it, even if it exists in compiler state?#2017-10-2621:45mhuebertthat would make sense to me#2017-10-2621:45mhuebertwell#2017-10-2621:45mhuebertno not really.#2017-10-2621:47thhellerok .. AFAICT the fix would be in cljs.js/ns-side-effects#2017-10-2621:47thhellerthat SHOULD set cljs.js/*loaded* but doesn’t#2017-10-2621:48mhuebertmakes sense#2017-10-2621:49thhellerquick fix is doing your or#2017-10-2621:49mhuebertif we aggressively reloaded, then we could wipe out changes to an ns that had been made locally. i don’t think a user ever expects a simple (require ’the.thing) to modify it if it exists.#2017-10-2621:49mhuebertyeah. i don’t use :reload much.#2017-10-2621:50mhuebertwe don’t even have a namespaces module in maria yet 🙂#2017-10-2621:50mhuebertbut for later this could be important.#2017-10-2621:52thhellerpushed the fix#2017-10-2621:53thhellerbut should probably be fixed upstream#2017-10-2621:53mhuebertyeah#2017-10-2621:58thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adb3adb7b6"}, :content ("[email protected]")}#2017-10-2622:10thhelleronly problem is that (require 'my.thing :reload) now doesn’t throw an error and pretends to load something 😉#2017-10-2622:10thhellersince its not in the index#2017-10-2622:10thhellerbut I guess thats ok#2017-10-2622:11thhelleroff to bed, gn8#2017-10-2709:29dimovichhello#2017-10-2709:29dimovichis it possible to integrate shadow-cljs into boot build?#2017-10-2709:30dimovichI guess one could make them run in parallel#2017-10-2709:30Jonnot sure but heard it been used in lein...#2017-10-2709:31Jonwhy not use shadow-cljs directly?#2017-10-2709:31dimovichI need to also compile the Clojure backend#2017-10-2709:32Jonoh, that explains...#2017-10-2709:46Jonhttps://github.com/thheller/shadow-cljs/wiki/Boot#2017-10-2709:46Jonempty...#2017-10-2713:07thheller@dimovich yes its possible but I don’t recommend it. boot has some oddities that basically destroy all caching#2017-10-2713:08thhellerbut there is a shadow.cljs.devtools.api namespace#2017-10-2713:08thhellershadow-cljs compile app is the same as calling (shadow.cljs.devtools.api/compile :app)#2017-10-2713:08thhellersame for release and the rest#2017-10-2713:09thhellerbut it also has pretty specific dependency requirement and requires clojure 1.9 for example#2017-10-2718:30dimovich@thheller thanks for the tips#2017-10-2808:30dimovichhow does shadow-cljs deal with local maven packages? While boot picks it up ok, shadow-cljs complains it cannot find the package in maven#2017-10-2808:30thhellerhmm does boot have repository config for them?#2017-10-2808:31dimovichnot really, I took cljsjs.fabric from the official repo, and modified it, then run boot package to install it to local maven#2017-10-2808:31thhelleror a plugin of some kind? I’m using https://github.com/cemerick/pomegranate which I think boot uses too?#2017-10-2808:32thhellerthat should work? did you restart the process?#2017-10-2808:33thhellerbut why use cljsjs? the point is to get rid of those 😉#2017-10-2808:34thhellerjust npm install fabric and (:require ["fabric" :as fabric])#2017-10-2808:34dimovichyeah I restarted the process... I'm using cljsjs.fabric because there are some issues with using it directly from npm (can't find jsdom)#2017-10-2808:35dimovichthanks for pomegranate suggestion, will try it#2017-10-2808:35thhellerI wanna hear about all packages that don’t work#2017-10-2808:35thhellerso I can fix it 🙂#2017-10-2808:36dimovichoh, that would be great 🙂#2017-10-2808:36thhellerpomegrenate is what shadow-cljs uses to resolve deps#2017-10-2808:36thhelleryou don’t use it directly 🙂#2017-10-2808:36thhellerlooking into the jsdom thing#2017-10-2808:36dimovichI've tried using fabric directly also using boot, but no success... same issue#2017-10-2808:36dimovichthanks!#2017-10-2808:37thhellerok found the problem, fixing#2017-10-2808:41dimovichhoho... we need to 3d print a superhero badge for you 🙂#2017-10-2808:49thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c6b5aea7a2a9b1eba5aaacb586f4e8f6e8f2f1"}, :content ("[email protected]")}#2017-10-2808:49thhellerplease report all packages that fail to import properly, that actually revealed two issues. the important one is fixed 😉#2017-10-2809:04dimovichgreat, it compiles ok now. checking if the app is running ok#2017-10-2809:05dimovichhow comes shadow-cljs can compile things that the official compiler can't?#2017-10-2809:05dimovichwhere was the issue?#2017-10-2809:05thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-10-2809:06thhellerit doesn’t try to compile things via the closure compiler :advanced#2017-10-2809:06thhellerit just bundles the code like webpack or any other js tool would#2017-10-2809:06thhellerand only does :simple … also similar to what uglifyjs or so would do#2017-10-2809:08thhellerthe issue is that some npm packages “disable” certain requires via “browser” overrides in package.json#2017-10-2809:08thhellerhttps://unpkg.com/fabric@1.7.19/package.json#2017-10-2809:08thhellerso jsdom shouldn’t have been included but the override didn’t trigger correctly#2017-10-2809:09dimovichgot it#2017-10-2809:09dimovichthanks!#2017-10-2809:14dimovichbtw, you mentioned shadow.cljs.devtools.api... how can I use it from a boot script? It's cljs, right?#2017-10-2809:15dimovichin boot there is a call task (call :eval (...))#2017-10-2809:32thhellerno its clojure, just call it#2017-10-2809:34thhellerI’m really do not know much about boot in a clojure REPL you’d just (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/compile :foo)#2017-10-2809:34thheller+ aliases if you wanted#2017-10-2809:35thhellerI suppose boot can do that somehow, I never understand how there task system works exactly#2017-10-2809:55dimovichI also need to provide externs for every module I use?#2017-10-2809:57thhellerit depends#2017-10-2809:57thhellerexterns are generated for all included JS but its not 100% accurate#2017-10-2809:58thhellerworking on some further externs inference currently#2017-10-2809:58thhellerbut yeah … sometimes you’ll need externs#2017-10-2811:07Jonhttps://twitter.com/jiyinyiyong/status/924231088116981760#2017-10-2811:20thhellerI do not know anything about boot .. does boot install when you release something or not?#2017-10-2811:20thhellerinto the local maven repo that is#2017-10-2811:20thhellerlein deploy does not do that, only lein install#2017-10-2811:21Jonoh, right...#2017-10-2811:21JonI use boot deploy, probably not calling (install)#2017-10-2811:25dimovichI'm getting Uncaught ReferenceError: process is not defined when trying to load the js#2017-10-2811:25thhellerloading which js?#2017-10-2811:28Jonpaste code?#2017-10-2811:31thhellerjust need to know which package is causing the issue, shadow-cljs release app --source-maps should help track it down#2017-10-2811:38thheller@dimovich {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8dfee5ece9e2faa0eee1e7fecdbfa3bda3b9b5"}, :content ("[email protected]")} should fix the process issue and make it easier to track problems by printing the name of the thing that failed to execute in the console#2017-10-2812:16dimovich@thheller trying now with the new version and source-maps#2017-10-2812:52dimovichwhen using fabric (:require ["fabric" :as fabric :refer (Canvas IText Image)])#2017-10-2812:52dimovichif I remove the fabric dependency it works ok#2017-10-2814:15thhellerfabric is one scary package#2017-10-2814:15thhellerwell its dependencies are 🙂#2017-10-2814:43thhellerok, the problem is that non of this should be required in the first place#2017-10-2814:43thhellersecond part of the problem is the cyclic dependency#2017-10-2814:43thhellerI’m not yet sure how to fix this#2017-10-2814:44thhellerhttps://unpkg.com/fabric@1.7.19/dist/fabric.js#2017-10-2814:44thhellerif you scroll down there is a#2017-10-2814:44thheller
(function() {

  if (typeof document !== 'undefined' && typeof window !== 'undefined') {
    return;
  }
#2017-10-2814:45thhellermeaning that everything that follows will not be executed … but that doesn’t quite work since my bundler doesn’t understand the if#2017-10-2814:45thhellerneed to think about how to fix that#2017-10-2815:16thhellerI wonder how webpack handles this#2017-10-2815:16thhellerI can fix it so it doesn’t error out but it will still include the http dependency although it shouldnt#2017-10-2815:16thhellersuper weird package .. thx for bringing it to my attention I guess#2017-10-2815:18thhellerbrowserify also bundles the stuff it shouldn’t#2017-10-2815:21thhellerso does webpack …#2017-10-2815:21thhellerhow has no on complained about this before?#2017-10-2815:23thhellerwell I guess I can then do the same as webpack and browserify …#2017-10-2815:45thhellerhttps://github.com/kangax/fabric.js/issues/4423#2017-10-2816:00thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "27544f464348500a444b4d546715091709131e"}, :content ("[email protected]")} now behaves like webpack would … 34kb overhead until the above issue is fixed#2017-10-2908:50dimovich@thheller yay! it compiles and works fine now. Thank you!#2017-10-3008:39thheller@mhuebert https://github.com/mhuebert/shadow-re-frame has no link to the demo? didn’t you have a live demo somewhere?#2017-10-3008:39mhuebertoh, hah. yes!#2017-10-3008:39mhueberti am actually working on that readme right now#2017-10-3008:39mhuebertwill push it soon#2017-10-3008:39mhueberthttps://mhuebert.github.io/shadow-re-frame/#2017-10-3008:40thhellerthx. I’m working on something kinda related I think#2017-10-3008:40thhellerI’m getting very tired of me accidentally printing the CLJS compiler state at the REPL#2017-10-3008:41thhelleras its easily several hundred megabytes#2017-10-3008:41thhellerlooking to build some kind of data explorer for this#2017-10-3008:41thhellerseems like the app-state thing from re-frame-trace#2017-10-3008:44thhellernot sure how I’ll build it yet since it needs to work for CLJ#2017-10-3008:49thhellercan’t see the app? 🙂#2017-10-3009:02mhueberthmm#2017-10-3009:03mhuebert@thheller is there an error somewhere?#2017-10-3009:03thhellerhehe nah its just behind the thing#2017-10-3009:03thhellermaybe align left not center?#2017-10-3009:04mhuebertah that’s a re-frame-trace thing, they drive the whole ui#2017-10-3009:04mhuebertoh but you mean align the content.#2017-10-3009:04thhelleryeah#2017-10-3009:06mhuebertwas that how it opened by default?#2017-10-3009:06mhuebertit’s supposed to open at 35% and then i have the other side proportionally sized#2017-10-3009:07thhellerhmm I think its saved. I had it open before and might have moved it#2017-10-3009:08thhelleror maybe I had it open with the chrome devtools open#2017-10-3009:09thhellerit just showed up like that when I opened it, was confused for a sec#2017-10-3009:09mhuebertin my fork of re-frame-trace I started writing some namespace-aware truncation functions, as I needed a way to recursively print abbreviated Clojure forms https://github.com/mhuebert/re-frame-trace/blob/preview-event-params/src/day8/re_frame/trace/pretty_print_condensed.cljs#2017-10-3009:10mhuebertre: re-frame-panel - yeah that’s weird. i think they are working on alternate ways to view that widget, trying to limit the amount of stuff I put in my re-frame-trace fork#2017-10-3009:13mhuebertso that code (pretty-print-condensed) is not there yet, but may be in the right direction, as it emits a string (not a React component) and focuses on truncation of individual elements of the structure#2017-10-3009:13mhueberti don’t know if other pretty-printers do that, haven’t looked#2017-10-3009:14mhueberteg. “print this whole structure but limit length of any individual element to 30 chars”#2017-10-3009:16thhellerI think that won’t help in my case#2017-10-3009:17thhellerthe compiler env is so deeply nested but each item is very tiny#2017-10-3009:19mhuebertis limiting depth sufficient?#2017-10-3009:20thhellerI still want to be able to explore everything#2017-10-3009:21thhellerdepth might not be enough, there might be seqs with 1000+ items too#2017-10-3009:23mhuebertbut this is in the terminal?#2017-10-3009:23mhuebertwhat options for interactivity exist?#2017-10-3009:30thhellerdunno yet#2017-10-3009:30thhellermight do a web ui, might do a swing ui or just text#2017-10-3009:30mhuebertthe re-frame-trace app db explorer utilizes cljs devtools, but i was there as that was coded and it was really awkward because cljs devtools is tightly coupled to jsonml, this format used by chrome devtools#2017-10-3009:30thhelleryeah the devtools formatters are basically what I want#2017-10-3009:30thhellerjust for CLJ as well#2017-10-3009:31mhueberti plan to continue developing the value-viewer that is used by maria, which you’ve seen earlier#2017-10-3009:31thhellerbut in the console I can drill down into any value I want#2017-10-3009:31thhellerwithout it blowing up trying to print it all#2017-10-3009:31thhelleralthough it also converts everything to json ml at once#2017-10-3009:31thhellerso can’t really do that with too large values either#2017-10-3009:32thhellersome kind of protocol is going to be required#2017-10-3011:02thhellerjust landed support for css reloading in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "90e3f8f1f4ffe7bdf3fcfae3d0a2bea0bea5a0"}, :content ("[email protected]")}#2017-10-3011:02mhuebert🎉#2017-10-3011:02thhellerif you are using :devtools :http-root it should just work#2017-10-3011:03mhuebertthat’s great.#2017-10-3011:03mhueberti’m trying to understand exactly how paths work when requiring stuff from npm. eg someting like “@material/menu/util”, given that menu is this dir: https://github.com/material-components/material-components-web/tree/master/packages/mdc-menu#2017-10-3011:04mhuebertthere is an index.js, which exports: export {MDCSimpleMenu, MDCSimpleMenuFoundation, util};#2017-10-3011:04mhuebertthere is a util.js#2017-10-3011:04thheller@material/menu/util.js#2017-10-3011:04thheller@material/menu#2017-10-3011:05thhellernode resolve rules in a nutshell: first check if there is an exact match (with ext), then test with added .js ext#2017-10-3011:05mhuebertwith ["@material/menu/util" :refer [getTransformPropertyName]] I am seeing ReferenceError: module$node_modules$$material$menu$util is not defined#2017-10-3011:05thhellerif match is a directory look for dir/index.js#2017-10-3011:05mhuebertoh with an ext#2017-10-3011:05thhellernah should work without#2017-10-3011:06thhelleruhm there might be an issue when live reloading such code#2017-10-3011:06mhueberti’ll restart the server/watch#2017-10-3011:06mhuebertrefreshing the page hasn’t seemed to work#2017-10-3011:06thhelleryeah there might be a cache issue#2017-10-3011:07thhellerI need to fix that but not sure how yet#2017-10-3011:07thhellerdelete the output dir#2017-10-3011:07thhellernot the cache dir#2017-10-3011:07thhellerwell .. either one should work#2017-10-3011:08thhelleryeah its probably the cache issue#2017-10-3011:09thhellerI’ll fix that next, it re-appeared when I reworked the JS support recently because of this weird fabric.js issue#2017-10-3011:10mhuebertso, this should work:
["@material/menu/simple/foundation" :as MDCSimpleMenuFoundation]
["@material/menu/util" :refer [getTransformPropertyName]]
#2017-10-3011:12thhellerno#2017-10-3011:12thheller["@material/menu/simple/foundation" :default MDCSimpleMenuFoundation]#2017-10-3011:12thhellerthis should#2017-10-3011:12thhellerES6 default exports are special#2017-10-3011:13thhellerunfortunately this is not officially supported yet, so beware when adding this to a library#2017-10-3011:13thheller["@material/menu/simple/foundation" :as foundation] then foundation/default#2017-10-3011:13mhuebertah. i was wondering about that. I saw the discussion in cljs-dev about this :default stuff.#2017-10-3011:14thhellervote here https://dev.clojure.org/jira/browse/CLJS-2376#2017-10-3011:14thheller:default only works in shadow-cljs, not sure yet whether it will be adopted in CLJS core#2017-10-3011:15thhellerI got tired of writing thing/default very very quickly when testing the ES6 support, thats why I added the :default#2017-10-3011:15thhellerits not pretty either way …#2017-10-3011:17thhellernote that you do not have to use :default MDCSimpleMenuFoundation :default thing also works since you can chose the name#2017-10-3011:17thhellerES6 default import/export are pretty weird#2017-10-3011:18mhuebertso there can be a :default export and also other exports?#2017-10-3011:18thhelleryes#2017-10-3011:18Jonhow is CSS in release mode?#2017-10-3011:19thheller@jiyinyiyong not in release mode, only watch.#2017-10-3011:19Jon🤔 well..#2017-10-3011:20thhellerits only watch/reload for now .. there is no support for directly bundling css in any way#2017-10-3011:21thhellerit watches the :watch-dir (or :http-root) and then replaces <link rel="stylesheet" href="/css/main.css"> tags if /css/main.css changes#2017-10-3011:21thhellernothing else#2017-10-3011:21thhellerhow the css gets there is up to you#2017-10-3011:22Jonsounds like you are controlling the HTML file?#2017-10-3011:22thhellerno?#2017-10-3011:22thhellerreplaces at runtime via javascript#2017-10-3011:22Jonwith js to manipulate <link/>?#2017-10-3011:22thhellerhtml files are never touched#2017-10-3011:24Jonhow do you help shadow-cljs learn where's the file located?#2017-10-3011:24thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L141-L154#2017-10-3011:24thhellerif you use the built-in http server it already knows enough#2017-10-3011:25JonI use http-server package from npm#2017-10-3011:26thhellerhow come?#2017-10-3011:26Jonlooks like it's just matching by file name#2017-10-3011:27Joninteresting by I will keep using Webpack in my cases... I have to make sure it's correctly bundled.#2017-10-3011:27Jonalthough I don't have much handwritten CSS in my current workflow https://github.com/mvc-works/coworkflow/blob/master/entry/main.css#2017-10-3011:29thhellernot ideal but you can do :devtools {:watch-dir "target"}#2017-10-3011:29thhellerah no wait … nevermind#2017-10-3011:29thhellerwebpack doesn’t spit out files while watching#2017-10-3011:30Jonyeah, and I think it's okay..#2017-10-3011:31thheller@jiyinyiyong @mhuebert you both seem to use cljs-devtools. how come? is the console support shadow-cljs adds not enough?#2017-10-3011:32mhuebert@thheller I don’t actually use it, only included it in that example because of re-frame-trace#2017-10-3011:33Jondidn't look into it... just thought I needed it so I need it..
#2017-10-3011:34Jonwhat does shadow-cljs provide?#2017-10-3011:34thhelleronly the custom devtools formatters so CLJS objects are recognizable in the console#2017-10-3011:35thhellervery plain though, not as colorful as cljs-devtools#2017-10-3011:35thhelleralso cljs-devtools does a whole lot more other stuff#2017-10-3011:36thhellerjust curious if there is a particular interesting feature I should implement#2017-10-3011:36thhellerbut just using cljs-devtools is fine too, nothing wrong with that#2017-10-3011:37JonI see PersistentHashMap and I think it's not formatted... so I used cljs-devtools#2017-10-3011:37Jonbut the values do not look like formatted by cljs-devtools#2017-10-3011:40Jonanyways bundling CSS is really huge work, there are style-loader css-loader file-loader url-loader involved just to bundle CSS with fonts...#2017-10-3011:44thhelleryeah I’m not touching that anytime soon#2017-10-3011:44Jonactually most of my CSS lives in ClojureScript https://github.com/Cirru/cumulo-editor/blob/master/app/src/app/comp/leaf.cljs#L35 since I don't care about compatibility in my personal stuffs.. I would like to drop Webpack... just I still need to bundle CSS correcly.#2017-10-3011:45thhellerI just use sassc directly for work#2017-10-3011:45JonI choose CSS in js...#2017-10-3011:46thhellerwell I do that too … but not for everything#2017-10-3011:48JonCSS in js solution in js world still use Webpack to extract CSS text files.#2017-10-3011:48Jonreally powerful these days#2017-10-3011:51Jonoffline for home~ bye#2017-10-3015:13mhuebert(replicate via npm install firebaseui and then include sth like ["firebaseui" :as firebase-ui] in a namespace)#2017-10-3015:15mhuebertrequiring "firebase/app.js" appears to work, but not "firebase/app", and since firebaseui is the one doing the require, i can’t change that#2017-10-3016:03mhuebert:+1::skin-tone-2: for CSS reloading, it’s working great, w/ zero extra config#2017-10-3016:40thheller@mhuebert it works for me?#2017-10-3016:41mhuebertReally. Hmm#2017-10-3016:41thheller"name" "firebase", "version" "3.9.0",#2017-10-3016:42thhellerI have 4.6?#2017-10-3016:43mhuebertthat may be it#2017-10-3016:43thhellermaybe pre4.0 was bundled differently?#2017-10-3016:43mhuebertentirely possible#2017-10-3016:44thhellercheck if there is a nested node_module/firebaseui/node_modules/firebase install#2017-10-3016:44mhueberti’ll try first with latest versions of both#2017-10-3016:45thhellerI do ignore those currently because I don’t want to run into situations where 2 versions of one package are loaded#2017-10-3016:45mhuebertfor browser builds that’s a good idea#2017-10-3016:47thhelleryeah but might cause issues like yours#2017-10-3016:47thhellershould at least warn or something#2017-10-3016:57mhuebertinteresting:
--- externs.shadow.js:3225
Parse error. Character '$' (U+FF04) is not a valid identifier start char
and last line of that file is ShadowJS.prototype.$;
#2017-10-3016:58thhellerhehe nice#2017-10-3017:00thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure/PropertyCollector.java#L26-L40#2017-10-3017:00thhellerfunny that I’m using a isJSIdentifier method from Closure that is supposed to check this 🙂#2017-10-3017:00thhellerguess that doesn’t quite work#2017-10-3017:01mhueberthah one would expect that to work!#2017-10-3017:03thhelleryep, returns true.#2017-10-3017:05thhellerdo you know which file that is from by any chance?#2017-10-3017:14mhuebertI’ve done a plain text search through the whole project and can only find that character in some strings inside JSON objects in iconv-lite#2017-10-3017:14mhuebertbut i don’t see how they would end up as a variable name#2017-10-3017:15mhuebertit’s weird#2017-10-3017:22thhellertry {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2d5e454c49425a004e41475e6d1f031d03181c"}, :content ("[email protected]")}#2017-10-3103:40cmalHi, I've got this warning in shadow-cljs release app:
-> Compile CLJS: devtools/hints.cljs
WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced.
         You should remove this library from non-dev builds completely because it impedes dead code elimination.
         The best way is to use :preloads compiler option: .
         To silence this warning please set :silence-optimizations-warning config key to true.
         More details: .
What should I add to the shadow-cljs.edn?
#2017-10-3107:40thheller@cmal not sure, maybe :compiler-options {:silence-optimizations-warning true}?#2017-10-3107:40thhelleror do you want it in dev only?#2017-10-3107:40thhellerthen :devtools {:preloads [devtools.preload]}#2017-10-3108:24cmalThanks. If I already have :devtools {:preloads [re-frisk.preload] :autoload true} in shadow-cljs.edn, should I change it to :devtools {:preloads [[re-frisk.preload] [devtools.preload]] :autoload true}?#2017-10-3108:24thheller:preloads [re-frisk.preload devtools.preload]#2017-10-3108:25cmalThanks.#2017-10-3108:26cmalAnother question. I am doing shadow-cljs watch app and then shadow-cljs cljs-repl app but I got this in cljs-repl:
[1:1]~cljs.user=> (+ 1 1)
There is no connected JS runtime.
#2017-10-3108:26thhelleryeah your app needs to be loaded in the browser or so#2017-10-3108:26cmalOK. Thanks.#2017-10-3108:26thhellerif you just want a repl you can do shadow-cljs node-repl#2017-10-3108:27cmalOK#2017-10-3110:01mhuebert2.0.50 introduced this error when building maria:
[:live] Configuring build.
[:live] Build failure:
target-fn shadow.build.targets.browser/process not found
{:target :browser}
ExceptionInfo: target-fn shadow.build.targets.browser/process not found
	clojure.core/ex-info (core.clj:4744)
	clojure.core/ex-info (core.clj:4744)
	shadow.build/get-target-fn (build.clj:180)
	shadow.build/get-target-fn (build.clj:153)
	shadow.build/configure (build.clj:198)
	shadow.build/configure (build.clj:185)
	shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:121)
	shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:90)
	shadow.cljs.devtools.server.worker.impl/fn--22666 (impl.clj:208)
	shadow.cljs.devtools.server.worker.impl/fn--22666 (impl.clj:200)
	clojure.lang.MultiFn.invoke (MultiFn.java:233)
	shadow.cljs.devtools.server.util/server-thread/fn--22550/fn--22551/fn--22555 (util.clj:162)
	shadow.cljs.devtools.server.util/server-thread/fn--22550/fn--22551 (util.clj:161)
	shadow.cljs.devtools.server.util/server-thread/fn--22550 (util.clj:146)
	clojure.core.async/thread-call/fn--7892 (async.clj:442)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
	java.lang.Thread.run (Thread.java:745)
#2017-10-3110:25thhelleruhm?#2017-10-3110:25thhellerthat definitely exists#2017-10-3110:25thhellermay be bad AOT cache, try deleting target/shadow-cljs/aot-classes#2017-10-3110:26thhellerwonder how it got into that state#2017-10-3110:32thheller@mhuebert {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "295a41484d465e044a45435a691b0719071c1b"}, :content ("[email protected]")} should fix the JS issue you ran into yesterday. https://github.com/thheller/shadow-cljs/issues/124#2017-10-3110:33thhellerwonder how the other thing happened though#2017-10-3110:45thheller21023 events is that normal in the shadow-re-frame demo?#2017-10-3110:45thhellerits firing events like crazy?#2017-10-3110:57thhellerguess it calling render for every time it wants to update the counter#2017-10-3110:58thhellerby doing so triggering another render?#2017-10-3110:58thhellercan’t tell if that might be related due to an update I did?#2017-10-3110:59mhuebertno, that’s not normal#2017-10-3110:59mhuebertbut i know what the cause would be#2017-10-3110:59mhueberteasy fix#2017-10-3111:00thhellerso not something I may have just caused by the update?#2017-10-3111:00mhuebertI don’t think so. it is related to how component-paths are read#2017-10-3111:01mhueberti had fixed it, but recently my patch was merged into re-frame-trace and one aspect of it may have not been applied/merged correctly#2017-10-3111:02thhellergood to know. I was getting worried that my update didn’t work properly#2017-10-3111:04mhueberti will build with latest update now#2017-10-3111:04mhuebertto make sure#2017-10-3111:04mhuebertand then test my other project with that bug from yesterday#2017-10-3111:05mhuebertnot important but WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :whitespace.#2017-10-3111:05mhuebertshouldn’t this warning only occur on :release?#2017-10-3111:06thhellerhmm its by cljs-devtools not by me#2017-10-3111:07mhueberti see.#2017-10-3111:09thhellerhmm ok it checks :optimizations which it expects to be :none#2017-10-3111:09thhellerI guess I can set that so it doesn’t complain#2017-10-3111:10thhellerin shadow-cljs :optimizations is only used in release mode and otherwise ignored#2017-10-3111:10mhueberti wouldn’t worry about it#2017-10-3111:11mhuebertthis project is a special case / demo of dev-time tools#2017-10-3111:11mhueberti just pushed an update to shadow-re-frame, for me the events count normally#2017-10-3111:13thhelleryou could also set :release {:compiler-options {:optimizations :whitespace}} which would only set that option for release#2017-10-3111:14thhellerbut I will still force it to :none since other macros might use that as well#2017-10-3111:14thhellernot something I ever recommend doing but people do weird things#2017-10-3111:17mhuebertyeah the fix from yesterday looks like it works#2017-10-3111:18thhellercounter still going crazy for me#2017-10-3111:18mhueberton the deployed version or locally?#2017-10-3111:19mhuebert& which browser?#2017-10-3111:19thhellerno deployed version is fine, just my local version#2017-10-3111:20thhellerah wait#2017-10-3111:20thheller
:source-paths ["src"

                ;; for development, checkout re-frame-trace and re-view into sibling directory,
                ;; or remove these entries:
                "../re-frame-trace/src"
                "../re-view/re-frame-simple/src"]
#2017-10-3111:20thhellerI might have old checkouts of those#2017-10-3111:21mhuebertmaybe remove those dirs#2017-10-3111:21mhuebertuse the version from clojars#2017-10-3111:21thhelleryeah thats it#2017-10-3111:21thhellerphew#2017-10-3111:24thheller:whitespace warning should also be gone in next update#2017-10-3111:31mhuebertextern annotation with ^js is pretty easy and intuitive#2017-10-3115:21mhuebertstill getting this browser/process not found error after rm -rf target#2017-10-3115:28mhuebertit does not happen if I compile the :live build by itself, only when multiple builds at the same time#2017-10-3115:29mhuebertand it is order dependent, npx shadow-cljs watch trusted live fails, npx shadow-cljs watch live trusted works#2017-10-3116:21mhuebertdownside to loading bootstrap stuff via inline <script> tags is that errors show up as coming from <anonymous> locations:
TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at Function.cljs.spec.test.alpha$macros.instrument.cljs$core$IFn$_invoke$arity$4 (<anonymous>:248:95)
    at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$6 (/js/compiled/cljs-runtime/cljs.core.js:13067:10)
#2017-10-3121:14thheller@mhuebert you keep finding the good bugs. npx shadow-cljs watch trusted live should now work in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "26554e474249510b454a4c5566140816081315"}, :content ("[email protected]")}#2017-10-3121:15thhellerrace condition when loading the target fn, so two builds with the same :target would cause one to fail.#2017-10-3122:03mhueberti’m trying to get a circleci thing running for maria#2017-10-3122:03mhuebertif i can figure this config out, it would be nice to get it to run whenever shadow-cljs updates 🙂#2017-11-0104:01cmalHi, it seems I touched nothing but suddenly went into a lot of errors such as
index.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at index.js:1
(anonymous) @ index.js:1
emptyObject.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at emptyObject.js:1
(anonymous) @ emptyObject.js:1
invariant.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at invariant.js:1
#2017-11-0104:08cmalReinstall shadow-cljs solves this. It may because of I run git pull in the shadow-cljs repo. 😕#2017-11-0104:21cmal
...
[CACHED] doumi/bottomnav.cljs
-> JS Cache read: 32 JS files
<- JS Cache read: 32 JS files (24 ms)
-> Closure - Optimizing ...
Closure compilation failed with 1 errors
--- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
I've already removed d3 from shadow-cljs.edn and deleted the d3 folder from ~/.m2/repository/cljsjs, but shadow-cljs still gives me this error.
#2017-11-0104:21cmal
10774 ± : ls /Users/yuzhao/.m2/repository/cljsjs/d3/                                                                         ⏎ [43m] ✹
ls: /Users/yuzhao/.m2/repository/cljsjs/d3/: No such file or directory
#2017-11-0104:23cmalDoes shadow-cljs need to do some "clean" work?#2017-11-0104:24cmalIt is weird I already have removed all about d3 from my code.#2017-11-0105:27cmal===> Hi, I removed the target folder , removed [braintripping/re-frame-trace "0.1.9"] and run shadow-cljs release app again and it works now!#2017-11-0109:11mhuebert@cmal that error I believe is from an old version of braintripping/re-frame-trace#2017-11-0109:12cmalOK. I've switched re-frame-trace to re-frisk now.#2017-11-0109:12cmalAnd it works well in wechat simulator.#2017-11-0109:14thheller@cmal that error is from an old cljsjs/d3 release, not directly related to shadow-cljs#2017-11-0109:16cmal@thheller I update shadow-cljs version. And after that I find the old target prevent me from re-compiling the new code until I removed target folder when it begins to work.#2017-11-0109:16thhelleryes, that is due to AOT. I do not recommend working with a checkout of shadow-cljs#2017-11-0109:17cmalOK.#2017-11-0109:17thhellerI can probably add a config option to disable AOT, but then startup will be very slow#2017-11-0109:18thhelleronly need to delete target/shadow-cljs/aot-classes, the rest is ok to keep#2017-11-0109:20cmalOK. Maybe a shadow-cljs clean-aot to clean the aot. I stared at the [CACHED] things for a while and finally found out removing target will work. 😄#2017-11-0109:20thhellerthat is not related#2017-11-0109:21cmal😕#2017-11-0109:21thheller[CACHED] cljs/core.cljs means that the CLJS compilation output is cached#2017-11-0109:22thhellerI do all kinds of checks to ensure that is properly invalidated#2017-11-0109:22thhellerthe AOT cache is wiped whenever a new shadow-cljs release is used#2017-11-0109:22cmalYes. I remembered I got the error message when Optimizing....#2017-11-0109:22thhellerbut that doesn’t work of you use a checkout#2017-11-0109:22cmal
-> Closure - Optimizing ...
Closure compilation failed with 1 errors
--- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
#2017-11-0109:23cmalNo. I did not use a checkout. Not yet find out how to work with a checkout. 😆#2017-11-0109:23thhellerdo shadow-cljs --cli-info | grep d3#2017-11-0109:23cmaljust in case because I lein install once weeks before.#2017-11-0109:24thhelleroh wait .. it already has all the info 😉#2017-11-0109:24thhelleryou are using cljsjs/d3/4.2.2-0#2017-11-0109:24thheller(probably not you, but one of your dependencies)#2017-11-0109:25cmalyep. @mhuebert says it was [braintripping/re-frame-trace "0.1.9"]#2017-11-0109:25thhellerhttps://github.com/cljsjs/packages/commit/d675025ee9194e536fd4cf2578ad0837c9bfd19d#diff-07cb41fdc598845710ebb9d47ab69d29#2017-11-0109:25cmalI removed that and it works.#2017-11-0109:25thhellerthis was fixed a while ago#2017-11-0109:25thhelleryou just need the updated cljsjs/d3 version#2017-11-0109:26cmal😄#2017-11-0109:26thhelleradd [cljsjs/d3 "4.3.0-5"] as your first :dependencies#2017-11-0109:26mhuebertlatest version of shadow-re-frame already has that https://github.com/mhuebert/shadow-re-frame/blob/master/shadow-cljs.edn#L8#2017-11-0109:26mhuebert(a newer re-frame-trace version)#2017-11-0109:26cmalNever mind. I do not use that any more. But I will write that down, in case later I will use d3 again. 😆#2017-11-0109:33thheller@mhuebert https://clojars.org/braintripping/re-frame-trace still lists the old cljsjs/d3 dependency?#2017-11-0109:35thhellerah its a fork ok#2017-11-0109:36mhuebertoh… you are right though I think#2017-11-0109:39mhuebertI had removed d3 from the build because that feature doesn’t work anyway, but then was trying to get my fork to be closer to master and forgot about this whole d3 extern fiasco#2017-11-0109:40mhuebertgoing to submit a PR to re-frame-trace#2017-11-0109:43mhuebertI didn’t notice because I am not doing an :advanced build for the demo anymore as it causes too many problems with trace#2017-11-0109:44thhellerwonder which hacks trace is doing 🙂#2017-11-0110:55thheller@mhuebert about circleci, if there is something I could add to make integration easier let me know#2017-11-0110:55thhellerstill need to figure out this cljs.test stuff#2017-11-0110:55mhuebert@thheller I happened to make my attempt last night when circleci itself began having reliability problems#2017-11-0110:56thhellerah hehe doh#2017-11-0110:56mhueberttheir 1.0 platform is way too slow and underresourced so the builds fail#2017-11-0110:56mhuebertand their 2.0 platform wasn’t working properly last night#2017-11-0110:56mhuebertunfortunately i didn’t realize that their platform wasn’t working until later so I gave up on some of the config stuff that might have worked#2017-11-0110:57thhellershadow-cljs happily eats up all the resources it can get since everything is threaded/parallel#2017-11-0110:57thhellermight need an option to turn that off for things like CI#2017-11-0110:58thheller2 builds in parallel = 2x memory requirement#2017-11-0110:58mhuebertit looks like parallelism in circleci means ‘multiple machines’ instead of providing multiple cores or more memory in one machine: https://circleci.com/docs/2.0/parallelism-faster-jobs/#2017-11-0110:59mhuebertand not sure if it helps us at all. they do give 4 instances for free for open source projects#2017-11-0110:59thhellerhmm so each “job” only gets one core?#2017-11-0111:03thhellerhmm can’t find any info on how much resources each job gets#2017-11-0111:04thhellerah found it, https://circleci.com/docs/2.0/configuration-reference/#resource_class#2017-11-0111:04thhellerOSS probably = small?#2017-11-0111:05mhuebertprobably#2017-11-0111:06thhelleryuck .. definitely need a “use less resources” option then, parallel builds will actually be slower on one core#2017-11-0111:08mhuebert2CPU/4096MB#2017-11-0111:08mhuebertthat’s what my build gets#2017-11-0111:09thhellerah ok, that should be ok then#2017-11-0111:12mhuebertcircleci 2.0 is based on docker vs. their old config system#2017-11-0111:12mhuebertwhich means it is no longer simple to specify an environment that has both nodejs and java#2017-11-0111:13thhellerdoh#2017-11-0111:13mhuebertit used to be as simple as specifying a version for both. now, because they only have prebuilt docker images for each individually, you have to make or find your own#2017-11-0111:13mhuebertthe one i found has an old version of node#2017-11-0111:13mhuebertequals pain.#2017-11-0111:14thhellerI have to confess that I have never used docker … or rather never could get it running.#2017-11-0111:15thhellerI take a plain old linux box over this container crap any day 🙂#2017-11-0111:15mhuebertnow i found a docker image that has java and recent node, but no git#2017-11-0111:19mhuebertapparently i already have a docker account#2017-11-0111:20thhelleryou could probably use the lein image they provide#2017-11-0111:20thhellerah no wait .. need npm 😛#2017-11-0111:26thhellerwait .. circleci is using clojurescript? how do they not have a pre-built image for this#2017-11-0111:27mhuebertmaybe they do#2017-11-0111:31mhuebertthere is an official clojure image but it appears to only include lein and boot#2017-11-0111:33thhellerhmm yeah thats enough if you only use cljsjs, guess I need to sell them on shadow-cljs 😉#2017-11-0116:59evekoI cannot get shadow cljs to compile my cljs, I get the error could not find or load main class clojure.main... Google does not give any usefull hints. Going through lein it works , but I don't want to use lein for this project.#2017-11-0118:52thheller@eveko which error do you get?#2017-11-0118:53evekoJust that it cannot find clojure.main#2017-11-0118:53thhellerfull error + command you used would help#2017-11-0118:53evekoGive me a moment need to fish my laptop#2017-11-0118:54thhellerwhich OS are you on? windows by any chance?#2017-11-0118:54evekoYeah Windows#2017-11-0118:54thhellerhmm yeah thats probably it. I never tried running windows before.#2017-11-0118:54thhellerhave you considered the linux subsystem stuff for windows? that works pretty well#2017-11-0118:54evekoI will try that in a moment#2017-11-0118:55evekoThe command is shadow-cljs watch app#2017-11-0118:55evekoThen error: could not find or load main class clojure.main#2017-11-0118:56thhellerpretty sure this is the cause https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L33-L34#2017-11-0118:57thhellerlet me check if there is an easy way to figure out if running in windows#2017-11-0119:00thheller@eveko try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "384b50595c574f155b54524b780a1608160d0c1509"}, :content ("[email protected]")} maybe that works#2017-11-0119:04evekoOk i got a different error now#2017-11-0119:04evekoIt is namespace related, so I think I can resolve it with some tinkering#2017-11-0119:05thhellerI really recommend the linux subsystem stuff, that just works out of the box#2017-11-0119:05thhellerI’m not 100% I handle everything correctly when it comes to windows, I should be in most cases#2017-11-0119:06thhellerotherwise just report the errors and I’ll see if I can fix it#2017-11-0119:07evekoI had the same error though from the wsl a moment ago#2017-11-0119:07evekoThe clojure main one#2017-11-0119:08thhellerhmm thats odd#2017-11-0119:08evekoBut then again, it does flip out having both windows and Linux version of commands #2017-11-0119:08thhellermaybe old node version?#2017-11-0119:08evekoI am on node 9#2017-11-0119:09thhellerhmm#2017-11-0119:09thhellerbooting my windows machine now 🙂#2017-11-0119:09evekoIt is a pity though, I wanted to experiment with some cljs front end, our backend at work is https://asp.net framework on windows#2017-11-0119:11thhellerI tried keeping everything windows compatible, just might have missed a few things#2017-11-0119:14evekoCurrent error I get is failed to inspect resource#2017-11-0119:15evekoThen the path of my cljs file#2017-11-0119:18thhellerI really need the full error#2017-11-0119:19thhellertrying it on my windows machine now but almost everything is outdated there#2017-11-0119:19thhellerupdates gonna take a while#2017-11-0119:23thhellerrunning it via wsl works fine#2017-11-0119:26eveko[:app] Compiling ... Nov 01, 2017 8:04:01 PM clojure.tools.logging$eval761$fn__764 invoke WARNING: failed to inspect resource "C:\Users\*\Documents\Visual Studio 2017\Projects\techtest\techtest\src-cljs\main\app.cljs", it will not be available. The required namespace "techtest.app" is not available.#2017-11-0119:26evekothis is the console output from windows#2017-11-0119:28evekothe wsl one also has the same error, but I believe that is because wsl tends to sometimes use the windows binary of noder/yarn#2017-11-0119:29evekoI will try making this work on my home desktop where i can be sure that wsl wont use windows binaries#2017-11-0119:30thhellerit sort of works in windows directly#2017-11-0119:30thhellerthe compiled succeeded but the watch failed, I can fix that#2017-11-0119:31thhellerthe above error just looks like a namespace violation?#2017-11-0119:32thhellertechtest.app should be in src-cljs\main\techtest\app.cljs#2017-11-0119:32thhellerif src-cljs/main is your source path#2017-11-0119:32thhellermain\app.cljs would be main.app#2017-11-0119:33evekooh hold on#2017-11-0119:33evekoyeah#2017-11-0119:33thhellernot sure why the inspect fails though, there should be a proper message for that#2017-11-0119:34thhelleroh hmm … might be me packing this mistake#2017-11-0119:35evekook i think i am overlooking how to set up the module in the edn#2017-11-0119:35evekoif I have src-cljs/main/app.cljs#2017-11-0119:35thheller:source-paths ["src-cljs"] in the shadow-cljs.edn#2017-11-0119:35evekothe namespace in app.cljs is techtest.app#2017-11-0119:36thhellerthen it should be in src-cljs/techtest/app.cljs#2017-11-0119:37thhellerah maybe its empty or doesn’t start with (ns techtest.app)?#2017-11-0119:37thhellereverything in CLJS is namespaced and it must always be first in each sourcefile#2017-11-0119:37eveko(ns techtest.app)#2017-11-0119:38evekomaybe something wrong here?#2017-11-0119:39thhellerdo you have :source-paths ["src-cljs"]? besides that it looks correct#2017-11-0119:39evekoyup#2017-11-0119:40thhellerhmm let me check if it chokes because of the spaces in the file path, eg. Visual Studio 2017#2017-11-0119:40thhellerit really shouldn’t but you never know#2017-11-0119:42thhellercan you try cloning https://github.com/shadow-cljs/quickstart-browser#2017-11-0119:43evekocloned#2017-11-0119:44evekoso I am getitng that clojure main error#2017-11-0119:44thhellernpm install + npx shadow-cljs watch app#2017-11-0119:44eveko😛#2017-11-0119:44thhellerah sorry#2017-11-0119:44thhellernpm install sh#2017-11-0119:44thhellerdidn’t bump the version#2017-11-0119:45thhellercompiling should work fine#2017-11-0119:45thhellerjust file watching is broken#2017-11-0119:46evekoyeah exception and then build complete#2017-11-0119:49thhellertrying to make sense of this error but I’ll get that fixed#2017-11-0119:50evekoI go try get my cljs to compile#2017-11-0119:50evekocause the one I just pulled worked, It also had the visual studio path, so the spaces are not the issue#2017-11-0119:51thhellerok good to know#2017-11-0119:51thhellerI got no immediate idea what might be causing your issue. does it dump a full stacktrace?#2017-11-0119:52evekono it does not.#2017-11-0119:52evekoit did dump one when doign the browser one#2017-11-0119:53evekothe required namespace is not available... 😕#2017-11-0119:56thhellerif you can post the contents of the project I can take a look#2017-11-0120:01evekoI have it on local git only atm#2017-11-0120:02evekounless you don't mind opening a zip#2017-11-0120:02thhellersure that works#2017-11-0120:02thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2017-11-0120:03thhellerskip the node_modules and target folders, don’t need those 🙂#2017-11-0120:09evekohere you go#2017-11-0120:09evekoyou propably also don't want the microsoft packages 😛#2017-11-0120:09thheller
(ns techtest.app
    :require [reagent.cor :as r])
#2017-11-0120:09eveko...#2017-11-0120:09thhellerthats missing a ( before :require#2017-11-0120:09evekobloody#2017-11-0120:10evekodirt in my eyes#2017-11-0120:10evekoand typo at core as well#2017-11-0120:12thhellershould be#2017-11-0120:12thheller
(ns techtest.app
  (:require [reagent.core :as r]
            [clojure.string :as str]))
#2017-11-0120:13thhelleras the reagent example for some reason doesn’t have a proper require for clojure.string#2017-11-0120:13thhellerbesides that it looks ok#2017-11-0120:14evekoit still does not find the namespace though
#2017-11-0120:16evekoalso if it seems that the watch is trying to do something#2017-11-0120:17thhellerhmm yeah it doesn’t work on my machine as well … investigating#2017-11-0120:24thhellerhehe nice#2017-11-0120:24thheller
<U+FEFF>(ns techtest.app
  (:require [reagent.core :as r]
            [clojure.string :as str]))
#2017-11-0120:25thhellerthere is a bad character in front#2017-11-0120:26evekowhaat?#2017-11-0120:26thhellerI can’t rid of it in my editor#2017-11-0120:27evekobut I don't have that , why would there be font info?#2017-11-0120:27thhellerdunno, my editor doesn’t show it either#2017-11-0120:28thhellerlooking at it with less shows it (the linux tool, not the css thing)#2017-11-0120:29evekoindeed#2017-11-0120:30evekobut nano can't see it#2017-11-0120:31thhelleryeah I tried vscode, atom, intellij, vim, emacs#2017-11-0120:32thhellernot a single one is able to show or remove it#2017-11-0120:32thhellersuper weird#2017-11-0120:33thhellerhttps://stackoverflow.com/questions/7297888/0xef-0xbb-0xbf-character-showing-up-in-files-how-to-remove-them#2017-11-0120:33thhellervim -b app.cljs worked#2017-11-0120:36evekoi just made an other file#2017-11-0120:36evekocopied the contents#2017-11-0120:37evekodelete old and rename#2017-11-0120:38evekobut now it cannot find react#2017-11-0120:39thhellernpm install react react-dom#2017-11-0120:40evekocreate-react-class#2017-11-0120:40evekocan i just not yarn add react?#2017-11-0120:41thhelleryes yarn works too#2017-11-0120:42evekoit does but now I get namespace error for create-react-class#2017-11-0120:43thhelleralso yarn add create-react-class#2017-11-0120:43thhellerits a bit unfortunate how reagent is bundled currently, the alpha is a bit in flux and doesn’t properly declare some deps#2017-11-0120:43evekowoot done 😛#2017-11-0120:43evekoit compiled#2017-11-0120:44thhellerI “fixed” the watch issue … well it doesn’t error out anymore, but doesn’t update either 😉#2017-11-0120:46thhellernot quite sure why#2017-11-0121:03evekonow i need to figure out how to make https://asp.net serve the correct path for js#2017-11-0121:04evekoit is trying to find the other compiled js in the views folder#2017-11-0121:04evekobut they are in the public#2017-11-0121:05thhellerhmm no idea how that works in https://asp.net, never used it#2017-11-0121:05thhellershould be easy to just serve one directory, its just static files#2017-11-0121:06thhellerhttps://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files#2017-11-0121:06thhelleruse the public directory?#2017-11-0121:06evekofixed#2017-11-0121:06evekovery easy really#2017-11-0121:06thhellercool#2017-11-0121:07eveko:asset-path "../js"#2017-11-0121:07evekoin the edn#2017-11-0121:07thhellerbe careful with relative paths in JS#2017-11-0121:07thhellerif you try to do that in it won’t work#2017-11-0121:07evekoindeed#2017-11-0121:15evekoit adds the asset-path at the end of the url for the lookup#2017-11-0121:15evekowhy is that so?#2017-11-0121:16eveko/public/views/public/js/cljs-runtime/module$node_modules$fbjs$lib$getActiveElement.j#2017-11-0121:16evekoinstead of public/js/cljs-runtime/module$node_modules$fbjs$lib$getActiveElement.js#2017-11-0121:19thhellerhmm?#2017-11-0121:19thheller:output-dir and :asset-path sort of belong together#2017-11-0121:20thheller:asset-path is where the files are reachable when using a http server#2017-11-0121:20thhellerpublic all files from :output-dir must be reachable there#2017-11-0121:20thheller:asset-path should basically always be an absolute path#2017-11-0121:21thhellereverything else is just asking for trouble#2017-11-0121:22thhellerthe asp link about mentions a wwwroot? so maybe use :output-dir "wwwroot/js"?#2017-11-0121:22evekoi will have to check around,#2017-11-0121:23evekothat is for https://asp.net core#2017-11-0121:23thhellerbut I really don’t know .. the article looks like it should work if configured correctly#2017-11-0121:23evekoi am using .net framework.#2017-11-0121:23thhellerits just static files, not the typical “view”#2017-11-0121:23evekothat is so#2017-11-0121:24evekooh well i will tinker arround. the ../js will be my dirty temporary solution#2017-11-0121:24evekoshould work fine if i treat the project as a spa#2017-11-0122:30thheller@eveko just published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b4c7dcd5d0dbc399d7d8dec7f4869a849a8181"}, :content ("[email protected]")} which has fixes for all the obvious windows issues I could find#2017-11-0122:31thhellerreloading works properly now#2017-11-0122:31thhellerlet me know if you run into any other issues#2017-11-0208:20evekoGreat, will let you know if I find anything#2017-11-0210:23mhuebertany idea how one can resolve an issue like this:
[:browser] Build failure:
symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
{:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object-assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object.assign/index.js"]}
ExceptionInfo: symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.data/add-provide (data.clj:74)
	shadow.build.data/add-provide (data.clj:69)
	shadow.build.data/add-provides/fn--19031 (data.clj:87)
#2017-11-0210:24mhuebertthe module auth0 depends on object.assign (and I use that in my web build), while postcss-loader uses object-assign (not used in web build)#2017-11-0210:25thhellerhehe nice#2017-11-0210:26thhellerI can probably change the alias generator to account for that, guess google didn’t anticipate something like this#2017-11-0210:27thhellerwill take a look later#2017-11-0210:27thhellerbut if the postcss-loader isn’t used in the build why does it get resolved?#2017-11-0210:27thhellerseems like it is used somehow?#2017-11-0210:28mhuebertit’s in package.json as it is used for a build script,#2017-11-0210:28mhuebertbut it shouldn’t have anything to do with the shadow build#2017-11-0210:28thhellerdoesn’t matter if its in package.json#2017-11-0210:28thhellerit only matters if the dependency gets added to the build via some :require#2017-11-0210:29mhuebertok. i removed postcss entirely, lets see..#2017-11-0210:30thhellersuper weird that there are actually object-assign and object.assign packages#2017-11-0210:30mhuebertmaybe i am just not using auth0 properly#2017-11-0210:30mhuebertyeah i am using the node version#2017-11-0210:31mhuebertso it is requiring unfriendly things#2017-11-0210:32thhellerif the things are compatible#2017-11-0210:32thhelleryou can just :resolve {"object.assign" {:target :npm :require "object-assign"}} or the other way#2017-11-0210:35thhellerI’ll be back later …#2017-11-0210:38mhuebertusing auth0-js instead of auth0 package solved this thing in particular. but this clash could be a more general thing. I think the resolve option as you specify there might be ‘enough’. at some point down the chain, the dev has to manually resolve conflicts.#2017-11-0217:36thhellergood to know. dunno how common this issue might be. the potential for conflict exists and should probably be fixed nonetheless.#2017-11-0312:59evekohow does the compiled js go about referencing node modules?#2017-11-0313:01thheller:browser builds bundle the code#2017-11-0313:01thhellernode targets just use require#2017-11-0313:02evekoi am getting this error#2017-11-0313:04thhellerhmm#2017-11-0313:05thhellerno immediate idea#2017-11-0313:05evekoI thought maybe it could have been that the js has no access to the node modules#2017-11-0313:06evekoas https://asp.net core only serves the wwwroot directory to the public#2017-11-0313:06thhellernah its all bundled into the <output-dir>/cljs-runtime/... directory#2017-11-0313:06thhellerand you’d get an error if something failed to load there#2017-11-0313:07thhellerdo you get any other errors in the browser console?#2017-11-0313:07thhellerthere should be a <output-dir>/cljs-runtime/module$node_modules$create_react_class$index.js file#2017-11-0313:08evekoindeed#2017-11-0313:08evekoit is there#2017-11-0313:08evekoi can even browse to it from the sources in the console#2017-11-0313:08evekothis is the full error#2017-11-0313:11thhellercan you paste the first few lines of <output-dir>/cljs-runtime/reagent.impl.component.js?#2017-11-0313:11thhellershould have goog.provide and goog.require + shadow.js.require#2017-11-0313:12evekoonly see goog ones#2017-11-0313:12evekonot shadow js#2017-11-0313:13thhellerstrange#2017-11-0313:15thhellerok, its missing for me too#2017-11-0313:15thhellerlooking into it#2017-11-0313:17thhellerwhich part of reagent are you using?#2017-11-0313:18thhellerthis works just fine https://mhuebert.github.io/shadow-re-frame/#2017-11-0313:18thhellerwell I guess the create-class fn#2017-11-0313:20evekoi am trying to make the simple example to work#2017-11-0313:20evekohttps://github.com/reagent-project/reagent/blob/master/examples/simple/src/simpleexample/core.cljs#2017-11-0313:22thhellerstrange, I used that exact example when testing myself#2017-11-0313:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/reagent.cljs#2017-11-0313:23thhellerbut yeah its broken#2017-11-0313:23thhellerwill fix#2017-11-0313:23thhellerI think I know why …#2017-11-0313:24thhelleryep .. those darn symbols … fixing …#2017-11-0313:49thheller@eveko fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d8abb0b9bcb7aff5bbb4b2ab98eaf6e8f6edee"}, :content ("[email protected]")}#2017-11-0313:51thhellerwonder how https://mhuebert.github.io/shadow-re-frame/ worked without running into that 😛#2017-11-0314:58evekoblack magic?#2017-11-0315:04evekocheers it works#2017-11-0316:14thheller@mhuebert you have used (set! *warn-on-infer* true) before. do you think it would be useful to always enable that for files with JS requires?#2017-11-0316:14thhellercurrently fixing it for shadow-cljs and removing a few false positives so it should be more reliable#2017-11-0319:45mhuebert@thheller I find these instructions (from https://clojurescript.org/guides/externs#externs-inference) a bit confusing:
However this alone isn't enough to have the compiler generate warnings around externs. Because of the large number of libraries written before this feature existed, we cannot enable this capability in a global way. Instead there is a new file local compiler flag *warn-on-infer* which is somewhat analogous to *warn-on-reflection* in Clojure. Once set the compiler will warn for the remainder of the file anytime it cannot determine the types involved in a dot form, whether property access or method invocation.
#2017-11-0319:46mhuebertfrom that, I understood that somehow enabling :infer-externs is not enough, and I also had to put *warn-on-infer* in my files to enable the inference#2017-11-0319:46mhuebertI think I’d like inference to happen automatically on all my projects where I import JS stuff (unless there are tradeoffs i’m not aware of)#2017-11-0319:48mhuebertso I am not entirely sure if I understand the question 🙂#2017-11-0320:09thhelleryeah basically what you said#2017-11-0320:09thhellercurrently you need to enable it once per file#2017-11-0320:09thhellerwhich I find annoying as well#2017-11-0320:09thhellerbut enabling it for everyhing may cause too many warnings#2017-11-0320:10thhellerdunno yet, I get like 600 warnings if I enable it for cljs.core#2017-11-0320:11thhellerso I though I just set the *warn-on-infer* for every file with a JS import#2017-11-0320:11thheller*warn-on-infer* was broken until today but now you’ll get proper warning again#2017-11-0321:14mhuebertSo just to confirm, does warn-on-infer only affect warnings or also extern generation?#2017-11-0407:52thhellerboth kinda, it will not generate any externs for everything it warns about#2017-11-0407:53thhellerbut things it doesn’t warn about will be generated#2017-11-0407:53thhellerregardless of warn-on-infer#2017-11-0411:38mhuebertAre there things it will generate externs for silently, but then not generate with warn-on-infer?#2017-11-0411:39mhuebertI guess the thing to avoid is a setting that could cause warnings to replace extern-generation on namespaces the user doesn't control?#2017-11-0411:59thhellerthe only bad thing *warn-on-infer* can do is cause too many warnings#2017-11-0411:59thhellerand it can generate LOTS of warnings, 600+ in cljs.core alone#2017-11-0411:59thhellerthat is after I tweaked it a lot, 1000+ before#2017-11-0412:00thhellerI guess enabling it be default would push more people towards tagging with ^js#2017-11-0412:00thhellerthe only problem is that sometimes the ^js tag is incorrect and should actually be tagged as ^clj#2017-11-0412:01thhellerwell .. rather rarely actually so it should be ok#2017-11-0412:02thhellerdunno .. I will leave it manual for now, maybe add a config option later that defaults to false at first#2017-11-0413:13thheller@mhuebert I just added shadow-cljs pom which IntelliJ/Cursive can import. basically the same as writing the “fake” project.clj. still better to use project.clj if you want to publish libs and such though.#2017-11-0413:24mhuebertExcellent!#2017-11-0514:31mhuebertpom.xml seems to work well#2017-11-0514:31mhueberti see some new infer-externs warnings that I didn’t before. Not sure what to do about these defprotocol warnings:
------ WARNING #3 --------------------------------------------------------------
 File: re_view/hiccup/core.cljs:14:1
--------------------------------------------------------------------------------
  10 |     js/Symbol
  11 |     (-pr-writer [sym writer _]
  12 |       (-write writer (str "\"" (.toString sym) "\"")))))
  13 |
  14 | (defprotocol IElement
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. this re-view$hiccup$core$IElement$to-element$arity$1 this)
--------------------------------------------------------------------------------
  15 |   (to-element [this] "Returns a React element representing `this`"))
  16 |
  17 | (defprotocol IEmitHiccup
  18 |   (to-hiccup [this] "Returns a hiccup form representing `this`"))
  19 |
source: https://github.com/braintripping/re-view/blob/master/re_view/src/re_view/hiccup/core.cljs#L14
#2017-11-0514:33thhellerI’m working on that currently#2017-11-0514:34mhuebertalso
------ WARNING #6 --------------------------------------------------------------
 File: re_view/hiccup/core.cljs:34:9
--------------------------------------------------------------------------------
  30 |             (println form)
  31 |             (.error js/console e)))
  32 |
  33 |
  34 |         (satisfies? IElement form)
---------------^----------------------------------------------------------------
 Cannot infer target type in expression (. form -re-view$hiccup$core$IElement$)
--------------------------------------------------------------------------------
  35 |         (to-element form)
#2017-11-0514:34thhellerdefprotocol, defrecord, deftype all generate bad warnings#2017-11-0514:34thhelleryeah implements? satisfies? as well#2017-11-0514:34mhuebertok#2017-11-0514:34thheller(list) as well#2017-11-0514:35thhellerits a lot more work than I anticipated#2017-11-0514:35mhuebertfor something like this:
41 |         (reduce (fn [out el]
  42 |                   (doto out (.push (-to-element el)))) #js [] form)
-----------------------------------^--------------------------------------------
 Cannot infer target type in expression (. G__33183 push (-to-element el))
--------------------------------------------------------------------------------
can ^js annotations go inline, like (.push ^js (-to-element el)) or would implementations of -to-element need to be annotated
#2017-11-0514:35thhellerguess thats why David didn’t work on it for a year 🙂#2017-11-0514:35mhuebert🙂#2017-11-0514:36thhellerwhats -to-element?#2017-11-0514:36thhellerinline should be fine, but you need to do it every time#2017-11-0514:36thhellerwould be better to annotate -to-element once#2017-11-0514:37thhellerah wait no#2017-11-0514:37thheller(doto ^js out (.push (-to-element el))))#2017-11-0514:37thhellerneed to annotate the out not the -to-element#2017-11-0514:37mhuebertthere is an IElement protocol with a -to-element method#2017-11-0514:37mhuebertah right..#2017-11-0514:49mhuebertso all the js (as opposed to clj-related) warnings were straightforward to fix#2017-11-0514:55thhellerfor the others I have to touch sooooo much code since its all generated all over the place#2017-11-0514:55thhellerI kinda want to create one function to create the proper symbol and re-use that everywhere#2017-11-0514:56thhellercljs.core changes are scary 🙂#2017-11-0515:23thheller
(deftype ShouldNotWarnAboutInfer [foo bar]
  Object
  (yo [x])

  ILookup
  (-lookup [this key]
    ::fake))
#2017-11-0515:23thhellerI’m unsure what to do about the things on Object#2017-11-0515:23thhellersometimes you want externs for those … sometimes you don’t#2017-11-0515:24thhellereg. implementing shouldComponentUpdate or so#2017-11-0515:24thhellervs something you just use in your own code#2017-11-0515:53mhueberthmm. what is default behaviour?#2017-11-0610:42thheller@mhuebert I think I covered most cases for externs inference now. if you can please test {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c3506746876687076"}, :content ("[email protected]")}.#2017-11-0610:43thhelleradded :infer-externs :auto to turn it on for every file in the project itself#2017-11-0610:43thhellertrue still requires the (set! *warn-on-infer* true), :auto just does it for files (not jars), :all for everything but thats not safe#2017-11-0610:44thhellerit also no longer warns about any properties already defined in externs#2017-11-0610:44thhellerso you could probably remove a whole bunch of annotations you already did#2017-11-0610:44thhellereg. (doto ^js out (.push (-to-element el)))) this doesn’t need to be annotated anymore since .push is defined in Array externs#2017-11-0612:08evekoHow can I reference npm deps in my cljs?#2017-11-0614:12mhuebert@thheller I really like the idea of these obvious cases (like .push) being taken care of#2017-11-0614:15mhuebertI am getting this error:
-> Closure - Optimizing ...
IllegalArgumentException: Don't know how to create ISeq from: com.google.javascript.jscomp.SourceFile$Preloaded
	clojure.lang.RT.seqFrom (RT.java:550)
	clojure.lang.RT.seq (RT.java:530)
	clojure.core/seq--5124 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--7829 (protocols.clj:75)
	clojure.core.protocols/fn--7829 (protocols.clj:75)
	clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
	clojure.core/reduce (core.clj:6748)
	clojure.core/into (core.clj:6815)
	clojure.core/into (core.clj:6807)
	shadow.build.closure/load-externs (closure.clj:392)
#2017-11-0614:16mhuebertand can confirm it happens in 2.0.60. when i reverted to 2.0.59, it kept happening until I deleted target#2017-11-0614:38thheller@mhuebert oops, fixen in 2.0.61#2017-11-0614:39thheller@eveko usually you need to first install the dependency via npm, say npm install thing. then in your (ns your.app (:require ["thing" :as thing]))#2017-11-0614:40thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#using-js-dependencies#2017-11-0614:40thhellerhas a short info how to translate require/import from JS#2017-11-0614:41evekoI have been trying to get blueprint to work, but can't get it to import into the ns#2017-11-0614:41thhellerimport { Intent, Spinner, DatePickerFactory } from "@blueprintjs/core";#2017-11-0614:41thhellerthis?#2017-11-0614:42evekofor example#2017-11-0614:42thheller(:require ["@blueprintjs/core" :as bp :refer (Intent Spinner)])#2017-11-0614:43thhellersome packages are weird and cause errors on imports, I want to know about those#2017-11-0614:43thhellerotherwise it should just work#2017-11-0614:44thhellercan also use bp/Intent, no need to use the :refer#2017-11-0614:44evekoIn my case I want to fiddle with components#2017-11-0614:44eveko(def button (r/adapt-react-class js/bp.ButtonFactory))#2017-11-0614:44thhellerwithout js/#2017-11-0614:44thhellerbp/ButtonFactory#2017-11-0614:45thhellerassuming you have bp used as :as#2017-11-0614:45evekonow I get at least a usefull error#2017-11-0614:45evekonow that ns is correct#2017-11-0614:46evekomissing js librarys#2017-11-0614:47evekook build succed now time to run the server and see if reagent manages to do anything remotely sane#2017-11-0614:57thheller@dustingetz you ask tough questions 🙂 you could probably look at https://github.com/lambdaisland/npmdemo to get a glimpse of whats different#2017-11-0614:57thhellerthat has config for all the build tools and shadow-cljs is among them#2017-11-0614:57thhellerI like to stay away from directly comparing to other tools myself since I haven’t used any of them#2017-11-0614:59evekobtw the live reloading plays real nice with dotnet core#2017-11-0614:59thhellerI’ll write a more thorough answer on reddit#2017-11-0614:59thhellernice, good to know#2017-11-0615:04Dustin Getzthank you#2017-11-0615:19thheller@dustingetz I also wrote https://code.thheller.com/blog/shadow-cljs/2017/09/15/shadow-cljs-introduction.html which covers some of the rationale#2017-11-0620:09thhellerI started putting together a quickstart for shadow-cljs recently https://github.com/shadow-cljs/quickstart-browser#2017-11-0620:09thhellerwhat do you think is easier for beginners? should I just stick with the command line or use the REPL?#2017-11-0620:10thheller(shadow/watch :app) vs npx shadow-cljs watch app#2017-11-0620:10thhellerI feel like using both in the same example might be too confusing#2017-11-0620:32mitchelkuijpersDamn just tried out shadow-cljs for the first time. I wanted to consume certain npm-modules which I never got working with the new npm-deps stuff. And I just tried it out with shadow-cljs and it somehow just works! Pretty damn cool#2017-11-0620:33thhellernice to hear 🙂#2017-11-0620:33mitchelkuijpersI do have one question about the release task does it use advanced compilation? Because it does not see to me that it does#2017-11-0620:34thhellerit depends on the :target you are using. :browser defaults to :advanced, the node targets default to :simple#2017-11-0620:35thhellerbut since most stuff from npm doesn’t work with :advanced it will only use :simple for that#2017-11-0620:35thhellerso you are getting both basically#2017-11-0620:35mitchelkuijpersAh so if you add npm-deps it will use simple for everything or only for the node deps and then the rest with advanced?#2017-11-0620:36thhellersimple for node deps only, advanced for CLJS+Closure#2017-11-0620:36mitchelkuijpersDamn that is cool#2017-11-0620:36thhelleryou can also try advanced for everything by setting :js-options {:js-provider :closure} but as you experienced that doesn’t work all too well 😉#2017-11-0620:37mitchelkuijpersVery true, right now we have some webpack build and then we add stuff to window which I hate so this is already 1000 times better#2017-11-0620:41thhellerfrom a technical perspective I pretty much do the same thing webpack does, just better integrated 😉#2017-11-0621:12mitchelkuijpersStill love not having two tools ^^#2017-11-0622:40thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html#2017-11-0622:40thhellerblogged about the externs work I did the last few days#2017-11-0709:57mhuebertdo bad things happen if the watch loop is tightened to <500ms? (https://github.com/thheller/shadow-cljs/blob/1cf72884ac7ef0da51d4cdc7ada55fc78a5dd77f/src/main/shadow/cljs/devtools/server/fs_watch.clj#L42)#2017-11-0709:58thhellerCPU usage goes up#2017-11-0709:58thhellerbut that delay typically doesnt matter much#2017-11-0709:59thhellerhttps://github.com/thheller/shadow-cljs/blob/1cf72884ac7ef0da51d4cdc7ada55fc78a5dd77f/src/main/shadow/util/FileWatcher.java#L47#2017-11-0709:59thhellerthis matters more and thats the highest it will go#2017-11-0709:59thhellerit is 2 sec on OSX#2017-11-0710:01thhellerdo you think the delay is too much?#2017-11-0713:52denikThe hot loading delay is one of my biggest pains developing web apps in cljs. Is there a on-save hook you can expose? Editor integrations could hook into that. It should also cause a massive speed increase by only reevaluating the forms that changed (as we would through repl).#2017-11-0714:39denikMy current workaround is a fn like
(defn with-reload [& _]
  (my-app.frontend.core/mount-root))
that I wrap components I’m editing with and simply eval the top level form:
(with-reload
 (defn my-comp []
   [:div "abc"]))
This hack that saves me a lot of time during dev. Almost browser dev-tools-like responsiveness.
#2017-11-0714:46thhellerI could easily expose a hook that the editor could call.#2017-11-0714:46thhellerI did some related work with the Language Server Protocol a while back#2017-11-0714:46thhellerhttps://github.com/thheller/shadow-cljs/issues/2#2017-11-0714:47thhellerthe proof of concept did exactly that. on file save inform the compiler and have the compiler return compile information so the editor can show warnings/errors#2017-11-0714:48thhellerLSP is a lot of work, if you just want a file-save hook I can probably add something http-ish where you post some data about which files were saved?#2017-11-0714:48thhellerpartial compile is tricky, not sure how to do that#2017-11-0715:34denikThanks theller! Looks like the on-save hook is low-hanging fruit and editor agnostic. Please add it!#2017-11-0715:35thhellerwhat do you need? I’m not aware of any editor that already has a hook for that#2017-11-0715:36denikthis https://clojurians.slack.com/archives/C6N245JGG/p1510065994000488?thread_ts=1510048862.000248&amp;cid=C6N245JGG#2017-11-0715:36thhelleryes but in what shape 🙂#2017-11-0715:36thhellerhttp endpoint you can curl? do you have EDN support or would JSON be simpler? or just one line per file saved?#2017-11-0715:37denikhmm, don’t know much about the workings of editor extensions#2017-11-0715:37thhellersame here 😛#2017-11-0715:37denikemacs and cursive are probably the two major editors with vim and vscode in the back#2017-11-0715:38denik@U0567Q30W thoughts?#2017-11-0715:41thhellerI went down this rabbit hole a while ago https://twitter.com/krisajenkins/status/811930122014093312 😉#2017-11-0715:44thhellerIn cursive you can connect to the shadow nrepl and send (shadow.cljs.devtools.api/compile :my-build) to the REPL on keypress#2017-11-0715:44thhellermaybe the closest thing already available#2017-11-0715:45thhellerbut triggers a full build, watch is faster since it maintains some state#2017-11-0715:47denikI agree. This is more about removing latency for UI code. Chrome devtools is instant. The editor knows exactly when files are edited, and most editors know which files were edited. This allows us to get rid of the whole file-watching process, which should enable major improvements in reload speed.#2017-11-0715:48denikRegarding compile per form, that’s essentially like top-level-form repl eval. Editors know the top level forms of files. So between saves, we could track all edited forms and compile them one by one. I think this will enable immense speed improvements.#2017-11-0715:49thhellerwell you can just use the REPL to eval the form you changed#2017-11-0715:51denikthat’s what I’m doing with the snippet above. As you can see it takes some wrapping, because we also want to call the reload-hook for the app to re-render the root ui component#2017-11-0715:55denikIt’s puzzling for me that compile times of entire projects are used as a significant measure when the major road blockers for DX lie in the waits between incremental compilation steps. It’s a bit like starting a clojure repl. It’s slow but the idea is that it will run forever. Once it’s up, it’s blazingly fast. In the long run, that’s what matters.#2017-11-0716:01thhellerI think its a tooling issue. You can bind “reload-my-app” to a button in Cursive, which just sends the proper function call to the REPL#2017-11-0716:02thhellerI have that for all my clojure setups, in CLJS live-reload+watch is usually good enough for me.#2017-11-0716:02thhellerbut yeah clojure I do just about everything at the REPL#2017-11-0717:27denik@U050RLRRQ and I discussed this. In his terms what’s needed is a) form-level change tracking and b) maintaining a dep graph per var. For forms without vars it could have get assigned an unique identifier in a). Instead of save, a keyboard shortcut evals all edited forms. Lastly, a after-eval hook reloads the app. Yes, if the hooks are available, both are tooling features. cc @U0567Q30W#2017-11-0717:27mhuebertyeah this seems pretty involved#2017-11-0717:28mhuebertwe’re looking at doing it in maria, that’s a much more controlled environment#2017-11-0717:33thhellerI usually just load-file when I make changes in a file. clojure again though, it might be slower in CLJS.#2017-11-0719:18denik@thheller yes it’s much slower. I’m glad we’re starting this conversation. Sometimes the hardcore tool developers are not the hardcore users. I’m glad we’re having the opportunity to share perspectives.#2017-11-0720:42thhellerI’m a hardcore user that just got fed up with the tools 😉#2017-11-0720:58denik🙂 then you must know the pain of 8+ secs between incremental compilations#2017-11-0721:15thhellernot really, its very rarely this slow. shadow-cljs handles this slightly differently and only recompiles files that changed and those that directly required it.#2017-11-0721:16thhellerwhen I’m working on a framework level thing thats used in a whole lot of places I usually isolate the thing I’m working on because the usual “app” would just be annoying at that point#2017-11-0721:17thhellerso my live-reloads are usually less than 1sec#2017-11-0710:01thhellerI thought about replacing it with something faster before#2017-11-0710:01thhellerunfortunately everything I looked at consumed a whole lot more CPU (which translates to battery)#2017-11-0710:52thhellerfigwheel uses https://github.com/wkf/hawk, no idea if that is faster?#2017-11-0713:56denikfigwheel is similarly slow. With large projects I had waits of 8+ seconds. Possibly because the cljs compiler has :recompile-dependents true by default, but it could also just be recompiling all the project-owned namespaces required in the files that changed. For UI development, this is very painful.#2017-11-0710:52thhellerits only slow OSX, windows/linux are pretty fast#2017-11-0710:52thhellerI think hawk fixes it for OSX#2017-11-0712:17mhuebertnot a huge deal but am curious how it would feel to be faster. currently working on a thing where a typical incremental compile is 0.4-0.5s, changes appear to show up on average 1.5s#2017-11-0712:57thhelleryeah I also sometimes feel like it could be faster#2017-11-0712:57thhellerlooking at the browser and nothing happens, switching back only to realize I wasn’t patient enough
#2017-11-0712:58thhellerthat surprised me when testing on windows the other day. it felt pretty much instant there.#2017-11-0713:12mitchelkuijpersHow do people here work with libraries like for example om which need cljs.react and when you use npm-deps which needs react?#2017-11-0714:39thheller@mitchelkuijpers see https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#breaking-change-removing-foreign-libs-support#2017-11-0714:41thhellermore examples here https://github.com/mhuebert/shadow-re-frame/tree/master/src/cljsjs#2017-11-0715:04thhellerusing hawk is pretty straightforward and actually a whole lot faster (on OSX, did’t test others yet)#2017-11-0715:04thhellerbut it doesn’t seem to detect deleted files#2017-11-0715:05thhellernot super critical though. I might just add a config option to switch between the two mechanisms#2017-11-0715:14mitchelkuijpersAh ok thnx let me see if I can fix this#2017-11-0715:16mhuebertthat sounds great#2017-11-0715:18mitchelkuijpersThat works like a charm thnx @thheller#2017-11-0715:20thhellerjust pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "73001b12171c045e101f190033415d435d4541"}, :content ("[email protected]")} which uses hawk to watch files#2017-11-0715:20thhellerit definitely reacts way faster on OSX#2017-11-0715:21thhelleradded a 250ms delay … could reduce that even further#2017-11-0715:22thhellerbut I think this is good enough while providing some safety that batch saves do not trigger 2 separate compiles#2017-11-0715:22thhellerI also made a small compiler improvement earlier today which should make it about 20% faster overall#2017-11-0715:23thhellerbut that needs more benchmarks to confirm#2017-11-0715:44mitchelkuijpersAnyone else ran into: The required namespace "com.rpl.specter.navs" is not available, it was required by "com/rpl/specter.cljc". I found this issue https://github.com/nathanmarz/specter/issues/72 but i don't run bootstrapped clojurescript#2017-11-0715:45thhellerI have a suspicion#2017-11-0715:46mitchelkuijpersIt only happens when I do compile instead of watch#2017-11-0715:47thhellernah it doesn’t work because of the ns form#2017-11-0715:48thhellerI have my own ns parser in shadow-cljs and it is a bit too strict#2017-11-0715:48thhellerhttps://github.com/nathanmarz/specter/blob/master/src/clj/com/rpl/specter/navs.cljc#L8-L9#2017-11-0715:49thhellerthis ends up as (:use) for CLJS, which my parser thinks is invalid#2017-11-0715:52mitchelkuijpersAh you have your own parser for the nice error messages?#2017-11-0715:56thhellerI have my own because the default is pretty hard to work with, less painful to write a custom one.#2017-11-0715:56mitchelkuijpersAh ok#2017-11-0715:58thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "91e2f9f0f5fee6bcf2fdfbe2d1a3bfa1bfa7a2"}, :content ("[email protected]")}#2017-11-0715:58mitchelkuijpersDamn you are fast#2017-11-0715:59thhellerhttps://github.com/thheller/shadow-cljs/commit/80b2088b254f32268335a1cd9bd84c2fb88910ac#diff-4854048b5b3aaa5a299c24106ff2baa9#2017-11-0715:59thhellerchange + to *, easy fix 😉#2017-11-0716:00mitchelkuijpersaw_yeah#2017-11-0716:12mitchelkuijpersWorks!#2017-11-0716:23mitchelkuijpersThe only thing I have now is that I have a lot of cljs.pprint warnings is that normal or am I screwing up?#2017-11-0716:23thhellerwhat kind of warnings?#2017-11-0716:25mitchelkuijpers
------ WARNING #40 -------------------------------------------------------------                                                          
 File: cljs/pprint.cljs:3144:3                                                                                                            
--------------------------------------------------------------------------------
3140 | ;;; This is the equivalent of (formatter-out "~:<
#2017-11-0716:25mitchelkuijpersNot sure if it's a derp from me#2017-11-0716:26thhellerhmm never seen those before#2017-11-0716:26thhellerI don’t get them either#2017-11-0716:26mitchelkuijpersI run from withing leiningen I'll investigate some more#2017-11-0716:27mitchelkuijpersMaybe I have a an old clojurescript or something weird#2017-11-0716:28mitchelkuijpersShould I not add clojurescript dep myself and rely on shadow-cljs?#2017-11-0716:28thhelleryes, and try adding shadow-cljs first so its deps get picked up first#2017-11-0716:28thhellerbetter yet, don’t use it with lein 😉#2017-11-0716:29mitchelkuijpersHmm does that work if you have macros serverside?#2017-11-0716:29thhellertry lein deps :tree and see what it complains about#2017-11-0716:29thhelleryes, shadow-cljs uses the JVM compiler.#2017-11-0716:29mitchelkuijpersYeah I already fixed a lot of issues there, but maybe not running from lein will be nicer#2017-11-0716:30thhellernot a clue what could be causing those warnings#2017-11-0716:31mitchelkuijpersYeah I saw a conflict about the shaded closure compiler#2017-11-0716:31thhellerthats not involved in here#2017-11-0716:32thhellerat least I can’t think of a reason why it would be. clojurescript version will have an impact but since everything else seems to work …#2017-11-0716:34thhellerdo you have a REPL open? try ( "cljs/pprint.cljs") and see if thats from 946#2017-11-0716:34thhelleralso check ( "cljs/pprint.cljc") just in case#2017-11-0716:35mitchelkuijpersI saw I had two profiles with different shadow-cljs deps, maybe that is the issue#2017-11-0716:36mitchelkuijpersI think I am going to try without leiningen, that will probably save me lots of time#2017-11-0716:37thhelleris lein deps :tree this bad? shouldn’t be too bad#2017-11-0716:37thhellerits a bit painful to use shadow-cljs for CLJS and lein for CLJ when using Cursive#2017-11-0716:38thhellersince cursive only reads the project.clj#2017-11-0716:39thhellerI use lein myself when developing shadow-cljs itself, so it definitely works fine#2017-11-0716:39thhellerjust conflicts are bad 😛#2017-11-0716:40mitchelkuijpersHmm even without leiningen I get the same errors#2017-11-0716:40mitchelkuijpersWtf#2017-11-0716:40thhellerwhat are you doing with cljs.pprint?#2017-11-0716:40mitchelkuijpersI thinkg nothing:#2017-11-0716:41mitchelkuijpersI get this errors while it is trying to build:#2017-11-0716:41thheller(:require [cljs.pprint :refer (pprint)]) (pprint {:x [1 2 3]}) definitely works#2017-11-0716:41mitchelkuijpers
Nov 07, 2017 5:39:45 PM clojure.tools.logging$eval347$fn__350 invoke                                                                                                                                                                                                                                                                                                       
WARNING: failed to get source excerpt for jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs at {:warning :dynamic, :line nil, :column nil, :msg "js/cljs.pprint.*current-length* not declared ^:dynamic", :extra {:ev {:name js/cljs.pprint.*current-length*, :tag js, :ret-tag js, :ns js}, :name js/clj
s.pprint.*current-length*}}                                                                                                                                                                                                                                                                                                                                                
java.lang.NullPointerException                                                                                                                                                                                                                                                                                                                                             
        
#2017-11-0716:42mitchelkuijpersAnd then all the warnings start popping up#2017-11-0716:43thhellerhow are you calling pprint?#2017-11-0716:44mitchelkuijpers
[cljs.pprint :refer [pprint]]
#2017-11-0716:44mitchelkuijpersthat is the require#2017-11-0716:44thhellerO M G#2017-11-0716:45thheller…. I think I found it#2017-11-0716:45thhellerhmm no wait#2017-11-0716:46thheller/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs it is using the correct file#2017-11-0716:46thhellerand your require is correct#2017-11-0716:48mitchelkuijpersI thind these very weird warnings:
Nov 07, 2017 5:46:55 PM clojure.tools.logging$eval347$fn__350 invoke                        
WARNING: failed to get source excerpt for jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs at {:warning :dynamic, :line nil, :column nil, :msg "js/cljs.pprint.*current-length* not declared ^:dynamic", :extra {:ev {:name js/cljs.pprint.*current-length*, :tag js, :ret-tag js, :ns js}, :name js/clj
s.pprint.*current-length*}}                                                     
java.lang.NullPointerException                                                               
        at clojure.lang.Numbers.ops(Numbers.java:1018)                          
        at clojure.lang.Numbers.minus(Numbers.java:137)                               
        at clojure.lang.Numbers.minus(Numbers.java:3717)                              
        at shadow.build.warnings$get_source_excerpts$make_source_excerpt__20342.invoke(warnings.clj:28)
        at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349$fn__20350$fn__20352.invoke(warnings.clj:43)
        at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349$fn__20350.invoke(warnings.clj:42)
        at shadow.build.warnings$get_source_excerpts$iter__20344__20348$fn__20349.invoke(warnings.clj:41)
#2017-11-0716:48thhellerdo you get any warnings on startup?#2017-11-0716:48thhellerjust run shadow-cljs clj-repl nothing else#2017-11-0716:49thhellerdoes that print a whole bunch of warnings?#2017-11-0716:49mitchelkuijpersI run it like this btw: node_modules/.bin/shadow-cljs clj-repl does that matter?#2017-11-0716:49mitchelkuijpersI have no warnings#2017-11-0716:49thhellerno thats ok, try npx shadow-cljs clj-repl, same thing but shorter 😉#2017-11-0716:50thhellerhmm#2017-11-0716:50mitchelkuijpersAh cool dit not know that#2017-11-0716:50mitchelkuijpersbut that works#2017-11-0716:52thhellerso on the clj-repl (shadow/compile :build-id {:verbose true})#2017-11-0716:53thhellerissues like this one https://github.com/braintripping/re-view/issues/8 used to cause trouble in the past#2017-11-0716:54thhellerbut I added warnings for that#2017-11-0716:55thhellerI’m really clueless#2017-11-0716:56mitchelkuijpersI see no weird things in the output#2017-11-0716:56thhellerI don’t know how it would get into this :line nil, :column nil situation (which causes the NPE)#2017-11-0716:57thheller( "cljs/core.cljc")#2017-11-0716:57mitchelkuijpers
HED] cljs/tools/reader/edn.cljs                                                       
[CACHED] cljs/reader.cljs                                                                 
[CACHED] cljs/tagged_literals.cljc                                              
[CACHED] cljs/analyzer.cljc                                                      
[CACHED] cljs/analyzer/api.cljc                                                             
[CACHED] om/next.cljc                                                                                                                                                                                                                                                                                                                                                      
-> Compile CLJS: cljs/pprint.cljs                                                           
<- Compile CLJS: cljs/pprint.cljs (2208 ms)                                             
[CACHED] fulcro/client/logging.cljc                                             
[CACHED] yahoo/intl_messageformat_with_locales.cljs                                          
[CACHED] fulcro/i18n.cljc                                                          
[CACHED] clojure/walk.cljs    
#2017-11-0716:57thhellerwhat does that say?#2017-11-0716:57mitchelkuijpers#object[java.net.URL 0x62f11ebb "jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljc"]#2017-11-0716:58thhellerok, so the cljs sources are definitely correct#2017-11-0716:58mitchelkuijpersI am using om.next could that break something?#2017-11-0716:58thhellerit shouldn’t. let me try. which version?#2017-11-0716:59mitchelkuijpers [org.omcljs/om "1.0.0-beta1" :exclusions [cljsjs/react-dom cljsjs/react org.clojure/clojurescript]]#2017-11-0717:03thhellercompiles fine, no warnings#2017-11-0717:04thhellertry nuking the target/shadow-cljs directory, maybe somehow the cache got corrupted#2017-11-0717:04thhellerI have no other explanation at this point#2017-11-0717:05mitchelkuijpersNo problem, I have to go will play some more with it#2017-11-0717:10mitchelkuijpersThank you for all the help though#2017-11-0717:12mitchelkuijpersNuking the cache does not help btw#2017-11-0717:12mitchelkuijpersI'll try to reproduce with a smaller example#2017-11-0717:12thhellerthats really weird. I have no clue at this point.#2017-11-0717:28Jonran into a new problem. Code works in watch mode, but throws error after release build Uncaught Error: No protocol method ISwap.-swap! defined for type object: [object Object] in http://repo.tiye.me/mvc-works/coworkflow/#2017-11-0717:30Jonprobably problem in my code, but unfriendly error message...#2017-11-0717:31thhellerno warnings during compile?#2017-11-0717:32JonI think I've located the bug, not shadow-cljs' fault..#2017-11-0717:32Jonhowever I had a bug in my build script and accidentally loaded "lib.js" twice, but without "main.js"#2017-11-0717:33Jonconfirmed..#2017-11-0717:33Jonjust can't relate this error message to my problem 😅#2017-11-0717:34JonBTW are we going to use https://github.com/shadow-cljs now?#2017-11-0717:35thhellerprobably not for the project itself. I just needed a place to put the example.#2017-11-0717:36thhellerI want to write a proper guide for it but that isn’t going very well#2017-11-0717:36Jontoo many features to tell?#2017-11-0717:40thhellernot knowing what to tell. I have no idea which things need explaining, in which order, etc.#2017-11-0717:41thhellerI also don’t like blogging, I much rather write code. 😉#2017-11-0717:44Jonfor me shadow-cljs has covered nearly all my basic needs(except for dynamic import and CSS bundling) at currently. blogging won't help very much.#2017-11-0717:44Jonmaybe other will, though..#2017-11-0717:45thhellergotta go, bbl#2017-11-0717:45thhellerdunno what you mean by “dynamic import”. feel free to explain, I can take a look later.#2017-11-0717:46JonI would like to learn your updates from Twitter(messages on slack also fine). I would reply to ask anyway when I want to learn more about the feature, as long as I know shadow-cljs supports it.#2017-11-0717:47Jonhttps://webpack.js.org/guides/code-splitting/#dynamic-imports actually I barely use it since my cljs projects are not large enough, just nice-to-have, my app always grows.#2017-11-0717:47Jonbye#2017-11-0720:41thhellerthats whats shadow.loader does, but you need to do it statically. I’m not convinced the dynamic approach is good. Might be doable though.#2017-11-0802:21JonI don't think dynamic import is a perfect solution either. Just sometimes sites go too large, no other solutions left.#2017-11-0802:21Jonhttps://twitter.com/jiyinyiyong/status/926461618015281153#2017-11-0802:21Jonhttps://twitter.com/jiyinyiyong/status/927935319206514689#2017-11-0806:51thheller@jiyinyiyong I thing :modules and shadow.loader are pretty good solutions for this but ultimately it is up to the developer of each app#2017-11-0810:57Jonagreed. just as I said, I have to make sure it doesn't break filename hashing#2017-11-0806:52thhellerif your app requires 3mb JS to even run you are doing it wrong. splitting it into smaller parts that then get loaded “dynamically” but still all need to be loaded for your app to work is basically the same as loading everything at once.#2017-11-0806:54thhellerin my experience the best optimization is using <script src="..." async> or defer. together with <link rel="preload"> (or h2 push) to let the browser start the download early.#2017-11-0806:54thhellerif you have a blocking script you are doing it wrong#2017-11-0809:11mhuebertI’m getting this build error when evaluating things in a cljs REPL, and then saving the same file:
[:browser] Build failure:
symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]
{:provide re-view.hiccup.core, :conflict [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], :resource-id [:shadow.cljs.repl/resource re-view.hiccup.core]}
ExceptionInfo: symbol re-view.hiccup.core already provided by [:shadow.build.classpath/resource "re_view/hiccup/core.cljs"], conflict with [:shadow.cljs.repl/resource re-view.hiccup.core]
#2017-11-0809:22thhellerhmm interesting#2017-11-0809:24thhellerah you are using watch combined with the REPL?#2017-11-0811:11mhuebertyes, I was#2017-11-0809:25thhellerso first loading (ns re-view.hiccup.core) via REPL, than saving the file and watch loading it again?#2017-11-0809:26thhellertypically I do not recommend using both#2017-11-0809:28thhellerin the REPL I usually want to be in control of what gets loaded, the live-reload just gets in the way at that point#2017-11-0809:37mitchelkuijpersI am finding out that if I change my entry point that I don't get the pprint error. I am suspecting fulcro to be the problem then#2017-11-0809:38thhellerlet me check that then 🙂#2017-11-0809:38mitchelkuijpersI am just trying out namespaces untill it breaks ^^#2017-11-0809:38mitchelkuijpersI love how fast the npm version is of shadow-cljs#2017-11-0809:39thhellerits even faster if you leave a shadow-cljs server running somewhere. only need to restart that if you change dependencies currently.#2017-11-0809:39mitchelkuijpersOh nice, but I will still put it into leiningen probably#2017-11-0809:40thhelleryou can do this https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L1-L2#2017-11-0809:40thhellerthat will make the shadow-cljs command use lein to start things#2017-11-0809:40thheller:lein true is enough, if you don’t want the custom profile#2017-11-0809:40mitchelkuijpersYeah already found it#2017-11-0809:40mitchelkuijpersWe should work on a good shadow-cljs website, do you need any help? I fixed the fulcro website a few weeks ago#2017-11-0809:41thhellerI need all the help I can get when it comes to documentation#2017-11-0809:41mitchelkuijpersI might take a stab at it this project deserves more attention#2017-11-0809:41mitchelkuijpersWriting docs is extremely hard#2017-11-0809:42thhellerdidn’t start a real website yet but could be done if useful#2017-11-0809:42thhellerindeed#2017-11-0809:43thheller[fulcrologic/fulcro "1.0.0"] this?#2017-11-0809:43mitchelkuijpersYes#2017-11-0809:43mitchelkuijpersBut I have it working now if I first compile a different NS and then the one I want#2017-11-0809:44mitchelkuijpersThat is not something I like hmm#2017-11-0809:45thhellerok one thing that is immediately bad#2017-11-0809:45thhellerif uses https://clojars.org/clojure-future-spec and that should be excluded since we are on clojure 1.9 anyways#2017-11-0809:45thheller(hopefully we are, that would be another probelm otherwise)#2017-11-0809:47mitchelkuijpersOk I excluded this, I think we are on the correct clojure version since I am using the npm version#2017-11-0809:47thhellerwhats the ns to include for fulcro?#2017-11-0809:48mitchelkuijpers [fulcro.client.core :as core]#2017-11-0809:49mitchelkuijpersThis is the complete NS btw:
(ns atlas-crm.ui.entry-points.spa-main
  (:require [atlas-crm.ui.entry-points.spa :refer [app]]
            [fulcro.client.core :as core]
            [atlas-crm.ui.root :as root]))

(reset! app (core/mount @app root/Root "app"))
#2017-11-0809:50mitchelkuijpersIf try to compile the atlas-crm.ui.entry-points.spa that also fails so that might be the problem#2017-11-0809:51thhellerThe required namespace “yahoo.intl-messageformat-with-locales” is not available, it was required by “fulcro/i18n.cljc”.#2017-11-0809:51mitchelkuijpersYeah i fixed that#2017-11-0809:51thhellerah its on npm#2017-11-0809:52mitchelkuijpers
(ns yahoo.intl-messageformat-with-locales
  (:require ["intl-messageformat" :as intl-messageformat-with-locales]
            [goog.object :as gobj]))

(gobj/set js/window "IntlMessageFormat" intl-messageformat-with-locales)
#2017-11-0809:52mitchelkuijpersIf you want I can try to make a minimal reproduction#2017-11-0809:52mitchelkuijpersSo I am not wasting your time#2017-11-0809:53thhellerthat always helps 🙂#2017-11-0809:54thhellerbut I kinda want to go through the process myself to see what people need to do to get this running#2017-11-0809:54thhellerand see if I can automate some of it#2017-11-0809:55thhellernormal CLJS libs should just work without too much effort#2017-11-0809:56mitchelkuijpersAh ok, I'll be back in about 30 minutes#2017-11-0810:05thhellerhttps://github.com/thheller/shadow-cljs/commit/f28191f9ab3a9158553c36a96c15e8bba6590435 those are the things I added to make it work#2017-11-0810:06thhellermostly the cljsjs.react and cljsjs.react.dom helpers since om is stil using js/React.createClass and js/React.DOM.h1 etc#2017-11-0810:06thhellerguess you did those as well?#2017-11-0810:06thhellerbut I only included the sources, I didn’t actually use any of them#2017-11-0810:06thhellerpprint still works though. no warnings either.#2017-11-0810:08thhellerha! spoke too soon, I still had the cached cljs.pprint#2017-11-0810:08thhellerdeleted the cache and got the warnings#2017-11-0810:08thhellerlooking into that now#2017-11-0810:24thheller14sec to compile om.next .. wonder what crazy things that ns is doing … scared to look 😛#2017-11-0810:57thhellerhaha .. found it#2017-11-0810:57thhellerdoh#2017-11-0810:59thheller(:require [clojure.pprint :refer (pprint)]) causes it … thats what you get when trying to take a shortcut in the alias code 😛#2017-11-0811:03thhellerI even left a note for this when I used the shortcut#2017-11-0811:03thhellerhttps://github.com/thheller/shadow-cljs/blob/d53f3468b30b024434a4c0707ae4fdda14f91ce3/src/main/shadow/build/cljs_bridge.clj#L84#2017-11-0811:12thheller@mitchelkuijpers fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1d6e757c79726a307e71776e5d2f332d332b29"}, :content ("[email protected]")}#2017-11-0811:17thhellerI have question, which I guess applies to everyone @mhuebert#2017-11-0811:18thhellerwhen working with the REPL, should watch become “passive”? as in not reload files automatically?#2017-11-0811:19thhellerit is currently possible to start dev worker in passive mode by calling (shadow/watch :your-build {:autobuild false})#2017-11-0811:19thhellerbut not from the commandline#2017-11-0811:19thhellerI guess I have only done the REPL-first development when using shadow-cljs node-repl#2017-11-0811:19mhueberthmm. related question, when I try the ‘Load file in REPL’ command in cursive, it says “TBD” and I think i have to restart the repl. do you know if this is expected, and if it is on the cursive or shadow-repl side?#2017-11-0811:20thhellerwhich never watches#2017-11-0811:20thhellerthats me. the nrepl code is a bit broken for this.#2017-11-0811:21thhellerit works when you use the socket repl but cursive doesn’t support that natively 😞#2017-11-0811:21thhellernrepl is general is pretty darn messy but I wanted to work on that anyways#2017-11-0811:22mhuebertfor me i’m usually not thinking in terms of watch or repl in a modal sense. i am making changes throughout the project and saving the files (and using git, etc), and periodically opening a REPL just to work on a small thing#2017-11-0811:23thhellerhmm yeah but thats why I’m asking#2017-11-0811:23thhellerwhen you actually start using the REPL, should watch become “passive”?#2017-11-0811:24thhellerotherwise you run into issues like before where a namespace defined at the REPL clashes with something in a file#2017-11-0811:24thhellerI can certainly fix this so it doesn’t cause an error and just loads the file#2017-11-0811:25thhellerbut it basically overwrites everything you did in the REPL by loading it from disk#2017-11-0811:25thhellerbut I guess its fine since you probably eval’d the same stuff anyways#2017-11-0811:26mhuebertpersonally that is what i would have expected to happen, but i may have a less repl-driven workflow than others#2017-11-0811:26thhellermy CLJS workflow isn’t REPL driven at all, thats why I never got into this situation before#2017-11-0811:26thhellerfor CLJS I usually have a watch running and just very occasionally poke at it with the REPL#2017-11-0811:27thhellernever defined an ns before though#2017-11-0811:27thhellerI’ll fix load-file first, then I’ll spend some time thinking about the other thing#2017-11-0812:29mitchelkuijpersThat seems to work @thheller nice find!#2017-11-0812:31mitchelkuijpersBtw with Figwheel watch keeps working even when we are connected with a repl, which actually kinda works#2017-11-0812:52thhellerthat also works for shadow-cljs, the question was whether that should be changed#2017-11-0812:52mitchelkuijpersAh ok, for me it kinda works because I mostly use the repl to get autocomplete in emacs 😛#2017-11-0812:53thhelleryeah its fine for those things#2017-11-0816:21mitchelkuijpersIs there a way to use shadow/repl or shadow/dev with nrepl?#2017-11-0816:21thhelleryeah its the shadow.cljs.devtools.api namespace. can’t figure out how to make cursive use shadow.user ns.#2017-11-0816:22thheller(require '[shadow.cljs.devtools.api :as shadow]) and you are good to go 😉#2017-11-0816:23mitchelkuijpersIf i try (shadow/watch :app) it says missing instance#2017-11-0816:23mitchelkuijpersI try this from a nrepl connection from a connected repl#2017-11-0816:23mitchelkuijpersI saw this note: This DOES NOT WORK while in nREPL unless your nREPL client supports needs-input.#2017-11-0816:24thhellerah you are in lein repl?#2017-11-0816:24mitchelkuijpersYes pretty much, I start it from within emacs#2017-11-0816:25thhellerI recommend that you set :nrepl {:port some-number} in shadow-cljs.edn#2017-11-0816:25thhellerthen connect to that if possible with emacs?#2017-11-0816:25mitchelkuijpersAh and then just connect?#2017-11-0816:25mitchelkuijpersSure#2017-11-0816:27thhelleryou can also embed the server though#2017-11-0816:27thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/repl.clj#2017-11-0816:27mitchelkuijpersYou mean embed the server which starts an nrepl server? I woul prefer that tbh#2017-11-0816:28thhellerI have this in the project itself#2017-11-0816:28thhellerand a hotkey in cursive that just sends (require 'repl) (repl/go) to the REPL#2017-11-0816:28mitchelkuijpersWhat I actually tried to do is start 3 workers when I start my dev env#2017-11-0816:29thhellershadow-cljs watch a b c#2017-11-0816:29mitchelkuijpersAh ofcourse#2017-11-0816:29thhelleror like the above also works#2017-11-0816:29mitchelkuijpersI'll play around with just connecting I do like that the npm version is so damn fast with trying stuff out and restarting#2017-11-0816:30thhellerI still think its too slow but a whole lot better than lein yes 😉#2017-11-0816:30mitchelkuijpersAnd I don't have to play dependency puzzle with shadow-cljs#2017-11-0816:32thhelleryou probably need to do the exclusions there too though#2017-11-0816:33mitchelkuijpersYes ofcourse#2017-11-0816:35thhellerplease let me know if emacs doesn’t work properly#2017-11-0816:35thhellerI really want this to work but I don’t know enough about emacs to test it myself#2017-11-0816:36mitchelkuijpersI use cider not sure if you want to support that?#2017-11-0816:36thhellerit should be supported#2017-11-0816:37mitchelkuijpersshould I do:
:nrepl {:port 3002
         :middleware
         [cider.nrepl.middleware.apropos/wrap-apropos
          cider.nrepl.middleware.classpath/wrap-classpath
          cider.nrepl.middleware.complete/wrap-complete
          cider.nrepl.middleware.debug/wrap-debug
          cider.nrepl.middleware.format/wrap-format
          
          cider.nrepl.middleware.inspect/wrap-inspect
          cider.nrepl.middleware.macroexpand/wrap-macroexpand
          cider.nrepl.middleware.ns/wrap-ns
          cider.nrepl.middleware.pprint/wrap-pprint
          cider.nrepl.middleware.pprint/wrap-pprint-fn
          cider.nrepl.middleware.refresh/wrap-refresh
          cider.nrepl.middleware.resource/wrap-resource
          cider.nrepl.middleware.stacktrace/wrap-stacktrace
          cider.nrepl.middleware.test/wrap-test
          cider.nrepl.middleware.trace/wrap-trace
          cider.nrepl.middleware.out/wrap-out
          cider.nrepl.middleware.undef/wrap-undef
          cider.nrepl.middleware.version/wrap-version]}
I am playing around with that
#2017-11-0816:37thhelleryes if you want to use that. guess its needed if you want to use some cider features#2017-11-0816:39mitchelkuijpersYeah but it seems to break stuff#2017-11-0816:39mitchelkuijpers
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!
NullPointerException: 
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        clojure.core/comp/fn--5529 (core.clj:2561)
        shadow.cljs.devtools.server.nrepl/start (nrepl.clj:243)
        shadow.cljs.devtools.server.nrepl/start (nrepl.clj:233)
        shadow.cljs.devtools.server/start-system (server.clj:129)
        shadow.cljs.devtools.server/start-system (server.clj:94)
        shadow.cljs.devtools.server/start! (server.clj:180)
        shadow.cljs.devtools.server/start! (server.clj:172)
        shadow.cljs.devtools.server/start! (server.clj:175)
        shadow.cljs.devtools.server/start! (server.clj:172)
        shadow.cljs.devtools.server/from-cli (server.clj:280)
        shadow.cljs.devtools.server/from-cli (server.clj:256)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:98)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:90)
        shadow.cljs.devtools.cli/main (cli.clj:139)
        shadow.cljs.devtools.cli/main (cli.clj:101)
        clojure.core/apply (core.clj:661)
        clojure.core/apply (core.clj:652)
        shadow.cljs.devtools.cli/-main (cli.clj:178)
        shadow.cljs.devtools.cli/-main (cli.clj:176)
        clojure.lang.Var.applyTo (Var.java:702)
        clojure.core/apply (core.clj:657)
        clojure.main/main-opt (main.clj:317)
        clojure.main/main-opt (main.clj:313)
        clojure.main/main (main.clj:424)
        clojure.main/main (main.clj:387)
        clojure.lang.Var.applyTo (Var.java:702)
        clojure.main.main (main.java:37)
#2017-11-0816:39thhellermaybe the list is old and some namespaces have changed?#2017-11-0816:39mitchelkuijpersActually the only thing I want to work is autocompletion and a working repl for clojurescript 😛#2017-11-0816:39mitchelkuijpersYeah probably will check it out#2017-11-0816:41mitchelkuijpersOh I do remember something about how they made all middleware dynamic, will investigate further#2017-11-0816:42thhellerhttps://github.com/clojure-emacs/cider-nrepl#2017-11-0816:42thhellergot the list from the readme#2017-11-0816:44mitchelkuijpersYeah but cider depends on the new snapshot#2017-11-0816:45mitchelkuijpers
:nrepl {:port 3002
         :middleware
         [cider.nrepl/wrap-apropos
          cider.nrepl/wrap-classpath
          cider.nrepl/wrap-complete
          cider.nrepl/wrap-debug
          cider.nrepl/wrap-enlighten
          cider.nrepl/wrap-format
          cider.nrepl/wrap-info
          cider.nrepl/wrap-inspect
          cider.nrepl/wrap-macroexpand
          cider.nrepl/wrap-ns
          cider.nrepl/wrap-out
          cider.nrepl/wrap-refresh
          cider.nrepl/wrap-resource
          cider.nrepl/wrap-spec
          cider.nrepl/wrap-stacktrace
          cider.nrepl/wrap-test
          cider.nrepl/wrap-trace
          cider.nrepl/wrap-tracker
          cider.nrepl/wrap-undef]}
This one seems to work
#2017-11-0816:50thhellerthat will probably kill your startup performance though 😉#2017-11-0816:54thhellerah cool. they load is dynamically now. then it won’t be so slow.#2017-11-0820:24thheller@mhuebert just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b5c6ddd4d1dac298d6d9dfc6f5879b859b8383"}, :content ("[email protected]")} with support for source maps in :bootstrap. not sure if you actually need them but it also fixed errors not showing proper locations you mentioned a few days ago.#2017-11-0908:31mitchelkuijpersYeah they actually fixed that ^^#2017-11-0908:35thhellerdoes it work properly?#2017-11-0908:53mitchelkuijpersIn combination with shadow-cljs not so much#2017-11-0908:55mitchelkuijpersWhat editor do you use btw? Just out of curiosity#2017-11-0908:55thhellerCursive#2017-11-0908:55mitchelkuijpersOur team is spacemacs and vim 😛#2017-11-0908:55thhellerwhat doesn’t work?#2017-11-0908:56mitchelkuijpersOk when I connect the cider middleware get's properly loaded because I don't get warnings anymore#2017-11-0908:56mitchelkuijpersAnd connecting by using:
(shadow.cljs.devtools.api/nrepl-select :app)
works
#2017-11-0908:57mitchelkuijpersAnd I can try stuff out in that repl#2017-11-0908:57thhellerdoes is actually eval in JS?#2017-11-0908:57thheller(js/alert "foo") or so?#2017-11-0908:57mitchelkuijpersYes I can do (.log js/console "hello") that works#2017-11-0908:58thhellerok#2017-11-0908:58mitchelkuijpersbut when I do it gives me the following error:
error in process filter: nrepl--dispatch-response: [nREPL] No response handler with id 0 found
error in process filter: [nREPL] No response handler with id 0 found
#2017-11-0908:58mitchelkuijpersBut it does work#2017-11-0908:58thhellercan you tell me the emacs commands you use?#2017-11-0908:59mitchelkuijpersI use cider-connect and then localhost and then the correct port#2017-11-0909:01mitchelkuijpersand i use cider-eval-last-sexp to run stuff or cider-eval-buffer but for the last one I get TBD log message#2017-11-0909:01mitchelkuijpersIf you want to try it out you could use spacemacs, then cider works out of the box#2017-11-0909:03mitchelkuijpersAnd I got this error when trying to eval a ns:
Nov 09, 2017 9:58:51 AM clojure.tools.logging$eval454$fn__457 invoke
SEVERE: Unhandled REPL handler exception processing message {:ns user, :op eval, :code (ns cljs.user
  (:require
   [fulcro.client.core :as uc]
   [om.next :as om]

   [atlas-crm.ui.entry-points.spa :as core]
   [atlas-crm.ui.root :as root]

   [cljs.pprint :refer [pprint]]
   [fulcro.client.logging :as log]
   [clojure.spec.test.alpha :as stest]
   [clojure.spec.alpha :as s]
   [expound.alpha :as expound]))
, :file /home/mitchel/Development/atlas-crm-next/dev/client/cljs/user.cljs, :line 1, :column 1, :session 56407dcf-efa5-4ab4-8991-457ba97aa97c, :id 28}
java.lang.IllegalArgumentException: No matching clause: :repl/error
	at shadow.cljs.devtools.server.nrepl$do_cljs_eval.invokeStatic(nrepl.clj:54)
	at shadow.cljs.devtools.server.nrepl$do_cljs_eval.invoke(nrepl.clj:23)
	at shadow.cljs.devtools.server.nrepl$cljs_eval$fn__25937.invoke(nrepl.clj:139)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.session$add_stdin$fn__25769.invoke(session.clj:229)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.load_file$wrap_load_file$fn__25818.invoke(load_file.clj:79)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
	at cider.nrepl$wrap_stacktrace$fn__1100.invoke(nrepl.clj:365)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__25437.invoke(middleware.clj:22)
	at cider.nrepl$wrap_format$fn__1026.invoke(nrepl.clj:188)
.....
#2017-11-0909:03thhellerhold on, trying to get this emacs thing running#2017-11-0909:03thhellerI think I have it connected#2017-11-0909:04thhellerhow do I get an actual REPL window?#2017-11-0909:04thhellercider-connect seemed to work but its just showing something in the status bar#2017-11-0909:05mitchelkuijpersdo you have vanilla emacs?#2017-11-0909:05mitchelkuijpersYou have to open the buffer of the repl#2017-11-0909:06mitchelkuijpersctrl+x b#2017-11-0909:06mitchelkuijpersI think haven't used emacs shortcuts in a long time#2017-11-0909:07mitchelkuijpersspacemacs has vim shortcuts parrot
#2017-11-0909:08thhelleryeah using spacemacs + vim#2017-11-0909:08mitchelkuijpersspacebar and then b b opens your buffers#2017-11-0909:09mitchelkuijpersif you have a clojurescript file open you can use , e e to eval the last sexp#2017-11-0909:09mitchelkuijpersand you can use , e b to eval a buffer#2017-11-0909:10thhellerok got it#2017-11-0909:10thhellerseeing the error#2017-11-0909:12mitchelkuijpersI was thinking do I need to configure piggieback or the fake on of shadow-cljs somehow? or is that automatic?#2017-11-0909:13thhellerthat should be automatic#2017-11-0909:14thhellersec, trying to get this working so I can debug it properly#2017-11-0909:24thhellerthe clojure part seems to be working?#2017-11-0909:24thhellerhow do I trigger autocomplete or so?#2017-11-0909:27thheller
[10:26:55,107] nrepl-receive {:ns cljs.user, :op eval, :code (js/alert "foo")
, :file *cider-repl localhost*<2>, :line 62, :column 12, :id 42}
[10:26:56,696] nrepl-send {:id 0, :session 9aa5ab6c-1f55-4a43-bc7d-1b9ad01a3d4f, :type :repl/result, :value nil, :ns cljs.user}
[10:26:56,696] nrepl-send {:id 42, :session 9aa5ab6c-1f55-4a43-bc7d-1b9ad01a3d4f, :status #{:done}}
#2017-11-0909:27thhelleralright. seems like I send the wrong :id back#2017-11-0909:27thhellershould be 42#2017-11-0909:30mitchelkuijpersBtw autocomplete you get after typing foo/f but you need to eval the ns so that it works#2017-11-0909:33thhellertrying to make sense of this nrepl code#2017-11-0909:33thhellerfor some reason it doesn’t set the id altough I pass it in#2017-11-0909:40thhellerok .. just removed the nrepl fn and create the response myself#2017-11-0909:40thhellersort of works now#2017-11-0909:40thheller
cljs.user> (js/console.log "foo")
"nil"
#2017-11-0909:40thhellerdunno why thats quoted though?#2017-11-0909:41mitchelkuijpersThat should not be quoted 😛#2017-11-0909:41thheller
cljs.user> (+ 1 2)
"3"
#2017-11-0909:41mitchelkuijpersThat is weird#2017-11-0909:41thhellerah might be because everything I get back is a string from the browser#2017-11-0909:43mitchelkuijpersThat makes sense#2017-11-0909:44thheller
[10:44:25,122] nrepl-receive {:ns "cljs.user", :op "eval", :code "(js/console.log \"foo\")\n", :file "*cider-repl localhost*", :line 52, :column 12, :id "16"}
[10:44:25,134] nrepl-send 16 {:type :repl/result, :value "nil", :id "16", :ns "cljs.user", :session "6fe7ed2f-85a6-4076-a7dd-5dfbe4aa0928"}
[10:44:25,134] nrepl-send 16 {:status #{:done}, :id "16", :session "6fe7ed2f-85a6-4076-a7dd-5dfbe4aa0928"}
#2017-11-0909:45thhellerthis is the flow, seems like it doesn’t like setting value to a string#2017-11-0909:45thhellerand just encodes it again?#2017-11-0909:48thheller
user-error: 'cider-load-buffer' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (', "').
#2017-11-0909:48thhellerwhat does that mean?#2017-11-0909:50mitchelkuijpersThen it doesnt detect that you have a clojurescript buffer#2017-11-0909:50mitchelkuijpersIt does that with some weird var#2017-11-0909:50mitchelkuijpersI fixed it by running a command in the cljs repl and then after that it did know#2017-11-0909:52thheller
user> (shadow.cljs.devtools.api/nrepl-select :browser)
To quit, type: :repl/quit
[:selected :browser]
cljs.user> (js/console.log "foo")
"nil"
cljs.user> (js/console.log "bar")
"nil"
#2017-11-0909:52thhellerthat seems to work fine#2017-11-0909:52thhellerbut trying any commands from the menu complains#2017-11-0909:53mitchelkuijperscan you check cider-connection-browser?#2017-11-0909:53mitchelkuijpersFor me that shows:
REPL                           Host             Port    Project          Type

* *cider-repl localhost*         localhost         3002   atlas-crm-next   ClojureScript
  *cider-repl atlas-crm-next*    localhost        46125   atlas-crm-next   Clojure
#2017-11-0909:53thheller* *cider-repl localhost* localhost 8202 shadow-cljs Clojure#2017-11-0909:53mitchelkuijpersah that's the problem#2017-11-0909:54mitchelkuijpersI did the following:
You can mute this warning by changing cljr-suppress-middleware-warnings.
user> (shadow.cljs.devtools.api/nrepl-select :app)
To quit, type: :repl/quit
[:selected :app]
JS runtime connected.
cljs.user> (.log js/console "hoi")
nil
#2017-11-0909:54mitchelkuijpersweird that that doesn't work for you#2017-11-0909:54mitchelkuijpersis the file in the right project?#2017-11-0909:55thhelleryes#2017-11-0909:57mitchelkuijpersDo you have incluced the middleware and cider 16 middleware? Maybe that helps#2017-11-0909:57thhellerusing the config you pasted above#2017-11-0909:58mitchelkuijpersAh ok#2017-11-0909:58thhellerWARNING: CIDER's version (0.15.0-snapshot) does not match cider-nrepl's version (0.15.1). Things will break!#2017-11-0909:58thhellerI get this on connect#2017-11-0909:58mitchelkuijpersAh#2017-11-0909:58thhellermaybe I have an old cider version?#2017-11-0909:58mitchelkuijpersyes try:
npx shadow-cljs -d cider/cider-nrepl:0.16.0-SNAPSHOT watch :app 
#2017-11-0909:58thhellerbut it says CIDER's version (0.15.0-snapshot) #2017-11-0909:59mitchelkuijpersOh wait your's wants 0.15.1#2017-11-0909:59mitchelkuijpershow do you add cider?#2017-11-0910:00mitchelkuijpersThat is weird because mine wants:
;; Connected to nREPL server - 
;; CIDER 0.16.0snapshot (package: 20171001.112), nREPL 0.2.13
#2017-11-0910:00thhellerno the slightest clue#2017-11-0910:01thhellerpackage-install doesn’t include cider#2017-11-0910:01mitchelkuijpersyou use spacemacs? try configuration-layer/update-packages#2017-11-0910:02thhellerwhat does that mean? 😛#2017-11-0910:02mitchelkuijpersthat updates all the spacemacs packages#2017-11-0910:02mitchelkuijpersor all the emacs packages#2017-11-0910:02thhelleryes … I gathered that by the name#2017-11-0910:02mitchelkuijpersyou could also check for updates, maybe you have an old version of spacemacs#2017-11-0910:03thhellerbut HOW do I try it?#2017-11-0910:03thhellerwhat command should I type?#2017-11-0910:04mitchelkuijpersOh#2017-11-0910:04mitchelkuijpersspace space and then type it in#2017-11-0910:04thhellerSPC SPC is undefined#2017-11-0910:05mitchelkuijpersOh you have an old spacemacs#2017-11-0910:05thhellervery likely. how do I update?#2017-11-0910:05mitchelkuijpersyou could remove emacs.d en dan reinstall spacemacs#2017-11-0910:06mitchelkuijpersdoes alt+x work?#2017-11-0910:06mitchelkuijpersthen search for spacemacs/check-for-new-version#2017-11-0910:07thhellerseems like I have a git checkout, just pull’d that#2017-11-0910:07thhellerstill undefined#2017-11-0910:07thheller
(render (foo "foo") (js/SPC SPC is undefined
document.getElementById "app"))
#2017-11-0910:07thhellergreat … now it fucked up my buffer?#2017-11-0910:08mitchelkuijpers? what the hell 😛#2017-11-0910:08thhellerkinda beginning to hate emacs again 😛#2017-11-0910:08mitchelkuijpersHaha I get that#2017-11-0910:08mitchelkuijpersI would just remove your emacs.d en close emacs#2017-11-0910:08mitchelkuijpersand then do a fresh clone and start emacs#2017-11-0910:10thhellerok done#2017-11-0910:10thhellerthat seems to install a bunch of stuff now at least#2017-11-0910:13mitchelkuijpersMaybe I should learn how to fix those issue with shadow-cljs so you don't have to go through this pain 😅#2017-11-0910:13thhellerSPC SPC is undefined but it should be updated now#2017-11-0910:13mitchelkuijpersAh ok#2017-11-0910:13mitchelkuijpersthen just use alt+x that also works#2017-11-0910:14mitchelkuijpersI think it is probably alt+enter for you#2017-11-0910:14thhellerWARNING: CIDER's version (0.16.0-snapshot) does not match cider-nrepl's version (0.15.1). Things will break! can I make it use non-snapshot? snapshots are scary.#2017-11-0910:16mitchelkuijpersThen you have to do some stuff with melpa, but probably all of your cider users will be using 0.16.0-snapshot#2017-11-0910:17mitchelkuijpersBut you should be able to pin the version somewhere, but not sure how that works tbh#2017-11-0910:19thhelleradded the snapshot but now I get [WARNING] No nREPL middleware descriptor in metadata of null, see clojure.tools.middleware/set-descriptor!#2017-11-0910:22thhelleroh .. was using the wrong ones 😛#2017-11-0910:24thhellerman this is what I really hate about emacs .. press one wrong key and things go totally nuts#2017-11-0910:24mitchelkuijpersWhat a horror this is#2017-11-0910:26thheller
user-error: 'cider-load-buffer' needs a ClojureScript REPL.
If you don't know what that means, you probably need to jack-in (', "').
#2017-11-0910:26thhellerstill#2017-11-0910:29thhellerseriously .. how does anyone get any work done with emacs …#2017-11-0910:30thhellerI’m completely lost and I have used it for a while a couple years ago#2017-11-0910:33thhellerCLJS <no project>@localhost:8202 (Java 1.8.0_144, Clojure 1.9.0-beta4, nREPL 0.2.13) [2 times]#2017-11-0910:33thhellerprobably the <no project>?#2017-11-0910:36thhellerseriously .. I can break everything in emacs with less than 3 clicks/keys#2017-11-0910:36thhellerI give up …#2017-11-0910:36thhellerI’ll push what I have .. and let you deal with this 😛#2017-11-0910:38thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "90e3f8f1f4ffe7bdf3fcfae3d0a2bea0bea6a7"}, :content ("[email protected]")} fixes the initial issue [nREPL] No response handler with id 0 found#2017-11-0910:44mitchelkuijpersHaha sorry I was busy#2017-11-0910:47thhellerwhat I found but couldn’t figure out how to change#2017-11-0910:47thhellerwas changing the jack-in command#2017-11-0910:47thheller Cider Cljs Lein Repl #2017-11-0910:48mitchelkuijpersIf you cider connect you have to make sure that you are in a project file#2017-11-0910:48thheller"(cemerick.piggieback/cljs-repl (cljs.repl.rhino/repl-env))"#2017-11-0910:48thhellerif you change that to just (shadow.cljs.devtools.api/nrepl-select :app) it should work?#2017-11-0910:50mitchelkuijpersdamnit now I am stuck in that configuration screen#2017-11-0910:50mitchelkuijpersyou then you can connect and then run cider-sibling-cljs-repl#2017-11-0910:50mitchelkuijpersthat should work#2017-11-0910:51mitchelkuijpersYou can change Cider Cljs Lein repl with customize-group Cider#2017-11-0910:51thhellerI’m done with emacs for a while … not enough patience to figure this out#2017-11-0910:52mitchelkuijpersSure I'll try it out myself#2017-11-0911:16mitchelkuijpersCould you push your changes? Then I can see where you changed stuff and play around#2017-11-0911:19thhellerah thought I did#2017-11-0911:19mitchelkuijpersHaha nice commit messages#2017-11-0911:19mitchelkuijpersthnx#2017-11-0911:20thhellerhttps://github.com/thheller/shadow-cljs/commit/721a0e123aee01faada30ab3694de7c138a80a9b#2017-11-0911:22mitchelkuijpersSorry one more question how do you hack on this and quickly test it out in emacs? not sure how to start#2017-11-0911:25thhellermy workflow is: lein with-profiles +cljs repl in the project itself. connect to that remotely via Cursive.#2017-11-0911:25thheller(require 'repl) (repl/go) starts the embedded server#2017-11-0911:25thhellerthen used emacs to cider-connect to localhost 8202#2017-11-0911:26mitchelkuijpersOk awesome thnx#2017-11-0911:27thhellershadow-cljs clj-repl also works, dont need the lein repl.#2017-11-0911:28thhellerjust doing that since every (repl/go) restarts the embedded server which also restarts the nrepl server. so I’m connected to that while calling (repl/go) I lose the connection.#2017-11-0911:29thhellerdunno how well emacs deals with 2 separate nrepl connections#2017-11-0911:30mitchelkuijpersI'll manage#2017-11-0911:30mitchelkuijpersThank you#2017-11-0911:51mitchelkuijpersHmm should I install all npm-packages manually? No package.json#2017-11-0911:53thhellerah yeah its .gitignore since I put a bunch of test packages there#2017-11-0911:53mitchelkuijpersAh ok can you share it here?#2017-11-0911:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/browser.cljs#2017-11-0911:53mitchelkuijpersAh ok 😛#2017-11-0911:54thheller
{
  "private": true,
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.6.0",
    "shadow-cljs": "file:packages/shadow-cljs",
    "source-map-support": "^0.4.15",
    "ws": "^3.2.0"
  },
  "dependencies": {
    "@atlaskit/navigation": "^18.0.0",
    "@blueprintjs/core": "^1.32.0",
    "@expo/vector-icons": "^5.2.0",
    "animated": "^0.2.0",
    "aws-sdk": "^2.122.0",
    "babel-core": "^6.26.0",
    "babel-plugin-external-helpers": "^6.22.0",
    "bootstrap": "4.0.0-beta.2",
    "browser-resolve": "^1.11.2",
    "browserify": "^14.4.0",
    "browserify-shim": "^3.8.14",
    "codemirror": "^5.31.0",
    "create-react-class": "^15.6.2",
    "d3": "^4.11.0",
    "envify": "^4.1.0",
    "firebase": "^4.5.1",
    "firebaseui": "^2.4.1",
    "highlight.js": "^9.12.0",
    "iconv-lite": "^0.4.19",
    "intl-messageformat": "^2.2.0",
    "jquery": "^3.2.1",
    "jquery-treetable": "^3.2.0-1",
    "js-nacl": "^1.2.2",
    "katex": "^0.9.0-alpha1",
    "leaflet": "^1.2.0",
    "material-components-web": "^0.22.0",
    "material-ui": "^0.18.7",
    "mkdirp": "^0.5.1",
    "module-deps": "^4.1.1",
    "moment": "^2.18.1",
    "node-libs-browser": "^2.0.0",
    "node-resolve": "^1.3.3",
    "parinfer": "^3.11.0",
    "parinfer-codemirror": "^1.4.1",
    "preact": "^8.2.5",
    "processing-js": "^1.6.6",
    "react": "^16.0.0",
    "react-addons-css-transition-group": "^15.6.2",
    "react-apollo": "^1.4.16",
    "react-dom": "^16.0.0",
    "react-leaflet": "^1.7.0",
    "react-vis": "^1.7.9",
    "readline-sync": "^1.4.7",
    "reqwest": "^2.0.5",
    "shortid": "^2.2.8",
    "source-map": "^0.6.1",
    "styled-components": "^2.1.1",
    "uglify-js": "^3.1.2",
    "uglifyify": "^4.0.3",
    "webpack": "^3.5.5"
  },
  "browserify-shim": {}
}
#2017-11-0911:54thhellerneed to remove some stuff, those are basically the pacakges I tested at one point or another#2017-11-0911:57mitchelkuijpersAh pretty much have it working now ^^#2017-11-0912:01thhellerdebug logging should be enabled which will log all nrepl messages#2017-11-0912:04mitchelkuijpersYeah very usefull#2017-11-0912:16mitchelkuijpersI am getting somewhere, when I try to eval a namespace form, here i try this one:
(ns demo.browser
  (:require-macros [demo.browser :refer (test-macro)])
  (:require ["react" :as react :refer (Component createElement)]
            ["react-dom" :as rdom :refer (render)]
            ["shortid" :as sid]
            ["jquery" :as jq]
            ["material-ui/RaisedButton" :as mui-btn :default btn]
    ;; ["@material/checkbox" :refer (MDCCheckbox MDCCheckboxFoundation)]
            ["babel-test" :as babel-test :default Shape]
            ["@material/menu/simple/foundation" :default menu]
            ["@material/menu/util" :as util]
            ["d3" :as d3]
            [clojure.pprint :refer (pprint)]
            [cljsjs.react]
            [clojure.spec.alpha :as s]
            [clojure.spec.gen.alpha :as gen]
            [shadow.api :refer (ns-ready)]
            ["circular-test" :as circ]))
I get an error with:
:cause conflict on "clojure.pprint" by "clojure.pprint" used by "cljs.pprint"
#2017-11-0912:21mitchelkuijpersI get the same for clojure.spec and cljs.spec#2017-11-0912:22mitchelkuijpersWhen I remove this a lot starts working ^^#2017-11-0912:22mitchelkuijpersEven the autocompletion#2017-11-0912:32mitchelkuijpersNice and I fixed the case statement which had a wrong default now I get:
[:FIXME {:type :repl/error, :message "failed to compile resource: [:shadow.build.classpath/resource \"cljs/pprint.cljs\"]", :data {:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "cljs/pprint.cljs"], :url #object[java.net.URL 0x6ad8fa90 "jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/pprint.cljs"], :file nil}, :causes ["No namespace: cljs.pprint found"]}]
#2017-11-0913:56thhellerdamn this aliasing code is killing me 🙂#2017-11-0914:02mitchelkuijpersYeah hehe#2017-11-0914:08thheller"No namespace: cljs.pprint found" that must be a cider error?#2017-11-0914:13mitchelkuijpersNo I think that is caused by: :cause conflict on "clojure.pprint" by "clojure.pprint" used by "cljs.pprint"#2017-11-0914:14mitchelkuijpersSo it fails to compile: clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "cljs/pprint.cljs"]#2017-11-0914:14thhellerthe first one I understand, the second I don’t understand 😛#2017-11-0914:15mitchelkuijpersI think the second one happens because of the conflict? (I am just guessing here)#2017-11-0914:47thhellerman I really hate having to combine this REPL code with watch#2017-11-0914:47thhellerso much undefined behaviour#2017-11-0914:53mitchelkuijpersI am trying to get something like this to work, not sure if this is even possible.
(defn cljs-repl []
  (shadow-server/start!)
  (shadow/watch :app)
  (shadow/nrepl-select :app))
Something like this does work with figwheel where you can just say (fig/cljs-repl (:figwheel-system @figwheel)) not sure if you want to support this but it has a really nice workflow we have one script that starts everything and then in our emacs starts 2 repls in one jvm
#2017-11-0914:54mitchelkuijpersWhat kind of undefined behaviour do you get? I would think on save just reload all affected namespaces? and blow away evalled stuff?#2017-11-0914:55thhelleryeah the above should work fine#2017-11-0914:55thhellerthats what I do essentially#2017-11-0914:55mitchelkuijpersI get: IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set clojure.lang.Var.set (Var.java:223)#2017-11-0914:56thhellerah .. right#2017-11-0914:56thhellerwell thats a bit more complicated#2017-11-0914:56thhellersince the nrepl connection you are one is not the one started by shadow-cljs#2017-11-0914:56mitchelkuijpersYes#2017-11-0914:57thhellerso instead you must add the middleware to the nrepl you are using#2017-11-0914:57mitchelkuijpersAhh that would be easy#2017-11-0914:57mitchelkuijpersand then no fiddling with cider middleware#2017-11-0914:58thhellerI’m not sure how to set this up though#2017-11-0915:00thhellershadow.cljs.devtools.server.nrepl is the ns and you need https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/nrepl.clj#L212-L218#2017-11-0915:01mitchelkuijpersAh thnx#2017-11-0915:01mitchelkuijpersWill try it out#2017-11-0915:07mitchelkuijpersI will write a guide if I have this working ^^#2017-11-0915:10thhellerI fixed the conflict but now watch can’t load the file anymore because its on conflict with the REPL 😛#2017-11-0915:10mitchelkuijpersOh god all because of the stupid aliasing?#2017-11-0915:10thhellerI guess I need to remove some of my strict checks#2017-11-0915:10thhellernah aliasing was just a bug#2017-11-0915:11thhellerbut when you call (ns some.thing) in the REPL it must not touch the filesystem#2017-11-0915:11thhellerso it defines a pseudo resource, which is fine#2017-11-0915:11thhellerthen you save the file, watch comes along, tries to use it#2017-11-0915:12thhellerbut since the REPL resource is already in use, it conflicts with the FS resource#2017-11-0915:12thhellerI guess I’ll just allow that, no need to be strict in this case#2017-11-0915:13thhellerneed to be kinda strict to ensure caching works properly#2017-11-0915:22thhellermeh … undefined is fine I guess#2017-11-0915:30mitchelkuijpersDamn the middleware works!#2017-11-0915:30mitchelkuijpersthis is awesome, I still get this error for some reason if I run a clean build from the repl in leiningen:
-> Compile CLJS: cljs/core.cljs
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/mitchel/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/core.cljs:987:14
--------------------------------------------------------------------------------
 983 | 
 984 |     (number? o)
 985 |     (if (js/isFinite o)
 986 |       (js-mod (Math/floor o) 2147483647)
 987 |       (case o
--------------------^-----------------------------------------------------------
No reader function for tag Inf

--------------------------------------------------------------------------------
 988 |         ##Inf
 989 |         2146435072
 990 |         ##-Inf
 991 |         -1048576
 992 |         2146959360))
--------------------------------------------------------------------------------

:error

But it works without leiningen so probably a dependency issue
#2017-11-0915:31thhelleryep tools.reader conflict. most often core.async.#2017-11-0915:31mitchelkuijpersAh thnx#2017-11-0915:31thhellereither exlude it or add [org.clojure/tools.reader "1.1.1"] to your project#2017-11-0915:35mitchelkuijpersYes that worked#2017-11-0915:35mitchelkuijpersawesome now it all works!#2017-11-0915:37thhellerwohoo#2017-11-0915:57thhellernow if I could only find a decent way so the REPL doesn’t conflict with watch in undefined ways#2017-11-0916:37thheller@mitchelkuijpers {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6c1f040d08031b410f00061f2c5e425c425a54"}, :content ("[email protected]")} should hopefully resolve most ns issues#2017-11-0916:38mitchelkuijpersAh awesome#2017-11-0916:38thhellerit may still run into weird situation but the worst that should happen is that watch blows away some REPL state#2017-11-0916:39mitchelkuijpersThat is not really a problem ^^#2017-11-0916:39mitchelkuijpersVery cool#2017-11-0917:21thhellerI started https://github.com/thheller/shadow-cljsjs in which I want to collect the cljsjs.* alias namespaces for common cljsjs packages#2017-11-0917:21thhellerso not every user has to create them#2017-11-0917:21thhellerrather have them in a central place#2017-11-1007:59mitchelkuijpersOh nice good idea#2017-11-1008:25thheller@mitchelkuijpers did you do any other tweaks to get the nREPL working or was including the middleware enough?#2017-11-1008:28mitchelkuijpersIncluding the middleware was enough#2017-11-1008:32thhellercould you post the setup somewhere so I can use it for future tests? 🙂#2017-11-1008:38mitchelkuijpersYes ofcourse#2017-11-1008:39mitchelkuijpersWill have to extract it will do it this weekend#2017-11-1008:39thhellercool#2017-11-1008:53mitchelkuijpersWill make one with a automatic emacs configuration so you can also run it in emacs 😛#2017-11-1008:54mitchelkuijpersYou have project specific config if you use projectile (which spacemacs does)#2017-11-1010:55thhellerso I finally wrote that blog post about JS deps#2017-11-1010:55thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2017-11-1010:55thhellerplease let me know if I missed something or how to improve it overall#2017-11-1012:05cmalHi, @thheller ! Do we have a method to hot-reload over https in shadow-cljs watch app now?#2017-11-1012:06thhellernot yet. I have it working but dealing with certificates is pretty painful 😞#2017-11-1012:06cmalWhat is the problem? I wonder whether I can help.#2017-11-1012:07cmalreloading hundreds of files every time is also painful.. 😢#2017-11-1012:07thhellerthe problem is that the default java keytool for working with certificates doesn’t like things openssl generates#2017-11-1012:07thhellerand vice versa#2017-11-1012:07thhellerso you constantly need to convert between each#2017-11-1012:08cmalIt seems a profound field.#2017-11-1012:08thhellerfor example this method of generating self-signed certs https://certsimple.com/blog/localhost-ssl-fix#2017-11-1012:09thhellercan’t be directly imported into java#2017-11-1012:09thhellerso you first need to convert it using openssl#2017-11-1012:09thhellersuper annoying#2017-11-1012:10cmalCan we use nodejs ssl? Or does it have the same problem?#2017-11-1012:10thhellercan’t use it and probably similar issues#2017-11-1012:10thhelleronce you have a cert its pretty easy though#2017-11-1012:11cmalI have a cert 😄#2017-11-1012:11thhellerI can merge the branch I have for this so you can try it#2017-11-1012:11thhelleris that cert compatible with keytool though? 😛#2017-11-1012:11cmalOK. Thank you for that.#2017-11-1012:12cmalNot sure. But I can have a try.#2017-11-1012:12thhelleralso the most annoying thing is that java requires a password on a cert#2017-11-1012:13thhellerno way I’ll allow putting a password into the shadow-cljs.edn config#2017-11-1012:13thhellerbut how do I get it then? 😛#2017-11-1012:13thhellerwhat format is the cert in? .p12? .pem?#2017-11-1012:13cmal😢#2017-11-1012:14cmalI only used them. The only thing I know is there is a privateKey file and a certificate file.#2017-11-1012:15thhellerwhat do they look like?#2017-11-1012:15thheller
-----BEGIN CERTIFICATE-----
MIIDMTCCAhmgAwIBAgIBATANBgkqhkiG9w0BAQsFADBGMRYwFAYDVQQDDA1UaG9t
YXMgSGVsbGVyMQswCQYDVQQGEwJERTEfMB0GCSqGSIb3DQEJARYQaW5mb0B6aWxl
bmNlLm5ldDAeFw0xNzEwMjMwNzU2MDVaFw0xODEwMjMwNzU2MDVaMEYxFjAUBgNV
BAMMDVRob21hcyBIZWxsZXIxCzAJBgNVBAYTAkRFMR8wHQYJKoZIhvcNAQkBFhBp
bmZvQHppbGVuY2UubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
xV7BEpu7npqMSUNPyWLr3dox8byM14f7HJuSCeqeln/lL/Yr/OwnD2fuurI9/k0H
xk9QJq2x76AsxHQOx5Bv036gLc+rUuBVAJkamRvYBwrCW2T5Z0ct1goVY5xy0iiP
bj6Dv/Wgpr9iM5rIVdf1zpp1U/IdcbQ7nJTGvScuroIQir73LKm5GuEKzz9dBWdw
C0wEjzuorHLjCTIF/ie9Qgjue1LX5mv+gjmQVfsDvaKPsddu5+It+VAvdvKmYbhN
NjAP1z+84VWF20phyfuqdvEgV2P8S73GL36EdiXP/raQg0zSBvsznN9EjbOB3nmQ
G1ljJvQBMIxAnIQx5XuKVQIDAQABoyowKDAOBgNVHQ8BAf8EBAMCB4AwFgYDVR0l
AQH/BAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcNAQELBQADggEBADoq8TDWIj/ZfUih
+XO9XfJ2/o3dMiQJEEhkQISEwVc0Bz+Ik2YXyuC7StgBaF1ji0YzhEmFx+7OvT5K
VRtJDf6f4SI9z4R+0ZRPKWR1MNGPGJddDg93IybloJ8zymLiKC3N76QIDeXo73hb
1x1aPFWiGcV3b3sY1zaifGphHdAK4tlyWMY4gUFCqmXH1x0OKPgMfSa6EwZpSw0u
x7Qq5Z5oemL7kNlPKpcC0R08+EaFC2g1ls0q55dvojgxuAC6wD120zrT7QTqkLQ/
gd9MCFduABKgkKv+Lay45jpFeObU5LMe57iNizRCF6E7eDPh7O0EIfJM+IcWtrxc
PDLcVSI=
-----END CERTIFICATE-----
#2017-11-1012:15thhellerthat style?#2017-11-1012:15cmalI'll have a look#2017-11-1012:16thhellerdont paste the priv key 😉#2017-11-1012:16cmalI almost do that...#2017-11-1012:17thhellerare they plain text files or some binary stuff?#2017-11-1012:17thheller
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAxV7BEpu7npq...
#2017-11-1012:17cmalplain text#2017-11-1012:17cmalboth are.#2017-11-1012:18thhellerok, let me grab my notes. kinda forgot how this worked already.#2017-11-1012:19cmal:+1:#2017-11-1012:27thhelleronce you have the cert stuff sorted out its easy 🙂#2017-11-1012:37cmalAhh, how can I try it?#2017-11-1012:37cmalHave you merged the branch?#2017-11-1012:42thhellercleaning it up a bit, will do soon#2017-11-1012:43cmalThank you.#2017-11-1013:03thhellerhttps://github.com/thheller/shadow-cljs/issues/88#issuecomment-343467923#2017-11-1013:04thhellerI’ll write up the instructions for getting a self-signed cert for osx#2017-11-1013:04thhellermaybe you can figure out how it works if you already have a cert#2017-11-1013:05thhellerkeytool has quite a few very confusing options#2017-11-1013:18cmalThank you. I will have a try#2017-11-1013:18thhellerhttps://github.com/thheller/shadow-cljs/issues/88#issuecomment-343470850#2017-11-1013:18thhellerthose are the steps I did to get the cert I’m using for testing#2017-11-1013:19thhellerthe SAN stuff is important for Chrome. Otherwise I couldn’t get it to trust the cert.#2017-11-1013:25cmalSorry for bothering. I have the key and cert file on my server. Should I download the two files and add the path of them to :ssl?#2017-11-1013:25cmalOr I should use keytool?#2017-11-1013:26thhelleryou must use keytool to create the keystore. I have no clue if you can import the certs you already have#2017-11-1013:26thhellerbut I think you can#2017-11-1013:27cmalOk. I will have a try.#2017-11-1013:27thhellerhttps://stackoverflow.com/questions/906402/how-to-import-an-existing-x509-certificate-and-private-key-in-java-keystore-to-u#2017-11-1013:27thhellerhttps://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html#2017-11-1013:28thhellerthat tool is probably more complicated than java itself but it can do pretty much anything related to ssl#2017-11-1014:21cmalHi, @thheller. It seems there is some (goog-define ssl false). How to enable ssl? I generated a keystore but don't know how to use it, if it can be used. I've already add :ssl {...} to shadow-cljs.edn#2017-11-1014:32mitchelkuijpersI just upgraded to the newest shadow-cljs and I start getting errors like:
ReferenceError: [BABEL] node_modules/styled-components/dist/styled-components.es.js: Unknown option: /home/mitchel/Development/atlas-crm-next/node_modules/react/react.js.Children. Check out  for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see . (While processing preset: "/home/mitchel/Development/atlas-crm-next/node_modules/react/react.js")
    at Logger.error (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/logger.js:41:11)
    at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
    at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
    at /home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
    at Array.map (native)
    at OptionManager.resolvePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/home/mitchel/Development/atlas-crm-next/node_modules/babel-core/lib/transformation/file/index.js:212:65)
#2017-11-1014:32mitchelkuijpersOh wait is it loading babel config?#2017-11-1014:37thheller@mitchelkuijpers looks like it. did it work before?#2017-11-1014:37thheller@cmal did you restart the server process?#2017-11-1014:38thhellerthe define will be set automatically#2017-11-1014:38cmalI just restart shadow-cljs watch app.#2017-11-1014:38cmaland I see shadow-cljs - starting ...#2017-11-1014:38cmalshadow-cljs - config: /Users/yuzhao/gits/luminus-projects/shadow-cljs-demo/shadow-cljs.edn version: 2.0.71#2017-11-1014:39cmalStill got this.
browser.cljs:260 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:260
(anonymous) @ browser.cljs:303
browser.cljs:260 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
    at Object.shadow$cljs$devtools$client$browser$ws_connect [as ws_connect] ()
    at 
#2017-11-1014:40cmalShouldn't it talk to the browser using wss://?#2017-11-1014:41thhellerit should if ssl is set#2017-11-1014:42cmalShould :keystore "the-file.ks" be in the same path of shadow-cljs.edn?#2017-11-1014:43thhellerits relative to the project root, so in that case yes#2017-11-1014:45cmalIs the version 2.0.71 the newest?#2017-11-1014:45cmalI see the clojars gray in github frontpage.#2017-11-1014:45thhelleryes, add :http {:port 8021} to your config, restart the server and open #2017-11-1014:46cmalERR_SSL_PROTOCOL_ERROR#2017-11-1014:46thheller?#2017-11-1014:47cmalmaybe the keystore is not valid?#2017-11-1014:47cmalshadow-cljs coming soon ...#2017-11-1014:47cmalhttp#2017-11-1014:47thhellerok, so ssl config isn’t working#2017-11-1014:47mitchelkuijpers@thheller It did work before, and I did not see the babel transforms before
#2017-11-1014:47cmalshadow-cljs - server running at http://localhost:8021#2017-11-1014:47thhellerdo you have :ssl {...} at the top level?#2017-11-1014:47thhellernot in the build config?#2017-11-1014:48cmal
{:dependencies
 [[cljs-ajax "0.7.2"]
  [re-frame "0.10.2"]
  [day8.re-frame/undo "0.3.2"]
  [day8.re-frame/http-fx "0.1.4"]
  [cljsjs/react "15.6.2-0"] ;; required by "reagent/impl/util.cljs"
  [reagent "0.7.0"]
  [reagent-utils "0.2.1"]
  [secretary "1.2.3"]
  [garden "1.3.3"]
  #_[braintripping/re-frame-trace "0.1.9"]
  [binaryage/devtools "0.9.7"]
  [re-frisk "0.5.0"]]

 :ssl {:keystore "my-keystore.jks"
       :password "000000"}
 
 :http {:port 8021}...}
#2017-11-1014:49thheller@mitchelkuijpers doh. I accidentally enabled the use of package.json "module".#2017-11-1014:49thhellerI did some tests with that and forgot to disable it again#2017-11-1014:49thhellerthats probably the issue#2017-11-1014:49mitchelkuijpersAh it does look cool but I get some random issues now 😛#2017-11-1014:50thhellerI’ll disable it again. It is definitely causing too many issues.#2017-11-1014:50mitchelkuijpersThnx#2017-11-1014:51thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4e3d262f2a2139632d22243d0e7c607e60797c"}, :content ("[email protected]")}. sorry about that.#2017-11-1014:52mitchelkuijpersNo problem thnx#2017-11-1014:54thheller@cmal I’m setting up a test project now. only tested it from within shadow-cljs itself so I might have missed something#2017-11-1014:59cmalOK. You can clone https://bitbucket.org/cmal/shadow-cljs-demo and run shadow-cljs watch doumi#2017-11-1014:59thhellertest project works as well#2017-11-1015:00cmalDoes that mean I give an invalid keystore file?#2017-11-1015:00thhellerthat should throw an exception. your config looks ok.#2017-11-1015:01cmalI can not remember why I add "/Users/yuzhao/gits/shadow-cljs/src/main"to the :source-paths#2017-11-1015:02thhellerah hehe#2017-11-1015:03thhelleryeah you need to remove that#2017-11-1015:03thhelleror git pull that checkout 😛#2017-11-1015:03cmalstill shadow-cljs - server running at #2017-11-1015:03thhellerotherwise you are using the old code#2017-11-1015:03cmalI removed it.#2017-11-1015:03thhellerit works for me?#2017-11-1015:03cmalstill shadow-cljs - server running at 😢#2017-11-1015:04thhelleryeah I didn’t update the message yet. it will show http always.#2017-11-1015:04thhellerneed to open it to actually see if its working#2017-11-1015:04cmalBUt#2017-11-1015:04cmalit seems works#2017-11-1015:05cmal
browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
#2017-11-1015:05cmalmaybe this is because of the cert#2017-11-1015:06thheller check this#2017-11-1015:06cmalNET::ERR_CERT_REVOKED#2017-11-1015:07thhelleryeah, getting a full trusted cert is complicated#2017-11-1015:08thhelleryou can create one for localhost as I described in the GH issue#2017-11-1015:08thhellerthat seems to work ok#2017-11-1015:08thhellerbut I don’t know how your entire setup works since you are not using a local server?#2017-11-1015:08cmalI rsync my cljs-runtime to the remote server.#2017-11-1015:09cmalmy Chrome get my page from remote server to debug.#2017-11-1015:09cmalhttps://m.beta.joudou.com/stock/annc#2017-11-1015:11cmalonly in the wechat devtool I can get data from the API and see the whole webpage, and it must be in a https:// server.#2017-11-1015:11cmalSo I rsync my file to the remote server and debug in the wechat devtool.#2017-11-1015:12cmalI am not sure, does the error message browser.cljs:281 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED tell me that the ssl-keystore is not valid?#2017-11-1015:13thhellerI don’t know. is your server?#2017-11-1015:13cmalBANG!#2017-11-1015:13cmalI will remove that.#2017-11-1015:13cmal😢#2017-11-1015:13cmal😆#2017-11-1015:14mitchelkuijpers@thheller I am setting up devcards and I got this error:
------ ERROR -------------------------------------------------------------------
 File: /home/mitchel/Development/atlas-crm-next/src/cards/atlas_crm/hipchat/ui/configuration_cards.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns atlas-crm.hipchat.ui.configuration-cards
-------^------------------------------------------------------------------------
Invalid :refer, var devcards.core/defcard does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |    [fulcro.client.cards :refer [defcard-fulcro]]
   4 |    [devcards.core :as dc :refer [defcard]]
   5 |    [atlas-crm.ui.screens.hipchat.configuration :as configuration]
   6 |    [fulcro.ui.forms :as forms]))
--------------------------------------------------------------------------------
when I changed the :refer to :refer-macros it started working. Is the compiler maybe to strict? Because this should work in CLJS
#2017-11-1015:14mitchelkuijpersOn line 4 btw#2017-11-1015:15thhellerhmm devcard.core has no self-require https://github.com/bhauman/devcards/blob/master/src/devcards/core.cljs so no it should not work#2017-11-1015:16cmal@thheller that is the server. remove :http {:port 8021} got WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED#2017-11-1015:17mitchelkuijpersAh true, then it's correct#2017-11-1015:17mitchelkuijpersNvm then @thheller sorry for wasting your time#2017-11-1015:17thheller@mitchelkuijpers should definitely be done by devcards though. does it really work in figwheel without?#2017-11-1015:18mitchelkuijpersYeah somehow it works in figwheel#2017-11-1015:18thhellermaybe something in that behaviour changed in CLJS itself?#2017-11-1015:18thhellerit used to only work with self-require, maybe thats optional now?#2017-11-1015:18thhellerI can totally make that optional too#2017-11-1015:19mitchelkuijpersI don't know tbh#2017-11-1015:19cmal@thheller I see. the wss:// server should be in my local machine, not the remote server.#2017-11-1015:20mikebDoes anyone know if shadow-cljs appends timestamps to sourcemaps, same as the main cljs compiler does mentioned here https://www.reddit.com/r/Clojure/comments/7bwtzu/anyone_here_using_macchiato_in_production/dplvemz/#2017-11-1015:20cmalThe connect to nothing.#2017-11-1015:21thheller@mikeb no it does not#2017-11-1015:21mikebAwesome, thanks. Will let the guys over there know.#2017-11-1015:21mitchelkuijpers@mikeb btw that breaks sourcemaps in firefox if you add timestamps#2017-11-1015:22thheller@cmal you are probably running into https://github.com/thheller/shadow-cljs/issues/91 now. did the websocket ever work?#2017-11-1015:23thhellerI gotta go for a bit … bbl#2017-11-1015:23cmalThank you for that!#2017-11-1015:40chrisdaviesAnyone here gotten shadow-cljs to work with Node? I'm getting Assert failed: (satisfies? build-log/BuildLog logger) when I run.#2017-11-1015:40chrisdaviesI opened an issue before I thought to come here. 🙂#2017-11-1015:50cmal
DEVTOOLS: connected!
browser.cljs:25 DEVTOOLS: REPL init successful
#2017-11-1015:51cmal😆#2017-11-1015:52chrisdavies^^^ My error was caused by an invalid main configuration.#2017-11-1015:52chrisdavies
{:id :script
   :target :node-script
   :main shadowhi.core/main
   :output-to "dist/shadowhi.js"}}}
#2017-11-1015:52chrisdaviesThat worked for me.#2017-11-1210:45Hendrik PoernamaHello, I read "JS-dependencies-in-practice" and am very interested in alternate ways to coexist with npm modules. I'm trying to understand how does shadow-cljs fit in existing build system? Right now I see it as an external application that kinda does everything with its own config files. I see that it also provides watcher and reloader. Does that mean it replaces figwheel or boot-cljs or lein-cljsbuild? Or maybe replace the whole lein/boot in the project?#2017-11-1212:29thheller@poernahi yes, it works standalone. no boot or lein required,#2017-11-1221:11OliverMHi! I'm using shadow-cljs with the guide for working with create-react-app. There's a link to an issue there where @thheller talks about getting auto-reload working for recompiled cljs files. They propose a sym-link solution there, which @thheller makes work - but how? Sorry if this is a noob question, I've been using shadow-cljs for literally 15 minutes#2017-11-1221:44OliverMHmm, also, when I add reagent to my project and require it in a namespace I receive the following error:
Build failure:
The required namespace "create-react-class" is not available, it was required by "reagent/impl/component.cljs".
#2017-11-1221:51OliverM(using the create-react-app example config)#2017-11-1221:59OliverMyarn add create-react-class fixed it, of course#2017-11-1303:54cmalHi, after changed my code, I found that have responsed
java.lang.IllegalArgumentException: No matching clause: :get
	at $files_req.invokeStatic(ws.clj:197)
	at $files_req.invoke(ws.clj:179)
	at $process.invokeStatic(ws.clj:283)
	at $process.invoke(ws.clj:254)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$apply.invoke(core.clj:652)
	at shadow.http.router$call_handler.invokeStatic(router.clj:12)
	at shadow.http.router$call_handler.invoke(router.clj:11)
	at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:20)
	at shadow.cljs.devtools.server.web$root.invoke(web.clj:19)
	at shadow.cljs.devtools.server$get_ring_handler$G__26813__26814.invoke(server.clj:52)
	at ring.middleware.params$wrap_params$fn__14985.invoke(params.clj:67)
	at aleph.http.server$handle_request$fn__13182$f__649__auto____13183.invoke(server.clj:157)
	at clojure.lang.AFn.run(AFn.java:22)
	at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62)
	at manifold.executor$thread_factory$reify__541$f__542.invoke(executor.clj:44)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:745)
#2017-11-1303:56cmalAnd the page was not modified with the newest code, though the console have some correct messages.#2017-11-1307:38thheller@oliver.mooney I didn’t touch the create-react-app example in quite a while. I imagine a lot has changed since then.#2017-11-1307:41thheller@cmal the client side for the code reload will send a http POST request to request the new content#2017-11-1307:41thhellersomehow that gets turned into a GET request? do you have a proxy or so that rewrites the request?#2017-11-1307:43thhelleris there some documentation about this wechat setup you are using?#2017-11-1307:44cmalI changed the source code of shadow-cljs and set the (env/ws-url js/document.location.hostname :browser) to (env/ws-url "localhost" :browser). This enables the hot reload. but got some error in the requests.#2017-11-1307:44cmalThe wechat developer tool just uses chrome.#2017-11-1307:45thhellerright. so I should allow configuration of the host that is used for the websocket and file updates and it should work?#2017-11-1307:46cmalI changed the param to ws-url, but https://clojurians.slack.com/archives/C6N245JGG/p1510545280000082 happens.#2017-11-1307:48thhelleryeah something must happen to the XHR request that gets sent to download the files#2017-11-1307:49thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L114#2017-11-1307:49thhellerit always sends a POST, there is no way it initially sends a GET.#2017-11-1307:50thhellerseems like maybe the wechat developer tools rewrites the request?#2017-11-1307:50cmalI wonder whether this is right:#2017-11-1307:51cmalboth 200, but I cannot see the content.#2017-11-1307:52cmaldevtools says it has reloaded, but page not reload the new content.#2017-11-1307:54cmalThe console got this#2017-11-1307:55thhelleryeah that error is from the server handling the request. it does not expect a GET request and fails. don’t know how a GET request ends up there.#2017-11-1308:02thhellerbut it seems to be loading the JS? how else would it produce those re-frame warnings?#2017-11-1308:18thhellerdid you maybe try to re-run the request in the devtools? that won’t work.#2017-11-1308:28cmalyes. I tried to re-run the request in the devtools. that did not work.#2017-11-1308:29cmalso ignore the :get error.#2017-11-1308:30cmalBut any possibility that the ws sent the data and devtools load the jss but the page is not reloaded?#2017-11-1308:31cmalThe updated code seems not injected into the browser html.#2017-11-1308:34cmal
DEVTOOLS: load JS doumi/bottomnav_comp.cljs shadow.cljs.devtools.client.browser.js:46
DEVTOOLS: load JS doumi/ua.cljs shadow.cljs.devtools.client.browser.js:46 
DEVTOOLS: load JS doumi/core.cljs shadow.cljs.devtools.client.browser.js:46 
#2017-11-1308:48thhellertry putting a (js/console.log "foo") at the top-level in the file. it should reload yes.#2017-11-1308:48cmalok#2017-11-1308:49thhellermaybe you have some code that is not reloadable properly? eg. a fn you put into a map somewhere?#2017-11-1308:49thhellerthere was a bug that the :after-load fn was not loaded properly and was using the old version (from before the code load)#2017-11-1308:49thhellerbut that only affected the :after-load fn, nothing else.#2017-11-1308:52cmalI will have a try#2017-11-1308:56cmalYes, the top level code get reloaded. There must be some problems with my code. Thank you @thheller.#2017-11-1309:13OliverM@thheller thanks, I thought as much - the regex you talk about in the create-react-app example is out of date. I'm trying to reproduce the fix in the issue you raised here: https://github.com/facebookincubator/create-react-app/issues/2281#2017-11-1309:13OliverMIs there a way to set the output directory of shadow-cljs, or is that the normal cljsbuild config option?#2017-11-1309:14OliverMI can just do a link between the directories once I figure that bit out#2017-11-1309:14thhelleryes you can set :output-dir.#2017-11-1309:15thhellerthe create-react-app example I made is currently broken because of the relative require it had#2017-11-1309:15thhellerI need to add support for that again, works fine if you don’t need relative requires in CLJS though.#2017-11-1309:17OliverMI've to restart yarn start after each cljs change and thought that was the culprit, but I'm not using relative requires, hmmm#2017-11-1309:17thhellerthere seems to be a bug with watch. it does not recover when a compile failed with an error.#2017-11-1309:18thhellerlooking at that next. see https://github.com/thheller/shadow-cljs/issues/105#2017-11-1309:19OliverMyeah, I've seen that too, but it's pretty quick to restart - yarn is the slowpoke for me#2017-11-1309:19thhellertry running a separate server instance, so restarting the watch is not to painful#2017-11-1310:11thhellerthe watch problems should go away with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "93e0fbf2f7fce4bef0fff9e0d3a1bda3bda4a7"}, :content ("[email protected]")}#2017-11-1311:43pedrorgirardiHi there! I added this dependency "rmwc": "0.0.1-beta10" to my package.json and I’m getting a funny error message: ReferenceError: Unknown plugin “react-hot-loader/babel” specified in “/Users/pedro/Developer/rmwc-cljs/node_modules/rmwc/package.json” at 0, attempted to resolve relative to “/Users/pedro/Developer/rmwc-cljs/node_modules/rmwc”#2017-11-1311:44pedrorgirardiAny thoughts?#2017-11-1311:45pedrorgirardiThe whole package.json is:
{
  "dependencies": {
    "create-react-class": "^15.6.2",
    "react": "^16.1.0",
    "react-dom": "^16.1.0",
    "rmwc": "0.0.1-beta10"
  },
  "devDependencies": {
    "shadow-cljs": "^2.0.74"
  }
}
#2017-11-1311:46thhellerhmm thats babel#2017-11-1311:48thhelleryou can edit the node_modules/rmwc/package.json and just rename the babel entry to xbabel or so#2017-11-1311:50thhellerprojects usually remove the babel entry when publishing to npm, this one doesn’t it seems#2017-11-1311:51thhellerlet me adjust my babel interop so that it ignores those settings#2017-11-1311:51pedrorgirardireally??#2017-11-1311:51pedrorgirardibig thank you @thheller!#2017-11-1312:01thheller@pedrorgirardi should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "681b00090c071f450b04021b285a4658465f5d"}, :content ("[email protected]")}#2017-11-1312:02pedrorgirardiGiving it a try right now 🙂#2017-11-1312:03thhellermeh doesn’t work#2017-11-1312:04thhellerwill do some tests with rmwc#2017-11-1312:04thhellersee what strange things they do 😉#2017-11-1312:04pedrorgirardi🎉 🎉#2017-11-1312:05pedrorgirardiIt did work! 😉#2017-11-1312:05thhellerah hehe … I tested with the old version … doh 🙂#2017-11-1312:06pedrorgirardihaha#2017-11-1312:19pedrorgirardiEverything working, so good! Thank you again @thheller!#2017-11-1315:26mhuebert@thheller is there a way to set :closure-defines dynamically from the cli? eg. if i want to build a release of a build where the closure variable server-env is set to dev or staging or whatever#2017-11-1315:27thhellerthat sounds more like an env variable the process would read?#2017-11-1315:27thhellerbut no, currently there is no way to set this dynamically#2017-11-1315:31thhelleryou can set env variables for the node process and access it per js/process.env#2017-11-1315:31thheller
THING=foo node
> process.env.THING
'foo'
#2017-11-1316:03mhuebertit’s a server that will build the cljs :release itself, so the app itself is not running on node and has no access to js/process.env#2017-11-1316:04mhuebertam thinking it will end up being a Clojure macro#2017-11-1316:05thhellerhmm not a fan of that#2017-11-1316:05thhellerit breaks caching 😛#2017-11-1316:05thhellerwhat does the the env variable do? where is it used?#2017-11-1316:06mhueberthm. which kind of caching? it would eg/ read an “API_URL” to know which backend to send ajax requests to, localhost:PORT or test-server.x or prod-server.y#2017-11-1316:06mhuebertso static, build-time stuff#2017-11-1316:10thhellerhmm I typically keep those things out of my build and in actual config#2017-11-1316:10thhellerand then pass in this config when calling from HTML#2017-11-1316:11thhellerdo you have a suggestions on how the env thing could look? I can’t think of a good way to do this right now#2017-11-1316:27thhellerah hehe .. just thought of something#2017-11-1316:27mhueberti’m not entirely sure. by ‘actual config’ what do you mean?#2017-11-1316:28thhellerhttps://github.com/shadow-cljs/quickstart-browser#2017-11-1316:29thhellerthis is the basic setup I have in all the things I build#2017-11-1316:29thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2017-11-1316:29thhellerthere is a init fn that is called from HTML#2017-11-1316:30thhellerif I have any runtime configuration that may change due the which user is accessing it#2017-11-1316:30thhelleror which server is running on#2017-11-1316:30thhellerI pass that config to the init fn#2017-11-1316:31mhuebertah i see. so this is a case where index.html is generated by a server vs. static file#2017-11-1316:31thheller<script>starter.browser.init({api_url: "foo"});</script>#2017-11-1316:31thhelleryes#2017-11-1316:32thhellerwell you could also use 2 separate static html files#2017-11-1316:33thhellerI just added something that you could use for this as well though#2017-11-1316:36thheller
(ns demo.run-test
  (:require [shadow.cljs.devtools.config :as config]
            [shadow.cljs.devtools.api :as api]))

(defn build [& args]
  (let [config
        (-> (config/get-build! :your-build)
            (assoc-in [:compiler-options :closure-defines 'some.ns/define] (System/getenv "FOO")))]
    (api/release* config {})
    ))
#2017-11-1316:36thhellershadow-cljs clj-run demo.run-test/build#2017-11-1316:36thhellerscripted the build process more or less#2017-11-1316:36mhueberthah that is almost exactly the code I was just writing as an example 🙂#2017-11-1316:37thhellerclj-run I just added, lets you call any clojure fn from the CLI#2017-11-1316:37thhellersame as lein run -m ...#2017-11-1316:38mhuebertthat was my next question 🙂#2017-11-1316:38mhuebertwhich version was this added in?#2017-11-1316:39thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "483b20292c273f652b24223b087a6678667f7e"}, :content ("[email protected]")} pushed like 5min ago#2017-11-1316:40thhellerI should add a get-build-config fn to the api namespace but besides that it should work#2017-11-1316:40mhuebertthat was fast 👀#2017-11-1316:41thhelleralready had it implemented when you asked 😛#2017-11-1316:41thhellerhttps://clojureverse.org/t/js-dependencies-in-practice/691/12?u=thheller#2017-11-1316:42thhellerits pretty rough and probably needs some tweaking but it should do the job#2017-11-1316:44mhuebertshould that be clj-eval?#2017-11-1316:45mhuebert
Invalid action "clj-run"

Usage:
  shadow-cljs <action> <zero or more build ids>
#2017-11-1316:45thhellerhmm no clj-run#2017-11-1316:46thheller
shadow-cljs clj-run demo.run-test/fn1 1 2 3
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.76
shadow-cljs - connected to server
[:fn1 ("1" "2" "3")]
#2017-11-1316:46thhellerserver process not restarted?#2017-11-1316:47mhuebertah correct. that is a bit confusing because it still shows 2.0.76 even though it’s not actually running that version#2017-11-1316:47thhelleryeah I should add a check for that#2017-11-1317:17thheller@mhuebert btw did you sort out the circleci issues?#2017-11-1318:38mhuebertI have not.. I got stuck sorting out the node/Java docker image and haven’t had time to finish#2017-11-1321:39mhuebertthis clj-run command, super useful#2017-11-1321:49mhuebertit seems to sometimes get stuck on a particular version of a file#2017-11-1321:49mhuebertie. editing the file and clj-run’ing it again, it evaluates the old version#2017-11-1406:20thheller@mhuebert yes it doesn’t to any reloading. when developing you can run it via the REPL and use load-file or (require 'the.ns :reload). maybe I should add some reloading though? not sure about that.#2017-11-1411:00mhuebert@thheller I think I would expect a cli command to load the most current version, it wasn’t in my mental model that there was a server somewhere else holding on to whatever version existed the first time i ran the command#2017-11-1414:11thhellerunfortunately its not that simple#2017-11-1414:12thhellerits fine when I do a simple :reload to only reload the main ns#2017-11-1414:12thhellerbut what if you include something else that you changed?#2017-11-1414:12thhellercan’t :reload-all since that may destroy some parts of the shadow-cljs process#2017-11-1416:30bolasblackHi thheller, how can :target :npm-module generate source map ? I tried :compiler-options {:source-map true}}, it works in :target :browser, but failed in :npm-module. Example: https://github.com/bolasblack/airtable-notifier-temp newest commit#2017-11-1416:36thhellerdon’t remember why I disabled source maps for :npm-module#2017-11-1416:36thhellerbut I can enable it again, hang on.#2017-11-1416:46thhellernevermind .. actually just a bug. fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8efde6efeae1f9a3ede2e4fdcebca0bea0b9b9"}, :content ("[email protected]")}#2017-11-1500:32bolasblackcool! thanks!#2017-11-1507:03cmalI wonder why the devtools reloaded my code but my page function was not applied. I did almostly the same as in a figwheel project. The only difference is that, after adding the compiled js file as a <script> tag, I add another <script> tag, in which the app.core.some_init() function is called. It seems the core.cljs file re-runs after shadow-cljs watch app tells the page(because a (.log js/console "ddd") runs), but I doubt the page does not know the app.core.some_init() function was called, so everything under the some_init function is not applied. Is that right? If so, how to make things under some_init function applied?#2017-11-1507:04thheller@cmal I recommend this kind of setup: https://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2017-11-1507:05thhellerinit is the fn called from HTML. it is only called ONCE ever.#2017-11-1507:05cmalMorning @thheller. You are here.#2017-11-1507:05thhellerthen :before-load will call stop, then load the code and :after-load call the start#2017-11-1507:06thhellerso if you need code to run after ever reload put it in start#2017-11-1507:06thhellermorning 😉#2017-11-1507:06cmalMust I use exactly the name init as the function exported?#2017-11-1507:06thhellerno, the names are all up to you#2017-11-1507:07thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/public/index.html#L9#2017-11-1507:07thhellerI just use this setup because sometimes you have code that can’t be live reloaded#2017-11-1507:08thhellerthat is done in init, so its only done once#2017-11-1507:08thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L18-L21#2017-11-1507:08thhellerdon’t need to use both callbacks. :after-load is enough if you just want something to run after loading code#2017-11-1507:08thhellerI think thats on-jsreload in figwheel#2017-11-1507:09thhelleryou can skip init as well if you don’t need it#2017-11-1507:09thhellerjust call start directly#2017-11-1507:12cmalI found if I change the function page, the figwheel project get reloaded well, but the shadow-cljs project also reloaded, but new page function not applied.#2017-11-1507:12thhelleryou need to call it somewhere?#2017-11-1507:13cmalyes, I add the js to a <script> tag and called app.core.init()#2017-11-1507:13cmalif I add a (.log js/console "bla") that runs.#2017-11-1507:13cmalBut If I change page function, no effect.#2017-11-1507:13thhellerso init is the fn that should run after loading code?#2017-11-1507:14thheller:after-load app.core/init#2017-11-1507:14cmalAhh#2017-11-1507:14cmalMaybe that is the reason.#2017-11-1507:14thhellerdunno what is different in your figwheel code, if you have an example I can take a look what it does differently#2017-11-1507:16cmalI run lein new luminus app +http-kit +re-frame to create a figwheel project.#2017-11-1507:16cmalBut my project is a require.js project.#2017-11-1507:17cmalthe luminus project just {% script "/js/app.js" %} in html template to apply the compiled code.#2017-11-1507:18thheller> :figwheel {:on-jsload "app.core/mount-components"}#2017-11-1507:18cmalIn my project, just did this:#2017-11-1507:18cmal
<!DOCTYPE html>
<html>
    <head>
        <% include ../common/meta.ejs %>
        <link href="/css/icomoon/style.css" rel="stylesheet">
        <% include ../common/autoRem.min.ejs %>
        <% include ../common/zhugeio.ejs %>
        <title><%- title %></title>
    </head>
    <body>

        <div id="app"></div>
        <script src="/doumi/js/doumi.js"></script>
        <script>
         doumi.core.annc_init();
        </script>
    </body>
</html>
#2017-11-1507:18cmalWahh.#2017-11-1507:19cmalGot it.#2017-11-1507:19thhellerso :after-load app.core/mount-components#2017-11-1507:19cmalOK. Thank you very much!#2017-11-1510:58tiensonqinHi, guys I created a shadow-cljs template to make beginners easier. https://github.com/tiensonqin/shadow-cljs-template#2017-11-1511:00thheller@tiensonqin cool!#2017-11-1511:27thheller@tiensonqin how come you removed the :before-load stop call?#2017-11-1511:28tiensonqin@thheller I don't mean to, will add it later.#2017-11-1511:28thhellermade a PR with some other tweaks#2017-11-1515:51Jon
:builds {:browser {:target :browser
                    :output-dir "target/browser"
                    :asset-path "/browser"
                    :modules {:main {:entries [app.main]
                                     :depends-on #{:lib}}
                              :lib {:entries [respo.core respo.macros
                                              respo.comp.inspect]}}
                    :devtools {:after-load app.main/reload!
                               :preloads [shadow.cljs.devtools.client.hud]
                               :http-root "target"
                               :http-port 8080}
                    :release {:output-dir "dist/"
                              :module-hash-names 8
                              :build-options {:manifest-name "cljs-manifest.json"}}}
          :bootstrap-support {:target :bootstrap
                              :output-dir "target/browser/bootstrap"
                              :entries [cljs.js]
                              :macros []}
#2017-11-1515:52thhelleroh#2017-11-1515:53thhellerthought I fixed that#2017-11-1515:53thhellerthe :main module must have shadow.cljs.bootstrap.env in the :entries#2017-11-1515:54thhellerit is supposed to add that automatically though#2017-11-1515:55Jon
[:bootstrap-support] Build failure:
The required namespace "cljs.env.macros" is not available, it was required by "cljs/js$macros.cljc".
#2017-11-1515:55Jonis it related?#2017-11-1515:56thhelleryeah you can’t bootstrap that#2017-11-1515:56thheller:entries [cljs.js] thats not how this works#2017-11-1515:57thhellercljs.js you use in the :browser build, the :boostrap build only includes namespaces that you want to use with the self-hosted compiler#2017-11-1515:57JonI think it's working after I added shadow.cljs.bootstrap.env manually#2017-11-1515:59Jonmy mistake, it should be in :exclude...#2017-11-1516:00thheller:entries should be something like reagent.core or so. namespaces you are going to need when evaling code#2017-11-1516:00thhellercljs.core is enough if you don’t want any other libraries#2017-11-1516:01thhellerhttps://github.com/mhuebert/shadow-bootstrap-example#2017-11-1516:02thhelleryou can include cljs.js with the proper exclude yes#2017-11-1516:07Jonwhat does cljs.js do?#2017-11-1516:10thhellerits what you use to use the bootstrapped compiler#2017-11-1516:13Jonwow#2017-11-1516:13Jondidn't notice from the name#2017-11-1516:15thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/selfhost/simple.cljs might help#2017-11-1516:21JonI read the you blog about bootstrap#2017-11-1516:25Jon
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(app.render.main_BANG_, process.argv.slice(2));
#2017-11-1516:25Jon
{ env: { NODE_ENV: 'development' }, browser: false }
#2017-11-1516:26Jon
=>> node target/ssr.js
Reading from entry/main.css
{ env: { NODE_ENV: 'development' }, browser: false }
SHADOW import error /Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js

/Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js:3
cljs.core.apply.cljs$core$IFn$_invoke$arity$2(app.render.main_BANG_, process.argv.slice(2));
                                                                                  ^
TypeError: Cannot read property 'slice' of undefined
    at Object.<anonymous> (/Users/chen/repo/cirru/cirru.org/target/shadow-cljs/builds/ssr/dev/out/cljs-runtime/shadow.module.main.append.js:3:83)
#2017-11-1516:26Jonany clue how process is overwritten?#2017-11-1516:44thhellerhmm#2017-11-1516:45thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js does this#2017-11-1516:45thhellerbut it isn’t supposed to overwrite anything, just add#2017-11-1516:46thhellerhmm no wait .. its not even supposed to be included for node builds?#2017-11-1516:47thhellerwonder how it gets included#2017-11-1516:47thhellerah doh the bootstrap stuff includes it#2017-11-1516:47thhellerhmm might need to split that then#2017-11-1516:50Jonlooks like :bootstrap does not support code in release mode#2017-11-1516:50thhellerit does#2017-11-1516:50thhellerah wait .. yes you cannot use the boostrapped compile with :advanced only :simple#2017-11-1516:53thhellerhmm a bunch of the :bootstrap stuff is not compatible with node currently#2017-11-1516:53thhellerthats why everything fails#2017-11-1516:53thhellerdid you copy the shadow.cljs.bootstrap.browser ns and create a node version?#2017-11-1516:57Jonnoop...#2017-11-1516:57Jonswitched to :simple, and works now#2017-11-1516:58JonI'm still using in a browser, but using the same component to generate HTML, that's why the bootstrap code is loaded in Node#2017-11-1516:58Jonthis is really a huge log!#2017-11-1516:59thhellerhaha oops. forgot to remove that debug log again 😛#2017-11-1517:00thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "47342f262328306a242b2d3407756977697f74"}, :content ("[email protected]")}
#2017-11-1517:01Jonnever mind. I just did it as an expriment#2017-11-1614:17mhuebertbuilding a bootstrap build:
[:doc-bootstrap] Build failure:
FileNotFoundException: ...project/js/compiled/bootstrap/js/cljs.core.js.map (No such file or directory)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:270)
	java.io.FileOutputStream.<init> (FileOutputStream.java:213)
	 (io.clj:230)
	 (io.clj:230)
it works if i manually create the js/compiled/bootstrap/js/ directory
#2017-11-1615:47Jonsame last night.. almost forgot it#2017-11-1616:22thheller@mhuebert oops, fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7c0f141d18130b511f10160f3c4e524c524448"}, :content ("[email protected]")}#2017-11-1617:44thhellerI refactored the shadow-cljs code related to interop with the closure compiler a bit today#2017-11-1617:45thhellerthat means it is now more flexible when it comes to choosing which :js-provider to use#2017-11-1617:46thhellerthe goal is to use Closure for all projects .js sources while using :shadow for node_modules#2017-11-1617:47thhellerso everything in the project runs through :advanced. I think that should be ok given that you control the .js and could fix :advanced issues if required#2017-11-1617:47thhellerso far it is looking promising#2017-11-1617:49thhellerI wanted to do this for a while but https://groups.google.com/d/msg/clojurescript/PTWne6hLAxI/UXgMDCNuDAAJ prompted me to work on it#2017-11-1617:50thhelleris anyone here jumping through hoops to work with ES6+ code you wrote yourself? ie. not on npm?#2017-11-1617:51thhellerbasic gist is that#2017-11-1617:51thhellersrc/integrated/core.cljs
(ns integrated.core
  "Start here."
  (:require ["./lib" :as lib]))

(defn init! []
  (lib/debugMessage "Narf"))
#2017-11-1617:51thhellersrc/integrated/lib.js
var debugMessage = (x = "any old string") => {
  console.log(`Printing ${x} from cljs!`);
};

export { debugMessage };
#2017-11-1617:52thhellernow works, the lib.js can even use any cljs code via import#2017-11-1617:52thhelleror going a bit more extreme#2017-11-1617:52thheller
import core from "goog:cljs.core";

import { createElement } from "react";

import { bar } from "./more-es6";

var foo = (x = "any old string") => {
  console.log(`Printing ${x} from cljs!`);
  console.log(core.assoc(null, 1, 2));
  console.log(createElement("h1", null, x));
  return bar(x);
};

export { foo };
#2017-11-1617:54thhellerfull JS interop one step closer#2017-11-1617:58thhelleron the surface it works just like before so hopefully it doesn’t break anything#2017-11-1618:00thhellerwould anyone here object to this new default behaviour? ie. running YOUR es6 code through :advanced?#2017-11-1618:02thhelleronly issue is that @dnolen said CLJS is never going to support relative requires, so no support for (:require ["./lib" :as lib]) in core 😞#2017-11-1623:38mhuebertI like the new automatic HTTP server options for the different builds#2017-11-1623:44thhellernew options?#2017-11-1700:12mhuebertoh nevermind. I had forgotten that I had added a devtools server to one of my other builds 🙂#2017-11-1700:13mhuebertseeing the list of HTTP servers in the logs and being able to click on them is nice. (one is a test build, the other an ordinary :browser build)#2017-11-1704:58cmalFileNotFoundException target/shadow-node-repl.js (No such file or directory) java.io.FileInputStream.open0 (FileInputStream.java:-2) when I tried to start shadow-cljs node-repl#2017-11-1706:49cmalAnother question: I add :nrepl {:port 8202} to my shadow-cljs.edn, but it tells me failed to require macro-ns "cljs.repl", it was required by "cljs.repl" when I shadow-cljs watch app#2017-11-1706:52cmalThe project is here : https://github.com/cmal/d3-cljs#2017-11-1706:59thheller@cmal ah doh. should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "47342f262328306a242b2d3407756977697f71"}, :content ("[email protected]")}. I bumped the closure compiler version yesterday but cljs.closure (used by cljs.repl) is not compatible with that.#2017-11-1707:00cmalThanks @thheller.#2017-11-1707:00cmalboth are the same problem?#2017-11-1707:01thhelleryes#2017-11-1707:20cmalHi, @thheller. shadow-cljs watch app works now.#2017-11-1707:20cmal
user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
To quit, type: :repl/quit
[:selected :d3-cljs]
cljs.user> (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.
cljs.user> (cemerick.piggieback/cljs-repl :d3-cljs)
There is no connected JS runtime.
cljs.user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
There is no connected JS runtime.
cljs.user> 
#2017-11-1707:21cmalI use Emacs and follows the instructions on github repo, but the repl seems not work.#2017-11-1707:21thhellerThere is no connected JS runtime. means that you need to open the app in the browser#2017-11-1707:22cmalI use cider in Emacs#2017-11-1707:22cmaland cider-connect to 8202#2017-11-1707:22thhelleryes#2017-11-1707:22thheller
`user> (shadow.cljs.devtools.api/nrepl-select :d3-cljs)
`
#2017-11-1707:22thhellernotice the user>. you were in a CLJ REPL#2017-11-1707:22cmalyep#2017-11-1707:22thhellernrepl-select causes it to switch to a CLJS REPL#2017-11-1707:23thheller
cljs.user> (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.
#2017-11-1707:23cmaland then I go into a cljs.user> repl#2017-11-1707:23thhellerthis then fails because there is no JS “host” connected#2017-11-1707:23thhellerie. in a :browser build you need to open it#2017-11-1707:23cmalI am in a :node-library build#2017-11-1707:23thhellerin :node-library you need to run node#2017-11-1707:24thhelleror use node-repl directly, that launches a node process for you#2017-11-1707:24cmalok#2017-11-1707:24cmalyou mean shadow-cljs node-repl or node-repl in Emacs?#2017-11-1707:25cmalThere is no connected JS runtime. [:node-repl] Configuring build. [:node-repl] Compiling ... [:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 10.58s) JS runtime connected.#2017-11-1707:25thhellerunfortunately you need to launch shadow-cljs node-repl outside of emacs#2017-11-1707:25cmalit works#2017-11-1707:25thhellerbut you can then (shadow.cljs.devtools.api/nrepl-select :node-repl) in emacs#2017-11-1707:26cmal
JS runtime connected.
cljs.user>  (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
There is no connected JS runtime.
cljs.user> 
#2017-11-1707:26cmal`cljs.user> (shadow.cljs.devtools.api/nrepl-select :node-repl) There is no connected JS runtime.`#2017-11-1707:26thhellernote the cljs.user> prompt. you are already in a CLJS REPL. nrepl-select ONLY works in CLJ REPLs#2017-11-1707:27thhellertype :repl/quit to get back to a CLJ REPL#2017-11-1707:27cmal
cljs.user> :repl/quit
:repl/quit
user> (shadow.cljs.devtools.api/nrepl-select :node-repl)
To quit, type: :repl/quit
[:selected :node-repl]
cljs.user>  (defn hello [who]
  (str "Hello, " who "!")
  "ret value")
#'cljs.user/hello
cljs.user> 
#2017-11-1707:27cmalyes!#2017-11-1707:28cmalThanks a lot. @thheller 😢 '#2017-11-1707:28thhellerI’ll change that behaviour so that you can only nrepl-select when the runtime is already connected#2017-11-1707:28thhellertoo confusing otherwise#2017-11-1707:29cmalThanks. simple_smile#2017-11-1707:59cmalAre there any examples for building tests of :node-library project in shadow-cljs?#2017-11-1708:00thhellerwhat do you mean by tests?#2017-11-1708:00cmalI want to write test like in lein test using cljs.test#2017-11-1708:00cmallike deftest and then run-tests#2017-11-1708:01cmalfor a node library#2017-11-1708:01thheller
(ns demo.app-test
  (:require [cljs.test :refer (deftest is)]))

(deftest some-demo-test
  (is (= 1 2)))
#2017-11-1708:02thhellerput that in test/demo/app_test.cljs, add :source-paths ["src" "test"]#2017-11-1708:02thhellershadow-cljs test#2017-11-1708:02cmalThanks !#2017-11-1708:02thhellerhttps://github.com/thheller/shadow-cljs/issues/57#2017-11-1708:03thhellerthat command needs a lot of work though#2017-11-1708:03thhellerits only a proof of concept at the moment#2017-11-1708:03cmalOK!#2017-11-1709:16mitchelkuijpers@thheller the advanced compilation change sounds great#2017-11-1709:17mitchelkuijpersBtw we are also interested in running the tests, that is the only problem we have now, because currently we use lein doo#2017-11-1716:53Jonhttps://github.com/thheller/shadow-cljs/search?utf8=%E2%9C%93&amp;q=babel&amp;type=#2017-11-1716:53Jonshadow-cljs depends on babel... which is unexpected#2017-11-1716:54JonNoticed that since we have unstable network in China...#2017-11-1716:54Jon
=>> yarn
yarn install v1.3.2
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
info There appears to be trouble with your network connection. Retrying...
#2017-11-1716:55Jon
[2/4] 🚚  Fetching packages...
verbose 27.931 Performing "GET" request to "".
[################################################] 188/189
#2017-11-1720:09jgdaveyStarted using shadow-cljs last night. I wish I would have found it sooner! I can suddenly use npm deps that wouldn’t work with :npm-deps!#2017-11-1720:11jgdaveyOne question: is there programmatic access to the Java apis? I’m curious if I can keep the watcher/builder in the same JVM instance as my application’s REPL (clojure).#2017-11-1720:11thhelleryes there is but it has pretty steep dependency requirements#2017-11-1720:12thhellerso you need to be running clojure 1.9#2017-11-1720:12thhellerbeyond that shadow-cljs compile app is the same as calling (shadow.cljs.devtools.api/compile :app)#2017-11-1720:13thhellerthe (shadow.cljs.devtools.server/start!) fn starts the embedded server#2017-11-1720:13jgdaveyOkay, interesting.#2017-11-1720:13thhellerstop! does the shutdown#2017-11-1720:14jgdaveyI wonder if that would work as a boot task (which can use instantiate separate instances/versions of Clojure through the “pod” abstraction)#2017-11-1720:14thhellerI do recommend running it standalone though since its much more optimized that way#2017-11-1720:14thhellerI do not recommend boot at all. they do a bunch of stuff that really get in the way, ie. caching doesn’t work.#2017-11-1720:14jgdaveyOkay, gotcha#2017-11-1720:15thhellerbut I don’t know much about boot so maybe you can figure it out so it works properly#2017-11-1720:16thhellereverything I tried just didn’t seem like a good fit at all#2017-11-1720:16jgdaveyYeah, I’m sure that boot could be used, but if its optimized for cli usage, that seems like the place to start#2017-11-1720:16thheller@jiyinyiyong yes it uses babel-core to transpile ES6 in node_modules.#2017-11-1720:17jgdaveyI’m wanting to minimize friction on a team of folks who are used to lein repl and then a (start) command that does everything, including figwheel#2017-11-1720:18thhelleryeah you can do that if you like, just not recommended.#2017-11-1720:19jgdaveyCool. Thanks for your help!#2017-11-1804:41cmalshadow-cljs watch a node library often tells me this: [:d3-cljs] Build failure: The required namespace "shadow.umd-helper" is not available. But it is working well, just do not know what this means. simple_smile#2017-11-1807:42thhellerodd#2017-11-1807:43thhellerindeed. I can reproduce. looking into it.#2017-11-1807:55thheller@cmal fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c7b4afa6a3a8b0eaa4abadb487f5e9f7e9ffff"}, :content ("[email protected]")}.#2017-11-1807:55cmal👍#2017-11-1810:59thheller@cmal saw your fork. you can now use {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "087b60696c677f256b64627b483a2638263031"}, :content ("[email protected]")} and specify :devtools {:use-document-host false} which changes the default behaviour and then uses the :host specified in :http {:host ...} which defaults to "localhost" instead of js/document.location.hostname#2017-11-1818:08Jonany reason we use manifest.json rather than *.edn?#2017-11-1818:29thhellerway back when I introduced the feature I was using a ruby script for deployment. it was easier to use .json files, thats pretty much the reason. never changed it since.#2017-11-1819:37jgdaveyI had an issue the other day with two npm dependencies clashing. Specifically object-assign and object.assign. How are these npm dep names munged?#2017-11-1819:47thhellerah hehe you are not the first to run into that one#2017-11-1819:48thhellermunging is done by (ModuleNames/fileToModuleName js-name)#2017-11-1819:49thhellerwhich is a utility function from the Closure Compiler#2017-11-1819:49thhellerwhich we kinda have to use unfortunately#2017-11-1819:49thhelleryou can use :resolve {"object-assign" {:target :npm :require "object.assign"}}#2017-11-1819:50thhellerso only one is included, assuming that they both do the same thing#2017-11-1819:50thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#redirecting-require#2017-11-1819:52jgdaveyAh, okay#2017-11-1819:52jgdaveyI assume they’re both polyfills, but I’d have to check#2017-11-1819:52jgdaveyThanks!#2017-11-1819:56thhellerlooks like they are doing the same thing yes.#2017-11-1820:00thhellerthe amount of polyfills npm packages depend on is scary.#2017-11-1901:40jgdavey@thheller Made a proof-of-concept boot task for the “release” phase: https://github.com/jgdavey/boot-shadow-cljs#2017-11-1901:41jgdaveyI left caching dir to default, and boot doesn’t touch it. It also works if your project doesn’t use clojure 1.9#2017-11-1906:21thheller@jgdavey neat. I added api/get-build-config recently so you don’t need to import the config namespace.#2017-11-1906:22thhellerboot usually does weird stuff to the classpath though#2017-11-1906:22thhellerdo incremental builds work?#2017-11-1908:55cmal@thheller thanks for 2.0.89#2017-11-1914:22thhellerif someone here likes building visualizations I could use some help with this: https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871#2017-11-1916:24Jonhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web/common.clj#L7-L13#2017-11-1916:24Jon
(defn not-found
  ([req]
    (not-found "Not found."))
  ([req msg]
   {:status 404
    :headers {"content-type" "text/plain"}
    :body msg}))
#2017-11-1916:24Jon
shadow-cljs - starting ...
shadow-cljs - HTTP server for ":app" available at 
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (155 files, 54 compiled, 0 warnings, 19.67s)
[2017-11-20 00:18:33 - SEVERE] error in HTTP handler
java.lang.StackOverflowError
	at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9)
	at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7)
	at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9)
	at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7)
	at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9)
	at shadow.cljs.devtools.server.web.common$not_found.invoke(common.clj:7)
	at shadow.cljs.devtools.server.web.common$not_found.invokeStatic(common.clj:9)
#2017-11-1916:24Jonprobably a bug#2017-11-1916:24thhelleroops#2017-11-1916:25thhelleryes, fixed#2017-11-1916:25thhellerthx#2017-11-1916:25thhelleroh hehe. I forgot that I need to bundle the .js for the ui now …#2017-11-1916:26thhellerdoesn’t do anything yet but still the 404 shouldn’t happen#2017-11-1916:27Jondidn't heard about UI?#2017-11-1916:27Jonwhat's that#2017-11-1916:27thhellerwell, what is going to be the UI. http://localhost:8080#2017-11-1916:27thhellerdoes not do anything yet.#2017-11-1916:30Jonoh#2017-11-1920:38thheller2.0.93 fixes the stackoverflow error above#2017-11-2014:05thhellerprobably going to write a blog post about this but I think I have finally arrived at 100% JS interop#2017-11-2014:05thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/local-js#2017-11-2014:05thhellerhttps://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/foo.js#2017-11-2014:05thhellerhttps://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/app.cljs#2017-11-2014:06thhellerCLJS using JS, JS using CLJS#2017-11-2014:06thhellereven with support for async/await and other newer JS features (see the .js file)#2017-11-2014:09thhellernot sure if anyone actually wants to do this but it was bothering me that it wasn’t possible or way too hard#2017-11-2015:09Jonlong time no changelog, btw...#2017-11-2022:57thhellerhttps://youtu.be/knTj3budWsU#2017-11-2023:04thhellerhttps://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/8#2017-11-2113:01mitchelkuijpersDoes anyone else run into this error after upgrading to the newest shadow-cljs?#2017-11-2113:02mitchelkuijpersAhh guess I need the newest core.async#2017-11-2113:19mitchelkuijpersNvm fixed by upgrading core.async#2017-11-2113:59thheller@mitchelkuijpers oops, yeah upgraded a bit prematurely I guess. I really need to sort out those dep conflicts properly 😛#2017-11-2114:04mitchelkuijpersit seems related that I have a nrepl open for that build#2017-11-2114:05mitchelkuijpersNope I made a boo boo in my code, but it seems to give errors like this when I screw up a macro#2017-11-2114:07thhellerhmm good to know, I’ll check it out#2017-11-2114:08mitchelkuijpersAnd I have one more question, does shadow-cljs reloads all affected namespaces by default? Or can I turn that on somehow#2017-11-2114:08mitchelkuijpersI have one ns that requires all tests files and I have to touch that before it reloads#2017-11-2114:08thhellerall directly affected namespaces, so only namespaces that have a require for the one that was changed#2017-11-2114:09mitchelkuijpersAh ok maybe I am doing something wrong then#2017-11-2114:09mitchelkuijpersI have a xxxx-test -> tests-to-run -> client-test-main#2017-11-2114:10thhellerdo you run all the tests all the time?#2017-11-2114:11mitchelkuijpersWe have a web renderer for the tests which probably just re-runs all tests or only the changed#2017-11-2114:11mitchelkuijpersI think it only runs changed ones#2017-11-2114:11mitchelkuijpersMaybe i just configured something wrong#2017-11-2114:13thhellertest is a somewhat special case since the test runner is constructed by a macro#2017-11-2114:13thhellerso technically it depends on all other namespaces but that is not properly expressed anyways#2017-11-2114:13mitchelkuijpersNow it seems to work somehow, not sure what the deal is#2017-11-2114:14mitchelkuijpersFor us it is because we have one NS like this:
(ns atlas-crm.tests-to-run
  (:require
   atlas-crm.sample-spec
   atlas-crm.ui.impl.routing.path-spec
   atlas-crm.ui.impl.routing.linear-search-router-spec))
#2017-11-2114:15mitchelkuijpersAnd then this:
(ns atlas-crm.client-test-main
  (:require atlas-crm.tests-to-run
            [fulcro-spec.selectors :as sel]
            [fulcro-spec.suite :as suite]))

(suite/def-test-suite client-tests {:ns-regex #"atlas-crm\..*-spec"}
  {:default   #{::sel/none :focused}
   :available #{:focused :should-fail}})
#2017-11-2114:15mitchelkuijpershmm yes maybe this macro breaks it#2017-11-2114:16thhelleryeah because of the indirection or tests-to-run, atlas-crm.client-test-main is not reloaded#2017-11-2114:16thhellersince it does not directly depend on the file#2017-11-2114:16thhellerI can add a “reload all” but in the past that was total overkill#2017-11-2114:16mitchelkuijpersBut it does not matter that client-test-main depends on tests-to-run?#2017-11-2114:17thhellertests-to-run is probably reloaded, but def-test-suite macro probably inspects some analyzer data and is not reloaded to do that again#2017-11-2114:17mitchelkuijpersAahh ok#2017-11-2114:18mitchelkuijpersWell it works good enough so not such a big deal#2017-11-2114:18thhellerwhy the indirection? why not put all the requires into the client-test-main?#2017-11-2114:19mitchelkuijpersbecause I also have on for CI#2017-11-2114:19mitchelkuijpersthis way I can share them all#2017-11-2114:19mitchelkuijpers
(ns atlas-crm.CI-runner
  (:require
   atlas-crm.tests-to-run
   [doo.runner :refer-macros [doo-all-tests]]))

;; This file is for running JS tests via karma/node for CI server
(doo-all-tests #".*-spec")
#2017-11-2114:19thhellerah ok#2017-11-2114:19mitchelkuijpersAnd figwheel does handle this case I think#2017-11-2114:20thhellerthats why I want to do a proper shadow-cljs test so you don’t have to write any of that#2017-11-2114:20mitchelkuijpersBut if there is better way them I am all ears#2017-11-2114:20mitchelkuijpersYeah that would be great#2017-11-2114:21mitchelkuijperswhich turns green when all tests pass#2017-11-2114:22mitchelkuijpersBut I rather have a good console runner with watch#2017-11-2114:24thhellerwhat I could probably do very easily is let you define the test runner#2017-11-2114:24thhellerand then use a regexp of some sort to construct the tests-to-run, or rather ensure that the namespaces are compiled/loaded properly#2017-11-2114:25thhellercoming up with a new test runner is a lot more work though#2017-11-2114:30mitchelkuijpersYeah maybe a bit too much work#2017-11-2114:31mitchelkuijpersI think most also allow you to give the namespaces instead of a regex macro thingy#2017-11-2114:45thhellerhmm doo is lein specific it seems 😞#2017-11-2114:57mitchelkuijpersThe code I have sent I just compile with shadow and then run with karma#2017-11-2114:57mitchelkuijpersthis:
(ns atlas-crm.CI-runner
  (:require
   atlas-crm.tests-to-run
   [doo.runner :refer-macros [doo-all-tests]]))

;; This file is for running JS tests via karma/node for CI server
(doo-all-tests #".*-spec")
#2017-11-2115:02thhellerhow do you compile? I have never used karma, what does the config look like? and the build config?#2017-11-2115:11mitchelkuijpersHold on I will share it#2017-11-2115:12mitchelkuijpersI have a karma.conf file in the root of the project with this in it:
module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless'],
    basePath: 'resources/public/',
    files: ['js/ci/ci.js', {pattern: 'js/ci/cljs-runtime/**', included: false}],
    frameworks: ['cljs-test'],
    plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
    colors: true,
    logLevel: config.LOG_INFO,
    client: {args: ["doo.runner.run_BANG_"],
    singleRun: true}
  })
};
#2017-11-2115:12mitchelkuijpersI added these deps:
"karma": "^1.7.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-cljs-test": "^0.1.0"
#2017-11-2115:13mitchelkuijpersand then I do yarn exec karma start or if you are using npm npx karma start#2017-11-2115:13mitchelkuijpersI have a config in my shadow-build.end like this:
:ci {:target :browser
               :asset-path "/base/js/ci"
               :modules {:ci {:entries [atlas-crm.CI-runner]}}
               :output-dir "resources/public/js/ci/"
               :devtools {:preloads [devtools.preload]}}
#2017-11-2115:14mitchelkuijperswith the above pasted CI-runner#2017-11-2115:14mitchelkuijpersI will make a example later this week for fulcro users#2017-11-2115:14thhellerexcellent. thx. I can definitely remove some of the boilerplate#2017-11-2115:15mitchelkuijpersI see a that a lot fulcro users want to use npm deps but they are not quite sure how, hopefully a example will help#2017-11-2115:16mitchelkuijpersChromeHeadless is gold btw for CI#2017-11-2115:17thheller
(suite/def-test-suite client-tests {:ns-regex #"atlas-crm\..*-spec"}
  {:default   #{::sel/none :focused}
   :available #{:focused :should-fail}})
#2017-11-2115:17thhellerthat has a separate config I presume?#2017-11-2115:17thhellerthe fulcro tests?#2017-11-2115:17mitchelkuijpersNo more cryptic phantomjs errors but sourcemapped errors in the console#2017-11-2115:18mitchelkuijpersThat is only to run the tests in the browsers#2017-11-2115:18mitchelkuijpersWith that you get the whole testing UI in the browser#2017-11-2115:19mitchelkuijpersThe config for that is:
:test {:target :browser
                 :asset-path "/js/test"
                 :modules {:common {:entries []}
                           :devcards {:entries [atlas-crm.cards] :depends-on #{:common}}
                           :test {:entries [atlas-crm.client-test-main] :depends-on #{:common}}}
                 :output-dir "resources/public/js/test/"
                 :compiler-options {:devcards true}
                 :devtools {:http-port 8600
                            :http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
                            :http-handler dev.test-handler/handler
                            :after-load atlas-crm.client-test-main/client-tests
                            :preloads [shadow.cljs.devtools.client.hud devtools.preload]}}
#2017-11-2115:19mitchelkuijpersI have one build for devcards and tests#2017-11-2115:19thhellerthx, that helps a lot.#2017-11-2115:24thhellerinteresting that you’d use a custom handler without static files#2017-11-2115:24thhellerI would not have expected that someone would do that 🙂#2017-11-2115:25thhellerI’ll mess around with the testing stuff later, already have some ideas.#2017-11-2115:26thhellerbbl#2017-11-2115:54mitchelkuijpersOh do you want the handler I needed it because some assets get server from the classpath#2017-11-2211:24thheller@mitchelkuijpers what does your :http-handler do? what kind of assets? css I presume?#2017-11-2211:27mitchelkuijpers@thheller
(ns dev.test-handler
  (:require [ring.middleware.resource :as ring-resource]))

(defn not-found [req]
  {:status 404
   :headers {"content-type" "text/plain"}
   :body "Not found."})

(defn wrap-dir-index [handler]
  (fn [req]
    (handler
     (update-in req [:uri]
                #(if (= "/" %) "/index.html" %)))))

(def handler (-> not-found
                 (ring-resource/wrap-resource "public")
                 (wrap-dir-index)))
#2017-11-2211:28mitchelkuijpersAlso pre-compiled js#2017-11-2211:28thhellerah ok.#2017-11-2211:30thhellerI can probably add an option for that as well.#2017-11-2211:34thhellerI fixed the most annoying part first. all those damn macros in cljs.test#2017-11-2211:34mitchelkuijpersCool, I also hadd to add a public dir or it wouldn't start up a http server#2017-11-2211:35thhelleryes, I’ll make :http-root optional if :http-handler is set.#2017-11-2211:35mitchelkuijpersNice#2017-11-2211:36thhellertest are now queryable at runtime so you can probably build some fancy UIs out of that#2017-11-2211:36thhellerjust need to figure out how to configure all of this from a build perspective#2017-11-2211:40mitchelkuijpersMaybe give a test filename regex or something#2017-11-2211:40thheller
{:target :browser
   :asset-path "/js/test"
   :modules {:common {:entries []}
             :devcards {:entries [atlas-crm.cards] :depends-on #{:common}}
             :test {:entries [atlas-crm.client-test-main] :depends-on #{:common}}}
   :output-dir "resources/public/js/test/"
   :compiler-options {:devcards true}
   :devtools {:http-port 8600
              :http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
              :http-handler dev.test-handler/handler
              :after-load atlas-crm.client-test-main/client-tests
              :preloads [shadow.cljs.devtools.client.hud devtools.preload]}}
#2017-11-2211:40thhellerneeds way more options that just a regex though#2017-11-2211:41thhellershadow-cljs browser-test some-regexp can probably spin up a http server and open it#2017-11-2211:41thhellerbut how would you configure the :http-handler#2017-11-2211:42thhellershadow-cljs browser-test --test-match some-regexp --port 1234 --handler some.ns/handler --runner atlas-crm.client-test-main etc#2017-11-2211:43thhelleryou end up with a whole bunch of optionas#2017-11-2211:49mitchelkuijpersHmm yes but most probably don't need the handler option#2017-11-2211:50thhelleryes but what do you do if you need it?#2017-11-2211:52thhellerdo you ever use the karma test server thing?#2017-11-2214:35mitchelkuijpersNot really#2017-11-2216:57colindresjI’m having a little troubling with shadow and namespaces#2017-11-2216:57colindresjI keep getting filename violation statements#2017-11-2216:59colindresjFor example:
INFO: filename violation for ns paper.components.tooltip, got: cljs/paper/components/tooltip.cljs expected: paper/components/tooltip.cljs (or .cljc)
#2017-11-2217:00colindresjMy shadow-cljs.edn file has :source-paths set to ["src/cljs"]#2017-11-2218:02thheller@colindresj thats odd, can you run shadow-cljs --cli-info?#2017-11-2218:03colindresjYeah#2017-11-2218:04thhellerhmm#2017-11-2218:04thhellerare you using :lein in your config? when embedding inside boot or lein their classpath will be used and :source-paths has no effect.#2017-11-2218:07colindresjYeah I am#2017-11-2218:08colindresjThe lein source path looks like this ["src/cljs" "src/cljc"]#2017-11-2218:08thhellersomehow "src" ends up in your classpath as well#2017-11-2218:09colindresjLet me dig around some more, the project.clj source paths vector looked different earlier (and had “src” in it)#2017-11-2218:10thhellerbtw its fine to use one source path. I put my cljs/cljc files into the same dir#2017-11-2218:11colindresjYeah, I keep going back and forth on which organizational style I prefer#2017-11-2218:12colindresjKind of related question: I’m currently using lein: true because I want to manage my clojure dependencies via project.clj (for cursive support)#2017-11-2218:13colindresjIs the lein option a full opt-in, or can I just use lein for dependency management, and shadow for classpath building via the .edn file’s source path vector?#2017-11-2218:15thhellerwow I never thought of that#2017-11-2218:16thhellercurrently the process is just launched through lein#2017-11-2218:16thhellerbut I could maybe just use it to get the classpath and then add the define :source-paths#2017-11-2218:17thhelleryou can however also use shadow-cljs pom to generate a pom.xml and use that for cursive#2017-11-2218:19colindresjOh sweet, didn’t realize that, will give it a try and see if it works#2017-11-2218:22thhellerproject.clj still gives you more features so its not 100%#2017-11-2218:25colindresjIt’s ok to have a shadow-cljs.edn file that just lists out :lein true and :builds ..., nothing else#2017-11-2218:25colindresjRight?#2017-11-2218:25thhelleras soon as cursive supports the new deps.edn I’ll add support for that which should remove some of the lein oddities#2017-11-2218:25colindresjAwesome#2017-11-2218:25thhelleryes, fine.#2017-11-2218:25colindresjThanks for the help#2017-11-2218:36thheller@mitchelkuijpers I’m fighting karma I don’t really understand what its doing#2017-11-2218:36thheller
22 11 2017 19:36:28.744:WARN [web-server]: 404: /js/cljs-runtime/goog.debug.error.js
22 11 2017 19:36:28.744:WARN [web-server]: 404: /js/cljs-runtime/goog.dom.nodetype.js
22 11 2017 19:36:28.745:WARN [web-server]: 404: /js/cljs-runtime/goog.string.string.js
22 11 2017 19:36:28.747:WARN [web-server]: 404: /js/cljs-runtime/goog.asserts.asserts.js
#2017-11-2218:36thhellerI assume thats because of the include: false from your config#2017-11-2218:37thhellerbut when I add them it will add them to the page itself which just breaks#2017-11-2218:37thhellerdo I need to compile to one file only?#2017-11-2218:39thhellerI seem to have the correct basePath but the js file can’t include anything else#2017-11-2218:42thhellerit loads all the js weirdly, guess it really wants one file only#2017-11-2218:48thheller
HeadlessChrome 0.0.0 (Mac OS X 10.12.6) LOG: '0 failures, 0 errors.'

22 11 2017 19:47:59.079:WARN [HeadlessChrome 0.0.0 (Mac OS X 10.12.6)]: Disconnected (1 times), because no message in 10000 ms.
HeadlessChrome 0.0.0 (Mac OS X 10.12.6) ERROR
  Disconnected, because no message in 10000 ms.
#2017-11-2218:49thhellerworks, just needs some karma interop I guess#2017-11-2218:49mitchelkuijpersAh you still need help @thheller#2017-11-2218:50mitchelkuijpersThe include stuff is really annoying not sure why it works that way..#2017-11-2218:50thhellerI think we really don’t want to run tests through karma at dev time#2017-11-2218:51thheller
:test-dummy
  {:target :browser-test
   :output-dir "out/demo-test-dummy/public/js"
   :devtools
   {:http-root "out/demo-test-dummy/public"
    :http-port 8606}}
#2017-11-2218:51thhellerI have this for now#2017-11-2218:51thhellerall the necessary hooks will be generated#2017-11-2218:52thhellerstill need a way to filter the namespaces but by default all namespaces that require cljs.test will be included#2017-11-2218:52thhellerwhich probably won’t work for fulcro#2017-11-2218:53mitchelkuijpersIt does use cljs.test under the hood#2017-11-2218:53mitchelkuijpersBut does it simply inspects all the files?
#2017-11-2218:53thhellerno it must have a require for cljs.test itself to trigger this#2017-11-2218:53thhellerbut I guess the regexp you where using is more flexible#2017-11-2218:54thhellersince its just about including the file in the build nothing more#2017-11-2218:54mitchelkuijpersYes that is pretty much the only thing#2017-11-2218:58mitchelkuijpersAhh now I see the browser-test target.. took me a while. I like that solution ^^#2017-11-2219:07thhellercan specify :runner for a custom runner#2017-11-2219:07thhellerstill messing with the details but the test one I’m using currently looks like#2017-11-2219:07thheller
(ns shadow.test.browser
  "generic browser test runner"
  (:require [shadow.test :as st]
            [shadow.dom :as dom]))

;; FIXME: implement custom reporter instead
(defonce log-node (dom/by-id "log"))
(when log-node
  (set-print-fn!
    (fn [s]
      (dom/append log-node (str s "\n")))))

(defn start []
  ;; (js/console.log "test env" @st/tests-ref)
  (st/run-all-tests))

(defn stop [done]
  (set! (.-innerText log-node) "")

  ;; FIXME: determine if async tests are still running
  ;; and call done after instead
  ;; otherwise a live reload might interfere with running tests by
  ;; reloading code in the middle
  (done))

;; not sure we need to do something once?
(defn ^:export init []
  (start))
#2017-11-2219:08thhellercould build something cooler but it’ll do for now#2017-11-2219:11mitchelkuijpersAh cool, if I would build a custom runner then how would I get a hold of all the test namespaces?#2017-11-2219:11mitchelkuijpersWith shadow.test somehow?#2017-11-2219:13thhelleryep, shadow.test/tests-ref is an atom with all the tests#2017-11-2219:19thhellerits all cljs.test as usual, the only thing I added is that deftest is registered at runtime#2017-11-2219:19thhellerso you can query everything and don’t need a macro to do that#2017-11-2219:19thhellerie. it gets very easy to just run tests that were live reloaded#2017-11-2219:29thhellerall this info was previously reserved for macro which is why anything involving tests also had to use macros#2017-11-2219:29thhellerthat takes care of that problem#2017-11-2219:29thhellermuch more flexibel#2017-11-2220:27thheller@mitchelkuijpers https://github.com/thheller/shadow-cljs/issues/57#issuecomment-346464244#2017-11-2220:47mitchelkuijpersDamn thats awesome will def try this out tommorow#2017-11-2300:14colindresj@thheller How can I generate the bundle-info.edn file for a build?#2017-11-2300:15colindresjI though shadow-cljs release my-build would add it to the output, but I’m not seeing it#2017-11-2302:20thheller@colindresj I’m still messing around with the functionality. its not ready but you can run shadow-cljs clj-repl and then (shadow/release-snapshot :build-id)#2017-11-2302:21thhellerit will be in target/shadow-cljs/release-snapshots/build-id/latest#2017-11-2302:21thhellerif you are only after the bundle-info.edn thats fine.#2017-11-2304:01thheller@cmal can’t sleep and needed to code something so I did the keyword optimization we were talking about#2017-11-2304:02thhellertest compiled my production app which is split into 4 modules#2017-11-2304:03thhellerlargest module went from 413761 bytes -> 406811 bytes before gzip and 53808 -> 52762 gzip’d.#2017-11-2304:03thhellerdoesn’t seem that great …#2017-11-2304:04thhelleryou can try it with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c3506746876687f7e"}, :content ("[email protected]")} and setting :compiler-options {:shadow-keywords true}#2017-11-2304:04thhellerI’m really surprised how little difference it actually makes#2017-11-2304:05thhellerneeds some more real world testing#2017-11-2304:06thheller3kb gzip across all 4 modules#2017-11-2304:07thhellershould be much larger difference in reagent apps though#2017-11-2304:07thhellera lot more keywords#2017-11-2304:08thhellernot sure how to test overall perf impact#2017-11-2304:18devoAnyone gotten a fulcro project building with shadow-cljs? Getting an error about clojure.future not being on the classpath, which I'm pretty sure is from https://github.com/tonsky/clojure-future-spec.#2017-11-2304:25devonvm, rolling version back to 1.1.1 resolved it.#2017-11-2305:04cmal@thheller Excellent work! I will check how this will decrease my compiled and gzip'd file.#2017-11-2305:12cmal187304 -> 185424 for gzipped file#2017-11-2305:12cmalparrot#2017-11-2308:10thhellerhmm thats like 1%.#2017-11-2308:11thheller@devo @mitchelkuijpers is using fulcro. clojure-future-spec is ignored by default since its a backport of clojure.spec to 1.8 but shadow-cljs already uses clojure 1.9#2017-11-2308:11thhellerbut it seems like that the backport was changed so it should be safe to require now#2017-11-2308:12thhellerlast time I checked it wasn’t safe to use. I will remove the removal so the clojure.future works again.#2017-11-2308:53thheller@cmal wrote a post about it, hope its ok that I used your numbers and mentioned you. https://clojureverse.org/t/feature-highlight-shadow-keywords/952#2017-11-2308:57cmalThat is OK. Thanks @thheller#2017-11-2309:05rauh@thheller Very cool stuff. I'm envisioning keyword interning here 🙂#2017-11-2309:05rauhBtw, you probably wanna remove the console.log statement in the code#2017-11-2309:05rauh(in constants-inject)#2017-11-2309:06thhellerhahaha OMG#2017-11-2309:06thhellershould not code at 5am#2017-11-2309:06thheller😛#2017-11-2309:06thhellerthx#2017-11-2309:06rauhKeyword interning could mean we can rewrite (= :foo a) to (identical? :foo a)#2017-11-2309:06thhellernah that can never work with :none#2017-11-2309:06rauhWell yeah, in production builds.#2017-11-2309:07thhellerwell it could work now that we have weak references (in some browsers)#2017-11-2309:07rauhYeah browser builds only for interning keywords. No risk there. Doesnt' even need a weakref#2017-11-2309:23sundbpHi. I’m testing out shadow-cljs for a node cli tool. Looks cool so far - great project!#2017-11-2309:24sundbpI’m looking at the release build output of a very simple hell-world:#2017-11-2309:24sundbp
(ns permafrost.main)

(def value-a 3)
(defonce value-b 2)


(defn reload!
  []
  (println "Code updated.")
  (println "Trying values:" value-a value-b))


(defn main
  [ & argv ]
  (println "App loaded:" argv))
#2017-11-2309:25sundbpthe shadow-cljs.edn:#2017-11-2309:25sundbp
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [[cider/cider-nrepl "0.16.0-SNAPSHOT"]
  [refactor-nrepl "2.4.0-SNAPSHOT"]]

 :nrepl
 {:port 8202}

 :builds
 {:pf {:target :node-script
       :output-to "out/permafrost.js"
       :main permafrost.main/main
       :devtools {:after-load permafrost.main/reload!}
       :release {:output-to "permafrost.js"}}}}
#2017-11-2309:25mitchelkuijpers@devo Send me a message if you need help, will publish a shadow-cljs starter with fulcro soon#2017-11-2309:25sundbpthe output is 838kb. I expected something smaller.#2017-11-2309:26sundbpis my assumption or setup wrong?#2017-11-2309:26thheller@sundbp by default the node targets are just using :optimizations :simple due to larger number of externs required on node setups#2017-11-2309:27sundbpso no dead code deleting?#2017-11-2309:27thhellertry compiling with :compiler-options {:infer-externs :auto :optimizations :advanced}#2017-11-2309:28thhellersome DCE is still done but much less aggressive. also no renaming happens since file size usually is not that important for node.#2017-11-2309:28thhellerbut the above settings will take care of that#2017-11-2309:28thhellerthen you get the full experience but might need to fix a few externs#2017-11-2309:29sundbpok. i was just surprised that not most got eliminated as i assumed just some println would bring in almost nothing#2017-11-2309:29thhellernah barely anything is removed in :simple#2017-11-2309:29sundbpso with those settings it’s 85kb#2017-11-2309:30thhellersounds about right#2017-11-2309:30sundbpcool. thanks#2017-11-2309:30thhellercan get it even lower but then you can’t println or prn only console.log#2017-11-2309:31thhellerbut any real code will be about that size minimum since its cljs.core with the datastructures#2017-11-2309:32sundbpright. made 1k diff to change to console.log#2017-11-2309:33sundbpnot worried about size - just verifying my understanding of what’s going on#2017-11-2309:34sundbpanother assumption: if i aim to package up an npm package with a cli tool using some npm packages. I put my dependencies in package.json, do my thing. the release build will not bring in any code from the npm packages into my output, right?#2017-11-2309:34thhellerif you set :build-options {:print-fn :none} it should go down more#2017-11-2309:34sundbpi.e. i’ll get an output that has all the code from the “cljs land”, but none from the “npm land” and hence fitting in nicely with npm#2017-11-2309:35thhelleryou can take a look at what I do for shadow-cljs itself#2017-11-2309:35thhellerhttps://github.com/thheller/shadow-cljs/tree/master/packages/shadow-cljs#2017-11-2309:35thhellerthats the package for npm#2017-11-2309:36sundbpcool. will do#2017-11-2309:36thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L29-L40 thats the build config#2017-11-2309:36sundbpbtw, I didn’t see any change with the print-fn change#2017-11-2309:37thhelleroh you might need to wipe your cache#2017-11-2309:37sundbpah. the npm-module target. was reading the source on that one as no docs yet.#2017-11-2309:37sundbpah. how do i do that?#2017-11-2309:37thhellerrm -rf target/shadow-cljs/builds/build-id#2017-11-2309:37thhellerI think I missed adding that setting to the cache-affecting-options 😉#2017-11-2309:37sundbpcool#2017-11-2309:38thhellerthe :npm-module name is a bit misleading. you can use :node-library as well which is a bit smaller and better optimizable than :npm-module#2017-11-2309:38thhellerI needed to a few “special” things thats why I used :npm-module#2017-11-2309:39thheller:node-script is fine too, thats how I started.#2017-11-2309:39sundbpstill see no effect of the :print-fn :none#2017-11-2309:39thhellerwith just (js/console.log "foo") in your code?#2017-11-2309:39thhellerah wait#2017-11-2309:40thheller
(defn main
  [ & argv ]
  (println "App loaded:" argv))
#2017-11-2309:40thhellerremove the &#2017-11-2309:40sundbpk 🙂#2017-11-2309:40thhellervarargs keep some collection code alive#2017-11-2309:41thhellerbut really don’t go down this road .. it won’t get below 85k in any reasonable app#2017-11-2309:41thhellerthats pretty much the minimum as soon as you use anything from cljs.core#2017-11-2309:41sundbpunderstood. wasn’t the intention - just wanted to check my understanding of what was going on#2017-11-2309:42thhelleras for the npm thing I recommend outputting into a dedicated directory with its own package.json. don’t use the one at the project root.#2017-11-2309:42thhelleryou can but you have to be really careful with devDependencies and such then#2017-11-2309:43sundbpright. i figured it’d be pretty safe with devDependencies vs dependencies?#2017-11-2309:43sundbpjust have the right thing in the right category and you’ll get the right outcome?#2017-11-2309:44thhelleryeah if you are careful it should work out.#2017-11-2309:44sundbpcool#2017-11-2309:45sundbpthanks a lot for the help - looks like the way to go for CLI tools in cljs for me!#2017-11-2309:47sundbpi’m curious about closh using lumo to run its node output: https://github.com/dundalek/closh/blob/master/bin/closh.js#2017-11-2309:47thhellerits pretty terrible to use lumo to do that if you ask me 😛#2017-11-2309:48sundbpwonder if related to that --cache option?#2017-11-2309:48thhellerlumo is great but having it check if something needs to be compiled before running it is not useful for production builds#2017-11-2309:49thhellermuch rather launch directly without all that overhead#2017-11-2309:49sundbpyes. i don’t quite understand.. because they already do a cljsbuild via lein to get an :advanced optimization output..#2017-11-2309:49thhellerclosh is a different story since it needs runtime eval#2017-11-2309:49sundbpah. that’s why they want lumo, got it.#2017-11-2309:50sundbpmakes more sense now#2017-11-2309:50thhellerstill wouldn’t use lumo but its the easiest option for that#2017-11-2309:50sundbpthen the lumo+eval+cache thing starts to make sense.#2017-11-2309:51thhellerbut as I understand lumo is adding a way to build projects as well#2017-11-2309:51sundbpyes, read some blog post about it#2017-11-2309:51sundbpbut don’t think any docs are about#2017-11-2309:51sundbpi’d love closh to become a viable day-to-day shell.#2017-11-2309:53thhellerseems cool yeah#2017-11-2309:58sundbpso for shadow-clj cli you output to packages/shadow-cljs/cli/dist, install a bin runner.js that loads this file with some logic around how it’s finding the file. what’s the purpose of the runner here?#2017-11-2310:13thhellerif shadow-cljs is installed globally it should still use the one installed in the project#2017-11-2310:13thhellerthats what the runner does#2017-11-2310:16sundbpah, ok.#2017-11-2310:16sundbpseems generally sensible#2017-11-2310:16sundbpthanks. that’s all I was pondering - should work out well!#2017-11-2313:12mitchelkuijpersNice new test support works awesome#2017-11-2313:32mitchelkuijpersI love removing the ns that includes al test nses#2017-11-2313:32mitchelkuijpersSomething still goes wrong with reloading but that is because the fulcro-spec runner is macro I think#2017-11-2316:55thheller@mitchelkuijpers {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1f6c777e7b7068327c73756c5f2d312f312e2f2f"}, :content ("[email protected]")} also adds :target :karma which always produces one output file (missing source maps currently, will add later)
:test-karma
  {:target :karma
   :output-to "out/demo-karma/test.js"}

module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless'],
    basePath: 'out/demo-karma',
    files: ['test.js'],
    frameworks: ['cljs-test'],
    plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
    colors: true,
    logLevel: config.LOG_INFO,
    // FIXME: do we need this?
    client: {args: ["shadow.test.karma.init"],
    singleRun: true}
  })
};
#2017-11-2316:56mitchelkuijpersAh I already had it working with browser-test 😛#2017-11-2316:56mitchelkuijpersIt even works with karma watch#2017-11-2316:56thhelleroh really. with watch?#2017-11-2316:57mitchelkuijpersYes#2017-11-2316:57thhellerah hehe I couldn’t figure out how to make that work#2017-11-2316:57mitchelkuijpersHehe I wrote my own runner, sort of#2017-11-2316:57mitchelkuijpers
(ns atlas-crm.CI-runner
  (:require
   [shadow.test :as shadow-test]
   [doo.runner :as runner :refer-macros [doo-tests]]))

(doo.runner/set-entry-point!
 (fn [tc]
   (let [total-tests (reduce
                      (fn [acc {:keys [vars]}]
                        (+ acc (count (keys vars))))
                      0
                      (vals (shadow-test/get-tests)))]
     (jx.reporter.karma/start tc total-tests))
   (shadow-test/run-tests (cljs.test/empty-env :jx.reporter.karma/karma))))
#2017-11-2316:58thhellerthere is now shadow.test.env which has the get-tests fn#2017-11-2316:58thhelleralso a get-test-count fn 😉#2017-11-2316:59thhellerhad to split into a seperate namespace since shadow.test depends on cljs.test but shadow.test.env needs to be loaded before cljs.test#2017-11-2317:00thhellerhow does your karma config look then?#2017-11-2317:01mitchelkuijpers
module.exports = function(config) {
  config.set({
    browsers: ['ChromeHeadless'],
    basePath: 'resources/public/',
    files: ['ci/js/test.js', {pattern: 'ci/js/cljs-runtime/**', included: false}],
    frameworks: ['cljs-test'],
    plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
    colors: true,
    logLevel: config.LOG_INFO,
    client: {args: ["doo.runner.run_BANG_"],
    singleRun: true}
  })
};
#2017-11-2317:02mitchelkuijpersand my shadow-cljs.edn#2017-11-2317:02mitchelkuijpers
:ci {:target :browser-test
               :asset-path "/base/ci/js"
               :ns-regexp "-spec$"
               :runner-ns atlas-crm.CI-runner
               :test-dir "resources/public/ci/"}
#2017-11-2317:02mitchelkuijpersSorry have to run, hope it helps!#2017-11-2317:02thhellerthx, it does.#2017-11-2317:02mitchelkuijpersI really love the shadow-test stuff btw#2017-11-2317:02mitchelkuijpersI have to fix fulcro spec I think since it uses macros#2017-11-2317:03thhellerglad it works for you. yeah those macros are annoying with respect to reloading#2017-11-2412:32Hendrik PoernamaI just tested shadow-cljs in my project and everything just works.. How can this be?? I haven't even included my 2500 lines extern files. This has got to be black magic.#2017-11-2412:34thhellerhehe#2017-11-2412:34Hendrik Poernamait even knows I'm pulling a var from script tag???
vN.j ? vN.j(ax, e5) : vN.call(null, ax, e5);
function f5() {
    return "undefined" !== typeof $zopim ? $zopim.livechat.window.show() : null
#2017-11-2412:35thhellerI did a “few” tweaks to the compiler to make this easier#2017-11-2412:38Hendrik Poernamawow... why doesn't everybody just use this. I think I spent close to a week debugging mangled node libraries that I fed to closure#2017-11-2412:39thhellerI don’t know 😉#2017-11-2412:40Hendrik Poernamathank you for shadow-cljs, this is amazing. I will help with documentation as I go along.#2017-11-2412:40thhellerits early still … still much left to do. I really need to write more docs but I prefer writing code.#2017-11-2412:50Hendrik Poernama:+1: #2017-11-2412:59thhellerjust pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3f4c575e5b5048125c53554c7f0d110f110e0f0e"}, :content ("[email protected]")}. see https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9#2017-11-2413:57nhawow that looks really useful! I’ll give shadow-cljs a spin when I get a chance 😄 can it run in separate “.edn” files like boot-cljs (https://github.com/boot-clj/boot-cljs/blob/master/docs/cljs.edn.md)?#2017-11-2414:01thhellernot currently no#2017-11-2414:04thhellercould add something like shadow-cljs.<build-id>.edn if that seems useful. I kinda like having my config in one place but it tends to get pretty large in bigger projects.#2017-11-2414:04nhaoh that’s because my build currently produces several js files#2017-11-2414:05thhellermultiple builds or one build with :modules?#2017-11-2414:05nhamultiple builds. I have yet to play with modules#2017-11-2414:06thhelleryou can configure many builds https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L28#2017-11-2414:06nhaalthough two of these builds share a few common functions, they are mostly independent.#2017-11-2414:06nhaoh cool 😄#2017-11-2414:06nhalooks good 😛#2017-11-2414:48mitchelkuijpersHow do people here handle cljs.spec integration with regards to the instrument call? My first guess would be to call it after each reload?#2017-11-2415:55sundbpI’m looking to use the “consul” npm module from cljs in a shadow-cljs project. I’m doing: (:require ["consul" :as consul]) in cljs, and the consul.js looks like:#2017-11-2415:56sundbp
function Consul(opts) {
  if (!(this instanceof Consul)) {
    return new Consul(opts);
  }
.....
};

/**
 * Module exports.
 */

exports.Consul = Consul;
#2017-11-2415:56sundbpthe js docs looks like:#2017-11-2415:56sundbp
Usage

var consul = require('consul')();

#2017-11-2415:56sundbpand then call fns like:#2017-11-2415:56sundbp
consul.acl.bootstrap(function(err, result) {
  if (err) throw err;
});
#2017-11-2415:57sundbpI’m struggling to work out how I translate to cljs side - any insight?#2017-11-2415:58sundbpI find a blog entry (https://blog.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html) that states: Some packages just export a single function which you can call directly by using (:require ["thing" :as thing]) and then (thing).#2017-11-2415:58sundbpnot having luck with that.#2017-11-2416:05mitchelkuijpersThat is because they export a class#2017-11-2416:06mitchelkuijpersprobably consul/Consul will work#2017-11-2416:06sundbp
eval error <eval>:-6
shadow.js.shim.module$consul.Consul()
                             ^

TypeError: Cannot read property 'Consul' of undefined
    at <eval>
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at runInThisContext (vm.js:152:38)
    at global.SHADOW_NODE_EVAL (/Users/sundbp/dev/bi/permafrost/out/permafrost.js:113:30)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/sundbp/dev/bi/permafrost/target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:28:1)
#2017-11-2416:07sundbpi tried that one..#2017-11-2416:08mitchelkuijpersHmm#2017-11-2416:08mitchelkuijpersand consul/default?#2017-11-2416:08sundbp
eval error <eval>:-6
shadow.js.shim.module$consul["default"]()
                            ^

TypeError: Cannot read property 'default' of undefined
#2017-11-2416:10sundbpif i change “consul” to “consul123" it fails, so it’s doing “something” with the require..#2017-11-2416:10sundbp
[:pf] Compiling ...
[:pf] Build failure:
The required JS dependency "consul123" is not available, it was required by "permafrost/cli.cljs".
#2017-11-2416:10mitchelkuijperscan you print what is in the consul object?#2017-11-2416:11sundbp
permafrost.cli> consul
"nil"
#2017-11-2416:11sundbpi don’t seem to really get anything in that require..#2017-11-2416:11sundbpor i don’t know how to see anything at least#2017-11-2416:11mitchelkuijpersCan you require consul/consul?#2017-11-2416:11mitchelkuijpersconsul.consul i mean#2017-11-2416:12sundbp
[:pf] Compiling ...
[:pf] Build failure:
The required JS dependency "consul.consul" is not available, it was required by "permafrost/cli.cljs".
#2017-11-2416:12mitchelkuijpersYou are trying this dependency right?: https://github.com/silas/node-consul#2017-11-2416:12sundbpyep#2017-11-2416:13mitchelkuijpersWhat is your target? :node ?#2017-11-2416:13sundbpnode-library in shadow-cljs.edn#2017-11-2416:13mitchelkuijpersAh ok#2017-11-2416:14mitchelkuijpersI am sorry I have no idea what is going wrong 😞#2017-11-2416:14sundbplikewise..#2017-11-2416:14mitchelkuijpersI have never tried node stuff with shadow-cljs#2017-11-2416:14sundbpin package.json of consul package it says main = ./lib, and then in lib/consul.js is the code i pasted.#2017-11-2416:14sundbpso it sort of looks reasonable to me#2017-11-2416:15mitchelkuijpersYeah same to me#2017-11-2416:18sundbp
» less target/shadow-cljs/builds/pf/dev/out/cljs-runtime/shadow.js.shim.module\$consul.js                              
goog.provide("shadow.js.shim.module$consul");
shadow.js.shim.module$consul = require("consul");
#2017-11-2416:28sundbp@thheller I’ve got a feeling we’re hitting some kind of bug here in the require system. it all looks ok, but I don’t think that the require to that shim has happened at the right time or something like that. looks like it’s nil#2017-11-2416:42Jon
Use of undeclared Var shadow.test.env/register-test
#2017-11-2416:42Jonwhat's this#2017-11-2416:47sundbp@mitchelkuijpers i got it to work in a release build!#2017-11-2416:47sundbpso it may be related to REPL stuff#2017-11-2416:47mitchelkuijpersAah ok#2017-11-2416:47sundbpin release i can do the require, and then do (prn (js-keys (consul))) and see the fns in the js docs#2017-11-2416:48sundbp@thheller let me know when you’re around and I can describe things and perhaps we can diagnose what goes wrong in REPL case.#2017-11-2417:01sundbpnow next problem is to call a nested fn. i.e. I can do (let [c (consul (clj->js {...})] ...), but then i need to access .kv.get in that c object.#2017-11-2417:01sundbpif i fetch out the fn via e.g. aget and call it I get a failure as it expects this to be set to c during the call..#2017-11-2417:28sundbpactually - got it all to work now. started again, cleaned dirs etc and got it working.#2017-11-2418:55thheller@sundbp I’m back. reading log.#2017-11-2418:57thhellernested fns you call with (-> consul (.-kv) (.get arg1 arg2 ...))#2017-11-2418:57thheller@jiyinyiyong where did you get this error? ah hmm … crap you are probably requiring cljs.test and do deftest somewhere in your build#2017-11-2418:59thhellershadow.test.env is included automatically for the new test builds but not for everything else. need to fix that#2017-11-2419:00thheller@sundbp (:require ["consul" :as consul]) should have just worked. no idea why it wouldn’t.#2017-11-2419:09thheller@jiyinyiyong fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fb88939a9f948cd698979188bbc9d5cbd5cacbc9"}, :content ("[email protected]")}, sorry about that.#2017-11-2500:09sundbp@thheller indeed. i think it had something to do with bad target/ cache + order of REPL and so forth. once i cleaned it out, started again and I had state I could explore and figured out the nested call.#2017-11-2500:09sundbpthanks - i’m really liking shadow-cljs so far, really good experience.#2017-11-2508:00Hendrik Poernamais there any config needed to enable css reloading? I got code reload to work, but css requires page refresh.#2017-11-2508:33thheller@poernahi css reloading currently requires that you use absolute paths#2017-11-2508:33thheller <link rel="stylesheet" href="/css/foo.css"/>#2017-11-2508:34thhellerif you use the built-in :devtools {:http-root ...} http server it should just work#2017-11-2508:34thhellerif not you need to specify :devtools {:watch-dir ...} which should be the path to your http root folder#2017-11-2508:38thheller:watch-dir "public" will reload public/css/foo.css when it finds the link in HTML#2017-11-2508:40thheller@sundbp if you run into that again please report what you were doing. I hate caching issues and want to fix all of them (in case it is one).#2017-11-2508:40Hendrik PoernamaGotcha. Will try that. Thanks#2017-11-2510:42sundbp@thheller sure, will do. I’ve just recently looked at cljs+node for some CLI tools requiring fast startup time, only done jvm clojure otherwise. So I’m new to shadow-cljs, and node, and npm/yarn so I may well have done steps in an unnatural order resulting in the weird situation. I can’t recall it but if I have to guess it may have been related to adding the dependency via yarn add and not restarting everything. Nothing complained and the shims etc looked sensible, but in the REPL session they weren’t available. So gut feel if I’d just restarted the node dev-output/foo.js at the time it’d have gotten picked up properly as shadow-cljs had done it’s thing. I was expecting the require in the shim to blow up or work as expected though, seemed to have silently errored instead.#2017-11-2510:46thhellerinstalling something with yarn does not require a restart. REPL might have some edge cases related to loading. builds should be fine.#2017-11-2611:50MalteHi, currently I'm playing around with shadow-cljs and still don't completely grasp its dependency management (especially the interplay between cljs and npm libs). When I bootstrap a leiningen app (e.g. with figwheel) and add rum as dependency, I can start my app with lein figwheel right away and all required dependencies are downloaded automatically. On the other hand, when I add rum as a dependency to shadow-cljs, I have to separately include the official js react dependencies in the project's package.json as well (e.g. done here: https://github.com/thheller/shadow-cljs-template). If I don't, I receive an The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs" (`cljsjs/react` is a dependency for rum) error. Why is that? I guess I'm not really understanding how leiningen and shadow-cljs solve the installation of dependencies internally, especially when it comes to cljsjs-libraries (which we don't really need in shadow-cljs anyways, right?).#2017-11-2611:52thhellerHi!#2017-11-2611:52thhellershadow-cljs uses npm to manage the JS dependencies. so you npm install react.#2017-11-2611:54thhellernot all CLJS project (eg. rum) properly declare their :npm-deps and will still use cljsjs#2017-11-2611:58thhellerso its a matter of projects not declaring the deps, they should be automatically installed once declared properly#2017-11-2611:58thhelleruntil that point though it will remain a bit manual#2017-11-2612:05thhelleroh if you use the template run npm install. it already has everything properly setup.#2017-11-2612:05thhellerlein templates just don’t run that command for you#2017-11-2612:14thhellerhttps://github.com/shadow-cljs/lein-template thats the template btw. deleted the old fork.#2017-11-2612:21MalteThanks a lot for your quick response 🙂 So that's already a lot clearer. Just for comparison: Why doesn't leiningen need this extra step of installing the react js dependency?#2017-11-2612:22thhellerbecause rum uses cljsjs.react which is the re-packaged npm package. so its not using npm but rather the 3rd party package. https://github.com/cljsjs/packages/tree/master/react#2017-11-2612:23thhellershadow-cljs uses the npm package directly, skipping the re-packaged cljsjs.#2017-11-2612:34MalteAh, OK, so shadow-cljs is aware of cljsjs dependencies and can skip them automatically? That's really cool!#2017-11-2612:35thhellerit doesn’t strictly skip them, it just provides the mapping back to their original npm packages. https://github.com/thheller/shadow-cljsjs#2017-11-2612:38thhellerI wrote a few posts about JS deps https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2017-11-2612:38thheller> The systems simply do not mix well and frequently conflict with each other. One library might use cljsjs.react while another uses the newer “react”. This would lead to two versions of React being included in your page.#2017-11-2612:39thhellerthats basically why I have to work around cljsjs packages, I don’t want any of those conflicts.#2017-11-2612:54MalteI think I've understood it now. Thanks again for your time! I'll also have a look at your blog posts.#2017-11-2612:57thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html hopefully covers everything about JS deps#2017-11-2703:00mjmeintjesHi. I've been using shadow-cljs for a new project, and it seems to be working well. However, I've run into a wall trying to get spec-tools library added a a dependency. When I start up shadow-cljs with spec-tools added as a dependency, I get the following error:
failed to inspect cljs file: jar:file:/home/matthys/.m2/repository/metosin/spec-tools/0.5.1/spec-tools-0.5.1.jar!/spec_tools/core.cljc {:tag :shadow.build.classpath/inspect-cljs, :resource-name "spec_tools/core.cljc", :url #object[java.net.URL 0x7f2d31af "jar:file:/home/matthys/.m2/repository/metosin/spec-tools/0.5.1/spec-tools-0.5.1.jar!/spec_tools/core.cljc"]}
Has anyone seen a similar error before?
#2017-11-2703:02mjmeintjesThis is then followed by the following exception:
failed to parse ns form {:clojure.spec.alpha/problems ({:path [:clauses :refer-clojure :clause], :pred #{:refer-clojure}
#2017-11-2709:03thheller@mjmeintjes fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "097a61686d667e246a65637a493b27392738393a"}, :content ("[email protected]")}. my ns parser was a bit too strict and didn’t allow (:import) which spec-tools.impl has for :cljs#2017-11-2715:47mitchelkuijpersIs this supported in shadow-cljs: js/document.body to get the document body? Because I am trying to use a preload for fulcro-devtools and here: https://github.com/fulcrologic/fulcro-inspect/blob/develop/src/fulcro/inspect/ui/events.cljs#L79 target is undefined#2017-11-2715:47colindresj@thheller Should i be using package.json or :npm-deps for listing and managing js dependencies?#2017-11-2715:50colindresjI’ve been using package.json, but recently noticed that if I require CLJS-lib A (built with shadow) that uses package.json for js deps within CLJS-lib B (also shadow-built), I won’t get CLJS-lib A’s js dependencies#2017-11-2717:45thheller@mitchelkuijpers yes of course thats supported.#2017-11-2717:47thheller@colindresj libraries should declare :npm-deps in a deps.cljs file that will make shadow-cljs isntall them on startup#2017-11-2717:49colindresjThanks @thheller. So, sort of like foreign libs were specified, except obviously replacing :foreign-libs for :npm-deps#2017-11-2717:50colindresjWhat’s the mapping look like within :npm-deps? is it module name to semnatic versioning range?#2017-11-2717:50thheller{:npm-deps {"thing" "range}} yes#2017-11-2717:50colindresjCool thank you#2017-11-2717:52tiensonqin@thheller I have some problem with js/requestAnimationFrame. I check the output of (or batched-updates js/requestAnimationFrame), it's
return or__32840__auto__;
} else {
  requestAnimationFrame;
}
#2017-11-2717:53tiensonqinfigwheel outputs:
if(cljs.core.truth_(or__30096__auto__)){
return or__30096__auto__;
} else {
return requestAnimationFrame;
}
#2017-11-2717:54tiensonqinIf I changed the output of shadow-cljs to figwheel output, then it doesn't complain.#2017-11-2717:55tiensonqinThe error is something like: Uncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined at Object.citrus$reconciler$schedule_update_BANG_ [as schedule_update_BANG_]#2017-11-2717:57thhellerhmm weird#2017-11-2717:58thhellerhmm what the heck#2017-11-2717:58thhellerit is indeed undefined#2017-11-2717:59thheller
var G__54995_54997 = "or";
var G__54996_54998 = (function (){var or__34403__auto__ = null;
if(cljs.core.truth_(or__34403__auto__)){
return or__34403__auto__;
} else {
document.body}
})();
console.log(G__54995_54997,G__54996_54998);
#2017-11-2717:59thhellerthats missing a return#2017-11-2717:59tiensonqinyeah exactly!#2017-11-2718:01thhellerlooking into that, not a clue what could cause this though#2017-11-2718:02tiensonqinCurrently I can work around it by wrapping a function: (or batched-updates (fn [] js/requestAnimationFrame))#2017-11-2718:03tiensonqinwhich works for me.#2017-11-2718:04thhellerah crap found it …#2017-11-2718:04tiensonqinso quick!#2017-11-2718:04tiensonqin👍#2017-11-2718:06thheller@tiensonqin @mitchelkuijpers fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "12617a73767d653f717e786152203c223c232226"}, :content ("[email protected]")}. sorry about that.#2017-11-2718:07thhellerI really need to start writing tests for the compiler hacks I’m doing#2017-11-2718:07thhellerthis is not cool 😞#2017-11-2718:07tiensonqinThank you very much for your great effort!
#2017-11-2718:07tiensonqinI'll try it soon and report back.#2017-11-2718:07mitchelkuijpersCool! Thnx#2017-11-2718:14tiensonqin@thheller confirmed it works, thanks.#2017-11-2721:01sundbpI’m running into this when trying to run shadow-cljs check foo:#2017-11-2721:01sundbp
-> Closure - Checking ...
ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
	shadow.build.closure/closure-source-file (closure.clj:565)
	shadow.build.closure/closure-source-file (closure.clj:565)
	shadow.build.closure/source-map-sources/fn--21021 (closure.clj:930)
#2017-11-2721:02sundbpany tips on what’s going on? @thheller#2017-11-2721:05thhelleroops#2017-11-2721:05sundbpwanting to run it to find a problem with the aero lib on nodejs, in advanced opt mode it gives:#2017-11-2721:05sundbp
function jB(a,b,c){b=b.l?b.l():b.call(null);$f.c(c,Qd,a);return b}function kB(a,b,c){b=null!=b&&(b.o&64||p===)?pf(ni,b):b;var d=E.b(b,Sk),e=E.b(b,Ck),f=E.b(b,Nk);if(v(Zl.a(f)))return null;try{var g=jB(a,d,c)}catch(k){throw c=k,[x.a(["could not start [",x.a(a),"] due to"].join(""))," ",x.a(c)].join("");}hB(b,g);$f.D(fB,T,a,new u(null,1,[Ck,e],null));return iB(new X(null,2,5,Y,[a,Nk],null),new vi(null,new u(null,1,[Zl,null],null),null))}
                                                                                                                                                                                                                             ^
could not start [#'permafrost.config/config] due to TypeError: Cannot read property 'b' of undefined
#2017-11-2721:05sundbpbut is fine in :simple mode.#2017-11-2721:05thhelleryeah I broke check recently when doing the externs inference work#2017-11-2721:05thhellerwill fix#2017-11-2721:05thhellertry shadow-cljs release app --debug#2017-11-2721:06sundbpk, running. tks#2017-11-2721:06thhellercompiles with source-maps and pseudo-names to debug those kind of things#2017-11-2721:06thhellercheck isn’t totally reliable anymore due to all the new JS interop#2017-11-2721:07sundbp
-> Closure - Optimizing ...
ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
	shadow.build.closure/closure-source-file (closure.clj:565)
	shadow.build.closure/closure-source-file (closure.clj:565)
	shadow.build.closure/source-map-sources/fn--21022 (closure.clj:930)
#2017-11-2721:07sundbpso still trips up source-maps..#2017-11-2721:08thhellerwhich :target is that?#2017-11-2721:08sundbp
:builds
 {:pf {:target :node-library
       :output-to "out/permafrost.js"
       :exports {:main permafrost.cli/main}
       :devtools {:before-load permafrost.cli/stop!
                  :after-load permafrost.cli/start!}
       :release {:output-to "permafrost.js"
                 :compiler-options {:infer-externs :auto
                                    :optimizations :advanced}}}}}
#2017-11-2721:08sundbpand running shadow-cljs release pf --debug#2017-11-2721:10sundbpI’ve narrowed it down to be in the aero library (i.e. if i exclude the aero/read-config call doesn’t trigger). but was hoping for a bit more info to figure out where it is.#2017-11-2721:10thhellerah doh#2017-11-2721:11thhellerwhats aero?#2017-11-2721:11sundbphttps://github.com/juxt/aero#2017-11-2721:16thhellerClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dba8b3babfb4acf6b8b7b1a89be9f5ebf5eaebee"}, :content ("[email protected]")}#2017-11-2721:16sundbpgiving it a try#2017-11-2721:18thhellernot sure what aero has to do with it though. release source maps were just generally broken for :node-library#2017-11-2721:18sundbpyeah - i’m just hoping that i’ll get a bit more info out with that fix, letting me find the issue in aero#2017-11-2721:19thheller(fs.readFileSync source "utf-8") probably this#2017-11-2721:19thhelleror (os.hostname)#2017-11-2721:20sundbp
/Users/sundbp/dev/bi/permafrost/permafrost.js:20075
    throw $done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$ = $e38700$jscomp$inline_1327$$, [$cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$(["could not start [", $cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$($state$jscomp$22$$), "] due to"].join("")), " ", $cljs$core$str$$.$cljs$core$IFn$_invoke$arity$1$($done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$)].join("");
    ^
could not start [#'permafrost.config/config] due to TypeError: Cannot read property '$cljs$core$IFn$_invoke$arity$2$' of undefined
#2017-11-2721:21sundbpit is indeed fixed, but didn’t give me much insight#2017-11-2721:21thhellercan you try with node --inspect the-thing.js so the source maps actually apply?#2017-11-2721:21sundbpok#2017-11-2721:22thhelleror --inspect-brk#2017-11-2721:23thhellerthat is an extremely weird line of JS#2017-11-2721:24thhellerit doesn’t even contain $cljs$core$IFn$_invoke$arity$2$#2017-11-2721:24sundbpso i’ve never used node inspect/inspect-brk. I ran it - what do I do next?#2017-11-2721:24thhellerthrow $done$jscomp$9_t__38328__auto__$jscomp$inline_1326$$ = $e38700$jscomp$inline_1327$$, that the heck is that? 😛#2017-11-2721:24sundbp
» node --inspect-brk bin/runner.js                                                                              ~15.0s 21:23:30
Debugger listening on 
For help see 
#2017-11-2721:24thhelleroh you have chrome I assume?#2017-11-2721:25sundbpah. see docs link#2017-11-2721:25sundbpi’m ok#2017-11-2721:25thheller#2017-11-2721:25thhellershould show it#2017-11-2721:26sundbpso it’s paused debugger at start of my runner#2017-11-2721:26thhelleryeah press the play button to run it#2017-11-2721:26thhellerclick the pause on exceptions thing (pause icon)#2017-11-2721:27thhellerjust in case it doesn’t stop automatically#2017-11-2721:28sundbpok. i don’t see any source-maps#2017-11-2721:29sundbpbut does indeed seem to be that utf-8 call#2017-11-2721:30thhelleryeah its not something the externs inference can detect properly#2017-11-2721:30thheller(and not actually valid code if you want to be picky)#2017-11-2721:30sundbpi don’t get the code to be honest#2017-11-2721:30sundbpwhat’s the proper way to write that call?#2017-11-2721:31sundbp(.readFileSync fs source "utf-8") ?#2017-11-2721:31thheller(.. fs (writeFileSync source "utf-8))#2017-11-2721:31thhelleror yours#2017-11-2721:31thhelleror better yet#2017-11-2721:32thheller(fs/writeFileSync ...) coupled with (:require ["fs" :as fs]) in the ns#2017-11-2721:32sundbpyeah, but in this case i think they wrote it for lumo, and that’s probably not gonna fly#2017-11-2721:32thhellerso the nodejs/require calls go away 😛#2017-11-2721:32thhellerlumo supports that#2017-11-2721:32sundbpah, it does. cool#2017-11-2721:33thhellerAntonio was the one that implemented the feature for CLJS core#2017-11-2721:34thhellersource maps indeed don’t work, looking into that#2017-11-2721:35sundbpthanks for all the help#2017-11-2721:35thhellernp, happy to help.#2017-11-2721:35sundbpi’m cleaning up aero and that’ll probaly be it + I learnt a bit about the process while doing it.#2017-11-2721:36thhelleraero scares me a bit because of https://github.com/juxt/aero/blob/master/src/aero/vendor/dependency/v0v2v0/com/stuartsierra/dependency.cljc#2017-11-2721:36thhellerdunno why they include that#2017-11-2721:36sundbpbtw, in this case i have a bin/runner.js, like your shadow-clj package. would that in any way throw source-maps off?#2017-11-2721:37thhellerit should not but it might. source maps are a bit funky in node sometimes#2017-11-2721:38thhellerit does load them correctly but it doesn’t use them.#2017-11-2721:38sundbpk#2017-11-2721:38sundbpi’ve used node for 2days so i’m totally new to the environment#2017-11-2721:55thhellerbtw you can also add <project>/externs/pf.txt and just put the problematic things into it. so
hostname
writeFileSync
#2017-11-2721:56thhellerdon’t need to rewrite the entire code. manual externs still apply.#2017-11-2721:56thhellercheck should also work again#2017-11-2721:57koz@thheller really enjoying shadow-cljs so far, great work! Scrolling up in the channel, it seems like deps.cljs has to have the same information that already resides in the package.json file. Is there an easier way to keep the two in sync?#2017-11-2721:59thhellercheck output
------ WARNING #3 --------------------------------------------------------------
 File: /Users/zilence/code/shadow-cljs/src/dev/demo/lib.cljs:13
--------------------------------------------------------------------------------
  10 |
  11 |
  12 | (def fs (js/require "fs"))
  13 | (fs.writeFileSync "x" "foo" "utf-8")
--------------------------------------------------------------------------------
 Property writeFileSync never defined on demo.lib.fs
--------------------------------------------------------------------------------
  14 |
--------------------------------------------------------------------------------
#2017-11-2722:00thheller@koz :npm-deps is only for libraries declaring dependencies on JS packages#2017-11-2722:00thhellerthe project always uses package.json (since that drives npm which isn’t aware of :npm-deps)#2017-11-2722:01thhellerits kinda hard for them to sync since its undefined how conflicts should be handled#2017-11-2722:03kozIt would be cool if package.json served as the canonical, and shadow-cljs could generate deps.cljs from it. It seems like it could be potentially dangerous for packages to get out of sync if writing a lib (also another thing to remember).#2017-11-2722:04thhelleragreed. I have not yet done any work related to publishing libs with shadow-cljs, deps.cljs would be part of it.#2017-11-2722:05sundbp@thheller ah, that’s good to know. I made PRs for the 2 libs I used that didn’t play ball, but good to know one can use official releases with externs while they await merge+release.#2017-11-2722:05thhellerit has come up before but I’m really unsure how to approach this issue#2017-11-2722:05kozcool, it’s amazing how well this all works though. thanks for the response!#2017-11-2722:07sundbpso far i’ve used: package.json has all node dependencies, nothing in deps.cljs/shadow-cljs.edn. shadow-cljs.edn has all cljs/clj dependencies. has been working ok sofar.#2017-11-2722:08thhelleryeah if I want publishing I need to mess with :profiles and such. I really don’t want to do that.#2017-11-2722:09thhellerbut it needs a proper way to exclude some dev-only code from a lib .jar. same as lein/`boot`#2017-11-2722:09thheller+ package.json handling which those don’t do#2017-11-2722:10koz@sundbp we’re working with publishing this as a library that will be brought in from other cljs projects, so we need dependencies declared in the deps.cljs file#2017-11-2722:10thhellerprobably not doing profiles, only :dev-dependencies or so#2017-11-2722:10sundbp@koz ya, then I guess there’s no great way to keep it fully clean right now.#2017-11-2722:10thhellerbut yeah publishing libs needs work#2017-11-2722:11thheller@koz be careful when publishing libraries with :npm-deps though. pretty good odds they won’t work with anything but shadow-cljs#2017-11-2722:12kozpoint taken. this is internal, so we have complete control over that thankfully#2017-11-2722:12thheller:npm-deps pretty often does not work in CLJS core#2017-11-2722:12thhellerah ok#2017-11-2722:32sundbp@thheller it’d be awesome if source-maps for nodejs was to work - give me a shout if you think you know what’s wrong and there’s anything I can do to help. thanks!#2017-11-2722:47thhellerlooking into it currently. the source map comment is not emitted for release currently but they don’t work in dev either which has the comments.#2017-11-2722:50sundbpi guess it makes sense to not emit in release, but with the --debug flag for release it would make sense#2017-11-2901:42sundbp@thheller i’m interested in making this timeout configurable: https://github.com/thheller/shadow-cljs/blob/6607f209b9535564ed9d59754cbde956537e8388/src/main/shadow/cljs/devtools/server/worker.clj#L74#2017-11-2901:46sundbpnot quite sure what best way is for threading a parameter all the way there. what approach would you suggest?#2017-11-2909:02thheller@sundbp does you code actually run this long? I noticed that sometimes the REPL doesn’t properly return the result and ends up in a timeout which is a bug.#2017-11-2909:02thhellercould make it configurable but where? 😛#2017-11-2909:08thhellerproblem is that there is no way to interrupt JS#2017-11-2909:58sundbpi’m using the REPL and sometimes have some long DB queries and such I’m waiting for. for exploration.#2017-11-2909:59sundbpwas thinking an option in shadow-cljs.edn would be logical#2017-11-2910:00thheller:devtools {:repl-timeout a-number}?#2017-11-2910:01thhellerbtw I can’t figure out why source maps don’t work (in :node-library)#2017-11-2910:02thhellerthey work just fine in :node-script#2017-11-2910:04sundbpyeah, something like that option was what i was hoping for#2017-11-2910:04sundbpseems small differences between the two profiles..#2017-11-2910:06thhelleryeah there are but I can’t figure out why they would affect source maps#2017-11-2910:06thhellerwell … I probably know why it doesn’t work but don’t have a solution yet#2017-11-2910:07thhellerI generate a piece of code the the exports. that piece does not have source maps so there is a “gap”#2017-11-2910:07thhellerthe gap seems to confuse the source mapper#2017-11-2910:10sundbpright.. i’m actually producing a node-script, but used node-library to use the bin/runner.js#2017-11-2910:11sundbpso i can switch it to node-script relatively easily to get source-maps if needed#2017-11-2912:49mitchelkuijpersI am running into this case on my build-server:
<- Compile CLJS: om/next.cljc (15087 ms)
Cache write: om/next.cljc
aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
{:aborted [:shadow.build.classpath/resource "fulcro/client/util.cljc"], :pending #{om.next}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.compiler/par-compile-one (compiler.clj:647)
	shadow.build.compiler/par-compile-one (compiler.clj:622)
	shadow.build.compiler/par-compile-cljs-sources/fn--11576/iter--11577--11581/fn--11582/fn--11583/fn--11584 (compiler.clj:721)
	clojure.core/apply (core.clj:657)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/apply (core.clj:661)
	clojure.core/bound-fn*/fn--5471 (core.clj:1995)
	java.util.concurrent.FutureTask.run (FutureTask.java:266)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
	java.lang.Thread.run (Thread.java:748)
Is this fixable?
#2017-11-2912:50thhellerodd#2017-11-2912:50thhellerits supposed to timeout after 30sec#2017-11-2912:52thhellerbut it completed om.next … not sure whats happening#2017-11-2912:54mitchelkuijpersMaybe this helps:#2017-11-2912:54mitchelkuijpers
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/logging.cljc"] waiting for #{om.next}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/i18n.cljc"] waiting for #{fulcro.client.logging}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/mutations.cljc"] waiting for #{fulcro.client.util fulcro.client.logging om.next fulcro.i18n}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/om_plumbing.cljc"] waiting for #{fulcro.client.mutations fulcro.client.logging om.next}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/data_fetch.cljc"] waiting for #{fulcro.client.util fulcro.client.mutations fulcro.client.logging om.next fulcro.client.impl.om-plumbing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/network.cljc"] waiting for #{fulcro.client.logging}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/impl/application.cljc"] waiting for #{fulcro.client.util fulcro.client.impl.data-fetch fulcro.client.network fulcro.client.logging om.next fulcro.client.impl.om-plumbing fulcro.i18n}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/core.cljc"] waiting for #{fulcro.client.util fulcro.client.mutations fulcro.client.impl.application fulcro.client.network fulcro.client.logging om.next fulcro.client.impl.om-plumbing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "atlas_crm/api/mutations.cljs"] waiting for #{fulcro.client.mutations fulcro.client.logging om.next fulcro.client.routing}
17-11-29 12:48:05 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro/client/routing.cljc"] waiting for #{fulcro.client.util fulcro.client.core fulcro.client.mutations fulcro.client.logging om.next}
17-11-29 12:48:06 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "atlas_crm/ui/app/routes.cljc"] waiting for #{fulcro.client.routing}
17-11-29 12:48:07 cb56ad16b459 WARN [shadow.build.compiler:286] - [:shadow.build.classpath/resource "fulcro_css/core.cljc"] waiting for #{om.next}
<- Compile CLJS: om/next.cljc (15087 ms)
Cache write: om/next.cljc
aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
{:aborted [:shadow.build.classpath/resource "fulcro/client/util.cljc"], :pending #{om.next}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcro/client/util.cljc"] still waiting for #{om.next}
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.compiler/par-compile-one (compiler.clj:647)
	shadow.build.compiler/par-compile-one (compiler.clj:622)
	shadow.build.compiler/par-compile-cljs-sources/fn--11576/iter--11577--11581/fn--11582/fn--11583/fn--11584 (compiler.clj:721)
	clojure.core/apply (core.clj:657)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/apply (core.clj:661)
	clojure.core/bound-fn*/fn--5471 (core.clj:1995)
	java.util.concurrent.FutureTask.run (FutureTask.java:266)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
	java.lang.Thread.run (Thread.java:748)
#2017-11-2912:54thhellerguess I really need to crank up this delay. did not expect any namespaces to ever take longer to compile than cljs.core#2017-11-2912:55thhellerwonder what om.next is doing that its this slow#2017-11-2912:57thhellertechnically the only reason to have this abort is to prevent infinite loops due to bugs#2017-11-2912:57thhellerI’ll just bump the timeout to a minute or so#2017-11-2913:10mitchelkuijpersThnx that will solve it for now, fulcro has forked om.next, I hope that compiles faster#2017-11-2913:13thhellerI need to decide on a framework I want to use for the shadow-cljs UI I want to build#2017-11-2913:14thhellerneed to try fulcro for that. maybe I can figure out why it so slow to compile.#2017-11-2913:20thheller@mitchelkuijpers try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0a79626b6e657d27696660794a38243a243b3a3c"}, :content ("[email protected]")}, bumped the timeout to 60sec#2017-11-2913:20mitchelkuijpersAwesome! Thnx @thheller#2017-11-2913:21thhellerwhat is the state of fulcro? how stable is it? or still alpha?#2017-11-2913:21mitchelkuijpersFulcro is pretty awesome in my opinion they even have special devtools released which makes it a pretty nice dev env. If you are seriously interesed I would be happy to assist in any way#2017-11-2913:21mitchelkuijpersThey are almost release fulcro 2.0 RC#2017-11-2913:22mitchelkuijpersbut there is also a 1.2 version which we are using in production#2017-11-2913:22thhellerI like fulcro although I’m not convinced that co-locating queries in components is the best idea#2017-11-2913:22mitchelkuijpersFor me the most important thing is that it has good documentation#2017-11-2913:22thhellerwould kinda prefer if that was decoupled a bit#2017-11-2913:22thhellerbut I guess too much relies on that idea#2017-11-2913:22mitchelkuijpersWe co-locate: queries, initial-state and css#2017-11-2913:23mitchelkuijpersWe love it, it makes a lot of stuff a lot more straightforward. For us the biggest win is the graph-db format#2017-11-2913:23thhellerI already solved css for me so I don’t need that 😉 https://github.com/thheller/shadow/wiki/shadow.markup#2017-11-2913:24mitchelkuijpersOh nice, we loved the way fulcro did it because you need to compose css to root. We use that to SSR markup and only return the css that is necessary for that view#2017-11-2913:25thhellerwhats the performance like? I think om.next always re-renders from the root?#2017-11-2913:25thhellerI tested om.next a long while ago and it was pretty terrible performance wise#2017-11-2913:26mitchelkuijpersNo you re-render from any point that you like#2017-11-2913:26thhellerbut it has been a real long while so that may have changed since then#2017-11-2913:26mitchelkuijpersyou can also re-render by ident if you know what that means. And then it will only re-render what is bound to that ident#2017-11-2913:27thhellerah ok. thats “new” then#2017-11-2913:27mitchelkuijpersIt has some nice tools to handle performance sensitive stuff#2017-11-2913:27mitchelkuijpersBut fulcro 2.0 forked om.next to fix some important stuff#2017-11-2913:27thhellerinteresting#2017-11-2913:28mitchelkuijpersSomething todo with the "Dynamic queries" and to add some nice performance optimizations#2017-11-2913:57mitchelkuijpersHmm I am trying to use the :karma target but it gives me:
[:ci] Compiling ...
{:type :shadow.build.targets.karma/test-namespaces, :test-namespaces [atlas-crm.ui.components.entity-selector-test atlas-crm.ui.impl.routing.path-test atlas-crm.ui.impl.routing.linear-search-router-test], :entries [shadow.test.env atlas-crm.ui.components.entity-selector-test atlas-crm.ui.impl.routing.path-test atlas-crm.ui.impl.routing.linear-search-router-test shadow.test.karma]}
no goog/base.js
{}
ExceptionInfo: no goog/base.js
        clojure.core/ex-info (core.clj:4739)
        clojure.core/ex-info (core.clj:4739)
        shadow.build.output/closure-defines-and-base (output.clj:46)
        shadow.build.output/closure-defines-and-base (output.clj:41)
        shadow.build.targets.karma/flush-karma-test-file (karma.clj:72)
        shadow.build.targets.karma/flush-karma-test-file (karma.clj:67)
        shadow.build.targets.karma/flush (karma.clj:94)
        shadow.build.targets.karma/flush (karma.clj:91)
        shadow.build.targets.karma/process (karma.clj:109)
        shadow.build.targets.karma/process (karma.clj:99)
        clojure.lang.Var.invoke (Var.java:381)
        shadow.build/process-stage (build.clj:110)
        shadow.build/process-stage (build.clj:102)
        shadow.build/flush (build.clj:316)
        shadow.build/flush (build.clj:312)
        shadow.cljs.devtools.api/compile* (api.clj:189)
        shadow.cljs.devtools.api/compile* (api.clj:184)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:40)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:30)
        shadow.cljs.devtools.cli/do-build-commands/fn--61387/fn--61388 (cli.clj:68)
        clojure.core/binding-conveyor-fn/fn--5476 (core.clj:2022)
        java.util.concurrent.FutureTask.run (FutureTask.java:266)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
        java.lang.Thread.run (Thread.java:748)
#2017-11-2913:57mitchelkuijpersAny idea why?#2017-11-2913:58mitchelkuijpersOr am I running it wrong I run: bin/lein run -m shadow.cljs.devtools.cli compile ci#2017-11-2913:59thhellerwhy do you torture yourself. those commands takes ages to run. 😉#2017-11-2913:59thhellerno idea though.#2017-11-2914:00mitchelkuijpersHaha what command should I run?#2017-11-2914:00thhellershadow-cljs compile ci 😉#2017-11-2914:00mitchelkuijpersHehe but i have set leiningen to true#2017-11-2914:01thhellerdoh 😛#2017-11-2914:01mitchelkuijpersSo I don't see a difference 😛#2017-11-2914:01mitchelkuijpersLol it does work when I run it like that#2017-11-2914:02thhelleryeah but its still using lein to start so thats no fun 😉#2017-11-2914:02mitchelkuijpersTrue#2017-11-2914:02thhellerno idea about the error though#2017-11-2914:03thhellerit means that it didn’t find goog/base.js in the compile output#2017-11-2914:03mitchelkuijpersNo worries it does work with the shadow-cljs command#2017-11-2914:03thhellerseriously?#2017-11-2914:03mitchelkuijpersNo I am stupid#2017-11-2914:03thhellerwhat the heck, with :lein true it basically calls exactly the command you used#2017-11-2914:03mitchelkuijpersHold on#2017-11-2914:04mitchelkuijpersNo I get the same error#2017-11-2914:05mitchelkuijpers
:ci {:target :karma
               :output-to "resources/public/ci/karma.js"}
Is this config maybe wrong?
#2017-11-2914:05mitchelkuijpersI stole it from you 😛#2017-11-2914:05thhellerno thats correct#2017-11-2914:06thhellerok, I get the same error now#2017-11-2914:06thhellerwonder where that came from#2017-11-2914:06thhellerchecking#2017-11-2914:07thhellernvm .. I’m just stupid#2017-11-2914:10thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e5968d84818a92c886898f96a5d7cbd5cbd4d5d2"}, :content ("[email protected]")}#2017-11-2914:10thhellerdidn’t you have :browser-test working with karma?#2017-11-2914:13mitchelkuijpersYeah I though I had#2017-11-2914:14mitchelkuijpersBut it doesn't seem to work#2017-11-2914:14thhellerI couldn’t get it to understand how closure wants to load files#2017-11-2914:14thhellerto the :karma target just always emits one file#2017-11-2914:15mitchelkuijpersThat is absolutely fine because this is only for Ci#2017-11-2914:15thhelleryou probably also want to set the :ns-regexp#2017-11-2914:15mitchelkuijpersYes sure#2017-11-2914:23mitchelkuijpersNo Karma breaks on:#2017-11-2914:24mitchelkuijpersReally sorry to keep disturbing you#2017-11-2914:30thhelleroh hehe oops#2017-11-2914:30thheller:js-options {:js-provider :shadow}#2017-11-2914:30mitchelkuijpersAh lol#2017-11-2914:30mitchelkuijpersI am still trying to get the other browser-test build working#2017-11-2914:32thhelleruhm that shouldn’t need that#2017-11-2914:35thhellerI’m confused now .. which doesn’t work :karma or :browser-test or both?#2017-11-2914:35thheller:karma is basically a very simplified version that doesn’t do live reloading or a REPL#2017-11-2914:36mitchelkuijpersOh sorry, :karma does not work#2017-11-2914:36mitchelkuijpersSo I should just add js-options provider shadow?#2017-11-2914:39thhelleryes that should do it#2017-11-2914:39mitchelkuijpersAwesome#2017-11-2914:43mitchelkuijpersThat works awesome!#2017-11-2914:45mitchelkuijpersToday we are moving over completely to shadow-cljs with my team ^^#2017-11-2914:50mitchelkuijpersI had one more idea btw, we are also using devcards do you think we could use :browser-test target to automatically include all files that end on -cards#2017-11-2915:00thheller:ns-regexp "-(test|cards)$" should do it?#2017-11-2915:01mitchelkuijpersYeah ^^#2017-11-2915:01thhellerI think devcards also needs the compiler options though#2017-11-2915:04thhellerbut I don’t think you want to include devcards with your tests? those don’t do anything cljs.test related or do they?#2017-11-2915:05mitchelkuijpersNo but I just want something to automatically include all -card namespaces so I don't have to keep adding them to one file#2017-11-2915:07thhellersounds like :target :devcards would be useful 😉#2017-11-2915:11mitchelkuijpersI can make my own targets right?#2017-11-2915:12thhelleryep#2017-11-2915:12mitchelkuijpersHmm that might be cool to do#2017-11-2915:13thhellerthat gets pretty low level though#2017-11-2915:13thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#2017-11-2915:15thhellergets substantially more complicated when trying to include a REPL/live-reloading#2017-11-2915:15mitchelkuijpersFirst I am struggling to get my :browser-test to work again, for some reason it does not seem to pick up my runner-ns#2017-11-2915:16thhelleroh doh .. that probably has the same issue I just fixed for :karma#2017-11-2915:16mitchelkuijpersoh 😛#2017-11-2915:16mitchelkuijpersOh lol then I could have still used the old way with using browser-test for karma#2017-11-2915:16mitchelkuijpersThat would explain why that broke#2017-11-2915:17mitchelkuijpersWould you be interested if I setup a circleci config for shadow-cljs to start adding some tests?#2017-11-2915:17thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c0b3a8a1a4afb7eda3acaab380f2eef0eef1f0f8"}, :content ("[email protected]")}. same issue indeed.#2017-11-2915:17mitchelkuijpersAh awesome thnx#2017-11-2915:18thhellercircleci yes#2017-11-2915:18thhelleralso I really can’t come up with proper ways to run tests#2017-11-2915:18thhellerthats the main issue#2017-11-2915:18thhellerhow do you verify that the browser output was correct?#2017-11-2915:19mitchelkuijpersMaybe a examples folder with for example a karma test, that one we could verify#2017-11-2915:19mitchelkuijpersbrowser output is a bit harder#2017-11-2915:19thhellerwell just verifying that the compile completed without an error would be enough to start#2017-11-2915:20mitchelkuijpersThere is the new chrome project where you can run chrome and do pretty nifty stuff#2017-11-2915:20mitchelkuijpersTrue#2017-11-2915:20mitchelkuijpersI could just start with creating a circleci config and run some tests#2017-11-2915:20thhellerbut often very subtle changes break in exciting ways#2017-11-2915:20thhellerand not always directly on startup#2017-11-2915:20mitchelkuijpersthat would be a good start at least#2017-11-2915:21thhelleryeah I need to look into this container business anyways#2017-11-2915:21mitchelkuijpersIf you create a issue in github I would be happy to help, we already have some cljs tests running on circleci#2017-11-2915:25thhellerhttps://github.com/thheller/shadow-cljs/issues/143#2017-11-2915:26thhellerI’ll look over the circleci docs, getting the config right is probably the hardest part#2017-11-2915:30thhellerah the docker image was a problem @mhuebert ran into#2017-11-2915:30thhellerI think it wasn’t easy to find a docker image with java8, current node+npm#2017-11-2915:34mitchelkuijpersI built one myself#2017-11-2915:35mitchelkuijpers
FROM circleci/clojure:lein-2.7.1
USER root
RUN curl -sL  | bash -
RUN apt-get install -y nodejs

# 
RUN wget -q -O -  | apt-key add -
RUN echo 'deb  stable main' >> /etc/apt/sources.list
RUN apt-get update && apt-get install --no-install-recommends -y google-chrome-stable
#2017-11-2915:42thhellernode 7?#2017-11-2915:53colindresjSorry to hijack this thread, but I’m wondering if I can use lein checkouts (or something similar) with shadow#2017-11-2915:55thhellerare you using lein or shadow-cljs directly?#2017-11-2915:56colindresjI’m using shadow-cljs#2017-11-2915:56thhelleryou can add :source-paths ["src" "checkouts/the-thing/src"]#2017-11-2915:56colindresjThat’s what I thought#2017-11-2915:57thhellerbut the checkout dependency still needs to be in :dependencies so its dependencies get picked up properly#2017-11-2915:57colindresjRight, it is#2017-11-2915:57thhellerthe source path will always be picked over the jar this way#2017-11-2915:57colindresjYeah that’s cool, I’d like that#2017-11-2915:58colindresjThen, could I just change the source paths in the release config?#2017-11-2915:58colindresjIe, the release override#2017-11-2915:58thhellerno, changing the classpath is not supported#2017-11-2915:58colindresjOk#2017-11-2915:59colindresjAlternatively, if I go through lein, checkouts should just work?#2017-11-2915:59thhelleryes#2017-11-2915:59colindresjCool thanks#2017-11-2916:06thheller@mitchelkuijpers the first lein test via circleci succeeded. not very meaningful since there are no tests but still 😉#2017-11-2916:06thhellerI’ll think about what to test and how to test it#2017-11-2916:06mitchelkuijpersNice small steps#2017-11-2916:06mitchelkuijpersI would love to contribute some tests, it would help us a lot#2017-11-2916:08thhellerwhy would they use .yml thats such a horrible format 😛#2017-11-2916:10thhelleryeah I wanted proper tests for a while. accidental changes like the :karma/`:browser-test` breaking are not cool#2017-11-2916:10thhellerproject getting to big to keep track of everything#2017-11-2916:15mitchelkuijpersYeah that is very understandable#2017-11-2916:15mitchelkuijpersYeah yml sucks but spacemacs protects me a bit from mixing spaces and tabs and such#2017-11-2916:21thhellerhmm can you start a process and then run other commands while that process is running?#2017-11-2916:24thhellerseems like you can background stuff#2017-11-2916:25mitchelkuijpersYou can also start multiple docker containers#2017-11-2916:25thhellerI just want to re-use the JVM and not start a new one for each command#2017-11-2916:26thhellerrun shadow-cljs server in the background and then run a bunch of things against that server#2017-11-2916:27mitchelkuijpersAh like that#2017-11-2916:29thhellerI’ll figure it out eventually#2017-11-2916:29mitchelkuijpersMaybe just create a clj script which does multiple things? Is that an option#2017-11-2916:30thhellerto test the JVM side yes but I also want tests for the CLI script#2017-11-2916:30mitchelkuijpersOh ofcourse#2017-11-2916:31thheller
====>> Saving Cache
Error: Skipping cache - error checking storage: not supported
#2017-11-2916:31thhellermeh .. many docs to read …#2017-11-3008:59Jontried requiring ["path" :as path] today, got huge error messages...#2017-11-3008:59Jonnot trying to reproduce yet..#2017-11-3009:00Jonas I remembered it was like maximum call stack exceeded#2017-11-3009:00Jonsomething like arrary-of caused.. didn't check it#2017-11-3009:04thhellergiven that the shadow-cljs CLI script does this as well I’m quite confident it works. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L3#2017-11-3009:04thhellerunless you maybe tried to do it with :target :browser which won’t work because its a node only package#2017-11-3009:04Jonwill try to repro that later.#2017-11-3009:04Jonit was :target :nodejs, I used fs module
#2017-11-3009:34Jon
=>> node target/main.js
SHADOW import error /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/shadow.module.main.append.js

/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154
var self__ = this;
                                                                                             ^
RangeError: Maximum call stack size exceeded
    at Array.join (native)
    at cljs.core.Keyword.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:11154:94)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:31863:12)
    at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
    at /Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9861:30
    at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9594:39)
    at Object.cljs$core$print_prefix_map [as print_prefix_map] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs.core.js:32481:18)
    at cljs$core$print_map (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9871:8)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9680:23)
    at cljs$core$pr_writer (/Users/chen/work/find-colors/target/shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core.cljs:9739:6)
#2017-11-3009:34Jon
=>> cat src/server/main.cljs

(ns server.main
  (:require ["walk-sync" :as walk-sync]
            [clojure.string :as string]
            ["fs" :as fs]
            ["path" :as path])) ; <---

(defn main! []
  (println path) ; <---
  (let [base-dir js/process.env.base
        paths (filter
               (fn [filepath] (string/ends-with? filepath ".tsx"))
               (walk-sync base-dir))
        *colors (atom [])]
    (doseq [filepath paths]
      (let [content (fs/readFileSync (str base-dir filepath) "utf8")]
        (doseq [line (string/split-lines content)]
          (if (string/includes? line "#")
            (let [color (re-find (re-pattern "#[0-9a-f]{3,6}") line)]
              (if (some? color) (swap! *colors conj color) (println line)))))))
    (println (string/join "\n" (sort (set @*colors))))))

(defn reload! [] (main!))
#2017-11-3009:38thhelleruhm why would you println that?#2017-11-3009:38thhellerits a recursive JS obj. don’t do that.#2017-11-3009:38thheller(js/console.log path) should work since it detects circles#2017-11-3009:38JonOh..#2017-11-3009:39Jonat first I used a local variable called path and it broke the global path.. so I tried to print#2017-11-3009:39thhelleryeah its not safe to print (some) javascript objects#2017-11-3009:40Jonany patterns to figure out recursive objects?#2017-11-3009:40thhellerjust don’t print JS objects in general#2017-11-3009:40thhellerclojure print is for clojure objects not JS objects#2017-11-3009:40Jonokay 😟#2017-11-3009:40thhellerit might work with some JS objects but it is not safe#2017-11-3009:41thhelleruse js/console.log when in doubt#2017-11-3009:41thheller
[
#2017-11-3009:42Jonwell, Circular#2017-11-3009:42thhellerclojure will endlessly descend into the [Circular] things#2017-11-3009:42thhellereventually blowing up the stack#2017-11-3009:42Jonwhy don't println detect it's not Clojure data and print woth #js ...#2017-11-3009:43Jon
cljs.user=> (println (clj->js {:a 1}))
#js {:a 1}
nil
cljs.user=>
#2017-11-3009:44thhellerit does that yeah … but it does not detect circles and stops .. it just keeps going#2017-11-3009:44Jonso it still needs to format the data, which means traverse the structure again?#2017-11-3009:44Jon>_<#2017-11-3009:44Jonwell, have to accept that#2017-11-3009:46thhellersince you really have to go out of your way to create circular structures in clojure thats fine#2017-11-3009:46thhellerJS not so much#2017-11-3009:49Jonjust console.log is longer to write, I preferred println first#2017-11-3011:16mitchelkuijpersWhile developing, we run into this exception a lot when a compile faills:
[:worker-error {:resources [[:shadow.build.classpath/resource "atlas_crm/ui/components/dialog.cljc"]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update} java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286]
#2017-11-3011:29thhellerhmm#2017-11-3011:30thhelleris that all? no more stack?#2017-11-3011:36thhellerthere should be a logfile in target/shadow-cljs#2017-11-3011:41thhellerit should log a proper warning with complete stack. I removed the prn since thats not useful at all.#2017-11-3011:43mitchelkuijpersAh ok no it only gives us this in the repl#2017-11-3011:43thhellerno logfile?#2017-11-3011:45mitchelkuijpersNo logfile in target/shadow-cljs#2017-11-3011:45thhellerah wait … you are using :lein. hmm do you have any kind of logging configured?#2017-11-3011:46thhellerand … I’m stupid … I set the logfile name to logging.properties so thats not good 😛#2017-11-3011:50thhelleranyways that does not apply when using lein#2017-11-3012:06thhellerwhen using lein it uses whatever logging setup you have configured#2017-11-3012:07thhellerthat might be an issue if you have the slf4j-nop on the classpath, which means no logging at all.#2017-11-3012:16mitchelkuijpersNo I have logback on the classpath#2017-11-3012:17thhellerthen it should have logged somewhere depending on the config you have#2017-11-3012:18thhellerunless you disable warnings#2017-11-3012:20mitchelkuijpersOh lol#2017-11-3012:20mitchelkuijpersI know what it is thnx#2017-11-3012:24timovanderkamp
17-11-30 12:21:13 UnknownHost WARN [shadow.cljs.devtools.server.util:286] - failed to handle server msg {:resources [[:shadow.build.classpath/resource atlas_crm/ui/components/dialog.cljc]], :shadow.cljs.devtools.server.system-bus/topic :shadow.cljs.devtools.server.system-msg/resource-update}
                                           java.lang.Thread.run              Thread.java:  748
             java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  617
              java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1142
                            java.util.concurrent.FutureTask.run          FutureTask.java:  266
                                                            ...                               
                                      clojure.core/bound-fn*/fn                 core.clj: 1995
                                             clojure.core/apply                 core.clj:  661
                                                            ...                               
                                    clojure.core/with-bindings*                 core.clj: 1965 (repeats 2 times)
                                             clojure.core/apply                 core.clj:  657
                                                            ...                               
shadow.build.compiler/par-compile-cljs-sources/fn/iter/fn/fn/fn             compiler.clj:  726
                          shadow.build.compiler/par-compile-one             compiler.clj:  667
               shadow.build.compiler/generate-output-for-source             compiler.clj:  621
                       shadow.build.compiler/maybe-compile-cljs             compiler.clj:  572
                    shadow.build.compiler/maybe-compile-cljs/fn             compiler.clj:  596
                       shadow.build.warnings/get-source-excerpt             warnings.clj:   55
                      shadow.build.warnings/get-source-excerpts             warnings.clj:   52
                                              clojure.core/into                 core.clj: 6815
                                            clojure.core/reduce                 core.clj: 6748
                                    clojure.core.protocols/fn/G            protocols.clj:   13
                                      clojure.core.protocols/fn            protocols.clj:   75
                              clojure.core.protocols/seq-reduce            protocols.clj:   24
                                               clojure.core/seq                 core.clj:  137
                                                            ...                               
              shadow.build.warnings/get-source-excerpts/iter/fn             warnings.clj:   41
           shadow.build.warnings/get-source-excerpts/iter/fn/fn             warnings.clj:   41
java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__46278__46282$fn__46283$fn__46284$fn__46286
#2017-11-3012:25mitchelkuijpersIt gives us this in the logging, we do log warnings. I seems to fail on initializing some class#2017-11-3012:39thhellerthats super weird, not doing anything special there#2017-11-3012:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/warnings.clj#L41#2017-11-3012:41thhellerespecially since it’s already supposed to catch all errors#2017-11-3012:42thhellermaybe lein has some old AOT cache? I really can’t see how line 41 can fail#2017-11-3012:43thhellerexcept that I may need to expand to Throwable#2017-11-3012:50mitchelkuijpersIt seems to break on a macro.. and also if we import the same thing twice by accident#2017-11-3012:50thhellerthats doesn’t explain NoClassDefFoundError though#2017-11-3012:50mitchelkuijperstrue#2017-11-3012:53thhellertry {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2d5e454c49425a004e41475e6d1f031d031c1c1d"}, :content ("[email protected]")}. only change is that it now catches Throwable since NoClassDefFoundError is not an exception#2017-11-3013:39timovanderkampI tried that version and this is the result:
Exception in thread "async-dispatch-2" 
java.lang.ExceptionInInitializerError
	at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:253)
	at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253)
	at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61)
	at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59)
	at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79)
	at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63)
	at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343$fn__49346.invoke(util.clj:119)
	at shadow.cljs.devtools.server.util$stdout_dump$fn__49338$state_machine__7021__auto____49343.invoke(util.clj:119)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
	at clojure.lang.Compiler.currentNS(Compiler.java:7397)
	at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1310)
	at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843)
	at clojure.lang.LispReader.read(LispReader.java:275)
	at clojure.lang.LispReader.read(LispReader.java:206)
	at clojure.lang.LispReader.read(LispReader.java:195)
	at clojure.lang.RT.readString(RT.java:1871)
	at clojure.lang.RT.readString(RT.java:1866)
	at shadow.cljs.devtools.errors$user_friendly_error$fn__49243.<clinit>(errors.clj:254)
#2017-11-3013:44thhellerI really have no idea whats going on there#2017-11-3013:45thhellernowhere in that file to I call read-string#2017-11-3013:46thhellerjust in case did you try running lein clean?#2017-11-3013:52timovanderkampyes I did#2017-11-3013:52timovanderkampI will try it again, just to be sure#2017-11-3013:53thhellerI think I found a thing, you are running in nREPL correct?#2017-11-3013:53thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c350674687668777777"}, :content ("[email protected]")} at least fixes the java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace#2017-11-3013:54timovanderkampYes I do, alright I will try that version out#2017-11-3014:05timovanderkampThis is what i get with version 2.0.111
Exception in thread "async-dispatch-8" 
java.lang.ExceptionInInitializerError
	at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:254)
	at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:253)
	at shadow.cljs.devtools.server.util$print_build_failure.invokeStatic(util.clj:61)
	at shadow.cljs.devtools.server.util$print_build_failure.invoke(util.clj:59)
	at shadow.cljs.devtools.server.util$print_worker_out.invokeStatic(util.clj:79)
	at shadow.cljs.devtools.server.util$print_worker_out.invoke(util.clj:63)
	at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347$fn__49350.invoke(util.clj:119)
	at shadow.cljs.devtools.server.util$stdout_dump$fn__49342$state_machine__7021__auto____49347.invoke(util.clj:119)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__7039.invoke(ioc_macros.clj:986)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__1082$fn__1083.invoke(channels.clj:95)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: Can't resolve find-ns
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1315)
	at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:843)
	at clojure.lang.LispReader.read(LispReader.java:275)
	at clojure.lang.LispReader.read(LispReader.java:206)
	at clojure.lang.LispReader.read(LispReader.java:195)
	at clojure.lang.RT.readString(RT.java:1871)
	at clojure.lang.RT.readString(RT.java:1866)
	at shadow.cljs.devtools.errors$user_friendly_error$fn__49246.<clinit>(errors.clj:254)
#2017-11-3014:11thhellerI don’t get whats going on .. seriously this doesn’t make any sense to me.#2017-11-3014:12thhellerbut the *ns* binding seems to be the cause since I changed that and the error changed#2017-11-3014:13thhellertry {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7e0d161f1a1109531d12140d3e4c504e504f4f4c"}, :content ("[email protected]")}. I removed that binding completely, maybe nrepl just doesn’t like doing that.#2017-11-3014:17timovanderkampOn it.#2017-11-3014:23timovanderkampIt works now!#2017-11-3014:24timovanderkampThanks a lot @thheller, works perfectly!#2017-11-3014:24jgdaveyI’m puzzling through an issue: Using shadow-cljs cljs-repl :id outputs response as I’d expect, but within Emacs/cider, after connecting and running (shadow.cljs.devtools.api/nrepl-select :id-of-build), responses come back, but they are always a string.#2017-11-3014:25jgdaveyAny clue where I should look for this, @thheller? I’m happy to work on it#2017-11-3014:29jgdavey
cljs.user> (+ 1 2)
"3"
#2017-11-3014:30thhellerwe already struggled with this once I really don’t know what I’m supposed to do#2017-11-3014:30thhellerit is the cider nREPL middleware causing this#2017-11-3014:31jgdaveyHmm, interesting#2017-11-3014:31jgdaveyDoes manually specifiying middleware in shadow-cljs.edn override the default stack?#2017-11-3014:32thhellerno it just adds#2017-11-3014:33jgdaveyGotcha#2017-11-3014:33thhellerhttps://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/util/cljs.clj#L66-L87#2017-11-3014:34thheller(:value response) is a string#2017-11-3014:34jgdaveyGotcha#2017-11-3014:35thhellerbut that for some reason gets pprint’d#2017-11-3014:35jgdaveyWeird#2017-11-3014:43jgdaveyI’ll play around with it. Didn’t realize you’d already done the same. I’ll let you know if I come up with anything. Thanks!#2017-11-3014:45thhellerthe problem is that cursive is fine with what I’m doing#2017-11-3014:45thhellercider isn’t#2017-11-3014:45jgdaveyYou mean with the piggieback emulation?#2017-11-3014:45thhellerno that doesn’t seem to be the issue#2017-11-3014:46thhellerwhen I remove the cider middleware everything is fine in cursive#2017-11-3014:46thhellerwhen I add it cursive also prints escaped strings#2017-11-3014:46thhellersince it works without the cider middleware I thought I was doing it correctly#2017-11-3014:47thhellerbut that does not seem to be true#2017-11-3014:47thhellerits really hard to find documentation for what this should actually do#2017-11-3014:50jgdaveyTotally. Cider’s a big project#2017-11-3014:51thhellerhttps://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/pprint.clj#L64-L75#2017-11-3014:51thhellerI think that was the print code#2017-11-3014:52thhelleror rather this https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/pprint.clj#L77-L85#2017-11-3014:53thhellereither way .. I guess I’ll need to read-string the result I get back from the CLJS repl#2017-11-3014:54thhellerwhich seems super silly given that it will just be printed again#2017-11-3014:56jgdaveyYeah, but that code you linked me to does call (read-string) conditionally#2017-11-3014:56jgdaveyMust be on the other side of the if there#2017-11-3016:14jgdaveyOkay, so actually issuing a pprint eval (in Emacs C-c C-p) rather than a vanilla eval behaves as expected, reading the string#2017-11-3018:02thhellerI can just read-string the value I get from the client if all else fails#2017-12-0109:29thheller@sundbp {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfccd7dedbd0c892dcd3d5ccff8d918f918e8e8c"}, :content ("[email protected]")} has the configuration :devtools {:repl-timeout 30000} (if you still need it)#2017-12-0109:47sundbpcheers - it’ll be useful for me at times!#2017-12-0110:06thheller@jgdavey when I try to read-string the REPL result Cursive breaks with
Error handling response - class java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence
#2017-12-0114:23jgdaveyYeah, I’ll just use my work-around for now#2017-12-0114:23jgdaveyThanks for trying!#2017-12-0422:06josehi, I'm just starting with shadow-cljs, and I'm confused about the targets purpose. For example, does it make sense to create a custom target to pre-process the CSS files?#2017-12-0422:53thhellerpre-process css?#2017-12-0422:53thheller:target is meant to define the target platform, ie. the thing thats going to run the generated JS#2017-12-0510:27joseAs I understood it, from this article on the wiki: https://github.com/thheller/shadow-cljs/wiki/Custom-builds I can create a custom build to add some extra steps to the build process, e.g. compile sass to css. Once I have a custom build I can start it with a command like shadow-cljs watch compile-css app , where app is the build targeting the browser. Is it correct? or what is the recommended way to add some extra steps to the build (e.g. compile sass)?#2017-12-0510:29thhelleryes you can do this but shadow-cljs is meant to compile CLJS/JS#2017-12-0510:29thhellerthe requirements for css are entirely different#2017-12-0510:29thhellerthat being said if you just want to run a function that does the css#2017-12-0510:29thhelleryou can hook that into your target#2017-12-0510:31thhellerI recommend to start by calling shadow-cljs clj-run your.css/build manually#2017-12-0510:32thhellerthat fn can use (shadow.cljs.devtools.api/get-build-config :app) if it needs the config#2017-12-0510:35joseok, thanks, my idea is to add a custom build to be able to build a complete website with just one command#2017-12-0510:36thhellerthe issue with this is that css has completely different concerns than CLJS#2017-12-0510:37thhellerCLJS gets recompiled a lot during development (and hot loaded)#2017-12-0510:37thhellertriggering a CSS compile on every CLJS compile is bad#2017-12-0510:37thheller(as is the reverse)#2017-12-0510:37thhellersince it does too much work#2017-12-0510:38thhellerso you really just want two independent things to run in parallel#2017-12-0510:38thhellerI do have my own sass utils in my project where I do this#2017-12-0510:39thhellerI understand the desire to make it part of the build but I don’t recommend starting with that#2017-12-0510:39thhellermake a standalone function that does what you want#2017-12-0510:40thhellerintegrating that into a custom target is much simpler later#2017-12-0510:40thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/custom-build#2017-12-0510:41thhellerhttps://github.com/thheller/shadow-cljs/wiki/Custom-builds#2017-12-0510:41joseso you have 2 different processes, one watching CLJS and other the CSS?#2017-12-0510:41thheller2 threads on the same JVM#2017-12-0510:43thhellerI have not yet settled on a proper API for “plugins” but sass would probably be a plugin#2017-12-0510:45joseare there plans to provide an api for plugins for shadow-cljs? that would be cool#2017-12-0510:46thhelleryes. the basic theme will probably be like this: you provide a function for shadow-cljs to call when starting#2017-12-0510:46thhellerthat function in turn can modify the server and register additional “hooks” it wants#2017-12-0510:46thhellereg. call this function when a dev build is started#2017-12-0510:46thhellercall this function when a release build is started#2017-12-0510:47thhelleretc#2017-12-0510:47thhellerbut … write plain clojure code with no dependecy on shadow-cljs until you REALLY need to#2017-12-0510:48thhellerthere are too many tool-specific tools already, that needs to end.#2017-12-0510:48thhellereverything you write should also work in lein (and boot and tools.deps clojure)#2017-12-0510:50josejust one more question, the wiki article says The state is a clojure map representing the full shadow-build compiler state. TBD: open an issue if you want to know more about this. can you point me to where to find more info about it?#2017-12-0510:51thhelleranything specific you want to know? there are no docs for this apart from the code itself#2017-12-0510:51thhellershadow.build.data has some utility functions#2017-12-0510:53josejust a link to some code to start to look into it is fine#2017-12-0510:54joseI think here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/data.clj , right?#2017-12-0510:54thhelleryes.#2017-12-0510:54thhellerprobably best to just look at the default targets, eg. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L505-L525#2017-12-0510:57josethanks a lot for all the info, really enjoying shadow-cljs and looking forward to the plugin api 🙂#2017-12-0510:57thhellerits all pretty CLJS/JS specific and CSS is a whole lot simpler#2017-12-0510:57thhellerwrite a plain function to compile css and you don’t even need a plugin API#2017-12-0512:05gravIs there some kind of hook that shadow-cljs calls after it recompiles in watch mode?#2017-12-0512:24thhellerhook to do what?#2017-12-0512:25thhellernone currently but I can add one easily. just need a use-case to justify it 😛#2017-12-0612:18mitchelkuijpersAll of a sudden I run into: could not find module-entry: babel-runtime/core-js/symbol Any idea what might cause this?#2017-12-0612:18mitchelkuijpersIt seems to want to resolve babel for some reason#2017-12-0612:24mitchelkuijpersHmm maybe I removed a dependency to much#2017-12-0612:26mitchelkuijpersNope, I am stumped#2017-12-0612:48mitchelkuijpersFixed by using the npm-shrinkwrap from a colleague.. So false alarm#2017-12-0613:32Jonhttps://github.com/parcel-bundler/parcel#2017-12-0703:36Jonhttps://gist.github.com/chenyong/71f9759f88f6498db55932e2ba896d68#2017-12-0703:37Jonnot reproduced after changing to version 114#2017-12-0708:35thhelleryeah I messed that up earlier. might need to delete target/shadow-cljs/logging.* in case it still doesn’t work.#2017-12-0710:02Jon
Request URL:
#2017-12-0710:02JonI see this when I change my files#2017-12-0710:02Jonbut I'm debugging with another device, which does not use localhost to connect my dev server#2017-12-0710:03Jonany options to change it to an IP address? or js/location.hostname?#2017-12-0710:04Jonwhy it starts two websocket connections, instead of one?#2017-12-0710:06thhellerits only two websockets if you use the hud#2017-12-0710:06thhellerit is js/location.hostname by default#2017-12-0710:08Jon
:devtools {:after-load app.main/reload!
           :preloads [shadow.cljs.devtools.client.hud]
           :http-root "target"
           :http-port 8080}
#2017-12-0710:08JonI think I didn't change it.#2017-12-0710:10thhellerhave you defined :http {:host ...} ?#2017-12-0710:10Jonno#2017-12-0710:10Jonfull file https://github.com/TopixIM/schemer/blob/master/app/shadow-cljs.edn#2017-12-0710:10thhellercheck shadow.cljs.devtools.client.env in the javascript console#2017-12-0710:12thhelleruse-document-host is true so it will use js/document.location.hostname#2017-12-0710:13thhelleroh doh#2017-12-0710:14thheller… the files request doesn’t use that yet#2017-12-0710:14thhellerI was confusing it with the websockets which should be using the other host#2017-12-0710:14thhellerlet me add it for the files req as well#2017-12-0710:14Jon😄#2017-12-0710:18thhellershould be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "097a61686d667e246a65637a493b27392738383c"}, :content ("[email protected]")}#2017-12-0710:23Jonthanks, confirmed it's working, the tab in my other device now reloads correctly 😬#2017-12-0714:26Jonhttps://twitter.com/WasmWeekly/status/938716499551940608 😛#2017-12-0717:21thhellerdoes that mean that you want wasm support?#2017-12-0719:44grav@thheller In my case, I’d like to restart a server every time the source changes.#2017-12-0802:25Jon@thheller not yet... but I noticed WebAssembly is supported by browsers a lot faster than I expected.#2017-12-0802:26JonAll browsers(except for IE...) now supports WebAssembly, Rust has merged support for WebAssembly backend.#2017-12-0802:27JonIn recent Haskell reflecting, several WebAssembly backends have been developed.#2017-12-0802:28JonI don't use WebAssembly yet. But if its DOM APIs integration is ready, things may change. I heard that would happen in less a year.#2017-12-0802:33Jonalso want to know your opinion?#2017-12-0805:12hagmonkI'm trying to make shadow-cljs work with cider ... keep having trouble getting it to switch to a clojurescript repl. Any pointers?
user-error: ‘cider-eval-last-sexp’ needs a ClojureScript REPL.
If you don’t know what that means, you probably need to jack-in (‘C-c M-J’).
#2017-12-0805:13hagmonkthis is after trying both (shadow.cljs.devtools.api/nrepl-select :plugin) and (cemerick.piggieback/cljs-repl :plugin). I have shadow-cljs watch plugin and shadow-cljs node-nrepl in the background#2017-12-0808:34thheller@hagmonk I don’t know anything about cider setup but @mitchelkuijpers got it working#2017-12-0808:59mitchelkuijpers@hagmonk I start shadow-cljs inside of my clojure process#2017-12-0809:00mitchelkuijpersWould that be an option for you? Then I can help you#2017-12-0815:34Jon
=>> yarn watch
yarn run v1.3.2
$ shadow-cljs watch browser
shadow-cljs - config: /Users/chen/repo/mvc-works/mvc-works.org/shadow-cljs.edn version: 2.0.115
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.pom from 
Retrieving thheller/shadow-client/1.3.0/shadow-client-1.3.0.pom from 
Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.jar from 
Retrieving thheller/shadow-client/1.3.0/shadow-client-1.3.0.jar from 
^C
=>> time yarn watch
yarn run v1.3.2
$ shadow-cljs watch browser
shadow-cljs - config: /Users/chen/repo/mvc-works/mvc-works.org/shadow-cljs.edn version: 2.0.115
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.0.115/shadow-cljs-2.0.115.jar from 
^C

real	1m3.436s
user	0m0.433s
sys	0m0.083s
#2017-12-0815:38Jonswitched to 4G network and downloaded in less than 10s, a lot faster than my WiFi#2017-12-0817:46hagmonkthanks @thheller and @mitchelkuijpers, but I hit a different problem that seems harder than the REPL for now 🙂#2017-12-0817:48hagmonkbasically I'm trying to convert this to clojurescript, i.e. write a grafana datasource plugin in clojurescript: https://github.com/grafana/simple-json-datasource/#2017-12-0817:48hagmonkshadow-cljs seems perfect because it really cuts away a lot of the ceremony about building cljs projects!#2017-12-0817:50hagmonkI'm trying to figure out if I have parity between what cljs is generating, and what the typescript build process in that plugin is generating#2017-12-0817:51hagmonkright now I'm approaching this as a node-library build target with exports, curious to know if I'm in the right direction ...#2017-12-0901:53hagmonkSlightly more specific question if anyone is game: QueryCtrl in a grafana plugin has to be "treated as an Angular controller" and it must "inherit from the app/plugins/sdk.QueryCtrl" class ... is such a thing even possible on the CLJS side?#2017-12-1008:37Jondo we have something like :local/root of deps.edn in shadow-cljs? https://clojure.org/reference/deps_and_cli#_dependencies#2017-12-1115:22mhuebertif clj-run fails (eg. an error like failed to load namespace: foo.x), should it return a non-zero error code? (or is there a way to make that happen?)#2017-12-1209:01Jonhttps://github.com/minimal-xyz/minimal-shadow-cljs-es6#2017-12-1209:01Jonjust want to see if it will work correctly...#2017-12-1210:32thheller@jiyinyiyong :entries supports strings and they current expect full paths#2017-12-1210:34thhellerso you could use "/src/main.js" as the entry in the config. but it is not currently supported to specify devtools and such since that expects cljs namespaces#2017-12-1210:34thheller@mhuebert it should, if it doesn’t open a ticket please#2017-12-1210:34thheller@hagmonk extending classes is possible yes, just not very pretty, see https://gist.github.com/thheller/7f530b34de1c44589f4e0671e1ef7533#2017-12-1213:49JonIs "./src/main.js" support? that's the common syntax in Node since Node prefers relative paths that start with ./#2017-12-1214:31thhellernot for entries since there is nothing to be relative to#2017-12-1214:31thhellerI can probably change it to use the project root as the default so it can be relative to that#2017-12-1402:01Jon> The big ticket item for shadow-cljs however currently is documentation. I should focus on that instead of actually coding but it is absolutely no fun for me so I usually don’t do it. If anyone would like to help out with actual docs I will happily walk you through everything … I just hate the writing part.#2017-12-1402:01Jonhttps://clojureverse.org/t/from-twitter-how-do-we-sell-clojure/1184/5?u=jiyinyiyong#2017-12-1402:02JonI'm interested but I'm not an good English writer. might help in Chinese docs...#2017-12-1410:26thhelleryou have already written more docs than me 🙂#2017-12-1410:29thhellerbut yeah keep it going. chinese is fine too, ideally I want all the languages 😉#2017-12-1414:53Jonare you ready for a http://shadow-cljs.org ?#2017-12-1414:53Jon...then you got no chance to change the name#2017-12-1415:24thhellerdoubt that a standalone domain is necessary or helpful (yet)#2017-12-1415:24thhellergithub pages should do fine for now#2017-12-1416:47JonGitHub has some constraints. I prefer serving pages with my own server, like http://respo.site/ and http://cirru.org/#2017-12-1416:49Jonnot sure about the benefits though... a site just gives visitors impression that it's a production-ready project, and a better entry to docs. Real users still want docs.#2017-12-1700:04mjmeintjesHi. Not sure if this is a shadow-cljs issue, but I was wondering whether you have experienced a problem with advanced compilation and regular expressions. It seems that the advanced optimizations is stripping out the backslashes from my regular expression patterns. (println #"(\p{Lu}+[\p{Ll}\u0027\p{Ps}\p{Pe}]*)") ;; (while developing): #"(\p{Lu}+[\p{Ll}\u0027\p{Ps}\p{Pe}]*)" ;; (advanced compilation): #"(p{Lu}+[p{Ll}\u0027p{Ps}p{Pe}]*)"#2017-12-1700:06mjmeintjesSeems to just be for the "\p" regex tag#2017-12-1709:00thheller@mjmeintjes hmm that would be closure doing that. what is \p, never used that before?#2017-12-1709:44thhellerlooks like that is es6, might work if you add :compiler-options {:language-out :ecmascript6}#2017-12-1720:47mjmeintjesThanks, I'll try that. Also never used \p before, but it is used in the funcool cuerdas string library, which currently does not work with advanced compilation due to this.#2017-12-1722:41thhellernothing else happens? is it using CPU?#2017-12-1722:43thhellermaybe the logfile in target/shadow-cljs has some info?#2017-12-1722:43hoppyit bails out after that#2017-12-2010:37mhueberthmm, the reagent with-let macro results in some externs inference warnings: https://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L48
Cannot infer target type in expression (. c__50784__auto__ -ratomGeneration)
Cannot infer target type in expression (. with-let79468 -generation)
#2017-12-2010:40thhellerhmm I think thats going to require type hints#2017-12-2010:40thhellerany idea why those are not protocols?#2017-12-2010:40mhuebertno idea#2017-12-2010:46thhellerI can't really make sense of that macro, seems weird#2017-12-2010:46mhuebertalright. so that would just be adding ^js in front of v and c##2017-12-2010:46thheller^clj not js#2017-12-2010:46thhellersince its a clojure value we don't need externs#2017-12-2010:46mhuebertah#2017-12-2010:47thhellerbut it doesn't detect it as a clojure value since it doesn't use a protocol#2017-12-2010:47mhuebertwould that also work in non-shadow builds#2017-12-2010:47thhelleryep#2017-12-2010:47mhuebertso (let [^clj ~v (reagent.ratom/with-let-values ~k)] …#2017-12-2010:48thhellercan't tag quoted syms like that#2017-12-2010:48thhellerv (with-meta {:tag 'clj} (gensym "with-let")) in the let above#2017-12-2010:49thhelleroops switch the args#2017-12-2010:49thheller(with-meta (gensym "with-let") {:tag 'clj})#2017-12-2010:50thhellerI think so at least .. maybe the unqoute does work too#2017-12-2011:13mhuebertalright, so what seems to work is your way^^ for the symbol that is bound outside of the syntax quote, v (with-meta (gensym "with-let") {:tag 'clj}) and an inline ^clj for the symbol that is bound within the quote (when-some [^clj c# reagent.ratom/*ratom-context*] ...)#2017-12-2011:14mhuebertneither seem to work the other way around#2017-12-2011:15thhellerinteresting. would not have expected ^clj c# to work#2017-12-2011:16thhellermakes sense though since its not unquoted#2017-12-2011:17mhueberti am seeing some deftype- or protocol-related type hint errors that show up the first time I run a build, but not after (unless i rm -rf target)
41 | (deftype GZIPPacker [packer]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. GZIPPacker -prototype) -taoensso$sente$interfaces$IPacker$)
--------------------------------------------------------------------------------
  42 |   taoensso.sente.interfaces/IPacker
  43 |   (pack [_ x]
  44 |     (try
  45 |       (->> x (pack packer) (gzip))
#2017-12-2011:18mhuebertactually it’s not entirely clear to me when they will appear or not#2017-12-2011:18thhellerare you using a checkout of shadow-cljs?#2017-12-2011:19mhuebertshadow-cljs is not listed in the dependencies, and there is no checkouts dir#2017-12-2011:19thhellerhmm ok#2017-12-2011:19thhellerI see those warnings sometimes when working on shadow-cljs itself, have not figured out where they come from either#2017-12-2011:19thhellersince they work most of the time#2017-12-2011:19mhuebertok, so the warnings remain during reload. but if i stop the process, and then start another watch process, the warnings are gone (until i remove the caches)#2017-12-2011:20thhellerodd#2017-12-2011:20thhellerthe warnings should prohibit the cache from being use at all#2017-12-2011:21thhellerI’ll take a look at sente#2017-12-2011:23thhellerI guess I could treat any variable name that uses that naming pattern as CLJS#2017-12-2011:23thhellereg. everything $thing$foo$#2017-12-2011:24mhuebertseems to happen in some even very simple cases of implementing protocols. the sente thing is probably easiest to debug/reproduce as it’s all open source. another example from my repo --
(defprotocol IExplain
  (explain [this value]))

(defrecord ExplainStruct [struct-schema]
  IExplain
  (explain [this value] (first (struct/validate value struct-schema))))
results in
24 | (defrecord ExplainStruct [struct-schema]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. ExplainStruct -prototype) -my-app$lib$forms$IExplain$)
--------------------------------------------------------------------------------
  25 |   IExplain
  26 |   (explain [this value] (first (struct/validate value struct-schema))))
#2017-12-2011:24thhellercan you run shadow-cljs clj-repl and then (require 'shadow.build.cljs-hacks :reload) and compile again?#2017-12-2011:25thhellersometimes it seems that the hacks aren’t loaded properly#2017-12-2011:25thhelleror rather overwritten somewhere else#2017-12-2011:26mhuebertk let me check, i have to start the process over w/o cache#2017-12-2011:26thhellerI need to clean up those hacks so I can make proper patches for CLJS#2017-12-2011:27thhellerI’m confused how they warnings go away with cache since any warning should prevent the cache from being written in the first place#2017-12-2011:27thhellersente does some weird elide-require stuff but besides that nothing that should interfere with the compile#2017-12-2011:28thhellerbut yeah it doesn’t seem to be related to sente anyways if you see it in your lib#2017-12-2011:30mhuebertok so i have 1) started a shadow server, 2) started a watch process, and I see all the warnings. Then I 3) did the clj-repl command above, and 4) edited a file to trigger the watch. Now the warnings are gone.#2017-12-2011:31thhelleryeah thats behaviour I see when working on shadow-cljs itself. just never saw it when using it as a lib.#2017-12-2011:32thhellerguess I need to figure out whats happening#2017-12-2011:32thhelleror find another way to hack the compiler 😛#2017-12-2011:34mhuebert🙂#2017-12-2011:35thhellerthe (in-ns 'cljs.analyzer) always felt like it could break any time#2017-12-2012:41thheller@mhuebert found it, fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f6859e97929981db959a9c85b6c4d8c6d8c7c7cf"}, :content ("[email protected]")}. cljs.core was force-loaded after the hacks so it was overwriting them again.#2017-12-2012:48mhuebert👍 works in my build#2017-12-2013:45davidst@thheller shadow-cljs emits an undeclared var warning for letfn forms if the bindings are not in the right order#2017-12-2013:45davidstsee https://github.com/funcool/bide/pull/16 for an example#2017-12-2013:45davidstaccording to the docstring the names in letfn should be available to all definitions#2017-12-2013:46davidstSo it looks like a shadow-cljs issue#2017-12-2014:16thhellerodd. didn’t know that letfn allows this behaviour. will look into it#2017-12-2019:42thheller@davidst fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c6b5aea7a2a9b1eba5aaacb586f4e8f6e8f7f4f6"}, :content ("[email protected]")}.#2017-12-2023:02davidst@thheller thank you!#2017-12-2102:02seako@thheller i'd like to help with the documentation writing effort, how can i get started?
#2017-12-2102:03seakoby which i mean, are there things in particular that you'd like documented but never have the time to document?#2017-12-2102:55JonI want h2 too..#2017-12-2103:43JonIs there docs for using shadow-cljs in clj now?#2017-12-2103:43JonI got errors in my attempts#2017-12-2103:43Jon
Exception in thread "main" clojure.lang.ExceptionInfo: missing instance {}
	at clojure.core$ex_info.invokeStatic(core.clj:4739)
	at clojure.core$ex_info.invoke(core.clj:4739)
	at shadow.cljs.devtools.server.runtime$get_instance_BANG_.invokeStatic(runtime.clj:11)
	at shadow.cljs.devtools.server.runtime$get_instance_BANG_.invoke(runtime.clj:8)
	at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:104)
	at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:99)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:125)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:115)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
	at build.watch$_main.invokeStatic(watch.clj:12)
	at build.watch$_main.invoke(watch.clj:8)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.main$main_opt.invokeStatic(main.clj:317)
	at clojure.main$main_opt.invoke(main.clj:313)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)
#2017-12-2107:48thheller@seako cool! I want to document all the things. I never know what to document since I wrote the thing and know how everything works. Anything helps really.#2017-12-2107:49thheller@jiyinyiyong in clj call (api/with-runtime (api/watch ...)) if you want a short lived runtime. (shadow.cljs.devtools.server/start!) if you want to start and leave it running in the background.#2017-12-2111:14Jon
2 | (ns app.updater (:require [respo.cursor :refer [mutate]]))
   3 |
   4 | (defn updater [store op op-data]
   5 |   (case op
---------^----------------------------------------------------------------------
 Cannot infer target type in expression (. G__35616 -fqn)
--------------------------------------------------------------------------------
   6 |     :states (update store :states (mutate op-data))
   7 |     :content (assoc store :content op-data)
   8 |     store))
#2017-12-2111:14Jondidn't see this warning before, what does it mean?#2017-12-2111:17Jon
=>> clj -m build.compile
Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
	at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106)
	at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106)
	at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30)
	at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:23)
	at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:108)
	at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:99)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:125)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:115)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:111)
	at build.compile$_main$body_fn__29460__auto____31659.invoke(compile.clj:9)
	at build.compile$_main.invokeStatic(compile.clj:8)
	at build.compile$_main.invoke(compile.clj:7)
	at clojure.lang.AFn.applyToHelper(AFn.java:152)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.main$main_opt.invokeStatic(main.clj:317)
	at clojure.main$main_opt.invoke(main.clj:313)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)
#2017-12-2111:17Jon
(ns build.compile
  (:require [shadow.cljs.devtools.api :as api]
            [shadow.cljs.devtools.server :as server]
            [clojure.java.shell :refer [sh]]))

(defn -main []
  (api/with-runtime
    (api/watch :browser)))
#2017-12-2111:21Jonturned out I need full examples running shadow-cljs in clj#2017-12-2111:22Jonworks fine when I use (server/start!)#2017-12-2111:22thhellerah, hmm for watch you can’t use with-runtime. only for compile.#2017-12-2111:22thhelleryeah, start! should work#2017-12-2111:22Jonoh... right, I forgot to change the function#2017-12-2111:23Jonworking now with api/with-runtime (api/compile ...)#2017-12-2111:23thhellerI really would not recommend running shadow-cljs via clj. it is just strictly worse than using shadow-cljs directly#2017-12-2111:24thhellerjust because you can doesn’t mean that you should 😉#2017-12-2111:25thhellerdon’t forget calling (server/stop!)#2017-12-2111:27Jonwell... I'm trying to solve the problem of compiling with shadow-cljs twice#2017-12-2111:27thhellerhmm?#2017-12-2111:28Jonas described https://github.com/thheller/shadow-cljs/issues/147#2017-12-2111:29thhellerclj won’t solve that for you#2017-12-2111:29JonI will put the scripts in a .clj file, not touching it from REPL actually#2017-12-2111:30thhellerclj will always launch a new JVM so I’m not sure what you are hoping to gain#2017-12-2111:30Jonduring my assets building, I need to start shadow-cljs twice from npm script#2017-12-2111:30thhellerno you do not#2017-12-2111:31thhellercreate ONE clojure function#2017-12-2111:31thheller(ns build.compile) (defn do-something [] ...)#2017-12-2111:31Jonthen I need to run clj to run that.#2017-12-2111:31thhellershadow-cljs clj-run build.compile/do-something#2017-12-2111:31thhellerin that function do whatever you want#2017-12-2111:31Jonmy build tool was npm scripts.. it does not run Clojure#2017-12-2111:31thhellereg. call (api/watch ...)#2017-12-2111:32Jonanyway I have to write Clojure code..#2017-12-2111:32thhelleryeah you’ll need to write clojure … but why use clj?#2017-12-2111:33Jonare you suggesting that I run clj code with shadow-cljs instead of clj#2017-12-2111:33thhelleryes, why not?#2017-12-2111:33Jondidn't try clj-run sub-command before#2017-12-2111:34thhellerit does literally the same stuff clj does#2017-12-2111:34thhellerwell it actually does more ..#2017-12-2111:34Jonthey look same too me. guess I don't need to duplicate deps in deps.edn if I call shadow-cljs clj-run#2017-12-2111:36Jonhow about the warning? Cannot infer target type in expression (. G__35616 -fqn)#2017-12-2111:36Jonnot seen it before, only got it when I call APIs#2017-12-2111:37thhellerdunno, does it happen with clj-run?#2017-12-2111:37Jonhaven't tried yet#2017-12-2111:38thhellerclj has a few issues with dependencies, it sometimes loads old versions#2017-12-2111:38thhellerit resolves differently than lein or boot. don’t know why … it is alpha so be careful.#2017-12-2111:39Jontried with clj-run, no warning now#2017-12-2111:39Jonthanks#2017-12-2111:40JonI will try migrate some of my build scripts to Clojure.. hope it runs well#2017-12-2113:20thhellerjust pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "186b70797c776f357b74726b582a362836292a2a"}, :content ("[email protected]")} which should start a bit faster. if you already have ssl configured it now supports http2 as well.#2017-12-2116:20tomc@thheller You mentioned in the cljs channel that shadow-cljs has support for using dependencies from npm. Is there a minimal example somewhere of how to require those dependencies in clojurescript code? Should it work the way clojurescript's :npm-deps is supposed to?#2017-12-2116:25thheller@tomc https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2017-12-2116:25thheller:npm-deps is supported when libs use it. in your project you directly npm install (or yarn) yourself#2017-12-2401:24mhuebert:npm-deps should also work for your own project, no? that’s what i have been doing.. then my libs/apps are consistent#2017-12-2116:26thhellerminimal example you can clone https://github.com/shadow-cljs/quickstart-browser and use that as a quickstart#2017-12-2116:30Jon
shadow-cljs - config: /Users/chen/repo/mvc-works/coworkflow/shadow-cljs.edn version: 2.0.122
shadow-cljs - starting ...
Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
	at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106)
	at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106)
	at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30)
	at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:23)
	at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:95)
	at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:86)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:112)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:98)
	at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:102)
	at shadow.cljs.devtools.api$watch.invoke(api.clj:98)
	at build.watch$_main.invokeStatic(watch.clj:9)
	at build.watch$_main.invoke(watch.clj:7)
#2017-12-2116:30Jonwhat does this error mean?#2017-12-2116:30thhellerwhat are you doing?#2017-12-2116:30Jon
(ns build.watch
  (:require [shadow.cljs.devtools.api :as api]
            [shadow.cljs.devtools.server :as server]
            [clojure.java.shell :refer [sh]]))

(defn -main []
  (server/start!)
  (api/watch :browser))
#2017-12-2116:31thhellerif you use clj-run you don’t need server/start!#2017-12-2116:31Jonwell...#2017-12-2116:32Jonhow about api/watch#2017-12-2116:32tomc@thheller thanks a lot#2017-12-2116:33JonI think it caused the error. the error remains without server/start!#2017-12-2116:33thhellerI need more information, I can’t tell what you are doing#2017-12-2116:34thhellerwhich command do you run?#2017-12-2116:34Jontrying to launch a watch server from API#2017-12-2116:34thhellerwhich command do you run?#2017-12-2116:34Jonyarn shadow-cljs clj-run build.watch/-main#2017-12-2116:34thhelleris a server running?#2017-12-2116:35Jonno server#2017-12-2116:35Jonturned out not a good idea to start watch server from a script.#2017-12-2116:35thhelleryou can do that no problem#2017-12-2116:37Jonwhat's the right code to start a watch server in Clojure code?#2017-12-2116:37thheller(api/watch :browser)#2017-12-2116:38thhellerhang on. I think I found the issue.#2017-12-2116:46thhellerso the issue is that clj-run only does a with-runtime which is a lightweight runtime that doesn’t start the embedded server#2017-12-2116:46thhellerbut watch needs the embedded server#2017-12-2116:47thhellerI did not expect anything to run watch via clj-run#2017-12-2401:33mhuebertI think a case came up this week where I thought “hey, we might need to move our watch command into a clj-run process)” but i can’t remember the exact context right now.#2017-12-2413:45mhuebertah, remembered one. I’m adding a function to my release script which rewrites asset paths in index.html to match the MD5 output names in manifest.edn. I’d like to make sure these paths get re-written to their base forms during dev. I’m trying to think of the most logical way to do this… what came to mind is using clj-run to run my-app.build/watch, and in that function, call the write-static-resource-paths! function once, after the initial compile of api/watch.#2017-12-2116:47Jona worker?#2017-12-2116:47thhellerI think I’ll change it so it just launches the full runtime instead#2017-12-2116:50thhellerthe issue with watch is that it starts a background thread#2017-12-2116:50thhellerthat background thread does not keep the process itself running#2017-12-2116:50thhellerso it starts, compiles once and then just exits#2017-12-2116:50thhellernot what you want#2017-12-2116:52thhellerwhat are you trying to do exactly that shadow-cljs watch the-build doesn’t do?#2017-12-2116:53Jonjust exploring, never tried it before#2017-12-2116:54Jonif that feels better, maybe I would rely on npm scripts less#2017-12-2116:54thhellerI can make it work easily but it does require you managing threads which is not very fun#2017-12-2116:57thheller
"del": "rm -rf dist/*",
    "release": "shadow-cljs release browser",
    "compile-ssr": "shadow-cljs compile ssr",
    "html": "node target/ssr.js && cp entry/manifest.json dist/",
    "build": "yarn del && yarn release && yarn compile-ssr && yarn html"
#2017-12-2116:57thhellerthese or which npm scripts are we talking about?#2017-12-2116:57Jonnever mind, actually I would use shadow-cljs command line, if launching it from Clojure is not better.#2017-12-2116:57thhellerI’m trying to help you here but I first need to understand what you are doing#2017-12-2116:58thhellerthere are several things I can do … just need to figure out which makes the most sense#2017-12-2116:58Jonthese lines does not include watching part, they are for releasing.#2017-12-2116:58Jon
(ns build.release
  (:require [shadow.cljs.devtools.api :as api]
            [shadow.cljs.devtools.server :as server]
            [clojure.java.shell :refer [sh]]))

(defn -main []
  (println (sh "rm" "-rf" "dist/*"))
  (api/with-runtime (api/release :browser))
  (api/with-runtime (api/compile :ssr))
  (println (sh "node" "target/ssr.js"))
  (println (sh "cp" "entry/manifest.json" "dist/")))
#2017-12-2116:58JonI added this script, and it does run faster than my previous version#2017-12-2116:58thhellerplease stop doing a new ns for everything#2017-12-2116:59thheller(ns app.build) (defn release [] ...) (defn watch [] ...)#2017-12-2116:59Jonwill merge them into one file later...#2017-12-2116:59thhelleryou can invoke functions directly with clj-run, makes things much easier to organize imho#2017-12-2116:59thhellerok so the build.release works with clj-run right?#2017-12-2117:00Jonit's a feature from shadow-cljs, I didn't see clj calls a specific function from CLI#2017-12-2117:00thhellerclj can’t call functions directly, only -main yeah#2017-12-2117:00Jonyes, it works, runs faster.#2017-12-2117:00thhellerif you use clj-run you also don’t need api/with-runtime#2017-12-2117:01thheller
(defn release []
  (println (sh "rm" "-rf" "dist/*"))
  (api/release :browser)
  (api/compile :ssr)
  (println (sh "node" "target/ssr.js"))
  (println (sh "cp" "entry/manifest.json" "dist/")))
#2017-12-2117:02Joncool#2017-12-2117:03thhellerso api/watch starts a background thread. its basically an async function. it returns as soon as the first compile completes#2017-12-2117:03thheller
(defn watch []
  (api/watch :browser)
  (api/repl :browser))
#2017-12-2117:04thhellerthis would work since the api/repl would “block” until you exit the repl#2017-12-2117:04thhellerbut thats annoying since you can’t switch anything#2017-12-2117:05Jonno, there's an error#2017-12-2117:05Jon
Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
	at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:106)
	at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:106)
	at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:30)
#2017-12-2117:05thhelleryeah you can’t do that NOW. I can make it work though#2017-12-2117:05Jonoh...#2017-12-2117:05thhellerthe question I want to answer is how to manage the threads most effectively#2017-12-2117:06JonI think I need to sleep now, too late in here#2017-12-2117:06Jonthanks again#2017-12-2117:06thhellerwhat do you want watch to do that shadow-cljs watch does not do?#2017-12-2117:07thhellerif you are literally just calling api/watch that doesn’t make much sense#2017-12-2117:07JonI was just trying to see if the watch server would launch#2017-12-2117:07thhellerI’ll change the embedded server logic so the Assert failed: (map? http) goes away#2017-12-2117:08Jonor, maybe trying to find out if clj CLI can replace npm scripts#2017-12-2117:08thhellerstill want to figure you what you are trying to do exactly to see if I can make things easier#2017-12-2117:09thhellernpm scripts is kinda annoying since it starts a new process for each command#2017-12-2117:09thhellerwhich CLJ just isn’t built for#2017-12-2117:09Jonwell, if it is, I have to accept#2017-12-2117:10thhellerdon’t give up so easily … this is not rocket science#2017-12-2117:10thhellerI just need to understand what you are trying to do#2017-12-2117:10thhellerI’m still just guessing here#2017-12-2117:10Jonmy daily work is in typescript and react, not much time to spend on here recently#2017-12-2117:11JonI'm just trying to get familiar with them and figure out if things can be easier#2017-12-2117:11Jonfound no direction yet#2017-12-2117:11Jontoo late,, really going to sleep#2017-12-2117:11thhellersleep well, good night.#2017-12-2117:11Jonbye#2017-12-2119:53mhuebertis there an equivalent to lein deps :tree with shadow#2017-12-2119:53mhueberti can’t remember..#2017-12-2119:55mhuebertshadow-cljs pom ; mvn dependency:tree#2017-12-2119:55mhuebertdoes the JVM stuff#2017-12-2120:01thhellernot yet. I want to add it eventually. didn’t even know about the mvn stuff but that seems to work#2017-12-2120:06mhuebertyeah, that could be added to shadow’s docs. someone else just told me about it.#2017-12-2120:07mhuebertis there a place where people like myself can add to docs?#2017-12-2120:08thhellerthe wiki#2017-12-2214:53mhuebertI added a note about a lein deps :tree to a new “FAQ” page, as I wasn’t sure where else to put it: https://github.com/thheller/shadow-cljs/wiki/FAQ#2017-12-2215:35mhuebertI also added the ‘Production Builds’ and FAQ pages to the sidebar, and re-organized it a bit.#2017-12-2215:36mhuebertI’d like to do something to the ‘Home’ page, because it gives the impression of the wiki being empty (unless you know to look at the sidebar)#2017-12-2222:42thhellerFAQ is a good idea, thx#2017-12-2222:43thhellerI want to work on the docs in the next few days as well but all suggestions are welcome#2017-12-2222:43thhellerfeel free to do whatever to the wiki, I really have no idea how to structure it myself#2017-12-2202:03Jonthings are different on this side in ClojureScript. when I was using CoffeeScript, it compiles to JavaScript and everything runs in JavaScript, most of the tools are fast(except for Webpack), we just start processes and kill processes like we did in Unix. That was mentally very easy.#2017-12-2202:05JonI still can't fit into Java world, to found Clojure starts so slowly, and ClojureScript compilation takes so much time. Again I know the author of BuckleScript, who put emphasis on performance in building his compiler.#2017-12-2202:06Jonsince it's reality that compilation takes time, I would eventually accept that fact, and change my scripts to reduce the cost in time.#2017-12-2202:10Jonsince there's cli release with a decent documentation, I would like to take a spin and see if that works in my case: replacing my npm scripts.#2017-12-2202:11Jonclj command takes about 2s to run in my machine, that's acceptable. And it's much better than Boot visually.#2017-12-2202:15Jonshadow-cljs takes long time to start too. It's reasonable to start a compiler with so much time, but not fast enough for scripts.#2017-12-2202:19Jonyou see, quick startup might not be significant for your cases, but it matters when someone does want to get result very quickly, like for beginners when they are learning Clojure or exploring new features. Or even for people like us, writing ClojureScript in the fractional time during job, I need to switch quickly..#2017-12-2202:22Jonplus, I think maintaining my projects with on languages lows the mental barrier. so just trying clj to see if there's any good ideas.#2017-12-2202:46Jonhow much time doe it take to yarn install shadow-cljs on your side?#2017-12-2202:47JonThere is networks issues in China to connect https://registry.yarnpkg.com and it took me nearly 4mins to install. https://gist.githubusercontent.com/chenyong/0101e397a4d2e2b20534abe3947bc0ff/raw/c46db389c3a3052350b9d9b979690ba3877524a1/yarn.log#2017-12-2204:03bolasblackI offen use lumo when I writing simple script XD#2017-12-2208:13thheller@jiyinyiyong so my “solution” to this is just having a server running. just do a comparison. a) time yarn your-scripts b) run yarn shadow-cljs server, in another terminal time yarn your scripts. The difference should be substantial when the server is running since you only pay for startup once.#2017-12-2208:13thhellerserver management itself is a bit annoying at the moment but I’m working on improving that#2017-12-2208:15thhellerso there might be a shadow-cljs start|stop|restart at some point which starts a background server so you could modify your scripts to first call start, then do all the rest, then call stop.#2017-12-2208:15thhelleralternate option is to run do everything using clojure, but I do understand the desire to use npm scripts.#2017-12-2208:18thhellerbesides that I can make shadow-cljs clj-run start as fast as clj, it is slow since it wants to provide easy access to shadow-cljs itself. as soon as you are going to use anything you are going to pay for that startup time again. UNLESS you are using the server instance …#2017-12-2208:18thhellerthe server instance just needs to be easier and all the problems are solved IMHO#2017-12-2208:19thhellerinstalling shadow-cljs takes about 20sec for me with the new AOT enabled, less than 5sec without#2017-12-2209:43Jonsorry but I wrote replies on https://clojureverse.org/t/discuss-intention-on-replacing-my-npm-scripts-with-clj-cli/1241/2#2017-12-2214:58mhuebertI can’t remember… is there a way to specify :compiler-options for :release? I’d like to set :devcards true but only for dev#2017-12-2215:00mhuebertI think I found it: https://github.com/thheller/shadow-cljs/wiki/Production-Builds#release-only-configuration#2017-12-2222:41thhelleryeah, {:dev {:compiler-options {:devcards true}}}#2017-12-2216:21davidstI am getting warnings when running shadow-cljs release app from com.cognitect/transit-cljs#2017-12-2216:21davidstversion 2.0.122 of shadow-cljs and "0.8.243" of transit-cljs (the latest versions currently)#2017-12-2309:50thheller@davidst the warnings are save to ignore for now. unfortunately transit contains some unreachable code for node compatibility which is never used.#2017-12-2318:14tianshushould I add exclusions for all cljsjs when using shadow-cljs?#2017-12-2321:12thheller@doglooksgood not required no, they are all ignored anyways#2017-12-2321:15thhellersee https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#migrating-cljsjs if you are using a library that requires a cljsjs lib#2017-12-2401:35mhuebert@thheller I added a Testing page to the wiki: https://github.com/thheller/shadow-cljs/wiki/Testing I just copied your most recent comment from the relevant issue (https://github.com/thheller/shadow-cljs/issues/57), feel free to update.#2017-12-2411:14mhuebert@thheller Added an item in FAQ about dev/release-specific options: https://github.com/thheller/shadow-cljs/wiki/FAQ#how-do-i-specify-options-only-for-dev-or-release-mode Added a placeholder Externs page, with a link to your latest blog post: https://github.com/thheller/shadow-cljs/wiki/Externs#2017-12-2515:59tianshudoes shadow-cljs support multiple profiles for :source-paths and :dependencies? I want to have a separate build for devcards.#2017-12-2516:02tianshuAha, found it in FAQ!#2017-12-2615:34Jon
``
$ shadow-cljs watch app
shadow-cljs - config: /Users/chen/repo/cumulo/cumulo-workflow/server/shadow-cljs.edn version: 2.0.123
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - starting ...
RuntimeException: java.net.BindException: Address already in use
	io.undertow.Undertow.start (Undertow.java:214)
	shadow.undertow/start (undertow.clj:147)
	shadow.undertow/start (undertow.clj:115)
	shadow.cljs.devtools.server/start-http/fn--21391 (server.clj:109)
	shadow.cljs.devtools.server/start-http (server.clj:108)
	shadow.cljs.devtools.server/start-http (server.clj:104)
	shadow.cljs.devtools.server/start-system (server.clj:137)
	shadow.cljs.devtools.server/start-system (server.clj:118)
	shadow.cljs.devtools.server/start! (server.clj:215)
	shadow.cljs.devtools.server/start! (server.clj:205)
	shadow.cljs.devtools.server/start! (server.clj:208)
	shadow.cljs.devtools.server/start! (server.clj:205)
	shadow.cljs.devtools.server/from-cli (server.clj:312)
	shadow.cljs.devtools.server/from-cli (server.clj:288)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:114)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:101)
	shadow.cljs.devtools.cli/main (cli.clj:162)
	shadow.cljs.devtools.cli/main (cli.clj:117)
	clojure.core/apply (core.clj:661)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/-main (cli.clj:204)
	shadow.cljs.devtools.cli/-main (cli.clj:202)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.main/main-opt (main.clj:317)
	clojure.main/main-opt (main.clj:313)
	clojure.main/main (main.clj:424)
	clojure.main/main (main.clj:387)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.main.main (main.java:37)
Caused by:
BindException: Address already in use
	sun.nio.ch.Net.bind0 (Net.java:-2)
	sun.nio.ch.Net.bind (Net.java:433)
	sun.nio.ch.Net.bind (Net.java:425)
	sun.nio.ch.ServerSocketChannelImpl.bind (ServerSocketChannelImpl.java:223)
	sun.nio.ch.ServerSocketAdaptor.bind (ServerSocketAdaptor.java:74)
	org.xnio.nio.NioXnioWorker.createTcpConnectionServer (NioXnioWorker.java:190)
	org.xnio.XnioWorker.createStreamConnectionServer (XnioWorker.java:243)
	io.undertow.Undertow.start (Undertow.java:173)
	shadow.undertow/start (undertow.clj:147)
	shadow.undertow/start (undertow.clj:115)
	shadow.cljs.devtools.server/start-http/fn--21391 (server.clj:109)
	shadow.cljs.devtools.server/start-http (server.clj:108)
	shadow.cljs.devtools.server/start-http (server.clj:104)
	shadow.cljs.devtools.server/start-system (server.clj:137)
	shadow.cljs.devtools.server/start-system (server.clj:118)
	shadow.cljs.devtools.server/start! (server.clj:215)
#2017-12-2615:35Jonweird.. not able to start two servers anymore.#2017-12-2618:32thheller@jiyinyiyong oh I though I pushed the fix for that already but it is in a branch#2017-12-2618:32thhelleryou specify :http {:port ...} to override the default port#2017-12-2618:32thhellerwill push the fix tommorrow#2017-12-2718:14wilkerlucioI'm trying to experiment with shadow-cljs in a Leiningen project, how can I make the shadow-cljs use resources/public as the public folder instead of public?#2017-12-2718:17thhelleruse for what? it is just the :output-dir?#2017-12-2718:23wilkerlucio@thheller I want to open the browser and see the page, I can't find a way to make the index.html work, because it tries to look into public, which doens't exist#2017-12-2718:24wilkerlucioand I can't change my project structure, other people depend on the current directory structure#2017-12-2718:25wilkerlucioI really just want to see if some problems that I currently have with Figwheel can be fixed by shadow-cljs, like how I have to trigger a rebuild after the first one, otherwise some specs don't work#2017-12-2718:26wilkerluciobut all examples I saw, they all seem to target people starting new projects, would be nice if we have some information on how to use shadow-cljs in a project that is already using figwheel (which is most of cljs projects I believe)#2017-12-2718:28thhellerwhat does your config say?#2017-12-2718:28thhellerit is either :output-dir or :http-root#2017-12-2718:28thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L10#2017-12-2718:28thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L23#2017-12-2718:29thhellerthe spec bug you'll probably see in shadow-cljs as well since its a bug in clojurescript itself that was fixed recently but not released yet#2017-12-2718:33wilkerluciothanks, I think :http-root is what I was looking for 🙂#2017-12-2718:33wilkerlucio@thheller can you send me the link for this jira ticket? I would like to take a read if have it easy#2017-12-2718:36thhellerhttps://github.com/clojure/clojurescript/commit/9a54081d3e0ffab699ee2e58b2adc595918f7c2b#2017-12-2718:37wilkerluciothanks#2017-12-2806:21JonShadow-cljs fails to import PIXI.js with ["pixi.js" :as [Pixi]]#2017-12-2820:24mhuebertnot sure if this is what’s causing your error, but :as should be a plain symbol, rather than a vector of symbols - eg. ["pixi.js" :as Pixi]#2017-12-2820:25mhuebert(`:refer` expects a vector only because you can refer multiple symbols from a namespace)#2017-12-2904:41Jonmy bad, I pasted the wrong code. I was using :as Pixi.#2017-12-2806:21Jon
Uncaught TypeError: Cannot redefine property: default$
    at Function.defineProperty (<anonymous>)
    at index.js:23
    at Array.forEach (<anonymous>)
    at Object.shadow$provide.module$node_modules$pixi_js$lib$core$index (index.js:21)
    at shadow.js.require (VM2328 shadow.js.js:51)
    at Object.shadow$provide.module$node_modules$pixi_js$lib$index (index.js:19)
    at Object.shadow.js.require (VM2328 shadow.js.js:51)
    at phlox.main.js:10
(anonymous) @ index.js:23
shadow$provide.module$node_modules$pixi_js$lib$core$index @ index.js:21
shadow.js.require @ VM2328 shadow.js.js:51
shadow$provide.module$node_modules$pixi_js$lib$index @ index.js:19
shadow.js.require @ VM2328 shadow.js.js:51
(anonymous) @ phlox.main.js:10
#2017-12-2821:15thhellerhmm weird what pixi is doing there#2017-12-2821:15thhellerI define the default$ for cljs compat since cljs munges default to default$#2017-12-2821:16thhellerI can take that out for JS->JS requires though since they won't need that#2017-12-2821:16thhellerwon't get to it until next week though#2017-12-2821:21mhueberthmm, what is it that Pixi is doing that causes this to choke?#2017-12-2821:24thhellerfrom the screenshot it is doing a forEach copying the properties from _math with was required above#2017-12-2821:25thhellerwhich it also did for _const#2017-12-2821:25thhellersince both have a default$ that blows up#2017-12-2821:25thhellerI think at least, didn't look at the actual code#2017-12-2821:28thhellerthe code already skips the default property but it doesn't know about default$#2017-12-2821:50mhuebertlooks like that is caused by babel? in the repo we have:
export * from './math';
then in the published node_modules, that has been compiled to
var _math = require('./math');

Object.keys(_math).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  Object.defineProperty(exports, key, {
    enumerable: true,
    get: function get() {
      return _math[key];
    }
  });
});
#2017-12-2821:53thhelleryeah looks like babel#2017-12-2821:53mjmeintjesIs it possible to specify the host ip for the dev server? I'd like the server to listen on 0.0.0.0 instead of localhost.#2017-12-2821:54thheller@mjmeintjes yes :http {:host "0.0.0.0"} in the top level, same as :builds#2017-12-2821:54thhelleroh wait dev server#2017-12-2821:55thhellerI think I forgot to add the option for those#2017-12-2821:56mjmeintjesYeah, just tried it but it seems to only change the ip for the shadow-cljs server, not the dev server.#2017-12-2821:56thhelleryeah, it defaults to localhost and isn't configurable#2017-12-2821:57mjmeintjesIt would make sense to add a :http-host key under devtools?#2017-12-2821:57thhellerwill fix it to use the main http :host config by default and :http-host in devtools#2017-12-2821:58thhelleryou probably only want to configure it once so it would make sense to configure use the top level :host#2017-12-2821:59mjmeintjesIt is strange, but I used to be able to access the dev server from other machines in a previous version, but since I upgraded it seems to only listen on localhost.#2017-12-2821:59mjmeintjes2.0.105 to 2.0.122#2017-12-2822:00thhelleroh that might be an unintended side effect of switching the http server#2017-12-2822:00thhellerremoved aleph and switched to undertow recently to optimize startup time and get http2 support#2017-12-2822:01mjmeintjesI see. No worries. Do you want any help adding the host option?#2017-12-2822:01thhellerI can take care of it if you don't mind waiting a few days#2017-12-2822:02thhellerpretty busy currently. should be next week.#2017-12-2822:02mjmeintjesNo rush. I'll see if I can figure it out and maybe create a PR.#2017-12-2822:04thhellerI wanted to tune the dev servers anyways, so I can do that as well then https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/dev_http.clj#L125#2017-12-2822:05thhellerI could just switch the default to 0.0.0.0, seems way more reasonable#2017-12-2822:05thhellerdon't really need to restrict it to localhost#2017-12-2822:07mjmeintjesI agree regarding the default, especially since it was that way before. Thanks.#2017-12-2822:08dominicmI was surprised to see undertow as a dependency of shadow, knowing there's a http server built-in makes more sense.#2017-12-2822:16dominicmhttps://github.com/thheller/shadow-cljs/wiki/REPL#embedded-dev-only I'm trying to do this, it seems that shadow/start-worker is not in devtools.api. I tried watch but ran into an issue where runtime/instance-ref was not set, so I figure I'm doing something wrong.#2017-12-2822:17thheller@mjmeintjes I pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9be8f3fafff4ecb6f8f7f1e8dba9b5abb5aaa9af"}, :content ("[email protected]")} which changes the default host back to 0.0.0.0#2017-12-2822:18thheller@dominicm if you are using the embedded version you need to manage the runtime somehow#2017-12-2822:18mjmeintjesGreat! I love the fast release cycles you have. Thank you. #2017-12-2822:18thheller(shadow.cljs.devtools.server/start!) to start and stop!#2017-12-2822:19thhellerstart-worker is just dev the wiki is a bit old#2017-12-2822:19thhellerbut it should still be there#2017-12-2822:20dominicm@thheller start-worker got moved into a different namespace I think. There's a get-or-start-worker in api.clj#2017-12-2822:21thhellerindeed. I renamed that to watch to match the CLI#2017-12-2822:21thhellerthe start! fn will launch the “runtime” which runs in a background thread(s)#2017-12-2822:22thhellerwatch in particular needs that#2017-12-2822:22dominicmhttps://github.com/thheller/shadow-cljs/blob/fafa15c0f0f5bca722853a8a3061f5b3ed81507d/src/main/shadow/cljs/devtools/api.clj#L48-L63 I'll mimic this structure, but where the shutdown is elsewhere.#2017-12-2822:22thhellerthe others start a “light” runtime so they don’t need that#2017-12-2822:23thhellercan’t do with-runtime for watch since it needs to keep running in the background#2017-12-2822:23dominicmYeah, exactly. But I presume it covers all the steps I need to take?#2017-12-2822:24thhellerno with-runtime is not suitable for watch#2017-12-2822:24thhellerstart! is#2017-12-2822:24dominicmI mean, it shows me the functions I need to call in order to do setup, no?#2017-12-2822:24thhellerno, it is a “light” runtime#2017-12-2822:25dominicmI'll read start!, I'm not interested in using the shadow http server in this case.#2017-12-2822:25thhellerwatch needs that to reload files though#2017-12-2822:25dominicmOh, why is that?#2017-12-2822:26thhellerthe clients connect to a websocket for REPL/reloading#2017-12-2822:26thhellerthat server is started by start! not by with-runtime#2017-12-2822:27dominicmIs there a version which starts only the websocket server (or just the core requirements).#2017-12-2822:27thhellerwith-runtime will use the server created by start! though so it won’t launch a new runtime#2017-12-2822:28thhellerif you don’t have any other http servers configured they won’t be started#2017-12-2822:28thhellerbut yes the websocket server is a core requirement#2017-12-2822:37dominicm
Dec 28, 2017 10:36:35 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.6.Final
IllegalArgumentException XNIO001001: No XNIO provider found  org.xnio.Xnio.doGetInstance (Xnio.java:255)
Is this a known, common, mistake?
#2017-12-2822:38dominicmHmm, looks undertow related#2017-12-2822:40thhellernever seen that before, probably a missing dependency#2017-12-2822:41thhellerare you on java8?#2017-12-2822:42thhellerI really don't recommend running shadow-cljs alongside all your other JVM stuff#2017-12-2822:43dominicmI'm on java8, yes.#2017-12-2822:43thhellertoo many headaches dealing with conflicts and such#2017-12-2822:43dominicmI'm thinking it could be an issue with tools.deps.alpha not resolving dependencies correctly.#2017-12-2822:44thhellergoogle says https://stackoverflow.com/a/31117740#2017-12-2822:45thhellerif you have mvn installed you can clj -Spom and mvn dependency:tree#2017-12-2822:45thhellermaybe that has some useful info#2017-12-2822:46dominicm
❯ boot -d thheller/shadow-cljs -B with-cp --write --file /tmp/bootcpfile
Retrieving maven-metadata.xml from  (6k)
Retrieving shadow-cljs-2.0.124.pom from  (7k)
Retrieving xnio-nio-3.3.6.Final.pom from  (6k)
Retrieving shadow-cljs-2.0.124.jar from  (376k)
Retrieving xnio-nio-3.3.6.Final.jar from  (113k)
That's interesting.
#2017-12-2822:48dominicmYeah, the boot classpath file has 2 entries for xnio, and tools.deps.alpha only has one.#2017-12-2822:48thhellertools.deps definitely has some unresolved issues. there was another issue where it picked an ancient version of clojurescript over a more current one#2017-12-2822:51dominicmMight be because the dependency has a scope sigh#2017-12-2822:53thhellerI think boot uses pomegranate which lein and shadow-cljs also use#2017-12-2822:53thhelleror basically all CLJ tools except tools.deps, so yeah there are going to be issues. it is still alpha after all 😉#2017-12-2823:00dominicmyeah, for sure.#2017-12-2823:07dominicmDirect dependency resolved it, opened TDEPS-26 to track#2017-12-2823:13dominicmI've got:
(shadow.server/start! {})
(shadow/watch
{:build-id :hoop/app
                       :target :browser
                       :output-dir "public/hoop/js"
                       :asset-path "/public/hoop/js"
                       :modules {:main {:entries [pro.juxt.hoop.app]}}})
Which is starting a server on 9360, but I can't see the build anywhere, or see any way to access the js, any hints?
#2017-12-2823:14dominicmI see a jar-manifest directory#2017-12-2823:14thhellerhmm?#2017-12-2823:14thhellerit is in "public/hoop/js"?#2017-12-2823:15thhellercan't see the build?#2017-12-2823:15dominicmNot on the filesystem, no. Just used find to check.
#2017-12-2823:15dominicmnothing matching "hoop" or ending with ".js"#2017-12-2823:15dominicm(well, nothing not mine matching hoop!)#2017-12-2823:16thhellerdid it complete?#2017-12-2823:16dominicm
user=> (def stop (pro.juxt.krei.core/watch))
shadow-cljs - server running at 
[:hoop/app] Configuring build.
#'user/stop
This is the only output I see, am I doing something wrong maybe?
#2017-12-2823:17thhellerdo you call stop! immediately watch watch?#2017-12-2823:18dominicmkrei.core/watch returns a function, which calls (shadow.server/stop!). So, no.#2017-12-2823:20thhellercan you try compile* with your config?#2017-12-2823:20thhellerdunno why it would stop printing#2017-12-2823:20thhellerbut no idea what you are doing either#2017-12-2823:20thhellerif you are messing with *out* or anything else the output would go elsewhere#2017-12-2823:21dominicmI'm not touching *out*#2017-12-2823:21thhellerI'd suggest trying without the complicated stuff first#2017-12-2823:21thhellercall start!#2017-12-2823:21thhellercall watch#2017-12-2823:21thhellersee what happens#2017-12-2823:23dominicm
user=> (shadow.cljs.devtools.server/start! {})
shadow-cljs - server running at 
:shadow.cljs.devtools.server/started
(shadow.cljs.devtools.api/compile* {:build-id :hoop/app
                       :target :browser
                       :output-dir "public/hoop/js"
                       :asset-path "/public/hoop/js"
                       :modules {:main {:entries '[pro.juxt.hoop.app]}}} {})
[:hoop/app] Compiling ...
AssertionError Assert failed: (cljs-util/is-file-instance? cache-root)  shadow.cljs.devtools.config/make-cache-dir (config.clj:115)
I guess the exception is lost into the background when it happens during a watch.
#2017-12-2823:24dominicmI'll have to figure out this cache-root stuff later, I'm probably not specifying something I should be.#2017-12-2823:24thhellerhmm that might just be an error since it expects a config file#2017-12-2823:26dominicmMaybe I need to merge in a default config then#2017-12-2823:26thhellerno it does that by default#2017-12-2823:27thhellertoo tired, going to bed. gn8#2017-12-2823:29dominicmI don't see any merge if I explicitly pass an empty map, #2017-12-2823:29dominicmNight #2017-12-2908:07dominicmOkay, passed the default-config, and success!#2017-12-2908:07dominicmI see a build happen.#2017-12-2908:37dominicmCan't seem to get autoload working, hosted from http://localhost:3000. I see my browser connect to http://localhost:9630/ws/worker/app/f02d4ea2-71cd-418f-8f6a-888ea31e9846/c809ecc7-6d24-48d2-848e-89636113d1d0/browser (and the 9630 server is running!). In my console log I see:
DEVTOOLS: connected!
browser.cljs:25:10
DEVTOOLS: disconnected!
browser.cljs:25:10
Immediately after one another.
#2017-12-2908:37dominicmThe rebuild is happening, I can see it at my REPL.#2017-12-2908:40dominicmI have :devtools {:autoload true} in my build config fwiw#2017-12-2909:09dominicmLooks like my lack of logger is causing any log messages to end up in the void, so I'll rectify that first#2017-12-2909:14dominicmuser=> [XNIO-1 I/O-3] WARN - stale websocket client, no worker for build :app there we are. Something to work with!#2017-12-2909:22dominicmLooks like namespaced build ids aren't supported/working.#2017-12-2910:39dominicmI'm struggling with using reagent/rum, I think due to their dependency on cljsjs.react. I'm getting The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs". Is there a config or something I need to use?#2017-12-2911:07thheller@dominicm shadow-cljs uses npm not cljsjs. so you need to npm install react react-dom create-react-class#2017-12-2911:08thhelleroh. I did not expect namespaced keywords. they currently break yes.#2017-12-2911:08dominicm@thheller using npm is mandatory, not optional?#2017-12-2911:09thhellermandatory#2017-12-2911:10thhellerI thought about supporting it optionally but no one asked for that yet#2017-12-2911:10thhellerthe systems don’t mix well so you’d either need to use cljsjs for everything or nothing#2017-12-2911:11thhellernpm for everything works way better and doesn’t rely on re-packaged cljsjs#2017-12-2911:12dominicmsure. Catches for me are: * we already have code using cljsjs * how do you work with supporting libraries that only work with cljsjs?#2017-12-2911:13thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2017-12-2911:13thhellerhas a section about migrating from cljsjs#2017-12-2911:13thhellersince probably all the things in cljsjs come from npm that should always work#2017-12-2911:15dominicmI also have a difficulty for my particular setup now, which is that I need to figure out how to "merge" npm dependencies, I can't rely on the classpath anymore.#2017-12-2911:18thhellerstill not sure how your setup looks so can’t comment much#2017-12-2911:18thhellerbut yeah merging npm is going to be a problem#2017-12-2911:23thhellerI would probably recommend creating a /cljs directory in your monorepo with /cljs/package.json for npm and /cljs/shadow-cljs.edn#2017-12-2911:23thhellerput all your builds configs there#2017-12-2911:24thhellerinclude all source paths and deps#2017-12-2911:24thhellerand then use the :output-dir to ../shop-clientA/public/js or whatever#2017-12-2911:25thhellerone place to manage CLJS builds, one JVM instance for all of them#2017-12-2911:26thhellerI really would not recommend running shadow-cljs in your JVM alongside the JVM stuff#2017-12-2911:26thhellerthat is just going to be annoying and nullifies all optimizations I’m doing for shadow-cljs#2017-12-2911:27thhellerrunning it with other JVM deps is just going to run into all sorts of conflicts#2017-12-2911:27dominicmOh, there's something additional to cljs/clj dependencies conflicting? What is the problem?#2017-12-2911:28thhellerno idea, you already ran into one issue with undertow#2017-12-2911:29thhellershadow-cljs has a bunch of dependencies and I don’t guarantee anything if you override those#2017-12-2911:29thhellereg. in your TDEPS issue you were using undertow 2.0.0.alpha which I don’t use for shadow-cljs#2017-12-2911:30thhellerdunno if that breaks anything since I never tested 2.0#2017-12-2911:30thhellerit might work but it might not#2017-12-2911:31thhellerI will also soon add the ability to add dependencies without restarting#2017-12-2911:31thhellerthat will not work when running the embedded version#2017-12-2911:31thhellerwell it might but I can’t promise that it won’t break anything on the CLJ side#2017-12-2911:32thhellerand you really do not gain anything by running shadow-cljs (or any other CLJS tool) alongside your CLJ stuff#2017-12-2911:33thhelleryou are just asking for trouble IMHO#2017-12-2911:36thhellerI do want to support using shadow-cljs as a library but it is making things a lot harder and you don’t benefit by most of the optimizations I’m doing regarding performance and startup time#2017-12-2911:37thhellerI personally switched to running one lein repl for everything CLJ and one shadow-cljs instance for everything CLJS#2017-12-2911:37thhellerremoved sooooo much pain I had previously#2017-12-2911:39thhellergotta go, bbl#2017-12-2911:53dominicmThe big win that I can see for having it all in one JVM is that most tooling (CIDER, etc.) works better if you do that. There's also less "fiddling", we use datomic, so we literally can do boot launch and everything we need is started. It's a nice experience. We've not had any issues with mixing cljs & clj dependencies in a project in the past. Although, one time I did manage to get cljs running in it's own boot pod, with it's own dependencies, it was a nice hack. The thingis, it didn't solve any problems, so we never used it.#2017-12-2911:56dominicmI think parts of shadow could be moved inside clj-embed or some other isolated runtime, including undertow.#2017-12-2914:40dominicmI was just thinking about how this could be resolved, and it occurs to me that I'm surprised that cljs doesn't allow libraries to have their own npm dependencies. What happens in the case that:
cljsA -> npm-deps [jslib 1.0]
cljsB -> npm-deps [jslib 2.0]
with normal clojurescript? Does cljsA get jslib1.0 and cljsB get jslib 2.0? That would make sense to me in a "node.js world", so I will be surprised if nobody has at least considered this before.
#2017-12-2916:21tianshuI think the om.dom in om is broken with shadow-cljs. but if render with other library(sablono), that works.#2017-12-2920:47thheller@dominicm I don't allow that since I don't want 2 versions of the same lib in the release bundle since size matters in the browser.#2017-12-2920:47thhellerand it is not allowed for the JVM anyways#2017-12-2920:48thheller@doglooksgood what makes you say that? om.dom should work just fine.#2017-12-3010:15tianshuI'm going to create a minimal repo that reproduce this issue.#2018-01-0212:43thheller@jiyinyiyong {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ff8c979e9b9088d29c93958cbfcdd1cfd1cecdc8"}, :content ("[email protected]")} fixes the pixi.js issue from a couple days ago#2018-01-0214:43Jonthanks 😄#2018-01-0411:27Jonhttps://github.com/thheller/shadow-cljs/issues/161#2018-01-0411:28JonIs there anyone else(besides me) wanting such a Wiki page?#2018-01-0411:31pesterhazyyeah I agree, a list of options would be helpful#2018-01-0411:32pesterhazyat least of the ones that are used most frequently#2018-01-0411:34thhellermost of the things are already documented somewhere#2018-01-0411:34thhellereg. https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#2018-01-0411:35thhellerand since shadow-cljs already sets the common compiler options for you#2018-01-0411:35thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#2018-01-0411:36thhellerthese are all the things you’d need to set for a build to take it from dev -> production#2018-01-0411:37thhellerWe can certainly start a dedicated page that lists all of them#2018-01-0419:26jgdavey@theller Good news. The most recent versions of shadow-cljs seem to have fixed the string-quoting issue in emacs/cider. The fix happened between 2.0.118 and 2.0.128. I think it may have been the switch to undertow.#2018-01-0419:59thhellerundertow is not involved in nrepl at all so that can't be it#2018-01-0420:23jgdaveyHmm, interesting. Not even for the websocket?#2018-01-0420:30thhellerthat part is but that is http and undertow doesn't do anything different there#2018-01-0420:31thhellerI did however change a bit in the nrepl protocol#2018-01-0420:31thhellerso that may have fixed it accidentally?#2018-01-0420:33jgdaveyI think so!#2018-01-0420:33jgdaveyEven if accidental, I appreciate it! Cheers!#2018-01-0514:24jgdavey@thheller Is there any way to skip aot (or defer it) during npm install? Having an issue deploying to Heroku since that change.#2018-01-0516:44thheller@jgdavey not that I know of but I’m probably going to disable it anyways#2018-01-0516:46thhellerpublished {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9eedf6fffaf1e9b3fdf2f4eddeacb0aeb0afaca7"}, :content ("[email protected]")} which doesn’t do the AOT on install#2018-01-0516:47jgdaveyOkay, thanks!#2018-01-0713:32qing97hello! I am a noob.Now I have some questions. When I run watch ,and I did some changes in the code,I need refresh the page to see changes.How it can auto refresh?#2018-01-0713:52thhelleryou need to set :after-load some.ns/reload#2018-01-0713:52thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L18-L21#2018-01-0713:53thhelleror if you don’t want a callback you can just set :autoload true#2018-01-0714:54qing97thanks a lot!#2018-01-0809:22Alex HHey @thheller - as mentioned in #clojurescript, I see the following issue when trying to use shadow-cljs (clojure 1.9.0, clojurescript 1.9.946 and core.async 0.3.443):#2018-01-0809:23Alex HOnly started using shadow-cljs yesterday and clojurescript a week ago, so bear with me!#2018-01-0809:23thhellerhello!#2018-01-0809:23thhellerdo you have the rest of the error available?#2018-01-0809:24thhellerthe actual message is missing#2018-01-0809:24Alex H[:app] Build failure: ------ ERROR ------------------------------------------------------------------- File: jar:file:/home/alex/.m2/repository/thheller/shadow-cljs/2.0.128/shadow-cljs-2.0.128.jar!/shadow/cljs/devtools/client/hud.cljs:1:1 -------------------------------------------------------------------------------- 1 | (ns shadow.cljs.devtools.client.hud -------^------------------------------------------------------------------------ Invalid :refer, var cljs.core.async/go does not exist -------------------------------------------------------------------------------- 2 | (:require [shadow.dom :as dom] 3 | [shadow.xhr :as xhr] 4 | [shadow.cljs.devtools.client.env :as env] 5 | [shadow.cljs.devtools.client.browser :as browser] --------------------------------------------------------------------------------#2018-01-0809:24Alex Hthat's all I get#2018-01-0809:24thhellerok, that looks like you are using an older version of core.async#2018-01-0809:25Alex HI'm using 0.3.443; I'll try 0.3.465 then#2018-01-0809:26thhelleryeah the latest version is required#2018-01-0809:27Alex Hok, that worked a treat - thanks!#2018-01-0809:27Alex Hso far I'm mightily impressed with shadowcljs; it got rid of all my funky issues that I was having with lein-figwheel when loading (many) npm modules#2018-01-0809:28Alex Hsince the closure compiler's module resolution doesn't support wildcard import/export and a few other things that npm modules do sometimes#2018-01-0809:29thhelleryeah, the closure compiler is not very reliable yet.#2018-01-0809:29Alex Hwhilst on it, though, I have one more question; in lein-figwheel, I used to have a :external-config {:devtools/config {:features-to-install [:formatters :hints]}} to configure binaryage/devtools#2018-01-0809:29Alex His there a way of doing that in the shadow-cljs.edn?#2018-01-0809:30thhellerI think you can stick that in :compiler-options, so :compiler-options {:external-config {:devtools/config {:features-to-install [:formatters :hints]}}}#2018-01-0809:30thhellermaybe without the extra :external-config, not sure if that is a figwheel thing#2018-01-0809:30thheller(nested in your build config)#2018-01-0809:33Alex HI'll give that a try later, thanks#2018-01-0814:54hlolliI see that shadow-cljs's manifest.edn is very similar to manifest.json for a chrome plugin I'm about to start to develop. I wonder if there's any trick for shadow to output manifest.json or rewrite the manifest.json on changes. I see myself manually adding js path to new files as I add namespaces and libraries. But this just gave me the idea that this should be possible.#2018-01-0814:55hlolli(given that this is not a problem with optimized compilations as they output 1 file, but at cost of long time)#2018-01-0815:00thheller@hlolli you can specify :manifest-name "manifest.json". the output format is chosen by file ext, just defaults to manifest.edn#2018-01-0815:01thhellerbut that manifest is not really intended to be used by chrome or anything#2018-01-0815:02thhellerits just some information about your modules in case you want to use :module-hash-names and need to get the actual filenames (since they are hashed)#2018-01-0815:03thhellerI could add a hook to let you write your own manifest based on the build info#2018-01-0815:03hlollihmm nice, easy thing to add some json manipulation in the pipeline. Or that, hook..#2018-01-0815:06thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L276-L314#2018-01-0815:06thhellerthats the code that generates the manifest. should be easy to extend/modify based on your needs#2018-01-0815:07hlolliok ok, my brain is uncaffinated and slow. Yes I'll check it out. Should manifest-name be located top-level in shadow-cljs.edn?#2018-01-0815:08thhellerin the build as {:build-options {:manifest-name "foo.json"}}#2018-01-0815:10hlollinice thanks, I will look at the flush-manifest function. It would be nice to write all the plugin configuration in edn and generate it.#2018-01-0815:10thhellernot sure how much config you need but should be easy yes.#2018-01-0815:11thhellergotta grab some food, bbl#2018-01-0815:11hlollicool, coffe here, Mahlzeit!#2018-01-0909:39thheller@hlolli so I thought about it a bit yesterday. the purpose of the :target abstraction is to capture as much as possible about the “final” product so it requires almost no post processing. In your case there should be a :target :chrome-extension where the config itself contains everything required to generate all the support files the chrome extensions want.#2018-01-0909:39thheller:browser sort of fits but not exactly since you’ll never serve things from a webserver and such#2018-01-0909:39thhellerso some assumptions that makes are simply incorrect#2018-01-0909:40thhellerI only did a very basic chrome extension once to test but forgot just about everything#2018-01-0909:40thhellershouldn’t be too hard to write a :target :chrome-extension though#2018-01-0909:41thhellermaybe it could even just look at the manifest.json itself and figure out what if needs to do from there#2018-01-0909:42thhellerI have some time later today, maybe I can take a look at this#2018-01-0909:43thhelleryou could try writing it yourself but the docs are non-existent for that part so its going to be painful 😉#2018-01-0910:12hlolliThe only required file so far I've seen is https://developer.chrome.com/apps/manifest manifest.json, the :background :scripts would be needed to be automatically filled, but that can also be html file, doubt cljs users will prefer a html file, think we can ignore that option. There are some local storage file schemas :storage :storage-schema, not sure how to best include that into cljs config, but they are just json files. I can also be forgetting something, this is the first time I'm doing extension myself. But starting with the manifest I believe half the battle will be won.#2018-01-0910:37hlolliI'm gonna give shadow-cljs/src/main/shadow/build/targets/chrome_extension.clj a try. I will ask here if I bump into problems.#2018-01-0910:39thhelleryou can put it anywhere#2018-01-0910:39thheller:target some.ns/process is supported#2018-01-0914:00hlolli@thheller I wonder if it would make sense to add :escape-unicode false here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L308 was useing icelandic chars for manifest metadata and they all got \u00xxx#2018-01-0914:14thhellernot sure? should be ok I guess?#2018-01-0914:53hlolliok, I'll create a PR tonight, another question, is it possible to access :module-hash-names from the state passed into this function. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L277 (I'm not useing this namespace or file directly, but creating code deriving from it).#2018-01-0914:54thheller:module-hash-names works by modifying :output-name for the module, so others don’t need to be concerned with it#2018-01-0914:55thheller:output-name defaults to :module-id+`.js`, :module-hash-names turns it into <module-id>.<hash>.js#2018-01-0914:56thhellernot sure what you mean by accessing it?#2018-01-0914:56hlolliok so I misunderstood you yesterday 🙂 the data I'm looking for is basically cljs-runtime/*.js#2018-01-0914:56hlolliand the :output#2018-01-0914:57thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L406#2018-01-0914:57thhellerthe cljs-runtime files are written in that fn call#2018-01-0914:58thhelleror rather in the flush-sources call, see https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L178-L209#2018-01-0914:59hlolliok nice! so :source-ids is what I'm looking for#2018-01-0914:59thheller:build-sources#2018-01-0914:59thhelleror when using :modules the :sources of each module#2018-01-0914:59thheller:build-sources is all sources from a build#2018-01-0915:00hlolliah yes, these maps with depends-on and bunch of metadata. Ok understand, thanks!#2018-01-0915:02thhellerunfortunately the state is too large to print so there is no easy way to inspect it#2018-01-0915:02hlollior
[[:shadow.build.classpath/resource "goog/base.js"] [:shadow.build.classpath/resource "goog/debug/error.js"] [:shadow.build.classpath/resource "goog/dom/nodetype.js"] [:shadow.build.classpath/resource "goog/string/string.js"] [:shadow.build.classpath/resource "goog/asserts/asserts.js"] 
...elided
slashes to dots = real filename.
#2018-01-0915:02thhellerthose are the “source ids”#2018-01-0915:03thhellereach id you can use to (data/get-source-by-id state source-id)#2018-01-0915:03thhellerthat map then contains all the source info for that particular source id#2018-01-0915:03thheller:resource-name is the relative filename on the classpath#2018-01-0915:04thheller:url contains the source location#2018-01-0915:04thheller:file may also be present but only for actual file, not files from libs in .jars#2018-01-0915:05thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L188-L192#2018-01-0915:05thhellerthe data/get-output! fn returns the generated code for that resource#2018-01-0915:07hlollicompletly unrelated to chrome-extensions, there's nothing here in your setup preventing the possibility to provide cljs-compiler as gulp plugin spitting out unoptimized cljs code. Just an idea for later project.#2018-01-0915:08thhelleryeah how output is written is completely customizable#2018-01-0915:08thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L70-L92#2018-01-0915:09thhellerthis creates one singular big file since karma had issues loading files the “closure-way” when I tried it#2018-01-0915:10hlolliyes, one big file is sadly what many modern js tooling relies on. Especially painful adding some cljs code mixed with typescript when one needs to wait a minute for clojurescript to spit 1 file in development.#2018-01-0915:11thhelleryou can run shadow-cljs server which avoids spinning up a new JVM for everything#2018-01-0915:12thhellerwhich makes everything else “fast”#2018-01-0915:12thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#optimization#2018-01-0915:13thhellerwhen that is running we pretty much have better performance than typescript or others would have#2018-01-0915:14thhellerwould be pretty easy to add on demand compilation of singular files if you don’t need a full “build”#2018-01-0915:14thheller“build” always involves packaging things together and such#2018-01-0915:14hlollinice, I'm all for wirting js in one language. But there are many projects mixing babel, typescript and coffeescript in one. If cljs could be one of those with minimal tooling, it would be nice. In this case, start the server once and hide that from the user.#2018-01-0915:15thhellershadow-cljs start runs the server in the background#2018-01-0915:15hlolliyup, child_process.spawn() ideal I'd guess, just theorizing.#2018-01-0915:15thhellerbut yeah most JS tooling is built assuming that you launch a new process for everything#2018-01-0915:15thhellerthats just not going to happen for CLJS#2018-01-0915:16thhellerif you want JS interop :npm-module may already solve that#2018-01-0915:16thhellerhttps://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-JS-Devs#2018-01-0915:17thhellercompiles CLJS in a way so any other JS tools can consume it (eg. webpack, node)#2018-01-0915:17hlolliok, wow#2018-01-0915:18thhellermade a teaser vid a while ago for create-react-app https://www.youtube.com/watch?v=BLDX5Twt2zk#2018-01-0915:20hlolliI feel weird not knowing about this for so long 😄#2018-01-0915:22thhellerwell for the first 3 years I basically never talked about shadow-cljs at all so that is probably my fault 😉#2018-01-0915:22thhellerbeen trying to blog more but I prefer writing code so I never get anywhere blog-wise 😉#2018-01-0915:25hlolligood seacret, while others struggle 🙂#2018-01-0915:34thhellerfigwheel is pretty deeply embedded in pretty much every template/tutorial these days#2018-01-0915:35thhellernot that easy to convince people to try something that does things differently#2018-01-0915:35thhellerbut again I blame only me and the lack of documention/articles#2018-01-0915:41hlolliyes, shadow-cljs is maybe a no-brainer to use for mixing cljs in js project, node platforms, browser plugins and probably Im forgetting a lot. Moveing divs with hot-reload, it wouldn't bother me useing relieable, compiler. After few years for figwheel, 99% of the errors I find like touching any part of my body blindfolded. Doesn't give me as much as it did in the past.#2018-01-0915:41thhellerwell these days shadow-cljs pretty much does everything that figwheel does, just differently 😉#2018-01-0915:42hlolliok! How is the story with editors like emacs?#2018-01-0915:43thhelleremacs just works with cider, some people here use it#2018-01-0915:44thhellerhttps://github.com/thheller/shadow-cljs/wiki/Cider#2018-01-0915:46hlolliah java is of course behind it#2018-01-0915:46hlollinice#2018-01-0915:48hlollimy last question, you see shadow-cljs and tools.deps (no lein or boot) a good combination, or would tools.deps be redundant?#2018-01-0915:49thhellerI will soon add support for tools.deps, similar to the current lein support#2018-01-0915:49thhellerthat is that you will be able to manage your dependencies via deps.edn#2018-01-0915:50thhelleryou can use tools.deps today but lose all the optimizations the shadow-cljs script does#2018-01-0915:51hlolliyes would be nice, to be able to provide library that can be used by lein+boot and potentially lumo and planck. If there's a standardize deps format.#2018-01-0915:51thhellerclj -m shadow.cljs.devtools.cli compile foo is equal to shadow-cljs compile foo#2018-01-0915:51hlollibut thats of course possible with maven .jar metadata#2018-01-0915:52thhellerI’m not totally sold on tools.deps for CLJS yet#2018-01-0915:52thhellerit is optimized for clojure after all and some things in CLJS are just different especially when integrating with npm and such#2018-01-0915:53thhellermight be better to start with a cljs-deps.edn than trying to integrate into deps.edn#2018-01-1017:14mhuebertFWIW I’m really looking forward to being able to use git deps: https://clojure.org/news/2018/01/05/git-deps#2018-01-0915:54thhellerstandardized deps format is definitely good but tools.deps assumes a classpath which is a JVM thing#2018-01-0915:54thhellernpm doesn’t have a classpath#2018-01-0915:54hlolliWell then you have package.json as well, seems to be unavoidable to have two project files. Or integrade tools.deps into package.json. That's a different headace.#2018-01-0915:54thhellerindeed#2018-01-0915:54hlollitools.deps gives me in lumo a nice way to resolve classpath for deps quickly and easily, nothing more so far.#2018-01-0915:56thhelleryeah, I have written my own thing for that https://github.com/shadow-cljs/shadow-cljs-deps#2018-01-0915:56thhellerif tools.deps had existed when I started I would have used that instead#2018-01-0915:57thhellerwell written my own is an overstatement. I re-used what lein and boot use 😉#2018-01-0915:58thhelleryou can run shadow-cljs node-repl if you need a quick REPL aware of your classpath, might not need lumo 😉#2018-01-0915:58thhellerbut lumo is better if you want “scripts”#2018-01-0916:00hlolliyes and portability. It's somewhat behind on dev tooling.#2018-01-0916:11thhellerwell you can always use :target :node-script to build the “scripts” and run them directly. lumo just lets you skip the build step which is nice.#2018-01-0916:15hlolliskips it completly yes if useing only bundled dependencies or native node functions.#2018-01-0916:18thhellerwell you can always publish :node-script to npm (with a package.json to declare deps)#2018-01-0916:19thhellerbut yeah for general scripting lumo wins#2018-01-0917:41koz@thheller I pinged you several weeks ago regarding transitive NPM dependencies not working correctly when trying to import a JAR dependency built with shadow-cljs. You mentioned that you were aware of the issue but didn’t have the bandwidth to address it. Is this still on your radar? Happy to help in any way to get this implemented.#2018-01-0920:23thheller@koz was that before :npm-deps? not sure I remember the issue#2018-01-0920:28kozWe did some work to port our front-end projects over to shadow-cljs, and while the NPM modules within that project worked great, we found that when we consumed those projects from another shadow-built project, the NPM modules coming from the dependent project couldn’t be resolved.#2018-01-0920:29kozHaha it’s a bit hard to describe - let me know if that doesn’t make sense and I’ll try to provide more of a visual illustration of the problem.#2018-01-0920:29thhellerdo you have the :npm-deps declared in a deps.cljs?#2018-01-0920:32kozYes, we did use :npm-deps inside a deps.cljs file inside of the dependent project#2018-01-0920:33kozIf it helps, we can try to put together a minimal test case#2018-01-0920:33thhelleryou declared them but they dont get installed?#2018-01-0920:35kozThey get installed in that project, but not in any projects that depend on that project#2018-01-0920:36thhelleris there any public cljs lib that declares :npm-deps? I don't know of any#2018-01-0920:36thhellerI'm pretty sure I tested this and it should work#2018-01-0920:38kozI’m not sure of any either - it’s possible that it works since we last tried it. We can try to set up a test case and put it up on a public repo if that helps.#2018-01-0920:43thhellerit helps to have a some lib available to test this with yes#2018-01-0920:44kozCool. I’ll put something together with the latest shadow-cljs version and will share with you once it is complete. Thanks!#2018-01-0920:50Alex HHm, I was just trying to use a stage-3 ES feature, but I don't think shadow-cljs is happy about it#2018-01-0920:50Alex His there any way to influence which babel plugins are used?#2018-01-0920:52thhellerbabel is only used for npm stuff, ie. node_modules/*#2018-01-0920:52thhellerwhat’s the issue? which feature?#2018-01-0920:52Alex Hobject spread#2018-01-0920:52Alex H{...foo, etc, etc}#2018-01-0920:53Alex Hso babel isn't used for relative JS imports?#2018-01-0920:53Alex Hsurely it is#2018-01-0920:53Alex H:require ["../../js/foo.js" :as foo] sort of thing#2018-01-0920:53thhellerno, stuff from the project itself runs through the closure compiler to get :advanced DCE#2018-01-0920:53Alex Hoh, ok.#2018-01-0920:54thhellerdo you have a full snippet of code I can try?#2018-01-0920:54Alex Hit's really just a dumb trial:#2018-01-0920:54Alex Hfunction assoc(obj, key, value) { return {...obj}//...obj, [key]: value} } export { assoc }#2018-01-0920:54Alex Hand then the aforementioned :require in a cljs file#2018-01-0920:56thhellerthat doesn’t look like valid code#2018-01-0920:56Alex Hwell, it is valid stage3 code#2018-01-0920:57Alex Hhttps://babeljs.io/repl/#?babili=false&amp;browsers=&amp;build=&amp;builtIns=false&amp;code_lz=GYVwdgxgLglg9mABAQwM6rhAFHARgKwBpEBrAUwE9iA3ZAGxDIEpEBvAKEUQCcyoRuSVgDpReIogDa5CgF0AXIloMyAX3br2ZAB4AHONyhsU6TIlVA&amp;debug=false&amp;circleciRepo=&amp;evaluate=false&amp;fileSize=false&amp;lineWrap=true&amp;presets=es2015%2Creact%2Cstage-2&amp;prettier=false&amp;targets=&amp;version=6.26.0#2018-01-0920:58Alex Has far as closure compiler is concerned, this is relevant: https://github.com/google/closure-compiler/issues/2303#2018-01-0920:58Alex Hso not yet supported, but maybe being worked on#2018-01-0920:59Alex Hanyway, my question, I guess, is whether it's possible to transpile things (slightly) with babel before feeding into closure compiler#2018-01-0920:59Alex H(as in, out of the box with shadow-cljs, not talking manually here)#2018-01-0921:00thhellerI can add an option to disable the use of the closure compiler and just use babel#2018-01-0921:00thhellerusing both is probably not a good idea#2018-01-0921:01thhellerbabel generates a bunch of code the GCC doesn’t like#2018-01-0921:01Alex HI was thinking doing the bare minimum in babel of transpiling to es2016 standard (even keeping the es2015 modules, etc), and then feeding that into closure compiler, so you still get DCE, etc#2018-01-0921:01Alex Hok, fair.#2018-01-0921:01thhellerwell if the closure compiler supports it we should be fine#2018-01-0921:02thhellerlooks like the commit made it in, unfortunately we can’t yet use the latest release of the closure compiler since CLJS breaks with it 😞#2018-01-0921:08Alex Hwell, other than that the interop with non-npm JS files seems to work a treat, thanks for that#2018-01-0921:09Alex Hand if you are ever bored, having an option to feed non-npm JS files through babel (instead of closure compiler?) would be a nice addition to shadow-cljs (but certainly not a must-have)#2018-01-0921:09Alex H😛#2018-01-0921:10thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/resolve.clj#L94#2018-01-0921:11thhellerthat is the only line that decided whether babel or gcc is used#2018-01-0921:11thhellerso easy to add#2018-01-0921:11thhellerah doh no, not that easy#2018-01-0921:11thhellerthe closure compiler needs to be able to parse the source file#2018-01-0921:12thhellerto extract the require/import/exports even if we pass it through babel after#2018-01-0921:12thhellerbut that fails since it doesn’t recognize the code#2018-01-0921:12Alex Hhow/why does that work with node_modules then, when they aren't closure-compiler compatible?#2018-01-0921:12thhellerbut I have a sketch for passing code through babel FIRST#2018-01-0921:13thhellerI only parse the JS first to look at the AST for require/import#2018-01-0921:13thhellerso as long as its valid JS we are good#2018-01-0921:14thhellerI need to add a pre-process anyways to get support for typescript, coffescript, JSX, etc#2018-01-0921:16Alex Hwell, it'd certainly be a nice feature#2018-01-0921:16Alex Hanyway, thanks again!
#2018-01-0921:43hlolliis it possible to rename the default output filename main.js, adding :output and :output-to in build options didnt made a difference.#2018-01-0921:43hlollinot that I actually want to rename it, just want to get that name programatically, in the end.#2018-01-0921:47thhellerthe module-id is the name so module :main is called main.js#2018-01-0921:47thhellerprogrammatically you get the name via :output-name#2018-01-0922:34koz@thheller Sorry for the confusion before - just updated everything and it seems to work perfectly - thanks for all of your help!#2018-01-0922:34kozAmazing job on this project.#2018-01-0923:05hlolliSo I believe I've succeeded with this, this can be polished (spec the manifest stuff) but everything put into :chrome-extension will be exported into manifest.json, only thing is to add: :target clj.chrome-extension/process (clj is just whatever source directory is on cp) https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998#2018-01-0923:23thhellerruntime-bundled? (or (nil? optimizations) (= :none optimizations) (= :simple optimizations))#2018-01-0923:23thheller:shadow.build/mode in the state is either :dev or :release#2018-01-0923:24thhelleris it safe to pass many scripts into “background”? though that was supposed to be one#2018-01-0923:27thhelleryou can probably shorten this by just “inheriting” from the browser target#2018-01-0923:27thheller
ns clj.chrome-extension
  (:refer-clojure :exclude (flush require))
  (:require [shadow.build :as build]
            [shadow.build.api :as build-api]
            [ :as io]
            [clojure.set :as set]
            [clojure.data.json :as json]
            [shadow.build.data :as data]
            [shadow.build.output :as output]
            [shadow.build.targets.shared :as shared]
            [shadow.build.classpath :as cp]
            [shadow.build.modules :as modules]
            [shadow.cljs.repl :as repl]
            [shadow.build.targets.browser :as browser]))

(defn flush-crx-manifest [{:keys [build-options chrome-extension stage mode] :as state}
                          {:keys [chrome-extension optimizations] :as config}]
  (let [runtime-bundled? (or (nil? optimizations) (= :none optimizations) (= :simple optimizations))
        chrome-extension (:chrome-extension config)
        cljs-runtime-path (:cljs-runtime-path build-options)
        js-main (-> state ::modules/modules :main :output-name)
        js-filelist (mapv #(->> (data/get-source-by-id state %)
                                :output-name
                                (io/file cljs-runtime-path)
                                .getPath)
                      (:build-sources state))
        data (merge {:manifest_version (or (:manifest_version chrome-extension) 2)
                     :name (or (:name chrome-extension) "unnamed-shadow-cljs-extension")
                     :version (or (:version chrome-extension) "1.0.0")
                     :background {:scripts (if runtime-bundled?
                                             (into [js-main] js-filelist)
                                             [js-main])}}
               chrome-extension)
        manifest-name "manifest.json"
        manifest-file (data/output-file state manifest-name)
        manifest (with-out-str
                   (json/pprint data :escape-slash false :escape-unicode false))]
    (spit manifest-file manifest))
  state)

(defn process
  [{::build/keys [stage mode config] :as state}]
  (-> state
      (browser/process state)
      (cond->
        (= stage :flush)
        (flush-crx-manifest config))))
#2018-01-1004:11cmalHi, I am trying to add d3 as a deps in a shadow-cljs project. I've found that in shadow-cljs demo/browser.cljs, it uses (:require ["d3" :as d3]) to include d3 but the "d3" in shadow-cljs.edn was commented out. I am wondering how the d3 in demo/browser.cljs can work. Should I add d3 in the package.json and (:require ["d3" :as d3]) to make d3 work in my project?#2018-01-1005:12cmalI add d3 to package.json and (:require ["d3" :as d3]), it works!#2018-01-1006:39Alex H@thheller I'm guessing you are aware, but I've just seen that clojurescript's :foreign-libs thing does seem to have support for the kind of preprocess step we were talking about yesterday: https://clojurescript.org/guides/javascript-modules#babel-transforms. I don't think that changes anything w.r.t. shadow-cljs, but might offer some inspiration#2018-01-1008:29thheller@alex340 yes I’m aware. I suggested the :preprocess a.qualified/symbol syntax. so far I have gotten away without any configuration for this and babel in theory could automatically be applied if there was a .babelrc present#2018-01-1008:33thheller@cmal you might want to consider using the separate d3-* packages instead of the d3 meta package. eg. (:require ["d3-color" :as d3-color]) instead of accessing the d3.color property. avoids always importing everything.#2018-01-1008:51cmalOK. Thank you @thheller#2018-01-1008:55cmal@thheller Does the "d3-color" here means I should add a d3-color to my package.json in the same directory of shadow-cljs.edn?#2018-01-1008:55thhellerif you add just d3 they will all be there already#2018-01-1008:55thhellerbut you can also skip the d3 install there and just install what you need in package.json#2018-01-1008:56cmalThanks!#2018-01-1010:10hlolli@thheller :shadow.build/mode showed to me :dev despite useing whitespace optimization. As for background scripts, it takes an array so I see it as one way to serve the depending js files, maybe there's another way to do it, but for example adblockplus uses 7 js files in background scripts. If it's only for development then it's probably ok, the user needs to http regex match if they want it to run on all or only specific addresses.#2018-01-1010:11thheller:optimizations only apply for shadow-cljs release. they are ignored otherwise.#2018-01-1010:12hlolliok, so my test is really, is this a single file output compilation or does the cljs-runtime dir get bundled too.#2018-01-1010:12thhellerit could just always emit a single file#2018-01-1010:12hlollihmm like the karma example?#2018-01-1010:13thhelleryeah#2018-01-1010:13thhellerI don’t know if background scripts are allowed to importScripts or something to load other files#2018-01-1010:14thhellerwhy did you mess with :module-hash-names in the example? that doesn’t seem useful for chrome exts? the hash names are meant to that you can http cache the files forever since new versions will have different names#2018-01-1010:14thhellerdidn’t have time to look into the chrome exts stuff yet so I don’t know any details#2018-01-1010:15thhellerdoes the REPL/hot reload work? is the ext allowed to connect to localhost?#2018-01-1010:15hlollihmm, that was not willingly 🙂#2018-01-1010:16hlolligood question, I never found documentation so far that it's part of js dev practices. Reloading an extension is either a button or you can dowload an extension to reload all extensions.#2018-01-1010:16thhellerif the extension is allowed to connect to the websocket the CLJS hot reload should just work#2018-01-1010:17thhellerbut not sure the security model allows that#2018-01-1010:17hlolliok, so I will give it a try#2018-01-1010:18thhellerfor now you can re-use the “generate single file” from the karma stuff#2018-01-1010:18thhellermight move that into the output ns at some point#2018-01-1010:18thhellerI had a :compact mode at some point which did basically that#2018-01-1010:19thhellersingle file wasn’t great for http development but might be perfect for chrome exts#2018-01-1010:19hlollithat could be!#2018-01-1010:36hlolli@thheller https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998#file-chrome_extension-clj-L63-L64 isn't this how :module-hash-names should be, don't think you copied all the code above 🙂 ?#2018-01-1010:36thhellerwhy do you want hash names?#2018-01-1010:37hlolliah you ment the oppisite, not useful haha ok#2018-01-1010:37thhellerit is an optimization for HTTP. you are not serving over http and thus not useful#2018-01-1010:37hlolliah ok, I thought it was for hasheing for recompilation.#2018-01-1010:37thhellernah that is solved elsewhere#2018-01-1010:38hlolliis inject-loader-setup-release useful?#2018-01-1010:39thhellerno#2018-01-1010:40hlolliok, I see that for flush, like your point was above, to only flush the crx-manifest#2018-01-1010:41hlollisignal I need to make coffee #2018-01-1010:53thhellerI’m not sold on actually generating the chrome manifest via the build#2018-01-1010:53thhelleryou can write it by hand and if you only generate one file you don’t need to modify the manifest at all#2018-01-1010:54hlolli@thheller yes that's right, the only reason I wanted to generate it was because I didn't want to type in all the files. If it's one file, then there's no reason to generate it.#2018-01-1010:55thhelleryeah#2018-01-1010:56hlollidon't I lose some optimization of haveing it in one file, say I only change one namespace, then all the data is compiled?#2018-01-1010:57thhellerso from the build perspective the flush is the last step#2018-01-1010:57thhellerit does not affect compilation#2018-01-1010:57thhellerso all caching and stuff remains the same#2018-01-1010:57hlolliah I see, nice#2018-01-1010:57thhellerflush only takes the compiled resources and writes it to disk in whatever format#2018-01-1010:57thhellerif you write 100 files or one doesn’t matter (much)#2018-01-1010:58thhellerflush also always happens by default for safety#2018-01-1010:59thhellerso even if nothing was recompiled the flush may still happen#2018-01-1010:59thhellerby default there are some checks in place to avoid some IO but technically you could just always write#2018-01-1011:00hlolliok, this sounds very boot-ish#2018-01-1011:00hlollilaunch!#2018-01-1011:16evekoHow would one setup the on reload function for a reagent app?#2018-01-1011:22thhellerdo you mean the reagent side of things or the shadow-cljs config for that?#2018-01-1011:24evekoI can get the on-reload function that i designated to fire#2018-01-1011:25evekobut just calling my applications start function is returning an error#2018-01-1011:25evekoso in the end I have to reload browser to see changes#2018-01-1011:27thhellerwhat kind of error?#2018-01-1011:28thhellerusually you should just need to render again#2018-01-1011:28thhelleryou can also use the :before-load to unmount and then mount :after-load#2018-01-1011:29thhellerI pretty much always follow this pattern https://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2018-01-1011:29thhellerinit once, then repeated start -> stop -> start -> ... for each hot reload#2018-01-1011:50evekothese are my two functions#2018-01-1011:51evekowhen reload gets callled#2018-01-1011:52evekoon the console in browser I get error rendering component#2018-01-1011:53thhellerlooks ok to me. what is the error?#2018-01-1011:55evekoError: No method in multimethod 'dashboard.routing/current-page' for dispatch value:#2018-01-1011:56evekoand if I just call begin on :after-load#2018-01-1011:56evekoi get#2018-01-1011:56evekoError: Target container is not a DOM element.#2018-01-1011:57thhellertry logging the value of (js/document.getElementById "app")#2018-01-1011:58thhellerseems like that gets removed from the page somewhere#2018-01-1011:59thhellerFWIW (defonce app-container (js/document.getElementById "app")) and then (r/render [..] app-container) is probably the safer thing to do#2018-01-1012:06evekonow I always get Error: Target container is not a DOM element.#2018-01-1012:15thhellerand what is (js/document.getElementById "app")?#2018-01-1012:15thhellerI assume you have a <div id="app"> in your html?#2018-01-1012:24evekoyeah it is in there#2018-01-1012:24evekoI got rid of the errors#2018-01-1012:24evekobut now I just reloads and the page stays blank#2018-01-1012:25evekobut I think I know what the issue is#2018-01-1012:25evekoI get the html from a server response#2018-01-1012:25evekonot by serving the static file#2018-01-1012:26evekoso when I call the reload there is just nothing 😕#2018-01-1012:33evekono statically serving the file did not help either. Now I get no error but the page is blank...#2018-01-1012:34thhellerI’m confused.#2018-01-1012:35evekoas am I#2018-01-1012:36evekoIt renders fine if reload the page manually#2018-01-1012:36evekobut the after load function just removes everything.#2018-01-1012:38thhellerso something is clearing your DOM,it is definitely not shadow-cljs doing that#2018-01-1012:39thhellermaybe (route/app-routes)?#2018-01-1012:39thhelleror the namespace that was reloaded?#2018-01-1012:48evekohad to make te route state into a defonce#2018-01-1012:48evekonow it works#2018-01-1013:06hlolliI've updated the script https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998 runs smoothly, works well when output-dir is set to target and the output-to single file to the directory I'm working on
:output-dir "target/js"
:output-to "js/main.js"
Tried adding the autoreload :devtools {:autoload true} and starting the repl shadow-cljs cljs-repl :my-id opening the extension background page I get
main.js:90082 WebSocket connection to '' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
DEVTOOLS: disconnected!
must be my config, read that websockets are fine in crx's.
#2018-01-1016:17thheller@hlolli by default it uses js/document.location.hostname to connect to which is incorrect here#2018-01-1016:18thhellertry setting :devtools {:use-document-host false}#2018-01-1022:15colindresj@thheller if I remember correctly shadow already includes https://github.com/binaryage/cljs-devtools, but I’m not seeing formatted logging. Is my memory wrong?#2018-01-1022:18thhellerno it doesn’t include cljs-devtools but it does have its own little console utilities which do basic formatting#2018-01-1022:18thhellernot as colorful though#2018-01-1022:18thhellershould still be able to expand any clojure collection and see it properly#2018-01-1022:22colindresjOh ok, nvm then. I’ll just add it separately#2018-01-1022:22colindresjThanks#2018-01-1022:23thhelleryeah just add it to the classpath and :devtools {:preloads [devtools.preload]} … way too much devtools in that line but it works 😉#2018-01-1022:23colindresjHahah yeah#2018-01-1022:23thhellerI could add it automatically whenever it finds cljs-devtools on the classpath#2018-01-1022:23thhellermight make that easier#2018-01-1022:23colindresjYeah that’d be pretty cool#2018-01-1022:24thhelleryeah let me do that#2018-01-1022:24colindresjI almost never continue a project without it#2018-01-1022:30thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e2918a83868d95cf818e8891a2d0ccd2ccd3d1d2"}, :content ("[email protected]")} should automatically include it if its on the classpath#2018-01-1112:30mhuebertI’ve added this to a new Devtools page on the wiki: https://github.com/thheller/shadow-cljs/wiki/Devtools#2018-01-1112:31thhellerthanks! @U0CKQ19AQ started writing a user guide yesterday. I like that format a lot more than the wiki so I’ll be moving all documentation over to that. See https://shadow-cljs.github.io/docs/UsersGuide.html#2018-01-1112:32thhellerhttps://github.com/shadow-cljs/shadow-cljs.github.io#2018-01-1112:33thhellerPRs very welcome. I’ll work on this primarily for a while until I’m not ashamed of the docs anymore 😉#2018-01-1112:34mhuebertawesome#2018-01-1112:37mhueberti’ve added a link to the user guide in the wiki home#2018-01-1112:40thhellerits still in pretty rough shape so it might not be that helpful yet#2018-01-1116:28colindresjAdded a quick PR to document this update#2018-01-1117:59tony.kayMight want to hold off on PRs for a few days. I work pretty rapidly on docs, and it would be distracting and confusing. I'd more appreciate additions to the wiki with issues opened on the repo pointing to that content. That way I can pull it in when it makes sense.#2018-01-1117:59tony.kayunless it is just typo/clarification stuff...those can be fine. But I may re-org pretty dramatically this early#2018-01-1118:39colindresjYep, no problem. Feel free to merge or cancel if it feels like too big a change.#2018-01-1022:32colindresjAwesome! Thanks @thheller#2018-01-1100:07tony.kayare compiler-options ignored for compile?#2018-01-1100:08thhellerdepends?#2018-01-1100:08thheller:optimizations only applies for release#2018-01-1100:09tony.kayI see. So release means compile and optimize, or is it just a separate step?#2018-01-1100:09thhellerall shadow-cljs builds are basically 2-in-1 if you are used to other build tools#2018-01-1100:10thhellercompile is one time dev compile, watch is dev compile on repeat, release is a release compile + optimization#2018-01-1100:10tony.kaygot it…I’m going to have to apply my asciidoc skills to your documentation 😉#2018-01-1100:11thhelleryour documentations skills definitely outshine mine#2018-01-1100:11thhellerwhenever I start writing docs I start drifting to the code and just write some other code instead#2018-01-1100:13tony.kayyeah, it’s tough…as you write them you discover bugs and missing things…and have to fix them right then#2018-01-1100:13thhellerexactly#2018-01-1100:14tony.kayI’m definitely liking the i18n ideas…I just discovered that trf is broken on extraction…compiler is moving the literal string to a var#2018-01-1100:15tony.kayfrom a plug-ins perspective, wouldn’t it be better just to give a clean API for code to store/retrieve data during compile, and then a hook to run at end of compile?#2018-01-1100:16tony.kayI love that macros give you the ability to extend the compiler…but it had never occurred to me that lifecycle would also be so useful.#2018-01-1100:17tony.kaysame thing with data_readers, now that I think of it#2018-01-1100:17thhellercompiler should also be able to help with css extractions and things like that#2018-01-1100:18thhellercould certainly create a proper API instead of directly messing with the cljs.env/*compiler* atom#2018-01-1100:18tony.kaycome to think of it…lifecycle is sufficient#2018-01-1100:18tony.kaystart and end, possibly events in th emiddle#2018-01-1100:18thhellerwhat do you mean by lifecycle? build events?#2018-01-1100:19tony.kayyou have access to the JVM and can create your own state#2018-01-1100:19tony.kayyeah…:compile-started :compile-finished#2018-01-1100:19thhellerright#2018-01-1100:19tony.kaythen an i18n package could just namespace their own atom, init it, and dump at the end#2018-01-1100:19thhellershadow-cljs has these stages currently https://github.com/thheller/shadow-cljs/wiki/Custom-builds#compilation-stages#2018-01-1100:20thhellercan't really use an outside atom#2018-01-1100:20thhellerit really needs to be in the analyzer data#2018-01-1100:20tony.kaywhy not? The JVM is a shared resource#2018-01-1100:20thhellerotherwise it won't be restored properly due do caching#2018-01-1100:21thhellershadow-cljs caches compilation pretty aggressively#2018-01-1100:21thhellerthat breaks whenever you touch things the compiler is not aware of#2018-01-1100:21tony.kayoh…so you couldn’t just clear it#2018-01-1100:22thhellersure you can clear it but I haven't done a lein clean in years#2018-01-1100:22tony.kaynice…that’s good to hear 🙂#2018-01-1100:22tony.kayso yeah, that kind of tooling would need a way to ensure that all files get processed#2018-01-1100:23thhellerthats my I'm dumping the strings into the analyzer data per ns#2018-01-1100:23thhellerinstead of one global collection#2018-01-1100:23thhellercan't reliable cache the global thing#2018-01-1100:25thhellercome to think of it hot reloading may actually mess up the string collection and collect repeatedly#2018-01-1100:25tony.kayso on startup the analyzer goes through all files, or is that timestamp shortcut too?#2018-01-1100:26tony.kayI mean, with caching, how would it ever work to re-run a compile to gather strings?#2018-01-1100:26tony.kay(other than to clean first)#2018-01-1100:26thhelleronly the result of the compilation is cached#2018-01-1100:27thhellerits a two step process, first all entries are followed and collection#2018-01-1100:27thhellerfor that only the ns is parsed nothing else#2018-01-1100:27tony.kaydep graph#2018-01-1100:27thhellerthen things are sorted in order#2018-01-1100:27thhellerand compile#2018-01-1100:28thhellerwhen a given namespace is to be compiled it is first checked if cache is available for that ns#2018-01-1100:28thhellerif yes it is restored into the proper places#2018-01-1100:28thhellerif not it is compiled as usual#2018-01-1100:28tony.kaybut then you’d skip the macro eval#2018-01-1100:28thhelleryes but the data is in the analyzer cache#2018-01-1100:29thhellerwhich is also restored#2018-01-1100:29thhellercache is .js file + analyzer data#2018-01-1100:29tony.kayoh…that cache is cached?#2018-01-1100:29tony.kayok#2018-01-1100:29thhellerbasically just [:cljs.analyzer/namespaces the-ns] is written to a file so anything thats in there just works#2018-01-1100:30tony.kayso, if there was an API with docs about the caching, then it’d be usable as a general store for general plug-ins#2018-01-1100:31thhelleryes#2018-01-1100:31tony.kayok, you write it and I’ll document it 🙂#2018-01-1100:33tony.kayI’ve got some things I need to percolate on anyway…so writing some docs for your project would maybe keep me from jumping on something too quickly.#2018-01-1100:33thhellerprobably should check with David first. I'm just abusing the analyzer data here, not sure if that is officially ok 😉#2018-01-1100:33tony.kayoh..right, that’s in code you don’t control#2018-01-1100:33thhellerbut given the namespaced keys and general clojure philosopy on open data structures that should be ok#2018-01-1100:34tony.kayJAM in some keys baby!#2018-01-1100:34thhellerthe compiler also isn't really concerned with any of it so it really should be ok#2018-01-1100:36thhellerI'll write the cljs.i18n things tomorrow#2018-01-1100:36thhellerits a good example use case. will ping David to get his opinion with that#2018-01-1100:36tony.kayI’ll start a book for you tonight if you’d like. Pull together your wiki stuff and start augmenting. asciidoc ok with you?#2018-01-1100:37thhellersure#2018-01-1100:37thhellernever used it but your docs look great so I'm in 😉#2018-01-1100:38tony.kaycool. It’s very similar to markdown#2018-01-1100:38tony.kayjust more powerful and pretty#2018-01-1100:41hlolliI added :use-document-host false then what I got was one of the stranger error logs I've seen 🙂 https://pastebin.com/MwwCmCsH short research led me to inline scripts in html causing this, it's maybe a longshot here https://developer.chrome.com/extensions/tut_migration_to_manifest_v2#inline_scripts (I'm also perfectly fine not haveing hot-reload, so no stress about this)#2018-01-1100:42thhellerweird, why devtools attempting to load ALL the files#2018-01-1100:43thhelleroh right ..#2018-01-1100:44thhellerwhen you generate the single output file the required things aren't set#2018-01-1100:44thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L377-L378#2018-01-1100:44thhellerbasically that needs to be added somewhere in the file#2018-01-1100:44thhellerthe karma stuff doesn't do that since its not concerned with hot reload#2018-01-1100:45thhellerbut yeah the security permissions are weird#2018-01-1100:45thhellermaybe you need to allow in the manifest?#2018-01-1100:45thhellerit tries to load from localhost which you are probably not allowed to connect to?#2018-01-1100:45hlolliI haven't received not-permitted error yet, but I think they include message that x feature need to be permitted. But not ruleing that one out still.#2018-01-1100:46hlolli1 sec...#2018-01-1100:47thheller
main.js:89433 DEVTOOLS: load JS goog/debug/error.js
main.js:89487 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-M37Ss2WONZF7RdLxeAaEIHlfH/yox80jtDrUm4wIlr8='), or a nonce ('nonce-...') is required to enable inline execution.
#2018-01-1100:47thhellerit is trying to load the goog/debug/error.js since it doesn't know that its already loaded#2018-01-1100:47thhellerbut thats what hot reload would be attempting to do#2018-01-1100:47thhellerso that would fail too#2018-01-1100:48hlolliok now it works!#2018-01-1100:48hlollihaha, facepalm, I was moveing node_modules folder around and shadow-cljs wasnt installed as dev-dependency. I installed it and now it's connected without warnings.#2018-01-1100:49hlolliOr the fact I reloaded the plugin, could be either or.#2018-01-1100:49thhellerweird, that shouldn't affect the plugin but who knows#2018-01-1100:50hlolli
DEVTOOLS: connected!
main.js:89433 DEVTOOLS: disconnected!
#2018-01-1100:50hlolli
[2018-01-11 01:47:54 - WARNING] stale websocket client, please reload client :vast
#2018-01-1100:50thhellerit may also be complaining due to this trick#2018-01-1100:50thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L51-L57#2018-01-1100:51thhellerthat basically tries to execute inline script which is blocked#2018-01-1100:51hlolliok, just one step backward, this is the right way to start the hot-reload in the cmd shadow-cljs cljs-repl :vast ?#2018-01-1100:51thhellerso might have to use js/eval instead#2018-01-1100:51hlolliwhere :vast is my id#2018-01-1100:51thhellershadow-cljs watch vast#2018-01-1100:52thhellercljs-repl vast only if you want the actual repl#2018-01-1100:52thheller(while watch is running)#2018-01-1100:52hlolliok, I got all the errors back now again#2018-01-1100:53thhelleryeah it is most likely the script-eval thing#2018-01-1100:53thhellerit seems to be ok with loading the code via xhr#2018-01-1100:53thhellerits just blocking the eval#2018-01-1100:54hlolliyes, and the way to permit it is with sha256 hash, I guess that hash changes a lot in development#2018-01-1100:55thhelleryeah, maybe eval works#2018-01-1100:56thhelleryou can copy this file into your project#2018-01-1100:56thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L51-L57#2018-01-1100:57thhellerand let the script-eval just use (js/goog.global.eval code) instead of creating a script element#2018-01-1100:57thhellermaybe that just fixes it#2018-01-1100:57hlolliok, I give it a try!#2018-01-1100:58thhellermaybe js/eval direct instead of going through goog.global try and see what works 😉#2018-01-1101:13tony.kay@thheller I’m looking at dev-http. I don’t see a way to plug into the middleware…am I missing anything?#2018-01-1101:14thhelleryou can only specify a custom handler (via :http-handler)#2018-01-1101:14hlolliin short this fixes it, but I haven't yet seen the hot reload in action, could be that I need to look closer at where shadow.cljs.devtools.client.browser is being injected since I'm not useing the same name. Only quirk was that I had to add this into my manifest "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"#2018-01-1101:14tony.kayah…that’s probably sufficient#2018-01-1101:15tony.kayI see. I didn’t look above the middleware#2018-01-1101:15thheller@tony.kay you are are providing a server anyways don't you? might be best to just use that instead of the dev http server shadow-cljs provides#2018-01-1101:16tony.kayworking on the book…it’s a thing that is sometimes useful#2018-01-1101:16tony.kayso scanning through what is supported#2018-01-1101:16thhellerah 🙂#2018-01-1101:19thheller@hlolli I only suggested copying the file into your project to replace the one in shadow-cljs#2018-01-1101:19thhellerspecifically to only test if js/eval would work#2018-01-1101:19thhellercan't test this easily myself since I have no basic setup for a chrome extension#2018-01-1101:20thhellerif you have something available publicly I can take a look#2018-01-1101:22hlolliok, I'll zip it and send this to you. Alternatively I could replace this one file, but I'd need to know how to compile shadow-cljs#2018-01-1101:22thhellerno you just the file into your classpath#2018-01-1101:23thhellersrc/shadow/cljs/devtools/client/browser.cljs if you :source-paths is ["src"]#2018-01-1101:23thhellerthat will then override the default#2018-01-1101:23thhellerno need to compile shadow-cljs itself or anything#2018-01-1101:23thhellerthe classpath ordering will ensure that your version is loaded over the version in the jar#2018-01-1101:23hlolliah didn't know that works 🙂#2018-01-1101:25thhellermight need to restart the compile process#2018-01-1101:25thhellerbut otherwise it just works#2018-01-1101:28hlollino error or warning in the console, I make changes, it compiles and nothing happens. You mentioned it shouldn't try to load all the files, the console looks like this:#2018-01-1101:28thhelleryeah that shouldn't happen#2018-01-1101:29thhellerbasically it should NOT load anything before REPL init successful#2018-01-1101:29thhellerit only does because the goog.dependencies_ stuff is not properly set#2018-01-1101:29thheller(because of manually generating the file)#2018-01-1101:30hlollihmm ok, so I could add it?#2018-01-1101:30thhelleryes#2018-01-1101:30hlollihere
(defn flush-crx-to-file
  [{:keys [polyfill-js unoptimizable build-options build-sources] :as state}
   {:keys [output-to] :as config}]
  (let [prepend
        (str unoptimizable
             (output/closure-defines-and-base state)
             "var shadow$provide = {};\n"
             "goog.global[\"$CLJS\"] = goog.global;\n")
        out
        (->> build-sources
             (map #(data/get-source-by-id state %))
             (remove #(= "goog/base.js" (:resource-name %)))
             (map #(data/get-output! state %))
             (map :js)
             (str/join "\n"))]
    (spit output-to (str prepend out)))
  state)
#2018-01-1101:30hlolliok!#2018-01-1101:32thhelleryeah add a map step that adds the two lines per file#2018-01-1101:39thhellerhmm you could try just adding :devtools {:async-require true} and just use the default :browser output#2018-01-1101:39thhellerie. not a single file#2018-01-1101:39thhellerthe async-require will load things via fetch instead of the usual closure debug loader#2018-01-1101:39thhellerfetch should just work#2018-01-1101:40hlollithat would leave me again with the background-script thingy?#2018-01-1101:41thhellerI really need to sleep. I can take a look tomorrow#2018-01-1101:41thhellerway too tired. gn8.#2018-01-1101:41hlollino, 😄#2018-01-1101:41hlollihaha yes good night, sleep well!#2018-01-1112:38mhuebertis there a recommended “path of least awkwardness” for deploying maven artifacts from a clojure project which is otherwise fully ‘managed’ by shadow-cljs?#2018-01-1112:39thhellersadly that would be using lein (or boot)#2018-01-1112:40thhellerI hope someone writes a generic deploy utility library that isn’t coupled to a build tool (ie. also works with tools.deps)#2018-01-1112:43mhueberthm. I guess I could have the project.clj read :source-paths and :dependencies from shadow-cljs.edn, https://stackoverflow.com/a/7741790/3421050
#2018-01-1112:43mhuebertavoid duplication of those entries#2018-01-1112:44thhelleryeah that works#2018-01-1112:45thhellersimilar to this https://clojureverse.org/t/combining-tools-deps-with-leiningen/658/4?u=thheller#2018-01-1113:34hlolliboom! https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998 @thheller ❤️
BUJAKA!
main.js:89714 DEVTOOLS: connected!
main.js:89714 DEVTOOLS: REPL init successful
main.js:89714 DEVTOOLS: load JS vast/core.cljs
core.cljs:31 BUJAKA!
main.js:89714 DEVTOOLS: load JS vast/core.cljs
core.cljs:31 BUJAKA!
#2018-01-1122:50martinklepsch> I hope someone writes a generic deploy utility library that isn’t coupled to a build tool While I agree that this would be a nice thing, deploying is a somewhat complex task and in the end you’ll end up with something like lein or boot. Now you have three things 🙂#2018-01-1122:51thhelleryeah probably#2018-01-1122:51thhellerbut if boot had a declarative configuration for that I could just call clj -m boot.deploy 😉#2018-01-1122:52martinklepschdeclarative as in reading from a file?#2018-01-1122:53thhelleryeah, :boot.deploy/config {...} in deps.edn#2018-01-1122:53thhelleror separate file#2018-01-1122:53martinklepschand are you attached to running clj instead of boot? 😉#2018-01-1122:54thhellerneither#2018-01-1122:55thhellershadow-cljs clj-run boot.deploy with [boot/deploy ...] in my deps#2018-01-1122:55thhellergeneric clojure. not coupled to a build tool#2018-01-1122:56thhellerlein run -m boot.deploy … everything that is able to launch a JVM should work#2018-01-1122:58thhellerI like boot but I don’t like that its all code and not really very declarative#2018-01-1123:01martinklepschIt’s an interesting idea to not have a binary like lein boot and just invoke namespaces#2018-01-1123:01martinklepschAll Clojure build tools were conceived at a time when there was no tool to construct a classpath for you#2018-01-1123:03martinklepsch> I like boot but I don’t like that its all code and not really very declarative It doesn’t have declarative interfaces because those generally end up falling short — that said bolting declarative interfaces on top of boot is something that is very trivial and should probably be embraced more#2018-01-1123:06martinklepschIt would be interesting to see what boot would look like if there was no boot binary#2018-01-1123:08thhellerits definitely worth having a dedicated binary still#2018-01-1123:09thhellercan do way more optimizations for startup time and such#2018-01-1123:09thhellerbut that doesn’t necessarily conflict with the thing working as a library as well#2018-01-1123:09thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2018-01-1123:10thhellermy take on the subject I wrote recently#2018-01-1123:11thhellerits definitely more work though so it might not actually be easy to do#2018-01-1123:11thhellertoo bad clojure makes it so hard to run isolated instances, too much static stuff#2018-01-1123:15martinklepschjava -cp (clj -Spath) boot.App repl running boot without boot 😄#2018-01-1123:16martinklepsch> too bad clojure makes it so hard to run isolated instances, too much static stuff not sure I understand what you mean @thheller#2018-01-1123:17thhellerwell the reason boot pods exist basically#2018-01-1123:17thhellercan’t “fork” a clojure runtime#2018-01-1201:13tony.kayBook updated. https://shadow-cljs.github.io/docs/UsersGuide.html#2018-01-1201:14tony.kayCovers the browser in pretty good detal, and I think I’ve got most of the standard node targets covered as well#2018-01-1201:14tony.kayStill needs some of the additional targets, testing, etc. But, it covers most of the wiki and blog at this point.#2018-01-1201:14tony.kaySome @thheller TODO items#2018-01-1202:09Jontime for a logo..?#2018-01-1202:25JonI need to update this page http://shadow-cljs.org/#2018-01-1202:36Jonloading Google fonts from China is disaster... in that UsersGuide.html#2018-01-1207:03tony.kay@jiyinyiyong If you want to send a PR that fixes it…it’s just asciidoctor: http://asciidoctor.org/docs/user-manual/#applying-a-theme#2018-01-1207:04tony.kayThe repository is https://github.com/shadow-cljs/shadow-cljs.github.io and there is a make file…just type make to try out changes.#2018-01-1210:28Jonwould you mind turning of fonts? https://github.com/asciidoctor/asciidoctor/issues/2515#issuecomment-352695396#2018-01-1210:59thhellerlooks kinda ugly without the fonts#2018-01-1210:59thhellershould be possible to download them so they are served from the same page though#2018-01-1211:00thhellerhttps://google-webfonts-helper.herokuapp.com/fonts#2018-01-1211:00thhellerjust need to figure out which fonts are actually used#2018-01-1214:06JonOpen Sans Light—Network resource(24 glyphs), Noto Serif—Network resource(169 glyphs), Droid Sans Mono—Network resource(82 glyphs)#2018-01-1214:07Jonbased on DevTools#2018-01-1215:53Jonwhat do you think? to be a logo?#2018-01-1218:28Alex Hany ideas on how to handle some sass/scss or less styles properly/nicely with shadow-cljs?#2018-01-1218:28Alex Hideally so that they also get re-built automatically, etc?#2018-01-1218:28Alex Hor is it just a case of using a separate process entirely to handle that?#2018-01-1218:29tony.kay@alex340 You could build a custom target and trigger them.#2018-01-1218:29tony.kayhttps://shadow-cljs.github.io/docs/UsersGuide.html#_custom_targets#2018-01-1218:30tony.kayI'm not sure how to access it, but I'm guessing you could even trigger hot reload#2018-01-1218:34Alex Hinteresting#2018-01-1218:36tony.kayall of the built-in targets use that, so there are plenty of examples in the source#2018-01-1218:37Alex Hhow would I go about detecting a change in one of the sass/less files?#2018-01-1218:37Alex Hwith a custom target#2018-01-1218:39tony.kaythat I don't know off the top of my head. Look at the file watching source (hawk something-or-other)#2018-01-1218:40tony.kaynot sure if that is pluggable yet#2018-01-1218:41tony.kayif nothing else you could hack it in the meantime with a cljs file that you touch during the trigger 😜#2018-01-1219:21thheller@alex340 shadow-cljs itself does not provide anything css related currently but it will reload css on the page#2018-01-1219:22thhellerif you are using the :devtools :http-root and the css is embedded in the page with an absolute path the css will be reloaded#2018-01-1219:23thhellersee https://github.com/thheller/shadow-cljs/issues/168#2018-01-1219:23thhellerI’m still deciding on a proper plugin API to enable doing the css compilation without the build itself#2018-01-1219:24thhellerfor now I recommend the normal tooling and just putting the output in a proper place to be reloaded#2018-01-1219:27Alex Hok, so if I get node-sass in watch mode to rebuild, shadowcljs should realize the file has changed and reload the css#2018-01-1219:27Alex Hthat'll work for me for now#2018-01-1219:27thhelleryep#2018-01-1219:27Alex Hfor production builds I'll see what I'll do, but I might just do an old-school Makefile executing both shadow-cljs and node-sass#2018-01-1219:27thhellerthats what I do currently#2018-01-1219:28Alex Hcool, thanks#2018-01-1219:28Alex H(again!)#2018-01-1219:30Alex H@tony.kay thumbs up on that doc you are writing for shadow-cljs. Still need to read through it in detail, but the bits I have read make a ton of sense & have been very useful!#2018-01-1219:31tony.kaymost of it was written by @thheller. I'm just organizing and editing 🙂#2018-01-1219:31tony.kaybut thanks#2018-01-1219:40thheller@jiyinyiyong I like the logo … although it seems a bit generic. Initially I thought I’d just take the CLJS logo and put a shadow under it 😉#2018-01-1314:05Jonplease explain "shadow" in shadow-cljs#2018-01-1314:23Jonlast time I asked about, I found it has no actually meaning(I might remember it wrong though).#2018-01-1314:23Jonif there's is a meaning, then we should try visualising that.#2018-01-1315:26thhellervery first namespace I ever created in clojurescript was for DOM stuff. I was playing with the shadow DOM spec stuff at the time, so I named the ns shadow.dom. the prefix kinda stuck.#2018-01-1315:26thhellerno particular meaning beyond that#2018-01-1400:27Jonmade me wondering why is shadow dom named with "shadow"...#2018-01-1400:42JonI added the image and sketch file in https://github.com/shadow-cljs/shadow-cljs.org/tree/master/entry#2018-01-1219:53mitchelkuijpersI love the thing you have on GitHub @thheller the cljs logo and then the shadow#2018-01-1219:55thhelleryeah its pretty cool. @shaunlebron did that.#2018-01-1219:55mitchelkuijpersYeah also really love those colors#2018-01-1312:56Alex HI'm somehwat confused by this:#2018-01-1312:56Alex Hcircular dependency: [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/core.cljs"] -> [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/fx.cljs"] -> [:shadow.build.classpath/resource "dlt/graphql/core.cljs"] {:resource-id [:shadow.build.classpath/resource "dlt/events.cljs"], :stack ([:shadow.build.classpath/resource "dlt/core.cljs"] [:shadow.build.classpath/resource "dlt/events.cljs"] [:shadow.build.classpath/resource "dlt/fx.cljs"] [:shadow.build.classpath/resource "dlt/graphql/core.cljs"])} ExceptionInfo: circular dependency: [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/core.cljs"] -> [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/fx.cljs"] -> [:shadow.build.classpath/resource "dlt/graphql/core.cljs"]#2018-01-1312:56Alex Hnothing, and by that I really mean nothing, requires dlt.core#2018-01-1312:56Alex Hyet, somehow, it seems to say that dlt.events requires dlt.core#2018-01-1312:57Alex Hthe only thing that requires dlt.core, if anything, is that it's :modules {:main {:entries [dlt.core]}} in the shadow-cljs.edn#2018-01-1312:57Alex H(and the after-load)#2018-01-1315:27thheller"dlt/events.cljs" is the circle#2018-01-1315:27thhellerit requires core?#2018-01-1315:28thhellerthe message indeed seems incorrect and confusing#2018-01-1316:52Alex Hno, it doesn't require core#2018-01-1316:53Alex H(ns dlt.events (:require-macros [cljs.core.async.macros :refer [go]] [dlt.util.macros :refer [p<! jsp<!]]) (:require [clojure.string :as s] [re-frame.core :as re-frame] [dlt.db :as db] [dlt.fx :as fx] [dlt.util.core :as u]))#2018-01-1316:53Alex HI mean, as I said, the only mention of dlt.core anywhere is in the shadow-cljs.edn for the :entries thing#2018-01-1316:56thhellerwhat does dlt.fx look like?#2018-01-1316:56thhellerand dtl.graphql.core?#2018-01-1316:56Alex H(ns dlt.fx (:require-macros [cljs.core.async.macros :refer [go]] [dlt.util.macros :refer [p<! jsp<!]]) (:require [clojure.string :as s] [re-frame.core :as re-frame] [dlt.graphql.core :as gql] [dlt.util.core :as u]))#2018-01-1316:56Alex H(ns dlt.graphql.core (:require [clojure.string :as s] [graphql-builder.parser :refer-macros [defgraphql]] [graphql-builder.core :as gql-builder] [reagent.core :as r] [re-frame.core :as re-frame] [apollo-client :refer [ApolloClient createNetworkInterface]] [graphql-tag :as gql] [dlt.util.core :as u]))#2018-01-1316:57Alex H(ns dlt.util.core (:require [cljs.core.async :as async] [clojure.string :as s]))#2018-01-1316:57Alex H(ns dlt.db)#2018-01-1316:57Alex Hand that's all the namespaces involved#2018-01-1316:58thhellerstrange indeed#2018-01-1316:59thhellerdo you maybe have a duplicate file somewhere that could cause a conflict?#2018-01-1316:59thhellersrc/main and src/test both having a dlt.core or so?#2018-01-1316:59Alex H~/code/dlt-frontend-shadowcljs master [1+] ❯ ag dlt.core src/clj/dlt/core.clj 1:(ns dlt.core) src/cljs/dlt/core.cljs 1:(ns dlt.core public/index.html 29: <script>dlt.core.init();</script> shadow-cljs.edn 26: :modules {:main {:entries [dlt.core]}} 33: :after-load dlt.core/on-js-reload assets/index.html 29: <script>dlt.core.init();</script>#2018-01-1317:00thhellerany of the othrs?#2018-01-1317:00Alex Hnot really, no#2018-01-1317:01Alex Hwould it help trying to blow away the output js dir?#2018-01-1317:01Alex HI had a version with a circular dependency at some point, but I fixed that by factoring the circular bits out into that fx namespace#2018-01-1317:02thhellerhmm not aware of any caching bugs currently but maybe you found one#2018-01-1317:02thhellerjust delete the target/shadow-cljs/builds directory#2018-01-1317:02thhellerand restart the compile#2018-01-1317:03Alex Hno joy#2018-01-1317:03Alex Hcircular dependency: [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/core.cljs"] -> [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/fx.cljs"] -> [:shadow.build.classpath/resource "dlt/graphql/core.cljs"] {:resource-id [:shadow.build.classpath/resource "dlt/events.cljs"], :stack ([:shadow.build.classpath/resource "dlt/core.cljs"] [:shadow.build.classpath/resource "dlt/events.cljs"] [:shadow.build.classpath/resource "dlt/fx.cljs"] [:shadow.build.classpath/resource "dlt/graphql/core.cljs"])} ExceptionInfo: circular dependency: [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/core.cljs"] -> [:shadow.build.classpath/resource "dlt/events.cljs"] -> [:shadow.build.classpath/resource "dlt/fx.cljs"] -> [:shadow.build.classpath/resource "dlt/graphql/core.cljs"]#2018-01-1317:03Alex HI guess I can push the repo somewhere#2018-01-1317:03Alex H(if you want to have a look)#2018-01-1317:04thhellerthat would help#2018-01-1317:05Alex Hhttps://github.com/bwalex/dlt-frontend-shadowcljs#2018-01-1317:06Alex Hit's a mess, including the commit messages, but there it is 🙂#2018-01-1317:06thhellerlooking into it#2018-01-1317:13thhellerone quick note: the :exlusions are incorrect, just one vector with symbols, no nested vectors#2018-01-1317:14Alex Hchanged, thanks#2018-01-1317:15Alex H(somehow did work well enough to get rid of my issues though - a warning with cuerdas and the fact that I wanted to use react 16 instead of 15.something)#2018-01-1317:15Alex Hmaybe someone thought of useless users like me and added a flatten in there 😛#2018-01-1317:17thhellerah found it#2018-01-1317:17thhellerevents -> fx -> graphql.core -> events#2018-01-1317:17thhellerdunno why the error message contains the others#2018-01-1317:18Alex Hdoh. sorry#2018-01-1317:18thhellercljsjs is all ignored anyways so it doesn’t matter much which version you have on the classpath#2018-01-1317:19thhelleronly their externs are used#2018-01-1317:19Alex H@thheller thanks for looking into it for me#2018-01-1317:19thhellernp, now I have a good example to use to tweak the error message#2018-01-1317:20thhellerthat error definitely didn’t help at all 🙂#2018-01-1317:20thhelleryou also don’t need clojure,clojurescript in the deps#2018-01-1317:20thhellershadow-cljs provides those#2018-01-1317:21thhellerand thats just my preference but do you really like putting everything into separate source paths?#2018-01-1317:22Alex Hwell, as I warned you a few days ago, I've only started looking into clojurescript ~2 weeks ago#2018-01-1317:22Alex Hso my opinions are, well, based on random bits and pieces that I've seen#2018-01-1317:22Alex Hsome of the lein-fighweel boiler plates for reagent or re-frame did that structure of src/clj/foo, src/cljs/foo#2018-01-1317:22thhellerhehe ok. it is totally fine to put .clj files next to .cljs files#2018-01-1317:22thhelleryeah no idea why they do that#2018-01-1317:23Alex Hit did feel a bit awkward for example for my dlt.styled thing#2018-01-1317:23Alex Hwhere macros live in one directory, and the rest in another entirely#2018-01-1317:23thhelleryeah. I typically have a src/main where all sources live clj,cljs,cljc#2018-01-1317:24thhellersrc/test for tests etc#2018-01-1317:24Alex Hyea, sounds like a plan. I might reorganize it like that#2018-01-1317:25thhellerthe one .js include you have might get you in trouble at some point#2018-01-1317:25thhellerI would also put that directly into the folder of the .cljs if possible#2018-01-1317:25Alex Hhow so?#2018-01-1317:25thhellergoing “outside” the classpath is not actually safe#2018-01-1317:25Alex Hah!#2018-01-1317:26thhellerreason is if you want to put things in a .jar and publish that, the relative path will be invalid since it wouldn’t be in the jar#2018-01-1317:27Alex Hyea, makes sense#2018-01-1317:27thheller(relative paths aren’t supported in jars anyways yet)#2018-01-1317:53thhellerfixed the error, next release will show the error properly. (eg Circular dependency detected: circular.foo -> circular.util.lib -> circular.foo)#2018-01-1509:02mhuebertwould it make sense to have some kind of --reload option for clj-run?#2018-01-1509:07thhellerI'd suggest using clj-repl and invoking the function via the REPL while developing it#2018-01-1509:07thhelleryou can do (require 'the.ns :reload) then#2018-01-1509:08thhellercursive and others let you Load file in REPL directly as well which also works#2018-01-1509:08thhellerI feel like the REPL would be much more productive than --reload#2018-01-1509:08thhellerbut I can add it if you feel like you need it#2018-01-1509:16mhueberthmm#2018-01-1509:16mhuebertwhile i am developing, i’d be using a repl (probably evaluating the stuff from my editor)#2018-01-1509:17mhuebertbut sometimes i might have a process running in the background from coding, and i want to build a release from the command line using the latest state of the code#2018-01-1509:20thhellerany particular reason you are not calling that from the REPL?#2018-01-1509:20mhueberti have a release command in package.json so that other team members only need to remember one thing (eg. npm run release) and this is what our ci / build systems call#2018-01-1509:20thhellerah. makes sense.#2018-01-1509:21thhellerI feel like you'd just add --reload permanently then though and just let it always reload?#2018-01-1509:22mhuebertyes#2018-01-1509:23mhuebertthe intent would be that anyone else touching the system wouldn’t have to worry about npm run release not using the latest version of that code#2018-01-1509:23thhellerI don't think clojure records when something was loaded. otherwise I could probably do something automatic#2018-01-1509:24mhuebertby way of example, say i have a dev-server running in the background. i run shadow-cljs watch browser and do some front-end coding, with live reload. Then I close the watch process and want to run a release#2018-01-1509:25mhuebertnormally i’d just run this from the command line, npm run release, but since the dev-server is in the background i end up restarting it whenever i do releases. possibly because i just haven’t developed the habit of using a repl for that bit#2018-01-1509:26thhellerhmm yeah restarting the server shouldn't be a necessary thing#2018-01-1509:27thhellerI'll see if I can figure out an automatic way to do this. if not I'll add the flag.#2018-01-1509:28mhuebert👍#2018-01-1509:31mhuebertis there any difference at all between shadow-cljs watch browser vs. shadow-cljs clj-run my-build-ns.core/watch, wherein I do some cleanup and then run (shadow.cljs.devtools.api/watch <build-id>) ?#2018-01-1509:32mhuebert(where ‘cleanup’ means ’revert some asset-path transformations performed during release` and other such build-pipeline-related stuff)#2018-01-1509:32thhellertiny bit of difference maybe#2018-01-1509:33thhellerwatch stops the build when connected to the server an you CTRL+C#2018-01-1509:33thhellerthe clj-run probably doesn't#2018-01-1509:35thhellerI'm still sorting out the hook API that would let you hook into :watch-start :release etc events#2018-01-1509:35thhellerthen you could probably use that instead of clj-run#2018-01-1509:49mhueberthmm ok#2018-01-1510:21mhuebertso in the meantime, shadow-cljs clj-run my.build.ns/before-watch; shadow-cljs watch browser;#2018-01-1510:22mhuebertwhich, if a server is already running, is super fast, otherwise it starts a server process twice#2018-01-1510:22thhellershadow-cljs start; shadow-cljs clj-run my.build.ns/before-watch; shadow-cljs watch browser;#2018-01-1510:22thhellerstart starts a background server if none is running#2018-01-1510:59mhuebertah great.#2018-01-1510:59mhuebertdo you recommend putting shadow-cljs into :npm-deps?#2018-01-1511:02thhellerno#2018-01-1511:02thhellerat most it is a dev dependency which :npm-deps doesn't handle#2018-01-1610:59mjmeintjesHi. I'm trying to use shadow-cljs along with Macchiato. However, I'm getting the following error when running the file produced by shadow-cljs -
SHADOW import error /projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js
/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539
      throw new TypeError('Line must be greater than or equal to 1, got '
      ^

TypeError: Line must be greater than or equal to 1, got null
I'm not sure if I'm doing anything wrong, because I have very limited experience with nodejs.
#2018-01-1611:00thhellercan you paste the full error?#2018-01-1611:00thhellerthat looks like it has trouble using the source map#2018-01-1611:00thhellerthat is not the actual error#2018-01-1611:01mjmeintjes
$ /projects/funnels-cljs$ node out/funnels-cljs/server.js

SHADOW import error /projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js
/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539
      throw new TypeError('Line must be greater than or equal to 1, got '
      ^

TypeError: Line must be greater than or equal to 1, got null
    at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:539:13)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/projects/funnels-cljs/node_modules/source-map/lib/source-map-consumer.js:604:22)
    at mapSourcePosition (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:199:42)
    at wrapCallSite (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:343:20)
    at /projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:378:26
    at Array.map (<anonymous>)
    at Function.prepareStackTrace (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:377:24)
    at process.emit (/projects/funnels-cljs/node_modules/source-map-support/source-map-support.js:431:52)
    at process._fatalException (bootstrap_node.js:386:26)
#2018-01-1611:02thhellerhmm that completely replaced the actual error#2018-01-1611:02mjmeintjesThis is basically just from taking the Macchiato lein project template, and then adding a shadow-cljs.edn file and trying to run it that way.#2018-01-1611:03thhellercan you share the repo so I can take a closer look?#2018-01-1611:04mjmeintjesWill do, give me a few minutes.#2018-01-1611:16thhellerI usually already remove the lineCount property from source maps, looks like I forgot to do that somewhere#2018-01-1611:16thheller/projects/funnels-cljs/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.crypto.js.map probably has "lineCount":null which it shouldn’t#2018-01-1611:20mjmeintjeshttps://github.com/mjmeintjes/shadow-cljs-macchiato#2018-01-1611:24thhellerhmm not about lineCount. odd.#2018-01-1611:32thhellerthe actual error is Error: Cannot find module 'simple-encryptor'#2018-01-1611:33thhellerand Cannot find module 'multiparty'#2018-01-1611:33thhellerand Cannot find module 'cookies'#2018-01-1611:33thhelleryou can set :compiler-options {:source-map false} in the build config#2018-01-1611:34thhellerso you’ll get all the errors yourself instead of me pasting them here#2018-01-1611:34thhellerits basically just a bunch of missing npm packages#2018-01-1611:34thhellerno idea why the source map is broken though. looking into that now.#2018-01-1611:36mjmeintjesThanks, appreciate the help!#2018-01-1611:42mjmeintjesIt is working now, was just a few missing npm dependencies.#2018-01-1612:00thhellerthere isn’t a single null in the source map. I don’t get it 😛#2018-01-1612:22thhellergah .. the source-map-support package for node is just one piece of horrible ugly code#2018-01-1615:15thheller@mjmeintjes should be safe to enable source maps with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cbb8a3aaafa4bce6a8a7a1b88bf9e5fbe5faf8f8"}, :content ("[email protected]")} again, was using incorrect offsets so source maps got confused.#2018-01-1704:22Jonturned into a promotion at last... https://twitter.com/jiyinyiyong/status/953482343632683008#2018-01-1705:16cmalSorry my mistake#2018-01-1716:14Jonhttps://github.com/thheller/shadow-cljs/issues/175#issuecomment-358355330#2018-01-1716:15Jonwebsocket problems is annoying#2018-01-1716:33Jonfixed by.... removing target/ and node_modules/ then reinstalling...#2018-01-1717:17JonPushed some changes to http://shadow-cljs.org/#2018-01-1718:13thhellerstale websocket client, please reload client :browser means that the client has JS that was not generated by the current worker#2018-01-1718:13thhellerie. the current watch#2018-01-1801:57Jonso, means generated js is old...#2018-01-1802:25sooheonHey all, has @thheller gone into more detail anywhere about why boot and shadow-cljs do not mix? Is it an actual performance problem, or just a lack of experience with the two together?#2018-01-1805:56robert-stuttafordhey folks - any plan to support auth-only maven repos? basically, can’t use shadow-cljs and pro datomic together in a codebase, which is a pretty substantial hurdle#2018-01-1805:57robert-stuttafordby that i mean this facility in lein:#2018-01-1805:57robert-stuttaford
:repositories
{"" {:url      ""
                   :username "xxx"
                   :password "yyy"}}
#2018-01-1809:30thheller@robert-stuttaford at the moment you can use lein to manage the classpath. you just specify :lein true in shadow-cljs.edn and setup your :dependencies and :source-paths via lein. everything will be executed via lein so :repositories should work. https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration#2018-01-1809:34thheller@sooheon lack of experience on my part. @jgdavey knows more and created https://github.com/jgdavey/boot-shadow-cljs#2018-01-1809:51thheller@robert-stuttaford shadow-cljs should also support :repositories but I never tested it so I can’t verify it actually works. try to just specify it at the top level in shadow-cljs.edn. you can use :username #shadow/env "DATOMIC_USERNAME" if you prefer to keep the username/password out of shadow-cljs.edn and use env variables instead.#2018-01-1810:05robert-stuttafordthank you @thheller, i’ll kick the tires!#2018-01-1810:08thheller@robert-stuttaford I use the same maven interop lib as lein or boot so it may just work. https://github.com/cemerick/pomegranate#2018-01-1810:27thheller@robert-stuttaford datomic has cljs support? Otherwise should not be required if you just want to build cljs?#2018-01-1810:28robert-stuttaford@thheller all clj / cljs / cljc source is in one place, so datomic code will be on the classpath, even if the cljs doesn’t use it#2018-01-1810:31thhellerthat doesn't matter#2018-01-1810:31thhellershadow-cljs will only touch code that is actually referenced somewhere in cljs#2018-01-1810:33thhelleronly problem may be macro files which also require some datomic code. otherwise it should be fine#2018-01-1810:45robert-stuttafordah, that’s good to know! definitely different to cljsbuild 🙂#2018-01-1819:13tianshucan I start a watch task without blocking in REPL?#2018-01-1823:11thheller@doglooksgood you mean starting the watch from the REPL? (shadow.cljs.devtools.api/watch :build) does not block the REPL.#2018-01-1902:17theasp@thheller Is there anyway to keep the npm deps in the config file?#2018-01-1902:26theaspAlso, any idea whats up here?
SHADOW import error /home/asp/projects/logview/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.cookies.js
Error: Cannot find module 'cookies'
#2018-01-1903:33tianshu@thheller I got an error said missing instance, how can I get this instance?#2018-01-1903:50tianshuok, I read the wiki found this can not work in nREPL.#2018-01-1905:07robert-stuttaford@thheller is it possible for me to use shadow in this manner: put all intermediate output in target, but put the final entry point in resources? in prod, we only use a single js in resources. in dev, we do what i just said, and serve target/js at /js in dev time. i’ve got shadow working, but because it puts stuff in resources, it now complains that it’s finding sources twice.#2018-01-1905:08robert-stuttafordie my working cljsbuild config
:output-to            "resources/app/js/app.js"
                   :output-dir           "target/js/out"
                   :asset-path           "/js/out"
#2018-01-1905:57robert-stuttaforddep in the root of the project (not in a profile), a (shadow/start!) call showing shadow-cljs - server running at in my repl. but, when i shadow-cljs watch, i get: ClassNotFoundException shadow.cljs.devtools.cli. what have i forgotten?#2018-01-1905:58robert-stuttafordthat’s right after a shadow-cljs - connected to server message#2018-01-1906:53robert-stuttaforddoes the cljs hot code reloading work without using the built in web server?#2018-01-1906:53robert-stuttaford(i know the docs say css requires the web server)#2018-01-1907:14robert-stuttafordeven when using :lein {:profile "+dev"}, :http-handler can’t find my dev profile http handler namespace.#2018-01-1908:25robert-stuttaford@thheller the docs could really do with an example devtools code snippet. i’ve been reading the source to figure out how to give it its options correctly 🙂#2018-01-1908:28tony.kay@robert-stuttaford You reading the new user guide?#2018-01-1908:28robert-stuttafordRobert finds https://github.com/thheller/shadow-cljs/tree/master/shadow-cljs.edn#2018-01-1908:29robert-stuttafordyes sir#2018-01-1908:29tony.kaythere is a lot on the devtools section...what option are you trying to figure out?#2018-01-1908:30robert-stuttafordnow that i’m reading that edn in github, i can see how output-dir, asset-path and http-root are meant to hang together#2018-01-1908:31tony.kaywell, if the user's guide needs clarification, send a PR...glad to improve it.#2018-01-1908:31tony.kayhttps://shadow-cljs.github.io/docs/UsersGuide.html#_output_settings#2018-01-1908:33robert-stuttafordto be clear: the guide has been tremendously helpful in many other ways @tony.kay 🙂#2018-01-1908:34tony.kaythanks, but yeah, we know it is incomplete...it was thrown together from existing stuff and my additions in about 2 days#2018-01-1908:46robert-stuttafordwow. that’s a massive doc for a week’s work#2018-01-1909:11tony.kaylike I said, most of the content existed in various places#2018-01-1909:56thheller@theasp npm deps are kept in package.json. libaries can publish a deps.cljs with :npm-deps {"thing" "version"} which shadow-cljs will transfer over to package.json. unfortunately most libaries do not yet do this.#2018-01-1910:00thheller@robert-stuttaford for now just add a require for shadow.cljs.devtools.cli where you require shadow.cljs.devtools.server.#2018-01-1910:01thhellerhere is a full devtools example https://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#2018-01-1910:03thheller@theasp Error: Cannot find module 'cookies' means you need npm install cookies#2018-01-1910:04thheller@doglooksgood “missing instance” means you probably need to call (shadow.cljs.devtools.server/start!) somewhere to start the embedded server instance#2018-01-1910:07thheller@robert-stuttaford the css and cljs hot loading works without the built-in http server yes. cljs just works, css just requires that you set :watch-dir which should point to the document root of your webserver.#2018-01-1910:08robert-stuttafordrad thanks @thheller will try things#2018-01-1910:10thhellerwhen running the embedded server you can also do everything directly from the REPL if you want#2018-01-1910:10thhellerno need to run the CLI#2018-01-1910:10thhellerstilll need to write the docs on that though#2018-01-1910:10robert-stuttafordfeels like i’m really close to having things set up right. will keep pushing#2018-01-1910:11thheller(shadow.cljs.devtools.api/compile :build) is the same as calling shadow-cljs compile build#2018-01-1910:11thhellerevery other command translates the same way#2018-01-1910:11robert-stuttafordwould the webserver support the use of immutant.web.async, given that you use undertow for the webserver?#2018-01-1910:12thhellerthe dev http thing no#2018-01-1910:12robert-stuttafordkk#2018-01-1910:12thhellerits just a very thin wrapper for undertow, not using immutant#2018-01-1910:16mitchelkuijpers@robert-stuttaford We also run it embedded for 2 months now works like a charm if you need help let me know#2018-01-1910:17robert-stuttafordi think i just won through!#2018-01-1910:18mitchelkuijpersAwesome we just do this:
(defn start-cljs-repl []
  (shadow-server/start!)
  (shadow/watch :app)
  (shadow/watch :test)
  (shadow/watch :devcards)
  (shadow/nrepl-select :app))
#2018-01-1910:18mitchelkuijpersand if something breaks you can just run shadow-server/stop! and restart everything#2018-01-1910:21robert-stuttafordvery nice!#2018-01-1910:22robert-stuttafordi’m enjoying having fast cli commands with the server running in the jvm. prefer to have the cljs output separate to the web server#2018-01-1910:23mitchelkuijpersYeah we use cider and emacs, so we like to run some command in emacs which starts everything inside of emacs#2018-01-1910:24mitchelkuijpersand then all the autocompletion works#2018-01-1910:31robert-stuttafordi may even finally learn to use a cljs repl properly#2018-01-1910:31thheller@robert-stuttaford draft-js was among the packages I tested when writing the npm integration. I might be able to help if you have questions.#2018-01-1910:32robert-stuttafordthanks thheller - i’ve got a working spike together 🙂 just getting the css watching working, and then i’m happy i can Build Features#2018-01-1910:33robert-stuttafordkudos on shadow - it’s come a bloody long way since i used your previous toolchain!
#2018-01-1910:33thhellerhehe yeah. UX was horrible back in those days 😉#2018-01-1910:41robert-stuttaford@mitchelkuijpers what does nrepl-select do?#2018-01-1910:42thhellerswitches the current nrepl over to CLJS. so whatever you type next in the REPL will eval in the app build#2018-01-1910:43thheller:repl/quit exits back to the normal CLJ nrepl#2018-01-1910:43robert-stuttafordnice!#2018-01-1910:44robert-stuttaford@thheller any thoughts on splitting the root js from all the extra js output on disk?#2018-01-1910:44robert-stuttaford(cf. my question at 7:07am)#2018-01-1910:44thhellerno that is intentionally not allowed#2018-01-1910:45thhellerif just creates headaches. it is already separated out into the <output-dir>/cljs-runtime directory#2018-01-1910:45thhellerproduction does not produce or need the cljs-runtime dir so you can ignore that for any release#2018-01-1910:46robert-stuttafordright. the issue is that if i put it all in resources, it’s all on the classpath, and shadow finds its own output and complains about double provides#2018-01-1910:46thhellerwhy do you want to split it in the first place?#2018-01-1910:46thhellerright … don’t put it on the classpath 🙂#2018-01-1910:46robert-stuttafordthe code is a library project; the jar includes the release js#2018-01-1910:46robert-stuttafordi’ll work it out. just have to find another way 😎#2018-01-1910:47thhellerthe jar includes compiled js?#2018-01-1910:47robert-stuttafordyes#2018-01-1910:47robert-stuttafordyou include the lib, add its ring handler to your ring app, and it serves the rest turn-key style#2018-01-1910:48robert-stuttafordmeans the app that uses it need not compile any js#2018-01-1910:48thhellerah#2018-01-1910:48robert-stuttafordits fine, our CI handles building the js and including it. the way i do it with cljsbuild just makes the routing easier.#2018-01-1910:49thhellerright you can just output to a directory that is not on the classpath by default#2018-01-1910:49thhellerand only added when building the jar#2018-01-1910:50thhellerputting compiled things into a jar just seems wrong to me since you now have to restart the server process if you want to update the JS/CSS#2018-01-1910:51thhellerbut uberjars are nice so I understand why you’d want to do it that way 😉#2018-01-1910:51robert-stuttafordall the stuff inside the box is developed in the library project, with a dev-only web server and repls and whatnot#2018-01-1910:52robert-stuttafordhttps://github.com/magnars/prone is a good example of how we’re working#2018-01-1910:52robert-stuttafordmeans we can run this feature set on any of our web visible services. untangling capability from location.#2018-01-1910:54robert-stuttaford@thheller, just confirming shadow does nothing to install npm deps - you have to do that yourself, right?#2018-01-1910:55thhellerunless the library you are using properly declares :npm-deps via deps.cljs yes, you have to do npm install#2018-01-1910:55thhellerpretty much no library does this as of today#2018-01-1910:56robert-stuttafordis that the consuming library or the consumed library? i guess i should include a package.json with all of these?
{:draft-js             "0.10.4"
 :draft-js-export-html "1.2.0"
 :immutable            "3.7.4"
 :react                "15.6.2"
 :react-dom            "15.6.2"}
#2018-01-1910:57thhellerplease use a string as a name 😉 the consumed library needs to provide this#2018-01-1910:57robert-stuttafordthis is my cljsbuild map 🙂#2018-01-1910:57robert-stuttafordi’ll sort, thanks#2018-01-1910:57tianshu@thheller I want to start the build in my nrepl(launched by cider), compile cljs and run clj code in same jvm. is it supported now? didn't found any guide for this.#2018-01-1910:58thheller@doglooksgood see the example @mitchelkuijpers pasted a couple minutes ago. shadow-server is the shadow.cljs.devtools.server ns. shadow is shadow.cljs.devtools.api#2018-01-1910:59robert-stuttaford@doglooksgood
(require '[shadow.cljs.devtools.server :as shadow]
         '[shadow.cljs.devtools.api :as shadow-api])

(shadow/start!)
(shadow-api/watch :app)
#2018-01-1910:59thhellerI’ll work on the embedding section of the docs, seems like a lot of people want to do this.#2018-01-1911:00thhellerthat example is incorrect 😉#2018-01-1911:00thhellerwatch is only in shadow.cljs.devtools.api not the server ns#2018-01-1911:00tianshuyes,I do like this too. but how can I switch to cljs-repl? #2018-01-1911:00tianshuit's likely nrepl-select not work in this case.#2018-01-1911:00thhellerah if you want to use the nrepl started by cider#2018-01-1911:01thhelleryou need to enable the middleware#2018-01-1911:01robert-stuttafordfixed thanks#2018-01-1911:01thheller@mitchelkuijpers has done that for cider I believe. I do not know how you’d setup the middleware with cider.#2018-01-1911:02robert-stuttafordthanks for the help today!#2018-01-1911:02thhelleryou need these 3 https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/nrepl.clj#L233-L235#2018-01-1911:03tianshuI'll take a look#2018-01-1911:03thhellereg. shadow.cljs.devtools.server.nrepl/cljs-select needs to be in your nrepl middleware#2018-01-1911:05tianshuI think if people use leiningen, they probably want do like this.#2018-01-1911:06thhellerI recommend using the standalone version which you can cider-connect to. It does all the complicated setup so you don’t have to.#2018-01-1911:07mitchelkuijpersI will send you the middleware @robert-stuttaford but I am currently out for lunch#2018-01-1911:07thhellerif someone tells me how to do the other way I can add it to the docs#2018-01-1911:08thheller@mitchelkuijpers @doglooksgood asked for the nrepl stuff but send it to me as well please#2018-01-1911:13tianshuafter I add middlewares, it works.#2018-01-1911:13tianshu😀#2018-01-1911:22tianshuI saw your shadow-cljsjs project that provide replacements for cljsjs. but the react version is likely use the dev version?#2018-01-1911:23thhellerthe watch and compile will use the dev version, release will use the release version#2018-01-1911:23thhelleryou’ll get complaint from react that you are using a minified dev version though#2018-01-1911:24thhellerthat is not a problem since the release will use the correct thing#2018-01-1911:25tianshuunderstand#2018-01-1911:28thhellerthey really don’t seem to expect that someone processes the dev version and doesn’t just use it as they shipped it#2018-01-1911:28thhellerneed to bug them about that#2018-01-1911:29tianshuthe dev version is a little slow, maybe#2018-01-1911:29tianshuhowever most time we won't debug react.#2018-01-1911:34thhellerthe dev version does a whole bunch of extra checks to validate you are using everything correctly. most of the time that is useful.#2018-01-1911:34thhelleryou can override to always use the release version if you prefer#2018-01-1911:34thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_redirecting_require#2018-01-1911:35thheller{:resolve {"react" {:target :npm :require "react/cjs/react.production.min.js"}}} (for react v16)#2018-01-1911:40tianshureally awesome feature!#2018-01-1912:01tianshucreate a repo to record how to do this. https://github.com/DogLooksGood/shadow-cljs-lein-cider-config#2018-01-1912:03thhellercool. thx.#2018-01-1912:09tianshuit will be better if shadow-cljs add these middlewares automatically.#2018-01-1912:10thhellerit does if you connect to the nrepl server that shadow-cljs provides#2018-01-1912:10thhellerit can’t if you connect to the nrepl server from lein#2018-01-1912:14mitchelkuijpers@thheller @doglooksgood
:repl-options {:init-ns user
                                      :nrepl-middleware [;; provided by fake-piggieback, only because tools expect piggieback
                                                         cemerick.piggieback/wrap-cljs-repl

                                                         ;; cljs support
                                                         shadow.cljs.devtools.server.nrepl/cljs-load-file
                                                         shadow.cljs.devtools.server.nrepl/cljs-eval
                                                         shadow.cljs.devtools.server.nrepl/cljs-select]}}}
#2018-01-1913:31theasp@thheller Ahhh! I assumed it was referring to macchiato.cookies, thanks#2018-01-1921:35Alex Hwhat's the best way of building a jar that includes both some backend clojure code (built via the usual lein compile & uberjar) and ideally some shadowcljs-built frontend code?#2018-01-1921:38Alex Hmaybe some sort of first-step build to put things under resources/, and then do the lein build?#2018-01-1921:39Alex Hor is there some better/clever way of doing these things?#2018-01-1921:43thhellershadow-cljs does not yet support building jars so yeah generate the code into some path that is preferably not on the classpath#2018-01-1921:44thhellerthen run lein to generate the jar (can use a profile to add the path to :resource-paths)#2018-01-1921:46thhellerbetter yet don’t put .js files in .jar. instead serve them directly from a directory if possible. otherwise you’ll need to restart the JVM process every time you want to update the .js.#2018-01-1921:47Alex Hsomewhat related - is there a stable API of sorts to call shadowcljs from a nodejs script (e.g. gulpfile), to do the build?#2018-01-1921:47Alex Hother than shelling out, that is#2018-01-1921:47thhellerno JS API available#2018-01-1921:48Alex Hok, that's fair#2018-01-1921:48Alex Hthanks#2018-01-2002:06denik
$ lein with-profile +cljs run -m shadow.cljs.devtools.cli
=>
exception in thread "main" java.lang.UnsupportedClassVersionError: shadow/build/closure/ErrorCollector has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0, compiling:(shadow/build/classpath.clj:1:1)
ideas?
#2018-01-2002:06denikI’ve already upgraded to java 9 and downgraded again#2018-01-2004:06theaspIs it possible to override the hot reload WS URL?#2018-01-2004:08theaspI want to use a reverse proxy#2018-01-2008:24thheller@theasp by default the the websocket uses the url of the page itself + the default port of 9630#2018-01-2008:25thhellerso if you serve the page over the proxy and also proxy 9630 that may work?#2018-01-2008:26thheller@denik hmm I switched to Java9 yesterday. are you on the latest release? maybe that broke older versions which it shoudln’t have#2018-01-2008:31thheller@denik I just published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b1c2d9d0d5dec69cd2dddbc2f1839f819f808287"}, :content ("[email protected]")} which has class file version 52 again. (actually fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "71021910151e065c121d1b0231435f415f404246"}, :content ("[email protected]")}, sorry about that)#2018-01-2012:13larshelgI'm trying out shadow-cljs and its working great so far. However I'm having problems getting the repl working correctly with cursive. I connect to the nrepl using cursive remote configuration. When i try to load a empty namespace its working ok, but when I load a simple namespace with some requires i get: CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec#2018-01-2012:25thheller@larshelg welcome. that sounds like you are maybe loading a ns with (:require ["a-string" ...]) as clojure code instead of cljs?#2018-01-2012:26thhellerswitching between clj/cljs is bit cumbersome in cursive#2018-01-2012:30larshelgHey, thanks for the welcome 🙂#2018-01-2012:30larshelgWell I start up the repl in cursive, the connection seems fine.#2018-01-2012:30larshelgConnecting to rempte nREPL server....#2018-01-2012:31larshelgClojure 1.9.0#2018-01-2012:31larshelgthen i load a simple namespace#2018-01-2012:32larshelgi have to switch from clj to cljs in the repl config bar#2018-01-2012:32thhellerwhen you connect to Cursive the REPL starts out of CLJ. so everything you eval is eval’d as clojure#2018-01-2012:32larshelgtrue#2018-01-2012:32thhelleryou then need to start a build “watch”#2018-01-2012:32larshelgbut i thought it would be enough to switch to cljs in the toolbar....#2018-01-2012:33thhellereither via the command line shadow-cljs watch the-build or via the REPL itself (shadow.cljs.devtools.api/watch :the-build)#2018-01-2012:33thhelleryou then need to switch the nREPL connection itself over to CLJS by selecting which build you want to talk to#2018-01-2012:33thheller(shadow.cljs.devtools.api/nrepl-select :the-build)#2018-01-2012:33thhellerat this point the eval happens in CLJS#2018-01-2012:33thhellerswitching the cursive CLJ/CLJS option only controls the editor part#2018-01-2012:34thhellerit does not interact with the REPL connection itself#2018-01-2012:34larshelgi see, i'll try that then 🙂#2018-01-2012:34larshelgi can sart the cursive repl before the shadow-cljs watch the-build?#2018-01-2012:35larshelgi thought i had to start the watch build first...#2018-01-2012:35thhellershadow-cljs has a server mode which will start the nrepl server#2018-01-2012:36thhellerone way to start the “server” is running shadow-cljs watch the-build#2018-01-2012:36thhellerthat starts the server AND watches the build#2018-01-2012:36thhelleryou can also just run shadow-cljs server or shadow-cljs start#2018-01-2012:36thhellerthat just starts the server and lets you do everything else independently#2018-01-2012:37larshelgi see, so far i only started with shadow-cljs watch "build"#2018-01-2012:37thhellerthat is ok. then the build is already running#2018-01-2012:37thheller(shadow.cljs.devtools.api/nrepl-select :the-build) would be enough then#2018-01-2012:38thhellerthe nrepl can also completely control the server, that is why it starts out as clojure#2018-01-2012:38thhellercolin is working on a REPL rework for Cursive which hopefully makes things a little easier to work with#2018-01-2012:45larshelgAfter running the (shadow.cljs.devtools.api/nrepl-select :server) the repl still complains about not being able to load clojurescript in a clojure repl#2018-01-2012:46larshelgI then try to change to clojurescript in the toolbar and load the namespace#2018-01-2012:46thhellertry something simple like (js/alert "foo")#2018-01-2012:47larshelgthe namespace loades ok, so thats good#2018-01-2012:47larshelgbut when i do a (in-ns 'shadowpusher.core)#2018-01-2012:47larshelgi get Thes i no connected JS runtime#2018-01-2012:48larshelgwhich seems weird, since the watch build is running, and everything else seems fine...#2018-01-2012:48larshelgyeah the alert gives same thing "no connected js runtime"#2018-01-2012:48thhellerno connected runtime means that you have not yet loaded the page in the browser#2018-01-2012:49thhellerwhen building for the browser#2018-01-2012:49larshelgits a node build...#2018-01-2012:49thhelleror started the node process#2018-01-2012:49thhellerif you connect to a build you are responsible for running it#2018-01-2012:49larshelgaha yeah i havent started the node process..#2018-01-2012:49thhelleryou can run shadow-cljs node-repl and (nrepl-select :node-repl)#2018-01-2012:50thhellerthat starts a node process automatically without a specific build#2018-01-2012:51thhellerbut builds do not start any node processes#2018-01-2012:59larshelgits all working now, thanks for the help @thheller#2018-01-2014:36denik@thheller yup downgrading shadow-cljs worked. Will try .137. Thanks!!#2018-01-2015:36theasp@thheller figwheel allows me to set :websocket-url to <wss://example.com/figwheel>, and the proxy sends that URL to figwheel. This way I don't need to make random ports public and can control access in one spot. I'd like to do the same with shadow-cljs#2018-01-2015:37thhellersure I can add that#2018-01-2015:39theaspAwesome!#2018-01-2015:39thhellerthere is just one issue#2018-01-2015:40thhellershould be easily solved if you proxy correctly though#2018-01-2015:40thhellerthe websocket url takes parameters#2018-01-2015:40theaspI don't think they are affected#2018-01-2015:40theaspSente uses paramaters too#2018-01-2015:41thhellerwell the parameters are in the path#2018-01-2015:41thheller#2018-01-2015:41theaspOhh! Yeah, no problem#2018-01-2015:41theasp/ws/*#2018-01-2015:43thhellercan’t remember why I used the path instead of query args#2018-01-2015:44thhellereither way if you set :websocket-url "" and forward /shadow-cljs/* to host:9630 that should be fine#2018-01-2015:44thheller(it also does some XHR requests for file reloading)#2018-01-2016:45thheller@theasp {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfccd7dedbd0c892dcd3d5ccff8d918f918e8c87"}, :content ("[email protected]")} lets you configure :devtools-url "". must be http or https, it will use ws where approriate.#2018-01-2016:45thhelleras long as /* is forwarded to the actual shadow-cljs instance that should work#2018-01-2016:46thhellerwhat are you using as proxy?#2018-01-2016:47thheller:builds {:build {:devtools {:devtools-url ...}}}} that is#2018-01-2016:47thhellerthinking about it I could probably move that to the top level to make things easier#2018-01-2017:10theaspAwesome! TYVM, I'm using nginx. I can give you an example if you want one#2018-01-2017:21denik@thheller trying to eval the ns form into the repl I get
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((:require [rum.core :as rum] ["d3" :as d3])) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses),  Extra input
 #:clojure.spec.alpha{:problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [rum.core :as rum] ["d3" :as d3])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x1f563fb3 "
#2018-01-2017:21denikit’s because of the string "d3"#2018-01-2018:21denik^ this is using proto-repl#2018-01-2019:21theasp@thheller DEVTOOLS: REPL init successful 🙂#2018-01-2019:27theasp@thheller https://gist.github.com/theasp/92b36733846be7dc0ed78840d3a3515a#2018-01-2020:05thheller@theasp neato.#2018-01-2020:06thheller@denik that looks like it might be trying to eval in clojure still. clojure doesn’t support the strings.#2018-01-2020:06thhellerI don’t know much about proto repl#2018-01-2020:36thhellerhmmm just did a quick test. it seems to connect fine but I can’ get it to eval anything#2018-01-2020:36thhellerit sends a bunch of stuff it shouldn’t be sending 😞#2018-01-2020:39cjsauerWhen using the :npm-module target (https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module), is it possible to somehow embed a REPL server into that outputted JS file? I'm trying to embed it into a create-react-app application, and then connect to it from CIDER 🤔#2018-01-2020:40thhelleryes but you need to shadow.cljs.devtools.client.node ns somehow#2018-01-2020:41thhellersince :npm-module doesn’t have clearly defined entries#2018-01-2020:43thhellerrequire("shadow-cljs/shadow.cljs.devtools.client.node") should do it if you are using the default :output-dir#2018-01-2020:43thhellereg. in the generated index.js#2018-01-2020:44thhellercreate-react-app makes things a bit tricky since its using ES6 import which can’t be conditional#2018-01-2020:44thhellerotherwise I’d recommend wrapping the require in the usual process.env.NODE_ENV check#2018-01-2020:45cjsauerAh ok. Maybe code splitting could help here? https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting#2018-01-2020:46cjsauerI'm actually setting :output-dir to node_modules/shadow-cljs#2018-01-2020:46cjsauerTo gain access to it using require#2018-01-2020:47thhellerI’d recommend just rewriting the index.js to require#2018-01-2020:48thhellerit has been a while since I messed with CRA#2018-01-2020:48thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/cljs-react-app#2018-01-2020:48cjsauerYou mean add require("shadow-cljs/shadow.cljs.devtools.client.node") to App.js?#2018-01-2020:48thhellerhttps://github.com/thheller/shadow-cljs-examples/blob/master/cljs-react-app/src/index.js#2018-01-2020:48thhellerthats what I did back then#2018-01-2020:49thhelleroh wait right .. not the node thing. require("shadow-cljs/shadow.cljs.devtools.client.browser");#2018-01-2020:49cjsauerThose links are great, thank you. I see you also set :runtime to :browser#2018-01-2020:50cjsauerIn the shadow-cljs.edn file#2018-01-2020:51thhellerCRA was the first project I used as a proof of concept for the integration#2018-01-2020:51thhellerhttps://www.youtube.com/watch?v=BLDX5Twt2zk#2018-01-2020:51thhellerMay 21, 2017 … lots has changed since then#2018-01-2020:53thhellerand the live reloading of CRA often completely messed up the REPL#2018-01-2020:53thhellernot sure if that situation improved on the CRA side#2018-01-2020:55justinleeis there a doc somewhere that explains what shadow-cljs is doing? you mentioned transpilation in the other thread. i’ve just gotten my head around why we have externs and how to avoid them with cljs-oops but it sound like shadow is doing something else. (the docs on how to use shadow are great, btw, kudos, i just like to have an idea of what the tool is actually doing)#2018-01-2020:55thhellerwrote a whole series about Js dependencies here https://code.thheller.com/#2018-01-2020:56justinleenice thanks. this looks like it was written for me 🙂#2018-01-2020:56thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2018-01-2020:58cjsauer@thheller once I have shadow.cljs.devtools.client.browser loaded, how would I start a REPL client? Something like: shadow-cljs cljs-repl?#2018-01-2020:58thhelleryes, wrote a whole section about that a few hours ago https://shadow-cljs.github.io/docs/UsersGuide.html#_clojurescript_repl#2018-01-2021:15cjsauerHmm...I keep getting this:
[3:1]~cljs.user=> (js/alert "test")
There is no connected JS runtime.
#2018-01-2021:15cjsauerI tried running shadow-cljs cljs-repl dev (my build id is "dev")#2018-01-2021:17thhelleryeah that means that the browser did not connect#2018-01-2021:17thhelleryou should see a connect message when you open the browser console#2018-01-2022:03cjsauerHm...still no luck. Once I have required shadow.cljs.devtools.client.browser in index.js, is there any function I need to call to actually "start" it? Or is the act of requiring it enough?#2018-01-2022:07cjsauerHere's what I'm working with: https://github.com/cjsauer/perfect-storm'#2018-01-2022:31cjsauerLooks like maybe there is a flag that must be enabled? https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L329#2018-01-2022:31thhelleryeah .. its completely broken#2018-01-2022:32thhellerjust fixed that part but the rest still doesn’t work#2018-01-2022:42thhelleropened https://github.com/thheller/shadow-cljs/issues/182 … will take a look tomorrow#2018-01-2022:42cjsauerSounds good. Thanks for the help @thheller#2018-01-2022:43thhellercouldn’t find an easy fix.#2018-01-2022:43cjsauerI wish I understood this sort of stuff better so I could help out 😕 Compilers are still kind of magic to me haha#2018-01-2022:49thhellerany particular reason you want to use create-react-app?#2018-01-2022:50thheller:npm-module works ok but the REPL is never going to be reliable anyways given the amount of stuff webpack does to the code#2018-01-2022:51cjsauerWell, my team is primarily JS guys, and they all use create-react-app. I'm looking for a good way to introduce ClojureScript to the team, but in a really seamless way that doesn't interrupt their workflow too much. I figured if I could at least jack a REPL in, I'd be able to preserve both workflow styles pretty well...#2018-01-2022:51cjsauershadow-cljs seems like a really promising tool for integration projects like the ones we face#2018-01-2022:52thhelleryeah thats what :npm-module was supposed to achieve, which it sorta does until you launch a REPL 😉#2018-01-2022:52cjsauerhehe, I'm excited to see it working. There's some really interesting workflows hiding in the JS/CLJS pairing#2018-01-2022:54thhellerREPL definitely works way better when shadow-cljs is in control and its JS doesn’t get rewritten by something else#2018-01-2022:54thhellerwe’ll see if I can fix it tomorrow. I’m not actually sure it ever worked properly beyond basic (js/alert "foo") 😉#2018-01-2023:01cjsauercool, I'll keep an eye on the repo 👍#2018-01-2021:02thheller@lee.justin.m I can go into technical details if you’d like. I mostly left those out and focused more on the “why”#2018-01-2021:02thhellerbut in essence it is doing the exact same thing webpack and others are doing#2018-01-2021:06justinlee@thheller My basic curiosity is that I’m a javascript programmer. Things like webpack and minification and babel all screw with the code and seem to be able to do so without breaking everything. So far I’m a little curious and terrified that certain kinds of innocuous code (.field js/thing) can be broken so easily. How do other tools do it? So my interest in (1) the practical, which so far has been: use cljs-oops for all external accesses and (2) learn about different approaches people are taking. It seems like you are doing something different in shadow to make interop safer (?). At any rate I just have a general technical curiosity here. No specific burning need.#2018-01-2021:08thhellerI don’t recommend using cljs-oops at all. shadow-cljs has greatly improved externs inference support which has elimitated the need for almost every extern I used before#2018-01-2021:08thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html#2018-01-2021:09thhellerbasically I run everything with :infer-externs :auto these days#2018-01-2021:09thhellervery occasionally I add a typehint#2018-01-2021:09thhellerthings like (.field js/thing) are fully inferred#2018-01-2021:15justinleeRegarding this: We only need externs for the code we actually call from CLJS, not everything the JS code uses. That suggests that over-specifying externs keeps code in that might otherwise be elided. Does GCC do DCE on npm modules? I thought the whole idea is that the compiler won’t do advanced optimizations on npm modules and the externs are a directive to the compiler not to name mangle those symbols in optimized code.#2018-01-2021:16thhellerno, shadow only does :simple for everything on node_modules.#2018-01-2021:16thhellerbut the CLJS/goog parts still run through :advanced#2018-01-2021:16thhellerso at the interop points you need externs#2018-01-2021:16thhellerbut since shadow now knows more about those interop points due to the requires in ns and such#2018-01-2021:17thhellerit can do better externs inference for those#2018-01-2021:18justinleeI was just trying to figure out why exactly too many externs increases code size.#2018-01-2021:18thhellerthe increase is minimal#2018-01-2021:18thhellerbut say you have createThing defined somewhere in the externs#2018-01-2021:19thhellerthe closure compiler will now protect that name whenever it can’t exactly identify which type it is on#2018-01-2021:19thhellersince CLJS is untyped that basically means always#2018-01-2021:19thhellerso createThing will never be shortened or removed, even if it could be otherwise#2018-01-2021:20justinleeit doesn’t really matter i guess but given that the javascript module is going through :simple optimizations i was think that createThing couldn’t ever be renamed or removed anyway#2018-01-2021:21thhelleryes, only very basic code removal is done for node_modules#2018-01-2021:22thhellerbut CLJS is still fully :advanced optimized so it could be removed there (in case it exists)#2018-01-2021:22thhellerthe goal is to run everything through :advanced at some point#2018-01-2021:22thhellerthats what CLJS tries to do .. but it just isn’t reliable enough yet.#2018-01-2021:24justinleeThis great stuff. I’m going to read through your stuff before I ask you any more questions. 🙂#2018-01-2021:25thhellermost of it should be covered in some form#2018-01-2021:25thhellerfeel free to ask though. always helps to validate that I’m not doing crazy things 😉#2018-01-2021:27justinleeI do have one other question, which is actually about DCE. Do you know if the symbol munging thing is necessary to do DCE? I’ve often wondered if we could just turn on DCE without the symbol munging and get some stuff for free.#2018-01-2021:27thhellerthe munging no but the collapse#2018-01-2021:28thhellerin CLJS (or closure) everything is namespaced#2018-01-2021:28thhellerso if you have (ns demo.app) (defn foo [])#2018-01-2021:28thhelleryou get a demo.app.foo = function() {} basically#2018-01-2021:29thhellerclosure collapses this down to demo$app$foo so it can remove the nested objects#2018-01-2021:29thhellerthis collapse is necessary for DCE (AFAIK)#2018-01-2021:30thhellerthe rename then just shortens it down to something like xA (or removes it entirely)#2018-01-2021:30thhellerthe closure compiler has some options that let you fine tune what it does to the code#2018-01-2021:31thhellerdisabling variable renaming or property renaming is an option#2018-01-2021:31thhellerbut if you disable too much you basically end up at :simple#2018-01-2021:31thhellerwhich is still better then uglifyjs but nowhere near :advanced#2018-01-2021:32justinleei see#2018-01-2021:33thhellerclosure is already pretty good at optimizing ES6. it just struggles with some dynamic CJS things people do#2018-01-2021:34thhellerhopefully more JS people will begin publishing more ES6 code#2018-01-2021:34thhellerslow procress I guess if node can’t even decide how to do proper es6 interop#2018-01-2021:38justinleeit would be interesting if you could do static analysis on a body of code to try to see if code was already safe for advanced optimization. you’d get a lot of false positives, but it might be able to show you everywhere something dangerous is happening (e.g. string property access)#2018-01-2021:40thhellerwell you can always set :js-provider :closure and see if you code still works. that does :advanced for everything. if it doesn’t go back to :shadow.#2018-01-2021:40thhellerfull analysis might be painful given the dynamic nature of JS#2018-01-2021:42justinleeyea it would probably not work in a lot of cases, but it would be awesome if you could use babel or something to provide certainty that a module is safe for compilation#2018-01-2021:42justinleeanyway, i don’t even understand what the hell is going on at any level so that’s just a pipe dream#2018-01-2021:42thhellerunfortunately babel is responsible for some of the breakage 😉#2018-01-2021:45thhellerdoing what webpack and babel do however seems to be the safest way to deal with node_modules so I’m doing that#2018-01-2021:47justinleewell i’m interested to dig in. so far the safest route for using modules for me has been to use distribution builds with no externs and run all accesses through cljs-oops.#2018-01-2021:50thhellerif you like cljs-oops by all means keep using it and reduce it gradually maybe#2018-01-2021:50justinleeoh i’m not wedded to anything, but cljs-oops is better than relying on some half assed broken not up to date externs file that someone made 3 years ago#2018-01-2021:51thhellerindeed#2018-01-2021:51thhellerbetter yet use :infer-externs :auto and let the compiler tell you if it doesn’t unterstand something#2018-01-2021:51thhellerwhether you then use ^js typehint or cljs-oops as the fix is up to you#2018-01-2116:20mhuebert:infer-externs :auto with occasional ^js typehints works really well. I use a lot of JS libs, and it’s become extremely rare to hit a problem. JS interop with :advanced compilation used to be my #1 complaint with writing real-world clojurescript — frequent, painful, manual hunting of obscure bugs, interrupted by multiple-minute recompile times — and that whole experience is just gone now. I see an immediate warning whenever something should be hinted, I add a ^js somewhere, and just keep coding.#2018-01-2117:47hlolliI'm trying to add a foreign js lib
:builds {:app {:js-options {:resolve {"libcsound" {:target :file
                    :file "resources/libcsound.js"}}}
(:require ["libcsound"]))
The required JS dependency "libcsound" is not available, it was required by "csound_wasm/core.cljs"
Something I'm not doing right, tried :target :npm and :require instead of :file. Same error.
#2018-01-2119:02thheller@hlolli what is the :target?#2018-01-2119:02thheller:resolve currently only works when using :shadow as js provider (eg. for :browser)#2018-01-2119:02hlolli:node-library#2018-01-2119:04thheller:node-library just directly delegates to node require so we can't influence what that does directly#2018-01-2119:04thhelleryou might be able to include it with a relative path#2018-01-2119:04thheller(:require ["./libcsound" :as x]) with the file just next to the .cljs file#2018-01-2119:05thhellerhmm nah that probably won't work either#2018-01-2119:05thhellerspent so much time on the browser stuff I never really got to any of the node things#2018-01-2119:06hlolliok that's no problem, I fall back to js/require works fine 🙂
#2018-01-2119:07thhellerah no relative might work#2018-01-2119:07thhelleralthough it will likely try to compile with with closure which will most likely blow up#2018-01-2119:08thhellerso yeah js/require might be the safest option#2018-01-2119:08hlolliok, yes I think the relative works relative to the cljs source file "../../../" pattern#2018-01-2119:08hlolliI stay with js/require !#2018-01-2119:12thhellerI opened this a while ago but didn’t get to it yet since I’m not sure how to resolve it properly. https://github.com/thheller/shadow-cljs/issues/131#2018-01-2120:04hlolliof curiousity, you think that a node-library will perform better or worse in cljs-land when the compiled js-file is required or the original cljs source code is requried?#2018-01-2120:16lilactownbtw @thheller you have been an awesome help over the last few days. really appreciate you taking the time to help through some of these issues I’m having#2018-01-2120:17thheller@hlolli not sure I understand the question? cljs source code?#2018-01-2120:18thheller@lilactown np. a few people have been using shadow-cljs with macchiato already and I still want to look at the template and create one for shadow-cljs#2018-01-2120:19thhellerhere is one project that might help https://github.com/mjmeintjes/shadow-cljs-macchiato#2018-01-2120:21lilactownwonderful. this confirms my suspicions about how figwheel reloads vs. shadow-cljs#2018-01-2120:22thhellerthe only problem was that macchiato does not properly declare the npm packages it depends on#2018-01-2120:23thhellerand it uses the old style js/require calls so you only get those errors at runtime#2018-01-2120:23thhellerif it complains about cannot find module ’cookies` just npm install cookies#2018-01-2120:23thhellercan’t remember which packages were needed exactly#2018-01-2120:24lilactownah yeah. ran into one dep that the cuerdas library needed, but other than that I’ve been able to run it just fine. just working on hot loading#2018-01-2120:19hlolliIm creating a node-module in cljs code for js users, but I can theoretically use that library im creating in cljs as well. Then I'm just wondering if it's worth releasing .jar and npm package, or is npm package fast enough that it wont make a difference.#2018-01-2120:20thhellerits definitely better to use CLJS code directly instead of the compiled output#2018-01-2120:29lilactownquestion, since I’m not familiar with what-all-does-what yet: macchiato uses mount to “manage state” (still not exactly clear on what that means in context). would it make sense to use mount to manage the web server?#2018-01-2120:29lilactowne.g. instead of storing a reference to the http/server obj in an atom, setup mount to manage start/stoping#2018-01-2214:05Jakub Holý (HolyJak)yes. we use luminus-generated cljure server code and that is how it uses mount#2018-01-2120:30thhellerno idea what mount does either sorry#2018-01-2120:30lilactown😂 ok, I’ll just use an atom for now#2018-01-2120:30thhellerfrom the template it looks like figwheel doesn’t bother with restarting the server at all#2018-01-2120:30thhellerwhich might work but node it notorious for keeping some state in some function closures somewhere#2018-01-2120:31thhellerthat state wouldn’t get reloaded properly#2018-01-2120:31lilactownyeah I’m pretty confused about that actually#2018-01-2120:32lilactownwhen I tried to just drop in the core/server fn to :after-load, it complained that a server was still running on the port#2018-01-2120:32lilactownbut the code did reload#2018-01-2120:33lilactownso I kind of assumed that figwheel was doing some kind of figgy magic to reload the server, but I really don’t know#2018-01-2120:33thhellerI can’t find any reference in the template to any figwheel reload hook#2018-01-2120:33thhellerso its probably just dumping in new code and hope that it works ok?#2018-01-2120:34lilactownyeah ¯\(ツ)/¯#2018-01-2120:34lilactownI think I actually would rather not restart the HTTP server, since that might clear out my session state#2018-01-2120:34lilactownbut maybe the mount magic handles that…#2018-01-2120:35thhelleryou don’t have to call stop/start, its just a recommendation#2018-01-2120:35Alex H@lilactown fwiw, I use mount on the backend side exactly for that#2018-01-2120:36Alex H@lilactown 3 components - http server (with immutant), an nrepl server, and a hikariCP instance for the database#2018-01-2120:36Alex H@lilactown you can get it to not do anything on a namespace reload, for example - or you can tell it to stop and start the server - depending on what you want#2018-01-2120:37Alex H(to be clear, that's with clj, not cljs on the backend, though)#2018-01-2120:39Alex Hbut mount should behave about the same#2018-01-2120:41lilactowngotcha#2018-01-2120:42lilactownI’ll probably set mount up to keep track of the HTTP server as well then#2018-01-2120:42lilactownit does look like it clears out my session state when I restart the HTTP server, though. which means I don’t want to restart on each hot reload#2018-01-2120:43Alex H(defstate ^{:on-reload :noop} ....) should do what you want#2018-01-2120:44thhellernot sure where the session state is kept but you can probably store it somewhere and re-attach on restart#2018-01-2120:44thhellerbut should be fine to just not restart the http server if that works for figwheel#2018-01-2120:46thhellerif you dont’ want to use the the :before-load and :after-load callbacks just set :autoload true#2018-01-2120:50lilactownI’m not able to see my changes to e.g. routes.cljs when I set :autoload true#2018-01-2120:51thhellerdoes it work in fighweel?#2018-01-2120:52thheller
(def routes
  ["/" {:get home}]
#2018-01-2120:52lilactownit does 😵 I set up a repo: https://github.com/Lokeh/shadow-cljs-macchiato#2018-01-2120:53thhellerhow do you add a route?#2018-01-2120:54lilactownhttps://github.com/Lokeh/shadow-cljs-macchiato/blob/master/src/server/routes.cljs has the routes definition and https://github.com/Lokeh/shadow-cljs-macchiato/blob/master/src/server/core.cljs has the http server that creates the handler for the routes#2018-01-2120:57thhellerso the server.core keeps a reference to the router. :handler (wrap-defaults router) this won’t be reloaded.#2018-01-2121:01lilactown🤔 I wonder how figwheel is reloading it then#2018-01-2121:02thhellertrying to figure that out right now 🙂#2018-01-2121:02thhellerI think its this call (mount/in-cljc-mode)#2018-01-2121:03thhellerhmm nope that does nothing#2018-01-2121:04lilactownI think it’s re-running the require’s at the top of app.cljs#2018-01-2121:04lilactownI say, with all the authority of someone who’s done CLJS for 3 weeks#2018-01-2121:05thheller^:figwheel-always seems to be used to force reload the .app ns always#2018-01-2121:05thhellerbut it doesn’t do anything, the requires won’t be done again#2018-01-2121:21lilactownOK, how could we set it up so that server.core doesn’t keep a reference to router?#2018-01-2121:25thhellerstill trying to figure out what figwheel does that I don’t#2018-01-2121:37thhelleroh wait you set :autoload true in the build config. that still needs to be in :devtools {:autoload true}#2018-01-2121:39thhellerit appears to work otherwise#2018-01-2121:47lilactown😑 jeeze#2018-01-2121:48lilactownyou’re right. it works just like figwheel when I make that change#2018-01-2121:48lilactownthanks for going with me on this wild goosechase 😅#2018-01-2207:36robert-stuttaford@thheller does shadow provide npm-deps to gclosure to be included in dead-code elimination and other whole program optimisations as described here? https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules#2018-01-2208:10thhellerit can yes but not by default#2018-01-2208:11thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2018-01-2208:11thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2018-01-2208:11thhellerhas some background on why it doesn’t by default#2018-01-2208:13thhellerbascially set :js-options {:js-provider :closure} and see if your build still works#2018-01-2208:13thhellerif yes great, it no set it back to :shadow 😉#2018-01-2208:13thhellerat this point I’d say the chances are less than 50% .. way too many incompatible packages#2018-01-2209:42robert-stuttafordok - i’ll give it a spin 🙂 thanks!#2018-01-2211:43mhuebert@thheller picking up on an old thread, I got maria building on circleci w/ shadow-cljs: https://github.com/mhuebert/maria/blob/master/.circleci/config.yml (finally got a docker image with java + node + git working.) I ran into weird issues where my circleci would stop build commands in the middle of what they were doing, and call them “successful”. no idea yet what the cause was. i was able to “get it to work” by breaking things up into smaller commands (hence server/start, then three independent server/release commands) but i am not convinced it will be reliable until i find out what was happening there.#2018-01-2213:40thheller@mhuebert npx shadow-cljs start shouldn’t need the background option. it will exit when the server has finished starting. at least in theory.#2018-01-2213:42thhellerI started setting up circleci for shadow-cljs itself too. still need to actually run something though. https://github.com/thheller/shadow-cljs/blob/master/.circleci/config.yml#2018-01-2213:46mhuebert@thheller hmm, i thought the problem was that circleci would somehow cause that process to exit without the background option#2018-01-2213:47mhuebertbut i don’t fully understand it#2018-01-2213:48thhellerhmm from what I understand from the docs the background will just run the process itself in the background#2018-01-2213:48thhellerbut the node process that starts the process itself will exit anyways#2018-01-2213:48thhellerand only waits until the server is started#2018-01-2213:49thhellerso that process does not run in the background, it starts a process that runs in the background by itself#2018-01-2213:57Jakub Holý (HolyJak)Why does the guide [1] say "node 7.0.0+" while the npm package [2] says "6.0.0+"? Who is wrong? [1] https://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code [2] https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/package.json#L24#2018-01-2214:01thhelleroops, the guide#2018-01-2214:01thheller@mhuebert maybe if you combine background with npx shadow-cljs server that works? (instead of start)#2018-01-2214:02thheller@holyjak to be honest the most recent version is always preferred and I don’t actually know the minimum version. I know some code breaks when using node v5#2018-01-2214:02thhellerthats why it has v6 as minimum#2018-01-2214:03mhuebert@thheller maybe what i really need to do is figure out why i can’t just run everything in a single shadow-cljs clj-run maria.build/release.. i don’t see any real reason why i should have to run these commands separately#2018-01-2214:03mhuebertand how they are being abruptly stopped and circleci declaring that a success#2018-01-2214:05thhellermaybe the logfile in target/shadow-cljs has some clues?#2018-01-2214:05mhueberti’ll try that later today#2018-01-2214:06mhuebertdo another build and ssh in#2018-01-2214:06thhellerbut yeah the release fn should work fine#2018-01-2214:06thhelleralthough if that is all you do https://github.com/mhuebert/maria/blob/master/editor/src/maria/build.clj#2018-01-2214:06thhelleryou can just run npx shadow-cljs release live trusted bootstrap#2018-01-2214:16mhuebertyeah, i only created the build script as part of the debugging, to see if it made a difference#2018-01-2214:16mhueberti was using that command earlier#2018-01-2214:16mhueberteither way, the process exits#2018-01-2214:16mhuebertat unpredictable times and without any message in the circleci logs#2018-01-2214:19hlolli wow, very nice site! I have handful of people I could recommend this to 🙂 @mhuebert#2018-01-2214:20mhuebert@thheller here is the circleci log for an example of the problem: https://circleci.com/gh/mhuebert/maria/322#2018-01-2214:20mhuebertif you click on the pwd; ls; cd editor; npm install; npm run release; command#2018-01-2214:20mhuebertit shows up as green,#2018-01-2214:21mhuebertbut it ended itself just after beginning the :bootstrap build. this is the very end of the log:
[:bootstrap] Compiling ...
-> Converting 31 JS sources
<- Converting 31 JS sources (3215 ms)
-> JS Cache write: 31 JS files
<- JS Cache write: 31 JS files (70 ms)
-> Compile CLJS: cljs/core.cljs
<- Compile CLJS: cljs/core.cljs (15735 ms)
#2018-01-2214:21thhellerhmmm#2018-01-2214:22thhellernow I remember. running the builds in parallel wasn’t great with circleci#2018-01-2214:24thhellerbut yeah thats not parallel. no idea why it would exit#2018-01-2214:24mhueberthere is an example where I put npx shadow-cljs start into a command (without background: true), then ran subsequent builds - https://circleci.com/gh/mhuebert/maria/325 the build after shadow-cljs start:
#!/bin/bash -eo pipefail
cd editor; npm run release;

> @ release /root/project/editor
> rm -rf public/js/bootstrap; shadow-cljs clj-run maria.build/release;

shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
#2018-01-2214:24robert-stuttafordcircleci’s VMs are pretty constrained. we switched to using our own instances with https://buildkite.com - clojure / cljs builds need lots of cpu#2018-01-2214:36mhuebertthat may indeed have sth to do with it#2018-01-2214:38mhuebertlooks like buildkite offers free accounts for open source, so may be a good fit for maria#2018-01-2214:57robert-stuttafordwell worth a try 🙂#2018-01-2214:25thheller@mhuebert if you use background try server instead of start so circleci can take back of backgrounding the process#2018-01-2214:25thhellerinstead of letting the node script do that#2018-01-2214:26thhellerwhat happens if you just run npx shadow-cljs release bootstrap and the other 2 builds after each other without the server?#2018-01-2214:27thhellerjust let it start 3 times?#2018-01-2214:28mhuebert@thheller I can’t remember if i tried that#2018-01-2214:28mhueberti will try using server instead of start#2018-01-2214:29mhueberthmm#2018-01-2214:30thhellermaybe as the last command just cat target/shadow-cljs/shadow-cljs.log.0 just in case#2018-01-2214:30mhuebertcircleci’s docs say: The background attribute allows for executing commands in the background. In this case, job execution will immediately proceed to the next step rather than waiting for the command to return.#2018-01-2214:32thhelleryeah probably need to sleep for a bit#2018-01-2214:32mhuebertfor the cache key, do you think v1-dependencies-{{ checksum "editor/package.json" }}--{{ checksum "editor/shadow-cljs.edn"}} would be sufficient#2018-01-2214:33mhuebertie. package.json + shadow-cljs.edn#2018-01-2214:34mhuebertam wondering how long to sleep for, if dependencies have changed it might take longer for the server to start?#2018-01-2214:34thhellerhmm true. no idea. start is supposed to solve that#2018-01-2214:34thhellersince it exits when the server is started#2018-01-2214:35mhueberti will try that again#2018-01-2214:36jgdaveyI’ve got an interesting issue. We’re using hiccup-like syntax for shared views in .cljc files, and it works with both server- and client-rendered libs. In one particular form field, :phone_number, the input’s name attribute is set to phone_number in development mode (watch), but after doing a shadow-cljs release, that field becomes phone-number. Other underscored field names seem to be unaffected.#2018-01-2214:37mhueberttried using start again and got the same,
shadow-cljs - config: /root/project/editor/shadow-cljs.edn version: 2.0.139
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server
Exited with code 1
#2018-01-2214:37mhuebertwill try now not using the server at all#2018-01-2214:39thheller@jgdavey no idea? shadow-cljs definitely never rewrites strings/keywords in any way? what does the code do?#2018-01-2214:39jgdavey(I’m using the latest version of shadow-cljs, and have tried dumping caches, etc)#2018-01-2214:40jgdaveyIt’s hiccup-style view code. I’ll dig further into our libs, but the fact that it acts differently between dev/release seemed odd#2018-01-2214:41thhellerAH!#2018-01-2214:41thhelleryeah .. doh … so in shadow-cljs release keywords are optimized#2018-01-2214:42thhellerso they are only allocated once#2018-01-2214:42thhellerso it replaces the new cljs.core.Keyword(null, "phone_number", hash, meta) calls with cljs$cst$kw$phone_number variables#2018-01-2214:43jgdaveyAh, interesting. But wouldn’t :phone-number be different than :phone_number?#2018-01-2214:43thhellerBUT if you have :phone_number AND :phone-number in your code the normalized JS variable name replace each other#2018-01-2214:43thhellersince - is just replaced by _ blindly#2018-01-2214:43jgdaveyInterestingl…#2018-01-2214:44thhellerlet me fix that damn munge function from closure#2018-01-2214:44jgdavey🙂#2018-01-2214:45jgdaveyCool. Everything else’s been working great, in prod. First issue we’ve hit with optimized js#2018-01-2214:45mhuebert@thheller ok, i think i will just abandon the server idea. for deploy I just want something as reliable as possible and a few extra seconds isn’t so important#2018-01-2214:47thheller@mhuebert I’ll try to figure out whats going on. I need it for shadow-cljs CI itself, just first need to figure out the npm side of things since I can’t npm install shadow-cljs there#2018-01-2214:51thheller@jgdavey should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f7849f96939880da949b9d84b7c5d9c7d9c6c3c7"}, :content ("[email protected]")}#2018-01-2214:51jgdaveyThat was quick 🙂#2018-01-2214:52mhuebert@thheller i added that cat log command. are any of these “waiting for…” messages significant? https://circleci.com/gh/mhuebert/maria/335#2018-01-2214:52thhellerfunny enough I fixed that issue once before in CLJS itself. https://dev.clojure.org/jira/browse/CLJS-1105 😉#2018-01-2214:53thheller@mhuebert not really. its just the parallel compile waiting for other files to compile first#2018-01-2214:53jgdavey@thheller Nice work. 🙂 Thanks again!#2018-01-2214:53thhellerthey will timeout eventually but it will log the abort#2018-01-2214:55thheller@mhuebert what is odd is the number of logs. there should be more than <number of cpu cores> log messages#2018-01-2215:01mhuebert@thheller weird, i just tried a new deploy after clearing the caches, and after everything ran successfully it said:
#!/bin/bash -eo pipefail
cat target/shadow-cljs/shadow-cljs.log.0
cat: target/shadow-cljs/shadow-cljs.log.0: No such file or directory
Exited with code 1
#2018-01-2215:03thhellerhmm guess there was nothing to log? the file is created lazily on the first log output#2018-01-2215:03mhuebertah ok#2018-01-2215:07mhuebertnow it will try printing the log if the build failed & do nothing if the log doesn’t exist:
- run:
          command: cat target/shadow-cljs/shadow-cljs.log.0 2> /dev/null
          working_directory: ~/project/editor
          when: on_fail
#2018-01-2221:52lilactownis there a way to get lein’s “checkouts” functionality working with shadow-cljs?#2018-01-2222:07Jakub Holý (HolyJak)@thheller typo in 7.1.2 of the guide: «Add start/top hook functions.»#2018-01-2222:43Jakub Holý (HolyJak)Also «Adding hooks for hot core reload.»#2018-01-2223:27thhellerthx. fixed.#2018-01-2223:25thheller@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integration#2018-01-2300:15lilactownI’m using the lein integration, and I’m not seeing my dependency in checkouts reload#2018-01-2300:31lilactownif I run lein install and restart the build watcher, it picks up my changes. but adding it to checkouts does not pick up my changes#2018-01-2300:32lilactowneven when I restart the build watcher#2018-01-2308:19thheller@lilactown shadow-cljs by default reloads files on the classpath that are not in jars. so checkouts should be reloaded. however for some reason lein does not always put checkouts paths on the classpath. I think the version of your :dependencies of the lib has to match the actual version of the lib. check if lein classpath lists the path correctly. should be before the actual .jar.#2018-01-2313:55thhellermade a quick demo for storybook.js in case someone is interested in using that. https://clojureverse.org/t/using-storybook-with-cljs/1495#2018-01-2317:24lilactownwhat is shadow.markup.react?#2018-01-2317:51lilactownI’m interested since I’m working on creating a styled component-like lib using emotion atm#2018-01-2318:06thhellersmall CSS-in-CLJS lib I use in my projects. https://github.com/thheller/shadow/wiki/shadow.markup#2018-01-2318:11lilactownwow, this is awesome!#2018-01-2314:16robert-stuttafordplease tweet so i can RT @thheller 🙂#2018-01-2315:48thhellerhttps://twitter.com/thheller/status/955829473382891520#2018-01-2320:29lilactownis there a way to set the default namespace for the REPL?#2018-01-2320:39thhellernot currently no#2018-01-2407:02tony.kay@thheller Not sure how far you are on the HUD, but I noticed that macro errors don’t show in the HUD (only at the CLI). It would also be nice to see the hot reload as an indicator like figwheel does as well…lets you know when you should expect a UI change. Sometimes you don’t know if you failed to make the change correctly, or if the thing is still compiling. A little more browser feedback would be really helpful. The compiler feels a lot more solid, but those little feedback bits really hurt the real-time experience for me (I have to leave a console open instead, which takes valuable screen space). As far as how the HUD looks: I think it’s fine. Yeah, it’s not as pretty as figwheel, but it’s just as useful (if macro errors showed up as well)#2018-01-2407:07tony.kay😜#2018-01-2407:39robert-stuttafordhaha i like the kapow suggestion#2018-01-2409:08thhellerplanned on doing the tools.deps integration today#2018-01-2409:09thhellercan maybe do some HUD work#2018-01-2409:21Jonhttps://github.com/shadow-cljs/shadow-cljs.org/issues/2#2018-01-2412:36thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6f1c070e0b0018420c03051c2f5d415f415e5b5c"}, :content ("[email protected]")} has experimental support for deps.edn. requires a very recent version and still has a couple problems but sort of works.#2018-01-2412:36thhellerjust add :deps {:aliases [:test :foo]} to shadow-cljs.edn if you want to try#2018-01-2412:36thhellerwill update docs later#2018-01-2412:58mhueberti’ve started seeing things happening locally like this:
[2018-01-24 13:55:44 - WARNING] TCP Port 9630 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9631 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9632 in use.
[2018-01-24 13:55:44 - WARNING] TCP Port 9633 in use.
[2018-01-24 13:55:53 - WARNING] :shadow.cljs.devtools.server.dev-http/start-error resources/public 8700 #error {
 :cause Address already in use
 :via
 [{:type java.lang.RuntimeException
   :message java.net.BindException: Address already in use
   :at [io.undertow.Undertow start Undertow.java 214]}
  {:type java.net.BindException
   :message Address already in use
   :at [ bind0 Net.java -2]}]
#2018-01-2412:59mhueberteven when I’ve quit all existing processes as best as I can tell#2018-01-2413:01mhuebertjust now I went into Activity Monitor and force quitting all the main processes seemed to work#2018-01-2413:03mhuebertit looks like one of the same issues we had on circle:
> shadow-cljs start; shadow-cljs clj-run web3.build.build/reset-asset-paths;shadow-cljs watch browser;

shadow-cljs - config: /Users/MattPro/Documents/sites2017/web3/shadow-cljs.edn version: 2.0.142
shadow-cljs - server starting ..................................................................................... ready!
shadow-cljs - config: /Users/MattPro/Documents/sites2017/web3/shadow-cljs.edn version: 2.0.142
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server
#2018-01-2413:03mhueberta command like shadow-cljs start; shadow-cljs clj-run _SOMETHING_; shadow-cljs watch browser seems to be problematic#2018-01-2413:04mhuebertand manually quitting processes becomes necessary#2018-01-2413:12thhellerodd#2018-01-2413:13thhellerwill look into it. maybe ; messes with the backgrounding of the process somehow#2018-01-2413:13thhelleris that on linux?#2018-01-2413:18thheller
$ shadow-cljs start; shadow-cljs clj-run test.foo/bar; shadow-cljs watch npm
shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
shadow-cljs - server starting ........................................... ready!
shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
shadow-cljs - connected to server
:bar


shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
shadow-cljs - connected to server
shadow-cljs - watching build :npm
[:npm] Configuring build.
[:npm] Compiling ...
#2018-01-2413:30thhellersame result on macOs and linux. no idea why any of it would fail.#2018-01-2415:34thheller@mhuebert I now have this reproduced in circleci#2018-01-2415:34thhellerhttps://github.com/circleci/circleci-docs/issues/1037#2018-01-2415:34thhellerhttps://circleci.com/gh/thheller/shadow-cljs/90#2018-01-2415:35thhellerno idea what the cancel means yet but thats the issue I guess#2018-01-2415:38thhellerhttps://discuss.circleci.com/t/step-was-canceled-with-background-true-server-google-cloud-pub-sub-emulator/19569#2018-01-2415:38thhellerlooks like a circleci thing#2018-01-2416:48thhellerfrom what I can tell the client just fails to connect to the tcp socket#2018-01-2416:48thhellerwhen I run the build with ssl I can open the port just fine#2018-01-2417:05thhellergot it to work it seems#2018-01-2417:05thhellerhttps://circleci.com/gh/thheller/shadow-cljs/99#2018-01-2417:06thhellerno idea why the added curl fixes it and why that says App not ready. start should only return once the cli-repl.port exists which is written AFTER all the servers were started.#2018-01-2417:07thhellerso it really doesn’t make sense to me what is going on#2018-01-2417:15thhellerhttps://circleci.com/gh/thheller/shadow-cljs/101 without curl but still sleep 1 after start. I give up figuring out why this is required.#2018-01-2419:47mhuebertSorry - was afk. The stuff I posted this morning was on my mac#2018-01-2420:41thheller@tony.kay just watched a bit of your fulcro workflow vid and couldn’t help but notice a lot of dead UI in intellij where figwheel is running. if you were to run shadow-cljs watch build in IntelliJ Terminal (or from REPL) in that place instead you’d get warnings there.#2018-01-2420:42thhellerfinished a few tweaks to the HUD too though. no Kapow! though.#2018-01-2420:45thhellerthats my setup usually#2018-01-2420:46thhellerHUD is nice too but mine needs work 😉#2018-01-2421:33thheller@mhuebert the only thing I can think of for your process issue is that something wipes out the target/shadow-cljs directory so you keep starting new instances since the old port info is gone. do you run lein clean or similar things by any chance?#2018-01-2422:37mhueberthmm#2018-01-2422:42mhuebert@thheller I think an issue may be that processes are not being killed.#2018-01-2422:50mhuebertnpx shadow-cljs start; npx shadow-cljs stop; => always adds a new process, doesn’t kill the last one#2018-01-2423:17mhuebertserver.pid is always reflecting the last process id created#2018-01-2423:18mhuebertall the .port files are deleted when I ctrl-c, but the process.id file and process itself remain#2018-01-2423:18mhueberti’m on mac os 10.13.2#2018-01-2501:16tony.kay@thheller I don’t actually need the figwheel status…it’s also my REPL. With no HUD I have to have a status window AND another one open for a REPL. I can also close the REPL with a keystroke and reclaim that dead space without it affecting my flow.#2018-01-2508:21mhuebertso, i’ve (1) changed the semicolons to &&’s, and (2) added a sleep 2 after shadow-cljs start (one second didn’t seem to be enough)#2018-01-2508:21mhuebertit seems to work#2018-01-2508:21mhuebertstill have the lingering-process issue#2018-01-2510:28thheller@mhuebert that is so strange. the lingering java process issue for me was solved by this weird trick https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L562-L568#2018-01-2510:29thhellerwhich node version/jvm version are you on?#2018-01-2510:29mhuebertnode v7.8.0,#2018-01-2510:31mhuebert
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
#2018-01-2510:53thhellercan you try upgrading node? the java version is fine.#2018-01-2510:54thhellerI’m on v8.9.0 but v9 also works#2018-01-2510:54thhellershouldn’t make a difference though#2018-01-2510:56thheller
$ npx shadow-cljs start; npx shadow-cljs stop;
shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
shadow-cljs - server starting ........................................... ready!
shadow-cljs - config: /Users/zilence/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.143
#2018-01-2510:56thhellerno lingering processes. macOS. no idea what else could be different#2018-01-2510:56thhellermacOS version?#2018-01-2511:08thhellerI plan on rewriting the process handling of the node script soon so I hope that issues goes away then#2018-01-2516:21mhuebertmac os 10.13.2#2018-01-2608:13thheller@mhuebert also 10.13 macOS?#2018-01-2617:36mhuebertYep - 10.13.2#2018-01-2714:19mhuebertAlthough I also got these same kinds of errors on CircleCI w/o Mac OS #2018-01-2714:40thhellercan you test running the npx shadow-cljs server standalone and if killing it with CTRL+C leaves the orphan java process?#2018-01-2810:34mhuebertno orphan process there#2018-01-2810:35mhuebertright now in one project, i can start a server with just a warning (“TCP Port 9630 in use” - despite no java process still running), while in another project (maria) when I try to start a server, I get this:
mattpro:editor MattPro$ npx shadow-cljs server
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - starting ...
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean?
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/boolean?
[2018-01-28 11:32:41 - WARNING] TCP Port 9630 in use.
BindException: Address already in use
	java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
	java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:382)
	java.net.ServerSocket.bind (ServerSocket.java:375)
	java.net.ServerSocket.bind (ServerSocket.java:329)
	clojure.tools.nrepl.server/start-server (server.clj:149)
	clojure.tools.nrepl.server/start-server (server.clj:121)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)
#2018-01-2810:36thhellerthats the nrepl server failing#2018-01-2810:36thhellerif you set a fixed port for nrepl that happens#2018-01-2810:36mhuebertah i’ll remove that option#2018-01-2810:37thhelleryeah fixed ports are a problem when running multiple shadow-cljs instances#2018-01-2810:37mhuebertin this case there was no other instance visibly running#2018-01-2810:38thhellerhmm I don't understand. if port 9630 is blocked something must be running#2018-01-2810:38mhuebertbut.. when I run this in the maria project I don’t see any main processes so maybe i’m just not seeing them#2018-01-2810:38thhellerps ax | grep java#2018-01-2810:38thhellerdoesn't list anything?#2018-01-2810:39mhuebertlooks like they are called java processes when i run the command from maria#2018-01-2810:39mhuebertand main when i run from my other project#2018-01-2810:39thhellerhmm? should always be called java#2018-01-2810:39thhellerno idea what main would be?#2018-01-2810:42mhuebertit starts out as java, and then at some point changes to main (or the first process ends and another one called main starts, however that works)#2018-01-2810:42thhellerhmm what does ps ax for that process look like?#2018-01-2810:43mhuebertsame pid#2018-01-2810:43mhuebert
PID   TT  STAT      TIME COMMAND
77080   ??  Ss     1:20.61 /usr/bin/java -Djava.util.logging.config.file=target
#2018-01-2810:44thhellerwhere is it called main?#2018-01-2810:45mhuebertin Activity Monitor#2018-01-2810:45thhellerwhen you run npx shadow-cljs server that is called main as well?#2018-01-2810:47mhuebertsame — while it’s loading it is called java, around the time it’s finished loading the name changes to main#2018-01-2810:47thhellerso weird#2018-01-2810:47thhellermy mac is still on 10.12 where this doesn't happen#2018-01-2810:47thhellercurrently switching my main machine over to windows#2018-01-2810:48thhellermight attempt the macos upgrade later#2018-01-2810:49mhuebertthis still never works:
mattpro:editor MattPro$ npx shadow-cljs start; npx shadow-cljs clj-run '(+ 1 1);'
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - server starting ..................................................... ready!
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
#2018-01-2810:51thhellerI don't get it, that always works for me#2018-01-2810:52thhellerwhats the state of java processes directly after that?#2018-01-2810:52thhellercan you rm -rf target/shadow-cljs before running that#2018-01-2810:52thhellerand then run the command?#2018-01-2810:52thhellerls -ahl target/shadow-cljs after?#2018-01-2810:54thheller
npx shadow-cljs start; npx shadow-cljs clj-eval '(+ 1 1)'
shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.pom from 
Retrieving thheller/shadow-cljs/2.0.144/shadow-cljs-2.0.144.jar from 
shadow-cljs - dependencies updated
shadow-cljs - server starting ........................................ ready!
shadow-cljs - config: /mnt/c/code/tmp/cljs-bg/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
2
#2018-01-2810:54mhueberti have ssh’d into circleci right now, so whatever OS they are running, and same thing:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0e7c61617a4e6c3a6c3d3d683837383b393c"}, :content ("[email protected]")}
#2018-01-2810:55thhellertarget/shadow-cljs contents?#2018-01-2810:55mhuebert
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fc8e939388bc9ec89ecfcf9acac5cac9cbce"}, :content ("[email protected]")}
#2018-01-2810:56thhelleranything in server.stderr.log or server.stdout.log?#2018-01-2810:56thhellercurl ?#2018-01-2810:56mhuebert
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "35475a5a4175570157060653030c03000207"}, :content ("[email protected]")}
#2018-01-2810:57mhuebert
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e5978a8a91a587d187d6d683d3dcd3d0d2d7"}, :content ("[email protected]")}
#2018-01-2810:57thhellerso the server is running#2018-01-2810:57thhellerand running npx shadow-cljs clj-eval '(+ 1 2)' probably works now#2018-01-2810:58thhellerah it doesn't work since you still have the older version that kills the port file#2018-01-2810:58mhuebert
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "13617c7c6753712771202075252a25262421"}, :content ("[email protected]")}
#2018-01-2810:59mhueberti can upgrade there, one sec. on my mac i am using the latest v#2018-01-2810:59thhelleryeah the older version still kills the port file, so none of the later commands works#2018-01-2810:59thheller
shadow-cljs - socket connect failed, server process dead?
deleted pid file, please retry command to start new server
#2018-01-2810:59thhellernewer version doesn't delete the file anymore#2018-01-2811:01thhellerhttps://github.com/thheller/shadow-cljs/blob/master/.circleci/config.yml#2018-01-2811:01thhellersee the start and then wait-for-server.sh which could probably just be sleep 1
#2018-01-2811:01thhellerbut that setup seems to work on circleci#2018-01-2811:02thhellerno idea about the mac stuff#2018-01-2811:02mhuebertafter updating, server starting seems to go on forever. i also tried rm -rf target
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "03716c6c7743613761303065353a35363431"}, :content ("[email protected]")}
#2018-01-2811:02thhellerit starts way slower due to no AOT#2018-01-2811:03thhellerwhat does the .log files say?#2018-01-2811:03mhueberti think it is stuck#2018-01-2811:03mhuebertone sec#2018-01-2811:04thhellerthis is circleci now right? kinda confusing thinking about both setups#2018-01-2811:04thhellerthe log files should at least say something#2018-01-2811:05mhuebertoh, i see. the version deployed to maria on GH still has nrepl-port specified so in stderr we have:
[2018-01-28 11:01:13 - WARNING] TCP Port 9630 in use.
BindException: Address already in use (Bind failed)
	java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
	java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387)
	java.net.ServerSocket.bind (ServerSocket.java:375)
	java.net.ServerSocket.bind (ServerSocket.java:329)
	clojure.tools.nrepl.server/start-server (server.clj:149)
	clojure.tools.nrepl.server/start-server (server.clj:121)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:278)
	shadow.cljs.devtools.server.nrepl/start (nrepl.clj:266)
but instead of throwing that error it keeps trying to start
shadow-cljs - server starting ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
#2018-01-2811:07mhueberti thought putting a sleep command in between start & the command would be a fix for all of this, but my colleague (on mac os) still got that same error even with shadow-cljs start && sleep 2 && shadow-cljs clj-run ...#2018-01-2811:08mhuebert(all of the stuff i am pasting now is circleci)#2018-01-2811:12thhellercan we please stick to debugging one thing at a time#2018-01-2811:12thhellerI doubt that the mac and circleci issues are related#2018-01-2811:12thhellercircleci I fixed by sleeping yes#2018-01-2811:12thhellerdoes that not work for you?#2018-01-2811:13thhellerif && don't work can you try multiple commands like in my circle config?#2018-01-2811:16mhueberton circleci i stopped using server or start entirely#2018-01-2811:17mhuebertthe reason i ssh’d into circleci was because it seemed like the same error#2018-01-2811:17thhelleron mac can you please delete target/shadow-cljs entirely, kill all java processes#2018-01-2811:17thhellerthen run npx shadow-cljs start alone#2018-01-2811:18thhellerthen run npx shadow-cljs clj-eval :foo#2018-01-2811:18thhellernot combined, after each other manually#2018-01-2811:18mhuebertyes, that worked#2018-01-2811:19thhelleras does npx shadow-cljs stop?#2018-01-2811:19thhellerI mean the java process is properly killed?#2018-01-2811:19mhuebertyes#2018-01-2811:20thhellersame deal, delete target/shadow-cljs, kill all java#2018-01-2811:20thhellernpx shadow-cljs start && npx shadow-cljs clj-eval :foo#2018-01-2811:20thhellerthat causes the error immediately?#2018-01-2811:21mhuebertyep#2018-01-2811:21mhuebert
mattpro:editor MattPro$ npx shadow-cljs start && npx shadow-cljs clj-eval :foo
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server starting ................................................... ready!
shadow-cljs - config: /Users/MattPro/Documents/sites2017/maria/editor/shadow-cljs.edn version: 2.0.144
shadow-cljs - connected to server
shadow-cljs - socket connect failed, server process dead?
#2018-01-2811:21thhellernow npx shadow-cljs clj-eval :foo alone works?#2018-01-2811:21mhueberthowever now i am able to npx shadow-cljs stop.#2018-01-2811:21thhellerie. the server is running#2018-01-2811:22mhuebertone sec#2018-01-2811:22mhuebertnow that works yes#2018-01-2811:23thhellerI have no clue what is happening. the node process that starts the server waits until the port file appears#2018-01-2811:23thhellerthe server writes the port file AFTER startup completed#2018-01-2811:23mhuebertis writing the port file the very last thing it does?#2018-01-2811:23thhellerdoes it work if you reset everything and add the sleep?#2018-01-2811:25thhellerwhat I don't get is why it works on my machine. macOS version shouldn't make a difference#2018-01-2811:25mhuebertadding a sleep 1 works for me now, but that is the same command that didn’t work for my colleague#2018-01-2811:28thhellerI'll just shuffle things arround a bit so that the node process waits a bit until after the file appears#2018-01-2811:28thhellerand maybe does a test run itself#2018-01-2811:31thhellerI have absolutely no other ideas#2018-01-2811:31thhellerwhat kind of hardware are you using? your colleague?#2018-01-2811:31thhellermaybe its just a timing issue?#2018-01-2811:34mhueberti’m not sure what his is. mine is a late 2013 macbook pro#2018-01-2811:39thhellerhmm I have the mid-2015 one, shouldn't be that much of a difference though#2018-01-2811:42mhueberti am not clear on the difference between what i get locally and the stuff i am replicating on circleci#2018-01-2811:42mhueberthttps://circleci.com/gh/mhuebert/shadow-circleci/2#2018-01-2811:43mhuebert^^ there i am running shadow-cljs start and clj-eval as two separate commands (no sleep) and getting an error#2018-01-2811:45thhelleryes I have that happening in my circleci setup as well#2018-01-2811:45mhuebertyou could fork that repo & add to circleci to ssh in if you wanted to try other stuff (https://github.com/mhuebert/shadow-circleci) it is just a plain docker image with java+node+git#2018-01-2811:45thhellerthats why I added the wait-for-server.sh#2018-01-2811:45thhellerbut thats just basically a sleep 1#2018-01-2811:48mhuebertright. is what’s happening there different in some way from what happens on my machine?#2018-01-2811:58thhellerI have no idea#2018-01-2811:58thhellerthere shouldn't be#2018-01-2812:07thhellerso it appears to work now on circleci#2018-01-2812:08thhellerwill push a new version once I figure out how to configure npm on windows#2018-01-2812:09thhellerhttps://circleci.com/gh/thheller/shadow-cljs/104#2018-01-2812:09thhellerlooks good now though, no sleep#2018-01-2812:14thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d7a4bfb6b3b8a0fab4bbbda497e5f9e7f9e6e3e2"}, :content ("[email protected]")} should hopefully fix this#2018-01-2812:29mhuebert👍:skin-tone-2:#2018-01-2814:03mhuebertmy test works too: https://circleci.com/gh/mhuebert/shadow-circleci/3#2018-01-2814:04thhellerphew#2018-01-2609:21mhuebertwill ask#2018-01-2609:21mhuebertmight be tomorrow, time zones..#2018-01-2610:44evekohow do I fix require namespaces from cljsjs? I found out that I need to include a maping of a sort, but can't get it to work#2018-01-2610:44evekoi am trying to get soda ash to work#2018-01-2610:44evekoThe required namespace "cljsjs.semantic-ui-react" is not available, it was required by "soda_ash/core.cljs".#2018-01-2611:07qing97https://shadow-cljs.github.io/docs/UsersGuide.html#_migrating_cljsjs @eveko#2018-01-2611:21evekoĮ forgot to create the cljsjs folder ! It works now thanks for the link#2018-01-2614:48hlollihas someone been able to connect to shadow-cljs nrepl connection with cider 0.17.0, I can connect but can't escape cider telling me that I'm not connected to cljs repl, I tried both cider-connect and cider-connect-clojurescript. Specifically I'm trying to connect to node-repl.#2018-01-2615:01hlolliah, this could be explained better to the manual, or I should have noticed it sooner. (shadow.cljs.devtools.api/nrepl-select :node-repl) node-repl is a node repl and the id of the build 🙂#2018-01-2713:29thheller@hlolli yes that can be explained better. will do soon.#2018-01-2713:29thhellercurrently still setting up windows and getting used to things#2018-01-2713:33hlolli@thheller I'm trying to uberjar a node-library, that require thing doen't seem to find a js resource I'm requireing, I did (js/require (path/join js/dirname "fileinroot.js")), that fileinroot is inside the uberjar, but won't get extracted. Is this something known, or maybe implementing resolve for modules from node-library targets just what's needed.#2018-01-2713:34hlolliI define it from leiningen in :reosource-paths -> lein uberjar and then it's in the .jar file#2018-01-2713:34thhelleruberjar a node library? node doesn't supports jars?#2018-01-2713:34hlolliI should rather say, clojurescript targeting node.js.#2018-01-2713:34hlolliie clojurescript code that uses js/require#2018-01-2713:34thhellerhow does uberjar play into this?#2018-01-2713:35hlolliI want to create library and in another project call it. I can't see a better way of hosting cljs code than on clojars?#2018-01-2713:36thhelleruberjar includes all your dependencies into the jar#2018-01-2713:36thhelleruberjars are usually not published on clojars.#2018-01-2713:37thhellerbut yes the js/require won't find things in jars#2018-01-2713:37thhelleri don't quite understand what you are trying to do#2018-01-2713:38thhellerif you want to publish a CLJS library you just publish the code, not the compiled code#2018-01-2713:39hlolliI have a cljs project that has a single vanilla js file that has exports that I want to use in cljs land. I require it and it all works, I just want to package the whole thing, and from a different project call the cljs functions that some also call vanilla js code#2018-01-2713:40thhellerah ok I thought you were trying the other way. consume the cljs in js.#2018-01-2713:40thhellerso the problem with .js files that you are including via js/require#2018-01-2713:40thhelleris that the compiler doesn't know about them#2018-01-2713:41thhellerand therefore won't do anything to include them in the build#2018-01-2713:41thhellerie. copy them out of the jar so node can find it#2018-01-2713:42thhellerthe problem with relative requires is that they currently only work for files#2018-01-2713:42hlollimhm#2018-01-2713:42thhelleroption a) publish the .js file to npm#2018-01-2713:43thhellerunfortunately#2018-01-2713:43hlolliyes, that can actually work in my case#2018-01-2713:43thhellerhttps://dev.clojure.org/jira/browse/CLJS-2061?focusedCommentId=46191&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-46191#2018-01-2713:43thheller> Supporting Node.js style paths as requires is just never, ever going to happen.#2018-01-2713:44thhellerif you publish the .js file to a npm package you can just declare it in :npm-deps for the lib#2018-01-2713:44hlollihehehe#2018-01-2713:44thhellerall other solutions are kinda hacky#2018-01-2713:44hlolliyes I'll do that, seems cleanest#2018-01-2713:46thhellerI have a few outstanding ideas for better JS interop since some things aren't as clean as I'd like#2018-01-2713:46thhellernot sure when I'll get to that though#2018-01-2713:47thhellershould make including random .js files easier though#2018-01-2713:47thhellerkinda not possible to publish ES6 .js files in .jars currently which is annoying#2018-01-2713:47thheller(or even CommonJS)#2018-01-2713:49hlolliyes that's bit annoying, I've often thought about the other way around, just start uploading cljs stuff on npm.#2018-01-2713:49thhellerthat doesn't really fix the issue though#2018-01-2713:50thhellerthe problem is that clojure(script) is classpath based#2018-01-2713:50thhellerie. you have multiple "roots" but each file must be unique on the classpath#2018-01-2713:50thhellerotherwise they override each other#2018-01-2713:50thhellernode/npm doesn't have a classpath at all#2018-01-2713:50thhellerits all just relative paths#2018-01-2713:51thhellerwe could easily add a bit of metadata to package.json to declare :source-paths for a lib#2018-01-2713:51thhellerand just add those to the classpath#2018-01-2713:51thhellerbut you can't break out of the classpath#2018-01-2713:51hlolliyes, but a cljs compiler can just ignore the package.json and node ecosystem, go straight to node_modules read a package description file and resolve the classpath and files just with node_modules/packagex cut off.#2018-01-2713:52thhellerthat doesn't work since the files aren't uniquely named#2018-01-2713:52hlollioh didnt know that#2018-01-2713:53thhellerin cljs everything is namespaced. eg. shadow.dom is in <root>/shadow/dom.cljs#2018-01-2713:54hlolliyes, my idea is that this <root> would just have to be resolved differently for npm packaged cljs code.#2018-01-2713:54hlolliBut my stomach is telling my that it really needs food, so Im afk for now#2018-01-2713:54thhellerthe classpath is a collection of paths#2018-01-2713:54thhellerso it could easiy add node_modules/some-package/src as that path#2018-01-2713:55thhellerjust add package.json "clojurescript":{"source-paths": ["src"]} or something and that would work easily#2018-01-2713:55thhellerthe problem is still that classpath and relative paths don't play well together#2018-01-2713:56thhellernothing is node is named so if one file include another it must use the relative path#2018-01-2713:58thhellersince node doesn't have naming you get nice looking imports like these#2018-01-2713:58thhellerreact-virtualized/dist/commonjs/AutoSizer#2018-01-2713:58thhellerhopefully js people get their act together and enable at least react-virtualized/AutoSizer at some point#2018-01-2713:59thhelleranyways ... whether CLJS is published to npm or clojars doesn't change how file refences work#2018-01-2713:59thhellerafk too#2018-01-2719:01tony.kay@thheller Just tried out the new HUD….NICE!#2018-01-2720:34thhellerkinda wanted to do more animations and stuff but its a start#2018-01-2720:35thhellerthe error printing code needs work but hey at least they get displayed now#2018-01-2722:02tony.kayI think it's really good. I care about functionality more than anything, and this is very functional.#2018-01-2808:18Jonsaw new HUB just now, the loading dots looks too obvious too me 😮#2018-01-2808:19JonI would feel better if it's place at bottom left and being very small, with colors like #ccc or #ddd#2018-01-2808:21Jonone of my screens has a width of 2560, the loading dots has a 1000px distance from where warnings are displayed#2018-01-2809:01thheller> the loading dots looks too obvious too me#2018-01-2809:02thhellerthey are supposed to be obvious? so that you know compilation/loading is happending#2018-01-2813:12Jonactually I think that dots are ugly, being rendered in black. And its position is too strange in large screens.#2018-01-2813:13Jonspeaking of loading icons, its more likely https://www.google.com/search?newwindow=1&amp;biw=1280&amp;bih=699&amp;tbm=isch&amp;sa=1&amp;ei=UsxtWrKSOImv0ASj35fQBA&amp;q=loading+icon&amp;oq=loading+icon&amp;gs_l=psy-ab.3..0l10.1506.1958.0.2107.5.3.0.2.2.0.101.268.2j1.3.0....0...1c.1.64.psy-ab..0.5.278...0i67k1.0.DpMYeVOh4uM#2018-01-2814:03thheller@jiyinyiyong I picked the loading anim from http://tobiasahlin.com/spinkit/ and I picked it because I obviously liked it.#2018-01-2814:04thhellerI can move it to the left though#2018-01-2814:05thhellerI always have my browser window with devtools on the side so it rarely is wider than about 1300px so center looked good to me#2018-01-2814:29Jonthere are some differences. white dots look good on a colorful background, black ones don't.#2018-01-2814:30Jonin the demo, there's enough time for the animation to play, however ClojureScript most times reloads quickly, not enough too see the animation#2018-01-2814:31Jon. Personally I think icons in static images would look better.#2018-01-2814:31thheller@jiyinyiyong the HUD needs tons of work so I'm happy to look at suggestions or even better alternate implementations#2018-01-2814:31thhellerthe code is pretty straightforward so feel free to tweak and play with it#2018-01-2814:33thhellerI kinda wanted to build in more features but I don't want to pollute the user's build with too many dependencies the HUD might want to pull in#2018-01-2814:44Jonstill looks strange though... but less confusions to me(personally)..#2018-01-2821:10martinklepschThis looks amazing @thheller — excited to see what’s to come! #2018-01-2917:28lilactownI have a strange one: apparently our corporate network blocks connections to 0.0.0.0, so when the JS runtime tries to connect to the shadow-cljs server, it blocks the connections#2018-01-2917:29lilactownis there a way to change it to 127.0.0.1 or localhost?#2018-01-2917:29thheller:http {:host "localhost"} in shadow-cljs.edn#2018-01-2917:31lilactowndoes that also work for node.js?#2018-01-2917:34thhellerI think so? its a server side setting#2018-01-2917:38lilactownahhh when I was skimming the docs, I thought that the http config was for managing the settings for serving a front-end project. my bad 😅 thanks!#2018-01-2918:29colindresjI’m getting a spec error when trying to compile some code that is in fact valid#2018-01-2918:33colindresjGetting rid of the :card/keys in favor of just :keys compiles#2018-01-2918:33colindresjI’m on clojurescript 1.9.946#2018-01-2918:36colindresjAnd shadow 2.0.146#2018-01-2918:36colindresjAny ideas why this fails the spec?#2018-01-2918:38thheller
clj
Clojure 1.9.0
user=> (fn [{:card/keys [:slug :title :can-edit? :can-complete?]}])
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/fn did not conform to spec:
#2018-01-2918:38thhellerbecause clojure complains#2018-01-2918:39thhellerthats plain clojure 1.9, no shadow or any other deps#2018-01-2918:39thhellerI think you are not allowed to combine namespaced keys with keywords#2018-01-2918:40colindresjOh yeah, let me check my Clojure version#2018-01-2918:40thheller(fn [{:card/keys [slug title can-edit? can-complete?]}]) this works#2018-01-2918:42colindresjThat fixed it#2018-01-2918:42colindresjThatnks @thheller#2018-01-2918:43thhellerit may work with default CLJS since they don't have the core.specs in the 946 release#2018-01-2918:43colindresjI wonder if self-hosted CLJS is a little different, cause in Lumo I’m ok with it#2018-01-2918:43thhellerbut it is in master#2018-01-2918:43colindresjOk, makes sense#2018-01-2918:43thhellerso it would break with the next release#2018-01-2918:43colindresjGood to know#2018-01-2919:13mitchelkuijpersJust played around with the new hud, works like a charm @thheller!#2018-01-3000:52kenbiersuper excited by this project but i’ve tried to boot up 3 of the examples in the example-repo and each gave me a different error#2018-01-3000:52kenbierall browser errors, no build errors#2018-01-3000:52kenbiercurious if im doing something wron#2018-01-3000:54kenbierthe browser example said that it couldn’t find references to the jquery and crypto modules, thoug i did a yarn install#2018-01-3000:59kenbierim using node v8.0.0 and 2.0.146#2018-01-3000:59kenbierfor local-js i get: > Uncaught ReferenceError: module$node_modules$react$index is not defined#2018-01-3001:00kenbierand my steps are yarn install then shadow-cljs watch app#2018-01-3001:00kenbierthats it#2018-01-3001:00kenbierperhaps im doing something wrong or some of these examples are stale… really all i want to do is get an example app running that requires rum from clojars and react from NPM#2018-01-3007:37kenbierah, seems like the lein templates work.#2018-01-3008:55thhellerI'll look over the examples. some of them are quite dated yes.#2018-01-3009:17Jonit appears too me shadow-cljs is writing some of the logs to stderr. I marked stderr red in my tool. Some of them are red.#2018-01-3009:17Jonlooks no difference in a terminal though.#2018-01-3009:21thhellerThe goal was to keep all log-like output to stderr#2018-01-3009:21thhellerif you want to use clj-run some.ns/fn which outputs to stdout I wanted to be able to capture that without any log output#2018-01-3009:21thhellerbut I never quite finished that work#2018-01-3009:22Jonso it's a feature.#2018-01-3009:23thhellerit is intended yes#2018-01-3009:23thhelleralthough I might as well revert it since it isn't done 100%#2018-01-3009:23Jonand something like "shadow-cljs - watching build :browser" will outputs to stderr as well?#2018-01-3009:24thhellerhonestly I don't know if its a good idea at all#2018-01-3009:24Jonnot sure either, just thought it looks too random and not as intuitive...#2018-01-3009:27thhelleragreed#2018-01-3009:28Jonwell, stackoverflow again... https://stackoverflow.com/questions/19870331/why-use-stderr-when-printf-works-fine#2018-01-3009:29thhellerhmm?#2018-01-3009:30Jon> The general practice is to redirect all error messages to stderr and all regular output to stdout. said by StackOverflow 😄#2018-01-3009:31thhelleryep#2018-01-3009:36Jonfound it interesting >_> https://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout#2018-01-3009:56thheller@kenbier the browser example had a bug which I fixed. local-js should work just fine. I removed the yarn.lock files from the examples since they locked in older version of shadow-cljs. so everything should be using the most recent version now without me having to update it.#2018-01-3009:58kenbier@thheller thanks!#2018-01-3009:59kenbieramazing project btw… lack of npm support has been my biggest pain with CLJS, and honestly something that should be more talked about!#2018-01-3010:01kenbier@jiyinyiyong just read some of your blog posts too, good stuff 🙂#2018-01-3010:11Jon#2018-01-3010:37thhellerweird, it should die#2018-01-3010:37thhellerbut I "fixed" this issue once before#2018-01-3010:37thhellerI don't handle any signals at all so no idea#2018-01-3010:38Jonor anything to do on my side? https://github.com/mvc-works/termina/blob/master/server/src/server/manager.cljs#2018-01-3010:40thhellerno idea. the node process fully controlls the java process so it should die when node dies#2018-01-3010:40thhellerbut that had issues before#2018-01-3010:41thhellerit might be because I use child_process.spawnSync and don't handle any signals#2018-01-3010:41thhellermaybe I'm supposed to use spawn and do everything async with manual signal handling#2018-01-3010:41thhellerI expected spawnSync to do the correct thing#2018-01-3010:44JonI'm not familiar enough with those APIs 😟#2018-01-3010:45thhelleryou are using it in manager.cljs 😉#2018-01-3010:45JonI never tried spawnSync.#2018-01-3010:45thhellerexec is the same as spawn I think#2018-01-3010:45Jonsyntax sugar I guess..#2018-01-3010:46thhellerbtw instead of (.exec cp command (clj->js {:cwd cwd})) you can do (cp/exec command #js {:cwd cwd})#2018-01-3010:46thhellerlooks a bit nicer#2018-01-3010:48Jon
cp = require 'child_process'

ret = cp.spawnSync 'sleep', ['100']

console.log ret
#2018-01-3010:49Jonrepeated the problem with CoffeeScript#2018-01-3010:50thhellerif anything thats a node issue yes#2018-01-3010:51JonI can't use #js {:cwd cwd} since my code is not written in Clojure directly...#2018-01-3010:52thhellerhmm maybe try https://stackoverflow.com/a/33367711#2018-01-3010:52thhellerkill with the negative id?#2018-01-3010:59Jon
Error: kill ESRCH
    at Object._errnoException (util.js:1003:13)
    at process.kill (internal/process.js:173:18)
#2018-01-3011:01Jon
(comment .kill proc)
       (.kill js/process (- 0 pid) "SIGKILL")
#2018-01-3011:04Jonturned out not working on my Mac#2018-01-3016:41theasp@thheller I've added shadow-cljs to my cljs docker images: https://hub.docker.com/r/theasp/clojurescript-nodejs/#2018-01-3016:50thhellernice#2018-01-3016:51thhellerlooks much better than the docker image I created 😛#2018-01-3016:52thhellerhttps://hub.docker.com/r/thheller/cljs-dev/ can't find the Dockerfile 😛#2018-01-3016:52thhellerbuilt if for the CI tests I still need to create https://github.com/thheller/shadow-cljs/blob/master/.circleci/config.yml#L8#2018-01-3017:02colindresjI have a macro that creates some locally scoped variables, but I’m getting a bunch of use of undeclared Var warnings#2018-01-3017:02colindresjMy macro looks like this#2018-01-3017:02colindresjAnd used like this#2018-01-3017:04colindresjHow might I get rid of the warnings?#2018-01-3018:00theasp@colindresj Can you show the warnings?#2018-01-3018:06colindresjHere’s an example @theasp#2018-01-3018:06colindresj
------ WARNING #17 -------------------------------------------------------------
 File: /Users/jorge/lunar/src/lunar/ui/catalog/views.cljs:119:69
 Use of undeclared Var lunar.ui.catalog.views/c
--------------------------------------------------------------------------------
#2018-01-3018:07colindresjThat c would be the var from the for-indexed snippet above#2018-01-3018:09theaspAre you sure c is defined?#2018-01-3018:13theaspActually, if it was nil that wouldn't matter#2018-01-3018:14colindresjYeah, if you look at the macro definition above, you’ll see that i and c are set within the argument vector of the mapping function for map-indexed#2018-01-3018:16theaspyes, sorry, I was meaning if c was defined.#2018-01-3018:17theasp
user=> (for-indexed [i c [{:card/id 1} {:card/id 2}]] [:li {:class "card" :key i} (:card/id c)])
([:li {:class "card", :key 0} 1] [:li {:class "card", :key 1} 2]
#2018-01-3018:17theaspit works in clojure#2018-01-3018:19colindresjYeah and works without warning in the cljs compiler too#2018-01-3019:45colindresjFound the issue, was forgetting to expose the macro via the namespace#2018-01-3019:45colindresjI’ve got all my macros in a macros.clj file, and forgot to create the matching macros.cljs file with the :require-macros in the ns form#2018-01-3019:45colindresjThanks for the help @theasp#2018-01-3019:46theaspdoh! 🙂#2018-01-3019:46theaspnp, but I don't think I was much help 🙂#2018-01-3111:15thheller@jiyinyiyong do you have the logo you made in SVG?#2018-01-3113:28Jonit is made with Sketch, just exported.. https://github.com/shadow-cljs/shadow-cljs.org/blob/master/entry/shadow.sketch#2018-01-3113:30thhellerthx#2018-01-3113:31JonI think the png one is better if you want to use. the SVG file I exported looks like not 400x400 exactly due to some invisible parts of the shapes.#2018-01-3115:49thheller@jiyinyiyong do you remember which font you used for the S? I don't have Sketch#2018-01-3116:16Jonnot font. It's by hand...#2018-01-3116:17JonI would suggest https://fonts.google.com/specimen/Josefin+Sans if you want a font-face, I already used it on http://shadow-cljs.org .#2018-01-3116:18thhellerI'm reconstructing the logo by hand since the sketch svg was pretty horrible#2018-01-3116:19JonI'm not sure about licence issues, also I considered fonts might not been thin enough. I just made an "S" by dragging a curve.#2018-01-3116:19thhelleradding a font is not an option though#2018-01-3116:19thhellerI'll stick with your path#2018-01-3116:20Jonwhat's the problem in SVG?#2018-01-3116:23Jontry if this SVG file helpful... sliced and trimmed pixels...#2018-01-3116:23thhellernah still horrible#2018-01-3116:23thhellerI got what I need now#2018-01-3116:24Jonwell.#2018-01-3116:24Jongot to check it out tomorrow. late in my timezone.#2018-01-3116:24Jongood night anyway..#2018-01-3116:29thhellergood night#2018-01-3116:07thheller@denik this happens when you use the stdin version of the repl#2018-01-3116:07thhellernot the nrepl#2018-01-3116:07thhellerI assume this is the nrepl started by cursive?#2018-01-3116:08denikyup after evaling the highlighted form. So I should use shadow/nrepl-select and a remote repl instead?#2018-01-3116:08thheller:repl/quit to exit the annoying popups btw#2018-01-3116:08thhelleryes but nrepl-select only works when the middleware is loaded#2018-01-3116:08thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-01-3116:08denikfigured that one out after restarting intellij 3 times 🙂#2018-01-3116:10denikis that currently best approach to get a cljs repl in intellij?#2018-01-3116:10thhellerimho the best approach is to not use nrepl#2018-01-3116:11thhellerand using the standalone stuff, not embedded in lein repl
#2018-01-3116:12thhellerie. start shadow-cljs watch app in the terminal (intellij terminal works great)#2018-01-3116:12thhellerthen connect directly to the nrepl shadow provides (which already has all the nrepl setup stuff taken care of)#2018-01-3116:14denikWill do that then. Thanks @thheller! Very grateful to have shadow-cljs!#2018-01-3116:17thhellerI made this utility for myself so I don't have to use nrepl#2018-01-3116:18thhellerclojure.main doesn't have all the features but everything I need 😉#2018-01-3116:30colindresjDoes shadow-cljs have something similar to lein checkout dependencies? Or if using :lein true will checkouts just work?#2018-01-3116:30colindresjI’m developing two separate CLJS projects together and one depends on the other#2018-01-3116:35thheller@colindresj with :lein true the usual lein checkouts work yes. you can also just add the :source-paths to the other repo#2018-01-3116:35colindresjCool that’s what I suspected, but just wanted to make sure#2018-01-3120:18davidstsomething about the release-snapshot feature broke for me. I am calling it with (shadow.cljs.devtools.api/release-snapshot :app {}). the file bundle-info.edn is created but unfortunately it is ill-formed. for example, it contains the string ... to abbreviate the contents of the vector under :build-sources. it looks like this edn file is created by some pretty printer that is meant for the repl.#2018-01-3120:45thheller@davidst it is using pprint indeed#2018-01-3120:45thhellerwasn't aware that could create invalid code?#2018-01-3120:51thhellerI just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c7b4afa6a3a8b0eaa4abadb487f5e9f7e9f6f2f7"}, :content ("[email protected]")} which doesnt pprint anymore#2018-01-3121:03davidstthank you! is there a way to create a snapshot from the command line?#2018-01-3121:06davidst@thheller in 2.0.150 the edn file is no longer pretty printed but still elided#2018-01-3121:09thhellercan you gist the file so I can take a look?#2018-01-3121:09thhellerno idea why it would elide anything?#2018-01-3121:10thhellercommand line shadow-cljs clj-eval "(shadow.cljs.devtools.api/release-snapshot :app {})" should work but no offical API for that yet#2018-01-3121:12davidsti am guessing it has something to do with *print-length* https://clojuredocs.org/clojure.core/*print-length*#2018-01-3121:13davidstit's set to 100 for me. maybe that's a cider thing?#2018-01-3121:15thhellerI guess that applies yes#2018-01-3121:16thhellerhmm if that is set globally that could mess up a whole bunch of stuff#2018-01-3121:17thhellereg. the cache written by release or any other call would also be elided#2018-01-3121:18davidstlooks like it was recently added in cider https://github.com/clojure-emacs/cider/commit/43a22c92e0a467d131179f6abba44803c215f098#2018-01-3121:19davidstthis works for me: (binding [*print-length* false] (shadow.cljs.devtools.api/release-snapshot :app {}))#2018-01-3121:20thhellerhmm I might just switch to using transit for everything. really don't want to deal with bindings whenver I print anything#2018-01-3121:20thhellermeh not a fan that this setting is applied to the repl session 😞#2018-02-0101:05tony.kaythe new code loading spinner in shadow is pretty sexy#2018-02-0302:10wilkerluciohello, I'm trying to compile a new project with shadow-cljs, but I'm getting this error:#2018-02-0302:10wilkerlucio
[:gql-contacts] Configuring build.
[:gql-contacts] Compiling ...
[:gql-contacts] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/wilkerlucio/.m2/repository/thheller/shadow-cljs/2.0.150/shadow-cljs-2.0.150.jar!/shadow/cljs/devtools/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------
#2018-02-0302:11wilkerlucioideas on how to fix?#2018-02-0302:24wilkerluciofixed, updated core-async#2018-02-0513:19thhellerI just published 2.1.0 which might break your build if you were using relative requires. I did a rework on that to hopefully gain better support for working with local .js files. It might unintentionally present other bugs as well. Please try it.#2018-02-0513:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_dealing_with_js_files#2018-02-0513:20thheller@hlolli you might be interested in this. I believe you were trying to deal with this a while ago (ie. use a .js file in a library jar)#2018-02-0513:54hlolli@thheller perfect timing, I try it!#2018-02-0519:28theaspIs shadow-cljsjs 0.0.5 still valid? I'm getting react-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.js#2018-02-0519:29thhellerthats an outdated cljsjs/react version. either exclude it or bump to a newer version#2018-02-0519:33thhellershadow-cljsjs has nothing to do with that#2018-02-0519:33theaspAh, I figured thats where the deps.cljs was from#2018-02-0519:33thhellernope thats the cljsjs/react package itself#2018-02-0519:34theaspWhat would have changed? I'm not requiring react directly, just through reagent 0.7.0#2018-02-0519:34thhellerCLJS itself does not validate deps.cljs files so "errors" in those files go unnoticed easily#2018-02-0519:35thhellershadow-cljs validates those files and checks if the contents are correct#2018-02-0519:35thhellerin this case the jar file does not contain a file it is referring too#2018-02-0519:35thhellerthat error has been there for a long time#2018-02-0519:36thhellerjust add [reagent "0.7.0" :exclusions [cljsjs/react cljsjs/react-dom]] since we are not going to use them anyways#2018-02-0519:37theaspYes, that makes sense. Why is it breaking all of a sudden though?#2018-02-0519:37theaspi.e. it worked yesterday#2018-02-0519:37thhellerbreaking? should just be a warning#2018-02-0519:37thhelleroh wait did you upgrade to 2.1.0 and it is breaking now?#2018-02-0519:38thhellermaybe I remove a try/catch accidentally#2018-02-0519:38theaspOh, no, it's not a warning:
failed to start service
{:id :classpath}
ExceptionInfo: failed to start service
        clojure.core/ex-info (core.clj:4739)
        clojure.core/ex-info (core.clj:4739)
        shadow.runtime.services/start-many/fn--15833 (services.clj:135)
        shadow.runtime.services/start-many (services.clj:126)
        shadow.runtime.services/start-many (services.clj:105)
        shadow.runtime.services/start-all (services.clj:144)
        shadow.runtime.services/start-all (services.clj:139)
        shadow.cljs.devtools.server/start-system (server.clj:191)
Caused by:
/home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.js
{:tag :shadow.build.classpath/deps-cljs, :source-path #object[java.io.File 0x64c82a3b "/home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar"], :name "cljsjs/react/development/react.inc.js"}
ExceptionInfo: /home/asp/.m2/repository/cljsjs/react/15.5.4-0/react-15.5.4-0.jar deps.cljs refers to file not in jar: cljsjs/react/development/react.inc.js
        clojure.core/ex-info (core.clj:4739)
        clojure.core/ex-info (core.clj:4739)
        shadow.build.classpath/process-deps-cljs/get-index-rc--17183 (classpath.clj:252)
        shadow.build.classpath/process-deps-cljs/fn--17187 (classpath.clj:265)
        clojure.core/map-indexed/mapi--8189/fn--8190 (core.clj:7228)
        clojure.lang.LazySeq.sval (LazySeq.java:40)
        clojure.lang.LazySeq.seq (LazySeq.java:49)
        clojure.lang.RT.seq (RT.java:528)
#2018-02-0519:39theaspSorry, I could have been clearer 😉#2018-02-0519:39thhellerbut you upgraded to 2.1?#2018-02-0519:39theaspYes#2018-02-0519:40thhellerfixing, just a sec#2018-02-0519:41thhelleradd the exclusions if you don't want to wait 😉#2018-02-0519:42theaspYup, works, thanks 🙂#2018-02-0519:42theaspoh, no, still errored out#2018-02-0519:42theaspjust took longer#2018-02-0519:43theaspoh#2018-02-0519:43theaspre-frame probably#2018-02-0519:43thhellermight be coming from a different dep now 😛#2018-02-0519:43thhellerunfortunately basically all CLJS libs still expect to use cljsjs#2018-02-0519:43theaspyup#2018-02-0519:53thhelleryou can also add [cljsjs/react "15.6.2-4"] do your dependencies so you don't have to exclude it for everything#2018-02-0519:54thhellertrying to figure out why it didn't error out previously#2018-02-0519:55thhelleror rather why it errors out now .. the file is actually in the jar#2018-02-0520:02thheller@theasp fixed in 2.1.1. thanks for the report.#2018-02-0520:02theaspAwesome, thanks for the quick fix#2018-02-0520:06mynomotoDid someone try shadow-cljs for building react-native projects? Is there a sample project somewhere?#2018-02-0520:07thheller@mynomoto I did some very basic tests a while ago https://github.com/thheller/shadow-cljs-examples/tree/master/cljs-react-native-app#2018-02-0520:07mynomoto@thheller I will take a look, thanks!#2018-02-0520:08thheller "shadow-cljs": "^0.18.0" hehe cute 😛#2018-02-0520:08thhellershould still work though#2018-02-0520:57shaunlebron@tony.kay @thheller what the hell, these docs are awesome! https://shadow-cljs.github.io/docs/UsersGuide.html#2018-02-0520:58justinlee@shaunlebron That is super weird timing. I was just writing this comment at the exact same time: “I finally drank two cups of coffee and read through the shadow-cljs guide. what a monumental project this is. I do not understand where you found the time.”#2018-02-0520:59shaunlebron💯 haha, on the same wavelength. very excited to see the attention to detail on docs. very well written#2018-02-0521:00shaunlebron@lee.justin.m i don’t get it either, thomas has been working on this for some 3-4 years#2018-02-0521:01thhelleralmost full time for the past 6 months or so, but yeah lots of work since dec 2013#2018-02-0521:01justinleei keep markdown notes to myself when i’m working through something complicated. you should see the file i wrote when trying to figure out JS import stuff based on the http://clojurescript.org docs. i really now wish i had gone with shadow first#2018-02-0521:03shaunlebronyeah, thomas’s blog posts on importing js libraries are really good#2018-02-0521:06shaunlebron@thheller awesome you took some time off to work on it, it really shows. let us know if you’re letting people support your work yet (patreon or whatever)#2018-02-0521:07thhelleryeah still thinking about where I want to go with that. I still want to do so much more but can't really justify doing it since I need to get back to actual work soon.#2018-02-0521:17shaunlebroni was in the same situation in november after taking 6 months on parinfer#2018-02-0521:18shaunlebronthe patreon stuff helps me treat the project as a part-time job to justify time spent#2018-02-0521:23thhelleryeah. I still need to look into that properly. Last time I checked the tax situation for patreon in germany was weird.#2018-02-0523:34lilactownis there a suggested way to run tests on Node.js for CI?#2018-02-0607:09cmalHi, I added [day8.re-frame/trace "0.1.18-react16"] to my project, shadow-cljs watch app complains
Build failure:
The required namespace "cljsjs.react-flip-move" is not available, it was required by "day8/re_frame/trace/utils/animated.cljs".
then I added [cljsjs/react-flip-move "2.9.17-0"] to shadow-cljs.edn, still same complains.
#2018-02-0607:18cmalDoes this relate to react-flip-move uses cljsjs?#2018-02-0607:52cmalI removed [cljsjs/react-flip-move "2.9.17-0"] from shadow-cljs.edn and add react-flip-move to package.json and create react_flip_move.cljs in cljsjs/ and it works.#2018-02-0609:15thheller@cmal https://shadow-cljs.github.io/docs/UsersGuide.html#_migrating_cljsjs#2018-02-0609:17thheller@lilactown not yet. totally forgot about node tests 😛#2018-02-0609:24cmalWhat a beautiful user guide! good job @thheller! Waiting this for long!#2018-02-0609:29thheller
(ns cljsjs.react-flip-move
  (:require cljsjs.react
            cljsjs.react.dom
            ["react-flip-move" :as flip-move]))

(js/goog.exportSymbol "FlipMove" flip-move)
#2018-02-0609:29thheller+ npm install react-flip-move should do it#2018-02-0609:42orestisIs there a brief overview on how shadow-cljs compares with the “vanilla” CLJS compiler? Does it build on top of it (incl. recent changes for npm integration etc) or does it overlay its own machinery on top of the “core” CLJS->JS compiler? Or something completely different?#2018-02-0609:49thheller@orestis it does use the default CLJS compiler but replaces certain parts. the npm integration is completely custom and none of the official code for that is used (since its too broken). so the npm/js integration is the biggest difference. a few minor tweaks to the compiler here or there.#2018-02-0609:51orestis@thheller Thanks — are there plans to eventually merge the two or are they serving different goals? I guess I’m worried about a long-term divergence and a difficult decision to make when starting out…#2018-02-0609:53thhellerso in theory everything is standard, that means everything shadow-cljs does should work with other tools too. in practice however that is not the case because CLJS is just broken in places. once that gets fixed you should be able to switch between shadow-cljs -> cljs without issues.#2018-02-0609:53thhellerI'm doing things differently because I didn't agree with the approach taken by CLJS and didn't see an easy way too fix it#2018-02-0609:54thhellerbut that is all just tooling related, the language itself is standard.#2018-02-0609:55thhellerI have been doing this for a long time and sometimes implement "experimental features" first that eventually make it into CLJS itself#2018-02-0609:55thhellerbest example is https://dev.clojure.org/jira/browse/CLJS-948#2018-02-0609:56thhellerwhich was in then shadow-build about a year before it landed in CLJS itself#2018-02-0609:59thhellercontributing to CLJS itself is pretty painful and slow so I eventually stopped and did it all in my tool directly#2018-02-0609:59orestisShadow looks fantastic, don’t get me wrong — it’s obvious by reading the docs that there’s a lot of well-thought features that are usable today. So thanks for all that!#2018-02-0609:59thhellereg. https://dev.clojure.org/jira/browse/CLJS-2376 is already in shadow-cljs, still waiting for patch acceptance in CLJS core ...#2018-02-0610:01orestisOut of curiosity, once a feature lands in CLJS, does shadow move to depend on that (while exposing the same API)?#2018-02-0610:01thhellerwhen it makes sense yes#2018-02-0610:04thhellerI initially started all of this because I wanted :modules support in CLJS#2018-02-0610:04thhellerthat eventually also landed in CLJS https://swannodette.github.io/2015/02/23/hello-google-closure-modules#2018-02-0610:05orestisOK, so would it be fair to summarize it like so — main CLJS development is (perhaps understandably?) slow to gain new features, esp. WRT the wider JS integration story, so shadow-cljs tries to bridge that gap, while trying (to some extent) to both profit from CLJS developments and also push new patches/ideas “upstream”? So at least currently and in the medium term, shadow-cljs is always going to be a superset of CLJS.#2018-02-0610:05thhellerbut integration is still not great in CLJS#2018-02-0610:05thhelleryes#2018-02-0610:06thhellerwell my opinion is that shadow-cljs is a build tool and CLJS should focus on language features#2018-02-0610:06thhellerIMHO there is too much tooling in CLJS itself that is half broken and unreliable#2018-02-0610:06thhellerso instead of building on that it replaces everything tooling related#2018-02-0610:07orestisFrom what I can remember, the only time where there is a shadow reference in your code is when using the dynamic loader features?#2018-02-0610:07thhelleragain shadow.loader existed about a year before cljs.loader ...#2018-02-0610:08orestis(Yep, I understand that — it’s just that I read the CLJS docs first 😉 )#2018-02-0610:08thhellercljs.loader unfortunately has some unsolvable issues which is why I don't recommend using it#2018-02-0610:08thhelleryeah docs were the biggest weakness of shadow-cljs which is why I now document everything first#2018-02-0610:08thhelleror try to anyways 😉#2018-02-0610:09orestisIt’s a difference though in the sense that shadow parses the various require statements its own way, while to the untrained eye you wouldn’t be able to know which build tool is used. Whereas the shadow loader is explicit.#2018-02-0610:09orestisThe shadow docs are fantastic, BTW. It’s just that to an outsider I just didn’t get the rationale immediately.#2018-02-0610:10thhelleryeah code loading is tricky since it really needs build tool support#2018-02-0610:10thhelleryeah I will add a Rationale section to the docs definitely#2018-02-0610:10thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/shadow-cljs-introduction.html has some things#2018-02-0610:12orestisA feature comparison matrix might also be a good idea? I hope I could help out a bit more but I’m just finding my way around CLJS for hobby work, with an eye of medium-term adoption in some projects, could be more than a year away…#2018-02-0610:21orestisReading the docs again, it is really a fantastic piece of work. I’ll definitely be using shadow-cljs for my hobby projects. Great job and thanks again! (and do consider setting up a Patreon or applying to Clojurists together!)#2018-02-0611:04JonCan we keep a FQA for this kind of questions? Maybe on ClojureVerse or GitHub issues, and with an index page somewhere... @thheller @orestis#2018-02-0611:05thhellertrying to write a section for the docs that explains the differences (and rationale)#2018-02-0611:05orestis@jiyinyiyong @thheller Let me know if I can be of any help (even editing the discussion into a Q&A form that could be expanded/vetted later)#2018-02-0611:06Jonwe can still link questions/answers to UserGuide from that index though...#2018-02-0611:08JonBTW I got these configs on my Nginx:#2018-02-0611:08Jon
server {
  server_name  ;
  location / {
    deny all;
  }
  rewrite ^/(.*)$  permanent;
}
#2018-02-0611:09Jonif someone happens to use , he/she will be redirected to UserGuide.#2018-02-0614:49mynomoto@thheller I tried the cljs-react-native-app, updated all deps to the latest from react create app and It just worked. Thank you! I will try do a PR later to update those on the examples repo.#2018-02-0615:37mynomotoIs there any vim users of shadow-cljs with an working config to connect to the repl?#2018-02-0617:19mitchelkuijpers@fatihict ^^^^#2018-02-0619:03tungstenhas anyone used material-ui/material-ui-next directly from npm with shadow-cljs?#2018-02-0619:05thhellerI did a few tests with material-ui while ago yes, did not try next#2018-02-0619:20thheller@bfast one thing to note about material-ui is that they provide an index file which includes everything but acessing individual components is also possible#2018-02-0619:21thhellerso always try to include components directly. (:require ["material-ui/Card" :default Card :refer (CardHeader)]) and such#2018-02-0619:21thhellerinstead of importing "material-ui" and picking apart that object#2018-02-0619:22thhellerthey also ship pure ES6 it seems so (:require ["material-ui/es/Card" ...]) should also work#2018-02-0619:23thhelleravoid (:require ["material-ui" ...]). should save a ton of bytes unless you are actually using everything#2018-02-0619:27tungstenthanks thheller. Does this work better than the vanilla cljs compiler#2018-02-0619:28thhelleryes#2018-02-0619:28tungstenis this by infering externs? just trying to understand#2018-02-0619:29thhellerno. shadow-cljs handles npm packages very differently and doesn't use anything from the :npm-deps functionality in CLJS (since it doesn't work)#2018-02-0619:30thhellerexterns inference helps too though#2018-02-0619:32tungstenhow do you integrate shadow-cljs with a full stack clj/cljs project#2018-02-0619:32thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#2018-02-0619:32thhellershould cover everything you need#2018-02-0619:33thhellerif you have lein setup already you can do it via https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2018-02-0619:36tungstenthanks#2018-02-0619:36tungstenIt would be nice if there was a plugin similar to lein cljsbuild... so that shadow-cljs could be invoked as part of the build process for generating an uberjar#2018-02-0619:38thhellerlein :aliases {"build-uberjar" ["do" ["run" "-m" "shadow.cljs.devtools.cli" "release" "your-build"] "uberjar"]}#2018-02-0619:39thhellerbash or make or anything really shadow-cljs release your-build && lein uberjar#2018-02-0620:41mynomoto@thheller Dominic over #vim-fireplace told me that you could have the incantation to get a cljs-repl working on vim using shadow-cljs.#2018-02-0620:44thhellerI had it once but completely forgot how it worked#2018-02-0620:44thhellercan you connect to the nrepl properly?#2018-02-0620:58dominicm@thheller I recall there was a function to call for the repl-env#2018-02-0620:59thhellershadow-cljs watch the-build then in vim :Connect and :Piggieback :the-build?#2018-02-0620:59dominicmThat's the one#2018-02-0621:06mynomotoThat worked mostly. I can jump to definitions and namespaces but show docs returns an error. Thanks, that will get me going.#2018-02-0621:06thhelleryou might need cider-nrepl on the classpath? not sure if the vim stuff uses that#2018-02-0621:08mynomotoIs there an example somewhere with different test and and prod dependencies? I'm thinking something like using react-with-addons for testing and plain react for prod.#2018-02-0621:08mynomotoI think fireplace adds that, but I will check, thanks.#2018-02-0621:10thhellerarent react addons deprecated?#2018-02-0621:11thhellerotherwise for test/prod stuff you control it all via the namespaces that are required#2018-02-0621:11thhellerfor dev you typically add :preloads#2018-02-0622:22thheller@lilactown I just added the missing :node-test target. See https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test#2018-02-0622:22lilactown❤️#2018-02-0622:23lilactownI’m guessing I need to pull down the latest version of shadow-cljs?#2018-02-0622:24thhelleryes 2.1.3#2018-02-0703:01mjmeintjes@bfast I'm using material-ui-next directly from npm with shadow-cljs, and it works great. For me it was a bit difficult figuring out how to require the different components, as some require using default and some require using refer. Here's my current imports, maybe that will help:
["material-ui/Button/Button" :default Button]
   ["material-ui/IconButton" :default IconButton]
   ["material-ui/Progress/LinearProgress" :default LinearProgress]
   ["material-ui/Radio/Radio" :default Radio]
   ["material-ui/Radio" :refer [RadioGroup]]
   ["material-ui/Form" :refer [FormLabel FormControl FormControlLabel FormHelperText]]
   ["material-ui/Switch" :default Switch]
   ["material-ui/Dialog" :default Dialog]
   ["material-ui/AppBar/AppBar" :default AppBar]
   ["material-ui/Toolbar" :default Toolbar]
   ["material-ui-icons/Menu" :default MenuIcon]
   ["material-ui-icons/Close" :default CloseIcon]
   ["material-ui-icons/MoreVert" :default MoreVertIcon]
   ["material-ui-icons/ExpandMore" :default ExpandMoreIcon]
   ["material-ui-icons/ExpandLess" :default ExpandLessIcon]
   ["material-ui/Menu" :default Menu :refer [MenuItem]]
   ["material-ui/Typography" :default Typography]
   ["material-ui/Card/Card" :default Card]
   ["material-ui/Avatar" :default Avatar]
   ["material-ui/Card" :refer [CardHeader CardMedia CardContent CardActions]]
   ["material-ui/Paper" :default Paper]
   ["material-ui/transitions/Collapse" :default Collapse]
   ["material-ui/TextField" :default TextField]
   ["material-ui/Drawer/Drawer" :default Drawer]
   ["material-ui/List/List" :default List]
   ["material-ui/List" :refer [ListItem ListItemIcon ListItemText]]
   ["material-ui/Divider" :default Divider]
   ["material-ui/ExpansionPanel/ExpansionPanel" :default ExpansionPanel]
   ["material-ui/ExpansionPanel" :refer [ExpansionPanelDetails ExpansionPanelSummary]]
Using the components is then simple, just use the special :> operator reagent provides, for example [:> Card {} ]
#2018-02-0710:42mynomoto@mjmeintjes that :> seems very interesting, I have been using reagent for a long time and I have never heard of it. Can you point me to some docs?#2018-02-0717:16colindresjFor those interested, just thought I post some pretty cool info: we’ve been porting over a large CLJS app from lein-cljsbuild + a lot of cljsjs and manually created foreign libs over to shadow-cljs and completed that task this morning. The productivity gains are one thing, but tangibly we’ve gone from an uncompressed 9.9MB build to 2.7 MB and gziped 1.4MB to ~700k#2018-02-0717:16colindresjLayer on the potential benefits form code-splitting, and that’s a a huge win for us thanks to shadow-cljs#2018-02-0717:16colindresjBig thank you to @thheller#2018-02-0717:23justinleewow interesting @colindresj. Where do you think most of the gains are coming from? I knew that shadow-cljs made it easier to import, but I didn’t realize it would do better at minification#2018-02-0717:24colindresjHaven’t done a deep-enough dive to figure it out just yet @lee.justin.m, but I’m guessing that since foreign libs (including those in cljsjs) don’t go through any kind of optimization, there’s a lot of duplication and dead code there#2018-02-0717:25colindresjEspecially when using JS libraries that are pre-compiled via Babel, I’ve noticed that a lot of our foreign libs contain the same Babel helpers over and over again#2018-02-0717:50dominicmI'd be interested in knowing about the optimization benefits too. I had not considered the duplication before, very interesting.#2018-02-0717:50dominicmI suppose duplication matters little with gzip though?#2018-02-0717:52justinleethe biggest thing that I know shadow allows you to do is reference partial components. e.g. material-ui lets you refer to just the component you are using. that’s actually possible to do in shadow#2018-02-0717:53justinleeif you set your foreign-lib up properly, you should be pointing to minified builds during production. if you guys were doing that and you are still seeing gains, that would be pretty amazing#2018-02-0717:55orestisGzip takes care of shipping the code to the browser, but the browser still has to parse and execute all the duplicate stuff.#2018-02-0720:09colindresj@dominicm I think so, which is why the gains at the point of gzip are proportionally much smaller than pre-gzip#2018-02-0720:10colindresj@lee.justin.m we were minifying our own foreign libs, hard to know for sure about all the others#2018-02-0720:30thheller@colindresj nice! biggest gain is probably from de-duping some stuff. closure :simple mode (which is used for npm deps) is also pretty good though, so thats part of it too.#2018-02-0720:42thhellerbut you essentially validated exactly why I wanted to get away from cljsjs. https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#cljsjs#2018-02-0720:43thhellerglad I'm not the only one seeing those results#2018-02-0720:55pepeHi, I am trying to use beicon with shadow-cljs on node, but getting this: The required namespace "beicon.impl.rxjs" is not available, it was required by "beicon/core.cljc". I skimmed last couple of days and found some similar stuff but somehow I can't get my head around it. The problem I guess is that beicon is using https://github.com/funcool/beicon/blob/master/assets/deps.cljs and it is not compatible with shadow-cljs.#2018-02-0720:56thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_migrating_cljsjs#2018-02-0720:56thhellernpm install rxjs#2018-02-0720:56pepeThanks!#2018-02-0720:57thhellerI'm not entirely sure how the shim file would have to look#2018-02-0720:58thheller
(ns beicon.impl.rxjs
  (:require ["rxjs/Rx" :as rx]))

(js/goog.exportSymbol "Rx" rx)
#2018-02-0720:58thhellermaybe?#2018-02-0720:58thhellerrx is one of those packages where you are better off importing only what you need directly#2018-02-0720:59pepeOk, I will try it#2018-02-0721:05pepeSo at least compilation is working. I will report how it will continue. I started to play with shadow this week and I fell in love.#2018-02-0721:06pepeSo this is my first try with small node library. If I manage to work with it, I am planning to move our front-end app to it#2018-02-0721:06pepeThank you very much again#2018-02-0721:08pepeWell everything is working for me#2018-02-0721:08thhellerhehe I did a quick test and rxjs loads 400+ files#2018-02-0721:08thhellerthats a bit scary 😛#2018-02-0721:08pepe😄#2018-02-0721:08thhellerbut it seems to work#2018-02-0721:09pepeIt does indeed#2018-02-0803:14mjmeintjes@mynomoto Here you go: https://reagent-project.github.io/news/news060-alpha.html, check the "Better interop with native React"#2018-02-0805:25armedHey, could somebody point me example with shadow-cljs on frontend and clojure as a server? Is this worth doing or just use classic figwheel approach?#2018-02-0805:55armedNwm, figured out. Was easier than expected#2018-02-0809:18orestisAny success stories in using shadow-cljs to write node servers? Piggy-backing onto popular “mainstream” JS libraries (e.g. Express et al) while keeping the business logic in CLJS.#2018-02-0809:35thhellerI think it is very common for most people to use Clojure on the server side (I do personally) so CLJS on the server is not too common yet.#2018-02-0809:47orestisApparently so… unfortunately having a REPL-driven with Node is a bit frustrating. I managed to get a working nREPL CLJS connection from Atom to shadow-cljs, but it’s still a bit flaky.#2018-02-0809:48orestisThe reloading story is much better though, and for people coming over from JS it should be a familiar experience.#2018-02-0809:49thhellerflaky how?#2018-02-0809:50thhellerI don't do much node development so if there are things that could be improved from the CLJS side let me know#2018-02-0810:02orestisOne immediately obvious thing is that compilation failures didn’t show up in Atom. Given the multitude of moving parts, I’d like to do some triaging before creating bug reports, it could be my fault, or proto-repl, or some other thing…#2018-02-0810:04thhellerwhat you can do is run shadow-cljs from a terminal inside atom#2018-02-0810:04thhellerterminal-plus or something like that#2018-02-0810:05thhellerI don't know it proto-repl shows any stdout output from the REPL.#2018-02-0810:10mitchelkuijpersI am trying out shadow-cljs 2.1.4 we are coming from 2.0.x and we get babel errors for some reason.. Was there a change that triggers this?#2018-02-0810:10mitchelkuijpers
ReferenceError: [BABEL] shadow$empty.js: Unknown option: /home/mitchel/Development/atlas-crm-next/node_modules/react/react.js.Children. Check out  for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

#2018-02-0810:14mitchelkuijpersOh I had a .babelrc that was causing this.. Sorry for the noise#2018-02-0810:15thhellerhmm weird?#2018-02-0810:19thheller.babelrc should be ignored for files in node_modules so if that wasn't an issue before thats definitely a bug#2018-02-0810:32Jon[Vote] https://clojureverse.org/t/which-is-your-preferred-way-to-use-a-build-tool-like-shadow-cljs/1566#2018-02-0810:35mitchelkuijpersThat might be a bug then.. Btw really loving the new loading indicator#2018-02-0810:36mitchelkuijpersAnd the warnings look a lot better too#2018-02-0810:36thhellerk, I'll check it out#2018-02-0810:36mitchelkuijpersBut it also said I had a configuration error so it might be my fault#2018-02-0810:37thhelleryeah but it shouldn't even be looking at .babelrc so it shouldn't matter whats in there#2018-02-0810:37mitchelkuijpersAh ok#2018-02-0811:10wilkerluciohello, I'm getting a weird warning from shadow-cljs:#2018-02-0811:10wilkerlucio
------ WARNING #1 --------------------------------------------------------------
 File: /Users/wilkerlucio/Development/pathom/src/com/wsscode/pathom/core.cljc:70:1
--------------------------------------------------------------------------------
  67 |                     (gen/call-gen g rdn size))
  68 |                   (gen/call-gen (gen/return []) rdn size)))))))
  69 |
  70 | (s/def ::mutation-expr
-------^------------------------------------------------------------------------
 No such namespace: operation.on, could not locate operation/on.cljs, operation/on.cljc, or JavaScript source providing "operation.on"
--------------------------------------------------------------------------------
  71 |   (s/with-gen
  72 |     (s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
  73 |     #(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
  74 |               val  (s/gen ::params)]
--------------------------------------------------------------------------------
#2018-02-0811:10wilkerluciooperation.on? my doesn't mention that at all#2018-02-0811:10wilkerluciostarted happening after loading test.check and generator things#2018-02-0811:11thhellermost likely the :require-macros thing again .. this is really beginning to bother me.#2018-02-0811:11thhellerhttps://github.com/thheller/shadow-cljs/issues/154#issuecomment-354760020#2018-02-0811:12thhelleris this just test.check or do you have any macros involved in this?#2018-02-0811:13wilkerluciojust test.check and spec, these are my requires:#2018-02-0811:13thhellerhttps://dev.clojure.org/jira/browse/CLJS-2454#2018-02-0811:13wilkerlucio
(ns com.wsscode.pathom.core
  (:refer-clojure :exclude [ident?])
  (:require
    [clojure.spec.alpha :as s]
    [clojure.set :as set]
    [clojure.test.check :as tc]
    [clojure.test.check.generators :as gen]
    [clojure.test.check.properties :as prop]
    [clojure.walk :as walk]
    [fulcro.client.primitives :as fp]
    #?(:cljs [goog.object :as gobj]))
  #?(:clj
     (:import (clojure.lang IAtom IDeref))))
#2018-02-0811:13thhellerseems like a bunch of stuff is relying in this broken behaviour 😞#2018-02-0811:14thhellerat this point I feel like giving up and just adding the broken stuff#2018-02-0811:14wilkerlucioI tried to add :include-macros on all of then, but no effect#2018-02-0811:15thhellerno the test.check stuff doesn't do it correctly (internally)#2018-02-0811:15thhellernothing you can do really#2018-02-0811:16thhellerI have to finish some work stuff. I'll look into this after#2018-02-0811:17wilkerluciothanks, what is been done wrong? does test.check has to require itself? just trying to understand#2018-02-0811:20thhellersee the CLJS issue, it is missing the :require-macros for itself in .cljc files with macros#2018-02-0811:21wilkerluciogotcha#2018-02-0811:21thhellermight also be spec itself#2018-02-0811:23thhelleryeah it this one https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/generators.cljc#L10-L21#2018-02-0811:24thhellerso the gen/let macro is not handled properly internally I assume#2018-02-0811:24thhellerback to work#2018-02-0812:48thheller@wilkerlucio I just noticed that (s/gen '#{do-something create/this-thing operation.on/space}) is in your code?#2018-02-0812:49thhelleris spec maybe trying to resolve that?#2018-02-0813:07thheller@wilkerlucio [clojure.test.check.generators :as gen :include-macros true] this seems to work?#2018-02-0813:08thhellerbut I'm not getting a compile error without it, only an error at runtime?#2018-02-0813:08thhellerdo you have the full code available so I can test this in your setup?#2018-02-0813:26wilkerlucio@thheller sorry the delay, was in meetings#2018-02-0813:26wilkerlucioactually my code has that, but it's quoted (sorry bad info before, didn't even occurred to me to look at quoted things)#2018-02-0813:26wilkerlucioit shouldn't try to eval it#2018-02-0813:26wilkerlucio
(s/def ::mutation-expr
  (s/with-gen
    (s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
    #(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
              val  (s/gen ::params)]
       (list key val))))
#2018-02-0813:27wilkerlucioI can send the full source in a min#2018-02-0813:33thheller
(do ;; s/def ::mutation-expr
  (s/with-gen
    (s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
    #(gen/let [key (s/gen '#{do-something create/this-thing operation.on/space})
               val  (s/gen ::params)]
       (list key val))))
#2018-02-0813:33thhellerthis compiles fine#2018-02-0813:34wilkerlucioI'm going to try a few things, just at work now, limited time, probably going to do more later once I get home#2018-02-0813:35wilkerlucio@thheller this works:#2018-02-0813:35wilkerlucio
(def sample-mutations '#{do-something create/this-thing operation.on/space})

(s/def ::mutation-expr
  (s/with-gen
    (s/and list? (s/cat :mutate-key symbol? :params (s/? ::params)))
    #(gen/let [key (s/gen sample-mutations)
              val  (s/gen ::params)]
       (list key val))))
#2018-02-0813:36wilkerluciobut that' weird, why I can't use the quoted directly there? I can try on pure cljs to see if it's a problem with cljs ou shadow, not sure at this point#2018-02-0813:38wilkerlucioon clojure side this is not an issue#2018-02-0813:40thheller
clj build.clj
WARNING: No such namespace: operation.on, could not locate operation/on.cljs, operation/on.cljc, or JavaScript source providing "operation.on" at line 9 src/test/foo.cljs
WARNING: No such namespace: create, could not locate create.cljs, create.cljc, or JavaScript source providing "create" at line 9 src/test/foo.cljs
#2018-02-0813:41thhellerdefault cljs fails as well#2018-02-0814:14wilkerluciothanks for helping with this debug#2018-02-0814:19wilkerlucioI'm looking if there is an issue on Jira, seems not, I'll open one#2018-02-0815:47thhellerI'm trying to get back into blogging. I'll try to capture most of features of shadow-cljs and why they exist in future posts. https://twitter.com/thheller/status/961626241655812097#2018-02-0817:56justinleeyou know @thheller when i read through all the work you’ve done on this project, I sometimes wonder if it wouldn’t have been easier if the cljs compiler just did DCE analysis itself on the clojurescript side, then produced normal javascript code that was bundled by webpack, skipping the entire google closure compiler step.#2018-02-0818:06orestisI don’t think when CLJS started out that it was feasible to do that — closure was probably the right decision back then.#2018-02-0818:10wilkerlucioand the Closure Compiler compilation is still one of the best available, also we leverage the goog apis, when CLJS was build this was all state of art#2018-02-0818:11orestisArguably it still might be.#2018-02-0818:12wilkerlucioyeah, but I guess the thing was to pick something robust, and the closure toolset is a good candidate, after all this is what google was using to build their major apps like gmail#2018-02-0818:19justinleeoh yea i’m sure it was the right choice then. i am really just curious whether symbol renaming is worth it.#2018-02-0818:24justinleei’m just being selfish in terms of what I want: I think my life would be easier if the cljs portion of my code just built itself into a self-contained js package and interacted with npm modules just like other js code and let me do the packaging with webpack.#2018-02-0818:28colindresj@thheller any interest in a PR for a CLI command that will auto generate a deps.cljs file from the package.json dependencies?#2018-02-0818:37orestis@lee.justin.m isn’t it possible to do this today? It is my impression that with shadow you can create an “npm module” that exports something and then you can consume it as you like.#2018-02-0818:38pepeThe problem with shared code, you mention in the article is exactly my problem. I have an app that have two client SPAs, one node rest server and couple of small node services. With shadow-cljs I am actually starting to see the light on the end of the tunnel. Only thing that bother me now is the #dailyprogrammer compatibility for the front end SPAs development. My workflow is very dependent on its functionality.#2018-02-0818:41justinlee@orestis that doesn’t solve the symbol renaming problem or the fact that you have to do so much work to call javascript from cljs. anyway sorry, it’s way off topic. i didn’t mean to clutter the channel.#2018-02-0818:43orestisThings that are exported should be not be renamed, I’m fairly certain that both shadow and the CLJS compiler can do that. Calling cljs from JS should not be that problematic given that CLJS functions are JS functions. You may have to write a JS shim layer on top though.#2018-02-0818:53justinleeYea I get all that. It’s just super error prone and clumsy as hell. That’s why people write libraries like cljs-oops just to avoid using externs. The npm integration is also clumsy, which is in part why we have shadow-cljs. If you are a medium level programmer like me who doesn’t fully understand (1) the internals of the google closure compiler, (2) the internals of cljs, (3) the intricacies of npm modules resolution and management, then it is a total nightmare to port an existing javascript website over. I don’t really know the answers, but I will say that it seems to me a lot of this chaos stems from (1) the fact that clojurescript takes over dependency management instead of integrating into the js ecosystem way of doing dependency management (2) symbol renaming#2018-02-0819:01justinleejust as an example: these are the notes I took for myself as I worked through all this stuff https://gist.github.com/jmlsf/d691e53e1fea4019a393412f781e2561#2018-02-0819:19wilkerlucioyou can mark a symbol as external, so it doesn't get minified eg (def ^:extern some-thing)
#2018-02-0819:20wilkerlucioI don't remember for sure if that is the correct keyword, but I'm pretty it exists#2018-02-0819:21wilkerluciojust found an article, it's actually ^:export: http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/#2018-02-0819:37justinleei realize there exist solutions. my point is that they clumsy and error prone and the documentation and tooling around this stuff is crazy complicated. my original point is that if we didn’t do symbol renaming, we could just call javascript and vs versa without any worries.#2018-02-0819:40thheller@lee.justin.m your notes are impressive and I feel your pain. shadow-cljs does things differently precisely because of the things you describe#2018-02-0819:40thhellerCLJS itself is pretty broken and clumsy indeed#2018-02-0819:41thhellerexterns are still a challenging subject but variable renaming is one of the most important things when it comes to saving bytes. so we can't really get away from that.#2018-02-0819:41thhellerespecially with the huge names CLJS generates for its fns.#2018-02-0819:43thhellerexterns inference is actually pretty reliable today and will spot most of the issues. I have completely removed all externs from my builds and completely rely on the inference. https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-02-0819:43thhellerbut again ... in CLJS it is still very unreliable#2018-02-0819:46justinlee@thheller well i just did a git checkout -b shadow so i’ll let you know in a few hours how it goes 😛#2018-02-0819:46justinleethe nightmare now is figuring out what this infernal leiningen template is doing for me to so i can use shadow instead#2018-02-0819:46thhellerif it is anything but npm install react-dnd and (:require ["react-dnd" :as dnd]) let me know 😉#2018-02-0819:47thhelleralthough IIRC react-dnd did some fancy stuff with HoC components and ES7 decorators#2018-02-0819:48justinleewell i just mean i have this giant lein thing that some tool created for me that has a ring handler and figwheel and piggieback and all this stuff i don’t fully understand#2018-02-0819:48justinleei’m hoping i can just start a shadow watcher and things will work#2018-02-0819:37thheller@lee.justin.m :npm-module does what you asked. processes CLJS with closure but lets you do the final packaging with webpack or others. I still consider the Closure Compiler to be the most advanced JavaScript tool out there so there are no other options for me.#2018-02-0819:39thheller@colindresj I'd prefer if that was just a normal clojure function so ALL tools could potentially benefit from it. you can run shadow-cljs clj-run your.tool/build-deps-cljs ... to execute it. similary lein run -m your.tool/build-deps-cljs ...#2018-02-0820:50colindresj@thheller that’s what I’m doing on my own, but was wondering if it would be worthwhile to have it available for others when they use shadow-cljs#2018-02-0820:53thhellerI'm strill trying to figure out how I want to approach publishing libraries with shadow-cljs. I really wish there was a tool agnostic way of doing this. your fn would fit well into such a tool#2018-02-0820:54thhellernot so much into shadow-cljs itself at this point since you can't use it to publish libs yet 😛#2018-02-0820:58colindresjHaha right, that makes sense#2018-02-0820:58colindresjMight put my function up on clojars or something and mention it here in case anyone else is doing libs with shadow-cljs#2018-02-0820:59thhellerhappy to include it in the readme/docs. still need to write that chapter on publishing libs#2018-02-0821:03colindresjCool#2018-02-0821:04justinleedumb question: what URL am I supposed to load once I have my watcher going? I tried to load but I get a shawdow-cljs generated webpage that has a link to Release Snapshots instead of my index.html#2018-02-0821:05thheller@lee.justin.m you need to configure a separate webserver for your build. see https://shadow-cljs.github.io/docs/UsersGuide.html#_http_server#2018-02-0821:05thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L22-L24#2018-02-0821:06thheller9630 is the server for shadow-cljs itself which will eventually serve the GUI#2018-02-0821:16justinleeokay i see. i think that’s working (although :http-handler {:http-handler shadow.http.push-state/handle}) gave me this error ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named. now my program is broken in some other way but it does appear to be loading.#2018-02-0821:17justinleeis main! a convention for the entry point? i just followed your medium article and changed my code to use that symbol. in the lein template i had been using, it needed an init! symbol#2018-02-0821:24thhellerdo you need push-state? it is optional and should just be :http-handler shadow.http.push-state/handle not nested in itself 😛#2018-02-0821:24thhellerthe medium article was written by @jiyinyiyong. no it is not convention. I always recommend the init/start/stop setup in my template.#2018-02-0821:25thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2018-02-0821:25thhellerie. call init from HTML, which calls start. live reload calls stop :before-load, then start :after-load#2018-02-0821:27thhellertweaked the http section a bit https://shadow-cljs.github.io/docs/UsersGuide.html#browser-http-server#2018-02-0821:29justinleethe push-state issue was my fault doh!#2018-02-0821:34justinleespiffy. that’s working and, unlike 80% of the time with cljs, I actually understand why 🙂#2018-02-0822:36justinleeby the way, i meant to say that the tweaked http section is very nice.#2018-02-0822:47thhellerI also tweaked the config specs so the error you run into with :http-handler gets a reasonable error. keep the feedback coming if you run into anything. it helps a lot.#2018-02-0822:54justinleeone small thing: for some reason, shadow is loading the minified development version of react. I tried to add
:js-options {:resolve {"react" {:target :npm
                                                   :require "react/dist/react.js"}}}}}}}
but it doesn’t seem to change anytning
#2018-02-0900:09justinleeokay well i can’t get react-flip-move to import: i get nil. i’m pretty sure this is a bug so i’ll open an issue so you have all the context#2018-02-0902:44justinlee^ sorry the problem above is that I had put :js-options inside of :devtools (would be super cool if there were warnings about config keys in unexpected places)#2018-02-0909:06thheller@lee.justin.m shadow-cljs indeed always minimizes files and react unfortunately complains about this during development. for shadow-cljs release it will use their correct production js and not minify the dev version. so the warning is the only problem.#2018-02-0909:16pepeI have created sample repo with both node and browser apps. It is just bare bones. https://github.com/pepe/two-in-shadows#2018-02-0909:16pepePlease tell me what you think about it.#2018-02-0909:17pepeAlso I have no problem to hook the #dirac#2018-02-0909:21thheller@pepe cool. you can run shadow-cljs watch client server to watch both builds in one process. no need to use separate processes.#2018-02-0909:21pepe@thheller great, thank you#2018-02-0909:27cmalHi, I use (:require ["qiniu" :as qiniu]) to import a node library to clojurescript in shadow-cljs. But I got stuck when trying to write javascript
var mac = new qiniu.auth.digest.Mac(key1, key2)
in clojurescript. I tried
(def mac (-> (qiniu.auth.digest/Mac access-key secret-key)))
but failed. How should I do this?
#2018-02-0909:28thhellerqiniu/auth.digest.Mac should work#2018-02-0909:28cmalThanks!#2018-02-0909:28cmal😂#2018-02-0909:29thhellerthe aliases created by :as must always be used as-is. qiniu.auth.digest is not a valid alias#2018-02-0909:29cmalOK#2018-02-0909:30thheller(def mac (qiniu/auth.digest.Mac. access-key secret-key))#2018-02-0909:31thhellernot the . at the end. that is sugar for new.#2018-02-0910:33pepeSo I successfully (and easily) added shared code to the sample. Man it feels great#2018-02-0915:53Jon
------ ERROR -------------------------------------------------------------------
 File: /Users/chen/repo/memkits/manuscript/src/app/util.cljs:6:11
--------------------------------------------------------------------------------
   3 |
   4 | (defn focus-text! []
   5 |   (js/requestAnimationFrame
   6 |    (fn [] (let [element (.querySelector js/document ".text"), .focus element] ))))
-----------------^--------------------------------------------------------------
Invalid local name: .focus at line 6 app/util.cljs
--------------------------------------------------------------------------------
#2018-02-0915:53Jonno more responding to my file changes after throwing this error...#2018-02-0915:54Jonrestarted server to make it work.#2018-02-0918:18justinleewell @thheller i really appreciate the help. i wanted to say thanks so much for your help and amazing work you are doing. for now, i have to declare defeat. i’ve spent too much time trying to make my project work in cljs and i just have to go back to javascript where i can be productive.#2018-02-0918:19justinleeif there were about 10 more of you i think everything would be different#2018-02-0918:19thhellerwhat happened?#2018-02-0918:21thhellerI can't let you go back to JS just yet 😉#2018-02-0918:22justinleebasically i’ve got a website i’m trying to build. i use a few libraries: flip-move, react-virtualized, react-dnd. it’s just excruciating to try to figure out how to use them in cljs. what i hate most of all is that i cannot figure out what’s going on. like yesterday trying to figure out why flip-move won’t load. there’s just nothing for me to do. i tried like 50 combinations of random shit in my config files and different versions of libraries#2018-02-0918:22justinleein JS if i have a problem i can methodically work through it. but in cljs i just get stuck. there’s nothing more i know to try#2018-02-0918:23justinleei reported the flipmove issue, but also several of my react-dnd libraries weren’t loading. i got an error message in teh console, but i have no idea what to do about it#2018-02-0918:23justinleeso maddening#2018-02-0918:24thhelleryeah the :as vs :default issue is a bit annoying due to the inconsistencies in JS#2018-02-0918:24justinleei opened up a new portion of my website that i’m trying to port and saw all of the crazy s* i have built with react-vritualized and i realized it was going to be super hard#2018-02-0918:24thhellerdid you try :npm-module at all?#2018-02-0918:24thhellerthis would let you keep your old toolchain and load CLJS into that#2018-02-0918:25justinleethe thing is that the primary thing i want from cljs is state management. atoms + specter is freaking amazing#2018-02-0918:25justinleewait#2018-02-0918:25justinleemaybe i don’t understand what you’re proposing#2018-02-0918:25thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2018-02-0918:26thhellerthis will compile CLJS into something CommonJS-ish#2018-02-0918:26thhellerso require from JS just works#2018-02-0918:27thhellerbut this only generates the CJS output. it is then treated like any other JS file by JS tool, ie. webpack#2018-02-0918:28thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/cljs-react-app#2018-02-0918:28justinleeso then i just access everything useing the js global accessors?#2018-02-0918:28thhellerthis demo is a bit old but it demos the integration in create-react-app#2018-02-0918:29thhellerno (:require ["react-dnd"]) stays just like that#2018-02-0918:29thhellerbut instead of shadow-cljs providing the value for this#2018-02-0918:29thhellerit just emits require("react-dnd") and lets webpack provide it#2018-02-0918:30thhellerso you literally make no modification to your webpack setup#2018-02-0918:30thhellershadow-cljs compile npm (default config included, no extra build config required)#2018-02-0918:30thhellerand then require("shadow-cljs/your.ns") and let webpack find it#2018-02-0918:31justinleeinteresting. question: is there a “verbose” mode in shadow-cljs to explain what it is doing when it tries to load a library?#2018-02-0918:32justinleebecause that would have helped me when i was trying to figure out what was going on#2018-02-0918:32justinleelike literally list every js file it is loading and why#2018-02-0918:32thhellerthe resolve rules are identical to node#2018-02-0918:33thheller(:require ["react-dnd"]) looks at node_modules/react-dnd/package.json for main#2018-02-0918:33thhellerreads that file, parses out all its require calls or import#2018-02-0918:33thhellerfollows those and so on#2018-02-0918:33thhellerit doesn't list the files exactly in the log output but I can add that if you want#2018-02-0918:34thhellerI think you got burned hard by the :foreign-libs mess and NOTHING from that applies to shadow-cljs#2018-02-0918:34justinleeokay well let me just try to see if i can get these packages to load before i give up#2018-02-0918:35thhellershadow-cljs pretty much does exactly what webpack does#2018-02-0918:35justinleei think the hard part is that in JS you just cut-n-paste whatever magical BS is required to get things to load. you need to understand that stuff and translate it in cljs#2018-02-0918:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-02-0918:37thhellerI made a translation table for that exactly#2018-02-0918:37justinleeyea but i did that and it didn’t work 🙂#2018-02-0918:37thhellerhowever you got bitten by the problem I described where react-flip-move pretends to be ES when it isn't#2018-02-0918:37justinleebelieve me there’s nothing you’ve written that i haven’t read at this point#2018-02-0918:39thhellerwhat you can always do is (:require ["thing" :as x]) and then (js/console.log "x" x)#2018-02-0918:40thhellerif that is just an object with a .default property you are better off using :default#2018-02-0918:40thhellerotherwise :as is always the safer choice#2018-02-0918:41thhellerdue to old compat issues there may also be a .default$ property but that is just :default again#2018-02-0918:41thhellerthe situation with ES6 default exports is really strange#2018-02-0918:42thhellerbut AFAICT thats also true in node world#2018-02-0918:42thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2018-02-0918:43justinleei guess the other thing i was puzzling through is the fact that reagent used to require cljsjs versions of react. so i excluded those. but I just could be sure what I was doing was working. that’s kind of why i was wishing for some kind of diagnostic.#2018-02-0918:43thhellerit still does#2018-02-0918:43thhellerbut as a migration shadow-cljs includes these shim files#2018-02-0918:43thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#2018-02-0918:44justinleecan’t i just exclude them?#2018-02-0918:44justinleethat seemed to work#2018-02-0918:44thhellerexcluding is fine but not required#2018-02-0918:45thhellerthe shim file basically maps the pseudo-ns that :foreign-libs otherwise would create back to the original npm package#2018-02-0918:45justinleewow you know why I couldn’t get react-flip to work? I was putting “.js” at the end of my :js-options :require.#2018-02-0918:45thhellerand then exports it to the global name the react foreign lib would have provided#2018-02-0918:46thhellerso technically you can require cljsjs.react and use js/React#2018-02-0918:47thhellerhow exactly? maybe I can validate that?#2018-02-0918:50justinleewait no that’s not it. args this is so annoying. i tried all of this last night and it didnt work#2018-02-0918:50thhellerwhy are you messing with it at all?#2018-02-0918:50thhellerhttps://github.com/thheller/issue-194/blob/master/src/starter/browser.cljs#2018-02-0918:51justinleei mean i saw that flip move had different distros and i tried resolving it to the .es module even before i reported that issue#2018-02-0918:51thheller
:js-options
{:resolve
  {"react-flip-move" {:target :npm :require "react-flip-move/dist/react-flip-move.es"}}}
#2018-02-0918:51justinleenow it’s working and i want to know how i screwed up so i don’t do it again#2018-02-0918:51thhellerdid I mess that up?#2018-02-0918:51justinleeno that works but i swear i tried that#2018-02-0918:51thheller:require "react-flip-move/dist/react-flip-move.es.js"#2018-02-0918:51thhellershould be fine too#2018-02-0918:52justinleethe only difference is that i use “react-flip-move/dist/react-flip-move.es.js”#2018-02-0918:52justinleebut both of those work now#2018-02-0918:58justinleeso back on my larger project. what does this mean and how i diagnose it:
shadow-cljs - failed to load module$node_modules$react_dnd$lib$DragDropContextProvider
shadow.js.jsRequire @ shadow.js.js:53
shadow$provide.module$node_modules$react_dnd$lib$index @ index.js:17
shadow.js.jsRequire @ shadow.js.js:51
shadow.js.require @ shadow.js.js:77
(anonymous) @ seekeasy.sidebar.js:10
#2018-02-0918:58thhellerthe actual error should be in there as well#2018-02-0918:59thhellerit rethrows the actual error that happened when importing#2018-02-0918:59thhellerso you should get an exception#2018-02-0918:59thhellerthe message just informs you which file failed to load#2018-02-0919:01thhellermodule$node_modules$react_dnd$lib$DragDropContextProvider is the internal namespace that is generated for the file#2018-02-0919:02dominicmIs the build target exposed anywhere? I have code which works in both node & browser with only a slight change.#2018-02-0919:07thhellerwhat do you mean? exposed at runtime?#2018-02-0919:10dominicm@thheller any time I guess build config or runtime, just need to be able to switch my code on it.#2018-02-0919:11thhellerswitch how?#2018-02-0919:11dominicmFor runtime I'd have to fallback on detection strategies I guess#2018-02-0919:11thhellerthe default recommended strategy would be a goog-define since it works with DCE#2018-02-0919:12dominicm
(dostuff
  (if (goog.node-js)
    (js/require "some-canvas-alt")
    (js/getElementById "canvas")))
I can do a goog.define 🙂
#2018-02-0919:13dominicmWanted to make sure there was nothing I'd be duplicating first#2018-02-0919:14thhellerugh you are getting into tricky territory with conditional requires but yes that would be a candidate for goog-define#2018-02-0919:14thheller(goog-define target "browser")#2018-02-0919:14thhellerthen in the node target :compiler-options {:closure-defines {your.ns/target "node"}#2018-02-0919:02thhellernode_modules/react-dnd/lib/DragDropContextProvider.js in this case#2018-02-0919:02justinleeunless something is messed up with my chrome, the above is all i got#2018-02-0919:04thhelleruhm I can't tell the actual error either, thats weird#2018-02-0919:05thhelleris this a fresh page reload?#2018-02-0919:06thhellerit literally just rethrows the error https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js#L53-L54#2018-02-0919:06thhellerno idea why that wouldn't show anywhere?#2018-02-0919:06justinleei’m going to try in a different browser#2018-02-0919:07thhelleryou can try chrome with pause on exception maybe#2018-02-0919:08thhellerI just tested (:require ["react-dnd"]) and it works just fine. what exactly do you require?#2018-02-0919:09justinleesame thing with firefox. i’m going to downgrade to react 15#2018-02-0919:10justinleesee if i get different resutls#2018-02-0919:10thhellerI'm on react v16#2018-02-0919:12justinleei’ll try this then i’ll start commenting things out until i get something sane#2018-02-0919:18dominicm@thheller Hmm, yes, I hadn't considered that conditional requires might be tricky territory. I don't want to compile into a single js particularly, I want to write a standalone js module (I think, haven't explored this far). Is there anything specific you'd recommend?#2018-02-0919:19thheller:closure-defines is static at compile time. if you prefer to detect at runtime instead you could use js/process.browser#2018-02-0919:20thhellerJS tools like webpack will set this. shadow-cljs does as well#2018-02-0919:21thheller@lee.justin.m react-dnd seems painfully hard to use even from the JS side. I would probably never be able to use this without looking at the docs every time.#2018-02-0919:22justinleethat’s true 🙂#2018-02-0919:22justinleei have it working though#2018-02-0919:23thhellercombining this with the weirdness that reagent does sometimes just smells like pain#2018-02-0919:25justinleeokay. now i’m losing my mind. i have removed react-flip-move from packages.json. my dependencies look like:
:dependencies
 [[org.clojure/clojure "1.9.0"]
  [org.clojure/clojurescript "1.9.946"]
  [reagent "0.8.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/creat-react-class cljsjs/react-dom-server]]
  [hiccup "1.0.5"]
  [secretary "1.2.3"]
  [cljs-http "0.1.44"]
  [com.rpl/specter "1.1.0"]
  [venantius/accountant "0.2.3" :exclusions [org.clojure/tools.reader]]
  [binaryage/oops "0.5.8"]
  [org.clojure/test.check "0.9.0"]]
and now i’m getting
The required JS dependency "react-flip-move" is not available, it was required by "cljsjs/react_flip_move.cljs"
Where is that cljsjs coming from?
#2018-02-0919:26thhellersomething is still requiring cljsjs.react-flip-move#2018-02-0919:26thhellerI think re-frame-trace does that#2018-02-0919:26justinleei’m not using re-frame#2018-02-0919:27justinleeis there a way to dump the dependency resolution graph?#2018-02-0919:27justinleekind of like yarn list#2018-02-0919:27justinleeor npm list#2018-02-0919:27thhellershadow-cljs clj-repl#2018-02-0919:27thheller(shadow.cljs.devtools.api/find-resources-using-ns 'cljsjs.react-flip-move)#2018-02-0919:30thhellerI should probably show the full graph in that exception, eg. everyone involved in that require#2018-02-0919:30justinleethat is SUPER useful#2018-02-0919:33justinleeokay got all of my stupidity out of the way. now i have a create-react-class issues:
shadow.js.js:53 shadow-cljs - failed to load module$node_modules$create_react_class$index
shadow.js.jsRequire @ shadow.js.js:53
shadow.js.require @ shadow.js.js:77
(anonymous) @ reagent.impl.component.js:3
shadow.js.js:54 Uncaught TypeError: m.Component is not a constructor
    at Object.shadow$provide.module$node_modules$create_react_class$index (index.js:23)
    at Object.shadow.js.jsRequire (shadow.js.js:51)
    at Object.shadow.js.require (shadow.js.js:77)
    at reagent.impl.component.js:3
#2018-02-0919:33justinleeweirdly, reagent will render a simple div#2018-02-0919:34thhellerthat means reagent is trying to new something thats supposed to be used a function#2018-02-0919:34thhellerbut I don't understand why you are getting failed to load?#2018-02-0919:35thhellerare you sure you are calling the DragSource setup stuff correctly?#2018-02-0919:35justinleei removed all of that stuff#2018-02-0919:36justinleei’m trying to get back to a hello-world and now i’ve obviously messed the buid configuration up so bad it won’t work#2018-02-0919:36thhelleris this in the test project? I'd love to see this state#2018-02-0919:36justinleethis doesn’t work anymore because of all the load errors:
(defn thing [] [:div "goodbye world"])

(defn mount-root []
  (reagent/render [thing]
                  (.getElementById js/document "app")))
#2018-02-0919:37thhellerand the build config?#2018-02-0919:37thhellerthere might be a caching error somewhere if you modified the node_modules directly while the compile is running#2018-02-0919:37thhellersince that modifies so many files it might just give up at some point#2018-02-0919:38justinleethe shadow config is just the dependencies vector, no additional options#2018-02-0919:38justinleei’ll nuke everything and restart#2018-02-0919:51justinleenothing is working. somehow i’ve messed up react and reagent. i downgraded to reagent 0.7.0 and i’ve installed the cljsjs/react.js shim#2018-02-0919:51thhelleryou never need to include the cljsjs/react shim. shadow-cljs provides this#2018-02-0919:52thhellerdid you nuke target/shadow-cljs?#2018-02-0919:52thhellerI'd really love to see the state the project is in though#2018-02-0919:54justinleejust tried that. same thing. so I should install react, react-dom, and create-react-app via npm, righT?#2018-02-0919:55thhelleryes#2018-02-0919:55thhellercreate-react-class you mean?#2018-02-0919:55thhellercreate-react-app no#2018-02-0919:55justinleesorry i mean create-react-class#2018-02-0919:57justinleeomg. i deleted node_modules, killed yarn.lock. only those three dependencies (react 15). i have reagent 0.7.0 with no exclusions. killed target. that got me back to a working state#2018-02-0920:00thhelleryou did restart the shadow-cljs process right?#2018-02-0920:00thhellerI mean the actual server process? didn't leave anything running in the background or so?#2018-02-0920:02thhelleruh I know what might have happend#2018-02-0920:02justinleeyea i haven’t been backgrounding the server because this smelled like caching. the one thing i haven’t been doing is killing the target. killing the target and resetting node_modules fixed whatever chaos i had created#2018-02-0920:02thhellernpm can install nested versions. so it maybe installed node_modules/thing/node_modules/react#2018-02-0920:02thhellerbut shadow-cljs only looks at node_modules/react never the nested versions?#2018-02-0920:03thhellermaybe yarn thought a thing was installed because it was nested#2018-02-0920:03thhellerbut shadow-cljs didn't find it and errored out on you?#2018-02-0920:04thhellerhmm damn we might never know 😛#2018-02-0920:04justinleei really don’t think that was it because i’m pretty sure i was looking at the create-react-class files#2018-02-0920:05justinleewell just wait 30 minutes and i’ll probably have it royally screwed up again#2018-02-0920:05justinlee🙂#2018-02-0921:04theaspDoes shadow-cljs clear the js console now?#2018-02-0921:04thhellerno#2018-02-0921:04theaspDamnit, wtf#2018-02-0921:04theasp😛#2018-02-0921:06theaspI have no idea whats doing it, but every refresh seems to clear the console, which is actually a bit convenient#2018-02-0921:07thhellerconsole.clear = function () { throw "who be calling me"; }#2018-02-0921:07thhellereval that in the chrome console 😉#2018-02-0921:11theaspNothing is thrown#2018-02-0921:12thhellerhmmm guess that doesn't work then 😛#2018-02-0921:14theaspYeah, either way, I think I like it, so if I find it and fix it, I would have to reimplement it#2018-02-0921:14thhellerdoesn't sound like a terrible idea so maybe I can add it behind a flag#2018-02-0921:15thhellerwould be good to find out who does it though#2018-02-0921:16theaspYeah, but should be trivial in the reload fn too. What would be even better is if the console can be scrolled to the bottom#2018-02-0921:16theaspHave a good weekend 🙂#2018-02-0921:17thhellerthx, you too!#2018-02-0921:39thhellerI wanted to see if I can compile a modern JS application with shadow-cljs. Turns out I can with no modifications to the source whatsoever. Only config stuff and a manual babel pass due to JSX.#2018-02-0921:39thhellerhttps://github.com/thheller/react-redux-realworld-example-app/tree/this-is-madness#2018-02-0921:42thhellerI'll probably write a blog post about this. I guess I can claim that shadow-cljs has pretty good JS support when it can do this. 😉#2018-02-0921:56justinleethat’s pretty amazing#2018-02-0921:57justinleei’m working through some unexpected things, but i really think most of my problems were related to a stale build#2018-02-0921:59thhellerthats unfortunate. I have not had any caching issues in years for CLJS#2018-02-0921:59thhellernpm/yarn however do scary stuff to the node_modules folder sometimes#2018-02-0921:59thhellerso I can't claim reliable caching for that yet#2018-02-0921:59thhellerneeds a lot more testing#2018-02-0922:02justinleeflipmove working, react-dnd working#2018-02-0922:02thhellerwohoo!#2018-02-0922:03justinleethe sheer non-determinism and crazy insanity that plagued me yesterday is gone#2018-02-0922:04justinleethe only weird thing that is happening is that when i’m off of the main entry point, reloading breaks now, presumably because i’m using html5 history#2018-02-0922:04thhellerI think you need to stick that into a defonce#2018-02-0922:05justinleeI’m using :http-handler shadow.http.push-state/handle#2018-02-0922:05thhellerthats only relevant when you reload the page manually#2018-02-0922:06justinleeright of course. when i’m not on the root path and i change the code, everything goes haywire and i have to reload#2018-02-0922:07justinleewhen I try to reload from the non-root path, something super werid happend#2018-02-0922:07thhellerhmm it shouldn't affect the reloading itself but I don't know what you do :after-load#2018-02-0922:07justinleeoh maybe that’s the problem#2018-02-0922:13justinleei would have though :after-load should just re-mount the root reagent component#2018-02-0922:15thhellerwell shadow-cljs doesn't do anything other than calling the specified function. so it is up to you.#2018-02-1009:10JonCan I connect to shadow-cljs's nREPL with my own code? Since my code is in ClojureScript, while nREPL was built in Java.#2018-02-1009:10JonI found socket REPL is much easier, guessing it's not in shadow-cljs...#2018-02-1009:49thhellerof course socket repl is in shadow-cljs#2018-02-1009:49Jonoh... just not found in docs#2018-02-1009:49thhellerin the target/shadow-cljs folder there is a socket-repl.port file#2018-02-1009:49thhellerthats the port of the socket repl#2018-02-1009:49thhelleralso the is a cli-repl.port file#2018-02-1009:50thhelleralso a socket REPL but it does NOT print a prompt#2018-02-1009:50thhellerotherwise its the same#2018-02-1009:50Jonsounds good#2018-02-1009:50thhellercli-port is used by the shadow-cljs script itself to communicate with the server#2018-02-1009:50JonI hate that prompt, hard to building tools#2018-02-1009:51Jonhow are the ports picked? randomly#2018-02-1009:51Jon?#2018-02-1009:51thhelleryes#2018-02-1009:51thheller:socket-repl {:port 123} can be configured#2018-02-1009:51thhellercli-repl is always random#2018-02-1009:51Joncool#2018-02-1009:51Jonwell..#2018-02-1009:52Jonguess I would like to try cli-repl...#2018-02-1009:52Jonanyone used it in building tools before?#2018-02-1009:54thhellerno idea#2018-02-1009:54thhellerbear in mind that the cli-repl is meant for internal use and not officially part of the public API#2018-02-1009:55thhellerI don't plan on removing it but its also not super well suited for tooling#2018-02-1009:55thhellerthe shadow-cljs script is simple since it just sends one thing#2018-02-1009:56thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/client.cljs#L56#2018-02-1009:57thhellerafter that it just reads#2018-02-1009:57thhellernrepl is used by pretty much all tools#2018-02-1009:57thhellermaybe prepl in the future? don't know what that is about yet#2018-02-1009:58Jonactually that's what I need to build a tool...#2018-02-1009:58Jonsocket REPL is nice, but I don't know how to deal with the prompts#2018-02-1010:22dominicmHi, you should check out #unrepl as something which has solved this#2018-02-1010:22dominicmIt adds structure to socket repl#2018-02-1009:58Jonmaybe trying regular expression... could be tedious.#2018-02-1009:58thhellersocket REPL isn't really meant for tools#2018-02-1009:59Jonso nREPL?#2018-02-1009:59thhellernrepl is what all other tools use yes#2018-02-1009:59thhelleryou can in theory use the cli-repl thing but that is literally just socket repl without prompt#2018-02-1009:59thhellerstilll has issues as soon as anything prints to stdout#2018-02-1010:00JonI was suggested node-nrepl-client last night, tried and it worked, but the message it returned is hard to understand#2018-02-1010:00thhellernrepl is weird yes#2018-02-1010:01Jonnrepl ╮( ̄▽ ̄")╭#2018-02-1010:02thhellerprepl is coming https://github.com/clojure/clojure/commit/86a158d0e0718f5c93f9f2bb71e26bc794e7d58e
#2018-02-1010:02thhellerthat solves some of the issues but nowhere near what nrepl provides#2018-02-1010:03thhellerwhat are you trying to build?#2018-02-1010:03JonI want to send a piece of Clojure code from my own process, and eval it in the runtime(browser, I mean), what's your suggestion?#2018-02-1010:04Jon"prepl" is so new, no Google results#2018-02-1010:04thhelleryeah .. no one knows what that is about yet. it was commited by Rich 2 days ago ...#2018-02-1010:04thhellerI can see what it does by reading the code ... I don't know WHY though#2018-02-1010:05thhellerso sending things to the browser is complicated#2018-02-1010:05Jonshadow-cljs is already doing that...#2018-02-1010:05Jonin cljs-repl.#2018-02-1010:06thhelleryes. but you need a running watch for that and a connected client#2018-02-1010:06JonI just noticed after using my own editor for so long, I don't even use some basic tool others are using in tools like EMACS.#2018-02-1010:06Jon...trying to script my own version#2018-02-1010:07Jonmy tool will base on that, page connected to shadow-cljs.#2018-02-1010:07thhellerwell if you don't care about the result at all you could just run shadow-cljs cljs-repl your-build and print all stdout somewhere#2018-02-1010:07thhellerbut parsing the output is painful#2018-02-1010:08thhellerbut you don't have to parse the output#2018-02-1010:08Jononly thing I can do at current is generate Clojure code, send it somewhere, maybe print the logs also.#2018-02-1010:08Jonoutput in browser, or in my process, I don't mind.#2018-02-1010:08thhellerwhat the shadow-cljs script does is connect to the cli-repl port#2018-02-1010:09thhellersend (shadow.cljs.devtools.cli/from-remote "some-uuid" "another-uuid" ["cljs-repl" "your-build"])#2018-02-1010:09thhellerafter that the output is just printed#2018-02-1010:10thhellerall input is sent to the socket as-is#2018-02-1010:10thhellerso the cljs-repl command will read and process it#2018-02-1010:11Jontried in my nodejs REPL, doesn't know how it works..#2018-02-1010:12Jonwhere should I get the uuids,#2018-02-1010:12Jonand where to put my code?#2018-02-1010:12thhellerlook at this file https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/client.cljs#2018-02-1010:13thhellerthere are no docs for this and there probably won't be#2018-02-1010:13Jonhaha..#2018-02-1010:13thhellerbut it is very simple code#2018-02-1010:13thhellerALL tools use nrepl. there is a reason for that.#2018-02-1010:15thhellerunrepl is newer but not many tools use it (yet). prepl will be something official but nobody knows when this will get adoption. socket-repl still isn't used by anything and thats has been there since 1.7.#2018-02-1010:16Jonstrange situation...#2018-02-1010:16thhellernot really, just use nrepl#2018-02-1010:17Jonwhat does this argument do? ["cljs-repl" "your-build"]#2018-02-1010:17thhellerjust follow the code#2018-02-1010:18thhellerthese are all internal details that are not part of the public API#2018-02-1010:18thhellerand never will be#2018-02-1010:18thhellerif you give me a clear definition of what you want to do I can take a look at implementing something to make that work#2018-02-1010:18Jon(>﹏<)#2018-02-1010:19Jonstill trying...#2018-02-1010:19thhellerbut all this is internal stuff I needed.#2018-02-1010:19thhellerjust saying that you could use it to make something semi reliable#2018-02-1010:19thhellerbut it has lots of issues and nrepl is far more reliable and tested#2018-02-1010:20JonI just saw people evaluating code from their editors last night.#2018-02-1010:20thhelleralso already has reliable middleware configuration and that stuff#2018-02-1010:20thhelleryes, everyone does that via nrepl#2018-02-1010:20thhellercursive doesn't even support connecting to remote socket REPLs (yet)#2018-02-1010:21Jonso people don't do that in Cursive?#2018-02-1010:21thhellerI do it pretty much always via nrepl#2018-02-1010:22Jonturned out nrepl is the thing I have to code anyway.#2018-02-1010:22thhellerI would recommend using that yes#2018-02-1010:22thhellersocket repl or even the cli-repl gets destroyed by any print you don't expect#2018-02-1010:23thhellerif you attempt to parse the output at all#2018-02-1010:23thhellerworks fine if you never try to parse the output though#2018-02-1010:23thhellerand you don't have to parse the output strictly speaking#2018-02-1010:24Jonno, I don't parse the output#2018-02-1010:24thhellerbut yeah REPL in my editor is a must have for Clojure. not so much for CLJS though.#2018-02-1010:25thhellerthen the prompt should not be an issue?#2018-02-1010:25JonI'm still thinking about if there any way to improve my workflow. I'm the only user, and no one would write plugins for me except myself.#2018-02-1010:26dominicmWhat editor do you use? 🤔#2018-02-1010:26Jontoo many threads ><#2018-02-1010:27Jonhttps://github.com/Cirru/calcit-editor#2018-02-1010:27dominicmah, your own#2018-02-1010:27dominicmI would totally recommend using unrepl then!#2018-02-1010:28dominicmUnrepl is a protocol for interacting with Clojure via socket repl#2018-02-1010:28Jonjust glanced video on unrepl hours ago,#2018-02-1010:28JonI didn't find enough docs.#2018-02-1010:28Jonplus, my toolchains is based on shadow-cljs,#2018-02-1010:28dominicmCome join #unrepl, @U3E46Q1DG would be glad to help 🙂#2018-02-1010:29JonI still have to connect it with shadow-cljs..#2018-02-1010:25dominicmA cursive user told me they were switching to https://github.com/pedestal/pedestal/blob/master/service-tools/src/io/pedestal/service_tools/dev.clj#L23 recently#2018-02-1010:26dominicm(Live-reload for clojure)#2018-02-1010:26Jonyeah prompt is not a issue for me.#2018-02-1010:26thheller@dominicm I toyed with that idea once but it is horrible in practice 😛#2018-02-1010:29thhellerbut cursive has a button for this so I guess the only difference is that I can trigger it when I want to#2018-02-1010:29dominicmThe cursive user told me they utilized the auto-save on un-focus feature, which surprised me 😂#2018-02-1010:32thhellerit is strange though. for clojure I definitely prefer manually requiring/reloading namespaces and doing things via the REPL#2018-02-1010:32thhellerin CLJS I just let live-reload do its thing and almost never use the REPL#2018-02-1010:33thhellerstrange how the workflows can be so different#2018-02-1010:36Jontook me long while to realize ["cljs-repl" "browser"] does nothing but connect me to the REPL in browser..#2018-02-1010:37Jondo people who eval code form EMACS or other editors call this API too?#2018-02-1010:40thhellerno one uses this API. no one even knows about this API.#2018-02-1010:40thhellereveryone uses nREPL.#2018-02-1010:41Jonbut... when they use nREPL, the code is evaluated in your Clojure process, not in the browser?#2018-02-1010:42thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage#2018-02-1010:43Jonso.... just used it to start watching...?#2018-02-1010:43thhellerI can't answer that. YOU need to decide what you want to do.#2018-02-1010:43thhelleryou can start the watch yes, you can also assume it is running already#2018-02-1010:43JonUmm...#2018-02-1010:44thhellerI don't know what your tool needs#2018-02-1010:44JonI want to click an expression in my editor, and it's evaluated in browser.#2018-02-1010:44Jonalso pressing keyboard shortcut probably#2018-02-1010:45Jonafter pressed, my editor will generate code and send to shadow-cljs#2018-02-1010:45Jonand let shadow-cljs send that piece of code into the connected browser tab, and eval.#2018-02-1010:45Jonjust like people did to eval selected code in a Clojure REPL with nREPL,#2018-02-1010:46Jondifference is my runtime is the browser, too far to send the code.#2018-02-1010:46JonI think I have got all the code needed to make it happen now..#2018-02-1011:12JonThanks for the help. Going out for some hours. I will try add it in my editor later, and gather feedbacks.#2018-02-1012:35schnipseljagdHi, I have the problem that *target* is set to default instead of nodejs (what I would expect) when the build is configured with :target :node-script. Can anyone give me a hind here where I am running into?#2018-02-1012:36thhellerhmm what is *target*?#2018-02-1012:38thhellerhehe cljs.core/*target* I presume. Didn't even know that existed#2018-02-1012:38schnipseljagdYes exactly, before this me neither 😉#2018-02-1012:39thhellerYou can set :compiler-options {:closure-defines {cljs.core/*target* "nodejs"}} in your build#2018-02-1012:39thhellerseems to be a self host thing though?#2018-02-1012:40thhellerah hmm no its used in some places#2018-02-1012:40thhellerI can set it to nodejs for :node-script and :node-library builds#2018-02-1012:40schnipseljagdGosh, thanks, I already tried various combinations to get this set via clojure-defines. Now it works.#2018-02-1012:41schnipseljagdI think that would be the correct solution.#2018-02-1012:44schnipseljagdI've opened an issue: https://github.com/thheller/shadow-cljs/issues/198#2018-02-1012:46thhellerhehe opened while I was writing the commit message. insta-closed 😉#2018-02-1012:49schnipseljagdThanks a lot! :+1:#2018-02-1018:38justinleeby the way @thheller, just to follow up on my sorrows of the past few days: not only was I battling the weird stale state issue, but it turns out that due to a known bug in an old version of nodemon (!!!), my server was restarting without me noticing every time I saved my client code in atom (actually it would restart even when i switched tabs). so the hot code reloading was appearing to break in the most nondeterministic and impossible to debug ways imaginable. talk about bad luck.#2018-02-1018:52thhellerdoh!#2018-02-1119:05donmullenTrying to get fulcro routing video demo up which uses shadow - and I’m using emacs/cider. When I add :dependencies [[cider/cider-nrepl "0.16.0"]] to my shadow-cljs.edn file I get
SERVER INSTANCE OUT OF DATE!
Please restart.
#2018-02-1119:06donmullenWithout that I can do cider-connect to a the repl - but get a message from cider indicating the cider-nrepl version is nil and doesn’t match cider version.#2018-02-1119:10donmullenFrom the connected repl - I can run (shadow/nrepl-select :cards) - but attempt tos C-c C-e from cljs file - get There is no connected JS runtime.#2018-02-1119:10donmullenPerhaps a question for #cider ?#2018-02-1119:14donmullenNVM : had another terminal running shadow-cljs - doh! — stopping that that and running again - everything seems to be working.#2018-02-1122:35thheller@donmullen in the future you can run shadow-cljs stop to stop the "out of date" (ie. dependencies were changed) server#2018-02-1202:17Jonfinished a prototype last night of sending code from my editor to developing webpage, https://www.youtube.com/watch?v=lOdUfa7TfW0#2018-02-1209:33thheller@jiyinyiyong two things: can you please post you target/shadow-cljs/logging.properties? the warning you see on startup is NOT normal. Also please dont use the from-remote call, it is not part of any public API and may change at any time. Just call (shadow.cljs.devtools.api/repl :build-id) instead.#2018-02-1215:31Jonhttps://gist.github.com/chenyong/acea24f322e51ea3d02ee477d92d84ae#2018-02-1215:32Jonthe file path it still old, coworkflow has been renamed to calcit-workflow for some weeks.#2018-02-1215:32Jonfixing by hand..(actually removed...)#2018-02-1215:33Jonno error now~#2018-02-1215:38thhellerah ok. I moved it to a relative path a while ago so that shouldn't happen again#2018-02-1215:47Jonyeah, I saw that 🙂#2018-02-1209:35thhelleralso your startup time seems excessively slow? you are probably out of memory and swapping right? maybe setting :jvm-opts ["-Xmx521M"] helps a little?#2018-02-1210:17JonCPU in Mac 12 inch is slow. It is obviously faster when I run shadow-cljs in Macbook Pro.#2018-02-1210:18thhellerit still seems very slow. just thinking that it might be using too much memory and start swapping#2018-02-1210:18thhellervery likely to happen if you only have 4GB or so#2018-02-1210:18Jonis (shadow.cljs.devtools.api/repl :build-id) doing the same thing like from-remote?#2018-02-1210:19thhellerno, but that is the point. from-remote does stuff you don't need.#2018-02-1210:19Jon> 1.2GHz dual-core 7th-generation Intel Core m3 processor Turbo Boost up to 3.0GHz 8GB 1866MHz LPDDR3 memory 256GB SSD storage1#2018-02-1210:19thhellerhmm guess that is a realyl slow CPU then 😛#2018-02-1210:20Jonnot with that device currently... looks it's 8G,#2018-02-1210:20Jonreally really slow CPU... I bought it because of the light weight.#2018-02-1210:21Jonwill do after I get home.#2018-02-1211:02pepeHi, may I ask how to get some other than js files from npm package in the build? In this case css from material-components-web package. I searched the User Guide and web generally, but haven't found anything.#2018-02-1211:03pepeI can just copy it to public folder, but maybe there is some better way?#2018-02-1211:05thhellercurrently shadow-cljs doesn't provide anything to build css#2018-02-1211:06pepewell I thought something like boot sifting#2018-02-1211:06thhellerso you either need to copy manually or use a tool to do it for you#2018-02-1211:06pepeOk, thank you#2018-02-1211:06thhellerI eventually want to build something for css but nothing available yet#2018-02-1211:21pepeCause today I spent such a horrible morning with cljsjs and externs problem in production build, I have to move to shadows ASAP 😉#2018-02-1215:53Jonjust moved my build script into a .clj file, from package.json https://github.com/mvc-works/calcit-workflow/blob/master/cli/build/main.clj#2018-02-1215:54Jonbut I still too call yarn build as an alias for shadow-cljs run-cljs build.main/build.. the later is quite long.#2018-02-1215:54Jonpossible to call that piece of code in a shorter form?#2018-02-1215:55thhellershorter form no#2018-02-1215:55Jon😄#2018-02-1215:56Jonthought about adding #!shadow-cljs for a while.#2018-02-1215:57Jonif there's some improvements on clj tool, I would try to switch.#2018-02-1215:57thhellerwhy would you switch?#2018-02-1215:58Joncalling clj cli/build.clj is shorter.#2018-02-1215:59Jonand when I want to run some bash scripts from clj, I don't have to initialize shadow-cljs before running it.(although calling Bash scripts from Clojure is kind of slow.)#2018-02-1216:08thhellerI personally dislike the running of scripts but I can add an option for that if you like#2018-02-1216:08thhellerif you put things in proper namespaces you can run everything from the REPL#2018-02-1216:09thhellerscripts are kinda annoying to use imho#2018-02-1216:11JonI used npm scripts for long time, typing yarn build yarn html is really smooth.#2018-02-1216:11thhellerI meant cli/build.clj as "script"#2018-02-1216:11Jontried clj again... not feeling very good still.#2018-02-1216:12Jonit's slow. only benefit is clj -m build.release is short to type in.#2018-02-1216:12thhellereasy fix alias x="shadow-cljs run-clj"#2018-02-1216:13thhellerx build.release#2018-02-1216:13Jonyep...#2018-02-1216:14Jonwhat did you mean by REPL?#2018-02-1216:16Jon
=>> yarn shadow-cljs clj-repl
yarn run v1.3.2
$ /Users/chen/repo/mvc-works/calcit-workflow/node_modules/.bin/shadow-cljs clj-repl
shadow-cljs - config: /Users/chen/repo/mvc-works/calcit-workflow/shadow-cljs.edn version: 2.1.6
shadow-cljs - starting ...
shadow-cljs - HTTP server for ":browser" available at 
shadow-cljs - server running at 
shadow-cljs - socket repl running at localhost:5900
shadow-cljs - REPL - see (help), :repl/quit to exit
[1:0]~shadow.user=> (require '[build.main :as b])
nil
[1:0]~shadow.user=> (b/build)
{:exit 0, :out , :err }
[:browser] Compiling ...
#2018-02-1216:16JonI actually feel better using a REPL.#2018-02-1217:25schnipseljagd
shadow-cljs node-repl
shadow-cljs - config: /home/joscha/src/realtime-playground/backend/shadow-cljs.edn version: 2.1.6
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm node-repl
Feb 12, 2018 6:17:05 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Feb 12, 2018 6:17:05 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server running at 
shadow-cljs - starting node-repl
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 1 compiled, 0 warnings, 1.96s)
[0:0]~cljs.user=> fs.js:642
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/home/joscha/src/realtime-playground/backend/shadow-cljs/builds/node-repl/dev/out/cljs-runtime/goog.debug.error.js'
    at Error (native)
    at Object.fs.openSync (fs.js:642:18)
    at Object.fs.readFileSync (fs.js:510:33)
    at global.SHADOW_IMPORT ([stdin]:44:15)
    at [stdin]:3003:1
    at [stdin]:3042:3
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at Object.<anonymous> ([stdin]-wrapper:6:22)
    at Module._compile (module.js:570:32)
When trying to run the node-repl in my setup I get this error. My build config is the following:
{:aws-lambda {:id               :aws-lambda
                       :target           :node-script
                       :output-to        "target/backend/backend.js"
                       :main             backend.core/main
                       :optimizations    :none
                       :language-in      :ecmascript5}}
What I noticed is that the backend/shadow-cljs/builds/node-repl/dev/out/cljs-runtime/goog.debug.error.js seems to be missing the target dir. Any hints for me?
#2018-02-1217:27Jonstrange... https://github.com/thheller/shadow-cljs/issues/193#2018-02-1217:41thheller@schnipseljagd oops. there is a bug in the resolve code#2018-02-1217:42thhellerlooking into it#2018-02-1217:48thhellerthe node process for the repl is started by basically doing cat target/shadow-node-repl.js | node and that filename gets lost in the process#2018-02-1217:48thhellerso node will resolve relative to the process root which is incorrect#2018-02-1217:49thhellerthat broke when I moved to relative paths in 2.1#2018-02-1217:49thhellermeh#2018-02-1217:50thhellercan't remember why I don't just call node target/shadow-node-repl.js#2018-02-1218:25thhellerjust released 2.1.7. I also upgraded the Closure Compiler version which may break stuff. Please let me know if you run into any issues. I did some testing and all appears to be working correctly but its really hard writing automated tests for this stuff so I may have missed some stuff.#2018-02-1218:39thheller@schnipseljagd 2.1.7 also fixes the node-repl#2018-02-1218:41schnipseljagdThx a lot. I am going to verify it.#2018-02-1219:17schnipseljagdLooks good to me 🙂#2018-02-1304:38justinleei’m trying to use PDFJS, which uses a web worker. the web worker is already distributed in the pdfjs-dist npm module under build/pdf.worker.js. what’s the right way to tell shadow-cljs about that file and that it need to be served during development and copied & minified during production?#2018-02-1304:38justinleeI see the 6.4 Web Workers in the manual, but that is for cljs code, i think#2018-02-1309:01thheller@lee.justin.m when I npm install pdfjs there is no such file?#2018-02-1309:09mjmeintjesHi. I seem to remember that there was a way to see how much size each library is adding to the total size of the release build using shadow-cljs. Is that a thing, or am I mis-remembering?#2018-02-1309:10thheller@mjmeintjes very crude version exists yes. see https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9?u=thheller#2018-02-1309:11mjmeintjesGreat, thanks. Exactly the post I was searching for.#2018-02-1309:12thhellerHaven't tested this in a while. might totally not work anymore 😛#2018-02-1309:14mjmeintjesNo worries, just glad I'm not going mad as I was sure I had seen it somewhere but couldn't find it anywhere.#2018-02-1309:15thhelleryeah not added to the docs yet#2018-02-1309:16thhellerkinda want to have an actual visualization first 🙂#2018-02-1309:31thheller@lee.justin.m ah I looked at the wrong package. from what I can tell you don't need to use their bundle but instead you create a (ns your.app.worker (:require ["pdfjs-dist/lib/core/worker"])) and then let shadow-cljs build it for you#2018-02-1309:32thhellerbut you can just (:require ["pdfjs-dist/build/pdf.worker"]) as well#2018-02-1317:46justinlee@thheller so I thought with web workers you typically have to specify a uri in the worker constructor, which then goes and fetches the source at that uri and then runs it. in javascript all I do is
const PDFJS = window.PDFJS;
PDFJS.workerSrc = '/pdf.worker.js';
and then I make sure that the pdf.worker.js bundle is available to be served. so if I just straight require it, won’t that just include the worker source rather than allowing it to be run in a new worker? or is there more shadow-cljs magic here?
#2018-02-1317:47justinleefor what it is worth: i think it would be really cool to have shadow-cljs build it for me since the optimizations might be better. i was just trying to do it the easy way first#2018-02-1317:48thhellerso the "trick" with web workers in shadow-cljs is that is uses the code splitting#2018-02-1317:49thhellermeaning that code used only by the worker will also only be loaded when the worker is started#2018-02-1317:49thhellerthe file that :web-worker true generates is a standalone worker file, ie. you call it with the webworker constructor#2018-02-1317:50thhellerI expanded the webworker section with an example#2018-02-1317:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2018-02-1317:50theaspHmm, new error from the closure compiler in 2.1.7:
Closure compilation failed with 1 errors
--- node_modules/dialog-polyfill/dialog-polyfill.js:692
this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
#2018-02-1317:51thhellerthe "problem" with the pre-built pdfjs.worker.js is that it basically doubles the code your user has to download#2018-02-1317:51thhellerfirst the normal pdfjs and then the worker file#2018-02-1317:51thhellercode splitting would be better but I don't know exactly what pdfkit expects from the worker#2018-02-1317:52thheller@theasp that worked before?#2018-02-1317:52theaspYeah, on Friday 🙂#2018-02-1317:52theaspand before...#2018-02-1317:53theasphttps://github.com/GoogleChrome/dialog-polyfill#2018-02-1317:54thhellerwhich version?#2018-02-1317:55thhellerah nvm got it#2018-02-1317:56thhellerweird thing is I set ECMASCRIPT_NEXT language mode#2018-02-1317:56thhellerwhich is way past ES6 so no idea why it wants es6#2018-02-1317:56theaspI was using 2.1.4 on Friday#2018-02-1317:57theaspYeah, I was reading that#2018-02-1317:57theaspEither way, I blame Google#2018-02-1317:57thhelleryeah I upgrade to the newest closure compiler verison in 2.1.7#2018-02-1317:57thhellerit had some improvements I wanted but I guess also some new bugs#2018-02-1317:58theaspSaid anyone who upgraded anything ever#2018-02-1317:58thhellerI'll see if I can figure something out#2018-02-1318:00justinleei read through the modules section again. if i understand correctly: i should create an empty cljs file for the worker that includes the entry point for the worker code. then declare that file as a web worker module and shadow will be able to serve it and pdfjs will be able to use it#2018-02-1318:02thhellerI don't know about pdfjs but yes thats the idea#2018-02-1318:06thhellergotta love those helpfull errors from closure#2018-02-1318:06thheller
--- null:-1
Missing externs definition for Symbol. Did you forget to include the ES6 externs?
#2018-02-1318:07theaspECMASCRIPT_NEXT for output, or input?#2018-02-1318:07thhellerforgot that I acutally set it to ES5 for node_modules files#2018-02-1318:07thhellerinput#2018-02-1318:07theaspAhh#2018-02-1318:08thhellerbut if I set it higher I get the error above#2018-02-1318:08thhellerbabel in theory is used for everything es6+ in node_modules for reasons such as this#2018-02-1318:08thhellerbut the file is not detected as es6 and AFAICT it isn't either#2018-02-1318:08thhellerdon't really understand what its complaining about#2018-02-1318:13thhellerhttps://github.com/google/closure-compiler/commit/41331b3d98612101fe09bd01bdd5b305526281e5#2018-02-1318:13theaspI don't understand why we still need a dialog polyfill in 2018#2018-02-1318:14thhellerto be honest I had no idea that a dialog api even existed#2018-02-1318:17thhellerwell .. I'm just going to bump the language in#2018-02-1318:18theaspI don't think it does anything you couldn't do manually#2018-02-1318:19thhelleryeah I've always done dialogs manually. takes 5 lines of code or so. no idea why you'd need a standard api for that#2018-02-1318:22theaspIt's supposed to handle focus and modalness in an accessible way#2018-02-1318:22thhelleryeah I guess its a common enough thing to make it standard#2018-02-1318:34thheller@theasp pushed 2.1.8 which seems to fix it#2018-02-1318:34theasp\o/#2018-02-1318:40justinleedo you use joker as a linter? it is cranky because of the extension to the ns and I don’t think it is extensible in thatway#2018-02-1318:42thhellereverything except :default is standard clojurescript so it should support that#2018-02-1318:42thhellerbut no I don't use it#2018-02-1318:42justinleei think it doesn’t like the strings#2018-02-1318:42justinleeno big deal#2018-02-1318:56theasp@thheller My mystery console.clear() call is no longer happening.#2018-02-1318:58thhellerI actually added a (js/console.clear) to my :before-load hook. I kinda like it.#2018-02-1318:58theasphaha#2018-02-1318:58thhellerbut not really sure if I should add it as an option. seems fine when done in :before-load#2018-02-1318:58theaspYeah, probably shouldn't#2018-02-1321:53koz@thheller just wanted to let you know that after upgrading from 2.1.6 -> 2.1.8 (2.1.7 didn’t compile) I am running into some issues where NPM deps are no longer coming in correctly (some libraries that I’m requiring are now resolving to undefined)#2018-02-1400:47currentoorhello, i’m noticing some weird behavior with cider. everything (eval, jump-to, docstring lookup) seems to be working except for symbols that get :referd in#2018-02-1400:47currentooranyone familiar with that?#2018-02-1405:01mjmeintjes@thheller Thanks, just thought I'd mention that the release snapshot analyzer displaying the size usage per dependency is really useful.#2018-02-1407:04thheller@koz can you give me examples of deps that dont work anymore?#2018-02-1407:40thhellerpushed 2.1.9 fixing one issue I found#2018-02-1407:50thhellergah found another issue#2018-02-1407:50thhellerI hate this change#2018-02-1407:54pepe@thheller for me it is material-component-web. Same with 2.1.9#2018-02-1407:55thhelleryeah thats what I'm testing with#2018-02-1407:55thheller(now, not before)#2018-02-1407:55pepeOr better "@material/ripple" to be precise#2018-02-1407:55pepeThe thing is js/module$node_modules$$material$ripple$index resolves to the right object#2018-02-1407:57thhellerthe problem is that the closure compiler folks decided to change how the interop between commonjs and es6 works#2018-02-1407:57thhellerso the CLJS compiler had to be adjusted as well#2018-02-1407:58thhellerproblem now is that babel converted ES6 -> CJS files#2018-02-1407:58thhellerare treated as CJS although they should be handled as ES6#2018-02-1408:02pepeThat's a pity. Nothing critical for me thou. I wish you best luck in solving it :+1::skin-tone-4:#2018-02-1409:22thheller2.1.10 should cover the most common cases#2018-02-1409:46Jon
shadow-cljs - updating dependencies
shadow-cljs - dependency update failed - Could not find artifact thheller:shadow-cljs:jar:2.1.10 in central ()
error Command failed with exit code 1.
#2018-02-1409:46thhelleroops. fixed.#2018-02-1409:50Jonworking now~#2018-02-1410:25thhellerstill trying to figure out if this is compatible with what webpack will be doing#2018-02-1410:26thhellerhttps://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655#2018-02-1410:29pepeFor me requiring ["@material/ripple" :as ripple] still yields undefined#2018-02-1410:35pepeI pushed not working state to https://github.com/pepe/two-in-shadows#2018-02-1410:41thhellerAFAICT it works?#2018-02-1410:42thhellerripple.MDCRipple.attachTo this is incorrect though#2018-02-1410:42thhellershould be ripple/MDCRipple.attachTo#2018-02-1410:43pepetrue, sorry#2018-02-1410:45pepeit works indeed, I defined ripple as js/module$node_modules$$material$ripple$index as workaround and forget to fix it. Thank you very much!#2018-02-1414:35koz@thheller I found that requiring threejs didn’t work correctly anymore#2018-02-1414:38kozI’m bringing it in as ["three" :as THREE]#2018-02-1414:40kozlet me try 2.1.10 and see if that works#2018-02-1415:31pithylessIf I’ve got a resources/public/js/test/index.html and I want it to be visible for the :browser-test target, is there a way I can tell it to look for index.html in another :resource-paths? Right now it only looks at :http-root. If not, is there a way I can move files, like sift in boot?#2018-02-1415:32pithylessThe main idea being I’ve got a shadow-target/ output dir, but I’d prefer not to keep any of those file in the git repo, just have it as a temporary target that can be wiped. Is that possible?#2018-02-1415:40denik@thheller trying to use vega-lite:
(:require ["vega-lite" :refer (compile)])
compile is undefined even though this is synonymous to https://github.com/nesterone/vue-vega/blob/9d7f1b3341471e33b402dc1383266d8570f16cfd/test/unit/specs/components/delegate/vegaLiteDelegate.spec.js when I type veg into the browser console, this variable autocompletes module$node_modules$vega_lite$build$src$index and module$node_modules$vega_lite$build$src$index.compile exists. Any ideas what might be going on here?
#2018-02-1415:50thheller@pithyless do you want to replace the default generated index.html or do you want to access that file independently?#2018-02-1415:50pithyless@thheller I want to replace it#2018-02-1415:51pithylesswhere :http-root is shadow-target/... and my file is resources/.../index.html#2018-02-1415:51thhellershadow-cljs will only generate an index.html if none exists#2018-02-1415:51thhellerso you can just copy yours to the :test-dir?#2018-02-1415:52thhelleror set :test-dir to resources/public/js/test#2018-02-1415:53pithylessI was trying to replicate my boot setup where resources/* where in git and all the compiled output stuff was in shadow-target/*#2018-02-1415:54pithylessas it stands, :test-dir will be a combination of stuff I’ve got in git and stuff generated by shadow#2018-02-1415:55thhellerI just gitignore the generated files and avoid the copying#2018-02-1415:55thhellerbut I'm currently planning the plugin API which would let you do things like that
#2018-02-1415:55pithylessI’ll .gitignore for now; but this kind of API improvement would be nice 🙂#2018-02-1415:57thheller@denik I don't unterstand the question? compile does exist yes?#2018-02-1416:56denikno everything is undefined#2018-02-1416:56denikcompile exists only through the long variable I found in the browser console#2018-02-1416:57denikthe requires do not work#2018-02-1416:58thhellerif you are on 2.1.7+ there is currently a problem. I tested with 2.1.10 which seems to work#2018-02-1416:59thhellerotherwise revert back to 2.1.6 until I fixed this mess.#2018-02-1417:24denik2.1.10 works#2018-02-1415:59thheller@koz confirmed that three doesn't work properly. I'll try to figure out why.#2018-02-1416:00thhellerah nvm .. works in 2.1.10#2018-02-1416:00koz@thheller just stopped by to tell you that (regarding 2.1.10)#2018-02-1416:00kozhowever it seems like https://github.com/Khan/aphrodite doesn’t work in 2.1.10#2018-02-1416:00koz(after working in 2.1.6)#2018-02-1416:02kozwhen you require ["aphrodite" :refer (StyleSheet)], StyleSheet is undefined#2018-02-1416:03thhellerindeed. checking.#2018-02-1416:03kozthank you#2018-02-1416:09thhelleraphrodite definitely has the strangest exports handling I have seen to date#2018-02-1416:09kozoh wow - I haven’t really looked into the source#2018-02-1416:12kozyeah this library isn’t like a big dependency for us, just wanted to let you know of a dependency that was working before that isn’t now (in case it affects others)#2018-02-1416:13kozthese are indeed weird exports#2018-02-1416:13thhellerproblem is that they I look for this pattern to decide if the file was ES6 converted by babel#2018-02-1416:14thheller
Object.defineProperty(exports, '__esModule', {
    value: true
});
#2018-02-1416:14thhellerthey set it but then not actually use the exports object#2018-02-1416:14thhellerI might have to revert back to the way it was before#2018-02-1416:18kozI wonder if this is due to them using an old version of Babel (seems to be Babel 5): https://github.com/Khan/aphrodite/pull/281. Babel 6 might have changed this: https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/#2018-02-1416:20thhellermight be but the detection was already questionable and I had to detect 3 different patterns already for the deps I had installed for testing#2018-02-1416:20thhellerso I doubt that aphrodite will be the only package with strange exports#2018-02-1416:20thhellerrather go back to the old way and try to be less smart about it I guess#2018-02-1416:47justinleewhy is it that shadow has to do all of this detection? like, how does babel+webpack manage to use es6 import syntax at all times with every npm module. maybe i’m not thinking clearly but if they are doing some kind of detection, can we go peek at their code and see what they are doing?#2018-02-1416:48thhelleractually the problem comes from the Closure Compiler and it wants to do the ES6/CJS interop#2018-02-1416:49thhellerhttps://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655#2018-02-1416:49thhellercovering all the scenarios they describe is hard if the closure compiler has different ideas#2018-02-1416:50thhellerfor CLJS there isn't actually a problem if I revert it back to the way it was (without detection)#2018-02-1416:51thhellerits only tricky because I want this to work#2018-02-1416:51thhellerhttps://github.com/thheller/shadow-cljs-examples/blob/master/local-js/src/demo/foo.js#2018-02-1416:51thhellerie JS<-CLJS->JS interop#2018-02-1416:52justinleethe answer to most of my “why is this so effing weird” questions in cljs is aways “because closure compiler” 🙂#2018-02-1416:53thheller"because JS" actually 😉#2018-02-1416:54thhellerclosure compiler is actually how I'd expect things to work .. then there is stuff like aphrodite which doesn't even make sense when you look at it 😛#2018-02-1416:55thhellerthere are too many ways of doing things in the JS world and they seem to be adding things every few months#2018-02-1416:56justinleei mean i know js is bizarre. but i still maintain that if cljs did its own symbol minification we could ditch closure compiler and have seamless integration with the js ecosystem.#2018-02-1416:57thhellerwell I wouldn't want to give up the :advanced stuff Closure does and from what I can tell the JS world is working towards getting something comparable#2018-02-1416:57thhellerbut that just won't work with some of the stuff they do#2018-02-1416:57justinleewell anyway you are mostly there anyway#2018-02-1416:58thhellerI actually think they will converge on a set of standards at some point that will pretty much match what GCC does today#2018-02-1416:59justinleehonestly if i can just get protorepl in atom working with shadow and maybe figure out a patch to get my linter working everything will be near perfect#2018-02-1417:15justinleequestion: the (:require ["npm-module-name" :as something]) is a really nice feature, but I wonder does it make sense to provide an option (maybe in :js-options?) to use a synthetic namespace. i ask because right now the string messes up my linter and deviates from cljs. it’s nice to be able to require the right module name right from the source without a compiler option but in the final estimation not critical. just a thought.#2018-02-1417:21thhellerdon't tell anyone but (:require [npm-module-name :as something]) actually works as well#2018-02-1417:21thhellerI just think a string is more reliable and makes it clear that you are importing JS and not CLJS#2018-02-1417:21justinleehaha okay#2018-02-1417:22thhellerbut CLJS allows the symbol so I have to do it as well#2018-02-1417:23justinleeoh yea that fixes my linter 🙂#2018-02-1417:28justinleeit doesn’t fix protorepl sadly#2018-02-1417:29justinleeit dumps
java.io.FileNotFoundException: Could not locate seekeasy/handler__init.class or seekeasy/handler.clj on classpath., compiling:(seekeasy/repl.clj:1:1)
which i assume must be part of the repl protocol as i don’t have a handler.clj or a repl.clj
#2018-02-1417:32thheller"clojure seekeasy" doesnt return anything useful on google or clojars#2018-02-1417:32justinleeoh sorry seekeasy is my namespace#2018-02-1417:32thhellerah ok#2018-02-1417:32thhellerI can take a look at proto repl in a bit#2018-02-1417:33thhellerlooked at it a while ago but forgot everything#2018-02-1417:33justinleei’ve been looking for something that documents the repl/nrepl convention/protocol but haven’t found anything#2018-02-1417:34justinleeit’s been one of the most confusing things being a new cljs programmer#2018-02-1418:07thhellerthe convention is to use middleware for tooling stuff but IIRC proto-repl just evals stuff#2018-02-1418:19justinleelooking at the code, it seems to implement an nrepl connection. isn’t that all you need?#2018-02-1418:19thhellerit depends on how they do the CLJS interop#2018-02-1418:20thhellernrepl connect should work without issue but not sure what they do regarding cljs#2018-02-1418:22thhellerits so weird .. I did so much coffeescript a couple years ago but I can't figure out whats going on anymore 😛#2018-02-1418:22thhellerit just looks so weird now#2018-02-1500:58justinlee@thheller one weird thing about using symbols instead of strings: it doesn’t work for default imports. if you do something like [react-flip-move :default FlipMove] then when you actually use FlipMove it will (weirdly) throw an error saying react_flip_move is not defined#2018-02-1500:59justinleei only have 2 libraries with default imports but its the same for both#2018-02-1500:59justinleealso: with protorepl, it works great, unless the evald code throws an error. then the buffer gets stuck forever and atom has to be restarted. there must be a different error channel#2018-02-1600:15tony.kaySeeing the HUD crash with this:
failed to parse websocket message {:type :build-failure, :build-config {:target :browser-test, :test-dir "resources/public/js/test", :ns-regexp "-test$", :runner-ns gondola.client.client-test-main, :devtools {:http-port 8022, :http-resource-root "public", :http-root "resources/public/js/test"}, :id :test, :build-id :test}, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs:13:1\n--------------------------------------------------------------------------------\n  10 |   ([id] [::address-result id])\n  11 |   ([id field] [::address-result id field]))\n  12 | \n  13 | (defsc AddressResult [this {:keys [id]}]\n-------^------------------------------------------------------------------------\nSyntax Error at gondola.client.smartystreets:13\n{:cause clojure.lang.ExceptionInfo: Invalid arity for query {:expected 0, :got 1}}\nExceptionInfo: Syntax Error at gondola.client.smartystreets:13\n\tclojure.core/ex-info (core.clj:4739)\n\tclojure.core/ex-info (core.clj:4739)\n\tfulcro.client.primitives/defsc (primitives.cljc:3203)\n\tfulcro.client.primitives/defsc (primitives.cljc:3142)\n\tclojure.core/apply (core.clj:661)\n\tclojure.core/apply (core.clj:652)\n\tcljs.analyzer/macroexpand-1*/fn--3565 (analyzer.cljc:3286)\n\tcljs.analyzer/macroexpand-1* (analyzer.cljc:3285)\n\n--------------------------------------------------------------------------------\n  14 |   {:ident (fn [] (address-result-path id))\n  15 |    :query '[*]})\n  16 | \n  17 | (defmutation get-street-address [{:keys [id] :as params}]\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "gondola/client/smartystreets.cljs"] {:tag :shadow.build.compiler/compile-cljs, :source-id [:shadow.build.classpath/resource "gondola/client/smartystreets.cljs"], :url #object[java.net.URL 0x71843d1d "file:/Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs"], :file #object[java.io.File 0x1367c8aa "/Users/tonykay/owsy/gondola-client/src/cljs/gondola/client/smartystreets.cljs"], :line 13, :column 1, :source-excerpt {:start-idx 9, :before ["  ([id] [::address-result id])" "  ([id field] [::address-result id field]))" ""], :line "(defsc AddressResult [this {:keys [id]}]", :after ["  {:ident (fn [] (address-result-path id))" "   :query '[*]})" "" "(defmutation get-street-address [{:keys [id] :as params}]"]}}} 
#2018-02-1600:15tony.kaythis is an exception thrown from a macro#2018-02-1604:16tony.kayThe REPL experience is also less than ideal (using 2.1.11). I get things like Error handling response - class java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.CharSequence for expressions like (+ 1 1)#2018-02-1608:12claudiunoob question 😞 Is it technically really hard to have figwheel with shadow-cljs ? In the latest defn-podcast think Bruce mentioned that he's planning on working on the internals of figwheel to make it more flexible.#2018-02-1608:39tony.kay@claudiu The hot code reloading is done by shadow-cljs, as is the compiling. Figwheel is both of those, but with the stock compiler. So, the short answer is “no, you don’t use figwheel with shadow-cljs”#2018-02-1609:09thheller@claudiu the question would be "why would you want to use figwheel with shadow-cljs?". what does figwheel provide that you do not get yet?#2018-02-1610:55claudiu@thheller They seem to be two things that do the same thing. I get why it does not work out of the box, was just curious, it could theoretically work, with some updates to figwheel that made it more modular . 🙂#2018-02-1610:58thhellershadow-cljs is much more low level than figwheel so it really wouldn't be practical to use figwheel for anything#2018-02-1610:58thhellerbut again .. why would you?#2018-02-1610:58thhellerif figwheel does something shadow doesn't I can take a look at adding it#2018-02-1610:59thhellerit may look like they do the same thing but they really don't#2018-02-1610:59thhellerfigwheel is for development only and doesn't do anything for release builds#2018-02-1610:59thhellershadow-cljs started with release builds and later added the dev stuff#2018-02-1611:01claudiuAhh oky got it 🙂#2018-02-1611:01thhellerI have never used figwheel so I might totally be missing something obvious ... so if you have something that shadow is missing over figwheel .. tell me.#2018-02-1611:06claudiuSo far so good. More of a noob question 🙂 since figwheel does hot reloading and is the 'default' in the clojurescript community, was just wondering if there technical aspects to why not work on integrating vs making the hot-reload from scratch 🙂 . Was listening to the defn podcast, Bruce said something about figwheel updates (can't remember exactly what), I immediately thought about shadow-cljs 🙂#2018-02-1611:09thhellerhe also said#2018-02-1611:09thheller> As a UI to ClojureScript the codebase is complex and complected.#2018-02-1611:09thhellershadow-cljs is a lot more complex due to being much more low level#2018-02-1611:10thhellerintegrating figwheel would probably be more work than just building it from scratch#2018-02-1611:10thhellerhot reload is a tiny fraction of the code#2018-02-1611:10thhellerthe config validation stuff is nice but not usable as a lib#2018-02-1611:11thhelleralso shadow-cljs config is probably too different to use it#2018-02-1611:12thhellerfigwheel has had much more work done on the usability front and yes I'd love to use some of that#2018-02-1611:12thhellerbut I really can't#2018-02-1611:13claudiumakes sense. Thank you for explaining the details 🙂#2018-02-1611:21thhellerthe rebel-readline stuff he is doing I can probably integrate at some point#2018-02-1612:00claudiuthat would be pretty awesome 🙂#2018-02-1613:31wilkerlucio@thheller following Tony comments, the only thing that I miss from Figwheel at this point is the REPL, it works really well there, but in shadow I've had problems with timeouts and sometimes not loading files at all#2018-02-1613:32thhellerplease report those things don't just ignore it#2018-02-1613:32thhellerfirst time I hear of that 🙂#2018-02-1613:32wilkerlucioother thing that I miss, but I think it's not directly a shadow concern, is been able to start my REPL directly from Cursive, with Figwheel I can create a run with clojure.main pointing to a tiny script that starts figwheel, this boots up the compilation and with a REPL ready to use, with shadow I have to do it in 2 steps (open the process in a terminal and connect via nREPL on Cursive)#2018-02-1613:35thhellercan you paste that figwheel startup file?#2018-02-1613:35wilkerlucioother than that, only love 🙂 and a special congrats on allowing external source paths, this is so good to work while developing multiple libs (I have a project where I'm having to use devbuilds for pathom, inspect and fulcro, without shadow it would be very painful)#2018-02-1613:36wilkerluciosure, one moment#2018-02-1613:36wilkerluciofigwheel.clj
(use 'figwheel-sidecar.repl-api)
(start-figwheel! "devcards" "test")
(cljs-repl)
#2018-02-1613:39thheller
(require '[shadow.cljs.devtools.server :as server])
(require '[shadow.cljs.devtools.api :as shadow])
(require '[shadow.cljs.devtools.cli])

(server/start!)
(shadow/watch :devcards)
(shadow/watch :test)
#2018-02-1613:39thhellerput that into the figwheel.clj instead. change nothing else. done.#2018-02-1613:39thhellerI guess I don't really know what (cljs-repl) does#2018-02-1613:40thhellersince you are starting two builds which repl do you get?#2018-02-1613:40thheller(shadow/repl :devcards) would drop you into the REPL for devcards#2018-02-1613:40wilkerluciofigwheel seems to choose it kind by random (probably a (first) on a map), but you can type :cljs/quit, it takes you to a place where you can select which REPL to connect#2018-02-1613:44thhellerwhat I personally do is just launch a lein repl#2018-02-1613:44wilkerluciojust tried running the script, got this:#2018-02-1613:44thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/repl.clj#2018-02-1613:44wilkerlucio
objc[32799]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin/java (0x10ce484c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10ced44e0). One of the two will be used. Which one is undefined.
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: es5>= in this context, compiling:(shadow/build/cljs_hacks.cljc:439:22)
#2018-02-1613:45thheller(require 'repl) (repl/go)#2018-02-1613:45thhelleruhm which clojurescript version are you using?#2018-02-1613:46wilkerluciooh, sorry, so the project.clj version matters on this case, because of cursive classpath, correct?#2018-02-1613:46thhelleryes#2018-02-1613:46wilkerluciothe lein file on this project was just a dump one for cursive, the real deps were in shadow, let me update and try again#2018-02-1613:46thhellerproblem here really is that cursive only supports lein#2018-02-1613:47thhellerif there was a shadow-cljs startup option we wouldn't have those issues#2018-02-1613:47wilkerlucioI hope this gets better with deps.edn does shadow supports deps.edn?#2018-02-1613:47thhelleryes#2018-02-1613:49wilkerluciocool, is there something on the guide about it? I tried to find these days but I failed#2018-02-1613:49thhellerits not really finished since clj isn't available on windows#2018-02-1613:49thhellerbut you can set {:deps {:aliaes [:foo :bar]}} in shadow-cljs.edn#2018-02-1613:50thhellershadow-cljs will then run the jvm via clj#2018-02-1613:52wilkerluciocool 🙂#2018-02-1613:52wilkerluciothe script now ran#2018-02-1613:52wilkerlucioduring the start it generated a lot of those:#2018-02-1613:52wilkerlucio
Feb 16, 2018 11:48:15 AM clojure.tools.logging$eval27442$fn__27445 invoke
INFO: duplicate resource goog/locale/scriptToLanguages.js on classpath, using jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/locale/scriptToLanguages.js over jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170519-fa0499ef/google-closure-library-0.0-20170519-fa0499ef.jar!/goog/locale/scriptToLanguages.js
Feb 16, 2018 11:48:15 AM clojure.tools.logging$eval27442$fn__27445 invoke
INFO: duplicate resource goog/positioning/anchoredviewportposition.js on classpath, using jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/positioning/anchoredviewportposition.js over jar:file:/Users/wilkerlucio/.m2/repository/org/clojure/google-closure-library/0.0-20170519-fa0499ef/google-closure-library-0.0-20170519-fa0499ef.jar!/goog/positioning/anchoredviewportposition.js
#2018-02-1613:53thhellerclasspath conflicts are fun arent they? 🙂#2018-02-1613:53wilkerluciono, they are not 🙂#2018-02-1613:53wilkerlucioand the REPL experience seems limited, it seems to don't understand some REPL send commands:#2018-02-1613:53wilkerlucio
[0:0]~cljs.user=> 3
3
[0:0]~cljs.user=> 4
4
[0:0]~cljs.user=> (in-ns 'com.wsscode.pathom.book.graphql.fulcro-network.demos)
Feb 16, 2018 11:51:36 AM clojure.tools.logging$eval27442$fn__27445 invoke
WARNING: client sent unknown msg {:type :repl/set-ns-complete, :id 7, :ns com.wsscode.pathom.book.graphql.fulcro-network.demos}
Timeout while waiting for REPL result.
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> (css/upsert-css "token-demo" RequireTokenApp)
#object[HTMLStyleElement [object HTMLStyleElement]]
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> {:map "with content"}
{:map "with content"}
[0:0]~com.wsscode.pathom.book.graphql.fulcro-network.demos=> [:book] Compiling ...
[:book] Build completed. (317 files, 2 compiled, 0 warnings, 0.78s)
#2018-02-1613:54wilkerluciothe output is not been formatted, seems like something is missing to cursive to understand#2018-02-1613:54wilkerlucioit was better on the nREPL version#2018-02-1613:55thhellerwell its mixing repl output with log output#2018-02-1613:55thhellerfighweel probably just doesn't log anything?#2018-02-1613:55wilkerluciono, just an information at start, then no logs#2018-02-1613:55wilkerlucio(only responses)#2018-02-1613:57thhellerWARNING: client sent unknown msg {:type :repl/set-ns-complete will be gone in next version.#2018-02-1613:58wilkerluciocool 🙂#2018-02-1613:58wilkerluciothere is another one like this:#2018-02-1613:58wilkerlucio
Feb 16, 2018 11:58:03 AM clojure.tools.logging$eval27442$fn__27445 invoke
WARNING: client sent unknown msg {:type :repl/require-complete, :id 10}
#2018-02-1613:58thhellerproblem with the logs is that I really want them#2018-02-1613:58thhellercould add an option though#2018-02-1613:58wilkerluciomakes sense#2018-02-1613:58wilkerlucioI like the logs too, would be nice if they could live together#2018-02-1613:59wilkerluciothis message seems to come now and then: Timeout while waiting for REPL result.#2018-02-1614:00thhelleralso fixed. the responses from the client weren't routed correctly in same cases#2018-02-1614:00wilkerlucionice 🙂#2018-02-1614:44Jon
[2018-02-16 22:42:59 - WARNING] TCP Port 9630 in use.
BindException: Address already in use (Bind failed)
	java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
	java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387)
	java.net.ServerSocket.bind (ServerSocket.java:375)
	java.net.ServerSocket.<init> (ServerSocket.java:237)
	shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:161)
	shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:153)
	shadow.cljs.devtools.server/start-system (server.clj:157)
	shadow.cljs.devtools.server/start-system (server.clj:132)

error Command failed with exit code 1.
info Visit  for documentation about this
#2018-02-1614:45Jonit exits when 9630 is used now?#2018-02-1614:45thhellershadow.cljs.devtools.server.socket-repl/start#2018-02-1614:45thhellersocket repl port conflict#2018-02-1614:45thhellerlike I said .. fixed ports are annoying#2018-02-1614:46Jonagreed...#2018-02-1614:46Jonhow about auto increment?#2018-02-1614:47thhellerwhat is the point then? just use a random port#2018-02-1614:47Jonit defaults to a random port?#2018-02-1614:48thhellersay you want a fixed port but that is taken by something else so you increment#2018-02-1614:48thhelleryour tool now connects to something else#2018-02-1614:48thhellerie. whatever claimed the port first#2018-02-1614:48thhellerthat seems strictly worse#2018-02-1614:49thhellerI can offer you two things#2018-02-1614:49thhellercreate a shadow-cljs command that dumps the currently active ports#2018-02-1614:49thhellerwhich doesn't seem all that useful given that you can just look at the files directly#2018-02-1614:50thhelleror I can add a http://localhost:9630/ports or so page#2018-02-1614:50thhellereither way ... whenever you use fixed ports you are going to run into conflicts#2018-02-1614:50thhellerwhich is why I said to not use them or avoid them wherever possible#2018-02-1614:51thhelleror you simly RUN shadow-cljs cljs-repl foo instead of connecting to any socket at all#2018-02-1614:52Jonnot sure how it interacts with my toolchains, but at current I can accept random ports, as long as I can find the ports easily.#2018-02-1614:52thhellerwhats easier than looking at target/shadow-cljs/socket-repl.port?#2018-02-1614:52Jonlike :socket-repl {:port 0}, it would be fine also.#2018-02-1614:52Jonit's printed in the logs#2018-02-1614:52JonI can just see them.#2018-02-1614:53thhellerseriously? you want to look at logs every time you start up a new server?#2018-02-1614:53Jonold habit from Webpack, did that a lot#2018-02-1614:53thhellerlook at the file and you'll never look for some random port#2018-02-1614:54thhellerthat seems like a horrible way to find out about a port but I can add that if you want#2018-02-1614:54Jonhow do you use these ports currently?#2018-02-1614:54Jonreading them with scripts? and do what?#2018-02-1614:55thhellerthe shadow-cljs script looks at the cli-repl.port and connects to that#2018-02-1614:56thhellerI made a tiny little helper for cursive to connect to the repl#2018-02-1614:56thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cursive_repl.clj#2018-02-1614:57Jonjust remembered nREPL did that a lot...#2018-02-1614:57JonI didn't understand why before. now it is...#2018-02-1614:57thhellernrepl always looks at .nrepl-port yes. but that belongs to lein and I don't want to conflict with that#2018-02-1614:57Jonis that common...solution in Java or in Clojure?#2018-02-1614:57JonI haven't seen that before in JavaScript world#2018-02-1614:58thhellerwhat is? writing ports to files?#2018-02-1614:58Jonyeah, ports in files#2018-02-1614:58JonUnix systems?#2018-02-1614:58thhellerseems pretty common. definitely not a java/clojure thing. probably a unix thing.#2018-02-1614:59thhellerpretty similar to .pid files I guess#2018-02-1614:59Jonsounds quite similar.#2018-02-1615:00Jonwell, just new stuff to JavaScript, we don't read files from browsers before. not seen in Node.js also.#2018-02-1615:00Jonanyway, I barely read those files, it's not in my toolchains yet. Reading them from logs is the most natural way for me.#2018-02-1615:02Jondoes it need an update in the docs? https://shadow-cljs.github.io/docs/UsersGuide.html#http#2018-02-1615:02thhellerwhat does?#2018-02-1615:02Jonoh, mistake...#2018-02-1615:02Jonno need to update, it's not socker REPL.#2018-02-1615:03Jonjust they have different strategies of picking ports.#2018-02-1615:03thhellerno they don't? they are all random by default unless you configure them#2018-02-1615:03thhelleronly the http port is sort of fixed#2018-02-1615:04thhellerwhich was sort of a bad idea and should be removed to be honest#2018-02-1615:04Jonokay, only http port special.#2018-02-1615:04Jonconsistency is preferred.#2018-02-1615:04thhellerhumans should never need to remember ports#2018-02-1615:04thhellerthats just annoying to work with#2018-02-1615:05Jonbut I still use localhost:8080 in browser history to develop my apps everyday.#2018-02-1615:05thhellerunfortunately it will require a proper UI to make working with those easier#2018-02-1615:06Jonsounds like a groups of toolchains to me...#2018-02-1615:09thhellerits certainly enough work for a couple of years 😉#2018-02-1615:12Joncan't wait that long~#2018-02-1615:13Jonsomehow I want to see how you use shadow-cljs in you browser apps... just want to find out how mach difference out there#2018-02-1615:13Jonmost of my habits are from Webpack.#2018-02-1615:13Jonmight be different with many other tools.#2018-02-1615:14thhellerI thought about writing that down somewhere. Probably would make it easier to understand why certain things are the way they are#2018-02-1615:15Jonthat would be good.#2018-02-1615:15thhellercan't use my work projects as examples though since I'm not allowed to post names#2018-02-1615:16JonI need to rethink some of my toolchains also. Habits brought from JavaScript to Clojure, not all of them are good.#2018-02-1615:16Jon"work" means your current "job"?#2018-02-1615:17Jondemo projects are fine... todoMVC app?#2018-02-1615:19thhellerI haven't set up a full demo project#2018-02-1615:19thhellerwell this is https://github.com/shadow-cljs/quickstart-browser#2018-02-1615:20thhellerthe workflow is simple shadow-cljs clj-repl. connect to that from Cursive.#2018-02-1615:20thhellerlaunch the build in the cursive repl. edit code.#2018-02-1615:21Jonthen you still need to demonstrate how to use inside the REPL#2018-02-1615:21thheller(shadow/watch :the-build)?#2018-02-1615:22JonI think shadow variable is not in REPL by default?#2018-02-1615:22Jonmaybe I'm wrong...#2018-02-1615:22thhellerlooks somewhat like that#2018-02-1615:24thhellerREPL always on the side with build log output and eval results#2018-02-1615:25thhellerbrowser on a 2nd monitor when building a website#2018-02-1615:25JonI started REPL in iTerm3#2018-02-1615:26JonSublime Text for exiting raw code, that browser for Calcit Editor.#2018-02-1615:26thhellerI do have the shadow-cljs clj-repl process running in a terminal#2018-02-1615:26thhellerbut pretty much never need to look at it#2018-02-1615:26Jonalso need another browser tab for my real app.#2018-02-1615:28hlolliI'm haveing a situation where I have two builds :admin and :public, with shadow-cljs watch admin it starts the http server for :public as well as :admin. Is it possible to prevent this?#2018-02-1615:29thhellerno. but it only starts the http server not the build.#2018-02-1615:30thhellerit starts the http server because I wanted to be able to use them with compile and release#2018-02-1615:30hlolliok then it's harmless, the ports were conflicting with other processes I was running#2018-02-1615:30hlollicool, thanks for clarifying!#2018-02-1615:30thhelleryeah fixed ports are a PITA to work with#2018-02-1615:31thhellerwish there was a proper cross-platform way to just use virtual hosts#2018-02-1615:31thhellerie. DNS not ports#2018-02-1615:31hlolliyes, dns's would be neat.#2018-02-1615:32hlollioff-topic, you seem the have mastered the urban dictionary more than anyone here on the slack, but nice to learn abbreviations like PITA along clojurescript 😄#2018-02-1615:33thhellerhehe#2018-02-1615:34JonI used Google to look up. English->Chinese dict not enough.#2018-02-1615:38hlolliP.E.M.D.A.S#2018-02-1615:39thheller@wilkerlucio 2.1.13 should fix the REPL issues you had#2018-02-1615:40thhelleralso fixed an issue where the build would get stuff if a macro had errors, changes to that would not trigger a reload.#2018-02-1615:59justinlee@thheller I don’t know if you did something specific to fix my protorepl issue, but if not, whatever you did in 2.1.13 fixed it#2018-02-1615:59justinleeits nice and stable now#2018-02-1616:00thhellergood to know#2018-02-1616:03justinleeoops no i spoke too soon. there is definitely something weird going on here.#2018-02-1616:03justinleei’ll do a bit more investigation. its going to be annoying because things aren’t erroring, they are timing out#2018-02-1616:05wilkerlucio@thheller confirmed that changing ns and loading file are working now 🙂#2018-02-1616:08justinleeis this expected behavior? when i connect to my app using shadow-cljs cljs-repl app, I get a timeout trying to switch to a library (and I confirmed that I’m connected to the browser by logging there first)
[3:1]~com.rpl.specter=> (js/console.log "***")
nil
[3:1]~com.rpl.specter=> (in-ns 'com.rpl.specter)
Timeout while waiting for REPL result.
#2018-02-1616:09justinleethe timeout causes bad things to happen in atom protorepl (a spinner shows up in the buffer and never goes away), but i wonder why i’m getting timeouts to begin with#2018-02-1616:10thhelleris it possible that the namespace isn't loaded yet?#2018-02-1616:10thhellerdoes it work if you (require 'com.rpl.specter) first?#2018-02-1616:10thhelleroh wait you are already in that ns#2018-02-1616:11thhellerbut I can confirm that I get a timeout when switching to non existing namespaces#2018-02-1616:12wilkerlucioI tried to go back to terminal usage, now I'm getting:#2018-02-1616:12wilkerlucio
shadow-cljs - config: /Users/wilkerlucio/Development/pathom-book/shadow-cljs.edn version: 2.1.13
shadow-cljs - socket connect failed, server process dead?
#2018-02-1616:12thhellerdid you kill the REPL process?#2018-02-1616:12wilkerlucioyeah#2018-02-1616:13thhellerhmm its supposed to clean up properly#2018-02-1616:13thhellerdelete the target/shadow-cljs/cli-repl.port file#2018-02-1616:13wilkerluciois there a way to force the clean up, or check for it?#2018-02-1616:14thhellerdunno I use a JVM shutdown hook to delete the port files#2018-02-1616:14thhellerbut maybe those don't trigger if you kill the jvm?#2018-02-1616:16wilkerlucioentering a meeting now, will check a bit later#2018-02-1616:20justinlee@thheller other random question: it looks like you used asciidoctor to compose the user guide? i started using gitbook to do something similar but it doesn’t understand clojure. are you happy with asciidoctor?#2018-02-1616:22thhellerkind of. I recently found slate which look a bit better but no idea if it supports clojure. https://lord.github.io/slate/#2018-02-1616:22thhellerasciidoctor works well though. no complaints so far.#2018-02-1616:25thhellerhttps://github.com/lord/slate#2018-02-1616:26thhellerasciidoctor is probably better all around but slate definitely looks neat for API docs#2018-02-1616:26thhellergtg, bbiab#2018-02-1616:49tony.kayI just upgraded to the latest version, and the REPL experience in IntelliJ is better, but still gives some errors on output. If I use the “send to REPL” for something in a comment block like (defn g [a] (js/console.log :HI a)), I see the error Failed to parse client result: No dispatch macro for: '#2018-02-1616:53tony.kayGuessing someone’s parsing doesn’t like the return of def #'the-ns/g#2018-02-1616:54tony.kay@thheller would that be in shadow or Cursive?#2018-02-1616:56tony.kayactually, this is perhaps a better representation of the output:
(def h (f/debounce g 1000))
Failed to parse client result: No dispatch macro for: '
=> "#'the-ns/h"
#2018-02-1616:56tony.kayso it does give back a string of what the def returned…everything “works”…it’s just a bit misleading/annoying#2018-02-1617:02wilkerlucio@thheller just FYI, running shadow-cljs stop fixed the start issue, after that it ran fine#2018-02-1617:28thhelleromg .. I finally figured out how nrepl is supposed to be used ...#2018-02-1617:30thhellerthat took way too long to figure out#2018-02-1617:30wilkerluciointeresting, how much different it is from the current impl?#2018-02-1617:30thheller:printed-value true#2018-02-1617:31thhellerI couldn't figure out why results from the shadow-cljs were always displayed as a string#2018-02-1617:31thhellerso I though other tools must be reading the response value#2018-02-1617:31thhellerbut that causes all kinda of issues apparently#2018-02-1617:32thhellerbut instead I'm supposed to set :printed-value on the message and just pass the string along
#2018-02-1617:32thhellerhttps://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl/middleware/pr_values.clj#2018-02-1617:32thhellernever knew that this middleware is used by default ...#2018-02-1617:37thhelleryep ... appears to resolve all issues ...#2018-02-1617:38wilkerluciobananadance#2018-02-1617:38wilkerlucioso 2.1.14 on the way? 🙂#2018-02-1617:39thhelleravailable now yes#2018-02-1617:41thhellerI tested atom and cursive. both appear to be working correctly now#2018-02-1617:47wilkerlucio@thheller just tried, but got some problems, the nrepl is not responding, and I see this on the shadow-cljs terminal:#2018-02-1617:50thhellermeh .. I guess that explains why its :printed-value 1 in piggieback .. no true#2018-02-1617:50tony.kaySome things are better, but I’m also seeing an issue#2018-02-1617:50tony.kayIf I run something like a react DOM render by accident it causes an exception on the client, then I get no more REPL output. If this helps, it is the js console message:
encoding of result failed TypeError: Cannot convert a Symbol value to a string
    at Array.join (native)
    at Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 ()
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] ()
    at cljs$core$pr_writer ()
    at 
    at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] ()
    at Object.cljs$core$print_prefix_map [as print_prefix_map] ()
    at cljs$core$print_map ()
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] ()
    at Object.cljs$core$pr_writer [as pr_writer] () {$$typeof: Symbol(react.element), type: "div", key: null, ref: null, props: {…}, …}
Restarting nREPL fixes it (do not have to restart shadow)
#2018-02-1617:50wilkerlucioI noticed any command I type on the REPL generate one of those#2018-02-1617:51wilkerlucioand :code is whatever I sent#2018-02-1617:52tony.kayI’m not seeing Wilker’s issue, though#2018-02-1617:58thhellerthat the error doesn't show up in the REPL is definitely not intended#2018-02-1617:58wilkerluciomine seems to got totally borked, nothing that I send to the REPL is working#2018-02-1617:59thhellerI fixed that I think#2018-02-1617:59wilkerlucio2.1.15?#2018-02-1617:59thhellercoming in a sec#2018-02-1618:00thheller@tony.kay the symbol issue is this one https://dev.clojure.org/jira/browse/CLJS-1628#2018-02-1618:18thheller2.1.15 prints errors and should fix the Boolean issue#2018-02-1618:18thhellererrors aren't yet source mapped, need to hook that up first#2018-02-1618:30wilkerluciocool, sends are back on nREPL here#2018-02-1618:33wilkerlucioone more thing: when using figwheel repl Intellij is able to recognize it's cljs and switch the repl for it (there is combobox to switch), but on shadow it can't and I have to manually change it#2018-02-1618:36thhellerhmm wonder what magic achieves that#2018-02-1618:48thhellerhehe its just the printed message#2018-02-1618:48thhellerTo quit, type: :cljs/quit#2018-02-1618:48thhellerbut I printed To quit, type: :repl/quit#2018-02-1618:48thhellercursive seems to only detect the first one#2018-02-1618:53wilkerlucioI think worth asking on #cursive, colin surely knows how it happens 🙂#2018-02-1618:53tony.kayand Colin is really open to that sort of thing#2018-02-1618:53thhellerI mean it works now#2018-02-1618:53wilkerlucioah, you changed for :cljs/quit and it did the trick?#2018-02-1618:53thhellerchanging the message was all it requred#2018-02-1618:53wilkerlucionice#2018-02-1618:54tony.kaysuper nice#2018-02-1618:54tony.kayyou rock Thomas!#2018-02-1618:56thheller2.1.16 seems to work properly with Cursive now#2018-02-1619:01wilkerlucioyes, confirmed, thanks for such quick fixes 💚#2018-02-1619:02thhellerif you find anything else let me know. I barely ever use the CLJS REPL so I never noticed these things#2018-02-1619:04wilkerlucioyeah, I guess after years of really bad REPL's on CLJS people just got used to live without it, but for me it's very important part of my workflow#2018-02-1619:04thhellerI just rely on live reloading for CLJS. For CLJ I use the REPL all the time.#2018-02-1619:06wilkerlucioI can understand that. what I do is that while writing functions, I just keep doing small changes and running on the REPL, that's the fastest feedback loop I know about, specially when writing data transformations#2018-02-1619:06theaspSooo... When are you going to support clojure? 😉#2018-02-1619:07thhellerhttps://clojureverse.org/t/share-the-nitty-gritty-details-of-your-clojure-workflow/1208/10?u=thheller#2018-02-1619:07thhellerthe deftest workflow unfortunately doesn't work for CLJS in Cursive#2018-02-1619:07thhellerotherwise I'd probably use that more there as well#2018-02-1619:09thheller@theasp probably never. enough tooling for that exists.#2018-02-1715:11ggaillardHello ! Did some of you encountered an error while :import-ing goog classes with v2.1.16? I got this error :
The required namespace "goog.i18n.DateTimeSymbols_en" is not available, it was required by "cli/web/services/app/translations.cljs".
The ns looks like :
(ns cli.web.services.app.translations
  (:require [bf.algo.generic :as a]) ;; an internal lib
  (:import [goog.i18n DateTimeSymbols DateTimeSymbols_en]))
#2018-02-1717:03hlollicould it be similar as with goog.string format, where you have to both import it and require it?#2018-02-1717:27thheller@ggaillard I think you are supposed to use the :compiler-options {:closure-defines {goog.LOCALE "en"}} and that will pull in the correct symbols#2018-02-1717:27thhellerie. never use the language directy but instead only use goog.i18n.DateTimeSymbols#2018-02-1717:28thhellerthat being said there is a bug since DateTimeSymbols-en works although its DateTimeSymbols_en#2018-02-1717:29thhellersee https://github.com/google/closure-library/blob/master/closure/goog/i18n/datetimesymbols.js#L3425#2018-02-1717:52thhellerchanged it so both versions are now available (just in case). should still rely on goog.LOCALE though#2018-02-1722:18ggaillard@thheller You are 100% right about setting goog.LOCALE to the desired locale instead of importing DateTimeSymbols_* for so many reasons (as cited in the link you provided). But in this case I was trying to build a component that switch date formats explicitly at runtime. So I was kind of poking the thing with a stick, to see what I could get out of it. Thank you for the workaround 🙂#2018-02-1801:19wilkerlucioI'm trying to use shadow with deps.edn, but I'm getting this:#2018-02-1801:19wilkerlucio
Wilker-Nu:pathom-book wilkerlucio$ shadow-cljs watch book
shadow-cljs - config: /Users/wilkerlucio/Development/pathom-book/shadow-cljs.edn version: 2.1.16
shadow-cljs - starting via "clojure"
Invalid option: -Sdeps
#2018-02-1801:19wilkerlucioideas what's that about?#2018-02-1801:21wilkerlucioI'm getting it should be trying to call -Spath instead?#2018-02-1801:29hlolliI've been spending a lot of time tonigh trying to find out why shadow-cljs release compiles differently on my computer vs on server. I'm useing same node and shadow-cljs versions, its the same git repo. I don't know what I could be missing, what could cause this. Because the error I get from the server I don't get on my computer, and if I copy the server compilation on to my computer, then I get the same error.#2018-02-1801:35hlollioh I think I see it now, on my computer I has shadow-cljs 2.1.6 the server has 2.1.16, guess my eyes got fooled, going to check that..#2018-02-1801:43hlolliyup confirmed, there's clearly an error that is present in 2.1.16 that is not present in 2.1.6, and reading the error it doesn't look like my code is anywhere there in between
TypeError: Cannot call a class as a function
    at b.a (quill.js:1952)
    at new b (quill.js:5471)
    at b.value (quill.js:5367)
    at b.value (quill.js:6617)
    at new a (quill.js:1111)
    at a.createEditor (mixin.js:13)
    at a.componentDidMount (component.js:202)
    at a.componentDidMount (factory.js:666)
    at commitLifeCycles (react-dom.production.min.js:150)
    at c (react-dom.production.min.js:159)
this does not have to be because of shadow-cljs.. going to investiage
#2018-02-1803:01thheller@wilkerlucio -Sdeps should be available. maybe you have an older version where its not?#2018-02-1803:02thheller@hlolli they only thing I can think would be the closure compiler update#2018-02-1803:04thhelleryou can try shadow-cljs release build --debug to get a more usefull error maybe#2018-02-1803:05hlolli@thheller yes, I gave up. It was successfully compileing, then I updated shadow, it failed, so I wanted to go back to version 2.1.6 and the failure stayed, maybe cacheing, target unclean. Don't know, but I'm ditching react-quill, useing quill straight up.#2018-02-1803:05wilkerlucio@thheller on the spot, updated clj and it's working fine 🙂#2018-02-1803:05thhellercould maybe be related to :default?#2018-02-1803:07hlollimaybe, as for every module require I was doing Module/default (which after reading the docs better, is avoidable), except react-quill... ok, going to have one more look at the chilren of the objects returned by importing react-quill...#2018-02-1803:08thheller:default is in a weird situation in some packages because even though they might provide examples as ES6 with default imports#2018-02-1803:08wilkerluciois it possible to activate extra deps aliases via command line?#2018-02-1803:08thhellerthey sometimes publish commonjs instead#2018-02-1803:09thheller@wilkerlucio no, only per config :deps {:aliases [:alias ...]}#2018-02-1803:11thhellerextra-deps does not make sense to me in a CLJS setting. maybe you have a use-case where it make sense but so far I haven't found one#2018-02-1803:11wilkerlucioI was thinking that shadow could have something like --clj-options -A:more-alias:other#2018-02-1803:11wilkerlucioin my case is more related to extra paths#2018-02-1803:11hlolliyes, maybe shadow could default to :default, probably screws up backwards compatability (and not compatable with rest of cljs I assume, so bad idea)#2018-02-1803:11wilkerlucioI imagine having deploy build with regular settings, but for dev I want to add local source paths to use dev versions#2018-02-1803:12wilkerlucioalso there could be situations you want to try building against different lib versions#2018-02-1803:14thheller@hlolli :default isn't in CLJS yet so I could definitely change it. problem is that the node/webpack world handles default exports differently than closure#2018-02-1803:15thhellerso I'm totally unsure which way to go#2018-02-1803:16thhellerI tried going the closure way but that broke way too many libs so I went with a compromise for now#2018-02-1803:18thheller@wilkerlucio ok, I'll add -A support#2018-02-1803:19hlolliclosure is working on a pace like javascript was in 1999... slow 🙂#2018-02-1803:20hlollispecifying the default is bearable enough to wait and see how closure develops#2018-02-1803:20thhellernah the situation is just messy and supporting the mess that is on npm sometimes is not their goal#2018-02-1803:22thhellerproblem really is that default import/exports didn't exist before ES6#2018-02-1803:22thhellerand everyone has a different interpretation about when or how to use them#2018-02-1803:22thhellerso every package does something a little different#2018-02-1803:22thhellerwhich is just messy#2018-02-1803:23thhellerI think I should just adopt what webpack does#2018-02-1803:23hlolliand requireing from closure, it can't differentiate that it's requireing es6 or cjs?#2018-02-1803:24hlolliyes, it's very messy, all my kudos to the closure developers that are trying to make something stable#2018-02-1803:24thhellerproblem is that people publish converted ES6 code to npm#2018-02-1803:24thhellerie. code that was ES6 but was converted to common js by babel#2018-02-1803:24thhellerclosure detects those as commonjs and rewrites them accordingly#2018-02-1803:25thhellerBUT that breaks how others require those#2018-02-1803:25thhellerso ... mess ..#2018-02-1803:25thhellerbut thats part of the reason I don't use closure to process anything on npm#2018-02-1803:25hlolliah, ok I though google closure had some babel functionality behind the hood, since import seemed to be what was running#2018-02-1803:26thhellerwell I use closure but not their es6/cjs rewriting#2018-02-1803:26thhellerif you can tell me which package fails now that worked before I can take a look#2018-02-1803:27hlollireact-quill#2018-02-1803:27thhellerand your require for it is?#2018-02-1803:27hlolliIm swimming in a mess, just deleted target and trying again now, then I can test this require#2018-02-1803:27hlolli["react-quill" :as Quill]#2018-02-1803:29thhellersee .. super weird package#2018-02-1803:29thhellerbut [:> Quill ...] should be working?#2018-02-1803:30hlollithat works in 2.1.6#2018-02-1803:30hlollinot 2.1.16, didnt try in between, so I dont know where it fails, well I did try, but as I was down to 2.1.10 I realized I didnt delete target in between of downgrading shadow-cljs 🙂#2018-02-1803:31thhellerdeleting target directory should never be necessary#2018-02-1803:31thhellercache is smart enough to detect file changes#2018-02-1803:32hlolliI had successful case of deleteing target just 5 mins ago, shadow-cljs was complaining about superfuntion or something, too strange to make sense, so it left after I tortched target.#2018-02-1803:33thhellerhttps://unpkg.com/react-quill@1.2.4/lib/index.js#2018-02-1803:34thhellermodule.exports = require('./component'); is what you get with :as Quill#2018-02-1803:34thhellerbut that also has a Quill property#2018-02-1803:34hlollifacepalm haha#2018-02-1803:34thhellerbut none of that behaviour should have change between the versions#2018-02-1803:35hlolliok..#2018-02-1803:35hlolliI can try 2.1.6 again moment#2018-02-1803:35hlolli(not that I want to prove you, but to see if this is irrelevant)#2018-02-1803:36hlolliIm doing the "crunch", so my short term memory and overall demenour is not crisp#2018-02-1803:38thhellerI reproduced the error with 2.1.16#2018-02-1803:40hlolliok, phew, so, I reproduced the success with 2.1.6#2018-02-1803:45thhellerI'll see if its the closure version#2018-02-1803:47thhellercrap ...#2018-02-1803:47thhellerdowngrading ONLY closure fixes it 😞#2018-02-1803:49thhellerit might work if you add [com.google.javascript/closure-compiler-unshaded "v20180101"] to your deps#2018-02-1803:49thhellerthats the release before their big changes#2018-02-1803:49thhellerI'll try to figure out whats different and see if I can do something about that#2018-02-1803:49hlolliok nice I'll try#2018-02-1803:51thhelleroh wait I just tested with [com.google.javascript/closure-compiler-unshaded "v20170910"]. so maybe thats the safe option.#2018-02-1803:52hlolliok, I'm starting the first one now, let's see, try the other one if it fails#2018-02-1803:53thhellerconfirmed that v20180101 works#2018-02-1803:53thhellerbut it prints a bunch of warnings that aren't there with v20170910#2018-02-1803:54hlolliyes it works, but notice a clue here, if you do [:> Quill/Quill] you get the same error as before.#2018-02-1803:55thhellerQuill is the react-quill component#2018-02-1803:56thhellerQuill/Quill is basically (:require ["quill" :as Quill])#2018-02-1803:56thhellersince they just pass that through#2018-02-1803:56hlolliand also printing the object Quill (the :as Quill) then the letter c #object[c], was b. If that could matter#2018-02-1803:57hlolliok I see#2018-02-1803:57thhellernah thats just the minifier being weird#2018-02-1804:01hlollithanks so much, here ends 11 hours struggle 😄, these kinds of issues really kill the flow and fun.#2018-02-1804:02hlollibut I've been lucky for long time, it was my turn hehe#2018-02-1804:02thhelleryeah these kinds of things are painfully annoying#2018-02-1804:03thhellerI'd prefer if it was something I did but I guess its not 😞#2018-02-1804:03thhellereasier to debug if its on my end#2018-02-1804:05hlollithats a good mindset, but yeh, it shows thats closure can sometime do non backwards compatable things.#2018-02-1804:05hlolliin their defence, workings with npm deps, I give them a break on that one#2018-02-1804:11thhellerno idea what to do though short of git bisect#2018-02-1804:17hlollimaybe there's some logic to their changes, or this is a bug, it seemed to be the default export was the supposedly nested quill.js object. Could that be symbol bug, maybe we can give this a better try on the newest closure compiler.#2018-02-1804:17thhellerno default exports in this code#2018-02-1804:18thhellerv20180204 is the latest release#2018-02-1804:19hlolliat least the difference seems to be that what object ["react-quill" :as Quill] becomes, differes between the compiler versions.#2018-02-1804:19thhellerpretty sure there is just some extra rewriting happening that wasn't there before#2018-02-1804:20thhellerthe object still seems to be the same#2018-02-1804:20thhellerits still a react component and stuff#2018-02-1804:21thhellerthe exception happens somewhere deep in Quill code#2018-02-1804:21thhellernot even react#2018-02-1804:21hlollireally... it seemes to me that the error message from the older version from [:> Quill/Quill] and [:> Quill] in newer compiler is exacly the same, but I can look better..#2018-02-1804:23thhellerQuill/Quill is never the component#2018-02-1804:23thhellerI'm logging it before trying to mount it and it look identical between the versions#2018-02-1804:24hlollimy theory goes like that, that in newest closure version ["react-quill" :as Quill] is also not the component#2018-02-1804:24hlolliok, then.. my theory is wrong 🙂#2018-02-1804:24thhellerexports was just my first instinct but it was wrong#2018-02-1805:27thhellerbisect this commit is bad#2018-02-1805:27thhellerhttps://github.com/google/closure-compiler/commit/6b807c063d42a463e3c32e5911c695a0976e2b67#2018-02-1810:46thhellerreported here https://github.com/google/closure-compiler/issues/2822#2018-02-1813:15thheller@wilkerlucio -A:foo now supported in 2.1.17#2018-02-1815:02wilkerlucio@thheller after I updated to 2.1.17, trying to compile is generating a lot of those:#2018-02-1815:02wilkerlucio
------ WARNING #1 --------------------------------------------------------------
 File: /Users/wilkerlucio/Development/third-part/fulcro/src/main/fulcro/client/primitives.cljc:608:21
--------------------------------------------------------------------------------
 605 |   (if-not (nil? x)
 606 |     #?(:clj  (or (instance? fulcro.client.impl.protocols.IReactComponent x)
 607 |                (satisfies? p/IReactComponent x))
 608 |        :cljs (true? (. x -fulcro$isComponent)))
---------------------------^----------------------------------------------------
 Cannot infer target type in expression (. x -fulcro$isComponent)
--------------------------------------------------------------------------------
 609 |     false))
 610 |
 611 | #?(:clj
 612 |    (defn react-type
#2018-02-1815:03thhellerI turned externs inference on by default so thats an extern inference warning#2018-02-1815:04wilkerluciothey are too many (140 in my case) the warns are poluting the UI on browser, making unusable =/#2018-02-1815:04wilkerluciohow I disable that?#2018-02-1815:04thhellerhmm really so many? I should probably turn it off then#2018-02-1815:05thheller:compiler-options {:infer-externs true} was the previous default#2018-02-1815:06wilkerluciotrue was the previous default? what is the default now?#2018-02-1815:06thheller:auto#2018-02-1815:07thhellerwith true you have to (set! *infer-externs* true) to get the warnings#2018-02-1815:07wilkerluciomost of then seem to come related to fulcro code#2018-02-1815:07thhellerauto sets that for all FILES on your classpath#2018-02-1815:08thhellerit will warn about all native interop where the interop value cannot be identified as js or clj#2018-02-1815:08thhellerso yeah lots of interop produces lots of warnings#2018-02-1815:08thhellerI'll revert it back to true ... 140 warnings is way too much#2018-02-1815:09wilkerlucioagreed, I just got back to sanity with the compiler option set to true again#2018-02-1815:09thhellerits only an issue if you have libraries like fulcro as actual sources#2018-02-1815:10thhellerwhen using a jar it won't warn about those#2018-02-1815:10thhelleralthough at some point everything should probably be annotated properly#2018-02-1815:10wilkerluciohumm, that makes sense, I'm using a bunch of things in dev mode at this point#2018-02-1815:10thhellerotherwise externs inference is never gonna catch on#2018-02-1815:11wilkerlucionot sure if @tony.kay is aware about those at this point#2018-02-1815:12thhellertrouble is that those probably don't require externs but the compiler can't figure this out on its own#2018-02-1815:13thhellerreverted the default in 2.1.18#2018-02-1815:22Jon
33 |          (.on socket "message" on-message!)
----------------^---------------------------------------------------------------
 Cannot infer target type in expression (. socket on "message" on-message!)
#2018-02-1815:23Jonguess I need to upgrade.#2018-02-1815:23thhelleryou probably want to typehint socket#2018-02-1815:23Jonhow?#2018-02-1815:24thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-02-1815:27thhellerbut if you didn't have issues so far you can probably either upgrade or disable via config#2018-02-1815:27thhellerguess setting the default was a little too ambitious#2018-02-1815:33Jonupgraded and no warnings now#2018-02-1815:33Jonadding ^js also worked.#2018-02-1816:22hlolliagain I'm getting strange difference between server and my computer, same shadow-cljs and same closure versions, which I find hard to believe. It's the tab button from material-ui menu, when I click on it, the server greets me with
index.js:19 Uncaught TypeError: Cannot read property 'ease' of undefined
    at Object.left (index.js:19)
    at b.d.scrollSelectedIntoView (Tabs.js:257)
    at b.value (Tabs.js:308)
    at commitLifeCycles (react-dom.production.min.js:150)
    at b (react-dom.production.min.js:159)
    at ka (react-dom.production.min.js:170)
    at t (react-dom.production.min.js:169)
    at p (react-dom.production.min.js:168)
    at m (react-dom.production.min.js:166)
    at Object.enqueueForceUpdate (react-dom.production.min.js:110)
and crashes the root component and leaves the site with only background, typical react crash, investiageing...
#2018-02-1816:29theaspHey, is there something equivalent to lein-ancient?#2018-02-1816:52hlollinah ok, not the compiler, both the source maps and main js file had the same md5sum#2018-02-1816:53thheller@hlolli is it possible that the server includes some other javascript that might cause conflicts?#2018-02-1816:54thhellergoogle analytics or something similar maybe?#2018-02-1816:54hlolliI've torched the js dir, no its still at this point completly the same, same server handler etc.#2018-02-1816:54hlolliI'm starting to suspect some callback stuff, its way slower connection, the server is in iceland and im in germany#2018-02-1816:55hlolliso typical js headache probably#2018-02-1817:08hlolliok I guess the md5sum differ, Im getting lost in all those terminal windows of on which computer I am#2018-02-1817:10thhellermd5sum can always differ due to the naming scheme by closure#2018-02-1817:11hlolliI guess :whitespace would be deterministic?#2018-02-1817:12thhellerI wouldn't count on it. should rather try shadow-cljs release app --debug to get more clues about where you are at in the code#2018-02-1817:12thhellercan also try shadow-cljs check app, maybe that has some clues#2018-02-1817:13hlolliok#2018-02-1817:14thhellerjust pause on exception in chrome and stepping through the code might help as well#2018-02-1817:14thhellerUncaught TypeError: Cannot read property 'ease' of undefined since its named ease I don't think its an externs issue#2018-02-1817:15thhellerbut maybe somewhere nil is passed where it shouldn't#2018-02-1817:15thhellerwhich npm package is involved? besides react-dom?#2018-02-1817:17thhellerhttps://unpkg.com/scroll@2.0.2/index.js#2018-02-1817:17thhellerthis one I guess#2018-02-1817:17hlolliok, I need coffee, it says on my computer
✗ shadow-cljs release public --debug
shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn version: 2.1.16
...
[:public] Build completed. (1509 files, 1389 compiled, 0 warnings, 48.10s)
oh damn, tmux is not allowing me to select text and copy,
#2018-02-1817:18thheller1509 files geez 😛#2018-02-1817:18hlollibut on the server it's 1476 files, should be easy to track, I should have seen this earleir#2018-02-1817:19thhellerhmm might be a good old npm non-deterministic install?#2018-02-1817:19thhellerhttps://npm.github.io/how-npm-works-docs/npm3/non-determinism.html#2018-02-1817:19hlolliyeh, geez, takes a minute for the browser to load the source maps#2018-02-1817:19hlolli6,4mb#2018-02-1817:19thhellerhehe I've seen bigger 😉#2018-02-1817:21hlolliI could try yarn#2018-02-1817:21hlollihttps://yarnpkg.com/blog/2017/05/31/determinism/#2018-02-1817:24thhellerpackage-lock.json is also a thing for npm if you have that committed#2018-02-1817:24thhelleryou can also try to compare the generated manifest.edn in the :output-dir#2018-02-1817:25thhellerthat lists all the included sources#2018-02-1817:28thhellerbut this scroll does this dynamic things closure is not very fond of#2018-02-1817:28thhellerso it may just be that#2018-02-1817:29hlolliok, yes I should defenitely commit the lockfile, I see now why it makes sense#2018-02-1817:30hlollilet's see what yarn does, maybe I commit that lockfile from yarn and switch over#2018-02-1817:38hlolli🎉sanity! Yarn compiled the exact same amount of files and now I get the bug on my laptop, the same as on the server.#2018-02-1817:41thhellerwould have been better the other way around 😉#2018-02-1817:42hlollihehe yeh, I wonder if I was cacheing older react versions, going to give some downgrade a try#2018-02-1817:42hlollibecause I think yesterday I downgraded react and upgraded again#2018-02-1818:03hlolliit seems to be bad codeing that this closure only receives 2 arguments out of 4 on call
_scroll2.default.left(_this.tabs, invert * nextScrollLeft);
module.exports = {
  left: make('scrollLeft'),
  top: make('scrollTop')
}
function make (prop) {
return function scroll (el, to, opts, cb) {
    if (typeof opts == 'function') cb = opts, opts = {}
var ease = opts.ease || inOutSine
but the object opts gets set to a default value {}, would guess that just adding var in front of that could fix is. In any case I open an issue.
#2018-02-1818:04thhellerdid you test if the closure version makes a difference?#2018-02-1818:05hlolliI downgraded from v20180101 to v20170910, I try the newest one with yarn quickly...#2018-02-1818:06hlolliwell, forget that comment about yarn 🙂 not a npm module#2018-02-1818:06thhellersince scroll.js is just a single file you could override what it resolves to#2018-02-1818:07hlollicleaver!#2018-02-1818:15hlollithe latest closure v20180204 didnt fix this, Im surprised how this worked for so long in the first place, only god knows (ergo nobody). But the idea of overriding I'll do anyway#2018-02-1818:15hlollilooks fixable#2018-02-1818:39wilkerluciojust tried to make a release build, but on some cases I'm getting this weird error:#2018-02-1818:39wilkerlucio
TypeError: Cannot read property 'log' of null
    at b (main.js:1638)
#2018-02-1818:39hlolli@thheller should I use :npm or will :file work too
:js-options {:resolve {"scroll" {:target :file
                                :require "./overrides/scroll_index.js"}}}
#2018-02-1818:40thheller:file "overrides/scroll_index.js"#2018-02-1818:42thheller@wilkerlucio shadow-cljs release app --debug should make it easier to find whats null#2018-02-1818:43wilkerluciothanks, trying#2018-02-1818:43wilkerlucioother thing that worth mention, when I delete the target and try to run shadow commands, I get this:#2018-02-1818:43wilkerlucioshadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'#2018-02-1818:43wilkerluciothen I have to manually create the target/shadow-cljs back so it works#2018-02-1818:44thhellerwhen does that happen?#2018-02-1818:46wilkerlucioif I delete the target folder#2018-02-1818:46wilkerluciorm -rf target#2018-02-1818:46thhellerwhich shadow-cljs command#2018-02-1818:47wilkerlucioany of then it seems, but I've been trying with watch#2018-02-1818:47wilkerlucioabout the --debug, seems something related to logging#2018-02-1818:47thhelleroh with :deps I guess?#2018-02-1818:47wilkerlucioon fulcro, that uses some logging stuff from closure#2018-02-1818:47wilkerlucioyeah, :deps is been used#2018-02-1818:50wilkerluciofixed the release build, had to add :compiler-options {:closure-defines {goog.LOCALE "en"}}, I remembered reading this earlier here#2018-02-1818:52thhellergoog.LOCALE "en" is one of the defaults?#2018-02-1818:52hlollididnt go trough this is still in the manifest and output "node_modules/scroll/index.js" after :js-options {:resolve {"scroll" {:file "overrides/scroll_index.js"}}}#2018-02-1818:53thhellerhehe, must still keep the :target :file#2018-02-1818:54hlolliah, I tried with target :npm, wasn't sure in which direction the target was aiming 🙂#2018-02-1818:54thheller:npm is configured via :require and :require-min#2018-02-1818:54thheller:file is :file#2018-02-1818:54thhellerbut :target is necessary to select which key to look at next#2018-02-1818:55hlolliyes, you could theoretically get all that data just from :require vs :file ? no pain to add target whatsoever#2018-02-1818:55thheller:file is a in a weird space right now since the classpath changes I made#2018-02-1818:56thhellerbut there is also :global 😉#2018-02-1818:56hlolliah, damn golbals#2018-02-1818:57thhellerI prefer to be explicit and not just look at a bunch of keys#2018-02-1818:58hlolliI could learn a thing or two from you on that topic#2018-02-1819:05hlollinow I have these two files nested in release ... target dir
module$overrides$scroll_index.js
module$node_modules$scroll$index.js
and the code requireing scroll/index.js finds neither. Maybe harmless, just wondering if this is affecting the correct true state of the target to compilation.
#2018-02-1819:06thhellerdid you clean the target dir? I don't clean anything#2018-02-1819:06hlollino, I bet that may help, let's see#2018-02-1819:06thhellernah the extra file doesn't harm anyone#2018-02-1819:06thhellerwould just be a leftover from a previous compile#2018-02-1819:07thhellerthe lookup should work though#2018-02-1819:07thhelleryou can check the modules$node_modules$material_ui$tabs$tabs.js or whatever that was called#2018-02-1819:08thhellerif it has the correct require up top#2018-02-1819:08thhellerit should but its been a while since I used :file#2018-02-1819:09hlolli
var _scroll = require('scroll');
var _scroll2 = _interopRequireDefault(_scroll);
function called from _scroll2 that existed, is now not found
#2018-02-1819:09thhellerwhat does the output file look like?#2018-02-1819:09wilkerlucio@thheller not sure what you mean by goog.LOCALE "en" is one of the defaults, defaults of what?#2018-02-1819:10hlolli1 sec.. its loading the source map, takes longer than compileing 😄#2018-02-1819:10thheller@wilkerlucio https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/api.clj#L42-L45#2018-02-1819:11thhellerand its the default in closure itself, so setting it to en shouldn't really make a difference?#2018-02-1819:11wilkerluciowell, it surely did here
#2018-02-1819:11thhellerstrange#2018-02-1819:12wilkerluciowas a random attempt, I just remembered you saying something about it here, I tried and worked 😛#2018-02-1819:12hlolliaw_yeah haha no "output" to show, deleted target, compiled again and now I can scroll like a m***fa*a#2018-02-1819:13thhellerand what did you change?#2018-02-1819:13hlollithis bast*rd opts = opts || {}; cured it haha, wow#2018-02-1819:16hlollithis feature of patcheing/overriding the npm modules, is very very important. Going to implement this into the lumo binary bundler I made recently. Since requireing .node files needs always some patcheing, not counteing fixing bugs.#2018-02-1819:16thhellerdoesn't work in node though#2018-02-1819:17thhellerthat just delegates to require. can't influence what that does.#2018-02-1819:17hlolliI mean implementing this concept, in js.#2018-02-1819:17thhellerfor :browser I control entirely how and what gets resolved#2018-02-1819:17thhellerwebpack has something similar, thats where I got the idea#2018-02-1819:18hlolliyeh, nexe has this concept of monkeypatching, I was already on the path of seeing the importance of this.#2018-02-1819:19hlollithis at least time from creating a fork, and aim npm modules to a github repo, which is the classical way I guess.#2018-02-1819:20thhelleryeah :resolve {"scroll" {:target :npm :require "@hlolli/scroll"}} would have been the alternative#2018-02-1819:20thhellerbut also wouldn't have any effect in node#2018-02-1819:21hlollibecause of the non-advanced optimizations?#2018-02-1819:21thhellerno because you don't require it. material-ui does.#2018-02-1819:22thhellerso we do only require("material-ui") and whatever that does we have no control over#2018-02-1819:22hlollihm ok, never had to try stunt like that so far, editing nested dependencies in npm#2018-02-1819:22thhellerworks in webpack but not in node#2018-02-1819:29thhellerI'm always amazed what closure does with the code#2018-02-1819:30thhellerits a wonder anything works at all#2018-02-1819:30thhellerhttps://gist.github.com/thheller/9ec47a878a2332317fe2d897c6d2cb2b#2018-02-1819:30thhellerdoesn't look anything like the input 😛#2018-02-1819:34hlolliyou can say closure is very foriging of the quality of the code it receives 🙂#2018-02-1819:36hlollino Im blameing the wrong victim here, this code is fine, mostly, just Tabs.js that was not filling in all the parameters#2018-02-1819:36thhellerstill need to do https://github.com/thheller/shadow-cljs/issues/173#2018-02-1819:36thhellerthat would have fixed the issue as well#2018-02-1819:36thhellerjust disable the closure processing of scroll#2018-02-1819:37hlolliIm glad I was able to fix it, but the cost of time chaseing these errors probably outweigh the benefit. Sounds reasonable to do this.#2018-02-1819:38thhellerexactly#2018-02-1819:55mhueberthmm, i’m setting up shadow-cljs in a new blank project and getting
shadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'
did some backtracking, and looks like this happens for every version 2.0.143 to present
#2018-02-1819:56thhellerjust fixed that#2018-02-1819:57mhuebertok#2018-02-1819:57mhuebertfor the next release?#2018-02-1819:58thhelleryeah building now#2018-02-1819:58mhuebert:+1::skin-tone-2:#2018-02-1820:00thhellerhmm build failed#2018-02-1820:00thhellerdunno why yet#2018-02-1820:08thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cfbca7aeaba0b8e2aca3a5bc8ffde1fee1fef6"}, :content ("[email protected]")} I hope#2018-02-1820:15mhueberthmm, getting#2018-02-1820:15mhuebert
npx shadow-cljs server
shadow-cljs - error $CLJS.Pg.resolve is not a function
#2018-02-1820:15thhellerdoh!#2018-02-1820:15thhellerthat was the error I fixed#2018-02-1820:15thhellerbut I didn't recompile#2018-02-1820:17thheller2.1.20 should work#2018-02-1822:26mhueberthmm,
mattpro:re-style MattPro$ npx shadow-cljs server
shadow-cljs - config: /Users/MattPro/Documents/sites2017/re-view/re-style/shadow-cljs.edn version: 2.1.20
shadow-cljs - error ENOENT: no such file or directory, open 'target/shadow-cljs/logging.properties'
#2018-02-1822:28wilkerlucioI'm still seeing that too#2018-02-1822:28thhellerdoes the path exist?#2018-02-1822:28wilkerlucio@mhuebert as a workaround, just mkdir -p target/shadow-cljs#2018-02-1822:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L618 that should take care of creating it?#2018-02-1822:30wilkerlucioweird...#2018-02-1822:30wilkerlucio@thheller I'm just starting trying to create the react native app, but got an error that I didn't see before:#2018-02-1822:30wilkerlucio
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
cannot find package.json for package react at /Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json
{:tag :shadow.build.npm/missing-package-json, :package-name "react", :package-json-file #object[java.io.File 0x55bcd296 "/Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json"]}
ExceptionInfo: cannot find package.json for package react at /Users/wilkerlucio/Development/personal/multi-timer/node_modules/react/package.json
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/find-package* (npm.clj:126)
	shadow.build.npm/find-package* (npm.clj:108)
	shadow.build.npm/find-package (npm.clj:137)
	shadow.build.npm/find-package (npm.clj:133)
	shadow.build.resolve/eval20329/fn--20332 (resolve.clj:210)
	clojure.lang.MultiFn.invoke (MultiFn.java:238)
#2018-02-1822:30wilkerlucioyou know what to do about this one?#2018-02-1822:31thheller/Users/wilkerlucio/Development/personal/multi-timer/node_modules/react does it exist?#2018-02-1822:32thhelleris it empty maybe? I think that happened to me before#2018-02-1822:32wilkerluciohumm. looks like it#2018-02-1822:32thhellerwhen in doubt rm -rf node_modules && npm install#2018-02-1822:32wilkerlucioI saw that before in another react native apps, there is something wrong with npm resolution#2018-02-1822:32wilkerlucioon the other project it works it used to work if you keep running npm install#2018-02-1822:33thhellerI'm no stranger to just resetting the folder and start from scratch#2018-02-1822:33thhelleralso I use mostly yarn these days which seems a bit more reliable#2018-02-1822:37mhuebert@wilkerlucio thanks, a workaround is less important than figuring out how to get this fixed so that I don’t have to add an extra instruction to all my READMEs 🙂#2018-02-1822:38wilkerlucioagreed, but sometimes we just need to get going 🙂#2018-02-1822:38thheller@mhuebert when you kill the server, rm -rf target/shadow-cljs and start the server again. does the target/shadow-cljs folder exist at least?#2018-02-1822:38thhellerits supposed to create that first and then write the logging.properties into that#2018-02-1822:38wilkerlucio@thheller just tried that here, it doesn't seem to be creating it#2018-02-1822:39thhellerwhat the heck#2018-02-1822:39mhueberthmm#2018-02-1822:39thhellertried it on windows and wsl linux#2018-02-1822:39thhellerwill try on mac#2018-02-1822:39wilkerlucioI'm on mac here#2018-02-1822:40mhuebertnpx shadow-cljs stop said that there was no server running, but then afterwards it worked#2018-02-1822:40mhuebertoh i see, the directory is actually created when I run npx shadow-cljs stop#2018-02-1822:41thhellerdo you use :lein or :deps?#2018-02-1822:41mhuebertbut npx shadow-cljs server does not create the directory#2018-02-1822:41mhuebert:deps#2018-02-1822:41mhueberttrying it for the first time#2018-02-1822:48thhellerif you just create the directory it works though?#2018-02-1822:48thhellernot the file, only the directory?#2018-02-1822:49thhelleroh no!#2018-02-1822:49thhellerI used mkdirp not mkdirp/sync ...#2018-02-1822:49thhellerthats probably it#2018-02-1822:50thhellerI didn't test with :deps#2018-02-1822:53thheller{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "40332821242f376d232c2a3300726e716e7271"}, :content ("[email protected]")} ...#2018-02-1823:03thhellerI'm done for the day. gn8.#2018-02-1823:13mhuebertg’night!#2018-02-1903:03eoliphanthi, I have an existing leiningen project that I’d like to convert to use shadow-cljs, I haven’t been able to find much in the way of complete examples online, and i’ve not quite figured it out from the docs, does anyone know of any more or less complete lein integration examples?#2018-02-1908:55thheller@eoliphant "lein integration" only means that the :source-paths and :dependencies are configured via lein. All build configs will still be in shadow-cljs.edn. So you only need to set :lein true in your shadow-cljs.edn. As far as builds they are identical whether or not you use lein.#2018-02-1908:56thhellereg. in this example https://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn you just set :lein true and move :dependencies and :source-paths to project.clj.#2018-02-1908:57thhellerI guess you must also add [thheller/shadow-cljs "2.1.21"] though#2018-02-1913:08eoliphantok @thheller thanks will check that out, so also, I take it I need to comment out my existing :cljsbuild keys in my project.clj?#2018-02-1913:09thhellernot required no#2018-02-1913:10thhelleryou should probably remove cljsbuild and figwheel from the plugins though. also not required but they will load a couple deps that shadow-cljs won't use#2018-02-1913:13thhelleryou might end up with a couple of conflicts. to be sort of safe include these deps first.#2018-02-1913:13thheller
[[org.clojure/clojure "1.9.0"]
 [org.clojure/clojurescript "1.9.946"]
 [thheller/shadow-cljs "2.1.21"]]
#2018-02-1913:14thhellercore.async is one common offender if you use an older version#2018-02-1913:14thhellerrunning standalone without lein won't have these conflicts so thats what I usually recommend#2018-02-1913:14eoliphantok will try that. Also, based on my reading, i need to pull out any cljsjs refs. I’m using reagent, etc. So would it just be a matter of adding exclusiions to the reagent dependencies, and pulling in the right react version, etc via npm?#2018-02-1913:15eoliphantyeah i saw the note that standalone is cleaner#2018-02-1913:15thhellerthats mostly taken care of already. you just need to manually npm install react react-dom create-react-class for reagent#2018-02-1913:15eoliphantright#2018-02-1913:16thhellergenerally if it tell you that is can't find a JS dependency you need to npm install it#2018-02-1913:16thhellersince we aren't using cljsjs but rather npm directly#2018-02-1913:16eoliphantbut i’d need to say exclude react from my reagent dependency, to keep it from getting pulled in that way?#2018-02-1913:16thhelleryou can but you don't have to. it won't be used either way.#2018-02-1913:17eoliphantah#2018-02-1913:17eoliphantok#2018-02-1913:17eoliphantoh right#2018-02-1913:17eoliphantbecause in this case i’m not running the cljsbuild#2018-02-1913:17eoliphantok thanks for your help will give this a whirl#2018-02-1913:19hlolli@eoliphant What I'm doing now, is to do all the server side clj stuff with lein, and serve the js-poutput directory with html, and when shadow-cljs is being run with watch, the hot reload works auto*magic*ally#2018-02-1913:19thhellerfeel free to ask questions. helps me write a "migrating from cljsbuild" chapter for the docs 😉#2018-02-1913:21eoliphantthat would be great, i was thinking about figuring out how to add this config as a luminus profile at some point#2018-02-1915:21martinklepschDoes shadow-cljs provide a way to load :none builds in Nashorn?#2018-02-1915:52thheller@martinklepsch I haven't done any serious nashorn work so no it doesn't.#2018-02-1915:53thhellermy conclusion so far has been that if you want to run clojurescript in nashorn you should just use clojure instead 😛#2018-02-1916:00thhellerwhat is your use-case? I'm curious what all the nashorn hype is about.#2018-02-1916:07martinklepschAgree that just running Clojure is probably preferable, was just evaluating options for server side rendering#2018-02-2001:22wilkerlucio@thheller hello, about the RN integration, would you have an idea why it only works if I compile to the node_modules/shadow-cljs directory? when I try compiling on anything else (still inside node_modules) it fails and dont run#2018-02-2002:42wilkerlucio@thheller not sure if you saw that, but it seems that shadow stops working if you delete some file that it did compiled before#2018-02-2002:42wilkerlucioit's happening to me compiling npm-modules (for react native)#2018-02-2002:42wilkerluciowhen I delete a file it's starting throwing errors#2018-02-2008:24thheller@wilkerlucio I ship a default .babelrc for shadow-cljs which tells babel to not do any processing#2018-02-2008:24thhellerhttps://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/.babelrc#2018-02-2008:25thhellerif you have use a custom dir that file won't exist so that might be the reason?#2018-02-2008:28thhellerIIRC I added that file for RN, might have been CRA though#2018-02-2012:31hlolli@wilkerlucio I believe I had that too yesterday. I dad yarn remove on a package. All I had to do was to restart shadow-cljs.#2018-02-2012:33thhellerthere seems to be an issue with deleting files. the watch doesn't seem to detect it.#2018-02-2012:33thhelleralso somehow adding new directories doesn't seem to register on windows#2018-02-2012:33thhellerI'm pretty sure that used to work on mac#2018-02-2013:07wilkerlucio@hlolli yes, restarting fix it#2018-02-2014:23martinklepschPlaying around with using shadow-cljs in a bigger, existing project and getting this:
The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs".
#2018-02-2014:26mynomoto@martinklepsch I think you need to install using npm install react react-dom create-react-class. Shadow doesn't use the included js from cljsjs.#2018-02-2014:27mitchelkuijpers@martinklepsch https://shadow-cljs.github.io/docs/UsersGuide.html#_migrating_cljsjs#2018-02-2014:28martinklepschGot it. Wasn’t aware foreign-libs aren’t supported at all. Will need to see if that’s an issue.#2018-02-2014:30thheller@martinklepsch since you can just use JS directly now there shouldn't be any need to use foreign-libs ever#2018-02-2014:31thhellerdoes anyone have a suggestion how to improve the > The required JS dependency "react" is not available, it was required by "cljsjs/react.cljs". error message?#2018-02-2015:54justinleeYou could just add “Install it using npm or yarn.” when I switched over to this project I couldn’t believe it was so easy after being burned by bizarre and unhelpful error messages coming from :npm-deps. 🙂#2018-02-2014:32thhellerI don't know what to write that would it more obvious about what you are supposed to do#2018-02-2014:33martinklepsch@thheller Insert a short link that points to the appropriate docs?#2018-02-2014:36thhellerthats a good start yes#2018-02-2014:39martinklepschIs there a workaround for the case that I depend on a library which has something like this: https://github.com/funcool/cuerdas/blob/master/src/cuerdas/regexp.cljc#L33 ?#2018-02-2014:39thhelleryep. just npm install xregexp#2018-02-2014:39thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cuerdas/vendor/xregexp.cljs#2018-02-2014:40thhellerthe shadow-cljsjs lib maps the foreign-libs back to their original npm packages and uses those directly#2018-02-2014:41thhellersince basically all cljsjs pacakges are just repackaged versions of the npm thing#2018-02-2014:42thhelleryou can just create them in your project in case they are not available in shadow-cljsjs yet#2018-02-2014:42martinklepschInteresting, got it#2018-02-2014:50martinklepschOk, next issue: 😄 (I’m on cljs 1.9.946)
646 |       #?(:cljs NaN :clj Double/NaN))))
----------------------^---------------------------------------------------------
 Use of undeclared Var cuerdas.core/NaN
#2018-02-2014:51thhellerold cuerdas version? https://github.com/funcool/cuerdas/blob/master/src/cuerdas/core.cljc#L646#2018-02-2014:51thhellershould be js/NaN?#2018-02-2014:52thhellerhttps://github.com/funcool/cuerdas/commit/fc9ec9241c6a0098a015d7de1331d2058aacd971#2018-02-2014:56martinklepschThat’s probably it. Guess I could have seen that myself 🙈#2018-02-2014:56thhellerhehe. those warnings easily get lost in other CLJS tools since it will only warn once when caching is enabled.#2018-02-2014:57thhellershadow-cljs doesn't cache files with warnings so you'll always see them#2018-02-2014:57martinklepschI’m always under the impression that Figwheel doesn’t print any warnings/errors to the console 😏#2018-02-2015:56justinleeand actually it might be worth the reminder for new people since npm-deps ostensibly installs the packages for you#2018-02-2015:56thhellerupdated https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install#2018-02-2015:57thhellerwill add a link to the msg later#2018-02-2017:16eoliphantHi i’m trying to get my lein project (gen’ed by luminus) converted to shadow here’s my lein dev config, not sure which other options need to be moved over. Also, trying to figure out how to map my dev,test, uberjar profiles over appropriately
:cljsbuild
                  {:builds
                   {:app
                    {:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
                     :figwheel {:on-jsload "fema-gmm.core/mount-components"}
                     :compiler
                     {:main "fema-gmm.app"
                      :asset-path "/js/out"
                      :output-to "target/cljsbuild/public/js/app.js"
                      :output-dir "target/cljsbuild/public/js/out"
                      :source-map true
                      :optimizations :none
                      :pretty-print true
                      ;:install-deps true
                      ;:npm-deps {:aws-amplify "0.2.6"
                      ;           :left-pad "1.1.3"}
                      :preloads [re-frisk.preload]}}}}
and what I have so far in my config file
;; shadow-cljs configuration
{:lein true
 ;:source-paths
 ;["src"]
 ;
 ;:dependencies
 ;[]

 :builds
 {:app {:target :browser
        :output-dir "target/cljsbuild/public/js"
        :asset-path "/js/out"
        :modules {:main {:entries [fema-gmm.app]}}}}}
#2018-02-2017:21thheller
{:lein true
 :builds
 {:app {:target :browser
        :output-dir "target/cljsbuild/public/js"
        :asset-path "/js"
        :modules {:main {:entries [fema-gmm.app]}}
        :devtools {:after-load fema-gmm.core/mount-components
                   :preloads [re-frisk.preload]}}}}
#2018-02-2017:22thhellernpm install aws-amplify#2018-02-2017:23thhellershadow-cljs itself does not have profiles since builds already cover that#2018-02-2017:24eoliphantah right#2018-02-2017:24eoliphantok#2018-02-2017:24eoliphantthat makes sense#2018-02-2017:24thhellerhow do I use the luminus tempalte? just lein new luminus foo?#2018-02-2017:24eoliphantyep#2018-02-2017:24eoliphantand the profile#2018-02-2017:24eoliphantfor cljs#2018-02-2017:25eoliphantlike lein new luminus foo +reagent or +re-frame ,etc#2018-02-2017:34thhelleryuck so many things I hate about that template#2018-02-2017:35eoliphantlol yeah, it was my onramp into clojure back in the day so have just kind of stuck with it, never got much into lein hacking as it generally just worked#2018-02-2017:36eoliphantFYI, the lein section in the docs doesn’t appear to mention adding the [thheller/shadow-cljs "2.1.21"] dependency#2018-02-2017:36thhelleroh right. thx.#2018-02-2017:42thhellerdo you have any particular reason why you want to run cljs from inside lein?#2018-02-2017:43thhelleror is it just "because"?#2018-02-2017:43eoliphantllol#2018-02-2017:43eoliphantso far#2018-02-2017:43eoliphantit’s just because#2018-02-2017:43eoliphantas i think aobut it#2018-02-2017:43eoliphantnot really necessary#2018-02-2017:43thhellerthats one of the most complex project.clj I have seen. scary that the template generates this mess.#2018-02-2017:44eoliphantsince i’m doing a lein run#2018-02-2017:44eoliphantand a lein figwheel#2018-02-2017:44eoliphantpresumably#2018-02-2017:44eoliphantthe shadow-cljs watch or whatever#2018-02-2017:44eoliphantwould be the equivalent#2018-02-2017:44eoliphantof lein figwheel?#2018-02-2017:44thhellerpretty much yes#2018-02-2017:45eoliphanti’d kind of thought that, the project.clj was nutty, I’ve spent a lot of my life lol, becoming proficient at maven, gradle,sbt, etc#2018-02-2017:45eoliphanthadn’t really dug into lein, but now I’m thinking I might lol#2018-02-2017:47eoliphantis the :after-load fema-gmm.core/mount-components setting up figwheel?#2018-02-2017:47thhellerwe don't use figwheel#2018-02-2017:48thhellerbut it does the equivalent of figwheel yes#2018-02-2017:48eoliphantah gotcha#2018-02-2017:50eoliphantso for my dev workflow#2018-02-2017:50eoliphanti’d conceivably just run shadow-cljs#2018-02-2017:51eoliphantbut for my builds, etc would run via lein I’m thinking#2018-02-2017:51thhellerlein for the server stuff#2018-02-2017:51thhellershadow-cljs for cljs#2018-02-2017:52thhellerI'm still trying to trim the generated config#2018-02-2017:52eoliphantright, at the moment, my app bundles the cljs and the lightweight server into the uberjar#2018-02-2017:52thhellerstill haven't figured out what it does 😛#2018-02-2017:52eoliphantlol#2018-02-2017:52eoliphantyeah there’s a ton of stuff in there lol#2018-02-2018:02thhellerdo you use the server stuff or do you just want cljs?#2018-02-2018:05eoliphantyeah I use the server stuff as well#2018-02-2018:05eoliphantrunning the build#2018-02-2018:06eoliphantgot some stactraces, etc. Pretty long would you like to see it here#2018-02-2018:06thhellersure#2018-02-2018:07thhellerprobably deps conflicts#2018-02-2018:07eoliphantwasn’t happy about parsing some of the files, etc#2018-02-2018:09thhellerthose are just warnings so not critical. no idea why you get those though#2018-02-2018:09eoliphantok#2018-02-2018:10eoliphantbut it complains at the end about the namepsace#2018-02-2018:10thhellerwell if you import it anywhere thats a problem yes#2018-02-2018:10thhellerbut we don't need it so don't import it#2018-02-2018:13thhellerhmm hehe#2018-02-2018:14thhellerhttps://github.com/bhauman/lein-figwheel/blob/master/support/src/figwheel/client/utils.cljs#L8#2018-02-2018:14thhellerdoesn't like that since it is not a valid op#2018-02-2018:15thhellerguess my parser is too strict#2018-02-2018:33thheller@eoliphant do you use the REPL to interact with figwheel?#2018-02-2018:46eoliphantyes I do ffrom time to time#2018-02-2018:46eoliphantactually that namespace thing is weird#2018-02-2018:47eoliphantthe project.clj config mentions it#2018-02-2018:47eoliphantbut it doens’t actualyl exist#2018-02-2018:47eoliphant.core is the entry point for the app#2018-02-2018:53thhellerphew that was quite a bit of work 😛#2018-02-2019:01thheller@eoliphant this is a rough rewrite of the template output https://github.com/thheller/lumifoo#2018-02-2019:04thhellerinstead of lein run I'd recommend lein repl (user/start)#2018-02-2019:05thhellerstarts the server and also the shadow-cljs app build#2018-02-2019:05thhellerI didn't do any of the test stuff#2018-02-2020:27eoliphantah ok lol, will check it out#2018-02-2101:49maridonkershttps://github.com/chooie/test-driven-clj-cljs#2018-02-2117:57thheller@denik semantic-ui-react adds 726 files to the compilation. that takes a while. shouldn't be a problem on the second compile once caching kicks in.#2018-02-2117:59thhelleryou can shadow-cljs compile app --verbose to get a bit more timing related output#2018-02-2117:59thheller
-> Shadow JS converting 729 JS sources
<- Shadow JS converting 729 JS sources (3688 ms)
-> Shadow JS Cache write: 729 JS files
<- Shadow JS Cache write: 729 JS files (5814 ms)
#2018-02-2118:02thheller:verbose true in the config also works#2018-02-2118:03denik@thheller running it with the verbose flag, cache doesn’t seem to kick in and it prints
-> Flushing 1023 sources
<- Flushing 1023 sources (108 ms)
-> Flushing unoptimized modules
<- Flushing unoptimized modules (95 ms)
#2018-02-2118:04denikbtw I’m on version "2.1.10"#2018-02-2118:04thhellerah that version doesn't have the verbose log for JS yet#2018-02-2118:05thhelleror it was names differently#2018-02-2118:05thhellershould be up top, something about convert#2018-02-2118:07thhellerthe Flushing ... is just writing the final JS to disk, not the actual compilation parts#2018-02-2118:07thheller[:browser] Build completed. (822 files, 728 compiled, 0 warnings, 18.15s)#2018-02-2118:07thheller[:browser] Build completed. (822 files, 0 compiled, 0 warnings, 1.06s)#2018-02-2118:08thhellerwithout/with cache with just semantic-ui#2018-02-2118:08thheller<- Flushing 822 sources (6966 ms)#2018-02-2118:08thhellerthats why caching is so important for these files 😛#2018-02-2120:18lilactownso, I’m trying to use a similar workflow to the way I work in CLJ, where I send forms from my editor to the REPL, and I’m not having much success#2018-02-2120:19lilactowneven if I ns into the namespace i’m working in at the REPL, none of the vars exist unless I manually evaluate the defs at the REPL#2018-02-2120:19lilactownevaluating forms that rely on just stuff in clojure.core works fine, though#2018-02-2120:21justinlee@lilactown I can’t seem to get a reliable functional repl session working either, though to be fair I couldn’t get it working with the lein/ figwheel / piggieback rube goldberg contraption using the normal cljs compiler either#2018-02-2120:21lilactownand I can refer to them by their fully qualified ns e.g. my.foo.bar/baz#2018-02-2120:22lilactownyeah, I have a feeling this is an issue with most cljs repls - I seem to recall similar issues with figwheel. was just wondering if someone had found a way to be productive#2018-02-2120:25justinleeoh yea that’s interesting--using a fully qualified namespace does work#2018-02-2120:25justinleebasically i gave up and I just rely on auto-reloading code and print statements to the console#2018-02-2120:32thhellerwhat exactly are you doing?#2018-02-2120:33lilactownI’m trying to try things out at the REPL as I’m developing#2018-02-2120:33thhellerbe precise .. otherwise I cannot reproduce#2018-02-2120:35lilactownI’m working on a Node.js app that serves a webpage. So e.g. I might have my-project.pages.sign-in that has some logic, makes some requests, etc.#2018-02-2120:35lilactownI’d like to be able to evaluate forms within that namespace at the REPL. e.g. if I have (def foo "bar") inside of my-project.pages.sign-in, I’d like to evaluate foo at the REPL and see “bar” printed out#2018-02-2120:37lilactownatm, I have to use the fully qualified namespace my-project.pages.sign-in/foo, even if I do (ns my-project.pages.sign-in) in the REPL first#2018-02-2120:37thhellerI just need what you send to the repl#2018-02-2120:37lilactownevaluating without the fully qualified namespace results in printing “nil” unless I also evaluate the def#2018-02-2120:38thheller
(shadow.cljs.devtools.api/nrepl-select :script)
To quit, type: :cljs/quit
=> [:selected :script]
(in-ns 'demo.script)
=> demo.script
(def foo "bar")
=> #'demo.script/foo
foo
=> "bar"
#2018-02-2120:39thheller
(in-ns 'cljs.user)
=> cljs.user
(ns demo.script)
=> demo.script
foo
=> "bar"
#2018-02-2120:42thhellerif you ns into a namespace that is not yet loaded#2018-02-2120:42thhellerit will not load that namespace, it will just create an empty one#2018-02-2120:42thhelleryou must (require 'that.ns) first to load it#2018-02-2120:42lilactownokay, hmm… I’m having trouble reproducing it 😅#2018-02-2120:43lilactownthe only thing that’s not working once I ns into the namespace are things that are (:require)’d in the ns declaration#2018-02-2120:43thhellerare you sure that the ns is loaded?#2018-02-2120:44thhellerswitching namespace you are supposed to do via in-ns not ns#2018-02-2120:44thhellerie. if you don't have a namespace loaded and (ns that.foo) it will be empty, no defs no requires nothing#2018-02-2120:45lilactownrestarting everything to try it with in-ns#2018-02-2120:45thhellerdo require first#2018-02-2120:45thhellerin-ns also only switches and does not load#2018-02-2120:45thhellerthats identical behavior to clojure though#2018-02-2120:47lilactownI think I’m getting a bit mixed up since in my clj project it defaults to the ns my -main function is in and I often evaluate the whole file#2018-02-2120:48thhellerthe CLJS workflow should pretty much work exactly like CLJ#2018-02-2120:48thhellerfew subtle differences due to async stuff but for the most part it should work#2018-02-2120:50lilactownthe sign-in ns looks like:
(ns cambia.web.experience.dashboard.pages.sign-in
  (:require [cambia.web.ui.components.page-header :as page-header]
            [cambia.web.experience.dashboard.components.page-setup :as page-setup]
            [cambia.web.experience.dashboard.components.login :refer [login]]))
;; ...

(defn foobar [] "baz")
#2018-02-2120:51lilactownI expect that this is related to my newbness with clojure 😅#2018-02-2120:52thhellerpage-header is an alias, you can't use that directly#2018-02-2120:52thhellerpage-header/foo or whatever is in that ns#2018-02-2120:53thhelleralso upgrade to fix the display-as-string-issue#2018-02-2120:54thheller:as is only direclty usable for JS namespaces. not allowed for CLJ(S).#2018-02-2120:56lilactownfacepalmdoh! OK, thanks.#2018-02-2120:56lilactownyeah I also realized that I’m on a really out of date shadow-cljs version, per your reply to my github issue 😛#2018-02-2120:56thhelleryeah lots of fixes since then 🙂#2018-02-2121:30justinleewhat i was trying was just trying to run a function from one of my files via proto-repl. i’ve seen video where people have (defn my-func [] ...) and then send forms that invoke it (my-func). I seem to need to run the definition manually before being able to use it. But @lilactown pointed out that it is actually loaded already but you have to use the fully qualified namespace#2018-02-2121:31lilactown@lee.justin.m try switching to the ns that you’re trying to evaluate it in#2018-02-2121:31justinleeit times out for me using atom + protorepl#2018-02-2121:32lilactown
(require 'my-project.core)
(in-ns 'my-project.core)
(my-func)
#2018-02-2121:32thhellerI can't comment on anything proto-repl. need to know what gets sent to the repl.#2018-02-2121:32justinleeis there a way to spy on the nrepl?
#2018-02-2121:34lilactownI’m using Emacs & CIDER. I notice that if I try and send those forms from a file to the REPL, they don’t work. but if I enter them into the REPL directly, they work#2018-02-2121:34thhellerproto-repl side I don't know. for shadow-cljs you can turn on debug logging#2018-02-2121:34justinleeoh interesting: this is showing up in the watch terminal [2018-02-21 12:29:33 - WARNING] client sent unknown msg {:type :repl/set-ns-complete, :id 0, :ns seekeasy.util}#2018-02-2121:34thheller@lee.justin.m also old version?#2018-02-2121:35thhellerthat was fixed recently#2018-02-2121:38justinleeurg. i’ve been updating shadow-cljs globally but apparently it was pegged in my package.json#2018-02-2121:39justinleeso I think i was on an old version. confusing because I apparently imagined that i was getting bug fixes from you last week.#2018-02-2121:42thhelleryeah project version is the one that counts#2018-02-2121:42justinleeso does the shadow-cljs binary delegate to the locally installed version?#2018-02-2121:42thhelleryep#2018-02-2121:43justinleeahhhh that explains it. i was testing your changes in a different test repo last week. i forgot that, which is why things seemed to go backwards#2018-02-2121:45justinleeso things work if i manually switch namespaces using (in-ns). it would seem like protorepl should do that for me, but this does make it usable#2018-02-2121:46thhellerit might have a keybinding for that? cursive does.#2018-02-2121:46justinleeI do a cmd-alt-b to send a form over to the repl. you’d think given that it knows what namespace i’m in when i do that, it would do a (in-ns) first#2018-02-2121:47thhellerno idea what proto-repl does. maybe there is an option for that?#2018-02-2122:17justinleeit looks like it wraps the form in an eval and sends it in an object like this {op: "eval", code: wrappedCode, ns: ns, session: session}. I need to figure out a way to dump the actual serialized bytes being sent over the socket to tell more, but the code should be sending the namespace of the current file from which you send the form#2018-02-2123:37richiardiandreahello folks, is shadow-cljs using its own internal way to resolve the classpath? If so I have a feature request if possible 😄#2018-02-2123:41justinleeit manages dependencies if that’s what you mean. what’s the request (i’m just curious)#2018-02-2200:12thheller@richiardiandrea what do you have in mind?#2018-02-2200:12thhelleryes it has its own internal resolve mechanisms#2018-02-2200:12richiardiandrea@thheller I wanted to ask if shadow could output the classpath so that I can use lumo 🙂#2018-02-2200:18thhellerso how this works internally is that shadow-cljs itself depends on shadow-cljs-jar#2018-02-2200:18thhellerwhich is a standalone uberjar thats just used for resolving maven dependencies#2018-02-2200:18thhellerhttps://github.com/thheller/shadow-cljs/tree/master/packages/shadow-cljs-jar#2018-02-2200:19thhellerhttps://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj#2018-02-2200:19thhellernot much code at all#2018-02-2200:19thhellerbasically reads a edn {:dependencies [[foo/bar "1.2.3"]]} map from stdin#2018-02-2200:20thhellerdownloads the deps#2018-02-2200:20richiardiandreauhm interesting#2018-02-2200:20thhellerwrite everything to :cache-root/classpath.edn#2018-02-2200:20thhellerexit with 0 on success#2018-02-2200:20richiardiandreacoool so I can use :cache-root/classpath.edn I guess#2018-02-2200:21richiardiandreaoh no yeah#2018-02-2200:21thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L144-L168#2018-02-2200:21richiardiandreait is in edn format, I need to convert it#2018-02-2200:21richiardiandreaand it does not include only the build deps but also shadow deps#2018-02-2200:22thhellerwell you could create something like lumo deps#2018-02-2200:22thhellerto build the classpath and such#2018-02-2200:22thhellerwell you could just use tools.deps which I would recommend at this point to be honest#2018-02-2200:22richiardiandreayep I could, but I have already project.clj in place and I can just use lein...or use tools.deps#2018-02-2200:23richiardiandreayeah exactly#2018-02-2200:23thhellerclojure already has clojure -Spath which is what I assume you are asking for?#2018-02-2200:23richiardiandreayep that's what I am using#2018-02-2200:25thhellerso what do you need shadow-cljs for?#2018-02-2200:25richiardiandreawell, I was just wondering 😄#2018-02-2200:27thhellersince I expect deps.edn to become standard pretty soon I'd suggest sticking with that#2018-02-2200:28richiardiandreait's just that it requires to use an additional tool on ci...while shadow can be provisioned through npm install but yeah...you are probably right...#2018-02-2200:29thhellerbut when using shadow-cljs you'd need a shadow-cljs.edn config#2018-02-2200:29thhellersince the script itself only reads from that#2018-02-2200:30richiardiandreayep I am ok with that, but then the classpath has to be generated with other tooling#2018-02-2200:30richiardiandreano worries Thomas, just grumbling at the some many tools to provision on CI 😄#2018-02-2200:35thhellerwell you could roll your own with the shadow-cljs-jar thingo#2018-02-2200:35richiardiandreaI could definitely do that#2018-02-2200:37richiardiandreaI like that you can export functions for :node-library, you could even add JSDoc 😄 😄 😄#2018-02-2200:38richiardiandreawill see if I can PR something sooner or later but shadow-cljs has improved a lot since the last time I checked!#2018-02-2200:46richiardiandrea@thheller you are awesome thanks for the fix!#2018-02-2200:55richiardiandrealast question, is there a way to use ClojureScript libraries deployed through the npm mechanism at the moment?#2018-02-2200:55thhellerno#2018-02-2200:58richiardiandreaand is there a way to add things to the shadow-cljs tool classpath by any chance? my deps are not deployed on Maven as we prefer npm in my company at the moment...#2018-02-2200:59richiardiandreaoh I see I can get creative with deps.edn, I will try that#2018-02-2200:59thhellershadow-cljs can't since it loads itself via maven#2018-02-2201:01richiardiandreaI am in a monorepo so I can have a deps.edn file that contains {:paths ["src" "../spec-cljs/src"]}#2018-02-2201:02richiardiandreaand it will end up in shadow's classpath#2018-02-2201:02richiardiandreathat is what I mean by "being creative" 😄#2018-02-2201:10richiardiandrealol other question#2018-02-2201:10richiardiandreawhen I build, I see in my dist a folder called cljs-runtime#2018-02-2201:11richiardiandreado I need to deploy both? how do I get a unique artifact?#2018-02-2201:16thhellerthat only happens when you set :output-dir#2018-02-2201:16thhelleryou can set :release {:output-to "some-other/path.js"} to only change the path for release#2018-02-2201:19thhellerif you only set :output-to you will only get that file. :output-dir during development uses an absolute path in the target/shadow-cljs directory so the cljs-runtime folder doesn't show up in the dist dir 😛#2018-02-2215:00bolasblackHi @thheller , I found (println "hello") will print hello in the screen I executed shadow-cljs node-repl, Is it possible to print the message in cider? (https://github.com/thheller/shadow-cljs/issues/207#issuecomment-367699962)#2018-02-2215:13thhellerLike I said it is not currently possible.#2018-02-2215:13thhellerI need to do some work around the node-repl with regards to nrepl#2018-02-2215:14thhellerand then there are two ways the output could get there. either pipe all stdout of the managed node process to the REPL#2018-02-2215:14bolasblackSorry, I've misunderstood you before. I thought you meant to let me open a new issue to discuss this issue 😂#2018-02-2215:15thhelleryes thats what I meant.#2018-02-2215:15thhellerdiscussing it here just gets lost so a ticket is better#2018-02-2215:19bolasblackok, I will open a new issue later 😛#2018-02-2220:36donmullenI’m getting IllegalStateException: Can't change/establish root binding of: *cljs-warnings* with set when using the [binaryage/oops] library (https://github.com/binaryage/cljs-oops) within a shadow-clj repl. Any ideas?#2018-02-2220:40thhellerhmm never noticed that its messing with compiler bindings from a macro#2018-02-2220:45donmullenYeah - I pulled the library in when goog.object/set did not seem to be working to set properties of a javascript object. I believe something else is going on. My javascript interop chops are weak.#2018-02-2220:46thhellerthat error in particular is a bug in shadow-cljs though. or rather was. fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "fd8e959c99928ad09e91978ebdcfd3ccd3cfc9"}, :content ("[email protected]")}#2018-02-2220:47donmullenExcellent - thanks @thheller!#2018-02-2221:05wilkerlucio@thheller do you have any idea how hard would be to enable REPL in React Native apps? how is it currently implemented for web, websockets? having live-reload/REPL on RN would be awesome#2018-02-2221:07thhellerit might work if you import "shadow-cljs/shadow.cljs.devtools.client.browser"#2018-02-2221:08thhelleror wherever your :output-dir is#2018-02-2221:08thhellerideally there would be a :target :react-native but I haven't done any serious RN development#2018-02-2221:09thhellerlast time I tested there wasn't any way to turn of their live reloading#2018-02-2221:10thhellerI didn't go past the "hello world" experience#2018-02-2221:14mathpunkI'm making a toy application, and to my surprise & delight I've got a user to support. My goal is for her to be able to run my server.js in node. I changed my project to use shadow-cljs, and it seems to be achieving my goal. However, I'm not sure what's going on with my tests.#2018-02-2221:15mathpunkI successfully compiled a test file, and ran it in node. But, my specs were not found.#2018-02-2221:15thhellerwhich config did you use?#2018-02-2221:15mathpunkI'll post it, one sec#2018-02-2221:16mathpunkand, shadow compile test followed by a node invocation on what was generated#2018-02-2221:16thhelleryou said "specs"? are you using cljs.test?#2018-02-2221:17mathpunkyes#2018-02-2221:17thhellerare the namespaces named sherman.server-test?#2018-02-2221:17mathpunkI doubt I have things set up 'correctly'.... I was developing by having a lein auto tach lumo process running, and I have a (cljs.test/run-tests) line at the end of each of my test files#2018-02-2221:18thhellerdefinitely don't need the run-tests#2018-02-2221:18thhelleryou can put a (prn :foo) or so to confirm that they are getting loaded#2018-02-2221:19thhellershadow compile test --verbose should also show them getting compiled#2018-02-2221:19thhellerwhat is your test namespace?#2018-02-2221:20mathpunkThis might be easiest, altho it is a push from before I was trying shadow: https://github.com/mathpunk/sherman#2018-02-2221:21mathpunkThe only thing that's changed since has been shadow-cljs.edn, and I've just commented out the cljs.test/run-tests#2018-02-2221:21mathpunklet's see what verbose compiling does...#2018-02-2221:21thhellerlooks fine#2018-02-2221:23mathpunkand... it is fine. I have no idea what that previous output was#2018-02-2221:24mathpunkok, second question: is there a method for having tests run when I change code? I used to use CIDER as my test runner for Clojure, which I don't think is going to work easily in CLJS. On this project I had been running a lein auto tach lumo task in a separate window, but I'm not sure if there's a way of doing something similar in shadow yet#2018-02-2221:25thhellerfor node not yet#2018-02-2221:25mathpunki guess third question is, should I remove my project.clj entirely? everything's being done by shadow now?#2018-02-2221:25mathpunkok#2018-02-2221:25thhelleryou can use something like chokidar-cli#2018-02-2221:26mathpunkoh ok, so that will watch to see if the output test file changes... great#2018-02-2221:26thhellerchokidar out/node-test.js -c 'node out/node-test.js'#2018-02-2221:26thhellernpm install -g chokidar-cli https://github.com/kimmobrunfeldt/chokidar-cli#2018-02-2221:26mathpunk👍#2018-02-2221:27mathpunkthanks so much! sorry about the first non-question, no clue what that was about#2018-02-2221:27thhellernp#2018-02-2221:37wilkerluciothanks, I'll try that out, it is possible now to disable their auto-reload#2018-02-2221:37wilkerlucioso we can do that and rely on the shadow one if that works 🙂#2018-02-2221:48wilkerlucio@thheller doens't work =/ the only thing I see is this message on the android console: I/ReactNativeJS: '%cDEVTOOLS: disconnected!', 'color: blue;#2018-02-2221:48wilkerluciocode doesn't reload, and the REPL doesn't respond as well#2018-02-2221:48wilkerlucio
To quit, type: :cljs/quit
=> [:selected :app]
3
There is no connected JS runtime.
#2018-02-2221:51thhellerno idea. I only ever opened the iOS emulater once#2018-02-2221:52thhellerwon't have time to play with react-native for a while#2018-02-2221:54thhellerif figwheel works then it is possible for shadow-cljs as well. just might take some tweaks.#2018-02-2221:59wilkerluciosure, I can try to look at it, thanks for the tips#2018-02-2222:02justinleehey @thheller if i wanted to hack around a bit with the nrepl connection, what’s the best way to experiment with shadow-cljs when building from source?#2018-02-2222:03thhellerI run lein with-profiles +cljs repl then (require 'repl) (repl/go)#2018-02-2222:04thheller(shadow.cljs.devtools.api/watch :browser) is the test build I commonly use#2018-02-2222:05thhellerwhat do you want to do?#2018-02-2222:10justinleeI want to debug the protorepl connection to see if I can make it do all the cool shit it is capable of, but I don’t want to bug you every single day 🙂#2018-02-2222:11wilkerlucio@thheller I see that the browser versions tries to use <script> tags to load things, that wont work on RN, I'm wondering if its easier to start from the node version, I tried that directly but seems like RN doesn't have teh crypto package, but in terms of load seems the node version is closer#2018-02-2222:11thhellerlast time I checked proto-repl didn't use any nrepl-middleware but rather just evals CLJ code straight up.#2018-02-2222:11thhellerso that won't work for CLJS#2018-02-2222:11justinleeIn theory, I should be able to get function arguments to pop up as I type, get autocompletion to work, be able to jump to source, be able to get docstrings inline.#2018-02-2222:11thheller@wilkerlucio if you use :npm-module it won't use <script>#2018-02-2222:11justinleeIt can connect via an nrepl connection. That’s how I use it.#2018-02-2222:12thheller@lee.justin.m like I said. they do this by evaling clojure code. I think.#2018-02-2222:12wilkerluciohumm, good to know, I'll keep reading 🙂#2018-02-2222:12justinleeMy suspicious is that it just doesn’t even try to do the stuff that it does with the clj repl, but I really want it to. 🙂#2018-02-2222:13thhelleryou'll probably need to hack that on the proto-repl side#2018-02-2222:13thhellerstill can't get past the blasphemy that proto-repl is written in coffeescript 😛#2018-02-2222:14justinleecoffeescript is a nice language. too bad I don’t know it.#2018-02-2222:14thhellernah its horrible. did it for 2 years before CLJS. never want to do it again#2018-02-2222:15justinleewell okay i’ll futz around with the coffeescript side. partly i wanted to get some insight as to what the hell is going on with all these different repl techniques#2018-02-2222:15justinleeit confuses the hell out of me that you can start a clj repl and then switch into a cljs-repl (like with figwheel). but then you can also connect to the same thing via a network#2018-02-2222:16thhellerusually with nrepl most of the heavy listing is done by middleware. ie. cider-nrepl.#2018-02-2222:16thhellerbut proto repl just straight up evals CLJ code#2018-02-2222:16justinleeso when you say “they do this by evaling clojure code” I don’t really know what you mean because, you know, isn’t that the “e” part of the repl?#2018-02-2222:17thhelleryes and no#2018-02-2222:17thhellernrepl has two ways of doing stuff#2018-02-2222:17thhellereval is usually just for what the user types#2018-02-2222:17thhellerand middleware handles tool related stuff#2018-02-2222:18thhellereg. https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/complete.clj#2018-02-2222:18thhellerthe middleware takes care of completion for clj and cljs#2018-02-2222:18thhellerbut proto-repl just sends full forms to eval#2018-02-2222:19thhellerhttps://github.com/jasongilman/proto-repl/blob/master/lib/proto-repl.coffee#L648-L656#2018-02-2222:22justinleeso, somehow in my many iterations before i landed on shadow, I was able to start protorepl and get a full feature set.#2018-02-2222:23justinleeI think I did that by lein watch or whatever the command was and then (do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))#2018-02-2222:23thhellerfor CLJS?#2018-02-2222:23justinleebut maybe that was when i was doing CLJ (sorry I just can’t remember)#2018-02-2222:23thhellerCLJ sure#2018-02-2222:23justinleeoh ok#2018-02-2222:23thhellerCLJ should work just fine now#2018-02-2222:25justinleeI really want to be able to make protorepl fully featured with cljs but I don’t even understand the problem. maybe after i’ve got a little more experience#2018-02-2222:25thhellerfrom briefly going over the proto-repl sources that will be a gigantic effort#2018-02-2222:25thhellerit just isn't built with CLJS in mind at all#2018-02-2222:26justinleeis the issue that the nrepl channel is different from whatever its doing when you just fire up a normal repl?#2018-02-2222:26thhellerno. the issue is what proto-repl is doing with the REPL.#2018-02-2222:27thhellerthere seems to be a gigantic discussion about this https://github.com/jasongilman/proto-repl/issues/54#2018-02-2222:29justinleeyea i’ve read through that. i wanted to push it forward. maybe it isn’t possible.#2018-02-2222:30thhellerit is definitely possible#2018-02-2222:31thhellerbut if you take a look at the completion code now#2018-02-2222:31thhellerhttps://github.com/jasongilman/proto-repl/blob/master/lib/completion-provider.coffee#L35-L45#2018-02-2222:31thhellerit evals this code in the REPL. which you can also do by hand.#2018-02-2222:31thhellerthis is clojure code that only gives you completions for clojure code.#2018-02-2222:31thhelleryou'd need to send entirely different code for CLJS#2018-02-2222:31justinleeit’s painful to think that all the juicy juicy data is sitting right there in the shadow watch process and all someone needs to do is just marshall a couple of dumb op codes back and forth to get it#2018-02-2222:32thhellerwell cider-nrepl already has access to all the data I believe#2018-02-2222:33thhellerproto-repl eval works because you just send stuff and it handles the result#2018-02-2222:33thhellerthat is simple#2018-02-2222:33thhellerand works the same in both languages#2018-02-2222:33thhellerthe rest is entirely different#2018-02-2222:34thhellerit seems to have special code for self hosted js#2018-02-2315:54justinleeis there a way to get stats on what is contributing to the release build sizes? my build is giant and I’m trying to figure out why#2018-02-2316:10thhellercurrently only from the REPL#2018-02-2316:10thheller(shadow.cljs.devtools.api/release-snapshot :the-build {})#2018-02-2316:11hlolliMy release build size is currently huge, I see quickly scanning over the minified code that for example all material-ui icons are bundled module$node_modules$material_ui_icons$Gamepad But it's still acceptable size with gzip#2018-02-2316:11thhellerthen navigate to and click through the release snapshot sutff#2018-02-2316:11thhellerhttps://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9?u=thheller#2018-02-2316:17hlollihaha
831.76 KB		node_modules/material-ui-icons
203.19 KB		node_modules/material-ui
ok I'm defenitely going to just download each svg that I use, damn!
#2018-02-2316:24hlolliexcept there's a way to cherry-pick files from a module?#2018-02-2316:25thhellerwhy are icons even js?#2018-02-2316:26hlollithey create react svg elements
var _ref = _react2.default.createElement('path', { d: 'M22 5.72l-4.6-3.86-1.29 1.53 4.6 3.86L22 5.72zM7.88 3.39L6.6 1.86 2 5.71l1.29 1.53 4.59-3.85zM12.5 8H11v6l4.75 2.85.75-1.23-4-2.37V8zM12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9c4.97 0 9-4.03 9-9s-4.03-9-9-9zm0 16c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z' });
#2018-02-2316:27tianshusometimes wired bugs occur can be fixed by lein clean when using with lein. maybe it's better to always clean before start?#2018-02-2316:28thheller@doglooksgood lein clean should not be required at all. if something doesn't work but works after lein clean I want details.#2018-02-2316:28thheller@hlolli looking at the package you can just import the icons you actually want#2018-02-2316:29hlolliyup, I do that for example ["material-ui-icons/Hotel" :as Hotel] this means I have required ["material-ui-icons"] somewhere?#2018-02-2316:29thhellereither you or a library you are using yes.#2018-02-2316:30tianshuI just setup a project, but I forgot to npm install react(I use reagent), then I kill the REPL process, add npm dependency with yarn. when start shadow-cljs again, i met OutOfMemory.#2018-02-2316:30tianshuafter lein clean, everything works fine.#2018-02-2316:30thhelleryou get OOM when starting the shadow-cljs process?#2018-02-2316:31hlolliyup it was me 🤐#2018-02-2316:33tianshu
shadow-cljs - config: /Users/shitianshu/sideline/loadstone/shadow-cljs.edn version: 2.1.24
shadow-cljs - socket connect failed, server process dead?
also I got this when type shadow-cljs in terminal. @thheller I think this is not a urgent issue, you can just ignore. when i have time, i can create a repo that reproduce the problem.
#2018-02-2316:35tianshusince i killed that repl in emacs, i don't have the error stack at this moment. no enough information to locate the problem.#2018-02-2316:35thhellerhmm if you forcefully kill the shadow-cljs process it won't clean up after itself. thats why you get socket connect failed, server process dead?#2018-02-2316:35thhellertry running shadow-cljs stop instead#2018-02-2316:35hlolliwow, the bundle went from 1,8mb down to 306,5kb, I was not paying attention to the bundle size#2018-02-2316:36thhellerhehe#2018-02-2316:36tianshuokay#2018-02-2316:36thheller@hlolli gotta be careful with those js imports 😉#2018-02-2316:36hlolliI thought google.closure could read minds too 😄#2018-02-2316:37tianshucan I add npm dependency or cljs dependency without stop shadow-cljs process?#2018-02-2316:37thhellernpm yes, doesn't require a restart. cljs no.#2018-02-2316:39thhellerone issue currently is that npm install does not trigger a recompile. if you have a watch running that failed because of a missing npm dependency that build will stay stuck#2018-02-2316:40justinleeso i if i do shadow-cljs server then shadow-cljs release :app and then navigate to http://localhost:9630/ I get “no release snapshots found”#2018-02-2316:40thheller@lee.justin.m not release. like I said you need to run this from the REPL. shadow-cljs clj-repl and then (shadow.cljs.devtools.api/release-snapshot :the-build {})#2018-02-2316:44tianshuokay, thanks!#2018-02-2316:44thheller@doglooksgood you can use the REPL to restart the build but its all a bit messy#2018-02-2316:45thhellershadow-cljs clj-repl (shadow/stop-worker :build) (shadow/watch :build)#2018-02-2316:47tianshuokay#2018-02-2316:47tianshuExceptionInfo: module without entry or suffix: react what's this error stands for?#2018-02-2316:48thhelleruhm what is in your node_modules/react/package.json?#2018-02-2316:48thhellerare you using npm or cnpm?#2018-02-2316:49thhellercnpm did some weird symlinks that causes issues a while ago#2018-02-2316:50thhelleryou can try shadow-cljs clj-repl (shadow.cljs.devtools.server/reload!) if anything weird is happening#2018-02-2316:51thhellerstops everything and reloads the server#2018-02-2316:52thhellerall of this will get much easier to use once I work on the UI#2018-02-2316:52thhellerdoing all of this from the REPL/CLI is horrible#2018-02-2316:52tianshuvery strange, I found react, react-dom and shadow-cljs in node_modules become empty...#2018-02-2316:53tianshuit becomes node_modules/react/node_modules#2018-02-2316:53tianshulike this.#2018-02-2316:53tianshuI re-run the yarn install#2018-02-2316:54tianshulet me investigate by myself#2018-02-2316:54tianshu😂#2018-02-2316:58justinleeis there a way to dump the dependency graph so I can see where some dependencies are coming from?#2018-02-2316:58justinleei think you told me once before. this time I will add it to my tips file. 🙂#2018-02-2316:59thhellerwill also be part of the UI. for CLJS you can do (shadow.cljs.devtools.api/find-resources-using-ns 'foo.bar)#2018-02-2316:59thhellerdoesn't yet work for JS deps though#2018-02-2317:01justinleehm. well something is going terribly awry when included pdf.js. it’s bundling the webworker#2018-02-2317:01justinleeit shouldn’t do that#2018-02-2317:04justinleeI’m including them very precisely like so:
["pdfjs-dist/lib/pdf.js" :as pdfjs]
            ["pdfjs-dist/web/pdf_viewer.js"]))
#2018-02-2317:08justinleeincluding the pre-built pdf.js actually reduces the total build, but it still includes the worker in the bundle somehow#2018-02-2317:12thhellerugh#2018-02-2317:12thheller
fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
    require.ensure([], function () {
      var worker;
      worker = require('./pdf.worker.js');
      callback(worker.WorkerMessageHandler);
    });
  } : dynamicLoaderSupported ? function (callback) {
    requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
      callback(worker.WorkerMessageHandler);
    });
#2018-02-2317:14tianshuis it possible to import css in cljs?#2018-02-2317:14thhellerno#2018-02-2317:15thheller@lee.justin.m it appears that it has some kind of dynamic loading mechanism which the compiler cannot identify as dynamic#2018-02-2317:16justinleeokay let me take a look at the docs. there is probably some stuff you have to do to make behave. this is a super complicated package#2018-02-2317:16justinleei astounded that it actually functioned by just including it so kudos to shadow#2018-02-2317:16thhellerthe pdf.js has this stuff#2018-02-2317:16thheller
{
  var isNodeJS = require('./shared/is_node.js');
  if (isNodeJS()) {
    var PDFNodeStream = require('./display/node_stream.js').PDFNodeStream;
    pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
      return new PDFNodeStream(params);
    });
  } else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
    var PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
    pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
      return new PDFFetchStream(params);
    });
  } else {
    var PDFNetworkStream = require('./display/network.js').PDFNetworkStream;
    pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
      return new PDFNetworkStream(params);
    });
  }
}
#2018-02-2317:17thhellerdynamic requires just won't work properly#2018-02-2317:18justinleewell you know i’m actually okay with it bundling the worker but i need to figure out how to start a worker using the bundled source. it is possible apparently#2018-02-2317:18justinleei just don’t want to fetch it twice#2018-02-2317:18justinleethe default is not to use a worker at all if it is bundled and just doesn’t work because your UI is unusable#2018-02-2317:22justinleeso somehow they got the main bundle and the worker bundle to build separately using webpack#2018-02-2317:22justinleethey have a webpack example.#2018-02-2317:22justinlee
~/test/pdf.js/examples/webpack$ npm run build

> 
#2018-02-2317:22thhelleryeah they are using something webpack specific#2018-02-2317:23thhelleror rather they are using the webpack code splitting stuff#2018-02-2317:23thhellerhttps://webpack.js.org/api/module-methods/#require-ensure#2018-02-2317:23thhellerI can detect calls to require.ensure and ignore them#2018-02-2317:24justinleeall they do is list two entry points. one for main.js, which does a var pdfjsLib = require('pdfjs-dist'); and one for the worker#2018-02-2317:24thhellerunfortunately not#2018-02-2317:24thheller
require.ensure([], function () {
      var worker;
      worker = require('../pdf.worker.js');
      callback(worker.WorkerMessageHandler);
    });
#2018-02-2317:24thhellerwebpack will use require.ensure to create a split point#2018-02-2317:25justinleeahh#2018-02-2317:25thhellerso you end up with two files#2018-02-2317:25justinleesneaky sneak#2018-02-2317:25thhellerclosure and shadow-cljs don't work that way#2018-02-2317:25thhellerbut I can skip require.ensure calls so the worker won't be bundled#2018-02-2317:31justinleeyea in the browserify example they have to use a gulp task to ignore that line
gulp.task('build-bundle', function() {
  return browserify('main.js', {output: TMP_FILE_PREFIX + 'main.tmp'})
    .ignore(require.resolve('pdfjs-dist/build/pdf.worker')) // Reducing size
    .bundle()
    .pipe(source(TMP_FILE_PREFIX + 'main.tmp'))
    .pipe(streamify(uglify()))
    .pipe(rename('main.bundle.js'))
    .pipe(gulp.dest(OUTPUT_PATH));
});
#2018-02-2317:32thhellerI could add an ignore option as well but seems fine to just ignore require.ensure#2018-02-2317:40thheller@lee.justin.m 2.1.25 should not include the worker anymore#2018-02-2317:40justinleetrying now#2018-02-2317:41justinlee(side note: vscode is pretty impressive. i went to update the version in package.json and the mouse-over already told me that 2.1.25 is the most recent version)#2018-02-2317:41thhelleryeah their JS intergration is pretty good#2018-02-2317:42justinleei’m thinking about trying them instead of atom to see if the tooling is better#2018-02-2317:42thhellerJS tooling is. everything else isn't.#2018-02-2317:42thhellerthat was my experience at least#2018-02-2317:53justinleeokay it is definitely eliding the worker. now i have to figure out what else broke. (I don’t think it is related)#2018-02-2317:54thhelleruh that broke something?#2018-02-2317:56justinleei don’t think so.#2018-02-2317:57justinleei’m checking to see what’s wrong#2018-02-2318:33justinleeokay so unfortunately that breaks pdf.js because what it does is goes and tried to load the worker code into the main thread https://github.com/mozilla/pdf.js/blob/99060e2485cacb8513e7bc50d88b70101069b1c9/src/display/api.js#L1478#2018-02-2318:38justinleehang on possible false alarm because downgrading to 2.1.24 does the same thing.#2018-02-2318:41thhellerwhat is the actual problem?#2018-02-2318:43thhelleryou might be better off just using their dist from a CDN and using it via a global#2018-02-2318:43justinlee
seekeasy.page.worker.js:1 Uncaught SyntaxError: Unexpected token <
pdf.js:3853 Uncaught TypeError: Cannot read property 'WorkerMessageHandler' of undefined
    at pdf.js:3853
    at HTMLScriptElement.c.onload (pdf.js:771)
#2018-02-2318:44justinleeyea i’ll just do that#2018-02-2403:03tianshu@thheller I found why shadow-cljs not stop gracefully in my case, I stop repl my cider's cider-quit command.#2018-02-2410:25thhellerhmm. try again?#2018-02-2411:51tianshugonna to try shadow-cljs with react-native. 😎#2018-02-2411:52tianshuit's likely there's no need to use figwheel anymore. #2018-02-2412:40thhellerI think some stuff will not yet work properly with react-native. I didn't do much testing with it at all but feel free to report when something comes up. should all be easy fixes.#2018-02-2414:13tianshu@thheller shadow-cljs - updating dependencies which work will be done at this moment. hang at here.#2018-02-2414:14tianshu^C and restart it works#2018-02-2414:29tianshushadow-cljs use maven for retrieving dependencies?
#2018-02-2414:30thhelleryes updating dependencies will try to resolve maven deps#2018-02-2414:31tianshuwhich maven will be used? it has an embed mvn?#2018-02-2414:33thhellerembedded yes, not maven but the same lib maven uses#2018-02-2414:33tianshuhow can I configure mirrors#2018-02-2414:34thhellerhmm no idea#2018-02-2414:34thhellerhttps://maven.apache.org/guides/mini/guide-mirror-settings.html#2018-02-2414:34thhellermaybe this works?#2018-02-2414:35thhellernot sure if that will be picked up automatically#2018-02-2414:35thhellerbut is there a clojars mirror?#2018-02-2414:35thhellerthe shadow-cljs jar comes from clojars#2018-02-2414:38tianshuno, it's likely not work.#2018-02-2414:39tianshumy mvn command will use the config in ~/.m2/settings.xml, but shadow-cljs not.#2018-02-2414:40thhellerhmm#2018-02-2414:40tianshuit's not a big problem but still a problem i think.#2018-02-2414:41tianshuChinese have to face the f**king network:confused:#2018-02-2414:42thhelleris clojars blocked?#2018-02-2414:44tianshuno, central#2018-02-2414:54thheller@doglooksgood I just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e415e4246"}, :content ("[email protected]")} which should support :mirrors in your shadow-cljs.edn config#2018-02-2414:54thhellerideally this wouldn't be part of the config but for now it is#2018-02-2414:54thhellerhttps://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate/aether.clj#L581-L591#2018-02-2414:55tianshuis there any plan to support global config for shadow-cljs?#2018-02-2414:55thheller:mirrors {"" {:name "some string" :url ""}}#2018-02-2414:57thhellerglobal config only for settings like these yes#2018-02-2414:57thhellerglobal build configs no#2018-02-2414:57tianshuI don't think :mirrors should be write in project config, also for cider dependencies.#2018-02-2414:58tianshuat least for :mirrors and :dependencies in my use case.#2018-02-2414:58thhelleryes I agree but adding a global config is more work. I first want to confirm that it actually works 😉#2018-02-2414:59tianshuIf there's a description on how i should looks like, I think a lot of people can help:no_mouth:#2018-02-2415:00thhellerI don't know what it should look like#2018-02-2415:03tianshuusing shadow-cljs in react-native, each time I save a file, client will have a full reload#2018-02-2415:07thhellerthats react-native#2018-02-2415:07thhellerI didn't do much react-native development but their hot reload tends to do that#2018-02-2415:08thhellerdon't know how to turn it off#2018-02-2415:44tianshuI found no matter where I put the output, it always full reload. maybe it listens to file writing event. and when shadow-cljs recompile, it overwrite all files, this cause a full reload.#2018-02-2416:16lilactownyes, the RN bundler watches the files#2018-02-2416:16lilactownand by default, refreshes the current view#2018-02-2416:17lilactown(at least, the version we’re using at work does that)#2018-02-2416:19lilactownif you go into the dev menu, you can turn on/off live reloading and hot module reloading#2018-02-2504:10tianshu@lilactown if a file is overwritten by the same content, also trigger a reload? #2018-02-2504:28lilactownThat sounds consistent with my experience, but I'm not sure#2018-02-2506:57tianshujust have a test, that's not true#2018-02-2507:23tianshuIt's super fancy to use shadow-cljs with react-native script, not expo.#2018-02-2507:39tianshufound source map not work#2018-02-2507:39tianshubut hot reload is good, no need figwheel, just use the built-in hot reload.#2018-02-2508:29tianshuanother bad news is repl will not work.#2018-02-2518:14lilactownyeah I ran into that with using e.g. storybook - since you’re consuming the code as a library instead of executing it live, REPL doesn’t work#2018-02-2518:14lilactownI actually have a question re: file watching as well#2018-02-2518:15lilactownis there any way to switch shadow-cljs to poll for changes, instead of relying on events?#2018-02-2518:16lilactownI’m running into issues running on docker toolbox on windows 🙃 been fighting with it for about ~30 hrs now and at this point, only thing that doesn’t work is hot reload#2018-02-2518:23lilactownhere's an issue explaining why it doesn't work: https://github.com/docker/for-win/issues/56#2018-02-2602:21sparkofreasonJust getting started taking shadow-cljs for a test spin. Hot reload doesn't seem to be working, though the when I change the code it does recompile and show a warning on the HUD. Any thoughts on how to diagnose the issue? I'm guessing I just misconfigured something.#2018-02-2602:31tianshuwhich :target you use?#2018-02-2602:33sparkofreason:browser#2018-02-2602:55tianshu@dave.dixon I think you need to provide a function for :after-load and :preloads [shadow.cljs.devtools.client.hud] in :devtools.#2018-02-2602:57tianshu
{:source-paths ["src"]
 :dependencies []
 :builds {:browser {:target :browser
                    :output-dir "target/browser"
                    :modules {:main {:entries [app.main]}}

                    :devtools {:after-load app.main/reload!
                               :preloads [shadow.cljs.devtools.client.hud]
                               :http-root "public"
                               :http-port 8080}}}}
I use this as minimal setup and it works
#2018-02-2602:59sparkofreasonYep. that did it, thanks. Not sure why that should be, seems like it should hot reload regardless whether I specify an explicit :after-reload, but whatever, it works.#2018-02-2603:27justinleeI think shadow has a kind of bias against magic automatic stuff. #2018-02-2609:22thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2018-02-2614:41sparkofreasonThanks. I managed to read everything but the "TIP" at the end of section 5.2.3 it seems. Maybe consider moving that to the beginning, because I read 5.2.2 as "shadow-cljs watch build-id" was all you needed to do to enable hot reload.#2018-02-2609:22thheller@dave.dixon hot-reload must be enabled by either a callback or :autoload true.#2018-02-2609:25tianshu@thheller is it possible to use repl with :npm-module ?#2018-02-2609:25thhellerI guess it could be enabled by default though#2018-02-2609:26thheller@doglooksgood yes and no. depends on the kind of post-processing that is done#2018-02-2609:26thhellerwhen just running in node yes#2018-02-2609:26thhellerwhen running in some other packager ... maybe but unlikely#2018-02-2609:27tianshuI want to use repl with react-native, how can I investigate what's going wrong?#2018-02-2609:28thhellerwith :npm-module there is no cleary defined entry namespace#2018-02-2609:28thhellerso you must manually load the repl code#2018-02-2609:29thhellercan you show me the react-native code?#2018-02-2609:29thhellerthen I can tell you how to load the repl code#2018-02-2609:29thhellerI forgot how the non create-react-native-app stuff looks#2018-02-2609:33tianshumy step is create project with react-native init Hello then cd Hello, run shadow-cljs init. edit shadow-cljs.edn to
...
:builds 
{:app {:target :npm-module
      :output-dir "js/"}}
And require js/hello.core.js in App.js.
#2018-02-2609:34tianshuI can make a repo later#2018-02-2609:34thhellertry import "js/shadow.cljs.devtools.client.node" in App.js#2018-02-2609:34thhellerah no wait its not node#2018-02-2609:34thhellerimport "js/shadow.cljs.devtools.client.browser"#2018-02-2609:35thhellermight need to set :runtime :browser in your build config#2018-02-2609:37tianshuhow can I specify where it connect to? I think JS runtime(on mobile) and shadow-cljs(on MBP) run on different IPs.#2018-02-2609:37tianshuis it a problem?#2018-02-2609:38thheller:devtools-url see https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2018-02-2609:38thhellerdoesn't have to be a proxy, can just be your machine#2018-02-2609:39tianshuokay, I'll have a try tonight#2018-02-2609:57tianshuif my ip is 192.168.1.151, what is the :devtools-url?#2018-02-2609:57thheller#2018-02-2610:05tianshu@thheller It works, expect one problem. since there's no document in react native, there will be a error for Can't find variable: document. But after I dismiss this error, it works.#2018-02-2610:19tianshucomment the body of script-eval it works and no error#2018-02-2611:50tianshuI want to make :react-native an :target 🙃#2018-02-2612:06thhellerthe most helpful thing at this point would be a basic demo project for react-native#2018-02-2612:06thhellerie. not create-react-native-app#2018-02-2612:07thhellerbut yes there should be a :target :react-native#2018-02-2612:08thhellerjust thinking that the best way about this would be to completely bypass the react-native packager#2018-02-2612:08thhellerbut I don't know how possible that is#2018-02-2612:08thhellerhttps://github.com/callstack/haul seems to do it but I haven't looked into how#2018-02-2612:41tianshu@thheller I think the hmr works as expectef without any problem, and the next two things are source map and repl. by tweak a little the repl works, there's no need to introduce additional tools.#2018-02-2612:42thhellerwell. source maps probably do not work because files are processed by the react packager#2018-02-2612:42thhellerI don't want to introduce haul. I want to do what haul does.#2018-02-2612:43thhellerso we don't need the react packager at all#2018-02-2612:43thhellerit will most likely just get in the way#2018-02-2612:44tianshuthat will be a huge work to do. i think we can do now is just having a condition to ensure no error when there's no js/document. #2018-02-2612:45tianshuit's pretty simple to do. #2018-02-2612:47thhellerthe point is that shadow.cljs.devtools.client.browser is meant for the browser. react-native is not a browser.#2018-02-2612:48thhellerI will not start adding some conditional hacks to make it work but then having to think about every potential future change because it might not work#2018-02-2612:49thhellerI much rather write a shadow.cljs.devtools.client.react-native version. that uses every capability react-native has.#2018-02-2612:49thhellerthese things are super simple to write so its not a big deal at all.#2018-02-2612:50tianshuadd a new client is good idea#2018-02-2612:51tianshuanother thing is auto set :devtools-url #2018-02-2612:52thhelleryeah :target :react-native could do that#2018-02-2612:56tianshuI saw there's a path like hello/core.cljs in source map, is that a relative path? in chrome, the src is not include in souces, there're node_modules and js(output dir). do you have any thought on this?#2018-02-2612:57thhellersource maps include sourcesContent so they don't need to look at other files#2018-02-2612:58thhellerdon't know what you mean by not included in chrome?#2018-02-2613:01tianshui mean my source path is src, but in chrome Sources section, there're only two folder: node_modules and js.#2018-02-2613:02tianshui want to create a repo for this.#2018-02-2613:03thhelleryou mean this?#2018-02-2613:04tianshuyes, there's no cljs file in my case#2018-02-2613:08tianshui think the path in source path may be wrong, in my case it is hello/core.cljs, i think it shoud be ../src/hello/core.cljs#2018-02-2613:10thhellerthe path does not map to a filesystem#2018-02-2613:10thheller../src/.. would definitely be incorrect#2018-02-2613:11tianshu😂#2018-02-2613:13thhellerwhat are you using the Sources panel for?#2018-02-2613:18tianshuI think source map is not necessary#2018-02-2613:20tianshurepl + hmr is enough #2018-02-2613:21tianshuI want to introduce react-native + shadow-cljs to my workmates. I think this is a awesome solution. the re-natal is really complex, at least it looks complex.#2018-02-2613:24thhellernever used re-natal but I think its the most commonly used tool for cljs+react-native#2018-02-2613:24thhellerso it probably does a bunch of other useful stuff#2018-02-2613:27tianshuit does a lot of shim job, because you can't use figwheel with react-native in a trivial way.#2018-02-2613:27tianshusource map + repl + hot load, re-natal provide these #2018-02-2617:15lilactownI opened up an issue w.r.t. windows + docker + volumes 😬#2018-02-2617:16thhellerjust answered#2018-02-2619:43kennyTrying out shadow-cljs for the first time and really loving it over Boot's CLJS stuff. Running into a warning using re-frame-10x:
11:41:42 CLJS | ------ WARNING #1 --------------------------------------------------------------
11:41:42 CLJS |  File: day8/re_frame_10x/view/parts.cljs:26:28
11:41:42 CLJS | --------------------------------------------------------------------------------
11:41:42 CLJS |   23 |    :children [[:h1 "Events"]
11:41:42 CLJS |   24 |               (render-registered re-frame.events/kind)
11:41:42 CLJS |   25 |               [:h1 "Subscriptions"]
11:41:42 CLJS |   26 |               (render-subs re-frame.subs/kind)
11:41:42 CLJS | ----------------------------------^---------------------------------------------
11:41:42 CLJS |  Use of undeclared Var re-frame.subs/kind
Has anyone else ran into this? It doesn't make sense given re-frame is in my :dependencies.
#2018-02-2619:44kennyOnly happens on initial compile.#2018-02-2619:44kennyEverything works as expected after though.#2018-02-2620:22lilactown🤔 that is strange. I wonder if it's a compilation order thing#2018-02-2621:26thhellernah shadow-cljs is just stricter than other tools and the file has no require for re-frame.subs so it complains#2018-02-2621:26thhellerhttps://github.com/Day8/re-frame-10x/blob/master/src/day8/re_frame_10x/view/parts.cljs#2018-02-2621:28thhellerguess I shouldn't be so strict for library code that you can't fix#2018-02-2621:29thhellerwithout the require it might break due to parallel compilation though#2018-02-2622:13kennyI'll submit a PR to fix the issue.#2018-02-2622:13kenny(in re-frame-10x)#2018-02-2622:43kennyIs anyone using devcards with shadow-cljs? I can't get any of my cards to appear until I load the namespace in the REPL. I am requiring me devcards namespace and have set :devcards to true in my :dev :compiler-options.#2018-02-2623:10kennyEh, just realized all we were using devcards for was card styling to demo our components. I just rolled our own version instead.#2018-02-2623:19mjmeintjesI've used devcards successfully with shadow-cljs. I just created a separate build config for devcards, and a separate entrypoint namespace, and it worked pretty well.#2018-02-2700:02kennyI see shadow-cljs uses thheller/cljs-dev Docker image for running CI tests. Is it recommended to use this image for our CI tests as well?#2018-02-2700:06kennyAlso, is it possible to specify :repositories in my shadow-cljs.edn?#2018-02-2700:09kennyIt appears not? 😬 https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L528#2018-02-2700:10kennyJust kidding 🙂 https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj#L36#2018-02-2700:22kennyI don't think shadow-cljs provides a way to configure a private Maven repository.#2018-02-2700:38kennyI guess I can move deps, source paths, and repositories into a project.clj.#2018-02-2701:17kennyIs there a reason the wait time is hardcoded for 60s? https://github.com/thheller/shadow-cljs/blob/d59524d3ef9dfd41a2b6e5ec58fa69a1ed5002e2/src/main/shadow/build/compiler.clj#L683 Seems like this should be configurable. My CLJS is failing to compile from hitting that limit (it's due to using some generators at macro time to generate some code).#2018-02-2706:40tianshu@thheller https://github.com/DogLooksGood/shadow-cljs-with-react-native-note can't wait to have a :react-native target.#2018-02-2706:40tianshu😢#2018-02-2708:41thheller@kenny I can make that timeout configurable. the "slowest" compile for a single ns I saw so far was ~15sec. what are you doing that it takes 60s+?#2018-02-2713:39thheller@kenny I changed the timeout condition in 2.1.28 which might just fix your problem. if not you can set :build-options {:par-timeout some-high-number-in-ms}#2018-02-2713:40thhellerprivate maven repos might work. I'm not sure. Using the same lib as lein but not sure if I'm maybe not setting something I would need to set. lein or deps.edn also work though.#2018-02-2716:33lilactownI really appreciate the lein integration - if only because it helps Cursive users 🙂 but also the ecosystem of plugins is quite nice#2018-02-2719:03kenny@thheller Thanks! I set it to 2 mins and I'm still having the issue. It appears to only happen on the CI though, and it's not clear why it is happening. The namespaces that it is printing out should not take a long time to compile. For example, DataScript is failing on the CI:
:shadow.build.classpath/resource "datascript/pull_api.cljc"] #error {
 :cause "aborted par-compile, [:shadow.build.classpath/resource \"datascript/pull_api.cljc\"] still waiting for #{datascript.pull-parser}"
 :data {:aborted [:shadow.build.classpath/resource "datascript/pull_api.cljc"], :pending #{datascript.pull-parser}}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "aborted par-compile, [:shadow.build.classpath/resource \"datascript/pull_api.cljc\"] still waiting for #{datascript.pull-parser}"
   :data {:aborted [:shadow.build.classpath/resource "datascript/pull_api.cljc"], :pending #{datascript.pull-parser}}
   :at [clojure.core$ex_info invokeStatic "core.clj" 4739]}]
Is there a way to get more information printed out? I'd bet something else is going on here.
#2018-02-2719:08kennyI added the -v flag and I get more information. I don't understand why some namespaces are taking a long time to compile. For example
Cache write: datascript/impl/entity.cljc
<- Compile CLJS: datascript/parser.cljc (78929 ms)
#2018-02-2719:11kennyCould this be happening as a result of another namespace taking a long time to compile? Or are these all compiled independently and DataScript is just taking a long time for some reason?#2018-02-2719:23kennyTurns out the DataScript thing was a red herring. I removed the code created by generators and it worked (getting a No binary for ChromeHeadless browser on your platform. error not but that's something else I'm guessing). Confusing debugging process though. Not sure why it was telling me DataScript was taking a long time to compile.#2018-02-2719:52thheller@kenny I have never seen such high numbers. what kind of setup is this on?#2018-02-2719:52kennycircleci#2018-02-2719:52thhellerNo binary for ChromeHeadless browser on your platform. is no error from shadow-cljs. probably karma?#2018-02-2719:53kennyRight. Trying to figure that one out now. The vanilla example in the docs does not work.#2018-02-2719:54thhellerthis one https://shadow-cljs.github.io/docs/UsersGuide.html#_installing_karma?#2018-02-2719:54kennyYes#2018-02-2719:54thhellerkarma-chrome-launcher doesn't install chrome so you need to install chrome manually#2018-02-2719:55kennyThat's where I'm at now. Do you use puppeteer?#2018-02-2719:56thhellerI haven't used puppeteer no#2018-02-2719:56kennyWhat do you use on the CI? I only suggested it because it was suggested here: https://github.com/karma-runner/karma-chrome-launcher#2018-02-2719:59kennySimply adding the steps they have there does not work. It appears other binaries are missing to start the headless chrome.#2018-02-2719:59thhellershould just be chrome although headless is fairly new#2018-02-2719:59thhellermaybe you just have an older verison?#2018-02-2720:00kennyYou install chrome on the CI?#2018-02-2720:00thhellerI haven't used this stuff on CI#2018-02-2720:00kennyOhhh#2018-02-2720:00thhellerbut others have (I think)#2018-02-2720:00kennyKnow any projects off the top of your head that do?#2018-02-2720:01thhelleropen source no#2018-02-2720:01thhellerbut yes you need to install chrome on the CI#2018-02-2720:02thhelleror use an image that has all of this setup. I know there was one but I forgot which#2018-02-2720:02thhellerlet me see if I can dig it up#2018-02-2720:05kennythis? https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3#2018-02-2720:05kennyIt's somewhat surprising how much work goes into getting this working.#2018-02-2720:06thhellerthere are probably a couple of images that have all this setup and ready to go.#2018-02-2720:06thhellerI can't find it though#2018-02-2720:08kennyPerhaps? https://hub.docker.com/r/geekykaran/headless-chrome-node-docker/#2018-02-2720:09thhellerdoesn't look like it has java#2018-02-2720:09kennyRighttt. Forgot that's needed.#2018-02-2720:09thhellerhttps://circleci.com/docs/2.0/circleci-images/#clojure#2018-02-2720:09thhellerlein-2.8.1-node-browsers should work#2018-02-2720:11kennyAh cool. I'll try that now.#2018-02-2720:13thhelleras for the datascript issue I can't find anything that would cause this slowdown. it might just be the CI acting up. I hear they have issues with rogue crypto miners running on their VMs#2018-02-2720:13thhellermight just be using all the CPU and causing yours to get slow#2018-02-2720:14kennyIt was a red herring. Turns out it was a completely different ns causing the issue but DataScript was the one printed out for some reason.#2018-02-2720:15kennyThat image worked!#2018-02-2720:16thhellerif namespaces take too long to compile other namespaces "behind" it may get delayed a lot if there aren't enough threads#2018-02-2720:17thhellerbut that means the problem ns would spend 60sec+ compiling a single form.#2018-02-2720:17kennyIt would've been helpful if the problem ns was the one printed out instead of a tangential one.#2018-02-2720:19kennyBut yes that was the case, I guess. I have code that runs at macro time which generates some static data for the runtime environment (using test.check generators). It does not take a long time to run on my machine but it does on the CI.#2018-02-2720:19thhellerI'll see if I can find some better diagnostics for this#2018-02-2720:20kennyPerhaps simply printing out the one that is taking the longest?#2018-02-2720:20thhellermaybe I'll think about it#2018-02-2720:21thhellera "hint" would be the verbose messages printed#2018-02-2720:21thheller-> indicates that an ns started compiling#2018-02-2720:21thheller<- means it completed#2018-02-2720:21thhellerso look for -> I guess#2018-02-2720:21thhellerbut that could be more obvious#2018-02-2720:21thhellerespecially when throwing#2018-02-2720:21kennySure but there are so many messages printed. Would be very time consuming to go through.#2018-02-2720:24kennyAbove that I have about 100 lines of
Feb 27, 2018 3:03:01 AM shadow.build.compiler invoke
WARNING: [:shadow.build.classpath/resource "cljs/test.cljs"] waiting for #{cljs.pprint}
with the namespaces in the log messages varying.
#2018-02-2720:25kennyThere's a lot of noise to sort through. Maybe printing a summary of all the namespaces still compiling and how long they are taking?#2018-02-2721:34lilactownI just use nrepl-select / cemerick.piggieback ¯\(ツ)/¯#2018-02-2721:57hlolli@lilactown you use piggieback with shadow-cljs? I deleted my original question, because I still wasn't sure about how to formulate it. As I'm trying to connect to node repl, I'm trying to find out if that's an edge case, but I'm realizing it's actually the same procedure.#2018-02-2721:57lilactownyeah, it functions exactly the same#2018-02-2721:58thhellerits fake piggieback though#2018-02-2721:58thhellerwhats up?#2018-02-2721:59hlolliwhat I started to do, without success, was to make a huge emacs function for starting shadow-cljs node repl, start cider connect, paste the code in, and fork the shadow-cljs process to the cider-repl buffer. To get the print callbacks in 1 buffer. But I didn't get success, as it's no way to know when the subprocess has finished starting shadow-cljs node-repl for cider to start the connection.#2018-02-2722:00thhellerI'm missing some context. what is going on?#2018-02-2722:00hlolliI feel somehow this all could be simpler 🙂 so only thinking out loud, nothing is broken#2018-02-2722:02hlolliwell, best would be if cider could start shadow-cljs, just open a ticket and ask if the maintainers have the time in the future to implement shadow-cljs connection like they do with lein and boot....#2018-02-2722:03thhellerwhat is the problem?#2018-02-2722:04lilactownI think @hlolli wants an Emacs fn that starts up a build and connects to it with CIDER#2018-02-2722:05lilactownsimilar to how you can run cider-jack-in and it uses lein to start a headless REPL and connect to it#2018-02-2722:05lilactownis that correct?#2018-02-2722:06hlollibingo, so no problem really, it's a minor distraction that I need a terminal window next to my emacs, and the connection it a 4 step. cider-connect -> select root folder -> go to repl buffer -> go to end of buffer -> type in (shadow.cljs.devtools.api/nrepl-select :node-repl) -> press enter twice#2018-02-2722:06hlolliand on top of that, all print/console.log is in the terminal buffer, but I get the return value tough to my emacs.#2018-02-2722:07thhellerI have no idea what you are talking about sorry.#2018-02-2722:08lilactownfor piping console.log to the REPL, I’m not sure that’s really related#2018-02-2722:09lilactownI don’t think even CIDER with lein (and e.g. figwheel) does that#2018-02-2722:09thhellerif you can describe what you want to happen I can maybe help#2018-02-2722:10hlolliyes that's right, browser repl connection doesn't do that, don't think it makes sense there, but this is only an extra feature, I know it's possible tough to implement in emacs with subprocesses#2018-02-2722:10thhellerbut those emacs steps you mention mean nothing to me#2018-02-2722:10thhellerso I can't tell what you actually want#2018-02-2722:11thhellerI can make prn output appear in the REPL window#2018-02-2722:11hlollihehe, I feel like @lilactown understands me. And could clairify if I'm explaining this inaccurately? But this is nothing that requires change from shadow-cljs itself, as far as I see.#2018-02-2722:11hlolliok, you mean you could send the prn return values trough the nrepl connection?#2018-02-2722:12thhelleryes#2018-02-2722:12hlolli"return" sorry side-effects I mean#2018-02-2722:12thhellerprn yes, console.log no#2018-02-2722:13thhellerwell actually in the case of node-repl I could make ALL output appear#2018-02-2722:13thhellersince I control the node process#2018-02-2722:13thhellerjust doesn't work for non :node-repl#2018-02-2722:14hlollisounds good to me, I guess if you pipe it, it wouldn't add load to the node process?#2018-02-2722:15thhellerI think the issue you have is that you can't start a node-repl via nrepl#2018-02-2722:15thhelleryou have to run it externally#2018-02-2722:15thhellerwhich is absolutely not want I want .. its just the way it is for now#2018-02-2722:15thhellerif the process is started via nrepl you'd already get all the output it produces#2018-02-2722:17hlolliif you look at cider and clojurescript in leiningen, you see that when you close emacs with running cider, it will prompt the user for closeing 3 processes, cider process/cljs process and nrepl process. So I can imagine cider startup function, where shadow-cljs would be started as a process within emacs.#2018-02-2722:20hlollito proof, I did hack something here which almost works https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030#2018-02-2722:22thhellerok .. let me first take out all emacs stuff you are doing an deconstruct the commands you are running#2018-02-2722:23thhellerfirst of all never hardcode the port plz#2018-02-2722:23thhellerI emit a target/shadow-cljs/nrepl.port file which contains the port number#2018-02-2722:23thhellersimilar to .nrepl-port from lein#2018-02-2722:24thhellermight need to parse shadow-cljs.edn though since :cache-root can be configured#2018-02-2722:25hlolliah nice, ok! Glad I posted this work in progress then, the explicit port is there because it's a work in progress, guess I was debugging/ruleing out. Did this month ago..#2018-02-2722:25thhelleryou then start shadow-cljs node-repl#2018-02-2722:25thhelleryou could wait for the mentioned file to appear instead of look at the output#2018-02-2722:26hlolliah!! ah!! ok#2018-02-2722:26hlolli🙂#2018-02-2722:26hlolliand also, I'm pipeing the stdout to the message buffer. I'd want to change that to the cider-repl buffer. Essentially printing all output to 1 buffer.#2018-02-2722:27thhellerdefun shadow-node-repl () is defined twice?#2018-02-2722:30hlolliok, I will try to make something better out of this, I had commented line 60 to bottom, because I was giving up starting shadow-cljs as a subprocess, due to exacly the problem that, I didn't know when shadow-cljs repl was ready, but if the behaviour is like you say, the file nrepl.port exists when the port is open and available, I have then a solution. I recommend not reading this until I've made changes 🙂#2018-02-2722:35thhellerhttps://github.com/thheller/shadow-cljs/issues/209#2018-02-2722:36thhellerhttps://github.com/thheller/shadow-cljs/issues/83#issuecomment-324574691#2018-02-2722:36thhellerI think those are the main issues right now related to nrepl#2018-02-2722:37thhellerstarting node-repl from within nrepl and seeing its stdout/stderr#2018-02-2722:37thhellerthis currently doesn't work since I'm unsure how I want to handle external processes#2018-02-2722:38thheller(shadow.cljs.devtools.api/node-repl) does since simply by reading until eof on stdin#2018-02-2722:38thhellerwhich is what shadow-cljs node-repl uses and just kills the node process aftrer#2018-02-2722:39thhellernrepl however doesn't have a "disconnect" notification#2018-02-2722:39thhellersince the server keeps running#2018-02-2722:39thhellerso the node process would keep running#2018-02-2722:40thhellerI'll probably add some kind of method to manage processes#2018-02-2722:40thhellergoing to need it anyways for some plugins#2018-02-2722:40thhellereg. starting a css compile thingo in the background#2018-02-2722:42hlolliWish I knew the nrepl protocol mechanics better, but if you're keeping the nrepl connection alive by simply look for eof. Don't know what to say, seems magic to me that nrepl can know which stdout to take as return value and send across the wire and which text to ignore (ex. the print stuff).#2018-02-2722:44thhelleruhm thats what I meant .. nrepl works differently. thats why the wait-for-eof method doesn't work#2018-02-2722:45thhellernrepl in a nutshell just sends messages in the form of {:op "do-a-thing" :some "thing"} and gets messages {:out "this is printed"} or {:value "foo"}#2018-02-2722:45thhellerbit more complex than that but thats the basics#2018-02-2722:45thhellermessages back and forth encoded via bencode+edn#2018-02-2722:46hlolliok so I take it that it needs to by synchronous, the :out would the the first output from the operation.#2018-02-2722:46thhellerno :out is always stdout#2018-02-2722:47thhellercan get many#2018-02-2722:47thhellerrelated to other messages or not#2018-02-2722:48thheller{:op "eval" :code "(+ 1 2)" :id 1} would get {:value "3" :id 1}#2018-02-2722:48hlolliok can be, haven't bumped into that so far. But in lumo this could become very messy, getting return values into the eldoc buffer, and eldoc completions into the repl buffer#2018-02-2802:15lilactownis there a way to re-use the shadow-cljs server, and use the lein integration?#2018-02-2802:44sparkofreasonRolled back to the version of shadow-cljs.edn that was working before, still getting the same behavior.#2018-02-2802:45sparkofreasonGetting weirder - running lein clean fixed the version without lein.#2018-02-2808:41thheller@dave.dixon socket connect failed, server process dead? means that the server was most likely killed forcefully so the server didn't clean up after itself. can you verify that the server is actually dead? ie. no running java process left?#2018-02-2808:42thhellerlein clean will delete the target folder which includes target/shadow-cljs/*.port#2018-02-2808:42thhellerthe script uses those files to decide whether it should start a new server or connect to old one#2018-02-2808:42thhellerI should add a command to delete those files#2018-02-2808:43thheller@lilactown re-use server? all commands works identically with or without lein#2018-02-2808:44thhellerjust don't run lein clean since that kills the information the server needs#2018-02-2808:44thhelleror set :cache-root ".shadow-cljs" in your config so lein clean doesn't mess with the server state#2018-02-2808:44thhellerwhich is a default I should probably change anyways#2018-02-2810:12mitchelkuijpers@hlolli not sure if i understand correctly but we run shadow-cljs like this:
(defn start-cljs-repl []
  (shadow-server/start!)
  (shadow/watch :app)
  (shadow/watch :test)
  (shadow/watch :devcards)
  (shadow/nrepl-select :app))
and then we can just do cider-jack-in-clojurescript We also have a .dir-locals.el which contains:
((nil . ((projectile-project-type . lein-test)
         (eval . (progn
                   (require 'cider)
                   (setq projectile-create-missing-test-files t)
                   (setq cider-cljs-lein-repl "(start-cljs-repl)"))))))
So we can set the correct command to start he cljs-repl
#2018-02-2810:13thheller@mitchelkuijpers I think the issue is that you can't yet do this with node-repl#2018-02-2810:16mitchelkuijpersAh ok nvm then#2018-02-2812:19hlollivery neat! @mitchelkuijpers I'm stealing that for my non-node projects 🙂
#2018-02-2817:33thhellerI just pushed 2.2.0. bumped to 2.2 because I changed the default cache directory. it is now .shadow-cljs instead of target/shadow-cljs. too many conflicts with lein cleaning the target directory. you can configure the old directory by setting :cache-root "target/shadow-cljs" in your config.#2018-02-2817:33thheller(shadow.cljs.devtools.api/node-repl) also works inside nrepl now#2018-02-2817:34thhelleralso added shadow-cljs browser-repl (or (shadow.cljs.devtools.api/browser-repl) for a simple browser REPL without a build config#2018-02-2818:02sparkofreasonTried updating to 2.2.0, still getting the issue where it immediately exits. Looking at the code it wasn't clear what would happen if cp/spawnSync failed before the process got started, i.e. if an error would be displayed. It seems like this is always failing for me, independent of lein, since it also failed to run an npm command it said it was executing.#2018-02-2820:18levitanongTried it as well. Now getting “cannot call a class as a function” error on an npm require. After a lein clean and downgrade back to 2.1.26, the issue disappears.#2018-02-2821:24thheller@levitanong your error is most likely related to https://github.com/google/closure-compiler/issues/2822#2018-02-2821:24thhellerit should work if you add [com.google.javascript/closure-compiler-unshaded "v20180101"] to your dependencies#2018-02-2821:25thheller@dave.dixon just calling lein with-profile dev run -m shadow.cljs.devtools.cli --npm watch app directly also fails without any error?#2018-02-2821:26sparkofreasonNo, directly calling the printed command works.#2018-02-2821:27thhelleryou are on windows with which node version?#2018-02-2821:29hlolliI'm noticing, no matter how I kill shadow-cljs process within emacs the file nrepl.port isn't always deleted causing shadow-cljs - socket connect failed, server process dead?, I wonder if it's sending some kill signal that isn't handled by shadow-cljs?#2018-02-2821:29thhellerno kill signals are handled by shadow-cljs since java doesn't support that#2018-02-2821:29thhellerwhat does emacs do with the process?#2018-02-2821:30sparkofreasonWindows 10, node 8.9.4#2018-02-2821:31hlolliI've tried two things (process-send-string (get-process "shadow-cljs") ":repl/quit\n") and (kill-process "shadow-cljs") it kills the process for sure, it may be sending some SIGTERM or SIGINIT, I wonder which or something else...#2018-02-2821:32hlolliwell, being a hacker, I can trigger emacs to delete these files on process kill...#2018-02-2821:32thhellerare you sure the process is actually dead?#2018-02-2821:32thhellerbecause the shadow-cljs process is the node process#2018-02-2821:33thhellerit has a java child process#2018-02-2821:33hlollihmmm, I actually look for java, I wonder if my gnome-system-moniter isn't showing it, due to being nested within emacs...#2018-02-2821:34hlollibut node should be able to listen to SIGTERM signals, so you can add some java process kill callbacks#2018-02-2821:35thheller@dave.dixon just reproduced the problem on my machine. I only ever started it via WSL bash so I never noticed it before#2018-02-2821:35thhellerwill look into it#2018-02-2821:51thheller@dave.dixon it seems to work with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a0d3c8c1c4cfd78dc3cccad3e0928e928e91"}, :content ("[email protected]")}#2018-02-2822:28sparkofreason@thheller Had some weird problem getting node to update shadow-cljs, but once I got past that it worked. Thanks for the quick fix.#2018-03-0101:20hlolliFor emacs users to try: https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 the magic is in the function shadow-cljs-jack-in I can start on my computer browser-repl node-repl and start watch and have cider connect to it without doing anything (like pressing enter twice). Only problem being the possibility of creating these ghost java processes. Deleteing .shadow-cljs directory most often fixes it. Assumes shadow-cljs v2.2.20+, the emacs package edn (melpa/elpa) and cider/cider-nrepl as declared dependency within shadow-cljs.edn.#2018-03-0112:07donmullenThanks @hlolli - do you have sample shadow-cljs / project.clj / .dir-local.el files to share? I’m just ramping up on all these - would be helpful. Some people have been using .dir-local.el to kick off shadow-cljs - I’m assuming using this gist would replace that. Also - I’ve run into CIDER not loading cider/cider-nrepl — and think I’m not putting it in the right place. Where specifically should that reference live?#2018-03-0112:15hlollino but I can set up one, just need to be in a buffer where a shadow-cljs.edn file is in the root. This does script does not take leiningen into account, and no need to .dir-local.el/projectile like I saw here recently. If you have cider-nrepl in :dependencies within shadow-cljs.el, it should fire the nrepl connection automatically.
{:dependencies
 [[cider/cider-nrepl "0.17.0-SNAPSHOT"]
:nrepl {:port 9000
         :middleware []}
...}
This I have on top level.
#2018-03-0112:29donmullenGot it - thanks @hlolli. For cljs/clj dev (with clj repl for server side) - do you just use regular cider-jack-in or cider-connect for that?#2018-03-0112:34hlolliyup, I just start a ring handler to serve the cljs-output directory and do my server side stuff with cider-jack-in, which picks up the project.cljs. (and in terminal I have shadow-cljs watch .. running) But I guess this could be simplified as well, there is to say get the autocompletions from both clj and cljs, thinking about it I didn’t test two nrepl connections, so things may get strange. I’ll try adding lein function tonight and let you know!#2018-03-0112:36hlolliRing handler as in, this typical commented section at the bottom of the main ring handler file (comment (defonce server (run-jetty … etc…)))#2018-03-0115:12hlolliThe node-repl had stupid bug there, which I fixed https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 plan to move this to a git...#2018-03-0103:01cmalHi, I defined a SomeGlobalObj in a.js and use SomeGlobalObj in b.js , I generated a a-externs.js file for *a.js* and add to shadow-cljs.edn :compiler-options, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js. How to fix this?#2018-03-0103:06shaunlebron👋 I’m using the :target :node-library to get a UMD api that works in both node and the browser#2018-03-0103:08shaunlebronfor example, var Foo = require("foo") in node, or just window.Foo in the browser if you’re just including the JS file in a script tag without a build system#2018-03-0103:09shaunlebronbut currently, I have to use window.returnExports instead of window.<my-lib-name> because this is hard-coded into the UMD template that shadow uses here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/umd_exports.txt#L7#2018-03-0103:12shaunlebron@thheller this should probably be a build option, maybe under :umd-root-name "Foo"?#2018-03-0103:13shaunlebronsorry, this should a github issue, i’ll file and link here#2018-03-0103:21shaunlebronfiled: https://github.com/thheller/shadow-cljs/issues/212#2018-03-0103:32levitanong@thheller thanks!#2018-03-0109:05tianshu@thheller When use emacs cider, people usually quit with cider-quit command, this is not normal quit behavior for shadow-cljs.#2018-03-0109:06thheller@doglooksgood can you please dig up the source of cider-quit so I can look at what it actually does and see if I can do something about it?#2018-03-0109:10tianshuIt use emacs built-in function delete-process, which send signal SIGHUP.#2018-03-0109:11tianshuit is mentioned: Function: delete-process name This function deletes the process associated with name, killing it with a SIGHUP signal. The argument name may be a process, the name of a process, a buffer, or the name of a buffer. is it possible to handle this signal?#2018-03-0109:20thhellerthe quesion is which process gets this signal#2018-03-0109:20thhellerprobably the node process#2018-03-0109:21thhellerI'll look into what happens exactly#2018-03-0109:27tianshuI think nrepl will receive#2018-03-0110:45hlolliI think one solution would be to add all of the processes https://github.com/thheller/shadow-cljs/blob/b107bafc2c20b07af580e3f7deaa1434f54b0022/src/main/shadow/cljs/npm/cli.cljs#L56 into a atom, and catch the SIGHUP signals, kill these processes, and then exit.#2018-03-0110:47hlolli@doglooksgood did you do your own shadow-cljs startup script in emacs? I could have maybe saved one evening by useing yours instead of makeing my own 😛#2018-03-0110:49tianshu😂sry, I still don't know how to solve this. @hlolli #2018-03-0110:51hlollidid you try https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 ? I believe we are haveing the same problem.#2018-03-0111:05tianshuLet me take a look#2018-03-0111:14thheller@hlolli I agree but spawnSync doesn't return until the process it spawned dies so I need to switch to spawn first#2018-03-0111:15thhellerturning sync code into async unfortunately requires a little more thought#2018-03-0111:15thhellerI'll look into it later#2018-03-0111:24thhellerbtw given the state of lein dependence in most tools such as cider I would probably recommend just running through lein#2018-03-0111:26thhellerbbiab, grabbing food#2018-03-0111:26tianshu@thheller I think the source map patch in re-natal is this: https://github.com/drapanjanas/re-natal/pull/102/files no need to patch in shadow-cljs#2018-03-0111:30tianshu@hlolli this script works with lein + shadow-cljs?#2018-03-0111:31tianshuhave you tried stop the build before quit?#2018-03-0112:17hlolli@doglooksgood no it just handles the shadow-cljs boot, cider boot and nrepl-select automatically. I guess with leiningen/shadow-cljs setup you don't need to boot shadow-cljs yourself. But I've never integrated shadow-cljs and leiningen, since they work perfectly seperately (within the same project).#2018-03-0112:35mhueberti am walking down a troubled road trying to get monaco-editor-core loading in cljs#2018-03-0112:35mhueberttheir loader has this OS detection which assumes it is not in a browser so long as there is a global process object
// OS detection
if (typeof process === 'object') {
	_isWindows = (process.platform === 'win32');
	_isMacintosh = (process.platform === 'darwin');
	_isLinux = (process.platform === 'linux');
	_isRootUser = !_isWindows && (process.getuid() === 0);
	let rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
	if (rawNlsConfig) {
		try {
			let nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
			let resolved = nlsConfig.availableLanguages['*'];
			_locale = nlsConfig.locale;
			// VSCode's default language is 'en'
			_language = resolved ? resolved : LANGUAGE_DEFAULT;
		} catch (e) {
		}
	}
	_isNative = true;
} else if (typeof navigator === 'object') {
	let userAgent = navigator.userAgent;
	_isWindows = userAgent.indexOf('Windows') >= 0;
	_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
	_isLinux = userAgent.indexOf('Linux') >= 0;
	_isWeb = true;
	_locale = navigator.language;
	_language = _locale;
}
#2018-03-0112:36mhuebertI can get it to work if I include monaco’s loader.js in its own script tag, and (js-delete js/self "process") before I instantiate it#2018-03-0112:36mhueberti was wondering if shadow depends on this process object at runtime#2018-03-0112:44mhuebertit looks like it is just a set of empty stubs#2018-03-0112:44mhuebertI wonder what things will break if it’s not there#2018-03-0113:00thheller@mhuebert the last time I tried monaco-editor it wasn't packaged in a way that was usable with any bundler (without heavy config)#2018-03-0113:00thhellerdid they change that?#2018-03-0113:00mhuebertyes it looks like a __#2018-03-0113:01mhueberti think its still awkward, there appear to be people who have found workarounds#2018-03-0113:01mhuebertbut#2018-03-0113:01thhellerah monaco-editor-core is some kind of custom package#2018-03-0113:01mhueberti am thinking i can just use it with their loader and not bundle it#2018-03-0113:01thhelleryeah that was my conclusion the last time#2018-03-0113:01mhueberti just want to make sure that deleting js/process won’t screw up anything else#2018-03-0113:02thhelleroh it definitely will screw up everything that uses it#2018-03-0113:03thhellermany packages either check process.browser or process.env.NODE_ENV#2018-03-0113:03thhellerwhile NODE_ENV will be inlined and optimized away#2018-03-0113:04thhellerthere might be other process.env accesses that won't be#2018-03-0113:05mhuebertsigh#2018-03-0113:08thhellerthere are several issues in their github issues complaining about this#2018-03-0113:08thhellerbut they don't seem to be interested in fixing it#2018-03-0113:08thheller(the package that is)#2018-03-0113:12mhuebertI can do something horrible like this:
(defn require [paths cb]
  (let [process (.-process js/self)]
    (js-delete js/self "process")
    (js/require (clj->js paths)
                (fn [result]
                  (set! (.-process js/self) process)
                  (cb result)))
    nil))
if it so happens that no other code attempts to read js/process during the span of time before require calls its callback
#2018-03-0113:13thhellerrequire? are you in node?#2018-03-0113:14thhellerdynamic require means it won't be provided by shadow-cljs#2018-03-0113:20mhuebertno that is using monaco’s loader#2018-03-0113:21mhuebertwhich supplies a global require#2018-03-0113:21mhueberti include it via a separate script tag, eg <script src="/js/monaco/vs/loader.js"></script>#2018-03-0113:22thhellerah. it fails because I create the process as a global#2018-03-0113:22thhellerthats totally unnecessary. I can remove that#2018-03-0113:22thhellerI thought you were inside something shadow-cljs bundled#2018-03-0113:22mhuebertoh#2018-03-0113:22thhellerwhere process must exist#2018-03-0113:22mhuebertso there aren’t other things that use process at runtime#2018-03-0113:22thhellerit must not exist as a global though#2018-03-0113:23thhellerthere are but I can isolate the scope of process so it doens't become global#2018-03-0113:23mhuebert🙂#2018-03-0113:26cmalHi, I define a SomeGlobalObj in a.js , use SomeGlobalObj in b.js , generate a a-externs.js file for *a.js* and add to shadow-cljs.edn :compiler-options, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js. How to fix this?#2018-03-0113:28thhellerwhat do the externs look like?#2018-03-0113:28thhellerare you sure they are used?#2018-03-0113:28cmal
var SomeGlobalObj = {
  "invoke": function () {},
  "on": function () {}
}
#2018-03-0113:29cmalThey are used because the invoke and on are not changed anymore.#2018-03-0113:29thhellerand the :compiler-options {:externs ["path/to/externs.js"]}?#2018-03-0113:29cmal :compiler-options {:externs ["./weixin-externs.js"]}#2018-03-0113:30thhellerthe externs file is in the project root?#2018-03-0113:31cmalyes. At first I got some error because compiler renamed on and invoke, then I add the externs and the error not come out again.#2018-03-0113:32thhelleris it a ES6 .js file?#2018-03-0113:32cmalno#2018-03-0113:33cmalNot sure I will check it.#2018-03-0113:34cmalNo, neither file is ES6.#2018-03-0113:36thhellerthe files are not part of the shadow-cljs build?#2018-03-0113:38cmala.js is not, b.js is imported into cljs#2018-03-0113:38thhellerhow do you access SomeGlobalObj in the js?#2018-03-0113:39cmalbare use, just SomeGlobalObj.#2018-03-0113:39cmal
function handleFontSize() {

    WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });

    WeixinJSBridge.on('menu:setfont', function() {
      WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
    });
  }
here WeixinJSBridge is SomeGlobalObj.
#2018-03-0113:41thhellerah. when do you get the warning?#2018-03-0113:41cmalwhen I run shadow-cljs release app#2018-03-0113:42cmal
shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn version: 2.1.4
shadow-cljs - connected to server
[:doumi] Compiling ...
------ WARNING #1 --------------------------------------------------------------
 File: com/cognitect/transit.js:649:8

 variable module is undeclared
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/cognitect/transit/impl/writer.js:256:8

 variable isObject is undeclared
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/types.js:384:70

 variable Buffer is undeclared
--------------------------------------------------------------------------------

------ WARNING #4 --------------------------------------------------------------
 File: doumi/autorem.js:13:4
 variable WeixinJSBridge is undeclared
--------------------------------------------------------------------------------

nil
[:doumi] Build completed. (713 files, 3 compiled, 0 warnings, 28.53s)
#2018-03-0113:45thhellerthe code does work though right?#2018-03-0113:45cmalyes, it works.#2018-03-0113:45thhellermy guess is that is complains about the variable because the .js file is not in the global scope#2018-03-0113:45thhellerits wrapped in a function#2018-03-0113:46thhellerunlike the CLJS/goog code which is in the global scope#2018-03-0113:46thhellerdoes the file have any require or exports?#2018-03-0113:47cmal
var autorem = function (...) {...}
module.exports = autorem;
#2018-03-0113:47thhellerwhat you can try is turn the file into ES6#2018-03-0113:48thhellerexport default autorem;#2018-03-0113:48thhellerand then in the cljs (:require ["./autorem" :default autorem])#2018-03-0113:49thhellerwhen the file is processesd as ES6 it is lifted into the global scope#2018-03-0113:49thhellerwhich might make the warning go away#2018-03-0113:49thhellerotherwise just ignore the warning#2018-03-0113:49cmalOK. Thanks!#2018-03-0113:50thhelleralthough you might just get the warning in a different place then#2018-03-0113:50thhellerI'm not sure why it complain if there are externs#2018-03-0113:50thhellerbut its a closure warning so I can't do much about it#2018-03-0113:51thhellerexcept always disabling the warning but that sounds like a bad idea#2018-03-0113:51cmalOK. 👍#2018-03-0114:13mikerodI was a bit curious on some background info on shadow-cljs. Is the goal to just be a divergent “fork” of cljs as it is right now? Are there thoughts or plans around merging compiler fixes/changes into the main cljs etc. I haven’t found a “rationale” sort of discussion on this from waht I’ve seen.#2018-03-0114:14mikerodI was just reading a bit through the codebase yesterday and was wondering where it is supposed to be headed. Looks like a cool project though by the way!#2018-03-0115:20thheller@mikerod https://groups.google.com/forum/#!msg/clojurescript/xMQuEmQt7oQ/AWT5RZe_nQQJ#2018-03-0115:21thhellerI have no intent of merging any of the build specific stuff into CLJS and neither does have CLJS any interest in doing so.#2018-03-0115:21thhellerI see it as a build tool which should not be part of the language itself#2018-03-0115:21thhellerjust like lein is not part of clojure#2018-03-0115:22thhellerI can move much faster and try many more things which would otherwise be impossible or reaallly slow when done in official CLJS#2018-03-0115:23thhellerwhen I find things that actually affect the compiler itself I usually submit patches and they usually get accepted#2018-03-0115:24thhellerit is good that CLJS moves so slow and is very careful when adopting new things#2018-03-0115:24thhellerjust sometimes frustrating when you want to build new things 😉#2018-03-0115:25thhellerthe goal is simple and hasn't changed. it should be a good build tool for CLJS.#2018-03-0115:53mikerodThanks @thheller that is some helpful insight indeed.#2018-03-0115:55thhellerhttps://dev.clojure.org/jira/browse/CLJS-948 started in shadow-cljs before it came part of standard cljs#2018-03-0115:55thhelleras did :modules#2018-03-0115:55thhellerso maybe its some kind of idea testing facility as well 😉#2018-03-0115:55thhellerthe good stuff should all eventually make it into core#2018-03-0115:57hlolli@thheller :include-macros true is in the core?#2018-03-0115:58thhellerthat didn't come from shadow-cljs. that was there from the beginning#2018-03-0115:59hlollihmm ok, maybe I saw this in the wild way back. Never mind, struck me as something new 🙂#2018-03-0115:59thhellerthat you no longer need it in most cases was the new thing 😉#2018-03-0116:02mikerodNice#2018-03-0116:33thheller@mhuebert {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "54273c35303b237937383e2714667a667a67"}, :content ("[email protected]")} doesn't leak the process global anymore#2018-03-0116:44mhuebertGreat!#2018-03-0116:40JonI'm still in hope that shadow-cljs may get a release page like Webpack's, given that we have so many releases https://github.com/webpack/webpack/releases ╮(╯▽╰)╭#2018-03-0116:42thhellerI tried that before ... you know how it ended ...#2018-03-0116:43Jonno...?#2018-03-0116:43thhellerthe changelog?#2018-03-0116:44Jontoo early. I didn't know how it ended at last.#2018-03-0116:45thhellerjust look at the commit history thats pretty much the release log 😉#2018-03-0116:46Jonreleases is different, when you release a new version, if I'm watching the repo, I would get notified of new releases.#2018-03-0116:46JonI don't think so.. 2 reasons,#2018-03-0116:46Jon1) I can't see versions in your commits,#2018-03-0116:47Jon2) in a commit you can't add a link to some docs in User Guide.#2018-03-0116:53thhellerI know a release log would be nice but I just can't currently. got too much other stuff on my list already. I might be up for an automated solution but I don't know any so for now there isn't anything#2018-03-0116:54thhellerupgrading is also optional if you don't have any issues#2018-03-0116:55thhellerso no need to always be on the latest version#2018-03-0116:55Jonmade me curious.. I think adding a release note only takes tens of seconds.#2018-03-0116:56thhellermaybe if you have a workflow for it .. I don't.#2018-03-0116:56JonClick "New Release" button, write version number, a title, add a line or two of descriptions... won't take long.#2018-03-0116:56Jonno workflow, just use GitHub.#2018-03-0116:57Jonwe don't need release notes as long as Webpack anyway, I guess most of updates, since they are mostly bug fixes, should be less than 5 lines.#2018-03-0117:00Jonsome of mine are really short. and GitHub generates a page for commits since last release https://github.com/Respo/respo/compare/0.8.13...master#2018-03-0117:00thheller@jiyinyiyong I understand. Still no.#2018-03-0117:01thhellerif you want short messages read the commit log. last commit will almost always reflect what you get with npm install#2018-03-0117:01Jonokay, ╮(╯▽╰)╭#2018-03-0117:01thhellerI don't have infinite amount of time to do this stuff#2018-03-0117:01Jonhow about just adding version after this "bump"?#2018-03-0117:09JonConcerns on my side might be different from yours. New commits are adding to shadow-cljs. Following the release notes would be the simplest way for me to keep updated with changes in shadow-cljs. In theory by reading messages in this channel I would keep myself updated. But I don't have enough time to read so many messages either.#2018-03-0117:10Jon1a.m. already. bye..#2018-03-0120:30hlolliThomas, you mentioned few weeks ago that you implemented an experimental feature of require-ing bundled in js jar file. Does it mean that I can do an override like this
:resolve {"mylib" {:target :file
                  :file "jar:file:/lib/some.jar!/mylib.js}}
bit sorry I didn't try to do this immediately, was stuck with other project and the @logbot hasn't published logs for this channel since last year.
#2018-03-0120:54thheller@hlolli just (:require ["/path/to/mylib.js" :as x]) abs path being on the classpath#2018-03-0120:56thheller(:require ["/mylib.js" :as x]) in your case. but be careful with files like that. everything on the classpath should be properly namespaced.#2018-03-0120:57hlolliBINGO, the slash without dot did it!#2018-03-0120:57thheller./ is relative to the current file#2018-03-0120:57hlollimakes sense#2018-03-0120:57thheller/ is from any classpath root#2018-03-0120:58hlolliadded lot of goog symbol and all kinds of jars, now cleanup... but yeh, very nice!#2018-03-0215:47hlollitakeing it 1 step further, how can I override/js-resolve the node-repl, so that "mylib" within a .jar becomes "/mylib", this is for a project that I don't plan to build, just use the node-repl for live evaluation. To be percise, this :require https://github.com/hlolli/csound-wasm/blob/master/src/csound_wasm/node.cljs#L3 I'm hopeing to stay leagal from within a .jar file (so in another project I'm requireing this project).#2018-03-0215:48hlollitherefore in this case I'm hopeing "libcsound" resolves to "/csound_wasm/libcsound"#2018-03-0215:50thhelleris this not available from npm?#2018-03-0215:51hlolliyes! 🙂 I'm hopeing to make this a clojurescript library, node library and a standalone browser js library.#2018-03-0215:51thhellerI mean why not juset require "/csound_wasm/libcsound"?#2018-03-0215:51hlolliit would probably work from the .jar, but within the project itself when compileing :node-library, it will complain.. I can try again#2018-03-0215:53thhellerif you package that file in a .jar it should work for any build using that jar#2018-03-0215:54thhellerit just has to be on the classpath#2018-03-0215:54hlollithat's true, I bet it would, I'm going to see now if that will ruin the shadow-cljs release node compilation.#2018-03-0215:55hlollihttps://github.com/hlolli/csound-wasm/blob/master/shadow-cljs.edn#L6-L8#2018-03-0215:55thhellerno don't#2018-03-0215:55thhellerno :js-options at all#2018-03-0215:57thhelleralways just require "/csound_wasm/libcsound" not libcsound#2018-03-0215:57hlolliyup that works! now confirming the .jar#2018-03-0215:59hlollibut I do get some errors from "/csound_wasm/libcsound" that I didn't get from "libcsound" + :js-resolve. Namely
Closure compilation failed with 7 errors
--- csound_wasm/libcsound.js:81
Invalid module path "goog:shadow.js.shim.module$fs" for resolution mode "BROWSER"
--- csound_wasm/libcsound.js:82
Invalid module path "goog:shadow.js.shim.module$path" for resolution mode "BROWSER"
--- csound_wasm/libcsound.js:4253
Invalid module path "goog:shadow.js.shim.module$crypto" for resolution mode "BROWSER"
--- csound_wasm/libcsound.js:5166
Invalid module path "goog:shadow.js.shim.module$ws" for resolution mode "BROWSER"
--- csound_wasm/libcsound.js:5416
Invalid module path "goog:shadow.js.shim.module$ws" for resolution mode "BROWSER"
--- remaining errors ommitted ...
#2018-03-0215:59hlolliso ok, I guess it didn't compile then, I was running an older output#2018-03-0216:00thhellerso what is happening there is that you have conditional requires#2018-03-0216:00hlollithis file is kinda shit, automatically generated js->c/c++ patch from emscripten compiler#2018-03-0216:00thhellerthose are generally a bad idea and not supported#2018-03-0216:02hlolliI wonder why it still differs, the :js-resolve and classpath require. The setup with :js-resolve, minified it all and didn't throw errors.#2018-03-0216:03thhellerit is treated differently#2018-03-0216:04thhellerhang on I'll check something#2018-03-0216:10thheller
make: Entering directory '/mnt/c/Users/thheller/code/shadow-cljs/tmp/csound-wasm/node_modules/speaker/build'
  CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
 #include <alsa/asoundlib.h>
#2018-03-0216:10thhellerguess its not available on windows#2018-03-0216:10hlolliahh, f** "speaker"#2018-03-0216:11thhellerdoes osx work?#2018-03-0216:11hlolliyes it should#2018-03-0216:11hlolliI can test 1 sec...#2018-03-0216:12hlollisuccess#2018-03-0216:13hlollithey say for windows Windows: win32 Audio output for Windows (winmm). whatever winmm is, need to look into that. Webaudio in node.js is a strange world.#2018-03-0216:13thhellerit might be because of WSL#2018-03-0216:17thhellerwhere does the libcsound.js come from?#2018-03-0216:17hlollihere https://github.com/csound/csound/blob/develop/Emscripten/build-wasm.sh#2018-03-0216:18hlollibut I added this module.exports = Module at the end of the file. the minifier would otherwise not find the object.#2018-03-0216:18thhellerok so the compromise I made#2018-03-0216:19thhellerwas that the classpath should only contain ES6#2018-03-0216:19thhellerbut yours is commonjs with dynamic requires#2018-03-0216:19thhellerso it should be treated like node_modules sources but isn't at the moment#2018-03-0216:20thhellerlet me see if I can reasonably change the behaviour#2018-03-0216:21hlolliok, otherwise I could see if it's reasonable to patch this file to become ES6 compatable, but that sounds daunting#2018-03-0216:22thhellerideally it wouldn't include the loading code at all#2018-03-0216:22thhellerand would you just let pass in the wasm code#2018-03-0216:24hlollithis seems to be work in progress https://github.com/kripken/emscripten/issues/5828#2018-03-0216:25thhellerwould be good if there was a way to generate libcsound_browser.js libcsound_node.js#2018-03-0216:25thhellerso the file itself doesn't include any conditional loading code#2018-03-0216:26hlollihmm, then there's the rust to wasm compiler, seperate of emscripten one, looking at wasm discussion in the wild, seems to be an overtake from the rust community.#2018-03-0216:27hlolliyup aggree, I bet this will be improved soon#2018-03-0216:28hlollino they use emscripten seemingly... nvm...#2018-03-0216:44thhellermeh this commonjs handling code of the closure compiler hurts my head#2018-03-0216:49thhellerI'll probably add a new source type that isn't processed by closure at all#2018-03-0216:49thhellerand just copied as is to the output dir#2018-03-0216:50thhellerthat should resolve the problem for node#2018-03-0216:54hlolliI would still be tempted to compile it with js-resolve and change the require form and then bundle the jar. But the feature of ignoring certain js deps to be processed by closure is going to save headaches.#2018-03-0216:55hlolliNo quatsch, wont work :)#2018-03-0216:55hlolliYes I really need to ignore option for the jar.#2018-03-0216:56thhellerhow come you don't just publish libcsound.js to npm independently?#2018-03-0216:57hlolliThat was my initial plan. Was curious of the new features in shadow-cljs. But from this position, sounds way easier#2018-03-0216:57thhellerwell closure is getting in the way here#2018-03-0216:58thhellerInvalid module path "goog:shadow.js.shim.module$fs" for resolution mode "BROWSER" this I can fix easily#2018-03-0216:58hlolliOr the third option, i dont make a jar at all and require the npm#2018-03-0216:59thhellerjar for cljs is fine. jar for es6 is experimental but should be fine. jar for commonjs is broken.#2018-03-0217:01hlolliYes, then I dont stress about this, bundle the libcsound when/if emscripten compile better js binding files#2018-03-0217:01thhellerthe problem is that I can't stop closure from rewriting require#2018-03-0217:02thhellerbut it shouldn rewrite require("fs")#2018-03-0217:03hlolliWell, deep in this emscripten js jungle is their own FS bindings. So I could see why this confuses the compiler#2018-03-0217:03hlolliNode 4.x filesystem bindings#2018-03-0217:03thhellernono the problem is that closure rewrites require calls#2018-03-0217:04thhellerand replaces them with direct variable references#2018-03-0217:04thhellerbut it shouldn't rewrite those requires#2018-03-0218:28lilactownit feels like integrating so heavily with google closure was not a good move for CLJS 😞 a lot of problems with CLJS today are caused by it’s dependence on it#2018-03-0219:17thheller@lilactown CLJS does not depend on it at all. I could do everything without the CLJS compiler. Closure is just far beyond every other JS tool out there when it comes to optimizing JS and I personally don't want to give that up.#2018-03-0219:19thhellerwe are just using the closure compiler for things its not yet super optimized to do#2018-03-0219:20thhellerso technically CLJS doesn't have any issues with closure. non-closure-js has.#2018-03-0219:20thhellercould be using babel for that part but I wanted to enable DCE for .js on the classpath#2018-03-0219:20thhellerthat might be a dead-end so I should probably opt out of that for now#2018-03-0219:21thhelleralready opted out for node_modules#2018-03-0317:05chris_johnsonHas anyone followed the instructions in this gist: https://github.com/DogLooksGood/shadow-cljs-with-react-native-note and been successful at getting a thing running in either an iOS simulator or an Android emulator?#2018-03-0318:01thheller@chris_johnson it should work if you use the built-in reload and no REPL. https://github.com/thheller/shadow-cljs/issues/214 should remove the hacks but I didn't yet work on it.#2018-03-0403:47tianshu@chris_johnson following this can make it work with reload and repl #2018-03-0416:43chris_johnsonWell, I followed the directions as closely as I could manage and I got this:#2018-03-0416:57hlolliwhy would cljs.env/*compiler* return nil in the node-repl? required or not#2018-03-0416:58thheller@hlolli this is not self-hosted. inside cljs cljs.env/*compiler* is NEVER initialized#2018-03-0416:59hlolliyup, clear sign I'm trying to run code from lumo 🙂#2018-03-0417:13thhelleryou can get to it inside a macro but I would not advise using it too much#2018-03-0417:14thheller@chris_johnson oops I think I broke it with the last commit I added. that didn't use to be there#2018-03-0417:16thhelleryou can set :devtools {:enabled false} if you want to play around but REPL won't work#2018-03-0417:17thhellerthere are some things to consider for react-native which I haven't yet implemented#2018-03-0417:17thhellerpure :npm-module will work but not the REPL or built-in live reload#2018-03-0417:28hlolliI was asking on #clojurescript about macro namespace reload, but I see now, that shadow-cljs node-repl has automatic macro namespace reload, very nice!#2018-03-0417:29thhellerthat is actually accidental 😛#2018-03-0417:29thhellerusually shadow-cljs clj-repl (require 'that.ns :reload)#2018-03-0417:30hlolliyeh, its nice, because I see that functions I wrote in lumo differ enormously in non-selfhosted node repl. So this macro namespace needs much cleaning, auto reload saveing me potentially some hours.#2018-03-0417:37thhellersince its clojure you can just work on it on a clojure repl#2018-03-0417:37thhellerbut yeah that gets tricky when you want to use cljs.env#2018-03-0417:50chris_johnson@thheller hey no worries, I understand that it’s not meant to be a supported use case yet. I just have a dev lead whose hair is slowly heating to ignition temperature dealing with the friction of our current RN project setup, and another team in this same shop that is having a delightful experience with Shadow so far, so I thought I would spend some time investigating if I could borrow some awesome for my RN team. #2018-03-0417:51chris_johnsonI’m honestly surprised that that turned out to be a bug and not just that I like, cleaned the project or restarted Metro but not hard enough or something like that#2018-03-0417:52chris_johnson“You said ‘rebuild dependency graph’ but I could tell your heart wasn’t in it, so I stopped partway through” — React Native toolchain, late 2017#2018-03-0417:52thhelleryeah just disable the :devtools for not and remove the import of shadow.cljs.devtools.*#2018-03-0417:53thhellerthen it should work fine with the usual built-in RN stuff#2018-03-0417:53thhellercaching is hard 😉#2018-03-0503:53cmalHi, are there any examples to use shadow-cljs do server-side-rendering for NodeJS-Express.js apps?#2018-03-0517:13denik@thheller 😏
shadow-cljs - server starting ...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^C
upgraded shadow-cljs to 2.2.3 and server takes forever to start. Any idea what I might be doing wrong?
#2018-03-0517:14thhellerhmm weird. anything in cat .shadow-cljs/*.log or try shadow-cljs server?
#2018-03-0517:15denikis this a problem: 12:12:10.950 [main] WARN shadow.cljs.devtools.server - TCP Port 9630 in use.#2018-03-0517:16thhellerno it should try the next automatically#2018-03-0517:17denikokay, server errored because the port is in use.#2018-03-0517:17denik
12:16:49.736 [main] WARN shadow.cljs.devtools.server - TCP Port 9630 in use.
12:16:49.736 [main] DEBUG io.undertow - starting undertow server 
#2018-03-0517:17thhellerah doh. I'm not looking at errors in start.#2018-03-0517:18thhellerthats the nrepl port#2018-03-0517:18thhellerthat does not try other ports and fails#2018-03-0517:18thhellerie. conflict with another nrepl port#2018-03-0517:18denikhmm, could only be in use by a previous instance of shadow-cljs#2018-03-0517:19thhellertry shadow-cljs stop#2018-03-0517:19denikalready did#2018-03-0517:19denikis that the kill-all cmd?#2018-03-0517:19denik
... version: 2.2.3
shadow-cljs - server not running
#2018-03-0517:20thhellerhmm yeah you might have an orphan process hanging arround#2018-03-0517:20thhellerjps lists all java processes#2018-03-0517:20thhellerjust kill it#2018-03-0517:21denikhave a few repls running, trying to narrow it down to the shadow-cljs ones#2018-03-0517:21thhellerthere is something weird going on with java processes hanging around when the node process gets killed#2018-03-0517:22thhellerjvisualvm might help#2018-03-0517:22thhelleror connect to the actual nrepl port#2018-03-0517:22thhellerlein nrepl :connect the-port#2018-03-0517:23thhellerand then (System/exit 1)#2018-03-0517:23thhellerlein repl not nrepl#2018-03-0517:26denik@thheller just killed all. Is there a way to link a process back to the execution command? As in all processes started by shadow-cljs *#2018-03-0517:26thhellernot with start as the node process exits#2018-03-0517:27thhellerbesides that I guess jvisualvm is the best option#2018-03-0517:28denikgave a brief look but it was a bit much to get into. killing all was the faster option#2018-03-0520:13hlolliin the node repl I'm getting strange error, that was fixed seemingly while ago for
(defprotocol Fun-Time (drinky-drinky [_]))
i get
IllegalStateException: Can't change/establish root binding of: *unchecked-if* with set
reported here https://groups.google.com/forum/#!msg/clojurescript/__Qf6L40cwU/MP7pTpTFDAAJ I explicitly added the most recent clojurescript as dependency, but this may be clojurescript bug.
#2018-03-0600:21lilactownis there a way to use a different config file than shadow-cljs.edn?#2018-03-0600:22lilactown(I'm trying to conditionally turn on :fs-watch {:watch :polling})#2018-03-0608:09thheller@lilactown you can set it in ~/.shadow-cljs/config.edn. that config will be merged with the one in the project#2018-03-0608:25thheller@hlolli thats a bug in shadow-cljs. just forgot to include the binding for REPL code. fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "493a21282d263e642a25233a097b677b677d"}, :content ("[email protected]")}#2018-03-0612:51mhuebertI’ve just set up one additional module in my project, and am trying to understand the :module-move warnings (dozens of them now appear). The source says ;; only warn when a file is moved to a module it wouldn't be in naturally#2018-03-0612:52mhuebertwould you expect these warnings if, eg. following the guide, one creates an empty :shared module in order to collect common dependencies? then there would be no deps in :shared at all ‘naturally’#2018-03-0612:53mhuebertor would there be something actually wrong, for this warning to appear#2018-03-0613:23mhueberthmm, after upgrading from shadow 2.1.4 to 2.2.4, I am getting a Cannot call a class as a function error at runtime:
shadow$provide.module$node_modules$graphql$language$source = function(g, v, m, r, l) {
    Object.defineProperty(l, "__esModule", {
        value: !0
    });
    l.Source = void 0;
    m("module$node_modules$graphql$jsutils$invariant");
    l.Source = function(a, f, c) {
        throw new TypeError("Cannot call a class as a function");
    }
}
;
#2018-03-0613:46thheller@mhuebert this is due to the newer closure compiler version. it was fixed recently but not released yet. https://github.com/google/closure-compiler/issues/2822#2018-03-0613:46thhelleryou can downgrade the closure compiler manually by adding [com.google.javascript/closure-compiler-unshaded "v20180101"] to your deps#2018-03-0613:48thheller@mhuebert yes :module-move is a bit tricky if you expected things to be moved#2018-03-0613:48mhuebertalright#2018-03-0613:48thhellerits more about printing the information somewhere than a warning#2018-03-0613:49thhellermoving just means that your module structure might not be optimal#2018-03-0613:49thhellergenerally it is not a problem though#2018-03-0613:49thhelleryou can "fix" it by just declaring the namespaces that get moved as :entries for :shared#2018-03-0613:51thhellerthere should be a better diagnostic than :module-move but thats what we have for now#2018-03-0613:52thhelleronly warning it should print if an actual entry you specified gets moved because that might actually be a problem#2018-03-0614:29mhuebertI see.#2018-03-0614:29mhueberthmm.#2018-03-0614:30mhuebertyeah it would make sense to see a message like “32 modules were moved”, and then that was written to a log somewhere#2018-03-0614:31thhelleryeah. moving can be non-obvious but it can be important#2018-03-0614:31thhellerusually isn't so the current solution is definitely too noisy#2018-03-0706:37pithylessRunning 2.2.4, I’m seeing #shadow-hud-loading-container but not seeing #shadow-hud-container if I force a syntax error (just an error in the terminal). Was the HUD changed in some recent version? (I upgraded from a 2.0.x version)#2018-03-0708:04thheller@pithyless didn't change the HUD in a while no (and its working as usual for me)#2018-03-0709:56mhuebertrandom cljs repl question. Quite frequently for whatever reason I get a “REPL Timed out” error (maybe caused by a syntax error or something else). Is there something I should try other than restarting the whole shadow-cljs server to get it working again? refreshing the browser page usually doesn’t work, nor does re-opening a new nrepl connection#2018-03-0709:57thhellerrestarting should never be required#2018-03-0709:57thhellerI recently added (shadow.cljs.devtools.api/reload!) to "restart" the server without restarting the JVM#2018-03-0709:57thhellerbut I'd like to hear more details about the timeout#2018-03-0709:58thhellerprobably a bug somewhere#2018-03-0709:58thhelleralthough one repl timeout shouldn't break the entire connection#2018-03-0709:59mhueberthmm#2018-03-0709:59mhueberti’ll see if i can reproduce something easily#2018-03-0710:00thhellerREPL command timed out. is the error?#2018-03-0710:00mhuebertthat is common yes#2018-03-0710:01mhuebertright now i am already in that state, and I am trying to evaluate :cljs/quit, i see
Error evaluating - class java.lang.InterruptedException: 
Error evaluating - class java.util.concurrent.RejectedExecutionException: Task 
#2018-03-0710:01thhellerhmm did you by any chance call shutdown-agents?#2018-03-0710:02mhueberti don’t think so no#2018-03-0710:02mhuebertwait#2018-03-0710:02mhuebertlet me restart, i don’t know when i quit the node process#2018-03-0710:02mhuebertso ignore this last bit#2018-03-0710:03thhellerrejected means that the pool was shutdown which shouldn't happen during normal eval#2018-03-0710:03thhelleronly thing that would do that is shutdown-agents#2018-03-0710:04mhuebertyeah I think while we were chatting I had already started going through the motions of restarting the thing and forgot#2018-03-0710:09mhuebertso, if I get the timed out error, I should try to :cljs/quit and then (shadow.cljs.devtools.api/reload!)#2018-03-0710:09thhellerfirst I'd like to know the form that caused the timeout#2018-03-0710:10thhellertry to eval something simple like (+ 1 2)#2018-03-0710:10thhellerthen quit/reload maybe#2018-03-0710:10mhuebertok#2018-03-0710:10thhelleris the timeout legit? do you do something that actually takes a long time?#2018-03-0714:12mhuebertno, I think it usually happens when there is some kind of evaluation error#2018-03-0714:12mhueberti will play around and see how i can replicate#2018-03-0718:19justinleeis there a flag to make the development server log requests, perhaps in one of the common log formats?#2018-03-0718:21thhellernot currently. why would you want that?#2018-03-0718:21thhellerit would be like hundreds of JS file requests. not very interesting?#2018-03-0718:22justinleedebugging. sometimes static resources load funny, or i have some kind bug with the way i’m manipulating client-side html5 history. it is nice to know sometimes when my app is actually hitting the server and what it is requesting#2018-03-0718:22thhellerdon't the chrome devtools tell you that?#2018-03-0718:22justinleeallegedly they do.#2018-03-0718:22justinleei can’t figure out why i am apparently loading an image successfully but i get a broken link image#2018-03-0718:23thhellerare you sure the image is getting loaded? I mean with push state you get success for everything although it always the index.html#2018-03-0718:23justinleethe other issue i have is when i’m not at the root level and I manually refresh, the development server doesn’t reserve the app like i would expect#2018-03-0718:24thhellersounds like you are using <script src="some/relative/path.js"> maybe?#2018-03-0718:24justinleeI guess I just wanted to sanity check what the hell was going on by checking the server logs. But you are right, there are other ways to debug this.#2018-03-0718:25justinlee<script src="js/main.js"></script>#2018-03-0718:25thhelleruse /js/main.js. otherwise it will attempt to load something/js/main.js when you are in /something/path#2018-03-0718:26justinleeoh.#2018-03-0718:26justinleeyup that fixed it. 🙂#2018-03-0718:26justinleethe error that happens is truly inscrutable#2018-03-0718:27thhellerwell yeah because you don't get 404s when using pushstate#2018-03-0718:27thhellermaybe I could 404 when .js files are requested#2018-03-0718:27justinleethis is also the problem with my images not loading#2018-03-0718:27thhellerunlikely you are going to use that in html5 history paths#2018-03-0718:27justinleechrome devtools thinks the request was successful#2018-03-0718:28thhellerin chrome you can click open in new tab for the request#2018-03-0718:29thhelleror look at the response preview#2018-03-0718:29thhellerif its html its not an image#2018-03-0718:30thhellerbut in general always use absolute paths to avoid such nightmares 😉#2018-03-0718:32justinleecreate-react-app handles this problem really well. i think they look at the headers. they also have a very convenient proxying feature so that development and deployment look similar when you server the bundle from the api server: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development#2018-03-0718:32justinleei think it is related#2018-03-0718:36thhellerguess I could check the headers#2018-03-0718:46justinleei have dreams of building c-r-a on top of shadow#2018-03-0718:50thhellerhehe why? or which part?#2018-03-0718:50justinleebecause I think its the right way to get an opinionated set of tools going and get people interested in cljs development#2018-03-0718:51thhellershould I just make the push-state thingo the default? kinda feels like it might be the "usual" thing you want for a cljs app#2018-03-0718:51justinleetemplates are terrible and once you use one you can never keep up to date#2018-03-0718:51thhellertrue but whats missing?#2018-03-0718:52thhellerI'm not buying the whole zero-conf argument. I think thats actually a bad idea#2018-03-0718:53justinleeyou just get so much functioning stuff for free with create-react-app. just look at the user manual.#2018-03-0718:54justinleedevelopment, production, testing, instructions on editor integration#2018-03-0718:54justinleezero-config really helps get you going and focusing on what matters#2018-03-0718:55justinleeyou can always eject and customize when you get sophisticated#2018-03-0718:55justinleein my experience, people overestimate the value of customization and underestimate the cognitive load needed to make decisions#2018-03-0718:55justinleeit is great if you are an expert, but it sucks otherwise#2018-03-0718:56justinleeso much of the cljs experience is still in the “use the source, luke” phase#2018-03-0718:56justinleeyou just won’t get anybody but hobbyists and top 1% programmers that way#2018-03-0719:00justinleeeven though I am a big fan of shadow-cljs and tell everyone to use it on slack, there is still something totally amazing about create-react-app. you npm install it, you create a new project, you say npm start, and BAM, you have a working hot reloading project. you can start editing right then and there. shadow is great, but you still have to go read the section on :devtools, pick a directory, make sure you’re setting it right, figure out how the :after-load handler works and install it somewhere, etc. etc. each of these things = friction.#2018-03-0719:01justinleeif you want to do a little experiment in react, it’s super easy because you can just fire off a c-r-a, do some stuff on the main page, and then throw it away#2018-03-0719:01justinleealso, shadow can’t really be opinionated about reagent vs. rum or what have you, whereas a create-reagent-app could#2018-03-0719:02justinleeit could be opinionated about a testing framework#2018-03-0719:02thhellerI'm all for making things easier especially for beginners but I do think that some config is important#2018-03-0719:03thhellerI could certainly simplify the :browser target and introduce some convention around it#2018-03-0719:03thhelleror add something like :browser-simple#2018-03-0719:03thhellerie. just set :app-ns my.app or so#2018-03-0719:04thhellerfrom that is infers my.app/start and my.app/stop as the :after-load and optional :before-load#2018-03-0719:04thhelleralways creates an public/js/main.js#2018-03-0719:04thhellerso no :modules#2018-03-0719:05thhellertesting I have something in the works that makes it zero conf#2018-03-0719:05justinleezero config should be thought of more like “sensible defaults for generic things that most people will want”#2018-03-0719:06justinleeeven with c-r-a you can eject. the only reason they did it that way is that it allows them to update the toolchain from underneath you, which is totally rad.#2018-03-0719:06thhellerwell thats the idea behind shadow-cljs in the first place#2018-03-0719:07justinleeand i think you’ve largely succeeded. the thing is that c-r-a does that one level up on the stack. it picks react, a testing framework, a bundler, give some options for addons like less/sass, etc.#2018-03-0719:08thhellertrue#2018-03-0719:09thhellerwell there could always be :target :reagent#2018-03-0719:09thheller:browser is just generic browser stuff, could totally do framework specific stuff#2018-03-0719:10thhellernot inside shadow-cljs itself but add one dep you are good to go#2018-03-0719:10justinleeone thing that create-react-app did which is quite clever is that they separated out create-react-app, which is a generic tool, from react-scripts#2018-03-0719:11justinleei wonder if shadow-cljs might be able to act as create-react-app and then you could write the react-scripts equivalent for, say, reagent.#2018-03-0719:12justinleesome people just fork react-scripts if they want quasi configuration capabilities. and others have react-scripts variants available#2018-03-0719:12thhellerwell the create-react-app part is just a template really.#2018-03-0719:12thhellerjust most of the template is hidden in react-scripts rather than the template itself#2018-03-0719:12justinleehttps://medium.com/@denis.zhbankov/maintaining-a-fork-of-create-react-app-as-an-alternative-to-ejecting-c555e8eb2b63#2018-03-0719:13justinleeright that’s what i mean.#2018-03-0719:13thhellerI absolutely hate templates as well#2018-03-0719:13thhellerfor this very reason#2018-03-0719:13thhellerthey just get out of sync and then you are F*#2018-03-0719:14justinleeyea and you have no idea what’s going on#2018-03-0719:14justinleethis is a big reason why i think lein ended up hurting the community. people made stuff that is complicated and undocumented but hid it behind a lein template#2018-03-0719:15justinleeits almost too powerful#2018-03-0719:15thheller
{:source-paths
 ["src"]

 :dependencies
 [[reagent/shadow-cljs "1.0.0"]]

 :builds
 {:app {:target :reagent
        :app-ns my.app}}}
#2018-03-0719:15thhellerthis is totalyl doable today without me doing anything#2018-03-0719:16justinleeso what would that script refer to? like, would it know to download something and then run it?#2018-03-0719:17thhellerthe "script" just generates that config#2018-03-0719:17thhellerand creates the matching package.json#2018-03-0719:17thhellerthen runs npm install and prints the usual help stuff#2018-03-0719:18thhellerand of course all the src files#2018-03-0719:18justinleei’m confused. i don’t see any documentation on a :reagent target in the guide. are you saying one can create custom targets?#2018-03-0719:19thhelleryep, custom targets#2018-03-0719:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_custom_targets#2018-03-0719:19thhellernot well documented but you can just delegate to the :browser target for everything in this case#2018-03-0719:20justinleeoh cool#2018-03-0719:20thhellerbasically just generate the usual :browser config from that :target :reagent baseline and call the browser/process fn#2018-03-0719:21thhellerbascially what :reagent means is that shadow-cljs will try to load shadow.build.targets.reagent/process#2018-03-0719:22thhellerhttps://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2018-03-0719:22justinleethis is great! i never really grokked this but shadow-cljs does really emulate c-r-a in structure#2018-03-0719:22thhellerall the default targets are built this way#2018-03-0719:22justinleei mean maybe you came first, but you know what i mean#2018-03-0719:24thhellerI might need to make a few adjustments to the devtools http stuff. this is not as flexible as I'd like it to be.#2018-03-0719:24thhellerbut apart from that everything should work just fine#2018-03-0719:26thheller@hlolli already created a basic chrome extension template this way. https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998#2018-03-0719:27thhellerwhich is basically just :browser with one adjustment to only output a single file in development#2018-03-0719:27justinleeto write cljs and target whatever chrome needs for its extensions?#2018-03-0719:28thhelleronly the JS part the manifest you still have to write#2018-03-0719:28thhellerbut you could also generate the manifest from the shadow-cljs config no problem#2018-03-0719:29thhellerI do want all these targets to exist, eg. :electron, :react-native, etc#2018-03-0719:29thhellerjust have limited time to create/maintain them#2018-03-0719:29thhellerbut they totally do not have to be part of shadow-cljs itself#2018-03-0719:30justinleewould it work if you publish them to clojars and then add them as a dependency?#2018-03-0719:31thheller
{:source-paths
 ["src"]

 :dependencies
 [[reagent/shadow-cljs "1.0.0"]]

 :builds
 {:app {:target :reagent
        :app-ns my.app}}}
#2018-03-0719:31thhellerthats the [reagent/shadow-cljs "1.0.0"]#2018-03-0719:31justinleeoh i see#2018-03-0719:32thhellercan't add it as a dependency to shadow-cljs itself since that would be circular#2018-03-0719:33justinleealso it would make you a gatekeeper of sorts. much better this way so people can just do whatever#2018-03-0719:33thhellerexactly 🙂#2018-03-0719:34justinleei have read of companies forking react-scripts privately so that they can keep their configuration separate and shared internally among their own projects#2018-03-0719:35thhelleryeah you could totally do that with shadow-cljs and a custom :target#2018-03-0719:36thhellermaybe there are other ways to "extend" things I just didn't think of yet#2018-03-0719:37thhellershadow-cljs clj-run reagent.quick-start#2018-03-0719:37thhellersome clojure ns that does all the bootstrapping and starts whatever you need#2018-03-0719:46justinleewell i’ll play with this a bit later. i think its a neat idea#2018-03-0719:50thhellera more focused :target could definitely set way more aggressive defaults than :browser can. and since its just clojure data you could just generate the more complex :browser config from the "easy" one.#2018-03-0720:19thheller@lee.justin.m just pushed 2.2.5 which makes push-state the default and does the Accept header check to no longer serve images as html#2018-03-0720:20justinleevery nice! thanks#2018-03-0811:42raymcdermott@thheller regarding testing I was really wanting to check that I couldn’t ‘program’ that behaviour in some way from the available tools#2018-03-0811:42thhelleryou can with the karma or browser-test stuff#2018-03-0811:42raymcdermott(original question … can I run tests on node,js after a file has changed?)#2018-03-0811:42thhellerbut for node not yet#2018-03-0811:43raymcdermottok, fair enough …. like I say I can wait if you have something in the works#2018-03-0811:44thhelleryou can use anything that watches files really#2018-03-0811:44raymcdermottI might end up installing another set of tools but would rather avoid it if poss#2018-03-0811:44raymcdermottthat’s true#2018-03-0811:44thhellerhttps://github.com/remy/nodemon also works#2018-03-0811:46thhellerthe chokidar thing works well enough and just just an yarn add chokidar-cli --dev away#2018-03-0811:46raymcdermottok, thanks for the options#2018-03-0811:52raymcdermottcan I link that into the shadow-cljs server#2018-03-0811:53raymcdermottor do I just kick off a build / node test?#2018-03-0811:53raymcdermott(with chokidar)#2018-03-0811:53raymcdermott(assuming the latter)#2018-03-0811:54thhelleryou can run any clojure code via shadow-cljs clj-run some.ns/fn#2018-03-0811:55thhellerso you could write a clojure fn that starts the chokidar process#2018-03-0811:55thhelleror even just do it in pure clojure without chokidar#2018-03-0811:59thheller@raymcdermott what do you usually use to do this? maybe I can steal some ideas.#2018-03-0812:00raymcdermotthonestly I usually just use cursive and run the tests as I go along in the REPL#2018-03-0812:00raymcdermottbut that doesn’t work so well for CLJS#2018-03-0812:01thhelleryeah same here. I do that all the time for CLJ. probably not doing many tests for CLJS since I can't do it there#2018-03-0812:01raymcdermottin short, I’ve got nothing 😉#2018-03-0812:02thhellerwhat I can offer you is that I just add a simple option that just runs node when a build completes#2018-03-0812:29thheller@raymcdermott in 2.2.6 you can do
{:target :node-test
 :autorun true
 :output-to "out/demo-test-node/script.js"}
#2018-03-0812:29thhellerjust runs node out/demo-test-node/script.js when the build completes#2018-03-0812:29raymcdermottthat would be plenty good enough#2018-03-0812:30thhelleryeah seemed silly to use another tool for this#2018-03-0812:31thhelleryou can use :ns-regexp "some.ns-test" to only run the test ns you care about (instead of all -test)#2018-03-0812:31raymcdermottesp since you have all the mechanics there already#2018-03-0812:33thhellerthere is some backstory to testing https://github.com/thheller/shadow-cljs/issues/57. so I had the autorun thing before but removed it because it didn't make sense in many other testing scenarios (eg. browser-test, karma). but now that they are different targets it really makes sense for :node-test#2018-03-0812:33raymcdermottwow, nice#2018-03-0812:33thhellerthe thing I'm working on is a gui that lets you select which test-ns or singular test you care about#2018-03-0812:33thhellerand then auto runs those in the browser or node#2018-03-0812:35thhellertoo many plans not enough time though 😉#2018-03-0812:35thheller:autorun should be an ok temp solution#2018-03-0812:35raymcdermotton a purely selfish note, works for me 🙂#2018-03-0812:41raymcdermottso assuming this…#2018-03-0812:43raymcdermottwhat does the autorun? the build server watching the files?#2018-03-0812:43thhellerwhatever is running the watch#2018-03-0812:43raymcdermottin other words would now shadow-cljs watch script be enough?#2018-03-0812:43thhelleryep#2018-03-0812:44raymcdermottdo you have an idea when will that be available?#2018-03-0812:44thhellernow with the 2.2.6 release#2018-03-0812:46raymcdermottso I can just npm update … cool!#2018-03-0812:46thhelleryep#2018-03-0812:47thhelleroh wait shadow-cljs watch script would not be enough. shadow-cljs watch script test would. or second shadow-cljs watch test process#2018-03-0812:47thhellerbut I guess you meant watch test#2018-03-0812:47raymcdermottok, I’ll give it a spin#2018-03-0812:48thhellerwhat also works is making a REPL command in Cursive for (shadow.cljs.devtools.api/compile :test)#2018-03-0812:48thhellerthen bind it to a key to run tests on demand rather than watch#2018-03-0812:50raymcdermottok, good to know - I’ll try that out too#2018-03-0812:57raymcdermotthmmm nothing happening, watch seems to do nothing#2018-03-0812:57raymcdermotteven on standard builds#2018-03-0812:57thheller@raymcdermott btw :optimizations only applies to release builds. so :none is actually invalid. :none is enforced for watch and compile always so you do not need to set it to :none ever.#2018-03-0812:57raymcdermottdo I have to do a standard build first?#2018-03-0812:57thhellerdid you restart the server? after updating?#2018-03-0812:58raymcdermottI’ll shut up#2018-03-0812:59thhellerthere might be an issue with the output and where it ends up#2018-03-0812:59raymcdermottshadow-cljs - error ENOENT: no such file or directory, open '.shadow-cljs/logging.properties'#2018-03-0813:00thhellerhmm odd. this was supposed to be fixed.#2018-03-0813:00raymcdermottseems like it needs something new#2018-03-0813:00thhellerwhat did you run?#2018-03-0813:01raymcdermottshadow-cljs watch script test#2018-03-0813:02thhellerand there really is no .shadow-cljs/logging.properties?#2018-03-0813:03raymcdermottwrong folder!#2018-03-0813:03thhelleroh. its supposed to be smart about that#2018-03-0813:04raymcdermottoh well, in the top dir it’s working#2018-03-0813:05thhellernext version it will work in nested folders as well 😉#2018-03-0813:08raymcdermottI feel less dumb now 🙂#2018-03-0818:47claudiuif I only use semantic-ui (seems to work well with the default compiler) would you still recommend going with shadow-cljs for the project ?#2018-03-0818:59thhellerof course!#2018-03-0818:59thhellerwhy would you want to run anything else 😉#2018-03-0819:05claudiu🙂#2018-03-0819:19dominicm@thheller we previous discussed not embedding shadow into a running project, If I used something like https://github.com/RutledgePaulV/clj-embed except without the isolation (you can access cljs/clj files from the parent classloader) do you see any reason why this would be ill advised?#2018-03-0819:21thhellerits perfectly fine to embed shadow in a project. I just don't recommend doing so since you are then in charge of resolving conflicts and such and the tool can't help you with that.#2018-03-0819:22thhellerclj-embed you might as well start a new JVM since you'll be paying the full startup cost for the isolation#2018-03-0819:23thhelleryou can't not-isolate the clojure runtime#2018-03-0819:24thhelleryou can't "fork" it#2018-03-0819:24dominicmThe benefit is simpler running for developers, without the conflicts. The startup cost isn't what I'm avoiding, it's the complex "start this, then that". Hmm, I will have to ensure that piggieback is happy to work cross-classloader. I'm not certain it will be.#2018-03-0819:24thhellerstart one thing for clojure and another thing for clojurescript seems perfectly reasonable#2018-03-0819:25dominicmSorry, I was referring to being able to access the parent classloader. I know clojure.lang.RT must be isolated.#2018-03-0819:25thhelleryou can't share the parent classloader#2018-03-0819:25thhellerclojure just doesn't work this way#2018-03-0819:27dominicmI think we're misunderstanding each other. I'm referring to having clj-embed have an embedded version of clojure, but being able to access files on the classpath of the parent, so that cljs compilation can happen as normal.#2018-03-0819:28thhellerbut the clojure stuff does not need the CLJS deps#2018-03-0819:29dominicmNo, that's correct.#2018-03-0819:30thhellerclj-embed also doesn't allow using the parent classloader IIRC?#2018-03-0819:31thhellerI guess I don't really understand what your goal is#2018-03-0819:31dominicmIt doesn't, but the code is relatively short, and changing that is simply switching a flag.#2018-03-0819:31thhellerif you expose the parent classloader you have to deal with the same conflicts you'd have when just embedding#2018-03-0819:32thhelleryes but this flag is what makes it work in the first place#2018-03-0819:32dominicmNot quite, because the local classloader gets priority.#2018-03-0819:32thhellerif you switch it nothing works anymore#2018-03-0819:32dominicmThe different version of immutant isn't loaded into the nested container, as the local one gets priority.#2018-03-0819:34dominicmEssentially, the idea is to minimize friction to running the project. Having the cljs load with cider's jack-in is very useful for emacs users who are used to that. Same for ProtoREPL's "Start REPL" etc.#2018-03-0819:39thhellerI honestly don't know what a good approach for all of this is. All tools seem to treat CLJS like CLJ but it just isn't the same. Things work differently in almost all aspects.#2018-03-0819:40thhellerso sure you can all do it over one process just fine. the only downside is having to deal with conflicts manually.#2018-03-0819:40thhellerbesides that it works just fine#2018-03-0822:43ddrbtHi, I'm trying to write a boot task for shadow-cljs. Can I programmatically set the :output-to and :output-dir options?
#2018-03-0905:19ddrbtLooking at this:
(defn compile* [build-config opts]
  (util/print-build-start build-config)
  (-> (util/new-build build-config :dev opts)
      (build/configure :dev build-config)
      (build/compile)
      (build/flush)
      (build-finish build-config)))
#2018-03-0905:22ddrbtWhere should I look to see where :output-to and :output-dir are getting set?#2018-03-0908:58thheller@ddrbt it is up to each individual target to control where output goes most targets set :build-options :output-dir to a java.io.File instance#2018-03-0916:19ddrbtPerfect! Thanks. Thinking of a PR: is opts special or can I pass in something like:
(shadow/compile :app
                     {:build-options {:output-to  "mypath/public/js"
                                      :output-dir "mypath/public/js"}})
?
#2018-03-0916:22ddrbtand then do
(defn compile* [build-config opts]
      ...
      (build/deep-merge opts)
      (build/flush)
      ...
      )))
#2018-03-0908:59thhellerusually only flush should write output so you could set it like this#2018-03-0908:59thheller
(defn compile* [build-config opts]
  (util/print-build-start build-config)
  (-> (util/new-build build-config :dev opts)
    (build/configure :dev build-config)
    (build/compile)
    (assoc-in [:build-options :output-dir] (io/file "somewhere"))
    (build/flush)
    (build-finish build-config)))
#2018-03-0909:00thhellercache files are a bit different but you probably don't need to touch that#2018-03-0911:02davidwI'm looking at switching our project over to shadow-cljs because it solves issues we're having using npm packages with cljsbuild. So far I can't see any reason not to move, pretty much everything seems to work the same or better. But experience tells me there can't be no down side at all. What are the trade-offs when using shadow-cljs?#2018-03-0911:46thheller@davidw I guess the biggest downside currently is that pretty much all editors/tools expect you to use leiningen. so if you want to use the standalone version of shadow-cljs you have to jump through a few hoops to make it work or use it via lein.#2018-03-0911:47thhellerbesides that I haven't used any other CLJS tools since 2013 and I can say with confidence that it fixes a whole lot of issues that are still present in standard CLJS#2018-03-0912:03davidwok. It certainly looks to fix the issues I've been having. I'll give a try and see how it goes. Thanks.#2018-03-0912:03davidwThis might be a stupid question because I don't know exactly how it works but could there ever be a situation in the future where some language feature was added to cljs that wouldn't work with shadow-cljs?#2018-03-0912:03thhellerno.#2018-03-0912:04davidwgreat#2018-03-0912:05thhellerin more than one instances features actually came to shadow-cljs before coming to CLJS itself#2018-03-0912:06thhellerbut language features itself should all be supported always since we are just using the same analyzer/compiler#2018-03-0912:07davidwthat's what I thought but wanted to double check.#2018-03-0912:14thhellerfeel free to ask questions if anything is unclear. helps me figure out what issues people run into when transitioning from other tools.#2018-03-0912:15davidwthanks, I will do.#2018-03-0912:19davidwif I do shadow-cljs watch app should that pick up changes to the dependencies in shadow-cljs.edn?#2018-03-0912:20thheller:dependencies currently require a restart. I have some plans to fix that but its not finished yet.#2018-03-0912:20thhellerbuild config changes will be picked up automatically#2018-03-0912:21davidwI see#2018-03-0913:28davidwI'm seeing some strange behaviour with devcards. The cards display ok but don't auto reload unless I add :after-load to the :devtools config. Even if the it points to a function that does nothing.#2018-03-0913:54thheller@davidw you can also set :autoload true. autoload is not enabled by default.#2018-03-0913:54thhellerI guess I should enable it by default to match figwheel. many people seem to expect that.#2018-03-0913:55davidwah, ok. I was confused because the little icon appears. I thought it was autoloading.#2018-03-0913:57davidwSo what does the little spinner icon signify then? if it's not that the code as been updated?#2018-03-0913:58thhellercomes in when the build starts and fades out when the build succeeds#2018-03-0913:59davidwok so it just tells you there's been a build, not that the build has been loaded?#2018-03-0914:03thhellerit is currently not coupled to the loading since we can't reliably say when the loading is completed due to async stuff you might be doing in :after-load#2018-03-0914:04thhellerbut if autoload is enabled it will most likely be finished before the icon disappears#2018-03-0914:04thhellersince the animation takes a bit of time#2018-03-0914:04thhellerI never considered the fact that the loading anim shows even when autoload is disabled#2018-03-0914:05davidwyes that seems strange to me#2018-03-0914:05davidwit really suggests that I'm getting the latest changes when icon is displayed.#2018-03-0914:06thhelleryes, but what seems strange to you is that autoload is not enabled by default.#2018-03-0914:06thhellerif it was enabled by default you'd probably never notice#2018-03-0914:06thhellerthe reason why its not enabled by default is simple#2018-03-0914:07thhellerI still have some code in production that does not use react#2018-03-0914:07thhellerautoloading only really works if you use react otherwise it can cause problems#2018-03-0914:07thhellerbut I guess I should enable it by default just because of figwheel#2018-03-0914:08thhellersames to be the more optimal choice given what people expect#2018-03-0914:09davidwno, I don't think that's what's strange. if I was changing the code I didn't see the icon I would assume it's not autoloading and go look for how to turn it on. it's more that if the browser that I'm looking at isn't getting changes why have the icon show at all?#2018-03-0914:09davidwand also why have the websocket connection?#2018-03-0914:09thhellerREPL#2018-03-0914:09davidwas soon as I pressed enter that popped into my head 🙂#2018-03-0914:09davidwof course#2018-03-0914:10thhelleralso you will still see warnings and errors even with autoload disabled#2018-03-0914:10davidwcool#2018-03-0916:50mhuebertIs there a way to indicate to shadow whether to use yarn or npm for installing packages it finds in deps.cljs files in dependencies?#2018-03-0916:57mhueberttrying to figure out how to manage JS dependencies that are pulled in from other deps. let’s say I am requiring library "a", and it only comes from some library Lib my app depends on. step 1, first compile: shadow-cljs installs version 1 of "a" because that is what is listed in a deps.cljs file in Lib. This is added to the local package.json. step 2: Lib updates their deps file to version 1.1 of "a". step 3: after upgrading to new version of Lib, we compile again. The local, auto-installed version of "a" will not be upgraded, but a warning is printed. I think the only thing one can do here is manually update the local package.json file whenever a warning like this appears?#2018-03-0917:55colindresjThat’s what I’ve been doing @mhuebert, I hope there’s a better way, but haven’t spent the time to investigate#2018-03-0917:56colindresjAny time I see the warning I pretty much just yarn remove a then run shadow again#2018-03-0918:23justinleeshouldn’t i be able to change ["react-dnd-html5-backend" :default HTML5Backend] into [react-dnd-html5-backend :as react-dnd-html5-backend :refer (default) :rename {default HTML5Backend}]? When I do that, I get a perplexing runtime error: Uncaught ReferenceError: react_dnd_html5_backend is not defined on this line of code (react-dnd/DragDropContext HTML5Backend). I’m confused that it complains about react_dnd_html5_backend instead of complaining about default or HTML5Backend maybe.#2018-03-0918:25justinleehm well just referring to react_dnd_html5_backend/default works, so nevermind#2018-03-0919:47theaspI don't recall seeing these before, but everything seems to work regardless:
------ WARNING #1 --------------------------------------------------------------
 File: bide/impl/helpers.js:29:41

 variable toString is undeclared
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/cognitect/transit.js:649:8

 variable module is undeclared
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/impl/writer.js:256:8

 variable isObject is undeclared
---------------------------------------
#2018-03-0920:04theaspnm, doesn't happen in 2.2.6#2018-03-0921:44thheller@theasp the bide warning ios definitely correct. https://github.com/funcool/bide/blob/master/src/bide/impl/helpers.js#L29 toString is not declared. the transit warnings are also correct but its in conditional node code so it doesn't matter much.#2018-03-0921:46theaspshadow-cljs ftw#2018-03-0921:48theaspI hate how common things like this are: '[object Array]' == toString.call(val)#2018-03-0921:50thheller@mhuebert conflict resolution with :npm-deps is icky. yarn will be used if a yarn.lock exists. there is this obscure and totally not official :node-modules {:managed-by :yarn} setting you can set in the shadow-cljs.edn top level as well.#2018-03-0921:51thheller@lee.justin.m shadow-cljs complains like this?#2018-03-0921:53justinlee@thheller shadow-cljs compiled it just fine. the error i got was runtime#2018-03-0921:54justinleeit’s not a big deal because using the default property is really fine#2018-03-0921:54justinleei don’t want to use the string literal requires because it stops my linter from working#2018-03-0921:58thhellerthere is definitely something weird going on with the rename#2018-03-0921:58thhellerplease open a github issue so I don't forget#2018-03-0921:58justinleeokay sure#2018-03-0922:01justinleedone#2018-03-1018:35thosmosjust looking into building an electron app with cljs. came across electron-forge (https://electronforge.io/templates) and am thinking it would be amazing if there were a CLJS option on that page, or at least if there were a 3rd party CLJS template that could be used with it. I'm thinking shadow-cljs would probably have the best integration with its nodejs-based tooling. Thoughts?#2018-03-1021:24mjmeintjesI'm experiencing a really annoying issue with shadow-cljs 2.2.6 and nodejs. Basically, any time after switching into a project namespace (using in-ns), restarting the nodejs app throws an "No reader function for tag object." warning/error. Everything still works, but with one of my scripts the error message takes around 30 seconds to print because it seems to be dumping all of the compiler state. I have built a small github repo to demonstrate the issue. I can open a github issue if you want, just thought I'd bring it up here first to see if it is something that I'm doing wrong. https://github.com/mjmeintjes/shadow-cljs-nodejs-bug#2018-03-1021:43mjmeintjesI've added a bug report here: https://github.com/thheller/shadow-cljs/issues/219#2018-03-1021:45mjmeintjesPS - I love the fact that I can just override single files from dependencies, including shadow-cljs, by just adding the file in the right place to my project. Makes investigating (and temporarily fixing) 3rd party bugs so much easier!#2018-03-1022:57thheller@thosmos I haven't done any real electron development, only basic tests. I know that it works well enough but I don't know how a real life app would look and what shadow-cljs could do to help with that. is there a good demo app for electron in CLJS or pure JS?#2018-03-1103:01Jonhttps://github.com/shadow-cljs/shadow-cljs.org/issues/3#2018-03-1113:29jtthIs there a kind of demo repo where I can try, say, loading up Rum from clojars and /cdn-cgi/l/email-protection from npm (https://material-ui-next.com/getting-started/installation/) together and just start throwing stuff together, or do I have to build out a config first?#2018-03-1113:53jtthAh, I found one: https://github.com/thheller/shadow-cljs-examples/tree/master/browser#2018-03-1115:57Jonis shadow.cljs.devtools.client.hud turned on by default now?#2018-03-1115:59Jonjust tried. No. thought it was on during reading https://shadow-cljs.github.io/docs/UsersGuide.html#hud#2018-03-1117:11justinlee@jiyinyiyong it is on for me by default for a browser target#2018-03-1117:20thheller@jiyinyiyong should be enabled by default for :browser yes#2018-03-1117:21thheller@jtth https://github.com/shadow-cljs/quickstart-browser also works. there is also https://github.com/mhuebert/shadow-re-frame and https://github.com/jacekschae/shadow-reagent#2018-03-1209:01orestisI have been doing some electron work in plain JS recently — one side is the “server” side which is Node with some extra electron APIs you require. The other side is the client side with also some extra APIs. I think it could be treated as just two separate targets…#2018-03-1210:28mhuebertWould anyone else also find it useful to be able to specify a vector of functions for :before-load and :after-load in devtools options?#2018-03-1210:30mhuebertI end up making on-reload! functions which only exist to trigger cleanup/reset behaviour from namespaces which have no other relationship to each other#2018-03-1210:52thheller@orestis wasn't the browser/renderer side also able to use require?#2018-03-1210:53orestis@thheller I think so, yes — but I haven’t dug that deep yet.#2018-03-1210:53orestisIIRC you are able to require the electron APIs from both sides, but the browser side gets access to the “remote” part of that.#2018-03-1210:53orestisSo some kind of built-in RPC I think.#2018-03-1210:54orestisI’m not sure how that works, but for shadow to do its thing you should just be able to expose a require function, no?#2018-03-1210:54thheller@mhuebert I could certainly add that but it sounds like you have some global state that needs refreshing? global state is tricky when it comes to reloading.#2018-03-1210:55orestisI might toy around with shadow and electron today as a break.#2018-03-1210:56thheller@orestis either way you can definitely build something with shadow. if require is possible you might get away with one build instead of two though.#2018-03-1210:57mhuebert@thheller the 3 things I currently do on reload are (1) clear a global error state which is set when a react component throws, (2) re-render react component tree from root, and (3) I have a logging lib which uses logging groups, and open groups need to be closed on refresh#2018-03-1210:57orestisI’ll have to check and see what the assumptions are — because one side is definitely no-browser, whereas the other side yes-browser.#2018-03-1210:57thheller@mhuebert you could do this in :before-load maybe?#2018-03-1210:58mhuebert@thheller I think if i would clear the error state before load, that would trigger a re-render before the new (possibly-fixed) views have been loaded#2018-03-1210:59mhuebertthe logging stuff could be though#2018-03-1211:00thhellerand just calling the other on-reload! fns directly from your one on-reload! doesn't work?#2018-03-1211:01mhuebertthat does, it was just mildly awkward because i didn’t have any existing namespace which could require all of the namespaces which had functions to be called#2018-03-1211:01mhuebertso i had to create a separate thing in a utility library which all of these namespaces could then require, and register on-load functions#2018-03-1211:02mhueberteg
(defonce on-reload* (atom {}))

(defn on-reload
  "Register a callback to fire when page reloads (during development)"
  [key f]
  (swap! on-reload* assoc key f))

(defn reload!
  "Fire registered reload callbacks"
  []
  (doseq [f (vals @on-reload*)]
    (f)))
#2018-03-1211:02thhellerthe trouble with a vector of multiple :after-load fns is that it can't control async#2018-03-1211:03mhuebertright#2018-03-1211:03mhueberti wasn’t thinking about that for my case#2018-03-1211:04mhuebertthis will be fine for now#2018-03-1211:05thhellerI was thinking about this zero-conf stuff a bit. we could certainly have some other ways to configure these hooks#2018-03-1211:05thhellereg. (ns my.awesome.stuff {:shadow/after-load some-fn-in-this-ns} ...)#2018-03-1211:06thhellerns meta doesn't hurt since it doesn't end up in optimized code#2018-03-1211:06mhuebertas a library author, if someone uses re-view it would be nice to say “and add re-view.render-loop/render to your :after-load option”#2018-03-1211:06mhuebertoh#2018-03-1211:06mhuebertyeah that would be cool#2018-03-1211:06mhuebertbetter than having to give instructions#2018-03-1211:07thhellercould also just put it on the fn itself#2018-03-1211:07thheller(defn ^:shadow/after-load on-reload! [] ...)#2018-03-1211:08thhellercompiler could even be smart and just ignore those fns when compiling release builds#2018-03-1211:09mhueberti guess the downside is that for a library that is less good, as you don’t want to impose specific tooling on users. not that metadata imposes it, but you don’t want (defn ^:shadow/after-load , ^:figwheel/after-load ...) (*I can’t remember what metadata figwheel all uses, i remember something like ^:figwheel-always)#2018-03-1211:09thhellersure we could do something generic that other tools could support as well#2018-03-1211:12thhellerI think this is only an issue with global state though which you shouldn't have in the first place 😛#2018-03-1211:12mhueberthaha. in a dream world#2018-03-1211:13thhellerhehe yeah#2018-03-1211:17thhellerI always unmount in :before-load just to avoid things interfering with reload#2018-03-1215:35tianshuseems there're two styles for configuration for clojure now lein style and tools.deps style: paths vs source-paths, deps vs dependencies, repos vs repositories. will it be a good idea to support both or insisting on the lein style or just like user use tools.deps with shadow-cljs?#2018-03-1216:12thheller@doglooksgood don't know about allowing two different styles in shadow-cljs.edn itself but maybe#2018-03-1409:40mhuebertweird edge case I just found: I had a .cljc namespace which used defmacro, but did not include a (:require-macros [...self...]) in the ns form. this was in a utility library I used in Maria. Whenever I would compile the ‘browser’ build and the ‘bootstrap’ build together, this still worked as expected, so I had no idea I had even made a mistake. But if I would compile the ‘browser’ build independently from the ‘bootstrap’ build, I wouldn’t get a warning, but cljs would treat the defmacro as a function and return the unevaluated form.#2018-03-1409:42mhuebertIt only showed up when I split these builds for circleci (I’m using tools.deps now, and that increases memory usage, so I can’t compile all the builds in one step anymore)#2018-03-1409:45thhellerwhy does tools.deps increase memory usage?#2018-03-1409:45mhuebertno idea#2018-03-1409:45mhuebertthe good news is that you get a proper exception on circle when it fails#2018-03-1409:45thhellerah right you limited the memory via jvm-opts. those are probably not yet passed onto tools.deps#2018-03-1409:47thhellerI don't know about the defmacro thing. one build should not affect the other since they are completely isolated#2018-03-1409:47mhuebert
[:bootstrap] Compiling ...[:live] Compiling ...[:trusted] Compiling ...


/usr/local/bin/clojure: line 342:   316 Killed                  "$JAVA_CMD" "${jvm_cache_opts[@]}" "${jvm_opts[@]}" -classpath "$cp" clojure.main "${main_cache_opts[@]}" "
#2018-03-1409:47mhuebertI really have no idea, but I could reproduce it#2018-03-1409:48mhuebertlocally and on the server#2018-03-1409:48mhuebertafter I finally figured out what was happening#2018-03-1409:48thhellerwell they do share the same clojure vm instance. so if one defines a var the other can see it#2018-03-1409:48thhellerbut both builds should always check if the defmacro is properly required#2018-03-1409:49thhellerdefmacro in .cljc files without being hidden in a conditional is scarily common#2018-03-1409:50thhellerah right ... the warning does only check if the var exists#2018-03-1409:50thhellerbut the var exists#2018-03-1409:50mhuebertthe macro is in util, a cljc file, and I was requiring it from another cljc file#2018-03-1409:50thhellerso it doesn't warn#2018-03-1409:51mhuebertso basically macros in cljc files should always be in a #?(:clj …)#2018-03-1409:51thhellerso if you (util/the-thing ...) it just calls it as a function#2018-03-1409:52thhelleryes, unless you care about self-host in which case I don't have an easy answer for oyu#2018-03-1409:52mhueberti think that’s fine with self host?#2018-03-1409:52thhellerno self host reads .cljc files with :cljs#2018-03-1409:53mhuebertoh, right.#2018-03-1409:53mhuebertmacrovich is probably the answer#2018-03-1409:53thhellernot really. same problem.#2018-03-1409:54mhuebert
(defmacro deftime
  "This block will only be evaluated at the correct time for macro definition, at other times its content
   are removed.
   For Clojure it always behaves like a `do` block.
   For Clojurescript/JVM the block is only visible to Clojure.
   For self-hosted Clojurescript the block is only visible when defining macros in the pseudo-namespace."
  [& body]
  (when #?(:clj (not (:ns &env)) :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))
    `(do 
#2018-03-1409:54mhuebertwould that not work?#2018-03-1409:54thhellerah right. its not doing this via read-cond#2018-03-1409:54thhellerso yes that works#2018-03-1409:55mhuebertincidentally this util macro itself uses macrovich, to use keyword-identical? for cljs and identical? for clj#2018-03-1409:57thhellerdoes your build actually work when running both builds? or does it just not complain?#2018-03-1409:57mhuebertit works#2018-03-1409:57mhuebertexpands the macro#2018-03-1409:57thhellerah right thats the cljs compiler doing that#2018-03-1409:58thhellerhttps://dev.clojure.org/jira/browse/CLJS-2454#2018-03-1409:58thhellerI don't think I can do anything here#2018-03-1409:59thhellerI don't know if you meant to call a fn or a macro when doing (util/the-thing ...)#2018-03-1409:59thhellerthe var exists because defmacro creates it#2018-03-1409:59thhellerI can probably complain when you defmacro in cljs though#2018-03-1410:00thhellerthats just never correct#2018-03-1410:00mhuebertexcept in self-host?#2018-03-1410:01thhellerhmm right#2018-03-1410:01thhellerwell I can just ignore it when compiling normal cljs#2018-03-1410:02thhellerI mean just don't compile it. so you'd at least get a undeclared var warning#2018-03-1410:04mhuebertright#2018-03-1410:05mhuebertbecause you know when you are compiling normal cljs vs. bootstrapped-macro-mode#2018-03-1410:05thhellerexactly#2018-03-1410:10thheller
------ WARNING #1 --------------------------------------------------------------
 File: C:\Users\thheller\code\shadow-cljs\src\dev\demo\browser.cljs:24:2
--------------------------------------------------------------------------------
  21 | (defmacro dummy-macro [& body]
  22 |   (prn :foo))
  23 | 
  24 | (dummy-macro 1 2 3)
--------^-----------------------------------------------------------------------
 Use of undeclared Var demo.browser/dummy-macro
--------------------------------------------------------------------------------
#2018-03-1410:12thhellermakes sense I guess although the warning is a little bit weird since the defmacro is right there 😛#2018-03-1410:19thhellerkinda weird CLJS doesn't already do this by default#2018-03-1410:20mhuebertyeah that looks good#2018-03-1410:21mhuebertwould have saved me a couple hours of debugging#2018-03-1410:21mhuebertit’s the non-locality that made it so weird. not requiring a clj namespace in one part of the project suddenly means that a cljs namespace somewhere else treats a macro like a function#2018-03-1410:23thhelleryeah it is definitely a weird issue. I blame https://dev.clojure.org/jira/browse/CLJS-2454 for not properly checking if macros are actually referred and blindly using them. defmacro is also to blame though.#2018-03-1410:23mhuebertyes i added a vote to that issue#2018-03-1410:26thhellerI wonder if there a legit reasons for keeping the defmacro but I can't think of any#2018-03-1410:28thheller@mhuebert just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "37445f565358401a545b5d4477051905190e"}, :content ("[email protected]")}. it probably breaks all the self-host stuff. please test.#2018-03-1410:28mhuebertok#2018-03-1410:29thhellerI mean it shouldn't break anything but self-host has proven me wrong more than once#2018-03-1410:29mhuebertanything in particular to look out for?#2018-03-1410:29thhellercompile warnings I guess#2018-03-1410:32mhuebertall looks good#2018-03-1410:32mhuebertjust the usual:
------ WARNING #1 --------------------------------------------------------------
 File: cljs/spec/test/alpha$macros.cljc:113:35
--------------------------------------------------------------------------------
 110 |   ([xs]
 111 |    `(instrument ~xs nil))
 112 |   ([sym-or-syms opts]
 113 |    (let [syms (sym-or-syms->syms (eval sym-or-syms))
-----------------------------------------^--------------------------------------
 Use of undeclared Var cljs.spec.test.alpha$macros/eval
--------------------------------------------------------------------------------
 114 |          opts-sym (gensym "opts")]
 115 |      `(let [~opts-sym ~opts]
 116 |         (reduce
 117 |           (fn [ret# [_# f#]]
---------------------------------------
#2018-03-1410:32mhuebertcan they not declare that?#2018-03-1410:33thhelleris that a known issue? I mean this doesn't work right?#2018-03-1410:33mhuebertthey set! eval later#2018-03-1410:34mhuebertis what is said on a slack log somewhere#2018-03-1410:35thhellerno idea what that means#2018-03-1410:37thhellercan't find where eval is set!#2018-03-1410:57fbielejec@thheller gotcha#2018-03-1410:58thheller@fbielejec I think cider-jack-in starts a new lein process, so it won't find the one started by shadow-cljs watch#2018-03-1410:58thhelleryou can instead start the embedded version in the cider repl#2018-03-1410:58fbielejecright, it's equivalent to lein repl basically, starts an nrepl session#2018-03-1410:59thhellerso you can do this https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2018-03-1411:00thheller
(require '[shadow.cljs.devtools.server :as server])
(server/start!)
(require '[shadow.cljs.devtools.api :as shadow])
(shadow/watch :foo)
(shadow/nrepl-select :foo)
#2018-03-1411:00fbielejeccan I invoke a watcher like this too? e.g.
(shadow.cljs.devtools.server/start!)
      (shadow.cljs.devtools.api/watch :dev)
      (shadow.cljs.devtools.api/nrepl-select :dev)
#2018-03-1411:00fbielejecwrote at the same time, nevermind#2018-03-1411:01thhellerbtw :dev is a built-in concept of shadow-cljs. every build has a dev and release mode#2018-03-1411:01fbielejecso I better not call the build-id :dev?#2018-03-1411:01thhelleryou can call it whatever but it doesn't make much sense yes#2018-03-1411:02thhellerin figwheel&co you actually have a different build for release#2018-03-1411:02thhellerin shadow-cljs its just shadow-cljs release the-build or shadow-cljs watch the-build#2018-03-1411:03fbielejecgotcha#2018-03-1411:03thhellerI need to document this better, I see this a lot 🙂#2018-03-1411:04fbielejecit's just scattered a bit, but the fact I can get npm packages working out of the box is worth spending some time searching 🙂 It's awesome.#2018-03-1411:06fbielejecOk, so I killed the watcher in the terminal, create a user ns with these invocations#2018-03-1411:06fbielejec
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server running at 
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "cljs-0x-connect.dev" is not available.

To quit, type: :cljs/quit
[:selected :app]
mar 14, 2018 12:02:49 PM clojure.tools.logging$eval8628$fn__8631 invoke
WARNING: stale websocket client, no worker for build :dev
#2018-03-1411:07fbielejecbut I do get the build served in the browser#2018-03-1411:07fbielejecno cljs REPL though#2018-03-1411:07thhellerdid you use :lein true in your shadow-cljs.edn?#2018-03-1411:07thhellerthe http server is independent of the build#2018-03-1411:07fbielejecyes, it''s probably a stale version served#2018-03-1411:10fbielejecyes I have :lein true.#2018-03-1411:10fbielejecWhat's curious is that it keeps me in clj REPL#2018-03-1411:11thhellerwondering why you get the build failure? did it work when running shadow-cljs watch?#2018-03-1411:11fbielejecme too, when running the same build using CLI tools it works as expected#2018-03-1411:12fbielejecsource paths maybe#2018-03-1411:12thhellerhttps://github.com/district0x/cljs-0x-connect/blob/master/project.clj#2018-03-1411:12thhellerplease don't ever clean the .shadow-cljs dir. :clean-targets ^{:protect false} ["target" "public/js" "node_modules" ".shadow-cljs"]#2018-03-1411:13thhellercache actually works in shadow-cljs so there is no reason to do it ever.#2018-03-1411:14fbielejecgotcha. Ok so the build failure happened because "src" was not in :source-paths ["src" "dev"]#2018-03-1411:14thhellerah#2018-03-1411:15fbielejecI incorrectly assumed it is handled by the shadow-cljs, since I specify the :source-paths ["src"] there too#2018-03-1411:16thhelleras soon as you set :lein :dependencies and :source-paths are managed by lein and no longer mean anything in shadow-cljs.edn#2018-03-1411:16thhellerI should really start writing a proper migration guide#2018-03-1411:18fbielejecok so very close now:
user> (start-dev!)
mar 14, 2018 12:17:48 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
mar 14, 2018 12:17:48 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server running at 
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (226 files, 124 compiled, 0 warnings, 29,07s)
To quit, type: :cljs/quit
[:selected :app]
user> JS runtime connected.
#2018-03-1411:19fbielejeconly problem is I'm kept in clj REPL in the user namespace, no cljs REPL#2018-03-1411:20thheller@mitchelkuijpers has cider experience. I don't really know anything about cider#2018-03-1411:20thhellerI think you are supposed to call something from cider to make the switch#2018-03-1411:20thhellerbut I don't know what#2018-03-1411:20fbielejecok I'll experiment with this, probably a middleware problem#2018-03-1411:20fbielejecmany thanks for your time and help!#2018-03-1411:30thheller@fbielejec if you figure it out let me know please. want to finally have something I can put into the docs. 🙂#2018-03-1411:32fbielejecI will, off course. Btw I notice the same behaviour (no cljs REPL) when just calling lein repl and then starting the server, watcher and repl using the API.#2018-03-1411:32thhellerI think you can't purely do this via clojure#2018-03-1411:33thhellersomething in cider is supposed to clone the session so you have one for clj and one for cljs#2018-03-1411:41fbielejecyou probably mean cider-create-sibling-cljs-repl. That could work, I'll try.#2018-03-1411:43thhellerhttps://markhudnall.com/2016/04/25/starting-figwheel-in-emacs/#2018-03-1411:43thhellerjust replace figwheel with the shadow-cljs stuff and it should work#2018-03-1414:07mitchelkuijpers@fbielejec did you figure it out?#2018-03-1414:08fbielejechey - yes, I'll be writing up a quick how-to post, should be done by evening#2018-03-1414:09fbielejecUnless it's urgent, then I'll paste the instructions here 🙂#2018-03-1414:09mitchelkuijpersNo, we have been working with cider for 2 months now 😛#2018-03-1414:09fbielejecaaahh ok#2018-03-1414:09fbielejecthen you should be doing the writing I guess 😄#2018-03-1414:10mitchelkuijpersYes you are completely right#2018-03-1418:25fbielejecno worries, http://www.blog.nodrama.io/shadow-cljs-cider/ 😛#2018-03-1420:46thheller@fbielejec cool!#2018-03-1421:04justinleeis the emacs/cider integration fully functional with a cljs nrepl? i.e., does it allow you to send forms, get documentation strings, do tab completion, find definitions, stuff like that?#2018-03-1421:27mitchelkuijpers@lee.justin.m yes all works#2018-03-1421:36justinleethat is the worst news ever: I really do not want to go back to emacs 🙂#2018-03-1421:39thhellerhehe#2018-03-1421:40fbielejec@lee.justin.m fairly certain the same setup should work for Cursive too#2018-03-1421:40justinleeprobably. i use atom. i tried to get cursive installed and it was super confusing.#2018-03-1421:42justinleei guess cursive would be better than emacs so i should give it another shot#2018-03-1421:43fbielejecnothing's better than Emacs 😁#2018-03-1421:43wilkerlucioexpect Cursive troll#2018-03-1421:43justinleei spent 15 years on emacs and i don’t want to go back#2018-03-1421:45fbielejecthat's the minimum time span one should spend before switching editors 😛. It's really paramount for productiveness imho, whatever the choice might be in the end.#2018-03-1421:47wilkerlucioagreed, I spent almost 8 years on Vim before moving to intellij stuff, I used to spend around 10 ~ 20% of my time tweeking my editor, in Intellij I don't have as much customizations, instead I just use it as is mostly (except for snippets and some repl commands) and I'm very happy with not having to configure things all the time#2018-03-1421:47thhellerI'm very happy with Cursive for the time being. Never want to back to emacs as well.#2018-03-1422:08justinleeIt asked if I wanted to index the remote repositories and I said yes. I’m worried i just told cursive to go index everything on maven and clojars.#2018-03-1422:10thhellerI honestly don't know what that is about but it eventually finishes 😉#2018-03-1422:27wilkerluciothe clojars index in a decent time, the maven can take forever#2018-03-1422:32justinleeso do i need to do anything special to get an nrepl to connect to shadow? I put in the localhost/9000 (which is what my nrepl is configured to), it just hangs on `Connecting to remote nREPL server... Clojure 1.9.0`. i confirm that it works if i connect using the terminal.#2018-03-1422:39thhellerit doesn't print anything else. you should be connected. just eval something to test#2018-03-1422:42justinleethat still doesn’t work.
Connecting to remote nREPL server...
Clojure 1.9.0
(js/console.log "HELLO")
CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(null:1:1) 
(+ 1 1)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(null:1:1) 
#2018-03-1422:43thhellerits a clojure repl#2018-03-1422:43thhellerno idea about the null though#2018-03-1422:43thheller
Connecting to remote nREPL server...
Clojure 1.9.0
(+ 1 2)
=> 3
#2018-03-1513:40p-himikI'm trying to migrate to shadow-cljs, but I keep getting this error:
module.js:478
    throw err;
    ^

Error: Cannot find module '@cljs-oss/module-deps'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at [eval]:3:13
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at Object.runInThisContext (vm.js:97:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:577:32)
    at evalScript (bootstrap_node.js:351:27)
Does anyone have any idea on what may be causing it? My package.json:
{
  "devDependencies": {
    "shadow-cljs": "^2.2.9"
  },
  "dependencies": {
    "create-react-class": "^15.6.2",
    "react": "^15.6.2",
    "react-dom": "^15.6.2"
  }
}
#2018-03-1513:51hlolli@p-himik@/cdn-cgi/l/email-protection#2018-03-1513:51hlolliok I can't write, lol my slack client is really screwing with me#2018-03-1513:53p-himikOh wow. 🙂 Yes, I've those steps.#2018-03-1513:54p-himikBTW, I'm using it with :lein true.#2018-03-1513:55hlollishouldn't matter, I get the same errors when a module is not in node_modules dir, is this module there at all?#2018-03-1513:55p-himikThere're shadow-cljs and shadow-cljs-jar dirs.#2018-03-1513:59hlolliok this is not a shadow-cljs dependency https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/package.json#L30-L38 so you'll have to add this yourself, maybe you have cljsjs dependency that needs cljs-oss/module-deps.#2018-03-1514:01hlollihttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-03-1514:03hlolliunrelated question, does it say on the bottom hlolli is typing?#2018-03-1514:05p-himikYes, it does. I think it has to do something with CLJS compiler itself. It tries to install the package here: https://github.com/clojure/clojurescript/blob/ade4ab7f8ab0fc1c74c627de7b042cf8b33beb14/src/main/clojure/cljs/closure.clj#L2340 And uses it here: https://github.com/clojure/clojurescript/blob/6b9c8c1aa8e9802314d8591d252bd0818d4e79e7/src/main/cljs/cljs/module_deps.js#L3#2018-03-1514:08hlolliI forward this to thheller, I have a working shadow-cljs project and the folder (at)cljs-oss is not in my node_modules, so sounds strange.#2018-03-1514:09p-himikDo you use :lein true?#2018-03-1514:10hlollino#2018-03-1514:11hlolliah ok, this may be related since this is dependency module#2018-03-1514:25p-himikInteresting. I just used re-frame-template and modified the generated project to use shadow-cljs. The shadow-cljs.edn files do not differ between two projects. But the build for my main project starts with
Compiling ClojureScript...
Compiling ["frontend/static/js/main.js"] from ["frontend/cljs"]...
Options passed to ClojureScript compiler: {... A large map of options...}
[... the aforementioned error ...]
whereas the build for the generated project starts with
shadow-cljs - server running at 
shadow-cljs - watching build :dev
[:dev] Configuring build.
[:dev] Compiling ...
#2018-03-1514:29hlolliI guess you'd only want to start leiningen for clojure (backend) stuff and leave the rest to shadow-cljs, icludeing removeing the cljsbuild from the leiningen plugins#2018-03-1514:31p-himikActually, I don't even use Clojure, I use Python. 🙂 I just wanted to try to migrate my project to shadow-cljs with the smallest cost possible.#2018-03-1514:32hlolliok, then use python to serve the output directories, you'll still get the hot-reload from shadow-cljs, if there's no clojure code involved, you don't really need leiningen anywhere.#2018-03-1514:33p-himikHmm, in the main project I have these lines:
;; to clean JS files generated during the build
  :hooks [leiningen.cljsbuild]
Removing the last one also removes the error, which of course surfaces a whole bunch of other errors. But they should be fixable.
#2018-03-1514:34p-himikYeah, I'm thinking about dropping lein altogether.#2018-03-1514:36hlolliYes, shadow-cljs alone is capable of doing all the cljs tooling you would need.#2018-03-1515:04thheller@p-himik yeah I'd advice dropping lein if you don't need clojure. the @cljs-oss/module-deps is not from shadow-cljs and must be coming from something in lein-cljsbuild
#2018-03-1515:05p-himik@thheller Yeah, I plan to give it a go today or tomorrow. Thanks.#2018-03-1515:16mhuebert@thheller re: circleci, do you know if the issue with :jvm-opts being passed down is a shadow issue or a deps issue?#2018-03-1515:18thheller@mhuebert shadow-cljs only. I can add that now.#2018-03-1515:20mhuebertcool, not a big rush, memory usage for my builds must be borderline because it works ~50% of the time. or maybe it depends on whether I’m sharing the instance with a crypto miner 💀#2018-03-1515:20mhueberti don’t know if they eat memory or just cpu#2018-03-1515:20thhellerwell. I'm not sure if you can specify those via deps.edn#2018-03-1515:20mhueberthmm#2018-03-1515:20thhellerdepends on the miner I think. some are memory bound some are cpu bound.#2018-03-1515:24mhuebertit looks like i can put jvm opts under an :aliases key#2018-03-1515:24mhueberthttps://clojure.org/reference/deps_and_cli#_aliases#2018-03-1515:25thhellerright I was looking for that#2018-03-1515:25mhuebertwould i need to also put that in shadow-cljs.edn, or does shadow run itself ‘under’ clojure#2018-03-1515:25thhellerif you use :deps it will run via clojure#2018-03-1515:26thhellerprobably a good idea to create a :ci profile for that option#2018-03-1515:26thhellerI should be able to easily pass :jvm-opts along from shadow-cljs.edn though#2018-03-1515:27thhellerjust forgot about it#2018-03-1515:33mhueberthm I got a memory error again, after adding :aliases {:jvm-opts ["-Xmx2G"]}#2018-03-1515:34mhuebertthis is what i run to start the thing:
npx shadow-cljs clj-run maria.build/release;
shadow-cljs - config: /home/circleci/project/editor/shadow-cljs.edn version: 2.2.9
shadow-cljs - starting via "clojure"
#2018-03-1515:34thhelleryou need to create an alias and activate it#2018-03-1515:34thheller:aliases {:ci {:jvm-opts ["-Xmx2G"]}} and shadow-cljs -A:ci#2018-03-1515:35thhellerhang on I just added the fix so jvm-opts get passed along from shadow-cljs.edn#2018-03-1515:36thhellershould work in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "cab9a2abaea5bde7a9a6a0b98af8e4f8e4fbfa"}, :content ("[email protected]")}#2018-03-1515:42mhuebertgreat, just had a maria build succeed w/ that option#2018-03-1515:58p-himikSuppose one project (say, reagent) depends on something from cljsjs (say, react). It has some particular version specified there. Is there any way to automatically update this version in package.json when the project updates its dependencies?#2018-03-1516:00thheller@p-himik cljsjs is not supported in shadow-cljs. npm is always used but no it is not synced until reagent starts declaring its react dependency via deps.cljs :npm-deps. I believe it started doing that in the latest alphas.#2018-03-1516:00p-himikI see, thanks.#2018-03-1517:05p-himikIt's working! But I see some errors like Use of undeclared Var re-frame.cofx/kind. The mentioned vars vary, but they all exist when I check. What could cause these warnings? We don't need to (:require [some.thing]) in order to write some.thing/foo, do we?#2018-03-1517:06thhelleryou do need to unless you like fun and undefined behaviour#2018-03-1517:07thhellerthe :require ensures that things get compiled in the correct order. without the require a namespace might be compiled before its dependency leading to those kinds of warnings#2018-03-1517:08p-himikInteresting. I can't find any documentation on mentions without requiring, but I've seen a ton of examples from which I've learned.#2018-03-1517:08thhellershadow-cljs is a bit stricter for those things because of the more aggressive caching and parallel compilation by default#2018-03-1517:09thhellerreferences without require are always a bad idea and should never be done#2018-03-1517:09thhellershould never be done in files. its fine for the REPL.#2018-03-1517:11p-himik> parallel compilation by default So one doesn't have to specify :parallel-build true? Or is it something different?#2018-03-1517:11thhellerno setting necessary. enabled by default.#2018-03-1517:12thhellerin fact you probably don't need ANY of the usual CLJS configuration#2018-03-1517:13p-himik:external-config and :closure-defines are still probably needed.#2018-03-1517:15thheller:external-config is dangerous with caching. handle with care. :closure-defines not needed if all you set is goog.DEBUG but otherwise yes#2018-03-1517:15p-himikI use only :devtools/config and :dirac.runtime/config in :external-config. Should be fine, right?#2018-03-1517:16thhellerto be safe keep it in :dev {:external-config ...} so it doesn't apply to release builds#2018-03-1517:16p-himikThanks!#2018-03-1517:17p-himikI think it should be :dev {:compiler-options {:external-config ...}}.#2018-03-1517:18thhellerah right. yes.#2018-03-1518:23p-himikI think the final bit in my project is to make dirac work. In project.clj I have :repl-options {:init (do (require 'dirac.agent) (dirac.agent/boot!))}. Is it possible to have something like that with shadow-cljs? I found this in the documentation: "When enabled the watch will also hot-reload your code and provide a REPL." However, the link on "enabled" just goes to "Development Options" section that doesn't say anything about REPL.#2018-03-1518:40p-himikOK, now I'm starting to think that I will still have to use Leiningen. Because otherwise: 1. Apparently I won't be able to have some code being run automatically on nREPL connection 2. Cursive won't fetch any dependencies (or I'll have to generate pom.xml each time shadow-cljs.edn is changed) 3. I won't be able to use Leiningen plugins (e.g. lein-environ) and tools (e.g. lein ancient)#2018-03-1518:42p-himikAlso, attempting to use dirac prints out something interesting:
[3:0]~shadow.user=> (dirac.agent/boot!)
#object[clojure.core$future_call$reify__8097 0x79c9b171 {:status :pending, :val nil}]
[3:0]~shadow.user=> -----------------------------------------------------------------------------------------------------------
[3:0]~shadow.user=> WARNING!
We detected unexpected middleware setup in your nREPL server at !
The difference (clojure.data/diff expected-ops reported-ops) is:
[nil
 [nil nil nil nil nil nil nil nil nil nil :cljs/select]
 [:clone
  :close
  :describe
  :dirac-devtools-request
  :eval
  :identify-dirac-nrepl-middleware
  :interrupt
  :load-file
  :ls-sessions
  :stdin]]

For reference, the reported versions by the nREPL server are:
{:clojure "1.9.0", :java "1.8.0_151", :nrepl "0.2.13"}

This usually happens when some extra middleware gets injected into your nREPL server behind your back.
e.g. * Didn't you include a middleware via ~/.lein/profiles.clj or BOOT_HOME/boot.properties?
     * Or maybe using Cider's nREPL stuff?
     * Or maybe using some combination of ancient Clojure/Java versions?
     * Or some bleeding-edge alpha versions?
     * Or a rogue tools.nrepl dependency in your project or its dependencies?

Please follow Dirac installation instructions: .
-----------------------------------------------------------------------------------------------------------
I guess shadow-cljs injects :cljs/select, right?
#2018-03-1519:58darwin@p-himik should be harmless, you should be able to suppress that warning by passing a config overrides into boot!: (dirac.agent/boot! {:skip-dirac-nrepl-middleware-check true}) or something like that#2018-03-1519:59darwinthere are maybe more warning suppression options, but it is not documented: https://github.com/binaryage/dirac/blob/46bd0ee54234d90240155c3df94b1946b7ecf182/src/lib/dirac/lib/nrepl_tunnel.clj#L312#2018-03-1520:06colindresjHow would one fully qualify a JS dependency when writing a macro?#2018-03-1520:13thheller@colindresj I have been thinking about that but the best solution right now is to create a helper fn in your cljs ns that calls the JS code and call that from the macro#2018-03-1520:13colindresjOk, that’s what I thought#2018-03-1520:13colindresjThanks#2018-03-1520:14thhellerproblem is that the JS namespace can change if filenames change or :browser vs :node-script#2018-03-1520:15colindresjYeah, I was look at the compiled source and the references didn’t seem reliable#2018-03-1520:15colindresjDon’t think a helper is the end of the world#2018-03-1520:16thhelleryou can get to it via the compiler env but I cannot guarantee that that won't change over time. so better stick with the helper fn for now#2018-03-1520:16colindresjCool#2018-03-1520:17thheller@darwin how come you are checking the nrepl middleware?#2018-03-1520:19darwin@thheller that is just a sanity check, people had weird issues when running some other middleware alongside dirac’s, just a warning#2018-03-1520:21darwinI might relax that check and check only against white-listed middleware which is known to be “compatible”#2018-03-1520:23kennyJust updated to shadow-cljs 2.2.10 and after first run I am receiving this error: https://pastebin.com/r0wteDyJ. Feels like a dependency issue but unsure. I am using ClojureScript 1.9.946.#2018-03-1520:24thheller@kenny use [org.clojure/clojurescript "1.10.145"] thats the version now used by shadow-cljs. if you want to continue using 946 you must downgrade the closure compiler#2018-03-1520:25kennyGotcha. Is there a compatibility table that has this info? Also, do you know if that is a stable release? The CLJS github doesn't have any visible info on that version.#2018-03-1520:26thhellertechnically you shouldnt worry about which cljs version you are using and just depend on the one shadow-cljs "ships"#2018-03-1520:26thhellerwhat we are using is stable yes#2018-03-1520:27thhellerthere wasn't an official release yet since lots of the new stuff they were working on is not stable#2018-03-1520:27thhellerbut we are not using that so it doesn't matter#2018-03-1520:27thhellergot impatient with the upgrade since I wanted to finally sort out the java9 issues#2018-03-1520:28thhellerupgraded to the pre-release pretty much for that reason#2018-03-1520:28kennyWhile I'm here, ever since switching to shadow-cljs I receive this warning in the console:
Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See  for more details.
How do you include React in your builds? Right now it's just in my package.json under dependencies.
#2018-03-1520:28kenny... for dev.#2018-03-1520:29thhelleryeah ignore that warning. everything is fine. react is just being annoying.#2018-03-1520:29thhellerit goes away when doing a release build#2018-03-1520:29kennyIt makes it sound like I should not be using a minified dev build of React when developing.#2018-03-1520:30thhellerno the warning is there to protect users from using the dev version in production#2018-03-1520:30kennyAnd the best solution is to always send a warning during development? 🙂#2018-03-1520:31thhellernah their detection is just flawed#2018-03-1520:32thhellerbeen meaning to bug them about that#2018-03-1520:34thhellerunfortunately due to their annoying packaging there is no way to get rid of the warning if you want to use the dev version#2018-03-1520:34thhellerif you always want to use the production version there is a way#2018-03-1520:34thhellerbut some of there debug messages are pretty helpful so I'd rather keep them#2018-03-1520:35kennyAgreed.#2018-03-1520:35kennyUnrelated note: Is there a way to get shadow-cljs to spit out the nrepl port into the same file leiningen uses so Cursive can work with the REPL? Right now I have to statically set the REPL port.#2018-03-1520:38kennyI haven't found a way in Cursive to set the nrepl port file to something other than the default -- .nrepl-port at the root directory.#2018-03-1520:46thhelleryeah I have been hesitant to write to that file since it belongs to lein and I don't want to get in its way#2018-03-1520:48thhellerguess I could just write it if it doesn't exist#2018-03-1520:50kennyMakes sense. Perhaps a config option to specify the REPL port file?#2018-03-1520:52thhellerwell as you said there is no way to configure cursive to use a different file#2018-03-1520:53kennyI mean in shadow-cljs. I'd think that If I explicitly specify shadow-cljs to write to .nrepl-port then it becomes my problem if that interferes with lein.#2018-03-1520:53thhellermaybe I can talk Colin into looking at other files now that shadow-cljs is gaining popularity#2018-03-1521:59mhueberthmm
[2018-03-15 22:55:34 - SEVERE] spark/util/mongoose-types/lib/plugins/useTimestamps.js:1: ERROR - Invalid module path "goog:shadow.js.shim.module$mongoose" for resolution mode "BROWSER"
var mongoose = require('goog:shadow.js.shim.module$mongoose')
this is supposed to be a :node-script, but this error says ‘resolution mode “BROWSER”’
#2018-03-1522:02thhellerBROWSER is the resolution mode for the closure compiler, we always use that since the others are just flat out broken#2018-03-1522:02mhuebertah ok#2018-03-1522:02thhellerare you compiling .js files with shadow-cljs?#2018-03-1522:03thhellerI mean outside node_modules?#2018-03-1522:03mhuebertthat was a cljs file attempting to require via a module via a relative path, which itself requires stuff from node_modules#2018-03-1522:04thhelleryeah that is currently only works for ES6 files#2018-03-1522:04thhellercommonjs is busted because of the closure compiler#2018-03-1522:04mhuebertie. in my-namespace ["./util/mongoose-types" :as mongoose-types], and then in ./util/mongoose-types/ it requires other stuff#2018-03-1522:04mhuebertahhh ok#2018-03-1522:06thhellerthe file has var mongoose = require('mongoose') which shadow-cljs replaces with the goog:shadow.js.shim.module$mongoose#2018-03-1522:06thhellerwhich the closure compiler in turn just replaces with var mongoose = shadow.js.shim.module$mongoose so all is good in the world#2018-03-1522:07thhellerfor ES6 that is .. for commonjs it doesn't process the goog: part#2018-03-1522:07thhellerI have not figured out how to solve this without everything breaking#2018-03-1522:07thhellerimport mongoose from "mongoose" should work just fine#2018-03-1522:08mhuebertI can use ordinary nodejs/require, using js/__dirname and relative paths#2018-03-1522:08mhuebertwell let’s see#2018-03-1522:09thhellerunfortunately not#2018-03-1522:10thhellerwell if you manually copy the .js files into the :output-to folder#2018-03-1522:10thhellerwith js/require they won't get copied from the source paths#2018-03-1522:16thhellerhmm just thought of something. might be able to trick GCC#2018-03-1600:30eoliphantjust wanted to drop a note @thheller shadow is amazing. You tried to help me get it goign with a luminus generated project a few weeks ago. But I kind of gave up as i was under a crunch, but just got back into it and abandoned trying to get it working with lein and just did it standalone. literally took like 15 minutes. clojure(script) is awesome, but dealing with the rest of the JS world is a bit of an s-show IMO, this really makes it just work.#2018-03-1604:10p-himik@darwin Thanks! No warning now. Although the option should be :skip-paranoid-middleware-setup-check.#2018-03-1604:43p-himik#2018-03-1604:43p-himikJust running (require '[cljs.repl]) leads to the same error. But running (require '[cljs.core]) is just fine. Removing all shadow-cljs lines from :init and :nrepl-middleware solves the issue. Do you have any idea on why it might be happening?#2018-03-1605:02p-himikAh, found https://github.com/thheller/shadow-cljs/issues/167 Hard to find when all the text is in images. 🙂#2018-03-1609:42thheller@p-himik I'm not sure what you are trying to do. why require cljs.repl? why require cljs.core? does requiring your code work?#2018-03-1609:46p-himik@thheller I'm just testing - that's what Dirac requires when it starts, as far as I can tell. Yeah, everything else appears to be working.#2018-03-1609:46thhellerlooking over the dirac architecture I don't think dirac is going to work#2018-03-1609:47thheller> With specific setup, Dirac is able to use Figwheel's compilers for REPL evaluations. Dirac nREPL middleware looks for Figwheel sidecar presence#2018-03-1609:47thhellerit already does special detection for figwheel. so it would have to do that for shadow-cljs as well#2018-03-1609:58darwinexactly, Dirac needs to talk to some CLJS REPL environment on server-side, normally it does that via its own fork of piggieback running on top of nREPL, but it can optionally switch to Figwheel’s REPL running on top of nREPL, it would have to do the same for shadow-cljs-managed CLJS REPL as well#2018-03-1610:01thheller@darwin but why fork piggieback? why not use the binding it sets? I already emulate piggiback so that the expected cemerick.piggieback/*cljs-compiler-env* binding is set in the session#2018-03-1610:06darwinI don’t remember the exact reasons, but it was easier for me to simply fork it and do my own thing. I ended up rewriting it. Unfortunately piggieback was really hard to understand (for me).#2018-03-1610:06darwinyou would not recognize this code 😉 https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/piggieback.clj#2018-03-1610:07thhellerI still don't understand piggieback. I work around it to.#2018-03-1610:07thhellerbut you said you need to the compiler env which is available via a binding so you don't need to mess with the rest#2018-03-1610:08darwinI wrote this code few years back, I’m sorry I don’t remember#2018-03-1610:09thhellerwell problem either way is going to be that shadow-cljs doesn't use the default cljs repl env stuff#2018-03-1610:10darwinbut if I recall correctly, I need compiler env in the same JVM as dirac nrepl middleware is running, if I can get that I can compile stuff#2018-03-1610:10thhellerit completely reimplements all REPL related things#2018-03-1610:10darwinhere you can see, how hard was figwheel integration: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/figwheel.clj#2018-03-1610:13darwinhere I collect all compiler descriptors available to Dirac: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/compilers.clj#L89 you can see that I collect dirac’s own (in nREPL) and add figwheels if avail#2018-03-1610:13darwinthere I could add yours, if I had access to them#2018-03-1610:15thhellerI'll take a look at it later. no clue whats going on there and not enough time to get started now.#2018-03-1610:16darwinsure, no problem, just wanted to let you know that I’m open to add support for shadow-cljs, if possible#2018-03-1616:12thheller@mhuebert I just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e3908b82878c94ce808f8990a3d1cdd1cdd2d2"}, :content ("[email protected]")} which should fix your issue from yesterday. the require('mongoose') thing.#2018-03-1616:41mhuebertGreat, will try it out#2018-03-1618:30fbielejecSay I have two namespaces, lets call them * ns-a with a hello-a function signature * ns-b with a hello-b function signature Can I have a build, that releases this as a library usable both from the browser and on the server (nodejs)? Also another question - say that one of these functions (`hello-a` for example) needs a slighty different implementation (for example a different socket client for a browser and nodejs), but after production release I still want the user to be able to just do:
(:require my-lib.ns-a :refer [hello-a])
and get the right implementation regardless of where she is running the code. Ideally without increasing the bundle size (so either without programmatically detecting the process, or by dead code elimination)? In the end:
(defn hello-a []
 (if process.browser
   "Hello from browser"
   "Hello from node"))
should become in the browser
function hello-a () {return "Hello from browser"}
and when required in nodejs env it becomes:
function hello-a () {return "Hello from node"}
#2018-03-1619:16thheller@fbielejec not sure what you mean by "releases this as a library usable both from the browser and on the server"#2018-03-1619:16thhelleryou mean the compiled version?#2018-03-1619:16thhellerfrom JS?#2018-03-1619:19thhellerfor the other thing you can use a goog-define which works with DCE and should do what you want#2018-03-1619:24justinlee@thheller I don’t know if you saw in #clojurescript but I pointed someone who wants to embed cljs in an existing project to https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module but i’m not sure that’s the best method#2018-03-1619:25thhellerI saw yes. depends on the project but it is a good option yes.#2018-03-1620:12fbielejec@thheller from another cljs project to start with.#2018-03-1620:15thhellerfor CLJS I would suggest 2 different namespaces otherwise you might get into all sorts of trouble if your users forget to set the closure-defines properly or so#2018-03-1620:16thhelleryou want to rely on DCE as little as possible and use other more reliable options#2018-03-1701:20mjmeintjesHi. I have an static index.html file. Is there any support in shadow-cljs to update that on release to point to the latest js file, based on the hash generated and available in manifest.edn? I know how to do it if I have a server that serves the html, but in this case the app is client side only.#2018-03-1701:54mjmeintjesNo worries, turned out to be pretty easy using the clj-run functionality#2018-03-1707:03escherizeHey, just curious, what's this thing for? http://take.ms/mHhEK#2018-03-1707:36escherizeAlso, I'm playing around with cljs-play and shadow-cljs. Unfortunately I'm getting the error: The required namespace "p5.core" is not available, it was required by "play_cljs/core.cljs".. I tried npm install p5 which did update my package.json --- however cljs-play uses foreign libs ( https://github.com/oakes/play-cljs/blob/7fa4c33cf1cb734985366e8bdca1d7ed78546715/src/deps.cljs ) that I'm unable to satisfy using npm install p5 Any tips?#2018-03-1708:59thheller@escherize oops thats an UI experiment I'm working on in a branch. must have accidentally published it in the jar.#2018-03-1708:59thheller@mjmeintjes yeah clj-run is a good solution. there is nothing built-in for this (yet).#2018-03-1709:01thheller@escherize your instinct was correct but to work arround foreign-libs an extra shim file is required. they look like this https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/d3.cljs#2018-03-1709:02thhellerso (ns p5.core (:require ["p5" :as p5])) (js/goog.exportSymbol "p5" p5). basically all they to is load the package properly from npm and export the global name that cljsjs would otherwise create#2018-03-1709:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-03-1709:03thhellerdont know if the global is actually p5 though#2018-03-1712:35cmal@thheller I just made a pull request to add web3.js into .#2018-03-1712:36thheller@cmal just commented 🙂#2018-03-1712:37cmalsorry for that.#2018-03-1712:38thhellerdon't need to close the PR. if you just push a new version of your fork it gets updated.#2018-03-1712:43cmal😅#2018-03-1712:43thhellermerged. I'll add it to the next release.#2018-03-1717:02justinlee@thheller Juhopetri was saying that he thought react would never work without externs. How are you doing it in shadow?#2018-03-1717:02thhellernode_modules files don't go through :advanced, so you don't need externs.#2018-03-1717:10justinleeOh do mom-deps files go through advanced?#2018-03-1717:11thhelleryes#2018-03-1717:13justinleeWow that was super unclear to me #2018-03-1717:13justinleeNo wonder it doesn’t work! :)#2018-03-1717:13justinleeI just thought it was a better foreign libs#2018-03-1717:16thhellerto be fair support is getting better and will get better over time as more people move towards ES6#2018-03-1717:17thhellerbut currently its not reliable enough to use .. thats why its not the default in shadow-cljs#2018-03-1717:22justinleeI just feel bad for people struggling to make it work who probably just want to get something working. #2018-03-1717:27thhelleryeah. the news announcement was way too premature IMHO.#2018-03-1718:21bhauman@thheller do you think you would benefit from something like figwheel-core?#2018-03-1718:21bhaumanI had shadow in mind when I was writing it#2018-03-1718:21thheller@bhauman besides from your ideas probably not. I have pretty much everything already.#2018-03-1718:22bhaumanwell coolio#2018-03-1718:22thhellerwould be nice to re-use your error reporting stuff though#2018-03-1718:23bhaumanwell if you get a chance check it out#2018-03-1718:23bhaumanas it has no deps at all#2018-03-1718:24bhaumanif you do think you could use it but need changes let me know#2018-03-1718:28thhellerI think shadow-cljs is much too low level and not built on the standard cljs.closure stuff at all#2018-03-1718:28thhellerit started out as a replacement to cljs.closure and lein-cljsbuild after all#2018-03-1718:29thhellerI only added the live-reload stuff way after#2018-03-1718:31bhaumanyeah if you don't have a compiler env then it won't help much#2018-03-1718:48thheller@bhauman while you are here. @mhuebert suggested the other day that it would be useful for libraries if they could hook into the live-reload process without the user having to configure it. eg. by adding a bit of meta to a (defn ^:on-jsload some-hook [] ...). I think you already have some special metadata in figwheel to do this stuff.#2018-03-1718:49thhellermaybe we can decide on some generic names so things work in figwheel and shadow equally#2018-03-1718:49bhaumanthis is a good idea#2018-03-1718:49bhaumanbut var data doesn't get pushed right??#2018-03-1718:50bhaumandoes it get pushed reliably#2018-03-1718:50thhellerif shadow-cljs I have :before-load, :before-load-async and :after-load to hook into the respective points in the reload cycle#2018-03-1718:50bhaumanis that metadata?#2018-03-1718:50thhellerdon't need it on the client. can just walk the compiler env when a compile finish and comb through the :defs#2018-03-1718:50bhaumanor rather config hooks#2018-03-1718:51thhellercurrently only config hooks but I want to allow the metadata as well#2018-03-1718:51bhaumanyeah that relies on a compiler hook#2018-03-1718:52bhaumanhave to think about this, trying to do as little on the compile side as possible now#2018-03-1718:53bhaumanactually yeah this is totally possible#2018-03-1718:54bhaumangot my head around it, its a good idea#2018-03-1718:54thheller
(for [[ns info] (::ana/namespaces compiler-env)
              :let [{:keys [defs]} info]
              {:keys [name meta] :as def} defs
              :when (:on-jsload meta)]
          [ns name])
#2018-03-1718:54thhellerthis should be enough to extract the info required, then just send it to the client and let it do the thing#2018-03-1718:55bhaumanyeah just have to push it with the other reload info I'm pushing#2018-03-1718:56bhaumanand they should probably label it with export as well#2018-03-1718:57thhellernah that would keep it alive after :advanced. don't want that for dev code#2018-03-1718:57bhaumaninteresting#2018-03-1718:57thhellerI was even thinking that fns like this could be automatically elided during release compiles but that would be way harder for you#2018-03-1718:58bhaumanyeah I'm moving out of the compile side of things#2018-03-1718:58thhellera "standard" set of metadata tags for this stuff would be nice though#2018-03-1718:58thhellerI saw something like :fighwheel-always and things already#2018-03-1719:00bhaumanyes it would be nice#2018-03-1719:01thhellerdo you have hooks for running code before loading any code already? or only :on-jsload?#2018-03-1719:01bhaumanyes I have before hooks#2018-03-1719:02bhaumanbasically before and after, no distinction for async#2018-03-1719:03thhellerI added the async due to node. its quite frequent that you need to wait for something to actually finish before continuing, eg. when closing http servers#2018-03-1719:04thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/script.cljs#L28-L34#2018-03-1719:04thhellerthat frequently failed if I just called (.close srv) and immediately continued with live-reloading#2018-03-1719:06thheller:before-load demo.script/stop in this case but (defn ^:dev/before-load-async stop [done] ...) would be neat#2018-03-1719:07thhellerI generally not a fan of having too much config in code but metadata solves this nicely as it doesn't really end up in the code#2018-03-1814:58thhellerjust released https://github.com/thheller/shadow-cljs/releases/tag/2.2.14 ping @mhuebert @bhauman#2018-03-1818:07mhuebertThis is great, will trim down my already-very-small shadow-cljs.edn even further #2018-03-1818:08mhuebertPlus handles the case of multiple on-reloads elegantly#2018-03-1818:18thhellerI was curious if I could trim down the config even more and looked at your maria/editor config#2018-03-1818:18thheller:http-handler shadow.http.push-state/handle push-state is now the default so you can leave that out too 🙂#2018-03-1818:19thhellernot seeing anything obvious to remove besides that#2018-03-1821:26mhuebertoh, that’s great#2018-03-1816:00thheller@bhauman I found :figwheel-always and :figwheel-noload on the ns name. do you support other metadata currently? and what exactly does :figwheel-always do? just always load it even if it wasn't compiled?#2018-03-1816:13bhaumanyes the intention of :figwheel-always is to reload the ns on every code change#2018-03-1816:14bhauman:figwheel-noload is to not load on code change#2018-03-1816:15bhauman:figwheel-load is to load regardless of whether it is in the dependency chain or not#2018-03-1816:16bhauman@thheller ^#2018-03-1816:17thhellernoted. thanks. :figwheel-noload I added already https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/worker/impl.clj#L137-L139#2018-03-1816:18thhellerwill think about the others#2018-03-1816:18bhauman:dev/once makes sense#2018-03-1816:20thhelleryeah added that last minute. like it way more than :dev/never-load#2018-03-1818:04mhuebertI like :dev/once too#2018-03-1819:35escherize@thheller Thanks -- the shim file has fixed my first issue with p5! And I just read through that part of the manual (good docs). The next error I'm getting is The required JS dependency "/assets/p5.tiledmap.js" is not available, it was required by "p5/tiled_map.cljs". Now, p5.tiledmap isn't in npm. I'm trying to require it by using the file locally, but can't quite get all the dots connected.#2018-03-1819:36thhellernot on npm? thats a first. 🙂#2018-03-1819:37thhellerwhere is it from then?#2018-03-1819:39thhellerthis one? https://github.com/linux-man/p5.tiledmap/blob/master/p5.tiledmap.js#2018-03-1819:43thheller@escherize so the only issue I see is that the require('../p5') is incorrect. it should be require('p5')#2018-03-1819:44thhellerotherwise it would attempt to load p5 from a relative file instead of npm#2018-03-1819:46thhellerbut if you change that you can put the file into your source path and just require it directly via (:require ["/abs/path/p5.tiledmap.js"]) like you were trying?#2018-03-1819:46thhelleror even better just publish that file to npm with the fix 😉#2018-03-1820:01thheller@escherize https://github.com/thheller/p5-tiledmap-demo#2018-03-1820:02thhellerit would be almost usable from what play-cljs if the require here was changed to require("./p5") (ie. minus one dot) https://github.com/oakes/play-cljs/blob/master/src/js/p5.tiledmap.js#L5#2018-03-1820:03thhellerthen you could just (:require ["/js/p5.tiledmap"]) in the shim file#2018-03-1820:11escherizeThanks for your help. I’m away from my computer now but will do this and report when I get back. Thanks for your help again!!!#2018-03-1911:01mitchelkuijpersIf anyone upgraded cider I made .dir-locals.el file with this code:
((nil . ((projectile-project-type . lein-test)
         (eval . (progn
                   (require 'cider)
                   (add-to-list 'cider-cljs-repl-types '("Shadow CLJS" "(do (shadow.cljs.devtools.server/start!) (shadow.cljs.devtools.api/watch :app) (shadow.cljs.devtools.api/nrepl-select :app))" nil))
                   (setq projectile-create-missing-test-files t))))))
This will make it possible to start up your cljs-repl again from emacs
#2018-03-1911:03thheller@mitchelkuijpers it still requires lein right?#2018-03-1911:04mitchelkuijpersYes for this solution you need leiningen#2018-03-1911:05mitchelkuijpersOr you could connect to nrepl which shadow-cljs starts but then you have to add their middleware first#2018-03-1911:06thhellergetting rid of lein would be neat since I have more control over the setup then#2018-03-1911:07thhellerI'd love to get it working with absolutely zero-conf#2018-03-1911:07mitchelkuijpersWe want to move to a deps.edn setup at one point so that would be nice. Not sure how that works though. I am talking in the #cider room about this#2018-03-1911:09mitchelkuijpersBtw we don't need leiningen but we need to inject the nrepl middleware#2018-03-1911:09thhellerthe cider middleware is automatically added when its on the classpath#2018-03-1913:27fbielejechi, has anyone tried packaging shadow-cljs compiled JS (production) code into jars, for consumption in another cljs projects?#2018-03-1915:03thheller@fbielejec for CLJS you should only be packaging the cljs source files never compiled code#2018-03-1915:04thhellerbut shadow-cljs currently does not provide anything to do the packaging of those#2018-03-1915:13fbielejecI see - and what about publishing as a module to npm registry, and then requiring via node_modules?#2018-03-1915:14thhellereither :node-library or :node-script work for that. see https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library#2018-03-1915:15thheller:npm-module also works#2018-03-1915:16thhellershadow-cljs started out as :node-script but :npm-module is slight more flexible but also more complex#2018-03-1915:16thhellerpublish is just npm publish#2018-03-1915:20fbielejecGotcha - I'm looking into ways of utilizing shadow-cljs compiled modules in upstream projects still using :cljsbuild. I suppose one could force fetching of that dependency via :npm-deps or lein-npm plugin, :notify or some other mechanism?#2018-03-1915:20thhellerI cannot emphasize this enough. DO NOT USE compiled CLJS code in OTHER cljs projects#2018-03-1915:21thhelleryou will get into a horrible mess if you try to do this#2018-03-1915:21thhellernothing will work at all#2018-03-1915:22thhellerproblem is that the compiled version of the library will contain its own version of cljs.core#2018-03-1915:22thhellerwhich will conflict with the other CLJS code being compiled in the project#2018-03-1915:23thhellerso you can't pass a cljs map from the project code to the library#2018-03-1915:23thhellerthere is no viable option if the other project is using cljsbuild and doesn't understand npm-deps properly#2018-03-1915:24thhellerpublishing to npm is only useful if you want your code to be consumable from JS#2018-03-1915:25thhellerfor CLJS the problem is that the cljs compiler needs access to the sources. there really isn't anything that can be done about this.#2018-03-1915:52fbielejecthanks - this will save my time from going down that rabbit hole 🙂#2018-03-1922:32escherize@thheller I decided to just publish the p5.tiledmap to npm -- I got it working too.#2018-03-1922:33escherizehttp://take.ms/rVr5f#2018-03-1922:42thhellercool!#2018-03-2007:50levitanong@thheller this is weird. I’m getting the https://github.com/google/closure-compiler/issues/2822 error even with [com.google.javascript/closure-compiler-unshaded "v20180101"] explicitly in my deps. I’ve made no recent changes that should affect this. Any ideas?#2018-03-2008:36levitanongScratch that, clearing rm -rf .shadow-cljs/builds fixed it#2018-03-2009:02Jonhttps://clojureverse.org/t/calling-cljs-from-js-in-a-cljs-project/1806#2018-03-2009:02JonI remembered we have examples for this case?#2018-03-2009:03thheller@jiyinyiyong https://github.com/thheller/shadow-cljs-examples/tree/master/local-js#2018-03-2009:04thhellerneed to do a full writeup and docs still#2018-03-2009:05thheller@levitanong changing the closure version doesn't invalidate the cache. I'll fix that.#2018-03-2009:25thheller@jiyinyiyong forgot that I wrote some docs for this as well: https://shadow-cljs.github.io/docs/UsersGuide.html#_dealing_with_js_files#2018-03-2021:42hlolliI just switched computers (bought new one) and starting my project on the new one welcoms me with this, any obvious troubleshoot here?
[:public] Build failure:
FileNotFoundException: public/js/module-loader.json (No such file or directory)
#2018-03-2021:50thhelleroh doh#2018-03-2021:50thhellercreate public/js by hand#2018-03-2021:53thhellerthat part of the code didn't ensure the output dir exists, fixed in master.#2018-03-2022:01hlolli🙂 thanks!#2018-03-2110:36mitchelkuijpersAnyone else runnig into with shadow-cljs 2.2.16:
Exception in thread "async-thread-macro-12" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__59202
	at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21)
	at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
	at clojure.core$reduce.invokeStatic(core.clj:6747)
	at clojure.core$reduce.invoke(core.clj:6730)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63)
	at shadow.cljs.devtools.server.reload_classpath$start$fn__59234.invoke(reload_classpath.clj:92)
	at clojure.core.async$thread_call$fn__8239.invoke(async.clj:442)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
#2018-03-2110:37thhellerhmm never seen that before#2018-03-2110:37mitchelkuijpersI think it's my fault#2018-03-2110:38mitchelkuijpersa wrong tools.reader version#2018-03-2110:39thhellerit might be related to the new cljs version#2018-03-2110:39thhellerwhich decided it was a good idea to ship the AOT bundle as the default#2018-03-2110:39thhellerso you get their tools.reader version always
#2018-03-2110:39mitchelkuijpersNo I a old tools.reader in my project.clj#2018-03-2110:39thhellerdoesn't matter when the AOT version is on the classpath#2018-03-2110:40mitchelkuijpersWell now it works after removing tools.reader 1.1.2#2018-03-2110:41mitchelkuijpersI see cider support as been improved:#2018-03-2110:41mitchelkuijpersVery cool#2018-03-2110:42mitchelkuijpersOnly thing that is not working anymore is file watching for some reason..#2018-03-2110:42mitchelkuijpersHmm#2018-03-2110:42thhelleryeah, fixed some piggieback things reported here https://github.com/clojure-emacs/cider/issues/2239#2018-03-2110:43thhelleryou need to tell me about these things. I wasn't even aware this was an issue 😛#2018-03-2110:44thhellerwhat are those failed to parse warnings?#2018-03-2110:44mitchelkuijpersOh sorry, I didn't dare you were so angry the last time you started cider 😛#2018-03-2110:44mitchelkuijpers
11:38:40.868 [nREPL-worker-0] WARN  shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/sha256.js
[{:line 11, :column 9, :message "'identifier' expected"}] {  }
11:38:40.875 [nREPL-worker-0] WARN  shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/md5.js
[{:line 9, :column 9, :message "'identifier' expected"}] {  }
11:38:40.877 [nREPL-worker-0] WARN  shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/cljs-hash/cljs-hash/0.0.2/cljs-hash-0.0.2.jar!/js/sha1.js
[{:line 9, :column 9, :message "'identifier' expected"}] {  }
11:38:41.633 [nREPL-worker-0] WARN  shadow.build.classpath - failed to parse javascript file: jar:file:/home/mitchel/.m2/repository/doo/doo/0.1.8/doo-0.1.8.jar!/runners/nashorn.js
[{:line 21, :column 39, :message "Semi-colon expected"}] {  }
11:38:42.192 [nREPL-worker-0] WARN  shadow.build.classpath - failed to parse javascript file: jar:file:/usr/lib/jvm/java-8-openjdk/lib/tools.jar!/com/sun/tools/hat/resources/hat.js
#2018-03-2110:44thhelleryeah I get frustrated easily by emacs .. doesn't mean I don't want it to work 😛#2018-03-2110:44mitchelkuijpersAh ok#2018-03-2110:45thhellerhmm I should turn off those warnings#2018-03-2110:45mitchelkuijpersHmm I know why watching is not working:#2018-03-2110:45mitchelkuijpers
(shadow-server/stop!)
shutting down ...
JS runtime disconnected.
Worker shutdown.
11:45:10.423 [nREPL-worker-2] WARN  shadow.cljs.devtools.server - shutdown failed ((rt/stop-all app)) {  }
java.lang.ThreadDeath: null
	at java.lang.Thread.stop(Thread.java:853)
	at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__62024.invoke(interruptible_eval.clj:243)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at user$eval74385$fn__74386$fn__74388.invoke(form-init5239952018706589785.clj:1)
	at shadow.cljs.devtools.server.nrepl$cljs_eval$fn__62323.invoke(nrepl.clj:171)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.load_file$wrap_load_file$fn__62170.invoke(load_file.clj:79)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at shadow.cljs.devtools.server.nrepl$cljs_load_file$fn__62334.invoke(nrepl.clj:192)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.session$add_stdin$fn__62099.invoke(session.clj:238)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_debug$fn__70069.invoke(nrepl.clj:161)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_enlighten$fn__70077.invoke(nrepl.clj:187)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_macroexpand$fn__70111.invoke(nrepl.clj:264)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cemerick.piggieback$wrap_cljs_repl$fn__62286.invoke(fake_piggieback.clj:31)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_inspect$fn__70103.invoke(nrepl.clj:224)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_out$fn__70127.invoke(nrepl.clj:305)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_pprint$fn__70035.invoke(nrepl.clj:107)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_tracker$fn__70191.invoke(nrepl.clj:450)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at shadow.cljs.devtools.server.nrepl$cljs_select$fn__62315.invoke(nrepl.clj:153)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.pr_values$pr_values$fn__61940.invoke(pr_values.clj:22)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl$wrap_test$fn__70175.invoke(nrepl.clj:415)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at cider.nrepl.middleware.pprint$handle_pprint_fn.invokeStatic(pprint.clj:49)
	at cider.nrepl.middleware.pprint$handle_pprint_fn.invoke(pprint.clj:44)
	at clojure.lang.Var.invoke(Var.java:385)
	at cider.nrepl$wrap_pprint_fn$fn__70025.invoke(nrepl.clj:88)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at clojure.tools.nrepl.middleware.session$session$fn__62084.invoke(session.clj:192)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__61733.invoke(middleware.clj:22)
	at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
	at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
	at clojure.tools.nrepl.server$handle$fn__62185.invoke(server.clj:28)
	at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
#2018-03-2110:47thhellerhmm what the heck?#2018-03-2110:47thhellerare you connected to the shadow-cljs nrepl or still via lein?#2018-03-2110:47mitchelkuijpersStill via lein#2018-03-2110:47thhellerwhy are you calling stop!?#2018-03-2110:48mitchelkuijpersBecause I did (shadow/watch :app) but it wasn't recompiling#2018-03-2110:48thhellertry reload! instead#2018-03-2110:48mitchelkuijpersAh ok#2018-03-2110:48thhellerit might still fail though#2018-03-2110:49mitchelkuijpersI will try hold on#2018-03-2110:49thhellerno idea whats going on#2018-03-2110:49mitchelkuijpersNow i have this again:
Exception in thread "async-thread-macro-15" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__59438
	at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21)
	at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
	at clojure.core$reduce.invokeStatic(core.clj:6747)
	at clojure.core$reduce.invoke(core.clj:6730)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63)
	at shadow.cljs.devtools.server.reload_classpath$start$fn__59470.invoke(reload_classpath.clj:92)
	at clojure.core.async$thread_call$fn__8239.invoke(async.clj:442)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
#2018-03-2110:49mitchelkuijperswhich is probably the error that causes this#2018-03-2110:49mitchelkuijperswhen doing (shadow/watch :app)#2018-03-2110:49thhellercan you try adding a custom cljs version please?#2018-03-2110:50thheller[org.clojure/clojurescript "1.10.145" :classifier "slim"]#2018-03-2110:50mitchelkuijpersSure#2018-03-2110:50thhellerno AOT#2018-03-2110:50thhellerwonder if that changes anything#2018-03-2110:50mitchelkuijpersrestarting#2018-03-2110:51thhellerdon't forget lein clean as usual. doesn't affect shadow-cljs but I don't know what lein may have done#2018-03-2110:53thhellerdo you get the error immediately on startup or only after changing a file?#2018-03-2110:53mitchelkuijpersI get it after stopping and starting the server again and then running (shadow/watch :app)#2018-03-2110:54mitchelkuijpersI am running this to start it btw:
(do (shadow.cljs.devtools.server/start!) (shadow.cljs.devtools.api/watch :app) (shadow.cljs.devtools.api/nrepl-select :app))
#2018-03-2110:55thhellerthat is fine#2018-03-2110:55mitchelkuijpersCould a circular dependency break shadow-cljs? Just thinking out loud here#2018-03-2110:56thhellercircular how? cljs? no#2018-03-2110:56thhellerso to break it you call (shadow.cljs.devtools.server/stop!) and then the start above again?#2018-03-2110:57mitchelkuijpers
cljs.user> :cljs/quit
:cljs/quit
user> (shadow-server/reload!)
Worker shutdown.
shadow-cljs - HTTP server for :devcards available at 
:shadow.cljs.devtools.server/restarted
user> Exception in thread "async-thread-macro-4" java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.server.reload_classpath$process_update$fn__65735
	at shadow.cljs.devtools.server.reload_classpath$process_update.invokeStatic(reload_classpath.clj:21)
	at shadow.cljs.devtools.server.reload_classpath$process_update.invoke(reload_classpath.clj:21)
	at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
	at clojure.core$reduce.invokeStatic(core.clj:6747)
	at clojure.core$reduce.invoke(core.clj:6730)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invokeStatic(reload_classpath.clj:45)
	at shadow.cljs.devtools.server.reload_classpath$process_updates.invoke(reload_classpath.clj:38)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invokeStatic(reload_classpath.clj:75)
	at shadow.cljs.devtools.server.reload_classpath$watch_loop.invoke(reload_classpath.clj:63)
	at shadow.cljs.devtools.server.reload_classpath$start$fn__65767.invoke(reload_classpath.clj:92)
	at clojure.core.async$thread_call$fn__9069.invoke(async.clj:442)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
#2018-03-2110:57thhellerI do that several hundred times when working on shadow-cljs itself yet I have never seen that error#2018-03-2110:57mitchelkuijpersthe error happens on the file change after reload!#2018-03-2110:57thhellerhmm do you use tools.namespace?#2018-03-2110:58mitchelkuijpersYes#2018-03-2110:58thhellerbut not during this process?#2018-03-2110:58mitchelkuijpersHmm yes I have run go#2018-03-2110:59mitchelkuijpersThat would make sense that it breaks it#2018-03-2110:59thhellerI don't know why it would though. maybe its something related to the nrepl change I did#2018-03-2110:59mitchelkuijpersMaybe i should start running it externally#2018-03-2110:59mitchelkuijpersLet me try that out to see if that breaks#2018-03-2111:00thhellerwell I have shadow-cljs embedded in lein to develop it so it should work just fine#2018-03-2111:00thhellercan you try just restarting it directly from the REPL without calling the tools.namespace stuff?#2018-03-2111:02thhellerjust trying to isolate if it might be trouble in your deps#2018-03-2111:03mitchelkuijpersHold on wil restart it first#2018-03-2111:03thhellerthrow in a lein clean for safety#2018-03-2111:04mitchelkuijpersI'll also run a lein deps tree#2018-03-2111:05mitchelkuijpershmm core async conflict might be related?#2018-03-2111:06thhellerhmm shouldn't be no#2018-03-2111:06thhellerdidn't see anything from it on the stacktraces yet#2018-03-2111:08mitchelkuijpersI just restarted#2018-03-2111:08mitchelkuijpersen changed a file#2018-03-2111:08mitchelkuijpersand nothing happens#2018-03-2111:08mitchelkuijpersit does not reload#2018-03-2111:09thhellerstill the same error?#2018-03-2111:10thhellerthe core.async thread macro hasn't changed in forever so that shouldn't matter#2018-03-2111:11thhellerI have no clue. it might be the piggieback change I did because that messes with the *ns* binding which is a bit scary#2018-03-2111:11thhellerbut piggieback does that so it should be fine#2018-03-2111:13mitchelkuijpersVery weird the only thing is broken is the watching and recompiling#2018-03-2111:13mitchelkuijpersthe repl works like a charm#2018-03-2111:13thhellerI don't get why that would be broken. I didn't touch that.#2018-03-2111:14thhellerand why does it fail loading the class in the first place#2018-03-2111:14thhellersuch a weird error#2018-03-2111:15thhellerwait does the reloading also not work if you just started it clean without stop! or reload! first?#2018-03-2111:18mitchelkuijpersYes#2018-03-2111:20thhellerwhich version were you on before upgrading?#2018-03-2111:21mitchelkuijpers2.1.21#2018-03-2111:23thhellerI don't get why it fails on reload-classpath. I didn't touch that in forever#2018-03-2111:26mitchelkuijpersOnly other conflicts with jars that I find is jackson-core but I cannot imagine that breaking anything#2018-03-2111:28thhelleryeah doubtful#2018-03-2111:31thhellerwait do you AOT compile maybe?#2018-03-2111:31mitchelkuijpersNo#2018-03-2111:37mitchelkuijpersWould it help if I put shadow-cljs in verbose mode somehow?#2018-03-2111:39thhellerprobably not. there is not additional logging in that place.#2018-03-2111:42thhellerI have never seen this error in several years of clojure. I don't understand why you'd get NoClassDefFoundError. clojure is supposed to create the class before loading it.#2018-03-2111:42mitchelkuijpersHmm I do a set-refesh-dirs#2018-03-2111:42mitchelkuijpersAnd now it works#2018-03-2111:42mitchelkuijpersWhen I removed that call#2018-03-2111:43mitchelkuijpersI had this:
(set-refresh-dirs "dev/server" "src/main" "test" "src/cards")
from
[clojure.tools.namespace.repl :as tools-ns :refer [set-refresh-dirs]]
#2018-03-2111:43mitchelkuijpersremoval works.. I still had this from the fulcro template#2018-03-2219:01tony.kayThe set-refresh-dirs was there because figwheel would copy cljc files into resources, and then server refresh will accidentally find them and cause problems. Shadow doesn’t do that, so it probably isn’t helping anything.#2018-03-2111:44thhellerI wonder why that would affect anything. will take a look at tools.namespace#2018-03-2111:44mitchelkuijpersI'll see if it stays fixed#2018-03-2111:47mitchelkuijpersThank you for listening @thheller#2018-03-2112:00mitchelkuijpersIt also keeps working after resets#2018-03-2112:00thhellergood to know#2018-03-2116:00mitchelkuijpers@thheller Now I am running into: java.lang.NoClassDefFoundError: Could not initialize class shadow.build.warnings$get_source_excerpts$iter__60601__60605$fn__60606$fn__60607$fn__60609#2018-03-2116:00mitchelkuijpersReally weird that I am getting NoClassDefFoundError#2018-03-2117:37thheller@mitchelkuijpers so weird indeed#2018-03-2117:38thheller> val_waeselynck [17:28] @thheller I tend to have this sort of error after I uberjar my project while my code is running. I think this changes the class files in some way to messes up the REPL.#2018-03-2117:38thhellerdo you do anything like that?#2018-03-2117:39thhellerbut the shadow-cljs classes should never be written to disk anyways#2018-03-2117:39thhellerI backed out of shipping AOT code because of errors like this#2018-03-2117:39thhellerbut I can't explain where this is coming from. which clojure version are you using?#2018-03-2117:45mitchelkuijpers1.9.0#2018-03-2117:45mitchelkuijpersI am now running it separately with the shadow-cljs command#2018-03-2117:47thhellerdid your clojure process use any classloader trickery?#2018-03-2117:47thhellerimmutant or some other container?#2018-03-2118:36mitchelkuijpersNo nothing like that#2018-03-2120:33jmckitrickHere I am @hlolli#2018-03-2120:34hlollicool, Im guessing you didn't set :devtools ?
:devtools {:http-root "public"
:http-port 8088
;; :http-handler dev.server/handler
:after-load visitor.main/init}
this is my current project, the after load would be my react init function.
#2018-03-2120:35jmckitrickI just cloned and ran this: https://github.com/lauritzsh/reagent-shadow-cljs-starter#2018-03-2120:35jmckitrickMaybe it’s too old.. I’ll update it#2018-03-2120:35hlolli
"devDependencies": {
    "shadow-cljs": "^2.0.115"
  }
yup too old I think 🙂
#2018-03-2120:36jmckitrickI see that now lol#2018-03-2120:37jmckitrickThere it is!#2018-03-2120:38jmckitrickOhh, nice spinner#2018-03-2120:38jmckitrickWow, I might switch from lein/cljsbuild to boot/shadow in the same week, lol.#2018-03-2120:39hlolliyup, I'm like a broken record repeating this tip, but you can basically start shadow-cljs watch and then start the backend to serve the output directory, you'll get the hot reload weather or not you're conencted to the localhost port given in the :devtools.#2018-03-2120:40hlolli(and the hud)#2018-03-2120:40jmckitrickok#2018-03-2120:42jmckitrickI assume it plays nicely with boot as well?#2018-03-2120:43hlolliyes, if you keep the clojure seperated from the clojurescript, then it would also work well with python, node or any backend.#2018-03-2120:44hlollisome folks are mixing lein and shadow in some fancy way, have no idea if that works with boot, and what the gain is from doing that.#2018-03-2120:47thheller@jmckitrick I know very little about boot and haven't done many tests. I know that it interferes a little with shadow-cljs related to caching and things. everything should work in theory but I really don't know.#2018-03-2120:47thhellerhappy to look at problems it you find any though#2018-03-2120:57jmckitrickI greatly appreciate the offer! We’re doing the first official clojure products at work, and I’ll be on the hot seat for any issues we run into along the way 😧#2018-03-2120:58thhellerthe smoothest option is to just keep the CLJ and CLJS worlds separate. they don't benefit at all when you combine them and just cause headaches if your CLJS deps interfere with CLJ deps#2018-03-2121:02jmckitrickInteresting. ok, duly noted.#2018-03-2121:35jmckitrickShould I be surprised if the binary is much smaller than that produced by cljs-build?#2018-03-2121:42thhellernot really. people frequently report this.#2018-03-2121:43thhellerthe config sets a couple of optmizations that you maybe didn't set when using cljsbuild#2018-03-2121:43thhellerand cljsjs is pretty ineffecient as well#2018-03-2121:43jmckitrickI might be sold, then. I’m going to spend the day tomorrow digging in deeper. So much for generative testing day, lol.#2018-03-2122:40justinleeI’ve updated my guide on how to use javascript in cljs. My goal here is to have something to point people to when they ask about this on slack. I’d appreciate a read before I start sending it to folks just to make sure I’m not mischaracterizing something. https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d#2018-03-2122:47jmckitrick@thheller doesnt it incur extra overhead to separate front and back ends? In other words how do I serve up the front end page and assets separately from the backend? I assume I need to run Express?#2018-03-2122:47jmckitrick@lee.justin.m you probably know the answer as well#2018-03-2122:48justinleeduring development you just serve the front end from the shadow-cljs development server#2018-03-2122:49justinleeduring production, you’ll compile the front end to a javascript bundle and then serve it as if it were a static resource from the backend#2018-03-2122:49justinleethe only annoying thing is that you have a cors issue during development#2018-03-2122:51jmckitrickSo I can’t really keep the code entirely separate, then, right? The payload still needs to end up in the js directory of the server project#2018-03-2122:53justinleeI was assuming you’ve got a SPA front end that connects via some kind of API that is running on clojure.#2018-03-2122:53thhellerI wouldn't separate the code because you might want to share some code from the client and server#2018-03-2122:54justinleeIf you are running a templated backend then the “keep it separate” advice might be more complicated.#2018-03-2122:54thhellerif you compile your code to say public/js and configure your server to serve static files from public you are all set#2018-03-2122:54justinleeOr if you’re doing something like server side rendering, that might call for something different.#2018-03-2122:55thhelleror the usual resources/public/js if you want to serve resources instead of files#2018-03-2122:56thheller@lee.justin.m reading over your gist#2018-03-2122:57thheller> The "double bundle" approach: same as (3)#2018-03-2122:58thhellershouldn't that be like (1)? you don't need to tell the compiler about the double bundle at all in theory#2018-03-2122:58thheller> "shoudl" typo#2018-03-2122:59thheller> I do not reccommend either of these approaches for now:#2018-03-2122:59thhelleryou do recommend #2 😉#2018-03-2122:59justinleeI think it should say like (1) or (3) because you can do it either way (the two blog posts I link to do either either way)#2018-03-2122:59thhellerwait nvm#2018-03-2123:02thhellerone extra thing that shadow-cljs does that the default cljs externs inference doesn't do#2018-03-2123:02thhellersince shadow-cljs fully processes all .js files it extracts some extra externs infos from them#2018-03-2123:02thhellermight be worth mentioning#2018-03-2123:02justinleedefinitely#2018-03-2123:04thheller> Shadow-cljs's import syntax#2018-03-2123:05thhellerthat makes it sound like string requires are shadow-cljs only. they are not. if :npm-deps ever works out it should work identically in CLJS#2018-03-2123:06justinleeAccurate? > Use shadow-cljs automated externs inference. Shadow-cljs will give you warnings when it can’t figure things out and you can just provide a type hint. Because shadow processes all of your JavaScript libraries, Shadow can infer externs from them, which is a real advantage over some other approaches relying on the built-in compiler’s extern inference.#2018-03-2123:08justinleedamnit i edited this so much that some stuff is out of order now 🙂#2018-03-2123:08thhellerin theory if externs inference for CLJS was perfect that would be enough. the extra JS processing just makes it a bit more reliable for now#2018-03-2123:15justinleeis it true you can use figwheel with shadow if you want to?#2018-03-2123:15thhellerno#2018-03-2123:16justinleeokay fixing that#2018-03-2123:17thhellerin your example config. remove clojure/clojurescript deps, they are provided. :http-handler push-state is the default now so you can remove that as well#2018-03-2123:18thheller>Note the :after-load entry point: this is what shadow-cljs will call when it hot reloads new code.#2018-03-2123:18thhellerNote the :after-load symbol, this is what shadow-cljs will call after hot reloading code finishes.#2018-03-2123:18thhelleror something like that#2018-03-2123:18thhellerthe "after" is key here, as before also exists#2018-03-2123:19thheller"when" is too ambiguous I think#2018-03-2123:19justinleeyou know i’m going to get rid of all that. it’s getting off topic#2018-03-2123:20justinleei just want to inform people about why shadow works better for imports#2018-03-2123:20justinleeA quickstart guide should be separate.#2018-03-2123:20thhellerI wouldn't bash cljsjs so heavily. It works pretty darn well IFF you are only using a very small amount of it. say if you are only using React it is pretty darn good for that.#2018-03-2123:20thhellerproblem is that it really doesn't scale well past say 3 packages#2018-03-2123:20justinleeIt was a freaking nightmare for me 🙂#2018-03-2123:21thhelleryeah probably starts breaking at 2 already#2018-03-2123:21justinleeIt’s so complicated! Here, learn this barely documented externs syntax! Here, learn boot!#2018-03-2123:21thhellerbut I used it for a very long time when I just wanted react is it worked well for that#2018-03-2123:22justinleeWell the real point of this document is for people who use lots of react libraries#2018-03-2123:22thhelleryeah making custom cljsjs packages is horrible. I wouldn't want to do that either#2018-03-2123:22justinleeAnd it doesn’t work for that at all#2018-03-2123:22thhellertrue#2018-03-2123:23justinleeI’ll look for places to tone it down. I don’t want to be mean to people who spent their free time on something.#2018-03-2123:23thheller> Can use standard CDN distros?#2018-03-2123:23thhellershadow-cljs: yes#2018-03-2123:23justinleereally?#2018-03-2123:23thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_a_cdn#2018-03-2123:24justinleeoh shit that’s pretty cool!#2018-03-2123:27thhellerpretty good overview of the current options overall#2018-03-2123:31thhelleryou could also mention that shadow-cljs actually allows full 100% interop (ns demo.bar (:require ["./foo" :as foo])) would load demo/foo.js from the classpath#2018-03-2123:32thhellerand that JS can actually require CLJS via import cljs from "goog:cljs.core"; cljs.assoc(nil, "foo", 1)#2018-03-2123:33thhellerthis is not 100% perfect yet but it is a goal of mine to support compilation of JS projects that just want to start using CLJS without having to rewrite everything#2018-03-2123:33thhellerso just start by introducing things gradually one file at a time or so 😉#2018-03-2123:35thhellerthats definitely something CLJS can't do 😉#2018-03-2123:36thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_dealing_with_js_files#2018-03-2123:38thhellerin theory I could add support for https://www.webjars.org/ which also mirrors npm#2018-03-2123:39justinleeOkay I added these two points. It’s a little OT but I agree it’s worth mentioning. * Shadow-cljs actually lets you load any JavaScript file on the classpath. So, (ns demo.bar (:require ["./foo" :as foo])) would load demo/foo.js from the classpath. [This is experimental.](https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js) * It also allows interop in the other direction, [by embedding cljs in an existing JavaScript app](https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module).#2018-03-2123:40thhellernpm-module isn't related to that#2018-03-2123:40justinleeoh oops#2018-03-2123:40thhellerwell it kind of is but its a different thing altogether#2018-03-2123:41thhellersince webpack or whatever is doing the packaging then#2018-03-2123:41thhellershadow-cljs just spits out webpack compatible code basically#2018-03-2123:41thhellerits complicated 😛#2018-03-2123:41justinleewhat’s the relevant section of the manual?#2018-03-2123:42thhellerdealing with js files I linked above#2018-03-2123:42thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_dealing_with_js_files#2018-03-2123:42thhellerhmm thats still missing an example for how the JS could talk to CLJS#2018-03-2123:43justinleethis part? https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js#2018-03-2123:43thhelleroh hehe yes. guess I did mention it.#2018-03-2123:44thhelleroh doh , { keyword } this doesn't work anymore with the latest closure compiler#2018-03-2123:44thhelleronly cljs.keyword but the direct refer was broken by them 😞#2018-03-2123:45thhelleror does it? I'm confused#2018-03-2123:45thhellertoo tired. I need sleep.#2018-03-2123:45justinleego to sleep. 🙂 thanks so much for your help. i feel better about this document now.#2018-03-2123:46thhellerthanks for writing it. sounds a bit like one giant ad for shadow-cljs. I like it 😉#2018-03-2123:48justinleei view it as essential guidance for any js->cljs transition 🙂#2018-03-2123:50thhelleralright I'm off to bed. gn8#2018-03-2200:49grounded_sageI'm venturing into using shadow-cljs. Everything seems to just work right up until I try to apply styles. Not sure how I would go about it from here.#2018-03-2200:50grounded_sage
(ns starter.browser
   (:require [rum.core :as rum]
             [react-native-web :as react-native :refer (View Text)]))



(rum/defc hello-world []
  [:div
   [Text "hello there"]
   [:h3 {:style {:color "blue"}} "Edit this and watch it change!"]])
#2018-03-2200:50grounded_sageI'd like to apply style to the Text element#2018-03-2202:50justinlee@grounded_sage that shouldn’t have anything to do with shadow#2018-03-2202:51grounded_sageYea I've been playing around with it. Can get things to work with Reagent. It appears it's to do with React component interop with Rum#2018-03-2202:52justinleeare you saying that the Text element imports and displays but it doesn’t style the way you expect?#2018-03-2202:52grounded_sageThat snippet of code works as is. However when it comes to styling I can't style it.#2018-03-2202:53justinleeI never got interop to work right with rum which is why I switched to reagent, honestly. I quite liked rum otherwise. It was just never clear how to pass back and forth between react components.#2018-03-2202:53grounded_sageWhen using Reagent I can do this and then it works
(def Text (r/adapt-react-class Text))

(defn app []
  [:div
   [Text {:style {:color "blue" :font-size "40px"}}   "hello"]
#2018-03-2202:53grounded_sageYea my preference is Rum however this is making me think otherwise 😞#2018-03-2202:54justinleeI feel you. I preferred the syntax of rum in many ways.#2018-03-2202:55justinleeso try one thing: try [Text {:style “color: blue”} “Hello there”]#2018-03-2202:55justinleeit may be that rum doesn’t do the style mapping on custom components#2018-03-2202:55justinleeas a general matter, it doesn’t make sense to do that--I assume this is some kind of react native thing#2018-03-2202:57grounded_sageThere appears to be some cache stuff going on. I'm getting old errors and code rendering that no longer exists in the file.#2018-03-2203:00justinleeone thing that can catch me: make sure your stuff is compiling. sometimes the heads-up-display will disappear and your old code will just be sitting there while your existing code has a compile error#2018-03-2203:00justinleeotherwise shadow is actually really good about caching#2018-03-2203:13grounded_sageFor some reason shadow-cljs is flat out not working anymore lol. Have no idea what I've done now 😛#2018-03-2203:14justinleewhat’s it doing?#2018-03-2203:14justinleetry restarting the server and see what you get on the terminal#2018-03-2203:16grounded_sageHow do you restart?#2018-03-2203:17grounded_sageIt says it is a server error#2018-03-2203:17grounded_sageI've retried downloading the quickstart#2018-03-2203:17grounded_sageIt doesn't work. On my old one it just throws a heap of errors that no longer exist. On my reagent one no changes to the file are being reflected but it is serving it as it was before#2018-03-2203:18justinleecan you look at your terminal history and tell me how you started shadow?#2018-03-2203:19grounded_sageI've just been using this from the quickstart npx shadow-cljs clj-repl#2018-03-2203:20justinleeand you just ran that once and left it up?#2018-03-2203:21justinleei believe you should just be able to kill that process and then restart it#2018-03-2203:21grounded_sageNo I've stopped and started on different files#2018-03-2203:22justinleeso kill everything and then go to your browser and reload the page#2018-03-2203:22justinleeif it reloads, there’s an old shadow process up somewhere that you’ll need to kill#2018-03-2203:32grounded_sageI've done a full restart of computer. This is the error I am getting on the Rum on
[:app] Build failure:
The required namespace "starter.browser" is not available.

[2018-03-22 13:31:05 - WARNING] stale websocket client, please reload client :app
[2018-03-22 13:31:23 - WARNING] stale websocket client, please reload client :app
[2018-03-22 13:31:40 - WARNING] stale websocket client, please reload client :app

#2018-03-2203:35justinleethe issue is that it can’t find your source code, I think. the build failure is causing all of these issues#2018-03-2203:35grounded_sageWeird thing is that the namespace was there. Making a change in the file and saving seems to have fixed it by triggering it to recompile#2018-03-2203:36justinleeare you starting from the same directory as before#2018-03-2203:36justinleethat is super weird#2018-03-2203:37justinleeI don’t really understand what’s going on. thomas is asleep so he won’t be back online for a while. actually you’re behind me so you’ll probably still be up when he gets up#2018-03-2203:37grounded_sageOk seems that calling [Text .... inside the Rum one was throwing a warning in the console. But it was still rendering#2018-03-2208:18thheller@grounded_sage The required namespace "starter.browser" is not available. is it possible your ns form is busted?#2018-03-2208:18thhellerthe warning/error for this currently ends up in the wrong place I think#2018-03-2208:19grounded_sageI'm not sure what the error was. Everything seemed fine. I've actually moved past this error and am currently trying to adapt React classes to be used with Rum.#2018-03-2208:21thhellerok. I don't know anything about rum but it should work identically as in other tools. if it doesn't please let me know.#2018-03-2208:28grounded_sageYea rum is working and so is reagent. It's just there isn't a standard way to interop with React components in Rum. So I'm searching the web for solutions. I actually feel like I am getting somewhere with Shadow CLJS over all the other options. Thanks!'#2018-03-2208:59thheller@grounded_sage you might be able to just create the React Element directly? don't know how Rum deals with this but (:require ["react" :refer (createElement)]) then (createElement Text #js {:foo "bar"} ...)#2018-03-2208:59thhellergetting children to work properly might be an issue then though#2018-03-2209:24sundbpHi. If I add a new file and namespace in a shadow-cljs project, should that file be picked up without restarting a shadow-cljs watch session?#2018-03-2209:24thhelleryes#2018-03-2209:25thhellerwell only if you also require that file somewhere#2018-03-2209:25thhellerjust creating it wouldn't have any effect#2018-03-2209:27sundbpI’m not really seeing this. so I have x.cli requiring x.foo that now requires x.api (this last one is new). I can’t seem to get it to try to compile this one#2018-03-2209:28thhellerhmm did you require before creating the file? that might result in a situation where the worker gets stuck#2018-03-2209:28sundbpi probably did, yes#2018-03-2209:29thhellerhmm yeah that would be an issue. let me look into that.#2018-03-2209:29sundbpthen out of luck and a restart?#2018-03-2209:30thhellerwhat was the last message you got?#2018-03-2209:30thhellerThe required namespace "starter.browser" is not available. like this?#2018-03-2209:31sundbpit’s nodejs: The required namespace "permafrost.api" is not available, it was required by "permafrost/health.cljs".#2018-03-2209:31sundbphm. a restart of the watch has same thing. could the state be messed up in .shadow-cljs ?#2018-03-2209:32sundbpor is it pilot error somewhere else#2018-03-2209:33thhellerjust to be sure you have a src/permafrost/api.cljs directly next to src/permafrost/health.cljs?#2018-03-2209:33thhellerunlikely for the cache to be messed up#2018-03-2209:33sundbp
» ll src/cljs/permafrost/api.clj src/cljs/permafrost/health.cljs                                                                                                                                                                                      09:32:53
Permissions  Size User   Group Date Modified Name
.rw-r--r--    704 sundbp staff 22 Mar  9:28  src/cljs/permafrost/api.clj
.rw-r--r--  1.6Ki sundbp staff 22 Mar  9:21  src/cljs/permafrost/health.cljs
#2018-03-2209:33thhellerha!#2018-03-2209:33thhellerits a .clj file#2018-03-2209:34sundbpha - old habbit!#2018-03-2209:34thhellerI could totally add a warning for this#2018-03-2209:34sundbpso this is a try if require before file picks it up - seems like it! thanks#2018-03-2209:35sundbpthat’d be awesome - I can see myself doing it again..#2018-03-2209:35sundbp
[:pf] Build failure:
The required namespace "permafrost.api" is not available, it was required by "permafrost/health.cljs".

[:pf] Compiling ...
[:pf] Build completed. (168 files, 59 compiled, 0 warnings, 42.48s)
#2018-03-2209:35sundbpall good - thanks. it’s an awesome tool!#2018-03-2209:45thheller
[:browser] Build failure:
The required namespace "demo.run-test" is not available, it was required by "demo/browser.cljs".
"demo/run_test.clj" was found on the classpath. Should this be a .cljs file?
#2018-03-2209:45sundbpthat’s great - very user friendly!#2018-03-2210:33grounded_sageDoes shadow cljs do dead code elimination? I feel like I am accumulating too many libraries just for small pieces of functionality.#2018-03-2210:36thhellerfor CLJS? yes.#2018-03-2210:37grounded_sageOk cool.
#2018-03-2210:38grounded_sageIs it possible to do something like this?
Rum will call sablono.compiler/compile-html in its macro. You could add a sablono.compiler namespace (a .clj file) into your project and create a compile-html function which calls Hicada with the config you like. This namespace will take precedence over any CLJ namespace on your classpath.
#2018-03-2210:38grounded_sagehttps://medium.com/@rauh/a-new-hiccup-compiler-for-clojurescript-8a7b63dc5128#2018-03-2210:39thhellerhmm?#2018-03-2210:39grounded_sageI feel like I am muddying the waters a lot here lol. I would love it if I could just somehow use React Native Web with Rum library and be able to have it all built in Node on Netlify xD#2018-03-2210:40grounded_sageI feel like I need to get my Clojure foo a lot better and hack my own version of Rum together 😕#2018-03-2210:41thhellerI would just give up on the hiccup thing altogether#2018-03-2210:41thhellerdon't need a compiler for hiccup if you are direclty using something better instead#2018-03-2210:43grounded_sageThe problem is Rum uses Sablono internally. Which doesn't work with self hosted.#2018-03-2210:43thheller
(html/div
      (html-section-header (name build-id))
      (html/div
        (html/button
          {:onClick #(conv/transact! this (watch-start! build-id))
           :disabled (any? worker)}
          "watch start")
        (html/button
          {:onClick #(conv/transact! this (watch-stop! build-id))
           :disabled (nil? worker)}
          "watch stop")
        (html/button {:onClick #(conv/transact! this (db/compile! build-id))} "compile")
        (html/button {:onClick #(conv/transact! this (db/release! build-id))} "release"))
      (html/pre {:ref (::dom-ref this)}
        (with-out-str
          (pprint data))))
#2018-03-2210:43thhellerlooks basically like hiccup, doesn't require a compiler.#2018-03-2210:44thhelleremits basically what the hiccup compiler would emit#2018-03-2210:45thhellerhttps://github.com/thheller/shadow/wiki/shadow.markup#2018-03-2210:45grounded_sageReact native for web uses View Text TouchableOpacity etc#2018-03-2210:46rauhI think you should post the stacktrace here as well (which you posted in #rum)#2018-03-2210:46thhellerso create a (rn/view ...) (rn/text ...) wrapper#2018-03-2210:46grounded_sageHmm i see. So shadow has markup etc.#2018-03-2210:47thhellerthe markup stuff is currently only built for the react-dom side#2018-03-2210:47thhellercould adapt it just as easily for RN#2018-03-2210:47thhellerthe point is to call functions instead of this hiccup-ish datastructure that needs to be compiled to be performant#2018-03-2210:49thhellerah ... so you ran into an actual problem#2018-03-2210:49thheller
Exception: No namespace: sablono.core found
    clojure.core/the-ns (core.clj:4128)
    clojure.core/ns-publics (core.clj:4155)
    clojure.core/ns-publics (core.clj:4155)
    shadow.build.macros/find-macros-in-ns (macros.clj:32)
    shadow.build.macros/find-macros-in-ns (macros.clj:30)
#2018-03-2210:49thhellermost likely this means that the macro ns failed to load#2018-03-2210:50grounded_sageThat was when I attempted to overwrite the sablono.compiler using Hicada#2018-03-2210:50thhellerdon't know what that is about but it should work as in any other tool#2018-03-2210:51grounded_sageBut in all honesty I'm really looking a solution I can run entirely in one VM be is JVM or Node so that I can deploy to Netlify.#2018-03-2210:52thhellerdo you mean running the code in the JVM or compiling the code in the JVM?#2018-03-2210:53grounded_sageCompiling#2018-03-2210:53thhellerdoes netlify support java?#2018-03-2210:53grounded_sageI'm kind working on creating some holy grail JAMstack solution in Clojurescript.#2018-03-2210:54grounded_sageThey have docker images with common build tools and allow others to provide build tool solutions.#2018-03-2210:54grounded_sageSo you can basically pick your build tool. Set what command is required to build it. Then point them at a github/gitlab repo.#2018-03-2210:55grounded_sageThen any changes you push they run the build and autodeploy to global CDN#2018-03-2210:55grounded_sagePoor mans devops#2018-03-2210:55grounded_sageI think it is a great solution for front ends even for larger productions. You cleanly separate front and backend.#2018-03-2210:56thhellerbut how is this related to the hiccup stuff?#2018-03-2210:58thhellerif java is available you can just run npx shadow-cljs release my-app and then have it copy your :output-dir to wherever?#2018-03-2211:00grounded_sageI don't know I'm confused as I don't know enough about all the processes. I am assuming that most options with netlify would just have one option in the docker images. So like either Node, JVM/Leiningen, JVM/Boot etc#2018-03-2211:01grounded_sagehttps://github.com/netlify/build-image/blob/master/Dockerfile#L299#2018-03-2211:02thhellerso it appears that java is installed. we don't need lein or boot#2018-03-2211:02thhellerbut back up a second. what are you actually trying to do?#2018-03-2211:03thhelleryou have a repo that should run some command, create a .js file that is then copied somewhere and loaded in a webpage?#2018-03-2211:07grounded_sageHave some kind of build process where I can output everything into some target folder (html, css, js, images, svg etc) Whilst using React Native for Web so that I can write code the same way (as close as possible) between doing a web app and native app.#2018-03-2211:10thhellerok shadow-cljs currently only supports JS and doesnt do the rest. but you can use whatever other tool you want for those#2018-03-2211:10thhellersay shadow-cljs generates your output into public/js#2018-03-2211:11thhellerhave another tool generate things into public/css and so on#2018-03-2211:11thhelleryou then copy the public folder and you are done?#2018-03-2211:12grounded_sageI think shadow cljs could work.#2018-03-2211:12thhellernpx shadow-cljs release your-build is all you'd need to run#2018-03-2211:13thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#L10#2018-03-2211:13grounded_sageYea.#2018-03-2211:13grounded_sageI really think my main issue is how I get Rum to come to the party lol.#2018-03-2211:14thhellerso the problem is that Rum doesn't understand react-native?#2018-03-2211:16thhellerFWIW (:require [shadow.markup.react :as html :refer ($)] ["react-native" :as rn :refer (Text View)]) then in render ($ Text {:style style-obj} "hello world")#2018-03-2211:16thheller$ is just sugar for calling createElement directly#2018-03-2211:17thhellerI could add a shadow.markup.react-native :as rn then (rn/text {:style ...} "foo") would just work#2018-03-2211:17grounded_sageJust normal React components#2018-03-2211:18thhellerI don't do any react-native dev so I have never written any utils for it#2018-03-2211:18grounded_sageReact Native for Web creates normal react components. https://github.com/necolas/react-native-web#2018-03-2211:18grounded_sageIt's just a way to create code that can work on React Native or React (web)#2018-03-2211:19grounded_sageSo you aren't writing View for one codebase and Div for the other when it's exactly the same thing visually.#2018-03-2211:21thhelleryeah so the problem is getting that to work with rum? I can guarantee that the above shadow.markup example I posted will just work#2018-03-2211:21thhellersince it doesn't have to do all this complex macro magic#2018-03-2211:21grounded_sageAnyways this works fine in Reagent and I believe Shadow-cljs is the right tool. No point me cluttering this channel with an issue that is basically unrelated:)#2018-03-2211:21thhellersure reagent should deal with this as well#2018-03-2211:23grounded_sageI don't think Shadow.markup does it for me because it does defstyled approach. All good. I will continue plugging away at this Rum problem haha#2018-03-2211:23thhellerI guess I don't understand how react-native-web works if there code example doesn't have a single reference to react-native-web#2018-03-2211:24thhelleraaaaaaaah ... babel-plugin-react-native-web ...#2018-03-2211:24grounded_sageYea haha. Tripped me up as well. I was like WHERE IS THIS COMING FROM. haha#2018-03-2211:25thhellerwell thats BS ...#2018-03-2211:26grounded_sageWell this works flawlessly
(ns starter.core
    (:require [reagent.core :as r]
              [react-native-web :as react-native :refer (Text View)]))

(def Text (r/adapt-react-class Text))
(def View (r/adapt-react-class View))

(defn app []
  [:div
   [View {:style {:background-color "red" :height "100px" :width "100px"}
          :accessibility-role "main"}
    [Text {:style {:color "blue" :font-size "40px"}}   "hello"]].....
#2018-03-2211:26grounded_sageBut that is using Reagent 🙂#2018-03-2211:26thhellerwhats wrong with reagent?#2018-03-2211:27thheller["react-native" :as react-native :refer (Text View)]#2018-03-2211:27grounded_sageI find Rum to be much nicer. Except this not working with React components is making me think otherwise haha#2018-03-2211:28thhellerand in your build config :js-options {:resolve {"react-native" {:target :npm :require "react-native-web"}}} 😉#2018-03-2211:28grounded_sageah nice!#2018-03-2211:28thhellerif you want to truly use the same code#2018-03-2211:29thhellerbasically all that does is rewrite ["react-native" :as react-native :refer (Text View)] to ["react-native-web" :as react-native :refer (Text View)]#2018-03-2211:30grounded_sageWell at the moment it's just a learning exercise. My focus is all web but this should help me bridge that.#2018-03-2211:30grounded_sageYea awesome. So much better than a babel plugin haha#2018-03-2211:30thhellerdoesn't do anything to the reagent/rum situation but might make things cleaner if you actually have a second build for a RN app#2018-03-2211:30grounded_sagecheers#2018-03-2211:45grounded_sageAh now I see where I am running up against. I tried this ages ago which is what was causing issues I first brought up in this channel. https://github.com/tonsky/rum/issues/20#issuecomment-282471141#2018-03-2211:46grounded_sagesablono is clj. So I was calling clj in cljs haha. So it seems all solutions would require me to do some clj if I am to use Rum.#2018-03-2212:01grounded_sageNot quite sure whether this could solve my problem but do you think I could use this https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-03-2212:02thhellerwhat problem?#2018-03-2212:02grounded_sageJust needing to run some clj to do the class adapting in Rum.#2018-03-2212:03grounded_sageIt looks like if I could use sablono.util and adapt them I could then just pull them in.#2018-03-2212:04thhellerI'm sorry I really don't understand what you are trying to do. Do you have some code I can look at?#2018-03-2212:05thhellerbut no clj-run is only meant to call clojure core directly. not as part of a build or anything.#2018-03-2212:06grounded_sageAh ok. Yea it probably won't work then. That comment #20 has the code I am referring to.#2018-03-2212:07grounded_sageThank you for your time! I think my best bet is just go with Reagent and move along. 🙂#2018-03-2212:08thhellerIf you create a full repo with an example of what you are trying to do I can look at it#2018-03-2212:08thhellerjust one ns doesn't tell me enough to figure it out#2018-03-2212:08thheller> When you write [(.-Route js/ReactRouter) {:name "home"} ] sablono tries to parse it as tag, something of form [:div attrs & children]. > Just create component with interop syntax, e.g. (js/ReactRouter.Route #js {:name "home"}). Do not put in a vector as first element (but as child — in sablono terms — it’s ok)#2018-03-2212:09thhellerso the issue is that sablono unconditionally tries to parse [Text ...] as something#2018-03-2212:10thhellerreagent has special syntax for [:> NativeThing ...]. maybe sablono does too?#2018-03-2212:15grounded_sageI believe that is just shorthand for adapt-react-class which Rum doesn't have as a utility built in.#2018-03-2212:16thhellerseems like a pretty big issue if rum/sablono doesn't support any native react components/classes#2018-03-2212:17thhellerit shouldn't require any hacks to make this work#2018-03-2212:17grounded_sageDefinitely#2018-03-2214:00jmckitrickOk, here goes. I’m spending part of the day trying shadow and hopefully documenting the cider setup, if I can get it working.#2018-03-2214:01jmckitrickSo, just to clarify where I left off… if I have a project with a backend serving a re-frame SPA, I’m still better off as one project, right? Even with shadow?#2018-03-2214:02jmckitrickI’m already excited about the browser caching fix. FF drives me nuts with that sometimes, and now Chrome does it as well.#2018-03-2214:06jmckitrickFirst, I’d like to fix the broken clojars link.#2018-03-2214:08jmckitrickBut I’m not sure what to do with the link to the image#2018-03-2214:14thhellerbroken clojars link?#2018-03-2214:14jmckitrickActually, the image below it#2018-03-2214:14jmckitrickI see ‘the artifact can be found at’ and a broken image link below that.#2018-03-2214:15thhellerI have no idea what you are talking about?#2018-03-2214:26thhelleroh you are talking about the broken images in the README? wonder why they are broken#2018-03-2214:27thhellerdidn't even notice this#2018-03-2214:28thhellerit appears to be something on githubs end. https://img.shields.io/npm/v/shadow-cljs.svg this source link works#2018-03-2214:28thhellerits just really slow so maybe github just runs into a timeout#2018-03-2214:30jmckitrickThe original gave me a plain text error message.#2018-03-2214:31thhellerah ok .. the guide had one too#2018-03-2214:32thhellerits broken in the README here too https://github.com/thheller/shadow-cljs#2018-03-2214:32thhellershould be a temp github issue#2018-03-2214:42jmckitrickI just added [thheller/shadow-cljs] to my project.clj, and :lein true in shadow-cljs.edn and then I run lein run -m shadow.cljs.devtools.cli compile and I’m getting class not found….#2018-03-2214:42jmckitrickI’ll dig some more#2018-03-2214:44thhellerwhich class?#2018-03-2214:44jmckitrickHold on…#2018-03-2214:44thhelleryou should really start out without the lein integration. so much simpler to just leave lein in its own world and not mess with it#2018-03-2214:44jmckitrickIt went farther this time, not sure why…#2018-03-2214:44jmckitrickok#2018-03-2214:45thhellerthat being said it should work fine so if you get errors please tell me#2018-03-2214:45jmckitrickLet’s go back to no lein…#2018-03-2214:46jmckitrickI do have separate clj cljc and cljs files under src… hopefully that won’t bite me just yet.#2018-03-2214:46thhellerthat is totally fine. I do too.#2018-03-2215:09jmckitrickok, so I got the deps installed and the build succeeded.#2018-03-2215:09jmckitrickI’m looking at a ‘shadow-cljs’ page with release snapshots links….#2018-03-2215:10jmckitrickI guess I need to serve up some other assets…#2018-03-2215:10thhellerthats the internal webserver intended for later UI work#2018-03-2215:11thhellerif you want to get a webserver for your build you can configure it here: https://shadow-cljs.github.io/docs/UsersGuide.html#browser-http-server#2018-03-2215:11jmckitrickOk, so I added a line for :main :entries, but the build is not finding that namespace.#2018-03-2215:12jmckitrickDo I need an entrypoint first?#2018-03-2215:12thhellerdo you have the file in the correct place?#2018-03-2215:12jmckitrickIt works under the lein build, but maybe shadow isn’t finding it?#2018-03-2215:12thhellerdepends on the :source-paths you have configured#2018-03-2215:14thhelleryou lein config probably has a some :source-paths configured. those need to be configured in shadow-cljs.edn as well#2018-03-2215:29jmckitrickI’m up and running!#2018-03-2215:30jmckitrickI had to comment out 2 npm react components… I’ll get to that part next.#2018-03-2216:06jmckitrickOnce I import those components successfully, do I use the [:> foo] notation for Reagent component creation?#2018-03-2216:11thhellerI think so#2018-03-2216:23jmckitrickSo here’s what I’m seeing when I load my page with the react components I’ve imported…#2018-03-2216:23jmckitrickGET net::ERR_ABORTED#2018-03-2216:23jmckitrickAnd there’s a whole list of other components.#2018-03-2216:24jmckitrickAnd I’m also using a minified react for dev… that’s giving me a warning.#2018-03-2216:24thhellerwhy would it abort?#2018-03-2216:24thhellermaybe some adblocker or so interfering?#2018-03-2216:25jmckitrickLet me turn it off#2018-03-2216:25jmckitrickThough it’s never been an issue before.#2018-03-2216:26jmckitrickWait, those classes are not found in my local directory….#2018-03-2216:26jmckitrickjs/cljs-runtime/module$node_modules$….#2018-03-2216:26jmckitrickA lot of them are, but not the 2 I required.#2018-03-2216:32thhellerreact-avatar-editor doesn't depend on lodash#2018-03-2216:33jmckitrickWell, some other things might… but I did discover that neither of these 2 components are in the manifest.edn.#2018-03-2216:34jmckitrickThough the react components and many others are.#2018-03-2216:34thhellerrewind please ... lets first look at this net::ERR_ABORTED thing.#2018-03-2216:34thhellerthere is no reason for this to happen#2018-03-2216:35jmckitrickok#2018-03-2216:40jmckitrickFirst of all, I’m removing code related to this component, doing a hard refresh, and I’m still seeing warnings related to it in the code. The page refuses to render. After a trivial change and hot reload, the page renders (with the components disabled)#2018-03-2216:41thhellerthat probably means that the component was not the cause#2018-03-2216:42jmckitrickBut there’s a handful of components that are not in the manifest, but are required by the 2 that I need. And of course, those 2 are missing as well.#2018-03-2216:42thhellerhttps://github.com/thheller/shadow-react-avatar-editor#2018-03-2216:42jmckitrickBut they are in the package.json.#2018-03-2216:42thhellerthis works perfectly fine for me#2018-03-2216:42jmckitrickHmm.#2018-03-2216:42jmckitrickhold on..#2018-03-2216:43thhellerwhat is the other component you are talking about?#2018-03-2216:43thhellerpackage.json doesn't matter .. only thing that matters is things you actually reference in your code#2018-03-2216:54jmckitrickok. I built your project, and it works. Thanks for that. I see differences in versions, so I bumped mine up, and everything broke.#2018-03-2216:55thhellerit is absolutely possible that your node_modules directory is messed up. npm does that frequently.#2018-03-2216:55jmckitrickI’m reverting to my versions, and I’m going to try that. Then I’ll revert yours to the same as mine, and try that#2018-03-2216:55jmckitrickI just blew that away and reinstalled. Let’s see how far I get…#2018-03-2216:55thhellerthere might be caching issues but I didn't have any in a long time#2018-03-2216:56thhellerjust in case you should kill the shadow-cljs process and delete the .shadow-cljs/builds directory#2018-03-2216:56jmckitrickI was about to ask how to clean#2018-03-2217:03jmckitrickSo the manifest (and cljs-runtime dir) still does not have the modules I need#2018-03-2217:04jmckitrickI don’t get it….#2018-03-2217:04thhellerare you sure you are looking at the correct directory and everything?#2018-03-2217:04jmckitrickHold on…#2018-03-2217:05jmckitricknvm#2018-03-2217:06jmckitrickPretty sure…#2018-03-2217:07jmckitrickThe path is… public/js/cljs-runtime/#2018-03-2217:11thhellerso I just added lodash.debounce to verify that it works and it works just fine#2018-03-2217:11thhellerthats the module$node_modules$lodash_debounce$index.js thats missing for you#2018-03-2217:13thhellerare you sure the file really doesn't exist?#2018-03-2217:14thhellerI'm still suspicious about the NET_ABORTED. that is usually caused by some browser extension.#2018-03-2217:24jmckitrickok, problem solved. All my fault, lol.#2018-03-2217:25jmckitrickI tried to make my shadow config mirror my lein cljs-build config, and I got them out of sync. So the build directories were incorrect.#2018-03-2217:25jmckitrickI tremendously appreciate the time you took to whip up that demo. That helped me narrow it down.#2018-03-2217:26jmckitrickDid you see my PR for cider docs? 😁#2018-03-2217:27thhellerah nice#2018-03-2217:30thhellerI'll look at the emacs stuff tomorrow#2018-03-2217:30thhellershouldn't be too hard to integrate it directly into cider#2018-03-2217:30thhellerso we don't need any of this special stuff#2018-03-2217:39lwhortoni just read through the whole user guide and one thing I didnt see mentioned was devdependencies. in lein, for example, I can specify a dev profile that has its own dependencies for things like binaryage/devtools and piggieback. how does shadowcljs handle this scenario?#2018-03-2217:44thhellerdoesn't have to. the builds control what is used. having :dependencies on the classpath does not affect what a build does.#2018-03-2217:44thhellerso its fine to always have them available#2018-03-2217:45jmckitrickIs there a way to use a debug React build, or else squash the warning I see in the console? @thheller#2018-03-2217:45thhellernote that it will probably get support for this at some point because it becomes relevant when packaging libraries#2018-03-2217:45thhellerbut it currently doesn't do that so it is not required#2018-03-2217:49thheller@jmckitrick the warning is a bit annoying yes but unfortunately no. everything is correct though. it just complains because it doesn't understand what shadow-cljs is doing. still need to bug the react people about their bad detection method#2018-03-2217:50thhelleryou are using the react debug build. react just doesn't expect that it is minified.#2018-03-2217:50jmckitrickNot a problem.#2018-03-2217:50thhellershadow-cljs release will use their proper release version so the warning will go away then#2018-03-2217:52jmckitrickNow that I have this working, I’m wondering if I should try lein integration…#2018-03-2218:00lwhortonis there a way to suppress warnings that stem from not-my-code? for example, something requires cuerdas and cuerdas uses NaN instead of js/NaN#2018-03-2218:01thhelleryeah by updating the cuerdas version. that was fixed a while ago.#2018-03-2218:03thhellerhttps://github.com/funcool/cuerdas/commit/fc9ec9241c6a0098a015d7de1331d2058aacd971#2018-03-2218:03lwhortonbut in general, is there a way to make these disappear? I don’t really know who is requiring some of these transitive deps, and I really dont want to do manual one-off updates and pray that I dont break some api, ya know?#2018-03-2218:04thhellerwell warnings are kinda important so no there is no way to turn them off#2018-03-2218:05thhellersince figwheel and other tools only show warnings once they tend to get ignored and forgotten#2018-03-2218:06thhellerand then people wonder why things break over time#2018-03-2218:06lwhortoni see your premise, but if the third-party code is out of my control it will be incredibly annoying to have those warnings always visible and obfuscating issues within my own app code#2018-03-2218:08thhellerI do see your point. I'll think about it. Maybe just not repeat the warnings on recompile, just show them once on watch start or so.#2018-03-2218:08thhelleryou can just fix it by adding [funcool/cuerdas "2.0.5"] to your deps#2018-03-2218:17jmckitrickSo I’ve just converted a colleague (at a different shop) to shadow-cljs. But he’s asking if there’s a way to alias ‘preact’ as a replacement for ‘react’ and ‘react-dom’ dependencies.#2018-03-2218:18thhellersure#2018-03-2218:18thheller:js-options {:resolve {"react" {:target :npm :require "preact"}}}#2018-03-2218:18thhellersame for react-dom#2018-03-2218:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_redirecting_require#2018-03-2218:19jmckitrickPerfect. I knew I saw something like that somewhere. Let me give it a shot…#2018-03-2218:20thhellerwasn't there a preact/compact or so? might need to use that#2018-03-2218:20jmckitrickCorrect.#2018-03-2218:20thhellerhttps://github.com/developit/preact-compat#2018-03-2218:20jmckitrick‘preact-compat’#2018-03-2218:21thhelleryeah exactly, same way it works in webpack. just written slightly different#2018-03-2218:21thheller
resolve: {
        alias: {
            'react': 'preact-compat',
            'react-dom': 'preact-compat',
            // Not necessary unless you consume a module using `createClass`
            'create-react-class': 'preact-compat/lib/create-react-class'
        }
    }
#2018-03-2218:21thhellerI never actually tested this for preact but it should work#2018-03-2218:22thheller
:js-options
{:resolve
 {"react" {:target :npm :require "preact-compat"}
  "react-dom" {:target :npm :require "preact-compat"}}}
#2018-03-2218:22jmckitrickI’m running it now… fingers crossed#2018-03-2218:28thheller@jmckitrick there might be a cache issue. I don't think :resolve currently invalidates the cache#2018-03-2218:28jmckitrickOk… I’m seeing errors, yes.#2018-03-2218:28jmckitrickso blow away .shadow-cljs/builds?#2018-03-2218:28thhelleryes I didn't account for :resolve in the cache code for this#2018-03-2218:29thhelleryes, try that.#2018-03-2218:29thhellerI'll fix this now#2018-03-2218:37thhellerhmm no it seems to invalidate correctly. I can switch it while a build is running#2018-03-2218:38thhellerah .. it invalidated CLJS correctly but not JS#2018-03-2218:38thhellerso if there is a JS lib that used react it will continue using react#2018-03-2218:38jmckitrickI’m seeing an error message about forceUpdate#2018-03-2218:39jmckitrick@kanwei blow away your .shadow-cljs/builds directory#2018-03-2218:39kanweithis is without any :exclusions in the deps#2018-03-2218:39thhellerdid you add the resolve config for create-react-class?#2018-03-2218:39jmckitrickI did not.. let’s see…#2018-03-2218:40thheller
:js-options
{:resolve
 {"react" {:target :npm :require "preact-compat"}
  "react-dom" {:target :npm :require "preact-compat"}
  "create-react-class" {:target :npm :require "preact-compat/lib/create-react-class"}}}
#2018-03-2218:41jmckitrickI’m up and running!#2018-03-2218:42kanweiit still seems to be loading react from cljsjs#2018-03-2218:42kanweihow do I exclude that from re-frame?#2018-03-2218:42thhellershadow-cljs doesn't support cljsjs so thats impossible 😛#2018-03-2218:43thhellerits probably this#2018-03-2218:43thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#2018-03-2218:43kanweioh#2018-03-2218:44kanweicould be#2018-03-2218:44thhellerthese files just exist since most CLJS projects still expect to use cljsjs#2018-03-2218:44thhellerits fine#2018-03-2218:50kanwei@thheller 1. great job on this, I'm pleasantly surprised#2018-03-2218:50kanwei2. I'm struggling to understand why the advanced compiled files are so much smaller than boot-cljs#2018-03-2218:50kanweiis it because it's running the npm through the optimizer too?#2018-03-2218:51thhellerthats hard to say without knowing what you boot-cljs build did#2018-03-2218:52kanweipretty vanilla re-frame app with cljsjs#2018-03-2218:52thhellerso the problem with as I outlined here https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2018-03-2218:52kanwei
(cljs :optimizations :advanced
                 :compiler-options {:output-wrapper true
                                    :pseudo-names true
                                    :pretty-print true})
#2018-03-2218:52thhellerthe problem with cljsjs is that these are pre-bundled packages#2018-03-2218:52thhellerpre-bundle means that they may include certain dependencies#2018-03-2218:52thhellerand then another package might include them again#2018-03-2218:53thhellerso you end up with the code loading twice#2018-03-2218:53thhelleroh wait#2018-03-2218:53thheller
:pseudo-names true
:pretty-print true
#2018-03-2218:53thhellerthese are debug settings. never use that for a production build 🙂#2018-03-2218:53thhellerso there is your reason#2018-03-2218:54thhellershadow-cljs release app --debug should be equivalent to that boot-cljs config#2018-03-2218:57justinleehey @thheller just out of curiosity why do you minify during development?#2018-03-2218:58thhellerhttps://unpkg.com/react@16.2.0/index.js#2018-03-2218:59thhellerI rely on closure :simple removing the conditional and only leaving one of the requires#2018-03-2218:59thhellerotherwise your page would load the production and dev versions. it would only use the dev version but I still don't like loading stuff I don't need#2018-03-2218:59justinleei see#2018-03-2219:00thhellerthis pattern by the react folks is super annoying#2018-03-2219:00thhellerbut yeah I optimize due to conditional requires .. and its basically free so why not#2018-03-2219:01thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure.clj#L1831-L1847#2018-03-2219:02thhellerbunch of tracking for keeping track of conditional requires#2018-03-2219:02thhellerI hope the world moves to ES6 quickly where this mess isn't allowed anymore 😛#2018-03-2219:03thhelleralthough I'm sure they'll find a way to mess it up again#2018-03-2219:03justinleeit’s so painful that something as dumb as a module system causes so much grief#2018-03-2219:04thhellerwell cljs isn't much better if you think about it. can't do conditional require either but sometimes you just want to.#2018-03-2219:04thhellerproper namespace support is huge though#2018-03-2219:05justinleeat least there is just ONE way to do it in cljs#2018-03-2219:06justinleeevery new js module proposal reminds me of https://xkcd.com/927/#2018-03-2219:07thhelleryep#2018-03-2219:08kanweinow trying to see if inferno-compat will work#2018-03-2219:08kanweigetting stuck on create-react-class#2018-03-2219:09kanwei
:js-options {:resolve {"react"     {:target :npm :require "inferno-compat"}
                                  "react-dom" {:target :npm :require "inferno-compat"}
                                  "create-react-class" {:target :npm :require "inferno-create-class"}}}
#2018-03-2219:10thhellerhmm that might be an issue due to the cljsjs compat namespace#2018-03-2219:11thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#L5#2018-03-2219:11thhellerthis assigns the React.createClass to whatever create-react-class returned#2018-03-2219:12thhellerthis is probably not was inferno-create-class is#2018-03-2219:13thhellercreate a cljsjs/react.cljs file in your project#2018-03-2219:13thhellerand copy the file above and just remove the create-react-class require and set below
#2018-03-2219:15thheller
(ns cljsjs.react
  (:require ["react" :as react]))
(js/goog.exportSymbol "React" react)
#2018-03-2219:15thhellerthis should do it. inferno-compat already provides the React.createClass#2018-03-2219:16kanweiwhat path is cljsjs/react.cljs?#2018-03-2219:16kanweiin src-cljs?#2018-03-2219:16thhellerif you source path is src-cljs then src-cljs/cljsjs/react.cljs yes#2018-03-2219:19kanweihmm still
Uncaught TypeError: reagent.impl.util.create_class.call is not a function
#2018-03-2219:20thhellerwhich reagent version is that?#2018-03-2219:21thhellerthere is no create-class reference in https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/util.cljs#2018-03-2219:22thhellerah but there used to be https://github.com/reagent-project/reagent/blob/18cb1468a671f5a96a912d2e3ccc13bbdbf3a68e/src/reagent/impl/util.cljs#2018-03-2219:22thhellercan you bump to a newer reagent version?#2018-03-2219:23kanweio#2018-03-2219:25kanweiprogress?#2018-03-2219:28thhellerhmm inferno-create-class does not export a function it exports inferno-create-class/createClass#2018-03-2219:28thhellerso the :resolve trick won't work since that differs from what create-react-class exports#2018-03-2219:28kanweiah#2018-03-2219:29kanweifeelsbad#2018-03-2219:29kanweii hate tooling#2018-03-2219:29thhelleryou are pushing the limits here#2018-03-2219:30kanweisomeone has to 🙂#2018-03-2219:30thhelleryou could create a inferno-create-class-compat package#2018-03-2219:30thhellerthat just does module.exports = require("inferno-create-class").createClass;#2018-03-2219:31thhellerthat might do it but I have never used inferno so I don't know what else is hiding in there#2018-03-2219:32kanweicool thanks#2018-03-2219:32kanweiprobably just stick to preact-compat#2018-03-2222:53justinlee@thheller i seem to have gotten my shadow into a bad state. shadow-cljs server start never returns and it doesn’t seem to finish a compile or recompile. if i kill that and do a single build, that works. i’ve already blown away .shadow-cljs but i’m not sure where else there may be state lurking#2018-03-2222:58justinleeoh sorry I guess you have to run a watch command separately in addition to the server. still it is weird that server start does not return#2018-03-2223:55grounded_sageWoot. Got things working. Nearly built a whole website now using React Native for Web.#2018-03-2302:24Josh HorwitzIs there a good full walkthrough/tutorial of making an app with shadow-cljs?#2018-03-2302:25justinlee@joshua.d.horwitz there is the user guide of course and there is also this starter repo https://github.com/lauritzsh/reagent-shadow-cljs-starter#2018-03-2302:26justinleeactually this quickstart might be better https://github.com/shadow-cljs/quickstart-browser#2018-03-2302:39Josh HorwitzThank you!#2018-03-2302:39Josh HorwitzI know Clojure decently and just trying to find where to get intro ClojureScript and start using it#2018-03-2302:41justinleethat’ll help with the tooling. for actually learning the language, the only hard part is getting your head wrapped around a single threaded language. then you need to pick a tech stack (fun!)#2018-03-2304:04grounded_sageI'm following the quickstart browser and I'm getting this when I do the release#2018-03-2304:04grounded_sage
------ WARNING #1 --------------------------------------------------------------
 File: cljs/core.cljs:37412:13

 variable Java is undeclared
--------------------------------------------------------------------------------

#2018-03-2304:30tony.kaySo, @thheller. I’m seeing code generation differences that break fulcro spec’s use of with-redefs. Instead of generated code calling functions like this:
fulcro.ui.forms.form_reduce.call(null,root_form,...)
shadow is generating:
fulcro.ui.forms.form_reduce.cljs$core$IFn$_invoke$arity$3(root_form,...
Then the use of with-redefs redefines fulcro.ui.forms.form_reduce to a function, and we end up with errors like this: fulcro.ui.forms.form_reduce.cljs$core$IFn$_invoke$arity$3 is not a function I can see that this looks like an optimization, but it definitely breaks code that has been working against clj and cljs for years. Seems to me it generally breaks cljs with-redefs
#2018-03-2306:01levitanong@thheller tried making a minimal case with the thing we were puzzling over with @tony.kay. Not sure if I found the same thing because this time i’m getting an actual error. Posted an issue: https://github.com/thheller/shadow-cljs/issues/225#2018-03-2307:40thheller@tony.kay that is probably broken because shadow-cljs defaults to :static-fns true. can you trying compiling with :compiler-options {:static-fns false}?#2018-03-2313:10tony.kayAh I see. I have seen that compiler option before. I guess I didn't expect it to break core functions.#2018-03-2313:27thheller@tony.kay I have this issue thats bugging me about om/fulcro query setup. the point of query language like graphql to me is that components just ask for what they want and don't have to worry where the underlying data is coming from (or its shape)#2018-03-2313:27thhelleryet in om/fulcro the components ALSO basically define the database schema via idents#2018-03-2313:27thhelleror am I just understanding idents wrong?#2018-03-2313:28thhelleridents just break the entire model for me#2018-03-2313:28thhelleryes having a normalized database is nice#2018-03-2313:29thhellerbut the components shouldn't be the ones deciding how the normalization happens in my mind#2018-03-2313:30thhellerI guess I might just need to use fulcro more and let it sink in but every time this nagging feeling just keeps coming up#2018-03-2313:31thhellerI understand why idents are on the components but it still feels like a mistake#2018-03-2313:43tony.kayGlad to talk about it, not sure this channel is the right place#2018-03-2313:43thhelleroh right#2018-03-2313:44thhellerthought we were in #fulcro 😛#2018-03-2319:19lwhortonhey guys is there an existing idiom for module-hash-names and your index.html file management?#2018-03-2319:19lwhortoninitially I was thinking of writing something that fetches the manifest.json, then dynamically adds a script tag to fetch my actual code source by parsing the name out of the manifest#2018-03-2319:20lwhortonbut that adds quite a bit of overhead right at the app load time, so preferably a compile-time solution already exists#2018-03-2319:32thhellerdo you have a static html file?#2018-03-2319:32thhellerif its generated by the server the manifest files should help#2018-03-2319:33thhellerif its static you could use https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-03-2319:35lwhortoni do have a static file, so ill take a look at clj-run#2018-03-2319:41thheller
(ns your.build
  (:require
    [shadow.cljs.devtools.api :as shadow]
    [clojure.edn :as edn]
    [clojure.string :as str]))

(defn release []
  (shadow/release :your-build)
  (let [manifest
        (-> (slurp "public/js/manifest.edn")
            (edn/read-string))

        index-src
        (slurp "public/index.html.src")

        index
        (reduce
          (fn [index-src {:keys [module-id output-name]}]
            (let [marker (str (name module-id) ".js")]
              (str/replace index-src marker output-name)))
          index-src
          manifest)]
    
    (spit "public/index.html" index)))
#2018-03-2323:57lwhortonI’m having difficulty with the related (shadow/watch) api. is there something different about the expectations of this fn?#2018-03-2323:58lwhortonsome complaints about “Exception in thread “main” java.lang.AssertionError: Assert failed: (map? http) at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:103)” when I try to do (shadow/watch (keyword build-id) where build-id is provided as a string from the cli#2018-03-2319:41thhellershadow-cljs clj-run your.build/release#2018-03-2319:42thhellerlooks at a public/index.html.src replaces <srcipt src="/js/main.js"> with <srcipt src="/js/main.<the-hash>.js">#2018-03-2319:43thhellerpretty hacky but should work. could make it more reliable by using better placeholder or something like that#2018-03-2319:45thhellercould even generate the full html from hiccup or so#2018-03-2319:46lwhortoni had something like the above-- or rather, was writing something like that right now. i guess my next question is: is there a way to use a pre-hook so I can shadow-cljs … oh wait#2018-03-2319:46lwhortonhah, that’s the purpose of shadow/release eh?#2018-03-2319:46thhellerindeed. thats the same as calling shadow-cljs release your-build just from the clojure api#2018-03-2319:46lwhortonokay, that’s neat — although slightly peculiar to change the “standard” api#2018-03-2319:47lwhortoni would have thought I could use a :pre-hook and maintain shadow-cljs release prod, and in that release hook templating would take place#2018-03-2319:47thhellerI'm still debating the proper way to add hooks into the build process#2018-03-2319:47thhellerbecause you can break things easily that way#2018-03-2319:47lwhortonit’s a lot to think about — once per build, or once per each reload, etc.#2018-03-2319:47thhellerbut yes there should be a way to hook in#2018-03-2319:48thhellereasiest way to do it currently is just via the clojure api and clj-run#2018-03-2319:48thhellerthat leaves the build process alone and just lets you run before/after easily#2018-03-2319:49thhellercustom builds also let you do this but thats much too low level for most cases#2018-03-2319:51lwhortonyea thanks for this; ill use the clj-run which will also allow me pass command line args, tightening up the above “hacky” solution a bit#2018-03-2320:34mhuebertdoes this error make any sense to you? I am masochistically trying to get my shadow builds working everywhere, this time during slug compilation on heroku.
remote:        > shadow-cljs start && shadow-cljs clj-run build.build/release && webpack -p;
remote:
remote: shadow-cljs - config: /tmp/build_248d245eeae37c14789671b54890ae63/_spark-spa/shadow-cljs.edn version: 2.2.14
remote: shadow-cljs - server starting .events.js:160
remote:       throw er; // Unhandled 'error' event
remote:       ^
remote:
remote: Error: spawn clojure ENOENT
remote:     at exports._errnoException (util.js:1026:11)
remote:     at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
remote:     at onErrorNT (internal/child_process.js:348:16)
remote:     at _combinedTickCallback (internal/process/next_tick.js:74:11)
remote:     at process._tickCallback (internal/process/next_tick.js:98:9)
remote:     at Module.runMain (module.js:592:11)
remote:     at run (bootstrap_node.js:394:7)
remote:     at startup (bootstrap_node.js:149:9)
remote:     at bootstrap_node.js:509:3
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
(I switched to shadow-cljs start && shadow-cljs release... because shadow-cljs release... doesn’t fail, it just prints “starting with clojure” and then heroku silently moves on to the next process and nothing is compiled)
#2018-03-2320:35thhellerlooks like clojure maybe isn't on the path?#2018-03-2322:35mhuebertah yikes, that’s probably it. the clojure buildpack wouldn’t have that yet#2018-03-2323:33mhuebertso, the following works to install clojure on heroku, assuming you are in the heroku/node buildpack after the heroku/jvm buildpack: curl -O && chmod +x linux-install-1.9.0.358.sh && ./linux-install-1.9.0.358.sh -p $(pwd)/.heroku/node#2018-03-2321:17justinlee@thheller what do you think about a feature on the browser side that gives some like warning that you’ve disconnected from the shadow-cljs server and/or a feature that lets you know if the build is broken. sometimes you think you’re looking at live code but you’re not#2018-03-2322:17thhellersure sounds like a good idea. open to suggestions to how that should look#2018-03-2322:18thhellerhttps://github.com/thheller/shadow-cljs/issues/189#2018-03-2322:38justinleemaybe the simplest thing is to deal with disconnection: seems to me that a popup similar to the one that signals a recompilation which simply shoes the cljs logo and says “disconnected” would be enough. query: does shadow-cljs try to reload once disconnected? maybe it should keep retrying, which would eliminate the problem most of the time#2018-03-2400:09lwhortoni’ve dug around here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/api.clj#L81 looking for the reason that I cannot seem to get (devtools.api/watch build-id) to work, and it seems like there’s some stateful dependencies in an existing runtime?#2018-03-2400:11lwhortoni get the issue assert failed (map? http), which if you backtrack quite a bit seems to be coming from an existing supervisor who has some http config. i’m not sure if there’s an alternative way I should be using the clj-run api or not, but this doesn’t seem to be correct 😕#2018-03-2400:18thhellerclj-run currently doesn't spin up a full server so watch doesn't work#2018-03-2400:18thhellerif you run a separate shadow-cljs server it should work#2018-03-2400:19thhelleron my way to bed. please open a ticket. there should be an option for clj-run to run a full server to enable watch#2018-03-2409:07mhuebertThis would be great. I’d like to have a script for dev which always compiles a few static assets before beginning ‘watch’, and I think clj-run would be the simplest way to set that up.#2018-03-2409:21mjmeintjesIs there are way to use shadow-cljs and browserify together? I'm trying to require a npm module (pouchdb-adapter-memory), but when I include it in my namespace requires it throws the following error:
shadow.js.js:91 Uncaught ReferenceError: Buffer is not defined
    at Object.shadow$provide.module$node_modules$buffer_from$index (index.js:5)
    at shadow.js.jsRequire (shadow.js.js:88)
#2018-03-2409:22mjmeintjesThe solution of Buffer is not defined error is to run the module through browserify, but I'm not sure how to integrate that with shadow-cljs.#2018-03-2409:24thhellerin the namespace that includes pouchdb-adapter-memory add an extra require for a (ns bugfix.buffer (:require ["buffer" :as buffer])) (js/goog.exportSymbol "Buffer" buffer)#2018-03-2409:25thhellerI could a hack to do this automatically but most packages these days behave properly and don't use a global Buffer#2018-03-2409:26thhellersicne that only exist in node#2018-03-2409:28thhellerimport bufferFrom from 'buffer-from'; // ponyfill for Node <6#2018-03-2409:29thhellerare you sure this is intended to work in the browser?#2018-03-2409:29thhellerlooks pretty node specific#2018-03-2409:29thhellerI guess#2018-03-2409:31thhellerif you require bugfix.buffer (or whichever ns you use for this) before the pouchdb thing it should work#2018-03-2409:31thhellerjust need to make sure the global exists before using it#2018-03-2409:35mjmeintjesThanks, that did the trick. Where I got stuck is that I didn't think to set the global in a separate namespace - I tried setting it in the same namespace which of course didn't work. Thanks for the quick reply.#2018-03-2409:35mjmeintjesThey do state on the npm page "Designed to run in either Node or the browser".#2018-03-2409:36mjmeintjesI've found some of the other less maintained pouch plugins have similar issues, one plugin had a requirement for Process#2018-03-2409:36mjmeintjesThanks for this quick reply, appreciate the help!#2018-03-2411:10hlolliI want to give some of those cljs devtools a try again, looking at dirac there's suggested way to start their agent (assumable on nrepl server) with :init in lein
:repl-options {:init (do
                       (require 'dirac.agent)
                       (dirac.agent/boot!))}
source: https://github.com/binaryage/dirac/blob/master/docs/installation.md is there an option like that available in shadow-cljs?
#2018-03-2411:11thhellernot really but you could use clj-run#2018-03-2411:11thhellerI'll probably add some hook options later today#2018-03-2411:11thhellerso that things like this become easier#2018-03-2411:13hlolliok, I'm also planing to look at integrating the clj cli tools into nixOs so I can use them later today. So I'll continue with the devtools quest tomorrow. Thanks thheller!#2018-03-2411:14hlolli(lein would work I guess)#2018-03-2419:09wilkerluciohello, I'm trying to compile something with shadow, but I'm getting this error:#2018-03-2419:10wilkerlucioI had a lot of code changes since the last time I compiled (was working on the clj side), and just bumped shadow as well, not sure what might caused#2018-03-2419:12wilkerlucioI"m trying to rever t and see if I get teh same with old shadow, but you guys have seen this before?#2018-03-2419:17wilkerlucioreverting shadow to 2.1.18 makes it generate warnings instead of breaking#2018-03-2419:31thhellerincompatible closure version#2018-03-2419:32thhellerclojurescript itself is pretty tied to a specific closure version#2018-03-2419:32wilkerluciois there a way to fix? when I reverted I was able to compile by fixing some macro requires, but now I bumped again and the error persists#2018-03-2419:32thhellerthe error has nothing to do with macro requires#2018-03-2419:33thhellerthat is just a side effect of the cljs.repl ns requiring cljs.closure#2018-03-2419:33thhellerand that is the ns that is broken#2018-03-2419:33thhelleryou can (require 'cljs.closure) to verify this in a clojure REPL#2018-03-2419:34thhellerhttps://dev.clojure.org/jira/browse/CLJS-2694#2018-03-2419:34thhellerso its not the shadow-cljs version that is the problem here#2018-03-2419:34thhellerits clojurescript+closure#2018-03-2419:35wilkerluciook, I think I'm starting to understand, but the cljs version is the same on both cases for me, when did the closure get updated? and it seems like this way I can't compile anything at all, the only way is to revert shadow here then?#2018-03-2419:36thhellershadow has nothing to do with this#2018-03-2419:36thhellerit is the closure version in combination with clojurescript#2018-03-2419:36wilkerluciobut reverting shadow here makes it work, I think I'm missing something#2018-03-2419:36wilkerlucioI'm still on cljs 1.9.946#2018-03-2419:37thhellerremove that#2018-03-2419:37thhellerlet shadow-cljs pick the clojurescript version#2018-03-2419:37thhelleror use [org.clojure/clojurescript "1.10.145"]#2018-03-2419:38thhellerpreviously I used a hack to provide a custom cljs.closure namespace but that had other issues#2018-03-2419:38thhellerit is kind of tricky trying to stay up to date with the closure compiler and clojurescript itself lags behind#2018-03-2419:39wilkerluciogotcha, just feel a little danger using those non-release versions, seems people are getting bitten by new things still, like the new map stuff#2018-03-2419:39thhellershould work better once the official clojurescript 1.10 comes out#2018-03-2419:39thhellernew hash stuff?#2018-03-2419:39wilkerluciosorry, map* stuff (new map keys been entity)#2018-03-2419:40wilkerluciobut for my current project it's work, I'm just wondering for people relying on it for real prod stuff#2018-03-2419:40wilkerlucioI guess they should lock the shadow-cljs if they have problems with new cljs things#2018-03-2419:41thhellerwell you want to fix those things anyways. clojurescript isn't going to change how MapEntry works#2018-03-2419:41thhellerso if you relied on broken behaviour you have to change it or forever stay on 1.9#2018-03-2419:41thhellerfor me 1.10 has been stable. the only non-stable part is all the new cljs.main stuff but we don't use any of that anyways so it doesn't matter#2018-03-2419:41wilkerlucioyeah, I agree, but sometimes you depend on a library that you don't have much control, and it might take a while to fix, and on those cases you get locked, unless you decide to fork... tradeoffs#2018-03-2419:42wilkerlucioat least people seem to be fixing it fast 🙂#2018-03-2419:42thhellerdo you know of particular libs that break?#2018-03-2419:42wilkerluciospecter was broken, but was fixed already#2018-03-2419:43thhellerah ok#2018-03-2419:44wilkerlucioand now it's working here, thanks for the explanations#2018-03-2420:37wilkerluciook, I think I'm hitting another hookie mistake, but on runtime I'm getting these: https://www.dropbox.com/s/vx09tnx0cu4si7c/Screenshot%202018-03-24%2017.36.45.png?dl=0#2018-03-2420:38wilkerlucioI was using React 16 with project already before, did something changed about loading the cljsjs deps?#2018-03-2420:39thhellershadow.process is the cause. don't know why that wouldn't exist though. maybe cache issue?#2018-03-2420:40wilkerluciohow can I burst it?#2018-03-2420:40thhellerrm -rf .shadow-cljs/builds#2018-03-2420:44wilkerlucio@thheller still getting the same, tried bursting and recompiling twice#2018-03-2420:46thhellerwhat does the main.js look like? it should contain a goog.addDependency for shadow.js and shadow.process#2018-03-2420:46thhellerI have no idea why shadow.process wouldn't exist since it shouldn't even compile if it can't find it#2018-03-2420:47thhellerare you sure you are loading the correct build?#2018-03-2420:47thhellernot some old leftover in a corrupted state?#2018-03-2420:49wilkerluciowait, I forgot to delete the old files thenselves as well facepalm#2018-03-2420:49thhelleroh wait .. shadow.process is not a thing anymore#2018-03-2420:49wilkerlucioyeah, now it works, thanks 🙂#2018-03-2420:49thhellera recompile should overwrite them#2018-03-2420:49wilkerlucioworked after removing the compiled files, first I just deleted the cache#2018-03-2420:50thhellerweird. recompiled files should always overwrite output#2018-03-2420:50thhellerwill check the logic for that#2018-03-2420:50wilkerlucioI was thinking this kind of things happens most often when I get back to a project that I didn't ran for a while#2018-03-2420:50wilkerlucioI was thinking if would be a good idea to store the last compilation run, and just burst everything after some amount of time (maybe 3 days or something)#2018-03-2423:02lwhortonhas anyone gotten shadow-cljs to work with vim-fireplace? Im not quite sure why, but none of the shadow-cljs tasks ever say shadow-cljs - nrepl running at localhost/127.0.0.1:8202, which makes me think I need to manually configure it to actually start an nrepl?#2018-03-2423:22justinleeso if you start a server, the server will say what port its running on. i configure to always use port 9000 :nrepl {:port 9000}. i know thomas has been reluctant to use lein’s nrepl port file#2018-03-2423:22justinleebut just hard coding the nrepl port has been easiest for me#2018-03-2423:39thheller.nrepl-port is generated when it doesn't exist and the nrepl port is also always printed in the latest version#2018-03-2423:52justinleeoh and I didn’t actually write a complete thought: if you start a server, the server prints out the nrepl, but subsequent commands do not#2018-03-2500:16eoliphantHi, I’m trying to play around with a js lib in the REPL. based on my reading, the import below should be something like this? (require '["auth0-js" :default auth0]). auth0 is nil after the require
import auth0 from 'auth0-js';

export default class Auth {
  auth0 = new auth0.WebAuth({
#2018-03-2500:19thheller@eoliphant unfortunately it depends on the packaging on npm. most likely that was converted by babel and might work differently#2018-03-2500:19thhellertry with :as and inspect the object#2018-03-2500:30eoliphantok checking it out. also, i’d typed an earlier comment but realized it was at least partly in error. But still seeing some weirdness. When I do a (require..) in the repl, it doesn’t seem to ever return the ‘nil’. at first i thought it wasn’t working at all, but I could say call str/blank? after require’ing clojure.string, etc. It threw me a little with this because I wasn’t sure the require itself was working#2018-03-2500:30eoliphanthmm the :as is also resulting in auth0 being nil#2018-03-2500:30eoliphantlooking at the source…#2018-03-2500:34thhellerI can take a look tomorrow. please open a ticket so I don't forget to look at it#2018-03-2500:34eoliphantsure no prob#2018-03-2500:34eoliphantthx 🙂#2018-03-2513:54thhellerI'm seriously struggling to find a better message than There is no connected JS runtime.. Please help!#2018-03-2513:54thhellermeans that the compiled JS output was not loaded or has not connected back to the REPL server#2018-03-2513:55thhellerie. not opened the thing in the browser or launched the node app#2018-03-2514:42thhellerchanged it so you can't switch the REPL if no client is connected#2018-03-2514:42thhellerstill pretty bad error message so. would love some suggestions.#2018-03-2514:42thheller
(shadow.cljs.devtools.api/nrepl-select :browser)
=> [:no-client :browser "Please load your JS to connect to the REPL."]
#2018-03-2516:38lwhortonis there a way to use lein’s repl but shadow-cljs’s cljs compliation? is that even possible when we start talking about connecting to browser sessions? the reason I ask is that the lein repl is just much more robust and developed, but shadow-cljs has much nicer cljs compilation and node module support#2018-03-2517:01justinlee“No application has connected to the nREPL server. Make sure your JS environment has loaded your compiled ClojureScript code.” @thheller how about something like that?#2018-03-2517:52javihi , my laptop chrashed and on reboot, when i run .... shadow-cljs watch app results in
shadow-cljs - config: /Users.......vc/shadow-cljs.edn version: 2.1.6
shadow-cljs - socket connect failed, server process dead?
#2018-03-2517:52javiany ideas?#2018-03-2518:11thheller@fj.abanses delete .shadow-cljs/*.port. 2.2.18 which I released today handles such crashed more gracefully.#2018-03-2518:12thheller@lwhorton if you want to embed in lein and want to use a remote nREPL you need to configure the shadow-cljs middleware. https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-03-2602:52lwhortonso is it possible then to have shadow-cljs “controlled” by lein, where say “lein repl -> (fig-start)” actually starts an nREPL but defers to shadow-cljs for the compilation and properly intercepts the repl?#2018-03-2608:59thhellertake a look at the docs and shadow.cljs.devtools.api. calling (shadow.clsj.devtools.api/compile :foo) is identical to shadow-cljs compile foo. same for watch and release.#2018-03-2518:13thhellerbesides that you can just use the clojure api to use shadow-cljs. https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2018-03-2518:14thheller@lee.justin.m sounds good. I'll add that later.#2018-03-2518:58javi@thheller thanks. upgrading to 2.2.18 fixed it#2018-03-2613:45hlollido you remember if the google closure bug we found last month was fixed already, the one you opened the ticket for? @thheller#2018-03-2613:48hlollihttps://github.com/google/closure-compiler/issues/2822 ok found it, I’ll give the new clojurescript release a try without targeting older closure compiler…#2018-03-2613:59hlollinevermind what I said, the release from 6 days ago v20180319 with the fix for #2822 isn’t on maven https://mvnrepository.com/artifact/com.google.javascript/closure-compiler-unshaded yet#2018-03-2614:13thhelleryeah apparently its stuck internally or something#2018-03-2614:14thhellerhttps://github.com/google/closure-compiler/issues/2860#2018-03-2615:29thheller@mhuebert @lwhorton regarding watch via clj-run. https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run since 2.2.19#2018-03-2615:32mhuebertgreat. re: how the server persists, would it quit when I hit ctrl-c in that terminal window?#2018-03-2615:32thhelleryes#2018-03-2615:33mhuebert:+1::skin-tone-2:#2018-03-2615:34thhelleradded that to the docs as well#2018-03-2616:57justinleeis there a way to make a namespace always available, e.g. a debugging library?#2018-03-2617:35thosmosI'm attempting to include the "sql.js" NPM module. It works in dev mode, but not in release, unless I set the :optimizations :simple compiler flag. In release mode, some of its functions work, except for one. I'm wondering what's going on and how best to troubleshoot. I can live with :simple optimizations, but I'm curious what's causing the problem.#2018-03-2618:02justinlee@thosmos what error message do you get?#2018-03-2618:09thosmos@lee.justin.m Uncaught TypeError: b.wb is not a function#2018-03-2618:10justinleeautomatic type inferences arn’t working. is your :infer-extern :auto set? https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-03-2618:11justinleemake sure those are on and then add type hints until the warnings go away#2018-03-2618:13thosmosthe actual call is (.prepare db "SELECT * FROM myTable WHERE MainID=? AND SubID=? AND ProtocolID=?;")#2018-03-2618:14thosmosyes when I did that, the call works, but there's no result, whereas with :simple it actually works, which makes me think the library is getting optimized?#2018-03-2618:14thosmosother functions like (.exec db) works, but not (.prepare db)#2018-03-2618:18justinleethe actual javascript goes through normal minification only. the b.wb is not a function is because something you are calling in clojurescript is getting munged. try this : (.prepare ^js db "SELECT * FROM myTable WHERE MainID=? AND SubID=? AND ProtocolID=?;")#2018-03-2618:19justinleethat will prevent the prepare symbol from being munged#2018-03-2618:20justinleeif that doesn’t work, then something in the minification process is actually messing with the javascript source, though that really shouldn’t happen#2018-03-2618:21justinleeactually, I don’t think changing compiler optimizations changes anything with regard to javascript, so that can’t be it.#2018-03-2618:21justinleeit’s got to be a missing type hint#2018-03-2618:25thosmosyeah when I add that I no longer get the error, but the call doesn't work.#2018-03-2618:25thosmosI'll keep looking for other type hints#2018-03-2618:26justinleemake sure you are positive that there is a different outcome on the prepare statement--maybe the prepare is working but something else is failing? if not, then there is a bug that @thheller will have to take a look at#2018-03-2618:28thosmos(def sql (js/require "sql.js")) is also how I'm loading the library.#2018-03-2618:29justinleeI assume you’re targeting node. I don’t know that there is any reason to do optimizations on node. Optimizations are about space efficiency, not time efficiency, as far as I know.#2018-03-2618:29justinleeBut it would still be good to understand the bug.#2018-03-2618:31thosmostrue#2018-03-2618:31thosmosI'll rig up a minimal test#2018-03-2618:43thosmos@lee.justin.m using the following minimal test, the row result is empty with optimizations and filled with :simple:
(def sql (js/require "sql.js"))
(def fs (js/require "fs"))
(defn testDB []
  (let [dbPath  "/my/db/path"
        fb     (.readFileSync ^js fs dbPath)
        db     (new (.-Database ^js sql) fb)
        stmt   (.prepare ^js db "SELECT * FROM tblTreatment WHERE MainID=? AND SubID=? AND ProtocolID=?;")
        _ (.bind ^js stmt (clj->js [1 1 1]))
        _ (.step ^js stmt)
        row (js->clj (.getAsObject ^js stmt))
        _ (println "ROW: " row)
        ]))
#2018-03-2618:45justinlee@thosmos awesome! thanks! hey could you do me a favor and open up a ticket in github? that way thomas will see it.#2018-03-2618:46thosmosI'll make a minimal github project and then do that#2018-03-2618:54thosmosoh, hmm, maybe this is relevant: I've been doing this in the renderer process. I just tested it in the main process and it works in release mode when it doesn't in the browser. in the main process, the target is :node-script, whereas in the renderer it's :browser#2018-03-2618:55justinleeokay wait i’m confused about the “rendered process” and the “main process”#2018-03-2618:55justinleewhat is that?#2018-03-2618:55thosmosthis is for an electron app which has two processes, one is the node app and the other is the browser app. they both have access to npm modules#2018-03-2618:56thosmossql.js works in both because it is pure javascript#2018-03-2618:56justinleeruh roh you’ve run completely off the edge of my expertise 🙂#2018-03-2618:57justinleethat definitely sounds like the problem but I can’t even guess what#2018-03-2618:57thosmosbut what this suggests is that in release mode, the :browser target seems to be doing something different than the :node-script target#2018-03-2618:58justinleeyea it does. i’d add that information into the ticket#2018-03-2618:58thosmosthanks for thinking it through with me#2018-03-2619:00thosmosit's probably that npm modules are fully handled only in the :node-x targets#2018-03-2619:10justinleeseems weird. handling npm modules on the browser is shadow’s raison d’etre. node is a later addition (as I understand it)#2018-03-2619:44thheller@thosmos do not use (js/require ...) for anything or half the inference won't work#2018-03-2619:45thhellerjust use (ns the.thing (:require ["fs" :as fs])) and treat it like any other namespace. eg. (fs/readFileSync ...) instead of (.readFileSync fs ...)#2018-03-2619:46thhelleras for the modules thing. for :browser things are handled entirely differently that is correct. you can however set :js-options {:js-provider :require} in your build. then they are handled exactly like :node-script#2018-03-2712:53mhuebertHmm, running /cdn-cgi/l/email-protection with [com.google.javascript/closure-compiler-unshaded "v20180101"] (to avoid that nasty bug, https://github.com/google/closure-compiler/issues/2822) I am getting:
[:browser] Compiling ...
[2018-03-27 14:51:57 - WARNING] Skipping pass rewriteScriptsToEs6Modules
[2018-03-27 14:52:05 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES
        at cljs.closure__init.load(Unknown Source)
        at cljs.closure__init.<clinit>(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at clojure.lang.RT.classForName(RT.java:2204)
        at clojure.lang.RT.classForName(RT.java:2213)
        at clojure.lang.RT.loadClassForName(RT.java:2232)
        at clojure.lang.RT.load(RT.java:450)
        at clojure.lang.RT.load(RT.java:426)
        at clojure.core$load$fn__6548.invoke(core.clj:6046)
        at clojure.core$load.invokeStatic(core.clj:6045)
        at clojure.core$load.doInvoke(core.clj:6029)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5848)
        at clojure.core$load_one.invoke(core.clj:5843)
        at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
        at clojure.core$load_lib.invokeStatic(core.clj:5887)
        at clojure.core$load_lib.doInvoke(core.clj:5868)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:659)
        at clojure.core$load_libs.invokeStatic(core.clj:5925)
        at clojure.core$load_libs.doInvoke(core.clj:5909)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:659)
        at clojure.core$require.invokeStatic(core.clj:5947)
        at clojure.core$require.doInvoke(core.clj:5947)
        at clojure.lang.RestFn.invoke(RestFn.java:2088)
        at cljs.repl$loading__5569__auto____6019.invoke(repl.cljc:9)
#2018-03-2712:54mhuebertmaybe shadow now depends on a more recent closure version?#2018-03-2712:56mhuebertor maybe it’s the latest cljs… i’ll try 2.2.18#2018-03-2713:04mhuebertso 2.1.18 builds with the old closure. makes sense..#2018-03-2713:05mhuebertnow, trying out using devtools.api/watch:
Exception in thread "main" java.lang.AssertionError: Assert failed: (map? http)
        at shadow.cljs.devtools.server.worker$start.invokeStatic(worker.clj:103)
        at shadow.cljs.devtools.server.worker$start.invoke(worker.clj:103)
        at shadow.cljs.devtools.server.supervisor$start_worker.invokeStatic(supervisor.clj:27)
        at shadow.cljs.devtools.server.supervisor$start_worker.invoke(supervisor.clj:18)
        at shadow.cljs.devtools.api$get_or_start_worker.invokeStatic(api.clj:85)
        at shadow.cljs.devtools.api$get_or_start_worker.invoke(api.clj:76)
        at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:102)
        at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
        at shadow.cljs.devtools.api$watch.invokeStatic(api.clj:92)
        at shadow.cljs.devtools.api$watch.invoke(api.clj:88)
        at web3.build.build$watch.invokeStatic(build.clj:57)
        at web3.build.build$watch.invoke(build.clj:49)
        at web3.build.build$watch.invokeStatic(build.clj:52)
        at web3.build.build$watch.invoke(build.clj:49)

#2018-03-2713:10mhuebertoh, that was only added in 2.1.19#2018-03-2713:13mhuebertattempted to add [org.clojure/clojurescript "1.10.145" :exclusions [com.google.javascript/closure-compiler-unshaded]], but then I get the java.lang.NoSuchFieldError: STRICT_MISSING_PROPERTIES error again#2018-03-2713:16mhueberti see this is an existing issue, https://github.com/thheller/shadow-cljs/issues/225#2018-03-2713:38thheller@mhuebert the problem unfortunately is in cljs.closure. why are you pinning a specific closure version again?#2018-03-2713:39mhueberti was trying to get the new :shadow/requires-server thing without the latest clojure version#2018-03-2713:39thhellerwhy though?#2018-03-2713:40thhelleroh wait .. you ran into this https://github.com/google/closure-compiler/issues/2822 right?#2018-03-2713:40mhuebertyes exactly#2018-03-2713:40thhellerhmm yeah I had hoped closure would release a new version by now#2018-03-2713:40mhuebertich auch#2018-03-2713:41thhelleryou can "fix" this by copying the https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj into your classpath#2018-03-2713:41thhellerand remove the problematic fields in (def warning-types ...)#2018-03-2713:41thhellereg. https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L151#2018-03-2713:42thhellerhttps://dev.clojure.org/jira/browse/CLJS-2694#2018-03-2713:42thhellercould also apply this patch#2018-03-2713:43thhellerI think I should probably add the "hack" I had for this previously#2018-03-2713:43thhellerwe don't actually use cljs.closure at all .. problem is that cljs.repl imports it though#2018-03-2713:44mhuebertwhat an annoying thing to keep in sync#2018-03-2713:45thhelleryeah with my patch that should get better#2018-03-2713:46thhellerthe closure people probably don't expect anyone to use the static fields directly#2018-03-2713:46thhellerlet me just add the hacked version again. this really shouldn't break so easily#2018-03-2713:57thheller@mhuebert try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a2d1cac3c6cdd58fc1cec8d1e2908c908c9092"}, :content ("[email protected]")}. should use the latest cljs version and hopefully let you use the closure v20180101#2018-03-2714:07mhueberthey, great#2018-03-2714:07mhuebertnow i can try the new watch stuff#2018-03-2715:16mhuebertworks great#2018-03-2715:18mhuebertI really like this setup. Now I have a single watch command which first compiles the necessary static assets (hiccup->html, garden->css) and then starts the shadow watch process#2018-03-2717:28sleepyfoxMorning#2018-03-2717:29sleepyfoxI am encountering the Error: Could not find or load main class clojure.main error when following the doco, there's obviously something that I've missed#2018-03-2717:30sleepyfoxI have a hello world app with the following shadow-cljs.edn:
{:source-paths ["src"]
 :dependencies []
 :builds {:server    {:target    :node-script
                      :main      server.main/main!
                      :output-to "target/main.js"}}}
#2018-03-2717:31sleepyfoxand a file ./src/server/main.cljs
(ns server.main

(defn main! [& cli-args]
    (prn "hello world"))
#2018-03-2717:31sleepyfoxAny help appreciated#2018-03-2717:32sleepyfoxI am invoking shadow-cljs compile server, and shadow-cljs -v returns: shadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20#2018-03-2717:34sleepyfoxjava -version shows openjdk version "1.8.0_141"#2018-03-2717:47thheller@sleepyfox can you paste the output of npx shadow-cljs clj-repl? the error looks like there is no clojure on the classpath which is very weird#2018-03-2717:48sleepyfoxexactly the same error:
shadow-cljs - config: /var/app/shadow-cljs.edn version: 2.2.20
shadow-cljs - starting ...
Error: Could not find or load main class clojure.main
#2018-03-2717:49thhellerhmm so strange#2018-03-2717:49sleepyfoxshadow-cljs was installed using npm install -g shadow-cljs#2018-03-2717:49thhellerdelete .shadow-cljs/classpath.edn and try the above again?#2018-03-2717:49sleepyfoxthis is a node v9.9.0 environment#2018-03-2717:50sleepyfoxah, now appears to be doing something useful#2018-03-2717:50sleepyfoxdownloading the internets#2018-03-2717:50thhellershadow-cljs --cli-info should also print some useful info#2018-03-2717:51sleepyfoxstack trace#2018-03-2717:51thhellerhmm?
#2018-03-2717:53sleepyfoxmissing paren#2018-03-2717:53sleepyfoxcompiling again...#2018-03-2717:54sleepyfoxOK, success. Thanks very much. Might consider adding that little trick to the doco#2018-03-2717:54thhellermissing paren?#2018-03-2717:54sleepyfoxNo, the delete .shadow-cljs/classpath.edn part#2018-03-2717:55thhellerthis should never be necessary. I don't know how you ended up there.#2018-03-2717:55sleepyfoxMe neither 😕#2018-03-2717:55sleepyfoxBut... computers. And PEBKAC#2018-03-2717:56sleepyfoxThanks anyway.#2018-03-2717:56thhellerif it happens again please post the output of shadow-cljs --cli-info (before deleting anything)#2018-03-2717:59sleepyfoxIf it happens again I'll capture the info you requested.#2018-03-2717:59thhellerthanks. the above is how it should look.#2018-03-2718:00sleepyfoxI suspect it was something to do with the environment, I've been creating a Docker image to try this stuff out in and it's possible an older jvm or node vm may have been causing an issue.#2018-03-2718:12mitchelkuijpers
shadow-cljs -d org.clojure/tools.nrepl:0.2.13 -d cider/cider-nrepl:0.17.0-SNAPSHOT server
the -d options does not seem to work when :lein true is enabled is this expected?
#2018-03-2718:14thhelleroh. hmm yeah it doesn't pass that along to lein#2018-03-2718:14thhellerI'll see about adding that#2018-03-2718:14sleepyfoxOK, same error on recreating the Docker image, diagnostic output is:#2018-03-2718:15thheller@sleepyfox are you creating a docker image that saves the .shadow-cljs directory but not ~/.m2?#2018-03-2718:16sleepyfoxYup, I think you've hit the nail on the head. I'm just mounting . to /var/app#2018-03-2718:17mitchelkuijpersBtw I am trying it out without leiningen since cider added shadow-cljs support ^^#2018-03-2718:17sleepyfoxI'll mount the src, target and other files independently instead of just using COPY . /var/app#2018-03-2718:20thhellerI never tried running shadow-cljs in docker. I could add a safeguard to test whether the classpath files still exist and if not invalidate the classpath and regenerate#2018-03-2718:20thhellerbut that seems like it would download the deps over and over again#2018-03-2718:20eoliphanthi i just upgraded to 2.2.20 and I’m getting an error, I couldn’t determine if it had something to do with what you guys have been discussing
Exception in thread "main" java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType, compiling:(shadow/build/cljs_closure.clj:3:1)
Did a --cli-info everything looks right
=== Version
cli:            2.2.20
jar-version:    2.2.20
config-version: 2.2.20
#2018-03-2718:21thheller@eoliphant do you have a specific closure-compiler version picked in your deps? or clojurescript for that matter?#2018-03-2718:22thhellerunfortunately clojurescript is very picky about which closure-compiler version gets used#2018-03-2718:22mitchelkuijpersHmm I want to use standalone shadow-cljs but duplication all deps from leiningen is too painfull how do other people handle this? Or do they just use leiningen?#2018-03-2718:23thhellerI think for now that can't be helped since cursive doesn't look at shadow-cljs.edn 😞#2018-03-2718:24eoliphantchecking#2018-03-2718:24eoliphantthis is a recent fulcro project#2018-03-2718:24eoliphantdoesn’t look like it#2018-03-2718:25thheller@eoliphant which clojurescript and closure versions are mentioned in --cli-info?#2018-03-2718:26eoliphantumm neither lol
MacBook-Pro:fm-ng-ui ericholiphant$ shadow-cljs --cli-info
shadow-cljs - config: /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn version: 2.2.20
=== Version
cli:            2.2.20
jar-version:    2.2.20
config-version: 2.2.20

=== Paths
cli:     /Users/ericholiphant/projects/fm-ng-ui/node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.cli.js
config:  /Users/ericholiphant/projects/fm-ng-ui/shadow-cljs.edn
project: /Users/ericholiphant/projects/fm-ng-ui
cache:   .shadow-cljs

=== Java
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

=== Source Paths

=== Dependencies
cache-file: /Users/ericholiphant/projects/fm-ng-ui/.shadow-cljs/classpath.edn

#2018-03-2718:27thhellerits in the dependencies 😉#2018-03-2718:28eoliphantah ok 🙂 clojure is just 1.9.0, there’s no explicit dependency for closure. In looking at the resolved dependencies in intellij, closure is v20170910#2018-03-2718:28eoliphantsorry you said clojurescript, that’s 1.9.946#2018-03-2718:29thhellerhmm are you using lein?#2018-03-2718:30eoliphantusing the recent fulcro setup which does set :lein true#2018-03-2718:30eoliphantim executing with npx shadow-cljs ....#2018-03-2718:30thhellerhmm try bumping clojurescript to 1.10.238 ... the shadow.build.cljs-closure ns was added today to work around a different problem with CLJS+Closure#2018-03-2718:30thhellerseems like I can't win this fight#2018-03-2718:31eoliphantugh. that’s no fun 😞#2018-03-2718:31eoliphantdependency hell#2018-03-2718:31thhellerindeed#2018-03-2718:31eoliphantgood luck will try 1.10..#2018-03-2718:33eoliphantyeah that seems to have fixed it#2018-03-2718:34thheller@mitchelkuijpers do you know the lein command line to inject stuff? can't find it#2018-03-2718:35thhellernvm ... found it https://github.com/technomancy/leiningen/blob/master/src/leiningen/update_in.clj#L34#2018-03-2718:36mitchelkuijpers
update-in :dependencies conj \[org.clojure/tools.nrepl\ \"0.2.13\"\ \:exclusions\ \[org.clojure/clojure\]\] -- update-in :plugins conj \[refactor-nrepl\ \"2.4.0-SNAPSHOT\"\]
#2018-03-2718:36mitchelkuijpersOh you found it already#2018-03-2718:36thhellerhmm plugins is going to be bad#2018-03-2718:36mitchelkuijpersyou don't need that#2018-03-2718:37mitchelkuijpersrefactor-nrepl only works for clojure not clojurescript#2018-03-2718:37thhellerhmm but it seems like you could just stick to lein? not really worth pretending to use shadow-cljs which then just delegates to lein#2018-03-2718:37thhellerwhen cider support for lein is better anyways?#2018-03-2718:50mitchelkuijpersYeah but we have some trouble when running shadow in leiningen within our repl instead of running it standalone#2018-03-2718:51mitchelkuijpersThe shadow-cljs integration in cider works pretty slick#2018-03-2718:52mitchelkuijpersBut maybe I should just fix our project somehow#2018-03-2718:55thhellerI wish all of this would just work but tools really only look at clojure stuff#2018-03-2718:56thhellerand only one at a time so you are pretty much forced into lein when you want actual clojure support#2018-03-2718:57mitchelkuijpersYeah but cider is making nice progress, i can now only run shadow-cljs without leiningen ^^#2018-03-2718:57mitchelkuijpersJust duplicated all of our deps in shadow-cljs.edn and it just works#2018-03-2718:59mitchelkuijpersHmm cannot upload images to slack anymore...#2018-03-2721:50hlolliA lazy persons bug report. Not sure if anyone uses moment.js regularly, probably closure bug, but the npm module for moment.js requireing it like this ["moment" :as Moment] and give it a timestamp (str (Moment "2018-10-03 18:48:05.123")) produces nicely human readable date but after compilation (guessing npm modules go trough :simple optimizations) the timestamp becomes unix timestamp (ex. 1522141700340) Someone else experienced something similar. Too busy tonight to open ticket, but can do so this weekend.#2018-03-2808:49thheller@hlolli https://dev.clojure.org/jira/browse/CLJS-2395#2018-03-2808:50thhellerclosure v20180319 is now available on maven. will bump shadow-cljs later.#2018-03-2809:07hlolli@thheller sleepelss night for me, I tried the new closure. Was hopeing it would fix a Quill bug I had completly randomly, evening before launching a new webapp. So two post-compilation bugs I'm gettiing. But as these are both admin endpoints, then I'm actually running shadow-cljs watch in production. Somehow build with optimizatioon :none gave me an error, wait I can send it...#2018-03-2809:10hlolli
shadow-cljs release :admin  ~/Documents/visitor
shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn version: 2.2.20
shadow-cljs - connected to server
[:admin] Compiling ...
optimizations set to :none, can't optimize
{}
ExceptionInfo: optimizations set to :none, can't optimize
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.closure/optimize (closure.clj:1081)
	shadow.build.closure/optimize (closure.clj:1074)
	shadow.build.api/optimize (api.clj:182)
	shadow.build.api/optimize (api.clj:176)
	shadow.build/optimize (build.clj:318)
	shadow.build/optimize (build.clj:310)
#2018-03-2809:11thhelleryeah :none is not an optmization setting .. its literally just compile#2018-03-2809:12hlollinice, I guess that omits the devtools?#2018-03-2809:12thhelleryes#2018-03-2809:13thhellerbut that doesn't affect the optimizations used for JS at all#2018-03-2809:14thhelleryou can set :js-options {:optimizations :whitespace} to switch it from :simple#2018-03-2809:14thhellerbut can you say more about the quill thing? does it still not work with the latest closure?#2018-03-2809:16hlollinope, I'll send the code which fails, it's react-quill actually#2018-03-2809:25hlolli
(:require ["react-quill" :as Quill])

(defn component []
  (let [quill-ref (atom nil)]
    (r/create-class
     {:reagent-render
      (fn [] [:> Quill {:default-value ""
                        :ref (fn [el] (reset! quill-ref el))
                        :modules {:toolbar {:container [[{:header [1 2 3 4 5 false]}]
                                                        ["bold" "italic" "underline" "strike" "blockquote"]
                                                        [{:list "ordered"} {:list "bullet"} {:indent "-1"} {:indent "+1"}]
                                                        ["link" "image"]
                                                        ["clean"]]
                                            :handlers  {:image (fn [_] 
                                                                 (let [editor (.getEditor @quill-ref)
                                                                       selection (.getSelection editor)]
                                                                   (.insertEmbed editor
                                                                                 selection.index "image"
                                                                                 (js/window.prompt "Please provide an image url")
                                                                                 "user")))}}}}])})))
headily elided, when clicking the image logo on the editor to provide img url, will work in :non the error otherwise is
admin.cljs:429 Uncaught TypeError: b.fi is not a function
    at b.<anonymous> (admin.cljs:429)
    at HTMLButtonElement.<anonymous> (quill.js:9393)
(anonymous) @ admin.cljs:429
(anonymous) @ quill.js:9393
For line number comparison then I'm running Quill Editor v1.3.6 one minor version above that which is declared in react-quill, same behaviour is in v1.3.5.
#2018-03-2809:26hlolliso line 423 in admin.cljs is .inserEmbed editor#2018-03-2809:27hlollicom.google.javascript/closure-compiler-unshaded "v20180319" the closure version#2018-03-2809:29thhelleris that error with watch? or release only?#2018-03-2809:29hlollirelease only#2018-03-2809:30thhellerdid you try shadow-cljs release the-build --debug?#2018-03-2809:31thhellershould give a better clue what b.fi is.#2018-03-2809:31thhellerdo you have :infer-externs :auto?#2018-03-2809:31hlolliI'm running now --debug, didn't touch the :infer-extern option#2018-03-2809:32thhellerjust trying to rule out that it is not a problem on the CLJS side.#2018-03-2809:32thhellerdefinitely always turn on :compiler-options {:infer-externs :auto} if you run into any issues#2018-03-2809:33hlolliok I try that, --debug only gave me warnings about transit and nashorn#2018-03-2809:33thhellerruntime error should be better though#2018-03-2809:34hlolliboom, it spotted something shade there now
431 |                                                                     (.insertEmbed editor
---------------------------------------------------------------------------^----
 Cannot infer target type in expression (. editor insertEmbed selection.index "image" (js/window.prompt "Hvað er URL á myndina?") "user")
excuse the foreign language used there 🙂
#2018-03-2809:35thhellerI think all you'll need is ^js editor (.getEditor @quill-ref)#2018-03-2809:35thhelleryeah exactly#2018-03-2809:35thhelleryou need to tell the compiler that editor is a JS object and nothing that uses it should be renamed#2018-03-2809:37hlollibetter later than never, to learn#2018-03-2809:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-03-2809:38thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/15/externs-the-bane-of-every-release-build.html#2018-03-2809:38hlolliso carrot js is a shadow reader?#2018-03-2809:38hlollinever seen this before#2018-03-2809:39thhelleryou mean ^js?#2018-03-2809:40hlolliyes, well it fixed it! wow, easy#2018-03-2809:41thheller^js is a standard CLJS thing for tagging a thing with a type#2018-03-2809:41thhellerususally in clojure this would be a class typehint like ^String#2018-03-2809:41hlolliah yes, I've seen that#2018-03-2809:41thhellerbut in CLJS we don't need classes so we only need to infer that the thing is a JS object or a CLJS object#2018-03-2809:41thhellerCLJS is fine to rename, JS will generated externs so it won't be renamed#2018-03-2809:42thhellerbut you'll only get the warnings if :infer-externs :auto is on#2018-03-2809:42thhellercan't turn that on by default since it may generate too many warnings#2018-03-2809:43hlolliah I see, now earlier talks here on that make more sense to me#2018-03-2813:38jmckitrickHas anyone used shadow with devcards?#2018-03-2813:38jmckitrickIf so, any special caveats?#2018-03-2815:03mitchelkuijpers@jmckitrick we use shadow with devcards#2018-03-2815:04mitchelkuijperswe have a file like this:
(ns atlas-crm.cards
  (:require
  .... namespaces with cards
   [devcards.core :as dc :refer-macros [start-devcard-ui!]]))

(start-devcard-ui!)

(defn refresh []) ;; Used for devcards live reload support
And a build like this:
:devcards {:target :browser
                     :asset-path "/js/devcards"
                     :output-dir "resources/public/js/devcards/"
                     :compiler-options {:devcards true :external-config {:fulcro.inspect/config {:launch-keystroke "ctrl-space"}}}
                     :modules {:devcards {:entries [atlas-crm.cards]}}
                     :devtools {:after-load atlas-crm.cards/refresh
                                :http-port 8600
                                :http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
                                :http-handler dev.test-handler/handler
                                :preloads [fulcro.inspect.preload]}}
#2018-03-2815:09mitchelkuijpersDoes anyone here know the command to get the page in shadow-cljs which shows how much space each dep or ns takes#2018-03-2817:56thheller@mitchelkuijpers (shadow.cljs.devtools.api/release-snapshot :the-build {}) then #2018-03-2817:56mitchelkuijpersAwesome thnx!#2018-03-2819:10mhueberthmm, does this look like correct usage of rename-prefixing for closure? :compiler-options {:rename-prefix-namespace "App"}#2018-03-2819:11mhueberti’m running into some collisions with other code on a page, using :advanced compilation, and it doesn’t seem to have an effect#2018-03-2819:12thheller@mhuebert this is not currently support because it needs special considerations for :modules#2018-03-2819:12thhellerif you just want to isolate your code add#2018-03-2819:13thheller:modules {:main {:entries ... :prepend "(function(){" :append "})();"}}#2018-03-2819:13thhelleralso problematic if you use more than one module though#2018-03-2819:14mhuebertdoes that have any effect on exports?#2018-03-2819:14thhellerno#2018-03-2819:16mhueberthmm. i do have two modules#2018-03-2819:16thhelleryeah thats a problem#2018-03-2819:17thhellerI have a plan for this but didn't get to it yet#2018-03-2819:17thhellerwhat exactly is the issue for you? would externs maybe solve it?#2018-03-2819:17mhuebertit overwrites #2018-03-2819:17mhuebertwhich an existing app uses for something#2018-03-2819:18thhellerthen add externs for that, so closure won't use that name#2018-03-2819:20thheller<project-root>/externs/your-build.txt global:io should do it#2018-03-2819:20mhuebertah that was that special externs file lookup/format?#2018-03-2819:20thhelleryes#2018-03-2819:22mhuebertsimple#2018-03-2819:23mhuebertis :stable-names supported?#2018-03-2819:23thhellerhas been the default in shadow-cljs for a couple of years. it is always on yes.#2018-03-2819:24mhuebert🙂#2018-03-2820:40thosmos@thheller @lee.justin.m I was getting the same results even after I used NS requires. But after looking at the compiled output, I found a workaround. Closure was optimizing away the (.bind stmt) call, probably because it was in a let with no binding of its results (even though it returns nil). When I bound the result Closure let it through:
(let [db ^js (:db @state)
      stmt (.prepare db "SELECT * ...")
      bound? (.bind stmt ids)])
The sql.js namespace includes two JS "classes" (functions with prototype methods) of Database and Statement. I'm currently bringing them in as (ns my.app (:require ["sql.js" :as sql :refer [Database Statement])) What's the best way to import them such that I can use them as namespaces like:
(let [
db ^Database (Database. dbBuffer)  
stmt ^Statement (db/prepare sqlStr)
bound? (stmt/bind ids)])
#2018-03-2820:42justinlee@thosmos is sql.js your file or is it on npm?#2018-03-2820:42thosmosit's from NPM#2018-03-2820:42justinleewhy not import it as an npm module?#2018-03-2820:42justinleei think weird shit happens when you import as javascript#2018-03-2820:42thosmosIs that not what I'm doing here: (:require ["sql.js" :as sql :refer [Database Statement])#2018-03-2820:43justinleeno you’re including the actual file#2018-03-2820:43justinleewhat you want to do is refer to the npm package name and then install the package in your repository using yarn or npm#2018-03-2820:44thhellerhttps://www.npmjs.com/package/sql.js its the package name. so everything is correct#2018-03-2820:44thosmosYes it's in package.json as a dependency and I use yarn to download it#2018-03-2820:44thhellerwhat exactly was the problem again?#2018-03-2820:44thheller(ns my.app (:require ["sql.js" :as sql :refer [Database Statement])) that should work just fine?#2018-03-2820:44thosmos@thheller turns out one of the function calls was getting optimized away by Closure#2018-03-2820:44justinlee@thheller doesn’t that run it through the optimizer?#2018-03-2820:45justinleeI thought javascript includes were optimized whereas npm includes just go through “simple”#2018-03-2820:45thosmosone of my function calls, not the package's function calls#2018-03-2820:46thosmos
(let [db ^js (:db @state)
      stmt (.prepare db "SELECT * ...")
      _ (.bind stmt ids)]) ;; this call got elided
#2018-03-2820:46thheller@lee.justin.m I don't understand. what are you talking about? sql.js is a normal npm package so it gets treated like any other. so it goes through :simple. but simple can also remove code.#2018-03-2820:47thheller@thosmos how did you confirm that this call specifically gets elided?#2018-03-2820:47justinleesorry i guess i got confused. i though that if you include a raw js file then it was treated differently. please ignore me.#2018-03-2820:47thosmosOh, but this is in an electron app in the UI process which is being built with :target :browser#2018-03-2820:47thheller@lee.justin.m raw .js file requires *always* start with either / or ./. anything that does not start with those is a npm package.#2018-03-2820:47thosmosIt works when I use :js-options {:js-provider :require} but not :shadow#2018-03-2820:48justinleeoh. got it.#2018-03-2820:48thheller@thosmos then use that. should be fine.#2018-03-2820:48thosmos@thheller I confirmed by looking at the compiled JS that's output#2018-03-2820:48thheller:shadow only rewrites the whole npm stuff because the browser doesn't have access to require. electron does so its totally fine to do this.#2018-03-2820:49thhellerbut that would not explain why the .bind does not get removed with :require#2018-03-2820:49thhellerbecause that doesn't affect the generated code at all#2018-03-2820:49thhellerit is pretty much identical as far as closure in concerned#2018-03-2820:53thosmos@thheller thanks for shadow-cljs. It's great! I love the server mode!#2018-03-2908:55mitchelkuijpers@thheller
10:53:53.250 [XNIO-5 task-8] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /release-snapshots/app/latest request {Accept=[text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8], Accept-Language=[nl-NL,nl;q=0.9,en-NL;q=0.8,en;q=0.7,en-US;q=0.6], Cache-Control=[max-age=0], Accept-Encoding=[gzip, deflate, br], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36], Connection=[keep-alive], Cookie=[_okbk=vi3%3Dinactive%2Ccd4%3Dtrue%2Cvi5%3D0%2Cvi4%3D1505836096585%2Cvi2%3Dfalse%2Cvi1%3Dfalse%2Ccd8%3Dchat%2Ccd6%3D0%2Ccd5%3Daway%2Ccd3%3Dfalse%2Ccd2%3D0%2Ccd1%3D0%2C; _ok=1700-237-10-3483; ring-session=1499777936043; _okdetect=%7B%22token%22%3A%2214837138200590%22%2C%22proto%22%3A%22http%3A%22%2C%22host%22%3A%22localhost%3A4040%22%7D; org.cups.sid=0ab9c463b9384ae47f668da6ac4cd702; olfsk=olfsk467559086084683; wcsid=bxjbgsCgQGydcOdD3m39N0N80JEr4BH2; _ga=GA1.1.1242069313.1495026997; hblid=BLdYcEe25b7HnC1K3m39NQDYCOR30OE6; _oklv=1505836580733%2CbxjbgsCgQGydcOdD3m39N0N80JEr4BH2], Upgrade-Insecure-Requests=[1], Host=[localhost:9630]} response {}} {  }
java.lang.RuntimeException: Map literal must contain an even number of forms
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:682)
	at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
	at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
	at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
	at clojure.lang.EdnReader$VectorReader.invoke(EdnReader.java:672)
	at clojure.lang.EdnReader.readDelimitedList(EdnReader.java:757)
	at clojure.lang.EdnReader$MapReader.invoke(EdnReader.java:680)
	at clojure.lang.EdnReader.read(EdnReader.java:145)
	at clojure.lang.EdnReader.read(EdnReader.java:111)
	at clojure.lang.EdnReader.readString(EdnReader.java:67)
	at clojure.edn$read_string.invokeStatic(edn.clj:46)
	at clojure.edn$read_string.invokeStatic(edn.clj:37)
	at clojure.edn$read_string.invoke(edn.clj:37)
	at shadow.cljs.devtools.server.web.release_snapshots$info_page.invokeStatic(release_snapshots.clj:41)
	at shadow.cljs.devtools.server.web.release_snapshots$info_page.invoke(release_snapshots.clj:33)
	at clojure.lang.AFn.applyToHelper(AFn.java:160)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$apply.invoke(core.clj:652)
	at shadow.http.router$call_handler.invokeStatic(router.clj:12)
	at shadow.http.router$call_handler.invoke(router.clj:11)
	at shadow.cljs.devtools.server.web.release_snapshots$root.invokeStatic(release_snapshots.clj:55)
	at shadow.cljs.devtools.server.web.release_snapshots$root.invoke(release_snapshots.clj:54)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$apply.invoke(core.clj:652)
	at shadow.http.router$call_handler.invokeStatic(router.clj:12)
	at shadow.http.router$call_handler.invoke(router.clj:11)
	at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:160)
	at shadow.cljs.devtools.server.web$root.invoke(web.clj:159)
	at shadow.cljs.devtools.server$get_ring_handler$fn__56432.invoke(server.clj:60)
	at ring.middleware.resource$wrap_resource$fn__14079.invoke(resource.clj:37)
	at ring.middleware.resource$wrap_resource$fn__14079.invoke(resource.clj:37)
	at ring.middleware.params$wrap_params$fn__14063.invoke(params.clj:67)
	at shadow.cljs.devtools.server.ring_gzip$wrap_gzip$fn__56057.invoke(ring_gzip.clj:94)
	at shadow.undertow$ring_STAR_$reify__56143.handleRequest(undertow.clj:27)
#2018-03-2908:56thhellerwhat the heck?#2018-03-2908:56thhelleroh wait ... probably cider right?#2018-03-2908:57mitchelkuijpersOh no this is after: (shadow.cljs.devtools.api/release-snapshot :app {})#2018-03-2908:57thhellerbut called via cider?#2018-03-2908:57thhellercider sets *print-length*#2018-03-2908:58mitchelkuijpersAah ok#2018-03-2908:58mitchelkuijpersSorry for the noise 😛#2018-03-2908:58thheller.shadow-cljs/release-snapshots/app/latest/bundle-info.edn probably contains elided forms#2018-03-2908:58thhellerI'll create a "safe" print fn that sets all the print vars back to something good#2018-03-2908:59thhellerfor now try (binding [*print-length* 0] (shadow.cljs.devtools.api/release-snapshot :app {}))#2018-03-2909:00mitchelkuijpersthat also breaks it right? print-length 0#2018-03-2909:00mitchelkuijpers😛#2018-03-2909:01thhelleris it nil by default? though 0 was print everything#2018-03-2909:02mitchelkuijpersAh that might be the case#2018-03-2909:02mitchelkuijpersI made it 999999999 😛#2018-03-2909:02thhellerIf it is bound to logical false, there is no limit.#2018-03-2909:02thhellerso false/nil works#2018-03-2909:04mitchelkuijpersNice this works#2018-03-2916:35danielo515Hello everybody#2018-03-2916:36danielo515I want to thank shadow-cljs developers a big thank for the easiest cljs tool to use#2018-03-2916:37danielo515I think the only downside the tool has is it's website,it seems to be focused on browser environments or browser targeted apps, while this is not true. I was looking for building some node-cljs scripts and I first discarded shadow-cljs for this regard#2018-03-2916:38thheller@rdanielo welcome. yeah the docs are a constant work in progress. can't document everything at once since it does so much.#2018-03-2916:42danielo515I can understand that. To be honest, docs are very good. The only thing I'm missing is a simple but clear statement saying: you can use this tool with node-js as target, here is the example project: link#2018-03-2916:43danielo515Because everything is already in place: node-js target documentation, node-js project examples, but there is no mention on the main readme#2018-03-2916:47jmckitrickWhen using re-frame-10x, I’m supposed to add a line to :closure-defines. What is the equivalent for shadow?#2018-03-2916:47thheller@jmckitrick :closure-defines {re-frame.trace/trace-enabled? true} in your build config#2018-03-2916:47thhellerI think that was it#2018-03-2916:47jmckitrickOh, same thing? ok#2018-03-2916:47thhellerprobably best to set it in :dev mode only#2018-03-2916:48danielo515@thheller are you the author of shadow-cljs ?#2018-03-2916:48thheller:dev {:closure-defines {re-frame.trace/trace-enabled? true}}#2018-03-2916:48thheller@rdanielo yep#2018-03-2916:53danielo515I want to thank you for thinking out of the box and making a non strictly js tool available through npm#2018-03-2916:53danielo515I think npm it is an impressive distribution system#2018-03-2916:54danielo515and I used it to deploy all kind of stuff, including interactive documentation and general scripts, glad to see that a JVM based tool get into it too#2018-03-2916:57thhellerwasn't my idea. copied it from https://github.com/cljs/tool but it makes total sense in a CLJS setting#2018-03-2917:01danielo515Absolutely, it was the most straighforward installation I experienced in the cljs world#2018-03-2917:01danielo515One simple question#2018-03-2917:01danielo515How can I reload a file on the REPL once it has been re-built ?#2018-03-2917:02danielo515I am targeting node repl#2018-03-2917:03thhellershould be (require 'that.ns :reload)#2018-03-2917:03thhellerbut thinking about it I may have actually broken that recently 😛#2018-03-2917:08thhelleroops yes its broken.#2018-03-2917:08thheller:reload is ignored, will fix#2018-03-2917:25hlolliI think dnolen talked about some bug with :reload or :reload-all, either or, or both (in clojurescript environment)#2018-03-2917:31thhellerno thats just me. not using the related CLJS code so if there is a bug in that as well its purely coincidental#2018-03-2919:24danielo515That's sad#2018-03-2919:24danielo515So reload-all does not work neither ?#2018-03-2919:26danielo515One question, after a couple of iterations the REPL become slow and arrow keys are not working, so I can not take advantage of history#2018-03-2919:27danielo515Anyone knows a reason ?#2018-03-2919:29danielo515Mmm, seems to be a problem with VSCode integrated terminals#2018-03-2919:29danielo515What a pitty#2018-03-2919:29danielo515Which editor do you use, which is not emacs#2018-03-2919:31justinleefor clojurescript, cursive is the only realistic choice.#2018-03-2919:31justinleei would prefer to use atom, but protorepl isn’t that great for it yet#2018-03-2919:35thheller@rdanielo :reload is fixed in 2.2.21#2018-03-2919:44danielo515Awesome. Can I reload all the already loaded files ?#2018-03-2919:45thheller(require 'the.thing :reload)#2018-03-2919:47danielo515But that will only require that file#2018-03-2919:47danielo515I want to reload the entire project#2018-03-2919:59thhelleroops forgot about :reload-all#2018-03-2920:48danielo515Does that mean that it works ?#2018-03-2920:59thhellerno :reload-all doesn't work. will fix.#2018-03-2919:36thhellerrlwrap makes things more usable if you are on linux/mac#2018-03-2919:37danielo515What is so cool about rlwrap ? Seems to be used on many cljs and haskell projects#2018-03-2919:38thhellerprovides readline capabilities. eg. up/down arrow support#2018-03-2919:38danielo515@lee.justin.m does cursive require an intellij license ?#2018-03-2919:38thhellerI did not have time to write the code for that yet myself but rlwrap just works#2018-03-2919:38thhelleryou can use IntelliJ Community Edition which is free#2018-03-2919:43danielo515Is this the proper way to declare deps on shadow ? :dependencies [:binaryage/oops "0.5.8"]#2018-03-2919:44thhellerno :dependencies [[binaryage/oops "0.5.8"]]#2018-03-2919:44thhellersame as lein or boot#2018-03-2919:45danielo515Ahh, that's the point#2018-03-2919:59danielo515Thanks @thheller, deps works now#2018-03-2919:59danielo515Has anyone being able to connect lighttable to a shadow repl ?#2018-03-2920:00danielo515
shadow-cljs - server running at 
shadow-cljs - socket repl running at localhost:49898
shadow-cljs - nREPL server started on port 49900
Damn, how many sockets does this open ?
#2018-03-2920:01danielo515Should I use the nREPL one for ide integrations ?#2018-03-2920:01thhellerno idea which kind of REPL lighttable supports#2018-03-2920:05danielo515it has an option to connect to a remote clojure REPL through nREPL#2018-03-2920:05danielo515So I guess the third one is the correct option#2018-03-2920:06danielo515Does this error Worker shutdown. mean that I have to restart the server process ?#2018-03-2920:11thhellerno it means that the watch was stopped#2018-03-2920:12danielo515REPL became non-responsive#2018-03-2920:13thhellerhow are you using things?#2018-03-2920:13thhellershadow-cljs node-repl?#2018-03-2920:15danielo515yes#2018-03-2920:16danielo515I had to reload the repl, force stop and then start it again#2018-03-2920:16danielo515Can this be related with js interop ? ` [{:type clojure.lang.ExceptionInfo :message "failed to parse ns require"` I'm using the latest version#2018-03-2920:16thhellerthen just running shadow-cljs node-repl again should work fine#2018-03-2920:17thhellerns form is invalid#2018-03-2920:17thhelleror rather the require I should say#2018-03-2920:17thhellerwhat are you trying?#2018-03-2920:17danielo515files are#2018-03-2920:17danielo515
(ns rancher-cli.core
  (:require 
    [cljs.nodejs :as nodejs]
    [rancher-cli.request :as req]))
#2018-03-2920:17danielo515and#2018-03-2920:18danielo515
(ns rancher-cli.request
  (:require [cljs.nodejs :as nodejs]
            [request :as req]))
#2018-03-2920:18danielo515and I ust did (require 'rancher-cli.core) on the repl#2018-03-2920:18danielo515but before I tried#2018-03-2920:18danielo515(in-ns 'rancher-cli.core)#2018-03-2920:18thhellerin-ns only works after require#2018-03-2920:18thhellerbut the require failed?#2018-03-2920:21thheller[{:type clojure.lang.ExceptionInfo :message "failed to parse ns require"#2018-03-2920:21thhellerwhen did you get this?#2018-03-2920:42danielo515I got that making a require after making the in-ns first#2018-03-2920:42danielo515So maybe I screw things up with that#2018-03-2920:42hlolliwhat is [request :as req], probably an error?#2018-03-2920:44hlolliif you are in light-table and you evaluate the whole file with ctrl+enter, you are effectively doing the same thing as require-ing a file#2018-03-2920:44danielo515Nope, it's an npm library#2018-03-2920:45geraldodevHi, do you have project to suggest as a starting point for developing with shadow-cljs ?#2018-03-2920:45hlolliah ok, npm library has special syntax in clojurescript, you would need quotation marks ""#2018-03-2920:46danielo515It was working before without quotation marks#2018-03-2920:45danielo515@hlolli are you using lightabe? How do you connect it to the repl?#2018-03-2920:45hlolliso (ns my.ns (:require ["request" :as req]))#2018-03-2920:47hlolliif that worked, it probably never got evaluated, except you have a cljs file called request lurking in your root directory#2018-03-2920:48danielo515I have a file called request on my directory, and it's there where I do the request#2018-03-2920:50hlolliyes but that file is on classpath#2018-03-2920:50danielo515Rebooting the server and the repl worked#2018-03-2920:50danielo515It is now working with your syntax#2018-03-2920:50danielo515But I think it would work too without quotes#2018-03-2920:51danielo515I did not find any reference to what you are saying, I mean about using quotes#2018-03-2920:55danielo515Oops, new error appeared, hahaha
[1:1]~rancher-cli.core=> (require 'rancher-cli.core :reload)
[:result {:type :repl/error, :ex #error {
 :cause "Circular dependency detected: rancher-cli.core -> rancher-cli.core"
 :data {:tag :shadow.build.resolve/circular-dependency, :resource-id [:shadow.build.classpath/resource "rancher_cli/core.cljs"], :path [rancher-cli.core rancher-cli.core], :stack [[:shadow.build.classpath/resource "rancher_cli/core.cljs"]]}
I'm pretty sure I don't have circular deps, well, I had loaded that namespace with in-ns so maybe that was the problem
#2018-03-2920:55hlolliAre you requireing re-frame in a node repl?#2018-03-2920:55danielo515@geraldodev which kind of project are you interested at ? node ? browser ?#2018-03-2920:56danielo515@hlolli are you talking to @mynomoto right ?#2018-03-2920:57thheller@mynomoto it appears zprint.main has (:gen-class) in its ns. this means it can't be loaded as CLJS. don't worry about it though unless you were actually planning on using that.#2018-03-2920:58thhellerI should make the error for this less noisy I guess#2018-03-2920:58hlollino I was talking to you @rdanielo, all these default slack profile pics are confuseing me who is who 🙂 I'm also bit burnt out after this week.#2018-03-2921:01mynomoto@thheller thanks, I'm not using it! I have problems ignoring stacktraces but will do my best 😉#2018-03-2921:01danielo515Yes, I agree, I'll update my avatar#2018-03-2921:04danielo515@hlolli no, I am not using re-frame. My error about the circular dependency solved by moving to a different namespace, making the require from there and then moving to the original namespace again#2018-03-2921:04danielo515Sorry to hear that you're burned out#2018-03-2921:05mynomoto
[:browser] Build failure:
The required namespace "cljsjs.react-highlight" is not available, it was required by "day8/re_frame_10x/view/components.cljs".
This one seems to be a real error.
#2018-03-2921:09thheller@mynomoto https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-03-2921:12mynomotoShould I create a PR on https://github.com/thheller/shadow-cljsjs ?#2018-03-2921:12thhellerthat would be lovely#2018-03-2921:14mynomotoGreat, will do. I'm kind of regreting the packages that I added on cljsjs now 🤔#2018-03-2921:18thhellerhehe#2018-03-2921:20mynomotoIs there a table somewhere of how the js thing is exported and how to require it from cljs?#2018-03-2921:24justinlee@mynomoto you mean the table in this section of the guide? https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-03-2921:25mynomoto@lee.justin.m that's the one, thanks! My search abilities are failing right now...#2018-03-2921:38mynomotoSo in the rabbit hole of highlight, how do I create a cljsjs shim for https://github.com/isagalaev/highlight.js/blob/master/src/languages/clojure.js ?#2018-03-2922:06mynomotoI think I solved the above problem but got a new one:
The required namespace "mranderson047.reagent.v0v8v0_alpha2.reagent.core" is not available, it was required by "day8/re_frame_10x/view/event.cljs".
"mranderson047/reagent/v0v8v0_alpha2/reagent/core.clj" was found on the classpath. Should this be a .cljs file?
There is a clj and a cljs file with the same name.
#2018-03-2922:07mynomotoI'm going to be away for a while.#2018-03-2923:51geraldodev@rdanielo browser#2018-03-3006:58claudiuHi, Noob question. I'm using Cursive and fallowing the instructions in the fulcro-lein-template. Build works, hot reload works, repl seems to work for stuff like "(+ 1 2)" but not (js/console.log "test") -> No such namespace: js,. Am I doing something wrong or is this the way it's supposed to work ?#2018-03-3007:26claudiufound it 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage#2018-03-3015:15danielo515Hello#2018-03-3015:15danielo515Is any way to start a watch and a repl on a single operation ?#2018-03-3018:10danielo515I just want to report that :reload still not work#2018-03-3018:19thheller@rdanielo how does :reload not work? I tested it yesterday?#2018-03-3018:36thheller@rdanielo https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_repl or https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run can be used to start watch+repl#2018-03-3019:29danielo515But those methods are for spawning an standalone repl, I want to launch a watch and a repl attached to it.#2018-03-3019:25danielo515Well, it may be something related to my setup#2018-03-3019:25danielo515Or how do I use it#2018-03-3019:25danielo515Can you describe the correct steps to reload a file and then execute the functions within it ?#2018-03-3019:26danielo515I am really missing the haskell :load functionality#2018-03-3019:26thhellerdon't know haskell#2018-03-3019:26thhellerin the REPL#2018-03-3019:26thheller(require '[the.thing :as x]) then (x/foo)#2018-03-3019:26thhellerto reload (require 'the.thing :reload)#2018-03-3019:27mynomoto@thheller do you know if this is a bug or if I'm doing something wrong?
The required namespace "mranderson047.reagent.v0v8v0_alpha2.reagent.core" is not available, it was required by "day8/re_frame_10x/view/event.cljs".
"mranderson047/reagent/v0v8v0_alpha2/reagent/core.clj" was found on the classpath. Should this be a .cljs file?
There is a clj and a cljs file with the same name.
#2018-03-3019:28thheller@mynomoto which re-frame-10x version is that?#2018-03-3019:28mynomoto[day8.re-frame/re-frame-10x "0.3.0-1-react16"]#2018-03-3019:35thheller@mynomoto whats the global for react-highlight?#2018-03-3019:36mynomoto
(ns cljsjs.react-highlight
  (:require ["react-highlight.js" :as react-highlight]))

(js/goog.exportSymbol "Highlight" react-highlight)
#2018-03-3019:37mynomoto
(ns cljsjs.highlight.langs.clojure
  (:require ["highlight.js" :as highlight]
            ["highlight.js/lib/languages/clojure" :as c]))

(.registerLanguage highlight "clojure" c)
#2018-03-3019:37mynomotoYou will need the other one too. But all of those are not really tested because compilation failed before I could check#2018-03-3019:39thhellerah#2018-03-3019:41thhellerodd. this does work in CLJS?#2018-03-3019:41thhellerthe re-frame-10x code require is with an underscore#2018-03-3019:41thhellerhttps://github.com/Day8/re-frame-10x/blob/react-16/src/day8/re_frame_10x/view/event.cljs#L6#2018-03-3019:41thhellerbut the provided namespace is with -#2018-03-3019:42thhellerso mranderson047.reagent.v0v8v0-alpha2.reagent.core is available but mranderson047.reagent.v0v8v0_alpha2.reagent.core is not#2018-03-3019:42mynomotoThat makes sense. I will try with a fixed version on my project.#2018-03-3019:42thhellerthis shouldn't work in CLJS. don't know why it does#2018-03-3019:43mynomotoI didn't test outside shadow.#2018-03-3019:48mynomotoAdding a version with the correct namespace works. Thank you @thheller!#2018-03-3019:49thhellerdo you still want to open the PR for those namespaces above so you get the "credit" (whatever that means)?#2018-03-3019:49thhelleror should I just add them?#2018-03-3019:50thhellerthe shadow-cljsjs ones#2018-03-3019:50mynomotoI will check if those are even working before opening the pr. I can do that now that the project is compiling.#2018-03-3020:01thhellerright. thx.#2018-03-3020:14mynomotoIs there a way to add a dependency for production only on shadow?#2018-03-3020:19thhellerthis doesn't really apply to shadow-cljs since your build decides what goes into it. not your dependencies.#2018-03-3020:19thhellereg. :preloads are not included in a release build therefore if doesn't matter if you have them on the classpath#2018-03-3020:21mynomotoCan you take a look at https://github.com/Day8/re-frame-debux#two-libraries ? It's a dependency only for side effects on clojurescript.#2018-03-3020:22mynomotoIt replaces the implementation of a tracing version of defn and fn but I'm not sure about how to do that using shadow.#2018-03-3020:27thhellerwait what? this stuff replaces things on the classpath?#2018-03-3020:28thhellerI guess you could fallback to deps.edn for this currently#2018-03-3020:30thhellerI don't get what is happening. why is that split into two libraries. the runtime overhead of doing one thing or another in the macro is tiny.#2018-04-0211:16danielcomptonThe macro that is created is pretty large, when you expand it out. We made two libraries so you didn’t need to include any of the dev dependencies and you could be 100% sure there was no extra code ending up in your prod build#2018-04-0211:17danielcomptonI have a feeling the :devcards true trick will not be safe under the new AOT cache?#2018-04-0211:17danielcomptonI’m happy to hear other approaches for solving this problem#2018-04-0211:18danielcomptoncc @mynomoto #2018-04-0302:54mynomotoI think I'm missing something simple here. Why wouldn't a closure define work to make the macro do what is done in the two libraries separately?#2018-04-0302:58danielcomptonWe make the separate stub library so that you can be absolutely sure that the extra code doesn't get included#2018-04-0302:58danielcomptonThe DCE does ensure that, but this felt like a safer way to do it#2018-04-0302:59danielcomptonYou don't have to use the tracing-stubs library I guess, as long as the closure-define isn't set#2018-04-0302:59danielcomptonIt will default to not running#2018-04-0318:07mynomotoYeah, I see what you mean but shadow doesn't have a native way of having different development/production dependencies, I would have to add another tool for that.#2018-04-0319:04danielcomptonSure, we’ll you should be fine just using the tracing library then#2018-03-3020:30thheller> With this setup, your use of both macros will have zero runtime and compile time cost in production builds, and are able to be turned off at dev time too via the Closure define. This ensures that you can leave your code instrumented at all times, but not pay any costs in production.#2018-03-3020:30thhellerthere are other ways besides :closure-defines to achieve this though#2018-03-3020:31thhellerdevcards does this via :devcards true#2018-03-3020:35mynomotoLet me try to invoke @danielcompton about this 🆙#2018-03-3107:54danielo515I just decided that I want to pollute my user namespace while developing on the REPL, is there a way to include an extra file while on REPL ?#2018-03-3108:29danielo515Maybe I can do it with development options#2018-03-3108:29danielo515But not sure how#2018-03-3114:20geraldodevis devcards compatible with shadow-cljs ?#2018-03-3116:00justinlee@geraldodev yes#2018-03-3116:00justinleei haven’t used it but others have#2018-03-3122:12geraldodevHow shadlow-cljs selects which cljs compiler is going to use ? It bundles it#2018-03-3122:20geraldodevI was expecting shadow-cljs not to touch .clj files. I've configured a a source path that contains user.clj and it compiled it. I know that because I'm using lein and pulling tools.namespace from profiles.clj. Since the shadow-cljs.edn is not using lein true It threw a compiler exception#2018-04-0102:05denikversion 2.2.21 EDIT: looks like this was a build issue. I’ve run into this at least twice now, still haven’t build up the habit of cleaning :output-dir (which solved it for me). @thheller have you considered to programmatically wipe all target output between versions?#2018-04-0102:34geraldodevI'm getting "module without entry or suffix: jquery ? On build entry put :js-options :resolve {"jquery" {:target :global :global "jQuery"} }#2018-04-0115:10geraldodevWhen You call "shadow-cljs cljs-repl cards" and press ) the repl exits. Are you using a different repl client with shadow-cljs ?#2018-04-0115:13thheller@geraldodev shadow-cljs does not touch the user.clj. Clojure does. whatever you put in there will be loaded by clojure.#2018-04-0115:14thheller@denik cleaning output-dir should never be necessary since the compiler is supposed to overwrite all relvant files. if you have something that is happening consistently thats a bug you should report.#2018-04-0122:27denik@thheller Unfortunately I don’t think I have anything reproducible enough. Only noticing that things break between version updates. And then I spend hours trying to figure out what’s going in. Could this maybe have to do with upgrading cljs to 1.10..?#2018-04-0122:48thhellerno. any version change will invalidate all caches.#2018-04-0115:14thheller@geraldodev the ) exit should not happen. it is indeed a bug.#2018-04-0115:16thhellerthe query thing however works just fine for me?#2018-04-0115:18geraldodev@thheller do you want me to open an issue ?#2018-04-0115:19thhellersure#2018-04-0115:20geraldodevman I was looking your code, beautiful use of spaces.#2018-04-0115:24geraldodevI find interesting that you bundle clojurescript. That means that shadow-cljs is kind of a curator of cljs versions#2018-04-0115:25geraldodevDo you remember which clojure code touches user.clj ?#2018-04-0115:25thhellerwhat do you mean? shadow-cljs is just a build tool for clojurescript. it uses clojurescript to compile everything.#2018-04-0115:26geraldodevBecause it bundles a specific version#2018-04-0115:28thhellerah yeah. thats just more convenient that way.#2018-04-0115:31thhellerdon't know what part of clojure loads user.clj#2018-04-0115:34geraldodevIt felt strange when the lack of tools.namespace dependency required by user.clj was blowing the compilation process.#2018-04-0115:35thhellerhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L482#2018-04-0115:35thhellerit in the RT.doInit function which is one of the first things that gets called when clojure starts#2018-04-0115:35thhellerno way around that#2018-04-0116:11geraldodev@thheller Is https://github.com/bhauman/devcards/pull/135 preventing the use of devcards with shadow-cljs ?#2018-04-0116:14geraldodevOr have you seen users using devcards with shadow-cljs ?#2018-04-0116:46thheller@geraldodev you can use devcards just fine. only need to use (:require [devcards.core :as devcards :include-macros true])#2018-04-0116:46thhellerand :compiler-options {:devards true}#2018-04-0116:58geraldodev@thheller Thank You! now I'm back in the game#2018-04-0119:39geraldodevI saw that :compiler-options {:devcards true} on one githubrepo but I was thinking It was a mistake, because I didnt see :devcards on neither shadow-cljs and clojurescript searching with ag#2018-04-0120:23alex-dixonAnyone using with cider?#2018-04-0120:25justinlee@alex-dixon not me, but have you seen this? http://www.blog.nodrama.io/shadow-cljs-cider/#2018-04-0120:26alex-dixonNot yet. Came across this so I was thinking it should recognize shadow-cljs.edn now but no luck. https://github.com/clojure-emacs/cider/commit/973e1041bd0a7f6e60dbda126e20d90b870bab05#2018-04-0120:29thheller@alex-dixon it works if you use a cider snapshot version but I don't think it was officially released yet#2018-04-0120:30alex-dixonOk. I just pulled 0.17.0-snapshot I think…date was from yesterday. I’m an emacs noob so not positive. Going to try with atom#2018-04-0120:32thhellerI know pretty much nothing about cider but it seemed to work fine#2018-04-0203:53denik@thheller I’m wondering what might be going with the compilation time of my project. Here’s the case. I’m using reagent with semantic-ui-react. Just requiring (not using) the file containing the wrapped semantic-ui-components (all defonces) at least triples the compilation time for the first as well as subsequent compilations. I can see that the file count is going up but I hope that wouldn’t slow it down so much. Could you shed some light?
[:app] Compiling ...
[:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.46s)
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.82s)
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 2.27s)
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.67s)
#2018-04-0209:15thheller@denik compile with --verbose or :verbose true in your config. should make it clearer.#2018-04-0209:16thhellermight be that the writing to disk part is actually the slow part since 700 extra files needs to be written#2018-04-0214:40denikWill do. @thheller since the files don’t change can they not be rewritten?#2018-04-0214:45bolasblackHi thheller, is there posible to create multiple :node-test builds? My shadow-cljs.edn:
{:deps {:aliases [:dev :test]}
 :cache-root ".shadow-cljs"
 :builds {:main {:target :npm-module
                 :output-dir "lib"
                 :compiler-options {:source-map true}}
          :main-test {:target :node-test
                      :output-to "lib/main-test.js"
                      :autorun true
                      :compiler-options {:source-map true}}
          :delay-test {:target :node-test
                       :output-to "lib/delay-test.js"
                       :ns-regexp "-test-delay$"
                       :compiler-options {:source-map true}}}}
Because of some job in namespace *-test-delay will cost lots time, so I hope I can start the test manually.
#2018-04-0215:01thheller@bolasblack sure, no problem.#2018-04-0215:03bolasblackI got a warning:
[:main-test] Build completed. (72 files, 0 compiled, 0 warnings, 6.19s)
[:main] Build completed. (174 files, 1 compiled, 0 warnings, 6.25s)
[:delay-test] Compiling ...
[:delay-test] Build failure:
The required namespace "utils.airtable-test-delay" is not available.
#2018-04-0215:06thhellerdo you include that somewhere?#2018-04-0215:06bolasblackNo#2018-04-0215:06thhellerodd#2018-04-0215:07thhellerah is the file named incorrectly perhaps?#2018-04-0215:07thhellerwith - instead of _?#2018-04-0215:07bolasblack😂😂😂😂 oh sorry#2018-04-0215:08bolasblackI forgot rename the file#2018-04-0215:10bolasblackIt's so embarrassing 😣 😂#2018-04-0215:11thhellernot really. I would make this mistake constantly if Cursive wouldn't warn me about it.#2018-04-0215:13thhellerthere should probably be a better error for this. you shouldn't have to guess whats wrong. it should tell you.#2018-04-0215:16bolasblackThanks for your comfort:laughing:, if the error be better, I think it will save lots my life (I make this mistake many times)#2018-04-0217:31thheller@denik I did some tests and it appears the resolve performance is terrible with so many files. didn't optimize any of that since I didn't expect an issue with it. I'll see if I can tweak that a bit. https://github.com/thheller/shadow-cljs/issues/235#2018-04-0217:42denikThanks @thheller that’s crucial for DX#2018-04-0217:42denikwould yarn over npm bring any benefit?#2018-04-0217:37raymcdermottany ideas?#2018-04-0217:46thhellervery odd. is maven or clojars blocked maybe?#2018-04-0217:57raymcdermottyeah - weird, I’ll check#2018-04-0217:57raymcdermottI’m using an AWS CodeBuild CI image#2018-04-0217:58raymcdermottI don’t have lein installed but I don’t think Shadow needs that - yes?#2018-04-0217:58thhellernot required yes#2018-04-0217:59thhellerthe error is from here https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj#L70#2018-04-0217:59thhellerbut pretty much all this code does is maven interop via pomegranate. which is exactly what lein or boot use#2018-04-0218:00raymcdermottcan I enable any further debug / diagnostics?#2018-04-0218:01thhellerunfortunately no. never had issues with this before.#2018-04-0218:02thhellercould try shadow-cljs pom and then use mvn directly to resolve the deps. maybe that prints more useful info#2018-04-0218:09raymcdermottthanks - i’ll let you know what fixes it#2018-04-0218:11thhellerhttps://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#2018-04-0218:12thheller> When you use Maven with an AWS CodeBuild provided Java build environment, Maven pulls build and plugin dependencies from the secure central Maven repository at https://repo1.maven.org/maven2. This happens even if your build project's pom.xml file explicitly declares other locations to use instead.#2018-04-0218:13thhellerdon't actually know if the settings.xml is used at all but that might be the reason it can't find shadow-cljs since thats on clojars not http://maven.org#2018-04-0218:15raymcdermottAWS is quite annoying sometimes 🙂#2018-04-0218:33raymcdermottahem, Maven is not installed#2018-04-0218:34thhellerdoh. maybe try a temporary project.clj and lein?#2018-04-0218:34raymcdermottinstalling maven now … might just all start to work … one min#2018-04-0218:36thhellermaven isn't required by shadow-cljs so that shouldn't affect anything really#2018-04-0218:37raymcdermottmade no difference so you are right!#2018-04-0218:37raymcdermottwill try with lein#2018-04-0218:37thhellerbut does maven tell you anything when using the pom file?#2018-04-0218:38thhellershadow-cljs pom && mvn dependency:tree or so#2018-04-0218:39raymcdermottI will give that a try#2018-04-0218:50raymcdermottso I think there is something off with the JDK install#2018-04-0218:52thhellervery weird indeed. no idea what would cause something like that.#2018-04-0218:53raymcdermotthttps://stackoverflow.com/questions/33439905/is-the-cacerts-file-missing-in-ubuntu-15-10-and-openjdk-8-jdk#2018-04-0218:54raymcdermottseems like a bug in ubuntu#2018-04-0218:54raymcdermottthe recommended fixes there do the job#2018-04-0218:55raymcdermottblimey - we so often find that we are sitting on top of sand#2018-04-0309:22tianshuwhat's :runtime option stands for?#2018-04-0309:26thhellerin which context?#2018-04-0309:39tianshuI understand, in :npm-module will add repl client when it see :runtime = :browser.#2018-04-0309:41thhellerREPL in :npm-module is very unreliable. I meant to take it out completely. don't expect things to work.#2018-04-0309:42thhellerbut yes :runtime decides if the browser REPL or node REPL clients get injected#2018-04-0310:04tianshuI am trying to add a react native target, I add a file, copy from browser.clj.#2018-04-0310:05tianshubasically, I can take this single file to a shadow-cljs project, and I will have a new target?#2018-04-0310:06thhellerthe REPL is not going to work properly in react-native when using their packager. probably need to do the same hackery that re-natal does for figwheel#2018-04-0310:06thhellersame for live-reload#2018-04-0310:08tianshuno, it works perfectly I think...#2018-04-0310:09tianshuremember a few days ago, I asked you about these things#2018-04-0310:09thhellerfor simple stuff maybe. ns and require are probably not going to work#2018-04-0310:09tianshuyou mean require other cljs file in repl?#2018-04-0310:10thheller(require '[some.thing :as x]) in the REPL yes#2018-04-0310:11tianshumaybe I can have a try on this#2018-04-0310:11tianshubut I don't think this is a serious problem.#2018-04-0310:14thhellerI still didn't spend much time with RN but the fact that they are re-bundling the output from shadow-cljs is going to cause issues with reload/REPL#2018-04-0310:14thhellereven if its just source maps not working#2018-04-0310:15thhellerso I'd much rather bypass their packager completely if possible#2018-04-0310:21tianshuI think cljsrn needs a big step on tooling.#2018-04-0310:21tianshuit's really a awesome way for building apps with clojure, as RN is much more mature than few years ago.#2018-04-0310:23thhellerare there any docs about what their packager actually does?#2018-04-0310:24tianshuhaven't see any#2018-04-0310:24tianshuand the package is likely still under development.😂#2018-04-0310:36thhelleris create-react-native-app the preferred way to create apps these days or react-native directly?#2018-04-0310:42tianshuyes, and it use exponent.#2018-04-0311:13sleepyfoxI can see that the version has been bumped to 2.2.22 over the previous 2.2.20#2018-04-0311:13thhellerare you using openjdk on ubuntu by any chance?#2018-04-0311:13sleepyfoxYes#2018-04-0311:13thhellersee the issue above#2018-04-0311:13sleepyfoxOK, thanks#2018-04-0311:13thhellerhttps://stackoverflow.com/questions/33439905/is-the-cacerts-file-missing-in-ubuntu-15-10-and-openjdk-8-jdk#2018-04-0311:14thhellerthis seems to fix that#2018-04-0311:18sleepyfoxNot in my case it seems#2018-04-0311:19thhellerdo you have mvn available?#2018-04-0311:20sleepyfoxI'm building on top of the official Clojure Docker image, which is clojure:lein, which is built on openjdk:8, which is built on buildpack-deps:stretch-scm#2018-04-0311:20sleepyfoxNo, there is no mvn#2018-04-0311:21sleepyfoxbut there is a /usr/local/bin/lein#2018-04-0311:21thhellerlein should run into issues as well. you can create a temp project.clj and just add shadow-cljs and let it try to resolve#2018-04-0311:22thhelleryesterday this yielded
Leiningen 2.8.1 on Java 1.8.0_162 OpenJDK 64-Bit Server VM Could not transfer artifact org.clojure:clojure:jar:1.9.0 from/to central (): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
#2018-04-0311:23thheller
(defproject the-thing "0.0.0"
  :dependencies
  [[thheller/shadow-cljs "2.2.22"]])
#2018-04-0311:23thhellerlein deps#2018-04-0311:24thhellerhopefully that spits out a better error#2018-04-0311:58sleepyfoxOK, fixed using the stackoverflow answer posted above#2018-04-0317:30thheller@denik just pushed 2.2.23 which should fix all performance issues in builds with many JS files. semantic-ui-react goes from 3sec+ back down to the usual 0.4s#2018-04-0317:40denikthank you! will test now!#2018-04-0318:14denik@U05224H0W for me it now takes 2x longer for each compile
[:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.59s)
[:app] Compiling ...
[:app] Build completed. (207 files, 1 compiled, 0 warnings, 0.54s)
[:app] Compiling ...
[:app] Build completed. (911 files, 728 compiled, 0 warnings, 19.55s) <=== required semantic ui
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.71s)
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.98s) <== ~ compile time avg
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 0.95s)
[:app] Compiling ...
[:app] Build completed. (911 files, 1 compiled, 0 warnings, 1.22s)
#2018-04-0318:32thhellercan you compile with --verbose and check where all the time is going?#2018-04-0318:32thhellerits more reasonable now but still too slow#2018-04-0320:39geraldodevDo you have conf recommendation for running server process?#2018-04-0321:30lilactownafter upgrading to 2.2.23 (from 2.2.3) I'm getting a crash when starting a watch: Caused by: java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType#2018-04-0321:43thheller@lilactown do you have a pinned closure-compiler version in your dependencies? if so remove it.#2018-04-0321:47lilactownnot that I'm aware of#2018-04-0321:48thhellerclojurescript?#2018-04-0321:48lilactownI do have clojurescript in my project.clj at 1.9.946#2018-04-0321:48lilactown(I'm using the lein integration)#2018-04-0321:49thhelleryeah bump that to 1.10.238.#2018-04-0321:50thhelleror create an empty (ns shadow.build.cljs-closure) .. I added that ns to work around a different issue related to CLJS versions .. can't win in this situation ...#2018-04-0321:51lilactownk, I'll try updating to 1.10.238. thanks!#2018-04-0323:00lilactownok, that's working great now#2018-04-0415:12rgmI'm trying to transition a re-frame/soda-ash (ie. semantic-ui) project to shadow in preparation for trying to do an Electron packaging, and I've hit a bit of an npm head-scratcher:#2018-04-0415:13rgmsoda-ash is using cljsjs/semantic-ui-react ... I've followed the cljsjs transitioning steps to replace it with my own little namespace that pulls in the NPM, but the compiler isn't happy that ReactDOM seems to be missing. It's in package.json but the compiler doesn't seem to be picking it up.#2018-04-0417:28thheller@rgm the semantic-ui-react/dist/umd is not a valid package unfortunately. commonjs should be fine. could even try the es version#2018-04-0417:29rgmthanks, yeah... was just trying to mirror what cljsjs.semantic-ui-react pulled down from unpkg (which soda-ash relies on) so I have no idea how lein cljsbuild is making that work. ¯\(ツ)/¯#2018-04-0417:30rgmguess it must just be foreign and tacked onto the front of the bundle in just the right place#2018-04-0417:30thhellerCLJSJS just includes things as they are and does not do any further processing. so it relies on the ReactDOM and React globals being available#2018-04-0417:31thhellerbut quickly looking over the umd bundle you are far better off not using that#2018-04-0417:31thhellersince it includes lodash and other stuff#2018-04-0417:31rgmugh, good times.#2018-04-0417:31thhellerso if you any other package also used lodash you'd include it twice. by using the commonjs directly its only included once#2018-04-0417:32rgmthinking downstream towards possible advanced compilation, is there an advantage to using the ES6 versus commonjs versions?#2018-04-0417:32thhellerES6 is better yes, much better actually.#2018-04-0417:33rgmthen ES6 it shall be 👍#2018-04-0417:33thhellereven better would be only requiring what you need but that seems a bit ugly for this package#2018-04-0417:34thhellerusing the index always pulls in everything which is a bit annoying if you only use 10% or their stuff#2018-04-0417:38thhellerhmm how long do these take? semantic-ui-react has a bajillion files#2018-04-0417:40rgm<- Shadow JS converting 1025 JS sources (18541 ms)#2018-04-0417:42thhellershould be fine with caching I hope but I need to optimize that#2018-04-0417:44rgmI'm still shaking off a few years with meteor.js waiting 30-40s every single time the file watcher fired up, so I'm cool with 18s one time.#2018-04-0417:45rgmbut far be it for me to stop you from making it faster 😉#2018-04-0417:53gadfly361@rgm @thheller if anyone is willing, would be happy to accept PR to add how to use soda-ash with shadow-cljs to soda-ash's README#2018-04-0417:54rgmAnd as it happens I would love to contribute that ... just need to find a bit of time#2018-04-0417:55thhellerwe can add the cljsjs.semantic-ui-react to https://github.com/thheller/shadow-cljsjs so others don't have to do this part#2018-04-0417:55rgm(also I haven't yet got my project back up on its feet so maybe I should wait until I've sorted that out ... don't think there's still a problem with SA since it all looks good but just want to actually see pixels on the screen).#2018-04-0418:26rgmholy dinah ... my project is working again, and so (I think) is advanced compilation for the first time ever#2018-04-0418:51rgm@gadfly361 lmk, but I'm not sure that soda-ash in particular needs anything more than https://github.com/thheller/shadow-cljsjs/pull/5 to exist... seems more of a shadow-specific concern that https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs documents well.#2018-04-0418:52rgmpretty much any use of shadow + cljsjs should lead here; it's not really on soda-ash#2018-04-0418:56thhellermerged. will include it in the next release.#2018-04-0418:58gadfly361@rgm sounds good to me! I am unfamiliar with shadow-cljs, so will leave it to you guys :) (Hope to take it for a test ride soon tho!)#2018-04-0418:59rgmha, I'm only about 10 minutes ahead of you on familiarity. Thx for soda-ash.#2018-04-0418:59gadfly361If only 10 mins, that bodes well for shadow cljs parrot#2018-04-0421:49hmaurerHi! I have been getting this error and I’ve no idea where it comes from:
NullPointerException: 
	clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:301)
	shadow.build.output/flush-dev-js-modules (output.clj:564)
	shadow.build.output/flush-dev-js-modules (output.clj:560)
	shadow.build.targets.npm-module/process (npm_module.clj:63)
	shadow.build.targets.npm-module/process (npm_module.clj:54)
	clojure.lang.Var.invoke (Var.java:381)
	shadow.build/process-stage/fn--14988 (build.clj:119)
	shadow.build/process-stage (build.clj:116)
#2018-04-0421:51thheller@hmaurer what is your build config? and version?#2018-04-0421:52hmaurer@thheller I just started with shadow so sorry if I am doing something silly. I installed it tonight so I assume latest version, and my build config is:
:builds
{:npm {:target :npm-module}}
#2018-04-0421:52hmaurerversion: 2.2.24#2018-04-0421:53thhellerdoes it work if you just use :builds {}?#2018-04-0421:54thhelleror add :output-dir "out" or so. it defaults to :output-dir "node_modules/shadow-cljs"#2018-04-0421:55hmaurerhum yes, with :builds {} it works#2018-04-0421:55thheller:target :npm-module requires at least :output-dir, which is set if using the built-in :npm config#2018-04-0421:55thhellerbut by you setting it manually that gets overridden. I'll add a validation for this#2018-04-0421:56hmaurerOh I see. In the doc it’s mentioned as optional#2018-04-0421:56hmaurerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_explicit_configuration#2018-04-0421:56thhelleroh that is incorrect#2018-04-0421:59hmaurerAh well, quick fix 🙂 Beyond that I am excited about shadow; I am working on a ClojureScript project which I would like to use as a library in a webpack project#2018-04-0421:59hmaurerit seems like a good fit#2018-04-0421:59hmaurerOh also, while I am at it: when running the watch command I get a bunch of warnings @thheller :
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/hmaurer/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#2018-04-0422:00thhelleryeah those are Java9 warnings. can't really do anything about them until that lib gets updated.#2018-04-0422:00thhellerdon't worry about those though. not a problem.#2018-04-0422:00hmaurerOk; just wanted to make sure something wasn’t off about my setup#2018-04-0422:00thhellerall good.#2018-04-0422:22hmaurer@thosmos is it possible to load some namespace automatically when clj-repl starts?#2018-04-0422:22hmaurer(to set up some functions, etc)#2018-04-0422:22hmaurere.g. I would like to load the my-app.tinker namespace, or similar#2018-04-0422:23hmaureroh also, is it normal that arrow keys don’t work in the clj-repl ? Am I required to use rlwrap?#2018-04-0422:35thhellerrlwrap yes#2018-04-0422:36thhellerclj-repl no. I still need to add an option for that.#2018-04-0422:36thhellerI never use the REPL from the command line. always from my editor (Cursive) so I really have no idea what people want for the command line#2018-04-0422:37thhellerfeel free to open a ticket though. I'm happy to add this.#2018-04-0422:43hmaurerOk, thank you! I should probably get used to an editor with good clojure repl integration#2018-04-0422:56thhellerit helps a lot if people actually just report what they expected to work. Can't fix anything if I'm not aware there is a problem in the first place.#2018-04-0422:56thhelleronly because I don't like working at the command line doesn't mean it shouldn't be supported properly#2018-04-0508:57troglotithey! where I can find :id-of-build which is needed to connect to cljs build? Described like here: https://github.com/thheller/shadow-cljs/wiki/Cider#2018-04-0508:58thhelleryour :builds {:id-of-build ...}. :app or so.#2018-04-0509:16troglotityeap, it worked, thank you!#2018-04-0511:08sleepyfoxI've noticed that upon first use, shadow-cljs downloads maven deps and stores them in ~/.m2 - is there a way of configuring this location?#2018-04-0511:08thhellernot currently no#2018-04-0511:09sleepyfoxThat's a shame, it's making CI builds more painful than they need to be#2018-04-0511:10thhellerhmm thats a standard maven thing so I'd expect there to be solutions for this with CI#2018-04-0511:10thhellerdunno if I can make configurable#2018-04-0511:10sleepyfoxAre you delegating to lein/mvn or doing it yourself?#2018-04-0511:11thhellercurrently using https://github.com/cemerick/pomegranate which is the same lein is using. might switch to tools.deps in the future.#2018-04-0511:11thhellerhttps://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate/aether.clj#L328#2018-04-0511:11thhellerlooks like its configurable though
#2018-04-0511:12sleepyfoxOK, I'll give that a go#2018-04-0511:12thhellertry setting :local-repo "wherever" in your shadow-cljs.edn config#2018-04-0511:12sleepyfoxyup#2018-04-0511:12thhellerneed to delete .shadow-cljs/classpath.edn though#2018-04-0511:12thhellerthat currently does not account for :local-repo changing#2018-04-0511:12sleepyfoxofc#2018-04-0511:38sleepyfoxWorking correctly, thanks#2018-04-0517:40hmaurer@thheller in clojurescript I recall you have to tag functions with ^:export to avoid the names being re-written by advanced compilation, however I see no mention of that with shadow (for the :node-module target). What’s the behaviour?#2018-04-0517:41thhellernot required, the compiler knows what it needs to know due to the :main config#2018-04-0517:41hmaurerAlso, can I benefit from dead code elimination with :node-module or simialr by specifying a namespace containing my “API”, and get everything that the API doesn’t depend on to be eliminated by Closure?#2018-04-0517:41thhellerfor :npm-module everything you don't ^:export is fair game and will most likely be removed#2018-04-0517:42hmaurerah#2018-04-0517:43hmaurerI don’t quite get the difference between :node-library and :node-module then#2018-04-0517:43hmaurerI think#2018-04-0517:43hmaurerI’ll re-read the doc#2018-04-0517:44thheller:node-library generates ONE file object with exports. so you end up with ONE require("the-thing")#2018-04-0517:44thheller:npm-module leaves the namespaces intact so you can require individual namespaces require("the-thing/some.ns")#2018-04-0517:44hmaurer@thheller so that’s similar to using :node-module and writing a special namespace myself, e.g. “api”, which contains my functions?#2018-04-0517:45hmaurer:node-library generates a single file mapping to various functions in various namespaces?#2018-04-0517:45thhellerwith :node-library you specify the :exports in the config. they can be from different namespaces yes.#2018-04-0517:45hmaurerbut with :node-module, as you said, I need to mark any function that I wish to use post-compilation with ^:export, right?#2018-04-0517:45thhelleryes#2018-04-0517:46hmaurerok. Thank you! 🙂#2018-04-0517:46hmaurerDo you have a recommended way to integrate shadow with other js projects? e.g. would you generate a npm package and symlink it from your other projects?#2018-04-0517:47hmaurerOr else?#2018-04-0517:47hmaurerI tried various approaches yesterday night#2018-04-0517:47hmaurerJust curious if you have one in mind#2018-04-0517:47hmaurerspecifically to get live-reload to work nicely with create-react-app/parcel/webpack/else#2018-04-0517:48thhellerideally you let shadow-cljs compile the JS completely#2018-04-0517:48thhellerintegrating the other way around is always going to be lossy#2018-04-0517:49thhellerin particular live-reload .. that pretty much goes out the window if you let anything else bundle the code#2018-04-0517:50thhellerI did this test a while ago. https://github.com/thheller/react-redux-realworld-example-app/tree/this-is-madness#2018-04-0517:51thhellerbasically took the entire create-react-app project. moved some things around but didn't change one line of code.#2018-04-0517:51thhellerand use shadow-cljs to compile it some some extra help from babel#2018-04-0517:51thhellerbut thats nowhere near reliable enough now .. but thats the direction I was going with#2018-04-0517:52thhellerintegration with webpack is easy enough and really depends on how your JS project is setup#2018-04-0517:52thhelleryou could create a dummy npm package for the JS output#2018-04-0517:52thhelleror just output it into some directory and refer to the files directly via either relative paths#2018-04-0517:52thhelleror webpack resolve config help#2018-04-0517:56hmaurerI didn’t realise shadow could bundle javascript as well#2018-04-0517:56hmaurerinteresting#2018-04-0517:56hmaurerand could i mix cljs, cljc and js sources this way?#2018-04-0517:56thhelleryes#2018-04-0517:56thhellerhttps://github.com/thheller/shadow-cljs-examples/tree/master/local-js/src/demo#2018-04-0517:56hmaurerBasically I am working on a project for which the “core” is written in clojurescript, but I want to develop the interface with React in JS#2018-04-0517:57thhellerapp.cljs uses foo.js which uses bar.cljs#2018-04-0517:57thhellerfull interop#2018-04-0517:58thhellerunfortunately all of this is not totally finished yet since you need to run babel manually currently#2018-04-0517:58hmaureris this kind of “mixed” project documented?#2018-04-0517:58thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_dealing_with_js_files#2018-04-0517:58hmaurerI’ll try to replicate the example though 🙂#2018-04-0517:58thhellervery experimental#2018-04-0518:00hmaurerWhile I am at it: you mentioned using the REPL only through your editor. If I wish to use a REPL through the command line, and have the ability to reload namespaces that changed on the fly, how could I do it?#2018-04-0518:00hmaurerRight now my project is set up with boot. Most of the project is composed of cljc files#2018-04-0518:00hmaurerI use the Clojure (not clojurescript) REPL, and wrote a function to reload namespaces (that I call manually, (reload); it looks for files that changed and reloads the namespaces)#2018-04-0518:04thhellerrlwrap npx shadow-cljs clj-repl (reload)#2018-04-0518:05hmaureroh there is a built-in reload function?#2018-04-0518:05hmaurerah you meant I should expose mine#2018-04-0518:05hmaurersorry#2018-04-0518:05hmaureryeah, which goes back to my question on loading a namespace by default when starting the repl#2018-04-0518:06hmaurerbut I can figure that out#2018-04-0518:06thhellershadow-cljs really isn't meant for Clojure though#2018-04-0518:06thhellerif you want reload for CLJS I recommend using the build-in reload stuff#2018-04-0518:06hmaurerI wouldn’t mind using the clojurescript repl#2018-04-0518:06hmaurerso long as I can get stuff auto-reloaded#2018-04-0518:06hmaureror manually reloaded somehow#2018-04-0518:07thhellerwhich REPL though? if you let webpack process your sources the REPL and live-reload pretty much don't work#2018-04-0518:08hmaurerthat would just be to debug the “core”, which is entirely written in clojurescript#2018-04-0518:08thhellerso shadow-cljs browser-repl or so?#2018-04-0518:08hmaurerit’s basically a library of functions#2018-04-0518:08thheller(require 'some.ns :reload) should do it then#2018-04-0518:26denik@thheller have been watching your commits. Slow compiles where always my biggest pet peeve with big project cljs builds! DX just got much more pleasant. 💯 thanks for the performance tweaks!#2018-04-0518:33thhellerI think there is still lots of tuning that could be done. just need time to do it 🙂#2018-04-0522:49tony.kayon hot code update: renaming a namespace seems to give shadow-cljs some problems. It complains that it can’t find the namespace anymore#2018-04-0608:08thhellerjust renaming the file?#2018-04-0617:29tony.kayrefactor in IntelliJ: which renames the file. Then shadow complains the file is missing and I have to restart it#2018-04-0600:44denik@thheller while using shadow-cljs in embedded mode, I want to redef the request-handler without restarting the server and build processes. Is there any way to do that?#2018-04-0601:08denikI think the problem is that the server closes over the value of the handler instead of keeping the var around.#2018-04-0601:09denikSince I’d be making new endpoints all the time it would be unfortunate and is unnecessary to have to recompile every time.#2018-04-0608:07thhellerwhich request-handler? the one for the build? you could either set :http-handler that just delegates to the var you want to switch.#2018-04-0608:07thhelleror use your own webserver to begin with. shadow-cljs really doesn't need anything special from the dev-http servers#2018-04-0608:57thheller@U050CJFRU sorry misunderstood what you were asking. fixed in 2.2.25. the var is now deref'd when the request happens not when starting the server. so any updates should be reflected immediately.#2018-04-0615:43denik@thheller you’re killing it! This is so much fun!#2018-04-0604:37levitanong@thheller hi, if I might make a suggestion regarding the shadow-cljs hud: Perhaps you can set z-index to a high value like 10000 to ensure that it stays on top of other absolutely positioned elements?#2018-04-0608:09thhellerthought that was already done but didn't do it for all elements. will add it to all.#2018-04-0609:00thhellerfixed. will be in next release.#2018-04-0609:16mjmeintjesWhen starting a repl with shadow-cljs node-repl, is it possible to connect via another nrepl client? What would to port be? I want to start a node repl without having to set up build config, and then connect to it via cider.#2018-04-0609:22mjmeintjesNo worries, seems to work when I connect to existing shadow-cljs server via cider and then call (shadow.cljs.devtools.api/node-repl).#2018-04-0609:27thheller@mjmeintjes it also works properly now if you just run (shadow.cljs.devtools.api/node-repl) without running shadow-cljs node-repl first.#2018-04-0609:32mjmeintjes@thheller Thanks, that works great.#2018-04-0610:03mjmeintjesOne thing I'm struggling with - when I have a :node-script target, I can start the compiled js file using node, and then connect to the nrepl using cider. However, I can't figure out how to make println statements output to the repl. When I call println, it prints in to console where I started the node js script. I would like it to print within the repl. Does that make sense? Is it possible?#2018-04-0612:09troglotitHey! Is there way to import/require non-js dependencies just like webpack?#2018-04-0701:52geraldodevI've typed a sdfçlj asdlfkj asd on my cljs file, and It appeared as a Warning. Is that right ? I didnt see an Error yet, just Warning .#2018-04-0701:52geraldodevUse of undeclared Var guts.http/asdlfkj#2018-04-0701:54geraldodevEvery non sensical word became Use of undeclared Var as a Warning#2018-04-0702:37justinlee@troglotit if you mean webpack loaders like image loaders and css loaders, the answer is no, shadow doesn’t do that for you#2018-04-0705:02levitanongis there a way to run a node js script via shadow-cljs? My workflow for a thing is, I compile a node script, then run it via node ..., and I’m looking for a cleaner way to do things.#2018-04-0711:23tianshu@thheller try to write a target for react native, met this error.
JS runtime connected.
[2018-04-07 19:16:05 - ERROR] UT005071: Undertow request failed HttpServerExchange{ POST /worker/files/app/467f79fb-e0e5-4f7b-9df5-56e803f4cf44/1998cbc0-21d4-4a18-a69f-aa7b9dff54f0 request {Connection=[keep-alive], Accept=[*/*], Accept-Language=[en-us], Accept-Encoding=[gzip, deflate], Content-Type=[application/edn; charset=utf-8], Content-Length=[303], User-Agent=[HelloRN/1 CFNetwork/893.14 Darwin/16.7.0], Host=[0.0.0.0:9630]} response {}}
clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "clojure/walk.cljs"] {:resource-id [:shadow.build.classpath/resource "clojure/walk.cljs"]}
	at clojure.core$ex_info.invokeStatic(core.clj:4739)
	at clojure.core$ex_info.invoke(core.clj:4739)
	at shadow.build.data$get_output_BANG_.invokeStatic(data.clj:168)
	at shadow.build.data$get_output_BANG_.invoke(data.clj:164)
	at $files_req$fn__19941.invoke(ws.clj:221)
	at clojure.core$map$fn__5587.invoke(core.clj:2745)
	at clojure.lang.LazySeq.sval(LazySeq.java:40)
	at clojure.lang.LazySeq.seq(LazySeq.java:49)
	at clojure.lang.RT.seq(RT.java:528)
	at clojure.core$seq__5124.invokeStatic(core.clj:137)
	at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
	at clojure.core.protocols$fn__7835.invokeStatic(protocols.clj:75)
	at clojure.core.protocols$fn__7835.invoke(protocols.clj:75)
	at clojure.core.protocols$fn__7781$G__7776__7794.invoke(protocols.clj:13)
	at clojure.core$reduce.invokeStatic(core.clj:6748)
	at clojure.core$into.invokeStatic(core.clj:6815)
	at clojure.core$into.invoke(core.clj:6807)
	at $files_req.invokeStatic(ws.clj:245)
	at $files_req.invoke(ws.clj:173)
	at $process_req.invokeStatic(ws.clj:283)
	at $process_req.invoke(ws.clj:253)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$apply.invoke(core.clj:652)
	at shadow.http.router$call_handler.invokeStatic(router.clj:12)
	at shadow.http.router$call_handler.invoke(router.clj:11)
	at shadow.cljs.devtools.server.web$root.invokeStatic(web.clj:160)
	at shadow.cljs.devtools.server.web$root.invoke(web.clj:159)
	at shadow.cljs.devtools.server$get_ring_handler$fn__21898.invoke(server.clj:60)
	at ring.middleware.resource$wrap_resource$fn__21453.invoke(resource.clj:37)
	at ring.middleware.resource$wrap_resource$fn__21453.invoke(resource.clj:37)
	at ring.middleware.params$wrap_params$fn__19405.invoke(params.clj:67)
	at shadow.cljs.devtools.server.ring_gzip$wrap_gzip$fn__21523.invoke(ring_gzip.clj:94)
	at shadow.undertow$ring_STAR_$reify__21609.handleRequest(undertow.clj:28)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
I found the code https://github.com/thheller/shadow-cljs/blob/0749e08322f5059e255fb3eb41a0f3c63c29c1d3/src/main/shadow/build/data.clj#L164
#2018-04-0711:44tianshudon't know why there's no clojure/walk in :output of state, there're clojure/string, clojure/data, etc.#2018-04-0715:53Alex HI've just updated to shadow-cljs 2.2.25, and stuff that used to work in the JS interop stopped working; I'm requiring a js file (with ["/gen/editor" :as editor], which in turn requires some npm modules; some of those npm modules are in commonjs format, so I use a "const omit = require('ramda/src/omit') for example instead of an ES6 import, to avoid the .default#2018-04-0715:53Alex Hhowever, shadow-cljs (or cljs? or something?) now always seems to add .default to the uses of that#2018-04-0715:54Alex Hvar omit$$module$gen$editor = module$node_modules$ramda$src$omit.default;#2018-04-0715:54Alex Hvar module$node_modules$ramda$src$omit = shadow.js.require("module$node_modules$ramda$src$omit", {});#2018-04-0715:54Alex H(in reverse order, sorry)#2018-04-0715:55Alex His there a way to avoid that automatic appending of .default to anything imported in JS?#2018-04-0715:55Alex Hit used to work on 2.0.138 as far as I can tell#2018-04-0716:07Alex Hthis is what is in the cljs-runtime/module$node_modules$ramda$src$omit.js file: shadow$provide.module$node_modules$ramda$src$omit=function(e,k,a,p,f){e=a("module$node_modules$ramda$src$internal$_curry2")(function(a,e){for(var c={},f={},g=0,k=a.length;g<k;)f[a[g]]=1,g+=1;for(var p in e)f.hasOwnProperty(p)||(c[p]=e[p]);return c});p.exports=e}#2018-04-0716:23Alex Hhere's a reproducer, fwiw: https://github.com/bwalex/shadowcljs-cjs-issue#2018-04-0716:31Alex Hsomehow trying to revert to 2.0.138 causes all sorts of other weird issues now. great.#2018-04-0716:44Alex H@thheller, any idea of how to work around that?#2018-04-0717:02Alex Hok, interesting - they just broke compatibility with everything in closure compiler itself#2018-04-0717:02Alex Hdoing import * as omit from 'ramda/src/omit' for example seems to work#2018-04-0717:02Alex Hon a slightly unrelated note, though, with the latest shadow-cljs I keep running into issues where it can't reload the js namespaces properly, though#2018-04-0717:03Alex Hwhen they get modified#2018-04-0717:03Alex Hin that reproducer repo (after fixing the import), I get:#2018-04-0717:03Alex H[:app] Build failure: no source by provide: module$gen$abc {:provide module$gen$abc} ExceptionInfo: no source by provide: module$gen$abc#2018-04-0800:04alex-dixonhttps://github.com/thheller/shadow-cljs/issues/240#2018-04-0718:18stathissiderishello, I’m trying to follow this guide and it’s unclear to me what I need to do after I run shadow-cljs watch app#2018-04-0718:19stathissideristhe article seems to imply that my browser should load something#2018-04-0718:19stathissiderisis that automatic or do I have to point it somewhere?#2018-04-0718:26orestisI don’t think shadow will open a browser. Which guide are you referring to?#2018-04-0718:27stathissiderisoops#2018-04-0718:27stathissideristhis one: https://medium.com/@jiyinyiyong/a-beginner-guide-to-compile-clojurescript-with-shadow-cljs-26369190b786#2018-04-0805:43JonI changed the sentences a bit. Try if that helps.#2018-04-0805:44Jonfor short, you can tell shadow-cljs to start an HTTP server.#2018-04-0718:29orestisPerhaps this is a bit more up to date? https://github.com/shadow-cljs/quickstart-browser#2018-04-0718:29stathissideristhanks, reading#2018-04-0718:29orestisIt has an explicit config key to open a dev server in the shadow edn config. #2018-04-0718:33stathissideristhis guide is much more complete, many thanks#2018-04-0718:36orestisNote that there is an official user manual that for some reason doesn’t appear very high on Google: https://shadow-cljs.github.io/docs/UsersGuide.html#2018-04-0718:38stathissideris@orestis I did see that, but I think it’s better suited as a reference rather than a guide to a newcomer!#2018-04-0718:39stathissiderisI found myself jumping around in that manual, struggling to form a complete picture#2018-04-0718:43stathissiderisso another question: is figwheel still superior in terms of reloading?#2018-04-0718:48orestisYeah, the manual is a reference. I think a quick start guide would be helpful there. #2018-04-0718:48orestisNo idea about superiority, but it is claimed that shadow provides the necessary functionality. #2018-04-0718:49orestisI lurk in this channel and I’m just repeating what I read :)#2018-04-0718:51stathissiderisgood strategy 😄#2018-04-0720:57thheller@alex340 the JS on the classpath stuff currenly only works with ES6. Closure processes CommonJS strangely and I don't know how to deal with that yet.#2018-04-0801:24geraldodevI' ve made a src/shim directory to put cljsjs shim. its annoying it was next to src/cljs#2018-04-0801:42steveb8nI’m having trouble getting a basic om-next app loading in devcards using shadow.#2018-04-0801:43steveb8nI’ve tracked it down to the om/reconciler object not satisfying IReconciler#2018-04-0801:44steveb8nhas anyone seen problems like this with om-next or core/satisfies? in shadow compiled code?#2018-04-0801:45steveb8nI also tried (satisfies? IFn identity) and that’s false as well#2018-04-0801:46steveb8n(satisfies? IDeref (atom {})) is true so satisfies? appears to generally work I guess#2018-04-0801:47steveb8nbut this fails and blocks om-next from starting#2018-04-0801:48steveb8n`(satisfies? om.next.protocols/IReconciler (om/reconciler {:state (atom {}) :parser (om/parser {:read (fn [& args] nil)})}))`#2018-04-0801:55steveb8n@stathissideris I’m just getting started with shadow but reloading and error msgs are looking great with shadow vs figwheel. devcards as well#2018-04-0804:36alex-dixonAnyone know how I might be able to solve reloading js files? https://github.com/thheller/shadow-cljs/issues/240#2018-04-0808:05thheller@alex-dixon my bad. the recent compile performance optimization I did for JS broke the reloading part#2018-04-0808:06thhellerwill fix it after breakfast#2018-04-0813:35javiHii, I am on shadow-cljs: ^2.2.21 and when attempting to include core.async in a build with target :bootstrap I get the following error... The required namespace "java.util.concurrent.locks.Lock" is not available, it was required by "cljs/core/async/impl/ioc_macros$macros.cljc". edn deps has [org.clojure/core.async "0.4.474"] has anyone come across this? Cheers! (edit: code format)#2018-04-0815:19alex-dixon@thheller Np at all. Anything I can do to help? Wanted to start on it but didn’t because I thought it might be too deep an issue for a first time contributor#2018-04-0816:13thheller@fj.abanses core.async is not self-host compatible and cannot be compiled by :bootstrap#2018-04-0816:14thheller@alex-dixon the reload issue is easy to fix but I went down this rabbit hole trying to make commonjs/es6 compatible again#2018-04-0816:14thhellerdidn't get anywhere again#2018-04-0816:14thhellerwill release the reload fix later#2018-04-0816:14thhellergrabbing some food first#2018-04-0816:16alex-dixonI’m not sure if this is an appropriate reaction but…what the heck is up with closure’s decision to not conform to the es6 modules spec and sort of invent their own version of it?#2018-04-0816:16thhellerwell might as well push it now. 2.2.26 should at least reload properly.#2018-04-0816:17thhellercan talk later .. gotta go#2018-04-0816:58stathissideris@steveb8n thanks!#2018-04-0817:07javi@thheller of course!! thanks. i just remembered... i am gonna use mfikes andare instead#2018-04-0819:24rgmis something like :closure-defines available in shadow-cljs? The problem I'm working on is that I want one target for electron and one target for the browser. It's re-frame, so I'd like to be able to branch on that at compile time and use that to choose whether data gets loaded from filesystem (electron) or the web (browser).#2018-04-0819:25rgmI tried using :closure-defines in a :compiler-options map and just at the top-level of the build, and it didn't seem to take.#2018-04-0819:26rgmoh, nvm. Was executing the wrong file.#2018-04-0819:26rgmduh#2018-04-0819:29rgmfor the record it seems to work at both levels: at the top level of the build map, and down in a :compiler-options map#2018-04-0819:30rgmlooks like the :compiler-options governs if they're both present#2018-04-0819:32thheller@rgm inside :compiler-options is the correct place yes but as a convenience its allowed in the build also#2018-04-0819:34rgmit occurred to me that I could also branch my event behaviour by altering the main start-up call in my index.html ... eg <script>my.project.system.go("electron")</script> but it seems less screwable-aroundable-with in prod if I just lock it in at build time.#2018-04-0819:35rgmman, so many knobs to twiddle 😬#2018-04-0819:35thhellerI would suggest just using 2 different entry namespaces#2018-04-0819:35thhelleryour.project.browser and your.project.electron#2018-04-0819:35thhellerso you can do all the setup needed in those and re-use parts that make sense#2018-04-0819:36rgmhm, ok... seems reasonable. It's 99% duped at this point but when it inevitably diverges that'll make sense#2018-04-0819:37rgmright now the entire rationale is providing offline use of an (effectively) read-only app.#2018-04-0819:38rgm(it's a little calculator for building construction and weirdly, job sites often have terrible network coverage).#2018-04-0819:40thheller@alex-dixon Closure is totally compliant with the ES6 spec. the problem is that the spec doesn't define how interop with commonjs should work and this is how we get into trouble. most of the code on npm is commonjs (eg. react) which don't have a "default" export. so their decision was that commonjs should ONLY have a default export and you access everything through that.#2018-04-0819:40thhellerso import React from "react"#2018-04-0819:41thhellerunfortunately webpack is not as strict and also allows direct refer#2018-04-0819:41thhellerimport React, { createElement } from "react" works in webpack but not in closure#2018-04-0819:41thhellerso I either make refers work or the default export#2018-04-0819:43thhellerneither option is perfect and I still need to figure out how to deal with this ... on top of that there is clojurescript where things work differently once more since it does not have a way to address ES6 default exports ... or rather that it is conflicting with that :as does ...#2018-04-0819:43thhellersuper annoying#2018-04-0819:44thhellerworst part is that I can't find any official documentation how all this works in webpack#2018-04-0819:44thhellerproblem is that people expect things to work just like webpack#2018-04-0819:44thhellerbut closure doesn't ...#2018-04-0819:44thhellerhttps://github.com/webpack/webpack/tree/master/examples/harmony-interop this is closest thing to a "spec" i found for this stuff#2018-04-0819:46thhellerunfortunately closure doesn't work like that at all#2018-04-0819:47thhellerI could drop closure entirely for this part but it would be neat if we could use closure for this to get the full DCE experience#2018-04-0819:47thhellertrying to find a reasonable solution for this has been pretty annoying#2018-04-0820:06alex-dixonI thought module.exports.foo = foo <-> export foo <-> module.exports = {foo: foo}#2018-04-0820:07alex-dixonconst {foo} = require(“./foo”) <-> import {foo} from ‘./foo’#2018-04-0820:07thhellernope#2018-04-0820:08thhellerclosure will rewrite a file foo/bar.js with module.exports.foo to module$foo$bar.default.foo#2018-04-0820:09thhellerbut import {foo} from ‘/foo/bar’ would would try to access module$foo$bar.foo#2018-04-0820:09thhellerthe reasoning is that import/export in ES6 are live references which can be updated#2018-04-0820:09thhellerin commonjs they are not#2018-04-0820:10alex-dixonIsn’t it the other way? require is dynamic, import is not. Unless you’re taking about import() which is a proposal that would be for dynamic import#2018-04-0820:11thhellerI mean if you var x = require("foo") with module.exports.foo = 1#2018-04-0820:11thhellerif the module does module.exports.foo = 2#2018-04-0820:11thhelleryour x will still be 1#2018-04-0820:11thhellerin ES6 it will be 2 with export let foo = 1 and later updating that foo#2018-04-0820:12thhelleryes require is dynamic and import is static#2018-04-0820:12thhellerbut thats something different#2018-04-0820:13thhellervery excellent description about the low level stuff https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/#2018-04-0820:14alex-dixonSounds like there’s some of that I don’t appreciate. To me just seems like closure is doing something a 3rd different way. Or 13th different way#2018-04-0820:14thhellernot really#2018-04-0820:15thhellerclosure works perfectly fine when all your code is ES6#2018-04-0820:15thhellerFWIW node still hasn't defined how they are going to do the ES6->CJS interop#2018-04-0820:15alex-dixon> import React, { createElement } from "react" works in webpack but not in closure#2018-04-0820:15thhellerwebpack just did something that sort of works but is hacky is hell#2018-04-0820:15alex-dixonWell yeah but I mean…that’s considered standard where I come from at least#2018-04-0820:15thhellerand totally destroys any possibility of DCE ever working#2018-04-0820:16alex-dixon??#2018-04-0820:17alex-dixonhttps://webpack.js.org/guides/tree-shaking/#2018-04-0820:17thhelleragain .. ES6 only ... doesn't work with commonjs#2018-04-0820:18thhellerthe tree shaking webpack pretends to do is childs play in comparison to what closure is doing#2018-04-0820:18thhellerBUT closure has to be more restrictive in what it can support because of this#2018-04-0820:18thhellerso its just tradeoffs#2018-04-0820:19alex-dixonRight#2018-04-0820:19thhelleragain ... I could completely drop Closure for this and just use babel then it could work more of less like webpack#2018-04-0820:19alex-dixonWas going to ask about that#2018-04-0820:19thhellerbut my ambition was to use closure because of the benefits we get from that#2018-04-0820:20thhellerand for the most part it works reasonably well ..#2018-04-0820:20thhellerits just the commonjs (ie. npm) interop that is icky since their recent change#2018-04-0820:20thhellerI was going to open an issue about this to get their feedback#2018-04-0820:20thhellerthey don't seem to concerned with importing arbitrary commonjs code#2018-04-0820:20alex-dixonYeah. And I figured what the hell…if that’s my only complaint it’s not a valid one. But still, what if Closure was optional for Clojurescript at least?#2018-04-0820:20thhellerit all works perfectly fine when just using ES6#2018-04-0820:21thhellerclosure will never be optional for clojurescript. at least not in any tool I'm writing.#2018-04-0820:21thhellerBUT it can be optional for the JS processing#2018-04-0820:22thhellerclojurescript just gains too much by using closure#2018-04-0820:22thhellerbut the JS world survives fine without it so we can too probably for the JS bits#2018-04-0820:24alex-dixonWhat does it gain? Runtime perf? It seems like shipping with advanced optionmizations is next to impossible if you want to use things from the JS ecosystem and makes debugging impossible. And for what? 100 ms faster initial load on mobile?#2018-04-0820:25thhellerI think npm integration is pretty much a solved problem in shadow-cljs. it just works and I don't have to worry about anything.#2018-04-0820:26thhellerthe local js stuff is where it gets tricky and ONLY because of my ambition of trying to make :advanced work for it#2018-04-0820:26thhellerso yeah blame me for that ... not closure#2018-04-0820:26alex-dixonExactly. Is it really worth the effot?#2018-04-0820:26alex-dixonNo lol#2018-04-0820:27thhellerclosure is only concerned about ES6 interop with Closure JS#2018-04-0820:27thhellerthey never said that npm integration is supposed to work#2018-04-0820:27alex-dixonI’ve been witnessing magic this weekend just going through your examples and making that babel one. It’s ridiculous any of this works#2018-04-0820:28thhellerI'm just a little bit tired of people blaming the Closure Compiler for our issues when its not really their fault#2018-04-0820:29thhellerI'll probably rewrite the local JS interop stuff and just use babel for it like I currently do with ES6 on npm#2018-04-0820:29thhellerthen everything should just work and be totally fine#2018-04-0820:30thhellerits a weird problem to solve since there is no clear "standard" an how any of this is supposed to work#2018-04-0820:30thhellerwebpack did something, babel does something else. still need to check out what parcel does.#2018-04-0820:31thhellerI'm sure its different as well...#2018-04-0820:34thhellerI'm sure things will settle down in closure as well .. they just did a complete rewrite of all of thise in the march release and then again in the april release#2018-04-0820:34alex-dixonWell. Thanks for hearing me out. For the record I think the problem is JS, not Closure. I’m realizing webpack-enabled JS has become standard JS to me and a lot of people#2018-04-0820:34thhelleryeah. would be nice if webpack documented their plans better so others could follow#2018-04-0820:35alex-dixonWhat are your thoughts on shadow-cljs and being able to do things that webpack does like require images, fonts and css?#2018-04-0820:35thhellerdoing it via require is an absolutely disgusting solution. I will never do that.#2018-04-0820:36alex-dixonLol#2018-04-0820:36thhellerI however have plans for a macro based solution#2018-04-0820:36thhelleror maybe ns metadata#2018-04-0820:37thheller(ns my.app {:css/include ["./foo.css"]} ...) or something along those lines#2018-04-0820:38alex-dixonOk. I was half-expecting you to say it’s beyond the scope of the project and that’s what webpack is for#2018-04-0820:38thhellerhell no. I totally want this.#2018-04-0820:38thhellerwe just can do better than require("foo.css") ... thats just horrible#2018-04-0820:39thhellerI do have a solution for scss in my work project#2018-04-0820:39thhellerjust didn't extract it properly for shadow-cljs yet#2018-04-0820:47alex-dixonWould you want the babel example? Can make a PR#2018-04-0820:48thhellerI kinda want to get away from undocumented examples. want examples with proper explanations whats going on.#2018-04-0820:48thhellerwriting those however is pretty time consuming and I didn't find the time yet#2018-04-0820:48alex-dixonAny other examples you might like to have? Was thinking of adding reagent to the babel one to show interop with it#2018-04-0820:52alex-dixonWas also thinking one with deps.edn#2018-04-0820:53thhellerif you don't mind writing a bit of readme to explain the involved parts 🙂#2018-04-0821:00thhellerkinda prefer standalone repos as well ... I started collecting links to guides/examples/templates in the main readme https://github.com/thheller/shadow-cljs/blob/master/README.md#examples#2018-04-0821:00thhellereasier to clone/copy that way#2018-04-0821:03alex-dixonSorry…just opened a bunch of issues with some things that have been on my mind. I liked the examples repo because I could just clone it and then run a bunch of different ones#2018-04-0821:04thhellerits a wonder any of those still work really. haven't updated many of them in a while#2018-04-0821:08thhellerI like issues. things discussed here get lost too easily. gh issues at least sort of stay online.#2018-04-0916:04troglotitHi! How to debug release build of shadow-cljs? Development (watch command) works ok. Maybe I did miss important configurations? “Generating Production Code” chapter doesn’t include anything particular#2018-04-0916:14troglotitThe particular error is React is not defined#2018-04-0916:29thhellerthis does not appear in watch?#2018-04-0916:37troglotityeap, in watch it works fine#2018-04-0916:39thhellerodd. what is your config?#2018-04-0916:44thhellerReact isn't defined by shadow-cljs anywhere unless you are using cljsjs.react#2018-04-0916:44thhellerbut if you use that there is no reason why it wouldn't work outside watch#2018-04-1008:18troglotitbut I’m using fulcro, without cljsjs.react#2018-04-1008:20thhellerdid you try running shadow-cljs release your-app --debug? what is your full stacktrace when you get the React not found error?#2018-04-1008:27troglotitit’s in routing.cljc file of fulcro in DynamicRouter declaration#2018-04-0916:19alex-dixon@troglotit what version of shadow?#2018-04-0916:22troglotit2.2.24#2018-04-0916:28thheller@troglotit shadow-cljs release the-build --debug#2018-04-0922:56briandunnShould shadow-cljs cljs-repl app work with: https://github.com/thheller/shadow-cljs-examples/tree/master/cljs-react-native-app ? I get No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. I have the code loaded and working in the iPhone Simulator via Expo. Is there another step to get the repl connected, or did I break something?#2018-04-1007:13thhellercljs-repl for :npm-module is currently in a weird state. It doesn't really work due to the way the react-native packager works.#2018-04-1007:13thhellerI want to add proper support for React Native but didn't have time to work on it yet. https://github.com/thheller/shadow-cljs/issues/214#2018-04-1012:59briandunnOk. thanks!#2018-04-1000:46tony.kayIs there a setting similar to figwheel’s :figwheel-always?#2018-04-1007:17thhellerI'm sort of against adding this. The only reason I can think of why this would be necessary is "bad" macros which also means their output isn't cacheable at all. For cljs.test I added this hack for my testing stuff. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L783-L811 Basically all it does is call register-test to register the test var at RUNTIME. meaning I can completely bypass all macros to discover new tests at runtime.#2018-04-1007:17thhellerGiven that you already have a spec macro in place would it not make sense to also do this?#2018-04-1007:18thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test.cljs#2018-04-1007:18thhellerthis is basically cljs.test rewritten to work completely without macros#2018-04-1007:19thhellerwhich means all the restrictions that come with the macros go away ... as does the need for :figwheel-always.#2018-04-1007:19thhellerI added some metadata support for configuring live-reload recently. https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2018-04-1007:20thhellerI added :dev/once (or :figwheel-no-load) but didn't add :figwheel-always since I think there are better solutions#2018-04-1007:20thhellerI can add it however if you'd prefer that.
#2018-04-1013:26tony.kayThanks, I appreciate the offer. I’ll look at your improved solution and see if I can make it work with both standard compiler and shadow in fulcro-spec. I agree that a test registry is a good idea. The original intention with fulcro-spec was to base off of the standard testing lib so that I wasn’t reinventing the wheel, just augmenting it with some nicer tires.#2018-04-1013:26tony.kaythanks for the code links#2018-04-1013:28tony.kayYeah, I think you’ve got the right idea…interestingly, I already have a wrapper for “dynamically focusing tests” at runtime which already augments the deftest output to register with that system…so it really should not be a stretch.#2018-04-1104:04tony.kaySo, I imported your code, and ended up with some issues: 1. When you remove a test, there is no clear way to remove it from the registry. The macros actually work fine with that case. 2. The CI test version no longer will run using shadow…the new CI tests are fine with the regular cljs build. Not sure why on that one. I assume it has something to do with your test gathering code? I’m getting pretty tired, so not up to investigating further tonight. 3. Adding a new file is not picked up by hot reload code.#2018-04-1104:06tony.kayOn the plus side: new tests within a namespace are picked up, which was my main complaint. Still, the overall experience isn’t nearly as nice as I have it working with figwheel, though it is true that you have to manually list the nses there.#2018-04-1104:14tony.kayActually, I see why CI broke. You’re using your test hack inside of it. I didn’t understand what you meant…so, in order for this to work right, I think I’d have to change fulcro-spec to depend on shadow-cljs 😕#2018-04-1104:17tony.kayI think we originally misunderstood each other. Fulcro spec emits deftest. My macro is just a thing that makes the reporting prettier for deftest. So, your “hacked” deftest should already be picked up by it without me having to import anything. So, the problems I’m seeing were already present in shadow, it seems.#2018-04-1104:34tony.kayI also noticed that your “run-all-tests” has a different argument order than in cljs.test. I guess that should not matter, but now I’m realizing that perhaps I have to call your runner, which means I don’t end up with a general solution that works for figwheel and shadow.#2018-04-1104:51tony.kayIf you’re at all interested I made a YouTube video (5 mins) that shows you some of the problems I’m seeing, along with how to reproduce them. https://youtu.be/QHc8wTprKHo#2018-04-1105:09tony.kayI'm sure the majority of the problems are the fact that that macro is side-effecting. I only see two ways of fixing that: one is to have an always re-load command for the compiler, and the other is to rewrite the testing library.#2018-04-1105:10tony.kayAnd I don't have time right now for a rewrite:(#2018-04-1106:33thhellerwhat I was suggesting was changing the specification macro to no only emit deftest but also registering the spec at runtime with your fulcro-spec. so basically
(defmacro specification
  "Defines a specification which is translated into a what a deftest macro produces with report hooks for the
   description. Technically outputs a deftest with additional output reporting.
   When *load-tests* is false, the specification is ignored."
  [& args]
  (let [{:keys [name selectors body]} (fss/conform! ::specification args)
        test-name (-> (var-name-from-string name)
                      (with-meta (zipmap selectors (repeat true))))
        prefix (im/if-cljs &env "cljs.test" "clojure.test")]
    `(do (~(symbol prefix "deftest") ~test-name
           (im/when-selected-for ~(fss/conform! ::sel/test-selectors selectors)
             (im/with-reporting {:type :specification :string ~name
                                 :form-meta ~(select-keys (meta &form) [:line])}
               (im/try-report ~name
                 
But I do understand that a rewrite just for the sake of a rewrite is not ideal. I will add support for :figwheel-always.
#2018-04-1106:34thhellerthis macro infection of fulcro-spec is pretty much the same that cljs.test but IMHO there is no good reason to do it this way.#2018-04-1106:35thhellerwhoever wrote fulcro-spec probably looked at cljs.test to see how to do it and just copied the approach.#2018-04-1109:00thhellerfixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d1a2b9b0b5bea6fcb2bdbba291e3ffe3ffe3e8"}, :content ("[email protected]")}. either (ns ^:dev/always some.ns ...) or (ns ^:figwheel-always some.ns ...) works.#2018-04-1109:01thhelleralso tracked down the problem you reported a few days ago with the refactor rename problem. https://github.com/cursive-ide/cursive/issues/1978#2018-04-1109:01thhellerI might just lift the strict name requirement in shadow-cljs then there should be no issue. might just turn it into a proper warning not flat out ignore the file.#2018-04-1113:24tony.kayI see. I agree with your opinion on the macros. The guy I had working on spec was just out of college, so he did pretty well considering. I might have made the same choice at the time.#2018-04-1113:25tony.kayThanks for the addition, it will save me headaches for now.#2018-04-1113:50thhellerjust finished a bit of a refactoring of the fs-watch. new files and deleted files should now be detected better. just finishing up some testing with that, should be released soon.#2018-04-1117:54tony.kaycool#2018-04-1000:48tony.kayrunning tests on hot code reload (as I do when I use Fulcro Spec) needs it…I’m having to re-save my test main every time I add a new test to get it to reload the test runner (and scan for new tests)#2018-04-1000:49tony.kayhttps://github.com/bhauman/lein-figwheel#preventing-and-forcing-file-reloads#2018-04-1002:14lwhortoni was just thinking — because cljsjs and other solutions are pretty tedious (foreign libs, npm-deps, etc), and shadow’s npm support is so good .. should I just use shadow to compile all my third party dependencies and then <script> that bundle onto the page before my lein/some-other-method bundle is loaded?#2018-04-1002:43lwhortonwould that require some sort of “umd” :target that allows me to export namespaces so that a downstream cljs project can simply js/someExportedNS?#2018-04-1002:47justinlee@lwhorton why not just include them in your source code and let shadow handle it?#2018-04-1002:48lwhortonbecause shadowcljs has other hurdles like the repl, which is quite annoying to work with#2018-04-1002:49lwhortoni want the niceities of lein as well as shadow#2018-04-1002:50cmalHi, can I make the app.js to load compiled cljs-runtime from another location other than /js/cljs-runtime? I found there are some var CLOSURE_BASE_PATH = '/js/cljs-runtime/'; in the beginning of the app.js.#2018-04-1002:50justinleeWell first of all, we should figure out how to get you a repl you’re happy with. have you opened up any issues on the things you’d like to see? The problem is that @thheller doesn’t use the repl so I don’t think he’s aware of the issues. He has said repeatedly he actually appreciates it when people open up github issues.#2018-04-1002:51justinleeSecond, doesn’t shadow run in lein mode? I don’t do it myself, but I see lots of people who try to do that#2018-04-1002:51lwhortonthe first big issue is that the repl just dies with any syntax error you input#2018-04-1002:51justinlee@cmal what are you trying to do?#2018-04-1002:51lwhortonso you have to restart it, re-require your namespaces, move into the right namespace, etc.#2018-04-1002:52justinleethat’s weird and you should definitely open a bug#2018-04-1002:52cmalmaybe change var CLOSURE_BASE_PATH = to another location.#2018-04-1002:53justinleeif you just want to put files somewhere else, you can use the :output-dir option#2018-04-1002:54cmalbecause the url is reverse proxied and I want those files to be another location, so the http service can access the actual location(maybe >) of the files, not #2018-04-1002:54justinlee#2018-04-1003:24lwhorton#2018-04-1003:27lwhorton#2018-04-1007:22thheller#2018-04-1007:22thheller#2018-04-1007:23thheller#2018-04-1002:55cmal#2018-04-1002:57justinlee#2018-04-1002:58cmal#2018-04-1007:04thheller#2018-04-1007:06thheller#2018-04-1007:06thheller#2018-04-1007:06cmal#2018-04-1007:07cmal#2018-04-1007:07cmal#2018-04-1007:08thheller#2018-04-1007:08cmal#2018-04-1007:09thheller#2018-04-1007:09cmal#2018-04-1007:10cmal#2018-04-1007:10thheller#2018-04-1007:10thheller#2018-04-1007:10thheller#2018-04-1007:11thheller#2018-04-1007:11cmal#2018-04-1007:11cmal#2018-04-1007:11thheller#2018-04-1007:11thheller#2018-04-1007:11cmal#2018-04-1007:12cmal#2018-04-1007:12cmal#2018-04-1014:36troglotit#2018-04-1016:07troglotit#2018-04-1016:46claudiu#2018-04-1021:29troglotit#2018-04-1014:51claudiu#2018-04-1015:12lwhorton#2018-04-1015:24lwhorton#2018-04-1015:29mitchelkuijpers#2018-04-1015:34lwhorton#2018-04-1015:38thheller#2018-04-1015:39lwhorton#2018-04-1015:39lwhorton#2018-04-1015:40thheller#2018-04-1015:40thheller#2018-04-1015:41thheller#2018-04-1015:41thheller#2018-04-1015:42lwhorton#2018-04-1015:43thheller#2018-04-1015:44thheller#2018-04-1015:51lwhorton#2018-04-1015:52lwhorton#2018-04-1015:52thheller#2018-04-1015:53thheller#2018-04-1015:53lwhorton#2018-04-1015:53lwhorton#2018-04-1015:59thheller#2018-04-1016:17lwhorton#2018-04-1016:20thheller#2018-04-1016:21thheller#2018-04-1016:22thheller#2018-04-1016:23thheller#2018-04-1016:28lwhorton#2018-04-1016:29lwhorton#2018-04-1018:00thheller#2018-04-1018:01thheller#2018-04-1018:01thheller#2018-04-1018:03thheller#2018-04-1018:10justinlee#2018-04-1018:10thheller#2018-04-1018:11thheller#2018-04-1018:11thheller#2018-04-1018:11thheller#2018-04-1018:13thheller#2018-04-1018:15justinlee#2018-04-1018:15justinlee#2018-04-1018:16thheller#2018-04-1018:16thheller#2018-04-1018:17thheller#2018-04-1018:17thheller#2018-04-1018:18thheller#2018-04-1018:18thheller#2018-04-1018:18thheller#2018-04-1018:19thheller#2018-04-1018:19thheller#2018-04-1018:19justinlee#2018-04-1018:21thheller#2018-04-1018:21thheller#2018-04-1018:21thheller#2018-04-1018:22justinlee#2018-04-1018:23thheller#2018-04-1018:23thheller#2018-04-1018:24thheller#2018-04-1018:24thheller#2018-04-1018:24thheller#2018-04-1018:25thheller#2018-04-1018:26thheller#2018-04-1018:28justinlee#2018-04-1018:29thheller#2018-04-1018:30thheller#2018-04-1018:35thheller#2018-04-1018:36thheller#2018-04-1018:59justinlee#2018-04-1018:59justinlee#2018-04-1019:38lwhorton#2018-04-1019:38lwhorton#2018-04-1019:39thheller#2018-04-1019:39lwhorton#2018-04-1019:39thheller#2018-04-1019:40thheller#2018-04-1019:41lwhorton#2018-04-1019:41lwhorton#2018-04-1019:42thheller#2018-04-1019:43thheller#2018-04-1019:43thheller#2018-04-1019:44thheller#2018-04-1019:44thheller#2018-04-1019:44thheller#2018-04-1021:30eoliphant#2018-04-1021:31eoliphant#2018-04-1022:04thheller#2018-04-1022:05eoliphant#2018-04-1022:05thheller#2018-04-1022:12eoliphant#2018-04-1022:13thheller#2018-04-1022:14thheller#2018-04-1022:18eoliphant#2018-04-1022:20thheller#2018-04-1022:22eoliphant#2018-04-1022:25thheller#2018-04-1022:26eoliphant#2018-04-1022:57eoliphant#2018-04-1100:30lwhortonis the push-state built-in support :devtools { :http-handler shadow.http.push-state/handle supposed to handle more than one path? localhost:xxxx/foo still directs to /index.html, and all downstream resources still point to <asset-path>/cljs-runtime/<asset> but localhost:xxxx/foo/bar will direct to /index.html and all downstream will incorrectly(?) point to /foo/<asset-path>/main.js#2018-04-1100:54justinlee@lwhorton if I reload on localhost:xxx/app/doc/6 or whatever it will reload the main bundle for me. is that what you are asking?#2018-04-1101:00lwhortoni get the main bundle reloaded, but in dev mode where everything is spit into js/cljs-runtime files, the asset path is off#2018-04-1101:00lwhortonI can write my own handler to fix it, but i’m not sure if that was the original intent#2018-04-1101:27justinleeso i use it with an spa that uses html5 browser history. so no matter what url you hit, it should return index.html. my code then dispatches to the right page. index.html loads the right stuff at that point. it really shouldn’t matter what url you are at, if i understand correctly#2018-04-1101:32lwhortoni wonder if my asset-path is just misconfigured, then#2018-04-1101:53lwhortonam i going crazy? if I remove :asset-path from my configuration, it looks like main.js is dumped into my :output-dir, but for some reason everything beyond the main.js file gets a js/cljs-runtime attached? if I look at the main.js file itself i see
var CLOSURE_BASE_PATH = '/js/cljs-runtime/';
#2018-04-1102:15lwhortonayup. the issue? <script src="/foo" .../> vs <script src="foo" >#2018-04-1102:15lwhortonapparently breaks the world of html#2018-04-1104:08quanganybody ever try to require aws-sdk? I'm new to shadow-cljs and am getting errors#2018-04-1104:18quanghttps://preview.ibb.co/fJXs2H/67.png#2018-04-1105:47Jonwhat's the code?#2018-04-1105:52quanghey Jon, 1 sec#2018-04-1105:55quangmaybe it has to do with aws-sdk I tried installing a different version, and got a different error#2018-04-1105:56quanguploading repo now...#2018-04-1105:57Jonhave you noticed module/method and module.method are different in shadow-cljs, if module is from npm?#2018-04-1105:57Jonguessing, since it's a common mistake#2018-04-1105:58quanghttps://github.com/quangv/quickstart-browser#2018-04-1105:58quang2 commits, moment.js works fine, but aws-sdk craps out#2018-04-1105:59quang> have you noticed module/method and module.method are different in shadow-cljs, if module is from npm? What is this?#2018-04-1105:59Jonif you put module in (ns ...) to import, you should use module/method to call it.#2018-04-1106:00Jon(ns (:require ["module" :as module]))#2018-04-1106:01Jonif you paste code, we may rule out this case.#2018-04-1106:01Jonhard to find a clue if you don't show the code.#2018-04-1106:02quang
(ns starter.browser
  (:require ["moment" :as moment]
            ["aws-sdk"]))
#2018-04-1106:03Jonthen how do you use code from aws-sdk?#2018-04-1106:03quangI can't, :as, :default also doesn't work#2018-04-1106:04quangmaybe aws-sdk is a monster...#2018-04-1106:04Jonerror thrown?#2018-04-1106:04quangactually, I am trying to use aws-amplify but I can't even get aws-sdk to :require... and I think aws-amplify depends on aws-sdk...#2018-04-1106:05quangyeah error thrown, I just tried a different version of aws-sdk and got a different error...#2018-04-1106:05quangso might just be out of luck#2018-04-1106:05Jonsounds strange..#2018-04-1106:05quangthanks for the sanity check Jon!#2018-04-1106:08quangI couldn't get this working with leiningen either (or at least :foreign-libs, :npm-deps) context here: https://stackoverflow.com/questions/49767358/aws-amplify-with-clojurescript#2018-04-1106:08quangshadow-cljs was my last attempt... it seems like it should work...#2018-04-1107:32thheller@quang I identified the problem. aws-sdk has a weird circular dependency in their code which shadow has trouble with. will see if I can fix that.#2018-04-1109:28javiwhen in cursive I follow the instructions to connect to the cljs repl. all works great, however, i cant access the cljs.repl apis... what am i missing?
Connecting to remote nREPL server...
Clojure 1.9.0
(require '[shadow.cljs.devtools.api :as shadow])
=> nil
(shadow/nrepl-select :b2)
To quit, type: :cljs/quit
=> [:selected :b2]
(require '[cljs.repl :refer [doc source]])
=> nil
(doc map)
=> nil
thanks
#2018-04-1112:22thhellernot sure. will look into it.#2018-04-1113:15javilet me know if i can help somehow#2018-04-1113:55thhellerhehe doh. @fj.abanses the output is printed to the browser console. the browser REPL client just didn't forward that to the REPL itself.#2018-04-1114:01javiyeah! ha ha, i see now 🙂 didnt think of looking there!#2018-04-1115:31quang@thheller Thanks!#2018-04-1115:33thheller@quang should work in 2.2.29. at least the require works. didn't know what/how to test further. let me know if you run into other issues.#2018-04-1115:37quangoh wow Thanks @thheller !! 🙂#2018-04-1115:50quangnice! works with latest version of AWS 🙂#2018-04-1115:56thhellersweet#2018-04-1116:08quangmy next goal was to get aws-amplify required, (steps were 1. moment, 2. aws-sdk 3. aws-amplify) Got a weird Uncaught ReferenceError: Buffer is not defined error, but it might not be related to shadow-cljs https://github.com/aws/aws-amplify/issues/140#2018-04-1116:09quang
(ns starter.browser
  (:require ["moment" :as moment]
            ["aws-amplify"]))
#2018-04-1116:13thheller@quang I probably have a work around for that. will look into it.#2018-04-1116:14thhellerI don't get how anyone can ever say that clojure is slow when yarn add aws-amplify takes Done in 74.61s.#2018-04-1116:19thheller@quang create a
(ns starter.buffer-fix
  (:require ["buffer" :as b]))

(js/goog.exportSymbol "Buffer" b)
and then require this in starter.browser BEFORE aws-amplify
#2018-04-1116:19thhellerthat should fix it#2018-04-1121:44quangThanks @thheller had to use a :refer instead, but fixed worked like a charm! 🙂#2018-04-1116:22quangThanks @thheller!! I had serious contemplation of going back to JavaScript last night... even hired a VA to research javascript-alternatives for me... hah#2018-04-1116:22quanglife saver, thanks man!#2018-04-1116:23thhellerthis is the problem btw: https://github.com/crypto-browserify/createHash/issues/20#2018-04-1116:23thhellerno idea what rn-nodeify is though. can't say if that would fix anything.#2018-04-1116:24quangnice, have to head out atm, but will try it out once I get back. Thanks thheller!#2018-04-1119:35bauerpauerHi there - is there any way to specify different configurations when running shadow-cljs release? I’m using (goog-define api-host ") along w/ :closure-defines in my shadow-cljs.edn to switch config for dev/release, but I feel like I need one more option.#2018-04-1119:36thheller@bauerpauer https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-04-1119:36bauerpauerBut maybe I’m missing something. I could certainly just make a new build altogether.#2018-04-1119:36thheller:release {:closure-defines ...}#2018-04-1119:36bauerpauerYep - I’ve got that goin already @thheller#2018-04-1119:37thhellerwhat else do you have in mind?#2018-04-1119:38bauerpauerWhat I’m up against is wanting to essentially do something like shadow-cljs release API_HOST= and shadow-cljs release API_HOST=#2018-04-1119:39bauerpauerwhen I run shadow-cljs dev, my (goog-define api-host "") works great.#2018-04-1119:39thhellerone option is to use the :closure-defines {foo #shadow/env "API_HOST"} in your config#2018-04-1119:39thhellerbut this has various problems because the env of the server is used when a server is running#2018-04-1119:40thhellerapart from that you can use clj-run to call (shadow.cljs.devtools.api/release* build-config-map)#2018-04-1119:41thheller(shadow.cljs.devtools.api/get-build-config :your-build) loads your build config from shadow-cljs.edn#2018-04-1119:41thhellerits just a map so you can modify it before calling release*#2018-04-1119:42thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-04-1119:43thheller(defn release [api-host] ...) could be called with shadow-cljs clj-run your.build/release #2018-04-1119:43bauerpauerYa, clj-run might be perfect. Thanks, I’ll give it a shot!#2018-04-1119:44bauerpauerSkipping around the manual has bitten me again 😉 One of these days I’ll read it straight through I swear!#2018-04-1120:50jmckitrickIs new?#2018-04-1121:13thheller@jmckitrick no. it has been online a while. @jiyinyiyong made it.#2018-04-1121:14jmckitrick@thheller I must have forgotten about it. Either way, it’s beautiful!#2018-04-1122:54cjmurphyFigwheel comes with its own web server for serving up your html/css/cljs using the information it gets from lein presumably. Does shadow-cljs? I assume not. If I'm right, can anyone recommend a server that does exactly what Figwheel does, except doesn't do its primary job of live code reloading? A web server that can be used with shadow-cljs when you don't really need one of your own.#2018-04-1123:00justinleeyes it does come with one. https://shadow-cljs.github.io/docs/UsersGuide.html#browser-http-server#2018-04-1204:12cjmurphyFrom the intro: "The built-in development server aggressively fixes browser caching issues"#2018-04-1204:19justinleeOh sorry I didn’t read your question properly.#2018-04-1204:20justinleeOr actually now that I’m reading it I don’t get what you are asking. The development server will serve up static assets .#2018-04-1204:50cjmurphyNot asking anything. Just making the point that I probably should have seen that comment right at the beginning of the docs. And excited about the 'aggressively fixing' part. I'll post my 'typical Lein/Figwheel' config once I've got it all working.#2018-04-1200:09pezHello, I want to support shadow-cljs in Calva (a VS Code extension adding Clojure support). I fail in my attempts to figure out how it should be done. Currently with leiningen I use the ls-sessions op of nrepl and try to figure out which session is Clojure and which is Clojurescript. But with the shadow-cljs repl I get back an empty array of sessions.#2018-04-1200:16pezMeaning I can’t even get Calva to connect to the shadow-cljs repl to find out what else might not be working. (Although possibly things should be working beyond that point since I use cider nrepl.)#2018-04-1204:51cjmurphyWhat should I do in response to this message: "WARNING: can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs."?#2018-04-1206:09cjmurphyI had a great idea. I did exactly what the instruction said and it fixed the warning. I guess if it had said 'please type: npm install --save-dev shadow-cljs' the message would have been clearer, to me anyway!#2018-04-1207:40thheller@cjmurphy you should npm install --save-dev shadow-cljs. might need to do npm init -y first if you don't have a package.json yet.#2018-04-1207:41cjmurphyThe command worked fine. I just got confused by 'install install' - I suggested a different word, so it is like 'type install...'.#2018-04-1207:42thheller@pez cider-nrepl should just work yet. weird that ls-sessions doesn't return anything since that is handled by the default session middleware. I'll see if I'm supposed to set anything.#2018-04-1207:43thhellerif you support the track-state middleware from cider however you should get a :repl-type message after each eval#2018-04-1207:43thhellerwhich is either clj or cljs.#2018-04-1207:45thhellerI see that you are looking for .nrepl-port. shadow-cljs writes this only when lein is not using it. might consider looking at .shadow-cljs/nrepl.port as well.#2018-04-1207:53thheller@cjmurphy fixed#2018-04-1208:21thheller@pez did a quick test. I think ls-sessions is empty because there are no default sessions. you'd first need to clone to create your own#2018-04-1210:16pezThanks @thheller. I thought thought the recursion should pick up shadow's nrepl port-file, but I was tired, I see now that it is named entirely differently.#2018-04-1210:17pezBut that wasn't the problem for me. What does clone imply? I will look at the track-state middleware, the way I do it today is really hackish.#2018-04-1211:33thheller@pez to be honest I don't know either about clone. Its just what cider or lein repl :connect do when connecting. that creates a session. in case of lein repl there sessions because lein repl consists of the part that starts the server and the one that connects. nrepl-middleware is mostly a mystery to me.#2018-04-1211:39pez@thheller I'll have a look. I only need to unlock enough about the mystery to get this working. 😃 Still, with lein projects I don't have to do any cloning, the sessions vector is populated anyway.#2018-04-1211:40thhellerwell but you are hi-jacking another session to do your work which certainly is not the intended way to do things 🙂#2018-04-1211:44pezI blame the original author for that. 😃 And will take your advice here to try be a better REPL citizen going forward.#2018-04-1211:45pezI couldn't get it working trying to use :lein true yesterday btw, so don't know if it behaves differently then. Will give it another try tonight.#2018-04-1211:45pez(By "it”, I mean shadow-cljs.)#2018-04-1211:46thhellerideally don't use lein, the point of shadow-cljs is to not rely on lein 🙂#2018-04-1211:46pezYes, I don't want to have to tell my users to use lein for this.#2018-04-1211:48pezAnother thing. Unrelated to Calva. My test project has a dependency that shadow-cljs says it can't inspect and thus it can't be used. Is there somewhere I can read up about such issues?#2018-04-1211:50thhellerwhich file fails to inspect?#2018-04-1211:50pezLet me check…#2018-04-1211:54pezIt's ysera:
[2018-04-12 09:08:24 - WARNING] failed to inspect resource "jar:file:/Users/pez/.m2/repository/ysera/ysera/1.1.0/ysera-1.1.0.jar!/ysera/state.cljc", it will not be available.
#2018-04-1211:57thhellerhmm that file doesn't seem to exist anymore? https://github.com/tomas81508/ysera#2018-04-1211:58thhellerbut anyways this is not an issue unless you are actually trying to use ysera.state from CLJS#2018-04-1211:59thhellerI should probably just remove the warning as most of the time this is not a problem at all#2018-04-1211:59pez@ekholm.tomas knows more about ysera. The test project I am using uses some ysera test methods (is= and such.#2018-04-1211:59thhellershadow-cljs just indexes the classpath on startup and sometimes people use .cljc files although they only work in clojure#2018-04-1212:02thhellerin this case the ysera/state.cljc is empty. meaning it has no ns form, meaning "it will not be available" at runtime#2018-04-1212:04pezAh, thanks.#2018-04-1212:04sonnytohow do I specify what version of clojurescript?#2018-04-1212:04sonnytoin the :depenency?#2018-04-1212:05thheller@sonnyto currently not really possible due to an incompatibility with certain closure-compiler versions#2018-04-1212:05sonnytolooked at sammple projects and version of cljs are not used#2018-04-1212:05sonnytooh#2018-04-1212:05sonnytoso what version is being used?#2018-04-1212:05thheller1.10.238#2018-04-1212:05sonnytocool#2018-04-1212:08thhellershadow-cljs always ships a "default" CLJS version which will pretty much always be the latest one available at release time#2018-04-1212:35thhellerthat is not code which was produced by shadow-cljs doing that?#2018-04-1212:36cjmurphyIt seems like devcards is not independent of figwheel, so wants to talk to figwheel. So nothing that can be done then.#2018-04-1212:36cjmurphyHowever all will be working, so message can be ignored.
#2018-04-1212:36thhellerno I think you just have old code loaded#2018-04-1212:37thhellershadow-cljs NEVER uses ?rel=1523416697167. so whatever code you have loaded is not the one produced by shadow-cljs#2018-04-1212:37thhellersome people are using devcards just fine. nothing in there requires you to use figwheel.#2018-04-1212:49cjmurphyMessage is not coming from shadow, and can't be coming from figwheel as now gone. My theory is that it is coming from devcards. I must need to tell devcards not to keep communicating with figwheel. Just don't know how to do that yet.#2018-04-1212:50thhellermy guess would be that you have some old generated code lying around somewhere that you are loading#2018-04-1212:51thhelleryou are not loading the correct code so whatever you are telling anything is not going to have any effect at all#2018-04-1212:51cjmurphyWell I can manually remove everything (clean) under public/resources/js and that should tell.#2018-04-1214:31pez@ekholm.tomas, I think you should bump the version of ysera. Version 1.2.0 seems to have an empty state.cljc file that shadow-cljs then complains about not being able to analyze. Checking the repo it seems like the file is removed in master. Not that ysera starts working in shadow-cljs just because of this, but at least one complaint less.#2018-04-1215:42lwhortonis anyone able to get reagent to work with shadow-cljs providing the react dep? for some reason I keep getting js/React not defined inside of reagent.impl#2018-04-1215:51thheller@lwhorton which version of reagent? Given that most examples use reagent I think its fair to assume that it works. https://github.com/thheller/shadow-cljs#examples#2018-04-1215:52thhelleroh do you maybe have an empty cljsjs/react.cljs file in your project?#2018-04-1215:53lwhortonyea i was following that nice example. i’m just not sure if I need to provide the “missing” namespaces of cljsjs/react/dom/server etc.#2018-04-1215:53lwhortonare you suggesting that by providing those namespaces I’m breaking reagent?#2018-04-1215:56thhelleryou don't need those with shadow-cljs. in fact if you have them it might break things.#2018-04-1215:56thhellercause thats where the js/React is coming from#2018-04-1215:57lwhortonarg, i hate having this giant chunk missing from my domain knowledge about packages#2018-04-1215:58thhellerso do you have cljsjs files in your project?#2018-04-1215:58lwhortonI do as a consequence of previously using lein (and it being required there)#2018-04-1215:59thhellerphew that is good to know.#2018-04-1215:59thhellerFWIW https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-04-1216:00lwhorton👍#2018-04-1216:03thhellerI lied above. shadow-cljs does actually need the cljsjs files but it provides a bunch of them already. https://github.com/thheller/shadow-cljsjs#2018-04-1216:03lwhortonis that shadow-cljsjs lib auto-included as part of shadow?#2018-04-1216:03thhellerthe problem is just that they are usually blank namespace declarations.#2018-04-1216:03thhelleryes shadow-cljs depends on shadow-cljsjs#2018-04-1216:03lwhortonok#2018-04-1216:04thhellerfor the most part you can just ignore it#2018-04-1216:05lwhortonso what I’m bumping into is something like React is not defined and if I pull apart the compiled source I see a bunch of cljs.core.apply.cljs$core$IFn$_invoke$arity$4(React.createElement, so some lib I’m using depends on window.React it seems#2018-04-1216:05thhelleryes. this is what https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs provides#2018-04-1216:05lwhortonand I’m not sure how best to solve it. if you’re already doing goog.set window React react#2018-04-1216:05thhellerbut if you had some yourself you probably had an empty (ns cljsjs.react) that just did nothing#2018-04-1216:06lwhortonyea I did have an empty cljsjs that did nothing (and then I tried manually requiring react and doing my own oset! ...)#2018-04-1216:06lwhortonwhich is what you’re already doing#2018-04-1216:06thhelleryeah but if you have a cljsjs.react in your project that effectively overrides the one in shadow-cljsjs#2018-04-1216:07lwhortonand I just wonder if it’s some sort of dependency loading order, or if in my boot.core file I have to manually require ["react"] just to ensure it’s there before some other lib tries to invoke it*#2018-04-1216:07thhellerwhat is the problem now? if you just remove the cljsjs files everything should work ok?#2018-04-1216:08thhellerit should not require any work on your part at all. reagent just works without you doing anything.#2018-04-1216:08lwhortonyea, i think the reagent part is working now (no more issues with reagent.impl js/React is not defined)#2018-04-1216:09lwhortonexcept there’s another macro-based lib I’m using that also uses js/React#2018-04-1216:09thhellerthat doesn't require either "react" or cljsjs.react? then yes that may lead to load order issues#2018-04-1216:09lwhortonso it seems to just assume the window already has React somewhere… https://github.com/roman01la/cljss/blob/master/src/cljss/reagent.clj#2018-04-1216:10lwhortonand it looks like the project.clj doesn’t list cljsjs.react or any react, lol.#2018-04-1216:10thhelleryep. you can probably fix that by requiring reagent before requiring cljss.reagent#2018-04-1216:11lwhortonah because reagent pulls in a dep to cljsjs which shadow will see and export js/React#2018-04-1216:11thhelleryep#2018-04-1216:12lwhortonwhy are you so helpful? how do you have this much time 😛#2018-04-1216:14thhellerhehe#2018-04-1216:15thhellerspeaking about time. I'll be back later 😉#2018-04-1217:21lwhortonoh man — what is this? i’ve never seen this before
`[2018-04-12 13:19:47 - WARNING] provide conflict for #{authentication.views} provided by compiled/authentication/views.js and {"/authentication/views.cljs" #{authentication.views}}
#2018-04-1218:46denik@thheller the changes from https://github.com/thheller/shadow-cljs/commit/9b8f289cdc34f468a242e05494da08a6aea3bb36 don’t seem to work for me I’ve tested by redefing routes and using the same code you use to see if the var’s value changed
(do (require (symbol (namespace `router-component)))
     ((find-var `router-component) {:uri "/abc"})) <- this works after redefing
but shadow-cljs’ server remains stuck on the initial value until I restart the whole instance.
#2018-04-1220:05thheller@lwhorton it appears that you :output-dir is on the classpath. that is not a good idea.#2018-04-1220:06thheller@denik I don't unterstand what that code does? it requires its own namespace?#2018-04-1223:23denik@thheller yes using the code you use to load the var of the handler#2018-04-1223:23denikAfter redefining the handler itself#2018-04-1223:24denikIt just happens to be in the same na but that shouldn’t matter if it’s properly required elsewhere#2018-04-1308:27thhellerok .. seriously ... how can anyone say that clojure is slow ... doing a bit of work with react-native and expo and both are WAAAAAAAAAAAAAAY slower than shadow-cljs. especially when adding the ridiculous amount of time yarn add takes.#2018-04-1308:28thheller@denik how are you reloading the code for the handler?#2018-04-1308:47pezI have a situation where I can build and watch my app and it works in the browser, but can't connect a cljs-repl. It says this when I try to execute something from the prompt:
$ shadow-cljs cljs-repl app
shadow-cljs - config: …shadow-cljs.edn version: 2.2.29
shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 1 2)
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
What am I not understanding?
#2018-04-1308:48thhellerdo you have the app opened in the browser?#2018-04-1308:54pezI have my app opened in the browser, yes. (Not the UI, if that is what you mean.)#2018-04-1308:57thhellerUI?#2018-04-1308:57thhellerwhat does the browser say? it should say something like shadow-cljs REPL connected in the console when you load the page#2018-04-1308:59pezThe server UI.#2018-04-1309:01pezI don't get that message in the console. I get something about some custom cljs devtools formatters not being rendered and then the result of evaluating my app file (a clojure map).#2018-04-1309:07thhellerI'm confused#2018-04-1309:07thhelleryou are running shadow-cljs watch app. you open whatever that produces in the browser?#2018-04-1309:08thhellerthe formatters message is probably from cljs-devtools#2018-04-1309:09thhellerwhat is your build config?#2018-04-1309:13pezI am sorry I am sharing my confusion. But you have the scenario right. Here's my build config:#2018-04-1309:14pez
:builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules {:game-of-life {:entries [game-of-life.main]}}
                :devtools {:after-load app.main/render!
                           :http-root "resources/public"
                           :http-port 8080}}}
#2018-04-1309:14pez(It's a simple figwheel project that I am trying with.)#2018-04-1309:15thhellerand you have loaded in your browser?#2018-04-1309:16thhellerit should definitely say something about the REPL connecting#2018-04-1309:17pezMy index.html file looks like this:
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="https://clojurescript.org/images/cljs-logo-icon-32.png">
  </head>
  <body>
    <div id="app">
      <h2>Static HTML from index.html</h2>
    </div>
    <script src="js/compiled/game_of_life.js" type="text/javascript"></script>
  </body>
</html>
#2018-04-1309:18thhellerpretty sure thats loading the wrong file?#2018-04-1309:19thhellerat least I dont remember changing - to _ for the output files?#2018-04-1309:19thhellercan you check if both exist? maybe from a previous fighwheel compile#2018-04-1309:19thhellerjust wipe resources/public/js/compiled to be safe#2018-04-1309:20pezI'll check.#2018-04-1309:21pezYeah, both exist. Thanks!#2018-04-1309:24pezThat explains why the app worked even though shadow-clj said there were compilation errors. 😃 I'll fix and then I might have a Calva version that can handle shadow-cljs projects.#2018-04-1309:24thhellercool!#2018-04-1309:33pezHmmm, now the cljs repl starts and everything with that is dandy. But Calva still only finds the clj repl, so some more work is needed. But there's a whole weekend ahead to get it done! 😃#2018-04-1309:34thhellerby default there only is the clj-repl#2018-04-1309:34pezMany thanks for your level of service, @thheller!#2018-04-1309:34thhelleryou call (shadow.cljs.devtools.api/nrepl-select :app) to switch the current session over to cljs#2018-04-1309:35thheller:cljs/quit will drop that session down to CLJ#2018-04-1309:35pezAh, but if I make two clones, maybe I can have both session types? It's a feature of Calva that it is easy to have both connected.#2018-04-1309:38thhelleryes, clone lets you do that#2018-04-1309:40pezAnother question, yesterday you said something about people using cljc files even though they only work in Clojure. What did you mean by that? Or if I misunderstood things completely.#2018-04-1309:41thhellersay you have a src/my/app.cljc (ns my.app) (js/console.log "foo")#2018-04-1309:41thhellerthis will compile fine with CLJS#2018-04-1309:41thhellerbut if you try to (require 'my.app) in a Clojure REPL it will blow up#2018-04-1309:42thhellersince CLJ does not understand the js/console.log#2018-04-1309:42thhellersame is true the other way. you can do clojure things that CLJS doesn't support#2018-04-1309:42pezIsn't that what conditional readers are for?#2018-04-1309:42thheller(ns my.app (:require []))#2018-04-1309:42thhelleryes they are.#2018-04-1309:43thhellerBUT not everyone that uses .cljc files actually makes sure that they work in both platforms#2018-04-1309:45pezI see. That is partly why I want Calva to keep both repls available. So that it is easy to switch between them and try make sure they work in both worlds. It has been quite a bother to get tests working in cljs, so we write most of our stuff in cljc.#2018-04-1309:46thhelleryeah I tend to test more in CLJ as well. cljs.test is horrible to use, too many macros.#2018-04-1309:51pezAbout clone now. With lein+figwheel I an ls-sessions and get a vector of sessions w/o cloning. But with shadow-cljs I must first clone to populate the vector. What I would think makes most sense is that the vector is populated to begin with, then I clone sessions that Calva can connect to.#2018-04-1309:51pezIt seems a bit strange to just clone nothing and magically there appears sessions.#2018-04-1309:52thhellerbut thats how sessions are created#2018-04-1309:52thhellerwith lein repl what you are cloning is the repl-y session which may already have put stuff in the session you don't actually need#2018-04-1309:52thhellerso cloning from nothing seems to be safer actually#2018-04-1309:53thhellerdon't use lein repl as a baseline IMHO#2018-04-1309:53thhellerbecause clj won't have that either#2018-04-1309:54thhellerat least I think that is what happening#2018-04-1309:54thhellerfigwheel doesn't actually create any sessions since only nrepl clients can do that#2018-04-1309:59pezI hear you. Is there a way I can now that I am connected to a shadow-cljs clj repl?#2018-04-1310:00thhellernot really unfortunately#2018-04-1310:00thhellernrepl doesn't exactly make it easy to give you extra information#2018-04-1310:01thhellerI could add a new nrepl op? so you send {:op "shadow-cljs/hello"} or so. shadow-cljs could reply with something while others will just reply with an error#2018-04-1310:03pezThat would work for me. Better than first testing (shadow.cljs.devtools.api/nrepl-select :app) and see if that works. I might start out with jsut letting the user manualy select what kind of session to connect to.#2018-04-1310:31troglotitIs it expected that Ctrl-C on shadow-cljs watch app sometimes leaves server running, so next time shadow-cljs watch app doesn’t do anything?#2018-04-1310:34thhellerdepends on what you mean by server. https://shadow-cljs.github.io/docs/UsersGuide.html#server-mode#2018-04-1310:34thhellerthe server instance can be shared, so if you run multiple shadow-cljs watch only one server will be used#2018-04-1310:34thhellerthe watch however should be stopped by the watch process that created it#2018-04-1310:35thhelleryou run use shadow-cljs clj-repl (shadow/stop-worker :app) to stop it if its "stuck"#2018-04-1310:53mjmeintjesHi. I'm trying to get shadow-cljs to spit out a javascript file that is usable for a service worker. I'm re-using the :web-worker true setting inside shadow-cljs.edn. However, I'm getting the following problem: ReferenceError: document is not defined (`at hud.cljs:47`) when running the service worker. If this is a bug I'm happy to open a Github issue, just wanted to check that I'm not just doing something stupid.#2018-04-1310:54thheller:web-worker in a module has a very distinct meaning. it is not suitable for making standalone webworkers or serviceworkers. that should be individual :target configs#2018-04-1310:55thhellerI'll get back to you later. need to eat something first.#2018-04-1310:55mjmeintjesNo rush, thanks. I've got it going in pure js for now in any case.#2018-04-1311:00thhellerI dont think CLJS is a good fit for service workers to be honest#2018-04-1311:00thhellerdidn't do much with those yet but I think a dedicated framework like https://developers.google.com/web/tools/workbox/ seems to be better#2018-04-1311:02mjmeintjesYeah, that's exactly the library that I'm using now. Was thinking about moving it into clojurescript, but in retrospect you are probably right about just leaving in javascript. The only thing that I was thinking is about using macros to automatically get the list of files to pre-cache from manifest.edn and filesystem (instead of having to run the cli tool), but that is probably just going to overcomplicate things.#2018-04-1311:02thhelleryeah things could definitely be more declarative from the looks of it#2018-04-1311:02thhelleranyways .. brb#2018-04-1311:40thheller@mjmeintjes I'm currently finishing up a target for react-native. will create simplified ones for worker after that, then we can properly evaluate whether it makes sense to use cljs for service workers#2018-04-1311:44mjmeintjesSounds great, thanks.#2018-04-1313:03denikhttps://clojurians.slack.com/archives/C6N245JGG/p1523608108000180 @thheller initially I was using mount but I also tried a simple fn, saved the file and loaded it in the repl. Should that work?#2018-04-1313:04thhellerI mean HOW are you actually reloading the code#2018-04-1313:04thhellerload-file or require or tools.namespace?#2018-04-1313:05denikload-file#2018-04-1313:05thhellerand what is the var? (defn foo [...])?#2018-04-1313:05thhellerI tested it in my REPL and it definitely works#2018-04-1313:05denikYes#2018-04-1313:05denikHuh with shadowcljs embedded?#2018-04-1313:06thheller(defn foo [req] {:status 200 :body "hello world"})#2018-04-1313:06thhellerwhen I change the :body, load-file and reload the browser I see the updated version#2018-04-1313:08denikHmm, tried that yesterday (several times) and it didn’t work for me. I’ll dig in. Thanks for the sanity check. #2018-04-1313:41thheller@denik oops. it is actually broken.#2018-04-1313:42thhellerI tested by modifying the default handler which obviously works#2018-04-1314:16denikdid you pass in the default handler’s var as a symbol to http-handler?#2018-04-1316:32thhellerI tested by passing :http-handler dev.http/handle but the ns was demo.http/handle so I got a NullPointerException`. I added a warning for that.#2018-04-1316:32thhellerotherwise it works just fine#2018-04-1320:52denik@thheller do you have a gist you can share? Is dev.http/handle the full ns or an alias? I’m wondering what I’m doing wrong. Also since I’m using shadow-cljs embedded, is there a way to pass the config in dynamically instead of through shadow-cljs.edn? I’m asking because the library I’m working on (releasing soon) is generating the shadow-config for the user and currently does some ugly macro magic to pretend that there is config when there is none. I wonder if that has anything to do with it.#2018-04-1320:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/repl/demo/http.clj#2018-04-1320:54thhellerwhat does a macro have to do with a shadow-cljs config?#2018-04-1320:55thhellershadow-cljs watch app basically calls (shadow.cljs.devtools.api/watch :app) which calls (shadow.cljs.devtools.api/watch* the-config-map {})#2018-04-1320:59denik@thheller does watch start it’s own server? I’m currently calling this
(with-shadow-config
   (shadow-config config)
   (shadow-server/start!)
   (shadow-api/watch :app))
#2018-04-1321:00denikoh shadow-server/start! takes a config#2018-04-1321:01denik@thheller I don’t see a shadow.cljs.devtools.api/watch*#2018-04-1321:08thhelleryeah sorry. I meant get-or-start-worker. just take a look at https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/api.clj should be easy to follow#2018-04-1321:09thhellerand no I do not recommend bypassing the config completely. that is not a supported use case since its waaaaaaaaaaaaaaaaaaaay too much work to account for that.#2018-04-1321:09thhellerand you lose a bunch of features by doing that anyways#2018-04-1321:10thhellerI'm curious to see what you are trying to build though#2018-04-1323:20denikThank you. The user can literally pass a regular shadow-cljs config (that is contained in a larger config) so they can still modify shadow-cljs at will but I merge defaults (that can be overridden) and therefore it’s important for me to be able to pass it dynamically.#2018-04-1401:38denik@thheller something must have been off with lein-checkouts - was still running version 2.2.23 😕 this is absolutely not your fault. However to avoid this in the future, have you thought about printing the shadow-cljs version as the server is started (like in the command line)?#2018-04-1407:35thhellerseems like a good idea yeah#2018-04-1313:44thhellerwait no .. it works.#2018-04-1313:45thhellerused the wrong ns ... adding a warning for that 😛#2018-04-1314:04denikSorry I’m not sure I understand, add a warning for what?#2018-04-1315:48bruHello #shadow-cljs, I’m having a lot of fun with this tool. However, I’m a bit stuck while trying to create a macro on a project with browser target. Is that supported?#2018-04-1315:50lwhortonwhat issue are you running into? i dont think shadow (or any build tool) affects the way your code is compiled wrt macros#2018-04-1315:52lwhortonyou certainly want to ensure any .clj files are still in your source-paths (its a common theme for people to do a /src/clj and /src/cljs#2018-04-1315:52bru@lwhorton at the moment I’m trying just to do something naive like spitting out some hiccup, I just copy/pasted the example from here: https://github.com/thheller/shadow-cljs-examples/tree/master/macros#2018-04-1315:52brubut even that doesn’t compile if I set target to browser#2018-04-1315:53bruwe’re talking about:
(defmacro h1 [props & children]
  `[:h1 ~props 
#2018-04-1315:54lwhortonhow are you running that example proj?#2018-04-1315:55bru@lwhorton shadow-cljs watch app (app is my build name)#2018-04-1315:55bruit’s much bigger than that, I just never needed a macro so far#2018-04-1315:55bruhm. I can try creating a skeleton app in fact#2018-04-1315:56lwhortoni have a strong sense that you have some other configuration issue… i’ve never had issues with macros so long as you write them in a .clj file, and include them in a cljs file#2018-04-1315:56lwhortonremember that as of 1.7? cljs automatically refer’s macros if both clj and cljs share a name#2018-04-1315:57bru@lwhorton good to know, I’ll definitely start with the skeleton app then#2018-04-1316:33thheller@bru what doesn't work? what error do you get?#2018-04-1316:33bruHi @thheller! I was getting two failing specs at compile time, hang on…#2018-04-1316:35bru@thheller :
Call to clojure.core/defn did not conform to spec
-- Syntax error -------------------

  (... [{:keys (attrs)} ...] ...)
        ^^^^^^^^^^^^^^^

has extra input
and
-- Spec failed --------------------

  (... [{:keys (attrs)} ...] ...)
        ^^^^^^^^^^^^^^^

should satisfy

  vector?
#2018-04-1316:35thhellerI guess it expects {:keys [attrs]}?#2018-04-1316:36thhellerthats clojure complaining about your code#2018-04-1316:38bruright, but the only addition was really the defmacro… let me try to remove it again, one sec#2018-04-1316:42bru@thheller confirmed, as soon as I remove this code, it compiles again:
(defmacro h1 [props & children]
   `[:h1 ~props 
#2018-04-1316:44bru@thheller hang on, I re-added without the @ and it compiled, it might have been just that#2018-04-1316:44thhellerthat compiles fine and is not the cause#2018-04-1316:45thhelleris this a .cljc file?#2018-04-1316:46brunope, a .clj at the moment, then I have a .cljs that require-macroes it, I’m copying the example from https://github.com/thheller/shadow-cljs-examples/blob/master/macros#2018-04-1316:47brubut I’m trying to make it work for a browser target rather than node#2018-04-1316:47thhellertarget is irrelevant for macros#2018-04-1316:47brucool, that was my expectations, glad I was right in that 🙂#2018-04-1316:47thhellerjust grep for {:keys (attrs)}. should be somewhere in your code#2018-04-1316:48thhellerOR you have another macro that emits this#2018-04-1316:48thhellerthe h1 is not the cause#2018-04-1316:49brunah that was the first macro I attempted to add to this project. But it might be in some of the dependencies… checking now#2018-04-1316:49bruand thanks for the support!#2018-04-1316:52bruand bingo! I was requiring tagsoup in that namespace, and that seems to be the root cause of the error.#2018-04-1316:52bruI suppose I’ll need a different parser#2018-04-1316:54thhellerhttps://github.com/nathell/clj-tagsoup/issues/18#2018-04-1316:54thheller> Thanks for reporting this, I'll be fixing it in a few days.#2018-04-1316:54thhellerfamous last words in OSS 😉#2018-04-1316:55thhellerdidn't the error tell you that it was that namespace? it should have. if not thats a bug.#2018-04-1316:57brufair point, let me check#2018-04-1316:59bruright, indeed it does, although too deep in the stacktrace for me to notice. it’s much easier now knowing what to look for 🙂#2018-04-1317:01thhellerfeel free to open a ticket with the tagsoup example. should be easy to reproduce when I find some time. the ns causing the problem should be the first thing you see not the last.#2018-04-1317:01thhellerwill see I can make that work#2018-04-1317:03bruawesome, thanks! Excellent work anyway, I’m really enjoying shadow-cljs#2018-04-1317:58Alex Hwas wondering - is there a way to see a breakdown of the final bundle size?#2018-04-1317:58Alex Has in, which module/file/whatever is contributing what in terms of size?#2018-04-1318:38lwhortonis there something fancy I should do to make sure my nrepl connection can attach to a shadow-cljs watch :id? i’m using vim-fireplace and I can’t seem to make a connectino#2018-04-1318:39thheller@alex340 https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9?u=thheller#2018-04-1318:39lwhortoni’ve tried using manual :Connect host/port/blah (vim), and also from a shadow-cljs cljs-repl using the api/nrepl-select :id .. but in the first case I get some unhelpful compilation error. in the second case I get cannot read prop 'nrepl_select' of undefined.#2018-04-1318:40lwhortondo i have to start a watcher, then a cljs-repl, then connect my browser, then connect to my nrepl?#2018-04-1318:40thhelleronly need to start the watch, then connect nrepl, then (shadow.cljs.devtools.api/nrepl-select :id)#2018-04-1318:40thhellercan't guarantee that the shadow alias exists#2018-04-1318:42lwhortonmust be some vim-fireplace issue i’m having. the watcher runs fine, an .nrepl-port file is spit out, and i can even connect a shadow cljs-repl#2018-04-1318:42thhellerI have zero clue what vim-fireplace does so I can't help there#2018-04-1318:42lwhortonme too 🙂#2018-04-1318:44lwhortoni don’t see this in the docs anywhere — but does shadow support a local-only profile kind of like leins ~/.lein/profiles.clj?#2018-04-1318:45thheller~/.shadow-cljs/config.edn is merged into the main config yes.#2018-04-1318:45lwhortonsweet#2018-04-1318:45lwhortonand now i can find it in the docs ><#2018-04-1318:47thhellerdont think I added it there yet#2018-04-1318:48lwhorton> You can either configure this in your shadow-cljs.edn config for the project or globally in your home directory under ~/.shadow-cljs/config.edn. its nesteld in there, but could probably use its own sub-section#2018-04-1320:25lwhortonso .. after much ado (digging through python, nvim support, pip, pyenv, pyvirtualenv) i’ve learned that from my root file /app/ I can invoke :Eval (+ 1 2) and the nrepl will return 3.#2018-04-1320:26lwhortonif I go into /app/src/some-mod.cljs and attempt to Eval it will always give me a compiler error in the output#2018-04-1320:30lwhortonit looks like that’s because I can actually eval any code that’s in a .clj file, but not cljs. which I suppose makes sense. I have to “start” the cljs environment via (cemeric.piggieback/cljs-repl :id), except when I do that I always get [:no-worker :main]#2018-04-1320:40thhellerthat means the watch is not running#2018-04-1320:43lwhortonhmm-- so i’m invoking clj-run build/dev where my builder does some stuff and ultimately defers to shadow/watch build-cfg opts#2018-04-1320:44lwhortonso unless there’s something else happening when I use shadow-cljs watch id, i think it’s running?#2018-04-1320:46thhellerI'm a bit confused. You say (cemeric.piggieback/cljs-repl :id) which would return [:no-worker :id] not [:no-worker :main]#2018-04-1320:46thhellerso I'm guessing there might be some id mixup?#2018-04-1320:47lwhortonsorry, i kept trying cemeric but also the shadow-provided api, I’m not sure if they returned different things let me check#2018-04-1320:47lwhortonbut it would be :main which is my module, i just used :id to confuse you#2018-04-1320:48thhellerthings would be easier to follow if you just run shadow-cljs server#2018-04-1320:48thhellerconnect to that#2018-04-1320:49thhellerrun (shadow.cljs.devtools.api/watch :main) and then I think :Piggieback :main?#2018-04-1320:49thhellerleave the custom stuff out of it until that works. impossible for me to tell what you are doing otherwise#2018-04-1320:53lwhortonill keep churning#2018-04-1320:57lwhortoninteresting#2018-04-1320:58lwhortonseparate shadow-cljs server, then connect to the nrepl, then run /watch :main spits back “no build with id :main”-- and here’s my config
:nrepl {:port 8001}
 :builds {:app
          {:modules {:main {:entries [boot.core]}}
 ...
#2018-04-1320:58thhelleryes beacuse the build id is :app#2018-04-1320:58lwhortonoh dangit#2018-04-1321:04lwhortonok, so now that i’m not being dumb — it spits back :watching. if from another buffer (cljs); i load the browser to connect to the js environment; I :Eval (shadow/nrepl-select :app); now i can eval in my cljs buffer#2018-04-1321:05lwhortoni know there was a release earlier that made the api/watch <id> automatically start a server, right? is there something different about that server versus starting it at the command line shadow-cljs server i wonder?#2018-04-1321:06thhelleryou mean clj-run?#2018-04-1321:06thhellershadow-cljs watch app starts a server if it isn't running yes#2018-04-1321:07lwhortonyes, sorry - my brain is all over the place today. i wonder if using clj-run to start a task that eventually calls shadow/watch config opts initializes a server differently#2018-04-1321:10thhellerif you are calling a function via clj-run that wants to call watch you have to do this: https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run#2018-04-1321:11thheller{:shadow/requires-server true} this is the important bit#2018-04-1321:14lwhortoni picked up on that a little bit ago while combing through the docs:
(defn dev
  {:shadow/requires-server true}
  [& args]
  (let [c (config/get-build! :app)
        build (merge c dev-cfg)]
    (move-index (:index-in build) (:index-out build))
    (shadow/watch build {:verbose true})))
#2018-04-1321:15lwhortonso that’s my shadow-cljs clj-run build/dev invocation#2018-04-1321:15thhellerwatch only takes a keyword id, not the actual config#2018-04-1321:16thhellerwhat is dev-cfg?#2018-04-1321:17lwhortonjust a out-of-scope map that defines some configurations#2018-04-1321:17lwhorton
(def cfg {:index-in "resources/index.html"
          :index-out "public/index.html"
          :manifest "public/js/compiled/manifest.edn"})

(def dev-cfg (merge cfg {:compiler-options {:closure-defines {'build-tools.constants/graphql-uri (or (System/getenv "GRAPHQL_URI")
#2018-04-1321:17thhellerand why is that not part of the config in the first place?#2018-04-1321:17thhellerah env#2018-04-1321:17lwhortonbecause I needed dynamic access to env vars#2018-04-1321:18thhellerwouldn't it be easier to pass this into your app via the index.html maybe?#2018-04-1321:18lwhortonso wrt the api/release there’s a release* version that does allow bypassing the get-config! calls#2018-04-1321:18lwhortoni should have checked (and i thought I did) but there doesn’t seem to be a corresponding watch*#2018-04-1321:19thhelleryeah that doesn't exist for watch since that is slightly more involved when doing things#2018-04-1321:19thhellerbut seriously .. why not pass the URL to your app on startup?#2018-04-1321:20thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/public/index.html#L10#2018-04-1321:21thhellerchange that to starter.browser.init("the-actual-url"); and have the init function set it to whatever var#2018-04-1321:21lwhortonno particular reason, I just wanted to use closure.defines because that’s how i’ve done it in the past. but also you still need to provide that index.html file a dynamic env var somehow#2018-04-1321:21lwhortoni guess it does get it out of the shadow-cljs world#2018-04-1321:22thhellerIMHO things like urls aren't actually compile time constants seeing as you are jumping through various hoops trying to get it there#2018-04-1321:23lwhortonthat’s a good idea i’ll look into this. that means I can just spin up a shadow server; nrepl works; the config goes back to being in one place#2018-04-1321:24thhellergenerating a HTML file that contains the URL should be way simpler than messing with the entire build#2018-04-1321:27lwhortonof course that means other people who dont want an nrepl now have to startup a server, then start up a watcher#2018-04-1321:27thhellerI'm still unsure what you are actually doing#2018-04-1321:27thhellerif you run shadow-cljs watch app the server will be running#2018-04-1321:28thhellerthere is no need to start it seperately#2018-04-1321:28thhellerrunning it seperately however has certain advantages#2018-04-1321:28thhellerbut you absolutely do not have to ...#2018-04-1321:28lwhortonoh I see. I think I need to stop, slow down, and get some sleep 😕#2018-04-1321:28lwhortoni’m asking really stupid questions#2018-04-1321:29thheller... I reaaaaaaaaaaaaallly need to get this UI stuff working ... clicking a button to start a build will be sooo much easier#2018-04-1321:29lwhortonyou’re making a ui? didn’t know about that#2018-04-1321:29thhelleryep#2018-04-1321:29thhellerwell ... planning to do a UI. did some sketches but I kinda don't like UI building#2018-04-1321:29thhellerdoing too much of that for work#2018-04-1321:30thhellerbut anyways the UX should go up 100x if you actually get a good UI#2018-04-1321:30thhelleran can click things for dev stuff#2018-04-1321:31thhellerbut for now the way I recommend using interop with ANY editor#2018-04-1321:31thhelleris running shadow-cljs server and doing everything via the REPL#2018-04-1321:31thhellerFROM the editor#2018-04-1321:32thhellercider recently added support for shadow-cljs and it seems to work pretty well#2018-04-1321:32lwhortonoh they did? i was just digging around in there and didnt see anything#2018-04-1404:24pezThe emacs cider integration looks solid: https://github.com/clojure-emacs/cider/blob/master/cider.el#2018-04-1413:46Alex H@thheller, I'm really struggling with advanced optimisation of JS-on-classpath (which in turn imports other libs); it starts renaming attributes like crazy, breaking all sorts of things, because I think the JS-on-classpath itself gets optimised separately from its imports#2018-04-1413:47Alex H@thheller,is there some way of making that work? would it work any differently if my JS-on-classpath was a separate node module instead packaged up with rollup or so?#2018-04-1413:47thheller@alex340 js on the classpath is optimized. so you'd need to write externs for JS interop since they can't be inferred by the CLJS compiler.#2018-04-1413:48thhelleryou can try tunning shadow-cljs check your-build#2018-04-1413:48thhelleralthough that will likely create a lot of warnings#2018-04-1413:48Alex Hyea, I guessed as much, but there's a metric ton of externs that get messed up#2018-04-1413:49Alex Hmy JS-on-classpath is effectively a wrapper around slate (the editor thing), which in turn brings in immutablejs#2018-04-1413:49Alex Hand none of that has a good way of defining externs for, not with ES6 modules anyway?
#2018-04-1413:49thhellerI want to add an option so the classpath-js gets treated like npm js#2018-04-1413:49thhellermeaning that it doesn't go through :advanced#2018-04-1413:50thhellerthat would probably fix everything#2018-04-1413:50Alex Hbut it'd still go through :advanced at the time the final bundle gets created?#2018-04-1413:50Alex Heither way, yes, that'd be awesome#2018-04-1413:50thhellerbut really give check a shot#2018-04-1413:50thhellerwriting externs is extremely simple with shadow#2018-04-1413:51thhellerI'll walk you through it if you want#2018-04-1413:51thhellerjust run it once and tell me how many warnings you get#2018-04-1413:51Alex Hyep, on it#2018-04-1413:51thhellerif its more than say 100 its probably not worth it#2018-04-1413:51thhellerbut shouldn't be that much usually#2018-04-1413:53Alex H36 + 20 warnings (starts counting twice)#2018-04-1413:53Alex Hlet me paste it somewhere#2018-04-1413:53thhellerwhat is the exact wording again? something about propery not defined#2018-04-1413:54Alex HFile: /home/alex/code/dlt/src/gen/slate-code.js:99:19 Property endBlock never defined on _change$value#2018-04-1413:55Alex Hfor example#2018-04-1413:55thhellerright#2018-04-1413:55thhellerwhat is your build id?#2018-04-1413:55Alex Hhttps://gist.github.com/bwalex/c7e4dc820d0246a10197225f58b4c982#2018-04-1413:56thhellercreate a externs/<your-build-id>.txt and the you add one word per line#2018-04-1413:56thhellerendBlock#2018-04-1413:56thhellerhandleOuterClick#2018-04-1413:56thhellerand so on#2018-04-1413:56Alex Hreally? that simple?#2018-04-1413:56thhellerfor every Property ... never defined#2018-04-1413:57thhelleryep#2018-04-1413:58thhellerand do yourself a favor while doing this: run shadow-cljs server separately#2018-04-1413:58Alex Hout of curiosity - should I do that for the ones coming from clojure bits & pieces as well?#2018-04-1413:58thhellerthen run shadow-cljs check until the warnings are gone 😉#2018-04-1413:58Alex He.g. in that output re.unicode, instaparse.core#2018-04-1413:59thhellerfor your code it would be better to do https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-04-1413:59thhellerbut yes you can also just put those into the .txt file#2018-04-1413:59Alex Hyea, I did that#2018-04-1413:59thhellerdoesn't really matter#2018-04-1414:00Alex HI have :infer-externs :auto#2018-04-1414:00Alex Hmidly weird some of those, like "getItem never defined on ShadowJS"#2018-04-1414:01thhellerShadowJS is the "type" assigned to anything returned by require#2018-04-1414:02thheller Property core never defined on instaparse#2018-04-1414:02thhellerthis is weird though? isn't that a cljs namespace?#2018-04-1414:03Alex Hyea, my bad, I think. was just trying to optimize things out manually, and I think defparser (the macro) actually needs instaparse.core ns#2018-04-1414:04thhelleryes probably#2018-04-1414:06Alex Hdidn't realize the externs problem was so simple. spent a few hours last week messing up with weird jsdoc strings to tell closure about types#2018-04-1414:06thhellerwell its only this simple in shadow-cljs 😉#2018-04-1414:07thhellereverywhere else its a nightmare#2018-04-1414:07Alex H0#2018-04-1414:07Alex Hsorry#2018-04-1414:08Alex Hbtw, thanks for that bundle size thing you pointed me at - very useful#2018-04-1414:10Alex Ha question about those Cannot infer target type in expression - from what I read in the shadow-cljs doc the other day, you can effectively get rid of them by marking them with ^js metadata - however, is that really required when the whole thing ends up going through closure?#2018-04-1414:11Alex Hfor example, it complains about some like getToken, which are provided by the google closure library, which presumably will get mangled the same way, so should just work?#2018-04-1414:11Alex H(even without the ^js metadata on it)#2018-04-1414:12thhellerisn't this mentioned in the docs? you can tag it with ^goog or ^clj to make the warnings go away#2018-04-1414:13Alex Hdon't see any mention of ^goog, but now that you mention it, I do see ^clj#2018-04-1414:13thheller^goog is for stuff from the closure lib#2018-04-1414:14thhellerin rare circumstance if could become a problem if you tag something not-cljs with ^clj#2018-04-1414:28Alex His there some way of waiving warnings from cljs dependencies?#2018-04-1414:28Alex HI think it's all clean now, apart from some noise coming in from reagent, instaparse, goog/base and cljs internals#2018-04-1414:29thhellerwhats left?#2018-04-1414:29thheller variable Java is undeclared#2018-04-1414:29thhellerfor this you can add global:Java to the .txt file#2018-04-1414:29thhellerforgot that I need to add that#2018-04-1414:30Alex Hhttps://gist.github.com/bwalex/c7e4dc820d0246a10197225f58b4c982#2018-04-1414:31thhellerhmm yeah can't make those go away#2018-04-1414:31Alex Hone less with that global:Java, but yea, still those 12 there#2018-04-1414:31Alex Hok, fair#2018-04-1414:32thhellerdid it work?#2018-04-1414:32Alex Habout to try#2018-04-1414:35Alex Hmost of it does, but the slate-based editor doesn't really work, somehow#2018-04-1414:35Alex Hdoesn't show any errors on the console either, though#2018-04-1414:37Alex Hsome rendering issue, the editing itself worked fine#2018-04-1414:37Alex Hstrange.#2018-04-1414:37thhelleryou can try shadow-cljs release app --debug but I doubt that would change anything#2018-04-1414:37thhellermight make it easier to debug though#2018-04-1414:40Alex Hdoes this preserve console.log messages?#2018-04-1414:40Alex Hfor some quick & dirty debug#2018-04-1414:40thhellerthey are not removed yes#2018-04-1414:58Alex Hinteresting. it is some mangling gone wrong#2018-04-1414:58Alex Heven though there is no warning about it, adding renderMark to the externs list fixes it#2018-04-1414:59Alex H(renderMark is a prop to slate's react editor component, and the function I was passing in for that prop was not getting called)#2018-04-1415:03Alex Hyea, doing a diff of the builds with/without that shows that there's two props getting messed up for some reason - renderMark and decorateNode#2018-04-1415:03Alex Hmangled, that is#2018-04-1415:03Alex Hno idea why#2018-04-1415:04Alex Hhttps://gist.github.com/bwalex/137054c5cec4e7a56be734cad32c8fd6#2018-04-1415:04Alex HI've added a comment to that gist to show the original code around that area#2018-04-1415:04thhellerhmm yeah all this stuff is not 100% accurate unfortunately#2018-04-1415:05thhellergood enough for most things but sometimes things seem to get lost#2018-04-1415:05Alex His there any reason why most props would map fine, but some would get mangled like that?#2018-04-1415:05Alex Hthey are pretty symmetric as far as I can tell#2018-04-1415:07thhellernot sure. any difference in the JS?#2018-04-1415:08thhellermaybe just something the closure compiler doesn't correctly check yet?#2018-04-1415:08Alex Hnot that I can tell - I have pasted the JS going into it in a comment on that gist#2018-04-1415:09Alex HrenderNode, renderMark and decorateNode look pretty similar, yet the latter two get mangled but the first one is ok (and so are all other props on that thing)#2018-04-1415:10thhellerhmm looks like it might be related to the name being identical to the value maybe? renderMark: renderMark,#2018-04-1415:10thhellermaybe the closure compiler gets confused by that#2018-04-1415:10Alex Hinteresting#2018-04-1415:11thhellerdecorateNode: function decorateNodeFoo() {#2018-04-1415:12thhellertry this. if that fixes the decorateNode issue we can probably try to create a minimal repro and report to the closure compiler#2018-04-1415:13thhellerdunno where renderMark is coming from but if you can change the name for that var as well try that too#2018-04-1415:15Alex Hnah, same thing#2018-04-1415:15Alex Hweird.#2018-04-1415:15Alex HI renamed both decorateNode and renderMark to decorate and renderMarkFoo respectively#2018-04-1415:16Alex Hsame renaming it to something else entirely (abcd)#2018-04-1415:16Alex Hoh well#2018-04-1415:16thhellerstrange#2018-04-1415:17thhellerwhat does the generated js look like#2018-04-1415:17thhellershould be in .shadow-cljs/builds/<your-id>/dev/closure-js#2018-04-1415:17thhellerah crap nevermind. thats a transit file#2018-04-1415:18Alex HrenderNode:renderNode$$module$gen$editor(_this.props.readOnly), renderMark:renderMarkFoo$$module$gen$editor, decorateNode:function decorate() {\n return undefined;\n }, value:_this.props.value, #2018-04-1415:18Alex Hlooks healthy, in other words#2018-04-1415:18thhellerindeed#2018-04-1415:18thhellerbut adding those to externs fixes it?#2018-04-1415:19Alex Hyep, I'll use that as a workaround#2018-04-1415:19Alex Hmakes me feel slightly uneasy, but good enough for now#2018-04-1415:19thhellerhmm#2018-04-1415:19thhelleryeah I have no idea why closure wouldn't mention those in check#2018-04-1415:20Alex Hno worries, I have taken up enough of your time!#2018-04-1415:20Alex Hthanks#2018-04-1415:20Alex Hseems to work well apart from this quirk#2018-04-1418:48lwhortoni just cannot get my vim-fireplace to work, and I have no idea where to look next. 1) start a shadow server 2) from inside a .clj buffer connect via :Connect <nrepl://localhost:port> 3) I can now use :Eval (+ 1 2) and get 3 (yay the connection to nrepl works) 4) cannot use :Eval from inside a .cljs buffer (always spits out Fireplace: class clojure.lang.Compiler$CompilerException) 5) from a .clj buffer run shadow...api/watch :app — get back :watching — success! 6) connect to the js environment by opening a browser 7) still no Eval in a .cljs buffer 8 ) from a clj buffer run shadow...api/nrepl-select :app — get back [:selected :app] — success! 9 ) from a clj buffer :Eval (js/alert) yay it works 10 ) still nothing works from a .cljs buffer#2018-04-1418:50lwhortonthe reason i’m asking here is because fireplace works with lein’s nrepl, and I can eval from a .cljs buffer, but i just can’t figure out the differences between repls#2018-04-1418:50thhellerwasn't there something like :Piggieback or so?#2018-04-1418:51lwhortoni’m not sure where piggieback fits in — my understanding was nrepl-select :id was going to already put me in a cljs environment?#2018-04-1418:51thhellerso after step 5 you run :Piggieback :app?#2018-04-1418:52thhellerit puts you into a CLJS environment on the server yes but the client might also need to update something#2018-04-1418:52lwhorton
:Piggieback [{env}]     Create a new nREPL session and invoke
                        cemerick.piggieback/cljs-repl with the given or
                        default (Rhino) environment.  This will also happen
                        automatically on first eval in a ClojureScript buffer
                        if not invoked explicitly. If {env} is a number, the
                        piggieback repl-env will will use a cljs.repl.browser
                        (rather than a Rhino) env with the port set to the
                        number provided.
#2018-04-1418:53thhellerno clue really. might need to ask somebody that knows vim#2018-04-1418:53thhellerwhat happens when you run :Piggieback :app?#2018-04-1418:54lwhortoneverything works like magic. 💕#2018-04-1418:58lwhortonthanks again my man. do you have a patreon (or equiv) setup for shadow-cljs by the way?#2018-04-1419:00thhellerkind of. I set it up but didn't tell anyone because I'm not really sure I want/how to do this.#2018-04-1419:00thhellerhttps://www.patreon.com/thheller#2018-04-1419:00thhellerthat was like 2 months ago and didn't touch it since then 😛#2018-04-1419:11lwhortona few days ago you mentioned that you do or dont have plans to allow running a shadow clj(s)-repl with an alternative default namespace (like how cli-tools’ clj automatically picks up the user ns? I can’t remember which.#2018-04-1419:12thhellerI do have plans and a partial implementation#2018-04-1419:12lwhortonthe reason I ask is I basically just want access to the 3 spec generator namespaces required to do generative testing in a repl - test.check.generators, spec.alpha, spec.gen.alpha#2018-04-1419:13thhellerI still think it would be way better if the client did this though#2018-04-1419:13lwhortonisn’t the “client” the process invoking shadow-cljs clj-repl (assuming you already have a server running in the background)?#2018-04-1419:14thhelleroh I thought you meant to nrepl#2018-04-1419:14thhellerfor clj-repl that would be easier to add yes#2018-04-1419:27larshelgI get one and just one warning: Use of undeclared Var clojure.string/join. Some libary is using clojure/string. I'm not but thats ok. However the hot reloader gives the compiler warning every time I make a change and messes up the hot loader. I tried to add :warnings false in the compiler-options but still get the warning after compilations. How to turn compiler warnings off?#2018-04-1419:55thheller@larshelg it should only warn once for code that lives in jars by default. if the warning is in a file on your classpath you'll need to fix it.#2018-04-1420:01larshelgI see. I will take a look. So there is no way to simply turn warnings off? If not permanently just for hot reload?#2018-04-1420:02thhellernot currently no.#2018-04-1420:02larshelgWarning is this: File: rewrite_clj/parser/string.cljs:39:16#2018-04-1420:02larshelgI think strangely its from a jar#2018-04-1420:03larshelgActually there is two, this is the second one: File: zprint/spec.cljc:379:14#2018-04-1420:03thhellertry shadow-cljs clj-repl and then ( "rewrite_clj/parser/string.cljs")#2018-04-1420:03thhellerif its in a jar open a bug report on github please#2018-04-1420:03larshelgWill do, thanks for the input 🙂#2018-04-1420:04thheller(should give you something like jar:... or file:.. urls#2018-04-1420:05larshelgjepp this: #object[java.net.URL 0x29a2b3d7 "jar:file:/Users/larsstrand/.m2/repository/rewrite-cljs/rewrite-cljs/0.4.4/rewrite-cljs-0.4.4.jar!/rewrite_clj/parser/string.cljs"]#2018-04-1420:05thhellerand the warning does not go away one the SECOND compile?#2018-04-1420:05larshelgnope#2018-04-1420:06thhellerhmm ok thats definitely a bug then#2018-04-1420:06larshelgeverything is working so smooth with my setup, using reframe and semantic-ui-react#2018-04-1420:07larshelgbut this two warnings messes up my hot reload flow#2018-04-1420:07thhelleryou can fix it#2018-04-1420:07larshelgi just have to do full refresh of my app every time#2018-04-1420:07thhellerif you take the file out of the jar. put it in your classpath. and fix the warning 😉#2018-04-1420:08larshelghehe, i'll try#2018-04-1420:09thhellerhmm do you know the github repo for this?#2018-04-1420:09larshelgnope#2018-04-1420:09thhellerah here https://github.com/rundis/rewrite-cljs/blob/master/src/rewrite_clj/parser/string.cljs#2018-04-1420:10thhelleryou can just take that file and add a [clojure.string] to the requires#2018-04-1420:11larshelgyeah you can see its not imported/required#2018-04-1420:11larshelgso its a bug#2018-04-1420:11thhelleryep#2018-04-1420:13larshelgso since i'm doing this, whats the easiest way to add it to the classpath?#2018-04-1420:13larshelgjust copy the file#2018-04-1420:13larshelgor make a rewrite_clj folder in my src?#2018-04-1420:14larshelgand put it there...#2018-04-1420:14thhelleryes create a src/rewrite_clj/parser/string.cljs in your project#2018-04-1420:14larshelgjepp#2018-04-1502:05tianshu@thheller just tried the new :expo target, following the example project.#2018-04-1502:08tianshuAnd I can just dismiss this error, the UI loaded successfully.#2018-04-1502:12tianshuIt's likely my exp is not the lastest.#2018-04-1502:27tianshustill met the same error with the lastest exp. @thheller can you provide your versions of exp and create-react-native-app?#2018-04-1507:52thheller@doglooksgood that is with the same code? or did you add something? maybe its your Expo app version?#2018-04-1507:52thheller
"dependencies": {
    "expo": "^26.0.0",
    "react": "16.3.0-alpha.1",
    "react-native": "0.54.0"
  }
#2018-04-1507:52thhellerthats what I got yesterday when running create-react-native-app#2018-04-1507:52tianshuIt's the same code, I haven't modify anything.#2018-04-1507:52thhellershould be easier to figure out the problem once I add source mapping#2018-04-1507:53tianshu
{
  "name": "DemoApp",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.13.1",
    "jest-expo": "26.0.0",
    "react-test-renderer": "16.3.0-alpha.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^26.0.0",
    "react": "16.3.0-alpha.1",
    "react-native": "0.54.0"
  }
}
I think we have the same dependencies.
#2018-04-1507:54thhelleryep thats identical to mine#2018-04-1507:55thhellerwhich expo app version do you have? mine is 2.4.7.1013849#2018-04-1507:58tianshu2.4.6.1013746#2018-04-1507:58tianshuThis may be the reason#2018-04-1507:59tianshuIf installed from AppStore, the version will be 2.4.7, if let exp download and install on ios simulator, the version will be 2.4.6#2018-04-1507:59tianshuI'll try if it works on 2.4.7#2018-04-1508:02thhelleryou can look at the DemoApp/out-ios/bundle.ios.js file and look at the lines directly until source maps work#2018-04-1508:03thhellermaybe that will give a clue which part of the code actually doesn't work#2018-04-1508:09tianshuyes#2018-04-1508:10thhellerdidn't try running anything in a simulator yet at all#2018-04-1508:13tianshuIt's a pretty large function, it failed at
16258           case 'blob':
 16259             if (typeof this._response === 'object' && this._response) {
 16260               this._cachedResponse = BlobManager.createFromOptions(this._response);
 16261             } else {
 16262               throw new Error("Invalid response for blob: " + this._response);    <--- Here
 16263             }
 16264
 16265             break;
can you find this part in your bundle.ios.js?
#2018-04-1508:14thhelleridentical#2018-04-1508:15tianshuthis error occurs after the app is launched, hot-reload and repl already work.#2018-04-1508:15thhellerseems to be the XHR wrapper they provide#2018-04-1508:15thhellerare you doing anything to trigger the error?#2018-04-1508:16tianshuno, error occur after app is started#2018-04-1508:17thhellerhow do you know that the rest works then?#2018-04-1508:18tianshuI can just press Dismiss#2018-04-1508:19thhellerand changing the code will display the actual changes after dimissing the error?#2018-04-1508:21tianshuyes, it works#2018-04-1508:22thhellerweird. reloading code is the only xhr request it should be doing#2018-04-1508:23tianshumaybe it's for some expo specific features?#2018-04-1508:24tianshuon my expo app on ios, I can't find the + button. It was there#2018-04-1508:24thheller+ button?#2018-04-1508:24tianshubut after upgrade the newer version, it disappear#2018-04-1508:25thhellerah you mean the scan qrcode thing? can just use the default iOS Camera app for that.#2018-04-1508:25tianshuyes#2018-04-1508:26thhelleryeah looks like that for me too. just use the Camera app#2018-04-1508:27thhelleron android I did get a scan qrcode option in the app itself. dunno why its not there on ios#2018-04-1508:29tianshuokay, I'll have try now#2018-04-1508:31tianshuOk, it works with 2.4.7 expo!#2018-04-1508:32thhellercool. 2.4.6 was running the simulator? how did you start the simulator?#2018-04-1508:33tianshuonce you use command exp to start a ios simulator, it will download expo and install it automatically.#2018-04-1508:35tianshumy error is about version incompatible, thank you very much and great job!#2018-04-1508:35thhellerah good to know.#2018-04-1508:37thheller
10:36:35 [exp] Installing Expo on device
\10:36:38 [exp] Couldn't start project on Android: Error running adb: Failed to install C:\Users\thheller\.expo\android-apk-cache\Exponent-2.4.0.apk:
#2018-04-1508:37thhellerwhen running exp android. I'm on windows so no iOS.#2018-04-1508:37thhelleremulator is running though. no idea what is wrong#2018-04-1508:38thhellerhmm I guess it can't find adb#2018-04-1508:41thhellerhmm how do I get the url to the emulator though?#2018-04-1508:41tianshuYou mean exp://...?#2018-04-1508:42thhelleryeah. emulator doesn't have a camera option#2018-04-1508:42tianshuon ios expo will use the url in clipboard.#2018-04-1508:43tianshuI haven't try android yet.#2018-04-1508:44thhellerah hehe that worked. thanks.#2018-04-1508:45tianshuwhat's version of expo on android emulator?#2018-04-1508:46thhellerhmm it seems to run fine in this emulator#2018-04-1508:46thheller2.4.0#2018-04-1508:47thhellerthat was easier than expected 😉#2018-04-1508:48tianshunever mind any error with versions, that not worth the time.😂#2018-04-1508:50thhellerI can probably fake the version easily. the client sends a "exponent-sdk-version" "26.0.0,25.0.0,24.0.0,23.0.0,22.0.0,21.0.0,20.0.0" header on connect. can just pretend to by any of those 😉#2018-04-1508:51thhellerdone. no idea if that fixes anything but shouldn't hurt.#2018-04-1509:27thhellerhaha nice#2018-04-1509:27thhellerthe android version sends "26.0.0,25.0.0,24.0.0,23.0.0,22.0.0,21.0.0,20.0.0" as versions#2018-04-1509:27thhellerthe ios version sends "20.0.0,21.0.0,22.0.0,23.0.0,24.0.0,25.0.0,26.0.0"#2018-04-1509:28thhellerwin for constistency I guess 😛#2018-04-1523:03tony.kayon 2.2.31 I’m no longer getting hot reload or a HUD. Anyone else seeing that?#2018-04-1523:09tony.kay@thheller I have no problems in 2.2.29 (well, HUD is a little erratic, but it’s always been in sort of a hard to describe way), but in 31 I get a console error about devtools, and hot load doesn’t work.#2018-04-1523:11tony.kay
shadow.module.test.append.js:2 Uncaught TypeError: Cannot read property 'devtools' of undefined
    at shadow.module.test.append.js:2
(anonymous) @ shadow.module.test.append.js:2
#2018-04-1523:12tony.kayI was trying to upgrade my template…based on lein new fulcro app shadow-cljs demo, running the test build.#2018-04-1603:22tony.kayBTW: my build does not indicate a preload of devtools, but it is on the classpath.#2018-04-1608:05thheller@tony.kay the hud works just fine for me when running lein new fulcro app shadow-cljs demo and shadow-cljs watch test with 2.2.31?#2018-04-1608:08thhellerno wait. didn't edit the project.clj. assumed the package.json version was used. doesn't work with 31 indeed.#2018-04-1608:47thhellerfixed in 32. the dynamic discovery I added in 30 forgot to add the devtools after discovery.#2018-04-1610:18tianshucan I use :npm-module target for expo to build a release version? (also should provide a index.js manually)#2018-04-1610:19thheller@doglooksgood I added release support in 2.2.31#2018-04-1610:19thhellerwhen you run shadow-cljs release it generates an optimized.ios.js in the :output-dir#2018-04-1610:19tianshuwhy you are so fast:scream:#2018-04-1610:20thhellerthat should work fine with the default exp/react-native tools when you use that as the entry#2018-04-1610:21thhelleryou can't use that file directly though. it must be run through metro#2018-04-1610:25tianshuI'll try the new feature in 2.2.31#2018-04-1610:28thhellerI didn't try exp build or any of the release stuff since it asked me a bunch of questions I didn't want to answer at the time#2018-04-1610:28thhellerkeychain and whatnot#2018-04-1610:33tianshuare react-native and expo targets work in the same way?#2018-04-1610:33thhellerno#2018-04-1613:07javiquestion: I am setting up my release toolchain starting with a simple one. Given I have a release build setup
...
:simple-deploy {:target :browser
                                  :output-dir "resources/public/simple-deploy/js/"
                                  :modules          {:main {:entries [simple-deploy.core]}}
                                  }
...
and a simple reagent mini app... with a single dependency on reagent
(ns simple-deploy.core
  (:require [reagent.core :as r]))

...
...
;; app code
...
...
(defn ^:export run []
  (r/render [simple-example]
            (js/document.getElementById "app")))
when I run shadow-cljs release simple-deploy --debug I get...
[:simple-deploy] Compiling ...
Closure compilation failed with 1 errors
--- EXTERNS:/Users/javierabanses/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
so the question is? when/why is d3 being included? NOTE: this is the first time i've run shadow-cljs release ... so maybe it is scanning the local maven repo for indexing or something? thanks in advance.
#2018-04-1614:39alex-dixon@fj.abanses Hm. Can you search bundle-info.edn for d3?#2018-04-1615:03pez@thheller Now I have released an update to Calva with the much lacking shadow-cljs support added. https://marketplace.visualstudio.com/items?itemName=cospaia.clojure4vscode#2018-04-1615:07pezThere are still some quirks that I don’t have the time to elaborate on right now, but nothing that should be a stopper. Also, I have no idea how this works for other projects than browsers. So anyone who would like to try that out and provide me feedback will become my hero.#2018-04-1615:17javi@alex-dixon.. not familiar with that file... is it in the .shadow-cljs folder?#2018-04-1615:46alex-dixon@fj.abanses Yeah but it looks like you might need to follow the instructions here to generate it: https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9#2018-04-1615:48alex-dixon@fj.abanses I’m actually not sure how helpful that will be. Also appears manifest.edn contains similar information#2018-04-1615:51javi@alex-dixon thanks! I am gonna check manifest.. and then the bundle...#2018-04-1616:15javi@alex-dixon when running
npx shadow-cljs clj-repl
shadow-cljs - config: /Users/zilence/code/shadow-cljs/shadow-cljs.edn version: 2.0.101
shadow-cljs - connected to server
shadow-cljs - REPL - see (help), :repl/quit to exit
[11:0]~shadow.user=> (shadow/release-snapshot :simple {})
:simple being build id i get ExceptionInfo closure errors clojure.core/ex-info (core.clj:4739) keep in mind shadow-cljs release :simple never finished and exited with an error... so maybe this means there is nothing to examine...
#2018-04-1616:37alex-dixon@fj.abanses Oh. Didn’t see that. That makes sense. I think it runs the release first in order to analyze it#2018-04-1616:42javi@alex-dixon is there a lein clean equivalent or even need for it? I am very new to the tool and can't see any in the docs#2018-04-1617:04pez@fj.abanses i just delete the artifacts.#2018-04-1617:05javi@alex-dixon @pez it just worked as soon as i stopped the repl i was running...#2018-04-1617:07alex-dixon@fj.abanses There isn’t a clean equivalent. I raised it as an issue here: https://github.com/thheller/shadow-cljs/issues/242#2018-04-1617:08javi:+1: i ll check that. thanks for the help#2018-04-1617:58thheller@fj.abanses the problem is most likely cljsjs.d3 on your classpath.#2018-04-1617:59thhellercurrently shadow-cljs uses the externs from any cljsjs package. probably should not do this anymore but it seems like a good idea in the beginning.#2018-04-1618:00thhellerdidn't think that this would ever be a problem but I guess there are some broken externs for d3#2018-04-1618:02thhellerbut it is not d3 being included. it is only the externs.#2018-04-1620:25thhellerI just pushed 2.3.0 which removes this behaviour. about time.#2018-04-1620:25thhellercompletely forgot it even existed#2018-04-1620:26javi@thheller you are a star 😀#2018-04-1621:05lwhortonhow do I use shadow-cljs clj-run some.namespace/-main arg1 arg2 arg3 with flags that is normal input for something like tools.cli?#2018-04-1621:06lwhortonbecause -a arg1 -b arg2 ... etc. throws with a shadow-cljs clj-run “unrecognized argument”#2018-04-1621:06lwhortondo I have to use some magic string or some other unix trick to make shadow-cljs ignore the arguments?#2018-04-1621:07thheller--#2018-04-1621:07thhellereverything after that just gets passed through#2018-04-1621:08thhellerI should probably change the CLI parsing for clj-run so that thats the default#2018-04-1621:08thhellerbut for not shadow-cljs clj-run foo.bar/run -- a b c#2018-04-1621:14lwhortonthanks again#2018-04-1623:10cjmurphyHow do you upgrade shadow-cljs? I can see that the version is specified in package.json and project.clj. So I can change it to say '2.3.0' in both those places. Then what do I need to do? I never saw this outlined in the documentation, yet everyone seems to be doing it. If I just run npx shadow-cljs watch main (the only command I ever run) the version change is not picked up.#2018-04-1700:19justinleechange it in package.json and then run npm install. restart shadow and it should pick it up#2018-04-1707:13alex-dixonDo you know the consequences of having a global install that’s out of sync? #2018-04-1708:17thhellerit always uses the one installed in the project over the global one so it should not be a problem.#2018-04-1706:31mjmeintjesI'm getting "Too many open files" error every now and then:
[:app] Compiling ...
[:app] Build failure:
FileNotFoundException: /home/matthys/projects/personal/learning/src/learning/web/topic_notes/core.cljs (Too many open files)
	java.io.FileInputStream.open0 (FileInputStream.java:-2)
	java.io.FileInputStream.open (FileInputStream.java:195)
	java.io.FileInputStream.<init> (FileInputStream.java:138)
	 (io.clj:229)
	 (io.clj:229)
	 (io.clj:69)
	 (io.clj:165)
	 (io.clj:165)
#2018-04-1706:31mjmeintjesI can create an issue for this, but not really sure what information I can provide. How would you go diagnosing this?#2018-04-1708:21thheller@mjmeintjes if you are on linux/osx you can use lsof -p <pid> to list the open files of the shadow-cljs process. jps should list the pid. not sure where the leak could be coming from so knowing which files are open would help a lot#2018-04-1708:23thhellermight also be an external process with too many files open though. doesn't have to be the shadow-cljs process since its a user limit not a per process limit IIRC#2018-04-1708:54mjmeintjesThanks, that helps. If it happens again I'll open an issue if it looks like shadow-cljs is at fault.#2018-04-1709:37pez@thheller: I edited the github project wiki to add info about Calva for editing shadow projects: https://github.com/thheller/shadow-cljs/wiki/Calva#2018-04-1709:38pez(I know it said deprecated, but didn’t see how to edit the other user guide, and people will look at the wiki pages as long as they are there anyway.)#2018-04-1709:39thhellercool thx. I will add it to the user guide later. or you send make a PR if you want https://github.com/shadow-cljs/shadow-cljs.github.io
#2018-04-1709:39thhellerhttps://github.com/shadow-cljs/shadow-cljs.github.io/blob/master/docs/editor-integration.adoc#2018-04-1710:13pezhttps://github.com/shadow-cljs/shadow-cljs.github.io/pull/13#2018-04-1712:57chris_johnson@pez: I want to say that I took Calva for a spin yesterday with a shadow-cljs project I have here and so far it looks really good#2018-04-1712:57pezOh, yay. Thanks for letting me know!#2018-04-1712:57chris_johnsonlike, “maybe I can finally stop scaring off the youths with my and then you simply download 'emacs'... speech when trying to infect them with The Clojure” good#2018-04-1712:59chris_johnsonI will have to dig through the extensions list and see if there’s anything that can hold a candle to magit and org-mode before get too serious about Code as a daily driver, but Calva seems to do really well for a REPL 🙂#2018-04-1713:01pezThe org extension doesn’t seem to match emacs org-mode very well. But GitLens together with the built in Git support is very good, I think. Maybe not magit-level, keyboard-wise, but still good.#2018-04-1713:02pezBut the download emacs thing is a good way to weed out the weak. 😃#2018-04-1713:04chris_johnsonwell, that’s certainly true, but I do think that being able to demonstrate the REPL workflow in a “modern editor” might get some of those “weaklings” interested enough to start lifting some mental weights, so to speak#2018-04-1713:05chris_johnsonMy experience has been that the vast majority of devs, once they see the REPL flow work, they will happily chew on emacs or JVM stacktraces or whatever for awhile to get what I’m selling hehe#2018-04-1713:08pezThat’s what happened to me. I was blown away and installed Emacs immediately.#2018-04-1713:08pezI think I should put together a playground project for people to try out shadow-cljs together with the interactive programming Calva enables.#2018-04-1713:11pezIf you play some with Calva for shadow-cljs, I am eager to learn if something does not work or if there is something that would make the experience better.#2018-04-1713:12chris_johnsonI intend to use it for my interactions with the project I mentioned before (shipped, production SPA but that I don’t have many responsibilities over) and also when I spike moving our RN app from Boot to shadow-cljs sometime Real Soon™#2018-04-1713:13chris_johnsonI will be sure to keep you posted#2018-04-1716:28pezActually, it seems there are some problems evaluating (loading) files in the Clojurescript repl of shadow-cljs. This works more stably in Figwheel’s repl. I have some investigation to do.#2018-04-1716:36thheller@pez I only tried the plugin briefly but it seemd to have a few issues#2018-04-1716:37thhellercouldn't get it to work properly. it seems weird to me that it forces me to select a CLJS repl before I actually do anything.#2018-04-1716:37thhellerI think there are a few issues with your approach that might cause problems#2018-04-1716:38pezHow do you mean before you actually do anything?#2018-04-1716:39thhellerie. in my work project I usually have 2 builds running. say one for the server one for the browser. if Calva tries to unconditionally load the CLJS file I'm currently working on in the REPL that will cause problem#2018-04-1716:39thhellersome server files can't be loaded in the browser repl#2018-04-1716:39thhellerI open the project, open a CLJS file and it asks me which build#2018-04-1716:39thhellerdidn't tell it to connect or anything#2018-04-1716:40pezIt defaults to autoconnect. This is a setting. Maybe it should default to not do that. But I am not sure that is the whole story behind what you mean with “my approach”?#2018-04-1716:41thhellerit seems to try to load the file I'm working on in the REPL?#2018-04-1716:41thhellerdon't know why it did that when I didn't tell it to do that#2018-04-1716:41pezI come from an environment where there is cljs in the browser and clj on the server.#2018-04-1716:42thhellerI also have clj on the server but I do have several CLJS builds in my project#2018-04-1716:42pezIt loads the file so that evaluating forms will be more likely to work.#2018-04-1716:43thhelleryeah but that doesn't work#2018-04-1716:43pezTell me why.#2018-04-1716:43thhellerassume this simple scenario. CLJS on the server, CLJS in the browser.#2018-04-1716:44thheller:server build is :node-script running in node. :app build is :browser#2018-04-1716:44thhellerI have the my.app.server file open. it imports various node packages#2018-04-1716:44pezYes, that is a scenario that breaks things right now.#2018-04-1716:44thhellerbut I'm connected to the :app REPL#2018-04-1716:44thhellersame for two different :browser builds. I have one for the website and one for the admin interface#2018-04-1716:45thhellercan't load admin stuff in the website#2018-04-1716:46thhelleradd a react-native app to the mix and so on#2018-04-1716:46thhellernot all cljs files run in all cljs builds#2018-04-1716:46pezI will have to go back to the drawing board for properly supporting shadow-cljs, I think. Can you tell me how you would like it to work?#2018-04-1716:47thhellerwell its part of a greater problem really. I have no idea how to address this.#2018-04-1716:48thhellerIn Clojure you only have one runtime. everything is nice and easy.#2018-04-1716:48thhellerin CLJS it is not since there are many different platforms and it is very likely that you'll be talking to many at once#2018-04-1716:48thhellerthere is also the problem of many connected runtimes.#2018-04-1716:49thhellersay you build a react-native app and have the app open in iOS and android. which do you use to eval the REPL code in?#2018-04-1716:49thhelleror the browser open in chrome and firefox?#2018-04-1716:49pezI ran into that problem today. shadow-cljs told me it couldn’t evaluate for me.#2018-04-1716:49thhellerits a problem you do not have for Clojure since there is only Clojure.#2018-04-1716:50pezI haven’t run into the problem with Figwheel, though.#2018-04-1716:50thhellerfigwheel cheats#2018-04-1716:50thhellerit just sends the eval to everything that is connected and displays the first result that comes back#2018-04-1716:50pezI see. 😃#2018-04-1716:51pezBut if we put that problem apart, which seems to be much bigger than Calva… Maybe if for shadow-cljs projects Calva asks for which build for every file that is opened? Possibly trying to remember per file between sessions.#2018-04-1716:52thhellerthat doesn't work because many files are shared and used in many builds#2018-04-1716:52thhellerthe only issue I have really is that it auto-evals#2018-04-1716:53thhellerjust let me manually eval what I want and everything is fine I think#2018-04-1716:53thhellerif I can toggle it to off that is fine too#2018-04-1716:54pezBut Calva only lets you have one build connected per workspace. Will that work?#2018-04-1716:54thhellerI gotta go. I will experiment with this some more tomorrow.#2018-04-1716:54thhelleras long as I can switch it yes thats fine#2018-04-1716:55pezYou can’t at the moment. Well, maybe you can reconnect and that has that effect, sort of.#2018-04-1717:00javithis may be a stupid question, can i set different :output-dir for :dev and :release? it seems the answer is yes from the docs... but maybe i am having a slow day and can't see it clearly. use case is i have watch running but i also have a quick test deploy script the compiles the same build but in release and deploys to surge.sh.#2018-04-1717:01javiso TLDR: can i run a release build if the same build is being watched? if so.. how do i set a different output folder?#2018-04-1717:07thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-04-1717:07thheller:release {:output-dir "foo/bar"}#2018-04-1717:39JonRefresh http://shadow-cljs.org/ and good luck!#2018-04-1717:56pepeI didn't know about :module-hash-names. It is actually great feature for me.#2018-04-1718:51pez@thheller I just published an update of Calva that does not auto evaluate files. Might make it an opt-in later, but this is a saner default considering all different kinds of workflows and project setups. I’m still pondering on how to support build switching. For now reconnecting might work. Please let me know if you try it out some more, what works and not.#2018-04-1718:53pezLoading of files does not seem to work through the shadow-cljs Clojurescript repl connection. So added a greeting note in the app log channel about a possible workaround which is to select all contents of the file and evaluate it.#2018-04-1803:15tianshu@thheller when start shadow-cljs in clj-repl mode, shadow/watch and shadow/repl can be used in shadow.user namespace. how to have these setup in server mode, or have a headless repl in clj-repl mode?#2018-04-1807:18quang@thheller I would say congrats on http://shadow-cljs.org/ ... but it seemed to have existed before today... I don't think I've ever seen it before today though 😅#2018-04-1807:55thheller@doglooksgood not sure I understand the question? (require '[shadow.cljs.devtools.api :as shadow]) works anywhere?#2018-04-1807:58thheller@quang you are correct I never updated the links. fixed.#2018-04-1808:04kennethkalmerhowdy folks, I’m having a small issue where I can’t figure out the correct require dance for using the twitter npm package#2018-04-1808:05kennethkalmerthe package has the following export: module.exports = Twitter, where Twitter is a function#2018-04-1808:05kennethkalmerhttps://github.com/desmondmorris/node-twitter/blob/master/lib/twitter.js#L15#2018-04-1808:06kennethkalmerI keep getting variations of: TypeError: shadow.js.shim.module$twitter.Twitter is not a function#2018-04-1808:16thheller@kennethkalmer (:require ["twitter" :as Twitter])#2018-04-1808:26kennethkalmerthanks, will try that again#2018-04-1808:26thhellerrule of thumb is when JS libs assign module.exports = ... directly that is :as. if they do exports.foo = ... that is :refer (foo)#2018-04-1808:28steveb8n@thheller I’ve fully moved over to shadow from cljsbuild and loving it. Have you applied for a Clojurists Together grant? This kind of tooling is what they want to fund#2018-04-1808:29thhellerI did indeed.#2018-04-1808:29thhellerand welcome 😉#2018-04-1808:29steveb8nyou have my vote#2018-04-1808:30steveb8nI was thinking of knocking up a d3 treemap on top of the release-snapshot data. has anyone else started on this already?#2018-04-1808:30thhellercurious to hear about your transition. any specific hurdles?#2018-04-1808:31thhellernot sure if anyone started yet. maybe discuss it here: https://github.com/thheller/shadow-cljs/issues/247#2018-04-1808:32steveb8ntransition was a couple of days work, I made it easier by building a separate project with all my cljsjs deps ported to shadow first and then migrated my real code over#2018-04-1808:33steveb8nI’d recommend that to anyone making the transition. I was much more confident when I started on my own code#2018-04-1808:34steveb8nI discovered how to use react-faux-dom with d3 while doing this work, what a revelation. idiomatic d3 in react#2018-04-1808:35thhellerwhat do you mean by cljsjs deps ported?#2018-04-1808:35thhellerdid you create a bunch of cljsjs. namespaces or rewrite your code to use npm directly?#2018-04-1808:36steveb8nthe only hiccup was grokking devcards and how it integrates. it seems like :devcards true isn’t quite enough since I’ve had to use preloads and call start-devcard-ui! myself to make that work#2018-04-1808:36steveb8nbut not a biggie#2018-04-1808:37thhellerdevcards comes up a lot. should probably create a proper example for it.#2018-04-1808:37steveb8nre: cljsjs, I switched over to npm deps for all cljsjs deps on the advice of someone in slack. worked great and had the side benefit of allowing me to use any version of npm deps I wanted#2018-04-1808:38steveb8nwith cljsjs I was always struggling to get the magic combination of deps + react + cljs versions all to play nicely. with npm deps, it was much easier to combine all the transitive deps and have them all play nice together#2018-04-1808:44pez@jiyinyiyong I fail at getting the server running for development. I get a 404 on localhost:7000. Everything seems to build nicely.#2018-04-1808:59Jontried yarn page?#2018-04-1808:59Jonyou might also need a symbolic link in target/ to entry/#2018-04-1809:00JonPage is created by running app.page/main!#2018-04-1810:21pezI don’t quite understand how to update the page. The editor only gives me the first line to edit. (Haven’t read up on the editor yet.)#2018-04-1815:10JonThat's the crazy part.#2018-04-1815:11Jonmy code was generated with https://github.com/Cirru/calcit-editor#2018-04-1815:11Jonit's an editor I created for generating Clojure code. with it you don't code in parentheses.#2018-04-1815:11Joncould be really hard to pick up.#2018-04-1815:12Jonif you just want to contribute the markdown part, try submit an issue and I will copy/paste.#2018-04-1815:13Jonthe harder way is to npm install -g calcit-editor on an Unix/Linux OS and launch my editor. Contact me when you need help about the editor. It's a mind blowing piece.#2018-04-1815:14Jontimezone problem anyway...#2018-04-1815:57pezI did install the editor. 😃 Launched it and it looked pretty awesome. But I couldn’t (or couldn’t figure out how to) edit the actual contents of the page. It only gave me the first line of Markdown.#2018-04-1816:55JonThere is a button at the bottom called "Draft box". Try it.#2018-04-1816:56JonPressing "Command d" on a *string* also does the trick.#2018-04-1819:12pezYes, there it is. 😃#2018-04-1808:48cmalHi, @thheller . I updated to shadow-cljs 2.2.26 and shadow-cljs watch xxx takes 10-30 seconds when recompiling for a small project. It takes few seconds before that.#2018-04-1808:48thheller@cmal the first compile or all compiles? the first compile will invalidate all caches so thats going to be slower yes.#2018-04-1808:49cmalrecompile#2018-04-1808:49cmalI use shadow-cljs watch and every time I changed a cljs source file, it takes 10-30 seconds to recompile.#2018-04-1808:50cmalBuild completed. (1030 files, 2 compiled, 0 warnings, 15.31s) Does that mean all files are recompiled?#2018-04-1808:51thhellertry running with shadow-cljs watch app --verbose#2018-04-1808:51cmalok#2018-04-1808:52cmal
^Cshutting down ...
JS runtime disconnected.
Worker shutdown.
shutting down ...
shutdown complete.
shutdown complete.
when I try to stop watch
#2018-04-1808:52cmalI am restarting watch now...#2018-04-1808:53pezI got that too. Sometimes it works just hitting enter to get the prompt back.#2018-04-1808:53cmalIt is quick now..#2018-04-1808:53cmalBuild completed. (1030 files, 2 compiled, 0 warnings, 1.67s)#2018-04-1808:54cmal...#2018-04-1808:55cmalquick now even I connect the js runtime.#2018-04-1809:20thheller@cmal was 1.67s just the initial compile when watch started or is that your recompile time when you change a file?#2018-04-1809:44cmal1.67s is the recompile time, the first compile time is 10.33s. Before restart shadow-cljs watch the recompile time used to be 10-30s .#2018-04-1809:44thhellerI mean is it the hot-reload time?#2018-04-1809:44thhellerbuild complete ... change a file .. build complete#2018-04-1809:44thhellerwhat is the second time?#2018-04-1809:45thheller1.67s seems rather slow#2018-04-1809:45cmal
[:usercreatedata] Compiling ...
-> Analyzing Module: :app
<- Analyzing Module: :app (28 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: usercreatedata/views.cljs
<- Compile CLJS: usercreatedata/views.cljs (180 ms)
Cache write: usercreatedata/views.cljs
-> Compile CLJS: usercreatedata/core.cljs
<- Compile CLJS: usercreatedata/core.cljs (19 ms)
Cache write: usercreatedata/core.cljs
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (0 ms)
-> build target: :browser stage: :flush
-> Flushing 1030 sources
<- Flushing 1030 sources (81 ms)
-> Flushing unoptimized modules
<- Flushing unoptimized modules (64 ms)
<- build target: :browser stage: :flush (152 ms)
[:usercreatedata] Build completed. (1030 files, 2 compiled, 0 warnings, 2.79s)
#2018-04-1809:45cmalmy computer is slow.#2018-04-1809:45cmalbut 10-30s is problematic#2018-04-1809:45thhellerhmm those numbers don't match up?#2018-04-1809:46cmalbefore I restart shadow-cljs, it was 10-30s#2018-04-1809:46thhelleryes I understand. but that seems to fixed by the restart. I'm interested in why your code compiles are so slow#2018-04-1809:47cmalIt seems there are two shutting down two shutdown complete when I tried to stop the problematic shadow-cljs watch session , does that mean something is wrong?#2018-04-1809:47thhellernot sure but doesn't matter since the jvm exits after that#2018-04-1809:47cmal
^Cshutting down ...
JS runtime disconnected.
Worker shutdown.
shutting down ...
shutdown complete.
shutdown complete.
#2018-04-1809:47thhellerI think the shutdown hook might cause the print twice#2018-04-1809:47cmalNow I stop shadow-cljs there are only one` shutting down...`#2018-04-1809:48thhellerprobably a bug in the older version that got fixed#2018-04-1809:48thhellerI'm curious where the delay is coming from though#2018-04-1809:49thhellerif you add all those <- ... (152 ms) timing infos together#2018-04-1809:49thhelleryou don't get to 2.79s#2018-04-1809:49thhellernot sure where it is spending that time#2018-04-1809:52cmal😕#2018-04-1813:14javi"shadow-cljs": "^2.2.21" when adding as a dependency, and compiling with shadow-cljs watch mybuild it can't seem to find io's dependencies and starts asking me to install each one of them... anyone came across this?#2018-04-1813:28thheller@fj.abanses any chance you are trying to use on the client?#2018-04-1813:29thhellerI think on the client you must use socket.io-client#2018-04-1813:36javiummm, you may be right , i remember that from vanilla js...i am bored migrating a project and the cljsjs package for io never asked for that....#2018-04-1817:12justinleeI’m trying to understand the cljsjs compatibility layer. Is the following correct? (1) shadow-cljs ignores the :foreign-libs compiler directive, (2) instead it looks at package.json to extract information would would otherwise have been provided via :foreign-libs, (3) when a project imports a cljsjs dependency or provides a :foreign-lib wrapped package, what we must do in shadow-cljs is provide an empty namespace (of whatever name is expected) that does a :require using shadow-cljs syntax and does a goog.exportSymbol.#2018-04-1817:30thheller1) correct. 2) no, it just looks at node_modules directly. never looks at the project package.json. 3) yes. cljsjs packages typically provide some global variable, eg. cljsjs.react provides js/React. if you use (:require ["react" ...]) that would not provide the global so we need to export it separately for those still expecting to find a js/React#2018-04-1817:43justinleethanks great. i’ve always been fuzzy on this cljsjs thing and i finally get it now#2018-04-1817:51justinlee@thheller the reason I went down this rabbit hole is this comment https://github.com/thheller/shadow-cljs/issues/136#issuecomment-345230354#2018-04-1817:53justinleein theory, could promesa do some kind of :npm-deps declaration that would download bluebird instead of packaging it?#2018-04-1817:55thhelleryes, it could. deps.cljs {:npm-deps {"bluebird" "version"}}#2018-04-1817:57thhellerwell for shadow-cljs that would work. for most CLJS builds not so much.#2018-04-1818:01justinleeyea okay. they’re not going to want to do that… at least not until npm-deps actually works#2018-04-1818:01thhellerexactly#2018-04-1906:02emccueIm trying to get started with shadow cljs and im using the re-frame example#2018-04-1906:03emccueThe example works beautifully, and with the skeleton project.clj cursive picks everything up just fin#2018-04-1906:04emccuebut when I try to use semantic-ui-react I get a "Uncaught ReferenceError: require is not defined"#2018-04-1906:04emccueI am running through yarn watch#2018-04-1906:05cmal@thheller Yesterday's problem shadow-cljs watch app slow appear again: it takes a long delay before each of two Cache write: xxx/xxx.cljs , but the times are not reported.#2018-04-1906:06cmalshall I update the version of shadow-cljs first? 2.2.26 now#2018-04-1906:12cmalupdated to 2.3.0#2018-04-1907:03thheller@emccue you are using ancient versions in the project.clj. definitely upgrade all of them before continuing.#2018-04-1907:06thhellerlatest shadow-cljs is 2.3.0#2018-04-1908:58cmalmaybe because during shadow-cljs watch app1, I shadow-cljs release app2 (another app)?#2018-04-1909:01thheller@cmal not really. each build has its own cache directory so they don't interfere with each other#2018-04-1909:02thhellerthere could be one possible problem looking at the code#2018-04-1909:02thhellerdo you use cljs.spec in both apps?#2018-04-1909:03cmalonly in one#2018-04-1909:03cmalnot in the slow app.#2018-04-1909:03cmalapp1#2018-04-1909:04cmalI will keep one eye on this problem, and try to figure out what happens when it becomes slow.#2018-04-1909:04thhellercurrently the cache-write only logs when it completed, not when it started so I assume that the cache write itself is just slow since its not timed#2018-04-1909:05thhellerthe cache is potentially writing a lot of data.#2018-04-1909:05thhellercan you check how large the .shadow-cljs/builds/app1/dev/ana/your/ns.cljs.cache.transit.json is?#2018-04-1909:06thhellermaybe it is getting excessively large for some reason#2018-04-1909:06thhellerare you maybe running low on disk space? the OS might get into real trouble with the FS then#2018-04-1909:06cmaldu -sh 33M#2018-04-1909:07thhellerhmm thats normal#2018-04-1909:07cmalin /builds#2018-04-1909:07cmalFree disk space 15.8GB#2018-04-1909:07cmalits SSD#2018-04-1909:08thhellerhmm yeah thats all ok then#2018-04-1909:09thhellerI will expand the timing log for cache reads/writes so get more accurate infos about that#2018-04-1909:09thhellerbut still not a clue what could be causing this#2018-04-1909:10cmalOK. I'll keep on my using and see what happens when it becomes slow.#2018-04-1909:10cmalThank you so much.#2018-04-1913:38gnlHow can I use alternative artifacts providing the same namespaces and API in dev and production, e.g. day8.re-frame/tracing and /tracing-stubs?#2018-04-1913:39gnlIn leiningen it's generally done different :dependencies in each profile but that doesn't seem possible in shadow-cljs. Am I missing something?#2018-04-1913:39gnl^done with#2018-04-1914:33thheller@clojurians.net I think this approach is pretty terrible and yes with just standard shadow-cljs this is not possible#2018-04-1914:33thhelleryou can do it if you use lein or deps.edn#2018-04-1914:37thhellerI will look into what exactly the re-frame trace stuff is doing and see if there isn't an alternative way#2018-04-1914:47gnlThere's also https://github.com/philoskim/debux-stubs I'm not a great fan of it either, but it strikes me as the most reliable way to make sure that tracing/debugging code doesn't end up in a production build. It is theoretically possible to leverage Closure's dead code elimination for that, but I believe there have been issues with it in the past and it's quite a bit more messy and error prone.#2018-04-1914:48thhellerdevcards does this via :devcards true. this seems more suitable since its just a compiler options.#2018-04-1914:49thhellerI would not trust DCE fully either#2018-04-1914:50thhellerthe macro stuff could just eliminate based on the compiler setting#2018-04-1914:50gnlYeah that does sound cleaner. In the meantime, for projects that do it the other way, I'm guessing this would be the way to go: lein with-profile +<dev/prod> run -m shadow.cljs.devtools.cli ...#2018-04-1914:50thhelleryes#2018-04-1914:51gnlGreat, thank you.#2018-04-1915:51emccue@thheller it was an obvious fix but it worked, thank you#2018-04-1915:57thheller@emccue how come you picked that particular version? is it still used in an example somewhere?#2018-04-1917:27colindresjIs it possible to use preloads with :target npm-module?#2018-04-1918:20emccueYeah it was used in whatever example I pulled this from#2018-04-1918:20emccueooh#2018-04-1918:20emccueit is in the example project.clj#2018-04-1918:21emccue...somewhere#2018-04-1918:21emccuecrap#2018-04-1918:21emccueI dont know#2018-04-1920:09thheller@colindresj no since there is no clearly defined entry they should be preloaded for#2018-04-1920:14levitanong@thheller According to the shadow-cljs docs, i should be able to copy the some fulcro source file, place it in my own project matching the directory structure of where it would’ve been were it in fulcro, make some change, and it would be using that instead of the actual lib. It seems this file is being ignored. Are there any known gotchas about this? I’m specifically trying to work on fulcro.client.primitives.cljc. I’ll be going off to bed now. Dropping this message hoping to catch you during your day, because timezones.#2018-04-1920:15thheller@levitanong you mean fulcro/client/primitives.cljc#2018-04-1920:15thhellerslashes not dots#2018-04-1920:15thhellerand yes if you put it into your classpath like that it should work#2018-04-1920:29colindresjThat’s what I thought @thheller. Any idea how I might integrate https://github.com/Day8/re-frame-10x into a storybook build?#2018-04-1920:32danielcompton@colindresj not sure what a storybook build is, but there’s an example of this usage on https://github.com/jacekschae/conduit#2018-04-1920:35colindresjStorybook’s is a kind of like a react component dev environment @danielcompton. It’s a JS lib though, so I’ve been using the npm-module shadow target to get my cljs code to work with it, but now want to include re-frame-10x and I’m having a little trouble#2018-04-1920:36colindresjI tried just requiring the compiled re_frame_10x.preload namespace, but it I get some react rendering errors when doing that, something about vbox not returning a valid component#2018-04-1920:37thheller@colindresj I don't remember if it was possible to influence which files storybook loads. IIRC it is just looking for files with a regexp#2018-04-1920:37thhelleryou could probably just require re-frame-10x.preload in your stories namespace?#2018-04-1920:37colindresjYeah, that’s what I did#2018-04-1920:37thheller@danielcompton https://clojureverse.org/t/using-storybook-with-cljs/1495#2018-04-1920:38colindresjAnd namespace-wise everything seems good, but then I run into that react rendering errror, so I feel like something’s up#2018-04-1920:38thhellerdid you set the proper :closure-defines?#2018-04-1920:38colindresjYeah, and just for testing I removed it and got the 10x warning telling me to set closure defines#2018-04-1920:38colindresjSo, I think that part’s good#2018-04-1920:39thhellerhmm maybe something in re-frame-10x doesn't like how storybook loads the code?#2018-04-1920:39colindresjThat’s what I’m thinking, or vice versa#2018-04-1920:40colindresjFor reference, this is my error @danielcompton Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of day8.re_frame_10x.utils.re_com.v_box#2018-04-1921:45danielcompton@colindresj have you chosen the right version of re-frame which matches your React version?#2018-04-1921:47danielcomptonIf you can't get it working, open an issue with a reproduction#2018-04-1922:03colindresjOk, will do. Thanks#2018-04-2009:31pezI just fixed an unnecessary dependency on lein in the shadow-cljs support of Calva. I guess most people have lein installed. But anyway, now the integrated REPLs are started using the shadow-cljs command.#2018-04-2009:32thheller@pez neat. its still not possible to do custom UI in VSCode right?#2018-04-2009:33pezNo, sadly it isn't. And sadly they seem to have decided to let the REPL needs be served by those integrated terminals: https://github.com/Microsoft/vscode/issues/547#2018-04-2009:35thhelleryeah that sucks#2018-04-2009:35pezI am still hungry for feedback from anyone revving Calva up for a spin for shadow-cljs projects.#2018-04-2218:06alex-dixonThe key functionality I’d want (may be equivalent to brain surgery to do it in VSCode from what I understand) is the ability to highlight text, or put my cursor behind forms and press certain key combinations to send that to the REPL. If Calva has this already forgive me, but I think last time I checked I didn’t see it. Showing the results in the editor isn’t something I really care about at all as long as I can see the repl output somewhere for what I just evaluated#2018-04-2009:35thhellerI didn't have time to test it again yet#2018-04-2009:36pezWell, anyone, I do appreciate that you have tons of other things on your plate. 😃#2018-04-2009:40pezIf I could interview some people about their shadow-cljs workflows, that would be awesome.#2018-04-2009:42thhellerI can tell you mine briefly. run shadow-cljs server or lein repl (when working on shadow-cljs itself). connect to nREPL remotely. run everything else through the REPL.#2018-04-2009:43thhelleronly using command line for shadow-cljs release ...#2018-04-2009:44thhellerone neat feature of Cursive is that it allows you to define snippets of code to send to the REPL on keypress#2018-04-2009:44thhellerso I have snippets to start my server and stuff via keybinds#2018-04-2009:47pezSo you switch between builds using the REPL?#2018-04-2009:48thhelleryep#2018-04-2009:49pezUsing snippets?#2018-04-2009:49thhellerno, that I do manually#2018-04-2009:50pezOk. There is a concept of snippets in Code. I will look at what that is.#2018-04-2009:50thhellerdon't think thats the same#2018-04-2009:51thhellersee https://cursive-ide.com/userguide/repl.html REPL Commands#2018-04-2009:52pezMe neither. :face_with_cowboy_hat: It is probably more about boilerplate #2018-04-2010:01pezThanks for that link. Very helpful!#2018-04-2011:14heyarnecould it be that shadow-cljs watch isn't shutting down cleanly when stopped via CTRL + C?#2018-04-2011:15heyarneit happened to me for the second time that i ended up with two ghost proccesses (one in node and one in java); i only realized when i started another instance and experienced very weird bugs#2018-04-2011:15heyarnelike objects not satisfying interfaces anymore even though they were when testing it on the repl#2018-04-2011:16thhellerdo you have another watch running?#2018-04-2011:16thhellerdifferent build?#2018-04-2011:16heyarneno, just one build#2018-04-2011:17heyarneit also doesn't happen always (of course not, that would maybe even make it reproducible)#2018-04-2011:18thhellerwhich OS?#2018-04-2011:18heyarnecurrent macOS#2018-04-2011:18heyarne10.13.4#2018-04-2011:20thhellerI have no idea how they would interfere with each other on the client side though#2018-04-2011:20thhellerthe server leaving ghost processes has happened before#2018-04-2011:20thhellerstill not sure what causes it#2018-04-2011:23heyarneok. i'll see if i can collect more info if this happens again#2018-04-2011:23heyarnegreat tool though! thanks a lot#2018-04-2014:15gnl@thheller - about the thing we talked about yesterday - different dependencies in dev and release mode - I actually think this may not be worth looking into at all. The two projects I mentioned are actually one, because re-frame/tracing is a fork of debux and I'm not aware of any other projects that do this. Since there's a workaround for the current situation and it's not really a great idea to do it this way in general, I'd say no reason to waste time/energy on this, unless there's another important use case.#2018-04-2014:25javiI am making a quick editor helper with . Said library uses (js/require ... ) to include the acorn-jsx js parser. I have forked it to patch it, what would be the correct approach to make libs that use js/require universally compatible?#2018-04-2014:27achikinHi! Could someone point me at good explanation about the advantages of shadow-cljs? I wonder is it worth and is it possible to replace standard pipeline and figwheel with shadow?#2018-04-2014:34gnlhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/shadow-cljs-introduction.html#2018-04-2014:35gnlIt's possible and it works great.#2018-04-2014:35gnl(and so far I think it's worth it)#2018-04-2015:08heyarnebtw: because it's not quite clear in the docs and you said you needed help, cider works via cider-connect, and then opening a cljs-repl as described (`(s/nrepl-select :build-id)`)#2018-04-2015:08heyarnewhich is really really neat 🙂#2018-04-2015:09heyarnewhat doesn't work is refactoring. but i don't know how good refactoring is with cljs anyways, with jvm-clj it's quite good#2018-04-2015:10heyarne@achikin that's actually what i did. it's nice because interaction with the npm ecosystem feels very painless, also configuration is quite easy and mostly just works#2018-04-2015:13heyarnealso it feels like compilation is a bit quicker? maybe that's just subjective. biggest pluspoint for me is embracing npm, because i work in a team of frontend-webdevs and if it's on npm it's a bit less alien#2018-04-2015:28achikinThis is what I'm actually interested in - having better npm dependency management.#2018-04-2015:40heyarneworks. you just require npm modules as you would with clojurescript modules. only surprise i had was when working with d3 i was requiring a module (d3-requests i think?) and it gave me the nodejs version of the module whereas i was expecting the browser version.#2018-04-2017:18achikinI'm looking through the examples, listed in the README.#2018-04-2017:19achikinFor example here https://github.com/mhuebert/shadow-re-frame/blob/8d1bc1057e5b28dd8df6b34872a95a12a39a735a/package.json#L9 react is included in package.json dependencies. Why?#2018-04-2017:34justinleeshadow-cljs pulls in npm modules directly from the node_modules, so what you do is install them normally using npm or yarn and a package.json.#2018-04-2017:35justinleenote that cljsjs libraries (and some other libraries, like promesa) put the javascript in the jar and wrap it with a :foreign-libs declaration. but shadow-cljs doesn’t support foreign-libs, so it just fakes the namespace and continues to rely on node_modules#2018-04-2017:36justinleeI think this business of reading the javascript directly is why the externs inference works so well#2018-04-2021:32kanweihey, how do I run multiple builds at the same time?#2018-04-2021:33kanwei
shadow-cljs watch app1,app2
etc
#2018-04-2021:45kanweiright, just space between works
#2018-04-2100:21achikinActually reagent has React as cljsjs dependency. And if you download and compile the sample project above - you'll see that it pulls React from cljsjs. The question is - can I use :exclusions like in leiningen project setup to exclude that dependency?#2018-04-2104:35justinleeI don’t think you have to (but you can). The cljsjs dependency won’t actually import the JavaScript because shadow’s cljsjs shim doesn’t let it. That’s why you need it in the package.json. #2018-04-2107:14thheller@achikin it downloads cljsjs packages since it just follows the dependencies. It does not however ever use any cljsjs packaged code. Its just on the classpath, never in your build. You can exclude it from the deps if you care about that but it doesn't matter.#2018-04-2113:00achikinThank you for the explanations.#2018-04-2113:31achikinI see that I can have :dev and :release configuration options. But can I have dev dependencies? Or it does not make sense?#2018-04-2113:54thheller@achikin doesn't really apply to CLJS since the build decides what is used not the classpath#2018-04-2113:54thhellerthere is one exception currently which re-frame-10x does with some stubs#2018-04-2113:55thhellerif you need that you currently must use lein or deps.edn#2018-04-2113:55thhellerI'll try to talk them out of that approach when I find some time#2018-04-2113:59thhellerbut in general I find the pattern of using the classpath to replace certain namespaces horrible and annoying to work with#2018-04-2113:59thhellersee https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2018-04-2114:15mynomotoI talked to Daniel about re-frame-10x and read the tracing code and the conclusion is that there is no harm in not using the stubs. You need only to have the correct closure defines for dev and prod. The tracing is added using macros that use the closure defines to decide to do the tracing or use the core fn and defn.#2018-04-2114:26thhellerah good.#2018-04-2114:55justinleedoes the presence of warnings prevent hot swapping? i was doing a refactor and i have a bunch of warnings that i’m trying to fix and it seems like hot swap is off#2018-04-2114:55thhelleryes#2018-04-2114:58justinleeAt least I’m not losing it. Can I force a reload anyway or turn that feature off? Sometimes it is helpful to be able to iterate on code to get rid of the warnings. #2018-04-2114:58thhellernot currently but I can add if you like. open a ticket so I don't forget.#2018-04-2115:01justinleeGreat I’ll open a ticket when back to compy #2018-04-2117:34Alex H@thheller I keep running into all sorts of half-mangled stuff with the advanced optimisation and the JS-on-classpath stuff; some things in the node_modules that get imported by that JS don't get mangled, yet in that JS the same property name does get mangled#2018-04-2117:35Alex Hleading to all sorts of obscure bugs#2018-04-2117:35Alex H(and the check command doesn't show any of them)#2018-04-2117:36Alex Hnot sure if you have any suggestions, but in the meantime I've reverted back to simple optimisations; it's a bummer because I lose DCE, but at least things work 😛#2018-04-2119:13Alex H@thheller on a somewhat unrelated topic, how can I build a local test version from source of shadow-cljs? I managed to build it following the circleci setup, but it always tries to pull down the jar from maven/clojars, at least when I try and integrate that test version into the actual project I'm trying things on#2018-04-2119:30Alex HI've worked out something terribly hacky by copying the jar into the local ~/.m2 under a new version that doesn't exist, etc, but I hope there's a better way 😛#2018-04-2119:35Alex HI've tried hacking shadow-cljs so that it runs the js-on-classpath through closure/convert-sources-simple instead of closure/convert-sources, but perhaps unsurprisingly that doesn't really work, it doesn't recognize the es6 module export/imports#2018-04-2119:41Alex Hah, I see how that was misguided.#2018-04-2120:05thheller@alex340 do you have reproducable examples for the name mangling sometimes not working? seems like something the closure folks may be interested in#2018-04-2120:05thhellerif you mess with shadow-cljs just run lein install to install it locally#2018-04-2120:06Alex HI've been messing with options to closure/convert-sources#2018-04-2120:06Alex Htrying to disable optimizations, for example, but that doesn't fix anything; it just reduces the bundle size somewhat#2018-04-2120:07Alex HI don't have any nice factored-out examples of the mess I'm getting myself into with that name mangling, no. I might try that tomorrow#2018-04-2120:07thhellerif you change this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/resolve.clj#L145#2018-04-2120:07thhellerto (if false ... so that the other branch is always chosen#2018-04-2120:07thhellerall code will be converted like node_modules#2018-04-2120:08Alex HI shall try that now#2018-04-2120:08thhellerbut that has issues with interop between JS->CLJS#2018-04-2120:08thhellerCLJS can use the JS just fine but not the other way#2018-04-2120:08Alex Hah. I currently need interop both ways#2018-04-2120:09thhelleryeah thats a problem#2018-04-2120:10thhellerproblem is that shadow-js is not converted by closure#2018-04-2120:10thhellerso closure doesn't know what parts you use#2018-04-2120:10thhellerso it will rename everything#2018-04-2120:10Alex Hwell, it did compile with that, but I guess it won't actually work?#2018-04-2120:10Alex Hand the mangling issues are gone#2018-04-2120:10thhelleryeah because your .js files will still call cljs.core or whatever#2018-04-2120:11thhellerbut that will be named xC or so#2018-04-2120:11thhellerif you still do :simple that is fine#2018-04-2120:11Alex Hwell, with :simple even the other thing works#2018-04-2120:11thhellerso you don't call the CLJS from the JS?#2018-04-2120:12Alex HI do. I import some react components from the CLJS into JS#2018-04-2120:12thhellerhow do you import?#2018-04-2120:12Alex Himport { Toolbar as Toolbar_ } from "goog:dlt.components.editor.toolbar";#2018-04-2120:13thhellerhmm but that should be mangled all over the place?#2018-04-2120:13thhelleror did you ^:export that?#2018-04-2120:13Alex H(def ^:export Toolbar (r/reactify-component toolbar))#2018-04-2120:13Alex Hyep#2018-04-2120:14thhellerah ok yeah that can work to some extent then#2018-04-2120:14thhellerbut only if you call functions on it that are exported (or in externs)#2018-04-2120:14thhellerso in the case of react components that should be fine#2018-04-2120:15thhellerbut you are playing with fire there#2018-04-2120:15thhellerI wonder if the name mangling issues could be fixed#2018-04-2120:15thhellerI only did very basic tests with all of this and never had this problem#2018-04-2120:16thhellerbut you have taken this much farther than I ever did so far#2018-04-2120:16Alex Hthe hack with treating them the same as npm fails in practice, even though it compiles#2018-04-2120:17Alex Hit falls over on one of those imported react components#2018-04-2120:17thhelleryeah like I said .. playing with fire ... surprised it worked for the Toolbar thing but I guess export saved it#2018-04-2120:18Alex Hanyway. maybe the way forward is to see if closure compiler on its own on that js file, without any of shadow-cljs or any cljs in general around it, trips up#2018-04-2120:18Alex Hand, if so, it should at least be possible to report it upstream#2018-04-2120:18thhellercan you share the JS code that gets mangled? maybe there is a clue in there somewhere#2018-04-2120:19Alex Hcan do, yea#2018-04-2120:19Alex Hhttps://gist.github.com/bwalex/9967004ee9b7deb36d1a19d7d8f87fdb#2018-04-2120:19thhellermight also be some of my externs inference or other JS processing. maybe its just skipping over something important#2018-04-2120:19Alex Hnot exactly a piece of art.#2018-04-2120:20Alex Hthe latest thing that was tripping it up is mangling the "onlyIn" to "zG" or whatever, but not in the soft-break module#2018-04-2120:21thhelleris it always the React.createElement props getting mangled?#2018-04-2120:21Alex Hno, I mean that "onlyIn" thing is not on a react element#2018-04-2120:21Alex Hit sometimes is props, sometimes other object properties#2018-04-2120:21thhellerah right#2018-04-2120:22thhellerwell to be safe from mangling you could use 'onlyIn'#2018-04-2120:22thhellerbut that sucks writing by hand#2018-04-2120:22Alex HI know, and I've done that in a few places#2018-04-2120:22thhellerno idea why would rename some things and not others#2018-04-2120:22Alex Hbut it's hard to find all the problems in the first place#2018-04-2120:23Alex HI'd be happy to do that (or via externs) if shadow-cljs check printed those issues#2018-04-2120:23thhellershould be quick to find with shadow-cljs release app --pseudo-names or --debug#2018-04-2120:23thhellerI really don't understand why it doesn't#2018-04-2120:24Alex Hnever used closure compiler on its own, but I think I'm going to see if I can set it up on just that one file (removing the cljs dependencies)#2018-04-2120:24Alex Hletting it loose on just the js + npm bits#2018-04-2120:24thhellershouldn't affect anything#2018-04-2120:25thhellerCLJS it understands perfectly find and the npm bits it doesn't see#2018-04-2120:25Alex Hyea, I mean to get a nicer reproducer#2018-04-2120:25thhellerI wonder what the JS it generates for these files look like#2018-04-2120:25thhellermaybe in there is a clue somewhere#2018-04-2120:26thhellercan you compile (not release) and add the converted form to the gist?#2018-04-2120:27thheller<output-dir>/cljs-runtime/module$whatever$name$it$had.js#2018-04-2120:27Alex Hon it.#2018-04-2120:28thhelleror .shadow-cljs/builds/<build-id>/release/closure-js/file/name.js#2018-04-2120:28thhellerthats transit but it contains the compiled code as well#2018-04-2120:29Alex HI've added the transit file#2018-04-2120:30Alex Hlet me see if I can also add the other one#2018-04-2120:30thhellerhmm one other thing. you aren't actually writing this code by hand? it looks like it was pre-processed by babel?#2018-04-2120:30Alex Hyep, it has a bit of babel preprocessing to be able to use React#2018-04-2120:30Alex HThis is the babelrc:
{
  "presets": [
    ["env", {
      "modules": false
    }]
  ],
  "plugins": [
    "transform-object-rest-spread",
    "transform-class-properties",
    "transform-react-jsx"
  ]
}
#2018-04-2120:32thhellermaybe some of the babel stuff is confusing it. should not need the env preset#2018-04-2120:32thhelleronly the plugins#2018-04-2120:33Alex Hthe gist now also contains the file from the output dir/cljs-runtime#2018-04-2120:33thhellerah ok. already had it extracted from the transit 😉#2018-04-2120:34thhellerso I'm guessing that the check stuff just does not check any objects#2018-04-2120:34thhellersome props don't get renamed since they are standard props with externs in either react or just DOM/HTML generic stuff#2018-04-2120:37thhellerone thing you could do is add /** @nocollapse */ {onlyLn:[...]}#2018-04-2120:37thhelleror rather write a babel plugin to add it for all JSX calls#2018-04-2120:37thhelleryou can turn off name mangling completely#2018-04-2120:37thhellerbut that also turns it off for CLJS#2018-04-2120:38Alex HI thought you couldn't do that without also turning off DCE?#2018-04-2120:38thhelleryou can fine tune almost everything but yeah disabling one thing might prevent another thing from working#2018-04-2120:39thhellerI could do something crazy#2018-04-2120:41thhellerI wrote this closure pass. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure/PropertyCollector.java#2018-04-2120:42Alex His there some sane way of getting closure compiler (standalone) to pick up the stuff in node_modules?#2018-04-2120:42thhellerthe idea was to collect all properties assigned to module.exports = or exports.foo#2018-04-2120:42thhellerturn out to be pretty unreliable due do some of the dynamic stuff JS people do#2018-04-2120:42Alex Hsounds like you are suggesting adding externs for all properties that that thing finds#2018-04-2120:43thhellerit could however be used to collect every object property in those JS files#2018-04-2120:43thhellerand add them to the externs#2018-04-2120:43thhelleryep#2018-04-2120:44Alex Hsounds... crazy. but might just work#2018-04-2120:45thhellerwell it is used today#2018-04-2120:45thhellerjust maybe filtering too much#2018-04-2120:45thhellerwill see if it extract onlyIn for example#2018-04-2120:47thhellerhmm what the heck#2018-04-2120:47thhelleryes it extract all of them already#2018-04-2120:47thheller
{tmp/alex.js=[hasMark, data, handleListOpClick, plugins, focus, type, hasInline, collapseTo, renderNode, ref, fontFamily, leaves, typeCell, checked, text, href, state, fontWeight, editorDeserialize, showLinkModal, onChange, textAlign, constructor, alt, textDecoration, renderMark, readOnly, check, fontStyle, handleBlock, node, borderRadius, style, object, tableOp, onKeyDown, flexGrow, blockName, typeItem, handleHideLinkModal, document, editorStateFromText, className, typeDefault, title, renderEditor, writable, spellCheck, listOp, flex, enumerable, handleLinkButtonClick, handleTableOpClick, disabled, onlyIn, hasBlock, placeholder, value, key, __proto__, editor, padding, types, backgroundColor, editorSerialize, typeTable, src, typeRow, handleMark, flexDirection, display, onPaste, marks, renderToolbar, toggleMark, prototype, handleHeading, editorEmptyState, nodes, toggleBlock, decorateNode, nodeKey, Editor, configurable]}
#2018-04-2120:49thhellersomething must be missing#2018-04-2120:49thhellercan you check if you .shadow-cljs/builds/<build-id>/release/externs.shadow.js has them?#2018-04-2120:49thhellerthey should be in there#2018-04-2120:50Alex Hlet me see#2018-04-2120:50thhellerif they aren't there might be a bug and they just get lost#2018-04-2120:50Alex H❯ cat .shadow-cljs/builds/prod/release/externs.shadow.js | grep onlyIn ShadowJS.prototype.onlyIn;#2018-04-2120:50thhellercrap#2018-04-2120:52thhellercompletely forgot that I already do the "crazy idea" I just had#2018-04-2120:52thhellerI started by only adding export.foo props but that didn't work well enough so I added everything#2018-04-2120:52thhellerbut that seems to have limits as well#2018-04-2120:52Alex Hwait, so I just did another npx shadow-cljs release prod#2018-04-2120:52Alex Hand now that's not in there#2018-04-2120:53thhellerhahaha doh!#2018-04-2120:53Alex Hthat might have been from before's experiment still with that if to treat it as npm#2018-04-2120:53Alex Hsorry#2018-04-2120:53thhelleryes but that is it#2018-04-2120:53thhellerthe pass only runs for npm code#2018-04-2120:53thhellernot the classpath js#2018-04-2120:53thhellerwhen I just add it for classpath js it might just work#2018-04-2120:54Alex H(.addCustomPass CustomPassExecutionTime/AFTER_OPTIMIZATION_LOOP property-collector)#2018-04-2120:54Alex HI presume?#2018-04-2120:54thhelleryes but that just collects it from the JS#2018-04-2120:54Alex Hah, true.#2018-04-2120:55thhellerthey need to end up in the :js-properties set in the compiler state#2018-04-2120:55thhellerbut thats slightly more complex due to the caching stuff#2018-04-2120:57thhellerlet me see if I can code this together quickly#2018-04-2121:11Alex Hnot sure if my example is really representative, but closure compiler does the right thing on a super trimmed down version with just that slate-soft-break, at least if I use the Es6 module that slate-soft-break provides#2018-04-2121:11Alex Hah, no, it's not es6. never mind#2018-04-2121:11Alex Hbut it certainly did rename the onlyIn in both places consistently#2018-04-2121:12thhelleryeah if you feed everything to closure that will work#2018-04-2121:13thhelleryou can try :js-options {:js-provider :closure}#2018-04-2121:13thhellerthat will use it for everything#2018-04-2121:13thhellerbut its currently very unreliable#2018-04-2121:13thhellerand doesn't use ES6 code from node_modules#2018-04-2121:14Alex Hyea, that blows up#2018-04-2121:14Alex H[2018-04-21 22:14:11 - SEVERE] node_modules/hoist-non-react-statics/index.js:7: ERROR - The define function must be called as a top-level statement. typeof define === 'function' && define.amd ? define(factory) :#2018-04-2121:14Alex Hetc#2018-04-2121:14thhellerI know that it doesn't work for a whole bunch of stuff on npm#2018-04-2121:15thhelleryeah .. like that#2018-04-2121:15thhellerit is more reliable when only feeding it ES6#2018-04-2121:15thhellerbut barely any packages on npm provide that properly#2018-04-2121:15Alex Hyep, true#2018-04-2121:15thhellerso I have the propery-collector hooked up#2018-04-2121:16Alex Hsomehow I'm still puzzled why this stuff doesn't just work (TM); don't you end up feeding everything to closure compiler as well? sure, the node_modules stuff gets pre-processed through babel (& a first round of closure compiler?) but then it gets fed in to build it all together, doesn't it?#2018-04-2121:17thhellerno. the :shadow-js stuff (ie. node_modules) is never passed to the :advanced compile#2018-04-2121:18thhellerit is processed separately with :simple and then added to the final build AFTER :advanced#2018-04-2121:18thhellerfeeding it through :advanced destroys everything#2018-04-2121:18thhellertry master#2018-04-2121:18thhellerhttps://github.com/thheller/shadow-cljs/commit/e56ec0bcfaddc234bd82e767daf343fddd5377a0#2018-04-2121:19thhellerwasn't a whole lot of code but should do it#2018-04-2121:21Alex Hwell, unless I'm useless, I don't think that worked#2018-04-2121:21Alex Hthat said, it is a distinct possibility that I am useless#2018-04-2121:21thhellerdid you restart after lein install?#2018-04-2121:22thhellerand wipe .shadow-cljs/builds just in case#2018-04-2121:22thhellercache should have been wiped but you never know#2018-04-2121:22Alex Hdidn't have the server running, so that's not it#2018-04-2121:22thhellercheck if externs file includes it now#2018-04-2121:22Alex Htrying now after removing the .shadow-cljs dir wholesale#2018-04-2121:22Alex Hit didn't on the previous attempt just now#2018-04-2121:23thhellerjust you running lein install should invalidate all cache since the shadow-cljs jar changed#2018-04-2121:23thhellerso that probably doesn't do anything but you never know 😉#2018-04-2121:25Alex Hwell, I've added a println just above your changes for extra paranoia, and that's certainly getting printed#2018-04-2121:25thhellerah crap#2018-04-2121:26Alex Hyea, definitely not working. not getting into that externs file, and not affecting what closure compiler outputs#2018-04-2121:26thhelleryeah I'm stupid#2018-04-2121:26Alex Hat this point, I highly doubt that 😉#2018-04-2121:26thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure.clj#L208#2018-04-2121:27thhellerit is still only collecting those for :shadow-js 😉#2018-04-2121:28thhellerhmm something is not right#2018-04-2121:28thhelleryou can just comment out that line for a test#2018-04-2121:28Alex Hyea, on it#2018-04-2121:29thhellerwonder why I'm generating the externs that way and not just from :js-properties#2018-04-2121:30thhellerthe externs inference stuff uses that#2018-04-2121:30Alex Hit's in the externs now#2018-04-2121:30Alex Hand the output looks healthier indeed#2018-04-2121:30thhellerbut does it run? 🙂#2018-04-2121:33Alex Hyep, that seems to work#2018-04-2121:33Alex Hit runs and that particular feature isn't broken anymore#2018-04-2121:33Alex Hthanks for your help, yet again!#2018-04-2121:34thhellercool. I'll change the externs gen code to just use js-properties instead#2018-04-2122:04thheller@alex340 cleaned up master a bit. please try it when you get a chance. will create a proper release tomorrow. too tired to test this properly now.#2018-04-2206:06Alex H@thheller whatever that did, it doesn't work anymore#2018-04-2206:07Alex HonlyIn doesn't appear in externs.shadow.js anymore, and the generated code is mangled incorrectly, as before#2018-04-2207:28shakdwipeeaHi guys, I am using https://github.com/jgdavey/boot-shadow-cljs to compile cljs in a boot task. The compilation is fine and the files are written but they are not being picked up by server. To expand, I am using a ring server with site-defaults which is able to serve other resources but not the js files generated in the task.| The build config https://github.com/jgdavey/boot-shadow-cljs/blob/master/src/com/joshuadavey/boot_shadow_cljs.clj#L88 produced in the task is
{:target :browser, :output-dir /home/akash/.boot/cache/tmp/home/akash/workspace/voidwalker/gw3/-fmvxaj/resources/public/js, :asset-path /js, :compiler-options {:optimizations :simple}, :modules {:app {:entries [voidwalker.source.app]}}, :id :app, :build-id :app, :cache-root /home/akash/.boot/cache/cache/project/home/akash/workspace/voidwalker/com.joshuadavey.boot-shadow-cljs/cache}
When accessing the file.. I get response map is nil. My shadow-cljs.edn
{:source-paths ["src/cljs"]

 :nrepl {:port 55000}
 :http {:port 9070
        :host "0.0.0.0"}


 :dependencies [[reagent "0.8.0-alpha2"]
                [reagi "0.10.1"]
                [funcool/bide "1.6.0"]
                [cljs-ajax "0.6.0"]
                [proto-repl "0.3.1"]
                [day8.re-frame/http-fx "0.1.3"]
                [hickory "0.7.1"]
                [re-frame "0.10.5"]
                [cider/cider-nrepl "0.17.0-SNAPSHOT"]
                [refactor-nrepl "2.4.0-SNAPSHOT"]]

 :builds {:app {:target :browser
                :output-dir "resources/public/js"
                :asset-path "/js"
                :compiler-options {:optimizations :simple}
                :modules
                {:app
                  {:entries [voidwalker.source.app]}}}}}
What should I look into?
#2018-04-2207:35shakdwipeeaGot it ... the fix was to set output-dir to public/js since that is what is served. :man-facepalming:#2018-04-2208:00thheller@alex340 sorry shouldn't write code when tired. should be fixed in master.#2018-04-2210:33Alex H@thheller yep, that seemed to work#2018-04-2210:33Alex H@thheller thanks!#2018-04-2218:15alex-dixonWhoops. Disregard! https://github.com/thheller/shadow-cljs/wiki/Calva#2018-04-2222:01gnlWhen hot-reloading a namespace with shadow-cljs, vars which have been removed from the code remain defined (similar to sending the whole thing to the REPL). When hot-reloading with figwheel they are removed. Can I get that behaviour with shadow-cljs?#2018-04-2222:18gnlFor example if I have a test defined in a namespace with deftest and remove or rename it, the old version's still there and gets executed with (run-tests).#2018-04-2320:17thhellerthis should be fixed as of {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a3d0cbc2c7ccd48ec0cfc9d0e3918d908d91"}, :content ("[email protected]")}#2018-04-2302:21steveb8nHi everyone, over the weekend I knocked up https://github.com/stevebuik/Stu#2018-04-2302:21steveb8nstill lots of work to be done, including better docs but feel free to download and try it out#2018-04-2302:22steveb8nI’ll log issues today for all the roadmap stuff. then we’d really appreciate any help with PR’s to make Stu even more powerful#2018-04-2315:32teawaterwireI'm using shadow-cljs in a project and I noticed a steep increase of compile time when I added some npm deps: before:
[:app] Compiling ...
[:app] Build completed. (338 files, 2 compiled, 0 warnings, 0.81s)
[:app] Compiling ...
[:app] Build completed. (338 files, 2 compiled, 0 warnings, 0.94s)
I added:
(:require ["firebase/app" :as firebase]
          ["firebase/auth"]
          ["firebase/database"])
And now I'm seeing smth like:
[:app] Compiling ...
[:app] Build completed. (592 files, 2 compiled, 0 warnings, 5.14s)
[:app] Compiling ...
[:app] Build completed. (592 files, 2 compiled, 0 warnings, 4.44s)
How could I mitigate that and keep the same developper experience? 🙂
#2018-04-2315:32thhellerwhich version? did some tweaks recently which should have fixed that#2018-04-2315:33teawaterwire2.3.0#2018-04-2315:34thhellercan you run with shadow-cljs watch app --verbose please and tell me where the time is going?#2018-04-2315:37teawaterwirehum restarting the shadow server and now I'm back to the fast compilation 🤔#2018-04-2315:38thhellerhmm you are the second to report this now. no idea what might be happening.#2018-04-2315:41teawaterwireto be fair, I think I kept the shadow server running for 3 days 😅 — it reported some errors but kept running:
[2018-04-22 18:56:31 - WARNING] classpath update failed
...
clojure.lang.ExceptionInfo: failed to inspect cljs file
#2018-04-2315:44teawaterwireshould I update to 2.3.1 ? while I'm at it 😁 : do we need the local npm install of shadow even though it's installed globally?#2018-04-2315:44thhelleryes, always in the project#2018-04-2315:47teawaterwireok, thanks! 👍#2018-04-2316:24lilactownif I wanted to develop + release a cljs lib - should I use leiningen for that?#2018-04-2316:24thhellerfor the final lein deploy yes 😉#2018-04-2316:28lilactownis there any example/boilerplate around that I could follow?#2018-04-2316:29thhellerthe usual lein instructions I guess#2018-04-2316:29lilactowni’ve honestly never tried to release a pure cljs lib before#2018-04-2316:29lilactownI don’t need to compile it for release, right?#2018-04-2316:30thhellerno, no compiled code at all. only the source files#2018-04-2316:30thheller
(defproject your/lib "version"
  :dependencies
  [...]
  :source-paths
  ["src"])
#2018-04-2316:30thhellerthen lein deploy clojars#2018-04-2316:31thhellerif you are using the resources dir make sure its empty and doesn't inlude anything compiled#2018-04-2316:31thhellerotherwise it will end up in the .jar#2018-04-2316:31thhelleryou can run lein jar and then jar -tvf target/your-lib-version.jar to verify what is in it#2018-04-2316:34thhellerhttps://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md#2018-04-2316:34thhelleryou can add
:repositories
  {"clojars" {:url ""
              :sign-releases false}}
if you don't want to deal with the gpg stuff
#2018-04-2317:01bhauman@thheller whats the list of "on-reload" client side hooks are you using again?#2018-04-2317:06lilactownthx thheller!#2018-04-2317:11thheller@bhauman for ns :dev/always -> :figwheel-always and :dev/once -> :figwheel-noload#2018-04-2317:11thhellerthe :figwheel-* are also supported, so either works#2018-04-2317:11bhaumanI was thinking the meta data on client side reload hooks#2018-04-2317:12bhauman@thheller#2018-04-2317:12thhellerah https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2018-04-2317:12thhellerso :dev/before-load + :dev/before-load-async to call before reloading any code#2018-04-2317:12thheller:dev/after-load + :dev/after-load-async#2018-04-2317:13bhauman@thheller cool thanks!#2018-04-2323:27lilactownI just upgraded to 2.2.31. Seeing this now in my Node.js build:
shadow-cljs - Using IP "10.240.18.219" from Interface "utun1"
Apr 23, 2018 4:23:05 PM shadow.cljs.devtools.server invoke
INFO: Found multiple IPs, might be using the wrong one. Please report all interfaces should the chosen one be incorrect.
and in the app itself:
REPL client error { Error: connect ETIMEDOUT 10.240.18.219:9630
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
  errno: 'ETIMEDOUT',
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: '10.240.18.219',
  port: 9630 }
REPL client disconnected
#2018-04-2323:51lilactown2.2.29 seems to work fine. 2.3.0 also exhibits this behavior#2018-04-2403:26alex-dixonAnyone able to run 2.3.2?#2018-04-2406:46thheller@lilactown what interfaces are reported?#2018-04-2406:47thhellerI added IP detection since react-native stuff needs to be able to connect to the shadow-cljs server remotely#2018-04-2406:47thhellerneeds to be filtered smarter I guess#2018-04-2407:06thhellerwow sorry everyone .. the update from yesterday certainly broke some stuff#2018-04-2407:43thheller2.3.4 should be better#2018-04-2408:34raymcdermottI’m struggling to run a REPL with Cursive - I have followed the guide but still am a bit stuck#2018-04-2408:34thhellerwhats the problem?#2018-04-2408:34raymcdermottI can’t load CLJS files into a REPL#2018-04-2408:35thhellerwhat is the error?#2018-04-2408:36raymcdermottit says I can’t load a CLJS file into a CLJ REPL#2018-04-2408:36raymcdermottso maybe I’m not ticking a box somewhere#2018-04-2408:37thhellerwhat steps did you do? is the watch running? did you nrepl-select it?#2018-04-2408:37raymcdermottwhat is nrepl-select#2018-04-2408:38thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage#2018-04-2408:38raymcdermottLOL, OK let me give that a shot#2018-04-2408:45raymcdermott[:no-client :script “Make sure your JS environment has loaded your compiled ClojureScript code.“]#2018-04-2408:46raymcdermottI have configured nrepl port in the edn config#2018-04-2408:47javi@raymcdermott have you
(require '[shadow.cljs.devtools.api :as shadow])
  (shadow/nrepl-select :build-id-to-focus-on)
in the clj repl after it starts?
#2018-04-2408:47raymcdermottand ran shadow-cljs watch script on the command line#2018-04-2408:47raymcdermottI have#2018-04-2408:47thheller> Make sure your JS environment has loaded your compiled ClojureScript code.#2018-04-2408:47thhellerdid you?#2018-04-2408:47thhellerah wait you are building a commend line script right?#2018-04-2408:48raymcdermottyes a CLI on top of node#2018-04-2408:49thhellerright. so you probably want to use shadow-cljs node-repl + (shadow/nrepl-select :node-repl) for this#2018-04-2408:49thhellerif the devtools were injected into your script#2018-04-2408:49thhellertheir websocket connection would keep the script running even after your work was done#2018-04-2408:49thhellerso the script would never exit#2018-04-2408:50thhellernode-repl is just a standalone node-repl not tied to any build#2018-04-2408:50thhelleryou can just (require 'your.script) and work as usual#2018-04-2408:50raymcdermottyes, that works!#2018-04-2408:51raymcdermottI can now load forms directly from the editor#2018-04-2408:51raymcdermottthanks#2018-04-2410:42gnl@thheller Do you have a preferred policy on bringing up shadow-cljs issues on Slack first vs. straight to GitHub or just play it by ear?#2018-04-2410:43thhellerprobably github. slack tends to get lost when I'm busy elsewhere.#2018-04-2413:22fatihictHello, I am trying to set up clojurescript spec instrumentation with shadow, but I am running into an issue. I added an fn in the after-load hook in my shadow-cljs.edn which calls instrument. I am getting spec errors for existing specs, but when I add a new spec I don't see anything. Can anyone help me with this issue?#2018-04-2413:32wilkerlucio@fatihict if you call instrument manually after the js is reloaded, it works?
#2018-04-2413:41fatihictI just tried your suggestion @wilkerlucio, but I don't see any messages in my devtools of the new spec I defined.#2018-04-2413:44wilkerlucioI'm just wondering if that's a issue of "timing" or maybe something else#2018-04-2413:46fatihictYeah, I also really wonder what the issue could be. I did try to define about 20 new specs, so it doesn't look like a timing issue.#2018-04-2413:56thheller@fatihict instrument is a macro so if the code must be recompiled in order for it to update which specs to instrument#2018-04-2413:57thhelleryou can force recompilation of the namespace that has the instrument call via (ns ^:dev/always that.ns ...)#2018-04-2414:05fatihict@thheller I also tried your suggestion, but it unfortunately doesn't solve my issue#2018-04-2414:06thhellerif you look at the browser console when loading code#2018-04-2414:06thhelleris your instrument file loaded before or after the code that contains the specs?#2018-04-2414:07thhellerif its loaded before that probably is the reason#2018-04-2414:09thhellerinstrument in CLJS only works on vars that are compiled BEFORE instrument is compiled.#2018-04-2414:11fatihictMy instrument file is loaded after the code that contains the specs.#2018-04-2414:16thhellerwhat specs are you testing with?#2018-04-2414:16thhelleryou might need to set :compiler-options {:static-fns false} in your build config#2018-04-2414:21fatihictI am currently testing with this:
(defn bla [x]
  (+ 1 x))

(s/fdef bla :args (s/cat :x number?))
And calling the function with a string to trigger an error
#2018-04-2414:23fatihictI also wrapper the call the instrument with a println and I noticed that the new specs I add are not included in the output of instrument#2018-04-2414:24fatihictI will try adding static-fns to my compiler options now#2018-04-2414:29fatihictAdding static-fns did not fix the issue either#2018-04-2414:29thhellerhow are you testing then exactly?#2018-04-2414:30thhellerare you sure the code running the tests is actually run after calling instrument?#2018-04-2414:30thhellereg. this won't do any spec checking#2018-04-2414:30thheller
(defn bla [x]
  (+ 1 x))

(s/fdef bla :args (s/cat :x number?))

(bla 1)
(bla "foo")

(st/instrument)
#2018-04-2414:32thhellereg. in your after-load function when calling instrument. if you call a specced function and that does not properly validate thats a bug. anything else is probably an issue related to when things happen.#2018-04-2414:32thhellerthe instrument macro is kinda icky to use in that regard#2018-04-2414:35fatihictI'm calling instrument and afterwards refreshing my fulcro application. In my application I have a call to the mentioned bla function.#2018-04-2414:37thhellerso to recap. you have an (ns ^:dev/always some.thing (:require [your.app :as x] [cljs.spec.test.alpha :as st]))#2018-04-2414:37thhellerwhich has a funtion that calls (st/instrument) and then (x/reload)?#2018-04-2414:38fatihictYes#2018-04-2414:41thhellerI just tested this#2018-04-2414:41thheller
(ns ^:dev/always demo.instrument
  (:require
    [demo.browser :as x]
    [cljs.spec.test.alpha :as st]))

(defn ^:dev/after-load instrument []
  (st/instrument)
  (js/console.log "instrument called")
  (x/bla 1)
  (x/bla "foo"))
#2018-04-2414:41thhellerin demo.browser I only added the defn bla no spec#2018-04-2414:41thhellerthen added the spec, saved the file, let live reload do the thing. and the spec failed as expected?#2018-04-2414:50fatihict@thheller That works for me as well. if I require the namespace where I have defined the spec in my instrument file it works, but not if I don't#2018-04-2414:50kanweiHow do I get :output-wrapper for production builds?#2018-04-2414:51kanweiputting it in :builds/:compiler-options/:output-wrapper still doesn't wrap#2018-04-2414:51thheller@kanwei :modules {:main {:entries ... :prepend "(function() {" :append "})();"}}#2018-04-2414:52kanweiI saw an add-wrapper fn in the source code, is that not exposed somehow?#2018-04-2414:52thhellerdon't think I added :output-wrapper as a simplified version of the above. all my builds use multiple modules where you kinda can't use a wrapper#2018-04-2414:54kanweihttps://github.com/thheller/shadow-cljs/blob/84e922780a7cca293cd3015f7b2fa9a8c36c4d22/src/main/shadow/build/cljs_closure.clj#L1958#2018-04-2414:54kanwei?#2018-04-2414:55thhellerthis is just cljs.closure copied from CLJS to fix one particular bug. it is not used at all.#2018-04-2414:55kanweiFor a lot of people, output-wrapper has caused problems since non-wrapped fn's can shadow (ha) other vars. Large discussions on the other library pages: https://github.com/boot-clj/boot-cljs/issues/64#2018-04-2414:56thheller@kanwei I'm well aware why :output-wrapper is useful. also gave you the solution you can use for now. same effect.#2018-04-2414:56thhellerthe issue is that as soon as you use multiple :modules the :output-wrapper breaks things#2018-04-2414:57kanweiI appreciate that, just trying to point out things people will run into#2018-04-2414:57thhellercould probably add support for it and just fail when multiple modules are configured#2018-04-2414:57thhellerfeel free to open a github issue so I don't forget to add it later#2018-04-2414:58kanwei👍#2018-04-2414:59wilkerlucio@fatihict so, you have to require it in some way, I guess it was the first thing tomas said, you have to force the ns that define the spec to be loaded before instrument, otherwise it will not work#2018-04-2415:00kanweialso is there any way to turn on :parallel-build for the cljs compiler?#2018-04-2415:00thhellerits always on#2018-04-2415:00thhellerno way to turn it off actually#2018-04-2415:01kanweik#2018-04-2415:10fatihict@wilkerlucio Is there a way to force the ns that has the spec to be defined without requiring it? Requiring every namespace with specs in my instrument namespace is not the best solution#2018-04-2415:12wilkerluciowell, it only has to be reloaded if changes, so if you save a spec file, that file should be reloaded before your after-load gets called, thats when I'm getting confused, because if it does so, then it should work @fatihict#2018-04-2415:33thheller@fatihict it should be fine to only require your :entries ns since that will have required everything else?#2018-04-2416:34wilkerlucio@thheller I'm experimenting with some auto-test setup using Shadow and Karma, I see the configuration outputs a single file, I can watch on shadow and karma and get some auto-test running, but it always runs all the tests, do you think would be possible to have something more localized? like generating multiple files and running parts of then, kind like Jest does (in case you know it)#2018-04-2416:37thheller@wilkerlucio definitely possible with some code that doesn't exist yet 😉#2018-04-2416:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/karma.cljs#L107 just need to filter somehow here#2018-04-2416:41thhellernever used Jest#2018-04-2416:54wilkerluciohumm, interesting#2018-04-2416:54wilkerlucioJest has a very cool test runtime, for instance, it can re-run only failing tests until they pass#2018-04-2416:55wilkerluciothen he can run the full suite after the tests get fixed, and it provides interactive commands if you wanna re-run things at anytime (one key shortcuts on the readline of the process)#2018-04-2417:02thhellermight be possible to just use Jest?#2018-04-2417:03wilkerlucioI'm really considering it, but there are downsides...#2018-04-2417:04wilkerlucioJest runs on node environments only, not in the browser#2018-04-2417:04thhellerdon't have time to look into that currently but shouldn't be hard given that storybook also just works#2018-04-2417:04wilkerlucioalthough JS community has a lot of tools to deal with that (for testing react things on node), I still think running in the browser is more reliable, and we can do real DOM testing#2018-04-2417:05wilkerlucioso, I'm thinking between having a great dev experience for testing vs been able to use real DOM on tests#2018-04-2417:06wilkerluciobut on the Jest that would be a lot of things to wrap before it gets smooth from a CLJS perspective#2018-04-2418:18wilkerluciohello, I got some weird thing, I tried removing the clojurescript from my deps, and now when I try to compile I'm getting this:#2018-04-2418:18wilkerlucio
shadow-cljs - config: /Users/wilkerlucio/Development/fulcro-shadow-boot/shadow-cljs.edn version: 2.3.5
shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch test
Exception in thread "main" java.lang.RuntimeException: No such var: ana/cacheable-files, compiling:(shadow/build/cljs_closure.clj:569:19)
	at clojure.lang.Compiler.analyze(Compiler.java:6792)
#2018-04-2418:19thhellerwhich CLJS version did you get? probably an old one.#2018-04-2418:19thhellerI make no guarantees for anything when running through lein#2018-04-2418:20wilkerluciohow can I know the version it got?#2018-04-2418:23thhellerlein with-profile cljs deps :tree#2018-04-2418:27wilkerluciook, found it, was fulcro-spec, thanks#2018-04-2419:36justinlee@thheller have you published your workflow with cursive? from various tidbits i get the sense that you must run your watch command from the terminal (or maybe from the repl?)#2018-04-2419:37thhellerREPL#2018-04-2419:37justinleei’m thinking there’s a better way than what i’m doing, which is to run the watch from the cli and then scroll all over the place to look at errors/warnings#2018-04-2420:26fatihict@thheller @wilkerlucio By the way, thanks for your help today. I haven't fixed my issue yet, but will update you once I know more 🙂#2018-04-2511:15raymcdermottI am trying …. for a CLI app to provide options & usage#2018-04-2511:16raymcdermottthere are two excellent node libs command-line-args and command-line-usage#2018-04-2511:16raymcdermottcommand line-args integrates very easily#2018-04-2511:17raymcdermottbut am having some trouble with command-line-usage#2018-04-2511:19raymcdermotthas anyone seen this before?#2018-04-2511:34thheller@raymcdermott are you not using :target :node-script?#2018-04-2511:34raymcdermottyes#2018-04-2511:34raymcdermottI am using that#2018-04-2511:35raymcdermottstandard stuff afaik#2018-04-2511:35thhellerright, sorry I was confused for a sec.#2018-04-2511:36thhellerthis is using the code directly from node_modules without any processing#2018-04-2511:36thhellernot really sure why it would fail#2018-04-2511:36thhellerdo you maybe call it with nil?#2018-04-2511:38raymcdermottI don’t think so …. checking#2018-04-2511:39thhelleryou can try running node package/main.js --inspect-brk and then turn on pause on exceptions#2018-04-2511:39thhellerthen check the stack to see what value was used to call the failing function#2018-04-2511:40raymcdermottUNKNOWN_OPTION: Unknown option: --inspect-brk#2018-04-2511:40thhellernode --inspect-brk package/main.js ?#2018-04-2511:41raymcdermottyes#2018-04-2511:41thheller should show the node process then#2018-04-2511:45raymcdermottit gives an error on domain.js#2018-04-2511:45raymcdermottNOENT#2018-04-2511:47thhellerno idea. doesn't seem to be the exception you are looking for. does it work if you just let it run again?#2018-04-2511:48raymcdermottno, then same error on bootstrap_node.js#2018-04-2511:48raymcdermottthen module.js#2018-04-2511:48raymcdermottthen internal/module.js#2018-04-2511:49raymcdermottthen the error I posted#2018-04-2511:49thhellerthat is misleading, the error occurs while your code is LOADING not while it is executing#2018-04-2511:49thhellerprobably because you run the function directly#2018-04-2511:49raymcdermottoh yes, I do that#2018-04-2511:50thhellerif you run it inside vouch-admin-cli.main/main the exception might be clearer#2018-04-2511:50raymcdermottit runs inside main#2018-04-2511:51raymcdermottsorry, misunderstood what you meant there#2018-04-2511:51thhelleroh right sorry.#2018-04-2511:53thhellerok bascially what happens is that shadow-cljs appends a file that contains (vouch-admin-cli.main/main ...)#2018-04-2511:53thhellerthis causes your main function to run#2018-04-2511:53thhellerand your main function throws#2018-04-2511:53thhellerbecause shadow-cljs was still loading the file it is one the stack#2018-04-2511:53thhellerbut it has nothing to do with shadow-cljs#2018-04-2511:54thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/node_bootstrap.txt#L49-L50#2018-04-2511:55raymcdermottso is it the transitive dep?#2018-04-2511:55thhellerno. it just seems to confuse the debugger#2018-04-2511:55raymcdermottoh#2018-04-2511:55thhelleryou should get to node_modules/command-line-usage/lib/chalk-format.js:8:13 in the debugger#2018-04-2511:56thhellerdon't know why it would show module.js and the other stuff#2018-04-2511:56raymcdermottI do#2018-04-2511:56thhelleroh?#2018-04-2511:56raymcdermottit’s giving str = undefined#2018-04-2511:57raymcdermottwhich is the arg being passed it#2018-04-2511:57thhellerchrome should show the stack#2018-04-2511:57thhellerjust go up the stack until you see how it got to be undefined#2018-04-2511:58raymcdermottdoing…#2018-04-2512:00thhellerhmm#2018-04-2512:00thhellernpx shadow-cljs node-repl#2018-04-2512:00thheller(ns foo.bar (:require ["command-line-usage" :as x]))#2018-04-2512:00thheller
(x (clj->js [{:header  "My CLI"
              :content "Manage your environment"}
             {:header     :Options
              :optionList [{:name        "create-xxxx"
                            :alias       :c
                            :typeLabel   "{underline name}"
                            :description "Create xxxx with that name"}
                           {:name        "help"
                            :alias       :h
                            :description "Print this usage guide."}]}]))
#2018-04-2512:01thheller
"
 My CLI\r
 \r
   Manage your environment \r
 
 Options\r
 \r
   -c, --create-xxxx name   Create xxxx with that name \r
   -h, --help               Print this usage guide.    \r
 "
#2018-04-2512:01raymcdermottI have some entries without a :description key#2018-04-2512:01raymcdermottand that breaks it !#2018-04-2512:01thhellerha!#2018-04-2512:02raymcdermottif only JS had spec#2018-04-2512:02thhellerhehe#2018-04-2512:02raymcdermottthanks vm for your help#2018-04-2512:02raymcdermottwould have wasted a shit ton more time#2018-04-2512:02raymcdermottand I know I can debug with chrome now 🙂#2018-04-2512:06raymcdermottI’m still loving those libs though#2018-04-2513:28gravIs it possible to specify dependencies directly from github?#2018-04-2513:51dimahttps://clojure.org/guides/deps_and_cli#_using_git_libraries#2018-04-2515:21troglotitI think what OP meant was if it's possible with regards to shadow-cljs not deps.edn#2018-04-2514:49Ivan FedorovHi Channel! Is there an tutorial entry on how to combine server clj run by leiningen with shadow-cljs? In a manner of how figwheel does that I can do a tutorial entry for that, if you explain. p.s. the tool is awesome, great thanks to the author and conrtibutors UPD: found a proper example, thanks#2018-04-2519:54thheller@grav it is possible if you use deps.edn. directly from shadow-cljs no#2018-04-2521:40donmullen@thheller even though shadow-cljs didn’t make top two to be funded by clojurists together - good to see it come in a strong #4 - good exposure. Perhaps next round! https://www.clojuriststogether.org/news/q2-2018-funding-announcement/#2018-04-2521:41danielcomptonYeah it was a good application and we would have liked to fund it if we had more money#2018-04-2610:40daveliepmannHi folks, I'm replicating https://github.com/shadow-cljs/expo-test and want to make sure I am on the right page. I'm able to get the DemoApp running in the Expo app on my iOS device, but it displays (and live-reloads) text from the JavaScript source rather than what I see in the ClojureScript source ("Hello World from CLJS! 1"). Is this expected?#2018-04-2610:53thheller@daveliepmann not sure I understand what you mean? which javascript source?#2018-04-2610:56daveliepmannApp.js#2018-04-2610:56daveliepmannat expo-test/DemoApp/App.js#2018-04-2610:56thhellerthat is unused?#2018-04-2610:57thhellerare you running the react-native things? they don't need to be running#2018-04-2610:57thheller> Do not run ANY of the printed instructions.#2018-04-2610:57daveliepmannI don't believe I'm running the react-native things, because I didn't run any of the printed instructions#2018-04-2610:58daveliepmann(I did the first time I went thru the README, but have stopped them and restarted my machine since then)#2018-04-2610:58thhellerhmm maybe something is cached then somewhere?#2018-04-2611:45daveliepmannI think I've cleared the cache successfully and am experiencing the same issue. I now suspect it could be that I was unable to download a version of the iOS app that supports QR codes, so I am loading the app on iOS thru the Expo desktop app.#2018-04-2612:01daveliepmanntrying now with manually sending link#2018-04-2610:58daveliepmannhmm#2018-04-2610:58thhellerrn cache not shadow-cljs cache#2018-04-2610:59daveliepmannright#2018-04-2610:59daveliepmanninvestigating#2018-04-2610:59thhellergot a work call now. I'll be back in a bit.#2018-04-2611:00daveliepmannno worries, thanks for the quick response#2018-04-2611:27gravCan I get shadow-cljs to generate a handler function for use with AWS Lambda? When configuring a Lambda function on AWS, I can specify a handler like myFile.myHandler, which magically makes AWS look for exports.myHandler in myFile.js.#2018-04-2611:44thheller@grav :node-library does this. :exports {:myHandler your.ns/handler}. so it is basically exports.myHandler = your.ns.handler;#2018-04-2611:56gravgreat!#2018-04-2611:57gravI tried adding something like the last statement directly to the generated js, but it didn’t work. I’ll use the :exports way#2018-04-2611:58thhelleryou'll need to use release builds with AWS though. it probably wont unterstand the dev stuff#2018-04-2611:58gravI did generate it using shadow-cljs release. Must’ve done something else wrong.#2018-04-2612:03grav@thheller works perfectly with :exports. Thanks!#2018-04-2612:06zarkonehi! sorry, completely new user here. Just tried to do this:
(ns live.client.components
  (:require
   [reagent.core :as r]
   #
and I get The required namespace "live.client.components" is not available, it was required by "filemporium/client/live.cljs".
#2018-04-2612:07zarkonewithout reader conditionals compilation seem to work fine, i.e. I get warnings from this namespace#2018-04-2612:13grav@zarkone Two things about reader conditionals - I’m pretty sure the @ shouldn’t be there scratch that - I’ve never seen :node before and can’t find it documented. I’m not sure you can discern on compile-time? On run-time you could ask if some node-specific api exists#2018-04-2612:14zarkonethanks, tried also with :node#2018-04-2612:14thheller@zarkone only one branch is taken when you use reader conditionals#2018-04-2612:14zarkonealso, @ is for splicing here, taken from https://groups.google.com/forum/#!topic/clojure-dev/8YJJM8lJuQs#2018-04-2612:15zarkonewill try out now without it#2018-04-2612:15thhellerI suspect that you want to take the live.client.subscriptions always?#2018-04-2612:15grav@zarkone yes, you’re right, didn’t know about that one 🙂#2018-04-2612:16zarkone🙂#2018-04-2612:16thhellerThe required namespace "live.client.components" is not available happens when the compiler failed to parse the ns form#2018-04-2612:16zarkone@thheller no, even without any code I still get the same error#2018-04-2612:16zarkoneyes, it seems like that#2018-04-2612:16thhelleroh hehe#2018-04-2612:16thhellerlive.cljs#2018-04-2612:17thhellerreader conditionals only work in .cljc files#2018-04-2612:17thhellerthat should definitely show a better error#2018-04-2612:17zarkonewow, right! this is components.cljs#2018-04-2612:18zarkonethank you, hope to figure out such things by myself next time 🙂#2018-04-2612:19thhellernp. I think the feature isn't properly documented at all yet since Core is kinda against it and declined the feature request#2018-04-2612:19thhellerso kinda keeping it hidden 😉#2018-04-2612:21zarkonesorry, Core of what? you mean that we can't extend reader conditionals on plain clj/cljs ?#2018-04-2612:21zarkoneno, it's actually pretty obvious -- I just haven't used cljc for some time#2018-04-2612:21thhellerCore as in the Clojure/ClojureScript projects.#2018-04-2612:22thhellerhttps://dev.clojure.org/jira/browse/CLJS-2396 this was declined#2018-04-2612:22thhellerI don't want to promote a feature that doesn't work officially in CLJS#2018-04-2612:23thhellerbut I needed it so its in there 😉#2018-04-2612:24zarkoneyes, I think I've came across this earlier. I actually think that yes, clj/cljs "isomorphic" compilation is usefull, but node/browser/etc separation is mandatory, i.e. more important.. so not sure why this was declined 😞#2018-04-2612:25zarkoneI was even thinking about switch back to cljx before I knew about shadow-cljs. thank you very much!#2018-04-2620:04kanwei@thheller not sure the new output-wrapper is working, still getting no wrapping even in 1-module builds#2018-04-2620:08thheller@kanwei didn't make a new release yet. its only in master for now. probably make a new release in a bit. just got home.#2018-04-2620:09kanweioh, it was tagged 2.3.8 so I thought it was in#2018-04-2620:09kanweicool#2018-04-2621:29kennyThe ES6 Import to CLJS Require table (https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages) has been helpful but I can't seem to get a particular package to work, and my knowledge of JS packages is quite limited. I am trying to use react-countup (https://github.com/glennreyes/react-countup#usage). I have added react-countup "3.0.3" to my package.json and npm install'ed. I have ["react-countup" :as countup] required in my ns. countup/CountUp is undefined though. If I look at the countup object itself, I can see a few functions defined: formatNumber and startAnimation but not the class: https://github.com/glennreyes/react-countup/blob/master/src/index.js#L105. I must be missing something simple here.#2018-04-2621:36kennyAh, I believe because their import is import CountUp from 'react-countup';, I do not need to do countup/CountUp. It should just be available under countup.#2018-04-2621:36kennyi.e.
(:require ["react-countup" :as countup])

;; this is the React component? 
countup
#2018-04-2621:39kennyA closer reading of the bits below the table yields the answer 🙂 It's actually this:
(:require ["react-countup" :as countup])

;; this is the React component
countup/default
#2018-04-2622:24thheller@kanwei just pushed 2.3.9 which has :output-wrapper. also documented it here: https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper#2018-04-2622:26thheller@kenny (:require ["react-countup" :default CountUp]) would be the translation of import CountUp from 'react-countup';#2018-04-2622:27thheller:default is definitely confusing#2018-04-2622:27kennyRight, but I don't really like the whole :refer-esque approach. I much prefer to use aliases.#2018-04-2622:28thhellertrue but be aware that the default import/export in ES6 has special meaning and might not always be /default in the future.#2018-04-2622:29thhellerunlikely that is going to change anytime soon but it might#2018-04-2622:29kennyThat's frustrating.#2018-04-2622:29thhelleragreed but unfortunately the JS world decided that it is going to be this way 😞#2018-04-2622:30kennyThe default thing seems silly to me. It saves two whole characters when import'ing. Perhaps I don't fully understand the advantage of it.#2018-04-2622:32thhellerin ES6 the default export is technically a standalone variable. it is not part of the object you would get with :as. The .default property only exists to make things compatible with CommonJS require. strict ES6 does not have this.#2018-04-2622:33kennyBleh.#2018-04-2622:33thhellerits pretty annoying ...#2018-04-2622:34kennyI'll begrudgingly use the :default syntax in the :require 😣#2018-04-2622:35kennyIs there a way to rename it? I was hoping to name my Reagent component CountUp as well.#2018-04-2622:36thhelleryou can use whatever name you want for it#2018-04-2622:36thheller(:require ["react-countup" :default Foo]) works just fine#2018-04-2622:36kennyOh, that makes sense.#2018-04-2622:36kennyThanks!#2018-04-2622:39thhellerbe aware that standard ES6 still has not accepted :default so you might actually be better off using countup/default for the time being if you care about compatibility. https://dev.clojure.org/jira/browse/CLJS-2376#2018-04-2622:42kennyIs David's comment there mostly wanting to wait for ES6 to accept (or not) :default?#2018-04-2622:52thhellerDavid is very hesitant to add features that are not in Clojure which is reasonable. Given that JS is so different I do not agree with several of his choices however. I fully expect to change his mind about this with time.#2018-04-2623:08thheller@kenny turns out I'm actually wrong. .default is part of the spec. Just re-read the spec and it is definitely defined as a getter.#2018-04-2623:09thheller:default is still useful though so that doesn't change#2018-04-2623:09kennySo I'd be safe using myalias/default?#2018-04-2623:09thhelleryes#2018-04-2623:10kennyGood to know. I'd definitely prefer that over the ns :default syntax just because I like aliasing things over referring them.#2018-04-2623:11thhelleryeah agreed. it just gets tiring to see thing/default everywhere depending on what JS you are working with#2018-04-2623:11thhellergiven that many JS files only have the default export and nothing else#2018-04-2623:12kennyTotally agree. I just created a def in my project so I don't need to do exactly that.#2018-04-2623:13thhellerbtw :default Foo is just syntax sugar for :rename {default Foo} so that also works in CLJS#2018-04-2702:54cjmurphy@thheller I use a tool with cljs-shadow that requires an entry in [:devtools :preloads]. This tool reads from its own .edn configuration file. The same tool works with Figwheel and the instruction was to (reload-config) after making changes to the configuration file. Is there an equivalent command for cljs-shadow? What worked for me was to rm -rf the builds directory.#2018-04-2707:52zarkonehi, I have another dumb question about cljc! so, I've defined a few lines in .cljc file:
#?(:node-script (.log js/console (str "HAHAHAHA.1")))
#?(:browser (.log js/console (str "HAHAHAHA.2")))
#?(:cljs (.log js/console (str "HAHAHAHA.3")))
and I also have this in build conf:
:reader-features #{:node-script}
:target :node-script
but I get only :cljs branch compiled, for some reason. Tried to use :node instead, same result
#2018-04-2708:06thheller@cjmurphy which tool is that?#2018-04-2708:07thheller@zarkone :compiler-options {:reader-features #{:node-script}}#2018-04-2708:09zarkone@thheller sorry, this one also was obvious >..< But now I better understand how it works. Thank you!#2018-04-2708:11thhellerI'll probably add a section about it in the docs. It is a useful feature after all.#2018-04-2708:13zarkoneyes, it is, definitely! Currently porting our SPA app to SSR, quite tough task, but I think it would be impossible at all without complete rewriting without this conditional features#2018-04-2708:14thhelleryeah thats what I used it for too. although I abandoned the SSR idea half way through. couldn't live with having to do JS on the server 😉#2018-04-2708:16zarkoneyes, but I just don't know any other solution in my case: we have SPA app and now "it turns out" that we need SEO to actually be crawler-friendly and etc#2018-04-2708:17zarkoneeither completely different codebase, doing html version for crawlers or something like this.#2018-04-2708:20thhellerSEO with just plain SPA can work but it seems to take google longer to index this and doesn't work at if you send out too many requests and such#2018-04-2708:20thheller+ bing and others definitely don't index SPAs properly#2018-04-2708:20thhellerso yeah HTML is probably the safest option#2018-04-2708:24zarkoneyes, so decided at least give this nodejs react server renderer a try, if not -- will have to rollback to this second idea#2018-04-2708:25thhellerhttps://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157 I replicated their results basically with one exception in 3. Google never recognized dynamically generated JSON-LD metadata#2018-04-2708:27thhellerbut definitely try the node server renderer and blog about your experience#2018-04-2708:27thhellermaybe you have more patience than I did 😉#2018-04-2708:29zarkonehaha) you suggest to add yet another tutorial article about server-side rendering to feed trolls? 🙂 ok, sounds nice -- at least, I haven't seen the one with shadow-cljs, AFAIR#2018-04-2708:29zarkonethanks!)#2018-04-2708:30thhellerhehe 😉#2018-04-2708:33troglotitWhat is the correct way specify shadow-cljs version in package.json and shadow-cljs.edn? Should they match 100% time or is it redundant to have it in shadow-cljs.edn#2018-04-2708:33thhellernot required in shadow-cljs.edn at all. it will pick whatever version is installed by npm so only package.json matters.#2018-04-2708:34thhellerdon't need to specify a clojurescript or clojure version either.#2018-04-2709:14thheller@zarkone wrote a bit of documentation here for future reference https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-04-2709:20zarkoneLooks great in my opinion! All the problems I've faced so far were touched. Thank you! :)#2018-04-2710:28cjmurphy@thheller Its a tool I use with Fulcro that catches anytime the state becomes de-normalized: https://github.com/chrismurrph/default-db-format. Currently it is written mainly assuming users use Figwheel.#2018-04-2710:31thheller@cjmurphy see https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache :cache-blockers#2018-04-2710:31thhelleryou'll probably need to add the default-db-format.prefs since that does a side-effecting read of the config file#2018-04-2710:33thhellerdeleting all the cache is kind of a nuclear option and not really required. since its only about that one single thing.#2018-04-2711:15jhey @thheller im trying to compile a node-script as such
//shadow-cljs.edn
{:builds {...
   :target :node-script}}

$ shadow-cljs release <script-id>
and based on the documentation it's supposed to output some single-file stand-alone script. But when I take it out of the directory it was built and put it inside a new dir, it won't run. I've tried to debug the problem and it seems that use the nodejs require as such:
shadow.js.shim.module$react_dom$server=require("react-dom/server")
So I then figured that maybe I can use the :js-options :shadow and I did but now I'm stuck because while it works on the watch mode it will fail on release. I'm running it likeso:
$ shadow-cljs release <script-id> --debug

IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
	clojure.lang.RT.seqFrom (RT.java:550)
	clojure.lang.RT.seq (RT.java:530)
	clojure.lang.APersistentMap.cons (APersistentMap.java:40)
	clojure.lang.RT.conj (RT.java:670)
	clojure.core/conj--5112 (core.clj:85)
	clojure.core/merge/fn--5679 (core.clj:3041)
	clojure.core/reduce1 (core.clj:936)
	clojure.core/reduce1 (core.clj:926)
And I have no idea how to debug from this 😞
#2018-04-2711:17thheller@j it outputs a single file yes. it however still requires the node_modules files since node will load these. so if you move the file you need to move it together with the package.json and install the deps in a new location.#2018-04-2711:18thhellerit is not currently supported to bundle all deps since that would significantly reduce the number of packages you'd be able to use (ie. nothing with native deps)#2018-04-2711:19thheller:js-provider :shadow can work in theory but I never tested it in combination with :node-script#2018-04-2711:20thheller"stand-alone" in the docs mean that shadow-cljs is not required after the file is compiled. it does not mean that node_modules will be bundled.#2018-04-2711:21thhellerI can take a look at making :js-provider :shadow work with :node-script later but as I said this severly limits the number of packages you'll be able to use.#2018-04-2711:23thhellerI will clarify this in the docs.#2018-04-2711:25jThanks for the quick reply, and it seems that the quick solution is just to include a package.json. Either way, great work on this tool! 🙂#2018-04-2711:25thhelleryep that is best#2018-04-2711:26thhellerI typically create an extra :output-to "out/foo.js" directory with a dedicated out/package.json file that only contains stuff actually required to run the script. eg. no devDependencies.#2018-04-2711:26thhellereg. shadow-cljs itself is published this way https://github.com/thheller/shadow-cljs/tree/master/packages/shadow-cljs#2018-04-2713:31davidwam I right in thinking using the path to a jsfile within an npm package in the require e.g.
(ns foo.core
  (:require ["jsonld/dist/jsonld.js" :as jsonld]))
and using :js-options :resolve to redirect the require e.g.
:js-options {:resolve {"jsonld" {:target :npm
                                  :require "jsonld/dist/jsonld.js"}}}
(ns foo.core
  (:require ["jsonld" :as jsonld]))
should be equivalent?
#2018-04-2713:32steveb8nhi everyone. I’ve made significant progress on Stu this week. check out the latest. https://github.com/stevebuik/Stu#2018-04-2713:33steveb8ntomorrow I will deploy to clojars and log issues so anyone willing to help know where to start#2018-04-2713:33steveb8nI’d appreciate any feedback#2018-04-2716:49thhellerlove the pre-closure toggle. the switch for compressed however is a bit useless since everything should always be zipped the the other number is a bit irrelevant. unlikely you gzip one release but not the other.#2018-04-2716:50thhellerstill not a super fan of the tree-map display. hard to make out any actually useful info.#2018-04-2716:51thhellerhttp://npm.anvaka.com/#/view/2d/shadow-cljs found this today. I like it very much.#2018-04-2716:52thhellerdefinitely need to trim some deps for shadow-cljs 😉#2018-04-2722:42steveb8n@thheller Good to know. Are you able to state the questions that you are trying to answer? That will enable me to know what new features you and others would find valuable#2018-04-2716:17colindresjI followed the guides for :target :karma, and the shadow-cljs build goes through fine, but when doing karma start I’m getting a reference error require is not defined#2018-04-2716:18colindresjRunning on shadow-cljs 2.3.10 and configs look like this:#2018-04-2716:35thheller@colindresj require is not defined where? any chance your code has a js/require call somewhere?#2018-04-2716:36thheller@davidw yes that is equivalent when using :target :browser#2018-04-2716:40colindresj@thheller in my output file (`test-ci.js`). Line looks like this: shadow.js.shim.module$react = require("react");#2018-04-2716:42thhelleroh the extra resolve toggled something off
#2018-04-2716:42thhellerjs-options isn't getting merged it is replaced#2018-04-2716:42colindresjAh, I was thinking it had something to do with that#2018-04-2716:42thhelleroops. you can temp fix it by adding :js-options {:js-provider :shadow :resolve ...}#2018-04-2716:42thhellerwill fix that in next release#2018-04-2716:42colindresjCool, will do#2018-04-2716:43colindresjThanks#2018-04-2716:58colindresjAs an aside, I thought shadow was the default provider @thheller #2018-04-2716:58colindresjIs it target specific?#2018-04-2716:58colindresjActually that makes sense — for node is probably require, etc#2018-04-2716:58thhelleryeah :shadow is only the default for the :browser, otherwise :require#2018-04-2717:39thheller@davidw I reported the jsonld error here https://github.com/google/closure-compiler/issues/2909#2018-04-2718:37sveriHi, I have a dependency that requires the jquery cljsjs package. So I added th jquery.cljs file in the cljsjs package like this:
(ns cljsjs.jquery
  (:require ["jquery" :as jquery]
                 ["$" :as jq]))

(js/goog.object.set jquery "$" jq)
(js/goog.exportSymbol "jquery" jquery)
The first error: The required namespace "cljsjs.jquery" is not available, it was required by "re_pressed/impl.cljs". is gone, but now it complains about $: `The required JS dependency "$" is not available, it was required by "cljsjs/jquery.cljs". Any idea how to reference that? My code above does not work.
#2018-04-2718:49sveriThanks to @gadfly361 I have this working now:#2018-04-2718:49sveri
(ns cljsjs.jquery
  (:require ["jquery" :as jquery]))

(js/goog.exportSymbol "jQuery" jquery)
#2018-04-2718:56davidw@thheller good to know about the reported issue. We ran into that and are working around it by using the jsonld/dist/jsonld.js require redirect but that wasn't working with our :target :karma build where we got require is not defined errors running the tests. It worked when I put the path in the require directly which seemed strange, hence the question. So it looks like we were running into the same issue as @colindresj#2018-04-2718:58thheller@davidw yeah thats my bad. should be fixed in the 2.3.11 release I just pushed. or just add :js-provider :shadow to your :js-options.#2018-04-2719:00thheller@sveri $ is only the variable, it is not an npm package. you can just add the additional (js/goog.exportSymbol "$" jquery) if you like#2018-04-2719:01sveri@thheller I got it working without the $ line. I already added a PR: https://github.com/thheller/shadow-cljsjs/pull/6 Thanks for putting all that together.#2018-04-2719:01thhellerah excellent. thx.#2018-04-2719:07sveri@thheller thanks for the instant release, I just included the updated version and it works, awesome. Do you have a automatic build set up?#2018-04-2719:08thhellernot really. but its just lein deploy clojars so pretty quick to do.#2018-04-2821:56tony.kayI’m trying to get css reload working, but It doesn’t seem to want to. I’ve got devtools working normally, using an absolute path to the CSS in the link tag, but when I update the CSS, no hot reload happens.#2018-04-2822:16tony.kayAh, figured out the problem. I’m trying to server files with .min.css, and the extension code in fs-watch uses index-of to find the dot…so multiple dots confuse it.#2018-04-2822:17tony.kayso, it works with files that have no other dots, but fails with files that contain dots beyond the extension.#2018-04-2906:21steveb8n@thheller I learned something interesting using Stu today. Using a minified d3.js makes no difference to overall artifact size. Does this make sense? And is it d3 specific or is this generally true for npm deps?#2018-04-2906:22steveb8nyou can see what I mean in the latest sample app comparing 0.9 and 1.0 https://htmlpreview.github.io/?https://github.com/stevebuik/Stu/blob/master/resources/public/stu-builds.html#2018-04-2906:29mjmeintjesJust saw that you added "Conditional Reading" (not sure when that was added) - that is a really useful feature, and will make node/browser code much easier, thanks.#2018-04-2906:29mjmeintjesMy unrelated question: is it possible to manually trigger hot code reloading, and stop the automatic load on file save?#2018-04-2907:38thheller@tony.kay will use last-index-of in next release.#2018-04-2907:41thheller@steveb8n everything from node_modules is minimized by Closure :simple optimizations yes. It sometimes even makes already minified stuff smaller but going out of your way to specifically select minified builds is not required no.#2018-04-2907:43thhellerthe bundle process has a bit of overhead per file though. so getting something minified over lots of files is better but not really required. overhead is small and might get smaller over time since I didn't try to optimize the overhead at all yet#2018-04-2907:46steveb8nthat’s good to know. I didn’t realise that :simple provided so much value#2018-04-2907:46steveb8nI’ll probably revert that minified change in that case. provides no extra value#2018-04-2907:47thheller@mjmeintjes yes it is possible. how would you want to trigger the reload though? (shadow/watch :app {:autobuild false}) will disable the automatic reloading.#2018-04-2908:33mjmeintjesNot really sure what the best solution would be, but I thought about triggering reloading from repl if that was possible.#2018-04-2908:33thhelleryep, just added API fns for that#2018-04-2908:34thheller(shadow/watch-compile-all!) to trigger a recompile on all running watches#2018-04-2908:34thheller(shadow/watch-compile! :app) for a single build#2018-04-2908:35thhellerlooking into one other thing and will make a release then#2018-04-2908:35mjmeintjesExcellent, thanks!#2018-04-2908:43mjmeintjesAnother thing: I've been testing out the new cider version's integration with shadow-cljs, and it mostly works great. Using their function cider-create-sibling-cljs-repl, I can easily create a javascript shadow-cljs repl. This works, but the only problem is that The only slight "snag" I've run into is that shadow-cljs exits with [:no-client :devcards "Make sure your JS environment has loaded your compiled ClojureScript code."] if I try to create the repl before first loading the web page. But, of course I can't, because cider-create-sibling-cljs-repl also starts the watch and compiles the code (it runs (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :%s) (shadow/nrepl-select :%s))). Is there a way to disable the initial check for connected JS environment?#2018-04-2908:44mjmeintjesI can create an issue if that is too complicated to discuss here.#2018-04-2908:44thhellerI fixed that in a recent version#2018-04-2908:44thhellerI thought the check would make things more user friendly. turns out it did the opposite 😉#2018-04-2908:44mjmeintjesGreat - very likely that I'm running a few versions behind - you seem to move very fast.#2018-04-2908:46mjmeintjesI must add that with the new cider improvements integrating shadow-cljs, the development story of ClojureScript is becoming really great. Thanks for all the work! :+1:#2018-04-2909:03thheller@mjmeintjes pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "eb98838a8f849cc688878198abd9c5d8c5dad9"}, :content ("[email protected]")}. if you start using the triggered compile I'd love some feedback about that. I have often though about using that myself since file watching seems to do a lot of unnecessary compiles. just to lazy to set it up.#2018-04-2911:26mjmeintjesI'm testing out the triggered compile now. I works great, the only problem I've found is that if I trigger a recompile, and nothing has changed, then the hud reloading image does not go away. I've opened up an issue for this.#2018-04-2915:28gnlThat's brilliant, was thinking just yesterday that this would be great to have and now here it is. \o/#2018-04-3007:41mjmeintjesI'm trying to figure out shadow-cljs' web worker support. I've set up the :modules, with a :worker modules that depends on :main and has :web-worker true. However, when I try to start my webworker, I get the following error: index.js:1 Uncaught ReferenceError: shadow$provide is not defined. This happens in the following line: shadow$provide["module$node_modules$object_assign$index"] = function(global,process,require,module,exports) {. Am I doing something obviously wrong?#2018-04-3010:31thheller@mjmeintjes should be fixed in 2.3.13.#2018-04-3017:39kennyThe nrepl.port file does not seem to be located in target/shadow-cljs/nrepl.port. Do I need to set a config value to get shadow-cljs to create it?#2018-04-3017:39thheller@kenny should be .shadow-cljs/nrepl.port. target/shadow-cljs was used in old versions.#2018-04-3017:40kennyGotcha. I ran into target/shadow-cljs here: https://github.com/thheller/shadow-cljs/wiki/Cursive#connecting-to-a-shadow-repl#2018-04-3017:41kennyIs symlinking still the recommended way to get nrepl to work with Cursive?#2018-04-3017:41thhellernah. I would recommend setting a fixed nrepl port and connecting to that#2018-04-3017:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2018-05-0103:37mjmeintjesIs it possible to use Conditional Reading for web-worker contexts? For example, I'm using prosemirror in one of my files. Unfortunately, prosemirror expects a global document variable, which is not available in web worker context. This makes it impossible to require the prosemirror namespace, because it throws an exception inside the webworker. I can definitely restructure the app into separate modules, but before doing that I just wanted to check because the Conditional Reading option would be much easier.#2018-05-0106:30mjmeintjesNo worries, just solved it by patching the underlying prosemirror library.#2018-05-0108:29thheller@mjmeintjes no it only works per build. restructuring the modules is the way to go I think#2018-05-0109:15thhellerhttps://twitter.com/DefnPodcast/status/991238980174798848#2018-05-0109:50pezI am trying to see if we can port Calva to Clojurescript one file at a time. But I’m having troubles getting the require to work for requiring JS files. I have structured the src directory the same way as under *Requiring JS* in the User Guide: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2018-05-0109:51thhellerrequire is very problematic. ES6 works much better if you can use that instead#2018-05-0109:52pezNot sure I follow. It is (:require []) I don’t get to work.#2018-05-0109:53thhelleroh. how so?#2018-05-0109:55pezTrying to require a file utilities.js at the root of the src/js directory from a cljs file in a subdirectory to src/main. But whatever I type except for "utilities" fails, Shadow says no:
The required JS dependency “../utilities” is not available, it was required by “repl/message.cljs”.
#2018-05-0109:55thhellerhmm might be a bug in the resolver code#2018-05-0109:56thhellertry ./../utilities?#2018-05-0109:56pezTried it, didn’t work. Even tried /../utilities 😃#2018-05-0109:57thhellerah hang on. the JS handling currently hides JS errors pretty badly#2018-05-0110:01pezI asked shadow-cljs to be verbose, but it doesn’t give any more clues to this particular issue.#2018-05-0110:01thhelleryeah hang on. looking into it#2018-05-0110:01pezHanging on. Many thanks!#2018-05-0110:02thhellerwhich config are you using?#2018-05-0110:02pez
{:source-paths
 ["src/main"]

 :dependencies
 [[org.clojure/core.async  "0.4.474"]
  [cider/cider-nrepl "0.16.0"]
  [org.clojure/tools.nrepl "0.2.12"]]

 :builds
 {:calva
  {:target :node-library
   :output-dir "out-cljs"
   :output-to "src/js/main.js"
   :exports {:message repl.message/message}
   :modules {:main {:entries [repl.message]}}
   :devtools {}}}}
#2018-05-0110:05pezrepl.message/message is a map with symbols from the module. I am hoping I can access that map from js code.#2018-05-0110:07thhelleruhm did you reorganize your files?#2018-05-0110:07thhellerI just forked master https://github.com/PEZ/clojure4vscode#2018-05-0110:08thhellerare the JS files still in src but you added a src/main?#2018-05-0110:08thhellerah#2018-05-0110:08thhellerhttps://github.com/PEZ/clojure4vscode/blob/wip-cljs-toolchain/shadow-cljs.edn#2018-05-0110:09thhellersrc/js must also be in :source-paths#2018-05-0110:09thhellerbut don't do :output-to "src/js/calva/main.js"#2018-05-0110:10thheller:output-to "dist/calva.js" or so and then use that as the main in package.json#2018-05-0110:12pezThanks. The problem with where to output-to is that main in package.json must remain ./src/js/extension for now.#2018-05-0110:13thhellerthat won't work though#2018-05-0110:15pezSo I must start with converting extension.js then maybe…#2018-05-0110:15pezNow I get this:
[:calva] Build failure:
NullPointerException:
	shadow.build.classpath/find-js-resource (classpath.clj:1017)
	shadow.build.classpath/find-js-resource (classpath.clj:998)
	shadow.build.resolve/eval14123/fn--14126 (resolve.clj:192)
	clojure.lang.MultiFn.invoke (MultiFn.java:243)
	shadow.build.resolve/resolve-string-require (resolve.clj:227)
	shadow.build.resolve/resolve-string-require (resolve.clj:210)
	shadow.build.resolve/resolve-require (resolve.clj:393)
	shadow.build.resolve/resolve-require (resolve.clj:386)
#2018-05-0110:16thhellerI just got it to compile fine with
{:source-paths
 ["src/cljs"
  "src/js"]

 :dependencies
 [[org.clojure/core.async  "0.4.474"]
  [cider/cider-nrepl "0.16.0"]
  [org.clojure/tools.nrepl "0.2.12"]]

 :builds
 {:calva
  {:target :node-library
   :output-to "dist/calva.js"
   :exports {:message repl.message/message}
   :modules {:main {:entries [repl.message]}}
   :devtools {}}}}
#2018-05-0110:16thhellerhow do I run this though?#2018-05-0110:16pezOpen the project in Code and hit F5.#2018-05-0110:17pezThat’s what I have too, except that I removed the :modules map. Will try with putting it back.#2018-05-0110:18thhellerno don't it isn't used#2018-05-0110:18thhelleronly :exports is relevant#2018-05-0110:18thhellerok I got the NPE. tring to figure out what that is all about#2018-05-0110:19thhellerah hehe#2018-05-0110:19thhellerdoh#2018-05-0110:19thhellerdo you really want separate classpaths?#2018-05-0110:20thhellerYou could just use src/main or something and put everything in there#2018-05-0110:20pezProbably not.#2018-05-0110:20thhellerthe problem is that the files are at the top-level#2018-05-0110:21thhellerI would suggest making a src/main/calva folder and putting all the files in there#2018-05-0110:21thhellersrc/main/calva/utilities.js and so on#2018-05-0110:22pezTrying it.#2018-05-0110:22pezDo I need the main?#2018-05-0110:23thhellerno but it is generally considered best practice in the JVM world#2018-05-0110:23thhellerso you can add src/test src/dev and so on later#2018-05-0110:23pezMakes sense#2018-05-0110:24thhellerfixing the NPE now#2018-05-0110:33thhelleryeah so the main problem you are going to run into the the use of require and module.exports#2018-05-0110:34pezWhat should I use instead?#2018-05-0110:34thhellerES6 import/export#2018-05-0110:35pezThanks. Is this what is causing the NPE?#2018-05-0110:35thhellerno the NPE is caused by the top-level file#2018-05-0110:36thhellerso it is in /utilities and then tries to resolve ./state#2018-05-0110:36thhellerit first tries to get the parent of /utilities which is nil#2018-05-0110:36thhellerit expects there to be a folder 😛#2018-05-0110:37pezSo if I use source path src/main and the namespace calva.repl.message it might work?#2018-05-0110:37pezThat’s a nicer namespace anyway. 😃#2018-05-0110:38thhellerso there are two parts to this problem#2018-05-0110:38thhellerwho is in charge of the build and who is in charge of loading the code?#2018-05-0110:38thhellerit works best if shadow-cljs has control over both equally#2018-05-0110:39thhellerthe problem with your current approach is that shadow-cljs is building it but vscode is loading it differently#2018-05-0110:40thhellerconst { message } = require('../../calva/main');#2018-05-0110:40thhellerthis breaks#2018-05-0110:40thhellerbecause the compile file is a completely separate universe basically#2018-05-0110:41thhellerwith ES6 you can do import X from "goog:calva.repl.message";#2018-05-0110:41thhellerbasically directly refer to a CLJS namespace#2018-05-0110:42thhellerhmm don't know how to explain this in a simple example#2018-05-0110:42pezThat is what I wanted to do to begin with.#2018-05-0110:43thhellerthe goog: prefix is a special syntax from the closure compiler to access namespaces#2018-05-0110:43pezI will look ES6 some more.#2018-05-0110:43thhellerso I imagine you want to rewrite this one file at a time#2018-05-0110:43pezYes, that is the “plan”.#2018-05-0110:44thhellerand JS + CLJS talking to each other#2018-05-0110:44thhellerso the CLJS can import the JS and JS can use the CLJS#2018-05-0110:44thhellerfor this to work properly you need ES6 import/export#2018-05-0110:44thhellerwhich should be a simple translation#2018-05-0111:05pezYeah, I should have been starting that translation long ago.#2018-05-0111:07pezA minimal cljs main entry point which just uses the current extension.js should maybe solve the problem with where to output-to.#2018-05-0111:19pezAnyway, if manualy I move the js file created by shadow to the root of where everything else lies (and use the main namespace calva to avoid the NPE) then I get things to compile and the extension to load. But I access the exported map incorrectly atm.#2018-05-0111:22pezI now pushed an update to the wip-cljs-toolchain branch with these changes. If you want to try it, just move the generated dist/calva.js to src/main/calva before reloading the extension host.#2018-05-0111:26thheller@pez hang on I got it working. just running into a few bugs#2018-05-0111:33pezIt is fun seeing Calva activate in the project where it is being developed. =)#2018-05-0111:35pezI’ll be away from the computer for some hours now. Hoping I’ll be home in time so I can continue this tonight.#2018-05-0111:45pedrorgirardi@pez, @thheller did this https://github.com/thheller/clojure4vscode/tree/migrate-to-es6/src/main/calva It’s a little bit late here so once you get back I will be away#2018-05-0113:37javiwhen initing a bootstrapped compiler env with (boot/init state {.... is it posible to pass options like in a regular build def
...
:my-build {...
:compiler-options {:my-flag true}
} ....
} 
that will show in (get-in @cljs.env/*compiler* [:options]) ? looking at the source at shadow.cljs.bootstrap.browser , but first time digging under the hood... 🙂 use case is : expanding / implementing something like https://github.com/bhauman/devcards/blob/ae6d1a459b91cfbccb4594c0e6970b2de289a4b3/src/devcards/core.clj#L133 deftest macro that works across cljs/browser.
#2018-05-0113:46thheller@fj.abanses you are passing the state to init#2018-05-0113:46thhellerjust set in it state?#2018-05-0113:47javi
(defonce c-state (cljs/empty-state))
(swap! c-state assoc-in [:options :my-option ] false)

(defonce _ (boot/init c-state
                    {:path         "/js/bootstrap"
                     :load-on-init '#{b2repl.user}}
                    (fn []))
I did, it works. I wasnt sure it was the right way. Thanks
#2018-05-0113:49thhellerit is. boot/init is just about loading pre-compiled code. does nothing beyond that#2018-05-0113:50javithanks @thheller :+1:#2018-05-0113:54gnlGetting this with shadow-cljs check:
Failed reading cache for scratchpad.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: 
#2018-05-0113:56gnlAnd shadow-cljs check takes quite a while to finish, which may as well just be the Closure compiler, but if it's slow due to the cache failing for some reason, it'd be great if it could be sped up.#2018-05-0113:56thhellercompile doesn't complain about cache?#2018-05-0113:56thhelleror release? or watch?#2018-05-0113:57gnlwatch doesn't, release dunno, checking now with newest version#2018-05-0113:58thhelleris this open source code? wonder where the pattern is coming from? probably somewhere in meta?#2018-05-0113:59thhellereasy to fix. just wondering why it only occurs in check#2018-05-0113:59gnlokay, watch isn't complaining, release is:
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
#2018-05-0113:59gnlIt's not open source yet, will be soon#2018-05-0113:59thhellerstop the watch and do a single compile please#2018-05-0114:00thhellerjust want to confirm that all phases complain. doesn't make sense for watch not to complain#2018-05-0114:00gnlI tested release first, before starting the watch, will do again, hang on...#2018-05-0114:00thhellerwatch just uses the cache once otherwise it'll be in memory already#2018-05-0114:00thhellerso it won't complain about cache failing#2018-05-0114:02gnl
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
#2018-05-0114:02gnlOn shadow-cljs compile#2018-05-0114:03gnlCould it be relevant that 1. this a .cljc file with macros and reader conditionals and 2. I'm using the lein integration with shadow?#2018-05-0114:05gnlI'm also getting these:
WARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available.
#2018-05-0114:05gnlNo idea if it's related in any way, but it's the same file.#2018-05-0114:05thhellermaybe a bad ns form?#2018-05-0114:05thhellercheck the logs#2018-05-0114:06thhellerif it doesn't contain any CLJS code just make it a .clj file#2018-05-0114:07thhellerwait#2018-05-0114:07thhellerit fails compilation despite being not available?#2018-05-0114:07thhellerthat doesn't make sense#2018-05-0114:07gnlCompilation succeeds actually#2018-05-0114:08thhellerso you didn't get the inspect resource error?#2018-05-0114:08thhellerI'm confused#2018-05-0114:08gnlIt's just a WARNING, the inspect resource thing#2018-05-0114:08gnlIt then goes on to display a build completed message#2018-05-0114:09thhellerhold on for a second#2018-05-0114:09thhellerIF! you get WARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available. the file will not be available#2018-05-0114:09thhellerand thus NEVER can be compiled successfully#2018-05-0114:09thhellerso you either got that error some time ago and fixed it in the meantime#2018-05-0114:09thhelleror something else is going on#2018-05-0114:10gnl`#2018-05-0114:10gnl
❯ shadow-cljs compile scratchpad                                                                                                                      1s 862ms
shadow-cljs - config: /Users/gnl/Code/re-frame-playground/shadow-cljs.edn version: 2.3.14
shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm compile scratchpad
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/gnl/scratchpad/0.1.0-SNAPSHOT/scratchpad.1.0-SNAPSHOT.jar!/scratchpad/core.cljc", it will not be available.
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/zprint/zprint/0.4.7/zprint-0.4.7.jar!/zprint/main.cljc", it will not be available.
[:scratchpad] Compiling ...
May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: node_modules/highlight.js/lib/languages/tp.js:14: WARNING - String continuations are not recommended. See 
    begin: '(AR|P|PAYLOAD|PR|R|SR|RSR|LBL|VR|UALM|MESSAGE|UTOOL|UFRAME|TIMER|\
           ^

May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)
------ WARNING #1 --------------------------------------------------------------
 File: node_modules/highlight.js/lib/languages/tp.js:14:11

 String continuations are not recommended. See 
--------------------------------------------------------------------------------

nil
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
[:scratchpad] Build completed. (602 files, 483 compiled, 0 warnings, 49.68s)
#2018-05-0114:10thhellerI assume you are working on scratchpad so why is scratchpad.1.0-SNAPSHOT.jar on the classpath?#2018-05-0114:12thhellerthe SNAPSHOT jar probably contains an older version which is then overwritten by your source files#2018-05-0114:12thhellerso everything is fine#2018-05-0114:12thhellerstill confusing but fine#2018-05-0114:12gnlI had the jar installed with lein install because I was messing around with lein checkouts before shadow-cljs and now I'm directly referring the source-path of the current version#2018-05-0114:12thhellerbut why is it on the classpath?#2018-05-0114:13thhellerah ok you have it in your deps?#2018-05-0114:13thhellerah nvm I get it now 😛#2018-05-0114:13gnlYes, lein checkouts supposedly needs that#2018-05-0114:13gnlI'm not using nvm. 🙂#2018-05-0114:13thhellernevermind 😉#2018-05-0114:14gnlWhat a mess. 🙂#2018-05-0114:14thhellerok the jar is just outdated but not a problem since you have the sources directly available#2018-05-0114:14thhellerthat is fine#2018-05-0114:14gnlOkay, so the .jar is irrelevant in this case and I can safely ignore the message?#2018-05-0114:14thhellerjust ignore the warning then#2018-05-0114:14gnlOkay.#2018-05-0114:14thhellerconfusing as hell if you delete a file but still leave it in the jar#2018-05-0114:14thhellerbut ok#2018-05-0114:14gnlI'll remove the .jar#2018-05-0114:15gnlNo need for lein checkouts anymore#2018-05-0114:15thhellerspent an hour or so once debugging this. couldn't figure out how it could still load a file that I just deleted 😛#2018-05-0114:15thhelleranyways ... the cache issue#2018-05-0114:15gnlThose are the best issues, when you start questioning the very fabric of reality. 🙂#2018-05-0114:15gnlProbably best to open an issue when the source is online#2018-05-0114:16gnlBefore we waste time guessing what might be going on#2018-05-0114:16thhellerjust grep the source for #" please#2018-05-0114:16thhelleris it used in any metadata or so?#2018-05-0114:16thhellerjust need to find out where the regex is coming from#2018-05-0114:17thhellerseems weird that it would leak into the compiler data but could be totally fine#2018-05-0114:17gnlIt's used in a spec#2018-05-0114:17gnland in a (comment) block#2018-05-0114:17gnlI can try removing the (comment) block#2018-05-0114:18thhellerthat shouldn't do anything#2018-05-0114:18thhellerit is never compiled#2018-05-0114:19thhellerI know how to fix it but I want to find out WHY it happens first#2018-05-0114:19gnlI'll remove it from the spec too, hang on#2018-05-0114:19thhellerif must be a regex in that file so it can't be in too many places#2018-05-0114:20gnlIt's just those two, comment and spec#2018-05-0114:20thheller(s/def ::foo #"hello world") this is fine so thats not it#2018-05-0114:21gnlchecking...#2018-05-0114:22gnlHah! Got it:
(s/def ::color (s/or :keyword keyword?
                     :literal (s/and string?
                                     #(re-matches #"#[a-fA-F0-9]+" %)
                                     #(or (= (count %) 7) (= (count %) 4)))))
#2018-05-0114:22thhellerindeed! thx#2018-05-0114:23thhellerwonder why that ends up in the analyzer data#2018-05-0114:25gnlThat keyword ends up in some metadata and you mentioned something about metadata before, is that a good direction?#2018-05-0114:25thhellerah right. its the specs getting serialized. forgot about that.#2018-05-0114:31gnlThe caching working doesn't make any difference to how long shadow-cljs check takes though, so apparently that's just the Closure compiler needing a while. Is there any way to speed this up, do you think? Somehow just recheck changed files or something or does it need to go over the whole project every time?#2018-05-0114:32thhellerdefine long?#2018-05-0114:32gnl31s#2018-05-0114:32thhellerwow hmm shouldn't take that long#2018-05-0114:32thhellertake a second or two in my code#2018-05-0114:33gnlTo describe the environment - it's a playground project with many dependencies one of which is the library that I'm currently working on.#2018-05-0114:33gnlBased on re-frame#2018-05-0114:33gnland lots of the warnings are in re-frame and reagent#2018-05-0114:33thheller[:scratchpad] Build completed. (602 files, 483 compiled, 0 warnings, 49.68s)#2018-05-0114:33thhelleris that all CLJS?#2018-05-0114:34thhelleror lots of JS deps as well?#2018-05-0114:34thheller49sec seems really slow as well#2018-05-0114:34gnlJust cljs#2018-05-0114:34thhellerbut yes check always checks all files. can't do a partial check.#2018-05-0114:36gnlWhich makes sense in a way, but some sort of caching would be nice, I'd love to be able to do the type-checking at a similar speed as hot-reloading.#2018-05-0114:37thhellerthat would take a pretty significant rewrite of the closure compiler#2018-05-0114:37thhellerits not currently set-up to do this live#2018-05-0114:38thhelleryou could make an extra build#2018-05-0114:38thhellerthat only includes the namespace you want to check#2018-05-0114:38thhellerso not your main entry for everything#2018-05-0114:38thhelleronly a partial subset#2018-05-0114:38thhellerie. shadow-cljs check-ns cljs.core or something like that#2018-05-0114:39thhellernot sure how useful that would be in your case#2018-05-0114:39thhellerbut the way the closure compiler does this means that you must provide all the sources and dependencies#2018-05-0114:40thhellerand currently you are only allowed to run it once. second attempt will fail.#2018-05-0114:40thhellerso you must throw away the previous instance and start fresh#2018-05-0114:40thhellerie. no cache (for GCC)#2018-05-0114:40thhellercljs is cached regardless#2018-05-0114:40thhellermaybe they support incremental checks and I just haven't found it in the API yet#2018-05-0114:40thhellernot sure#2018-05-0114:42thhellerjust published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9eedf6fffaf1e9b3fdf2f4eddeacb0adb0afab"}, :content ("[email protected]")}. should fix the cache issue#2018-05-0114:42gnlOkay, this clears up a few things, thanks. I don't think a single-ns check will do the trick for my use case, but I'll let you know when I finish my thing, it'll be clearer what I have in mind and then we can brainstorm some more about how best to approach this if at all possible.#2018-05-0114:42gnlAlright, testing...#2018-05-0114:43thhellerprobably won't make GCC any faster#2018-05-0114:43thhellerhow long does release take?#2018-05-0114:44gnl50+ seconds#2018-05-0114:44gnlLet me check again...#2018-05-0114:47tianshuthere's a great npm library https://github.com/gtanner/qrcode-terminal#2018-05-0114:49gnlOkay, so:
shadow-cljs check
[:scratchpad] Build completed. (161 files, 0 compiled, 0 warnings, 4.80s)
34s 786ms

shadow-cljs release
[:scratchpad] Build completed. (161 files, 130 compiled, 0 warnings, 41.58s)
55s 530m
#2018-05-0114:50gnlWhat's the discrepancy between the time reported in build completed and the actual time it took?#2018-05-0114:50gnlI'm assuming in the case of check that's where the actual checking happens#2018-05-0114:51gnlbtw the caching issue's fixed in 2.3.15, thank you!#2018-05-0115:03thhellertry running with --verbose#2018-05-0115:03thhellerhmm#2018-05-0115:04thhelleruhm wait#2018-05-0115:04thhellerdo you not have a server running?#2018-05-0115:05gnlI do when watching, haven't really done any release builds yet and just started checking#2018-05-0115:05thhellerdefinitely always have a separate npx shadow-cljs server running#2018-05-0115:05thhellermakes all commands a whole lot faster since you don't have to pay for the startup each time#2018-05-0115:06thhellerprobably takes 20sec to just start things and warm up before anything actually related to check happens#2018-05-0115:08gnlOh wow, clearly I've severly underestimated the startup time of the whole thing. (shadow/check ...) in the REPL is done in 14seconds now.#2018-05-0115:08gnlStill not great, but way better.#2018-05-0115:08thhelleryeah startup is painfully slow#2018-05-0115:08gnlThank you!#2018-05-0115:08thheller14sec is still not ideal. try (shadow/check :scratchpad {:verbose true})#2018-05-0115:09thhellermost of the time is probably spent in check itself#2018-05-0115:09thhellerprobably can't make that faster#2018-05-0115:09gnlYup, will probably have to cut down on dependencies, but will check verbose true first#2018-05-0115:11gnlYeah, about 12 seconds on checking, the rest on loading stuff from the cache#2018-05-0115:11thhellerhmm yeah. dunno if there are flags in the closure compiler I'm supposed to be setting#2018-05-0115:11thhellerchecksOnly supposedly turns off all the slow stuff#2018-05-0115:12thhellerbut maybe not everything#2018-05-0115:12thhellerits not super reliable to begin with anyways#2018-05-0115:12gnlMaybe :closure-warnings makes a difference in that it doesn't only control reporting but actual checking?#2018-05-0115:13thhellerin most cases it only controls whether a warning is emitted or not
#2018-05-0115:13thhellersometimes it does enable the entire check too though#2018-05-0115:15thhellergotta go. I'll be back in a few hours.#2018-05-0115:15gnlCool, thank you for the help!#2018-05-0116:29pezThanks for the help with migrating Calva imports/exports to ES6, @thheller! I have merged it into my wip branch now and it compiles and the extension loads. I pushed my branch with the changes. The extension doesn’t quite work yet, commands die silently. I guess the message module looked resonably simple to start the porting with, but it is also very central to most everything Calva does. 😃#2018-05-0116:30pezBut I’m on it and hope to be able to merge this into master soon.#2018-05-0120:45pezHmm, I have made some little progress, but it seems that utilities.js is sometimes not imported correctly, I get errors saying things like module$calva$utilities.X is not a function from places like hover.js and messages.cljs. However shadow.js seems to get a correct import, because it can use utilities.js functions.#2018-05-0120:46pezAnd now I am too tired to think so this will have to rest a while. 😃#2018-05-0120:48thheller@doglooksgood sorry about that. fixed in 2.3.16#2018-05-0120:50thheller@pez yeah the cjs-to-es6 tool I used to migrate the exports did some weird stuff#2018-05-0120:51thhellerdefinitely not correct it those and just accidentally works here and there#2018-05-0121:00pezSo you think I can get it working by fixing the imports manually? They look right to me. (I don’t see any difference between the imports that works and those that don’t.)#2018-05-0121:12thhellerproblem is that it used export default { some, stuff, ... }#2018-05-0121:12thhellerthis works if the other file does import x from "./utilities" and then does x.some#2018-05-0121:12thhellerdoesn't work if it does import { some, stuff } from "..."#2018-05-0121:13thhellercan either use export without the default and adjust the others#2018-05-0121:13thhellerto use import * as util from "./utilities" and then util.<thing>#2018-05-0121:14thhellerfor some reason ES6 doesn't allow "partial" refers. either all or nothing. no idea why.#2018-05-0121:21pezYes, now I got some more stuff to work. Thanks for the pointers!#2018-05-0122:03pezThere. Now it seems most stuff works. Maybe all stuff. I am really too tired to figure that out right now. 😃 Anyway, pushed the changes to the wip branch for anyone who cares. Calva is on it’s way to be ported to Clojurescript, thanks to shadow-cljs!#2018-05-0122:10pezI had to do a funny trick. The new message.cljs module of course produces proper clojure maps. But the bencoder(.js) module of course has none of that. So I made a small migrate.cljs module that converts it back to a Javascript object. I use it from client.js before giving the message to bencoder. If I can port client.js to Clojurescript I will be able to remove this migration module, I think.#2018-05-0202:05richiardiandreaOff-topic - are you building an nRepl cljs server by any chance?#2018-05-0204:08pezRather an nrepl cljs client. It’s an extension to VS Code, Calva. I am now curious why you asked? :face_with_cowboy_hat:#2018-05-0204:38richiardiandreaBecause I was thinking at some point about writing a lumo nRepl-compatible server of some sort. I was actually wondering which bencode library to use on JS for instance...so I guess I will observe Calva closely 😉 #2018-05-0204:41pezThat would be wonderful. Then Calva could support Lumo, I think. Is it something unRepl can be used for?#2018-05-0204:48pezMost of the client is still in JavaScript, though. The only part I have ported is the messages maps. #2018-05-0123:58mjmeintjesHi. Every now and again I get the following error printed by shadow-cljs:
[2018-05-01 23:27:27 - SEVERE] Unhandled REPL handler exception processing message {:ns user, :op eval, :code (ns learning.web.web-worker.core
  (:require [learning.web.module.core :as m]
            [keechma.toolbox.pipeline.core :as pp]
            [keechma.controller :as controller]
            [learning.js-utils :as j]
            [keechma.toolbox.pipeline.controller :as pp-controller]
            [goog.object :as go]))
, :file /home/matthys/projects/personal/learning/src/learning/web/web_worker/core.cljs, :line 1, :column 1, :session 6e5b0609-56d9-4d5f-9b08-91f627139e22, :id 15}
java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.errors$user_friendly_error$fn__16179
        at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:290)
        at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:289)
Is this something you've seen before? I can create an issue and try to figure out what's causing it, but it doesn't seem to do anything bad.
#2018-05-0322:54Logan Powell@mjmeintjes I'm also trying to get setup for keechma development with shadow-cljs. Did you ever get your setup worked out?#2018-05-0322:58mjmeintjesYeah, I've been using shadow-cljs and keechma for a couple of months now and it works great. Let me know if you have any questions.#2018-05-0323:00Logan Powelldo you have an example repo with the configs that you could share 🙏#2018-05-0323:00Logan Powellalso, I'm using Atom with protorepl, will that be ok?#2018-05-0323:04Logan Powelljust stalked you real quick and found this: https://github.com/mjmeintjes/shadow-cljs-keechma-node Let me know if you recommend other resources (tutorials/guides/etc.)!#2018-05-0404:22mjmeintjesThat project should show you the basics, however it is a bit more complicated than needed because it also includes server side rendering using nodejs webserver. One of my goals for this month is to get a guide out on how to get started using shadow-cljs and keechma. For now your best bet is to have a look at https://github.com/gothinkster/clojurescript-keechma-realworld-example-app and keechma docs to get started with Keechma. Shadow-cljs is pretty straightforward - I'll extract my basic setup to a starter project and let you know. One important tip - have a look at https://github.com/keechma/keechma toolbox, especially datasource loaders and pipeline controllers. I know that sounds like a lot of jargon, but have a look and let me know if you have any questions. Ypu can also ask on the keechma channel, they are really helpful.#2018-05-0404:23mjmeintjeshttps://github.com/keechma/keechma-toolbox#2018-05-0404:24mjmeintjesI haven't used Atom before, so can't help you there unfortunately.#2018-05-0410:51Logan PowellThank you so much @mjmeintjes ! Your help is greatly appreciated! Btw, you come highly recommended by the Keechma author himself 👍#2018-05-0204:14pez@thheller Right now the clojurescript porting comes at a heavy cost: most of the debugger help is lost, even for non-ported code. Very often the variables view is empty, and the debugger complaints about missing scopes. Is it something I have configured incorrectly, you think?#2018-05-0204:43odieHi all, I’m having trouble calling cljs’s “format” function.
(format "%d bottles of beers on the wall" 99)
=> TypeError: Cannot read property 'call' of undefined
    at eval (eval at <anonymous> (), <anonymous>:1:23)
I have no idea how to go about figure out what I’m doing wrong here. I’m using shadow-cljs version 2.3.16.
#2018-05-0205:18odienevermind x_x It appears format never made it into any actual release of clojurescript.#2018-05-0205:37tianshudoes shadow-cljs support aot cache share?#2018-05-0208:44thheller@mjmeintjes no idea. are you deleting the .shadow-cljs for any reason? or using :cache-root "target/shadow-cljs" and deleting the target dir (lein does this)? or any other classloader/classpath trickery?#2018-05-0208:44thheller@doglooksgood no. cache is always per build. shared would be invalidated far too often to be useful.#2018-05-0208:46thheller@odie yeah format doesn't exist. there is goog.string.format but it requires a weird require setup (:require [goog.string.format] [goog.string :refer (format)])#2018-05-0208:47thheller@pez hmm does vscode not support source maps?#2018-05-0208:47pezIt does.#2018-05-0208:48pezI can step the code and such, but there's an exception thrown complaining about scopes something.#2018-05-0208:48thhellerbut it loads the map?#2018-05-0208:50pezIn that the code looks sane and I can step it, yes. At least the code that was .js. Stepping the cljs code does not work very well.#2018-05-0208:51thhellerso you are not stepping through the compiled JS but the actual source JS?#2018-05-0208:56pezExactly. I have to put the breakpoint in the compiled JS, but code picks up the source JS when the breakpoint fires.#2018-05-0208:56thhellerI don't follow#2018-05-0208:57thhellerhow do you set a breakpoint in compiled JS but then see the source?#2018-05-0208:57pezIt gets a bit crazy since the compiled JS is quite heavily rewwritten, but I think I can live with that. The problem is this lack of context such as variables, which I think is due to that exception on lacking scopes.#2018-05-0208:58pezIt just happens. Code opens up the source when the code pointer enters the compiled code (not sure I am using the right terminology):#2018-05-0208:58thhellersorry I have never used the vscode debugger and do not quite understand what you are doing#2018-05-0208:58thhellerdoes vscode even officially support debugging compiled code?#2018-05-0208:59pezNot sure it does.#2018-05-0208:59thhellerie. stuff written in coffeescript? JSX and so on?#2018-05-0208:59pezIt does support Typescript officially.#2018-05-0208:59thhellerwell .. yeah because thats from MS#2018-05-0208:59thhellerothers as well?#2018-05-0209:00pezHaven't checked.#2018-05-0209:02pezHere's part of that stack trace I mentioned:
Error processing "scopes": TypeError: Line must be greater than or equal to 1, got -1
    at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/node_modules/source-map/lib/source-map-consumer.js:584:13)
#2018-05-0209:09pezWhat I do is that I place a breakpoint in the generated code. When that breakpoint hits, Code opens up the source and I can step the code without pretending to be a closure compiler. Sometimes I can see some variables , but most often not (and that exception is thrown).#2018-05-0209:12thhelleryeah sorry I won't be much help here. not enough time/brain capacity to look into how vscode works#2018-05-0209:12thhellersource maps in general seem to work ok and I never had an issue in the browser#2018-05-0209:13thhellerso no idea why vscode complains. might be something incorrect in the source map but I don't know#2018-05-0209:21pezI'll investigate it further and see if I can understand if something can be fixed on our (as in shadow-cljs or Calva) end.#2018-05-0211:06gnl@thheller Quick question before I open an issue with the Closure compiler, since you've worked a lot with externs - are you aware of any way to add Closure annotations to internal code with externs or something? I tried using externs directly, but as expected they get overridden by the annotation-less actual function definition:
variable cljs.core.inc redefined with type function(?): ?, original definition at EXTERNS:externs/clojure.core.js:12 with type function(number): number
#2018-05-0211:07thhelleryou can't add type annotations to existing code via externs.#2018-05-0211:07thhellerexterns are only for external code.#2018-05-0211:08gnlYeah I get the idea, I'm just trying to make this work somehow. Will open an issue with Closure, then. Thank you#2018-05-0211:09thhellerno idea if its possible to attach type information after the fact#2018-05-0211:09thhellerI don't think so#2018-05-0211:10thhellerare you trying to type cljs.core?#2018-05-0211:11gnlAmong other things. Working on something and went off on a bit of a tangent to see how well this might work.#2018-05-0211:11thhellerprobably not at all#2018-05-0211:13thhellertyping clojure maps and vectors is pretty hard and I think you'd need new stuff the GCC doesn't support for it#2018-05-0211:14thhellerie. how do you type [:div {:foo "bar"} "hello world"] when it also may be [:div "hello world"] and so on#2018-05-0211:14gnlOh I'm not expecting any sort of deep structural typing from this, it's just some added value to a library that I'm trying to get over the finish line.#2018-05-0211:14gnlThere's lots of runtime exceptions that boil down to trying to pass a vector where you should have passed a map or something.#2018-05-0211:14thhelleryou can add typehints in cljs directly#2018-05-0211:15thheller(def ^{:jsdoc ["@type Foo"]} foo ...)#2018-05-0211:15thheller:jsdoc meta is emitted as is into the code#2018-05-0211:15gnlYup, using that, but was hoping could do this for cljs code I import.#2018-05-0211:16thhellerI wouldn't put too much effort into this. CLJS doesn't typecheck at all anyways the check is sort of a failed experiment in that regard#2018-05-0211:17thhellerit is useful in certain situations but you'll never get it to actually fully typecheck a program#2018-05-0211:17thhellernot without significant work on CLJS and GCC that is#2018-05-0211:18gnlYup, you're right, I'm not. This is just a maybe/sorta cherry on top kind of thing.#2018-05-0211:19gnlWill let you know when it's done, if you have any ideas how to improve on it.#2018-05-0211:20thhellerI could add something that lets you define extra metadata that gets merged in on compile#2018-05-0211:20thhellerie. {cljs.core/inc {:jsdoc ["whatever"]}#2018-05-0211:21thhellerthats not too hard to do doubtful you'd gain anything by doing that#2018-05-0211:22gnlThat would, I believe, be pretty great. At the moment, based on my initial work, I'm actually quite optimistic that there is some value to be gained from this.#2018-05-0305:23wilkerlucioafter upgrading to the latest shadow, I can't start the compilation, getting:#2018-05-0305:23wilkerlucio
[2018-05-03 02:09:34 - WARNING] HTTP startup failed
java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found
#2018-05-0305:23wilkerlucioreverting to 2.2.18 works#2018-05-0308:12thheller@wilkerlucio are you using deps.edn? if so you might need to upgrade that#2018-05-0308:14thhellerthe XNIO package is a :scope "runtime" dep so older versions of tools.deps wouldn't pick that up. https://dev.clojure.org/jira/browse/TDEPS-26#2018-05-0312:55wilkerlucio@thheller thanks, that works#2018-05-0312:58javiIn order to manage the complexity of my projects, Is there a way to the dependency graph (edited) of a src ? ie: to render graphs or as input for further analysis of code tools.namespace doesn't like stuff like ["codemirror" :as codemirror]. thanks!#2018-05-0312:59thhellerI think there is a word missing#2018-05-0312:59thhelleryou want a dependency graph I assume?#2018-05-0312:59javiyeah, sorry#2018-05-0313:00thheller@steveb8n is working on https://github.com/stevebuik/Stu which wants to answer those questions#2018-05-0313:01thhellerrendering a dependency tree is surprisingly difficult since it gets unreadable pretty fast#2018-05-0313:02thhellerthis is available today: https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/11?u=thheller#2018-05-0313:03thhellerbut it only aims to answer the "why is my build so big?" question. it does not yet answer "why is this in there?"#2018-05-0313:06javiYeah, my goal is to get the "what is in there and who asked for it" something like , lein's plugin that lets me get a high level view of a project'.#2018-05-0313:08thhellerhttp://npm.anvaka.com/#/view/2d/shadow-cljs#2018-05-0313:08thhellerthought about building something like that. just don't have the time to do it.#2018-05-0313:10thhellerbut this is already pretty much unusable. can't see anything useful.#2018-05-0313:11javiyeah, something like that. > thought about building something like that. just don't have the time to do it. understandable! 😀 I am gonna see what i can do... that way i learn more of how shadow and the cljs compiler work too.#2018-05-0313:11javithanks!#2018-05-0313:11javiwill report back#2018-05-0313:12thhellerthe release-snapshot function I linked above produces a bundle-info.edn#2018-05-0313:12thhellerthis should contain everything you would need to build graphs#2018-05-0313:12thhellerso no real need to dig into any internals#2018-05-0313:12thhelleryou can of course but all the data is already exported just in case#2018-05-0313:13javiyeah, i was jus looking into stu and found a tree in there. makes sense#2018-05-0313:13javi> so no real need to dig into any internals how could i not 🙂? I am learning a lot#2018-05-0313:13thhellerhttps://github.com/kisielk/godepgraph/blob/master/example.png#2018-05-0313:14thhellerthis would be another good example of an unreadable dep graph (IMHO)#2018-05-0313:18javiI am aiming at something interactive and queryable... maybe dump the graph into datascript and use some datalog visual query browser that i have somewhere from a project challenge + coffee#2018-05-0313:19javihttps://i.pinimg.com/originals/1b/29/a6/1b29a68af04275773ef23255c6b255f5.jpg#2018-05-0316:20pez@thheller is there a way to instruct shadow-cljs which path it should use for the sources entry in the source-map files? VS Code allows me to place breakpoints in my actual source files if I edit the source map. For instance for the message module in Calva shadow puts calva/repl/message.cljs in sources. If I change that to ../../src/main/calva/repl/message.cljs things start to work.#2018-05-0316:22pez(I have :output-dir "out" in my build config, which puts the generated files in out/cljs-runtime)#2018-05-0316:37thheller@pez hmm I could probably add an option for that#2018-05-0316:40pezThe user guide lists :source-map-path as unsupported or non-applicable. But maybe that is actually meant to point to where the source maps are…#2018-05-0316:41thhellermaybe. but it seems more logical to me to just emit the absolute file path?#2018-05-0316:41thhellerthis doesn't make sense in a browser context of course#2018-05-0316:41thhellerbut for node/vscode it probably works?#2018-05-0316:43thheller:source-map-path only applies to the browser context I think when you want to have source maps in a different path not matching :asset-path#2018-05-0316:44pezAbsolute path works for node, I just tested.#2018-05-0316:45pezFor the browser, I am using the Chrome Debugger extension for Code and it has an option for rewriting paths. I haven’t figured it out, but I think it should be able to help.#2018-05-0316:46JonI got some trouble running my code bundled with shadow-cljs in release mode. (code running on http://tabletwo.topix.im/ )#2018-05-0316:46Jon(sorry to break the thread though...)#2018-05-0316:48pezno worries, this channel seems single threaded. 😃#2018-05-0316:47pezI haven’t tried debugging a shadow browser project, so it might work out of the box.#2018-05-0316:47thheller@jiyinyiyong which version?#2018-05-0316:48Jontried 2.3.13 and 2.3.16 , happens in both.#2018-05-0316:49thhellerare you sure you tried the .16?#2018-05-0316:49thhellermaybe forgot to restart the server when updating?#2018-05-0316:49thhellerthat issue should be fixed in .16#2018-05-0316:57JonTurned out I can still get two copies of window.shadow$provide in my bundle, with 2.3.16.#2018-05-0316:57JonTried twice.#2018-05-0316:57JonI guess the code should be just shadow$provide, since it's defined with var somewhere in the file.#2018-05-0316:50Jonprobably!#2018-05-0316:50Jonrestarting server...#2018-05-0316:53thheller@pez hmm but what do I do about sources in jars?#2018-05-0316:53thhellervscode probably won't understand those?#2018-05-0316:59thheller@pez what do I need to do to test this?#2018-05-0317:02thheller@jiyinyiyong actually it is not fixed. sorry about that.#2018-05-0317:03Jon😂 so it's still there...#2018-05-0317:03Jonokay, I'm just waiting for an update.#2018-05-0317:04thheller@jiyinyiyong 2.3.17#2018-05-0317:05thhellerthat damn :output-wrapper 😛#2018-05-0317:05thhellergotta be careful when adding stuff#2018-05-0317:05thhellerproblem is in the combination of :output-wrapper with multiple :modules#2018-05-0317:07JonI haven't noticed that feature... new feature..#2018-05-0317:08thhellerwait? you haven't turned that on?#2018-05-0317:09Jonhttps://github.com/TopixIM/tabletwo/blob/master/shadow-cljs.edn#2018-05-0317:09JonI don't know that option, :output-wrapper#2018-05-0317:09thhellernevermind ... I'm just bad at boolean logic.#2018-05-0317:09Jonit's working correctly now, with 2.3.17. cool.#2018-05-0317:10thhellerthat particular feature is only supposed to be turned on with multiple modules#2018-05-0317:10thhellerbut it actually also enabled with just one when it shouldn't be#2018-05-0317:10thhellerfixing that#2018-05-0317:11JonI'm currently bundling my code in a single file. Not trying to split them for now.#2018-05-0317:12thhelleryeah .. I really need more test builds#2018-05-0317:12thhellerall my builds use multiple modules so I didn't test this particular case#2018-05-0317:12thhellermy bad#2018-05-0317:15JonI switched my workflow to single bundles like in last months, or a little earlier. Just for convenience. I found myself gain no obvious benefit by splitting them(at least for now).#2018-05-0319:02kanweiit's safe to not
npm install --save-dev shadow-cljs
if we're just using the jar and compiling to browser, right? seems to work (get a warning)
#2018-05-0319:03thhellerwhat do you mean?#2018-05-0319:04thhellerthe install is required for certain things (ie. babel) so you definitely should always add it#2018-05-0321:01vermaI am having a weird problem getting CSS file watching to work with Windows, pretty sure I am screwing something up, but the source watching works fine, changes are compiled and pushed to my electron hosted app#2018-05-0321:02vermabut css doesn't, although the sass command that I run on file change, stages the file in the correct location (since hitting refresh loads the CSS changes)#2018-05-0321:10vermaI tried the :file-watch option to switch to :polling but I got an error about key (sorry can't seem to find that option to tell the exact error)#2018-05-0321:14kanwei@thheller still seems to work without babel#2018-05-0321:15kanweitrying to minimize dependencies for CI/builds#2018-05-0321:16kanweialso found an issue where if you symlink node_modules to another folder, it doesn't build on shadow-cljs#2018-05-0323:14thheller@verma how is you css embedded? it currently requires an absolute path#2018-05-0323:14thhellerdoubtful that it is windows related given that I'm on windows myself. but I don't do any electron development so there might be something going on there.#2018-05-0323:15thheller@kanwei it works without babel until you need babel. which you will for anything ES6 in node_modules.#2018-05-0323:15thhellersymlinking is a bit problematic yes. have not found an acceptable solution for that yet since I need to know the actual file path for caching and stuff#2018-05-0400:30steveb8n@fj.abanses @thheller thanks for the feedback. that helps me prioritise what gets done next#2018-05-0401:38verma@thheller it is absolute path, <link rel="stylesheet" href="/css/main.css">, I had a few issues to begin with, with electron development, first thing was that it couldn't figure the WS url, since I was opening the file using file:// URL and it was expecting http(s). But I suspect that issue isn't related to this (may be). I run the shadow-cljs dev server and open the URL from electron.#2018-05-0401:39vermaeverything seems to work fine, code reloading is working as expected, but changing the CSS does nothing. I turned on :verbose and :debug mode for shadow-cljs, to see if it prints any log messages etc. but still quiet. Whenever a code change is made however, its super quick and I see changes immediately 😕#2018-05-0407:52dimaDoes shadow-cljs support :aliases of deps.edn? https://clojure.org/reference/deps_and_cli#_aliases It doesn’t see dependencies provided in :extra-deps as i don’t have way to specify which alias it should be using#2018-05-0408:16dimaSeems like it does support it https://github.com/thheller/shadow-cljs/commit/a4dc7e25a0361060155947d6cdd84efa4f99b427#diff-c7cc43da93f76aa510b78d86aac0fd74R250#2018-05-0408:51thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2018-05-0408:54dima@thheller thanks, somehow missed that example with aliases#2018-05-0408:29grounded_sageCan shadow-cljs do SSR I've just been searching and can't find much info regarding SSR and shadow cljs?#2018-05-0408:33mitchelkuijpers@grounded_sage What would you need from shadow-cljs to do SSR? I am not quite sure what you mean.#2018-05-0408:53thheller@grounded_sage shadow-cljs only builds your JS it doesn't run any for you. you can build JS that does SSR perfectly fine though.#2018-05-0408:53grounded_sageI thought so.#2018-05-0408:55grounded_sageI'm just wrapping my head around how it all sort of fits in. Currently reviewing Gatsby JS to see if the community plugins and ecosystem is worth using as a default for smaller work. Though my current thoughts are still that it would be better to stick with CLJS#2018-05-0408:56thhelleryou can probably use gatsby directly with :npm-module#2018-05-0408:56grounded_sageHmm I didnt even think about that..#2018-05-0408:58thhellerhmm maybe not#2018-05-0408:59thhellerforgot that it uses the file paths for stuff#2018-05-0408:59thhellerthat probably won't work#2018-05-0409:00grounded_sageyea well tbh there isn't much of Gatsby that I couldn't recreate. I'm just mentally figuring out what is missing from my current workflow that helps me get the performance and workflow similar to Gatsby#2018-05-0409:04grounded_sageI'm not interested in recreating Gatsby as a whole. Just an environment focused on perf basically.#2018-05-0409:05thhellerwell you could always use gatsby and just create the pages/*.js manually and require the CLJS code from them#2018-05-0410:40kurt-o-sysjust wondering: if I have environment specific configuration (sources), how to do this in shadow-cljs (I'm porting a project from lein to shadow-cljs)? Should this work
{:source-paths ["src"]
 ...
 :builds {:app {:target           :browser
                :output-dir       "resources/public/js"
                :asset-path       "/js"
                :modules          {:main
                                   {...}}
                :dev              {:source-paths ["env/src/dev"]}
                :prod             {:source-paths ["env/src/prod"]}
                :compiler-options {:closure-warnings {:global-this :off}
 
?
#2018-05-0410:40thhellernot possible since I consider this a bad anti-pattern#2018-05-0410:41kurt-o-sysoh, ok... so, how to do environment-specific configs? 😛#2018-05-0410:41thhellerwhat in particular?#2018-05-0410:42thhellerI typically recommend building out your production app and structure the code that way#2018-05-0410:42kurt-o-syswell, for example, connections to test or prod api's#2018-05-0410:42thhellerthan "add" additional code via :devtools {:preloads [...]}#2018-05-0410:42kurt-o-sysoh, the build is exactly the same, it's about configs (keys, uri's, ...)#2018-05-0410:43thhellerright. those I pass into the app on startup#2018-05-0410:43thheller<script>my.app.init(some_data_here);</script>#2018-05-0410:43kurt-o-sysd'you use any kind of library to parse or so? Or you just pass a file name?#2018-05-0410:43kurt-o-sysin your html?#2018-05-0410:44thhellerthere are many different ways you can do this. all depends on your needs.#2018-05-0410:44thheller:closure-defines also works#2018-05-0410:44thhellerbut "dynamic" config data I pass in on startup always#2018-05-0410:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-05-0410:45thhellerthis is supported. just not for :source-paths#2018-05-0410:45kurt-o-sys🙂#2018-05-0410:46kurt-o-syswell, on startup... that's build time. The generated html/css/js is static, so it has to be there after building the app. The 'dynamic' part is: on build-time, pass the right configs.#2018-05-0410:47thhellerbut you said generated html#2018-05-0410:47thhellerso you can generate that html to include the config?#2018-05-0410:47kurt-o-sysyeah... I guess closure-defines is what I need#2018-05-0410:48thhelleryou have several different options to do any of this#2018-05-0410:48thhellerreally depends on what you are doing exactly#2018-05-0410:48kurt-o-sys(urls etc, nothing extremely secret here, just different in prod or dev)#2018-05-0410:48thhellervia HTML is the definitely the best option IMHO since you do not need to recompile to change the config#2018-05-0410:49kurt-o-sysright, makes sense.#2018-05-0410:50kurt-o-sysso, it'll be html or clojure-defines (which can be used inside :builds {:app {:dev {:clojure-defines {...}}}}, right)?#2018-05-0410:50thhelleryes#2018-05-0410:50kurt-o-systhx! will do.#2018-05-0410:51kurt-o-sysmost probably html - no need to recompile to change the config, I totally agree. Cool!#2018-05-0410:51thhellerI have this ancient blog post I wrote about the way I do this#2018-05-0410:52thhellerhttps://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html#2018-05-0410:52kurt-o-sys:+1:#2018-05-0410:52thhellerI have been using this approach for 6+ years now#2018-05-0410:52thhellermight give you some ideas#2018-05-0411:26kurt-o-systhx!#2018-05-0411:48troglotitI'm using https://github.com/weavejester/environ with this kind of code. If you need env variables - that's the way#2018-05-0411:49thhellerthats a bad idea since it breaks caching#2018-05-0411:50thhellerthe CLJS compiler and shadow-cljs is not aware of your environment variables so your code will not be recompiled if you change them#2018-05-0411:50thhelleryou can block it from being cached https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2018-05-0411:50troglotitthat's fine trade-off for me 🙂. I'm not even sure how env variables in linux/macos/posix should work regarding processes, and changing in runtime; So all of the use cases for env variables for me is where those static uri to my backend. The benefit is env variables are injectable by different kind of dockers/ci/cd#2018-05-0411:55thhelleryeah but all of them require recompilation#2018-05-0411:56thhellerif you instead pass in the config at runtime you can compile once and actually use the same output for all envs#2018-05-0411:58thhellerin CI I want to test what will actually be released#2018-05-0411:58thhellernot some special CI build#2018-05-0412:00thhellernever liked env for the same reasons I don't like bindings in clojure. it is not immediately obvious those will affect your program.#2018-05-0412:01thhellerif you run node server.js path/to/config.edn instead I can look at the config to see whats in it#2018-05-0412:01thhellerdon't have to worry about some env vars being set and such#2018-05-0412:01thhellersame approach for the browser bascially. just a different way to get the config there#2018-05-0412:01thhellerIMHO, YMMV#2018-05-0412:25pezWhat do people use for unit testing with shadow-cljs node projects?#2018-05-0412:26thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test#2018-05-0416:47pezThanks @thheller, I’ll have a think about how that can be supported in Calva.#2018-05-0417:28Logan Powell👋 hi everyone! Newb here... I'm getting an error when trying to setup shadow with proto-repl/atom:
CompilerException java.lang.RuntimeException: No such var: shadow.cljs.devtools.api/start-worker, compiling:(null:1:1) 
the other two commands: (shadow.cljs.devtools.api/compile :app) (shadow.cljs.devtools.api/nrepl-select :app) are working flawlessly... Any ideas?
#2018-05-0417:29lwhortoni just updated to the latest shadow-cljs and am now getting “warning macro namespace reloaded” — i dug around the src files, user guide, and gh issues, but I don’t really see why this exists#2018-05-0418:38thheller@lwhorton that shouldn't be a warning. it is fine and expected, think I left it in there when I debugged something. sorry for the confusion.#2018-05-0418:40thheller@loganpowell why are you calling start-worker? watch is probably what you are looking for?#2018-05-0418:41Logan PowellHi @thheller! I'm following a template I found: https://github.com/shadow-cljs/examples/tree/master/proto-repl#proto-repl-with-shadow-cljs#2018-05-0418:44thhellerugh. don't! thats super old.#2018-05-0418:45thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_proto_repl_atom#2018-05-0418:45Logan Powellhaha ok. Thank you!#2018-05-0418:46thhellerI'll update the README. the rest still looks accurate so should be fine#2018-05-0418:46Logan PowellSweet. Yes, the starting block helps a bunch#2018-05-0501:11steveb8n@thheller any chance you would support “release-snapshot” in the CLI? If not, I can build my own CLI as a temp workaround. Thoughts?#2018-05-0501:20steveb8nhas anyone found a docker image that has npm and clojure/lein installed?#2018-05-0501:28steveb8nscratch that, I found https://hub.docker.com/r/theasp/clojurescript-nodejs/#2018-05-0502:19tianshu@thheller lastest version of emacs cider now has a great support for shadow-cljs. simply start with cider-jackin, no need to add cider-nrepl dependency manaully, nor any setup. the section in user guide should be updated.#2018-05-0502:21tianshuanother thing I found is that undertow(builtin in shadow-cljs) will failed to start when use with tools.deps. #2018-05-0506:18steveb8n@thheller ignore that question. I can do it in the new cli that generates snapshots#2018-05-0508:28thheller@doglooksgood upgrade tools.deps to fix the undertow issue#2018-05-0508:29thheller@steveb8n I will add a CLI command for release-snapshot eventually yes.#2018-05-0508:29tianshugreat! #2018-05-0508:31thheller@steveb8n the lein-node-browser images have everything you'd want I think#2018-05-0519:00gravI’m looking at using AWS Lambda together with shadow-cljs. Everything works fine, but my deployment consists of a bash-script that uses the aws-cli. Anyone has anything better for deployment? lein-cljs-lambda is nice, but that couples me to cljs-build (and leiningen)#2018-05-0523:16mjmeintjesShadow-cljs has pretty good support for programming a build/release script in clojure, see here: https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run. You might be able to combine that with https://github.com/mcohen01/amazonica/blob/master/README.md to build your deployment.#2018-05-0600:10cjsauerIs there a way to set the initial namespace when running shadow-cljs clj-repl? I'd like to set it to user instead of shadow.user as I have some helper functions defined there.#2018-05-0602:45lwhortonis this something shadow-cljs might support, since it has a finite number of supported :compiler-options#2018-05-0606:16mjmeintjesCan you think of a reason that an app would work when building release with :pseudo-names true, but then throw an exception when released without that option?#2018-05-0607:14mjmeintjesTurned out to be an externs issue causing a naming conflict.#2018-05-0608:49thheller@lwhorton no. why would you need that?#2018-05-0619:10lwhortonhttp://Sentry.io doesnt seem to handle indexed sourcemaps in their parser#2018-05-0619:11lwhortonI wonder if mozillas sourcemap has a way to reformat a map... didnt seem to#2018-05-0619:57thhellerhmm the reason it is using an index map is because of the npm stuff#2018-05-0619:57thhellerCLJS + goog is all one map#2018-05-0619:58thhellerand then one per node_modules .js file#2018-05-0620:00thhellerdon't know how to turn it into one merged one either#2018-05-0621:28lwhortonit’s a bummer that we can’t let another tool make the map at the end. wouldn’t want to miss out on the compiler’s optimizations just for sake of sourcemaps#2018-05-0621:32thhellerwonder why sentry doesnt support index map. seems pretty common and https://github.com/mozilla/source-map supports it as well#2018-05-0608:50thheller@mjmeintjes yes externs. with :pseudo-names you get long variable names that are less likely to clash, so it sometimes fixes things.#2018-05-0608:52mjmeintjesThe weird thing is that I've been releasing and compiling without externs for a couple of months, but then just randomly today it started crashing. Probably just lucky/unlucky with name conflicts.#2018-05-0608:53thhellerhehe yeah I had this happen before. works one day but then breaks suddenly. Closure picks variable names sort of incrementally so it starts with a,b,c,d,... and then picks aa,ab,ac,... and so on. if you have enough vars you eventually get to ga which google analytics already uses and clashes#2018-05-0608:53thhelleror similar things#2018-05-0609:57tianshusome function called static function which is just a simple ES6 module export.
// a.js
module.exports = {
  setString: xxx
}
If a is an export of module b, and I require like this (:require ["b" :refer [a]]) I can use setString with following code:
(def a-set-string (aget a "setString"))
(a-set-string xxx)
but this won't work
(a.setString xxx)
is this an expected behavior?
#2018-05-0610:01thhellera/setString
#2018-05-0610:01thhellernot a.#2018-05-0610:02thhellerand yes that is expected#2018-05-0610:03tianshuif use a/setString, it will say can't find variable a.#2018-05-0610:03thhellerhmm wait#2018-05-0610:04thhellerI'm confused now. what is b?#2018-05-0610:04thheller(:require ["b" :refer [a]]) this doesn't make sense?#2018-05-0610:05thhellerhow is a.js involved in that?#2018-05-0610:05tianshuin my case, "b" is "react-native" and a is Clipboard.#2018-05-0610:06thheller(:require ["react-native" :refer (Clipboard)]) (.setString Clipboard "foo")#2018-05-0610:09tianshuyes, this works#2018-05-0610:09tianshubut how to distinguish these situations?#2018-05-0610:10thhellerwhich situations?#2018-05-0610:12thhellerah you mean a.setString working sometimes? well ... blame weird choices in the CLJS compiler. it only works for locals not ns aliases#2018-05-0610:13tianshuso .setString a and a.setString is different?#2018-05-0610:13thhellerfrom the code that gets emitted it is the same#2018-05-0610:13thhellerbut they are analyzed differently#2018-05-0610:13thhellerno idea why.#2018-05-0610:15thhellerI guess I could tweak the code for this to make it work#2018-05-0610:15thhellerbut I don't think its a good idea to do this anways#2018-05-0611:06tianshui think it's better to always use (.setString a)#2018-05-0611:13thhellerindeed#2018-05-0611:20tianshuwhats the difference between (a/b) and (.b a) here for npm module? #2018-05-0611:22thheller:as sets up a namespace alias so it acts like any other CLJS namespace#2018-05-0611:22thhellerthe (.b a) is not valid for CLJS namespaces and you must use a/b there#2018-05-0611:22thhellerit just works for JS namespace since you are also allowed to use them directly#2018-05-0611:24thhellereg. (:require [clojure.string :as foo]) then foo is not a variable and you can only use (foo/upper-case ...) not (.upper-case foo)#2018-05-0611:26thhellerfor JS :as must create a variable since some CommonJS uses module.exports = function() ... which would not be callable otherwise#2018-05-0611:26tianshuclear for me#2018-05-0611:29tianshui should always use a/b when a is a alias of npm module. #2018-05-0611:30thhellerbasically you should NEVER use a.setString in any circumstance. the only exception to this is anything in the js/ namespace (eg. (js/console.log "foo")) IMHO.#2018-05-0611:31thhellerthats my rule for this.#2018-05-0611:31thhellera.setString would not be valid in Clojure so I never do it.#2018-05-0611:51tianshu best practice is not obvious for begginer, this is bad i think. #2018-05-0613:17thhellerpretty sure that no official docs ever mention that a.setString is even possible or allowed#2018-05-0613:18thhellerso not sure where this is even coming from#2018-05-0613:22javiI am writing some tests to explore how the cljs compiler works, Given
...
:test                         {:target    :node-test
                                                 :output-to "out/node-tests.js"
                                                 :ns-regexp "-test$"
                                                 :autorun   true}
                  :bootstrapped-assets-for-test {:target    :bootstrap
                                                 :output-dir "out/bootstrap"
                                                 :entries [eval-and-parse.botstrapped-libs]
                                                 :exclude #{cljs.js}}
....
and...
(ns eval-and-parse.core-test
  (:require
    [cljs.js :as cljs]
    [cljs.env :as env]
    [shadow.cljs.bootstrap.browser :as boot]
    [cljs.test :refer-macros [deftest is testing run-tests async]]))

(deftest library-gets-loaded-and-accesible-on-bootstrap-mode
         (async done
                (let [c-state (cljs/empty-state)]
                     (boot/init c-state
                                  {:path         "/bootstrap"
                                   :load-on-init '#{eval-and-parse.bootstrapped-libs}}
                                  (fn []
                                   ;; --------------- tests
                                      (done))))))
I am getting ...
SHADOW import error ... ... ... .shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.module.main.append.js

........shadow-cljs/builds/test/dev/out/cljs-runtime/goog.net.xmlhttp.js:175
    return new XMLHttpRequest();
Is this because of the env where the tests are running? ie: :target :node-test
#2018-05-0613:24thhellernot sure what your question is going to be but :entries [eval-and-parse.botstrapped-libs] seems to be missing an o#2018-05-0613:27javihey, sorry, pressed send by mistake before finishing the message#2018-05-0613:26thhellerc-state should be a comiler env. not an analyzer env. eg. (cljs.env/default-compiler-env)#2018-05-0613:26thhellerdunno if you saw https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2018-05-0613:27thhelleroh wait you are running node#2018-05-0613:28thhellershadow.cljs.bootstrap.browser only works in the browser .. hence the name#2018-05-0613:28javiI have an editor, compiles and consumes all libs great.#2018-05-0613:29javiNow i am setting up tests to fill in my conceptual blanks and get a whole picture of compilation#2018-05-0613:30javiso i am getting that message with test profile
{:target    :node-test
                                                 :output-to "out/node-tests.js"
                                                 :ns-regexp "-test$"
                                                 :autorun   true}
#2018-05-0613:30thhelleryou can use :browser-test instead of :node-test#2018-05-0613:30javiOK#2018-05-0613:31thhellerit should be pretty simple to write a shadow.cljs.bootstrap.node that works the same#2018-05-0613:31javiwhat do you mean?#2018-05-0613:31javithe same as :browser?#2018-05-0613:31thheller
(ns eval-and-parse.core-test
  (:require
    [cljs.js :as cljs]
    [cljs.env :as env]
    [shadow.cljs.bootstrap.browser :as boot]
    [cljs.test :refer-macros [deftest is testing run-tests async]]))
#2018-05-0613:32thhelleryou are requiring shadow.cljs.bootstrap.browser which clearly has "browser" in the name#2018-05-0613:32thhellerbut then run it in node#2018-05-0613:32thhellerthe boot/init utility function assumes it is running in a browser#2018-05-0613:33javiOK! makes sense now. 🙂 gonna give it a try. thanks#2018-05-0613:33thhelleryou can write a similar function for node. I just have not written that yet.#2018-05-0613:33thhellerwould actually be substantially easier in node since you can use fs/readFileSync#2018-05-0613:34javiI understand. the whole picture is becoming clearer now#2018-05-0613:34thhellerthe :bootstrap target basically just pre-compiles files so they can be loaded at runtime#2018-05-0613:35thhellerthe other option is to no precompile anything and just making the sources accessible directly#2018-05-0613:35thheller:bootstrap then creates a index.transit.json containing all the information for the compiled files#2018-05-0613:36thhellerboot/init loads that index and then loads whichever namespaces are required#2018-05-0613:36javiyeah, i followed your post on that#2018-05-0613:36javii am poking to see where cljs places things in the environment etc...#2018-05-0613:37thhellerwell that all works a bit differently in self-host CLJS#2018-05-0613:37thhellerbut for the most part it is all in cljs.env/*compiler*#2018-05-0613:38thhellerie. c-state#2018-05-0613:38thhellerinfo about cljs.core you would find in (get-in @c-state [:cljs.analyzer/namespaces 'cljs.core])#2018-05-0613:39thheller(after init completes)#2018-05-0613:42javiI have a little viz of the compiler env and i can see things being added etc... makes sense ... one thing... when i do
(:require .....
   ["an-npm-lib" :as an-npm-lib]
...)
where does that go in the cljs.env/*compiler*
#2018-05-0613:44thhellerit doesn't#2018-05-0613:45thhelleror rather I have no idea where it goes. shadow-cljs handles that very differently#2018-05-0613:45thhellerno idea how it works in standard CLJS#2018-05-0613:45thhellerI think :js-module-index is involved#2018-05-0613:46javiok, so you use your dependecy resolution mechanism to look that up? Sorry, i am sure some of these questions are a bit stupid... 🙂#2018-05-0613:47thhellernot stupid at all#2018-05-0613:47thhelleryes shadow-cljs has its own resolve mechanism#2018-05-0613:47thhellerin fact it replaces the entire parser for ns#2018-05-0613:50javimakes sense, where in the source can i look to begin to understand this?#2018-05-0613:50thhellerCLJS or shadow-cljs?#2018-05-0613:51javishadow-cljs#2018-05-0613:51thhellerhttps://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc#L2566#2018-05-0613:52thhellerthat part is replaced by shadow.build.ns-form and shadow.build.resolve#2018-05-0613:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/resolve.clj#L402#2018-05-0613:53javiwow. thanks!#2018-05-0613:53thhellerthis is the starting point. so if you have a browser build with :entries [foo.bar] it get called with (resolve-entries state [foo.bar])#2018-05-0613:53thhellerand so on#2018-05-0613:55thhellerbut most of the resolve magic is in that file. shadow.build.npm has the npm specific stuff#2018-05-0613:55thhellerbut everything starts in shadow.build.resolve#2018-05-0613:56thhellerall of this works very very differently in CLJS though so none of this applies if you are looking into self-hosted stuff#2018-05-0613:57javican i access it like when i do this?
(->> "
		(do
     (ns my.somns (:require [clojure.string :as string])) 
     (def g 90)
     
     (ns my.r (:require [clojure.string :as string])) 
     (def lo 90)
     )
     "
     cljs.tools.reader/read-string
     (cljs.analyzer/analyze user-env)
     cljs.compiler/emit-str
     )
#2018-05-0613:57thhellerno#2018-05-0613:57thhellerwell, not with those API calls#2018-05-0613:57javiok#2018-05-0613:57thhelleryou can access everything yes#2018-05-0613:59thhellerbut shadow-cljs is a build tool for building files. so some of the more dynamic stuff like evaling strings works differently as well#2018-05-0613:59javiha ha yes!! gonna try it.#2018-05-0614:00thhellerthis might provide some hints https://github.com/thheller/shadow-cljs/blob/master/src/repl/shadow/cljs/repl_test.clj#2018-05-0614:03thhelleryou are probably better off looking at the official cljs.analyzer stuff though#2018-05-0614:03thhellerthe shadow-cljs stuff is pretty specific to shadow-cljs#2018-05-0614:05javithanks!! I will look at both little by little so i can see the different approches and learn from that. one last question... at the browser console module$node_modules$codemirror$addon$edit$closebrackets is that how shadow builds a look up for the bootstrapped libs?#2018-05-0614:06thhellerthat is the ns alias created for the node_modules/codemirror/addon/edit/closebrackets.js file yes#2018-05-0614:07javiok thanks! gonna look into those resources you sent me. thanks so much!#2018-05-0614:07thhellertry looking at the index.transit.json data#2018-05-0614:07thhellershould make sense how it all comes together there#2018-05-0614:08thhellerin shadow-cljs everything is treated as a resource. each resource can provide one or more namespace and and can require zero or more#2018-05-0614:09thheller(ns foo.bar) would be :provides #{foo.bar} :requires #{cljs.core} and so on#2018-05-0614:10thheller(ns foo.bar (:require ["react" :as r])) basically gets rewritten to (ns foo.bar (:require [module$node_modules$react... :as r]))#2018-05-0614:15javi> in shadow-cljs everything is treated as a resource At some point (it is sunday...) ( .. and as a beginner on the compiler bits ...) i would love to hear your view on the deps.edn/requiring from github and codeq etc... thanks for the help. have a great rest of sunday!#2018-05-0614:21thhellerI think it is interesting but not sold on actuallly using git deps#2018-05-0614:22thhellernot possible to use shadow-cljs as a git dep for example since it has some java code that needs to be compiled first#2018-05-0614:23thhellerhttps://www.youtube.com/watch?v=lKXe3HUG2l4#2018-05-0614:25thhellerthinking about this stuff is a gigantic rabbit hole ... It is interesting to think about but I do no have enough time to do anything about it 🙂#2018-05-0619:11PontusI just setup shadow-cljs for my project, and I was wondering something. I've got om-next as a dependency and I think that's using a cljsjs packaged react. Then I've installed React with npm as it was needed as a dependency for another react-library. Do I know use two versions of React or does shadow-cljs somehow make om-next use the npm installed React?#2018-05-0619:25wilkerlucio@pontus.colliander you are using the npm version, when you use a cljsjs dependency with shadow, you are actually loading this file: https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#2018-05-0619:26wilkerluciothese are the common ones because people already rely on cljsjs, but you can just create your cljsjs.my-package and make a shim like the one in the link I send before#2018-05-0619:43Pontusokay, so that changes all references om-next had to the cljsjs-react to the npm version? Pretty cool#2018-05-0711:38heyarnei have a problem in firefox with a self-signed ssl certificate#2018-05-0711:38heyarnei proceeded like described in the user guide#2018-05-0711:38heyarneand the wss:// connection fails#2018-05-0711:39heyarne
Firefox can’t establish a connection to the server at . browser.cljs:315:8
shadow-cljs: websocket error 
error

bubbles: false

cancelBubble: false

cancelable: false

composed: false

currentTarget: null

defaultPrevented: false

eventPhase: 0

explicitOriginalTarget: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }

isTrusted: true

originalTarget: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }

target: WebSocket { url: "", readyState: 3, bufferedAmount: 0, … }

timeStamp: 4402

type: "error"

<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
browser.cljs:27:10
shadow-cljs: WebSocket disconnected! browser.cljs:27:10 
#2018-05-0711:42heyarnehere's a screenshot that's maybe easier to parse: https://transfer.sh/PreAs/Screen%20Shot%202018-05-07%20at%2013.40.46.png#2018-05-0711:42heyarne(visually i mean)#2018-05-0711:43heyarneit works fine in chrome. any idea what's going on? it's really annoying that chrome and ff handle localhost differently when it comes to stuff like this or http requests with CORS headers#2018-05-0711:58heyarnethe solution seems to be to create my own root ca which i can then use to create the certs#2018-05-0711:59heyarnemaybe this is helpful to anybody. i for one am switching to chromium as my dev browser for now. 😕#2018-05-0712:10thheller@arne-clojurians are you using the ssl support built into shadow-cljs or any other webserver?#2018-05-0712:11thhellerI'm guessing that you are using a different webserver and shadow-cljs has no ssl configured?#2018-05-0712:14thhellerI still haven't figured out how to configure ssl in windows so I can't really test things easily#2018-05-0712:19heyarneno i'm using the shadow-cljs ssl support#2018-05-0712:19thhellerhmm ok#2018-05-0712:20heyarneso i generated the certificate, configured shadow-cljs and experienced the behavior above. i'm on macos just in case that turns out to be important#2018-05-0712:20thhellerhmm I'm pretty sure I tested firefox in my setup on mac#2018-05-0712:21heyarneoh really? maybe i messed up the certificate creation?#2018-05-0712:21heyarnethere are a couple of issues on stackoverflow about firefox and self-signed certs with wss#2018-05-0712:21heyarnebut the ones i found are already a couple of years old#2018-05-0712:22thhellerwell if it works fine in chrome I see no reason why it wouldn't work in FF#2018-05-0712:22heyarneyes. if there was a clear standard for this at least.#2018-05-0712:23thhellerdid you create with SAN and everything?#2018-05-0712:24heyarnebut as i said; i've run into trouble with cors-headers in ff while it worked fine in chrome, so it wouldn't surprise me too much#2018-05-0712:25thhellerlet me try to figure out this windows thing and then I'll see what FF does#2018-05-0712:25thhellerI definitely want this to work#2018-05-0712:26heyarneSAM? I hear that term for the first time. I followed this guide, which I found in the docs: https://certsimple.com/blog/localhost-ssl-fix#2018-05-0712:33thhellerSAN. SubjectAlternateName#2018-05-0712:34thhellerchrome complained for me when the cert didn't include that#2018-05-0712:37heyarneIt contains the subject name (common name, country) and the issuer name (common name, country). No complaints in current Chromium#2018-05-0713:23thhellerI don't understand why this is so fucking complicated ... 😡#2018-05-0713:42hlolliyeh I had problem with self signed signatures on Chrome, they just restricted them recently, ff should work fine. But I didn't read the whole context of this discussion above....#2018-05-0714:34thheller@arne-clojurians finally got this working. you first need to go to https://localhost:9630 and confirm the security exception firefox shows#2018-05-0714:34thhellerno idea why it doesn't trust the cert once its installed#2018-05-0714:38thhellerbut it seems to work fine once you trusted the "main server"#2018-05-0715:03heyarne@thheller thanks so much!#2018-05-0715:18thhellerfound these instructions for windows/linux. seems more complicated than it should be but works well. https://gist.github.com/jchandra74/36d5f8d0e11960dd8f80260801109ab0#2018-05-0715:30jmckitrickWe just got a new project I’ll be implementing with shadow, so you’ll be seeing a lot more of me in coming days 😉#2018-05-0715:31jmckitrickI have to start by showing we can import a navbar from npm for our admin screen, and then a react-select for the core functionality.#2018-05-0715:32thhellergood luck 🙂 let me know how it goes#2018-05-0715:49jmckitrickI assume a lein template is still the best way to start a fresh project?#2018-05-0715:50jmckitrickI lean toward luminus now, and it supports front-end-only reagent apps, of course.#2018-05-0715:50jmckitrickBut I’m open.#2018-05-0716:03heyarne@jmckitrick are you talking about scaffolding? for that lein works well, yeah. personally i do it by hand or by git cloning a project i set up before.#2018-05-0716:04heyarnei'm running shadow-cljs watch x via npm script and i'm receiving status 130 when Ctrl + Cing it. is this normal? never noticed it before#2018-05-0716:04jmckitrickI’d like a consistent structure for my colleagues. So I’ll probably use lein new luminus +re-frame or something similar.#2018-05-0716:04heyarneit might be confusing if you don't use the project.clj then though. or are you using lein for everything?#2018-05-0716:05heyarnei just use bare shadow-cljs, which is why i'm asking#2018-05-0716:05thheller@jmckitrick if you only need frontend you can start with this https://github.com/shadow-cljs/quickstart-browser#2018-05-0716:05jmckitrickAh, good point.#2018-05-0716:05thheller@arne-clojurians what is status 130?#2018-05-0716:06jmckitrick@thheller I’ll try it now….#2018-05-0716:08thhellerhttps://github.com/quangv/shadow-re-frame-simple-example also has re-frame and stuff#2018-05-0716:08thhellerhttps://github.com/quangv/shadow-re-frame-simple-example#2018-05-0716:11heyarne@thheller exit code 130#2018-05-0716:14thhellerno idea where that would come from?#2018-05-0716:14thhellerdid you upgrade to npm v6?#2018-05-0716:16heyarneyes#2018-05-0716:17heyarne
npm ERR! code ELIFECYCLE
npm ERR! errno 130
npm ERR! 
#2018-05-0716:19thhellerno idea. I didn't change anything. might be npm v6?#2018-05-0716:27heyarneit is actually. npm 5.8 doesn't show this behavior#2018-05-0716:30thheller> This is probably not a problem with npm#2018-05-0716:30thhellerliars 😉#2018-05-0716:31heyarneblatant 😉#2018-05-0716:43jmckitrickOk, I have the skeleton app running in watch mode, reagent/re-frame are running.#2018-05-0716:43jmckitrickI’ve just imported the in-house navbar component I need, and here’s the error I got:#2018-05-0716:44jmckitrick
errors in file: /Users/devmbp42/tst/admin-destination-guides/node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less", :js-requires [], :js-errors [{:line 1, :column 0, :message "Character '@' (U+0040) is not a valid identifier start char"}], :goog-requires [], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /Users/devmbp42/tst/admin-destination-guides/node_modules/ui-agent-navigation/lib/navigation/styles/agent-navigation.less
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/get-file-info* (npm.clj:520)
	shadow.build.npm/get-file-info* (npm.clj:428)
	shadow.build.npm/get-file-info (npm.clj:556)
	shadow.build.npm/get-file-info (npm.clj:553)
	shadow.build.npm/find-resource* (npm.clj:650)
	shadow.build.npm/find-resource* (npm.clj:610)
#2018-05-0716:44jmckitrickIt looks like I need to get a less processor running, and I’ve not done that before.#2018-05-0716:45jmckitrickBut I don’t want to assume….#2018-05-0716:46thhellerless is not supported yet but its supposed to get filtered#2018-05-0716:46thhellerah ...#2018-05-0716:46thheller
(def asset-exts
  #{"css"
    "png"
    "jpg"
    "jpeg"
    "svg"})
#2018-05-0716:46thhellerI'll add less#2018-05-0716:55thhellerlooks like your in-house stuff has the assumption of using webpack built-in though#2018-05-0716:56jmckitrickHmm.#2018-05-0716:56jmckitrickWell, there’s support for ES6 or UMD.#2018-05-0716:56jmckitrickNot sure if that assumes webpack for both.#2018-05-0716:56jmckitrickWhat would I need to change? The author is on our team.#2018-05-0716:57thhellerno they do a require("./agent-navigation.less") in the code (or import)#2018-05-0716:57thhellerie. from JS they require a stylesheet#2018-05-0716:57jmckitrickAh.#2018-05-0716:57thhellershadow-cljs will just filter those out currently#2018-05-0716:58thhellerbut that means you must get the styles by other means#2018-05-0716:58jmckitrickRight, that’s the next step.#2018-05-0716:58jmckitrickI assume I can refer to a relative path?#2018-05-0716:58jmckitricker, a path in node_modules?#2018-05-0716:59thhelleryep#2018-05-0716:59jmckitrickLet’s try…#2018-05-0717:00jmckitrickI assume I need to bump my shadow-cljs for your change… or else comment out that line of the module#2018-05-0717:00thhellerhow are you using shadow-cljs?#2018-05-0717:00jmckitrickI have a server running, and watch running.#2018-05-0717:00thhelleryou can run shadow-cljs clj-repl#2018-05-0717:01jmckitrickI just started from scratch.#2018-05-0717:01jmckitrickRight…#2018-05-0717:01thheller(in-ns 'shadow.build.npm) then
(def asset-exts
  #{"css"
    "scss"
    "sass"
    "less"
    "png"
    "gif"
    "jpg"
    "jpeg"
    "svg"})
#2018-05-0717:01jmckitrickah ok#2018-05-0717:01thhellerno need to wait for me to fix things 😉#2018-05-0717:01jmckitricksweet!#2018-05-0717:02thhellerthen restart the watch and things should work#2018-05-0717:02jmckitrickHow does that integrate with server/watch mode?#2018-05-0717:02jmckitrickok#2018-05-0717:02thhellerjust do it while server is running#2018-05-0717:02jmckitrickgot it#2018-05-0717:02thhelleror just run clj-repl itself which then acts the server#2018-05-0717:02thhellercan run (shadow/watch :app) in the REPL as well#2018-05-0717:04jmckitrickok, the error is gone. Now to try the component itself…#2018-05-0717:20thhellerhmm 96k files in my node_modules. this is getting out of hand. 😛#2018-05-0717:25jmckitricklol#2018-05-0717:36jmckitrickSo far, so good!#2018-05-0717:36jmckitrickNow I need to set up a proxy to the rest of the app to get a login cookie.#2018-05-0717:37jmckitrickMy colleague has a nwb.config.js with a section for devServer and a proxy setting below that.#2018-05-0717:38jmckitrickLet me check the shadow docs first#2018-05-0717:38jmckitrickGot it!#2018-05-0717:38thhellershadow-cljs itself has no support for acting as a proxy itself#2018-05-0717:40thhelleronly support putting a proxy in front of it#2018-05-0717:40jmckitrickHmm. I need to find out how to do that… what tools would work?#2018-05-0717:41thhellernginx?#2018-05-0717:41jmckitrickOf course, silly me. I assume it could be set up to work the same way… I’ll have to figure that part out.#2018-05-0717:46jmckitrickThis proxy setting is only for devtools, correct?#2018-05-0717:47thhelleryes#2018-05-0717:47thhellerif you only do local development you do not really need it#2018-05-0717:50thhellerhmm I could actually add proxy support pretty simlpy#2018-05-0717:51thhellerbut typically you have something in front of the dev server#2018-05-0717:51thhellernot the dev server in front of something#2018-05-0717:52jmckitrickYes, I’m sure you’re right.#2018-05-0717:52jmckitrickSo webpack passes options to another node package that does the proxying.#2018-05-0717:53jmckitrickSo I need to figure out how to replicate that so the in-house module I’m running can access the login cookie from our app.#2018-05-0717:53thhellerwell what does it proxy to?#2018-05-0717:54jmckitrickOur company login domain, or one of the dev/qa versions#2018-05-0717:55jmckitrickI just need the CLJS app to be able to see the cookies from the company domain.#2018-05-0717:56thhellerdo you have local dns?#2018-05-0717:59jmckitrickLet me find out…. I’m pretty ignorant of our networking setup.#2018-05-0718:01thhellerits not required. just makes things a little easier.#2018-05-0718:01thhellerif you proxy to your company domain the cookie that gets set will effectively be localhost (assuming it doesn't set a domain itself)#2018-05-0718:03jmckitrickRight. My colleague developed the react component I need to embed, and it’s proxied to the company domain to access that cookie. I need to do the same. With his setup, there’s built in support for proxies, so I need to replicate that some other way.#2018-05-0718:03jmckitrickI guess I’m belaboring the obvious.#2018-05-0718:04thhellerI personally use nginx for pretty much all my stuff#2018-05-0718:04thhellerin development as well as production#2018-05-0718:04thhellerso I'm pretty used to that#2018-05-0718:05justinleejust to weigh in on the proxy thing: create-react-app will proxy your api server for you. this is pretty convenient if your release target serves the api and the frontend bundle from the same endpoint. it enables you to keep cors turned off without having to set up an nginx proxy in dev#2018-05-0718:06thhelleris that documented somewhere?#2018-05-0718:06jmckitrickWhat web server are we running?#2018-05-0718:06justinleehttps://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development#2018-05-0718:06jmckitrickYeah, we have nginx to connect our individual apps to make them run seamlessly on our dev boxes.#2018-05-0718:06jmckitrickI just don’t know it that well 😕#2018-05-0718:07jmckitrick@lee.justin.m That’s exactly what we used#2018-05-0718:07jmckitrickI think#2018-05-0718:07justinleei should probably just use nginx. the proxy feature is just a convenience.#2018-05-0718:07jmckitricknwb#2018-05-0718:07thhellerI'm all for convenience 😉#2018-05-0718:09jmckitrick@lee.justin.m Are you saying a proxy: ... entry in package.json is all I need? Does that apply to the dev server used by shadow?#2018-05-0718:10justinlee@jmckitrick if you were using create-react-app that’s all you’d need 🙂#2018-05-0718:10jmckitrickYes, if only, lol.#2018-05-0718:10thhellerChallenge accepted!#2018-05-0718:10justinleehaha#2018-05-0718:10jmckitrickHey, I’m willing to help and/or contribute in any way I can!#2018-05-0718:11jmckitrickWhat’s the server used in shadow?#2018-05-0718:13thhellerundertow#2018-05-0718:13jmckitrickok#2018-05-0718:14justinleewow the proxying has gotten really sophisticated since i last checked in with c-r-a. when they first put that feature in there were no options and it only proxied certain mime types#2018-05-0718:36thhellerdone#2018-05-0718:37thhellerwell the simple version is#2018-05-0718:38jmckitrickWow, now what? lol.#2018-05-0718:39jmckitrickI guess the next version will have the less fix as well 😉#2018-05-0718:46thhellerI'm not happy with the implementation but it seems to work fine#2018-05-0718:46thhellerdoes it need to proxy websockets?#2018-05-0718:46thhellerthat probably doesn't work#2018-05-0718:48thhelleroh hehe. it actually works#2018-05-0718:48thhellernice#2018-05-0718:49justinleegotta love it when you’re accidentally a genius#2018-05-0718:49thhellerI have nothing to do with that. its just an undertow handler#2018-05-0718:49justinleessh#2018-05-0718:49justinleenobody needs to know that#2018-05-0718:51justinleecan i pull a new version and try it out or is it not ready yet?#2018-05-0718:54PontusIs there a way to see what Clojurescript version is used when compiling and to specify which version to use?#2018-05-0719:37thhellerin theory it is possible yes but due to some backwards incompatible changes in CLJS you currently have to use 1.10.238#2018-05-0719:37thhellerotherwise just specify clojurescript in your deps#2018-05-0917:07PontusAh okay, not sure I'm doing it right. In the :dependencies in the shadow-cljs.edn ? When I do that it doesn't give me the shadow-cljs - updating dependencies message that I normally see.#2018-05-0917:12thhellershadow-cljs itself it already pinned to 1.10.238 so no need to specify it there#2018-05-0917:13thhellerand you can't currently downgrade that due to a breaking change in the closure interop#2018-05-0718:57thheller@lee.justin.m @jmckitrick just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2f5c474e4b4058024c43455c6f1d011c011d1f"}, :content ("[email protected]")}. you can set :devtools {:proxy-url ""} and all requests that would otherwise 404 will be proxied to that url instead#2018-05-0718:57thhellerie. anything without a file#2018-05-0718:57justinleehow does that interact with push state?#2018-05-0718:57thhellerprobably needs some more advanced config options to only proxy specific paths and such
#2018-05-0718:57thhellercompletely replaces push-state#2018-05-0718:58thhellerthats why I mention the more advanced config options 😉#2018-05-0718:59justinleehaha okay. so what c-r-a does is check the mime type so that only api requests go to the api server. The development server will only attempt to send requests without text/html in its Accept header to the proxy.#2018-05-0718:59thhellerbut who says that the proxy server can't serve images?#2018-05-0718:59thhelleror html for that matter?#2018-05-0719:00justinleei think the idea is that you serve static resources off of your development server but just proxy api reqeusts#2018-05-0719:00justinleethere’s no real benefit to serving static resources via proxy#2018-05-0719:00thhellerwell honestly ... you should just be using nginx for all of this#2018-05-0719:00justinleehaha#2018-05-0719:01justinleeok#2018-05-0719:01thhellerbut I guess we can mimic what CRA does#2018-05-0719:02thhellerbut the proxy support doesn't proxy anything you have a file for#2018-05-0719:02thhellerso it only breaks if you actually reload a push-state url#2018-05-0719:02thhellerif you load the index initially everything works 😉#2018-05-0719:33jmckitrickAwesome! I’ll check it out soon. And I’ll read up on nginx too#2018-05-0809:02heyarneare there any best practices on testing a re-frame app with shadow-cljs? i use emacs and cider for development, and i love cider-test-run-all-tests and cider-test-run-ns-tests. i guess i don't get this kind of emacs integration with shadow-cljs easily, right?#2018-05-0809:03thhellerI don't know? you should?#2018-05-0809:03thhellerdoes it work for clojurescript in general?#2018-05-0809:04thhellermight be clojure only?#2018-05-0809:07thhelleryeah the cider-nrepl middleware for this directly interfaces with clojure.test. no support for CLJS in general#2018-05-0809:42heyarneyes, i noticed that too. i think i'll just go for continuous node-tests for now. i think i could still later on switch to using cljc tests#2018-05-0810:21thhellerif you have a REPL running you can just invoke tests from there#2018-05-0810:21thheller
rlwrap shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn version: 2.3.19
shadow-cljs - connected to server
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 7.92s)
[1:1]~cljs.user=> JS runtime connected.
[1:1]~cljs.user=> (require '[cljs.test :refer (deftest is)])
nil
[1:1]~cljs.user=> (deftest foo-test (is (= 1 2)))
{:namespaces {cljs.user {:vars {foo-test #'cljs.user/foo-test}}}, :hooked true}
[1:1]~cljs.user=> (foo-test)

FAIL in (foo-test) (at C:476:9)
expected: (= 1 2)
  actual: (not (= 1 2))
nil
[1:1]~cljs.user=>
#2018-05-0810:25thhellerdoesn't have all the fancy formatting but serves its purpose#2018-05-0813:04jmckitrick@thheller Does 2.3.20 have the updated filter for less files?#2018-05-0813:04thhelleryes#2018-05-0813:05jmckitrick:+1::skin-tone-2:#2018-05-0816:22jmckitrickI’ve added a project called tubax to my edn file, and when the page refreshes that has the dependency, I see this: The required namespace "ext.saxjs" is not available, it was required by "tubax/core.cljs".#2018-05-0816:22jmckitrickI’m not sure if tubax is broken, or if I’m not configuring shadow to import it correctly.#2018-05-0816:24jmckitrickSo it looks like tubax has an assets/deps.cljs file#2018-05-0816:25jmckitrickand it bundles sax.js with it#2018-05-0816:39fatihictCan anyone help me with understanding of the :default key in shadow cljs requires? These are my requires:
["react" :refer [createFactory]]
["@atlaskit/field-radio-group" :default radio-group]
Here I create a factory and use the component:
(def radio-group (createFactory radio-group))
(radio-group #js {...})
I assumed the call to radio-group here would result in a call to the factory and not the class radio group. Is this a wrong assumption? If I change my require from ["@atlaskit/field-radio-group" :default radio-group] to ["@atlaskit/field-radio-group" :as radio-group] and my def from (def radio-group (createFactory radio-group)) to (def radio-group (createFactory radio-group/default)) my code does work.
#2018-05-0817:06justinlee@fatihict i do essentially the same thing with react-flip-move but I use reagent’s adapt-react-class instead of createFactory and it works#2018-05-0817:07justinleebut given that you get it work work with the alternate syntax I wonder if there is something messed up with the default import#2018-05-0817:08thheller@fatihict :default is tricky since it depends on whether the npm lib was packages as commonjs or es6#2018-05-0817:11thheller@jmckitrick funcool has a lot of these ... :foreign-libs are not supported. it appears to be this package https://www.npmjs.com/package/sax#2018-05-0817:12jmckitrickAh, ok.#2018-05-0817:12thhellerso npm install sax and then create a (ns ext.saxjs (:require ["sax" :as sax])) (js/goog.exportSymbol "sax" sax")#2018-05-0817:12jmckitrickGot it!#2018-05-0817:13jmckitrickWhile I’m thinking about it, the react-select component works great, but the X icon for removing a ‘chip’ from the multi-select mode is rendering as a ~A or something like that. It’s supposed to me &times;. Would that have anything to do with shadow?#2018-05-0817:14thhellermore likely to the encoding of your page#2018-05-0817:14jmckitrickok#2018-05-0817:14thhellertry <meta charset="UTF-8"> in your <head>#2018-05-0817:15thhellerassuming you are using utf-8 or course 😉#2018-05-0817:15jmckitrickI was UTF-8 before UTF-8 was cool, lol.#2018-05-0817:15jmckitrickActually, this is from the cloned quickstart…#2018-05-0817:16jmckitrickSo I might open a PR for this#2018-05-0817:16thhellerwell did it fix that?#2018-05-0817:16jmckitrickBoom. Problem solved.#2018-05-0817:16thhellerhmm strange#2018-05-0817:16jmckitrickI should have thought of that, but it’s something I so rarely deal with….#2018-05-0817:17jmckitrickI forgot the simple stuff, too. Was thinking of minification, etc.#2018-05-0817:18fatihictAh, good to know. Thanks @thheller & @lee.justin.m#2018-05-0817:20thheller@jmckitrick are you using the proxy support? that might be the problem. the dev server usually sets charset=utf-8 via http headers#2018-05-0817:21jmckitrickHmm. Let me see…#2018-05-0817:21thhellerso setting it in html should usually not be required#2018-05-0817:21jmckitrickYes, let me restart without and see…#2018-05-0817:21thhellerno need to restart#2018-05-0817:21thhellerjust comment out the proxy url and save the config#2018-05-0817:22thhellerit'll restart the http server#2018-05-0817:24jmckitrickActually, that did not solve it. But the meta tag did.#2018-05-0817:25thhellerstrange#2018-05-0817:27thhellerfeel free to open a ticket for this. I'll see if I can reproduce this later.#2018-05-0820:15jmckitrickWill do.#2018-05-0908:20odieHi all, I’m just getting started with fulcro and exploring the shadow-cljs version of the app template a bit. I can connect and drop into the cljs repl. The prompt indicates I’m in the cljs.user namespace. But, if I were to create a matching “cljs/user.cljs” file, none of the code in the file seems to be loaded. Any idea what I might be doing wrong?#2018-05-0908:24thheller@odie oh I forgot about that. it currently doesn't check the filesystem and always generates one. please open a ticket so I don't forget it again#2018-05-0908:26odieOh! Good thing I asked! I’ve been messing around with this for too long, thinking I must be missing something obvious. 😃 Will open a ticket!#2018-05-0909:58thheller@odie fixed in 2.3.21. as a bonus :devtools {:repl-init-ns my.app} is now also supported#2018-05-0909:58odieThanks! That was fast! 👍#2018-05-0910:20kurt-o-sysI'm trying to run shadow-cljs with lein. Without lein, I have no problems. With lein:
$ shadow-cljs watch app
shadow-cljs  <project-home> 
shadow-cljs - config: <project-home>/shadow-cljs.edn version: 2.3.19
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" java.lang.RuntimeException: Unable to find static field: ECMASCRIPT6 in class com.google.javascript.jscomp.CompilerOptions$LanguageMode, compiling:(shadow/cljs/closure.clj:712:13)
        at clojure.lang.Compiler.analyze(Compiler.java:6792)
#2018-05-0910:20thheller@kurt-o-sys with lein you need to put clojurescript into your deps#2018-05-0910:21thhellerotherwise you probably end up with an old incompatible version#2018-05-0910:21thhellercheck lein deps :tree which clojurescript version you are using (and which closure-compiler version)#2018-05-0910:21thhellerjust adding [org.clojure/clojurescript "1.10.238"] should fix it#2018-05-0910:22kurt-o-sys[org.clojure/clojurescript "1.10.238" :scope "provided"] is in the dependencies#2018-05-0910:22kurt-o-sysin lein...#2018-05-0910:22thhellerplease check lein deps :tree if its actually used though#2018-05-0910:23thhellerand which com.google.javascript/closure-compiler-unshaded version in particular as that is causing the problem#2018-05-0910:23thhellershould be v20180319#2018-05-0910:25kurt-o-sys
$ lein deps :tree | grep clojure-compiler-unshaded
lein  ... Possibly confusing dependencies found:
[thheller/shadow-cljs "1.0.20170629"] -> [org.clojure/tools.reader "1.0.0"]
 overrides
[re-frame "0.10.5"] -> [org.clojure/clojurescript "1.9.908"] -> [org.clojure/tools.reader "1.0.5"]
 and
[com.taoensso/tempura "1.2.0"] -> [com.taoensso/encore "2.94.0"] -> [org.clojure/tools.reader "1.2.1"]
 and
[org.clojure/clojurescript "1.10.238"] -> [org.clojure/tools.reader "1.3.0-alpha3"]

Consider using these exclusions:
[re-frame "0.10.5" :exclusions [org.clojure/tools.reader]]
[com.taoensso/tempura "1.2.0" :exclusions [org.clojure/tools.reader]]
[org.clojure/clojurescript "1.10.238" :exclusions [org.clojure/tools.reader]]

[thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]]
 overrides
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"]
 and
[ring "1.6.3"] -> [ring/ring-core "1.6.3"]

Consider using these exclusions:
[ring "1.6.3" :exclusions [ring/ring-core]]

[com.rpl/specter "1.1.0"] -> [riddley "0.1.12"]
 overrides
[thheller/shadow-cljs "1.0.20170629"] -> [aleph "0.4.3"] -> [manifold "0.1.6"] -> [riddley "0.1.14"]

Consider using these exclusions:
[thheller/shadow-cljs "1.0.20170629" :exclusions [riddley]]

[thheller/shadow-cljs "1.0.20170629"] -> [ring/ring-core "1.6.1" :exclusions [clj-time]] -> [commons-fileupload "1.3.2"]
 overrides
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-servlet "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-jetty-adapter "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-devel "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]
 and
[ring "1.6.3"] -> [ring/ring-core "1.6.3"] -> [commons-fileupload "1.3.3"]

Consider using these exclusions:
[ring "1.6.3" :exclusions [commons-fileupload]]

[compojure "1.6.0" :exclusions [instaparse]] -> [ring/ring-codec "1.0.1"] -> [commons-codec "1.6"]
 overrides
[org.clojure/clojurescript "1.10.238"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.clojure/clojure]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"]
 and
[thheller/shadow-cljs "1.0.20170629"] -> [com.cognitect/transit-clj "0.8.300" :exclusions [org.msgpack/msgpack]] -> [com.cognitect/transit-java "0.8.324"] -> [commons-codec "1.10"]

Consider using these exclusions:
[org.clojure/clojurescript "1.10.238" :exclusions [commons-codec]]
[thheller/shadow-cljs "1.0.20170629" :exclusions [commons-codec]]
#2018-05-0910:25thhelleruhm thheller/shadow-cljs "1.0.20170629"?#2018-05-0910:25thhellerthat is an ancient version 😛#2018-05-0910:25thhellerbump it to 2.3.21#2018-05-0910:25kurt-o-sysright, ok.#2018-05-0910:27kurt-o-sysok, my bad... took some template from somewhere.#2018-05-0910:27thhellerhow come you are using lein though?#2018-05-0910:29kurt-o-syswell, maybe I didn't check the docs enough, I have in my project.clj things like yagni, kibit, yagni etc. I'm not sure how to do it in shadow-cljs:
:aliases {"eastwood"     ["with-profile" "lint" "eastwood"]
            "kibit"        ["do"
                            ["with-profile" "lint" "shell" "echo" "== Kibit =="]
                            ["with-profile" "lint" "kibit"]]
            "yagni"        ["do"
                            ["with-profile" "lint" "shell" "echo" "== Yagni =="]
                            ["with-profile" "lint" "yagni"]]
            "bikeshed"     ["do"
                            ["with-profile" "lint" "shell" "echo" "== Bikeshed =="]
                            ["with-profile" "lint" "bikeshed" "--max-line-length=140"]]
            "cljfmt-check" ["do"
                            ["with-profile" "lint" "shell" "echo" "== cljfmt check cljs =="]
                            ["with-profile" "lint" "cljfmt" "check" "src/cljs"]]
            "cljfmt-fix"   ["do"
                            ["with-profile" "lint" "shell" "echo" "== cljfmt fix cljs =="]
                            ["with-profile" "lint" "cljfmt" "fix" "src/cljs"]]
            "check-deps"   ["with-profile" "lint" "ancient" "all"]
            "lint"         ["do" ["eastwood"] ["kibit"] ["yagni"] ["bikeshed"] ["cljfmt-check"]]}
#2018-05-0910:30thhellerah ok. yeah lein plugins require lein 😉#2018-05-0910:30kurt-o-sys(I just started using shadow-cljs, due to issues with npm, well...)#2018-05-0910:31thhellertotally fine to use lein. just curious why. lein plugins is good reason 😉#2018-05-0910:42kurt-o-sysshadow-cljs is a breeze, btw... will present it in a workshop on http://jsconf.be#2018-05-0912:03thhellernice!#2018-05-0914:19jmckitrickQuestion on the new proxy-url setting#2018-05-0914:19jmckitrickIf I’m running the cljs app on port 8020, will the proxy setting allow me to forward to a different port? I’m trying that, and it’s not working.#2018-05-0914:20thhellerhmm?#2018-05-0914:20thhellerthe proxy setting will cause the content you proxy from to be available under 8020#2018-05-0914:22thhelleror what do you mean by cljs app?#2018-05-0914:25jmckitrickJust the shadow server, I mean.#2018-05-0914:25jmckitrickBut that app needs an XHR call forwarded to port 9000#2018-05-0914:26thheller:http-port 8020 :proxy-url ""#2018-05-0914:26jmckitrickThe http-port is already set to the default, I haven’t changed it.#2018-05-0914:26jmckitrickCorrection.#2018-05-0914:26thhellerthere is no default?#2018-05-0914:26jmckitrickIt’s set to 8020, yes, lol.#2018-05-0914:27jmckitrickI’ll keep experimenting.#2018-05-0914:28thhellerso you do have another server running locally on port 9000 I assume?#2018-05-0914:28jmckitrickGot it!#2018-05-0914:28jmckitrickIt was http vs https#2018-05-0914:30thhellerif whatever server is running on port 9000 is capable of serving files you could just use that#2018-05-0914:30thhellerno need to use the built-in shadow-cljs server#2018-05-0914:30thhellerits just files#2018-05-0914:32bhauman@thheller hmmm if I crib some ideas from you would you want me to mention your name and give you credit?#2018-05-0914:33thheller@bhauman don't worry about it. I don't think there is a single new original new idea in anything I have done in shadow-cljs.#2018-05-0914:34bhaumanI thinking it would be cool to give some credit figwheel in your docs eh?#2018-05-0914:34bhaumanthe absence of a mention is kind of galling#2018-05-0914:36thhelleryou are absolutely right. I should definitely add a section for that.#2018-05-0914:37thhellerI have never used figwheel but definitely drew a lot of inspiration from it#2018-05-0914:38bhaumanthanks man 🙂#2018-05-0914:40bhaumanBTW i just implemented the after-load and before-load meta data hooks#2018-05-0914:40bhaumanits a pretty sweet addition#2018-05-0914:42thhellersweet!#2018-05-0914:42bhaumanalthough I require a ^:figwheel-hooks mark on ns#2018-05-0914:43bhaumandidn't wan't to search across every var on each compile#2018-05-0914:44thhellerprobably a good idea. I didn't check how long that takes after I put it in but probably should have.#2018-05-0915:42javiI am playing with custom builds, simple, just a post build hook to copy some files as documented here https://shadow-cljs.github.io/docs/UsersGuide.html#_example.
(ns build.browser-post-process
  (:require [shadow.build :as build]
            [shadow.build.targets.browser :as browser]))

(defn core [{::build/keys [stage mode config] :as state}]
  (let [state (browser/process state)]
    (when (and (= :flush stage) (= :dev mode))
      ;; do task here
      state)))
and config :target build.browser-post-process/core in a build called b2 when running shadow-cljs watch b2 in "shadow-cljs": "^2.3.20" I get
...
...
shadow-cljs - watching build :b2
[:b2] Configuring build.
[2018-05-09 16:32:38 - WARNING] failed to handle server msg: {:type :start-autobuild}
java.lang.AssertionError: Assert failed: (build-api/build-state? %)
        at shadow.build$configure.invokeStatic(build.clj:175)
        at shadow.build$configure.invoke(build.clj:175)
...
...
am i missing something? cheers!
#2018-05-0917:11thheller@fj.abanses the build.browser-post-process/core must always return the state it receives#2018-05-0917:12thhelleryou are not returning the build state properly#2018-05-0917:17thhelleryou moved the state into the when#2018-05-0918:44javi@thheller ouch!! 😞 sorry the code in the user guide has some typos and i misinterpreted it.
(ns build
  (:require [shadow.build :as build]
            [shadow.build.targets.browser :as browser]))

(defn custom [{::build/keys [stage mode config] :as state}]
  (let [state (browser/process state] 
    (when (and (= :flush stage) (= :dev mode))
      (call-rsync)
    state))
(browser/process state and also the closing paren for the (when I can fix the docs and send a pull request if it helps you.
#2018-05-0920:46thheller@fj.abanses thx. fixed it.#2018-05-0920:50thhellerhmm this example is still totally incomplete#2018-05-0921:00javilet me know if i can help testing something...#2018-05-0920:50javithanks. Also, in the karma settings secction
{...
 :builds {:ci-tests {:target     :karma
                     :output-to  "target/ci.js"
                     :ns-regexp  "-spec$"}
below this in the how to run snnippets the build is referenced as ci
$ shadow-cljs compile ci
$ karma start --single-run
#2018-05-0920:51javireplying to previous comment.#2018-05-1010:44jmckitrickI see the cider integration docs are still marked ‘help wanted’. I’m interested in helping clarify that section, once I have a few details nailed down.#2018-05-1011:38jmckitrickI’m not sure if my method of integrating with cider is unofficial or wrong. What’s the difference between shadow.cljs.devtools.api/nrepl-select and shadow.cljs.devtools.api/repl ?#2018-05-1012:34jmckitrickAlso, once I build my project, what’s the best way to deploy it in a container-friendly way?#2018-05-1012:34jmckitrickWith a back and front-end project, I’d have a jar, which works nicely with Docker.#2018-05-1013:52thheller@jmckitrick I'm not an emacs user so I don't know how to configure anything. help is definitely welcome. repl delegates to nrepl-select nowadays so it doesn't matter much which on is used.#2018-05-1013:53jmckitrickok, cool. I’ll put together some points and open a PR#2018-05-1013:53thhellerdeploy depends entirely on your setup. jars works although I personally do not recommend them since you need to restart your server to reload the cLJS#2018-05-1013:53jmckitrickIf not a jar, what else for front-end only?#2018-05-1013:53jmckitrickI’m trying to be as devops friendly as possible 😉#2018-05-1013:54thhellerits just a .js file, just copying that should be enough#2018-05-1013:54thhellerjar file implies you have a java webserver running as well#2018-05-1013:55jmckitrickRight, and I don’t want that.#2018-05-1013:55jmckitrickSo we’d need a build step that copies the payload into our client app.#2018-05-1013:55thhellerso just take the js file(s) and copy them to a directory#2018-05-1013:55jmckitrickRight, ok.#2018-05-1013:55thhellerand use any webserver to serve it#2018-05-1013:56jmckitrickYeah, that’s what I figured. I was hoping there was a more self-contained way to do it that didn’t depend on relative paths to other projects. Oh well.#2018-05-1013:56jmckitrickMaybe what I need to do is move this project into that one, and call shadow as part of that build.#2018-05-1013:56thhellerdon't unterstand what you mean#2018-05-1013:57jmckitrickWell, this project is in its own repo. And we like to be able to deploy components into containers from standalone repos, where possible.#2018-05-1013:57thhellerno idea what that means "deploy components into containers"#2018-05-1013:58jmckitrickSo each repo represents a component, either a server, a nodejs front-end, etc.#2018-05-1013:58jmckitrickEach repo is deployed into a docker container, which is deployed into Rancher or Kubernetes#2018-05-1013:58jmckitrickWithout dependencies on other components.#2018-05-1013:59thhelleryes but your server must serve the .js files#2018-05-1013:59thhellerhow else would the client access them#2018-05-1014:01jmckitrickCorrect. Node comes with express, and obviously a jar file would have netty or something similar.#2018-05-1014:02thhelleris express directly serving the traffic or is something like nginx in front?#2018-05-1014:02thhelleror any other loadbalancer?#2018-05-1014:02thhellerhow do you deal with other assets? ie. css, images, etc#2018-05-1014:02jmckitrickexpress is a tiny server that just serves up the index, js, and css for one component.#2018-05-1014:03jmckitrickThis is all behind Rancher, loadbalancer, nginx, etc#2018-05-1014:03jmckitrickAnyway, I don’t mean to bore you with our devops details, I just want to pick the best way to get our payload into our build.#2018-05-1014:03thhellerI would just copy things to a path that nginx is serving#2018-05-1014:04jmckitrickRight, that’s probably what we’ll do.#2018-05-1014:07thhellerthings used to be so much simpler without all these containers 🙂#2018-05-1014:44jmckitrickYep! I think I found my answer. Since this is all npm-integrated, I’ll configure the project to serve the assets with express.#2018-05-1117:28theasp@jmckitrick Or macchiato? 🙂#2018-05-1117:35theaspI have a project that has stopped building when run in a container, with no obvious cause:
Step 7/14 : RUN npm install --save-dev shadow-cljs && shadow-cljs release client server
 ---> Running in 2718b0f65743
npm WARN app No repository field.
npm WARN app No license field.

+ 
#2018-05-1117:37thheller@theasp it might discard the error message when clojure is missing? maybe thats not available#2018-05-1117:37theaspYeah, thats exactly it#2018-05-1117:38theaspI was about say that 😉#2018-05-1117:38thhellerplease open an issue for this so I don't forget to fix it#2018-05-1117:38theaspSure!#2018-05-1117:44theaspThis "installing clojure" thing seems bizarre now#2018-05-1117:48theaspDamn, the official clojure docker image doesn't have it either#2018-05-1117:52theaspWhat happens if the clojure version doesn't match the version in deps.edn?#2018-05-1117:52thheller1.9 is required due to spec#2018-05-1117:53thhellerbut the script version itself is all 1.9 anyways I think#2018-05-1117:53thhellerbut the script clojure version doesn't affect your version at all.#2018-05-1118:26kanweiany way to disable CLJS DevTools?#2018-05-1119:02theasp@thheller Is there a way to get shadow-cljs to download deps, without building?#2018-05-1119:05theaspMaybe this is all I need: clojure - <<<"nil"#2018-05-1119:11theaspYeah, that does it!#2018-05-1120:27thheller@kanwei :devtools {:enabled false}#2018-05-1120:28thhelleror do you mean these? https://github.com/binaryage/cljs-devtools#2018-05-1120:31kanweiyeah binaryage ones#2018-05-1120:31kanweii already turned off :devtools#2018-05-1120:41thheller:devtools {:console-support false} or not putting them on the classpath should do it#2018-05-1201:47lilactownanyone know if there's a way to force an ns to always be recompiled/reloaded?#2018-05-1207:43thheller@lilactown (ns ^:dev/always my.thing)#2018-05-1413:58javi@thheller the defn podcast was a great listen! congrats 🍺#2018-05-1508:43grounded_sage@thheller just listened to you on defn. Something interesting to check out is Svelte and its accompanied framework Sapper. Interesting concept as it allows you to write applications that compile down to virtually hand written JS size/perf. #2018-05-1508:45grounded_sageI’ve moved to using Sapper for now as most things I am building are more websites than full blown apps. I’m 100% betting on web now as PWA is now hitting desktop and once it’s standard on phones I see little need for native apps anymore. It’s still really new so things will likely change but would be great if we could do something like this without dropping to JS for logic. #2018-05-1508:55thhellerI looked at svelte but I don't buy the "compiles to hand written JS" argument at all.#2018-05-1508:56thhellerIt looks nice but it is data binding with JS objects again.#2018-05-1508:57thhellerI don't want to do data bindings again ever 😛#2018-05-1509:03grounded_sageI’m wondering how much work it would be to do something similar in cljs land. I’ve never done much at the js level as I dove straight into Clojure first and moved around Elixir, Elm space before coming back to Clojure. #2018-05-1509:04thhellerwhat do you mean by similar?#2018-05-1509:06thhellertheir .html files can pretty much just be .cljs files with one simple macro#2018-05-1509:07thhellerunless you really want to write html. but who wants to do that if you can write hiccup instead#2018-05-1509:09grounded_sageNot sure really haha. I like using React from cljs but have found it difficult to get the kind of workflow I am looking for. Also I’ve come to realise that vdom has noticeable overhead and only really serves the purpose of hedging bets by spreading out across rendering targets and handling issues that browsers are progressively smoothing out. #2018-05-1509:09grounded_sageHiccup is so much cleaner and less error prone than HTML lol of course. #2018-05-1509:10thhellerwhat kind of workflow are you looking for? I do agree that vdom/react is not the perfect solution either but every abstraction is going to have weaknesses#2018-05-1509:10thhellerI do like it far more than the old mutable dom style though#2018-05-1509:11grounded_sageJAMstack. I think separation of front end and back end makes a tonne of sense #2018-05-1509:13thhellerare we not doing that already?#2018-05-1509:21thhellerI do think that people reach for React too quickly sometimes though. If you only have one tiny thing on a page that actually is a bit dynamic you can usually do it with a tiny bit of DOM interop#2018-05-1509:21thhellerin CLJS it sometimes looks like React is your only option#2018-05-1509:32thhellerhave you seen http://hoplon.io/?#2018-05-1509:41grounded_sageLast time I looked at Hoplon it didn’t have a story for ssr#2018-05-1509:44thhelleryeah ssr is tricky subject. I don't want to use CLJS on the server but if you go with React you pretty much have to#2018-05-1509:47grounded_sageI’m big on the idea of Netlify and other services like it. Just put your whole front end on a CDN (set and forget) and use an API for the data you need. #2018-05-1510:03grounded_sageI thought about using Preact CLI as it’s very lightweight but it still requires the vdom boot up time and memory resources. Plus it still requires compat if you want to take full advantage of the React ecosystem. Svelte seems to win or be on par on the js benchmarks site. Especially when it comes to memory usage. Doing lighthouse testing on Sapper. Taking out images you can get interactive in under 1 second and meaningful render around 0.5 for simple stuff like what I am doing now. Plus the entire web application can be shipped in the first network packet. In performance profile it’s like 20ms compared to almost 300 ms scripting time. Those are just baseline numbers I have seen. #2018-05-1510:11grounded_sageThere also seems to be a growing number of people bundling up components into web components. So people are using like Vue/React/Angular mixed together. I get this funny feeling that we are going to see a swing back to non vdom UI’s when PWA is everywhere. #2018-05-1510:27thhellerdo you have a svelte example that actually does dynamic stuff? I can only find mostly static pages#2018-05-1510:28troglotitVue/React/Angular all have huge runtimes, it’s somewhat possible to compile them to WebComponents, but it doesn’t mean you should mix them#2018-05-1510:29thhellerbenchmarks are dangerous since you can build frameworks that are optimized to win in those benchmarks#2018-05-1510:29thhellerbut then lose in actual real world apps#2018-05-1510:30thheller100kb gzip'd JS is fine I think and you can fit a whole lot of stuff into that#2018-05-1510:31Chris RosengrenHello, new user trying to setup, when running shadow-cljs watch app, I got the error: HTTP startup failed java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found. Adding org.jboss.xnio/xnio-nio {:mvn/version "3.4.6.Final"} to deps.edn fixed it and the clojurescript compiled. Am I doing something wrong?#2018-05-1510:33thheller@christopher.rosengren if you use tools.deps you must upgrade that to the latest version. needs this fix https://dev.clojure.org/jira/browse/TDEPS-26#2018-05-1510:33Chris RosengrenThanks.#2018-05-1510:34thhellerbut yeah adding the dep also works#2018-05-1511:23grounded_sage@thheller I've been slowly collating things but there is a heap that I simply didn't bookmark because I didn't think. This is that demo that they used to show off React Fiber. https://svelte-sierpinski.surge.sh/ Another animation example. https://svelte.technology/repl?version=2.6.1&amp;gist=c1cdfadefd7c7aee3e312b2b7e332053 https://svelte.technology/repl?version=2.6.0&amp;gist=cfdaa8caaba693666acefba8b85a050b#2018-05-1511:28grounded_sage@troglotit this is the thing I was referring to https://custom-elements-everywhere.com/ I also know this is a thing as I have watched a few videos with respect to Elm being able to interact with the non-typed js world and other people saying they let front end devs write in whichever framework they wish and treat it as front-end "microservices".#2018-05-1511:29grounded_sageIf you look at the first thing in FAQ at the bottom it clearly states that the full intention is for people to share components everywhere which doesn't make sense with runtimes embedded.#2018-05-1511:31grounded_sage@thheller db monster one. https://svelte-dbmonster.surge.sh/#2018-05-1511:33grounded_sageThere is quite a bit of stuff on here which may be relevant to your queries also. https://github.com/flagello/awesome-sveltejs#built-with-svelte#2018-05-1511:33troglotit<my-awesome-component/> to be able to render it - this component should be bundled with it’s renderer. If it’s handwritten/Svelte or similar - it’s ok, but it can come with React or something else#2018-05-1511:45grounded_sage@troglotit that's the perspective I am looking at right now. React and React Native was created to hedge bets on which platform will win. Whilst dealing with dev productivity across platforms and web version + edge cases + web inconsistencies. Everyone grabbed the vdom and ran with it. Now we have a very fragmented web ecosystem with less composition/sharable work. I haven't been around for a long time in programming/web world but from where I am standing it looks like the PWA and newer more consistent browsers with automatic updates will have us going back to JS without bundled runtimes.#2018-05-1511:58thheller@grounded_sage those are all toy examples. I was thinking more along the line of some kind of form with some dynamic properties (eg. select boxes depending on previous choices, suggestions from the server and so on)#2018-05-1512:01thhellerweb components would be nice but its all this old mutable horror show I want to get away from#2018-05-1512:02grounded_sageYea I feel ya. I will ping them in Gitter and see if anyone has anything.#2018-05-1512:10grounded_sageThis is built with Sapper/Svelte. https://offert.hitta.se/#2018-05-1512:12thhellerI don't understand .se but it only seems to be the homepage. the "dynamic" stuff seems to be something else https://www.hitta.se/s%C3%B6k?vad=snickeri#offert#2018-05-1512:15thhellerI'm in the GraphQL/om.next/fulcro camp. Those actually seem to do something "better"#2018-05-1512:16thhellerbut they have downsides too ... nothing is perfect#2018-05-1512:20grounded_sageYea fulcro seems really good when doing full stack#2018-05-1512:22thhellerApollo has some interesting stuff as well but who wants to do JS 😉#2018-05-1512:23grounded_sageEvery time I look at Fulcro the docs and resources impress me#2018-05-1512:23grounded_sageI really don't want to do JS haha. I'm using Svelte/Sapper because I can't justify the runtime and there isn't a good static site generator story for Clojure ecosystem.#2018-05-1512:24troglotitI started at new position w/o experience in april - spent month learning and writing fulcro, then decided to rewrite in re-frame.#2018-05-1512:25troglotitI came from JS & React. I had thoughts of writing bindings to Apollo for reagent, but I’m too inexperienced#2018-05-1512:41grounded_sageInteresting. I haven't looked at Apollo before only heard about it#2018-05-1512:42thhellerhttps://www.gatsbyjs.org/ might be interesting for you as well#2018-05-1512:47grounded_sageYea I assessed that and really considered it. Though I wasn't sure how far I would get due to plugins etc. I already messed around enough in Cljs playing around with React Native for Web. If I was going to use plain React I would use Preact-cli due to preact being more lightweight. Anything more complex I'd rather use Cljs.#2018-05-1513:00grounded_sageAs a side note relating to Gatsby this is interesting @thheller https://blog.mgechev.com/2018/05/09/introducing-guess-js-data-driven-user-experiences-web/#2018-05-1513:09thhellerseems like a bit of over-engineering but interesting#2018-05-1513:22grounded_sageDefinitely.#2018-05-1513:49grounded_sageI've done a heap of reading and testing. Preact is pretty comparable and I don't see how Svelte way could be made functional.#2018-05-1514:40jjttjjI'm very new to node and electron and shadow-cljs. Am I supposed to be able to access node libraries from the :browser targeted renderer in electron? It seems like (defonce fs (js/require "fs")) works for me but (:require ["fs" :as fs]) results in Uncaught SyntaxError: Unexpected token . Also, this might be unrelated, but when I (defonce fsr (js/require "fs-readdir-recursive")) after installing the package with npm I get Uncaught ReferenceError: fs_readdir_recursive is not defined This is all after adding only these modifications to the shadow-cljs electron example. Any obvious things I'm doing wrong here?#2018-05-1514:48thheller@jjttjj I have not done any electron development myself and I don't know what the recommend approach is. Do you know if you are supposed to use require in the renderer or not?#2018-05-1514:48thhelleryou can set :js-options {:js-provider :require} in the renderer config which should make all packages work#2018-05-1514:49thhellerbut I honestly do not know if you are supposed to it that way or not#2018-05-1514:56thhellerseems to be ok to just use :js-provider :require. this will just call js/require basically instead of trying to bundle/convert the code that :browser usually does#2018-05-1514:59jjttjjOk great that seemed to work for fs thanks! Still having issues with the external node dep ["fs-readdir-recursive" :as fsr] ... (def x2 (fsr/read dir)) getting shadow.js.shim.module$fs_readdir_recursive.read is not a function#2018-05-1515:02thhellerit only exports the single function#2018-05-1515:02thheller(def x2 (fsr dir)) should work#2018-05-1515:03jjttjjthat did it! awesome thanks so much for the help 🙂#2018-05-1519:21denik@thheller is self-hosted cljs broken or just this demo? I can’t get it to run: https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2018-05-1519:22thhellercan't get what to run?#2018-05-1519:22denik
npm install -g shadow-cljs
git clone 
cd shadow-cljs
shadow-cljs watch bootstrap-host bootstrap-support
open 
#2018-05-1519:24thhelleruhm I didn't touch that example in forever. seems to be missing reagent#2018-05-1519:24denikthat’s what I got too#2018-05-1519:27thhellershould compile fine if you add reagent to the classpath#2018-05-1519:27thhellerthis is not an official example though. its just files I randomly have in the repo 😛#2018-05-1519:28denikI added it to the deps in the lein cljs profile and it didn’t work 😕#2018-05-1519:30thhellerthis stuff is way more complicated than it needs to be in the repo since it does stuff in the worker#2018-05-1519:31thhellershadow-cljs watch bootstrap-host bootstrap-support bootstrap-worker#2018-05-1519:33thhellerno wait .. looking at the wrong file#2018-05-1519:33thhellershadow-cljs watch bootstrap-host bootstrap-support#2018-05-1519:34thhellerthis works if you remove the reagent.core from the config#2018-05-1519:34thheller
:bootstrap-support
  {:target :bootstrap
   :output-dir "out/demo-selfhost/public/bootstrap"
   :exclude #{cljs.js}
   :entries [cljs.js demo.macro demo.lib]
   :macros []}
#2018-05-1519:35thhellerdon't know about reagent though.#2018-05-1519:35thheller
(require '[demo.lib :as x])
   (js/console.log "x" (x/hello))
#2018-05-1519:35thhellerthis works demo.selfhost.simple#2018-05-1520:01denik@thheller I’d need to be able to require the cljs deps of the project within self-hosted cljs, so how would I get reagent in there?#2018-05-1520:01thhellerit should just work with reagent#2018-05-1520:02thhellerbut I don't remember which reagent version I tested#2018-05-1520:02thhellerit might break with 0.8.#2018-05-1520:05denikhmm. for one I’m in this yakshave because having a cljs repl as a devtool in browser would be cool but also because unfortunately I can’t seem to get a cljs-repl going within cursive from an embedded shadow-cljs process (I get a window prompt)#2018-05-1520:05denikis there a repl-based workaround?#2018-05-1520:05thhellerare you using lein with cursive?#2018-05-1520:05thhellerif so you need to add the nrepl-middleware for the prompt to go away#2018-05-1520:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-05-1520:12denik🙏:skin-tone-2: problem solved#2018-05-1520:07denikyes. aha! ok, will try#2018-05-1520:11justinlee@thheller you sound more professorial than I was expecting 🙂#2018-05-1520:12thhelleris that a good thing or a bad thing? 🙂#2018-05-1520:13justinleeit’s neither good nor bad. it’s just funny to have a person who is nothing more than text to me suddenly become real 🙂#2018-05-1520:14thhellerI don't have a degree or anything of that sort though 😉#2018-05-1520:29justinleewell you have demonstrated that that is obviously not needed#2018-05-1523:27grounded_sage@jjttjj what are you using Electron for?#2018-05-1523:36jjttjj@grounded_sage basically experimenting with making just a "file explorer" type thing. Fed up with the default Windows one and have a few ideas I want to play with. Started with jvm clj but wasn't liking the gui situation there#2018-05-1523:38grounded_sage@jjttjj kind of like this? https://keminglabs.com/finda/
#2018-05-1600:22jjttjjCool, yeah something like that. Search definitely needs improvement. Also was thinking some backup mechanisms#2018-05-1600:25jjttjjBasically just want a playground where I can mess with files+UI :)#2018-05-1605:22bupkiswhat would be the best way, in a shadow-cljs build to include CSS that's bundled with an NPM module? For the javascript itself, i'm using the shadow-cljs Guide's recommendation of "some-lib" :default SomeExport in the ns :require, etc., but not sure how to include the CSS. In JS I could use a similar import statement for the CSS, but here I've resorted to copying the file out of the npm_modules subdir and into my :http-root#2018-05-1606:28thheller@samuel.wagen yeah CSS "includes" are not yet supported. didn't have time to work on it yet.#2018-05-1606:38bupkis@thheller thanks, that's fine, I'll use my bandaid for now 🙂#2018-05-1606:38bupkisif you point me in the right direction, I might try to implement it myself#2018-05-1606:40thhellerNothing to point to really. I have a basic idea for a concept but nothing implemented yet.#2018-05-1606:41thhellerI also won't do it via ns require. I think that is a bad idea.#2018-05-1606:41thhellerIt will probably be some kind of macro#2018-05-1606:41thheller(assets/include "./some.scss")#2018-05-1606:41bupkisyeah I agree, overloading ns require to do too much feels hacky#2018-05-1606:41thheller(assets/resource-uri "./some.png" :size "300x200")#2018-05-1606:42bupkisthat would be lovely 🙂#2018-05-1606:42thhellerthats the current concept#2018-05-1606:43thhellerjust need a way to do it that doesn't break the compiler cache#2018-05-1606:43thhellerand is sort of flexible/extendable enough to support sass/less/imagemagick/...#2018-05-1606:46bupkismaybe sass/less could stay like the current include of own js files - the processor runs externally and shadow-cljs only deals with the produced artifacts (https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects)#2018-05-1606:48thhellerproblem is you can't process them one by one. you need to collect all and then process them together#2018-05-1606:49thhellerI will probably do a "simple" version first that doesn't do anything and just records which resources were "included"#2018-05-1606:49thhellerand then export that info so another tool can do the actual work#2018-05-1606:50thhellerI have some custom tooling built on top of node-sass in my work project#2018-05-1606:50thhellermight just extract it from there#2018-05-1609:28kurt-o-sysIf I get it well, cljsjs packages don't work pretty well with shadow-cljs? At least, I can't make it work with [cljsjs/auth0-lock "11.5.2-0"]#2018-05-1609:29kurt-o-sysSo I tried to add the auth0-lock to package.json#2018-05-1609:29kurt-o-sys
"dependencies": {
    "auth0-lock": "^11.6.1",
   ...
}
#2018-05-1609:29kurt-o-sysbut than, I get this:
The required JS dependency "auth-lock" is not available, it was required by "ui_app/components/navbar.cljs".

You probably need to run:
  npm install auth-lock
#2018-05-1609:29kurt-o-sys(and I ran npm install auth-lock already a few times, but it's still the same...)#2018-05-1609:30kurt-o-sysI guess I must be missing something 😛#2018-05-1609:30thhellerauth0-lock or auth-lock? which one is it? 😛#2018-05-1609:30kurt-o-sysoh... sh*t#2018-05-1609:31kurt-o-systhx a lot for solving this extremely hard bug 😉#2018-05-1617:11denikthis also prevents me from getting back into the parent clj process#2018-05-1617:12denikand it seems to have killed cljs compilation#2018-05-1617:12denikfinding myself restarting the repl more than in comfy in clojure 😕#2018-05-1617:13thhellerwhat did you send before the timeout?#2018-05-1617:14thhellerquitting the REPL should never be necessary#2018-05-1617:15thhellerif all else fails you can do (shadow.cljs.devtools.server/reload!)#2018-05-1617:15thhellerbut no without more info I have no idea what could be happening#2018-05-1617:18denikI deleted a function which caused the recompile. afterwards I got the time out ¯\(ツ)/¯#2018-05-1617:19denik(shadow.cljs.devtools.server/reload!) from the timed out repl?#2018-05-1617:19thheller> I deleted a function which caused the recompile.#2018-05-1617:19thhellerwhat does that mean?#2018-05-1617:23thhellerthe :cljs/quit didn't timeout? I can't see what you sent before the first :cljs/quit and :cljs/quit technically cannot timeout since it is never sent to the client#2018-05-1617:25thhellerI suspect that you are in a CLJ REPL already? I cannot tell which client you are using. are you running standalone or embedded? too many moving parts, need to narrow it down#2018-05-1617:25denikI was in a CLJS repl, sorry should’ve made that clear#2018-05-1617:25denikusing shadow-cljs embedded#2018-05-1617:26thhelleryes I recognize that error but I need to know what triggered it. so you must have sent something but I can't see what was sent#2018-05-1617:26deniknow hitting this:
[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".
#2018-05-1617:26denikit previously worked#2018-05-1617:26denikI didn’t send anything. The message before this was a recompile log.#2018-05-1617:27thhelleranything in the log? should get a warning why it is not available#2018-05-1617:29thhellersince you are running the embedded version: what else are you doing in the VM? use tools.namespace or anything like that?#2018-05-1617:29thhellerthat can seriously mess with things#2018-05-1617:46denikI’m using mount which uses tools.namespace I believe#2018-05-1617:46deniknot getting more warnings
[:app] Compiling ...
[:app] Build completed. (928 files, 2 compiled, 0 warnings, 0.78s)
[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/core.cljs".
#2018-05-1617:49thhelleryeah sorry. not a clue. is that after a fresh restart or still in this broken state?#2018-05-1617:50thhellertools.namespace can critically mess with the internal state of the shadow-cljs server runtime#2018-05-1617:50thhellerso you might need to reload! that at some point#2018-05-1617:52thhellerembedded you are pretty much on your own which is why I don't recommend doing that#2018-05-1617:53thhelleryou gain nothing but these kinds of headaches from it#2018-05-1617:58denikFresh restart#2018-05-1617:58thhellerin the clojure REPL try ( "net/cgrand/xforms.cljc") after it fails#2018-05-1617:59thhellerno idea why it would disappear#2018-05-1617:59thhelleryou can turn on debug logging#2018-05-1617:59thhellerbut that depends on which logging framework you are using in embedded#2018-05-1618:01thheller
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{HH:mm:ss,SSS}] %m%n

log4j.logger.shadow=DEBUG
#2018-05-1618:01thhellerthis is my log4j.properties#2018-05-1618:02denikAFK will try in a second.#2018-05-1618:02denikShould I turn verbose on?#2018-05-1618:02thhellerprobably wont be much help#2018-05-1618:02thhellerthe classpath indexer is not part of the build so its errors go to the log instead#2018-05-1618:05denikI use the repl because I want to get rid of the command line. There are to many build commands that need to be run in a certain order etc to get a project going. My current setup I run one Clojure function in the repl and it takes care of shadow-cljs and the backend. Is there a way to manage multiple Clojure repls each with their own jvm from one (master-)repl?#2018-05-1618:06thhellerwhich client are you using?#2018-05-1618:08thhellerI do understand the desire to have all of this running with one click#2018-05-1618:09denikwhat do you mean by client?#2018-05-1618:09thhellerREPL client#2018-05-1618:09denikintellij cursive#2018-05-1618:09deniklein repl local#2018-05-1618:10thhellerunfortunately it is not so easy to completely isolate shadow-cljs due to clojure being hard to isolate#2018-05-1618:10thhellerbut first we should get your logging setup done#2018-05-1618:10thhellerso we can at least get a clue about what is going on#2018-05-1618:11thhellerare you using any kind of logging currently? log4j, logback or anything like those?#2018-05-1618:11denikno#2018-05-1618:13denik@thheller what would I need to do?#2018-05-1618:14thhelleradd these deps to your dev profile#2018-05-1618:14thheller
[org.slf4j/slf4j-log4j12 "1.7.25"]
     [log4j "1.2.17"]
#2018-05-1618:14thhellerif you have a src/dev or dev source path already configured#2018-05-1618:14thhellercreate a log4j.properties there with the content I pasted above#2018-05-1618:14thhellerdone#2018-05-1618:16thhellerthe config only logs to the console since that is what I'm using for shadow-cljs but it should be printing more info#2018-05-1618:23thheller
[10:59:38,136] classpath updates total:2
[10:59:38,137] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,205] classpath update [:mod] C:\Users\thheller\code\shadow-cljs\src\ui-release\shadow\cljs\ui\dist\js\ui.js
[10:59:38,271] :shadow.cljs.devtools.server.system-msg/resource-update {:namespaces #{module$shadow$cljs$ui$dist$js$ui}, :deleted #{}, :updated #{module$shadow$cljs$ui$dist$js$ui}, :added #{}}
#2018-05-1618:23thhellershould see messages like those#2018-05-1619:31denik@thheller followed your instructions but it doesn’t seem to work, only getting warnings
[15:29:41,605] XNIO version 3.3.8.Final
[15:29:41,639] XNIO NIO Implementation Version 3.3.8.Final
15:29:42.237 WARN  [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "/Users/den/Dropbox/dev/code/vimsical/web-stack/resources/templates/frontend/core.cljs", it will not be available.
15:29:49.381 WARN  [shadow.build.classpath] (nREPL-worker-1) failed to inspect resource "jar:file:/Users/den/.m2/repository/vimsical/web-stack/0.1.01/web-stack-0.1.01.jar!/templates/frontend/core.cljs", it will not be available.
15:29:49.610 WARN  [shadow.build.babel] (nREPL-worker-1) can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs.
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server running at 
shadow-cljs - socket repl running at localhost:61783
shadow-cljs - nREPL server started on port 61785
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (928 files, 3 compiled, 0 warnings, 7.10s)

[:app] Compiling ...
[:app] Build failure:
The required namespace "net.cgrand.xforms" is not available, it was required by "ankify/frontend/util/dom.cljs".
#2018-05-1619:34thhellerhmm might be a conflict with some other logging library#2018-05-1619:39thhellerwhat exactly are you doing to trigger the second compile?#2018-05-1619:41denikuncommenting [net.cgrand.xforms :as x]#2018-05-1619:41denikjust got it to work. restarted intellij!#2018-05-1619:41thhelleruhm ... I assumed the problem was that is compiled once fine and then failed#2018-05-1619:41thhellerthat probably just meant that the lib wasn't on the classpath?#2018-05-1619:43denikIt worked initially through a several compilation, then the repl timeout caused me to restart the repl, then it didn’t work, the I deleted the compiled js, restarted intellij. now it works#2018-05-1619:43denikyeah I think so too, sth todo with the classpath#2018-05-1620:38lilactownI'm running into a problem with a particular npm package, graphql#2018-05-1620:38lilactownwhen using it in Node.js, it works just fine as expected#2018-05-1620:39lilactownhowever, when using it on the client-side (it's a peer dependency of another npm package, graphql-tag, which translates GraphQL strings to an AST), I get this error:
source.js:15 Uncaught TypeError: Cannot call a class as a function
    at new C.Source (source.js:15)
    at C.parse (parser.js:34)
    at c (graphql-tag.umd.js:136)
 ...
#2018-05-1620:43lilactownit seems to not be passing this check:
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
#2018-05-1620:43lilactownthe offending line:
var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
#2018-05-1621:59lilactownhey it looks like https://shadow-cljs.github.io/docs/UsersGuide.html is down#2018-05-1700:56wilkerluciohad anyone tried to use shadow-cljs to create chrome extensions?#2018-05-1700:57wilkerlucioI'm trying to create a developer tool there, but the connection doesn't work, it's trying to use a path relative to the extension, which ends up like this:
shadow.cljs.devtools.client.browser.js:811 WebSocket connection to '' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
#2018-05-1700:57wilkerluciois there a way to force the URL for the websocket to be used as localhost instead of relative to page?#2018-05-1701:08wilkerluciogot it, closure defines 🙂#2018-05-1701:08wilkerlucio
:closure-defines {shadow.cljs.devtools.client.env/devtools-url ""}
#2018-05-1701:21wilkerlucioafter more setup, new issue:#2018-05-1701:21wilkerlucio
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-8QW/FL/JEeHNL6TDE0m/ACLlRnGNJ8rr574pBcCZ1hM='), or a nonce ('nonce-...') is required to enable inline execution.
#2018-05-1701:21wilkerluciothat happens when shadow tries to reload the files#2018-05-1701:21wilkerlucioI tried adding "content_security_policy": "'unsafe-inline'", to the manifest, but chrome doesn't allow that =/#2018-05-1701:21wilkerlucioany ideas on how to get around that?#2018-05-1704:41wilkerlucioanother issue regarding chrome, I need to compile and run things also in content scripts, and there it's pretty hard to read content dynamically, I'm seeing by the docs that shadow doens't use other compilation modes in dev, but I really need something like :whitespace, or anything that outputs everything in a single file, is there a way to do this in dev mode?#2018-05-1708:19thheller@lilactown this was a bug in the closure compiler. the latest shadow-cljs version has the latest closure so try that#2018-05-1708:21thheller@wilkerlucio :devtools {:devtools-url ...} is shorter or :devtools {:use-document-host false} should also work#2018-05-1708:23thhellerhmm CSP would need the nonce. wonder if there is a way to get it#2018-05-1709:32thheller@wilkerlucio I changed the eval method in 2.3.23 and this seems to work then https://github.com/thheller/shadow-cljs/blob/master/out/chrome-ext/manifest.json#L10#2018-05-1709:33thhellertook the default CSP rules from https://developer.chrome.com/apps/contentSecurityPolicy and added script-src: 'self' 'unsafe-eval';#2018-05-1709:34thhelleronly did the basic background.js test though. that loads fine and live-reload, REPL work#2018-05-1712:37wilkerlucio@thheller awesome! now the reload is working on background and on the devtool 🙂#2018-05-1712:37wilkerluciobut I noticed a few things after updating (I was in 2.3.21 before):#2018-05-1712:38wilkerlucio- my builds now seem to be starting one by one (I run 4 builds at once, so the startup got noticable slower)#2018-05-1712:39thhelleroh. yeah I know why. will fix.#2018-05-1712:39wilkerlucio- the regular browser devcards build, it tries to use my IP directly and it didn't connected, I had to set the :devtools-url manually for it, while before it worked without setup#2018-05-1712:40thhellerhmm maybe my boolean logic failed again, will check#2018-05-1712:41wilkerluciothanks#2018-05-1712:42wilkerlucioand about the content-script page, you have any idea what we can do to work there?#2018-05-1712:42thhellerwhat is that?#2018-05-1712:42wilkerluciothe loads seems to fail completely there, the content-script permission is weird#2018-05-1712:43wilkerlucioin the past I used to work in dev mode using :whitespace compilation for it so it loads on a single file#2018-05-1712:43wilkerlucionow it's just a bunch of:#2018-05-1712:43thhellerwhat is content-script?#2018-05-1712:43wilkerlucio
09:41:46.304 main.js:3027 GET  404 (Not Found)
(anonymous) @ main.js:3027
env.load @ main.js:3020
(anonymous) @ main.js:3065
09:41:46.306 main.js:3027 GET  404 (Not Found)
(anonymous) @ main.js:3027
env.load @ main.js:3020
(anonymous) @ main.js:3065
09:41:46.307 main.js:3027 GET  404 (Not Found)
(anonymous) @ main.js:3027
env.load @ main.js:3020
(anonymous) @ main.js:3065
09:41:46.307 main.js:3027 GET  404 (Not Found)
(anonymous) @ main.js:3027
env.load @ main.js:3020
(anonymous) @ main.js:3065
09:41:46.308 
#2018-05-1712:43wilkerluciocontent-script is when you want a chrome extension to inject code in the user page#2018-05-1712:44wilkerlucioon manifest.json is like this:#2018-05-1712:44wilkerlucio
"content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["js/content-script/main.js"],
      "run_at": "document_start"
    }
  ],
#2018-05-1712:44thhellerhmm dev mode will probably not work for this#2018-05-1712:45wilkerlucioI wrote some about it in the past, because figwheel also didn't worked good for it: https://medium.com/@wilkerlucio/setting-up-figwheel-for-chrome-extensions-content-scripts-f1631d8e782a#2018-05-1712:45thhellerwe really need to control the global scope for the devtools stuff#2018-05-1712:45wilkerlucioI wasn't sucessful on making it work proper, but there is some info about loading there#2018-05-1712:47thhellerjust to clarify: this is for javascript that will be injected into any random page? meaning pages not written by you?#2018-05-1712:47wilkerlucioyes, correct#2018-05-1712:47thhelleryeah :dev builds will never be reliable for this#2018-05-1712:49thheller:release is probably the only safe thing for this#2018-05-1712:50thhellerI could add a :dev thing that only outputs a single file so the debug loader is not used#2018-05-1712:50thhellerbut live-reload or REPL will never work properly#2018-05-1712:51thhelleryou can get lucky and have it work but it won't be reliable or even safe#2018-05-1712:52wilkerluciook, it's reasonable, because currently it just doesn't work as dev at all, I would have to manually re-trigger a release everytime on every update#2018-05-1712:52wilkerlucioif we can it just re-compiling in a single file automatically, would help a lot#2018-05-1712:57wilkerluciobut I'm wondering, why can't the REPL work there?#2018-05-1712:58thhellerduring dev mode it assumes that YOU own the global scope#2018-05-1712:58thhellermeaning it creates a bunch of global variables, eg. cljs, goog and so on#2018-05-1712:59thhellerwhen injected into the page you do not own the global scope so the potential for conflicts is high#2018-05-1712:59thhellerwhat are you trying to do?#2018-05-1713:00thhellerits also a bit scary since you are technically giving the page you inject into access to your REPL#2018-05-1713:01thhellersuppose your plugin injects into a page that is running a dev build#2018-05-1713:01thhelleryour code would replace the actual page code#2018-05-1713:01thhellerand everything would explode#2018-05-1713:06wilkerluciobut on content scripts you kind have your own context, and you can inject those variable and reliably access then#2018-05-1713:07wilkerlucioI'm making a fulcro-inspect version that runs on chrome ext / electron#2018-05-1713:07thhellerI thought the scripts are injected? ie eval'd in the page?#2018-05-1713:07wilkerlucioso the content-script will have to hook into the fulcro tools to send information to the remote ui (that will be in a chrome devtool/electron)#2018-05-1713:07wilkerluciothey are, but they have a special context#2018-05-1713:08wilkerluciohttps://developer.chrome.com/extensions/content_scripts#2018-05-1713:08wilkerlucioAlthough the execution environments of content scripts and the pages that host them are isolated from each other, they share access to the page's DOM. #2018-05-1713:09thhellerah so they are isolated#2018-05-1713:09thhellerok thats fine then#2018-05-1713:09thhellerok then scratch everything I said.#2018-05-1713:12wilkerluciosorry I wasn't clear before, it's been a while I read that, so yeah, separated envs, shared DOM#2018-05-1713:13thhellerhmm whats the minimum of config I need for this?#2018-05-1713:13thhellerwill need a test setup for this otherwise I'd just be guessing#2018-05-1713:15wilkerluciothis should be fine on manifest:#2018-05-1713:15wilkerlucio
"content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["js/content-script/main.js"],
      "run_at": "document_start"
    }
  ],
#2018-05-1713:15wilkerluciothat will make the script run on every page#2018-05-1713:16wilkerluciofor compilation I currently have this:#2018-05-1713:16wilkerlucio
:chrome-content-script {:target          :browser
                                        :output-dir      "shells/chrome/js/content-script"
                                        :asset-path      "js/content-script"
                                        :closure-defines {:devtools-url ""}
                                        :modules         {:main {:entries [fulcro.inspect.chrome.content-script.main]}}}
#2018-05-1713:25thhellerok this should be easy#2018-05-1713:26thhellerthe :browser config is not really suited for this though#2018-05-1713:34thhellerit appears that I must reload the chrome extension before it uses any updated code#2018-05-1713:34thhelleror am I doing something wrong?#2018-05-1713:42thheller@wilkerlucio how important is "run_at": "document_start" to you? would document_idle be enough?#2018-05-1714:01wilkerlucio@thheller I don't know yet, was just setting up the env, maybe document_idle will be enough#2018-05-1714:02wilkerluciois there a roadblock with document_start?#2018-05-1714:02thhellernah not really. currently the debug loader tries to be smart and checks if it can use document.write to load scripts#2018-05-1714:02thhellerwith document_start that is true#2018-05-1714:02thhellerbut that causes the scripts to load in your the ppage#2018-05-1714:03thhellernot in the isolated context 😛#2018-05-1714:03wilkerluciohehe, maybe we can have a flag for it#2018-05-1714:03wilkerlucioso we can override on content-script case#2018-05-1714:03thhellerwith document_idle the check fails and it then does the usualy async load + eval#2018-05-1714:03thhelleryeah adding that currently#2018-05-1714:21zarkoneHi! trying to do release build of project. Got this output for :target :node-script:
var shadow$provide = {};
#!/usr/bin/env node
(function(){
...
#2018-05-1714:22thheller@zarkone which version are you one? I thought I fixed that#2018-05-1714:22zarkoneoh, sorry, forgot to checkout. I'm on something-recent-11#2018-05-1714:22zarkonewill now try to update, thanks!#2018-05-1714:23kennyAre macros supposed to work with shadow-cljs node-repl?#2018-05-1714:24thhellerusing macros or actually writing defmacro? using yes, writing no.#2018-05-1714:24kennyLatter.#2018-05-1714:24kennyIs there a way to write macros in node?#2018-05-1714:25kennyNot in node but to be used in node.#2018-05-1714:26kennyMy use case is I'd like some computation to be done at compile time and statically defined in the app.#2018-05-1714:26thhellerits the same deal as with any other macro for CLJS#2018-05-1714:26thhellerthey need to be written in CLJ#2018-05-1714:26kennyRight but I can't get it to work with node-repl.#2018-05-1714:26thhelleryou could write them in shadow-cljs clj-repl#2018-05-1714:26thhelleryou can't write them inside node-repl since that is a CLJS repl#2018-05-1714:27kennyOh I see. So I need to run two REPLs?#2018-05-1714:28kennyIt confused me because when developing my browser application I am able to write and use macros by default.#2018-05-1714:28thhellerhmm? the rules for the browser are identical?#2018-05-1714:29kennyI was trying to follow this example: https://github.com/shadow-cljs/examples/tree/master/macros.#2018-05-1714:29kennyThis is what happens: https://github.com/kennyjwilli/shadow-cljs-macros#2018-05-1714:30thhellernot how that works#2018-05-1714:30thheller
(ns shadow-macros.core
  (:require
    [shadow-macros.macros :include-macros true :as macros]))
#2018-05-1714:30zarkone@thheller thanks! got rid of this error.#2018-05-1714:30thhellerthis will try to load shadow-macros/macros.cljs AND the .clj file#2018-05-1714:30thhellersince only the .clj file exists this fails#2018-05-1714:30zarkonealso, getting this with release build:
------ WARNING #1 --------------------------------------------------------------
 File: com/cognitect/transit.js:649:8

 variable module is undeclared
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/cognitect/transit/impl/writer.js:256:8

 variable isObject is undeclared
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/types.js:384:70

 variable Buffer is undeclared
--------------------------------------------------------------------------------


#2018-05-1714:31thheller@zarkone yeah disregard those ... they aren't used anyways#2018-05-1714:31kennyI believe I also tried just :require-macros and that did not work either.#2018-05-1714:32thheller@kenny the macros example I made is how you should setup macros#2018-05-1714:32thhellermeaning you write a .cljs file and .clj file with the same name#2018-05-1714:32thhellerand the cljs file does a require-macros for itself#2018-05-1714:33thhellerNEVER do dedicated .macros namespaces. thats just makes things more confusing#2018-05-1714:33zarkone@thheller just haven't seen this warnings with boot-cljs and :advanced optimizations. Trying to figure out why some parts of my code in release silently doesn't work 🙂 Thank you!#2018-05-1714:33thheller@zarkone boot probably doesn't have those checks enabled#2018-05-1714:34zarkoneright, that might be the case: haven't seen default params enabled in boot for cljs compilation#2018-05-1714:34thheller@kenny taking my macros example you would write your macro in the app/lib.clj#2018-05-1714:35thhellerand then use it from app/main.cljs#2018-05-1714:35thhelleryour example tries to skip the "additional" .cljs file but it is very important to have that#2018-05-1714:35thhellerdo not try to shortcut your way out of that#2018-05-1714:36kennyI had no idea that was a requirement.#2018-05-1714:36thhellerit is not a requirement but it saves you from dealing with :require-macros or :include-macros all over the place#2018-05-1714:36thhellergetting those correct is just a nightmare#2018-05-1714:36kennyI totally agree.#2018-05-1714:37thhellerwith the recommended setup you do :require-macros ONCE and only to require itself#2018-05-1714:37thhellerno-one else ever needs to to know about macros at all#2018-05-1714:37kennyWait so I don't even need to :include-macros then?#2018-05-1714:37thhellerexactly#2018-05-1714:38thhellerhttps://github.com/shadow-cljs/examples/blob/master/macros/src/app/main.cljs#L1-L2#2018-05-1714:38thhellerclean and simple#2018-05-1714:39thheller@zarkone CLJS by default doesn't enable those checks either. its just something shadow-cljs does. if you want to find out why things don't work shadow-cljs check your-build might help#2018-05-1714:39kennyYep that works. Wow, that clears a lot up. Thank you. I think this bit of information is important enough to include in the documentation somewhere.#2018-05-1714:40zarkone@thheller oh, thanks a lot! will try it out#2018-05-1714:40thhelleris that not documented anywhere else? this has been in CLJS for a couple of years#2018-05-1714:40thhellerhttps://dev.clojure.org/jira/browse/CLJS-948#2018-05-1714:40kennyI don't think I've read anywhere about a "suggested" pattern.#2018-05-1714:40thhellerI always wonder why people still do the old way#2018-05-1714:41thheller3+ years#2018-05-1714:41thhellerare there any official macro docs?#2018-05-1714:42kennyThere's this https://clojurescript.org/guides/ns-forms. But doesn't really suggest a pattern.#2018-05-1714:42kennyI'd even argue that makes things more confusing because it introduces you to all the different ways you can use macros 🙂#2018-05-1714:42thhellerI guess its mentioned under Implicit Sugar#2018-05-1714:42zarkone@thheller actually, I've known that I can get rid of :require-macros from recent defn podcast where you've talked about it 😄#2018-05-1714:43thhellerbut yeah super confusing that its not mentioned as the first and only thing#2018-05-1714:43kennyExactly. That's what it needs. I don't have any reason to care about all that other stuff.#2018-05-1714:43zarkonebtw, was really good episode#2018-05-1714:44thhellerit was fun! a bit all over the place but fun. 🙂#2018-05-1714:44kennyIs there a technical reason why the dummy CLJS ns can't be created behind the scenes?#2018-05-1714:47kennyThat may be what your issue there is talking about?#2018-05-1714:48kennyNo that's different.#2018-05-1714:48thhellerthe CLJS ns serves several purposes#2018-05-1714:48thhelleryou can write actual CLJS code there that you macros might want to use#2018-05-1714:49thhellerand if you want to emit code that uses other namespaces the CLJS ns can require those to ensure they are loaded#2018-05-1714:49thhellersince .clj files can't require CLJS files#2018-05-1714:49kennySure but I may not have either of those requirements.#2018-05-1714:49thhellertechnically it could generate a simple version if only a clj file exists yes#2018-05-1714:50thhellerbut thats kinda dangerous since ANY clojure namespace can then be loaded that way#2018-05-1714:50thhellerin practice it is not a problem to create that simple .cljs file#2018-05-1714:51kennyThat's true. What is the danger in being able to load and CLJ namespace?#2018-05-1714:52thhellerconfusion mostly#2018-05-1714:53thhellerpeople might end up trying to use random CLJ libraries and wonder why they don't work#2018-05-1714:53thhellerhappens often enough as it is#2018-05-1714:54kennyThat's fair enough#2018-05-1714:55kennyThanks for the help!#2018-05-1715:16thheller@wilkerlucio the problem with a single output file is source maps. debugging without those is horror but they get waaaaaaaaaaaaay too large and slow#2018-05-1715:16thhellerwonder if that could be improved somehow#2018-05-1715:24wilkerlucio@thheller yeah, not cool, after those changes is the regular :none working?#2018-05-1715:24thhellerI'm playing with a coupe different approaches currently#2018-05-1715:25thhellera) output files like browser, load async over network#2018-05-1715:25thhellerb) output files like brower, load via document.write#2018-05-1715:25thhellerc) output one file#2018-05-1715:25thhellera) sucks because certain lifecycle events fire before the code is loaded eg. chrome.runtime.OnInstalled#2018-05-1715:26thhellerb) sucks because chrome complains and you must reload browser extension manually on each code change#2018-05-1715:26thhellerlive-reload works though#2018-05-1715:26thhellerc) seems best but source map gen is too slow 😞#2018-05-1715:28thhellerthere is this trick webpack and others do to just use eval + sourceURL#2018-05-1715:28thhellerbut that feels so dirty 😛#2018-05-1715:31thhellerunfortunately https://groups.google.com/d/msg/google-chrome-developer-tools/7mONVX1IAYo/Psq3uIBoCgAJ was never fixed#2018-05-1715:32thhelleror rather https://bugs.chromium.org/p/chromium/issues/detail?id=552455#2018-05-1715:35wilkerluciogotcha, thanks for the clarification, this is a tricky one#2018-05-1715:36jjttjjHow do prevent the clojure.spec exception from being thrown due to the non-conforming NS form from the JS string requires? I'm trying :jvm-opts ["-Dclojure.spec.compile-asserts=false"] in shadow-cljs.edn but it's not seeming to be working. is there a standard way to address this?#2018-05-1715:37thheller@jjttjj which error? invalid ns forms are never allowed?#2018-05-1715:37thhellerthe asserts can't be disabled since the ns form would be invalid#2018-05-1715:39jjttjjgetting a massive spec error relating to an invalid NS form when I try to eval the NS form in the repl. It works fine outside of the repl connection. I assumed this was due to the (:require ["js-lib" :as js-lib"] ...) string form causing issues but I could be wrong#2018-05-1715:40thhellermassive spec error where? are you trying to eval this in CLJ?
#2018-05-1715:41thhellerCLJS REPL should work fine for this but you might be trying to eval this in CLJ which won't work#2018-05-1715:42jjttjjdoh! yup that was it, thanks!#2018-05-1715:54thheller@wilkerlucio I will think about this for a bit. you can get it sort of working now by setting
:chrome-content-script
  {:target :browser
   :output-dir "shells/chrome/js/content-script"
   :asset-path ""
   :modules {:main {:entries [fulcro.inspect.chrome.content-script.main]}}
   :devtools
   {:devtools-url ""
    :http-root "shells/chrome/js/content-script"
    :http-port 8020}}
#2018-05-1715:54thhellerbut must use document_idle for now#2018-05-1715:56thheller:browser is complete overkill for this though.
:chrome-ext
  {:target :chrome.content-script
   :output-to "out/chrome-ext/background.js"
   :entry demo.chrome-bg}
#2018-05-1715:56thhellerthis is better 😉#2018-05-1716:01wilkerlucio@thheller thank you very much for looking so quickly on it, I’ll try those as soon as I get home today#2018-05-1716:20thheller@wilkerlucio good timing I guess since I wanted to try some ideas for a chrome extension for shadow-cljs anyways 🙂#2018-05-1716:54theeternalpulsein the beginner's tutorial https://medium.com/@jiyinyiyong/a-beginner-guide-to-compile-clojurescript-with-shadow-cljs-26369190b786 It mentions you have to link the index.html to the target folder. Is there a way to do this as part of the build process in the shadow-cljs.edn file?#2018-05-1717:09lilactown@thheller I'm still seeing the Uncaught TypeError: Cannot call a class as a function error in shadow-cljs 2.3.22#2018-05-1717:15lilactownupped to 2.3.23, same issue#2018-05-1717:22wilkerlucio@thheller the version with the chrome updates is released?#2018-05-1717:26lilactownI think that for now, I can just delete the _classCallCheck(this, Source); from the source of the npm module#2018-05-1717:27lilactownis there a way for me to vendor the npm module outside of node_modules/? I see that I can redirect what it resolves to, but the only options I see are either :global or :npm. I'd like to stick it in another dir that I can commit to source control#2018-05-1719:44thheller@lilactown what was your error again?#2018-05-1719:45thhelleroh wait .. it was graphql right?#2018-05-1719:46thhellerthat is not actually a closure issue#2018-05-1719:46thhellerit is this one https://github.com/graphql/graphql-js/issues/1316#2018-05-1719:47thhellermaybe not though .. the error was different https://github.com/thheller/shadow-cljs/issues/248#2018-05-1719:48thhellerhttps://github.com/google/closure-compiler/issues/2822#2018-05-1719:49thhellerthis should be fixed in closure 20180506. maybe you have an older closure dependency?#2018-05-1719:49thhelleras for npm fixing I would suggest taking the node_modules/graphql directory and publish it under @lilactown/graphql or so#2018-05-1719:50thhellerthen :resolve {"graphql" {:target :npm :require "@lilactown/graphql"}}#2018-05-1719:51thheller@theeternalpulse I don't recommend that setup. better use https://github.com/shadow-cljs/quickstart-browser#2018-05-1722:26theeternalpulseAh thanks, it is linked in the main website, so I figured it was recommended. Also there's a discrepancy in the namespaces created and built in that article#2018-05-1913:17Jonwould you suggest any fix? I can update those contents.#2018-05-1913:17Jonmaybe on https://github.com/shadow-cljs/shadow-cljs.org/issues#2018-05-1719:52thhellerthat just has a public/index.html that doesn't need to be moved or anything#2018-05-1719:58wilkerlucio@thheller sorry bothering, I can't find the updates with the chrome things, did you pushed those?#2018-05-1719:58thheller@wilkerlucio which updates? I didn't release anything related to that yet no#2018-05-1719:59thhellerjust got back home. will fiddle around with it some more now#2018-05-1720:00wilkerlucioah, gotcha, no worries, I just had assumed you pushed, my bad#2018-05-1720:01thhellerthe config I posted doesn't work? the :browser one?#2018-05-1720:03thhellerhehe I can crash chrome by pressing ctrl+shift+e trying to profile my background page 😛#2018-05-1720:08lilactownWould it matter if I had clojurescript in my lein deps? I'm using the lein integration#2018-05-1720:08lilactownRegarding the version of closure I'm usinf#2018-05-1720:09thhellerjust check with lein deps :tree#2018-05-1720:09thhellerand yes that would matter#2018-05-1720:09thhellerdepending on the order of your deps#2018-05-1720:12wilkerluciodidn't tried yet, still not home, was just trying to check it before you might go sleep 🙂#2018-05-1720:12lilactownOk I'll check when I'm back at my computer 😁#2018-05-1720:12wilkerluciowhen you announced the :target :chrome.content-script I though it was out#2018-05-1720:13thhellernah need to sort out the source map issue first#2018-05-1720:14thheller@wilkerlucio just pushed the basic version in master#2018-05-1720:14thheller
:chrome-bg
  {:target :chrome-extension
   :output-to "out/chrome-ext/background.js"
   :entry demo.chrome-bg}

  :chrome-content
  {:target :chrome-extension
   :output-to "out/chrome-ext/content-script.js"
   :entry demo.chrome-content}
#2018-05-1720:15thhellerbut no live-reload or REPL support yet#2018-05-1720:15wilkerluciocool, but isn't the background settings different from the content-script one?#2018-05-1720:15wilkerlucioI mean, the background and devtools parts were working perfectly here#2018-05-1720:15thhelleryeah you can stick with :browser for that one#2018-05-1720:16thhellerbut :browser does a lot of stuff that the chrome ext will never use#2018-05-1720:16thhellerbut if it works for you just stick with that for now#2018-05-1720:17thhellerstill just messing arround#2018-05-1720:17wilkerluciohum, so the plan is for :chrome-extension for all, I would guess content-scripts would have a different setting compared to background/popups/devtools, I guess we will figure that soon#2018-05-1720:17thhellerI need to check which capabilities the chrome ext itself has#2018-05-1720:19thhellerseems like its a bunch of different ways to execute scripts#2018-05-1720:19thhellernot sure they all run in the same runtime or are isolated from each other and so on#2018-05-1720:23wilkerlucioyeah, sometimes chrome forces you do make a lot of round before doing something, what you can do in background is different from what you can do on a popup page, that's also different from a content-script...#2018-05-1720:24thhellera different build for each seems like a bit of overkill but probably the only option#2018-05-1720:24thhellerone build means only one live-reload/REPL#2018-05-1720:24wilkerluciofor compilation I think 2 should suffice, one for content-script, and another for the rest#2018-05-1720:25wilkerluciobecause the content-script is the one that has a bit difference in security things#2018-05-1720:25wilkerluciothe other ones vary mostly on which chrome API's you can access, but that's not a compilation concern#2018-05-1720:27thhellerI thought you wanted a REPL in the content-script?#2018-05-1720:27thhellerand background#2018-05-1720:27wilkerlucioI do#2018-05-1720:28wilkerluciobut the REPL for background and pages is working already, isn't it?#2018-05-1720:28thhellerI guess#2018-05-1720:28thhellerbugs me a bit that the browser target does so much more stuff we don't need#2018-05-1720:29thhellerif I can sort out this source map issue then all targets could technically use the simplified :chrome-extension#2018-05-1720:30wilkerluciowhat kinds of things the :browser does that we don't need there?#2018-05-1720:31thhellergenerating manifest stuff#2018-05-1720:32thhelleroutput wrappers#2018-05-1720:32thhellersome code gen could be simplified#2018-05-1720:32thhellerbunch of small stuff really .. but just the config alone could be easier#2018-05-1720:33wilkerlucioagreed#2018-05-1720:33thhellerbrowser target code is 700+ lines#2018-05-1720:34thhellerchrome ext could be 60 or so#2018-05-1720:34thhellerless moving parts, easier to debug#2018-05-1720:34thhellerif it wasn't for this damn source map issue I'd be done already#2018-05-1720:37thhelleranother option would be to rewrite the manifest.json#2018-05-1720:37thhellerand just automatically add the scripts#2018-05-1720:37thheller> The list of JavaScript files to be injected into matching pages. These are injected in the order they appear in this array.#2018-05-1720:37thhellerit already takes a list of files so I could update those#2018-05-1720:39wilkerluciothe problem is happening now is at initial load, or to refresh code after?#2018-05-1720:39thhellerwhich problem? the only problem currently is no source maps#2018-05-1720:40wilkerlucioyeah, that one 🙂#2018-05-1720:40wilkerlucioso there are no source-maps at all?#2018-05-1720:40thheller:chrome-extension generates a single file#2018-05-1720:40thhellergenerating a source map for that single file takes 500ms+#2018-05-1720:40thhellersince its huge#2018-05-1720:40thhellertoo slow for watch#2018-05-1720:40thhellerand can also take quite a while to load in chrome itself#2018-05-1720:43thhellerI think the manifest edit option might be best#2018-05-1720:44thhellerdifficult to coordinate though when running 2+ builds#2018-05-1720:44thhellerdon't want to deal with file locking and such#2018-05-1720:46wilkerluciodoes that solve the problem on reloading code after?#2018-05-1720:47thhellernot related to that at all. that all works without issues in theory. didn't enable it yet#2018-05-1720:47thhellerthe reloading problem is solved though by adding the script-src 'unsafe-eval'#2018-05-1720:48thhellerthat probably won't change since we need eval#2018-05-1720:54wilkerlucioyeah, and that's fine#2018-05-1720:55wilkerluciowould be nice to do some changes before releasing, but that is a deploy process problem#2018-05-1721:25thheller:flush (362 ms) with index map with only cljs.core#2018-05-1721:25thhellerdefinitely not an option#2018-05-1721:27thheller:flush (9 ms) without any maps#2018-05-1722:10thheller@wilkerlucio master now has source maps and REPL but not live-reload doesn't work#2018-05-1722:10thhellerbut only the slow source maps so its not very practical#2018-05-1722:14thhellerwill do some more digging after sleep#2018-05-1722:20wilkerluciothank you very much, I just got home, so time to try and hack 🙂#2018-05-1722:41lwhortondoes shadow yet support continuously running tests? i know that’s not a … flavor… that people in the clj world like, but it would ease a lot of my coworker’s anxieties#2018-05-1722:43lwhortonlooks like the default node target just spits out a file, then you can run it with node automatically with :autorun . i could probably setup some node watcher to keep reading that file for changes and rerun on change, but I dont want to duplicate effort#2018-05-1722:48thheller@lwhorton :autorun is specifically only for :node-test? what else do you mean?#2018-05-1722:53lwhortoni mean that if I run shadow compile test with :autorun true it will launch the node ./out/node-tests.js and spit the results, but then the node process dies… is there a built in way to keep rerunning that node command every time node-tests.js changes?#2018-05-1722:54thhellershadow watch test#2018-05-1722:55thhellerbut no the node process will exit every time#2018-05-1722:55thhellerre-using that is currently not supported#2018-05-1722:55lwhortonthat’s exactly what i was looking for, i’m just being stupid (forgot watch was a thing)#2018-05-1722:57wilkerlucio@thheller I tried adding the content script here now, it loads, but I'm getting errors: https://www.dropbox.com/s/hevvi7n2lps765i/Screenshot%202018-05-17%2019.56.34.png?dl=0#2018-05-1722:58wilkerluciops: I'm using the .23 version yet, not sure how to use it shadow from master#2018-05-1722:59thhelleryeah thats the conflict stuff I mentioned. your injected code "replacing" the actual code in the page#2018-05-1722:59thhellerso they conflict with each other#2018-05-1722:59thhellerto try master just clone it and run lein install#2018-05-1722:59wilkerlucioah, I'm using from the npm run version#2018-05-1723:00wilkerlucioI was reading the code on repo, I guess you do some scripting to make a release (because trying to install directly from git didn't work, there is no package.json on the root)#2018-05-1723:01thhellerhmm?#2018-05-1723:02thhelleryou should just need lein install#2018-05-1723:02thhellerdon't mess with the npm stuff. it is not required.#2018-05-1723:03wilkerluciook#2018-05-1723:03wilkerlucioso I just override my local version, right?#2018-05-1723:03thhelleryes#2018-05-1723:04wilkerlucioI see it still compiles one by one, would you like me to create an issue so we don't forgot about the paralell initial compilation?#2018-05-1723:04thhelleryeah, forgot already 😛#2018-05-1723:06wilkerluciodone#2018-05-1723:08wilkerlucio
[:chrome-content-script] Build failure:
invalid require
{:entry [fulcro.inspect.chrome.content-script.main]}
ExceptionInfo: invalid require
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.resolve/resolve-require (resolve.clj:492)
	shadow.build.resolve/resolve-require (resolve.clj:482)
	shadow.build.resolve/resolve-entry (resolve.clj:496)
	shadow.build.resolve/resolve-entry (resolve.clj:495)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:341)
	clojure.core/reduce (core.clj:6747)
#2018-05-1723:08wilkerluciothe :entry is to be a namespace, right?#2018-05-1723:08thhellerjust the symbol#2018-05-1723:08wilkerlucioah#2018-05-1723:08thhellernot in a vector#2018-05-1723:08wilkerluciofacepalm#2018-05-1723:09thhellerfinal version will have specs for that but didn't add those yet 😉#2018-05-1723:09wilkerlucioyeah, I tried to be smart and just move the code, that's what I get, hehe#2018-05-1809:56heyarneCan I configure shadow-cljs to write .nrepl-port like figwheel does? That way cider could auto-detect the port#2018-05-1809:57thhellerlatest version of cider has support for shadow-cljs#2018-05-1809:57thhellershadow-cljs also writes that file when it doesn't exist#2018-05-1809:59heyarneoh cool, good to hear!#2018-05-1810:45thheller@wilkerlucio had an idea how to resolve pretty much all problem and it seems to work very nicely. nothing released yet but I wrote down some stuff here: https://github.com/thheller/shadow-cljs/issues/279#2018-05-1811:38wilkerlucio@thheller interesting, one thing occurred to my mind, if we add new files, that would mean we also have to change the manifest during dev?#2018-05-1811:39thheller"add new files?"#2018-05-1811:39wilkerlucionew cljs files#2018-05-1811:39thhellerno?#2018-05-1811:40thhelleryou only specify :entry. if the entry "reaches" the newly added file it will be automatically added#2018-05-1811:41wilkerlucioso, the files listed there are the goog bootstrap things, + shadow things, + cljs things + 1 single file for the user things, is that correct?#2018-05-1811:41thhellerhmm?#2018-05-1811:41thhellerYOU never write the files#2018-05-1811:41wilkerlucio
"background":
 {"persistent":false,
  "scripts":
  ["out/background.js", "out/cljs-runtime/goog.debug.error.js",
   "out/cljs-runtime/goog.dom.nodetype.js",
   "out/cljs-runtime/goog.string.string.js",
   "out/cljs-runtime/goog.asserts.asserts.js",
   "out/cljs-runtime/goog.reflect.reflect.js",
   "out/cljs-runtime/goog.math.long.js",
   "out/cljs-runtime/goog.math.integer.js",
   "out/cljs-runtime/goog.object.object.js",
   "out/cljs-runtime/goog.array.array.js",
   "out/cljs-runtime/goog.structs.structs.js",
   "out/cljs-runtime/goog.functions.functions.js",
   "out/cljs-runtime/goog.math.math.js",
   "out/cljs-runtime/goog.iter.iter.js",
   "out/cljs-runtime/goog.structs.map.js",
   "out/cljs-runtime/goog.uri.utils.js",
   "out/cljs-runtime/goog.uri.uri.js",
   "out/cljs-runtime/goog.string.stringbuffer.js",
   "out/cljs-runtime/cljs.core.js",
   "out/cljs-runtime/clojure.string.js",
   "out/cljs-runtime/shadow.cljs.devtools.client.console.js",
   "out/cljs-runtime/shadow.module.shared.append.js",
   "out/cljs-runtime/demo.chrome_bg.js",
   "out/cljs-runtime/shadow.module.background.append.js"]},
#2018-05-1811:42thhellerthat stuff is generated. only stuff in manifest.edn matters. manifest.json is generated.#2018-05-1811:42wilkerlucioyeah, but I'm wondering if when I add a new file, the generated list of scripts will have to change#2018-05-1811:42thhelleryes it does#2018-05-1811:42wilkerluciobecause I think when you change that, you also have to go into the extensions pages and refresh the extension manually#2018-05-1811:42thhellerbut you have to reload the extension for any code change anyways#2018-05-1811:43wilkerluciothe manifest is not auto-updated afaik#2018-05-1811:43thhellercode isn't either#2018-05-1811:43thhellerif you want that you MUST load remotely#2018-05-1811:44thhellerbut that has several other drawbacks so I opted not to do that by default. but it could be configured to work that way#2018-05-1811:44wilkerlucionot quite, I just tested on the background page here#2018-05-1811:45wilkerluciothe current setup does update#2018-05-1811:45wilkerluciothe content-scripts are the exception I think#2018-05-1811:45thhellerwhich "current setup"?#2018-05-1811:45wilkerluciothe old one#2018-05-1811:45thhellerwhich old one 🙂#2018-05-1811:45thheller:browser?#2018-05-1811:45wilkerlucio
:chrome-background     {:target     :browser
                                        :output-dir "shells/chrome/js/background"
                                        :asset-path "js/background"
                                        :devtools   {:devtools-url ""}
                                        :modules    {:main {:entries [fulcro.inspect.chrome.background.main]}}}
#2018-05-1811:45wilkerlucioyeah#2018-05-1811:45thhelleryeah browser loads remotely#2018-05-1811:46wilkerlucioright now I only refresh the extension when I have to change the content-script, if we go that direction I'm afraid we will have to do more ext refreshes#2018-05-1811:47thhellerI'm a bit confused, what exactly are you talking about?#2018-05-1811:47thhellerWHICH reload in particular?#2018-05-1811:48thhellerthe config above is not for a content script#2018-05-1811:48wilkerluciook, let me see if I'm also on the same page as you#2018-05-1811:48wilkerlucioI'm talking about the new changes you proposed for the compilation#2018-05-1811:48wilkerlucioin your example, the background page will change from the current browser :target#2018-05-1811:49wilkerlucioand instead will pre-compile and use the files from the manifest directly#2018-05-1811:49wilkerluciois that correct?#2018-05-1811:49thheller> background page will change from the current browser idea#2018-05-1811:49thhellerI don't understand that sentence#2018-05-1811:49wilkerluciobrowser target I mean, the way we compile the background#2018-05-1811:50thhellerthe entire chrome extension is compiled in one build yes. :browser is no longer used.#2018-05-1811:50thhellerbut that pretty much means nothing in itself#2018-05-1811:50wilkerluciothat I think its a downgrade in the experience for development#2018-05-1811:50wilkerluciobecause using :browser, I don't have to refresh the extension when I do updates on the background code#2018-05-1811:51thhelleryes you do#2018-05-1811:51wilkerluciono#2018-05-1811:51wilkerlucioI just checked#2018-05-1811:51thhellerhang on again . .. you are talking about LIVE reload here right?#2018-05-1811:51wilkerluciono#2018-05-1811:52wilkerlucioabout changing code, and refreshing the background page only (open devtools for it from the extensions pane, and use cmd+r in the inspector tool, it refreshes)#2018-05-1811:52thhellerhmm you can do that?#2018-05-1811:54thhellerhmm I just checked. that works fine?#2018-05-1811:54thhellerbut yes that could be a problem when new files are added#2018-05-1811:54wilkerlucioI took a tiny screen recording to show it#2018-05-1811:55thhellerbut it also doesn't trigger the OnInstalled callback#2018-05-1811:56wilkerluciotrue, but I think we don't to change that most of the time#2018-05-1811:56thhellersorry I don't get it. it is updating?#2018-05-1811:56wilkerlucioyes#2018-05-1811:56wilkerluciocheck the log#2018-05-1811:56wilkerlucioafter the refresh, the log comes with the new message#2018-05-1811:56wilkerlucio(sorry, I should frozen the last frame more, it transitions back to the gif start quickly)#2018-05-1811:56thhellersorry the gif is a bit fast. can't really tell what I'm looking for?#2018-05-1811:57wilkerlucioI update the bg code, shadow reloads it, you see a new message, then I go into the bg and refresh#2018-05-1811:57wilkerluciothe same file is loaded, now with the updated message on the log#2018-05-1811:57thhellerthat is also live-reloading so I'm still confused what you are actually talking about#2018-05-1811:58wilkerluciono, I thin you are missing the refresh on the devtools pane#2018-05-1811:58wilkerluciowhen the log is cleared and started over#2018-05-1811:58wilkerluciocheck when the elements pane got reset and re-rendered#2018-05-1811:58wilkerluciothat's a refresh#2018-05-1811:58thhelleryes I see that#2018-05-1811:59thhellerbut I do not understand where the problem is?#2018-05-1811:59wilkerluciothere is no problem here, this is the good version, using browesr#2018-05-1811:59wilkerlucioI'm afraid that will be lost with the new proposed changes#2018-05-1811:59thhellerWHAT will be lost?#2018-05-1811:59wilkerlucioand instead of a simple refresh on the devtools panel, I'll have to go in the extensions page and ask a refresh there#2018-05-1812:00thhellerit works identically AFAICT#2018-05-1812:00thhellerI have this#2018-05-1812:00thheller
(ns demo.chrome-bg)

(js/console.log "chrome-bg")
#2018-05-1812:00thheller:background {:entry demo.chrome-bg}#2018-05-1812:00thhellercompile it ONCE and see chrome-bg in the log#2018-05-1812:00thhellerI change the log message and compile it ONCE again#2018-05-1812:00thhellerCTRL+R to reload#2018-05-1812:01thhellerand I see the updated message?#2018-05-1812:01thhellerdid not do a full reload of the chrome ext#2018-05-1812:01wilkerluciocool, that's good, I was afraid that would break#2018-05-1812:02wilkerluciowhat about new files, had a chance to test that?#2018-05-1812:02thhellerwhy would it though?#2018-05-1812:02wilkerlucioI'm not sure about how chrome caches things there, considering the same scenario doesn't work this way with content-scripts (where I have to go into the ext pane and refresh there every time it changes)#2018-05-1812:04thhellerall problems can be fixed but please one problem at a time#2018-05-1812:04thhellercontent-scripts follow different rules#2018-05-1812:04thhellerand it is mostly about HOW the code is loaded and WHEN#2018-05-1812:05thhellerthe reason it seems to update when using :browser is that the code is loaded async and from remote#2018-05-1812:05thhellerso it is not actually loaded from the extension itself#2018-05-1812:05thhellerbut via http#2018-05-1812:06thhellerthere are several important aspects to this#2018-05-1812:06thhellernothing in this is specific to :browser. all of this could work identically in :chrome-extension#2018-05-1812:06thhellerthe point is to figure out what the actual problem is though#2018-05-1812:07thhellerasync has other issues in particular with :background since you can't use OnInstalled for example#2018-05-1812:08thhellerit is totally possible to use async for content scripts but sync for background#2018-05-1812:08wilkerluciohumm, I think I'm getting it now, OnInstalled can only run in the initial code, so async loading for it on :browser is broken, correct?#2018-05-1812:08thhellerjust trying to identify what you are actually after#2018-05-1812:09thhellerhalf-correct. the :browser loader is semi-smart and detects if it can document.write which means it appears sync#2018-05-1812:09wilkerluciomy idea was just trying to reduce the number of times we have to refresh the ext from the extensions page (or dont increase it, hehe)#2018-05-1812:10thhelleryeah but for that we need to when when you actually need to do that#2018-05-1812:11thhellerdo not think that you are giving up anything when not using :browser. that is not the intention here. keeping all the features but with easier configs is the goal. :browser is too complicated and does too many things we don't need#2018-05-1812:12wilkerluciogotcha, thanks for the clarification 🙂#2018-05-1812:13thhellerif you see a reproducible thing that doesn't work as expected let me know#2018-05-1812:13thhellerthis is far from done yet but I do think the direction is good#2018-05-1812:13thhellerso far I haven't come up with a reason not to this#2018-05-1812:13thhellermeaning putting everything into one build driven by the manifest.edn vs. having multiple separate builds#2018-05-1812:14thhellerhow the code is loaded is completely costumizable#2018-05-1812:15thhellerso the most important question currently would be to decide if there is a reason NOT to combine everything into one build. in which scenario would that NOT work.#2018-05-1812:16wilkerlucioI think currently the major pain point you described already, that's how to switch the REPL target#2018-05-1812:16thhellerI think :content-scripts can always load async remotely. they don't have any special lifecycle callbacks anyways right? eg. no OnInstalled#2018-05-1812:17wilkerluciohumm, there is a catch there#2018-05-1812:17wilkerluciofor example#2018-05-1812:17wilkerlucioI might want to inject things on page DOM via content-script before the user code is there, (like settings a flag so the user know an extension is installed)#2018-05-1812:17wilkerlucioif the code loads async, that will break I think#2018-05-1812:18thhelleryeah if you need document_start then that breaks#2018-05-1812:18wilkerlucioso, problem only for document_start#2018-05-1812:18thhellerbut since that is part of the config#2018-05-1812:18thhellerthe compiler could emit the correct thing#2018-05-1812:22thhellerstill need to figure out how to do the programmtic content script inject#2018-05-1812:22wilkerlucioone idea, what you think on using namespaced keywords for shadow things? like :shadow/entry?#2018-05-1812:22thhellerdeclarative is easier#2018-05-1812:22wilkerlucioso we can avoid collisions with regular manifest things#2018-05-1812:23thhellerprobably a good idea. easier to filter out later.#2018-05-1812:23thhellerbut currently its just :entry not sure what else we need#2018-05-1812:24thhellerthats easy enough to filter#2018-05-1812:24wilkerlucioyeah, just trying to be future proof#2018-05-1812:24wilkerluciowe never know if chrome might decide they want to use entry key for anything#2018-05-1812:25thhellertrue. its also more visible/obvious in the config.#2018-05-1815:04thheller@wilkerlucio (js/chrome.runtime.reload) actually does a full reload of the extension. could bind that to a key in cursive.#2018-05-1815:04wilkerluciointeresting#2018-05-1815:06thhellercould also do it :dev/before-load but it loses all state so not super great#2018-05-1817:13lilactownexcluding the closure compiler from clojurescript & adding in the version you specified fixed it :+1:#2018-05-1817:13lilactownthank you thheller!#2018-05-1820:41theeternalpulseSo is figwheel needed when using the shadow-cljs dev tools? It pretty much live-reloads and exposes the nrepl server, so is figwheel needed for some other cases?#2018-05-1820:41thhellerfigwheel is never needed no. its not supported in fact.#2018-05-1820:46theeternalpulseok cool. Also yesterday you gave me a startup app that instructed to use npx server and watch app seperately, but shadow-cljs watch app does both in one command. Other than having the ability to stop one or the other, is it advised to use the shadow-cljs command over npx?#2018-05-1820:49thhellernpx is only useful in case you do not have shadow-cljs installed globally. if you do you can skip npx.#2018-05-1820:49thhellerrunning the server instance separately however is recommended but not required#2018-05-1820:50thhellerit becomes more useful when you start using REPLs and multiple builds. just using watch is fine if you only have one build#2018-05-1820:51theeternalpulsegreat, loving it so far, still have yet to catch your interview on defn podcast#2018-05-1823:12thhellerbananadance#2018-05-1823:18wilkerluciocongrats man 🙂#2018-05-1823:20wilkerluciohow we can package libraries for things developed with Shadow? had anybody ever done that? how to share the npm dependencies? stil using lein for generating the jar?#2018-05-1823:22thhelleryeah I still haven't worked on that. pretty complicated topic. lein works fine so I recommend that.#2018-05-1823:22thhellernpm deps you can put into a deps.cljs at the root of you lib via {:npm-deps {"react" "some-version"}}#2018-05-1823:23thhellershadow-cljs will isntall those on server start of shadow-cljs npm-deps#2018-05-1823:24thhellerbut given the state of :npm-deps support in CLJS that might not work too well outside shadow-cljs#2018-05-1823:24thhellerno clue how it works together with cljsjs#2018-05-1823:27wilkerluciofor my case I'm ok been shadow only#2018-05-1823:28wilkerluciobut there is not much now, I think if we want to actually use the npm ecosystem, shadow is the only way until cljs core / closure figures on that side#2018-05-1823:30wilkerluciodo you know if there is a tool to read from package.json and spit on deps.edn?
#2018-05-1823:34thhellerdoubt that deps.edn is going to support npm anytime soon#2018-05-1823:35wilkerluciowell, so shadow is the way to go 🙂#2018-05-1823:35wilkerlucioone thing just occured to me about the manifest.edn, did you though about how to add extra compilations there? (besides content-script and background)#2018-05-1823:36wilkerlucioanother common cases are js for popup pages, devtools, apps...#2018-05-1823:36thhelleryes. just extra things in the config.#2018-05-1823:36wilkerlucioand those don't have a place in the regular manifest, they are loaded via html#2018-05-1823:37wilkerlucioyou already have an idea of what that will look like?#2018-05-1823:37thheller:page-action {:shadow/entry foo.bar :shadow/output-to "page_action.js"}#2018-05-1823:38thhellerso you could write the popup.html and just <script src="page_action.js">#2018-05-1823:38wilkerluciook, but that should be under some other key right? to avoid collision with regular manifest keys#2018-05-1823:39thhelleryeah. not yet sure what makes the most sense#2018-05-1823:40wilkerlucionamespaces are another option, but I feel like the nesting might be less confusing#2018-05-1823:40thhelleryeah I'm currently trying to address the multiple REPLs issue#2018-05-1823:40thhellerhaven't thought more about the compilation stuff#2018-05-1823:41thhellerif you have something that you'd like to see I'm open to adding it#2018-05-1823:41wilkerluciook, I'll stop breaking your focus 🙂 I'll try to think on those too and I'll let you know if get some idea#2018-05-1823:41thhellerhttps://github.com/nrepl/piggieback/issues/88#2018-05-1823:42thhellerthis is a pretty big issue that ideally should have tool support#2018-05-1823:42thhellerbut thats probably going to take a while 😉#2018-05-1823:58wilkerluciois that shadow retuning status code 130 on ctrl+c expected?#2018-05-1823:58thhellerit doesn't#2018-05-1823:59thhellerthat seems to be a npm v6 thing#2018-05-1823:59wilkerluciocli version: 2.3.23 node: v8.11.2#2018-05-1823:59wilkerlucioare you using the 10?#2018-05-1823:59thhellerwhich npm -v?#2018-05-1900:00wilkerluciojess, 6.0.1#2018-05-1900:00wilkerlucioI was sure it was 8 from shadow telling me 😛#2018-05-1900:00thhellerI'm on v9.4.0 and 5.6.0#2018-05-1900:00wilkerlucioI did installed the 8 yesterday, not sure why the one from node -v still 6#2018-05-1900:01thhellernpm versions differ from the node versions#2018-05-1900:01thhellerkinda unrelated since you can update npm independently#2018-05-1900:01wilkerlucioI mean node, installed node 8 yesterday#2018-05-1900:01thhellershadow-cljs only reports the node version#2018-05-1900:01wilkerlucioah#2018-05-1900:01thhellerdunno how to get the npm version (running npm -v seems like overkill)#2018-05-1900:02wilkerlucioso the latest npm is the problem#2018-05-1900:02thhellerbut yeah someone reported the 130 a few days ago. no idea where that comes from but it is not happening in v5#2018-05-1900:03thhellerI never explicitely set 130 anywhere#2018-05-1900:03wilkerlucioI only noticed because I wrapped the shadow calls in npm scripts#2018-05-1900:03wilkerluciothen it complains when I stop the compilation#2018-05-1900:03thhelleryep#2018-05-1900:03thhellernot a clue#2018-05-1900:03wilkerluciono big deal, just a minor annoyance#2018-05-1900:04thhelleryeah I'll probably have to look into it at some point#2018-05-1900:05thhellerif you feel like it open an issue. otherwise I just forget again 😉#2018-05-1900:05wilkerluciosure 🙂#2018-05-1900:06wilkerluciothe manifest.edn for content-script is working? I tried using it now, but seems like it's generating multiple files (failing on document_start)#2018-05-1900:07thhellerit always generates multiple files yes. does that not work with document_start? I tested on idle and that worked.#2018-05-1900:07wilkerluciono, I got those:#2018-05-1900:07wilkerlucio
main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.120 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.120 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.121 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.121 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.140 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.140 main.js:3016 GET  0 ()
(anonymous) @ main.js:3016
env.load @ main.js:3009
(anonymous) @ main.js:3054
20:57:00.141 
#2018-05-1900:08thhelleruhm it should not GET anything? maybe outdated?#2018-05-1900:08wilkerlucioI didn't tried using idle, let me try that just to check if the document_start is really the problem#2018-05-1900:10thhellermight just need to reload the extension?#2018-05-1900:10wilkerlucioI tried, but its even loading now#2018-05-1900:10wilkerluciois this correct?#2018-05-1900:10wilkerlucio
:content_scripts         [{:matches ["<all_urls>"]
                            :entry   fulcro.inspect.chrome.content-script.main
                            :run_at  "document_idle"}]
#2018-05-1900:10thhellerah no#2018-05-1900:10thheller:content-scripts#2018-05-1900:10thhellerI can't stand looking at _ in keywords 😛#2018-05-1900:11thhellershould probably support both but currently it only supports -#2018-05-1900:11wilkerluciook, that's easy at least 😛#2018-05-1900:11wilkerlucioI'm on the - team too#2018-05-1900:11thhellerall - will be converted to _ before writing the JSON#2018-05-1900:12thhellerso both work already but it currrently only checks :content-scripts not :content_scripts#2018-05-1900:13wilkerlucionow hte compilation seems fine, but it's failing to connect the repl#2018-05-1900:14wilkerluciois there any other configuration that needs to change?#2018-05-1900:14thhellerfailing how?#2018-05-1900:14wilkerlucio
browser.cljs:310 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
#2018-05-1900:14thhelleris the IP correct?#2018-05-1900:15wilkerlucioyes, but I guess it used to work via localhost#2018-05-1900:15wilkerlucioI remember it not working by ip#2018-05-1900:15thhellerthe usual :devtools {:devtools-url ""} might work?#2018-05-1900:16thhellerwhich IP did shadow-cljs display on server startup?#2018-05-1900:16thhellerit might be picking an incorrect IP#2018-05-1900:16wilkerlucioit shows that IP, and it seems correct here: https://www.dropbox.com/s/dlt369wf080csvm/Screenshot%202018-05-18%2021.16.52.png?dl=0#2018-05-1900:17thhellerthats a different IP? but the public address is your internet address. thats likely incorrect.#2018-05-1900:17wilkerluciobut for some reason seems not connecting, I'm using the company macbook, it might have firewall or something setup (I did the setup long ago, don't remember)#2018-05-1900:18wilkerluciothe public ip is for the building here#2018-05-1900:18wilkerlucioit's using my local ip#2018-05-1900:18thhellerah didn't see the other one#2018-05-1900:18thhellercan you go to ?#2018-05-1900:18wilkerluciono#2018-05-1900:19wilkerlucio192.168.0.121 refused to connect.#2018-05-1900:19thhellerbut localhost:9630 works?#2018-05-1900:19wilkerlucio:+1:#2018-05-1900:19thhellerstrange#2018-05-1900:20thhellerits supposed to bind to 0.0.0.0 so the IP should work#2018-05-1900:20thhellerdo you have multiple IPs?#2018-05-1900:20wilkerlucionot that I know#2018-05-1900:20wilkerlucio0.0.0.0 works too#2018-05-1900:21thhellerstrange#2018-05-1900:22wilkerlucio#2018-05-1900:22wilkerluciothat was just wrong, no sense 😛#2018-05-1900:23thhellerdid your IP maybe change since the server was started?#2018-05-1900:23thhellerwlan up/down that sort of stuff?#2018-05-1900:23wilkerlucioI did disconnected from a VPN during the middle, I'm restarting to try again#2018-05-1900:23wilkerluciorestarted server, same thing#2018-05-1900:24thhelleroh VPN. maybe it picked your VPN adapter#2018-05-1900:24thhellerforgot what the command was for osx. ifconfig maybe?#2018-05-1900:24thhellercheck which adapters you have#2018-05-1900:25wilkerlucio
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether a4:5e:60:d9:ad:3b
	inet 192.168.0.121 netmask 0xffffff00 broadcast 192.168.0.255
	media: autoselect
	status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
	ether 06:5e:60:d9:ad:3b
	media: autoselect
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
	ether 1a:77:42:f7:ca:78
	inet6 fe80::1877:42ff:fef7:ca78%awdl0 prefixlen 64 scopeid 0x8
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=60<TSO4,TSO6>
	ether 6a:00:00:34:ba:00
	media: autoselect <full-duplex>
	status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=60<TSO4,TSO6>
	ether 6a:00:00:34:ba:01
	media: autoselect <full-duplex>
	status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 6a:00:00:34:ba:00
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x2
	member: en1 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 9 priority 0 path cost 0
	member: en2 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 10 priority 0 path cost 0
	media: <unknown type>
	status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::8ea2:2eee:6e4c:561e%utun0 prefixlen 64 scopeid 0xe
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::d746:7a38:7b:f32%utun1 prefixlen 64 scopeid 0xf
	nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::bdc0:d124:6bee:608b%utun2 prefixlen 64 scopeid 0x10
	nd6 options=201<PERFORMNUD,DAD>
EHC64: flags=0<> mtu 0
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
	ether 40:6c:8f:55:95:d7
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (none)
	status: inactive
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
	lladdr 00:0a:27:02:00:49:ca:5f
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect <full-duplex>
	status: inactive
#2018-05-1900:25thhellerhmm ok so it does pick the correct one#2018-05-1900:26thhellerno idea why it doesn't work thought. I can connect to which is my machine#2018-05-1900:26thhellerI should just remove all the "smart" logic I added since working on the react-native stuff#2018-05-1900:26thhellerand just default to localhost again. that had less issues 😛#2018-05-1900:28wilkerluciohehe, what motivated you to work on figuring the correct ip address?#2018-05-1900:28thhellerreact-native required it#2018-05-1900:29thhelleror rather expo. since I was using my actual phone to test stuff and not an emulator. so localhost didn't work#2018-05-1900:29wilkerluciooh true, would be nice to keep that for RN stuff#2018-05-1900:29wilkerlucioand now that you said so, I did RN with shadow, and it worked then#2018-05-1900:29wilkerlucioI'll try restarting here#2018-05-1900:30wilkerluciomaybe it screws up after a VPN connection#2018-05-1900:31thhellerbrowsers can just use document.location so its easier there but that breaks for chrome exts#2018-05-1900:33wilkerluciono, still not work#2018-05-1900:33thhellerdoh#2018-05-1900:33wilkerlucioI clicked on the shadow link thinking it was the ip (that was above :P)#2018-05-1900:34thhelleropen an issue please. too tired to figure out what to do 😛#2018-05-1900:35thheller:devtools-url should fix it#2018-05-1900:35thhellerbut I'd prefer the default to work properly#2018-05-1900:39wilkerluciook#2018-05-1900:41wilkerlucioissues ready#2018-05-1900:42wilkerlucioand :devtools-url works fine#2018-05-1900:43thhellerI'm off to bed, gn8#2018-05-1900:44wilkerluciogood night, thanks again, and just to wrap up, document_start works fine#2018-05-1917:05gnlCan the :before-load hook prevent reloading by returning false or something like that?#2018-05-1917:15gnl...or rather - could it?#2018-05-1918:52borkdudeI’m trying to use Reagent in a node project to render some HTML statically. This is my config:
{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:app {:target :node-script
                :output-to "target/main.js"
                :main server.main/main!
                :devtools {:after-load server.main/reload!}}}}
This is my require:
(ns server.main
  (:require [reagent.dom.server :refer [render-to-static-markup
                                        render-to-string]]))
#2018-05-1918:52borkdudeThe error I get:
The required namespace "react" is not available, it was required by "reagent/impl/template.cljs".
although I see react listed in the dependencies of Reagent?
#2018-05-1919:49borkdudeI’ve solved it by adding react and react-dom via npm#2018-05-1920:00borkdudeHow do I get shadow-cljs to output a single .js file that I can use without additional libraries?#2018-05-1920:01borkdudee.g. now I get
$ /tmp/html.js
internal/modules/cjs/loader.js:573
    throw err;
    ^

Error: Cannot find module 'react-dom/server'
while it works in the project directory
#2018-05-1920:16thheller@borkdude node packages are not bundled. since that is not usually how its down for node. typically you'd compile to some directory and put a package.json there with the dependencies you need#2018-05-1920:16thhelleryou then npm install it and run it#2018-05-1920:18thheller@clojurians.net no there is currently no "recommended" way to abort a reload. why would you want to?#2018-05-1922:16kennyI kept getting this printed to the console when trying to run my tests:
shadow-cljs - config: /Users/kenny/compute_software/clake/cli/shadow-cljs.edn version: 2.3.21
shadow-cljs - starting via "clojure"
[2018-05-19 15:10:33 - WARNING] failed to inspect resource "/Users/kenny/compute_software/clake/cli/test/clake_cli/core_test.cljs", it will not be available.
[:test] Compiling ...
========= Running Tests =======================

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (26 files, 0 compiled, 0 warnings, 1.98s)
... and could not figure out what was wrong. I had a pretty vanilla test file:
(ns clake-cli.core-test
  (:require [cljs.test :refer :all]))

(deftest my-test
  (is (= 1 1)))
Turns out I forgot :refer :all isn't support in CLJS which caused that issue. I suggest make the error message more clear for this case (especially because that is the default file Cursive generates for CLJS tests).
#2018-05-2006:16emccueI was just messing about with https://github.com/halfzebra/create-elm-app#2018-05-2006:16emccueI wonder if there is value in making something like this for shadow and clojure#2018-05-2007:46theeternalpulseI defined a macro in a clj file and am using :require-macros to use it in a cljs file but I'm getting a build failure
22 |      ^{:key letter} [letter-button letter])
  23 |    "Now in the drum-kit-lesson"])
  24 | 
  25 | (create-lesson letters)
-------^------------------------------------------------------------------------
ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Named
	clojure.core/namespace (core.clj:1589)
	clojure.core/namespace (core.clj:1589)
	cljs.analyzer/fn--1733 (analyzer.cljc:1491)
	cljs.analyzer/fn--1733 (analyzer.cljc:1473)
	clojure.lang.MultiFn.invoke (MultiFn.java:251)
	cljs.analyzer/analyze-seq* (analyzer.cljc:3348)
	cljs.analyzer/analyze-seq* (analyzer.cljc:3346)
	cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3353)

--------------------------------------------------------------------------------
#2018-05-2008:32thheller@theeternalpulse looks like a macro error, probably generating invalid code#2018-05-2015:17theeternalpulsethis is my macro. I've reduced it down quit a bit to test and was still getting the error
(defmacro create-lesson [component]
  `(def 'lesson (if style
                  (with-meta `'~component {:style style})
                  `'~component)))
#2018-05-2015:18theeternalpulseI'm basically trying to create a def in a namespace that attaches style metadata so when the component is mounted with reagent it also mounts a style tag to the header#2018-05-2018:45thhelleryeah that macro is invalid. can't even figure out what it is supposed to do?#2018-05-2018:45thhellerbut it does not like the 'lesson. that is the error you are seeing.#2018-05-2019:03theeternalpulseI see. I wanted to create a local def called lesson where the macro is used, and not have it try to resolve a namspace.#2018-05-2019:10thheller(def ~'lesson ...) should do that#2018-05-2019:11thhellerbut you should read about macro hygiene. this is generally not a good idea.#2018-05-2019:25theeternalpulseI am really jsut trying to attach metadata to a clojurescript function but I was reading and in order to fetch it I have to get a reference to thee var, which I can't do in clojurescript#2018-05-2019:25theeternalpulseso I just wanted to create a simple thing that would do (def lesson (with-meta fn {:style style})) if the style var was defined#2018-05-2019:26theeternalpulseI guess it's overkill but it piqued my curiosity and led me down that dark path#2018-05-2019:27thhellerI always recommend writing the code entirely without macro (if possible) until it works and then eliminate the boilerplate later#2018-05-2019:27thhellerstarting with a macro first is always challenging#2018-05-2019:27thhellervars are totally possible though. dynamic vars are not.#2018-05-2019:27theeternalpulseyeah, it's a bit harder to debug in clojurescript#2018-05-2019:28theeternalpulseeven with cider connected, doesn't seem to like macros#2018-05-2019:28thhellerits tricky since macros are written in clojure#2018-05-2019:35theeternalpulseyeah, Either way, that cleared it up. I'll go down the easier path, too much of a rabbit hole to be worth it lol#2018-05-2008:33thheller@kenny please open an issue so I don't forgot. the error should be more clear indeed.#2018-05-2021:27wilkerlucio@thheller noticed something weird here, I just add my test folder to my source-paths, and for some reason, now on my chrome compilations I'm getting start code from fulcro-spec, which doesn't make sense, on my chrome entry points there is nothing pointing to fulcro-spec, and this start code from spec is messing up other things, just removing the test from :source-paths and recompiling fixes it, any idea what that might be?#2018-05-2021:30thhellerwhat is "start code from fulcro-spec"?#2018-05-2021:31thhellerpreloads maybe?#2018-05-2021:33wilkerluciothere is none there#2018-05-2021:34wilkerluciothat's what I'm finding confusing, I have no reference to fulcro-spec on this build#2018-05-2021:35thhellerfrom the clj REPL you can run (shadow.cljs.devtools.api/find-resources-using-ns 'fulcro.spec) or whatever the ns is#2018-05-2021:35thhellerno idea why added test code would become part of you build though. maybe a naming conflict?#2018-05-2021:37wilkerlucioother thing, about the nrepl-port, here everytime I run shadow it uses a new port#2018-05-2021:37wilkerlucioI though I read something about it creating a file and sticking to that number, do I have to configure anything for that to happen?#2018-05-2021:38thhellerthe port is always random and always written to .shadow/nrepl.port by default. you can however configure a fixed port#2018-05-2021:38thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2018-05-2021:38wilkerluciodo you have a way for cursive to pick the port number from that?#2018-05-2021:39thhellerno I use a fixed port due to cursive#2018-05-2021:43wilkerlucioI ran the command you said#2018-05-2021:43wilkerlucioall the references I'm finding are from my test file sources#2018-05-2021:44wilkerluciois there other way I can try to figure why the spec stuff is leaking into other build?#2018-05-2021:46wilkerlucioI may have found it#2018-05-2021:46thhellerthere should be ... but currently there is no easy way#2018-05-2021:46wilkerluciothere was a cljs.user in the test directory#2018-05-2021:46wilkerlucioyeah, that was it#2018-05-2021:47thhellerah, right.#2018-05-2021:48wilkerluciothe experience with chrome + shadow is been awesome, even still incomplete, I'm close to have a beta for fulcro-inspect running as a chrome devtool 🙂#2018-05-2021:49thhellernice. I'll probably work on it a bit more tomorrow.#2018-05-2111:51wilkerlucio@thheller I tried to make a chrome release, but I see it says not implemented, any chance you can prioritize that? :)#2018-05-2112:10thhelleryeah I'll fix that first. I'll be back in a couple hours and take a look at it then#2018-05-2112:10thhellerit should already be compiling and outputting the correct files. only the part updating the manifest is missing#2018-05-2115:23thheller@denik no one reported this so far and I haven't seen anything like that myself. not sure what could cause this. log looks fine.#2018-05-2116:50ggaillardScratching my head around an issue with shadow.loader where the moduleInfo is undefined, and thus 'isLoaded' is undefined. I have modules defined as in {:module-loader true, :modules {:main {:entries []}, :login {:entries [app.login] :depends-on #{:main}}}}. It compiles fine. I get a module-loader.edn and module-loader.json in my :output-dir, containing {:module-uris {:login ["files paths", …]} :module-infos {:login #{}}} In the console:
shadow.loader.load("login");  // => Error: Unknown module: login
shadow.loader.set_loaded("login") // => Cannot read property 'onLoad' of undefined
shadow.loader.mm.getModuleInfo("login") // => undefined
I have been through the doc multiple times but now I'm feeling stuck. Did I miss something ?
#2018-05-2116:59thheller@ggaillard check the last line of you main.js. it should contain a call to shadow.loader.setup#2018-05-2117:10ggaillardMy main.js ends with SHADOW_ENV.load(["path", …]) and no call to loader.setup in the file unfortunately. Neither in login.js 😕#2018-05-2117:13ggaillardmain.js is the first file to load, no code is referencing shadow.loader before it finish loading#2018-05-2117:13thhellerah you are still in dev mode. that its in the last file mention in the load call#2018-05-2117:13thhellershadow.modules.main.append or so#2018-05-2117:16ggaillardIndeed ! I got 2 lines in there:
shadow.cljs.devtools.client.browser.module_loaded('main');

shadow.loader.enable();
#2018-05-2117:20thhellerhmm thats supposed to have a setup call?#2018-05-2117:23thhellerhmm try adding cljs.core to the entries of main. there might be a bug with empty :entries#2018-05-2117:23thhellersince it can move everything into login then#2018-05-2117:24ggaillardI don't know ... if I recall correctly, lein-cljsbuild is outputing modules infos to the build by defining a goog constant. How is the goog ModuleLoader parametrized in shadow ? I'll try adding cljs.core 🙂#2018-05-2117:29thhellerit is parameterized by injecting the setup call#2018-05-2117:31ggaillardOk got it, I'm looking at the source code. I'll try to find out what's going on#2018-05-2117:34thhellerit seems like the isLoaded call was renamed to isActive. so that explains why that fails#2018-05-2117:36ggaillardA change in the closure compiler api ?#2018-05-2117:36thhellerclosure library#2018-05-2117:37thhellerbut I just tested in my build and it works fine#2018-05-2117:40thhellerah no isLoaded is still around. you are just missing the setup call for some reason.#2018-05-2116:59thhellerif you are trying to use the loader before that call that might be why#2018-05-2117:59alvinahello is there any way connect repl using cider#2018-05-2117:59alvina?#2018-05-2118:00thhellerthe latest version of cider should have support for that#2018-05-2118:01thhelleror configure a fixed nrepl port https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL and user cider-connect#2018-05-2118:06alvinamy cider version is 0.18.0spanshot#2018-05-2118:07alvinawhen is try to "cider-connect" localhost:PORT#2018-05-2118:07alvinait says#2018-05-2118:08alvinaSync nREPL request timeouot#2018-05-2118:08alvina(op clone id 1 timestap ...)#2018-05-2118:09alvinasorry used wrong port#2018-05-2118:10alvinatrying again ..#2018-05-2118:17thheller@wilkerlucio master has support for release. I changed :entry to :shadow/entry as you suggested so you need to update those.#2018-05-2118:17thhelleralso added support for multiple different content-scripts should that ever become necessary. no config change for that.#2018-05-2118:18alvinano luck with cider#2018-05-2118:19thhellerbest ask in #cider. I personally do not use emacs and can't really comment on whats going on over there. maybe something new they added recently.#2018-05-2118:19thheller0.17.0 worked AFAIK#2018-05-2118:19alvinasure#2018-05-2118:20alvinawhich editor you use#2018-05-2118:20alvina?#2018-05-2118:20thhellerCursive#2018-05-2118:24thheller@wilkerlucio master had a bug. update again if you already did.#2018-05-2118:27wilkerlucio@thheller thanks for the heads up, I'm at the office now, so I'll be checking it later today#2018-05-2122:36wilkerlucio@thheller I just tried the compilation, it seems to work mostly, something weird is around some special UTF-8 chars, I use for example the chars and for tree views, but on adv compilation they are rendering as â–¼ and â–¶, you know what that can be about?#2018-05-2122:39wilkerluciops: that is not the chrome build, it's on the devtool build, which is a :browser target#2018-05-2122:55wilkerlucionah, seems something about the chrome devtool, weird it works on normal compilations though#2018-05-2207:14thheller@wilkerlucio typically I'd say this is due to the charset of the page. <meta charset="UTF-8"> typically fixes it for the browser. not sure about chrome extension though.#2018-05-2209:47thheller@wilkerlucio there seems to a be a long history related to this. in short CLJS will emit console.log("\u25B6\u2764\u25C0"); which works fine without setting a charset. Closure will optimize and turn that into console.log("▶❤◀"); however which then fails to load properly without a specified charset. see https://dev.clojure.org/jira/browse/CLJS-1547?focusedCommentId=42617#2018-05-2209:49thhellerapparently the default charset is the problem here. if you set :compiler-options {:closure-output-charset "US-ASCII"} it will keep the same escaped sequence that CLJS emits and the problem goes away#2018-05-2209:49thhellerwonder if you can set the default charset for chrome, seems weird that it doesn't load UTF-8 properly by default#2018-05-2210:02thhelleroh right. chrome does the right thing for the extension. the browser seems to require a charset though#2018-05-2217:32mhueberthmm. i’m playing around with a bootstrapped build, wondering about how one might get a watch build to send updates to the browser. Seems a two-part problem; first, figuring out how to get (require 'the-ns :reload) to work (currently I have to dissoc a namespace from :cljs.analyzer/namespaces before it will do anything), maybe modifying shadow.cljs.bootstrap.browser/load-namespaces to accept a :reload parameter, and second - any idea how a client could be notified when namespaces in a bootstrapped build are modified? i would guess one just wants a callback to be fired, maybe w/ a list of changed namespaces, as there is no way for shadow to know anything about what’s going on with compiler states in the browser#2018-05-2217:39wilkerlucio@thheller thanks! I'll try that out#2018-05-2217:41thheller@mhuebert you are talking about the bootstrap support build notifying the host build correct?#2018-05-2217:42mhuebert@thheller yes#2018-05-2217:43thhellernot sure how to do that given the complexity of self-host itself#2018-05-2217:43thhellersending a websocket message to the host build is easy enough#2018-05-2217:44thhellerbut getting it to the right place might be tough#2018-05-2217:44mhuebertI would think the host build would need to do the work of putting it in the right place#2018-05-2217:44thhelleryeah but currently there is no way for you to "hook" into anything the devtools client is doing#2018-05-2217:45thhellerits complex enough as it is so I don't want to introduce another layer that might cause problems#2018-05-2217:45thhellerhow does the self-host part deal with :reload?#2018-05-2217:46thhellerit should be able to just load other content right?#2018-05-2217:47mhuebertyes. the only nit there is the first problem i mentioned above - i am not sure exactly where to fix it - that i have to dissoc the ns from the compiler-state before load-namespaces will reload it#2018-05-2217:48mhuebertbut when i do that, it all works#2018-05-2217:48mhuebertthe only thing i am missing is some way of knowing that a ns has changed#2018-05-2217:48thhellerit would probably be best if you implemented your own shadow.cljs.bootstrap.browser. I implemented that as a proof of concept but what you are asking goes way beyond what I planned for it#2018-05-2217:48mhuebertk#2018-05-2217:51mhuebertI don’t think that part will be so hard on my side.#2018-05-2217:52mhueberti am already running the watch build from a script via clj-run, maybe there is a way i can make a little hack to listen in for when shadow has recompiled things in my bootstrap build?#2018-05-2217:53mhuebertgotta get dinner, bbl#2018-05-2217:58thhellerI do have plans for a generic API endpoint I want to build the UI on-top of. this would expose such data but thats pretty much in planning stages#2018-05-2217:58thhellerdid a few tests for graph queries using pathom but thats about it#2018-05-2217:58thhellersince you'd probably need a websocket for subscription-ish things that is even further from existing#2018-05-2217:59thhellerI guess you could build you own http server that you then connect a websocket to and notify whenever a compile finishes#2018-05-2220:31grav
$ shadow-cljs compile em-admin
shadow-cljs - config: /Users/grav/repo/eddie-michel/em-poc/shadow-cljs.edn  cli version: 2.3.23  node: v8.6.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm compile em-admin
Exception in thread "main" java.lang.RuntimeException: No such var: module-graph/validate-inputs, compiling:(shadow/build/cljs_closure.clj:931:3)
	at clojure.lang.Compiler.analyze(Compiler.java:6792)
What to do?
#2018-05-2220:31gravI’m using :lein true in my shadow-cljs.edn, and I’ve added [thheller/shadow-cljs "2.3.23"] to the deps in my project.clj#2018-05-2220:40gravah, needed to upgrade clojurescript dep to newest 1.10.238.#2018-05-2221:24gravHmm … cannot seem to get namespaces with dash (`-`) to work. For instance, a namespace, my-package.namespace I would assume maps to my_package.namespace, but that ends up being undefined. Works if I remove the dash from the namespace and use e.g. mypackage.namespace#2018-05-2222:30mhuebert@thheller so to know what to send the client, I could do something like this -
(def proc (watch))

 (def output-chan
   (let [c (chan)]
     (tap (:output-mult proc) c)
     c))

 (defn bootstrap-compiled-sources [{:keys [type build-config info]}]
   (when (and (= :build-complete type)
              (= :bootstrap (:target build-config)))
     (:compiled info)))

 (def bootstrap-loop
   (go-loop []
     (let [evt (<! output-chan)]
       (some-> (bootstrap-compiled-sources evt)
               (println))
       (recur))))
#2018-05-2306:30thheller@grav my-package.namespace maps to my_package.namespace but must also be in a my_package/namespace.cljs. otherwise - is totally fine.#2018-05-2306:38thheller@mhuebert yeah that should work. you might want to use (tap (:output-multi proc) c true) so the c closes when the worker stops#2018-05-2306:38thhellerah nvm thats the default anyways#2018-05-2310:32troglotitHey! Is there anything like webpack-bundle-analyzer for shadow-cljs?#2018-05-2310:34thhellerhttps://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/11?u=thheller#2018-05-2310:34thhellerand https://github.com/stevebuik/Stu#2018-05-2310:34thhellerstill in pretty rough shape overall#2018-05-2312:07troglotitI’m having issue when using default exports, they’re undefined I import them like this: [“moment” :default moment] [“react-datepicker” :default DatePicker]#2018-05-2312:11thheller@troglotit default exports depend on how the package is packaged. if its commonjs it might just has a single export in which case it would be :as DatePicker or :as moment. you can try using :as x always and (js/console.log x) to see which properties it has. :default only works if there is a default property.#2018-05-2312:18troglotityeah, it was commonjs. It had "module": "es" - so I thought it should provide es modules 😅#2018-05-2312:19thhellerI still need to add support for those. unfortunately not all pacakges are available as ES and interop between some was weird#2018-05-2312:19thhellercurrent way seemed to be the best compatibility wise#2018-05-2314:53mhuebert@thheller is push-state still the default for the shadow dev server? I seem to recall this was at one time, not sure if that has changed or if the docs should be updated#2018-05-2316:13thheller@mhuebert yes its the default#2018-05-2316:51lwhortonis there a built-in for running a particular namespace, but not all namespaces, through a test? or would that require creating a custom :runner-ns#2018-05-2317:13lwhortoncurrently im using a custom runner-ns that is a clone of the provided https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/browser.cljs with a hard-coded regex 😛#2018-05-2317:28thheller@U0W0JDY4C :ns-regexp "my.only.namespace-test"#2018-05-2317:29thhellerthe runner should eventually get some kind of UI but thats not done yet#2018-05-2317:43lwhortonwould that require restarting the test process each time the config file changed?#2018-05-2317:54thhellerno, config changes automatically trigger a recompile#2018-05-2318:01lwhortonah that I did not know, 👍#2018-05-2316:53lilactownis there any docs/explanation of what :dev {:compiler-options {:devcards true}} does?#2018-05-2317:16mhuebert@lilactown that is a flag to enable https://github.com/bhauman/devcards (if you have included it)#2018-05-2317:16mhuebert(it is not specifically related to shadow-cljs)#2018-05-2317:19lilactownI know, I want to know what it actually does to the build 🙂#2018-05-2317:30thheller@lilactown it enables this https://github.com/bhauman/devcards/blob/master/src/devcards/util/utils.clj#L4-L6#2018-05-2317:30thhellerwhich some of the macros use to decide if they should emit something or not#2018-05-2317:46lilactownthanks!#2018-05-2408:42thheller@wilkerlucio style question. which would you prefer?
{:something 1
 :chrome/options {:matches [""]
                  :run-at "document_idle"}}


{:chrome/matches [""]
 :chrome/run-at "document_idle"
 :something 1}
#2018-05-2408:45thhelleror I guess I could as anyone. I'm sort of undecided on which style to use. lots of nested maps or namespaced keys. Other potential candidates :compiler-options, :js-options etc.#2018-05-2411:18mitchelkuijpersI am always for namespaced keys make stuff way easier and then you can spec it#2018-05-2411:59thhellerI prefer it for maybe one or two keys with the same ns. after that I prefer a nested map.#2018-05-2411:21timovanderkampah I just found an issue related to this https://github.com/thheller/shadow-cljs/issues/273#2018-05-2411:58thheller@timovanderkamp do you use emacs+cider as well or standalone?#2018-05-2412:00timovanderkampYes I do#2018-05-2413:13fatihictI run into this issue as well with shadow 2.3.23, without emacs but with cider/cider-nrepl#2018-05-2413:59hlolliI'm hitting this error browser.cljs:39 Uncaught TypeError: Cannot read property 'written' of undefined useing
shadow-cljs.edn  cli version: 2.3.23  node: v9.6.1
tried deleteing target, this is a website I did few months back, and I updated shadow-cljs, and now can't see my changes stacktrace
browser.cljs:39 Uncaught TypeError: Cannot read property 'written' of undefined
    at Object.shadow$cljs$devtools$client$browser$goog_is_loaded_QMARK_ [as goog_is_loaded_QMARK_] (browser.cljs:39)
    at shadow$cljs$devtools$client$browser$src_is_loaded_QMARK_ (browser.cljs:48)
    at Function.G__35120__1 [as cljs$core$IFn$_invoke$arity$1] (core.cljs:4222)
    at cljs.core.filter.cljs$core$IFn$_invoke$arity$2 (core.cljs:5124)
    at cljs.core.LazySeq.sval (core.cljs:3394)
    at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (core.cljs:3452)
    at Object.cljs$core$seq [as seq] (core.cljs:1210)
    at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2445)
    at cljs.core.LazySeq.cljs$core$IReduce$_reduce$arity$3 (core.cljs:3458)
    at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2517)
#2018-05-2414:08hlolliforget that 😛 haha, just needed to clear cache
#2018-05-2414:10thhellerwhich cache?#2018-05-2414:11hlollibrowser cache#2018-05-2414:11hlollichrome's "Empty Cache and Hard reload"#2018-05-2414:12thhellerhmm ok, seems odd that you only partially get the newer version though.#2018-05-2414:28wilkerlucio@thheller I tend to prefer flat maps over nested ones, I found they usually simpler to deal with (only have to know one key instead of a path), so I like the one with namespaces better#2018-05-2415:13dominicmI'm trying to get om/brutha working with React. With both /cdn-cgi/l/email-protection and /cdn-cgi/l/email-protection, I'm getting TypeError: React.DOM.p is undefined. I'm using shadow-cljsjs.#2018-05-2415:13dominicmis this a known issue?#2018-05-2415:18jjttjjI'm trying to get play-cljs (https://github.com/oakes/play-cljs) working with shadow-cljs. It seems it bundles its own JavaScript source in their code (rather than using an external dependency) for the library p5.js, and then require it with:
(:require [goog.events :as events]
            [p5.core]
            [p5.tiled-map]
            ...
When I try to compile this with shadow-cljs I get
The required namespace "p5.core" is not available, it was required by "play_cljs/core.cljs".
Is there a way to make this work? (edit: I have already installed p5 in my project with npm)
#2018-05-2415:25dominicmFixed mine, apparently the latest version in the om readme is not the latest#2018-05-2415:38jjttjjI think my issue is that play-cljs uses foreign libs which is unsupported by shadow#2018-05-2415:39thheller@dominicm was it fixed in om? the React.DOM stuff has been deprecated for a while.#2018-05-2415:39dominicm@thheller yep#2018-05-2415:41thheller@jjttjj someone successfully used play-cljs with shadow-cljs but I forgot how exactly. typically you'll just need to install p5 via npm and create a shim file ala https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-05-2415:42thheller@escherize can you share your p5/play-cljs setup?#2018-05-2419:04kurt-o-sysRather fundamental question of how to use npm-libs with shadow-cljs. I can import them properly, but I fail to get this to work: https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/getting-started.html#your-first-table More specifically, how translate this line to cljs:
export default () =>
  <BootstrapTable keyField='id' data={ products } columns={ columns } />
#2018-05-2419:05kurt-o-sysI can't seem to use [:> BootstrapTable {:data (clj->js content) :keyField "id"}]] or [BootstrapTable {:data (clj->js content) :keyField "id"}]]#2018-05-2419:06kurt-o-sysreason: Cannot call a class as a function#2018-05-2419:08kurt-o-sysI've got this require: ["react-bootstrap-table-next" :default BootstrapTable]#2018-05-2419:26kurt-o-syshmmm... missing something. not sure what yet.#2018-05-2419:26kurt-o-sysd'you mind sharing the cljs code? (how d'you use BootstrapTable?#2018-05-2419:27justinleethat code snippet is basically complete. the only thing missing is
(defn start []
  (js/console.log "Starting...")
  (r/render [app]
            (.getElementById js/document "app")))

(defn ^:export init []
  (start))
#2018-05-2419:29kurt-o-sysnaa, that part is ok.#2018-05-2419:29kurt-o-sysI'm struggling with the table.#2018-05-2419:30justinleei mean you literally have a code complete example. i just cloned reagent-shadow-cljs-starter, did a yarn add, and bam it works#2018-05-2419:31justinleeby the way, i note that you didn’t supply the :columns key above#2018-05-2419:32kurt-o-sysnope, I didn't...#2018-05-2419:32kurt-o-syslet me try 😛#2018-05-2419:38thheller@kurt-o-sys which version are you using? there was a bug in the closure compiler that was fixed only recently. https://github.com/google/closure-compiler/issues/2822#2018-05-2419:40kurt-o-sysversion of? cljs?#2018-05-2419:41kurt-o-sys[thheller/shadow-cljs "2.3.21"] [org.clojure/clojurescript "1.10.238" :scope "provided"]#2018-05-2419:41thhelleroh lein?#2018-05-2419:41kurt-o-sys(well, shadow-cljs, but with :lein true)#2018-05-2419:41kurt-o-sysoh, wait.#2018-05-2419:42thhellercan you run lein deps :tree and see which com.google.javascript/closure-compiler-unshaded version you get?#2018-05-2419:42kurt-o-sys[com.google.javascript/closure-compiler-unshaded "v20180319"]#2018-05-2419:42kurt-o-sysbut I may be getting there.#2018-05-2419:43thhellertry adding [com.google.javascript/closure-compiler-unshaded "v20180506"]#2018-05-2419:43kurt-o-sysMay be related to the table being loaded twice (for some reason), first time with empty data.#2018-05-2419:43kurt-o-sysok, will check.#2018-05-2419:43thhellerit might not be related to the version issue but the error looks familiar#2018-05-2419:43kurt-o-sysok, thx...#2018-05-2419:45thhellernot sure why you are getting the old version though since the shadow-cljs version you have already depends on the newer on#2018-05-2419:45thhellerbut for some reason the "older" version of cljs gets picked up first#2018-05-2419:45kurt-o-sysupdated the shadow-cljs version to 2.3.23 now.#2018-05-2419:46kurt-o-syswhich gives me the new version of the closure-compiler.#2018-05-2419:48thhellerah ok. thought .21 already had the upgraded version but guess not#2018-05-2419:48kurt-o-sysyeah, upgrading seems to help! thx a lot!!#2018-05-2419:56nijkHi all!#2018-05-2419:57nijkDoes anyone know if it is possible to define deps on a per-build basis in shadow-cljs.edn?#2018-05-2419:59thheller@nick828 hi! no that is not possible as its typically not useful to do this for CLJS. it is perfectly fine to always have devcards on the classpath as your build config defines what ends up in your build. not the classpath.#2018-05-2420:00nijkah ok, so let’s say I wanted to ‘accidentally’ add devcards to my :app bundle… What would I have to do?#2018-05-2420:01thhelleryour namespaces decide what ends up in a build. so if none of your namespaces requires devcards.core then it will not be included.#2018-05-2420:02thhellerif you "accidentally" want to you (:require [devcards.core ...])#2018-05-2420:02nijkcool, thought so - but I just wanted to double check. I’m much more familiar with JS than cljs and I think this is analogous to tree-shaking#2018-05-2420:03thhellernot really. tree shaking also only optimizes the code you actually use. you could have thousands of npm packages installed but it would not matter to your build unless you require them all#2018-05-2420:04nijkok, I’m with you#2018-05-2420:01thhellerbut you can use deps.edn or lein to still do it if you really want to#2018-05-2420:05nijkJust out of interest could you point to an example of how this might look? I’m using deps.edn to define those aliases in the screenshot above#2018-05-2420:05thhellershadow-cljs -A:some-alias compile the-build#2018-05-2420:06thhelleronly works when not connecting to a server though#2018-05-2420:08thhellerclj -A:x -m shadow.cljs.devtools.cli compile the-build#2018-05-2420:08thhellerno need to use shadow-cljs directly. clj works just fine too. just a tiny bit more to type out#2018-05-2420:08nijkThanks Thomas 🙂 I’m really enjoying using Shadow-cljs as a front-end dev it’s far better than the alternatives I’ve been exposed to in the cljs eco-system#2018-05-2420:09thhellerthanks 🙂#2018-05-2420:41kurt-o-sysnew 'translation' question: https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/filter-props.html#how-to-use
(ns ...
  (:require 
            ["react-bootstrap-table-next" :default BootstrapTable]
            ["react-bootstrap-table2-filter" :refer [textFilter] :default filterFactory]))

(defn generate-columns [fields]
  (map (fn [[fieldname title props]]
         (merge {:dataField fieldname
                 :text title}
                props)) fields))


  (let [
        columns (generate-columns
                 [["name" (i18n [:general/name]) {...
                                                  :filter  (textFilter) )}]
                  ["email" (i18n [:general/email]) {...}]])]
    [:div [:> BootstrapTable {:data          ...
                              :keyField      "id"
                              :filterFactory (filterFactory)
                              :columns       columns}]]))
shows the filter, properties to set work fine, but when I start to type (and hence, the filter should start):
text.js:102 Uncaught TypeError: c.props.onFilter is not a function
    at text.js:102
#2018-05-2420:44thhellerguessing you are supposed to pass a :onFilter prop somewhere#2018-05-2420:45thhellerwhy the "generate-columns" fn?#2018-05-2420:48thhellerseems easier to just
(def columns
  (-> [{:dataField "id"
        :text "Product ID"}
       {:dataField "name"
        :text "Product Name"
        :filter (textFilter)}
       {:dataField "price"
        :text "Product Price"
        :filter (textFilter)}]
      (clj->js)))
#2018-05-2420:48kurt-o-sysoh, to generate the columns more easily.#2018-05-2420:49kurt-o-systhere's always that datafield and text, so I just provide them as vectors.#2018-05-2420:50thhellerI think ultimately you end up with a lot more code going the generate-columns route#2018-05-2420:50thhellerbut from what I can gather you probably just miss a (clj->js columns)#2018-05-2420:50kurt-o-sysdepends on how many fields you have and how many tables 😛#2018-05-2420:50kurt-o-sysyeah, trying with clj->js#2018-05-2420:50thhellernot sure how reagent deals with transforming nested values#2018-05-2420:50kurt-o-sysoh, ok...#2018-05-2420:51thhellerso you are probably passing a CLJS vector to the react component which expects a JS array#2018-05-2420:54justinlee@kurt-o-sys the syntax is :filter (filterFactory) not :filterFactory (filterFactory)#2018-05-2420:54kurt-o-sysoh sh*t.#2018-05-2420:55kurt-o-sysmust be getting late... need to get some sleep.#2018-05-2420:56kurt-o-systhx a lot again! (I love shadow-cljs, I love the community, ... I'm full of love this evening :p)#2018-05-2420:58justinleehow i miss the amazing error checking of libraries like react-dnd, which would have caught that and given you nice error message. a really good and easy to use map validator would save the world so much grief. i had high hopes for schema and spec but they’re not quite there.#2018-05-2420:59thhellerpretty sure schema/spec wouldn't help with this JS component though 😉#2018-05-2421:00kurt-o-syswell, I could've caught that there was a 'wrong' key.#2018-05-2421:09justinleeI mean, generally, I wish this existed. I had high hopes for a lisp-based language having good tools in this department, which is one of the reasons why I got excited about cljs. Actually in JS, if you have typescript or flowtype going, these problems get caught at compile time. It’s not there yet, but it could be some day. 🙂 Still the best error checking seems to come from the facebook people who have a bunch of ad hoc checking built in.#2018-05-2421:10thhelleragain: this assumes that the JS component is written in flow or typescript. if its not you gain nothing.#2018-05-2421:10thhellerand the propTypes checks are done by react anyways so the JS components could add them easily#2018-05-2421:10justinleewell with flowtype third parties can type it. there’s a sideband project to provide types for libraries#2018-05-2421:11thhellerthird parties could also spec/schema it, that is not a good argument 🙂#2018-05-2421:11justinleeneither spec or schema give ergonomic error messages#2018-05-2421:11justinleeand spec doesn’t even let you do closed maps without shenanigans#2018-05-2421:11thhellerit is "ok" with something like expound, but yeah they could be improved#2018-05-2421:12thhellerspec doesn't let you do closed maps. writing a spec for closed maps however is easy#2018-05-2421:13justinleefor example, you should be able to type the shadow-cljs.edn such that if you misplace a key like :after-load, it should be able to give you a super high quality error message#2018-05-2421:13justinleespec doesn’t check for closed maps, which is a top form of error I’d like to catch#2018-05-2421:14thhellerhttps://github.com/thheller/shadow/blob/master/src/main/shadow/spec.cljc#2018-05-2421:15thheller
(s/def ::y (map-spec :req {:foo string?} :closed? true))

  (s/explain ::y {:foo "1" :x 1})
#2018-05-2421:15justinleeoh i didn’t know you could do that#2018-05-2421:16thhellerextending spec is definitely possible but a bit cumbersome due to the macro-heavy implementation#2018-05-2421:16justinleeoh you’ve done some wizardry here.#2018-05-2421:16justinleeokay, NORMAL programmers like me can’t do that 🙂#2018-05-2421:16thhellerso definitely not recommended and I generally agree with the design decision done by spec regarding open maps#2018-05-2421:17thhellerbut yeah in case on config files that is not ideal#2018-05-2421:17justinleespec makes hard stuff possible but it doesn’t make simple stuff easy#2018-05-2421:18thheller@bhauman also did some impressive stuff in figwheel regarding the config validation, which could probably be turned into a really good library given unlimited time 😉#2018-05-2421:18thhellersomeone just has to write all this stuff#2018-05-2421:18justinleei’ve heard about that but haven’t checked it out since i’m on the shadow train#2018-05-2422:14thheller@wilkerlucio I'm beginning to question the viability of my :chrome-extension support. I extended it to support other scenarios like page/browser actions and it all works ok enough but has some drawbacks. might just end up recommending using a separate build for the extreme edge cases#2018-05-2422:16wilkerlucioyeah, I think the current support is good already, I don't mind having multiple builds for (I already do with the devtool), I think its to contemplate the main cases, and leave the rest out#2018-05-2422:17wilkerluciothe main issue IMO is the leak of repl support between builds, but that's not a specific problem of chrome target I guess (more related to modules in general)#2018-05-2422:19thhellerwell the REPL has the same problem for every build that you open in multiple runtimes, eg. opening a browser build in chrome+firefox#2018-05-2422:19thhellerreact-native running android/ios side by side and so on#2018-05-2422:20thhellerso that should be solved either way but sadly no editor is currently setup to do this#2018-05-2503:59theeternalpulseI'm connected to the nrepl in emacs but can't seem to eval anything using js/. Is this only available during compilation.#2018-05-2506:03grav@theeternalpulse Sounds like you have a Clj repl and not a CLJS repl. I usually invoke (shadow.cljs.devtools.api/nrepl-select :my-target) which drops me in the cljs-repl.#2018-05-2506:03grav(where :my-target is from your shadow-cljs.edn)#2018-05-2508:23bbssSince cider 17 my figwheel set-up for hot reloading chrome extension content script broke, so this seems like an excellent moment to try https://github.com/thheller/shadow-cljs/issues/279#2018-05-2508:25bbssI must be missing something, I thought maybe it's not the latest version of shadow-cljs but that seems to be the latest#2018-05-2508:25bbss
Baruchs-MBP-2% shadow-cljs compile chrome-ext
shadow-cljs - config: /Users/baruchberger/stah/cljsc2/shadow-cljs.edn  cli version: 2.3.23  node: v8.9.4
shadow-cljs - starting ...
[:chrome-ext] Compiling ...
Target ":chrome-extension" for build :chrome-ext was not found. The built-in targets are:
  - :browser
  - :browser-test
  - :node-script
  - :node-library
  - :npm-module
  - :karma
  - :bootstrap
#2018-05-2508:29thheller@bbss that is still a WIP and currently only available in master#2018-05-2508:30bbssI tried to find how to build from master, the version seems up-to-date.#2018-05-2508:30thhellerjust git clone and lein install#2018-05-2508:30bbssokay great, thanks.#2018-05-2508:31thhellerhope to get a release out today with basic support for :chrome-extension#2018-05-2508:34bbssdid you manage to get hot loading working on content-script pages?#2018-05-2508:34thhelleryep#2018-05-2508:35bbssI've done it twice on projects with figwheel, but what I was doing felt like black magic and the blogs writing about it online also have trouble figuring it out.#2018-05-2508:35thhellerjust works#2018-05-2508:35bbssAwesome, my experience with shadow-cljs so far has been so streamlined, great work.#2018-05-2508:39thhellernice to hear, thanks.#2018-05-2508:57bbssI'm giving the same path to source-paths as in my project.clj with lein, but am getting The required namespace "cljsc2.cljs.content-script" is not available.. Any hints?#2018-05-2508:59thhellerMaybe you have a content-script.cljs? shadow-cljs is pretty strict about enforcing _ but the error message for that is still missing (or rather ends up in the wrong place)#2018-05-2509:06bbssHmm, I renamed everything to remove the dash/underscore#2018-05-2509:06bbssStill getting The required namespace "cljsc2.cljs.contentscript" is not available..#2018-05-2509:07thhellerwhat is your source-path?#2018-05-2509:07thhellerassuming src you should have a src/cljsc2/cljs/contentscript.cljs correct?#2018-05-2509:08bbss
{:source-paths ["src/cljsc2/cljs"]
 :dependencies [[org.clojure/clojurescript "1.9.946"]
                [fulcrologic/fulcro "2.5.2"]
                [org.clojure/core.async  "0.3.443"]
                [com.cognitect/transit-cljs "0.8.243"]
                [cljsjs/d3 "4.12.0-0"]]
 :builds {:chrome-ext {:target :chrome-extension
                       :extension-dir "out/chrome-ext"}}}
#2018-05-2509:08bbssyes#2018-05-2509:08thhellerthat is an incorrect source-path#2018-05-2509:08thhellerthat is not how they work#2018-05-2509:08thhellersrc would be correct#2018-05-2509:08thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath#2018-05-2509:09bbssOkay reading up.#2018-05-2509:09bbssNow I'm getting namespace react not available but I can try to figure out how to solve that 🙂#2018-05-2509:09thhellernpm install react react-dom#2018-05-2509:10bbssthat's cool. using npm for it. super clean 🙂#2018-05-2509:16bbss[:chrome-ext] Build completed. (257 files, 135 compiled, 0 warnings, 57.26s) Hooray. Let's see if it runs!#2018-05-2510:12thheller@wilkerlucio @bbss just pushed an update for the chrome-ext stuff, still only on master though. https://github.com/thheller/shadow-cljs/issues/279#issuecomment-392007641#2018-05-2510:23bbssThanks, will check it out and update.#2018-05-2510:27thheller@bbss did it run with the "older" config?#2018-05-2510:27bbssWell I was still solving issues with dependencies, but I got a succesful print from the extension so yes#2018-05-2510:28bbssHad one issue which I assume is because an earlier loaded file errored. Uncaught TypeError: cljsc2.cljs.contentscript.core.init_BANG_ is not a function#2018-05-2510:29thhellerpossibly#2018-05-2510:50troglotitDid anyone faced Uncaught TypeError: $goog$string$$.format is not a function ? I thought Closure library is somewhat bulletproof to name munging#2018-05-2511:07ggaillardTo use goog.string.format you need to require the goog.string namespace and goog.string.format namespace, look at this example : https://github.com/reagent-project/reagent-utils/blob/master/src/reagent/format.cljs#L6#2018-05-2511:09ggaillardDoes it solve it?#2018-05-2511:38troglotitYeah, it works. Thanks!#2018-05-2511:13bbssI have some JavaScript that I need to manually include, is there an easy way to include some js file? I would include it in the html but the content-script has no access to the window.#2018-05-2511:17bbss@thheller I'm getting `At least one js or css file is required for 'content_scripts[0]'. Could not load manifest.` when loading the extension using the latest push.#2018-05-2511:20bbssMaybe I forgot to include something, hold on.#2018-05-2511:43thheller@bbss you probably need to remove the :content-scripts entry from manifest.edn since that will now be generated from :shadow/outputs#2018-05-2511:43bbssYeah, sorry I was being stupid. Working in the wrong buffer..#2018-05-2511:43thheller:shadow/entry there is no longer correct#2018-05-2511:44bbssIt works now, just need to include some manual JS. Will use yarn add file:// for it.#2018-05-2511:44thhellerwhat do you mean by manual js?#2018-05-2511:45bbsserr, well non-compiled JS. I have some horrible unoptimized for loops for running through image data.#2018-05-2511:45bbssAnd normally I manually include these in a script tag of the page. But since the content-script has limited access to that it's saying those are undefined.#2018-05-2511:46thhelleryou can just (:require ["./some-script.js" :as x]) and its exports will be available via CLJS#2018-05-2511:46bbssI wouldn't even need to yarn add, great. Thanks.#2018-05-2511:46thheller(this assumes in the the same directory as your .cljs file#2018-05-2511:46bbssOkay. Makes sense.#2018-05-2511:46thhelleryou can put it anywhere on the classpath and include it via "/somewhere/some-script.js" as well#2018-05-2511:47thhellerbut must be on the classpath, so in one of your :source-paths#2018-05-2512:17bbssokay, getting close. Jacking in with cider but now the manifest.json is invalid:
"out/cljs-runtime/cljs.pprint.js", ...],
#2018-05-2512:18thhellergrrrrrrrrr#2018-05-2512:19thhellercider sets *print-length* which messes with things in pretty annoying ways#2018-05-2512:21thheller@bbss master should fix that#2018-05-2512:25bbssIt did! Thanks @thheller. I have my trusty in IDE cljs eval back, now with new shadow-cljs flavor.#2018-05-2512:26bbssHowever my screen is now full of build warnings after refreshing. I guess I should use proper reflection instead of the regular . syntax.#2018-05-2512:26thhellerhmm?#2018-05-2512:27thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-05-2512:28bbssYes, I included that with auto.#2018-05-2512:28thhelleryeah those are the things that might break in :advanced#2018-05-2512:29thheller(fn [^js cell] ...) would fix one of them#2018-05-2512:29bbssYou can see the image I posted? Slack said it's only visible to me.#2018-05-2512:30thhellerbut yeah might need to turn off the externs inference if you get too many warnings#2018-05-2512:30thhellerI can see the image yes. I think the slack message is just info about them not storing it due to lack of premium#2018-05-2512:30bbssI turned it on because I thought I'd need it for d3/react#2018-05-2512:31thhellerfunny thing is that you probably don't need it for those#2018-05-2512:31thheller. is native interop and the compiler sometimes needs a hint to figure out if you are working with a JS object which it shouldn't rename#2018-05-2512:32thhelleror something else which would be fine to rename#2018-05-2512:32thhellerthe fulcro thing is odd since I thought that was fixed#2018-05-2512:33bbssIt's a version that's already a couple weeks old though.#2018-05-2512:33thhellerthat actually looks like invalid code (generated by the fulcro macro)#2018-05-2512:34bbssThank you so much for helping me out so quickly.#2018-05-2512:34bbssI'm so happy I got my set-up back with a recent cider.#2018-05-2512:35bbssI'll probably be using it quite a bunch more now.#2018-05-2512:37bbssGot my set-up back + the code is simplified a bunch. It's cool to integrate so naturally with JS, I thought cljs<->JS interop was already decent but shadow-cljs really takes it up a notch.#2018-05-2512:39bbsswith my approach before I had to include react and d3 from external sources as cljsjs deps didn't work. Now don't even need them 🙂!#2018-05-2514:05bbssfigwheel has a on-js-reload. I think :devtools {:after-load ns/fn} is the analog. But I get can't find fn cljsc2.cljs.contentscript/on-js-reload. Funnily enough it also reports that when I remove that from the shadow-cljs.edn and add ^:dev/after-load as function meta.#2018-05-2514:07thhellerodd. will check. it might be related due to the weird scoping in content-scripts. it probably tries to look up window.cljsc2....#2018-05-2514:21thheller@bbss fixed in master#2018-05-2514:29bbss@thheller confirmed, you're the best 🙂#2018-05-2514:30thhellerI doubt that given that I added the bug that prevented that from working 😉#2018-05-2514:32bbssWell, being able to write a module system that works on so many platforms with such a consistent api is 💯#2018-05-2514:32bbssAll the exceptions, hidden config options and rules with almost no error reporting of the extension ecosystem... Ugh. So much trouble saved in this approach 🙂#2018-05-2514:33thhellerbtw I just pushed 2.3.24 which has the latest version of the chrome stuff as well#2018-05-2514:34thhellermight need to bump your dep if you do another lein install later#2018-05-2514:34thhellernot confident that I covered everything for :chrome-extension yet so I still consider that a WIP#2018-05-2514:35bbssYes, I feel lucky googleing for "shadow-cljs chrome extension" this morning and seeing your 7 day your old issue with a proof of concept!#2018-05-2514:36kurt-o-sysjust wondering @thheller: I really like your way of thinking and how to pass configs from index.html... but here's the thing: how to pass different configs read from a config file. I mean: if I have 2 index.html files (one for prod and one for dev) that seems fine. However, whenever I need to add some lines (script, css) to index.html, I need to do it in 2 places. So I'd prefer to be able to have a kind of templating/preprocessing of index.html, so it reads the config from a file. How d'you do that usually?#2018-05-2514:36thhellerI have been planning a chrome extension for shadow-cljs for years now so it was about time 😉#2018-05-2514:38thheller@kurt-o-sys my server-side is always clojure so the html is generated by the server which makes adding dynamic stuff pretty easy#2018-05-2514:39kurt-o-sysoh, ok...#2018-05-2514:39kurt-o-sysno static html file there, right 😛#2018-05-2514:39thhellergenerating an index.html could be done via clj-run#2018-05-2514:40thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-05-2514:40kurt-o-sysnice, thx!#2018-05-2514:40kurt-o-systhat will certainly do!#2018-05-2514:41thhellerI want to add a webpack-ish html thing eventually#2018-05-2515:46mhuebert@thheller this is not a big deal, but is there a reason why shadow.loader can’t be used immediately when a page loads? one must have it called later (or after a 0ms timeout) otherwise an “Unknown module: …” error pops up#2018-05-2515:47mhueberti was also looking at the builtin cljs.loader. I actually can’t get it to work at all, it shows a warning about source maps not being found and just prints my callback function to the console#2018-05-2515:47theeternalpulseanyone having issues accessing the documentaiton?#2018-05-2515:48mhuebert@theeternalpulse i am able to refresh https://shadow-cljs.github.io/docs/UsersGuide.html w/o issue#2018-05-2515:50theeternalpulseodd, it times out on my work or home laptop. I'm on the west coast of north america.#2018-05-2515:50mhueberti’m in berlin so we are probably hitting different endpoints#2018-05-2515:48thhellerhmm yeah I kind of torn about supporting this. I could make it work ... BUT the idea is that loading should be triggered by a user event#2018-05-2515:48thhellerif you are loading one script which then immediately loads another you should just be loading one combined version#2018-05-2515:48thhellersince that would be faster#2018-05-2515:48mhuebertI mean as long as it is predictable, and isn’t a variable amount of time delay#2018-05-2515:49mhuebertbut in a SPA i may check the route and then load the appropriate module#2018-05-2515:49thhellercurrently a shadow.loader.setup function call is added to the end of the base module#2018-05-2515:49thheller@mhuebert yeah there are valid arguments for loading modules directly. no doubt about that.#2018-05-2515:50thhellerthe problem goes away when you go full async#2018-05-2515:50mhuebertwhat do you mean by full async?#2018-05-2515:50thhellerhow is your app initialized/started?#2018-05-2515:51mhueberti am figuring out how i will do that now. I don’t think this is going to be an issue at all because i will be resolving this in a callback anyway#2018-05-2515:52mhuebertit was just the first thing i hit trying to test out modules and was wondering if there was something weird going on#2018-05-2515:52thheller<script async src="/js/base.js"></script>#2018-05-2515:52mhuebert
(defn init []
  (routing/listen
   (fn [{:keys [path] :as location}]
     (try-module-load))))

(-> js/document
    (.addEventListener "DOMContentLoaded" init))
#2018-05-2515:52mhuebert^^this works#2018-05-2515:52thhellerI'm assuming that you have a ns that simply calls (init) or so#2018-05-2515:52mhuebertah i see#2018-05-2515:53thhelleryeah that works as well#2018-05-2515:53thhellerI do this pretty much always https://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html#2018-05-2515:55thhellerie. embed a <script type="shadow/run" data-fn="my.app/init">["some" "args"]</script> which basically invokes (my.app/init "some" "args") when the JS is loaded#2018-05-2515:55thhellerbut technically that could still have the same problem with the loader#2018-05-2515:56thhellerI can change the setup sequence#2018-05-2515:56thhellerI probably should just to get rid of this problem#2018-05-2515:59mhuebertI like how that looks on the server side#2018-05-2515:59mhuebertalong the lines of (cljs 'some.ns/fn & args)#2018-05-2515:59mhuebertwhich i guess is just hiccup for the script tag#2018-05-2516:00thhelleryep exactly#2018-05-2517:44thheller@mhuebert just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "32415a53565d451f515e584172001c011c0007"}, :content ("[email protected]")} which changes the shadow.loader init so it should be immediately available#2018-05-2517:51mhuebertCool, thanks!#2018-05-2518:23justinleei need a cron job that updates my shadow-cljs every morning 😛#2018-05-2522:14Logan PowellI'm getting this error when trying to eval the code above:
utils.async_fetch._GT__BANG__BANG_.call(null,c,"hello");
                                   ^

TypeError: Cannot read property 'call' of undefined
#2018-05-2522:14thheller>!! does not exist in CLJS#2018-05-2522:14Logan Powellah!#2018-05-2522:14Logan Powelldoes >!?#2018-05-2522:14thhellerwhen inside a go#2018-05-2522:15Logan Powellah, so I can't follow [this walkthrough](https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj)#2018-05-2522:15Logan Powellis there one for cljs.core.async?#2018-05-2522:15thhellerno that is intended for clojure#2018-05-2522:15thhellerno idea#2018-05-2522:15Logan Powellbtw, Hi @thheller#2018-05-2522:15Logan Powell🙂#2018-05-2522:16Logan Powellok#2018-05-2522:16thhellerhey 😉#2018-05-2523:09Logan PowellAlrighty! I think I'm finally all set up with SHADOW BABY!#2018-05-2523:10Logan Powellbananadance#2018-05-2523:10Logan Powelljust had to get used to the new error messages 😉#2018-05-2601:20justinleestart importing some npm modules#2018-05-2614:21mhuebertone small difference b/w cljs and shadow loader is that the cljs version accepts a keyword as module name#2018-05-2614:27mhuebertI half expected to be able to resolve a symbol asynchronously and have the appropriate module loaded automatically; I guess this would require including a whole namespace->module index#2018-05-2614:38mhuebertI’m finding that the built-in resolve macro is not exactly the thing I would want/expect for module loading; there’s no need to include the var’s metadata, and it shouldn’t be necessary to provide the symbol statically at compile time. I am looking at using a function like this instead:
(defn resolve-to-value [sym]
  (->> (.split (str sym) #"[./]")
       (map munge)
       (to-array)
       (apply gobj/getValueByKeys js/window)))
then I can pass symbols around as values instead of having to wrap them in the resolve macro,
(def handlers {:home 'my-app.views.pages/home})
...
(resolve-to-value (:home handlers))
Otherwise, I had to use something like a case statement
(defn handler-var [k]
  (case k
    :home (resolve 'my-app.views.pages/home))
#2018-05-2615:05thheller@mhuebert that doesn't work in :advanced#2018-05-2615:18thhellerI thought about adding async-require or something similar that would automatically do the shadow.loader business.
(async-require
  [[some.ns :refer (foo)]
   [some.thing :as x]]
  (x/bar)
  (foo))
#2018-05-2615:19thhellercould take some :require-ish forms and the body would execute when all required modules are ready#2018-05-2615:20thhellercould even return a promise that would resolve to the final return value of that body#2018-05-2615:21thhellerbut that would require some compiler trickery to work properly#2018-05-2615:21thhelleralso wouldn't allow what you are after since the require forms would still be static#2018-05-2615:38mhuebertright. i have reverted to the case form b/c of the :advanced bit.#2018-05-2616:08kwladykaDo you know example repo to show how to use material-ui in shadow-cljs?#2018-05-2616:08kwladykaor something similar#2018-05-2616:08kwladykaI use re-frame#2018-05-2616:11thheller@kwladyka don't know any but (:require ["@material-ui/core/Button" :default Button]) [:> Button {:variant "raised" :color "primary"} "Hello World"] might work#2018-05-2616:11thheller
import React from 'react';
  import Button from '@material-ui/core/Button';

  const App = () => (
    <Button variant="raised" color="primary">
      Hello World
    </Button>
  );
#2018-05-2616:11kwladykathe best I would like to use https://mdbootstrap.com, but this can be too difficult#2018-05-2616:11thhellerbasically just translated their default example#2018-05-2616:14kwladykaone thing which I notice is after that I have to reload browser manualy#2018-05-2616:14kwladykaSo my assumption is after add dependency always reload browser manually#2018-05-2616:14kwladykathank you for help#2018-05-2616:14kwladykaDo you think using this mdbootstrap is possible / simple in cljs?#2018-05-2616:14thhelleryarn add mdbreact (:require ["mdbreact" :as mdb]) [:> mdb/Button ...]#2018-05-2616:15kwladykano way… It would be too easy…#2018-05-2616:15thhellerI have no clue about the reagent/re-frame part since I do not use that#2018-05-2616:15thhellerbut importing it works simple enough#2018-05-2616:15thhellercss probably needs some manual work though#2018-05-2616:16kwladykahttps://github.com/mdbootstrap/React-Bootstrap-with-Material-Design as default they use webpack, not an issue?
#2018-05-2616:24kwladykaI will try anyway 🙂#2018-05-2616:28thhellerseems to work fine#2018-05-2616:37thhellerhonestly though. do not use that package. it is horrible. it does work but it is horrible.#2018-05-2616:40kwladykaheh lol, I didn’t use it. I found it in last week. It just looks beautiful 🙂#2018-05-2616:41kwladykabut after what you said I have to consider it again 🙂#2018-05-2616:41thhellerjust use https://material-ui.com/ directly#2018-05-2616:42kwladykaI am looking something with ready UI components and idea of material + bootstrap twitter sounds good#2018-05-2616:44thhellermdbreact might work for that#2018-05-2616:45thhellercan always optimize later#2018-05-2616:46thhellerjust test them all 😉#2018-05-2616:47kwladykaI did it form UI sense of art perspective. I didn’t do it from tech perspective yet 🙂#2018-05-2708:05kwladykaWhatever I change content, page in browser reload without any errors, but content on page doesn’t change. I have to reload browser each time manually. Am I doing something wrong?#2018-05-2708:10kwladyka
(defn main-panel []
  [:div "foo"])
#2018-05-2708:16thheller@kwladyka you probably need an after-load callback to actually re-render?#2018-05-2708:16thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2018-05-2708:17kwladykaIt was working in figwheel without additional re-render functions#2018-05-2708:17thhellerin figwheel it is called on-jsload I think#2018-05-2708:17thhellerI doubt that#2018-05-2708:18thhellercheck you figwheel config#2018-05-2708:18kwladykaoh…. true… I am sorry#2018-05-2708:19kwladykathank you again#2018-05-2708:21kwladykait works 🙂#2018-05-2709:26kwladykaIs there a way to not write:
["@material-ui/core/Styles" :default Styles]
            ["@material-ui/core/AppBar" :default AppBar]
            ["@material-ui/core/Toolbar" :default Toolbar]
            ["@material-ui/core/Typography" :default Typography]
            ["@material-ui/core/Button" :default Button]
...
#2018-05-2709:27kwladyka[@material-ui/core/ :foo [Styles AppBar Toolbar]] or import all or …?#2018-05-2709:27thhellerno#2018-05-2709:30kwladykaIt is not shadow-cljs question probably, but how to translate into cljs:
const styles = {
  root: {
    flexGrow: 1,
  },
};

function SimpleAppBar(props) {
  const { classes } = props;
  return (
    <div className={classes.root}>
      <AppBar position="static" color="default">
        <Toolbar>
          <Typography variant="title" color="inherit">
            Title
          </Typography>
        </Toolbar>
      </AppBar>
    </div>
  );
}

SimpleAppBar.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(SimpleAppBar);
while I am using reagent with hiccup.
#2018-05-2709:30thhellerno idea. probably need to ask in #reagent#2018-05-2709:31kwladykaok, thx#2018-05-2711:47thhellerin 2.3.27 I finally merged the :build-hooks stuff I had laying around since forever. should have done this way sooner but here it is now: https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-05-2711:47thheller@mhuebert ^ might be interesting to you since I know you do a lot of custom clj-run stuff already#2018-05-2712:15mhuebertThis is awesome#2018-05-2711:52thheller@kurt-o-sys you also asked about generating an index.html for the build. :build-hooks could now do stuff like that.#2018-05-2711:55kurt-o-sys:+1:#2018-05-2716:56Jonhttps://github.com/thheller/shadow-cljs/issues/284#2018-05-2717:36mhuebert@thheller these build hooks are working great for my html- and css- file generation#2018-05-2717:36mhuebertno longer any need to use clj-run#2018-05-2717:40mhuebert#2018-05-2718:03mhuebertis the watched & changed file that triggers a build noted in the build state somewhere?#2018-05-2719:16thheller@mhuebert doesn't the build-info contain all that?#2018-05-2719:39mhuebert@thheller it has :compile-start, :timings, :modules, :sources, :compiled#2018-05-2719:40mhuebert:compiled is the closest, but I didn’t see that it indicates which file changed#2018-05-2719:41thheller:compiled is the set of resources that where recompiled#2018-05-2719:41thheller:sources is the list of all sources in that build#2018-05-2719:41thhellerso for each :sources where :resource-id is contained in :compiled gives you the sources that were recompiled#2018-05-2719:42thhellerthe "trigger" itself is not kept#2018-05-2719:44thheller
(->> sources
     (filter #(contains? compiled (:resource-id %)))
     ...)
#2018-05-2719:45mhuebertyeah, I was doing something like that in the client
active-namespaces (set (keys (:cljs.analyzer/namespaces @carton/compiler)))
compiled-namespaces (-> (:sources @bootstrap-env/index-ref)
                        (select-keys compiled)
                        (vals)
                        (->> (filter (comp active-namespaces :ns))))
#2018-05-2719:46thhellerthat works too#2018-05-2719:47mhuebertthen i used made a ring handler that serves arbitrary resources from the classpath and requested the original clj* files to eval directly via self-host#2018-05-2719:48mhueberti am still just experimenting, with what kind of dev experience might be nice when building selfhost-compatible things.#2018-05-2719:49mhuebertthis stuff is to allow for editing from intelliJ, with all changes going into a live environment in the browser#2018-05-2719:49mhuebertmetadata on vars determines how they are visualized#2018-05-2719:50mhuebertso you can have a nice tree of all your namespaces, with various def’d things appearing in arbitrary/nice ways#2018-05-2719:51mhuebertsome things in common with devcards but more like a general namespace browser + ability to layer custom views where you want#2018-05-2719:52thhellersounds cool but why self-host?#2018-05-2719:53thhellerhmm I guess you want maria-style? so cloud vs something running locally?#2018-05-2719:55mhuebertnot entirely sure. it could be an augmentation to a version of maria (or something like it) which runs locally, and is also updated from files, but you have the full compiler state on hand#2018-05-2719:57mhueberti was also looking at making a little API in the handler for exposing more things from the compiler-state,#2018-05-2719:57mhuebertthen one could do more with non-selfhost stuff#2018-05-2719:59thhellerI did a few tests with pathom for using graph queries to expose shadow-cljs internal data#2018-05-2720:00thhellerwhich could technically be used to let you query the entire cljs.analyzer state for whatever you'd need#2018-05-2720:00thhellerI do have plans myself for the shadow-cljs that would let you browser docs and such#2018-05-2720:00thhellerwith a little eval window to try stuff directly#2018-05-2720:01mhuebertnice#2018-05-2720:01thhellerI added http://localhost:9630/repl as the first basic test#2018-05-2720:01mhueberti have not looked at pathom before#2018-05-2720:01thhellernot related to the pathom/graph stuff#2018-05-2720:01thhellerjust wanted to test accessing the REPL directly from the browser#2018-05-2720:03mhuebertwe will want some kind of namespace browser for maria eventually,#2018-05-2720:04mhuebertand it would be very nice if the same thing could be used outside of selfhost#2018-05-2720:05mhuebertpathom looks promising in that the same description of analyzer data could be resolved on the shadow side or in the browser, depending on which compiler-env you wanted to inspect#2018-05-2720:06thhelleryeah it made writing a few test queries really easy#2018-05-2720:20mhueberthmm is there a way to type into http://localhost:9630/repl#2018-05-2720:20mhuebertoh nevermind i didn’t see the thing at the bottom#2018-05-2720:20thhellercodemirror with parinfer at the bottom#2018-05-2720:20thhellershift+enter to eval#2018-05-2720:21thhellerextremely basic stuff. no history, no autocomplete, nothing useful really#2018-05-2720:21mhuebertahhh cool#2018-05-2720:21mhuebertbut the basic concept is there#2018-05-2720:21mhuebertand could easily add some UI around evaluating useful things by clicking#2018-05-2720:22thhellerI will start building a proper UI eventually. just started with this to test some stuff#2018-05-2720:24mhuebertis there a way to list builds?#2018-05-2720:25thhellerits just a clojure REPL#2018-05-2720:26thheller(-> (shadow.cljs.devtools.config/load-cljs-edn) :builds keys)#2018-05-2720:26mhuebertthat’s what i was looking for#2018-05-2720:26thhellershould probably add a proper api method for that#2018-05-2720:27thhelleropen a ticket for that if you need it#2018-05-2720:29mhuebertdone#2018-05-2810:02bupkisHello. Does anybody else have issues with Vim and the latest shadow-cljs (2.3.28). I upgraded from 2.3.23 to make use of the build hooks, and my vim-fireplace setup stopped working. When I do "Piggieback :build-id" from Vim, with 2.3.23 everything works, but with 2.3.28 I get the following error:#2018-05-2810:02bupkisin vim:
Error detected while processing function <SNR>28_piggieback[1]..fireplace#platform:
line   32:
E605: Exception not caught: Fireplace: :Connect to a REPL or install classpath.vim
#2018-05-2810:03bupkisin shadow-cljs console:
[2018-05-28 13:02:24 - SEVERE] Unhandled REPL handler exception processing message {:id fireplace-lap1-1527501741-5, :op clone}
java.net.SocketException: Socket closed
        at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
        at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
        at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
        at clojure.tools.nrepl.transport$bencode$fn__20978.invoke(transport.clj:103)
        at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
        at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
        at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
        at clojure.tools.nrepl.middleware.session$session$fn__22346.invoke(session.clj:188)
        at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__21967.invoke(middleware.clj:22)
        at shadow.cljs.devtools.server.nrepl$start$fn__22599.invoke(nrepl.clj:344)
        at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
        at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
        at clojure.tools.nrepl.server$handle$fn__22419.invoke(server.clj:28)
        at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
        at clojure.lang.AFn.call(AFn.java:18)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:844)
#2018-05-2810:04bupkisvim-fireplace is the latest version, cider-nrepl is 0.17.0#2018-05-2810:05thhellerdid you restart the server properly? I don't use vim-fireplace so I can't say what happens on that side#2018-05-2810:05bupkisyes, I also tried on a clean empty project from scratch#2018-05-2810:06bupkisand I can reproduce that 2.3.23 works, and 2.3.28 doesn't#2018-05-2810:09thhellernrepl is driving me crazy. I suspect its caused by a change I did to try an fix https://github.com/thheller/shadow-cljs/issues/273#2018-05-2810:10thhelleralthough I have no idea how that has any effect at all in clone#2018-05-2810:13thhellerbut all the messages tell me is that a socket was closed#2018-05-2810:13thhellerare you positive that the close is not initiated by vim-fireplace?#2018-05-2810:13bupkisit probably is, but why does it work with the older shadow-cljs version?#2018-05-2810:14thhellernot a clue. unfortunately I don't have a vim-fireplace setup to test any of it#2018-05-2810:15thhelleris there a quick an easy way to set that up without doing a million things?#2018-05-2810:15thhellerassuming ZERO vim config present?#2018-05-2810:16bupkiswould a container do? if yes I can write a dockerfile for you to run vim in#2018-05-2810:16thhellerdunno I'm on windows and docker-compose stuff seems to require windows pro#2018-05-2810:18bupkishow can I run a dev build of shadow-cljs itself? maybe it would be easier if I try to isolate the changes you mentioned above than try to setup vim on windows#2018-05-2810:18bupkis(i don't have windows at all)#2018-05-2810:18thhelleryou can clone the repo and run lein with-profiles +cljs repl and then (require 'repl) (repl/go)#2018-05-2810:19thhellerthe connect to the started nrepl server at localhost port 8202#2018-05-2810:19thheller(not the nrepl provided by lein)#2018-05-2810:19thhellerthat setup has a bunch of debug stuff enabled. among other things it prints all nrepl messages to the console#2018-05-2810:20thhellermight need to bump cider-nrepl in project.clj first. its still v16#2018-05-2810:21bupkisthanks. cloning now. i'll try with 16 first, then bump to 17, etc. until I isolate it.#2018-05-2810:26tianshu@thheller is that if use tools.deps or leiningen for dependency management, shadow-cljs will ignore -d command line argument?#2018-05-2810:26thhelleryes#2018-05-2810:26tianshuis this designed?#2018-05-2810:28thhellerwell when either of those the classpath is constructed by them#2018-05-2810:29thhellerso you should probably be using them directly if you need stuff like that#2018-05-2810:30thhellerif you use lein the command is printed on startup, you can literally just use that instead#2018-05-2810:30tianshufor editor users (like emacs cider), it will inject dependencies by using -d, this will not work if I use leiningen or tools.deps.#2018-05-2810:32thhellerif you are using lein use the emacs built-in support for lein?#2018-05-2810:38tianshucider now has built-in support for shadow-cljs.#2018-05-2810:38thhellerI guess it should be possible to modify https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L272-L293 to inject dependencies for lein as well (or tools.deps)#2018-05-2810:39tianshuI'll take a look, to see If I can make a PR for it.#2018-05-2810:39thhellerI know but with :lein you are effectively using lein not shadow-cljs#2018-05-2810:39thhellerit just delegates#2018-05-2810:39thhellerthe opts has :dependencies key which are those added by -d https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L286#2018-05-2810:40bupkis@thheller 8bb0cf436a928a804e42ec094e77b7e774a5aac3 is where it breaks fireplace.#2018-05-2810:40tianshuokay#2018-05-2810:40thhellerif you tell me the the command line for lein to add those deps I can add it#2018-05-2810:42thheller@samuel.wagen hmm I guess that makes sense#2018-05-2810:43bupkisSuccessful session:
user=> [13:38:34,327] nrepl-receive {:id "fireplace-lap1.local-1527503914-1", :op "clone"}
[13:38:34,332] nrepl-receive {:id "fireplace-lap1.local-1527503914-2", :op "describe", :verbose? 1}
[13:38:34,367] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-3", :op "eval"}
[13:38:34,373] nrepl-receive {:id "fireplace-lap1.local-1527503914-4", :op "classpath"}
[13:38:36,086] nrepl-receive {:id "fireplace-lap1.local-1527503914-5", :op "clone"}
[13:38:36,089] nrepl-receive {:id "fireplace-lap1.local-1527503914-6", :op "describe", :verbose? 1}
[13:38:36,119] nrepl-receive {:code "[(System/getProperty \"path.separator\") (System/getProperty \"fake.class.path\")]", :id "fireplace-lap1.local-1527503914-7", :op "eval"}
[13:38:36,125] nrepl-receive {:id "fireplace-lap1.local-1527503914-8", :op "classpath"}
[13:38:36,132] nrepl-receive {:id "fireplace-lap1.local-1527503914-9", :op "clone"}
[13:38:36,135] nrepl-receive {:code "((or (resolve 'cider.piggieback/cljs-repl)(resolve 'cemerick.piggieback/cljs-repl)) :browser)", :id "fireplace-lap1.local-1527503914-10", :op "eval"}
[13:38:37,311] nrepl-receive {:id "fireplace-lap1.local-1527503914-11", :op "close"}
[13:38:37,314] nrepl-receive {:id "fireplace-lap1.local-1527503914-12", :op "close"}
[13:38:37,316] nrepl-receive {:id "fireplace-lap1.local-1527503914-13", :op "close"}
Bye for now!
#2018-05-2810:43bupkisFailed session:
user=> [13:39:21,353] nrepl-receive {:id "fireplace-lap1.local-1527503961-1", :op "clone"}
[13:39:21,357] Unhandled REPL handler exception processing message {:id fireplace-lap1.local-1527503961-1, :op clone}
java.net.SocketException: Socket closed
	at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
	at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:155)
	at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
	at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
	at clojure.tools.nrepl.transport$bencode$fn__724.invoke(transport.clj:103)
	at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28)
	at clojure.tools.nrepl.middleware.session$register_session.invokeStatic(session.clj:144)
	at clojure.tools.nrepl.middleware.session$register_session.invoke(session.clj:137)
	at clojure.tools.nrepl.middleware.session$session$fn__1254.invoke(session.clj:188)
	at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__903.invoke(middleware.clj:22)
	at shadow.cljs.devtools.server.nrepl$start$fn__20723.invoke(nrepl.clj:344)
	at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
	at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16)
	at clojure.tools.nrepl.server$handle$fn__1327.invoke(server.clj:28)
	at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:844)
#2018-05-2810:43thhellerI suspect the added :greeting-fn maybe?#2018-05-2810:44thhellertry removing https://github.com/thheller/shadow-cljs/blob/8bb0cf436a928a804e42ec094e77b7e774a5aac3/src/main/shadow/cljs/devtools/server/nrepl.clj#L338-L340#2018-05-2810:44bupkislet me try removing it#2018-05-2810:44thhellermaybe vim-fireplace doesn't like receiving random out messages#2018-05-2810:44thhellerand just drops the socket#2018-05-2810:45tianshuI'll post a issue for that#2018-05-2810:45bupkis@thheller spot on, without greeting-fn HEAD works#2018-05-2810:45thheller@doglooksgood please do#2018-05-2810:45thheller@samuel.wagen ok. I'll remove that, doesn't serve any real purpose anyways#2018-05-2810:46bupkischeers, thank you!#2018-05-2810:47bupkisvim-fireplace is too fragile, but AFAIK there isn't a better alternative yet#2018-05-2810:48bupkisstupid question - how can I use a shadow-cljs dev version with my code?#2018-05-2810:48thhellerits gone in master#2018-05-2810:48thhellerbest option is probably just lein install#2018-05-2810:49thhellerthat installs over the current 2.3.28#2018-05-2810:49thhellerthen use as usual#2018-05-2810:49bupkisi don't have it global, i only have it as a devDependency in packages.json and use npx shadow-cljs#2018-05-2810:49thhellerthe npm part doesn't matter#2018-05-2810:50thhellerhang on, I can just make a release with the fix as well#2018-05-2810:50bupkisawesome#2018-05-2810:51thhellertry {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "56253e373239217b353a3c251664786578646f"}, :content ("[email protected]")}#2018-05-2810:54bupkisworks fine, vielen Dank!#2018-05-2810:55bupkisI guess I ought to try Cursive, but too many years in Vim have damaged me I guess 😄#2018-05-2810:58bupkisbtw. the new build-hooks stuff is very useful!#2018-05-2811:01bupkisI use it to expose the git commit hash (and dirty status) as a Closure define, which exposes it to the CLJS code in the browser. Enables me to have that hash in my telemetry so that when I report client exceptions from the browser, I also have a way to pinpoint the exact code revision.#2018-05-2811:08tianshuhttps://github.com/thheller/shadow-cljs/issues/286 I just post a issue for this, If you don't have time, I think I can help:sunglasses:#2018-05-2811:38heyarneis there a reason why #shadow-connection-error is position: absolute and not position: fixed?#2018-05-2811:43thhellernot really 😛#2018-05-2813:05BraviI love how there’s a channel for everything 😄#2018-05-2813:06thheller:http-host should just be the host, not a url.#2018-05-2813:07thhellerthe websocket by default assumes you are running locally. it that not the case?#2018-05-2813:08thhellerdeomens-l53.test is that your machine?#2018-05-2813:08Braviso I’ve got vagrant running and the virtual host is that yes#2018-05-2813:09Bravi
deomens-l53.test/admin
this page is served from php
#2018-05-2813:10thhellerand shadow-cljs is running in vagrant or outside?#2018-05-2813:10Braviand within that page I have my div#application and then the <script> where my cljs app lives#2018-05-2813:10Braviit’s outside of vagrant#2018-05-2813:10Braviat the moment#2018-05-2813:10thhellerok then you probably need to configure :devtools {:devtools-url ""} in your build config#2018-05-2813:10thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2018-05-2813:11thhellersince the setup assumes everything is running on the same machine which it isn't when running in vagrant#2018-05-2813:14Braviand I guess now I need to redirect these requests to localhost, right?#2018-05-2813:14thhellercan you open ?#2018-05-2813:15thhellerif so you don't need anything else. :devtools-url just configures where the websocket tries to connect to#2018-05-2813:15Braviyep I can and it says shadow-cljs.. and then release snapshots#2018-05-2813:16thhellerit used because you are probably on ... somewhere#2018-05-2813:16Bravithat’s the whole page basically#2018-05-2813:16thhelleryep, that is correct#2018-05-2813:16thhelleryou can remove :http-port and :http-host from your config#2018-05-2813:17thhellerjust set the :devtools {:devtools-url ""} and you should be good#2018-05-2813:18thhellerassuming of course that you are compiling the files somewhere the vagrant php server can see them?#2018-05-2813:20thhellerare you using laraval?#2018-05-2813:20BraviYes!#2018-05-2813:20Bravithat solved it#2018-05-2813:20Braviand yes I’m using laravel#2018-05-2813:20thhellerok#2018-05-2813:20Bravithank you so much 😄#2018-05-2813:21Braviso the first issue was that I had both - http-host and devtools-url as well#2018-05-2813:21Braviand when I removed http-host#2018-05-2813:21BraviI just had an extra forward slash in the end here -> #2018-05-2813:21Bravisilly mistake#2018-05-2813:22thhellerah right. I should probably validate that#2018-05-2813:22Bravithis is so cool! finally! 😄#2018-05-2813:23Bravithank you for this awesome tool#2018-05-2813:54Braviand to use some third party react components, can I not do [:> some-react-class] anymore?#2018-05-2813:55thhellersure you can#2018-05-2813:58Bravihmm#2018-05-2813:58Bravii’m getting Uncaught Error: Assert failed: Expected React component in: [:> #js {:DayPicker #object[b], :DateUtils #js...#2018-05-2814:00thhellerlooks like you are passing the wrong thing? maybe [:> foo ..] instead of [:> foo/DayPicker ...]?#2018-05-2814:03Bravithat’s it! I thought it was importing the actual component under foo but now I understand how it works#2018-05-2814:03Bravithank you again 😄#2018-05-2816:09justinleeis there anyway to kick off an arbitrary shell action when running a watch? I just need to run a node-sass watch target to compile my sass. it seems like a lot of complexity to add lein in just to do that#2018-05-2816:10thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-05-2816:10thhelleroh another watch#2018-05-2816:11thhellerwell the idea for things with state is plugins. not yet documented or final. but the idea is this: https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/dummy_plugin.clj#2018-05-2816:11thhellera plugin defining a clojure map with :start and :stop functions#2018-05-2816:12thhellerwhen server starts the :start function is called. whatever that returns will be called be passed to :stop on server shutdown#2018-05-2816:12thhellerso you could start a java.lang.Process in :start and .destroy that in stop#2018-05-2816:13thhellerenabled via :plugins [demo.dummy-plugin] in shadow-cljs.edn#2018-05-2816:14thheller:depends-on can be used if you want access to some of the other shadow-cljs components#2018-05-2816:15thhelleruse https://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html#2018-05-2817:18heyarnedoes anybody have an example for a .travis.yml with shadow-cljs & karma tests?#2018-05-2818:03heyarnemanaged to set this up btw. You can find it here: https://github.com/heyarne/airsonic-ui#2018-05-2818:37heyarne@lee.justin.m you can also check out https://github.com/heyarne/airsonic-ui. I've set up parallel builds w/ sass --watch and shadow-cljs watch using npm scripts#2018-05-2915:19justinlee@U9N6R1DM4 this is a much easier way of doing it and I learned about the run-p command. thanks!#2018-05-2818:54kwladykaI have file /src/cm/theme.js
const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
  status: {
    danger: 'orange',
  },
});
How to use theme in cljs?
#2018-05-2818:55kwladykaI tried ["/cm/theme.js" :refer [theme]] but it doesn’t work#2018-05-2818:55thhellerdid you export it?#2018-05-2818:56thhellerexport { theme };#2018-05-2818:56kwladykaWhat do you mean? Export where, how?#2018-05-2818:56thhellerwhere does createMuiTheme come from?#2018-05-2818:57thhellerimport or require?#2018-05-2818:57kwladyka
import { createMuiTheme } from '@material-ui/core/styles';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
  status: {
    danger: 'orange',
  },
});
This is whole content of js file
#2018-05-2818:57kwladykait is example from material-ui page#2018-05-2818:57thhellereither export const theme = ...#2018-05-2818:57thhelleror export { theme }; somewhere#2018-05-2818:58kwladykaok so unless export it I can’t use variable from there?#2018-05-2818:58thhelleronly exported variables are visible to others#2018-05-2818:58kwladykaoh ok thx#2018-05-2818:58thhellernormal ESM behaviour#2018-05-2818:58kwladyka["/cm/theme.js" :refer [theme]] is ok to import it to cljs?#2018-05-2818:58thhelleryep#2018-05-2818:58kwladykaI am weak about JS itself, I have a long break to code directly in JS#2018-05-2818:59kwladykait works 🙂#2018-05-2819:02thhellerthe one thing that is a bit dangerous when doing JS directly is externs#2018-05-2819:02thhellersince externs inference only works for CLJS#2018-05-2819:03thhellerso release might get you into trouble#2018-05-2819:40kwladykaThere is one thing which make more in doubt if I want keep theme in js. I wrote text-decoration instead of testDecoration and error is visible only in console. Not in web browser. Because of that I will probably stay with cljs.#2018-05-2819:41thhelleryeah JS support is still pretty rough. I need to work on it a bit more but no time#2018-05-2819:42kwladykasure, just feedback#2018-05-2819:42kwladykayou are doing great job#2018-05-2821:50theeternalpulsehow do I make React exposed as a global through the config? I'm using cljss and the macros expand to js/React calls.#2018-05-2823:22theeternalpulseseems it's related to https://github.com/roman01la/cljss/issues/45#2018-05-2905:30axrsHas anyone noticed an error when releasing for :browser with cljs.spec.alpha? We've just started to see and error with the compiled modules with: - shadow-cljs 2.3.30 - clojurescript 1.10.238 - node 10.2.1
Uncaught TypeError: L.l is not a function
at dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307

TypeError: L.l is not a function
    at $n (dist/cljs/spec/alpha.cljs:91:19 <- dist/shared.js:513:307)
    at no (dist/cljs/spec/alpha.cljs:300:33 <- dist/shared.js:519:141)
    at dist/io/comp/spec/user_spec.cljc:7:0 
The line in question is: (s/def :user/first-name u/non-empty-string-conformer), which passes all node, doo and clojure tests
#2018-05-2905:38thheller@axrs try compiling with shadow-cljs release app --pseudo-names or --debug#2018-05-2905:41axrsThanks @thheller, I'll give it a shot and report back#2018-05-2905:41thhellergenerally that looks like externs trouble but might just be a spec implementation error#2018-05-2905:42thhellerI think I ran into something similar when builing a custom spec with deftype and not defrecord#2018-05-2905:42thhellerdunno what u/non-empty-string-conformer is#2018-05-2905:47axrsu/non-empty-string-conformer is just a function#2018-05-2905:48axrsdoesn't really do too much that would through it off unfortunately#2018-05-2905:48axrs
(defn- non-empty-string [s]
  (if (or (not (string? s))
          (string/blank? s))
    ::s/invalid
    (string/trim s)))

(def non-empty-string-conformer (s/conformer non-empty-string))
#2018-05-2905:56axrsThanks @thheller, that solved the problem! Was a strange one#2018-05-2905:57thhellerwhat solved the problem?#2018-05-2905:57thhellerdon't actually use the --pseudo-names output. that is just for debugging purposes.#2018-05-2905:58thhellerif the problem goes away by doing so you have externs problems#2018-05-2905:58thhellertry shadow-cljs check app#2018-05-2906:00axrsAhhh. Yeah, --pseudo-names solved the problem.#2018-05-2906:01thhelleryes but it also makes your builds huge#2018-05-2906:01axrsI'll run a check and review all of our interop.#2018-05-2906:01thhellerexterns problems are sometimes weird to debug since they can mess with your code in unexpected ways#2018-05-2906:07thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs also helps#2018-05-2906:12axrsThanks. The check shows we have a few places we can fix up. I'll see if inferring helps shortly#2018-05-2906:18axrsMaybe found another problem now after running check IllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistry#2018-05-2906:18axrs
IllegalArgumentException: No matching method found: getGlobalType for class com.google.javascript.rhino.jstype.JSTypeRegistry
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:53)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
	shadow.build.closure/register-cljs-protocol-properties (closure.clj:387)
	shadow.build.closure/register-cljs-protocol-properties (closure.clj:372)
	shadow.build.closure/check/fn--13533 (closure.clj:1078)
	shadow.build.closure/check (closure.clj:1073)
	shadow.build.closure/check (closure.clj:1071)
	shadow.build/check (build.clj:371)
#2018-05-2906:18thhellerhmm which version are you running? I fixed a while ago#2018-05-2906:19thhellermaybe your closure version is out of date?#2018-05-2906:19axrsshadow-cljs - config: ... cli version: 2.3.30 node: v10.2.1, Clojure 1.9.0, lein 2.8.1#2018-05-2906:20thhellerlein ...#2018-05-2906:20thhellerrun lein deps :tree#2018-05-2906:20thhellercheck which closure-compiler-unshaded version you get#2018-05-2906:20axrsMy problem child... lein...#2018-05-2906:20thhellershould be [com.google.javascript/closure-compiler-unshaded "v20180506"]#2018-05-2906:21axrsMy unshaded is coming from clojurescript 1.10.238#2018-05-2906:22axrsI'll add a dep and try again#2018-05-2906:22thhellertry
[org.clojure/clojurescript "1.10.238"
    :exclusions
    [com.google.javascript/closure-compiler-unshaded]]
#2018-05-2906:22thhelleror just remove clojurescript dep entirely. shadow-cljs will bring that in#2018-05-2906:27axrsYep, excluding the unshaded fixed the getGlobalType error. I've got a few warnings that may be the underlying cause (externs related). I'll let you know how I go 🙂#2018-05-2906:27axrsThanks for everything @thheller#2018-05-2906:27thhellercheck may be reporting a few false positives. it is not perfect. happy to help if you have questions#2018-05-2907:42axrs@thheller unfortunately, the issue still remains. I've fixed up all the externs within our source. The only thing left I can think of is the (s/def is doing something else funky#2018-05-2907:42thhellerdo you have any other JS running in your page?#2018-05-2907:42thhellerare you using multiple :modules?#2018-05-2907:43axrsNo to other JS (in this scenario), but yes to modules#2018-05-2907:43thhellerabsolutely no other JS in the page?#2018-05-2907:44axrsYep. Created a seperate html file and loaded just those in#2018-05-2907:44thhellertry :compiler-options {:output-wrapper true} just to be sure (in your build config)#2018-05-2907:46axrsThanks. Will try 🙂#2018-05-2907:47thhellerit can sometimes be tough to debug those issues, might need to open up the debugger and step through the code to find out exactly whats happening#2018-05-2907:48axrsYeah. It's going to be tricky to do so I think. loading all scripts into the page causes it to hang while it trys to do it's thing. I should be able to debug one script at a time hopefully#2018-05-2907:48thhellerthe problem is L.l is not a function which is closure-shortened variable. with :pseudo-names it will not be that short by rather $something$.$fooBar$#2018-05-2907:48thhellerso the changes of that conflicting with something are slim over just .l conflicting with something#2018-05-2907:49thhelleryou can try adding a externs/<your-build>.txt and adding one line with just l#2018-05-2907:49thhellerbut it would still be worth finding out where the l is coming from in the first place#2018-05-2907:51axrsYep. That all makes sense and confirms what I thought it was doing.#2018-05-2907:53thhellercurious if the .txt file fixes it or if it just becomes another character 😛#2018-05-2908:00axrsThe output wrapper actually fixed it
#2018-05-2908:00axrs!#2018-05-2908:00thhellerso then there must be some external JS in your page#2018-05-2908:00axrsI'm thinking maybe a race condition#2018-05-2908:00axrsshared.js and app.js were being loaded and evaluated at the same time#2018-05-2908:00thhelleror some JS that just forcefully sets L maybe?#2018-05-2908:00thhellerno that can't happen#2018-05-2908:00axrsohh#2018-05-2908:01thhellerJS engines are single threaded. so "at the same time" is not possible#2018-05-2908:02axrsThat's true.#2018-05-2908:02thhellermaybe something just sets window.L or so#2018-05-2908:03axrsHmm. Maybe. We do have a few npm dependencies that are being being used with Shadow. One of them could be doing something internally.#2018-05-2908:03thhellerare you using mapbox? I think they use L by default?#2018-05-2908:03thhelleror rather leaflet?#2018-05-2908:03thhellerhttps://leafletjs.com/#2018-05-2908:04thhellerin your page with the error check what L is in the console#2018-05-2908:04thhellerI assumed the .l property was the problem but maybe its just the L global#2018-05-2908:05thhellerbut :output-wrapper is fine to use as well#2018-05-2908:05thhellerjust makes the build slightly larger#2018-05-2908:05axrsYep. We leaflet is used as a sub dependency in a package, as an npm dep. So that might be the culprit.#2018-05-2908:06axrsWhich would make sense, as it's loaded after the shared modules#2018-05-2908:07axrsThanks for the help again. Such a simple thing can cause a big issue...#2018-05-2908:08thhelleryep confirmed. leaflet always creates the L global#2018-05-2908:09thhellermeh#2018-05-2908:12thhellerhttps://github.com/Leaflet/Leaflet/issues/2364#2018-05-2908:12thhellerguess thats on purpose#2018-05-2908:15axrsYeah. I think I'll be killing off leaflet. It's being a problem child#2018-05-2908:16thhellerI'm reserving L by default now so the compiler will never attempt to use it#2018-05-2908:16thhellerjust in case someone uses leaflet. not a problem for builds that don't.#2018-05-2908:17axrsThanks. It feels wrong to do so, but will help others out in the future no doubt#2018-05-2908:18thhellerI might just default :output-wrapper to true as well. its not currently default when using multiple modules because the build gets slightly larger#2018-05-2908:19thhellerbut would be the safer default#2018-05-2908:19axrsCool. It might be worth adding it to the docs as well. It's not listed as a supported option, but is mentioned above somewhere.#2018-05-2909:14tianshu@thheller now shadow-cljs + lein + cider works great!#2018-05-2909:32thheller@doglooksgood cool#2018-05-2910:16nijkDoes anyone know if it’s possible to use the suppress annotations provided by closure compiler? Or if not, any kind of workaround that would allow something like the exclusion of particular files from throwing warnings? https://github.com/google/closure-compiler/wiki/@suppress-annotations#2018-05-2910:21thheller@nick828 which warnings do you get?#2018-05-2910:21nijkUse of undeclared Var#2018-05-2910:22thhellerhow it that related to an annotation?#2018-05-2910:23nijkWell my understanding is that it will allow me to do this: > If you cannot easily fix a JsCompiler warning, you can suppress it using the @suppress annotation in the function’s JSDoc block#2018-05-2910:24nijkI would prefer to fix the warning, but at this stage I’m looking at my options#2018-05-2910:25thhellerwhat kind of code are we looking at?#2018-05-2910:25thhellerand what is the full warning? the annotations really only suppress warnings for the function you annotate and that should never be necessary in CLJS#2018-05-2910:27nijkIt’s cljs and I’m implementing code-splitting - the warning is triggered by the fact that I need to refer to a function in another namespace that has not been required. If I were to require it in then I believe that the bundles would not be correct. Perhaps this would be better dealt with some other way (by using a macro?)#2018-05-2910:28thhellerso the "official" solution is to use resolve#2018-05-2910:28nijkoooo, ok - please do tell me more#2018-05-2910:28thhellerso (let [something (resolve 'some.ns/foo)] (something))#2018-05-2910:28nijkok#2018-05-2910:28thhellerthat way your code can call a function that it has no require for#2018-05-2910:29nijksounds great, thanks @thheller#2018-05-2910:33thhellernote that you can only actually call the resolved var after the code has been loaded. otherwise it'll just error out#2018-05-2910:36nijkTimely message! I’ve just noticed that 🙂#2018-05-2910:43nijk@thheller Thanks for your help there, it’s now working beautifully 🙂 I’m not sure if I’ve struggled with this because I’m new to Clojure & ClojureScript but I wonder if a slightly fuller example of a code-splitting implementation might be helpful to others? I’ve been following this: https://shadow-cljs.github.io/docs/UsersGuide.html#_loading_code_dynamically#2018-05-2911:24thheller@nick828 unfortunately pretty much all uses for code-splitting and dynamic loading rely pretty heavily on the framework you are using and how your code it structured#2018-05-2911:24thhellercoming up with a general purpose example is pretty tough#2018-05-2911:25thheller
;; foo.bar is part of module :foo
(def some-var (resolve 'foo.bar/x))

(-> (loader/load "foo")
    (.then (fn []
             ;; foo.bar is now loaded
             (some-var))))
#2018-05-2911:27thhellerso basically whenever you want to call some-var you probably need to wrap it in a load call to ensure it is loaded#2018-05-2911:28thhelleryou call check (loader/loaded? "foo") as well#2018-05-2911:29thhellerusing multi-methods also helps#2018-05-2911:32thhellertypically you'd trigger the load in the router or on click#2018-05-2911:43thhellerare there any reagent/re-frame examples out there that use routing?#2018-05-2912:04nijk@thheller fair point, I guess the resolve call was all I needed to understand in the context of loading modules dynamically. Good point on checking that the module is loaded, I had noticed that from the docs. For what it’s worth I’m using Kee-frame for routing although there are many ways to handle the routing, that said I wasn’t suggesting that the docs had anything more than a very basic example of using resolve - agnostic of any routing…#2018-05-2912:06thhelleris there a kee-frame template or so?#2018-05-2912:06nijkA Kee-frame template that gives an example of how code-split modules could be loaded?#2018-05-2912:07thhelleronly the routing part#2018-05-2912:13nijkI’m not sure I quite understand what you’ve got in mind, there is a demo project linked to from Kee-frame’s readme: https://github.com/ingesolvoll/kee-frame-sample, the routers.cljs for the demo project is here: https://github.com/ingesolvoll/kee-frame-sample/blob/master/src/cljs/kee_frame_sample/routers.cljs#2018-05-2912:17thhellernot a clue what that is about. why 3 different routers?#2018-05-2912:17thhellerlooks like it already pretty heavily abstracts all the routing logic though. might make it harder to adapt it to be aware of splits#2018-05-2913:32nijkThe commit message might be helpful to explain that: > Changed API to support different routing libs. Example implementation…#2018-05-2913:34nijkDo you just want a boilerplate for handling routes in Kee-frame so that you can give an example implementation of code-splitting in your docs?#2018-05-2913:35thhellernot the docs but this example could be made more useful. https://github.com/shadow-cljs/examples/tree/master/code-split#2018-05-2913:35thhellerI can probably do a framework-less generic example#2018-05-2913:37nijkAh right! I’m with you now - yeah I’d recommend steering clear of a framework for this, I wonder if a very basic bidi implementation would be enough - you might need more of your own boilerplate to make it work though#2018-05-2913:39nijkto be clear, I’m not saying that this is absolutely necessary in order to understand how to implement code-splitting using Shadow-cljs - just that the current documentation could be a bit clearer about good practices on resolving namespaces that may not have been loaded at the point where the code is first executed#2018-05-2913:40thhelleryeah. it is tricky to do this correctly so the docs should definitely clarify this a lot more#2018-05-2913:41nijkI’d love to see an example of how you have done this correctly 🙂 that would be super useful to me#2018-05-2913:41thhellerthere could also be a little more support by a macro or two#2018-05-2913:42thhellercurrently you have to know which module a namespace is in which is a bit annoying#2018-05-2913:42nijkYes, that’s where I think my current implementation is not so great#2018-05-2913:43nijkAre you familiar with ReactBoilerplate?#2018-05-2913:43thhellerlooked at it yes, used it no#2018-05-2913:44nijkit might be worth having a look at the way it handles code splitting - I haven’t used it for 6months+ but from memory it was pretty straight-forward to implement#2018-05-2913:45nijkIt’ll obviously be rather different from how things are handled in the cljs world but I think a lot of the underlying patterns are quite similar#2018-05-2913:49thhellermain problem for me is that I don't use reagent. so I have no idea how you'd write it in reagent#2018-05-2913:50nijkOk, I might be able to convince my people to allow me spin off a generic repo to provide an example in Reagent/Reframe#2018-05-2913:54thheller
(defn async-component [the-module the-var]
  (let [loading-ref (r/atom false)]
    (-> (fn []
          (if loading-ref
            [:div "Loading ..."]
            (the-var)))
        (with-meta
          {:component-did-mount
           (fn [this]
             (-> (loader/load the-module)
                 (.then #(reset! loading-ref true))))}))))
#2018-05-2913:55thheller(async-component "foo" (resolve 'some.foo/var))#2018-05-2913:55thhellerassuming (ns some.foo) (defn var [] [:div "hello world"])#2018-05-2913:56thhellernot exactly sure how you are supposed to do lifecycles in reagent#2018-05-2913:57thhellerhttps://github.com/ingesolvoll/kee-frame-sample/blob/master/src/cljs/kee_frame_sample/core.cljs#L21-L25#2018-05-2913:57thhellerso instead of [live/live] you do the async-component call#2018-05-2913:57nijkah, yeah that is a bit of a pain. These docs are quite good: https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-3-a-class-with-life-cycle-methods#2018-05-2913:58nijkThis is similar to my first attempt at it, I’ve now moved to a reframe approach using event handlers (coeffects/effects/interceptors) for loading the module at the right time in the application#2018-05-2913:59thhellerbasically you want a stateful component that re-renders when the code is loaded#2018-05-2913:59thhelleralternative when using something like re-frame that has an event handler like :set-current-page or so#2018-05-2913:59thhellerinstead of directly setting the page you figure out which module to load#2018-05-2913:59thhellerand then do the actual :set-current-page in a callback#2018-05-2914:00nijkNot sure if you saw my message above: > I’ve now moved to a reframe approach using event handlers (coeffects/effects/interceptors) for loading the module at the right time in the application#2018-05-2914:00nijkFrom the reading I’ve done on approaching problems with a React vs Reframe mindset, I’ve decided to move away from the stateful component pattern#2018-05-2914:01thhellerdoesn't matter which approach you use. somewhere you need some state that gets updated when the code is loaded and triggers a re-render#2018-05-2914:01thhellerdoes not matter *where* the state is#2018-05-2914:01nijkAgreed, the pattern you are suggesting is what needs to happen#2018-05-2914:01nijkThe ‘how’ is a little less important#2018-05-2915:30justinlee@thheller is this the bhauman library for checking maps you were talking about the other day? https://github.com/bhauman/spell-spec it looks amazing#2018-05-2915:32thhellerfigwheel had something similar. looks like he extracted it into a proper lib. nice.#2018-05-2915:33thhellerbut yeah I was talking about those kinds of error messages. figwheel has some really good error messages.#2018-05-2918:29theeternalpulseis cljss an offshoot of the shadow.css stuff in the wiki#2018-05-2918:30theeternalpulseI noticed that it has similar macro names#2018-05-2918:32thhellerno. I think we more or less both took styled-components from the react work as inspiration#2018-05-2918:33thhellerthe implementations are entirely different#2018-05-2923:33wilkerlucio@thheller do you we could update the manifest.json automatically after changing the manifest.edn?#2018-05-3005:15tianshuhow can I tell shadow-cljs don't log debug level?#2018-05-3005:19tianshuhttps://github.com/thheller/shadow-cljs/blob/a5b266efd8c042d3438ec2ba7c32cb4c17d73edb/src/main/shadow/cljs/devtools/server/nrepl.clj#L344 I don't want this log, it will be showed in the REPL, a little annoying.#2018-05-3006:05thheller@doglooksgood debug log should not be enabled by default? when using embedded lein however you are in charge of configuring your logging#2018-05-3006:06thheller@wilkerlucio yeah I was going to add that#2018-05-3011:18heyarneis there a recommended strategy to have multiple watched builds at the same time? for example i have a test build (`:karma`) and a :browser build and I'd like them both to run continuously in the background#2018-05-3011:19heyarneat the moment i just have two separate processes and maybe that's the way to go, i was just wondering whether there's a better way#2018-05-3011:22thhellershadow-cljs watch karma browser#2018-05-3011:22heyarneoh. maybe i should have just tried that haha#2018-05-3011:29troglotitI have the same thought like multiple times a day 😄#2018-05-3014:44jmckitrickHas anyone here built a shadow app as a docker image with drone?#2018-05-3014:47dominicmHow does shadow pick up transitive npm deps? Or perhaps rather, does it?#2018-05-3014:47dominicmIf I depend on libraryA which depends on npm dependency X, how should that be communicated?#2018-05-3015:00heyarne@dominicm shouldn't dependency x be installed when you install npm install -S libraryA? I mean the whole npm ecosystem is managed by npm and shadow-cljs provides a bridge to it#2018-05-3015:01heyarneis there a way to update dependencies in a running watch? via the clojure api?#2018-05-3015:24dominicm@arne-clojurians I have a clojurescript libraryA, which depends on npm X#2018-05-3015:28dominicmI figured it out, deps.cljs supports :npm-deps key.#2018-05-3017:09jjttjj#2018-05-3021:47mhueberthmm, when I put :asset-path to "/", it tries to load scripts from #2018-05-3021:48mhuebert(i’m trying to compile a service worker which needs to be at the root of the site)#2018-05-3021:48mhuebert& empty string throws a config error#2018-05-3106:20thheller@mhuebert try :web-worker true for the module but I think service workers should probably be their own build.#2018-05-3112:10bupkiscan the cljs-repl of shadow-cljs keep history, similar to the way lein does? (e.g. .lein-repl-history)#2018-05-3112:42mhuebert@thheller sounds good. I was following the example and thought maybe there was a reason to keep it all in the same build, but separating it out makes it easy to change the output-dir without affecting the main build, which is better anyway.#2018-05-3113:50thheller@mhuebert yeah I'm unsure about service workers. they are sort of standalone so making them part of a build is not ideal. including an extra cljs.core however makes it extra large which is also not ideal. just sticking with something like workbox.js might be an option though#2018-05-3113:51mhuebertyeah, i was thinking of avoiding cljs altogether but didn’t find a library I liked yet, workbox.js looks good, thanks for the tip#2018-05-3113:51thheller@samuel.wagen I have not done any work on that yet#2018-05-3114:12bupkisno worries, was just wondering.#2018-05-3114:15thhelleropen a ticket otherwise I'll just forget again. I only use the REPL from cursive and that keeps track of history and stuff#2018-05-3115:18jmckitrickIs there a way to inject different env settings into a system based on dev vs release?#2018-05-3115:18jmckitrickTo clarify, I mean settings that I can use within my code, not just for the build itself?#2018-05-3115:19jmckitrickActually, I could have different source paths for each env, and pull in an ‘env’ namespace for each. Like Luminus sets up….#2018-05-3115:24jmckitrickOr is there a better way?#2018-05-3115:46mhuebert@jmckitrick you might use: https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2018-05-3115:49jmckitrickYou’re right! I read over that too quickly. Thanks!#2018-05-3115:50jmckitrickI thought they were just for the compiler settings.#2018-05-3116:16justinleefor people who use cursive and shadow, is there a way to automate the process of “select cljs repl and then issue the nrepl-select command”?#2018-05-3116:17thhellerdo you mean the clj/cljs select box? that should switch automatically when you nrepl-select?#2018-05-3116:39justinleei’m being super lazy. i just want to avoid opening up the file that contains the nrepl-select magic and pasting into the repl#2018-05-3116:40thhellerI don't follow. what nrepl-select magic?#2018-05-3116:40thhelleryou mean the actual command?#2018-05-3116:41justinleeyea, in order to get to my app’s repl (which is the only repl I ever use) I cut-n-paste
(require '[shadow.cljs.devtools.api :as shadow])
(shadow/nrepl-select :app)
every time
#2018-05-3116:41thhellerjust call (shadow.cljs.devtools.api/nrepl-select :app) directly#2018-05-3116:41thhellerOR make a REPL command#2018-05-3116:41thhellersetup a keybinding for it#2018-05-3116:42justinleewait how do you make a repl command? i think that’s what I want. i’m trying to search for it but failing#2018-05-3116:43justinleeoh sorry i’m an idiot. nevermind#2018-05-3116:43justinleeoh i was overthinking this problem 🙂#2018-05-3116:44thhellerits a bit weird but the menu only shows up when actually connected to a REPL#2018-05-3116:44thhellerbut then tools -> REPL -> add new command#2018-05-3117:01thhelleroh doh I just noticed. I didn't document a new thing 😛#2018-05-3117:02thhellerthe REPL should now actually start out in shadow.user not user anymore#2018-05-3117:02thhellerso (shadow/nrepl-select :app) should work by default#2018-05-3117:02thhellerno need require anymore#2018-05-3117:03thhellerand you can set :repl {:init-ns something.foo} to make yours the default#2018-05-3117:20thheller@wilkerlucio https://github.com/thheller/shadow-cljs/issues/279#issuecomment-393607869 regarding the config reload you asked about#2018-05-3117:22thheller> You may also now put the :shadow/outputs config into the build config instead under the :outputs key since we don't need to namespace here.#2018-05-3117:22thhellerjust edited that in 😉#2018-05-3117:23wilkerluciovery nice 🙂#2018-05-3119:20thheller
------ ERROR -------------------------------------------------------------------
 File: C:\Users\thheller\code\shadow-cljs\src\dev\demo\es6.js:15:16
--------------------------------------------------------------------------------
  12 |   console.log("await value", value);
  13 | }
  14 | 
  15 | var obj = {hello-World: 1};
----------------------^---------------------------------------------------------
'}' expected
--------------------------------------------------------------------------------
  16 | 
  17 | export { foo, someAsyncFn };
  18 | export default "defaultExport";
--------------------------------------------------------------------------------
#2018-05-3119:21thhellerthose that use the .js support will soon get proper errors for those#2018-05-3119:21thhellerthe errors closure produces are weird .. but still better than before#2018-05-3119:48lilactownhey thheller, do you have any advice on how to go about scaffolding projects that are meant to be consumed as libraries?#2018-05-3119:49thhellerI guess follow https://github.com/thheller/shadow/blob/master/project.clj#2018-05-3119:49lilactownI'm kind of struggling with deciding if I should put everything in project.clj and use lein integration, or if I should use shadow-cljs.edn and just put runtime deps in project.clj... plus there's also npm deps...#2018-05-3119:50thhelleryeah. unfortunately adding shadow-cljs deploy involves a lot of work so thats still ways off#2018-05-3119:51thhellerI think duplicate config is fine for now ... you don't update deps that often#2018-05-3119:51thhellernpm deps you can put in deps.cljs#2018-05-3119:52thhellerso in the setup above src/main/deps.cljs {:npm-deps {"react" "^16.3.0"}}#2018-05-3119:53lilactownhuh. is that a convention outside of shadow-cljs?#2018-05-3119:54thhellerwell only shadow-cljs actively uses npm so its not well supported anywhere else#2018-05-3119:54thhellerbut deps.cljs is officially supported by CLJS, I did not "invent" that#2018-05-3119:55thhellerat this point it is probably still safer for libs to use cljsjs#2018-05-3119:56kurt-o-sysI'm having the react-flatpickr component and I'm trying to do this: https://flatpickr.js.org/plugins/#weekselect Everything else seems to work, but adding a plugin seems to fail... Here's some relevant code:
(ns ...
  (:require ...
            ["react-flatpickr" :default Flatpickr]
            ["flatpickr/dist/l10n/nl.js" :refer [Dutch]]
            ["flatpickr/dist/plugins/weekSelect/weekSelect" :default weekSelectPlugin]))


(defn week-picker [...]
  [...
    [:> Flatpickr {:options (clj->js {:locale      Dutch
                                      :defaultDate (coerce/to-date selected-calendar-date)
                                      :plugins     [(weekSelectPlugin. {})]
                                      :weekNumbers true})
                   :onChange    (fn [selected-dates _ _ ] (js/console.log "--" selected-dates))}]
  ...
I'm getting this error: Uncaught TypeError: module$node_modules$flatpickr$dist$plugins$weekSelect$weekSelect.default is not a constructor
#2018-05-3119:56kurt-o-sysI have the feeling I'm missing something... but I fail to see what 🙂. All other imports seem to work fine, but this plugin-thing doesn't work#2018-05-3119:57thheller@kurt-o-sys unfortunately some packages include ES6 example but actually ship CommonJS#2018-05-3119:58kurt-o-sysok... which means they can't be imported?#2018-05-3119:58thhellertry this in the REPL (require '["flatpickr/dist/plugins/weekSelect/weekSelect" :as x]) then (js/console.log x)#2018-05-3119:58thhellerif that exported object has a .default property the :default will work#2018-05-3119:58thhellerotherwise it might just be :as ... instead of :default#2018-05-3119:59kurt-o-sysok, let me check 🙂#2018-05-3119:59thhellerthey can be used fine but compatibility is weird#2018-05-3119:59kurt-o-sysok, thx#2018-05-3120:00thhellerotherwise you are calling (weekSelectPlugin. {}) maybe you are supposed to call (weekSelectPlugin {})?#2018-05-3120:01thhellernew Thing() vs Thing();#2018-05-3120:01kurt-o-sysyeah, well... I'm trying to fin dout 🙂#2018-05-3120:01thhellerah new is correct ... nvm#2018-05-3120:02kurt-o-syswell, the js/console.log gives me:
ƒ (){return function(a){function b(b){var c=b.target;if(c.classList.contains("flatpickr-day")){b=a.days.childNodes;var d=c.$i/7;c=b[7*Math.floor(d)].dateObj;d=b[7*Math.ceil(d+.01)-1].dateObj;for(var h=…
#2018-05-3120:03thhellerok its just a function. then use :as weekSelectPlugin and that should work#2018-05-3120:03thheller(weekSelectPlugin. #js {}) though as it won't understand CLJS maps#2018-05-3120:04thheller
[1:1]~cljs.user=> (require '["flatpickr/dist/plugins/weekSelect/weekSelect" :as x])
nil
[1:1]~cljs.user=> (x. #js {})
#object[Function]
#2018-05-3120:04kurt-o-sysright. nice.#2018-05-3120:04thhellerseems to work#2018-05-3120:10kurt-o-sysniiice! thx a lot!#2018-05-3120:44kurt-o-sysanother question @thheller: I'm having a https://github.com/Day8/re-frame app and when I start it using shadow-cljs watch app, hot reload doesn't seem to work as expected. I have a page with a menu, let's say page1 and page2. When I'm on page1, the content of page1 is shown, obviously. However, when I update that page (the content of page1), it is not updated in the browser. When I click in the menu page2 and page1 again, the update is there...#2018-05-3120:44kurt-o-systhis is the config:
{:lein     true
 :jvm-opts ["--add-modules" "java.xml.bind"]
 :nrepl    {:port 3333}
 :builds   {:app {:target           :browser
                  :output-dir       "resources/public/js"
                  :asset-path       "/js"
                  :modules          {:main {:entries [ui-app.core]}}
                  :compiler-options {:closure-warnings {:global-this :off}
                                     :closure-defines  {"re_frame.trace.trace_enabled_QMARK_"        true
                                                        "day8.re_frame.tracing.trace_enabled_QMARK_" true}}
                  :devtools         {:http-root "resources/public"
                                     :http-port 3449
                                     :preloads  [shadow.cljs.devtools.client.hud
                                                 devtools.preload
                                                 day8.re-frame-10x.preload]}}}}
#2018-05-3120:51thheller@kurt-o-sys there is no :after-load callback. do you have one configured in the code? using ^:dev/after-load somewhere in the code?#2018-05-3120:52thhellerthe update is not there since you need to trigger a re-render after the code was loaded somehow#2018-05-3120:52thhellerdid you follow a template or so?#2018-05-3120:53kurt-o-sysyeah, I had a template from somewhere... and no, I have no ^:dev/after-load anywhere 🙂. I'm still new to shadow-cljs 🙂#2018-05-3120:54thhellerwell if you used figwheel before you'd have a :on-jsload callback in the config#2018-05-3120:54kurt-o-sysright...#2018-05-3120:56kurt-o-sysget it 🙂#2018-05-3120:57thhellerif you have a (defn render [] ...) in your ui-app.core just add (defn ^:dev/after-load render [] ..)#2018-05-3120:58thhelleror add :devtools {:after-load ui-app.core/render ...} to your config. same result.#2018-05-3120:58kurt-o-sysok, makes sense! will do.#2018-05-3121:02kurt-o-syswell, I pass config to that render (which comes from the index.html), but that shouldn't be an issue, should it?#2018-05-3121:03thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2018-05-3121:03thhellerI always recommend this setup#2018-05-3121:04thhelleryou call init from the HTML. if you pass config into that method you add a (defonce config-ref (atom nil)) and then (reset! config-ref the-config) in init#2018-05-3121:04thhellerstart then just derefs the config-ref#2018-05-3121:04thhellerand proceeds as usual#2018-05-3121:32kurt-o-sysnot using atom now, but I already kept it in the re-frame app state (db). I'm just reading it from there. Thx a lot! Love shadow-cljs more and more.#2018-05-3121:54tony.kayanyone using shadow-cljs with react 16? I’m getting React not defined errors on release builds#2018-06-0108:27mitchelkuijpersThat is weird, it works for us. Maybe you could try deleting the .shadow-cljs folder and then do a clean npm install#2018-06-0112:57tony.kayYeah, I've tried all of that. A vanilla Fulcro template with React 16 is fine. Something weird is hosed.#2018-06-0112:58tony.kayA git clean -xfd wipe doesn't help#2018-06-0113:00mitchelkuijpersHave you double checked package.json so that it contains:
"react": "16.3.2",
    "react-dom": "16.3.2",
#2018-06-0113:00mitchelkuijpersI know I am asking dumb questions but I a am trying to get to the root cause#2018-06-0113:00tony.kayyep#2018-06-0113:00mitchelkuijpersYou could also check package-lock.json which should get generated#2018-06-0113:01mitchelkuijpersDo you have:
(ns cljsjs.react
  (:require ["react" :as react]))

(js/goog.exportSymbol "React" react)
Not sure if that is still necessary with the newest shadow-cljs
#2018-06-0113:01tony.kayI even tried manually coding in a set of global React at the entry point#2018-06-0113:02tony.kayI didn't try it via an export...I'll try that. Why would Fulcro template work without that (and this one as well for months), and suddenly need it?#2018-06-0113:03tony.kayif it were a new project, I'd suspect those kinds of things. With this one I suspect that some dependency loop or something in npm deps is confusing things.#2018-06-0113:04tony.kaybut I tried backing out the one I know was added recently and that didn't seem to help. The upgrade to React 16 was the other one...and it is wanting core-js at 1.x and something else wants 2.x, so not sure if that could hose things.#2018-06-0113:04tony.kaysuch a long list of deps it is mind boggling#2018-06-0113:20mitchelkuijpersOh dear, which version of shadow are you using though? And are they the same in package.json and project.clj?#2018-06-0113:20mitchelkuijpersOh you found it#2018-06-0113:20mitchelkuijpersNIc#2018-06-0113:20mitchelkuijperse#2018-06-0113:24tony.kayYeah, Fulcro issue#2018-06-0113:24tony.kaythanks for the help 🙂#2018-05-3122:10kwladyka
(ns cm.core
  (:require [reagent.core :as reagent]
            [re-frame.core :as re-frame]
            [cm.events :as events]
            [cm.views :as views]
            [cm.config :as config]
            [bidi.bidi :as bidi]
            [goog.events :as goog-events]
            [goog.history.EventType :as EventType]

            [taoensso.timbre :as l])
  (:import goog.History))

(def route ["/" {"log-in" :log-in
                 "log-out" :log-out
                 "sign-up" :sign-up}])

(defmulti handler #(:handler %))

(defmethod handler :default [request]
  (l/info "page" request)
  (re-frame/dispatch [:handler (:handler request)]))

(defn hook-browser-navigation! []
  (doto (History.)
    (goog-events/listen
      EventType/NAVIGATE
      (fn [event]
        (->> (.-token event)
             (bidi/match-route route)
             (handler))))
    (.setEnabled true)))

(defn dev-setup []
  (when config/debug?
    (enable-console-print!)
    (println "dev mode")))

(defn ^:dev/after-load mount-root []
  (re-frame/clear-subscription-cache!)
  (reagent/render [views/page]
                  (.getElementById js/document "app"))
  (hook-browser-navigation!)) ;; <<<<<<<< this line

(defn ^:export init []
  (re-frame/dispatch-sync [::events/initialize-db])
  (dev-setup)
  (mount-root))
After reload page in web browser without any change of code (like add enter on the end of file) I get this HTML in page:
<html><head></head><body><input type="text" name="history_state1" id="history_state1" style="display:none"></body></html>
So I end with this error:
env.cljs:168 error when calling lifecycle function cm.core/mount-root Error: Target container is not a DOM element.
    at h.exports (invariant.js:43)
    at sa (react-dom.development.js:17117)
    at Object.render (react-dom.development.js:17196)
    at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:20)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs:44)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs:39)
    at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs:74)
    at cm$core$mount_root (core.cljs:51)
    at shadow.cljs.devtools.client.env.make_task_fn (env.cljs:165)
    at shadow$cljs$devtools$client$env$do_js_reload_STAR_ (env.cljs:173)
Why? How to fix it? What I want to achieve: URL navigation like url#/log-in. That is why I added (hook-browser-navigation!) but in some magic way it has conflict with shadow-cljs during development.
#2018-06-0102:48wilkerlucioI'm trying to port a big app to use shadow, I'm trying to start by using the lein profile, but when I try to compile I'm getting:#2018-06-0102:48wilkerlucio
Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/externs__init.class or cljs/externs.clj on classpath., compiling:(shadow/build/cljs_bridge.clj:1:1)
	at clojure.lang.Compiler.load(Compiler.java:7526)
	at clojure.lang.RT.loadResourceScript(RT.java:379)
	at clojure.lang.RT.loadResourceScript(RT.java:370)
	at clojure.lang.RT.load(RT.java:460)
	at clojure.lang.RT.load(RT.java:426)
	at clojure.core$load$fn__6548.invoke(core.clj:6046)
	at clojure.core$load.invokeStatic(core.clj:6045)
	at clojure.core$load.doInvoke(core.clj:6029)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5848)
	at clojure.core$load_one.invoke(core.clj:5843)
	at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
	at clojure.core$load_lib.invokeStatic(core.clj:5887)
	at clojure.core$load_lib.doInvoke(core.clj:5868)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$load_libs.invokeStatic(core.clj:5925)
	at clojure.core$load_libs.doInvoke(core.clj:5909)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:659)
	at clojure.core$require.invokeStatic(core.clj:5947)
	at clojure.core$require.doInvoke(core.clj:5947)
	at clojure.lang.RestFn.invoke(RestFn.java:2793)
	at shadow.build.classpath$eval17191$loading__6434__auto____17192.invoke(classpath.clj:1)
	at shadow.build.classpath$eval17191.invokeStatic(classpath.clj:1)
	at shadow.build.classpath$eval17191.invoke(classpath.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
#2018-06-0102:48wilkerlucioany idea what that can be?#2018-06-0102:56wilkerlucioI tried moving the deps and source-paths directly to shadow-cljs.edn, it works there, so it's something around lein integration#2018-06-0106:11thheller@wilkerlucio probably a dependency pulling in an old CLJS version. when using shadow-cljs it adds :exclusions [org.clojure/clojurescript] automatically for every dep to avoid that#2018-06-0106:15thheller@kwladyka this is a problem due to loading goog.History. It uses document.write to insert an iframe dynamically.
(defn do-route [token]
  (->> token
       (bidi/match-route route)
       (handler)))

(defn hook-browser-navigation! []
  (doto (History.)
    (goog-events/listen
      EventType/NAVIGATE
      (fn [event]
        (do-route (.-token event))))
    (.setEnabled true)))

(defn dev-setup []
  (when config/debug?
    (println "dev mode")))

(defn ^:dev/after-load mount-root []
  (re-frame/clear-subscription-cache!)
  (reagent/render [views/page]
    (.getElementById js/document "app")))

(defn ^:export init []
  (re-frame/dispatch-sync [::events/initialize-db])
  (dev-setup)
  (mount-root)
  (hook-browser-navigation!))
#2018-06-0106:15thhellerthis should work. basically you must avoid constructing a History object twice. so the above calls it in init once and not in start which is called for each live-reload.#2018-06-0106:17thhellermaybe makes sense to call it before mount-root. not sure what makes most sense.#2018-06-0106:20thheller@tony.kay I use react v16. a React global only exists when you use cljsjs.react since by default there will be no React global exported?#2018-06-0106:20thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#L4 this creates the global#2018-06-0106:21thhellerif you just (:require ["react" :as x]) that won't create a global?#2018-06-0106:23thhellerbut that should be a problem during dev then too?#2018-06-0106:37thhellermaybe you "accidentally" get React during dev due to some preload?#2018-06-0107:39kwladyka@thheller ah thank you. I don’t know how I was checking it yesterday. Maybe because it was after midnight 🙂#2018-06-0107:40kwladykaWhat is your personal opinion about using such solution to let users copy & past URLs? Do you know something better? What do you use?#2018-06-0107:41thhellerwhat do you mean? using urls to route application state? that is pretty much considered best practice and good.#2018-06-0107:44thhelleralthough I probably recommend using goog.history.Html5History instead since that uses normal paths instead of append #/...#2018-06-0107:44kwladykayes, like url#/foo/bar#2018-06-0107:44thhellerbut that requires server support so might not work always#2018-06-0107:44kwladykaexactly, that is something what I am asking about#2018-06-0107:44kwladykaI don’t have experience with it#2018-06-0107:45kwladykaoh, thank your for that. I have to read about it.#2018-06-0107:45kwladykaOh I guess you talk about support for path to load right file#2018-06-0107:46thhellerthe idea is the same, use the url to construct the initial state of your application. either the url can be /foo/bar or url#/foo/bar. the first requires server support while the second doesn't. but beyond that they pretty much work the same#2018-06-0107:46thhelleryeah the server must be aware of all the urls you may be constructing client side. with url# it just needs one#2018-06-0107:48kwladykaThat is interesting web browser doesn’t reload page. I have to read about it 🙂#2018-06-0107:49kwladykaWill it work with shadow-cljs? When I will have localhost:8020/foo/bar/baz and click refresh?#2018-06-0107:49thhelleryes#2018-06-0107:49kwladykagreat 🙂#2018-06-0107:49kwladyka❤️#2018-06-0107:50thhellerthat is commonly known as pushState routing. the shadow-cljs server will serve the index.html by default for all urls that don't exist otherwise#2018-06-0107:50kwladykamake sense#2018-06-0108:45kurt-o-sysif one wants to add spec instrumentation during dev: that's done with build-hooks, right?#2018-06-0108:49kurt-o-sysoh, hooks are clojure functions? - need plain cljs functions to instrument only during dev. Will check docs again 😛#2018-06-0110:14mitchelkuijpers@kurt-o-sys We had a lot of trouble adding spec-instrumentation, if you get it working correctly we would be interested in how you did that#2018-06-0112:55tony.kay@thheller Well, it is a fulcro project, and Fulcro works fine with React 16. In fact, this project has worked in release mode before, it just started breaking. I tried backing out to an older versino of the compiler, but that does not fix it. I suspect perhaps some new dependency was added that perhaps confused things. If I compile in dev mode it is fine. If I do release with any level of optimization it breaks, but differently based on which optimization level I choose. At whitespace it crashes on a line that is trying to set goog.debug.Error= something (debug isn't defined). At simple and above it is React.#2018-06-0112:56tony.kaythe preloads is a good lead. I'll try removing them and see if that breaks dev mode#2018-06-0113:13tony.kay@thheller You are right: removing the preloads breaks it…so it must be that react isn’t being pulled in correctly#2018-06-0113:17tony.kayAh, I think it was Fulcro…I was missing a require of cljsjs.react in one of the files, which confuses the dep order. Trying a fix#2018-06-0113:23tony.kayyeah, that was it#2018-06-0114:27kurt-o-sys@mitchelkuijpers I'm not 100% sure if it works as it should. I get too many validation errors, unless it's justified I get them 🙂 - still analyzing that part. However, this is what I did:
(ns ui-app.core
  (:require-macros [secretary.core :refer [defroute]])
  (:import goog.History)
  (:require ...
            [orchestra-cljs.spec.test :as st]
            ...))
 
...

(defn ^:dev/after-load start
  []
  (println "starting...")
  (let [...
        dev        ...
        ...]
    (when dev
      (println "instrumenting...")
      (st/instrument))
    ...))

...
#2018-06-0114:28kurt-o-sysin another namespace:
(ns ...
  (:require ...
            [orchestra.core :refer-macros [defn-spec]]
            ...))
 
(defn-spec some-fun #(repeatedly true)
  [arg (s/cat :arg #(repeatedly true))]
  ...)
#2018-06-0114:28kurt-o-sys(the repeatedly true works fine :)#2018-06-0114:29mitchelkuijpersI thinks our problem was that it would only instrument directly required namespaces#2018-06-0114:31kurt-o-sysit seems to instrument this, but changing #(repeatedly true) to anything else seems to make the specs fail for now#2018-06-0114:42kurt-o-syswell, it's working... just had wrong specs 🙂#2018-06-0118:45lilactownso I have a super bizarre problem / use-case that I'm wondering if anyone has ideas for#2018-06-0118:46lilactownI'm currently server-rendering my pages using reagent on Node.js, as well as building client-side code with the same codebase - all via shadow-cljs#2018-06-0118:46lilactownwhat I'd like to do is use module-splitting to split up some of the heavier parts of my client-side bundle, and conditionally load them if a certain component is server-rendered#2018-06-0118:47lilactowne.g. I have a feature-container component that is conditionally rendered by the server, and when rendered it could put some code on the page that would dynamically load the feature client-side module#2018-06-0118:48lilactownis this at all feasible? 😅#2018-06-0118:49lilactownright now I basically have the client-side entry point look for a specific ID and if so, render that part of the page - so I could make that load the module.#2018-06-0118:50lilactownbut I'd like to move that behavior into the component itself instead of having to modify the entry point every time I add a new feature#2018-06-0119:15thheller@lilactown in my setup I just collect which modules should be loaded and then emit that info into the HTML#2018-06-0119:16thhellermanifest.edn can help automate the config part#2018-06-0119:17thhellerI have helpers in my server code that emit stuff like (cljs 'some.app.entry 1 2 3) which basically calls (some.app/entry 1 2 3) and figures out which module some.app is in so ensures that the module is loaded first#2018-06-0119:18thhellerbut that stuff is currently only used in an internal CMS admin app so can't share that part
#2018-06-0119:18thhellerdidnt' extract the code for that (yet)#2018-06-0119:20lilactownnice. so if I'm understanding, (cljs 'some.app.entry 1 2 3) gets translated to some JS that gets put on the page that will call (some.app/entry 1 2 3)?#2018-06-0119:20thhellerhttps://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html#2018-06-0119:21thhellerthis method basically#2018-06-0119:21thhellerso it emits the script tag and then later decides which modules to load#2018-06-0119:21thhellerwhen the modules load they look for the special script tags and call them#2018-06-0119:23lilactownnice!#2018-06-0119:24lilactownI think I can use that exact strategy with shadow.loader/load to do what I want 😄 yeah?#2018-06-0119:25thhelleryep that works. I just track is on the server and directly emit <script> tags for the required modules#2018-06-0119:25thhellerand also emit a <link rel="preload" ...> to make it even faster#2018-06-0119:25thhellerbut shadow.loader totally works too#2018-06-0119:26lilactown🤔 would shadow.loader be a lot slower?#2018-06-0119:26thhellera bit yes#2018-06-0119:26thhellerwith preloads the code will be available ASAP#2018-06-0119:26lilactownI'm just not sure how I would determine which file to load. I guess that's what the manifest.edn is for?#2018-06-0119:27thhellerwithout you first download the base module, wait for parse and eval, and then trigger download of the additional modules#2018-06-0119:27thhellerexactly, manifest.edn should contain everything you need. it is what I use.#2018-06-0119:29lilactown🤔 OK so I would parse manifest.edn, and add the file according to the module ns passed in. but it does necessitate then that I have to have some custom way to know when the module has been loaded (like what your blog has with (ns-ready))#2018-06-0119:30thhelleryeah shadow.api + ns-ready you still need to do in all your :entries that have these exported methods basically#2018-06-0119:31thhellerif you use shadow.loader you may however use the load deferred to do stuff on load#2018-06-0119:33lilactownwould shadow.loader respect the preloads? as in, would it refetch the module or realize it was already loaded?#2018-06-0119:34lilactownor would the browser just cache it anyway#2018-06-0119:34thhelleryes preloads work#2018-06-0119:42lilactownawesome! thanks for the help 😄#2018-06-0218:30wilkerluciois there a way to dismiss warnings on browser after compilation compilation?#2018-06-0219:39wilkerluciomy issue is that I'm getting warnings from a depency library I have no direct control, and the warnings keep coming during hot reloads#2018-06-0219:43wilkerlucioone of the libraries I'm trying to use got this:#2018-06-0219:43wilkerlucio
SEVERE: node_modules/tether/dist/js/tether.js:384: ERROR - Duplicate let / const / class / function declaration in the same scope is not allowed.
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
         ^^^^^^^^^^^^^^^
#2018-06-0219:48wilkerlucioI see this function was defined before on the same file, is there a way to control this behaviour and just allow it to redefine the function?#2018-06-0222:35wilkerlucioI'm trying to read some js files from a cljs, but I can't figure how to make shadow find it, I have this structure:
- src
  - file.cljs
  - file-js.js
#2018-06-0222:36wilkerlucioin file.cljs I'm trying (:require ["./file-js"]) but I get The required JS dependency "./file-js" is not available, ...#2018-06-0300:41justinleehm i just tried and it seems to work for me#2018-06-0300:41justinleei tried the same files structure as what yo uare doing#2018-06-0307:01thheller@wilkerlucio try the latest version. previously errors in JS file ended up in the wrong place so you'd get confusing errors like The required JS dependency ... instead of actually showing the error in the file. It most likely just has a parse error.#2018-06-0307:02thhellerplease open an issue about the tether thing. will need to check it out later.#2018-06-0307:11thheller@wilkerlucio there is a weird problem currently for cljs files including JS files in the classpath root. CLJS does not like namespaces with one segment. so src/file.cljs is bad. try src/thing/file.cljs instead so at least one level nested. JS file should be nested with it. Generally everything on the classpath should be properly scoped as you'd otherwise just get into trouble with dependency conflicts.#2018-06-0309:49ggaillardI got stuck with an issue combining datascript and shadow-cljs in :release mode. Turns out it was caused by a missing extern as in :compiler-options {:externs ["datascript/externs.js"]}. I didn't got the issue with cljsbuild, so I suppose the extern was automatically injected, moreover this detail is not mentionned in the datascript documentation. Is there a reason shadow-cljs behave differently regarding externs ?#2018-06-0309:50thhellermaybe accidental? were you using many cljsjs packages before?#2018-06-0309:52ggaillardIndeed ! it was my #1 reason to migrate to shadow: getting rid of cljsjs 🙂#2018-06-0309:52thhellersince they often package generated externs maybe one of those accidentally "fixed" the datascript issue#2018-06-0309:53thhellerit doesn't really matter where a property is defined in the externs, as long as it is defined somewhere#2018-06-0309:54thhellerah ok nvm datascript includes the externs via deps.cljs#2018-06-0309:55thhellerI have support for that disabled, should probably add a compiler option to enable it#2018-06-0310:01ggaillardIs it pertinent to provide an option ? As far as I can tell, I've never seen a use case where not providing an extern was a solution. Wouldn't be enough to perform a (set/union …) of all available externs ? Wherever they comes from a file A or a file B ?#2018-06-0310:35thhellerthe reason I disabled them is because 99% of the time they are not required#2018-06-0310:35thhellerand providing too many externs may be bad for :advanced since it can't remove anything that is mentioned in externs#2018-06-0310:35thhellerso you could end up with more code staying alive then desired#2018-06-0310:36thhellerdatascript is the first case I heard where this is a problem#2018-06-0315:51wilkerlucio@thheller thanks! makes sense, I was trying in a single namespace (`cljsjs`), seems using more works fine#2018-06-0315:52wilkerlucioabout the warnings, is there something I can do to dismiss then on the screen? I'm porting this big project, and warnings from dependencies are making the page unusable after reloads#2018-06-0315:53wilkerluciowhat about having a UI that only shows one warning, and can navigate via buttons (arrows) across the errors, and with an X to just close then, I can work on this#2018-06-0316:32thheller@wilkerlucio open an issue please. won't get to it before tuesday though.#2018-06-0316:38thhellerI think it would be best to put all warnings in a separate container with overflow: scroll; so it doesn't go beyond a certain height#2018-06-0316:54wilkerlucioyeah, make it dismissable#2018-06-0316:54wilkerlucioI was thinking about something more interactive, but in a container can be easier#2018-06-0421:13richiardiandreadoes shadow accept the new https://github.com/google/closure-compiler/blob/6797f5b2932c4dcdc12a3d4f9580d7fb9ae4bbf8/src/com/google/javascript/jscomp/CompilationLevel.java#L30 ? I would love to play with it 😄#2018-06-0421:38thhellerno point#2018-06-0421:39thhellersame as whitespace as far as shadow is concerned#2018-06-0421:41richiardiandrea@thheller maybe I am not familiar with shadow enough, but in vanilla Cljs bundling is never done, so deps are read from node_modules even in whitespace mode#2018-06-0421:41richiardiandrea(talking about nodejs target)#2018-06-0421:42richiardiandreais shadow-cljs doing that instead?#2018-06-0421:42thhelleryou can bundle node_modules files just fine with shadow#2018-06-0421:42richiardiandreaok cool#2018-06-0421:42thhellerBUT since node does not have the concept of an uberjar I do not recommend doing that#2018-06-0421:43richiardiandreawell but that is the point of bundling, you produce one single .js file#2018-06-0421:43thhellerbundle isn't aware of npm either so it changes nothing in that regard#2018-06-0421:43thhellerjust set :js-options {:js-provider :shadow} for your node build and it will bundle everything#2018-06-0421:43richiardiandreaoh, I thought the GCC BUNDLE was for that#2018-06-0421:43thhellerit just fails immediately when you try to include native packages#2018-06-0421:44richiardiandreaso you are saying that in any case it is a tool on top of GCC that needs to do that bundling#2018-06-0421:44thhelleris there no "bundle everything" solution in the node world?#2018-06-0421:44thhellerfeels weird if there isn't#2018-06-0421:44richiardiandreayes there is, I use this, one sec#2018-06-0421:45richiardiandreahttps://github.com/paullucas/les-clj/blob/master/scripts/build#L14#2018-06-0421:45richiardiandreabrowserify + uglify#2018-06-0421:45richiardiandreabut I hoped to have everything in one tool 😄#2018-06-0421:46thhellerwell like I said it WILL fail for any package with native code#2018-06-0421:46thhellerany other can technically work. just isn't built for it yet.#2018-06-0421:47richiardiandreakk no problem just inquiring 😉#2018-06-0421:47thhellerBUNDLE will do nothing as its just a lighter-weight version of WHITESPACE#2018-06-0421:47thhellerie. no transpile#2018-06-0421:48thhellerbit busy this week but open a ticket if you want a one-file option for node targets (similar to :browser)#2018-06-0421:48thhellershould be quite easy to add#2018-06-0421:49richiardiandreaok let me open an issue#2018-06-0421:49richiardiandreano big rush#2018-06-0423:43wilkerlucio@thheller do you think it's possible to have REPL on karma ci builds?#2018-06-0504:45kennyI am getting an exit status 0 for a test build with :autorun set to true that has failing tests. This does not seem like the expected exit status.#2018-06-0506:09claudiuHi. Looking at the manifest.edn, I see both cljsjs/react.js & node_modules/react is this expected ?#2018-06-0506:20thheller@claudiu yes. in shadow-cljs cljsjs.react is just a "bridge" to the npm react. see https://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#2018-06-0506:20thhelleronly required because some libs still use cljsjs.react instead of react directly. it does not include the actual cljsjs code ever#2018-06-0506:22thheller@kenny :autorun is mostly meant for watch and therefore cannot emit an exit code. you are probably better off running tests manually instead#2018-06-0514:25kennyI suggest adding a note to the docs about this 🙂#2018-06-0506:24thheller@wilkerlucio possible yes. when running karma in watch mode however it will destroy the REPL on each reload#2018-06-0506:25claudiuahh cool 🙂 thank you. Trying to see if I can get the bundle size down a bit, after adding semantic-ui to my project 🙂#2018-06-0509:53thhellerI would appreciate some feedback on https://github.com/thheller/shadow-cljs/issues/292#2018-06-0518:38wilkerlucio@thheller I opened an issue about the Tether library: https://github.com/thheller/shadow-cljs/issues/294 do you think you can help me with that? that's my last blocker to make a first shadow try release here#2018-06-0518:39thhellercan check in a few minutes, just finishing up another thing#2018-06-0518:40wilkerluciothank you 🙂#2018-06-0518:51thheller> We at HubSpot have been thrilled by Tether's success! However, the demands of maintaining such a complex project have outstripped our willingness and ability to do so effectively, as a quick glance at the issue tracker will tell you.#2018-06-0518:51thhellerthat does not inspire confidence in the library 😉#2018-06-0518:54wilkerlucioyeah, just more of the legacy stuff I have to keep around for a while#2018-06-0518:54wilkerlucioit's not the worst, I can just copy their dist file, fix and use it directly (removing the second definition fixes it)#2018-06-0518:54thheller@wilkerlucio unfortunately there is no way to turn that error into a warning or off#2018-06-0518:55wilkerluciono problem, thanks for looking it, I'll just use my own copy, this should not need upgrade as far as I see#2018-06-0519:25p-himikHi, I'm trying to use https://github.com/ccampbell/mousetrap and all is fine, I was even able to use plugins by writing (:require ["mousetrap/plugins/global-bind/mousetrap-global-bind"]). I wonder - is it the correct usage in a scenario where a library developer just wants you to include a <script> tag on your page? It appears to be working, with and without .js extension.#2018-06-0519:29thheller@p-himik not sure I understand the <script> question? the .js is optional and doesn't affect the output whether you use it or not#2018-06-0519:36p-himik@thheller The documentation at https://github.com/ccampbell/mousetrap/tree/master/plugins specifies that if I'm to use a plugin, I have to write something like <script src="%path-to-plugin.js%"></script> in my HTML. And I guess the above :require does just the same, with no potential problems?#2018-06-0519:39thhellerhmm the plugins rely on the Mousetrap global and don't properly express their dependency on mousetrap itself but if it works it works#2018-06-0519:39thhellerjust make sure you always require mousetrap before any of the plugins#2018-06-0520:36wilkerlucio@thheller just curious, the deps from shadow-cljsjs, they are looked up at runtime, or they go bundled with shadow?#2018-06-0520:36thhellerjust pushed 2.3.35 with some perf improvements. please let me know if things actually got faster and not slower 😉#2018-06-0520:37thhellershadow-cljs just depends on it https://github.com/thheller/shadow-cljs/blob/master/project.clj#L66#2018-06-0520:37thheller@wilkerlucio 2.3.35 includes your updates#2018-06-0520:38wilkerluciocool, thanks 🙂#2018-06-0521:21richiardiandreahello folks, I am build some code, and I get a bunch of warnings:
[:init-store-fn] Compiling ...
Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: 
#2018-06-0521:22richiardiandreais it something I am doing wrong?#2018-06-0521:29wilkerlucio@richiardiandrea just a wild guess, are you declaring clojurescript dep in your dependencies (or maybe some dep is)?#2018-06-0521:30wilkerlucioI tend to have those weird errors when something sets cljs to a version that's different from the one shadow is using#2018-06-0521:30richiardiandreaI do#2018-06-0521:30richiardiandreaoh#2018-06-0521:30wilkerluciowhich version it is? latest shadow uses 1.10.238 if I remember right#2018-06-0521:32richiardiandreayes same version there#2018-06-0521:32richiardiandreaI was also specifying clojure 1.10-alpha4 maybe that is why#2018-06-0521:33wilkerluciosounds a good place to try#2018-06-0521:33richiardiandreawill get rid of them#2018-06-0521:58thheller@richiardiandrea wild guess but maybe 2 instances of shadow-cljs are running and messing with each other?#2018-06-0522:03thhellerclojure/clojurescript deps should not be factors there#2018-06-0522:03thhellersomething is messing with the transit json output of the cache#2018-06-0522:13justinleeseems faster:
[:app] Build completed. (741 files, 615 compiled, 1 warnings, 31.53s)
[:app] Build completed. (743 files, 617 compiled, 0 warnings, 27.73s)
#2018-06-0522:14justinleefirst line was 2.3.30, second is 2.3.35#2018-06-0522:14richiardiandreausing deps.edn for what is worth... so not sure about caching, or how to debug the problem#2018-06-0522:15thhellerold vs new?#2018-06-0522:16thheller@richiardiandrea did you ensure that only one instance is running?#2018-06-0522:16thhellernot a leftover one in the background or so?#2018-06-0522:17richiardiandreadunno, I actually now cannot reproduce...#2018-06-0522:17justinleedid it again on the exact same code base:
2.3.30: [:app] Build completed. (743 files, 617 compiled, 0 warnings, 31.35s)
2.3.35: [:app] Build completed. (743 files, 617 compiled, 0 warnings, 27.73s)
#2018-06-0522:18richiardiandreastrange world of caching 😄#2018-06-0522:18justinleemore than 10% improvement. that’s pretty good!#2018-06-0522:19thhellerwatch recompiles should be faster too#2018-06-0522:20justinleehm for some reason i had cache off. i don’t remember why i did that#2018-06-0522:21justinleeoh. i bet it was when i didn’t realize that the code doesn’t reload when there are warnings.#2018-06-0522:25justinleewell now i’m not sure about that data. i turned the cache on, redid the watch, the time went up to 51.19s. but on a restart it went down the 8.62s. maybe because it takes time to write the cache?#2018-06-0522:25justinlee(note: I don’t use the server. i just run the watch directly because i only have one build)#2018-06-0522:26thhellerwatch starts a server so you are using the server#2018-06-0522:27thhellerand yes enabling the cache will make it slower the first time since it has to be written#2018-06-0522:27justinleethat makes sense. obviously that’s a good tradeoff.#2018-06-0600:14richiardiandreaso in order to bundle in node, which target should I use? I am adding the preamble so I need I thing either :node-library or :npm-module#2018-06-0601:18richiardiandreabecause :node-script prepends a #! and webpack barfs 😄#2018-06-0605:56claudiuHi, trying to setup and inspect my production build found release-snapshot really usefull ( https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/11). Could not find in the user guide release-snapshot any reason why it's not there ?#2018-06-0607:01thheller@richiardiandrea if you want to use webpack use :npm-module#2018-06-0607:01thheller@claudiu yeah I still need to mention that. It is a bit unfinished thats why it is not mentioned yet.#2018-06-0609:26claudiuCool 🙂 Playing with react-semantic-ui, it really helped a lot to understand why my bundle-size grew so much. Are there any optimizations that I can opt-in to get better build sizes with shadow-cljs (ex: change the js output to es6, ie11+) ?#2018-06-0612:12kwladykaI asked on #clojurescript about issue with https://github.com/venantius/accountant . But I would like to be sure: is it shadow-cljs issue or accountant issue? Looks like accountant, but who knows.#2018-06-0612:17hlolli@kwladyka how's your :devtools in shadow-cljs.edn config? You define correct http-root?#2018-06-0612:34kwladyka@hlolli
{:http-root "public"
                           :http-port 8020}
#2018-06-0612:35kwladykaOh I just discovered without accountant I have the same issue, so it is about shadow-cljs#2018-06-0612:36kwladykaWhen run http://localhost:8020/foo/bar/baz but app works with http://localhost:8020/foo (which doesn’t exist too)#2018-06-0612:37kwladykaand of course it works with http://localhost:8020 🙂#2018-06-0612:47kwladykaSo everything is fine when use 1 level url, but when use more I have this issue#2018-06-0612:53wilkerlucio@kwladyka what your :asset-path look like (in the build config)?#2018-06-0613:02kwladyka@wilkerlucio :asset-path "js"#2018-06-0613:03wilkerluciothat looks like the issue to me, try /js instead#2018-06-0613:03kwladyka🍺 thank you#2018-06-0613:04wilkerluciono worries, this is the base path for js requires, so if you have it relative it only works on the root#2018-06-0613:08kwladykaYou saved my day 🙂#2018-06-0613:11wilkerlucioglad to help 🙂#2018-06-0613:13wilkerlucio@thheller hey, this might be something stupid I'm doing, but I'm getting some warnings that I didn't expect in shadow, I create a new namespace, both clj and cljs separated files (clj for a macro), I did :require-macros on my cljs file, but when I use the macro shadow is warning me that I'm using an undefined symbol, but my macro is a def-like macro, so I don't understand why I'm getting these warnings#2018-06-0613:13wilkerluciothis is my macro code:#2018-06-0613:13wilkerlucio
(defmacro defcard [sym settings]
  (let [fqsym (if (namespace sym)
                sym
                (symbol (name (ns-name *ns*)) (name sym)))]
    `(init-card ~fqsym ~settings)))
#2018-06-0613:13wilkerluciomacro usage:#2018-06-0613:13wilkerlucio
(ws/defcard sample-card
  {::ws/node-props
   {:className ""}

   ::ws/render
   (fn [node]
     (gobj/set node "innerHTML" "Hello World"))})
#2018-06-0613:13wilkerluciowarning:#2018-06-0613:13wilkerlucio
5 | (ws/defcard sample-card
-------^------------------------------------------------------------------------
Use of undeclared Var my.ns/sample-card
#2018-06-0613:14wilkerlucioam I missing something here?#2018-06-0613:19kwladyka@wilkerlucio Is it possible to require macro in clj in cljs file?#2018-06-0613:19wilkerluciothats how you have to do it, macros in cljs only exists in clj space, since they run at compilation time#2018-06-0613:20kwladykaOh I see. I didn’t write macro for cljs. I expected macro for cljs need to be in cljs files.#2018-06-0613:20wilkerluciono, they must be in .clj or .cljc files#2018-06-0613:32mhuebert@wilkerlucio is init-card itself a macro which expands to (def ~the-name ...)? I don’t see a def form in the macro so I don’t know where that var is being defined #2018-06-0613:33wilkerlucioI said def-like just in the sense of syntax, init-card is just a function#2018-06-0613:33wilkerlucioI don't actually def anything, the macro is just a sugar to expand the symbol#2018-06-0613:34mhuebertMaybe you want to quote that symbol ?#2018-06-0613:35mhuebertNow it is just expanding to a fully qualified symbol which hasn’t been defined anywhere so you are seeing that warning#2018-06-0613:36mhuebertMost def-style macros use a real def behind the scenes to create a var which can be referenced like any other. (Not all of course.)#2018-06-0613:37wilkerluciofulcro for example has the defmutation macro, it doesn't output anything by default, also don't give warnings#2018-06-0613:37wilkerlucioI'm pretty sure that's is possible to do, and shouldn't trigger a warning, my guess is that I'm just missing something stupid#2018-06-0613:38mhuebertHow do you want to reference “sample-card” later?#2018-06-0613:38wilkerlucioI'm registering it on an atom for later usage#2018-06-0613:40mhuebertThen maybe just quote the symbol. Won’t get a warning then#2018-06-0613:40mhuebert'~fqsym#2018-06-0613:41mhuebertOr (quote ~fqsym)#2018-06-0613:41wilkerlucioyes! that's the stupid thing I was missing, thanks 🙂#2018-06-0613:41mhuebert np :)#2018-06-0615:02p-himikWhen I start shadow-cljs, it prints:
shadow-cljs - Using IP "10.83.10.6" from Interface "tun0"
Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke
INFO: Found multiple IPs, might be using the wrong one. Please report all interfaces should the chosen one be incorrect.
Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke
INFO: Found IP:10.83.10.6 Interface:tun0
Jun 06, 2018 1:56:37 AM shadow.cljs.devtools.server invoke
INFO: Found IP:192.168.1.220 Interface:wlan0
Jun 06, 2018 1:56:37 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Jun 06, 2018 1:56:37 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server version: 2.3.23
shadow-cljs - server running at 
The problem here is that it uses tun0 interface, which is a VPN interface in my case. I casually switch VPN throughout the day, and when I do that, I also have to restart shadow-cljs. Maybe it shouldn't use tun interfaces? Is there anything I can do on my setup to make it always use localhost?
#2018-06-0616:46lwhortonheya guys, i’m looking for a way to build a release version of my app using shadow that replaces just a few namespaces with “mock” implementations. is there support for this somewhere? i know I can use clojure.defines via the normal compiler config options.. but i wonder if there’s a better approach, or if this is crazy. the intent is to replace just a few functions that do side-effectey/networking things with stubs so that I can run some functional tests without touching the network#2018-06-0617:16kwladyka@lwhorton generally to mock something in Clojure just use https://clojuredocs.org/clojure.core/with-redefs#2018-06-0617:21kwladykaFor example:
(deftest wfirma
  (with-redefs [wfirma.api/request-api (constantly (read-string (slurp "test/bind-input/products-wfirma.edn")))]
    (let [products-wfirma (db-products/get-products :wfirma)]
      (testing "wfirma -> products"
        (is (every? nil? (map (partial s/explain-data ::sp/product) products-wfirma))
            "spec")
        (is (= "00014" (:code (first products-wfirma)))
            "parse")))))
or
(deftest estore->db
  (with-redefs [atomstore.soap/connection (constantly nil)
                atomstore.soap/get-products (constantly (slurp "test/bind-input/products-all.xml"))]
    (testing "atomstore->products"
      (is (= (:body (core/app (mock/request :get "/shops/hc/db/products/refresh")))
             "done")))))
#2018-06-0617:22kwladykaSimple as that 🙂#2018-06-0617:22kwladykaNo extra modules etc. Clear Clojure 🙂#2018-06-0617:23kwladykaSo you save in some files reposne from server and later use this files to bind reposne from server#2018-06-0617:31lwhortonyea I wish I could, but my contexts are not great for with-redefs: i have a clj runtime executing webdriver ui tests, so I can’t really with-redef some cljs code to stub out implementations. like I said I think I have to pre-build the cljs component with a “global redef” and then use the clj webdriver to interact for testing#2018-06-0617:37kwladykahmm I remember in one project we were starting webdrive ui tests from ClojureScript code, so then it should be possible to do with-redef. I didn’t have exactly this issue before, so I don’t have solution for that.#2018-06-0617:38kwladykaWe solved that on infrastructure level#2018-06-0617:38kwladykafor all sevices#2018-06-0618:30richiardiandreaI still see errors when I compile with deps.edn, but this time also an error#2018-06-0618:30richiardiandrea
Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: 
#2018-06-0619:21thheller@richiardiandrea can you please confirm that you are absolutely 100% certain that there is only ONE instance of shadow-cljs running at any given time for the project? not some process running a background racing another process in the foreground or anything like that? there can only be one process active at any given time for a build. I have seen the above error when 2 processes were active and tried to write the cache at the same time. that produced garbage JSON and could never be read again#2018-06-0619:22thhellerthe NPE is probably from a missing :output-dir. the validation for that is missing.#2018-06-0619:22richiardiandrea
ps -ef | grep java
arichia+ 23173 22953  0 12:22 pts/1    00:00:00 grep --color=auto java
#2018-06-0619:23richiardiandreawhen it runs it is:
arichia+ 23272 23266  0 12:23 pts/1    00:00:00 bash /home/arichiardi/.local/bin/clojure -J-Djava.util.logging.config.file=/home/arichiardi/git/laputa/lambda-cqrs/.shadow-cljs/logging.properties -Sdeps {:aliases {:shadow-cljs-inject {:extra-deps {thheller/shadow-cljs {:mvn/version "2.3.35"}}}}} -A:cljs-jvm:shadow-cljs-inject -m shadow.cljs.devtools.cli --npm compile init-store
arichia+ 23285 23272 99 12:23 pts/1    00:00:30 /usr/bin/java -Djava.util.... <- shadow?
#2018-06-0619:24thhellerlooks good and you get the above errors for every compile call?#2018-06-0619:24richiardiandreayeah#2018-06-0619:25richiardiandreashould I delete some folder?#2018-06-0619:25thhellerno please don't.#2018-06-0619:25thhellerplease send me the .shadow-cljs/builds/init-store/dev/ana/cljs/core/async.cljs.cache.transit.json file#2018-06-0619:26thhellerwant to see whats up with that and why it fails to parse#2018-06-0619:28thhellerand a clj -Stree would help although deps shouldn't play a role here. doubt there is the JSON impl that writes invalid JSON and then complains about it when trying to read it#2018-06-0620:19p-himik@thheller Could you please check my message above about tun devices and constant IP changes? Thanks!#2018-06-0620:38thheller@p-himik yes I'll switch the default back to localhost. detecting the IP is way too unreliable https://github.com/thheller/shadow-cljs/issues/296#2018-06-0620:50richiardiandreaother q: is there a way to export a function as default export? I am trying to achieve this: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#exporting-a-function#2018-06-0620:54thhellerthats currently "buggy" but you can {:target :node-library :exports some.ns/some-fn} (defn some-fn [] the-exported-fn)#2018-06-0620:55thhellerit basically ends up as module.exports = some.ns.some_fn();#2018-06-0620:55thhellerso the result of the function call ends up as the result#2018-06-0620:55thhellershouldn't actually be the function call though#2018-06-0620:55thhellerdunno why I did it like that#2018-06-0620:56richiardiandreaok let me try that and then I can try to see if I can help with some fix or something..#2018-06-0620:57justinlee@thheller just out of curiosity could shadow have an issue with the “use strict” issue that they were talking about in #cljs-dev#2018-06-0620:57justinleeor do you do something different#2018-06-0620:57thhellerprobably not since it does the same as webpack and others, ie. wrapping in a function#2018-06-0620:58justinleeah yea that would fix it. i wonder why dnolen doesn’t want to do that. it seems not hard to do and much safer#2018-06-0620:58thhellerwell you can't do it easily with cljsjs#2018-06-0620:59thhellerthe code is not processed in any way and just blindly prepended#2018-06-0620:59justinleeright#2018-06-0620:59thhellerif you wrap that code in a functions some global it is supposed to create might not end up getting created maybe?#2018-06-0621:00justinleewell i’ve never really understood how webpack knows what its supposed to export. you have to manually export every symbol through the iife#2018-06-0621:00thhellerI didn't follow the discussion though. not sure which problems this causes exactly.#2018-06-0621:01justinleethe issue is that if you do blind concatenation and a script has a global “use strict”, that will break other parts of code that are not strict compliant#2018-06-0621:01justinleeit’s likely that simply removing “use strict” will be okay, though technically you can write code that breaks without it (though not very realistic code, to be fair)#2018-06-0621:03thhellerwell replacing use strict looks like band-aid rather than an actual fix#2018-06-0621:03justinleeyes. i agree. clearly wrapping each module in an IIFE with a function-local “use strict” is much more robust#2018-06-0621:04richiardiandreaso @thheller the exports above does not work for :npm-module it seems#2018-06-0621:04thheller@richiardiandrea thats why I included :target :node-library explicitely when mentioning it#2018-06-0621:05thhellerit is not possible with :npm-module#2018-06-0621:05thhellerwell ... it is possible#2018-06-0621:05thheller:target :npm-module :output-dir "foo"#2018-06-0621:06thhellerindex.js module.exports = require("./foo/your.ns").foo; and (defn ^:export foo [...] ...)#2018-06-0621:07richiardiandreaok yeah 😄#2018-06-0621:07thhellerjust need to create the index.js manually and use that as your main "entry"#2018-06-0621:07richiardiandreaso what is the difference between library and module ?#2018-06-0621:07thheller:node-library creates a single file#2018-06-0621:07thheller:npm-module creates commonjs files to they behave like any other commonjs#2018-06-0621:08thhellerso you can import namespaces individually and stuff#2018-06-0621:08richiardiandreaoh ok that's is what I need then#2018-06-0621:08richiardiandreasorry I mean :node-library#2018-06-0621:08thheller:npm-module is mostly intended to be processed by other tools, ie. including cljs output in a webpack build#2018-06-0621:09thhellerdon't mistake "single file" for the single file you are after though#2018-06-0621:09thhellersingle file as in .jar not uberjar#2018-06-0621:09richiardiandreauhm...ooook#2018-06-0621:09richiardiandreaok right#2018-06-0621:10richiardiandreaI can basically pass one file with the exported default and give that to webpack can't I? then it will bundle node_modules + mine#2018-06-0621:10thhellerif you post-process in any way :npm-module is the way to go#2018-06-0621:10richiardiandreaok#2018-06-0621:11thhellerbut yes :node-library will also work. its just way less flexible.#2018-06-0621:11richiardiandreaI am at the "whatever" is faster kind of point 😄#2018-06-0621:11thhellerbut does the amazon cloud stuff seriously not support installing packages via package.json?#2018-06-0621:11thhelleror azure rather?#2018-06-0621:12richiardiandreawell, I am on azure now ......#2018-06-0621:12richiardiandreayeah you can but you have to have one package.json per function#2018-06-0621:12richiardiandreaI want to produce one js per function from one cljs project#2018-06-0621:13thhellersorry that sentence doesn't compute#2018-06-0621:13richiardiandreaah ah#2018-06-0621:14thhelleris there a full azure JS example? no idea what function means in this sense#2018-06-0621:14richiardiandreaI know it is weird, but azure wants
fn1
  - index.js
  - node_modules
fn2
  -

fnn
#2018-06-0621:14richiardiandreaand I want to produce that from a unique clojure project#2018-06-0621:15thhelleryou mean you have a clojure project that should output many azure fns?#2018-06-0621:15richiardiandreayeah#2018-06-0621:16richiardiandreawhy? because they will all run in a REPL#2018-06-0621:16richiardiandreaand emulate the cloud#2018-06-0621:17richiardiandreaok cool :node-library works#2018-06-0621:17richiardiandrea
$ node init-store/unbundled.js 
Hello World
#2018-06-0621:17thhellerso what I would probably do is create a fn1 directory. put a package.json into it.#2018-06-0621:18thheller:builds {:fn1 {:target :node-library :exports your.fn1/foo :output-to "fn1/index.js"}}#2018-06-0621:18thhellerrepeat that for every fn#2018-06-0621:18richiardiandreayep that's what I am doing 😉#2018-06-0621:19richiardiandreatook a bit of questioning about shadow's options#2018-06-0621:19richiardiandreathanks for your answer btw#2018-06-0621:20thhellernever written a azure fn but could add a :target :azure-fn if it needs some custom processing or config options#2018-06-0621:21thhellerwon't get much shorter than :node-library probably#2018-06-0621:23thhellerit could generate the package.json and maybe this from metadata? https://github.com/Azure-Samples/functions-node-sas-token/blob/master/GetSasToken-Node/function.json#2018-06-0621:23thhellerno idea what that file is about though#2018-06-0621:25richiardiandreaI think that bundling node in shadow would already improve things phenomenally. So that you get js + node-modules without using webpack#2018-06-0621:26thheller
(defn my-handler
  {:azure/bindings
   [{:authLevel "function"
     ...}]}
  [context req]
  ...)
#2018-06-0621:26thhellerjust abusing metadata on defn and the target could read that to generate the function.json#2018-06-0621:26richiardiandreaOpened an issue for that 👼#2018-06-0621:26richiardiandreaAh yeah that of course is better ;)#2018-06-0621:26richiardiandreaAlso more work :)))#2018-06-0621:27thheller5 lines of code 😉#2018-06-0621:27richiardiandreafunction.json contains a lot more#2018-06-0621:27richiardiandreaBecause a function can bind to many things not just http#2018-06-0621:28thhelleryeah but EDN can express anything that JSON can express
#2018-06-0621:28richiardiandreaFor sure#2018-06-0621:28thhellerbut no idea about the purpose of those files and how "static" they are#2018-06-0621:48richiardiandreaThey are static yeah...but then shadow would need to know about azure functions...dunno up to you :)#2018-06-0621:48thhellershadow doesn't need to know anything. the target does 😉#2018-06-0621:48richiardiandreaI think the bundling is a good compromise for me ;)#2018-06-0621:48richiardiandreaTrue#2018-06-0621:49thhellerthe target could technically be a library. although its not documented at all so I don't expect anyone to be able to write one.#2018-06-0621:49thhellerI'm curious now however and just created an azure account to play around 😉#2018-06-0621:49richiardiandreaAhah ok cool#2018-06-0622:55richiardiandrea@thheller so build hooks are always clojure only right? they are executed by the jvm ?#2018-06-0622:59richiardiandreasorry yes, the answer is yes#2018-06-0623:18richiardiandreatoo bad the hook is not triggered here for some reason#2018-06-0706:11thhellernot triggered?#2018-06-0715:59richiardiandreaYeah I wanted to launch webpack on flush but that's ik. Can use bash for now, don't have really time to debug it#2018-06-0716:03thhellermaybe you forgot the {:shadow.build/stage :flush}?#2018-06-0716:03thheller> At least one configured stage is required since the hook otherwise would never do anything.#2018-06-0716:07richiardiandreaI copied the example in the doc basically#2018-06-0718:24richiardiandreaThe file I have in my dev folder is:
(ns ep-cloud.shadow)

(defn hook
  {:shadow.build/stage :flush}
  [build-state & args]
  (prn [:hello-world args])
  build-state)
#2018-06-0718:24richiardiandreawhich is :source-paths#2018-06-0718:24richiardiandreaand I have :build-hooks [(ep-cloud.shadow/hook 1 2 3)]#2018-06-0718:26thhellerwhich version are you on? it is a pretty recent addition?#2018-06-0718:32richiardiandrealatest version#2018-06-0623:27spiedenanyone know the require form and symbol to access Button.Group below via shadow-cljs?
import React from 'react'
import { Button } from 'semantic-ui-react'

const ButtonExampleGroup = () => (
  <Button.Group>
from: https://react.semantic-ui.com/elements/button#groups-group
#2018-06-0623:27spiedencan’t figure it out#2018-06-0623:36smnplkHi guys. First time shadow-cljs user here. I just created a project with reagent, but I get the folowing error when building "The required namespace "react" is not available, it was required by "reagent/core.cljs".#2018-06-0623:37spieden@smnplk you may just need to do npm install react#2018-06-0623:38spiedenshadow ignores the js components brought in by jars i think#2018-06-0623:38wilkerluciono foreign-libs in shadow, so cljsjs is ignored#2018-06-0623:39spiedenhttps://shadow-cljs.github.io/docs/UsersGuide.html#_installation#2018-06-0623:39smnplk@spieden thanks, didn't know that. Now I get a different error, The required namespace "create-react-class" is not available, it was required by "reagent/impl/component.cljs". Do i just :exclude create-react-class when requiring reagent.core ?#2018-06-0623:40spiedensame fix i believe =)#2018-06-0623:40spiedennpm install create-react-class#2018-06-0623:40spiedeni think that’s some kind of react 15 -> 16 backwards compatibility shim#2018-06-0623:40smnplk@spieden, thank you. And thanks for the docs, I don't know how I missed these beutiful docs. Maybe I'm blind.#2018-06-0623:41spiedensure just switching over myself#2018-06-0623:42wilkerluciowelcome to the npm-enabled cljs world 🙂#2018-06-0623:43smnplkThank you guys 🙂 I see the link to docs is on github, but I overlooked because of the tempting beginners guide below.#2018-06-0706:10thheller@spieden (:require ["semantic-ui-react" :as sem]) sem/Button.Group#2018-06-0713:08thheller@richiardiandrea https://github.com/thheller/shadow-cljs/issues/297#2018-06-0714:06wilkerlucio@thheller hello man, how you doing? question, how does work the part of shadow that you can click on a warning and it opens on the editor? I'm looking at the sources and see that it triggers something on the server to do it, can you tell me how that works?#2018-06-0714:07wilkerlucioand you know if it's possible for me to do something similar strait in the browser? for context, I'm creating a devcards alternative, and I would like to jump to the card source from a button in the page#2018-06-0714:10thhellercan't do it straight in the browser no. it basically just does a xhr and the server then executes via the shell https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web/api.clj#L55-L86#2018-06-0714:11thhelleruses ProcessBuilder https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/util.clj#L363-L396#2018-06-0714:14thhellersince the browser can't just randomly start applications it must go through the server#2018-06-0714:21wilkerluciogotcha, so I think I'll make this "shadow-only" and I can just leverage your xhr call#2018-06-0714:23thhellercould also export this to something more generic and figwheel could do the same#2018-06-0714:24thhellerie. you call (when-let [open js/OpenFileInEditor] (open "some/file.cljs" 10 1))#2018-06-0714:24thhellerand shadow-cljs/figwheel just export the js/OpenFileInEditor#2018-06-0714:27wilkerluciogood idea#2018-06-0715:07richiardiandreaLooked at the issue and the PR and left some comment there, I think there is value...but the target can be made generic - say :lambda-fn - and the metadata dropped - easy to write anyways`. Will try to come up with a PR today and probably I will ask you more questions on how to package everything, node_modules included, in a single file#2018-06-0715:09richiardiandrea@thheller ^ and thanks 😉#2018-06-0716:52spieden@thheller worked, thanks!#2018-06-0718:01wilkerlucio@thheller trying to use the open-file, but not working, I guess I might be sending the wrong path, what the path need to be relative to?1#2018-06-0718:02thhellershould be absolute I think#2018-06-0718:02thhelleror relative to the project root#2018-06-0718:05wilkerlucioI'm getting the info out of (meta &form), but the path there seems relative to its own source path, do you know if I can get the absolute path there somehow?#2018-06-0718:05thhellertry shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1) in the console#2018-06-0718:06thhellerhmm good question. I don't think you can get to the actual file#2018-06-0718:07thhellerI got annoyed by leaking /home/thheller/code/shadow-cljs/src/... or other absolute paths into the compiled output#2018-06-0718:08thhellerso now it only has access to the classpath path#2018-06-0718:10thhellerI could add another open-classpath fn that maps the classpath path to an absolute path and opens that#2018-06-0718:11wilkerluciogotcha, I couldn't make it work, I tried manually asking for the shadow file#2018-06-0718:11wilkerluciothe editor gets focused, but the correct file isn't opened#2018-06-0718:11wilkerlucioI tried relative to project and absolute#2018-06-0718:12thhellerthis doesn't work? shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)#2018-06-0718:13wilkerlucioon the js console this line doesn't work at all#2018-06-0718:13wilkerlucio
shadow.cljs.devtools.hud.open_file("shadow-cljs.edn", 1, 1)
VM52189:1 Uncaught TypeError: Cannot read property 'open_file' of undefined
    at <anonymous>:1:26
#2018-06-0718:13wilkerlucioah, was msising client: shadow.cljs.devtools.client.hud.open_file("shadow-cljs.edn", 1, 1)#2018-06-0718:13wilkerluciobut still, not focusing the correct file#2018-06-0718:14thhellerdo you have :open-file-command setup correctly?#2018-06-0718:14wilkerlucioyeah, when I click from a warning it works#2018-06-0718:14wilkerlucioups, or at least was working early, for some reason seems like that isn't working now either#2018-06-0718:14wilkerluciolet me try restarting shadow#2018-06-0718:17wilkerlucionow it's not working anymore, even on warnings =/#2018-06-0718:18wilkerlucioI have this on ~/.shadow-cljs/config.edn#2018-06-0718:18wilkerlucio
{:open-file-command
 ["idea" :pwd "--line" :line :file]}
#2018-06-0718:20wilkerluciostrange, I''m sure it worked earlier#2018-06-0718:21thhellermaybe your editor is confused? it is working fine for me#2018-06-0718:27wilkerluciomaybe, I'll try restarting it#2018-06-0718:29wilkerluciostill the same, I'll give up on that for now, not that important#2018-06-0719:19oscarI'm finding that running shadow-cljs via "clojure" (with a deps.edn file) results in a process that never exits.#2018-06-0719:22thhellerdoes it hang or what do you mean?#2018-06-0719:24oscarIf I do a release, it successfully builds and then hangs.#2018-06-0719:25oscarI converted my deps.edn to a project.clj and running under lein I don't have the same issue.#2018-06-0719:28oscarIt looks like any action that shells out to the clojure process never returns. I can put together an example repo in a couple hours if you want.#2018-06-0719:29oscar
$ yarn shadow-cljs clj-eval "(println \"hello\")"
yarn run v1.7.0
warning package.json: No license field
$ /home/oscar/Projects/penny-profit/redux/node_modules/.bin/shadow-cljs clj-eval '(println "hello")'
shadow-cljs - config: /home/oscar/Projects/penny-profit/redux/shadow-cljs.edn  cli version: 2.3.36  node: v10.4.0
shadow-cljs - starting via "clojure"
hello
nil

#2018-06-0719:30oscarAnd it just hangs without returning to the prompt#2018-06-0719:35wilkerluciohad you tried without yarn? I used with deps.edn before, didn't had this issue, also there is a strange thing about the 130 status code return, I wonder if that + yarn is getting you in this place#2018-06-0719:38thhelleryeah check which process actually doesn't exit. is it really the java process sticking around?#2018-06-0719:40thhelleryarn -> node (shadow-cljs) -> clojure (bash) -> java . could be any one of them#2018-06-0720:59oscarSubstituting npx for yarn yields the same results.#2018-06-0720:59oscarIt looks like java isn't exiting. I'll try to make a simplest-case repo.#2018-06-0721:10oscarOh! One of my dev namespaces starts an http server. That's probably what's keeping the process alive. When I switched to lein, I didn't include my dev path. Thanks for the help!#2018-06-0721:11oscarYeah. That was it.#2018-06-0800:12hlolliI'm haveing diffuculty connecting to a node based nrepl in cider
shadow.user> (shadow.cljs.devtools.api/watch :node)
:already-watching
shadow.user> (shadow.cljs.devtools.api/nrepl-select :node)
To quit, type: :cljs/quit
[:selected :node]
cljs.user> :a
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
cljs.user> (shadow.cljs.devtools.api/nrepl-select :node)
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
cljs.user> 
here I already started a watch, also when I start server and manually ignite the watch, I get the same error message.
#2018-06-0800:18oscar@hlolli You've only started the build. You need to run the compiled code before you can evaluate cljs. Do $ node <your-build.js> and then try evaling again.#2018-06-0800:20hlolli@oscar boom thanks!#2018-06-0800:20hlolliamazing how fast things change, this is not how I did things in the old days (6-8 weeks ago) 😛#2018-06-0800:22richiardiandreaThere is also a node-repl command directly#2018-06-0800:23hlolli@richiardiandrea of course, and that's how I did things in "the old days". That brain cell must have gotten erased on some berlin dancefloor.#2018-06-0800:24richiardiandreaAh ah ok ;)#2018-06-0800:24richiardiandreaYeah well I have to say that I prefer to work at the REPL too and have a shadow server always on#2018-06-0800:26hlolliyeh, for a website that I did recently, I got into this rythm, so the environment is the browser when it's opened, so this all makes sense.#2018-06-0800:28richiardiandrea@hlolli do you have completions in emacs + shadow? I think I see them intermittently#2018-06-0800:28hlolliyes, at a quick glance, company-mode is doing its job correctly#2018-06-0800:29richiardiandreaCool thanks so I will try to check if my config is broken somehow#2018-06-0810:34kwladyka * I have this symbols instead of * for required fields in material ui#2018-06-0810:35kwladykaI found this https://github.com/mui-org/material-ui/issues/10494#2018-06-0810:35kwladykaIs it possible to solve it in some way in shadow-cljs?#2018-06-0810:36kwladykaNot sure what is the right solution here#2018-06-0811:58thheller@kwladyka you probably just need to set the correct charset for your html <meta charset="utf-8">#2018-06-0814:21jmckitrickHas anyone figured out how to get cider to run (shadow.cljs.devtools.api/repl :app) after connecting?#2018-06-0814:22jmckitrickI’m doing it manually now#2018-06-0816:39colindresj@thheller how do you suggest including dependencies from private maven repos? Currently, I use lein and an s3 wagon to handle it, but hoping to move off of lein entirely#2018-06-0816:55thheller@colindresj I have never used a private maven repo so I don't know what setup is involved. if it just requires a :repository entry you can do that in shadow-cljs.edn just like lein#2018-06-0817:45colindresjSo something like:#2018-06-0817:45colindresj
:repositories
 [["private-maven"
   {:url "",
    :snapshots false,
    :sign-releases false,
    :username :env/aws_access_key_id,
    :password :env/aws_secret_access_key}]]
#2018-06-0817:46colindresjI get a shadow-cljs - dependency update failed - Vector arg to map conj must be a pair with that#2018-06-0817:47thhellerI think that should be a map#2018-06-0817:48thheller{"private-maven" {...}}#2018-06-0817:48colindresjOh ok#2018-06-0817:48thhellerdunno about the :env/ stuff. that might be something lein does?#2018-06-0817:49colindresjYeah that’s for reading env variables#2018-06-0817:49thheller:username #shadow/env "aws_access_key_id"#2018-06-0817:49colindresjAh cool didn’t know there was a reader tag for env vars with shadow#2018-06-0817:49colindresjThat’s sweet#2018-06-0817:51colindresjDo I have to specify maven central and clojars in the repositories map as well, or will shadow merge my map with defaults?#2018-06-0817:51thhellerwill be merged#2018-06-0817:51thhellerhttps://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj#L36#2018-06-0817:52colindresjCool thank you#2018-06-0817:54richiardiandreaquestion about new :exports#2018-06-0817:55richiardiandreaI have :exports-var in my config#2018-06-0817:55richiardiandreabut I receive:
should contain keys: :exports, :exports-fn, :exports-sym

|          key | spec |
|--------------+------|
|     :exports |  nil |
|  :exports-fn |  nil |
| :exports-sym |  nil |
#2018-06-0817:55richiardiandrea cli version: 2.3.36#2018-06-0817:55richiardiandreaI see the code has :exports-var in there, so maybe it has not been deployed yet?#2018-06-0817:56richiardiandreaoh, no I think there is a bug, let me fix it#2018-06-0817:58thhelleroh yeah the spec is invalid#2018-06-0817:58richiardiandreaopened a PR#2018-06-0817:59thhelleroh ... already fixed it 🙂#2018-06-0817:59richiardiandrealol kk no problem 😉#2018-06-0818:02richiardiandreadoes :output-to in a :release map?#2018-06-0818:02richiardiandreaah yes it works#2018-06-0818:20kwladyka
(ns material-ui.colors
  (:require ["@material-ui/core/colors/deepPurple" :default deepPurple]
            ["@material-ui/core/colors/green" :default green]
            ["@material-ui/core/colors/blue" :default blue]))

(def deepPurple deepPurple)
(def green green)
(def blue blue)
Is there any way to do something like that? In that case blue is nil when load from another namespace [material-ui.colors :as colors] In the same namespace blue has value.
#2018-06-0818:21kwladykaSure I can name all colours cblue or something like that, but it would be so ugly#2018-06-0818:22thhellerso the (def deepPurple deepPurple) is basically a self-reference#2018-06-0818:22thhelleryou can do :default mui-deepPurple#2018-06-0818:22thheller(def deepPurple mui-deepPurple)#2018-06-0818:23kwladykano shortcut to list all colours and def all of them?#2018-06-0818:24thhellerdon't ask me ... ask the insane JS people making a file per color 😛#2018-06-0818:24kwladyka(def deepPurple (js->clj mui-deepPurple)) - how compiler work? Will it be count in the browser or during compile?#2018-06-0818:24kwladykaheh 🙂#2018-06-0818:25kwladykathis one too?#2018-06-0818:25thheller(def deepPurple (js->clj mui-deepPurple)) whats this supposed to do?#2018-06-0818:25thhellerisn't it a string?#2018-06-0818:25kwladykanow I have to get value like that (aget colors/blue "A400")#2018-06-0818:27thhellerah its a JS object#2018-06-0818:28thhellerwell honestly I would just make a function#2018-06-0818:28kwladykaor maybe it is just stupid to use this colours objects hmm#2018-06-0818:29kwladykaI want to avoid performance waste to count all colour in the web browser#2018-06-0818:29thheller(defn color [x y] ...) so you can do (color :blue 400)#2018-06-0818:29kwladykathis energy could be use for cyrptocurrency instead of counting colours 😛 😉#2018-06-0818:29kwladykahmm#2018-06-0818:29kwladykaIt will work 🙂#2018-06-0818:30kwladykabut if js->clj in this situation will be optimised during build code it will be even better#2018-06-0818:30thhellerthe js->clj is at runtime#2018-06-0818:31thhelleryou could just take the color codes and port them to CLJS#2018-06-0818:32thhellerDCE will actually remove the colors you don't use then#2018-06-0818:33kwladykahmm#2018-06-0818:34thhellernot sure how material-ui uses the colors internally though?#2018-06-0818:34thhellerI guess they sometimes take the color object as arguments somewhere?#2018-06-0818:35kwladykaIt can be use to make a them for example:
(def theme (mui/create-mui-theme
             (clj->js
               {:palette {:primary {:main (aget colors/blue "A400")}
                          :secondary {:main (aget colors/deepPurple "500")}}
                :overrides {:MuiAppBar {:root {
                                               ;:color "#00ff00"
                                               ;:background-color "white"
                                               }}
                            :MuiButton {:root {:text-transform "none"}}}})))
#2018-06-0818:36thhellerso you use it only once ever?#2018-06-0818:36kwladykaI wanted use it in view components also, for example to set colour of the button#2018-06-0818:37thhellerthen seriously just :palette {:primary {:main "#42a5f5" ...#2018-06-0818:37kwladykabut I start to think maybe it is stupid idea to use this objects…#2018-06-0818:37kwladykahttps://material-ui.com/style/color/#color-palette#2018-06-0818:37kwladykaexactly#2018-06-0818:37kwladykaI can rewrite values from there instead#2018-06-0818:38kwladykajust I am not a graphic designer and this pallet of colours help me a little 🙂#2018-06-0818:38thhelleryeah the palette is great#2018-06-0818:39thhellerbut just copying the colors you want seems like a much better solution that dealing with those JS objects#2018-06-0818:39thhellerits not like the color blue is suddenly going to change its color code#2018-06-0818:42kwladykaprobably you are right. This is the trap of using ready solutions. Start to turn off brain and use it 🙂#2018-06-0818:44kwladykamaybe I will write macro one day or something for that 🙂#2018-06-0818:58richiardiandreais there a way to add dev folder to shadow's classpath?#2018-06-0818:59thheller:source-paths ["src" "dev"]?#2018-06-0818:59thhellerif you want to replace files: no, that is not possible#2018-06-0818:59richiardiandreayep ok, sorry should have asked better...only in dev mode, not for :release#2018-06-0819:00thhellerwill need to drop to deps.edn or lein for that#2018-06-0819:00thhellerI consider it a horrible anti-pattern so I won't add support for that#2018-06-0819:00thhelleryou can do it fine via lein or deps.edn though#2018-06-0819:00richiardiandrea@thheller so my next q. would be, is there :aliases in :release#2018-06-0819:01richiardiandreaI see it global only#2018-06-0819:01thhelleryes classpath applies globally#2018-06-0819:01thhellershadow-cljs -A:release --force-spawn release your-app#2018-06-0819:01richiardiandreaso if it is an antipattern, maybe I can ask if there a better way to do the following 😄#2018-06-0819:02richiardiandreaI have the classic my-org.dev namespace that uses the dotenv library to load environment variables only when using the REPL#2018-06-0819:02richiardiandreaI don't wont to use it in :release, so I added:
(when goog.DEBUG
  (dev/load-env-vars!))
#2018-06-0819:03richiardiandreabut I see that I have to require it...which indeed feels like an anti-pattern#2018-06-0819:03richiardiandreait is kind of a :preload#2018-06-0819:03thhellerdev stuff you can easily load via :preloads#2018-06-0819:03richiardiandreayeah maybe I should do that#2018-06-0819:05thhellerI should really write down my recommended way to inject "runtime" config#2018-06-0819:05richiardiandreadefinitely#2018-06-0819:05thhellerbrowser app?#2018-06-0819:05richiardiandreano, node server app#2018-06-0819:05thhellerah thats probably the easier solution of them all#2018-06-0819:06thheller(defn main [config-path] (let [config (-> (fs/readFileSync config-path) str (reader/read-string))] ...))#2018-06-0819:06richiardiandreaI use env vars, I just need to load them from somewhere#2018-06-0819:06richiardiandreayeah...i do something similar#2018-06-0819:06thhellerthen call with node server.js dev-config.edn#2018-06-0819:07thhelleror node server.js prod-config.edn ...#2018-06-0819:07richiardiandreawe prefer env vars here 😄#2018-06-0819:07thhellerno nasty env vars in your compiler output#2018-06-0819:07richiardiandreabut I see your point#2018-06-0819:07thhellerbut with node you can easily access env vars? why include them at compile time?#2018-06-0819:07richiardiandreayes I can, I just need to load them at runtime for REPL dev#2018-06-0819:08richiardiandreaI think :preloads is fine#2018-06-0819:08richiardiandreabut the dev folder will need to always be on the classpath#2018-06-0819:08thhellerI don't understand, why do you need to load them at runtime for REPL dev?#2018-06-0819:09richiardiandreabecause I need them for running 😄#2018-06-0819:09richiardiandrealike DB connection and all that#2018-06-0819:09thhellerassuming you are using :target :node-script?#2018-06-0819:09richiardiandreaat the moment it is :node-library#2018-06-0819:10thhellersame thing ... you are starting the node process do you not?#2018-06-0819:10thhelleror are you using (shadow/node-repl)?#2018-06-0819:10richiardiandreaI am starting it with node-repl#2018-06-0819:10richiardiandreaor similar thing 😄#2018-06-0819:11thhellerso would (shadow/node-repl {:node-env {"hello" "world"}}) help? (adding extra env vars to the node process so js/process.env.hello works?#2018-06-0819:12richiardiandreasomething like that would definitely help...but dotenv is kind of nice because it automagically reads from .env the variables#2018-06-0819:12thheller(shadow/node-repl {:node-env (read-from-dotenv)})?#2018-06-0819:13thhellernever heard of dotenv#2018-06-0819:13richiardiandreaah ah 😄#2018-06-0819:13richiardiandreayeah I mean it's a JS thing right?#2018-06-0819:14thhellerI don't know? what is it?#2018-06-0819:14thhellerhttps://github.com/rentpath/clj-dotenv has a big fat [DEPRECATED]?#2018-06-0819:14richiardiandreauhm#2018-06-0819:16richiardiandreaprobably shadow should have its own way of loading vars and I can use that instead, I can drop dotenv actually. it could be env.edn or something#2018-06-0819:17thhellerI'm still trying to understand what problem you are actually trying to solve though#2018-06-0819:17richiardiandreaok so#2018-06-0819:17thhellerI still have no idea what the actual problem is#2018-06-0819:17richiardiandreamy server has to connect to the db#2018-06-0819:17richiardiandreaat runtime in production, env vars will be set for it#2018-06-0819:17richiardiandreaat runtime in the repl, I need a way to load env vars#2018-06-0819:18thhellerso your code uses something like js/process.env.DB?#2018-06-0819:18richiardiandreayep#2018-06-0819:18richiardiandreawe don't like config files here for now 😄#2018-06-0819:18richiardiandreadon't ask me why 😉#2018-06-0819:19thhelleryou do ... they are just config files for bash or something like that#2018-06-0819:19thhellergotta be written down somewhere 😉#2018-06-0819:19thhellerok assuming that dotenv is just a npm lib I think :preloads is the best option#2018-06-0819:20richiardiandreayeah, so again the problem would be that that code should not leak to production#2018-06-0819:20richiardiandreathat is why normal clj/cljs you would use an clj alias#2018-06-0819:20thheller:preloads are never included in release builds?#2018-06-0819:21richiardiandreaoh cool#2018-06-0819:21richiardiandreaand i guess the namespace will be trimmed#2018-06-0819:21richiardiandreaif not required#2018-06-0819:21thhellerif its not required anywhere (besides :preloads) then it won't even be compiled in release#2018-06-0819:22richiardiandreaawesome#2018-06-0819:22thheller{:target :node-library :exports .... :devtools {:preloads [my-org.dev]}}#2018-06-0819:23richiardiandreaperfect sorry if it took so long 😉#2018-06-0819:23thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2018-06-0819:23thhellerI understand why you want to use separate :source-paths in CLJS usually#2018-06-0819:24thhellerbut that is not an issue in shadow-cljs since it won't just randomly include stuff just because its on the classpath#2018-06-0819:24richiardiandreaoh that's exactly what I need 😄#2018-06-0819:24richiardiandreano random mess#2018-06-0820:15richiardiandreaOther q. 😄 I connected to a REPL with nrepl-select in emacs, and I have a server in another window that compiles. Is there a way to stop receiving the compilation logs in the nrepl-select-ed buffer?#2018-06-0820:17thhellerwell the watch messages appear wherever the watch was started#2018-06-0820:18thhellernrepl-select has nothing to do with those messages#2018-06-0820:18thhellerI think cider is just setup to always do watch+select#2018-06-0820:24richiardiandreaNo I am doing it manually#2018-06-0820:24richiardiandreaI have a watch in the terminal#2018-06-0820:24richiardiandreaThen I connected with a nrepl-select#2018-06-0820:24richiardiandreaThe messages are visible in the buffer in emacs#2018-06-0820:25richiardiandreaSo you are saying it is not expected?#2018-06-0820:27thhellerwhich messages are we talking about?#2018-06-0820:27thhellerit is not expected to get random messages no?#2018-06-0820:28richiardiandreaI receive watch messages in my buffer#2018-06-0820:28thhellerplease give me an example of a message you get#2018-06-0820:28richiardiandreaWatch was started in a terminal#2018-06-0820:28thhellerthere are a gazillion messages, no idea what you mean by watch messages#2018-06-0820:28richiardiandreaOh ok right so compilation warnings#2018-06-0820:29thhellerplease just paste one example 😛#2018-06-0820:29richiardiandreaKk I was afk let me go and do it#2018-06-0820:30richiardiandrea
user> (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :init-store)(shadow/nrepl-select :init-store))
To quit, type: :cljs/quit
[:selected :init-store]
JS runtime disconnected.
JS runtime connected.
JS runtime disconnected.
JS runtime connected.
JS runtime disconnected.
JS runtime connected.
[:init-store] Compiling ...
[:init-store] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /home/arichiardi/git/laputa/lambda-cqrs/src/ep_cloud/init_store.cljs:23:3
--------------------------------------------------------------------------------
  20 | 
  21 |   This function is idempotent, you can call it multiple times."
  22 |   [ctx request]
  23 |   (let [azure-callback
---------^----------------------------------------------------------------------
Call to cljs.core/let did not conform to spec
-- Spec failed --------------------

  ([... ... (partial ... ...) ... ... ... ...] ... ...)
             ^^^^^^^

should satisfy

  vector?
...
#2018-06-0820:31thhellerI very clearly see a (shadow/watch :init-store) there?#2018-06-0820:31richiardiandreaOh crap lol#2018-06-0820:32richiardiandreaI was sure I did not use it :(#2018-06-0820:33richiardiandreaSorry for the noise ;)#2018-06-0823:15richiardiandreaso is there a "watch test" mode in shadow by any chance?#2018-06-0823:38richiardiandreaI have a problem cause the tests are there but it does not seem to pick them up#2018-06-0900:46richiardiandreasolved, opened a PR for the error#2018-06-0915:59lilactownI’m working on a bunch of macro stuff right now in CLJ-land, and I’m having trouble getting shadow-cljs to pick up my changes#2018-06-0916:03lilactownatm I have a dependency tree something like
workshop.cljs
 |
 -> react.cljs
    |
    -> react.clj
       |
       -> compiler/core.clj
          |
          -> compiler/parser.clj
          |
          -> compiler/analyzer.clj
          |
          -> compiler/generator.clj
#2018-06-0916:04lilactownchanges to react.clj trigger a recompile/hot load, but changes to transitive dependencies (e.g. compiler/core.clj or beyond) do not trigger a recompile and seem to require a restart to pick up changes#2018-06-0916:05thheller.clj files are never followed#2018-06-0916:05thhelleronly the initial one counts#2018-06-0916:05thhellerwhy not just develop the macros at the REPL?#2018-06-0916:05thhellerCLJ REPL I mean#2018-06-0916:08lilactownI did initially just work in a CLJ repl on the compiler, but there’s some hairiness that I’m trying to diagnose that I’m not seeing in my REPL
#2018-06-0916:11thhellerI guess the macro tracking could be improved but would be a bit of work#2018-06-0916:12lilactownyeah. I guess I was just wondering if there was a way that I could get it to reload without restarting the shadow-cljs process?#2018-06-0916:12lilactownwould reloading at the REPL work?#2018-06-0916:13thhelleruse the REPL. literally the only reason to restart is changing dependencies, nothing else requires a restart#2018-06-0916:14thhellerwon't have much time to work on anything shadow-cljs related the next few weeks#2018-06-0916:15thhellerbut open a ticket so it doesn't get lost#2018-06-0916:16lilactownok np. I appreciate all the help 😄#2018-06-0916:43richiardiandrea@lilactown (require-macros ns : reload) or :reload-all should work. It usually reads the source on disk and loads it#2018-06-0916:44thhellerrequire-macros isn't actually supported currently#2018-06-0916:44richiardiandreaOh really#2018-06-0916:45richiardiandreaSo does that mean that shadow cannot compile vanilla cljs code? I am asking because I wanted to use it in an existing project#2018-06-0916:46richiardiandreaOr not supported at the REPL only?#2018-06-0916:46thheller(require-macros ..) iis a REPL only thing#2018-06-0916:47thheller:require-macros is fully supported#2018-06-0916:47thhellertwo very different things though#2018-06-0916:48richiardiandreaWell... implementation might be different...but they kind of do the same thing no?#2018-06-0916:48thhellerno#2018-06-0916:49richiardiandreaHow come?#2018-06-0916:49richiardiandreaFrom a user of the language perspective what is the difference?#2018-06-0916:49thhellerI don't know what you are asking#2018-06-0916:50thhellerif you want (require-macros 'the.macro :reload-all) literally just open a CLJ REPL and (require 'the.macro :reload-all)#2018-06-0916:50thheller:require-macros in the ns is metadata#2018-06-0916:50richiardiandreaOf course#2018-06-0916:50thhellerit does absolutely nothing by itself#2018-06-0916:51richiardiandreaMetadata always does something or it wouldn't be there in the first place#2018-06-0916:51thhelleryes ... it will cause the compiler to load the macro ns. in that sense they achieve the same thing#2018-06-0916:52thhellerwhat I mean thought is that require-macros actually evals code#2018-06-0916:52thheller:require-macros does nothing until the compiler is actually ready to do something#2018-06-0916:52thhellerso everything happens at a different time and stuff#2018-06-0916:52richiardiandreaOk got it#2018-06-0916:54thhellertrivial to add#2018-06-0916:54thhellerthe only reason require-macros isn't supported is because I have never needed it#2018-06-0916:54thhellerfeel free to open a ticket if you want it#2018-06-0916:55thhellerto me macros are clojure code so I develop them at a clojure REPL. might just be me though#2018-06-0917:13mj_langfordHow many people are using shadow-cljs for backend node based servers?#2018-06-0917:17richiardiandrea@mj_langford I have just started that#2018-06-0917:21richiardiandreaSome bumps with cider, but the rest is pretty good#2018-06-0918:17lilactownWe've been using it at work for about 4 months now#2018-06-0918:17lilactownPretty solid#2018-06-0919:03mj_langfordIs this the "goto" page you use for imports from JS codebases? https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-06-0923:07jefffriesenHi. Has anyone gotten a react virtualized component working with a direct npm import like shadow-cljs recommends? There’s the start of an example but it doesn’t quite go far enough… https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-06-0923:07jefffriesenI’m trying to get something rendering like this:
import React from 'react';
import ReactDOM from 'react-dom';
import { Column, Table } from 'react-virtualized';
import 'react-virtualized/styles.css'; // only needs to be imported once

// Table data as an array of objects
const list = [
  { name: 'Brian Vaughn', description: 'Software engineer' }
  // And so on...
];

// Render your table
ReactDOM.render(
  <Table
    width={300}
    height={300}
    headerHeight={20}
    rowHeight={30}
    rowCount={list.length}
    rowGetter={({ index }) => list[index]}
  >
    <Column
      label='Name'
      dataKey='name'
      width={100}
    />
    <Column
      width={200}
      label='Description'
      dataKey='description'
    />
  </Table>,
  document.getElementById('example')
);
#2018-06-0923:09jefffriesenHere’s mine:
(ns simple.virtual-table
  (:require ["react-virtualized" :refer (Table Column)]))
(enable-console-print!)

(def rows
  [{:name "brian vaughn" :description "one"}
   {:name "brian vaughn" :description "two"}
   {:name "brian vaughn" :description "three"}
   {:name "brian vaughn" :description "four"}
   {:name "brian vaughn" :description "five"}
   {:name "brian vaughn" :description "six"}])


(defn react-virtualized-table []
  [:div
   [:h3 "React Virtualized Table"]
   [:> Table {:headerHeight 30
              :height 300
              :rowCount 5
              :rowGetter (fn [m] 
                            (get rows (aget m "index")))
              :rowHeight 50
              :width 400
              }
      [:> Column {:label "Name"
                  :dataKey "name"
                  :width 100}]
      [:> Column {:label "Description"
                  :dataKey "description"
                  :width 100}]
    ]])
#2018-06-0923:09jefffriesenI get the table rendering with rows and columns, but the columns empty#2018-06-0923:11jefffriesen
<div class="ReactVirtualized__Table__rowColumn" role="gridcell" title="" style="flex: 0 1 100px; overflow: hidden;"></div>
#2018-06-0923:12jefffriesenAnyone have luck with this? All examples online (for most npm components) use cljsjs like this one: https://gist.github.com/crankyadmin/cd2a22ecfe4068a94e6800f5a9349811#2018-06-1007:04thheller@momoblackblack in the :rowGetter fn you are returning a clojure map from rows which react-virtualized then will try to row["name"] via :dataKey I think. the other example you linked does clj->js which you are missing.#2018-06-1009:59henrikThis message popped up all of the sudden. SHADOW import error […]/resources/server/cljs-runtime/shadow.js.shim.module$ws.js I solved it with yarn add ws. Is this normal?#2018-06-1010:02thhellerhmm I very recently made it optional to install shadow-cljs in your project#2018-06-1010:02thhellerdo you only have the shadow-cljs installed globally?#2018-06-1010:02thheller(shadow-cljs depends on the ws package so it should be installed)#2018-06-1010:03henrikGlobally, yes. I’ll remove it and reinstall it, see if that shakes things up.#2018-06-1010:03thhellerto be safe add it to your project#2018-06-1010:03thhellernpm install --safe-dev shadow-cljs#2018-06-1010:21henrikStill, three days of fiddling with cljs settings, and now it just works.#2018-06-1010:21henrikClearly sorcery. Burn him. He’s a witch.#2018-06-1010:22thhellerhaha 🔥😎#2018-06-1010:47biscuitpantsanyone ever get an error like this?
➜  Monolith git:(mw-jest-tests) ✗ shadow-cljs compile app
shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Monolith/shadow-cljs.edn  cli version: 2.4.0  node: v9.5.0
shadow-cljs - starting ...
12:46:16.597 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
12:46:17.773 [main] DEBUG shadow.cljs.devtools.api - starting runtime instance
[:app] Compiling ...
ExecutionException: java.lang.NoClassDefFoundError: com/google/common/collect/Streams
	java.util.concurrent.FutureTask.report (FutureTask.java:122)
	java.util.concurrent.FutureTask.get (FutureTask.java:192)
	clojure.core/deref-future (core.clj:2292)
	clojure.core/future-call/reify--8097 (core.clj:6894)
	clojure.core/deref (core.clj:2312)
	clojure.core/deref (core.clj:2298)
	clojure.core/map/fn--5587 (core.clj:2745)
	clojure.lang.LazySeq.sval (LazySeq.java:40)
Caused by:
#2018-06-1010:48thhellerprobably a dependency conflict with guava#2018-06-1010:48biscuitpantsah#2018-06-1010:48thhellerIIRC datomic bring a different version than the closure compiler wants#2018-06-1010:49thheller[com.google.guava/guava "22.0"] is required#2018-06-1010:49biscuitpantsokay, trying that now, thank you#2018-06-1010:49biscuitpantsnice, getting further, thank you 🙂#2018-06-1010:49biscuitpantsforgot about that dependency conflict and Datomic#2018-06-1010:50thhellerdatomic doesn't support CLJS so you can probably remove that?#2018-06-1010:50biscuitpantstransitive dependency…#2018-06-1116:06jefffriesen@thheller Thanks for the suggestion on getting react virtualized working. It was missing clj->js.#2018-06-1117:56spiedenthat still bites me from time to time. with react stuff i seem to end up needing it sometimes and others not#2018-06-1118:41justinlee@spieden it probably feels that way because a bunch of the reagent adapters call the converter functions for you, but with callback heavy libraries like react virtualized, you interface directly with the library and you tend to need to deal with marshaling directly#2018-06-1118:51spiedenah i see#2018-06-1119:47tungstenis there a write-up anywhere of how shadow-cljs does NPM modules better than the normal cljs compiler?#2018-06-1120:16justinleehttps://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d#2018-06-1120:16justinlee@bfast ^^#2018-06-1120:16justinleeyou might just check out the table at the end for the tldr#2018-06-1123:30richiardiandreaI have a strange error that I have never seen before: I have two different :node-library built with shadow and I try to require them in node:
> var h1 = require ("./init-store")
...a bunch of SHADOW load...
> var h2 = require ("./query-events")
#2018-06-1123:30richiardiandreabut the second require throws#2018-06-1123:31richiardiandrea
SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs.spec.alpha.js
Error: No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object]
    at SHADOW_IMPORT_PATH (/home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:5:26)
    at /home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:3033:1
    at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/lambda-cqrs/query-events/index.js:65:44)
    at /home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/spec/alpha.cljs:1334:1
    at Object.cljs$spec$alpha$def_impl [as def_impl] (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/spec/alpha.cljs:297:3)
    at Function.cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4 (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:4470:7)
    at Function.cljs.core._swap_BANG_.cljs$core$IFn$_invoke$arity$4 (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:854:1)
    at Object.cljs$core$missing_protocol [as missing_protocol] (/home/arichiardi/git/laputa/lambda-cqrs/query-events/cljs-runtime/cljs/core.cljs:312:3)
> 
#2018-06-1123:31richiardiandreahas anyone seen this error?#2018-06-1123:31richiardiandreait looks like some global state there gets in the way#2018-06-1123:33richiardiandreawill open an issue#2018-06-1205:45thheller@richiardiandrea you should only ever be loading one :node-library per node process (during development). if you need 2 use :npm-module#2018-06-1214:55richiardiandreaThanks will try that today and will also try to see if I can change :azure-fn.#2018-06-1209:49henrikShould this theoretically reload a CSS file placed in ../public/css/main.css? (I’m not using the bundled server)
:builds {:client {:output-to "../public/js/main.js"
                   :output-dir "../public/js"
                   :target :browser
                   :asset-path "/js"
                   :modules {:main {:entries [landing-page.client.core]}}
                   :devtools {:watch-dir "../public"
                              :after-load landing-page.client.core/run}}}}
#2018-06-1209:58thhellerif you are using /css/main.css in your html yes#2018-06-1209:58thhellerif you use css/main.css no#2018-06-1210:08henrikYup: [stylesheet "/css/main.css"]#2018-06-1210:08henrikThough there is no index.html, it’s entirely generated. And served with firebase serve.#2018-06-1210:09thhellerhmm what does [stylesheet ..] emit?#2018-06-1210:10henrikIt’s just a small helper function:
(defn stylesheet
  "Particle for defining a stylesheet."
  [href]
  [:link {:href href
          :rel "stylesheet"}])
#2018-06-1210:10thhellerhmm that should work#2018-06-1210:10henrik<link href="/css/main.css" rel="stylesheet">#2018-06-1210:10thhelleryeah thats exactly what the code looks for#2018-06-1210:11henrikOK, well, good to know that it should work, then it’s probably my fault somewhere#2018-06-1210:12thhelleroh. are you on windows by any chance?#2018-06-1211:07henrikNo macOS. I’ll rummage around a bit and see if I can get it to work. Otherwise I’ll try to produce a minimal case. The ../ shouldn’t make a difference, should it?#2018-06-1211:09thhellerit might. will check.#2018-06-1211:19thheller../ indeed was the problem. fixed in 2.4.2#2018-06-1211:26henrikYep, works fine now. Thank you!#2018-06-1211:27henrikThe ../ is because I had to put src in a weird place to not make firebase-functions have a huge hissy fit.#2018-06-1210:12thhellerjust noticed that it isn't working for me either when running windows#2018-06-1210:13thhellerthe "update" message is {:type :asset-watch, :updates ["/css\\foo.css"]}#2018-06-1210:13thhellerso the path is invalid#2018-06-1210:13thhellerworks when running in wsl but not windows#2018-06-1210:15thhellerwill fix https://github.com/thheller/shadow-cljs/issues/305#2018-06-1210:41kurt-o-sysI have been able to import many npm libs already, but I seem to fail on this one: https://github.com/wwayne/react-tooltip it looks pretty straight forward, so I guess I must be overlooking something really stupid:
import ReactTooltip from 'react-tooltip'
<ReactTooltip />
in cljs (using shadow-cljs):
(:require ...
            ["react-tooltip" :default ReactTooltip])
[:> ReactTooltip>
However, ReactTooltip is undefined (when do (js/console.log ReactTooltip)). Why would ReactTooltip be undefined?
#2018-06-1210:41thheller@kurt-o-sys try :as ReactTooltip. sometimes the code is packaged as commonjs which doesn't have default exports.#2018-06-1210:43kurt-o-sysoh right... you already told me before. I have to write it down somewhere 😛 Thx!#2018-06-1210:43thhelleractually I should write that down too 😉#2018-06-1210:45kurt-o-sys😉#2018-06-1211:08thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2018-06-1211:23kurt-o-sys:+1:#2018-06-1220:56mynomotoIs there a way to use jars from a private s3 from shadow-cljs with something like https://github.com/s3-wagon-private/s3-wagon-private?#2018-06-1220:57thhellerif you used :repositories config in project.clj the config is identical to that#2018-06-1220:57thhellerI have not used it myself but it seems to work#2018-06-1220:58mynomotoOk, I will try that, thanks!#2018-06-1220:58thheller:repositories {"thing" {:url ... :username #shadow/env "AWS_ACCESS_KEY"}}#2018-06-1220:59thheller#shadow/env looks up the env variable and uses that in the config#2018-06-1221:25mynomotore-frame-10x doesn't work after moving to lein. Is that a known problem? The required namespace "day8.re-frame-10x.preload" is not available.#2018-06-1221:49danielcompton@mynomoto how are you adding s3 wagon to your build?#2018-06-1221:54mynomotoI'm on commute ATM, I think I only be able to continue debugging tomorrow.#2018-06-1222:00mynomotoI may have misunderstood how to use lein with shadow.#2018-06-1222:51danielcomptonI don't know if s3-wagon-private would work with Shadow cause it would need to be loading a JVM to download the dependencies#2018-06-1222:51danielcomptonas it hooks into Aether#2018-06-1222:51danielcomptonHow does Shadow download dependencies? Just making the HTTP calls itself?#2018-06-1307:02kurt-o-sysAnother question @thheller: if I have a npm package which embeds css, it seems to fail to import/require the css. For example: draft.js, in ES:
import 'draft-js-static-toolbar-plugin/lib/plugin.css'
import 'draft-js/dist/Draft.css'
If I require both in cljs, the css doesn't seem to be added. Is this the normal behaviour? If so, the best way would be, I assume, to add the css file to index.html?
#2018-06-1307:35kurt-o-sys@mynomoto I only got 10x dev working on shadow-cljs, never on lein (well, not if I wanted to add other npm-libraries, which was pretty much a mess)#2018-06-1309:12thheller@kurt-o-sys .css stuff is currently not supported but might come at a later date. until then you need another way to bundle your css. unfortunately some JS libs are designed with the expectation of webpack being used and adding all the weird conventions that entails is a bit time consuming#2018-06-1309:12kurt-o-sysok... makes sense, thx.#2018-06-1309:13kurt-o-sysso, adding to index.html will do#2018-06-1309:13thheller@danielcompton deps are done via https://github.com/cemerick/pomegranate so the exact same lib that lein or boot use. it is done via a standalone uberjar via shadow-cljs-jar launched before the actual JVM. its is basically only a very tiny wrapper using pomegranate, see https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs-jar/src/shadow/cljs/npm/deps.clj#2018-06-1309:21thheller@kurt-o-sys index.html probably won't have access to node_modules/draft-js/dist/Draft.css so probably need to copy it manually#2018-06-1309:22kurt-o-sys@thheller right... well, I can just add https://cdnjs.com/libraries/draft-js#2018-06-1309:23kurt-o-sysno need to copy.#2018-06-1309:23thhelleryeah that works too#2018-06-1311:16kurt-o-syswill script it to fetch css from downloaded npms#2018-06-1313:25kurt-o-sysok, well, if you ever need external npms and you use http://blob.tomerweller.com/reagent-import-react-components-from-npm , it won't work to add 10x. The reason being: you'll take out reactjs to webpack, and 10x will not find react on startup (or someting like that). In shadow-cljs, it's no issue, since shadow-cljs inverts the logic (compile cljs to js and add it to a normal npm project - lein and boot try to embed js in their own compilation, which makes the google closure compiler cry for many npm packages). That's, at least, how I think it is 😛.#2018-06-1313:30mynomoto@kurt-o-sys I mean using lein to call shadow https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen I was hoping almost nothing would change except who creates the classpath and manage dependencies.#2018-06-1313:30thheller@mynomoto yes nothing else changes#2018-06-1313:31thheller:source-paths and :dependencies move to project.clj basically. that is it.#2018-06-1313:31kurt-o-sysright, that's it. That's what I do as well 🙂#2018-06-1313:31kurt-o-sysand add :lein true to shadow-cljs 😛#2018-06-1313:31thhellerright#2018-06-1313:32mynomoto@kurt-o-sys is that setup that you were refering to about not getting re-frame-10x to work?#2018-06-1314:12mynomotoLooks like shadow can check the artifact on a private s3 maven but cannot fetch it whan adding :repository. That way I can fetch the dependency using lein and run using only shadow. Adding a :plugins seems to make no difference.#2018-06-1314:28thhellermaybe its enough if I add the s3-wagon-private stuff to the classpath? no idea how this works#2018-06-1314:28thheller(classpath of the deps tool that is)#2018-06-1314:30thhellerbest to stick with lein for now#2018-06-1316:05mynomotoI think I got a good tradeoff, using lein to only fetch the dependency and shadow can go from there. I think it's interesting that it can check the dependency but not download it, but I may be misunderstanding what's going on.#2018-06-1316:16thhellermaven works by always looking at ~/.m2 first so if all the deps are there there is no need to ever talk to s3. so yeah this works but using the lein interop is probably best since you otherwise need to manually sync the deps in shadow-cljs.edn and project.clj#2018-06-1316:32mynomotoIt's only one or two deps, and calling from lein is breaking re-frame-10x and I'm more willing to keep things in sync than debugging that. The odd thing is that without adding the :repositories key it doesn't work even with the dependency cached on ~/.m2 It complains that cannot find metadata.#2018-06-1316:35thhellerbreaking re-frame-10x does not make sense. it should still work if your dependencies are identical#2018-06-1316:35thhellerlein literally just constructs your classpath, nothing more.#2018-06-1316:35thhellerit may be a dependency conflict however#2018-06-1319:19richiardiandrea@afhammad I don't think that is possible, how can it run in the browser then?#2018-06-1319:19richiardiandreaI mean, you are use fs, which is node specific#2018-06-1319:23afhammadusing js/require seems to work for the same package, i thought shadow would be smart to use an appropriate import depending on the target#2018-06-1319:24richiardiandreaoh well, I am not 100% that works, let's wait for better answers#2018-06-1319:24afhammadthanks#2018-06-1319:38justinleeI believe it would have to do static analysis on the clojurescript code to make that work. presumably, that’s why you do this in the namespace forms instead of in the middle of arbitrary clojurescript code: the ns form is designed to be analyzed statically#2018-06-1319:40justinleeon node targets, it can just load the javascript dynamically whenever it encounters the require#2018-06-1319:42justinleethis is why you end up with the immense complexity of webpack: it’s trying to figure out what to do given that you can stick a require anywhere#2018-06-1319:54thheller@afhammad js/require is just a regular function call and not indexed by shadow-cljs. fs is a node only package, you will get a shim if you (:require ["fs" :as fs]) in a browser build but that does not support using fs.readFileSync#2018-06-1319:54thhellernode-only functionality is not available in the browser no matter how you package it#2018-06-1320:00justinleewell, unless you do what webpack does and simulate the functionality. 🙂#2018-06-1320:03thhellerthat is what I do#2018-06-1320:04thhellerdoesn't change the fact that fs.readFileSync cannot possibly work in the browser#2018-06-1320:04thhellerwebpack uses these https://github.com/webpack/node-libs-browser and so does shadow-cljs#2018-06-1320:10justinleebut you’re not going in an looking for requires and then re-writing them, are you? webpack does that. (I wouldn’t think that would be something you’d want to do)#2018-06-1320:11thhellerI'm confused. what are we talking about?#2018-06-1320:12thhellerjs/require is never processed no but webpack does#2018-06-1320:12thhellerfs.readFileSync doesn't work in either case#2018-06-1320:17richiardiandrea@thheller a question about a shadow resource: does this look right?
{:cache-key [1528920986368],
   :output-name "index.js",
   :resource-id
   [:shadow.build.targets.azure-fn/fn-index "query-events$index.js"],
   :resource-name "query-events$index.js",
   :type :js,
   :source "module.exports = blax",
   :last-modified 1528920986368,
   :requires #{ep-cloud.query-events},
   :provides #{}}
#2018-06-1320:17justinleesorry ignore me. i’m making a stupid point.#2018-06-1320:17richiardiandreait is not outputed in the filesystem and maybe I am doing something wrong#2018-06-1320:19thheller@richiardiandrea uhm looks good but what are you trying to do?#2018-06-1320:19richiardiandreaI would like to write to fn-name/index.js#2018-06-1320:19thhellerresource creation is only useful if you need something to be compiled#2018-06-1320:19richiardiandreaoh#2018-06-1320:19richiardiandreaok#2018-06-1320:19richiardiandreadoes not need to be compiled a guess#2018-06-1320:20richiardiandreaI saw :source there and though I could paste my own JS 😄#2018-06-1320:20thhelleryou can but the resource itself does nothing. it needs to be required somewhere to become part of the compilation and output#2018-06-1320:20thhellerI was going to do some azure-fn stuff now#2018-06-1320:21richiardiandreaI can push what I have if you want to have a look#2018-06-1320:21richiardiandreaI was implementing what you were describing#2018-06-1320:21thhelleryeah I can take a look if you are on the correct path#2018-06-1320:21richiardiandreakk#2018-06-1320:22richiardiandreafeel free to discard everything if not 😄#2018-06-1320:23spiedeni’ve been having great success translating ES6 into shadow-cljs require forms, but how about something like this:
var FileSaver = require('file-saver');
#2018-06-1320:23thhellerthe funcpack stuff that was mentioned looks like its just webpack. could be useful as a hook though#2018-06-1320:23spiedenES6 imports that is#2018-06-1320:23thhellerthats not es6? (:require ["file-saver" :as FileSaver]) should do it#2018-06-1320:24richiardiandreayeah but I am not sure we need it, in any case it is good that you have a look and you validate#2018-06-1320:24spiedenok thanks#2018-06-1320:24richiardiandrea@spieden sorry crossed wires 😄#2018-06-1320:24spiedeni’m blissfully ignorant of js packaging =)#2018-06-1320:28thheller@richiardiandrea do you think a namespace per fn makes sense or would you want to put multiple fns into the same ns? (referring to :azure-fn or course)#2018-06-1320:29richiardiandreaI think it makes sense...but I am passing :fn map as is to :exports so probably what you say is still supported?#2018-06-1320:30richiardiandrea(using :node-library target at the moment - maybe not the right one)#2018-06-1320:30thhellerunrelated to that. if we only allow one fn per ns we can abuse :modules better#2018-06-1320:30thhellerbut I guess thats not useful if everything is loaded all at once anyways#2018-06-1320:31richiardiandreaYeah#2018-06-1320:43thheller:azure-fn doesn't really fit anymore when using multiple fns#2018-06-1320:43thheller:azure-fns or :azure-app or something else maybe better?#2018-06-1320:45richiardiandrea@thheller yep sure#2018-06-1320:46richiardiandreaI meant to change that as well after getting it up and running#2018-06-1320:46richiardiandreaazure-app feels better#2018-06-1320:48thheller@richiardiandrea yep picked that. master has the updated version. your stuff went kind of the wrong direction making things more compilcated then needed#2018-06-1320:51richiardiandrea@thheller can you print the structure of your app-dir ?#2018-06-1320:52richiardiandreaI mean do you have one subfolder per function?#2018-06-1320:53thheller
.
├── cljs
│   └── shared.js
├── host.json
├── local.settings.json
└── simple
    ├── function.json
    └── index.js
#2018-06-1320:54richiardiandreaUhm, i just don't see where you map over the fn-map#2018-06-1320:54thheller
(defn do-flush [{::keys [fn-map] :as state}]
  (reduce-kv flush-fn-file state fn-map))
#2018-06-1320:54richiardiandreaOh that is where, cool#2018-06-1320:55richiardiandreaGotcha#2018-06-1320:55thhellerpushed another update that adds a check if the fn has :azure/* metadata and fails if missing#2018-06-1320:55thhellercould probably generate a better error#2018-06-1320:55thhelleralso fixed the caching thingo#2018-06-1320:56thhellertotal nonsense to optimize that but oh well#2018-06-1320:56richiardiandreaAwesome, will validate the work on master today and report back problems in case#2018-06-1320:56thhelleryou are using the azure fn v2 stuff right?#2018-06-1320:56thhellerI was testing with v1#2018-06-1320:56richiardiandreaYep v2#2018-06-1320:57richiardiandreaThe cross validation of function params would be cool at some point, but it needs some fiddling with bindings...not a priority for me now#2018-06-1320:58richiardiandreaWanted to get it working in func host by today though so thanks for you help#2018-06-1320:58richiardiandreaWill try after lunch#2018-06-1320:58thhelleryeah func host doesn't exist in my version#2018-06-1320:59thhellerfunc run simple works for the thing I built#2018-06-1320:59richiardiandreaOh right, wow#2018-06-1320:59thhellerwill try to test with v2 instead#2018-06-1320:59richiardiandreaWill try soon too#2018-06-1320:59thhellerjust saw the beta tag and decided to stick with "stable"#2018-06-1321:00richiardiandreaLearn a bunch of shadow today btw#2018-06-1321:00richiardiandreaVery clean approach to targets#2018-06-1321:01richiardiandreaEverything is spec-ed data, so like it#2018-06-1321:02thhelleryou could actually put the :azure-app target into a library. no reason for it to be in shadow-cljs itself#2018-06-1321:02thhellerbut the entire :target stuff is completely undocumented so I don't expect anyone to write targets just yet#2018-06-1321:03thhellerits easy to take the wrong path. your resource approach could eventually be done if things get more complex but for now its overkill.#2018-06-1321:29wilkerlucio@thheller I've been getting a lot of those lately:#2018-06-1321:29wilkerlucio
[:workspaces] Build failure:
FileNotFoundException: resources/public/js/workspaces/main.js (No such file or directory)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:270)
	java.io.FileOutputStream.<init> (FileOutputStream.java:213)
	 (io.clj:230)
	 (io.clj:230)
	 (io.clj:69)
	 (io.clj:166)
	 (io.clj:166)
#2018-06-1321:29wilkerlucioI get when I'm starting from a clean compilation, and then when I try again it works#2018-06-1321:30thhellerwhich target is that? probably just a missing (io/make-parents ...) call#2018-06-1321:30thhellerie. trying to write a file in a directory that wasn't created yet#2018-06-1321:30thhellermight be due to moving stuff into async recently#2018-06-1321:32wilkerlucioits a :browser#2018-06-1321:32thhelleryep found it#2018-06-1321:35thhellerthe :modules output can be written before the sources are flushed. only sources create the parent dirs, the modules did not#2018-06-1321:36thhellerexplains that the second pass works since the directory was created then#2018-06-1321:36wilkerlucioyeah, makes sense#2018-06-1321:43thheller@wilkerlucio pushed 2.4.3 which should fix the issue (async sure is fun, brought way more issues with it than I would have expected)#2018-06-1321:45wilkerlucioasync is good, and hard...#2018-06-1321:45wilkerlucioseems to be working now :+1:#2018-06-1322:13justinleesomething got a lot faster in 2.4. one of my files caused a nearly 6 second recompile now causes a 3 second recompile#2018-06-1408:12thhellerprobably the new async stuff for cache writes. They can be pretty expensive and are now done in a thread pool in parallel.#2018-06-1322:15richiardiandrea@thheller I see one thing that is odd, if I change the meta on the function, the data map from the compiler does not change#2018-06-1322:16richiardiandreait looks like it has to do with caching#2018-06-1322:17richiardiandrea(keeping the server running)#2018-06-1322:18richiardiandreawait now it changed...weird..#2018-06-1322:21richiardiandreaopened a PR for scriptFile#2018-06-1400:36richiardiandreaI have a problem with :azure-app while compiling with :simple
> var x = require("./query-events")
TypeError: $s$$.substring is not a function
    at Function.cljs.core.subs.cljs$core$IFn$_invoke$arity$2 (/home/arichiardi/git/laputa/lambda-cqrs/cljs/shared.js:9564:15)
#2018-06-1405:40levitanong@thheller is it possible for shadow-cljs to :closure js provider for one npm package, but :shadow everywhere else?#2018-06-1405:50thheller@levitanong no, always all or nothing#2018-06-1405:54levitanong😢#2018-06-1414:52henrygarnerI'm working on migrating a large app over to shadow, playing whack-a-mole migrating existing cljsjs dependencies to their npm equivalents. I've hit up against an issue with clipboard, which causes shadow to throw: > failed to resolve: ./clipboard-action from [redacted]/node_modules/clipboard/dist/clipboard.js > {:relative-to #object[java.io.File 0x624eb05d "[redacted]/node_modules/clipboard/dist/clipboard.js"], :entry "./clipboard-action"} > ExceptionInfo: failed to resolve: ./clipboard-action from [redacted]/node_modules/clipboard/dist/clipboard.js Here's the offending line: https://github.com/zenorocha/clipboard.js/blob/master/dist/clipboard.js#L506#2018-06-1414:53henrygarnerI'm not a front-end specialist, but the above looks fishy to me: the /dist directory doesn't contain clipboard-action.js, only /src does. But the /src dir isn't packaged into the module. Does this imply a bug in clipboards packaging: making relative reference to a file which doesn't exist?#2018-06-1415:51thheller@henrygarner which version is that? https://unpkg.com/clipboard@2.0.1/dist/clipboard.js doesn't seem to have that?#2018-06-1415:51thhelleroh wait, yes it does#2018-06-1415:54thhellerit is scary how bad some packages are built and webpack allowing it instead of complaining 😞#2018-06-1415:55thheller@henrygarner "clipboard/dist/clipboard.min.js" instead of just "clipboard" seems to work#2018-06-1416:10justinleeit occurs to me that people don’t actually program in any version of ecmascript anymore. they program in webpack.#2018-06-1416:20thhellerindeed 😞#2018-06-1417:49richiardiandrea@thheller your solution with munging is not working on my side#2018-06-1417:49richiardiandreabecause the umd helper exports the names unmunged#2018-06-1417:51thhelleroh indeed. I was 100% sure the code used munging#2018-06-1417:52richiardiandreaso either the umd starts munging or we use my fix with the array, or if you have any other approach I can work on it#2018-06-1417:52richiardiandreaI also pushed a PR with another fix for the dirs#2018-06-1417:55thhellerhmm I don't know whats best. I think munging makes more sense.#2018-06-1417:56richiardiandreayeah me too, but maybe it is going to cause massive breakage#2018-06-1417:57thhellerpeople using :node-library probably already use :exports {:someVar some.ns/some-var} or :exports {:some_var some.ns/some-var} so its probably ok#2018-06-1417:57thhellerdoubt that people really want require("./the-lib")["some-var"]#2018-06-1417:59richiardiandreayeah that is true#2018-06-1418:04thhelleradded the munge and merged your PR#2018-06-1418:06richiardiandreacool lemme try 😄#2018-06-1418:08thhellerI gotta go, be back later#2018-06-1418:08richiardiandreathanks for the quick fix#2018-06-1420:02nickmbaileyany advice on debugging “Timeout while waiting for REPL result.” while trying to require an internal namespace?#2018-06-1420:10thheller@nickmbailey see if the browser console shows an error#2018-06-1420:19nickmbaileyaha thanks#2018-06-1420:19nickmbaileydidn’t think to look there#2018-06-1420:25wilkerlucio@thheller I noticed that if my code triggers an error on reload (runtime), the shadow HUD stays on screen forever#2018-06-1420:42thhellerdidnt I fix that? thought I did#2018-06-1420:44wilkerlucioI'm in the latest shadow, so I think it still there#2018-06-1420:45thhellerok. please open an issue. will look into it.#2018-06-1420:45wilkerluciothanks#2018-06-1420:46thhellerah right. I only fixed it for errors in callback fns#2018-06-1420:46thhellerwonder what the behaviour should be. given that the before-load fns were already called#2018-06-1420:46thhellershould it call the after-load fns when the code fails to load or not?#2018-06-1420:47wilkerlucioI would expect it give some feedback and tell that some problem occurred during code load, and I think don't call after-load, like if it was a compilation warning#2018-06-1421:47kennyI have :http-port 3000 in my shadow config but when running shadow-cljs watch app it prints shadow-cljs - HTTP server for :app available at . Why does this happen? It appears the content is available at ports 3000 and 3001.
#2018-06-1422:18thheller@kenny if port 3000 is taken it will try 3001. so they may be an old instance hanging around at port 3000 or a different server using it#2018-06-1422:19kennyOh interesting. I would've expected a warning. I'll investigate.#2018-06-1503:09nickmbaileyI’m having trouble using javascript libraries from a browser repl with shadow-cljs. The following fails in a browser repl but works in a node repl.
[2:1]~cljs.user=> (require '[moment :as m])
nil
[2:1]~cljs.user=> (m)
ReferenceError: module$node_modules$moment$moment is not defined
#2018-06-1503:09nickmbaileyanyone know why the two would be different?#2018-06-1506:16thheller@nickmbailey hmm it works for me?
$ shadow-cljs browser-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn  cli version: 2.4.4  node: v9.4.0
shadow-cljs - connected to server
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (136 files, 35 compiled, 0 warnings, 6.93s)
[10:1]~cljs.user=> JS runtime connected.
[10:1]~cljs.user=> (require '["moment" :as m])
nil
[10:1]~cljs.user=> m
#object[g]
[10:1]~cljs.user=> (m)
#object[oa Fri Jun 15 2018 08:16:14 GMT+0200]
#2018-06-1506:38thheller@nickmbailey figured it out. there is a bug when you using a symbol instead of a string. (require '["moment" :as m]) works but (require '[moment :as m]) doesn't. https://github.com/thheller/shadow-cljs/issues/318 (fixed in 2.4.5)#2018-06-1512:31thhellerhttps://clojureverse.org/t/shadow-cljs-build-reports/2284#2018-06-1512:59wilkerlucio@thheller nice!#2018-06-1513:00wilkerlucioI was playing with it, and found a few things that might worth fixing:#2018-06-1513:00wilkerlucio1. sorting by name seems broken: https://www.dropbox.com/s/fggshabqdr8jv8j/Screenshot%202018-06-15%2010.00.21.png?dl=0#2018-06-1513:00wilkerlucio2. maybe its a mac problem, but see the outline on the header when I click, you can turn that off by css outline: none#2018-06-1513:02thhellerits the default react-table css but yeah that could be tweaked#2018-06-1513:03thhelleropen an issue please for any bugs or suggestions#2018-06-1513:03thhellerthis has been lingering for too long and should hopefully see more use now#2018-06-1513:07wilkerluciocool#2018-06-1513:08wilkerlucioI just tried running it, but got an exception:#2018-06-1513:08thhellerClosure version conflict#2018-06-1513:08wilkerluciodid cljs got updated or something?#2018-06-1513:08thheller[com.google.javascript/closure-compiler-unshaded "v20180610"]#2018-06-1513:09thhellerCLJS just got a new release yes but I haven't updated to that yet#2018-06-1513:09wilkerluciooh, ok, I was going to update that, but I think that would break as well right? 😛#2018-06-1513:09thhellerno that should just work#2018-06-1513:10thhellerdon't anticipate any breaking changes ... unlike Closure which seems to have a few with every release#2018-06-1513:16wilkerluciostill getting that error =/ bumped CLJS and Closure, double checked the lein deps, only the newest closure is there#2018-06-1513:17wilkerlucio
[org.clojure/clojurescript "1.10.312"]
                 [com.google.javascript/closure-compiler-unshaded "v20180610"]
#2018-06-1513:17thhellerand with CLJS 1.10.238?#2018-06-1513:18wilkerluciosame thing, I can't compile with the newest shadow at all anymore#2018-06-1513:18thhellerlein clean?#2018-06-1513:19thhellernever know what that might fix#2018-06-1513:19wilkerluciotried, also deleted .shadow-cljs, but still getting the same problem#2018-06-1513:20wilkerlucioI'm going to check again my deps, might be something there#2018-06-1513:21wilkerluciothe deps seem right, not sure what else to look for#2018-06-1513:22thhellerhmm just tried in a test project and everything is working fine#2018-06-1513:22wilkerlucioups#2018-06-1513:23wilkerlucioI was sure I had updated shadow, but seems not, and I was generating my deps list without shadow profile facepalm#2018-06-1513:24wilkerluciothanks for hanging with me on this, yeah, the issue was I forgot to update shadow in the project.clj#2018-06-1513:31wilkerluciobut coming back to the report, I got this now:#2018-06-1513:31wilkerlucio
shadow-cljs - config: /Users/wilkerlucio/Development/nubank/shuffle/shadow-cljs.edn  cli version: 2.4.5  node: v8.11.2
shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm run shadow.cljs.build-report app output.html
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
Failed reading cache for cljs.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 3964606])
 at [Source: (FileInputStream); line: 1, column: 3969231]
Failed reading cache for shuffle.chat.views.message: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 256687])
 at [Source: (FileInputStream); line: 1, column: 257415]
Failed reading cache for cljs.spec.gen.alpha: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 118722])
 at [Source: (FileInputStream); line: 1, column: 138937]
Failed reading cache for shuffle.chargeback.commons.purchases-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 180112])
 at [Source: (FileInputStream); line: 1, column: 184263]
Failed reading cache for cljs.stacktrace: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 74864])
 at [Source: (FileInputStream); line: 1, column: 126007]
Failed reading cache for shuffle.widgets.chargeback.ready.details: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 56211])
 at [Source: (FileInputStream); line: 1, column: 56715]
Failed reading cache for shuffle.chargeback.commons.chargebacks-widgets: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 42573])
 at [Source: (FileInputStream); line: 1, column: 45439]
Failed reading cache for fulcro.logging: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (FileInputStream); line: 1, column: 41860])
 at [Source: (FileInputStream); line: 1, column: 43739]
#2018-06-1513:32wilkerlucioI was hoping it ends at some point, but seems like it's just hanging now#2018-06-1513:32thhellerprobably just still compiling?#2018-06-1513:32wilkerluciomy CPU is low, but I'm waiting more, its been a couple minutes already#2018-06-1513:33thhellerhmm shouldn't take that long#2018-06-1513:33wilkerluciothis is a big app, does it usually takes much longer than release builds?#2018-06-1513:33thhellerno should be about the time of a release build (thats what it does in the background)#2018-06-1513:34wilkerlucioha, just finished 🙂#2018-06-1513:34thhellerthe source map parser however might be really slow in bigger apps?#2018-06-1513:34wilkerlucioand I can't see the time it took because of warnings and long output 😛#2018-06-1513:35thhellerwarnings should be gone on second try though?#2018-06-1513:37wilkerluciothats fine, I can time it out later, one thing I found strange is that I got a lot of blank entries, and I think it's missing a lot of files from the project#2018-06-1513:37wilkerluciomaybe it got the top ones#2018-06-1513:37wilkerluciobut it goes like this at some point: https://www.dropbox.com/s/x1du7j9a4ncjlkj/Screenshot%202018-06-15%2010.37.18.png?dl=0#2018-06-1513:37thhellerhmm thats weird indeed#2018-06-1513:38wilkerlucioI counted here, 676 blank lines#2018-06-1513:42thhellervery strange#2018-06-1515:29nickmbailey@thheller awesome! thanks for the quick fix#2018-06-1515:31levitanong@wilkerlucio @thheller that happens to me when i use https://date-fns.org/. Its structure is several smaller sub-folders that can each be separately required, so I assume when shadow tries to find out the library name, it doesn’t actually find anything.#2018-06-1515:36thheller@levitanong thx, there indeed seems to be something funky in there. filenames however seem to work fine, its just missing the package name/version#2018-06-1515:40levitanongYeah, if i open it up the dropdown, it works fine.#2018-06-1516:42richiardiandreaso @thheller I don't remember if I can or cannot at the moment have multiple entry points in the same namespace for :azure-app #2018-06-1516:44colindresj@thheller any idea how one might use rebel readline with the shadow-cljs clojurescript repl?#2018-06-1516:52thheller@richiardiandrea you can. currently no code splitting is performed#2018-06-1516:53thheller@colindresj I didn't have time to look into that yet. might not be easy at the moment#2018-06-1517:03colindresjYeah I spent a little bit of time on it and it felt not straightforward. Wanted to check if I was missing something. Not a big deal#2018-06-1521:09cjsauerDoes shadow have a method for importing CSS files, similar to how JS does it? i.e. import "../node_modules/[NAME_OF_YOUR_LIBRARY]/lib/styles.css";#2018-06-1522:33justinlee@cjsauer no it doesn’t#2018-06-1522:33justinlee(it’s really webpack that does that. it isn’t a javascript thing)#2018-06-1522:35cjsauer@lee.justin.m ah of course. I ended up writing a tiny little build hook that is working well enough
(defn copy-files
  {:shadow.build/stage :flush}
  [build-state & {:keys [dest files]}]
  (doseq [f files]
    (let [input (io/file f)
          input-name (.getName input)
          output (io/file dest input-name)]
      (io/make-parents dest input-name)
      (println (format "Copying %s to %s" input output))
      (io/copy input output)))
  build-state)
#2018-06-1522:36cjsauerThis let's me copy the CSS into my public folder where I can then load it on the page#2018-06-1522:37justinleeyea that works. i just use standard unix tools with npm scripts. imo you don’t need such tight integration with a monolithic build tool unless you’ve got a really big and complicated project. there’s something nice to just have simple scripts.#2018-06-1522:38cjsauerFor sure. I like the idea of someone being able to look at shadow-cljs.edn and seeing "ah, this is pulling some CSS files out of a node module".#2018-06-1522:39cjsauerIt let's the intent exist right next to the other project dependencies#2018-06-1522:39justinleeyea i get the appeal for sure. i’m often of of two minds on the issue: some times the pendulum is on dead simple unix solutions and sometimes i like the One File To Rule Them All approach#2018-06-1522:41cjsauerYep, which is getting easier and easier thanks to projects like tools.deps and friends. I'm loving being able to pop off pretty sophisticated build solutions right inside Clojure. Really exciting direction.#2018-06-1522:41cjsauerAll of my repl and build scripts leverage simple unix scripts relying on clj. I'm liking it a lot.#2018-06-1522:42cjsauerMakes splitting projects into smaller sub-projects really easy too.#2018-06-1522:43justinleeyou should write a blog post about your approach. i think a lot people would like to hear about that#2018-06-1522:43cjsauerI definitely will soon. It's all scribbled into my notebook, just have to transfer it over.#2018-06-1614:23wilkerlucio@thheller I found a nasty issue with shadow + lein + cljs 1.10.312#2018-06-1614:24wilkerlucioI can't use test.check generators with this combined settings#2018-06-1614:24wilkerluciothere was some changes in dynamic var checking, not sure what exactly, but it keeps complaining that clojure.test.check.generators is not loaded, but it is#2018-06-1614:25wilkerluciousing just shadow without lein works fine#2018-06-1614:25wilkerlucioI just created a minimum repro, I'll open an issue with that#2018-06-1614:26thhellerhmm lein basically only constructs the classpath. are you sure there aren't any classpath issues?#2018-06-1614:26wilkerluciothe repro is really simple, I can't see how that would be#2018-06-1614:27wilkerluciounless I'm blind and missing something, can you take a look?#2018-06-1614:28thhellersure#2018-06-1614:28wilkerluciojust preparing the repro to upload, one min#2018-06-1614:31wilkerlucio@thheller https://github.com/wilkerlucio/bug-shadow-lein-cljs-312#2018-06-1614:43wilkerluciohere I get this with this code:#2018-06-1614:43wilkerlucio
alpha.cljs:70 Uncaught Error: Var clojure.test.check.generators/return does not exist, clojure.test.check.generators never required
    at alpha.cljs:70
    at cljs.spec.gen.alpha.LazyVar.cljs$core$IDeref$_deref$arity$1 (alpha.cljs:22)
    at Object.cljs$core$_deref [as _deref] (core.cljs:673)
    at Object.cljs$core$deref [as deref] (core.cljs:1449)
    at Function.cljs$core$IFn$_invoke$arity$variadic (alpha.cljs:70)
    at alpha.cljs:91
    at cljs.core.Delay.cljs$core$IDeref$_deref$arity$1 (core.cljs:10369)
    at Object.cljs$core$_deref [as _deref] (core.cljs:673)
    at Object.cljs$core$deref [as deref] (core.cljs:1449)
    at Object.cljs$spec$gen$alpha$gen_for_pred [as gen_for_pred] (alpha.cljs:148)
#2018-06-1614:47thhellerI do get it as well with just shadow-cljs#2018-06-1614:47thheller(using master and 1.10.312)#2018-06-1614:49wilkerluciostrange, when I replace :lein true with:
:source-paths ["src"]

 :dependencies [[org.clojure/clojure "1.9.0"]
                [org.clojure/clojurescript "1.10.312"]
                [org.clojure/test.check "0.9.0"]
                [thheller/shadow-cljs "2.4.5"]]
#2018-06-1614:49wilkerlucioit works here#2018-06-1614:49thhellerclojure.test.check.generators.return$ exists so there is some renaming going on#2018-06-1614:50thhelleryou can't put org.clojure/clojurescript into shadow-cljs.edn#2018-06-1614:50thhelleror rather its filtered out to always use the version shadow-cljs "prefers"#2018-06-1614:50thhellerdoes CLJS not rename the return?#2018-06-1614:50wilkerlucioah, gotcha, and how do you force shadow to use a different version?#2018-06-1614:51thhellerI don't. master is already bumped to 1.10.312. just didn't make a new release yet#2018-06-1614:51thhellerjust did a lein install to use it#2018-06-1614:52thhellerit seems like everything is correct to me?#2018-06-1614:52wilkerlucioyeah, but compiling with pure cljs main things, it works#2018-06-1614:52wilkerlucioso I guess there is something getting off#2018-06-1614:52thhellerstrange#2018-06-1614:52thhellerwonder what cljs generates#2018-06-1614:52wilkerluciothis can be a problem to bump shadow, anyone using generators will be affected#2018-06-1614:54wilkerluciowhen I was trying to debug in #clojurescript yesterday david said this: https://clojurians.slack.com/archives/C03S1L9DN/p1529073112000560#2018-06-1614:54wilkerlucioring any bells?#2018-06-1614:55thhellerno, so far it just looks like a renaming issue#2018-06-1614:55thhellerreturn is a reserved word so it should be munged to return$#2018-06-1614:55thhellerbut for some reason this is not happening for the var generation stuff#2018-06-1614:56thhellerneed to figure out how to compile cljs without shadow-cljs#2018-06-1614:56thhellernot used to this cljs.main business#2018-06-1614:56wilkerlucioI can send you a repo ready here#2018-06-1614:57wilkerluciodeps.edn#2018-06-1614:57wilkerlucio
{:paths ["src"]
 :deps {org.clojure/clojurescript {:mvn/version "1.10.312"}
        org.clojure/test.check {:mvn/version "0.9.0"}}}
#2018-06-1614:57thhellercljs.main -c my-app.core#2018-06-1614:57thhellergot it#2018-06-1614:57wilkerlucioI tried here, seems the name is clojure.test.check.generators.return$#2018-06-1614:57wilkerlucioas you said#2018-06-1614:58thhellerhmm yeah the code is actually looking for that so no idea why it doesn't find it#2018-06-1614:59thhellerthere is some weird code genration going on#2018-06-1615:00wilkerlucioand we though cljs would come with no surprises 😛#2018-06-1615:00thhellerif((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.quick_check !== 'undefined')))){#2018-06-1615:01thheller((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) is tested twice#2018-06-1615:02thhellershadow-cljs generates this though#2018-06-1615:02thhellerif((((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined')) && ((typeof clojure !== 'undefined') && (typeof clojure.test !== 'undefined') && (typeof clojure.test.check !== 'undefined') && (typeof clojure.test.check.generators !== 'undefined') && (typeof clojure.test.check.generators["return"] !== 'undefined')))){#2018-06-1615:02thhellerquadruple checked#2018-06-1615:02thhellerclojure.test.check.generators["return"] this fails#2018-06-1615:03thhellernot yet sure why shadow generates different code#2018-06-1615:04thhellerthe compiler hacks were gonna get me at some point 😉#2018-06-1615:06wilkerluciojust curious now, how do you find the compiled code? there is a way in chrome to go from source mapped to compiled source?#2018-06-1615:07thhellerjust open the file in the editor. just searched for the never required error and went from there#2018-06-1615:08wilkerluciook, more a brute force thing 🙂#2018-06-1615:08thhellerok the exists? thing is definitely weird and messes with how shadow-cljs handles js/stuff#2018-06-1615:10thhellerok got an idea to fix it#2018-06-1615:27thhellerhaha the cljs.spec.gen.alpha/dynaload macro does the work that the new exists? macro does. thats why the check is done twice#2018-06-1615:31wilkerlucio(and #2018-06-1615:32wilkerlucioseems like it#2018-06-1615:35thhellermeh if I fix it the simple way I create another bug again 😞#2018-06-1615:36wilkerluciois that some shadow hack that is not going well with the new exists??#2018-06-1615:37thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L448-L468#2018-06-1615:40thhellerbasically the problem is that clojure.test.check.generators/return gets turned into clojure.test.check.generators.return$ but js/clojure.test.check.generators.return is turned into clojure.test.check.generators["return"]#2018-06-1615:40thhellerand the new exists? macro turns all vars into js/#2018-06-1615:40thhellerno idea why that is#2018-06-1615:41thhellerjs/ has special treatment in shadow-cljs because of the JS interop it does#2018-06-1615:42thhellerJS code in npm doesn't munge .return or so but the CLJS compiler does when you try to access it#2018-06-1615:45wilkerlucioI was reading the commits, seems like it was to fix some self-hosting thing#2018-06-1615:45wilkerlucioso that might be way they keep touching on JS, since it's all self-hosting have access too#2018-06-1615:46thhellerhttps://github.com/clojure/clojurescript/commit/9f8ad161eda1eb4b0fdb782e593ee9400b4e1f96#2018-06-1615:46thhellerthis wasn't self host related#2018-06-1615:46thheller(exists? this.ns.does.not.exist) would fail previously#2018-06-1615:46thhellerthe first impl just had to be fixed for self-host later#2018-06-1615:48thhellerI'm just trying to make sense of WHY the js/ is added#2018-06-1615:49thheller
(core/defmacro exists?
  "Return true if argument exists, analogous to usage of typeof operator
   in JavaScript."
  [x]
  (if (core/symbol? x)
    (core/let [x     (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
                       (= "js" (namespace x)) name)
               segs  (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
               n     (count segs)
               syms  (map
                       #(vary-meta (symbol "js" (string/join "." %))
                          assoc :cljs.analyzer/no-resolve true)
                       (reverse (take n (iterate butlast segs))))
               js    (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
      (bool-expr (concat (core/list 'js* js) syms)))
    `(some? ~x)))
#2018-06-1615:49thhellerthis is the current impl#2018-06-1615:49thhellerif I change it to
(core/defmacro exists?
  "Return true if argument exists, analogous to usage of typeof operator
   in JavaScript."
  [x]
  (if (core/symbol? x)
    (core/let [x     (core/cond-> (:name (cljs.analyzer/resolve-var &env x))
                       (= "js" (namespace x)) name)
               segs  (string/split (core/str (string/replace (core/str x) "/" ".")) #"\.")
               n     (count segs)
               syms  (map
                       #(vary-meta (symbol (string/join "." %))
                          assoc :cljs.analyzer/no-resolve true)
                       (reverse (take n (iterate butlast segs))))
               js    (string/join " && " (repeat n "(typeof ~{} !== 'undefined')"))]
      (bool-expr (concat (core/list 'js* js) syms)))
    `(some? ~x)))
#2018-06-1615:49thhellerit works just the same and fixes the shadow issue#2018-06-1615:49thhellerliterally just remove the "js" in the symbol call#2018-06-1615:50thhellerI don't get why its there#2018-06-1615:50thhellerjs/ will also cause shadow to generate externs and I think CLJS as well#2018-06-1615:50thhellerI don't get it 😛#2018-06-1615:53thhellerI really need to learn cljs.main. someone should verify that the exists? calls not actually generate externs via externs inference. I think they might.#2018-06-1615:53wilkerluciomaybe we should bring that to #cljs-dev ?#2018-06-1615:53thhellernah I'd rather verify first#2018-06-1615:55thhellerah I get why the "js" is there now#2018-06-1615:56wilkerluciowhys that?#2018-06-1615:56thheller(exists? cljs.core/return) "(typeof cljs.user.cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.return$ !== 'undefined')"#2018-06-1615:57thhellerseems like the cljs.analyzer/no-resolve is ignored for some reason and js/ is just an easy way to force it to not resolve#2018-06-1616:08thhellermeh this messes with my externs inference. will need to think about it#2018-06-1616:56wilkerluciothanks for checking it out#2018-06-1713:24theaspWhat situation causes FileNotFoundException: .shadow-cljs/builds/server/release/externs.shadow.js (No such file or directory)?#2018-06-1713:35theasphttps://circleci.com/gh/theasp/lapidary/39#2018-06-1716:48dominicmIs there any reason cljs.js/eval wouldn't work correctly with shadow?#2018-06-1717:07lilactown@dominicm I was just about to ask if you’re using shadow-cljs in #clojurescript 😅 I’m testing it there as well and am running into the same issue#2018-06-1717:07lilactownthis SO post might be relevant: https://stackoverflow.com/questions/50828008/how-can-i-make-functions-available-to-clojurescripts-eval#2018-06-1717:09lilactownI’m not sure how shadow-cljs provides the compiler metadata that @mfikes is talking about#2018-06-1717:13thheller@dominicm self-host support requires the bootstrapping by the :bootstrap build#2018-06-1717:13thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2018-06-1717:14thhellercljs.js/eval isn't any different but the way the system is initialized is#2018-06-1717:15dominicm@thheller Aha! I suspect this is it then, same for @lilactown#2018-06-1717:18thheller@mhuebert is using shadow-cljs for maria.cloud so he might have some tips#2018-06-1717:20thhellerI actually don't know much about self-host myself#2018-06-1717:37dominicm@thheller One difference from your blog is that we had to use :load-on-init to get the :entries to load.#2018-06-1810:32bupkishow can I force shadow-cljs to use a local version of a library (installed via lein install for example) instead of fetching it from clojars, etc.? I know I can override individual files, but in this case I'm testing changes to the library's dependencies so it'd be easier to use the JAR that I've locally built.#2018-06-1810:32thhellerjust lein install it#2018-06-1810:33thhellerno need to force anything, it will use that jar as long as the versions match#2018-06-1810:34thhelleryou may also just add :source-paths ["../../path/to-lib/src" "src"]#2018-06-1810:41bupkisawesome. i did try that, but haven't realised that the library in question has subprojects that also needed to be lein installd. thank you, it's very easy with shadow-cljs, as always.#2018-06-1810:44thhellerits a maven thing really so you can do this with lein or tools.deps as well#2018-06-1811:02bupkisgood to know, cheers#2018-06-1813:51fatihictHello, I just noticed that shadow-cljs doesn't pick up changes after a while watching a build. I'm on shadow-cljs 2.4.2.#2018-06-1813:52thhellernever heard a single report like that. gonna need more info 😛#2018-06-1814:06fatihictWell, It's actually really vague 😛.. I'm running shadow like so npx shadow-cljs watch app and after a while shadow is not compiling new changes anymore. @timovanderkamp ran into the same issue today. If it occurs again and when I have more info I will keep you updated#2018-06-1814:08Logan PowellHow would I phrase require('dotenv').load() in a shadow :require statement?#2018-06-1814:09thheller(:require ["dotenv" :as dotenv]) then outside ns (dotenv/load)#2018-06-1814:09Logan PowellThank you!#2018-06-1814:30cjmurphyCan someone help with: https://stackoverflow.com/questions/50911612/how-to-get-devcards-working-with-shadow-cljs#2018-06-1814:30cjmurphy?#2018-06-1814:48thheller@cjmurphy it is missing the most important thing#2018-06-1814:48thhellerhow do you actually use devcards?#2018-06-1814:48thhellerhow do you require it?#2018-06-1814:49thhelleryou are most likely running into https://github.com/bhauman/devcards/pull/135#2018-06-1814:51thhellerand do you call (devcards.core/start-devcard-ui!)?#2018-06-1814:53cjmurphyNo I'm not calling (devcards.core/start-devcard-ui!).#2018-06-1814:55thhelleris that not usually require? sorry I don't use devcards myself so I'm just guessing#2018-06-1814:55thhellerdocs seems to suggest that you have to call that#2018-06-1814:55cjmurphyJust looking in the fulcro template right now, and can't see a call to start-devcard-ui! there, yet it uses cards.#2018-06-1814:58wilkerlucio@cjmurphy https://github.com/fulcrologic/fulcro-lein-template/blob/fd57821e03b05313d2e3c36306f1e02e955c184d/resources/leiningen/new/fulcro/shadow-cljs/src/cards/fulcro_template/cards.cljs#L5#2018-06-1814:59wilkerluciomaybe you were looking at fulcro-template? that was the old one that we usually clone#2018-06-1815:04cjmurphyYes I was looking at fulcro-template. Never have looked at fulcro-lein-template as cloning has always been good enough for me. Didn't realise that fulcro-template had become old. That should give me enough to fix the issue. Thanks @wilkerlucio simple_smile#2018-06-1815:09wilkerluciono problem 🙂#2018-06-1816:42justinleequestion about file structure: i have a couple of files that have many functions in them (server calls and state manipulation). almost everything in my code base depends on them. the problem is that compilation is is taking 9-10 seconds. i’m a little surprised by that because it only causes 12 files to recompile and this is not a huge code base.#2018-06-1816:42justinleeis this expected, and if so, should i just work on breaking up the files so that the dependencies are more targeted?#2018-06-1816:44thheller@lee.justin.m what are you doing in that file? 9-10 sec seems excessive? how long does compiling cljs.core take on your machine?#2018-06-1816:45justinlee@thheller any edit, even to a comment, will cause the recompile. how do i test cljs.core?#2018-06-1816:45thhellerI'd love to get my hands on that file just to use it as a basis to tweak the compiler 😉#2018-06-1816:45thhellerrm -rf .shadow-cljs/builds/<id>/dev#2018-06-1816:45thhellershadow-cljs compile <id> --verbose#2018-06-1816:46justinleei use schema pretty heavily. i wonder if it is the macro expansion#2018-06-1816:46thhellerah yep .. that definitely hurts performance#2018-06-1816:47thhellerprobably just macro performance then#2018-06-1816:47justinleethere’s nothing in .shadow-cljs#2018-06-1816:47justinleeexcept for config.edn#2018-06-1816:47thhellerin the project not your home dir#2018-06-1816:49justinleeah got it. <- Compile CLJS: cljs/core.cljs (6549 ms)#2018-06-1816:50justinlee(note that i am not running a server while doing this, in case it matters. i usually just run the watch command directly and i killed it before doing this test)#2018-06-1816:51thhellerwatch will get faster over time due to better JIT but 6.5sec is good baseline#2018-06-1816:51thhellerthen 9-10s with many macros is not so excessive#2018-06-1816:51thhellerstill waaaaaaay too slow#2018-06-1816:52thhellerbut no easy fix for now#2018-06-1816:55justinleeum. okay, so now that i restarted the recompile time is down to 1.68s !#2018-06-1816:55justinleei’ve got my watch running in verbose mode, so i#2018-06-1816:55justinleei’ll see if i can figure out what changes over time#2018-06-1816:56thhellerah I thought it took 9-10sec to compile that single file#2018-06-1816:57thhellerI have some ideas for making live-reload perf better but they all involve using the analyzer data more intelligently#2018-06-1816:57thhellerwhich is a ton of work and idea if it will actually help#2018-06-1816:57thhellercurrently if you change one file all the files that depend on that file directly are also recompiled#2018-06-1816:58thhellersay you change (defn foo [a b]) to (defn foo [a b c]) the others need to be recompiled to get the warnings#2018-06-1816:58thhellerbut we could detect if any function signature actually changed in a recompile#2018-06-1816:59thhellerand only trigger the dependent recompiles if necessary#2018-06-1816:59justinleebefore i asked my question, i didn’t have verbose on, so i was just reporting the total recompile time, which was 10s. now that i restarted, the total recompile time is 1.6 seconds.#2018-06-1817:00thhellerhmm if it gets slower again let me know#2018-06-1817:01justinleei think i’ve noticed this before but didn’t believe it, but now i’ll pay closer attention (and i should have data because verbose is on)#2018-06-1817:26lilactownhey all - I started working on an idea I’ve been thinking about for awhile - a new lib for creating React components using hiccup: https://github.com/Lokeh/hx#2018-06-1817:27lilactowninterested in getting some feedback from people and thought users of shadow-cljs users might appreciate some of the goals 😅#2018-06-1817:29justinleethat would be a hell of a lot easier for javascript programmers to understand#2018-06-1817:38lilactownthat’s the idea#2018-06-1817:46thheller$ this is a really neat trick (unfortunately the code format in Cursive always breaks it apart 😞#2018-06-1817:46lilactown😂 I’m glad you think so - I’ve been afraid it’s a bit too clever#2018-06-1817:48lilactownI like the ease of use that reagent has in that it gets annoying having to type (compile-hiccup ... over and over when you break out for some actual Clojure code#2018-06-1817:48thhellerI do think its probably too clever but repeating hx/compile all the time sux too#2018-06-1817:48lilactown^ yep exactly#2018-06-1817:48thhelleryeah 😉#2018-06-1817:49lilactownbummer about Cursive formatting 😧 I wonder if there’s a way to fix it#2018-06-1817:49thhellerI personally don't use hiccup at all anymore (on the client)#2018-06-1817:49thhellerthis https://github.com/thheller/shadow/wiki/shadow.markup takes care of having to type :div.page-title and just calling (page-title ..) looks better anyways 😉#2018-06-1817:52thhellerbut it's not always great either ... still looking for better solutions#2018-06-1817:55lilactownI think that the thing I appreciate the most about hiccup is it gives you the ability to run transformations over the code before actually computing the React tree#2018-06-1817:55lilactownalthough when you start taking the all-macro approach like hx the value might be less 😛#2018-06-1817:57dominicmhttps://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html Am I reading this correctly that npm deps do go through google closure in a clever way?#2018-06-1818:09thhellerthey go through closure :simple yes#2018-06-1818:09bolasblackHi thheller, I encountered an issue releated with cljs.spec.alpha/fspec : the code always throw error Error: Var clojure.test.check.generators/return does not exist, clojure.test.check.generators never required even though I have already required clojure.test.check.generators. I reproduced the issue in #2018-06-1818:09thheller@bolasblack yes, 1.10.312 currently has a problem#2018-06-1818:10bolasblackBut if I use clj --main cljs.main --repl, the code works fine#2018-06-1818:10thhellerI identified the problem but not happy with the workaround yet#2018-06-1818:10bolasblackYou can have a try with my repo#2018-06-1818:11thheller@bolasblack sorry 1.10.238 in combination with shadow-cljs#2018-06-1818:11thhellerits a shadow-cljs issue really. one of the compiler hacks I did for externs inference breaks due to a change in what code the exists? macro generates#2018-06-1818:11thhellerjust stick with 1.10.238 for now#2018-06-1818:12bolasblackI understand 🙂#2018-06-1818:16bolasblackThis issue is not so important to me, so I can wait until you are willing to fix it. 🙂#2018-06-1818:17wilkerlucio@lilactown one feedback, I find cool the trick for $, but this also is a problem... it generates syntax, I might be a purist here, but I dislike it in same way I dislike => on midje, it seems cool until you want to apply paredit things, then the beatly of simplicity falls apart, I really got used to om.next style of having functions, they are easier to separated from vectors while reading, are faster (since there is pre-processing, they already return the elements). for $ I would hater you just have a function that does it: $ [:div "bla"] vs ($ :div "bla")#2018-06-1818:18wilkerlucioand the later doesn't need macro expansion 😉#2018-06-1818:21lilactownwell, it’s meant to aid in writing your React data using hiccup#2018-06-1818:22lilactown🤔 maybe I could add the $ as a sort of progressive enhancement#2018-06-1818:23lilactownI only tested it with my editor setup (spacemacs clojure layer) but if it doesn’t work under Cursive or paredit then that’s a problem#2018-06-1818:24thheller@lilactown also check out http://book.fulcrologic.com/#LocalizedDOM#2018-06-1818:25lilactownI’ve been thinking about adding an interceptor-style way of extending the hx.react/compile macro so it might be a good way to add it as an optional transform#2018-06-1818:27lilactown@thheller that is pretty cool!#2018-06-1818:29lilactownI’m trying to avoid putting too many things into the hx lib… I do want to explore how I can enable transforms like that to be added easily, though#2018-06-1818:30lilactownI already have a reagent-like state management with atoms implemented in https://github.com/Lokeh/hx/blob/master/src/hx/state.cljc 😂 I need to split it out from hx though#2018-06-1912:59wilkerlucioI'm trying to run karma tests, but I'm getting this: Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n at ev#2018-06-1912:59wilkerlucioideas what it can be?#2018-06-1913:03wilkerlucionevermind, bad karma config#2018-06-1913:50wilkerlucio@thheller I'm playing around with karma watch + ci build watch#2018-06-1913:51wilkerluciothey almost work, but seems like karma detects changes to the file while it's been flushed, causing syntax errors when it tries to read#2018-06-1913:51wilkerluciodo you think would be possible to make this change more atomic? like writing to a temp file and then renaming instead of flushing directly in the final path#2018-06-1913:54thhellersure, you can mess arround with that https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L94-L96#2018-06-1914:16wilkerlucioI see you left a comment on source maps, is that hard to get there? I think this could be very useful to debug erros from CI#2018-06-1914:17thhellerits not hard to get there just really slow#2018-06-1914:18wilkerluciohumm, so maybe put a flag behind it#2018-06-1914:18thhellercan take several seconds to generate a proper source map#2018-06-1914:18wilkerluciowell, the compilation here takes about 60 seconds, adding a few might not be that bad#2018-06-1914:19thhellerduring watch?#2018-06-1914:19wilkerlucioah, no, but that's a CI build, the watch on it was most for fun#2018-06-1914:19wilkerlucioI usually run the tests in another way in dev#2018-06-1915:40wilkerlucio@thheller is there a way to remove preloads from a specific module? I'm starting to work with web workers, but it's adding the preloads which I don't need there, is there a way to do that on the same build, or I need to create a new one?#2018-06-1923:46currentoorI added this to my shadow-cljs.edn file
:dependencies [[cider/cider-nrepl "0.17.0-SNAPSHOT"]
                [refactor-nrepl "2.4.0-SNAPSHOT"]]
but trying to connect cider to the nrepl port results in
WARNING: CIDER's version (0.17.0-snapshot) does not match cider-nrepl's version (nil). Things will break!
         More information.
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0-SNAPSHOT (package: 20180420.223) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
#2018-06-2000:17currentoorI also had, in my shadow-cljs.edn file
:lein         {:profile "cljs"}
adding the dependencies to the cljs profile in project.clj made the warning go away for cider-nrepl, which is good enough for now,
#2018-06-2000:19currentoorany idea what needs to be done for clj-refactor? i still get
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0-SNAPSHOT (package: 20180420.223) and n/a, respectively.
#2018-06-2000:42lilactownyeah I haven’t figured out how to make that go away#2018-06-2000:42lilactownhonestly I see it in most of my CLJ projects, regardless of shadow-cljs 😅#2018-06-2000:43lilactownI think that shadow-cljs automatically loads the cider-nrepl middleware if it detects it on the classpath. I don’t think it does the same for clj-refactor#2018-06-2000:44lilactownthere’s a place in the userguide about adding nrepl middleware to shadow-cljs: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2018-06-2000:47lilactownso you’ll need to add
{...
 :nrepl {:port 9000
         :middleware ['refactor-nrepl.middleware/wrap-refactor]}
 ...}
#2018-06-2000:47lilactowni think#2018-06-2000:47lilactownmaybe without the '#2018-06-2000:48lilactownyou might also need to add the CIDER middleware as well#2018-06-2001:22jefffriesenI’m wondering if I’ve got my shadow-cljs configuration set up incorrectly. A couple issues 1. Slow: 5-15 seconds for live reload. This is on a very small project with 8 files. Reading other comments on this thread makes me think that this is typical. 2. Source maps: I think these are on by default, but I get so many errors where the component name isn’t exposed - it’s like it’s using a minified name. My problem is always with b! Here’s a simple example
(defn stats-modal []
  [:> sem/Modal {:trigger (reagent/as-element (stats-button))}
   [:> sem/Modal.Content
    [:p "example content"]]
   ])
Debugging it, I get different versions of this: > Warning: Failed prop type: Invalid prop trigger supplied to b, expected a ReactNode. > in b (created by permits.views.home.header.stats_modal) > in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar) > in div (created by permits.views.home.header.header_bar) > warning.js:34 Warning: Failed prop type: Invalid prop trigger supplied to b, expected a ReactNode. > in b (created by permits.views.home.header.stats_modal) > in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar) > in div (created by permits.views.home.header.header_bar) > in div (created by permits.views.home.header.header_bar) > The above error occurred in the <b> component: > in b (created by b) > in b (created by b) This sometimes narrows it down to the React component, but for bigger components I have no idea where the problem is. That leads me to very small refactors where I check for errors in the rendering. But with slow reload times it feels impossible to be productive. Is there a source map option to get non-minimized errors? Or does that slow it down more? Here is my shadow-cljs.edn files:
{:source-paths ["src"]

 :dependencies [[reagent "0.7.0"]
                [re-frame "0.10.5"]
                [binaryage/devtools "0.9.10"]
                [day8.re-frame/re-frame-10x "0.3.2-react16"]
                [bidi "2.1.3"]
                [kibu/pushy "0.3.8"]
                [cider/cider-nrepl "0.17.0"]
                [soda-ash "0.81.1"]]

 :builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:main {:entries [permits.core]}}
                :compiler-options {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
                
                ;; start a development http server
                :devtools {:after-load permits.core/render
                           :http-root "public"
                           :http-port 8020
                           :preloads [devtools.preload day8.re-frame-10x.preload]}

                :release {:output-dir "dist/js"}}}}
#2018-06-2001:26jefffriesenI run first npx shadow-cljs server then npx shadow-cljs watch app#2018-06-2002:18justinleethe 10 second reloads i don’t think are normal. mine are less than 2 seconds.#2018-06-2002:18justinleethe ‘b’ thing is something from reagent#2018-06-2002:42jefffriesenOk, I’ll look at Reagent error messages. It looked like minimization, which I thought would be shadow-cljs role. I wonder why it’s so slow to reload#2018-06-2002:48justinleewhen thheller gets up he can help with that. try running your watch with the --verbose flag. that will give you some insight#2018-06-2002:50justinleeyou might be right about the minification. i think the :> operator is setting the name of the component from the function name and the function name appears as though it is getting minified. that seems weird though, because i’m pretty sure thomas only runs node modules through simple minifications#2018-06-2006:38thhellernode_modules only run through :simple yes but :simple does include variable renaming by default wherever it can. :property-renaming however is usually only used in :advanced.#2018-06-2006:39thhellerit has been a problem before with graphql#2018-06-2006:39thhellerhttps://github.com/thheller/shadow-cljs/issues/248#2018-06-2016:39justinleesorry just saw this thread. thanks for the info.#2018-06-2002:58jefffriesenOk. I’ll try the verbose flag#2018-06-2005:25albert.laiHi, all. Currently, I am trying to migrate my lein cljs build to shadow-cljs. I find that the embed resource tricks stop working. May I know there is some workaround on this?#2018-06-2005:33lilactownhm interesting#2018-06-2005:33lilactownwhat’s the error?#2018-06-2006:15thheller@albert.lai that indeed looks like a bug. will look into it.#2018-06-2006:16thheller@momoblackblack usually you should have source maps for everything but the error message looks like it might be generated by react so it might not use source maps. you can try setting :dev {:js-options {:variable-renaming :off}} and/or :property-renaming :off#2018-06-2006:17thheller5-10sec is not normal. you can try running with --verbose to get a bit more timing information. would be useful to know where the time is spent.#2018-06-2006:18thheller@currentoor if you use :lein then :dependencies in shadow-cljs.edn are ignored. everything must be in project.clj. no idea about emacs stuff.#2018-06-2006:19thheller@wilkerlucio currently there is no way to skip preloads for workers. still need to do a standalone worker build target. currently the worker module just loads all the sources of the modules it depends on without any filtering. not sure how easy it would be to filter.#2018-06-2006:57thheller@albert.lai fixed in 2.4.6. btw if your CLJS namespace with the macro self requires (ns abc.cljs-embed (:require-macros [abc.cljs-embed])), you scan skip the :include-macros true everywhere else#2018-06-2006:58albert.lai@thheller thanks! I will try it now!#2018-06-2008:49troglotitDoes anyone uses cljss with shadow-cljs? Did you solved cache busting, i.e. do your styles hot-reload?#2018-06-2008:57levitanong@thheller is there a function for “release”ing, but rather than writing to disk, it returns some string a server can keep in memory?#2018-06-2008:58thheller@levitanong no, it always assumes you want to write to disk#2018-06-2008:59thhellerdo you run shadow-cljs as part of your production app?#2018-06-2009:03levitanong@thheller yes, when i run the server, i do a number of things. For css, I compile via garden css (and then store the string in memory, so that whenever a request matches that css route, i shave a bit off my response time because i skip i/o. Plus, cachebusting is way easier) For js, I run shadow/release.#2018-06-2009:04levitanongdev mode is pleasant because i use stuartsierra’s component, so setup/teardown of shadow.server/start! and shadow.server/stop!#2018-06-2009:05levitanongso I’m just thinking, it would just be neat if i could do to js what i do for css.#2018-06-2009:05thhellerthe way I do this is not run shadow-cljs as part of my server#2018-06-2009:05thhellerbut instead have it watch the output-dir for changes to the manifest.edn#2018-06-2009:05thhellerwhich contains all the required info about the JS#2018-06-2009:06thhellerso it can reload the JS when the manifest changes#2018-06-2009:07thhellerrunning the entire shadow-cljs server in your production app may not be the best idea#2018-06-2009:07levitanonghow so?#2018-06-2009:07thhellerit really is meant for development and launches a bunch of endpoints you really don't want to expose on a public server#2018-06-2009:07levitanongahh#2018-06-2009:08thhellersocket repl, nrepl, etc#2018-06-2009:08levitanongbut i’m not using that for production#2018-06-2009:08levitanongi only run release for production#2018-06-2009:08levitanongand the shadow server stuff when my server is in dev mode#2018-06-2009:08thhelleryeah that should be ok#2018-06-2009:09levitanongyay!#2018-06-2009:09levitanongso i have another question:#2018-06-2009:09levitanongis there any plan to support more profiles other than dev and release?#2018-06-2009:09thhellerlike what?#2018-06-2009:09levitanongin my company, we have several stages our apps go through: development, testing, staging, a million other things, and then finally prod#2018-06-2009:10levitanongit’s only in development that i want to run things in dev mode, the rest in release#2018-06-2009:10thhellerso my stance on this is simple: everything beyond development should use the release profile#2018-06-2009:10levitanonghowever, those other profiles should be using slightly different endpoints#2018-06-2009:10thhellersince what good is testing/staging if it uses different code than production#2018-06-2009:10thhellerand configuration of endpoints and such really should not be part of build config#2018-06-2009:11thhellerit is runtime config you want to pass in differently#2018-06-2009:11thhellerI really should add that to the docs#2018-06-2009:11levitanongbut what about the google closure defines?#2018-06-2009:11levitanongor is that me misusing that functionality? 😛#2018-06-2009:11thhelleryes 😉#2018-06-2009:12levitanongdo you have any advice for endpoints? because i don’t really need them to be set at runtime.#2018-06-2009:12thhellerI usually recommend this setup#2018-06-2009:12thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/public/index.html#L10#2018-06-2009:12thhellerthe init fn is called from HTML#2018-06-2009:12thhelleryou can pass starter.browser.init({endpoint:"http://..."}) there#2018-06-2009:13thhellerand then have the init fn store that somewhere useful and make your app use it#2018-06-2009:13levitanongah, that is fascinating.#2018-06-2009:13levitanongbut what about API keys?#2018-06-2009:13thhellersame thing#2018-06-2009:13levitanongbut wouldn’t that be exposing your API keys to the public?#2018-06-2009:14levitanong’cause it’ll just be there in your script tag in “plaintext”#2018-06-2009:14thhellerit is just as public in your compiled JS#2018-06-2009:14levitanongbut it’s more accessible, isn’t it? 😛#2018-06-2009:14thhellerwell if someone is looking for the keys they will find them#2018-06-2009:14thhellerprobably by just looking at the XHR requests you are making with those keys#2018-06-2009:15levitanongthat’s true#2018-06-2009:15levitanongi guess that’s why domain constraints are there#2018-06-2009:16thhelleryeah you don't get any more security by compiling the keys into your JS via closure defines#2018-06-2009:16thhellerbut if you put them into the closure defines you have to recompile whenever the keys change (eg. prod vs staging)#2018-06-2009:17thhellerif you just pass every bit of runtime config into init that problem goes away#2018-06-2009:17thhellerand you staging builds actually use the prod JS#2018-06-2009:17levitanongi like this#2018-06-2009:17levitanongthanks @thheller! this was really helpful 😄#2018-06-2009:18thhellerI use this approach since about 2012 or so https://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html#2018-06-2009:18thhellermight be interesting but the init(the_config) method works just fine too#2018-06-2009:25levitanong@thheller interesting. what is that cljs function?#2018-06-2009:26thhellerjust a helper that emits the script tag from above#2018-06-2009:26thheller
<script type="shadow/run" data-fn="my_app.feature1" data-ref="self">
    {config: true,
     data: big_json_blob_from_server}
  </script>
#2018-06-2009:27levitanongokay, understood.#2018-06-2009:27levitanongthanks again!#2018-06-2012:17thheller@wilkerlucio @bolasblack the 1.10.312 ...spec/return issue should be fixed in 2.4.6#2018-06-2012:17thheller@wilkerlucio @bolasblack the 1.10.312 ...spec/return issue should be fixed in 2.4.6#2018-06-2012:18wilkerlucioI was a bit worried about that one, how did you manage to get around the js marking?#2018-06-2012:20thhellersame way David did it https://github.com/clojure/clojurescript/commit/693cd0da6d89a4d3a583a9e78e68e458580b43cc#2018-06-2012:20thhellerchecking (not (-> sym meta ::no-resolve))#2018-06-2012:21thhellerfeels super hacky but couldn't come up with a cleaner solution#2018-06-2012:31wilkerluciowell, if works 😛#2018-06-2012:33thhellerI hope it does. didn't actually verify with test.check itself, just some test code I wrote#2018-06-2012:33wilkerluciook, I can verify that and let you know, will try now#2018-06-2012:45wilkerlucioyup, generators working just fine 🙂#2018-06-2012:22grounded_sageJust wondering what you mean by this https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration @thheller#2018-06-2012:24thhellerwhich part?#2018-06-2012:24grounded_sageI'm thinking of using the Clojure cli and layering on other tools to create something like Gatsby in respect of compiling to a PWA with PRPL pattern etc.#2018-06-2012:25thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2018-06-2012:25grounded_sageI'm just curious about the caution you have there and what it really means.#2018-06-2012:26grounded_sageYea I have read that a few times. So you just mean that the other build tools can slow down the experience and get in the way yea?#2018-06-2012:26thhellerthe shadow-cljs command has a built-in server mode#2018-06-2012:27thhellerso if the server is running it will connect to that instead of starting a new JVM#2018-06-2012:27thhellerif you use lein or clj directly they won't know about that server and start a new JVM#2018-06-2012:27thhellerwhich is a whole lot slower#2018-06-2012:28thhellerapart from that it has a few safeguards to avoid some dependency conflicts like accidentally using an ancient version of clojurescript#2018-06-2012:28grounded_sageWell I am thinking for the most part there isn't any reason for using the clj for anything other than the full compilation step. When I want to do the SSR, Critical CSS inlining etc.#2018-06-2012:29grounded_sageI'm just thinking of using the Clj-cli for SSR, Critical CSS inlining, image manipulation etc.#2018-06-2012:30thhelleryou could use shadow-cljs run your.tool/css-inline ... instead of clj -m your.tool ...#2018-06-2012:30thhellerso yeah if you build it for the clj tool it will automatically work with shadow-cljs run as well#2018-06-2012:34grounded_sageOh wow. I hadn't read that stuff before.#2018-06-2012:36grounded_sageThis looks easier than I thought it would be 😮#2018-06-2012:38grounded_sageOk that will learn me for not reading the full manual!#2018-06-2015:23jefffriesen@thheller I tried using :variable-renaming :off and :property-renaming :off but still getting these obscured errors. So here’s an example error
warning.js:34 Warning: Failed prop type: Invalid prop `trigger` supplied to `b`, expected a ReactNode.
    in b (created by permits.views.home.header.stats_modal)
    in permits.views.home.header.stats_modal (created by permits.views.home.header.header_bar)
    in div (created by permits.views.home.header.header_bar)
For this code:
(defn stats-modal []
  [:> sem/Modal {:trigger (reagent/as-element stats-button)
                 :basic true}
   [:> sem/Modal.Content
    [:p "example content"]]
   ])
Here’s my config:
{:source-paths ["src"]

 :dependencies [[reagent "0.7.0"]
                [re-frame "0.10.5"]
                [binaryage/devtools "0.9.10"]
                [day8.re-frame/re-frame-10x "0.3.2-react16"]
                [bidi "2.1.3"]
                [kibu/pushy "0.3.8"]
                [cider/cider-nrepl "0.17.0"]
                [soda-ash "0.81.1"]]

 :builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:main {:entries [permits.core]}}
                :compiler-options {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
                :dev {:js-options {:variable-renaming :off
                                   :property-renaming :off}}
                
                ;; start a development http server
                :devtools {:after-load permits.core/render
                           :http-root "public"
                           :http-port 8020
                           :preloads [devtools.preload day8.re-frame-10x.preload]}

                :release {:output-dir "dist/js"}}}}

#2018-06-2015:24jefffriesenthe error is not wrapping the stats-button. It should be (reagent/as-element (stats-button))#2018-06-2015:24jefffriesensem is from ["semantic-ui-react" :as sem]#2018-06-2015:31thhellermight be reagent?#2018-06-2015:38jefffriesenIt might be. Ok. There is just no config that I know of in Reagent for that.#2018-06-2015:38jefffriesenBut I’ll look there#2018-06-2015:39thheller
Warning: Failed prop type: Invalid prop `trigger` supplied to `Modal`, expected a ReactNode in Modal
#2018-06-2015:40thhellerwith just react and :variable-renaming :off#2018-06-2015:40thheller(react/createElement sem/Modal #js {:trigger (fn [])})#2018-06-2016:10lilactown@momoblackblack you might need to do (reagent/as-element [stats-button])#2018-06-2016:12justinleeno that’s not the issue. there’s something funny going on with the way reagent imports components.#2018-06-2016:14jefffriesenI did try that: [:> sem/Modal {:trigger (reagent/as-element [stats-button]). No errors but the button doesn’t trigger the modal. Nothing happens. The only thing that works is [:> sem/Modal {:trigger (reagent/as-element (stats-button)). Someone else said it’s maybe because of a hacky way react-semantic-ui set up those triggers that made it require a ()#2018-06-2016:18justinlee@thheller using react-virtualized imported like so [react-virtualized :refer [AutoSizer InfiniteLoader List]] and running the following in the repl: (react/createElement AutoSizer #js {} (js-obj)) you get the Warning: Failed prop type: Invalid prop children` of type object supplied to b, expected function. in b`#2018-06-2016:19thhellerdo you have :variable-renaming :off?#2018-06-2016:19justinleeno. should I?#2018-06-2016:19jefffriesenthere’s that b component again ^#2018-06-2016:20jefffriesen@lee.justin.m you can see my config above after @thheller suggested it#2018-06-2016:20jefffriesen
:dev {:js-options {:variable-renaming :off
                                   :property-renaming :off}}
#2018-06-2016:21jefffriesenbtw, this does work: [:> sem/Modal {:trigger (reagent/as-element [:div [stats-button]]). My issue wasn’t so much getting it to work, because I eventually got it to work through trial and error. I am just trying to make future debugging easier#2018-06-2016:21thhellerbeginning to think that :variable-renaming :off might be a safer default#2018-06-2016:22thhellerbut it makes the code quite a bit larger after optimizations#2018-06-2016:22justinleethat fixes it with straight react interop. trying inside reagent#2018-06-2016:24justinleethe reason this happens is because reagent sets the display name of the component by using the .name property of the component#2018-06-2016:24justinleewhen you minimize, you get a letter like b#2018-06-2016:25justinleeso this value changes depending on that setting:
window.module$node_modules$react_virtualized$dist$commonjs$index.AutoSizer.name
"AutoSizer"
#2018-06-2016:29justinleethe closure documentation states that it does not change function names except in advanced compilation. how are you doing that if you are not in advanced?#2018-06-2016:32thhellerguess they changed that? :simple definitely has that turned on#2018-06-2016:32lilactown@momoblackblack I would open up an issue on reagent about how [:> sem/Modal {:trigger (reagent/as-element [stats-button])}] doesn't work#2018-06-2016:32thhellerwell technically it only changes local variable names#2018-06-2016:32justinleeconfirmed that the config change fixes the issue with reagent#2018-06-2016:33justinleeits changing the names of exported functions too#2018-06-2016:33thhellerno#2018-06-2016:34thhellerwell it depends .. exports.Foo = function Foo() {}#2018-06-2016:34thhellerexports.Foo is unchanged, function Foo() {} will be#2018-06-2016:35justinleeI see and that’s the value reagent uses#2018-06-2016:36justinleeReagent should check for a displayName prop so that it would work for nonfunctional components at least. Easy fix#2018-06-2016:37thhellerI could just default :variable-naming to :off during dev#2018-06-2016:37justinleeUnless that’s how react determines the display name ... haha#2018-06-2016:37thhellerdidn't to it to avoid the situation where dev builds work but prod builds don't#2018-06-2016:37thhellerbut not sure this can ever actually affect anything relevant#2018-06-2016:40thhellerits actually required for graphql so maybe its the better default#2018-06-2016:41justinleeyou should definitely add them to the user guide#2018-06-2018:04nickmbaileydoes anyone have any examples of using shadow-cljs to compile clojurescript that can be pulled in as an npm dependency by regular javascript projects?#2018-06-2018:06denis_krivosheevAbout this issue with react-semantic-ui. Turns out this is semantic-ui issue, not reagent#2018-06-2018:07denis_krivosheevthey take children and extend the props of the very top node with some additional hooks#2018-06-2018:07denis_krivosheevonClick and something else#2018-06-2018:07denis_krivosheevBut if the top level node doesn’t accept these props, everythiing is going to be bad#2018-06-2018:09denis_krivosheevso just wrapping reagent component into the native component resolves the issue:
:trigger (reagent/as-element [:div [stats-button]])
#2018-06-2018:10denis_krivosheev@nickmbailey I’m also looking for it today. This is the best example I found so far: https://github.com/loganpowell/shadow-proto-starter#2018-06-2018:10denis_krivosheevTested it, it works, not deployed to npm yet though#2018-06-2018:15denis_krivosheevHere the dark magic happen for semantic-ui-react https://github.com/Semantic-Org/Semantic-UI-React/blob/43793ae59df9504131d1c9af4762a75321aa3ccc/src/addons/Portal/Portal.js#L445#2018-06-2018:16denis_krivosheevThey clone element and extend its prop#2018-06-2018:21nickmbailey@denis_krivosheev yeah i maybe should have been more specific in that i’m targeting the browser specifically, from what i can tell that example is meant for node (maybe it works for both?)#2018-06-2018:26jefffriesen@nickmbailey Denis was commenting on a previous issue#2018-06-2018:27nickmbaileyyeah he also linked an example for my question in the middle there though 🙂#2018-06-2019:14denis_krivosheevYeah. It’s hard to track several themes in the same chat 😃#2018-06-2021:31justinlee@thheller you may be amused by this twitter thread https://twitter.com/dan_abramov/status/1009179550134296577#2018-06-2022:03thhellerhehe nice 🙂#2018-06-2022:09richiardiandreawell we package some uncompiled cljs in there 😄#2018-06-2022:10justinlee“just add babel-shadow-cljs-transform to your build tool chain!” no problem!#2018-06-2022:11thhellernice to see that at least someone is aware of this in the JS world#2018-06-2022:12justinleedan has huge mindshare so it’s good he’s talking about it (125k followers)#2018-06-2022:12richiardiandreatrue, didn't expect that at all#2018-06-2104:07caleb.macdonaldblackA dependency I’m using uses cljsjs firebase and I’m getting The required namespace "firebase.app" is not available, it was required by "com/degel/re_frame_firebase/core.cljs". In the firebase cljsjs library it seems to export firebase.app like this:
{:file "cljsjs/development/firebase-app.inc.js"  :provides ["firebase.app"]}
I’ve installed firebase app and firebase through npm but it is not picking it up. How would shadow-cljs know to point firebase-app to firebase.app? Just wondering how I would begin to fix this
#2018-06-2104:24justinlee@caleb.macdonaldblack is something you are using still requiring something through cljsjs? If so, you need to shim the cljsjs file. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-06-2104:25justinleeotherwise, if this is your file, you just add something like [firebase :as firebase] to your (require...) vector#2018-06-2104:26caleb.macdonaldblackYea this it another dependency requiring. The link you sent looks like it exactly what I need. Thank you!#2018-06-2104:26justinleeokay yea, just create that little file and it should work#2018-06-2105:34caleb.macdonaldblackI am still having trouble here. the library is requiring it like this: [firebase.app :as firebase-app]#2018-06-2105:35caleb.macdonaldblackand in the cljsjs package it is setting it up to work on the firebase.app namespace with the :provides option in the deps.cljs#2018-06-2105:35caleb.macdonaldblackI’m looking at this repo: https://github.com/thheller/shadow-cljsjs for examples but none of them help me here#2018-06-2106:05justinleeI thought you’d need to something like (ns firebase.app (:require ["firebase" :as firebase])) (js/goog.exportSymbol "firebase" firebase))#2018-06-2106:06caleb.macdonaldblackoh i see your namespace is firebase.app I didn’t take notice of that#2018-06-2106:07caleb.macdonaldblacklet me try now#2018-06-2106:08justinleethe thing i’m not sure about is whether that export is right#2018-06-2106:12caleb.macdonaldblackYea that did it. I was wondering what was with the weird file structure in the shadow-cljsjs repo. It was matching the required namespace#2018-06-2106:12caleb.macdonaldblackthanks again#2018-06-2106:14justinleeoh good i’m glad that worked#2018-06-2114:27albert.laiRecently, I try to change my project using this amazing shadow-cljs. It is a great success! I love the idea, the build tools itself is built as a library. I want to take this one step further, if all the internal api could take a map instead of hard coded to (config/load-cljs-edn), it would be easier to integrate with other libraries (like Component/Integrant).#2018-06-2114:29albert.laiAnother idea is we can have api to access the data in manifest.edn, it would be very useful information for adding caching list in serviceworker.#2018-06-2114:30albert.lai@thheller don’t know if they are good ideas for shadow-cljs#2018-06-2114:34thheller@albert.lai you have access to all the data. not sure what you want to do with it.#2018-06-2114:35thhellerintegrating with component/integrant should be pretty straightforward. config file isn't going away for the time being though.#2018-06-2115:09albert.laihttps://github.com/duct-framework/server.figwheel, I am trying to integrate shadow-cljs to duct framework. everything is working, the only different is the shadow-cljs’s config is not inside the system map. This make sharing information abit indirect. e.g. the webpush’s application server key string must first export to environment variable for shadow-cljs to include.#2018-06-2115:09thhellerI reaaaaaaaaallly do not recommend running shadow-cljs as part of your clojure server#2018-06-2115:10thhellerI wouldn't do this with figwheel either though#2018-06-2115:14thhellerIn my production app I have a "component" which just watches for changes to the manifest.edn#2018-06-2115:14thhellerso I compile elsewhere and rsync the compiled output to the production server#2018-06-2115:18thhelleryou can run it as part of your server if you really want but you are just making life harder IMHO#2018-06-2115:18thhellerif you run it standalone you get a couple of benefits#2018-06-2115:19thhellerlike automatically recompiling when you change your config#2018-06-2115:19thhellerand way less dependency conflicts#2018-06-2115:28albert.laiI know your idea. But duct will only load figwheel in development mode, figwheel will be excluded in production.#2018-06-2115:28albert.laiBut, yes, it did have more chance to have dependency conflicts..#2018-06-2115:31thhellerI understand that the goal is to start everything at once but to me it just looks way more complicated than running them separately#2018-06-2115:41albert.laiwhen it works, it works well. when it stop working, now we have a bigger mud ball. It might not worth the effort. Thanks for your explanation.#2018-06-2117:35JonI need some help on auto generated externs,#2018-06-2117:35Jonhttps://github.com/Cirru/calcit-editor/commit/de17328850f4847ce26eec42b625f63d8268e974#2018-06-2117:35JonI added ^js and :compiler-options {:infer-externs :auto} in my project, the warnings are gone.#2018-06-2117:36Jonhowever is the js file generated the method name is still renamed.#2018-06-2117:37Jon
(.use app "/" (.static ^js express dir) (serve-index dir (clj->js {:icons true})))
#2018-06-2117:37Jon
=>> client=local node server.js
Using default schema.
/Users/chen/repo/cirru/calcit-editor/dist/server.js:731
function Kv(){var a=ek.a(Hv),b=Bv(),c=mv.join(__dirname,"app");a=100+a;b.use("/",Bv.Yd(c),function(){var a=Ni(new u(null,1,[yj,!0],null));return Cv(c,a)}());b.listen(a);return Gi(P([["Serving local editor at ",x.a(Yq.blue(["",x.a(a)].join("")))].join("")]))}
                                                                                    ^

TypeError: Bv.Yd is not a function
    at Kv (/Users/chen/repo/cirru/calcit-editor/dist/server.js:731:85)
    at Function.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:733:377)
    at $e (/Users/chen/repo/cirru/calcit-editor/dist/server.js:152:111)
    at /Users/chen/repo/cirru/calcit-editor/dist/server.js:733:270
    at Object.<anonymous> (/Users/chen/repo/cirru/calcit-editor/dist/server.js:734:3)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
#2018-06-2117:38JonDid I miss some steps?#2018-06-2120:05thheller@jiyinyiyong try compiling with shadow-cljs release server --pseudo-names to confirm that it is actually that part of the code#2018-06-2120:05thhellercertainly looks like it but want to be sure#2018-06-2120:06thhellercheck if the .shadow-cljs/builds/server/release/externs.shadow.js file contains the .static property#2018-06-2120:08thhellerstatic is one of those reserved "special" properties that the CLJS compiler will munge#2018-06-2120:09thhellerbut then your code wouldn't work in dev either#2018-06-2120:36thheller@jiyinyiyong just saw that you use .static express when express is a ns :as alias. try express/static instead. that has protection against the built-in munging from the CLJS compiler#2018-06-2120:40thhellerI think the issue is that static gets renamed to static$ by the cljs compiler and your code isn't used in dev so you only notice it on release?#2018-06-2120:53thhelleroh right or set :compiler-options {:language-out :ecmascript5} maybe#2018-06-2121:52thheller@jiyinyiyong found it. fixed in 2.4.8. it was in my externs generation code which munged reserved properties when it shouldn't have.#2018-06-2123:58theaspblink#2018-06-2123:58theaspHow did you know I was going to ask about that??? 😉#2018-06-2202:29Jon@thheller It works by using express/static. Thanks.#2018-06-2202:30JonIt's an extra feature I barely test in development but checked before releasing on npm.#2018-06-2202:31Jon
=>> cat externs.shadow.js
/** @constructor */
function ShadowJS() {};

ShadowJS.prototype.NEGATIVE_INFINITY;
ShadowJS.prototype.NaN;
ShadowJS.prototype.POSITIVE_INFINITY;
ShadowJS.prototype.Server;
ShadowJS.prototype.ceilingEntry;
ShadowJS.prototype.cleanup;
ShadowJS.prototype.client;
ShadowJS.prototype.createConnection;
ShadowJS.prototype.createServer;
ShadowJS.prototype.dirname;
ShadowJS.prototype.env;
ShadowJS.prototype.execSync;
ShadowJS.prototype.existsSync;
ShadowJS.prototype.exit;
ShadowJS.prototype.floorEntry;
ShadowJS.prototype.fromCharCode;
ShadowJS.prototype.generate;
ShadowJS.prototype.gray;
ShadowJS.prototype.join;
ShadowJS.prototype.listen;
ShadowJS.prototype.on;
ShadowJS.prototype.readFileSync;
ShadowJS.prototype.static$;
ShadowJS.prototype.unbounded_unshift;
ShadowJS.prototype.writeFileSync;
ShadowJS.prototype.yellow;=>>
#2018-06-2202:32Jonno externs for static if I use (.static express). found $static#2018-06-2202:32Jonit works in 2.4.7 now.#2018-06-2212:25pezI get
1 | (ns calva.fmt.formatter
-------^------------------------------------------------------------------------
Invalid :refer, var ysera.test/is= does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |    [ysera.test :refer [is= is is-not]]
   4 |    [cljfmt.core :as cljfmt]))
It is a cljc file and seems to work fine in the clj-repl. I’m trying to use Ysera 1.2.0: https://github.com/tomas81508/ysera/blob/master/src/ysera/test.cljc
#2018-06-2212:26pez^ shadow-cljs 2.4.8 ^#2018-06-2212:40thheller@pez is= is a macro and the file does not have :require-macros so you need to [ysera.test :include-macros true :refer [is= is is-not]]#2018-06-2212:42thhellerthis lib doesn't look very CLJS compatible at all#2018-06-2212:51pez@thheller thanks! It now compiles. I am using it so that I can embed tests with function definitions w/o conditional readers and such.#2018-06-2212:52thheller
(defmacro deftest [name & body]
  `(if-cljs
     (println "Not implemented.")
     (clojure.test/deftest ~name 
#2018-06-2212:52thhellersays not implemented 😉#2018-06-2212:53pezAs for CLJS compatibility, I know that the devs behind Ysera are using it in a rather large CLJS project, but probably also there it is mostly used in order to embed tests.#2018-06-2212:53pezYes, I run tests in CLJ, guess that is how it is meant to be used.#2018-06-2215:54haywoodthis might be a question for the beginner's channel, but is there a way to include a namespace's functions globally for use in the repl? For context I want to use debux's functions without requiring the macros in each file#2018-06-2215:54haywoodI'm connected to a browser-repl via shadow#2018-06-2216:34richiardiandreaI am receiving this today from a node-test build:
========= Running Tests =======================
Error: ENOENT: no such file or directory, open '/home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/goog.debug.error.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:46:15)
    at /home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:3005:1
    at Object.<anonymous> (/home/arichiardi/git/laputa/lambda-cqrs/out/tests.js:3146:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
===============================================
[:test] Build completed. (141 files, 81 compiled, 0 warnings, 16.27s)
#2018-06-2216:46thhellerpretty clear error message no?#2018-06-2216:46thhellerdoes the file exist or not?#2018-06-2216:56richiardiandrea@thheller it seems to exist no, before it did not, I have a different error now#2018-06-2216:56richiardiandrea
========= Running Tests =======================
SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/ep_cloud.commit_event.js
#2018-06-2216:57richiardiandreacan it be a compilation error not displayed?#2018-06-2216:57richiardiandrealet me try to compile#2018-06-2216:57thhellerlook further down. that just means that it failed to load that file#2018-06-2216:57thhellerwhich can happen if it throws an exception while loading#2018-06-2216:57richiardiandrea
========= Running Tests =======================
SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.cljs-tests/cljs-runtime/ep_cloud.commit_event.js
===============================================
[:test] Build completed. (141 files, 9 compiled, 0 warnings, 6.17s)
#2018-06-2216:58richiardiandreano other output#2018-06-2216:58thhellerdont autorun and run manually#2018-06-2216:58richiardiandreak#2018-06-2217:00thhellerwonder where the rest of the error is though#2018-06-2217:01richiardiandreayeah I do know I am not executing with node#2018-06-2217:01brown131I#2018-06-2217:03richiardiandrea
node .cljs-tests/tests.js 
SHADOW import error /home/arichiardi/git/laputa/lambda-cqrs/.shadow-cljs/builds/test/dev/out/cljs-runtime/ep_cloud.commit_event.js
#2018-06-2217:03richiardiandreano other output#2018-06-2217:04thhellertry node --inspect-brk .cljs-tests/tests.js and open with chrome debugger via #2018-06-2217:04brown131I'm looking at the doc for shadow.repl and when I try to do the "(require 'shadow.repl-demo)" it cannot find that namespace. Where is that? It does not appear to be in the shadow-cljs-2.4.8.jar.#2018-06-2217:04thhellerthere is supposed to be more output. no idea why its not there#2018-06-2217:05thheller@brown131 what do you want with shadow.repl? thats an old thing which isn't really relevant anymore#2018-06-2217:06brown131What I'm trying to do is start a REPL in Cursive so I can debug CLJS.#2018-06-2217:06thhelleryou cant debug CLJS with cursive?#2018-06-2217:07brown131Was that a question or a statement?#2018-06-2217:07thhelleror do you mean just eval code? not actually using the debugger?#2018-06-2217:09brown131I would like to be able to set breakpoints in functions in the code and then call the functions in the repl and have them hit those breakpoints, analogous to what can be done with Clojure.#2018-06-2217:10thhellerCursive does not support that for CLJS#2018-06-2217:10brown131Ah. What are my options with Cursive then?#2018-06-2217:12richiardiandrea@thheller I see the error in the catch, and it is some runtime error#2018-06-2217:12richiardiandreanow, the catch shows "import error" then throws#2018-06-2217:13richiardiandreabut I only see the result of console.error("SHADOW import error", filePath);#2018-06-2217:14richiardiandreadefinitely weird I don't see the error, something must be wrapping it#2018-06-2217:16richiardiandreathis prints:
// the comment is for source-map-support which unfortunately shows the wrong piece of code but the stack is correct
  try {
  /* ignore this, look at stacktrace */ fn.call(global, require, module, __filename, __dirname);
  } catch (e) {
    console.error("SHADOW import error", filePath);
    console.error(e);
    throw e;
  }
#2018-06-2217:16brown131Trying to answer my own question, it appears that I should start a shadow watch then run a remote nREPL to connect.#2018-06-2217:18thheller@richiardiandrea wonder where the throw e ends up? or the console.error(e)?#2018-06-2217:19richiardiandrea@thheller me too 😄 but the throw is top level...there a couple of FFE on the top#2018-06-2217:20richiardiandrea@thheller there is no console.error(e), I added it#2018-06-2217:21thhelleroh hehe#2018-06-2217:24richiardiandreashould I PR that? I know not nice, but cannot understand where the exception ends up, after`throw` the debugger just exits#2018-06-2217:27thhellerrather find out where the throw ends up#2018-06-2217:50wilkerlucio@thheller I just realized now, but I'm not seeing the error HUD anymore, when the compilation fails it just prints something weird in the console and the HUD loader goes away, I remember now that there was a big error display covering the screen before#2018-06-2217:50wilkerlucionow that I notice, it seems like it was this way for some time, I'm talking about errors like compilation failures (missing parentesis or something)#2018-06-2217:52wilkerlucioerror example:#2018-06-2217:52wilkerlucio
failed to parse websocket message {:type :build-failure, :build-config {:target :browser, :output-dir "resources/public/js/workspaces", :asset-path "/js/workspaces", :compiler-options {:closure-output-charset "US-ASCII"}, :dev {:closure-defines {common-cljs.config/dev? true}}, :devtools {:preloads [devtools.preload fulcro.inspect.preload], :before-load nubank.cljs.workspaces.core/before-load, :after-load nubank.cljs.workspaces.core/after-load}, :modules {:main {:entries [nubank.shuffle.workspaces]}}, :build-id :workspaces}, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs:9:40\n--------------------------------------------------------------------------------\n   6 | (ws/deftest test-capitalize-words\n   7 |   (assertions\n   8 |     (misc/capitalize-words \"hello world\") => \"Hello World\"\n   9 |     (misc/capitalize-words \"\") => \"\")))\n----------------------------------------------^---------------------------------\nnubank/shuffle/common/logic/misc_ws.cljs [line 9, col 40] Unmatched delimiter ).\n\n--------------------------------------------------------------------------------\n  10 | \n  11 | (ws/deftest test-index-of\n  12 |   (assertions\n  13 |     (misc/index-of #{:b} [:a :b :c]) => 1\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"] {:ex-kind :reader-error, :source-excerpt {:start-idx 5, :before ["(ws/deftest test-capitalize-words" "  (assertions" "    (misc/capitalize-words \"hello world\") => \"Hello World\""], :line "    (misc/capitalize-words \"\") => \"\")))", :after ["" "(ws/deftest test-index-of" "  (assertions" "    (misc/index-of #{:b} [:a :b :c]) => 1"]}, :file #object[java.io.File 0x6178a54c "/Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs"], :resource-id [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"], :ex-type :reader-exception, :column 40, :line 9, :url #object[java.net.URL 0x6fbf5713 "file:/Users/wilkerlucio/Development/nubank/shuffle/workspaces/nubank/shuffle/common/logic/misc_ws.cljs"], :source-id [:shadow.build.classpath/resource "nubank/shuffle/common/logic/misc_ws.cljs"], :tag :shadow.build.compiler/compile-cljs}} #error {:message "Invalid symbol: cloj … lang.ExceptionInfo:.", :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:150
(anonymous) @ browser.cljs:318
#2018-06-2217:52wilkerlucio(logged as warn in console)#2018-06-2217:57richiardiandrea@thheller I am an idiot, I forgot I had an uncaught exception handler registered#2018-06-2218:08thheller@wilkerlucio hmm weird. thought I fixed that. it fails reading the :file and :url #object literals#2018-06-2218:09wilkerlucioI'm on 2.5.7#2018-06-2218:09wilkerluciothe fix was after that?#2018-06-2218:09thhellerno. thought I fixed that a long time ago#2018-06-2218:09thheller2.1 or so#2018-06-2218:09thhellerplease open an issue. don't have time to look into it now#2018-06-2218:10wilkerluciosure#2018-06-2218:20richiardiandreaquestion, I have a server running, and I do watch :test in another terminal, is it expected that I see the console logs in the server terminal?#2018-06-2218:26thhellerdepends on the output. some output yes#2018-06-2219:16richiardiandreawhat do you think about adding these helpers to node-test? It is even more important to have them in shadow because of the different classpath approach
-n, --namespace SYMBOL                             Symbol indicating a specific namespace to test.
  -r, --namespace-regex REGEX  .*\-test$             Regex for namespaces to test. Only namespaces ending in '-test' are evaluated by default.
  -v, --var SYMBOL                                   Symbol indicating the fully qualified name of a specific test.
  -i, --include SYMBOL                               Run only tests that have this metadata keyword.
  -e, --exclude SYMBOL                               Exclude tests with this metadata keyword.
#2018-06-2219:19richiardiandreaor a subset#2018-06-2219:21richiardiandreasay I have integration tests, I don't have an easy way to exclude them in "normal" tests cause :ns-regexp is only inclusive#2018-06-2219:29thhellersure#2018-06-2219:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/node_test.clj#L40-L41#2018-06-2219:29thhellerpretty simple to write more sophisticated filtering#2018-06-2219:29richiardiandreawill open an issue for now- yep I was checking that#2018-06-2221:10ClashTheBunnyHey folks, has anybody gotten @material design react components working with shadow-cljs?#2018-06-2221:15thhellerthe file contains JSX code#2018-06-2221:15thheller
return (
      <button
        className={classes}
        ref={initRipple}
        {...otherProps}
      >
        {icon ? this.renderIcon() : null}
        {children}
      </button>
    );
#2018-06-2221:16ClashTheBunnyAaah. Any way to do that?#2018-06-2221:16thhellernot currently no#2018-06-2221:16thhellervery unusual for code on npm to contain jsx code#2018-06-2221:16thhellerusually only the converted kind#2018-06-2221:16thhellerguess someone forgot to do that#2018-06-2221:16ClashTheBunnyHow about with the non-react version: I get ExceptionInfo: module without entry or suffix: @material/button#2018-06-2221:17ClashTheBunnyNevermind, no javascript in that...#2018-06-2221:23ClashTheBunnyIs there a way to load sass into the app, possibly with sass4clj?#2018-06-2221:24thhellernot ouf of the box but can do something with build hooks for clj-run#2018-06-2221:39ClashTheBunnyIt does seem like the examples/babel project does the jsx stuff, but it may be broken. I get errors about the default on the export default MyDefaultComponent#2018-06-2221:43ClashTheBunnyand then it gets stuck on react's default statement.#2018-06-2221:49thhellerthe babel example is meant for project code outside node_modules since that is treated differently#2018-06-2223:11steveb8nis there an example anywhere that shows building a cljs/node AWS lambda artifact using shadow?#2018-06-2223:32richiardiandrea@steveb8n not doing exactly that, but you would build the JS with :node-script and then zip everything up (`node_modules` included)#2018-06-2223:33steveb8nthanks. I’ll give that a try#2018-06-2321:09theasp@thheller I'm having an issue with shadow-cljs release client server that doesn't happen with shadow-cljs release client && shadow-cljs release server. Am I missing something totally obvious? Would you like this in a ticket? Bad build: https://circleci.com/gh/theasp/lapidary/42 Good build: https://circleci.com/gh/theasp/lapidary/43#2018-06-2321:10theasp
[:client] Build completed. (637 files, 525 compiled, 0 warnings, 95.07s)
FileNotFoundException: .shadow-cljs/builds/server/release/externs.shadow.js (No such file or directory)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:270)
	java.io.FileOutputStream.<init> (FileOutputStream.java:213)
	 (io.clj:230)
	 (io.clj:230)
	 (io.clj:69)
	 (io.clj:166)
	 (io.clj:166)

The command '/bin/sh -c npm install --save-dev shadow-cljs && shadow-cljs release client server' returned a non-zero code: 1
#2018-06-2321:51theasphttps://github.com/thheller/shadow-cljs/issues/323#2018-06-2411:58smnplkIf I add ["firebase/firebase-firestore" :as db], I get the following error. failed to load module$node_modules$firebase$firebase_firestore#2018-06-2414:02thheller@smnplk https://github.com/jacekschae/shadow-firebase/blob/master/src/app/fb/init.cljs might help#2018-06-2414:43smnplk@thheller nope, I get "could not find module-entry: firebase/app." I am using firebase version 5 npm package, but you are using ver 4.#2018-06-2414:43thhellerI have not used any firebase at all so I don't know exactly#2018-06-2414:44thhellerbut typically firebase had "side-effecting" requires#2018-06-2414:45thhellerso you only had one main require and the others didn't return anything#2018-06-2414:45thhellerand instead just added stuff onto the firebase main thing#2018-06-2414:46smnplk@thheller Yeah I know, but I am trying to use es6 module packaging thingie, where you can require only what you need.#2018-06-2414:46thhelleryes thats what the demo above does#2018-06-2414:47smnplkI could probably require the whole thing with (:requie ["firebase" :as fb])#2018-06-2414:47thhellerfirebase/app used to be an alias for @firebase/app so maybe the alias is just gone?#2018-06-2414:48smnplkyes, but demo above is using firebase ver 4. If I use the import from demo in my code, which uses firebase ver 5 package, it doesnt compile#2018-06-2414:48smnplki think it's now firebase/firebase-app.#2018-06-2414:50thheller@firebase/app still exists when I npm install firebase#2018-06-2414:51thheller "firebase": "^5.1.0"#2018-06-2415:00thheller@smnplk I get Uncaught ReferenceError: firebase is not defined when trying to load firebase/firebase-firestore so it seems like you are not meant to use those files directly when using a build tool#2018-06-2415:00thhellerseems like they are made for direct <script src=...> inclusion#2018-06-2415:06thheller
["@firebase/app" :default fb]
    ["@firebase/firestore"]
#2018-06-2415:06thhellerseems to work fine?#2018-06-2415:15bbssI'm having an issue with releasing, in my chrome-ext with which I develop locally it works but when using shadow-cljs release dev it doesn't anymore. One of the node_modules deps is an empty object when importing.#2018-06-2415:17thhellermight be externs? do you have :infer-externs :auto turned on?#2018-06-2415:17thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-06-2415:18bbsshttps://github.com/bbss/cljsc2/blob/master/shadow-cljs.edn Nope, don't have it on.#2018-06-2415:19bbssreading up on the article#2018-06-2415:19smnplk@thheller I see. But we aren't suppose to use "@firebase" packages directly#2018-06-2415:20thheller@bbss I'm confused. you said chrome-ext but the :dev build is a browser build?#2018-06-2415:21bbssyes, I'm just doing the chrome-ext for development.#2018-06-2415:22bbssI'm doing that so I can develop with the web-page from my production server#2018-06-2415:23bbssIt might be possible to do that without a chrome extension.. I'm not sure 🤔 .#2018-06-2415:23thhellersorry I'm lost. your cljsc2.cljs.core imports a bunch of chrome specific apis#2018-06-2415:24bbssOh, yeah it does. Those are not used anymore I think.#2018-06-2415:24bbssI don't think the issue I'm having now is related to the chrome-ext. Sorry for the misdirection.#2018-06-2415:25thhellerso shadow-cljs watch dev works?#2018-06-2415:25thhellerI can't figure out this project. seems to be a bit all over the place#2018-06-2415:26bbssYeah.. It's a bit of a mess, in the process of cleaning it up right now. But still a lot of imports that aren't needed.#2018-06-2415:27bbssthe shadow-cljs watch dev seems to work. but with externs on I do get some warnings: Cannot infer target type in expression (. (gdom/getElement "notebook-container") prepend el)#2018-06-2415:30thhellerthats fine but you are using :optimizations :simple anyways so its probably not externs#2018-06-2415:31smnplknope. TypeError: module$node_modules$$firebase$app$dist$index_cjs.initializeApp is not a function#2018-06-2415:32thheller:as vs :default?#2018-06-2415:40smnplkthe above type error is if I use :as , If I use :default, I get "BUILD-WARNING in app/firebase.cljs at [13:2] No such namespace: firebase, could not locate firebase.cljs, firebase.cljc, or JavaScript source providing "firebase""#2018-06-2415:41thheller
["@firebase/app" :default fb]
    ["@firebase/firestore"]
#2018-06-2415:41thheller(.initializeApp fb ...)#2018-06-2415:41thhellerworks fine#2018-06-2415:44smnplkI asked because it complained about undeclared Var before, I had to restat shadow, now it looks like it's working fine. Thank you kind sir 🙂#2018-06-2415:32bbssThis line is erroring: https://github.com/bbss/cljsc2/blob/master/src/cljsc2/cljs/parinfer_wrap.cljs#L18#2018-06-2415:32bbssis there something wrong with my import syntax maybe? I tried making the first parinfer-codemirror a string. But that didn't change it.#2018-06-2415:34thheller{:forceBalance true} looks wrong. probably should be #js {:forceBalance true}?#2018-06-2415:35bbsshmmm, I'll try. but if I js/console.log parinfer-codemirror it seems to be an empty object, so init is not defined.#2018-06-2415:36thhellerjust did a release build with parinfer-codemirror and the object is not empty#2018-06-2415:45bbssmaybe something wrong with the module syntax? https://github.com/shaunlebron/parinfer-codemirror/blob/master/parinfer-codemirror.js#2018-06-2415:45thhellernope. I just tested with that version. works fine#2018-06-2415:46bbssHmm, I'm not really sure why for me the import is not working then.#2018-06-2415:47thhellercheck if node_modules/parinfer-codemirror/parinfer-codemirror.js is the actual file you want?#2018-06-2415:52bbssYes, it is the one I want. In my chrome-ext it does work. Interestingly in that file codemirror is defined, but the parinfer and parinfer-codemirror are both empty objects. Both are from the same author so could it be the exporting syntax is the culprit?#2018-06-2415:52thhellerit works absolutely fine for me#2018-06-2415:53thhellerso it must be something in your setup#2018-06-2415:54bbssOkay, I'll dig deeper. I am loading it into a jupyter notebook, and it might be somehow the module systems are clashing#2018-06-2416:03bbssHowever the codemirror import does have the version from npm, and the one used by jupyter notebook is a different version.#2018-06-2416:04bbssNo errors/relevant warnings. 😕#2018-06-2416:04thhellermaybe jupyter is using require.js? amd?#2018-06-2416:04bbssyes, it is.#2018-06-2416:04thhellerah ok. https://github.com/shaunlebron/parinfer-codemirror/blob/master/parinfer-codemirror.js#L14#2018-06-2416:05thhellerthat is checked first so it attempts to make require.js happy#2018-06-2416:05thhellerand doesn't get to the part we need#2018-06-2416:06bbssAh, I will edit the file in node_modules.#2018-06-2416:07thhellerprobably not a good idea#2018-06-2416:07thhellerI know nothing about jupyter but maybe there is a way for you to remove the define?#2018-06-2416:08bbsssomething like window.define = undefined after the jupyter notebook js?#2018-06-2416:10thhellerthat might do it? I have no idea how/when jupyter loads the code#2018-06-2416:24bbssyep! included a (:require ["definedeleter.js"] in the file, does the trick!#2018-06-2416:24bbss@thheller thanks so much once again!#2018-06-2416:32thheller@bbss you can also use :entries [..] :prepend "window.define = undefined;" in your :modules config#2018-06-2416:32thhellermaybe even :prepend "window.defineOriginal = window.define; window.define = undefined;" :append "window.define = window.defineOriginal;"#2018-06-2416:33thhellerso its restored properly when CLJS is finished loading#2018-06-2416:35thhellerI could probably add a fix for this so the define branch is never taken in amd wrapped files#2018-06-2416:35thhellersince we never want that#2018-06-2416:36bbssThe prepend append is even cleaner, and it works 🙂 Thanks again.#2018-06-2416:36bbssThanks for sticking with me and my ridiculously exotic set-ups 😅#2018-06-2416:37thhelleryou could definitely clean up a little 😉#2018-06-2416:43bbssHahah, yes for sure.. This weekend was already a big improvement though. Went from a very biiiig main file to splitting it up into somewhat reasonable namespaces.#2018-06-2416:44bbssRecompile times were getting to 20 seconds. Now down to sub second again.#2018-06-2416:44bbssOnly dev.. so I'm not too hard on myself 😄#2018-06-2510:35thheller@smnplk turns out there was a bug in shadow-cljs resolve rules that prevented firebase/app from working properly. fixed in 2.4.9.#2018-06-2511:54ClashTheBunnyHey @thheller, just wanted to follow up and let you know that RMWC works perfectly. I did a quick update to the shadow-reagent example with the buttons replaced with react components from that project: https://gitlab.com/randall.mason/shadow-rmwc-reagent-example/#2018-06-2511:55ClashTheBunnyWe’ll see if Google gets their act together and compiles the JSX in their version of the react wrapper.#2018-06-2514:06mhueberthmm, any ideas about an error like this:
FileNotFoundException: .../stest/node_modules/apollo-upload-client/lib/main (Is a directory)
        java.io.FileInputStream.open0 (FileInputStream.java:-2)
        java.io.FileInputStream.open (FileInputStream.java:195)
        java.io.FileInputStream.<init> (FileInputStream.java:138)
I tried adding this option:
:js-options {:resolve {"apollo-upload-client" {:target :npm
                                                           :require "apollo-upload-client/lib/main/index.js"}}}
where apollo-upload-client/lib/main/index.js is definitely a file, and then I still get:
ExceptionInfo: :resolve override for "apollo-upload-client" to "apollo-upload-client/lib/main/index.js" which does not exist
the file I am trying to compile:
(ns example.core
  (:require ["apollo-upload-client"]))
#2018-06-2514:10thheller@mhuebert is that after upgrading to 2.4.9?#2018-06-2514:10mhuebertIt is a fresh project so I am using 2.4.9 but haven’t tried on an earlier version#2018-06-2514:11mhueberti’ll try now#2018-06-2514:12mhuebertcompiles in 2.4.8#2018-06-2514:14thheller
"main": "lib/main",
  "module": "lib/module",
#2018-06-2514:14thhellerwould be impossibly hard for them to write lib/main/index.js instead 😛#2018-06-2514:15thhellerwill fix, guess I removed a branch for that somewhere#2018-06-2514:37thheller@mhuebert should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adb7adb2b3"}, :content ("[email protected]")}#2018-06-2515:58theasp@thheller Did the default for node.js change to advanced compilation?#2018-06-2517:06thheller@theasp yes#2018-06-2520:16lilactownare there any tips to speeding up release builds?#2018-06-2520:17lilactownatm we are running in jenkins. running npx shadow-cljs release build1 build2 is taking about ~360s#2018-06-2520:18thhellerI guess you are always recompiling from scratch then? ie. no cache?#2018-06-2520:19lilactowncorrect#2018-06-2520:19thhellerstep #1: add cache 😉#2018-06-2520:19lilactown😂 any tips on how to do that?#2018-06-2520:20thhellerno idea how to do it in jenkins but you just need to "keep" .shadow-cljs/builds directory#2018-06-2520:20thhellermake sure its persisted between builds#2018-06-2520:20lilactownI'm kind of dumb at the CI stuff. we're using docker in a runner, so I know we can leverage some caching with the docker containers#2018-06-2520:21lilactownhmm#2018-06-2520:24thhelleryou can try running the builds after each other instead of concurrently but that probably won't help much since the threadpool should ensure that all cores are properly ulitilzed#2018-06-2520:24thhellerbut running in parallel consumes more memory then running sequentially#2018-06-2520:24thhellerso if you are memory constrained that might help#2018-06-2520:25lilactownahh interesting#2018-06-2520:26lilactownI would probably want to start the shadow-cljs server separately then#2018-06-2520:26thhelleryou can use clj-run or run#2018-06-2520:27thhellerie. write a (defn build-all [] (shadow/release :build1) (shadow/release :build2)) then shadow-cljs run that.ns/build-all#2018-06-2520:28thhellerbut that won't do as much as caching would#2018-06-2520:29thhellercaching will probably bring it down to 60sec or so#2018-06-2520:29thhellersequential maybe 330sec#2018-06-2520:29thhellerunless you are really really low on memory#2018-06-2520:29thhellerlike 512mb or so#2018-06-2520:29lilactownit could honestly be around that. it depends on how many other jobs are running#2018-06-2520:31lilactownI'll fiddle with it for a bit and see if I can figure out how to persist the cache between builds. thanks @thheller 🙂#2018-06-2520:33thhellercache should be the best option. beyond that you can try messing with :jvm-opts ["-Xmx2G"] or so in shadow-cljs.edn#2018-06-2520:34thhellerthis would put the max memory for the jvm at 2gb#2018-06-2520:34thhellerwhatever makes sense for the machine the build is running on. this can sometimes help a bit but nothing like caching would#2018-06-2521:35lwhortonhey guys, does shadow-cljs support git shas as dependencies, or should i move my whole dep tree to deps.edn and deal with it there?#2018-06-2521:39thhellerno, not supported. only via deps.edn + :deps true#2018-06-2523:03lilactownis there some incantation to see the dependency tree of my project using just shadow-cljs (not lein or deps.edn)?#2018-06-2523:11lilactownalso does it support exclusions?#2018-06-2523:13lilactownbecause this is currently failing:
:dependencies
 [[cider/cider-nrepl "0.16.0-SNAPSHOT"]
  [binaryage/devtools "0.9.7"]
  [devcards "0.2.5"]
  [re-frame "0.10.5"
   :exclusions
   [reagent "0.7.0"]]]
#2018-06-2523:14lilactown
shadow-cljs - dependency update failed - java.lang.Character cannot be cast to clojure.lang.Named
#2018-06-2523:23richiardiandreaHello folks! I am doing:
(ns my-ns 
  (:require [azure-storage :as az-storage]))
but I receive
conflict on "az-storage" by "azure-storage" used by "shadow.js.shim.module$azure_storage"
{:tag :shadow.build.ns-form/require-conflict, :ns-info {:rename-macros nil, :renames {}, :meta {:source "ep-cloud.azure", :file "repl-input.cljs", :line 1, :column 5, :end-line 1, :end-column 19}, :ns-aliases {clojure.spec.alpha cljs.spec.alpha, lodash.upperfirst shadow.js.shim.module$lodash_upperfirst, fs shadow.js.shim.module$fs, bunyan shadow.js.shim.module$bunyan, pg shadow.js.shim.module$pg, process shadow.js.shim.module$process, util shadow.js.shim.module$util, clojure.pprint cljs.pprint, dotenv shadow.js.shim.module$dotenv, lodash.camelcase shadow.js.shim.module$lodash_camelcase, lodash.kebabcase shadow.js.shim.module$lodash_kebabcase, ajv shadow.js.shim.module$ajv, aws-sdk shadow.js.shim.module$aws_sdk}, :use-macros nil, :excludes #{}, :name ep-cloud.azure, :js-aliases {"azure-storage" shadow.js.shim.module$azure_storage}, :imports nil, :requires {node-util util, ep-cloud.define ep-cloud.define, shadow.js.shim.module$azure_storage shadow.js.shim.module$azure_storage, cljs.core cljs.core, gobj goog.object, goog goog, goog.object goog.object, util util, az-storage shadow.js.shim.module$azure_storage, azure-storage azure-storage, shadow.js.shim.module$util shadow.js.shim.module$util, def ep-cloud.define}, :seen #{:require}, :uses nil, :require-macros {cljs.core cljs.core}, :flags {:require #{}}, :js-deps {"azure-storage" {:as az-storage}}, :deps [goog cljs.core ep-cloud.define goog.object shadow.js.shim.module$util shadow.js.shim.module$azure_storage util azure-storage]}, :merge-key :requires, :sym az-storage, :ns azure-storage}
ExceptionInfo: conflict on "az-storage" by "azure-storage" used by "shadow.js.shim.module$azure_storage"
	clojure.core/ex-info (core.clj:4754)
	clojure.core/ex-info (core.clj:4754)
	shadow.build.ns-form/merge-require (ns_form.clj:245)
	shadow.build.ns-form/merge-require (ns_form.clj:238)
	shadow.build.ns-form/process-symbol-require (ns_form.clj:292)
	shadow.build.ns-form/process-symbol-require (ns_form.clj:281)
	shadow.build.ns-form/process-require (ns_form.clj:323)
	shadow.build.ns-form/process-require (ns_form.clj:320)
#2018-06-2523:23richiardiandreawhat does the above mean?#2018-06-2523:23richiardiandreaI don't need the require?#2018-06-2523:23richiardiandreaI cannot alias it?#2018-06-2523:24richiardiandrearename to only storage seems to solve it#2018-06-2602:47steveb8nHI all, I’m having trouble making the :node-library target work with the shadow CLI tool installed via npm i.e. not via a lein REPL#2018-06-2602:47steveb8nhas anybody else had success with this in the past?#2018-06-2602:48steveb8nI’m using :exports with a map and I’m getting an error#2018-06-2602:48steveb8nThe required namespace "pages.handlers" is not available, it was required by "shadow/umd_helper.cljs".#2018-06-2602:48steveb8nbut that namespace is in the correct place under the “src” dir#2018-06-2604:19steveb8nand it works ok when using lein to manage classpath i.e. server and build/watch commands invoked in REPL#2018-06-2606:12thheller@lilactown exclusions are just the symols without versions. thats what it complains about. will add a spec for that.#2018-06-2606:14thheller@steveb8n are you sure the :source-paths are the same?#2018-06-2606:14lilactownahhh ty ty!#2018-06-2606:14steveb8nI tried without :source-paths and with. no change#2018-06-2606:15thhellerand what is your :source-paths now?#2018-06-2606:15thhellerit is required so you cannot take it out. unless using lein or deps or course#2018-06-2606:16steveb8nwhat’s stranger is that it works for the :node-test target#2018-06-2606:16steveb8nbut since I have it working via the repl I am avoiding the CLI for now#2018-06-2606:16thhellerjust check the source paths#2018-06-2606:17thhellerand then check <source-path>/pages/handlers.cljs#2018-06-2606:17steveb8nok. I’ll switch back. gimme a couple of mins#2018-06-2606:17thheller:node-test discovers files so you may just have a typo in your namespace#2018-06-2606:17thhellerie. the ns is page.handlers or pages.handler#2018-06-2606:17thhellereasy to overlook#2018-06-2606:19steveb8nsource paths is :source-paths ["src"]#2018-06-2606:19steveb8nhave reproduced now#2018-06-2606:19steveb8nhave confirmed correct ns is pages.handlers#2018-06-2606:20steveb8nonly other possible mistake is `:exports {:home pages.handlers/home-page :context pages.handlers/app-context-page}`#2018-06-2606:20thhellerand you have confirmed that you have a src/pages/handlers.cljs?#2018-06-2606:21steveb8nmaybe not “only” 🙂#2018-06-2606:21steveb8nyes. must be ok since it works via repl#2018-06-2606:21thhellercould be src/pages/handlers.clj#2018-06-2606:22steveb8ndefinitely .cljs#2018-06-2606:22thhellerand what does shadow-cljs browser-repl then (require '[pages.handlers :as x]) give you? without lein?#2018-06-2606:24steveb8nthe repl starts but the require fails#2018-06-2606:24steveb8nhere’s my shadow file contents#2018-06-2606:25steveb8n`{;:lein true ; let lein/project.clj manage source-paths and deps :dependencies [] :builds {:pages {:target :node-library :source-paths [“src”] :js-options {:js-provider :shadow} ; include deps in single resource :output-to “out/pages/handlers.js” ; where does compilation output go :exports {:home pages.handlers/home-page :context pages.handlers/app-context-page} :release {:output-to “out/release/handlers.js”}} :test {:target :node-test :source-paths [“src” “test”] :output-to “out/tests/node-tests.js” :ns-regexp “-spec$” :autorun true}}} `#2018-06-2606:25thhellerah ...#2018-06-2606:25steveb8nI’m using the :pages build#2018-06-2606:25thheller:source-paths is only at the top level. it is not per build.#2018-06-2606:25steveb8nI tried that also. will retry again to check my sanity#2018-06-2606:26thheller:js-options {:js-provider :shadow} ; include deps in single resource this doesn't work for node#2018-06-2606:26thhellersee https://github.com/thheller/shadow-cljs/issues/290#2018-06-2606:26steveb8nthat was going to be my next question. I’m hoping for a way to generate 1 big js artifact for node. this is destined for AWS lambda#2018-06-2606:26steveb8nI’ll comment it out for now#2018-06-2606:27steveb8nok, with :source-paths at top level, same error when required in repl#2018-06-2606:28thhellerdid you restart the server properly?#2018-06-2606:28steveb8nno! restarting…#2018-06-2606:29steveb8nit works!#2018-06-2606:30steveb8nso it was the top level key in that case. thank you - again!#2018-06-2606:30steveb8nsince you are here. the webpack workaround for the single file bundle. is there an example of that somewhere?#2018-06-2606:31steveb8nI’ve recently used webpack/umd so I can work it out but an example will be faster#2018-06-2606:31thhellerno idea, I never did that#2018-06-2606:31steveb8nok. I’ll dig into it. thanks#2018-06-2606:32steveb8nwhen deploying a node module to AWS lambda, a single file is much easier to manage#2018-06-2606:33steveb8nFYI : this is for a sample project using Datomic Ion so might get a little more support for shadow once we have it working#2018-06-2606:34thhellerI have not used any of the cloud stuff. all my projects are too small to justify cloud stuff. I'm open to adding support for it just don't have the time to look into it currently.#2018-06-2606:35steveb8nno worries. we’ve got your back on the cloud stuff#2018-06-2606:35thhellerit is definitely possible to do one-file but needs some special treatment since everything is currently meant for the browser#2018-06-2606:35thhellerand some of the node emulation stuff needs to be adjusted to not emulate but rather use the real thing#2018-06-2606:35steveb8ncool. it’s not urgent since there is a workaround. I’ll try it out and report back#2018-06-2606:36steveb8nBTW : I’m going to ClojuTre. will you attend that?#2018-06-2606:37thhellerno#2018-06-2606:37steveb8nshame. would be nice to shake hands one day#2018-06-2606:37steveb8nok I’ll get back to it. thanks again#2018-06-2607:23thhellerone day I'll go to a conference 😉 they are usually too far away and I hate travelling#2018-06-2609:52mhuebertI’ve created a small PR for an issue with watch* - https://github.com/thheller/shadow-cljs/pull/326 - it is currently throwing away the config map it is passed, re-reading the config from its build-id.#2018-06-2609:58thheller@mhuebert oops. the if check should just be removed since it always expects a build-config map. passing a keyword would break the destructure above#2018-06-2610:00thhellerfixed in master#2018-06-2613:43grounded_sageI know this is very side effecty but I can't seem to run this in my clj-run (map #(spit (str % ".txt") "test") ["one" "two"])#2018-06-2613:54grounded_sageI probably need a recursive function but I'm still curious why it doesn't run but the spit on it's own works and doing this function in a repl works as well.#2018-06-2616:17thheller@grounded_sage clj-run is for calling fully qualified functions, ie. your.thing/foo#2018-06-2616:19thhellerif you are doing that inside your function then note that map is lazy and doesnt do anything unless consumed (wrap in doallor use doseq)#2018-06-2616:27pezCan the :node-test target be made to generate tests from the :test functions inside function attribute maps?#2018-06-2616:29thheller@pez maybe? it currently relies in cljs.test/deftest but since cljs.test doesn't look for anything besides that the change would really need to be in cljs.test#2018-06-2616:35thhellerI also sort of tried to avoid macros since they make everything harder#2018-06-2616:35thhellerand since you need a macro to get the metadata it doesn't seems like a good idea#2018-06-2616:37pezHmmm, I wonder why it is not part of cljs.test already…#2018-06-2616:38thhellerwhats wrong with deftest? having lots of metadata on defns makes them sort of unreadable no?#2018-06-2616:39thhellerand all your namespaces need to import cljs.test for the is assertions? it is generally best practice to have separate your.thing and your.thing-test namespaces#2018-06-2616:40pezI think it is very readable to have the tests embedded in the function tested. I like to “document” my functions that way.#2018-06-2616:43pezI have decided not to use CLJC for the ClojureScript parts of my extensions. It makes it a bit less easy to access the node ecosystem. But at the same time cuts me out of my embedded tests. I was hoping I could eat the cake and have it. 😃#2018-06-2616:43thhellerwell you can write your own macro to do this. there just isn't anything built-in#2018-06-2616:44pezYou mean a macro that creates the deftest as well as the defn for me?#2018-06-2616:50pezThis might be a silly example, but I think it is readable:
(defn- split
  "Splits text at idx"
  {:test (fn []
           (is= [" " " "]
                (split "  " 1))
           (is= ["(foo\n " "\n bar)"]
                (split "(foo\n  \n bar)" 6)))}
  [text idx]
  [(subs text 0 idx) (subs text idx)])
#2018-06-2616:53pezIt helps me use the REPL to create the function TDD-style. And then I can leave some of the “exploration” code as unit tests where they help both with testing and explaining what the function does.#2018-06-2616:54pezAnyway, I probably will write any macro helping me keep this style of coding. Just not sure what kind of macro is needed. 😃#2018-06-2621:30pezIs there a way to get the tests to automatically run when they are built using watch?#2018-06-2622:21thheller:autorun true#2018-06-2702:34grounded_sage@thheller thanks. I thought it was something on my end 🙂#2018-06-2707:13pez@thheller I have :autorun true, The watcher recompiles the test target and I can run it using node, but it is not automatically run, AFACS.#2018-06-2716:34lilactown
:server-tests {:target :node-test
                         :output-to "target/test/tests.js"
                         :ns-regexp ".test."
                         :autorun "true"}
#2018-06-2716:34lilactown^ works for me#2018-06-2716:45richiardiandrea^ have a similar setup and it works for me as well#2018-06-2718:42lilactowndoes anyone have an example using karma with devcards?#2018-06-2718:42lilactownI seem to remember an example floating around#2018-06-2719:33nijkDoes anyone know why the Shadow User Guide suggests an npm install of shadow-cljs both locally and globally?#2018-06-2719:33nijkhttps://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code#2018-06-2719:34nijk> $ npm install --save-dev shadow-cljs > $ npm install -g shadow-cljs#2018-06-2720:10justinleeI think the reason is because the global version installs the cli on your path but the local version is the actual compiler that gets used. you presumably want the compiler version checked into your source code control but it is convenient to have the cli on the path.#2018-06-2720:44thheller@nick828 the global install is just for convenience. only the one in the project actually matters#2018-06-2721:24nijk@lee.justin.m @thheller Thanks 👍#2018-06-2723:00lwhortonhmm, has anyone bumped into shadow-cljs - command completed without status #js { .. giant js object }?#2018-06-2723:07lwhortoni can only reproduce it in a ci environment, not locally. this probably means it has something to do with running inside a docker container. it’s kind of hard to debug becuase the output is something like {:status nil, :signal "SIGKILL", :output #js [nil nil nil], :pid 546, :stdout nil, :stderr nil … not super helpful 😞#2018-06-2723:57lwhortonafter some more investigation, this seems like a memory issue. if i increase my docker limits (docker for mac) to 8gb instead of 4, my local docker image build completes. since i’m using circleci (which has a 4gb-per-build limit) i’m not really sure what else to do. oh no.#2018-06-2805:11lilactownI think you can configure the amount of memory the JVM will use#2018-06-2805:12lilactownthere’s a known issue where docker containers do not expose the amount of RAM actually available, so the jvm will consume more than allocated for the container#2018-06-2805:20lilactownyou should be able to manually configure the amount of memory the JVM will consume, either through shadow-cljs or through defaults of whatever java runtime you’re using in the container itself#2018-06-2805:40bupkisis there a way to rename the default export when requiring a JS library? Looking at the "ES6 Import to CLJS Require" table in the User's Guide, but don't see that, so I was wondering whether I'm missing something obvious?#2018-06-2805:52levitanong@thheller I’m getting an error when i open the output from build-report. It was a complaint about an odd number of map elements in a map, because node_modules/date-fns has 201 elements. I suspect this is because the date-fns library contains several sub-folders—one for each function—so that the user can cherry-pick the individual fns she wants to use.#2018-06-2806:32pez@lilactown @richiardiandrea thanks, it was actually working for me as well. I was just tricking myself by running a separate watcher for the test target and looking there for test results. But the results where coming from my node-libarary target… Now I am running both targets from the same watcher and it works. Almost. I do get en error on startup:
Error: ENOENT: no such file or directory, open '/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js'
Is there a way I can avoid that? Am I still going about it the wrong way?
#2018-06-2806:36pez(From there on whenever I save the file tests are run. But I would prefer they ran at startup too, w/o throwing errors in my face.)#2018-06-2807:04thheller@lwhorton SIGKILL looks indeed like the process is getting killed by maybe the OOM killer. you can configure the max memory by setting :jvm-opts ["-Xmx2G"] in shadow-cljs.edn.#2018-06-2814:35lwhortonyea, i finally figured it out. it was the 4gb-per-instance limit in circle, so if I set JVM_TOOL_OPTIONS -Xmx3g everything goes through fine#2018-06-2814:36lwhortondidn’t know there was a jvm-opts config, though. thanks!#2018-06-2807:06thheller@samuel.wagen you can choose whatever name you want for :default (eg. :default whatever). the name is completely up to you.#2018-06-2807:09bupkis@thheller Oh now I see! it makes sense. thanks.#2018-06-2807:10thheller@pez there was a race condition in :node-test. fixed in master, will make a release later#2018-06-2807:11thheller@levitanong what is the error exactly?#2018-06-2807:23levitanongFor some reason it works now. It might be a lein clean thing. Sorry for the noise!#2018-06-2807:25thhellerI'm especially interested in those issues though. lein clean should NEVER be required ever. If it is its a bug I want to fix. please let me know if you run into this again#2018-06-2807:30levitanongWill do!#2018-06-2807:31levitanongReproduced it!
#error {:message "The map literal starting with \"node_modules/date-fn...\" contains 201 form(s). Map literals must contain an even number of forms.", :data {:type :reader-exception, :ex-kind :reader-error}}
#2018-06-2807:31levitanonghappens when i run generate from the repl#2018-06-2807:34thhellercan you open the HTML file and look for node_modules/date-fn?#2018-06-2807:34thhelleris there really a ... in there?#2018-06-2807:34thhellerwait .. is the error from the CLJ side or CLJS side?#2018-06-2807:35levitanongoh boy i shouldn’t have opened it in emacs#2018-06-2807:35levitanongcljs side#2018-06-2807:35levitanongwell. more on javascript side#2018-06-2807:35thhellerhehe yeah the file can be huge
#2018-06-2807:17grounded_sageI'm looking to run some node scripts to manipulate some files. Is Nashorn the best way to go about this?#2018-06-2807:17thhellerno. node?#2018-06-2807:17grounded_sageIt's kind of during the clj-run step.#2018-06-2807:18grounded_sageI want to run Critical to inlines critical css and Subfont to do font subsetting.#2018-06-2807:18thhellerstill node#2018-06-2807:19thhelleryou can use clojure.java.shell/sh#2018-06-2807:19grounded_sageOk I had a feeling that was the case which is why I asked before I dove in.#2018-06-2807:20grounded_sageAhh yea I was about to ask whats the best way to trigger node scripts. But that seems way more simpler. Just jump into the shell.#2018-06-2807:21thhellershadow-cljs uses babel internally for some of the node_modules rewriting and does so by launching a node process#2018-06-2807:21thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/babel.clj#L36#2018-06-2807:22thhellerthe node process just wait for input from stdin and writes replies to stdout#2018-06-2807:22thhellerit basically just communicates via EDN messages back and forth#2018-06-2807:23thhellerdoesn't have to be this complicated if you just want to call something once#2018-06-2807:23thhellerbut in case of the babel stuff starting a new node process for each transformed file was way too slow#2018-06-2807:24grounded_sageI want to run Critical, Subfont during the production step. Lighthouse during an Audit step and Puppeteer for a testing step.#2018-06-2807:25grounded_sageMy preference would be to stay out of vanilla JS as much as possible. Just thinking through the best way to do it 🙂#2018-06-2807:26thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/transform.cljs#2018-06-2807:26thhellerthis is the file doing the node side of things#2018-06-2807:26thhelleryou can easily do the same and just communicate via EDN messages#2018-06-2807:27grounded_sageCheers!#2018-06-2807:27grounded_sageThat's what I want to do so that should help me get there#2018-06-2807:38thhelleryeah there it is right at the bottom#2018-06-2807:38thheller4360, ...}#2018-06-2807:39thhellerno idea how the ... gets there. its supposed to be using the safeguard for that so emacs settings *print-length* doesn't mess it up#2018-06-2807:39thhelleroh nvm ...#2018-06-2807:39levitanongi used vim for this#2018-06-2807:40levitanongi generally use vim for huge files haha#2018-06-2807:40thhellerbut you are using emacs cider REPL to run the generate#2018-06-2807:40levitanongah right#2018-06-2807:40thhellerand thats the problem since emacs unconditionally sets *print-length* for the REPL#2018-06-2807:40thhellerit will work if you do (binding [*print-length* nil] (generate ...))#2018-06-2807:41thhellerwill add a fix for it#2018-06-2807:41levitanonghurrah!#2018-06-2807:41levitanongthanks @thheller#2018-06-2807:43levitanongYeah, that fixes it!#2018-06-2807:43thhellercider setting *print-length* is really really bad for shadow-cljs 😛#2018-06-2810:58henrygarnerI have a project that builds in shadow 2.4.8 but fails in >= 2.4.9 with > The required JS dependency "entities/lib/decode_codepoint.js" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js". It looks as though the way package require handling changed in 2.4.9: https://github.com/thheller/shadow-cljs/compare/3a43f6d...a2c870c . But require in htmlparser2 looks okay to me... https://github.com/fb55/htmlparser2/blob/master/lib/Tokenizer.js#L3 (unlike the issue with clipboard I ran into last week, the required file does actually exist this time!)#2018-06-2811:00thheller@henrygarner odd. I'll take a look shortly#2018-06-2811:13thheller@henrygarner fixed in 2.4.11. thanks for the report.#2018-06-2811:27henrygarnerAmazing! Thanks @thheller 👌#2018-06-2813:59thheller@smnplk ideally you want to avoid running code "globally" and instead move it into a :dev/after-load callback#2018-06-2813:59thhellersince an exception while loading code prevents other code from being loaded properly#2018-06-2814:10smnplkI have it in :builds :app :devtools :after-load --> app.main-view#2018-06-2814:10smnplkI am using the latest version of cli and npm shadow-cljs#2018-06-2814:11thhellerah right sorry. forgot that any error will cause the display above#2018-06-2814:11smnplkThe problem occurs only if i call (app-routes) inside main-view function.#2018-06-2814:11smnplkbut if i add it somewhere outside, all works fine#2018-06-2814:11thheller(app-routes) probably uses goog.History which must only ever be created once#2018-06-2814:13smnplkI am importing goog.History#2018-06-2814:13thhellerthe error means that the div#wrapper element does not exist#2018-06-2814:13smnplkIll try defonce#2018-06-2814:14thhellerand goog.History will reset the dom when it is constructed when the page finished loading#2018-06-2814:14smnplkwhoa, didn't know that it resets the dom.#2018-06-2814:15thhellergoog.History is sort of ancient and should probably not be used anymore#2018-06-2814:15thhellerhttps://google.github.io/closure-library/api/goog.history.Html5History.html is the successor#2018-06-2814:15smnplksuggestion for any better routing lib that uses Html5History ?#2018-06-2814:16smnplkOh, just found one. Bide 🙂#2018-06-2814:24smnplk@thheller, I just switched to Html5History and the problem went away.#2018-06-2819:33justinleefor grins i tried running shadow-cljs on an amazon c5d-xlarge instance. i am surprised that it only runs twice as fast as my 2012 era macbook. i guess single threaded performance just isn’t improving much now#2018-06-2819:40thhelleron my desktop I get cljs.core compile times of about 2.5sec which is substantially faster than my macbook with about 6sec#2018-06-2819:42justinleeyea my macbook is about 6-6.5 seconds#2018-06-2819:43thhelleri have the i7-8700k which still seems to be the best in single core perf#2018-06-2819:44thhellerwonder how much compiler can still be tweaked to get more out of each core#2018-06-2819:45justinleei feel like there are opportunities for more sophisticated dependency analysis#2018-06-2819:45thhellernot for single-ns compiles#2018-06-2819:46thhellercan't do those in parallel#2018-06-2819:46thhellerbig ns like cljs.core are the bottleneck since everything else has to wait for them to compile#2018-06-2819:47justinleei meant more like realizing that although a dependency i include changed, i really don’t need to recompile because the function i’m using didn’t change#2018-06-2819:47justinleei have tons of functions in one file that everything depends on, but in reality each file only depends on a small part. i could break it up (and eventually I will)#2018-06-2819:49thhelleryes incremental compiles could definitely be better with some more logic#2018-06-2819:49thhellerbut I mean clean non-cached performance which I think can be at least 50% faster still#2018-06-2819:49justinleeoh interesting. through parallel compile or something?#2018-06-2819:50thhellerno just by tweaking things. clojure compiles way faster but has to do a lot more work since the JVM is much less dynamic than JS#2018-06-2819:51thhellerso there are still probably some bottlenecks in the code somewhere that just need to be found and fixed#2018-06-2819:52thhellerits not a fair comparison since most of the clojure compiler stuff is written directly in java#2018-06-2821:58theeternalpulseI was wondering if crowdfunding a slack pro for clojurians would be worth it?#2018-06-2821:59theeternalpulseop, just looked at pricing lol#2018-06-2821:59justinleeit would be insanely expensive#2018-06-2822:00theeternalpulseYeah, I thought I saw reasonable pricing a while back, but for that price it's not even worth the history#2018-06-2822:01theeternalpulseAnd I clicked the wrong forum, my bad#2018-06-2917:59haywoodCan someone sorta explain how the cljs browser repl works with regards to eval'd values and re-compilation? It's kind of magic how I can declare an atom, and then reset! the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it. Is there a way to persist that value in the repl so that it survives a re-compilation?#2018-06-2918:00haywoodoh I guess I could shove it into local-storage#2018-06-2918:00haywoodalso is it possible to declare 'global' functions that are available at the repl no matter which namespace is currently selected?#2018-06-2918:01haywoodthis is all inside the cljs-repl started via (shadow/nrepl-select :app)#2018-06-2918:23justinleeyou can make a value survive recompilation by using defonce instead of def. that’s what you’ll want to with your application state#2018-06-2918:24justinleei’m not sure what you mean by >then reset! the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it.#2018-06-2918:24justinlee@haywood ^#2018-06-2918:25haywoodah awesome#2018-06-2918:25haywoodI mean:#2018-06-2918:26haywooddoing stuff like that, where I want to mess around with a value so I'll reset it in an atom. 'exercise' the code in the browser, come back and the atom will have the value#2018-06-2918:26haywoodit's pretty magic, and awesome#2018-06-2918:26haywoodlines 3 and 5 are afterwards when I'm messing around#2018-06-2918:28haywoodoh man, defonce is a game changer thanks#2018-06-2918:28justinleemaybe the piece you are missing is that when you drop into the cljs repl (by calling (shadow/nrepl-select :app) you are actually running code on the browser#2018-06-2918:29justinleewhatever code your run in the cljs repl is just like running javascript in the browser console, except that it gets compiled to js first#2018-06-2918:29haywoodyea the fact that I can write arbitrary code, eval it in the repl, and it gets compiled on the fly down to javascript and eval'd in the correct place is pretty wild#2018-06-2918:29haywoodyou're right#2018-06-2918:30haywoodis there a way to declare values in the repl that are "above" or global to all namespaces?#2018-06-2918:31justinleethat’s why the cljs repl is often totally effed up and hard to get going. you have a menage a trois of the browser, your editor / tty, and cljs compiler (which is running in java)#2018-06-2918:31justinleei don’t think so. people often ask for it but i haven’t seen an answer#2018-06-2918:31haywoodcool#2018-06-2918:31haywoodyea it's been working great for me, especially paired with debux#2018-06-2919:12haywoodso I was able to import debux and declare a 'global' dbg atom in cljs.user. and I can refer to those globally by fully qualifying the namespace 🙂#2018-06-2919:12haywoodthat basically satisfies my request for global stuff#2018-06-3000:11richiardiandreawhen I deploy my Azure app, I get a bunch of:
Stack: Error: ENOENT: no such file or directory, open 'D:\home\arichiardi\git\laputa\lambda-cqrs\.shadow-cljs\builds\az\dev\out\cljs-runtime\goog.debug.error.js'
what am I missing?
#2018-06-3003:51richiardiandreait looks like some path is built by looking at .shadow-cljs. This is shadow-cljs compile and I though I could still deploy that even if "unoptimized" without .shadow-cljs. Probably not - meaning compile is not self contained#2018-06-3005:20mjmeintjesHow do I build a local copy of shadow-cljs to test changes to the Clojure code?#2018-06-3005:20mjmeintjesAnd how to I make my project use that local copy?#2018-06-3009:09thheller@richiardiandrea if you deploy you MUST use shadow-cljs release your-thing. not compile.#2018-06-3009:09thhellercompile is a dev build only meant to run on the machine it was compiled one#2018-06-3009:11thheller@mjmeintjes option a) clone and lein install. option b) add <clone>/src/main to you :source-paths. option c) use lein + checkouts. option d) use deps.edn :local/root#2018-06-3009:11thhellerthe bug you reported is due to a change I did in the resolve code to fix a different bug. guess I introduced more than I fixed. will take care of it in a bit#2018-06-3021:30mjmeintjes@thheller Thanks, that seems pretty easy.#2018-06-3022:42dpsutton#2018-06-3022:43dpsuttonI'm trying to crank up shadow-cljs and running into this. Anyone encountered this before?#2018-06-3022:51dpsuttonso it was missing javafx. and java-atk after that. :duck:#2018-07-0102:48wilkerlucioI have some code where a depnedency is triggering a warning#2018-07-0102:49wilkerlucioand that's preventing shadow to reload the code, the HUD stays on, nothing is notified, at console it says it compiled and show warnings on dep libraries#2018-07-0107:57thheller@dpsutton never seen that error before. shadow-cljs doesn't use anything from javafx so its weird to get an error like that. IIRC only the nashorn CLJS REPL uses the javafx stuff. it looks like you are using the JRE thought and not the JDK?#2018-07-0107:58thheller@wilkerlucio thats a pretty vague description. typically warnings from libraries should only be shown once and not interfere with the live reload IF they come from the jar?#2018-07-0112:27wilkerlucio@thheller yeah, I found it strange, in this case Im back using deps.edn, and the package causing the issue is the core.matchers, I’ll try to make an example and send as an issue, I was wondering if just that description would make something click for you#2018-07-0113:02bolasblackWOW, I just tried fspec and seems the related issue has been fixed, thanks thheller!#2018-07-0113:35urbanslugAnyone here using sass?#2018-07-0113:35urbanslugMind telling me how you got that working?#2018-07-0116:09thheller@urbanslug I'm using node-sass in my work project directly from the CLI, didnt' try any of the JVM related sass tools.#2018-07-0116:10thheller@wilkerlucio ah are you using git deps? The logic for warnings currently assumes that all "library" code lives in jars but in case of git deps they are actual files so they are treated like project code with "sticky" warnings#2018-07-0116:28urbanslug@thheller does that work with live reload?#2018-07-0116:29urbanslugOh you have the node-sass tool running concurrently?#2018-07-0116:30thhellernode-sass is running separately yes but the css is live reloaded as well#2018-07-0116:31thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2018-07-0117:11justinlee@urbanslug i just fire off of a node-sass watcher using npm, which also fires up my api server and the shadow watch. i also have the npm-run-all package installed so i an run things in parallel in one terminal using run-p. pretty handy for simple build script stuff#2018-07-0117:35urbanslug@thheller Ah I see > shadow-cljs currently provides no support for directly compiling CSS but the usual tools will work and should be run separately. Just make sure the output is generated into the correct places.#2018-07-0117:35urbanslug@lee.justin.m thanks a ton!#2018-07-0118:29wilkerlucio@thheller yes I'm using a git dep, but the code triggering the warning is not a git dep#2018-07-0118:30thhellerwhat kind of warning are we talking about here? is it a public lib?#2018-07-0118:31wilkerlucio
------ WARNING #1 --------------------------------------------------------------
 File: clojure/math/combinatorics.cljc:278:26
--------------------------------------------------------------------------------
 275 |         indices (apply concat
 276 |                        (for [i (range (count v))]
 277 |                          (repeat (f (v i)) i)))]
 278 |     (map (partial map v) (lex-permutations indices))))
--------------------------------^-----------------------------------------------
 clojure.math.combinatorics/lex-permutations is deprecated
--------------------------------------------------------------------------------
 279 |
 280 | (defn permutations
 281 |   "All the distinct permutations of items, lexicographic by index
 282 | (special handling for duplicate items)."
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: clojure/math/combinatorics.cljc:285:29
--------------------------------------------------------------------------------
 282 | (special handling for duplicate items)."
 283 |   [items]
 284 |   (cond
 285 |     (sorted-numbers? items) (lex-permutations items),
-----------------------------------^--------------------------------------------
 clojure.math.combinatorics/lex-permutations is deprecated
--------------------------------------------------------------------------------
 286 |
 287 |     (all-different? items)
 288 |     (let [v (vec items)]
 289 |       (map #(map v %) (lex-permutations (range (count v)))))
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: clojure/math/combinatorics.cljc:289:23
--------------------------------------------------------------------------------
 286 |
 287 |     (all-different? items)
 288 |     (let [v (vec items)]
 289 |       (map #(map v %) (lex-permutations (range (count v)))))
-----------------------------^--------------------------------------------------
 clojure.math.combinatorics/lex-permutations is deprecated
--------------------------------------------------------------------------------
 290 |
 291 |     :else
 292 |     (multi-perm items)))
 293 |
--------------------------------------------------------------------------------
#2018-07-0118:31wilkerlucioyes, org.clojure/math.combinatorics#2018-07-0118:34thhellerk got it#2018-07-0118:37thheller
Exception in thread "async-dispatch-8" java.lang.OutOfMemoryError
        at java.base/java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:188)
        at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:180)
        at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:147)
        at java.base/java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:512)
        at java.base/java.lang.StringBuffer.append(StringBuffer.java:275)
        at java.base/java.io.StringWriter.write(StringWriter.java:106)
#2018-07-0118:37thhellerthe :build-complete message never makes it to the client since it fails printing#2018-07-0118:38thhellerwonder why its so large#2018-07-0118:40thhelleralright there seems to be some circular structure in there#2018-07-0118:41thhellergeez it dumps the entire analyzer env into the warning data#2018-07-0118:48thheller@wilkerlucio fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c1b2a9a0a5aeb6eca2adabb281f3eff5eff0f2"}, :content ("[email protected]")}#2018-07-0118:49wilkerlucioamazing 🙂#2018-07-0121:49eoliphantHi, I’m running into a weird issue. I’m using shadow-cljs with lein. and getting this error, despite the fact that querystring is very much installed my node_modules
shadow-cljs - config: /Users/ericholiphant/projects/fm-ui/shadow-cljs.edn  cli version: 2.4.13  node: v10.5.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Jul 01, 2018 5:00:34 PM org.xnio.Xnio clinit
INFO: XNIO version 3.3.8.Final
Jul 01, 2018 5:00:34 PM org.xnio.nio.NioXnio clinit
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server version: 2.4.12
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 56649
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required JS dependency "querystring" is not available, it was required by "node_modules/url/url.js".

Searched in:/Users/ericholiphant/projects/fm-ui/node_modules

You probably need to run:
  npm install querystring
#2018-07-0121:53thhellerhmm second time I see this now#2018-07-0121:54thheller@eoliphant can you please check if you have shadow-cljs as a dep in your project?#2018-07-0121:54thhellerif not add it and re-test#2018-07-0121:54eoliphantin project.clj?#2018-07-0121:54eoliphantyeah it’s there one sec#2018-07-0121:54thhellerno package.json#2018-07-0121:54thhellerjust npm install shadow-cljs#2018-07-0121:54eoliphantah#2018-07-0121:54eoliphantok#2018-07-0121:59eoliphantdammit.. lol, that was it#2018-07-0122:01thhellerhmm yeah but thats totally not intentional, just remembered that https://github.com/webpack/node-libs-browser has a "polyfill" for "querystring"#2018-07-0122:01thhellerbut if querystring is actually installed it should probably just be using that#2018-07-0122:14eoliphantgotcha#2018-07-0201:44steveb8ndoes anyone know of a good docker image with shadow-cljs and the aws cli installed?#2018-07-0206:41urbanslug@steveb8n Ha! I ran into this issue not so long ago and even submitted a PR https://github.com/thheller/shadow-cljs/pull/333#2018-07-0206:41urbanslugbut it doesn't have the aws cli installed#2018-07-0206:42urbanslugwold be okay to
FROM urbanslug/shadow-cljs

RUN install aws-cli
In my case I was using it for a CD pipeline
#2018-07-0206:42urbanslugso I see no need to bloat it#2018-07-0206:48urbanslugAlso if I may ask, would one want the aws-cli tool in the container?#2018-07-0206:49urbanslugYou have to config it for a specific user in so many ways#2018-07-0207:32steveb8n@urbanslug cool, thanks. I was using https://hub.docker.com/r/theasp/clojurescript-nodejs but no CLI there either. I’ll make one using yours and will publish on dockerhub as well#2018-07-0207:35urbanslugNote it down in the PR if you run into any problems please#2018-07-0207:35urbanslugor issue#2018-07-0207:42steveb8ndefinitely!#2018-07-0210:42urbanslug@thheller About the first it's possible to have the full JDK installed. About having to have always be installed in the project this would only be done in the project itself during an npm install. Maybe what would work is just a java and npm image then the npm install of the project installs shadow-cljs which would just be a different image anyway.#2018-07-0210:42urbanslugJust my thoughts#2018-07-0210:43grounded_sageI'm getting tripped up in the build hooks :shadow.build/mode :release is being called when I run npx shadow-cljs watch app#2018-07-0210:50thheller@grounded_sage no it isn't?#2018-07-0210:53steveb8nI’m gonna try to find a Docker image with just node/npm, aws-cli and jdk. if I have any luck I’ll report back#2018-07-0215:12urbanslugfwiw https://github.com/thheller/shadow-cljs/issues/334#issuecomment-401837727#2018-07-0210:55grounded_sage@thheller it is for me for some reason.#2018-07-0210:56grounded_sage
{:app {:target :browser
        :build-hooks [(util.task/hook) (util.task/css-inline-hook)]...}
(defn css-inline-hook
  {:shadow.build/mode :release
   :shadow.build/stage :flush}
  [build-state & args]
  (do
    (println "Inlining css")
    (css-inline)
    build-state))
`
#2018-07-0210:56thhellerthere is no mode filter#2018-07-0210:56grounded_sageahh ok#2018-07-0210:57thheller{:shadow.build/keys [mode] :as build-state} and then test it via (when (= mode :dev) ...)#2018-07-0210:58grounded_sageI just saw this in docs and assumed I could filter the hooks that way
The build-state has some important entries which might be useful for your hooks:

:shadow.build/build-id - the id of the current build (eg. :app)

:shadow.build/mode - :dev or :release
#2018-07-0210:58thhelleryou can. just not via the metadata#2018-07-0210:59grounded_sageok#2018-07-0211:01thhellerI could certainly add that though#2018-07-0211:07grounded_sageI think something like that would be handy. But I recognise that once you add something it's hard to take out 🙂 the example you gave worked fine#2018-07-0301:58steveb8n@urbanslug I had to create a new image in the end. it’s here https://hub.docker.com/r/steveb8n/cljs-node-aws-cli/#2018-07-0305:02urbanslug@steveb8n hmm I always thought the Dockerfile was visible by default#2018-07-0305:13steveb8nApparently only when you do an"automated build" #2018-07-0305:13steveb8nI just pushed from local#2018-07-0305:16steveb8nI just pasted the dockerfile into the description so you can see it#2018-07-0305:47grounded_sagewhere does :ssl {} go in my config?#2018-07-0305:48grounded_sageI'm trying to satisfy all the lighthouse audits locally#2018-07-0306:03grounded_sageoh nvm I have to do the self signed stuff all g#2018-07-0307:00thedavidmeisterhi#2018-07-0307:00thedavidmeisteris it normal that if i run shadow-cljs watch npm in one tab#2018-07-0307:01thedavidmeisterand shadow-cljs node-repl npm in another#2018-07-0307:01thedavidmeisterthat i have to quit the repl and restart it to see code changes?#2018-07-0307:01thedavidmeisterand that when i restart i don't have any repl history saved?#2018-07-0307:56thheller@thedavidmeister node-repl is completely standalone and does not take a build argument. you probably want shadow-cljs cljs-repl npm. if you want REPL history and stuff use rlwrap shadow-cljs cljs-repl npm. didn't have time to add that yet.#2018-07-0307:57thedavidmeisteroh ok#2018-07-0307:57thedavidmeisterlet me try that...#2018-07-0308:00thedavidmeisterso i see this now#2018-07-0308:00thedavidmeisterNo application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.#2018-07-0308:00thedavidmeisterwith the rlwrap command#2018-07-0308:00thhellerthat message has been tuned like 100 times. I do not know how to make it any clearer.#2018-07-0308:01thhelleryou need to launch whatever target :npm used and load your JS#2018-07-0308:01thhellerif the :npm target is :npm-module than REPL is a lot harder to do#2018-07-0308:02thedavidmeisterok, what target would let me test things out more easily?#2018-07-0308:02thhellerwhich things?#2018-07-0308:02thedavidmeisterhitting an API from cljs#2018-07-0308:02thedavidmeisterfrom a repl, with code reloading as i make changes#2018-07-0308:04thheller:browser is generally the easiest since you get easy access to browser devtools#2018-07-0308:04thhellerhttps://github.com/shadow-cljs/quickstart-browser#2018-07-0308:05thheller:node-script if you need node stuff#2018-07-0308:05thhellerthe node-repl doesn't do live reload since thats not usually how you work with a REPL#2018-07-0308:05thedavidmeisteri did try browser, but code reload did not work and it wouldn't let me make network calls#2018-07-0308:06thhellerdid you open the file directly instead of over http?#2018-07-0308:06thedavidmeisterwhat do you mean live reload isn't usually how i work with REPL?#2018-07-0308:06thhellerin a REPL env you typically control when the code is reloaded manually#2018-07-0308:06thhellerCLJ REPL for example doesn't do any live reloading automatically#2018-07-0308:07thedavidmeisteroh, the boot one has an option to#2018-07-0308:07thhellerits left to tools like tools.namespace or manually calling (require 'foo.bar :reload) or load-file#2018-07-0308:07thedavidmeisterso i'm used to that in clj#2018-07-0308:07thhellerin the quickstart-browser repo just run npx shadow-cljs watch app and open #2018-07-0308:08thhellerthat does live reload and has a REPL via rlwrap npx shadow-cljs cljs-repl app#2018-07-0308:12thedavidmeisterkk, i'll try that out#2018-07-0308:22thedavidmeisterah ok this is working, thanks!#2018-07-0308:22thedavidmeisteri'll try to port it to what i was doing and see where i went wrong#2018-07-0308:41thedavidmeistersomewhat related question#2018-07-0308:41thedavidmeisteris there a way to only require something from npm when i'm not running it in a browser?#2018-07-0308:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-07-0308:52thedavidmeisteroooooh#2018-07-0310:20lsnapeHiya, I'm getting this intermittent failure when running my karma tests after a shadow-cljs watch ci. The karma error is a bit obscure, but I can trace it down to this line: https://github.com/thheller/shadow-cljs/blob/5df9969639030128586afd2968db2ea5f704b4b0/src/main/shadow/test/karma.cljs#L17 Error message:
{
    "message": "Uncaught TypeError: s.replace is not a function\nat ci.js:138901:1\n\nTypeError: s.replace is not a function\n    at Object.clojure$string$replace_all [as replace_all] (ci.js:53046:10)\n    at Object.clojure$string$replace [as replace] (ci.js:53105:23)\n    at Object.shadow$test$karma$indent [as indent] (ci.js:358372:23)\n    at shadow$test$karma$format_log (ci.js:358467:304)\n    at ci.js:32847:89\n    at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32848:3)\n    at cljs.core.LazySeq.sval (ci.js:26691:109)\n    at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (ci.js:26842:10)\n    at Object.cljs$core$seq [as seq] (ci.js:19645:13)\n    at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32821:36)",
    "str": "Uncaught TypeError: s.replace is not a function\nat ci.js:138901:1\n\nTypeError: s.replace is not a function\n    at Object.clojure$string$replace_all [as replace_all] (ci.js:53046:10)\n    at Object.clojure$string$replace [as replace] (ci.js:53105:23)\n    at Object.shadow$test$karma$indent [as indent] (ci.js:358372:23)\n    at shadow$test$karma$format_log (ci.js:358467:304)\n    at ci.js:32847:89\n    at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32848:3)\n    at cljs.core.LazySeq.sval (ci.js:26691:109)\n    at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (ci.js:26842:10)\n    at Object.cljs$core$seq [as seq] (ci.js:19645:13)\n    at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (ci.js:32821:36)"
  }
#2018-07-0310:25lsnapeThat namespace is requiring clojure.string but isn't using the alias s. I'd be surprised if that was the problem though!#2018-07-0310:33lsnapeSo the problem is a non-string message in the is, which is invoked when the test fails. Is the correct fix to just call str on a s? https://github.com/thheller/shadow-cljs/blob/5df9969639030128586afd2968db2ea5f704b4b0/src/main/shadow/test/karma.cljs#L15#2018-07-0310:38thhellerI copied that code from some library#2018-07-0310:38thhellerno idea what it actually does 😛#2018-07-0310:39thhellerbut yeah looks like a non-string being passed into the fn#2018-07-0310:39thhellerwonder which assertion generates a non-string though?#2018-07-0310:39thheller@lsnape you can create a copy of that file in your project and test arround#2018-07-0310:40lsnapeOh it was one of the assertions in my tests.#2018-07-0310:40lsnapeHa that'll learn ya 😂#2018-07-0310:41lsnapeI was passing a map as the 2nd pos arg to is#2018-07-0320:38lilactownis there some incantation I can do to get a node_module that exports only a .jsx file to work?#2018-07-0320:38thhellernot currently no#2018-07-0320:39thhellerwell I guess you can use babel to transform it so there is a js file#2018-07-0320:41lilactownso I would need to do a transform into like an externs dir and add that to my source paths?#2018-07-0320:47thhellernpx babel node_modules/that-module should be enough#2018-07-0320:48thhelleror use another npm package that doesn't use jsx. or complain that they only ship non-standard JSX#2018-07-0409:19thhellerI just pushed 2.4.15 that now automatically deals with the global use of Buffer which previously required an ugly hack. Anyone using such a Buffer hack please try it without in 2.4.15.#2018-07-0409:20thhellerI adopted that behaviour since too many packages blindly use the global Buffer and webpack and others just rewrite it#2018-07-0409:21thhellerweb3 notoriously uses the Buffer object almost everywhere which should just work now without any hacks#2018-07-0414:22PontusHello, I'm getting this error in the main bundle of my app in Internet Explorer 11: Object doesn't support property or method 'includes', do I have to manually somehow include a polyfill to resolve this?#2018-07-0414:26thhellerits probably https://caniuse.com/#feat=array-includes#2018-07-0414:26thhellerso yeah that needs a polyfill for IE#2018-07-0414:30Pontusokay, I've done that for js projects using babel in the past but I'm a bit confused how to set it up with shadow-cljs, is there an example anywhere on how to do it?#2018-07-0414:32thheller@pontus.colliander which part of the code uses .includes? closure usually is supposed to automatically inject polyfills like that#2018-07-0414:33thhelleror are you using a dev build? it might work with shadow-cljs release?#2018-07-0414:37Pontushm no I'm using shadow-cljs release app when compiling#2018-07-0414:38Pontuslooks to me like it's atlaskit npm module that I installed, it's inside a function named shadow$provide.module$node_modules$$atlaskit$analytics_next$dist$cjs$withAnalyticsEvents = function(a, k, b, f, c) {#2018-07-0414:39thhellerok, I'll check why it doesn't add the polyfill#2018-07-0414:39Pontusthanks!#2018-07-0414:44thhellerdo you know where the error occurs? after calling which function?#2018-07-0414:44thhellerjust adding ["@atlaskit/analytics-next" :as as] does not cause the error#2018-07-0414:44thhellerguess I need to call something to trigger it#2018-07-0414:50PontusIt's in a method called this.mapCreateEventsToProps = function(c, d)#2018-07-0414:50Pontusit's called on initial render in my app#2018-07-0414:51thhellerI reproduced with (.includes #js [1 2 3] 3)#2018-07-0414:53Pontusah okay :+1:#2018-07-0415:03thhellerok found it. there is some weird interaction between the polyfills stuff and the node_modules file polyfills get lost#2018-07-0415:03thhellerwill fix later#2018-07-0415:04Pontusawesome#2018-07-0415:05thhellersee https://github.com/thheller/shadow-cljs/issues/337#2018-07-0415:10hlolliI've been lately on and off cljs, was there any clean way to require .-default avaialable?#2018-07-0415:13hlollijust from 2 months, I reopened a project and so many components were crashing, due to newer versions of libs are useing the default export option. But to be expected, easy fix.#2018-07-0415:52thheller@hlolli (:require ["thing" :default foo]). not official yet but works in shadow-cljs. https://dev.clojure.org/jira/browse/CLJS-2376#2018-07-0421:21urbanslugare you guys using clj-fmt? Which linting/style tool are you using seems clj-fmt requires leiningen#2018-07-0421:35hlolliI'm testing out webpack + shadow.cljs, I fell in love with the file loader in a different project. Was there ever an idea proposed to make a shadow-cljs loader, simply trigger shadow-cljs compile on changes/matched regex(for prod).#2018-07-0421:36thhellerfile loader is pointless. just compile with :npm-module and include the file directly via import or require#2018-07-0421:37hlollihmm, does that work for images as well? One thing I liked was for example in scss, @import "~../../node_modules/slick-carousel/slick/slick.css"; this could just pack it into my css output.#2018-07-0421:38thhellerI'm confused. you want to do that in CLJS or via webpack?#2018-07-0421:40hlolliIf possible in CLJS, then I don't see reason to use webpack, but with webpack you can import an image and css with image-loader and css-loaders.#2018-07-0421:40thhelleryeah I'm never ever going to implement that via ns require. I do however have plans to add something similar via some macros#2018-07-0421:41hlolliok I'm just experimenting. But webpack should understand js/require and that would trigger the loader, returning either image url or base64 of the image.#2018-07-0421:44hlolliI used to hate webpack 🙂, but the idea of requireing styles from node_modules was an eye opener. And its way more stable than when I was struggling with it few years back.#2018-07-0421:45thhelleryeah the idea is nice. just hacking it into js/require is horrible IMHO#2018-07-0421:45thhellerbut I guess they have to since they don't have macros#2018-07-0421:46hlolliyes I guess they do that. But I hacked js/require once when I was bundling a lumo app into a binary. Can be horrible and powerful.#2018-07-0421:51thhellergetting a bit frustrated with JS lately due to the many hacks people have adopted#2018-07-0421:51thhellermakes it an absolute nightmare to write a reasonable tool to bundle it#2018-07-0421:53thhellerI shouldn't have written the build reports feature, too much insights into the horrors of some JS packages 😛#2018-07-0421:56hlolliyes, I think that awakening is everywhere. Of the js tools, very sad to see how gulp is sinking in standard. It was a potential for clean build and deploy tool. But all hot-reload tutorials for gulp, is basically useing webpack in gulp, with webpack-stream, and from that point, you're in js tool hell.#2018-07-0421:57hlolliand no wepack boilerplate in the code, just purely combine compilations like they were indended, in streams#2018-07-0421:57thhellerjust today I added support for the dreaded global Buffer support that works in node and the browser thanks to webpack only#2018-07-0421:58thhelleror I guess browserify too. If they had just decided to not support it people would be using require("buffer") properly instead today#2018-07-0421:59thhellerreally wish there was a package manager for JS that only accepted valid linted ES6 code#2018-07-0421:59thhellergotta end this CommonJS mess at some point anyways 😉#2018-07-0422:01hlolliyes, start by haveing nodejs understanding it without babel, wasn't that the plan anyway, I take babel for granted.#2018-07-0422:02thhellerno babel please. that is reponsible for half of the misery
#2018-07-0422:03hlolliso commonjs is the only common denominator still.#2018-07-0422:07thhellerwish it was ES6. would make life to much easier.#2018-07-0422:08hlollithen you're refering to node modules that are released as es6? Isn't that very rare#2018-07-0422:08Space GuyIt'd be a good start, but you'd still need babel for 'server-side jsx' or whatever#2018-07-0422:09hlollijust looking over my node_modules, always common.js I think, with source maps maybe to es6#2018-07-0422:09thhellerdon't really care about node. thats gonna need to adopt ES6 at some point too.#2018-07-0422:09thhellerpoint is to only publish standards compliant ES6+ code to npm#2018-07-0422:09thhellerand let tools do the rewriting#2018-07-0422:10thhellerNOT publish rewritten code and let tools figure out what was rewritten#2018-07-0422:10hlolliah I see#2018-07-0422:10thhellerI think every JS builds with even a small number of JS deps ends up including three different Object.assign polyfills#2018-07-0422:10hlolliisn't it possible now to publish both .es6 and .js, I've seen it many times with typescript based libs#2018-07-0422:11thhelleryeah it is available more frequently#2018-07-0422:11thhellerbut one major source of pain is CommonJS <-> ES6 interop#2018-07-0422:11thhellerits much safer to only use CommonJS only or ES6 only#2018-07-0422:11thhellerthe interop story sucks#2018-07-0422:12thhellergetting better since webpack adopted a stricter version as the default but still bad#2018-07-0422:12hlolliyup, as consumer of libs I don't notice it, except useing require vs import, but you're creating tools, so I guess you have different view of this#2018-07-0501:31caleb.macdonaldblack
------ WARNING #7 --------------------------------------------------------------
 File: /Users/calebmacdonaldblack/Projects/medial/test/cljs/medial_web/components/util_test.cljs:1:5
 Invalid Filename, got cljs/medial_web/components/util_test.cljs but expected medial_web/components/util_test.cljs (or .cljc)
--------------------------------------------------------------------------------
#2018-07-0501:31caleb.macdonaldblackAny idea how I can get that warning to go away? There is probably a setting I’m missing or something#2018-07-0501:32caleb.macdonaldblack
:source-paths ["src/cljs" "medial-common/src" "src/clj"]
:test-paths ["test/cljs" "test/clj"]
#2018-07-0501:33caleb.macdonaldblackI’m using :lein true and those options are in project.clj#2018-07-0506:12thheller@caleb.macdonaldblack something must be adding "test" to the classpath#2018-07-0506:14caleb.macdonaldblack@thheller When you say something do you mean source-paths or test-paths?#2018-07-0506:14caleb.macdonaldblackWhat else can add "test" to the classpath?#2018-07-0506:14thhellernot sure. any plugin can add stuff IIRC#2018-07-0506:15caleb.macdonaldblackwe are using karma#2018-07-0506:16thhellertry running lein classpath and check if /Users/calebmacdonaldblack/Projects/medial/test is on there#2018-07-0506:19caleb.macdonaldblackHmm Im not sure what I’ve done since I sent that message earlier in the day but the warning isn’t showing up anymore#2018-07-0506:21caleb.macdonaldblackI did change my tests-paths form test -> test/cljs but I though I was still getting the warning. Maybe I forgot to restart or something but I’ve definitely no longer getting any warnings. Thanks for the help anyway#2018-07-0511:58hlolliI'm trying to follow the shadow-cljs/examples/webpack example, I'm getting require errors, in the output of :npm-module (I output to "node_modules/shadow-cljs") there are many relative require that fail, for example
ERROR in ./js.reagent.core.js
Module not found: Error: Can't resolve './shadow.js.shim.module$react.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./js.reagent.core.js 24:0-43
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js

ERROR in ./js.reagent.dom.js
Module not found: Error: Can't resolve './shadow.js.shim.module$react_dom.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./js.reagent.dom.js 22:0-47
 @ ./js.reagent.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
so I require it explicitly in one of my cljs source file
(:require ["react"]
            ["react-dom"])
but that wont fly far
symbol shadow.js.shim.module$react already provided by [:shadow.build.classpath/resource "js/shadow.js.shim.module$react.js"], conflict with [:shadow.build.js-support/require "react"]
in general shadow.js.shim.module$react_dom.js and shadow.js.shim.module$react.js are just one of hundreds of requires that webpack complains about being missing. I tried https://www.npmjs.com/package/closure-loader if this was a goog.provide issue, didn't make a difference. I guess these files are reachable for shadow-cljs, but are not spit to files. Maybe this is configureable, or :npm-modules for webpack isn't the right build.
#2018-07-0511:59thheller./js.reagent.core.js#2018-07-0511:59thhellerthat doesn't look valid#2018-07-0511:59thhellerwhy is there a js. in front?#2018-07-0512:00thhellerclosure-loader is not required and will probably break everything#2018-07-0512:00thhellerwhat files are in node_modules/shadow-cljs#2018-07-0512:01thhellerthere should be a node_modules/shadow-cljs/reagent.core.js for example#2018-07-0512:01hlollithat one's missing, no reagent.core.js, full stacktrace https://pastebin.com/MjnT4apj#2018-07-0512:02thhellerwhat files are in node_modules/shadow-cljs#2018-07-0512:02thhellerjust list one#2018-07-0512:02thhellernode_modules/shadow-cljs/cljs.core.js#2018-07-0512:02thhellerwhatever .. there must be something?#2018-07-0512:02hlollijs.reagent.core, cljs.user.js#2018-07-0512:03thhellerthe js. in front should not be there#2018-07-0512:03thhellerno idea how it would get there either#2018-07-0512:03thhellerwhat is your config?#2018-07-0512:03hlollisomething wrong here?
:public {:target           :npm-module
                   :output-dir       "node_modules/shadow-cljs"
                   :asset-path       "/"
                   ;; :source-map true
                   :module-loader    true
                   :js-options       {:resolve
                                      {"scroll" {:target :file
                                                 :file   "overrides/scroll_index.js"}}
                                      :js-provider :shadow}
                   :modules          {:main {:entries [visitor.main]}}
                   :compiler-options {;; :source-map true
                                      :source-map    true
                                      :infer-externs :auto
                                      ;; :optimizations :none
                                      }
                   ;; :devtools         {:http-root  "public"
                   ;;                    :http-port  8088
                   ;;                    :after-load visitor.main/init}
                   :open-file-command
                   ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}       
#2018-07-0512:04thhelleruhm yeah that config is invalid#2018-07-0512:05thheller
{:target :npm-module
 :output-dir "node_modules/shadow-cljs"
 :entries [visitor.main]
 :compiler-options {:infer-externs :auto
                    :source-map true}}
#2018-07-0512:05thheller:open-file-command is not valid in a build config btw. it should be at the top level#2018-07-0512:06thhellerbut non of that explains the js. in front#2018-07-0512:06hlolliok, something from c/p, didnt complain, or do anything 😛#2018-07-0512:06hlolliok, 1 min, try this...#2018-07-0512:07hlollistill the js. prefixes#2018-07-0512:07hlolliand same error#2018-07-0512:07thhellerwhats your webpack config? are you sure the loader is not still in there?#2018-07-0512:08thhellerwebpack doesn't require ANY config whatsoever for this#2018-07-0512:08hlolliyup, I may suspect there's a zombie process running atm... 1 min..#2018-07-0512:08thhellerI don't know where the js. in front is coming from. I just tested locally and everything is fine.#2018-07-0512:10hlolliok, maybe I take the example and move my source over... yes no idea, there was a zombie process there, nukeing the dir, npm i...#2018-07-0512:11hlolliah bingo!#2018-07-0512:11hlollithat was it, I realized there was a zombie ps there screwing with me, if I would have read the shadow-cljs logs I should have realized it, that it was always connecting to a server#2018-07-0512:12thhellerstill doesn't explain the js. but ok#2018-07-0512:12hlollinow the only error is
ERROR in /home/hlolli/Documents/visitor/index.js
Module not found: Error: Can't resolve 'shadow-cljs/visitor.main' in '/home/hlolli/Documents/visitor'
 @ /home/hlolli/Documents/visitor/index.js 1:0-35
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
basically my webpack config
#2018-07-0512:13thhellerdid you recompile CLJS after cleaning node_modules?#2018-07-0512:14hlollicould the js. be explained by asset-path, which I had before?#2018-07-0512:14hlolliyes#2018-07-0512:14thheller/home/hlolli/Documents/visitor/node_modules/shadow-cljs/visitor.main.js exists?#2018-07-0512:14hlolliyes!#2018-07-0512:15thhellertry restarting webpack? dunno#2018-07-0512:15thhellertry node require("shadow-cljs/visitor.main")#2018-07-0512:15hlolliyes, this is now webpack, could be exlusions or lack of includes, just config shit there, I've been changeing it alow#2018-07-0512:15hlolliok#2018-07-0512:15hlolli
Error: Cannot find module 'shadow-cljs/visitor.main'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
#2018-07-0512:16thhellerare you sure you are in the correct directory? what is __dirname?#2018-07-0512:16thhellernvm. thats not available in the shell#2018-07-0512:16hlolliahh facepalm#2018-07-0512:16hlollithe directory got empty#2018-07-0512:17hlollinode_modules/shadow-cljs cleared... now
> require("shadow-cljs/visitor.main")
ReferenceError: window is not defined
    at Object.<anonymous> (/home/hlolli/Documents/visitor/node_modules/shadow-cljs/ajax.xml_http_request.js:46:6)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
webpack screwing with me I assume
#2018-07-0512:19thhelleryeah ok browser only code doesn't load in node#2018-07-0512:19thhellerbut it resolves properly to get that far#2018-07-0512:19thhellermust be webpack then#2018-07-0512:19hlolliyes, I clear the config and view it over, now it's delivering
ERROR in ./ajax.xml_http_request.js
Module not found: Error: Can't resolve 'xmlhttprequest' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./ajax.xml_http_request.js 42:160-185
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
but it could be anything at this point, will report if Im still stuck
#2018-07-0512:20thhellermussing npm install xmlhttprequest#2018-07-0512:20thhellermissing#2018-07-0512:21hlolliok, next error haha
ERROR in ../xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'child_process' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib'
 @ ../xmlhttprequest/lib/XMLHttpRequest.js 15:12-36
 @ ./ajax.xml_http_request.js
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js

ERROR in ../xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'fs' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib'
 @ ../xmlhttprequest/lib/XMLHttpRequest.js 16:9-22
 @ ./ajax.xml_http_request.js
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
#2018-07-0512:21thhellerah wait#2018-07-0512:21thhellerset :runtime :browser in the build config#2018-07-0512:22thhellercljs-ajax is using cljs.core/*target*#2018-07-0512:22hlolliyes, thought it was bit node targeted there
{:target           :npm-module
                   :output-dir       "node_modules/shadow-cljs"
                   :entries          [visitor.main]
                   :runtime          :browser
                   :compiler-options {:infer-externs :auto
                                      :source-map    true}}
like this?
#2018-07-0512:22thhelleryep#2018-07-0512:23hlolliwill nuke the dir again, didnt change.. moment..#2018-07-0512:23thhellermight need to kill .shadow-cljs/builds/public. not sure if changing that nukes the cache#2018-07-0512:23thhellerit should be you never know#2018-07-0512:24hlolliah ok, will try#2018-07-0512:25thhellerotherwise try setting :compiler-options {:closure-defines {cljs.core/*target* "browser"}} in the build config#2018-07-0512:26hlolliok I try that, because the error wont go#2018-07-0512:26thhellerhaha no wait ... its a conditional require ... webpack doesn't like those#2018-07-0512:26thhellershadow-cljs hates them too#2018-07-0512:27thhellercopy https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs to your source path#2018-07-0512:27thhellerand replace
(def xmlhttprequest
  (if (= cljs.core/*target* "nodejs")
    (let [xmlhttprequest (.-XMLHttpRequest (js/require "xmlhttprequest"))]
      (goog.object/set js/global "XMLHttpRequest" xmlhttprequest)
      xmlhttprequest)
    (.-XMLHttpRequest js/window)))
#2018-07-0512:27thhellerwith just (def xmlhttprequest (.-XMLHttpRequest js/window))#2018-07-0512:28hlolliah ok I see, wouldn't it be better then as a macro?#2018-07-0512:28hlollifor future#2018-07-0512:29thhellerI never used that lib. I don't know.#2018-07-0512:30hlollithen the condition is resolved before compilation, could add ticket#2018-07-0512:31hlollivoila, all lights are green#2018-07-0512:31hlollithanks a lot!#2018-07-0512:32thhellerthey probably don't expect that uncompiled CLJS output gets processed by webpack#2018-07-0512:32thhellercompiled the closure compiler will probably have removed the js/require call so it wouldn't fail#2018-07-0512:33hlolliyes, or more reader-macros, like so many are begging for.#2018-07-0512:34thhelleryou mean like these https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading 😉#2018-07-0512:34hlolliexacly, one of many reasons I prefer shadow-cljs 🙂#2018-07-0512:35thhelleryeah that would certainly fix this problem#2018-07-0518:11currentoorI used a template to generate a shadow-cljs app but I see this warning, in development Warning: It looks like you're using a minified copy of the development build of React.#2018-07-0518:12currentoornone of my cljs code or deps is minified#2018-07-0518:12currentoorany idea why this is happening?#2018-07-0518:14justinlee@currentoor it’s harmless (but unfortunately i don’t think you can get rid of it). shadow does some minification that trips that warning, but the warning isn’t accurate. you are using the correct version.#2018-07-0518:14currentooroh ok well that's a relief simple_smile#2018-07-0518:14currentoorthanks!#2018-07-0610:13lsnapeHi, I'm tracking down a npm dependency issue in my production app that I'm having trouble reproducing in a minimal demo. Pulling in the raven-js npm dependency in my prod app gives me a syntax error when requiring the module. I can trace it to an innocuous-looking function in a utilities js file. The only difference I can see is in the 'Sources' tab in the Chrome inspector: a file under node_modules/raven-js/src/utils.js exists in my test project, but in prod it's missing (all neighbouring source files are there). This might be a red herring but I can't see any other differences worthy of note.#2018-07-0610:14lsnapeThe file module\$node_modules\$raven_js\$src\$utils.js is served up in both projects, along with the .map file.#2018-07-0610:15lsnapeAny guidance on things I could try greatly appreciated, as I feel a bit like I'm shooting in the dark!#2018-07-0610:23thheller@lsnape what is the error you get?#2018-07-0610:29thhellerand you do not get this problem during development or is the code just not used in dev?#2018-07-0610:30thhellerwait nvm. thats a dev error#2018-07-0610:31thhellerhmm it compiles and loads fine for me#2018-07-0610:32thhellerdo you use lein?#2018-07-0610:34lsnapeYea it's dev. I'm actually getting boot to serve the assets out of the target dir#2018-07-0610:34thhellerwhat do you use to run shadow-cljs? just shadow-cljs or lein or boot?#2018-07-0610:34lsnapeIt's a bit cobbled together atm. I run shadow-cljs watch app from one terminal window, and boot to serve assets out of target/public.#2018-07-0610:35thhellershadow-cljs standalone though? no lein, boot or tools.deps?#2018-07-0610:35lsnapeI'm chaining watch tasks so boot copies the compiled JS into the dir we serve.#2018-07-0610:35thhellertrying to rule out dependency issues#2018-07-0610:35lsnapeYeah standalone shadow.#2018-07-0610:35thhellerok#2018-07-0610:36thhellerand boot copies everything correctly? not that it just stopped in the middle of the file or something?#2018-07-0610:37thhellercheck if the <output-dir>/cljs-runtime/module\$node_modules\$raven_js\$src\$utils.js file is corrupted or so#2018-07-0610:38thhelleror rather check if the file generated by shadow-cljs is identical to the file served by boot#2018-07-0610:40lsnapeDoing that now. I'll diff it against the demo app, which is working.#2018-07-0610:41lsnapeThere is a difference:
1,3c1,3
< shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,new Request(""),
< new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> shadow$provide.module$node_modules$raven_js$src$utils=function(global,process,require,module,exports,shadow$shims){function isUndefined(what){return void 0===what}function isPlainObject(what){return"[object Object]"===Object.prototype.toString.call(what)}function isString(what){return"[object String]"===Object.prototype.toString.call(what)}function isArray(what){return"[object Array]"===Object.prototype.toString.call(what)}function supportsFetch(){if(!("fetch"in _window))return!1;try{return new Headers,
> new Request(""),new Response,!0}catch(e){return!1}}function each(obj,callback){var i,j;if(isUndefined(obj.length))for(i in obj)hasKey(obj,i)&&callback.call(null,i,obj[i]);else if(j=obj.length)for(i=0;i<j;i++)callback.call(null,i,obj[i])}function truncate(str,max){if("number"!==typeof max)throw Error("2nd argument to `truncate` function should be a number");return"string"!==typeof str||0===max?str:str.length<=max?str:str.substr(0,max)+"…"}function hasKey(object,key){return Object.prototype.hasOwnProperty.call(object,
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
#2018-07-0610:41lsnapeThat's diffing broken working#2018-07-0610:42thhellercan't see anything 😛#2018-07-0610:42thhellerfirst version is older though#2018-07-0610:43lsnapeFirst is using shadow 2.4.8.#2018-07-0610:43thhellermight just be a closure compiler bug. try upgrading#2018-07-0610:43lsnapeOK, sorry should have checked that.#2018-07-0610:44thhellerhmm no compiler changes since then though#2018-07-0610:45thhellerotherwise try deleting the .shadow-cljs/builds directory just to rule out a cache issue#2018-07-0610:45thhellerunlikely but never hurts to try 😉#2018-07-0610:47lsnapeOK will do#2018-07-0610:48thhellercan't really tell what else is different in the diff besides ,shadow$shims which was added recently#2018-07-0610:49thhellerother than that is appears similar. be sure to check the actual output served by boot though might be something happening in transit#2018-07-0610:52lsnapeyeah, eventually I'd like to isolate boot completely.#2018-07-0611:01lsnapeOK, still broken but the diff has changed:
3c3
< key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
---
> key)}function joinRegExp(patterns){for(var sources=[],i=0,len=patterns.length,pattern;i<len;i++)pattern=patterns[i],isString(pattern)?sources.push(pattern.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")):pattern&&pattern.source&&sources.push(pattern.source);return new RegExp(sources.join("|"),"i")}function htmlElementAsString(elem){var out=[],className,attr;if(!elem||!elem.tagName)return"";out.push(elem.tagName.toLowerCase());elem.id&&out.push("#"+elem.id);if((className=elem.className)&&isString(className)){var classes=
#2018-07-0611:02lsnapereplace(/([.*+?^=!:}()|\[\]\/\\])/g,"\\$1")) replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1"))#2018-07-0611:05lsnapeHmm this is actually looks like a raven-js lib version discrepancy.#2018-07-0611:05lsnapeNope they are both the same 😞#2018-07-0612:14thheller@lsnape do you have anything in your config which might affect this? custom :js-options?#2018-07-0612:15thhellercustom closure-compiler dependency?#2018-07-0612:16thhellerI don't actually think that there is anything you do via the config to affect this but gotta rule it out still#2018-07-0612:27lsnape@thheller I think I know what it is. We've got an asset fingerprinting boot task that scans all source files for template params ${param} and replaces them with a hashed version, or in the case of development skips over them. It looks like the regex is being incorrect replaced by the task. 😞#2018-07-0612:28thhellerFWIW shadow-cljs has that built-in via https://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing#2018-07-0612:28lsnapeIt's an easy fix but very annoying. Thanks for working it through with me though.#2018-07-0612:28thhellerah I guess you mean images and stuff#2018-07-0612:29lsnapeYeah we need it for all assets. Do you think that's out of scope in shadow?#2018-07-0612:29thhellerno. I have plans for that. just not the time to implement it currently.#2018-07-0612:29lsnapeIf shadow supported hashing all assets then we could ditch boot entirely!#2018-07-0612:30lsnapeHere's the boot task I wrote to take care of it: https://github.com/ELiTLtd/boot-asset-fingerprint#2018-07-0612:30lsnapeFeel free to steal anything out of there. It's something I'd be interesting in doing with a bit of guidance? Up to you!#2018-07-0612:32thhellerso its just about change the references in the HTML?#2018-07-0612:32thhellerI thought you were hashing images and stuff?#2018-07-0612:33lsnapeYeah, it hashes the file names and the references in other files, such as html and css.#2018-07-0612:34lsnapeSo ${img/foo.png} in bar.html becomes img/foo-af28b.png in the html file, plus a new file is written to the file path.#2018-07-0612:34thhelleryeah. the example only had .js so I thought it was just about .js#2018-07-0612:36lsnapeI really like the way you do it by generating a manifest file for module hashing. It's more work to plumb it in the project, but it's very flexible.#2018-07-0612:37thhelleryeah in my work projects I just watch the manifest for changes in production#2018-07-0612:37thhellerso I can deploy new JS code without restarting the server#2018-07-0612:39thhellerbut its a clojure server generating the HTML anyways so no static html to rewrite#2018-07-0612:41lsnapeThat's what we're doing in our latest project: html page frame is all hiccup rendered on request (memoized).#2018-07-0612:41lsnapeBut older projects serve up html templates rendered after cljs compilation time.#2018-07-0615:16lilactownI'm still struggling with shadow-cljs in CI. running a release build takes up to 10 mins#2018-07-0615:17thhellerdid you enable caching?#2018-07-0615:17lilactownyep. persisting the .shadow-cljs/builds/ folder shaved off about a minute or so#2018-07-0615:18thhellerdid you run with --verbose? cache should be way more than that#2018-07-0615:18thhellerverbose should tell you exactly where the time is spent#2018-07-0615:19lilactownOK, I'll dig into it more#2018-07-0615:19lilactownfor reference, about half of that is just starting shadow-cljs 😬 compiling takes about 5 mins#2018-07-0615:19thheller5min to start? are you running on a toaster?#2018-07-0615:19lilactown😂#2018-07-0615:20lilactownvery well could be for all I know#2018-07-0617:04lilactownI'm trying to compile a target :karma build:
-> build target: :karma stage: :configure
NullPointerException:
	shadow.build.targets.karma/configure (karma.clj:21)
	shadow.build.targets.karma/configure (karma.clj:16)
	shadow.build.targets.karma/process (karma.clj:112)
	shadow.build.targets.karma/process (karma.clj:108)
	clojure.lang.Var.invoke (Var.java:381)
	shadow.build/process-stage/fn--15189 (build.clj:120)
	shadow.build/process-stage (build.clj:117)
	shadow.build/process-stage (build.clj:109)
#2018-07-0617:04lilactownI'm a little unsure if my regexp is working. would that trigger this error?#2018-07-0617:14thhellermissing :output-to, need to add specs for the config still#2018-07-0617:16lilactownahh, I had output-dir#2018-07-0618:26lilactownI'm getting an error when trying to run karma tests:
d on socket wpx59euvS82blWCjAAAA with id 10464947
HeadlessChrome 0.0.0 (Mac OS X 10.13.5) ERROR
  {
    "message": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n    at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n    at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at ",
    "str": "Uncaught ReferenceError: shadow is not defined\nat : shadow is not defined\n    at eval (eval at <anonymous> (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n    at ContextKarma.start (/Users/r627543/Code/fido/packages/web/app/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at "
  }
#2018-07-0620:13thhellerI'm guessing that karma isn't loading the correct js?#2018-07-0620:13thhellerlooks like its trying to call the shadow.test.karma.init fn maybe and doesnt find it?#2018-07-0620:28lilactownthis is what my config looks like:
{:target :karma
           :ns-regexp ".devcards$"
           :output-to "target/karma/tests.js"}
#2018-07-0620:29lilactownand I copied the karma.conf.js from the user-guide#2018-07-0620:29thhellerand you changed the path there?#2018-07-0620:30lilactown
module.exports = function (config) {
  config.set({
    browsers: ['ChromeHeadless'],
    // The directory where the output file lives
    basePath: 'target/karma/',
    // The file itself
    files: ['target/karma/tests.js'],
    frameworks: ['cljs-test'],
    plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
    colors: true,
    logLevel: config.LOG_INFO,
    client: {
      args: ["shadow.test.karma.init"],
      singleRun: true
    }
  })
};
#2018-07-0620:43lilactownnvm I figured it out#2018-07-0620:43lilactownfiles is relational to basePath#2018-07-0620:43thhellerbasePath + files doesn't work I think#2018-07-0620:43thhelleryep#2018-07-0620:43lilactown😅 PEBKAC. thanks for holding my hand#2018-07-0721:36urbanslugI'm trying to call a default export from an npm module#2018-07-0722:34lilactowndepending on how react-d3-speedometer is implemented. if it’s using ES module syntax (import/export), then you can do: (:require ["react-d3-speedometer" :default d3-speedometer) and use it like [:> d3-speedometer]#2018-07-0721:36urbanslugproblem is I can't figure out how to call the default export as a react component in reagent#2018-07-0721:38urbanslug
(:require ["react-d3-speedometer" :as s])

(defn x
  []
  [:> ...how to call default export of s?]
#2018-07-0722:28jjttjjhi everyone, sorry I'm not 100% sure this is shadow specific but I just started messing around with raw react, anyone know why (react/createElement "h1" nil #js["hello world"] ) seems to return nil at the repl, but when i js/console.log it I get a react element value?#2018-07-0722:45jjttjjok I see that this is related to https://dev.clojure.org/jira/browse/CLJS-1628#2018-07-0801:31justinlee@urbanslug you can import using the default keyword (see shadow user manual) or just access the property named “default”#2018-07-0804:22urbanslug@lee.justin.m I swear I gleaned over this manual a couple of times and didn't see this#2018-07-0804:22urbanslugfacepalm#2018-07-0814:32mhuebertHmm, trying to use the aws-sdk package and it is bundling the node.js version:
(ns my-ns.aws 
  (:require ["aws-sdk/lib/util" :as util]))

(prn [(util/isNode) (util/isBrowser)])
;; => [true false]
in the aws-sdk package.json there are some "browser" settings which maybe aren’t being read?
"browser": {
    "lib/aws.js": "./lib/browser.js",
    "fs": false,
    "./global.js": "./browser.js",
    "./lib/node_loader.js": "./lib/browser_loader.js"
  },
#2018-07-0814:34mhuebertthere is a also this field
"browserify": {
    "transform": "./dist-tools/transform.js"
  },
#2018-07-0815:06thhellerwhich target? :browser?#2018-07-0815:06mhuebertyes#2018-07-0815:11thhellerhehe that result is kind of hilarious#2018-07-0815:11thheller
isBrowser: function isBrowser() { return process && process.browser; },
  isNode: function isNode() { return !util.isBrowser(); },
#2018-07-0815:12thhellervery sophisticated checking logic 😉#2018-07-0815:12mhueberthaha yeah#2018-07-0815:13thhellerbut the check should succeed. checking why it doesn't#2018-07-0815:14thhellertry setting :closure-defines {shadow.js.process.browser true}#2018-07-0815:15thhellerthats supposed to be set for :browser target by default but for some reason isn't#2018-07-0815:24mhuebert:+1::skin-tone-2: that works#2018-07-0815:25thhelleryeah browser target only set this for release builds#2018-07-0815:25thhellerwill fix but setting it manually is fine for now#2018-07-0815:26mhuebertgreat. i was worried this would be related to some weirdness with how the aws-sdk package is built#2018-07-0815:27thhellerthe browser field in package.json is fully supported. its just that checked that failed#2018-07-0914:57jmckitrickIs the shadow-re-frame repo the current recommended starting point for a project of that type?#2018-07-0915:51kasukoI took a look at shadow-cljs and like what I saw. I was wondering is there any advice for packaging and consuming a shadow-cljs project as a library in another Clojurescript project that may be a leinigen project?#2018-07-0916:24thheller@kasuko shadow-cljs currently has no built-in support for packaging/publishing libraries. you can use lein for that though. as far as comsuming that goes there is nothing special regarding shadow-cljs and it works just like any other cljs lib.#2018-07-0916:26thheller@jmckitrick I don't use re-frame myself but I tested this most recently and it worked well https://github.com/jacekschae/shadow-re-frame#2018-07-0916:48jmckitrickPerfect, thanks!#2018-07-0917:56kasuko@thheller I need to use shadow-cljs to handle NPM dependencies that the current core-cljs library can not. So I need shadow-cljs to compile and output those dependencies in JS that could be properly imported by core-cljs ... should I be using the :browser target?#2018-07-0917:57kasukoSpecifically I am trying to make a reagent based ApolloClient wrapper#2018-07-0917:57thhellerthats not possible. CLJS libraries only contain the source code, no compiled code.#2018-07-0917:58kasukoAh damn, I really hoped that'd be possible.#2018-07-0918:01thhellerunfortunately not. I guess you could try the cljsjs route if there isn't a package for apollo-client already?#2018-07-0921:53lilactownis there a way to tell the closure compiler not to eliminate a namespace?#2018-07-0921:54lilactownI'm trying to do a release version of a bunch of devcards (weird I know), which get included in a top-level ns that just calls devcards.core/start-devcard-ui!#2018-07-0921:54lilactownthe namespaces that don't have explicit side effects (e.g. a println) get removed tho 😞#2018-07-0922:27wilkerlucio@lilactown mark the function as export, eg: (defn ^:export dont-kill-me [])#2018-07-0922:34lilactownaweomse thanks!#2018-07-0923:30oscarI want to use the built-in http server to develop my API, but I can't seem to get it to reload namespaces. I've tried wrap-reload and (clojure.tools.namespace.repl/refresh) but I can't seem to get anything to work.#2018-07-1001:40grounded_sageHey I've nearly finished putting together the first iteration of a build tool based on shadow. I'm striving for 100/100 lighthouse audit out of the box when testing the release locally on the shadow-cljs server. The failing points I have are. 1. Does not redirect HTTP traffic to HTTPS 2. Does not use HTTP/2 for all of its resources Is there a simple way to set this up?#2018-07-1006:09grounded_sageThere is some strange behaviour when I use srcset on an img tag. For some reason using this attribute triggers a network request for the same image every time I change the browser size. When hosted on Netlify this does not happen.#2018-07-1006:18thheller@oscar shadow-cljs is focused on CLJS development. if you want to build a CLJ server you should do so using CLJ tools which you are going to need anyways for release (by which I mean build your own CLJ webserver, do not piggyback on the built-in server)#2018-07-1006:22thheller@grounded_sage no not currently. feels a bit out of scope. since HTTPS requires domain names the only way to do this is running on localhost:80 + localhost:443. if you run on http://localhost:8080 you cannot redirect to https://localhost:8080 but must use a different port which then is treated as a different server and the whole spiel begins again#2018-07-1006:27thheller@lilactown @wilkerlucio ^:export doesn't actually preserve the "namespace". there are no namespaces in :advanced compilation. it just basically sets your.app.foo = xW; after the fact. so what once was your.app.foo became xW and is then reassigned later.#2018-07-1012:19gleisonsilvaHello guys! I'm just starting with shadow-cljs on a new project... has anyone a example of using material-ui with it? I've tried the cljsjs way, but I saw that this is not supported anymore... I'm a bit confused...#2018-07-1012:22thheller@gleisonsilva the whole point is to use npm directly, so you npm install it and start using it#2018-07-1012:23thhellerI can "translate" if you have an example of the "cljsjs way"#2018-07-1012:25gleisonsilvaI was trying to follow this -> https://github.com/cljsjs/packages/tree/master/material-ui#2018-07-1012:27thhellerhow would you use that though?#2018-07-1012:28thhellerlike an example react example#2018-07-1012:29gleisonsilvai'm not sure... i'm a begginer with both (shadow-cljs and material-ui react components) i'm trying to find examples of react components with shadow-cljs, but I haven't found yet..#2018-07-1012:30thhellerwhich react wrapper are you using? reagent?#2018-07-1012:32gleisonsilvayes. i'll use reagent#2018-07-1012:33thhellerI would recommend going through https://www.jacekschae.com/learn-reagent-free/uk29i?coupon=SHADOW#2018-07-1012:36thhellerI made this example repo a while ago https://github.com/thheller/shadow-react-avatar-editor#2018-07-1012:37thhellershowing the use of react-avatar-editor. you can substitute that with material-ui or any other of the material design wrappers#2018-07-1012:37gleisonsilvatks, @thheller! I'll check that out.#2018-07-1012:38hlolli@gleisonsilva for boilerplate, I did this
(:require
            ["material-ui/styles" :as styles]
            ["material-ui/AppBar" :as AppBar]
            ["material-ui/styles/MuiThemeProvider" :as Theme]
)
(def muiTheme
  (styles/createMuiTheme
   #js {:palette #js {:primary   #js {:main         "#7796a8" ;; "#3f50b5"
                                      :dark         "#848F92" ;; "#BCCACD"
                                      :light        "#e0e7eb" ;;"#002884"
                                      :contrastText "#fff"}
                      :secondary #js {:light        "#7796a8" ;; "#3f50b5"
                                      :main         "#e0e0e0" ;;"#757ce8"
                                      :dark         "#e0e7eb" ;;"#002884"
                                      :contrastText "#000"}
                      :stepper   #js {:iconColor "green"}}}))

..later...
[:> Theme/default {:theme muiTheme} .... rest of app]
#2018-07-1012:50gleisonsilvatks, @hlolli! I'll try.#2018-07-1013:41oscar@hlolli @gleisonsilva you can avoid having to do Theme/default. If your require is instead ["material-ui/styles/MuiThemeProvider" :default Theme] then you can just say Theme.#2018-07-1013:51oscar@gleisonsilva also, I'd suggest directly using Material-UI v1 (which is a lot different than v0.x). Translation from JS is pretty straightforward and the new require strings ("@material-ui/core/styles" work just fine as :require statements in shadow-cljs. I've been using it for a while so feel free to direct questions my way.#2018-07-1015:25kennyI just updated to the shadow-cljs 2.4.17 and now I am getting DEBUG logs from shadow-cljs in my console. Is there a way to configure shadow-cljs logging?#2018-07-1015:26thhellerwhat do you mean? logging hasn't changed for quite a long time?#2018-07-1015:27kennyFor example, I'm getting messages like these:
18-07-10 15:23:32 Kenny-Compute-Software-Macbook.local DEBUG [shadow.cljs.devtools.server.worker.impl:286] - :shadow.cljs.devtools.server.worker.impl/runtime-msg 7b6011fe-e547-4b81-8ee2-fba61e36daf8 :ping
#2018-07-1015:28kennyI did not receive those before. I also switched to use deps.edn.#2018-07-1015:28thhellerah thats the reason#2018-07-1015:28thhellerthe shadow-cljs npm thing sets up logging. deps.edn does not.#2018-07-1015:29kennyWhat do you mean? I was using the lein integration before.#2018-07-1015:30thhellerdo you use any logging library?#2018-07-1015:30thhellerjava logging library I mean. logback, log4j, ...?#2018-07-1015:31kennyNot in my cljs app. It is possible some other dependency is pulling one of those in though.#2018-07-1015:31thheller
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

.level=INFO

java.util.logging.FileHandler.limit=5000000
java.util.logging.FileHandler.count=3
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=WARNING

java.util.logging.SimpleFormatter.format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS - %4$s] %5$s%6$s%n


java.util.logging.FileHandler.pattern=.shadow-cljs/shadow-cljs.log
#2018-07-1015:31thhellerthis is the default logging config used when using shadow-cljs to run stuff#2018-07-1015:32thhellerneed to append -Djava.util.logging.config.file=logging.properties to your jvm args#2018-07-1015:33thhellerI think its :jvm-opts ["-Djava.util.logging.config.file=logging.properties"] in deps.edn#2018-07-1015:33thhellerI don't know why you are seeing debug messages though. those are usually hidden by default so you might have some logging going on already#2018-07-1015:34thhellerI can probably automate that for the deps.edn integration#2018-07-1015:35kennyYeah, it is strange. I have had numerous cases where tools-deps resolves things differently than lein which causes issues similar to this one.#2018-07-1015:35thhelleryeah tools.deps is stricter. which is good but different from lein so sometimes has unexpected results#2018-07-1015:36kennyAgreed. I'll fiddle with exclusions to see if I can get the default behavior back.#2018-07-1015:37thhellerany particular reason you fight with lein or tools.deps instead of just using the built-in dependencies support?#2018-07-1015:40kennyYes, twofold. 1. We switched to tools.deps to use Git dependencies. Does shadow-cljs have support for this? 2. I like to use the lein-cooper plugin to start shadow-cljs and node-sass via a single command (i.e. lein dev).#2018-07-1015:42thheller1) is not supported no. 2) is possible via clj-run#2018-07-1015:42kennyWhat is clj-run?#2018-07-1015:43thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-07-1015:47kennyInteresting! I'll give that a try.#2018-07-1015:52kennyAdding some exclusions fixed the DEBUG issue.#2018-07-1015:54kennyYou are missing a ] in your example here: https://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run#2018-07-1015:54thhellerthx will fix that#2018-07-1016:01kennyStrange error on my first cut. I would've expected the exception immediately:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d6bdb3b8b8af969db3b8b8affb95b9bba6a3a2b3fb85b9b0a2a1b7a4b3fb9bb7b5b4b9b9bd"}, :content ("[email protected]")}
The issue was I copy and pasted the code from the example and forgot to update the build id to the build id for my project.
#2018-07-1016:02thhellerwhat do you mean immediately? the exception was caused by your code so it can't happen "earlier"?
#2018-07-1016:04kennyOh, I think I know the problem. I have a call to sh that did not complete because it is node-sass's watch command. So I'm guessing the call to shadow/watch did not occur until after I ^C'ed.
(defn start-dev
  {:shadow/requires-server true}
  [& args]
  (prn (shell/sh "npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"))
  (shadow/watch :app))
#2018-07-1016:05thhellercorrect. shell/sh never exits so watch is never called#2018-07-1016:06kennyHmm. Probably need to find a better shell library then.#2018-07-1016:06thhellerhmm now that I think about it there is no easily accessible "run in background but show streaming output" type of utility fn built-in#2018-07-1016:06kennyRight, that's exactly what I need.#2018-07-1016:07thhelleryou can use ProcessBuilder I guess#2018-07-1016:08kennyYeah, I suppose so.#2018-07-1016:09thheller
(let [cmd ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]]
  (future
    (-> (ProcessBuilder. cmd)
        (.inheritIO)
        (.start)
        (.waitFor))))
#2018-07-1016:09kennyWill killing the parent process also kill the child?#2018-07-1016:09thhelleryes#2018-07-1016:10thhellerhmm how does lein-cooper handle the output? are they all just dumping to stdout?#2018-07-1016:11kennyYes. + some nice formatting.#2018-07-1016:11kennyAnd if a subproc fails, the whole thing exits.#2018-07-1016:14kennyI forgot I actually extracted lein-cooper into a self-contained library several months ago haha: https://github.com/ComputeSoftware/join-process/blob/master/src/join_process/core.clj. I think I can use that here.#2018-07-1016:16thhellerbtw you can also just use tools.deps directly. you do not have to go through shadow-cljs#2018-07-1016:17thhellerclojure -m shadow.cljs.devtools.cli compile app is identical to shadow-cljs compile app#2018-07-1016:18thhellercan just replace shadow-cljs with clojure -m shadow.cljs.devtools.cli for any command the only thing you miss out of is the server support. see https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2018-07-1016:20kennyNot sure I understand the advantage you gain by doing that.#2018-07-1016:23thhelleryou don't really. the result should be the same.#2018-07-1016:34kennySo I got it to work like this:
(ns dev.build
  (:require
    [join-process.core :as join-proc]))

(defn start-dev
  [& args]
  (join-proc/join-process [{:name "cljs"
                            :cmds ["shadow-cljs" "watch" "app"]}
                           {:name "sass"
                            :cmds ["npx" "node-sass" "resources/css/" "--watch" "--recursive" "--output" "resources/public/css"]}]))

(defn -main
  [& args]
  (apply start-dev args))
Running this command clj -A:dev:start-dev with these deps.edn :aliases:
{:dev  {:extra-paths ["env" "devcards-src"]
        :extra-deps  {compute/join-process {:git/url ""
                                            :sha     "3068d554275575f499c0bd999ea3e17fc41eabad"}}}
 :start-dev {:main-opts ["-m" "dev.build"]}}
#2018-07-1016:35kennyI would've expected this to work though:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2e454b4040576e654b404057036d41435e5b5a4b037d41485a594f5c4b03634f4d4c414145"}, :content ("[email protected]")}
However, nothing was printed to the console.
#2018-07-1016:35thhellernote the shadow-cljs - connected to server. a server instance is already running#2018-07-1016:36kennyHow does that change the output?#2018-07-1016:36thhellerthe older server instance probably still has the older code loaded?#2018-07-1016:38kennyYou're right - restarting the server fixed it. Makes sense but was a bit confusing.#2018-07-1016:38thhellerits probably still better to use clj directly since clj-run assumes you will be running shadow-cljs code and loads all the namespaces#2018-07-1016:39thhellerwhich will make startup way slower compared to just clj directly#2018-07-1016:39thhellersince all you do run 2 new separate processes#2018-07-1016:41kennyMakes sense#2018-07-1113:18eoliphanthi, what’s a good way to handle config stuff that varies across environments? say dev vs production api endpoints,#2018-07-1113:25hlolli@eoliphant I'm useing webpack with shadow since recently, and there I can do something like this in plugins, reading from environmental variables
new webpack.DefinePlugin({
            'DEVELOPMENT': JSON.stringify(process.env.NODE_ENV === 'development'),
        }),
then I can see if I'm in development mode
(def dev? js/DEVELOPMENT)
some plugin like this may exists with other means.
#2018-07-1113:29eoliphantyeah, I was hoping for something ‘shadow only’ lol.#2018-07-1113:31eoliphantI see this for the build itself https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration wondering if I can use that plus the build hooks#2018-07-1113:32eoliphantah, read right past this.. https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2018-07-1113:33hlollinice! way better 😛#2018-07-1113:33eoliphantsometime you just need to talk stuff thrugh lol. I literally read past this twice lol#2018-07-1113:35hlolliI've read past this more than twice, and finally it clicked now in my brain what it's used for.#2018-07-1115:56thheller:closure-defines is a good option, you can also use https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading or combine both#2018-07-1115:58justinleewhen I see this line <- Cache write: seekeasy/upload.cljs (4825 ms) does that mean it is taking 4.8 seconds just to write a single file to disk or does that include some kind of wait time for other writes too?#2018-07-1115:59thheller4,8sec to write the Cache for that file only. does not include any other time. how big is that file?#2018-07-1116:00justinleeit’s 35 lines of cljs code#2018-07-1116:00thhellerdoes it include a macro that inlines some gigantic datastructure?#2018-07-1116:00justinleethis seems to happen over time#2018-07-1116:01justinleeno macros are actually used in the file. it is just a single defn#2018-07-1116:02justinleei bet if i stop and restart the process it will be fast again#2018-07-1116:02thhellerthats weird. I have never seen this get slower over time. can you check how big .shadow-cljs/builds/<your-build>/dev/ana/seekeasy/upload.cljs.cache.transit.json is?#2018-07-1116:02thhellerbefore restarting please?#2018-07-1116:03justinlee543532#2018-07-1116:04thhellerthats way too large for a simple file#2018-07-1116:04justinleewtf there’s all kinds of crazy shit in here#2018-07-1116:04justinleethere’s just pages and pages of this kind of stuff "^2I","^2D","^43","^44","^5W","^6R"#2018-07-1116:05thhellerits the cache data structure in transit#2018-07-1116:05thhellercan you send it to me please? might include a clue whats repeating#2018-07-1116:05thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection> or a gist#2018-07-1116:06thhellerthats normal transit encoding for keywords and other constants. not unusual.#2018-07-1116:06thhellerI suspect that the analyzer data is growing over time for some reason#2018-07-1116:07thhellerits supposed to get a reset when the file is recompiled#2018-07-1116:11justinleeokay sent. it took me a really long time to remember how to show a freaking dotfile in mac haha#2018-07-1116:12thhellerthx checking it out. now you can try restarting the server and recompiling that file#2018-07-1116:12thhellercache should be smaller then#2018-07-1116:15thhellerok there is definitely something odd going on in there#2018-07-1116:16justinleei sent you the same file after restart#2018-07-1116:16thhellerjust to rule out outside factors: do you use pure shadow-cljs.edn or lein/tools.deps?#2018-07-1116:16justinleepure shadow. no dirty lein for me 🙂#2018-07-1116:16thhellerdo you use any other CLJ side stuff? cider, tools.namespace?#2018-07-1116:17justinleethe only weird thing i have is ghostwheel#2018-07-1116:17justinleethough this file doesn’t directly invoke any of that#2018-07-1116:17thhellerthats only spec related and doesn't mess with namespaces directly IIRC#2018-07-1116:18justinlee
:dependencies
 [[org.clojure/clojure "1.9.0"]
  [org.clojure/clojurescript "1.10.238"]
  [com.bhauman/spell-spec "0.1.1"]
  [expound "0.7.1"]
  [metosin/spec-tools "0.7.1"]
  [gnl/ghostwheel "0.2.2"]
  [org.clojure/test.check "0.9.0"]
  [reagent "0.7.0"]
  [secretary "1.2.3"]
  [venantius/accountant "0.2.3" :exclusions [org.clojure/tools.reader]]
  [funcool/promesa "1.9.0"]
  [cljs-ajax "0.7.3"]
  [com.rpl/specter "1.1.0"]]
#2018-07-1116:18justinleeand i just use cursive#2018-07-1116:18thheller
module$node_modules$react_dom$lib$reactProdInvariant
module$node_modules$react_dom$lib$ReactPropTypesSecret
module$node_modules$prop_types$factory
module$node_modules$react$lib$React
module$node_modules$fbjs$lib$invariant
module$node_modules$fbjs$lib$warning
shadow.js
module$node_modules$react_dom$lib$reactProdInvariant
module$node_modules$react_dom$lib$ReactPropTypesSecret
 module$node_modules$prop_types$factory
module$node_modules$react$lib$React
module$node_modules$fbjs$lib$invariant
module$node_modules$fbjs$lib$warning
#2018-07-1116:19thhellerthese are supposed to be distinct. checking why they are repeated over and over again#2018-07-1116:20thhelleryeah the clean file doesn't repeat them endlessly#2018-07-1116:21thhellerah found it I think#2018-07-1116:30sakallihi *. n00b q's: decided to try to build an app on shadow-cljs today. used the
lein new shadow-cljs 8bs-vision-survey +reagent
template. according to the readme it has the following commands:
yarn install, yarn watch, yarn clean, yarn release
the shadow-cljs.edn file looks like this
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies [[binaryage/devtools "0.9.7"]
                [reagent "0.8.0-alpha2"]
                [org.clojure/core.async  "0.4.474"]
                [com.pupeno/free-form "0.6.0"]
                [cljs-http "0.1.45"]
                [com.cemerick/url "0.1.1"]]
 
 ;; set an nrepl port for connection to a REPL.
 :nrepl        {:port 8777}

 :builds
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"

        :modules
        {:main
         {:entries [vision-survey-8bs.core]}}

        :devtools
        ;; before live-reloading any code call this function
        {:before-load vision-survey-8bs.core/stop
         ;; after live-reloading finishes call this function
         :after-load vision-survey-8bs.core/start
         ;; serve the public directory over http at port 8700
         :http-root    "public"
         :http-port    8700
         :preloads     [devtools.preload]}
        }}}
got it working while developing and decided to deploy the app. i ran
yarn release
and deployed the public folder to a server. the app runs but only displays the placeholder page with "Shadow-cljs rocks!" - text. any pointers how to fix it?
#2018-07-1116:31thheller@sakalli any messages in the browser console?#2018-07-1116:34sakalliah yeah. something wrong with the path to the js. lets see if i can fix it. thanks.#2018-07-1116:39thheller@lee.justin.m trying to figure out how this happens over time. do you have one watch running for very long times (days) or do you restart frequently?#2018-07-1116:40justinleeone watch that goes for days#2018-07-1116:40justinleei rarely restart#2018-07-1116:40justinleeand i’m pretty sure this takes a long time to manifest#2018-07-1116:41thhelleryeah it probably gets slower with every recompile#2018-07-1116:42justinleeoh yea on a single recompile it went from 68314 to 77632#2018-07-1116:42thhelleror rather it gets slower for every file that is not recompiled#2018-07-1116:42justinleeand i didn’t change anything except whitespace in one of its dependencies#2018-07-1116:45justinleei see, so i have certain utility files that everything depends on. when i touch those files, all of the cache files increase in size#2018-07-1116:46justinleewhen i just touch upload.cljs, just that file and its dependencies get bigger#2018-07-1116:47thhellernevermind. of course its growing when I edit the file and change the contents 😉#2018-07-1116:51thheller@lee.justin.m should be fixed in 2.4.20. pretty obvious bug when looking at it. to the degree that I can't figure out how caching works at all. that should really have invalidated the cache all the time.#2018-07-1116:51sakalliok. so got the path working but there is another error "SyntaxError: identifier starts immediately after numeric literal" referring to the line
<script>vision-survey-8bs.core.init();</script>
at the end of the index document. so no numbers allowed in function names?
#2018-07-1116:52thheller@sakalli that is javascript where - is actually minus. must "munge" the name to use _ instead. <script>vision_survey_8bs.core.init();</script>#2018-07-1116:53justinleeThe Six Stages of Debugging:
1. That can't happen.
2. That doesn't happen on my machine.
3. That shouldn't happen.
4. Why does that happen?
5. Oh, I see.
6. How did that ever work?
#2018-07-1116:53thhellerexactly 🙂#2018-07-1116:54sakallihaha#2018-07-1116:54thheller@lee.justin.m thanks for the report and the files. would have taken ages to debug without.#2018-07-1116:57sakalliis there a hack to munge it other than manually or fixing the whole app (which is quite some work since this name is in the directory structure and all over the app). very little js experience.#2018-07-1116:58thheller@sakalli what do you mean? the CLJS compiler does that automatically. you just need to do it once in the HTML when calling the init function.#2018-07-1116:59thhellerwhen it doesn't work after changing the _ you just might be missing the important ^:export bit on the (defn ^:export init [] ...)#2018-07-1117:00sakalliok. thanks @thheller#2018-07-1117:00justinlee@thheller thank YOU for being such a freaking wizard. the fix appears to be working for me#2018-07-1117:01justinleenow i think i’m going to have to ditch ghostwheel because it is basically has to be recompiled anytime i change any file. i’d rather have subsecond turnaround i think#2018-07-1117:03thhellerI only looked at it briefly. seemed nice but also like a lot of overhead 🙂#2018-07-1117:05justinleei’m kind of missing my .h files: they sure did make compilation faster#2018-07-1117:06justinleeon a project of considerable size it must be very frustrating to iterate on utility files as the whole world has to be recompiled#2018-07-1117:06thhellerwell fancy things like ghostwheel must cost something 😉#2018-07-1117:07thhelleryeah I really want to do some performance work but that takes sooo much time#2018-07-1117:07thhellerit bothers me already when I have to wait 3sec or so#2018-07-1117:08thhellerthe fastest thing you can do is working at the REPL without live-reloading at all#2018-07-1117:08justinleei guess i’m just not sure why, for example, ghostwheel/core.cljc has to be recompiled when I change file A, which includes file B, which uses ghostwheel, even though B and ghostwheel don’t change#2018-07-1117:08thhellersince you control what gets reloaded and when#2018-07-1117:08thhellerbut its also more manual and annoying at times 😉#2018-07-1117:09justinleei have fantasies about creating some kind of build system that loads everything up and creates a granular database of functions and macros and transcends the concept of a file. then we can all ascend into developer heaven#2018-07-1117:09thhellerwhy is ghostweel.core recompiled?#2018-07-1117:10justinleei don’t know. but it is recompiled everytime i touch any file#2018-07-1117:10thhellerhmm that shouldn't be?#2018-07-1117:10justinleeoh well if that’s a bug then that’d be a good thing. i thought it was just something inherent to the messiness of macros#2018-07-1117:11justinleeshould i try to create a small repro?#2018-07-1117:12thhelleroh right. whole lots of magic macros. still shouldn't recompile ghostweel.core if you touch a namespace that requires it though#2018-07-1117:12thhelleror does it produce warnings?#2018-07-1117:14justinleenope#2018-07-1117:17gnlIf I may chime in – ghostwheel really shouldn't be recompiled every time you just change a namespace which uses it, I would definitely consider this a bug, although not yet sure where. I don't think I've ever witnessed that, but I'll look into it on my end, see if I can reproduce it.#2018-07-1117:18justinleei’m trying to create a repro here too. likely is user error on my part#2018-07-1117:19gnlAre you somehow directly referencing the actual ghostwheel source in your project – for example by adding the cloned repo to your source paths or something – or just using the clojars artifact?#2018-07-1117:20justinleeclojars#2018-07-1117:20thheller@lee.justin.m does this still happen in 2.4.20? I can totally see this happening with the older versions#2018-07-1117:22justinlee@thheller yes it does#2018-07-1117:26justinleeokay yea this is easy to repro#2018-07-1117:27gnlOops.#2018-07-1117:27gnlI think this one's on me.#2018-07-1117:27gnlGimme a few minutes.#2018-07-1117:27justinleethanks for looking into it!#2018-07-1117:28gnlHey, I'm as allergic to long recompile/reload times as anyone. 🙂#2018-07-1117:36gnl@lee.justin.m Okay, try 0.2.3-SNAPSHOT#2018-07-1117:39gnlThis is embarrassing – I had ^:dev/always set on the tracing namespace (leftover from development) and ghostwheel.reporting+ghostwheel.core depend on it, so there's a whole lot of unnecessary work being done.#2018-07-1117:40justinleeoh yea now its zippy. no ghostwheel recompiles anymore#2018-07-1117:40justinleethanks!#2018-07-1117:40justinleetook my recompile from >2s to <1s#2018-07-1117:41justinleeand now that we’ve fixed the shadow-cljs bug, my 14s builds are less than 1s too 🙂#2018-07-1117:42justinlee@thheller one thing: when i updated the version of ghostwheel in shadow-cljs.edn, it kicked off a recompile, but it didn’t actually download new artifacts. is that intended?#2018-07-1117:42justinleeI had to restart to get new artifacts.#2018-07-1117:42gnl@lee.justin.m I just went through the six stages of debugging you described above in like 15 seconds.#2018-07-1117:43gnlThat was a ride. 🙂#2018-07-1117:43gnlI'll see about releasing 0.2.3 soon, cause this one's painful.#2018-07-1117:45thheller@lee.justin.m recompile should only happen if the build config changed. only :dependencies should not trigger it. downloading new artifacts is only done of startup since doing that at runtime is way too complicated#2018-07-1117:46justinleeokay cool. the recompile must have been because i hadn’t saved some other file because it isn’t doing it now.#2018-07-1117:47thhellerbbiab. gotta buy some food.#2018-07-1122:30gnl@lee.justin.m – if you run into anything like this again, please let me know. Ghostwheel's runtime overhead should be zero and the recompile overhead virtually zero (the code generation here is really not particularly complex or expensive), unless you enable tracing and/or gen-testing on hot-reload, which will of course slow things down.#2018-07-1122:33justinlee@clojurians.net cool thanks. i’m still not 100% on how the compiler works so i’m never quite sure if there’s an issue. it’s a real delight to deal with folks like you and @thheller so thanks for that#2018-07-1122:37gnlWhen you're not sure just ask on #ghostwheel first and if we can't clear this up quickly, you can open an issue on GitHub. I need eyes on this thing to get it solid, so feedback is appreciated.#2018-07-1214:27lsnapeI'm trying to add an extern for an ES6 class ctor in one of my js files. I'm requiring like this:
["/js/audio/wavesurfer.cursor-time" :default wavesurfer-cursor-time-plugin]
The js file looks like:
class CursorTimePlugin {
  static create(params) { ... }
}
...
export default CursorTimePlugin;
The runtime error I get when I compile a release build is: Uncaught TypeError: $module$js$audio$wavesurfer_cursor_time$$.default.create is not a function
#2018-07-1214:29lsnapeOh and I'm calling the function in my cljs namespace like: (.create ^js wavesurfer-cursor-time-plugin (clj->js (:cursor-time options))) I've experimented with all sorts of defs in my externs file, but none make the problem go away! For example, the following doesn't work:
var $module$js$audio$wavesurfer_cursor_time$$ = {};
$module$js$audio$wavesurfer_cursor_time$$.default = {};
$module$js$audio$wavesurfer_cursor_time$$.default.create = function(params) { };
#2018-07-1215:05justinleethat doesn’t look like an externs issue because the name isn’t getting munged#2018-07-1215:07justinleeif was an advanced compilation issue it would say something like g432 is not a function#2018-07-1215:14oscar@lsnape I think your require string is probably wrong. "/" Means filesystem root. https://nodejs.org/api/modules.html#modules_all_together#2018-07-1215:27lsnapeSorry @lee.justin.m should have mentioned I''ve added :pseudo-names true. If I turn it off then I do indeed get wpa.default.create is not a function.#2018-07-1215:28lsnapeAnd @oscar the above code works in development.#2018-07-1215:40justinleethat’s weird that the typehinting didn’t work. if you use a string accessor it works, I assume?#2018-07-1215:51lsnapeYes I'd expect it to work too. What do you mean by a string accessor?#2018-07-1215:55justinlee
(def thing #js{:getSomething (fn [] :a)})
=> #'cljs.user/thing
(goog.object/get thing "getSomething")
=> #object[getSomething]
((goog.object/get thing "getSomething"))
=> :a
#2018-07-1215:55justinleeyou can just use goog.object/get to grab the create function off of the imported object and then invoke that value#2018-07-1215:55justinleebecause the closure compiler does not munge strings, it won’t be subject to advanced compilation#2018-07-1215:56justinleeit’s just a way of confirming that the issue is symbol munging rather than the actual create symbol somehow not being there at all#2018-07-1218:04thheller@lsnape @lee.justin.m this is probably not a munging issue. if you use /js/... to import the file it will be imported by the closure compiler and passed through :advanced. meaning it needs to externs.#2018-07-1218:05justinleeooh i missed that this was a direct include#2018-07-1218:05thheller@oscar starting with / has a different meaning in shadow-cljs and means importing from the classpath root. https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2018-07-1218:06oscarAh. I've only ever imported node modules. That makes sense.#2018-07-1218:12thheller@lsnape judging by the compiler output it appears that the static create method is getting removed by closure. which I believe is documented somewhere. let me see if I can find it#2018-07-1218:18thhellerhttps://github.com/google/closure-compiler/issues/1776#2018-07-1218:19thheller
class SomeClass {
    /** @nocollapse */
    static create(params) {
        return ["SomeClass.create",1,2,params];
    }
}
#2018-07-1218:19thhellerthis works. I don't think the issue is solvable by externs alone.#2018-07-1219:38lsnapeThanks thheller! I'll give that a go.#2018-07-1219:50lsnapeThat's done it. Thanks, not sure how long it would have taken me to stumble across that. You rock metal#2018-07-1222:38dfcarpenterNew shadow-cljs user here. So on shadow-cljs watch app I am getting The required JS dependency "jquery" is not available, it was required by "cljsjs/jquery.cljs". How can I figure out which dependency needs that so I can assess whether I want it or not?#2018-07-1222:53justinlee@dfcarpenter just do a npm i jquery --save#2018-07-1222:53justinleeshadow-cljs basically ignores the foreign-libs dependency in the cljsjs package because it reads js code directly from the node_modules directory, so you need to install the js modules directly#2018-07-1222:54justinleeoh sorry you were asking a different question#2018-07-1222:54dfcarpenterI figured it out by checking each dep repo. Looks like the re-pressed library ( capturing keyboard events in re-frame ) uses jquery ( which is overkill )#2018-07-1222:55justinleei suspect there is a lein deps :tree type command in the shadow repl but i don’t know what it is#2018-07-1223:20gadfly361@dfcarpenter Yeah, re-pressed does unfortunately use jQuery 😬 (I didn't want to go through the trouble of making an abstracted way to guarantee cross-browser support ... so leaned on jquery to do it for me with which)#2018-07-1223:22dfcarpenter@gadfly361 Ahh, of course cross browser support. Totally understand; there be dragons for cross browser/legacy browsers. Anyways, does the google closure library not handle this or does it only handle chrome?#2018-07-1223:25gadfly361@dfcarpenter I am not actually sure, but if it does, then that would be a good approach 🙂#2018-07-1223:45dfcarpenter@gadfly361 Actually since gmail and I think the google office suite uses the closure library and it does have really good cross browser support I think it may be a good option.#2018-07-1313:16thheller@tomi.hukkalainen_slac I'm curious. Did you try shadow-cljs yet? I see that you are struggling to get CLJS+npm working I can tell you with confidence that this would all just work in shadow-cljs. 😉#2018-07-1313:17HukkaOh yes, I didn't ask here yet. I quickly checked the examples and noticed that they were all frontend only#2018-07-1313:17HukkaI was wondering if there's a sample project that combines backend too, preferably with lein#2018-07-1313:18thhellerjust use lein for the backend. no need to change that#2018-07-1313:18HukkaThe docs seemed to give pretty strong encouragement to not use lein, but I'm guessing shadow can't handle plain clj on its own#2018-07-1313:18thhelleryou can use lein or tools.deps. I just recommend standalone shadow-cljs since its more tuned and takes care of some other stuff#2018-07-1313:19thhellerI'd guess that about half of the people here use lein though. https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2018-07-1313:19HukkaHow does shadow handle dead code elimination with the closure compiler and es modules?#2018-07-1313:20HukkaI'm trying to get to the bottom of where the problem even is, currently#2018-07-1313:20thhellernode_modules never use the full DCE and only run through :simple (in shadow-cljs)#2018-07-1313:22thhellerbut if you require only the "components" you need thats usually good enough#2018-07-1313:22thhellerand thats what the JS world does and recommends#2018-07-1313:22thhellergetting :advanced working for node_modules is highly experimental and has never worked reliably for me#2018-07-1313:23HukkaI though that https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules meant that it is doing that#2018-07-1313:23Hukkasigh There are too many moving pieces#2018-07-1313:24thhelleryeah its highly experimental and alpha. I don't think that anyone has ever gotten that to work. at least I never heard a single success story#2018-07-1313:24thhellerit does work in a few isolated cases like just React+ReactDOM#2018-07-1313:24thhellerbut each package you add makes success less likely#2018-07-1416:39gleisonsilvaHello, guys! May you help me... supposed that I need to add a "break line / new line" after the compiled js file... shadow-cljs gives me an option for that? Or should I just use bash and make a dirty thing like echo "" >> main.js?#2018-07-1416:40gleisonsilvaThis is need because I need to upload the files to a third party cms repository that is complaining abou the absence of a new line on the file end...#2018-07-1420:04thheller@gleisonsilva thats a strange requirement. you can do it with :modules {:main {:entries [...] :append "\n"}} though.#2018-07-1511:21Yehonathan SharvitShadow-cljs really rocks!!!!#2018-07-1511:21Yehonathan SharvitI was able to compile a 16k lines of clojurescript code and make it an npm module, easilly consumable by a react web app#2018-07-1511:22Yehonathan SharvitA question about publishing the npm package: is it advised to include the generated js.map files?#2018-07-1512:04thheller@viebel you can but most tools do not read them although I do think that webpack supports it somehow#2018-07-1512:57Yehonathan SharvitThanks @thheller. Does somebody know how webpack makes use of the js.map files?#2018-07-1518:05denis_krivosheevHi guys. I have a big react app written on TypeScript. I wanna migrate it to clojurescript using shadow cljs. So basically I’m interested in interop between clojurescript and JavaScript (and vice versa). Is there some examples how to do so?#2018-07-1518:17Yehonathan Sharvit@denis_krivosheev what kind of interop examples do you need? 1. accessing javascript code from clojurescript 2. accessing npm modules from clojurescript#2018-07-1518:17Yehonathan Sharvit3. both#2018-07-1518:17denis_krivosheevThe main issue here is using cljs from js files#2018-07-1518:18denis_krivosheevI read the docs and it suggests to use goog: prefix... and compiler is going to understand that #2018-07-1518:18denis_krivosheevBut I don’t understand how#2018-07-1518:19denis_krivosheevFor now the root of my app is going to be in typescript and I want to use clojurescript from there#2018-07-1518:20denis_krivosheevAnd also use some ts from cljs#2018-07-1518:20Yehonathan Sharvitdo you want to integrate clojurescript into your code base?#2018-07-1518:20denis_krivosheevYes#2018-07-1518:20Yehonathan SharvitThere is a video demo that @thheller did#2018-07-1518:21denis_krivosheevSounds awesome. Where can I find it?#2018-07-1518:21Yehonathan Sharvithere it is: https://www.youtube.com/watch?v=BLDX5Twt2zk#2018-07-1518:21denis_krivosheevGreat thanks!#2018-07-1518:21Yehonathan SharvitIt is a bit old so some of the shadow-cljs commands have changed#2018-07-1518:22Yehonathan SharvitI think you need to run shadow-cljs compile npm#2018-07-1518:23Yehonathan SharvitMy turn to ask for support#2018-07-1518:23Yehonathan SharvitI am seeing the following error when running npm watch test#2018-07-1518:23Yehonathan Sharvit
Jul 15, 2018 6:13:41 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :test available at 
shadow-cljs - server version: 2.4.5
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 57924
shadow-cljs - nREPL server running on port 57926
shadow-cljs - watching build :test
[:test] Configuring build.
[:test] Compiling ...
[:test] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/viebel/.m2/repository/thheller/shadow-cljs/2.4.5/shadow-cljs-2.4.5.jar!/shadow/cljs/devtool
s/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------
#2018-07-1518:24Yehonathan Sharvitnpm compile test works fine#2018-07-1518:24Yehonathan Sharvithere is my shadow-cljs.edn#2018-07-1518:24Yehonathan Sharvit
{:lein true
 :builds {:npm 
            {:target :npm-module
             :output-dir "."}
          :test
            {:target :browser-test
             :test-dir "resources/public/js/test"
             :devtools  {:http-port 8021
                         :http-root "resources/public/js/test"}}}}
#2018-07-1518:25Yehonathan Sharvitanybody can help solving this issue?#2018-07-1519:00HukkaFigwheel has an option to start a ring server to serve the frontend. Does shadow have something similar? Couldn't find anything in the guide#2018-07-1519:10oscarhttps://shadow-cljs.github.io/docs/UsersGuide.html#browser-http-server#2018-07-1519:13gravWhen I start shadow-cljs server from cmd-line, it says:
shadow-cljs - Using IP "192.168.1.43" from Interface "en0"
Can I get it to listen on 0.0.0.0 or localhost instead? Currently I have to restart the server every time my ip changes.
#2018-07-1519:20gravSeems it’s just using the first one from this fn-call: https://github.com/thheller/shadow-cljs/blob/eaa84c584905dbcf97e6fa8f78a6d955d4ac00fd/src/main/shadow/cljs/devtools/api.clj#L666 So maybe it’s not configurable?#2018-07-1519:59thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server.clj#L173 this is the relevant line#2018-07-1519:39Hukka@oscar Precisely, there seems to be support only for static file serving, not running a full ring api#2018-07-1519:40oscar:http-handler#2018-07-1519:40urbanslugHey guys so I'm trying to use this tool https://github.com/sass/node-sass However this
(:require ["node-sass" :as sass])

(sass/render {:file 'path-to-file'})
errors with Invalid symbol: 'path-to-file'
#2018-07-1519:40urbanslugis that not how to call these js functions?#2018-07-1519:41thheller@viebel thats an outdated core.async version#2018-07-1605:53Yehonathan Sharvitthanks @thheller That solved the issue#2018-07-1519:41thheller@grav its always listening on 0.0.0.0 unless otherwise specified. the fixed IP is also gone for a couple of releases now.#2018-07-1519:42thheller@urbanslug 'path-to-file' thats a symbol in CLJS, must use "path-to-file". ie. double quotes#2018-07-1519:43thhellerand you probably need to either use clj->js or #js {:file ...} as node-sass expects a JS object not a CLJS map#2018-07-1519:43urbanslug@thheller Ah I see. I thought that error was weird. Aren't symbols things that resolve to something?#2018-07-1519:44urbanslugso strings are double quotes and single quotes are symbols like vars are symbols?#2018-07-1519:44urbanslugI'm clearly missing something#2018-07-1519:44urbanslugYeah I thought it being a cljs map would be an issue#2018-07-1519:44thheller' is quote in CLJS#2018-07-1519:45urbanslugAh!#2018-07-1519:45urbanslugYeah#2018-07-1519:45urbanslughahaha#2018-07-1519:45urbanslugmacro#2018-07-1519:45urbanslugthe syntax highlighting also hinted to that facepalm#2018-07-1520:07urbanslughas anyone used node-sass? I get an interesting error that dirname is not defined basically from https://github.com/sass/node-sass/blob/master/lib/extensions.js#L10 defaultBinaryDir = path.join(__dirname, '..', 'vendor')#2018-07-1520:08thhellerare you trying to use node-sass in a :browser build?#2018-07-1520:08urbanslugya 🙂#2018-07-1520:08thhellerthats not going to work. it relies on libsass which is a native c extension#2018-07-1520:08urbanslugYeah it pointed to this in the readme https://github.com/sass/libsass#2018-07-1520:09urbanslug@thheller you know a way to get this done?#2018-07-1520:09thhellerit is not possible#2018-07-1520:10urbanslugwow#2018-07-1520:10urbanslug😞#2018-07-1520:10urbanslugI was calling node-sass via the binary but it ddidn't have code-reload#2018-07-1520:10urbanslugguess I'll go back to css then#2018-07-1520:11thhellerwhat are you trying to do?#2018-07-1520:12thhelleryou can use node-sass in node builds just fine. just not in the browser.#2018-07-1520:13urbanslugI am making a reagent app using shadow cljs#2018-07-1520:13urbanslugand I wanted to use scss for easily managing css#2018-07-1520:14thhellerthats fine. just have to compile the scss on the server and load the compile css#2018-07-1520:18urbanslugOk so this is how I'm doing it rn. I have a project cljs file along the following lines:
{...
 scripts: {
  sass: "node-sass ...",
  dev: "shadow-cljs watch app;",
  repl: "shadow-cljs cljs-repl app;"
}}
so for dev I run all 3 in different split screens
#2018-07-1520:18urbanslugis this kinda what you mean or are you saying there's a way to configure shadow-cljs in the .edn file?#2018-07-1520:19thhelleryes something like that. shadow-cljs has nothing built-in for sass (yet)#2018-07-1520:19urbanslugalso this doesn't reload css after node-sass updates the file#2018-07-1520:19urbanslugso I have to manually reload and lose state#2018-07-1520:19thhellercss reloading should work. assuming you have an absolute path#2018-07-1520:20thhellercheck if you have a <link rel="stylesheet" href="/absolute/path.css">#2018-07-1520:20thhellerif thats not using an absolute path it will not be live reloaded#2018-07-1520:20urbanslugAh I have "./css/style.css"#2018-07-1520:21urbanslugbut an absolute path makes it brittle like it means I have to change that for prod#2018-07-1520:22thhellerrelative paths are currently not supported as stated in the docs. no idea how you setup looks like so can't comment on that.#2018-07-1520:23urbanslugthanks I haven't gone through the docs very well#2018-07-1606:57denis_krivosheev@thheller Hi. Do you have an example of how to call cljs from js with shadow-cljs? I created namespace and tried
import {foo} from 'goog:demo.foo';
it doesn’t work. I tried this example from documentation either:
import cljs, { keyword } from "goog:demo.foo";

cljs.array_map(keyword("foo"), "hello world");
In both cases javascript loader says: Module not found: Can’t resolve ‘goog:demo.foo’ in ‘/Users/den/git/test/mhello-cljs/src’
#2018-07-1608:28thheller@denis_krivosheev this only works if the JS is compiled by shadow-cljs. I have some code for testing in the shadow-cljs repo. it looks like this https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/es6.js#L1#2018-07-1609:28thheller@tomi.hukkalainen_slac you still seem to be fighting with :foreign-libs. I'm curious if you tried shadow-cljs and if you chose not to use it why?#2018-07-1609:32HukkaI checked the docs to see how I could replace the current build with shadow without reworking too much, but got a bit stuck at the server side, again. I'm currently letting figwheel start the ring server for backend in dev mode. That works by simply telling figwheel where the ring handler is. At first I figured that shadow doesn't do that at all, only static files. Then I did get a pointer that there is a fallback handler config when client requests urls that aren't available as static, but that was... pretty sparsely documented. Just says that it's a function from req to response, without saying anything what the request or the response are#2018-07-1609:32HukkaSurely I could have looked into source to figure it out, but once again I tried a different way to include libs that are not in cljsjs#2018-07-1609:33HukkaI can't escape the feeling that moving to shadow would require significant refactoring of the way the backend and frontend are built and work together#2018-07-1610:05thhellerwhat do you use to serve the backend in production?#2018-07-1610:06thhellerthanks for the feedback though. I'll smooth over that part of the docs. shadow-cljs focus is on CLJS and I always run my own webserver when I need server side stuff.#2018-07-1610:41thheller@tomi.hukkalainen_slac FWIW the backend and the frontend work together exactly the same way. figwheel doesn't do anything to the backend and you can start the backend server by any other means. the only thing CLJS requires from the backend is that the generated JS files are served properly.#2018-07-1610:41thhellerhttps://github.com/ring-clojure/ring/wiki/Getting-Started#2018-07-1610:42thhelleryou can use run-server with whatever you have specified as :ring-handler in figwheel#2018-07-1610:42thhellerdon't even have to shadow-cljs about it whatsoever#2018-07-1613:18HukkaWe use compojure-api#2018-07-1613:19HukkaI think an example showing the whole stack would go a long way, though of course what the stack is varies. I think that the compojure-api + reagent/re-frame is pretty usual#2018-07-1611:54Yehonathan SharvitA question related to the :browser target#2018-07-1611:54Yehonathan SharvitHere is my shadow-cljs.edn file:
{:target :browser
           :output-dir "resources/public/js/browser"
           :devtools  {:http-port 8025
                       :http-root "resources/public/js/browser"}
           :modules {:main {:entries [audyx.app.init]}}}
 
#2018-07-1611:55Yehonathan SharvitI created an index.html in resources/public/js/browser with the following content:
<script src="main.js"></script>

#2018-07-1611:56Yehonathan Sharvitbut when I load localhost:8025/index.html#2018-07-1611:56Yehonathan SharvitI get many console errors for all the js dependencies#2018-07-1611:57Yehonathan SharvitFor instance:
 Not found
#2018-07-1611:57Yehonathan SharvitWhat is wrong with my configuration?#2018-07-1612:18thheller@viebel :asset-path "/" in your config, it defaults to "/js"#2018-07-1612:20thhellerany reason why you don't use resources/public as :http-root though? typically you should avoid putting anything other than generated output into :output-dir#2018-07-1612:20Yehonathan Sharvitok#2018-07-1612:21Yehonathan Sharvitand then the :asset-path should be "js/browser". Right?#2018-07-1612:21thheller/js/browser yes#2018-07-1612:21thhelleralways try to use absolute paths. much easier to work with later.#2018-07-1612:22Yehonathan SharvitThis is what I meant. I made a typo#2018-07-1612:22Yehonathan Sharvit🙃#2018-07-1612:22Yehonathan Sharvitthat works#2018-07-1612:23Yehonathan SharvitNow I am launching a REPL with shadow-cljs cljs-repl browser#2018-07-1612:42Yehonathan Sharvit@thheller The code doesn't seem to reload on code change. I mean: I see in the browser a notification that the compilation started but the code changes don't take effect and the :before-load function is not triggered. In my case, I have a couple of build warnings, so I set :ignore-warnings true but it didn't help#2018-07-1612:42Yehonathan Sharvitwhat can I do?#2018-07-1612:42thhellerdo you have the :after-load hook properly set?#2018-07-1612:43thhellerin figwheel that would be :on-jsload I think#2018-07-1612:43thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#L3-L5#2018-07-1612:44thhellereither like this in the code via metadata or :devtools {:after-load your.app/start} in the config#2018-07-1612:45Yehonathan SharvitYeah#2018-07-1612:45Yehonathan SharvitI have tried both#2018-07-1612:46Yehonathan Sharvitbut it didn't help#2018-07-1612:46Yehonathan Sharvit
:browser
          {:target :browser
           :output-dir "resources/public/js/browser"
           :asset-path "/js/browser/"
           :ignore-warnings true
           :devtools  {:http-port 8025
                       :http-root "resources/public/"
                       :before-load audyx.app.init/before-load
                       :after-load audyx.app.init/start}
           :modules {:main {:entries [audyx.app.init]}}}
#2018-07-1612:47thhellerwhat does the browser console show?#2018-07-1612:47Yehonathan Sharvit
shadow-cljs: WebSocket connected!
browser.cljs:27 shadow-cljs: REPL init successful
browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/calibration.cljs at [77:3]
	Wrong number of args (1) passed to audyx.audio.ambiences.calibration/create-noise-node
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/transducer_calibration.cljs at [32:3]
	Wrong number of args (3) passed to cljs.core/replace
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/audio/input.cljs at [35:13]
	Use of undeclared Var audyx.audio.input/-Infinity
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/volume.cljs at [29:1]
	Bad method signature in protocol implementation, ILoop initial-index does not declare arity 3
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/single.cljs at [10:1]
	->Single already refers to: audyx.test.records.loop.single/->Single being replaced by: audyx.test.records.loop.single/->Single
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/graphs/vocalsnr_graph.cljs at [13:1]
	Bad method signature in protocol implementation, Graph graph-definition does not declare arity 3
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
#2018-07-1612:47Yehonathan SharvitI see the shadow-cljs icon rotating#2018-07-1612:48thhellerthats it? nothing after those warnings?#2018-07-1612:48Yehonathan Sharvitnothing#2018-07-1612:49thhellerah the ignore-warnings is misplaced#2018-07-1612:49thhellershould be in :devtools#2018-07-1612:50Yehonathan Sharvitahahah#2018-07-1612:51Yehonathan Sharvit👏#2018-07-1612:51Yehonathan SharvitNow I have exactly the same as figwheel. right?#2018-07-1612:51thhellerno idea. I have never use figwheel. 😛#2018-07-1612:52Yehonathan SharvitOk#2018-07-1612:52Yehonathan SharvitIs there a way to have code completion in the shadow-cljs REPL?#2018-07-1612:52thhellerconnect your editor then yes. otherwise currently no#2018-07-1612:53Yehonathan SharvitWill try to connect emacs#2018-07-1612:54Yehonathan Sharvitwhat editor will you recomend on windows?#2018-07-1612:54thhellerI use Cursive only (and would recommend)#2018-07-1612:54Yehonathan SharvitI have recently switched from Macos to Windows 10#2018-07-1612:54Yehonathan SharvitUsing WSL#2018-07-1612:54Yehonathan SharvitI am having troubles installing leiningen on Windows#2018-07-1612:55Yehonathan SharvitTrying to install shadow-cljs now#2018-07-1613:14Yehonathan SharvitMeanwhile I was able to enjoy a shadow repl inside emacs (cider)#2018-07-1613:14Yehonathan SharvitThe instructions on the shadow doc are very clear#2018-07-1613:15Yehonathan Sharvitthe only thing that was not 100% straightforward was that I had to configure [cider/cider-nrepl "0.17.0"] according to my cider version: 0.18.0-SNAPSHOT Maybe you can add a comment about that here: https://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies_2#2018-07-1613:16Yehonathan Sharvitalso, M-x cider-create-sibling-cljs-repl is now: M-x cider-connect-sibling-cljs#2018-07-1613:17thhellerif you use the built-in shadow-cljs support in cider you don't have to specify it at all I think#2018-07-1613:17thhellerbut I do not use emacs and know nothing about it#2018-07-1613:34dpsuttonif you start shadow-cljs from emacs through CIDER it will insert the dependencies for you (I think)#2018-07-1613:59Yehonathan Sharvit@thheller now trying to configure Cursive#2018-07-1614:00Yehonathan SharvitWhat context module should I provide in the Clojure remote REPL settings?#2018-07-1614:16thhellerdo you have more than one?#2018-07-1614:23Yehonathan SharvitNo idea. I don't know what is a context module?#2018-07-1614:23thhellerhow did you create the cursive project?#2018-07-1614:46Yehonathan SharvitI opened my project root folder#2018-07-1614:47thhelleryou should probably generate a pom.xml via shadow-cljs pom#2018-07-1614:48thhellerand then file -> new -> from existing sources and then select the pom.xml#2018-07-1614:48thhellerleave everything as is and accept acouple times#2018-07-1614:48thhellerthat should setup all the deps properly#2018-07-1614:50Yehonathan Sharvitok. trying it#2018-07-1614:50thhellerwhenever you change dependencies just call shadow-cljs pom again and let cursive update it#2018-07-1614:51Yehonathan Sharvitok#2018-07-1614:53thhelleryou can also use project.clj with lein of course. cursive has a bit better integration with that.#2018-07-1614:53thhellerbut I had no issues with using pom.xml#2018-07-1614:53Yehonathan SharvitWhat REPL should I create? A remote Clojure REPL?#2018-07-1614:53Yehonathan SharvitI don't see an option for a Cljs REPL#2018-07-1614:54thhelleryes remote clojure repl#2018-07-1614:54thhelleronce connecte call (shadow.cljs.devtools.api/repl :browser) to switch it to CLJS#2018-07-1614:58Yehonathan SharvitSeems to work#2018-07-1614:58Yehonathan SharvitIs there a way to call this code automatically?#2018-07-1614:58thhellerdont think so#2018-07-1614:59thhelleryou can create a REPL command and assign that to a keybinding#2018-07-1615:01Yehonathan Sharvithow?#2018-07-1615:02thhellerhttps://cursive-ide.com/userguide/repl.html#2018-07-1615:06Yehonathan SharvitCool#2018-07-1615:06Yehonathan SharvitNow I have a very weird issue in Cursive#2018-07-1615:07Yehonathan SharvitI don't get a prompt in the REPL window#2018-07-1615:07Yehonathan SharvitI can send commands to the REPL but I cannot type any command#2018-07-1615:07thhellerare you typing in the correct window? the input thing has its own space below#2018-07-1615:08thhellersorry gotta go. Cursive has pretty extensive docs and should contain everything you need.#2018-07-1615:08thhellerI'll be back later#2018-07-1615:08Yehonathan SharvitThanks a lot#2018-07-1615:08Yehonathan Sharvitfor your help#2018-07-1615:08Yehonathan Sharvitand for shadow-cljs#2018-07-1615:08Yehonathan SharvitIt really rocks!!!#2018-07-1816:19JonI want to quote this.#2018-07-1816:20Jonscreenshot~#2018-07-1616:08Yehonathan SharvitI am having a warning at the beginning of the execution of compilation:
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch browser
Compiling ClojureScript...
Compiling ["public/clojurescript/dev/2ffae5ec-aa76-40ed-aadc-d3878fce327a.js"] from ["src/cljs/audyx" "resources"]...
module.js:549
    throw err;
    ^

Error: Cannot find module '@cljs-oss/module-deps'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at [eval]:3:13
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:652:30)
    at evalScript (bootstrap_node.js:463:27)
#2018-07-1616:09Yehonathan SharvitAfter that the compilation completes successfully. But I'd prefer fixing this warning#2018-07-1616:09Yehonathan SharvitAny idea?#2018-07-1616:12thhellerthat is something from standard CLJS#2018-07-1616:12thhellerthat is not a shadow-cljs compilation, possibly lein-cljsbuild or so?#2018-07-1616:13thhellerdefinitely not a shadow-cljs message though#2018-07-1622:08Yehonathan Sharvitsome package.json contains a browser key (e.g https://github.com/aws/aws-sdk-js/blob/master/package.json) According to https://docs.npmjs.com/files/package.json#browser :
If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. window)
#2018-07-1622:09Yehonathan SharvitDoes shadow-cljs behave like this when browser key is present on a npm module imported?#2018-07-1622:09Yehonathan SharvitCurrently, I am not able to require aws-sdk in my shadow-cljs project#2018-07-1622:10Yehonathan SharvitIt seems like shadow-cljs ignores the browser key#2018-07-1622:26Yehonathan Sharviton :target :browser builds#2018-07-1706:38denis_krivosheevHi @thheller I’m trying to use posh library in my project. It produces error when load because it calls clojure.walk/postwalk function. In according to ClojureScript documentation https://www.clojurescript.org/about/differences clojure.walk namespace is included to ClojureScript. It works fine with lein and figwheel, but looks like there is no such namespace when I compile it in shadow-cljs. Any thoughts how to fix this?#2018-07-1706:57denis_krivosheevInteresting, if I require [clojure.walk :as walk] and then use it inside my code (even like clojure.walk/postwalk), it works. But if I use it without requiring in this particular namespace, and just use clojure.walk/postwalk it fails. In general case I would just require it, but it’s library code, not mine#2018-07-1707:06thheller@viebel the browser key is fully supported and I tested including aws-sdk and it worked fine. what error do you get?#2018-07-1707:07Yehonathan Sharvitmaybe in my case it doesn't work due to :lein true?#2018-07-1707:07thheller@denis_krivosheev code must always be required properly to work yes. you might be able to make it work if you include clojure.walk before including the library. shadow-cljs is a bit stricter about requires due to the parallel compilation#2018-07-1707:08thheller@viebel nope, doesn't affect that at all#2018-07-1707:08Yehonathan Sharvithmm#2018-07-1707:08Yehonathan Sharvitlet me try again#2018-07-1707:08thhellerI'm gonna need the error you are seeing otherwise I can't help#2018-07-1707:10Yehonathan SharvitI get this error:
Compiling ClojureScript...
Compiling ["public/clojurescript/main.js"] from ["src/cljs/audyx"]...
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: module not found: "fs" from file /mnt/c/Users/USER/prj/audyx-deps/node_modules/aws-sdk/lib/util.js
    at onresolve (/mnt/c/Users/USER/prj/audyx-deps/node_modules/@cljs-oss/module-deps/index.js:181:30)
    at onResolve (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:70:11)
    at innerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:143:22)
    at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)
    at next (/mnt/c/Users/USER/prj/audyx-deps/node_modules/tapable/lib/Tapable.js:249:35)
    at innerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/Resolver.js:143:22)
    at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)
    at next (/mnt/c/Users/USER/prj/audyx-deps/node_modules/tapable/lib/Tapable.js:249:35)
    at resolver.doResolve.createInnerCallback (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:41:24)
    at callbackWrapper (/mnt/c/Users/USER/prj/audyx-deps/node_modules/enhanced-resolve/lib/createInnerCallback.js:10:21)

#2018-07-1707:11thhellerthat doesn't look like a shadow-cljs error. are you using lein-cljsbuild again?#2018-07-1707:11thheller@cljs-oss/module-deps shadow-cljs never ever uses that#2018-07-1707:11denis_krivosheev@thheller requiring it before the library doesn’t work either#2018-07-1707:12Yehonathan SharvitI have :lein true#2018-07-1707:12denis_krivosheev
(ns differ.core
  (:require
   [datascript.core :as datascript]
   [expound.alpha :as expound]
   [orchestra-cljs.spec.test :as st]
   [cljs.spec.alpha :as s]
   [clojure.walk :as walk] ;; <- here
   [re-posh.core :as re-posh])) ;; <- this library using it
#2018-07-1707:12thheller@viebel that doesn't matter. you are not currently using shadow-cljs. I don't know what exactly you are doing but the above error is not produced by shadow-cljs#2018-07-1707:13thhellertry removing any reference to figwheel or lein-cljsbuild from your project.clj#2018-07-1707:13thhelleror whatever else may be in there#2018-07-1707:14thheller@denis_krivosheev you can take this file https://github.com/mpdairy/posh/blob/master/src/posh/lib/pull_analyze.cljc#2018-07-1707:14thhellerand put it into your classpath and add the clojure.walk require#2018-07-1707:15denis_krivosheevoh, great idea!! thanks!#2018-07-1707:15denis_krivosheevwhat is the order of classpath walking? my code first or library first?#2018-07-1707:16thhellersource-paths always take priority#2018-07-1707:16denis_krivosheevcool! Great thanks!#2018-07-1707:16thhellerit should really be fixed in the posh library though#2018-07-1707:41denis_krivosheevYeah, will create a PR to them#2018-07-1707:43denis_krivosheev@thheller one more thing in my console. I’m building project with target :npm-module and use it from javascript as in your example project. When it starts it throws an error: Uncaught ReferenceError: SHADOW_ENV is not defined#2018-07-1707:43denis_krivosheeveven if I start it this way: SHADOW_ENV=development shadow-cljs watch app#2018-07-1707:44thhellerthats not what that does 😉#2018-07-1707:44denis_krivosheevYeah, it’s just my gues. But how to fix this?#2018-07-1707:45denis_krivosheevThe same error in your example project#2018-07-1707:45thhellerhmm really?#2018-07-1707:46thhellerit works just fine on my machine#2018-07-1707:46thhellerwhat is your setup/config?#2018-07-1707:47denis_krivosheevyeah, in this one https://github.com/shadow-cljs/examples/tree/master/cljs-react-app#2018-07-1707:47denis_krivosheev
{:source-paths
 ["cljs-src" "cljs-test"]

 :nrepl {:port 8450}

 :dependencies
 [[org.clojure/clojurescript "1.10.339"]
  [org.clojure/clojure "1.9.0"]
  [reagent "0.8.1"]
  [datascript "0.16.6"]
  [orchestra "2017.11.12-1"]
  [expound "0.7.1"]
  [re-posh "0.3.0"]]

 :builds
 {:app {:target :npm-module
        :output-dir "dist/cljs"
        :runtime :browser
        :entries [differ.core differ.chat.views]}
  :test {:target :node-test
         :output-to "dist/cljs/test"}}}
#2018-07-1707:48denis_krivosheevI’m using it the same way as in example, except I use not node_modules but just a folder inside my project#2018-07-1707:48thhellerruntime browser?#2018-07-1707:48thhellerah CRA right#2018-07-1707:48denis_krivosheevYes, the error is in runtime. Browser chrome#2018-07-1707:49thhellerany particular reason you are not using :target :browser instead? do you need anything from CRA?#2018-07-1707:50denis_krivosheevI wanna migrate my project to clojurescript, but it’s big and there is no way I can rewrite it from scratch. It’s TypeScript and I need interop from TypeScript to ClojureScript and vice versa#2018-07-1707:50thhellerah ok#2018-07-1707:52thhellerI think the :runtime :browser might be causing some confusion. I just tested with node which works fine.#2018-07-1707:53thhellergotta get my test setup running again first#2018-07-1707:53thhellerhaven't used that in a while#2018-07-1707:57thhellerhmm nope also runs fine in the browser for me#2018-07-1707:57thhellerplease check if dist/cljs/cljs_env.js exists and has a var SHADOW_ENV ... line#2018-07-1707:59thhellerand please post the full error you get including the stacktrace#2018-07-1707:59thhellermaybe its just in a spot I didn't check#2018-07-1707:59Hukka
$ lein run -m shadow.cljs.devtools.cli help
Unknown action.
What might I be doing wrong?
#2018-07-1708:00denis_krivosheev
browser.cljs:39 Uncaught ReferenceError: SHADOW_ENV is not defined
    at Object.shadow$cljs$devtools$client$browser$goog_is_loaded_QMARK_ [as goog_is_loaded_QMARK_] (browser.cljs:39)
    at shadow$cljs$devtools$client$browser$src_is_loaded_QMARK_ (browser.cljs:48)
    at Function.G__24616__1 [as cljs$core$IFn$_invoke$arity$1] (core.cljs:4222)
    at cljs.core.filter.cljs$core$IFn$_invoke$arity$2 (core.cljs:5124)
    at cljs.core.LazySeq.sval (core.cljs:3394)
    at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (core.cljs:3452)
    at Object.cljs$core$seq [as seq] (core.cljs:1210)
    at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2445)
    at cljs.core.LazySeq.cljs$core$IReduce$_reduce$arity$3 (core.cljs:3458)
    at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (core.cljs:2517)
#2018-07-1708:00thheller@tomi.hukkalainen_slac not using shadow-cljs help 😉#2018-07-1708:00HukkaWell, if it doesn't work via lein, then the doc misled me 😞#2018-07-1708:01denis_krivosheev@thheller also I’m using shadow-cljs 2.4.20#2018-07-1708:01denis_krivosheevmaybe it’s the reason#2018-07-1708:01thheller@tomi.hukkalainen_slac the help command is more or less useless regardless but currently its implremented only on the CLJS side so its just missing#2018-07-1708:01thheller@denis_krivosheev nah found the issue its in the live reloading code#2018-07-1708:03denis_krivosheevah, cool#2018-07-1708:07thheller@denis_krivosheev should be fixed in 2.4.21#2018-07-1708:24denis_krivosheevGreat! thank you!#2018-07-1708:29denis_krivosheev@thheller tested. Fixed. Great job! shadow-cljs rocks :the_horns:#2018-07-1710:14Hukka@thheller I was wondering if I should make a repository, that builds a ring-jetty backend and shadow/re-frame frontend commit by commit, documenting the commands in the README (as some of the files in the repo are not written by hand)?#2018-07-1710:14HukkaAs soon as I get it working myself, of course#2018-07-1710:42HukkaHm. How do I tell shadow not to use the version of a an npm library packaged under dist, but instead the non-minified src version, for debugging/development?#2018-07-1711:13HukkaGah. :js-options :resolve seems to do the trick, but the library is actually jsx, which wasn't really visible from the filenames#2018-07-1711:16HukkaHaha, next section in the guide 🙂#2018-07-1711:10niclasnilssonAny hints on what to do when (server/start!) doesn’t return, as in the example at https://shadow-cljs.github.io/docs/UsersGuide.html#embedded. It just hangs with no output.#2018-07-1711:17niclasnilssonHmm… It does start under a boot repl, but not under a clj (deps.edn) repl… Any ideas to get it started under clj?#2018-07-1716:18thhellerwhat are you calling? it should work exactly the same in all envs#2018-07-1716:58niclasnilssonJust (server/start!)#2018-07-1717:07niclasnilssonHmm. I had some other things in my deps.edn as well, but when stripping that out and running a deps.edn with just shadow-cljs in, it does this:
% clj
Clojure 1.9.0
user=> (require '[shadow.cljs.devtools.server :as server])
nil
user=> (server/start!)
Jul 17, 2018 7:03:33 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Jul 17, 2018 7:03:33 PM clojure.tools.logging$eval8756$fn__8759 invoke
WARNING: HTTP startup failed
java.lang.IllegalArgumentException: XNIO001001: No XNIO provider found
        at org.xnio.Xnio.doGetInstance(Xnio.java:270)
        at org.xnio.Xnio.getInstance(Xnio.java:187)
        at io.undertow.Undertow.start(Undertow.java:116)
        at shadow.undertow$start.invokeStatic(undertow.clj:194)
        at shadow.undertow$start.invoke(undertow.clj:158)
        at shadow.cljs.devtools.server$start_http$fn__22410.invoke(server.clj:136)
        at shadow.cljs.devtools.server$start_http.invokeStatic(server.clj:135)
        at shadow.cljs.devtools.server$start_http.invoke(server.clj:131)
        at shadow.cljs.devtools.server$start_system.invokeStatic(server.clj:180)
        at shadow.cljs.devtools.server$start_system.invoke(server.clj:154)
        at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:349)
        at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:283)
        at shadow.cljs.devtools.server$start_BANG_.invokeStatic(server.clj:286)
        at shadow.cljs.devtools.server$start_BANG_.invoke(server.clj:283)
        at user$eval22617.invokeStatic(NO_SOURCE_FILE:3)
        at user$eval22617.invoke(NO_SOURCE_FILE:3)
        at clojure.lang.Compiler.eval(Compiler.java:7062)
        at clojure.lang.Compiler.eval(Compiler.java:7025)
        at clojure.core$eval.invokeStatic(core.clj:3206)
#2018-07-1717:07niclasnilsson(Not hanging anymore though)#2018-07-1717:13niclasnilssonAnd upgrading tools.deps fixed the XNIO problem#2018-07-1717:15niclasnilssonAnd now it works with the other stuff I had in deps.edn as well. So basically, an upgrade of tools.deps (and clojure) made it work.#2018-07-1718:26thhellerah right. yeah older versions of tools.deps didn't support :scope "runtime" which the xnio stuff uses.#2018-07-1719:05thheller@urbanslug the vals issue you ran into earlier was actually a bug in shadow-cljs which should be fixed in 2.4.22#2018-07-1719:18urbanslug@thheller thanks for the update 🙂#2018-07-1809:10nijkIs there a way to decrease the size of an app built and served by shadow-cljs in dev mode? We’re only a few pages into our app and the payload in dev is already over 15MB - well over half of that is cljs core and uncompressed 3rd party deps. There’s also an issue regarding the sheer number of http requests required to deliver code this way, I’m seeing hundreds of requests for the category of code described above, this makes testing on a mobile or in browser emulation tools very slow#2018-07-1812:26Hukka@nick828 Is turning optimizations on out of the question?#2018-07-1812:27nijk@tomi.hukkalainen_slac I don’t believe that is recommended in development for compilation time reasons#2018-07-1812:44HukkaYou could try how bad it is#2018-07-1812:44HukkaTesting and pure development are a bit different, so it might be better still to do even :simple for those mobile test runs#2018-07-1813:01nijk@tomi.hukkalainen_slac That’s a fair point, not ideal but a workaround that I can live with#2018-07-1811:30niclasnilssonWhen starting an embedded shadow-cljs from clj (with a deps.edn only containing the dep on shadow 2.4.20), the :source-paths in shadow-cljs.edn seems to be totally ignored. Can I convince the embedded shadow to use the source paths in shadow-cljs.edn instead? I tried :deps false without success. (I can setup an alias in deps.edn, but I’d rather have the cljs stuff in the shadow config and the clj stuff in deps.edn)#2018-07-1812:29HukkaRelated to nijk's question, is there a nice way to analyze/visualize the shadow bundle content sizes, similar to https://chrisbateman.github.io/webpack-visualizer/ or https://github.com/webpack-contrib/webpack-bundle-analyzer#2018-07-1812:33hlolli@tomi.hukkalainen_slac answer is yes, how, I forgot. Start the server and type some command. Sure someone here will tell you. There’s I think a blog post from thheller on how to do it.#2018-07-1812:34HukkaThanks for the hints. I'll go hunting in google and in the blog#2018-07-1812:36Hukkahttps://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871#2018-07-1812:43HukkaThat last comment shows the same report I get with https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report so I guess no pretty graphs for now, unless I build it myself.#2018-07-1812:43HukkaCan't be assed, the list is good enough#2018-07-1814:03Yehonathan Sharvit@thheller I was offline for 2 days#2018-07-1814:03Yehonathan SharvitBack to the issue that I have with aws-sdk#2018-07-1814:03Yehonathan SharvitHere is my error:
➜  shadow-cljs-app git:(master) ✗ shadow-cljs watch browser
shadow-cljs - config: /Users/viebel/prj/shadow-cljs-app/shadow-cljs.edn  cli version: 2.4.5  node: v10.6.0
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - starting ...
[2018-07-18 17:02:28 - WARNING] TCP Port 9630 in use.
[2018-07-18 17:02:34 - WARNING] failed to start :browser dev-http:8025 reason: java.net.BindException: Address already in use
shadow-cljs - HTTP server for :browser available at 
shadow-cljs - server version: 2.4.5
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 49168
shadow-cljs - nREPL server running on port 49170
shadow-cljs - watching build :browser
[:browser] Configuring build.
[:browser] Compiling ...
[:browser] Build failure:
The required JS dependency "util" is not available, it was required by "node_modules/aws-sdk/lib/event_listeners.js".

Searched in:/Users/viebel/prj/shadow-cljs-app/node_modules

You probably need to run:
  npm install util

See: 
#2018-07-1814:04Yehonathan SharvitI have created a public github repo that reproduces this issue. Here it is: https://github.com/viebel/shadow-cljs-app#2018-07-1815:54thheller@viebel you need to add shadow-cljs itself as a npm dep. npm install --save-dev shadow-cljs that will install the missing util polyfill#2018-07-1819:18Yehonathan SharvitAwesome. It worked. I missed this part in the documentation#2018-07-1815:57thheller@nick828 I'd look into trying to reduce the deps a bit. 15mb is a bit excessive and will still probably be huge in :advanced release builds. beyond that gzip + http2 can help reduce load times in dev#2018-07-1815:59thheller@niclasnilsson shadow-cljs completely relies on the JVM classpath so whatever you use to manage that is responsible for including the source paths. shadow-cljs can't add any paths after startup.#2018-07-1816:01niclasnilsson@thheller Ah, ok. Thanks!#2018-07-1816:23thheller@tomi.hukkalainen_slac I played with various visualizations but none of them were even close to the simple table view in actual visible information#2018-07-1816:24thhellerstill want to add some complementary graphs at some point though#2018-07-1816:43plamenHello, first time user of shadow-cljs and trying to run the “conduit” example from the main repo (as it matches as close as possible what I need to do) to adapt my workflow to it. Everything yet works, except that if I change the source code (of a reagent component from the demo), shadow-cljs says that it compiled without errors, the browser then tries to reload it, but then throws an error in its console:#2018-07-1816:43plamen
env.cljs:174 error when calling lifecycle function conduit.core/main Error: Target container is not a DOM element.
    at module.exports (invariant.js:43)
    at legacyRenderSubtreeIntoContainer (react-dom.development.js:17239)
    at Object.render (react-dom.development.js:17318)
    at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:20)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$3 (dom.cljs:44)
    at Function.reagent.dom.render.cljs$core$IFn$_invoke$arity$2 (dom.cljs:39)
    at Function.reagent.core.render.cljs$core$IFn$_invoke$arity$2 (core.cljs:74)
    at conduit$core$main (core.cljs:75)
    at shadow.cljs.devtools.client.env.make_task_fn (env.cljs:171)
    at shadow$cljs$devtools$client$env$do_js_reload_STAR_ (env.cljs:180)
shadow.cljs.devtools.client.env.make_task_fn	@	env.cljs:174
shadow$cljs$devtools$client$env$do_js_reload_STAR_	@	env.cljs:180
(anonymous)	@	env.cljs:180
(anonymous)	@	env.cljs:209
shadow$cljs$devtools$client$env$do_js_reload_STAR_	@	env.cljs:180
shadow.cljs.devtools.client.env.do_js_reload.cljs$core$IFn$_invoke$arity$4	@	env.cljs:216
shadow$cljs$devtools$client$browser$do_js_reload	@	browser.cljs:66
(anonymous)	@	browser.cljs:151
(anonymous)	@	browser.cljs:100
goog.events.EventTarget.fireListeners	@	goog.events.eventtarget.js:284
goog.events.EventTarget.dispatchEventInternal_	@	goog.events.eventtarget.js:381
goog.events.EventTarget.dispatchEvent	@	goog.events.eventtarget.js:196
goog.net.XhrIo.onReadyStateChangeHelper_	@	goog.net.xhrio.js:867
goog.net.XhrIo.onReadyStateChangeEntryPoint_	@	goog.net.xhrio.js:813
goog.net.XhrIo.onReadyStateChange_	@	goog.net.xhrio.js:797
XMLHttpRequest.send (async)		
goog.net.XhrIo.send	@	goog.net.xhrio.js:627
goog.net.XhrIo.send	@	goog.net.xhrio.js:352
shadow$cljs$devtools$client$browser$load_sources	@	browser.cljs:92
shadow$cljs$devtools$client$browser$handle_build_complete	@	browser.cljs:151
shadow$cljs$devtools$client$browser$handle_message	@	browser.cljs:267
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:148
(anonymous)	@	browser.cljs:327
#2018-07-1816:46plamen(I changed the dependency in the example source to use the latest 2.4.21 version of shadow-cljs)#2018-07-1816:51plamenWith the “conduit” example I mean the example source from https://github.com/jacekschae/conduit#2018-07-1817:12eoliphantanyone have ant.design working with shadow?#2018-07-1817:31Hukka@thheller Hm, ok#2018-07-1817:32Hukka@eoliphant One coworker is playing with it, but not with shadow. I guess he has just a dist bundle with global assignment or something. Any particular problems?#2018-07-1817:32eoliphantnah, was just curious about to give it a whirl#2018-07-1817:32eoliphantthere’s apparently a cljsjs bundle for it already#2018-07-1817:32HukkaI lost interested after he told me you need to run your separate less build anyway to change the style. So I went for material-uiV1 instead (from V0)#2018-07-1817:32HukkaI see, perhaps he's then using that#2018-07-1817:32eoliphantand someone has a wrapper for it as well#2018-07-1817:33eoliphantyeah i just like it because it’s pretty complete lol#2018-07-1817:34HukkaMUI got a lot of flak from being difficult to customize, but I think their choice to use JSS is the best one, from the modern options I'm aware of#2018-07-1817:34Hukka(I mean the old version was rightfully criticized for that, but the new one has JSS)#2018-07-1817:38eoliphantill check it out. i’m more of a backend guy. so i tend towards stuff that gets most of the way there, then someone else can come theme , etc#2018-07-1817:43eoliphantnow i’m looking at MUI agian.. looks prety cool. especially the pro thanks for confusing me lol lol..#2018-07-1817:52thheller@plamen that usually happens when using goog.History for some routing purposes and reloading the file that initializes it. the conduit code has that issue. the hook-browser-navigation! should only be called once.#2018-07-1818:19kennyCan I set :deps :aliases on a per build basis?#2018-07-1905:37thheller@kenny no. but you can call clj -A:xyz -m shadow.cljs.devtools.cli compile foo instead of shadow-cljs compile foo#2018-07-1905:52thhellerbut consider this https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html. it is generally not useful or required to separate source paths for CLJS.#2018-07-1906:18Yehonathan Sharvit@thheller I want to write a cljs lib that wraps an npm module (in my case js-yaml). What should be the :target for this cljs lib? Should it be :npm-module?#2018-07-1906:29thheller@viebel nothing. CLJS libs are uncompiled source files packaged in a jar. meaning they aren't configured at all for shadow-cljs since it has nothing to build#2018-07-1906:31Yehonathan Sharvitok#2018-07-1906:32Yehonathan Sharvitwhat about the package.json file of the lib? I will include it the jar. right?#2018-07-1906:32thhellerno#2018-07-1906:32thhelleryou create a deps.cljs at the root with {:npm-deps {"js-yaml" "the-version"}}#2018-07-1906:32thhellerpackage.json won't be used at all#2018-07-1906:33thhellersince npm doesn't look into .jar files#2018-07-1906:33Yehonathan Sharvitok. let me try it#2018-07-1907:18Yehonathan SharvitAnd then in an app that consumes my cljs-yaml lib I won't need to manually install js-yaml. Right?#2018-07-1907:19thhellerif you are consuming with shadow-cljs then js-yaml will be installed automatically if deps.cljs specifies it#2018-07-1907:19thhellerfor standard CLJS it might be more tricky and I honestly can't tell you how it works there#2018-07-1907:22Yehonathan SharvitIt's ok for me to consume with shadow-cljs#2018-07-1907:22Yehonathan SharvitBut it doesn't work either - for the moment#2018-07-1907:22Yehonathan Sharvit
➜  shadow-cljs-app git:(master) ✗ shadow-cljs compile browser
shadow-cljs - config: /mnt/c/Users/USER/prj/shadow-cljs-app/shadow-cljs.edn  cli version: 2.4.22  node: v8.10.0
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - starting ...
[:browser] Compiling ...
The required JS dependency "js-yaml" is not available, it was required by "cljs_yaml/core.cljs".

Searched in:/mnt/c/Users/USER/prj/shadow-cljs-app/node_modules

You probably need to run:
  npm install js-yaml

See: 
#2018-07-1907:23thhellerwhat are the contents of the cljs-yaml.jar?#2018-07-1907:25Yehonathan Sharvithmmm#2018-07-1907:25Yehonathan Sharvitit doesn't contain deps.cljs#2018-07-1907:25Yehonathan SharvitI published it with lein deploy clojars#2018-07-1907:26thhellerwhere do you have the deps.cljs?#2018-07-1907:26Yehonathan Sharvitin the root folder#2018-07-1907:26thhellerneeds to be in one source path#2018-07-1907:27Yehonathan Sharvitahah#2018-07-1907:34Yehonathan SharvitIt works now#2018-07-1907:36Yehonathan Sharvit😎👏#2018-07-1907:39Yehonathan Sharvit@thheller shadow-cljs is adding js-yaml automatically to the package.json of my app#2018-07-1907:39thhelleryes it must#2018-07-1907:40Yehonathan SharvitI am not sure this is the best option#2018-07-1907:40thhellerits the only option#2018-07-1907:40thhellernpm can remove things when not listed in package.json#2018-07-1907:40thhelleror rather yarn does that by default. if you remove something from package.json it is uninstalled#2018-07-1907:40Yehonathan SharvitI see#2018-07-1907:42Yehonathan SharvitWhat I can do in my app is never touch the dependencies in package.json by myself and only works with deps.cljs. And let shadow-cljs manage the dependencies in package.json#2018-07-1907:42thhelleryou should really be using package.json + npm as its meant to be by npm#2018-07-1907:43thhellerusing shadow-cljs to "emulate" it will just suck#2018-07-1907:43thhelleryou are going to run into conflicts eventually and gonna need npm to resolve them anyways#2018-07-1907:43thhellerI hate npm too but thats the way it works in the JS world. can't do anything to change that.#2018-07-1907:43Yehonathan SharvitI don't understand. What is the best place to declare my npm dependencies? package.json or deps.cljs?#2018-07-1907:44thhellerpackage.json in your project. deps.cljs for libs#2018-07-1907:44Yehonathan Sharvitok#2018-07-1907:44Yehonathan Sharvitgot it#2018-07-1907:52HukkaHm, I understood that @viebel is trying to make a lib for all the npm deps, and then just mark them as clj deps, letting the build tool then download the subnpmdeps. But that's discouraged?#2018-07-1907:52HukkaI suppose that's the cljsjs-way, but without doing externs etc#2018-07-1907:55Hukka@thheller Does shadow have some kind of concise document on how it works, internally? I often have the feeling that I need to know how the tools I use to not get cut in edge cases. For instance, I was wondering why my .-js-property accesses didn't get mangled by advanced closure, when using plain npm requires. The libraries themselves are not build with advanced, so the names stay correct on that end, but my cljs code should be.#2018-07-1907:59thheller@tomi.hukkalainen_slac since shadow-cljs processes all the JS it also extracts all properties found in those JS files and uses those for externs inference#2018-07-1907:59thhelleralso when using (:require ["thing" :as t]) all accesses to t/foo are automatically added to externs#2018-07-1908:01thhellerthis is probably the most concise document about how it works currently https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html#2018-07-1908:03HukkaIn this case it was callback code, again. So I'm making a function that I give to a JS thingy. Then the thingy calls my function, giving it an #js object as parameter. Then I do property access on that object#2018-07-1908:03HukkaBefore, on vanilla cljs (though not on the newest version) I tried to make externs for that, but ended up with metadata helpers everywhere, and eventually just used oops#2018-07-1908:04HukkaBut with shadow, the plain .- and even set! just worked#2018-07-1908:04thhellerwhen it doubt add ^js typehints https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-07-1908:05HukkaThough perhaps that's just the new and improved externs inference working better... which means I don't know how the plain cljs works either (and certainly I don't)#2018-07-1908:05thhellershadow-cljs does a lot more externs inference since it processes all the JS#2018-07-1908:06thhellerfor example when it finds exports.foo = ... it will add foo to externs just in case you call it#2018-07-1908:06HukkaConcretely, I was testing https://github.com/paypal/downshift#usage.#2018-07-1908:07HukkaIt uses the child function / render prop paradigm, so everything you do with it is always making a function that downshift will then call when it needs to, and then you work on the parameter object#2018-07-1908:10HukkaIt's not a full example (missing the reagent atom setup and reset function), but shows how to change the input element functionality inside the downshift autocomplete component.#2018-07-1908:10HukkaThe FIXME is outdated, since it still works in shadow-cljs release app 🙂#2018-07-1908:11thhellersafest thing to do would be (fn [^js downshiftProps] ...)#2018-07-1908:11thhellerthen it should probably work in normal CLJS as well#2018-07-1908:11thheller(.-nativeEvent.-preventDownshiftDefault event) thats not valid though#2018-07-1908:12thheller(.. event -nativeEvent -preventDownshiftDefault)#2018-07-1908:12HukkaOdd, didn't get any errors or warnings#2018-07-1908:13thhelleryeah since JS allows setting any arbitrary props. it just won't have any effect 😉#2018-07-1908:13HukkaIs it setting a property named 'nativeEvent.-preventDownshiftDefault'?#2018-07-1908:14thhellerprobably "_preventDownshiftDefault"#2018-07-1908:14thhellernot sure actually. maybe it accidentally works#2018-07-1908:15HukkaThat line might not be even necessary, then. The method call matters the most.#2018-07-1908:15HukkaAnyway, I'm miffed when things don't work as I expected, even if the work unexpectedly 😕#2018-07-1908:16HukkaI could just pepper ^js in every callback like that, but it feels like cargo culting#2018-07-1908:17thhellerset :compiler-options {:infer-externs :auto} in your build config#2018-07-1908:17thhellerand set it whenever you get a warning#2018-07-1908:17thhellerotherwise you should be fine#2018-07-1908:17HukkaCould :compiler-options {:infer-externs :all} help...#2018-07-1908:17HukkaAh, :auto instead#2018-07-1908:17thhellerI don't recommend :all since that will complain about files you don't control
#2018-07-1908:30Hukkainfer-externs doesn't give any warnings. I kinda would like to try if the same works on new clojurescript, but I'm guessing I couldn't get the deps installed 😅#2018-07-1908:31HukkaI now have a fully working minimal set with lein, ring/jetty, uberjars etc. Time to move the real project into shadow#2018-07-1908:32Hukka😔 maybe lunch first#2018-07-1908:32thhellerprobably best to keep the CLJ part with lein and stuff#2018-07-1908:32thhellershadow-cljs is focused and built on CLJS#2018-07-1908:32thhellerwhile you can run CLJ normally through it it will never be optimized for it#2018-07-1908:32thhellerie. no uberjars#2018-07-1909:11claudiunot really sure to be honest. 🙂 I am deploying my test-app to google-appengine, and that's the format there.#2018-07-1909:12claudiuAdded lein-tools-deps to my project, seems to work for development but the uberwar seems to compile multiple times the same file, and when I run it I get some strange errors.#2018-07-1909:19dominicmI can try find some time to look into it for you.#2018-07-1909:23dominicmLooks like a jar with a specific fs layout, shouldn't be too difficult to get working with pack, I'm a little worried about git dependencies, that might need some testing.#2018-07-1910:13claudiuCool 🙂 Could help with testing git & normal, and see how it matches the lein one.#2018-07-1911:24claudiuHaving the uberwar option would be really awesome.#2018-07-1917:28dominicmIs there an easy way to test an uberwar locally?#2018-07-2009:15claudiuI have only used uberwar in appengine context. The simplest way to test the war I can think of is : https://gist.github.com/claudiuapetrei/540c8aca1ef53d86f75f123b319a3703#2018-07-2010:06dominicmThanks, I'll take a look#2018-07-1908:33HukkaI mean lein makes shadow compile the cljs into resources, and then bundles the jetty server that servers that along with the dynamic api code#2018-07-1908:33thhellerah ok#2018-07-1908:34HukkaI was thinking if I should make this into a tutorial repository, but not sure if there's demand/use for it.#2018-07-1908:34HukkaBuilding the thing commit by commit, where you could follow the workflow, and document the cli commands into the readme#2018-07-1908:38thhellersounds like a good idea. I still need to document the whole "migrating from X ..." parts but since I have never used X thats pretty tough#2018-07-1909:19plamen@thheller A lot of thanks for the hint from yesterday about the reload/history initialisation!#2018-07-1909:44Hukka@thheller Coming to clojutre? We'd get you a beer (or whatever floats your boat ;)#2018-07-1910:17HukkaHm. If I make a clojurescript library and use the :require :default syntax, will vanilla cljs users have problems importing my lib?#2018-07-1911:09p-himikIs there any particular reasons for using lists in the table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages? I had to scratch my head for a minute since before that page I've seen lists in :refer only in really old code - now all examples use vectors.#2018-07-1912:56colindresjClojure doesn’t care if you use a list or a vector, it’s just become idiomatic to use a vector. I don’t want to speak for him, but I suspect that @thheller might be using a list to help show that it’s a JS dependency being brought in (same reasoning behind strings vs symbols in require)#2018-07-1912:34HukkaOn my real project I'm getting a bunch of
Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
WARNING: provide conflict for #{cljs_time.format cljs-time.format} provided by cljs_test/generated_test_suite.out/cljs_time/format.js and {"/cljs_time/format.cljs" #{cljs-time.format}}
Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
WARNING: provide conflict for #{cljs_time.predicates cljs-time.predicates} provided by cljs_test/generated_test_suite.out/cljs_time/predicates.js and {"/cljs_time/predicates.cljs" #{cljs-time.predicates}}
Jul 19, 2018 3:32:07 PM shadow.build.classpath invoke
INFO: filename violation for ns cljs.nodejs, got: cljs_test/generated_test_suite.out/cljs/nodejs.cljs expected: cljs/nodejs.cljs (or .cljc)
I've no idea what that generated_test_suite is, and I'm not using cljs-test myself. I tried googling and seems to point at boot-cljs-test... which is really odd. Any idea what's going on?
#2018-07-1912:35Hukkacljs-time seems to use that boot-cljs-test, but I don't see how it could be running#2018-07-1912:36HukkaHm. The compiled js dir has cljs_test.generated_test_suite.out.cljs.core.constants.js and cljs_test.generated_test_suite.out.cljs_time.internal.core.js#2018-07-1913:14HukkaWell, got that fixed by upgrading the cljs-time package. New one doesn't have the conflicting files. But I wonder why lein-cljsbuild never complained about that#2018-07-1914:49mitchelkuijpersWe just upgraded from shadow-cljs 2.4.7 to 2.4.22 and now it breaks on release with: ["scroll-into-view-if-needed" :default scroll-into-view-if-needed] it creates P4a["default"] but P4a contains:
ƒ (a,b){if(b===Object(b)&&0!==Object.keys(b).length&&
"function"===typeof b.behavior)return b.behavior((0,e.default)(a,b));b=!1===b?{block:"end",inline:"nearest"}:b===Object(b)&&0!==Object.keys(b).leng…
#2018-07-1916:21thheller@mitchelkuijpers odd. did you upgrade whatever npm package that is as well? maybe they changed the export?#2018-07-2007:07mitchelkuijpersThe problem was that our build server had npm install --no-package-lock but that did not only not create a new package-lock.json but it would also ignore it... Now we updated node and changed the command to npm ci and life is great again ^^#2018-07-1916:22thheller@p-himik I always use lists for :refer. personal preference I guess. CLJ(S) don't care, both are equally valid#2018-07-1916:23thheller@tomi.hukkalainen_slac that looks like some generated code is on the classpath, try shadow-cljs clj-repl and then ( "cljs_test/generated_test_suite.out/cljs_time/format.js")#2018-07-1916:23thhellerthat should tell you where its coming from#2018-07-1918:41Hukka@thheller It was, yes, and was fixed in a new release of the lib. But I was surprised that the old cljsbuild based system didn't tell me about that#2018-07-1918:41HukkaIs shadow using the clojurescript compiler, or is it completely separate and the common point is the closure compiler?#2018-07-1919:20thheller@tomi.hukkalainen_slac shadow-cljs indexes the classpath and is a bit overeager in some cases. its is the standard clojurescript compiler but the way things are resolved is a bit different, to make the custom JS resolvers possible etc.#2018-07-1919:23HukkaWould be great to read a guide that opens the hood and shows different parts of the engine#2018-07-1919:23HukkaBut no doubt there's plenty of other things to do too...#2018-07-1919:24thhelleryeah it takes forever to write and I never know where to start. I tried starting a blog series about the differences https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2018-07-1919:25thhellerwill probably continue that when I have some more time#2018-07-1919:28HukkaDoes anyone else know the innards well enough, and could be prodded?#2018-07-1919:29thhellerof shadow-cljs? probably no#2018-07-1919:30HukkaDo you have stats from npm or clojars on how widely used it is?#2018-07-1919:30Hukka(I have no idea if those services collect any data like that)#2018-07-1919:31thhellerboth seem widely unreliable#2018-07-1919:31thhellerhttps://clojars.org/thheller/shadow-cljs#2018-07-1919:31thhellerhttps://www.npmjs.com/package/shadow-cljs#2018-07-1919:32thhellerbut its growing steadily#2018-07-1919:33HukkaI suppose it is quite difficult to convert those into distinct users, as someone might be using a cached version for a year, never updating, and someone else might have a clean CI build after every line (committed separately)#2018-07-1919:35thhelleryeah I don't care much about those numbers. new people keep ending up here and thats a good enough metric for me.#2018-07-1920:10HukkaUgh. The experience of starting a dev mode with material-ui is... bad. It's downloading many small files, so it takes over a minute to get all of those#2018-07-1920:11HukkaI'm afraid it's also a transient dependency, so there's not much I can do from within my own code#2018-07-1920:17thhelleryeah I have been thinking about grouping all files from one lib into one file#2018-07-1920:18HukkaAnd it looks like leaflet is somehow broken 😞 The map tiles are really wonky. No errors, though#2018-07-1920:18HukkaMight have to try to make a minimal example without any plugins, since the project uses several and the new imports might play havoc#2018-07-1920:19thhellerIIRC leaflet was leaking some globals which were creating issues#2018-07-1920:19HukkaLeaflet and its plugins are far from the best behaving modules in npm, instead relying on global vars even though they export themselves in name#2018-07-1920:19HukkaNot only leaking, but designed to do it...#2018-07-1920:21HukkaBefore I was just loading the dist files in the meta section, and then referring them via js/L#2018-07-1920:22HukkaTomorrow, then#2018-07-1920:23Hukka@thheller Bundling per package/import would be great#2018-07-1920:24HukkaI didn't count, but there are hundreds, if not thousands of tiny files inside material-ui#2018-07-1920:24HukkaEvery material icon, for example#2018-07-1920:24thhelleryeah gotta figure out the best way to deal with source maps first#2018-07-1920:24thhelleryeah some js libs are absolute an absolute nightmare#2018-07-1920:24thhellerI think antd has something like 900 files as well#2018-07-1920:25HukkaIs there a workaround? Perhaps refer directly to the dist file, if the npm lib has that?#2018-07-1920:25thhellerI looked at this recently since I want to build something similar for shadow-cljs#2018-07-1920:25thhellerhttps://github.com/joshwcomeau/guppy#2018-07-1920:25thhellerI don't get this pattern#2018-07-1920:26thhellerhttps://github.com/joshwcomeau/guppy/blob/master/src/components/AddDependencySearchBox/index.js#2018-07-1920:26thhellerhundreds of these index.js files that just re-export#2018-07-1920:26thhelleryeah you can load the dist file directly but that includes everything again. you really want to only include the components you actually use#2018-07-1920:27HukkaSeems like the @material-ui/icons has so many files that unpkg times out showing the contents >_<#2018-07-1920:27thhelleryeah its a bit crazy#2018-07-1920:28HukkaI know I do, and I'll try tomorrow if it makes a difference. I'm hoping my fingers crossed that the other packages I'd like to use don't just import the whole iconry wholesale#2018-07-1920:30HukkaOh well, it was just four files. Trying it now, though it's soon midnight#2018-07-1920:30thhellerif you can only (:require ["@material-ui/icons/Add" ...]) instead of @material-ui/icons and then icons/Add#2018-07-1920:31thhellerif you include the icons index it'll pull in every single icon and not a single one will be removed by DCE#2018-07-1920:32thhellerthe whole library is really really bad IMHO. its just one mess after the other.#2018-07-1920:34HukkaOh, $Deity, yes, the mui addons I have refer to single icons too#2018-07-1920:34HukkaI guess they rely on the DCE that does work pretty well in the webpack world#2018-07-1920:35HukkaAnd if they did bundle them into bigger files, I suppose it would be even harder to use just a few#2018-07-1923:11richiardiandreahello folks, is there a switch or a closure define to detect if I am in watch/repl mode in shadow?#2018-07-1923:11richiardiandreaI want to avoid executing the -main with target :node-script#2018-07-1923:12richiardiandreawhich happens when I watch and then launch node my-script#2018-07-2007:09Hukka@richiardiandrea I've had to inject an env param on clj side, but haven't had to work on that on cljs side. Have you checked what is inside the environ? If nothing, perhaps there's a param to put something in there depending on which profile you are running#2018-07-2007:31thheller@richiardiandrea no there is no built-in closure define for that. why do you want a :node-script without a :main though? wouldn't the generic node-repl work then?#2018-07-2007:39HukkaDoes shadow do something different with macros? I'm getting "undeclared Var" for using JS module from inside a macro, though the actual use is in #?(:cljs)#2018-07-2007:41Hukka
26 | #?(:cljs (deficon postilaatikko "0 0 46 54"))
----------------^---------------------------------------------------------------
 Use of undeclared Var reititin.icons/SvgIcon
#2018-07-2007:42thhellertry ~'SvgIcon otherwise the unquote willl qualify the symbol#2018-07-2007:43thhellerand the clojure side can't see the SvgIcon#2018-07-2007:45thhellerto answer your question though: no, shadow-cljs does not do something different with macros#2018-07-2007:45HukkaHey, awesome, thanks! No idea how that worked before, again#2018-07-2007:45HukkaThough then I did use mui/SvgIcon instead, since cljsjs used a big bundle anyway 🤔#2018-07-2007:45thhellerwait it did work in standard CLJS?#2018-07-2007:45thhellerah right#2018-07-2007:46HukkaBut using the symbol name with ns qualifier shouldn't matter, right?#2018-07-2007:46thhelleryou mean js/MaterialUI...?#2018-07-2007:47HukkaNo, just mui/SvgIcon, not going through js globals#2018-07-2007:47thhellerif a symbol is with a namespace the macroexpand will leave it alone. if its without symbol the unquote will try to qualify it#2018-07-2007:47Hukkarequiring from "material-ui" :as mui, which cljsjs provides#2018-07-2007:47thhellerhmm what was mui?#2018-07-2007:47HukkaBut ok, that explains. I hadn't realized the namespace affects macroexpand#2018-07-2009:27Hukka@thheller What would be the recommended way to load css files in npm modules, what in webpack world would be handled by the file loaders?#2018-07-2009:28thhellercurrently thats not supported. I have a few plans for that but didn't have time to work on it#2018-07-2009:29HukkaAh 😞#2018-07-2009:30thhellerI currently just copy the styles out manually with a script#2018-07-2009:31thhelleror copy by hand since most of the time the css isn't even linked from the JS#2018-07-2009:31thhellerie. codemirror or react-table. they just contain css files in the npm module but don't refer to them from the JS#2018-07-2009:32thhellerits a webpack-only thing to refer to css files from JS files and I hope it doesn't become more widespread#2018-07-2009:34HukkaYes, it would make more sense to use the style field in package.json#2018-07-2009:35HukkaLeaflet does that, though, so it could be read from there#2018-07-2009:36HukkaI suppose so that if anything requires the module, then the style is injected into head first#2018-07-2009:37HukkaIn any case, that was the last missing piece. I just downloaded the css as a static file into the project, which is a bit ugly. Have to remember to update it, if I ever update leaflet. But... things work now!#2018-07-2009:37thhellerextracting the require("./thing.css") is easy enough as they are already filtered out#2018-07-2009:37thhellerkeeping them somewhere to process later would be easy#2018-07-2009:38HukkaI'm not sure if leaflet requires the css anywhere, didn't check#2018-07-2009:38thhelleryeah but if its referenced in package.json is equally easy to extract#2018-07-2009:38HukkaYeah#2018-07-2009:39HukkaHow hard you think that might be, if/when I'd delved into shadow-cljs?#2018-07-2009:39thhellerjust copying some css is super easy. the problem comes when you need to process scss or @import "./another-file.scss"#2018-07-2009:39thhellernot hard at all. you can do it all via build hooks. https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-07-2009:40HukkaHm, so this wouldn't even require modifying shadow-cljs, and could be done via pure config?#2018-07-2009:40thhellerdoing it performant without repeating all the work constantly in watch is a bit more complicated though#2018-07-2009:40HukkaAh#2018-07-2009:41thhellerno modifications to shadow-cljs are required. all the build data is available in the build hooks. you just extract what you need.#2018-07-2009:43thhellergranted that basically nothing of the build data is documented and finding the right thing to extract might be difficult#2018-07-2009:44HukkaSomehow I have the habit of always ending up on the rocky paths, so to speak, when it comes to Clojure#2018-07-2009:45HukkaA coworker keeps getting amazed at it, always talking how his experiences have been so smooth#2018-07-2009:45thhellerwell its rocky if you expect things to work like webpack. Clojure isn't like webpack or npm#2018-07-2009:46thhellerand my past experiences with either npm or webpack have been far from smooth. quite the opposite actually.#2018-07-2009:46HukkaThis is a rather more common than just working node modules, or even clojurescript in general.#2018-07-2009:47HukkaIt took me less than a month to end up looking at clojure source itself to figure out what's happening in a rare case#2018-07-2009:51HukkaDo you think documenting an example build-hook would be a good solution, or would it be better still to do some changes into shadow-cljs that would handle it automatically, when it sees a package.json with "style"?#2018-07-2009:52thhelleras I said: I do have plans for a built-in solution but that will take some time. currently too busy with other stuff.#2018-07-2009:52thhellermaybe next month#2018-07-2009:53thhellerI think that a build-hook would be useful too though and it will be impossible to cover every single scenario#2018-07-2009:54thhellerI never saw a style field in package.json for example#2018-07-2009:54thhellerso it might be only leaflet doing something like that#2018-07-2009:55HukkaSorry, didn't mean that you should reprioritize, but I was wondering if this is something I might be able to do#2018-07-2009:56HukkaAnd if it would be more worthwhile than solving it via the build hooks#2018-07-2009:57thhellerwhat exactly do you want to do? build-hooks may be one solution but you might not even need those#2018-07-2009:58HukkaNot sure if it's exactly common, but for example bootstrap and normalize.css do it do#2018-07-2009:59HukkaIf you think it makes sense for shadow-cljs to automatically inject the css files for modules it sees having that in package.json, without any extra config, I could try to implement that#2018-07-2010:00thhellerinject where?#2018-07-2010:00HukkaYou said you had plans or ideas already, so if with those I wouldn't even need the build-hooks, maybe I could just as well help solve this for everyone#2018-07-2010:00thhellerplans for extracting the data and making it available to other tools (such as build hooks)#2018-07-2010:03thheller
(ns demo.hooks
  (:require [shadow.build.data :as data]
            [shadow.build.npm :as npm]))

(defn dummy
  {:shadow.build/stage :flush}
  [{:keys [npm] :as state} & args]
  (let [used-npm-modules
        (->> (data/get-build-sources state)
             (map :package-name)
             (remove nil?)
             (into #{}))
        
        styles
        (->> used-npm-modules
             (map #(npm/find-package npm %))
             (map :package-json)
             (filter #(get % "style"))
             (into []))]

    (prn [:styles styles])
    (prn [::flush args used-npm-modules]))
  state)
#2018-07-2010:03thheller
:build-hooks
   [(demo.hooks/dummy 1 2 3)]
#2018-07-2010:04thhellerthis will find all the npm packages that were used in the build and give you the package.json data to work with#2018-07-2010:04thhellerfrom there you can extract the style and post-process it however you want#2018-07-2010:05thhellerits just a dummy test hook I had but maybe that can help you get started#2018-07-2010:09HukkaCertainly will. Can build-hooks work on closure defines, or have some other way to communicate to CLJS/JS code that "here's the list of CSS files you should inject before doing anything else"?#2018-07-2010:11thhellerdefine what you mean by inject? inject where? and what?#2018-07-2010:13HukkaInject into <head>, either the links to the static CSS files copied to the output dir, or as <style> tags inlining the CSS#2018-07-2010:14thhelleryou could copy the css files to the output dir yes. how that ends up in the HTML is up to you#2018-07-2010:14HukkaOf course the best (perhaps the "right") way to do it would only trigger when any code actually requiring the given npm lib is loaded, so that big CSS files are not downloaded without actual need#2018-07-2010:14thhellerthe above snippet only include npm modules that where actually required#2018-07-2010:15HukkaYes, I'm trying to figure out if the build-hooks have a way to set some environment where the other part could pick it up, for example some code in the main cljs code#2018-07-2010:15thhellerif you write the CLJS code to inject something I can tell you how to get the data there#2018-07-2010:15HukkaMm, I'll try to rephrase that... if using code splitting, only at the point the relevant parts are loaded#2018-07-2010:15thhellerif you code split the above code is only a tiny bit more complicated#2018-07-2010:16thhellerjust have to work through :build-modules instead of :build-sources. :build-modules is a vector of maps. each will have a :sources key which lists all the sources included in that module#2018-07-2010:17thhellerbut right now I don't understand how you are planning to inject the CSS files via CLJS#2018-07-2010:17thhellerwebpack commonly writes a HTML file directly and does not inject the styles via JS#2018-07-2010:17thhellerso I wouldn't inject the styles via JS either since thats just going to be slow#2018-07-2010:19HukkaI was thinking that the CSS files are static, but the tag to load them would be loaded just in time for the code that needs it. Or alternatively I was really thinking about inlining the whole thing, as I think JSS does it.#2018-07-2010:20HukkaSo when the cljs requiring leaflet is loaded, <link href="vendor/leaflet/leaflet.css" rel="stylesheet" type="text/css"> is added to head just before#2018-07-2010:20HukkaOr whatever the url is#2018-07-2010:20thhelleryeah but you first have to load the JS, parse it, execute it, then that adds the css which the browser then downloads etc#2018-07-2010:21thhellerthats a gazillion times slower than having the browser download it in parallel with your JS#2018-07-2010:21thhellerso really the css should be included via your HTML statically#2018-07-2010:24HukkaIf it's inlined in the JS, it's downloaded at the same time as the code#2018-07-2010:24thhellerbut you still have to wait for parse&execute#2018-07-2010:24HukkaBut yes, code splitting + static CSS files would add roundtrips#2018-07-2010:24thhellerplus caching will suck because you invalidate more#2018-07-2010:26HukkaI still wouldn't want to add it manually, even if it's in the static index.html. So, you'd say that serving the html via template, or building it via template into a static file would make more sense?#2018-07-2010:26thhellerwhat I would do it extract all the referenced styles and then per module create a corresponding .css file. so for :modules {:main {:entries ...}} which creates a main.js I would create a main.css and include that statically via the HTML when including the main.js#2018-07-2010:27thhellerrewriting a .html file is equally trivial#2018-07-2010:28thhellerbut it all completely depends on what you are building. your requirements might be different.#2018-07-2010:31HukkaCaching isn't that important at this point for the CSS files, so bundling into a single main.css could work. @imports in the main.css would add roundtrips as well, so I don't think I'd go that route. But might as well build the html file when building the js bundle, so that it would include all the separate css files too.#2018-07-2010:31thhellerI would try to resolve the imports and so that you only have one css file per module#2018-07-2010:35thhellerin my work projects I use a very simple node-sass setup which has been good enough for me for years#2018-07-2010:38HukkaThanks for your input and help. I'll save these snippets and the discussion, and I'll get back to you after I've worked on a good enough start for the tutorial to get some feedback on, and include the build-hook there too.#2018-07-2011:03HukkaBefore: cljsjs, muiv0 – 4MB. Now: shadow and npm es modules, muiv1 – 1MB#2018-07-2012:32thhellersmall improvement 😉#2018-07-2016:41plamenHello all again - I have another question (I don’t know if there is a short answer or not): I came to shadow-cljs because of the need to convert an older Vaadin based application part of which I would like to reimplement in ClojureScript, but still using at least one Vaadin grid component from their JS/React based framework which because of that would theoretically be usable from ClojureScript. The part which I don’t know is (by lack of enough experience in later years around all facets of JS and its build processes/frameworks) if it is possible to use it through shadow-cljs (or vanila cljs) while it is delivered under a NPM (as a wrapper) and (the actual build recipe) Bower build. I understand that the problem has several steps in the doability (can Closure process it, if not, how does it present its namespaces to Closure/cljs/shadow-cljs, is that understood from the build chain, the Bower config is not a single module description, but a bunch of dozens smaller components from the framework and related js libraries, is there a single js file produced at the end of Bower which can be accessed from cljs/Closure etc etc.) If anyone can shed some light into it I would be thankful.#2018-07-2018:32HukkaWell it probably doesn't make any sense to somehow try to build the library component with shadow. But there's no need, also. As it works as npm module, it should work just fine.#2018-07-2018:33HukkaUnless there are some "interesting" output formats where a npm lib is supposed to only work with other bower projects, and not offering a built ES, commonjs, AMD, or UMD module. Or just a var in global scope#2018-07-2019:35thheller@plamen I'm gonna need more details about the build setup otherwise I can't make any suggestions. I don't know Vaadin or how bower is involved. If everything is normal JS it should be easy to consume but looking at the demo application it seems to construct everything together from HTML files, eg. https://github.com/vaadin/expense-manager-demo/blob/master/src/content-panel.html#2018-07-2019:35thhellerif bower produces commonjs out of that its easy#2018-07-2019:35thhellerbut I don't know#2018-07-2019:36thhellerclosure has some built-in support for polymer but I never used that so it might not work properly#2018-07-2023:03eoliphanthi, I’ve seen some notes around pulling in aws-sdk. Not sure if there’s a new issue or i’m doing something wrong ["aws-sdk" :refer [AWS]] or ["aws-sdk" :default AWS] are resulting in a null AWS#2018-07-2023:17eoliphantHi @plamen I’ve actualy done quite a bit of Vaadin development, but need a little more info. How old is the app? Prior to v10 they had both the legacy java/gwt stuff and then introduced the Polymer (not React) based ‘elements’ in the v8 timeframe as a separate sort of parallel option. That was a stepping stone to the new Flow architecture in v10 that basically unified all of that. The Polymer based stuff is ultimately just javascript so you could potentially use it from clojurescript, but I’ve not tried it myself. There was a clojure wrapper for the v7/8 java stuff, i’m not aware of anything for the client stuff. But it’s again, just javascript. One word of caution though. While clojure/script tends to make everything more wonderful, Vaadin’s (and Polymer’s) programming models are not functional/reactive, but object based, and even in Clojure(script) don’t feel nearly as nice as the react-based stuff in the clojurescript ecosystem. That Clojure wrapper for the java stuff, did reduce some of the cruft and ceremony, but you were still very much ‘programming objects’. There have been a couple libs, like RxVaadin, that tried to make it more FRP’ish, but those were also pretty clunky to implement.#2018-07-2100:28richiardiandreahas anybody ever seen:
goog.nodeGlobalRequire=function(path){return false};goog.provide("goog.debug.Error");goog.debug.Error=function(opt_msg){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var stack=(new Error).stack;if(stack)this.stack=stack}if(opt_msg)this.message=String(opt_msg);this.reportErrorToServer=true};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.provide("goog.dom.NodeType");goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.provide("goog.string");goog.provide("goog.string.Unicode");goog.define("goog.string.DETECT_DOUBLE_ESCAPING",false);goog.define("goog.string.FORCE_NON_DOM_HTML_UNESCAPING",false);goog.string.Unicode={NBSP:" "};goog.string.startsWith=function(str,prefix){return str.lastIndexOf(prefix,0)==0};goog.string.ends

TypeError: Cannot set property 'Error' of undefined
    at /home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:69:102
    at Object.<anonymous> (/home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:3038:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
#2018-07-2100:29richiardiandreathe target is :node-script#2018-07-2107:20thheller@richiardiandrea that might be :whitespace not being compatible with node.#2018-07-2108:10thheller@eoliphant it always helps to run a shadow-cljs browser-repl and then calling (require '["aws-sdk" :as x]) (js/console.dir x)#2018-07-2108:11thhellerif the object has a AWS property you want :refer. if it has a .default property you want :default. if it has no properties at all and is just a function you want :as#2018-07-2112:27eoliphantgotcha#2018-07-2112:27eoliphantthanks @thheller#2018-07-2117:27peteypeteI’m testing out shadow.cljs with a seemingly basic implementation of the npm package react-select. I’m using the code from here, which works fine with cljsjs. https://gist.github.com/pesterhazy/6c517653945f84a39c1ae3cc8b20c552. Shadow however, serves me up this error.
Uncaught Error: Assert failed: Expected React component in: [:> nil {:value nil, :options #js [#js {:value "a", :label "alpha"} #js {:value "b", :label "beta"} #js {:value "c", :label "gamma"}], :onChange #object[Function]}]
Any ideas?
#2018-07-2117:51p-himikjs/window.Select is not defined. Most likely, importing of cljsjs.react-select creates a global Select object but shadow-cljs does not. Instead of js/window.Select you want to use the stuff that you explicitly import.#2018-07-2117:52p-himikAlso, I always thought that such things must be wrapped in reagent.core/adapt-react-class. But maybe I'm wrong here.#2018-07-2117:55p-himikAh, :> handles that.#2018-07-2118:33peteypeteThanks @U2FRKM4TW. I got the Select element to render with :require ["react-select" :refer [Select]] Now on-click of the select item gives
Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development. See  for more information.
#2018-07-2121:22thhellerwhat do you do on click?#2018-07-2121:40peteypeteI attempt to access the dropdown selection list.#2018-07-2121:44thhellerand are you doing any cross origin stuff? ie. loading the JS from a different domain or such?#2018-07-2121:49peteypeteI used Jacekschaes template#2018-07-2121:50peteypetehttps://github.com/jacekschae/shadow-reagent#2018-07-2121:50thhellerso you are using ?#2018-07-2121:51peteypeteI moved it to 3010 because I had another project running.#2018-07-2121:54peteypetebut yes, error still exists running on :3000#2018-07-2122:01thhellerport itself doesn't matter. was just checking if you use the built-in server or something else#2018-07-2122:03thhellerI just checked the package#2018-07-2122:04thhellerthis is not actually valid :require ["react-select" :refer [Select]]#2018-07-2122:04thhellershould be :require ["react-select" :default Select]#2018-07-2122:11peteypetecorrected but same error#2018-07-2122:12thhellerare you sure you are using things correctly? the :refer [Select] shouldn't have worked at all#2018-07-2122:13peteypeteI am a nOOb but it did render the Select element on the DOM#2018-07-2122:13thhellerand what exactly are you doing in the onclick?#2018-07-2122:19peteypetethe dropdown arrow on the select menu#2018-07-2202:04p-himik@U8KRRN70S He meant whether you do any requests or call something that does some requests.#2018-07-2122:19thhellerthat looks like something is writing to the DOM?#2018-07-2122:20peteypeteyes even with :refer [Select]#2018-07-2122:20thhellerplease post the code of you onChange#2018-07-2122:21thheller:refer [Select] is absolutely not valid and shouldn't even render anything#2018-07-2122:21peteypetek something wierd going on#2018-07-2122:22thheller
(ns app.views
  (:require
    [app.state :refer [app-state]]
    [app.events :refer [increment decrement]]
    ["react-select" :default Select]))

(defn header
  []
  [:div
   [:h1 "A template for reagent apps"]
   [:> Select {:onChange (fn [e]
                          (js/console.log "onChange" e))
               :options
               [{:value 1 :label "1"}
                {:value 2 :label "2"}]}]])
#2018-07-2122:22thhellerthis works fine#2018-07-2122:22peteypete
(ns app.views
  (:require [app.state :refer [app-state]]
            [app.events :refer [increment decrement]]
            [reagent.core :as r :refer [atom]]
            ["react-select" :default Select]
            ["prop-types" :refer [PropTypes]]))

(defonce value (r/atom nil))

(defn header
  []
  [:div
   [:h1 "A template for reagent apps"]])

(defn counter
  []
  [:div
   [:button.btn {:on-click #(decrement %)} "-"]
   [:button {:disabled true} (get @app-state :count)]
   [:button.btn {:on-click #(increment %)} "+"]])

(defn select-ui []
  [:> js/window.Select {:value @value
                        :options #js [#js {:value "a" :label "alpha"}
                                      #js {:value "b" :label "beta"}
                                      #js {:value "c" :label "gamma"}]
                        :onChange #(reset! value (aget % "value"))}])

(defn root-ui []
  [:div {:style {:width 400}}
   [:h3 "Select test"]
   [select-ui]])
#2018-07-2122:23thhellerjs/window.Select is not what you get from shadow-cljs. thats something else entirely. don't know where tthat is from#2018-07-2122:23thhellerits just [:> Select ...]#2018-07-2122:24thhellerif you have a script tag included otherwise you are not actually using the npm package#2018-07-2122:24peteypetesweet works. I’m learn alot.#2018-07-2122:25thhellerin general js/ is for accessing global variables which is very common in cljsjs packages but never required in shadow-cljs#2018-07-2122:25thhelleryou use directly what you require in your ns like any other CLJS namespace/refer#2018-07-2122:25peteypeteah yea I jammed a script in there to try and load another way#2018-07-2122:26peteypeteThanks @thheller. Shadow looking good. Moving onto trying ag-grid. Thanks again#2018-07-2122:28thhelleryou can follow the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-07-2122:29thhellerso import { AgGridReact } from 'ag-grid-react'; becomes (:require ["ag-grid-react" :refer (AgGridReact)])#2018-07-2122:29peteypeteexcellent reference#2018-07-2122:29thhellerthe css stuff is not yet supported#2018-07-2122:29thhellerso that needs to be done manually. everything else is though.#2018-07-2207:42flyboarder@thheller (:require ["@feathersjs/client" :as feathers]) this is returning nil, any idea why?#2018-07-2207:43thhellerthat has no return value. do you mean feathers is nil?#2018-07-2207:43flyboarderyes#2018-07-2207:43flyboarderI was previously using cljsjs, moving to shadow-cljs#2018-07-2207:44flyboardercompile happens sucessfully#2018-07-2207:46thhellerits not nil for me?#2018-07-2207:46thhellerusing shadow-cljs browser-repl and (require '["@feathersjs/client" :as x]) (prn x) I get #object[createApplication]#2018-07-2207:47thhellerie. x in this case is a function#2018-07-2207:49flyboarderok, I am removing node_modules and trying again#2018-07-2207:49flyboarderit detects the missing package and tells me to npm install @feathersjs/client#2018-07-2300:30flyboarder@thheller so after spending all night fixing errors that shadow warned all the builds compile, except that I am getting a new error on runtime: IllegalStateException: ASSIGN 2 [length: 45] [source_file: feathers/app.cljs] is not the parent of GETPROP 2 [length: 21] [originalname: feathers] [source_file: feathers/app.cljs]#2018-07-2302:20Josh HorwitzI was looking to use https://github.com/priornix/antizer to use Ant design CSS framekwork in my project, but I can’t seem to get it to work. I have the cljsjs/antd added to my shadow-cljs.edn but I’m getting the error ’cljsjs.antd` is not available.#2018-07-2303:30flyboarderLooks like I was able to solve the above with simple optimizations#2018-07-2305:06thheller@joshua.d.horwitz see https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs so you'd create a src/cljsjs/antd.cljs with
(ns cljsjs.antd
  (:require ["antd" :as antd]))

(js/goog.exportSymbol "antd" antd)
#2018-07-2305:08thheller@flyboarder can you share the feathers/app.cljs? maybe you are doing something you are not supposed to. never seen that error before though.#2018-07-2305:19thheller@flyboarder oh I do think I have seen this error before. are you maybe doing (def feathers feathers) or something similar? ie. assigning a variable to its own name?#2018-07-2314:28flyboarderThis is exactly what I am trying to do!#2018-07-2314:29flyboarderIt worked with boot-cljs without issues, but moving to the npm packages from cljsjs seems to complain#2018-07-2315:42thhellerwhy are doing that though? it doesn't do anything?#2018-07-2315:42thhellerI understand that you did need to do this with cljsjs to pull the global into the local scope but you no longer need that with shadow-cljs since there is no global to pull in#2018-07-2318:06flyboarder@thheller often what I am doing is directly exposing something from an npm lib via my own lib which then gives easy access to whatever was in npm, for whoever consumes my library#2018-07-2318:07flyboarderbut I guess if I wrap this in a function it will do the same thing#2018-07-2318:47thhellerits fine if you choose different names#2018-07-2318:47thhellerjust assigning the same name to itself actually assigns itself, ie. var x = x; so it ends up undefined#2018-07-2308:50thhellerhttps://twitter.com/thheller/status/1021316633334288384#2018-07-2308:50thhellerhttps://twitter.com/thheller/status/1021316633334288384#2018-07-2309:34mitchelkuijpersJust tried it out, this is very helpful for us. Because sometimes we need to work inside of an iframe with ngrok. Loading 1000's of files often takes a while 😛 It works for us with one module and fails for the other 4 modules we have. One fails with:
root.cljc:28 Uncaught TypeError: Cannot read property 'create_react_factory_STAR_' of undefined
    at eval (root.cljc:28)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at issue-linking-panel.js:1
#2018-07-2309:35mitchelkuijpersAnother one fails with:
main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
    at eval (main.cljs:28)
    at eval (main.cljs:50)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at page-linking-panel.js:3
But I have to say those two cannot connect to the shadow-cljs websocket because that runs on localhost, could that be related?
#2018-07-2309:37thhellerhmm are you calling eval in main.cljs or root.cljc? can you share whats happening in the reported lines?#2018-07-2309:56mitchelkuijpersHmm one is runnning: (def spinner (utils/create-react-factory "spinner/default")) which is a macro which does:
(defn create-react-factory* [clazz]
  #?(:clj (constantly nil)
     :cljs (createFactory clazz)))
#2018-07-2309:57mitchelkuijpersThe other one is failing on:
(ssr/get-SSR-initial-state)
which is from fulcro which reads transit from a script tag, so I can imagine it might be using eval
#2018-07-2309:58thhelleris there an earlier/later error related to the ssr namespace?#2018-07-2309:59thhellerit just seems like the namespace isn't created properly which can happen when an exception it thrown#2018-07-2309:59mitchelkuijpers
browser.cljs:321 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
browser.cljs:321 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
    at Object.shadow$cljs$devtools$client$browser$ws_connect [as ws_connect] (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:982:15)
    at eval (/js/modules/cljs-runtime/shadow.cljs.devtools.client.browser.js:1064:37)
    at eval (<anonymous>)
    at Object.goog.globalEval ()
    at Object.env.evalLoad ()
    at 
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:321
(anonymous) @ browser.cljs:379
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ shared.js:3320
main.cljs:28 Uncaught TypeError: Cannot read property 'get_SSR_initial_state' of undefined
    at eval (main.cljs:28)
    at eval (main.cljs:50)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:2188)
    at Object.env.evalLoad (shared.js:3042)
    at page-linking-panel.js:3
(anonymous) @ main.cljs:28
(anonymous) @ main.cljs:50
goog.globalEval @ shared.js:2188
env.evalLoad @ shared.js:3042
(anonymous) @ page-linking-panel.js:3

#2018-07-2309:59thhellersince that would currently abort loading all the things that come after#2018-07-2309:59mitchelkuijpersThese are all errors that it is trying to connect to shadow so maybe that makes the rest fail#2018-07-2310:00mitchelkuijpersBecause it works with one module which can correctly connect to shadow-cljs#2018-07-2310:00thhellerah ok yeah that makes sense#2018-07-2310:00thhellerthe devtools are loaded first via preload. that throws when loading and aborts loading the rest#2018-07-2310:01thhellertry setting :devtools {:enabled false}#2018-07-2310:01thhellerI will make the websocket detection more robust so it doesn't hard fail and breaks everything else#2018-07-2310:01thhellerwith the traditional loader this doesn't affect the overall loading since each file is eval'd individually#2018-07-2310:23thheller@mitchelkuijpers just pushed 2.4.24 which should handle this more gracefully#2018-07-2311:03mitchelkuijpersAwesome thank you @thheller#2018-07-2311:39Hukka@thheller @mitchelkuijpers I'll start a thread here, since this is a bit different. Earlier I prodded about the small files too. Then I started to work on jetty's http/2, which took a while since the adapter's h2 support was broken, and only today I managed to fix it. It didn't help squat. Jetty was using full 4 threads and page load was over a minute. Then I wondered if the problem wasn't jetty, but ring. Or compojure. So just last hour I tried changing resource serve from routes into wrap-resources. Now page load is 1.5 seconds#2018-07-2311:40Hukkahttp/2's effect now is neglible, at least with localhost latencies. Might still matter with some added latency, will try that later.#2018-07-2311:41HukkaEven browsing straight to /index.html which maps to the filesystem shaves about 100ms off the loading time#2018-07-2311:42HukkaFor comparison, my pageload is about 700 requests with dev mode on#2018-07-2311:46HukkaWith Chrome's fast 3G preset h2 is 55 seconds and http/1.1 85 seconds#2018-07-2311:46HukkaThat's without server push, which I won't bother setting up for now
#2018-07-2313:23HukkaI was barking the wrong tree completely. The problem is the authentication handler. It's checking the pw hundreds of times...#2018-07-2315:41thhellerFWIW shadow-cljs supports h2 automatically when you enable SSL#2018-07-2315:41thhellerbut yeah h2 doesn't help much on localhost#2018-07-2401:45lwhortondoes shadow support .zip files on the classpath? i’m trying to generative-test some really crappy node code from another cljs app. that node code is ultimately bundled into a zip file, and i’m just curious if i have to unzip the file before attempting to run shadow (or if my error is elsewhere)#2018-07-2402:34richiardiandreaI was wondering if there is an easy way to have :optimizations :none compilation mode but all in one unique file, concatenated. I have a requirement to leave things readable from a JS dev standpoint but I feel checking in :cache-root is not a clean approach.#2018-07-2405:22thheller@richiardiandrea define "readable". its not like the compiled CLJS code is easily understandable so what do you gain by "readable"?#2018-07-2414:19richiardiandreaI know, I think I need to make clear that is never going to be like reason or typescript compiled code...probably the goal is to debug things in the debugger and that's why the requirement is "readable" and one-file#2018-07-2414:30thhellerbut you have source maps for that? wouldn't you want to know the actual code being used?#2018-07-2414:35richiardiandreaI know well...I am trying to understand if it is possible to have an alternative, if not I will just say here that we are going to live with source maps only ;)#2018-07-2414:36thhelleryou can just do a :simple build with :compiler-options {:variable-renaming :off :property-renaming :off :pretty-print true} that should be as close to readable as possible#2018-07-2414:36thhellerbut I really don't know what you'd gain from having that#2018-07-2414:37richiardiandreaI don't know either, I will try to explain that too but thanks for having an answer ready for me ;)#2018-07-2405:24thhellerthe "cache" is also not useful for humans to consume as its transit encoded data#2018-07-2405:28thheller@lwhorton .jar files are basically zip files and yes those are supported but you said "node code" so I'm assuming .js files? what kind of code are you talking about? https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath#2018-07-2418:09lwhortonit’s a typescript codebase, but i’m transforming the ts -> js and then adding build/the-js-files/ as a src path. after some playing around I found a way to get everything up and running. the only wonky piece was the npm integration. if i have a parent dir /proj which contains /proj/the-node-code, compiling the node code and adding it to the proj/shadow-cljs.edn’s source files config works. however, it looks like the node_modules resolving can’t find the node code’s libraries unless I add them explicitly to /proj/node_modules. i’ve tried adding the proj/the-node-code/node_modules also to the source files, but the compiler still cant manage to resolve some import foo from 'some-lib' dependency in the node code.#2018-07-2418:12thhellerI can't really make out what you are saying. you either have classpath js or node_modules. they are handled entirely differently. if you have say src/js/some-folder/converted-from-ts.js and put src/js on the :source-paths you can require it via (:require ["/some-folder/converted-from-ts" :as x])#2018-07-2418:13thhellerthe converted file itself can import foo from 'some-lib' as usual assuming that some-lib is in node_modules?#2018-07-2418:13thhellerbasically all "paths" (ie. "/foo/bar" or "./foo" or "../foo") are assumed to be on the classpath#2018-07-2418:13thhellerotherwise node_modules is checked#2018-07-2418:14thhellerwhat is "can’t find the node code’s libraries"?#2018-07-2418:18lwhortonill see if i can be more clear: compile the node code into some /build folder. add that build folder to a parent project’s source files. from a test_runner.cljs file (in the parent), require a file from the /build project (something like ["/build/my-file/file" :as x]. the file can be found, because it doesn’t complain about resolving /build/my-file/file, but it does throw an error such as cannot import module 'momentjs' from /build/my-file/file.#2018-07-2418:18thhellerfirst mistake is the /src#2018-07-2418:19thhellerplease be very clear about the exact paths you are using. otherwise it just gets confusing as hell.#2018-07-2418:19lwhortonah yea, sorry… assume that’s supposed to be /build/my-file/file#2018-07-2418:19thhellerfirst specify your :source-paths#2018-07-2418:20thheller:source-paths ["src/cljs" "src/js"] I'd suggest#2018-07-2418:20thhelleryou generate the code into src/js/some-unique-enough-name/my-file/file.js#2018-07-2418:21thhelleryou MUST qualify names on the classpath otherwise they will clash#2018-07-2418:21lwhortoni will get back to you on this, i’m unfortunately knee-deep in another (unrelated) problem. thanks for the quick turnaround time, though#2018-07-2418:21thhellerinside your CLJS you then (:require ["/some-unique-enough-name/my-file/file.js" :as x])#2018-07-2418:21thhellerin the JS or TS however you only use relative paths#2018-07-2418:22thhellersince node handles absolutes paths differently#2018-07-2418:22thhellercannot import module 'momentjs' from /build/my-file/file who produces this error? its not a shadow-cljs error? is this a node build?#2018-07-2418:23lwhortongive me 2 mins let me context swap so i dont waste your time#2018-07-2418:31thhellerisn't the package called just moment? not momentjs?#2018-07-2418:33lwhortonokay, here’s the details:#2018-07-2415:52kozCan you set custom shadow-cljs configuration options based on the deps.edn alias that is passed in on startup via shadow-cljs -A (for instance, only load a preload or set a compiler option if a specific alias is passed)? If not, can you extend an existing build configuration?#2018-07-2415:53thhellerwhat kind of option do you want to pass?#2018-07-2415:54kozBasically, I want to opt-in to re-frame-10x in development since it’s slowing things down at times, so at the minimum, enable the re_frame.trace.trace_enabled_QMARK_ closure-define flag if an alias is passed to the dev build#2018-07-2415:56thhelleryou could use clj-run and build a function that uses shadow.cljs.devtools.api to do (shadow/get-build-config :foo) update that config map and then call (shadow/compile* modified-config {})#2018-07-2415:56thhellerthe cli has nothing to overriding built-in currently#2018-07-2415:56kozcool, i’ll look into that. yeah, this is probably an edge case. thanks @thheller#2018-07-2416:11justinlee@thheller new perf enhancements are quite nice. about a third faster on the initial load#2018-07-2419:47richiardiandreaso :node-test returns 0 even when tests are failing#2018-07-2419:48thhelleronly if you use :autorun. instead use compile and run node the-output.js. that will preserve the proper exit code#2018-07-2419:49thhellerie. do shadow-cljs compile the-test && node out/the-test.js#2018-07-2419:50richiardiandreaoh#2018-07-2419:50richiardiandreaok cool that should work#2018-07-2419:52richiardiandreais there an env var / switch to enable :autorun from the command line (it would be super handy)#2018-07-2419:52richiardiandreaactually, no#2018-07-2419:52richiardiandreawatch should be good enough if it runs the tests#2018-07-2419:53thhellerthere will probably be some kind of shadow-cljs node-test --ns-regexp foo#2018-07-2419:54thhellerso you don't need an actual config#2018-07-2419:54thhellerthen there could be a --autorun or --compile-only depending on which makes more sense#2018-07-2419:54richiardiandreathe goal would be to keep :autorun false in shadow-cljs.edn but be able to run tests in watch mode#2018-07-2419:54richiardiandreayeah#2018-07-2419:55thhelleryou could set :release {:autorun false} and then use shadow-cljs release the-tests. that way they wouldn't autorun#2018-07-2419:55richiardiandreaoh, nice#2018-07-2419:57richiardiandreauhm I am doing yarn shadow-cljs release :test && node .cljs-tests/cd-tests.js but I still have a zero exit code#2018-07-2419:57thhellerI blame the extra yarn#2018-07-2419:57thhellertry without that first#2018-07-2419:57richiardiandreawell, the && is after that#2018-07-2419:58thhellerwhat is the exit of just the node?#2018-07-2419:58richiardiandrea0#2018-07-2419:58thhellerand its :target :node-test?#2018-07-2419:58richiardiandrea
Ran 3 tests containing 7 assertions.
2 failures, 1 errors.
#2018-07-2419:58richiardiandreayeah#2018-07-2419:58richiardiandrea
{:target :node-test
                 :main cd.test-runner/-main
                 :autorun true
                 :release {:optimizations :simple
                           :variable-renaming :off
                           :property-renaming :off
                           :pretty-print true
                           :source-map true
                           :autorun false}
                 :output-to ".cljs-tests/cd-tests.js"}
#2018-07-2419:59richiardiandreamaybe the merge has a problem, let me get rid of :autorun true#2018-07-2419:59thhellerthats incorrect. missing a :compiler-options for anything but :autorun#2018-07-2419:59richiardiandreaoh man, sorry facepalm#2018-07-2419:59thhellerbut none of that would affect the exit code#2018-07-2420:00richiardiandreatrying:
{:target :node-test
                 :main cd.test-runner/-main
                 ;; :autorun true
                 :release {:compiler-options {:optimizations :simple
                                              :variable-renaming :off
                                              :property-renaming :off
                                              :pretty-print true
                                              :source-map true}
                           :autorun false}
                 :output-to ".cljs-tests/cd-tests.js"}
#2018-07-2420:00thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#L9-L11#2018-07-2420:00richiardiandreauhm, still zero#2018-07-2420:01thhellerwait. why is there is :main?#2018-07-2420:01richiardiandreaI see#2018-07-2420:01richiardiandreayeah let me get rid of that#2018-07-2420:01richiardiandreaI wanted to test only one namespace#2018-07-2420:01richiardiandreabut it is unnecessary#2018-07-2420:01thhellerthen set :ns-regexp "that.ns"#2018-07-2420:02thhellerugly hack but works for now#2018-07-2420:02richiardiandreayeah so removing the :main makes it work#2018-07-2420:03richiardiandreastill odd the reason why it does not do it though, I can open a low-prio issue if you like#2018-07-2420:03thhellerwell it won't include the main runner ns then#2018-07-2420:03thhellerso the defmethod isn't added which sets the exit code#2018-07-2420:03thheller:main is allowed in case you want to use other test frameworks and such#2018-07-2420:04thhellernothing odd about it. should probably just document it.#2018-07-2420:07richiardiandreaOk cool thanks for the support 😉 #2018-07-2420:09flyboarder@thheller We are building out a comprehensive collection of boot tasks for shadow-cljs#2018-07-2420:09flyboarderhttps://github.com/degree9/boot-shadow#2018-07-2420:09flyboarderfeedback from any boot users is appreciated#2018-07-2420:12thheller@flyboarder :cache-root is a global config option and cannot be set per build#2018-07-2420:20flyboarder@thheller thanks! cache disabled!#2018-07-2421:03gravIs it possible to set a closure define in the config edn from an environment variable?#2018-07-2421:09thheller@grav #shadow/env "THE_THING"#2018-07-2421:09gravSweet!#2018-07-2505:18bupkisWhat is the purpose of the socket REPL that's being also started? Is it currently used, or is it there in preparation for future use? I couldn't find anything in the guide, and I'm curious 🙂#2018-07-2505:51thheller@samuel.wagen you are free to use it. I sometimes use it when I get frustrated by some nrepl stuff.#2018-07-2506:13bupkis@thheller any idea how to get to the CLJS side from it? piggieback is nrepl only#2018-07-2506:14thheller@samuel.wagen shadow-cljs clj-repl uses the socket REPL. then (shadow/browser-repl) switches it to a CLJS browser repl. or (shadow/node-repl) or (shadow/repl :your-build)#2018-07-2507:09bupkisinteresting. I tried connecting to the socket repl from unrepl 's unravel#2018-07-2507:13bupkisoh of course. clj-repl does an implicit require. if I do (require '[shadow.cljs.devtools.api :as shadow]) then (shadow/repl :build-id) works and I get the cljs repl#2018-07-2507:14thhellerah right. yeah its the .api namespace#2018-07-2507:14thhellerclj-repl starts out in shadow.user#2018-07-2507:15thheller
(ns shadow.user
  (:require
    [clojure.repl :refer (source apropos dir pst doc find-doc)]
    [clojure.java.javadoc :refer (javadoc)]
    [clojure.pprint :refer (pp pprint)]
    [shadow.cljs.devtools.api :as shadow :refer (help)]))
#2018-07-2508:04bupkisyep, doing (in-ns 'shadow.user) and (shadow/repl :build-id) does the trick with unravel#2018-07-2509:28kwladykahttps://github.com/thheller/shadow-cljs/wiki#2018-07-2510:16kwladyka> Cursive does not currently support resolving dependencies via shadow-cljs.edn. You can run shadow-cljs pom to generate a pom.xml and import that using the IntelliJ. How exactly? Curisve still doesn’t recognise detest#2018-07-2511:08thheller@kwladyka you call shadow-cljs pom and then in cursive file -> new -> project from existing sources and select the pom.xml#2018-07-2511:10kwladykaoh in that way. It doesn’t sound like good solution considering dependencies changing, so each time I will have to start new project.#2018-07-2511:10thhelleryou don't#2018-07-2511:10kwladykabut I know there is alternative 🙂#2018-07-2511:10thhellerjust call shadow-cljs pom again and cursive will automatically update the changed pom.xml#2018-07-2511:10thhelleror ask first .. depends on the setting you have there#2018-07-2511:10thhellerbut you only need to create the project once#2018-07-2511:13thhellerweird#2018-07-2511:14thhellercheck if the file is actually generated properly?#2018-07-2511:15kwladykahow?#2018-07-2511:15thhellersome text editor#2018-07-2511:16thhellerah .. nvm its not pretty printed so its tough to tell if it actually contains something#2018-07-2511:16thhellerI guess check if it looks like xml#2018-07-2511:17kwladykait looks ok#2018-07-2511:17thhellerand you did project from existing sources not module from existing sources?#2018-07-2511:18kwladykayes#2018-07-2511:18thhellerthen I don't know. can you post the pom.xml so I can look at it? just tested it on a dummy project and it worked fine.#2018-07-2511:21thhellerthat imported completely fine for me?#2018-07-2511:21thhellersame intellij version#2018-07-2511:21kwladykaI have no idea why#2018-07-2511:22kwladykaor maybe… I have 1 to check#2018-07-2511:25kwladykahaha it is funny, but: > @kwladyka you call shadow-cljs pom and then in cursive file -> new -> project from existing sources and select the pom.xml I was selecting pom.xml file. As I see right way is to choose directory contain pom.xml file, not select file directly.#2018-07-2511:26thhellerI selected the pom.xml every time never the directory#2018-07-2511:27kwladykahmm so maybe it doesn’t work with select directory#2018-07-2511:27thhellerwhere is the source file?#2018-07-2511:28thhellerwait what is the problem?#2018-07-2511:29kwladykaBTW do you recommend solution with pom.xml for cursive or another one? 🙂#2018-07-2511:29thhellerI do recommend that yes#2018-07-2511:29thhellerI use it myself#2018-07-2511:29thhellerbut what is the actual problem you have?#2018-07-2511:30kwladykawith cmd+down I can jump to the source etc.#2018-07-2511:30kwladykaBut with shadow-cljs and Cursive I can’t do both#2018-07-2511:31thhellerso your problem is that deftest isn't indented correctly?#2018-07-2511:31thhelleror what do you mean by "recognise deftest"?#2018-07-2511:32kwladykayes, but it is deeper issue. It is not indent correctly, because Cursive doesn’t see this dependency.#2018-07-2511:32thhellerdidn't you just say that you can navigate to the source?#2018-07-2511:33kwladykanormally I can press cmd+down and it will open source code of deftest. With shadow-cljs I can’t so my assumption Cursive can’t find that dependency#2018-07-2511:33thhellerah you mean you can't#2018-07-2511:33kwladykasorry if it wasn’t clear#2018-07-2511:33thhellerI don't know. It all works completely fine for me#2018-07-2511:34kwladykaBut I opened this project by select directory, not pom.xml. It doesn’t work for me as I mentioned before.#2018-07-2511:34kwladykaI have really no idea why.#2018-07-2511:36kwladykaI just tried it with empty folder with only this pom.xml. The same issue.#2018-07-2511:37thhellerI don't know what to tell you. I click new -> project -> project from existing sources then select the actual generated pom.xml file. accept a couple times and nothing else#2018-07-2511:37thhellerit works fine with the file you just posted and creating the test/boilerplate/example_test.cljs#2018-07-2511:38kwladykaWhen you select folder instead of a file does it work the same for you or there is a difference?#2018-07-2511:39thhelleryou can try cloning this repo https://github.com/shadow-cljs/quickstart-browser and trying it there#2018-07-2511:40thhellerit doesn't do anything when I select the directory#2018-07-2511:40thhellerjust closes the dialog#2018-07-2511:41kwladykahmm when I select directory I have this:#2018-07-2511:41thhellerhmm that seems to be missing the maven option?#2018-07-2511:42thhellerI thought the maven integration was built-in but maybe its a plugin? or disabled for some reason?#2018-07-2511:42kwladykahmm doest it mean it is because i don’t have “maeven integration” installed?#2018-07-2511:43thhellerI have no idea. maybe?#2018-07-2511:43kwladykaoh so we probable solved it#2018-07-2511:43thhellerI didn't install or mess with any other plugin besides cursive#2018-07-2511:44kwladykanow I have different dialogs#2018-07-2511:44thhellerno, leave all the defaults#2018-07-2511:44thhellerjust click next till its done#2018-07-2511:45kwladykaoh yeah it works!#2018-07-2511:45kwladykayou are the boss 🍻#2018-07-2511:46kwladykait is time for take a break and eat dinner 🙂#2018-07-2511:46kwladykathank you#2018-07-2511:46thhellerso the maven integration was just missing?#2018-07-2511:46kwladykayes#2018-07-2511:46kwladykaI didn’t install it#2018-07-2511:46thhellerhmm good to know for future reference#2018-07-2511:47kwladykaI went to the plugin list and checked maven integration, restart Intellij and it works#2018-07-2513:48wilkerlucio@kwladyka if you can, another good option is to use deps.edn to manage dependencies, Cursive is supporting those already in the latest versions#2018-07-2516:20royalaid@wilkerlucio It is important to point out that there are some caveats and that support is alpha quality AFAIK#2018-07-2516:23thhellerFWIW pom.xml is the most stable and well supported option and we really only need to tell cursive about the deps and source paths#2018-07-2516:41lilactownI'm running into an issue using module splitting + shadow-cljs 2.4.24#2018-07-2516:42lilactown(recently updated from 2.3.x)#2018-07-2516:43lilactownwhen I run in dev mode, everything works as expected. however when I do a release build, I get an error when the bundle runs#2018-07-2516:44lilactown
Uncaught TypeError: P.l is not a function
    at main.js:1246
#2018-07-2516:44lilactownthis is my shadow-cljs.edn config for this build:
:dashboard
          {:target :browser
           ;; :module-loader true
           :modules
           {:main {:entries [cambia.web.experience.dashboard.client.core]}
            :icon-row {:entries [cambia.web.experience.dashboard.components.icon-row.client]
                       :depends-on #{:main}}
            }
           :compiler-options {:infer-externs :auto}
           :output-dir "public/dashboard/assets/app/js"
           :asset-path "assets/app/js/"
           :devtools
           {:after-load cambia.web.experience.dashboard.client.core/start-dev}}
#2018-07-2516:45lilactowncommenting out the :icon-row module gets rid of the error#2018-07-2516:45thheller@lilactown add :compiler-options {:infer-externs :auto}#2018-07-2516:45lilactownit's present#2018-07-2516:45thhellerhehe oh right#2018-07-2516:45thhellerno warnings?#2018-07-2516:45lilactown😄#2018-07-2516:45lilactownonly one in a completely unrelated file:
[:dashboard] Compiling ...
------ WARNING #1 --------------------------------------------------------------
 File: cambia/web/experience/dashboard/components/hsa/client.cljs:3:10

 variable $ is undeclared
--------------------------------------------------------------------------------

nil
#2018-07-2516:45lilactownhaven't investigated yet#2018-07-2516:46thhellerprbably not unrelated#2018-07-2516:46thhellertry running with shadow-cljs release dashboard --pseudo-names and do whatever to trigger the error#2018-07-2516:47thhellerit'll give you a more readable hint at the error location#2018-07-2516:47lilactownkk#2018-07-2516:47thhellerit might also be a global variable conflict#2018-07-2516:48thhellerif the error goes away with --pseudo-names thats most likely the issue#2018-07-2516:48lilactown...it did 😅#2018-07-2516:48lilactowntesting it again without pseudo-names just to be sure#2018-07-2516:49thhelleryou can try adding :compiler-options {:output-wrapper true} or find out how the global P is defined and what it is#2018-07-2516:49lilactownyep, removing pseudo-names triggers the error#2018-07-2516:50thheller:output-wrapper isn't great when using modules so you should rather find out where that clashing global is coming from#2018-07-2516:50thhelleryou can then add externs for it so closure doesn't use that variable#2018-07-2516:51thhellerjust type P in the browser console and see if the object provides any clues#2018-07-2516:51lilactown:output-wrapper did fix it. what are the concerns with modules?#2018-07-2516:52thhelleroutput gets larger. not super important since gzip takes care of most of it#2018-07-2516:52thhellerstill .. fixing it the other way isn't much harder either#2018-07-2516:52lilactownI see#2018-07-2516:53justinleeis there no way to dump a map from munged names to original names?#2018-07-2516:53lilactownnot really complaining but I did notice that going from 2.3.x => 2.4.24 that my release bundle got bigger by about 4x (224kb to 804kb)#2018-07-2516:53thhellersource maps do that#2018-07-2516:54lilactown
> P
ƒ Promise() { [native code] }
🤔 not very illuminating
#2018-07-2516:54thhellerwhat? thats not normal#2018-07-2516:54thhelleryou can compile with shadow-cljs release dashboard --source-maps#2018-07-2516:55thhellerwait nevermind that won't tell you where P comes from#2018-07-2516:55thhellerdo you have the P defined in the page when you remove the script tag for your JS code?#2018-07-2516:55thhelleror asked another way: are there any other script tags in the page besides your CLJS code?#2018-07-2516:56lilactownthere are, I'll try that out#2018-07-2516:56thhellergoing from 2.3 to 2.4 should definitely not make your build larger though#2018-07-2516:56thhellerand certainly not by that amount#2018-07-2516:57thhellergenerate a build report and see where all the bytes come from: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2018-07-2516:57lilactownhmm. with sourcemaps on, the error takes me to mount.core#2018-07-2516:57lilactown:+1: will do once I figure this out#2018-07-2516:58thhelleryeah nevermind that. its a confusing error since closure thinks it created the P variable and points you to the location where it created it#2018-07-2516:58thhellerbut its var was replaced by something else#2018-07-2516:58thhellersome npm deps forcefully create some globals and can cause these issues#2018-07-2516:59thhellerI think leaflet always creates window.L#2018-07-2516:59thheller:output-wrapper guards you against such things but makes the build larger by 5% or so#2018-07-2516:59thhellerbut nowhere near 4x#2018-07-2516:59lilactowncould be one of the polyfills or analytics scripts that I have to use 🙄#2018-07-2517:00lilactownI'm okay with a 5% increase if I (or my team, who has no idea how to debug this stuff :P) don't need to worry about this#2018-07-2517:00thhellerwell you know thats its P so the simple fix is to create externs/dashboard.txt with one line global:P and done#2018-07-2517:00thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2018-07-2517:00thhellerbut yeah :output-wrapper is generally safer. you can always optimize that away later.#2018-07-2517:13lilactownis the "Optimized" size in the build report the gzipped size or real size?#2018-07-2517:14thhellerreal size#2018-07-2517:16lilactownI don't see anything super offensive - it looks like clojure.core is the largest offender#2018-07-2517:16lilactowngenerating a build report from the 2.3.x branch for comparison now#2018-07-2517:16lilactownah hm, the incantation isn't there#2018-07-2517:16thhellernot sure in which version I added the build reports though#2018-07-2517:17thhellerhow large is cljs.core?#2018-07-2517:17lilactown184.63kb#2018-07-2517:17thhellerthats about normal and would have been the same in 2.3#2018-07-2517:20thhellerbut that also gzips down to like 30kb so its no biggy#2018-07-2517:23lilactownhmm. nevermind#2018-07-2517:24lilactownon the 2.3 branch I'm seeing about the same when I run the release build locally - 800kb#2018-07-2517:24thhellerwhere are the other 616kb though?#2018-07-2517:25thhellerprobably mostly npm deps?#2018-07-2517:25lilactownyeah#2018-07-2517:25lilactownthere's another 100kb from clojure.pprint that I could probably get rid of#2018-07-2517:26lilactownthen 90kb for react-dom, 70kb from bluebird and google-closure-library...#2018-07-2517:27lilactownI was comparing it to the bundle I currently have deployed - I wonder why there's such a difference#2018-07-2517:27lilactownit might be gzipped. that would be embarrassing lol#2018-07-2517:27lilactownyep it was gzipped size 😂#2018-07-2517:28lilactownsorry for the false alarm!#2018-07-2519:26kwladykaWhat is the best way to use cljs REPL with shadow-cljs with cursive? https://github.com/thheller/shadow-cljs/wiki/Cursive#connecting-to-a-shadow-repl ?#2018-07-2519:32thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2018-07-2519:32thhellerset fixed :nrepl {:port <number>}#2018-07-2519:32thhellerand connect to that via cursive Clojure REPL -> Remote#2018-07-2519:33thhellerthen do the watch and nrepl-select described in the guide#2018-07-2521:21richiardiandrea@thheller I wanted to investigate a bit how to add REPL support for :node-test and I see that you are disabling :devtools explicitly?#2018-07-2521:22richiardiandreais it because of stable namespaces are needed there and we don't have one? (I actually though we always have a main entry point autogenerated)#2018-07-2521:24richiardiandreaI could use the normal :node-script target with a REPL but I don't know if the tests are compiled there#2018-07-2607:33kwladyka
shadow-cljs watch app
(shadow/watch :app)
=> :already-watching
(shadow/nrepl-select :app)
To quit, type: :cljs/quit
=> [:selected :app]
(js/alert "foo")
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
I have opened website in Chrome. What I miss?
#2018-07-2607:34thhellerdoesn't seem like the website has your generated JS loaded?#2018-07-2607:34thhelleranything in the browser console?#2018-07-2607:34thhellershould say shadow-cljs: WebSocket connected!#2018-07-2607:38thhellerif you want something easier to just test nrepl and stuff you can run shadow-cljs browser-repl and then (shadow/repl :browser-repl) in the REPL to select it#2018-07-2608:16kwladykashadow.cljs.devtools.api/find-resources-using-ns wow you are always surprising me#2018-07-2608:16kwladykait works#2018-07-2609:28biscuitpantsis it possible to merge certain keys from a build config? for instance, i want to create a dev build that uses all of the “release” entries, plus 1 more?#2018-07-2609:50bupkis@thheller Have you thought about using rebel-readline in the various REPLs that shadow-cljs provides?#2018-07-2610:06thheller@biscuitpants see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-07-2610:06biscuitpantssweet thank you @thheller#2018-07-2610:06biscuitpantsloader-mode eval is amazing!#2018-07-2610:07thhellersweet. do you have before/after data? curious about the difference#2018-07-2610:08thheller@samuel.wagen I have not. I only use the REPL from my editor so readline support doesn't do anything for me and thats why I haven't worked on anything related yet.#2018-07-2610:08thhellerit does sound cool but I didn't have time to look into it yet#2018-07-2610:09bupkis@thheller fair enough. do you have any pointers where to start, if I want to try adding it myself?#2018-07-2610:09biscuitpantsno concrete metrics, but i can feel the difference in the browser. before, without eval loader mode, the browser would have at least 2 seconds of lag, appending all the goog scripts. now, nothing. our “loading” symbol doesn’t even show anymore! 😄#2018-07-2610:10thhellerhehe nice#2018-07-2610:21thheller@samuel.wagen no idea. you can probably use it out of the box for the CLJ REPL#2018-07-2610:21thhellerbut no idea how to hook up the CLJS part#2018-07-2610:25bupkisyeah, one step at a time I guess 🙂#2018-07-2610:25bupkisI'll try hooking it up to the CLJ part when I get some free time#2018-07-2610:25bupkisit has CLJS support but I'd need to explore it#2018-07-2610:31thhellerI'm guessing that is pretty tightly integrated with the cljs.repl APIs which wouldn't work with shadow-cljs#2018-07-2610:33bupkisoh well 🙂 I'm using vim-fireplace, and I find myself not liking it much and preferring to use the cljs-repl instead.#2018-07-2610:33thhellerbtw you can open while shadow-cljs is running#2018-07-2611:07Jonno "eval" button?#2018-07-2611:07thhellershift+enter#2018-07-2611:08Jontried "command enter"...#2018-07-2611:08Jonwrong guess#2018-07-2611:09thhelleryeah UI/UX currently sucks. I just wanted to test some stuff and it works ok-ish#2018-07-2611:10Jonlooks good#2018-07-2610:33thhellerwhile that is currently very basic it has parinfer support#2018-07-2610:33thhellerI'll probably work on adding history support, completion and all that stuff at some point#2018-07-2610:33thhellerI think that makes for a way better interface than a stupid command line
#2018-07-2610:34thhellerits basically only a proof of concept currently though#2018-07-2610:34bupkisI know of it, but I prefer a terminal split instead of yet another browser window/tab - it's less context switching for me.#2018-07-2610:35thhellerthats why I do have plans for a chrome extension which would put the REPL into your browser devtools 😉#2018-07-2610:35thhellerie. not a tab#2018-07-2610:36bupkisthat would be cool to have, for sure. for my use case though, I love the cljs-repl feature of showing the println output in the repl in addition to having it in the devtools console - helps me use devtools less and stay nearer my editor#2018-07-2610:38bupkisI have tried several times to switch to Emacs for the better integrated REPL, but it's just not for me, even with evil-mode. Anyway, that's irrelevant. Maybe I'll be able to add some more creature comforts to cljs-repl even without directly using readline-rebel#2018-07-2610:38thhellerwell I do have plenty of plans for all of this but just not enough time to actually do it#2018-07-2610:38thhellerso if you figure out how to hook up the rebel-readline stuff let me know#2018-07-2610:38bupkisain't that the case with all of us 🙂 in any case, your efforts are greatly appreciated, shadow-cljs has been much more pleasant experience than the alternatives, at least for me#2018-07-2610:38bupkiswill do, for sure#2018-07-2612:16kwladykahttps://github.com/ethereum/web3.js
(ns boilerplate.example-test
  (:require [cljs.test :refer [deftest is testing use-fixtures]]
            ["web3"]))

(println (pr-str (js/Web3.)))
How to do:
var Web3 = require('web3');
var web3 = new Web3();
I was trying a few ways, but always ReferenceError: Web3 is not defined
#2018-07-2613:00p-himik@kwladyka It should be available as js/web3, lower-case.#2018-07-2613:00kwladykait is not 😞#2018-07-2613:01p-himikAh, it also supports require - I didn't notice. Wait a sec.#2018-07-2613:01p-himik@kwladyka You use version 14, right?#2018-07-2613:02kwladykahmm npm i web3 did this: "web3": "^1.0.0-beta.35" I didn’t notice it#2018-07-2613:03p-himikWell, in 0.14.0 you should be able to use (:require ["web3" :as web3]) in your ns definition.#2018-07-2613:03p-himikMaybe 1.0.0-beta.35 backwards-compatible in this regard.#2018-07-2613:03p-himikWell, if you want to use beta at all.#2018-07-2613:03p-himikFor future reference: https://shadow-cljs.github.io/docs/UsersGuide.html#npm#2018-07-2613:05kwladyka
(ns boilerplate.example-test
  (:require [cljs.test :refer [deftest is testing use-fixtures]]
            ["web3" :as web3]))

(println (pr-str (js/web3.)))
#2018-07-2613:05kwladykathe same issue#2018-07-2613:05kwladykawith right version#2018-07-2613:05p-himikNo-no, no need for js/.#2018-07-2613:05p-himikJust web3.#2018-07-2613:06kwladykaweb3. with .?#2018-07-2613:06kwladykaok I have progress #object[Web3 [object Object]]#2018-07-2613:06kwladykathanks#2018-07-2613:07kwladykaconsole.log(web3); // {eth: .., shh: ...} // it's here! Can I print it without webrowser?#2018-07-2613:08kwladykainstead of #object[Web3 [object Object]]#2018-07-2613:12p-himikNot sure I understand. You mean you want the contents, not the [object Object], and you're using CLI, not a browser console?#2018-07-2613:13kwladykashadow-cljs watch node-test <- at that moment i am running tests, so it is not in web browser#2018-07-2613:13kwladykaweb3 says I can do console.log(web3) to print it#2018-07-2613:13kwladykabut (println …) in cljs print #object#2018-07-2613:14p-himikYou can try (js/console.log web3). If that doesn't change anything, there should be other members of js/console, like dir. But I have no idea whether they're supported during the test run.#2018-07-2613:16kwladykaoh it works… just like that#2018-07-2613:16kwladykaI expected it would be harder#2018-07-2613:16kwladykathanks again#2018-07-2613:05p-himik@thheller How bad is it to override functions defined in some other ns? Will it work? Will it be predictable? I have some issues with Reagent, and I really don't want to include the whole library just to change a couple of functions.#2018-07-2613:31p-himikI've found cljs.core/find-ns-obj, but it's in the section titled "Bootstrap helpers - incompatible with advanced compilation". I have no idea how exactly they're incompatible though - they appear to use munge, so at least symbol names should be correct.#2018-07-2613:31p-himikAh, munge has nothing to do with the advanced compilation...#2018-07-2613:09kwladykaWhy not make your own code which use reagent? It sounds a little like a bad idea.#2018-07-2613:11p-himik@kwladyka If you're interested, you can take a look at https://github.com/reagent-project/reagent/issues/389 for more details. In essence, these functions that I'd like to change are used deep inside Reagent, so I can't just add my own implementation and tell Reagent to use it. I don't plan overriding to be a long-term solution. More like a piece of plumbing until the issue is fixed.#2018-07-2613:22kwladykahmm Do js class need #js format instead of clsj? That is why it is converted. No idea, but it sounds reasonable.#2018-07-2613:23p-himikThe problem there is that all CLJS data passed to a wrapped React component is being converted into JS data structures. The issue is that it's impossible in the general case to convert the data back because CLJS->JS conversion is lossy.#2018-07-2613:24kwladyka> CLJS data passed to a wrapped React component is being converted into JS data structures. No reason for that?#2018-07-2613:26p-himikWell, there's definitely a reason - just as you wrote yourself. The issue is that it's a reason for most of the cases, but definitely not for all of them. E.g. my component is not a true React component, but rather a wrapped Reagent component, so not only do I not need the conversion, but it straight spoils everything.#2018-07-2613:28kwladykahmm not sure what you want achieve in practice, but are you sure adapt-react-class is right function then? It sounds like you want use it with other purpose, than it was created.#2018-07-2613:29p-himikWhat do you mean? The pure React wrapper that I want to use returns a React class, so I have to use adapt-react-class. And it also accepts only a pure React class, so I have to use reactify-component.#2018-07-2613:31kwladykaok, sorry I can’t help. I was using it only for js modules#2018-07-2613:46thheller@kwladyka (:require ["web3" :as web3]) and then use web3 without js/.#2018-07-2613:47thheller@p-himik overriding a var from a different namespace is absolutely not recommended#2018-07-2613:48thhelleryou can instead just take the original source file and put it in your source path with the changes you want#2018-07-2613:48p-himik@thheller Yeah, I was thinking about that. But how do I make sure that my file has priority?#2018-07-2613:49thhellersource path always as priority#2018-07-2613:49p-himikOh, that's good to know, thanks!#2018-07-2613:50thhelleronly works in your project though. can't do that with libraries#2018-07-2613:51p-himikBut hypothetically - would something like (set! reagent.core/adapt-react-class (fn [c] ...)) work? Wait, what do you mean? Either I don't understand something, or your statement contradicts with what you already said.#2018-07-2613:52thhellerit sort of works yes but you must ensure that the thing you are adding has the exact same signature as the original#2018-07-2613:52thhellerie. can't do that with muilti arity fns#2018-07-2613:52p-himikOh, I was trying to change signature, heh.#2018-07-2613:54thhelleryeah the set! won't update the compiler/analyzer data so it may emit code that isn't compatible#2018-07-2613:54thhellerback to the override issue: it works in your project since the project sources paths come first before the jars on the classpath#2018-07-2613:54thhellerif you however package all your code up into a jar#2018-07-2613:55thhellersince your jar will depend on reagent the reagent jar will be loaded first#2018-07-2613:55thhellerso it takes priority then#2018-07-2613:55thhellerhowever its totally fine in an uberjar again#2018-07-2613:55p-himikSo is in a single JS, right?#2018-07-2613:56p-himikI don't deploy jars, I run the build on target servers.#2018-07-2613:56thhellerthats fine yeah#2018-07-2613:56p-himikGreat, thanks!#2018-07-2614:11thheller@kwladyka the code to match the JS example would be
(ns boilerplate.example-test
  (:require [cljs.test :refer [deftest is testing use-fixtures]]
            ["web3" :as Web3]))

(def web3 (Web3.))
#2018-07-2614:13kwladyka@thheller thank you, @p-himik already showed me it in thread 🙂#2018-07-2614:14thhellerah ok didn't see that#2018-07-2614:49lilactownthe more I use reagent, there are some things I love about it (the ability to represent my component tree as dumb vectors) and some things I hate (all of the magic)#2018-07-2614:50lilactownif they had not included their own async rendering and special reagent classes then it would be so much more flexible. but perf would probably be terrible#2018-07-2614:52thhellerbut perf is terrible because of the dumb vectors which you like 😉#2018-07-2614:53thhellerto me (html/h1 "hello world") looks just as nice as [:h1 "hello world] but doesn't require vectors->reactelement translation#2018-07-2614:55lilactownlol. well I wrote my own macro that turns the dumb vectors into function calls#2018-07-2614:55lilactownbut then I started to wonder what the point was 😛 I'm starting to coming around to the parens (div "foo")#2018-07-2614:55lilactownbut we actually use the fact that the runtime representation of a reagent component is just a vector a lot at work#2018-07-2614:56lilactownit turns out that it's much easier to traverse and transform than an actual React tree#2018-07-2614:57thhelleralso much slower though 😉#2018-07-2614:57thhellerwell traversing and transforming vs. not doing that#2018-07-2614:58lilactowntrue 😛 but there are usecases#2018-07-2615:01lilactownwe're doing server rendering of react components on Node.js, and are using the apollo library to do queries to a graphql endpoint. on the server side we traverse the tree, fetch all of the data necessary to render it, and then call render-to-string. using reagent + cljs it's a simple clojure.walk algorithm with some clever binding. with pure React it would involve calling the render function or calling a special getData method (which dan_abramov admonished the community for)#2018-07-2615:02thhelleror you use the om.next/fulcro approach and don't worry about react at all 😉#2018-07-2615:06lilactownapollo is basically relay++ 😛 and tbh the reason I had to write my own SSR stuff is because we're using reagent and not apollo-react...#2018-07-2615:06lilactownbut om.next & fulcro didn't really fit our use case. we wanted to go all-in on React, and also we're not building an SPA#2018-07-2615:03thhelleror I think the relay guys do that as well#2018-07-2615:03lwhortonhmm… i know shadow can read json files, since it first goes to a lib’s package.json and traces from there. but what the heck might this be? The required JS dependency "node-releases/data/processed/envs.json" is not available, it was required by "node_modules/browserslist/index.js" . my dependency postcss has a dep on browserslist, which has a dep on node-releases (which exposes the envs.json file). a double transient dependency resolution 😞#2018-07-2615:05thheller@lwhorton do you have a node_modules/node-releases/... directory?#2018-07-2615:06lwhortonindeed, it was installed after i installed postcss (which lists the dep tree i mentioned)#2018-07-2615:06thhellerbecause that file exists for me?#2018-07-2615:07thheller
[1:1]~cljs.user=> (require '["browserslist" :as x])
nil
[1:1]~cljs.user=> x
#object[browserslist]
#2018-07-2615:07thhellercompiles and loads fine#2018-07-2615:09thhellerbut you shouldn't try to compile postcss for the browser#2018-07-2615:09thhellerthats a really bad idea#2018-07-2615:09thhellerthe last time I checked it was gigantic#2018-07-2615:10lwhortonugh *shakes fist* ie11#2018-07-2615:11thhellerhmm my browserslist version doesn't load the envs.json#2018-07-2615:12lwhortonyea i think that’s the same error i’m getting. the envs.json file is definitely there, and the require statement in browserslist is pointing to the right file#2018-07-2615:12thhellerhmm or its just filtered out. thats odd#2018-07-2616:36dijonkitchenHow does :npm-deps compare to shadow-cljs?#2018-07-2617:19souenzzois possible export a js bundle that will be used in a template-like website (PHP/django that use many <script src=...> ), without risk to conflict with another bundle?#2018-07-2617:25thheller@souenzzo sure it should work by default. Its just not recommended to make multiple independent CLJS builds like that and loading them since each will contain their own cljs.core version which would not be compatible with each other#2018-07-2617:25thhellerif you only have one however CLJS build and the rest is non-CLJS that is not a problem#2018-07-2617:26thheller@dijonkitchen shadow-cljs only compiles npm dependencies with :simple optimizations. :npm-deps tries to do :advanced. If that works its better but it rarely works so shadow-cljs sacrifices that for more compatibility.#2018-07-2617:32dijonkitchenYeah, I’ve had trouble with :npm-deps but it should work, at least for simpler cases. Why does it rarely work?#2018-07-2617:38lilactown🤔 can I have two separate bundles (they're on separate pages) with the same module identifier?#2018-07-2617:40souenzzo@thheller I just need to delivery one script src='...' with one function. But I dont know anything about the other scripts that this site will use.#2018-07-2618:11thheller@dijonkitchen it rarely works because the mess of JS that is on npm. they don't follow the closure JS standards at all and sometimes to some dynamic stuff which the closure compiler doesn't understand. also the commonjs support is a bit lacking in places and some idioms the JS folks use are not supported at all.#2018-07-2618:12thhellershadow-cljs basically follows the model of webpack instead and matches that much more closely since most JS libs are sort of tuned for that#2018-07-2618:12thheller@lilactown what module identifier? if you mean :modules no, that must be unique.#2018-07-2618:13lilactownyeah i mean :modules#2018-07-2618:13thheller@souenzzo thats fine then if you lib doesn't interact with the other ones#2018-07-2618:14lilactowne.g.
:dashboard
{:target :browser
 :modules {:main {...}
           :onboarding {...}}}

:other-page
{:target :browser
 :modules {:main {...}
           :onboarding {...}}}
#2018-07-2618:15souenzzo@thheller the main cljs compiler/the closure compiler itself has problems if there is 2 bundlers imported in the same browser #shadow-cljs solves that?#2018-07-2618:17thhellerthe :output-wrapper solves that. CLJS also supports that though.#2018-07-2618:18thheller@lilactown thats two different builds, thats fine if you use different :output-dir values#2018-07-2618:18thhellerbut if the user will jump between dashboard and other-page frequently#2018-07-2618:19thhelleryou should look into :app {:target :browser :modules {:common {...} :dashboard {:depends-on #{:common} ...} :other-page {....}} instead#2018-07-2618:22lilactowngotcha#2018-07-2618:22lilactownyeah I haven't quite shook out how I want to structure it yet#2018-07-2618:22lilactownright now we only have the one page, just trying to think ahead#2018-07-2618:23thhelleryeah getting :modules just right is tough. always consider how the user moves though.#2018-07-2618:23thhellerwhen I started with modules I had one gigantic build that included everything#2018-07-2618:24thhellerand would just have a module for :admin stuff and then one per page and so on#2018-07-2618:24thhellerbut the user would never access :admin and some of the stuff in there made the base modules larger#2018-07-2618:24thhellerso it was much better to have a separate :admin build and keeping that out of normal user stuff#2018-07-2618:25thhellerbut if :dashboard and :other-page are both used by the user (in the same session)#2018-07-2618:25thhellerthen those should be modules#2018-07-2618:26thheller@souenzzo you can either do (defn ^:export your-fn [...]) to have your function accessible from HTML via <script>your.ns.your_fn();</script>#2018-07-2618:27thhelleror you can use (defn your-fn [...]) (js/goog.exportSymbol "yourFn" your-fn) to have it accessible as <script>yourFn();</script>#2018-07-2618:28thhellerI'd suggest doing the second. otherwise you need to ensure that the NS you use doesn't clash with anything on the page, ie. ensure there is no your variable in the example above#2018-07-2618:38souenzzoNice! There is some "formal" docs about it?#2018-07-2618:40thhellerno idea, probably#2018-07-2623:27eoliphantHi, i’m trying to ‘transate’ some react jsx code over to cljs I read through the section on using babel to convert jsx’es to .js, got that working. but imports of other resources just work? Here’s a snippet
import "perfect-scrollbar/css/perfect-scrollbar.css";


import withStyles from "@material-ui/core/styles/withStyles";


import Header from "components/Header/Header.jsx";
import Footer from "components/Footer/Footer.jsx";
import Sidebar from "components/Sidebar/Sidebar.jsx";

import dashboardRoutes from "routes/dashboard.jsx";

import appStyle from "assets/jss/material-dashboard-pro-react/layouts/dashboardStyle.jsx";

import image from "assets/img/sidebar-2.jpg";
import logo from "assets/img/logo-white.svg";
So I get that after running babel I should be able to do something like (require ["components/Header/Header" :default Header]) but does this also work for the css, images and what have you? like (require [ "perfect-scrollbar/css/perfect-scrollbar.css"])
#2018-07-2623:29justinlee@eoliphant importing non-js resources like that doesn’t work in shadow-cljs (it’s a webpack-specific extension)#2018-07-2623:29eoliphantthat’s what I was thinking/wondering lol#2018-07-2623:29justinleejust include css directly in your html#2018-07-2623:30eoliphantok so, for this component level style stuff?#2018-07-2623:30justinleewebpack has a bunch of “loaders” that bundle up resources for you. people can get a bit obsessed with reducing the # of round trips a page load takes, but the reality is you can always bundle all your css into a single file using less or sass, so at most it is a single additional tag#2018-07-2623:30eoliphantok#2018-07-2623:31eoliphantthis is a lib/tempate#2018-07-2623:31justinleein my index.html, I just have a <link rel="stylesheet" href="/css/site.css"> in my <head> tag#2018-07-2623:31eoliphantso I could just scan the dirs?#2018-07-2623:31eoliphantand to grab all the .css files#2018-07-2623:32eoliphantto mush them into an uber css or something?#2018-07-2623:32justinleethat’s what I do#2018-07-2623:32justinleei’m sure there’s something more sophisticated, but that solution is simple and it works#2018-07-2623:32eoliphantsure#2018-07-2623:32eoliphanti like simple lol#2018-07-2623:32justinleeyea me too 🙂#2018-07-2623:33eoliphanti understand the rationale for this approach but it seems kind of ‘noisy’ lol#2018-07-2623:36eoliphantso these jss files or whatever shold just work as they’re javascript?#2018-07-2623:36justinleegod css is so terrible. I had been @importing library css into my main scss, but now it is deprecated. https://github.com/sass/libsass/issues/2611 The only clear solution is ‘use webpack’ (?) lol#2018-07-2623:36eoliphantlol#2018-07-2623:36justinleei don’t know what jss is#2018-07-2623:38eoliphantit looks like .jsx files with style info#2018-07-2623:38eoliphant
import {
  drawerWidth,
  drawerMiniWidth,
  transition,
  containerFluid
} from "assets/jss/material-dashboard-pro-react.jsx";

const appStyle = theme => ({
  wrapper: {
    position: "relative",
    top: "0",
    height: "100vh",
    "&:after": {
      display: "table",
      clear: "both",
      content: '" "'
    }
  },
  mainPanel: {
    transitionProperty: "top, bottom, width",
    transitionDuration: ".2s, .2s, .35s",
    transitionTimingFunction: "linear, linear, ease",
    [theme.breakpoints.up("md")]: {
      width: `calc(100% - ${drawerWidth}px)`
    },
    overflow: "auto",
    position: "relative",
    float: "right",
    ...transition,
    maxHeight: "100%",
    width: "100%",
    overflowScrolling: "touch"
  },
  content: {
    marginTop: "70px",
    padding: "30px 15px",
    minHeight: "calc(100vh - 123px)"
  },
  container: { ...containerFluid },
  map: {
    marginTop: "70px"
  },
  mainPanelSidebarMini: {
    [theme.breakpoints.up("md")]: {
      width: `calc(100% - ${drawerMiniWidth}px)`
    }
  },
  mainPanelWithPerfectScrollbar: {
    overflow: "hidden !important"
  }
});
#2018-07-2623:38justinleethat seems bad. surely there a distribution-friendly version of the library#2018-07-2623:39justinleelibraries should haven’t jsx and inline css and crap like that. most library ship with compiled code#2018-07-2623:39eoliphantit’s like an add-on for mui#2018-07-2623:39eoliphantbut everything is source#2018-07-2623:40justinleeit’s just not going to be easy to make that stuff work with cljs without a build step. as i’ve said to thheller before: people don’t program in javascript anymore, they program in webpack. but most people are decent enough to build their code into something portable before shipping to npm#2018-07-2623:40eoliphantyeah it’s not in npm it’s commercial#2018-07-2623:40eoliphantugh webpack lol#2018-07-2623:41justinleethe import "thing.css" is webpack. the jsx needs a babel transform#2018-07-2623:41eoliphantwell at least it comes with a config#2018-07-2623:41eoliphantfor babel, webpack etc#2018-07-2623:41eoliphantso i can use those as a starting point#2018-07-2623:41eoliphantgotcha#2018-07-2623:42justinleeso many people use the webpack/babel stack that code is starting to assume that you are too. so you’ll need to set up a build step before using with cljs#2018-07-2623:42eoliphantyeah i’d already figured that, since shadow doens’t compile .jsx#2018-07-2623:42eoliphantso will just add the other crap as well lol#2018-07-2623:47eoliphantpresumably this node-sass-chokidar thing is tackling the css, also doesn’t look like it uses webpack (directly at least), it’s using react-scripts for the build
"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm run build-css && react-scripts build",
#2018-07-2623:49justinleethat will build the css, but it won’t strip the webpack loader extensions out of the code. i.e., you’ll still have the import “blah.css” in the code, and that is going to make the js runtime choke#2018-07-2623:54eoliphantah.. hell… so what fixes that?#2018-07-2623:56justinleeone of the css loaders in the webpack config will. if it already comes with a config, then it should be good to go#2018-07-2623:56eoliphantso the babel plugin will leave that stuff in?#2018-07-2623:56eoliphantah#2018-07-2623:56eoliphantit doesn’t look like it does#2018-07-2700:03eoliphantlooks like this react-scripts command does bunch of that stuff, delegates out to webpack etc#2018-07-2700:03eoliphantbut apparently the configs are internal or something#2018-07-2700:12eoliphantfound it, you can ‘eject’ the project and see all the configs#2018-07-2700:14justinleefwiw, react-scripts is the meat of create-react-app#2018-07-2700:14eoliphantyeah#2018-07-2700:14eoliphantjust figured that out 🙂#2018-07-2700:14justinleeso you have a commercial library that assumes you’re running on c-r-a? wonders never cease#2018-07-2700:14eoliphantlol#2018-07-2700:15eoliphanteven better that’s how it’s distributed#2018-07-2700:15justinleei don’t really grok how that’s supposed to work#2018-07-2700:15eoliphantyeah it’s a little annoying#2018-07-2700:16eoliphantthey’ve lumped the components, demo pages, etc#2018-07-2700:16justinleeso if it is cra have you tried typing npm run-script build#2018-07-2700:16eoliphantall in a ‘src’#2018-07-2700:16eoliphantyeah#2018-07-2700:16eoliphantjust re-unpacked it#2018-07-2700:16eoliphantand trying that#2018-07-2700:17justinleethat should create a javascript bundle and a css bundle#2018-07-2700:22eoliphantso.. at this point i should be able to drop the .js in my source and (require) stuff from it?#2018-07-2700:28justinleei don’t know 🙂#2018-07-2700:29justinleethe thing is that the bundle is going to include react#2018-07-2700:29justinleei wonder if the intermediate compiled files can be picked up before they’ve been bundled#2018-07-2700:58eoliphantugh this is truly in the weeds now. since that’s essentially an ‘app’… yeah it’s gonna have react#2018-07-2700:58eoliphantplus#2018-07-2701:01eoliphantugh.. lol, plus not even sure how the (require) is supposed to work. I have this main.js now, with all the components I want. But if I’m doing (require “a/b” :default c) presumably shadow is going to expect to see that in node_modules, etc#2018-07-2701:06eoliphantto your point, i really need the transformed .jsx files#2018-07-2707:10thheller@eoliphant the code you posted seems to be very webpack specific and its going to be hard to port this to shadow-cljs. you could instead use :target :npm-module and continue using the existing build system to create the final bundle#2018-07-2707:11thhellerresults won't be optimal but probably a lot less work to integrate#2018-07-2707:47kwladykaI have .sol files in project, which are files in different language to compile. I would like to do shadow-cljs watch tests and re-run tests if this file will change. At that moment shadow-cljs doesn’t detect this change. 1) How to re-run tests when .sol files change? 2) How to compile .sol files if they change. I have to run code (probably the best lein command) each time when files in /src/contracts change. It could be done in 2 separated steps. 1) shadow-cljs watch app to watch changes including change of compiled files .abi in some directory, 2) watcher to track /src/contracts to compile them when source changed.#2018-07-2707:50thheller@kwladyka how are the .sol files used in the project?#2018-07-2707:53kwladyka.sol are compiled to .abi and .bin files. These files are used by module in javascript later.#2018-07-2707:54thhellerhow are they compiled? by a command you trigger?#2018-07-2707:54thhellerie. make contract or something?#2018-07-2707:54kwladykaat that moment by this https://github.com/district0x/lein-solc#2018-07-2707:54kwladykabut it could be run by shell#2018-07-2707:54kwladykabut probably I prefer lein command#2018-07-2707:54kwladykato make it consistent#2018-07-2707:55thhellerlein solc once && touch test/your_ns/*-test.cljs#2018-07-2707:55thhellerthat is probably the easiest thing#2018-07-2707:55thhellertouch will cause the compiler to trigger a recompile, which will then trigger re-running the tests.#2018-07-2707:56thhellerbut that probably doesn't work when you use lein solc auto#2018-07-2707:56kwladykano way to add directory to watch in shadow-cljs?#2018-07-2707:57thhellerthere are plenty of options. they are all just a lot more complicated than the above#2018-07-2707:57kwladykabut this above wouldn’t work for me in easy way too#2018-07-2707:58thhellerwhy not?#2018-07-2708:00thhellerare the .abi files actually consumed via some macro or such or are they just loaded via the node fs package?#2018-07-2708:05kwladykahmm or maybe this .abi and .bin files are needed to update in blockchain, not in js… not sure, I am doing it first time. However I need: 1) detect change in directory and run code 2) re-run tests after files changed / blockchain update <- this one I have to check to be sure#2018-07-2708:06thhellerI'm asking because its important to know if you actually need to recompile the code or just re-run the test#2018-07-2708:07kwladykahmm and actually I am not using project.clj here, so I am not sure about lein solc. I am trying to move solution into shadow-cljs from standard lein cljs compiler#2018-07-2708:07kwladykaI have to re-compile .sol files, not .cljs files.#2018-07-2708:08thhellerlein solc just seems to shell out to solc so you don't seem to gain much from it#2018-07-2708:08thhellerso if you just run the tests that will use the updated .sol files?#2018-07-2708:09kwladykaok, once again:#2018-07-2708:10kwladyka1) when change .sol files I have to re-compile them to .abi and .bin files. <- this one for sure 2) when step 1) finish I have to update blockchain and I think use this files in javascript module too <- not 100% sure. cljs files don’t need to be re-compile. 3) re-run tests#2018-07-2708:11thhellerso you can shadow-cljs compile tests once (no watch). update the .sol files and compile those#2018-07-2708:11thhellerthen run node out/the-tests.js without recompiling the CLJS#2018-07-2708:12thhellerand it will use the newer contract files?#2018-07-2708:12kwladykabut while develop .sol code I will have to write tests in cljs to check them. So I have to use fresh tests.#2018-07-2708:13thhelleryes but please figure out my question first#2018-07-2708:13thhellerthe recommendation on what to do then varies greatly on the answer#2018-07-2708:13kwladykaI don’t need to compile cljs files after change .sol files. But I will edit .sol and .cljs files step by step#2018-07-2708:14thhelleryes. I'm just trying to be sure that you do not need to recompile the CLJS when you edit .sol files#2018-07-2708:14thhellerso they do not need to coordinate at all#2018-07-2708:14kwladykayes, compiled .sol files are used at runtime, not during compilation#2018-07-2708:16kwladykabut maybe I need third party solution to watch .sol files and run shell command then. Maybe it is not something to do in shadow-cljs#2018-07-2708:16thhellerok. then I would recommend using chokidar. disable :autorun in the shadow-cljs build config. then let chokidar watch the :output-to file and in addition to that the .sol files.#2018-07-2708:16thhellerand then trigger running the tests if either change#2018-07-2708:17kwladykathanks, I didn’t use it. I will check it.#2018-07-2708:17thhellersince you are going to need something to run watch the .sol files anyways#2018-07-2708:17thhellerthat seems like the best option#2018-07-2708:18kwladykabecause there is no option in shadow-cljs to watch directory and then do something while I am doing shadow-cljs watch ...?#2018-07-2708:18thhelleryou can also use the https://www.npmjs.com/package/chokidar directly and create a small watch.js#2018-07-2708:19kwladykaOh so Can I use it not directly?#2018-07-2708:19kwladykaoh by directly you mean js code#2018-07-2708:19thheller@kwladyka you can use shadow-cljs to watch the directory and make it do all of it BUT that is not documented at all and a little more complex than just using chokidar#2018-07-2708:19kwladykaok thx#2018-07-2708:19thhelleryes, directly in some js code#2018-07-2708:22thhellerthe problem with doing it in shadow-cljs is that you must be very careful of not leaking data. ie. watching a file and then not closing it#2018-07-2708:22thhelleryou don't really have to deal with that when you just a node process that you can kill at any time#2018-07-2708:22thhellerkilling shadow-cljs sucks because of its startup time#2018-07-2708:27kwladykaok, doing this in third party solutions sounds ok#2018-07-2708:29kwladykaso I will compile .sol files with chokdiar. It will detect changes in files and run commands for me. But how to tell shadow-cljs watch tests to re-run? by touch?#2018-07-2708:29thhellerI'm assuming that is :target :node-test?#2018-07-2708:30kwladykaat that moment yes, but later probably I will move to Karma#2018-07-2708:31kwladykadifficult to say at that moment#2018-07-2708:31thhellerwell can't comment on the karma part but for :node-test I would recommend simply dropping :autorun true from your build config and letting your chokidar thing run the tests whenever either the .sol files change or the :output-to changes#2018-07-2708:31kwladykamaybe I could stay with node-test#2018-07-2708:32thhellerie. shadow-cljs watch tests just watches and compiles the .cljs files but does not run the tests#2018-07-2708:32kwladykaoh I see#2018-07-2708:32thhelleryou then just call node out/the-tests.js to run them#2018-07-2708:32kwladykajust not run shadow-cljs watch tests, use only chokidar#2018-07-2708:33thheller> ie. shadow-cljs watch tests just watches and compiles the .cljs files but does not run the tests#2018-07-2708:34kwladykaok I understand now#2018-07-2708:35thhellerbasically you'll have the shadow-process procress runnning and doing its thing#2018-07-2708:35thhellerand then the chokidar thing running independently#2018-07-2708:36kwladyka🍻#2018-07-2708:42biscuitpants#2018-07-2708:42biscuitpantsdoes this error look familiar to anyone? running shadow-cljs watch from the CLI works, but using the library i get this exception#2018-07-2708:42biscuitpantsi have a feeling its something to do with dependencies clashing#2018-07-2708:44thheller@biscuitpants yes. incompatible closure compiler version#2018-07-2708:44thhellerusing lein?#2018-07-2708:44biscuitpantsyes to start the process#2018-07-2708:45thhellerthen make sure you have the correct CLJS 1.10.339 and no manual closure-compiler-unshaded depdencency#2018-07-2708:45thhellercheck lein deps :tree it'll probably show a conflict somewhere#2018-07-2708:48biscuitpantsthank you! that was it. i’ve got another problem with Transit, but that’s the same issue 🙂#2018-07-2708:48thhellercore.async is another one to watch out for#2018-07-2708:49biscuitpantsi fixed that one yesterday actually (big thanks to shadow too)#2018-07-2708:49biscuitpantswith figwheel we just could not get a cljs repl to work. always a problem about cljs.core.async.macros#2018-07-2708:49biscuitpantsusing shadow and the repl works with no problem#2018-07-2708:49biscuitpantsseriously happy man ❤️#2018-07-2709:05kwladyka@thheller You help everybody all the time. When do you work? Are you a robot? 🙂#2018-07-2709:05biscuitpantsis it possible to start a repl from the library, without stdin then waiting for input?#2018-07-2709:06biscuitpants@kwladyka i’m pretty sure he doesn’t sleep haha#2018-07-2709:06kwladykamaybe he has secret twin 😉#2018-07-2709:06thhellerhehe. unfortunately not a robot 😉 and no twin#2018-07-2709:07thhellerwork currently consists of rewriting 3 year old CSS+HTML#2018-07-2709:07thhellerso I'm happy about every excuse not to do that 😉
#2018-07-2709:08kwladykahaha I just see this joke in that context > How long will take to rewrite 3 years old CSS + HTML 3 years#2018-07-2709:08thheller@biscuitpants what do you mean? non-nrepl repl?#2018-07-2709:09thhellerhehe if I had to do this for 3 years out probably jump out of a window or so 🙂#2018-07-2709:09biscuitpantsso when i do shadow/repl :app my repl process expects input and hangs until i give input#2018-07-2709:10thhellerbut isn't that the point of a REPL?#2018-07-2709:10biscuitpantsthis is from running a lein repl and then using the api to setup my builds and CLJS repl#2018-07-2709:11thhellerah right you probably need to add the nrepl middleware#2018-07-2709:11kwladykaCan you tell a little your personal story how did you start shadow-cljs, how did you get money to not work in that time etc. You did so good job. I am curious your story how did you achieve it having life in the same time (this is my assumption :P).#2018-07-2709:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-07-2709:12thheller@kwladyka I started using CLJS about 5 years ago. the tools sucked so I started building my own. so I built it mostly on weekends over 5 years and used it for my projects.#2018-07-2709:12biscuitpantsah thank @thheller - just saw that now 🙂 i see the server starts an nREPL automatically too#2018-07-2709:12kwladykaoh man you live in Germany, so close to me#2018-07-2709:13kwladykaDefinitely I have to buy you a bear one day#2018-07-2709:13thhellerhaven't got any money to work on shadow-cljs yet. took some time off work last year to work and docs and such#2018-07-2709:14thhellerthinking about doing this a bit more seriously in the future. there is so much more I want to do but just can't justify doing#2018-07-2709:15thhellerseriously wish I didn't have to do these annoying work projects anymore. they pay well but totally suck. 😛#2018-07-2709:15kwladykaoh you definitely deserve for funds#2018-07-2709:16kwladykayeah, probably everybody wish to use native solutions#2018-07-2709:16kwladykaBut it wouldn’t happen soon#2018-07-2709:37biscuitpantswhen i do shadow/nrepl-select :build i get Can't change/establish root binding of: *nrepl-cljs* with set#2018-07-2709:38thhellerthat probably means that the middleware isn't loaded#2018-07-2709:38biscuitpantsoh i see. it looks like i need to set up the nrepl middleware?#2018-07-2709:38biscuitpants🙂 thank you#2018-07-2709:49nhaMaybe you could apply to the clojurists together? https://www.clojuriststogether.org/#2018-07-2709:50kwladykaI will vote for you 🙂#2018-07-2709:52thhellerI did apply#2018-07-2709:52thhellerstarts next week so who knows 😉#2018-07-2709:54kwladykalet us know if we can do something for you to make it happen 🙂#2018-07-2710:49eoliphantthanks @thheller You mean this from the guide?
:js-options
   {:resolve {"d3" {:target :npm
                    :require "d3/build/d3.js"}}}
And the code I posted was perhaps a bad example it’s from a sample page, I’m mainly after the components, thought they certainly also have the style imports.. Here’s an example from their custom button
import React from "react";
// nodejs library that concatenates classes
import classNames from "classnames";
// nodejs library to set properties for components
import PropTypes from "prop-types";

// material-ui components
import withStyles from "@material-ui/core/styles/withStyles";
import Button from "@material-ui/core/Button";

import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";
So to your point, I’d build this to say my-mui-lib.js Then do something like the following? But isn’t the :require going to look in node_modules?
:js-options
   {:resolve {"my-mui-lib" {:target :npm
                    :require "my-mui-lib.js"}}}
#2018-07-2710:50eoliphantThey should really just adopt/merge/whatever shadow into cljsbuild 🙂#2018-07-2710:51thhellereek why would you want that 😉#2018-07-2710:51thhellerhow do you build the JS only currently#2018-07-2710:51thhellerand how do you want to integrate CLJS into that?#2018-07-2710:52thhelleror rather what is more code. the CLJS part of the JS part?#2018-07-2710:52eoliphantah I’m building a CLJS app#2018-07-2710:52eoliphanti just have this lib of MUI extensions I want to use#2018-07-2710:52thheller:resolve is not the option you are looking for#2018-07-2710:53eoliphantgotcha, i didn’t see the :target :npm-module you mentioned in the guide#2018-07-2710:53eoliphantthoguht that was it#2018-07-2710:53thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2018-07-2710:54eoliphantah duh, searced for both keywords together lol#2018-07-2710:55thhellerbut your app is primarily CLJS and you just have some library which is JS?#2018-07-2710:55eoliphantexactly#2018-07-2710:55thhellerand that library is not available on npm?#2018-07-2710:55eoliphantusing MUI, want to add these nicer components#2018-07-2710:55eoliphantnope#2018-07-2710:56eoliphantthese components aren’t free#2018-07-2710:56thhellerI'm guessing its the pro version of this https://github.com/creativetimofficial/material-dashboard-react?#2018-07-2710:57eoliphantyepper#2018-07-2710:57thhellertrying to get a sense of what the code looks like#2018-07-2710:57bbss@eoliphant I'm using material-ui with shadow-cljs. I'm re-using some of the experiments done by @thheller earlier.#2018-07-2710:57eoliphant#2018-07-2710:58bbsshttps://github.com/bbss/cljsc2/blob/master/src/cljsc2/clj/trashdrawer/material_ui_interop.clj to generate a cljs file with factories for each component: https://github.com/bbss/cljsc2/blob/master/src/cljsc2/cljs/material_ui.cljs#2018-07-2710:58eoliphantjust uploaded a screen shot of the layout.. which you apparently cant see because we’re on the free plan lol#2018-07-2710:58bbss@eoliphant we can still see it, confusing slack message is confusing#2018-07-2710:59eoliphantok @bbss so you had to do this to core#2018-07-2710:59eoliphantlol, ok cool#2018-07-2711:00bbssThis is by no means the "correct way". Meaning I haven't tested it with advanced compilation, and it might import everything so no tree shaking.#2018-07-2711:00eoliphantso, I really just need the components#2018-07-2711:00eoliphantgotcha#2018-07-2711:00bbssBut in case you were looking at how to hack it together. It works fairly well.#2018-07-2711:01eoliphantthe js build ecosystem is quite literally a nightmare lol#2018-07-2711:08bbssYeah, and shadow-cljs helps a ton 🙂 I really hope shadow-cljs get the clojurists together help.#2018-07-2711:14thheller@eoliphant that library is an absolute nightmare#2018-07-2711:15thhelleronly looking at the free version but I assume the pro version isn't much better#2018-07-2711:15thhellerbut it should work if you just put it into one directory#2018-07-2711:16thhellerand run babel on it#2018-07-2711:18thhellertesting something with the free package#2018-07-2711:18eoliphantok, so yes based on @lee.justin.m’s advice, I did the babel thing#2018-07-2711:18eoliphantlast night#2018-07-2711:18eoliphantso say the header of the button component I posted earler#2018-07-2711:19eoliphantin .jsx#2018-07-2711:19eoliphantis now#2018-07-2711:19eoliphant
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

import React from "react";
// nodejs library that concatenates classes
import classNames from "classnames";
// nodejs library to set properties for components
import PropTypes from "prop-types";

// material-ui components
import withStyles from "@material-ui/core/styles/withStyles";
import Button from "@material-ui/core/Button";

import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";
#2018-07-2711:19thhelleralways fun when a simple npm install takes several minutes to complete ...#2018-07-2711:19eoliphantlol#2018-07-2711:20thhellerDone in 166.89s.#2018-07-2711:20eoliphantwhereas the example compoents obvioully still have css, etc imports
// creates a beautiful scrollbar
import PerfectScrollbar from "perfect-scrollbar";
import "perfect-scrollbar/css/perfect-scrollbar.css";

// @material-ui/core components
import withStyles from "@material-ui/core/styles/withStyles";

// core components
import Header from "components/Header/Header.jsx";
import Footer from "components/Footer/Footer.jsx";
import Sidebar from "components/Sidebar/Sidebar.jsx";

import dashboardRoutes from "routes/dashboard.jsx";

import appStyle from "assets/jss/material-dashboard-pro-react/layouts/dashboardStyle.jsx";

import image from "assets/img/sidebar-2.jpg";
import logo from "assets/img/logo-white.svg";
#2018-07-2711:20thhellerthe problem is import buttonStyle from "assets/jss/material-dashboard-pro-react/components/buttonStyle.jsx";#2018-07-2711:21eoliphantrgith#2018-07-2711:21eoliphantright#2018-07-2711:21eoliphantthat’s a jss or whatever file#2018-07-2711:22thhelleryeah that should be relative paths#2018-07-2711:22thhellertrying to figure out if there is a babel plugin to override that#2018-07-2711:23eoliphantnow if I do the ‘src/gen’ dir per your .jsx example, and all that stuff is in there#2018-07-2711:23eoliphantwouldn’t the buttonStyle resolve? ah wait, no.. because it’s not .js#2018-07-2711:23eoliphantugh#2018-07-2711:24thhellerno imports without a / or ./ in front will resolve to node_modules#2018-07-2711:24thhellernot the classpath#2018-07-2711:24eoliphantgotch#2018-07-2711:25eoliphantand conversely, if i just say do the full webpack build#2018-07-2711:26thhelleryeah thats probably the easier option#2018-07-2711:28eoliphantok, but in that case, wasn’t sure how I’d require a given component. I say stick ‘irritating-mui-lib.js’ in my src. and I want to do the equivalent of (require ["components/CustomButton/Button" :default Button]) if this was working normally#2018-07-2711:31thhellerthats not a problem since webpack will then resolve the components#2018-07-2711:31thhellerit just won't work in the REPL at all#2018-07-2711:32eoliphantok, but in my cljs code, that require above would work?#2018-07-2711:32thhellerwhen using the webpack stuff yes#2018-07-2711:33thhellerwell assuming of course you have webpack configured correct and stuff#2018-07-2711:33thhellerits an absolute mess#2018-07-2711:33eoliphantand the .js should be just included in the .html, as opposed to trying to (require [“irritating.js”….])#2018-07-2711:33eoliphant?#2018-07-2711:33eoliphantyeah I’m going to assume that at least#2018-07-2711:34eoliphanttheir webpack build is functional#2018-07-2711:34eoliphantlol#2018-07-2711:34thhellertheirs yes but also when you use it as a library?#2018-07-2711:35thhelleralright this looks promising https://www.npmjs.com/package/babel-plugin-transform-import-paths#2018-07-2711:36eoliphantyeah again, this is where i’m getting a headache. lol. They’re using the stock create-react-app stuff. So that build creating an ‘app’ that’s probably had its tree shaken lol, etc.#2018-07-2711:36thhellerif only I didn't have to wait 2mins to install that shit#2018-07-2711:36eoliphantso conceivably, it might not even have all of the components#2018-07-2711:36thhellerso they basically just dumped their shit into a basic boilerplate#2018-07-2711:36eoliphanti’m guessing#2018-07-2711:36thhellerinstead of making it a proper clean library 😛#2018-07-2711:36eoliphantyeah#2018-07-2711:36eoliphantthat you’re supposed to just drop these in your source treee#2018-07-2711:37eoliphantwhich is mega, mega irritating#2018-07-2711:37eoliphantseems like they should have a component#2018-07-2711:37eoliphantdistro and an examples distro that uses it#2018-07-2711:39thhellernpm is such a shit show sometimes#2018-07-2711:39thhellerwhy the heck does it take 166sec to install a single package#2018-07-2711:39thhellerand then that package is empty for some reason?#2018-07-2711:40thhellerguess the plugin is just broken#2018-07-2711:41thhelleronto the next then#2018-07-2711:45thhellermeh also doesn't work#2018-07-2711:47thhelleruhm wait#2018-07-2711:47thhellerit works now?#2018-07-2711:49eoliphantHaven't tried heading to the office going to give it a shot when i get in#2018-07-2711:50eoliphantBut yeah as i think about it#2018-07-2711:50thhellerok I think I got it working#2018-07-2711:51thhellerabsolute nightmare but working#2018-07-2711:51thhellerI'll see if I can setup a demo repo#2018-07-2711:52eoliphantThe tree shaking is most likely a problem#2018-07-2711:52thhellerI'm somehow doubtful that it works properly in webpack?#2018-07-2711:53eoliphantSo the import path fixer upper should do the thing for the paths.?#2018-07-2711:53eoliphantWell as far as that goes. The demo or whatever runs fine. #2018-07-2711:53thhelleryeah its rewritten to var _cardStyle = require("../../assets/jss/material-dashboard-react/components/cardStyle"); for me#2018-07-2711:54thhellernpx babel src -d ../src/gen/material-dashboard-react#2018-07-2711:54thhellerassuming the stuff is cloned into <project>/some-dir running the babel in some-dir#2018-07-2711:55thhellerin CLJS then (:require ["/material-dashboard-react/components/whatever/andSoOn" :as x])#2018-07-2711:56thhellerjust need to manually add all the proper npm dependencies#2018-07-2711:56eoliphantOk ok. That's great. But will still need something to strip out the css, etc refs like webpack does right?#2018-07-2711:56thhellernot sure. which one is used?#2018-07-2711:56eoliphantYeah. I already copied all their deps into my package.json#2018-07-2711:57thhellerah right#2018-07-2711:57thhellerhmm but its only the dasboard component doing this I think#2018-07-2711:58thhellerbut yeah that won't work#2018-07-2711:58eoliphantTo handle the css? Whatever the more or less default webpack hander is i guess. #2018-07-2711:59thhellerwell the css is just ignored#2018-07-2711:59thhellerproblem is the image imports#2018-07-2711:59thhellersince they are supposed to return something#2018-07-2711:59thhellerand shadow-cljs would just return nil#2018-07-2712:00thhellerimport image from "assets/img/sidebar-2.jpg";#2018-07-2712:00thhelleris supposed to return the path to that image#2018-07-2712:00thhellerbut it will be nil#2018-07-2712:00eoliphantHaving said that it looks like the components are largely using jss#2018-07-2712:01eoliphantRight#2018-07-2712:01thhellerwell you should really try :npm-module I guess#2018-07-2712:01thhellerit won't be fun but probably easier than trying to get all the webpack specific stuff out#2018-07-2712:02thhellerbasically you let the mui stuff alone#2018-07-2712:02eoliphantFortunately i think most of the image refs are in the examples, not the components. But will need to verify#2018-07-2712:03thhellermeh .. no time to finish this. I'll probably take a look later#2018-07-2712:03thhellerthere has to be some solution to this mess#2018-07-2712:03eoliphantOk ill read up on it when i get in#2018-07-2712:05eoliphantThanks for the help. ;)#2018-07-2714:00kwladykahttps://clojurians.slack.com/archives/C6N245JGG/p1532689094000283 hmm so you read the file as a text and parse it to generate cljs ? @bbss#2018-07-2714:01kwladykaBTW wow StarCraft II API in cljs nice 🙂#2018-07-2714:03eoliphantOk, yeah I was so busy reading over the code, totally missed that.. super cool#2018-07-2714:07eoliphantSo, @thheller, when you’re back around, I read over the :npm_module target. If I’m understanding this correctly it allows me to call my cljs code from js, and plays nicely with a webpack, etc toolchain. But am I correct in that I wont be able to grab say these components in my CLJS code?#2018-07-2716:40bbss@kwladyka I run the clojure file which checks the dirs in node_modules and filters some dirs to get the names of what the material-ui exports. Write that to the cljs file which can then be used by other cljs.#2018-07-2806:48kwladykaBut you parse the code, not use cljs to “read” the code. Parse string, not load the code to read something from namespace etc.#2018-07-2806:49kwladykaI am asking because I wanted do something similar for material-ui too before#2018-07-2806:49kwladykaBut is sounds too complex and hard, so I resigned and I am using material-ui as normal node_module require#2018-07-2716:50lilactownis there a way to get source maps in node.js release builds?#2018-07-2717:06lilactownI'm having serious issues with doing a release build rn after upgrading#2018-07-2717:19thhellershadow-cljs relaease your-build --source-maps or :compiler-options {:source-map true}#2018-07-2717:22lilactownthey don't show in the stack trace when my app fails 😕#2018-07-2717:23thhelleryou might need to manually load the source-map package#2018-07-2717:23thhellernode -r source-map your-script.js might do it#2018-07-2717:25thhellerhttps://github.com/evanw/node-source-map-support#2018-07-2717:25thhellernode -r source-map-support/register compiled.js#2018-07-2717:25thhellerlike that I guess#2018-07-2717:29lilactown@thheller with shadow-cljs 2.4.24 I'm getting this error using a release build with :node-script
TypeError: (intermediate value)(intermediate value)(intermediate value).Dg is not a function
    at a8 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1694:329)
    at lh (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1710:27)
    at jh (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:249:291)
    at Function.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1712:156)
    at Function.y.b (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:212:112)
    at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:1711:103
    at Object.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1713:3)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
#2018-07-2717:42lilactownreverting back to 2.4.0 fixes. zeroing in on the version that introduced it...#2018-07-2717:46lilactownlooks like this commit introduced this: https://github.com/thheller/shadow-cljs/commit/7f3c7cadd9c78d9dd5e923c4d2fa795bd53d84b6#2018-07-2718:22thheller@lilactown that commit made :advanced the default and the above error is most likely externs#2018-07-2718:22thhellerdo you have :infer-externs :auto set?#2018-07-2718:22lilactownyes#2018-07-2718:22thhellerno warnings?#2018-07-2718:22lilactown1 sec#2018-07-2718:23thhellertry running shadow-cljs release your-build --pseudo-names to figure out what .Dg is#2018-07-2718:23thhelleror set :compiler-options {:optimizations :simple}#2018-07-2718:31lilactown
TypeError: (intermediate value)(intermediate value)(intermediate value).$createServer$ is not a function
    at $macchiato$server$start$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:33718:362)
#2018-07-2718:37lilactownchanging to :simple gives me:
Users/r627543/Code/fido/packages/web/app/target/out/server.js:22985
        return $keyword_fn$$.cljs$core$IFn$_invoke$arity$1 ? $keyword_fn$$.cljs$core$IFn$_invoke$arity$1($x$$) : $keyword_fn$$.call(null, $x$$);
                             ^

TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at $cljs$core$thisfn$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22985:30)
    at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22957:19)
    at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:22974:35
    at $cljs$core$thisfn$$ (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:23003:465)
    at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:23032:10)
    at cljs.core.clj__GT_js (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:22969:31)
    at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:14078:104
    at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:14079:8
    at cljs.core.LazySeq.sval (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:10219:122)
    at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:10295:8)
#2018-07-2718:40lilactown:whitespace
/Users/r627543/Code/fido/packages/web/app/target/out/server.js:1016
goog.debug.Error = function(opt_msg) {
                 ^

TypeError: Cannot set property 'Error' of undefined
    at /Users/r627543/Code/fido/packages/web/app/target/out/server.js:1016:18
    at Object.<anonymous> (/Users/r627543/Code/fido/packages/web/app/target/out/server.js:118841:3)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
#2018-07-2718:41lilactownI'm wondering if this is a weird interaction with :reader-features#2018-07-2718:42lilactownhmm nope#2018-07-2718:51lilactownokay, apparently I needed to restart my shadow-cljs server because now :simple is working#2018-07-2719:38thheller@lilactown :whitespace is not compatible with node. the :simple error was actually an :advanced build with pseudo names active#2018-07-2723:22eoliphanthey @thheller i looked at that :npm_module stuff, but I’m not quite grokking how that’s would work. Would I be be able to ref stuff from the react libs in my cljs code?#2018-07-2723:40Schpaa#2018-07-2723:41Schpaathis is from the manual, but is it true?#2018-07-2800:20eoliphantyep that works. Ive only done it with the full lein integration prevously#2018-07-2808:11thheller@schpaencoder yes that is accurate. lacking a lot of details but accurate.#2018-07-2808:13thheller@eoliphant sorry I didn't get to it yesterday. I'll see if I find some time today#2018-07-2808:14thhellerthe idea with :npm-module would be to compile to <project>/material-dashboard-react/src/cljs and then in the src/index.js to require("./cljs/your.main").start()#2018-07-2808:15thhellerie. calling (ns your.main) (defn start [] ...)#2018-07-2808:15thhellerfrom CLJS you can then require the (:require ["components/...."]) but the downside with this is that you can't require using relative paths#2018-07-2808:15thhellersince that would make shadow-cljs try to import them#2018-07-2808:16thhellerits probably not much cleaner than the other way#2018-07-2808:59Schpaa> yes that is inaccurate. lacking a lot of details but accurate. Which is it?#2018-07-2808:59thhellerhaha oops#2018-07-2808:59thhelleryes. that is accurate. 😛#2018-07-2808:59thhellerjust woke up#2018-07-2808:59SchpaaHehe#2018-07-2809:00thhellerfixed. 😉#2018-07-2809:01thhellerwhy are you asking? any issues?#2018-07-2812:33eoliphanthey @thheller no probs, no idea how you manage to keep this going and presumably have a life and what have you lol I’ll play around with it some. I’m admittedly a little weak with this stuff, more of a backend middleware guy, so usually just beat up on my ui guys to get the toolchains working, when I needed to do UI stuff lol. But man, the js spec folks, really need to figure something out. I’m definitely a big fan of ‘practical’ and organic standards like say spring in the java world. But when one is looking at some .js code and says something like ‘oh, that’s a webpack import’, where’s , we may have issues lol. I think the whole transpilation thing was a good idea that’s gone haywire.#2018-07-2813:32eoliphanthey #theller i can’t get that transform-input-paths plugin to work. babel keeps saying it can’t find it, based on the authors notes, it looks like it mightbe targeted at v7 or something. gonna try the root-imports plugin that it alludes to#2018-07-2813:48eoliphantwould dumping all this crap into an NWB project, and creating an exporter index.js potentially be a way around this? https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#libraries#2018-07-2815:22lilactownis there a trick to embedding shadow-cljs in a clojure project?#2018-07-2815:23lilactownI’m trying to start the server and watch from my CIDER REPL. server starts, but when I run a watch it starts complaining about cljs/tools/reader#2018-07-2815:23lilactowncompile works fine#2018-07-2815:23eoliphantWell, i’m both annoyed and a little pleased lol. I sent a note to those guys, about the need to have this packaged properly and got a response that they’re working on it. So as I was starting to try to setup my own repo, discovered that there’s already an NPM distro, for the free/lite one. So I just installed that and it seems to work. Now just having an issue with the styles/options. the default appearance is what you’d expect, nice and material, so the css is sort of working. but it doesn’t seem to be honoring the options that are passed in
[reagent.core :as r]
            ["material-dashboard-react/components/CustomButtons/Button" :default Button]
            ["material-dashboard-react/assets/jss/material-dashboard-react/components/buttonStyle" ]))

(def mui-button (r/adapt-react-class Button))

(defn render [ctx]
  [:<>
   [:div [mui-button {:color "info"} "Hi There"]]
   [:div

   [:button {:on-click #(<cmd ctx :update :dec)} "Decrement"]
#2018-07-2815:23lilactownI’m guessing it’s a transient dependency thing#2018-07-2815:25eoliphanti use it with cursive. I start the watch from the command line, attach to it, then select to flip over to cljs#2018-07-2815:25lilactownyeah, that’s how I do it at work. my website is already a clojure project tho so I was hoping I could have it all in one REPL#2018-07-2815:26lilactown@eoliphant so it shows “Hi there” but isn’t respecting “color”?#2018-07-2815:27eoliphantah yeah, i found it to be clunkier to run even though it was ‘better’ integrated#2018-07-2815:27eoliphantyep, it’s really weird#2018-07-2815:28eoliphant#2018-07-2815:28eoliphantSo renders as it should in the material style#2018-07-2815:29eoliphantI know reagent does it for you, but I also tried {"color" "info"} and clj-jsing it as well#2018-07-2815:30lilactowngrabbing at straws, but try using :> Button {:color "info"} "Hello"#2018-07-2815:30eoliphantyeah good point was thinking about that#2018-07-2815:32eoliphantdammit lol#2018-07-2815:32eoliphantas you learn in science, only vary one thing at a time lol#2018-07-2815:33eoliphantso, I was doing this, and switching over to keechma#2018-07-2815:33thheller@eoliphant the default .babelrc shipping with the material-dashboard stuff worked after all. the transform-import-paths wasn't required.#2018-07-2815:33eoliphantand hadn’t updated my :after-load directive#2018-07-2815:33thhellerso just running babel in the directory worked fine#2018-07-2815:35thheller@lilactown it complains about tools.reader how? that might just be dependency conflict#2018-07-2815:35lilactown
lilactown.core> (shadow/watch :client)
[:client] Configuring build.
[:client] Compiling ...
:watching
lilactown.core> [:client] Build completed. (132 files, 2 compiled, 2 warnings, 1.72s)

------ WARNING #1 --------------------------------------------------------------
 File: cljs/tools/reader/edn.cljs:121:36
--------------------------------------------------------------------------------
 118 |                    (recur (inc i) (+ d (* uc base)))))))
 119 |            (js/String.fromCharCode uc))))))
 120 | 
 121 | (def ^:private ^:const upper-limit (int \uD7ff))
------------------------------------------^-------------------------------------
 cljs.core/bit-or, all arguments must be numbers, got [string number] instead
--------------------------------------------------------------------------------
 122 | (def ^:private ^:const lower-limit (int \uE000))
 123 | 
 124 | (defn- read-char*
 125 |   [rdr backslash opts]
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: cljs/tools/reader/edn.cljs:122:36
--------------------------------------------------------------------------------
 119 |            (js/String.fromCharCode uc))))))
 120 | 
 121 | (def ^:private ^:const upper-limit (int \uD7ff))
 122 | (def ^:private ^:const lower-limit (int \uE000))
------------------------------------------^-------------------------------------
 cljs.core/bit-or, all arguments must be numbers, got [string number] instead
--------------------------------------------------------------------------------
 123 | 
 124 | (defn- read-char*
 125 |   [rdr backslash opts]
 126 |   (let [ch (read-char rdr)]
--------------------------------------------------------------------------------

#2018-07-2815:35lilactownif I trigger a re-compile this turns into an error#2018-07-2815:35thhellererror how?#2018-07-2815:36thhellerwarning looks legit#2018-07-2815:36lilactown
[:client] Compiling ...
[:client] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/will/.m2/repository/org/clojure/tools.reader/1.0.0-alpha4/tools.reader-1.0.0-alpha4.jar!/cljs/tools/reader/edn.cljs:121:1
--------------------------------------------------------------------------------
 118 |                    (recur (inc i) (+ d (* uc base)))))))
 119 |            (js/String.fromCharCode uc))))))
 120 | 
 121 | (def ^:private ^:const upper-limit (int \uD7ff))
-------^------------------------------------------------------------------------
Can't redefine a constant at line 121 cljs/tools/reader/edn.cljs
--------------------------------------------------------------------------------
 122 | (def ^:private ^:const lower-limit (int \uE000))
 123 | 
 124 | (defn- read-char*
 125 |   [rdr backslash opts]
--------------------------------------------------------------------------------

#2018-07-2815:36thheller1.0.0-alpha4 that is defniitely the wrong version#2018-07-2815:37thhellerwe are up to 1.3.1 I think#2018-07-2815:37eoliphantok, but that still needs to get commonjs’ed or whatever right? I’m poking trhough the npm version of the free one, and say the button class, has all the stuff fixed up that we discussed.
...
var _withStyles = require("@material-ui/core/styles/withStyles");

var _withStyles2 = _interopRequireDefault(_withStyles);

var _Button = require("@material-ui/core/Button");

var _Button2 = _interopRequireDefault(_Button);

var _buttonStyle = require("../../assets/jss/material-dashboard-react/components/buttonStyle");
...
#2018-07-2815:37thheller1.3.0#2018-07-2815:37eoliphantI was thinkign of just dumping the pro source#2018-07-2815:37thheller@eoliphant yeah thats the code I get by running babel#2018-07-2815:37eoliphantoh really?#2018-07-2815:37eoliphantby default?#2018-07-2815:37eoliphantok#2018-07-2815:38thhellerin the checkout directory#2018-07-2815:38eoliphantlet me try it agian#2018-07-2815:38thhellernpm install and then npx babel src -d out#2018-07-2815:38eoliphantah but in the free one#2018-07-2815:38thhelleryeah#2018-07-2815:38eoliphantyeah that’s it#2018-07-2815:38eoliphanti’m gonna drop this pro code#2018-07-2815:38thhellercheck the .babelrc of the pro version#2018-07-2815:38eoliphanton top of ti#2018-07-2815:38eoliphantof it#2018-07-2815:39thhellerit its different for some reason copy the free version over#2018-07-2815:39eoliphantbut your’re saying only babel is required#2018-07-2815:39eoliphantif that’sthe case#2018-07-2815:39thhellerwell webpack is still sort of required for the Dashboard stuff#2018-07-2815:39eoliphantthen I’ll just move the babelrc over#2018-07-2815:39thhellersince that has an image import#2018-07-2815:39eoliphantright because of that#2018-07-2815:39thhellerdunno about the pro stuff#2018-07-2815:39eoliphanti’m less concered about thouse#2018-07-2815:39eoliphanti’m probably gonna just recreate that in cljs#2018-07-2815:41lilactownso when I run lein deps :tree I’m seeing this:
Possibly confusing dependencies found:
[org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]
 overrides
[thheller/shadow-cljs "2.4.24"] -> [org.clojure/tools.nrepl "0.2.13"]

Consider using these exclusions:
[thheller/shadow-cljs "2.4.24" :exclusions [org.clojure/tools.nrepl]]
#2018-07-2815:41eoliphantthough yeah.. I’m just gonna move all the build crap over to the pro dir.. Then I should just be able to point to the build dir as a local repo in my actual projects package.json right?#2018-07-2815:41lilactownI don’t have tools.nrepl in my project.clj <_<#2018-07-2815:42lilactownnor profiles.clj afaict#2018-07-2815:42thheller@lilactown thats always added. but look for tools.reader#2018-07-2815:42thhellerlein itself depends on nrepl#2018-07-2815:42thheller@eoliphant the pro version doesn't have a .babelrc?#2018-07-2815:43lilactownreader only appears once and it’s 1.3.0#2018-07-2815:43eoliphantnope#2018-07-2815:43eoliphantuses all the create-react-app defaults i guess#2018-07-2815:43lilactowntrying this one more time, I just cleared out some unused deps#2018-07-2815:43thheller@lilactown that can't be. the alpha4 must come from somewhere#2018-07-2815:45thhellerremember the profiles in project.clj maybe something in there is responsible. or a plugin.#2018-07-2815:46eoliphantgiven that they have this working for the free one, I guess they were trying to figure out how to handle the paid version, but seems like that would just be a private npm repo, and give you a login when you pay or something#2018-07-2815:48thhellerjust need the .babelrc and the package.json really.#2018-07-2815:48thhellerbower stuff etc is irrelevant#2018-07-2815:49eoliphantyeah will diff the package scripts since the pro has more deps and the lib build stuff isn’t in the pro#2018-07-2815:49eoliphantgonna be a little annoyed if this just works lol, this could have been couple lines in the readme lol#2018-07-2815:52lilactownI’m afraid it’s cider-nrepl middleware#2018-07-2815:53thhellerhmm that should really be using a more recent version#2018-07-2815:53thhellerwhen in doubt just add clojurescript and tools.reader to your deps in case you don't have that#2018-07-2815:53lilactownI’m on a slightly older version of CIDER. the latest uses 1.1.1#2018-07-2815:54thhellerthats still really old#2018-07-2815:54lilactownI hadn’t added clojurescript or tools.reader to my deps yet#2018-07-2815:55lilactownI figured shadow-cljs would handle those for me#2018-07-2815:55thhelleryeah gotta be a bit more careful with deps in project.clj
#2018-07-2815:56thhellerit should work if you list shadow-cljs first#2018-07-2815:56lilactown🙃 I just put tools.reader in my deps and it worked#2018-07-2815:57lilactownFML. that was like an hour of my morning 😂#2018-07-2815:57lilactownshould have just ran shadow-cljs from my terminal. oh well, now I know#2018-07-2815:58thhelleryeah thats why I don't recommend using lein. just too many things you need to watch out for 😛#2018-07-2815:58lilactownI should switch to deps.edn#2018-07-2815:58lilactownis that any less painful?#2018-07-2815:59thhellerwell .. not really ... just different pains#2018-07-2815:59lilactownlol#2018-07-2818:59chazu👋#2018-07-2819:01chazui was trying to find the best way to eval some code on server mode startup last night, and I saw that a config option to run a worker was added for server mode, but it seems to have been removed. Whats the best way to do some eval on server startup?#2018-07-2819:01chazu👋 @iam#2018-07-2819:12eoliphantany one using shadow- with keechma?#2018-07-2819:12eoliphanti’m having some weird problem with the hot reload#2018-07-2819:13eoliphantshadow-cljs is calling the reload func#2018-07-2819:13justinlee@chazbone you could probably use https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-07-2819:13chazu@lee.justin.m thanks! 😄 I’ll get to it!#2018-07-2819:13eoliphantbut the ui isn’t updating#2018-07-2819:14justinleethe only thing is that those hooks will run even when you are just compiling (as opposed to running a server), so you might have to do some detection of the environment#2018-07-2819:14chazuyeah thats alright with me, a little bit of overhead is fine#2018-07-2819:56thheller@chazbone you probably want https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-07-2819:56thhellersee the section below with {:shadow/requires-server true}#2018-07-2819:57thheller@eoliphant thats probably not related to shadow-cljs but what you do in your reload func#2018-07-2819:57thhellermaybe the re-render you are calling just decides to no re-render or stops early#2018-07-2819:58eoliphantwell I just noticed something that I’m working to reproduce, it appears figwheel is pushing one more file than shadow does prior to the reload getting called#2018-07-2819:59eoliphanti’m setting up shadow on the keechma default template app#2018-07-2819:59thhellernever looked at keechma but if you have some code I can look at it would help#2018-07-2820:05eoliphantok yeah just reproduced it. You want the whole project zipped up? but in short, in their template ui/main namespace, there’s a render function. say changing a bit of text in it, causes the following in figwheel
Figwheel: loaded these files
15:27:21.506 utils.cljs?rel=1532803397043:71 ("../keech_proj/ui/main.js" "../keech_proj/ui.js" "../keech_proj/core.js")
and the following in shadow.
shadow-cljs: load JS keech_proj/ui/main.cljs
15:59:49.184 browser.cljs:25 shadow-cljs: load JS keech_proj/ui.cljs
15:59:49.185 browser.cljs:25 shadow-cljs: call keech-proj.core/reload
ui refs ui\main and as you can see the reload func itself is in core
#2018-07-2820:05thhellerI'm gonna need the full code#2018-07-2820:05eoliphantsure#2018-07-2820:06thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection> or some git repo is fine#2018-07-2820:10eoliphantsent to your email. Just jacked shadow into it. Has a shadow-cljs.edn, package.json, etcand changed the name of the .js in the index.html everything else should be more or less as it was generated#2018-07-2820:14thhellerwhats the lein command to run the figwheel version?#2018-07-2820:15thheller
(defn reload []
  (let [current @running-app]
    (println "RESTART" (true? current))
    (if current
      (app-state/stop! current start-app!)
      (start-app!))))
#2018-07-2820:15eoliphantshould just be lein figwheel#2018-07-2820:15thhellerthis might not be correct?#2018-07-2820:16thhellerif current version is running, stop it#2018-07-2820:16eoliphantand you have to change thename of the .js#2018-07-2820:16thhellerso the first call of reload just stops everything but never restarts it?#2018-07-2820:16eoliphantin index.html#2018-07-2820:16eoliphantyeah read weird to me too, but it works in figwheel#2018-07-2820:16thhellerI don't know anything about keechma but that looks suspicious to me#2018-07-2820:17thhellerah nvm, the extra start-app! is probably called once stop finishes#2018-07-2820:17eoliphantyeah that makes sense#2018-07-2820:18thhellerwhere is this shadow-cljs.edn config from?#2018-07-2820:22eoliphanti just copied it over from antoehr one of my projects and stripped the extraneous stuff out#2018-07-2820:22eoliphantadded the deps to match the project.clj etc#2018-07-2820:23thhellerok then go to your other project and take out the hud preload#2018-07-2820:23thhellerthat is really old and not required since forever ago 😉#2018-07-2820:23eoliphantlol gotcha#2018-07-2820:26thhelleralso when copying deps leave out clojure,clojurescript and shadow-cljs itself#2018-07-2820:27thhellerthey will be ignored anyways#2018-07-2820:27eoliphantok, yeah I’d migrated from lein, to shadow, to deps, just carried those foward iguess#2018-07-2820:28thhellerso far I can't see anything from the shadow-cljs side. everything seems to be doing what it should do#2018-07-2820:29eoliphantyeah the only thing i saw, vs figwheel was that fighwheel was repushing the core#2018-07-2820:30eoliphantin addition to the other 2#2018-07-2820:32thhellerah I think I know#2018-07-2820:33thhelleryep thats it#2018-07-2820:34thhellernote the def app-definition in .core. that holds a reference to ui which is a map of the components#2018-07-2820:34thhellersince core is never updated the re-render doesn't change#2018-07-2820:35thhellercore is nore reloaded because its not directly dependent#2018-07-2820:35eoliphantYeah I was wondering if it had something to do with the way it does dependencies#2018-07-2820:35thhellerif you instead turn the def into defn everything works again#2018-07-2820:35eoliphantI see your ^:dev/once option, is there like a ^:dev/always?#2018-07-2820:36eoliphantah#2018-07-2820:36thheller
(defn app-definition []
  (-> {:components    ui
       :controllers   controllers
       :subscriptions subscriptions
       :html-element  (.getElementById js/document "app")}
      (dataloader/install datasources edb-schema)
      (forms/install keech-proj-forms/forms keech-proj-forms/forms-automount-fns)))

(defonce running-app (clojure.core/atom nil))

(defn start-app! []
  (prn "START-APP!")
  (reset! running-app (app-state/start! (app-definition))))
#2018-07-2820:36eoliphantok even better#2018-07-2820:36thhellershadow-cljs doesn't reload ALL dependents like figwheel seems to do#2018-07-2820:36thhellerbecause that can get reaally slow and shouldn't be required#2018-07-2820:37thhellerunless you do something like that where one namespace holds global state from another#2018-07-2820:38thhellercould add a reload-all or something setting but no way I'm making that the default 😛#2018-07-2820:38eoliphantyeah that makes more sense#2018-07-2820:38eoliphantah no#2018-07-2820:38eoliphantlol#2018-07-2820:39thhellerseems to work just fine if you just change it to a defn#2018-07-2820:39eoliphantI was thinking more for cases like this, that perhaps couldn’t be solved as you’ve done it here#2018-07-2820:39eoliphantexceptions not rules lol#2018-07-2820:39thhelleryou are the first to report such a case#2018-07-2820:40thhellerand yes there is a ^:dev/always you can put on the ns#2018-07-2820:41eoliphantlol well then I do feel special lol. Gonna drop a note in their channel as well#2018-07-2820:44thhellerhttps://github.com/thheller/shadow-cljs/issues/349#2018-07-2820:45eoliphantand thanks for the help on that material ui stuff. good lord. lol, literally a like 2 sentence readme would have made most of that avoidable#2018-07-2820:46thhellerah I made a test repo for that btw#2018-07-2820:46thhellerpushed it here: https://github.com/thheller/shadow-mui-dashboard-test#2018-07-2820:46thhelleronly tested the basic components but it seems to work https://github.com/thheller/shadow-mui-dashboard-test/blob/master/src/main/app/views.cljs#2018-07-2820:47eoliphantgotta shoot them a note… so they can add it for the pro or whaever#2018-07-2820:47eoliphantyeah I’ve gotten a page or so done looks prettty fine#2018-07-2921:45prabhath6How does one get hot code reloading in a shadow-cljs project? I found :after-load app.main/reload! on the home page of shadow-cljs added it to my .edn file, but when i change css property of an element in component the browser does not reflect the change, i had to refresh to get the new styling. Is there something else i am missing here.#2018-07-2922:09lilactown@prabhath6 what does your reload! function do?#2018-07-2922:12prabhath6ha, i thought it was some inbuilt function. Do i need add one.#2018-07-2922:13lilactownyes#2018-07-2922:14lilactownshadow-cljs does hot code reloading by default, but it needs to know what to run - you can define a function in any ns and then tell shadow-cljs to run that function before or after reloading your code#2018-07-2922:15prabhath6thanks, do you have any example that i can refer to. I am completely new to clojurescript and shadow-cljs#2018-07-2922:17lilactownsure. there are a number of examples here: https://github.com/shadow-cljs/examples#2018-07-2922:17lilactownthe user guide is also a really good resource: https://shadow-cljs.github.io/docs/UsersGuide.html#2018-07-2922:20lilactownI usually am working with react, so my start! or reload! function usually just re-renders my application#2018-07-2922:21lilactownhere’s a really simple example that I just wrote this morning / last night: https://github.com/Lokeh/lilac.town/blob/master/src/lilactown/client/core.cljs#2018-07-2922:26prabhath6thanks for the input. I was able get it working. I was rendering my application again in the reload function. But i am not sure if this is the right way to do it.
(defn reload! []
  (r/render
   [some-component]
   (.getElementById js/document "app")))

(defn ^:export main
  []
  (r/render
    [some-component]
    (.getElementById js/document "app")))
Can i make it better or is this good enough.
#2018-07-2922:27lilactownUsually I would just call main again in my reload! function so that I don’t have to change it twice 😄#2018-07-2922:27lilactownbut that looks good otherwise#2018-07-2922:28prabhath6i was thinking the same, abstract it and call it in both the methods. Thanks for help :+1:#2018-07-3004:37prabhath6I am having issues connecting to proto-repl in atom. i connected to remote repl and executed (shadow.cljs.devtools.api/nrepl-select :app). Then tried to get into a namespace, but the prompt remains as cljs.user=> it does not change to the new namespace. If i try to access anything from that namespace it returns as nil. Any idea why this is happening. The UI works fine, the only issue is i cannot access anything in repl.#2018-07-3004:41lilactownhow are you getting into the namespace?#2018-07-3004:43prabhath6
(ns lib.data
  (:require [reagent.core :as r]))
pasting this in repl
#2018-07-3004:58prabhath6This is the .edn file.#2018-07-3006:05caleb.macdonaldblackI’m playing around with shadow-cljs watch in a docker container and the live reload is quite slow (around 10-15 seconds). I have my docker resources at CPUs: 7 and memory: 8.0 GiB. On my mac live reload is usually less than a second. It seems to detect the file changes pretty quickly and then takes forever to compile. Would this be down to docker not being as fast as my mac or something else maybe?#2018-07-3007:34thheller@caleb.macdonaldblack this is usually due to the fs-watch not being slow. you can try setting :fs-watch {:watcher :polling} in your shadow-cljs.edn. at the root not in the build config. should be faster at the cost of more resources used.#2018-07-3007:34thhellerif thats not the slow part trying running shadow-cljs watch build --verbose to get more timing infos about where it might be slow#2018-07-3007:35thhellerjust want to rule it out as a problem#2018-07-3007:35caleb.macdonaldblackI saw the issue with that and ive tried fs-watch already. I think it improved the initial detection but was still otherwise slow to compile#2018-07-3007:35thhellersince it has been the most common problem for people running in containers#2018-07-3007:35thhellerah ok#2018-07-3007:35thhellerthen please try running with --verbose to see where its slow#2018-07-3007:36caleb.macdonaldblackIll have a look#2018-07-3007:50thheller@prabhath6 you must always (require 'lib.data) in the REPL first. otherwise (ns lib.data ...) will just set up an empty namespace which won't have any of your functions. to switch to a loaded namespace you should also use (in-ns 'lib.data) instead.#2018-07-3103:09prabhath6thanks for the input. It worked. :+1:#2018-07-3007:54caleb.macdonaldblack#2018-07-3007:54caleb.macdonaldblackAfter restarting my laptop my compile times have improved. Ill run locally outside docker and see what I get#2018-07-3007:55thheller@caleb.macdonaldblack which version are you on? there was a cache issue fixed recently that caused cache to get slower over time#2018-07-3007:55thhellerit looks like thats whats happening to you there#2018-07-3007:55caleb.macdonaldblack2.4.2#2018-07-3007:55thhelleryeah please try upgrading#2018-07-3007:56caleb.macdonaldblack#2018-07-3007:57thhellerit starts out fine but gets slower over time. regardless of running in a container or not.#2018-07-3007:57thhellerit was fixed in 2.4.20+#2018-07-3008:00caleb.macdonaldblackhttps://i.gyazo.com/1d7a8406030d028688b7e7cdd10f2c51.png#2018-07-3008:00caleb.macdonaldblackhttps://i.gyazo.com/6cb2bdb8b787c7b52f802c75e4019ae0.png#2018-07-3008:00caleb.macdonaldblackWe had tried to update briefly in the past but ended up with the above error#2018-07-3008:00caleb.macdonaldblackWe ended up just reverting back#2018-07-3008:00thheller@caleb.macdonaldblack remove shadow-cljs, clojure, clojurescript from your deps#2018-07-3008:02thhelleroh wait nevermind thats a lein config#2018-07-3008:02thhelleryes then bump clojurescript to 1.10.339 as well.#2018-07-3008:05caleb.macdonaldblackhttps://i.gyazo.com/5f1572df0826aea702639d68d9c2d131.png#2018-07-3008:05caleb.macdonaldblackhttps://i.gyazo.com/6b05f8827efefcc7d1940e05cce01aca.png#2018-07-3008:05caleb.macdonaldblackThat’s with just the cljs bump#2018-07-3008:05thhellerdid you lein clean just in case?#2018-07-3008:05caleb.macdonaldblackNope Ill try#2018-07-3008:06thhellerFWIW try moving shadow-cljs,clojure,clojurescript to the top#2018-07-3008:08caleb.macdonaldblackThe ordering seems to have fixed that#2018-07-3008:08caleb.macdonaldblackI had know idea the ordering mattered.#2018-07-3008:09thhelleryeah transitives dependencies are weird. the first one encountered is chosen, not the latest version. lein doesn't resolve conflicts very well#2018-07-3008:09thhellerdeps.edn does a better job there#2018-07-3008:13caleb.macdonaldblackhttps://i.gyazo.com/c8947a066f5b45b6419da541d8f1685e.png#2018-07-3008:13caleb.macdonaldblackhttps://i.gyazo.com/fd2ffc9031cc9c59a8cf562ba316f138.png#2018-07-3008:13caleb.macdonaldblackahh#2018-07-3008:13caleb.macdonaldblackOkay so there is a comparison between docker container and my mac#2018-07-3008:14thhellerhmm#2018-07-3008:14thhellerseems like the disk is really slow#2018-07-3008:15caleb.macdonaldblackAlso there doesn’t seem to be any difference before and after the update. But based on what you said ealier it seems like the update will help for longer running shadow-cljs processes#2018-07-3008:15caleb.macdonaldblackThis could be it#2018-07-3008:15caleb.macdonaldblackI am mapping a volume here. I will try in docker without a mapped volume#2018-07-3008:16caleb.macdonaldblackI looks like it’s probably the docker configuration causing the slow downs here.#2018-07-3008:16thhellercheck how big .shadow-cljs/builds/caleb/dev/ana/medial_web/core.cljs.cache.transit.json is just in case#2018-07-3008:17thhellermaybe its getting bigger than it should be? but since its only happening in the container I'm just guessing a slow disk in the container#2018-07-3008:27caleb.macdonaldblack[:caleb] Build completed. (381 files, 2 compiled, 0 warnings, 0.35s) with no mapped volume#2018-07-3008:27caleb.macdonaldblackin a container#2018-07-3008:27thhellersweet#2018-07-3008:27caleb.macdonaldblackSo I think what Ill do is just map the src directories as read only volumes#2018-07-3008:27caleb.macdonaldblackShould be fast as then#2018-07-3008:28caleb.macdonaldblackAs always thanks for your help @thheller. You’re awsome!#2018-07-3015:56lilactownthheller, do you have a patreon or some other way that we could buy you a lunch / coffee / beer? 😄#2018-07-3016:02thhellerI did start to setup a patreon but kinda got stuck since I don't really know what to do with it 😉#2018-07-3016:11richiardiandreaThere are also other programs in the crypto space like gitcoin or status's bounty that are interesting and easy to setup - just an FYI#2018-07-3016:12richiardiandreaDifferent I know but imho more effective than patreon for one time donations#2018-07-3016:13lilactowneither way, put it on your github / site and you'll at least get a meal out of me#2018-07-3016:13richiardiandreaMore effective because the maintainer can claim the bounty/prize on issue and everybody wins :i_love_you_hand_sign:#2018-07-3017:09kurt-o-sysmaybe I'm missing something, but when I do an app release with some specific preloads/`compiler-options`, my app doesn't always seem to run. It runs fine in non-release mode.
{:lein     true
 :jvm-opts ["--add-modules" "java.xml.bind"]
 :nrepl    {:port 3333}
 :builds   {:app {:target           :browser
                  :output-dir       "resources/public/js"
                  :asset-path       "/js"
                  :modules          {:main {:entries [ui-app.core]}}
                  :compiler-options {:closure-warnings {:global-this :off}
                                     :closure-defines  {"re_frame.trace.trace_enabled_QMARK_"        true
                                                        "day8.re_frame.tracing.trace_enabled_QMARK_" true}}
                  :devtools         {:http-root "resources/public"
                                     :http-port 3449
                                     :preloads  [shadow.cljs.devtools.client.hud
                                                 devtools.preload
                                                 day8.re-frame-10x.preload]}}}}
The problem most probably is the re-frame-10x-dashboard/hud. Since I'm not using devtools and dev-mode is off in release mode, there seem to be issues with that dashboard, giving a null where there shouldn't be one. My question actually is: can you make compiler-options specific to the environment. Now, it defines some closure-defines. I'm not sure if that's the problem, switching them off when not in dev-mode, may solve the problem (I think).
#2018-07-3017:16lilactownyou can set compiler-options based on dev vs release#2018-07-3017:18lilactownthere's an example in the user-guide using closure defines: https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2018-07-3017:20kurt-o-sys:+1: what I was looking for (I think)#2018-07-3019:44thheller@kurt-o-sys there is also https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration but I guess the closure-defines chapter covers that more or less too#2018-07-3021:03dnolenI’m getting with familiar with existing shadow-cljs usage on a client project - is in-ns usage supposed to be a bit slow?#2018-07-3021:03thhellernot that I know of no?#2018-07-3021:04dnolenhrm I keep seeing it take 4-5 seconds#2018-07-3021:04dnolenand Timeout while waiting for REPL result.#2018-07-3021:04dnolenin the watch terminal I see#2018-07-3021:04dnolenstuff like client sent unknown msg {:type :repl/set-ns-complete, :id 9, :ns ...}#2018-07-3021:06thhelleruhm which REPL are you using?#2018-07-3021:06dnolenunrelated - is there any documentation on using shadow w/o nREPL? i.e. I just want to run a shadow-build / REPL via Clojure code, or wire up to Component, yadda, or you are on you own?#2018-07-3021:06dnolen@thheller shadow-cljs cljs-repl ...#2018-07-3021:06thhellersee shadow.cljs.devtools.api ns#2018-07-3021:06thhellerbasically shadow-cljs compile build is identical to calling (shadow.cljs.devtools.api/compile :build)#2018-07-3021:07thhellersame for watch/release/etc#2018-07-3021:07dnolensame for REPL?#2018-07-3021:07thhelleryep#2018-07-3021:08dnolenk, any insight onto the ns switching issue?#2018-07-3021:08thhellerwhich version are you on?#2018-07-3021:08thheller
$ shadow-cljs cljs-repl browser
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn  cli version: 2.4.22  node: v9.4.0
shadow-cljs - connected to server
[1:1]~demo.browser=> (in-ns 'cljs.core)
nil
[1:1]~cljs.core=>
#2018-07-3021:08thhellerno problem here#2018-07-3021:09dnolenthat’s probably it#2018-07-3021:09dnolen2.1.1 I think#2018-07-3021:09thhelleruh yeah thats quite old#2018-07-3021:09thhellerthere was something related a while ago so thats probably it#2018-07-3021:10thheller2.4.24 is current#2018-07-3021:11dnolenk and I see *nrepl-active* is false by default, so I don’t need to worry about it#2018-07-3021:12thhellerbtw you can totally skip the entire npm shadow-cljs command if you prefer to just use tools.deps + clj#2018-07-3021:12thhellerclj -m shadow.cljs.devtools.cli compile build is identical to shadow-cljs compile build#2018-07-3021:12thhelleryou just miss out on the built-in server mode support#2018-07-3021:13dnolenah nice#2018-07-3021:13thhellerthe npm package should still be installed though since it brings in some required deps like source-map-support, node-libs-browser and so on#2018-07-3021:13dnolengot it#2018-07-3021:15thhellerI'm working on a guide for CLJ users familiar with lein,deps.edn etc#2018-07-3021:15thhellersince most of the docs are currently written from the npm perspective#2018-07-3021:15thhellershould be done soon. might answer some of questions you probably have right now 😉#2018-07-3021:17dnolencool, yes that would be useful, but having the api answers a lot of questions#2018-07-3021:17dnolenin-ns issue is gone after bumping - thanks!#2018-07-3021:26Logan Powellare there any disadvantages to using the :lien true setup with Shadow in Cursive/Idea?#2018-07-3021:27Logan Powellbtw, very excited to see David Nolen taking interest in Shadow!#2018-07-3021:27thhellerI guess dependency management is a bit more complicated. the shadow-cljs command eliminates some of the most common problems which you have to do manually with lein#2018-07-3021:28thhellerie. ensuring compatible clojure,clojurescript,closure-compiler versions etc#2018-07-3021:28thhellerbeyond that its totally fine and will have the same results#2018-07-3021:28Logan PowellI see, so it would be better to just duplicate the setup with shadow.edn + project.clj#2018-07-3021:29Logan Powellnot a big deal at all, just curious#2018-07-3021:29thhellerdepends. many people like running shadow-cljs embedded in the main CLJ JVM so they only have to worry about running one JVM that does it all#2018-07-3021:29thhellerI prefer running things side by side since CLJ and CLJS don't really need anything from each other technically#2018-07-3021:30thhellerso if you prefer embedded its easier to just stick with just project.clj#2018-07-3021:30Logan PowellI'm rather new to the entire clj/s game really, so I don't have any legacy preferences#2018-07-3021:31thhellerup to your preference I guess. I recommend running shadow-cljs standalone since thats avoid a whole world of potential dependency conflicts#2018-07-3021:32Logan Powellok, but just to make sure I understand, in the docs https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive it mentions that I can "create a dummy project.clj or use the full Leiningen integration". I'm just trying to understand what the tradeoffs would be#2018-07-3021:32thhellerfor cursive I usually just do shadow-cljs pom and create a new project from the generated pom.xml#2018-07-3021:34Logan Powellok, that will handle everything then? (I'm new to Intellij as well... I actually wrote up an entire article about using Shadow with Atom, but Atom couldn't handle the amount of data I was trying to parse 😄 so I had to up my IDE)#2018-07-3021:34thhellerI'm working on properly documenting all this stuff. its all a bit lacking at the moment.#2018-07-3021:34thhelleryes. its mostly about properly handling dependencies and the pom.xml takes care of that#2018-07-3021:34thhellerjust need to manually run shadow-cljs pom whenever you change dependencies#2018-07-3021:34Logan Powellno worries, it's a lot to take on, so many different IDEs, but shadow's been working like a charm for me so far (using NPM like a boss), so it's totally worth the time#2018-07-3021:35Logan Powellgotcha, thank you!#2018-07-3021:49Logan PowellSorry, I'm getting Cannot import anything from C:/Users/Surface/Projects/clojure/cljs/census-geojson/pom.xml when trying that#2018-07-3021:50thhellerah. you need to have the maven support plugin active. for some reason that is disabled for some people.#2018-07-3021:51Logan Powellah, ok#2018-07-3021:51thhellergo into the plugin options and install the "Maven Integration" plugin#2018-07-3021:59Logan PowellThat seems to have done it#2018-07-3103:25prabhath6I was wondering if its possible to change an Atom in proto-repl and then show the updated state in page?#2018-07-3105:30bupkisAfter upgrading to shadow-cljs 2.4.25, I started getting the following warnings upon starting a watch:#2018-07-3105:31bupkis
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see clojure.tools.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'refactor-nrepl.middleware/wrap-refactor, see nrepl.middleware/set-descriptor!
#2018-07-3105:31bupkis
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-apropos, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-classpath, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-complete, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-debug, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-enlighten, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-format, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-info, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-inspect, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-macroexpand, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-ns, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-out, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-content-type, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-slurp, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-pprint-fn, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-profile, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-refresh, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-resource, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-spec, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-stacktrace, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-test, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-trace, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-tracker, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-undef, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.nrepl/wrap-version, see nrepl.middleware/set-descriptor!
#2018-07-3105:31bupkisI guess it's connected to the upgrade to the new nrepl?#2018-07-3105:33bupkisI have
[cider/cider-nrepl "0.18.0-SNAPSHOT"]
                [refactor-nrepl "2.4.0-SNAPSHOT"]
in my shadow-cljs.edn, together with :nrepl { :middleware [refactor-nrepl.middleware/wrap-refactor]}
#2018-07-3105:34bupkisRemoving refactor-nrepl doesn't have any effect on the warnings#2018-07-3105:37bupkisthe new nrepl also breaks fireplace (unrelated to shadow-cljs of course) so I guess I'll roll back to the previous version of shadow-cljs for now#2018-07-3107:27tiensonqin@samuel.wagen Yeah, I have the same problem too.#2018-07-3107:32thhellerhmm crap#2018-07-3108:03thhellergreat .. it works without the cider-nrepl. I thought that was already upgraded but I guess not.#2018-07-3108:07tiensonqinawesome!! I'll give it a try.#2018-07-3108:08thhellerI'll try another approach. this stuff is supposed to be backwards compatible but my check for that is not reliable enough#2018-07-3108:08thhellerthe refactor-nrepl middleware is also not nrepl 0.4+ compatible.#2018-07-3108:10tiensonqinYeah, it could connect to cljs repl. But auto-complete and other features won't work since no dependent of cider-nrepl.#2018-07-3108:10tiensonqinI could just downgrade version, anyway this is very cool.#2018-07-3108:10thhelleryeah since @bozhidar was the one pushing for the 0.4+ upgrade I thought that cider-nrepl was already upgraded#2018-07-3108:10thhellerbut I just saw that that is not the case#2018-07-3108:12tiensonqinoh, I tried to add
(middleware/set-descriptor!
 #'cider.piggieback/wrap-cljs-repl
 {:requires #{}
  :expects #{}
  :handles {}})
#2018-07-3108:12tiensonqinbut sooner I find you already did that in the fake ns.#2018-07-3108:12thhelleryeah the issue it that both nrepl versions are loaded#2018-07-3108:12thhellerand the middleware is registered with the wrong version#2018-07-3108:13thhellerie. a different version than the actual server being used#2018-07-3108:13tiensonqincool, learned something, 👍#2018-07-3108:15tiensonqinBtw, I encountered some error like "Duplicate parameter name "xxx"", it seems that cljs compiler generated wrong code. I have to change some symbol names to work around, and that's the reason that I upgraded shadow-cljs.#2018-07-3108:15tiensonqinhaven't met that error before.#2018-07-3108:16thhellerhmm not sure I know the error you are talking about?#2018-07-3108:17thhelleryou can use 2.4.24 for now. the .25 version only changed the nrepl support.#2018-07-3108:17tiensonqinI should create a minimal reproduce case. cool#2018-07-3108:18tiensonqinhttps://github.com/emezeske/lein-cljsbuild/issues/432#2018-07-3108:22thhellerthats a really old issue and the fix for that is not relevant to shadow-cljs#2018-07-3108:23tiensonqinYeah, it's not related to shadow-cljs, I shouldn't post it here.#2018-07-3108:24thhellerif you have the full error that would help#2018-07-3108:24tiensonqinthanks, I'll create a minimal case later.#2018-07-3109:06thheller@tiensonqin @samuel.wagen try 2.4.26 if you get a chance. it now hopefully detects things correctly.#2018-07-3109:06tiensonqin@thheller great!#2018-07-3109:07thhellerI really don't like that they completely destroyed any kind of compatibility with the version upgrade#2018-07-3109:10tiensonqinDo they say that on changelog? There're 2 things that I don't want to upgrade: 1. react native 2. cider-nrepl#2018-07-3109:11thhellerhttps://github.com/thheller/shadow-cljs/issues/348#2018-07-3109:11thhellerI just falsely assume that he wanted the upgrade due to cider-nrepl using the newer version#2018-07-3109:23tiensonqin@thheller 2.4.26 works for me!#2018-07-3109:34bupkis@thheller just tried it, it works for me too and doesn't break vim-fireplace as 2.4.25 did.#2018-07-3109:35bupkisdid you release it from a private repo though, because I can't see a commit in github and was curious what you did#2018-07-3109:35thhelleroops sorry. just forgot to push.#2018-07-3109:36thhellerhttps://github.com/thheller/shadow-cljs/commit/98fb3d2fb9475f4f1da5aa42f96074a9fb722868#2018-07-3109:40bupkisoh now I see. I didn't know Cursive wasn't using nREPL, that explains it.#2018-07-3109:41thhellerit does support nrepl. just doesn't use any middleware.#2018-07-3109:41bupkiserr, cider-nrepl#2018-07-3109:41bupkisyeah that's what I meant#2018-08-0114:38haywoodis there a way I can add a package to my classpath when using shadow and deps? I need to include cider/nrepl v0.18 without hardcoding it in deps.edn#2018-08-0114:50lilactownhow are you running shadow-cljs?#2018-08-0114:53haywoodthrough npm run#2018-08-0114:54haywoodI could create a cider alias and#2018-08-0114:55haywoodwondered if there was anything I could do globally, sort of like lein user profiles#2018-08-0114:57lilactownI think you can set global aliases#2018-08-0114:58lilactownit’s funny, I literally just started digging into deps.edn#2018-08-0114:59thheller@haywood you can run shadow-cljs -d cider/cider-nrepl:version ...#2018-08-0115:00haywoodgotcha, thanks Thomas#2018-08-0115:00lilactownhttps://clojure.org/reference/deps_and_cli#_directories also says that it will check $HOME/.clojure/deps.edn#2018-08-0115:00haywoodahh#2018-08-0115:01lilactownso that’s probably what I’m going to do - setup a :cider alias#2018-08-0115:01lilactownI was wondering what kind of support cider had for deps.edn already, I know it automatically injects the nrepl middleware and all that for leiningen#2018-08-0115:02thhellerit injects automatically for shadow-cljs too#2018-08-0115:03thhellervia -d which is also passed along to deps if you use :deps#2018-08-0115:03lilactownI noticed a weird thing: when I launched and connected to my app via cider, and then manually started shadow-cljs, it wouldn’t allow me to connect to a cljs repl#2018-08-0115:03lilactownwhich I kind of expected#2018-08-0115:04lilactownbut when I set up my dev profile to automatically start shadow-cljs, suddenly it was dropping me in shadow.user on startup and I could connect to CLJS REPLs 😄#2018-08-0115:04lilactown(using lein)#2018-08-0115:05lilactownI’m not unhappy about it, it was just surprising - I didn’t know what was going on. still don’t. but I’m guessing it’s some sort of CIDER + shadow-cljs magic
#2018-08-0115:06thhellerI don't understand what you are saying#2018-08-0115:06thheller"launched and connected to my app via cider" meaning your CLJ app?#2018-08-0115:06lilactownyes#2018-08-0115:06lilactownusing whatever magic cider-jack-in does#2018-08-0115:07thhelleryeah but if you start shadow-cljs separately then it will be a difference JVM#2018-08-0115:07thhellerand thus a completely different nrepl server#2018-08-0115:07thhellerso from your CLJ repl you can't talk to the CLJS repl since its elsewhere#2018-08-0115:08thhellerI dont know anything about cider so no idea how it handles multiple connections#2018-08-0115:08lilactownpreviously, I was starting shadow-cljs by running cider-jack-in, then requireing the shadow server et. al., starting it and running a build#2018-08-0115:11haywooda bit of FUD, but I think it's all working when adding the cider version to my global .clojure/deps.edn. I upgraded emacs and a bunch of stuff yesterday, and all of a sudden my .cljs files weren't connected to my cljs repl instance. when evaling I'd get something like cannot call stringp of nil, where nil was the cider cljs connection#2018-08-0115:15lilactownand it was fixed by upping your nrepl version?#2018-08-0115:16haywoodthere was a mismatch between cider versions in emacs and the project#2018-08-0115:16haywoodso pinning the cider version in the project to the one in emacs seems to have fixed it#2018-08-0115:12lilactownfor whatever reason I couldn’t switch into a CLJS REPL, I can’t remember why. but after setting up lein to automatically start the shadow server and my build, it started working ¯\(ツ)/¯#2018-08-0115:12thhellerYou can't switch to a CLJS REPL is CLJS is running in a different VM#2018-08-0115:13thhellerunless you open a second connection but AFAICT cider only expects to run over one connection#2018-08-0115:13thhellerso if its connected to your CLJ app via jack-in it won't find the CLJS one#2018-08-0115:15lilactownI was starting shadow server in my jacked-in REPL though#2018-08-0115:16lilactownI’m not reporting a bug or anything, it was just weird. I can try and reproduce it again if you are curious#2018-08-0115:16thhellerah I thought "manually started shadow-cljs" means separately#2018-08-0115:17lilactownyeah sorry. imprecise language#2018-08-0119:55lilactownshould this work?
;; deps.edn
:aliases
 {:dev {:extra-deps {thheller/shadow-cljs {:mvn/version "2.4.24"}
                     binaryage/devtools {:mvn/version "0.9.10"}}
        :extra-paths ["dev"]}}
clj -A:dev -m shadow.cljs.devtoools.cli release client
#2018-08-0119:56thhellerapart from making a release build from a dev profile yes 😉#2018-08-0119:57lilactown😛 just trying to get things to work!#2018-08-0119:57lilactowni’m getting this error:
clj -A:dev -m shadow.cljs.devtoools.cli release client
2018-08-01 12:57:06.920:INFO::main: Logging initialized @11265ms
Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtoools/cli__
init.class or shadow/cljs/devtoools/cli.clj on classpath.                                            
#2018-08-0119:58lilactownif I run clj -A:dev and then (require '[shadow.cljs.devtools.cli]), it requires it just fine#2018-08-0119:58thhelleroh .. three o#2018-08-0119:58lilactown:face_palm:#2018-08-0119:58thhellerpicard-facepalm#2018-08-0119:58lilactownthank you for putting up with me @thheller 😄#2018-08-0119:59thhellerI'm thinking about dropping the devtools package for the .api, .cli and .server namespace#2018-08-0120:00thhellerjust shadow.cljs.cli would look so much better 😉#2018-08-0120:00lilactownthat would honestly be pretty nice#2018-08-0120:00lilactownI type that namespace a lot 😆#2018-08-0120:02thhellerI think you can add :main-opts ["-m" "shadow.cljs.devtools.cli"] to the dev profile#2018-08-0120:03thhellerthen its just clj -A:dev release client#2018-08-0120:03thhellermight be a different name though. not exactly sure.#2018-08-0120:07lilactownnice. I’ll probably setup a :release alias now. just needed to sanity check my understanding of clj#2018-08-0120:14lilactownactually this is dumb. this is going to to load my whole app classpath in order to execute shadow-cljs#2018-08-0120:15lilactown🤔 if I set :deps true in my shadow-cljs.edn, and give it an alias, will it also load all of the top-level :deps in deps.edn?#2018-08-0120:16lilactownI assume so, which means if I want to use shadow-cljs using deps.edn I need to separate my clojure app deps from my client app deps and put them in separate aliases#2018-08-0120:28dfcarpenterDoes anyone know how I could use something like https://css-blocks.com/ with a reagent project running on shadow-cljs?#2018-08-0120:43thheller@lilactown what exactly is your goal? if you are going to separate deps anyways why not keep CLJS deps in shadow-cljs.edn?#2018-08-0120:43lilactownjust messing around with deps.edn basically#2018-08-0120:44lilactowntrying to figure out how it works and how it fits into my workflow#2018-08-0120:46thheller@dfcarpenter I use this myself https://github.com/thheller/shadow/wiki/shadow.markup but all the CSS-in-JS(ish) tools will be rather hard to integrate and are currently not supported#2018-08-0120:47thhellermostly due to them being written in JS and expecting JS code#2018-08-0120:47dfcarpenter@thheller Yeah, I was taking a closer look at it and it seems unfeasable. I might just resort to the standard separate SCSS tooling#2018-08-0120:48thhelleryeah I do have plans for something scss related so that should become easier hopefully#2018-08-0120:52lilactownCSS-in-JS seems to work just fine for me#2018-08-0120:53thhelleryeah some work ok-ish but some require way too much compiler tuning#2018-08-0120:57lilactownwe use emotion.sh at work - it’s real good#2018-08-0120:57lilactownI think it depends on if it’s a true “CSS-in-JS” or requires some compiling#2018-08-0120:58thhelleremotion.sh is one of those things that clearly shows how shit the JS syntax is#2018-08-0120:59thhellersame as graphql .. whats with all the strings ... 😛#2018-08-0121:16lilactownit’s pretty great with EDN on top 😉#2018-08-0121:20dfcarpenter@lilactown Do you have a gist or example somewhere I can look at?#2018-08-0121:22mattlyI'd love to see this too#2018-08-0121:25lilactownI posted on reddit about this a little while ago: https://www.reddit.com/r/Clojure/comments/8vn6lr/new_clojurians_ask_anything/e1u5qgn/?context=1#2018-08-0121:26lilactownHere's a gist of the code 😛 https://gist.github.com/Lokeh/5ecb2f77c4a488bc37cf347fe6edfe56#2018-08-0121:27lilactownit's literally just: (css/edn {:font-size "14px" :&:hover {:color "blue"}})#2018-08-0204:35mattlyok this is really nice to work with#2018-08-0204:39lilactown😄 we really like it. been using it at work for about 5 months since the start of our project#2018-08-0211:24SchpaaThe shadow-CLJS manual is 20000 words long#2018-08-0213:24thhellerso much left to add still 😞#2018-08-0213:38henrik@thheller Draw a picture. A picture says more than 1000 words. Or even better: upload an interpretive dance! I’m sure that says more than 20000 words.#2018-08-0213:44thhellerI wish 😛#2018-08-0215:16pezI’m having trouble with release building of a node library target. Getting
TypeError: a.Ga is not a function
extensionHostProcess.js:452
    at Object.ih [as greetings_activationGreetings] (/Users/pez/.vscode/extensions/cospaia.clojure4vscode-1.3.33-TS-CLJS/out/lib/calva.js:276:520)
    at activate (/Users/pez/.vscode/extensions/cospaia.clojure4vscode-1.3.33-TS-CLJS/calva/extension.ts:114:14)
I don’t get this if I build with compile. What is the most obvious thing I could have missed? I have release building working in another vscode extension project (Calva Formatter) and am trying to use the same build pipeline in Calva…
#2018-08-0215:17thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/15/externs-the-bane-of-every-release-build.html#2018-08-0215:17lilactown#2018-08-0215:17thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#externs#2018-08-0215:22thheller@pez if you prefer not to deal with externs you can set :compiler-options {:optimizations :simple} although I do recommend trying :compiler-options {:infer-externs :auto} first#2018-08-0215:36pezThanks! (I was looking for where functions in my library were not properly exported… 😃 ) I could get past the first hurdle by adding a type hint. Now will see if :infer-externs does the trick. I should get less of these problems once I have factored the code better between what I do in TypeScript code and what I do in ClojureScript code.#2018-08-0215:58pez@thheller: I will be moving Calva development to implementing more and more of the “business rules”/logic in CLJS and do the integration in VSCode in TypeScript. (Building the whole extension using shadow-cljs worked, but meant that I couldn’t use the debugger for all that JS code that still remains to be ported and I can’t afford the slowdown in development that that brought.) Anyway, so I will build the logic as a node library using shadow-cljs. Thing is the library API will get pretty “fat”/have many functions. Since namespacing is dropped, I am now trying with prefixing the function names. Is there a cleaner way, that you can see?#2018-08-0215:59thhelleryou can use :npm-module so the TS part can import namespace separately when required#2018-08-0216:07pezWow, seems the convenience mode should work for me.#2018-08-0216:08thhellerwell not if you plan on deploying the code anywhere#2018-08-0216:08thhellerwell, if you publish under your own package name that can do it of course#2018-08-0216:15pezThe code will be deployed anywhere the Calva extension is installed, so I will have to learn some about building npm modules, I guess. But the name spacing it allows is so much nicer than what I have now, so I’m happy to investigate.#2018-08-0216:52thheller@pez you can just make it part of your calva stuff#2018-08-0216:54thhellerits basically just a directory you need. it doesn't have to be entirely separate package#2018-08-0217:26bupkisI'm trying out Cursive. And I decided to also try out :node-script at the same time, since I just want to play around with ClojureScript and Cursive's REPL integration. I've written a minimal shadow-cljs.edn, ran npx shadow-cljs pom, left a running npx shadow-cljs server in a terminal, imported pom.xml into Cursive, connected to the REPL, I am able to do (shadow/watch :the-id) and and then (shadow/nrepl-select :the-id) - Cursive recognizes it at that point as a CLJS REPL. But if I try to evaluate anything - I get "No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript"#2018-08-0217:26bupkisSo I guess :node-script isn't the best option for that kind of experimentation, do I really need to switch to :browser and keep a browser running even though I just want to play around with the language itself?#2018-08-0217:27thhellerjust use (shadow/node-repl) instead#2018-08-0217:28thhellerotherwise you need to actually run the node script manually. ie. call node the-script.js#2018-08-0217:29bupkisoh I see. I read that section of the manual, but had a brain fart and didn't think it applies to me. In that case I don't even need to tell shadow to watch the app, since I'm sending code to the repl via cursive and not running the compiled output, right?#2018-08-0217:30thhellernode-repl doesn't watch yes. :node-script does.#2018-08-0217:30bupkisREPL command timed out#2018-08-0217:31bupkislet me restart Cursive just in case#2018-08-0217:31thhellerwhat command?#2018-08-0217:31bupkisjust what Cursive output when I told it to switch the REPL namespace to the current file's one#2018-08-0217:33bupkisand shadow-cljs shows [:did-not-find myns.core]#2018-08-0217:34bupkisJust to be sure I'm doing it right: generate pom, import pom into cursive; start shadow-cljs server; start cursive nrepl connection; issue (shadow/node-repl) - at that time cursive shows that it is in CLJS repl. but then setting the REPL namespace fails#2018-08-0217:34thhellerdid you require it first?#2018-08-0217:36thhelleryeah I can reproduce with (in-ns 'ns.that.wasnt.loaded-yet)#2018-08-0217:36thhellerguess cursive just sends a blank in-ns#2018-08-0217:36bupkisI tried loading the file in the repl (via Cursive's REPL / Load file in REPL) and got the following:#2018-08-0217:37bupkis
Loading src/myns/core.cljs... repl/require failed { Error: ENOENT: no such file or directory, open '/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/clojure.set.js'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:348:35)
    at global.SHADOW_IMPORT ([stdin]:45:15)
    at Object.shadow$cljs$devtools$client$node$closure_import [as closure_import] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:33:4)
    at Object.shadow$cljs$devtools$client$node$repl_require [as repl_require] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:61:7)
    at shadow$cljs$devtools$client$node$process_message (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:122:6)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
    at WebSocket.<anonymous> (/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:159:12)
    at WebSocket.emit (events.js:182:13)
    at Receiver._receiver.onmessage (/Users/bupkis/dev/myns/node_modules/ws/lib/WebSocket.js:141:47)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path:
   '/Users/bupkis/dev/myns/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/clojure.set.js' }
done
#2018-08-0217:39bupkisif I require it manually in the REPL - loading the file afterwards works fine#2018-08-0217:40thhellernot a clue whats happening. the recent nrepl change seems to have messed up something on my side and I can't use nrepl anymore#2018-08-0217:40thhellergod dammit I hate nrepl so much#2018-08-0217:40bupkisI wonder if connecting from Cursive to the socket-repl with something like tubular would be better#2018-08-0217:40bupkisnot sure if Cursive supports socket repl at all#2018-08-0217:41thhelleryou can create a clojure.main config and set parameters to -m shadow.cursive-repl#2018-08-0217:41bupkisbut tubular goes around that#2018-08-0217:41thhellerthat will automatically connect to the running shadow-cljs server#2018-08-0217:41bupkislet me try that#2018-08-0217:46thheller
[2:1]~cljs.user=> (require 'demo.script)
nil
[2:1]~cljs.user=> (in-ns 'demo.script)
nil
[2:1]~demo.script=> 
#2018-08-0217:46thhellerthis works for me. thats all I know 😛#2018-08-0217:47bupkisyeah if I require it first, then load-file works#2018-08-0217:48bupkisbtw. the clojure.main with -m shadow.cursive-repl raises an exception#2018-08-0217:49bupkishttps://pastebin.com/xbXkAHQy is the stack trace#2018-08-0217:49thhellerthats all?#2018-08-0217:50thhellerthe only interesting bit is missing 😛#2018-08-0217:50bupkisyeah just noticed cursive didn't copy it#2018-08-0217:50bupkishad to expand manually#2018-08-0217:50bupkis
at java.util.Formatter.checkText(Formatter.java:2579)
	at java.util.Formatter.parse(Formatter.java:2565)
	at java.util.Formatter.format(Formatter.java:2501)
	at java.util.Formatter.format(Formatter.java:2455)
	at java.lang.String.format(String.java:2940)
	at clojure.core$format.invokeStatic(core.clj:5684)
	at clojure.core$format.doInvoke(core.clj:5678)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at shadow.cursive_repl$get_socket_port.invokeStatic(cursive_repl.clj:25)
	at shadow.cursive_repl$get_socket_port.invoke(cursive_repl.clj:10)
	at shadow.cursive_repl$repl.invokeStatic(cursive_repl.clj:31)
	at shadow.cursive_repl$repl.invoke(cursive_repl.clj:29)
	at shadow.cursive_repl$_main.invokeStatic(cursive_repl.clj:93)
	at shadow.cursive_repl$_main.invoke(cursive_repl.clj:87)
	at clojure.lang.AFn.applyToHelper(AFn.java:154)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.core$apply.invokeStatic(core.clj:657)
	at clojure.main$main_opt.invokeStatic(main.clj:317)
	at clojure.main$main_opt.invoke(main.clj:313)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)
#2018-08-0217:51thhellerhehe oops. never had that error so I never noticed#2018-08-0217:51thhellerare you in the correct directory? and is the shadow-cljs server instance running?#2018-08-0217:51thhellerthe error above is just a missing .shadow-cljs/socket-repl.port file which should exist when the server is running#2018-08-0217:52bupkisyes the file is there and the port is the correct one. the run configuration for that clojure repl has the working dir set correctly#2018-08-0217:53thhelleroh hehe . that script is really old#2018-08-0217:54thhelleryou can set :cache-root ".shadow-cljs" in your shadow-cljs.edn#2018-08-0217:54thhellerI'll modernize the script a bit#2018-08-0217:57bupkisyeah that works#2018-08-0217:57bupkisbut I think I'll stay with the nrepl way and manually requiring the NS before trying to load the modified file in the repl#2018-08-0217:57bupkisthe autocomplete is busted in the cursive-repl mode#2018-08-0217:58bupkisbut that's probably cursive's fault#2018-08-0217:58thhellerI'll try to figure out what happened to my nrepl stuff#2018-08-0217:58thhellerthen I can test whats actually going on#2018-08-0217:59bupkisI know you're busy so no worries, the node-repl thing is a working solution#2018-08-0218:00bupkisbtw. is :node-script the best way to do what I'm trying to - e.g. to have a live repl in Cursive that I can load files into and play. It's not a problem to run some Node process manually outside of Cursive if need be, I'm already running the server so one more won't hurt hehe#2018-08-0218:01thhellerno node-repl is better for that#2018-08-0218:02thhellerunless you also want the node script to actually do something itself#2018-08-0218:02thhellerif you just want the REPL then node-repl#2018-08-0218:02bupkisthanks 🙂#2018-08-0218:05lilactownthheller, how hard do you think it would be for someone to carve out a pared down version of shadow-cljs that just built code? as in no watcher, repl, etc.#2018-08-0218:06lilactownI think it would be very useful for running on e.g. a toaster jenkins or gitlab runner#2018-08-0218:07thhellerwhats wrong with shadow-cljs compile?#2018-08-0218:07thhellerthat doesn't start any watchers or anything?#2018-08-0218:08lilactownIME when running on CI, starting the shadow-cljs process to run shadow-cljs release app takes the majority of the time spent on that task#2018-08-0218:08lilactownthinking of ways to optimize the startup time#2018-08-0218:08thhelleryou never reported back with any actual startup times#2018-08-0218:08thhellerdid you address the caching issues?#2018-08-0218:09lilactownI did address the caching issue, and that sped up the building of the code itself a bit. but the startup can still be in the ~3-5 min range#2018-08-0218:10thhellerdo you have shell access to the box running the stuff?#2018-08-0218:10lilactownobviously it gets worse the more jobs that are running. we’re working on getting beefier CI servers and some other enhancements#2018-08-0218:11lilactownprobably not; it’s a docker container running I’m-not-sure-where tbh#2018-08-0218:11thhellerare you using deps.edn yet?#2018-08-0218:12lilactownnot at work, no. we’re using leiningen, but I didn’t notice any changes between using regular shadow-cljs and the leiningen integration#2018-08-0218:12thhellerbefore you try to optimize anything in the dark you should really gather some data first#2018-08-0218:13lilactownagreed. I’m on my day off and thinking of hare brained ideas 😛#2018-08-0218:13thhellerlaunch a blank lein repl and then (time (require 'shadow.cljs.devtools.api))#2018-08-0218:13thhellerif that actually takes 3-5min we can talk about tuning that#2018-08-0218:14lilactownI can tell you that running the container locally on my 16gb macbook, the build times are completely reasonable#2018-08-0218:14thheller5min seems pretty excessive to load some code#2018-08-0218:15lilactownbut not joking I have time npx shadow-cljs release <builds> running on our CI and I easily see ranges from 5-10mins#2018-08-0218:16thhellerI totally believe you but I would still like to see a npx shadow-cljs release <builds> --verbose report#2018-08-0218:16thhellerI need to know WHERE the time is spent before thinking about optimizing anything#2018-08-0218:16thhellerthere is a lot of stuff happening even on startup#2018-08-0218:17thhellerso it could be the classpath indexing just being terribly slow#2018-08-0218:17lilactowntotally. I’ll gather some data and report back early next week#2018-08-0218:18lilactownmy main task for this sprint is improving our CI 🙃 so if there’s some low hanging fruit I can grab once we know more I’ll be happy to do the work#2018-08-0218:18thhellerso if you cache only .shadow-cljs/builds you might want to add .shadow-cljs/jar-manifest#2018-08-0218:18thhellerbut again ... without any data this is impossible to make suggestions for#2018-08-0218:20thhellerassuming you actually fixed the cache issue#2018-08-0218:22lilactownwe are persisting .shadow-cljs/builds and node_modules at the moment - not sure about jar-manifest. I can’t remember if I only kept the builds folder or the whole .shadow-cljs#2018-08-0218:22lilactownI’ll check on monday :+1:#2018-08-0218:23thhellerits only a guess. also the disk performance really matter. just the other day @caleb.macdonaldblack changed something in his container setup to go from 3sec+ recompile times down to 0.3secs#2018-08-0218:23thhellerso thats another thing to look out for#2018-08-0218:24thhellerbut really run with --verbose. the output prints just about everything where any time is spent#2018-08-0218:24thhellerwell its probably still missing a lot of details but it should help#2018-08-0218:29daviwil@thheller new here, just wanted to say thanks for all the work you've done on shadow-cljs! I've been waiting so long for a viable dev setup for working with ClojureScript in a "normal" JavaScript project#2018-08-0218:30thhellerwelcome. glad you like it.#2018-08-0218:30daviwilit's a relief to not have to deal with leiningen for a project that doesn't use any Clojure code on the JVM#2018-08-0218:34daviwilHas anyone been able to set up rebel-readline in the shadow-cljs REPL? Not sure if it's incompatible with how shadow-cljs works, but it'd be awesome to have that readline experience#2018-08-0218:35thhellerI have not looked at it yet. the CLJ repl should work out of the box. no idea how to hook up the CLJS REPL though#2018-08-0218:35daviwilYeah, that's the part I wasn't sure about#2018-08-0218:35thhellerI always recommend hooking up your editor first. I only use the REPL from Cursive the readline was never important to me#2018-08-0218:36daviwilI've gotten shadow-cljs to work with Calva in VS Code, but the REPL experience isn't that great there. I'll try setting it up with ProtoREPL next#2018-08-0218:37thhellerhttps://medium.com/@jacekschae/slick-clojure-editor-setup-with-atom-a3c1b528b722#2018-08-0218:37daviwilYep, found that one last night, thanks!#2018-08-0218:37daviwilI suppose I should try to get it working in Atom since I'm a member of the Atom team 😉#2018-08-0218:37thhellerfeel free to open an issue about rebel-readline#2018-08-0218:38daviwilYeah, I think I'll try to give it a shot and set up a demo repo if I can get something working#2018-08-0218:38thhellerthe question has come up multiple times now so if there is an issue I maybe won't forget about looking at it at some point 😉#2018-08-0218:46pez@daviwil: as the author of Calva, I’d like to know what about the REPL experience isn’t great in your opinion. I have tons of ideas of where to focus my efforts, but time is limited and knowing what would make people stick with Calva is gold. #calva-dev is a good place to talk about these things. 😃#2018-08-0218:48daviwilHey! Sorry I didn't give more context to what I meant there. What I didn't say is that I'm really impressed with the overall setup experience of REPLs in Calva, worked super smoothly in my experience#2018-08-0218:49daviwilThe one thing that surprised me is how the CLJ and CLJS REPLs appear in different terminal items, I actually didn't know they were there until I clicked into the dropdown#2018-08-0218:49daviwilThat may be a mistake on my part, though#2018-08-0218:50daviwilI've tried different Clojure(Script) extensions in VS Code in the past and Calva is the only one that worked for me first try, so kudos for that!#2018-08-0218:52pezThe terminal API:s are very limited. I am thinking about doing something with some “special” text files. A bit like how it seems to be implemented in Emacs/CIDER.#2018-08-0218:53daviwilYeah, definitely. I am the original author of the PowerShell extension which is also heavily REPL-driven. They seem to be making progress on getting a WebView extensibility API online so that you can do custom UI panes. That might be an opportunity to make a ProtoREPL-like REPL UI for your extension 🙂#2018-08-0218:53pezI do hope many people get it working first try.#2018-08-0218:53thheller@pez you still can't do custom UI in vscode right? last time I checked it wasn't possible to add anything custom besides a weird previewHTML trick#2018-08-0218:53daviwilLemme see if I can find the APIs they were adding for that#2018-08-0218:55daviwilYou can see a bunch of PRs where they've been adding it: https://github.com/Microsoft/vscode/pulls?q=is%3Apr+sort%3Aupdated-desc+webview+is%3Aclosed#2018-08-0218:55thhellerhttps://github.com/Microsoft/vscode/issues/1833 this is still open I guess 😛#2018-08-0218:55pez@thheller: It is very limited.#2018-08-0218:55daviwilhttps://github.com/Microsoft/vscode/blob/master/src/vs/vscode.d.ts#L5461#2018-08-0218:55daviwilLooks like the WebView APIs made it out of "experimental"#2018-08-0218:56thhellerwebview would be pure gold#2018-08-0218:56daviwilI wish their API docs were more linkable 😕#2018-08-0218:56daviwilhttps://code.visualstudio.com/docs/extensionAPI/vscode-api#2018-08-0218:56daviwilSearch for createWebviewPanel#2018-08-0218:57daviwilDownside is that it has to be in an editor column, not in the terminal/output panel area#2018-08-0218:58thhellerhmm that might still be useful though#2018-08-0218:58daviwilYeah, I think you'd be able to do a lot with it#2018-08-0218:58thhellerso the current proof of concept is reachable under assuming you have a shadow-cljs server running#2018-08-0218:58daviwilI think it allows you to send messages to the JavaScript loaded in the WebView#2018-08-0218:58thhellerthe idea is to build a UI for shadow-cljs including REPL stuff#2018-08-0218:58thhellereditors could then just host the page in a webview#2018-08-0218:58daviwilThat'd be amazing#2018-08-0218:58thhellerand boom you have a full UI for CLJS in your editor#2018-08-0218:59thhelleratom, cursive would support this today. looks like vscode might too#2018-08-0218:59daviwilThen maybe I could make a shadow-cljs extension for Atom very easily 🙂#2018-08-0219:00thhellerthat UI idea has been brewing for soo long now I should really just start working on it 😛#2018-08-0219:01daviwilNice! I see the REPL page at that uri#2018-08-0219:01thhellerinput at the bottom has parinfer active#2018-08-0219:01pezThe editor column has become more viable with the addition of the grid layout.#2018-08-0219:01thhellershift+enter to execute#2018-08-0219:01daviwil@pez that's true#2018-08-0219:02daviwilThanks! I was just about to ask how to execute because Ctrl+Enter wasn't working#2018-08-0219:02daviwilthis looks great#2018-08-0219:04thhellerhttps://code.visualstudio.com/docs/extensions/webview looks promising#2018-08-0219:04daviwilOoooh yeah, I was wondering if they had some conceptual docs for it#2018-08-0219:05thhelleralthough it appears to only support local html and no url for the document itself#2018-08-0219:07daviwilCould it be possible to include a simple html/js file combo with the extension that can link up to the REPL server?#2018-08-0219:08daviwilnot ideal, but should be possible#2018-08-0219:09thhellerit seems to allow loading resources from urls so just a simple html with <script src=""> or so might do it already#2018-08-0219:09thhellerwell gotta build the UI first anyways 😉#2018-08-0219:09daviwiltrue, true 🙂#2018-08-0219:09daviwilexciting possibilities, though#2018-08-0218:47richiardiandreaabout to add select-nrepl support in cider 😉 feel free to try it out https://github.com/clojure-emacs/cider/pull/2397#2018-08-0219:01richiardiandreaabout the above, I wonder whether a watch-all could be a good idea ...#2018-08-0223:30danielcomptonIt looks like http://shadow-cljs.org is down?#2018-08-0223:36daviwilTiming out for me too#2018-08-0223:38thheller^ @jiyinyiyong#2018-08-0223:38thhellerthe domain is maintained by @jiyinyiyong and hosted in China#2018-08-0300:15richiardiandrea@thheller is there a way to load a namespace that, for example, sets up custom test clojure.test/report handlers and stuff?#2018-08-0300:18richiardiandreaI would go for preload but I remember last time we discussed about why it is not in :node-test#2018-08-0303:45grounded_sageHey everyone I'm finally ready to share what I have been working on. I call it Shadow JAM a JAMstack build tool built with Shadow CLJS. At the moment it's a very rough prototype. Would love it if others with more clojure experience could chime in and help me make it better. I'd love it to have a lot more polish before it lands on something like Reddit as I think it would bring a lot of interest to how much better the experience can be building Progressive Web Apps in Clojure/Script than the alternatives. https://github.com/groundedSAGE/shadow-jam#2018-08-0306:56grounded_sageWould love your feedback on this @thheller #2018-08-0306:58thhellerI'll try to go over it soon. saw a few rough mistakes and you should really turn this into a proper library. people cloning all this code is absolutely not ideal and makes it extremely hard to upgrade in the future.#2018-08-0308:27grounded_sageYea it’s really rough, I can point to many mistakes. I either don’t know how to fix them or my domain confidence is somewhat lacking. I do plan to turn it into a library. I’ve had people telling me I should make it public so that others can help with it. #2018-08-0306:23endenwerHey everyone. I am trying to use shadow-cljs for electron development. I used this repo https://github.com/ahonn/shadow-electron-starter. Everything works except live reloading. Din't find how to enable it. In terminal I see compilation after changes but nothing is happening in electron app.#2018-08-0306:37thheller@endenwer the setup in that repo is a bit broken. try changing the config to
:renderer
  {:target :browser
   :output-dir "resources/public/js"
   :asset-path "js"

   :modules {:renderer {:init-fn app.renderer.core/start!}}

   :devtools {:after-load app.renderer.core/start!}}
#2018-08-0306:37thhellerand then removing the blank (start!) call from the app.renderer.core ns otherwise it'll be called twice on startup#2018-08-0306:37thhellerbut that should do it#2018-08-0306:48endenwer@thheller Thanks. It works, but I also had to update shadow-cljs version. I can submit pr with all changes if it makes sense.#2018-08-0306:49thhellerhttps://twitter.com/cljtogether/status/1025165873827393537#2018-08-0413:28eoliphantWell-deserved!#2018-08-0306:49thhellermy plans include making official templates/examples for all of these#2018-08-0306:58endenwerCider repl shows this WARNING: No Clojure project was detected. The refactor-nrepl middleware was not enabled. (You can mute this warning by customizing 'cljr-suppress-no-project-warning'.) Can I somehow fix it?#2018-08-0307:22thhellerI think you need to add https://github.com/clojure-emacs/refactor-nrepl to your deps but better ask someone actually using cider. I have no idea what its for.#2018-08-0307:23endenwerok, thanks#2018-08-0308:36bupkisis there a way to get Cursive to also resolve symbols from JS libraries?#2018-08-0308:36bupkiswhen connected to a shadow-cljs repl#2018-08-0308:37bupkisfor example I have (ns myns.core (:require ["xregexp" as xregexp])) and can use it fine, stuff like (def my-re (xregexp "some.*regex" "g")) works fine, but Cursive shows xregexp cannot be resolved#2018-08-0308:38bupkisit's not a big deal of course, just wondering whether I'm doing something wrong#2018-08-0308:40thheller@samuel.wagen no that is not currently supported by cursive unfortunately#2018-08-0308:40bupkisfair enough, just wanted to be sure I'm not missing something 🙂#2018-08-0309:16nhacongrats for the clojurists together funding!#2018-08-0312:23thhellerthanks!#2018-08-0312:41pezYes, someone just told me about the funding. Great to hear! I guess it still is a bit more symbolic than real pay, but, boy, does shadow-cljs deserve the recognition!#2018-08-0312:56pezWhen using the :npm-module target what will my-constant be exported as for something like (def ^:export my-constant 5.662)?#2018-08-0313:19peznvm, I tested and see that it got named my_constant.#2018-08-0314:48pezWhy could it be that the cljs-repl complains about no application connected? I have started the app and I get this when I start the cljs repl:
$ npx shadow-cljs cljs-repl :calva
shadow-cljs - config: /Users/pez/Projects/clojure4vscode/shadow-cljs.edn  cli version: 2.4.26  node: v10.1.0
shadow-cljs - connected to server
[3:1]~cljs.user=> 1
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
[3:1]~cljs.user=>
It seems to tell me that it is connected to the server, but then complains that it is not. This used to work, and I don’t think I have changed something that should make it stop working. Funny thing is that the nREPL client in Calva can connect and can do everything I tell it, except evaluating (which gives the same error message as trying to evaluate from the REPL prompt).
#2018-08-0314:50thheller@pez I'm assuming you switched to :npm-module?#2018-08-0314:59pezI did.#2018-08-0315:00pezBuilding to a local directory, not in node_modules, if that makes any difference for this problem.#2018-08-0315:04richiardiandreaCongrats congrats, happy to see the project receiving recognition from the community!#2018-08-0315:08kozAre JS includes (described in https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js) run through the Closure Compiler with advanced compilation during a release build? If so, is there a way to turn it off for those files?#2018-08-0315:32pez@thheller was not being able to use the REPL the price to be payed for switching to :npm-module? 😃#2018-08-0316:23thheller@pez :npm-module doesn't have a clearly defined entrypoint and as such cannot properly "preload" the devtools client. you can load it manually from JS though. so assuming you do import ... from "shadow-cljs/your.ns"; somewhere#2018-08-0316:23thhellerhmm doh. do you actually use import or require?#2018-08-0316:24thhellerwell either way the point is to load shadow-cljs/shadow.cljs.devtools.client.browser before any other CLJS import#2018-08-0316:24thheller@koz yes they run through :advanced but no you can't turn that off (currently). why would you want to?#2018-08-0316:28kozIt seems to be mangling some of my objects, for instance I’m declaring something like var kb = this.quill.keyboard; (which has an addBinding() method, which I call via kb.addBinding(). When I run it through advanced compilation, it turns kb.addBinding() into something like b.rE(), which it can’t find (I believe b still resolves to this.quill.keyboard, but it doesn’t have an rE() function on it).#2018-08-0316:28kozI can try to draw up a simple repro case since there may be other variables at work here.#2018-08-0316:31thheller@koz did you try shadow-cljs check your-build? you should be getting a warning for that case#2018-08-0316:31thhellerand then use https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2018-08-0316:31kozLet me try that, thanks @thheller#2018-08-0316:31kozThis library continues to amaze me, great work.#2018-08-0316:32thhellerdidn't check if its easily possible to do externs inference for JS#2018-08-0316:33thhellerbut check should find the problem. since you already know the problem though you can just create the externs/your-build.txt with one line addBinding#2018-08-0316:34kozAwesome, I’ll try that - completely missed that section, sounds like a useful option.#2018-08-0316:34thhelleris quill not imported via shadow-cljs? wonder why it doesn't respect the addBinding method#2018-08-0316:35kozIt’s a transitive dependency of react-quill#2018-08-0316:35koz(which is imported via shadow)#2018-08-0403:10steveb8nI’m using the “promesa” lib on node.js (in an AWS lambda) and seeing an error that suggests that the release compile is obfuscating a promesa fn when it shouldn’t. Anyone seen this before or have an example of promesa being advanced compiled with shadow?
2018-08-04T02:57:14.739Z	15b1728f-9792-11e8-bf66-b982ac270145	TypeError: this.Rd is not a function
at Promise.f.promesa$protocols$IPromise$_catch$arity$2 (/var/task/handlers.js:680:71)
at zz (/var/task/handlers.js:676:641)
at Kz (/var/task/handlers.js:682:442)
at Fo (/var/task/handlers.js:778:164)
I am using deps.edn for classpath/deps. I wonder if that’s causing the problem?
#2018-08-0403:40steveb8nI just read the docs on https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs. I’ll see if that can fix the problem#2018-08-0407:19thheller@steveb8n turn on :compiler-options {:infer-externs :auto} if you haven't. run shadow-cljs release your-build --pseudo-names to figure out what .Rd is.#2018-08-0407:50pez@thheller: thanks! Glad to hear there is hope! 😃 Tried it now, using import * as shadowBrowser from '../lib/shadow.cljs.devtools.client.browser', as the first clsj import being done, but it doesn’t fix the problem. Worse, it makes the release build fail. What am I not understanding correctly?#2018-08-0407:51thhellerwell yeah thats the problem. the file only exists in dev builds and you must conditionally require it#2018-08-0407:51thhellerbut you can't do conditional requires with import#2018-08-0407:52thhellertypically you would if (process.env.NODE_ENV == "development") { require("../lib/shadow.cljs.devtools.client.browser"); }#2018-08-0407:52thhelleryou can maybe do this after all the imports though#2018-08-0407:52thhellerdon't know how other tools deal with import and require in the same file#2018-08-0407:57thhellerare you actually running in the browser though? not exactly sure how vscode works internally. maybe its a node environment?
#2018-08-0408:19pezI think it is a node environment. 😀#2018-08-0408:20thhellerwhich error do you get though?#2018-08-0408:20thhellerit should at least print something in the console?#2018-08-0408:52pezThe error message when the release build fails?#2018-08-0408:53thhellerno dev stuff#2018-08-0408:53thhelleryou should get some kind of message when the devtools either fail to load or connect#2018-08-0408:55pezOk, not at the computer right now, but will check ASAP. Should I be using the browser client, even though it is a node environment?#2018-08-0408:56thhellerprobably no but isn't it based on electron? which is this weird hybrid#2018-08-0409:03pezYes, Electron.#2018-08-0410:18pezNo, I can’t find any output from the devtools anywhere.#2018-08-0410:20thhellercheck the generated lib/cljs_env.js file please#2018-08-0410:20thhellerthe CLOSURE_DEFINES in particular?#2018-08-0410:22thhelleris the code available somewhere? I can take a look at it later#2018-08-0410:27pezCLOSURE_DEFINES:
var CLOSURE_DEFINES = $CLJS.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":false,"shadow.cljs.devtools.client.env.proc_id":"2cce7108-2ff9-43b0-9469-40d5785b5f80","goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9631,"shadow.cljs.devtools.client.env.use_document_host":false,"shadow.cljs.devtools.client.env.module_format":"js","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"calva","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"localhost","goog.TRANSPILE":"never"};
#2018-08-0410:28thheller"shadow.cljs.devtools.client.env.enabled":true#2018-08-0410:28thhellerso when the shadow.cljs.devtools.client.browser is loaded it should defiinitely do something#2018-08-0410:30pezMaybe the TypeScript compiler optimizes it away?#2018-08-0410:30thhellertry just import "./lib/...."#2018-08-0410:31pezChecked it. It didn’t optimize it away. Now will try with just import#2018-08-0410:33thhellerthere is one suspicious thing: the 9631 port#2018-08-0410:33thhellerwhich means you probably have 2 shadow-cljs isntances running?#2018-08-0410:34thhellermight not be intentional and you are just connected to the wrong one?#2018-08-0410:40pezI do have two instances running. The project I am testing my extesion with and then the watcher building the library/modules. I do not think I am connected to the wrong one.#2018-08-0410:41pezI get SyntaxError: Unexpected token import when just importing. At runtime, the TS compiler seems to think it is dandy.#2018-08-0410:42thhellerdid you try require instead yet?#2018-08-0410:44pezI was talking shit. Had placed the import in the generated file…#2018-08-0410:45pezThe TS compiler rewrites it as require. (Yes, I did try the conditional require. It helps building the release build, but still this connection problem.)#2018-08-0410:47pezBut now using import (transcribed to require) I do get an error message with a hint, at last…#2018-08-0410:49pezwindow not defined here: window.addEventListener("beforeunload",(function (){#2018-08-0410:50thhellerso I guess its really node then#2018-08-0410:50thhellertry adding :runtime :node in your build config#2018-08-0410:50thhellerand loading ...client.node instead of .browser#2018-08-0410:52pezThanks! Will try right away.#2018-08-0411:00pezNow it connected! But running into a new problems
ReferenceError: SHADOW_NODE_EVAL is not defined
	at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/clojure4vscode/lib/shadow.cljs.devtools.client.node.js:62:14)
#2018-08-0411:01pezLine 62: var result = SHADOW_NODE_EVAL(js,source_map_json);#2018-08-0411:01thhellerugh#2018-08-0411:01pezI placed :runtime :node in the target config, was that correct?#2018-08-0411:02thhelleryes. hmm sorry the .node stuff is not currently compatible with :npm-module#2018-08-0411:02thhellerI'll see about fixing that#2018-08-0411:02thhellerit currently assumes :node-libray or :node-script#2018-08-0411:12pezI get very confused by the fact that I am using Calva for developing Calva. For Calva I use the built Calva extension, so maybe I need to build that and install before we conclude that things does not work…#2018-08-0411:20pezNo, I get the same error.#2018-08-0411:23pezI’ll package a release w/o the :runtime :node config for now. Do you think I can fix it in shadow-cljs and send you a PR, or is it expert level stuff?#2018-08-0411:24thhellerhmm I just checked the code and it should actually work#2018-08-0411:25thhellerah no wait nevermind.#2018-08-0411:25thhellerI guess you can try and set global.SHADOW_NODE_EVAL = function(js, sm) { goog.globalEval(js); } before you load the .node ns#2018-08-0411:26thhellerah no wait the goog. won't exist yet#2018-08-0411:26thhellerso try just global.SHADOW_NODE_EVAL = function(js, sm) { eval(js); }#2018-08-0411:26thhellerthe problem itself isn't hard to fix#2018-08-0411:27thhellerthe problem is identifying the platform correctly and then doing things in the correct order#2018-08-0411:27thhellerI don't know how the vscode or electron stuff executes exactly#2018-08-0411:27thheller
global.SHADOW_NODE_EVAL = function(js, smJson) {
  if (smJson) {
    js += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,";
    js += Buffer.from(smJson).toString('base64');
  }

  // console.log(js);

  return VM.runInThisContext.call(global, js,
    {filename: "<eval>",
     lineOffset: 0,
     displayErrors: true});
};
#2018-08-0411:28thhelleryou can also try just adding that. thats the default fn used by :node-script and :node-library#2018-08-0411:28thhellerVM is var VM = require("vm");#2018-08-0411:40pezNow a new error:
ReferenceError: cljs is not defined
	at <eval>:2:1
	at <eval>:3:1078
	at ContextifyScript.Script.runInThisContext (vm.js:23:33)
	at runInThisContext (vm.js:95:38)
	at global.SHADOW_NODE_EVAL (/Users/pez/Projects/clojure4vscode/out/calva/extension.js:14:32)
	at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/clojure4vscode/lib/shadow.cljs.devtools.client.node.js:62:14)
#2018-08-0411:40thhellerhmm yeah thought so. the VM part doesn't work#2018-08-0411:40thhellertry with direct eval instead#2018-08-0411:40pezThis should all go in the development conditional, right? (Not that I have gotten that one to work yet, but anyway.)#2018-08-0411:41thhelleryes#2018-08-0411:42pezI need to go now. Will be back later today. Can’t express how much I appreciate all your help.#2018-08-0412:30pezCurious, the SHADOW_EVAL function is called with the cljs code compiled to js as a result of nrepl carrying out the eval operation?#2018-08-0412:30thhellerits used to to eval the code created by the repl yes#2018-08-0415:36pezUsing eval directly gives the same error.#2018-08-0415:38thhellerhmm yeah the module isolation is tricky with this one#2018-08-0415:40thhellerdo you know if the TS tools do something to the compiled CLJS code at all?#2018-08-0415:41thhelleror does it just copy the files along with its output?#2018-08-0415:47pezThe TS compiler never touches the CLJS generated code, I’m pretty sure.#2018-08-0415:51Alex Hhm, what's the flow to recompile individual files with the node-repl? Especially when e.g. I'm building a library, so don't really have an entry point that requires all the files I might want to load in the node-repl to try out#2018-08-0415:51pezWhat I do is to build the cljs code toward a ‘/lib’ directory which is also symlinked to the /out directory where the TS compiler puts it stuff. Conceptually like so:
/out/calva/*.js (generated from *.ts)
/out/lib/*.js (generated from *.cljs)
#2018-08-0415:53pezI do the copying.#2018-08-0415:53thheller@alex340 the common workflow is to load your code via load-file or (require 'that.ns :reload). Cursive has a keybind to load the current file in the REPL and thats what I use all the time. The command uses load-file but require also works.#2018-08-0415:53Alex HI tried (require 'some.ns :reload), but that didn't seem to cause shadow-cljs to rebuild it#2018-08-0415:54thhellerhmm it should?#2018-08-0415:54pezRebuilds are not triggered by that, AFAIK, @alex340.#2018-08-0415:54Alex Hthe file has an explicit typo in it, and yet
cljs.user=> (require 'verktyg.styled :reload)
nil
#2018-08-0415:55Alex Hok, so how are they triggered when using a repl-based flow?#2018-08-0415:55pezAre you running a watcher on the code?#2018-08-0415:55Alex Hno, because I don't have any particular entry point#2018-08-0509:56pezHello. Sorry to bother with a noob question, but his has been puzzling me since yesterday 😃 Why does the lack of entry point prevent the use of a watcher? It seems there is something important for me to learn here.#2018-08-0415:55Alex Hit's just a collection of namespaces as part of a library#2018-08-0415:56thhellerthey ARE supposed to be triggered by that. there does not need to be a watcher running for that.#2018-08-0415:56thhellerif its not thats a bug#2018-08-0415:56thhellertotally possible, not ruling that out. if you can reproduce it in a dummy project please report it#2018-08-0415:56Alex HI can push this project. it's a bit of a mess, so didn't want to publish it yet, but w/e#2018-08-0415:57Alex Hor actually, maybe I can set a simpler dummy#2018-08-0415:57thhellerI can try myself in a bit. need to finish this post first. 😉#2018-08-0416:05Alex H@thheller https://github.com/bwalex/shadow-cljs-reload-bug#2018-08-0416:05Alex Hthe package.json is a bit lazy, in that it contains irrelevant stuff (and so does the shadow-cljs.edn), but that's about it#2018-08-0416:07thhellerthx. will check it out.#2018-08-0416:09pez@thheller: what is the :runtime config supposed to do? (I don’t find it mentioned in the docs.)#2018-08-0416:10thhellerdecide which REPL client gets compiled#2018-08-0416:13thhellerhttps://clojureverse.org/t/faster-startup-via-aot/2603#2018-08-0416:14thheller@lilactown should maybe help with your CI issues#2018-08-0416:34lilactownReplying so I remember to look later 😍#2018-08-0416:38pez@thheller: that should mean that I can keep that part of the config even though it is not solving my problem right now, because when Calva is used “out there” it will be the REPL client of the particular projects that are in play and not the REPL client in the Calva extension?#2018-08-0416:39pezSorry if it is a stupid question, I meant what I said that using Calva for Calva development confuses me. 😃#2018-08-0416:40thhelleryes, user projects won't be affected#2018-08-0416:40thhellerits just your REPL while developing the calva for calva inception stuff 😛#2018-08-0416:40pezHaha, thanks. I’ll try to remember that.#2018-08-0423:42eoliphantanyone using antd with shadow?#2018-08-0500:50steveb8n@thheller thanks. that hint led to me notice that promesa bundles bluebird and an externs file. so I added :compiler-options {:externs ["bluebird/externs.js"]} and that fixed it.#2018-08-0500:50steveb8nand congrats on the clj-together funding too. you earn all that and more with your efforts to help us#2018-08-0514:56pez@thheller: do you have some other ideas about what I can do to get back the REPL for Calva development?#2018-08-0514:57thheller:node-library 😛#2018-08-0514:58pezI’m almost ready to do that, but losing the name spacing is not alluring at all.#2018-08-0514:59thhellerI'm in troubleshooting mode anyways so I can try something#2018-08-0515:02pezYou want to experiment on your side or remote control me like we did yesterday? 😃#2018-08-0515:02pezHere’s the dev how-to of Calva development anyway: https://github.com/BetterThanTomorrow/calva/wiki/How-to-Contribute#2018-08-0605:21bupkisafter updating to shadow-cljs 2.4.30, the I get an empty .nrepl-port, and shadow-cljs server shows shadow-cljs - nREPL server started on port (no port shown). the shadow-cljs.edn is very simple:
{:dependencies [[zprint "0.4.10"]
                [funcool/cuerdas "2.0.5"]]
 :source-paths ["src"]
 :builds {:test2 {:target :node-script
                  :main fmtz2.core/main
                  :output-to "out/test2.js"}}}

#2018-08-0605:21bupkisgoing back to 2.4.28 works fine#2018-08-0607:39thheller@samuel.wagen there should be a warning printed on startup if nrepl fails?#2018-08-0607:42bupkis
shadow-cljs - config: /Users/bupkis/dev/test2/shadow-cljs.edn  cli version: 2.4.30  node: v10.8.0
shadow-cljs - starting ...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/bupkis/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
shadow-cljs - server version: 2.4.30
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 55789
shadow-cljs - nREPL server started on port
#2018-08-0607:42bupkisonly warnings are the JDK10 ones in xnio#2018-08-0607:42bupkisbut I get those with working versions too#2018-08-0607:43thhelleroh right nevermind. I just broke it#2018-08-0607:45bupkis🙂#2018-08-0607:51thheller@samuel.wagen should be fixed in 2.4.31#2018-08-0608:01bupkisit now starts the nrepl server, but when I do (shadow/node-repl) from Cursive - I get RuntimeException Can't resolve find-ns clojure.lang.Util.runtimeException (Util.java:221)#2018-08-0608:05thhellerwhat the heck#2018-08-0608:05thhellerhttps://github.com/thheller/shadow-cljs/issues/273#2018-08-0608:05thhellerthis used to only happen with cider#2018-08-0608:06bupkisno cider in this particular project#2018-08-0608:06thhellerdo you have the full stacktrace?#2018-08-0608:06bupkiscursive isn't showing it to me#2018-08-0608:07bupkislet me try outside of cursive#2018-08-0608:08bupkishmm that only happens in cursive#2018-08-0608:09bupkisif i start the server, and in another terminal do shadow-cljs clj-repl and from that I do (shadow/node-repl) - I get to the CLJS repl no problem#2018-08-0608:09bupkisbut in cursive - the above error. going back to 2.4.28 fixes it#2018-08-0608:10thhelleryeah the problem lies in nrepl#2018-08-0608:10thhellerit is doing something with the classloader#2018-08-0608:10bupkisintellij is 2018.2, cursive is 1.8.0-eap4-2018.2 if that matters#2018-08-0608:10thhellerno its a shadow-cljs side problem#2018-08-0608:10thhelleror rather nrepl server side#2018-08-0608:10bupkiscould it be connected to another problem I'm having with versions >2.4.28? it also has issues in a project where I use refactor-nrepl (`[WARNING] No nREPL middleware descriptor in metadata of #'refactor-nrepl.middleware/wrap-refactor, see nrepl.middleware/set-descriptor!`), but I guess that's not a shadow issue, more of an issue between the new nrepl and refactor-nrepl#2018-08-0608:11thhellercider-nrepl as of 0.18.0 uses nrepl 0.4#2018-08-0608:12thhellerI'm not sure if there is a refactor-nrepl upgrade out yet#2018-08-0608:12thhellerbut I said you use cursive? why the middleware then?#2018-08-0608:13bupkisI said above it's in a different project, just thought it could be related since it started in >2.4.28 too.#2018-08-0608:13bupkissorry for confusing you#2018-08-0608:14thhellerthe entire problem is due to nrepl 0.4 not being compatible with 0.2#2018-08-0608:14thhellerso libraries written for 0.2 stop working#2018-08-0608:14thhellercider had a new release yesterday for 0.4#2018-08-0608:14bupkisbut Cursive perhaps isn't supporting 0.4 yet?#2018-08-0608:15thhellercursive doesn't care#2018-08-0608:15thhellerit doesn't use any middleware so it works either way#2018-08-0608:15bupkisbut it still uses nrepl?#2018-08-0608:15bupkisah so only the middlewares are having issues, not vanilla nrepl clients#2018-08-0608:16thhelleryes#2018-08-0608:16thhellerclients are unaffected since the nrepl messages didn't change#2018-08-0608:16bupkisbut shadow is affected (in the cursive case) somewhat?#2018-08-0608:17thhellerit seems to work for me. I cannot reproduce the find-ns problem#2018-08-0608:18bupkisweird. let me blow away the .shadow-cljs directory and try again. the config is above - very vanilla#2018-08-0608:19thhellerah got it#2018-08-0608:25thhellerhehe what the actual F*$##2018-08-0608:26thhellerI tracked the problem down to tools.logging a while ago but thought it was just masking a different underlying issue#2018-08-0608:26thhellerI now fixed the tools.logging issue#2018-08-0608:26thhellerand the problem goes away#2018-08-0608:26bupkisha, it really is a wtf#2018-08-0608:26bupkiswhy does tools.logging mess with the class loader#2018-08-0608:27thhellerhttps://groups.google.com/d/msg/clojure-dev/mRWujdKmtmE/exjJCZFkAgAJ#2018-08-0608:28thhellerso tools.logging uses *ns* all over the place which results in this find-ns call#2018-08-0608:28thhellerWHY exactly it fails I have no idea#2018-08-0608:30thhellerso I'm really just treating a symptom when fixing tools.logging#2018-08-0608:30thhellerthe underlying issue I have not yet identified#2018-08-0608:31bupkisthat thread is ridiculous, why are they being so stubborn to even acknowledge the issue, not to mention accept a fix#2018-08-0608:33thhellerI shouldn't have made it about load time ... and really should have just started by patching tools.logging instead#2018-08-0608:33thhellerwhich I'll replace now I guess#2018-08-0612:54eoliphantHi, i’ve just done a release build and it’s pretty obnoxiously large (~5Mb) , is there any way to figure out what the contributors are ?#2018-08-0613:27thheller@eoliphant https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2018-08-0614:03eoliphantduh 🙂 cool thanks.#2018-08-0615:33heyarneHm.. I'm getting a warning cljs.core.ICounted is not a protocol when trying to implement a record with custom counting, however my tests seem to show that it's working correctly. Am I missing something?#2018-08-0615:33thhellercljs.core/ICounted#2018-08-0615:34heyarneDuh#2018-08-0615:34heyarnethanks#2018-08-0615:34thhellerwell maybe. not actually sure 🙂#2018-08-0615:39thheller@samuel.wagen the find-ns issue should hopefully be fixed in 2.4.32. I can no longer reproduce it at least.#2018-08-0618:51bupkis@thheller yep, works perfectly, vielen Dank#2018-08-0619:59eoliphantanyone using the aws-sdk? It’s adding like 2Mb to my build, I’m only requiring the following
["aws-sdk" :default AWS]
    ["aws-sdk/clients/s3" :default S3]
#2018-08-0620:34thhellerhmm aws seems to import a crapton of JSON files#2018-08-0620:43thhellerit may work if you do
["aws-sdk/lib/util" :as AWS]
    ["aws-sdk/clients/s3" :as S3]
#2018-08-0620:44thhellerif you import aws-sdk it'll bring in every single thing including the stuff you don't actually use#2018-08-0620:44thhellerso you should awlays try to only require what you actually need#2018-08-0620:45thheller^ @eoliphant#2018-08-0620:47samarthI’m trying to use shadow-cljs in a small project which uses some npm modules that I want to require in my ClojureScript code. I’m using Emacs with CIDER and followed the instructions on https://shadow-cljs.github.io/docs/UsersGuide.html#cider to start a server and connect to the repl, but running M-x cider-connect times out with the error:
[nREPL] Establishing direct connection to localhost:55098 ...
[nREPL] Direct connection to localhost:55098 established
helm-M-x: Sync nREPL request timed out (op clone id 1)
I’m very new to all of this ClojureScript stuff and want to try it out so any help would be appreciated. Thanks!
#2018-08-0620:50thheller@samarthkishor1 I don't know anything about cider unfortunately#2018-08-0620:51samarth@thheller I’ll try posting this in the cider channel then. Thanks for the response!#2018-08-0620:53thhellercider is in this weird spot right now due to the nrepl 0.4 migration. are you on 0.18.0 already?#2018-08-0620:53thhellerI tried my best at supporting both nrepl versions but that has proven to be much harder than anticipated#2018-08-0620:54thhellermay be related to this though#2018-08-0620:56samarthI upgraded to the latest version of cider this morning and the dependencies section of my shadow-cljs.edn file looks like this:
:dependencies [[cider/cider-nrepl "0.18.0"]]
#2018-08-0620:56thhellerare you on the latest shadow-cljs too?#2018-08-0620:57thhellerfixed a few related bugs just today#2018-08-0620:57samarthI installed it yesterday from npm but I can try the latest version#2018-08-0620:57thheller2.4.32 should hopefully fix most issues#2018-08-0621:06samarthI got the repl to run but I can’t send expressions to the repl from a cljs buffer or evaluate them. At least I have something to work with though. Thanks!#2018-08-0621:07thhellerdon't forget about all of this https://shadow-cljs.github.io/docs/UsersGuide.html#_launch_the_clojurescript_repl#2018-08-0621:07thhellerno idea how current that is though#2018-08-0621:12samarthM-x cider-create-sibling-cljs-repl doesn’t seem to be a command. I’ll look in the cider docs to see if it got renamed to something else#2018-08-0621:13kanweiupdated to 2.4.32 and getting this:#2018-08-0621:13kanwei
<< Building for release >>
[:mp360] Compiling ...
The required namespace "doublethedonation.integrations.app" is not available.

[:ddregister] Compiling ...
The required namespace "doublethedonation.register" is not available.

[:ddplugin] Compiling ...
The required namespace "doublethedonation.external" is not available.

[:mp360partners] Compiling ...
The required namespace "doublethedonation.partner-portal.app" is not available.
#2018-08-0621:13kanweidowngraded to .31 and it works fine#2018-08-0621:14thhellerhmm thats odd. nothing changed regarding compilation. only logging stuff.#2018-08-0621:20thheller@kanwei how are you calling things? << Building for release >> looks like something custom maybe?#2018-08-0621:23kanweihttps://gist.github.com/kanwei/26c0da2c47278f598f5e02fa8a543c87#2018-08-0621:23kanweicalling it with
(cljs/release :builds #{:mp360 :mp360partners :ddregister :ddplugin})
#2018-08-0621:25thhellerhmm I don't know boot, can you try it without boot?#2018-08-0621:35thhellerthe errors sugguests that maybe the classpath isn't configured properly. but nothing changed regarding that in 2.4.32#2018-08-0621:35flyboarder@kanwei could you maybe try with https://github.com/degree9/boot-shadow#2018-08-0621:36flyboarderit was originally based on that gist (or a similar one)#2018-08-0621:36flyboarderalternatively try with the standalone cli app as @thheller suggests#2018-08-0621:37thhelleroh heck I know what it is#2018-08-0621:38thhellerI dropped the java.classpath dependency and its single use#2018-08-0621:39thhellerwhich I guess boot relies on#2018-08-0621:39thhellertotally forgot about that. I'll revert that change.#2018-08-0621:40flyboarder@thheller where was that modified? Is this something I can patch in the boot task directly?#2018-08-0621:42thhellercan boot set the java.class.path property?#2018-08-0621:42flyboarder@thheller boot does I believe as it abstracts the actual classpath with a virtual one, via the fileset concept#2018-08-0621:43flyboarderhttps://github.com/boot-clj/boot/wiki/Filesets#2018-08-0621:44thhelleryes but shadow-cljs needs to read the classpath#2018-08-0621:44thhellersince it can't do that by looking at the classloaders in Java9#2018-08-0621:44thhellerit does that by looking at the system property java.class.path#2018-08-0621:44thhellerand I removed the "old" stuff which looks at the classloader#2018-08-0621:45thhellerbut I guess boot really needs that#2018-08-0621:48thhellerhttps://github.com/thheller/shadow-cljs/commit/e9bd399ab82f9ac826f880ab51a50f67bac5783f#2018-08-0621:48flyboarder@thheller we should be able to provide a class path, since boot requires building it’s own#2018-08-0621:49flyboarderhttps://github.com/boot-clj/boot/blob/master/doc/boot.pod.md#get-classpath#2018-08-0621:49thhellerthis should fix it#2018-08-0621:49thheller@kanwei try 2.4.33, sorry about that. didn't think anyone was relying on that old behaviour since it doesn't work in java9+#2018-08-0621:50thheller@flyboarder does boot work with java9+?#2018-08-0621:50flyboarderyep all the way to Java 11#2018-08-0621:50thhellerbut how do you get the classpath from in side a pod?#2018-08-0621:51flyboarder(boot.pod/get-classpath)#2018-08-0621:51thhellerwell I can't add boot specific api calls to shadow-cljs#2018-08-0621:52flyboarderright, so we need to be able to pass a classpath to shadow-cljs config#2018-08-0621:52thhellerI guess you could replace the shadow.build.classpath/get-classpath fn with something that calls the boot thing?#2018-08-0621:54flyboarderor we can build the pod using an existing classpath from shadow#2018-08-0621:54flyboarder@thheller ^#2018-08-0621:54thhellerthe gist already has a prepare-runtime fn that seems to do some stuff#2018-08-0621:55thhelleryou could try#2018-08-0621:55thheller
(in-ns 'shadow.build.classpath)

(defn get-classpath []
  (boot.pod/get-classpath))
#2018-08-0621:55thhellerbut you can open an issue about the classpath via config thing#2018-08-0621:56thhellershould be easy enough to hook up#2018-08-0621:56flyboarderwhere is the shadow class path being constructed?#2018-08-0621:56flyboarderI wonder if I can just use that?#2018-08-0621:56thhellerwhat do you mean?#2018-08-0621:57flyboarderIs it just checking the property? or does it build it’s own?#2018-08-0621:57thhellerthe shadow-cljs npm command builds the classpath and starts with JVM with it set#2018-08-0621:57thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/classpath.clj#L35-L43#2018-08-0621:58thhellerthis then reads that#2018-08-0621:59flyboarder@alandipert Do you know of a way to fix this classpath issue above? Ideally I’d like to just patch it within a boot task to the shadow pod#2018-08-0622:00flyboarder@thheller I’ll keep looking into this and see if I can patch it from the boot task instead of requiring changes to the internals of shadow#2018-08-0622:00thhellerfrom what I know its no longer possible to inspect the classpath by looking at classloaders in java9+#2018-08-0622:00thhelleronly with very ugly reflection warnings which I don't want#2018-08-0622:01flyboarderBoot has to be doing something that makes this possible 😛#2018-08-0622:01thhellerbut that might not actually be true. so if someone knows a way to still do it in java9+ I'm happy to consider it#2018-08-0622:02thheller@flyboarder its only a problem is something actually tries to inspect the classpath. you don't usually have much reason to do so#2018-08-0622:06thhellerhttps://github.com/boot-clj/boot/issues/691#2018-08-0622:07thhellerthose are the reflection warnings I want to avoid#2018-08-0622:13thhellerhttps://youtu.be/4fevIDAxQAM?t=13m26s#2018-08-0622:32flyboarder@thheller looks like there was an issue open to add boot class path support to external tools, a quick check for boot.class.path could also do the trick#2018-08-0622:36thhelleris that documented somewhere? impossible to google#2018-08-0622:37flyboarder@thheller https://github.com/boot-clj/boot/issues/249#2018-08-0622:37flyboarderhttps://github.com/boot-clj/boot/blob/59909f135871af4a8ae82bda3268e8816b238e36/boot/core/src/boot/core.clj#L142-L158#2018-08-0622:38thhellerok I can add the extra check for that#2018-08-0622:38thhellertomorrow though. off to bed. gn8#2018-08-0622:46flyboarder@kanwei can you post your boot environment also? Does it include the source folders that are also in shadow-cljs.edn?#2018-08-0700:51eoliphantYeah @thheller, let me try that, I tried “aws-sdk/config” but that didn’t do it#2018-08-0703:58Josh HorwitzHey all, is there any good docs/tutorial on using shadow-cljs to write a command line tool?#2018-08-0704:43daviwil@joshua.d.horwitz I don't know of one specifically, but you should be able to do this fairly easily by generating a node script build and wrapping it with nexe - Node script build: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node - nexe: https://github.com/nexe/nexe#2018-08-0704:44Josh HorwitzThank you @daviwil #2018-08-0706:26y.khmelevskiihi! How can I require some dependency, for example, cljs.spec.test.alpha only in :dev mode? I need this dependency not to be in release bundle.#2018-08-0706:32thheller@y.khmelevskii people generally only require cljs.spec.test.alpha in test namespaces and not your regular ones#2018-08-0706:32thhellerotherwise you can use this https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-08-0706:33thheller@eoliphant its probably aws-sdk/lib/config#2018-08-0706:42y.khmelevskiithank you @thheller. But I can’t do something like this:
#
I need to create a separate build section in shadow-cljs.edn and I need to use .cljc files, right? Maybe can I use additional external path for :dev and :release mode.
#2018-08-0706:44thhellerdo you actually require cljs.spec.test.alpha in any of your main namespaces though?#2018-08-0706:44thhelleror just in test namespaces that aren't actually used by your normal build?#2018-08-0715:45jjfineis there any way to get verbose compile output? compilation is hanging and i'm having trouble figuring out where the issue is.#2018-08-0715:45thhellershadow-cljs compile your-build --verbose#2018-08-0715:47jjfinethanks#2018-08-0715:49thhellerlet me know if you need help. compilation should never hang. it may just take a while if you use a lot of JS deps.#2018-08-0715:52jjfinecool, that at least narrowed it down to the file that's causing it#2018-08-0715:55thhellerdoes it actually hang or just compile forever? I have never had any reports of a hanging compilation#2018-08-0716:02jjfinecompile forever might be more accurate#2018-08-0716:03jjfinei think i've narrowed it down to a macro#2018-08-0716:03jjfinemaybe its expanding infinitely#2018-08-0716:04jjfineits stuck compiling one of my source files and maxing out my cpu#2018-08-0716:06thhelleryeah sounds like a loop#2018-08-0803:27cjmurphyI've done npm install d3 and setup to resolve to "d3/build/d3.js", as recommended in the book, but get the error: "ExceptionInfo: could not find module-entry: d3/build/d3.js".#2018-08-0803:29cjmurphyWanting to be able to require d3, like so: (:require ["d3" :as d3]).#2018-08-0806:44thheller@cjmurphy ideally don't require the d3 meta package. instead require only the parts you actually need. d3 was split up into many smaller packages for this reason. see https://www.npmjs.com/search?q=d3-#2018-08-0806:45thhellereg. (:require ["d3-color" ...])#2018-08-0806:45thhellerit pretty much maps 1:1. so if you used d3.color before thats just imported via d3-color now#2018-08-0806:46cjmurphyI was doing that but mot examples have js/d3 as what they start with. See https://stackoverflow.com/questions/51728357/d3-javascript-translation-to-clojurescript/51728732#51728732#2018-08-0806:46cjmurphyWhat I did works but other things will be harder.#2018-08-0806:47thhellerwell if you don't care about download size too much you can use d3 directly too. its really just an optimization to only require the smaller packages#2018-08-0806:48cjmurphyI want to call the function: (.interpolateWarm), but there is no context, so how do I call it?#2018-08-0806:48cjmurphyIt takes a number and rets a colour.#2018-08-0806:49cjmurphy(.interpolateWarm js/d3 30) would work I think.#2018-08-0806:49thhellerusing js/d3 is incorrect in shadow-cljs
#2018-08-0806:50thheller(:require ["d3" :as d3]) means that you pull d3 into the local scope. js/d3 is the global scope, just use d3 instead#2018-08-0806:50thheller(.interpolateWarm d3 30)#2018-08-0806:50thhelleror better yet#2018-08-0806:50thheller(d3/interpolateWarm 30)#2018-08-0806:50cjmurphyOh, will try, thanks...#2018-08-0806:51thhelleror even better (:require ["d3-interpolate" :refer (interpolateWarm)]) and then (interpolateWarm 30)#2018-08-0806:51thhelleralthought I can't find the interpolateWarm fn?#2018-08-0806:52cjmurphyIt is not d3#2018-08-0806:52cjmurphyreact-vis#2018-08-0806:52thhellerdo you have the JS example you are trying to convert/use?#2018-08-0806:53cjmurphy#2018-08-0806:54cjmurphyhttps://towardsdatascience.com/advanced-visualization-with-react-vis-efc5c6667b4#2018-08-0806:54cjmurphyTrying to do the whole article.#2018-08-0806:54thhellerand btw (:require ["d3" :as d3]) should work just fine today. they were in a weird state packaging-wise for a while but all of that was sorted out.#2018-08-0806:55thhelleryou just have to remember to use d3 directly and never js/d3#2018-08-0806:55cjmurphyRight yes, and not have the dot even when doing interop.#2018-08-0806:55thheller. is fine if you want#2018-08-0806:56thheller(d3/thing) is the same as (.thing d3) just looks nicer#2018-08-0806:57thhellerimport {interpolateWarm} from 'd3-scale-chromatic'; is (:require ["d3-scale-chromatic" :refer (interpolateWarm)]) and then just (interpolateWorm ...)#2018-08-0806:57thhellerthere is a translation table available here: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-08-0806:58cjmurphy["d3-scale-chromatic" :refer (interpolateWarm)]#2018-08-0806:59cjmurphyYes above what been using. Been referring to the book.#2018-08-0806:59thhellerI'll remove the confusing d3 example from the book. its not relevant anymore.#2018-08-0806:59cjmurphySo (:require ["d3" :as d3]) should work, and I do need it right? But not working for me at the moment.#2018-08-0807:00thhellerno you do not need it but yes it works.#2018-08-0807:00thhellerwhats not working?#2018-08-0807:00cjmurphyExceptionInfo: could not find module-entry: d3/build/d3.js#2018-08-0807:00thhellerno config whatsoever, so if you took the :resolve config example you need to remove that#2018-08-0807:01cjmurphyYes I removed the wrong bit of config ....#2018-08-0807:01thhellerso you have nothing d3 related configured in your config?#2018-08-0807:01cjmurphyCorect now.#2018-08-0807:01thhellerand it still doesn't work?#2018-08-0807:02cjmurphy"ui.cljs:70 Uncaught ReferenceError: d3 is not defined"#2018-08-0807:02thhellerprobably because you are using js/d3 again?#2018-08-0807:02cjmurphyIndeed#2018-08-0807:03cjmurphyFantastic, works now.#2018-08-0807:03cjmurphyThank you simple_smile#2018-08-0817:15thhellerI'm experimenting with a couple of options for quickly create shadow-cljs projects. pretty much all templates that currently exist use lein and I want non-lein options. One option I'm properly abandoning is npx create-cljs-project. I was just messing with a couple ideas for UI but it doesn't actually create anything yet. it already bugs me that its way too slow though#2018-08-0817:15thheller
$ npx create-cljs-project foo
npx: installed 35 in 18.384s
? Name of your project? test
? Which target? Browser
? Would you like some demo content? re-frame - A Reagent Framework For Writing SPAs, in ClojureScript.
#js {:project-name "test", :target :browser, :template :re-frame}
#2018-08-0817:15thheller18.3s just to run the damn thing is pretty much a non-starter for me#2018-08-0817:16flyboarder@thheller is there an example repo for new projects?#2018-08-0817:16thhellerhttps://github.com/thheller/shadow-cljs#examples#2018-08-0817:19flyboarderThere is boot-new which works great for boot project templates#2018-08-0817:19thhelleralso a non-starter#2018-08-0817:20thhellerbasic ground rules: this is for JS devs. neither boot nor lein are available. not going to make them install that first.#2018-08-0817:21lilactownhow long does create-react-app take?#2018-08-0817:21thhellerjust launching it about 6sec or so#2018-08-0817:21lilactown
~/Code  npx create-react-app foo
npx: installed 67 in 4.526s
huh
#2018-08-0817:22thhelleryeah I could optimize like they do#2018-08-0817:22thhellerbut still bugs me that it takes so long#2018-08-0817:25lilactownoh btw, we moved our CI runner to it’s own EC2 and starting + compiling takes <1 min now 😉#2018-08-0817:25lilactownturns out running on something other than a toaster helps#2018-08-0818:09thhellerhehe I bet. did you notice a difference in start up with AOT? or were you on deps/lein anyways?#2018-08-0818:15lilactownwe’re using lein, but I’m working on migrating us off of that so we can take advantage of that as well#2018-08-0818:15thhelleryou can do it in lein but I do not recommend it if you have any CLJ server side code#2018-08-0817:26flyboarder@thheller you could use mustache templates and build a command into shadow-cljs#2018-08-0817:27thheller@flyboarder
(ns shadow.cljs.create.cli
  (:require
    [goog.object :as gobj]
    ["inquirer" :as inq]
    ["mustache" :as mst]
    ["fs" :as fs]))
#2018-08-0817:27thhellerthat was the plan ... but install time matters to me and if the baseline is 18sec I'm doing something else.#2018-08-0817:27thhellernpm install shadow-cljs already takes way too long#2018-08-0817:28thhellerI'm stronly considering implementing https://github.com/thheller/shadow-cljs/issues/290 so npm doesn't take forever installing all the shitty deps#2018-08-0817:29thhellerhttp://npm.broofa.com/?q=shadow-cljs this is already pretty ridiculous ... just because of babel#2018-08-0817:32thhellerevery time I start a new test shadow-cljs project I already forgot what I wanted to do by the time it finished installing#2018-08-0817:33thhellernpm is so horribly slow in WSL its absolutely no fun to work with#2018-08-0818:04lilactownyeah that is a bummer. I remember reading about some weird WSL disk issues, I wonder if it’s related#2018-08-0818:05thhellerdon't really have any issues ... its just slow. there is an open ticket about it but doesn't seem to be a priority#2018-08-0818:06thhellerits really only npm thats slow however since it deals with soooooo many files#2018-08-0818:06thhelleron a single thread ...#2018-08-0818:06thhellergotta hate node sometimes#2018-08-0819:06bbssIs there a trick to make shadow-cljs not load whole libraries? e.g. I refer from @material-ui/icons like so:
["@material-ui/icons" :refer [PlayArrow Pause Stop]]
it slows down incremental compilation significantly, 3-4 seconds on my machine. And now something worse is happening: my browser stops loading with a failed to load resource: net::ERR_INSUFFICIENT_RESOURCES. It seems to load a ton of node_modules.
#2018-08-0819:07thhelleryes. only require what you need. (:require ["@material-ui/icons/PlayArrow" :default PlayArrow])#2018-08-0819:08bbssGot it, thanks.#2018-08-0819:08thhellerthis "@material-ui/icons" requires every single icon and there are a lot of them#2018-08-0819:09bbssOkay, I hoped :refer would be smart. But I understand that might be hard (impossible) to implement.#2018-08-0819:09bbssOr well I hoped the JS world would have figured out a nice way actually.#2018-08-0819:10thhelleryeah can't do it with :refer gotta do it manually#2018-08-0819:10bbssSo be it. Thanks.#2018-08-0819:11thheller961 files are included by @material-ui/icons#2018-08-0819:11bbssYeah, it's ridiculous.#2018-08-0819:11thhellergotta love the crap the JS world comes up with#2018-08-0819:11bbss🙂#2018-08-0820:37wilkerlucio@bbss I have used https://react-icons.github.io/react-icons/ and it seems to play nice, specially if you only include the icons you need (they have each separated in its own file)#2018-08-0820:38bbssCool, I'll give it a look. The approach of requiring as default works too, but it's a bit cumbersome.#2018-08-0821:38lilactowndoes shadow-cljs have a command to just “download all dependencies”?#2018-08-0821:39thhellernot currently. but I'm currently reworking how all of that is handled.#2018-08-0821:39thhelleropen a ticket if you need it#2018-08-0822:36lilactownjust updated to 2.4.33 and seeing this error:
Exception in thread "main" java.lang.NoSuchMethodError: com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
	
#2018-08-0822:38lilactownhrm. it might be due to a dependency…#2018-08-0822:40lilactownadding this to my dependencies [nubank/workspaces "1.0.0-preview6"] triggers the error#2018-08-0822:47lilactowndowngrading to nubank/workspaces 1.0.0-preview5 works just fine#2018-08-0822:57lilactownhas nothing to do with shadow-cljs. raised an issue with workspaces#2018-08-0904:11richiardiandreaHow does shadow handles npm transitive deps? Core has deps.cljs I wonder whether I can rely on it in shadow #2018-08-0904:29justinleeWhat do you mean? npm handles npm transitive deps#2018-08-0904:42richiardiandrea@lee.justin.m say you have a cljs dep that includes an npm dep. You want to consume that in shadow#2018-08-0904:42justinleeyou have to add it to your package.json. e.g., reagent requires react. you have to add react to your package.json and install it via npm#2018-08-0904:45justinleethat’s why there is the whole cljsjs shim thing#2018-08-0904:47richiardiandreaUhm, I thought this was a thing in shadow as well, but maybe Thomas was against it and therefore not implementated: https://dev.clojure.org/jira/browse/CLJS-1973#2018-08-0904:48richiardiandreaIn your scenario a user of many lib should know and include all the npm transitive deps manually#2018-08-0904:48justinleei’m not 100% sure what he’s talking about, but i think npm-deps actually shells out to npm#2018-08-0904:48justinleein shadow, you need to install npm modules yourself, which you can do via npm or yarn#2018-08-0904:49justinleefor example: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install#2018-08-0904:49richiardiandreaSo yeah, that means that I would need to know what npm deps each lib is using. Example, cuerdas uses xregexp, if I want to use it I need to install it manually? #2018-08-0904:50richiardiandreaYeah well the answer seems yes#2018-08-0904:50richiardiandreaIt feels a bit backwards#2018-08-0904:50justinleeit’s great 🙂#2018-08-0904:51justinleehaving manually packed npm dependencies is fine when you have one-offs, like in cuerdas. but the moment you start including, say, more than one react library, it’s a nightmare#2018-08-0904:52richiardiandreaSay you are using 100 cljs libs including 100 npm deps...I do not think this method scales 😄#2018-08-0904:52justinleeon the contrary, it’s the only method that would scale#2018-08-0904:53justinleeyou would never get 100 cljs libs with 100 npm deps to work if they all had hardcoded crap installed#2018-08-0904:53richiardiandreaMaybe I am missing something...#2018-08-0904:53richiardiandreaWhat does hardcoding means?#2018-08-0904:54richiardiandreaEach cljs dep declares what it is using #2018-08-0904:54justinleecuerdas, for example, literally includes the javascript in its distribution. so if some other library has xregexp, you’ll get two copies#2018-08-0904:54richiardiandreaYep that is not good ok#2018-08-0904:54justinleein some cases, like react, it just won’t work#2018-08-0904:55richiardiandreaVanilla cljs allows an :npm-deps in deps.cljs in your jar#2018-08-0904:55justinleenpm has a rather sophisticated algorithm to flatten the tree#2018-08-0904:55richiardiandreaSo that you can transitively know which npm dep you will be using#2018-08-0904:55richiardiandreaAnd shell out to npm install#2018-08-0904:56richiardiandreaCuerdas' current way is not optimal if it does the bundling and I agree with you there#2018-08-0904:56justinleeyea i don’t know what npm-deps is doing under the covers (I understand that it uses npm, but beyond that, it’s a mystery to me)#2018-08-0904:56justinleei think at this point in time, most libraries (every one that I’ve looked at) that includes npm stuff just bundles the npm in the distribution#2018-08-0904:57richiardiandreaYeah that's bad, but: > ClojureScript libraries that package foreign dependencies can also benefit from these enhancements. Ticket CLJS-1973 adds support for the :npm-deps option in deps.cljs files, allowing library authors to develop and distribute libraries that directly depend on Node.js modules.#2018-08-0904:57richiardiandreahttps://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/#2018-08-0904:58richiardiandreaThis is how it should be done if I understand correctly #2018-08-0904:58richiardiandreaNot sure though 😉 #2018-08-0904:59justinleethere are a couple of things to know (that aren’t obvious from that article or the official docs). (1) npm-deps will run the npm module through advanced compilation, which may or may not work, and (2) it seems incredibly brittle and basically impossible to debug. I believe that is why dnolen published the webpack guide#2018-08-0904:59richiardiandreaAgree and switched to shadow for exactly those reasons#2018-08-0905:00richiardiandreaStill, a way to declare and detect transitive npm deps seems good#2018-08-0905:00justinleeit would be interesting if libraries could just ship with their own package.json#2018-08-0905:00justinleethen you could just do normal transitive resolution#2018-08-0905:01richiardiandreaBut that's what the deps.cljs is for I guess#2018-08-0905:01richiardiandreaAnd note "I am guessing" #2018-08-0905:01richiardiandreaWill actually try it out tomorrow#2018-08-0905:01justinleei’m not sure deps.cljs will ever be expressive enough, but maybe#2018-08-0905:01justinleeactually it should work yea#2018-08-0905:02justinleewhether shadow can or should interpret npm-deps is something thomas would have to answer#2018-08-0905:02justinleethat makes my head hurt 🙂#2018-08-0905:02richiardiandreaAh ah! I hear you simple_smile #2018-08-0905:03richiardiandreaCool so I'll stay tuned, thanks for answering 😉 #2018-08-0905:07lilactownI’m pretty sure shadow-cljs respects deps.cljs#2018-08-0905:09lilactownseeing as I installed a cljs dependency just now and a bunch of stuff magically appeared in my package.json when I did git status 😄#2018-08-0905:10justinlee@lilactown whoa. oh fascinating. so you installed a cljs dep that had an npm-deps in it, and shadow added that to your package.json?#2018-08-0905:10justinleewhat dep did you add? I want to test#2018-08-0905:10lilactownhttps://github.com/nubank/workspaces/#2018-08-0905:10lilactowndeps.cljs defined here: https://github.com/nubank/workspaces/blob/master/src/deps.cljs#2018-08-0905:12justinleeyea look at that!#2018-08-0905:14justinlee@richiardiandrea there’s your answer. it does respect deps.cljs#2018-08-0905:16richiardiandreaAwesome @lilactown @lee.justin.m with this answer in mind my goal is to check if it works with cuerdas and fix it if not. Thank you! #2018-08-0906:46thheller@richiardiandrea deps.cljs works BUT in case of the shadow-cljsjs compatibility packages no deps.cljs is provided. that is because there is no way to selectively install :npm-deps. Since this package contains a lot of cljsjs.* shims adding a deps.cljs would always install too many packages. https://github.com/thheller/shadow-cljsjs#2018-08-0906:49thhellercuerdas is one of those cljsjs/foreign-libs compat things#2018-08-0906:49thhellertherefore its xregexp dep is not installed#2018-08-0906:53thhellerFWIW the thing I don't like about deps.cljs and :npm-deps is about their interaction with the compiler. using them to declare actual npm dependencies is fine by me#2018-08-0911:35urbanslugis there a cljs way of reading/setting env vars before starting the dev server?#2018-08-0911:37thhellernot sure I understand that question#2018-08-0911:38urbanslugSo I want to set some env vars that my cljs app should read to know e.g which API url to make requests to#2018-08-0911:38urbanslugalso have defaults#2018-08-0911:39thhellerassuming your app is :target :browser?#2018-08-0911:39urbanslugyes#2018-08-0911:39thhellerok what I always recommend is forgetting about env vars#2018-08-0911:39thhellerthe browser does not have env vars#2018-08-0911:40urbanslugOkay#2018-08-0911:40thhellertake this setup for example#2018-08-0911:40thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#L7-L12#2018-08-0911:40thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/public/index.html#L10#2018-08-0911:40thhellerit is absolutely fine and recommended to pass whatever "env" vars you want to the init method#2018-08-0911:41thhellerie. call <script>starter.browser.init({url:""});</script>#2018-08-0911:41thhellerand do whatever with that in the code#2018-08-0911:41thhellerso the HTML file controls the env#2018-08-0911:41urbanslugbut this var changes from dev to prod#2018-08-0911:42thhellerthats exactly the point. create a different html depending on env#2018-08-0911:42thhellerthe problem with feeding env vars to the compiler#2018-08-0911:43thhelleris that you actually have to recompile to get the changes in#2018-08-0911:43thhelleryou can also use :closure-defines https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2018-08-0911:45thhelleryou can also use :closure-defines {some.app/var #shadow/env "MY_VAR"} if you are deadset on using environment variables#2018-08-0911:46thhellerbut I really really do not recommend doing so.#2018-08-0911:46urbanslugI would expect one sets them only once when starting dev server or while doing advanced compilatiion so recompiling to get the changes in doesn't sound like a problem since as the closure defines describes it they are compile time constants#2018-08-0911:47urbanslugthe list of vars can be large#2018-08-0911:47urbanslug*grow#2018-08-0911:47thhellerwell .. if they are actually compile time constants then use :closure-defines#2018-08-0911:47thhellerbut often they are actual runtime configuration data#2018-08-0911:48thhellerand keeping them out of the compiler has many benefits, like being able to easily change them#2018-08-0911:48urbanslughmmm yeah they are runtime config data#2018-08-0911:50thhellerto me setting things in the HTML is the equivalent to what env vars usually do#2018-08-0911:50thhellersince they control the env#2018-08-0911:50thhellerdoing it in the compiler is just weird#2018-08-0911:50urbanslugok here's a situation. I set it in the html and read it in my init fn then from there I use a setter to create a sort of global for the app object that other functions can access#2018-08-0911:50thhellerwell don't you have a global state atom anyways?#2018-08-0911:51thhellereg. reagent, re-frame or whatever? all of them pretty much do#2018-08-0911:51thhellerjust put it in there in the init fn#2018-08-0911:51urbanslughmm ya#2018-08-0911:51urbanslug🙂#2018-08-0911:52thhellerotherwise a (my.app.env) (defonce config (atom {:the "defaults"})) also works#2018-08-0912:05urbanslugya I'll just swap! the app state#2018-08-0912:05urbanslugI'm wondering what could go wrong with two index.html files#2018-08-0912:06urbanslugnot two at the same time but...#2018-08-0912:06thhellerwhats your server side?#2018-08-0912:07urbanslugI expect to point nginx to get pointed to the index.html file of my choice#2018-08-0912:07urbanslugbut the SRE guys could feel different#2018-08-0912:08thhellerwell you can just use a build hook to generate a proper index.html#2018-08-0912:08urbanslug*index.html meaning intial html file#2018-08-0912:08thhelleror anything else you do to deploy really#2018-08-0912:08urbanslugI was wondering whether to use something like a build hook or sed to set the necessary vars in the index.html file#2018-08-0912:09urbanslugso that I have one#2018-08-0912:09thhellerif if you intended to call MY_ENV=foo shadow-cljs release your-build#2018-08-0912:09urbanslugyeah that would be great#2018-08-0912:09thhelleryou can call shadow-cljs release your-build && generate-prod-index.sh#2018-08-0912:09urbanslugaj#2018-08-0912:09urbanslug*ah#2018-08-0912:10thhelleryou can totally use env vars if you want to ... I just don't recommend it. up to you what you do#2018-08-0912:10urbanslugyeah the generate-prod-index.sh would edit the html file to have the necessary values for vars#2018-08-0912:10urbanslugmakes sense#2018-08-0912:11urbanslugand then init function would read them#2018-08-0912:11thhellerI know a few people use the clj-run option#2018-08-0912:12thhellerI do too https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-08-0912:12thheller
(defn release []
  (shadow/release :my-build)
  (generate-prod-index))
#2018-08-0912:12thhellershadow-cljs run my.build/release#2018-08-0912:12thhellerif you want to stay in clojure and not resort to other shell scripts#2018-08-0912:13urbanslugah seems perfect for my case#2018-08-0912:17urbanslugactually this is really good. It answers a lot of questions that I had#2018-08-0912:18thhelleryou can also split the shadow/release call into calling (shadow/get-config :my-build) updating that config (its just a map) and then calling shadow/release* with it#2018-08-0912:19thhellerso you could adjust the config pretty much any way you like#2018-08-0914:13lilactownis there a way to get closure to chill out about This code cannot be converted from ES6. extending native class: Array#2018-08-0914:14lilactownI’m trying to mess with the compiler options and adjust what it expects as input/output, but it’s not working quite yet#2018-08-0914:14thhellergonna need more info. never seen this message.#2018-08-0914:15lilactowna library I’m trying to do use does something akin to:
class Foo extends Array {
  ...
}
which Google Closure cannot convert to ES5
#2018-08-0914:16lilactowntheir advice is basically that they only support ES6#2018-08-0914:17thhellerwhich library?#2018-08-0914:17lilactownhttps://github.com/williamngan/pts/issues/22#2018-08-0914:19lilactownnpm install pts if you want to test it#2018-08-0914:21thhellermeh#2018-08-0914:21lilactown😂#2018-08-0914:22thhellerthe package doesn't contain the sources. only a pre-bundled webpack npm package#2018-08-0914:22thhellerwish people would start putting proper ES6 sources in their packages 😞#2018-08-0914:24lilactownit’s hard to get people to understand what to bundle/transpile vs not#2018-08-0914:25thhellerits easy: transpile anything that isn't standard es6 but not more#2018-08-0914:25lilactownI had to tell a bunch of contractors at work that no, you cannot deliver a bunch of internal npm packages that have JSX in them 🙃#2018-08-0914:25thhellerwell I guess for maximum compatibility you also want a commonjs package#2018-08-0914:26thhellerso es6 in node_modules usually gets transpiled by babel for reasons such as yours#2018-08-0914:26thhellerbut the file is not properly identifed as es6 since it doesn't have any import/export statements#2018-08-0914:26thhellerthats my mistake probably, closure probably identifies it properly when pre-parsing#2018-08-0914:27lilactownhm. this looks like a case where both babel and closure fail#2018-08-0914:28thhellerI have not yet figured out how to stop closure from transpiling#2018-08-0914:28thhellerfor some reason :language-out :ecmascript6 still transpiles most of the stuff out#2018-08-0914:28thhellerwhen there isn't actually a reason to do so#2018-08-0914:29thhellerare you sure that babel fails?#2018-08-0914:30thheller> Yes, Pt extends Float32Array so that we can keep all the native functions while adding new ones.#2018-08-0914:30lilactownit’s not babel AFAIK
[:workspaces] Compiling ...
Closure compilation failed with 1 errors
--- node_modules/pts/dist/pts.js:288
This code cannot be converted from ES6. extending native class: Array
#2018-08-0914:30thhellerah the good old OOP mentality 😉#2018-08-0914:30lilactownhahaha#2018-08-0914:30thheller@lilactown yes its not babel. I mean did you try babel manually since you said "babel and closure fail"#2018-08-0914:30thhellershadow-cljs currently does not try to use babel for that file#2018-08-0914:30lilactownoh I see what you mean. there might be a babel plugin we can use, but usually babel also cannot handle this#2018-08-0914:31lilactownhe mentions it in the issue#2018-08-0914:37thhellerbabel seems to work fine#2018-08-0914:38thhellerwell not sure if the package actually becomes usable but you can try it#2018-08-0914:39lilactown🤔 so should I vendor the lib and run babel on it, since shadow isn’t detecting that it’s ES6?#2018-08-0914:39thhellerno. I'll fix the detection part but first I want to verify that it actually works#2018-08-0914:40thhellersince I have no idea what pts actually does I could use some help with the verify part#2018-08-0914:41thhellerwhat you want to do is: in your project dir run npx babel --presets env node_modules/pts/dist/pts.js -o node_modules/pts/foo.js#2018-08-0914:41thhellerand then (:require ["pts/foo" ...]) instead of just pts#2018-08-0914:42thhellerhmm ok doesn't actually work#2018-08-0914:43thheller
TypeError: Constructor Float32Array requires 'new'
    at Pt.Float32Array (<anonymous>)
#2018-08-0914:48thheller@lilactown seems to work if you set :js-options {:language-out :ecmascript6}#2018-08-0914:49thhellerseems like it just can't be compiled down properly#2018-08-0914:49lilactown:face_palm: I was trying to set that in :compiler-options#2018-08-0914:50thhelleroh right. I don't think its properly documented for :js-options#2018-08-0914:51thheller:compiler-options is only for the final :advanced optimization#2018-08-0914:51thhellerbut since the JS sources don't go through that they have their own setting#2018-08-0914:52lilactownahhh#2018-08-0914:59lilactownoof yeah this library is painfully OO 😞#2018-08-0915:04wilkerlucioand docs sounds kind nice, could be cool to have a functional cljs wrapper around it#2018-08-0915:05lilactownyeah I’m going to get something working and then maybe start hacking on a CLJS interface#2018-08-0915:05lilactownthe library just looks freakin’ cool#2018-08-0916:21urbanslug@thheller Do I need to do anything to turn this JS object into a clj(s) obj <script>starter.browser.init({url:""});</script>#2018-08-0916:21urbanslugbecause in my case it's undefined in the cljs#2018-08-0916:27urbanslugnvm I wasn't using json#2018-08-0917:40thheller@urbanslug dont need to use json. js->clj it fine or just normal js interop#2018-08-0917:51currentoorhas anyone used shadow-cljs to develop on a raspberry pi?#2018-08-0917:52thhellerwhy would you do that to yourself? thats just gonna be way too slow 😉#2018-08-0917:53currentoorlol nice#2018-08-0917:53thhellerI mean running code on it is fine#2018-08-0917:53thhellerbut developing on it?#2018-08-0917:53currentoorwell the approach i was thinking was running shadow-cljs + emacs on my laptop and pushing the compiled js to the raspberry pi#2018-08-0917:54thhelleryeah thats fine#2018-08-0917:54currentooris there a hook somewhere in shadow-cljs to do this sort of thing?#2018-08-0917:54currentoorideally i’d have a dev environment with hot code reloading#2018-08-0917:55thhellerwell what do you want to build? assuming a node-script?#2018-08-0917:55currentoorthe only hooks i see are inside JS#2018-08-0917:55currentooryes a node script#2018-08-0917:55thhellerhow is the pi connected?#2018-08-0917:56thhellercan you mount a network drive on it?#2018-08-0917:56currentoorssh at the moment 😅#2018-08-0917:56thhellersshfs or something like that would work too#2018-08-0917:56currentooryeah i could do that#2018-08-0917:58thhellerah damn that would probably suffer the same issue I fixed yesterday#2018-08-0917:58thhellerdidn't release the fix yet though#2018-08-0917:59thhellerwell what I would probably do a) mount a sshfs drive on the pi that points to your local project#2018-08-0917:59thhellerb) run node out/your-thing.js on the pi#2018-08-0917:59thhellerthat will connect to your local machine for the hot-reload/repl stuff#2018-08-0918:00currentoorcool, what’s the issue you fixed?
#2018-08-0918:00currentoorand thank you!#2018-08-0918:00thhellerwell :node-script currently has some hard coded absolute paths#2018-08-0918:00thhellerso they basically only run on the machine they were compiled on#2018-08-0918:01thhellerduring development, release is fine.#2018-08-0918:01thhellerbut yeah the pi won't find the absolute path#2018-08-0918:01thhellerso that doesn't work#2018-08-0918:01currentoori see, so the above approach won’t work yet right?#2018-08-0918:01thhellerright now no#2018-08-0918:01thhellerI should have a release ready soon#2018-08-0918:02currentoorok no worries simple_smile#2018-08-0918:02currentooralso congrats on the clojurists together grant, well deserved!#2018-08-0918:02thhellerthx although I'm beginning to think I scammed myself#2018-08-0918:03thhellerspending way more time with this than I planned initially 😉#2018-08-0918:03thhellerbut its good to work on the stuff I wanted to work on for a while#2018-08-0918:03currentoorit’s definitely good for the community simple_smile#2018-08-0918:09urbanslugMore of a cljs question. I set a var as you said @thheller but when it comes to retrieving it from the app-state does something change? all my attemps to retrieve give me null/undefined#2018-08-0918:10thhellerhow are you setting it?#2018-08-0918:11urbanslug(-> @app-state :config :url) however it's there when I console log the (:config @app-state)#2018-08-0918:11urbanslug(swap! app-state merge {:config (js->clj config)})#2018-08-0918:11urbanslugwhere config is the var from js#2018-08-0918:12thhellerI'm confused. is it there or not?#2018-08-0918:14thhellerits there if you do (:config @app-state) but not when (-> @app-state :config :url)?#2018-08-0918:14urbanslugyes#2018-08-0918:14urbanslugor even (:url :config @app-state)#2018-08-0918:14urbanslugthe threading doesn't matter#2018-08-0918:14thhellerthats not valid#2018-08-0918:14urbanslughmm#2018-08-0918:14thheller(get-in @app-state [:config :url]) doesn't work?#2018-08-0918:15thhellersame as threading so it shouldn't be there either then#2018-08-0918:15urbanslugone sec#2018-08-0918:15thhellerah wait ...#2018-08-0918:16thhellerthe (:config @app-state) probably shows {"url" "..."} right?#2018-08-0918:16thhellerthats a string key and you are trying to get a keyword#2018-08-0918:16thhellertry either (get-in @app-state [:config "url"]) or (js->clj config :keywordize-keys true) when doing the initial swap!#2018-08-0918:19urbanslug> thats a string key and you are trying to get a keyword#2018-08-0918:19urbanslugya#2018-08-0918:19urbanslugfacepalm#2018-08-1011:44chrispsshadow-cljs test: is this just a placeholder for the future, or is it functional?#2018-08-1011:44thhellernot currently functional. use https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test instead#2018-08-1011:45thhellerit'll be back eventually#2018-08-1011:58chrispsok#2018-08-1012:14chrispsCan someone point me to a canonical shadow-cljs.edn file (testing and everything included).#2018-08-1012:14chrispsI know Leiningen has this, anything similar?#2018-08-1012:16thhellernot really. I'm working on a template solution similar to lein templates#2018-08-1012:16thhellerbut what do you want to know? the docs should contain everything you need#2018-08-1012:16thhellerif you still have questions please ask them so I can fill in the docs 😉#2018-08-1012:16chrispsI want to know what is wrong with my edn file#2018-08-1012:17chrispscli does not tell what is wrong#2018-08-1012:17thhellerwhat error do you get?#2018-08-1012:17chrispsshadow-cljs - error failed reading config file:#2018-08-1012:17thhellerprobably unbalanced parens#2018-08-1012:17chrispsobviously#2018-08-1012:18chrispsand paren balances the source oddly#2018-08-1012:18chrispsId expect test and app to be aligned#2018-08-1012:18chrispsbut it is offset by 1 char#2018-08-1012:18thhellerthen fix it?#2018-08-1012:19chrispshehe#2018-08-1012:19thhellerI can take a look if you want to post it here or priv msg#2018-08-1012:19thhellerwhich editor do you use?#2018-08-1012:20chrispsCursive#2018-08-1012:20chrispsI just need a simple example with valid syntax#2018-08-1012:20thhellerwith parinfer or paredit?#2018-08-1012:20chrispsturned off now, crazy stuff#2018-08-1012:20thhellervalid clojure is valid config syntax#2018-08-1012:21thheller:builds should be a map of :builds {:foo {...}}#2018-08-1012:21chrispsright#2018-08-1012:21thhellerif you want to see a gigantic config https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#2018-08-1012:21chrispsyes please#2018-08-1012:21chrispsjust what I needed, thank you sir#2018-08-1012:21thhellerbut don't take that as a best practice or anything, its my development config with lots of test config builds#2018-08-1012:21chrispsthis will do!!#2018-08-1012:22thhellershadow-cljs init will create a basic config for you#2018-08-1012:22thhellerthere will be a shadow-cljs new ... soon#2018-08-1012:22chrispsI just learned that I know nothing, so ….#2018-08-1012:22chrispsNow I will know 🙂#2018-08-1012:22thhellerthe "getting started" right now is pretty bad .. working on it#2018-08-1012:23chrispsdon’t let perfect be the enemy of good#2018-08-1012:25chrispsthe professionals can figure out the details, get the basic structure correct and be aware of cognitive overload#2018-08-1012:25chrisps(the current version suffers the latter, big time)#2018-08-1012:26thhellerstill curious to see your broken config though#2018-08-1012:26thhellerjust so I have something to test with and improve the error msg#2018-08-1012:28chrispsI understand that, but not right now#2018-08-1012:30chrispsthe problem was: unbalanced parens, or more specific: skewed parens#2018-08-1012:30chrispssince I’m fault free all the time, I blame it on parinfer#2018-08-1012:30chrisps(not really)#2018-08-1012:33chrispsyour “canonical” .edn file just ensured I was not crazy#2018-08-1012:33chrisps(just sloppy)#2018-08-1013:00chrispsCan I trust 9.2. Testing in the Browser chapter to be true?#2018-08-1013:22thhelleryes (could be a lot cleaner though)#2018-08-1013:26chrispscould be cleaner, but take care, love what you do!!#2018-08-1018:50currentoor@thheller you mentioned the running nodejs remote fix might be in the next release, just wondering how far that might be?#2018-08-1018:50currentoorand should i just check the npm page for updates? or are releases announced elsewhere?#2018-08-1018:51thhellerI'm working on rather big branch right now that I don't want to leave#2018-08-1018:51thhellerhope to get that done soon though. hopefully today.#2018-08-1018:51currentoormuch obliged simple_smile#2018-08-1019:33kurt-o-sysI have an app in cljs which compiled within a few dozens of seconds, which is fine. However, now, it takes a very long time, if it ever succeeds. Even after reverting my last changes, compilation seems to take forever. Is there a way to 'debug'/profile compilation? (cross-posted from #clojurescript)#2018-08-1019:33thheller@kurt-o-sys try shadow-cljs watch app --verbose#2018-08-1019:33kurt-o-sysok, thx.#2018-08-1019:35thhellerthe extra warnings from closure you are seeing should be gone in the latest version btw (they didn't matter anyways)#2018-08-1019:35kurt-o-sysoh, ok, will check.#2018-08-1019:36kurt-o-sysAm I looking for anything particular in the verbose compilation?#2018-08-1019:37thhelleranything suspiciously long I guess?#2018-08-1019:37kurt-o-syswell... it just hangs right now, not sure where exactly:
-> Cache read: ui_app/panels/booking_detail/location.cljs
<- Cache read: ui_app/panels/booking_detail/contact_details.cljs (56 ms)
-> Cache read: ui_app/panels/booking_detail/contact_detail.cljs
<- Cache read: ui_app/panels/booking_detail/location.cljs (19 ms)
<- Cache read: ui_app/panels/booking_detail/contact_detail.cljs (47 ms)
#2018-08-1019:37kurt-o-syslast 5 lines, nothing new apears.#2018-08-1019:38thheller-> means it started doing something, <- means it finished that something with x time#2018-08-1019:39thhellerso I guess look for the last -> line that doesn't have a <-#2018-08-1019:39thhellerhard to make that output cleaner with text only#2018-08-1019:41kurt-o-sys
-> Cache read: cljs/core/match.cljs
#2018-08-1019:41kurt-o-sysdoesn't finish#2018-08-1019:42thhellerhmm it might be gigantic#2018-08-1019:42thhellerthere was a caching bug where the files would get larger with each compile#2018-08-1019:43kurt-o-sysand I found another one.#2018-08-1019:43thhellerbut I think that was fixed in 2.4.28 already#2018-08-1019:43kurt-o-systhere may be a few.#2018-08-1019:43kurt-o-sysok... let me check.#2018-08-1019:43thhellercheck .shadow-cljs/builds/app/dev/ana/cljs/core/match*#2018-08-1019:43thhellerhow large is it?#2018-08-1019:44thhelleryeah the cache bug was fixed in 2.4.20#2018-08-1019:45kurt-o-sysoh, small... 6.4k#2018-08-1019:45thhellerok its not that then#2018-08-1019:45thhellerits using a threadpool, so its probably just stuck behind some other tasks#2018-08-1019:45thhellercheck if you find another ->?#2018-08-1019:46kurt-o-sysyeah, one of my ns, small one.#2018-08-1019:46kurt-o-syswill try again#2018-08-1019:46thhellermight be an infinite macro expansion?#2018-08-1019:47thhelleris the CPU at 100%?#2018-08-1019:47kurt-o-sysit is. 4.9GB memory, CPU 100%#2018-08-1019:47kurt-o-sysI haven't got any macro's myself, so it would be another one...#2018-08-1019:48thhellerkinda hard to debug since you are using lein#2018-08-1019:48kurt-o-sysok...#2018-08-1019:49thhellerwell wouldn't be much easier without but I could rule out classpath issues 😛#2018-08-1019:49kurt-o-sysso, if I add the dependencies to shadow-cljs, it would be easier?#2018-08-1019:49kurt-o-syslol, ok 🙂#2018-08-1019:49thhellertry to find the very first incomplete -> though#2018-08-1019:50guilherme.teodorohi, I’m using a npm library and babel is returning a TypeError: Uncaught TypeError: Cannot instantiate an arrow function. Anyone can help me?#2018-08-1019:50thhellereverything depending on that will be stuck behind that#2018-08-1019:50thheller@guilherme.teodoro babel is returning?#2018-08-1019:51kurt-o-sys@thheller nice - that will keep me busy for a while 😛#2018-08-1019:51thheller@kurt-o-sys you can send me the full log to <mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>. I can take a look if you want#2018-08-1019:52thhellerlein deps tree would help too, or the project.clj. no need to switch everything.#2018-08-1019:53guilherme.teodoro@thheller Thx. I will send#2018-08-1019:53kurt-o-sysoh, I will try myself first 😛#2018-08-1019:54thheller@kurt-o-sys its very unlikely to be a dependency conflict though. I don't think any dep conflict causes an infinite loop during complation#2018-08-1019:54thhellernot sure what it could be though. I've only seen such problems with infinitely expanding macros#2018-08-1019:55thhelleris only the CPU busy or disk too?#2018-08-1019:55thhellerhmm disk should be idle. cache is done async after compilation is done.#2018-08-1019:59thheller@guilherme.teodoro what do you mean by "babel is returning". that looks like a thrown exception in the browser? also the full error would help.#2018-08-1020:05thhellerah thx. got the email.#2018-08-1020:18kurt-o-sys@thheller I seem to be getting there. Probably something with a package called graphql-builder and queries or syntax or so. At least, I can compile again if I remove some graphql-queries 😛. Thx!#2018-08-1020:19thhellerah yeah that parses graphql at compile time right?#2018-08-1020:20thheller@guilherme.teodoro that @absinthe/socket package is probably the weirdest code I have ever seen. no idea whats happening though.#2018-08-1020:21kurt-o-sys@thheller yes, graphql parses plain queries at compile time. The problem seems to be: I defined a query with the same name twice.#2018-08-1020:32guilherme.teodoro@thheller hahaha that’s true.#2018-08-1020:32thheller
.bind(void 0)
      , getHandlerName = function(e) {
        return _newArrowCheck(this, _this$4),
        "on" + String(e)
    }
    .bind(void 0)
      , notify = function(e, n, i) {
        return _newArrowCheck(this, _this$4),
        e.observers.forEach(getNotifier(getHandlerName(n), i))
    }
    .bind(void 0)
      , _this$6 = void 0
      , findIndex = function(e, n, i) {
        return _newArrowCheck(this, _this$6),
        e.findIndex(utilsComposite.hasIn([n], i))
    }
    .bind(void 0)
      , _this$5 = void 0
      , remove$1 = function(e) {
        return _newArrowCheck(this, _this$5),
        function(n) {
            return _newArrowCheck(this, _this$5),
            utilsArray.remove(findIndex(n, "request", e.request), 1, n)
        }
        .bind(this)
    }
#2018-08-1020:33thhellerwhat even is this? I thought I knew JS. guess I don't#2018-08-1020:34guilherme.teodoroError:
Uncaught TypeError: Cannot instantiate an arrow function
    at exports.default (newArrowCheck.js:8)
    at index.js:2
    at Object.kitasato$events$create_absinthe_socket [as create_absinthe_socket] (events.cljs:250)
    at events.cljs:260
    at events.cljs:260
this method:
["@absinthe/socket" :as absinthe]
;; ....
line 250: (.create absinthe phoenix-socket)
#2018-08-1020:35thheller@guilherme.teodoro yes I reproduced the error. can't figure out what is happening though. the JS is just weird.#2018-08-1020:36guilherme.teodoroI see#2018-08-1020:37guilherme.teodoroJS made by Elixir developers#2018-08-1020:37thhellernah its seems flow generates that kind of code for arrow functions#2018-08-1020:40thhellerI'm lost. can you confirm that this actually works fine in a webpack or so build? I don't see anything shadow-cljs could be doing differently#2018-08-1020:45guilherme.teodoroNo, I made the CLJSJS package using the umd version https://unpkg.com/@absinthe/socket@0.1.10/compat/umd/index.js#2018-08-1020:46guilherme.teodoroSo, I don’t if works in webpack#2018-08-1020:46thhellerthat also doesn't work for me?#2018-08-1020:46thhelleryou can just require ["@absinthe/socket/compat/umd/index" :as absinthe] to use that directly#2018-08-1020:48guilherme.teodorohmmm, I’m gonna try#2018-08-1020:49guilherme.teodoroSame error#2018-08-1020:50thhellerbut the cljsjs package worked?#2018-08-1020:50guilherme.teodoroWhen I was using lein, yes#2018-08-1020:51guilherme.teodoroCan I use cljsjs package with shadow-cljs?#2018-08-1020:52thhellerno#2018-08-1020:54thhellerjust ["@absinthe/socket" :as absinthe] and calling (absinthe/create nil) is enough to trigger the problem though#2018-08-1020:54thhellernot sure whats happening but at least its reproducible#2018-08-1020:55guilherme.teodoroit’s so weird…#2018-08-1021:12thhelleryeah I give up. can't figure it out.#2018-08-1021:15thhellerhttps://github.com/thheller/shadow-cljs/issues/365 I'll see if I can figure out when I'm less tired.#2018-08-1021:21guilherme.teodoroOk, thanks#2018-08-1109:08cjmurphyIf in JavaScript see import simplify from 'simplify-js'; then after npm install simplify-js working fine I ought to be able to require: ["simplify-js" :refer (simplify)] and look at simplify and it should not be undefined. Is that correct?#2018-08-1109:09thheller@cjmurphy see the translation table: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2018-08-1109:09thhellerimport simplify .. is a default export. so it would be ["simplify-js" :default simplify].#2018-08-1109:10thheller["simplify-js" :refer (simplify)] is equiv to import { simplify } from 'simplify-js';. note the extra {}. ES6 imports are weird.#2018-08-1109:12cjmurphyThanks again. Bookmarking that table now...#2018-08-1109:13thhellersee the section below about default exports#2018-08-1109:13thhellerthe REPL is very useful for checking out how packages are actually structured#2018-08-1109:59thhellerLooking for some feedback here: https://clojureverse.org/t/poll-reworking-the-launcher/2633#2018-08-1114:55daviwilAhhh, time to enjoy some weekend ClojureScript thanks to shadow-cljs 🙂#2018-08-1202:00yqrashawnHi guys. I’m new to clojure and shadow-cljs. I encountered this error when shadow-cljs watch app#2018-08-1202:00yqrashawn
shadow-cljs - config: /Users/yqrashawn/workspace/HOME/right-site/shadow-cljs.edn  cli version: 2.4.33  node: v9.8.0
shadow-cljs - starting ...
Aug 12, 2018 9:54:04 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 12, 2018 9:54:04 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
Exception in thread "main" java.lang.AssertionError: Assert failed: (qualified-symbol? sym)
        at shadow.cljs.devtools.server.nrepl04$middleware_load.invokeStatic(nrepl04.clj:269)
        at shadow.cljs.devtools.server.nrepl04$middleware_load.invoke(nrepl04.clj:269)
        at clojure.core$map$fn__5587.invoke(core.clj:2745)
        at clojure.lang.LazySeq.sval(LazySeq.java:40)
        at clojure.lang.LazySeq.seq(LazySeq.java:49)
        at clojure.lang.RT.seq(RT.java:528)
        at clojure.core$seq__5124.invokeStatic(core.clj:137)
        at clojure.core$filter$fn__5614.invoke(core.clj:2801)
        at clojure.lang.LazySeq.sval(LazySeq.java:40)
        at clojure.lang.LazySeq.seq(LazySeq.java:49)
        at clojure.lang.RT.seq(RT.java:528)
        at clojure.core$seq__5124.invokeStatic(core.clj:137)
        at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
        at clojure.core.protocols$fn__7835.invokeStatic(protocols.clj:75)
        at clojure.core.protocols$fn__7835.invoke(protocols.clj:75)
        at clojure.core.protocols$fn__7781$G__7776__7794.invoke(protocols.clj:13)
        at clojure.core$reduce.invokeStatic(core.clj:6748)
        at clojure.core$into.invokeStatic(core.clj:6815)
        at clojure.core$into.invoke(core.clj:6807)
#2018-08-1202:00yqrashawnAny idea?#2018-08-1202:06lilactownis this with a fresh project?#2018-08-1202:06yqrashawnit’s generated by re-frame-template#2018-08-1202:07yqrashawnhttps://github.com/Day8/re-frame-template#2018-08-1202:09lilactowncan you post your shadow-cljs.edn?#2018-08-1202:10yqrashawn
{:nrepl {:port 9898
         :middleware [[cider/piggieback "0.3.5"]]}
 :http {:port 3333
        :host "0.0.0.0"}
 :source-paths ["src/clj" "src/cljs"]
 :dependencies [[org.clojure/clojure "1.8.0"]
                [org.clojure/clojurescript "1.10.238"]
                [reagent "0.7.0"]
                [re-frame "0.10.5"]
                ;; [secretary "1.2.3"]
                [garden "1.3.5"]
                [ns-tracker "0.3.1"]
                [compojure "1.5.0"]
                [bidi "2.1.3"]
                [yogthos/config "0.8"]
                [ring "1.4.0"]
                [re-pressed "0.2.2"]
                [re-frisk "0.5.3"]
                [binaryage/devtools "0.9.10"]
                [day8.re-frame/re-frame-10x "0.3.3"]]

 :builds
 {:app {:target :browser
        :output-dir "resources/public/js/compiled/"
        :asset-path           "js/compiled/out"
        :modules {:main {:entries [right-site.core]}}
        :devtools {:http-root "resources/public"
                   :http-port 3000
                   :http-host "0.0.0.0"
                   :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]
                   :autoload true}}}}
#2018-08-1202:12yqrashawn
src
├── clj
│  └── right_site
│     ├── core.clj
│     ├── css.clj
│     ├── handler.clj
│     └── server.clj
└── cljs
   └── right_site
      ├── config.cljs
      ├── core.cljs
      ├── db.cljs
      ├── events.cljs
      ├── home-page
      │  ├── home_page_data.cljs
      │  └── home_page_views.cljs
      ├── login-page
      │  ├── login_page_data.cljs
      │  └── login_page_views.cljs
      ├── routes.cljs
      ├── subs.cljs
      └── views.cljs
#2018-08-1202:16yqrashawnI just removed the :middleware [[cider/piggieback “0.3.5”]] and it works.#2018-08-1202:17yqrashawnIs the middleware syntax wrong?#2018-08-1202:17lilactownyeah that’s what I was going to try next#2018-08-1202:17lilactownit might be a couple different things#2018-08-1202:18lilactownI think it’s unnecessary, since shadow-cljs provides it’s own version of piggieback#2018-08-1202:21lilactownnot exactly sure why it’s throwing, but you should be fine to develop without it as a dependency#2018-08-1202:23yqrashawnThanks. I’ll try.#2018-08-1202:33yqrashawnI created a issue in case someone else stuck with the same question. https://github.com/thheller/shadow-cljs/issues/366#2018-08-1207:49thheller@namy.19 thanks for the report. I'll probably just filter out manually specified piggieback middleware in the future.#2018-08-1208:30urbanslugAnyone know how to kill the nrepl server?#2018-08-1208:31urbanslugWhen I try to start the repl in emacs I keep getting an error
error in process sentinel: Could not start nREPL server: shadow-cljs - config: .../shadow-cljs.edn  cli version: 2.4.11  node: v10.8.0
shadow-cljs - connected to server
server already running

#2018-08-1208:32thheller@urbanslug shadow-cljs stop should stop it#2018-08-1208:34urbanslugthanks#2018-08-1208:36urbanslugemacs still gives the error 😬#2018-08-1208:37urbanslugbtw @thheller when I put the constants in my html they tended to get lost on files changes#2018-08-1208:37urbanslugWhen I modified cljs files#2018-08-1208:37thhellerhmm?#2018-08-1208:37thhellerdo you reset your state on reload?#2018-08-1208:42urbanslugI don't think I do. I don't have code that resets the app-state no#2018-08-1208:43thhellerdo you have a (defonce app-state ..) or (def app-state ..)?#2018-08-1208:54urbanslug
(defonce app-state (r/atom default-app-state))
where default-app-state is an object
#2018-08-1208:54urbanslugbut I transact this app state in my init to add the runtime args#2018-08-1208:56thhellerand you only call init once? its not a hook or anything?#2018-08-1208:56thhellerI don't know your app setup but if state in the atom gets lost that on your side of things#2018-08-1208:56thhellershadow-cljs doesn't mess with your atoms#2018-08-1209:10urbanslugYes I only call init once. I will investigate#2018-08-1218:08JonI think now I have trouble download that jar file from GitHub,#2018-08-1218:09thhelleryeah sorry about that. still trying to figure out how to deal with this.#2018-08-1218:09Jonnot even managed to do it with proxychains, although proxychains4 wget ....jar worked.#2018-08-1218:09thhellerI really want to get rid of the mandatory shadow-cljs-jar dependency#2018-08-1218:09Joncan I download it manually?#2018-08-1218:09Jonor redirect the link to another domain where I can prepare that jar file?#2018-08-1218:10thhelleryes, you can put it into ~/.shadow-cljs/shadow-cljs-launcher-2.0.0.jar manually#2018-08-1218:11JonDownloaded and it's running#2018-08-1218:13JonDoes shadow-cljs make use of proxychains?#2018-08-1218:13thhellerno. I don't even know what that is 😛#2018-08-1218:13thhellerits just doing a simple download using the node https package#2018-08-1218:13Jonhttps://github.com/haad/proxychains#2018-08-1218:14JonI need this proxy to access Google#2018-08-1218:14Jonand download files from GitHub, which has amazon addresses#2018-08-1218:15Jonof socks5 specifically. But in command line tools, proxychains is required.#2018-08-1218:15thhellerso my current thought is to continue providing the shadow-cljs-jar package but not depend on it#2018-08-1218:15thhellerso you install it manually#2018-08-1218:16thhellerwould that work? annoying but npm works right?#2018-08-1218:17thhellerjust haven't figured out how to ensure the correct version numbers with this way#2018-08-1218:19Joninstall it manually means download and put it in ~/.shadow-cljs/?#2018-08-1218:19thhellerno you npm install shadow-cljs shadow-cljs-jar#2018-08-1218:20thhellerpreviously shadow-cljs just depended on shadow-cljs-jar but I want to get rid of that extra npm download since it mostly wasted#2018-08-1218:20Jonit's okay in my case. they are peerDependencies.#2018-08-1218:20thhelleronly considering adding it back for chinese users as an alternate to the github download if that so unreliable#2018-08-1218:21Jonunreliable, 😄#2018-08-1218:21thhellerchinese internet is a bit scary#2018-08-1218:26Jonagreed.#2018-08-1218:30thhellerhmm I could create a shadow-cljs-standalone package which downloads shadow-cljs and the launcher (via npm)#2018-08-1218:31Jonhaha#2018-08-1218:32JonI think I can't finish running new version tonight.. going to bed, bye~#2018-08-1218:32thhellerwell you don't have to upgrade, nothing new in it besides the launcher#2018-08-1218:35thhelleroh there is actually one new thing. @currentoor the change to :npm-script is in 2.5.0 so it should be now possible to do the raspberry pi development we talked about.#2018-08-1218:38currentoorThank you so much!#2018-08-1218:38currentoorI’ll try later today #2018-08-1218:46thhelleryou'll probably need to set :output-to "out/script.js" :output-dir "out/something". by default :output-dir is set to something that might not be reachable on the pi#2018-08-1220:25currentoorso i made a directory on my laptop pi and mounted the raspberry pi’s filesystem on it#2018-08-1220:25currentoorset these values
:output-dir "pi/nodetest/ucv_tcs"
                :output-to  "pi/nodetest/main.js"
#2018-08-1220:25currentoorbut when i try to run the compiled file i get
Error: ENOENT: no such file or directory, open '/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime/goog.debug.error.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at global.SHADOW_IMPORT (/home/pi/nodetest/main.js:46:15)
    at /home/pi/nodetest/main.js:3005:1
    at Object.<anonymous> (/home/pi/nodetest/main.js:3200:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
#2018-08-1220:26currentooroh wait i forgot to update shadow-cljs#2018-08-1220:26currentoor:man-facepalming:#2018-08-1220:36currentooryeah @thheller i’m still getting that error even after updating#2018-08-1220:38currentoori see this in the compiled out put#2018-08-1220:38currentoor
var SHADOW_IMPORT_PATH = "/Users/currentoor/src/ucv/pi/nodetest/ucv_tcs/cljs-runtime";
#2018-08-1220:38currentoormaybe i misunderstood what you said earlier, i thought this was no longer going to be an absolute path?#2018-08-1220:39currentoorif i manually edit that variable to be a relative path it works, except the repl doesn’t seem to connect#2018-08-1220:40currentoor
REPL client error { Error: connect ECONNREFUSED 127.0.0.1:9630
    at Object._errnoException (util.js:992:11)
    at _exceptionWithHostPort (util.js:1014:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 9630 }
REPL client disconnected
#2018-08-1220:41currentoornot a caching thing, i tried lein clean#2018-08-1220:44thhelleruhm that is definitely not the upgraded code#2018-08-1220:45thhellershould be something starting with var SHADOW_IMPORT_PATH = __dirname +#2018-08-1220:45thhellerthe host thing you just need to configure#2018-08-1220:46thheller:devtools {:devtools-url "http://<ip-of-your-machine>:9630"}#2018-08-1220:48currentoorhmm, i nuked node_modules and did an npm install#2018-08-1220:48currentoorthese lines are printed when i start shadow-cljs#2018-08-1220:48thhelleryou said lein clean? are you using lein?#2018-08-1220:48currentoor
shadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn  cli version: 2.5.0  node: v10.4.1
shadow-cljs - running: lein with-profile cljs run -m shadow.cljs.devtools.cli --npm watch tcs
#2018-08-1220:48currentooryes i am#2018-08-1220:48thhellerdo you have a shadow-cljs version in project.clj?#2018-08-1220:49thhellerlook further down in the printed messages#2018-08-1220:49thhellerthe versions on top are the npm package versions#2018-08-1220:49currentooryes that was it#2018-08-1220:52currentoori forgot project.clj had it too#2018-08-1220:53currentoorthat worked beautifully!#2018-08-1220:53currentoorthanks again!#2018-08-1218:36Jon
=>> yarn watch
yarn run v1.9.4
$ shadow-cljs watch client
shadow-cljs - config: /Users/chen/repo/mvc-works/calcit-workflow/shadow-cljs.edn  cli version: 2.5.0  node: v10.8.0
shadow-cljs - starting 2.5.0 with launcher 2.0.0 ...
Downloading: thheller/shadow-cljs/2.5.0/shadow-cljs-2.5.0-aot.jar from 
Downloading: org/clojure/clojurescript/1.10.339/clojurescript-1.10.339-slim.jar from 
Downloading: com/google/javascript/closure-compiler-externs/v20180805/closure-compiler-externs-v20180805.jar from 
Downloading: com/google/javascript/closure-compiler-unshaded/v20180805/closure-compiler-unshaded-v20180805.jar from 
Downloading: com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar from 
Aug 13, 2018 2:34:44 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 13, 2018 2:34:44 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 
shadow-cljs - server version: 2.5.0
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 53885
shadow-cljs - nREPL server started on port 53887
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build completed. (198 files, 98 compiled, 0 warnings, 32.43s)
#2018-08-1218:36Jonfinally.#2018-08-1218:36Jonit was downloading jar files, took long time.#2018-08-1218:36Jon
{:source-paths ["src" "cli"]
 :mirrors {"central" {:name "central"
                       :url ""}}
#2018-08-1218:37thhelleroh shit .. I don't think :mirrors works anymore#2018-08-1218:37JonI added mirrors, it was expected to use aliyun#2018-08-1218:37thhellertotally forgot to check if tools.deps actually supports that#2018-08-1218:37Jonso it's a bug? 😮#2018-08-1218:37thhelleryes.#2018-08-1218:38Jonokay. 🤔#2018-08-1218:38JonI'm going to bed. too late. bye.#2018-08-1218:39thhellergn8#2018-08-1219:56hlollidoes shadow-cljs offer any way to run a script before compilation. What I'm looking to do, is compiling for browser where I sed replace a variable with base64 of a .wasm file but compile to node without that replace. It would be nice to avoid having two copies of that emscripten bindings file, as one would include few mb string and the other not.#2018-08-1219:57thhellereither https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run or https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-08-1219:57hlolliSo that the script would replace in the "stream" but not the file itself.#2018-08-1219:57hlolliah I see, I think that would be enough!
#2018-08-1219:57hlollithanks!#2018-08-1219:58thhellerwont base64 make the file huge? isn't it better to download it independently via xhr?#2018-08-1220:01hlolliyes it makes a very huge file. But the mechanism in the wasm bindings makes it bit tedious to bundle the app, it's a window.fetch and needs cors to work right, as well as not working with file:// protocol. As I'm makeing a library that mostly non-programmers use, just one script tag makes it easier for everyone.#2018-08-1220:02hlollibut in node, it doesn't make sense to do it, and actually overflows the heap.#2018-08-1220:04thhellercors to download a text file?#2018-08-1220:05thhellerah nvm. probably not downloading from the same domain then#2018-08-1300:20hlolliI may be wrong, but I feel like the returned build-state from :compile-prepare and/or :compile-finished isn't ending up in the source code, be it watch or release. Just doing string/replace on the string of js resource (nested under :sources [:shadow.build.npm/resource "libcsound/libcsound.js"] :source)#2018-08-1308:08thheller@hlolli what I would suggest is creating a libcsound/libcsound_browser.js and then in package.json use a "browser":{"libcsound/libcsound.js": "libcsound/libcsound_browser.js"} override#2018-08-1308:09thhellerthis will cause pretty much all JS build tools (including shadow-cljs) to include the libcsound/libcsound_browser.js when building for the browser#2018-08-1308:09thhellerbut otherwise use the node version#2018-08-1308:10thhellerhttps://github.com/defunctzombie/package-browser-field-spec#replace-specific-files---advanced#2018-08-1309:02hlolli@thheller didn't know about this funtionality with "browser", sweet. Was hoping to avoid having two copies of that file. As it would essentialy mean two copies of the wasm binary as well. Is what I'm trying to do, in build-state, assoc-ing-in :sources a new source string, possible?#2018-08-1309:03thhelleryes but not recommended because you destroy source maps that way#2018-08-1309:03hlollihere my hook
(defn wasm2datauri
  {:shadow.build/stage :compile-finish}
  [build-state & args]
  (let [resrc   [:shadow.build.npm/resource "libcsound/libcsound.js"]
        src     (get-in build-state [:sources resrc :source])
        wasm    (string/trim (:out (sh "node" "libcsound/datauri.js")))
        new-src (string/replace src "libcsound.wasm" wasm)]
    (assoc-in build-state [:sources resrc :source] new-src)))
#2018-08-1309:03hlolliah ok, it's only one line, so won't create a new line.#2018-08-1309:04thhellercan't do it in :compile-finish though#2018-08-1309:05thhellerbut I really do not recommend doing it this way#2018-08-1309:05thhellerit messes with the cache as well#2018-08-1309:06hlolliah I see.. maybe only in release, as flush?#2018-08-1309:06hlollino it uses cache too I guess#2018-08-1309:07hlollican I calculate sha256sum of the string and replace it with what the cache hash value?#2018-08-1309:08thhellerwhy reinvent the wheel though? "browser" is exactly for cases such as yours?#2018-08-1309:09thhellerdo you have the code available somewhere? I kinda don't understand what exactly you are trying to do#2018-08-1309:09hlolliI'm just trying to avoid having two different files, just create the file/string during compilation#2018-08-1309:09thhellerwhy does it have to be during compilation though?#2018-08-1309:09thhellerwhy not do it before?#2018-08-1309:10thhellertrying to do this as part of the compilation itself just makes it 100x more complicated#2018-08-1309:11hlollithen I have two 6mb files, 1 is js bindings files from emscripten, another .wasm, and when the .js file gets 6mb with the base64 string, it's hell to open and edit.#2018-08-1309:11thhellerno I mean create the file before you run shadow-cljs#2018-08-1309:11thhellernode create-that-browser-file.js && shadow-cljs ....#2018-08-1309:11hlolliah yes#2018-08-1309:11hlollihaha of course#2018-08-1309:12hlolliI can hook shadow to delete it after compilation#2018-08-1309:12hlollibingo!#2018-08-1309:12thhellerif the extra file is a problem you could also create a secondary package?#2018-08-1309:13thhellerlibcsound-browser or whatever#2018-08-1309:13thhellerand include that via :resolve settings#2018-08-1309:13hlolliyup, that's what I previously did.#2018-08-1309:13hlolliand that works too#2018-08-1309:14hlolliso I'm only trying to simplify, by having 1 copy of every file that I need.#2018-08-1309:14thhellerwhat you are trying to do doesn't exactly sound simple to me#2018-08-1309:15hlolliyes, I can see how you see that. And it's probably true.#2018-08-1309:16thhelleryou could also use a CLJS macro and read the file directly during compilation#2018-08-1309:16thhellerbut no idea if that works with the way the js bindings are setup#2018-08-1309:18hlolliyes, didn't consider that, a macro. I guess a slurp can be evaled by a macro.#2018-08-1309:18thhellerI strongly suggest however that you do whatever you need to do BEFORE shadow-cljs compilation starts#2018-08-1309:19thhellerand then compiling everything normally#2018-08-1309:19thhellerdoing it during compilation will just break in various ways#2018-08-1309:19hlolliyes, your suggestion above, just use package.json script and create the file before, sounds clean to me#2018-08-1313:34pauldI have a lein project that I want to use shadow-cljs for, so I included [thheller/shadow-cljs "2.5.0"] in the project.clj deps. However now I get an Exception when I run lein cljsbuild once min:#2018-08-1313:35pauld#2018-08-1314:00thheller@pauld there is figwheel in that stacktrace and not shadow-cljs?#2018-08-1314:01pauldI know, very strange.#2018-08-1314:04thhellerah you have a user.clj that loads figwheel on startup#2018-08-1314:04thhellerthe problem is an old closure compiler version#2018-08-1314:05thhellercheck lein deps :tree#2018-08-1314:07pauldah! thanks - that fixed it#2018-08-1314:07pauldI had an older clojurescript dep#2018-08-1314:08pauldI'm wondering if I can run a build report on this lein project.#2018-08-1314:09pauldnpx shadow-cljs run shadow.cljs.build-report app report.html#2018-08-1314:09thhellerdepends on the cljsjs deps. some may not work#2018-08-1314:09pauldyeah I do get an error#2018-08-1314:10pauldCaused by: /home/paul/.m2/repository/cljsjs/create-react-class/15.6.0-1/create-react-class-15.6.0-1.jar deps.cljs refers to file not in jar: cljsjs/create-react-class/production/create-react-class.min.inc.js#2018-08-1314:10thhellerthats an old reagent version I think#2018-08-1314:10thhellerit was fixed a while ago though.#2018-08-1314:11thhelleryou can just exclude cljsjs/create-react-class from your deps for that one#2018-08-1314:12pauldI will have to see where it gets pulled. It's a qlkit transitive dependency.#2018-08-1314:13pauld[cljsjs/create-react-class "15.6.2-0"] [cljsjs/react "16.2.0-3"] [cljsjs/react-dom "16.2.0-3"]]#2018-08-1314:33pauld#2018-08-1314:34pauldOr is there newer version I should be getting? say from npm?#2018-08-1314:34pauldI get the following error now:#2018-08-1314:35pauld#2018-08-1314:50hlolli@pauld I would use react and react-dom from npm isntead of cljsjs when useign shadow-cljs#2018-08-1314:51pauldAnd what if the clojurescript library I use - uses it?#2018-08-1314:51pauldcan I do some :excludes to make the switch?#2018-08-1314:53ClashTheBunnyYou can just provide it by providing the CLJS namespace.#2018-08-1314:55ClashTheBunnyLike this example: https://github.com/kurtharriger/shadow-cljs-reframe-template/blob/master/src/cljs/cljsjs/react.cljs#2018-08-1314:55ClashTheBunnyThat way, your dependent library gets react in the namespace it expects.#2018-08-1315:06thhelleryou don't actually need those for the most common dependencies#2018-08-1315:06thhellerthey are provided by https://github.com/thheller/shadow-cljsjs#2018-08-1315:06thhellerits just that one exception that had a buggy cljsjs release#2018-08-1315:07thhellerotherwise you don't need to exclude cljsjs dependencies#2018-08-1315:07pauldyeah react stuff seems to work after npm install except:#2018-08-1315:07pauldCaused by: The required namespace "cljsjs.material-ui" is not available, it was required by "qlkit_material_ui/core.cljs".#2018-08-1315:08thhelleryeah that would require one such wrapper#2018-08-1315:09thheller
(ns cljsjs.material-ui
  (:require ["material-ui" :as mui]))

(js/goog.exportSymbol "MaterialUI" mui)
#2018-08-1315:09thhellerI'm not exactly sure what the global or npm package are for those though#2018-08-1315:09thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-08-1315:10thhellerbut FWIW since you want build-reports anyways. material-ui is one of those huge packages#2018-08-1315:11thhellerand its much much better to only include what you actually need.#2018-08-1315:11thhellerlike @material-ui/core/Button#2018-08-1315:11thhellerbut qlkit probably assumes that you use everything#2018-08-1315:11pauldyeah... I read that somewhere#2018-08-1315:12pauldI wonder how I would go about trimming down qlkit deployment size#2018-08-1315:14pauldnpm installing cljsjs dependencies, putting in excludes, wrapping where necessary and putting in only specific material-ui deps via npm install?#2018-08-1315:14thhellerIn my example I posted a comparison for antd vs individual antd components#2018-08-1315:14thhellerhttps://clojureverse.org/t/shadow-cljs-build-reports/2284#2018-08-1315:14thhellerand thats 1.6mb vs 350kb#2018-08-1315:14thhellermaterial ui is larger than that#2018-08-1315:15thhellerthe problem is with qlkit. if that always imports the material-ui "meta" package which in turn includes everything else#2018-08-1315:15thhelleryou won't get a smaller bundle#2018-08-1315:15pauldso only option is to fork qlkit?#2018-08-1315:16thhellergeez#2018-08-1315:16thhellerhttps://github.com/forward-blockchain/qlkit-material-ui/blob/master/src/qlkit_material_ui/core.cljs#L2-L3#2018-08-1315:16thhellerthe svg-icons are another megabyte or so I believe#2018-08-1315:22thheller
-rw-rw-rw- 1 thheller thheller 1007K Feb 27 17:59 material-ui.min.inc.js
-rw-rw-rw- 1 thheller thheller  1.4M Feb 27 17:59 material-ui-svg-icons.min.inc.js
#2018-08-1315:22thheller2.4mb total#2018-08-1315:22thhellerjust due to those two requires#2018-08-1315:23thhellerfor the SVG icons its really important to only import the ones you actually use and not everything#2018-08-1315:30lilactownqlkit-material-ui.core is super small. you could probably rewrite it to only include what you need#2018-08-1315:31thhelleryeah I think you can take it out completely#2018-08-1315:31thhellerthe only thing that seems to be relevant is the (ql/regsiter-component ..) call https://github.com/forward-blockchain/qlkit-material-ui/blob/master/src/qlkit_material_ui/core.cljs#L51#2018-08-1315:33thhellerso (:require ["@material-ui/core/Button" :default Button]) and (ql/register-component :button Button) may just work?#2018-08-1315:34lilactownsounds like it, as long as the register-component is called before qlkit/mount#2018-08-1315:35thhellerdoing that for all the components and icons you actually use seems to be best#2018-08-1315:35thhellerannoying but best 😉#2018-08-1315:36pauldThanks!#2018-08-1315:59pauldAlso material-ui-svg-icons is now depreciated in favor of: @material-ui/icons#2018-08-1315:59thhelleryeah you can import each icon individually there too#2018-08-1316:17pauld#2018-08-1316:19pauldIt could be a fun game to trim this down.#2018-08-1316:55lilactownmodule keys can be namespaced right?#2018-08-1317:37thheller@lilactown no they cannot#2018-08-1317:38thhellerwell they can but the ns will be dropped#2018-08-1317:42lilactown😞#2018-08-1317:42thhellerwhy? what would it accomplish?#2018-08-1317:45lilactownI know I’m going to run into an issue eventually where two different experiences might have similar components, e.g.: dashboard/livehelp homepage/livehelp I can simply use dashes instead of slashes, it’s not a huge deal. just aesthetically it would be nice to be able to namespace them#2018-08-1319:58mhueberthmm, would there be any harm in adding a build hook that goes before :configure, where I could modify :closure-defines?#2018-08-1320:00mhuebertmaybe I am just editing the wrong piece of the state#2018-08-1320:04mhuebertah. I was trying to modify :shadow.build/config, but those settings have already been locked-in elsewhere, so I can instead update-in build-state [:compiler-options :closure-defines]#2018-08-1320:17thheller@mhuebert yeah you can do it in :compile-prepare#2018-08-1321:12larshelg@thheller Just wondering about the react-native support. Is this supported or on the roadmap?#2018-08-1321:13thheller@larshelg depends on what you expect to work. I do not use react-native myself and haven't done any work on the support in a while#2018-08-1321:13ClashTheBunnyThere is an example: https://github.com/shadow-cljs/examples/tree/master/cljs-react-native-app#2018-08-1321:13thheller:npm-module will work but is sort of limited regarding repl/live-reload#2018-08-1321:14larshelgGreat, I will give it a try 🙂#2018-08-1321:21larshelgWell it would be great with repl/live-reload support. I dont know how hard it would be to implement. But seeing that there is partial support for RN it would be great to have it on the roadmap.#2018-08-1321:22thhellerits on the roadmap yes. just don't know when I can get to it since I need to look into react-native stuff first#2018-08-1321:22thhellerlast attempts always had me frustrated figuring out the metro details#2018-08-1321:23thhellernever could get source maps to work for example#2018-08-1321:23larshelgYeah i found this: https://github.com/thheller/shadow-cljs/issues/214#2018-08-1321:25lilactownthheller if I have time, I’d like to dig into the RN stuff. would you appreciate any help with that?#2018-08-1321:26thhellerany help is appreciated yes#2018-08-1321:26larshelgI sure would appreciate it#2018-08-1321:30thhellerFWIW I think the only hurdle left were the source maps#2018-08-1321:30thhellerwhich however are very important but I couldn't even figure out if they are even supposed to work at all#2018-08-1321:30thhellerdocumentation on that subject is sparse#2018-08-1321:32thhellerhttps://github.com/facebook/metro/issues/104 nothing happened here so they still might not be supported#2018-08-1321:33larshelgI see, but the hot reload is working?#2018-08-1321:33thhellershould be yeah#2018-08-1321:33thhellernot with :npm-module though#2018-08-1321:34larshelggreat, i guess no source maps means debugging is a nightmare, but still glad to hear that all the other stuff is working#2018-08-1321:35thhellerwell with :npm-module you can just use the built-in RN reloading stuff#2018-08-1321:36larshelgyeah, I´ll look into it#2018-08-1414:06pauldJust wanted to confirm: (:require ["react-virtualized" :refer (Column Table)]) does NOT do tree shaking.#2018-08-1414:06pauldat least in :shadow mode#2018-08-1414:08thhellercorrect. split it into two requires.#2018-08-1414:08pauldso this is recommended (as in docs): (:require ["react-virtualized/dist/commonjs/AutoSizer" :default virtual-auto-sizer] ["react-virtualized/dist/commonjs/List" :default virtual-list]))#2018-08-1414:09pauldcool thanks#2018-08-1414:09thhelleres or commonjs yes#2018-08-1414:09thhellerI would recommend the es versions#2018-08-1414:10pauld? not sure if I understand#2018-08-1414:10thhellerin the path it says commonjs. "react-virtualized/dist/commonjs/AutoSizer"#2018-08-1414:11pauldoh ok! haha#2018-08-1414:11thhellerthey do actually ship 2 versions which are bundled slightly differently#2018-08-1414:11thhellerits a bit more efficient to use the es version "react-virtualized/dist/es/AutoSizer"#2018-08-1414:23urbanslugIs there a way to do feature flags without env vars?#2018-08-1414:24thhellerno idea what you mean by that?#2018-08-1415:35urbanslugsorry I'll explain later#2018-08-1415:41djtangohey folks - does anyone have any externs handy for using express?#2018-08-1415:41djtangoadvanced optimisations are clobbering the lib's vars#2018-08-1415:44thhelleruse https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-08-1415:56djtangowe already had :infer-externs :auto turned on and changing to simple (instead of advanced) solved the issue#2018-08-1415:57djtangothough there could be another interrelated setting that bungled stuff#2018-08-1415:57thhellerand you didn't get any warnings?#2018-08-1416:01djtangoHmm just speaking with my team-member it was specifically to do with some middleware and an exception handling callback#2018-08-1416:02thhellerhmm? do you mean that the JS is accessing a property from CLJS that is getting renamed?#2018-08-1416:02djtangoI feel I can see how that might be harder to infer - let me dive a bit deeper.#2018-08-1416:03djtangoI'll see if I can put together a minimal replication#2018-08-1416:03thhellerinfer works for anything where you access a JS property from CLJS#2018-08-1416:03thhellernot the other way around#2018-08-1416:06djtangook that's interesting, I can see a line which looks suspect so I'll take a look at that specific bit#2018-08-1416:52richiardiandreaI receive a couple of warnings with transit-cljs, not a big deal, just wanted to report them:
------ WARNING #2 -------------------------------------------------------------- 
File: com/cognitect/transit/impl/writer.js:256:8
variable isObject is undeclared
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
 File: com/cognitect/transit/types.js:384:70
 variable Buffer is undeclared
#2018-08-1416:52richiardiandreaalso, is there a way to disable warning colors?#2018-08-1416:52thhelleryeah. known issue. can't do anything about that#2018-08-1416:52richiardiandreakk cool#2018-08-1416:53thhellercolors off isn't exposed so I guess its not possible#2018-08-1416:53richiardiandreais anything we can do about that > contributing it? it is quite annoying in CI 😄#2018-08-1416:54richiardiandreaactually...let me explore the code 😉#2018-08-1416:54thhellerthere is a shadow.build.warnings/*color* binding#2018-08-1416:54richiardiandreaah nice#2018-08-1416:55richiardiandreabut yeah...will get back to you, thanks for now 😄#2018-08-1417:03kennyIf I run shadow-cljs release app, the first time I will get an error compiling my code but subsequent runs the error is not printed. This behavior does not make sense to me.#2018-08-1417:03thhellerwhat is the error?#2018-08-1417:04kenny
------ ERROR -------------------------------------------------------------------
 File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/core.cljs:41:3
--------------------------------------------------------------------------------
  38 |   []
  39 |   (s/check-asserts true)
  40 |   (set! s/*explain-out* expound/printer)
  41 |   (st/instrument)
---------^----------------------------------------------------------------------
Unable to resolve var: def-command-spec in this context at line 41 compute/ui_frontend/core.cljs
--------------------------------------------------------------------------------
#2018-08-1417:04kennyUpdating to 2.5.0 to see if the problem still occurs.#2018-08-1417:06thhellerpretty sure that st/instrument is never going to work in :advanced?#2018-08-1417:06kennydef-command-spec is a macro BTW.#2018-08-1417:06kennyUpdated to 2.5.0 and still have the issue.#2018-08-1417:07kennyI'm not sure why that code is even getting compiled. It is located in this function:
(defn init-dev-tools
  []
  (s/check-asserts true)
  (set! s/*explain-out* expound/printer)
  (st/instrument)
  nil)
which is called like this:
(when ^boolean goog.DEBUG
  (init-dev-tools))
#2018-08-1417:07thhellerI would recommend putting stuff like this into an extra ns and use :preloads#2018-08-1417:08thhellerthe ns that is in will stilll have the st and expound requires otherwise#2018-08-1417:08thhellerbut as far as the problem goes I'm not actually sure#2018-08-1417:08thhellerinstrument is a funky macro#2018-08-1417:09kennyOk, I can do that. I would've thought that because that function call never occurs DCE would remove expound and st.#2018-08-1417:09thhelleryeah don't rely on DCE too much. there are lots of things that it can't remove. especially things the st ns does#2018-08-1417:10kennyI'll try moving that stuff to a preload. FWIW, def-command-spec is a Spec'ed macro.#2018-08-1417:11thhellerI'm not entirely sure why it doesn't fail the second time though#2018-08-1417:11thhelleroh wait I actually do#2018-08-1417:11kennyOh, and the problem only occurs when I call def-command-spec in the same ns it is defined in.#2018-08-1417:11thhellerst/instrument is a side effecting macro#2018-08-1417:11thhellerbut the ns is still cached so the side effects won't happen when using the cached code#2018-08-1417:12thhelleryeah don't ever call that in a release build. even when its supposed to be DCE'd#2018-08-1417:14kennyAre preloads called every time code reloads?#2018-08-1417:14thhellerno but you can force it via (ns ^:dev/always your.preloads)#2018-08-1417:14thhellerjust make sure that your "preload" depends on your main entries#2018-08-1417:15thhellerotherwise the st/instrument code won't actually instrument anything since your code isn't loaded yet#2018-08-1417:16kennyRightttt#2018-08-1417:16kennyWill that force everything to be reloaded every time?#2018-08-1417:18thhellerhmm? no only that ns#2018-08-1417:18kennyEven though it depends on my main entries?#2018-08-1417:18thhellerthat doesn't matter since they don't depend on the preload#2018-08-1417:20thhellergotta go, bbl#2018-08-1420:11davidstWhat's the way to resolve classpath conflicts in the most recent 2.5.0 version of shadow cljs? I have tried the re-frame conduit example. The compilation errors out because apparently an old version of re frame gets loaded. It's surprising because the dependencies vectors in shadow-cljs.edn explicitly lists a more recent version of re-frame. I have tried using exclusions but couldn't get it to work either.#2018-08-1420:14thhellershadow-cljs deps-tree is new#2018-08-1420:19thhellerinteresting error#2018-08-1420:19thhellerlooking into it#2018-08-1420:21thhellerhehe nice#2018-08-1420:22thhellerreagent is an explicit dependency but re-frame depends on reagent/reagent. guess tools.deps doesn't de-dupe those#2018-08-1420:22davidstI see#2018-08-1420:24thhellerhmm or its just me using it wrong#2018-08-1420:24thhellercan't replicate with clj alone#2018-08-1420:51thheller@davidst should be fixed in 2.5.1#2018-08-1420:53davidst@thheller great thank you#2018-08-1422:17pauldSuppose I want to use some javascript library only while in development. How would one go about setting this up?#2018-08-1422:18pauld{:devtools {:preloads ...?#2018-08-1422:19pauldBut then do I have to require this code in a namespace that is not reachable from the build's :entries?#2018-08-1422:20pauldor is :preloads only for clojure dependencies (not clojurescript or javascript)?#2018-08-1422:27pauldI suppose what I want to do is just have a clojurescript file under at dev/usr.cljs.#2018-08-1422:31pauldI'll see if I can use this code by eval'ing in cider-emacs I suppose this code that get required in dev/user.cljs will not get included in any build output provided it isn't called via code in the :entries namespaces.#2018-08-1422:36thhelleryes :preloads is for dev-only code. the ns included via :preloads must however not the required by anything else#2018-08-1422:38thhellerotherwise you might just leave it out of :preloads entirely since it will be included anyways#2018-08-1422:38thhellerthis is an option if you want to just remove one require https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-08-1423:36richiardiandreaaaaarg so excited about the new runtime dep feature........
shadow.user> (shadow/reload-deps! '{specs {:local/root "../spec-cljs"}})
:shadow.cljs.devtools.api/standalone-only
shadow.user> 
#2018-08-1423:36richiardiandrea😄 😄 🙂#2018-08-1423:37richiardiandreaso nice that we have it in there though#2018-08-1502:26currentoori’m using shadow-cljs from lein and when i do lein ubjerjar i get this
[2018-08-15 02:23:56.368 - INFO] duplicate resource cljs/compiler.cljc on classpath, using jar:file:/home/ec2-user/.m2/repository/org/clojure/clojurescript/1.10.339/clojurescript-1.10.339-slim.jar!/cljs/compiler.cljc over jar:file:/home/ec2-user/.m2/repository/org/clojure/clojurescript/1.9.946/clojurescript-1.9.946.jar!/cljs/compiler.cljc
but i made sure both package.json and project.clj have the same version of shadow-cljs, 2.5.1
#2018-08-1504:38lilactownit looks like you have clojurescript included twice#2018-08-1504:38lilactowndo you have clojurescript in your project.clj dependencies?#2018-08-1504:41lilactown@currentoor also why are you creating an uberjar with your clojurescript dependencies in it?#2018-08-1504:57currentoor@lilactown i don’t have clojurescript in project.clj deps#2018-08-1504:58currentoorbecause in :uberjar :preptasks i have
:prep-tasks ["clean" ["clean"]
             "compile" ["with-profile" "cljs" "run" "-m" "shadow.cljs.devtools.cli" "release"
                        "main" "pos" "signon"]]}
#2018-08-1504:59currentooris that a bad thing to do?#2018-08-1505:01lilactowncan you do a lein deps :treeand see if there’s duplicate CLJS being pulled in somewhere?#2018-08-1507:12thheller@richiardiandrea the reload-deps! still doesnt quite work. need to find a better strategy for dealing with conflicts and actually making the added sources available to compilation. right now they are just added to the classpath and would require reloading the server first. I'll write an official introduction once I sorted out the kinks.#2018-08-1507:13thheller@currentoor you don't need to include anything from CLJS for a CLJ uberjar? in fact you want to avoid that to make it smaller. not sure how you end up with 2 versions of cljs on the classpath though.#2018-08-1523:57currentoorit happens even if i do shadow release main instead of via uberjar prep task#2018-08-1523:57currentoorand it only happens on the latest version of shadow-cljs#2018-08-1523:57currentoori’ll see if it can happen in a minimal repo#2018-08-1600:13currentoor@U05224H0W so i was able to reproduce the issue in a minimal repo#2018-08-1600:13currentoorthis is the bare bones lein fulcro template, except i bumped shadow-cljs in package.json and project.clj#2018-08-1600:14currentoorhttps://github.com/currentoor/fulcro-shadow-cljs-classpath#unexpected-behavior#2018-08-1600:14currentoori logged what i saw in the readme#2018-08-1600:16currentoorit does ultimately compile correctly but it still worries me that there are two versions of the compiler hanging around#2018-08-1600:19currentoor@U0CKQ19AQ wrote the template used for this example, maybe he has an insight?#2018-08-1600:19currentoornothing looks suspect to me#2018-08-1600:46currentoorAlso I don’t see the warnings when running shadow-cljs in dev mode#2018-08-1603:19tony.kayMy only insight would be that when you bump versions of things it changes the dep graph, and that could pull crap in differently and cause all manner of issues.#2018-08-1603:20tony.kayCompare a lein deps :tree on the working vs non-working @currentoor#2018-08-1606:16thhellerah crap. I know why this happens ...#2018-08-1606:17thhellerI switched to using org.clojure/clojurescript "1.10.339" :classifier "slim" since the default release includes AOT classes which where clashing with shadow-cljs AOT classes#2018-08-1606:17thhellerdidn't expect lein to treat this as an entirely different artifact#2018-08-1607:35thhelleryeah confirmed. tools.deps does the thing I expected but lein does not which l leads to the duplicated dep#2018-08-1617:31currentoorwhat version of lein?#2018-08-1617:33currentoori’ll try updating lein, see if the latest version has this problem#2018-08-1617:33currentoordamn i’m already at the latest#2018-08-1617:40thhelleryeah doesn't matter its in all lein versions#2018-08-1617:41currentooris it just an annoying warning for now, or could it actually cause problems in the build?#2018-08-1617:41thhellerprobably yeah. I'll fix it eventually but not quite sure what to do yet#2018-08-1617:42currentoorthanks for being so helpful, as usual! simple_smile#2018-08-1508:11biscuitpantswhat is the default directory that the SSL server serves? is it configurable?#2018-08-1508:11thhellerhmm?#2018-08-1508:12thhellerit is configured by any of the normal options. :http-root and such#2018-08-1508:12biscuitpantsah#2018-08-1508:12thhellerhttps doesn't have different options#2018-08-1508:12biscuitpantsthank you mr#2018-08-1508:14biscuitpants
10:14:27.602 [main] DEBUG io.undertow - JDK9 ALPN not supported
java.lang.NoSuchMethodException: javax.net.ssl.SSLParameters.setApplicationProtocols([Ljava.lang.String;)
	at java.lang.Class.getMethod(Class.java:1786)
	at io.undertow.protocols.alpn.JDK9AlpnProvider$1.run(JDK9AlpnProvider.java:47)
	at io.undertow.protocols.alpn.JDK9AlpnProvider$1.run(JDK9AlpnProvider.java:43)
	at java.security.AccessController.doPrivileged(Native Method)
is this expected? i’m thinking it could do with dependency mismatches
#2018-08-1508:15thhellerhmm never seen that#2018-08-1508:16thhelleropen an issue. I can take a look later. no this is not expected.#2018-08-1508:17biscuitpantsokay will do#2018-08-1518:07richiardiandreaI am getting a weird
Circular dependency detected: testing.cljs.spec -> testing.cljs.spec
 (require 'testing.cljs.spec :reload)
when I do (require 'testing.cljs.spec :reload)
#2018-08-1518:12richiardiandreaand it looks like after that someting is messed up:
Circular dependency detected: testing.cljs.spec -> testing.cljs.spec

ClassCastException: 

#2018-08-1518:13thhellerwhich ns were you in before the require?#2018-08-1518:13richiardiandreathe parent of that one#2018-08-1518:14thhellerwhat is a parent?#2018-08-1518:14richiardiandreaa dependent#2018-08-1518:14richiardiandreaI mean A requires B, I was in A#2018-08-1518:14thhellerand B is testing.cljs.spec?#2018-08-1518:15richiardiandreayep, but I am now noticing that (unfortunately) it does not happen every time#2018-08-1518:15richiardiandreawill try to repro it consistently
#2018-08-1518:16richiardiandreaI also see a
ClassCastException: clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative
	clojure.lang.RT.assoc (RT.java:820)
	clojure.core/assoc--5218 (core.clj:191)
	clojure.core/assoc--5218 (core.clj:190)
	clojure.core/update (core.clj:6135)
	clojure.core/update (core.clj:6123)
	shadow.build.ns-form/eval10706/fn--10708 (ns_form.clj:372)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6762)
	clojure.core/reduce (core.clj:6745)
	shadow.build.ns-form/parse (ns_form.clj:483)
	shadow.build.ns-form/parse (ns_form.clj:450)
	shadow.cljs.repl/make-repl-resource (repl.clj:76)
	shadow.cljs.repl/make-repl-resource (repl.clj:60)
	shadow.cljs.repl/repl-ns (repl.clj:304)
	shadow.cljs.repl/repl-ns (repl.clj:302)
	shadow.cljs.repl/process-read-result (repl.clj:415)
	shadow.cljs.repl/process-read-result (repl.clj:395)
	shadow.cljs.devtools.server.worker.impl/eval17297/fn--17300 (impl.clj:491)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--17044/fn--17045/fn--17053 (util.clj:265)
	shadow.cljs.devtools.server.util/server-thread/fn--17044/fn--17045 (util.clj:264)
	shadow.cljs.devtools.server.util/server-thread/fn--17044 (util.clj:237)
	java.lang.Thread.run (Thread.java:748)
now after REPL reboot
#2018-08-1518:16richiardiandreait was not showing up before#2018-08-1518:17thhellerI think you reported something like that before but never provided more details#2018-08-1518:17thhellerhttps://github.com/thheller/shadow-cljs/issues/303#2018-08-1518:18richiardiandreaoh right, let me get rid of the namespaces line by line#2018-08-1518:19thhellerI need more overall details. just a random stacktrace doesn't give me anything to go on. its equally important to know what you did to get there#2018-08-1518:19richiardiandreayeah, well I am working on a macro in a .cljc file...#2018-08-1518:19richiardiandreaso plenty of moving parts#2018-08-1518:20richiardiandreahow do you usually deal with exceptions like this? I see the issue is closed but of course the problem is still there 😄#2018-08-1518:21richiardiandreajust asking from a maintainer perspective#2018-08-1518:21thhellerI asked for more info. you didn't provide any. I close it after a while since there is nothing I can do.#2018-08-1518:22richiardiandreayep I saw that, just wondering whether it is best to leave open things like this, because other folks can pitch in...I maintain a couple of projects as well and wanted to ask your opinion 😄#2018-08-1518:25thhellerdunno still figuring this out myself. Getting a report with a basically blank exception with no additional details and no further movement despite a "Will try to investigate more" might just mean that it never happened again#2018-08-1518:25richiardiandreatrying to repro, but cannot right now, will answer in that issue if I find anything more robust#2018-08-1518:25thhellerdon't want to chase around anything blindly#2018-08-1518:25richiardiandreaok cool yeah#2018-08-1518:25richiardiandreayes that's for sure#2018-08-1518:26thhellerhehe and as I say that I figure it out ...#2018-08-1518:27richiardiandreawoah really?#2018-08-1518:27richiardiandreait looks like I had a compilation error in the macro file, that you can repro with
(defmacro a-macro
  []
  (let []
    `(println "test")))
#2018-08-1518:27richiardiandreaand the second time around, I get the ClassCastException#2018-08-1518:28richiardiandreaI mean the second require around#2018-08-1518:30thheller
[5:0]~shadow.user=> (shadow/browser-repl)
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (134 files, 1 compiled, 0 warnings, 0.52s)
[5:1]~cljs.user=> JS runtime connected.
[5:1]~cljs.user=> (ns foo.bar)
nil
[5:1]~foo.bar=> (require 'demo.browser :reload)
nil
[5:1]~foo.bar=> (ns foo.bar (:require demo.browser))
[:result {:type :repl/error, :ex #error {
 :cause "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"
 :via
 [{:type java.lang.ClassCastException
   :message "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"
   :at [clojure.lang.RT assoc "RT.java" 820]}]
 :trace
 [[clojure.lang.RT assoc "RT.java" 820]
  [clojure.core$assoc__5138 invokeStatic "core.clj" 191]
  [clojure.core$assoc__5138 invoke "core.clj" 190]
  [clojure.core$update invokeStatic "core.clj" 6120]
  [clojure.core$update invoke "core.clj" 6108]
  [shadow.build.ns_form$fn__13691 invokeStatic "ns_form.clj" 372]
  [shadow.build.ns_form$fn__13691 invoke "ns_form.clj" 368]
  [clojure.lang.MultiFn invoke "MultiFn.java" 233]
  [clojure.lang.PersistentVector reduce "PersistentVector.java" 341]
  [clojure.core$reduce invokeStatic "core.clj" 6747]
  [clojure.core$reduce invoke "core.clj" 6730]
  [shadow.build.ns_form$parse invokeStatic "ns_form.clj" 483]
  [shadow.build.ns_form$parse invoke "ns_form.clj" 450]
  [shadow.cljs.repl$make_repl_resource invokeStatic "repl.clj" 76]
  [shadow.cljs.repl$make_repl_resource invoke "repl.clj" 60]
  [shadow.cljs.repl$repl_ns invokeStatic "repl.clj" 304]
  [shadow.cljs.repl$repl_ns invoke "repl.clj" 302]
  [shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 415]
  [shadow.cljs.repl$process_read_result invoke "repl.clj" 395]
  [shadow.cljs.devtools.server.worker.impl$fn__19853 invokeStatic "impl.clj" 491]
  [shadow.cljs.devtools.server.worker.impl$fn__19853 invoke "impl.clj" 455]
  [clojure.lang.MultiFn invoke "MultiFn.java" 233]
  [shadow.cljs.devtools.server.util$server_thread$fn__19628$fn__19629$fn__19637 invoke "util.clj" 265]
  [shadow.cljs.devtools.server.util$server_thread$fn__19628$fn__19629 invoke "util.clj" 264]
  [shadow.cljs.devtools.server.util$server_thread$fn__19628 invoke "util.clj" 237]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 844]]}}]
#2018-08-1518:31richiardiandreaseems similar 😄#2018-08-1518:54thheller:reload handling is completely weird. don't know how I intended that to work in the first place 😛#2018-08-1518:56richiardiandrea😄#2018-08-1518:57richiardiandreawell I have just introduced that key binding in cider so I guess nobody was really using it 😛#2018-08-1518:58thhellernah the problem only appeared if you did the (ns ...) after calling require :reload#2018-08-1518:58richiardiandreaoh#2018-08-1518:58thhellersince ns is additive in the REPL it had trouble merging the flags, thats all#2018-08-1518:59richiardiandreaoh ok good then#2018-08-1613:34Logan PowellIs it just me, or is there some issue with shadow kicking me out of the REPL (`CompilerException java.lang.RuntimeException...`) when debugging core.async code?#2018-08-1613:35Logan PowellI'm getting an unusual number of these REPL terminations when working with core.async. It looks as though, when something goes wrong within a chan (e.g., an error like nil is not allowed in a channel), stuff breaks#2018-08-1613:40heyarneI'm sometimes receiving SyntaxErrors when running karma tests. the message looks like this:
{
    "message": "Uncaught SyntaxError: missing ) after argument list\nat ci.js:114889:322\n\nSyntaxError: missing ) after argument list",
    "str": "Uncaught SyntaxError: missing ) after argument list\nat ci.js:114889:322\n\nSyntaxError: missing ) after argument list"
  }
#2018-08-1615:03thheller@loganpowell do you have an example of code that kicks you out? how are you debugging core.async code? async in general is pretty tough to debug given its async nature but I don't know what you mean by getting kicked out?#2018-08-1615:04thheller@arne-clojurians I believe there was an issue with karma running tests too early, meaning it started running tests while the file was still being written?#2018-08-1615:05thhellertry setting a super high autoWatchBatchDelay https://karma-runner.github.io/2.0/config/configuration-file.html (2000 or so should be good)#2018-08-1615:06Logan Powell@thheller right now, it looks like anytime I get an error inside a chan I'm getting kicked out.#2018-08-1615:07thhellercan be please be more specific what you mean by getting kicked out?#2018-08-1615:08Logan PowellI have to restart the Cursive REPL with (shadow.cljs.devtools.api/node-repl)#2018-08-1615:08thhellerah. its a node repl. node crashes on uncaught exceptions I think?#2018-08-1615:09Logan Powellah, ok#2018-08-1615:09Logan Powellwell, the shadow-cljs node server keeps running, but Cursive breaks#2018-08-1615:09Logan Powellmaybe a Cursive issue#2018-08-1615:09Logan Powell?#2018-08-1615:10thhellerprobably not. might be a nREPL issue though#2018-08-1615:11thhellerwait ... what do you mean by node server?#2018-08-1615:11thhelleryou mean shadow-cljs itself right?#2018-08-1615:11thhellerthe node-repl process probably dies#2018-08-1615:11Logan Powellyessir#2018-08-1615:11Logan Powell
λ shadow-cljs clj-repl
shadow-cljs - config: C:\Users\Surface\Projects\clojure\cljs\census-geojson\shadow-cljs.edn  cli version: 2.4.25  node: v8.11.3 shadow-cljs - starting ...
shadow-cljs - server version: 2.4.25
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 50413
shadow-cljs - nREPL server started on port 3333
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=>
#2018-08-1615:11Logan Powellstill running#2018-08-1615:12Logan Powellok, not a big deal, I can just keep restarting the node-repl session in Cursive. This only seems to happen when working with core.async so I hope to be done with that soon 😄#2018-08-1615:13thhellerit is a big deal ... just need more info to piece together what exactly you are doing#2018-08-1615:14Logan Powellso, anything that goes wrong inside a chan seems to kick me out of the session. I'm trying to think of a better way to explain...#2018-08-1615:15thhellerI'm still not clear on what you mean by kicked out#2018-08-1615:15thhellercursive gets disconnected?#2018-08-1615:15Logan PowellI get kicked out for putting nil into a chan, when a function that's being called in a go block errors out, when I forget to eval a defn before eval'ing a go block that contains it... yes cursive gets disconnected#2018-08-1615:16Logan Powellthe nREPL session doesn't stop in the shadow-cljs clj-repl session. I just have to re-eval (shadow.cljs.devtools.api/node-repl) to start the Cursive REPL again and then re-eval the namespace, functions, etc.#2018-08-1615:17thhellerI'm so confused ... can you do a step by step?#2018-08-1615:17Logan PowellI don't have to shadow-cljs clj-repl again#2018-08-1615:17Logan Powellsorry!#2018-08-1615:21Logan PowellFor example: step 1) shadow-cljs clj-repl => REPL session starts step 2) Error put into a chan => Error thrown in Cursive REPL (`shadow-cljs` still running, doesn't break) step 3) (shadow.cljs.devtools.api/node-repl) => restart node-repl in Cursive step 4) eval (ns...) and functions to get me back to debugging the core.async logic step 5) bug in code = repeat from step 2)#2018-08-1615:22thhellerI'm even more confused now#2018-08-1615:22thhelleryou are running shadow-cljs clj-repl externally?#2018-08-1615:22thhellerand CONNECT remotely with cursive?#2018-08-1615:23thhelleror is this all in a terminal outside of cursive?#2018-08-1615:23Logan PowellIt's remote#2018-08-1615:23Logan PowellSeparate terminal#2018-08-1615:24Logan PowellWould it be better to use the terminal in IDEA?#2018-08-1615:24thhelleryes, lots.#2018-08-1615:24Logan PowellSweet! I will do that! Any particular command I should use in there, just the terminal included with Idea or something to do with Cursive?#2018-08-1615:25thhellerany terminal is fine. point is that it doesn't use nrepl and I can see the full session#2018-08-1615:25thhellerI think the node process just dies due to the uncaught exception#2018-08-1615:25Logan PowellGotcha. I'll do that and report on my findings. Thank you again Thomas!#2018-08-1615:25thhellerbut I don't know what you mean by kicked out still#2018-08-1615:27Logan PowellI don't know how else to describe the behavior of having the shadow-cljs clj-repl still running, but the Cursive REPL dies on me, requiring me to re-eval (shadow.cljs.devtools.api/node-repl) in there to kick start Cursive REPL again. It feels like getting kicked out#2018-08-1615:27Logan PowellLet me try the Idea REPL#2018-08-1615:27Logan PowellI'll be back!#2018-08-1615:28thhellercursive REPL dies on you: does it display anything? can you still type?#2018-08-1615:28thhellercursive ALWAYS starts out on CLJ mode when you connect#2018-08-1615:28thhellerrunning node-repl will switch to CLJS mode#2018-08-1615:29thhellerwhen the node-repl dies you should just be in CLJ mode again#2018-08-1615:29Logan PowellYes, I'm using Node/NPM interop atm#2018-08-1615:29thhellerthats why I don't understand what "kicked out" means#2018-08-1615:29Logan PowellI think that's what's happening, yes, I'm getting "kicked out" of the CLJS session and into CLJ#2018-08-1615:29thhellerthe connection should still be fine#2018-08-1615:29thhellergeez ok#2018-08-1615:29Logan PowellSorry! 😄#2018-08-1615:29thhellerso you are just in CLJ mode and can eval CLJ code normally#2018-08-1615:30Logan PowellYes, it becomes a Java runtime#2018-08-1615:30Logan Powell
CompilerException java.lang.RuntimeException: Unable to resolve symbol: defn in this context, compiling:(null:1:1)
#2018-08-1615:31thhellerok the REPL is just stuck in the wrong namespace probably#2018-08-1615:31thhellertry (in-ns 'shadow.user) after you get "kicked out"#2018-08-1615:31thhellerthen just 1 or whatever#2018-08-1615:32thhellerjust so confirm that the CLJ repl still works#2018-08-1615:32Logan Powelllet me try#2018-08-1615:33urbanslug@thheller I can't find a link to a demo project you had that used shadow-cljs and was reading configs from the html file.#2018-08-1615:33thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/public/index.html#L10 this one?#2018-08-1615:34Logan Powell#2018-08-1615:34thhellerjust calling <script>starter.browser.init({foo: "bar"});</script> instead?#2018-08-1615:35thheller@loganpowell forget about it. I think I know whats happening.#2018-08-1615:36urbanslugyeah I got that I just thought that it had it right there in the example#2018-08-1615:36urbanslugweird#2018-08-1615:36urbanslugmine has a window.onload#2018-08-1615:36urbanslugmaybe that is the issue but I don't see why because the fn gets called but the args don't#2018-08-1615:36thhellersame idea. just pass data to the init fn#2018-08-1615:36urbanslugdoesn't work on reload#2018-08-1615:37urbansluglet me pull your example and try replicate#2018-08-1615:37thhellerinit is never supposed to get called on reload?#2018-08-1615:37urbanslugit is#2018-08-1615:37thhellerthe whole point of init is to only get called once#2018-08-1615:37urbanslugok that makes sense#2018-08-1615:37thhellerhttps://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#2018-08-1615:38thhellersee the entire setup#2018-08-1615:38urbanslugso what I do is transact app state in the init to add the vars from the html#2018-08-1615:38thhellerinit is called once on startup from HTML#2018-08-1615:38thhellerit calls start#2018-08-1615:38urbanslughmmm#2018-08-1615:38thhelleron live-reload first stop is called and then start after loading the code#2018-08-1615:38thhellerwhatever happened in init never happens again#2018-08-1615:38thhellerand is not supposed to#2018-08-1615:39urbanslugok that makes sense#2018-08-1615:39thhellerif it gets called again then yes it won't have any arguments#2018-08-1615:39urbanslugthen in my case it does get called again#2018-08-1615:40thhellerdo you either have it marked as an :dev/after-load or :after-load in the config?#2018-08-1615:40urbanslugyes I do 😬#2018-08-1615:42thhellerok. so you split the init into 2 functions. one that can be called again (ie. doesn't use args) and one that puts the config somewhere safe#2018-08-1615:43urbanslugThanks for that I was reading the docs trying to figure out how to handle it all#2018-08-1615:44urbanslugAlso is there a client side routing lib you recommend?#2018-08-1615:45thhellerno I don't do recommendations 😉#2018-08-1615:47urbanslugLOL#2018-08-1615:48thhellerI don't know any to be honest. I have my own super basic one that I use for my work projects#2018-08-1615:54thheller@loganpowell
[7:1]~cljs.user=> (require '[cljs.core.async :as a])
nil
[7:1]~cljs.user=> (a/go (throw (ex-info "foo" {})))
<eval>:1
(function (){var c__34073__auto__ = cljs.core.async.chan.call(null,(1));
                                                         ^

TypeError: Cannot read property 'call' of undefined
    at <eval>:1:58
    at <eval>:89:3
    at Script.runInThisContext (vm.js:65:33)
    at runInThisContext (vm.js:199:38)
    at global.SHADOW_NODE_EVAL ([stdin]:75:30)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:25:16)
    at shadow.cljs.devtools.client.node/node-eval (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:48:30)
    at Object.repl-expr (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:91:16)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:48:13)
    at shadow.cljs.devtools.client.node/repl-invoke (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:116:6)
[7:1]~cljs.user=> (+ 1 2)
3
#2018-08-1615:55urbanslugOk#2018-08-1615:56Logan Powell#2018-08-1615:56thheller@loganpowell when I do the above in nrepl it breaks#2018-08-1615:56Logan PowellI see, so nREPL issue#2018-08-1615:56thhellerit doesn't help me if you post an example I cannot execute myself#2018-08-1615:56Logan Powell🙂#2018-08-1615:57thhellerI have absolutely no clue what you code does#2018-08-1615:57Logan PowellI apologize#2018-08-1615:57Logan PowellI was being lazy#2018-08-1615:57thhellerbut I can reproduce that the nrepl gets stuck in an unusable state#2018-08-1615:57Logan Powellforgive my laziness. You're being generous and I, greedy#2018-08-1615:58Logan PowellI just don't know exactly what I'm doing wrong#2018-08-1615:59thhelleryeah understandable. nrepl is a total mess and I don't understand whats going on half the time either#2018-08-1615:59Logan PowellYour example helps me understand what you need for me to help you help me#2018-08-1615:59Logan Powellok, no worries! Without a hitch otherwise. The NPM interop is flawless#2018-08-1615:59Logan Powell🙏#2018-08-1616:00thhellerFWIW just executing (js/process.exit 1) breaks the entire thing#2018-08-1616:00Logan Powellhaha#2018-08-1616:00thhellerif the node process dies it breaks the entire nrepl session#2018-08-1616:00thhellerbut only the nrepl session, normal repl is fine#2018-08-1616:01Logan Powellcorrect, shadow's repl keeps on humming#2018-08-1616:01Logan Powellok, onwards! Thank you again#2018-08-1616:01Logan Powellalways a model of patience#2018-08-1616:03thhellerhttps://github.com/thheller/shadow-cljs/issues/370#2018-08-1616:11hlolliAfter some experimenting with wrapping AudioWorklet with clojurescript, I found goog.defineClass, it works with "watch", but when I release, I encounter
Closure compilation failed with 1 errors
--- csound_wasm/browser.cljs:201
Unsupported class definition expression.
makes me wonder why it works with watch to begin with...
#2018-08-1616:12hlollimaybe there's another way around this https://developers.google.com/web/updates/2017/12/audio-worklet somehow grabbing the prototypes and convert it to object...#2018-08-1616:12thhellerwell in watch the code isn't processed by closure#2018-08-1616:13thhellerso maybe you are just doing something you are not supposed to#2018-08-1616:13hlolliyes, there's a lot of not supposed to, when it comes to mixing classes with clojurescript...#2018-08-1616:13hlolliI've never dealt with this kind of interop.#2018-08-1616:14thhelleryeah classes are a bit annoying#2018-08-1616:14thhellerthis might do it#2018-08-1616:14thhellerhttps://gist.github.com/thheller/7f530b34de1c44589f4e0671e1ef7533#2018-08-1616:14hlolliwhat I came up with was
(def CsoundWorkletNode
  (goog.defineClass
   js/AudioWorkletNode
   #js {:constructor
        (this-as that
          (fn [ctx]
            ((.-superClass_ that) ctx "csound-processor")))}))
mocking this
class MyWorkletNode extends AudioWorkletNode {
  constructor(context) {
    super(context, 'my-worklet-processor');
  }
}
and it worked surprisingly, luckily the superClass that's injected from closure library helped a lot.
#2018-08-1616:15thhellerjust replace React.Component with AudioWorkletNode#2018-08-1616:15thhellerfirst of all this goog.defineClass is totally invalid#2018-08-1616:15thheller(goog/defineClass ...) or (js/goog.defineClass ...)#2018-08-1616:15thhellerthat the other one works is accidental#2018-08-1616:16thhellerand this-as must be the first inside the fn not outside#2018-08-1616:17thhellerand what is .-superClass_?#2018-08-1616:17hlollithe error changed
Closure compilation failed with 1 errors
--- csound_wasm/browser.cljs:192
The class must be defined by an object literal
#2018-08-1616:17hlolliI guess super#2018-08-1616:18thheller
(def CsoundWorkletNode
  (js/goog.defineClass
    js/AudioWorkletNode
    #js {:constructor
         (fn [ctx]
           (js/super ctx "csound-processor"))}))
#2018-08-1616:18thheller?#2018-08-1616:19hlolliyour version
Closure compilation failed with 1 errors
--- externs.shadow.js:11
Parse error. 'identifier' expected
#2018-08-1616:19thhellerhaha doh. it probably tried to generate externs for super#2018-08-1616:20hlolliI thought I was doing simple optimizations#2018-08-1616:20thhellerdon't tell anyone I posted this but try#2018-08-1616:20thheller
(def CsoundWorkletNode
  (js/goog.defineClass
    js/AudioWorkletNode
    #js {:constructor
         (fn [ctx]
           (js* "super({}, {});" ctx "csound-processor"))}))
#2018-08-1616:39hlolli[slack] it's back up#2018-08-1616:41hlolli@thheller this is the error message from "who knows who"
Closure compilation failed with 1 errors
--- csound_wasm/browser.cljs:193
Parse error. Semi-colon expected
#2018-08-1616:42thhellerhmm yeah js* is weird. better not use it#2018-08-1616:43thhellerwhat is the point of the class exactly?#2018-08-1616:44hlolliI don't get it. I guess the logic is, that only the newest browser support audioworklet, and old ecmascript can't compile classes anyway. Not sure what's the logic.#2018-08-1616:44hlolliAnd if this is something that is decided by w3c, then I guess more is coming.#2018-08-1616:45thhellermight be like web components where you MUST use class with extends or else it breaks#2018-08-1616:45thhellerCLJS can not currently emit that#2018-08-1616:46thhelleryou could try writing actual JS and calling a CLJS fn#2018-08-1616:46thhellerdunno how much sense that makes though#2018-08-1616:47hlollihmm yes... I need this shit twice, one for the global scope, another for script processor scope.#2018-08-1616:48thhellerdo the worklets behave like workers?#2018-08-1616:48hlolliI could write some js and pass into it a js object from clojurescript, to run the code defined in cljs land#2018-08-1616:48hlolliyes#2018-08-1616:48thhellerie. can they call importScripts?#2018-08-1616:48hlollialmost, in the audioworklet, the import script is a fetch, that must be over https#2018-08-1616:49hlolliso not file:// protocol, localhost tough considered "safe"#2018-08-1616:49hlolliit's shit if you ask me#2018-08-1616:50thhellerit seems extremely weird to me#2018-08-1616:50thhellerchrome devtools also don't seem to show how the code is loaded#2018-08-1616:50thhellerhttps://googlechromelabs.github.io/web-audio-samples/audio-worklet/basic/hello-audio-worklet.html#2018-08-1616:51hlollilol, it's even crackling a bit, which is the main point of preventing with audioworklet#2018-08-1616:51thhellerI know absolutely nothing about audio processing so I have no idea what the point of any of this is 😛#2018-08-1616:52hlollipreviously there was audioProcessorNode, that would get latencies if you changed the dom or something.#2018-08-1616:53thhellerdid you try the other method from the gist I posted? no goog.defineClass?#2018-08-1616:54hlolliuh, did your gist get lost when the slack was down?#2018-08-1616:54thhellerhttps://gist.github.com/thheller/7f530b34de1c44589f4e0671e1ef7533#2018-08-1616:54hlolliah no.. wait#2018-08-1616:54thhellerjust replace React.Component with whatever class#2018-08-1616:55thhellerhttps://gist.github.com/thheller/36332574918b974a3e4996efcb7457d2#file-web-component-v1-cljs-L2#2018-08-1616:56thhellerthe Reflect.construct call might also work. it was necessary for web components a while back#2018-08-1616:56thhellernot sure if it still is though. that was 2 years ago#2018-08-1616:56hlolliok nice, I saw similar thing here http://www.50ply.com/blog/2012/07/08/extending-closure-from-clojurescript/ surprised to see mutations on defn#2018-08-1616:57hlolli2 mins...#2018-08-1616:58thhelleryeah its weird#2018-08-1617:00thhellerhang on though. how are you building those extra files?#2018-08-1617:00thhellerlooks like you use a dedicated build for that?#2018-08-1617:00hlolliyes, I have a dedicated build for the processor/worker#2018-08-1617:01thhellerdon't do that 😛#2018-08-1617:02hlollicompile then as a module?#2018-08-1617:02thheller
:modules
{:shared {:entries [cljs.core] :depends-on #{}}
 :main {:entries [demo.app] :depends-on #{:shared}}
 :audio1 {:entries [demo.audio1] :depends-on #{:base} :web-worker true}}
#2018-08-1617:03thhellerin the main browser you load shared.js + main.js#2018-08-1617:03thhellercontext.audioWorklet.addModule('/js/audio1.js')#2018-08-1617:04thhellerno idea if this works for the audio things though#2018-08-1617:04hlolliyes I think I would trip on this sooner or later#2018-08-1617:04thhellerit was intended for actual webworkers#2018-08-1617:04thhellerthe audio files will become huge otherwise since each will contain its own cljs.core version#2018-08-1617:04thhellernot exactly ideal either way but worth a try#2018-08-1617:04thhellerdoesn't fix the class problem though#2018-08-1617:09hlollithe idea here
(set! (.. component-fn -prototype -constructor) my-component)
is that component-fn is its own function and not my-component?
#2018-08-1617:10thhelleroh thats copy&paste error#2018-08-1617:10thhellershould be my-component instead of component-fn#2018-08-1617:10hlollimakes sense#2018-08-1617:18hlolliI think I have to sweat over this a bit, im getting
Uncaught TypeError: Illegal invocation
    at Object.goog.object.extend (goog.object.object.js:610)
    at browser.cljs:212
code
(goog.object/extend CsoundWorkletNode.prototype js/AudioWorkletNode.prototype)
#2018-08-1617:18hlolliit compiles tough, good news#2018-08-1617:18thhellerCsoundWorkletNode.prototype this is rarely valid CLJS code#2018-08-1617:18thheller(.. CsoundWorkletNode -prototype)#2018-08-1617:19thhellerdon't try to cheat the system. you never know when it breaks#2018-08-1617:19thhellerbut yeah the illegal invocation is the exception I got with web components I think#2018-08-1617:19thhellertry the web components Reflect stuff#2018-08-1617:20hlolliyup, I still get the same error, changed it to see what would happen, the double dot macro I don't find to be so good looking, but will use it when/if needed 🙂#2018-08-1617:20hlolliok#2018-08-1617:26hlolliI'm getting confused about that HTMLComponent parts, I assume I don't need them?
(defn component []
  (js/AudioWorkletNode #js [] component))

(set! (.-prototype component)
      (js/Object.create (.-prototype js/AudioWorkletNode)
                        #js {:constructor (fn [ctx])}))
#2018-08-1617:27thhelleryou removed the Reflect call#2018-08-1617:27wilkerlucio@hlolli just a small tip, I suggest you try to using goog.object/set instead of set!, it's easier to read and is adv compilation proof#2018-08-1617:27thhellerthats the only important bit#2018-08-1617:27hlolliah ok, my misunderstanding#2018-08-1617:33thhellerI don't think this is gonna work either#2018-08-1617:33hlolli
(defn component []
  (js/Reflect.construct js/AudioWorkletNode #js [] component))

(set! (.-prototype component)
      (js/Object.create  (.-prototype js/AudioWorkletNode)
                         #js {:constructor (fn [ctx])}))

(def context (new js/AudioContext))

(-> (.addModule context.audioWorklet "./csound-wasm-worklet-processor.js")
    (.then (fn [] (new component context))))
Uncaught (in promise) TypeError: Failed to construct 'AudioWorkletNode': 2 arguments required, but only 0 present.
    at new csound_wasm$browser$component (browser.cljs:207)
#2018-08-1617:35thhellerthe arguments is the #js [] in the reflect call#2018-08-1617:35thhellerbut I don't think this is going to work anyways#2018-08-1617:36thhellerthe :web-worker stuff definitely doesn't work at all#2018-08-1617:36thhellerthe context created is not like a webworker#2018-08-1617:36thhellerit can't eval or do other stuff#2018-08-1617:37thhellerit looks like its a strict es6 module environment which makes sense#2018-08-1617:38hlolliI think it worked, just need to plugin the worker correctly now
(defn component [ ctx node-name ]
  (js/Reflect.construct js/AudioWorkletNode #js [ ctx node-name ] component))

(set! (.-prototype component)
      (js/Object.create  (.-prototype js/AudioWorkletNode)
                         #js {:constructor (fn [ctx])}))

(def context (new js/AudioContext))

(-> (.addModule context.audioWorklet "./csound-wasm-worklet-processor.js")
    (.then (fn [] (this-as that (new component context "csound-processor")))))
Uncaught (in promise) DOMException: Failed to construct 'AudioWorkletNode': AudioWorkletNode cannot be created: The node name 'csound-processor' is not defined in AudioWorkletGlobalScope.
#2018-08-1617:40hlolliok, then I skip the :web-worker flag and keep the modules?#2018-08-1617:40thhellerno modules won't work with this#2018-08-1617:40hlolliok, so I keep it like this 🙂#2018-08-1617:43thhellerto be honest all of this looks downright hostile towards CLJS#2018-08-1617:44thhellerOOP all over the place and special loading restrictions#2018-08-1617:49hlolliI bet you've never seen this 🙂
Uncaught TypeError: Cannot use 'in' operator to search for 'StopIteration' in undefined
    at csound-wasm-worklet-processor.js:187
    at csound-wasm-worklet-processor.js:2133
#2018-08-1617:49hlolliI think I should just write the processor in javascript, that can be forgiven...#2018-08-1617:51hlolli
goog.iter.StopIteration="StopIteration"in goog.global
no global in this secure environment
#2018-08-1617:52hlolliwhich means, f*, I need to write even more in the processor script than I imagined#2018-08-1618:05thhelleryeah its a ES6 module scope#2018-08-1618:05thhellergoog.global = this; but this is undefined in a module scope#2018-08-1618:06hlolliis there a closure option to compile to this?#2018-08-1618:07thhellerhmm?#2018-08-1618:08hlollithere's :es6-strict and :es6-typed, maybe :es6-module smth... dunno#2018-08-1618:09thhellerdunno. the closure library release used by CLJS is very old. it might be fixed in newer versions already.#2018-08-1700:43richiardiandreawhat does this mean in practical terms? I cannot use set! on goog-define?
Closure compilation failed with 4 errors
--- registry/aws_test.cljs:16
@define variable registry.PROVIDER assignment must be global
#2018-08-1705:55thhellergoog.define are compile time constants, so no you cannot set! them#2018-08-1716:50richiardiandreayes, however sometimes you want to use it in your tests#2018-08-1716:50richiardiandreaI have seen the pattern used in the wild as well#2018-08-1716:55thhellerthen set them via :closure-defines in the test build?#2018-08-1716:55thhellerthey are constants with special treatment by the compiler so closure will really not like you messing with them#2018-08-1717:02richiardiandreauhm ok, yeah but I'd have to split my conf for each and every value of it then...I found that vanilla cljs allows this, I frankly don't know why, maybe older GCC...in any case for now it is ok#2018-08-1717:02richiardiandreamaybe I should just use a :^dynamic var containing a goog-define for this...still deciding#2018-08-1717:13thhellerwell then you lose all the benefit of a goog-define in the first place. I don't know what you are trying to do in the first place but registry.PROVIDER looks like it is actually a runtime configuration option and not a compile time constant.#2018-08-1717:15richiardiandreaat the beginning it was, I still need to make it so by using the shadow's conditional reader features but it is not a prio so I will convert it to ^:dynamic for this iteration#2018-08-1702:05chgraham[edit] Ok, at https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#what-is-the-hints-feature I finally noticed that I can enter, at the REPL: (devtools.core/install! [:formatters :hints]) Also, to make the documentation better, it should be explained exactly where the following configuration is written: :external-config { :devtools/config { :features-to-install [:formatters :hints] :fn-symbol “F” :print-config-overrides true}} I assume it’s written in cljs-build configuration. I’m using shadow-cjls, not cljs-build. -------------------------------------------------------------------------------- I’m using Cursive and running this command from an IntelliJ terminal: lein with-profile +dev-cljs run -m shadow.cljs.devtools.cli watch :app …so when my web page loads, I see: Installing CLJS DevTools 0.9.10 and enabling features :formatters (with :hints and :async greyed out - the latter two weren’t loaded). How can configure project.clj or shadow-cljs.edn - or employ some other tactic - so that I can activate the :hints functionality of CLJS DevTools, i.e., DevTools? (PS, here is relevant portion of project.clj :profiles {:dev-cljs {:dependencies [[binaryage/devtools “0.9.10"] [thheller/shadow-cljs “2.5.1”]]}} and here is shadow-cljs.edn {:source-paths [“src”] :nrepl {:port 3333} :lein {:profile “+dev-cljs”} :builds {:app {:target :browser :output-dir “public/js” :asset-path “/js” :modules {:main {:entries [giggin.core]}} :devtools {:after-load giggin.core/main :http-root “public” :http-port 3000}}}}#2018-08-1705:56thheller:app {... :compiler-options {:devtools/config {:features-to-install ...}}} I believe#2018-08-1705:57thheller:external-config as described in the docs is :compiler-options in shadow-cljs.edn#2018-08-1705:22endenwerHey guys, does anyone know how to enable css live reloading for electron?#2018-08-1706:03thheller@endenwer how does electron deal with CSS? how are the files included?#2018-08-1706:07endenwerI am trying to make it work with this example https://github.com/ahonn/shadow-electron-starter.#2018-08-1706:07endenwerConfig
;; shadow-cljs configuration
{:source-paths ["src"]

 :dependencies [[reagent "0.8.0-alpha2"]
                [cider/cider-nrepl "0.18.0-SNAPSHOT"]]

 :builds {:main {:target :node-script
                 :output-to "resources/main.js"
                 :main app.main.core/main}

          :renderer {:target :browser
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:init-fn app.renderer.core/start!}}
                     :devtools {:after-load app.renderer.core/start!
                                :watch-dir "resources/public"}}}}

#2018-08-1706:08endenwerThere is a library for that https://github.com/Quramy/electron-connect but as I know it reloads everything not just css#2018-08-1706:19thhellerhmm it has trouble with the file:// urls electron returns for document.location.href#2018-08-1709:49biscuitpants#2018-08-1709:50biscuitpantsso i’m trying to run karma, to test my outputted js files#2018-08-1709:50biscuitpantsthose dependencies that are not found are in the “dependencies” key in package.json , and i’ve npm install’d#2018-08-1709:54thhellerhmm odd#2018-08-1709:54thhellerI guess this code fails#2018-08-1709:54thheller
if (util && util.inspect && util.inspect.custom) {
  module.exports.prototype[util.inspect.custom] = function () {
    var obj = util.inspect({ length: this.length });
    return this.constructor.name + ' ' + obj;
  };
}
#2018-08-1709:58biscuitpantsany reason why that would fail?
#2018-08-1709:58biscuitpantseven after an explicit npm install it still does not work#2018-08-1709:58thhellerthere is nothing for you to install#2018-08-1709:59thhellercompilation would fail if it were missing any packages. the code is just weird#2018-08-1710:00biscuitpantswhich code? mine? i.e is this something i can fix?#2018-08-1710:00thhellerno the JS code in node_modules/readable_stream#2018-08-1710:00biscuitpantsah#2018-08-1710:00thhelleryou probably can't fix it no#2018-08-1710:00biscuitpantspoo. well i’m using that to resolve stream#2018-08-1710:01biscuitpants
:resolve {"object.assign" {:target :npm :require "object-assign"}
                              "stream"        {:target :npm :require "readable-stream"}}
#2018-08-1710:01biscuitpantsso could maybe try remove that?#2018-08-1710:01thhelleruhm yeah don't do that#2018-08-1710:01biscuitpantsif i dont:
[:ci] Compiling ...
symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
{:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object-assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object.assign/index.js"]}
ExceptionInfo: symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
#2018-08-1710:02thhellersorry I meant don't do the stream override#2018-08-1710:02biscuitpantsoh right#2018-08-1710:02biscuitpantsokay let me try that#2018-08-1710:02thhellerobject.assign is fine#2018-08-1710:02thhellershadow-cljs has a few built-in node overrides for browser builds#2018-08-1710:02thhellerand you just interfered with one of them 😉#2018-08-1710:03thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/npm.clj#L288#2018-08-1710:03biscuitpantsoh haha#2018-08-1710:03biscuitpants
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install readable-stream/writable.js
#2018-08-1710:03biscuitpantstrying the readable-stream/writable.js. but i’ve installed readable and stream#2018-08-1710:03biscuitpantsyeah that repo doesn’t exist (writable.js)#2018-08-1710:03thhelleryou probably installed too many packages#2018-08-1710:04biscuitpantsah#2018-08-1710:04thhelleror rather the wrong ones#2018-08-1710:04biscuitpantsill clean node modules#2018-08-1710:04thhellerall of those should be ... wait ... do you have shadow-cljs and a dependency in your package.json?#2018-08-1710:04thhellerI made that optional a while ago and this has caused sooo much trouble#2018-08-1710:04thhellerit definitely was not worth removing it#2018-08-1710:04biscuitpants#2018-08-1710:06thhellerremove util and buffer definitely#2018-08-1710:06thhellerthem rm -rf node_modules#2018-08-1710:07thhellernpm install should definitely install the node_modules/readable-stream then#2018-08-1710:07biscuitpantstrying that now#2018-08-1710:07thhellernpm can be a PITA sometimes#2018-08-1710:08biscuitpants
➜  Monolith git:(shadow-cljs) ✗ shadow compile ci --debug
shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Monolith/shadow-cljs.edn  cli version: 2.5.1  node: v10.8.0
shadow-cljs - starting 2.5.1 with launcher 2.1.0 ...
[:ci] Compiling ...
The required JS dependency "readable-stream/readable.js" is not available, it was required by "node_modules/stream-browserify/index.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install readable-stream/readable.js

See: 

➜  Monolith git:(shadow-cljs) ✗
#2018-08-1710:09thhellerdoes node_modules/readable-stream exist? if so check its package.json please#2018-08-1710:09biscuitpantsno it doesn’t#2018-08-1710:10thhellerhmm? are you running npm in the wrong directory or something?#2018-08-1710:10biscuitpantsnah definitely in the right dire#2018-08-1710:10biscuitpants#2018-08-1710:11thhellertry deleting node_modules and package-lock.json again#2018-08-1710:11biscuitpantslol doing that now as a try#2018-08-1710:11thhellerI don't understand why it wouldn't install the package?#2018-08-1710:12biscuitpantsah that worked!#2018-08-1710:12biscuitpantspackage-lock was out of sync i guess#2018-08-1710:12thhellerhmm ok#2018-08-1710:12biscuitpantsdoes that happen often?#2018-08-1710:13thhelleryeah .. npm sucks ...#2018-08-1710:14biscuitpants😕#2018-08-1710:18urbanslugis there a way to reduce how much memory shadow-cljs is using?#2018-08-1710:18urbanslugHave an 8G laptop and having trouble#2018-08-1710:19thhelleryou can set :jvm-opts ["-Xmx1G"] in shadow-cljs.edn#2018-08-1710:19thhellerthat would limit it to 1gb#2018-08-1710:19thhellercan try -Xmx512m#2018-08-1710:20thhellermaybe 256m but at that point you'll run into problems I think#2018-08-1710:23biscuitpants
[:ci] Compiling ...
The required JS dependency "react-dom/test-utils" is not available, it was required by "node_modules/enzyme-adapter-react-15/build/ReactFifteenAdapter.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install react-dom/test-utils
i’m guessing i need to add a :resolve key for this?
#2018-08-1710:24thhelleris react-dom not installed?#2018-08-1710:24thhellerand no you don't need :resolve for this#2018-08-1710:24thhellerwhenever you see a message like this#2018-08-1710:25thhellercheck /Users/chrisetheridge/code/Cognician/Monolith/node_modules + react-dom/test-utils#2018-08-1710:25thhellerso#2018-08-1710:25thheller/Users/chrisetheridge/code/Cognician/Monolith/node_modules/react-dom/test-utils.js#2018-08-1710:26thhellerthe error message isn't ideal. it should list the full paths it tried to find#2018-08-1710:26biscuitpantsah okay. let me check that#2018-08-1710:26biscuitpantsi’ve installed react-dom#2018-08-1710:27thhellerit was in your deps so it should be there#2018-08-1710:27thhellerbut you pinned the version to exactly 15.0.0#2018-08-1710:27thhellerthats probably not ideal#2018-08-1710:27thhellerit may just not exist in that version#2018-08-1710:27biscuitpantsyeah that’s most probably the reason. going to see if i can bump it#2018-08-1710:28biscuitpantsoh i can use 16#2018-08-1710:28thhellerprobably don't have to bump to the latest react. just something more recent from the 15.x branch#2018-08-1710:29thheller15.0.0 is probably just bad#2018-08-1710:38biscuitpantsyeah that worked 🙂 thank you#2018-08-1710:38biscuitpantsis it possible to use a runner ns with karma?#2018-08-1710:38biscuitpantsif i use a runner ns, i get init is not defined#2018-08-1710:39biscuitpants
➜  Monolith git:(shadow-cljs) ✗ karma start --single-run
17 08 2018 12:38:56.254:INFO [karma]: Karma v2.0.5 server started at 
17 08 2018 12:38:56.259:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
17 08 2018 12:38:56.267:INFO [launcher]: Starting browser ChromeHeadless
17 08 2018 12:38:56.619:INFO [HeadlessChrome 0.0.0 (Mac OS X 10.13.6)]: Connected on socket B0WRKA9GuQOl0l4wAAAA with id 88087934
HeadlessChrome 0.0.0 (Mac OS X 10.13.6) ERROR
  {
    "message": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n    at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n    at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at ",
    "str": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n    at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n    at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at "
  }
#2018-08-1710:40thhellerare you using a custom :runner-ns?#2018-08-1710:40biscuitpantsyes#2018-08-1710:40biscuitpantscan you not use a custom one?#2018-08-1710:40biscuitpantswith karma#2018-08-1710:40thhellerthen you must adjust your karma config accordingly#2018-08-1710:40thhellerit tries to call client: {args: ["shadow.test.karma.init"]#2018-08-1710:41biscuitpantsah of course. it hooks into shadows one#2018-08-1710:41biscuitpantsdoh thanks dude#2018-08-1711:03biscuitpants
[0:0]~cljs.user=> (require '["enzyme-adapter-react-16" :as Adapter])
[:result {:type :repl/error, :ex #error {
 :cause "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
 :data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
   :data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
   :at [clojure.core$ex_info invokeStatic "core.clj" 4739]}]
i get this when trying to require that npm dep? regardless of :as or :refer
#2018-08-1711:04biscuitpantsin a shadow-cljs browser-repl#2018-08-1711:11biscuitpantsnvm. hit this before. i was on the wrong build#2018-08-1711:30biscuitpantshmm i still cannot require this module properly#2018-08-1711:34biscuitpants
["enzyme-adapter-react-16" :default Adapter]
#2018-08-1711:34thhellerbrowser repl doesn't have the :resolve setting#2018-08-1711:34biscuitpantsregardless of :default :refer or :as, i get undefined each time#2018-08-1711:34thhellerread the error message. none of that matters#2018-08-1711:35biscuitpantsi get no error message. printing the required object gives me undefined#2018-08-1711:36thhellerhmm? you just posted an error above?#2018-08-1711:36biscuitpantsthat was in the browser repl. i wanted to debug the require from there. but dropped that cause of the resolution errors#2018-08-1711:37thhellersec#2018-08-1711:39endenwerFix for loading files with absolute paths in electron. With this live reloading will work.#2018-08-1711:41thheller@endenwer I can fix the live reload, its just getting confused because of the file: url since I didn't expect that it just assumes http semantics currently.#2018-08-1711:42thhellerno need to hack into electron to make this work#2018-08-1711:43endenwerThis is from https://github.com/electron/electron/issues/2242. I din't find another way to fix live reloading#2018-08-1711:44thheller@endenwer I can fix it .. just not right now.#2018-08-1711:45thhellerhttps://github.com/thheller/shadow-cljs/issues/371#2018-08-1711:45endenwerYou mean in shadow-cljs?#2018-08-1711:45thhelleryes#2018-08-1714:24thheller@henrik try running shadow-cljs stop and then shadow-cljs server. it probably fails on startup.#2018-08-1714:25thhellerodd#2018-08-1714:25thhellermay be related to the new launcher though. I'm currently reworking that again to fix a few things#2018-08-1714:25thhelleryou can just downgrade to 2.4.33#2018-08-1714:26henrikI see. Are you storing logs somewhere that I can send you?#2018-08-1714:27thhellerthere should be one in .shadow-cljs/*.log#2018-08-1714:30henrikDowngrading works fine#2018-08-1714:31henrik
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2a424f445843416a67434743580718"}, :content ("[email protected]")}
#2018-08-1714:31thhellerthose are not normal errors though#2018-08-1714:37henrikOK, I rm-rf’d .shadow-cljs, reinstalled 2.5.1, and did a shadow-cljs start.#2018-08-1714:37henrikserver.stderr.log has a single Error: Unable to access jarfile null in it#2018-08-1715:51davidstwhat's the recommended way to serve non-js dependencies from npm (e.g., the css file for katex)? I am hoping there is something better than webjars or symlinks into the node_modules directory#2018-08-1715:52thhellerdon't serve them at all. bundle them into one file.#2018-08-1715:52thhellerI currently use node-sass for that#2018-08-1716:37ClashTheBunnyI would appreciate some 👀 on https://github.com/shadow-cljs/lein-template/pull/4#2018-08-1716:38ClashTheBunnyI'm off to lunch right now, but I'll be back in a couple hours.#2018-08-1720:10Logan PowellIs it possible to increase --max-old-space-size (the max heap size) via the package.json (reference: https://stackoverflow.com/a/34358130) I'm running out of memory doing some very large batch processing with fs#2018-08-1720:10Logan PowellI.e., can shadow listen for the start command in package.json?#2018-08-1720:18thheller@loganpowell where are you running out of memory?#2018-08-1720:18Logan Powell
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node_module_register
 2: v8::internal::FatalProcessOutOfMemory
 3: v8::internal::FatalProcessOutOfMemory
 4: v8::internal::Factory::NewFillerObject
 5: v8::internal::wasm::WasmOpcodes::TrapReasonMessage
 6: 000002033BF843C1
#2018-08-1720:19thhellerno which build?#2018-08-1720:19Logan Powellcli version: 2.4.25#2018-08-1720:19Logan Powellyou mean shadow or Node?#2018-08-1720:20thhellernode-repl or what?#2018-08-1720:20Logan Powellyes, node-repl#2018-08-1720:20Logan Powellbut it's due to the load I'm putting on Node#2018-08-1720:20thhelleryou can run (shadow/node-repl {:node-args ["--whatever"]})#2018-08-1720:21thhellerthat option is however not available from the CLI currently so only from clj-repl#2018-08-1720:25Logan PowellLike this?
(shadow.cljs.devtools.api/node-repl {:node-args ["--max-old-space-size=8192"]})
To quit, type: :cljs/quit
=> [:selected :node-repl]
#2018-08-1720:25thhelleryep#2018-08-1720:26Logan Powellso that's the equivalent of:
"start": "node --max-old-space-size=4076"
#2018-08-1720:26Logan Powellsorry with the 8192 in there instead#2018-08-1720:27thhelleryes#2018-08-1720:27Logan Powellsweet! Thank you!#2018-08-1816:09richiardiandreaCrossposting this idea: https://twitter.com/bhauman/status/1030846968384430080?s=20#2018-08-1816:10richiardiandreaI found I need this when setting up custom defmethods for testing - now I require one namespace in each and every test. What does Thomas think about it?#2018-08-1816:11thhellerthat seems like trying really hard to avoid having multiple independent builds?#2018-08-1816:13thhellerie. in shadow-cljs you'd have a app, devcards and tests build instead#2018-08-1816:15thhellerand if you need to inject extra stuff into a dev build you have :preloads?#2018-08-1816:22richiardiandrea@thheller uhm yep but I remember that we discussed about preload in node-test once and it was not working? I will try again though because I cannot recall now#2018-08-1816:26thhellerdidn't I fix that? thought I did#2018-08-1816:27thhellerhttps://github.com/thheller/shadow-cljs/issues/302#2018-08-1816:28thhellermaybe still missing for :node-test though?#2018-08-1816:33richiardiandreaUhm will take a look #2018-08-1816:48richiardiandreaSeems indeed missing, I will add it#2018-08-1816:54thheller@richiardiandrea already added it. wil probably make a release with it later#2018-08-1816:54thhellerfinishing up something else first though#2018-08-1816:54richiardiandreaAh ah ok cool thank you! Was about to.#2018-08-1818:10richiardiandrea@thheller I noticed that if I am in a cider REPL and do (require '[cljs.repl :refer [doc]]) then (doc map) the output of that goes in the terminal and not in the REPL...might be a CIDER issue but do you have any hint on that?#2018-08-1820:30thhellerhmm doc probably prints during compilation. so it prints wherever the compilation was started. did you start the watch or whatever per CLI and then connected the REPL?#2018-08-1822:20richiardiandreaYep like that#2018-08-1822:21richiardiandreaAnd you are probably very right in saying that it prints during compilation, I seems to recall something like that when I was writing stuff in lumo#2018-08-1822:24thhellerhmm no its printed on the client#2018-08-1822:24thhellerbut node-repl doesn't capture that yet#2018-08-1822:26thhellerhttps://github.com/thheller/shadow-cljs/issues/373#2018-08-1822:30richiardiandreaok cool thank you for opening the issue#2018-08-1822:29thheller@richiardiandrea just pushed 2.6.1 with :preloads support for :node-test#2018-08-1822:36richiardiandrea@thheller thank you trying that 😉#2018-08-1823:05richiardiandreaseems to work like a charm#2018-08-1904:30richiardiandreauhm, no....the side effects must be somewhere else...these defmethods are confusing...I will confirm later if it really works 😄#2018-08-1904:30richiardiandreaI guess this is correct? :devtools {:preloads [testing.with-diff-reporter]}#2018-08-1904:31richiardiandreathe full entry is:
{:target :node-test
                 :output-to ".cljs/tests.js"
                 :ns-regexp ".*-test"
                 :autorun true
                 :devtools {:preloads [testing.with-diff-reporter]}
                 :release {:compiler-options {:optimizations :simple
                                              :variable-renaming :off
                                              :property-renaming :off
                                              :pretty-print true
                                              :source-map true}
                           :autorun false}}
#2018-08-1904:33richiardiandreaI made sure and a normal require works...I am overriding the cljs.test multimethods, are those required before :preloads or after?#2018-08-1907:24thheller@richiardiandrea :dev {:preloads [...]} currently. forgot that should be in :devtools. will fix later#2018-08-1907:32thhellerif you want to mess with cljs.test options however I suggest copying https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs and adjust whatever you need and your ns via :runner-ns. its main fn will be called when running the test script#2018-08-1917:25richiardiandreaWill try with preloads just to see what happens, the resort to that. Not to write a runner is convenient 😄 #2018-08-1912:47wilkerluciohello, I just did a big bump on shadow from 2.4.10 to 2.6.1 and now getting these:#2018-08-1912:47wilkerlucio
RuntimeException java.io.EOFException
	com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:114)
	cognitect.transit/read (transit.clj:319)
	cognitect.transit/read (transit.clj:315)
	shadow.build.cache/read-cache (cache.clj:49)
	shadow.build.cache/read-cache (cache.clj:33)
	shadow.build.classpath/find-jar-resources/fn--10051 (classpath.clj:565)
	shadow.build.classpath/find-jar-resources (classpath.clj:564)
	shadow.build.classpath/find-jar-resources (classpath.clj:553)
	shadow.build.classpath/find-resources (classpath.clj:623)
	shadow.build.classpath/find-resources (classpath.clj:621)
	shadow.build.classpath/index-path* (classpath.clj:843)
	shadow.build.classpath/index-path* (classpath.clj:840)
Caused by:
EOFException
	com.cognitect.transit.impl.JsonParser.parse (JsonParser.java:44)
	com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:112)
	cognitect.transit/read (transit.clj:319)
Exception in thread "main" java.lang.NoSuchMethodError: com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
	at cognitect.transit$writer.invokeStatic(transit.clj:157)
	at cognitect.transit$writer.invoke(transit.clj:139)
	at shadow.build.cache$write_stream.invokeStatic(cache.clj:9)
	at shadow.build.cache$write_stream.invoke(cache.clj:8)
#2018-08-1912:48wilkerlucioany ideas what might be that?#2018-08-1912:52wilkerluciofixed by manually adding transit-java dep on latest#2018-08-1914:18thhellerwhat the heck?#2018-08-1914:20thhelleris this with plain shadow-cljs or lein/deps?#2018-08-1914:20thhellershadow-cljs depends on transit-clj which depends on transit-java so it should be there regardless?#2018-08-1915:27wilkerlucio@thheller plain shadow-cljs in this case#2018-08-1915:28wilkerluciomaybe some other dep of mine was overriding the transit version?#2018-08-1916:54thhellerhmm shadow-cljs is added as the very first dep to avoid such issues#2018-08-1918:28ClashTheBunnyIs there a dep-tree option to Shadow?#2018-08-1918:29thhellerthere was in 2.5 but its gone in 2.6. will be coming back soon.#2018-08-1918:29thhellerin the meantime you can try shadow-cljs pom and mvn dependency:tree if you have maven installed#2018-08-1918:56ClashTheBunnyAhh! Perfect!#2018-08-1919:21urbanslugAnyone know how to fix cannot infer externs for https://github.com/Day8/re-frame-template/blob/master/src/leiningen/new/re_frame/src/cljs/routes.cljs#L18 Seems to break the entire app because I set up navigation before mounting components#2018-08-1920:24thheller@urbanslug (fn [^js event] ...)#2018-08-1920:30urbanslugthanks a ton#2018-08-1920:34thheller@urbanslug but isn't the token coming from a closure router usually? that shouldn't require externs. are you sure thats the problem?#2018-08-1920:43urbanslugNo I'm not sure#2018-08-1920:43urbanslugI can't figure out routing lol#2018-08-1920:46wilkerlucio@thheller would be hard to support local deps (like deps :local/root) on shadow deps? I have been in mane cases were it would be very nice to use that#2018-08-1920:46thhellerwell you can just add the source path manually#2018-08-1920:46thhellerjust keep the deps as normal but also add the source-path#2018-08-1920:46thhellerthe files on the source path will be used over the jar#2018-08-1920:47thhellerI need to figure out some tools.deps stuff before I switch back to that#2018-08-1920:48thhellereventually I want to use it but the issues in 2.5 sort of got out of hand#2018-08-1921:07urbanslugHave you used accountant? From the readme on accountant this seems like it should be possible
(defn hook-browser-navigation! []
  (doto (History.)
    (gevents/listen
     EventType/NAVIGATE
     (fn [event] (secretary/dispatch! (.-token event))))
    (.setEnabled true)))


(defn setup-routing!
  []
  (accountant/configure-navigation!
   {:nav-handler  #(hook-browser-navigation!)
    :path-exists? (fn [path] (secretary/locate-route path))}))

#2018-08-1921:07urbanslugbut calls to accountant/navigate don't dispatch the routes#2018-08-1921:08thhellerno I have not used accountant#2018-08-1921:15urbanslugweird how little literature there is on naviation with goog.Histroy for cljs#2018-08-1921:15thhellerwhats your issue? routing is not that hard. sometimes seems libraries just make it harder#2018-08-1921:19urbanslughmm I want to transact the app state when links are clicked so that I can change views#2018-08-1921:20urbanslugand also have back forward in the browser#2018-08-1921:20urbanslugso I have two things on my urls click handlers and hrefs#2018-08-1921:20urbanslugI could transact app-state in click handlers but they won't update the url bar#2018-08-1921:21urbanslugand they spread state changing functions all over#2018-08-1921:22urbanslugMy routes defined secretary.core/defroute have funcitons transact the app state#2018-08-1921:23urbanslugthese fns don't seem to get triggered when the page is refreshed#2018-08-1921:25thhellerhttps://github.com/venantius/accountant looking at the docs it seems you are setting :nav-handler incorrectly#2018-08-1921:26thhellercalling the hook-... fn should only be done once on init#2018-08-1921:28urbanslughmmm I can't see that anywhere in the code#2018-08-1921:28urbanslugI mean the readme#2018-08-1921:29thheller(accountant/configure-navigation! {:nav-handler (fn [path] ...) :path-exists? (fn [path] ...)})#2018-08-1921:29urbanslugyou mean setup-routing! in my case#2018-08-1921:29thheller
(fn [path]
  (secretary/dispatch! path))
#2018-08-1921:29thhellerthats the :nav-handler you are supposed to use I guess#2018-08-1921:30urbanslugthat doesn't preserve history from what I can see#2018-08-1921:30urbanslugunless my assets are stale#2018-08-1921:30urbanslugOne sec#2018-08-1921:30urbanslugI'll clean eveything and try again#2018-08-1921:31thhellerwhat does preserve history mean to you?#2018-08-1921:31urbanslughmmm yeah it changes the url bar that's for sure#2018-08-1921:31urbanslugI mean umm render the previous view#2018-08-1921:31urbanslugSay I have two routes:#2018-08-1921:32thhellerthe user presses "back" and the hook fires to trigger the secretary/dispatch!#2018-08-1921:32thhellerthat how it goes from what I can see?#2018-08-1921:33urbanslug
(defroute root-path "/" [] (swap! app-state assoc :view :index))

(defroute map-path "/posts" [] (swap! app-state assoc :view :posts))
#2018-08-1921:34urbanslugso if I start at / and click a link for posts that runs :on-click #(accountant/navigate! "/posts")#2018-08-1921:34urbanslugit loads posts yes#2018-08-1921:35urbanslugbut if I press back the url bar will update witout the app-state change ties to the route. Even when I refresh it still ignores the contents of the url bar#2018-08-1921:36thhellersorry I don't know enough about any of theses libs to make a suggestion#2018-08-1921:36thhellerseems to me that you might just miss some call on startup?#2018-08-1921:37urbansluglet me move my call to setup-routing! to my init so that websocket stuff doesn't affect it and see#2018-08-1921:38urbanslugI appreciate the help 😄#2018-08-1921:38thhelleradding a few js/console.log calls never hurts 😉#2018-08-1921:39urbanslughaha I've done that already#2018-08-1921:39urbanslugI think the issue is that I don't quite get what I'm trying to make it do so I can't tell what's failing#2018-08-1921:39urbanslugI should just use reframe and let it handle everything for me#2018-08-2006:34bedersFirst of all: Thanks for shadow-cljs. I'm still learning the details, but it has simplified my things a lot!#2018-08-2006:34bedersI'm not sure how to deal with error messages like this though:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/openpgp/dist/openpgp.js"]]}
#2018-08-2006:35bedersHere's what I did:
npm install --save openpgp 
#2018-08-2006:35bedersthen in a ns decl: :require ["openpgp" :as openpgp]#2018-08-2006:36bederserror was caused by
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(FUNCTION ): node_modules/openpgp/dist/openpgp.js:38406:70
SymmetricallyEncrypted.prototype.encrypt = async function (algo, key) {
  Parent(CALL): node_modules/openpgp/dist/openpgp.js:38406:70
SymmetricallyEncrypted.prototype.encrypt = async function (algo, key) {
#2018-08-2006:37bedersso it looks like the code requires async/await (which is EcmaScript 2017).#2018-08-2006:37bedersIs that the issue here? Do I need to translate it with babel first?#2018-08-2006:37bedersthanks for the help and if there's a tip jar somewhere for shadow-cjls, let me know 🙂#2018-08-2007:28thheller@beders looks like a bug in the closure compiler. that INTERNAL COMPILER ERROR. message is from Closure not shadow-cljs.#2018-08-2007:28thhellerit reports many more errors when compiling that file#2018-08-2007:28thhelleropenpgp.js:34964: ERROR - This code cannot be converted from ES6. Undecomposable expression: Please rewrite the yield or await as a separate statement.#2018-08-2007:32thhellerhttps://github.com/google/closure-compiler/issues/3054#2018-08-2007:35thhellernot much we can do for now. you could probably process it with babel first but that is not usually recommended or required.#2018-08-2007:48thhellermaybe I should switch all pre-processing of node_modules to babel. currently its only down when the file has import/export#2018-08-2008:04thheller@beders I forgot that you can set :js-options {:language-out :ecmascript-2017} which will skip the transpilation#2018-08-2008:04thhellerbut only works in modern browsers with async support#2018-08-2008:26biscuitpants#2018-08-2008:26biscuitpantsi feel like this is a dep error?#2018-08-2008:26thhelleryes, probably guava#2018-08-2008:29thhellercheck which guava version is on the classpath. shadow-cljs --cli-info should do it#2018-08-2008:29biscuitpantsthank you. did deps-tree go in the new ver?#2018-08-2008:30biscuitpants[maven] com/google/guava/guava/20.0/guava-20.0.jar#2018-08-2008:36thhellerdeps-tree was tools.deps so its currently not available#2018-08-2008:36thheller20.0 is the old version. I don't get how that is used though#2018-08-2008:38thhellerit should be [com.google.guava/guava "25.1-jre"]#2018-08-2008:38biscuitpantsyeah don’t worry, using 25.1-jre worked#2018-08-2008:38biscuitpantshaha yeah that one worked perfectly#2018-08-2008:38biscuitpantsthank you#2018-08-2008:38thhellercan you share your :dependencies? I wonder how the old guava ends up on there#2018-08-2008:46biscuitpantssure, 1 sec#2018-08-2008:46biscuitpants#2018-08-2008:46biscuitpantscould be expound or orchestra. deps i haven’t looked at in depth before#2018-08-2008:46thhellernah shadow-cljs also brings in expound so its not that#2018-08-2008:47biscuitpantsis it possible to get more context with this error?
[2018-08-20 10:43:41.614 - INFO] :shadow.build.npm/js-invalid-requires - {:requires [{:line 37, :column 17}]}
#2018-08-2008:47thhellerhmm weird that should be including the filename the require was in#2018-08-2008:47biscuitpantsyeah unfortunately that’s all i get 😕#2018-08-2008:47biscuitpants#2018-08-2008:48biscuitpantsis that a require within a cljs file?#2018-08-2008:48biscuitpantsor is this after cljs has been compiled?#2018-08-2008:48thhellernah its usually not important#2018-08-2008:48biscuitpantsoh ok#2018-08-2008:48biscuitpantsi’ll ignore then#2018-08-2008:48thhellersome JS files have require("./foo/" + bar) type stuff#2018-08-2008:49biscuitpantsah right#2018-08-2008:49biscuitpantsnice. it took me 20 minutes to move from project.clj to shadow on this project! 😄#2018-08-2008:49biscuitpantsliterally no hiccups#2018-08-2008:49thhellerwell except for the deps stuff 😉#2018-08-2008:50biscuitpantshaha well that was luckily pretty small 😉#2018-08-2008:50biscuitpantsand i’m used to those errors now, from my fight with jackson#2018-08-2008:50thhellerbtw [cognician/base "336" :exclusions [com.google.guava/guava]]#2018-08-2008:50thhellermaybe need to do the deps exclusion for the other cognician things?#2018-08-2008:50biscuitpantsyeah i’ll do that too, thank you#2018-08-2008:51thhellerI'm guessing that the guava deps comes from there#2018-08-2008:51biscuitpantspossible#2018-08-2009:29biscuitpantsso this is new:#2018-08-2009:29biscuitpants#2018-08-2009:29biscuitpantsgetting a lot of those in my console#2018-08-2009:30biscuitpantsand:#2018-08-2009:30biscuitpants
#2018-08-2009:30thhellerCannot read property 'cwd' of undefined#2018-08-2009:31thhellerits the raven include causing the rest of the errors#2018-08-2009:31biscuitpantsah really#2018-08-2009:31thhellerit fails to load so all that depend on it also fail to load#2018-08-2009:31thhellererror is probably more graceful without :loader-mode :eval#2018-08-2009:32biscuitpantsah, yes, there are two types of ravens. one for client and one for server (node)#2018-08-2009:32biscuitpantsi was using the node one 🙂#2018-08-2009:39biscuitpantscan shadow-cljs deploy to maven?#2018-08-2009:40thhellernot at the moment#2018-08-2009:40biscuitpantsok#2018-08-2011:50biscuitpantscan shadow resolve deps that use S3p? https://github.com/s3-wagon-private/s3-wagon-private#2018-08-2011:50biscuitpantsif it uses deps.edn to resolve, then i assume yes?#2018-08-2012:06biscuitpantsah i see. i’d need to add a “wagon”, via Pomegranate#2018-08-2012:08biscuitpantsso i can work around this (by using a build clj script), but it would be great if we could specify wagons in build config#2018-08-2012:08biscuitpantslike https://github.com/circleci/s3-wagon-private/blob/master/src/main/resources/leiningen/wagons.clj#2018-08-2012:37thheller@biscuitpants using tools.deps did have too many bugs so currently it doesn't use tools.deps and no s3 is not supported#2018-08-2013:53biscuitpantsah okay @thheller yeah i see its using a mix of custom code and also pom#2018-08-2013:59thhellerI don't have access to any s3 repo so I can't easily test anything regarding that#2018-08-2014:00thhellerfor now I'd recommend lein/deps.edn for that since I have never looked into anything related#2018-08-2015:19biscuitpantsokay thank you#2018-08-2015:19biscuitpantshave you ever worked with pnpm ?#2018-08-2015:36thhellerI did a few tests yes but never in a real project#2018-08-2015:36thhellerit seems good but all the symlinks may confuse shadow-cljs#2018-08-2015:40thhellerdependencies are also installed weirdly#2018-08-2015:43biscuitpantsi think it does unfortunately, worthwhile to open an issue? i’m not sure if you aim to support it#2018-08-2015:44thhellerat that point I may as well write my own npm package installer 😉#2018-08-2015:44thhellerpnpm pretty heavily abuses the nested installs of npm which I absolutely hate#2018-08-2015:46thhelleralso don't know how it deals with version conflicts yet#2018-08-2015:46biscuitpantsinteresting. i didn’t know that. i found their method of installing (and sharing deps) to be clever#2018-08-2015:46biscuitpantsbut, i have not used it too much yet#2018-08-2015:47thhellerits pretty darn fast so thats real nice#2018-08-2017:36heyarneCan I trace module dependencies with shadow-cljs? I know about shadow-cljs.build.release-report, but can I get more fine-grained info? for example "which namespaces require cljs.pprint")#2018-08-2017:47thheller@arne-clojurians there is a (shadow.cljs.devtools.api/find-resources-using-ns 'cljs.pprint) but its very basic#2018-08-2017:47thhelleruse it from shadow-cljs clj-repl or nrepl#2018-08-2017:47heyarnealright, i'll give it a try#2018-08-2017:47heyarnethank you#2018-08-2017:48heyarnecan't repeat it often enough: super nice tool and your support is always helpful. thanks!#2018-08-2017:55heyarne:resolve is just meant for js packages, right? or can i easily switch debux for debux-stubs like described here? https://github.com/philoskim/debux#3-installation#2018-08-2017:56thhellerits only for JS yes. I'm a bit hesitant addding something similar for CLJS since it would be incompatible with any other tool#2018-08-2017:57thhellerI think the whole solution of stubs is kinda bad though. you can do the stubs using deps.edn or project.clj if you really have to#2018-08-2018:02thhellerthe functionality already exists though#2018-08-2018:03thhellerBUT the issue is that the stubs have the same namespace so it wouldn't work#2018-08-2018:04heyarneIt's not such a big issue for me tbh. I can also just clean up after myself and remove the requires before doing a release#2018-08-2019:04heyarnewhat's kind of interesting is i thought google closure compiler would be smart enough to do it by itself. i had a :require redux.core :refer [dbg] in a namespace that lands in production, but no call to dbg in it. still a lot of the pprint and analyzer stuff landed in the optimized file, resulting in something like a 150kbit pre-gzip (~50kb gzipped) decrease when i removed it#2018-08-2019:06thhellerclosure is heavily dependent on how the code is written and many things CLJS libs do just can't be eliminated#2018-08-2106:06urbanslugOh really? I didn't know about that second part#2018-08-2107:03thhellerhttps://github.com/thheller/shadow-cljs/commit/26cbb11c1f9848bda7a81546b18065b9dd34bc84#2018-08-2107:03thhelleranyone with access to s3 repos around?#2018-08-2108:40biscuitpantsworking well for me @thheller#2018-08-2109:20biscuitpants
➜  Manage git:(shadow-cljs) ✗ shadow-cljs browser-repl app
shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Manage/shadow-cljs.edn  cli version: 2.6.2  node: v10.8.0
shadow-cljs - connected to server
ClassNotFoundException shadow.cljs.devtools.cli  java.net.URLClassLoader.findClass (URLClassLoader.java:381)
on the new version?
#2018-08-2109:22biscuitpantshmm nvm. doing a new build sorted it out#2018-08-2109:25thhellerweird#2018-08-2109:26thhellerah maybe you had the server running and deleted some .m2 files or .shadow-cljs?#2018-08-2109:32biscuitpantsdon’t think so, but highly possible#2018-08-2110:54this.robHey all. Having some trouble with express using advanced optimizations. Error handling middleware (4 arity functions) are being compiled to 3 arity functions if the last arg (`next`) is not used e.g. in the case where we want to finish handling the request and send the response from within that middleware function. Because express uses the arity of the middleware to determine that it is an error handling middleware, when we are running the app with advanced optimizations this middleware is not being called as it should when an error is thrown from one of our routes.#2018-08-2110:55this.robwe are wondering what the best way to prevent the dropping of the last arg would be...#2018-08-2112:50kwladykaexample of code will help a lot to understand you issue#2018-08-2112:49kwladykaI have this error when try to load namespace in Cursive: CompilerException java.lang.RuntimeException: No such var: s/explain-data, compiling: with code
(defn- value->spec-msg [specs->msg spec value]
  "Check value with spec.
  If fail return msg error."
  (-> (s/explain-data spec value)
      (get-in [:cljs.spec.alpha/problems 0 :via])
      (last)
      specs->msg))
But I have it in :require and it works in webbrowser
(ns services.form
  (:require [cljs.spec.alpha :as s]
            [reagent.core :as r]
            [taoensso.timbre :as l]))
How can I use REPL cljs in Cursive in friendly way?
#2018-08-2112:56thheller@kwladyka remember that the REPL you connect to in Cursive starts as a Clojure REPL. you need to switch it to CLJS first.#2018-08-2112:57kwladykaI did it#2018-08-2112:57kwladykaBut what can be important I am in node-test REPL#2018-08-2112:58thheller@rs the only thing I can think of at the moment is using goog.reflect. You can call (gr/sinkValue next) as the first thing in the function. it doesn't actually do anything besides telling the compiler that the next should be kept and not removed.#2018-08-2112:59thheller@kwladyka CompilerException java.lang.RuntimeException: No such var: s/explain-data, compiling: pretty sure that you get this error when in a Clojure REPL#2018-08-2112:59kwladykaWhat I want to achieve: during write tests I often use REPL to check code during write tests / code of functions#2018-08-2113:00thhellerI assume you connected to the REPL remotely#2018-08-2113:00thhellerthen called (shadow/repl :your-build)#2018-08-2113:00thhellerthen eval'd whatever#2018-08-2113:02kwladykahmm you are right, for some reason I am not in CLJS REPL…. hmm I was in :app instead :node-test REPL#2018-08-2113:03kwladykathank you, the simplest things always make the harder issues 🙂#2018-08-2113:03thhelleryeah the REPL UI in Cursive it not that obvious unfortunately#2018-08-2113:03thhellereasy to confuse which state you are in#2018-08-2113:04kwladyka
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
Oh but I see I can’t use node-test with cljs REPL ?
#2018-08-2113:04kwladykathis appear when i try to run a code#2018-08-2113:05thhellerwell yeah#2018-08-2113:05thheller:node-test isn't really meant for REPL development since its supposed to exit after running your tests#2018-08-2113:05thhelleryou can use (shadow/node-repl) instead#2018-08-2113:08kwladyka
(shadow/node-repl)
To quit, type: :cljs/quit
=> [:selected :node-repl]
Loading test/services/form_test.cljs... repl/require failed { Error: ENOENT: no such file or directory, open '/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.test.env.js'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:348:35)
    at global.SHADOW_IMPORT ([stdin]:45:15)
    at Object.shadow$cljs$devtools$client$node$closure_import [as closure_import] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:33:4)
    at Object.shadow$cljs$devtools$client$node$repl_require [as repl_require] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:61:7)
    at shadow$cljs$devtools$client$node$process_message (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:122:6)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
    at WebSocket.<anonymous> (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:159:12)
    at WebSocket.emit (events.js:182:13)
    at Receiver._receiver.onmessage (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/node_modules/ws/lib/WebSocket.js:141:47)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path:
   '/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.test.env.js' }
Not so easy
#2018-08-2113:09thhellerah which version are you on? I broke node-repl in 2.4.33 I think#2018-08-2113:09thhellermight have been .32#2018-08-2113:09thhelleris fixed in 2.6.2#2018-08-2113:10kwladyka{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d7a4bfb6b3b8a0fab4bbbda497e5f9e3f9e4e4"}, :content ("[email protected]")} ok will try to update#2018-08-2113:17kwladyka
(shadow/node-repl)
To quit, type: :cljs/quit
=> [:selected :node-repl]
Loading src/services/form.cljs... done
Loading test/services/form_test.cljs... done
(-> {:names->value {:email ""
                              :password ""}
               :names->validations {:email [::spec-email]
                                    :password [::spec-password test-fn]}
               :specs->msg {::spec-email "Typo? It doesn't look valid."
                            ::spec-password "Password is required."}}
              (form/init-form))
(node:9656) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
<eval>:1
form.init_form(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"names->value","names->value",-1214004968),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"email","email",1415816706),"",new cljs.core.Keyword(null,"password","password",417022471),""], null),new cljs.core.Keyword(null,"names->validations","names->validations",-1835037433),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"email","email",1415816706),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("cljs.user","spec-email","cljs.user/spec-email",1595736430)], null),new cljs.core.Keyword(null,"password","password",417022471),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword("cljs.user","spec-password","cljs.user/spec-password",1742175166),cljs.user.test_fn], null)], null),new cljs.core.Keyword(null,"specs->msg","specs->msg",1137057203),new cljs.core.PersistentArrayM

ReferenceError: form is not defined
    at <eval>:1:1
    at Script.runInThisContext (vm.js:91:20)
    at runInThisContext (vm.js:298:38)
    at global.SHADOW_NODE_EVAL ([stdin]:74:30)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:25:16)
    at /Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:30
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:91:16)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:13)
    at shadow$cljs$devtools$client$node$process_message (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:116:6)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/kwladyka/Library/Mobile Documents/com~apple~CloudDocs/storage/Projects/content-manager-fe/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:148:10)
#2018-08-2113:18kwladykaWhen shift + cmd + p to run code in REPL#2018-08-2113:18thhellerprobably in the wrong namespace#2018-08-2113:19thhellerI don't know if thats my mistake or cursive but for CLJS you need to manually switch the ns#2018-08-2113:19thheller(in-ns 'whatever) or the REPL hotkey#2018-08-2113:22kwladykawith manual switch it works, thx#2018-08-2113:23kwladyka🍻#2018-08-2113:24kwladykaBTW @thheller I will be 6-10 in Berlin. Would you like to have a bear / tea if you are somewhere around?#2018-08-2113:25thhellerbit too busy for a trip to berlin. thats still 400km away for me 😛#2018-08-2113:28kwladykaOh I had hope maybe you live somewhere around#2018-08-2113:50heyarneis it possible to set up rebel-readline with a shadow-cljs cljs-repl?#2018-08-2113:50thhellerI don't know. Didn't look into it yet.#2018-08-2113:50thhellerCLJ should work out of the box but CLJS is a bit more complicated#2018-08-2113:51thhellerhttps://github.com/thheller/shadow-cljs/issues/358#2018-08-2114:17kwladykaHow to simulate webbrowser input changes in shadow-cljs? I just described my needs on #clojurescript#2018-08-2115:08this.rob@thheller thanks for the suggestion re: using goog.reflect. Its a shame the removal of unused args can't be turned off in the closure compiler to preserve arity!#2018-08-2115:09thhellerwell its rather weird for JS functions to check arities of the declared function#2018-08-2115:10this.robyes agreed. That's express...#2018-08-2117:02justinleeyea it’s actually not that unusual to check arities. there’s a whole style of programming that will, for example, return a promise if you pass 2 args but use a callback if you pass 3. 🙂#2018-08-2117:24thhellerwell thats different. that checks if the third arg was passed in at all which is normal#2018-08-2117:25thhellerbut checking the arity of the function that was passed is rather weird imho#2018-08-2118:41urbanslugHey so I have a dir structure like
├── shadow-cljs.edn
├── src
├── test
└── yarn.lock
and according to the shadow-edn has:
:source-paths ["src" "test"]
:test {:target    :browser-test
         :test-dir  "resources/public/js/test"
         :ns-regexp "-test$"
         :devtools  {:http-port          8021
                     :http-root          "resources/public/js/test"}}
#2018-08-2118:42urbanslugand then I have test.app.core_test.cljs#2018-08-2118:42urbanslugHowever, when I try to run my tests I keep getting a TBD#2018-08-2118:43urbanslugbasically my tests don't run#2018-08-2118:43urbanslugI want to keep my tests out of src#2018-08-2118:43urbanslugalso I don't have a test runner because from the docs, shadow will use the default cljs one(s)?#2018-08-2118:44urbanslugWhat am I missing?#2018-08-2118:53urbanslugmy test/app/core_test requires cljs.test https://github.com/thheller/shadow-cljs/issues/57#issuecomment-339673404#2018-08-2118:57urbanslugbasically experiencing this but I'm not using karma https://github.com/thheller/shadow-cljs/issues/57#issuecomment-356174200#2018-08-2119:12urbanslugthere's no /js/test.js#2018-08-2119:16thheller@urbanslug I have trouble understanding what you are saying#2018-08-2119:17thheller> However, when I try to run my tests I keep getting a TBD#2018-08-2119:17thhellerwhat? :browser-test you run by opening ?#2018-08-2119:20thhellertest.app.core_test.cljs would be in test/test/app/core_test.cljs right?#2018-08-2119:23urbanslugI have app.core-test in` test/app/core_test.cljs`#2018-08-2119:23urbanslugI am opening it in the browser now#2018-08-2119:24urbanslugand get the 404 on js/test.js#2018-08-2119:24thhellerdid you compile the tests?#2018-08-2119:24urbanslugI wasn't doing this before > what? :browser-test you run by opening http://localhost:8021?#2018-08-2119:24thhellershadow-cljs compile test#2018-08-2119:24thhelleror shadow-cljs watch test#2018-08-2119:25thhelleror shadow-cljs release test#2018-08-2119:25urbanslugtest i ran shadow-cljs watch test``#2018-08-2119:25urbanslugbut not compile#2018-08-2119:25urbansluglet me run compile test and see#2018-08-2119:25thhellerwatch is fine#2018-08-2119:25urbanslugwell I think compilation of the test failed becuse one of the required namespaces is missing#2018-08-2119:26urbanslugin my src...#2018-08-2119:26urbanslugmakes sense now that I know that the test had to compile#2018-08-2119:26thhellerit should compile even without a single test#2018-08-2119:27urbanslugya I've been rewriting in re-frame and moving things about#2018-08-2119:27urbanslugit won't compile#2018-08-2119:27urbanslugmissing namespaces and what not#2018-08-2119:27thhellerwhats the error?#2018-08-2119:28urbanslugthe error is on my end#2018-08-2119:28thhellerI don't know what missing namespaces and what not means#2018-08-2119:28urbanslugI'm renaming namespaces#2018-08-2119:28urbanslugand moving them around#2018-08-2119:28urbanslugsorry#2018-08-2119:32thhellerI'm confused. So the only problem is that the watch didn't finish compiling? which explains why the js/test.js doesn't exist and your tests will only run once it completes#2018-08-2119:33thhellereverything around testing isn't exactly user friendly currently. it'll get better soon I hope.#2018-08-2119:35urbanslugya! > So the only problem is that the watch didn't finish compiling?#2018-08-2119:35urbanslugI appreciate the effort#2018-08-2119:35urbanslugI've done cljs with om now before figwheel and all#2018-08-2119:35urbanslugthis is a huge leap for me#2018-08-2119:37urbanslugThis should run successfully though, right?
(ns app.core-test
  (:require-macros [cljs.test :refer-macros [deftest testing is]])
  (:require [cljs.test :as t]
            [app.core :as core]))

(deftest fake-test
  (testing "fake description"
    (is (= 1 2))))

#2018-08-2119:38thhellerassuming that the rest of your build compiles properly yes#2018-08-2119:38urbanslugUncaught TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined#2018-08-2119:38urbanslugit compiled with many warnings#2018-08-2119:39urbanslugbut somehow seems not to have = defined#2018-08-2119:39urbanslugfrom the error#2018-08-2119:39urbanslugthat's an error in the js console#2018-08-2119:39urbanslug> Ran 0 tests containing 0 assertions. > 0 failures, 0 errors.#2018-08-2119:39thhellerwhat are the warnings#2018-08-2119:42urbanslugok sorry again
Use of undeclared Var app.core-test/deftest 
#2018-08-2119:43urbanslugI'm clearly missing the dep cljs.test#2018-08-2119:43urbanslugand should add it to my edn#2018-08-2119:44urbanslugwasted enough of your time lol#2018-08-2119:44thhellerno you shouldn't#2018-08-2119:44thhellerits on there#2018-08-2119:44thhellerhttps://github.com/thheller/browser-test-example#2018-08-2119:44thhellerhere is all the example code you posted#2018-08-2119:45thhellernpx shadow-cljs watch test and open . runs totally fine without warnings#2018-08-2119:45thhellerI have no idea whatever else you are doing though#2018-08-2119:45thheller
Testing app.core-test

FAIL in (fake-test) (at http:438:85)
fake description
expected: (= 1 2)
  actual: (not (= 1 2))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
#2018-08-2119:46thhellerI used different source paths but that doesn't really matter#2018-08-2119:46thhelleralso tweaked the requires a bit since :require-macros isn't necessary.#2018-08-2119:46thheller
(ns app.core-test
  (:require [cljs.test :as t :refer [deftest testing is]]
            [app.core :as core]))
#2018-08-2119:49urbanslugOK it has to be on my side#2018-08-2119:49urbanslugI have 48 warnings so...#2018-08-2119:50urbansluggotta step away from this for a bit. It seems moving to re-frame won't be a quick thing haha#2018-08-2119:51urbanslugI appreciate you testing that out for me#2018-08-2119:51urbanslugthat's a ton of help#2018-08-2120:01urbanslugstashed my changes and redid it with just the tests (without all the move-to-reframe-code) and it works#2018-08-2120:01urbansluggotta stop crying wolf 😬#2018-08-2120:03urbanslugand now I see this will likely not work in CI#2018-08-2120:08thhellerthats where karma comes into play#2018-08-2120:09thhelleror just :node-test#2018-08-2120:24urbanslughave you used any for react?#2018-08-2120:24urbanslugand btw I thought I saw warning when not explicitly using require-macros#2018-08-2120:24urbanslugor it being deprecated#2018-08-2120:24urbanslugI mean using refer-macros#2018-08-2120:25thhellerah that was the problem yes#2018-08-2120:25thhelleryou used :require-macros with :refer-macros#2018-08-2120:25thhellerits supposed to be :require-macros + :refer#2018-08-2120:26thhelleror :require + :require-macros#2018-08-2120:26thhellerbut :require + :refer is just fine too#2018-08-2120:26thhellerI guess that could be considered a nsform bug if it doesn't complain about the combo of :require-macros + :refer-macros#2018-08-2120:26thhellertotally didn't see that at all#2018-08-2120:27thhellerthe "automatic" :refer of macros doesn't always work as it depends on the namespace that declares the macro#2018-08-2120:27thhellerbut it definitely works for cljs.test#2018-08-2120:34thhellerhttps://github.com/thheller/shadow-cljs/issues/377#2018-08-2121:03urbanslughaha my messing around was good for something#2018-08-2211:44biscuitpants@thheller do you have any plans to support requring CSS in JS, like webpack allows? what do you use for this functionality?#2018-08-2211:57thhellerI do have plans for that yes, nothing actually usuable yet though. I just use node-sass currently.#2018-08-2212:07urbanslugSo after realizing that the browser test wouldn't do for me I'm exploring node-test#2018-08-2212:07urbanslugI think this is what react uses with jest when you create a react app from the scaffold#2018-08-2212:08urbanslugbasically testing even my node modules#2018-08-2212:10urbanslugseems there isn't much literature about this#2018-08-2212:11urbanslug
========= Running Tests =======================
SHADOW import error /home/user/project/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$semantic_ui_react$dist$es$index.js
/home/user/project/node_modules/semantic-ui-react/dist/es/index.js:2
import _Confirm from './addons/Confirm';
       ^^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)

#2018-08-2214:55thheller@urbanslug thats ES6 code which doesn't work natively in node. there is some option to enable it but I forgot.#2018-08-2214:55thhelleryou are also probably testing browser stuff so :browser-test or :karma may be better suited#2018-08-2215:27urbanslug@thheller I want it to work on CI#2018-08-2215:27thheller:karma then#2018-08-2215:27urbanslugmaybe a headless browser in a docker container idk#2018-08-2215:27urbanslugok let me check out karma#2018-08-2215:28urbanslugit seemed to only talk about angular#2018-08-2215:28urbanslugand I'm doing react#2018-08-2215:28urbanslugreagent#2018-08-2215:28urbanslugWhich linter do you use?#2018-08-2215:28thhellerkarma is generic, not tied to any framework. its just a headless browser basically.#2018-08-2215:28thhellerI don't use a linter#2018-08-2215:29urbanslugAh > karma is generic, not tied to any framework. its just a headless browser basically.#2018-08-2215:29urbanslugthanks m8#2018-08-2216:19urbanslughmm I have a problem with this args: ["shadow.test.karma.init"], in my karma.conf.js#2018-08-2216:19urbanslugseems to be an arg to karma-run#2018-08-2216:20urbanslugI'm basically having it be app.core-test#2018-08-2216:20urbanslugUncaught ReferenceError: app is not defined...#2018-08-2216:21thhellerno thats wrong#2018-08-2216:21thhelleryou leave it as is#2018-08-2216:21thhellerthat is the main test runner#2018-08-2216:22thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-karma#2018-08-2216:22thhellerthis works. no need to adjust anything#2018-08-2216:23thhellerlike all test targets your tests are included via the :ns-regexp#2018-08-2216:23thhellerALL included tests are then executed by shadow.test.karma/init#2018-08-2216:23thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/karma.cljs#L113#2018-08-2216:24thhellerbasically that just makes sure that some output is emitted that karma can understand#2018-08-2216:24thhellerunless you write your own runner ns you do not touch args#2018-08-2216:25urbanslugsame thing though Uncaught ReferenceError: shadow is not defined...#2018-08-2216:25thhellerthat probably means that your paths are wrong#2018-08-2216:26thhellercheck that basePath: 'out/demo-karma' and files match your paths#2018-08-2216:26urbanslugtree is like so
├── src
├── target
├── test

#2018-08-2216:27thheller:output-to "target/ci.js"#2018-08-2216:27urbanslugI'm using your basepath target#2018-08-2216:27thhellerwhat is your :output-to?#2018-08-2216:27thheller
basePath: 'target',
        // The file itself
        files: ['ci.js'],
#2018-08-2216:27urbanslugOk I know where I messed up#2018-08-2216:27thhellerbasically the two combined must match whatever :output-to is#2018-08-2216:28urbanslugI had ::output-to "target/cli.js"#2018-08-2216:28urbanslugcli instead of ci#2018-08-2216:28thhellerI don't use karma myself so its a wonder any of this works at all#2018-08-2216:28thhellerdocs could certainly be improved#2018-08-2216:28urbanslugDo you test your code?#2018-08-2216:29thhellersome of it yes#2018-08-2216:29thhellerin clojure though#2018-08-2216:29urbanslugha! the test ran successfully#2018-08-2216:29urbanslugand without chromium#2018-08-2216:29urbanslughow? > in clojure though#2018-08-2216:29urbanslugI mean with chromium not chrome#2018-08-2216:29thhellerlein test 😉#2018-08-2216:30urbanslugI don't have lein on my system 😄#2018-08-2216:30thhellerI should write more tests but meh testing 😉#2018-08-2216:30urbanslugTrue! Tests are hell and nobody appreciates the effort that goes into them#2018-08-2216:30urbanslugwhich sometimes is a ton#2018-08-2216:31thhelleryep its often more code to write the test than the actual code#2018-08-2216:31thhellerespecially UI testing#2018-08-2216:31thhellerthats why I don't do it#2018-08-2216:31thhellerbasically I only test critical functions that work with pure data#2018-08-2216:31urbanslugI also installed what was here https://github.com/Day8/re-frame-test#running-the-cljs-tests-with-karma but not sure that it helped#2018-08-2216:32urbanslugthis is my aim too but I literally needed a way to run the tests somehow in CI > basically I only test critical functions that work with pure data#2018-08-2216:32urbanslugand I didn't have one#2018-08-2216:33urbanslugis there a reason you chose a different dir for your karma tests output? than the usual resources/public...#2018-08-2216:34urbanslugWhen I figure out what I'm doing I'll try improve the docs. They could do with some clarification. Comments like don't mess with karma client args#2018-08-2216:36urbanslugAlso the need to set CHROME_BIN=chromium or whatever it is I wonder how nicely this will play in CI#2018-08-2216:39urbanslugseems people install the whole damn thing https://github.com/Zenika/alpine-chrome/blob/master/Dockerfile#L10#2018-08-2216:39urbanslugslow tests are tests that people will refuse to run 🤔#2018-08-2216:40thhellerI can't make any recommendations regarding karma. I don't use it. I don't know how it works.#2018-08-2216:41thhellereven less so in a CI env#2018-08-2216:45urbanslugwell I'll let you know what I learn anyway#2018-08-2216:46urbanslugwhen I learn it...#2018-08-2216:46urbanslug90% there#2018-08-2216:48urbanslugyou have this https://github.com/thheller/shadow-cljs/blob/master/karma.conf.js#2018-08-2216:54heyarnecould it be that hot-reloading multimethods doesn't work as expected?#2018-08-2216:55thhellerdepends on what you expect?#2018-08-2216:56heyarneprobably true. it didn't seem to execute the updated code when i changed the source of the dispatch function#2018-08-2216:56heyarneuntil i Ctrl + C'd and restarted#2018-08-2216:56heyarneand i expected it to execute it#2018-08-2216:56heyarnewithout having to restart the build#2018-08-2216:59thhellerah yeah defmulti is basically defonce. you can only change the dispatch fn if its a reference to some other fn#2018-08-2216:59thheller(defmulti foo bar) works but (defmulti foo (fn [x] ...)) doesn't#2018-08-2216:59heyarnehm... i had it as a reference#2018-08-2218:14richiardiandreahas anybody have this before with deps.edn?
shadow-cljs - starting via "clojure"
Error building classpath. nil
java.lang.NullPointerException
#2018-08-2218:16richiardiandreaok got it#2018-08-2218:16richiardiandrea...almost#2018-08-2218:17thhellerstrange#2018-08-2218:17richiardiandreanow I got it, crazy maps 😄#2018-08-2218:17richiardiandreait's a clojure issue#2018-08-2218:17richiardiandreaerror reporting is not helpful when there are mistakes in the deps.edn file#2018-08-2218:31biscuitpants@urbanslug @thheller we currently have Karma running tests under shadow-cljs in a CI env. happy to help if you need it#2018-08-2218:44richiardiandreaare folks here using shadow-cljs in Cursive? I have a question 😄#2018-08-2218:44thhellerI do#2018-08-2218:45richiardiandrea@thheller how do you setup the REPL? If the port is random, can you still use the nrepl file automagically for that?#2018-08-2218:45richiardiandrea(writing a post btw, so this will all be documented :D)#2018-08-2218:46thhellerusing .nrepl-port in non-lein projects#2018-08-2218:47richiardiandreauhm, which Run configuration do you select?#2018-08-2218:49thhellerclojure repl -> remote -> use leiningen port#2018-08-2218:50richiardiandreaand how do you lauch the nrepl server? within Cursive?#2018-08-2218:51thhelleralways in the terminal
#2018-08-2218:52thhellerjust running npx shadow-cljs server in the build-in terminal and leaving that running#2018-08-2218:52richiardiandreaok I though there was a way to run it inside, if external then I am already good 😄#2018-08-2218:52richiardiandreathank you#2018-08-2218:54urbanslug@biscuitpants hmmm do you have a way to watch your karma tests?#2018-08-2219:17richiardiandrea@thheller question, is there a function for unwatching a build?#2018-08-2219:17richiardiandreaI see shadow/stop-worker#2018-08-2219:17thhelleryep#2018-08-2219:17richiardiandreabut start-worker is priivate#2018-08-2219:17thhellerwatch starts the worker#2018-08-2219:18richiardiandreaok, what about making it consistent? adding unwatch or something? even just an alias#2018-08-2219:18thhellerunwatch isn't exactly clear what it means#2018-08-2219:18thhellercould just mean stop getting log messages but leave worker running#2018-08-2219:18richiardiandrearight#2018-08-2219:20richiardiandreawill think about it more, don't even know if there is some usability issue there, just going through what I have written it felt ....itchy 😄#2018-08-2219:20thhellerI think its fine. just need to document what a worker is since people technically only ever see watch#2018-08-2219:20richiardiandreayeah#2018-08-2219:21thhellerbut is a (shadow/watch :the-build {:autobuild false}) still a watch? 😉#2018-08-2219:21richiardiandreawell, I was thinking if there is a use case where you don't want to watch the logging#2018-08-2219:22richiardiandreajust compile...#2018-08-2219:22richiardiandreabut maybe not#2018-08-2219:22richiardiandreabecause logging gives you the errors#2018-08-2219:22thhellerwell thats just compile which doesn't start a worker 😉#2018-08-2219:23thhellerworker is just more generic term for "process responsible for managing the build compilation"#2018-08-2219:23thhellerwatching anything is actually optional#2018-08-2219:24richiardiandreayeah...if we had protocol server on the shadow server, one wouldn't need to check the terminal for errors I guess, but we are not there yet#2018-08-2219:24richiardiandreaso you actually have to watch#2018-08-2219:24thhelleryep#2018-08-2219:25thhellerwe'll the pure REPLs (node-repl, browser-repl) don't watch at all so it is possible working without watch#2018-08-2219:25thhellerjust need to manually load stuff which is totally fine too#2018-08-2219:26richiardiandreayep for browser you actually see errors in there#2018-08-2219:26richiardiandreatrue, for now node, you will see evaluatiion errors#2018-08-2219:26richiardiandreaI like this actually, I think I will try this workflow#2018-08-2219:26thhellerI also added shadow/watch-compile-all! for compile-on-key-press vs compile-on-file-save#2018-08-2219:26richiardiandreaok nice#2018-08-2219:27richiardiandreathat is very cool actually#2018-08-2219:27richiardiandreafits very well into my workflow#2018-08-2219:27thhellerforgot who I added it for but it makes total sense#2018-08-2219:27thhellerwatch without autobuild#2018-08-2219:28thhellerand bind the trigger to a key. so you can compile all changed files when pressing that key instead of all the time a file is changed#2018-08-2219:28richiardiandreathat's awesome#2018-08-2219:28thhellerwatch often is a bit over eager#2018-08-2219:29richiardiandreaagree#2018-08-2219:29richiardiandreathat key just send a REPL command?#2018-08-2219:29richiardiandreayep I guess 😄#2018-08-2219:29richiardiandreaoh the above command, right#2018-08-2219:29thhelleryeah just send (shadow.cljs.devtools.api/watch-compile-all!) to the REPL on keypress#2018-08-2219:30thhellersimple setup with REPL commands in cursive#2018-08-2219:30richiardiandreanice#2018-08-2219:32thhellerbut yeah I really like the run in terminal + remote REPL connect in cursive#2018-08-2219:32thhellerwhen I get tired of nrepl I sometimes use clojure.main REPL with -m shadow.cursive-repl#2018-08-2219:32thhellerthat autoconnects to the socket repl instead of nrepl#2018-08-2219:32richiardiandreaoh#2018-08-2219:32richiardiandreanice#2018-08-2219:32richiardiandreaI was trying just now clojure -A:dev:tree -m shadow.cljs.devtools.cli server#2018-08-2219:33thhellerhow you start the server doesn't really matter#2018-08-2219:33thhellercan be embedded too#2018-08-2219:34richiardiandreayeah I am documenting both..for nrepl this is also valid clojure -A:dev:test -m nrepl.cmdline (does not end up in shadow.user though#2018-08-2219:35richiardiandreaand the you need also --middleware I guess, so I am not documenting that one 😄#2018-08-2219:36richiardiandreahow do you connect to socket REPL?#2018-08-2219:36richiardiandreadoes not seem to work here#2018-08-2219:36thhellernrepl is horrible to setup manually#2018-08-2219:36richiardiandreaException starting REPL: java.lang.ArithmeticException: integer overflow#2018-08-2219:36thhellerhmm?#2018-08-2219:37thhellerclj -m shadow.cursive-repl should just work (+ whatever aliases you need of course)#2018-08-2219:38richiardiandreaok will try that#2018-08-2219:38thhellerstill haven't played with the cursive deps.edn support. not on EAP at the moment.#2018-08-2219:38richiardiandreakk yeah well, I don't see much here actually#2018-08-2219:51richiardiandrea@thheller is there a difference between repl and nrepl-select?#2018-08-2219:53thhellerrepl delegates to nrepl-select when connected via nrepl.#2018-08-2219:54thhellernrepl-select just skips the check if you are in nrepl if you know you are in nrepl#2018-08-2219:55thhellerI recommend using repl since it also works for socket repl and just looks better 😉#2018-08-2219:59richiardiandreaOk cool then#2018-08-2221:48richiardiandrea@thheller so watch-compile-all! does not work if I am not watching?#2018-08-2221:48richiardiandreabecause I want a worker and do not want to watch#2018-08-2221:48richiardiandreabut want watch-compile-all! 😄#2018-08-2221:49thhelleryeah it still needs the worker. its meant to be combined with (shadow/watch :the-build {:autobuild false}) for now#2018-08-2221:49thhelleryou do want to watch though since it otherwise wouldn't pickup file changes#2018-08-2221:49richiardiandreaoh so in that case wouldn't start-worker make sense?#2018-08-2221:49thhellerso triggering a compile wouldn't do anything#2018-08-2221:49thhellerjust look at the impl of watch#2018-08-2221:50thhellerit also hooks up the output printing and such#2018-08-2221:51thhellerI guess you could argue that naming of all of this isn't great#2018-08-2221:51thhellerbut I suck at naming and couldn't come up with something useful#2018-08-2221:51richiardiandreayeah I think that is my main objection#2018-08-2221:51thhellerwatch-compile-all! is also meant for force-triggering a compilation for builds that may be stuck#2018-08-2221:52richiardiandreayep I think I got it now#2018-08-2221:52thhellersay a missing npm dep currently leaves the build stuck#2018-08-2221:52richiardiandreajust was missing (shadow/watch :script {:autobuild false})#2018-08-2308:26biscuitpantsis it possible to call (shadow/nrepl-select :app) from a different nrepl that’s running from the same app? or do you have to use the shadow nrepl to call that? can the shadow nrepl replace clojure.tools.nrepl ?#2018-08-2308:27thhellerdo you mean a different nrepl server?#2018-08-2308:28thhelleryou'll need to add the middelware to that server https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-08-2308:28biscuitpantsokay, and then do i still call nrepl-select ?#2018-08-2308:29thhelleryes#2018-08-2308:30biscuitpantsokay thank you#2018-08-2308:30hlollidid shadow-cljs offer any way of bundling a jar? Recommend using leiningen for that?#2018-08-2308:30thhellernot yet, leiningen recommended yes.#2018-08-2308:31biscuitpantsyou can use something like this https://github.com/juxt/pack.alpha#2018-08-2308:31biscuitpantsyou’d need a deps.edn file though#2018-08-2308:31hlolliwow nice!#2018-08-2308:31hlollithanks @biscuitpants#2018-08-2308:32biscuitpantsi haven’t used it in prod yet though 🙂#2018-08-2308:32hlolliI love riding on rough paths, live on the edge 😛#2018-08-2308:35hlollibtw, a proof that audioworklet and wasm can be compiled with shadow-cljs https://jsfiddle.net/4o3q5tu7/1/ (just showoff)#2018-08-2308:39biscuitpantsthis is very cool#2018-08-2316:32urbanslugis there a way to specify dependecies for dev and for prod with shadow-cljs?#2018-08-2316:32urbanslugbased on https://github.com/Day8/re-frame-debux#installation#2018-08-2316:33urbanslugbut https://github.com/jacekschae/conduit/blob/master/shadow-cljs.edn#L12 I can see both bundled together#2018-08-2316:36thheller@urbanslug no that is not supported currently. you can do it via :lein or :deps if you need to#2018-08-2316:37urbanslug:deps?#2018-08-2316:37urbanslughttps://clojure.org/reference/deps_and_cli#2018-08-2316:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2018-08-2316:38urbanslugthanks 🙂#2018-08-2317:34hlolliIs it possible, or has it been thought trough and considered not worth it. To publish jar with cljs resources and bundle with it the shadow-cljs.edn file, which when consumed by other shadow-cljs app. Will inherit the npm dependencies, :resolve and :hooks (or make it configureable which to inherit and what not)?#2018-08-2317:37hlolliThis seems to part of another endless discussion of npm deps in cljs. But yeh, totally annoying. tools.deps supporting :npm-deps would be nice. It almost doesn't happen anymore that someone makes a library in clojurescript.#2018-08-2318:09richiardiandrea@hlolli I had a look at pack as well for the same reason and I am thinking of adding an Azure pack target for my use case: https://github.com/juxt/pack.alpha/issues/18#2018-08-2318:09richiardiandreabut it would definetly convenient to have everything in one tool...#2018-08-2318:17hlolli@richiardiandrea yes looks like this is very special usecase. Maybe it's not such a big problem of packageing the stuff we need, generate .pom etc. But what the build tools do with it. I'd like more radical integration with javascript. As for the hooks, js already has install, preinstall and postinstall. We have 4 tools to build clj/s (lein/boot/shadow-cljs/clj), and none can do it. If you ask me, the minification that webpack does is pretty radical and has gotten way better. Clojurescript isn't an island, but almost.#2018-08-2318:18hlolliDon't know why I added the webpack comment there 🙂 but it's easy not to use any optimization, at least in shadow-cljs, which I love.#2018-08-2318:27hlolliAnyway, to end my rant, which only in a good tone and with great love of cljs. Then imagine, publishing a cljs library running on nodejs "by the book". Then the recommended way is bundling all the dependencies in a consumeable form, makeing a jar, stuffing in the js, and declare foreign libs. With that, generate extern. Now imagine 100 modules in the node_modules for like 5 npm deps. Wiriting extern for each and one of them. Then ok, if successful, upload them to cljsjs, create PR and wait, so that at the end of it you can tell your friend, "hey check out my new library with this oneliner". End of rant 🙂#2018-08-2318:50richiardiandreayeah not ideal#2018-08-2318:50thheller@hlolli it has been considered but ruled "not desirable". a library should never be specific to one tool, its one of the worst aspects of some npm deps and not something I want to introduce to CLJS. its already kind of bad that CLJS can't easily consume most npm deps like shadow-cljs but I do hope that they'll catch up eventually.#2018-08-2318:50thhellercustom :resolve hooks are really a last resort option and should be used very rarely#2018-08-2318:50thheller:npm-deps you can declare in deps.cljs which shadow-cljs supports and will install on startup. CLJS will to when configured to do so.#2018-08-2318:51thhellerjs install/postinstall/preinstall hooks are the worst idea ever IMHO#2018-08-2318:53thhellerthere is also the fundamental difference in how cljs and closure view the world vs webpack. closure wants to optimize your whole program, webpack optimizes file by file and only recently gained some cross-file stuff#2018-08-2318:53thhellerso publishing CLJS libs to npm for use by JS is probably never going to be easy#2018-08-2318:54thhellerwebpack minification is laughable compared to what closure does. it is getting better but is nowhere near closure :advanced#2018-08-2319:01thhellerI can start ranting about all the bad things in npm for hours but I'd rather not 😉#2018-08-2319:07thhellerhappy to look over whichever problem you are running into though#2018-08-2319:08thhelleryou seem to have deleted another related message. at least I got an email notification but can't find the message here 😉#2018-08-2319:20hlollihehe yup, I deleted it, it was about being stuck between :es5 and :es6 when I using cljsbuild. If I uesed :es5 then I got errors about const and whole lots of features not being supported. When I used :es6, I started to get require calls adding .default and some of the node modules. Basically I'm working on packaging cljs app so that, hopefully, everyone can consume it on any build tool. But :npm-deps in deps.cljs, I had no idea that was possible. That may actually be exactly what I need. Thanks for pointing that out!#2018-08-2319:23thhelleryeah the .default issue is a bit annoying. its the closure compiler doing that and unfortunately breaks many npm packages. and its a wontfix 😞 https://github.com/google/closure-compiler/issues/2971#2018-08-2319:27hlolliChad Killingsworth seem to have encountered this himself and made some changes. Maybe I try them out.#2018-08-2413:51onetomIt's funny you are mentioning this because when vscode was open sourced, the very first thing i did is i tried to compile it, then i tried to see how can i hook in to the rendering and the file buffer, to see if i can implement elastic tabstops. But then I got lost in the forrest of typescript classes and gave up on it...#2018-08-2319:28hlollithe problem was with .default, is that it was a module that I wasn't event require-ing directly, but a nested require#2018-08-2319:29thhellerthe change should be available in the closure compiler version used by shadow-cljs#2018-08-2319:29thhellerbut it doesn't matter. it only fixed an unrelated issue#2018-08-2319:33hlolliit was in lein, but yup, I am leaving it behind for now and concentrating on tools.dep.#2018-08-2319:34thhellertools.deps isn't any different than lein when it comes to what CLJS does#2018-08-2319:34thhellerbut whats the actual problem you are trying to solve?#2018-08-2319:35hlolliah sorry, the actual problem was running tests.#2018-08-2319:36hlolliBut I guess that they need to run in lein too... so I won't leave it behind. My brain is bit drained.#2018-08-2319:45hlolliif this is a nofix, then I just publish this stuff I have and write big red letters, use shadow-cljs. This is happening in the module "safe-buffer", which some module I'm requireing, is requireing, is requireing a built-in module "buffer"
var buffer = require('buffer')
this becomes
module$buffer.default
and I get ReferenceError: module$buffer is not defined
#2018-08-2319:47thhellerclosure probably didn't understand the buffer package#2018-08-2319:48thhellerbut yeah .. actually using :npm-deps in CLJS is rather unreliable still#2018-08-2319:49thhellerbuffer is also usually a built-in node package so it requires the node-libs-browser shims that webpack also uses#2018-08-2319:49thhellerdunno if you have those installed#2018-08-2319:50thhellerhttps://github.com/webpack/node-libs-browser#2018-08-2319:50hlolliI'm in this case only targeting node, I have seperate namespace for the browser, which I don't think this package will get required#2018-08-2319:50hlolliI would assume that, built-in modules would just get hard-coded into the closure compiler.#2018-08-2319:51thhellerhmm if you are only building for node that closure shouldn't rewrite any code at all?#2018-08-2319:51thhellerare you maybe not setting :target :nodejs or so?#2018-08-2319:51thhellerand no closure has no predefined handling for built-in node packages at all#2018-08-2319:52hlolliyes ahh, but I have :simple I "meant" that for .cljs sources#2018-08-2319:52thhellerit doesn't matter#2018-08-2319:53hlollithis is what I'm working with now#2018-08-2319:53hlollihttps://pastebin.com/sS89zmQU#2018-08-2319:53thhellerin shadow-cljs when compiling for node the (:require ["whatever" :as x]) just generates a require("whatever") call#2018-08-2319:53thhellerthe code rewriting stuff only applies for browser builds since they can't use require#2018-08-2319:53thhellernode builds for CLJS also emit require#2018-08-2319:54thhellerso it should never get to the situation where require("buffer") is turned into module$buffer at all#2018-08-2319:55thhellerI honestly have no idea about that config, may need to ask someone else#2018-08-2319:56hlolliok, yes, I wish closure would not change anything inside node_modules#2018-08-2319:57thhellerit shouldn't when building for node#2018-08-2319:57thhellerbut I think :npm-deps confuses it#2018-08-2319:57thhellertry setting :npm-deps false and see if that works#2018-08-2319:57hlolliok#2018-08-2320:05hlolliah ok I get it! now what's happening it that I just add the npm modules to foreign-libs, which is good, because I can set :module-type for each and every dependency.#2018-08-2320:06thhellerhmm?#2018-08-2320:07thhelleryou don't add npm modules to :foreign-libs ever. they won't work.#2018-08-2320:07hlollifor example, when compiling, I get
Caused by: clojure.lang.ExceptionInfo: No such namespace: web-audio-api, could not locate web_audio_api.cljs, web_audio_api.cljc, or JavaScript source providing "web-audio-api"
#2018-08-2320:08thhellerdoes node_modules/web-audio-api exist?#2018-08-2320:08hlolliyes and if I add
{:file        "node_modules/web-audio-api/index.js"
:provides    ["web-audio-api"]
:module-type :commonjs}
it will go away
#2018-08-2320:08thhellerbut your code won't run at all#2018-08-2320:09thhellerthats not what foreign-libs are for#2018-08-2320:09thhelleryou want the CLJS compiler to emit require("web-audio-api"). that is all. nothing else.#2018-08-2320:09thhellerI don't know what setting you need to set to get it to do that#2018-08-2320:10thhellerask someone that does before continuing. you are on the completely wrong path when trying to use :foreign-libs to solve this.#2018-08-2320:10hlolliok just commented :npm-deps false then it compiles, just again ReferenceError: module$buffer is not defined#2018-08-2320:10thhellerthey are not suitable for this at all. :foreign-libs are prepended to the compiled code as-is!#2018-08-2320:12hlollihehe I maybe ask at another channel. And want to add that this is no "problem" for me, it's only an extra cool point that more people could use my code. Most likely, 1-2 peeps max will 🙂#2018-08-2320:15thhellerI honestly can't figure out how to make it emit require#2018-08-2320:15thhellerI know that it can do so but no idea how#2018-08-2320:15hlollibefore asking, I'll try this with vanilla closure in js...#2018-08-2320:16hlollijust for sanity#2018-08-2320:16thhellerclosure got nothing to do with this#2018-08-2320:16thhellerthats the point. closure should not be involved at all.#2018-08-2320:16thhellerthe CLJS compiler should emit require and let node figure it out#2018-08-2320:18hlolliyou don't think it could be connected with :language-in :es6 ?#2018-08-2320:18rafHello, I've just started using shadow-cljs for my ClojureScript development. My configuration file looks so:
{ :source-paths ["src/clj" "src/cljc" "src/cljs"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:app {:target :browser
                :output-dir "resources/public/js"
                :asset-path "/js"
                :modules {:main {:entries [my-ns.main]}}}}}
In one of the file I'm requiring reagent like so:
(ns my-ns.main
  (:require [reagent.core :as r]))
when I try to build this I got such message: The required namespace "reagent.core" is not available, it was required by Should I invoke some command to install it? Or maybe I should install it by lein project? Thanks in advance!
#2018-08-2320:19thheller@hlolli no.#2018-08-2320:21thheller@raf use three quotes for multi line code. your config looks fine and should work. are you sure you started shadow-cljs after adding the dependency?#2018-08-2320:21thhellerif you have an old instance running that won't have the dep and won't find it#2018-08-2320:23raf@thheller I use such command in the shell:
lein run -m shadow.cljs.devtools.cli compile app
#2018-08-2320:24thhellerwell if you use lein to run the command you need to add the dependency to project.clj#2018-08-2320:24thhelleror run shadow-cljs compile app#2018-08-2320:25rafah, clear. Somehow I thought lein is just throttling it to the shadow-cljs cli#2018-08-2320:25rafthen I've install npm package with shadow-cljs#2018-08-2320:25thheller:source-paths and :dependencies in shadow-cljs.edn don't matter if you use lein#2018-08-2320:25thhelleras lein will only use project.clj#2018-08-2320:26raf@thheller clear - I thought that only puting :lein option in the shadow-cljs.edn makes that lein deps are used#2018-08-2320:27thhellergenerally yes but only if you actually use the shadow-cljs command itself and not lein#2018-08-2320:27rafnow everything is clear. Thank you very much for help! I appreciate this! You've saved me a lot of time 🙂#2018-08-2320:27raf@thheller now when I think about this, this ofc makes sens#2018-08-2320:28raf@thheller thank you. Have a good night#2018-08-2320:44raf@thheller just wanted to let you know, that now everything works, I was able to compile and run code#2018-08-2320:45hlolliI think the problem is @cljs-oss/module-deps": "^1.1.1"#2018-08-2320:46thhelleryou are still doing it wrong it that is used at all#2018-08-2320:47thhellerbut yeah maybe just having it installed messes with things#2018-08-2320:48hlolliI get Error: Cannot find module '@cljs-oss/module-deps' don't know who's asking for this then Error: Could not locate the bindings file. Tried:... for node-speaker#2018-08-2320:49thhellernot a clue whats happening. I'm off to bed. gn8#2018-08-2320:49hlolliok, gn8, thanks again for all your help!#2018-08-2321:21kwladykaWhat is the best way to develop “lein” library and include it to shadow-cljs as dependency? My goal is to develop module and during this development test it in separated project as lein and shadow dependency.#2018-08-2321:22kwladykaI was even thinking about use the same project with project.clj and shadow-cljs.edn and run the same code using both to test it#2018-08-2321:24kwladykaSo all in all I created module to help validate form with specs and fns. I want it to be dependency for lein and shadow-cljs example project (which will be the same project). This example project will have forms in web browser to let developers easy have the demo.#2018-08-2321:25kwladykaBut the main issue is during developing I want to use version from my local hard drive, but when build project I want to use version from github.#2018-08-2400:29richiardiandreaare lifecycle hooks working for node targets: I am trying to use :after-load but it does not seem to get triggered#2018-08-2400:31richiardiandreanvm it works, I just did not see that print in the node process terminal#2018-08-2410:19kwladykaI will present me team shadow-cljs as alternative to leiningen. Maybe we could use it instead. Can you recommend articles about lein <-> shadow-cljs code compatibility, something what prove shadow-cljs is mature solution and no scary to use it etc.?#2018-08-2410:19thhellerif your team is used to leiningen then there is no reason to switch#2018-08-2410:20thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2018-08-2410:20thhellerI assume you mean switch from cljsbuild/figwheel though and no I haven't written anything on that subject yet#2018-08-2410:21thhellerI started several times but its tough for me to write it since I haven't used cljsbuild/figwheel for 4+ years#2018-08-2410:21thhellerdoes me using it in production for 4 years count as mature? 😛#2018-08-2410:22kwladykasure, but team probably want something more black and white prove on paper#2018-08-2410:23kwladykaI think the main difference is how :require macros looks. Also in shadow we can write event.target.name while in lein we can not (as i know)#2018-08-2410:24thhellernope all that is completely standard#2018-08-2410:24thhellershadow-cljs just uses the normal CLJS compiler. the only modification it does is basically to the parsing of the ns form. thats it.#2018-08-2410:25thhellereverything else is completely standard#2018-08-2410:25thhellerwell I guess npm support isn't standard#2018-08-2410:25kwladykabut the same :require code wouldn’t work with lein#2018-08-2410:25thhellerdepends on what you require but otherwise it should behave exactly the same#2018-08-2410:26kwladykaI want to point what is not compatible#2018-08-2410:26thhellerJS deps aren't compatible#2018-08-2410:26thhellereverything else is#2018-08-2410:26kwladykaThis is the main concern of people#2018-08-2410:26kwladykaok so by deps we mean exactly this :require code part?#2018-08-2410:27thhellerCLJS/lein cannot do (:require ["some-npm-dep" :as x]) reliably#2018-08-2410:27thhellerso those JS deps will not work#2018-08-2410:27thheller(:require [any.other.cljs.ns :as x]) will work just fine#2018-08-2410:28thhellerCLJSJS deps don't work which is the big adjustments your team would need to make#2018-08-2418:59kwladykaBecause of deps.edn. How to determine which CLJSJS will / wouldn’t work?#2018-08-2420:00thhellernone will work but you can "emulate" them. some are already emulated. https://github.com/thheller/shadow-cljsjs/tree/master/src/main#2018-08-2420:00thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-08-2410:28thhellerie. switch from using CLJSJS deps to using npm directly instead#2018-08-2410:32kwladykaany other hints what talk to people to introduce shadow-cljs?#2018-08-2410:33kwladykaBTW Why somebody could prefer https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen instead of use shadow-cljs directly?#2018-08-2410:35thhellerif you have a Clojure server-side using lein#2018-08-2410:35kwladykaWhat do you mean?#2018-08-2410:36thhellerthe only focus of shadow-cljs is CLJS development. if you do any kind of CLJ development I recommend using lein for that part.#2018-08-2410:36thhellersome people prefer running only one tool and embedded shadow-cljs in their CLJ server process instead#2018-08-2410:36kwladykaso for projects which contains clj and cljs files in the same project / repository ?#2018-08-2410:38thhellerif you do any kind of CLJ development yes. the presence of .clj files could just be macros or utility functions, those are fine for shadow-cljs#2018-08-2410:38kwladykaoh, true#2018-08-2410:39thhellersome people also use deps.edn instead of lein#2018-08-2410:39thhellerits all fine and I guess depends on how much non-CLJS development you do#2018-08-2410:39thhellersome also use deps.edn for pure CLJS development though due to the extra features deps.edn offer (eg. git-deps)#2018-08-2410:39kwladykaBTW something moved forward with lein cljs npm dependency support?#2018-08-2410:40thhellerremove the "lein" modifier from your statements#2018-08-2410:40thheller"lein" has absolutely nothing to do with any of this#2018-08-2410:40thhellerstandard clojurescript has the limitations, not lein. and no it is still a work-in-progress with many rough edges.#2018-08-2410:43thhellershadow-cljs basically uses the standard clojurescript compiler but replaces the JS support with its own implementation. thats it.#2018-08-2410:43thhellerall other tools use the standard implementation which is a bit unreliable#2018-08-2410:45thhellerhttps://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d#2018-08-2410:45thhellerhttps://theiceshelf.com/log/2018-06-cljs-npm-deps/#2018-08-2410:46thhellerthose might be helpful. good experience reports in trying to get JS deps working.#2018-08-2410:47kwladykathank you, I will look on it. Now I have to go and will be back in a few hours.#2018-08-2419:01kwladykaHmm so while you could rewrite this limitations in shadow-cljs, why standard cljs can’t?#2018-08-2419:11wilkerluciostandard cljs is targetting a harder integration, they want to make so every node module is correctly understood by Google Closure so they can be optimized on release builds. As far as I understand, Shadow relaxes on this goal and just copy over the used files (grossly speaking), this doesn't have all the good optimizations, but works#2018-08-2419:46thhellerthe JS integration in shadow-cljs is basically modeled after webpack instead and following their conventions.#2018-08-2419:47kwladykaSo shorty this is about what @U066U8JQJ said?#2018-08-2419:52thhellerits really not that easy to explain the differences#2018-08-2419:52thhellershadow-cljs sacrifices some optimizations for better compatibility with JS#2018-08-2419:53thhellerclojurescript doesn't do that and the end result is better when it works.#2018-08-2419:53thhellerit however rarely works.#2018-08-2419:56thhellerthe difference is only in the JS integration. the generated CLJS code is identical.#2018-08-2420:28dnolenbut note all that old stuff is really obviated by the new Webpack support#2018-08-2420:28dnolenlinking to that stuff now doesn’t make any sense to me#2018-08-2420:29dnolenwe’ve more or less stopped recommending :npm-deps as the way since the last release#2018-08-2420:56richiardiandrea@dnolen say I am producing a ClojureScript library which has npm dependencies, does the Webpack method would work there? seems like I would still need to declare transitive :npm-deps somehow#2018-08-2420:56dnolenWebpack support has nothing to do with :npm-deps#2018-08-2420:57dnolenthere’s really no point in talking about them together#2018-08-2420:59dnolenas in - they will never interoperate - but this not really important for the common use case of - I just need X from node_modules for this thing I’m trying to ship#2018-08-2421:03dnolenmost of teeth gnashing in the past is about that - not what you’re talking about#2018-08-2421:04richiardiandrearight, so the webpack solution is only for compiling down in order to produce either a node script or a browser JS - make sense, thank you!#2018-08-2421:12urbanslugSo mainly based on https://github.com/thheller/shadow-cljs/issues/179#issue-289518679 I'm trying to come up with devcards template for shadow-cljs https://gitlab.com/urbanslug/sniff/blob/master/shadow-cljs.edn However, when I run yarn devcards I get the error that the build for app isn't running and well devcards doesn't work. Anyone have an idea about this?#2018-08-2421:13urbanslugpublic now#2018-08-2421:36thheller> I get the error that the build for app isn't running#2018-08-2421:36thhellerwhat kind of error is that? I don't know of any such error in shadow-cljs#2018-08-2421:37thhellerdevcards doesn't work how? I don't see it in dependencies?#2018-08-2506:54smnplkAfter upgrading shadow-cljs to the latest version 2.6.3, why does the log output still say "server version: 2.4.26" and "cli version: 2.4.26" ? If I do "which shadow-cljs" it does point to the new binary /home/simon/.nvm/versions/node/v10.8.0/bin/shadow-cljs#2018-08-2506:56urbanslugok uploading a screenshot but it's taking forever#2018-08-2506:57urbanslughttps://screenshots.firefox.com/93KJnKJ606U51PN6/localhost#2018-08-2506:57urbanslug@thheller that ^#2018-08-2506:58smnplkoh, nvm. I didn't run npm upgrade. 🙂#2018-08-2507:00urbanslugI wonder whether I should have different {:main {:entries [...]}}#2018-08-2507:07thheller@urbanslug https://gitlab.com/urbanslug/sniff/blob/master/resources/public/devcards.html#L25#2018-08-2507:07thhelleryou are including the wrong output file#2018-08-2507:07thhellershoud be js/devcards/main.js#2018-08-2507:08thheller@smnplk the version installed in the project is always used over the global install
#2018-08-2507:18urbanslughmmm is it just me or does devcards still need saving for me to see the changes? I should probably watch the talk#2018-08-2507:19urbanslugI thought it would be the inventing on principle thing or storybook where I change text and the UI changes#2018-08-2507:19urbanslugwithout a save#2018-08-2507:19urbanslugthis feels just like shadow-cljs hot reload#2018-08-2507:21thhelleryou still need to save. something smarter would require pretty heavy compiler modifications#2018-08-2507:21thhelleryou can use the REPL though#2018-08-2507:22thhellerwhich is generally faster than saving, waiting for watch etc#2018-08-2507:25urbanslugok defcard I'm using defn#2018-08-2507:26urbanslughmmm let me see how I can do this > you can use the REPL though#2018-08-2507:27urbanslugfrom what you're saying though I don't see a big difference between devcards and what shadow does. I could have shadow with a different build outputting to a different js file referenced by a different html and get the same result, right?#2018-08-2507:28thhellerdevcards is just a clojurescript library. shadow doesn't do anything comparable no.#2018-08-2507:29thhellerdevcards is not responsible for any live-reloading or anything. that is done by shadow or figwheel#2018-08-2507:30urbanslughmmm ok I should really finish reading the readme because defcard doesn't even create a function#2018-08-2507:30urbanslugYeah let me first do what the docs say#2018-08-2507:31thhellerif you haven't watched the talk then yes you should definitely watch the talk#2018-08-2507:39urbanslughaha ya I clearly dk what this tool is for. 😄 I created a devcard and can't get those nice meters on it#2018-08-2507:39urbanslug
(ns sniff.devcards
  (:require [devcards.core :refer-macros (defcard)]
            [devcards.core :as dc] 
            [reagent.core :as r]))

(def x 10)

(defcard simple-component [x]
  [:div
   [:p (str  "I am a component!" x) ]
   [:p.someclass
    "I have " [:strong "bold"]
    [:span {:style {:color "red"}} " and red "] "text."]])


(defn ^:export main
  []
  (dc/start-devcard-ui!))
#2018-08-2507:40urbanslugand screenshots by ff is taking forever to upload#2018-08-2507:42urbanslughttps://screenshots.firefox.com/JQGoNudrcFFhbNB7/localhost#2018-08-2507:42urbanslugbut this resource is proper http://rigsomelight.com/devcards/#!/devdemos.defcard_api#2018-08-2508:12thhellerpretty sure that that is not the correct way to create a devcard#2018-08-2508:12thhellerI never used it but the [x] is definitely out of place#2018-08-2509:01urbanslughahaha I read the docs and yeah it wasn't#2018-08-2509:02urbanslugI can kinda see what devcards are for. Taking a component out and just seeing what's wrong with it in isolation#2018-08-2509:04urbanslugNow to use a deps.edn#2018-08-2509:59thhellerI'd say its about getting visual examples of you components in different states#2018-08-2509:59thhellernot about "seeing whats wrong with it"#2018-08-2519:52rafHi! I'm working or re-frame/reagent application and somehow I cannot force shadow-cljs to do live reloading of page content. The strange part is that repl and browser are connect and when I save the file I see in the browser log:
shadow-cljs: load JS <name>
but he HTML on the page is not changed. When I refresh whole page I see the changes. Any tip what is going on? Or maybe where in shadow JS code I could look to debug it
#2018-08-2519:53thhellerdo you have the hooks properly configured?#2018-08-2519:53thhellerthe page doesn't change without hooks and you triggering the page update#2018-08-2519:53thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2018-08-2519:54thhellerin reagent apps there typically is a call to render which you need to call again in the hooks#2018-08-2519:56raf@thheller oh, I read the manual but somehow I've missed the need to add those hooks. Again you save me lot of time!#2018-08-2519:56raf@thheller thank you#2018-08-2519:58raf@thheller and of course it works, as you suggested I've added the hook to the main render method and I have my live reloading of HTML :+1:#2018-08-2520:02thheller@richiardiandrea nice article on the cursive setup. one small nitpick: the source-map-support install is not required. shadow-cljs already depends on that and ensures that it is installed.#2018-08-2520:02richiardiandreaoh cool thank you#2018-08-2520:02richiardiandreawill fix that#2018-08-2520:03richiardiandreaI guess this is true only for npm install though am I right?#2018-08-2520:03thhelleralso the new npx create-cljs-project foo might be useful. skips the yarn init + yarn add calls#2018-08-2520:04thhellerits new so it doesn't have any options yet but saves some typing already 😉#2018-08-2520:04thhelleryarn create cljs-project foo also works#2018-08-2520:05thheller@richiardiandrea not sure what you mean by npm install?#2018-08-2520:05richiardiandreaI mean npm install shadow-cljs#2018-08-2520:06thhelleryes that is already required basically. it provides the few dependencies we require.#2018-08-2520:06thhellersource-map-support, node-libs-browser, ws, etc#2018-08-2520:06richiardiandreaok cool, as long as it is it pulled transitively 😄 will add a comment on that, thank you!#2018-08-2520:07raftaking the opportunity I have one more question (I've started using shadow-cljs few days ago and still try to figure out all the stuff - still I think it's superior work!): is there way to make live reload of work with the repl? I mean: when I run some code I repl I would like to see the changes in my reagent app#2018-08-2520:07richiardiandreais create-cljs-project a new thing? since which version?#2018-08-2520:07thheller@raf just call the :after-load function you just added via the REPL#2018-08-2520:08thhellerie. make a change, eval it, then eval the render#2018-08-2520:08thhellerthere is no REPL hook to do that automatically. not sure that would be a good idea#2018-08-2520:09thheller@richiardiandrea you answered the post about it? https://clojureverse.org/t/project-templates/2694#2018-08-2520:09richiardiandreaoh, ok did not check after that 😉#2018-08-2520:10rafalso not sure if this would be a good idea 😉 and of course you've helped me again. When I've run the render method in repl I see my changes. Now I think my whole development environment is ready to do some coding 😉#2018-08-2520:11thheller@raf which editor are you using? in Cursive you could make a REPL command for (your.app/render) and bind it to a key#2018-08-2520:11thhellerso you could re-render on keypress. might be useful.#2018-08-2520:11raf@thheller I'm using Emacs with Cider#2018-08-2520:11thhellerits possible there too but I have no idea how 😉#2018-08-2520:11rafand ofc I could do that in Emacs 😉#2018-08-2520:12rafI think I know 😄#2018-08-2520:12raf@thheller if I find time maybe I will write small blog post about all the stuff you have learned my on this slack - maybe it safe you some time with "another me" next time 😄#2018-08-2520:13thhellerI always try to note what questions people ask and update the docs accordingly but sometimes stuff gets in the way#2018-08-2520:13thhellerso blog posts are always welcome 😉 as are docs PRs#2018-08-2520:14richiardiandrea😄 that is what I did for the Cursive blog post, that's great that you are always online Thomas, especially in terms of usability shadow-cljs does not have rivals#2018-08-2520:16raftrue that! I find shadow-cljs the best option right now, plus the possibility to ask you a question here is also extremely nice#2018-08-2520:16raf@thheller I think your manual has all the bits that are needed, but sometimes if you're new to the subject it's hard to connect them in one story#2018-08-2520:18thhelleryeah its tough to properly organize sometimes#2018-08-2520:18thhellerI'll be writing a proper quickstart guide once I figure out this template situation#2018-08-2520:19rafgreat, good luck with that 🙂#2018-08-2520:20richiardiandrea@thheller yarn create-cljs-project cursive-shadow-cljs does not work but the npx version does#2018-08-2520:24richiardiandreaI think yarn does not do project resolution from npm#2018-08-2520:27thheller@richiardiandrea not the extra space in my example. yarn has a special create command which is kind of a gimmick#2018-08-2520:27thhellerso yarn create cljs-project loads the create-cljs-project package and calls it#2018-08-2520:27richiardiandreaoh#2018-08-2520:27thhellernpx just calls whatever#2018-08-2520:27richiardiandreawow completely missed reading that 😄#2018-08-2520:28richiardiandreaadding it to the post#2018-08-2520:30rafI will call it a night. Have a good one, bye#2018-08-2523:02ghidenHello. I just started to play with shadow-cljs a few days ago. How do you start an external server from shadow-cljs? I have a boot file that starts a proxy server to backend API, and my re-frame app talks to the API server through this proxy. Is this something possible to do with shadow-cljs?#2018-08-2607:13thheller@ghiden the built-in http servers can proxy themselves. would that work? https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2018-08-2607:13thhellerah nvm you want to proxy the API not the shadow-cljs API 😉#2018-08-2607:14thhelleryou can always use clojure https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-08-2607:15thhellerthere is no built-in process management yet. but I will likely add it at some point#2018-08-2607:16thhellerhttps://github.com/thheller/shadow-cljs/issues/381#2018-08-2607:17ghidenThank you for your advice. So basically I have to start a proxy server from one terminal and start a watcher with proxy settings from a different terminal?#2018-08-2607:19thhellerhmm wait I got confused myself#2018-08-2607:19thhellerthere are two proxy settings, mixed them up myself#2018-08-2607:19thhellerone isn't documented#2018-08-2607:20thhellerso say you start the built-in server via :devtools {:http-port 8080 :http-root "public" :proxy-url ""}#2018-08-2607:20thhellerevery request you make to that does not exist on the file system will be requested from the configured proxy#2018-08-2607:21thheller -> #2018-08-2607:21thhellerwould that work?#2018-08-2607:21ghidenYep that should work#2018-08-2607:22ghidenWhat’s the undocumented one?#2018-08-2607:22thheller:proxy-url isn't documented#2018-08-2607:23thheller:devtools-url is the other proxy-related one but for the other direction. ie. a proxy in front of the shadow-cljs dev server#2018-08-2607:23ghidenAh devtools-url is the one documented#2018-08-2607:24ghidenIs it safe to use proxy-url?#2018-08-2607:25thhellersafe as any other proxy I guess?#2018-08-2607:25ghidenI mean why isn’t documented?#2018-08-2607:25thhellerits just using the built-in undertow proxy support#2018-08-2607:25thhellerbecause I added it for someone and forgot to write the docs 😉#2018-08-2607:25thhellerits a tiny amount of code#2018-08-2607:25thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/dev_http.clj#L51-L68#2018-08-2607:25ghidenCool#2018-08-2607:27thhellerbut its not very configurable and just proxies everything that doesn't have a local file#2018-08-2607:28thhellerwill still need to add more sophisticated options at some point#2018-08-2611:24kwladykaWhat is the story of shadow in name? 🙂#2018-08-2611:49pauldI'm trying out the fulcro shadow-cljs template. The build launches fine in the terminal (as per README), but I'm wondering if I someone might know why I get this error when trying to launch in CIDER: Exception in thread "main" java.lang.RuntimeException: No such var: ana/cacheable-files, compiling:(shadow/build/cljs_closure.clj:569:19)#2018-08-2611:51pauldI created a bare fulcro build using this: lein new fulcro app shadow-cljs#2018-08-2611:57pauldMaybe using cider-connect is the better option for this.#2018-08-2612:14pauldthe template is using an old version of piggieback...#2018-08-2612:26pauldMaybe cider can't handle launching the more complicated shadow-via-lein setup in this template.#2018-08-2612:26pauldI might have to take this over to #cider#2018-08-2612:31pauldOk, after updating piggieback I get the following error after cider-jack-in-clojurescript using lein profile then choosing shadow as the cljs connection type.#2018-08-2612:47pauldOk, I'm getting closer? I had outdated dependencies (fulcro, shadow-cljs, etc) so now I get this error during compilation:#2018-08-2612:50pauldThe above was generated by doing cider-jack-in-clojurescript, but choosing the shadow profile instead.#2018-08-2613:39thheller@pauld that is still a very outdated cljs dependency? should be 1.10.339#2018-08-2613:40thhelleryou are trying to run the embedded version right?#2018-08-2613:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded you need to call the server/start! fn mentioned there.#2018-08-2613:41thhellerthe missing instance means that no server was started#2018-08-2614:11pauldAh! You are a genius. It was the outdated clojurescript 'dependency'.#2018-08-2614:12pauldI use quotes here because lein deps :tree revealed that clojurescript was not a dependency anywhere.#2018-08-2614:12pauldso I included it in deps and that fixed my issue.#2018-08-2614:13pauldweirdly this only occurred using cider-jack-in-clojurescript. shadow-cljs watch main did not show this compiler error.#2018-08-2614:14thhellerno idea about the cider part but it may be starting through lein and not the shadow-cljs command#2018-08-2614:14thhellerthen lein is responsible for all the classpath stuff and you are on your own sorting out classpath issues#2018-08-2614:15pauldyeah the fulcro template is using lein via the :lein option in shadow-cljs.edn.#2018-08-2614:16pauldCider may not be dealing well with this use case.#2018-08-2614:16thhellerits mostly about getting your dependencies right#2018-08-2614:16thhellerit should work if you just add clojurescript 1.10.339, shadow-cljs manually maybe#2018-08-2614:17thhellerbut core.async and lots of other things are important too so make sure youhave the latest verisons of those too#2018-08-2614:17pauldYes, that did work as I said above.#2018-08-2614:18pauldthanks!#2018-08-2618:42urbanslugHello, does shadow not work well with npm packages from git?#2018-08-2618:43urbanslugI've installed an npm package from git but shadow-cljs gives The required JS dependency "<name>" is not available, it was required by "<namespace>".#2018-08-2618:52urbanslug@thheller ^ ?#2018-08-2619:02hlolli@urbanslug is the npm package in node_modules ? shadow-cljs as far as I know, doesn't do anything when it comes to installing npm pacakges from npm/git/wherever#2018-08-2619:02urbanslugit's not in node_modules#2018-08-2619:03urbanslugwhich I guess is more a yarn/npm issue then?#2018-08-2619:03hlolliyes, it's an npm issue then#2018-08-2619:03hlollinpm i does it work?#2018-08-2619:03urbanslugit says it's installed#2018-08-2619:03hlolliwhat package is this?#2018-08-2619:03urbanslugbut when I list contents of node_modules it's not there#2018-08-2619:04urbanslughttps://github.com/urbanslug/react-d3-speedometer#2018-08-2619:05hlollihttps://github.com/urbanslug/react-d3-speedometer/blob/master/package.json#L76#2018-08-2619:05hlollithis doesn't exist maybe?#2018-08-2619:05urbanslugSMH#2018-08-2619:06urbanslugthis works on npm install https://github.com/palerdot/react-d3-speedometer/blob/master/package.json#L76#2018-08-2619:06urbanslugso...#2018-08-2619:07hlolliif you're inside the root of this package, and you do npm install, then "main" doesn't matter. But if you for example require directory locally, it will look at "main" to know which js if the main. If none is found, it defaults to index.js#2018-08-2619:07hlolliand how you declare a git dep matters as well in the package.json#2018-08-2619:08hlolliprotocol needs to be git:// as far as I remember#2018-08-2619:10urbanslugthe directory somehow just didn't get "cloned into node modules. What's weird is that I started a new (js not cljs) project and npm installed it and it was then in my node modules.#2018-08-2619:10hlolliok look here https://github.com/urbanslug/react-d3-speedometer/blob/master/.scripts/prepublish.sh#2018-08-2619:11hlollithis repository is only the source code not the distribution. You could run this file, commit it, and then require the git. The developer of this lib probably runs this every time before npm publish#2018-08-2619:12urbansluginteresting#2018-08-2619:12urbanslugthat is weird#2018-08-2619:13thhellernothing werid about it. pretty much every npm package has some form of build step#2018-08-2619:14urbanslug@hlolli btw I deleted my lock files and when I yarn installed then it installed the git repo#2018-08-2619:14hlolli@thheller was there a way to have the test runner say how many tests it ran? I'm running node-test, and I only see if I get failures.#2018-08-2619:14urbanslugbut let me prepublish and push#2018-08-2619:14urbanslugto mae sure it works, getting installed was only one step#2018-08-2619:15hlolliyup, I'd do that if you want to install it from git...#2018-08-2619:15thheller@hlolli it should print the summary?
Ran 2 tests containing 6 assertions.
0 failures, 0 errors.
#2018-08-2619:16hlolliyes, I am looking for exactly this#2018-08-2619:17hlolliI have target :node-test, and start the test just with shadow-cljs compile buildID, I just get a Build completed in the end.#2018-08-2619:18thhellerbecause compile only compiles the test and does not run them? unless you set :autorun true#2018-08-2619:18hlolliit runs them, at least I get test failed, when I write a failing test#2018-08-2619:18hlollihaha yes#2018-08-2619:18hlolliok I did that#2018-08-2619:19hlolliI should use release instead of compile?#2018-08-2622:10richiardiandreaI use release and on completion launch node out-dir/tests.js in CI so that I can get the right exit code#2018-08-2622:19hlollithanks @U0C8489U6 the problem was mainly that run-tests wasn't called. But I just used use-fixtures, like I've always done, those (few) times I take the time to write tests.#2018-08-2622:19hlolliI'm a bad bad example of programmer in terms of lack of tests 🙂#2018-08-2623:13hlolliif I may ask, how do you trigger it on completion, with hooks?#2018-08-2623:14hlollior just "script" "npx shadow-cljs release x && node out/test.js", that should do the trick..#2018-08-2623:45richiardiandreaYep exactly the above @hlolli #2018-08-2623:49hlolli@U0C8489U6 a newb question, can you run shadow-cljs on circleci?#2018-08-2623:50richiardiandreaUhm, at the moment I am not on Circle CI, can't you?#2018-08-2623:53hlolliI'm looking at docker images, there's one for shadow-cljs, but I'm not sure if you must run their official docker images, or I can choose from docker-hub one.#2018-08-2623:53hlolliI can just try :=)#2018-08-2700:06hlolliworks fine to pull any image from dockerhub, so, nice#2018-08-2700:21richiardiandreaYes you can pull anything, you basically just need an image with jdk8 and then your package.json pulls in the rest#2018-08-2619:19urbanslugIs it also normal for the output of the publishing to be gitignored? https://github.com/palerdot/react-d3-speedometer/blob/master/.gitignore#L4#2018-08-2619:19thheller@urbanslug yes normal. you never put compiled code into git#2018-08-2619:20urbanslugI guess I should prepublish after npm install then?#2018-08-2619:20urbanslughmmm#2018-08-2619:20urbanslugno#2018-08-2619:20hlollino that's a bad idea#2018-08-2619:21urbanslugbut then say I npm install it from git it won't have the dist dir#2018-08-2619:21thheller@urbanslug what are you trying to do exactly? I can't really identify what problem you are actually trying to solve#2018-08-2619:21thhellerthe git dep is not from you I assume? why are you using the git version?#2018-08-2619:22urbanslugthe git dep is from me#2018-08-2619:22urbanslugI want to use a fork of the project#2018-08-2619:23urbanslugand I don't want to publish the fork to npm#2018-08-2619:23urbanslughttps://github.com/urbanslug/react-d3-speedometer#2018-08-2619:24thhellerthen you'll need to switch to the directory manually and run the ./scripts/prepublish.sh#2018-08-2619:24urbanslugyeah I thought so, after npm installing it from git, right?#2018-08-2619:25thhelleryes#2018-08-2619:25urbanslugI held back because of > no that's a bad idea#2018-08-2619:25hlolliyes, I tried makeing a release with nested node module recently. And it's paiin#2018-08-2619:25thhellerwell you'll probably also need to manually install all the tools required to run the prepublish.sh script#2018-08-2619:25urbanslugbabel#2018-08-2619:25hlolliI'd rather use git submodule, and there npm i etc#2018-08-2619:26hlollibut I may be wrong#2018-08-2619:26urbanslugthe submodule would have the compilation output though, right?#2018-08-2619:26urbanslugwell I don't think you're wrong about it being a pain#2018-08-2619:26hlolliyou can try, as well you could try useing "scripts" {"install" and run it there. Maybe it can work.#2018-08-2619:27urbanslugusing scripts install?#2018-08-2619:27hlollito clarify what I'm saying, you can look at npm hooks. When you install a module, a module can run script.#2018-08-2619:28hlollithe pain I mention, could arise from npm peer dependencis. You could get some module missing errors. But doesn't have to be.#2018-08-2720:31ghidena question running some clj code https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-08-2720:31ghidendoes the code need to be in the source-paths?#2018-08-2720:31thhelleryes. always.#2018-08-2720:39ghidenthanks#2018-08-2722:54richiardiandrea@thheller is there some source for https://www.npmjs.com/package/create-cljs-project? where?#2018-08-2722:55richiardiandreaoh found 😄#2018-08-2722:55richiardiandreahttps://github.com/thheller/shadow-cljs/tree/master/packages#2018-08-2722:56richiardiandreaa bit of magic there, I cannot find dist/script.js#2018-08-2722:56richiardiandreaoh found that too 😄#2018-08-2722:57thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/create.cljs#2018-08-2722:58thheller@richiardiandrea ^#2018-08-2722:58richiardiandreacool awesome 😉#2018-08-2722:58richiardiandreayou really are a Lisp dev 😄 rolling your own 😉#2018-08-2722:59thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L39-L44#2018-08-2722:59richiardiandreacool i like it thank you!#2018-08-2722:59thhellerroll my own?#2018-08-2723:00richiardiandreaI mean without using neither yaoman nor lein templates#2018-08-2723:00richiardiandrea😄#2018-08-2723:00thhellerbecause it doesn't do any templating yet 😉#2018-08-2723:00richiardiandreait should be made a library so that we have a JS package tool from .edn I actually like it better than the lein one#2018-08-2723:01richiardiandreariiiight, I see#2018-08-2723:15ghidenproxy-url has proxy-port? or i can just specify "http://localhsot:8181" as proxy-url?#2018-08-2723:16thhelleryes url with port#2018-08-2723:17ghiden👍#2018-08-2723:20richiardiandreawould it be a good idea to add a parameter to set the :nrepl port from the command line?#2018-08-2723:20richiardiandreaI feel that info should not be part of the shadow-cljs.edn#2018-08-2723:21thhellerwell it should really really really just be read from .shadow-cljs/nrepl.port#2018-08-2723:22thhellerbut I guess it could be a CLI option too. CLI is due a rewrite anyways#2018-08-2807:11gravCan't get deps.edn and Reagent working together. I end up getting The required namespace "react" is not available, it was required by "reagent/core.cljs".#2018-08-2807:11gravI have :deps true in my shadow-cljs.edn, and :deps {reagent {:mvn/version "0.8.1"}} in my deps.edn#2018-08-2807:39thheller@grav deps.edn doesn't cover installing npm deps at all. npm install react react-dom create-react-class is required manually since reagent doesn't declare those :npm-deps.#2018-08-2808:16gravah, of course#2018-08-2808:29thhellerhttps://github.com/thheller/shadow-cljs/issues/382 I'll try to find a way to make this smarter#2018-08-2808:55hlolliwas there ever a discussion about having tools-deps support installing npm packages?#2018-08-2808:58thhellerno idea. the odds of that happening are probably near zero though.#2018-08-2808:59thhellerjust the nature of npm deps is so anti-clojure best practice its not even funny#2018-08-2809:00thhellerversion ranges as the default, running globally vurnable things on install,postinstall,etc#2018-08-2809:02hlolliyes, so just have yarn or npm do all the work of resolveing the dependencies. Just have 1 file to assemble all the deps needed to build a project. :npm/yarn or :npm/npm to specify the resolver.#2018-08-2809:03thhellerbut whats the point of that? package.json and npm install already cover that#2018-08-2809:03thhelleryarn also uses the same npm registry so it doesn't really make sense to differentiate between yarn and npm in the dep location#2018-08-2809:04hlollithe only point is simplification. Especially if the package.json is stored in a .jar file. Just manual labour.#2018-08-2809:05thhellerbut it isn't simpler#2018-08-2809:05hlolliand why would it then make a difference if the user makes a package.json or deps.edn stores it, same end result#2018-08-2809:05thhellerbut how do you resolve conflicts?#2018-08-2809:05thhellerlib A depends on react v16, lib B depends on react v15#2018-08-2809:05thhellerwhich one do you pass to npm install?#2018-08-2809:06thhellerits annoying as it is with deps.cljs and :npm-deps#2018-08-2809:06hlolliyou pass the entry point to npm install and lib A and lib B to nested dependencies and npm resolves it like it would#2018-08-2809:07thhellerclojure lib A and B#2018-08-2809:07thhellernot npm lib A and B#2018-08-2809:08thhellerits probably all solvable but IMHO it should just be left with npm.#2018-08-2809:08thhellerI also personally have no interest in deps.edn#2018-08-2809:08hlolliyes, my whole point is to leave it to npm, if deps.edn declares a npm dependencies, then npm should treat the npm dependencies like it was a module.#2018-08-2809:09thhellerI guess I don't understand what you are saying then. npm doesn't know about deps.edn#2018-08-2809:10hlollithat's right, there could be a mechanism to export package.json and then require it.#2018-08-2809:10thhellerI'm saying CLJ lib A declared :deps {"react" {:npm/version "v16"}} and lib B declares :deps {"react" {:npm/version "v15"}}#2018-08-2809:10thhellerwhich one do you pass to npm#2018-08-2809:10thhelleryou can't pass both#2018-08-2809:10thhellerresolving npm version ranges is a nightmare#2018-08-2809:11hlolliyou pass libA and libB to npm. Then you have conflict like you'd always have in this situation.#2018-08-2809:11thhellerwhat do you mean by pass libA and libB to npm#2018-08-2809:11thhellerhow?#2018-08-2809:13hlollinode_modules/libA/package.json["react" "v16"] node_modules/libB/package.json["react" "v15"] entry ./package.json {"dependencies":{"libA" "...", "libB": ".."}#2018-08-2809:14hlollithat root package.json doen't really have to exist, could be a stream#2018-08-2809:14hlollidon't know, just throwing ideas#2018-08-2809:14thhellernode_modules/libA doesn't exist though?#2018-08-2809:14thhellerits maven package?#2018-08-2809:17hlolliyes, so it would exist in ~/.m2, tools.deps, could theoretically, read the deps.edn from the maven resources, and spit package.json, or somehow resolve it, and run npm install from the directory it was called from to generate node_modules#2018-08-2809:17hlolliwhen and only npm modules are a dependency of an application, which are these days, most clojurescript apps.#2018-08-2809:21hlollibut yes, if all the maven deps are themselves a module, they may resolve conflicts, but they are themselves a module but not their dependencies. So it doesn't make sense what I said, in the sense that we want the dependencies to be first class, and then it surely can conflict.#2018-08-2809:26hlolliwhat goes against always choosing the higher version?#2018-08-2809:29thhellerits not how npm works, due to their use of version ranges everywhere#2018-08-2809:30thheller^16.0.0 doesn't match ^15.0.0#2018-08-2809:30thhellerbut don't take my work for any of this. I'm not qualified to commend on any deps.edn issues. ask in #tools-deps what their plans are#2018-08-2809:33hlolliunrelated, I worry about react17; componentWillReceiveProps and componentWillUpdate are going to get deprecated and renamed with UNSAFE_ prefix. React libraries are going to get "doesn't work on my computer" storm soon.#2018-08-2809:36thhelleryep. fun times ahead.#2018-08-2813:34biscuitpants#2018-08-2813:34biscuitpantshas anyone seen this error with datascript and shadow-cljs before?#2018-08-2813:59biscuitpantsseems to have gone after a rebuild#2018-08-2814:36biscuitpantswhat do “js/my-fn is shadowed by a local” errors point to?#2018-08-2814:37thheller(let [my-fn ...] (js/my-fn ...))?#2018-08-2814:38biscuitpants#2018-08-2814:39biscuitpantsnavigate-fn in this case is: js/history.replaceState or js/history.pushState#2018-08-2814:41thhelleris there a (def history ..)?#2018-08-2814:42biscuitpantsno#2018-08-2814:51biscuitpantsinteresting
#2018-08-2814:51biscuitpantsremoving:
(and (relative? url)
            (exists? navigate-fn))
#2018-08-2814:51biscuitpantsfixes it#2018-08-2814:51biscuitpantsand its down to the (exists? ...) call#2018-08-2814:52biscuitpantsusing (some? ...) works#2018-08-2814:52thhellerah right. exists? only works for globals#2018-08-2814:52biscuitpantsoh really?#2018-08-2814:52thhellerif (some? navigate-fn)#2018-08-2814:53biscuitpantswould js/history not be a global though?#2018-08-2814:53biscuitpantsi guess it cannot see that at compile time#2018-08-2814:53thhellerexists? is basically only for global constants yes#2018-08-2814:53biscuitpantsgood to know#2018-08-2814:54urbanslugWhen using shadow-cljs with deps.edn say I have one build :app and I have two aliases :dev and :production in my deps.edn#2018-08-2814:54biscuitpantsis this not enforced in other compilers?#2018-08-2814:54urbanslugIn both cases I want to run the build called app#2018-08-2814:54urbanslugIs there a way to tell the build when to use which deps.edn alias?#2018-08-2814:56urbanslugeven if I were to break the build :app into two (dev and prod) specifying the alias seems to take place outside the :builds value; on the same level actually.#2018-08-2814:56urbanslugI could share the code if it'll help#2018-08-2814:57thheller@urbanslug that is not possible, a build cannot be tied to an alias#2018-08-2814:57urbanslugwell in this case re-frame tracing says to use different deps for prod and dev#2018-08-2814:57thhellershadow-cljs -A:production release app#2018-08-2814:57urbanslughmmm#2018-08-2814:57thhelleryou can do that though#2018-08-2814:58urbanslugand it'll download all other deps plus the one in production, right?#2018-08-2814:58urbanslugOn it#2018-08-2814:59urbanslugyuuuppppppp#2018-08-2814:59urbanslugseems to work#2018-08-2814:59urbanslug🙂#2018-08-2814:59urbanslugran into an error but hmm probably unrelated#2018-08-2814:59urbanslugworked ok with just shadow.cljs#2018-08-2815:01urbanslug
{:deps
 {reagent                     {:mvn/version "0.8.0"}
  re-frame                    {:mvn/version "0.10.5"}
  day8.re-frame/http-fx       {:mvn/version "0.1.6"}
  secretary                   {:mvn/version "1.2.3"}
  com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
  proto-repl                  {:mvn/version  "0.3.1"}
  devcards                    {:mvn/version "0.2.5"}
  binaryage/devtools          {:mvn/version  "0.9.10"}
  day8.re-frame/re-frame-10x  {:mvn/version "0.3.3-react16"}}
 :aliases
 {:dev
  {:extra-deps
   {day8.re-frame/tracing-stubs {:mvn/version "0.5.1"}}}
  :prod
  {:extra-deps
   {day8.re-frame/tracing {:mvn/version  "0.5.1"}}}}}
#2018-08-2815:01urbanslugError building classpath. Could not transfer artifact thheller:shadow-cljs:jar:2.6.3 from/to clojars (): Range Not Satisfiable (416)#2018-08-2815:02urbanslugthe jar doesn't exist#2018-08-2815:02urbanslugit's an npm module#2018-08-2815:02thhellerno idea. its probably clj printing that#2018-08-2815:03thhellerno its a jar#2018-08-2815:03thhelleryou have the aliases switched btw#2018-08-2815:03thhellerprod should include the stubs not the other way#2018-08-2815:04thhellernone of that is relevant#2018-08-2815:04urbanslugOk I should use gists#2018-08-2815:04thhellerjust run clj#2018-08-2815:04urbanslugsorry#2018-08-2815:04thhellerit should throw the same error on startup#2018-08-2815:04urbanslugI thought it was my shadow-cljs.edn#2018-08-2815:04thhellerno its not#2018-08-2815:05thhellerah nvm it won't print the error on startup because the dep is injected dynamically#2018-08-2815:05thhellerjust add thheller/shadow-cljs {:mvn/version "2.6.3"} to your :deps#2018-08-2815:05thhellerthen run clj#2018-08-2815:06thhellerthese -stubs packages are starting to bug me ... I really dislike the entire concept#2018-08-2815:07urbanslugok#2018-08-2815:07urbanslughttps://gist.github.com/urbanslug/181f52e80737a7e446fbfb8d908db48a#2018-08-2815:07thheller^ its not relevant#2018-08-2815:07urbanslugI thought I could be messing up in the shadow-cljs.edn#2018-08-2815:08thhelleryou are but that doesn't matter#2018-08-2815:08thhellerit doesn't even get that far#2018-08-2815:08urbanslugbut it's not on clojars > just add thheller/shadow-cljs {:mvn/version "2.6.3"} to your :deps#2018-08-2815:09thhellerof course it is#2018-08-2815:09thhellerhttps://clojars.org/thheller/shadow-cljs#2018-08-2815:09urbanslugheh#2018-08-2815:10urbanslugassumptions#2018-08-2815:10urbanslugclj is downloading deps now#2018-08-2815:11urbanslugsuccessfully done#2018-08-2815:12thhellerdid you cheat and use 2.6.4?#2018-08-2815:12urbanslugSame error on shadow-cljs -A:dev watch app;#2018-08-2815:13urbanslugnaah I used 2.6.3#2018-08-2815:13urbanslugclj ran successfully#2018-08-2815:14urbanslugtrying with 2.6.4 same error about being unable to transfer 2.6.3#2018-08-2815:15thhellerok show me you deps.edn please#2018-08-2815:16urbanslughttps://gist.github.com/urbanslug/268f2d2452d24742bf2cff5963548d9b#2018-08-2815:16thhellerrun clj -A:dev -m shadow.cljs.devtools.cli watch app please#2018-08-2815:17urbanslugException in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class or shadow/cljs/devtools/cli.clj on classpath.#2018-08-2815:18urbanslugno init?#2018-08-2815:18thhelleris that actually your deps.edn?#2018-08-2815:18urbanslugYup I could push my changes and you pull and clone to test#2018-08-2815:18urbanslugCould be something in my env that's messed up#2018-08-2815:19thhellerI mean is it saved on disk and you are in that actual directory?#2018-08-2815:19thhellerthe error above suggests that shadow-cljs is not actually on the classpath#2018-08-2815:20urbanslugyup, well shadow-cljs is installed in the node modules via npm not for my user but I did run clj after adding it to deps.edn so it should be#2018-08-2815:20thhellerdon't confuse node_modules with that is happening#2018-08-2815:20urbanslugOk what is happening is that it's not in .m2#2018-08-2815:20urbanslug?#2018-08-2815:21thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_high_level_overview#2018-08-2815:22thhellertwo parts. the npm package is completely independent from all the clojure stuff#2018-08-2815:22thhellerthe clojars package is the one we are interested in at the moment#2018-08-2815:22urbanslughttps://gitlab.com/urbanslug/sniff#2018-08-2815:23urbanslugshadow-cljs is def not in my ~/.m2/repositories#2018-08-2815:23urbanslugI'll remove it and start over#2018-08-2815:24thhellerit would be in .m2/repository/thheller/shadow-cljs#2018-08-2815:25urbanslugdarnit I already deleted my .m2 but I can see a thheller dir was there#2018-08-2815:25thhellerwhat the actual ...#2018-08-2815:25thhellerI get the same error#2018-08-2815:27thhellerhahaha#2018-08-2815:27thhellergod dammit#2018-08-2815:27urbanslugWhat's up?#2018-08-2815:27thhelleruse parinfer or something 😛#2018-08-2815:27thheller
day8.re-frame/re-frame-10x  {:mvn/version "0.3.3-react16"}}
  thheller/shadow-cljs        {:mvn/version "2.6.3"}
#2018-08-2815:28thhellernote the misplaced closing }#2018-08-2815:28urbanslugdarnit#2018-08-2815:28thhellershould be
day8.re-frame/re-frame-10x  {:mvn/version "0.3.3-react16"}
  thheller/shadow-cljs        {:mvn/version "2.6.3"}}
#2018-08-2815:28urbanslugYa I added it outside the deps#2018-08-2815:30urbanslugI use emacs with paredit#2018-08-2815:30urbanslugI should've seen the differently colored parens#2018-08-2815:31thhellerhmm and it didn't complain about that?#2018-08-2815:31urbanslugnaah clj ran just fine#2018-08-2815:31thhellerCursive paredit would change the indent so it would be more obvious#2018-08-2815:34urbanslugweird how $ clj and $ clojure failed after removing my ~/.m2 I thought they called the clojure bin in my /usr/bin/clojure I'm waiting for my yarn dev to finish now. It should work.#2018-08-2815:35thhellerprobably clj -Sforce since you deleted files that it that would exist#2018-08-2815:36urbanslugwooo! success!!!!#2018-08-2815:36kwladykaWhat are best practice for :output-dir, :output-to, :test-dir for :target: :browser :node-test browser-test. I mean i see paths like public/js, resources/public/js, resources/public/js/out and I am trying to solve the puzzle why so many paths. Should best practice be to use path in resources or not etc. Maybe not super important but I am trying to do some guideline.#2018-08-2815:37thhellerI personally never use resources but many people do#2018-08-2815:37thhellerits really up to you#2018-08-2815:38kwladykaAny pros / cons?#2018-08-2815:38kwladykaFor example if somebody have also server things in project?#2018-08-2815:38thhellerits just a directory. the reason is that many people want to package their .js files into uberjars. that is easier with resources/public#2018-08-2815:40thhellerdepending on the server you run you can either serve a "resource" which means something that is on the classpath and the resources directory typically is in lein#2018-08-2815:40thhelleror you can serve "files" from an actual directory#2018-08-2815:41kwladykathe reason to pack .js to uberjars are? make a module? other benefits?#2018-08-2815:41thhellerdeploy one single file#2018-08-2815:42thhellerthe uberjar will contain everything and serve resources#2018-08-2815:42kwladykaoh yes, if somebody not use docker it make sense#2018-08-2815:42thhellerI don't do that since it also requires restarting your clojure server to update .js files#2018-08-2815:42thhellerwhich just seems like a waste#2018-08-2815:42kwladykaso why you never use resources?#2018-08-2815:43thhellerI have an uberjar for my server but that server is configured to serve the public directory via files#2018-08-2815:43thhellerso I can swap the files at any time without restarting the server#2018-08-2815:44kwladykaso you don’t use resources path to avoid confusion (what I understand)#2018-08-2815:44thhellermore about keeping the uberjar clean#2018-08-2815:45thhellerand not putting anything in there that doesn't have to be#2018-08-2815:45kwladykaok thx#2018-08-2815:45thhellerI do way more frequent releases of my frontend JS than the backend server#2018-08-2815:45kwladykaso you put all tests to /out/… and app to /public?#2018-08-2815:46thhellerrestarting the backend server every time the frontend changes sucks#2018-08-2815:46thhellerdepends on the project#2018-08-2815:46thhellerone project has multiple virtual hosts#2018-08-2815:47thhellerso I output to vhosts/alias.foo.com/public vhosts/other.foo.com/public#2018-08-2815:47thhellerand so on#2018-08-2815:48thhellerits really up to you and your project#2018-08-2815:48urbanslugIf you serve the frontend via reverse proxy (nginx) you don't have to restart the backend#2018-08-2815:48thheller@urbanslug of course you do. if you only serve resources.#2018-08-2815:48urbanslughmmm why? the frontend is just making ajax requests to your backend#2018-08-2815:49thheller... ok I guess you are serving the resources/public directory via nginx?#2018-08-2815:49urbanslugyes 🙂#2018-08-2815:49thhellerthats cheating and not using the uberjar. in that case it would actually be waste to have the .js in the uberjar at all#2018-08-2815:50thhellerthus using resources at all being "bad"#2018-08-2815:50urbanslugCI tool builds that dir and copies it to a dir on your server#2018-08-2815:50urbanslugOh I don't use an uberjar should probably read about it and see why I'd want to#2018-08-2815:51thhellerits fine not to do it#2018-08-2815:51urbanslugWhy do you do it?#2018-08-2815:51kwladykaAfter change to: :output-dir "public/js" But it is running. Also I restarted server and watch app#2018-08-2815:51thhellerbut your statement was just incorrect in the discussion we were having#2018-08-2815:52urbanslugAh I see#2018-08-2815:53thheller@kwladyka are you including the correct .js file in the .html?#2018-08-2815:55kwladykathx#2018-08-2815:56kwladykaok it is time to take a break 🙂#2018-08-2817:01urbanslugI've noticed that tests (karma) don't work when I'm using deps.edn such as in https://gitlab.com/urbanslug/sniff#2018-08-2817:01urbanslugis that expected?
$  CHROME_BIN=/usr/bin/chromium y test                                                                                                                                                              
yarn run v1.9.2
$ karma start --single-run
28 08 2018 20:01:16.832:INFO [karma]: Karma v3.0.0 server started at 
28 08 2018 20:01:16.834:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
28 08 2018 20:01:16.839:INFO [launcher]: Starting browser ChromeHeadless
28 08 2018 20:01:17.119:INFO [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Connected on socket VQ5gfyizvjWfbb8bAAAA with id 10361789
HeadlessChrome 0.0.0 (Linux 0.0.0): Executed 0 of 0 ERROR (0.003 secs / 0 secs)
error Command failed with exit code 1.
info Visit  for documentation about this command.
#2018-08-2817:03thhellerdid you compile properly? does the target/test.js exist?#2018-08-2817:03thhellerI just see you running karma (which I know very little of)#2018-08-2817:04urbanslugLet me try again but yeah I've cleaned abd compiled#2018-08-2817:04urbanslug
$ y compile-tests                                                                                                                                                                                  
#2018-08-2817:05urbanslugbut when I use shadow-cljs.edn the tests work#2018-08-2817:06thhellerwhat does that mean? the command you just pasted used deps.edn?#2018-08-2817:07urbanslugwhen my shadow.cljs file looks like so:
:dependencies [[cljs-ajax "0.7.3"]
                [reagent "0.8.0"]
                [re-frame "0.10.5"]
                [day8.re-frame/http-fx "0.1.6"]
                [secretary "1.2.3"]
                [com.andrewmcveigh/cljs-time "0.5.2"]
                [proto-repl "0.3.1"]
                [devcards "0.2.5"]
                [binaryage/devtools "0.9.10"]
                [day8.re-frame/re-frame-10x "0.3.3-react16"]
                [day8.re-frame/tracing "0.5.1"]
                ;[day8.re-frame/tracing-stubs "0.5.1"]
                ]


 ;:deps         true
#2018-08-2817:07urbanslugwhen https://gitlab.com/urbanslug/sniff/blob/master/shadow-cljs.edn is edited#2018-08-2817:10thhellerwhat am I even looking at? what is it supposed to say? I do not know or use karma. what is the issue here?#2018-08-2817:12thhelleryou are saying the when :deps true and running shadow-cljs -A:dev compile test the tests somehow behave differently?#2018-08-2817:14urbanslugyes > you are saying the when :deps true and running shadow-cljs -A:dev compile test the tests somehow behave differently?#2018-08-2817:15urbanslugI didn't have the -A:dev in compile test earlier but it doesn't seem to have made a difference.#2018-08-2817:16urbanslugA successful test run
CHROME_BIN=/usr/bin/chromium y test                                                                                                                                                             
#2018-08-2817:16thhelleruhm aren't namespaces missing without the alias?#2018-08-2817:17thhellercompilation probably didn't finish? so there were no tests to run?#2018-08-2817:17urbanslugSorry#2018-08-2817:17urbanslug
CHROME_BIN=/usr/bin/chromium y test                                                                                                                                                             
#2018-08-2817:17urbanslugfailed test run#2018-08-2817:17thhellerI'm much more interested in the shadow-cljs output. karma doesn't tell me anything.#2018-08-2817:17thhellerwhat did you run before karma?#2018-08-2817:18urbanslug
$ y compile-tests                                                                                                                                                                                 
#2018-08-2817:20thhellerah ...#2018-08-2817:20thhelleryour deps.edn doesn't declare any :paths ["src"]#2018-08-2817:20thhellerso it doesn't find your source files and has no tests to run?#2018-08-2817:22urbanslugOk now reading https://clojure.org/reference/deps_and_cli#_paths#2018-08-2817:23urbanslugI didn't know that I needed it#2018-08-2817:23urbanslugworks now for sure#2018-08-2817:23thhellergood to know. I can probably add a warning if no source files are found#2018-08-2817:24thhellerdid you not try to compile your other builds? they should have failed too?#2018-08-2817:24urbanslugI didn't try to compile them, no.#2018-08-2817:25thheller
:source-paths ["src" "test"]

 :deps         true
#2018-08-2817:25thhellerthe :source-paths in shadow-cljs.edn are not used when :deps true is used#2018-08-2817:25thhellerso you need to move them to :paths in deps.edn instead#2018-08-2817:28urbanslughmm I guessed that it had to do with the source paths but the dev server was working with the source paths in shadow-cljs.edn so I couldn't have guessed it#2018-08-2817:33thhellerI think you are still a little confused how the things fit together#2018-08-2817:34thhellershadow-cljs the npm package is just about starting a JVM with the proper JVM dependencies loaded#2018-08-2817:34thhellerit can either to this via lein, clojure or its built-in launcher#2018-08-2817:35thhellerunfortunately its pretty tough to check what you actually do in deps.edn so its rather hard to debug#2018-08-2817:38thhellerbut thanks for digging through it#2018-08-2817:38urbanslugI see > shadow-cljs the npm package is just about starting a JVM with the proper JVM dependencies loaded#2018-08-2817:38thhellerI can now add a bunch of steps to my checklist for future reference 😉#2018-08-2817:38urbanslugidk what quality of examples you require but I'm offering that one there. If I had it at the start it would've made my life a lot easier.#2018-08-2817:39urbanslugbecause the clojurescript compiler (by clojure) to compile cljs#2018-08-2817:40urbanslugso basically what you're starting are web sockets to update the UI and listening for file changes#2018-08-2817:40urbanslugbut you're also doing really neat stuff with npm#2018-08-2817:40urbanslugidk how#2018-08-2817:41thhellerall in clojure#2018-08-2817:42thhellerthe npm package itself is really just for starting. it does not else.#2018-08-2817:43urbanslugI'm talking about getting packages from npm and not clojars#2018-08-2817:43urbanslugas was (maybe still is) with lein#2018-08-2817:43thhellerI don't get any packages from npm, you do via npm install#2018-08-2817:44urbanslugso you just check the node modules#2018-08-2817:44urbanslugand...#2018-08-2817:44thhelleryes I resolve all the files that your build needs and package them together so you can load them in your page#2018-08-2817:45thheller+ some fancy compiler tricks#2018-08-2817:46urbanslugwhat about the refers? How say... I require a default export#2018-08-2817:47urbanslugBecause it's really easy here. I can have a person work in react and the default export just works#2018-08-2817:47urbanslugnot so with the other tools from what I've seen in the other channels#2018-08-2817:47urbanslugAnywho I have too many questions 🙂#2018-08-2817:48thhellerthose would be the fancy compiler tricks I guess. I made a few modifications since I wanted to use that myself. other CLJS tools can't do that yet no.#2018-08-2818:08hlolliAny chance to lift this restriction? At least outside of project, I'm locally debugging a lib via npm link <libname>, I could theoretically copy over the files, but perhaps lift it, if the file was seen to be a symlink, otherwise keep the same behaviour. https://github.com/thheller/shadow-cljs/blob/016c0c87241ba8bb3a5d753774c052c8661ac8ba/src/main/shadow/build/npm.clj#L431-L433#2018-08-2818:11thhellerhmm#2018-08-2818:13thhellerits actually a different issue I think. it just shouldn't use the canonical file at all#2018-08-2818:14hlollithis is a browser compilation, for node-library this doesn't happen.#2018-08-2818:15thhelleryeah. java has two ways of resolving file paths#2018-08-2818:16thhellerI'm just using the wrong one#2018-08-2818:16hlolliah gotcha#2018-08-2818:16thheller> A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent. This method first converts this pathname to absolute form if necessary, as if by invoking the getAbsolutePath() method, and then maps it to its unique form in a system-dependent way. This typically involves removing redundant names such as "." and ".." from the pathname, resolving symbolic links (on UNIX platforms), and converting drive letters to a standard case (on Microsoft Windows platforms).#2018-08-2818:17thhellerI'm using it remove the .. and other relative path crap npm packages do#2018-08-2818:17thhellerbut it shouldn't replace the links#2018-08-2818:18hlolliin the quote you posted it says it does 🙂 (if you mean symlink by link)#2018-08-2818:19thhelleryes I know. I mean that I want to to replace .. and stuff but NOT follow links#2018-08-2818:19thhellercurrently it does#2018-08-2818:19thhellerneed to figure out if there is a way to make it not do that but still replace ..#2018-08-2818:20hlolliwithout knowing it, maybe the java8 file class offers something.#2018-08-2818:22thhellerthe quote I just posted is from java.io.File/getCanoncialPath 😉#2018-08-2818:22hlollijava.nio.file.Path
Path resolve(Path other)
Resolve the given path against this path.
If the other parameter is an absolute path then this method trivially returns other. If other is an empty path then this method trivially returns this path. Otherwise this method considers this path to be a directory and resolves the given path against this path. In the simplest case, the given path does not have a root component, in which case this method joins the given path to this path and returns a resulting path that ends with the given path. Where the given path has a root component then resolution is highly implementation dependent and therefore unspecified.
#2018-08-2818:22thhellernah Path/normalize it is#2018-08-2818:25hlolliah resolve is of course just like in node.fs, watched an example of stackoverflow before reading the docs, I never posted that 🙂#2018-08-2818:26thhelleryeah just want to get rid of the dots#2018-08-2818:32thhellersometimes I wish I was using Path for everything. File really isn't all that great anymore.#2018-08-2818:33thhellerbut some parts of the Path API are just annoying so meh 😛#2018-08-2819:19kwladykaWhy [2018-08-28 21:14:35.480 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/eth-lib/lib/bytes.js", :requires [{:line 9, :column 193}]}? Is it a bug in web3js or I am doing something wrong? I think it is connected with "web3": "^1.0.0-beta.35".#2018-08-2820:15thhellerlook at the file location#2018-08-2820:15thhellerI can't tell you whats happening there#2018-08-2820:15thhellerit probably doesn't matter though since those often are conditional requires#2018-08-2914:58kwladyka
(:require [clj-macros :refer [slurp]]
            ["web3" :as web3])
cause The required namespace "clj-macros" is not available While I have this file /src/clj_macros.clj which is (ns clj-macros … ) Why?
#2018-08-2915:10kwladykaOh I shoule use :require-macros instead#2018-08-2915:10kwladykaI found your example https://github.com/shadow-cljs/examples/blob/master/macros/src/app/lib.cljs#2018-08-2920:17flyboarder@thheller Im getting weird errors using 2.6.4#2018-08-2920:17flyboarder
SHADOW import error /Users/matt/Projects/cannabit/cannabit-pharma/app/cljs-runtime/app.server.js

/Users/matt/Projects/cannabit/cannabit-pharma/app/cljs-runtime/goog.object.object.js:427
  if (obj !== null && key in obj) {
                          ^
TypeError: Cannot use 'in' operator to search for 'path' in undefined
#2018-08-2920:18flyboardercompiled without errors#2018-08-2920:44pvillegas12I’m trying to use materialize css in a clojurescript app with shadow-cljs, I’ve already added the dependency, but I’m missing a step to actually use it in the dom#2018-08-2920:47thheller@flyboarder did this work in previous versions? that looks to me like node is complaining about something?#2018-08-2920:48thheller@pvillegas12 shadow-cljs has no support for compiling any css. so whatever you need to do you need to do it manually#2018-08-2920:51pvillegas12@thheller you mean adding a style tag directly to the index.html? Where in the file system do npm dependencies store the css?#2018-08-2920:53thhellerI don't know. that depends on the npm library#2018-08-2920:55pvillegas12materialize css, but I guess the question is more general, in a clojurescript app after getting an npm dependency how do I include the js/css?#2018-08-2920:55thhellerJS https://shadow-cljs.github.io/docs/UsersGuide.html#npm#2018-08-2920:55thhellerCSS you are on your own. I have plans for supporting CSS but nothing usable yet.#2018-08-2921:23flyboarder@thheller yeah it all worked previously#2018-08-2921:24flyboarder@thheller shadow-cljs check returns warnings about cljs 1.10#2018-08-2921:25thhellerso if you downgrade to 2.6.3 it works?#2018-08-2921:25thhelleryou are not giving me much information so I can't really help#2018-08-2921:30flyboarder@thheller im not sure what the previous version was, I had used npm#2018-08-2921:41flyboarderI’m digging more….#2018-08-2921:50thheller> shadow-cljs check returns warnings about cljs 1.10#2018-08-2921:51thhellerwhat does this even mean?#2018-08-2921:51thhellermaybe I can figure something out if you show me some errors but right now I'm just clueless#2018-08-2921:59flyboarder@thheller sorry, here is a couple examples#2018-08-2922:00flyboarder#2018-08-2922:04flyboarder@thheller I also see a bunch of these:
------ WARNING #33 -------------------------------------------------------------
 File: ~/.m2/repository/degree9/featherscript/0.4.0-SNAPSHOT/featherscript-0.4.0-SNAPSHOT.jar!/feathers/channels.cljs:8:7
 Property on never defined on app
--------------------------------------------------------------------------------
#2018-08-2922:04flyboarderIn this case app is a symbol for a runtime object#2018-08-2922:09flyboarderActually I think all the errors involve runtime objects#2018-08-2922:12thhellerodd#2018-08-2922:16flyboarder@thheller for the last error above#2018-08-2922:16flyboarder
(defn connection [app listener]
  (.on app "connection" listener))
#2018-08-2922:16flyboarder^ how should I fix this?#2018-08-2922:16thhellerwhat is app?#2018-08-2922:16flyboarderexpress server#2018-08-2922:16flyboarderwell feathersJS server#2018-08-2922:16thhellerthen (defn connection [^js app listener] ...)#2018-08-2922:17flyboarderah ok#2018-08-2922:17thhellerhmm I get the check warnings in cljs.core as well. maybe the recent closure update changed something#2018-08-2922:19thhellerbtw are you using lein/deps? do you have :infer-externs turned on?#2018-08-2922:21flyboarderI am using boot and npm#2018-08-2922:21flyboarderI thought infer-externs was for release builds?#2018-08-2922:21thhellercheck is also for release builds#2018-08-2922:21flyboarderI have been testing with shadow-cljs compile server which compiles without issues#2018-08-2922:22thhellerwhat was the problem again?#2018-08-2922:22flyboardererrors on runtime#2018-08-2922:23thhellerand you are sure that you are calling things correctly? I mean you didn't make a change and pass an undefined value somewhere?#2018-08-2922:23flyboarderno everything was working 2 weeks ago when I last compiled the project#2018-08-2922:23thhellerso the absolutely only change you did since then is updating only shadow-cljs?#2018-08-2922:24thhellerthe error looks like you are passing something undefined to goog.object/set#2018-08-2922:26thhellerwhat is the full stacktrace of the error?#2018-08-2922:26flyboarder#2018-08-2922:27flyboarder
(defn authentication [^js app]
  (let [conf (obj/get app "auth")
        path (obj/get conf "path")
        app (auth/configure app conf)]
    (auth/service app path)))
#2018-08-2922:27flyboarder^this is the authentication function#2018-08-2922:27flyboarderand I can (prn app)#2018-08-2922:28thhellerplease do#2018-08-2922:29thhellerlooks like it maybe doesn't have an auth prop?#2018-08-2922:30thhelleroh when you upgraded shadow-cljs did you maybe upgrade all your other npm deps as well?#2018-08-2922:30thhellermaybe there was a breaking change somewhere in there?#2018-08-2922:30flyboarderpossibly
#2018-08-2922:30thhelleryou can also run node --inspect-brk your.js#2018-08-2922:30thhellerand then remote debug the exception#2018-08-2922:37flyboarderlooks like “2.4.17” was the last version I was using#2018-08-2922:38thhellerdid you check if it has a auth and path prop?#2018-08-2922:41thhellercan't see a reason why that code would work in 2.4.17 but not 2.6.4 so I'm putting my money on other updated npm deps which broke stuff#2018-08-2922:43thhellerjust validate that app really has the properties you expect it to have#2018-08-2923:02flyboarder@thheller have you seen this yet? java.lang.ClassNotFoundException: com.google.javascript.jscomp.CompilerInput$ModuleType when using shadow-cljs as a library#2018-08-2923:02thhelleryes. incompatible closure compiler version.#2018-08-2923:03thhellermost often from incompatible/outdated clojurescript versions#2018-08-2923:05flyboarderhmm#2018-08-2923:43flyboarderso I blew away the .m2 directory and its still showing up#2018-08-3000:01flyboarderI give up, it builds just fine in docker container#2018-08-3000:01flyboarderso something is wrong on my mac#2018-08-3007:40thheller@flyboarder did you verify if app still has all the properties you expect? I know its easy to suspect shadow-cljs doing something wrong (and it might) but its just as likely that you accidentally upgraded something else and app just isn't what it used to be anymore?#2018-08-3007:40thhellerthats the first thing I'd verify#2018-08-3012:25mhuebertAre there any known reasons how a browser REPL gets into a state where it returns [:did-not-find some.namespace] for namespaces that are part of the build?#2018-08-3012:26thhellercalling in-ns before require might do this?#2018-08-3012:26thhellerie. you are trying to in-ns a ns that wasn't compiled yet#2018-08-3012:27mhueberthmm#2018-08-3012:28mhuebertmaybe my flow is wrong, I was trying something new, starting with (shadow/watch :browser {:autobuild false}) so that it doesn’t always recompile whenever I tab to the browser, and then evaluating blocks or running “Load file in REPL” from intelliJ#2018-08-3012:29thhellersounds good to me. maybe you just pressed switch-to-current-ns before load-file-in-repl?#2018-08-3012:29mhueberti’ll see if I can figure out exactly how to reproduce the state.#2018-08-3012:30thhellerswitching itself doesn't load anything so you must either load-file or require first#2018-08-3012:30mhuebertok#2018-08-3012:31mhuebertall of the namespaces are part of the original compile,#2018-08-3012:31mhuebertbut at some point i become unable to enter some of them#2018-08-3012:31thhellernote that the :did-not-find is a placeholder. I need to check what the standard CLJS REPL does in this place.#2018-08-3012:31mhuebertok#2018-08-3012:31thhellerbut yeah it only happens in in-ns calls#2018-08-3012:32thhelleroh wait. I think I know how you can trigger it#2018-08-3012:33thheller:autobuild false doesn't recompile on file change but the file change still invalidates the file so that it will be recompiled#2018-08-3012:33thhellerso yeah the ns disappears from the compiler state#2018-08-3012:34mhuebertok, yes now I can reproduce#2018-08-3012:34mhuebertbut even after I load the file, it still says :did-not-find#2018-08-3012:34thhellerload the file, change the file, call in-ns should be the steps#2018-08-3012:35mhuebertI don’t quite understand that#2018-08-3012:35thhelleryou load file in REPL your namespace#2018-08-3012:35mhuebertso I currently have a namespace which was changed (marked invalid)#2018-08-3012:35thhellerwithout changes? what did you do?#2018-08-3012:35mhuebertI can load file in REPL#2018-08-3012:35mhuebertI just made an edit and saved#2018-08-3012:36thhellerok that removes the ns from the compiler state#2018-08-3012:36thhellerif you then call in-ns it should fail#2018-08-3012:36mhuebertyes#2018-08-3012:36thhellerbut only AFTER editing it#2018-08-3012:36thhellerbefore it should work fine right?#2018-08-3012:36mhuebertyes#2018-08-3012:36mhuebertso it is now out of the compiler state#2018-08-3012:36thhelleryeah thats the watch in the background messing with the compiler state#2018-08-3012:37mhuebertthen I run load file in REPL, it appears to work — Loading cljs/src/spark_web/views/feedback.cljs... done#2018-08-3012:37mhuebertbut I still can’t in-ns#2018-08-3012:37thhellerthat might be a race condition, did you wait long enough?#2018-08-3012:38thhellerload file once, make some changes to the file, save them, the load file again#2018-08-3012:38mhuebertminutes, I mean it never works again, the only way I can use the ns again seems to be starting a new process#2018-08-3012:38thhellerhmm really?#2018-08-3012:38thhellerwatch and REPL really don't play well together sometimes#2018-08-3012:39thhellerI gotta go eat something. I'll try to reproduce later.#2018-08-3012:39thhelleropen an issue with the basic steps please#2018-08-3012:40mhuebertok#2018-08-3012:41mhuebertis there a different way (other than watch) to compile such that the browser will connect to the shadow server for a REPL?#2018-08-3012:56thhellershadow-cljs browser-repl but that probably has the same issue#2018-08-3013:07mhuebertok. posted: https://github.com/thheller/shadow-cljs/issues/384#2018-08-3013:08mhuebertreproduction was not as clean-cut as I’d have liked#2018-08-3013:28mhuebertI should also try with a fresh project to make sure it wasn’t anything to do with my particular build#2018-08-3013:29thhellernah it makes total sense. the watch invalidating the files is just a bit overeager#2018-08-3013:29thhellerand just shouldn't do its stuff when autobuild is off#2018-08-3013:29thhellerso it doesn't interfere with the REPL#2018-08-3013:50mhuebertso in a minimal example I am finding more reliable behaviour. maybe it also has something to do with how much time it takes to reload larger namespaces with a lot of dependencies? or could multiple changes trigger overlapping/interfering processes?#2018-08-3013:50thhellerthere is definitely a timing element involved#2018-08-3013:51thhellersay you load-file and then save the file#2018-08-3013:51thhellerthe save came after the load so it invalidates the file#2018-08-3013:51mhuebertat some point in my small example I also saw things like this;
no source by id: [:shadow.build.classpath/resource "shadow_ex/core.cljs"]
{:id [:shadow.build.classpath/resource "shadow_ex/core.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "shadow_ex/core.cljs"]
        clojure.core/ex-info (core.clj:4739)
        clojure.core/ex-info (core.clj:4739)
        shadow.build.data/get-source-by-id (data.clj:147)
        shadow.build.data/get-source-by-id (data.clj:144)
        shadow.build.compiler/remove-dead-js-deps/remove-fn--14770/fn--14771 (compiler.clj:873)
        clojure.core/complement/fn--5391 (core.clj:1433)
        clojure.core/filter/fn--5614 (core.clj:2809)
        clojure.lang.LazySeq.sval (LazySeq.java:40)

#2018-08-3013:52thhelleryeah I already know the problem#2018-08-3013:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/worker/impl.clj#L582-L588#2018-08-3013:54thhellerit autobuild is off it'll have reset (meaning removed) a bunch of resources from the compiler state which compile usually adds in again#2018-08-3013:54thhellerbut since compile doesn't happen its messed up#2018-08-3013:54thhellerjust shouldn't do anything is autobuild is off#2018-08-3013:54thhellerproblem solved 😉#2018-08-3013:55thhelleror maybe just remember to invalidate them but only do so before the next actual compile is triggered#2018-08-3013:55thhellerso it doesn't mess with the REPL doing stuff#2018-08-3013:55thhellerI'll think about it a bit#2018-08-3013:56mhuebertsounds great#2018-08-3014:16mhuebertalso, not sure if this is already covered, but following a :did-not-find ... error, a few seconds later a REPL command timed out. message shows up#2018-08-3014:16mhuebertmight have expected that the :did-not-find would cause the command to stop/fail immediately?#2018-08-3015:45flyboarder@thheller I agree with you, I believe this is being caused by classpath conflicts as I am getting many and noticed the closure compiler is from 2017#2018-08-3015:45flyboarderSo I think the version being used is faulty#2018-08-3015:45flyboarderof the libraries not shadow#2018-08-3015:45thheller@mhuebert nah the :did-not-find thing is really just a placeholder because I was undecided on how to deal with the situation. wanted to check what CLJS did but somehow forgot about it.#2018-08-3015:46thheller@flyboarder I'm confused. I thought compilation worked fine but you were getting errors at runtime?#2018-08-3015:47flyboarderI am it compiles without issues, but I suspect the version being pulled in is old#2018-08-3015:58thhellerso did you verify that app has the properties you expect it to have? that is the first and only question you should answer.#2018-08-3015:58thhellernone of the dependency issues matter at all if app isn't what you expect it to be#2018-08-3016:39mhuebertjust ran into a super weird issue trying to require /cdn-cgi/l/email-protection the minified version throws an error Cannot read property 'lib' of undefined when shadow requires it — partway into the file, a variable is undefined when it shouldn’t be. I can require the unminified version without any issues, so I guess it’s something to do with their minification#2018-08-3016:40mhuebertit looks like they are using terser for minification#2018-08-3016:41mhuebertshould say: rollup w/ commonjs & terser#2018-08-3016:46thhellerwhat would I need to call to try this?#2018-08-3016:47thheller(require '["auth0-js" :as x]) (x/???)?#2018-08-3016:56mhuebertyou don’t have to call anything - just require it#2018-08-3016:56mhuebertit fails when evaluating the script#2018-08-3016:57thhellerah ok#2018-08-3017:01thhelleruhm I only get that when I require it in the REPL? inside a normal build it seems to work?#2018-08-3017:02mhueberthmm I am running (shadow/compile :browser), and then opening the page#2018-08-3017:03thhellerme too#2018-08-3017:04thhellerversion "9.7.3"?#2018-08-3017:04mhuebertI don’t get the error if I shadow/release#2018-08-3017:04mhuebertyeah#2018-08-3017:04thhellerI do get the error if I just do shadow-cljs browser-repl and the require#2018-08-3017:05thhellerbut it works in the browser build I use for testing#2018-08-3017:05mhueberti’m using a fresh/empty project#2018-08-3017:06mhuebertare there any differentiating options around how code is evaluated when required?#2018-08-3017:07thhellernot really#2018-08-3017:08thhellerthe REPL has some extra things but thats not active with just compile#2018-08-3017:16thhellerok getting it in an empty project too#2018-08-3017:18thhellerhehe the minified code makes this tough to debug#2018-08-3017:20thhellerwhat the heck is this doing createCommonjsModule(function(module, exports) {#2018-08-3017:20thhellerthats just nuts 😛#2018-08-3017:26thhellerok there is definitely something very odd happening#2018-08-3017:27thheller(undefined.algo = {})) is in the transformed code but not in the source#2018-08-3017:28thhellerit might be closure just getting confused by the code. it might be my JS processing. no clue what is happening#2018-08-3017:29thheller
core = createCommonjsModule(function(module, exports) {
        var CryptoJS;
        module.exports = ((CryptoJS =
          CryptoJS ||
          (function(Math, undefined) {
            var create =
              Object.create ||
              (function() {
                function F() {}
                return function(obj) {
                  var subtype;
                  return (
                    (F.prototype = obj),
                    (subtype = new F()),
                    (F.prototype = null),
                    subtype
                  );
                };
              })();
            undefined = {};
            var C_lib = (undefined.lib = {}),
              Base = (C_lib.Base = {
                extend: function(overrides) {
#2018-08-3017:29thhellerthat has to be some of the weirdest JS I have ever seen 😛#2018-08-3017:29mhuebertyeah, I was digging through that too. super weird!#2018-08-3017:30thhellerI guess its time to investigate this some more https://github.com/thheller/shadow-cljs/issues/173 😉#2018-08-3017:31thhellerminifying already minified files isn't all that great to begin with#2018-08-3017:32mhuebertI wondered if maybe there were collisions with global vars, as I’ve run into that a bunch of times when mixing cljs code with other projects#2018-08-3017:32mhuebert(to figure out what to add as global: externs)#2018-08-3017:32thhellerJS libs should never create global vars#2018-08-3017:40thhellerhaha I think I know whats happening#2018-08-3017:41thhelleryep#2018-08-3017:42thhellerthere is an actual function definition that uses undefined as a binding name function(Math, undefined) {#2018-08-3017:42thhellerclosure seems to get confused by that and starts using it all over the place#2018-08-3017:44thhellerI'm surprised that undefined is even a legal binding name but this is JS so I expect nothing less I guess#2018-08-3017:47thhellerneed to see if I can reproduce this with just closure. looks like a bug on their end#2018-08-3017:49richiardiandreaquestion, do I understand correctly that a top level :clojure-defines in a build will be used for both :dev and :release?#2018-08-3017:49thhelleryes#2018-08-3017:49richiardiandreacool thanks!#2018-08-3017:55thheller@mhuebert gotta love the JS world. you can temporarily fix it by setting :js-options {:variable-renaming :local}#2018-08-3017:55thhellerits definitely the closure compiler getting confused by the undefined#2018-08-3017:55mhuebertwhat!#2018-08-3017:55thhellerI disabled variable-renaming by default to fix an issue in another library and making debugging a bit easier in general#2018-08-3017:56thhellerwith variable renaming closure will change the function signature to function(a,b) { so the undefined is gone and nothing left to get confused about#2018-08-3017:57mhuebertthat is genuinely weirder than I even expected#2018-08-3018:00mhuebertdo you know why it only affected the minified version?#2018-08-3018:00mhuebertas the non-minified version also has undefined there#2018-08-3018:01mhuebertthat :js-options setting works for me#2018-08-3018:03thhellerno idea why the non minified version doesn't have this issue. Maybe another function wrapper is added or so that makes it go boom#2018-08-3018:04thheller
module.exports = ((CryptoJS =
        CryptoJS ||
        (function(Math, undefined) {
#2018-08-3018:04thheller
/**
		 * CryptoJS core components.
		 */
		var CryptoJS = CryptoJS || (function (Math, undefined) {
#2018-08-3018:04thhellerprettified min vs non-min#2018-08-3018:05thhellerdefinitely changed in structure#2018-08-3018:05thhellerI don't even know how to begin describing this problem to the closure devs#2018-08-3018:05thhellercan't reproduce it with standard compiler since it doesn't allow turning variable renaming off#2018-08-3022:06urbanslugAnyone know how I can have shadow pass this arg to clojure -Sdeps '{:mvn/local-repo ".m2/repository"}'#2018-08-3022:06thheller:local-repo ".m2/repo..." in shadow-cljs.edn#2018-08-3022:12thhelleror do you use deps.edn and want it to use that? then there is no way other than calling clj -Sdeps '{:mvn/local-repo ".m2/repository"}' shadow.cljs.devtools.cli release app#2018-08-3022:26urbanslugYeah I think I'll have to call clj separately then#2018-08-3022:26urbanslugI want it to only happen on CI and not disrupt dev#2018-08-3022:29urbanslugthe default is $HOME/.m2/repository but I want it to be ./m2/repository#2018-08-3022:30urbanslugbut only for CI#2018-08-3022:30urbanslugwhcih does build tests and release#2018-08-3022:30urbanslugso for all 3 calls to shadow-cljs#2018-08-3022:33thhelleryou can make an issue for this. happy to add something that makes this possible.#2018-08-3022:33urbanslugI tried messing with the value of HOME to trick it but that didn't work haha#2018-08-3022:34urbanslugThere are a couple of issues here tbh. Are you talking about an issue regarding not being able to pass args to clj#2018-08-3022:34urbanslugand there are issues like clj can't take that path as a var imo it should#2018-08-3022:34urbanslug*env var#2018-08-3022:34thhellerwell if you are using deps.edn anyways I'd suggest just using clj directly.#2018-08-3022:35thhelleryou gain nothing by going through shadow-cljs#2018-08-3022:36urbanslugwell I gain the convenience of "shadow-cljs release app;" which I'd have to figure out what it's actually calling#2018-08-3022:38thhellerreplace shadow-cljs with clj -m shadow.cljs.devtools.cli#2018-08-3022:38thhellerthats what it calls#2018-08-3022:38thhellerclj -m shadow.cljs.devtools.cli release app#2018-08-3022:38urbanslughmmm#2018-08-3022:39urbanslugok let me try it#2018-08-3022:39urbanslugDo you still feel there's an issue here?#2018-08-3022:40thhellernot if you use deps.edn#2018-08-3022:42thhelleralso thought about "merging" configs a bit but generally not a fan#2018-08-3022:43thhellerbut there should be an easier way to tweak some stuff for CI and such#2018-08-3101:38wilkerluciohello, I'm having an issue to compile on a project, it sudenly start to fail to compile Fulcro:#2018-08-3101:38wilkerlucio
File: jar:file:/Users/wilkerlucio/.m2/repository/fulcrologic/fulcro/2.6.0/fulcro-2.6.0.jar!/fulcro/client/primitives.cljc
failed to require macro-ns "fulcro.client.primitives", it was required by "fulcro.client.primitives"
{:tag :shadow.build.macros/macro-load, :macro-ns fulcro.client.primitives, :ns-info {:rename-macros nil, :renames {}, :meta {:file "fulcro/client/primitives.cljc", :line 1, :column 5, :end-line 1, :end-column 29}, :ns-aliases {clojure.core.async cljs.core.async, clojure.stacktrace cljs.stacktrace, clojure.spec.alpha cljs.spec.alpha}, :use-macros nil, :excludes #{var? key replace force}, :name fulcro.client.primitives, :op :ns, :env {:ns {:name cljs.user}, :context :statement, :locals {}, :fn-scope [], :js-globals {console {:name console}, location {:name location}, escape {:name escape}, screen {:name screen}, global {:name global}, process {:name process}, require {:name require}, alert {:name alert}, history {:name history}, window {:name window}, module {:name module}, exports {:name exports}, document {:name document}, navigator {:name navigator}, unescape {:name unescape}}, :line 1, :column 1}, :imports nil, :requires {t cognitect.transit, set clojure.set, clojure.spec.alpha cljs.spec.alpha, gstring goog.string, log fulcro.logging, targeting fulcro.client.impl.data-targeting, fulcro.transit fulcro.transit, clojure.zip clojure.zip, p fulcro.client.impl.protocols, fulcro.client.impl.parser fulcro.client.impl.parser, fulcro.logging fulcro.logging, goog.string goog.string, async cljs.core.async, cljs.core cljs.core, gobj goog.object, goog goog, goog.object goog.object, fulcro.tempid fulcro.tempid, cljsjs.react cljsjs.react, cljs.core.async cljs.core.async, fulcro-css.css-implementation fulcro-css.css-implementation, fulcro.util fulcro.util, cognitect.transit cognitect.transit, hist fulcro.history, clojure.set clojure.set, clojure.core.async cljs.core.async, util fulcro.util, s cljs.spec.alpha, parser fulcro.client.impl.parser, fulcro-css.css-protocols fulcro-css.css-protocols, transit fulcro.transit, str clojure.string, zip clojure.zip, clojure.string clojure.string, cljs.spec.alpha cljs.spec.alpha, clojure.walk clojure.walk, tempid fulcro.tempid, fulcro.client.impl.data-targeting fulcro.client.impl.data-targeting, fulcro.history fulcro.history, fulcro.client.impl.protocols fulcro.client.impl.protocols}, :seen #{:require :require-macros}, :uses {prewalk clojure.walk}, :require-macros {fulcro.client.primitives fulcro.client.primitives, cljs.core cljs.core}, :form (ns fulcro.client.primitives (:require-macros fulcro.client.primitives) (:refer-clojure :exclude [var? key replace force]) (:require [goog.string :as gstring] [cljsjs.react] [goog.object :as gobj] fulcro-css.css-protocols fulcro-css.css-implementation [clojure.core.async :as async] [clojure.set :as set] [fulcro.history :as hist] [fulcro.logging :as log] [fulcro.tempid :as tempid] [fulcro.transit :as transit] [clojure.zip :as zip] [fulcro.client.impl.data-targeting :as targeting] [fulcro.client.impl.protocols :as p] [fulcro.client.impl.parser :as parser] [fulcro.util :as util] [clojure.walk :refer [prewalk]] [clojure.string :as str] [clojure.spec.alpha :as s] [cognitect.transit :as t])), :flags {:require-macros #{}, :require #{}}, :js-deps {}, :deps [goog cljs.core goog.string cljsjs.react goog.object fulcro-css.css-protocols fulcro-css.css-implementation cljs.core.async clojure.set fulcro.history fulcro.logging fulcro.tempid fulcro.transit clojure.zip fulcro.client.impl.data-targeting fulcro.client.impl.protocols fulcro.client.impl.parser fulcro.util clojure.walk clojure.string cljs.spec.alpha cognitect.transit]}}
ExceptionInfo: failed to require macro-ns "fulcro.client.primitives", it was required by "fulcro.client.primitives"
#2018-08-3101:38wilkerlucioI have another project with very similar deps (same fulcro version) that compiles fine with the same shadow-cljs version (2.6.4)#2018-08-3101:39wilkerluciotried cleaning .shadow-cljs, but I can't seem to figure how to get this project to compile again#2018-08-3101:39wilkerluciois there anything else I can cache clear to get it back?#2018-08-3106:57thheller@wilkerlucio strange. try shadow-cljs clj-repl and then (require 'fulcro.client.primitives)#2018-08-3106:58thhellerwonder why it fails to load?#2018-08-3107:30biscuitpantsman can i just say how much i love shadow-cljs @thheller#2018-08-3107:30biscuitpantsrecently discovered the report functionality, and that has been awesome#2018-08-3107:32biscuitpantsour entire (small) team of ~6 developers is absolutely loving it too. everyday i’m getting small anecdotes about how much better it is to work with#2018-08-3107:32thhellerlovely feedback. thx. 🙂#2018-08-3111:22wilkerlucio@thheller just tried, I got this:#2018-08-3111:22wilkerlucio
Wilker-Nu:fulcro-inspect wilkerlucio$ shadow-cljs clj-repl
shadow-cljs - config: /Users/wilkerlucio/Development/third-part/fulcro-inspect/shadow-cljs.edn  cli version: 2.6.4  node: v8.11.2
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - starting ...
	Aug 31, 2018 8:22:29 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 31, 2018 8:22:29 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :devcards available at 
shadow-cljs - HTTP server for :test-dev available at 
shadow-cljs - server version: 2.6.4
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 61362
shadow-cljs - nREPL server started on port 63104
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=> (require 'fulcro.client.primitives)
CompilerException java.io.FileNotFoundException: Could not locate clojure/future__init.class or clojure/future.clj on classpath., compiling:(fulcro/history.cljc:1:1)
#2018-08-3111:23thhelleryeah sorry about that. that is fixed in the version I'm just about to release#2018-08-3111:24thhellergot a bit overeager with the dependency filtering#2018-08-3111:25wilkerlucioI wonder why it works on other projects 🤔#2018-08-3111:26thhellermaybe using lein/deps?#2018-08-3111:26wilkerlucioyeah, doing that 🙂#2018-08-3111:26thhelleryeah the shadow-cljs launcher thingy just filtered too much#2018-08-3111:26thhellerdidn't think we need clojure-future-spec due to always being 1.9#2018-08-3111:26thhellerbut seems like it has a special namespace#2018-08-3111:27thhellerjust pushed 2.6.5. should be fixed there.#2018-08-3111:30wilkerluciojust tested and compiled fine, thanks!#2018-08-3111:41kwladykaIs it possible to use different :source-paths for different builds? I am thinking about that in context of /checkouts to develop a library. I would like to run app with my checkouts version and with public version.#2018-08-3111:41thhellerno#2018-08-3111:42thhellerwell you can use deps.edn or project.clj then yes but not with shadow-cljs itself#2018-08-3111:44kwladykaok thx#2018-08-3112:49wilkerlucioI have a project that uses a deps :local/root to point to a dep, this dep has some code that contains warnings and shadow is preventing code reload, shouldn't it ignore warnings outside the source paths?#2018-08-3112:50wilkerlucioalso, in this point, the code I'm talking about is related to some macro-magic, and I think in the way it works it's impossible to avoid the warnings... would be possible to mark some part of the code as "I know this looks weird" so it ignores warnings on that block?#2018-08-3112:50wilkerluciobecause while working on it at dev time those warnings are big PITA#2018-08-3113:12urbanslughmmm I've noticed that when I start the shadow repl in emacs when using a deps.edn with aliases because the command to start shadow doesn't specify the alias like -A:dev some dependencies don't load#2018-08-3116:31lilactownyou can specify what aliases to use when you jack-in with clojure cli tools#2018-09-0107:37urbanslug@U4YGF4NGM Sorry long post alert#2018-09-0107:37urbanslugI never got a chance to pick aliases. Here's my process: hmmm how? Here are my steps depending on which command I use either clojure-cli or shadow-cljs 1. M-x cider-jack-in-cljs 2. [Prompt] Which command should be used - clojure-cli - shadow-cljs 3. Choosing clojure-cli is what I think you said up there so I pick that. 4. [prompt] Select a clojurescipt repl type - shadow - shadow-select - custom all of these fail
[nREPL] Establishing direct connection to localhost:36749 ...
[nREPL] Direct connection to localhost:36749 established
error in process filter: nrepl-send-sync-request: Sync nREPL request timed out (op classpath)
error in process filter: Sync nREPL request timed out (op classpath)
/different port number depending on which repl type I choose though./ So I start again but this time I chose the repl-type as shadow-cljs. - [prompt] Select a clojurescipt repl type * shadow * shadow-select * custom - I go with shadow [prompt] select shadow-cljs build I choose app in my browser I get "shadow-cljs - Stale Client! You are not using the latest compilation output!" When I make a change I get:
[:app] Compiling ...
[:app] Build failure:
The required namespace "day8.re-frame.tracing" is not available, it was required by...
this was under the alias dev in my deps.edn
#2018-09-0114:08lilactownso it’s a little more complicated, unfortunately#2018-09-0114:12lilactownwhat I do is I modify the cider-clojure-cli-global-options#2018-09-0114:13lilactownbut when you run cider-jack-in you can also add a command to specify args before it runs#2018-09-0114:13lilactowne.g. C-u M-x cider-jack-in#2018-09-0114:14lilactownit’ll ask you for the nREPL command, and you can use that to add additional args, e.g. -A:dev#2018-09-0114:15lilactownthat’s nice for one offs, but annoying to do over and over so like I said, I add a dir-local for cider-clojure-cli-global-options in my project#2018-09-0114:16lilactown
((clojure-mode
  (cider-clojure-cli-global-options . "-A:server:dev")))
is what I have in my .dir-locals.el at the root of my project
#2018-08-3113:14wilkerlucionevermind, I just figured a way to make my code work in a way that doens't trigger warnings 🙂#2018-08-3113:53heyarneI'm getting a build-report.html with invalid js#2018-08-3113:53heyarnehas something like this already been reported?#2018-08-3116:17thheller@arne-clojurians can you send me the broken report? I haven't had any reports about that breaking no#2018-08-3116:19thhelleroops nevermind#2018-08-3116:22thheller@arne-clojurians fixed in 2.6.6. I accidentally included a dev version of the build reports JS and not the actual release version.#2018-08-3118:09thheller@hlolli btw sorry it took so long but the 2.6.6 release should allow you to use npm link. I didn't test it thought so please do.#2018-08-3118:09hlolliok, test it now#2018-08-3118:14hlolliyes, no error, compiling browser with 2.6.6#2018-08-3118:15hlolli(and linked the same module as resulted previously in the error)#2018-08-3118:19thhellergood#2018-08-3118:20wilkerlucio@thheller I noticed something, yesterday I tried to use :hud false on a project but that didn't worked, I restarted the compilation but the HUD was still showing up#2018-08-3118:22thhelleroh I think I removed that option#2018-08-3118:23thhelleropen an issue so I don't forget adding that in again. HUD should definitely be optional#2018-08-3118:23wilkerlucioone question though, the alert box is considered part of HUD?#2018-08-3118:23wilkerluciobecause I wanted to remove the warning box, I would keep the compiling status and remove just the warnings if I could#2018-08-3118:24thhelleryes its all part of the hud but I'm fine adding more fine-grained options like :hud :all :errors-only :off?#2018-08-3118:24wilkerlucio(I had so many warnings that the warning box rendering was taking about 10 seconds to have the UI responding...)#2018-08-3118:25wilkerluciothe fine-grained options sounds nice#2018-08-3118:25wilkerluciomaybe it could be a set#2018-08-3118:25wilkerlucio:hud #{:progress :errors}#2018-08-3118:26wilkerlucio:hud true | false | #{:compiling :errors :warnings}#2018-08-3118:27thhellersounds like a plan. please open an issue. I won't get to it this weekend and might forget otherwise#2018-08-3118:27wilkerluciosure#2018-09-0112:11urbanslugDoes shadow have plans of supprting a deps.edn alias in the build config?#2018-09-0112:11urbanslugI've noticed that deps.edn doesn't work so well with the repl in emacs#2018-09-0112:12urbanslugthis is what I ran into maybe I'm doing something ridiculous#2018-09-0112:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2018-09-0119:38urbanslug😬 Sorry#2018-09-0212:41priornixHi, trying out shadow-cljs, looks neat#2018-09-0212:42priornixI managed to compile with shadow-cljs watch app and then run node target/app.js. Next, on another window, I ran shadow-cljs cljs-repl app, but I can't load the cljs namespace?#2018-09-0212:43thheller> I can't load the cljs namespace#2018-09-0212:43thhellerwhat does that mean? what are you doing?#2018-09-0212:43priornix
shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 3 3)
[2:1]~cljs.user=> (require '[myapp.core :as mc])
#2018-09-0212:43priornix
[3:1]~cljs.user=> mc
nil
#2018-09-0212:43priornixI'm trying to load and eval the cljs app#2018-09-0212:44thhelleryou did?#2018-09-0212:44priornixYes (+ 3 3) returned 6#2018-09-0212:44thhellermc is not valid. :as does not create a local variable#2018-09-0212:44thhellerjust a namespace alias#2018-09-0212:44thhellermc/your-thing#2018-09-0212:44priornixI see#2018-09-0212:44priornixNo, I mean#2018-09-0212:45thhellerthat :as works as a variable is an exception for JS namespaces only#2018-09-0212:45priornixHmm, well, calling the namespace doesn't work, let me show you#2018-09-0212:46priornix
[7:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
                    ^
TypeError: Cannot read property 'call' of undefined
#2018-09-0212:46thhellerwhat is the code?#2018-09-0212:47thhellerfirst gotta prove that the code exists 😉#2018-09-0212:47priornixSure, let me hack out the code for you 🙂#2018-09-0212:47priornixJust playing around with it#2018-09-0212:47priornixGreat work, @thheller was using lumo before this#2018-09-0212:48priornixBut didn't really do much work on lumo anyway let me start on a minimal code and send you the output#2018-09-0212:53priornix
(ns myapp.core)

(defn test1 []
  (println "test1"))

(defn main! []
  (println "entry"))
#2018-09-0212:54priornix
shadow-cljs - connected to server
[1:1]~cljs.user=> (+ 3 3)
6
[1:1]~cljs.user=> (require '[myapp.core])
nil
[1:1]~cljs.user=> myapp.core/main)
nil
[1:1]~cljs.user=> (myapp.core/main)
<eval>:1
myapp.core.main.call(null)
                ^

TypeError: Cannot read property 'call' of undefined
#2018-09-0212:55thhelleryou called it main!#2018-09-0212:55priornixOh#2018-09-0212:55priornixDarn 🙂#2018-09-0212:55priornixThanks @thheller I need a new pair of eyes!#2018-09-0213:04priornixJust a quick question, I am reading through the user guide. What's the difference between cljs-repl and node-repl?#2018-09-0213:05priornixSo far, I noticed that println results appear in node-repl not in cljs-repl#2018-09-0213:05thhellernode-repl is standalone and not specific to any build#2018-09-0213:05thhellercljs-repl is part if your build, started and managed by you#2018-09-0213:06thhellerif you just care about the REPL use node-repl#2018-09-0213:07thhellernode-repl output is currently only going to where the node-repl was started#2018-09-0213:07thhellerthats a bug tracked here https://github.com/thheller/shadow-cljs/issues/373#2018-09-0213:11priornixHmm. The output was appearing in the node-repl window just now. Don't know what I did, but it's not appearing inside node-repl window now. cljs-repl works though#2018-09-0213:13priornixRestarted shadow-cljs watch and it works now#2018-09-0213:14priornixI think it could be a bug. Because when I quit node-repl and restarted it, the output disappeared#2018-09-0213:14priornixLet me try to reproduce it again#2018-09-0213:15thhellernode-repl isn't stopped if you leave it#2018-09-0213:15thhelleryou only resume it when you connect again#2018-09-0213:15priornixI see, well, let me see if I can recreate this issue#2018-09-0213:15priornixBecause when I quit and resumed node-repl the output disappeared completely#2018-09-0213:15thhellerthere is not really anything to reproduce. its a known issue. just didn't get to it yet#2018-09-0213:15priornixAh okay#2018-09-0213:16thhelleryes like I said. the output goes to the process that started it.#2018-09-0213:16priornixSo it's a known issue, got it#2018-09-0213:16thhellerif you start node-repl and leave it#2018-09-0213:16priornixUnderstood now#2018-09-0213:16thhellerthe process that started it is gone. so no more output#2018-09-0213:16priornixRight, got it
#2018-09-0213:16thhellerI'm undecided whether leaving it should kill the REPL#2018-09-0213:17thhelleryou can run shadow-cljs clj-repl (shadow/stop-worker :node-repl) to stop it#2018-09-0213:17thhellerand then run the node-repl again#2018-09-0213:17thhelleror run the (shadow/node-repl) from the clj-repl#2018-09-0213:17priornixI see#2018-09-0213:17priornixThanks for the help#2018-09-0213:20priornixSo the workaround that you mentioned kills the REPL#2018-09-0213:21priornixIs there a way to check how many builds are running#2018-09-0213:22priornixif there's only 1, just kill node-repl when leaving it#2018-09-0213:24thhellernot as part of the public API currently no#2018-09-0213:26priornixWhat are the use cases where node-repl is preferred to cljs-repl?#2018-09-0213:26thhellerdon't know about preferred because that is up to you#2018-09-0213:27thhellernode-repl is recommended if you just want to explore at the repl#2018-09-0213:27thhellercljs-repl is recommended if you have an actual running application that you just want to poke into#2018-09-0213:27thhellersince you control the node process there you can more easily interact with it#2018-09-0213:28priornixAnd in node-repl you can re-direct the output to REPL#2018-09-0213:32priornixNeed me to update https://github.com/thheller/shadow-cljs/issues/373 with this example, where the output ends up in the wrong place?#2018-09-0216:43thheller@priornix please do. might miss something otherwise#2018-09-0217:35flyboarder@thheller so I blew away the .m2 and .boot directories and sure enough, I can no longer compile 😢#2018-09-0217:36flyboarderI did look into the properties of the app object, it seemed to be correct (confirmed with source) but did not exists when I tried to access them#2018-09-0217:37flyboarderso I cleared the folders and assumed it was caching something#2018-09-0217:37flyboardernow I am getting#2018-09-0217:37flyboarder#2018-09-0217:37thhellerso you are using boot#2018-09-0217:37thhellerand I cannot control how boot resolves dependencies#2018-09-0217:38thhellertherefore you must ensure that everything is correct yourself#2018-09-0217:38thhellerthe above error means that you are using an incompatible closure-compiler version#2018-09-0217:38thhellerand most likely an incompatible clojurescript version#2018-09-0217:39thhellerit hsould be clojurescript 1.10.339#2018-09-0217:39flyboarderok, but where when compiling using shadow as a lib can I specify those things?#2018-09-0217:39thhellerI don't understand that question#2018-09-0217:39thhelleryou mean if you use shadow-cljs directly without boot?#2018-09-0217:40flyboarderlet me find the line I am invoking#2018-09-0217:40thhellerI don't know anything about boot. I presume there is a command to show your dependencies#2018-09-0217:40thhellerrun that and look at which cljs version gets picked#2018-09-0217:40flyboarderhttps://github.com/degree9/boot-shadow/blob/master/src/degree9/boot_shadow/impl.clj#L55-L59#2018-09-0217:41flyboarderThe dependencies are handled by boot already#2018-09-0217:41thhellerthat is completely irrelevant to the problem#2018-09-0217:41thhelleryes and boot is messing them up#2018-09-0217:41thhellerlook at nothing else but the dependency graph that is used to invoke whatever command you are using#2018-09-0217:42flyboarderI see what you mean, it throws an error currently#2018-09-0217:42thhellerplease note that just specifying the deps like in shadow-cljs is not the same thing#2018-09-0217:42flyboarderboot show -p#2018-09-0217:42flyboarderin that repo is throwing an error#2018-09-0217:43flyboarderclojure.lang.Symbol cannot be cast to java.lang.Number#2018-09-0217:43flyboarderI’ll check the dependencies list for a typo#2018-09-0217:43thhellerI presume thats a boot error?#2018-09-0217:44flyboarderI believe so#2018-09-0217:45flyboarder#2018-09-0217:45flyboarderhere we go#2018-09-0217:45flyboarder@thheller line 109 [org.clojure/clojurescript “1.10.339”]#2018-09-0217:46thhellerI see that but I don't see thheller/shadow-cljs?#2018-09-0217:46flyboarderthat comes from the boot pod#2018-09-0217:47flyboarder[[thheller/shadow-cljs "2.6.4"]]#2018-09-0217:47flyboarderis the version I am using#2018-09-0217:47thhellerthen show me the deps that the pod uses#2018-09-0217:47thhellereverything else is pretty irrelevant#2018-09-0217:48thhellercan you run a REPL inside the pod?#2018-09-0217:49flyboarderI dont know if there is an easy way to grab that#2018-09-0217:49flyboarderI dont think so#2018-09-0217:49thhellercan you run the shadow-cljs server?#2018-09-0217:50flyboarderhttps://github.com/boot-clj/boot/wiki/Pods#creating-pods-based-on-current-env#2018-09-0217:50thhellerI see a start-server!#2018-09-0217:50flyboarderthis is how I build the pod environment#2018-09-0217:50thhellerrun the shadow-cljs server and then use shadow-cljs clj-repl command#2018-09-0217:50thhellerand run ( "cljs/core.cljs")#2018-09-0217:50flyboarderkk one sec#2018-09-0217:54flyboarderI get an error when connecting to the repl#2018-09-0217:54flyboarderClassNotFoundException shadow.cljs.devtools.cli java.net.URLClassLoader.findClass (URLClassLoader.java:381)#2018-09-0217:56thhelleryour boot setup is seriously frustrating. I'm afraid I can't help you. If you run into the same issue running the compile without boot I'm happy to look further but I can't look into how boot works.#2018-09-0217:57flyboarderand nothing happens after the resource func#2018-09-0217:59thhellerin your readme it says boot shadow/server#2018-09-0217:59thhellerif you run that I presume it starts the shadow-cljs server yes?#2018-09-0217:59flyboarderyes#2018-09-0217:59flyboarderthat works just fine#2018-09-0218:00thhellerand then running shadow-cljs clj-repl doesn't work?#2018-09-0218:00thhellerplease paste everything not just one line#2018-09-0218:00flyboarder#2018-09-0218:01thhellerwhy is that version 2.4.22?#2018-09-0218:01flyboarder#2018-09-0218:02flyboarderI imagine the global npm version I have is different than the dependency boot is pulling in#2018-09-0218:02flyboarderI can update it#2018-09-0218:02thhellerthe global version isn't used if you have it installed in your project#2018-09-0218:03thhellerah wait ... I guess thats boot nonsense again of not actually keeping the files in node_modules/... but someplace else#2018-09-0218:03flyboarderright#2018-09-0218:03flyboarderboot dosent pollute the project dir#2018-09-0218:03thhellerok then the global version is used#2018-09-0218:04thhellerok in your boot stuff make sure that the shadow.cljs.devtools.cli namespace is required#2018-09-0218:04thhellerI think its just not loaded due to boot starting the server not shadow-cljs#2018-09-0218:05flyboarder#2018-09-0218:05flyboarderI can print from the shadow-cljs repl I think#2018-09-0218:05thhellerplease don't try to skip problems#2018-09-0218:05thhellerone at a time#2018-09-0218:06flyboarderI’ll add the extra ns#2018-09-0218:08flyboarderok, ns added starting server…..#2018-09-0218:08flyboarder#2018-09-0218:09thhellersee#2018-09-0218:09thhellercljs 1.9.946 ends up on the classpath BEFORE 1.10.339#2018-09-0218:09thhellerI presume that the same thing happens for the closure compiler#2018-09-0218:10thhellerthus you end up with conflicting classes which can't be loaded properly#2018-09-0218:10flyboarderok I see#2018-09-0218:10flyboarderso this is really a classpath conflict#2018-09-0218:11thhellerit always was. there is no other explanation 😉#2018-09-0218:11flyboarderyeah I guess so hahaha 😛#2018-09-0218:11thhellerI have seen that error plenty of times and it always was caused by an old clojurescript version#2018-09-0218:11thhelleror rather an old closure-compiler version#2018-09-0218:12thhellerthats why the shadow-cljs command does a few extra tweaks to ensure that old versions don't get loaded#2018-09-0218:12flyboarderkk, thanks for your help on this, I need more coffee #2018-09-0219:51flyboardersome progress….#2018-09-0219:52thheller( "cljs/user.cljs") is probably the easiest way to verify if the version is correct#2018-09-0310:56mhueberthmm, another REPL workflow question, related to that last :autobuild fix. Is there a way to tell shadow to recompile all of the files that were marked as invalidated along-the-way?#2018-09-0310:57mhuebertfully controlling what gets updated in the browser is fantastic (so fast!) but then if I ever do need to reload the page, the compiled js files are old#2018-09-0311:02thhelleryes (shadow/cljs.devtools.api/watch-compile! :the-build-id) or (shadow.cljs.devtools.api/watch-compile-all!)#2018-09-0311:02thhelleralthough that will also load all the files#2018-09-0311:03thhellerI think that this needs more fine tuned options however#2018-09-0311:03thhellersince you basically still want autobuild actually just not autoload#2018-09-0311:03thhelleropen to suggestions regarding that workflow#2018-09-0311:19mhueberthmm#2018-09-0311:20mhueberti’ll try this for awhile. watch-compile! does what I was hoping#2018-09-0313:45kwladykaHow would you compare https://clojurescript.org/guides/webpack to shadow-cljs in the context of npm dependencies? pros / cons ?#2018-09-0314:09thheller@kwladyka https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html#2018-09-0320:07flyboarder@thheller I was able to get builds working again, server now compiles just fine and doesn’t throw the error anymore#2018-09-0320:10flyboarderAlthough when compiling the client, I now get
[:client] Compiling ...
The required namespace "shadow.cljs.devtools.client.console" is not available.
#2018-09-0320:22thhellerthat never existed? no idea where that would be coming from?#2018-09-0320:23thhellercheck (shadow.cljs.devtools.api/find-resources-using-ns 'shadow.cljs.devtools.client.console)#2018-09-0320:23thhelleroh wait nvm#2018-09-0320:23thhellerof course it exists#2018-09-0320:23thhellerno idea why it doesn't exist for you though#2018-09-0320:24thhellerblaming the classpath again#2018-09-0320:25thhellercheck ( "shadow/build.clj") or so#2018-09-0320:32flyboarder@thheller here is my output from that#2018-09-0320:32flyboarder#2018-09-0320:33thhellerand the ( "shadow/cljs/devtools/client/console.cljs")?#2018-09-0320:34flyboarder#2018-09-0320:34thhellerhmm no idea why it wouldn't find it then?#2018-09-0320:34thhellermaybe try wiping your .shadow-cljs directory. maybe some bad cache?#2018-09-0320:35flyboarderok I will clear the .shadow-cljs and .boot folders#2018-09-0320:38flyboardercleared both, same issue#2018-09-0320:42thhellernot a clue#2018-09-0320:51flyboarderdoes shadow have an easy way to view the current classpath?#2018-09-0320:53thheller(System/getenv "boot.class.path")#2018-09-0320:56thhellerbut classpath seems to be ok. no idea why it wouldn't find the ns though.#2018-09-0320:57flyboarderis that from the clj-repl?#2018-09-0321:00flyboarderi get nil for boot.class.path, shadow.class.path and java.class.path#2018-09-0321:00thhellerehm sorry#2018-09-0321:00thhellerSystem/getProperty#2018-09-0321:00thhellertoo tired 😛#2018-09-0321:01flyboarderoh lol I should have caught that#2018-09-0321:02flyboarderhm, ok so shadow-cljs isn’t being included#2018-09-0321:03thhellerhow does that work? how is it running then? 😛#2018-09-0321:11flyboarderI imagine this is a boot pod thing#2018-09-0402:37ghidencan a shadow-cljs project produce a jar file without js dependencies? What I want to do is from one project, I want to produce a NPM package for js projects and cljs jar package for cljs projects.#2018-09-0402:38ghidenFor cljs projects to fill out the js dependencies, I was thinking I could use the webpack method that described here https://clojurescript.org/guides/webpack#2018-09-0403:27lilactownshadow-cljs doesn’t currently have a way of creating a jar AFAIK. I usually use a very minimal project.clj and use leiningen to create a jar + publish it#2018-09-0407:32thheller@ghiden CLJS packages are just uncompiled .clj(s|c) files. you never ship compiled CLJS code to other CLJS users. so any method of producing/publishing a jar file it valid you do not need shadow-cljs for that, although it will likely get support for it at some point.#2018-09-0407:34ghidenthank you @thheller#2018-09-0407:35ghideni guess the last piece that i need to figure out is whether cljs projects can use webpack to load the npm dependencies required by the published package#2018-09-0407:37thhellerfor now my recommended path is to use the cljsjs compatibility layer instead#2018-09-0407:37thhellersince the webpack part requires additional work on the lib consumer side#2018-09-0407:38thhellerits not an ideal solution either though#2018-09-0412:34exit2I have a node module that I’ve installed into an existing clj/cljs project that uses lein. I’m having some issues getting things to compile, would shadow-cljs be helpful for my scenario? I already have an existing build system, so I don’t want to replace that but if they could live in harmony together that would be ideal 🙂#2018-09-0412:36thhellernot sure I understand the question. shadow-cljs is a build tool so you are going to replace your existing build system if you use it. it is however fine to use it from lein.#2018-09-0412:38exit2right now Im trying to follow the https://clojurescript.org/guides/webpack guide, and things aren’t working out for me#2018-09-0412:38exit2my node module is a React component that I’ve built and put on NPM#2018-09-0412:39exit2so when I try to fire everything up I get some issues around React not being available#2018-09-0412:39exit2Uncaught ReferenceError: module$react is not defined#2018-09-0412:39exit2so I was wondering if some how including shadow-cljs can help me with these issues#2018-09-0412:39thhellersorry can't help you troubleshoot the webpack setup. don't know anything about it.#2018-09-0412:39thhellerbut with shadow-cljs you just npm install the-thing and (:require ["the-thing" :as x])#2018-09-0412:40thhellerthats it#2018-09-0412:40exit2the only reason I think I was pointed to the webpack guide is because I’m using webpack to build my React component, but I don’t think those things should be related#2018-09-0412:41exit2do you have documentation on how I should integrate this with lein?#2018-09-0412:41thhellerI recommend first starting without lein#2018-09-0412:41thhellerfigure out how things work. then integrate it into lein#2018-09-0412:42exit2cool#2018-09-0412:42thhellerie. npx create-cljs-project test-project cd test-project npm install your-thing#2018-09-0412:42exit2got it, so understand how things work in isolation before trying to integrate it into my existing stuff#2018-09-0412:43thhellerwell you can use your actual code if you want to. that is not a problem#2018-09-0412:44thhellerjust don't do it via lein#2018-09-0412:44thhellermight be best to start with https://github.com/shadow-cljs/quickstart-browser#2018-09-0412:47thhellerFWIW you might be able to skip the publish to npm part completely and just consume the code directly via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2018-09-0412:47thhellerexample for that is here https://github.com/shadow-cljs/examples/tree/master/babel#2018-09-0413:01Hukka@thheller Late congrats on the clojurists together funding (I'm back from a break)#2018-09-0413:01ikitommichanges: https://github.com/metosin/muuntaja/blob/master/CHANGELOG.md#060-392018#2018-09-0413:03ikitommimuch better perf out-of-the-box and supports optional byte[] responses, than enable NIO in some servers#2018-09-0413:18thhellerthanks#2018-09-0416:33kennyI started shadow-cljs fresh this morning and was receiving this message:
------ ERROR -------------------------------------------------------------------
09:29:53 cljs |  File: /home/kenny/compute_software/ui-frontend/src/compute/ui_frontend/components/constructors.cljs
09:29:53 cljs | Exception: No namespace: compute.ui-frontend.components.constructors found
The constructors ns follows the two ns pattern for exposing macros - there's a constructors.clj and a constructors.cljs. I had forgotten to remove a reader conditional from my constructors.clj file which caused that error. Once I fixed it the error went away. If I add the misplaced reader conditional back in after the initial compile, I get a much better error:
09:30:43 cljs | [2018-09-04 09:30:43.832 - WARNING] :shadow.cljs.devtools.server.reload-macros/macro-reload-ex - {:ns-sym compute.ui-frontend.components.constructors}
09:30:43 cljs | CompilerException java.lang.RuntimeException: Conditional read not allowed, compiling:(compute/ui_frontend/components/constructors.clj:9:3)
#2018-09-0416:35kennyIt'd be nice if the latter error was printed instead of the obtuse first one.#2018-09-0420:30Josh HorwitzI’m looking to use an Ant design library with my shadow app, would it be best to use the antd react package from NPM or https://github.com/priornix/antizer which is a clojurescript lib#2018-09-0420:38lilactownantizer looks nice. the only thing to note is that you might have some additional steps since it uses cljsjs#2018-09-0420:38lilactownsee: https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#breaking-change-removing-foreign-libs-support#2018-09-0420:40Josh HorwitzThanks! I’ll try and go the antizer route since I know it already#2018-09-0420:58thhellerI really don't recommend using wrappers like antizer. it'll pull in every single thing in antd. meaning your final JS grows by at least 1mb#2018-09-0420:58thhellerprobably way more#2018-09-0420:58thhellerif that is not important to you than its totally fine to use of course#2018-09-0421:23Josh HorwitzHere’s a quick starter I put together using the wrapper, I will work on using it without next. Thanks!#2018-09-0421:23Josh Horwitzhttps://github.com/jdhorwitz/shadow-reframe-antizer#2018-09-0423:58Nolanhey everyone, curious if anyone else has run into issues using test.check/defspec with the default :runner-ns shadow.test.browser. the workaround is easy, i just wrote a custom runner that calls clojure.test/run-tests in start, but curious if im missing something or what other solutions may be out there#2018-09-0504:08ghidenhow do you guys create a JS class and extend React.Component in cljs?#2018-09-0504:15justinlee@ghiden most people use a library on top of react, such as reagent or rum#2018-09-0504:16justinleeyou can also use create-react-class, which is a helper library that lets you create components using a function instead of es6 classes#2018-09-0504:16justinleeif you really want to extend and use the es6 machinery, then you need to use the goog.obj libraries from the google closure library#2018-09-0504:17justinleethis is an example of how to do that https://gist.github.com/pesterhazy/2a25c82db0519a28e415b40481f84554#2018-09-0504:17ghideni guess that's the only path#2018-09-0504:17ghidenthank you#2018-09-0504:19ghidenI didn't know about create-react-class and that looks more comfortable for cljs#2018-09-0504:21justinleethat’s what reagent uses. i believe it will be supported indefinitely going forward and should be fine to use#2018-09-0504:21ghidentrying to create a small component that can be used from js so I'm staying away from reagent#2018-09-0508:23thheller@nolan can you be a bit more specific about the defspec issue? what is the problem? do you actually mean clojure.test/run-tests not cljs.test/run-tests?#2018-09-0512:15Nolanhey @thheller, apologize for the poor clarity. i have one clojure.test/deftest and one clojure.test.check.clojure-test/defspec defined in test/some-test, and originally i was trying to use the default runner namespace (i.e. shadow.test.browser) with the following build config:
:tests
  {:target :browser-test
   :test-dir "target/test"
   :devtools {...}
when i built and ran the tests, it would ignore the defspec test and only run the deftest. If i called clojure.test.check/quick-check directly within a deftest, it would run and work fine, but forfeit the test.check reporting line. adding a custom :runner-ns to the build config fixed the problem, where start looks like this:
(ns runner-main
  (:require [clojure.test :as t]
                 [some-test]))

(defn start []
  (t/run-tests `some-test))

... ;; trivial stop and init
let me know if this helps, happy to provide more info
#2018-09-0512:16thhelleris this actually CLJS code though? :browser-test isn't meant to run clojure code#2018-09-0512:16thhellerits kinda hard to tell due to the aliasing#2018-09-0512:17Nolanits a .cljc file in testing another .cljc file, but all the code works in cljs#2018-09-0512:18thhellerah ok found it#2018-09-0512:18thhellerhmm ok yes you are going to need a custom runner#2018-09-0512:19thhellerand you are going to need to set (ns ^:dev/always the-runner)#2018-09-0512:19Nolanok, no worries. that works fine for me. just wanted to float it out there and see what came back. thanks for the investigation and input!#2018-09-0512:19thhellersince the run-tests is a macro that need to be recompiled#2018-09-0512:19Nolanyeah, i imagined it had to do with the macro#2018-09-0512:19thhellerthe shadow.test.browser thing works by hacking the deftest macro so it doesn't have to use the macro to actually run the tests#2018-09-0512:20thhellerbut it doesn't hack the defspec thing and therefore can only "discover" the extra tests in the macro#2018-09-0512:21thhellermeh I don't like this. maybe I'll revise the deftest hack and just use the macro after all#2018-09-0512:24thhellerI opened https://github.com/thheller/shadow-cljs/issues/386 so I don't forget about it#2018-09-0512:24thhellerI'll think about it for a bit#2018-09-0512:24thhellerusing a custom runner is totally fine though#2018-09-0512:35nolan330right on! thanks again for your help#2018-09-0516:18kanweiFYI shadow no longer works on [org.clojure/clojure "1.10.0-alpha7"]#2018-09-0516:18kanwei
java.lang.Exception: Unable to resolve spec: :clojure.core.specs.alpha/args+body
clojure.lang.ExceptionInfo: Unable to resolve spec: :clojure.core.specs.alpha/args+body
#2018-09-0516:21thheller@kanwei thx for the note. I can fix that later.#2018-09-0516:21kanweibroke a lot of older libs as well... gonna be a tough upgrade#2018-09-0516:23wilkerluciowe have to also consider this still an alpha, I can understand the excitement to use it but can be painful to maintain something that's subject to keep on rapid changes =/#2018-09-0516:24thhellerits not a problem in this case though since I just abused the core.specs to validate CLJS code#2018-09-0516:24thhellerbut nowadays CLJS has its own "core" specs so I should just use those#2018-09-0516:26wilkerlucioglad to hear that, I though was worst 🙂#2018-09-0517:32thhellerhmm turns out that the core.specs were committed but are not actually in use#2018-09-0517:32thhellerhttps://clojurescript.org/news/2018-03-26-release#_core_specs_alpha#2018-09-0517:32thhellerI'll see if they actually work. It would be fine not using the specs at all too.#2018-09-0517:55jjttjjI'm to use the antizer library working with shadow-cljs, which depends on the cljsjs version of antd. I've made my stub file as follows:
(ns cljsjs.antd
  (:require ["antd" :as antd]))


(js/goog.exportSymbol "antd" antd)
and npm installed antd. but the value of antd in that namespace is just coming up as nil. Anyone know what might be going on here?
#2018-09-0517:56thhellerrun shadow-cljs browser-repl and try (require '["antd" :as x]) x#2018-09-0518:01jjttjjhmmm I'm getting a console warning:
You are using a whole package of antd, please use  to reduce app bundle size.
and a repl timeout
#2018-09-0518:03thhellerhaha nice that they yell at you now for including that#2018-09-0518:04thheller@jjttjj try again after the timeout. REPL is just too impatient for it to complete#2018-09-0518:04jjttjjoh wait yeah it seems to be loading properly now#2018-09-0518:04jjttjj
[0:0]~cljs.user=> x
#js {:Affix #object[Affix], :Anchor #object[Anchor], :AutoComplete #object[AutoComplete], :Alert #object[Alert], :Avatar #object[Avatar], :BackTop #object[BackTop], :Badge #object[Badge], :Breadcrumb #object[Breadcrumb], :Button #object[Button], :Calendar #object[Calendar], :Card #object[Card], :Collapse #object[Collapse], :Carousel #object[Carousel], :Cascader #object[Cascader], :Checkbox #object[Checkbox], :Col #object[Col], :DatePicker #object[PickerWrapper], :Divider #object[Function], :Dropdown #object[Dropdown], :Drawer #object[Drawer], :Form #object[Form], :Icon #object[global], :Input #object[Input], :InputNumber #object[InputNumber], :Layout #object[Adapter], :List #object[List], :LocaleProvider #object[LocaleProvider], :message #js {:open #object[open], :config #object[config], :destroy #object[destroy], :success #object[Function], :info #object[Function], :warning #object[Function], :error #object[Function], :loading #object[Function], :warn #object[Function]}, :Menu #object[Menu], :Modal #object[Modal], :notification #js {:open #object[open], :close #object[close], :config #object[config], :destroy #object[destroy], :success #object[Function], :info #object[Function], :warning #object[Function], :error #object[Function], :warn #object[Function]}, :Pagination #object[Pagination], :Popconfirm #object[Popconfirm], :Popover #object[Popover], :Progress #object[Progress], :Radio #object[Radio], :Rate #object[Rate], :Row #object[Row], :Select #object[Select], :Skeleton #object[Skeleton], :Slider #object[Slider], :Spin #object[Spin], :Steps #object[Steps], :Switch #object[Switch], :Table #object[Table], :Transfer #object[Transfer], :Tree #object[Tree], :TreeSelect #object[TreeSelect], :Tabs #object[Tabs], :Tag #object[Tag], :TimePicker #object[TimePicker], :Timeline #object[Timeline], :Tooltip #object[Tooltip], :Mention #object[Mention], :Upload #object[Upload], :version "3.9.1"}
#2018-09-0518:05thhellerlooks non-nil-ish#2018-09-0518:06thhellerdon't see a reason why it would be nil in the build then? how did you check that?#2018-09-0518:07jjttjjconnected to nrepl and switched to the cljsjs.antd ns#2018-09-0518:08jjttjjgetting a bunch of
shadow.js.js:87 shadow-cljs - failed to load module$node_modules$fbjs$lib$UnicodeBidi
shadow.js.jsRequire @ shadow.js.js:87
shadow$provide.module$node_modules$fbjs$lib$UnicodeBidiService @ UnicodeBidiService.js:46
shadow.js.jsRequire @ shadow.js.js:85
shadow$provide.module$node_modules$draft_js$lib$EditorBidiService @ EditorBidiService.js:18
shadow.js.jsRequire @ shadow.js.js:85

...

shadow.js.jsRequire @ shadow.js.js:87
shadow$provide.module$node_modules$antd$lib$index @ index.js:485
shadow.js.jsRequire @ shadow.js.js:85
shadow.js.require @ shadow.js.js:111
(anonymous) @ cljsjs.antd.js:3
shadow.js.js:87 shadow-cljs - failed to load module$node_modules$antd$lib$index
errors in js console
#2018-09-0518:09thhellerright .. don't ignore those. thats why antd doesn't exist#2018-09-0518:09jjttjjohhh so those are deps ant needs in the cljsjs namespace?#2018-09-0518:10thhelleryes those are all getting pulled in by antd#2018-09-0518:10thhellerbut I included antd fine just a few days ago. which version are you using?#2018-09-0518:10thhellerhmm although I didn't try the full package#2018-09-0518:10jjttjj
[cljsjs/antd "3.8.0-0"]
#2018-09-0518:11jjttjjvia the https://github.com/priornix/antizer project#2018-09-0518:11thhellerhehe that version is pretty irrelevant. the npm version matters. but its already listed above :version "3.9.1"#2018-09-0518:11thhellerI'll see whats up with that#2018-09-0518:12jjttjjthanks!!#2018-09-0518:13thhellerhmm it compiles and loads without errors for me?#2018-09-0518:13jjttjjweird! hmmm maybe i installed the wrong npm version let me try that again#2018-09-0518:14thhelleroh wait. still had an old install#2018-09-0518:16thheller3.8.2 worked but 3.9.1 also works fine#2018-09-0518:17thhellercan you post the full errors you get? usually only the first and the last one matter though#2018-09-0518:18jjttjj#2018-09-0518:19thhellerah#2018-09-0518:19thhelleryou have a bad page encoding#2018-09-0518:19thhellerset <meta charset="UTF-8"> in your HTML (or the http header if you control those)#2018-09-0518:20jjttjjoh wow that worked! thanks so much#2018-09-0518:20jjttjjprobably should have posted that full output sooner, sorry!#2018-09-0518:20thhellerbtw don't use antizer and rather import only what you need from antd directly#2018-09-0518:21thhellerotherwise your final output goes up by more than 1mb since you get everything#2018-09-0518:21thheller(thus their warning on startup)#2018-09-0518:22jjttjjgotcha thanks#2018-09-0523:32ghidenI'm trying use this library https://github.com/rauhs/hicada for creating React component. But not sure if I'm doing it right. hicada expects you to write your own macro. So here is something that works.#2018-09-0523:33ghiden#2018-09-0523:35ghidenI wish I could use 'react.createElement for :create-element but it complains that ReferenceError: react is not defined#2018-09-0523:35lilactownyou will probably need to require react in whatever namespace you use it in#2018-09-0523:36ghidenwhen I use the macro, I require react too#2018-09-0523:39ghidenforgot to mention that i get this error when I use this component from other project#2018-09-0523:39ghideni use npm-module as target#2018-09-0607:21thheller@ghiden I recommend creating a wrapper function. (ns your.thing (:require ["react" :as react])) (defn create-element [...] (react/createElement ...))#2018-09-0607:22thhellerthen use your.thing/create-element. Closure will optimize the extra wrapper fn away#2018-09-0607:27ghiden@thheller thanks. I’ll try that approach.#2018-09-0607:29thhelleryou can also use (def create-element react/createElement) if you don't care about the wrapping part#2018-09-0609:15ghidenJust confirmed that it works! Thanks again! :+1:#2018-09-0609:40mitchelkuijpersI am running into:
failed to require :target :browser-test for build :test
CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defelem in this context, compiling:(hiccup/page.clj:20:1)
        clojure.lang.Compiler.analyze (Compiler.java:6792)              
        clojure.lang.Compiler.analyze (Compiler.java:6729)                    
        clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3813)           
        clojure.lang.Compiler.analyzeSeq (Compiler.java:7005)                                                                                                                                                                             clojure.lang.Compiler.analyze (Compiler.java:6773)
        clojure.lang.Compiler.analyze (Compiler.java:6729)                                         
        clojure.lang.Compiler.eval (Compiler.java:7066)                                  
        clojure.lang.Compiler.load (Compiler.java:7514)                        
        clojure.lang.RT.loadResourceScript (RT.java:379)
        clojure.lang.RT.loadResourceScript (RT.java:370)
        clojure.lang.RT.load (RT.java:460)                                                                                                                                                                                       
        clojure.lang.RT.load (RT.java:426)                                                                  
        clojure.core/load/fn--6548 (core.clj:6046)                                  
        clojure.core/load (core.clj:6045)                                             
        clojure.core/load (core.clj:6029)                                                            
        clojure.core/load-one (core.clj:5848)                                                                                                                                                                                    
        clojure.core/load-one (core.clj:5843)                                                                   
        clojure.core/load-lib/fn--6493 (core.clj:5888)                        
        clojure.core/load-lib (core.clj:5887)                                     
        clojure.core/load-lib (core.clj:5868)             
        clojure.core/apply (core.clj:659)                                                          
        clojure.core/load-libs (core.clj:5925)                                           
        clojure.core/load-libs (core.clj:5909)                                 
        clojure.core/apply (core.clj:659)                   
        clojure.core/require (core.clj:5947)                                       
        clojure.core/require (core.clj:5947)                             
        shadow.build.targets.browser-test/eval91055/loading--6434--auto----91056 (browser_test.clj:1)
        shadow.build.targets.browser-test/eval91055 (browser_test.clj:1)
        shadow.build.targets.browser-test/eval91055 (browser_test.clj:1)      
        clojure.lang.Compiler.eval (Compiler.java:7062)                       
        clojure.lang.Compiler.eval (Compiler.java:7051)                                                                                                                                                                           
        clojure.lang.Compiler.load (Compiler.java:7514)
                                     
when trying to use browser-test, when I add hiccup it works again. So maybe you did some deps cleanup?
#2018-09-0609:41thheller@mitchelkuijpers there was a race-condition related to that. I fixed it a few versions ago though. which version are you on?#2018-09-0609:42thhellerI delayed loading all the web stuff so that is a) doesn't get AOT compiled and b) doesn't delay server startup#2018-09-0609:43thhellerbut due to loading hiccup in a different thread you could end up trying to use it before it finished loading#2018-09-0609:43thhellerthat you are seeing above#2018-09-0609:50mitchelkuijpersI was trying out 2.6.6, but I just downgraded to 2.6.3#2018-09-0609:50thhellerhmm that should be fixes in 2.6.6 definitely. what command did you run?#2018-09-0610:57mitchelkuijpers
npx shadow-cljs watch test
#2018-09-0610:57mitchelkuijpersIt was fixed when I added hiccup to my deps#2018-09-0610:58thhellershadow-cljs depends on hiccup. that hasn't changed in forever.#2018-09-0610:58thhellerbut as I said its a race condition so it is just a timing issue. if the build starts too fast you'll run into the problem again.#2018-09-0610:58thhellerI'll see why this is still happening#2018-09-0610:59mitchelkuijpersAh ok, that makes sense#2018-09-0610:59mitchelkuijpersI am using tools.deps not sure if that helps#2018-09-0611:00thhelleryou misinterpret the error. hiccup is definitely on the classpath regardless of you adding it or not. it is not a dependecy problem.
#2018-09-0611:01thhellerits a race condition. shadow-cljs will load the hiccup namespace in another thread but due to how Clojure works the namespace will be immediately available#2018-09-0611:02thhellerso thread one will starting loading hiccup one form at a time starting with ns.#2018-09-0611:02thhellerthe other thread has (:require [hiccup.core ...]) and clojure sees that the ns is already loaded#2018-09-0611:02thhellerdespite the other thread still being in the process of loading the individual forms#2018-09-0611:03thhellerthe other thread continues on. wants to use defelem but it isn't loaded yet and boom#2018-09-0612:16mitchelkuijpersAh ok, thank you for the explanation#2018-09-0615:28bastiwhen using the :node-test target how can I get the node process to connect to my REPL?#2018-09-0615:31bastibasically I’d like to have a REPL session where my test-code is already included#2018-09-0616:39richiardiandrea@basti what I do is to have a separate :node-script target that requires all the test namespaces so that they are compiled. Not ideal I know, maybe @thheller has a better idea#2018-09-0616:50thheller@basti :node-test disables all devtools since it supposed to exit after running the tests since we need the exit code for CI. is it not sufficient if you just use node-repl and manually load whichever test you are working on/want to run?#2018-09-0618:29richiardiandreaIs node-repl compiling everything on the classpath independently? I think that is the problem I have noticed#2018-09-0618:33thhellerit doesn't compile anything unless you require it#2018-09-0618:57bastimanually loading would work but it’s tedious because I have to load all test dependencies, and If I required a library in my tests that hasn’t been required yet it’s missing#2018-09-0618:57bastiso I kinda end up requiring test dependencies in my production code to work around#2018-09-0618:58thhellernot sure I understand? your tests will require the code they need?#2018-09-0619:00richiardiandreaso what @basti is saying is something I faced as well, and it basically made me do something like this in a separate entry point:
(ns my.registry.repl
  (:require [cljs.spec.alpha :as s]
            ;; so that we have the test compiled in the REPL
            [my.registry-test]
            [my.registry.aws-test]
            [my.registry.azure-test]))
#2018-09-0619:01bastiyeah well explained @richiardiandrea! that’s what I was trying to say!#2018-09-0619:04richiardiandreaif node-repl compiles everything independently from the entry point then it should be good#2018-09-0619:09richiardiandreaotherwise the REPL would complain and you have to require in the REPL the namespace in order to "compile" it the first time, that is what I have experienced at least#2018-09-0619:12thhellerwould complain about what?#2018-09-0619:12thhelleryes you have to require a ns before anything can be used#2018-09-0620:03richiardiandreayes and that is what I think we are both asking, if there is a way to have a node repl that automagically requires/compiles the test namespaces - without the glue file above#2018-09-0620:04thhellernot currently no#2018-09-0620:04thhellerbut why do you need to require ALL? do you not use the REPL to work on ONE particular test/ns? why do the others need to be loaded?#2018-09-0620:09richiardiandreathis might be true, but still, maybe metadata marker on the ns that tells node-test to preload that particular one ns would be convenient 😉#2018-09-0619:28lilactownin the :browser-test target, if I use a custom runner-ns do I need to :require all of them test namespaces?#2018-09-0619:28thhellerno. just modify https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/browser.cljs to your needs#2018-09-0619:29thhelleronly need to keep the init/start/stop fns#2018-09-0619:29thhellereverything else is optional#2018-09-0619:29lilactownah, I just found that file 😄 thanks!#2018-09-0619:29thhellerbtw cljs-test-display looks real nice and I was thinking about using it by default#2018-09-0619:29thhellerjust didn't get to it yet#2018-09-0619:30lilactownyeah! I'm going to whip up a test runner for it. I can submit a PR when I'm done#2018-09-0619:33thhellersweet#2018-09-0620:41lilactownwas a change made to the type inference between 2.4.4 and 2.6.6? I'm running into https://dev.clojure.org/jira/browse/CLJS-1918 all of a sudden#2018-09-0620:42lilactowntch. looks like it might be because I'm on an older CLJS version.#2018-09-0620:46lilactownyep. just removing my overrides of CLJS and the closure compiler fixed it.#2018-09-0710:28HukkaFor some reason I'm not getting newest cljs source in Chrome's devtools. I know the source has updated, since the console.log fires, but even when I click the logged line, I end up in a line that doesn't have any logging. Is it a problem in the Chrome, or might there be something messing my source maps?#2018-09-0711:28thheller@tomi.hukkalainen_slac are you using the built-in http server or some other web server? the built-in disables all caching to prevent stuff like this, others may not#2018-09-0714:10pvillegas12I’m using the :module-hash-names true option for my build, looks like manifest.edn has the mapping to the output name, but how do I make index.html point to that specific js file?#2018-09-0714:10thhellerwhat are you using to generate the index.html?#2018-09-0714:11pvillegas12🙂 good question, what should I use?#2018-09-0714:12thhellerwell that kinda depends on what you are doing? 😛#2018-09-0714:12thhellerI have a clojure webserver that generates my HTML via hiccup#2018-09-0714:12pvillegas12I want to serve a fulcro app from s3#2018-09-0714:12Hukka@thheller Jetty, with ring#2018-09-0714:13thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks would be the answer#2018-09-0714:13thhelleror rather would be an answer. there are many things you can do. how are you doing deployment overall?#2018-09-0714:15pvillegas12I’m currently investigating how to go about this, but currently thinking to do shadowcljs release main with the md5 hashed javascript, push it to S3 and use cloudfront to serve the assets. However, I am trying to get this working with both the index.html and css parts of the build#2018-09-0714:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run also works#2018-09-0714:16thhellerthen clj-run sounds good maybe?#2018-09-0714:17thheller
(defn release [server]
  (shadow/release :my-build)
  (-> (io/file "output-dir" "js" "manifest.edn")
      (slurp)
      (edn/read-string)
      (generate-index-html))
  (sh "build-my-css" ...)
  (sh "rsync" "-arzt" "path/to/output-dir" server))
#2018-09-0714:17pvillegas12@thheller you mean writing the deploy script in clj right?#2018-09-0714:18thhellercould be done via make. Just read the manifest.edn and generate the index.html for it via whatever means you prefer?#2018-09-0714:18pvillegas12:+1: bit new to this release manually part, thanks!#2018-09-0714:31pvillegas12@thheller any pointers for css bundling?#2018-09-0714:31thhellerI use https://github.com/sass/node-sass#command-line-interface currently#2018-09-0718:08justinleei was helping someone in another channel with macros and i realized this works:
[2:1]~cljs.user=> (defmacro foo [] `(1 2 3))
#'cljs.user/foo
[2:1]~cljs.user=> (foo)
(1 2 3)
#2018-09-0718:08justinleehow can defmacro work in a cljs repl?#2018-09-0718:15lilactownworks in figwheel.main too#2018-09-0719:44thhellerit doesn't work. you are just calling a function.#2018-09-0719:59justinleewhy does it even let me do it? the only reason i’m asking is because i sort of thought it would throw an error#2018-09-0720:20thhellerself-host reasons I guess#2018-09-0720:47richiardiandreathe test for that is if (macroexpand '(foo)) actually works#2018-09-0720:52justinleeit doesn’t. the fact that it doesn’t proves that i don’t understand the cljs macro system even a little bit#2018-09-0720:53richiardiandrealol#2018-09-0720:53richiardiandreait's simple, they never work 🙂#2018-09-0720:53justinleeeven simpler: i never use them 🙂#2018-09-0720:53richiardiandreathat's wise#2018-09-0814:13grounded_sageHow can I do a binding with shadow cljs?#2018-09-0814:13grounded_sagehttps://github.com/roman01la/cljss/commit/ef661a5d29356ff97e2e07b75af48fc06c876d53#diff-56b26c1ab3f7c730b3d264bf99467f74R179#2018-09-0814:16thhellersame way it is done there#2018-09-0814:16thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-09-0814:17thheller(defn foo [] (binding [x y] (shadow.cljs.devtools.api/compile :the-build))#2018-09-0814:17thhellermight have to disable caching though#2018-09-0814:23grounded_sageOk. I was avoiding clj-run and leveraging build hooks.#2018-09-0814:25grounded_sageCould I wrap the build-state of a build hook with it?#2018-09-0814:25thhellerno#2018-09-0814:25grounded_sagehmm yea just took another look and realised#2018-09-0814:27grounded_sageSo the dynamic variable binding should be avoided to keep it to build hooks and keep caching then?#2018-09-0814:28thhellerno idea. i don't know what cljss does#2018-09-0814:28thhellerit looks like it doing a bunch of side effects in macros#2018-09-0814:29thhellerand that seriously breaks with caching enabled#2018-09-0814:29grounded_sageYea this is the SSR implementation being worked on.#2018-09-0814:29grounded_sageI'm looking to leverage it in shadow-jam and just figuring out how I can leverage that SSR.#2018-09-0814:30grounded_sageI probably need to have a closer look at the caching situation then as well because I perform image manipulation and generate multiple image files in macros.#2018-09-0814:31thhellerdon't do such things in macros#2018-09-0814:31thhellerever#2018-09-0814:33grounded_sageThere isn't really any other way for me to perform it from what I can tell.#2018-09-0814:34grounded_sageIt's the macro I use here. https://github.com/groundedSAGE/shadow-jam/blob/master/src/routes/index.cljc#L14 that I am referring to.#2018-09-0814:34thhellerthere are plenty of ways. they just might not be documented too well#2018-09-0814:36grounded_sageAllows defining a source image and other details which it then uses to grab image, collect certain metadata, use that metadata to figure out data required for the html markup and generates corresponding assets.#2018-09-0814:38thhellerso the basic misconception I see it that you think everything has to happen in the macro#2018-09-0814:38thhellerit doesn't have to happen in a macro at all#2018-09-0814:38thhellerthats the fallacy with starting with a macro in the first place#2018-09-0814:39thhellerso lets imagine this without a macro at all#2018-09-0814:39thhelleryou have want to achieve [:picture [:img {:src "some.jpg"}]]#2018-09-0814:39grounded_sageI thought it through and discussed with others and apparently macro was only way. I try and avoid macros as I know the objective is data > fn > macro#2018-09-0814:40thhellerwhere the PATH to the image is "replaced"#2018-09-0814:40thhellerso you instead call [:picture [:img {:src (your.lib/get-path "some.jpg")}]]#2018-09-0814:41thhelleryou then of course want responsive versions#2018-09-0814:41thheller[:picture [:source {:srcset (your.lib/get-path "some.jpg" :small) :media "..."}]] [:img {:src (your.lib/get-path "some.jpg")}]]#2018-09-0814:42thhellerso then the question becomes what get-path looks like#2018-09-0814:42thhellerits a function#2018-09-0814:42thhellerso it can take data from everywhere#2018-09-0814:42thhellerso lets suppose there is a global "myImages" variable#2018-09-0814:43thheller(defn get-path [img-name img-variant] (goog.object/get js/myImages img-name (name img-variant)))#2018-09-0814:43thhellernow the question is how do you get the info you need for myImages#2018-09-0814:43thhellera) generate it statically since you know which images you have and then append it to the final build output#2018-09-0814:44grounded_sageIt's actually
[:picture [:source "various responsive sizes"] [:source "the same thing again but fallback image format"] [:img "the image again which contains more metadata and fallback"]]
#2018-09-0814:44thhellerthats what I just posted above#2018-09-0814:44grounded_sageAh yes slow typing. Apologies.#2018-09-0814:45thhellerthe other option is to actually employ a macro but only store which images where accessed and which variants#2018-09-0814:45thhellerso you can extract that in a build hook#2018-09-0814:47thhellerso basically the concept is to use a helper function that can return data that was not part of the CLJS compilation at all#2018-09-0814:47thhellerand then append it to the final build output instead#2018-09-0814:48thhelleror pass it to the build by any other means#2018-09-0814:49thhellerin my experience image processing too much is actually a problem in the long rum#2018-09-0814:49thhellersometime you don't just want to use the same image in different sizes#2018-09-0814:49thhellersometimes you want a big one and a small cropped one (instead of the whole area)#2018-09-0814:50thhellersometimes the smaller one is completely different#2018-09-0814:50thhellerbuilding a system that can generate all the images you want into a macro is just gonna be painful to use for everyone#2018-09-0814:55grounded_sageI kind of see what you mean with the helper functions. For me right now the macro seems easier to grok. I'm just working to bring this up to a gatsby like experience (through stealing ideas) then hopefully people with more dev chops can chime in and help me polish it lol.#2018-09-0814:56thhellerso then steal how they deal with images#2018-09-0814:56thhellerthey don't have macros either#2018-09-0815:02grounded_sageI've print screened your explanations. Brain a bit foggy as is late here now.#2018-09-0815:06thhellerI'm a bit too busy with other stuff but hooking image processing and scss into shadow-cljs is on my list#2018-09-0815:06thhellerjust won't be part of normal compilation and a plugin of sorts instead#2018-09-0815:06thhellerprobably not going to touch ssr though#2018-09-0815:08grounded_sageI'm interested to see your image processing implementation when done and see how much more I have to learn 😛#2018-09-0815:12thhellerwell I'm just going to take whatever tools already exist#2018-09-0815:12thhellermake them generate some edn/json data#2018-09-0815:12thhellerand then concat that into the build#2018-09-0815:12thhellerdone#2018-09-0815:13thhellerright now my image processing is a .sh file with a bunch of convert img.jpg other-image.jpg#2018-09-1011:24heyarneI'm trying to play around with http://ptsjs.org/, which can be installed with npm i pts. Doing a naive (:require ["pts" :refer Pt]) gives me the following error:
--- node_modules/pts/dist/index.js:3828
This code cannot be converted from ES6. extending native class: Float32Array
--- node_modules/pts/dist/index.js:4022
This code cannot be converted from ES6. extending native class: Array
How do I approach this? There's a minified version in dst that contains different non-convertible es6-code and an es5-version that's follows UMD from what I can see. Trying to require the es5-version gives me No such namespace: Pt, could not locate Pt.cljs, Pt.cljc, or JavaScript source providing "Pt".
#2018-09-1012:18thheller@arne-clojurians you can probably set :js-options {:language-out :ecmascript6} in your build config#2018-09-1013:19heyarnenow i'm slightly confused... there's a shadow.js.babel in the shadow global variable? i skimmed the docs and it said something about running babel yourself for things like jsx interop, but there's a bundled babel as well?#2018-09-1014:06lilactown@arne-clojurians I ran into this a little while ago. I posted an issue here: https://github.com/williamngan/pts/issues/22#2018-09-1015:33heyarnedid you try to bundle your code with advanced optimizations? basically as soon as i do (.. form (stroke "#abc") (fill "#def")) it tries to optimize to heavily. even if i type-hint form it can't infer the call to stroke and won't know what it returns, causing it to not find fill which has been obfuscated#2018-09-1015:34heyarneso what i do now is (.. form ^js (stroke "#abc") ^js (fill "#def"))... but this doesn't feel like a sensible thing to do#2018-09-1015:35heyarnemaybe @U05224H0W knows something about this, is this a problem of closure compiler and chaining APIs?#2018-09-1015:35lilactowndo you have infer-externs on?#2018-09-1015:38heyarneno#2018-09-1015:38heyarnei guess it's on :auto by default?#2018-09-1015:39heyarne(-> ^js form (.stroke "#abc") (.fill "#def") (.point whatever)) seems to work#2018-09-1015:40lilactownthis is my config https://github.com/Lokeh/lilac.town/blob/master/shadow-cljs.edn#L8#2018-09-1015:40lilactownhttps://github.com/Lokeh/lilac.town/blob/master/src/lilactown/client/pts.cljs#2018-09-1015:42lilactownit looks like I do have to annotate the space#2018-09-1016:10thheller@arne-clojurians it is not on auto by default. you must turn it on. I think .. has a bug in that it doesn't propagate typehints properly#2018-09-1016:10thheller-> is fine so use that#2018-09-1014:06lilactownthheller’s solution is what I used#2018-09-1014:10heyarnethanks!#2018-09-1014:26thheller@arne-clojurians the built-in babel is used to transform ES6 code from node_modules only.#2018-09-1014:27thhelleronly using babel because of some compatibility issues with closure#2018-09-1014:27thhellerhttps://github.com/google/closure-compiler/issues/2971#2018-09-1100:02royalaidDoes anyone have experience using https://github.com/vvvvalvalval/scope-capture with shadow?#2018-09-1100:03royalaidI am looking into using it and seems that the way shadow does things might not work with what scope-capture wants to do#2018-09-1100:03royalaidbecause it seems like there are separate processes for the build and repl#2018-09-1104:21ghidenI'm trying to use this cljs wrapper for React. https://github.com/dmohs/react-cljs And, when I publish as npm, I get an error "ReferenceError: createReactClass is not defined". Maybe this library is not a good one to use with shadow-cljs but does anyone have experience with this library? or any good React wrapper that works with shadow-cljs?#2018-09-1107:49thhellerwhich version do you use? the bundled version should work#2018-09-1107:49thhellerwhich version do you use? the bundled version should work#2018-09-1108:22ghidenis there any way to export from shadow-cljs?#2018-09-1108:22thhellerwhy did do you not use the bundled version?#2018-09-1108:23thhelleryes there are ways. I'm just trying to understand why you are not using the default way.#2018-09-1108:23ghidenif i use the bundled version, I have to shim cljsjs, right?#2018-09-1108:23thhellerno#2018-09-1108:24thhellerit'll include this shim automatically#2018-09-1108:24thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/create_react_class.cljs#2018-09-1108:24thhellerwhich is also the example of how to export the global#2018-09-1108:24thhellerso either YOU can include cljsjs.create-react-class OR let the library do that#2018-09-1108:25ghidenah, i see#2018-09-1108:25thhellerif you do it you must ensure that you do it before including it before any of the library code since it may try to access it directly#2018-09-1108:25ghidenbut this library depends on 'creatReactClass', how do i export this variable?#2018-09-1108:26thhellerthe code above does that#2018-09-1108:26thheller(js/goog.exportSymbol "createReactClass" create-react-class)#2018-09-1108:26ghidenok, i'll try#2018-09-1108:26ghidenthanks for your help#2018-09-1108:26ghidenyou are always helpful!#2018-09-1108:26thhellerbut it'll probably not work if you publish to npm#2018-09-1108:27ghideni thought so#2018-09-1108:27thhellernpm doesn't like exporting to global#2018-09-1108:27ghidenyep#2018-09-1108:27ghidenwhat's the best way to create a react component?#2018-09-1108:27thhellerso thats a limitation of the library. since it shouldn't use the global in the first place#2018-09-1108:28thhellerjust use create-react-class directly#2018-09-1108:28ghidenfrom react?#2018-09-1108:28thheller(create-react-class #js {:render (fn [] (this-as this ...))})#2018-09-1108:28ghidenthen you can't use hiccup style and have to fill lots of gaps#2018-09-1108:29ghideni guess that's the price you have to pay?#2018-09-1108:29thhellerif you want hiccup style my not use reagent?#2018-09-1108:29thhelleror rum?#2018-09-1108:30ghideni tried reagent but couldn't export as react component#2018-09-1108:30thhellerand did you ask them?#2018-09-1108:30ghidenreact didn't see it as a react component#2018-09-1108:30ghidenno i didn't#2018-09-1108:31ghideni guess no one is trying to do such things#2018-09-1108:31ghidenit's a very niche needs that i have to achieve#2018-09-1108:32thhellerwell its a self imposed problem due to hiccup-style which I personally got rid off for the most part due to overhead#2018-09-1108:32thhellerbut as I understand it#2018-09-1108:32thhelleryou can call (reagent.core/as-element [your {:hiccup "stuff"}]) and that will return a react element#2018-09-1108:33thhellerso if you need a "component" (defn ^:export my-component [props] (r/as-element [...]))#2018-09-1108:34ghidenas-element works#2018-09-1108:34thhellerthere is also#2018-09-1108:34thhellerhttps://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L106-L124#2018-09-1108:35ghidentried that one too and react didn't recognize as component#2018-09-1108:35thhelleris that not recognized by react?#2018-09-1108:35ghideni used "render" not reagent-render#2018-09-1108:35thhelleryeah dunno. as-element should be fine for whatever#2018-09-1108:36ghidenit seems that deref is not working#2018-09-1108:36ghidenas-element works but you can't retain local state#2018-09-1108:37thhellerhttps://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L61-L67#2018-09-1108:37thhellerI got absolutely no clue about reagent. go ask in #reagent#2018-09-1108:37ghidenyep, thank you#2018-09-1108:37ghidenthat function I haven't tried so i will check it out#2018-09-1108:38ghidenby the way, so you write everything manually?#2018-09-1108:38ghidenrender and stuff?#2018-09-1108:39thhellerif you upgrade to 2.6.7 and run shadow-cljs server and open you can see the shadow-cljs UI preview I'm working on#2018-09-1108:39ghidenoh cool#2018-09-1108:39thhellerthis is written in fulcro and the code is here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/app.cljs#2018-09-1108:39ghidenthank you#2018-09-1108:41thhellerI mostly do this nowadays https://github.com/thheller/shadow/wiki/shadow.markup#2018-09-1108:41thhellereg. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/style.cljs#2018-09-1108:42thhellerthis is a preview though so the UI is pretty darn ugly#2018-09-1108:43thhellerpersonally I find this more pleasant to work with than hiccup style https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/pages/build.cljs#L112-L146#2018-09-1108:44ghidenshadow-client#2018-09-1108:44ghidenis this production ready?#2018-09-1108:45thhellerI use it in production yes. I doubt that anyone else does though. 😉#2018-09-1108:45thhellernever talked about it much#2018-09-1108:47ghidendefinitely i'll check it out#2018-09-1108:48ghidendanke schoen#2018-09-1109:28ghidenreactify-component is working! thanks!#2018-09-1109:07hlolliIs there a way to set goog.global to empty js-object at compile time. I'm trying to compile advanced and my regex replace hook won't cut it then.#2018-09-1109:08thhellerthat will break many things. why would you though?#2018-09-1109:08thhellerie. it will break core.async#2018-09-1109:08thhellerclosure uses goog.global.setTimeout etc#2018-09-1109:08hlolliit's again this worklet environment I'm working with.#2018-09-1109:08hlolliwell, didn't break anything the regex replace.#2018-09-1109:08hlollinot using any setTimeout, it's not allowed to be used there#2018-09-1109:09thhelleryeah if you use no code that uses it then yes that won't break#2018-09-1109:09thhellerbut still .. its dangerous#2018-09-1109:09thhellerwhy is it important?#2018-09-1109:09thhellerjust don't use goog.global and there should be no problem?#2018-09-1109:09hlolliit won't find process or window. it tries to assign the variable still#2018-09-1109:10thhellergoog.global = this is the default#2018-09-1109:10hlolliI think shadow or something uses it to write to it, it if's just an empty object it will work.#2018-09-1109:10thhellerso it just will be nil?#2018-09-1109:10hlolliyes it will be nil#2018-09-1109:10hlolliwould prefer it to be #js {}#2018-09-1109:11hlollithis is my hook (string/replace slur "goog.global=this" "goog.global={}")#2018-09-1109:11thhellerwell did you figure out what it writing to it?#2018-09-1109:11hlollihmm I did figure it out and forgot hehe, I can look#2018-09-1109:11thhellerso the hook you are probably just calling in the wrong place#2018-09-1109:12thhellerie. after optimizations it won't be called that#2018-09-1109:12hlolliah! good point#2018-09-1109:12hlolliI could call it earlier#2018-09-1109:12hlolliI tought maybe there was some option I could use for this#2018-09-1109:12thhellerthere is not no#2018-09-1109:13thhellerI hacked that once or twice before though#2018-09-1109:13thhellerhttps://github.com/thheller/shadow-cljs/blob/ba67074ffb8e300ce9bd66eeedb8557fb9b74313/src/main/shadow/build/closure.clj#L713#2018-09-1109:13thhellerstill do I guess#2018-09-1109:14thhelleryou can do it in a hook although it won't be pretty (as there is no official API for this yet)#2018-09-1109:14hlolliIf I regex replace before optimization, should I spit the result to a disk or change the build-state object that I return?#2018-09-1109:15thheller(update-in build-state [:output [:shadow.build.classpath/resource "goog/base.js"] :js] str/replace ... ...)#2018-09-1109:16hlollibingo, thanks for posting the *-in path, saves me time 🙂#2018-09-1109:16thhellercall that in a build hook in :compile-finish stage#2018-09-1109:17thhellermay need to adjust you regex though since I think it has spaces by default#2018-09-1109:17hlolliyupyup, thanks!#2018-09-1109:21hlolli4wiw, this is a snippet that calls goog.global for example
//iter.js
goog.iter.StopIteration = ('StopIteration' in goog.global) ?
    // For script engines that support legacy iterators.
    goog.global['StopIteration'] :
    {message: 'StopIteration', stack: ''};
#2018-09-1109:23thhellerright#2018-09-1112:13Hukka@thheller Is it possible to use the :closure package provider for only some of the npm dependencies, that are known to survive advanced compilation?#2018-09-1112:16thhellerno.#2018-09-1112:16thhellersay react is compatible but some react-lib you are using is not. react-lib would call the non-optimized react and go boom#2018-09-1112:17thhellermaking it a per-module setting would be a nightmare to configure#2018-09-1113:56thhellerI made a short video preview for the UI work I've been doing recently if someone is interested https://www.youtube.com/watch?v=gyqzLE1VU0s#2018-09-1113:57thhellerfeedback very welcome. I'll post it to the forums soon I guess.#2018-09-1116:38codonovanDoes shadow-cljs support anything like Leins checkout dependencies? https://goo.gl/UajWqf#2018-09-1116:39thheller@codonovan you can just add the :source-paths to your config manually. otherwise no.#2018-09-1116:40codonovanCheers. I'll have a look at doing that#2018-09-1116:41thhellerif you just add the usual dependency but also add the source path the files from the source-path will be used over the files in the jar#2018-09-1116:42thhellerotherwise using lein or deps.edn works too#2018-09-1116:43codonovanI'd totally missed the Leiningen integration part in the docs, reading through that now 🙂#2018-09-1117:59PontusHello, I'm using shadow-cljs with fulcro for my app. I've started experimenting with Gatsby (https://www.gatsbyjs.org/) to generate the static pages for my app (login/registration/landing-page/pricing etc), which I write in JavaScript. The idea is to have a static page as the entry point to the application, instead of the server rendered html I currently have. I thought perhaps I could just build my clojurescript app as an npm module (like described here: https://shadow-cljs.github.io/docs/UsersGuide.html#_convenience_mode) and it does seem to almost work, I can import it from node_modules in gatsby -- but when I try to mount it I just see the application for a brief instant and then it disappears -- and then I get a bunch of errors in the console: Uncaught ReferenceError: clojure is not defined in var G__15382__$1 = (((G__15382 == null))?null:clojure.string.replace(G__15382,/[#\*_^\-\\[\]=>~]/,""));` and similar errors. Could someone point me in the right direction from here to make it work? Also, I don't know if building an npm module is even the right approach here, I'm just experimenting a bit.#2018-09-1118:01thheller@pontus.colliander can you tell which file fails? the file may just be missing the require for clojure.string#2018-09-1118:02thhellerwhich works ok in the browser but not for npm#2018-09-1118:03thhellerie. is the file calling (clojure.string/replace ...) directly or (str/replace ...) via an alias#2018-09-1118:04Pontusyeah it's calling clojure.string/replace directly, I didn't require it#2018-09-1118:05thhelleradding a proper require should fix that then#2018-09-1118:05Pontuscool, I'll try that, thanks!#2018-09-1118:08Pontusyep it worked#2018-09-1119:59wilkerlucio@codonovan another way is using deps.edn, you can use :local/root and point directly to the folder, this way you get source paths and depencies#2018-09-1120:00wilkerlucioIME lein checkouts + cljs don't play nice together#2018-09-1120:04thheller@wilkerlucio how come? I have been using checkouts with cljs code since basically the beginning of my cljs work?#2018-09-1120:05wilkerlucioyou did? every time I tried that it always got the wrong deps, but I'm talking about figwheel times, I guessed that since the classpath calculation is the same (from lein) it would be the same results, but maybe shadow does something different?#2018-09-1120:06thhellerno idea about figwheel but yeah shadow may handle this differently#2018-09-1120:12wilkerlucioglad to hear it works on shadow, I might try again sometime 🙂#2018-09-1208:19pepeHi, is there way to add :closure.defines through shadow/release function API? I need staging and production release builds and cannot get my head around the configuration. Or is there some better way I do not see?#2018-09-1208:23pepeWell I found archive from 2018-06-20 and yes I did not see it. So ignore previous message.#2018-09-1217:19urbanslugThere's a lib I'm trying to use which default exports a class like so export default class RotatedMarker extends Marker https://github.com/verdie-g/react-leaflet-rotatedmarker/blob/master/src/RotatedMarker.jsx#L5#2018-09-1217:21urbanslughowever, what's weird is I can't imports it via :default because I get a shadow require error error but with :as I don't get the error
#2018-09-1217:21urbansluganyway short question is is there something different about importing a default export that is like that?#2018-09-1217:33urbanslug
Uncaught TypeError: Super expression must either be null or a function, not object
    at _inherits (react-leaflet-rotatedmarker.js:26)
    at react-leaflet-rotatedmarker.js:29
    at Object.shadow$provide.module$node_modules$react_leaflet_rotatedmarker$lib$react_leaflet_rotatedmarker (react-leaflet-rotatedmarker.js:28)
    at Object.shadow.js.jsRequire (shadow.js.js:85)
    at Object.shadow.js.require (shadow.js.js:111)
    at ken.utils.leaflet_map.js:4

#2018-09-1217:38urbanslugwith that file being like so https://gitlab.com/snippets/1753417#L26#2018-09-1217:40thheller@urbanslug what is Marker? it is not defined anywhere in that file?#2018-09-1217:41thhellerah hmm#2018-09-1217:41urbanslugOne sec I fetch a link for where it comes from#2018-09-1217:41thhellerit seems to be missing an import#2018-09-1217:41urbanslughttps://github.com/PaulLeCam/react-leaflet#2018-09-1217:41thhellerthis may be a closure bug?#2018-09-1217:41urbanslughmmm#2018-09-1217:42urbanslugSo sometimes it works like when I comment out the import of RotatedMarker and just call Marker#2018-09-1217:42urbanslugbut when I clean#2018-09-1217:42urbanslugit fails#2018-09-1217:43urbanslughmmm#2018-09-1217:43urbanslugany idea how I can get around it? I could whip something up really fast if it'll help#2018-09-1217:43urbanslugsomething with all the tools#2018-09-1217:43thhellerthe error is not from react-leaflet#2018-09-1217:45thhellerok its not a closure bug. the file is just packaged badly#2018-09-1217:46thhellerI don't see how this code can ever work?#2018-09-1217:46thhellerhttps://github.com/verdie-g/react-leaflet-rotatedmarker/blob/master/src/RotatedMarker.jsx#L2-L3#2018-09-1217:46thhellerit has the imports in the original sources#2018-09-1217:46thhelleroh no wait .#2018-09-1217:46thhellerI read the code wrong 😛#2018-09-1217:50thheller@urbanslug "but when I clean" what does this even mean?#2018-09-1217:52thhellerI think this may just be incompatible version wise or so?#2018-09-1217:52thhellerthe problem is that react-leaflet marker is a react element not a class#2018-09-1217:52thhellerthey all seem to be#2018-09-1217:53urbanslugWhen I run shadow-cljs clean#2018-09-1217:53urbanslugSorry I have a bad connection#2018-09-1217:53thhellerthat command doesn't exist#2018-09-1217:54urbanslughaha rm -rf target; rm -rf public/js;#2018-09-1217:54urbanslugwhen I delete all compiled files#2018-09-1217:55thhellerwell of course it fails if you remove all the files?#2018-09-1217:55urbanslugthen recompile#2018-09-1217:56urbanslugOk this is the process:#2018-09-1217:57thhellerit fails directly for me just be requiring it#2018-09-1217:59urbanslugadd ["react-leaflet-rotatedmarker" :default RotatedMarker] replace all Marker calls with RotatedMarker remove/comment out ["react-leaflet-rotatedmarker" :default RotatedMarker] and replace all RotatedMarker calls with Marker shadow-cljs recompiles reloads the page and it works as though I'm calling RotatedMarker clean then try again... rotation doesn't work#2018-09-1217:59urbanslug> it fails directly for me just be requiring it Yeah I tried it in the REPL and it failed on me too#2018-09-1217:59urbanslugwhich is why I thought the problem is related to the import#2018-09-1217:59thhelleryou don't need all this to reproduce#2018-09-1218:00thhellerthe error happens immediately when importing react-leaflet-rotatedmarker#2018-09-1218:00urbanslugwell but it magically works when it's commented out and shadow recompiles believe it or not.#2018-09-1218:01urbanslugwhich is what's weird#2018-09-1218:01urbansluglike what makes it suddenly work when it's commented out and RotatedMarker calls are replaced with Marker ones#2018-09-1218:02thhellerI don't understand? if you comment out the require then it will work yes? the require is what fails?#2018-09-1218:03urbanslugif I comment the import out and revert RotatedMarker calls to Marker, rotation works in the dev server#2018-09-1218:03urbanslugif I were to recompile it goes back to the old Marker#2018-09-1218:04thhellerI really don't follow what you are saying sorry#2018-09-1218:05urbanslugwell it's not deterministic tbh#2018-09-1218:05thhellereverything seems deterministic to me? it fails 100% of the time when I try to import react-leaftlet-rotatedmarker#2018-09-1218:06urbanslugyes in a repl, no?#2018-09-1218:06urbanslugin the browser it works sometimes#2018-09-1218:06thhelleroh .. forgot about the REPL if an import breaks#2018-09-1218:06thhellerit'll just have some weird lingering state or whatever#2018-09-1218:07thhellerso let me break down the problem#2018-09-1218:08urbanslugSomething like
(:require ["react-leaflet" :refer [Marker]]
          ["react-leaflet-rotatedmarker" :default RotatedMarker])

[:> RotatedMarker {...}]

#2018-09-1218:08thhellerreact-leaflet exports an object with many problems which look like they are supposed to be classes#2018-09-1218:08urbanslugfails initially#2018-09-1218:08thhellersome of them are#2018-09-1218:08thhellerie Map, MapComponent ...#2018-09-1218:08thhellerbut Marker is just an object#2018-09-1218:08thhellerand class ... extends <object> is not valid#2018-09-1218:08thhellerthat is what is failing#2018-09-1218:08urbanslugsave and recompile shadow does things and rotation works on Marker
(:require ["react-leaflet" :refer [Marker]]
          ;["react-leaflet-rotatedmarker" :default RotatedMarker]
          )

[:> Marker {...}]
#2018-09-1218:09thhellernow I need to figure out if its a bug in shadow-cljs/closure that Marker is not a class#2018-09-1218:09urbanslughmmm#2018-09-1218:09thhellertypically I just jump into node to verify ...#2018-09-1218:09thheller
$ node
> require("react-leaflet")
ReferenceError: window is not defined
    at /mnt/c/Users/thheller/code/shadow-cljs/node_modules/leaflet/dist/leaflet-src.js:230:17
    at version (/mnt/c/Users/thheller/code/shadow-cljs/node_modules/leaflet/dist/leaflet-src.js:7:65)
>
#2018-09-1218:09urbanslugthat's cool too#2018-09-1218:10thhellerguess I need to webpack to verify instead#2018-09-1218:11urbanslugI'm not sure what's going on anymore 🙂#2018-09-1218:11urbanslughaven't tried to use leaflet in node#2018-09-1218:11thhellerI'm trying to verify if the error happens in shadow-cljs only or in webpack too#2018-09-1218:11urbanslugI see#2018-09-1218:12urbanslugfwiw react-leaflet works in the browser for me all the time but react-leaflet-rotatedmarker is what's weird#2018-09-1218:13thhellerlike I said it may just be version incompatible but the error looks odd enough so it may be an actual bug#2018-09-1218:13thhellergotta verify in webpack to be sure#2018-09-1218:15urbanslugok, cool#2018-09-1218:16thhellerok. I get the same error in webpack#2018-09-1218:17thhellerso its just not compatible. maybe react-leaflet changed something since react-leaflet-rotatedmarker was released#2018-09-1218:18urbanslughmmm#2018-09-1218:18urbanslugI have "react-leaflet": "^2.0.1", and it expects "react-leaflet": "^1.7.8",#2018-09-1218:19urbanslugit also uses a fairly old version of react#2018-09-1218:19thhellerguess thats it then#2018-09-1218:19urbanslugLooking into it#2018-09-1218:19thhellernpm package "react-leaflet-rotatedmarker" expected version "#2018-09-1218:19thhellershadow-cljs even warned about that#2018-09-1218:31urbanslugI didn't see that warning#2018-09-1218:31urbanslugbut I just downgraded to 1.9.1#2018-09-1218:31thhelleryeah its too easy to overlook currently 😉#2018-09-1218:31urbanslugand it works#2018-09-1218:31thhellerI also didn't see it until I looked for it#2018-09-1218:31urbanslug"cleaning" and checking to see if it'll still works#2018-09-1218:32thhelleryou absolutely never need to clean#2018-09-1218:32thhellerbesides what you are cleaning doesn't actually remove the cache#2018-09-1218:33urbanslugSMH#2018-09-1218:33urbanslughahaha wow really?#2018-09-1218:33thhellerthe cache is in .shadow-cljs/builds#2018-09-1218:33thhelleryou are only cleaning the output#2018-09-1218:33thhellerwhich is ok but wouldn't fix a cache problem if there was one#2018-09-1218:34thhellerbut there hasn't been a cache related issue in a while now#2018-09-1218:34urbanslugSo all of this was a placebo? I could've sworn it had an effect#2018-09-1218:34urbanslughaha#2018-09-1218:35thhellerhehe no effect on the compiler no#2018-09-1218:35urbanslugone of those unplug the flash drive safely#2018-09-1218:36urbanslugThanks for your help btw. The problem was really simple but I don't know if I could've figured out because I didn't expect that to be the problem.#2018-09-1218:36urbanslugyup it works#2018-09-1405:43ghidenanyone know a good example of using create-react-class directly from cljs?#2018-09-1407:31thheller@ghiden there is not much to it. (:require ["create-react-class" :as crc]) (def MyComponent (crc #js {:render (fn [] (this-as this ...))}))#2018-09-1407:36ghidenThanks. I didn’t know about this-as thing. Now it works.#2018-09-1407:39thhelleryou can also do wrap this in a proper function if you want#2018-09-1407:39thhellerhttps://gist.github.com/thheller/7f530b34de1c44589f4e0671e1ef7533#2018-09-1407:40thhelleryou'd add the same #js {:render ...} as the last arg to the gobj/extend call#2018-09-1407:40thhellerbut create-react-class is completely fine#2018-09-1407:41ghidenES6 way? I see#2018-09-1410:07ghidenwhat would be a reason when I do "release", I get an error from "reagent" saying "js/React is missing". This is :target :npm-module and :runtime :browser. And I get this error from the consumer of this published npm module.#2018-09-1414:57thheller@ghiden globals work differently in node and the way reagent uses the React global won't work there. Didn't reagent switch to a proper require a while ago? are you on an ancient version?#2018-09-1415:44thhellerit might work if you do (js/goog.exportSymbol "React" react js/global) when (:require ["react" :as react])#2018-09-1420:45ghidenYes. I'm using an old version 0.7.0 due to some dependencies restrictions. This doesn't seem to work. But I just tried 0.8.1 and it works.#2018-09-1416:25Logan PowellSince we're talking about using React from shadow-cljs can I ask a naive question? Is pulling in a third-party React component as simple as npm install react-super-cool-component and then (require ["react-super-cool-component" :as rscc])?#2018-09-1416:25thhelleryes, 95% of the time#2018-09-1501:53Jonhttps://github.com/minimal-xyz/minimal-shadow-cljs-nodejs/issues/2#2018-09-1510:20lxsameerhey folks, I'm new to shadow-cljs, I used :node-script target, and ran shadow-cljs watch app which compiles the app just fine ( it's a hello world ) but when i use node to run the compiled file#2018-09-1510:20lxsameerafter printing hello world it waits and never exit#2018-09-1510:20lxsameeris it normal ?#2018-09-1510:21thheller@lxsameer yeah, it is normal. it is the devtools connection keeping the process alive. if you do not plan on using a REPL into your build then set :devtools {:enabled false} in your build config#2018-09-1510:22thhellerthen the process will exit normally when you are done with it#2018-09-1510:22thhellerhaven't yet figured out how to tell the node process to shut itself down if the only remaining thing is the devtools websocket#2018-09-1510:29lxsameer@thheller thanks, man#2018-09-1510:29lxsameeralso I'm having some problem using cider with shadow-cljs#2018-09-1510:29lxsameeri have to run clj-repl via shadow and use cider-connect and then call (shadow/node-repl)#2018-09-1510:30lxsameeri there any easier way ?#2018-09-1510:31thhellerI don't use emacs so I have no idea sorry. you can run shadow-cljs node-repl and cider-connect#2018-09-1510:31thhellerbut you still need to switch the CLJ repl to CLJS via (shadow/repl :node-repl)#2018-09-1510:31thhellerso thats not any better really#2018-09-1510:32lxsameerthanks man,#2018-09-1510:33lxsameerAlso kudos, So far I liked shadow-cljs so much , It's a really cool piece of software#2018-09-1516:55tony.kayIs there a known issue with current versions of shadow-cljs related to this kind of error:
Error: ENOENT: no such file or directory, open '/Users/.shadow-cljs/builds/babel-worker/dev/out/cljs-runtime/goog.debug.error.js'

#2018-09-1516:56tony.kayThat isn’t the correct folder for .shadow-cljs in any build universe I live in#2018-09-1516:56thhelleroh crap did I publish the dev version again?#2018-09-1516:56thhellerwhich version are you on?#2018-09-1516:56tony.kayI’m on 2.6.7#2018-09-1516:56thhelleroh doh#2018-09-1516:58thhellercompiling ..#2018-09-1517:00thheller@tony.kay should be fixed in 2.6.8. sorry about that.#2018-09-1517:00tony.kayI’ll give it a shot and report back 🙂#2018-09-1517:00tony.kayno prob…I’ve done similar things#2018-09-1517:00thhellerhappens when I deploy after making a dev build#2018-09-1517:00thhellershould really start looking into proper automated deploy stuff#2018-09-1517:00tony.kaydo I need to blow away any caches?#2018-09-1517:00thhellerno#2018-09-1517:00tony.kaycool#2018-09-1517:01tony.kaysame error 😞#2018-09-1517:02thhellerhmm maybe you do then. delete .shadow-cljs/babel-worker#2018-09-1517:02tony.kayalready trying…#2018-09-1517:02thhellerin your project. dunno why its pointed at /Users/.shadow-cljs in the error above#2018-09-1517:03tony.kayme neither…makes no sense#2018-09-1517:03tony.kayit’s like babel misdetected project root#2018-09-1517:03tony.kayworked this time 🙂#2018-09-1517:03thhellerah yeah. that setup doesn't properly invalidate on new versions#2018-09-1517:03thhellerI'll fix that#2018-09-1609:35thhellerhttps://clojureverse.org/t/hud-or-not/2862#2018-09-1611:46ClashTheBunnyHas there been discussion on this topic? https://github.com/yarnpkg/rfcs/pull/101. It seems like all of the node_modules we would like to have wouldn't be there. What would shadow-cljs look like in that universe?#2018-09-1618:38thheller@clashthebunny I saw that but didn't try it yet. The node resolution stuff is pretty flexible so it should be pretty easy to adopt whatever they are doing. I even experimented with downloading/installing npm packages manually in a better suited format that would bypass node_modules as well#2018-09-1712:12HukkaHm. I'm pretty sure my cljs repl seemed to work fine, but now it doesn't have any readline support. That is, can't use previous commands or edit the current line without deleting it#2018-09-1712:12HukkaUsing watch and then cljs-repl app#2018-09-1712:13HukkaSeems like it's trying to start a new nrepl server, failing due to port being bound, and then launching it in different port#2018-09-1712:15thhelleris that a question?#2018-09-1712:15thhellercljs-repl never had any readline support natively?#2018-09-1712:19HukkaI guess I remember wrong... Guess it was from the piggieback days#2018-09-1712:19HukkaWho's this jiyinyiyong? I noticed just now that there's been a bunch of new releases by him, but no commits#2018-09-1712:21thhellerits @jiyinyiyong. he volunteered doing the release stuff on github. he also created http://shadow-cljs.org.#2018-09-1712:24HukkaSo, what's the recommended way to get a fully featured cljs repl with shadow? Go via clj repl and (shadow/repl :app)?#2018-09-1712:25thhellerthere is no readline support there either. the recommended way is to hook up your editor properly.#2018-09-1712:25thhelleror use rlwrap#2018-09-1712:25thhelleror wait till have I the REPL hooked up to the UI (which I'm currently working on)#2018-09-1712:28HukkaI'll use lein repl :connect for now#2018-09-1712:31HukkaHmh, that doesn't work that well 😕. The first time I connect with browser, things are ok. The second time I can't require anything successfully. The require passes, but using the namespace always just complains about ReferenceError#2018-09-1712:33thhellergonna need more info. full errors help a lot.#2018-09-1712:38Hukka#2018-09-1712:38HukkaThe disconnect/connect is when I refresh the page in the browser#2018-09-1712:39thhelleryeah. think about it. the code is loaded by the browser#2018-09-1712:39thhellerif you reload the browser all state it had previously loaded is gone#2018-09-1712:40thhellerthis is kind of a problem with the REPL since the server part still thinks that the namespace is loaded#2018-09-1712:40thhellerthis is true for all CLJS repls though#2018-09-1712:42thhellergets even more fun if you connect with 2 different browsers at different times#2018-09-1712:45thhellerI can probably fix the require to trigger the include again though#2018-09-1712:47HukkaAh, so the require checks some "cache" or something and does a null op?#2018-09-1712:48thhellernot some cache. it only checks the analyzer state and compiles it if necessary. it is not in this case so it does nothing#2018-09-1712:48thhellerbut it should probably still tell the runtime to load the ns#2018-09-1712:50HukkaIs there an explicit command for loading the namespace?#2018-09-1712:56thhellerthinking about it ... yeah this is definitely a bug#2018-09-1712:56thhellerthe watch worker shouldn't make any assumptions about which namespaces the client has loaded#2018-09-1712:57thhellerI'll fix that#2018-09-1713:04claudiuHi, Silly question but can't seem to get it right. I am running some clojurescript code on nodejs and I get goog.net.xmlhttp.js:175 return new XMLHttpRequest(); ReferenceError: XMLHttpRequest is not defined. Any idea how I can set something like global.XMLHttpRequest = require('node-http-xhr'); ?#2018-09-1713:06thhellerbest way probably is to create a helper namespace#2018-09-1713:07thheller(ns my.xhr-shim (:require ["node-http-xhr" :as xhr])) (set! js/global.XMLHttpRequest xhr) and include that in your :main namespace#2018-09-1713:08thhellerprobably as the very first require to ensure its loaded before the others#2018-09-1713:09claudiuawesome 🙂 thank you 🙂#2018-09-1713:20thheller@tomi.hukkalainen_slac the issue is will be fixed in the next release. the require will then do what you'd expect.#2018-09-1713:20thhellerwill release probably later today#2018-09-1713:33HukkaThanks!#2018-09-1803:28wilkerluciohello, I wrote some JS code that uses ES6 destructuring (like const {a, b} = someObject)#2018-09-1803:28wilkerlucioit works fine on dev, but when I do a production build this doens't work, when I log a or b they come undefined#2018-09-1803:28wilkerluciohow can I make so the compilation works right for this case?#2018-09-1803:33wilkerlucioactually, it seems to understand the destructuring, but the JS is mangling the variable names#2018-09-1803:33lwhortonyou need to have a read through https://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/#2018-09-1803:34wilkerluciothis code:
const {svg, svgWidth, svgHeight, data} = settings
#2018-09-1803:34wilkerluciois getting this JS output:
a = c.svg;
        var d = ;
        b = c.uk;
        var e = c.data;
#2018-09-1803:35wilkerlucioc.svg and c.data are correct, but was supposed to be c.svgWidth and c.uk would be c.svgHeight#2018-09-1803:35lwhortonthe compiler mangles every single variable name unless told otherwise. when interfacing between the two environments you must be careful to either annotate the name or use a non-mangled accessor. my favorite is https://github.com/binaryage/cljs-oops#2018-09-1803:35wilkerluciothanks @lwhorton, but I think I'm on a different space here, this is not cljs code, this is js code#2018-09-1803:35lwhortonare you attempting to call the js from cljs?#2018-09-1803:36wilkerlucioyeah, my data gets on JS fine, in my case this is a d3 viz that I wrote on JS, and I require that in a cljs file#2018-09-1803:36wilkerluciowhen I call the JS code, my JS object contains the right keys#2018-09-1803:36wilkerluciobut after destructuring the names get bad (see code above)#2018-09-1803:38wilkerluciokind weird that the names svg and data are correct, but svgWidth and svgHeight are not (got mangled to Am and uk respectively)#2018-09-1803:41lwhortonim not sure i understand how you are invoking the code, but if you are in a compiled cljs file attempting to use javascript source, the cljs (in the optimized js form) will mangle the names, so it’s in effect going from obj.someVar to likely obj.a … but if the js exposes obj.someVar, you will obviously get undefined or null trying to access obj.a.#2018-09-1803:42lwhortonyou can avoid this with externs files, or string property accessors (the compiler doesnt mangle strings in any case, so obj["someVar"] will never change), or use the newer ^js typehint#2018-09-1803:42wilkerluciomy invocation is correct, I tried logging the data, as here:#2018-09-1803:42wilkerlucio
export function renderPathomTrace(element, settingsSource) {
  const settings = initTrace(element, settingsSource)
  const {svg, svgWidth, svgHeight, data} = settings

  console.log("set svg", svgWidth, svgHeight);
#2018-09-1803:43wilkerlucioI know I cna go around using obj["Something"] but then I lose the destructuring properties and have to write a whole lot more#2018-09-1803:43wilkerluciothis is kind looking like a bug somewhere, because I should be able to destructure that#2018-09-1803:43wilkerluciothis is common ES6 code#2018-09-1803:43wilkerlucionothing special about it#2018-09-1803:43lwhortoni also have no idea how shadow-cljs handles js->js transpilation (es6/7/8 babel?), if at all, so i don’t think i can help further#2018-09-1803:44wilkerlucioyeah, my guess is that there is some compiler-option that I might change to get this to work properly#2018-09-1803:44wilkerlucioI know :language-in and :language-out, but I tried some combinations without success#2018-09-1803:47wilkerluciook, I got working with :language-in and :language-out as :ecmascript-next#2018-09-1803:47wilkerluciobut if someone can clarify if that's the correct way to go, please let me know, I think it's fine in my case because it's a chrome extension, so I can count on a updated JS engine#2018-09-1803:48wilkerluciothanks for hanging with me on this one @lwhorton#2018-09-1805:51thheller@wilkerlucio the JS code will go through :advanced but there are likely no externs for those names since no externs inference is done for JS code#2018-09-1805:51thhellerprobably easiest to create a externs/your-build.txt and add svgWidth, svgHeight, svg one line each#2018-09-1805:52thhellertry shadow-cljs check your-build#2018-09-1805:52thhellerit should warn about those#2018-09-1810:05bedersI'm sorry if this is a newbie question, but is it possible to eval some ClojureScript code on the browser console (once I've connected to the server etc.). I find myself jumping back and forth between the REPL (running in IntelliJ) and the Chrome JS console (with CLJS formatting enabled). Would be neat to have it all in one place. How are you working with shadow-cljs and Intellij?#2018-09-1810:14claudiu@beders not sure if this is what you mean. For cursive, shadow-cljs, I connect to remote repl localhost 9000. Then evaluate (shadow/nrepl-select :client_build) this send everything to the browser.#2018-09-1810:21bedersyup, I'm doing (shadow/repl :app) to connect. Which works fine#2018-09-1810:23bedershowever, any js/console.log ends up in the browser console and I got those nicely formatted clj objects in there as well. Would be nice if wouldn't have to go back and forth to see all the output and explore objects interactively. I often then tell Chrome to store an object to a global variable (like temp1) which I then access in the REPL via js/temp1 It's ok, but sometimes it would be quicker if in the browser console, I could just type: shadow.eval('(some clojure-script)');#2018-09-1810:38claudiuAhh no clue. But why not just display it in the repl ? think that should work#2018-09-1811:39thheller@beders that is not currently possible but will be soon#2018-09-1812:04wilkerlucio@thheller cool, in what folder should externs go? root of the project, source root?#2018-09-1812:14wilkerluciook, figured at root#2018-09-1812:57thhelleryes at the root https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2018-09-1815:27dfcarpenterAny examples of integrating scss into a shadow-cljs project?#2018-09-1815:29thhellernot that I'm aware of. I just run https://github.com/sass/node-sass#command-line-interface#2018-09-1821:57richiardiandreadoes defspec work in shadow? for some reason I don't see my tests reported...#2018-09-1821:59thhellercurrently they are not discovered properly no#2018-09-1821:59thhellerhttps://github.com/thheller/shadow-cljs/issues/386#2018-09-1821:59richiardiandreaoh ok#2018-09-1822:00thhellercustom runner with normal cljs.test would work#2018-09-1822:00richiardiandreayep, I think I saw it working with cljs-test-runner#2018-09-1822:00richiardiandreabut yeah I can have a :main#2018-09-1822:27lwhortonis there a way to turn off parallel-build? it’s listed in the user guide as unsupported#2018-09-1822:28thhellerI added support for that recently yes#2018-09-1822:28thhellerbut why would you?#2018-09-1822:28thhellerjust :compiler-options {:parallel-build false}#2018-09-1822:29lwhortonwell have i got a story to tell you …#2018-09-1822:29lwhortonthe short version is the roman01/cljss library has a race condition on atoms, and i think it can be avoided by turning off parallelism#2018-09-1822:31lwhortonif you peek here there’s a ton of context to build up in your head, but you can see there’s a suspicious reset-env! cls followed by a future reference to cls (that’s not a deref): https://github.com/roman01la/cljss/blob/master/src/cljss/builder.clj#L10-L19#2018-09-1822:35thhellerno idea whats happening but all that looks very cache-incompatible#2018-09-1822:35thhellermay need to turn off caching#2018-09-1906:27biscuitpantsshould builds not fail when a warning/error comes up like this?
npm package "slate-react" expected version "
#2018-09-1906:27biscuitpantsor, is it possible to fail builds when this happens?#2018-09-1906:28thhellernot currently possible to fail builds due to that no.#2018-09-1906:29thhellerit is also pretty much unfixable#2018-09-1906:29thhellersince if you install the new version the other packages that were expecting the older versions will complain#2018-09-1906:30biscuitpantsah#2018-09-1906:30biscuitpantscause we hit a compilation bug with this and so i’m a bit weary of it going unnoticed#2018-09-1906:31biscuitpantsis it possible this can happen “randomly”, when deps have not been touched?#2018-09-1906:32thhellerwell if they haven't been touched no#2018-09-1906:32thhellerbut npm install isn't exactly deterministic#2018-09-1906:33thhellerso just running npm install again may produce different results#2018-09-1906:35thhellerI will be adding additional functions for the UI for this so that you can run something like deps-check so see potential version conflicts and fail if there are#2018-09-1906:35thhellerdon't actually need to compile for that#2018-09-1909:24biscuitpantshas anyone ever seen a problem for Symbol is undefined in IE11?#2018-09-1909:25thhellerhttps://kangax.github.io/compat-table/es6/#test-Symbol#2018-09-1909:26biscuitpantsah i see#2018-09-1909:26thhellernot supported in ie11#2018-09-1909:26biscuitpantsnot supported#2018-09-1909:26biscuitpantswould need a polyfill#2018-09-1909:27thhelleryeah#2018-09-1909:28biscuitpantsdo you know of any good polyfills/practices for this?#2018-09-1909:28thhellerdepends on what you are doing and where you are doing it? are you using Symbol or is it a npm lib?#2018-09-1909:32thheller(react uses symbol but self-polyfills it if not available typically)#2018-09-1909:47biscuitpantsnpm lib#2018-09-1909:48biscuitpantsall the online answers point to babel which i cannot/don’t want to use#2018-09-1909:49thhellerhmm closure should detect the use of Symbol and inject accordingly#2018-09-1909:49thhellerdo you have a :language-out configured in your :js-options?#2018-09-1909:50biscuitpantsnope#2018-09-1909:50biscuitpants
{:app {:target     :browser
        :output-dir "resources/cognician/manage/js/"
        :asset-path "/cognician/manage/js/"
        :devtools   {:loader-mode     :eval
                     :ignore-warnings true}
        :modules    {:app {:entries [cognician.manage.app]}}
        ;; build env specific settings
        :dev        {:compiler-options {:ignore-warnings true}
                     :closure-defines  {cognician.manage.DEBUG true
                                        goog.DEBUG             true}}
        ;; production
        :release    {:compiler-options {:infer-externs :auto
                                        :source-maps   true}}}}
#2018-09-1909:51thhellerwhich npm lib?#2018-09-1909:51biscuitpantsslate#2018-09-1909:51biscuitpantsgetting a link now#2018-09-1909:51biscuitpantshttps://github.com/ianstormtaylor/slate#2018-09-1909:53biscuitpantsand with it, slate-react (react counterpart lib)#2018-09-1909:53thhellerI'm a bit busy right now. I'll check later why the symbol polyfill isn't added.#2018-09-1909:54thhellerare you trying in dev or release or both?#2018-09-1909:55biscuitpantsi’ve yet to try dev, i’ll try that now#2018-09-1909:55biscuitpantsno worries man, thank you for the bit of help
#2018-09-1909:55thhelleryou can maybe cheat and just use js/Symbol in your CLJS#2018-09-1909:55thhellerand then set :compiler-options {:rewrite-polyfills true}#2018-09-1909:56thhellerbut the entire polyfills handling is a bit weird right now#2018-09-1909:56thhellersince JS typically injects their own polyfills all over the place#2018-09-1909:57biscuitpantsi’ll try that out, thank you#2018-09-1913:16grounded_sageI'm not quite sure what I am doing wrong. But when I use deps.edn shadow-cljs can't find the namespace I use for clj-run.#2018-09-1913:33thhelleris it on the classpath?#2018-09-1913:52grounded_sageIt runs fine when I am declaring dependencies the normal way in the shadow-cljs.edn file.#2018-09-1913:53thhellerthat doesn't answer my question 😛#2018-09-1913:54grounded_sageWell I assume it is on the classpath. I'm still kind of in the dark on a lot of the JVM stuff. lol#2018-09-1913:54thhellerwhat are your :source-paths? and does the deps.edn have matching :paths?#2018-09-1913:56grounded_sage:source-paths are here. https://github.com/groundedSAGE/shadow-jam/blob/master/shadow-cljs.edn#L3#2018-09-1913:57thhelleryou need to add those via :paths to deps.edn too#2018-09-1914:00grounded_sageThat fixed it. Cheers!#2018-09-1917:02lwhorton@biscuitpants i just did a polyfill straight at the top of my index.html. ie11 doesn’t support Array.find natively, which was about the only older version incompat I found with cljs.#2018-09-1917:02lwhortonbut the rewrite polyfills option didn’t seem to work for that particular case, hence the direct inclusion#2018-09-1917:02biscuitpantsah okay, that’s a good idea. i’ll try that#2018-09-1917:07lwhortoni remember boot-clj has a :checkouts option which was useful for pointing to a local jar instead of a published mvn artifact. to do the equivalent in shadow do I just add the dir to the :source-paths config? i feel like I read somewhere that shadow-cljs cannot modify the classpath above/outside its root, but not sure if that’s right#2018-09-1919:30thheller@lwhorton completely fine to add :source-paths to wherever. the rule for non-project files is only for node_modules#2018-09-1921:28lilactown🤔 I just upgraded from 2.4.24 to 2.6.8 and I'm getting a bunch of inference warnings. I think I ran into this before...#2018-09-1921:29thhellerdo you maybe have a pinned clojurescript version?#2018-09-1921:29lilactownah yeap#2018-09-1921:30lilactownremembering now 😅 I have a pinned clojurescript + closure-compiler that I needed to remove to upgrade#2018-09-1922:10dfcarpenterIs there anything like Prettier for cljs/reagent?#2018-09-2005:53thheller@dfcarpenter Cursive has that built-in but there is also https://github.com/kkinnear/zprint#2018-09-2015:20kanweiis there a way to exclude an optional npm dependency that is pulled in via a library? https://github.com/dbushell/Pikaday/issues/718#2018-09-2015:20kanweipikaday supposedly uses moment optionally but it gets pulled in regardless, there's a hack for webpack but how would I do this in shadow-cljs?#2018-09-2015:27thheller@kanwei you can try :js-options {:resolve {"moment" false}}#2018-09-2015:33kanwei@thheller that didn't work#2018-09-2015:36thhelleroh doh. yeah thats broken.#2018-09-2015:53thheller@kanwei should be working properly in 2.6.9.#2018-09-2016:12kanweinice, thanx#2018-09-2016:13justinleemy code now compiles fine in dev mode, but when i run shadow-cljs run shadow.cljs.build-report app build-report.html i get a spec error when trying to compile specter#2018-09-2016:13justinleehow do i even go about diagnosing the issue?#2018-09-2016:13thhellerpost the error and I can maybe suggest something#2018-09-2016:14thhellerdo you get the error for shadow-cljs release app as well or just be build report?#2018-09-2016:16justinleeactually upgrading from 1.1.0 to 1.1.1 fixed it#2018-09-2016:16justinleeshould have tried that first#2018-09-2016:17thhellerhow do you like specter? I never looked into it much but recently I feel like I've been doing a lot more nested stuff where it supposedly helps?#2018-09-2016:18justinleeI think it is awesome, though I don’t like how big it is, but in reality, I’m writing a very heavyweight app so it doesn’t really matter#2018-09-2016:19justinleefor the front end, I do the standard single-atom state object and have all of my mutators in one place sort of like redux reducers#2018-09-2016:19justinleeeach “reducer” is typically a single specter transform#2018-09-2016:21justinleesomething like this is where it really shines:
(multi-transform
   [ATOM (multi-path
          [:notebook-order (terminal-val notebook-order)]
          [:notebooks      (terminal #(merge-with into % notebooks))])]
   root)
This replaces one key and merges in with another in a single mutation
#2018-09-2016:21justinleeif you have a lot of this kind of stuff it becomes pretty easy to read and is very concise#2018-09-2016:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/repl_system.clj#L137-L149#2018-09-2016:22thhellercode like this .. a nested map where I want to remove stuff by some nested key deep down#2018-09-2016:23thhellerideally I'd want to remove some values but also return the values that were removed besides the updated value#2018-09-2016:23thhellerkinda looks dirty to have the side effect right in there 😛#2018-09-2016:25justinleeright i’m not 100% sure i follow this code but its the kind of thing that specter is good at#2018-09-2016:25thheller{:repl-sessions {1 {:tool-id 1 ...} 2 {:tool-id 2 ...}}#2018-09-2016:26thhellerremove all vals where tool-id = 1#2018-09-2016:26justinleeoh yea it’s great at taht#2018-09-2016:26justinleei think i have code like that#2018-09-2016:27justinleeI do that by-id transform quite a bit so i have a helper:
(defn by-id [id] (fn [elt] (= (:id elt) id)))
(setval [ATOM :uploads ALL (by-id (:id upload))] upload root)
#2018-09-2016:28justinleei’d have to think about how to do that by-vals transform you’re doing#2018-09-2016:29thhelleryeah I guess I'll look into it some more. heard enough interesting things about it by now so it seems to be useful#2018-09-2016:29thhellerjust how much code does it generate though? not a fan if it adds too much code 😛#2018-09-2016:29justinleeit is a bit complicated, i’ll say, but in my opinion it is harder to write than to read. also nathan is quite responsive in #specter. supposedly it is super fast, thought that doesn’t matter to me so much#2018-09-2016:31justinleei’ve chatted with nathan about getting the code size down. he said it is definitely possible to pull in less of the library, but he doesn’t do a lot of cljs so hasn’t messed with it. it adds 188k of unzipped code#2018-09-2016:31justinleethe generated code i think should be a fairly tight loop#2018-09-2016:33thhellerhmm thats quite a lot#2018-09-2016:38jefffriesenI’m trying to autorun tests in cljs files. I’ve used the config in the docs
{...
 :builds
 {:test
  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true}}}
shadow-cljs compile test
The tests run fine:
shadow-cljs - connected to server
[:test] Compiling ...
========= Running Tests =======================

FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9)
expected: (= 1 2)
  actual: (not (= 1 2))

Testing test.classify-test

FAIL in (a-failing-test) (cljs-runtime/cljs/test.cljs:476:9)
expected: (= 1 2)
  actual: (not (= 1 2))

Ran 2 tests containing 2 assertions.
1 failures, 0 errors.
===============================================
[:test] Build completed. (27 files, 1 compiled, 0 warnings, 0.99s)
But then the tests quit and don’t watch for changes. What does autorun do? Is there a way to run the tests when either the tests change or the functions they test change? Thanks
#2018-09-2016:39thhellershadow-cljs compile test compiles once and exits#2018-09-2016:39thhellershadow-cljs watch test will do what you want#2018-09-2016:39thhellerautorun runs the node process to execute the tests#2018-09-2016:40jefffriesenYep - that is working. Thank you#2018-09-2017:29richiardiandreaso I am using bunyan in shadow-cljs and they have a logger object that has a .child method#2018-09-2017:29richiardiandreawhat would be that quickest way to provide or infer this extern so that it does not get renamed?#2018-09-2017:29richiardiandreaI see shadow-cljs check complains about it, which is good#2018-09-2017:31richiardiandreacan I just use ^js?#2018-09-2017:35richiardiandreaah no I can't I am in a macro ...#2018-09-2017:37richiardiandreaok using this for now:
{:optimizations :advanced
 :variable-renaming :off
 :property-renaming :off
 :source-map true}
no time for fiddling 😄
#2018-09-2017:54thheller@richiardiandrea you can use it in a macro just fine. just need to watch how you create the symbol#2018-09-2017:54thhellerdon't turn renaming off. output is gonna be huge#2018-09-2017:54richiardiandrea@thheller isn't ^js a reader macro? maybe I am mistaken#2018-09-2017:55thhellerno it is metadata#2018-09-2017:55richiardiandreauhm ok, it did not work...#2018-09-2017:55thhellerlike I said you need to check how you create the symbol#2018-09-2017:56thhellergenerally (let [the-sym (with-meta (gensym) {:tag 'js})] ...)#2018-09-2017:56richiardiandreaI do:
(defmacro child-logger
  "Create a child logger for the current namespace."
  []
  `(. ^js (deref laputa.event-store.logging/parent-logger)
      (~'child (cljs.core/js-obj
                    :namespace (laputa.event-store.logging/self-ns-name)
                    :level (if ^boolean goog.DEBUG "debug" "info")))))
#2018-09-2017:56richiardiandreaoh#2018-09-2017:56richiardiandreathat is maybe what is not working#2018-09-2017:58thheller
(defmacro child-logger
  "Create a child logger for the current namespace."
  []
  `(.child ^js (deref laputa.event-store.logging/parent-logger)
     (cljs.core/js-obj
       :namespace (laputa.event-store.logging/self-ns-name)
       :level (if ^boolean goog.DEBUG "debug" "info"))))
#2018-09-2017:58thhellertry this. the . may be loosing the meta#2018-09-2017:59thhelleror better yet#2018-09-2017:59richiardiandreaI was trying (let [the-sym (with-meta 'child {:tag 'js})]...#2018-09-2018:00thheller
(defmacro child-logger
  "Create a child logger for the current namespace."
  []
  `(laputa.event-store.logging/get-child-logger
     (cljs.core/js-obj
       :namespace (laputa.event-store.logging/self-ns-name)
       :level (if ^boolean goog.DEBUG "debug" "info"))))
#2018-09-2018:00thhellereliminates all need for tags in the macro#2018-09-2018:00richiardiandrearight 😄#2018-09-2018:00richiardiandrealet me see and thanks 😄 did not know about that trick above#2018-09-2018:00thheller
(defmacro child-logger
  "Create a child logger for the current namespace."
  []
  `(laputa.event-store.logging/get-child-logger
     (laputa.event-store.logging/self-ns-name)
     (if ^boolean goog.DEBUG "debug" "info")))
#2018-09-2018:00thhellerand get rid of the extra js-obj 😉#2018-09-2019:22richiardiandrea@thheller another question, how would you go about not renaming env vars? e.g.: process.env.PGDATABASE#2018-09-2019:24thhellerhmm?#2018-09-2019:25thhellerjs/process.env.PGDATABASE will never be renamed#2018-09-2019:25richiardiandreaoh ok, I was using process.env.PGDATABASE#2018-09-2019:26richiardiandreawhich works at runtime but it is obviously odd...forgot the js/#2018-09-2019:26thhellerdon't you get a warning for that?#2018-09-2019:26richiardiandreanope#2018-09-2019:26richiardiandreawith check yes, I just checked#2018-09-2019:27richiardiandrea
File: /home/arichiardi/git/laputa/event-store/src/laputa/event_store/db/config.cljs:31:19
 Property PGDATABASE never defined on process.env
#2018-09-2019:27thhellerhmm strange. I would expect a warning for process.env.PGDATABASE#2018-09-2019:28thhellerhmm yeah no warning. thats a bug I think.#2018-09-2019:28richiardiandreaok will open an issue#2018-09-2019:28thhellercheck with plain CLJS first#2018-09-2019:29thhellerdunno if its a bug in shadow-cljs or CLJS#2018-09-2019:29richiardiandreakk#2018-09-2019:29richiardiandreastill getting the warnings with check after js/ was added#2018-09-2019:32thhellerhmm I don't?#2018-09-2020:29richiardiandreaOk well, might be something here ;)#2018-09-2021:34richiardiandrea@thheller do you use a monorepo? if yes do you have a shadow-cljs server started in the monorepo root?#2018-09-2021:34richiardiandrea(is it possible?)#2018-09-2021:35thhellernot sure I understand the question. define a monorepo? I have one repo per project? is that a monorepo?#2018-09-2021:37richiardiandreayep so I have this:
├── cljs-template
├── commit-event-fn
├── continuous-delivery
├── dashboard
├── lerna.json
├── metrics-fn
├── package.json
├── query-events-fn
├── README.md
├── registry-fn
├── scrutinizer-fn
each folder has a shadow-cljs file, I was wondering if I could share the jvm
#2018-09-2021:38thhellerno#2018-09-2021:39thhellerif you look at the shadow-cljs repo there are quite a few builds now that actually do stuff and aren't just for testing#2018-09-2021:39thhellereg. the ui or cli builds#2018-09-2021:39thhellerthey output to packages/shadow-cljs for example#2018-09-2021:40richiardiandreaI could probably have a shadow.edn in the root containing all the builds for the subrepos..#2018-09-2021:40thhellerso the output itself is isolated#2018-09-2021:40richiardiandreaoh ok yeah#2018-09-2021:40thhellerand the sources are in their own namespaces#2018-09-2021:40richiardiandreawill have a look#2018-09-2021:43thhellerhttps://github.com/thheller/shadow-cljs/tree/master/packages three of those are actual npm packages#2018-09-2021:44thhellerall their sources are in src/main not in packages/... at all#2018-09-2021:44richiardiandreayep I see, we have a different folder layout#2018-09-2021:45richiardiandreathat's ok, just wondering, would've been cool useful#2018-09-2021:46thhellerI never saw a reason to organize the code that way since it just gets annoyingly hard to share code#2018-09-2021:47thhellerbut no idea about your project or how you organize it with multiple people#2018-09-2021:48richiardiandreayeah we moved away from that to make sure we isolate lambda development...#2018-09-2021:49richiardiandreatrying to make sure what we share goes in a lib but has some friction so that it does not become a kitchen sink#2018-09-2021:50thhellerwe already use namespaces to organize code so for CLJS I see no reason they can't all be on the same source-path#2018-09-2021:50thhellersince building the code will only include whatever is used#2018-09-2021:52richiardiandreaI know I know how you feel about that and that's ok in single project, everything is on the classpath, but it was getting messy...#2018-09-2021:52richiardiandreaso the team decided to split#2018-09-2021:52richiardiandreawas not even my own decision per se#2018-09-2021:52thhelleryeah I can see that too#2018-09-2021:54richiardiandreastill very happy with shadow-cljs, I could potentially include everyting in a big deps.edn + shadow-cljs.edn at some point...will see#2018-09-2021:55thhellerwell its just data so if the builds have unique names you can just slurp and merge em all 😉#2018-09-2122:33lilactownhey, I've been trying to get test.check/defspec working and just saw this issue#2018-09-2122:33lilactownhttps://github.com/thheller/shadow-cljs/issues/386#2018-09-2122:33lilactownis there any work around right now?#2018-09-2122:34thhelleryeah copy this but call cljs.test instead of shadow.test#2018-09-2122:34thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#2018-09-2122:34thhellerso ct/run-all-tests instead of st/...#2018-09-2122:37thhellermust also set (ns ^:dev/always ...) though since its a macro and must always be recompiled to pick up new tests#2018-09-2123:41richiardiandreaI thought Thomas you had already handled :reload in a (require) but i still see:
Circular dependency detected: laputa.event-store.db -> laputa.event-store.db
#2018-09-2206:50thhellerhttps://github.com/thheller/shadow-cljs/issues/367#2018-09-2206:51thhellerI have not. I have a pretty big REPL rework in progress. I'll get to it once thats done#2018-09-2200:44lilactownI'm still running into instances where it's not picking up my defspec after switching to the cljs.test/run-all-tests#2018-09-2201:17lilactownI ended up adding the hack to the clojure.test.check defspec macro#2018-09-2206:48Jakub Holý (HolyJak)Hello! I have noticed that https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_2 says to use :devtools {:repl-init-ns my.app while https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL says to use :nrepl {:init-ns my.repl}. Are these two the same thing or unrelated? Thanks!#2018-09-2206:48thhellerunrelated#2018-09-2206:49thhellerone is for the nrepl CLJ connection and the other is for the build CLJS repl#2018-09-2216:10lilactownI’m trying to get started with evaluating some code using cljs.js, but for some reason I can’t use any cljs.core vars#2018-09-2216:11lilactownthis is what I’m doing right now:
(defonce !results (atom nil))

(defn print-results [results]
  (reset! !results results))

(cljs/eval-str
 (cljs/empty-state)
 "(def asdf 1)"
 'visual-spec.eval-test
 {:eval cljs/js-eval}
 print-results)
#2018-09-2216:12thhelleryour first time using self-hosted?#2018-09-2216:12lilactownyes#2018-09-2216:12thhelleryou need to "bootstrap" the entire thing and load the analyzer data#2018-09-2216:12thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2018-09-2216:20lilactowndo I need to watch the :bootstrap-support build or just compile it once?#2018-09-2216:21thhellereither works. it doesn't support any REPL or live reloading anyways#2018-09-2216:29lilactowndo I need to call boot/init on each reload of my code? or is it just called once and then I can keep calling compile-it?#2018-09-2216:34thhellerdepends on how you manage your state?#2018-09-2216:47lilactownI guess, is there any reason I wouldn’t call boot/init on each hot reload?#2018-09-2216:48thhellerI don't know how you manage your state and cannot answer that#2018-09-2216:48thhelleryou can absolutely call it all the time#2018-09-2216:48thhellerbut generally I doubt that thats useful#2018-09-2216:48thhellerunless your index changes often#2018-09-2216:49lilactownI’m trying to figure out why I would care how my state is managed based on using the shadow-cljs bootstrapper#2018-09-2216:49lilactownwhat’s “index” in this context?#2018-09-2216:49thhellerdid you read https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html?#2018-09-2216:49thheller> The :bootstrap build itself will generate an “index” with useful information for the compiler.#2018-09-2216:49thhellerthe boostrapper itself doesn't manage any state#2018-09-2216:50thheller(defonce compile-state-ref (env/default-compiler-env))#2018-09-2216:50thhellerthis is the state that is important#2018-09-2216:50lilactownsorry I skimmed it 😛#2018-09-2216:50lilactownI see#2018-09-2216:51thhellerif your bootstrap support build doesn't change (eg. you don't watch it) then you probably only need to call boot/init once#2018-09-2216:52thhellerI don't do any self-host development myself so I can't really recommend what the best approach would be#2018-09-2216:52thhellerno idea if you'd want to reset the compiler-env on every reload or not#2018-09-2216:58lilactowngotcha. I understand now. thank you#2018-09-2218:12lilactownwould there be some reason that a build with :module-loader true and then trying to bootstrap would be incompatible?#2018-09-2218:14thhellerit depends. self-host can be tricky that way#2018-09-2218:14thhellerit won't be aware of module loader at all#2018-09-2218:14lilactownwhat I’m seeing is that if I add a module that depends on shadow.cljs.bootstrap.browser, it immediately breaks all of my modules#2018-09-2218:14lilactown
/assets/js/cljs-runtime/shadow.module.main.append.js:4 Uncaught (in promise) TypeError: Cannot read property 'env' of undefined
    at eval (/assets/js/cljs-runtime/shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:2188)
    at loadPending (main.js:2957)
    at main.js:2990
#2018-09-2218:15thhellerah. the shadow.cljs.boostrap.env ns may have been moved#2018-09-2218:15thhellerit must always be in the default module#2018-09-2218:16thhellertry adding it to your default module#2018-09-2218:16thhellerthe one that everything else depends on#2018-09-2218:17lilactownyep. adding [shadow.cljs.bootstrap.env] to the requires in my main module immediately fixed all of my modules#2018-09-2218:50Jakub Holý (HolyJak)Hello! I get this in my trivial browser app, in Chrome Console: > main.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined where main.js is a module compiled by hdow cljs. Any idea why that could be?#2018-09-2218:52thhellerhmm do you use more than one module?#2018-09-2218:53Jakub Holý (HolyJak)Yes, do:
:modules {:shared {:entries []}
          :main {:entries [app.main] :depends-on #{:shared}}
          :brand {:entries [app.templates.brand] :depends-on #{:shared}}}
#2018-09-2218:53Jakub Holý (HolyJak)(I am trying to create a separate bundle for my "home" page and my "brand" page so each loads faster)#2018-09-2218:53thhelleryou must load the shared before main#2018-09-2218:53Jakub Holý (HolyJak)uh, just realized that 🙂 Thanks a lot!#2018-09-2218:55Jakub Holý (HolyJak)BTW what does > assets/index.html(please link it to target/index.html) looks like: in the Begginner Guide mean? Should I ln -s ../assets/index.html inside target or what?#2018-09-2616:41JonI should fix...#2018-09-2616:44JonI'm changing it to "copy". do you think it being easier to understand?#2018-09-2218:56thhellerhmm?#2018-09-2219:06thheller@holyjak I can't find that anywhere in the guide? what are you referring to? https://shadow-cljs.github.io/docs/UsersGuide.html?#2018-09-2310:13Jakub Holý (HolyJak)Sorry for the delay @thheller! http://shadow-cljs.org/ -> Beginner Guide (== https://medium.com/@jiyinyiyong/a-beginner-guide-to-compile-clojurescript-with-shadow-cljs-26369190b786)#2018-09-2311:40huygnhi, I'm trying to setup code splitting with below config. I have app.main which is an spa router and 2 pages (home & todo)
:modules {:shared {}
                          :main {:entries [app.main]
                                 :depends-on #{:home :todo}}
                          :home {:entries [app.pages.home]}
                          :todo {:entries [app.pages.todo]}}
however doing so yields two modules without deps, please specify which one is the default. but those 2 pages dont really depends on anything except rum. Am I missing something here? 🤔
#2018-09-2406:50Jakub Holý (HolyJak)perhaps the error message could be improved? I too got it and was baffled, @thheller; perhaps: > two modules without deps, perhaps they should both depend on a third, "shared" module (with empty entries)? see <url to docs for this>#2018-09-2312:25thheller@gnhuy91 you need to specify a shared module. so its probably the reverse. :home depends-on #{:main} as well as todo depends on #{:main}#2018-09-2312:26thhellerapp.main will always be loaded and home and todo on demand. so they depend on :main#2018-09-2312:30huygnarh thanks! so I misunderstood it there 👌#2018-09-2318:59huygnhi, on "loading code dynamically", how can I access to the loaded module? (loader/load "extra") resolver only indicate loaded/failed status and does not return the module itself. (in webpack it is import(() => "./foo").then(foo => foo.default))#2018-09-2319:01thhellerwell thats where it gets a bit tricky#2018-09-2319:01thhellerthe namespaces that are part of the module you loaded are accessible#2018-09-2319:01thhellerbut the compiler doesn't handle this very nicely#2018-09-2319:02thhelleryou can use resolve to get to a function you defined#2018-09-2319:02thheller((resolve 'your.ns/foo) 1 2 3)#2018-09-2319:03thhellerwould basically call (your.ns/foo 1 2 3)#2018-09-2319:03huygnlet me try, thanks!#2018-09-2319:05huygnmindblow :exploding_head: , it works#2018-09-2319:07huygnmore tricky than i thought, was building a loadable component wrapper to handle dynamic rum components#2018-09-2319:07huygnthank alots 🙏#2018-09-2319:08thhelleryeah closure handles modules statically so it works a bit differently than in webpack#2018-09-2321:39lilactownis there any analyzer metadata I can get out of a bootstrapped environment?#2018-09-2321:40lilactownI’m trying to get line number and position of a particular token (e.g. a path into a map)#2018-09-2321:41thhelleryou can modify cljs.tools.reader to do what you need#2018-09-2321:42thhellerit doesn't keep line/col metadata on keywords by default#2018-09-2321:45lilactowndoes it keep line/col metadata on other values?#2018-09-2321:46thhelleredn reader no. cljs reader yes#2018-09-2321:46thhellernot on keywords, numbers, strings, bools#2018-09-2321:48thhellermaybe this helps. I tried something related a while ago https://dev.clojure.org/jira/browse/TRDR-42#2018-09-2321:50lilactown🤔 is there something I’m doing wrong here?
(-> (reader/read-string "{:foo 5
                          :bar [1 2 3]}")
    (meta))
comes back as nil
#2018-09-2321:51thhelleryou are using the EDN reader#2018-09-2321:51lilactown
(require ...
            [cljs.tools.reader :as reader])
?
#2018-09-2321:53thhellerhttps://github.com/clojure/tools.reader/blob/master/src/main/cljs/cljs/tools/reader/reader_types.cljs#L227#2018-09-2409:20Jakub Holý (HolyJak)Can anybody shed a light why shadow-cljs release hides js/React from my code? I use shdow-cljs to produce an npm-module, which is then consumed by a .js file, processed by Webpack (during a gatsby build run). When I shadow-cljs compile app then everything works just fine. However, when I do shadow-cljs release app instead then webpack fails with > WebpackError: js/React is missing (thrown from https://github.com/reagent-project/reagent/blob/v0.7.0/src/reagent/impl/util.cljs#L12) Why? What can I do to fix it? (The .js file that requires my cljs-based npm module does import React) Thansk a lot!!!! (Here is the code: https://github.com/jakubholynet?tab=repositories)#2018-09-2409:21thheller@holyjak shadow-cljs doesn't hide anything from you. the pattern reagent uses is just not compatible with node#2018-09-2409:21thhelleryou should upgrade to the latest reagent version#2018-09-2409:23Jakub Holý (HolyJak)I did not mean to defame shadow-cljs 🙂 Thanks a lot, awesome that you know what the problem is. However I cannot upgrade easily as I have to use React 15 and Reagent 0.8 requires 16. Do you think that somebody in #reagent could help? Or is there anything else I can do? I guess what Reagent does somehow fails under :advanced for some reason?#2018-09-2409:22thheller0.8.1 I believe#2018-09-2409:24thhelleryou can try to call (set! js/global.React react) with (:require ["react" :as react])#2018-09-2409:26thhellerwhy does reagent require v16? I don't think thats true#2018-09-2409:26thhellernote that the cljsjs version it depends on it completely irrelevant as that won't be used#2018-09-2409:26thhellerit will use the react version you installed via npm in your project#2018-09-2409:26thhellerso if you install v15 you should be good to go?#2018-09-2409:57Jakub Holý (HolyJak)I don't know, I saw that reagent v8 updated to React 16 and I have assumed it is not backwards compatible with 16 but I haven't really tried. I will try to upgrade then. I have v15 installed (and it worked in dev, non-release). I will also try the call you suggested. Thanks a lot, you are extremely helpful!#2018-09-2409:58thhellertry upgrading first. I don't think reagent adopted any of the newer lifecycle methods yet so it shouldn't matter#2018-09-2409:58thhellerit works in dev because the development loader works differently there#2018-09-2410:28thheller@holyjak I think you are making things a bit more complicated than they need to be#2018-09-2411:26thhellerdamn gatsby is one gigantic mess#2018-09-2411:26thhellerseriously wtf ...#2018-09-2412:27Jakub Holý (HolyJak)Thanks a lot, upgrade to Reagent 0.8 solved the problem and it now works with release just nicely#2018-09-2412:40thheller@holyjak I got curious about the gatsby stuff an implemented a minimal example of how I would approach this#2018-09-2412:41thhellerhttps://github.com/thheller/gatsby-cljs/blob/master/src/main/demo/gatsby.cljs#2018-09-2412:41thheller
(defn page-index
  {:export true
   :gatsby/page "index"
   :gatsby/graphql
   "query IndexQuery {
      site {
        siteMetadata {
          description
        }
      }
   }"}
  [props]
  (r/as-element
    [:h1 "hello world!"]))
#2018-09-2412:41thhellerbasically the idea is that you create a normal clojure function for each page#2018-09-2412:41thhelleradd some metadata to it that a build hook will then extract and create the src/pages files#2018-09-2412:42thhellerit bypasses all the other gatsby stuff basically. you just write a function per page#2018-09-2412:43thhellernot a clue how the dynamic createPages stuff would work but should be simple to hook up AFAICT#2018-09-2412:43thhellergranted that I would not expect anyone to know how to write the hook but its pretty simple https://github.com/thheller/gatsby-cljs/blob/master/src/main/shadow/gatsby.clj#2018-09-2412:44thhellercould be made easier with macros properly but I didn't use any since metadata is probably enough#2018-09-2508:14Jakub Holý (HolyJak)Man , you rock! I have been working on this in the past three days and you came in a short time with a better and much nicer solution! Thank you!#2018-09-2413:14ClashTheBunnyHey there! I'm wondering how to fix an update to shadow-cljs. I updated it and now I get The required namespace is not available.#2018-09-2413:15ClashTheBunnyThe full error is
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2557444b4844564a4b65464440564457"}, :content ("[email protected]")}
#2018-09-2413:16ClashTheBunnyI went from 2.5.1 to 2.6.9.#2018-09-2413:54ClashTheBunnyI may have upgraded from 2.0.144, but I don't have the logs from when it worked last.#2018-09-2414:12thheller@clashthebunny did you update devcards in the meantime too? or mess with your source-paths in any way?#2018-09-2414:14thhellerdevcards.core_card isn't part of devcards itself? is that one of your sources?#2018-09-2414:17thhelleryou can run shadow-cljs clj-repl (shadow/find-resources-using-ns 'devcards.core_card) to figure out who is using that#2018-09-2414:40ClashTheBunnyI did update it at the same time!#2018-09-2414:40ClashTheBunnyI'll keep digging. Thanks for the pointers.#2018-09-2414:52Nolanhey everyone, saw https://clojureverse.org/t/shadow-cljs-and-leinigen-and-npm-oh-my/2735/22 and have been able to connect vim-fireplace to the nREPL started by shadow-cljs watch service I ran :Piggieback :service as well with no confirmation if that worked properly. When I try to evaluate a form that uses reader conditionals (just :clj and :cljs) in a .cljc, I get “Conditional read not allowed”. Is this because :Piggieback is failing, or some other configuration issue?#2018-09-2416:42thheller@nolan its not shadow-cljs since I can use them just fine in the REPL directly
[2:1]~cljs.user=> #?(:cljs 1)
1
#2018-09-2416:43thhellerseems to work fine over nrepl as well so its probably vim-fireplace?#2018-09-2416:44thhellerlooking at the full exception should tell you#2018-09-2416:46Nolanright on. i am able to do the same in the repl directly. not a huge issue. I’ll check into it a bit more later. thanks!#2018-09-2419:00lilactownabout every other time I run my builds, I see this error message:
failed to require :target :browser-test for build :browser-tests
CompilerException: java.lang.RuntimeException: Unable to resolve symbol: defelem in this context, compiling:(hiccup/page.clj:20:1)
	clojure.lang.Compiler.analyze (Compiler.java:6792)
	clojure.lang.Compiler.analyze (Compiler.java:6729)
	clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3813)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7005)
#2018-09-2419:00lilactown
RuntimeException: Unable to resolve symbol: defelem in this context
	clojure.lang.Util.runtimeException (Util.java:221)
	clojure.lang.Compiler.resolveIn (Compiler.java:7299)
	clojure.lang.Compiler.resolve (Compiler.java:7243)
#2018-09-2419:07thhellerhmm this was supposed to be fixed a while ago. which version are you on?#2018-09-2419:08lilactown2.6.8. it started happening after upgrade to that version from 2.4.x#2018-09-2507:38thheller@lilactown I pushed 2.6.10 which should fix this now. its a weird race condition but its behind a lock now so it should be ok.#2018-09-2514:06lilactown🙇 thank you!#2018-09-2514:10ClashTheBunny#2018-09-2514:11ClashTheBunny#2018-09-2514:18thheller@clashthebunny please grep for devcards in your project. the file must come from somewhere#2018-09-2514:18thhellerthere is nothing devcards related in shadow-cljs itself so I have no clue where things are coming from#2018-09-2514:19ClashTheBunnySorry, I forgot to add that part.
deps.edn:        devcards {:mvn/version "0.2.5"}
package.json:    "devcards": "shadow-cljs watch devcards",
public/cards.html:        <script>devcards.core_card.init();</script>
shadow-cljs.edn:                :devcards {:target :browser
shadow-cljs.edn:                            {:entries [devcards.core_card]}}
shadow-cljs.edn:                           :dev {:compiler-options {:devcards true}}
src/cljs/devcards/core_card.cljs:(ns devcards.core_card
src/cljs/devcards/core_card.cljs:   [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
src/cljs/devcards/core_card.cljs:   [devcards.core :as dc]
src/cljs/devcards/core_card.cljs:   [devcards.core-table :as table]
src/cljs/devcards/core_card.cljs:                                              :filter (if (not-empty (get-in @devcards.core_card/card-state [:card :image-data]))
src/cljs/devcards/core_table.cljs:(ns devcards.core-table
src/cljs/devcards/core_table.cljs:   [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
src/cljs/devcards/core_table.cljs:   [devcards.core :as dc]
#2018-09-2514:20ClashTheBunnyAnd here is shadow-cljs.edn:
{:deps  true
 :nrepl {:port 8230}

 ; :cache-blockers #{deck-builder.macros}
 :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]

 :builds       {:browser
                {:target           :browser
                 :modules          {:base {:entries [deck-builder.core]}}
                 :output-dir       "public/js/compiled"
                 :asset-path       "/js/compiled"
                 :devtools         {:http-root    "public"
                                    :http-handler shadow.http.push-state/handle
                                    :http-port    8280
                                    :after-load   deck-builder.core/mount-root
                                    :preloads     [devtools.preload]}}

                :browser-test
                {:target           :browser-test
                 :test-dir         "out/browser-test"
                 ;; :compiler-options {:closure-defines  {re-frame.trace.trace-enabled? true}}
                 :devtools         {:http-root    "out/browser-test"
                                    :http-port    8290}}

                :karma-test
                {:target           :karma
                 :output-to        "out/karma/test.js"}

                :devcards {:target :browser
                           :output-dir "public/js/compiled"
                           :asset-path "/js/compiled"

                           :modules
                           {:main
                            {:entries [devcards.core_card]}}

                           :dev {:compiler-options {:devcards true}}
                                                    ;; :closure-defines {goog.DEBUG        true}}}
                                                    ;;                   day8.re-frame.tracing.trace-enabled? true}}}

                           :devtools
                           {:autoload true
                            ;; :before-load app.core/before-load
                            ;; :after-load app.core/after-load
                            ;; :http-handler shadow.http.push-state/handle
                            ;; :preloads     [day8.re-frame-10x.preload]
                            :http-root "public"
                            :http-port 3449}}}}
#2018-09-2514:20thhellerso there it is? (ns devcards.core_card#2018-09-2514:20thhellerwhat is the full ns form? I fixed a bug in the ns form that maybe that ns form slipped through?#2018-09-2514:20ClashTheBunnySeems to be, and it's in my path:
~/c/deck-builder ❯❯❯ cat deps.edn                                                                                                                                                                                                                                                                             master ✭ ✖ ✱ ◼
{:deps {re-frame {:mvn/version "0.10.5"}
        day8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}
        binaryage/devtools {:mvn/version "0.9.10"}
        proto-repl {:mvn/version "0.3.1"}
        devcards {:mvn/version "0.2.5"}
        cider/cider-nrepl {:mvn/version "0.18.0"}
        refactor-nrepl {:mvn/version "2.4.0-SNAPSHOT"}
        secretary {:mvn/version "1.2.3"}
        venantius/accountant {:mvn/version "0.2.4"}
        org.clojure/data.csv {:mvn/version "0.1.4"}
        json-html {:mvn/version "0.4.4"}
        io.joshmiller/exif-processor {:mvn/version "0.2.0"}
        cljs-ajax {:mvn/version "0.7.4"}
        camel-snake-kebab {:mvn/version "0.4.0"}
        thheller/shadow-cljs {:mvn/version "2.6.10"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}

 :paths ["dev"
         "test/cljs"
         "src/clj"
         "src/cljs"]


 :aliases {:outdated {:extra-deps {olical/depot {:mvn/version "1.2.0"}}
                      :main-opts ["-m" "depot.outdated.main"]}}}
#2018-09-2514:21ClashTheBunnyIt's significant, sorry for the spam:
(ns devcards.core_card
  (:require-macros
   [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
   [cljs.test :as t :include-macros true :refer-macros [testing is]]
   [deck-builder.macros :as dm])
  (:require
   ["rmwc/Select" :refer (Select)]
   ["rmwc/Grid" :refer (Grid GridCell)]
   ["rmwc/Chip" :refer (Chip
                        ChipText
                        ChipIcon
                        ChipSet)]
   ["rmwc/Card" :refer (Card
                        CardPrimaryAction
                        CardMedia
                        CardAction
                        CardActions
                        CardActionButtons
                        CardActionIcons)]
   ["rmwc/Drawer" :refer (Drawer DrawerHeader DrawerContent)]
   ["rmwc/TextField" :refer (TextField TextFieldIcon TextFieldHelperText)]
   ["rmwc/Fab" :refer (Fab)]
   ["rmwc/Radio" :refer (Radio)]
   ["rmwc/Button" :refer (Button ButtonIcon)]
   ["rmwc/List" :refer (ListItem ListItemText)]
   ["rmwc/Toolbar" :refer (Toolbar
                           ToolbarRow
                           ToolbarSection
                           ToolbarTitle
                           ToolbarMenuIcon
                           ToolbarFixedAdjust
                           ToolbarIcon)]
   ["rmwc/Shape" :refer (ShapeContainer)]
   ["rmwc/Typography" :refer (Typography)]
   ["rmwc/Icon" :refer (Icon)]
   ["rmwc/Elevation" :refer (Elevation)]
   [json-html.core :refer (edn->html)]
   [reagent.core :as r]
   [ajax.core :as ajax]
   [ajax.protocols :as protocols]
   ;; [re-frame.core :as rf]
   ;; [re-frame.db :refer [app-db]]
   [devcards.core :as dc]
   [devcards.core-table :as table]
   [deck-builder.views :as v]
   [deck-builder.core :as c]
   [clojure.string :as str]))
#2018-09-2514:21thhelleryep there it is#2018-09-2514:22thheller[cljs.test :as t :include-macros true :refer-macros [testing is]]#2018-09-2514:22thhellerthis is not valid#2018-09-2514:22ClashTheBunnyNice!#2018-09-2514:22thhelleralthough I wonder why you are not getting the correct error message to tell you this#2018-09-2514:22ClashTheBunnyI assume I just change it to the same as the devcards include.#2018-09-2514:23thhellerjust put [cljs.test :as t :refer [testing is]] into your :require not :require-macros#2018-09-2514:24thhellerdo me a favor and delete your .shadow-cljs/jar-manifests directory and then start the server again as you did above#2018-09-2514:25thhellerhmm no wait that won't change anything. the file isn't in a jar#2018-09-2514:25thhellerI'm confused why are not getting the correct error
#2018-09-2514:25thhellerwill try to reproduce#2018-09-2514:31ClashTheBunnyMuch better error now:
[:devcards] Compiling ...
------ ERROR -------------------------------------------------------------------
 File: /tank/rmason/code/deck-builder/src/cljs/devcards/core_table.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns devcards.core-table
-------^------------------------------------------------------------------------
Invalid namespace declaration
-- Syntax error -------------------

  (... ... (:require-macros
            [devcards.core
             :as
             dc
             :refer
             [defcard defcard-rg deftest mkdn-pprint-str]]
            [cljs.test :as t :include-macros true :refer-macros [testing is]]
            [deck-builder.macros :as dm]) ...)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input

-- Relevant specs -------

:shadow.build.ns-form/ns-form:
  (clojure.spec.alpha/cat
   :ns
   '#{clojure.core/ns}
   :name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :meta
   (clojure.spec.alpha/? clojure.core/map?)
   :clauses
   :shadow.build.ns-form/ns-clauses)

-------------------------
Detected 1 error

--------------------------------------------------------------------------------
   2 |   (:require-macros
   3 |    [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
   4 |    [cljs.test :as t :include-macros true :refer-macros [testing is]]
   5 |    [deck-builder.macros :as dm])
--------------------------------------------------------------------------------

:error
[1:0]~shadow.user=>
#2018-09-2514:31thhellerI don't understand why you didn't get that before though#2018-09-2514:32ClashTheBunnyAnd it's from the old problem. The ns form doesn't contain that anymore.#2018-09-2514:33thhellerhmm?#2018-09-2514:33ClashTheBunnyI moved cljs.test down below. It's not in the :require-macros section anymore:
1 (ns devcards.core_card
    2   (:require-macros
    3    [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
    4    [deck-builder.macros :as dm])
    5   (:require
    6    ["rmwc/Select" :refer (Select)]
    7    ["rmwc/Grid" :refer (Grid GridCell)]
    8    ["rmwc/Chip" :refer (Chip
    9                         ChipText
   10                         ChipIcon
   11                         ChipSet)]
   12    ["rmwc/Card" :refer (Card
   13                         CardPrimaryAction
   14                         CardMedia
   15                         CardAction
   16                         CardActions
   17                         CardActionButtons
   18                         CardActionIcons)]
   19    ["rmwc/Drawer" :refer (Drawer DrawerHeader DrawerContent)]
   20    ["rmwc/TextField" :refer (TextField TextFieldIcon TextFieldHelperText)]
   21    ["rmwc/Fab" :refer (Fab)]
   22    ["rmwc/Radio" :refer (Radio)]
   23    ["rmwc/Button" :refer (Button ButtonIcon)]
   24    ["rmwc/List" :refer (ListItem ListItemText)]
   25    ["rmwc/Toolbar" :refer (Toolbar
   26                            ToolbarRow
   27                            ToolbarSection
   28                            ToolbarTitle
   29                            ToolbarMenuIcon
   30                            ToolbarFixedAdjust
   31                            ToolbarIcon)]
   32    ["rmwc/Shape" :refer (ShapeContainer)]
   33    ["rmwc/Typography" :refer (Typography)]
   34    ["rmwc/Icon" :refer (Icon)]
   35    ["rmwc/Elevation" :refer (Elevation)]
   36    [json-html.core :refer (edn->html)]
   37    [reagent.core :as r]
   38    [ajax.core :as ajax]
   39    [ajax.protocols :as protocols]
   40    ;; [re-frame.core :as rf]
   41    ;; [re-frame.db :refer [app-db]]
   42    [devcards.core :as dc]
   43    [devcards.core-table :as table]
   44    [deck-builder.views :as v]
   45    [deck-builder.core :as c]
   46    [clojure.string :as str]
   47    [cljs.test :as t :refer [testing is]]))
#2018-09-2514:34ClashTheBunnyMaybe a clean or something is now required?#2018-09-2514:35thhellerdoubtful#2018-09-2514:35ClashTheBunnyThe above output is from a (shadow/once :devcards)#2018-09-2514:36thhellerdoes it happen when you run shadow-cljs compile devcards? ie. kill all running shadow-cljs instances and start fresh?#2018-09-2514:36thhellersomething weird seems to be going on on your machine#2018-09-2514:41ClashTheBunnyNo, I figured it out. I had that refer-macros in core_table.cljs also. Just too similar a name to pick it out of the error message.#2018-09-2514:45ClashTheBunnySo, I got the right message when core_table.cljs was included in core_card.cljs but not when the error was in core_card.cljs which is what shadow-cljs.edn uses as it's entry point.#2018-09-2514:49ClashTheBunnyYeah, it compiles now that I fixed both places.
[1:0]~shadow.user=>  (shadow/once :devcards)
[:devcards] Compiling ...
npm package "fbjs" expected version "
#2018-09-2514:49ClashTheBunnyThe full set of changes:
~/c/deck-builder ❯❯❯ git diff deps.edn shadow-cljs.edn src                                                                                                                                                                                                                                                  ⏎ master ✭ ✖ ✱ ◼
diff --git i/deps.edn w/deps.edn
index 10891a0..342b4ac 100644
--- i/deps.edn
+++ w/deps.edn
@@ -12,7 +12,7 @@
         io.joshmiller/exif-processor {:mvn/version "0.2.0"}
         cljs-ajax {:mvn/version "0.7.4"}
         camel-snake-kebab {:mvn/version "0.4.0"}
-        thheller/shadow-cljs {:mvn/version "2.5.1"}
+        thheller/shadow-cljs {:mvn/version "2.6.10"}
         com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}

  :paths ["dev"
diff --git i/src/cljs/devcards/core_card.cljs w/src/cljs/devcards/core_card.cljs
index 974362c..f322b04 100644
--- i/src/cljs/devcards/core_card.cljs
+++ w/src/cljs/devcards/core_card.cljs
@@ -1,7 +1,6 @@
 (ns devcards.core_card
   (:require-macros
    [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
-   [cljs.test :as t :include-macros true :refer-macros [testing is]]
    [deck-builder.macros :as dm])
   (:require
    ["rmwc/Select" :refer (Select)]
@@ -44,7 +43,8 @@
    [devcards.core-table :as table]
    [deck-builder.views :as v]
    [deck-builder.core :as c]
-   [clojure.string :as str]))
+   [clojure.string :as str]
+   [cljs.test :as t :refer [testing is]]))


 (enable-console-print!)
diff --git i/src/cljs/devcards/core_table.cljs w/src/cljs/devcards/core_table.cljs
index 494687b..6046ea4 100644
--- i/src/cljs/devcards/core_table.cljs
+++ w/src/cljs/devcards/core_table.cljs
@@ -1,7 +1,6 @@
 (ns devcards.core-table
   (:require-macros
    [devcards.core :as dc :refer [defcard defcard-rg deftest mkdn-pprint-str]]
-   [cljs.test :as t :include-macros true :refer-macros [testing is]]
    [deck-builder.macros :as dm])
   (:require
    ["rmwc/Select" :refer (Select)]
@@ -45,7 +44,8 @@
    [deck-builder.views :as v]
    [deck-builder.core :as c]
    [deck-builder.rules :as rls]
-   [clojure.string :as str]))
+   [clojure.string :as str]
+   [cljs.test :as t :refer [testing is]]))

 (def fake-player-data
   (apply merge
#2018-09-2522:57mattlyI'm having an issue attempting to pull the graphiql npm module into a new library, [2018-09-25 15:49:47.466 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/graphql-language-service-interface/dist/GraphQLLanguageService.js", :requires [{:line 149, :column 30}]}#2018-09-2522:58mattlythe offending require:#2018-09-2522:58mattly#2018-09-2522:59mattlywe're attempting to port to shadow-cljs from lein and wanted to use npm deps instead of clojars#2018-09-2523:01mattlyI'm not sure why it's doing this dynamic require#2018-09-2523:53justinlee@mattly when you say you want to use “npm deps” do you mean the :npm-deps compiler flag or do you mean doing it the shadow-cljs way, where you install the library using npm or yarn and then require it directly?#2018-09-2523:53mattlythe latter#2018-09-2523:57justinleeokay I just wanted to sanity check 🙂 thomas is surely asleep right now so you may have to wait for him, but one thing to try is to see if there are different distributions of the library you might be able to try.#2018-09-2523:57justinleei had trouble with one of these conditional requires in the pdf.js library and in the end i just stopped trying to bundle it with shadow#2018-09-2600:00justinleepotentially relevant: https://github.com/graphql/graphql-language-service/issues/111#2018-09-2600:10mattlyyeah I saw that one#2018-09-2600:10mattlyI might just stay with cljsjs for this one anyway#2018-09-2607:08thheller@mattly that is just a warning that the dynamic require won't be resolved. do you get an actual related error?#2018-09-2607:10thhelleralso looks like the language-service thing is meant to run in node? are you sure that its supposed to work in the browser?#2018-09-2607:12thhellerwhich cljsjs package is that? or which npm package for that matter? codemirror-graphql?#2018-09-2617:06mattly@thheller the cljsjs package I'm using on the lein version of the project is [cljsjs/graphiql "0.9.3-0"]#2018-09-2617:07mattlyand that pulls in codemirror#2018-09-2617:08mattlyanyway IDK what's going on with it necessarily, but when I pull in the "graphiql" npm module via (:require ["graphiql" :default GraphiQL]) I get some other compilation errors. Which I assumed to be related to the warning.#2018-09-2617:16thhellerdepends. what errors do you get?#2018-09-2617:16thhellerI can try myself later#2018-09-2617:22mattlyhm, I'm having different errors this morning#2018-09-2617:23thhellerit compiles and loads fine for me. do I have so call something to trigger the error?#2018-09-2617:24mattlyI was getting an error attempting to mount the GraphiQL react componnet#2018-09-2617:24thheller["graphiql" :as GraphiQL]#2018-09-2617:24thhellerits not a default export#2018-09-2617:24mattlyaha#2018-09-2617:34mattlynow I'm getting Uncaught ReferenceError: process is not defined for React's prop-types module#2018-09-2617:35mattlywhich, I have a very similar app working otherwise and I'm not seeing any material differences in their shaddow-cljs.edn files#2018-09-2617:39thheller@mattly which version are you on?#2018-09-2617:41mattlyof shadow-cljs? react?#2018-09-2617:41thhellershadow-cljs#2018-09-2617:41mattlylooks like 2.6.6 according to package.json#2018-09-2617:41thhellerI have prop-types in my current build so that should work#2018-09-2617:41mattlyyeah I think something else is going on here#2018-09-2617:42mattlyhere's the full list of errors#2018-09-2617:42mattly#2018-09-2617:43thhellerthe global is not defined stands out. which index.js is that?#2018-09-2617:43mattlycljs-runtime#2018-09-2617:43thhellerfull path please. cljs-runtime contains all compiled files 😉#2018-09-2617:44mattlyah, sorry#2018-09-2617:44mattlyI apparently only get it on mouseover#2018-09-2617:44thhelleryou can click it on the console#2018-09-2617:45thhellerare you doing any kind of special config for your build? or any other hackery?#2018-09-2617:45mattlyyes and then it opens the file but doesn't show me the path#2018-09-2617:45mattlyno#2018-09-2617:45mattlythis was straight-up copied from a working project#2018-09-2617:45mattlyok here we go#2018-09-2617:45thhellerright click the tab for the source file and copy link#2018-09-2617:45mattlyjs/cljs-runtime/node_modules/crypto-browserify/index.js#2018-09-2617:46thhellerdo you use multiple :modules maybe?#2018-09-2617:46mattly... or perhaps js/cljs-runtime/node_modules/buffer/index.js#2018-09-2617:47thhellerhmm no those all work fine#2018-09-2617:47thhellersince I can import graphiql, react, react-dom just fine it must be something in your setup#2018-09-2617:47mattly#2018-09-2617:48thhellerok so its not the config#2018-09-2617:48thhelleryour html only loads /js/main.js correct?#2018-09-2617:48mattlydouble-checking on that#2018-09-2617:48mattlyemacs is crapping for me right now and I can't quit it yet because of work in-flight on another project#2018-09-2617:49mattlyyes, that is the only JS loaded by the html#2018-09-2617:50thhellerand there are no other <script> tags that do anything weird? 🙂#2018-09-2617:51mattlynope – only script tags in the doc are the ones loaded by closure#2018-09-2617:52mattlymy hunch now is it's some unspoken peer dep of react#2018-09-2617:55thhellerdo you get warnings on build about npm version conflicts?#2018-09-2617:56mattlyno#2018-09-2617:56thhellercan you maybe trim some requires? try adding them one-by-one until it breaks? react-dom,react,graphql,graphiql all work fine for me#2018-09-2617:57mattlysure#2018-09-2617:58thhellercheck the public/js/cljs-runtime/module$node_modules$object_assign$index.js file please#2018-09-2618:00mattlystripped my main ns down to nothing, no errors#2018-09-2618:00mattlyI'm going to slowly start bringing them back in#2018-09-2618:01thhellercheck the file please. that is where _assign comes from that makes the others fail#2018-09-2618:01thhellerjust want to check if that file is maybe not what its supposed to be#2018-09-2618:02thhellerits minified so it'll look like a mess. just paste it.#2018-09-2618:03mattly#2018-09-2618:03thhellerok so thats definitely not correct#2018-09-2618:03mattlyperhaps I should just try removing public/js and start over?#2018-09-2618:04thhellerdid you try {:js-provider :closure} at one point?#2018-09-2618:04mattlyyeah I think so#2018-09-2618:04mattly... and then removed it#2018-09-2618:04thhelleryeah but that output is from that#2018-09-2618:04mattlyfun times#2018-09-2618:05mattlyok I'm going to clean that directory#2018-09-2618:05thhellerdon't know why that doesn't get overwritten though#2018-09-2618:05thhelleris node_modules maybe on your :source-paths?#2018-09-2618:06mattlynope#2018-09-2618:06mattlyOK I'm back to where I was yesterday#2018-09-2618:08mattlywith requiring GraphiQL#2018-09-2618:10thhellerand those are?#2018-09-2618:11mattlyI have this now: (:require ["graphiql" :as GraphiQL]#2018-09-2618:11mattly(js/console.log GraphiQL) does the expected thing and prints the function#2018-09-2618:12mattly...and after changing things like GraphiQL.Toolbar to GraphiQL/Toolbar it works as expected#2018-09-2618:12mattlyso it was a require/import problem#2018-09-2618:15mattlyGraphiQL's docs tell you to import GraphiQL from 'graphiql'; and so I took this line form the ES6 to require table: import defaultExport from "module-name"; (:require ["module-name" :default defaultExport])#2018-09-2618:16thhelleryeah thats icky because it depends on how the package is actually bundled on their end#2018-09-2618:16mattlywhich seems on par with my experiences so far with node module documentation#2018-09-2618:17thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2018-09-2618:17mattlyanyway, thanks a lot#2018-09-2618:17thhellerI kinda want to do what webpack does for this so it works more consistently#2018-09-2618:17mattlyyeah, that makes sense#2018-09-2618:17thhellerbut that might break code for some people so I don't like doing that 😛#2018-09-2618:18thhelleralso CLJS doesn't officially support :default yet ...#2018-09-2618:18mattlyright#2018-09-2622:04jstaabHey all, quick question for a relative beginner. How do you usually connect to shadow-cljs' repl (either the socket or nREPL). I'm trying to use unravel localhost port but it seems to be detecting my clj namespaces, not my cljs ones. Also, there's no js namespace. Is there a way to tell it I'm on js? Or, even preferably, is there a way to use rebel-readline with shadow-cljs?#2018-09-2622:11justinlee@jstaab you’ve connected to a clj namespace. from there, type (shadow/nrepl-select :my-app) and I think that’ll bump you into the cljs repl#2018-09-2622:11ClashTheBunnyYou can access any javascript from cljs.#2018-09-2622:14jstaabOk, if I do (shadow.cljs.devtools.api/nrepl-select :client) I get
IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set  clojure.lang.Var.set (Var.java)
        clojure.lang.Var.set (Var.java)
        shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invokeStatic (api.clj)
        shadow.cljs.devtools.api$nrepl_select.invoke (api.clj)
        user$eval14469.invokeStatic (unrepl-session)
        user$eval14469.invoke (unrepl-session)
        clojure.lang.Compiler.eval (Compiler.java)
        clojure.lang.Compiler.eval (Compiler.java)
        clojure.core$eval.invokeStatic (core.clj)
#2018-09-2622:15ClashTheBunnyWhat is the client build id?#2018-09-2622:15jstaabMy shadow-cljs.edn has :builds {:client {...}}, so client? Or the build id something else?#2018-09-2622:16ClashTheBunnyNo, that seems right.#2018-09-2622:16ClashTheBunnyWhat's the target of that build id?#2018-09-2622:16jstaabIf I do (shadow.cljs.devtools.api/nrepl-select :app) I get [:no-worker :app]#2018-09-2622:16jstaab:browser#2018-09-2622:16jstaab
{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:client
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"
   :modules {:main {:entries [portal.client.core]}}
   :devtools
   {:http-root "public"
    :http-port 8700}}}}
#2018-09-2622:16ClashTheBunnyAnd you have a browser connected?#2018-09-2622:17jstaabOoh hey maybe that's it, I had a different repl connected, just a sec#2018-09-2622:17ClashTheBunnyWhat if you run (shadow/repl :client)? Is it possible you're trying to bind from a non-nrepl?#2018-09-2622:17jstaabhmm nope I connected to the right port, same thing#2018-09-2622:18jstaabno such namespace shadow#2018-09-2622:18ClashTheBunnydo :repl/quit to exit the current repl and try again?#2018-09-2622:19jstaabAre you assuming rebel or unravel? That looks like a rebel command#2018-09-2622:20ClashTheBunnyIt's a shadow-cljs command.#2018-09-2622:20jstaabIn rebel, here's what I get:
user=> (shadow.cljs.devtools.api/nrepl-select :client)
ClassNotFoundException shadow.cljs.devtools.api  java.net.URLClassLoader.findClass (URLClassLoader.java:381)
#2018-09-2622:20ClashTheBunnyHow did you connect rebel to shadow-cljs?#2018-09-2622:22jstaabclj -m rebel-readline.main for rebel, (haven't figured out how to connect to nrepl/socket repl yet); unravel localhost 57282 for unravel, that's the socket repl port#2018-09-2622:22ClashTheBunnyWhat command did you use to start shadow?#2018-09-2622:23jstaabshadow-cljs watch client#2018-09-2622:23ClashTheBunnyI usually start it with shadow-cljs clj-repl and then I bounce into the different repls.#2018-09-2622:24jstaabHuh, ok I'll give that a try. Does that command give you a repl directly or do you still have to connect? I thought I had tried that#2018-09-2622:25jstaabOh hey it does work#2018-09-2622:27jstaabOk, maybe a bit closer, now I get:
[1:0]~shadow.user=> (shadow/nrepl-select :client)
[:no-worker :client]
#2018-09-2622:27jstaabDoes watch client have to be running at the same time?#2018-09-2622:28ClashTheBunnyYou have to connect a browser, which does require a build (shadow/once :client)#2018-09-2622:28ClashTheBunnyOr (shadow/watch :client)#2018-09-2622:29ClashTheBunnyWhen you connect your browser, it will allow you to connect to the cljs repl.#2018-09-2622:30jstaabOkay, closer:
rlwrap shadow-cljs clj-repl
shadow-cljs - config: /Users/jstaab/Desktop/cc/portal/shadow-cljs.edn  cli version: 2.6.10  node: v8.4.0
shadow-cljs - starting ...
Sep 26, 2018 3:29:46 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Sep 26, 2018 3:29:46 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 
shadow-cljs - server version: 2.6.10
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 59883
shadow-cljs - nREPL server started on port 59885
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=> (shadow/watch :client)
[:client] Configuring build.
[:client] Compiling ...
:watching
[1:0]~shadow.user=> [:client] Build completed. (162 files, 1 compiled, 0 warnings, 8.57s)

[1:0]~shadow.user=> (shadow/nrepl-select :client)
IllegalStateException Can't change/establish root binding of: *nrepl-cljs* with set  clojure.lang.Var.set (Var.java:223)
#2018-09-2622:31jstaabI am connected to the app#2018-09-2622:31jstaabat 8700#2018-09-2622:31jstaabAnd the server at 9630, still getting the same thing#2018-09-2622:33ClashTheBunnyDoes (shadow/repl :client) work?#2018-09-2622:33ClashTheBunnyMaybe you need to do (shadow/nrepl-select :client) from within nrepl? Have you connected nREPL?#2018-09-2622:34jstaabGot it, I did what the docs said here https://shadow-cljs.github.io/docs/UsersGuide.html#cljs-repl and it worked this time#2018-09-2622:35jstaabNot sure why I wasn't able to get it to go before#2018-09-2622:36ClashTheBunnyNot in nrepl or in nrepl?#2018-09-2622:36jstaabNot sure what you mean. I wasn't able to connect to the nrepl from a differnt client (I still get the root binding error on unravel)#2018-09-2622:38jstaabHa I just found your issue: https://github.com/bhauman/rebel-readline/issues/172#2018-09-2622:38jstaabI guess you're the guy to talk to#2018-09-2622:39ClashTheBunnyNo, I'm just a user. Would love to plug them together, though!#2018-09-2622:39jstaabMe too, rebel is really nice#2018-09-2622:39jstaabDo you use any external repl or just rlwrap with shadow-cljs' built-in repl?#2018-09-2622:40ClashTheBunnyrlwrap and built-in#2018-09-2622:40jstaabalrighty, I guess that's where I'm at too then. Thanks for your help!#2018-09-2622:41ClashTheBunny👍#2018-09-2623:24lilactownit sounds like an issue when using unravel / socket REPL#2018-09-2623:24lilactownmight be worth opening an issue#2018-09-2623:25lilactownI typically use Emacs' CIDER or Cursive's integrated REPL personally, which all use nREPL#2018-09-2705:43gklijsI went to a meetup last night about https://github.com/zeit/next.js/ is it possibly combinable with shadow-cljs? One of the problems of a big spa, especially with clojurescript is that you need all the js for all the pages.#2018-09-2707:12thheller@gklijs it is probably easy to use in the same way I tried with gatsby https://clojureverse.org/t/creating-websites-with-gatsby-shadow-cljs/2912#2018-09-2707:12thhellerbut it probably will have the same issues and don't fit that into the system#2018-09-2707:13gklijsThanks, I might give it a try, but so far only done very small cljs things, so don't really need it.#2018-09-2707:16gklijsIt's very similar Gatsby, but is more configurable#2018-09-2707:18thhelleryeah going over the docs the integration would look pretty similar#2018-09-2707:19thhellermight even work better since they don't seem to do these AST transforms that gatsby does#2018-09-2707:20thhellerI have been considering writing one of those site generators for shadow-cljs#2018-09-2708:29thheller@gklijs got curious and implemented the same example I did for gatsby. https://github.com/thheller/next-cljs#2018-09-2708:30thhellerworks fine but has some issues around SSR since it serializes the data to JSON and that doesn't work too well for CLJS data#2018-09-2708:30thhellercould be worked around though#2018-09-2711:39Hannu HartikainenI tried running tests using node.js with an npm script
"scripts": {
    "test": "shadow-cljs compile test"
  }
and the shadow-cljs build config
:test {:target    :node-test
                       :output-to "target/node-tests.js"
                       :ns-regexp "-test$"
                       :autorun   true}}}
But when I run the tests (whether by npm test or npm run test) the exit status is zero even if there were failures. Is it just a bad idea to run the tests with :autorun?
#2018-09-2711:42Hannu HartikainenThe docs say > The node process exit code will be set to 0 when successful and 1 on any failures. and > :autorun (boolean, optional) Run the tests via node when a build completes so I expected this should work. Maybe the docs just need a clarification.#2018-09-2711:49thheller@hannu.hartikainen don't use :autorun if you need the exit code. it mostly meant for running tests automatically with watch. use shadow-cljs compile test && node target/node-tests.js instead#2018-09-2805:55bbssHad a pretty big headscratcher when experimenting with multiple web workers + shadow-cljs. Because adding a web-worker to the main app build ended up using some JS that's incompatible with web-workers (using window or such). I had to add an extra build and run it in parallel, that breaks hot-reloading but still works. However when I got to write and load a third worker things started getting weird. The main worker namespace kept on getting re-evaluated, even though the single namespace that requires the main worker was not, causing the workers that it loaded to keep spawning endlessly. I ended up fixing it by not using :worker in the :modules of the extra worker builds, they need to be unique over multiple builds I guess?#2018-09-2807:23thheller@bbss why did you not isolate the code using window and such so it doesn't get loaded by the worker?#2018-09-2807:23thhellerloading 2 different development builds in the same page is gonna be problematic yes#2018-09-2807:26bbsshmm I hadn't really looked into the option, I guess starting my main build loads fulcro which was what broke it. Not sure how to isolate that.#2018-09-2807:27thheller
{:shared {:entries []}
 :web-shared
 {:entries []
  :depends-on #{:shared}}
 :web1
 {:init-fn 
  :depends-on #{:web-shared}}
 :worker-shared
 {:entries []
  :depends-on #{:shared}}
 :worker1
 {:init-fn your.worker1/init
  :web-worker true
  :depends-on #{:worker-shared}}
 :worker2
 {:init-fn your.worker2/init
  :web-worker true
  :depends-on #{:worker-shared}}}
#2018-09-2807:27thhellerhaving empty :entries allows them to "catch" dependencies to they don't go further up the graph#2018-09-2807:28bbssokay, I'll give that a shot!#2018-09-2807:28thhellerso your app would would shared,web-shared,web1 in the page#2018-09-2807:31thhellerI actually got something in the UI that should make it easier to figure out which code ends up where#2018-09-2807:31thheller#2018-09-2807:32thhellerstill working on it though. lots of stuff left to do.#2018-09-2807:32bbsscool, yeah this would have helped. I had some assumptions but mostly it was hard to figure out what was going wrong 😅#2018-09-2807:33thhellerbut you should be able to "move" code around so that the worker doesn't load the DOM related code#2018-09-2807:33bbssI had tried some things but didn't consider an empty entries. I'll let you know if I figure it out.#2018-09-2807:33bbssThanks!#2018-09-2807:34thhellerthey don't have to be empty. you can also force certain dependencies which might make sense too#2018-09-2816:36grounded_sageSuper stoked you are going to have a go at doing something similar to Gatsby @thheller I've been chipping away at it with Shadow Jam but I'm sure what you can come up with would be way better than what I can put together 🙂 Plus you can make the whole experience much more integrated.#2018-09-2816:58grounded_sageAt the moment I am doing a couple of websites that have so little JS interaction I can't justify shipping the React runtime. So I'm just using Rum in Clj to generate the static html and Shadow Cljs to create the JS scripts that actually do work on the page. It's been so easy to do with Shadow-cljs#2018-09-2817:45Logan PowellSorry for the potentially stupid question, but if I get a java.net.SocketException: Socket closed exception when I terminate my shadow-cljs clj-repl (node repl) after working with some core.async I/O, is it due to me not close!ing a chan?#2018-09-2817:50Logan PowellI only get this exception thrown after ending my REPL session and only when I'm working with core.async#2018-09-2819:20thheller@loganpowell no idea. don't worry about it if you are ending the repl session anyways. it might be something async trying to write to the socket you just closed#2018-09-2819:21Logan Powell@thheller thank you for the piece of mind. Moving on...#2018-09-2819:21thhelleris that the full error you get or does it have a stacktrace?#2018-09-2819:24thhellerhmm weird. why is nrepl in there at all? did you open a second connection in an editor or so?#2018-09-2819:24thhellerbut yeah you are quitting the actual server not just the REPL#2018-09-2819:24thhellerso any open connection will be forcefully terminated .. leading to such exception if something was writing to it or trying to write to it#2018-09-2819:25thhellerthere might be a race condition where something tries to notify something else. I'll see if I can just mute exceptions during shutdown#2018-09-2819:27Logan Powellno worries. It's not having an impact on me except for the shutdown exception.#2018-09-2819:28Logan PowellI'm using a remote REPL, yes. I was having issues with the terminal in IDEA#2018-09-2901:52priornixHi there, I am using shadow-cljs with keechma. Hot-reload on the keechma project works with figwheel but does not work with shadow-cljs.#2018-09-2901:52priornixA sample project can be found here: https://github.com/mjmeintjes/shadow-cljs-keechma-node?files=1#2018-09-2901:55priornixHow a keechma project is structured is usually this: core.cljs -> app/definition -> ui/ui -> component#2018-09-2901:56priornixIn figwheel when the component is modified the dependency graph is resolved correctly, and app/definition is reloaded. In shadow-cljs, the reloading propogates from component and stops at ui/ui#2018-09-2902:00priornixThe browser console output for shadow-cljs for the code above is as follows:
shadow-cljs: call example.client.core/stop 
shadow-cljs: load JS example/client/ui/main.cljs 
shadow-cljs: load JS example/client/ui.cljs
shadow-cljs: load JS example/client/core.cljs
#2018-09-2902:02priornixThe changes did not propagate to although it clearly has a dependency on ui/ui:
(def definition
  {:components    ui
   :controllers   controllers
   :subscriptions subscriptions
   :router :history
   :routes [":category/:page"]})
#2018-09-2907:08thheller@priornix this is https://github.com/thheller/shadow-cljs/issues/349#2018-09-2907:09thhelleryou are keeping references to namespace defs in a map in another namespace#2018-09-2907:09thhellerhonestly this should be avoided as this is global state#2018-09-2907:10priornixYes, that's true.#2018-09-2907:10priornixIt does make the code simpler though.#2018-09-2907:11thhellerso you currently have 2 options#2018-09-2907:12thheller(defn definition [] ...) and change all references to (definition)#2018-09-2907:12thhellerthis will recreate the map whenever it is used. ensuring that it has all the latest references#2018-09-2907:12priornixI tried to do that earlier that, but it didn't work.#2018-09-2907:12thhelleror tag the namespace with (ns ^:dev/always the.ns-with-definition)#2018-09-2907:13thhellerbut honestly thats horrible#2018-09-2907:13priornixYes haha#2018-09-2907:13priornixI'd rather go with the first approach, but I didn't manage to get it to work, I'll try to replace ui as well.#2018-09-2907:14thhellergeez .. there is sooooooo much global state in this ...#2018-09-2907:14thhellerhttps://github.com/mjmeintjes/shadow-cljs-keechma-node/blob/master/src/example/client/core.cljs#L17-L19#2018-09-2907:14thhellerevery file is full of it#2018-09-2907:15thhellerhttps://github.com/mjmeintjes/shadow-cljs-keechma-node/blob/master/src/example/client/subscriptions.cljs#L15-L16#2018-09-2907:16priornixYes, that's how keechma is structured. It's only for the component and the app-definition though. States are kept in it's own space. Feel free to ping @mihaelkonjevic#2018-09-2907:17priornixHaving said that, I prefer keechma to re-frame it's a higher order abstraction than re-frame and deals nicely with app states#2018-09-2907:19thhellerhmm yeah I'll add an option to force reload all dependents#2018-09-2907:19priornixActually if you look at re-frame it's full of global states as well#2018-09-2907:19priornixhttps://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/events.cljs#2018-09-2907:19thhellerits generally not necessary and slower#2018-09-2907:20priornixhttps://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/db.cljs#2018-09-2907:20thhelleryeah I know but those update references in a global map on each reload and generally don't keep state from another namespace#2018-09-2907:20thheller(def x {:a another/b})#2018-09-2907:20thhellerthi sis the only problem#2018-09-2907:21thhellercalling functions etc from other namespace is not a problem#2018-09-2907:21thhelleror rather not even that is the problem#2018-09-2907:21thhellerthe issue is when there is one-hop#2018-09-2907:22priornixSo currently figwheel does a global reload#2018-09-2907:22thheller(def x {:a ns2/thing}) (ns ns2) (def thing {:a ns3/thing})#2018-09-2907:22priornixGot it#2018-09-2907:23thhellerfigwheel isn't really involved in this#2018-09-2907:23thhellerthe default in CLJS is to :recompile-dependents#2018-09-2907:23thhellerand all of them will be reloaded#2018-09-2907:23priornixFor now we can put the keechma definitions all within a file. Just a matter of convention#2018-09-2907:23thhellerbut this recompiles a lot more namespaces that don't actually need to be recompiled#2018-09-2907:23priornixRight#2018-09-2907:23priornixHence why shadow is much faster#2018-09-2907:23thhellerso it can be a lot slower in bigger apps#2018-09-2907:24thhellerso what is really needed is a :reload-dependents option#2018-09-2907:24thhellersince the code didn't change we only need to reload it to trigger the global state updates#2018-09-2907:24thhellerwithout actually recompiling it#2018-09-2907:24priornixYes, I was looking for such an option. To manually specify certain namespaces to be reloaded always#2018-09-2907:26priornixThe other way is to let the developer specify the namespaces that has to be reloaded. so {:reload-namspace :all} versus {:reload-namespace [foobar.core]}#2018-09-2907:26thhellerthe other option is to not use those chained references from one namespace to another#2018-09-2907:27thheller(ns a {:a another/a}) is totally fine#2018-09-2907:27thhellersince that ns will depend on another both will be reloaded#2018-09-2907:27priornixRight#2018-09-2907:27thhellerthe problem is when the second depends on the third because the first won't depend on the third#2018-09-2907:27thhelleryou can just require the third in the first to make it reload#2018-09-2907:28thhellerthen everything should work as expected#2018-09-2907:28priornixMakes the code fragile though, having to remember which ones to require#2018-09-2907:29priornixFragile only in dev-mode of course#2018-09-2907:38priornixAnyway, thanks @thheller for the help and the great tool.#2018-09-2907:42thhellerthis has come up often enough now that I'll probably add it soon 😉#2018-09-2909:50bbssOn dependencies in workers that depend on window: I've gone from multiple builds to splitting into multiple modules, that made them build together, but it's the :devtools :preloads fulcro.inspect.preload that have the thing that depends on window.-localStorage#2018-09-2909:50thhellerah!#2018-09-2909:50thhellerright those always get added to the default module#2018-09-2909:50thhellerhmm#2018-09-2909:50bbssokay, it's not really a big issue for me#2018-09-2909:50bbsshappy they build together now 🙂#2018-09-2909:51thhellerI can probably add support for :preloads in :modules themselves#2018-09-2909:51thhellermakes more sense actually#2018-09-2909:52thhellerso each module can have its own preloads instead#2018-09-2909:52bbssYeah that makes sense to me.#2018-09-2909:54thhellerhttps://github.com/thheller/shadow-cljs/issues/390#2018-09-2909:55bbssAnother issue I now face is that if I want to do a
(defn ^:dev/after-load recalc []
  (prim/transact!
   (:reconciler @app)
   `[(gsv.api.mutations/update-some-data {})]))
I don't have a ref to the state in the worker.
#2018-09-2909:55bbss:after-load should maybe be available from the config though. Looking into that.#2018-09-2909:56thhellerwhat do you mean?#2018-09-2909:56bbssThe namespace that starts the worker doesn't get re-evalled when just the worker changes.#2018-09-2909:56bbssI want to redo the calculation that uses the worker.#2018-09-2909:56thhellerthen you must create an after-load fn in the main app that notifies the worker to recalc (eg. send a message to it)#2018-09-2909:57thhellershadow-cljs can't do that for you#2018-09-2909:58thhellerlive-reloading currently also doesn't work for workers#2018-09-2909:58thhellerso I recommend killing them in a hook and restarting them#2018-09-2909:59thhellerit has been a while since I used the worker stuff myself. I think there are still a few rough edges that could be tweaked#2018-09-2909:59bbssYeah for now I've just been loading many workers and reloading the namespace that starts them, not caring about cleaning them up.#2018-09-2910:46bbssSo I see the shadow-cljs logo when the worker compilation happened. But I can't seem to find a hook into it from the config. These don't seem to work. https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2018-09-2910:47thhellerwhat do you mean by worker compilation happened? I though you used :modules?#2018-09-2910:48bbssYes, I mean when I change the worker cljs the build recompiles it.
#2018-09-2910:48thhelleryes as I said .. no live-reload happens IN the worker itself#2018-09-2910:49bbssI don't mind that. But the file that loads the worker needs to reload it.#2018-09-2910:49thhelleryes you do that via :dev/after-load#2018-09-2910:49bbssSo now I have to change the worker, and the file that requires it. No biggie, but would be nice if changing the worker triggered the reload on namespace that requires the worker.#2018-09-2910:49thheller(defn ^:dev/after-load restart-workers [] (.terminate the-worker) (start-the-worker))#2018-09-2910:50thhellerin the namespace that manages the worker#2018-09-2910:50thhellernot the code of the worker itself#2018-09-2910:50bbssthat after-load won't be called if I just change the worker.#2018-09-2910:50thhelleryes it will?#2018-09-2910:51bbssHmm, let me re-check.#2018-09-2910:51thhellerremember NOT in the worker file itself#2018-09-2910:52bbssYes, changing the worker file, saving, triggers a recompilation. But neither the :after-load from :devtools nor the annotated function from the namespace that requires the worker gets called.#2018-09-2910:52bbssUnless I change the file that requires the worker.#2018-09-2910:53thhellerafter-load is completely independent of actual compilation#2018-09-2910:53thhelleropen the browser console and post the log please#2018-09-2910:54thhelleroh wait haha I think it might just "optimize" the restart cycle away completely#2018-09-2910:54thhellersince non of the main-build code changed there is nothing to reload#2018-09-2910:54thhellerthus it is skipped completely#2018-09-2910:55bbssYes, that could be it. The
shadow-cljs: call gsv.client/start
browser.cljs:25 shadow-cljs: call gsv.client/recalc
util.cljs:187 Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
Don't happen when I change the worker code.
#2018-09-2910:56thhellerhehe yep the reload gets optimized out#2018-09-2910:57thhellerthe browser main doesn't have the worker code loaded (obviously) so it decides that it doesn't need to reload any code#2018-09-2910:57thhellerand skips calling the lifecycle fns as well#2018-09-2910:58bbssThat makes sense, I am quite happy that it loads "just what changed" usually 🙂#2018-09-2911:00bbssAnyway it's not a big deal to just change both files so don't worry about solving it quickly or so.#2018-09-2911:01thhellerhmm I could always trigger the lifecycle but I doubt that you usually want that#2018-09-2911:01thhelleryou could annotate some namespace with :dev/always so that some file of the main thread always gets reloaded#2018-09-2911:01thhellerbut that seems rather dirty#2018-09-2911:02bbssHmm that could work, when developing I usually reload that namespace anyway.#2018-09-2911:02thhelleryeah but dependents also get reloaded. its a bit messy#2018-09-2911:02thhelleryou could add an empty preload I guess#2018-09-2911:03thheller(ns ^:dev/always some.reload-helper)#2018-09-2911:03thheller:preloads [some.reload-helper]#2018-09-2911:03thhellerso nobody depends on that ns but it always gets reloaded to trigger the lifecycle fns#2018-09-2911:03thhellersuper ugly hack but should work#2018-09-2911:04thhellerI need to review some of the webworker stuff to figure out how to deal with this properly#2018-09-2911:06bbssYep! That works and will do fine for now I think. 👍#2018-09-2911:06bbssThank you.#2018-09-2911:08thhellerhttps://github.com/thheller/shadow-cljs/issues/391#2018-09-2920:22ClashTheBunnyHas anybody gotten the latest posh working with shadow-cljs?
-- Syntax error -------------------
  (... ... ... (... [posh.plugin-base :as base :include-macros] ... ... ...))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
------ ERROR -------------------------------------------------------------------
 File: jar:file:/tank/ranmason/.m2/repository/posh/posh/0.5.6/posh-0.5.6.jar!/posh/reagent.cljs:1:1
--------------------------------------------------------------------------------
   1 | (ns posh.reagent
-------^------------------------------------------------------------------------
Invalid namespace declaration
-- Spec failed --------------------
  (... ... ... (:require ... ... ... ...))
                ^^^^^^^^
should be one of: :import, :import-macros, :refer-clojure, :require-macros, :use, :use-macros
#2018-09-2920:27thhellerthis is an invalid ns form#2018-09-2920:27thhellerhttps://github.com/mpdairy/posh/blob/master/src/posh/reagent.cljs#L3-L4#2018-09-2920:28thhellershadow-cljs validates more strictly than the default so the default just sort of works accidentally#2018-09-2920:29thhellershould be :include-macros true or better yet a :require-macros in the posh.plugin-base itself#2018-09-2921:35ClashTheBunnyThat was it.#2018-09-3009:49jacekschaecan i somehow get rid of these warnings when I start my dev server?
Sep 30, 2018 11:47:29 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Sep 30, 2018 11:47:29 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/jacek/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#2018-09-3010:22thhellernot sure if there is an undertow release with a fixed dependency yet#2018-09-3010:25thhellerdoesn't look like it#2018-09-3010:25thhellernot sure if I can just bump xnio without breaking undertow#2018-09-3010:25thhellerhttps://issues.jboss.org/browse/XNIO-322#2018-09-3010:25jacekschae🤔#2018-09-3010:27thhellertry adding [org.jboss.xnio/xnio-nio "3.6.5.Final"] + [org.jboss.xnio/xnio-api "3.6.5.Final"] to your deps#2018-09-3010:27thhellermaybe the warning goes away and everything runs?#2018-09-3010:27thhellerI don't get warnings anymore on windows#2018-09-3010:27thhellerseems to be a mac issue#2018-09-3010:28thheller@jacek.schae btw are any of your "students" on windows?#2018-09-3010:28thhellerI know of one but are there more?#2018-09-3010:28thhellerwondering how the percentages win/mac are#2018-09-3010:29jacekschaejust added the deps#2018-09-3010:29jacekschae
Sep 30, 2018 12:29:24 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.6.5.Final
Sep 30, 2018 12:29:24 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.6.5.Final
Sep 30, 2018 12:29:24 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.3.0.Beta2
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jboss.threads.ThreadLocalResetter$1 (file:/Users/jacek/.m2/repository/org/jboss/threads/jboss-threads/2.3.0.Beta2/jboss-threads-2.3.0.Beta2.jar) to field java.lang.Thread.threadLocals
WARNING: Please consider reporting this to the maintainers of org.jboss.threads.ThreadLocalResetter$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#2018-09-3010:30thhellergetting close to having something usable for the ui. wondering if its worth investigating publishing it on windows app store#2018-09-3010:30thhellerhehe nice#2018-09-3010:30jacekschaei don't really have the view into use env#2018-09-3010:30jacekschaei don't know if someone has win, mac, or linux#2018-09-3010:31thhellerah thought you may log it on purchase or so#2018-09-3010:31thhellerapparatently you can :exclusions [org.jboss.threads/jboss-threads]#2018-09-3010:31thhellerhttps://issues.jboss.org/browse/UNDERTOW-1355#2018-09-3010:35jacekschaethanks for help anyways#2018-09-3010:35jacekschaethe exclusions didn't help either#2018-09-3010:35jacekschaei saw the video of the ui, look forward to the finalised version#2018-09-3010:38thhellerstarting build a standalone electron version and its coming along nicely#2018-09-3010:38thhellerreally liking where this is going#2018-09-3010:51jacekschaegreat to hear! :+1: If you would need any feedback feel free to ping me.#2018-09-3018:00lilactownI have an app that I’m using bootstrapped CLJS. It works fine in development but when I run a release build, it breaks. There are some errors when I load the bundle:
/assets/bootstrap/js/cljs.core$macros.js:1 Uncaught ReferenceError: goog is not defined
/assets/bootstrap/js/cljs.tools.reader.reader-types$macros.js:1 Uncaught ReferenceError: goog is not defined
/assets/bootstrap/js/cljs.reader$macros.js:1 Uncaught ReferenceError: goog is not defined
/assets/bootstrap/js/cljs.env.macros$macros.js:1 Uncaught ReferenceError: goog is not defined
/assets/bootstrap/js/cljs.analyzer.macros$macros.js:1 Uncaught ReferenceError: goog is not defined
/assets/bootstrap/js/cljs.compiler.macros$macros.js:1 Uncaught ReferenceError: goog is not defined
#2018-09-3018:02lilactowncode is here: https://github.com/Lokeh/lilac.town/blob/master/src/lilactown/client/visual_spec.cljs#2018-09-3018:02lilactownshadow-cljs.edn is here: https://github.com/Lokeh/lilac.town/blob/master/shadow-cljs.edn#2018-09-3019:53thheller@lilactown if you use the self-host stuff you cannot compile with :advanced, only :simple#2018-09-3019:53thhellerso add :optimizations :simple to the :compiler-options#2018-09-3020:07lilactownah bummer#2018-09-3020:01vigilancetechI'm trying to adapt the first hoplon example to shadow-cljs but its giving me a "CompilerException: clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:" error. My ns declaration looks okay to me (but I'm still somewhat new to clojure). Can someone look at it and tell me what might be wrong? Also any other advise in this endeavour would be helpful. /cdn-cgi/l/email-protection:vigilancetech-com/address-book.git#2018-09-3020:04thhellerthats a clojure error. you are probably trying to load a cljs into clj?#2018-09-3020:04vigilancetechhere's my command line: shadow-cljs run build/hop watch app#2018-09-3020:05thhellerthere is no code here https://github.com/vigilancetech-com/address-book#2018-09-3020:05vigilancetechoops! hmm. I wonder where that push went 😄#2018-09-3020:07vigilancetechok, check it again#2018-09-3020:08thhellerno idea whats going on in that repo sorry#2018-09-3020:09thhellerI don't know boot or hoplon#2018-09-3020:11vigilancetechthe build.boot is there but I'm not using it. I just added the shadow-cljs files and tried renaming some stuff to make it work. In a nutshell this is what hoplon does: https://github.com/hoplon/hoplon/wiki/How-is-a-hl-file-different%3F#2018-09-3020:12thhellerthere is not much code in there and I still can't tell whats happening#2018-09-3020:14vigilancetechthe hoplon function just slightly finesses the *.hl file to generate the cljs file with those included namespaces. It just has to run before the cljs compile function does so I set up the build.clj file as per this: https://github.com/thheller/shadow-cljs/wiki/Custom-builds#2018-09-3020:15thhellerhttps://github.com/vigilancetech-com/address-book/blob/master/src/build.clj this doesnt do anything#2018-09-3020:15thhellerand if you are new to clojure creating a custom build is gonna be tough as it requires pretty in depth knowledge about how CLJS and shadow-cljs + CLJ work#2018-09-3020:16thhellerits probably also not for what you are trying to do#2018-09-3020:18vigilancetechI've been having constant trouble getting boot to work with cider. Getting a decent repl doesn't seem to be too much of a priority with the hoplon/boot community, but as I'm working with fairly complex existing app (rather than a new one) I need to be able to get my hands right on the guts of it and understand what makes it "tick"#2018-09-3020:18vigilancetechso it was either this or figwheel under boot, but several of the things you're doing with shadow just seems cleaner#2018-09-3020:19thhellercan you get hoplon to just spit out normal .cljs files?#2018-09-3020:19thhellerthen you don't need to hook into anything and let shadow-cljs just process those cljs files#2018-09-3020:19vigilancetechby "new" I'm meaning I'm probably 6 months in after not having done much programming for a couple decades (with a fair bit of lisp before that)#2018-09-3020:21vigilancetechyeah, I think I could if I could figure out how to either tell boot where to put them or shadow where to find them I guess. I just wanted to start off with baby steps w/shadow to try and fully understand it, like how to get it to run the hoplon function first.#2018-09-3020:21thhelleryeah feeding custom inputs to a build is next level advanced stuff#2018-09-3020:22thhellerdon't do it basically#2018-09-3020:22vigilancetechso that function "hop" I created under the ns won't get called with a "run?"#2018-09-3020:23thhellerthis shadow-cljs run build/hop watch app will call (build/hop "watch" "app")#2018-09-3020:23vigilancetechhmmm... okay, that's somewhat enlightening#2018-09-3022:01joelsanchezafter trying to use npm packages for the 45th time with :npm-deps, I've forced myself to give shadow-cljs a try. I have to say, I'm very much pleased, and I think I've been missing out 🙂#2018-10-0116:55DormoAny comment on how it compares to Figwheel? Liking Figwheel is what keeps me from switching#2018-10-0117:05joelsanchezfor now they seem to offer similar functionality, but these are the benefits of shadow-cljs for me: - very good integration with npm, and ditching of cljsjs. thank God - more reasonable defaults (I had to alter-var-root figwheel's CSS reload notificator because it was so annoying) - better error messages and better monitoring of the state of your build, through the web interface#2018-10-0117:05joelsanchezI can live with most things but if I have to mess with webpack, cljsjs's boot tasks or :npm-deps and the "nameToPath" errors again, I'm switching careers#2018-10-0117:07joelsanchezI met shadow-cljs for the first time when trying to search for a way to do code splitting / modules. the standard solution is a disgrace and shadow-cljs, I think, does a pretty good job#2018-10-0117:26thhelleranother thing may be better and more reliable caching. no lein clean to fix weird bugs 😉#2018-10-0119:12markxHello all! I just found about shadow-cljs. Looks really nice!#2018-10-0119:15markxI just have one quick question: I heard figwheel is the one to use for live loading code change into repl and browser. Does shadow-cljs also take care of this functionality? In the same way figwheel does it?#2018-10-0119:15thheller@markx welcome and yes it has the same functionality#2018-10-0119:16markxgreat! once less thing to deal with 🙂#2018-10-0119:17markxI have to say, shadow-cljs really seems to solve the pain for beginners from JS world.#2018-10-0119:24thhellerthat was kind of the goal yes#2018-10-0119:35markxDoes shadow-cljs use figwheel under the hood, or implement live loading in its own way?#2018-10-0119:36thhellernot using figwheel no. it has its own impl.#2018-10-0121:44markxWhat’s the recommended way to create a new project that uses shadow-cljs?#2018-10-0121:45markxI mean something like lein template, or some command like npm init that generates necessary files.#2018-10-0122:00thheller@markx npx create-cljs-project foo-bar works but its still a work in progress#2018-10-0122:00thhellerstill figuring out how to best handle templates#2018-10-0122:01markxthis create-cljs-project is an npm module?#2018-10-0122:01thhellerits a script on npm yes#2018-10-0122:02thhellerrun it with npx or yarn though. don't install it#2018-10-0122:02thhellerthere are also some lein templates though if you prefer those#2018-10-0122:03markxhmm why not install it?#2018-10-0122:04thhellerwell its a one time use and by not installing it you ensure that you always get the latest version#2018-10-0122:04thhellersimilar to create-react-app etc#2018-10-0122:04thhelleryou can install it but you don't gain much by doing so#2018-10-0122:04markxI see. Yeah I never used npx before. I guess this is a bonus#2018-10-0122:05thhelleryarn create cljs-project foo-bar if you prefer yarn#2018-10-0122:05thhellernpx is useful for running things without isntalling them#2018-10-0122:12markxpretty nice.#2018-10-0122:12markxCould you also recommend me a lein template?#2018-10-0122:15thhellerhttps://github.com/thheller/shadow-cljs#examples#2018-10-0122:41markxhmm <script>starter.browser.init();</script>. What should this be if my namespace is something like foo-bar.core?#2018-10-0122:42markxI know this is something from the closure lib, but maybe it’s confusing for normal js people.#2018-10-0122:51markxah I see. foo_bar.core then#2018-10-0218:04sbIf I get a similar message and yarn add react not helps, then what can I do?
The required namespace "react" is not available, it was required by "reagent/core.cljs".
I read the documentation, but not clear for me. How possible to solve? I added to project.clj exclusions too /cljsjs/react.
#2018-10-0218:04sbSomebody saw similar issue? This is not my project, just an example, just I would like to understand.. maybe I will see in my projects too.#2018-10-0218:06thheller@sb in shadow-cljs you use npm packages directly. so you need to npm install react#2018-10-0218:06thhellerunfortunately reagent doesn't properly declare its dependency on react since it uses cljsjs#2018-10-0218:07thhelleryou probably need npm install react react-dom create-react-class#2018-10-0218:07thhellerif you have an example it probably has those dependencies already set and you just did not run npm install#2018-10-0218:07sbSame example. Now, I have more time to play with that.#2018-10-0218:08sbhttps://github.com/Otann/shadow-cljs-fullstack#2018-10-0218:09thhellerhttps://github.com/Otann/shadow-cljs-fullstack/blob/master/package.json#L22-L26#2018-10-0218:09thhellerthey are declared so you just need to run npm install in the project directory#2018-10-0218:10sbYes, I did it. I test again. Clear npm modules and restart.#2018-10-0218:11sbOk, I don’t know what was the problem. Now works. Sorry!#2018-10-0218:11sbThanks :+1:#2018-10-0220:14markxHi just curious: is it possible to get rid of <script>simple.core.init();</script> from html?#2018-10-0220:26markxoh so it’s just for the first load, and not mandatory. nvm#2018-10-0223:17clojuregeekI’m trying to debug some tests.. is there anyway to do a println ? Tried that and js/console.log#2018-10-0223:23richiardiandrea@clojuregeek are you on node? because the stdout logs at the moment may appear in terminal that you are not expecting (not that test terminal window)#2018-10-0223:23clojuregeekYes#2018-10-0223:23richiardiandrea@clojuregeek yeah so there is an issue open https://github.com/thheller/shadow-cljs/issues/373#2018-10-0300:23lilactownprinting in node shows up in stdout of wherever you're running the node process#2018-10-0320:12wilkerlucio@thheller I noticed when using the web UI, when I stop a build it stops the whole server, I was expecting that the server shoud be only shutdown if I pause all builds (or maybe not even then, enabling to restart those quicker)#2018-10-0320:17wilkerlucioI think it's something to do that I'm starting shadow with shadow-cljs watch app, then if I start other build, and then stop app, the server stops entirely#2018-10-0320:36lilactownyeah, i think you could do shadow-cljs server to avoid it stopping?#2018-10-0320:40wilkerlucioyeah, that probably works, but still weird behavior, so I hope this can be considered a bug and fixed#2018-10-0320:40wilkerluciobecause most of time I like to start watching some build, and change as I see fit#2018-10-0320:47vigilancetechwhat should I do when I get something like this?
The required namespace "cljsjs.markdown" is not available, it was required by "hoplon/ui.cljs".
Put it in my apps shadow dependencies?
#2018-10-0320:56vigilancetechit didn't help#2018-10-0321:05thheller@vigilancetech https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-10-0321:06thheller@wilkerlucio feel free to open an issue to discuss this but yeah this is kind of intended right now since if you stop the build using the UI and restart it the running shadow-cljs watch app will no longer receive output since the build it was watching ended#2018-10-0321:07thhellerI do however have plans for customizing the shadow-cljs server command#2018-10-0321:08vigilancetechis the markdown shim in the shadow-cljsjs library? How do I find out what shims are currently there?#2018-10-0321:08thhellerso that you can write a function that starts everything you want#2018-10-0321:08thheller@vigilancetech https://github.com/thheller/shadow-cljsjs#2018-10-0321:08thhellerhttps://github.com/thheller/shadow-cljsjs/tree/master/src/main/cljsjs#2018-10-0400:49vigilancetechany idea what might be causing this?#2018-10-0404:58vigilancetechcan anyone see the screenshot I just posted? I got a nag about being out of slack space (even tho I only have 3 tiny files uploaded)#2018-10-0408:00thheller@vigilancetech this file does not contain any rgb def https://github.com/hoplon/ui/blob/master/lib/src/hoplon/ui/attrs.cljs#2018-10-0408:01thhellerguess it got moved to https://github.com/hoplon/ui/blob/master/lib/src/hoplon/ui/colors.cljs#L169#2018-10-0413:17vigilancetechDoesn't shadow use my local .m2 repo? The source code I had up in that screen shot is the version installed in it#2018-10-0414:59thheller@vigilancetech it uses ~/.m2 and whichever version you have specified in your dependencies yes#2018-10-0417:29vigilancetech@thheller ok, yeah, my fault. It compiled. Thanks! Now to see if it worked 🙂#2018-10-0418:32thhellerdid you figure out the hoplon .hl -> cljs compile?#2018-10-0418:58priornixHmm, shadow-cljs clj-run does not seem to work?#2018-10-0418:58priornix
shadow-cljs.edn  cli version: 2.6.10  node: v10.11.0
shadow-cljs - starting ...
failed to run function: demo.build/dev
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym demo.build/dev}
ExceptionInfo: failed to run function: demo.build/dev
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:129)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:84)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:145)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:135)
	shadow.cljs.devtools.cli/main (cli.clj:196)
	shadow.cljs.devtools.cli/main (cli.clj:151)
	clojure.core/apply (core.clj:661)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/-main (cli.clj:238)
	shadow.cljs.devtools.cli/-main (cli.clj:236)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.main/main-opt (main.clj:317)
	clojure.main/main-opt (main.clj:313)
	clojure.main/main (main.clj:424)
	clojure.main/main (main.clj:387)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.main.main (main.java:37)
Caused by:
NullPointerException:
	clojure.core/deref-future (core.clj:2292)
	clojure.core/deref (core.clj:2312)
	clojure.core/deref (core.clj:2298)
	shadow.cljs.devtools.server.supervisor/active-builds (supervisor.clj:14)
	shadow.cljs.devtools.server.supervisor/active-builds (supervisor.clj:12)
	shadow.cljs.devtools.api/worker-running? (api.clj:132)
	shadow.cljs.devtools.api/worker-running? (api.clj:128)
	shadow.cljs.devtools.api/watch (api.clj:207)
	shadow.cljs.devtools.api/watch (api.clj:201)
	shadow.cljs.devtools.api/watch (api.clj:205)
	shadow.cljs.devtools.api/watch (api.clj:201)
	demo.build/dev (build.clj:9)
	demo.build/dev (build.clj:6)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/do-clj-run/body-fn--15420--auto----16265 (cli.clj:127)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:126)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:84)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:145)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:135)
	shadow.cljs.devtools.cli/main (cli.clj:196)
	shadow.cljs.devtools.cli/main (cli.clj:151)
	clojure.core/apply (core.clj:661)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/-main (cli.clj:238)
	shadow.cljs.devtools.cli/-main (cli.clj:236)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.main/main-opt (main.clj:317)
	clojure.main/main-opt (main.clj:313)
	clojure.main/main (main.clj:424)
	clojure.main/main (main.clj:387)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.main.main (main.java:37)
#2018-10-0418:59priornix
(ns demo.build
  (:require
    [shadow.cljs.devtools.api :as shadow]
    [clojure.java.shell :refer (sh)]))

(defn dev []
  {:shadow/requires-server true}
  (sh "ls" "-l")
  (shadow/watch :app))
#2018-10-0418:59priornixCalling this from CLI: shadow-cljs clj-run demo.build/dev#2018-10-0419:02priornixAh, okay, I have to run shadow-cljs server first#2018-10-0419:02thhellerno you don't need to run server first#2018-10-0419:02thhellerthats what the meta is for#2018-10-0419:03thhelleryou just placed the meta in the wrong place#2018-10-0419:03priornixWell, it doesn't work though 😞#2018-10-0419:03thheller
(defn dev []
  {:shadow/requires-server true}
  (sh "ls" "-l")
  (shadow/watch :app))
#2018-10-0419:03priornixI have to run server before it works#2018-10-0419:03thhellerbefore the [] not after#2018-10-0419:03priornixOh duh#2018-10-0419:03priornixApologies 🙂#2018-10-0419:03thhelleror (defn ^:shadow/requires-server dev [] ...)#2018-10-0419:03priornixThanks#2018-10-0419:04priornixThink the latter syntax is clearer#2018-10-0419:04priornixAt least for me 🙂#2018-10-0419:05thhellerI prefer the map#2018-10-0419:05priornixAnyway, thanks#2018-10-0419:07priornixAlso a slight clarification in your document might be useful#2018-10-0419:07priornixI tried to create a .cljs instead of a .clj file#2018-10-0419:08priornixSo a slight tip in your document might be useful#2018-10-0419:10priornixI can create a pull request for this#2018-10-0419:11priornixBut where's your asciidoc files stored at?#2018-10-0419:12thhellerhttps://github.com/shadow-cljs/shadow-cljs.github.io#2018-10-0608:58grumpletI'm wondering whether shadow-cljs could help configure antd dependencies rather than pulling in everything with clsjsjs/antd? Anyone aware of any prior art on this? (See https://github.com/priornix/antizer/issues/7 for background)#2018-10-0608:59thheller@grumplet you can require whatever you need in antd via (:require ["antd/es/button" ...]) etc#2018-10-0609:00thhellerif you require "antd" you will get everything though#2018-10-0609:02grumpletOK - that sounds good. I wondered whether antd would be especially awkward because it bundles its css using some webpack feature that I don't pretend to understand.#2018-10-0609:02thhellercss is not currently handled by shadow-cljs so you need to require those elsewhere#2018-10-0609:03thhellerbut otherwise everything works fine#2018-10-0609:03grumpletOK - so I find a way to extract antd css and then simply require the code.#2018-10-0609:03thhellerI even used antd as a sample for the build reports features#2018-10-0609:03thhellerie. including antd fully https://code.thheller.com/demos/build-report/huge.html#2018-10-0609:04thhellervs. just requiring whatever is used antd/es/button in this case https://code.thheller.com/demos/build-report/not-so-huge.html#2018-10-0609:04grumpletThis sounds like what I've been looking for. Will go play! 🙂#2018-10-0610:22Pontusis being able to import css something that will be implemented in the future in shadow-cljs?#2018-10-0610:23thhellerstill undecided. probably not in shadow-cljs itself but rather something you can use via build hooks#2018-10-0610:26Pontuswould be cool 🙂 If there's one thing I miss from javascript it's the ability to just do import './style.css' -- the closest I've come to that is this library but it's deprecated: https://github.com/rgdelato/styled-classnames#2018-10-0610:27thhellerI personally use https://github.com/thheller/shadow/wiki/shadow.markup a lot#2018-10-0610:27thhellereg. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/style.cljs#2018-10-0610:29Pontuslooks like styled-components#2018-10-0610:29thhelleryep#2018-10-0616:18kanweiFYI shadow doesn't seem to startup on alpha9/beta1#2018-10-0618:11markxHi does anyone use vim fireplace with shadow?#2018-10-0620:52thheller@kanwei starts and works fine for me?#2018-10-0621:39vigilancetech@thheller No, I didn't figure out the .hl ->cljs compile yet. Fighting other issues now, but when I do I'll post it#2018-10-0700:45kanwei@thheller it hangs after calling shadow.cljs.devtools.server/start! via a boot task#2018-10-0701:27peteypeteI’m using shadow to deploy a production build that includes the library, re-frame-firebase. https://github.com/deg/re-frame-firebase. If I run with :optimizations :simple or :advanced, I get the following error.
------ WARNING #1 --------------------------------------------------------------
 File: firebase/app.cljs:1:14

 constant firebase assigned a value more than once.
Original definition at externs.shadow.js:6
--------------------------------------------------------------------------------
If I run with :optimizations :whitespace, I do not get any compile errors but the browser is not happy and I get
main.js:3157 Uncaught TypeError: Cannot set property 'Error' of undefined
    at main.js:3157
    at main.js:15494   Uncaught TypeError: Cannot read property 'main' of undefined
    at window.onload ((index):14)
goog.nodeGlobalRequire=function(path){return false};goog.provide("goog.debug.Error")
Any ideas on what is going on and how to resolve? TNX
#2018-10-0712:02thheller@kanwei no idea but the log you posted clearly shows that you have some dependency conflicts which may cause issues#2018-10-0712:02thhellerie. version 1.3.0 + 1.3.1 of the linked lib are both on the classpath#2018-10-0712:03thhellerlikely there are other conflicts#2018-10-0712:04thheller@peter005 thats a warning not an error?#2018-10-0712:05thhellerdo you have the cljsjs.firebase shim setup correctly?#2018-10-0712:46bbssHitting some weird issue with an undeclared warning, not sure if it's the cljs compiler or something in shadow-cljs.#2018-10-0712:46bbss
(go-loop []
  (let [[[request-spec preload started] result] (<! finished-requests)
        request-took-ms (- (.getTime (js/Date.))
                           (.getTime started))
        latest-ten (cons request-took-ms (take 9 @avg-processing-time-coll))
        avg-processing-time (/ (reduce + latest-ten) (count latest-ten))]
    (when (not preload)
      (do (aset result "took" (+ avg-processing-time 100))
          (js/postMessage result #js [result])))
    (recur)))
#2018-10-0712:46bbssSays result is undeclared.#2018-10-0712:49thhellerno idea. maybe core.async doesn't like the nested destructure?#2018-10-0712:49bbssSorry, I should edit that. The issue doesn't happen for this code exactly.#2018-10-0712:50bbssWith the data literal it gives the warning. Without it doesn't.#2018-10-0712:52thhellerI'm guessing core.async macro maybe gets confused?#2018-10-0712:53bbssYeah could be the go loop.#2018-10-0712:54bbss
163 |           (js/postMessage #js {:result result} (to-array [(aget result "data")]))))
----------------------------------------------^---------------------------------
Use of undeclared Var gsv.worker/result
#2018-10-0712:55thheller(js-obj "result" result) does that complain?#2018-10-0712:57bbssTried (js/postMessage (clj->js {:result result}) (to-array [(aget result "data")])) that works.#2018-10-0712:57bbssdidn't consider js-obj, that is less invasive probably. Trying that.#2018-10-0712:58bbssWeird issue though! 😄#2018-10-0714:32thheller@bbss I can reproduce this easily ... will see if its shadow-cljs or upstream
(go (let [a 1]
      (prn a)
      (prn #js [a])
      (prn #js {:a a})))
#2018-10-0714:32thhellerwarns about both #js uses#2018-10-0714:32thhellerprobably core.async though, no issues without the go#2018-10-0716:46thheller@bbss https://dev.clojure.org/jira/browse/ASYNC-132#2018-10-0716:57thheller@kanwei maybe you are running into this https://dev.clojure.org/jira/browse/CLJ-2414. hard to tell since it seems to be working fine for me#2018-10-0716:58thhellerbut the example specifically mentions sun.nio.fs.UnixPath and I'm on Windows so that might explain it#2018-10-0723:15peteypete@thheller Tnx for pointing me in the right direction. Shim needs some attention.#2018-10-0801:51mynomoto@vigilancetech you could not use .hl files and have no problems with compiling them. That's how I was using hoplon.#2018-10-0803:18vigilancetech@mynomoto ???#2018-10-0816:38eoliphantHi. I seem to have run into issues with more recent versions of AWS amplify. Using aws-amplify-react 2.0.7 and shadow 2.6.10 requiring this ["aws-amplify-react" :refer [Authenticator]] causes this:
The required JS dependency "babel-runtime/helpers/extends" is not available, it was required by "node_modules/aws-amplify-react/dist/AmplifyUI.js".

Searched in:/Users/ErichOliphant/Documents/projects/sqd/node_modules

You probably need to run:
  npm install babel-runtime/helpers/extends
The transpiled AmplifyUI.js has the following
...
var _extends2 = require('babel-runtime/helpers/extends');


But the babel runtime package has the preceding @ in node_modules which I presume is the problem. Why can't everyone just use clojurescript.. Ugh...
#2018-10-0817:23thheller@eoliphant this might just be a version conflict. check if node_modules/babel-runtime exists?#2018-10-0817:23thhellerbabel v7 switched to using @babel/... scoped packages#2018-10-0817:24thhellerbut the old version should still be installed, just might be getting installed in a nested folder?#2018-10-0817:24eoliphantah hell. totally misread that#2018-10-0817:24eoliphantthe error#2018-10-0817:24eoliphantyeah what's there now is @babel/runtime/...#2018-10-0817:24thhellerbut since its a new package the old one should still be available?#2018-10-0817:25eoliphantyeah#2018-10-0817:25eoliphantalso trying to look at who's pulling the newer one in#2018-10-0817:26eoliphanti'm not grabbing it explicitly#2018-10-0817:26eoliphantugh#2018-10-0817:26eoliphantok found it#2018-10-0817:26eoliphantsemantic-ui-react#2018-10-0817:26eoliphantrequires ^7.0.0#2018-10-0817:26thhellerbut that has different packages#2018-10-0817:26thhellerthe OLD packages will not conflict with the new ones#2018-10-0817:26eoliphantah i see what you're saying#2018-10-0817:27eoliphantbecause the pkg name is entirely different#2018-10-0817:27thhellerif in doubt just rm -rf node_modules and npm install#2018-10-0817:27eoliphantthe 'new and improved' amplify setup#2018-10-0817:27eoliphantacutalyl has you do some wacky stuff by hand#2018-10-0817:27thhellerhow so?#2018-10-0817:27eoliphantbefore you actually npm install the packages themselve#2018-10-0817:28eoliphanti just ignored it#2018-10-0817:28eoliphantone sec#2018-10-0817:29thhellernpm WARN #2018-10-0817:29thhellerdid you install that?#2018-10-0817:30thhellercompiles fine for me when I npm install aws-amplify aws-amplify-react#2018-10-0817:30eoliphantthey have you create this seed file with the scripts and dev deps first, then you install amplify but in any case will try just installing babel-runtime by hand#2018-10-0817:30eoliphantreally...#2018-10-0817:30eoliphantI did npm install aws-amplify aws-amplify-react#2018-10-0817:30eoliphantas well#2018-10-0817:31thhelleryou likely just have a dependency conflict somewhere#2018-10-0817:31thhellercheck FIRST if node_modules/babel-runtime exists and is NOT empty (it might be)#2018-10-0817:32thhellerTHEN check if node_modules/aws-amplify-react/node_modules/babel-runtime exists and is not empty#2018-10-0817:32thhellerif THAT exists you have a version conflict somewhere#2018-10-0817:32eoliphantah no I didn't lol. ugh. Been working for about 18 hrs straight probably time for a break. I only did amplify-react..#2018-10-0817:34thhellerthere is a command to list dependency conflicts but I forgot what it was#2018-10-0817:34eoliphantbut hmm that didn't help there's still no node_modules/babel-runtime And the only thing under node_modules/aws-amplify-react/node_modules is regenerator-runtime whatever that is#2018-10-0817:35eoliphantgonna try blowing node_modules away#2018-10-0817:36thhellerwhat happens if you just install it?#2018-10-0817:36thhellerif it doesn't exist you can just isntall it?
#2018-10-0817:36eoliphantyeah will try that next#2018-10-0817:36eoliphantalready blew away node_modules#2018-10-0817:37eoliphantif that doens't work will add it by hand#2018-10-0817:40thhelleroh shit I think I know what might be happening#2018-10-0817:41thhellerhmm no it just doesn't declare the dependency#2018-10-0817:43thhellerjust npm install babel-runtime should fix it#2018-10-0817:43thhellerI just had it installed because some other package was using it#2018-10-0817:50kanwei@thheller yeah that infinite loop seems to fit the description of what i was seeing - thanks#2018-10-0818:04eoliphantThanks @thheller.. yeah again.. why can't everyone just use cljs lol#2018-10-0818:28eoliphantHey I'm also having this problem again (https://github.com/thheller/shadow-cljs/issues/228) pulling in auth0-js with :default or :as results in a nil symbol#2018-10-0818:37thheller@eoliphant their minified packaging seems to do really weird stuff to the code that may trip up the closure compiler#2018-10-0818:37thheller(:require ["auth0-js/dist/auth0.js" :as auth0]) seems to work fine#2018-10-0818:38eoliphantit's always something lol#2018-10-0818:38eoliphantah cool#2018-10-0818:38thhelleryou should be getting a warning in the browser console#2018-10-0818:38eoliphantwill try that#2018-10-0818:38eoliphantyeah was getting this ' Cannot read property 'lib' of undefined'#2018-10-0818:38eoliphant
shadow.js.js:88 Uncaught TypeError: Cannot read property 'lib' of undefined
    at auth0.min.js:9
    at auth0.min.js:9
    at createCommonjsModule (auth0.min.js:9)
    at auth0.min.js:9
    at auth0.min.js:9
    at Object.shadow$provide.module$node_modules$auth0_js$dist$auth0_min (auth0.min.js:9)
    at Object.shadow.js.jsRequire (shadow.js.js:85)
    at Object.shadow.js.require (shadow.js.js:111)
    at sqd.ui.components.auth0.js:5
#2018-10-0818:39thhelleryeah the minified package is just weird#2018-10-0920:47joelsanchezhaving some...problems here#2018-10-0920:48joelsancheznormally shadow-cljs works flawlessly, this happens on very specific circumstances. I will post the solution when/if I find it#2018-10-0920:52thheller@joelsanchez this looks like an internal closure compiler error, this sometimes happens with weird JS code on npm it just doesn't like#2018-10-0920:52thhellertypically there isn't much to be done besides reporting it to them and wait for the fix#2018-10-0920:53thhellerhelps a lot to reproduce with on the closure compiler though#2018-10-0920:53thhelleralthough NoSuchMethodError is weird so it may just be a dependency conflict?#2018-10-0921:08thheller@joelsanchez if you use lein or deps make sure you are getting the correct closure-compiler version#2018-10-0923:37joelsanchez@thheller yeah it was that. using an old closure compiler because of a deps conflict. thank you!#2018-10-1007:07sbIf somebody created shadow-cljs with xterm, what is the experience, what is the best approach?#2018-10-1007:09thhellersome of the shadow-cljs UI uses xterm.js but I'm not actually sure about the best approach yet. it doesn't fit well into the react model#2018-10-1007:09sbYes, I see too.#2018-10-1007:10sbThanks the answer!#2018-10-1012:50romdoqIs there a better dev workflow for working on an :npm-module than to have a separate stand-alone :browser target build for development? I currently have my project successfully imported as a module into our website, but hot-reloading doesn't seem to work out of the box that way (unless I've messed something up).#2018-10-1013:44thheller@mel.collins hot reloading with npm-module is tricky since shadow-cljs is not in charge of the final bundle. so it is not super reliable#2018-10-1013:44thhellerbut you can set :runtime :browser in your config#2018-10-1013:44thhellerand then require("shadow-cljs/shadow.cljs.devtools.client.browser") somewhere in your JS#2018-10-1013:44thhellerthat may or may not make the live-reloading work#2018-10-1013:45thhellerdepends on what webpack does with the code and stuff#2018-10-1014:47romdoqHmm, well that require() did the trick when I embedded it in the code of the website itself, but I'd prefer to keep the cljs stuff limited to my cljs module so I guess I need to keep poking at this tomorrow.#2018-10-1014:48thheller@mel.collins unfortunately due to the way :npm-module works there is no easy way to do this outside of doing it via the JS#2018-10-1014:49thhellerbut typically you can just wrap it in if (process.env.NODE_ENV == "development") { ... } and you are set#2018-10-1015:06romdoqaha! I got it working a with a (defonce _hack (js/require "...")) in my main cljs file.#2018-10-1015:06romdoqthat feels really dirty though 😄#2018-10-1015:07romdoqguess the next task is to make it only do that for the dev build#2018-10-1015:12thheller@mel.collins yeah thats a bit dirty 😛#2018-10-1015:13thhelleryou can wrap it in (when ^boolean js/goog.DEBUG ...) that should remove it from production#2018-10-1015:13thhellerdoesn't make it cleaner though 😛#2018-10-1015:22romdoqfantastic! That worked perfectly. 😄 You're a hero @thheller.#2018-10-1015:23romdoqI think our codebase is already somewhat dirty, so I should be able to get away with it!#2018-10-1021:40lilactownwhen I connect to shadow-cljs via nREPL, I get a message "version-to-list: Version must be a string" and I'm not able to send forms to it from a file / get any sort of autocomplete#2018-10-1021:40lilactownall of this via CIDER#2018-10-1021:42lilactownevaluating directly in CIDER buffer works, just no autocomplete#2018-10-1021:44thheller@lilactown that message is not from shadow-cljs so no idea whats happening#2018-10-1022:02lilactownheh, I guess I accidentally removed cider-nrepl from my deps 🙄#2018-10-1022:17eoliphantquick question, I'm trying to make sure I'm doing the best I can to help shadow optimize the size of the build. This is in a reagent project, that's using semantic ui react. I'd previously created a helper namespace that aliased the semantic ui react namespace, and had def's of all the components with adapt-react-class applied. I figured that since that was a 'use' of the react class, I was effectively pulling everything in. I've since setup another experiment, where I'm just pulling in a few classes for a small page. However, when I run the build report, I'm still seeing roughly the same 'optimized' size#2018-10-1022:18thheller@eoliphant make sure what you are not somehow including the main semantic-ui-react package directly as that it itself will pull everything in (regardless of use)#2018-10-1022:19thhellerthere is no :advanced compilation for node_modules so it doesn't do full dead code removal#2018-10-1022:20eoliphantah gotcha#2018-10-1022:20thhellerso just including something usually means that is all included#2018-10-1022:20eoliphantyeah that's exactly what i'm doing#2018-10-1022:23thhellerdo you actually include only what you need though? the webpack instructions do not apply here#2018-10-1022:23eoliphantyeah in my test code, i :refer'ed just the components I wanted, but to your point I did it from the top level package#2018-10-1022:24thhellerno that is not how it works#2018-10-1022:24thhellerassuming that you mean (:require ["semantic-ui-react" :refer (Thing)])#2018-10-1022:24thhellerthat will include everything#2018-10-1022:24eoliphantexactly#2018-10-1022:24thhellerthis does not work#2018-10-1022:25eoliphantright so I need#2018-10-1022:25thhellerinstead you must (:require ["semantic-ui-react/dist/es/views/Card" :as Card])#2018-10-1022:25thhellerfor example ..#2018-10-1022:25eoliphantyeah#2018-10-1022:25eoliphantthat's what I'm doing now#2018-10-1022:26eoliphantso now i'm thinking, a nice 'wrapper' would be maybe a macro or something that hides all the pathing#2018-10-1022:27thhellernot possible via macro#2018-10-1022:27eoliphantah ok, that's no fun lol#2018-10-1022:28thhelleryeah I have no solution right now since I do not think that using :refer to eliminate code is a useful thing to do in the first place#2018-10-1022:29thhellerand the way the JS world structures code is just messy and every projects does its own thing#2018-10-1022:29eoliphantgotcha, so its ultimately back to externs + the JS insanity#2018-10-1022:29eoliphantyeah you obviously deal with this more than the rest of us#2018-10-1022:29eoliphantbut just the few times I've pinged you about stuff#2018-10-1022:29thhellerwell ... IMHO just importing what you need is not really all that bad#2018-10-1022:30eoliphantand went into the offending package#2018-10-1022:30eoliphantyeah literally each case was different#2018-10-1022:30eoliphantYeah I don't mind it too much, but it also goes back to your point about everyone doing their own thing#2018-10-1022:31eoliphantso I just fixed my example per your advice#2018-10-1022:31eoliphantthis works ["semantic-ui-react/dist/es/collections/Menu" :refer (Menu MenuItem Image MenuMenu) ] just fine and now there's 73 vs 400+ kb of stuff#2018-10-1022:32eoliphantbut that directory is potentially a brittle reference#2018-10-1022:32eoliphantif they decide to muck around with the distro, etc#2018-10-1022:32eoliphantbut in any case problem solved for now 🙂#2018-10-1022:32thhelleryeah its annoying#2018-10-1022:33thhellerbut at this point I'm very doubtful the JS world is every gonna adopt a clean namespacing scheme 😛#2018-10-1022:33eoliphantyeah#2018-10-1022:33thhellersome packages at least try to have nicer paths#2018-10-1022:33eoliphantholding one's breath#2018-10-1022:33eoliphantis probably not adviseable#2018-10-1022:34thhellerI could add some special magic that could maybe shorten this somehow to at least get rid of the dist/es but thats just not gonna be reliable again#2018-10-1022:34eoliphantthough I had a moment of extreme gratification yesterday. finally got the go ahead to do the "2.0" of a pretty large project in clojure(script)/datomic cloud etc#2018-10-1022:34thhellergiven the amount of random shit the packages do#2018-10-1022:34eoliphantbeen focusing on the backend, but just had one of the ui devs come up and say 'this is all you have to do???'#2018-10-1022:35eoliphanthe's apparently not a big fan of webpack lol#2018-10-1022:35thhellerhehe#2018-10-1022:36thhellerwe should just write our own cljs-react-ui so we can get rid of the messy JS packages 😉#2018-10-1022:36eoliphantironically i didn't realize just how insane it is. I focus more on architecture, and far more hands-on on server side stuff, so when ever I did UI stuff, i'd just do a create-react-app etc#2018-10-1022:36eoliphanthad no friggin idea#2018-10-1022:36eoliphanthow much insanity it hides#2018-10-1022:36eoliphanti know#2018-10-1022:36thhellerhehe yeah its a complete mess#2018-10-1022:37thhellerI'm always amazed it works at all 🙂#2018-10-1022:37eoliphantwe just need to get the rest of the world to drink the kool aid#2018-10-1022:37eoliphantwell yeah a while back I think i bugged you about trying to get this Material UI framework working#2018-10-1022:38eoliphantand that's what prompted me to learn more about all the frigging magic that's going on#2018-10-1022:38Nolanmay have come up before, but i get an issue with the stream dependency when trying to (require '["sjcl" :as sjcl]). may be an easy fix, still havent gotten to the point where i can grok these types of issues quickly#2018-10-1022:38eoliphantbecause they were using plugins to inmport images, css, etc etc. That 'look like' imports. ugh..#2018-10-1022:40thheller@nolan what is the problem?#2018-10-1022:41Nolanjust get “…probably need to run npm install stream” even after npm installing stream.#2018-10-1022:42Nolanso likely with the way stream is written or bundled#2018-10-1022:42thhellerah you are probably missing the shadow-cljs install in your actual project?#2018-10-1022:42Nolanah, ill try that#2018-10-1022:44thhellerstream is one of those node native packages that is emulated for the browser#2018-10-1022:45thhellerusing https://www.npmjs.com/package/stream-browserify not https://www.npmjs.com/package/stream#2018-10-1022:45thhellerthe first one is installed automatically when you install shadow-cljs in the project#2018-10-1022:45thhellerso shadow-cljs should always be in your package.json devDependencies (or dependencies)#2018-10-1022:47Nolanthat makes a bunch of sense. working beautifully. thanks for the quick help @thheller.#2018-10-1022:49Nolantotally agree with @eoliphant, shadow takes so much friction out of working with js deps. really appreciate everything!#2018-10-1101:52vigilancetechcan someone here tell me what I'm missing? my shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [
  [binaryage/devtools "0.9.10"]
  [adzerk/env                "0.3.1"          :scope "test"]
  [com.rpl/specter "1.1.1"]
  [hoplon/hoplon "7.3.0-SNAPSHOT"]
  [cljsjs/markdown                          "LATEST"]
  [vigilancetech/ui "0.3.0-SNAPSHOT"]
  ]

 :builds
 {:app { :target :browser
        :compiler-options {:language-in :ecmascript5-strict }
        :output-dir "public/assets/app/js"
        :asset-path "/assets/app/js"
        :build-hooks [(build.hop/foo)]
        :modules {:main {:entries [guardian.dashboard]}}}}}
under src/build/hop.cljs
(ns build.hop
  (:require [shadow.cljs.devtools.api :as shadow]
            [hoplon :refer hoplon]))

(defn foo
  {:shadow/requires-server true}
  [build]
  (hoplon/hoplon)
  (shadow/watch (keyword build)))
With the command line:
shadow-cljs run build.hop/foo app 
I'm getting the error:
failed to load namespace: build.hop 
#2018-10-1106:53thheller@vigilancetech you can only run Clojure functions but you created a .cljs file. must be either .clj or .cljc#2018-10-1106:54thhellerand your :build-hooks is not correct#2018-10-1106:55thhellereither you use run or :build-hooks but the same function cannot be used for both#2018-10-1107:01thhelleralso there is no such thing as a hoplon namespace as far as I can tell?#2018-10-1107:01thhellerI just looked over the hoplon impl and it pretty much seems to require boot to work at all#2018-10-1110:20thheller@kanwei did you test clojure-1.10 beta2 yet? I assume it fixes the issue but confirmation would be nice#2018-10-1114:44vigilancetech@thheller thanks for your observations. It looked to me like hoplon was just a preprocessor to finesse the files to get some of its libraries in context (like to address a shortcoming in clojurescript refer) and expand some macros (another shortcoming in earlier clojurescript). https://github.com/hoplon/hoplon/wiki/How-is-a-hl-file-different%3F I'm fairly new to this. You see something different?#2018-10-1114:46thheller@vigilancetech well its important to look for the details#2018-10-1114:46thheller> could be replaced with the following .cljs file#2018-10-1114:47thhellerso you could write that .cljs files and shadow-cljs will understand it no problem#2018-10-1114:47thhellerBUT#2018-10-1114:47thheller> :hoplon/page metadata will tell boot hoplon task to generate the HTML file for the given namespace#2018-10-1114:47thhellerthe "boot hoplon task" requires boot and won't be executed without it#2018-10-1114:47thhellerso I don't know how useful to standalone .cljs file really is#2018-10-1114:49thhellerI don't know anything about the architecture that hoplon wants but it looks to me that is requires boot#2018-10-1114:56vigilancetech@thheller IIRC the boot tasks are fairly generic (e.g. its simple to make your own custom ones) but you've given me a direction to focus on, thanks.#2018-10-1114:56thhellerit doesn't matter how generic they are .. they still require boot#2018-10-1114:57thhellerbut as far as I can tell it doesn't do any CLJS compilation on its own#2018-10-1114:57thhellerso the default result is to generate a bunch of .cljsand .html files#2018-10-1114:58vigilancetechI think there's just one of each, and from my observation the html file never changes as its just a launcher for the resultant js#2018-10-1114:59vigilancetechwhat appears to me is the big thing about boot is the ability to customize in your own commands and the encapsulation it gives them and each part of the compile process#2018-10-1115:00thhelleryes as long as you stay within boot that is true#2018-10-1115:01vigilancetechbut from what I can tell there's been very little attention in that community given to keeping a REPL going for a long time and I prefer being able to go directly to NPM like you're doing. Also I'm sick of having to restart the JVM each time I tinker with the build.boot file#2018-10-1115:02thhellerwell yeah boot fundamentally is a build tool on its own. a REPL is a long running process which doesn't exactly fit into the whole build tool theme where each task runs after each other but is supposed to finish#2018-10-1115:04vigilancetechit seems like the whole hoplon/boot community de-emphasizes needing a REPL but I'm too much of a noob to really be able to do without one (and I'm dealing with a fairly sophisticated existing application code base which essentially makes my work more akin to reverse-engineering; a task that's virtually impossible without one)#2018-10-1115:07thhellerthere is https://github.com/degree9/boot-shadow written by @flyboarder who is also involved in hoplon I think#2018-10-1115:07thhellermaybe he can help#2018-10-1115:07thhellerbut I have no idea how any of it works either and there have been issues in the past#2018-10-1115:13vigilancetechOkay. I've talked to him before about other issues. I'll ask him for more details. Thanks.#2018-10-1116:28vigilancetech@thheller I've commented out the :build-hooks, renamed my hop.cljs to hop.clj, and tried to "run" foo and I'm still getting
failed to load namespace: build.hop
#2018-10-1116:28thhellerif you still have [hoplon :refer hoplon] then its because it can't load that#2018-10-1116:29thhellertry running shadow-cljs clj-repl instead and (require 'build.hop)#2018-10-1116:29vigilancetechok#2018-10-1116:30vigilancetechyeah, looks like you're right:
[12:0]~shadow.user=> (require 'build.hop)
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec:
In: [1] val: ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])) fails spec: :clojure.core.specs.alpha/ns-form at: [:args] predicate: (cat :docstring (? string?) :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses),  Extra input
 #:clojure.spec.alpha{:problems [{:path [:args], :reason "Extra input", :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [shadow.cljs.devtools.api :as shadow] [hoplon :refer hoplon])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x780884b2 "
#2018-10-1116:31vigilancetechextra input? Sounds like a parens mismatch or something#2018-10-1116:32vigilancetechor it doesn't like a doc string?#2018-10-1116:33thhellerit doesn't like [hoplon :refer hoplon]#2018-10-1116:33thheller:refer is always a collection of symbols#2018-10-1116:33thhellerbut the hoplon ns doesn't exist in the first place#2018-10-1116:34thheller[hoplon :refer (hoplon)] would be correct use of :refer but hoplon is still invalid#2018-10-1116:34vigilancetechgot it#2018-10-1116:35vigilancetechdoes it matter if the symbols are a list or a vector? Cuz other than in some of your code I seem to recall only seeing them in a vector#2018-10-1116:35thhellerI personally always use lists for :refer but it can be a vector too yes#2018-10-1116:39flyboarder@vigilancetech @thheller just going through the chat, what can I help with?#2018-10-1116:40vigilancetech@flyboarder I was trying to swap out boot for shadow-cljs on a project so I can take mostly take advantage of the latest cider release#2018-10-1116:40vigilancetecha hoplon project#2018-10-1116:40vigilancetech(but also because of some other features I like in shadow)#2018-10-1116:40flyboarderAh I have recently migrated all my work to shadow-cljs via the boot task mentioned above, I have not used cider so I am not sure how that would fit in#2018-10-1116:41vigilancetechwell, its supposed to be fairly easy once you can get the shadow cljs repl fired up#2018-10-1116:41vigilancetechdoes your boot task do the shadow watch also?#2018-10-1116:41flyboarderthat was super easy to get going, @thheller has done a great job#2018-10-1116:41flyboarderNo I let boot handle the watch command#2018-10-1116:42flyboarderI have some example code, one sec#2018-10-1116:42vigilancetechokay, cuz I think shadow has to do the watch to get the repl#2018-10-1116:42flyboarderyou can launch the repl without watch#2018-10-1116:42thhellerno you can't?#2018-10-1116:43vigilancetechwell, doesn't watch inject the repl stuff into your project (so you connect to the browser with your repl client)?#2018-10-1116:43flyboardershadow-cljs binary might need it but boot can handle that for you#2018-10-1116:43flyboarderboot watch shadow/server#2018-10-1116:43flyboarderwill keep the server running#2018-10-1116:44flyboarderboot watch shadow/compile or boot watch shadow/release#2018-10-1116:44vigilancetechwhat I was thinking is to not use boot at all, but just get shadow to "preprocess" my source files with hoplon, but hoplon doesn't appear to be/have a namespace so shadow run barfs#2018-10-1116:45flyboarderI am just going to show you all the relevant shadow stuff for how I do it, shadow file above^#2018-10-1116:46vigilancetechok, thx#2018-10-1116:47flyboarderthese tasks wrap boot-nodejs and boot-hoplon and run the boot-shadow task#2018-10-1116:49flyboarderthats basically it I think#2018-10-1116:49vigilancetechhave you been using the shadow cljs repl?#2018-10-1116:50flyboarderyep, the tricky parts all here https://github.com/degree9/enterprise/blob/master/src/degree9/repl.cljs#2018-10-1116:50vigilancetechokay, thanks. I got some stuff here to digest 🙂#2018-10-1116:51flyboarderonce you have the server running with the compilation environment, you can use the shadow-cljs binary to connect to the repl-server#2018-10-1116:51thhellerI have absolutely no clue what is happening in this code#2018-10-1116:52flyboarder@thheller which part can I explain better?#2018-10-1116:52thheller(comp (shadow/compile :build :client)) what is this?#2018-10-1116:52thhellerthats not a valid shadow-cljs API anywhere?#2018-10-1116:52flyboardershadow/ is from boot-shadow it wraps the shadow-cljs library and calls it as a boot task#2018-10-1116:53thhellerah#2018-10-1116:54flyboarderboot has a “build pipeline” which is represented here#2018-10-1116:56vigilancetech@flyboarder can you describe the reasoning behind your decision to use boot to drive shadow rather than just trying to run the hoplon pre-process from shadow and eliminate boot completely?#2018-10-1116:56thheller@vigilancetech the hoplon pre-process is a boot task. you simply cannot run that from shadow-cljs.#2018-10-1116:57flyboarderSure, we have a 1 language rule, everything on the development side is done in clojure (boot) and everything within the project compiles to clojurescript (nodejs/hoplon/feathers)#2018-10-1116:57flyboarderAgreed^ boot tasks cannot run in other clojure contexts#2018-10-1116:58flyboarderas it relies directly on the custom environment shown above#2018-10-1116:58vigilancetechso hoplon is really complected with boot#2018-10-1116:58flyboardernot at all#2018-10-1116:58flyboarderhoplon is just clojurescript#2018-10-1116:58flyboarderboot-hoplon depends on boot#2018-10-1116:59vigilancetechok, so boot-hoplon is complected with boot. Hoplon proper is basically a cljs library. Is that essentially correct?#2018-10-1116:59flyboarderyes#2018-10-1116:59flyboarderall things regarding boot and hoplon aside, this comes down to a problem of preprocessing#2018-10-1116:59vigilancetechand boot-hoplon is the preprocessor#2018-10-1116:59flyboardernot really#2018-10-1117:00flyboarderboot-hoplon was its own project, we bundled it with hoplon to simplify dependencies because it does nothing if you never load the code#2018-10-1117:00flyboarderthe preprocess task in boot-hoplon is old and uses phantom.js#2018-10-1117:01flyboarderso the question becomes how do I preprocess using shadow-cljs#2018-10-1117:02flyboardermy solution is you dont, you use boot for that#2018-10-1117:02vigilancetechbut it seems, at first glance, that hoplon's pre-processing is so simple.#2018-10-1117:03vigilancetechhttps://github.com/hoplon/hoplon/wiki/How-is-a-hl-file-different%3F#2018-10-1117:04vigilancetechis there much more to it than that?#2018-10-1117:09vigilancetechisn't the html that's generated (by hoplon-boot reading the ^{:hoplon/page "index.html"}) just a launcher for the js that's created by the hlisp, etc...? https://github.com/hoplon/hoplon/wiki/HLisp#2018-10-1117:22flyboardernot quite, HLisp is really just the dom stuff#2018-10-1117:23flyboarderthe preprocessing happens by using an internal script to load the app in phantom and grab a snapshot of the dom#2018-10-1117:24flyboarderthere is also the convenience macros which do some file level code manipulation#2018-10-1117:25flyboardermy experience with shadow has been to ignore the file generating that boot-hoplon does because it really doesn’t align with how shadow handles the directory structure#2018-10-1117:25flyboarderso I just use a static html file#2018-10-1117:28vigilancetechyeah, that seems similar to the index.html I've found that hoplon/boot creates by default. Thanks for explaining the purpose of the prerendering. That was going to be my next question.#2018-10-1117:29flyboarderyeah it’s best to just use hoplon as a cljs lib with shadow, which work really well it’s just you need to manually configure a bunch of things#2018-10-1117:30flyboarderI am sure there is probably a perfect configuration of shadow that would let boot-hoplon do its thing but I have yet to find it#2018-10-1117:32flyboarderAlso when boot does the converting from .hl to .cljs its slow…. like reeeeaaalllly slow….#2018-10-1117:32vigilancetechI guess the reason why I'm digging so hard on this is because my eventual goal would be to use hoplon from lumo#2018-10-1117:33flyboarderyeah so just use it as a cljs library and dont use .hl or the (page) macro#2018-10-1117:33vigilancetechto jettison the JVM/transcompile situation completely#2018-10-1117:33flyboarderthat will work well and wont be build tool specific#2018-10-1117:34flyboarderyeah you could drop boot entirely if you wanted#2018-10-1117:34vigilancetechok, thanks for the insight.#2018-10-1117:35vigilancetechhave you looked into using hoplon from lumo at all yet?#2018-10-1117:35flyboarderI like the idea of just using javascript, but the problem I see is already happening in the js ecosystem, we get all these tools that kinda do the same thing#2018-10-1117:35flyboarderyeah a bit, no working projects tho#2018-10-1117:36flyboarderlike the thing thats awesome about boot is that it’s an environment for building things not a build tool#2018-10-1117:37flyboarderI think boot will get ported over eventually tho#2018-10-1117:38vigilancetechthink boot will get ported over to cljs?#2018-10-1117:38flyboarderyeah the problem there is the classpath#2018-10-1117:38flyboardersolve that for me and I’ll put in the time to port the rest#2018-10-1121:08richiardiandreaBtw lumo has a translation layer from file (node modules) to classpath so maybe that port is not that far away...at the end of the day it is files right?#2018-10-1121:10richiardiandreaWell and files in zip files :)#2018-10-1117:40vigilancetechthat would be cool and a significant step to getting into lumo. I'll keep it in mind for my almost non-existent spare time!#2018-10-1117:47flyboarderyeah me too, if you need help with a boot/shadow setup let me know, it works really well#2018-10-1117:52vigilancetechthanks, I probably will. Actually looking at my app, it already doesn't use *.hl/(page) and it compiles. I just can't figure out how to get the shadow web server to serve it yet. It does have the ^{:hoplon/page "index.html"} metadata on (ns) however. The build.boot does call (hoplon) in the "develop" task tho.#2018-10-1117:52vigilancetech*it compiles with shadow#2018-10-1118:28flyboarderah so for my projects, I start a server with boot-nodejs, because by backend is cljs#2018-10-1118:29flyboarderand my backend serves my frontend#2018-10-1118:29flyboarderyou could drop in any static server as a boot task#2018-10-1118:39kanwei@thheller yup fixed in beta2 as expected#2018-10-1118:40kanweithanks for looking into it#2018-10-1123:32Bravihi everyone. is it correct to put [binaryage/devtools “0.9.4”] in my dependencies? will this be automatically removed in release build?#2018-10-1123:49lilactownyes#2018-10-1123:52Bravithank you#2018-10-1212:09tobiasqHi, I'm having a problem when using advanced compilation using the posh library (with rum) that does reactive queries from datascript. Code works fine when using :simple optimisation but reactions do not happen with :advanced. Does anyone know a way of setting a clojurescript library to not be included in the advanced optimisation (like using externs for js?)#2018-10-1212:25gklijs@tobias291 I don’t think thats possible, ideally you find the problem and make a pr, could be something like https://github.com/oliyh/re-graph/issues/15 (oliyth mentions some differences in settings there which might fix your problem)#2018-10-1212:37gklijslook for field accessors might help, https://github.com/oliyh/re-graph/commit/adf6847dd71850f20ef5b241e2ed2c2ee76a315c#2018-10-1212:55tobiasq@gklijs thankyou - I can't find anything obvious, I think I'll create a simple test case to track down further - do you know if it's possible to get optimisation information from the compiler?#2018-10-1213:04gklijsI don’t really know, especially not for shadow-js, maybe you can have a source map with the advanced compilation and find out which function gives unexpected results?#2018-10-1213:54thheller@tobias291 it is not possible to exclude certain CLJS code from :advanced. which posh version do you use? the default one uses an invalid :require and doesn't compile at all#2018-10-1213:58tobiasq@thheller I'm using a branch I made with fixes here - https://github.com/tobiasquinn/posh/tree/master-rum - and a merge from pull request here - https://github.com/mpdairy/posh/pull/30 - I'm getting closer to the problem, something isn't being pushed through to the update analysis so I'm using console outputs to compare compiled and release builds and trace back#2018-10-1214:03thhellerit may just be missing the datascript externs? they are broken. I opened a PR quite some time ago https://github.com/tonsky/datascript/pull/216#2018-10-1214:18Bravican I just say what an awesome tool shadow-cljs is. I used it on 3 different cljs projects and it’s just pure awesomeness and I think there is no excuse for js devs not to switch to cljs forever#2018-10-1214:42aaron51Want to use Shadow with Expo (instead of Figwheel+Expo). Not looking to replace Metro bundler, would like to run that separately. Any examples or experiences of people doing this? (I know about thheller's clojureverse post, but that replaces Metro, which is more than I want to do)#2018-10-1214:46tobiasq@thheller thankyou so much! That fixed it, I used the method in the PR comments of including the datascript externs.js in my compiler options#2018-10-1214:47thheller@aaron51 you can use :npm-module with expo. it works ok-ish. https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2018-10-1214:53aaron51Thank you, we will give this a try!#2018-10-1214:48thhellerbut I have virtually no experience with react-native and didn't get very far last time#2018-10-1214:48thhellerI failed getting source maps to work which kinda sucked#2018-10-1217:54wilkerluciohello, I'm trying to connect to a node-js repl with Shadow, I can run npx shadow-cljs node-repl and it starts fine, but that REPL runs on the terminal only, I want to connect and send commands from my editor, but when I connect to the nREPL I only get the Clojure one, how can I transition that to run from my editor targeting the node repl?#2018-10-1217:57thhellersame as always. over nrepl just call (shadow.cljs.devtools.api/repl :node-repl) so switch the nrepl session over#2018-10-1217:57wilkerluciook, I think I just figured, running (shadow/node-repl) did the trick#2018-10-1217:57thhellerif the node-repl is already running that is#2018-10-1217:57thhellerotherwise yeah just node-repl#2018-10-1217:58wilkerluciothat is simpler I think, I just start the server, connect nREPL and run that 🙂#2018-10-1217:58wilkerluciothanks#2018-10-1218:00thhellerproblem is output though#2018-10-1218:00thhellerprints only go to whereever the repl process was started#2018-10-1218:02wilkerlucioI think that's fine, but taking the opportunity we are talking about REPL, in the Clojure REPL's when we send a form from the editor that form runs in the same NS as the file from where you ran it, but in CLJS it always use the current ns on the REPL, do you know why is the difference? and if we could have cljs to do the same as clj?#2018-10-1218:05thhellerthats a cursive thing and the way it does it for CLJ is not possible for CLJS no#2018-10-1218:06thhellerit would be trivial do add however if we just changed the nREPL middleware a bit#2018-10-1218:06thhellerbut pretty doubtful that gonna happen anytime soon#2018-10-1218:16wilkerluciogotcha, thanks for clarifying#2018-10-1218:17thhellerFWIW this is what cursive sends if you eval a form#2018-10-1218:17thheller
"(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)"
#2018-10-1218:17thhellerall the \n are there so that the error message matches the line of the actual file#2018-10-1218:18thhellerbut it doesn't do that when you are in a CLJS REPL#2018-10-1218:21wilkerluciointeresting, I had no idea about that#2018-10-1218:22thheller
{:file "(in-ns 'shadow.cljs.devtools.api)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n(def ^:dynamic *nrepl-cljs* nil)", :file-name "api.clj", :file-path "C:/Users/thheller/code/shadow-cljs/src/main/shadow/cljs/devtools/api.clj", :id "a2b09333-3223-4d43-9cb6-54236e79dbb8", :op "load-file"}
#2018-10-1218:23thhellerits already kinda cheating since it uses load-file without an actual file (thats the full nrepl message that gets sent)#2018-10-1218:23thhellerso yeah I kinda blame Cursive 😉#2018-10-1218:23thhellerbut having worked with nrepl myself I can totally understand why its done that way#2018-10-1218:25thhellerfor cljs its just {:code "(prn :foo)", :id "549215c5-9e36-4eb9-9e8e-f17288de92bf", :ns "demo.browser", :op "eval"}#2018-10-1218:27thhellerhang on
#2018-10-1218:29thhellerdoesn't it already use the file ns for eval? at least it seems so for me?#2018-10-1218:30thhellerhmm I think it may actually just be a bug?#2018-10-1218:31thhellercursive does send the correct :ns but its just ignored#2018-10-1218:31thhelleryeah totally a bug#2018-10-1218:34wilkerlucionice, so we gonna get it to run in file ns? 🙂#2018-10-1218:35thhelleryeah should be doable. need to verify how emacs handles this though#2018-10-1218:36thhellerhttps://github.com/thheller/shadow-cljs/issues/393#2018-10-1218:36thhellergot completely distracted by the fact that a different nrepl message is sent for CLJ#2018-10-1218:36thhellerdidnt even see the :ns for the CLJS message 😛#2018-10-1218:40wilkerlucioglad you just revisited it 😛#2018-10-1218:48thhelleralways ask questions if something doesn't work as you'd expect it to 🙂#2018-10-1219:01markxHi can someone show me how to connect to shadow repl with vim and fireplace?#2018-10-1219:01haywood@markx when you boot shadow from the terminal, it'll start an nrepl server for you#2018-10-1219:02haywoodit prints the port the repl is on (configurable if you wanted). I'd just look up how to connect to a remote repl in fireplace#2018-10-1219:02haywoodit'll take localhost and whatever port was spit out#2018-10-1219:02markxI know that port, but I just don’t know how to use fireplace to connect#2018-10-1219:03markxbecause…I don’t need piggieback?#2018-10-1219:04haywooduh, checking my deps, I am using a piggieback alias that's used when I boot shadow#2018-10-1219:05haywoodit's for cider though#2018-10-1219:05haywoodI highly recommend spacemacs 😂#2018-10-1219:06markxThanks, but not the answer I’m looking for 😂#2018-10-1219:06haywoodyea sorry I'm looking at the fireplace docs and not seeing anything about connecting to an nrepl, maybe my assumption about it was incorrect#2018-10-1219:08markxIt says to connect to cljs repl, I need to use piggieback. But then shadow doesn’t use piggieback, so I don’t know what to do now.#2018-10-1219:09haywoodare you using deps?#2018-10-1219:23markxNo, I’m using shadow-cljs#2018-10-1219:36lilactownshadow-cljs I think provides a piggieback compatibility namespace#2018-10-1219:38lilactownI haven't used vim-fireplace before, but however you would connect to a piggieback connection should work?#2018-10-1219:45lilactownI wish I understood how to use vim and it's package management so I could explore more hehe#2018-10-1219:48mj_langfordTPope's Pathogen and related writings is a good resource Will.#2018-10-1219:48mj_langfordhttps://www.vim.org/scripts/script.php?script_id=2332#2018-10-1219:50lilactownsweet! thanks!#2018-10-1223:09markxHey guys#2018-10-1223:09markx> If the popular cider-nrepl is found on the classpath it will be added automatically. No additional configuration required.#2018-10-1223:10markxHow can I find out whether cider-nrepl is found and run?#2018-10-1223:35lilactownif you’re starting shadow-cljs from the terminal, you’ll need to add it to your dependencies#2018-10-1300:01markx@lilactown 😱#2018-10-1300:02markxSo in what condition will it be added automatically, as in the description?#2018-10-1300:03lilactownthe description is saying that it will add it to the middleware that the nREPL server uses#2018-10-1300:03lilactownotherwise you would have to add additional configuration to tell shadow-cljs to use the cider-nrepl middleware when it starts the nREPL server#2018-10-1300:05markxOh nice. It works now! Thanks!#2018-10-1300:05lilactownthere are other cases, such as starting shadow-cljs from within CIDER itself, that it will automatically inject the cider-nrepl dependency#2018-10-1300:05lilactownmagic upon magic 🙂#2018-10-1300:05markxThose are already confusing enough…#2018-10-1300:05markxI’ll stay stupid for now 😛#2018-10-1300:07markxI tried to read the figwheel.main docs. It keeps talking about “figwheel repl” “cljs repl” “nrepl” “clojure repl” and more. So confusing!#2018-10-1300:07lilactownyeah, it is very confusing#2018-10-1300:08markxNow I have cider-nrepl and shadow work now. Anything else you would recommend for me to use?#2018-10-1300:09lilactownnope, I would start with that#2018-10-1300:09lilactownthere’s plenty to learn there#2018-10-1300:09markxbut still, how do I know if cider is running?#2018-10-1300:09lilactownare you using Emacs?#2018-10-1300:10markxno. I’m using vim#2018-10-1300:10markxand vscode#2018-10-1300:10lilactownah. I’m not sure then 😕#2018-10-1300:11markxdoes it say anything in the repl?#2018-10-1300:11lilactownlooks like it has some instructions here: https://github.com/ctford/vim-fireplace-easy#2018-10-1300:13lilactownhm okay. I’m reading about how to use it with figwheel#2018-10-1300:15lilactownwhat does your REPL say right now?#2018-10-1315:31markx@lilactown It says some warnings, but other than that, the eval and autocompletion are working, so I guess it’s working.#2018-10-1408:14mitchelkuijpersI am trying to use shadow-cljs for a Jira Addon, but when I load shadow in watch mode, there is apparantly alread a goog.string defined and some other stuff which clashes and make the whole dev mode of shadow fail. Anyone here know a trick to prevent that?#2018-10-1408:15mitchelkuijpersI am getting all kind of errors like this 😞#2018-10-1408:44thheller@mitchelkuijpers hmm thats odd. is there already a goog version loaded on the page?#2018-10-1408:44thhellerjust check goog in the console without loading the .js generated by shadow-cljs?#2018-10-1408:57mitchelkuijpers@thheller Yes there is already something there#2018-10-1409:55thhellerhmm yeah thats a problem. there can only be one development build loaded at a time#2018-10-1409:56thhellerare there two different CLJS dev builds on the page?#2018-10-1409:59thheller@mitchelkuijpers you can probably "fix" the warning by adding :prepend "goog.isProvided_ = function(name) { return false; }; to your base module#2018-10-1411:14mitchelkuijpersDamn this is annoying it seems my code get's overwritten again.. 😞#2018-10-1411:15mitchelkuijpersJira uses it for i18n and soy templates#2018-10-1411:16mitchelkuijpersIs it possible to make google closure use another base instead of goog?#2018-10-1411:29mitchelkuijpersDamn even during production they still have a goog ns.. So my only change for getting this to work would be to use another prefix I would think.#2018-10-1411:36mitchelkuijpersLol I currently fixed it by doing: goog = {};#2018-10-1411:39mitchelkuijpersI did not get the :prepend option working for some reason during dev is it possible to set it with the :devtools option?#2018-10-1411:49mitchelkuijpersBut this of course makes fulcro-inspect stop working but I can live with that for now#2018-10-1414:08thhellerJira uses unoptimized closure code?#2018-10-1409:59thhellerbut it may break a bunch of stuff in other places if you just overwrite the already loaded code#2018-10-1410:00kurt-o-sysI'm trying to use https://github.com/gregthebusker/react-confirm-bootstrap#readme in one of my shadow-cljs projects. So far, I've been able to add other components, but I seem to fail this one: The example in js:
var Confirm = require('react-confirm-bootstrap');

    var ConfirmAction = React.createClass({
        onConfirm() {
            // Preform your action.
        },

        render() {
            return (
                <Confirm
                    onConfirm={this.onConfirm}
                    body="Are you sure you want to delete this?"
                    confirmText="Confirm Delete"
                    title="Deleting Stuff">
                    <button>Delete Stuff</button>
                </Confirm>
            )
        },
    });
I'd expect something in cljs like this:
(ns ....
  (:require ["react-confirm-bootstrap" :default Confirm]))

      [:> Confirm {:body      "question"
                 :title     "whatever"
                 :onConfirm #(println "confirmed")}
       [:span "push me"]]
There are no errors or warnings, but when clicking 'push me', nothing happens...
#2018-10-1410:00kurt-o-sysNot sure if it's reagent or shadow-cljs related, actually 😛#2018-10-1410:00thheller@kurt-o-sys probably ["react-confirm-bootstrap" :as Confirm] not :default#2018-10-1410:01kurt-o-syswhen I use :as: Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.#2018-10-1410:02thhellerhmm ok#2018-10-1410:02kurt-o-sysnot sure about that library... may be something weird in there.#2018-10-1410:02mitchelkuijpers@thheller I think I am first going to check if I can turn the other one in release mode#2018-10-1410:04thheller@kurt-o-sys maybe it just doesn't support a span?#2018-10-1410:05kurt-o-sys🙂
[:> Confirm {:onConfirm #(println "test")
                   :title "title"
                   :body "body"}
       [:button "test"]]
still nothing happens 😛
#2018-10-1410:05thhellerit looks like it is cloning the children and adding props#2018-10-1410:05thhellerthat won't work with reagent#2018-10-1410:05kurt-o-sysoh, ok... so, no way to solve that one?#2018-10-1410:05thheller(r/as-element [:button "test"]) maybe#2018-10-1410:05kurt-o-sysok, will try 🙂#2018-10-1410:06thhelleror you can just leave out the button altogether and specify :buttonText#2018-10-1410:06kurt-o-sysoh, right. may work fine - although I wanted just an icon there, but well...#2018-10-1410:07thhelleras-element should work#2018-10-1410:07thhellernot sure how reagent typically deals with this though#2018-10-1410:07thhellerhttps://github.com/gregthebusker/react-confirm-bootstrap/blob/master/src/Confirm.js#L72-L90#2018-10-1410:10kurt-o-syslol, you know what, it seems it does work, but I can't see the dialog that pops up... It's hidden behind the other stuff for some reason.#2018-10-1410:10thhellerhmm actually this should probably work in reagent#2018-10-1410:10thhellerah yeah maybe just z-index 😛#2018-10-1410:11kurt-o-systrying, but nope. Not sure where it's gone.#2018-10-1410:16kurt-o-sysok... so it's the opacity that was set to 0, and fade didn't seem to work fine.#2018-10-1414:07thheller@mitchelkuijpers its not just goog. any other namespace will have the same issues (eg. cljs.core). but no there is no way to adjust that#2018-10-1414:23grounded_sage@thheller I’m giving a bit of hammock time to my static site generator and was just wondering where I can follow your thoughts and updates on building a “Gatsby like” system and the plugin system you mentioned some time ago that you will be adding for stuff like Sass. Would like to ensure what I end up building is in the right direction. #2018-10-1414:28thheller@grounded_sage I can't give you any details since I don't have them myself yet#2018-10-1414:28thhellerthe plugin system is actually already implemented so there is nothing left to do there#2018-10-1414:28thhellerbut the gatsby like stuff will not be part of shadow-cljs itself#2018-10-1414:29thhellerit would just be using it like any other tool#2018-10-1414:29thhellerfor this to work you basically need a full framework like gatsby etc#2018-10-1414:29thhellerso I'd probably build on top of fulcro myself#2018-10-1417:29pauldI'm playing with fulcro shadow-cljs template (nodemo) and I'm working through the fulcro book. I've been able to adapt the template to follow along with the book, but I'm getting the following compiler error when trying to build the :cards build:#2018-10-1417:29pauldThe required namespace "cljsjs.marked" is not available, it was required by "devcards/util/markdown.cljs".#2018-10-1417:31pauldI did an npm install marked but still get the same error.#2018-10-1417:59pauldHmmm, I wonder if I have an old version of devcards running since I can't see any dependency on cljsjs.marked in the devcards project.clj on github.#2018-10-1418:13pauldOk I see that devcards "0.2.6" does have this dependency and the shodow-cljs documentation says that the solution is to npm install marked but the error still occurs.#2018-10-1418:22pauldHmmm, I can't seem to npm install marked --save in such a way that will get devcard build to compile.#2018-10-1418:24pauldI guess it needs a shim.#2018-10-1418:37pauldOk, made a shim for marked, but now I'm getting this errror: The required namespace "create-react-class" is not available, it was required by "devcards/core.cljs". but I thought the required shim for react already existed in shadow.#2018-10-1418:37pauldI guess I'll make a shim for this too...#2018-10-1418:40pauldHmmm, puzzling - I see create-react-class in shadow-cljsjs project.#2018-10-1418:42pauldoops probably forgot to install it.#2018-10-1418:46pauldOk, that was it - sorry for the noise.#2018-10-1500:13vigilancetechokay, now I started a shadow repl from the terminal on the demo project (minimal-shadow-cljs-browser) and it seems to be working. Now I want to switch over to cider, but when I :cljs/quit out of it and go to cider-jack-in it says the server's already running and doesn't give me a repl buffer in emacs. I even tried reloading the page and restarting the shadow server. How am I supposed to quit out so I can come in from cider without having to reboot my whole machine?
error in process sentinel: Could not start nREPL server: shadow-cljs - config: /home/kevin/tmp/minimal-shadow-cljs-browser/shadow-cljs.edn  cli version: 2.6.6  node: v8.11.1
shadow-cljs - connected to server
server already running
#2018-10-1500:14vigilancetechI can reconnect to it from the terminal with shadow-cljs cljs-repl app#2018-10-1500:22vigilancetechalso, section 4.3.1 of the user guide says:
If the popular cider-nrepl is found on the classpath it will be added automatically. No additional configuration required.
but the cider's man page says:
Much of CIDER's functionality depends on the presence of CIDER's own nREPL middleware. Starting with version 0.11, When cider-jack-in (C-c C-x (C-)j (C-)j) is used, CIDER takes care of injecting it and its other dependencies.
so, should I remove the cider-nrepl from my system to have it work with shadow or is that the nrepl shadow is looking for?
#2018-10-1502:39aaron51When running shadow-cljs tests with karma (3.0.0), how do I run only a single deftest (and rerun when files change)?#2018-10-1502:50aaron51Workaround - replace all (deftest with #_(deftest and comment in the tests you want to focus on. Please let me know if there’s a better way.#2018-10-1503:17richiardiandreaThere is no better way at the moment, I think. Other tools analyze the meta on the deftest (for instance ^:focus) but it is not a clojure.test feature#2018-10-1503:18richiardiandreaIf you are at the REPL you can use clojure.test/test-var and friends though#2018-10-1507:14thhellerthis is not possible with karma currently no. but you can always just fire up a REPL and run a singular test.#2018-10-1507:14thhellergiven how karma works it probably won't be a very efficient way to test a single var as all the code still has to be loaded regardless#2018-10-1503:57grounded_sage@thheller all good. Are the plugin docs in the guide? With respect to the Gatsby stuff. I agree it has to be a full framework. I’m investing in Rum due to SSR and open state management. Was more interested in the common implementation details that could be shared if any. #2018-10-1506:56thheller@vigilancetech if cider starts the shadow-cljs server it will add the middleware. it you start it separately you have to add it. I recommend adding it yourself since you then don't hve to worry about if cider adds it or not. adding it twice is not a problem.#2018-10-1506:57thhellerI don't understand what you mean by quitting the REPL and cider-jack-in. those are two completely different things#2018-10-1506:57thhellerthere can also be many connections to a shadow-cljs REPL so you don't have to quit one for the other to take over#2018-10-1506:58thhellerI do recommend running shadow-cljs server separately#2018-10-1506:58thhellerand then using cider-connect as describe here https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2018-10-1515:46neupshHello, how do i use npm packaged css in clojurescript app? I have installed bulma and 'bulma-react-components` npm packages and am using bulma components in my app by requiring it as ["react-bulma-components" :as bulma], an i can see the component part working. Now, how do i import the css in my app?#2018-10-1515:46neupshDo i have to include a <link rel="stylesheet" href="..." /> or is there a better way to load npm-packaged css module in clojurescript through shadow-cljs ?#2018-10-1515:51thheller@neupsh shadow-cljs does not process any CSS yet so you have to get it into your page by other means. I typically use the node-sass cli or just copy the css manually into my public/css directory#2018-10-1515:58neupsh@thheller thank you, i will try to use sass to import it and give it a try#2018-10-1518:01sbHello, shadow-cljs is compatible with sente?#2018-10-1518:02thhellerprobably? never tested it#2018-10-1518:02sbMeans, I would like to use with http-kit and sente and at front-end#2018-10-1518:02thhellerwell the CLJS side you can do with shadow-cljs yes#2018-10-1518:02thhellerthe server part I would recommend something more tailored for CLJ development, ie. lein#2018-10-1518:04sbI use lein works fine with http-kit and compojure (shadow-cljs). I just want to use ws to transfer data between parts. Thanks! I check it.#2018-10-1521:48kennyI am using Highcharts with shadow-cljs and am trying to get the no-data-to-display plugin to work. The docs say to add modules/no-data-to-display.js to your imports. I did this by adding ["highcharts/modules/no-data-to-display"] to my :require but that doesn't appear to work. I'm curious if there is any sort of initialization that I need to do to get the plugin to work. Any thoughts?#2018-10-1521:51kennyIf I change the require to ["highcharts/modules/no-data-to-display" :as foo] and run (js/console.log foo) it logs a function, not a map like most npm modules do.#2018-10-1521:53thhellerare you maybe suppsed to call that function?#2018-10-1521:54kennyI tried with no args and I got an error. Took a guess and called it like this (foo highcharts) where highcharts is ["highcharts/js/highcharts" :as highcharts] and it worked. Very weird. In their examples all they do is add <script src=""></script> to their index.html.#2018-10-1521:54thhellerwell yeah thats because thats just the browser banging on a global variable#2018-10-1521:55thhellertheir bundle just then calls that function on load basically#2018-10-1521:56kennySeems like an odd way to do it.#2018-10-1521:57kennyI suppose that isn't an abnormal conclusion when working with JS libs though...#2018-10-1521:58thhellerindeed 😛#2018-10-1521:59thheller@wilkerlucio just published 2.6.11 which should now properly use the REPL ns even for CLJS#2018-10-1600:55wilkerlucionice! once I get home I’ll try it out#2018-10-1600:57vigilancetechI did npm -g up shadow-cljs from root but it still says: server version 2.6.6. Any idea what I did wrong?#2018-10-1601:19wilkerlucio@vigilancetech are you using the lein integration? if you are check the version on the project.clj#2018-10-1601:21vigilancetechno, just shadow straight#2018-10-1601:21wilkerlucioupdate the local version as well, install without -g#2018-10-1601:22vigilancetechah, that did it! Thanks!#2018-10-1601:25wilkerlucioglad it worked#2018-10-1602:16wilkerlucio@thheller after I bumped I'm getting a ton of these:#2018-10-1602:16wilkerlucio
[:failed-to-compare "^2.2.5" "2.2.6" #error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]}]
 :trace
 [[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 20]
  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 11]
  [shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18306 invoke "npm_deps.clj" 27]
  [clojure.lang.Delay deref "Delay.java" 42]
  [clojure.core$deref invokeStatic "core.clj" 2312]
  [clojure.core$deref invoke "core.clj" 2298]
  [shadow.cljs.devtools.server.npm_deps$fn__18305$fn__18308 invoke "npm_deps.clj" 33]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 163]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 157]
  [shadow.cljs.devtools.server.npm_deps$main$fn__18389 invoke "npm_deps.clj" 179]
  [clojure.core$complement$fn__5391 invoke "core.clj" 1433]
  [clojure.core$filter$fn__5614 invoke "core.clj" 2813]
  [clojure.lang.LazySeq sval "LazySeq.java" 40]
  [clojure.lang.LazySeq seq "LazySeq.java" 49]
  [clojure.lang.RT seq "RT.java" 528]
  [clojure.core$seq__5124 invokeStatic "core.clj" 137]
  [clojure.core$seq__5124 invoke "core.clj" 137]
  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 181]
  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 172]
  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 162]
  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 153]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
#2018-10-1602:17wilkerluciothe compilation still works, but that's making the console unusable#2018-10-1607:39thheller@wilkerlucio hmm odd. should be fixed in 2.6.12#2018-10-1607:45HukkaI've been reading https://github.com/thheller/shadow-cljs/issues/238 but cannot figure out a way to require the go macro from cljs.core.async#2018-10-1607:47HukkaI get
File: jar:file:/home/hukka/.m2/repository/thheller/shadow-cljs/2.4.21/shadow-cljs-2.4.21.jar!/shadow/cljs/devtools/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------
no matter what kind of requires I use in my code
#2018-10-1607:47thheller@tomi.hukkalainen_slac you have an old incompatible core.async version in your classpath#2018-10-1607:48HukkaHum, ok. No wonder I'm hitting walls#2018-10-1607:49thhellermake sure its 0.4.474#2018-10-1607:49Hukkacljs-http requires 0.3.442 😞 Let's see if it works with overrides#2018-10-1607:53HukkaHuh. The maintainer has made a release on the same day, before he updated the deps#2018-10-1607:55thhelleryeah that dep should really be bumped#2018-10-1609:38HukkaI hadn't realized that <!! is not available on cljs, so I couldn't do the quick hack I needed anyway 😞 But thanks again for the lightning fast help. I wouldn't have guessed the problem from that error and my googling wasn't good enough#2018-10-1609:40thhelleryes blocking IO is not possible in CLJS (or rather the underlying JS)#2018-10-1611:35wilkerlucio@thheller fix confirmed, thanks!#2018-10-1612:32gravIf I 1. start MY_ENV=foo shadow-cljs server, 2. connect via nrepl and compile a node-script build, 3. start the script with MY_ENV=bar node out/my-script.js, 4. connect a node-repl, then (.-MY_ENV js/process.env) has the value foo. How come? I’d expect bar.#2018-10-1612:35thhellerare you connecting to node-repl or the REPL for your build?#2018-10-1612:36thhellernode-repl is its own node process started by shadow-cljs#2018-10-1613:10romdoqI have an :npm-module project that's being yarn installed from a git repo by a website, and so runs shadow-cljs release npm in the package.json postinstall hook. Unfortunately the module uses Reagent, which needs (but doesn't explicitly depend on) other packages, so shadow-cljs apparently doesn't have some namespaces (for example, create-react-class) available at this point. The dependencies are installed by yarn, but in the main website's node_modules, which I guess isn't accessible to each individual package's postinstall command. Are there any good/recommended ways of making such packages available when the project is installed as a dependency?#2018-10-1613:10romdoqI'm currently looking at ways to just distribute the transpiled javascript instead, but I might just be missing something, so advice is welcome.#2018-10-1613:58p-himikHi. Is there a way to get the access to the data from shadow-cljs.edn in my cljs files?#2018-10-1615:40thheller@mel.collins never use shadow-cljs in a postinstall hook, thats just way too slow. instead you do the release and just publish the compiled files instead#2018-10-1615:41thheller@p-himik only in the form of :closure-defines. what else would you want access to?#2018-10-1615:42p-himik@thheller E.g. TinyMCE has an option to explicitly provide it with the paths to themes and skins that it downloads when it's used for the first time.#2018-10-1615:42p-himikSo, I think :asset-path is required in this case.#2018-10-1615:44thhellernot sure what you'd want to do with that? it only contains the files generated by the compiler#2018-10-1615:46p-himikMaybe my logic is a bit convoluted, yeah. Right now, I use a build hook to copy all relevant files from node_modules to :asset-path, and then use the copied files either as arguments to TinyMCE or somewhere in index.html (e.g. CSS files).#2018-10-1615:46thheller(meaning that the themes and skins won't be on that directory)#2018-10-1615:47thhellerah so they are there#2018-10-1615:48thhellerso :asset-path is available as js/CLOSURE_BASE_PATH#2018-10-1615:48thhellerbut its a development only thing so do not use that#2018-10-1615:48thhellerits probably best to goog-define it#2018-10-1615:49thhellerOR just discover it dynamically by looking for the script tag in the DOM and taking its src attribute#2018-10-1615:49p-himikWow that's convoluted.#2018-10-1615:50p-himikWould it make sense to add an access to shadow-cljs.edn via some marco that just inlines all requested values?#2018-10-1615:52thhellerhmm no I don't think so#2018-10-1615:53thhellerbut I still don't understand what exactly it is you are trying to do#2018-10-1615:53thhelleryou already copied the files yourself. assume for a second that you copied them somewhere NOT in :asset-path#2018-10-1615:53thhellerhow would you pass it then?#2018-10-1616:00p-himikI would have to write this other path in: 1. Some cljs files that use them (currently an issue with :asset-path as well) 2. In index.html (not an issue with :asset-path since the server can just read the EDN and inline all values in the HTML template) 3. In nginx.conf (not an issue since this file is being generated from different files, including the EDN) Of course, for (1) I could use the same thing as in (2) or (3), but it would become much more convoluted than it is now, and also it would probably lose some integration with IDE since I would have to use some kind of templating. Another solution would be to read the EDN with some Lein plugin (I also use project.clj). I think something like that can be achieved since there's already lein-environ plugin that does something similar.#2018-10-1616:10thhellerso I do have plans for adding support for some static asset paths#2018-10-1616:11thhellersay in webpack you can require("./some-path/some.png") and it'll return the path to that file#2018-10-1616:11thhellerit sounds like that is what you need#2018-10-1616:12thhellerso (def some-tiny-mce-asset (assets/path-for "tiny-mce/theme/foo.css"))?#2018-10-1616:12thhelleror is it just a bunch of files with a specific naming convention where the entire folder needs to be copied?#2018-10-1616:13thhellerthe compiler would only copy the path you actually asked for but could maybe support wildcards#2018-10-1616:14thhellerthe problem with having a macro access the config is cache invalidation since the code must be recompiled if the values change#2018-10-1616:14thhellerand that already is complicated enough. I don't want to add to it#2018-10-1616:21p-himikIt's both. CSS are used in just the way you described, with require. That is, in JS. In CLJS, I just include the relevant CSS files in index.html and copy them from node_modules/something to :asset-path. And some things, like TinyMCE require a user to supply a bunch of files with a specific naming convention. So in this case, I just copy the whole folder from node_modules/tinymce to :asset-path and then pass the configured path (mapped in nginx.conf) to tinymce.init. > the problem with having a macro access the config is cache invalidation since the code must be recompiled if the values change Ahhh, that's right. I remember having this issue with lein-environ. Thanks for making me aware of that. Would the option with goog-define that you've suggested solve it? If so, could you please describe it a bit more? I have no clue on how one would link it with shadow-cljs.edn.#2018-10-1616:27thhelleryou don't "link" it. you create (ns your.config) (goog-define asset-path "/foo") and in the config :closure-defines {your.config/asset-path "/bar"}#2018-10-1616:28thhellera helper function might help too (defn path-for [asset] (str asset-path asset))#2018-10-1616:29thhellerso you use (config/path-for "/some.css") in your code#2018-10-1616:39p-himikAh, so I will have to repeat the value of :asset-path - in :asset-path itself and in :closure-defines?#2018-10-1616:40thhellertechnically :asset-path itself has no meaning in release builds#2018-10-1616:41thhellersince you decide what the asset path is when you include the <script src="/something/foo.js">#2018-10-1616:42thhellerdevelopment builds just need to know the path since they dynamically load more code later (eg. hot-reload)#2018-10-1616:42thhellerbut yeah you would add it twice#2018-10-1616:51p-himikI see. Thanks!#2018-10-1620:14kanwei@thheller upgraded to 2.6.12 and randomly got an exception and now seems stuck/hanging: https://gist.github.com/kanwei/fee660eb1cdeb22934402cd5ee8ef2ed#2018-10-1620:16thhellergiven that it is in a boot function I have no idea whats happening#2018-10-1623:30tony.kayThe HUD seems to regularly malfunction on me when I’m working with errors like this:
#error {:message 
"Invalid symbol: cloj … lang.ExceptionInfo:."
, :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:151
(anonymous)	@	browser.cljs:343
#2018-10-1623:39tony.kayI’ve been seeing this for some time. sometimes HUD works, but often it just spins and I have to look in the console to understand the error#2018-10-1623:50tony.kaySeems like the serialization n line 104 of impl.clj is sending an exception over the websocket, and cljs reader can’t decode it because it is a clojure type#2018-10-1623:51tony.kaynot sure why it works sometimes, and sometimes not#2018-10-1700:01tony.kayI think maybe when I convert a clj -> cljs file? I think I did that shortly before this started happening…I noticed the real error was missing a : on require#2018-10-1700:02tony.kayi.e. (ns ... (require ...#2018-10-1700:02tony.kaybut I cannot reproduce it that way once restarted#2018-10-1700:20richiardiandreaAlso noticed sometimes the watch does not report the error, it prints "Error:" that's it#2018-10-1700:21richiardiandreaSince version .12 will try to repro#2018-10-1707:46thheller@tony.kay which version are you on? I removed the :e from the :build-failure message precisely because of those errors#2018-10-1708:30thhellerbtw can you please try (pr-str (ex-info "foo" {:bar 1})) in your project? I don't understand why :e would not print as #error .... It seems like something is messing with the default printing setup?#2018-10-1712:48tony.kay2.6.8 is the version that did that particular case#2018-10-1712:48tony.kayI’ll upgrade and watch for future problems#2018-10-1712:49thhellerIIRC @wilkerlucio reported a similar issue a while back (bad exception printing) but I could never reproduce it#2018-10-1712:49tony.kayit is strange, which is why I’ve held off…it dies in ways I can never repro either#2018-10-1712:50thhelleris this with just shadow-cljs running standalone or is there some server stuff as well?#2018-10-1712:50thhellerie embedded in lein/deps?#2018-10-1712:50wilkerlucioyeah, I still have it, at the nubank project I always have to get errors on the console#2018-10-1712:51wilkerlucioin my case just shadow, no server things#2018-10-1712:51wilkerlucioI just got one, let me paste here too#2018-10-1712:51wilkerlucio
env.cljs:167 failed to parse websocket message {:type :build-failure, :report "------ ERROR -------------------------------------------------------------------\n File: /Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs:55:43\n--------------------------------------------------------------------------------\n  52 |           (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})\n  53 |           (ui/text-field-raw {:maxLength \"8\"\n  54 |                               :value     postcode-lookup\n  55 |                               :onChange  })\n-------------------------------------------------^------------------------------\nnubank/shuffle/modules/logistic/components.cljs [line 55, col 43] The map literal starting with :maxLength on line 53 column 30 contains 5 form(s). Map literals must contain an even number of forms.\n\n--------------------------------------------------------------------------------\n  56 |           (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})\n  57 |           (ui/button {:onClick #(let [postcode (-> this fp/props :address/postcode)]\n  58 |                                   (if (= 8 (count postcode))\n  59 |                                     (db.h/load this (fp/get-ident this) AddressForm {:params {:abrams.api/extra-attrs {:address.brazil/postcode postcode}}}))\n--------------------------------------------------------------------------------\n", :e clojure.lang.ExceptionInfo: failed to compile resource: [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"] {:ex-kind :reader-error, :source-excerpt {:start-idx 51, :before ["          (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})" "          (ui/text-field-raw {:maxLength \"8\"" "                              :value     postcode-lookup"], :line "                              :onChange  })", :after ["          (ui/text-field {::ui/target this ::ui/attr :address/postcode :classes [:$margin-right-12]})" "          (ui/button {:onClick #(let [postcode (-> this fp/props :address/postcode)]" "                                  (if (= 8 (count postcode))" "                                    (db.h/load this (fp/get-ident this) AddressForm {:params {:abrams.api/extra-attrs {:address.brazil/postcode postcode}}}))"]}, :file #object[java.io.File 0x396f9cf3 "/Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs"], :resource-id [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"], :ex-type :reader-exception, :column 43, :line 55, :url #object[java.net.URL 0x37a875ae "file:/Users/wilker.lucio/Development/nubank/shuffle/src-common/nubank/shuffle/modules/logistic/components.cljs"], :source-id [:shadow.build.classpath/resource "nubank/shuffle/modules/logistic/components.cljs"], :tag :shadow.build.compiler/compile-cljs}, :build-id :workspaces} #error {:message "Invalid symbol: cloj … lang.ExceptionInfo:.", :data {:type :reader-exception, :ex-kind :reader-error}}
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:167
(anonymous) @ browser.cljs:344
`
#2018-10-1712:52thhelleryeah same thing :e clojure.lang.ExceptionInfo: failed to compile resource:#2018-10-1712:52wilkerluciothis I think is the important bit, seems like what Tony described:
#error {:message 
"Invalid symbol: cloj … lang.ExceptionInfo:."
Invalid symbol: clojure.lang.ExceptionInfo:.
, :data {:type :reader-exception, :ex-kind :reader-error}}
#2018-10-1712:52wilkerlucioyeah, exactly#2018-10-1712:52thhellercan you quickly run a shadow-cljs clj-repl to that process?#2018-10-1712:52thhellerand see if (pr-str (ex-info "foo" {:bar 1})) prints as #error ...?#2018-10-1712:53wilkerluciook, checking it out#2018-10-1712:53thhellerbtw if you upgrade that issue should be gone#2018-10-1712:53thheller:e is no longer part of that message#2018-10-1712:53wilkerlucio
[1:0]~shadow.user=> (pr-str (ex-info "foo" {:bar 1}))
"#error {\n :cause \"foo\"\n :data {:bar 1}\n :via\n [{:type clojure.lang.ExceptionInfo\n   :message \"foo\"\n   :data {:bar 1}\n   :at [clojure.core$ex_info invokeStatic \"core.clj\" 4739]}]\n :trace\n [[clojure.core$ex_info invokeStatic \"core.clj\" 4739]\n  [clojure.core$ex_info invoke \"core.clj\" 4739]\n  [shadow.user$eval33297 invokeStatic \"form-init8724609811994379936.clj\" 1]\n  [shadow.user$eval33297 invoke \"form-init8724609811994379936.clj\" 1]\n  [clojure.lang.Compiler eval \"Compiler.java\" 7062]\n  [clojure.lang.Compiler eval \"Compiler.java\" 7025]\n  [clojure.core$eval invokeStatic \"core.clj\" 3206]\n  [clojure.core$eval invoke \"core.clj\" 3202]\n  [shadow.cljs.devtools.server.socket_repl$repl$fn__17857 invoke \"socket_repl.clj\" 97]\n  [clojure.main$repl$read_eval_print__8572$fn__8575 invoke \"main.clj\" 243]\n  [clojure.main$repl$read_eval_print__8572 invoke \"main.clj\" 243]\n  [clojure.main$repl$fn__8581 invoke \"main.clj\" 261]\n  [clojure.main$repl invokeStatic \"main.clj\" 261]\n  [clojure.main$repl doInvoke \"main.clj\" 177]\n  [clojure.lang.RestFn invoke \"RestFn.java\" 805]\n  [shadow.cljs.devtools.server.socket_repl$repl invokeStatic \"socket_repl.clj\" 64]\n  [shadow.cljs.devtools.server.socket_repl$repl invoke \"socket_repl.clj\" 28]\n  [shadow.cljs.devtools.server$from_cli$fn__19792 invoke \"server.clj\" 606]\n  [shadow.cljs.devtools.server$from_cli invokeStatic \"server.clj\" 605]\n  [shadow.cljs.devtools.server$from_cli invoke \"server.clj\" 517]\n  [clojure.lang.AFn applyToHelper \"AFn.java\" 160]\n  [clojure.lang.AFn applyTo \"AFn.java\" 144]\n  [clojure.lang.Var applyTo \"Var.java\" 702]\n  [clojure.core$apply invokeStatic \"core.clj\" 657]\n  [clojure.core$apply invoke \"core.clj\" 652]\n  [shadow.cljs.devtools.cli$lazy_invoke invokeStatic \"cli.clj\" 22]\n  [shadow.cljs.devtools.cli$lazy_invoke doInvoke \"cli.clj\" 19]\n  [clojure.lang.RestFn invoke \"RestFn.java\" 460]\n  [shadow.cljs.devtools.cli$blocking_action invokeStatic \"cli.clj\" 148]\n  [shadow.cljs.devtools.cli$blocking_action invoke \"cli.clj\" 135]\n  [shadow.cljs.devtools.cli$main invokeStatic \"cli.clj\" 196]\n  [shadow.cljs.devtools.cli$main doInvoke \"cli.clj\" 151]\n  [clojure.lang.RestFn applyTo \"RestFn.java\" 137]\n  [clojure.core$apply invokeStatic \"core.clj\" 661]\n  [clojure.core$apply invoke \"core.clj\" 652]\n  [shadow.cljs.devtools.cli$_main invokeStatic \"cli.clj\" 238]\n  [shadow.cljs.devtools.cli$_main doInvoke \"cli.clj\" 236]\n  [clojure.lang.RestFn invoke \"RestFn.java\" 421]\n  [clojure.lang.Var invoke \"Var.java\" 385]\n  [user$eval543 invokeStatic \"form-init8724609811994379936.clj\" 1]\n  [user$eval543 invoke \"form-init8724609811994379936.clj\" 1]\n  [clojure.lang.Compiler eval \"Compiler.java\" 7062]\n  [clojure.lang.Compiler eval \"Compiler.java\" 7052]\n  [clojure.lang.Compiler load \"Compiler.java\" 7514]\n  [clojure.lang.Compiler loadFile \"Compiler.java\" 7452]\n  [clojure.main$load_script invokeStatic \"main.clj\" 278]\n  [clojure.main$init_opt invokeStatic \"main.clj\" 280]\n  [clojure.main$init_opt invoke \"main.clj\" 280]\n  [clojure.main$initialize invokeStatic \"main.clj\" 311]\n  [clojure.main$null_opt invokeStatic \"main.clj\" 345]\n  [clojure.main$null_opt invoke \"main.clj\" 342]\n  [clojure.main$main invokeStatic \"main.clj\" 424]\n  [clojure.main$main doInvoke \"main.clj\" 387]\n  [clojure.lang.RestFn applyTo \"RestFn.java\" 137]\n  [clojure.lang.Var applyTo \"Var.java\" 702]\n  [clojure.main main \"main.java\" 37]]}"
#2018-10-1712:54thhellerhmm looks like it should#2018-10-1712:54thhellerno idea why it doesn't when printing for the websocket msg#2018-10-1712:55wilkerluciodo you use transit for the encoding? because I learned that you can have generic handlers to have "default handlers" to encode things that transit doesn't understand, that could fix some encoding issues#2018-10-1712:55thhellerno its EDN#2018-10-1712:55thhellerjust pr-str in this case#2018-10-1712:55wilkerlucioI was in the latest version already 🤔#2018-10-1712:56wilkerluciomaybe that could change, transit encoding is also faster than pr-str#2018-10-1712:56thhellerhmm that can't be?#2018-10-1712:56wilkerluciowhat can't be?#2018-10-1712:56thhellerI removed the :e from the :build-failure message#2018-10-1712:56thhellerthere should be no way it ends up in the websocket message?#2018-10-1712:57wilkerlucioah, sorry, again I forgot to update the lein -.-#2018-10-1712:57wilkerluciolet me do that#2018-10-1712:57thhellerI could change it to transit but I've been trying to keep dependencies to a minimum given that the code is injected into the build#2018-10-1712:58wilkerlucioyeah, makes sense, but the gain can be noticable, when I was testing speed of things for the Fulcro Inspect encoding to send Fulcro data, transit sometimes gets up to 2~3x faster than pr-str on my tests#2018-10-1712:59thhelleryeah I know. EDN is quite slow#2018-10-1713:00wilkerluciohey, I just got this:#2018-10-1713:00wilkerlucio
[:workspaces] Build failure:

#2018-10-1713:00wilkerlucioit fail and gets stuck#2018-10-1713:00wilkerlucioI had the same yesterday, both on the latest version#2018-10-1713:01thhellerhmm nothing else?#2018-10-1713:01wilkerluciono, it gets stuck after that, no more printing#2018-10-1713:01thhellerhehe doh .. that code is still accessing :e of course ...#2018-10-1713:02thhellertry compiling from the UI#2018-10-1713:02thhellerthat should display the real error properly#2018-10-1713:03wilkerlucioits not every time#2018-10-1713:03wilkerluciobut now I got the correct HUD on my compilation 😄#2018-10-1713:03wilkerluciofor the error#2018-10-1713:03wilkerluciook, HUD is working fine now in the latest#2018-10-1713:04wilkerluciostarted working on HUD, stopped on console 😛#2018-10-1713:05thhelleryeah just fixed the console#2018-10-1713:08wilkerlucionice, so happy to see the HUD error back again, thank you! 😄#2018-10-1716:18haywoodI have a shadow build that outputs to target: npm-module which I import into react storybook (which has it's own server and index.html runner). I'm trying to get the browser repl working for this build, is there a javascript file I need to import into the foreign index.html?#2018-10-1716:19haywoodI'm not sure it's even possible#2018-10-1716:20thheller@haywood its not gonna be very reliable you you need to load the shadow.cljs.devtools.client.browser namespace#2018-10-1716:20thhellermay need to set :runtime :browser in your config so it gets compiled#2018-10-1716:21thhellerrequire("./path-to/shadow.cljs.devtools.client.browser")#2018-10-1716:22haywoodroger, will try thanks!#2018-10-1716:27haywoodnice, I just had to import it into my project's core.cljs file#2018-10-1716:27haywoodand all works#2018-10-1716:27haywood🙂#2018-10-1716:28thhellerproblem with that is that release will also include it then#2018-10-1716:28haywoodit's just a development tool anyway#2018-10-1716:28thhellerah thats ok then#2018-10-1721:20wilkerlucio@thheller I'm having problems doing release builds with shadow 2.6.12:#2018-10-1721:21thhellerlooks like an old closure compiler version?#2018-10-1721:21wilkerluciohumm, could be#2018-10-1721:21thhellershould be [com.google.javascript/closure-compiler-unshaded "v20180910"]
#2018-10-1721:21wilkerluciois there a easy place for me to find which are the current ones used by shadow?#2018-10-1721:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/project.clj#L40#2018-10-1721:22wilkerluciook, answering my own question https://github.com/thheller/shadow-cljs/blob/master/project.clj#L34-L40#2018-10-1721:22thheller😛#2018-10-1721:22thhellerif you list shadow-cljs as your first dependency you should always be getting the correct versions#2018-10-1721:23thheller(assuming you use project.clj)#2018-10-1721:24thhellerwhat are you doing that you get the old version in the first place?#2018-10-1721:24wilkerlucioI'm in a bizarre situation that I have to support both shadow-cljs and lein cljsbuild (the later just to run old tests on phatomjs that I'm unable to proper compile/run with shadow, not shadow fault, previous setup was not very nice)#2018-10-1721:25wilkerluciojust bumped both, but I still getting that error#2018-10-1721:25wilkerluciotrying to clean .shadow-cljs and trying again#2018-10-1721:26thhellerjust check lein deps :tree#2018-10-1721:26thhellerthat issue won't be affected by whats in .shadow-cljs#2018-10-1721:28thhellerlein-cljsbuild may actually be messing with you deps an inject older versions#2018-10-1721:29wilkerlucioI tried the deps :tree, the versions seem correct there#2018-10-1721:29wilkerlucioand I'm trying to do the shadow release#2018-10-1721:31wilkerluciooh, when I bumped the cljs and closure I also had shadow downgraded and forgot to upgrade back facepalm trying again#2018-10-1722:01markxWhen I make some changes to a function, do I have to save the file to make the changes effective? Eval the new function to repl doesn’t seem to do the job, so I’m wondering if this is expected or there’s something wrong with my setup#2018-10-1722:05thhellerdepends on what you mean by "make the changes effective"#2018-10-1822:39markxI was hoping for something like, when I change the return value in get-x from 1 to 2 and eval get-x into repl, the console will start to log 2 instead of 1.
(defn get-x [] 1)
(defn loop []
   (js/console.log (get-x)
  (loop))
#2018-10-1822:42markx@thheller ^#2018-10-1908:17thhellerdepends on how you do the loop? can't do it like that because that will forever block the main thread so nothng else ever happens#2018-10-1920:18markxSo it will work if I don’t block the thread?
(defn loop []
   (js/console.log (get-x)
  (js/setTimtout loop 0))
#2018-10-1921:07thhelleryes#2018-10-1722:06thhellerif you just eval the function you just get a new function. nothing else happens.#2018-10-1722:06thhellerthats unlike live-reload where there is an entire lifecycle of stuff that also happens#2018-10-1722:06thhellerie. calling the after-load hook to re-render in case you are using reagent or so#2018-10-1722:07thhellerthat hook isn't called if you just eval a function?#2018-10-1819:13thhellerI just pushed 2.6.14 which has a few performance optimizations. Nothing super major but can save a couple secs on larger builds#2018-10-1823:43richiardiandreaoddly with 2.6.14 I get an exception printed out but everything seems fine:
RejectedExecutionException: Task 
#2018-10-1904:01grounded_sageI’m thinking hard about the caching provided by shadow and how to avoid wrecking it with my ideal stack. Just curious whether FactUI breaks caching due to being based on Clara. https://github.com/arachne-framework/factui#2018-10-1908:21thheller@grounded_sage yeah clara-rules is not very cache friendly. IIRC the problematic part of fact-ui is the f/rulebase call#2018-10-1908:21thhellerso the ns that calls that has to be tagged with ^:dev/always#2018-10-1908:31thheller@richiardiandrea the threadpool was Terminated? did you ctrl+c or something? normally a watch never terminates the threadpool? not even when the watch is stopped since its shared on the entire system (only stop! does that)#2018-10-1912:46urbanslugHey, does shadow-cljs have issues with cond->#2018-10-1912:46urbanslugor re-frame maybe?#2018-10-1912:46thhellerno?#2018-10-1912:49urbanslugSorry, it's a re-frame thing https://github.com/Day8/re-frame-debux/issues/22#2018-10-1915:00wilkerlucio@thheller just gotta say, the repl fix that uses the current code NS is awesome! much better experience, and with your tips to remove warnings and the latest shadow my compilation times got down from 15s (for file with lots of dependants) to 3s!! awesome!!#2018-10-1915:40thhellerfor future reference: if anyone is seeing regular watch recompile times of 10sec+ please let me know. there is probably something to be improved just waiting to be found! do not assume that 10s+ is normal#2018-10-1916:22thhellerheck even 5sec is probably too much 😛#2018-10-1916:46urbanslughmm there's a new REPL?#2018-10-1916:47thhellerno, just fixed a bug#2018-10-1916:47urbanslugSo umm how to get this new repl? Update? I use emacs and connect to nrepl#2018-10-1916:47urbanslug:s/update/update shadow version#2018-10-1916:48thhellerthe change was for Cursive only I think. not sure emacs actually sends the :ns when evaling from a file#2018-10-1916:48thhellerthe behaviour in Cursive is that it uses the namespace of a file when you send a form from a file to the REPL#2018-10-1916:49thhellereg. if you send ::foo from that will be :#2018-10-1916:49thhellereven if the REPL is currently in cljs.user#2018-10-1916:50thhellermy emacs setup is completely busted so I have no idea if emacs actually sends :ns or not#2018-10-1919:46richiardiandreaHad this problem agian in CI:
[2018-10-19 19:41:40.023 - INFO] :shadow.build.classpath/jar-cache-read-ex - {:file #object[java.io.File 0x1f0f5174 ".shadow-cljs/jar-manifest/1539977882000-core.rrb-vector-0.0.12.jar.manifest"]}
RuntimeException java.io.EOFException
	com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read (ReaderFactory.java:114)
	cognitect.transit/read (transit.clj:319)
	cognitect.transit/read (transit.clj:315)
	shadow.build.cache/read-cache (cache.clj:49)
	shadow.build.cache/read-cache (cache.clj:33)
	shadow.build.classpath/find-jar-resources/fn--11757 (classpath.clj:565)
…	cognitect.transit/read (transit.clj:319)
#2018-10-1920:02thhellersounds like maybe a job got killed while writing cache output?#2018-10-1920:02thhellerits no biggy as the cache will just be re-built#2018-10-1920:02thhellerits just a warning not a critical error#2018-10-1920:24lilactownI'm using 2.6.10 and getting very intermittent errors when doing a release build in CI:
aborted par-compile, [:shadow.build.classpath/resource "clojure/string.cljs"] still waiting for #{cljs.core}
{:aborted [:shadow.build.classpath/resource "clojure/string.cljs"], :pending #{cljs.core}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "clojure/string.cljs"] still waiting for #{cljs.core}
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.compiler/par-compile-one (compiler.clj:760)
	shadow.build.compiler/par-compile-one (compiler.clj:729)
	shadow.build.compiler/par-compile-cljs-sources/fn--12969/iter--12970--12974/fn--12975/fn--12976/fn--12977 (compiler.clj:822)
	clojure.core/apply (core.clj:657)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/with-bindings* (core.clj:1965)
	clojure.core/apply (core.clj:661)
	clojure.core/bound-fn*/fn--5471 (core.clj:1995)
	java.util.concurrent.FutureTask.run (FutureTask.java:266)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
	java.lang.Thread.run (Thread.java:748)
#2018-10-1920:24lilactownmight this be fixed by some of the changes to parallel compilation that I see since 2.6.10? It's hard for me to test since it only happens intermittently#2018-10-1920:58TeMPOraLhi all#2018-10-1920:58TeMPOraLa question about minification/advanced optimizations#2018-10-1920:59TeMPOraLI've tried manually specifying :optimizations :advanced, :infer-externs :auto and :shadow-keywords true, and still, a release build looks like this:#2018-10-1921:00TeMPOraL(not sure if the image uploaded correctly, as slackbot is saying something about no storage left)#2018-10-1921:01TeMPOraLbasically: #1, a curious unminified polyfill always shows up, and #2 plenty of full names visible in code#2018-10-1921:02TeMPOraLif I include reagent and re-frame, I get ~300k of release bundle; I tried adding a button and textfield component from material-ui, and the bundle size shoots up to 600k +#2018-10-1921:02TeMPOraL(it gets up to 1MB if I include all of material-ui-core)#2018-10-1921:02TeMPOraLis this normal behaviour, or am I missing some extra minification setting?#2018-10-1921:04lilactownmaterial-ui is incredibly heavy, yeah#2018-10-1921:04TeMPOraLI thought so, but then I stumbled upon some issues about material-ui bundle size, and people apparently expect a release bundle to be ~100-300k max#2018-10-1921:05lilactownare you using a minified version of react & material-ui?#2018-10-1921:05lilactownthey might be talking gzipped#2018-10-1921:05thheller@temporal.pl run this to get a details breakdown of all the stuff in your build https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2018-10-1921:06thhellerand yes material-ui is huge if you import all of it#2018-10-1921:06thhelleryou typically want to limit it to only import what you are actually using#2018-10-1921:09TeMPOraL@thheller thanks#2018-10-1921:09TeMPOraLhttp://paste.temporal.pl/shadow-cljs-build-report.html#2018-10-1921:09TeMPOraLthis is the report I get; do sizes there look normal?#2018-10-1921:09thhellerthats not the report 😉#2018-10-1921:09thhellerthe html file is more detailed#2018-10-1921:09TeMPOraLI'm new to shadow-cljs, and cljs in general, so I have no point of reference#2018-10-1921:09TeMPOraLuh, ok 😄#2018-10-1921:09lilactownthose sizes look pretty normal#2018-10-1921:12thheller@temporal.pl use things like (:require ["@material-ui/core/Button" ...]) to only include parts of the package#2018-10-1921:16TeMPOraLyes, this case uses only
["@material-ui/core/Button" :default muiButton]
["@material-ui/core/TextField" :default muiTextField]
for test
#2018-10-1921:16TeMPOraLif I include it all, it's + 400k to total size#2018-10-1921:18TeMPOraLstill; it's a fresh project, and I'm not married to any UI library yet, so if I could ask you for recommendation?#2018-10-1921:18TeMPOraLfriends over the JS land discouraged me from using react-bootstrap#2018-10-1921:21thhellerdunno really .. they all get pretty large pretty quickly#2018-10-1921:27lilactownI just bumped to 2.6.14 and I'm getting this error in CI#2018-10-1921:28TeMPOraLok, thanks for help and good night!#2018-10-1921:29thheller@lilactown thats a bad closure compiler version#2018-10-1921:29lilactownaackclkasdlfds#2018-10-1921:29lilactownI do this everytime I update shadow-cljs. I'm sorry#2018-10-1921:30thhellerthats what you get for not using shadow-cljs to manage your deps 😉#2018-10-1921:31thhellernot a fan that closure keeps changes their public interfaces. they don't seem to care much about backwards compatibility 😞#2018-10-1921:32thhellerwell to be fair that interface wasn't public and I had to cheat to get access to it 😛#2018-10-1921:37lilactownheh, when I try and run the release command locally i get an OOM error#2018-10-1921:38lilactownone release build works fine, but concurrent ones: npx shadow-cljs release server client dev-client#2018-10-1921:39lilactownhm, fixed by killing my watch's#2018-10-1921:40lilactownah I bet I was using the old version shadow-cljs I had running as a server#2018-10-1922:01lilactownOK, the previous error occurred again after upgrading#2018-10-1922:03thhellerhmm don't scare me like that ... I actually changed how parallel compile works. don't tell me I actually broke it?#2018-10-1922:03thhellerare you absolutely 100% sure that the correct code is loaded#2018-10-1922:03thhellerno bad AOT cache or anything?#2018-10-1922:05lilactownI've been seeing this error intermittently since 2.6.10#2018-10-1922:06lilactownit could be cache related#2018-10-1922:06lilactownin the past, re-running the build has resolved it, but it was popping up relatively often#2018-10-1922:07thhellerthats definitely not normal and should never actually happen. its just a safeguard so the process doesn't wait forever#2018-10-1922:07lilactownI'm re-running it right now so we'll see if it happens twice 😛#2018-10-1922:07thhellerrun with :verbose true in the config please#2018-10-1922:07thhellerotherwise its gonna be impossible to reconstruct what happens#2018-10-1922:07thheller(or with --verbose on the CLI)#2018-10-1922:09lilactownI'll add that once this job finishes#2018-10-1922:09thhellerhmm is the machine maybe just overloaded?#2018-10-1922:10thhellerif the other 2 builds proceed normally the third may just not be getting a chance to run before its timeout#2018-10-1922:10thhellerstill need to add that --parallel=false option#2018-10-1922:11thhelleryou should try creating a clojure fn that just does the builds sequentially#2018-10-1922:11lilactownI might do that#2018-10-1922:11lilactownok, this job succeeded#2018-10-1922:11thhellerthe way this works is that all builds more or less start at the same time and enqueue all the CLJS compiles onto a threadpool#2018-10-1922:12thhellerwhich then compiles them in order they were submitted#2018-10-1922:12thhellerso its entirely possible that the queue just gets too long#2018-10-1922:12lilactownhmm I see#2018-10-1922:13thhellerkinda unlikely but possible#2018-10-1922:13thhelleryou were running on a toaster before 😉#2018-10-1922:13lilactownI wonder if it might have to do with other jobs running on the same machine#2018-10-1922:13lilactownlol, well we upgraded the toaster#2018-10-1922:14lilactownwe now have a group of toasters in AWS ECS for our pipeline#2018-10-1922:14lilactownI'm wondering if a particular EC2 gets used for multiple concurrent builds if it's what causes the error#2018-10-1922:15lilactownit might be poisoning the cache, or just overloading it#2018-10-1922:15thhellerdefinitely try running with verbose AND running them after each other instead of parallel#2018-10-1922:15thhellercache is always isolated per build#2018-10-1922:15thhellerso they can't interfere with each other#2018-10-1922:33lilactownalright, I wrote a simple script to do the build:
(ns release
  (:require [shadow.cljs.devtools.server :as server]
            [shadow.cljs.devtools.api :as shadow]))

(defn -main [& args]
  (server/start!)
  (shadow/release :server {:verbose true})
  (shadow/release :client {:verbose true})
  (shadow/release :dev-client {:verbose true})
  (server/stop!)
  (System/exit 0))
I'll report back if I see those errors again
#2018-10-1922:35thhellerdon't really need a server instance for release#2018-10-1922:37lilactownah OK#2018-10-1922:38thhellershadow-cljs run release/all also works a bit better probably#2018-10-1922:39thheller(defn all [] ...) of course .. not -main#2018-10-1922:39thhelleror wrap the calls in (shadow/with-runtime ...) yourself#2018-10-1922:40thheller
(defn -main [& args]
  (shadow/with-runtime
    (shadow/release :server {:verbose true})
    (shadow/release :client {:verbose true})
    (shadow/release :dev-client {:verbose true})))
#2018-10-1922:41lilactownwhat does with-runtime do?#2018-10-1922:41thhellershare some components between the builds#2018-10-1922:42thhellerotherwise they all go off and re-index the classpath 3 times and stuff#2018-10-1922:42thhellerif you use shadow-cljs run thats done automatically#2018-10-1922:43thheller
(defn all [& args]
  (shadow/release :server {:verbose true})
  (shadow/release :client {:verbose true})
  (shadow/release :dev-client {:verbose true}))
#2018-10-2011:04grav@thheller RE: environment of the node repl, I was using api/node-repl which started its own process. Using api/nrepl-select works as expected.#2018-10-2122:14royalaid@thheller I have been playing around with html5 audio and video and noticed something odd in my app. When I try to seek in chrome it just resets my elements but when I seek in chrome it works as intended#2018-10-2122:15royalaidApparently this seems to be caused by a lack of the backing http server providing Http 206 Responses#2018-10-2122:15royalaidWould it be hard to support this with Shadows built-in server? #2018-10-2122:17royalaidSome context, see this SO post: https://stackoverflow.com/a/36101965/1868456#2018-10-2122:18thhellerhmm the server just uses the default ring-file middleware to serve files#2018-10-2122:18thhellerso if there is one that supports 206 that should be easy to add#2018-10-2122:19royalaidI think it is more to do with undertow#2018-10-2122:19royalaidnot sure though#2018-10-2122:19thhellerundertow supports it#2018-10-2122:19royalaidyeah I just have no idea how to make the correct configuration 😄#2018-10-2122:19royalaidlittle out of my depth#2018-10-2122:19thhellerlike I said .. its the ring middleware. nothing to do with undertow#2018-10-2122:20royalaidAhhh okay#2018-10-2122:20royalaidmakes more sense#2018-10-2122:21thhellercould probably use the default undertow handler for serving files#2018-10-2122:21thhellerwhich likely supports this out of the box#2018-10-2122:22thhellerring is a bit limited in some areas#2018-10-2122:24royalaidSo some basic googling, maybe it is super easy to add? https://github.com/remvee/ring-partial-content + https://github.com/thheller/shadow-cljs/blob/88d533b36b2d020dcf167ed11451955c3991a445/src/main/shadow/cljs/devtools/server/dev_http.clj#2018-10-2122:24royalaid?#2018-10-2122:28thhellerhmm no that doesn't look compatible#2018-10-2122:28thheller:body (subs body start (inc end))#2018-10-2122:28thhellerbody will be a java.io.File instance IIRC#2018-10-2122:28thhellerso that will fail#2018-10-2122:31thhelleropen an issue please. I'm off to bed. gn8#2018-10-2122:40royalaidWill do#2018-10-2206:37vigilancetechNow I'm trying to take the shadow-cljs electron example code (https://github.com/shadow-cljs/examples/tree/master/electron) and connect to the main and renderer processes with emacs cider-connect-cljs (renderer first) then with cider-connect-sibling-cljs (main). When I do the renderer everything looks okay (other than a middleware mismatch error cuz I'm using the latest snapshot) but when I do the sibling it appears to give me the same repl and it has a bunch of errors:
...
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; ‘cider-repl-display-help-banner’ to nil.
;; ======================================================================
shadow.user>
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings. To quit, type: :cljs/quit
[:selected :renderer]
WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:55)
WARNING: Use of undeclared Var shadow/watch (<stdin> at 1:55)
WARNING: No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow" (<stdin> at 1:76)
WARNING: Use of undeclared Var shadow/nrepl-select (<stdin> at 1:76)
cljs.user> 
there's a 2nd repl buffer that is created with similar, but not quite exactly the same, results:
...
;;
;; You can remove this message with the <M-x cider-repl-clear-help-banner> command.
;; You can disable it from appearing on start by setting
;; ‘cider-repl-display-help-banner’ to nil.
;; ======================================================================
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.4.0 (package: 20180826.2149) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.
shadow.user> TypeError: shadow.watch is not a function
    at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:4:8)
    at eval (eval at <anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8), <anonymous>:7:3)
    at file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:8
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:139:108)
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:827:46)
    at shadow$cljs$devtools$client$browser$handle_message (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:907:44)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.env.js:258:102)
    at WebSocket.<anonymous> (file:///home/kevin/0work/examples/electron/app/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:1002:40)
shadow.user> 
The 2nd repl's buffer status says it's only pending. The renderer repl doesn't initially have those (non-middleware) errors until after the sibling is created. From the terminal(s) the repls work perfectly. The renderer can do things like (js/alert "foo") and it works. The main issues an error when trying to do that (as it should because its only the launcher). Help!?!?
#2018-10-2207:43thheller@vigilancetech sounds like emacs is not capable of managing two connections?#2018-10-2207:44kwladyka@thheller hi, why EPL-1.0 vs MIT or EPL-2.0? I am trying to learn about licences 🙂#2018-10-2207:44thhellerno clue#2018-10-2207:44kwladykahaha thanks to be honest 🙂#2018-10-2207:45thhellerEPL is the default license set when you create a new project with lein new#2018-10-2207:45thhellerand clojure is using it so that sounded ok to me#2018-10-2207:48kwladyka“disclose source” - do you know what does it mean in practice? It force to public sorce when modify “program” / use “program”? Public source of EPL licensed “program” or whole app using this “program” as a dependency.#2018-10-2207:49thhelleras far as I understand the source must be "open" when you modify it#2018-10-2207:51kwladykabut the question is: for example if somebody will write wrapper on shadadow-cljs will be forced to public source or not? It is dependency, not modification of the code itself.#2018-10-2207:52kwladykaunderstanding licenses is harder than coding 😉#2018-10-2207:53thhellerhehe yeah ... to be honest I just looked at the summary on github and that looked ok#2018-10-2207:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/LICENSE#2018-10-2207:54thhellerbasically anyone can do anything they want as long as they publish the source. and I can't be sued for bugs 😛#2018-10-2207:56kwladykajust thinking if there is any risk for developers if they use source code with EPL license they will have to public app / part of they app#2018-10-2207:56kwladykaAnd for myself if I have to add some extra informations to my app about ALL deps license…#2018-10-2207:57kwladykamaybe i break the law everyday and I don’t know 🙂#2018-10-2207:58kwladykabecause the question is if using “program” as dependencies force me to license conditions. Or as long as it is deps only it doesn’t matter.#2018-10-2207:59kwladykaSorry, I know it is not the topic for this channel. Just blowing my mind and nobody really understand and can answer 🙂#2018-10-2208:06thhelleryeah its tough. I also have no clue how to do include licenses from libs properly#2018-10-2208:18thhellerfrom my perspective you can do whatever you like with shadow-cljs BUT if you make a commercial profit I expect you to contribute back any actual changes you make#2018-10-2208:18thhellerif you just use it as a lib without modifications that is fine#2018-10-2209:04kwladykayeah, but I am talking about license not shadow-cljs directly. It seems everybody don’t care about licenses, but I have some experience about law. I really expect the worst always. Bad things happening however you try be legal 🙂#2018-10-2209:04thhelleryeah its annoying#2018-10-2212:52emil0rshadow-cljs - starting ... [:app] Compiling ... The required namespace “infinitor.collector.core” is not available.#2018-10-2212:52emil0rAny idea why that happens? Got src/infinitor/collector/core.cljs#2018-10-2212:52emil0rwith a -main function#2018-10-2212:52thhellerand you have :source-paths ["src"]?#2018-10-2212:53vigilancetech@thheller have you ever looked into what it would take to have a system-wide shadow-cljs compile server rather than having to spin up a JVM for each project?#2018-10-2212:53emil0rAh… a bit too used to how lein sets it up I see 🙂#2018-10-2212:54thheller@vigilancetech yes I have but it would be too much work and probably not worth the effort#2018-10-2212:54emil0rWhy does shadow-cljs as default split the source paths up as src/dev, src/main and src/test?#2018-10-2212:54thhellerbecause its my recommended setup#2018-10-2212:54emil0rWhat’s the reasoning behind it?#2018-10-2212:55thhellerI like it and most projects use a setup like that?#2018-10-2212:55thhellerjust change it to ["src"] if you do not need or want it#2018-10-2212:56thhellerthe reasoning is that you'll often have sources that are only for tests or development#2018-10-2212:56thhellerand you want to split those from your main sources#2018-10-2212:56emil0rbetween main and test sure. Bit different from how lein sets it up, but I’m not fussed about it. Trying to fit src/dev into the mental model#2018-10-2212:56thhellerrather than having dev at the root I prefer to put it in src/dev#2018-10-2212:56emil0rok. fair enough#2018-10-2212:57thhellerlein puts src and test at the root#2018-10-2212:57thhellerand most people add dev later on#2018-10-2212:58emil0r:+1:#2018-10-2213:00thheller@vigilancetech the problem really is classpath isolation. each project has its own set of dependencies and those do not always match. can only load one version of a lib at a time#2018-10-2213:23vigilancetech@thheller could Stewart Sierra's components help with that?#2018-10-2214:30thheller@vigilancetech no#2018-10-2214:30thhellerjust trust me when I say that I tried various different approaches and all of them had too many drawbacks to be worth the trouble#2018-10-2215:13vigilancetechnot meaning to pester you about it, but it sounds like boot has something in it that may provide that sort of isolation if you ever want to check it out sometime. Having a bunch of people developing on one server isn't that common nowadays, however maybe there might be a use for it in CI#2018-10-2215:23thhellerplease ... I thought about this for a very long time ... there is nothing to be gained#2018-10-2215:23thhellerIF I want full classloader isolation then each "pod" (when using boot terminology) will load its own clojure version and dependencies#2018-10-2215:23thhellerwhich means you pay the full startup cost#2018-10-2215:24thhellerif you account for that having separate vms is actually faster and easier to manage#2018-10-2215:24thhellersure if you don't care about classloader isolation then you can optimize a few things#2018-10-2215:24thhellerbut I care very much about that since dealing with dependency conflicts is already complicated enough#2018-10-2215:25thhellerclojure just isn't built for multiple runtimes in the same VM#2018-10-2215:26thhellerthe upcoming launcher UI will make it easier to manage multiple shadow-cljs instances so you don't have to have a terminal open for each#2018-10-2215:27thhellerbut running multiple projects in the same JVM is a not something I'm going to pursue further#2018-10-2215:59royalaid@thheller just following up on previous discussion I have filled the issue for the 206 http codes here:https://github.com/thheller/shadow-cljs/issues/396.#2018-10-2216:06thhelleryeah I took a look this morning. unfortunately I can't easily use the undertow handler directly#2018-10-2216:07thhellermight just modify default ring middleware a bit#2018-10-2216:24vigilancetech@thheller well, I wasn't so much concerned about the start up time as the memory footprint of multiple servers. I happen to be running on a pretty small machine (which is why I'm looking at moving to bootstrap). Although my situation is unusual, I'd think that in a build farm it would also be a concern.#2018-10-2216:25thhellersame situation again. memory footprint would not change.#2018-10-2216:25thhellerif the default memory setting are problematic you can always tune them#2018-10-2216:26thhelleradd :jvm-opts ["-Xmx1G"] to you shadow-cljs.edn to limit the amount of memory to 1gb#2018-10-2216:26thhellercan go lower if you want#2018-10-2216:26thhellerdepending on your project really. closure needs the most memory when optimizing so I wouldn't go lower than 512M#2018-10-2216:26vigilancetechyeah, well, soon enough I'll probably have a bigger machine, but I've got this little ARM TV box I'd just love to see being able to be turned into a professional development system for up and coming, but otherwise impoverished programming apprentices#2018-10-2216:28vigilancetechIIRC, when I started multiple servers, each was taking about 700MB of resident memory#2018-10-2216:28thhelleryeah because the the default JVM memory settings are greedy#2018-10-2216:35vigilancetechWell, thanks for your help/info @thheller, and I really love what you've done with this tool. Back when I was on boot it was hell to try and get a reliable REPL going, much less connect to it with cider. Plus I think it was a bit of overkill for what I needed (that may change in the future, IDK). Can you think of a situation where shadow would be vulnerable to the problems boot's pod isolation solves? Like a resident dependency in the development machine that gets overlooked in the config file that doesn't exist in the target machine throwing an error?#2018-10-2216:36thhellerwell dependency issues are always possible depending on how complicated you make your setup#2018-10-2216:37thhellerbut no .. nothing but your config can add stuff to the classpath#2018-10-2216:38thhellerI never had this problem though so I'm not sure how you'd even get into that situation#2018-10-2216:40vigilancetechfortunately I haven't either, but the boot documentation seems to make it sound like a serious concern. Not sure if its enough of a threat to have to deal with the extra complexity of getting it all configured though. Certainly not for me, right now.#2018-10-2217:54emil0rWhat am I missing?
(require ["Buffer" :as Buffer])

(Buffer/alloc 1024)
#2018-10-2217:54emil0rgetting TypeError: shadow.js.shim.module$Buffer.alloc is not a function#2018-10-2217:58thhellerwell what is Buffer? try to print it (js/console.log Buffer)#2018-10-2217:59emil0rhmm… getting a nil#2018-10-2217:59emil0rnot what i expected#2018-10-2218:00thhellerwhats your build target?#2018-10-2218:00thhellerin node you can just cheat and use (js/Buffer.alloc ...)#2018-10-2218:01emil0rargh… sorry. the stdout is not connected to the REPL in emacs#2018-10-2218:01emil0rsec#2018-10-2218:02thhellerso it exports multiple objects#2018-10-2218:02thhellerthen you need (:require ["Buffer" :refer (Buffer)])#2018-10-2218:03emil0rnah. was just me logging to the console twice#2018-10-2218:03emil0rah, i see what you mean#2018-10-2218:04thhellerits still exporting multiple objects 😉#2018-10-2218:04emil0ryeah. (Buffer/Buffer.alloc 1024) works#2018-10-2218:06emil0rany good way of handling UUIDs in cljs? using the npm module uuid only gives me strings as opposed to an object reflecting the UUID#2018-10-2218:12thhellerno idea. they all seem to be using strings only#2018-10-2218:16emil0rwow… so bad#2018-10-2219:49emil0r@thheller thumbs up for shadow-cljs 🙂. very smooth once i got it up and running#2018-10-2222:08kanweiamen to that... went from boot to tools.deps and shadow works perfect now 🙂#2018-10-2222:40kanweithanks for all the amazing work @thheller#2018-10-2301:34richiardiandrea@emil0r We use https://github.com/lbradstreet/cljs-uuid-utils#2018-10-2311:23wilkerlucio@richiardiandrea @emil0r in cljs core we already have (random-uuid) and uuid?, what features are you guys getting from those external libraries?#2018-10-2314:38richiardiandreaAs far as I know uuid? checks the type not the content so we used the lib for validation#2018-10-2315:48wilkerlucioyeah, if you need to check strings that makes sense#2018-10-2311:45emil0rno particular reason. just converting some js code to cljs#2018-10-2311:45emil0ranyone got any recommendations for configuration libraries?#2018-10-2311:59emil0rhaving said that… i do use some js libraries which expect UUIDs as strings#2018-10-2315:01thheller@royalaid just release 2.6.15 which should now properly support range requests and 206#2018-10-2316:37royalaidJust following up to confirm it works! Thanks for all the hard work! 🙌#2018-10-2323:01thhelleranyone on 2.6.15 should upgrade to 2.6.16. live-reload is broken in 2.6.15.#2018-10-2401:35richiardiandreaI am noticing weird things too when reloading and I thought it was on my code base. I will try to repro after the update#2018-10-2404:33bbssis there a way to use node_modules that are npm linked? It seems shadow-cljs doesn't pick them up.#2018-10-2407:55emil0r@thheller getting this error
The required namespace "konserve.filestore" is not available, it was required by "infinitor/collector/database.cljs".
"konserve/filestore.clj" was found on the classpath. Should this be a .cljs file?
Looking in the repo for konserve they have one .clj file and one .cljs file. Is this a bug in shadow-cljs or should I look elsewhere?
#2018-10-2408:48thheller@emil0r looking at the repo isn't always the correct answer. looking at the .jar is. and that doesn't include the filestore.cljs. looks like that was created after the last release.#2018-10-2408:54emil0rindeed#2018-10-2408:55thheller@bbss how so? it should be working as long as node_modules/the-thing/... exists. the-thing is allowed to be a link. maybe need to upgrade if you get a complaint about not being allowed to use sources outside the project. that was fixed.#2018-10-2408:56bbssah, my local global version might be out of date. Cheers!#2018-10-2410:47bbssI'm seeing linear growth in compilation times:
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 1.62s)
------ WARNING #1 --------------------------------------------------------------
point_cloud_layer_fragment_glsl assigned a value more than once.
--------------------------------------------------------------------------------
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 2.72s)
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 3.80s)
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 6.44s)
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 12.04s)
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 23.20s)
[:main] Build completed. (1197 files, 3 compiled, 0 warnings, 57.57s)
;;after shadow-cljs restart
[:main] Build completed. (1197 files, 1040 compiled, 0 warnings, 112.28s)
#2018-10-2410:48bbsshowever after restart + rm -rf .shadow-cljs the recompilation is fast again#2018-10-2410:49thhellerwhich version are you on? there was a bug like that a while ago#2018-10-2410:49bbss2.6.2#2018-10-2410:49bbssUpdating before asking my next question 😅#2018-10-2410:49thhellerhmm no that definitely had the fix for that problem#2018-10-2410:50thhellerif you see this again please run with --verbose#2018-10-2410:50thhellerotherwise impossible to tell where the time is going#2018-10-2410:50bbssokay, will do#2018-10-2410:50thhellerif you have side-effecting macros I would check those first#2018-10-2410:51bbssNot that I'm aware of.#2018-10-2410:52thhellerthe cache issue where compiles got slower over time was fixed in 2.4.20 so must be something else#2018-10-2410:52thhellerthey also didn't get slower but that much so quickly 😉#2018-10-2414:03thheller> ... hangs a long time here....#2018-10-2414:04thhellerwhere? the point of the log is to first log when something starts and then again when something completes#2018-10-2414:04thhellerso there should be a <- msg with a high ms number?#2018-10-2414:05bbssthat's where it hangs. exactly there#2018-10-2414:06thhellerhmm thats odd .. there is no pending stuff unless you removed some lines?#2018-10-2414:06thhellerany -> without a matching <-?#2018-10-2414:07thheller> <- Closure JS Cache read: 4 JS files (2427 ms)
#2018-10-2414:07thhellerthis is suspiciously slow#2018-10-2414:07thhellerplease check how large .shadow-cljs/builds/main/dev/shadow-js/index.json.transit is?#2018-10-2414:08thhellerand .shadow-cljs/builds/main/dev/closure-js/index.json.transit#2018-10-2414:09bbss-rw-r--r-- 1 baruchberger staff 155600 Oct 24 22:35 .shadow-cljs/builds/main/dev/shadow-js/index.json.transit -rw-r--r-- 1 baruchberger staff 298854289 Oct 24 22:55 .shadow-cljs/builds/main/dev/closure-js/index.json.transit#2018-10-2414:09thhellerwhat the heck 😛#2018-10-2414:09thheller300mb?#2018-10-2414:09bbss😅#2018-10-2414:10bbssdoes transit somehow cache requests from my app?#2018-10-2414:10bbssNo clue why it would be that big#2018-10-2414:10thhellerno that is compiler cache data#2018-10-2414:10thhellerdo you import any .js files directly?#2018-10-2414:10bbssYes#2018-10-2414:11thhellerare they this large?#2018-10-2414:11bbssHmm, I don't think so.#2018-10-2414:11bbssThe files themselves are small, maybe their deps?#2018-10-2414:12thhellercheck the output directory .shadow-cljs/builds/main/dev/closure-js#2018-10-2414:12thhellerwhats the largest file?#2018-10-2414:12bbssthat one, by far#2018-10-2414:12thhelleryeah thats clear since it basically contains all the others#2018-10-2414:13bbss
-rw-r--r--  1 baruchberger  staff  298854289 Oct 24 22:55 index.json.transit
-rw-r--r--  1 baruchberger  staff       3958 Oct 24 19:43 module$gsv$api$partition.js
-rw-r--r--  1 baruchberger  staff      20392 Oct 24 22:53 module$gsv$ui$custom_point_cloud.js
-rw-r--r--  1 baruchberger  staff       5023 Oct 24 19:43 module$gsv$ui$point_cloud_layer_fragment_glsl.js
-rw-r--r--  1 baruchberger  staff       7160 Oct 24 19:43 module$gsv$ui$point_cloud_layer_vertex_glsl.js
#2018-10-2414:13thhellerso it looks like closure is doing crazy stuff to one of your inputs#2018-10-2414:13thhellerit should never get this large#2018-10-2414:14bbssthe only thing I can imagine somehow, this morning I tried to use shadow-cljs to build a npm package, on a different project, it npm packs the directory (100mb) in the process.#2018-10-2414:14bbssbut it's a different project entirely.#2018-10-2414:15thhellerit makes no sense for the file to be that big .. its just an index ...#2018-10-2414:15thhellercan you send it to me?#2018-10-2414:16thhellerzipped please 😛#2018-10-2414:16bbssSorry I just deleted it. When it happens again I will.#2018-10-2414:16bbssJudging by how it went previously that will take around 20 minutes..#2018-10-2414:17thhellergah make a copy next time please#2018-10-2414:17bbssSorry..#2018-10-2414:17thhellerimpossible to tell whats going on if you delete the evidence 😛#2018-10-2414:17bbss😅#2018-10-2414:21thhellerbtw the :module-move messages are gone in the latest version#2018-10-2414:21bbssI've pulled the latest into my shadow-cljs repo, but what was the command to install it locally again?#2018-10-2414:22thhellerwhy do you have a local repo?#2018-10-2414:22thhellerlein install#2018-10-2414:22bbssI have a local repl because earlier you pushed a fix for something and I wanted to have it quick.#2018-10-2414:24thhellerits all released now 😉#2018-10-2414:24thhellerif you run lein install you must run the build-all.sh first#2018-10-2414:25thhellerotherwise some files will be missing#2018-10-2414:25bbssOkay, will do after I reproduce.#2018-10-2414:27thhellerjust observe the cache index on each compile. it should be almost constant in size depending on the amount of JS files used#2018-10-2414:28thhellereven 1mb is probably too big already#2018-10-2414:33bbss
-rw-r--r--    1 baruchberger  staff   10699 Oct 24 23:21 start.index.json.transit
->
-rw-r--r--  1 baruchberger  staff  26659 Oct 24 23:27 index.json.transit
Enough of a growth increase? or is this expected?
#2018-10-2414:33thhellerno thats enough already#2018-10-2414:33thhellerunless you added many js files#2018-10-2414:33bbssDo you want me to send them?#2018-10-2414:33thhelleryes that would help lots#2018-10-2414:33bbssNo added none, just editted a bit.#2018-10-2414:34bbssWhere to send?#2018-10-2414:34thhelleredits should definitely not affect the size#2018-10-2414:34thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2018-10-2414:37bbsssent#2018-10-2414:40thhellerok found the problem I think#2018-10-2414:41bbssso quick 🙂#2018-10-2414:43thhellerits pretty obvious if you look at the data#2018-10-2414:43thhellerthe index is basically just a map that tracks whatever compiler settings were active and so on#2018-10-2414:44thhellerit tracks which polyfills closure injected#2018-10-2414:44thhellerthats supposed to be a set#2018-10-2414:44thheller
:injected-libs ("es6/util/inherits"
                 "es6/util/setprototypeof"
                 "util/objectcreate"
                 "es6/util/arrayfromiterable"
                 "es6/util/arrayfromiterator"
                 "es6/util/makeiterator"
                 "es6/symbol"
                 "es6/object/assign"
                 "util/polyfill"
                 "util/global"
                 "util/defineproperty"
#2018-10-2414:44thhellerbut it ends up as a list. so it basically doubles in size on each compile since it re-adds everything#2018-10-2414:45bbssthat's why it was so linear in time increase 🙂#2018-10-2414:48thhellernow only to figure out where it becomes a list ...#2018-10-2414:50bbssAlright, no rush from my side. I can live with a rm + restart once in a while.#2018-10-2414:50thhellerno need for restart. you can just delete the index file#2018-10-2414:50bbsseven better 👍#2018-10-2415:00thhellerwow doh ...#2018-10-2415:00thheller
injected-libs
        (-> (.get injected-libraries-field cc)
            (keys)
            (into #{})
#2018-10-2415:01thheller-> instead of ->> ...#2018-10-2415:02bbss1 char bug ㅋㅋㅋ#2018-10-2415:06thhellerTIL: (clojure.set/union #{} '(1 2 3)) => (1 2 3)#2018-10-2415:06thhellermeh#2018-10-2415:07bbssHmm, that is surprising indeed.#2018-10-2415:08thhellerset/union has so many weird behaviours ... should just use into ...#2018-10-2415:09TeMPOraL
dev> (clojure.set/union #{1 2 3} '(1 2 3))
#{1 3 2}
dev> (clojure.set/union #{1 2 3} '(1 2 3 4))
(2 3 1 1 2 3 4)
#2018-10-2415:09TeMPOraLsource explains it all:#2018-10-2415:09TeMPOraL
dev> (source clojure.set/union)
(defn union
  "Return a set that is the union of the input sets"
  {:added "1.0"}
  ([] #{})
  ([s1] s1)
  ([s1 s2]
     (if (< (count s1) (count s2))
       (reduce conj s2 s1)
       (reduce conj s1 s2)))
  ([s1 s2 & sets]
     (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))]
       (reduce into (first bubbled-sets) (rest bubbled-sets)))))
#2018-10-2415:12bbssHmm, I see the implementation is very elegant. But a few warnings on non-sets would be nice.#2018-10-2415:12thheller@bbss fixed in 2.6.17#2018-10-2415:12bbssThank you!#2018-10-2416:26jeromeI'm having trouble mapping react to preact-compat when targeting :npm-module to build the leaves (view components) of an existing JS preact app in CLJS. Would you all expect this to work for my shadow-cljs.edn?
{:source-paths ["src"]
 :dependencies [[cljs-css-modules "0.2.1"]
                [reagent "0.8.1"]]
 :builds {:npm {:target :npm-module
                :output-dir "build/cljs"
                :compiler-options {:infer-externs :auto}
                :js-options {:resolve {"react" {:target :npm
                                                :require "preact-compat"}
                                       "react-dom" {:target :npm
                                                    :require "preact-compat"}}}}}}
When I npx shadow-cljs compile npm I get
[:npm] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
The only way I've found to move forward is to create symlinks from node_modules/[react|react-dom] to node_modules/preact-compat
#2018-10-2416:49thheller@jeromedane :resolve is not supported for :npm-module or rather it is very limited#2018-10-2416:50thhellerit only works reliably for :browser really. for :npm-module you really need to configure it in whatever you are targetting#2018-10-2416:50jeromeWe might want to reflect that in the documentation for :resolve?#2018-10-2416:50thhellereg. webpack or node#2018-10-2416:50thhellerit is?#2018-10-2416:51thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-limitations#2018-10-2416:52jeromeAh, I see. Thanks. Suggested add > It is therefore not recommended to be used with targets that use require directly (eg. :node-script[, :npm-module]) for those of us that are a little thicker than most. Thank you!! ❤️#2018-10-2418:18shaunlebron@gklijs asked a question about loading .wasm files in cljs#2018-10-2418:36claudiuthink this is a job for a smart router. if you want this custom logic. got something like this built with fulcro#2018-10-2418:37hmaurer@U3LP7DWPR the loading indicator isn’t the important bit though; that’s easily doable with fulcro right now; what I meant is that with suspense you could trigger data-loading at the component level#2018-10-2418:37hmaurerI think?#2018-10-2418:19shaunlebroncreated an issue here with some context: https://github.com/thheller/shadow-cljs/issues/397#2018-10-2418:22gklijsThanks, I now have some wasm included in npm, will give shadow-cljs a try#2018-10-2418:20richiardiandreain the latest shadow, whever I do a require in the REPL I get:
another.ns> (require '[policy-fn.env :as env])
Circular dependency detected: policy-fn.env -> policy-fn.env
 (require '[policy-fn.env :as env])
#2018-10-2418:20richiardiandreaonly custom namespaces, no core namespace like clojure.string#2018-10-2418:21richiardiandreaactually, let me differentiate more#2018-10-2418:21richiardiandreait is a namespace that has been added to the path but at runtime, while the JVM was running#2018-10-2418:24richiardiandreaI restarted the JVM and now I receive a bunch of [:did-not-find ...]#2018-10-2418:24richiardiandreacompilation is successful#2018-10-2418:26richiardiandreafor this file the watcher does not pick up the changes#2018-10-2419:10mynomoto@thheller about the code you were fixing this morning why not set instead of (into #{})#2018-10-2419:10mynomotoWorks for -> and ->>#2018-10-2420:02thhellerIts just a habit to use into but yes set would have prevented this problem. Kinda still using into because it used to be faster ...#2018-10-2419:47lilactownwas there a change made to the way that module splitting works?#2018-10-2419:47lilactownwhen I do a release build, I see this message now:
Module Entry "cambia.web.experience.dashboard.components.survey-prompt.client" was moved out of module ":survey-prompt".
It was moved to ":main" and used by #{:onboarding :survey-prompt}.
and the bundle is not created
#2018-10-2419:48lilactownit looks like there are cross-references between the two modules#2018-10-2419:48lilactownbut this worked in a previous version#2018-10-2420:03thheller@lilactown yes I added that as a hard error because otherwise it goes by unnoticed#2018-10-2420:03thhelleryou specified that namespace as as :entries for one of your modules#2018-10-2420:03thhellerbut another module directly required it so it was never in that module#2018-10-2420:04thhellerso effectively making the :survey-prompt module useless#2018-10-2420:05lilactownGotcha#2018-10-2420:06lilactownIt looks like adding : survey-prompt to the dependencies of :onboarding fixed it#2018-10-2420:07thhellerif that makes sense for your module structure then that is the correct fix yes#2018-10-2420:07thhellerthat error message probably will get more details at some point#2018-10-2420:08thhellerbut the previous behavior with no errors was worse 🙂#2018-10-2420:08lilactownHeh. Well luckily for us it didn't change the behavior at all while it was wrong#2018-10-2420:10thhellerwell it changed your modules. the code was moved to :main previously as well#2018-10-2420:10thhellerso you thought you were splitting but actually everyone was always loading it#2018-10-2420:10thhellermaking :main larger that it would otherwise be#2018-10-2420:10thhellerprobably not by much if its just a few components but still#2018-10-2420:19lilactownYeah. It hadn't affected us yet because ATM we always load those modules#2018-10-2420:26gklijsUsing the shadow-cljs - browser quickstart should it be possible to just do an npm install to use an npm module. I tried, https://github.com/gklijs/shadow-gol-3d (last commit, rest is copy) but it keeps saying
The required JS dependency "game-of-life-3d" is not available, it was required by "gol/main.cljs".

Searched in:/Users/gerardklijs/Workspace/shadow-gol-3d/node_modules

You probably need to run:
  npm install game-of-life-3d
but when I look in node_modules it's there
#2018-10-2420:31thheller@gklijs there is no support for .wasm yet so that module won't load#2018-10-2420:35gklijsok, that too bad#2018-10-2420:35thhellerbut you found a bad incorrect error message for packages that don't have a main but only module#2018-10-2420:36thhellerthat could be fixed but then it would fail when trying to load the .wasm file#2018-10-2420:36thhellerso not much better#2018-10-2420:39gklijsno.. It's not really well supported yet. Even with webpack I could not get a production build. I could take the compiled javascript and serve it with webpack probably, but then I lose easy reloading.#2018-10-2420:43thhellerI presume the .js file is Rust output?#2018-10-2420:43thhellerthats really where the problem is#2018-10-2420:44thhellerbut thanks for the example. I can use that to test some stuff#2018-10-2420:45gklijsyes, almost the default wasm-pack output, only added some utils methods at the end#2018-10-2420:46thhellerI never used the Rust stuff before so no idea how that part works#2018-10-2420:47gklijsKind of surprised how hard it's with clojurescript, did get it to work with Elm.#2018-10-2420:47thhellerwhat did you do in elm?#2018-10-2420:49gklijsFrom rust it's pretty easy to create some wasm module, also there's a lot of js/wasm interop work done.#2018-10-2420:51gklijsSo far in Elm I just had the basics working, but I could load and start the wasm part, and get info back through a port.#2018-10-2421:11thhellergeez the generate file is just weird#2018-10-2421:13richiardiandrea@thheller I have a Q...what can be the cause [:did-not-find policy-fn.api.query-events] error when connecting to nrepl? it does not happen in socket REPL but it does in nrepl, I switch a couple of versions of shadow, now on 2.6.10#2018-10-2421:13richiardiandreathen a REPL command timed out. follows#2018-10-2421:13thhellerin-ns before require or ns#2018-10-2421:13richiardiandreaoh but has that changed? I never needed that#2018-10-2421:14thhellerbasically in-ns before the policy-fn.api.query-events has been compiled#2018-10-2421:14thhellerstill need to check how CLJS behaves in that case. I just don't know what to do#2018-10-2421:15thhellerno that has not changed. has always been that way#2018-10-2421:15richiardiandreaoh ok, so there must be something on the cider side#2018-10-2421:17thhellerno clue what cider does#2018-10-2421:18thheller@gklijs is it possible to tune the wasm that gets generated? right now the .js files imports the .wasm and the .wasm imports the .js file right back#2018-10-2421:19thhellerthats kind of annoying to deal with since you can't process the .js in any meaningful way 😛#2018-10-2421:19thhellerthe browser must also be able to load it#2018-10-2421:22richiardiandrea@thheller if you can help me on the shadow side I can debug what broken#2018-10-2421:22richiardiandreacider does this:
(cider-nrepl-request:eval (format "(in-ns '%s)" ns)
                                (cider-repl-switch-ns-handler connection))
#2018-10-2421:24thheller@richiardiandrea in-ns is fine but what is happening BEFORE that? where is the require or so?#2018-10-2421:24thhellerwhich REPL are you connected to? your app? plain node-repl?#2018-10-2421:25richiardiandreait is a select-nrepl#2018-10-2421:25thhellerthats CLJ#2018-10-2421:25gklijs@thheller I don't think so, it's probably also why you need to load asynchronously#2018-10-2421:26gklijsThere's some sort of chicken and egg problem there#2018-10-2421:26thhellerright now this is part of the code#2018-10-2421:26thheller
(import "./game_of_life_3d" "__wbg_time_ff03c978915ebe44" (func $./game_of_life_3d.__wbg_time_ff03c978915ebe44 (type $t2)))
  (import "./game_of_life_3d" "__wbg_timeEnd_5ba22134470392e6" (func $./game_of_life_3d.__wbg_timeEnd_5ba22134470392e6 (type $t2)))
  (import "./game_of_life_3d" "__wbg_random_86efc8986c8a8805" (func $./game_of_life_3d.__wbg_random_86efc8986c8a8805 (type $t3)))
  (import "./game_of_life_3d" "__wbindgen_throw" (func $./game_of_life_3d.__wbindgen_throw (type $t2)))
#2018-10-2421:26thhellerso no matter what it will try to import the JS file relative to the path of the wasm#2018-10-2421:26thhellerthats just always going to break#2018-10-2421:27thhellerwell it'll work if you leave the code alone and just use it via <script type="module" ...>#2018-10-2421:27thhellerbut typically you can pass in an import import#2018-10-2421:28thhellerso you can pass in the functions instead of the wasm file trying to load them itself#2018-10-2421:28gklijsYes, or import it in index.ts, and load that with import("../ts/index.ts")#2018-10-2421:35richiardiandrea@thheller this is what is sent
(-->
  id         "20"
  op         "eval"
  session    "b5cba90b-dd4f-446a-81ea-2a02be297cb2"
  time-stamp "2018-10-24 14:32:34.813926979"
  code       "(in-ns 'laputa.policy-fn.api.query-events)"
)
(<--
  id         "7"
  session    "b5cba90b-dd4f-446a-81ea-2a02be297cb2"
  time-stamp "2018-10-24 14:32:34.864485854"
  out        "[:did-not-find laputa.policy-fn.api.query-events]
"
)
(<--
  id         "20"
  session    "b5cba90b-dd4f-446a-81ea-2a02be297cb2"
  time-stamp "2018-10-24 14:32:44.826639415"
  err        "REPL command timed out.
"
)
#2018-10-2421:35thhelleryou didn't answer my questions#2018-10-2421:36thhellerwhat REPL is this? where is the require for that ns?#2018-10-2421:36richiardiandrearight sorry 😄#2018-10-2421:36thhellerit just isn't loaded. thats all there is to it#2018-10-2421:36thheller(in-ns 'i.do.not.exist)#2018-10-2421:36richiardiandreathis is the form sent: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s))#2018-10-2421:37richiardiandreaafter the clojure REPL boots up#2018-10-2421:37thhelleryes .. that is also fine. but you are still completely ignoring my question#2018-10-2421:37thhellerwhat REPL is this? what build :target? how is it started?#2018-10-2421:37thhellernode-repl? :browser?#2018-10-2421:38thhellerwhere is the require?#2018-10-2421:38richiardiandrealet me answer all the Qs#2018-10-2421:38richiardiandreaso#2018-10-2421:38richiardiandreaI start with yarn shadow-cljs watch az#2018-10-2421:39richiardiandreaclasspath resolved with deps.edn#2018-10-2421:39richiardiandreaI launch and connect with the above#2018-10-2421:39thheller:target :azure-app?#2018-10-2421:39richiardiandreayeah#2018-10-2421:39richiardiandreaafter that I don't do any require#2018-10-2421:40richiardiandreaI connect with cider and try to switch namespace#2018-10-2421:40thhellerrun yarn shadow-cljs watch az --verbose#2018-10-2421:40richiardiandreatrying#2018-10-2421:41thhellerdoes it compile your ns?#2018-10-2421:41thhellerdid I get REPL working for the azure stuff? can't remember really#2018-10-2421:41thhellerah node-lib. so should be fine#2018-10-2421:42richiardiandrea@thheller it does not seem to compile that namespace for some reason#2018-10-2421:43thhellerthen nothing requires it?#2018-10-2421:43thhellerwhats your fn-map?#2018-10-2421:43richiardiandreayes I think that might be right#2018-10-2421:44richiardiandreaso weird#2018-10-2421:44richiardiandreaok but thanks for getting my head straight#2018-10-2421:44thhellerI think it would be much safer and less headache if cider just sent (require 'laputa.policy-fn.api.query-events) (in-ns 'laputa.policy-fn.api.query-events)#2018-10-2421:45richiardiandreayeah I agree with you and I will open an issue#2018-10-2421:45thhellerin-ns without require first also sucks in clojure#2018-10-2421:45richiardiandreait does not make sense to do anything different#2018-10-2421:45richiardiandreayeah#2018-10-2421:45thheller
(in-ns 'foo.bar)
=> #object[clojure.lang.Namespace 0x25e67a35 "foo.bar"]
(+ 1 2)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(C:\Users\thheller\AppData\Local\Temp\form-init11452515739617339391.clj:1:1) 
#2018-10-2421:46thhelleralso safer with require first if you switch into non-existent namespaces#2018-10-2421:47richiardiandreayep let me check with the cider folks but I totally agree#2018-10-2421:53richiardiandrea@thheller I am opening an issue in cider but I have a small suggestion for shadow as well. What if the error messages returned [:not-required .....]? It would be clearer what you have to do next and what the problem was#2018-10-2421:54thhellerits basically no "not implemented error" because I don't know what to do#2018-10-2421:54thhellerneed to check what the default CLJS repl does first#2018-10-2421:55richiardiandreaok cool I will open an issue then#2018-10-2421:55richiardiandreathanks a lot again#2018-10-2422:03richiardiandreaok opened and this is what happens in vanilla:
$ cljs-node-repl 
[Rebel readline] Type :repl/help for online help info
cljs.user=> (in-ns 'foo.bar)

foo.bar=> (+ 1 2)
3
foo.bar=> 
#2018-10-2422:07thhellerok so it just creates an empty ns?#2018-10-2422:07richiardiandreayeah...#2018-10-2422:07thhellerwhat happens if you in-ns into a ns that actually exists but was not required yet?#2018-10-2422:08richiardiandreauhm I would have to try on a project, will do it later ok? now I need to get stuff done for the day 😄#2018-10-2422:08thhellerI can try myself later#2018-10-2422:09thhelleror rather tommorrow 😉#2018-10-2422:09richiardiandreaoh, also one day I think you suggested me to use shadow/repl instead shadow/select-nrepl, maybe I should PR cider#2018-10-2422:09richiardiandreayeah 😄#2018-10-2422:09thhellerdoesn't really matter for cider given that it always uses nrepl#2018-10-2422:09richiardiandreaok coolio#2018-10-2422:10thhelleras a user its nicer to type shadow/repl IMHO but for a tool it doesn't matter#2018-10-2422:10richiardiandreatotally, good point#2018-10-2422:58lilactownOK I have a weird thing I'm trying to do#2018-10-2422:59lilactown
(defmacro defstart! [args & body]
  `(do
     (defn ~'-start! ~args
       
#2018-10-2422:59lilactownI'm trying to set the meta-data {:export true :dev/after-load true} from a macro. not having any success yet#2018-10-2422:59lilactownideas?#2018-10-2423:05lilactownah.
(defmacro defstart! [args & body]
  `(do
     (defn ~'-start! ~args
       
#2018-10-2505:28vigilancetechwhat's the advantage or disadvantage of using shadow's built in nrepl vs cider-nrepl (when using cider)?#2018-10-2508:03thheller@vigilancetech that is a question for the cider folks. its all about their middleware and what features it provides. I think it provides auto complete and other things but I'm not sure what.#2018-10-2512:24kozI might be missing something, however when trying to load modules on demand using shadow.loader in dev, it seems to 404 since it’s making the request for the additional compiled JS files to the port that the actual application is running in (5000), and not the port that the shadow dev server is serving the JS files from (3449). I have {:devtools {:loader-mode :eval :http-port 3449 :http-root "resources/public"}} set in the associated build, is there anything else I might be missing?#2018-10-2514:24thheller@koz its just a static file request on the same server that also served the initial .js file#2018-10-2514:24thhellerso if the initial is from :5000 it must also serve the modules#2018-10-2514:24thhellerif it 404s check that your :asset-path is correct#2018-10-2514:25kozok will do that, thanks!#2018-10-2514:46kozAlso, is :loader-mode :eval still a valid flag? I think at one time it was used to opt-in to a new loading mode, but can’t find any mention of it in the docs.#2018-10-2514:47thhelleryes thats still a thing#2018-10-2514:47thhelleroh right if you use that it may have problems with shadow.loader depending on the version you are on#2018-10-2514:48kozi see, is there a version that it should be OK?#2018-10-2514:48thhellerforgot which version I fixed that in but it was some time after I added loader-mode :eval#2018-10-2514:48thhellerthe latest definitely has that fixed#2018-10-2514:48thheller2.6.18#2018-10-2514:48kozI’m on 2.6.4 right now, but can try updating#2018-10-2514:50thhellerI think it was fixed in 2.6.10 so that might be it#2018-10-2514:52kozcool thanks#2018-10-2515:09kozJust updated to 2.6.18 and still running into the same issue. The app has a script tag to load the main JS bundle from the shadow dev server (http://localhost:3449/js/compiled/dev/main.js), which is working fine. Are you saying that any modules loaded via shadow.loader (e.g. /js/compiled/dev/cljs-runtime/lazily_loaded_module.js) won’t load from that same localhost:3449, but that our application server (instead of the shadow-cljs devtools server) needs to be configured to statically serve the compiled JS bundles?#2018-10-2515:10thhellerso it has <script src="">?#2018-10-2515:10kozyeah#2018-10-2515:10thhellerthen you need to set :asset-path to #2018-10-2515:11kozoh ok, didn’t know that took a host/port#2018-10-2515:21thhellerbasically in case of the loader it will combine the asset-path + filename#2018-10-2515:22thhellertypically thats just a path so it would request relative to the location of the current document#2018-10-2515:24kozthat worked, however I’m getting CORS errors from accessing a resource on a different port via XHR. I tried adding
{:devtools {:push-state/headers {"content-type" "text/html; charset=utf-8"
                                    "access-control-allow-origin" "*"}
to my shadow-cljs.edn, but don’t see the second header.
#2018-10-2515:25thhellerhmm would it not be possible to make :5000 just serve the files?#2018-10-2515:25thhellerits just static files#2018-10-2515:27thhellerCORS can currently not be configured for static files#2018-10-2515:27thhellerthe push-state handler is only for actual push-state requests (ie. files that don't exist)#2018-10-2515:28kozi see. yeah it would take a bit of extra configuration on our end, but we can make something work for now. thanks!#2018-10-2515:28thhelleryou could also use :3449 and let it proxy to :5000 for API stuff#2018-10-2515:29thheller:devtools {:proxy-url ""}#2018-10-2515:30kozcool let me give that a try.#2018-10-2515:31thhellerlocalhost:3449 should then serve whatever :5000 serves#2018-10-2516:55wilkerluciohello, sometimes I'm getting this in my CI release build for shadow:#2018-10-2516:55wilkerlucio
aborted par-compile, [:shadow.build.classpath/resource "garden/compiler.cljc"] still waiting for #{garden.units}
{:aborted [:shadow.build.classpath/resource "garden/compiler.cljc"], :pending #{garden.units}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "garden/compiler.cljc"] still waiting for #{garden.units}
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
#2018-10-2516:56wilkerluciothe ns after still wanting for usually changes, so I'm wondering if that's some shadow timeout? if it is, can I increase it somehow? as the codebase grows I'm feeling its starting to happen more often, a second trigger of the build usually works#2018-10-2517:13thheller@wilkerlucio hmm do you have a verbose log? the timeout is 60000 already and its very unusual if it hits that? you can increase is via :build-options {:par-timeout <num-in-ms>}#2018-10-2517:24lilactown@wilkerlucio I was running into a similar issue on CI as well.#2018-10-2517:24lilactownI was running a number of release builds concurrently, and switching to running them synchronously seems to have resolved the issue#2018-10-2517:25thhellerah right I never asked if that changed anything#2018-10-2517:29thhellerthis is so weird logically. the tasks are submitted in dependency order so it is ensured that garden.units is compiled before garden.compiler.#2018-10-2517:30thhellerso the only case where garden.compiler is even waiting for compile is when a thread is becoming available while the others are still compiling#2018-10-2517:30thhellerbut that means that garden.units takes 60sec to compile#2018-10-2517:31thhellerplease turn on :verbose true (globally in config) or run with --verbose#2018-10-2517:31thhellerI don't get how this would happen even with many builds running in parallel#2018-10-2517:32thhellergarden.units should never take this long to complete and it must have started no matter how many other jobs there are#2018-10-2517:33thhellerdoesn't matter which namespaces. it the same logic everywhere#2018-10-2517:35thhellera verbose log should at least end with the time it took for garden.units to complete#2018-10-2518:23wilkerlucio@thheller a lot of times I get this with cljs.core as well, and I'm running 2 parallel builds, the total compilation time gets to about 6 minutes when it works#2018-10-2518:24thhellerwhat the heck. is it running on a toaster?#2018-10-2519:12wilkerluciojust a lot of files, 70K CLJS lines without counting deps, 😛#2018-10-2519:26wilkerlucio@thheller I'm having an issue that I had before with release builds regarding externs on .js files, but I can't remember how I fixed that, is that a way to tell the compilation to dont mangle code from .js files?#2018-10-2520:03thhellerit doesn't matter how many files there are. the queuing ensures that they are compiled in proper order with minimzed wait times#2018-10-2520:03thheller@wilkerlucio shadow-cljs check the-build should tell you#2018-10-2520:05thhelleri'll definitely add the sequential option so that release builds don't run in parallel by default#2018-10-2520:05thhellerseems to cause more issues than it solves#2018-10-2520:37wilkerluciois there a way to run shadow using a diferent profile then the one defined on shadow-cljs.edn?#2018-10-2520:38thhellerprofile?#2018-10-2520:38thhelleryou mean deps.edn alias?#2018-10-2520:38thhellershadow-cljs -A :foo:bar?#2018-10-2520:43patOk so I've figured a nice way to generate bindings for Wasm modules. I'm a shadow-cljs noob. Where do I start to work out a packaging solution#2018-10-2520:43patTheres an array buffer that must be loaded async, and functions defined afterward. Would be nice to treat it as a module#2018-10-2520:57thhellerdefine module? as in code split :modules?#2018-10-2520:58patI trust your judgment on this, I'd like shadow-cljs to inform how I proceed#2018-10-2520:58thhellerwell it depends all on how the .wasm is structured#2018-10-2520:58thhellerI only checked the Rust output and thats not going to work in either case#2018-10-2520:58patwhy is that
#2018-10-2520:59thhellersince the .js so so coupled to the .wasm#2018-10-2520:59patno im completely outside that#2018-10-2520:59thhellerhttps://github.com/thheller/shadow-cljs/issues/397#issuecomment-432981467#2018-10-2520:59patgenerating our own bindings, not rust-wasm wasm-bindgen#2018-10-2521:00patyes talking linking up to exported functions ourselves. I think I've got it but next step after is the important bit#2018-10-2521:03thhellercan you give me an example?#2018-10-2521:04patinstead of doing this https://github.com/pkpkpk/fress/blob/master/src/wasm_test/fress/wasm_test.cljs#L68#2018-10-2521:05patcan define functions for you given a module description#2018-10-2521:06patright now you have to use a string to lookup the exported function and use that to call it#2018-10-2521:07patwasm-bindgen uses an ast to rig this up, we can do the same#2018-10-2521:08patyou can define functions statically if you want its just not a pleasant dev experience#2018-10-2521:12patAm I explaining this ok? Im probably alittle close to this#2018-10-2521:14thhellerwhere is the wasm?#2018-10-2521:14thhellerhow to I generate it?#2018-10-2521:15patIm not sure what you mean#2018-10-2521:16patI've already built a cargo layer. Just need to load arraybuffer and instantiate it#2018-10-2521:16thhellerI don't know what cargo is#2018-10-2521:16patok yeah thats rust build tool. got all that figured out#2018-10-2521:17pathttps://github.com/pkpkpk/cargo-cljs/blob/master/src/main/cljs/cargo/api.cljs#L38#2018-10-2521:18patyou get your array buffer, separately a description of the module, and generate cljs bindings from that#2018-10-2521:18thhelleryeah thats not an option for the browser#2018-10-2521:18pati dont understand#2018-10-2521:19patits just a build tool you can send buffer to browser no problem#2018-10-2521:19patthat would I assume be some hook step in shadow-cljs#2018-10-2521:19thhellerbut its written in cljs. so its of no use for shadow-cljs#2018-10-2521:20thhellershadow-cljs is written in Clojure and hooks are Clojure#2018-10-2521:20patok you can shell out and do it#2018-10-2521:20pati can rewrite it in rust if need be#2018-10-2521:21thhellerso what I ideally want is a .wasm file and a .json or .edn file that has some data about the file#2018-10-2521:21thheller(which would save parsing the .wasm)#2018-10-2521:22patyeah im there#2018-10-2521:23patbuild details are less interesting, getting async needs of namespaces etc is where I need help#2018-10-2521:23thhellerhmm?#2018-10-2521:24thhellerasync is not going away probably#2018-10-2521:24patyes, how to get it all to play nicely with closure etc#2018-10-2521:25thhelleryou don't? you just js/fetch the .wasm file an instantiate it#2018-10-2521:25patsure people can already do that#2018-10-2521:25thhelleror instantiateStreaming#2018-10-2521:26patthat too but is poorly supported. Im looking for easy integration with cljs project minus dealing with this stuff.#2018-10-2521:26patif not possible thats ok#2018-10-2521:27thhellerwhich stuff? its like 3 lines of code? the complicated part as I see it is passing function INTO the wasm so it can call js functions#2018-10-2521:27thhellerand getting functions out so that normal code can call it#2018-10-2521:28thhellerand that kinda needs compiler support#2018-10-2521:28patYes it would be nice to distrubute wasm modules as libs is all. I agree the existing burden is really all that bad#2018-10-2521:29patok I thought maybe#2018-10-2521:29patisn't that bad *#2018-10-2521:29thhelleryes I want that but as I said I need a .wasm file + some metadata about it#2018-10-2521:30thhellerotherwise there is no way to "automate" it into a build#2018-10-2521:30patyes I've got that!#2018-10-2521:30patwhats next#2018-10-2521:30thhellergive it to me?#2018-10-2521:30patlol#2018-10-2521:30thhellerI don't care about anything else#2018-10-2521:30thhellersince you can't expect a user of a lib to install the entire Rust tool pipeline#2018-10-2521:31thhellerthe final result is what I'm interested in#2018-10-2521:31patofcourse#2018-10-2521:31thhellernot how it got there#2018-10-2521:31patI was asking you to write something, I'm offering a contribution. but if you just want the raw tools thats cool#2018-10-2521:32patwasnt*#2018-10-2521:32patgeez i cant type#2018-10-2521:32thhelleryeah I totally want to explore how I can integrate .wasm into shadow-cljs to make things nicer#2018-10-2521:33patI will clean things up and try to put them in clj for you#2018-10-2521:33thhellerfor that I need a .wasm file I don't have and can't produce#2018-10-2521:33thhellerI do not want to install Rust or anything#2018-10-2521:34thhellercompiling rust is just never going to become part of shadow-cljs ever#2018-10-2521:34thhellersure it can shell out but thats not the integration point#2018-10-2521:34thhellerthe integration point is a .wasm file + metadata#2018-10-2521:34patyes!#2018-10-2521:34thhellerso if you can give me that I'd the grateful#2018-10-2521:35pati didnt explain myself very well I apologize#2018-10-2521:35patI am saying, we can have a binary and a description, and turn it into something that feels like a namespace#2018-10-2521:36patthe process of packaging that up should inform how the description is used with the binary#2018-10-2521:36patpeople dont have to care about rust if they dont want to#2018-10-2521:36thhellerwe are running in circles#2018-10-2521:37pati know#2018-10-2521:37thhellerif you can give me a .wasm file + metadata I can work something out#2018-10-2521:37thhellerif not I can't do anything#2018-10-2521:37pat:+1:#2018-10-2521:37thhellerthe only other .wasm file I have is never going to work#2018-10-2521:38thhellerI'll eventually look into the rust wasm tools but that will probably be next year#2018-10-2604:37gklijsThe one from me does work, and since you only need to use it by calling the functions in the JavaScript that comes with it, there is no need to do anything to the wasm at compile time, besides copying it.#2018-10-2605:30gklijsApparently there was a pr for adding wasm to externs for closure, but it wasn't accepted. https://github.com/google/closure-compiler/pull/2534#2018-10-2607:18thhellerhttps://github.com/google/closure-compiler/blob/master/contrib/externs/webassembly.js ?#2018-10-2607:18thhellerall merged#2018-10-2607:19thhelleryes the one you have works .. unless you modify or rewrite the JS in any way then it doesn;t#2018-10-2607:19thhellerso I meant that it'll never work with shadow-cljs without processing the .wasm#2018-10-2608:10gklijsMissed the contib map#2018-10-2522:18wilkerlucio@thheller sorry, wasn't clear, I mean lein profiles, because I have a specific type of run that I want to have different deps there#2018-10-2522:18thheller@wilkerlucio no thats not supported but you can just use lein with-profiles +whatever run -m shadow.cljs.devtools.cli release whatever#2018-10-2522:19thhellerits the same as calling shadow-cljs release whatever#2018-10-2522:19thhellerjust lets you do whatever lein thing you want#2018-10-2522:28thheller@lilactown @wilkerlucio on your failing builds. how many CPU cores do the machine have? 1-2?#2018-10-2522:30thhellerand how long do builds take that don't fail?#2018-10-2522:32wilkerlucio5 ~ 6 min here, I don't how many cpus are on this one, I can check, but those are shared instances doing CI for a lot of projects#2018-10-2522:33thhellerI think it may be the closure optimization stalling things#2018-10-2522:33thhellerI know that it was taking 45sec for one of your builds the other day#2018-10-2522:33thhellerso its easy to imagine that it gets past the 60sec mark when under load#2018-10-2522:34thhellerwhich means it can fully utilize a core and stall other work trying to use it#2018-10-2522:34thhellernot actually sure how java schedules work like this#2018-10-2522:35thhellerI know in erlang processes only get a certain number of reductions but I think thats different on the JVM#2018-10-2522:39lilactownwhen they were done concurrently, the builds were taking ~400s#2018-10-2522:42lilactownthe builds run on a m4.2xlarge EC2 inside a docker container#2018-10-2522:43lilactownit says it has 8 vCPUs#2018-10-2522:45thhellerbut the issue has not happened again since switching to sequential builds?#2018-10-2522:46thhellerprobably the only area where parallel build is useful to begin with is running multiple closure optimizations in parallel#2018-10-2522:46thhellersince they are single threaded and take a while#2018-10-2522:47thhellerbut if they completely prevent a parallel build from making any progress that kinda defeats the purpose#2018-10-2522:52lilactownyeah, since switching to sequential builds I haven't seen an issue#2018-10-2608:41vigilancetechwith this repo: {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "77101e0337101e031f02155914181a"}, :content ("[email protected]")} I'm getting nothing but Build failure: from the watch task and this from the server:
...
shadow-cljs - nREPL server started on port 42651
Exception in thread "async-dispatch-5" java.lang.Error: java.net.SocketException: Socket closed
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
        at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
        at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
        at java.io.BufferedWriter.flush(BufferedWriter.java:253)
        at clojure.core$flush.invokeStatic(core.clj:3703)
        at clojure.core$prn.invokeStatic(core.clj:3713)
        at clojure.core$prn.doInvoke(core.clj:3706)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at shadow.cljs.devtools.server.util$stdout_dump$fn__13982$state_machine__6460__auto____13987$fn__13990.invoke(util.clj:213)
        at shadow.cljs.devtools.server.util$stdout_dump$fn__13982$state_machine__6460__auto____13987.invoke(util.clj:213)
        at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
        at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
        at clojure.core.async.impl.ioc_macros$take_BANG_$fn__6478.invoke(ioc_macros.clj:986)
        at clojure.core.async.impl.channels.ManyToManyChannel$fn__2089$fn__2090.invoke(channels.clj:95)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        ... 2 more
This is me toying around with shadow's electron example. This is one thing ya gotta love about clojuresque languages. Opaque error messages. Anyone have an idea what it is (and why it doesn't tell me anything useful)?
#2018-10-2608:47vigilancetechAlso, I'm pretty sure I saw a flag to make shadow not output custom terminal codes (e.g. vt100) so it could be used, for example, in eshell. Now I can't find it (and it doesn't appear to be anywhere in the manual). Does anyone remember what it is?#2018-10-2609:38thheller@vigilancetech that is not a build failure message#2018-10-2609:39thhellerthere is no such flag#2018-10-2609:39thhellerrun shadow-cljs server and open #2018-10-2609:39thhellerthen select your build#2018-10-2609:39thhellerand click compile#2018-10-2609:40thhellerand to be of any use debugging I need to know which command you used in which environment#2018-10-2616:16robert-johanssonHello all - I'm quite new to clojurescript and shadow-cljs. I'm thinking about the possibility to write your own cljs code for an existing React template.#2018-10-2616:16robert-johanssonFor example - I'm curious in using this one: https://github.com/coreui/coreui-free-react-admin-template#2018-10-2616:17robert-johanssonIs it possible to write cljs code that includes components/scss/etc from the template, and build such project with shadow-cljs?#2018-10-2616:29thheller@robert-johansson JS/CLJS yes, scss no#2018-10-2616:46robert-johansson@thheller OK sounds promising. So I could probably then add JS/JSX files from the template to a shadow-cljs project, and then import components locally from my cljs code?#2018-10-2617:01thhellerjsx files are going to need to be pre-processed but then they can be imported normally yes#2018-10-2617:02thhellerhttps://github.com/shadow-cljs/examples/tree/master/babel#2018-10-2618:16robert-johansson@thheller That seems to be exactly what I need. Thanks!#2018-10-2618:42wilkerluciois there a flag today to make the builds serial? its for my ci thing, or do I have to run separated processes?#2018-10-2620:03Wilson Velezhi, how can I stop a watch?#2018-10-2620:03Wilson VelezI’m starting it “shadow-cljs watch app”#2018-10-2620:04thhellerctrl+c#2018-10-2620:05thheller@wilkerlucio there is no flag no but you can create a function and call that via shadow-cljs run#2018-10-2620:05Wilson Velezthanks#2018-10-2620:19thheller@wilkerlucio just pushed 2.6.19 which now does release sequentially instead of parallel#2018-10-2620:19thhelleruntil I can figure out what is happening thats the safer default#2018-10-2620:23wilkerluciothanks!#2018-10-2622:24Wilson Velezhow do I know and change the version of clojure(Script) in my shadow-cljs configuration?#2018-10-2623:18lilactown@wvelezva shadow-cljs pulls in the latest clojurescript version#2018-10-2623:18lilactownI think you can override it in your dependencies#2018-10-2702:35richiardiandreaOh all releases of all targets? This will make our builds way slower. Haven't followed but I compile my tests always in parallel for note and haven't noticed anything wrong#2018-10-2707:53thheller@wvelezva shadow-cljs always tracks the latest CLJS version and it is not recommended to change that. Downgrades are generally not supported. You can use master in most cases unless there have been breaking changes but I'm not aware of any. There was supposed to be a new release a while ago ...#2018-10-2707:56thheller@richiardiandrea when builds reach a certain size they seem to start failing due to parallel compilation timeouts. (Now reported multiple times). I will add the parallel option back as soon as I figure out what could be happening. Right now I can't explain why it would timeout and that bothers me.#2018-10-2708:41JonCurious if I can do this:#2018-10-2708:41Jon
{:source-paths ["src"]
 :dependencies []
 :builds {"app" {:output-dir "target/"
                 :asset-path "."
                 :target :browser
                 :modules {"main" {:init-fn app.main/main!}}
                 :devtools {:after-load app.main/reload!
                            :http-root "target"
                            :http-port 8080}}}}
#2018-10-2708:42JonI want to use "app" instead of :app to indicate that it's specified by me and not part of shadow-cljs' options.#2018-10-2708:43Jonsame in using "main"#2018-10-2708:48thhelleryou cannot no. Not sure I see the point. Every key in :modules is always specified by you, not sure how a string would make that clearer?#2018-10-2708:50thhellerremember that the keyword is also used again in :depends-on when code splitting#2018-10-2708:50thheller:depends-on #{"foo" "bar"} vs :depends-on #{:foo :bar}#2018-10-2708:50thhellerif enough people express interest in this I'll consider it#2018-10-2708:51thhellerbut you don't use {"foo": {"bar": 1}} in JS either to express that it is "your" value.#2018-10-2708:52Jonno choice in JavaScript.#2018-10-2708:52thheller(I was thinking of webpack config where {foo: {bar: 1}} is possible and used, not .json files)#2018-10-2708:53Jonkeywords make me think this field will be checked by program and I have to use a certain word there. while I found strings quite flexible and I know it's my choice to name it.#2018-10-2708:54thhelleryou can use whatever you want there .. it just matters that its a valid keyword#2018-10-2708:55thhellerwhich is also a useful constraint since it matches what a filename should be#2018-10-2708:55Jonyes, (after I actually know that it means)#2018-10-2708:55thheller:modules {"SOMETHING foo \ bard" {:init-fn ...}}} would be bad#2018-10-2708:56Jonthen validate the string?#2018-10-2708:57thhellerif you convince me that it has actual benefits over a keyword#2018-10-2708:57thhellerits not hard to learn that they key of the :modules map will become the filename#2018-10-2708:57thhellerand that is the only restriction it has#2018-10-2708:58Jonkind of agreed...#2018-10-2709:00Jonevery time I step away from shadow-cljs.edn for some weeks then looks into it again, I feel a bit confused that :main is in shadow-cljs' specification and where do I specify the filename.#2018-10-2709:04thhellerit isn't in any specification#2018-10-2709:05thhellercall it :index it is completely up to you#2018-10-2709:06thheller> The :modules section of the config is always a map keyed by module ID. The module ID is also used to generate the Javascript filename. Module :main will generate main.js in :output-dir.#2018-10-2715:43lilactownFWIW I would much rather have namespaced keywords as module keys 😉#2018-10-2716:52thheller:foo.bar or :foo-bar is perfectly valid. what would :foo/bar give you?#2018-10-2709:06thhellerfrom the docs ...#2018-10-2709:06Jonyeah, I knew that. just took several seconds to warm up again.#2018-10-2712:01y.khmelevskiihello! I want to change cljs code during build. I use build hooks for this. For example, I want to remove some lines from sources with comment ;; exclude-line I did something like this
(defn- update-values [m f & args]
  (reduce (fn [r [k v]]
            (assoc r k (apply f v args))) {} m))

(defn exclude-dev-code
  {:shadow.build/stages #{:compile-finish}}
  [build-state]
  (update-in
   build-state
   [:output]
   update-values
   (fn [value]
     (update-in value [:source]
                #(clojure.string/replace
                  %
                  #"(?s)([^\n]+)\;\; exclude-line"
                  "")))))
but unfortunately this approach doesn’t work. Can you explain me please what am I doing wrong?
#2018-10-2712:41thheller@y.khmelevskii not sure I understand what you are trying to do. whats the point of removing a comment?#2018-10-2712:41thhelleralso if you mess with the source after compliation the source maps will be busted#2018-10-2712:42y.khmelevskiiI want to remove some lines from my sources during compilation. I use comments for marks these lines#2018-10-2712:43thhellerwhy though?#2018-10-2712:43thhellerwhat is the goal?#2018-10-2712:43thhellerwould this help? https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-10-2712:44thhellerdo you have a concrete example of what kind of code you want to remove?#2018-10-2712:47thhelleryour hook doesn't work because the :source in :output is only used for source map and you are calling it in :compile-finish which is after CLJS compilation#2018-10-2712:48thhelleryou'd need to do it in :compile-prepare and inside :sources#2018-10-2712:48thhellerbut I think the reader conditionals are probably cleaner?#2018-10-2712:52y.khmelevskiiI want to remove some requires, for example
(ns test.components.app.nav.view
  (:require
   [ghostwheel.core :refer [>defn =>]] ;; clj-exclude-line
#2018-10-2712:52thhellerthats the exact usecase for reader conditionals#2018-10-2712:53y.khmelevskiiunfortunately conditional_reading doesn’t work in cljs files#2018-10-2712:53thhellerthen rename them to .cljc? no other difference really#2018-10-2712:54y.khmelevskiigot it, thank you! I will try#2018-10-2719:14neupshHello, i am trying to use quil in my cljs project managed by shadow-cljs, i added [quil "2.7.1"] to :dependencies in shaldow-cljs.edn and use the quil.core namespace, but it fails to compile with the following error:#2018-10-2719:15neupsh
The required namespace "org.processingjs.Processing" is not available, it was required by "quil/core.cljc"
#2018-10-2719:16neupshThis is what i am trying to use https://github.com/quil/quil#2018-10-2719:16neupshProcessing js is packaged by quil and should have been available#2018-10-2719:17neupshDoes anyone have any idea on how to use it with shadow-cljs? They have a wiki on how to use it with clojurescript here: https://github.com/quil/quil/wiki/ClojureScript#2018-10-2719:17thhellerprocessing is probably bundled as a foreign-lib ala cljsjs. this is not supported by shadow-cljs. instead you use the npm package directly (assuming there is one)#2018-10-2719:18neupsh@thheller yes Processing-js library is available in npm#2018-10-2719:18thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-10-2719:19thheller
(ns org.processingjs.Processing
  (:require ["processing" :as proc]))

(js/goog.exportSymbol "the-global-quil-uses" proc)
#2018-10-2719:19thhellerbasically#2018-10-2719:20neupsh@thheller cool, let me try that.. Thank you#2018-10-2719:20thheller(js/goog.exportSymbol "Processing" proc) I guess#2018-10-2719:24thhellerhttps://www.npmjs.com/package/processing-js is this it? updated 2 years ago?#2018-10-2719:25neupsh@thheller yes#2018-10-2719:26neupsh@thheller it is a nice drawing library and quil is a clojure(script) wrapper 🙂#2018-10-2808:00lassemaattaHi. I've noticed that our build produces a lot of warnings regarding provide conflicts and filename violations. This doesn't seem to cause any actual problems, but I don't like seeings warnings. Any idea what might be the cause of this?#2018-10-2808:00lassemaattaFor example:#2018-10-2808:01lassemaatta
[2018-10-28 09:54:53.504 - WARNING] provide conflict for #{clojure.string} provided by out/clojure/string.js and {"/clojure/string.cljs" #{clojure.string}}
[2018-10-28 09:54:53.504 - INFO] filename violation for ns vimsical.re-frame.fx.track, got: out/vimsical/re_frame/fx/track.cljc expected: vimsical/re_frame/fx/track.cljs (or .cljc)
#2018-10-2808:02lassemaattaOur dependencies are declared in project.clj, therefore we use :lein true#2018-10-2808:06lassemaattaOur configuration for the :app build looks basically like this#2018-10-2808:06lassemaatta
:builds {:app               {:target :browser}
          :module-hash-names true
          :output-dir        "resources/public/js/compiled"
          :asset-path        "/js/compiled"
          :module-loader     true
          :modules           {:common {:entries [foobar.main]}
                              ..      a few other modules..}
          :devtools          {:http-port    4000
                              :http-root    "resources/public"
                              :http-handler shadow.http.push-state/handle
                              :before-load  foobar.main/before-load
                              :after-load   foobar.main.main/after-load
                              :preloads     [dev.preloads]
                              :loader-mode  :eval}
          :js-options        {:resolve {"object.assign" {:target :npm :require "object-assign"}}}
          :dev               {:compiler-options {:optimizations   :none
                                                 :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
          :release           {:compiler-options {:optimizations :advanced}}}
#2018-10-2808:35thheller@lasse.maatta out seems to be on the classpath?#2018-10-2808:35thhellerso its either in your :source-paths or :resource-paths?#2018-10-2808:36thhellerthe sources also seem to get copied there which is bad#2018-10-2808:37lassemaattayeah, our project.clj says :resource-paths ["resources"]#2018-10-2808:41lassemaattahmm. undefining or pointing the :resource-paths elsewhere doesn't seem to affect the warnings.#2018-10-2808:50lassemaattaalso, I can't find any reference to out in our source or configuration. Is it some internal shadow-cljs thing?#2018-10-2809:43Jon#2018-10-2809:43Jonanything I can do except for turning inference off?#2018-10-2811:06thheller@lasse.maatta no shadow-cljs does not use any out directory. maybe its leftovers from cljsbuild or so?#2018-10-2811:07thheller@jiyinyiyong yes, typehint correctly. you cann remove all ^js you currently have since they are all incorrect#2018-10-2811:07thhelleronly ^js this is required#2018-10-2811:58JonOh. it works. So the warning is pointing at the wrong position.#2018-10-2813:21ClashTheBunnyIs this just me?#2018-10-2813:22ClashTheBunnyI didn't even have ClojureScript in my deps.edn, so I don't know what version I was using beforehand.#2018-10-2813:29ClashTheBunnyI tried because of this:#2018-10-2815:23thheller@clashthebunny not sure. I'll check master tommorrow. didn't see any breaking changes but maybe I missed something#2018-10-2901:52souenzzoThere is docs about how to add a single cljs file on a (possibly) complex react/jsx/npm project?#2018-10-2906:35thheller@souenzzo https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2018-10-2907:08lassemaatta@thheller: I think I may have figured out the problem I had yesterday (lot's of provide conflicts). I happened to notice that the .jar of one of our dependencies (https://github.com/vimsical/re-frame-utils) from clojars contains a directory called out (6.2 megabytes), which in turn contains cljs, goog, .. re_frame, .. reagent.. and a bunch of other compiled js libraries. Now I'm no expert on building packages, but that doesn't seem quite right?#2018-10-2907:28thheller@lasse.maatta yes. that is not correct and should not be done#2018-10-2916:21Wilson VelezHi, I’m moving from leiningen and figweel to shadow-cljs.#2018-10-2916:21Wilson VelezI’m doing a single re-frame app that has a db.cljs file with the specs and a handler.cljs file with the database initialization. after the initialization there is an interceptor used for debug#2018-10-2916:21Wilson Velez
(def check-spec-interceptor
  (after (partial check-and-throw :custodian_assets.db/db)))
#2018-10-2916:22Wilson Velezbut I’m getting this error#2018-10-2916:22Wilson Velez
alpha.cljs:71 Uncaught Error: Unable to resolve spec: :custodian_assets.db/db
    at Object.cljs$spec$alpha$reg_resolve_BANG_ [as reg_resolve_BANG_] (alpha.cljs:71)
    at Object.cljs$spec$alpha$Specize$specize_STAR_$arity$1 (alpha.cljs:128)
    at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:124)
    at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:141)
    at Function.cljs$core$IFn$_invoke$arity$2 (alpha.cljs:359)
    at custodian_assets$handlers$check_and_throw (handlers.cljs:14)
    at Function.G__14213__2 [as cljs$core$IFn$_invoke$arity$2] (core.cljs:4268)
    at re_frame$std_interceptors$after_$_after_after (std_interceptors.cljc:313)
    at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:68)
    at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:106)
#2018-10-2916:23Wilson VelezWhat am I missing?#2018-10-2916:30hoopesHi, quick question - I’m trying to use https://github.com/gadfly361/soda-ash/blob/master/src/soda_ash/core.cljs , which has (:require [cljsjs.semantic-ui-react]… in it. This adds about 600 files to my dev build, but when it’s compiled for production, only the actually used components will remain, or b/c it’s cljsjs, it’ll keep the whole semantic ui code? Thanks!#2018-10-2916:43thheller@hoopes all will be included yes#2018-10-2916:44hoopesso cljsjs stuff (i think i heard you say this in a podcast?) is best to avoid when using shadow?#2018-10-2916:44thhelleryou can only requite whatever you need manually but when including the root package everything will be included#2018-10-2916:44thhellerno its the same if you import (:require ["semantic-ui-react" ...])#2018-10-2916:45hoopesright, but the soda-ash lib uses cljsjs, so i should avoid that lib in shadow (?)#2018-10-2916:45thhellersoda-ash yes thats a problem if it always imports everything#2018-10-2916:46hoopesgotcha - thanks!#2018-10-2917:58hoopesdoes it make sense to try to control two different browser apps from a single shadow-cljs.edn file?#2018-10-2918:39hoopesand/or does it make sense/is it possible to change source paths per app? or does the namespacing make that irrelevant? (sorry, my first cljs app…)#2018-10-2919:10thheller@hoopes :source-paths can only be configured once per shadow-cljs.edn, not per build. you run have multiple builds per config though that is perfectly fine. only code used in a build will actually be compiled#2018-10-2919:10hoopesok, great, thanks again#2018-10-2920:40littleliHi all. I have confusing issue regarding paths. How to solve situation where application in prod sits on some path like http://mydomain.com/coolapp but in dev there is no need for /coolapp path? in index.html I have /coolapp but then having issues with paths in dev.#2018-10-2920:41littleliwhat I did... I split builds, paths and on dev I add clumsy /coolapp prefix but I hate idea that files are now copied to different locations 🙂#2018-10-3006:14thheller@ales.najmann https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-10-3006:15thheller:asset-path "/js" :release {:asset-path "/coolapp/js"}#2018-10-3006:15thhelleror :dev {:asset-path ...} whichever you prefer#2018-10-3007:24pekka#2018-10-3007:25pekkaI have trouble understanding how the :proxy-url works. If I make request to localhost:8888/todos/1 I get HTTP 503#2018-10-3007:26thhellerseems correct. I'll check#2018-10-3007:32thhellerhmm yeah it doesn't like the https for some reason#2018-10-3007:34pekkaThere was a different proxy method? Would that work with https? I'd like to develop against a existing API that uses https#2018-10-3007:35thhellerthere is no other built-in proxy method no but I can fix this issue#2018-10-3007:36pekkaoh, great!#2018-10-3007:36thhellerits just a config error in the code#2018-10-3007:51thheller@pekka I fixed it locally but now I get a 403 Forbidden from cloudflare#2018-10-3007:52thhellerit works when I try to access it directly but not through the proxy#2018-10-3007:52thhellerand now it appears to have banned me completely since even the ssl handshake fails#2018-10-3007:53pekkaok 😊#2018-10-3007:55thhellerother ssl sites I can proxy fine but cloudfare seems to filter the proxy requests#2018-10-3007:55pekkaok, I don't need cloudflare as such, that was just as an example#2018-10-3007:56thhellerah ok#2018-10-3007:56pekkaIs your fix something you can release though? That would help me very much!#2018-10-3007:59thheller@pekka fixed in version 2.6.20#2018-10-3007:59pekkagreat! 🙇#2018-10-3008:06pekkanow the request works but since the target uses vhost it gets confused 😄#2018-10-3008:09pekkaIt would work if the proxy rewrites the Origin#2018-10-3008:10pekkaDo you know if undertow(?) supports that?#2018-10-3008:11thhellerhmm no idea#2018-10-3008:12thhelleryou can just use any other http server if that is easier#2018-10-3008:12pekkaok, no problem I can live with this 😄#2018-10-3008:12thhellerits just files as far as shadow-cljs is concerned#2018-10-3008:14thhellerhmm there is a rewriteHostHeader option for the proxy handler#2018-10-3008:14thhellermaybe thats enough?#2018-10-3008:14pekkaI woud think so#2018-10-3008:15pekkawith TLS SNI it is the only thing the webserver sees before terminating TLS#2018-10-3008:15thhellerwonder why it defaults to false#2018-10-3008:16thhellerguess I'll add an option for that#2018-10-3008:42littleli@thheller yes, I use :asset-path but alone it does not work, assets have to be produced on specified path with specified :output-dir at least and I don't like that location is different for :dev and :release builds 😞#2018-10-3008:43thhelleryou can override all options#2018-10-3008:43thheller:release {:output-dir "foo/bar"}#2018-10-3008:44littlelisure, it is just that there are more moving parts in the build. like asset 'copying' and so on and on release build process can be different and one has to do additional checking so that build is correct.#2018-10-3008:45thhellernot sure I understand what you mean or what the problem is?#2018-10-3008:45littleliit's more or less nitpicking from my side#2018-10-3008:45littlelireproducibility#2018-10-3008:46littleliif there are different pipelines for dev and release, more moving parts, more stuff can break#2018-10-3008:46thhellerwell dev is always going to have differences compared to release#2018-10-3008:47thhellerbut I have been running without :release specific config for years#2018-10-3008:47littlelime too, but this project that I have is different unfortunately 🙂#2018-10-3008:48littleliit actually works, so no worries#2018-10-3008:55thheller@pekka just pushed 2.6.21 which fixed a couple issues with the proxy support and also now supports rewriting the host header#2018-10-3008:55thhellerenabled by default :proxy-rewrite-host-header false to disable#2018-10-3009:46pekka👍#2018-10-3010:04pekkaSeems "change origin" would be the feature that is required. for example#2018-10-3010:05pekka#2018-10-3010:06thhellerwhat does that do?#2018-10-3010:06pekkachange the Origin-header in the request#2018-10-3010:06pekkadoesn't seem to be an option on the undertow Proxy...#2018-10-3010:07pekkaI can link through the @cedx/reverse-proxy, so no problem for me, just for further study 😊
#2018-10-3014:11pekkaWhat are the https settings in :devtools?#2018-10-3014:15pekkaor is https supported on devtools http server?#2018-10-3017:14thheller@pekka https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl enables it for all servers#2018-10-3020:49vigilancetechbasic "hello world" example for shadow + hoplon + electron (w/reload): https://github.com/vigilancetech-com/shadow-hoplon-electron#2018-10-3021:37thhellerhttps://github.com/vigilancetech-com/shadow-hoplon-electron/blob/master/package.json#L34#2018-10-3021:37thhellerwhat kind of ancient verison is that? 😛#2018-10-3022:09thheller@clashthebunny I just checked CLJS master and there were 2 changes to the analyzer/compiler that aren't currently compatible. will need to wait for a final release. can't fix them now since that would break the current 1.10.339 release#2018-10-3022:09ClashTheBunnyGreat to know. Thanks for being so on top of everything!#2018-10-3022:12thhellerseems to work fine with the fixes though. I can push the branch if you are eager to play with master but I think they are getting ready to release "soon" now#2018-10-3103:22Wilson VelezHi all, I’m having a problem, I’m seeing this message in the chrome console#2018-10-3103:23Wilson Velez
browser.cljs:325 Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
    at shadow$cljs$devtools$client$browser$heartbeat_BANG_ ()
#2018-10-3103:23Wilson Velezand my app is not reloading, any clues?#2018-10-3103:23Wilson Velezthank you#2018-10-3106:39cmalHi, @thheller I got a NullPointerException when shadow-cljs release qiniu compiling a node-library:
:qiniu {:target :node-library
          :output-to        "out/node-library/qiniu.js"
          :exports          {:list qiniu.core/list-prefix
                             :del qiniu.core/delete-key
                             :clear qiniu.core/delete-keys}}
[:qiniu] Compiling ...
NullPointerException:
	clojure.lang.Numbers.ops (Numbers.java:1018)
	clojure.lang.Numbers.dec (Numbers.java:120)
	shadow.build.warnings/get-source-excerpts/make-source-excerpt--10702 (warnings.clj:27)
	shadow.build.warnings/get-source-excerpts/iter--10704--10708/fn--10709/fn--10710 (warnings.clj:44)
	shadow.build.warnings/get-source-excerpts/iter--10704--10708/fn--10709 (warnings.clj:43)
	clojure.lang.LazySeq.sval (LazySeq.java:40)
	clojure.lang.LazySeq.seq (LazySeq.java:49)
	clojure.lang.RT.seq (RT.java:528)
	clojure.core/seq--5124 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--7835 (protocols.clj:75)
	clojure.core.protocols/fn--7835 (protocols.clj:75)
	clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
	clojure.core/reduce (core.clj:6748)
	clojure.core/into (core.clj:6815)
	clojure.core/into (core.clj:6807)
	shadow.build.warnings/get-source-excerpts (warnings.clj:45)
	shadow.build.warnings/get-source-excerpts (warnings.clj:9)
	shadow.build.warnings/get-source-excerpts-for-rc (warnings.clj:51)
	shadow.build.warnings/get-source-excerpts-for-rc (warnings.clj:47)
	shadow.build/enhance-warnings (build.clj:34)
	shadow.build/enhance-warnings (build.clj:21)
	shadow.build/extract-build-info/fn--12724 (build.clj:92)
	clojure.core/map/fn--5587 (core.clj:2745)
	clojure.lang.LazySeq.sval (LazySeq.java:40)
	clojure.lang.LazySeq.seq (LazySeq.java:49)
	clojure.lang.RT.seq (RT.java:528)
	clojure.core/seq--5124 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--7835 (protocols.clj:75)
	clojure.core.protocols/fn--7835 (protocols.clj:75)
	clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
	clojure.core/reduce (core.clj:6748)
	clojure.core/into (core.clj:6815)
	clojure.core/into (core.clj:6807)
	shadow.build/extract-build-info (build.clj:94)
	shadow.build/extract-build-info (build.clj:64)
	shadow.build/update-build-info-after-compile (build.clj:102)
	shadow.build/update-build-info-after-compile (build.clj:100)
	shadow.build/compile (build.clj:354)
	shadow.build/compile (build.clj:344)
	shadow.cljs.devtools.api/release* (api.clj:306)
	shadow.cljs.devtools.api/release* (api.clj:293)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
	shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
	shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
	shadow.cljs.devtools.cli/main/body-fn--15607--auto----16461 (cli.clj:168)
	shadow.cljs.devtools.cli/main (cli.clj:167)
	shadow.cljs.devtools.cli/main (cli.clj:134)
	clojure.core/apply (core.clj:661)
	clojure.core/apply (core.clj:652)
	shadow.cljs.devtools.cli/-main (cli.clj:221)
	shadow.cljs.devtools.cli/-main (cli.clj:219)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.core/apply (core.clj:657)
	clojure.main/main-opt (main.clj:317)
	clojure.main/main-opt (main.clj:313)
	clojure.main/main (main.clj:424)
	clojure.main/main (main.clj:387)
	clojure.lang.Var.applyTo (Var.java:702)
	clojure.main.main (main.java:37)
#2018-10-3106:39cmalshadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn cli version: 2.6.21 node: v8.9.4#2018-10-3108:54cmalthe into [] of extract-build-info of build.clj.#2018-10-3109:34thheller@cmal hmm that is odd. it appears you have a warning in your code with an invalid source location. there was a similar problem with some macro generated code ages ago but that was fixed.#2018-10-3109:35thheller@wvelezva hmm is the websocket connection getting blocked somehow? can you check the state of the websocket connection in the browser devtools?#2018-10-3115:57Wilson VelezThe devtools only show pending#2018-10-3115:58Wilson Velez#2018-10-3115:58Wilson Velez#2018-10-3117:40thhellerthat is odd. is your local firewall maybe blocking the connection or so?#2018-10-3119:19Wilson Velezno, it isn’t#2018-10-3119:19Wilson Velezit is working on firefox and in a incognito mode chrome#2018-10-3119:20Wilson Velezit is something related with my current chrome status#2018-10-3119:20Wilson Velezthanks!#2018-10-3119:20Wilson VelezI can work with an incognito window#2018-10-3109:42thheller@cmal I just published 2.6.22 which catches those exceptions since they are not critical. would help if you could paste the remaining warnings so that I can maybe figure out why it would fail to extract the source excerpt.#2018-10-3113:48Logan PowellIs there a way to load remote resources into a cljs project using shadow? I'm working on publishing an NPM library that has a couple of configuration files I'd like to keep out of the library and load when the user uses the library, so they don't have to update the library every time the config gets updated...#2018-10-3114:28Logan PowellIt's cool if I can't, I can just add some core.async to work it in... just curious#2018-10-3115:08thheller@loganpowell not sure what you are asking. if your library needs to load other files that aren't part of your compilation then shadow-cljs cannot help no#2018-10-3115:09Logan PowellThank you sir. I figured I'd ask 😉#2018-10-3115:10Logan PowellI'm just trying to figure out how to best load a config without having to request it over the wire every time a user of the NPM library I'm publishing calls a function that needs it#2018-10-3115:11Logan PowellIt may just be the price I have to pay for separating out the remote config#2018-10-3115:11thhellerif its part of the library you can just js/require it#2018-10-3115:11thhellerif its remote you need to request it by other means#2018-10-3115:11Logan PowellIt's remote#2018-10-3115:11Logan PowellI have it working with an internal core.async fetch#2018-10-3115:12Logan Powellcurrently#2018-10-3115:12Logan Powellbut it will be requested on every function call it pertains to#2018-10-3115:12Logan PowellI was trying to figure out a way to load it just once#2018-10-3115:14Logan Powelldon't worry about it. It will work for an MVP. Do you ever sleep?! 😄#2018-10-3115:20thhellernot usually at 16:20 😉#2018-10-3115:21Logan Powellhaha#2018-10-3115:22Logan PowellI keep forgetting you're in Germany#2018-11-0100:23Wilson Velez#2018-11-0100:24Wilson VelezI’ve configured shadow to run with lein#2018-11-0100:25Wilson VelezI’m trying to release the code but I’m getting the error above.#2018-11-0103:10cmal@thheller OK, thanks. I'll try that.#2018-11-0105:37cmalIt works all right now.#2018-11-0105:53thheller@wvelezva that error happens when using an invalid closure compiler version#2018-11-0105:53thhellermake sure its [com.google.javascript/closure-compiler-unshaded "v20180910"] or later#2018-11-0106:17lassemaattasince everyone else seems to be pasting their exceptions, I might as well participate too 🙂#2018-11-0106:17lassemaattasometimes during compilation we get this:#2018-11-0106:17lassemaatta#2018-11-0106:19thhellerstrange. shadow-cljs isn't even on the stack. not much I can do about that#2018-11-0106:19lassemaattayeah, I guess it has something to do with that hawk library.#2018-11-0106:20thhelleryeah thats the file watcher on OSX#2018-11-0106:20thhellerother platforms don't use that but the others are too slow on OSX#2018-11-0106:21lassemaattais that watcher activated dynamically based on the platform or should it be always there? I'm asking because I'm running linux 🙂#2018-11-0106:21thhelleroh right. remembered wrong. only windows uses the default JDK watcher#2018-11-0106:24thhellerbut hawk also switches again and uses the JDK one for linux#2018-11-0106:25lassemaattaokay, thanks for the info :+1: I think I'll report this to the hawk project, let them sort it out. in any case, the error doesn't seem to cause any issues, most likely it just fails to watch one or more files#2018-11-0106:25thhellerhawk is more or less dead I think#2018-11-0106:25thhellerno updates for years#2018-11-0106:26thhellerproblem is OSX since the JDK watcher is so slow. otherwise I wouldn't use it at all#2018-11-0106:27thhellerbut for linux I can probably filter it out and directly use the JDK one#2018-11-0106:27thhelleryeah let me do that#2018-11-0106:27lassemaattawow, thanks 🙂#2018-11-0106:30thheller@lasse.maatta try 2.6.23. error might still happen but now I should be able to fix it if it does.#2018-11-0114:28Wilson Velezthanks @thheller, I didn’t know I had to add the closure compiler myself#2018-11-0114:30Wilson Velezanyone know if I can have a specific name for my release file?#2018-11-0115:02Wilson Velezright now I’m using a hook to the :flush stage to execute a “cp <outputfile> <releasefile>”#2018-11-0115:03tony.kay@wvelezva you know about the file name hashing support, right?#2018-11-0115:04Wilson Velez👀#2018-11-0115:04Wilson Velezno, sorry#2018-11-0115:04tony.kayhttps://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing#2018-11-0115:04tony.kayif you’re renaming the file to avoid cache issues, you probably want that instead#2018-11-0115:04tony.kayotherwise I think it’s just the build name#2018-11-0115:05tony.kayI think you might be able to use a filename in :output-to, but I have not tried#2018-11-0115:06tony.kaythat might just be for node#2018-11-0115:07Wilson Velezyes the :output-to it is only for node#2018-11-0115:07tony.kayrather..module name, is what I meant#2018-11-0115:08tony.kayyeah, module name…so using a diff kw as the module name will cause a diff name for the file#2018-11-0115:09Wilson VelezI got it, I just need two builds sections, one for my dev with the paths for dev#2018-11-0115:09Wilson Velezand a new one for my release#2018-11-0115:09tony.kayI don’t think that’s a great idea#2018-11-0115:09tony.kaywhy do you care about the filename?#2018-11-0115:09tony.kaywhen you run the release you get an optimized file#2018-11-0115:10tony.kayand code splitting is going to rely on those names, so…I think perhaps you’re asking for future trouble#2018-11-0115:12tony.kayI have not tried it, but you could perhaps set different output directories with https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-11-0115:13tony.kayif you’re worried about “accidents” or something in deployment#2018-11-0115:13Wilson Velezit’s because we are used to use a name during development and then when the js file is complete we compilete it in the right production folder#2018-11-0115:14Wilson VelezI also test that and it “works”, but it is the same name for dev and prod#2018-11-0115:14Wilson Velezit is not really a problem#2018-11-0115:14Wilson VelezIt’s just an old habit#2018-11-0115:14Wilson Velez😄#2018-11-0115:15tony.kayyeah, figured.#2018-11-0115:15Wilson Velezbut I’m going to use it, it’s really simple that way#2018-11-0115:16Wilson Velezthanks @tony.kay#2018-11-0119:24manandearthHi there, Can someone refer me to an example of a shadow-cljs project with both cljs and clj files in order for me to understand how data can be required from one to the other? I basically want some to use some Clojure libraries in the back and serve the data in the cljs front.#2018-11-0120:48thheller@adamgefen not sure I understand the question. shadow-cljs generally focuses only on CLJS development and I recommend using lein for CLJ. as far as sharing sources is concerned you just point both at the same :source-paths and use the code as normal#2018-11-0120:58manandearth@thheller so if I use some Java scraping library to grab xml to a clojure data structure, I should write it as edn to :source path and slurp it back in my cljs file?#2018-11-0120:59thhellerno you probably want to create a HTTP server in CLJ for that and let the CLJS app talk to that#2018-11-0121:01thheller(assuming you are building something for the browser)#2018-11-0121:02manandearthOk. I'll look into that.#2018-11-0121:02thhellerif you want something full stack I'd suggest looking at #fulcro#2018-11-0121:03manandearthI want it for the browser but I did think that it will be useful to keep some logic in the back in order to be able to expand.#2018-11-0121:07grav@adamgefen If you want the browser to convert xml into edn, you could go with an npm package such as https://www.npmjs.com/package/xml2js and then transform it to edn with js->clj.#2018-11-0121:13manandearththanks @grav, I'll have a look.#2018-11-0122:01vigilancetech@thheller yeah, that was pretty old. Came in from here (what I started with to build the example): https://github.com/shadow-cljs/examples/blob/master/electron/package.json#2018-11-0207:27vehashi, guy, thanks for the fantastic tool,where is the location that I can set binaryaga/devtool confighttps://github.com/binaryage/cljs-devtools/blob/master/docs/configuration.md#configuration-via-compiler-optionsfor project.clj they use :external-config { :devtools/config { :features-to-install [:formatters :hints] :fn-symbol "F" :print-config-overrides true}}#2018-11-0207:46thheller@vehas :compiler-options {:external-config {:devtools/config ...}}} should do it#2018-11-0208:45vehas@thheller thanks, it's work. should put it somewhere in doc, I try to search for : external-config and can not get any explanation#2018-11-0209:38thhellerwell its not a thing in CLJS itself. it was basically invented by cljs-devtools I think#2018-11-0213:13hlolliwas there any lein ancient-ish plugin for shadow-cljs for deps?#2018-11-0213:34ClashTheBunnyYou can use yarn update-interactive to update your javascript dependencies.#2018-11-0213:35ClashTheBunnyYou can also use depot with deps.edn or lein-ancient with project.clj, depending on how you encode your dependencies.#2018-11-0213:35ClashTheBunnyBut I think we're all waiting for you to make it for shadow! 🙂#2018-11-0213:39hlolliI use ncu all the time for package.json, the clojure deps tend to update way slower than npm 🙂 well, I could do it, at minimum I hope I planted seeds 😛#2018-11-0213:45hlollibetter solution if this wasn't a plugin but a part of shadow-cljs itself#2018-11-0214:13thhellerthere is nothing like that available for shadow-cljs currently no#2018-11-0217:15lsnapeHi, I have a shadow flush build hook that generates static html and css files and writes them to a public directory. I would like the Clojure functions that render the static files to be reloaded on file change, so that implementation changes are picked up and I see the updated html/css on my page. Is there a convenient way to do this in shadow?#2018-11-0217:31lsnapePresumably I can do this using the reloaded workflow within clj-run, and calling watch and server within this task? Maybe there's another way?#2018-11-0217:54tony.kay@thheller I’m getting a strange error that I don’t understand related to macro output. I’ve expanded the macro and when I put that in the file it is fine, but when I use the macro I get an exception in core, but the stack trace doesn’t get me anywhere.
IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
        clojure.lang.RT.seqFrom (RT.java:550)
        clojure.lang.RT.seq (RT.java:530)
        clojure.core/seq--5124 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--7829 (protocols.clj:75)
        clojure.core.protocols/fn--7829 (protocols.clj:75)
        clojure.core.protocols/fn--7781/G--7776--7794 (protocols.clj:13)
        clojure.core/reduce (core.clj:6748)
#2018-11-0218:04tony.kayany hints on how I can get more info from the compiler about what it is working on/seeing?#2018-11-0218:09lilactown🤔 this looks like an error at macro-time#2018-11-0218:10lilactownI’ve had better luck getting meaningful errors by evaluating the namespace the macro lives in in a CLJ REPL, then I have relying on shadow-cljs to report the correct error#2018-11-0218:55tony.kayit macro expands perfectly in clj#2018-11-0218:57tony.kayhttps://github.com/fulcrologic/fulcro-incubator/blob/feature/extend-defsc/src/main/fulcro/incubator/defsc_extensions.clj#L128#2018-11-0219:22tony.kaythe lastest shadow-cljs shows a more complete stack trace, and that pointed out where the problem was#2018-11-0219:29tony.kayBizzarre…I found the problem, but I honestly don’t understand it#2018-11-0219:32tony.kaybut I don’t believe it is a shadow problem…the bigger stack trace has gotten me unstuck#2018-11-0219:36lilactownwhat is the issue?#2018-11-0219:44tony.kayI found it…my macro was emitting a cons, and the other macro was spec checking it to be a list?#2018-11-0219:45tony.kaynever would have found that without a better stack trace…#2018-11-0220:54thheller@tony.kay yeah shortening stacktraces has been a mistake throughout#2018-11-0220:56thheller@lsnape there is no built-in support for reloading non build-related CLJ code. I typically recommend developing that in a REPL and just using the usual load-file from the REPL to reload the code manually#2018-11-0223:27souenzzoI want to configure 2 cljs builds: one with dev and src, with "base" deps + "devcards" dep one just with src, with "base" deps. How can I write it in shadow-cljs.edn?#2018-11-0223:37lilactown@souenzzo you can only have one set of source-paths#2018-11-0223:39souenzzoCan/should I create many shadow-cljs.edn files?#2018-11-0223:39lilactownthe way you would do it is in the module you create for your dev build, you'll require the base and devcards namespaces#2018-11-0223:39lilactownin the entrypoint of the module for just the app, you'll require just the base#2018-11-0223:40lilactownwhen you compile the code for a given build, shadow-cljs only includes the code that you refer to via :require in your namespaces#2018-11-0300:18souenzzoI'm using shadow in "npm" mode. I'm trying to use devcards for both reagent and "raw" react components#2018-11-0308:04thheller@souenzzo it is intended that you use all your source-paths all the time. a build only includes whatever is required. https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2018-11-0308:04thhellernamespaces already provide enough separation. no need to do it at the source-path level#2018-11-0319:18mhueberthmm, I am working on bringing maria.cloud up to the latest shadow-cljs version (it was on 2.2.x). I found that something changed in 2.3.9 which causes ReferenceError: goog is not defined errors when loading cljs.core macros (`/js/compiled/bootstrap/js/e9a22ddf.cljs.core$macros.js`), the stacktrace points to the first line, goog.provide('cljs.core$macros');. Not a lot changed between 2.3.8 and 2.3.9, https://github.com/thheller/shadow-cljs/compare/2.3.8...2.3.9#2018-11-0320:14mhueberthmm, it doesn’t look like the code in the 2.3.8 jar matches the code with the 2.3.8 tag on github#2018-11-0320:18mhuebertso i think at least the changes from 2.3.7 (on github) also are included in the cause#2018-11-0320:46thheller@mhuebert the :output-wrapper default changed so that may be causing the issues#2018-11-0320:47thhellertry setting :compiler-options {:output-wrapper false}#2018-11-0320:47mhuebertI did try that — unfortunately didn’t help#2018-11-0320:48thhellerand you are still using :simple for the host build?#2018-11-0320:48mhuebertyes#2018-11-0320:48thhellerdid you set the output-wrapper for the host build?#2018-11-0320:49thhellerit will have no effect on the bootstrap build#2018-11-0320:49thhellergoog is not defined is probably cause by the output-wrapper#2018-11-0320:49thhellersince that prevents creating global variables which the bootstrap stuff relies on#2018-11-0320:50mhuebertk let me try that again#2018-11-0320:52mhuebertso does the output-wrapper stuff mean that there wouldn’t ever be name collisions from advanced builds with other random global variables?#2018-11-0320:52thhelleryes#2018-11-0320:52thhellerwell not "ever" but they are certainly reduced by a bunch#2018-11-0320:53thhellerits basically just a function wrapped arround the code so it has its own scope instead of global#2018-11-0320:54mhuebertin my last project i had these super weird bugs from advanced builds accidentally “discovering” other short global names from old js libraries that i was also using. i ended up generating a list of externs from all the objects defined on “window”#2018-11-0320:54thhelleryeah it should prevent that kind of issues#2018-11-0320:55mhuebertok, so this is good news. I clearly did not put :output-wrapper stuff in the right place before. can successfully compile maria with latest version of shadow#2018-11-0515:48teawaterwirehi, I'm having troubles understanding the meaning of "cljsjs packages are not supported" (https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs) — for instance, to use re-frame-10x, as it is mentioned here (https://github.com/Day8/re-frame-10x/blob/master/docs/Advanced-Setup.md#using-shadow-cljs) I just need to npm install some packages, but I will have some global variables exported (ie js/FlipMove), which means that somehow these lines are still taken into account? https://github.com/cljsjs/packages/blob/ade50f320730c9f144382a519414e09c8ba73fe5/react-flip-move/build.boot#L33-L36#2018-11-0515:48teawaterwirehi, I'm having troubles understanding the meaning of "cljsjs packages are not supported" (https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs) — for instance, to use re-frame-10x, as it is mentioned here (https://github.com/Day8/re-frame-10x/blob/master/docs/Advanced-Setup.md#using-shadow-cljs) I just need to npm install some packages, but I will have some global variables exported (ie js/FlipMove), which means that somehow these lines are still taken into account? https://github.com/cljsjs/packages/blob/ade50f320730c9f144382a519414e09c8ba73fe5/react-flip-move/build.boot#L33-L36#2018-11-0515:59teawaterwire(`/cdn-cgi/l/email-protection`)#2018-11-0516:52wilkerlucio@U5UCAE37Z its not, the reason it works is because of shadow-cljsjs#2018-11-0516:52wilkerluciohttps://github.com/thheller/shadow-cljsjs#2018-11-0516:52wilkerluciothis contains some pre-packaged ways to load things to look like they come from cljsjs, but they dont#2018-11-0516:52wilkerlucioif the library you want to use is not there, you will need to export the symbols yourself#2018-11-0517:14teawaterwireoh I see it is already in the package shadow-cljsjs ? because I thought I had to add it manually, but ok that would make sense... Thanks!! I was confused 🙂#2018-11-0517:16wilkerluciono worries, the shadow-cljsjs comes built-in with shadow, so new stuff might need new versions, but its usually updated#2018-11-0517:41teawaterwireshadow never ceases to amaze me!#2018-11-0516:44kanweiupgraded to Clojurescript 1.10.439 and now getting compile errors: https://gist.github.com/kanwei/6d7e68bb26074b1c6a7e5036c3bc157f#2018-11-0516:45kanweiwent back to 1.10.339 and it builds again#2018-11-0517:12kanweithere also seems to be a caching issue: i use inferno-compat instead of react, and upgraded all the dependencies in package.json, and ran npm-install. running shadow-cljs only upgraded inferno-compat, and doing console.log(inferno) still showed old version. i removed the entire .shadow-cljs folder and it built with the updated inferno.#2018-11-0518:48ClashTheBunnyI already mentioned that issue and there is a solution on master, I believe.#2018-11-0518:52hlolliout of curiosity, what does this warning mean
63 |                        (when (exists? event.target.files)
------------------------------------^-------------------------------------------
 js/event is shadowed by a local
#2018-11-0519:42thheller@hlolli (let [event ...] ...)? exists? assumes to only check global variables#2018-11-0610:49hlolliah, I took it for typef x.y.z !=== 'undefined' but it's trivial to do this logic differently... (or not do it at all since it should always exist in input type="file") thanks!#2018-11-0519:43thheller@kanwei 1.10.439 is not currently supported. I'm hesistant to push the update to make it compatible because it has a pretty annoying externs inference regressen https://github.com/thheller/shadow-cljs/issues/401#2018-11-0519:44kanweiah ok#2018-11-0519:44kanweiany idea on the caching issue?#2018-11-0519:45kanweiit's weird that inferno-compat upgraded but inferno stayed old#2018-11-0519:45thheller@kanwei the cache issue I don't know. did you have the watch running while npm install was doing its thing?#2018-11-0519:45kanweihmmmmm#2018-11-0519:45thhellersomething it seems to confuse the watch since npm modifies so many files#2018-11-0519:45kanweican't remember, possible#2018-11-0519:45kanweibut wouldn't a fresh run check for staleness?#2018-11-0519:46kanweii definitely restarted it after install#2018-11-0519:46thhellerah ok yes that definitely rechecks#2018-11-0519:46kanweiyeah, it still had old inferno#2018-11-0519:46kanweii don't care per-se now that it works, but i figured it might happen to someone else#2018-11-0519:50thhellerjust to recap you had an old version of inferno-compat and just installed a new version over it but shadow-cljs didn't pick it up?#2018-11-0519:50thhellerthat should be easy enough to reproduce. I'll try tomorrow#2018-11-0520:09kanweii had old versions of 5 libraries:
"inferno": "^6.1.4",
    "inferno-clone-vnode": "^6.1.4",
    "inferno-compat": "^6.1.4",
    "inferno-create-class": "^6.1.4",
    "inferno-create-element": "^6.1.4",
#2018-11-0520:09kanwei(this is the updated versions)#2018-11-0520:09kanweithe old ones were 5.6.1#2018-11-0520:10kanweiwhen i upgraded today, all of them to 6.1.4, inferno-compat updated but inferno stayed at 5.6.1#2018-11-0520:10kanweii had to go into the generated code and console.log(inferno) to verify#2018-11-0520:10thhellerare you sure that node_modules/inferno-compat actually had the new version?#2018-11-0520:11kanweipretty sure, yes#2018-11-0520:11thhellermaybe it was installed nested somewhere#2018-11-0520:11kanweiwell, the app broke, so if inferno-compat stayed old, it would not have broken#2018-11-0520:11kanweiwas giving inferno.render was not found#2018-11-0520:12thhellerI assume you have some :resolve settings?#2018-11-0520:13thhellerto switch out react?#2018-11-0520:13kanwei
:js-options       {:resolve {"moment"             false
                                                             "react"              {:target :npm :require "inferno-compat"}
                                                             "react-dom"          {:target :npm :require "inferno-compat"}
                                                             "create-react-class" {:target :npm :require "inferno-reagent-compat"}
                                                             "jquery"             {:target :global
                                                                                   :global "jQuery"}}}
#2018-11-0520:42Logan Powell👋 Hi fellows, I'm trying to do some challenging js<->cljs interop with a js library that internally uses promises to call functions that the user supplies (which seem to need to be pre-compiled into javascript for it to work). I'm rummaging around the shadow docs and trying to work out how to configure some test code, compile it to js then re-include it as a require#2018-11-0520:43Logan PowellI can't seem to resolve / require the local file that I've compiled...#2018-11-0520:43Logan PowellI get this:#2018-11-0520:43Logan Powell
The required JS dependency "../../dist/test.js" is not available, it was required by "workers/core.cljs".
#2018-11-0520:45Logan PowellThis is the first time I'm actually trying to compile with shadow-cljs... I've been working solely in dev mode (@ 5-months) so far#2018-11-0606:55thheller@loganpowell I don't really understand what you are trying to do? You are trying to include the compiled library in CLJS?#2018-11-0612:38Logan PowellSo, I might be setting myself up for failure, but I have a function that can cause js vm heap overflow that I'm hoping to offload to a worker using this library (which uses promises to communicate with webworkers/child_processes): https://github.com/josdejong/workerpool with this library (which enables translation of promises to core.async compatible things): https://github.com/jamesmacaulay/cljs-promises I'm trying to test out some code I want to use inside the "pool"... maybe I should use the web workers config? https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2018-11-0614:17thhellerare you running in node? or the browser?#2018-11-0614:21thhellerewww .. do not use that library. it is only going to work for extremely basic examples since it relies on turning the function into a string#2018-11-0614:38Logan Powellhaha,#2018-11-0614:39Logan Powellis there a better library you are aware of? I'm trying to run in browser and node, but developing in node#2018-11-0614:42Logan PowellMaybe parrallel.js? https://github.com/parallel-js/parallel.js#2018-11-0618:05Logan PowellOr: https://github.com/WebReflection/workway#2018-11-0609:05thheller@loganpowell and no you can use promises directly without any kind of tricks or pre-compile/re-include tricks#2018-11-0609:48thhellerFWIW I improved the error message for the problem you are running into to make it clearer what is happening#2018-11-0609:55thhellerI just added a quickstart section to the main readme. Feedback very welcome. Not sure if I should make this a separate document or part of the user guide or blog post. https://github.com/thheller/shadow-cljs#quick-start#2018-11-0610:36mj_langford@thheller thats wonderful. I'd love to see that prominently linked off the project page#2018-11-0612:55Hannu HartikainenI was trying to reproduce a possible bug in reitit and the maintainer (@ikitommi) noted that there’s something weird about how backtick resolution works with shadow-cljs. This code https://github.com/dancek/reitit-frontend-spec-coercion-repro runs
(js/console.log `int?)
and the value is starter.browser/int? instead of the expected cljs.core/int?. Did I do something wrong or is that a bug?
#2018-11-0614:18thhellerhmm strange. looking into it#2018-11-0613:46flowthingI tried adding an entry for cljsjs.js-joda in shadow-cljsjs, but the build fails with an NPE like this https://gist.github.com/eerohele/3983e27b07eb2e029936e2af2f937e62 Am I doing something wrong or should I file an issue?#2018-11-0613:58flowthingActually, scratch that. I was barking up the wrong tree. It's actually this issue: https://github.com/thheller/shadow-cljs/issues/401#2018-11-0614:54thheller@hannu.hartikainen just pushed 2.6.24 which fixes the incorrect int? resolve. thanks for the report.#2018-11-0614:54Hannu Hartikainengreat! now back to my original repro 🙂#2018-11-0617:28Logan PowellWhat's the difference between an explicitly configured :npm-module (with :entries) and the :node-library target?#2018-11-0618:10thheller@loganpowell the way it is packaged. :node-library has one thing JS can require while :npm-module has one per NS#2018-11-0618:11Logan Powell@thheller thank you sir#2018-11-0618:12Logan Powellshould I still :output-dir to node_modules when using :node-library if I'm looking for smooth JS ecosystem interop?#2018-11-0618:13thhellerI still don't know what you are trying to do exactly#2018-11-0618:13thhellerespecially what "smooth JS ecosystem interop" means to you#2018-11-0618:13thhellerdoes that mean you publishing a library to npm that JS can use?#2018-11-0618:15thhellerif you are building something that you are going to consume from CLJS then do not use either#2018-11-0618:25Logan Powell"publishing a library to npm that JS can use": exactly#2018-11-0618:26thhellerthen I recommend :node-library#2018-11-0618:27thhellerunless you really need more complex stuff that :node-library can't do (eg. multiple require entries)#2018-11-0618:28Logan Powellgotcha#2018-11-0621:18thhellerjust pushed https://github.com/thheller/shadow-cljs/releases/tag/2.7.0 for those eager to play with the new CLJS release#2018-11-0621:18thhellerdon't expect too much from the promised performance gains ... most of them were already in shadow-cljs for a while#2018-11-0621:20thhellersymbols with . in them are now checked more strictly and may produce warnings when used improperly#2018-11-0621:20thhellerprevious versions accepted ANY symbol with a . without validation (eg. i.dont.exist) would not warn at compile time and only fail at runtime#2018-11-0621:45richiardiandreacool thanks Thomas, I will bump and report 😄#2018-11-0701:57currentoorthe server mode of shadow-cljs is freakin awesome!#2018-11-0701:57currentoorthanks @thheller!#2018-11-0717:24Logan Powell😞#2018-11-0718:45thheller?#2018-11-0719:42Logan PowellI suck at this#2018-11-0719:43Logan PowellI think upgrading to JDK 192 broke something, then I said fuck it and tried to replace it with AdoptOpenJDK now everything is broken#2018-11-0719:43Logan PowellI'm no good at ops#2018-11-0719:43Logan Powellwell, I'm basically no good at any of this 😄#2018-11-0719:46Logan Powell#2018-11-0719:47Logan Powellis there a recommended alternative to Oracle for Clojureists?#2018-11-0721:06vigilancetech@loganpowell you might try: https://en.wikipedia.org/wiki/OpenJDK#2018-11-0721:08Logan PowellThank you @vigilancetech but there are a few distributions of OpenJDK and the only one that seems to be popular/documented is Oracle's#2018-11-0721:08Logan Powellis there another distribution of OpenJDK not from Oracle that people use?#2018-11-0721:09vigilancetechhttps://en.wikipedia.org/wiki/List_of_Java_virtual_machines#2018-11-0721:13vigilancetechI have a gentoo based distro (e.g. a lot of packages) and those are the only two showing. If it was at all popular chances are someone would have packaged it up there#2018-11-0721:14vigilancetechcan you downgrade?#2018-11-0721:39Logan PowellSorry, restarted my computer 😞#2018-11-0721:39Logan Powelltrying to figure this out#2018-11-0721:40vigilancetechwhat OS are you using? Maybe you can just uninstall/reinstall the packages?#2018-11-0721:41Logan PowellWindows#2018-11-0721:41Logan Powell10#2018-11-0722:40Logan PowellWelp, I've broken it for sure... I have literally uninstalled everything (Java/Zulu/AdoptOpenJDK/Shadow/etc.) and reinstalled it and am still getting the error above 😞#2018-11-0722:51vigilancetechNow I'm coming from a linux background so YMMV but you can try renaming your ~/.shadow-cljs directory and your ~/.m2/repository directory and create a new project directory and go in there and do shadow-cljs init then see if you can put something in there to work. (`~` here is my home directory. Not sure how that is designated under windows).#2018-11-0722:54Logan PowellLet me give that a go... could it be a cached issue?#2018-11-0722:54vigilancetechit would seem like it to me#2018-11-0722:55vigilancetechI'm kind of a noob to shadow too, but I've recently ported a slightly complex project#2018-11-0722:56vigilancetechthe example that I'm most familiar with (and I know works as of pretty recently) is: https://github.com/shadow-cljs/examples/tree/master/electron#2018-11-0722:57vigilancetechyou could just clone that rather than creating the new project folder as I suggested above#2018-11-0722:57Logan Powelllet me give that a go#2018-11-0807:06thheller@loganpowell you missed the upgrade message I guess. shadow-cljs 2.7.0 REQUIRES CLJS 1.10.439#2018-11-0807:06thhellerI guess you are using lein or deps.edn and did not do that upgrade?#2018-11-0807:07thhellerit has nothing to do with the JDK. I'm using openjdk myself#2018-11-0807:07thhellerhttps://github.com/thheller/shadow-cljs/releases/tag/2.7.0#2018-11-0807:48thhellernevermind .. its actually a bug in the REPL code#2018-11-0808:08thhellershould be fixed in 2.7.2#2018-11-0809:49nbdam2.7.2 repl works for me..#2018-11-0810:26Logan Powell@thheller thank you. I was going crazy.#2018-11-0810:44achikin@thheller btw. When I'm using reagent with npm React with shadow-cljs do I need to exclude cljsjs/react from reagent dependency and add empty cljsjs/react ns definitions to the project or it is taken care of automatically?#2018-11-0810:45thhellerits taken care of automatically. cljsjs is just ignored and won't be used so besides the extra download it doesn't hurt#2018-11-0810:45thhellerno need to exclude#2018-11-0810:45thhelleronly manual thing you need to do currently is npm install react react-dom create-react-class#2018-11-0810:46thhellersince reagent currently does not declare those dependencies properly#2018-11-0810:46achikin@thheller and no need for externs also?#2018-11-0810:47thhellershould be fine without yes. turning on externs inference just in case helps though https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2018-11-0810:48thhellerreagent/re-frame all build fine without though#2018-11-0812:30Logan Powell@thheller do you have a patreon?#2018-11-0812:31Logan PowellI would like to support your work#2018-11-0812:32thhellercurrently not no. I started the setup but never finished it.
#2018-11-0812:33Logan PowellPlease do, I think others might be happy to help you help them#2018-11-0812:37thhellerwill do soon#2018-11-0812:38nhaYou may be interested in giving to clojurists together: https://www.clojuriststogether.org/news/q3-2018-funding-announcement/#2018-11-0812:38Logan PowellI will do that, but I also want to support your work directly#2018-11-0813:04wilkerlucio@thheller hello, I did the upgrade here, I noticed now we are back on logging the warnings every time for third part libraries (before they usually only happened in first compile if I remember right), was this change intended?#2018-11-0813:05thhellerno intended change there no?#2018-11-0813:06thhellerbut you may be getting new warnings that weren't there before due to the stricter checks regarding symbols with dots#2018-11-0813:08pepeI actually started to get warning on every compile with specter. And pretty weird ones:
------ WARNING #1 --------------------------------------------------------------
 File: com/rpl/specter.cljc:1275:19
--------------------------------------------------------------------------------
1272 |           ns (namespace structure)]
1273 |       (cond (keyword? structure) (keyword ns new-name)
1274 |             (symbol? structure) (symbol ns new-name)
1275 |             :else (i/throw-illegal "NAME can only be used on symbols or keywords - " structure)
-------------------------^------------------------------------------------------
 Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
1276 |             ))))
1277 | 
1278 | (defnav ^{:doc "Navigates to the namespace portion of the keyword or symbol"}
1279 |   NAMESPACE
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/rpl/specter.cljc:1288:19
--------------------------------------------------------------------------------
1285 |           new-ns (next-fn (namespace structure))]
1286 |       (cond (keyword? structure) (keyword new-ns name)
1287 |             (symbol? structure) (symbol new-ns name)
1288 |             :else (i/throw-illegal "NAMESPACE can only be used on symbols or keywords - " structure)
-------------------------^------------------------------------------------------
 Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
1289 |             ))))
1290 | 
1291 | (defdynamicnav
1292 |   ^{:doc "Adds the result of running select with the given path on the
--------------------------------------------------------------------------------
#2018-11-0813:08pepeAs there is no java ns#2018-11-0813:09thhellerinteresting. I'll check#2018-11-0813:10pepeI actually do not think it is shadows fault. But too low knowledge here#2018-11-0813:11wilkerlucioyeah, I think the initial warning is ok, but I remember we this discussion before about then showing up after the first compile#2018-11-0813:11thhelleryeah that behavior should not have changed#2018-11-0813:15thheller@pepe its a problem in specter that just wasn't "detected" previously#2018-11-0813:15thheller
com.rpl.specter.NAME_transform_STAR_ = (function com$rpl$specter$NAME_transform_STAR_(structure,next_fn){
var new_name = (function (){var G__36732 = cljs.core.name(structure);
return (next_fn.cljs$core$IFn$_invoke$arity$1 ? next_fn.cljs$core$IFn$_invoke$arity$1(G__36732) : next_fn.call(null,G__36732));
})();
var ns = cljs.core.namespace(structure);
if((structure instanceof cljs.core.Keyword)){
return cljs.core.keyword.cljs$core$IFn$_invoke$arity$2(ns,new_name);
} else {
if((structure instanceof cljs.core.Symbol)){
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2(ns,new_name);
} else {
throw (new java.lang.IllegalArgumentException(com.rpl.specter.impl.smart_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["NAME can only be used on symbols or keywords - ",structure], 0))));

}
}
});
#2018-11-0813:16thhellergotta find the code that is actually responsible for generating this#2018-11-0813:16thhellerbut throw (new java.lang.IllegalArgumentException... is certainly not valid JS 😉#2018-11-0813:18thheller
#?(
   :clj
   (defmacro throw-illegal [& args]
     `(throw* IllegalArgumentException 
#2018-11-0813:18thhelleryeah thats not gonna work 😛#2018-11-0813:25Logan PowellI can confirm that I have been some "new" errors from third-party libraries (Specter included)#2018-11-0813:26thhellerexamples? I might need to remove the new checks if its gets too much#2018-11-0813:26Logan Powellsec#2018-11-0813:28Logan Powell#2018-11-0813:30Logan PowellBut I'd rather know now that this won't work in javascript then trying to debug after release 😄#2018-11-0813:30thhelleruhm what is defun?#2018-11-0813:31Logan Powell(defun ... is a third-party library#2018-11-0813:31thhellerwhy is your code full of stuff leading with a .? .defun .deploy_cencus_function#2018-11-0813:31Logan Powellhttps://github.com/killme2008/defun#2018-11-0813:31thhellerthats not normal#2018-11-0813:32Logan PowellI barely ever use the . notation#2018-11-0813:32Logan Powellunless I'm interop'ing with js#2018-11-0813:32thhellerthat would not emit that either#2018-11-0813:32thhellerI think something else is broken in that macro#2018-11-0813:32pepebut when I look into specter/impl.cljc where the macro is defined, there is cljs version too:
#?(
   :clj
   (defmacro throw-illegal [& args]
     `(throw* IllegalArgumentException 
#2018-11-0813:32thheller@pepe https://github.com/nathanmarz/specter/issues/267#2018-11-0813:33thhelleryeah its confusing because of the self-conflict it has#2018-11-0813:33thhellermacro comes before fn so the CLJS version is never used#2018-11-0813:33pepeOk. I thank you sir!#2018-11-0813:34pepeyeah from the Issue I can understand it#2018-11-0813:38Logan PowellThat might be the issue with defun as well. It's a macro over the core.match macro 😄#2018-11-0813:38thhellerno, thats different. not the same name#2018-11-0813:39Logan Powellis it something I'm doing wrong?#2018-11-0813:39Logan Powellbtw, I can also confirm that - besides the new error - it looks like AdoptOpenJDK is now working 😉#2018-11-0813:40Logan Powellbye bye Larry Ellison#2018-11-0813:41Logan PowellDon't know if it will help, but here's the log from my repl#2018-11-0813:41Logan Powell#2018-11-0813:41thheller
23 | (defun.core/defun deploy-census-function
-------^------------------------------------------------------------------------
IllegalArgumentException: Invalid signature "..." should be a list
	clojure.core/assert-valid-fdecl/fn--8348 (core.clj:7405)
	clojure.core/map/fn--5587 (core.clj:2747)
	clojure.lang.LazySeq.sval (LazySeq.java:40)
	clojure.lang.LazySeq.seq (LazySeq.java:49)
#2018-11-0813:42Logan Powellsorry, I truncated the code#2018-11-0813:42Logan Powellsec#2018-11-0813:42thheller@loganpowell in the output above I can't see what you did#2018-11-0813:42thhellerI assume you sent something via nrepl?#2018-11-0813:43Logan PowellCursive (IDEA)#2018-11-0813:43Logan Powellnrepl (remote)#2018-11-0813:43thhelleryeah. I'mm gonna need what you sent 😛#2018-11-0813:43thhellerbut yeah I can't get defun to work at all#2018-11-0813:43Logan PowellJust the args?#2018-11-0813:44thhellerwhat did you send before that?#2018-11-0813:44thhellermust have done a require or so#2018-11-0813:44Logan Powell#2018-11-0813:46Logan Powellwait, now it's not throwing the error#2018-11-0813:47Logan Powelllet me track this down a bit more#2018-11-0813:47Logan Powellcould be me making a stupid mistake#2018-11-0813:48thhellerok the problem is that the error ends up in the wrong place#2018-11-0813:48thhellershould be output to the REPL but ends up in the server console#2018-11-0813:48thhellerI can fix that part but defun still doesn't like the code#2018-11-0813:49Logan Powelllet me work on it#2018-11-0813:50thhellerit is odd that you get such weird code output#2018-11-0813:50thhellerfor me it just doesn't output anything and fails completely#2018-11-0813:52thhellerhttps://github.com/thheller/shadow-cljs/issues/402#2018-11-0813:53Logan Powelldon't worry about it... It probably has something to do with all the reorganization of the code I did to get namespaces looking like https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath#2018-11-0813:53Logan Powellhaha#2018-11-0813:54Logan Powellintellij freaked out#2018-11-0813:54thhellerhehe#2018-11-0814:05Logan PowellPlease let us know when you have the Patreon setup.#2018-11-0814:18Logan PowellIn the meantime, just wanted to say that I believe the work you're doing is really important for the future of ClojureScript#2018-11-0814:19Logan PowellThe existing tooling is - by far - the biggest barrier for newbs#2018-11-0814:21Logan PowellI think you should rename it to "lumin" instead of "shadow" 😄#2018-11-0814:21thhellernaming is hard and renaming everything is too much work 😉#2018-11-0814:21Logan Powellit's a joke#2018-11-0814:22Logan Powellit's just so much "easier" than anything else...#2018-11-0814:22Logan Powell"bringing cljs into the light"#2018-11-0814:23Logan Powellanyway, enough gushing... I'll be bach#2018-11-0815:19hlolliNot sure if I can Händel it.#2018-11-0816:47manandearthI am looking for a dataviz library to use with clojurescript. My background is not Javascript so importing and using d3 seems complicated from cljs . The most promising library for my purpose is hanami https://github.com/jsa-aerial/hanami/blob/master/src/cljs/aerial/hanami/core.cljs . Yet loading the ns raises the following error: >conflict on "h-box" by "re-com.box" used by "re-com.core" I think it's to do with cljsjs packages required in the library. It requires:
[cljsjs.vega]
   [cljsjs.vega-lite]
   [cljsjs.vega-embed]
   [cljsjs.vega-tooltip]
as well as:
[re-com.core
    :as rcm
    :refer [h-box v-box box gap line h-split v-split
            button row-button md-icon-button md-circle-icon-button info-button
            input-text input-password input-textarea
            label title p
            single-dropdown
            checkbox radio-button slider progress-bar throbber
            horizontal-bar-tabs vertical-bar-tabs
            modal-panel popover-content-wrapper popover-anchor-wrapper]
    :refer-macros [handler-fn]]
   [re-com.box
    :refer [h-box v-box box gap line flex-child-style]]
   [re-com.dropdown
    :refer [filter-choices-by-keyword single-dropdown-args-desc]]

   [aerial.hanami.utils
    :refer [title2 href]]
#2018-11-0818:04thhellerboth re-com.core and re-com.box have a :refer for h-box (and others)#2018-11-0818:05thhellerthat is not valid. granted that CLJS doesn't validate this by default#2018-11-0818:05thhellerimporting d3 is not complicated at all. just (:require ["d3" :as d3]) and then (d3/whatever ...)#2018-11-0908:56manandearthdo I not need to add dependencies to the package.json file? is npm install d3 all I need?#2018-11-0908:58manandearthI see about the conflicting refers...#2018-11-0909:16thhellernpm install d3 will add it to package.json automatically yes#2018-11-0913:22manandearthI can't seem to get very far with this. is:
(def circle-demo
  (
   -> d3  
      (.select "#myCircle")
      (.append "svg")
      (.attr "r" "30")
      (.attr "cx" "50")
      (.attr "cy" "50")
       (.attr "fill" "grey")
   )

  )
a valid syntax? That's with "d3" required as d3
#2018-11-0917:53thhelleryes that looks correct#2018-11-0817:03hyoohi, shadow-cljs doesn't seem to recognize a new cljs file when it is added in src and doesn't load the file automatically to repl. Is there a way to fix that?#2018-11-0817:34wilkerluciofiles never get loaded automatically, you have to require it from another file that's already been used, or manually load the file into the REPL (using the load file feature from your editor)#2018-11-0819:44hyoocool. thanks!#2018-11-0820:59richiardiandreaI have a problem in downloading transitive dependencies from deps.cljs in shadow...it looks like it does not read our custom registry setting in .npmrc...has anyone tried that?#2018-11-0821:02richiardiandreauhm it looks like shadow is trying to guess, I have just discovered the :managed-by option 😄#2018-11-0821:03richiardiandreabut I don't see where it should go actually#2018-11-0902:07priornixI'm trying to debug a react library react-sortable-hoc https://github.com/clauderic/react-sortable-hoc. I installed it locally using npm install extern/react-sortable-hoc. The package.json file contains the following:
"dependencies": {
    "create-react-class": "^15.6.2",
    "left-pad": "file:extern/left-pad",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-sortable-hoc": "file:extern/react-sortable-hoc"
  }
I have also checked that node_modules/react-sortable-hoc is pointing to the extern/react-sortable-hoc. But when I refer to this library from cljs, the following error appears
[:frontend] Build failure:
The required JS dependency "react-sortable-hoc" is not available, it was required by "sortable/frontend/sortable.cljs".

Searched in:sortable/node_modules
As a test, I git-cloned the left-pad library and installed it locally, but it works.
(:require [reagent.core :as r :refer [atom]]
            [reagent.ratom :refer-macros [reaction]]
            ["react-sortable-hoc" :as rsh]
            ["left-pad" :as lp]
#2018-11-0907:35thheller@richiardiandrea shadow-cljs just calls npm install <packages-from-deps-cljs> or yarn add <packages> (if yarn.lock) exists#2018-11-0907:35thhellerno idea about .npmrc if that needs an extra flag or something?#2018-11-0907:36thheller@priornix are you sure that there are all the actual files in node_modules/react-sortable-hoc? npm sometimes leaves empty directories (non-linked)#2018-11-0907:55thheller@priornix did you build the react-sortable-hoc? the git repo does not contain the dist files so that may be the problem?#2018-11-0909:11priornix@thheller Thanks, I only ran npm install. Running npm run-scripts build works.#2018-11-0910:56grumpletThis is probably obvious, but I can’t immediately work out how I see or configure or update the clojurescript version that an existing shadow-cljs project depends on? There’s no mention in the package.json, shadow-cljs.edn (or project.clj - I’m using cursive).#2018-11-0911:11thheller@grumplet shadow-cljs has a default version is depends on. I do not recommend changing that.#2018-11-0911:11thhellerthe latest version depends on 1.10.439#2018-11-0911:13thhellerie. if you update shadow-cljs that will usually update the CLJS version with it#2018-11-0911:13thhellermay need manual tweaking in project.clj#2018-11-0911:16grumpletAh thanks. Just found that the version is listed in https://clojars.org/thheller/shadow-cljs. This wasn’t an immediate need, but I have had reason to change the clojurescript version I depended on in other non-shadow projects, so got to thinking…#2018-11-0911:18thhellershadow-cljs typically depends on the latest release. downgrading may not always be possible. 2.7.0 for example requires 1.10.439+ since there were some breaking changes in the cljs.analyzer (given that breaking changes are quite rare)#2018-11-0913:58Logan PowellI'm getting this in my compiled/released javascript. Does the compiler remove tests that are included as {:test #(assert...)} metadata of a function? If not, I can pull them out. I just liked that I could have my tests right next to my functions...#2018-11-0917:45kennyJust curious, are people still compiling their SASS for their CLJS app in a separate process? Or is there something built-in to shadow-cljs?#2018-11-0917:50thheller@kenny nothing built-in for sass (yet)#2018-11-0917:51kennyIs this the relevant ticket? https://github.com/thheller/shadow-cljs/issues/381#2018-11-0917:51thhellerthat or https://github.com/thheller/shadow-cljs/issues/353#2018-11-0917:52thheller@loganpowell asserts are typically elided but that particular way to add tests might not be depending on whether you accessed the var somewhere#2018-11-0917:53Logan PowellThanks man. I'm moving the tests out of the metadata currently, so I'll let you know#2018-11-0923:27richiardiandreaI am still debugging a problem where the yarn add that Shadow launches is not see my .yarnrc ...#2018-11-0923:27richiardiandreacan it be that environment vars like HOME are not set when the shell with yarn add is launched?#2018-11-1000:24richiardiandreaI checked ProcessBuilder and they should be set#2018-11-1009:07thheller@richiardiandrea the yarn process inherits the env of the shadow-cljs process#2018-11-1017:57richiardiandreaI don't think it is shadow's fault but I get a lot of corrupted packages now from the registry and I cannot understand why#2018-11-1017:57richiardiandreaThanks for answering though!#2018-11-1017:35Bravihi everyone. can I use closure-defines in my release?#2018-11-1017:35Braviso basically can I add it here?
:release    {:compiler-options {:optimizations :advanced}}
#2018-11-1018:02gleisonsilvahello everyone! may u help me... after I've tried use a new lib in my project, I ended up messing up all npm and shadowcljs dependencies.. so I've decided do rollback all changes and clean-up node_modules and js/compiled folders (`js/compiled` is my output-dir). But... after that, a few warnings and misbehaviors shows up... the first one is these several warnings that compiler is now showing:#2018-11-1018:02gleisonsilva
------ WARNING #1 --------------------------------------------------------------
 File: mranderson048/re_frame/v0v10v2/re_frame/events.cljc:61:11
--------------------------------------------------------------------------------
  58 |       (if *handling*
  59 |         (console :error "re-frame: while handling \"" *handling* "\", dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler.")
  60 |         (binding [*handling*  event-v]
  61 |           (trace/with-trace {:operation event-id
-----------------^--------------------------------------------------------------
 Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.events/java
--------------------------------------------------------------------------------
  62 |                              :op-type   kind
  63 |                              :tags      {:event event-v}}
  64 |             (interceptor/execute event-v interceptors)))))))
  65 | 
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:48:29
--------------------------------------------------------------------------------
  45 |   (let [cache-key [query-v dynv]]
  46 |     ;; when this reaction is no longer being used, remove it from the cache
  47 |     (add-on-dispose! r #(do (swap! query->reaction dissoc cache-key)
  48 |                             (trace/with-trace {:operation (first-in-vector query-v)
-----------------------------------^--------------------------------------------
 Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
  49 |                                                :op-type   :sub/dispose
  50 |                                                :tags      {:query-v  query-v
  51 |                                                            :reaction (reagent-id r)}}
  52 |                               nil)))
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:111:4
--------------------------------------------------------------------------------
 108 |   "
 109 | 
 110 |   ([query]
 111 |    (trace/with-trace {:operation (first-in-vector query)
----------^---------------------------------------------------------------------
 Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
 112 |                       :op-type   :sub/create
 113 |                       :tags      {:query-v query}}
 114 |      (if-let [cached (cache-lookup query)]
 115 |        (do
--------------------------------------------------------------------------------
#2018-11-1018:04gleisonsilvawhy these warnings?#2018-11-1018:04gleisonsilvain shadow-cljs.end i've:
... 
:dependencies [
                [re-frame "0.10.5"]
                [day8.re-frame/re-frame-10x "0.3.3-react16"]
...
#2018-11-1018:05gleisonsilvaIf I remove re-frame-10x, these warnings goes away#2018-11-1018:05gleisonsilvain package.json I have these dependencies:
"dependencies": {
		"@material-ui/core": "^1.3.1",
		"@material-ui/icons": "^1.1.0",
		"@material-ui/lab": "^1.0.0-alpha.5",
		"create-react-class": "^15.6.3",
		"highlight.js": "^9.13.1",
		"react": "^16.3.2",
		"react-dom": "^16.3.2",
		"react-flip-move": "^3.0.1",
		"react-highlight.js": "^1.0.7",
		"d3": "^3.5.16"
	},
	"devDependencies": {
		"shadow-cljs": "^2.4.17"
	}
#2018-11-1019:22gleisonsilvaI've found that the issue started as version 2.7 of shadow-cljs after i've downgrade to 2.6.23, the issue is gone#2018-11-1019:58richiardiandreaWe also had to downgrade in a project with 2.7 and 1.10.439. I will open an issue soon-ish#2018-11-1020:28thheller@gleisonsilva 2.7 started to validate some things more strictly which warns about stuff that otherwise didn't warn#2018-11-1020:28thhellerit is probably invalid code so the warning is most likely correct#2018-11-1020:29thhelleralready reported one issue to specter https://github.com/nathanmarz/specter/issues/267#2018-11-1020:42thheller
if((i__34699_34962 < count__34698_34961)){
var vec__34702_34963 = chunk__34697_34960.cljs$core$IIndexed$_nth$arity$2(null,i__34699_34962);
var k__34636__auto___34964 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__34702_34963,(0),null);
var cb__34637__auto___34965 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__34702_34963,(1),null);
try{var G__34706_34970 = new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(mranderson048.re_frame.v0v10v2.re_frame.trace._STAR_current_trace_STAR_,new cljs.core.Keyword(null,"duration","duration",1444101068),duration__34635__auto___34957,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"end","end",-268185958),mranderson048.re_frame.v0v10v2.re_frame.interop.now()], 0))], null);
(cb__34637__auto___34965.cljs$core$IFn$_invoke$arity$1 ? cb__34637__auto___34965.cljs$core$IFn$_invoke$arity$1(G__34706_34970) : cb__34637__auto___34965.call(null,G__34706_34970));
}catch (e34705){if((e34705 instanceof java.lang.Exception)){
var e__34638__auto___34973 = e34705;
mranderson048.re_frame.v0v10v2.re_frame.loggers.console.cljs$core$IFn$_invoke$arity$variadic(new cljs.core.Keyword(null,"error","error",-978969032),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Error thrown from trace cb",k__34636__auto___34964,"while storing",mranderson048.re_frame.v0v10v2.re_frame.trace._STAR_current_trace_STAR_,e__34638__auto___34973], 0));
} else {
throw e34705;
#2018-11-1020:42thhellerif((e34705 instanceof java.lang.Exception)) is certainly not valid JS#2018-11-1020:43thhellerI'll see tomorrow if I can find where the invalid code is generated#2018-11-1020:44thhellermight add a compiler option to back off from the extra validation. seems like this broken code is present in plenty of libs#2018-11-1101:16gleisonsilva@thheller to be able to use Atom+ProtoRepl I do really need to add proto-repl dependence to my shadow-cljs.edn? I mean... when using emacs, I just "connect to nrepl" port. Using proto-repl, why do I need to add that dependence (as showing in shadow-cljs docs..)#2018-11-1104:15richiardiandreaI can answer this one 😄 Cider adds the dependencies necessary for you. Just a few editors do that. Proto-repl probably does not so this really is a question for the proto-repl. The other one that does it - I think experimentally - is Calva for VSCode#2018-11-1109:56gleisonsilvaafter I've deleted node_modules + compiled files, I'm not able anymore to connect to nrepl (in this project) using atom+protorepl... but I do can connect using emacs (on this very same project). Any thoughs?#2018-11-1220:29flyboarderI would say you need the proto-repl package for your project#2018-11-1221:29gleisonsilvait is present already, but don't work anymore... i'm suspecting that the nrepl package (v nrepl-0.4.5) that is bringing by shadow-cljs is breaking it#2018-11-1106:44bbssI'm having a minification issue when using shadow-cljs release and I just want to turn it off for now. I thought I could do that with:
:builds {:main     {:target     :browser
                    ...
                     :modules    {.. some modules...}
                     :compiler-options {:optimization :simple
                                        :infer-externs :auto}}
But it seems that doesn't have any effect on the minification. I added the infer-externs so I could see if I'm running the right build and it does have an effect. Not sure what's going on.. 🤔
#2018-11-1108:03thheller@bbss :optimizations not :optimization#2018-11-1119:31aisamuThis is an unexpectedly nice feature of figwheel-main (that we might be able to use in shadow with little fuss, as it's self-contained https://github.com/bhauman/spell-spec).#2018-11-1110:21bbssOuch.. Thanks @thheller #2018-11-1110:45gleisonsilvaHello! I'm facing an issue to connect to nrepl on Atom+Proto-Repl. When comparing two projects "a" and "b", where "a" works and "b" dont, I see (by shadow-cljs info) that the nrepl dependence are different. How can I get the specific library that is bringing that lib to my project? I mean.. I don't have nrepl as a declared dependence, so I think that another one is bringing that. It is possible to build a graph showing who is bringing who?#2018-11-1110:47thheller@gleisonsilva shadow-cljs --cli-info shows a basic graph#2018-11-1110:49gleisonsilva@thheller seens to me that the output of info and --cli-info are the same... I can't see diffence among then#2018-11-1110:50gleisonsilvaat least as version 2.6.23 of shadow-cljs#2018-11-1111:12thhellerright and that should list who included nrepl#2018-11-1217:09mhuebertis there any blessed way to figure out the current target at macro-expansion time? eg. to switch based on “nodejs” or “browser”#2018-11-1217:18mhueberteg
(= "nodejs"
     (-> @cljs.env/*compiler*
         :options
         :closure-defines
         (get 'cljs.core/*target*)))
#2018-11-1217:58lilactown🤔#2018-11-1217:59lilactownI have used reader conditionals in a .cljc file to do this#2018-11-1217:59lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-11-1217:59lilactownnot sure how to do that in e.g. a macro tho#2018-11-1217:59lilactownor how it relates to macroexpansion#2018-11-1218:19thheller@mhuebert anything in :compiler-options ends up in (:options @cljs.env/*compiler*) so you could add your own option#2018-11-1218:19thhellerbut no there is no officially sanctioned way#2018-11-1218:20thheller:compiler-options {:external-config {...}} has some extra treatment to invalidate all cache when anything in there changes#2018-11-1218:20thhellerso might want to put it in there#2018-11-1218:21thhellerconditional reading might work if you can just include a different namespace and just have 2 different implementations#2018-11-1218:22thheller(:require [#?(:node some.thing :cljs some.other-thing) :as foo])#2018-11-1219:21heyarnehow can i restrict the memory allocated to shadow-cljs?#2018-11-1219:25mhuebertThe conditional reads might be exactly what I want#2018-11-1219:25mhuebertI didn't notice the shadow support for that#2018-11-1219:59thheller@arne-clojurians :jvm-opts ["-Xmx1G"] in the shadow-cljs.edn top level#2018-11-1220:00thhellermight be able to run with -Xmx256M but probably not much lower than that#2018-11-1220:31haywoodanyone ever seen this? it's gotta be something simple, I'm working from a project I have locally as a template, and it works over there, I'm only removing aliases I no longer need... Caused by: java.lang.RuntimeException: Unable to resolve var: comp/*source-map-data-gen-col* in this context#2018-11-1220:33mhuebert@haywood that looks like what I got when I ran the latest version of shadow with an older version of ClojureScript pinned in my Deps somewhere#2018-11-1220:34haywoodmakes sense, let me track that down#2018-11-1221:14thheller@haywood yes 2.7.X requires CLJS 1.10.439. this is enforced when using shadow-cljs.edn but lein or so may need manual tweaking#2018-11-1221:15thhellerunfortunately they added a new requiring binding which means older versions aren't compatible anymore#2018-11-1221:16haywoodinteresting ok. I'm using 2.4.24 and 1.10.339.#2018-11-1221:18thhellerthat can't be. 2.4.24 did not use that binding#2018-11-1221:18thhellerneither did 1.10.339 so at least one version differs#2018-11-1221:20haywooddang, great memory, ok I'll dig into what's installed locally to see what's up#2018-11-1221:44haywoodoof, I think the problem was re-installing deps without deleting my .cpcache directory 😞 😞 😞#2018-11-1221:44haywoodthat was copied over#2018-11-1313:58mdallastellaHola#2018-11-1314:56manuelhi everybody. A question concerning shadow-cljs intergration in CIDER. I am working on a mixed CLJ/CLJS project (deps.edn + shadow-cljs). Following shadow-cljs manual, I end up with 3 REPL: - CLJ REPL: where I run the http server and play with CLJ files - CLJ REPL: the one connected to shadow-cljs watch [...] - CLJS REPL: the sibling of the above Is this the expected situation? cider-find-var doesn't seem to be working, but I can interact with the browser from the CLJS REPL.#2018-11-1314:59thhellerhey. I don't use emacs myself so I can't really comment. sounds correct though#2018-11-1314:59thhellerno idea what cider-find-var is or does though#2018-11-1314:59manuelthanks @thheller. cider-find-var is a jump-to-definition.#2018-11-1315:01thhelleryeah sorry no idea how that works. maybe its talking to the wrong REPL?#2018-11-1315:02manuelI'll investigate further, thanks. 🙂#2018-11-1315:43haywood@manuel you don't have to launch separate cljs repls. I just run the watch command, and connect to the NREPL server that's printed out using cider connect. After that, to get the browser repl working, I run (shadow/nrepl-select :build-name) in that repl buffer window#2018-11-1315:44haywoodwhen you navigate to the project in the browser, you'll see "JS runtime connected"#2018-11-1315:45haywood---- I have a library that uses deps and shadow, I want to use it from another project, but the library has npm dependencies, how do I package those deps so when I use the library I don't get npm install errors?#2018-11-1315:46manuel@haywood fantastic, thanks#2018-11-1315:46thheller@haywood create a deps.cljs and add {:npm-deps {"that-lib" "1.2.3"}}#2018-11-1315:46haywooddeps.cljs and not deps.edn?#2018-11-1315:47thhellerdeps.cljs must be on the classpath and yes deps.cljs#2018-11-1315:47haywoodohh, ok#2018-11-1315:47haywoodI had tried adding that to deps.edn to no avail, will look into that#2018-11-1315:47thhellermust be part of the lib. deps.edn usually isn't#2018-11-1315:48manuel@haywood cider-find-var is not working yet, though#2018-11-1315:49haywooddo you have cider in a global deps file?#2018-11-1315:49haywoodI have this in my ~/.clojure/deps.edn cider/cider-nrepl {:mvn/version "0.18.0-SNAPSHOT"}#2018-11-1315:49manuelhere's the project: https://github.com/manuel-uberti/boodle#2018-11-1315:50manuelI have that in shadow-cljs.edn#2018-11-1315:50haywoodoh, so it's just find var? everything else is working?#2018-11-1315:50manuelyes 🙂#2018-11-1315:50haywoodgotcha, let me see if mine is working#2018-11-1315:51manuelmine now gives: user-error: ‘cider-find-var’ requires the nREPL op "info" (provided by cider-nrepl)#2018-11-1315:52haywoodthanks @thheller that worked 🙂#2018-11-1315:56haywood@manuel huh, yea mine works once connected to the browser repl#2018-11-1315:56haywoodI don't have any special cider or repl stuff in my shadow project#2018-11-1315:57haywoodI do have this in my .clojure/deps.edn refactor-nrepl {:mvn/version "2.4.0"}#2018-11-1315:57haywoodnot sure if that's necessary#2018-11-1316:11thheller@gleisonsilva I finally had some time to properly trace the re-frame-10x warnings you reported a few days ago https://github.com/Day8/re-frame-10x/issues/219#2018-11-1316:11thhellerpretty much the same issue as https://github.com/nathanmarz/specter/issues/267#2018-11-1316:17gleisonsilvathis is great, @thheller! Thank you very much#2018-11-1317:00manuel@haywood thanks again. I added refactor-nrepl to my shadow-cljs.edn, and cider-find-var is working now.#2018-11-1317:00haywoodgreat, we did it!#2018-11-1317:01manuelI also removed anything CLJS related from my .dir-locals.el, BTW.#2018-11-1318:07richiardiandreaQuestion, I am trying to get a node repl for a :node-script but I get:
node bin/migrate-event-store
Error: ENOENT: no such file or directory, open '/home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at global.SHADOW_IMPORT (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:47:15)
    at /home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3006:1
    at Object.<anonymous> (/home/arichiardi/git/laputa/event-store/bin/migrate-event-store:3115:3)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
what was the reason for that again?
#2018-11-1318:08richiardiandrea(ooops sorry for the ping 😸)#2018-11-1318:09thhellerdoes it exist? maybe removed .shadow-cljs dir without recompiling?#2018-11-1318:09richiardiandreait does not exists no#2018-11-1318:09richiardiandrea
-rw-rw-r-- 1 arichiardi arichiardi    5671 Nov 13 10:04  goog.debug.console.js
-rw-rw-r-- 1 arichiardi arichiardi   19066 Nov 13 10:04  goog.debug.debug.js
-rw-rw-r-- 1 arichiardi arichiardi    1713 Nov 13 10:04  goog.debug.errorcontext.js
-rw-rw-r-- 1 arichiardi arichiardi    1797 Nov 13 10:04  goog.debug.error.js
-rw-rw-r-- 1 arichiardi arichiardi   13935 Nov 13 10:04  goog.debug.formatter.js
-rw-rw-r-- 1 arichiardi arichiardi    4312 Nov 13 10:04  goog.debug.logbuffer.js
-rw-rw-r-- 1 arichiardi arichiardi   26315 Nov 13 10:04  goog.debug.logger.js
-rw-rw-r-- 1 arichiardi arichiardi    6131 Nov 13 10:04  goog.debug.logrecord.js
-rw-rw-r-- 1 arichiardi arichiardi    2404 Nov 13 10:04  goog.debug.relativetimeprovider.js
#2018-11-1318:10richiardiandreaoh sorry yeah it is there#2018-11-1318:10thhellerat this full path /home/arichiardi/git/laputa/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js?#2018-11-1318:10richiardiandreauhm...nope#2018-11-1318:11richiardiandreait seems like it expects in the parent of the project folder#2018-11-1318:11richiardiandreathe project path is /home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime/goog.debug.error.js#2018-11-1318:12richiardiandreaI must have messed something up#2018-11-1318:13thhellercheck the :output-to file generated by the build#2018-11-1318:13richiardiandreayeah that ends up correctly in :output-to "./bin/migrate-event-store"#2018-11-1318:13thhellerno .. check the content of the actual file#2018-11-1318:13richiardiandreaoh#2018-11-1318:14thhellerit'll have something like var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/script/dev/out/cljs-runtime'; at the beginning somewhere#2018-11-1318:14richiardiandreayeah var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/migrate/dev/out/cljs-runtime';#2018-11-1318:14richiardiandreaI am on 2.6.23 in this project#2018-11-1318:14richiardiandreaand if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/arichiardi/git/laputa/event-store/.shadow-cljs/builds/migrate/dev/out/cljs-runtime"; }#2018-11-1318:14richiardiandreait seems like it does not go in the if#2018-11-1318:15thhellerits not supposed to#2018-11-1318:16thhellerbut it seems to go up one level too much#2018-11-1318:16richiardiandrea__dirname is HEY /home/arichiardi/git/laputa/event-store/bin#2018-11-1318:16richiardiandreaI put a console.log#2018-11-1318:16thhellertry :output-to "bin/migrate-event-store"#2018-11-1318:16richiardiandrealemme try#2018-11-1318:17richiardiandreait works with the above#2018-11-1318:17richiardiandreabut...#2018-11-1318:17richiardiandreauhm#2018-11-1318:18thheller:output-to is always relative to the project root so ./ is pointless#2018-11-1318:18thhellerguess I should add a validation for that or properly normalize the path#2018-11-1318:18richiardiandreakk good to know#2018-11-1318:19richiardiandreaso the scripts runs now but it does not connect to any REPL, I am never sure we added support for :node-script REPLs 😄#2018-11-1318:20thhellerthey always had support#2018-11-1318:20richiardiandreasoooo should the script stop with something like#2018-11-1318:21richiardiandrea
{:target :node-script
                    :main laputa.event-store.migrate/-main
                    :output-to "bin/migrate-event-store"
                    :release {:compiler-options {:optimizations :advanced
                                                 :source-map true}}}
#2018-11-1318:21richiardiandreait probably does but it might be a problem in my script...which has option validation with failures#2018-11-1318:22richiardiandreayeah probably that's what happens#2018-11-1318:22richiardiandreaso never mind about the second issue#2018-11-1318:22richiardiandreaand really thanks about debugging and solving the first#2018-11-1319:31richiardiandreaToday is debugging day, so I have this:
$ cat .shadow-cljs/config.edn 
{:node-modules {:install-cmd ["--network-concurrency" "1" :packages]}}
#2018-11-1319:31richiardiandreabut I still see running: yarn add ... packages#2018-11-1319:31richiardiandreais that the right place where to put that conf?#2018-11-1319:34richiardiandreaoh I see it is in $HOME...but I also can put it in shadow-cljs.edn it seems#2018-11-1319:36richiardiandreaseems to work, definitely nice#2018-11-1319:39richiardiandrea
shadow-cljs - config: /home/arichiardi/git/laputa/scrutinize-fn/shadow-cljs.edn  cli version: 2.7.3  node: v8.12.0
shadow-cljs - starting via "clojure"
running: yarn add --network-concurrency 1 ....packages....
#2018-11-1319:57thhelleryeah shadow-cljs.edn or ~/.shadow-cljs/config.edn#2018-11-1319:58thhellerdon't think .shadow-cljs in the project dir is a useful location#2018-11-1321:21richiardiandreaagree 😉#2018-11-1322:32pvillegas12When we do (shadow/release :prod) for the production build, do we need to do compression ourselves?#2018-11-1322:34thhellercompression?#2018-11-1322:34thhellergzip? yes, that is done typically by the webserver#2018-11-1322:34pvillegas12as gzip -9 js-file.js#2018-11-1322:34pvillegas12I mean when doing the release of the assets#2018-11-1322:34pvillegas12I am pushing this to s3#2018-11-1322:35pvillegas12and within the bucket I obviously see the uncompressed js#2018-11-1322:35thhellernot sure how s3 handles it but I'd expect it to automatically compress#2018-11-1322:35thhellerjust check the request the browser makes#2018-11-1414:43lsnapeHi, is there a way I can get a list of the source files that were compiled in the build-state from within a :flush build hook?#2018-11-1414:46thhellersure the :build-sources key has the resource-ids in dependency order#2018-11-1414:46thhellereach id will have (get-in build-state [:sources resource-id]) and [:output resource-id] for the source and generated output#2018-11-1414:46lsnapeCool, thanks!#2018-11-1414:47lsnapeAnd from that I can get the files that were touched and recompiled in that incremental compile step?#2018-11-1414:48thhelleryou can also check :shadow.build/build-info which has the full summary#2018-11-1414:49thhellerincluding a :compiles #{rc-a rc-b} set for each resource that was actually compiled#2018-11-1414:49thhellercan also use (shadow.build/resources-compiled-recently build-state)#2018-11-1414:49thhellerrecently referring to compiled in last compile increment (when using watch)#2018-11-1414:49thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build.clj#L55-L66#2018-11-1414:50thhellerwhich also shows how you'd extra that info yourself#2018-11-1414:50lsnapeAmazing, sounds like just what I need. Trying it out now..#2018-11-1414:51thheller:shadow.build/build-info is what the websocket uses to decide which code to reload and stuff so that might be most useful#2018-11-1414:54lsnapeYep I can see (get-in build-state [:shadow.build/info :compiled]) contains exactly what I need.#2018-11-1415:53lsnapeAnother related question: if I wanted to modify the source files before compilation, will writing to the source files directly be sufficient? Or do I need to update the strings in the build state?#2018-11-1415:55thhellermodify in what way? most reliable option is to just modify the files directly on disk#2018-11-1415:55thhellerotherwise the caching logic might get in your way#2018-11-1415:55lsnapeI want to change references to assets in my source files, so that they are fingerprinted.#2018-11-1415:56lsnapee.g. [:img {:src "${img/ponys.png}"}] becomes [:img {:src "${img/ponys-HASH.png}"}]#2018-11-1415:56thhellerIMHO that should not be done by modifying the source files directly#2018-11-1415:57thheller[:img {:src (helper/get-img-src "img/ponys.png")}]
#2018-11-1415:57thhellerand then have the helper/get-img-src fn look it up from the JSON object#2018-11-1415:57lsnapeAnd get-img-src references a built manifest file?#2018-11-1415:57thhellerthat is either present in the page set by your HTML#2018-11-1415:57thhelleror prepend generated in a hook#2018-11-1415:58lsnapeI agree that is a better solution. I've already written a library that does it the 'search and replace' way, so was planning to reuse that.#2018-11-1416:00thhelleryou can modifiy sources in a :compile-prepare hook but getting correct caching is tricky enough as it is#2018-11-1416:01lsnapeYeah, I had a feeling that I might run into trouble!#2018-11-1416:02thhellerI have plans to integrate something like this fingerprinting for assets directly but didn't get to it yet#2018-11-1416:03lsnapeI'm just thinking about how I could make the img->hashed-img-path map available to the implementation of get-img-src.#2018-11-1416:03thhellerbut my plan involved this lookup map I suggested#2018-11-1416:04lsnapeyes, well I don't think it's too much work#2018-11-1416:04thhellera) you just append it manually after compilation#2018-11-1416:04thhellerb) you do it in a hook in :compile-finish (or :flush)#2018-11-1416:06thhellerdoing it via hooks is gonna be trickier since you need to tinker with some internals#2018-11-1416:06lsnapeSure, but the compiled JS needs the updated map? IIRC if we write a file then we'll need a macro to slurp the contents of that file?#2018-11-1416:06lsnapeAnd that file needs compiling.#2018-11-1416:06thheller(defn get-img-src [path] (or (goog.object/get js/your$lookup$map path) path))#2018-11-1416:07thhellerecho "\nvar your$lookup$map = {"img/ponys.png": "img/ponys-HASH.png"};" >> main.js#2018-11-1416:08lsnapeI see. Presumably we don't have to shell out to echo though?!#2018-11-1416:08thhelleryeah no shell if you do it on a hook#2018-11-1416:09thhellerappending to the final JS is easy no matter which method you use#2018-11-1416:10thhellerthe idea is to just use the path directly if it was not overridden with a hashed value#2018-11-1416:10thhellerworks nicely in dev#2018-11-1416:10thhellerand optimizes easily in prod#2018-11-1416:10lsnapeCool, that makes sense. And where in the build-state can I prepend to the top of main.js?#2018-11-1416:11lsnapeYeah, initially I was planning to use mode to either skip or fingerprint the assets.#2018-11-1416:12lsnapeThere are some edge cases to take care of. e.g. changing an asset involves a recompilation of the source file that references it.#2018-11-1416:12lsnapeActually, you have something in place already to do that for CSS files, don't you?#2018-11-1416:12thhellerno it doesn't#2018-11-1416:13thhelleror asset as in something inlined by a macro?#2018-11-1416:13thhelleror why would you recompile if an asset changes?#2018-11-1416:14lsnapeI mean, if I changed ponys.png will the browser receive a message to reload that asset?#2018-11-1416:14thhellerno image reloading does not exist (yet)#2018-11-1416:14thhellerkinda tough to do#2018-11-1416:15lsnapeWell typically we don't want to hash assets in dev mode anyway, so it's kind of a moot point.#2018-11-1416:16thhelleryeah in dev you just use the normal file paths#2018-11-1416:16thhellerjust make get-img-src return the original either via a :closure-define or some logic that checks if the path was overridden#2018-11-1416:17thheller(which it won't be in dev)#2018-11-1416:17lsnapeI'll try and knock something up. And whereabouts can I prepend the lookup map to the main.js file?#2018-11-1416:17lsnapeYeah, we don't want to generate a junk hash-map of identities in dev mode!#2018-11-1416:18thhelleroption a) :flush will be called after the file has been written#2018-11-1416:18thhellerso you just append on disk#2018-11-1416:19thhellerb) do it in :configure by basically setting :modules {:main {:prepend-js "var lookup$map = <json>;\n"}}}#2018-11-1416:19thhelleras if you had that in the build config#2018-11-1416:21thheller(update-in build-state [:shadow.build.modules/config <module-id> :prepend-js] str "var lookup$map = " (json/write-str {"foo" "bar"}))#2018-11-1416:21thhellersomething like that#2018-11-1416:21lsnapeYeah I got ya#2018-11-1416:21thhellercan use :prepend-js or :append-js doesn't really matter#2018-11-1416:21thhelleror :prepend :append#2018-11-1416:22thheller:prepend-js will go through :advanced so the closure compiler may be smart enough to directly inline the strings#2018-11-1416:22thhelleroptimizing out the get-img-src lookup completely#2018-11-1416:22lsnapeThe latter sounds preferable.#2018-11-1416:23thhellerpotentially yes#2018-11-1416:26lsnapeOne advantage of the dumb regex search-and-replace approach is the same mechanism works for assets referenced in index.html and CSS files. Luckily for us we generate the page frame in hiccup and CSS in garden. Still, we need to generate a manifest file for use on the server.#2018-11-1416:29thhellersure that works too#2018-11-1416:30thhellerin :compile-prepare you can modify the source#2018-11-1416:30thhellerjust probably need to disable caching since it otherwise won't invalidate properly#2018-11-1418:24richiardiandrea@thheller it seems we have another problem like yesterday in our build D:\home\.shadow-cljs\builds\az\dev\out\cljs-runtime\goog.debug.error.js#2018-11-1418:24richiardiandreaaz is the name of target :azure-app#2018-11-1418:24richiardiandreait seems like it is again trying to skip a folder#2018-11-1418:24richiardiandreaand read from the parent of our project#2018-11-1418:24thhellerwhich path are you using in the config?#2018-11-1418:24thhellerjust take out ./ and it should work#2018-11-1418:24richiardiandrea:app-dir "azure/build"#2018-11-1418:25richiardiandreacould it be somewhere in the code?#2018-11-1418:25thhellercheck whats in the output file#2018-11-1418:25richiardiandrea(checking in the meantime)#2018-11-1418:26thhellerbeginning to regret trying to the the output dir clean#2018-11-1418:27richiardiandreawe can tweak no prob...let's see where the problem is 😄#2018-11-1418:29richiardiandreaI am checking the output file but I don't see anything like the SHADOW-IMPORT like yesterday#2018-11-1418:31thhellerhmm? are you checking the correct file?#2018-11-1418:31richiardiandreamaybe not 😄#2018-11-1418:31richiardiandreai'll be back#2018-11-1419:12richiardiandrea@thheller so this is what my colleague sees:
var SHADOW_IMPORT_PATH = __dirname + '/../../../.shadow-cljs/builds/az/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/Users/user/github-ep/laputa/commit-event-fn/.shadow-cljs/builds/az/dev/out/cljs-runtime"; }
global.$CLJS = global;
#2018-11-1419:13richiardiandrealike yesterday, the first points outside the project folder#2018-11-1419:13richiardiandreabut this time we don't have ./#2018-11-1419:25richiardiandreaI see in the code this happens:
{:exports fn-map
                                    ;; FIXME: can't have a {:cljs some.ns/fn} function when using cljs dir
                                    :output-to (str app-dir "/cljs/shared.js")}`
#2018-11-1419:27richiardiandreaso that looks good to me#2018-11-1421:10thheller@richiardiandrea you posted a d:\home windows location and the code snippet above is clearly not windows#2018-11-1421:10thhellerso I'm guessing the code wasn't compiled on that machine#2018-11-1421:11thhellerdev builds are only meant to run on the machine they were compiled on#2018-11-1421:22richiardiandreauhm ok thanks, there must be something going on here#2018-11-1421:22richiardiandreathe snippet above came from a deployed lambda, this latest from a laptop#2018-11-1421:22richiardiandreasomething is not right, I will get a better understanding first#2018-11-1421:22richiardiandreathen get back to you#2018-11-1421:26thhelleryou should only ever deploy release compiled files#2018-11-1421:27thhellernever compile or watch#2018-11-1421:27thhellerif its trying to access anything in cljs-runtime it was not a release build#2018-11-1421:39richiardiandreayep it seems like something like deploy a compiled thing happened#2018-11-1421:49richiardiandrea@thheller it looks like the culprit on my colleague's MacOsX machines is:
<- Cache read: cljs/core.cljs (151 ms)
-> Compile CLJS: cljs/core.cljs
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs
NullPointerException:
    cljs.compiler/emit/fn--3144 (compiler.cljc:189)
    clojure.lang.Atom.swap (Atom.java:37)
    clojure.core/swap! (core.clj:2344)
    clojure.core/swap! (core.clj:2337)
    cljs.compiler/emit (compiler.cljc:187)
    cljs.compiler/emit (compiler.cljc:182)
    shadow.build.compiler/eval12942/fn--12943 (compiler.clj:238)
    clojure.lang.MultiFn.invoke (MultiFn.java:234)
    shadow.build.compiler/default-compile-cljs/fn--12969 (compiler.clj:289)
    shadow.build.compiler/default-compile-cljs (compiler.clj:288)
    shadow.build.compiler/default-compile-cljs (compiler.clj:274)
    clojure.core/partial/fn--5739 (core.clj:2617)
    shadow.build.compiler/do-compile-cljs-string/fn--12930 (compiler.clj:227)
#2018-11-1421:49richiardiandreait compiles fine on linux though#2018-11-1421:54thhellerthats a version conflict#2018-11-1421:54thheller1.10.439 requires 2.7.X#2018-11-1421:55thhellerthe errors above indicates old shadow-cljs version with new CLJS#2018-11-1421:59richiardiandreaooooooo#2018-11-1421:59richiardiandreaok now that makes sense#2018-11-1422:00richiardiandreamy colleague did not do yarn install after updating to 2.7.3#2018-11-1422:01thhellerthat doesn't matter when using deps.edn? (or lein)#2018-11-1422:08richiardiandreawe are using yarn shadow-cljs for launching things but I am interesting in knowing more about deps.edn case#2018-11-1422:11thhellerI assume you are using deps.edn because the version conflict above can't happen with pure shadow-cljs.edn#2018-11-1422:12thhellerit enforces the CLJS version used based on the version of shadow-cljs in package.json#2018-11-1422:12thhellerif you use deps.edn that can't be enforced so whatever you have in there will be used#2018-11-1422:13richiardiandreaoh I see what you mean#2018-11-1422:13haywoodoh yea, do I not need to declare it in package.json if I'm adding shadow to my deps? had been cargo culting that without knowing if I needed it#2018-11-1422:13richiardiandreayeah ClojureScript is taken from deps.edn#2018-11-1422:14richiardiandreaso you are saying I should get rid of that in deps.edn basically#2018-11-1422:14thheller@haywood yes. it is recommended so your project doesn't rely on some global install in the system#2018-11-1422:15haywoodoh, but I guess if I remove it from package.json, my npm run scripts will stop working#2018-11-1422:15thheller@richiardiandrea no. I guess its fine. forgot that shadow-cljs injects itself into deps.edn on startup#2018-11-1422:16thheller@haywood I'm confused. you SHOULD have it in your project. do not remove it.#2018-11-1422:17thheller@richiardiandrea I was just wrong. it actually does matter that the proper version is installed via yarn/npm#2018-11-1422:18richiardiandreaoh ok good to know thanks#2018-11-1422:18thhellerjust keep it all in shadow-cljs.edn so you don't get such issues 😉#2018-11-1422:24richiardiandreaI know we should move away from using yarn shadow-cljs but haven't had the time to figure out the replacement#2018-11-1422:25richiardiandreaideally we should be able to do clojure -A:shadow watch as a replacement#2018-11-1422:26thheller["-m" "shadow.cljs.devtools.cli"] for whatever the args key way#2018-11-1422:26thheller:main-opts?#2018-11-1422:26richiardiandreayep#2018-11-1422:27thhellerbut that won't properly handle the server mode so thats not really recommended#2018-11-1422:27richiardiandreauhm ok then good that you've just told me that 😄#2018-11-1422:27thhellerthe npm package detects if a server is running and talks to that directly if it is#2018-11-1422:28thhellerthe clj script will just start a new jvm every time#2018-11-1422:28richiardiandreaoh no we don't want that 😄#2018-11-1422:37thhellercould maybe add a clojure version that does that check but it would be way slower and launcher a full JVM just to connect to a remote socket is a bit overkill#2018-11-1422:40richiardiandreayeah actually for one-off tasks in CI we don't want a shared JVM anyways#2018-11-1423:03kniarzynHI. I am using shadow-cljs with re-frame. What can I do to prevent reseting app-db after each file chenge?#2018-11-1423:07thhellerit should never reset unless you do it?#2018-11-1423:10kniarzynYes. It keeps reseting after each file change. Don't know where to look for cause.#2018-11-1423:11thhellerwell lets start with your setup. do you have any :after-load or :before-load hooks configured?#2018-11-1423:11kniarzynI have autoload#2018-11-1423:11kniarzynsets to true#2018-11-1423:12thhellerthat defaults to true so doesn't matter#2018-11-1423:12thhellerwhat does the browser console say when you change a file?#2018-11-1423:13thhellerit should print at least one load JS message#2018-11-1423:14thhellerthere are a couple example repos here and plenty of them use re-frame https://github.com/thheller/shadow-cljs#examples#2018-11-1423:14thhellermaybe that can help comparing the configs#2018-11-1423:14kniarzynshadow-cljs: load JS herman/pages/observations.cljs browser.cljs:25 shadow-cljs: load JS herman/views.cljs browser.cljs:25 shadow-cljs: call herman.core/mount-root browser.cljs:25 shadow-cljs: call herman.core/init#2018-11-1423:15thhelleralright. so what does herman.core/mount-root or herman.core/init do? are you sure both should be called on reload?#2018-11-1423:16kniarzynNo. I think herman.core/init should not be run#2018-11-1423:17thhelleryou probably have :dev/after-load metadata on it?#2018-11-1423:17kniarzynOnly this ^:export#2018-11-1423:18thhellerthen maybe :after-load herman.core/init in your build config?#2018-11-1423:18thhellermust be set somewhere otherwise shadow-cljs would not call it#2018-11-1423:19kniarzynYou are great. Thank you.#2018-11-1423:20kniarzynIt is working now as I want.#2018-11-1511:14claudiuTrying to run a old project on a new machine and getting this:#2018-11-1511:14claudiu
npx shadow-cljs watch server 
shadow-cljs - config: /home/claudiu/clojure/fulcro-nodejs-ssr-example/shadow-cljs.edn  cli version: 2.7.3  node: v8.11.0
shadow-cljs - starting via "clojure"
Exception in thread "main" java.lang.RuntimeException: Unable to resolve var: comp/*source-map-data-gen-col* in this context, compiling:(shadow/build/compiler.clj:455:13)
#2018-11-1511:14claudiuany idea what it could be ?#2018-11-1511:21claudiusolved... strange one. Updating clojurescript 1.10.339 to 1.10.439 fixed the error#2018-11-1512:10thheller@claudiu 2.7.x depends on cljs 1.10.439 yes. since cljs added that backwards incompatible change older versions don't work anymore#2018-11-1512:12claudiuwas initially using shadow-cljs 2.6.7 and got the error. 🙂#2018-11-1512:13thhellerwell the reverse is also true. 1.10.439 can't be used <2.7.0#2018-11-1512:13claudiuby the way... big big thank you for the shadow-cljs + node.js stuff. Really awesome dev experience 🙂#2018-11-1512:30claudiuDon't know how much you're using fulcro & nodejs. But getting SSR with data from the network is like really easy & not much code overhead (nice experience on first load + refresh) 🙂 added a demo app https://github.com/claudiu-apetrei/fulcro-nodejs-ssr-example#2018-11-1512:31thhellercool. just one minor nitpick. separating src/main/app and src/main/server is not necessary. namespaces already split the code enough and server code won't be included in the app build#2018-11-1512:32thhellerbut if you like working like that it is fine to do this#2018-11-1512:32thhellerjust not necessary#2018-11-1512:41claudiuAhh yep, just a personal preference to keep the sever & app code in separate folders :) for this demo app just copy pasted the structure from another project :) #2018-11-1512:42thhellerhow do you deal with shared code? extra folder?#2018-11-1512:44thhellerah nvm its already sharing the app folder.#2018-11-1512:51claudiuYep. Named it app (instead of client) so all the client + shared should code should be there. Only the server should import from app. #2018-11-1512:56thhellershould I add it to https://github.com/thheller/shadow-cljs#examples?#2018-11-1513:07claudiuif you want sure 🙂#2018-11-1607:47claudiu@U05224H0W Actually think it's better to not. It is just a proof of concept for fulcro SSR and I don't really think that express.js is the way to go. Will probably build an example app with nodejs+fulcro+pathom+code-splitting that uses https://macchiato-framework.github.io/ with a bit more app code, that one should be a nice addition for the shadow-cljs examples page.#2018-11-1513:44MalteHi, I'm using the :npm-module target (for now in convenience mode) to include some cljs into an existing JS project. I know that I can 'hot reload' the cljs code into the JS code base using shadow-cljs watch npm, but is it also possible to use a cljs repl with that target? I've tried using cider and manage to start a cljs repl, but everytime I try to eval something it tells me that the application hasn't connected to the REPL server. I've tried navigating to (which works), but this doesn't connect. Is connecting via browser even possible with :npm-module?#2018-11-1514:54thheller@li1 since :npm-module does not have a clearly defined entry the devtools cannot be injected automatically#2018-11-1514:54thhelleryou can set :runtime :browser in the config#2018-11-1515:28Malteso something like
{:source-paths
 ["src"]

 :dependencies
 []

 :runtime :browser

 :builds {}}
?
#2018-11-1515:31thheller
:builds
{:npm
 {:target :npm-module
  :runtime-browser
  :output-dir "node_modules/shadow-cljs"}}
#2018-11-1515:32thhellerthat would be identical to the "convenience" mode#2018-11-1515:32thhelleroops :runtime :browser#2018-11-1515:33Maltethis works, awesome! 🙂#2018-11-1515:33Malteis the runtime flag documented somewhere?#2018-11-1515:34thhellerdon't think so#2018-11-1516:11Malteoh, and if this really proves to be unreliable with my setup, the fallback would basically be to write cljs without a repl and to restart my JS build server every time it needs to pick up changes? or is there something in-between?#2018-11-1517:18thhellerit all depends on how much the JS is processed. don't know enough about your setup to comment really#2018-11-1518:25MalteOK, thanks a lot, this really helped me#2018-11-1514:55thhellerand then require("shadow-cljs/shadow.cljs.devtools.client.browser") somewhere in your JS#2018-11-1514:55thhellerthat also enables live-reload not just the REPL#2018-11-1514:56thhellerbut its not super reliable. depending on which other build tool you are using for JS#2018-11-1622:10kenran_Hi! I'm currently learning Clojure(Script) and web development in general, and I'm interested in understanding the tooling. So far I've created a very small playground app and I'm using lein and figwheel-main. But I want to give shadow-cljs a try since it looks awesome. One question before I start actually porting stuff would be: I am depending on a library that has react as a dependency via cljsjs iirc. Does that pose a problem when switching to shadow-cljs? Or can I exclude those and get react into the project via node?#2018-11-1623:22lilactownshadow-cljs ignores cljsjs. so you can install react/react-dom as an npm dependency and it will just work#2018-11-1622:11mattlyis there an easy way in shadow-cljs watch mode to expose the value of an environment variable to a value in cljs-land?#2018-11-1622:12mattlyI've done this sort of thing before with macros#2018-11-1623:19lilactown@mattly browser or nodejs?#2018-11-1623:19mattlybrowser#2018-11-1623:19mattly#2018-11-1623:19lilactownsounds like macros would be the easiest way#2018-11-1623:20mattlyof course now I'm realizing that I only need env vars for local development, and then to derive everything from the url for the compiled js#2018-11-1623:20lilactownalthough beware that this would only be picked up while building#2018-11-1623:20mattlyeyah#2018-11-1623:20lilactownyeah, that's how we do it - we key off the particular URL the script is loaded in#2018-11-1623:21lilactownfeels like a hack at first, but it means that we don't have to rebuild it based on what environment we want to deploy to#2018-11-1623:21mattlyright#2018-11-1814:45kenran_I think I don't understand the testing workflow with shadow-cljs yet. I'm used to figwheel-main where I start it up and automatically get two pages I can check: one for the actual app, one for a test hosting page (similar to what I accomplished with shadow-cljs and the :browser-test target).#2018-11-1814:47kenran_I can shadow-cljs watch browser-test to get this, but then I don't have the app running as well. Do I need 2 watch processes? Can I combine them somehow? Or should I just use the :node-test target?#2018-11-1814:47thhellershadow-cljs watch browser-test your-app runs 2 watches#2018-11-1814:48kenran_Oh wow, how could that escape me! Let me try#2018-11-1814:48thhelleryou can as many builds as you want in parallel#2018-11-1814:49thhelleralso as separate watch if you prefer to split the terminals and not have all output in one#2018-11-1814:49kenran_I repeat myself, but: wow!#2018-11-1814:50kenran_Thanks a lot for all the work. I don't regret giving it a try one bit so far. The best thing compared to what I used before is how blazingly fast the hot reloading is.#2018-11-1814:52kenran_Is there a (default) way to get notifications about the test results in the second browser tab? That is, maybe change the icon or show a popup once something breaks?#2018-11-1814:53thhellercurrently that is very minimal and has no notifications or anything#2018-11-1814:54thhellerI'm planning to hook up https://github.com/bhauman/cljs-test-display but didn't get to that yet#2018-11-1814:54thhelleryou can do it yourself with a custom runner but should really be the default#2018-11-1814:55kenran_Ah yes, that's the one that's default in figwheel-main (same author). It looks pretty, but that's not really necessary for me. It's just a convenience.#2018-11-1818:47eoliphantHey @thheller, have a barcode lib that’s not behaving https://serratus.github.io/quaggaJS/
(require '["quagga" :default Quagga]) ; default export is nil, as it looks like what's in node_modules, doesn't have a nice index.js, etc

(require '["quagga/dist/quagga" :default Quagga])

; blows up with
failed to resolve: ./config.node.js from /Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js
{:relative-to #object[java.io.File 0x400fd1fa "/Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js"], :entry "./config.node.js"}
ExceptionInfo: failed to resolve: ./config.node.js from /Users/erichkoliphant/Dropbox/projects/jv-consumer/node_modules/quagga/dist/quagga.js
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/find-relative (npm.clj:268)

; it works on node and in the browser, guessing that there's something going on with the conditional stuff?
#2018-11-1821:25thheller@eoliphant AFACIT (require '["quagga" :as Quagga]) seems to work fine. not sure why it has a default property in node#2018-11-1821:26thhellerthe files in dist are not for build consumption and look like standalone builds that you'd include directly via <script>#2018-11-1821:27eoliphantyeah#2018-11-1821:27eoliphanttaht’s what i ended up doing in the meantime#2018-11-1821:27eoliphantnow messing around with react-webcam, similar fun#2018-11-1821:30thhellerI'm not sure why the :default isn't available. it seems to be available on node#2018-11-1821:30eoliphantas doensn’t seem to work for it either 😞#2018-11-1821:32thhellerhmm odd it is actually using the dist file#2018-11-1821:33eoliphantbut yeah thanks, :as works just fine for quagga#2018-11-1821:33eoliphantJS is such a s-show#2018-11-1821:33thhellerah "browser": "dist/quagga.min.js",#2018-11-1821:34thheller
if (false) {
    config = require('./config.dev.js');
} else if (true) {
    config = __webpack_require__(58);
} else {
    config = require('./config.prod.js');
}
#2018-11-1821:34thhellergotta love the crap they put into their builds#2018-11-1821:34eoliphantugh#2018-11-1821:34eoliphantlol#2018-11-1821:35thhelleryeah conditional requires are tricky#2018-11-1821:36thhelleryeah the browser build is just different and doesn't have a default export#2018-11-1821:37eoliphantgotcha#2018-11-1821:42eoliphanthey while your’e around, I saw some of your expo experiments from a while back. is that still experimental?#2018-11-1908:22thheller@eoliphant the dedicated expo stuff is deprecated. its just too much work trying to replicate everything the official tools do. I also don't do any react-native development so I didn't spend any more time on it#2018-11-1908:40manueljust another THANK YOU @thheller for shadow-cljs. I spent the weekend reworking the UI of my project (moving from Skeleton to Bulma, revisiting modal panels, etc.). shadow-cljs stays out of my way and makes development nice and smooth. Really great stuff.#2018-11-2018:42richiardiandreaHi all, hi Thomas! I am looking into https://github.com/thheller/shadow-cljs/issues/407 and would like to ask how to apply :exclusions to the shadow dependency if I am using it through package.json. I tried a couple of things to no avail#2018-11-2018:44thhellerI thought you were using deps.edn?#2018-11-2018:44thhellercan't apply exclusions to shadow-cljs itself in shadow-cljs.edn#2018-11-2018:50richiardiandreawell I am using deps.edn but not for shadow, cause the automatic detection of server mode is not working unless I have it in package.json. Am I right?#2018-11-2020:30thheller@richiardiandrea no that has nothing to do with it. it just looks for .shadow-cljs/http.port file which is written when the server is started#2018-11-2117:10richiardiandreais this configurable? If so in a monorepo I could start yarn shadow-cljs server from the parent and all the child projects could connect to it#2018-11-2117:11richiardiandrea@U05224H0W yes I do not care in CI but I could potentially care and shed off 3 seconds per sub project 😄#2018-11-2117:51thhellerthe time you spent thinking about ways to get rid of 3sec startup time already accounts for about 1000 project starts#2018-11-2117:52thhellerand no you cannot share a server instance between projects. they are isolated on purpose#2018-11-2117:58richiardiandreaAh ah I wish it was like you said, also this shaving off is way more important for my team than my time spent thinking about it apparently. That's why I am trying hard to improve things 😄 #2018-11-2118:06thhellerso what is the workflow of your team?#2018-11-2118:07thhellerdo they run a shadow-cljs server at the start of the day and leave that running?#2018-11-2118:07thhellerthat is pretty much the only thing that matter#2018-11-2118:07richiardiandreaNo they cd into the lamdba project and start a watch#2018-11-2118:07thhellerIF that is running in the project you have zero startup time for any other command#2018-11-2118:08thhellerok that starts a server instance as well#2018-11-2118:08thhellerand its a problem that this takes 5sec or so?#2018-11-2118:08thhellerwhen done once a day?#2018-11-2118:09richiardiandreaYeah#2018-11-2118:09richiardiandreaGive me a sec will be back#2018-11-2118:15richiardiandreaso they start a server instance in the project of the lambda they want to work on#2018-11-2118:15richiardiandreaand the following commands are correctly avoiding startup time#2018-11-2118:15richiardiandreabut sometimes you want to run commands in two lambdas, now you need two JVMs#2018-11-2118:20thhellerwell you can always combine the projects and just have one project for many lambdas#2018-11-2118:20thhellerthat would take care of that#2018-11-2118:20richiardiandreamy boss does not want to do that, he says that the tool should be smarter 😄#2018-11-2118:22thheller:source-paths ["lambda1/src/main" "lambda2/src/main"] and just create a combined config#2018-11-2118:25richiardiandreaYeah I can do that. Would you be open to adding some sort of magic that helps with this kind of setup (monorepo) so that the merge is done automatically?#2018-11-2118:26thhellerthe problem is :dependencies#2018-11-2118:26thhellerthose can't be merged easily#2018-11-2118:26thhellerotherwise I would have done this ages ago#2018-11-2118:26thhellerbut clojure can't load 2 versions of the same dependency#2018-11-2118:27richiardiandreaYep but in a monorepo is in general what you want, so you can just error out (like you already do for transitive node_modules...nice touch btw)#2018-11-2118:27thhellermerging build configs is easy enough#2018-11-2118:28richiardiandreaI am actually manually keeping Clojure deps.edn in sync making sure I have the same version everywhere#2018-11-2118:28richiardiandreait's painful 😄#2018-11-2118:29richiardiandreasomething that does this for me would be awesome...now - this probably would be better in a separate lib#2018-11-2118:30richiardiandreabut shadow-cljs could wrap the lib and provide a fully fledged solution for monorepos#2018-11-2118:31thhellerI don't think shadow-cljs needs to do anything#2018-11-2118:31thhellerisn't the point of the monorepo to keep everything in one repo?#2018-11-2118:31thhellerif everything is already in one repo and we already have namespaces to separate everything ...#2018-11-2118:31thhellerwhy split it further?#2018-11-2118:31thhelleror why not keep the shadow-cljs config one level up?#2018-11-2118:32thhellerrepo/lamba1/shadow-cljs.edn + repo/lamba2/shadow-cljs.edn OR repo/shadow-cljs.edn#2018-11-2118:32thhellerleave the sources where they are .. doesn't really matter#2018-11-2118:32thhellerjust add :source-paths ["lambda1/src" ...] and in the builds just use :app-dir "lambda1/output"` or whatever#2018-11-2118:33thhellerwhat is the point of separating everything if combining it is actually what you want?#2018-11-2118:33thhellerit doesn't even make sense to do this in JS ...#2018-11-2118:34thhellerjust write a shell script that takes the nested shadow-cljs.edn files .. extracts the builds and rewrites the paths#2018-11-2118:51thhellerFWIW if you can create a "demo" monorepo that demonstrates your setup I can maybe think of something to do#2018-11-2118:51thhellerbut right now it just feels like you are shooting yourself in the foot for "reasons"#2018-11-2119:12richiardiandreayeah sometimes you have to take decisions you don't agree with...but thanks for trying to find solutions.#2018-11-2020:30thhellerdoesn't matter how#2018-11-2020:30thhellerbut I thought you didn't care about server-mode in CI anyways#2018-11-2020:30richiardiandreawell there was a reason we discussed and we ended up deciding not to use deps.edn....if there is no reason I can think about moving 😉#2018-11-2020:30richiardiandreayeah#2018-11-2020:34thhellerbut anyways the SERVER can be started any way you like#2018-11-2020:34thhelleryou only need the shadow-cljs npm package to actually talk to it#2018-11-2020:35thhellerso clj -m shadow.cljs.devtools.cli release your-build is totally fine for CI#2018-11-2020:35thhelleras well as clj -m shadow.cljs.devtools.cli server to start the dev server#2018-11-2020:36thhellerstill don't actually recommend using deps.edn but if you want to tweak stuff for CI thats your best option currently#2018-11-2020:36thheller(apart from actually just enabling caching)#2018-11-2020:39richiardiandreaok that's cool I can tweak that then - thanks for clarifying#2018-11-2105:40bedersshadow-cljs is full of treasures. Just discovered the proxy option. Works really well (except for POSTs).#2018-11-2105:41bedersIs there a way I can determine if my code is running in dev mode?#2018-11-2105:41bedersfor example, when running in dev, I'm talking to an API that runs on a different port number#2018-11-2105:41bedersin production however, I'm not#2018-11-2105:46bederssomething like (if (find-ns 'shadow)...) maybe?#2018-11-2105:59lilactowncheck js/goog.DEBUG#2018-11-2108:09thheller@beders what do you mean except for POSTs?#2018-11-2115:15bedersI didn't look deeper into it, but POST requests didn't make it through the proxy. In that case I was talking to a sente endpoint which would like to upgrade the connection to a websocket.
#2018-11-2116:37thhellerwhich version are you on? all requests should work just fine#2018-11-2116:38thhellerolder versions didn't handle this correctly. 2.7.x should be fine though#2018-11-2400:04bedersthank you! As usual, I missed the slack reply 😞#2018-11-2108:10thhelleruse https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines for build specific options js/goog.DEBUG is one of them#2018-11-2109:55cmalhi, @thheller. Today I have a clean machine build and have update the version of re-frame . shadow-cljs gives me so many warnings, but I think things such as Use of undeclared Var re-frame.events/java re-frame.events/java are not exist in the source code. The error messages are:#2018-11-2109:57thheller@cmal yeah this is due to a new check in 2.7.x. already reported here https://github.com/Day8/re-frame-10x/issues/219#2018-11-2109:58thhelleroh wait .. they are in re-frame itself as well? guess I should report it there too#2018-11-2109:58cmalmaybe, I have the following deps:#2018-11-2109:59cmal
[re-frame "0.10.6"]
  [day8.re-frame/undo "0.3.2"]
  [day8.re-frame/http-fx "0.1.7"]
  [com.smxemail/re-frame-cookie-fx "0.0.2" ]
#2018-11-2110:00cmalAnd the warnings certainly come from re-frame.#2018-11-2110:01thhellerreported here for re-frame too https://github.com/Day8/re-frame/issues/514#2018-11-2110:02thhelleryou can downgrade shadow-cljs to 2.6.24 for now#2018-11-2110:02cmalok, Thanks.#2018-11-2110:06thhellerhmm#2018-11-2110:06thhellerno that seems to be fixed?#2018-11-2110:06thhellerI don't get those warnings?#2018-11-2110:07thheller@cmal are you sure the re-frame is actually using that version?#2018-11-2110:09thhellerit was actually fixed in https://github.com/Day8/re-frame/commit/3de2ff8ff3403af2fcf29f287462a36f58c7bbb0#diff-87c1083a777fb7472aa850b82f8c2def#2018-11-2110:09thhellerso it appears that you have some older version?#2018-11-2110:10thhellerrun shadow-cljs clj-repl and ( "re_frame/trace.cljc") to check which file is actually getting used#2018-11-2110:11cmalok#2018-11-2110:20cmalit is 0.10.2. I removed .shadow-cljs and compiled again. Another question, @thheller. https://github.com/funcool/cats/blob/master/project.clj project like this uses (defproject funcool/cats ...), how should I require this? I use [cats.core :as m] but shadow-cljs tells me The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs"., while [funcool/cats.core :as m] just syntax error.#2018-11-2110:22thheller@cmal the defproject name is only relevant for the dependency itself. it has nothing to do with the namespaces you use in CLJS#2018-11-2110:22thhellerie. you depend on [funcool/cats "2.3.1"] but (:require [cats.core ...])#2018-11-2110:23thhellerremoving .shadow-cljs should not affect anything in your dependencies?#2018-11-2110:24cmalI just add [funcool/cats "2.3.1"] this to my deps.#2018-11-2110:24cmalbut cannot figure out a way to use it in the source code.#2018-11-2110:25cmal[cats.core :as m] will get the error The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs"#2018-11-2110:25thhelleryou do not use lein/`deps.edn` right?#2018-11-2110:25thhelleryou only have your :dependencies in shadow-cljs.edn?#2018-11-2110:25cmal
{:dependencies
 [[cljs-ajax "0.7.2"]
  [reagent "0.8.0-alpha2"]
  [reagent-utils "0.3.1"]
  [re-frame "0.10.6"]
  [day8.re-frame/undo "0.3.2"]
  [day8.re-frame/http-fx "0.1.7"]
  [secretary "1.2.3"]
  [garden "1.3.3"]
  [funcool/cats "2.3.1"] ;; <- just added this line
  [com.andrewmcveigh/cljs-time "0.5.2"]
  [com.smxemail/re-frame-cookie-fx "0.0.2" ]
  [com.taoensso/timbre "4.10.0"]
  [hiccups "0.3.0"]
  [thheller/shadow-cljsjs "0.0.16"]
  [org.clojure/core.async "0.4.474"]]
shadow-cljs.edn
#2018-11-2110:26thhellerno :lein or :deps keys? please confirm that#2018-11-2110:26cmalSo I should lein install this?#2018-11-2110:27cmalno :lein no :deps#2018-11-2110:27thhellerok. did you restart the server process properly?#2018-11-2110:27thhellerafter adding that line?#2018-11-2110:28cmaljust shadow-cljs watch doumi. not start another server.#2018-11-2110:28thhellerwhat did the watch say when you started#2018-11-2110:28thhellerconnected to server?#2018-11-2110:28thhelleryou may have another server process still running somewhere#2018-11-2110:28cmal
shadow-cljs watch doumi
shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn  cli version: 2.7.4  node: v10.13.0
shadow-cljs - starting ...
11月 21, 2018 6:28:38 下午 org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
11月 21, 2018 6:28:38 下午 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/yuzhao/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
shadow-cljs - server version: 2.7.4
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 53798
shadow-cljs - nREPL server started on port 53800
shadow-cljs - watching build :doumi
[:doumi] Configuring build.
[:doumi] Compiling ...
^[[:doumi] Build failure:
The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs".
#2018-11-2110:29thhellerhmm that looks like it should#2018-11-2110:29thhellersomething odd is going on in your system#2018-11-2110:29cmal😢#2018-11-2110:30thhellerthis was AFTER adding the line and saving the file?#2018-11-2110:30cmalyes#2018-11-2110:30cmal
shadow-cljs watch doumi                                                                                                                                                                                                                                                                                                                                 [2h0m] ✹ ✭
shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn  cli version: 2.7.4  node: v10.13.0
shadow-cljs - starting ...
11月 21, 2018 6:30:21 下午 org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
11月 21, 2018 6:30:21 下午 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/yuzhao/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
shadow-cljs - server version: 2.7.4
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 53912
shadow-cljs - nREPL server started on port 53914
shadow-cljs - watching build :doumi
[:doumi] Configuring build.
[:doumi] Compiling ...
[:doumi] Build failure:
The required namespace "cats.core" is not available, it was required by "doumi/helper.cljs".
#2018-11-2110:30cmalrun several times.#2018-11-2110:30cmalsame error#2018-11-2110:31thhellersame deal shadow-cljs clj-repl and ( "cats/core.cljc")#2018-11-2110:31cmalnil#2018-11-2110:31cmal
[1:0]~shadow.user=> ( "cats/core.cljc")
nil
#2018-11-2110:31thhellerso then it is not on the classpath?#2018-11-2110:32thhellerare you sure you edited the correct shadow-cljs.edn?#2018-11-2110:32thheller/Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn#2018-11-2110:32cmalSorry for that.#2018-11-2110:32cmal:+1:#2018-11-2110:32cmalI am editing the file in the old machine.#2018-11-2112:45mrgHi#2018-11-2112:45mrgI'm trying to use different configurations based on whether i'm in the dev environment, or in release mode#2018-11-2112:46mrgIn leiningen I would have the same configuration namespace in two different environment paths, and add them to :source-paths conditionally#2018-11-2112:47mrgI tried this with shadow-cljs but I' getting the error ":source-paths is only valid globally and cannot be configured in build :app."#2018-11-2112:47mrgI haven't found a way of getting different things to happen in dev vs release. Help, please?#2018-11-2112:48thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration and https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2018-11-2112:48thhellerfor development https://shadow-cljs.github.io/docs/UsersGuide.html#_preloads#2018-11-2112:49thhellerI consider this :source-paths hack an anti-pattern and its not supported by shadow-cljs itself. you can still use it when using deps.edn or lein if you really want to#2018-11-2112:49mrgI saw your post about it 🙂#2018-11-2112:50mrgBut I hadn't found a way to get this to work#2018-11-2112:50thhellerwhat exactly?#2018-11-2112:51mrgGetting different things to happen at release vs dev time#2018-11-2112:51thhellerdefine "things"#2018-11-2112:51mrgIn my case, loading different configuration#2018-11-2112:51thhellerthere are plenty of options via the links I posted above#2018-11-2112:51mrgYeah, I think closure-defines will work#2018-11-2112:51mrgThank you for that!#2018-11-2112:52thhellerhow do you define "loading different configuration"?#2018-11-2112:52mrgI don't understand the question. I have one s3 bucket that I want to use while developing, and another one that I want to use in the released app#2018-11-2112:53thhellerok. I define that as "runtime configuration" and not "build configuration"#2018-11-2112:53mrgI want to choose this bucket based on the run environment, so I don't forget to un/comment things#2018-11-2112:53mrgYep, that's it#2018-11-2112:53thhellerI should really document this somewhere ...#2018-11-2112:54thhellerso I do recommend that you have an init function in your app#2018-11-2112:54thhelleryour.app.init() or something#2018-11-2112:54thhellereither called from the HTML via <script> or any other means really#2018-11-2112:54thhellerthat init function can either load the config itself via XHR#2018-11-2112:55thhelleror via some other variable set in the HTML#2018-11-2112:55thheller<script>var app$config = {"s3url":"...."};</script>#2018-11-2112:55thhellerand the init function then reads that and initializes for re-frame state or whatever you are using#2018-11-2112:56thhellerthat way your HTML can control the stuff which makes it easy to change and doesn't require recompiling your CLJS when those things change#2018-11-2112:56mrgBut I still need to figure out either which runtime environment I am in, or use different HTML files depending on that, right?#2018-11-2112:56mrgSo I'm still back to closure-defines#2018-11-2112:57thhellerdo you have a server part? or just a static HTML file?#2018-11-2112:57mrgjust static html#2018-11-2112:57thhellerwell yeah you could just have a index.html + index-dev.html#2018-11-2112:58mrgwhy would you use that approach over closure-defines?#2018-11-2112:58mrgit seems easier to me to just set an environment key and act based on that?#2018-11-2112:58thhellerwell I typically assume some kind of webserver that generates the HTML#2018-11-2112:58thhellersince the config I assign is typically dependent on some server-side stuff where recompiling the CLJS would be overkill#2018-11-2112:59mrgIn my case I'm acting on data from a 3rd party server that I don't have control over#2018-11-2112:59mrgMakes sense#2018-11-2112:59thhellerbut closure-defines is totally fine#2018-11-2112:59mrgI'll give that a shot#2018-11-2112:59mrgThanks a lot#2018-11-2112:59mrgAnd since I have you here, thank you so much for shadow-cljs#2018-11-2113:00mrgIt's taken a lot of pain out of CLJS development for me#2018-11-2113:00mrgto the point where I used to hem and haw a lot about starting a new project for fear of the fiddly configuration#2018-11-2113:00thhellervery welcome 🙂#2018-11-2113:06mrgclosure-defines worked well! Thanks and have a great day!#2018-11-2117:12neuralhello all#2018-11-2117:13eoliphantHi, i’m running into an issue where dev/watch builds work just fine. But a release build is failing with
Uncaught ReferenceError: __webpack_require__ is not defined
    at eval (index.js:1)
    at Object../components/index.js (app.js:330)
    at c (app.js:234)
    at ./components/Button/Button.jsx (app.js:236)
    at Object.shadow$provide.module$node_modules$$grantsolutions$grant_solutions_ui$dist$index (app.js:236)
    at oI (app.js:1362)
    at app.js:2070
    at app.js:2164
Fortunately, this is a react lib that’s being developed by another group, so if I can figure out what the problem is I can have them tweak the build to fix this. Any offhand ideas re: what might cause this. In poking around in the code, so far haven’t seen some of the other stuff that’s caused issues
#2018-11-2117:32lilactownhow is the lib packaged?#2018-11-2117:32lilactownis it ES5? is it a single bundle?#2018-11-2117:39eoliphantlooks like ES5 and JSX. here’s a bit of it unpacked
...
;; example of how we're pulling it in 
["@grantsolutions/grant-solutions-ui" :as gsui]

(def Button (uc/component-factory gsui/Button))
#2018-11-2117:40lilactownif it’s actually trying to run JSX code then it’s not going to work#2018-11-2117:40lilactownyou need to look in the dist folder#2018-11-2117:40eoliphantah hell i knew that lol, one sec#2018-11-2117:41eoliphantok yeah, looks like a bundle#2018-11-2117:41eoliphant#2018-11-2117:43eoliphant__webpack_require__ is defined in the index.js
function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
maybe it’s getting munged away in the release build?
#2018-11-2117:44lilactownit could be some other error#2018-11-2117:44lilactownlike a collision once advanced compilation kicks in#2018-11-2117:45eoliphantugh yeah#2018-11-2117:46eoliphantjust tried forcing whitspace only#2018-11-2117:46eoliphantsame issue#2018-11-2117:55thhellerwhat build target is this? :npm-module?#2018-11-2117:56eoliphantbrowser#2018-11-2117:57eoliphantit’s a pretty OOTB Fulcro w/ shadow config#2018-11-2117:57thhellerand how do you include the JS?#2018-11-2117:58eoliphantit’s just an alias right now ["@grantsolutions/grant-solutions-ui" :as gsui]#2018-11-2118:00thhellerhmm not sure why this would work in dev but not release#2018-11-2118:01eoliphantyeah#2018-11-2118:02eoliphantit’s weird. any problems I’ve seen before have been consistent. because of whatever lib weirdness#2018-11-2118:02eoliphantthey just didn’t work at all#2018-11-2118:02eoliphantand not an expert, but the webpack and babel configs, seem mercifully simple#2018-11-2118:03eoliphant
module.exports = {
  entry: "./components",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "index.js",
    library: "",
    libraryTarget: "commonjs"
  },
  plugins: [new MiniCssExtractPlugin(), new StyleLintPlugin()],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ["babel-loader", "eslint-loader"]
      },
      {
        test: /\.(sa|sc|c)ss$/,
        use: [
          MiniCssExtractPlugin.loader,
          "css-loader",
          "postcss-loader",
          "sass-loader"
        ]
      },
      {
        test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
        use: "file-loader"
      }
    ]
  },
  resolve: {
    extensions: [".js", ".jsx"]
  }
};
---

{
  "presets": ["@babel/env", "@babel/flow", "@babel/react"],
  "plugins": [
    "@babel/proposal-class-properties",
    "@babel/proposal-object-rest-spread",
    "flow-react-proptypes"
  ]
}
#2018-11-2118:05thhellerthat seems fine yes#2018-11-2118:06thhellerand if the file itself contains the require definition that should work fine#2018-11-2118:16eoliphantwhich file?#2018-11-2118:16thhellerindex.js#2018-11-2118:16eoliphantah#2018-11-2118:17eoliphantthis is ‘raw’ one
// @flow

// $FlowFixMe
import "../styles/main.scss";

export * from "./Button";
export * from "./Icon";
export * from "./Notification";
export * from "./Form";
export * from "./Modal";
export * from "./Popover";
export * from "./Search";
export * from "./List";
export * from "./Table";
export * from "./utils";
export * from "./Progress";

#2018-11-2118:18thhellerdoesn't matter#2018-11-2118:18eoliphantand yeah, the one in dist.. defines __webpack_require__#2018-11-2118:19eoliphantok this is weird. when I speciffy whitespace#2018-11-2118:19eoliphantit fails differntly#2018-11-2118:20thhellerdon't specify whitespace#2018-11-2118:20thhellerits not a supported optimization mode for anything#2018-11-2118:20eoliphant
Uncaught TypeError: Cannot set property 'Error' of undefined
    at app.js:768
    at app.js:11615
And it looks like it’s goog.debug.Error that’s missing
#2018-11-2118:20eoliphantok#2018-11-2118:20eoliphantjust tried it to see if it would help#2018-11-2118:22eoliphantI think the docs may be out of date :optimizations supports :advanced, :simple or :whitespace#2018-11-2118:23thhellerhttps://github.com/thheller/shadow-cljs/issues/408#2018-11-2118:24thhellercan you send me the index.js?#2018-11-2118:24eoliphantgotcha 🙂 ok, this is weird. I went to simple. same issue. But webpack.require__ is called before it’s defined#2018-11-2118:24thhellerI'm out of guesses#2018-11-2118:24eoliphantsure#2018-11-2118:24thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2018-11-2118:25thhellerJS doesn't work like CLJS so calling something that is defined later is fine#2018-11-2118:25eoliphantsure thing#2018-11-2118:25thhelleras long as it is defined in the same scope#2018-11-2118:28eoliphantah right#2018-11-2118:35eoliphantjust sent it#2018-11-2118:37thhellergeez#2018-11-2118:37thhellerthats a debug JS build#2018-11-2118:37thhellerthat was not built with webpack in production mode#2018-11-2118:37thhelleryou really really don't want to use that 😛#2018-11-2118:37eoliphantlol ok, yeah this is from another group, i have the source so I can muck aroiund with it#2018-11-2118:38eoliphantbut beyond that it shuold still behave consistently right?#2018-11-2118:38thhellerI think it is webpack -p#2018-11-2118:38thhellereval("__webpack_require__.r(__webpack_exports__);\n/* harm#2018-11-2118:38thhellerit just evals the code all over the place#2018-11-2118:39thhellerbut since it evals a string clojure just probably thought that the __webpack__require function was unused and removed it#2018-11-2118:39thhellerif its built without debug mode it should be working fine#2018-11-2118:40eoliphantah gotcha#2018-11-2118:40eoliphantok#2018-11-2118:40eoliphantwill grab it and try building it locally#2018-11-2118:41eoliphantugh there’s not even a non-dev build#2018-11-2118:41eoliphantin the scripts#2018-11-2118:42thhellereek. nobody uses that for production builds then 😛#2018-11-2118:42eoliphant
"compile": "run-s compile:*",
    "compile:storybook": "build-storybook -o dist/storybook",
    "compile:webpack": "webpack --mode=development",
    "format": "run-s format:*",
    "format:icons": "eslint components/Icon/glyphs/*.jsx --fix",
    "prepack": "run-s clean:build test compile",
#2018-11-2118:42eoliphantyeah it’s still in dvelopment#2018-11-2118:43eoliphantbut they should be pushing the right build to the repo#2018-11-2118:45thhellerindeed. making everyone run the debug build is no fun 😉#2018-11-2118:45thhellerbut FWIW using the build itself is already problematic#2018-11-2118:46thhellerit includes its own version of moment, react, react-dom, etc etc etc#2018-11-2118:46thhellerso they won't be compatible with the ones used by your CLJS#2018-11-2118:46thhelleror you'll have 2 versions loaded on the page#2018-11-2118:47thhellerso the entire setup doesn't seem ideal to me#2018-11-2119:02eoliphantgotcha#2018-11-2119:03eoliphantok so given that I generally avoid JS like the plague#2018-11-2119:03eoliphantlol#2018-11-2119:03eoliphantwhat’s the best way to address that. make those dev dependencies?#2018-11-2119:04thhellerbest way would be to just include the babel output and not package anything at all#2018-11-2119:04thhellerso no webpack#2018-11-2119:05eoliphantok this is another team. We’re ultimately their consumer, so I can make them do whatever I wish lol#2018-11-2119:05eoliphantactually now that I think about it#2018-11-2119:05eoliphantthis shouldn’t be a super big deal#2018-11-2119:05eoliphantthey’re on the hook for the components#2018-11-2119:06eoliphantand this demo app#2018-11-2119:06thhellerif you have the sources and the babel config already it should be easy#2018-11-2119:06eoliphantyeah just figuring out the best, least disruptive way to tell them they have to do this lol#2018-11-2119:07eoliphantthey’re using storybook, etc etc. but to your point#2018-11-2119:07eoliphantall that should still work just fine#2018-11-2119:07eoliphanti think#2018-11-2119:07thhellerwell storybook output probably should not be part of the npm package#2018-11-2119:07thhellerbut yeah it doesn't hurt anyone if its there#2018-11-2119:08eoliphantshoulda just foreced them to learn CLJS lol#2018-11-2119:08eoliphantugh#2018-11-2119:08eoliphantbut in looking at their scripts#2018-11-2119:10eoliphantthey have all the usual jest, lint, etc stuff. That should be fine.. and separate ones to build and run storybook#2018-11-2119:10eoliphantbut ugh in looking at this, yeah storybook is all mixed in#2018-11-2119:10thhellerdoesn't matter really#2018-11-2119:10thhellerjust leave it there#2018-11-2119:11thhellerin the node_modules version of the lib you currently have#2018-11-2119:11thhellerrun npm install#2018-11-2119:12eoliphantSo potentially, everything can remain the same
"start": "start-storybook --port 1999",
    "prepack": "run-s clean:build test compile",
    "clean": "yarn clean:build && yarn clean:modules",
    "clean:build": "rm -rf dist",
    "clean:modules": "rm -rf node_modules",
    "test": "run-s test:*",
    "test:flow": "flow",
    "test:eslint": "eslint components --ext .js --ext .jsx",
    "test:stylelint": "stylelint styles",
    "test:jest": "jest",
    "compile": "run-s compile:*",
    "compile:storybook": "build-storybook -o dist/storybook",
    "compile:webpack": "webpack --mode=development",
    "verify:eslint": "eslint --print-config .eslintrc | eslint-config-prettier-check",
    "format": "run-s format:*",
    "format:icons": "eslint components/Icon/glyphs/*.jsx --fix"
aside from the complie:webpack /
#2018-11-2119:12thhellerthen npx babel components --out-dir out#2018-11-2119:12thhellerjust as a test#2018-11-2119:12eoliphantok#2018-11-2119:12thhelleryes all that can stay as is .. doesn't matter#2018-11-2119:12eoliphantalready pulled it down#2018-11-2119:13thhellerno do it in the version you have intalled#2018-11-2119:13thhellernot the source repo#2018-11-2119:13thhellerjust a test#2018-11-2119:13eoliphantah#2018-11-2119:13eoliphantok#2018-11-2119:14thhellerthe generated out folder should jsut contain a bunch of clean .js files#2018-11-2119:14thheller["@grantsolutions/grant-solutions-ui/out/index.js" :as gsui] should then maybe work?#2018-11-2119:15eoliphantgotcha#2018-11-2119:15eoliphantok so if that works#2018-11-2119:15eoliphantthen I can go yell at them lol#2018-11-2119:17thhelleryou want to stay as close as possible to the original sources#2018-11-2119:17thhellerjust need to get rid of .jsx really#2018-11-2119:17thhellerthat avoid conflicts with already-bundled deps and stuff#2018-11-2119:18thhellercould clean up the package to get cleaner paths but thats next level stuff 😉#2018-11-2119:51eoliphantgot pulled into a call#2018-11-2119:51eoliphantthat did it 🙂#2018-11-2117:15neuralsomeone know what this error is???#2018-11-2117:15neural'''1. Unhandled java.lang.IllegalStateException Can't change/establish root binding of: nrepl-cljs with set'''#2018-11-2117:16neurali am in emacs !#2018-11-2117:53thheller@neural.works.com sounds like the nrepl middleware was not loaded properly https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-11-2118:01neural@thheller you mean the var cider-jack-in-cljs-middlewares?#2018-11-2118:01thhellerhow did you start the server instance?#2018-11-2118:03neurali started a cider-jack-in then that repl i run the server/start! and shadow/watch.... then i tried the cider-connect-siblings-cljs#2018-11-2118:03thhellerok so you are using lein or deps.edn to start the server?#2018-11-2118:03neuraldeps.edn#2018-11-2118:03thhellerand which nrepl server are you connecting to?#2018-11-2118:04thhellerit does not appear to be the one started by shadow-cljs#2018-11-2118:05neuralmaybe thats the problem... i started a regular cider-jack-in then when i started the shadow-cljs server inside that nrepl and it started a new repl!#2018-11-2118:05thhellerwhatever nrepl server you are connected to must have the nrepl middleware loaded#2018-11-2118:05thhellerI don't know which one you are connected to or how to configure that one#2018-11-2118:06neuralmy cider-jack-in-cljs-nrepl-middlewares is ("cider.piggieback/wrap-cljs-repl" "shadow.cljs.devtools.server.nrepl/cljs-load-file" "shadow.cljs.devtools.server.nrepl/cljs-eval" "shadow.cljs.devtools.server.nrepl/cljs-select")#2018-11-2118:08neuralshadow-cljs always starts a new nrepl????#2018-11-2118:09thhellerI have no idea what cider-jack-in-cljs-nrepl-middlewares is or means so I can't say if that is correct or not#2018-11-2118:10thhellershadow-cljs starts its own nrepl server yes. you do not have to use that one if the nrepl server you are talking to has the middleware properly loaded#2018-11-2118:11thhellermaybe ask in #cider how to configure nrepl middleware for cider-jack-in + deps.edn#2018-11-2118:11thhellerI have no idea what that does#2018-11-2118:11neuralme too!#2018-11-2118:11neuraltks! will check that!#2018-11-2118:11thhelleryou could just run shadow-cljs server and cider-connect or whatever thats called#2018-11-2118:12thhellerthat ensures that everything is setup properly on the shadow-cljs side#2018-11-2118:13neuralok.. but i need the oposite... i started a cider-connect with an already started server...#2018-11-2118:14neural...then if i want shadow-cljs to run... i run embedeed in that server... but it always started its own server...#2018-11-2118:14thhellerits all about the middelware, you can connect to any nrepl server that has that middleware loaded#2018-11-2118:14thhellerit does NOT matter that its own server is started#2018-11-2118:14thhelleryou do NOT need to use it#2018-11-2118:15thhellerit won't interfere with anything#2018-11-2118:15thhellerjust don't talk to it#2018-11-2118:15thhellerit has nothing to do with your problem#2018-11-2118:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-11-2118:15neuralbut then how i started a shadow-cljs repl on that embeede server? its not the server from shadow-cljs#2018-11-2118:16thhellerthis shows how to set everything up for lein. I just can't tell you how to do it for deps.edn + emacs#2018-11-2118:17thhellerI can't help you ... I have absolutely no clue how emacs does the project stuff#2018-11-2118:17thhelleryou are starting an nrepl server somehow. that server does not have the middleware loaded.#2018-11-2118:17thhellernothing else matters#2018-11-2118:17neuraltks Thomas!! im guessing its the middleware... gonna check that!!!#2018-11-2206:53manuelhi. shadow-cljs has been reporting this on my build:
------ WARNING #1 --------------------------------------------------------------
 File: bidi/bidi.cljc:29:12
--------------------------------------------------------------------------------
  26 | actually a valid UUID (this is handled by the route matching logic)."
  27 |   [s]
  28 |   #?(:clj (java.util.UUID/fromString s)
  29 |      :cljs (cljs.core.UUID. s)))
------------------^-------------------------------------------------------------
 Wrong number of args (1) passed to cljs.core.UUID
--------------------------------------------------------------------------------
  30 | 
  31 | ;; When forming paths, parameters are encoded into the URI according to
  32 | ;; the parameter value type.
  33 | 
--------------------------------------------------------------------------------
It's a warning, so nothing serious as I can keep working with no problem. Just wondering: should I report it to bidi?
#2018-11-2208:07thhellerprobably yes#2018-11-2208:08thhellerthey are supposed to use (cljs.core/uuid s)#2018-11-2208:08thhelleror just (uuid s)#2018-11-2208:14manuelok, I'll open an issue on their repo.#2018-11-2208:15manuelnevermind, there is already an issue on this: https://github.com/juxt/bidi/issues/189#2018-11-2214:22lsnapeHi thheller, FYI I've got asset fingerprinting working in a configure build hook similar to how we outlined it last week. Deploying today. If it all works then I'll run the implementation past you.#2018-11-2214:23lsnapeI think there's still quite a bit of work required before it's ready for a PR into shadow-cljs.#2018-11-2222:33mattlyshadow-cljs just started reporting this on a project I hadn't touched for a few weeks:#2018-11-2222:33mattly#2018-11-2222:34thheller@mattly shadow 2.7.x requires CLJS 1.10.439#2018-11-2222:34thhellerso need to bump that when using deps.edn#2018-11-2222:35mattlyhuh thanks#2018-11-2222:35mattlyI don't remember upgrading anything#2018-11-2222:35mattlythanks#2018-11-2222:35thhelleryou probably have a version range in your package.json for shadow-cljs#2018-11-2222:36thheller"shadow-cljs":"^2.6.12" or whatever#2018-11-2222:36mattlyyeah indeed#2018-11-2222:36thhellerthat automatically upgrades#2018-11-2222:36thhellercan just set a fixed version (which I recommend doing)#2018-11-2222:36thhellerto avoid issues such as this 😉#2018-11-2222:37mattlyyeah that's typically what I do#2018-11-2222:37thhellerno idea why version ranges are still the default in node world 😞#2018-11-2222:37mattlyperhaps because they think anything older than a day is obsolete
#2018-11-2222:38thhellerhehe#2018-11-2222:38mattlytroll#2018-11-2310:58miridius@thheller where does the :resource-name field come from in the rc map that the various shadow-cljs compiler functions use? I have a weird issue where increasingly large numbers of letters are being dropped from the beginning of the :resource-name for my cljs source files, which eventually causes the path to start with a /, which causes IllegalArgumentException: /middle-of-my-namespace/core.cljs.cache.transit.json is not a relative path when interacting with the cache. I scoured the source to try to figure out where the issue is coming from but I can't for the life of me figure out where the details for the source files are coming from.#2018-11-2311:00thheller:resource-name is just a name. it is never used in any file ops.#2018-11-2311:01thhellerhttps://github.com/thheller/shadow-cljs/blob/fb252af9fcf2568fa9d368baa6b5405633450b81/src/main/shadow/build/classpath.clj#L612-L614#2018-11-2311:02thhellerconstructed like that for filesystem paths for example#2018-11-2311:02thhellerhttps://github.com/thheller/shadow-cljs/blob/fb252af9fcf2568fa9d368baa6b5405633450b81/src/main/shadow/build/classpath.clj#L482#2018-11-2311:02thhellerfor classpath jars#2018-11-2311:03miridiushttps://github.com/thheller/shadow-cljs/blob/fb252af9fcf2568fa9d368baa6b5405633450b81/src/main/shadow/build/compiler.clj#L471-473#2018-11-2311:04thhelleroh right its used there#2018-11-2311:04thhelleryeah forgot about those 😛#2018-11-2311:04miridiusthat's the function that's throwing an exception for me. I've figured out how to reproduce the issue as well, it happens if any of the source paths involve symlinks#2018-11-2311:04thhellerstill the resource-name generation is pretty simple. not sure why it would mess up#2018-11-2311:05thhellerhmm what kind of symlink?#2018-11-2311:05thhellerwindows/mac/linux?#2018-11-2311:07miridiuslinux#2018-11-2311:07miridiustoy example:
.
├── client
│   └── core.cljs
└── src
    └── main
        └── my
            └── namespace
                └── client -> ../../../../client
#2018-11-2311:10thhellerah ok that makes sense#2018-11-2311:10thhellerhttps://github.com/thheller/shadow-cljs/blob/fb252af9fcf2568fa9d368baa6b5405633450b81/src/main/shadow/build/classpath.clj#L603#2018-11-2311:10thhellerthis assumes that the canonical path of the file is always a child of the root#2018-11-2311:11thhellerwhich it is not in this case#2018-11-2311:11miridiusah 🙂#2018-11-2311:11thhellerok. easy fix#2018-11-2311:14thhellerhmm not sure how well this plays with file watching though#2018-11-2311:16thheller@miridius can you just swap the links around so that client -> src/main/my/namespace/client?#2018-11-2311:19miridiusnot really, the reason for the links is that I'm trying to use polylith architecture (https://polylith.gitbook.io/polylith/), where the source is broken into components that are then symlinked into various systems as needed#2018-11-2311:19miridiusideally the symlinked paths should be watched as well#2018-11-2311:19thhellerhmm yeah I just tested the fix and while it finds the file properly#2018-11-2311:19thhellerfile watching does not work#2018-11-2311:20thhellerhmm polylith doesn't seems to make much sense for CLJS?#2018-11-2311:20thhellersince you can't build the system like that#2018-11-2311:21miridiuswell I'm building a full stack app (with Fulcro) so there are server components, client components, and also shared components like the UI (used by server for SSR) and the API#2018-11-2311:21thhellerhmm by why is the direction of the link relevant?#2018-11-2311:21thhellerthe end result from a file system perspective is the same?#2018-11-2311:22miridiusbecause it needs to be one-to-many so that one component can be in multiple systems#2018-11-2311:22miridiusalthough to be fair there will only ever be a single cljs system since as you said it can't really be split up#2018-11-2311:22miridiusso maybe it makes sense to do it that way#2018-11-2311:22thhellernot sure I understand you can still have as many links as you want?#2018-11-2311:24miridiuslet's say I have a component "api", which is used by both the "server" system and the "client" system, but not by other systems. So it must have its source stored at /components/api/src, and then /systems/client/src/api and systems/server/src/api will link to it#2018-11-2311:25miridiusI do feel though that symlinks are kind of a pain, I'm wondering if the same result can be achieved by just using a more monolithic source folder and then having fine grained source-path settings in the build files for each system#2018-11-2311:25thhellertalk about making things uneccessary complex 😛#2018-11-2311:25miridiushaha 🙂#2018-11-2311:25miridiusthere's a leiningen plugin which does all the work for you#2018-11-2311:26miridiusit works great for pure clojure projects... clojurescript not so much 😄#2018-11-2311:27miridiushttps://github.com/tengstrand/lein-polylith#2018-11-2311:27thhelleryeah because CLJS has a real build system unlinke CLJ#2018-11-2311:28thhellerso it doesn't matter how many files you have on the classpath#2018-11-2311:28thhellerthe build will only include whatever was actually used#2018-11-2311:38thhelleralright. I think I got links working properly with watch#2018-11-2311:43miridiusawesome! and yeah I think you're right it doesn't make sense to use polylith for cljs. But since there's a lot of .cljc source files I'm not sure there's a way I could use polylith for the backend but then also have all the cljs source in one place. I'll have to think about it!#2018-11-2311:46thheller@miridius try it with 2.7.6. I think it should work properly now#2018-11-2312:19miridius@thheller it works! you're a legend :star-struck:#2018-11-2317:47lilactownI wonder if we’ll ever get tree shaking on the JVM/CLJ#2018-11-2317:58littleliIt has little value on JVM#2018-11-2317:59lilactownwe’ll see once people are trying to create wasm modules from JVM languages 😉#2018-11-2318:01lilactownI’m kind of joking, but many of the langs who have attempted to positions themselves to take advantage of wasm have run into this problem where suddenly their ability to prune unused lib code is very important#2018-11-2318:08littleliI would expect graalvm to provide solution for that.#2018-11-2320:17thhellerwasm is never gonna be a good target for JVM#2018-11-2320:17thhellertoo much the JVM offers you'd need to replicate which makes files too large#2018-11-2320:18gklijsWhen you create a native image with graalVM it sort of happens. And now you no longer need the whole JDK, for running Java it might become more important to also decrease the size of fat jars#2018-11-2320:22littleliI believe there will be wasm interpreter for graalvm#2018-11-2322:04gklijsI actually asked at Devoxx, and that do what some web output, but most lively this will be JavaScript. Also they are looking for some Electron integration also.#2018-11-2320:24thhellermaybe but if it requires a 10mb download to bootstrap its not gonna be very useful (for the web)#2018-11-2321:44lilactownI wonder if you could download the necessary bootstrapping once and cache it for every website thereafter#2018-11-2322:23richiardiandreahi all! Question time! Do we have a way to enable *check-assert* in a shadow release compilation step?#2018-11-2322:24thhellerwhat is *check-asserts*?#2018-11-2322:29thhellerthe only assert related option you have is :compiler-options {:elide-asserts false}. not aware of any other.#2018-11-2400:02richiardiandrea@thheller should be that one, let me try that#2018-11-2400:03richiardiandreaactually it might be something else...I mainly want to instrument even if release#2018-11-2408:23manuelI have [refactor-nrepl "2.4.0"] in my shadow-cljs.edn, I am connected to the nREPL server started by shadow-cljs watch via cider-connect and (shadow/nrepl-select my-app). When I try to do M-x cljr-clean-ns in a CLJS file, I get this: user-error: The refactor-nrepl middleware isn’t available! Did you remember to install it? Am I missing something?#2018-11-2408:40thheller@manuel guess you need to configure the middleware#2018-11-2408:40thheller:nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]}#2018-11-2408:42manuel@thheller you mean add that to shadow-cljs.edn?#2018-11-2408:43thhelleryep#2018-11-2408:47manuel@thheller works like a charm. Thank you!#2018-11-2421:43achikinCan I serve release build with the built-in development server?#2018-11-2421:43thhellerin actual production or just for testing locally?#2018-11-2421:46achikinFor testing locally.#2018-11-2421:46thhellerits just serving files so yeah you can use it#2018-11-2421:47thhellerit will be started automatically when a server is running, eg. npx shadow-cljs server#2018-11-2421:47thhellerno watch needs to be running#2018-11-2421:47achikinI want to experiment with :js-options {:js-provider :closure}#2018-11-2421:47achikinThank you!#2018-11-2421:48thhellergood luck 😛#2018-11-2421:48thhellerI gave up a long time ago. too many packages just don't work 😛#2018-11-2421:50achikinI have a few. react, material-ui and some react components.#2018-11-2421:51thhellerreact sort of works. most components don't#2018-11-2421:51thhellerespecially everything rewritten by babel#2018-11-2421:51achikinI've just run shadow-cljs check app and got a bunch of warnings. All of them come either from cljs.core or from reagent - is that expected?#2018-11-2421:52thhellersomething about Java from cljs.core yes that is expected#2018-11-2421:52thhellerreagent not sure?#2018-11-2421:52achikin
------ WARNING #28 -------------------------------------------------------------
 File: ~/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:10520
 actual parameter 2 of goog.object.set does not match formal parameter
found   : (string|symbol)
required: string
--------------------------------------------------------------------------------
#2018-11-2421:53achikin
------ WARNING #31 -------------------------------------------------------------
 File: ~/.m2/repository/reagent/reagent/0.8.1/reagent-0.8.1.jar!/reagent/impl/component.cljs:296:33
 Property _reactInternalInstance never defined on G__2678
--------------------------------------------------------------------------------
#2018-11-2421:55achikin#2018-11-2421:55thhellerhmm yeah the reagent one will probably get renamed without externs#2018-11-2421:55thhellerthe goog.object.set is due to an outdated closure library I think#2018-11-2421:55thhellerit hasn't been updated in ages#2018-11-2421:56thhellerbut won't cause issues#2018-11-2421:56thhellercheck unfortunately is not very useful sometimes#2018-11-2421:56achikin> hmm yeah the reagent one will probably get renamed without externs Do I need to provide externs for reagent?#2018-11-2421:58achikinI mean react 🙂#2018-11-2421:58thhellerhmm no I guess not#2018-11-2422:00thhellerhmm guess those are all fine#2018-11-2422:01achikinThank you! Everything seems to be working under release 🙂#2018-11-2422:01thhellerwith :closure?#2018-11-2422:08achikinNo, without :closure#2018-11-2422:13achikinJust tried :closure. main.js is 95kb instead of 98kb with :shadow, nothing is rendered due to minified react error. And it was just react + material-ui with a single button rendered on the screen.#2018-11-2422:13achikinYou were right - it's not worth it 🙂#2018-11-2422:14thhelleryeah material-ui is a terrible package when it comes to :advanced#2018-11-2422:16lilactown> material-ui is […] terrible#2018-11-2423:06souenzzosome recommendation for a CSS noob?#2018-11-2422:16thheller😛#2018-11-2501:11dspiteself#2018-11-2501:11dspiteselfany advice#2018-11-2505:47wilkerluciois there a way to write portable libraries that include plain js files? I'm asking because by cljs standards they say to use :foreign-libs (https://github.com/clojure/clojurescript-site/blob/master/content/reference/packaging-foreign-deps.adoc), but shadow on the other side can import js files directly, but no :foreign-libs, I'm working in the Workspaces project and I have a dependency on a simple js file, is there a way to write it so users of the library get correct behavior with both standard cljs and shadow?#2018-11-2510:24thheller@dspiteself looks like you are using a browser build in a non browser environment? something that doesn't have access to document#2018-11-2510:24thheller@wilkerlucio the support for JS files in standard CLJS is absolutely terrible. they can't talk to CLJS code or import other code themselves#2018-11-2510:26thhellerbut if you don't need that you can emulate the inclusion just like cljsjs#2018-11-2510:26thhellerhmm maybe not actually. I'm not sure if :foreign-libs are used before the classpath or after#2018-11-2514:54wilkerlucio@thheller so the best option seems to be create a npm package a cljsjs package and a shadow-cljsjs to get it compatible?#2018-11-2515:11thhellerI'm not sure to be honest. what kind of JS file do you have?#2018-11-2517:52wilkerlucio@thheller this is the file in question, its a fuzzy search algorithm: https://gist.github.com/wilkerlucio/221cda4bc18184ea827cbf1e545aa4a2#2018-11-2517:52wilkerlucio#2018-11-2517:53wilkerlucioI even started trying to convert, but its a very stateful procedural algorithm, that's actually better as is then trying to port it to functional I think#2018-11-2518:04dspiteselfYea I am targeting a serviceworker which is like a webworker. https://developers.google.com/web/fundamentals/primers/service-workers/ It does not have document. It uses self.importScripts()#2018-11-2518:04dspiteselfIt seems like it would need to be a different target#2018-11-2520:44thheller@dspiteself try setting :modules {:main {... :web-worker true}}}#2018-11-2520:44thheller@wilkerlucio I don't even know how you'd use that file with standard CLJS? did you get that working already?#2018-11-2520:46wilkerlucioif I want to target a single compiler (regular cljs OR shadow) its easy#2018-11-2520:46wilkerluciousing the foreign libs thing#2018-11-2520:46wilkerluciothe foreign lib give it a name, you require and use globals (as described here: https://github.com/clojure/clojurescript-site/blob/master/content/reference/packaging-foreign-deps.adoc)#2018-11-2520:47wilkerlucio@thheller the problem is making something that works in both cases, I can't find a way to make those compatible#2018-11-2520:47thhellerhow do you actually use that file with CLJS though?#2018-11-2520:48thhellerI mean how do you require it and access the code?#2018-11-2520:48wilkerlucioyou add something like this to deps.cljs:#2018-11-2520:48wilkerlucio
{:foreign-libs
  [{:file "react/react.js"
    :file-min "react/react.min.js"
    :provides ["com.facebook.React"]}]
 :externs ["react/externs.js"]}
#2018-11-2520:48wilkerluciothen you required the name said in the :provides, so, in this case: (:require [com.facebook.React])#2018-11-2520:49wilkerluciothen the code is just injected#2018-11-2520:50wilkerlucioand the file is expected to set globals, so very much like adding a new <script> tag, but goes in the same bundle#2018-11-2520:50thhelleryeah thats what I mean#2018-11-2520:50thhellerthe file doesn't export any globals so you rewrite the file to make it work with CLJS?#2018-11-2520:51wilkerlucioyeah, I would do that#2018-11-2520:51wilkerlucioin this case is just 3 functions that are terrible to write in cljs 😛#2018-11-2520:53thhellercan't think of anything besides the usual cljsjs and shadow-cljsjs trick#2018-11-2520:53wilkerlucioit sucks so bad, for such a small thing -.-#2018-11-2520:56thhellerI'm not sure if you maybe can write it in Closure JS and just import it directly#2018-11-2520:56thhellershadow-cljs understands that but I'm not sure if CLJS does#2018-11-2520:56thhellerie. you add a goog.provide("some.ns.fuzzy") some.ns.fuzzy.fn = function ...#2018-11-2520:57thhellerit might work#2018-11-2520:58thhelleryeah I think that should work#2018-11-2520:58thhellertransit-cljs is importing transit-js that way#2018-11-2521:03thhellerhttps://github.com/cognitect/transit-js/blob/master/src/com/cognitect/transit.js#2018-11-2521:04thhellerprobably don't need the goog.scope stuff for your file since its so short#2018-11-2521:04wilkerluciointeresting, so if I make it like a google closure module I can import it directly in regular cljs?#2018-11-2521:04thhellerI'd suggest using the "older" model the closure lib uses#2018-11-2521:05thhellerbut yes you can import those directly#2018-11-2521:05thhellerhttps://github.com/google/closure-library/blob/master/closure/goog/string/string.js#2018-11-2521:05thhellerjust one goog.provide("some.ns")#2018-11-2521:05thhellerand then everything prefixed with some.ns.foo = function() ...#2018-11-2521:06thhelleror the way transit does it with goog.scope if you want local vars#2018-11-2521:06wilkerluciocool, I'll try the first#2018-11-2521:10wilkerlucio@thheller this works, awesome! thanks for saving me on this one 🙂#2018-11-2521:13wilkerlucioa new workspaces version will be out soon, I think you might like it, some fixes and improvements, including a better spotlight (using the new fuzzy search)#2018-11-2521:13thhellersweet. I need to get back actually coding a bit .. too busy with other stuff the past few weeks#2018-11-2521:27souenzzo
$ shadow-cljs server
shadow-cljs - config: /home/souenzzo/src/my-next-stack/shadow-cljs.edn  cli version: 2.7.6  node: v11.2.0
shadow-cljs - running: lein with-profile client,webdev run -m shadow.cljs.devtools.cli --npm server
Executable '' not found on system path.
'' should be lein 🙂
#2018-11-2521:29thhellerindeed. the error message is wrong#2018-11-2521:29thhellerbut it is looking for lein#2018-11-2521:30thhelleris lein found via which lein?#2018-11-2522:01souenzzoyep. already installed lein. Just reporting the wrong error message#2018-11-2522:01thhellerthx. just fixed it.#2018-11-2522:01souenzzohttp-root in devtools can be a array?#2018-11-2522:02thhellerno only one dir#2018-11-2522:02souenzzook#2018-11-2522:02thhellercould add support for multiple if you need#2018-11-2522:05souenzzoWith figwheel, I use output-dir on target/public/js/out then serve target/public and resources/public (my index.html is on resources/public/index.html )#2018-11-2522:06thhelleryou can set :http-resource-root "public"#2018-11-2522:06thheller(in addition to :http-root)#2018-11-2522:08souenzzoWhat is the difference between http-resource-root and http-root ???#2018-11-2522:08thhellerresources are served from the classpath#2018-11-2522:08thhellerhttp-root from the filesystem#2018-11-2522:11thheller(this assumes that resources is on the classpath, which is is by default in lein but not shadow-cljs.edn)#2018-11-2522:23souenzzoIt's already working nice 🙂#2018-11-2522:49souenzzowhen I try to start shadow from repl I get
(shadow/watch :main :cards)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
missing instance
#2018-11-2522:50thhellerthe server needs to be running when you run in embedded mode#2018-11-2522:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2018-11-2522:50thhellerthe server/start!#2018-11-2522:50thhellerand (shadow/watch :main) (shadow/watch :cards)#2018-11-2522:50thhellerit only takes one build arg from the REPL#2018-11-2523:12souenzzoIn shadow-cljs how I handle things like [fulcrologic/fulcro "2.6.15" :exclusions [cljsjs/react]] ?? Should I exclude in project.clj and just add in package.json?#2018-11-2602:00souenzzoI'm using shadow-cljs with this settings but: - I get No app connected. in Fulcro Inspect tab on console - after-load dont call cljs.user/on-jsload after load https://github.com/souenzzo/my-next-stack/blob/feature/shadow-cljs-wip/shadow-cljs.edn#2018-11-2609:33thheller@souenzzo why are you source files all over the place? kinda hard to tell whats going on#2018-11-2611:48souenzzoI always use project like this. is it a bad pattern?#2018-11-2609:33thhellerhow did you start the app?#2018-11-2609:34thhellerI'm guessing that you started the shadow-cljs server instance without having the webdev profile active?#2018-11-2609:34thhellercljs/user.cljs then instead uses the default which doesn't have the after-load hook#2018-11-2612:21souenzzoI'm using webdev profile user.cljs is loaded on browser and when I call cljs.user.on_jsload() on js console it works as expected....#2018-11-2610:04miridiusHi @thheller I'm getting a strange error during optimizations java.lang.NoSuchMethodError: com.google.javascript.jscomp.AbstractCompiler.getInputsInOrder()Ljava/lang/Iterable when releasing (even if optimization is just set to :whitespace), I've tried using --debug and -v but couldn't find any clues.#2018-11-2610:05miridius#2018-11-2610:05thhellerthat happens when an incompatible closure-compiler version is used#2018-11-2610:05miridius#2018-11-2610:05thhellercheck lein deps :tree#2018-11-2610:06thhelleryou'll probably see a complaint about closure-compiler-unshaded#2018-11-2610:06miridiusok thanks!#2018-11-2610:06thhellercan just add [com.google.javascript/closure-compiler-unshaded "v20180910"] to your :dependencies#2018-11-2610:06thhellerthat should take care of it but you may need to bump it manually in the future#2018-11-2610:07thhellersince closure updates about once a month#2018-11-2610:57heyarnehmm... i'm receiving some warnings that with the latest shadow-cljs 2.7 that i don't receive with the latest 2.6. what does that mean? why does it resolve things differently?#2018-11-2610:58thheller@arne-clojurians it doesn't resolve things differently. it just checks some extra things it didn't previously check.#2018-11-2610:58thhellerhttps://github.com/Day8/re-frame-10x/issues/219#2018-11-2610:58thhellerthe bug was always there just nobody noticed#2018-11-2611:01heyarneah cool. good to know!#2018-11-2614:50achikinI want to disable println for release code like this (set! *print-fn* (fn [& _])). What is the best way to achieve this in shadow-cljs? In lein-cljsbuild I've included different paths to :source-paths which contained cljs files with build-specific commands.#2018-11-2615:08achikin@thheller can I have different :source-paths for release and dev or is there any other way to inject different code for dev/release?#2018-11-2615:08thhelleryou can just do (when-not ^boolean js/goog.DEBUG (set! *print-fn* (fn [& _])))#2018-11-2615:09thhellerthat'll only silence the prints in release#2018-11-2614:57achikinI also have a question regarding build report https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report . Will it build AND generate a report or it will only generate a report on an existing build?#2018-11-2615:02thheller@achikin not sure I understand the question. it will compile everything to generate the report but it will not do a full build. if that makes sense 😛#2018-11-2615:05achikinThat makes a lot of sense, thank you 🙂#2018-11-2615:05achikinI want to generate the report as a part of a CI pipeline.#2018-11-2615:07thhelleryeah its a separate step from release as it modifies the build to ensure it can generate all the info it needs#2018-11-2615:07thhellerit requires source maps for example which release builds don't have enabled by default#2018-11-2615:06thheller@souenzzo oops I forgot that all cljs.* files are not checked for reload metadata because I assumed they would never have any#2018-11-2615:06thhellerso it doesn't ever check cljs.user. probably best to just pick another name#2018-11-2618:38rschmuklerHey all! Does shadow-cljs provide any way to access assets sometimes packaged with NPM (eg. CSS files)? If not, does anyone have any advice beyond requiring the stylesheet directly via a link tag to the node_modules?#2018-11-2618:58lilactownnope#2018-11-2618:59lilactownyou should probably move the CSS out of node_modules, though#2018-11-2619:14thheller@rschmukler not currently no. I use the node-sass cli and just a main.scss which directly @import "node_modules/foo/bar.scss";#2018-11-2619:15thhelleror just copy them all manually#2018-11-2619:16rschmuklerAlright, thanks for the quick responses! I just ended up vendoring the file directly and included it via a link element. We're using garden or I'd probably do the import route via sass#2018-11-2701:04heyarnei have a reagent view that i use for debugging. it lives in its own namespace and basically just looks like this: (defn debug [x] [:pre (with-out-str (pprint data))])#2018-11-2701:05heyarneit's required nowhere but still pprint ends up in the bundle#2018-11-2701:05heyarnecan i help google closure compiler with identifying this as unused code?#2018-11-2701:06thhellercljs.pprint can not currently be removed by closure#2018-11-2701:07thhellerso cljs.pprint itself is the problem and remains as soon as you import it#2018-11-2701:07thhellereven if unused#2018-11-2701:07heyarnei see. so i could try switching to zprint i guess?#2018-11-2701:09thhellerthey'll pretty much all remain in some form#2018-11-2701:09thhellerclosure doesn't remove defmulti/defmethod so as soon as that is used you are out of luck#2018-11-2701:09thhellerI think fipp was decently removeable#2018-11-2701:10thhellerbest to remove the code completely by not importing it in the first place 😉#2018-11-2701:12heyarneoh nice. yeah i just switched to fipp which shaved off 108kb (pre-gzip) off my build#2018-11-2701:12heyarnei'm always amazed by how quick i get answers here. thanks for all the support!#2018-11-2701:12heyarneshadow-cljs is amazing#2018-11-2701:52thhellerfun times in npm land. https://twitter.com/garybernhardt/status/1067111872225136640#2018-11-2702:55ClashTheBunnyIt steals your cryptocurrency wallet.#2018-11-2708:55thhelleryeah .. what else ... 😉#2018-11-2708:56thheller> he emailed me and said he wanted to maintain the module, so I gave it to him. I don't get any thing from maintaining this module, and I don't even use it anymore, and havn't for years.#2018-11-2708:56thhellerjust lol ...#2018-11-2709:09thhellertime to rethink this container business I guess 😉#2018-11-2711:13achikinThat is AWESOME! https://gifyu.com/image/Tr8i#2018-11-2711:14achikinI made a small demo of adding npm dependency to a running watch build.#2018-11-2713:21jcbI know this must have come up before, but I can't find a definitive answer. I've been using https://github.com/thheller/lumifoo as a guide to integrate shadow-cljs into a luminus project. However every time the watch socket updates the browser I get a an error "Target container is not a dom element" - what do I need to change to remedy this? thanks! - to clarify I'm just running this repo for testing with a couple of non-breaking dependency bumps and npm for react/dom etc#2018-11-2714:24thheller@jcb that error is from react when the element does not exist#2018-11-2714:24thhellerso there is no #navbar or #app in the HTML maybe?#2018-11-2714:25thhellercan really remember what that repo was about#2018-11-2714:25thhellerjust check if the HTML matches what the code expects#2018-11-2714:48jcbhi thanks for the example repo, I checked before asking and it's all fine. I think it might have something to do with the way the history is working with the page routing. I'll probably just move on and try to adapt a more recent version of the luminus template and see how I go. cheers!#2018-11-2715:05jcbactually, is there any other full stack frameworks that you could suggest that work well with shadow-cljs?#2018-11-2715:05jcbI don't program full time, just occasionally as a tool for work, so I can't really try everything out. I've used luminus as it has has good documentation and covers all the bases with sensible defaults but I'd be open to changing things up.#2018-11-2715:05thhellerfulcro is nice#2018-11-2715:10jcbthanks, i did give it a go a while back but it wasn't quite so easy to get into. Also om next seemed quite daunting compared to reagent#2018-11-2715:12jcbperhaps now that I've made a couple of things it might make more sense#2018-11-2715:16jcbhttp://book.fulcrologic.com <---- I'm pretty sure this didn't exist back then. looks great#2018-11-2716:32mj_langfordCrytpocurrency finally made malware stop trying to steal WoW account credentials.#2018-11-2717:29eoliphanthey guys, I ran into an issue, where I was trying to use a local version of an npm lib, that was installed via npm install <pkg dir>. During the release build it throws a “ExceptionInfo: files outside the project are not allowed: ” Have the same issue if you try an npm link#2018-11-2717:35eoliphantyeah @jcb Fulcro is a bit more to get into up front, especially compared to say reagent, etc. But, I’ve found more than once, that by the time you get done pulling in other libs, and creating some of your own utilities, etc etc you end up with a good subset of what Fulcro gives you out of the box.#2018-11-2717:51wilkerlucioalso fulcro tooling has been evolving a lot lately, that's a big thing to do if you are trying to make your own stuff, IMO (disclaimer: I wrote some of those) Fulcro has top grade tools for web development (db inspector, transaction log, network log, query running built-in, tracer if used with pathom...)#2018-11-2717:54thheller@eoliphant symlinks or npm link should be allowed depending on the version you are on. forgot which version I add that though, might need to upgrade?#2018-11-2718:16eoliphantok, looks like 2.4.22 will upgrade and give it a whirl#2018-11-2718:34eoliphantjust went to 2.7.6 and still seeing the same thing 😞#2018-11-2721:58achikinFrom the docs (:require ["module-name" :refer (export)]) - why does :refer block is not in square brackets as usual?#2018-11-2722:25thheller@achikin it doesn't matter. use what you prefer. I prefer a list for :refer. vector or even sets are fine too#2018-11-2722:26thheller@eoliphant are you sure its linked properly and wasn't installed nested somewhere#2018-11-2722:26thhellernode_modules/foo -> ../../whatever/foo?#2018-11-2722:27eoliphantI think so. But will check it again when I get home#2018-11-2723:36richiardiandreaso I have a failure in my release functions:
[2018-11-27T23:26:20.408Z]  INFO: scrutinize-event-fn/10976 on RD28187871EEEA: interceptor error (function=scrutinize-event-fn, :namespace=cljs.user, :level=info, retry-counter=0, trace-id=3
aa0f630-2610-4cb4-9f51-8000fda9a3b8, error={})
    Error: [object Object] is not ISeqable
        at Object.cljs.core.seq (D:\home\site\wwwroot\cljs\shared.js:6731:9)
        at Function.cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:8386:25)
        at Function.cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:8463:136)
        at Object.cljs.core.vec (D:\home\site\wwwroot\cljs\shared.js:15652:235)
        at Function.cljs.core.async.map.cljs$core$IFn$_invoke$arity$3 (D:\home\site\wwwroot\cljs\shared.js:59880:19)
        at Function.cljs.core.async.map.cljs$core$IFn$_invoke$arity$2 (D:\home\site\wwwroot\cljs\shared.js:59877:30)
        at Object.laputa.scrutinize_fn.fx.command_commit_event_BANG_ (D:\home\site\wwwroot\cljs\shared.js:65920:120)
        at laputa.scrutinize_fn.interceptor.commit_event_BANG_ (D:\home\site\wwwroot\cljs\shared.js:66027:34)
        at Object.sieppari.core.try_f (D:\home\site\wwwroot\cljs\shared.js:55118:89)
        at sieppari.core.leave (D:\home\site\wwwroot\cljs\shared.js:55133:202)
I was wondering how can I see the source mapped version with release?
#2018-11-2723:38thhellershadow-cljs release the-build --source-maps#2018-11-2723:38thhelleror shadow-cljs release the-build --debug (for source maps + pseudo-names)#2018-11-2723:39thhellerlaputa.scrutinize_fn.fx.command_commit_event_BANG_ guess you are running :simple?#2018-11-2800:05richiardiandreayep I am running simple at the moment, I did not know I needed a switch, I do have :source-maps true#2018-11-2800:06thhellerits :source-map true I think#2018-11-2800:06thhellercan never remember if its source-map or source-maps#2018-11-2800:06richiardiandreayep I have:
:release {:compiler-options {:optimizations :simple
                                              :variable-renaming :off
                                              :property-renaming :off
                                              :pretty-print true
                                              :source-map true}
                           :autorun false}
#2018-11-2800:10richiardiandreaI will double check if source-map-support is in the deployed node_modules together with the .map#2018-11-2800:13thhellerah yeah you need to set that up manually#2018-11-2800:13thhellerits only loaded in dev by default#2018-11-2800:13richiardiandreaoh#2018-11-2800:13thhellernode -r source-map-support your-script.js or however that works#2018-11-2800:13richiardiandreamay I ask why? the vanilla compiler does that IIRC, is there any performance impact?#2018-11-2800:14richiardiandreayeah well I am not in control of what is passed to node#2018-11-2800:18thhellerdunno if its injected by default. I don't use node much.#2018-11-2800:18thhellerhttps://www.npmjs.com/package/source-map-support#2018-11-2800:18thhellernode -r source-map-support/register compiled.js#2018-11-2800:20richiardiandreait seems like it is required, I can add it manually for sure - maybe I can open an issue and actually contribute it#2018-11-2800:20richiardiandreahttps://github.com/clojure/clojurescript/blob/1d1cee6d30033ff6a360edbfbb4492b55d4a4496/src/main/clojure/cljs/closure.clj#L1689#2018-11-2800:20thhellerthats the dev build#2018-11-2800:26richiardiandrearight, for a second I remembered differently#2018-11-2723:51lilactownI have a build like so:
:browser-tests {:target :browser-test
                          :test-dir "target/browser-tests/"
                          :module-loader true
                          :ns-regexp "-test"
                          :runner-ns runner.core
                          :devtools  {:http-port 8021
                                      :http-root "target/browser-tests/"}}
for some reason, this works perfectly fine on my computer but not on my coworkers. I'm using macOS and she is using Windows, though I don't think that's the issue
#2018-11-2723:52lilactownin her file system, I see the test.js built correctly, however it responds with a 404 from the shadow-cljs HTTP server#2018-11-2723:53thhellerremove the trailing slash from :http-root
#2018-11-2723:53thhellerwindows is picky like that#2018-11-2723:53thhelleralso :test-dir#2018-11-2723:58lilactownhmm that hasn't seemed to fix it#2018-11-2723:59thhellerhmm#2018-11-2812:50souenzzowhen I run shadow-cljs with jvm11 it says Warning: Nashorn engine is planned to be removed from a future JDK release Is it a know issue?#2018-11-2900:14souenzzoBump?#2018-12-0508:14fugbixedhttps://jaxenter.com/graalvm-nashorn-interview-147115.html this might give you a hint#2018-12-0508:17fugbixedand that https://docs.oracle.com/en/java/javase/11/docs/api/jdk.scripting.nashorn/module-summary.html#2018-11-2812:52achikinCan't compile https://github.com/funcool/decimal with shadow-cljs#2018-11-2812:52achikinThe error is The required namespace "decimal.extern.decimaljs" is not available, it was required by "decimal/core.cljs".#2018-11-2812:53achikinI have asked in the funcool channel directly, but maybe somebody has a clue...#2018-11-2812:55achikinhttps://github.com/funcool/decimal/blob/master/src/decimal/core.cljs#L2#2018-11-2813:02achikinhttps://github.com/funcool/decimal/blob/master/assets/deps.cljs#2018-11-2813:07thhelleryeah pretty much all funcool libs contain some kind of foreign lib#2018-11-2813:07thhellerI already added the shim for a few#2018-11-2813:07thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cuerdas/vendor/xregexp.cljs#2018-11-2813:08thhellerits probably an npm package that needs to be exported to some global#2018-11-2813:08achikinCould that be fixed through shadow-cljs.edn config?#2018-11-2813:09thhellerno#2018-11-2813:09thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-11-2813:10thheller(ns decimal.extern.decimaljs (:require ["decimal.js" :as dec])) (js/goog.exportSymbol "something" dec)#2018-11-2813:11thhellerhappy to add it to https://github.com/thheller/shadow-cljsjs#2018-11-2813:11thhellerjust no idea which global it expects#2018-11-2813:14achikinThank you, I'll have a look!#2018-11-2813:17thhellerseems like its Decimal#2018-11-2813:18achikinDo I understand correctly from this https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js that I can use the decimal.js file, packaged inside [funcool/decimal] jar instead of installing it from npm?#2018-11-2813:18thhellerno#2018-11-2813:18achikinBut Absolute requires like /some-library/components/foo mean that the compiler will look for a some-library/components/foo.js on the classpath;#2018-11-2813:18thhellergenerally yes but you definitely don't ever want to do this for packaged sources#2018-11-2813:19thhellerjust include it from npm if you want it done properly#2018-11-2813:19thhellerno guarantee that it will even work at all when importing from the classpath#2018-11-2813:19thhellersince classpath goes through :advanced#2018-11-2813:20achikinI wanted to reuse that one for the sake of compatibility...ok, I got that.#2018-11-2813:20achikinThank you for clarifying!#2018-11-2813:20thhelleryeah foreign-libs on the CLJS side are not processed at all and just prepended#2018-11-2813:21thhellerJS from the classpath is actually fully processed so you typically only want to do it for you own sources#2018-11-2814:53achikinGot another one 🙂
File: ...
failed to require macro-ns "clojure.core.strint", it was required by "..."
FileNotFoundException: Could not locate clojure/core/strint__init.class or clojure/core/strint.clj on classpath.
#2018-11-2815:02achikinOh, sorry. Seems like strint was moved from the core....#2018-11-2815:02achikinI wonder how did it work under lein-cljsbuild...#2018-11-2815:04achikinOh, I had core.incubator in leiningen dependencies...#2018-11-2815:20thhelleryeah it was never in core#2018-11-2817:48iha2How do you load a file with shadowcljs repl.#2018-11-2817:49iha2I keep trying but I keep getting a “file not found in classpath” errors.#2018-11-2817:49iha2sorry if this is a simple question.#2018-11-2817:49iha2I’m using load-file to try and reach the file.#2018-11-2817:50ClashTheBunnyWhich repl are you in?#2018-11-2817:50iha2cljs-repl I guess.#2018-11-2817:50ClashTheBunnyIn a specific build-id?#2018-11-2817:51iha2yup#2018-11-2817:51ClashTheBunnyBrowser?#2018-11-2817:51iha2script#2018-11-2817:51thheller@iha2 it is not currently possible to load files that are not on the classpath#2018-11-2817:52iha2It’s in the folder of the parent app.#2018-11-2817:52iha2Does that make it in the classpath.#2018-11-2817:52thhelleryou can (require '[some.ns :as x]) as normal but load-file is limited to files in your :source-paths#2018-11-2817:53iha2ok cool it’s in there#2018-11-2817:53thhellerit must also have an ns form.#2018-11-2817:53iha2it does#2018-11-2817:55iha2(load-file "DailyProgrammer/single_symbols_squares.cljs")#2018-11-2817:55iha2DailyProgrammer is in src#2018-11-2817:55iha2is that correct?#2018-11-2820:35aisamuIs it possible to have a cljs REPL connected to an :npm-module target?#2018-11-2820:48thheller@iha2 no you need the full path from the project root or an absolute path#2018-11-2823:09Bravihi everyone. I’m trying to use firebase npm module with my app and I’m having issues importing things from the module. for example, when I try to
(:require ["firebase/database" :as database])
it comes up as an empty object
#2018-11-2823:10Bravibut some things work, like for example if I do
(:require ["firebase/app" :as firebase])
#2018-11-2823:11Braviany ideas anyone, what could be causing this?#2018-11-2823:25flyboarder@bravilogy is this for nodejs or browser?#2018-11-2823:41Braviit’s for browser#2018-11-2823:26flyboarderyou probably want ["firebase/database"] instead, and initialize with (def database (.firestore firebase))#2018-11-2823:28flyboarderor something like that, I have a really old firebase library here: https://github.com/degree9/firebase-cljs see how things are initialized#2018-11-2823:37Braviyeah it seems to work with cljsjs#2018-11-2823:37Bravican’t figure out what I’m missing 😕#2018-11-2823:37Bravidamn it#2018-11-2823:44Braviok I think I figured it out. I think I just have to do
(:require ["firebase/app" :as firebase]
          ["@firebase/database"])
#2018-11-2900:27flyboarder@souenzzo this is a java 11 thing, not specific to shadow-cljs#2018-11-2905:01richiardiandreaHi Thomas (sorry for the previous mention) - would you be interested in a "community maintained" branch 2.6.x but against Cljs 1.10.339? It seems like there are problems with source maps and expound and I was wondering if I can backport a couple of patches from 2.7.x except the cljs one#2018-11-2908:45thheller@richiardiandrea no. I'd much rather look at the problems and fix them. so far I haven't heard of any problems though.#2018-11-2909:50romdoqWhen running a :browser-test build of my project, it looks like specs don't get cleared when hot reloading, so some tests appear to still work until the page is reloaded and the registered specs cleared. I've just been re-namespacing a bunch of my specs, and was confused why tests weren't failing when I knew they should. Is this a (known?) issue, or might I have just misconfigured something?#2018-11-2909:58thhellerjust reload the page to get rid of old tests. they do are not currently removed properly that is true#2018-11-2910:00thheller@richiardiandrea I assume this is the source map problem you mentioned? https://dev.clojure.org/jira/browse/CLJS-2993 added a patch for that. whats up with expound?#2018-11-2910:06romdoqthat's what I thought, thanks. Should I file an issue for the old specs not being removed?#2018-11-2910:06thhelleryes please otherwise I forget again#2018-11-2910:57aisamuGood morning! Is it possible to have a cljs REPL connected to an :npm-module target? ProtoREPL works with the base REPL, but as soon as I change to the build repl no further command works (even though the ns changes to cljs.user, and the message for :cljs/quit appears)#2018-11-2911:01thheller@aisamu its a bit complicated for :npm-module given that we are not in control how the JS is loaded#2018-11-2911:01thhellerit is sort of possible if you require("shadow-cljs/shadow.cljs.devtools.client.browser") from the JS#2018-11-2911:02aisamuI see, thanks! Will give it a try later today#2018-11-2911:52romdoq@aisamu fwiw, I'm having good success using something like this in my main CLJS entry point:
(goog-define EMBEDDED_DEV false)
(when EMBEDDED_DEV
  (defonce _dirty_repl_hack
    (js/require "my-module/build/npm/shadow.cljs.devtools.client.browser")))
This doesn't require anything additional in the embedding javascript project, and will get optimized away in release builds
#2018-11-2916:32vigilancetechwhen I launch my app like this: $ electron public/main.js it gives me this:
REPL client error { Error: connect ECONNREFUSED 192.168.43.81:9630
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '192.168.43.81',
  port: 9630 }
REPL client disconnected
and now cider-connect-cljs gives me a failed error. 9630 isn't my repl port. It's the shadow console port. I've tried blowing off ~/.cache and .shadow-cljs in the project dir. Also rmmed .nrepl-port in the project dir. How do I fix?
#2018-11-2916:35vigilancetechwhen I visit localhost:9630 I get:
shadow-cljs
Project: /home/kevin/0work/guardian-dashboard
Release Snapshots
#2018-11-2916:36vigilancetechrather than the normal shadow console#2018-11-2917:01thheller@vigilancetech 9630 is the default port used by the shadow-cljs webserver which serves the websockets used for the REPL#2018-11-2917:01thhellerbut it only typically connects to localhost? not sure why it tries to connect to an IP?#2018-11-2917:01thhellerdid you set some related config in the :devtools?#2018-11-2917:08thhelleralso you may want to upgrade if 9630 still shows "Release Snapshots"#2018-11-2917:08thhellersounds like a rather old version#2018-11-2918:11aisamuGood afternoon! Is it possible to locate the (simple) externs file somewhere else? A quick glance at the source seems to indicate that no, but I'd rather be sure! (a symlink is working) And is there a reason for keeping inference warning on properties that are defined in the externs file? I've hinted things covered by the externs just to clear the warnings - they're very useful and I didn't want to add noise there.#2018-11-2920:03vigilancetech
:devtools {:http-root "public"
                                :http-port 8080}}

#2018-11-2920:16vigilancetech@thheller I just updated to {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d0a3b8b1b4bfa7fdb3bcbaa390e2fee7fee6"}, :content ("[email protected]")} and I get the same error#2018-11-2920:25thheller@aisamu no idea what you are talking about. if you add hints you don't need to define them anywhere else?#2018-11-2920:27aisamuWhen I add hints I don't have to define externs because that's taken care of. But when I add externs without hints, even though the final code is correct (doesn't munge the calls I've asked) I still get the "Cannot infer type" warning.#2018-11-2920:28thhellerah now I get it#2018-11-2920:29aisamuOn this specific instance I'd prefer hints because this will probably be used in a lot of places... (immutableJS's toJS(), get and so on). Adding hints clears the errors and the warnings. Adding externs clears the errors only.#2018-11-2920:29thhellerah yeah thats a bug#2018-11-2920:31thhellerplease open an issue. the simplified externs are just not token into account for the externs inference thats all#2018-11-2920:32aisamuGot it, thanks! And, regarding their location, is there a way (even if hacky) to specify a place other than externs/build.txt?#2018-11-2920:33thhellernot currently no but I can add a config option for that if you need#2018-11-2920:36aisamuThat'd be very nice! It's mainly for consistency with the existing project's structure. (JS, with shadow-cljs painlessly bolted on. Thanks for this lovely tool!)#2018-11-2920:44currentoori just realized server mode picks up changes to shadow-cljs.edn without needing a restart!#2018-11-2920:44currentoorthat’s really cool!#2018-11-2920:45thhelleryou can do pretty much everything without a restart. only changing CLJ(S) deps currently requires restart#2018-11-2920:46currentooryou’re putting other build tools to shame lol#2018-11-2922:51macrobartfast@thheller you are getting compliments at the Clojure Conj for being very helpful to folks.#2018-11-2923:27lilactownthheller is a saint#2018-11-3000:49richiardiandreaI can only confirm that, even folks that haven't tried shadow 😃 #2018-11-3001:16vigilancetech@thheller I did npm i shadow-cljs -g and it gave me that version I pasted above, but its still giving me release snapshots on the console. How do I tell what version of shadow is actually executing? I don't see any -version option#2018-11-3001:31lilactown@vigilancetech you also should install shadow-cljs as a dependency in your application's project. the shadow-cljs command will use whatever version of it is installed in your project#2018-11-3002:05vigilancetech@lilactown hmm... my project dependency file doesn't have any dep for shadow. Wouldn't it automatically be using the newest installed then?#2018-11-3002:06lilactownYou should install it locally in your projects package. Json#2018-11-3008:16thheller@vigilancetech yeah I absolutely recommend installing shadow-cljs in your project. easier to ensure you get the correct version#2018-11-3008:16thhellerthe global install you don't really need.#2018-11-3009:39pezI need some advice. For two of the Calva extensions to VS Code I have a shadow-cljs based tool-chain, where TypeScript is used to create the extension entry point and shadow-cljs is used to compile the ClojureScript code into a JavaScript library that the TypeScript code then consumes. For when the extensions need to share logic I have so far relied on them exposing API:s to each other. But this creates a dependency between them that I rather not want to have. So I am leaning towards creating a lib that is published in a way that all my extensions can use. The options I see are either to build a CLJS library that I can put on clojars, or a JS library that I publish as an NPM module. Do I have other options that I don't see? (I think that a CLJS library makes the most sense, but am not fully clear about what my tradeoffs are.)#2018-11-3009:41thhellernot sure what you mean. typescript can't consume clojars?#2018-11-3009:41pezNo, it would be the CLJS that consumed that.#2018-11-3009:43thhellerbut how does it all work together in the end?#2018-11-3009:44thhellerif you have 3 different builds then you'll have 3 different cljs.core versions#2018-11-3009:44thhellerthat are each not compatible with each other#2018-11-3009:44pezNot sure I am following…#2018-11-3009:44thhellerso when they talk to each other you always have to serialize the data#2018-11-3009:45thhellerI don't quite understand why you have different extensions and how they interact with each other#2018-11-3009:45thhellerdo they interact at all?#2018-11-3009:45thhellerand how is typescript involved in any of it?#2018-11-3009:46pezTypeScript is what I use to integrate into VS Code. (I have changed this quite a few times, but the only thing that really worked for me was this setup.)#2018-11-3009:47pezThey are different extensions because they solve different enough problems, so someone can use some other REPL extension and still use Calva Formatter (for instance).#2018-11-3009:49pezI also have a third extension, Calva Paredit, that is still TypeScript only, but that I am going to change to the same toolchain so that I can use some of functions that I have developed for the formatter.#2018-11-3009:49thhellerso with CLJS you want to avoid splitting things as much as possible#2018-11-3009:50thhellersince the whole idea of whole-program-optimizations breaks pretty badly if you don't have the whole program#2018-11-3009:50thhellerso what I would probably do is create a "calva-core" library#2018-11-3009:50pezYes, one CLJS lib for all Calva common things.#2018-11-3009:50thhellerthat contains everything you want#2018-11-3009:50thhellerand then have the typescript parts expose the parts you want to vscode#2018-11-3009:51thhellerbut only have one CLJS build for everything#2018-11-3009:51thhellercould be using :npm-module#2018-11-3009:52thhelleror :node-library depending on how many exposed API's you actually need#2018-11-3009:53pezAh, but I never got the :npm-module working last time I tried it. So went back to :node-library even though the API is pretty thick.#2018-11-3009:54pezWhy is one-lib preferable over each extension having its own CLJS lib that each are using a common lib?#2018-11-3009:55thhellerwhen you compile clojurescript it always implicitely contains cljs.core#2018-11-3009:55thhellerso if you have 3 separate libs you have 3 separate cljs.core "instances"#2018-11-3009:55pezOh#2018-11-3009:55thhellerwhich means that map instances from plugin-A cannot be accessed by B+C directly#2018-11-3009:55thhellersince they are different types#2018-11-3009:56pezI see. Good that I asked about this!#2018-11-3009:59pezBut, sorry if I am a bit thickheaded, I use libraries from Clojars all the time, and have never seen this problem. Aren't they compiled into my code just like any other code?#2018-11-3010:00thhellerbuilds not libraries#2018-11-3010:00thhellerlibraries are uncompiled .cljs files#2018-11-3010:00thhellerbuilds are compiled .js files#2018-11-3010:00thhellerimportant distinction#2018-11-3010:00thhellerBUILDS can't talk to each other easily#2018-11-3010:01pezThe extensions do not need to talk to each other, really.#2018-11-3010:17pezI only need them to be able to share some code.#2018-11-3010:22thhellerI just published a demo repo showing what I would probably do#2018-11-3010:22thhellerhttps://www.npmjs.com/package/@shadow-cljs/npm-module-demo#2018-11-3010:23thhellernpm i @shadow-cljs/npm-module-demo then require("@shadow-cljs/npm-module-demo")#2018-11-3010:23thhellerwhich will give you https://github.com/thheller/npm-module-demo/blob/master/src/main/foo/bar.cljs#2018-11-3010:23thhellerrequire("@shadow-cljs/npm-module-demo").hello("x")#2018-11-3010:24thhellersame as require("@shadow-cljs/npm-module-demo/foo.bar").hello("x")#2018-11-3010:24thhellerrequire("@shadow-cljs/npm-module-demo/foo.baz").hello("x") to access the other ns#2018-11-3010:25thhellerdoesn't need to be a scoped package. just didn't want to create another "global" dummy package on npm#2018-11-3010:25thhellerso say you publish calva-core to npm that way#2018-11-3010:26thhellerthe typescript code can then just require("calva-core/foo.bar") so get access to whatever CLJS fn it needs#2018-11-3010:26thhellerBUT this important bit here is that you only have one compiled CLJS version#2018-11-3010:27thhellerof course that is totally optional but with 3 different extensions that means cljs.core will only be loaded once#2018-11-3010:27thhellerreducing memory and load time and stuff#2018-11-3010:27thhellerand the 3 extensions can actually talk to each other if needed#2018-11-3010:27thhellerthat might not make sense at all#2018-11-3010:28thhellerstill don't understand what role the typescript plays in all of this of how much of the code you actually share#2018-11-3010:36pezThanks a lot! I'll have a look at this and see where it takes me.#2018-11-3010:55pezWill the CLJS code have as easy access to the functions in this module as well? Seems like it will publish a JS API. Which is not too much of a bother, I am mainly curious.#2018-11-3010:56thhellerthe CLJS in calva-core can talk to any other CLJS in calva-core but not to any other CLJS not in calva-core#2018-11-3010:58pezI will need to play with it to get it. Super duper help, thanks again.#2018-11-3011:00thhellerthe only thing to remember really is your builds. a CLJS build can only consume uncompiled CLJS code, it can never consume compiled CLJS code (macros would not work)#2018-11-3011:00thhellerso if you want 3 separate CLJS builds than putting a uncompiled CLJS library on clojars is your only option#2018-11-3011:01thhellerif you however have 3 separate typescript builds then putting one compiled CLJS build on npm is fine#2018-11-3011:46pezI currently have three separate TS builds and two separate CLJS builds, but I'm willing to try something else. 😃#2018-11-3011:54thhellerI would probably get rid of the TS completely but if that is important to you it should be fine#2018-11-3012:01pezIt is only important to me because it was the only way I could get my development process work.#2018-11-3012:34achikin@thheller do you support :warnings under :compiler-options?#2018-11-3013:29thheller@achikin I'm not actually sure. I'd think so?#2018-11-3013:46thhellerhmm no I guess I don't. do you need it? never came up before#2018-11-3014:30achikinNot that much. I have some deprecation warnings that annoy me a bit.#2018-11-3014:31achikin
2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling shadow/build/compiler.clj at (455:13)
1. Caused by java.lang.RuntimeException
   Unable to resolve var: comp/*source-map-data-gen-col* in this context
#2018-11-3014:32achikinI'm trying to run shadow-cljs from within cider.#2018-11-3014:32thhellerwrong CLJS version#2018-11-3014:32thhellershadow-cljs 2.7.x requires CLJS 1.10.439+#2018-11-3014:32achikinThat was my first guess, so I've removed cljs dependency from project.clj#2018-11-3014:32thhelleryou are using an older CLJS version probably#2018-11-3014:32thhellerdon't do that when using project.clj#2018-11-3014:33thhellerits undefined which cljs version you'll get then#2018-11-3014:33thhellersince it'll pick the first one encountered. not the latest one.#2018-11-3014:34achikinThank you, I'll introduce it back.#2018-11-3014:37thhelleror don't use project.clj. the problem is taken care of in shadow-cljs.edn 😉#2018-11-3015:14achikinI have quite big server-side project.clj 😞#2018-11-3015:14achikin
Show: Project-Only All 
  Hide: Clojure Java REPL Tooling Duplicates  (23 frames hidden)

1. Unhandled clojure.lang.ExceptionInfo
   missing instance
   {}

                  core.clj: 4739  clojure.core/ex-info
                  core.clj: 4739  clojure.core/ex-info
               runtime.clj:   11  shadow.cljs.devtools.server.runtime/get-instance!
               runtime.clj:    8  shadow.cljs.devtools.server.runtime/get-instance!
                   api.clj:  130  shadow.cljs.devtools.api/worker-running?
                   api.clj:  128  shadow.cljs.devtools.api/worker-running?
                   api.clj:  207  shadow.cljs.devtools.api/watch
                   api.clj:  201  shadow.cljs.devtools.api/watch
                   api.clj:  205  shadow.cljs.devtools.api/watch
                   api.clj:  201  shadow.cljs.devtools.api/watch
                      REPL:    1  user/eval55989
                      REPL:    1  user/eval55989
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7051  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
                  core.clj: 1965  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   85  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  clojure.tools.nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  222  clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    interruptible_eval.clj:  190  clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
                  AFn.java:   22  clojure.lang.AFn/run
   ThreadPoolExecutor.java: 1142  java.util.concurrent.ThreadPoolExecutor/runWorker
   ThreadPoolExecutor.java:  617  java.util.concurrent.ThreadPoolExecutor$Worker/run
               Thread.java:  745  java.lang.Thread/run
#2018-11-3015:15achikinFor some reason I can't connect from emacs#2018-11-3015:15achikinI'm running shadow-cljs server separately, but still no luck#2018-11-3015:16thhellershadow-cljs server starts its own instance with its own nrepl server#2018-11-3015:16thhellerbut the above error suggests that you are not connected to that#2018-11-3015:16thhellerbut instead some other JVM running an nrepl server (that happens to have the shadow-cljs dependency loaded)#2018-11-3015:17thhelleryou can use the embedded version https://shadow-cljs.github.io/docs/UsersGuide.html#embedded if you prefer running shadow-cljs inside your other JVM#2018-11-3015:17thhellerthen you don't need the separate shadow-cljs server instance#2018-11-3015:18thhellerFWIW it doesn't matter how large your server-side is. it is perfectly fine to use project.clj for the server-side and shadow-cljs.edn for the CLJS side of things#2018-11-3015:18thhellerbut yeah tooling like emacs makes that pretty annoying#2018-11-3015:19thhellerso you probably want to be using the embedded version instead#2018-11-3015:19achikinDoh. I'll probably make some PRs both to cider and shadow docs after the weekend 🙂#2018-11-3015:21thhellerI don't use emacs and the setup seems to be changing somewhat regularly. so the instructions somehow constantly change and its impossible for me to keep up.#2018-11-3015:22thhellerI can't get it working at all anymore 😛#2018-11-3015:39achikinMe either 😞#2018-11-3015:39achikin
1. Unhandled java.lang.IllegalStateException
   Can't change/establish root binding of: *nrepl-cljs* with set

                  Var.java:  223  clojure.lang.Var/set
                   api.clj:  361  shadow.cljs.devtools.api/nrepl-select
                   api.clj:  356  shadow.cljs.devtools.api/nrepl-select
                   api.clj:  358  shadow.cljs.devtools.api/nrepl-select
                   api.clj:  356  shadow.cljs.devtools.api/nrepl-select
                      REPL:    1  user/eval73496
                      REPL:    1  user/eval73496
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7052  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java:  137  clojure.lang.RestFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  657  clojure.core/apply
                  core.clj: 1965  clojure.core/with-bindings*
#2018-11-3015:40thhellerthis means that the nrepl middleware is not used#2018-11-3015:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2018-11-3016:59vigilancetechok, I've installed shadow 2.7.6 both globally, in my project directory, in the devDependencies in package.json, and as a dependency of my project in shadow-cljs.edn and THIS is what I get when I start the server in the project directory: shadow-cljs - config: /home/kevin/0work/guardian-dashboard/shadow-cljs.edn cli version: 2.3.24 node: v8.12.0 Why? Is there a cache somewhere I need to clean out first?#2018-11-3017:03vigilancetechdoing a global grep of my project folder shows no file contains "2.3.24" anymore#2018-11-3017:08thheller@vigilancetech what are ytou using to start? lein or deps.edn? probably not just shadow-cljs.edn right?#2018-11-3017:10thhellerwhat does /home/kevin/0work/guardian-dashboard/node_modules/shadow-cljs/package.json say?#2018-11-3017:13vigilancetechoh, sorry, I was wrong about nothing saying "2.3.24". I was using grep from within emacs and it just was very slow in returning results. I must have been swap bound. There are a lot of instances of that in that file under node_modules. No, I'm just using shadow cli version with the shadow-cljs.edn file#2018-11-3017:14thhellerthe only file of interest to me is the one above#2018-11-3017:14thheller> There are a lot of instances of that in that file under node_modules.#2018-11-3017:14thhellerno clue what that means#2018-11-3017:14vigilancetech
{
  "_from": "
#2018-11-3017:15thheller> "version": "2.3.24"#2018-11-3017:15thhellerclearly says which version is being used?#2018-11-3017:16vigilancetechyes, right, but I did the npm i shadow-cljs in my project folder after changing the package.json shadow version. I have to change it here too?#2018-11-3017:16thheller/home/kevin/0work/guardian-dashboard/package.json#2018-11-3017:16thhellerwhich version is declared in there?#2018-11-3017:17vigilancetech
{
    "name": "guardian-dashboard",
    "version": "3.3.2",
    "description": "UI to JBOG guardian server",
    "main": "guardian/dashboard.js",
    "directories": {
        "doc": "doc"
    },
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
        "type": "git",
        "url": "git+"
    },
    "author": "Jessie Umblerg/Kevin Haddock",
    "license": "private trade secret",
    "bugs": {
        "url": ""
    },
    "homepage": "",
    "dependencies": {
        "electron": "^3.0.6",
        "jquery": "^3.3.1",
        "markdown": "^0.5.0",
        "npm": "^6.4.1",
        "querystring": "^0.2.0",
        "url": "^0.11.0",
        "util": "^0.11.0"
    },
    "devDependencies": {
        "shadow-cljs": "^2.7.6"
    }
}
#2018-11-3017:17thhellerso something does not add up#2018-11-3017:17thhellerdid you actually npm install or just edit the package.json manually?#2018-11-3017:18vigilancetechactually I think I did npm i shadow-cljs after editing it manually#2018-11-3017:18vigilancetechand it confirmed it installed 2.7.6#2018-11-3017:18thhellerthe old version is still installed though#2018-11-3017:18thhellerdid you run it in the correct directory?#2018-11-3017:18vigilancetechpretty sure. I can try it again#2018-11-3017:19vigilancetechall my terminal sessions are in that directory#2018-11-3017:19thhellerotherwise the good old rm -rf node_modules && npm install#2018-11-3017:21vigilancetechok, I just did an npm i in that directory and now the package.json in the node_modules/shadow-cljs says 2.7.6#2018-11-3017:23vigilancetechI'm pretty sure I ran the npm i shadow-cljs in there after changing the version in the package.json in the project's home folder and making it a dep in the shadow-cljs.edn and it didn't properly update it (even tho it said it did). I'll have to check that out again next time shadow's version number gets bumped to see if it does the same thing again.#2018-11-3017:24thhellernpm can be funky like that#2018-11-3019:42Wilson Velezare npm included libraries analyzed by google closure to eliminate not accessible code?#2018-11-3019:47lilactownno, they're treated as foreign libraries AFAIK#2018-11-3020:07thhellerthey are run through closure but only with :simple optimziations. it does some DCE but not the real stuff.#2018-11-3020:07thheller@lilactown they are processed and not treated like foreign libs#2018-11-3020:07lilactownTIL!#2018-11-3020:08thhelleractual foreign libs in CLJS are not processed at all but thats partly why shadow-cljs doesnt support those 😛#2018-12-0100:46jstaabHey there, can anyone tell me how to avoid name mangling using the node-library target? Here's my shadow-cljs.edn:
{:source-paths ["src"]
 :builds
 {:my-lib
  {:target :node-library
   :output-to "lib/my-lib.js"
   :exports-fn my-lib.js/generate-exports}}}
And my file:
(ns my-lib.js
  (:require [my-lib.core]))

(defn generate-exports []
  (clj->js my-lib.core))
#2018-12-0100:48jstaabThe file contains all the usual stuff, but what's weird is some functions get mangled and some don't for no apparent reason; they're defined the same way, but when I import them from nodejs, I get stuff like:
split: { [Function: d] A: [Function: c], a: [Function: b] },
     gc: { [Function: d] A: [Function: c], a: [Function: b] },
#2018-12-0100:48jstaabSplit is a function in my namespace; gc (and most of the rest of the object) is garbage#2018-12-0101:09vigilancetechcan this warning safely be ignored? https://github.com/nathanmarz/specter/issues/267#2018-12-0108:57thheller@vigilancetech well it is definitely a bug but apparently it seems to work ok regardless#2018-12-0108:57thhellerotherwise more people would run into issues I guess#2018-12-0108:59thheller@jstaab typically you want the exports to be static to prevent such renaming. it also is not exactly valid to call (clj->js some.ns) as that will all be renamed#2018-12-0109:00thhellertypically you want to return #js {:foo my-lib.core/foo :bar my-lib.core/bar :baz some.ns/baz} and so on#2018-12-0109:00thhellerthat ensures that the names do NOT get mangled#2018-12-0109:01thhellerotherwise you can just run with` :compiler-options {:optimizations :simple}` as the :advanced optimizations are not that relevant on node#2018-12-0115:52jstaabThanks @thheller I'll give that a try. I was hoping to do something dynamic since I have lots of exports and don't want to enumerate them all. I can just see myself adding a function, testing, building, releasing, integrating into client code then face palming because I forgot to export it :face_palm: #2018-12-0116:47thhellerwe gotta be explicit about exports otherwise DCE doesn't work 😉#2018-12-0116:47thhellersame as JS these days#2018-12-0116:48jstaabWhat does DCE stand for? Anywhere I can read more about it?#2018-12-0116:48jstaabWould a dynamically generated map work as an export? Or is it more of a static analysis kind of thing?#2018-12-0116:48thhellerdead code elimination#2018-12-0116:48jstaabgotcha#2018-12-0116:49thhellerdynamic basically means we can't remove anything because it might be used#2018-12-0116:50thhelleryou could use :npm-module instead since that controls what is exported directly in the ns#2018-12-0116:50thheller(defn ^:export foo [])#2018-12-0116:50jstaabAh, that's good to know, I definitely want DCE (my library will be used on node and in browser)#2018-12-0116:51thhellerwell DCE for libraries isn't all that useful since everything you export will not be removed#2018-12-0116:51jstaabIs that in the docs? I don't see anything about not being able to to DCE, or name mangling here: https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_exports#2018-12-0116:51thhellereven thought the user may only use 2 of the 10 things you export#2018-12-0116:51jstaabDoes it help with dependencies though? Like including only parts of a cljs utility library#2018-12-0116:55thhelleryeah it is still required for the CLJS parts. otherwise the code will be huge.#2018-12-0117:02jstaabAlright, I'll fiddle with some npm-module stuff, that sounds way nicer. I may submit a PR to the docs too#2018-12-0117:15jstaabOk, function exports are working great now, is there any way to prevent name mangling of nested object properties? Also, where's the repo for https://shadow-cljs.github.io/docs/UsersGuide.html ? I was thinking of adding a bit of clarification for posterity.#2018-12-0117:16jstaabOh, oh I didn't clj->js the export#2018-12-0117:19jstaabAnother question: is there a way to automatically wrap exported cljs code for js interop? so clj->js on exports and return values; js->clj on function parameters?#2018-12-0117:19jstaabBy the way, thanks @thheller for an amazing library and a slice of your saturday 🙂#2018-12-0117:20jstaabOr wait... late Friday?#2018-12-0117:20jstaabAh, late Saturday, sure#2018-12-0117:50vigilancetech@thheller FYI I wasn't getting that warning/bug before I upgraded shadow as per our discussion above#2018-12-0117:59vigilancetech@thheller, well I can tell you that my app no longer in fact works since that warning.#2018-12-0120:35thheller@jstaab no there is no automation for that but you could do it via a macro#2018-12-0120:36thheller@vigilancetech the warning has no impact on the code that was generated at all so it must be something else#2018-12-0120:52vigilancetech@thheller oh great 😕#2018-12-0120:53thhellerwhat is the issue?#2018-12-0120:53thhellermight be the move from CLJS 1.10.339 -> 1.10.439 but I'm not aware of any regressions regarding actual runtime stuff#2018-12-0201:11vigilancetech#2018-12-0209:38thheller@vigilancetech thats odd. do you know which part of you code triggers this?#2018-12-0209:54thheller(this is definitely not related to the warning change)#2018-12-0216:02Logan PowellI'm trying to keep some functions' internal state available between function calls... While using local let bindings seems to do the trick while working in the REPL, once I shadow-cljs release to an :npm-library and import the work, the functions seem to be losing their internal state across calls. I'm not sure how to fix this (or if it's even possible), but I see that :rename-prefix-namespace creates a global var in JS. Might this keep those internal function bindings "alive" between calls?#2018-12-0216:05Logan PowellThis is just a snippet/abbreviated version... the spooler actually merges a number of different external resource APIs' results together#2018-12-0216:05thhellersaw that snippet in #clojurescript but could not make sense of it#2018-12-0216:05Logan Powellhaha, sorry, I suck at snippets#2018-12-0216:05Logan PowellHi @thheller!
#2018-12-0216:06thheller
(ns app.core
	(:require [app.spooler :refer [spooler]
			   cljs.core.async :as a]))
#2018-12-0216:06Logan PowellThe point of the matter is that the local (let [cache... bindings are working in cljs, but not when I release the cache is never reached by the function across calls#2018-12-0216:06thhellerthis is invalid#2018-12-0216:06thhellerI assume that only because its a snippet?#2018-12-0216:07Logan Powellyessir#2018-12-0216:07Logan PowellI tried to make a small snippet#2018-12-0216:07Logan Powellthat basically represents the complexity of the problem#2018-12-0216:08thhellerto me the go looks invalid#2018-12-0216:08thhelleragain might just be due to snippet but creating a fn inside a go block is a no no#2018-12-0216:08thhellerand calling >! in there even more so#2018-12-0216:08Logan Powellthat's true!#2018-12-0216:09Logan PowellI forgot, it's just a representation... the actual code works 100% of the time in cljs#2018-12-0216:09thhellerthen nothing is ever put in =I= AFAICT?#2018-12-0216:09Logan PowellI think it has something to do with the fact that when I release the function is wrapped in a self-executing context, which is run and then thrown away#2018-12-0216:10thhellerthe code semantics don't change in :advanced#2018-12-0216:10Logan Powellsec...#2018-12-0216:10thhellerand the code above doesn't produce any extra globals?#2018-12-0216:11Logan Powellhttps://github.com/loganpowell/census-geojson/blob/master/src/census/utils/core.cljs#L137#2018-12-0216:11Logan Powellthis is the actual function that I try to create a local cache#2018-12-0216:14thhellerno idea. don't see anything that would behave any differently in :advanced#2018-12-0216:14Logan Powellok, I'll keep hacking 😉#2018-12-0216:15thhelleryou might get that done way easier with a transducer#2018-12-0216:15Logan PowellI'm using transducers in the merger function that uses $GET$: https://github.com/loganpowell/census-geojson/blob/master/src/census/merger/core.cljs#L167#2018-12-0216:17Logan Powellbasically, I'm trying not to have to call all the remote resources on every call when any of them are the same as last call and merge them together from cache if valid#2018-12-0216:18Logan Powellthe code is not easy to understand. I don't even know how to create a good snippet, but the most important thing is that those returned volatiles are never getting the chance to get used when I import the compiled js#2018-12-0216:19thhellerdid you try outputting everything here https://github.com/loganpowell/census-geojson/blob/master/src/census/utils/core.cljs#L162#2018-12-0216:19thheller(prn [:call url @$url$ ...]) just to verify that everything is what you think it is?#2018-12-0216:20Logan PowellI have done essentially that... the url's get printed every time#2018-12-0216:21Logan Powellwhen I run the code from the REPL, I get something like:
getting data from source:
...

(run the function again with the same args)

getting data from cache:
...
but when I use it in js land I get
getting data from source:
...

(run the function again with the same args)

getting data from source:
...
#2018-12-0216:22thhellerI'd still output everything together .. just to verify that actually IS what you think it is#2018-12-0216:22thhellernot that your cond is what you think it is#2018-12-0216:22Logan Powellbut why would it work in the REPL and not in JS?#2018-12-0216:23thhellerthe REPL is JS so no idea what that means#2018-12-0216:23Logan Powellthat's my point though... I don't know why it would be different#2018-12-0216:23Logan PowellLet me give your advice a go#2018-12-0216:27thhellermaybe you are just calling it differently in the actual app vs REPL#2018-12-0216:27thhellerlike calling the $GET$ again instead of re-using#2018-12-0216:27thhellerno idea. gotta go 🙂#2018-12-0216:27Logan Powellthank you as always for your help#2018-12-0216:32Logan Powellbtw, still waiting on that Patreon page 😉#2018-12-0218:53Logan PowellGot it working!#2018-12-0221:22vigilancetech@thheller no, and right not it escapes me how to find it out. I'll have to start with a minimal working "hello world" project and start adding stuff till it breaks I guess.#2018-12-0221:41thhelleryou could try git bisecting but thats kinda tricky to set up currently#2018-12-0221:58vigilancetechoh, yeah, okay, well, something to check out. Thanks.#2018-12-0223:16thhellerits also fine to just downgrade to 2.6.24 for the time being#2018-12-0309:33romdoqWhen I starting using re-frame in my project, the release build of my browser npm module started erroring with Cannot read property 'navigator' of undefined during import of the module. I've tracked down that goog.base.js sets $ = window.global at the end, but window.global is undefined. I'm not sure if it's something shadow-cljs is doing, or something webpack is doing, or both. Any ideas how to proceed?#2018-12-0309:37thheller@mel.collins which version are you on? I fixed a related issue recently#2018-12-0309:38thhellertry 2.7.4+#2018-12-0309:44romdoqhah, I could've sworn I updated shadow-cljs last week, but apparently I was still on 2.6.10. The lastest version does indeed Just Work™, thanks!#2018-12-0313:19Logan PowellIs there a way to bundle all dependencies with a :node-library or :npm-module as is done with :web-worker true?#2018-12-0313:53thhellernot sure how :web-worker is relevant to the bundling but all dependencies for node is not possible#2018-12-0313:53Logan PowellGotcha, thank you.#2018-12-0313:56thhellerFWIW there is an open issue about that https://github.com/thheller/shadow-cljs/issues/290#2018-12-0313:56thhellerjust didn't have time to work on it. also not totally convinced that it should be done.#2018-12-0314:02shaunlebroni used shadow-cljs yesterday to bundle cljs pretty-printer into a node.js project#2018-12-0314:03shaunlebron(i couldn’t figure out how to produce a commonjs module file from native cljs compiler)#2018-12-0314:03shaunlebronlove it, it just worked#2018-12-0314:04shaunlebroni wanted to prevent confusion by prepending an // Auto-generated comment to the output file: https://github.com/shaunlebron/highlight-tree-sitter/blob/master/shadow-cljs.edn#L6#2018-12-0314:04shaunlebronis that possible?#2018-12-0314:04thhellersure but don't forget \n#2018-12-0314:05thhellerhmm actually no I don't think :node-library respects that option#2018-12-0314:05shaunlebroni suppose a umd target would also work for my use-case#2018-12-0314:07shaunlebronoh, umd isn’t a separate target#2018-12-0314:08thhellerstill haven't done any work on the umd stuff#2018-12-0314:08thhellerits complicated#2018-12-0314:09thhelleropen a ticket about the prepend stuff. I'm barely at the PC currently and didn't get much done the past few weeks#2018-12-0314:09shaunlebronnp, great work on all this#2018-12-0314:10shaunlebron@jiyinyiyong love the website!#2018-12-0314:19pezOT, but, what is cljs pretty printer, @shaunlebron?#2018-12-0314:20shaunlebroncljs.pprint#2018-12-0314:20shaunlebronjust wanted to print js arrays as s-expressions#2018-12-0314:20pezOK, thanks. I thought it was maybe something new I had to look at. 😃#2018-12-0314:20shaunlebronhttps://github.com/shaunlebron/highlight-tree-sitter#2018-12-0314:21pezThat's cool. Will you try get that into Atom to replace the current regex based tokenizer?#2018-12-0314:23shaunlebrontree-sitter is actually built for atom#2018-12-0314:23shaunlebronit’s available for some langs, js included. clojure is being worked on#2018-12-0314:27pez👍#2018-12-0317:25hoopesHi, I'm building my cljs to js for https://storybook.js.org in accordance with https://github.com/shadow-cljs/examples/blob/master/cljs-storybook/shadow-cljs.edn . I'd like to be able to see my sourcemaps, but the URLs are something like //# sourceMappingURL=cljs.core.async.impl.buffers.js.map, which is not where they're actually served from. Accd to the user guide, :source-map-path doesn't have any effect at all - is there a solution to this? Thanks very much!#2018-12-0317:38thheller@hoopes the problem is not with shadow-cljs. the problem is that the code is processed further by storybook (webpack I believe). it must read the source maps and apply them to its output#2018-12-0317:38thhellerno idea how to do that#2018-12-0317:38hoopesgot it - sorry for the noise, i'll track it down. thanks very much!#2018-12-0317:47thheller@hoopes I think it needs this but not sure https://github.com/webpack-contrib/source-map-loader#2018-12-0317:47hoopescool, i was just looking through storybook stuff to figure out how to hook into their webpack config#2018-12-0317:47hoopes(if i could do it inline, that would be ok too...)#2018-12-0318:14aisamuHi! I'm running into some differences on the runtime behavior of require between :npm-module and :browser-test targets. Given the sample import ["module/folder/file-with-default-function.js" :as file :default function], here's what the names get assigned to:
|          | :browser-test                          | :npm-module           |
|----------+----------------------------------------+-----------------------|
| file     | Object{default: function(args){ ... }} | function(args){ ... } |
| function | function(args){ ... }                  | undefined             |
Is that expected? The current workaround is a shim cljs file that checks for the existence of a default and binds the var to that instead
#2018-12-0318:16thheller@aisamu when using :npm-module it emits a straight up require("module/folder/file-with-default-function.js") call. however that is filled in I cannot control#2018-12-0318:16thhelleryou can try setting :js-options {:prefer-esm true} in the :browser-test build#2018-12-0318:16thhellerit might then behave like :npm-module#2018-12-0318:17thhellerproblem is that each package does pretty much their own shit regarding packaging#2018-12-0318:17thhellerand not all modules play well when the esm entries are used#2018-12-0318:19thhellerstill need to figure out what kind of magic webpack is doing#2018-12-0318:19aisamuIf :js-options is located at the root of the build config (next to :target), then the result is the same 😕#2018-12-0318:20thhellerhow is the :npm-module code loaded?#2018-12-0318:20thhellerwebpack/node?#2018-12-0318:20aisamuThrough webpack, yup#2018-12-0318:21thheller"module/folder/file-with-default-function.js" which module is this?#2018-12-0318:21thhelleror more importantly how is it consumed from the JS side?#2018-12-0318:22aisamuIt's a standard ES6 file with a small fn:
export default (args) => {
  return ...
}
#2018-12-0318:22thhellerI think that has something to do with how requires are handled internally#2018-12-0318:22thhelleris it your file?#2018-12-0318:22aisamuYup!#2018-12-0318:22thhellerthen load it directly#2018-12-0318:23thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2018-12-0318:25aisamuThat's how it was initially done, but it was breaking webpack#2018-12-0318:25thhellerhmm yeah I think :npm-module is a problem for this#2018-12-0318:26thhellerhmm how is webpack configured? they have a setting for this. maybe you are not using the "new" default behavior?#2018-12-0318:26thhellerI tried matching what the latest webpack does#2018-12-0318:27aisamuIt's a rather large existing webpack 3.11.0 project. Is there something specific I should look for?#2018-12-0318:31thhellerah webpack 4 changed how some of that works#2018-12-0318:31thhellerhttps://medium.com/webpack/webpack-4-import-and-commonjs-d619d626b655#2018-12-0318:31thhellerso it might just be webpack3?#2018-12-0318:31aisamuOh, that'd explain it! If that's the case, sorry for the noise!#2018-12-0318:32thhellerthe result in :browser-test looks correct to me. not sure about webpack and :npm-module#2018-12-0318:33thhellerbut I suspect its the interop between the require,shadow-cljs and webpack#2018-12-0318:34thhellerthere are a few rough edges like that#2018-12-0318:35aisamuSure thing! Thanks for the help! I'll use the shims while we migrate to 4 🙂#2018-12-0318:35thhelleryou could just write your .js file as commonjs#2018-12-0318:35thhellerthat should solve the issue 😉#2018-12-0320:27souenzzoShould I care about this warnings?
------ WARNING #2 --------------------------------------------------------------
 File: com/cognitect/transit/impl/writer.js:256:8

 variable isObject is undeclared
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
 File: fulcro_css/css_implementation.cljc:212:56

 variable garden is undeclared
--------------------------------------------------------------------------------
#2018-12-0320:46thheller@souenzzo no. can be ignored#2018-12-0320:52thheller@vigilancetech btw the issue you reported the other day was related to this https://github.com/nathanmarz/specter/commit/e7abb2b5384b0b64d871fb347be7c34a15473eb2#2018-12-0320:52thhellernot the issue I had reported or the java warning#2018-12-0320:52thhellerso 1.12 should have fixed your issue already#2018-12-0321:26vigilancetechyes, seems to do the trick. Thanks!#2018-12-0322:42vigilancetechokay, now does anyone see a problem with this?
shadow-cljs - config: /home/kevin/0work/guardian-dashboard/shadow-cljs.edn  cli version: 2.7.6  node: v8.12.0
shadow-cljs - starting ...
Dec 03, 2018 2:28:19 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Dec 03, 2018 2:28:19 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 
shadow-cljs - server version: 2.7.6
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 42319
shadow-cljs - nREPL server started on port 45695
and
Starting Nmap 7.70 (  ) at 2018-12-03 14:38 PST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00016s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 998 closed ports
PORT     STATE SERVICE
631/tcp  open  ipp
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.65 seconds
(the latter was done with the -Pn flag) And cider won't connect with merely the "failed" error (nothing else, and doesn't get to the point where it even creates the nrepl message buffer even tho its enabled).
#2018-12-0322:49thhellernot sure what I'm supposed to be seeing?#2018-12-0322:50vigilancetechwell, shouldn't there be a port open for the nrepl server for instance?#2018-12-0322:51thhellertry nc localhost 45695 or whatever port is shown#2018-12-0322:51thhelleror just configure a fixed port#2018-12-0322:52thhellerno idea how nmap scans or what -Pn means#2018-12-0322:52vigilancetechI think it does all the ports rather than just the common ones#2018-12-0322:52thhelleronly need to test one port#2018-12-0322:53thhellerthe port that is shown on startup. it will either use that one or nothing. its not gonna report one but then use another#2018-12-0322:53thhellerno point in scanning everything#2018-12-0322:53thhellergiven that is also didn't show 9630 it doesn't seem be a useful scan#2018-12-0323:01thhellerif you have lein installed you can also do lein repl :connect localhost:<the-port> without a project#2018-12-0400:09vigilancetech
lein repl :connect localhost:42659
Connecting to nREPL at localhost:42659
CompilerException java.lang.ClassNotFoundException: clojure.tools.nrepl, compiling:(null:1:82) 
#namespace[user]
Error loading namespace; falling back to user
nil
user=> Bye for now!
#2018-12-0400:10vigilancetechfrom my project deps (in shadow's file)
:dependencies
 [
  [thheller/shadow-cljs "2.7.6"]
  [refactor-nrepl "2.4.0"]
  [org.clojure/clojure "1.10.0-alpha6"]
  [org.clojure/clojurescript "1.10.339"]
  [cider/cider-nrepl "0.19.0-SNAPSHOT"]
  [binaryage/devtools "0.9.10"]
  [adzerk/env                "0.3.1"          :scope "test"]
  [com.rpl/specter "1.1.2"]
;;  [hoplon/hoplon "7.1.0"]
  [hoplon/hoplon "7.3.0-SNAPSHOT"]
;;  [vigilancetech-com/hoplon "6.0.0-alpha17"]
  [cljsjs/markdown "0.6.0-beta1-0"]
  [vigilancetech/ui "0.3.0-SNAPSHOT"]
  ]

#2018-12-0402:20royalaid@thheller I am trying to use the :node-library output with AWS Lambda and am running into problems when I take the output and upload it to lambda. Does the output require a specific node version as its minimum?#2018-12-0408:17pez@vigilancetech try with adding [org.clojure/tools.nrepl "0.2.13"] to those dependencies.#2018-12-0409:00pez(Even though I think it used to work with just having the cider deps and shadow injected the rest.)#2018-12-0410:22thheller@royalaid node v6+ is required yes but thats a pretty old version so aws should definitely have that#2018-12-0410:22thhellerwhat is the problem you see?#2018-12-0420:10royalaidhttps://github.com/royalaid/minimal-shadow-cljs-nodejs#2018-12-0420:11royalaidHere is a repro, if you do a release and then upload the zip to AWS lambda it just returns null#2018-12-0420:12royalaid#2018-12-0420:12royalaid#2018-12-0420:12royalaidAdditionally these errors appear in the editor, not sure if they are red herrings#2018-12-0420:14royalaidSpecifically I have just zipped and uploaded the target folder in that project#2018-12-0420:20thhellerhmm that is odd#2018-12-0420:20thhellerseems to work fine in node#2018-12-0420:21thhellerbut it is trying to create a global variable. maybe they don't allow that for some reason?#2018-12-0420:41royalaidyeah that is what struct me, why is it happy in node?#2018-12-0420:41thhellerI'm guessing its just sandboxed stricter than normal node#2018-12-0420:49royalaidhttps://clojurians.slack.com/archives/C6N245JGG/p1543956542218300#2018-12-0420:49royalaidHere is the full compiled output#2018-12-0420:49royalaidpretty printed#2018-12-0420:53thhellertry 2.7.8. I changed how the exports are generated so it doesn't rely on the global.#2018-12-0421:33royalaid🙌#2018-12-0421:34royalaid#2018-12-1018:24Nolan@royalaid just out of curiosity, are there any npm deps in this project? was running into a (potentially) similar thing recently, and wondering if it’s related#2018-12-1018:25royalaidI haven't included any in the example project but plan to do a follow up post leveraging AWS's graphql lib for an example#2018-12-1018:26royalaidbut if you want to include npm deps Shadow's docs have a great section on how to do so#2018-12-1018:28Nolanright on. one thing i ran into that may or may not be helpful in your case is that i needed to copy node_modules into the zip, as thomas is undecided on “single-file” node builds. that might be obvious to most people but i spent a decent bit of time figuring that out, especially with :advanced on#2018-12-1018:28royalaidThat is good to know, I will include it in some edit's I want to make to the post#2018-12-0410:26thheller@vigilancetech do you have a user.clj in your sources that tries to do something with nrepl?#2018-12-0410:29thhellercider-nrepl 0.18+ requires nrepl 0.4+ but you seem to use the older version somewhere somehow?#2018-12-0410:31pezleiningen uses tools.nrepl still, I think.#2018-12-0410:34thheller@pez yes that is true but connecting should still work fine as the protocol itself is unchanged#2018-12-0410:34thheller
lein repl :connect localhost:8202
Connecting to nREPL at localhost:8202
shadow.user=>
#2018-12-0410:34thhellerworks fine regardless of nrepl version used#2018-12-0410:35thhellergetting tired of this cider stuff constantly breaking ... gonna have to spend some time with it some day ...#2018-12-0410:54pezI think some of it will stabilize when the transition to be nrepl is done. #2018-12-0410:55thhellerit has never been "stable" in 5 years so I have my doubts#2018-12-0410:56thhellerevery time I try it the setup I had before is broken and doesn't work anymore#2018-12-0411:02manuelIt used to work better before the move to the new sessions system, but it's not that "unstable" now. 🙂#2018-12-0411:15mdallastella@thheller what ide/editor are you currently using?#2018-12-0411:16thhellerCursive#2018-12-0415:34vigilancetech@thheller no user.clj#2018-12-0415:48richiardiandreaHad a little fun during/after the conj and built a bash script that runs and wait for the watch to be ready and then launches node: https://github.com/elasticpath/fonda/blob/master/scripts/repl To be refined for sure but it works fine for now :)))#2018-12-0415:55richiardiandreaJust noticed there is a small bug lol#2018-12-0419:45pez@thheller I’m trying to create an npm module of my existing Calva Formatter code, using the recipe you made for me. It builds and run tests, but I don’t know how to run the module so that I can hook the REPL in.#2018-12-0420:49royalaid#2018-12-0500:48richiardiandreaso before going all the way in depth on this I would like to get an opinion. I was a shadow-cljs.edn with:
:release {:compiler-options {:optimizations :simple
                                              :variable-renaming :off
                                              :property-renaming :off
                                              :pretty-print true
                                              :elide-asserts false
                                              :source-map true}
                           :autorun false}
#2018-12-0500:48richiardiandreait used to test some spec#2018-12-0500:49richiardiandrea
(= {:problems
            [{:path []
              :pred 'cljs.core/keyword?
              :val {:foo :bar}
              :via []
              :in []}]
            :value {:foo :bar}
            ::error2/id :this-is-an-error-id}
           (ex-data (error2/spec-ex-info :this-is-an-error-id spec body)))
#2018-12-0513:22richiardiandreaSo this is basically the original spec, sorry if messy. keyword? is the spec (predicate only) and {:foo :bar} the value. I will try to repro in core as well#2018-12-0500:49richiardiandreathe problem is, witch shadow-cljs watch the above passes#2018-12-0500:49richiardiandreawith the :release config above it does not#2018-12-0500:49richiardiandrea
(not
 (= {:problems
     [{:path [], :pred cljs.core/keyword?, :val {:foo :bar}, :via [], :in []}],
     :value {:foo :bar},
     :laputa.tools.error2/id :this-is-an-error-id}
    {:laputa.tools.error2/id :this-is-an-error-id,
     :value {:foo :bar},
     :problems [{:path [],
                 :pred :cljs.spec.alpha/unknown,
                 :val {:foo :bar},
                 :via [],
                 :in []}]}))
#2018-12-0500:50richiardiandreathe problem above is in the :pred, which is :cljs.spec.alpha/unknown in :release#2018-12-0500:50richiardiandreadoes it sound a thing worth an issue in shadow? or core?#2018-12-0509:04thheller@richiardiandrea spec + body is missing from the code above so I can't say.#2018-12-0509:04thhellergiven that I don't do anything to specs its probably in core?#2018-12-0509:05thhellerbut the above doesn't show enough to reproduce anything#2018-12-0513:23richiardiandreaSorry if messy. keyword? is the spec (predicate only) and {:foo :bar} the value. I will try to repro in core as well then#2018-12-0517:10escherizeWould shadow be a good choice for writing a wrapper for a react based component framework?#2018-12-0517:27thheller@escherize I assume you mean writing a CLJS wrapper? for that you don't need a compiler at all since CLJS libraries are just uncompiled .cljs files#2018-12-0517:27thhellerso you can use whatever. that being said shadow-cljs does not currently support publishing libs so you'd need lein or something else anyways 😉#2018-12-0517:28thhellerthe challenge you'll face however is writing the library in a way that CLJS can access it#2018-12-0517:28thheller(given that you'll probably be using some npm dependencies?)#2018-12-0517:28escherizeYeah, there are a couple npm dependencies.#2018-12-0517:29thhelleryeah thats a problem for people not on shadow-cljs#2018-12-0517:29thhellerso you probably need to create some cljsjs packages or so#2018-12-0517:30escherizeone of which is react - Not sure how to do the bundling / packaging of the libraries.#2018-12-0517:30thhellerreact is solved already so thats not a problem#2018-12-0517:30escherizeI'd prefer to avoid making cljsjs stuff 🚒#2018-12-0517:30escherizeif possible, at least.#2018-12-0517:31thhellerits probably fine to write it with shadow-cljs in mind first#2018-12-0517:31thhellerand then add the cljsjs parts later (if needed)#2018-12-0517:32escherizeYeah, I think that's what I want to do.#2018-12-0517:32thhellerbut it is probably going to require some tweaks for the other build tools since npm access is limited#2018-12-0517:38escherizeright#2018-12-0520:45pez@thheller is there some way I can run my npm module library such that the cljs repl can be used? I now tried starting a the simple demo http server code from the user guide (the node hot-reload section). I can start the server and browse to it, but shadow-cljs still doesn’t count that as an app has connected.#2018-12-0520:46pezI guess my question is: how would you do to be able to use the REPL with the npm module code, while developing it?#2018-12-0521:16aisamuI asked that a couple days back, but haven't got the chance to test the proposed workaround#2018-12-0521:23pezWhat was the proposed workaround?#2018-12-0521:51pezI found it. However I am targeting node.#2018-12-0521:13ClashTheBunnyLike, you want shadow to rebuild every time node_modules changes?#2018-12-0521:14ClashTheBunnyIs it for running in node or the browser?#2018-12-0521:29pez@clashthebunny Assuming you are asking me. 😄 I have some code I’d like to share between some VS Code extensions and am repackaging that code as an NPM module. VS Code is built on Electron, so it is node.#2018-12-0521:32pezToday that code is built using target :node-library and connects to the REPL when the extension starts. But this repackaging is really totally independent on VS Code or anything but node. And I can’t figure out how to get it connected to the REPL.#2018-12-0521:35ClashTheBunnyYou could check what party repl is doing: https://github.com/party-repl/clojure-party-repl#development#2018-12-0613:45mauricio.szaboI'm doing the same with Chlorine, my package for Atom, with Shadow-CLJS too#2018-12-0521:35ClashTheBunnyThey are developing an atom plugin with shadow-cljs.#2018-12-0521:39pezCool project! They are using the same approach as I do today.#2018-12-0522:05thheller@pez in your build config try :runtime :node and then loading require("./path-to-output/shadow.cljs.devtools.client.node")#2018-12-0522:05thhellerit is probably not going to be very reliable but it might work#2018-12-0522:09pezI just tried that, actually. Ran into the problems I had last time I tried to build with the :npm-module target.#2018-12-0522:11pezLots of complaints when requiring the client. Then no eval. Which I tried to fix using this:
global["SHADOW_NODE_EVAL"] = function (js, smJson) {
        if (smJson) {
            js += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,";
            js += Buffer.from(smJson).toString('base64');
        }
        //console.log(js);
        return eval(js);
    };
#2018-12-0522:11thheller> Lots of complaints#2018-12-0522:11pez(Which you once gave me, last time I went down this path. 😄)#2018-12-0522:11thhellershow me one? two?#2018-12-0522:12thhellerREPL is always tricky since we are not in charge of loading the final code#2018-12-0522:13thhelleras always you could just use node-repl outside all of this to work on the CLJS side of things#2018-12-0522:13pezThe complaints: It starts here:
var shadow = require('./calva_lib/shadow.cljs.devtools.client.node')
undefined
> failed to parse websocket message {:type :repl/init, :repl-state ...
#2018-12-0522:14thheller... please ... stop ... removing the most important parts from the errors ...#2018-12-0522:14pezSorry, I can post it all in a snippet. Just a sec.#2018-12-0522:15thhellerpost the "end" of the message .. there should be a stacktrace?#2018-12-0522:15thhelleror some reason WHY it failed to parse?#2018-12-0522:15thhellerthe first part is just the message it failed to parse#2018-12-0522:15thhellershould maybe drop/re-order that part#2018-12-0522:16pezThere was, I was about to paste that too.
ReferenceError: SHADOW_IMPORTED is not defined
    at Object.shadow$cljs$devtools$client$node$is_loaded_QMARK_ [as is_loaded_QMARK_] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:64:24)
    at Object.shadow$cljs$devtools$client$node$repl_init [as repl_init] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:137:40)
    at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:478:41)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
    at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)
    at WebSocket.emit (events.js:182:13)
    at WebSocket.EventEmitter.emit (domain.js:460:23)
    at Receiver._receiver.onmessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/WebSocket.js:141:47)
    at Receiver.dataMessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:389:14)
    at Receiver.getData (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:330:12)
#2018-12-0522:17pez(The message it failed to parse was huge, that’s why I choose to do it in two steps.)#2018-12-0522:17thhellerso please take this file and put it into your source path#2018-12-0522:17thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs#2018-12-0522:18thhellerchange this part https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs#L29 to js/global.SHADOW_IMPORTED#2018-12-0522:18thhellerlet me know if that fixes the problem?#2018-12-0522:18pezDoin’ it!#2018-12-0522:22pezShould I remove the :runtime :node thing?#2018-12-0522:22thhellerno other changes no#2018-12-0522:22pezOK. I get the same errors.#2018-12-0522:23pezBut am unsure which node client I am using, since that runtime directive.#2018-12-0522:24thhellerit is connected to the shadow-cljs server using the node ws module. so you are in node.#2018-12-0522:25thhellertry
(defn is-loaded? [src]
  (js/$CLJS.SHADOW_ENV.isLoaded src))
#2018-12-0522:26thhellerit'll probably still fail but I'm gonna need some way to reproduce the problem#2018-12-0522:29pezI restarted the node process after having replaced the is-loaded? function and then I could require the client w/o complaints.#2018-12-0522:33thhellerso does the rest work?#2018-12-0522:33pezGetting the SHADOW_NODE_EVAL reference error still. “Installing” it per that code I pasted earlier gives some eval power back.#2018-12-0522:34pezBut trying to eval any of my code I get:
ReferenceError: calva is not defined
    at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:1:22)
    at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:4:3)
    at global.SHADOW_NODE_EVAL (repl:7:16)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:60:14)
    at /Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:177:41
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:154:108)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:175:92)
    at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:482:41)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
    at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)
#2018-12-0522:34thhelleryeah this is probably not going to work#2018-12-0522:34thhellerscopes are weird in electron#2018-12-0522:35pezThere’s no electron involved here.#2018-12-0522:35thhellerI thought you were loading the code in electron?#2018-12-0522:37pezYes, I probably am… Let me think about what is going on. I am really just executing node inside the packages folder and then requiring the node client like so: require('./calva_lib/shadow.cljs.devtools.client.node')#2018-12-0522:38thhellerwell .. that simplifies things a lot ...#2018-12-0522:39pezSo I don’t think electron is there in any way.#2018-12-0522:39thhellerI thought you were loading electron extensions and stuff#2018-12-0522:40pezNo, I have choosen to keep all that vscode stuff in TS. And building a library that only deals with data in CLJS. That is what I am trying to package as a npm module.#2018-12-0522:41thhellerwell say so next time 😉#2018-12-0522:41pezHaha, I have tried to say it so many times. I probably suck at communication.#2018-12-0522:43thhellerok I have no reproduced. looking into it.#2018-12-0522:45pezCool. I’ll push this experiment to github so it is easier to look at what the heck it is I am doing.#2018-12-0522:46pezEverything about this is new to me. Electron, VS Code. Node. CLJS. The list goes on. 😄#2018-12-0522:54thhelleryeah this is not going to work. especially not in electron.#2018-12-0522:55pezWhat is not going to work?#2018-12-0522:56thhellernode REPL via npm-module#2018-12-0522:58pezI’m not sure where electron enters the picture, but you seem to have doubts regardless?#2018-12-0522:58thhellerwell that is the ultimate goal no?#2018-12-0522:59pezI want to consume the module in an electron app, yes.#2018-12-0522:59thhellerthere is no point in getting the node-repl to work in npm-module when you can just use shadow-cljs node-repl instead?#2018-12-0523:00pezI haven’t tried that. First time I hear of it.#2018-12-0523:01thhellerif you just want a repl to work on the CLJS side of things just use node-repl#2018-12-0523:01thhellergetting the REPL to work inside electron via npm-module is not going to work#2018-12-0523:01pezToday I start the repl using npx shadow-cljs cljs-repl :calva-lib#2018-12-0523:01thhelleryeah don't#2018-12-0523:02thhellernpx shadow-cljs node-repl#2018-12-0523:03pezI get the same errors as before.#2018-12-0523:05pezBut I can eval stuff at the prompt after a while.#2018-12-0523:05thhellerdoing what?#2018-12-0523:06thhelleroh yeah if you have the changed node.cljs still in your sources thats now gonna break stuff#2018-12-0523:06thhellerso you need to remove that first#2018-12-0523:06pezOk#2018-12-0523:07pezBut will I be able to connect to the nREPL server too this way?#2018-12-0523:07thhelleryes#2018-12-0523:07thhelleryou can also start the node-repl via nrepl#2018-12-0523:12pezHow would I do that?#2018-12-0523:13thhellerif you are connected to the CLJ nrepl part you simply call (shadow.cljs.devtools.api/node-repl)#2018-12-0523:13thhellerthat'll start the node REPL and switch the session to CLJS#2018-12-0523:16pezAwesome. I’ll have to hack Calva to support this, then can continue to hack on Calva using it. 😄
#2018-12-0523:18pezI checked the user guide and it says there are no builds involved using this repl. There are big chunks of shadow-cljs knowledge missing for me. I don’t really understand what is different with this repl and the other one.#2018-12-0523:19thhellerother REPLs runs as part of your build while your build is doing its thing, eg. rendering something using react when the page loads#2018-12-0523:19thhellernode-repl is just a simple node-repl that doesn't do anything on its own until you tell it to do something#2018-12-0523:24pezOK. But I think that should work pretty good for my particular setup.#2018-12-0609:34thheller@pez forgot to mention that there also is a npx shadow-cljs browser-repl in addition to node-repl. same deal, configless but runs in the browser.#2018-12-0609:38pezThanks!#2018-12-0523:29pezI’ll make Calva support this mode and continue with the npm-module idea of sharing code between the extensions. It really seems like it should work well. Huge thanks for all this patience with me. I truly appreciate.#2018-12-0607:24biscuitpantshas anyone had a problem with using shadow-cljs with cljsjs packages?#2018-12-0607:24biscuitpantsone of our projects still uses lein, and brings in a cljsjs package. no matter how i configure deps, shadow cannot find the dep for some reason#2018-12-0609:15thheller@biscuitpants cljsjs packages are not supported at all and must be emulated. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2018-12-0609:16biscuitpantsok so absolutely zero compatiblity. that’s all good#2018-12-0609:16biscuitpantsthank you!#2018-12-0609:17thhellerhappy to take a PR to add the shim file here https://github.com/thheller/shadow-cljsjs#2018-12-0609:17thhellerthe most common cljsjs packages are already emulated I guess#2018-12-0609:23biscuitpantsoh nice! didn’t know about that repo#2018-12-0614:11biscuitpantshow would i add a dev file to builds, only during dev time? so an extra ns to load when doing dev#2018-12-0614:20thheller@biscuitpants :devtools {:preloads [foo.bar]}. as of recently individual modules also accept preloads, eg. :modules {:foo {:preloads [...]}}#2018-12-0616:40pez@thheller: This node-repl thing is perfect for my npm module in the making! Here testing the coming Calva support for it. Thanks again!#2018-12-0616:43pezI choose to make it selectable this way:#2018-12-0617:43thheller@richiardiandrea lets continue here. no need to spam #clojurescript 😉#2018-12-0617:44richiardiandreakk#2018-12-0617:44thhellerso when you say "lib A" and "lib B" I read CLJS lib A+B. is that correct or are you talking about npm libs?#2018-12-0617:45richiardiandreaso yeah lib B is a CLJS lib which contains deps.cljs#2018-12-0617:45richiardiandrealib A is the consumer#2018-12-0617:46thhellerso strictly speaking its not a library at all?#2018-12-0617:46richiardiandrealib B is - lib A no#2018-12-0617:46richiardiandreaso let's say lib B and cons A 😄#2018-12-0617:47thhellerso A is the thing that will actually be executed? in that case you definitely want a package-lock.json with all the deps in package.json#2018-12-0617:48thhellerotherwise the next time you run npm install it might have a completely different set of deps#2018-12-0617:48richiardiandreayep I have a package-lock.json in lib A and I am ok with that and I like the warning when deps.cljs is out of sync#2018-12-0617:49richiardiandreamy only issue is when I build cons A - the deps.cljs dependencies gets added to its package.json#2018-12-0617:50thhellerbut you want them in there? I don't understand why that is a problem?#2018-12-0617:50thheller> otherwise the next time you run npm install it might have a completely different set of deps#2018-12-0617:51richiardiandreaso it feels like as if I had a project.clj which is modified by the transitive dependencies of lib A#2018-12-0617:51thhellerstop using "lib A" .. just use A please. it is confusing enough as it is.#2018-12-0617:51thhellerok so lets make a rather simple scenario#2018-12-0617:52thhellerB declares {:npm-deps {"react" "^16.0.0"}}#2018-12-0617:52thhellerA uses B and no package.json is not updated and no package-lock.json is created at all#2018-12-0617:53richiardiandreait does, that is the problem#2018-12-0617:53richiardiandreain the A project#2018-12-0617:53thhelleryou run npm install in the project NOTHING is installed#2018-12-0617:53richiardiandreawell no?#2018-12-0617:53richiardiandreaI think it does here 😄#2018-12-0617:53thhellerpackage.json of A is presumably empty#2018-12-0617:53richiardiandreathat is why I had to add the flags#2018-12-0617:54richiardiandrealet me see one sec#2018-12-0617:54thhellershadow-cljs was not executed yet#2018-12-0617:54richiardiandreaah ok#2018-12-0617:54thhellerI actually talking about npm install. we can agree that nothing happens yes?#2018-12-0617:54richiardiandreaagreed#2018-12-0617:54thhellerso your code cannot execute since the dependencies are not installed?#2018-12-0617:55thhellerso you NEED to execute shadow-cljs in order to run your code#2018-12-0617:55thhellerthat seems like problem to me?#2018-12-0617:55richiardiandreaagreed#2018-12-0617:55richiardiandreaI have to use shadow in order to install the transitive deps for sure, because A does not declare them#2018-12-0617:56thhelleralso :install-cmd lets you do this already. I'm not changing the default.#2018-12-0617:56thhellerthe reason they need to be put into package.json of A is partly due to tooling#2018-12-0617:56thhellersay you do npm install something-a-wants#2018-12-0617:57thhellerit may actually REMOVE everything that was installed via B deps.cljs since its not in package.json#2018-12-0617:57richiardiandreadoes JS tooling rely on package.json or on node_modules? because the deps will be in node_modules...#2018-12-0617:57richiardiandreasorry silly question, not a JS expert here#2018-12-0617:57thhellerboth#2018-12-0617:58richiardiandreakk in that case than I see why you would want that#2018-12-0617:58thhellerthe situation is messy enough as it is and I never liked :npm-deps#2018-12-0617:58richiardiandreaI am coming from Clojure/Java where you only inspect that classpath I guess#2018-12-0617:59richiardiandreaperfect thanks for your patience and explanation, I was sure there was some reason there I was missing#2018-12-0617:59thhelleryou can't compare clojure since we are trying to "merge" 2 different package managers here#2018-12-0617:59thhellerwe need to collect classpath dependencies for CLJ(S) and then a secondary set of deps for npm#2018-12-0618:00thhellerbut npm doesn't know how to read the first set#2018-12-0618:00thhellerso we need to move it out of there to something that npm can understand#2018-12-0618:00thhellerthus add it to package.json#2018-12-0618:00richiardiandreagotcha that makes perfect sense now#2018-12-0618:00thhellerI don't know how to do this cleaner#2018-12-0618:00richiardiandreaI guess I just needed to understand why 😉#2018-12-0618:01thhelleryou can try to work with your custom :install-cmd. maybe it works for you. I never used npm that way. it may actually work.#2018-12-0618:01thhellerI just want something a little more predictable.#2018-12-0618:01richiardiandreabut no yeah, if you say that npm relies on both, I need to carry them over cause I am relying on JS tooling like the Azure stuff#2018-12-0618:02richiardiandreaso I am going to use the default for the time being#2018-12-0618:02thhellerwell that adds a third thing. no idea what Azure does.#2018-12-0618:02richiardiandreayeah but the explanation you gave me make sense anyways 😉#2018-12-0618:03thhellertooling generally uses package.json to resolve version conflicts and such#2018-12-0618:03thhelleror rather uses package-lock.json in case of npm#2018-12-0618:03thhellerto kinda ensure that running npm install is at least semi consistent given the widespread use of version ranges in the npm world#2018-12-0623:01richiardiandreaHas anything changed with the way :azure-app's :fn-map gets emitted? I have a weird error with 2.7.8#2018-12-0623:02richiardiandrea[error] Worker was unable to load function trigger: 'TypeError: Cannot read property 'trigger' of null'.#2018-12-0623:03richiardiandreawoah ok, all our functions seems broken 😅#2018-12-0700:32richiardiandreadoes shadow-cljs release prevent instrument to happen somehow?#2018-12-0709:05thheller@richiardiandrea release sets :elide-asserts true which may affect instrument. not actually sure. try setting :compiler-options {:elide-asserts false}#2018-12-0715:42richiardiandreaWill do#2018-12-0716:40richiardiandreaDavid said that this is not the reason but I am going to try and see...#2018-12-0718:50thhellerdidn't think so but wasn't sure. good to know.#2018-12-0808:09pezI’m running into problems with matching unicode letters with regexps. It works in a Figwheel browser project I have:
(re-seq #"(?u)[\p{L}]+" "adams-äpple")
=> ("adams" "äpple")
But in shadow-cljs, targeting node, I get this:
(re-seq #"(?u)[\p{L}]+" "adams-äpple")
Error: <eval>:1
cljs.core.re_seq.call(null,/[\p{L}]+/u,"adams-\u00E4pple")
                 ^
SyntaxError: Invalid regular expression: /[\p{L}]+/: Invalid escape
    at <eval>:1:18
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at runInThisContext (vm.js:139:38)
    at global.SHADOW_NODE_EVAL (/Users/pez/Projects/calva-fmt/lib/calva_fmt.js:83:30)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
    at /Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:48:13
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:102:11)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:46:1)
    at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-fmt/.shadow-cljs/builds/calva-fmt-lib/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:116:5)
#2018-12-0816:54pezAnd in the browser console as well as in node this works:
> "adams-äpple".match(/[\p{L}]+/ug);
[ 'adams', 'äpple' ]
#2018-12-0823:57royalaidI wrote a short blog post about CLJS+Shadow+Lambda https://dev.to/royalaid/cljs-s-lambda-697#2018-12-0904:47idiomancy@royalaid hey, that blog post is right up my alley! sounds like shadow-cljs is the way to go! However, my big ish right now is getting a repl running in Cursive with a deps.edn based project. The wiki seems to assume I'm either a) not using nREPL or b) am using Leiningen Any tips?#2018-12-0905:30idiomancyI'm basically blocked on No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code#2018-12-0906:03idiomancyran shadow-cljs node-repl dev with build config
:builds
 {:dev {:target     :node-script
        :nrepl      {:init-ns ginandtomic.core}
        :output-to  "main.js"
        :asset-path "/js"
        :main       ginandtomic.core/main}}
output some locations to connect, connected on nrepl port, ran
(require '[shadow.cljs.devtools.api :as shadow])
(shadow/watch :dev)
(shadow/nrepl-select :dev)
seems to believe everything is fine, outputting:
To quit, type: :cljs/quit
=> [:selected :dev]
and yet, when I try to evaluate any cljs, it throws No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code
#2018-12-0906:04idiomancyno lo comprendo#2018-12-0907:59pez@idiomancy , I am not familiar with the node-script target, but that nrepl connection needs an application to connect to, that has an entry point in your code. Not sure how you do that with node-script or if the build repl will work. But you might have some use of the node-repl: (shadow/node-repl). #2018-12-0915:53idiomancy@pez aw_yeah yeaaaaahhhhhh!!!!!!#2018-12-0915:53idiomancyThank you!!!#2018-12-0915:53idiomancyThat did it!!#2018-12-0915:55pezCool. That REPL is not hooked to your application, Which might or might not matter at times.#2018-12-1005:45skrat#2018-12-1005:45skratI just freshly install shadow-cljs with yarn and tried to use it for the 1st time#2018-12-1006:00skratIt turns out to be a dependency no somewhat newer clojurescript, mine was 1.10.339 and did not contain comp/*source-map-data-gen-col*#2018-12-1007:02pez@thheller: I'm running into two issues with building calva-lib as an npm module. One is that I can't require it when I npm install it, only if I do npm link (which is handy during development). Here's the repo: https://github.com/BetterThanTomorrow/calva-lib#2018-12-1007:04pezAnother is that I seem to get a different behaviour when built as an npm module and when built as a node library. I am trying to pinpoint exactly where the difference happens, but wanted to ask if you have heard of such a thing?#2018-12-1012:37achikin@thheller I've managed to integrate funcool/decimal properly.#2018-12-1012:38achikinYou said I can donate that back to shadow-cljs. Where should I put it?#2018-12-1015:44achikinI'm a bit concerned. I have quite a huge cljs app. My current cljsbuild+webpack setup generates 871KB app.js + 351KB webpack-bundle.js. While shadow-cljs generates one 3.1MB app.js file. What could possibly be wrong?#2018-12-1015:53wilkerlucioyou need to consider the cljs lib overhead (all the imutable data structures), but shadow has a report feature taht you can use to track exactly whats adding up on the bundle#2018-12-1015:53wilkerluciohttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2018-12-1015:57achikinI'm compiling the same code#2018-12-1015:57achikinI have two branches - one with lein cljsbuild and webpack and another one with shadow-cljs#2018-12-1015:58wilkerlucioshadow handles npm differently, there is a chance webpack is doing a better job at DCE on NPM modules, the report can give you more details#2018-12-1016:16achikin#2018-12-1016:17achikinI wonder what webpack did to that file...#2018-12-1016:38achikinBTW, does shadow-cljs server serve GZIPed files?#2018-12-1016:58achikinI guess it's not... that's why I spotted so big difference....#2018-12-1016:59achikinTaking gzipped version into account - shadow did much better than my current setup 🙂#2018-12-1017:51pez@thheller: I have a clue to the different behaviour now. In my own code I had to (:require clojure.string) for the :npm-module to work, but not while I was using a :node-library target. And it seems that is what is happening inside a library I am using (`cljfmt`). I get ReferenceError: clojure is not defined.#2018-12-1022:34jstaabCan anyone tell me how to conveniently get the stack trace from shadow-cljs watch test using a node-test autorun build? I tried using the main entry in my shadow-cljs.edn to override the formatter to print a thrown error, but that caused weird watch behavior that I didn't want to figure out. Right now, I'm not using a main module for the build, and I'm getting stuff like:
ERROR in (test-line-item-tax-exempt) (Error:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[Error Error: No matching clause: ]
#2018-12-1117:06jstaab@thheller any ideas on this?#2018-12-1100:24idiomancyhas anyone here successfully made a lambda function with shadow-cljs that calls the aws sdk?#2018-12-1101:05royalaid#2018-12-1108:14idiomancy@royalaid let me know when you do. there are a couple of gotchas I can help you with.#2018-12-1108:14idiomancyI'm stuck on one of them now.#2018-12-1108:14idiomancyWhen promesa is in the stack, I'm getting "cannot find module bluebird"#2018-12-1110:10thhellerthis means you must install the bluebird npm package. no idea how to do that for AWS though.#2018-12-1117:13idiomancyI just have to copy the node_modules into the target directory and zip the whole thing up before I send it up to lambda. shouldn't be a big deal. Thanks so much for that insight, that's really helpful#2018-12-1108:14idiomancywhen I try to invoke the lambda#2018-12-1108:29pez@idiomancy I have seen some discussions about how mixing externs and shadow's built in ways to resolve them can cause problems. I have also just recently experienced that it sometimes matters what kind of target you are using. Looking at the promesa source code I see this: https://github.com/funcool/promesa/blob/547d01652f335df18d4f2950efc8e7caba416fbb/assets/deps.cljs#L5 It might and might not be what is biting you. I guess one way to find out is to try build the promesa library yourself, using shadow-cljs.#2018-12-1108:29idiomancyhmmm#2018-12-1108:42idiomancyso, this experiment you're suggesting#2018-12-1108:42idiomancyto build the promesa library#2018-12-1108:42pezSuggesting is a strong word 😃#2018-12-1108:42idiomancyhahaha#2018-12-1108:42idiomancyfair#2018-12-1108:43pezMaybe check what the Shadow User Guide says about externs first. Might be some way to configure around the problem you are seeing.#2018-12-1108:44idiomancyhmm#2018-12-1108:44idiomancyyeah#2018-12-1108:44idiomancythe word externs is terrifying to me#2018-12-1108:44pezBut since it is in a cljs library you are using, I somehow doubt that there is an easy solution.#2018-12-1108:45pezIf you build promesa using shadow-cljs it will take care of externalizing stuff. What I had in mind was trying to just put the promesa code in your src path and let it be part of your build (as an experiment).#2018-12-1108:47pezFull disclosure: I am a shadow-cljs noob (and Clojure(Script) noob as well). I am just trying to piece together whatever clues and hints I have picked up so far.#2018-12-1108:47idiomancyahh, I see#2018-12-1108:51pezThis looks interesting (from the user guide): > With :auto the compiler will perform additional checks at compile time for your files only. It won’t warn you about possible externs issues in library code. :all will enable it for everthing but be aware that you may get a lot of warnings.#2018-12-1108:52pez(Regarding :compiler-options {:infer-externs)#2018-12-1108:55pezAnd also this: https://shadow-cljs.github.io/docs/UsersGuide.html#_manual_externs#2018-12-1109:04idiomancyalright.. building with the bluebird assets in and compiler options set... lets giver er a whirl#2018-12-1109:05idiomancytest unsuccessful. bluebird remains unfound 😞#2018-12-1109:38pez😞 Did you use :all?#2018-12-1109:40pezAlso, probably best to clean the build.#2018-12-1110:20thhellerthis is never necessary. if it is its a bug but so far I had no reports that there are any issues.#2018-12-1110:21pezAh, good to know. Should lower my build times a lot.#2018-12-1109:40pezWhat optimizations are you using, btw?#2018-12-1109:51idiomancywell, the :shadow js-provider purpotedly only uses simple optimizations#2018-12-1110:21thhellerexterns have nothing to do with cannot fine module bluebird. thats just means the the npm package bluebird is not found by node. they are not bundled in node build (unlike browser builds)#2018-12-1110:22pezThat figures.#2018-12-1110:24thhellerexterns only affect the renaming of JS code. so if you get weird errors like zy.Fp is not a function or undefined or whatever that is most likely caused by externs.#2018-12-1110:25pez@thheller Do you have any idea what my ”Reference error clojure is not defined” could be about, when I use cljfmt in my npm-module build?#2018-12-1110:26thhellerhad slack turned off over the weekend. which error?#2018-12-1110:29pezWhen I build with target npm-module I seem to need to require things like clojure.string or I get this reference error. (I didn't need that with the node-library build.) That's not a problem, but it also seems to extend to libraries I use. So when cljfmt reaches certain paths in its code it croaks with the reference error of clojure not being defined.#2018-12-1110:29thhellerwhat is the full error? including stack trace.#2018-12-1110:30thhellerthe code is bundled differently for :npm-module and is more sensitive to use-without-require type of code problems.#2018-12-1110:30pezI don't get a stack trace. But I guess I could make that happen.#2018-12-1110:31thhellerso most likely something in cljfmt uses clojure.string (or something similar) but does not :require it in its ns#2018-12-1110:31thhellerthats my guess anyways. can't say more without stacktrace#2018-12-1110:32pezThat's what I think as well. Is there a way around it, if that is the case?#2018-12-1110:32thhelleryeah fix cljfmt (if thats indeed the error)#2018-12-1110:33pezOK. I'll do that. Wasn't sure it was an error to use cljoure.string without requiring it.#2018-12-1110:33thhellerbut can't say anything without a stacktrace#2018-12-1110:33pezI also have this problem with regular expressions: https://clojurians.slack.com/archives/C6N245JGG/p1544256572353800#2018-12-1110:34thhellerhmm that is odd#2018-12-1110:34thhellertry :compiler-options {:output-charset "ASCII"} maybe?#2018-12-1110:35thhellerhmm no that is only for optimized builds#2018-12-1110:35thheller> It works in a Figwheel browser project#2018-12-1110:35thhellerI'm guessing that it also works in a shadow-cljs browser project?#2018-12-1110:35thhellereg. browser-repl?#2018-12-1110:36thhellerwhich node version is that?#2018-12-1110:38pezHaven't tried it in a browser project. Let me check the node version.#2018-12-1110:44pezI get 9.7.1 from node --version.#2018-12-1110:46pezIt works in browser-repl.#2018-12-1110:47thhellernode version seems fine. no idea whats happening.#2018-12-1110:48thhellerdoes it work when you use it in a file and not via the REPL?#2018-12-1110:49pezHmmm, let me try that#2018-12-1110:55pezIt doesn't work when used in my extension either.#2018-12-1110:56thhellerdid you load it via the REPL?#2018-12-1110:57thhellerdoes it fail when you put it into a file that is loaded on startup regularly without a REPL even being attached?#2018-12-1110:59pezI didn't have any repl attached when I tried now. Just built the extension with shadow's watcher and loaded it.#2018-12-1110:59thhellerhmm ok#2018-12-1110:59thhellercan you try constructing the regexp differently?#2018-12-1111:00pezNot sure how I would do that.#2018-12-1111:00thheller(js/RegExp. "[\p{L}]+" "u")#2018-12-1111:00pezOK.#2018-12-1111:00thhellerI think#2018-12-1111:00pezIt looks right to me. 😃#2018-12-1111:00thheller(js/RegExp. "[\\p{L}]+" "u")#2018-12-1111:00pezyes, of course#2018-12-1111:02pezThen I get the error when constructing the regexp. (But it works in browser-repl)#2018-12-1111:05thhellerno idea sorry#2018-12-1111:05thhellerseems to work fine when you do it directly in node#2018-12-1111:16peznot for me...#2018-12-1111:29thhellerin node. no cljs.#2018-12-1111:30thheller
$ node
> /[\p{L}]+/u
/[\p{L}]+/u
>
#2018-12-1111:30thhellerdoes that not work for you?#2018-12-1111:44pezNo, I get ”invalid escape”. Very strange. I have the same on two of my computers. In any case it is now a shadow issue, which I thought at first.#2018-12-1111:47pezI do have yet another issue though… I can't require my npm-module from an npm install. Only if I npm link it locally.#2018-12-1111:52thhellerno idea what that means#2018-12-1111:54thhellerbe verbose in error reports. I can't guess anything with this little information.#2018-12-1112:04pezI'm sorry. It is the whole problem. And not an error report, I think. It is rather me not being able to figure out how to do it. To me it looks like I am doing what you showed me (`npm i @shadow-cljs/npm-module-demo` then require("@shadow-cljs/npm-module-demo")). In my case I do
const formatter = require('@cospaia/calva-lib/lib/calva.fmt.formatter'); 
But it does not work from an npm install only from an npm link.
#2018-12-1112:04thhellerwhat error do you get though?#2018-12-1112:05pezLet me reproduce it. (This was on my home computer a few days ago).#2018-12-1112:06thhelleralways say what happens when something doesn't work. just saying "it does not work" is not very useful on its own.#2018-12-1112:07pezActivating extension 'cospaia.calva-fmt' failed: Cannot find module '@cospaia/calva-lib/lib/calva.fmt.formatter'.#2018-12-1112:10pezAgain, if I npm link it locally, it works (as in no complaints) and the extension does what it should do (minus croaking on certain input due to that cljfmt thing that I need to fix).#2018-12-1112:11thhellerwhen you install it. does the file node_modules/@cospaia/calva-lib/lib/calva.fmt.formatter.js exist?#2018-12-1112:12thhelleryou may just not package the files properly for npm when creating the actual package?#2018-12-1112:12thhellernpm link is just a symlink so it will contain files that may not the in the package otherwise#2018-12-1112:12thhellereg. you are ignoring the lib/ directory?#2018-12-1112:14pezWhat do you mean I am ignoring lib/? In some .ignore file?#2018-12-1112:15thhellerdoes the file exist or not?#2018-12-1112:18pezYou are right, I only have the main: file (from packages/package.json) there.#2018-12-1112:18pezlib/calva.main.js in my case.#2018-12-1112:19pezGreat, then I need to figure out how to package this properly.#2018-12-1112:19thhellermaybe npm uses .gitignore when building the package#2018-12-1112:19thhellerIIRC it does if there is no .npmignore but can't remember#2018-12-1112:20pezThe .gitignore file in packages/ lists:
*.js
*.js.map
#2018-12-1112:23pezIt's the same with your demo module (that it only contains the main: entry).#2018-12-1112:24pezBut I'll figure it out. Tons of thanks for all the help!#2018-12-1112:44pezYes, it works if I specify
"files": [
        "lib/"
    ]
in package.json. Yay!
#2018-12-1113:13javiI just upgraded to 2.7.8 and i am getting this warning when running a build with :bootstrap target
[2018-12-11 13:01:18.740 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (symbol? current-ns)
        shadow.build.cljs-hacks/shadow-js-access-global (cljs_hacks.cljc:16)
        shadow.build.cljs-hacks/shadow-js-access-global (cljs_hacks.cljc:16)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:167)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:131)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:135)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:131)
        cljs.analyzer/resolve-symbol/fn--2589 (analyzer.cljc:3910)
        cljs.analyzer/resolve-symbol (analyzer.cljc:3909)
        cljs.analyzer/resolve-symbol (analyzer.cljc:3905)
        clojure.tools.reader/syntax-quote* (reader.clj:705)
        clojure.tools.reader/syntax-quote* (reader.clj:693)
        clojure.tools.reader/expand-list (reader.clj:623)
any ideas of where i should start looking to get rid of it? thanks in advance..
#2018-12-1113:33thheller@fj.abanses in the shadow-cljs clj-repl try (def x (shadow/compile! :the-build-id {}))#2018-12-1113:33thhellerneed the full stacktrace#2018-12-1113:34thhelleror if you have more of the above thats fine too#2018-12-1113:34thhellerjust need to know where it is fully in the stack#2018-12-1113:37thhelleralso if you are using deps/lein make you sure have the correct tools.reader version#2018-12-1113:37thhellermight be a dep conflict. never seen that error before.#2018-12-1113:41WhiskasHow is the experience for shadow-cljs users when integrating JSX modules into a CLJS project?#2018-12-1113:42thhellerJSX is not supported, so you need to run babel separately. but works ok-ish https://github.com/shadow-cljs/examples/tree/master/babel#2018-12-1113:44javihi @thheller it is on my side, an ns started complaining when compiled... nearly got the culprit 🙂 thanks, apologies for the noise!#2018-12-1113:45WhiskasIs it easy to replace figwheel with shadow-cljs in a project generated by a leinegan template?#2018-12-1113:48thhellerwell it doesn't matter what kind of project you have. you need to get familiar with shadow-cljs and how that works regardless. when you know how it works it is easy to switch the project yes.#2018-12-1117:10WhiskasSo… someone knows how to solve this?#2018-12-1117:10Whiskas
[:app] Configuring build.
-> build target: :browser stage: :configure
<- build target: :browser stage: :configure (2 ms)
[:app] Compiling ...
-> Analyzing Module: :app
[:app] Build failure:
The required namespace "day8.re-frame.tracing" is not available, it was required by "dbiz_health/commom/events.cljs".
#2018-12-1117:11WhiskasI could not find day8.re-frame.tracing in npm#2018-12-1117:12jstaabtry re-frame.trace https://github.com/Day8/re-frame/blob/master/src/re_frame/trace.cljc#2018-12-1117:13jstaabAnd of course make sure re-frame is installed in your shadow-cljs.edn file.#2018-12-1117:18WhiskasOah, problem solved, i just forgot to migrate a dependency from the :dev profile to the main deps of shadow-cljs.edn#2018-12-1117:28Whiskas
------ WARNING #1 --------------------------------------------------------------
 File: bidi/bidi.cljc:29:12
--------------------------------------------------------------------------------
  26 | actually a valid UUID (this is handled by the route matching logic)."
  27 |   [s]
  28 |   #?(:clj (java.util.UUID/fromString s)
  29 |      :cljs (cljs.core.UUID. s)))
------------------^-------------------------------------------------------------
 Wrong number of args (1) passed to cljs.core.UUID
--------------------------------------------------------------------------------
  30 |
  31 | ;; When forming paths, parameters are encoded into the URI according to
  32 | ;; the parameter value type.
  33 |
--------------------------------------------------------------------------------
Someone knows how to solve this?
#2018-12-1117:31jstaabA number of things seem fishy to me there, try (cljs.core/uuid s)#2018-12-1117:32jstaabOh, I see that's in bidi#2018-12-1117:32Whiskasyeah, i’m trying to compile and getting this error#2018-12-1117:33Whiskasi found some issues about it on github, but no solution#2018-12-1117:33jstaaboutta my depth#2018-12-1117:56Whiskas@morgancmartin Hey, can you share with me the fork you used to solve the bidi problem?#2018-12-1117:57Whiskasi’m referring to this: https://github.com/juxt/bidi/pull/190#2018-12-1119:55WhiskasNvm, i just solved the problem by following this tutorial: https://stackoverflow.com/questions/17497937/patch-library-from-clojars#2018-12-1120:56thheller@mateus.pimentel.w its just a warning also. no impact on runtime.#2018-12-1208:04pez@thheller Revisiting that cljfmt problem with clojure.string being used without proper require, I found that it happens in rewrite.cljs: Here: https://github.com/rundis/rewrite-cljs/blob/5ed0980d4fc65ba00780deadb3cf245d742bfeb9/src/rewrite_clj/parser/string.cljs#L39 This is quite a bit more problematic than if it had been in cljfmt itself, because the latter is actively maintained, and PRs pulled, but it is not so with rewrite-cljs. Is my only option now to use my own version of rewrite-cljs, or is there something I can tell shadow-cljs that will make it handle this omission? Seeing that it does handle it when I have my lib compiled as a :node-library, but maybe that is totally accidental depending on if the clojure module has been required by some other piece of code earlier in the compile cycle? (I have the full stack trace, if that is of any help.)#2018-12-1208:18pez(I am already using my own fork of cljfmt, tracking upstream tightly, so it is not the end of the world if I have to fork rewrite-cljs to patch this, but if it can be avoided, I would rather avoid.)#2018-12-1210:16thheller@pez not sure. right now fork is your only option I think. let me think about it. maybe I can work around it somehow.#2018-12-1210:50pezThanks. I have forked and have everything working with the npm-module as I had with the node-library, so I am good right now. 😃#2018-12-1210:51pezWith some luck the PR is small and important enough for the maintainer to stir and pull it in.#2018-12-1212:35Jakub Holý (HolyJak)Hi @thheller, had you time to think any more about https://github.com/thheller/gatsby-cljs and StaticQuery support there? Thank you!#2018-12-1516:25tbrooke@holyjak @thheller keep me posted on any efforts re: gatsby I’m a shadow-js newbie and this seems like a good starter project#2018-12-1212:36thheller@holyjak no. no time to do so.#2018-12-1214:11pez@thheller: when I build my npm-module using :release some .js files are totally empty. Buildling using :compile works. Is there something that I loose by not using :release?#2018-12-1214:12thheller@pez they become empty because the closure compiler decides they are unused and eliminates everything#2018-12-1214:12thhelleradd ^:export hints for fns you want to keep#2018-12-1214:16thhellerand yes release is pretty much always worth it#2018-12-1214:16thhelleryou can switch to :optimizations :simple for node though#2018-12-1214:21pezThanks!#2018-12-1216:38royalaid@thheller is there a way to provide build opts to build-report? looking at the source it doesn't seem so#2018-12-1216:38thhellerwhat kind of build opts? its purpose is to show what your release build looks like so it uses your builds release config#2018-12-1216:39royalaidThe same ones that can be provided to release#2018-12-1216:40thhelleran example please. no idea what you are after#2018-12-1216:40royalaidYeah, 1 sec#2018-12-1216:41royalaidSo we use this function to build our release
(defn release
  "Build :browser release, with advanced compilation"
  ([] (release "local"))
  ([release-flag]
   (shadow/release* (-> (config/get-build! :browser)
                        (assoc ::release-flag release-flag)) {})))
#2018-12-1216:42royalaidI would like a way to provide that build/release config to build-report to track bundle sizes and such#2018-12-1216:42royalaidthat help at all?#2018-12-1216:42thhellerwhats the purpose of the ::release-flag?#2018-12-1216:42royalaidTo set at the command line between our env's, test, staging, prod, etc#2018-12-1216:43thhellerhow or where do you use that though? the compiler doesn't use that anywhere?#2018-12-1216:44royalaidOh#2018-12-1216:44royalaid1 sec I actually have to dig it up#2018-12-1216:44royalaid(inherited this project so some part of the code base are a bit of mystery to me still)#2018-12-1216:47thhelleras for the build reports there currently is no option to let you edit the config before compiling#2018-12-1216:47thhellerbut I could probably add a similar thing so you can modify the the build config similar to release*#2018-12-1217:47hoopeshi, sorry for what's probably a simple question, but has anyone used npm fonts with shadow-cljs? like, once i npm install --save some-font, what's the preferred method for actually using it?#2018-12-1217:50thheller@hoopes shadow-cljs does not support any fonts or css so you'll have to use the usual tools for that#2018-12-1217:50hoopesgotcha - thanks!#2018-12-1218:49royalaid@thheller thanks so much!#2018-12-1218:53thheller?#2018-12-1219:13royalaidFor investigating and the info#2018-12-1219:13royalaidSaves me some time from trying to plug it together right now#2018-12-1300:01idiomancy
Error handling response - class java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
<eval>:12
:(function (){var writer__7270__auto__ = (new java.io.StringWriter());
                                         ^

ReferenceError: java is not defined
    at <eval>:12:42
    at <eval>:16:3
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at runInThisContext (vm.js:139:38)
    at global.SHADOW_NODE_EVAL ([stdin]:75:30)
    at 
🤔
#2018-12-1300:26thheller@idiomancy that looks like it is trying to eval clojure code? that certainly is not valid CLJS 😉#2018-12-1300:31idiomancyyeah, thats what I mean. This seems to be an error printing an exception. This is very strange.
#2018-12-1300:32idiomancyits an error with a websocket call#2018-12-1300:32idiomancybeing executed from js interop#2018-12-1300:32idiomancywith no clojure involved#2018-12-1300:33idiomancy#2018-12-1300:33thhellerwhat are you sending to the REPL?#2018-12-1300:34thhellerit looks to me like something is sent to the REPL to be eval'd#2018-12-1300:34thhellerhence the websocket in the stacktrace since that triggers the eval#2018-12-1300:34idiomancyits an rpc call#2018-12-1300:34idiomancydoing blockchain stuff#2018-12-1300:35idiomancythats interesting though#2018-12-1300:35thhellerit looks to me like you are sending maybe some CLJ macro code to the REPL#2018-12-1300:35thhellerie. code that expands to CLJ not CLJS#2018-12-1300:36idiomancyhmmm#2018-12-1308:09ggaillardHey guys! Just encountered something strange with :infer-externs :auto (shadow 2.7.9): Given this code:
(ns foo.bar)
(defprotocol JustUsedAsATag)
(defrecord SomeRecord [field]
    JustUsedAsATag)
I get this warning:
Cannot infer target type in expression (. (. SomeRecord -prototype) -foo$bar$JustUsedAsATag$)
It happens only when the protocol do not declare any method (empty protocol). Is this related to shadow? Should I open an issue?
#2018-12-1308:34thheller@ggaillard interesting. never seen that before. it did not happen previously?#2018-12-1308:37ggaillardIt's the first time I have a use case for an empty protocol, so I never tried before. Anyway I never saw this warning while compiling other libs thought#2018-12-1308:40thhellerbut it did not happen with an empty protocol previously?#2018-12-1308:40thhellerI have an idea why it may be happening but confirmation would help#2018-12-1408:50ggaillardSorry I don't know since it's the first time I'm using an empty protocol.#2018-12-1312:56metacriticalHas anyone tried nw.js with shadow-cljs ?#2018-12-1312:59thhellerI'm using it with electron which is pretty much the same idea AFAICT?#2018-12-1313:03metacriticalyes#2018-12-1313:04metacritical@thheller Can you point me to a sample link on github?#2018-12-1313:04thhellerno idea about nw.js#2018-12-1313:05metacriticalI mean electron.#2018-12-1313:05thhellerslightly old but should still work https://github.com/shadow-cljs/examples/tree/master/electron#2018-12-1313:05thhellerhttps://github.com/ahonn/shadow-electron-starter#2018-12-1313:05thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L106-L129#2018-12-1313:06metacriticalWoW this is what i wanted, thanks @thheller#2018-12-1313:15aisamuGood morning! Is clj-refactor supported with the CIDER in shadow? Manually adding the dependencies don't seem to help. Here's what I currently have:
;; :dependencies 
                [com.billpiel/sayid "0.0.17"]
                [refactor-nrepl "2.4.0"]
                [cider/cider-nrepl "0.19.0-SNAPSHOT"]
;; Output after cider-connect
WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
CIDER is working fine, I'm just missing the refactoring features. (Haven't tried sayid, but I doubt it works on cljs)
#2018-12-1313:17thhelleryou need to add the middleware I guess#2018-12-1313:17thheller:nrepl {:middleware [something.from.refactor-nrepl]}#2018-12-1318:02aisamuStill get the "no project found" warning, but things are apparently working! Thanks!#2018-12-1314:29pez@thheller: I still fail with building a working :release build. I get this stack trace (hopefully I haven't trunkated it too early again):
TypeError: Cannot read property 'core' of undefined
extensionHostProcess.js:344
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:8:280)
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/cljs.core.js:2044:3)
	at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio )
	at Object.Module._extensions..js (module.js:653:10)
	at Module.load (module.js:561:32)
	at tryModuleLoad (module.js:504:12)
	at Function.Module._load (module.js:496:3)
	at Function.t._load (/Applications/Visual Studio )
	at Function.t.getExtensionPathIndex.then.s._load (/Applications/Visual Studio )
	at Function.t.getExtensionPathIndex.then.r._load (/Applications/Visual Studio )
	at Module.require (module.js:586:17)
	at n (/Applications/Visual Studio )
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:1:232)
	at Object.<anonymous> (/Users/petery/Projects/calva-lib/packages/lib/calva.fmt.formatter.js:37:3)
	at Module.t._initNodeRequire.r._compile (/Applications/Visual Studio )
At /lib/calva.fmt.formatter.js:1:232 it is requiring calva.js_utils.js which is built from this small cljs file:
(ns calva.js-utils)

(defn ^:export jsify [o]
  (clj->js o))

(defn ^:export cljify [o]
  (js->clj o :keywordize-keys true))
#2018-12-1314:31thhellerwhat do the first few lines of /Users/petery/Projects/calva-lib/packages/lib/cljs.core.js look like?#2018-12-1314:33pezFirst two:
var window=global;var $CLJS=require("./cljs_env");require("./goog.math.long.js");require("./goog.math.integer.js");require("./goog.string.string.js");require("./goog.object.object.js");require("./goog.array.array.js");require("./goog.uri.uri.js");require("./goog.string.stringbuffer.js");
var cljs$cst$keyword$ns,cljs$cst$symbol$root,cljs$cst$symbol$default_DASH_dispatch_DASH_val,cljs$cst$symbol$mseq,cljs$cst$symbol$defrecord_STAR_,cljs$cst$keyword$val,cljs$cst$symbol$_meta,cljs$cst$symbol$js_STAR_,cljs$cst$symbol$__hash,cljs$cst$symbol$ns_STAR_,cljs$cst$symbol$ascending_QMARK_,cljs$cst$symbol$fqn,cljs$cst$symbol$update_DASH_count,cljs$cst$symbol$off,cljs$cst$symbol$cnt,cljs$cst$keyword$status,cljs$cst$keyword$descendants,cljs$cst$symbol$nil_DASH_val,cljs$cst$symbol$dispatch_DASH_fn,
#2018-12-1314:34thhellerlooks like its supposed to#2018-12-1314:34thhellercan you gist the full file?#2018-12-1314:35pezSure!#2018-12-1314:36pezhttps://gist.github.com/PEZ/fa9cb69385d3dda4818688c74d9562eb#2018-12-1314:38thhellerhmm odd#2018-12-1314:39thhellernot sure why this is happening but the code is in the wrong order#2018-12-1314:40thhellermay actually happen because of :simple. not actually sure though.#2018-12-1314:41pezLet me try to remove that then…#2018-12-1314:41thhellerhmm yeah its probably because of :simple#2018-12-1314:41thheller$CLJS.cljs = { tools: {} }; is declared too later#2018-12-1314:41thhelleror rather it is used before it is declared#2018-12-1314:43pezYeah, w/o :simple the build works.#2018-12-1314:44pezI assume it does not really matter for my extension?#2018-12-1318:27WhiskasHow do i reference a javascript file from CLJS? i already inserted the folder in the source path#2018-12-1318:31thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2018-12-1318:35Whiskas@thheller, do you recommend using this when working with JSX or there is another way?#2018-12-1318:35Whiskasi am already compiling the files with babel#2018-12-1318:35thhellerthe babel example I linked the other day is pretty much what I recommend yes#2018-12-1318:43WhiskasDo you know what is the main cause of this error? :
[:app] Build failure:
The required JS dependency "Components/list" is not available, it was required by "dbiz_health/common/views.cljs".

Searched in:/Users/pimentel/Projetos/dbiz-health/node_modules

You probably need to run:
  npm install Components/list
#2018-12-1318:44Whiskasit is looking for it in node_modules#2018-12-1318:44Whiskas
:source-paths
 ["src/cljs"
  "src/clj"
  "src/gen"
  "test/cljs"
  "test/clj"]
#2018-12-1318:44thhellerbecause you didn't read the docs#2018-12-1318:45Whiskaswhen i read them i got the belief that putting the folder in sources was enough, i think i did not read it more carefully#2018-12-1318:45thhelleryou need the / in front otherwise it'll check node_modules as thats the notation for npm#2018-12-1318:49Whiskasit worked, thanks#2018-12-1319:32WhiskasI’m seeing that this example is kinda different from the javascript i generated locally#2018-12-1319:32Whiskas
import React from "react"


const MyComponent = ({ key }) => {
  console.log('child props: ', key)
  return (
    <li key={key}>
      Hello JSX!
    </li>
  )
}

const MyDefaultComponent = ({ children }) =>
  <div>
    <h1>Hello JSX!</h1>
    <ul>
      {children}
    </ul>
  </div>


export { MyComponent }

export default MyDefaultComponent
#2018-12-1319:33WhiskasI’m having a null reference error in “React”#2018-12-1319:33WhiskasMy generated file is importing React with the ES6 syntax import React from "react"#2018-12-1319:33Whiskasand the one from the example is doing it in another way#2018-12-1319:34WhiskasShould i try to generate .js files like that or the cause for this error is other?#2018-12-1319:35WhiskasError:
MyComponent.js:7 Uncaught TypeError: Cannot read property 'createElement' of undefined
    at MyComponent (MyComponent.js:7)
    at beginWork (react-dom.development.js:14564)
    at performUnitOfWork (react-dom.development.js:17821)
    at workLoop (react-dom.development.js:17861)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
    at invokeGuardedCallback (react-dom.development.js:257)
    at replayUnitOfWork (react-dom.development.js:17108)
    at renderRoot (react-dom.development.js:17980)
    at performWorkOnRoot (react-dom.development.js:18838)
#2018-12-1319:36thhelleryou must generate ES6 modules. don't let babel turn import into require#2018-12-1319:38thhelleralso you pasted the same code twice? where is yours?#2018-12-1319:39Whiskasops, i think i edited the wrong post,#2018-12-1319:39Whiskasi will edit it again#2018-12-1319:39WhiskasSo, i did a test here#2018-12-1319:39Whiskasand with es2015 it works fine#2018-12-1319:40Whiskasi just need to learn how to make it to work with es2016#2018-12-1319:40Whiskasi will post the generated es2016#2018-12-1319:40Whiskasgenerated es2016:
import React from "react";

var MyComponent = function MyComponent(_ref) {
  var key = _ref.key;

  console.log('child props: ', key);
  return React.createElement(
    "li",
    { key: key },
    "Hello JSX!"
  );
};

var MyDefaultComponent = function MyDefaultComponent(_ref2) {
  var children = _ref2.children;
  return React.createElement(
    "div",
    null,
    React.createElement(
      "h1",
      null,
      "Hello JSX!"
    ),
    React.createElement(
      "ul",
      null,
      children
    )
  );
};

export { MyComponent };

export default MyDefaultComponent;
`
#2018-12-1319:41lilactownlgtm#2018-12-1319:42Whiskasthe null reference error is coming from React when trying to call .createElement#2018-12-1319:44thhellerhmm es6 is supposed to work but maybe the import stuff for npm is broken there#2018-12-1319:44thhellerhaven't used that in a while#2018-12-1319:44thhellerstick with es2015 for now. don't have time to look into it right now.#2018-12-1319:44Whiskasalright#2018-12-1319:45Whiskasthe difference between using e2016 and 2015 is that es2015 does’nt get google closure’s advanced optimization, right?#2018-12-1319:45thhellerthat is correct yes#2018-12-1416:30justinbarclaySo I've run into a problem with requiring an npm module, "auth0-js", that the files it produces aren't named the way that shadow-clj expects. Instead of being "auth0-js.js", the files are just called "auth0.js". https://github.com/auth0/auth0.js/blob/master/package.json Are there any work -a-rounds for this?#2018-12-1416:34thheller@emoarmy not sure what you mean. it doesn't matter to shadow-cljs at all.#2018-12-1416:35thheller(:require ["auth0-js" :as ajs])#2018-12-1416:41justinbarclayOk, sorry. I'm going to look into this more on my end. It looks like I was misreading an error message.#2018-12-1418:45justinbarclayI think I’ve found my issue… I have a require statement as such:
(ns 
  (:require ["auth0-js" :as ajs]))
But when I run shadow-cljs watch frontend This error pops up in my console: "shadow.js.js:87 shadow-cljs - failed to load module$node_modules$auth0_js$dist$auth0_min" I think what’s happening is that the “auth0-js” is getting converted to “auth0_js”, but npm doesn’t follow the naming convention where a - translate to a folder structure with an _. I’ve got a repo here to recreate the issue: https://github.com/justinbarclay/auth0-js-bug
#2018-12-1419:58thheller@emoarmy the error has absolutely nothing to do with the generated filename#2018-12-1419:59thhellerit just tells you that it failed to load that file because of some error that occured while loading the file#2018-12-1420:00thhellercannot read property lib of undefined is that error#2018-12-1420:01thhellertry :js-options {:variable-renaming :local} in your build config#2018-12-1420:01thhellerauth0-js will always be renamed to auth0_js since auth0-js is auth0 - js in javascript since - is an operator#2018-12-1420:04justinbarclayAwesome! That worked wonderfully, thank you for your time!#2018-12-1420:06justinbarclayIs this config used directly by the closure compiler? I’m wondering where else I should be looking next time I run into an issue like this#2018-12-1420:09thhellernormally you shouldn't need any of those options. the defaults should work. I know for a fact that setting this :variable-renaming :local will break other JS libs#2018-12-1420:09thhellerbut yes that is a closure compiler option when transforming the JS code#2018-12-1501:18lilactownwith latest clojurescript master, I’m getting a stacktrace when I try and run a watch#2018-12-1501:20lilactownhttps://gist.github.com/Lokeh/0b9a0e0551e320859cc2e509a58410f8#2018-12-1501:22lilactownrepo you can test: https://github.com/Lokeh/hx/tree/datafy#2018-12-1501:28lilactown82c10925eb8d9c3cecf23447ddf4e1342f120b69 (commit before HEAD of master) works fine, so it’s something in https://github.com/clojure/clojurescript/commit/6ccb629e365f46a9516e4defeced652cce9d4d35#2018-12-1507:40Jongot a question, I want to build my code in dev mode and prod mode, so I created a macro to read from environment variable. however shadow-cljs runs a watch server, which means the code compiles in another process, by environment variable does not work when watch server is running. where should I put the variable now?#2018-12-1507:58pezNot sure I follow, @jiyinyiyong. watch is only for dev mode. #2018-12-1508:19Jonyep, watch server is running all the time, and I run watch on my own laptop.#2018-12-1508:20Jonmaybe I should change that. not trying CIs yet.#2018-12-1508:51pez@jiyinyiyong one thing you can do is to checkout the project in another directory and run release there.#2018-12-1508:54Jonmaybe time for a CI.#2018-12-1511:16thheller> so I created a macro to read from environment variable#2018-12-1511:17thheller@jiyinyiyong don't do that. it breaks caching as the cache won't invalidate if you change the env var#2018-12-1511:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2018-12-1607:35Jonrelease specific configs is still not enough. tried closure-define, no lick either. At last I switched to browser/nodejs(environment variables) for detecting environment.#2018-12-1607:35Jonat runtime, rather than at compilation.#2018-12-1607:37JonI thought it would become more predictable if I could decide the environment during compilation. However that breaks caching you mentioned.#2018-12-1511:28thheller@lilactown that commit is invalid. clojure doesn't like that either for me?#2018-12-1511:28thheller{::spec/keys [:problems :fn :cljs.spec.test.alpha/caller]} data#2018-12-1511:29thheller
(let [{:spec/keys [:problems]} data]
  problems)
#2018-12-1511:29thheller
CompilerException clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/local-name at: [:args :bindings :binding :map :mb 0 :sym] predicate: simple-symbol?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/seq-binding-form at: [:args :bindings :binding :map :mb 0 :seq] predicate: vector?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-bindings at: [:args :bindings :binding :map :mb 0 :map] predicate: coll?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-special-binding at: [:args :bindings :binding :map :mb 0 :map] predicate: map?
In: [0 0 0 1 0] val: :problems fails spec: :clojure.core.specs.alpha/ns-keys at: [:args :bindings :binding :map :nsk 1] predicate: simple-symbol?
In: [0 0 0 0] val: :spec/keys fails spec: :clojure.core.specs.alpha/map-bindings at: [:args :bindings :binding :map :msb 0] predicate: #{:as :or :syms :keys :strs}
...
#2018-12-1511:29thhellerin a clojure REPL?#2018-12-1511:30thhellerits not supposed to take keywords in :keys destructuring?#2018-12-1511:32thheller{:clojure.spec.alpha/keys [problems fn], :clojure.spec.test.alpha/keys [caller]} data is the clojure variant. not sure why that was changed?#2018-12-1516:28lilactownack#2018-12-1516:29lilactownI wonder why when I tried it with the regular CLJS main REPL, Nashorn REPL, and figwheel it didn’t complain#2018-12-1517:41thheller@lilactown shadow-cljs uses the core specs from clojure for CLJS. those are not included in normal CLJS yet#2018-12-1517:41thheller(and I believe it defaults to clojure 1.8 which also didn't have them)#2018-12-1617:43lilactownI'm trying to figure out how best to setup my library to be consumed by both shadow-cljs and vanilla cljs projects re: npm deps#2018-12-1617:44lilactownIt depends on react#2018-12-1617:44thhellerjust depend on cljsjs/react#2018-12-1617:46lilactownI was dissuaded from trying to use deps.cljs#2018-12-1617:48lilactownHmm. So if I need an alpha version of react, I'll probably have to get that onto cljsjs myself#2018-12-1618:03thhelleryeah thats pretty much the only way for other cljs tools#2018-12-1618:03thhellerfor shadow-cljs it would be fine with deps.cljs {:npm-deps {"react" "that-version"}}#2018-12-1618:59lilactowngotcha thanks!#2018-12-1619:00lilactownunrelated question: you were doing some work on a UI for shadow-cljs. I remember seeing a REPL. was this a true, connected-to-my-app REPL?#2018-12-1619:03lilactownactually just realized it’s in the current latest of shadow-cljs, answered my own question: it is! 😄#2018-12-1619:04thhelleryeah. needs a lot more work though#2018-12-1619:04lilactownis it talking nREPL to my app?#2018-12-1619:08thhellergeez no. nrepl is a horrible protocol to work with 😛#2018-12-1619:08thhelleralso would be kinda pointless since the app is served by shadow-cljs#2018-12-1619:09thhellerconnecting to the nrepl server provided by shadow-cljs is an extra step we don't need 😉#2018-12-1619:26lilactownhaha!#2018-12-1619:27lilactownI’m curious how it works then. I’m interested in embedding a CLJS REPL in an app for some dev tooling I’m thinking about… I was worried I would have to setup the self-hosted bootstrapping in any apps that used it tho#2018-12-1619:33lilactownah OK, looks like it’s talking over a websocket at the shadow-cljs app server using some custom format. it must be running that to shadow-cljs’ machinery for sending code to be evaluated in process#2018-12-1619:37thhelleryes that part is the same as nrepl or any other shadow-cljs repl#2018-12-1619:37thhellerthe app talks to shadow-cljs via ws#2018-12-1619:39thhellercljs-repl is pretty tricky so its not super easy to embed from a library or so#2018-12-1700:10flyboarderanyone know why this started popping up? could not find string alias for "socket.io-client" from app.client#2018-12-1700:21flyboarder@thheller ^#2018-12-1700:47flyboarderweird - I restart some of my builds and it went away#2018-12-1716:52royalaidCross posting from the CLJS Slack channel: https://clojurians.slack.com/archives/C03S1L9DN/p1545065495662700#2018-12-1717:17mj_langfordThank you very much for writing that up.#2018-12-1717:02thheller@royalaid nice. why are you using the node.js JS REPL instead of a CLJS REPL though?#2018-12-1717:03royalaidMostly because I wanted to show what it looks like calling into CLJS from JS#2018-12-1717:04royalaidI plan on making a follow up post gluing together DynamoDB and a lambda and using the NodeJS view of the world to show how to two are connected#2018-12-1717:04royalaidThat being said I also want to show the Dev workflow using the repl to debug too#2018-12-1717:04royalaidbut it really hard for me to capture that process in a meaningful using just text#2018-12-1717:05royalaidIt feels like the best way for newcomers to experience the repl is just watching a dev use it, like the first time someone watches a person who knows vim jet around a file#2018-12-1717:06thhellerI think it would be less confusing with a CLJS REPL but if showing the interop is your goal I guess thats fine#2018-12-1717:07thhellerthis way you kinda have to know a few things about the internals#2018-12-1717:07richiardiandreaHad the same thought, just finished reading the blog post simple_smile #2018-12-1717:07royalaidYeah still trying to find my feet with blogging so this feedback helps a ton, thank you!#2018-12-1717:07thhelleror this m.aws.createTable() isn't immediately obvious what this actually calls#2018-12-1717:08royalaidNow that is something I may make an edit for clarity#2018-12-1717:08thhellershadow-cljs node-repl (require '[server.create-table :as ct]) (ct/invoke) might be cleaner#2018-12-1717:16WhiskasSomeone here knows how to make cljs with live reloading debugabble?#2018-12-1717:16Whiskasin chrome#2018-12-1717:20thhellerwhich part do you want to debug?#2018-12-1717:22WhiskasSo, in chrome, i am able to set breakpoints in code when i go in Sources tab at js/compiled/out/cljs-runtime/[…] , but when i update the code and live reload it, this code is’nt being updated too#2018-12-1717:22Whiskaslike, i think some implementations put a timestamp on these cljs files url everytime they are updated#2018-12-1717:23thhellerwhy not set the breakpoint in the cljs file?#2018-12-1717:23Whiskasi set on the cljs,#2018-12-1717:23Whiskaswhat i mean is that the files are not being updated as i change them#2018-12-1717:23Whiskasso i can’t set breakpoints on new code#2018-12-1717:25thhellernot sure to be honest. never tried this. the timestamp is mostly used for cache busting, don't think it is used for debugging purposes#2018-12-1717:26Whiskasit is usefull in the sense that when you cache bust the code you can debug what you have just written without reloading the page again, hah#2018-12-1717:26Whiskasis it possible to enable it?#2018-12-1717:27thhelleryou can try to take this file and put it into your classpath#2018-12-1717:27thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L63#2018-12-1717:28thhellerchange that line to add "?rand=" (rand) at the end (after resource-name)#2018-12-1717:28thhellermaybe that does the trick#2018-12-1717:29Whiskasalright#2018-12-1717:29Whiskasthanks#2018-12-1717:30thhellerit might be because shadow-cljs doesn't actually reload files#2018-12-1717:30thhellerit loads the files as edn and evals them#2018-12-1717:30thhellerso the load isn't async#2018-12-1717:31thheller(and never has cache issues)#2018-12-1717:49Whiskasif i re-define that function within the namespace it will work too?#2018-12-1717:49thhellersure#2018-12-1717:50Whiskasi put browser.cljs into the folder path /shadow/cljs/devtools/client but i think it was’t executed again, so i will try that#2018-12-1717:50thhellermay need to restart the server for this to work#2018-12-1717:51thhellersince it already has the old file loaded and may just ignore the new one#2018-12-1717:51Whiskasalright#2018-12-1718:07WhiskasCan you see if this is right? i reloaded the server and i think it did not got this file#2018-12-1718:08thhellerassuming src/cljs is your source path?#2018-12-1718:10Whiskasyea#2018-12-1718:10Whiskasi tried running the whole file on repl too#2018-12-1718:11Whiskason the cljs repl#2018-12-1722:20jstaabHey there, I'm running into trouble getting transitive dependencies to install (in particular the js dependencies of a cljs dependency, macchiato). Anything I'm missing? For now I'm just installing them myself.#2018-12-1722:22thheller@jstaab since most cljs packages still rely on cljsjs and do not support npm they in turn don't properly declare their npm dependencies#2018-12-1722:23thhellerso we can't install them automatically#2018-12-1722:23jstaabGotcha#2018-12-1722:23jstaabWhere would I find the package.json for the installed version of my immediate dependency so I can hack something together?#2018-12-1722:24jstaabOr I guess that would be the problem wouldn't it#2018-12-1722:25thhellerthere is only the package.json in your project which you add the deps to manually#2018-12-1722:26jstaabMacchiato has one: https://github.com/macchiato-framework/macchiato-core/blob/master/package.json#2018-12-1722:26jstaabIs there any way to get at that? Maybe it's excluded from the installed version#2018-12-1722:26thhellerin its project but not in its .jar#2018-12-1722:27jstaabwhere would shadow-cljs put that?#2018-12-1722:27thhellerit doesn't exist. do not waste your time looking for it#2018-12-1722:28jstaabOk, thanks#2018-12-1722:28thhellerit will be located in the maven repo#2018-12-1722:28thhellerso ~/.m2/repository/whatever/macchiato..../something-version.jar#2018-12-1722:28thhelleryou can check whats in it with jar -tvf that.jar#2018-12-1722:29thhellerbut even if it would ship its package.json it would not be a common thing to do#2018-12-1722:29thhellerso you'd need to talk to every library author to add it#2018-12-1722:29thhellerand at that point you could instead convince them to add deps.cljs instead#2018-12-1722:30thhellerthere is no "standard" for this yet and I don't know what to do to get one#2018-12-1722:30jstaabDoes shadow-cljs support deps.cljs?#2018-12-1722:30thhellerits a complicated situation thats not just solved by adding a package.json or whatever#2018-12-1722:30jstaabSure#2018-12-1722:30thheller:npm-deps in deps.cljs yes. nothing else.#2018-12-1722:30jstaabI didn't even realize maven was involved#2018-12-1722:30jstaabOk, cool I'll try that#2018-12-1722:31jstaabI mean, it doesn't solve my problem, but seems better than a package.json, which is what I'm currently doing#2018-12-1722:32thhellerdefinitely use a package.json in your project#2018-12-1722:32thhellerI cannot emphasize that enough. do NOT rely on deps.cljs#2018-12-1722:32jstaabha#2018-12-1722:32jstaabok#2018-12-1722:32thhelleralways use package.json and KEEP your lock file#2018-12-1722:33jstaabIs deps.cljs just for libs? or is that just the non-existent standard you were talking about?#2018-12-1722:33thhellerotherwise npm becomes one unpredicatable mess#2018-12-1722:33jstaabyeah, I learned about lockfiles the hard way#2018-12-1722:33thhellerdeps.cljs is just for libs#2018-12-1722:33jstaabok#2018-12-1722:33jstaabthanks again!#2018-12-1722:33jstaabThis is complex#2018-12-1722:33jstaabI started reading shadow's source at one point and got completely lost#2018-12-1722:35thhellerit does a lot of stuff these days 😉#2018-12-1808:49manuelhi guys, upon starting shadow-cljs watch :my-app, I am getting this:
[2018-12-18 09:39:02.276 - INFO] Using tools.nrepl 0.2.* server!
This is my shadow-cljs.edn:
{:source-paths ["src/cljs"]
 :nrepl {:port 8777
         :middleware [refactor-nrepl.middleware/wrap-refactor]}
 :dependencies [[bidi "2.1.4"]
                [binaryage/devtools "0.9.10"]
                [cider/cider-nrepl "0.18.0"]
                [cljs-ajax "0.8.0"]
                [clojure-humanize "0.2.2"]
                [com.cemerick/url "0.1.1"]
                [hickory "0.7.1"]
                [day8.re-frame/http-fx "0.1.6"]
                [kibu/pushy "0.3.8"]
                [macchiato/hiccups "0.4.1"]
                [re-frame "0.10.6"]
                [reagent "0.8.1"]
                [reagent-utils "0.3.1"]
                [refactor-nrepl "2.4.0"]]
 :builds {:my-app {:target :browser
                   :output-dir "resources/public/js"
                    :asset-path "/js"
                    :modules {:main {:entries [my-app.core]}}}}}
Any ideas? 🙂
#2018-12-1809:34thheller@manuel what is the problem?#2018-12-1809:34manuelI'm not sure it's related, but I get these warnings when I do cider-connect:
WARNING: CIDER requires nREPL 0.2.12 (or newer) to work properly
         More information.
WARNING: Can't determine Clojure's version. CIDER requires Clojure 1.8.0 (or newer).
         More information.
WARNING: CIDER requires cider-nrepl to be fully functional. Many things will not work without it!
         More information.
#2018-12-1809:36manuel(I cross-posted this problem in #cider, because I don't know to what it's related TBH)#2018-12-1809:37thhellerand you are on cider 0.18 on the emacs side?#2018-12-1809:38manuelnope, CIDER 0.19.0snapshot (package: 20181212.1936). But even using [cider/cider-nrepl "0.19.0-SNAPSHOT"] in shadow-cljs.edn doesn't fix it.#2018-12-1809:39thhellerare you sure? did you restart properly after changing it? AFAICT the versions need to match#2018-12-1809:39manuellet me try again#2018-12-1809:40thhellerand are you sure you are connecting to 8777? not using some other built-in nrepl mechanism that starts something via deps.edn? since you mentioned that#2018-12-1809:41manuelsame warnings#2018-12-1809:41manuelno, I explicity input the port 8777#2018-12-1809:41manuelI restarted Emacs, just to be sure, but the warnings are still there.#2018-12-1809:42thhellerand what startup message did you get?#2018-12-1809:42thheller[2018-12-18 09:39:02.276 - INFO] Using tools.nrepl 0.2.* server!#2018-12-1809:42thhellerthis should be gone right?#2018-12-1809:42manuelno still there#2018-12-1809:42thhellerthat should definitely be gone though#2018-12-1809:46manuelnote that on another project with [cider/cider-nrepl "0.18.0"] I haven't got neither the message nor the warnings after CIDER connect.#2018-12-1809:47manuel
❯ shadow-cljs clj-repl
shadow-cljs - config: /home/manuel/githubs/manuel-uberti/boodle/shadow-cljs.edn  cli version: 2.7.9  node: v8.14.0
shadow-cljs - starting ...
Dec 18, 2018 10:45:14 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Dec 18, 2018 10:45:14 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server version: 2.7.9
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 36281
shadow-cljs - nREPL server started on port 8777
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=> (require '[ :as io])
nil
[1:0]~shadow.user=> (io/resource "cider/nrepl.clj")
#object[java.net.URL 0x324afa73 "jar:file:/home/manuel/.m2/repository/cider/cider-nrepl/0.18.0/cider-nrepl-0.18.0.jar!/cider/nrepl.clj"]
#2018-12-1809:49thheller
[com.cemerick/austin "0.1.3"]
  [com.cemerick/piggieback "0.1.2"]
    [org.clojure/tools.nrepl "0.2.3"]
#2018-12-1809:49thhellerthat should not be there#2018-12-1809:50thhellernot sure what adds that dependency#2018-12-1809:50manuellet me check#2018-12-1809:50thhellerbut it messed up cider.nrepl detection of which nrepl server to uise#2018-12-1809:51manuelfound it: macchiato/hiccups#2018-12-1809:51manuelI'll exclude austin from it.#2018-12-1809:53manuelfixed it, you're the man! 🙂 Thank you!#2018-12-1811:05davidwHi. We have an app that uses a library, both app and lib are under our control, both have clj/cljs/cljc code. We use deps.edn and the app references the library with a git sha. We need to hand over the source code for the app to our client but not the source code for the library. On the jvm side I can create an aot compiled skinny jar for the lib. Is there something similar I can do on the javascript side so that I can still use the library, with no/minimal code changes, but without distributing the source?#2018-12-1811:20thheller@davidw no that is not possible. CLJS compiler needs the full analyzer data to compile which it can only build from source#2018-12-1811:41davidwI don't really know how the whole compilation process works so this may be a stupid question but would it not be possible to bundle up the js files that get generated during a dev build in cljs-runtime and then use them when compiling the app? The CLJS compiler has already generated js for those namespaces, no?#2018-12-1811:42thhellerno. the analyzer data is needed for namespaces that :require your lib#2018-12-1811:42thhellerand macros also make this complicated#2018-12-1811:43thhellerwhy is it so bad to ship the source code? its not exactly "secret" either with AOT compilation#2018-12-1811:43thhellerthats what licences are for after all#2018-12-1811:45davidwI understand it's not "secret", etc. It's a constraint I've been given so it's what I'm trying to work within for now.#2018-12-1811:46thhelleryeah. It would not be impossible to do this but it would involve a bit of compiler work and nobody has worked on anything like that AFAICT#2018-12-1811:46thhellerand yeah macros make this extra tricky#2018-12-1811:50davidwif you don't mind I'd like to pick your brains on it a little more. Leaving macros aside for now 🙂. You've made it possible to :require npm modules and they obviously don't have the cljs analyzer data. In theory could something similar be done to :require the pre-compiled .js output?#2018-12-1811:52thhellernot really. the cljs compiler can only emit cljs code with the anaylzer data present#2018-12-1811:52thhellerif that is not present it can only emit js code relying on interop#2018-12-1811:52thhellerso stuff like protocols don't work for example (since they require analyzer data and don't exist in JS)#2018-12-1811:53thhellerit is really the analyzer data that is the problem#2018-12-1811:53thhellerthe generated JS pretty much doesn't matter so that would work no problem#2018-12-1811:53thhellerbut analyzer data may change inbetween cljs versions#2018-12-1811:54thhellerso you'd need the analyzer data for your-library-v1.3-compiled-by-cljs-1.10.439#2018-12-1811:54thhellerand every other possible cljs version the user may be using at the time#2018-12-1811:54thhellerit is possible ... just a bit of work#2018-12-1811:59davidwIf it's possible, how do you think you'd you solve it? Would you package up the analyzer data?#2018-12-1812:01thhelleryeah bundle the js+analyzer data. somehow teach to compiler to discover and use it#2018-12-1812:02davidwok, sounds like more than "just a bit of work" 🙂#2018-12-1812:04thhellerit is definitely not a trivial bit of work yes#2018-12-1812:06davidwSo it seems my options are, compile the lib to js and use js interop which means quite extensive changes to the app code, or just distribute the source code in a jar.#2018-12-1812:26thhellerdo you use any CLJS-only features in the lib?#2018-12-1812:26thhellermacros, protocols, defrecord, deftype, etc?#2018-12-1812:27thhellerif not you can maybe get away with just shipping the JS#2018-12-1812:27thhellerI never actually tried and it is not recommended to do so but in theory it could work as it will be treated as Closure JS, like the closure library itself and that works fine.#2018-12-1812:28davidwhow would I go about testing it?#2018-12-1812:29thhellerdo a dev compile. take the files from the cljs-runtime dir for your lib only and put them into the classpath of the other app#2018-12-1812:29thhellereg. your.lib.foo.js#2018-12-1812:30thhellerdon't put the lib sources on the classpath of the app#2018-12-1812:30thhellerso that is only finds the js files (shadow-cljs will scan the classpath so make sure it doesn't contain the actual sources)
#2018-12-1812:31davidwok, I'll try that, thanks.#2018-12-1812:31thhellerit will definitely not be ideal but it might work#2018-12-1812:31thhelleras long as there are no macros 😉#2018-12-1812:32davidwok, do they need to be in namespaced subfolders on the classpath?#2018-12-1812:32thhellerno that doesn't matter for js files#2018-12-1812:33davidwok, thanks. I'll give it a try.#2018-12-1812:33thhellerthey will contain goog.provide("your.lib") which is all it needs#2018-12-1815:36Alex KHi folks. Anyone have an idea how to require Grommet in from NPM? I think they're doing something a bit odd with the es6 module exports, but I don't have the experience to say what that is or figure a way around it. Thanks.#2018-12-1817:39thhellerwhat did you try?#2018-12-1818:38Alex K[grommet :as g] at first. Nothing in g when I printed it in console other than that it was an es6 module. After that I looked at the index file the package.json indicated, and tried ["grommet/components" :as gc] ["grommet/contexts" :as gcon] ["grommet/default-props" :as gdp] ["grommet/themes" :as gt]. The latter three had relevant bits, but not components. Also tried pulling in components from the subdirectories, but everything I tried turned up undefined. I don't grok the exports stuff enough to know what else I should try.#2018-12-1818:45thhellerI get Cannot read property 'apply' of undefined when it tries to load the code#2018-12-1818:48thhellernot really sure whats happening but it has nothing to do with exports or how you require it#2018-12-1818:48thhellerit just fails to load module$node_modules$grommet$components$Box$Box#2018-12-1818:59thhellerok what the actual F#2018-12-1819:00thhellerthere is definitely something weird in the code 😛#2018-12-1819:05lilactowntheir website is also slow as molasses#2018-12-1819:09thhellersorry. not a clue what is happening here. completely clueless what is even going on in that code#2018-12-1819:11Alex KNot a problem. I've been getting the feeling that library might not be dependable anyway. Thanks for trying, and thanks for shadow too. It's made things much easier.#2018-12-1820:51ShaneLesterHaving a bit of trouble finding some info on this- is there a semi-painless way to have shadow use a different version of clojurescript? Essentially, there has been a commit to the cljs repo that fixes an annoying bug for me, and I’d like to give it a shot while also continuing to use shadow etc.#2018-12-1820:58thheller@shanelester55 only if you use deps.edn or lein to manage your deps#2018-12-1820:59ShaneLesterAhh I see. The dependencies section of the shadow-cljs.edn won’t do the trick then? (I did attempt to require a clojurescript version in there but it spit out a message saying it wouldnt use it)#2018-12-1820:59thhellerno that doesn't support git deps which you'll need for this I guess?#2018-12-1821:00thhelleryes it currently enforces a cljs version to ensure compatibility#2018-12-1821:00ShaneLesterRight, that makes sense. Alrighty. Does shadow generally follow releases of clojurescript pretty closely?#2018-12-1821:00ShaneLesterI could just wait for another release after all#2018-12-1821:01thhelleryeah I'll usually update within the day of release#2018-12-1821:01ShaneLesterPerfect. I’ll probably just wait for the next release then 🙂#2018-12-1821:01ShaneLesterThanks for your help!#2018-12-1822:32flyboarderdoes this error ring any bells for anyone? java.lang.NoSuchFieldError: PARSE_RESULTS just after the server starts up#2018-12-1822:33flyboarderI assume this is a dependency problem#2018-12-1823:53thhelleryes probably bad closure-compiler dependency#2018-12-1900:10flyboarder@thheller thanks, I thought so - tracked it down. im just pinning what shadow-cljs uses for deps moving forward#2018-12-1900:16kennyTrying to get a new project set up with shadow-cljs. I always forget, what am I supposed to do when I see this message?
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
After running (shadow.cljs.devtools.api/nrepl-select :app).
#2018-12-1900:17jstaabIf it's a browser app opening the app in the browser does that for me if I recall correctly#2018-12-1900:17kennyI see all of this output in the console:
shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn  cli version: 2.7.9  node: v6.2.2
WARNING: The org.clojure/clojurescript dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
shadow-cljs - starting ...
Dec 18, 2018 4:14:27 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Dec 18, 2018 4:14:27 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server version: 2.7.9
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 33453
shadow-cljs - nREPL server started on port 9009
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (141 files, 1 compiled, 0 warnings, 1.27s)
I tried connecting to the url in that output http://localhost:9630 but that doesn't help.
#2018-12-1900:17jstaabWhat's your build target?#2018-12-1900:18kenny:browser#2018-12-1900:19jstaabYou need to visit it before you call nrepl-select I believe, did you try it in that order?#2018-12-1900:19kennyYes#2018-12-1900:21kennyMy guess is that's not the correct URL I need to visit. It's not clear what the right URL is though.#2018-12-1900:22kennyhttps://shadow-cljs.github.io/docs/UsersGuide.html#_connect_the_javascript_environment > For example, for browser development, browse to http://localhost:8080. Where does that URL come from?#2018-12-1900:23jstaabDoes 9630 run your app or the shadow cljs console thing?#2018-12-1900:23kennyThe console.#2018-12-1900:24jstaabOh ok, you do need to connect to your app. I feel like I usually see another line in there that shows your app's port#2018-12-1900:24jstaabI usually run shadow-cljs server and shadow-cljs watch app separately if that's any help#2018-12-1900:25kennyAll I get from running the former is this:
shadow-cljs server
shadow-cljs - config: /home/kenny/Forks/bide/shadow-cljs.edn  cli version: 2.7.9  node: v6.2.2
shadow-cljs - connected to server
server already running

#2018-12-1900:25jstaabUnfortunately, I haven't yet been able to grok shadow's source code so I'm still in black box land, though getting a bit better#2018-12-1900:25jstaabThe watch command implicitly starts a server, I just remember being confused by some odd behavior#2018-12-1900:26kennyI have a browser based library that I'd like to open a REPL for -- there's no "app" in the traditional sense.#2018-12-1900:27jstaabInteresting, do you have any modules specified in your shadow-cljs.edn?#2018-12-1900:27jstaabMaybe just paste that file#2018-12-1900:27kenny
{:source-paths ["src"]
 :dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
 :nrepl        {:port 9009}
 :builds       {:app {:target   :browser
                      :modules  {:main {:entries [bide.core]}}}}}
#2018-12-1900:28jstaabNo output-dir huh#2018-12-1900:28jstaabI got the sense that was required, is there a default?#2018-12-1900:28kennyNo idea. If it was required, I'd expect shadow-cljs to tell me that.#2018-12-1900:28jstaabFor sure#2018-12-1900:29jstaabI've noticed it's pretty tolerant to bad configuration though#2018-12-1900:29jstaabThough this one seems like a show stopper#2018-12-1900:29jstaabYeah, from the docs: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL
shadow-cljs - HTTP server for ":app" available at 
#2018-12-1900:30kennyWhy is that line not there for me?#2018-12-1900:30jstaabCouldn't tell ya#2018-12-1900:31jstaabDid you try adding an output-dir?#2018-12-1900:31jstaabAll the examples seem to have one, I know it's used for test builds etc#2018-12-1900:31kennyPretty sure it has a default given it created a public directory in my project.#2018-12-1900:31jstaabok, that sounds familiar#2018-12-1900:34jstaabHere's where the message comes from: https://github.com/thheller/shadow-cljs/blob/64c74fc5a60dcaebc5be152b447122d64765d5ce/src/main/shadow/cljs/devtools/server/dev_http.clj#L129#2018-12-1900:36jstaabOh hey https://shadow-cljs.github.io/docs/UsersGuide.html#browser-http-server#2018-12-1900:36jstaabAdd http-port to your config#2018-12-1900:37jstaabActually I'm not sure if that would do it, but you might try playing with the server options#2018-12-1900:39kennyI added all of the :devtools stuff
{:source-paths ["src"]
 :dependencies [[org.clojure/clojurescript "1.10.339" :scope "provided"]]
 :nrepl        {:port 9009}
 :builds       {:app {:target   :browser
                      :modules  {:main {:entries [bide.core]}}
                      :devtools {:http-root    "public"
                                 :http-port    3000
                                 :http-handler shadow.http.push-state/handle}}}}
then created an index.html and added script tag that loads the main.js file. That seems like a mighty high barrier to starting a browser REPL 🙂 It'd be cool to see that process simplified for cases like this.
#2018-12-1900:40jstaabFor sure, though compare to lein-cljsbuild, which is not much simpler, and significantly magicker#2018-12-1900:41jstaabIs it working for you then?#2018-12-1900:41kennyYes#2018-12-1900:42jstaabNice! Sorry my process was so slow; @thheller could have gotten you sorted much faster, I'm still learning 🙂#2018-12-1900:44kennyThanks for the help. This seems like it'd make a fantastic addition to the docs. I'll make a note and, if I have time this weekend, submit a PR.#2018-12-1900:46kennyAny idea if you can get hot reload of js files?#2018-12-1911:42thhellerwhat do you mean? actual .js files?#2018-12-1916:56kennyYes#2018-12-1900:46kennyIt appears any change to a js file requires a browser reload to be picked up.#2018-12-1900:48jstaabHmmm sounds plausible, maybe you could hack it by establishing your own file watcher and calling a rebuild function#2018-12-1900:48jstaabHaven't had that problem myself#2018-12-1910:42pepeHi. After upgrading to 2.7.9 my release build fails with this error:
TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2902)
    at Function.cljs.core.key__GT_js.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:2897)
    at mdc.615F7DC4.js:2901
    at $cljs$core$thisfn$$ (mdc.615F7DC4.js:2904)
    at Function.cljs.core.clj__GT_js.cljs$core$IFn$_invoke$arity$variadic (mdc.615F7DC4.js:2906)
    at Object.cljs.core.clj__GT_js (mdc.615F7DC4.js:2899)
    at Object.sablono.interpreter.attributes (back-office.9160B910.js:2201)
    at Object.sablono.interpreter.element (back-office.9160B910.js:2203)
    at Object.sablono.interpreter.interpret_vec (back-office.9160B910.js:2204)
    at cljs.core.PersistentVector.sablono$interpreter$IInterpreter$interpret$arity$1 (back-office.9160B910.js:2205)
    at Object.sablono.interpreter.interpret (back-office.9160B910.js:2187)
    at Function.<anonymous> (back-office.9160B910.js:9408)
    at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$3 (mdc.615F7DC4.js:1400)
    at Function.cljs.core.apply_to_simple.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1399)
    at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (mdc.615F7DC4.js:1422)
    at $class$$jscomp$6_mixins$$ (back-office.9160B910.js:2685)
    at fh (back-office.9160B910.js:112)
    at qg (back-office.9160B910.js:140)
    at rg (back-office.9160B910.js:141)
    at Jd (back-office.9160B910.js:153)
    at Sa (back-office.9160B910.js:152)
    at sg (back-office.9160B910.js:150)
    at Hb (back-office.9160B910.js:148)
    at Ag (back-office.9160B910.js:165)
    at Qe (back-office.9160B910.js:165)
    at sc.render (back-office.9160B910.js:214)
    at back-office.9160B910.js:169
    at yg (back-office.9160B910.js:164)
    at Od (back-office.9160B910.js:169)
    at Object.render (back-office.9160B910.js:216)
    at Object.rum.core.mount (back-office.9160B910.js:2702)
    at Object.my_trees.frontend.back_office.app.start (back-office.9160B910.js:9443)
    at Object.my_trees.frontend.back_office.app.init (back-office.9160B910.js:9448)
    at (index):1
#2018-12-1912:03aisamuHave you tried clearing node_modules? We observed a bunch of weird errors updating to 2.7.8 that went away with an rm -rf...#2018-12-1912:22pepeit didn't help#2018-12-1910:43pepeIt is with the :optimizations :simple#2018-12-1911:01pez@pepe what happens with advanced compilation?#2018-12-1911:02pepeSame error just cryptic 🙂.#2018-12-1911:44thheller@pepe not sure. probably something changed in cljs 1.10.439#2018-12-1911:46pepeOk. Is there direction you can direct me for investigation please? It seems it has something to dy with keyword creation#2018-12-1911:48thhellernot sure. probably hook up JS debugger with pause of exception and try to figure out whats happening#2018-12-1911:48thhellerwhat is undefined when it shouldn't be#2018-12-1914:16pepeIt is very strange $keyword_fn$$ is undefined in the clj->js function definition.#2018-12-1915:42pepeWhich should be name#2018-12-1915:48pepeAnd it is on third or fourth time the function is called.#2018-12-1912:12pepe@aisamu no, I will try. Thank you#2018-12-1912:17koala punchhi, i’m having problems connecting to shadow-cljs repl from cursive#2018-12-1912:17koala punchits trying to run cljs commands in a clj repl#2018-12-1912:17koala puncheven though i changed the dropdown, anyone else have this?#2018-12-1912:18thhellerthe dropdown doesn't mean anything#2018-12-1912:18koala punchbtw thheller, it’s a fantastic tool 🙂#2018-12-1912:18thhellerin the clj repl you must select the cljs repl of the build#2018-12-1912:18koala punchah i have to piggyback like in figwheel?#2018-12-1912:18thhellerby calling (shadow.cljs.devtools.api/repl :the-build)#2018-12-1912:18thhellerthat will automatically switch the cursive dropdown as well#2018-12-1912:19koala punchboom#2018-12-1912:19koala punchworking#2018-12-1912:19koala punchis that in the docs somehwere?#2018-12-1912:20thhellerprobably not prominent enough but yeah it is#2018-12-1912:20koala punchi couldn’t find it#2018-12-1912:21koala punchis there a trick so i don’thave to type it every time?#2018-12-1912:22thhellercreate a repl command in cursive and bind it to a key#2018-12-1912:24thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljs-repl#2018-12-1912:27achikinJust FYI regarding the funcool/decimal issue https://github.com/funcool/decimal/issues/7#issuecomment-448576845#2018-12-1912:27koala punchthanks#2018-12-1912:28koala punchexcellent, it’s all working now#2018-12-1912:28koala punchthanks 🙂#2018-12-1912:29koala punchcalva works out of the box#2018-12-1912:29koala punchcursive seems more fiddly#2018-12-1912:29thheller@achikin does it not also need some Decimal global or so?#2018-12-1912:30thheller@christopher.paul calva as additional support for shadow-cljs. cursive does not (yet)#2018-12-1912:30koala punchyea i noticed 🙂#2018-12-1912:55achikin@thheller it only requires js/Decimal.noConflict in a form of a function.#2018-12-1913:02thheller@achikin right;. but you are not calling that fn so it probably should be (js/goog.exportSymbol "Decimal.noConflict" decimal-js/noConflict)#2018-12-1913:04achikin@thheller as far as I can see from the sources of funcool/decimal
(def ^:static +decimal+ (js/Decimal.noConflict))
(def ^:dynamic *decimal* +decimal+)
I need to provide a function, which can be called by decimal.core
#2018-12-1913:04achikinhttps://github.com/funcool/decimal/blob/master/src/decimal/core.cljs#L9#2018-12-1913:05thhelleryeah#2018-12-1913:05thhellerbut you are just removing the noConflict call basically#2018-12-1913:05thhellersince all you provide is something that returns Decimal#2018-12-1913:06achikinnoConflict does basically the same#2018-12-1913:06thheller(js/goog.exportSymbol "Decimal" decimal-js) might also work?#2018-12-1913:07achikinLet me try both of your solutions.#2018-12-1913:07thhellershould stay as close as possible to the original without changing semantics#2018-12-1913:07thhellergranted I don't know anything about the package#2018-12-1913:08achikin> (js/goog.exportSymbol "Decimal" decimal-js) might also work? I'm not sure about this one because noConflict depends on the global environment of javascript...#2018-12-1913:08achikinI've tried some more simple solutions and it appears that noConflict remains empty...#2018-12-1913:08thhellerah ok. it thats not always available thats fine I guess#2018-12-1913:09achikinI'm not very much into js, and this looks confusing for me#2018-12-1913:09achikin
// Export.
  if (typeof window !== 'undefined') {
      globalScope = window;
  } else if (typeof global !== 'undefined') {
      globalScope = global;
  }
  if (!globalScope) {
    globalScope = typeof self != 'undefined' && self && self.self == self
      ? self : Function('return this')();
  }

  noConflict = globalScope.Decimal;
  Decimal.noConflict = function () {
    globalScope.Decimal = noConflict;
    return Decimal;
  };

  globalScope.Decimal = Decimal;
})(this);
#2018-12-1913:10achikinI think in my case it sets globalScope.Decimal properly, but not globalScope.Decimal.noConflict#2018-12-1913:11achikinAnd as soon as funcool tries to access noConflict instead of the Decimal directly - that does not always work properly...#2018-12-1919:31lilactownthere’s no way to reference an edn file in the source path, is there?#2018-12-1919:44thhellerprobably better to load it at runtime. otherwise a macro can do that although not recommended.#2018-12-2006:15ahungryDoes shadow cljs support specifying the clojure / clojurescript versions in the edn file? I would really like to use 1.10 for the new error reporting but my OS level install is 1.9 still#2018-12-2006:16ahungryOh, I suppose this answers that : `#2018-12-2006:16ahungryWARNING: The org.clojure/clojure dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility. WARNING: The org.clojure/clojurescript dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.#2018-12-2006:17lilactown@m131 you can specify a diff version of either clojure or cljs if you use deps.edn or leiningen integration#2018-12-2006:18lilactownI expect that you wont’ get much out of updating to Clojure 1.10, since you shouldn’t be writing much CLJ code with shadow-cljs?#2018-12-2006:18lilactownand shadow-cljs is up to date with the currently released version of CLJS#2018-12-2006:19ahungryoh, nice, thank you. Do the 1.9 features of spec work well in shadow-cljs / clojurescript?#2018-12-2006:20ahungryI've been playing with clojure the last 3 or 4 months, loving it. Now attempting to write an npm lib/module in shadow-cljs#2018-12-2006:20lilactownyeah, you have full access to clojure.spec.alpha in CLJS#2018-12-2006:21ahungryvery nice#2018-12-2006:21ahungrymy biggest pain-point now is unlike C-c M-j to just jack into a lein project automatically, it seems I have to start a shadow-cljs repl in the terminal and use cider-connect and then manually type a port - is that usual?#2018-12-2006:22ahungryand while that is annoying, it always defauls to clj not cljs, so then I must run (shadow.cljs.devtools.api/node-repl :dev) by hand in the repl to get to the app / node repl I guess?#2018-12-2006:22ahungry(Emacs btw)#2018-12-2006:22lilactownah hm#2018-12-2006:22lilactownI haven’t messed around with connect to a REPL for an npm lib before#2018-12-2006:23ahungryits good when its all set up, I can dev for awhile, just very cludgy (I guess I could write some custom elisp to auto insert the text in repl for me)#2018-12-2006:23lilactownwhen developing for the browser, or for a Node.js server, I just run cider-jack-in-clojurescript and it starts shadow-cljs and connects me to the REPL#2018-12-2006:23ahungrycider supports a C-c M-J command for cljs jack in, and I see that launches some type of nrepl with npx / shadow, but it then tries to open a browser ,which is useless for me#2018-12-2006:24ahungrynice, so, probably not a real common workflow i'm doing#2018-12-2006:24ahungry(trying to write a generic node/npm package in clojurescript)#2018-12-2006:24lilactownyeah for Node.js, I omit opening the browser page and instead start my node.js server#2018-12-2006:25lilactownI think there’s a command to just start a node-repl from a terminal, but i’m not sure if it starts nREPL#2018-12-2006:25lilactownwhat build target are you using?#2018-12-2006:27ahungrynode-library#2018-12-2006:27ahungryhttps://github.com/ahungry/functional-riemann-client#2018-12-2006:29ahungrywell, thank you for the help - gonna hit the hay, hopefully someone has solved this and is in the channel, or i'll whip up some abomination of elisp to auto-connect as needed and come share my findings tomorrow night or so 😆#2018-12-2006:29lilactownI would expect, based on the user guide, that you could start a watch build like normal and then run the compile Node.js script#2018-12-2006:30lilactownin which case you could probably use the normal cider-jack-in-clojurescript#2018-12-2006:30lilactownbut I don’t have time to try it - gotta leave as well 😄 good night!#2018-12-2006:30ahungryyou too#2018-12-2008:23pezI am pretty sure I've seen shadow jack-in code in cider. But, i might have dreamt it up too…#2018-12-2014:43aisamuIIRC, it asks for a repl type when you jack-in (either shadow or shadow-choice or something like it)#2018-12-2014:43justinbarclayI know for browser I can cider-jack-in-cljs, choose shadow-cljs, and then I get a couple of prompts such as which build I’d like to use. This was very similar to how I jacked in to lein,#2018-12-2021:24Whiskasthere are people using webpack with shadow-cljs?#2018-12-2021:40thheller@mateus.pimentel.w you can do that via :npm-module. https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2018-12-2102:53reaysawasup! when I switched to Lein following the user guide, I noticed I also had to manually include the same clojure/script jars as shadow-cljs in the dependencies did I do something wrong?#2018-12-2102:54reaysawaafter specifying them directly, the scripts began working again#2018-12-2107:46ouvasamHi, Is there a way to get an env var define in the console (e.g. export URI=http://uri) in the shadow-cljs.edn for compilation ? I use it closure-defines to pass it to cljs code Thanks#2018-12-2107:51ouvasamIf possible i would like something like that#2018-12-2107:51ouvasam#2018-12-2107:55ouvasamMay be i could do this with https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2018-12-2108:15thheller@ouvasam it is not recommended to use env vars during compilation since that suggests that you actually want to do runtime configuration during compilation#2018-12-2108:16thhelleryou could instead call your.app.init("") to initialize your app#2018-12-2108:16thhellerthat means you can change the URI without actually recompiling your code#2018-12-2108:16thhellerother than that you can use :closure-defines {foo.bar/uri #shadow/env "URI"} so use env vars in the config#2018-12-2108:17thhellerbut that is not recommended#2018-12-2108:19thheller@joao.paulo.silvasouza it is sometimes required to pin clojure/script versions when using lein yes. not doing it wrong as you are otherwise relaying on a bit of randomness when it comes to the deps#2018-12-2108:22ouvasam@thheller Ok Many thanks#2018-12-2114:20aisamuGood morning! What is the recommended approach for testing CLJ files with shadow-cljs? (The reason is testing a macro's helper functions)#2018-12-2116:34thheller@aisamu I typically do this with the clj REPL. not actually writing tests just evaling stuff until it looks right#2018-12-2116:35thhellerotherwise you can use the clj-run stuff to call your own main function to run the tests#2018-12-2116:36aisamuGreat, thanks!#2018-12-2116:41Logan Powell👋 hi everyone! Has anyone used shadow-cljs to publish something to clojars or do I need to use leiningen for this and dup the shadow-cljs.edn file -> project.clj?#2018-12-2116:42thheller@loganpowell publishing with shadow-cljs is not currently supported. project.clj + lein is easier currently IMHO#2018-12-2116:42Logan Powellgotcha#2018-12-2116:42Logan Powellshould it be a 1:1 setup for the project.clj (i.e., can I just copy the shadow.cljs.edn file)?#2018-12-2116:43Logan PowellI only used lein for like a week before finding shadow-cljs#2018-12-2116:43Logan Powell(I have very little lein experience)#2018-12-2116:44thhelleronly need to copy your :dependencies (don't include clojurescript or shadow-cljs itself)#2018-12-2116:44Logan Powellsweet! thank you 🙂 and thank you so much for all your work with shadow#2018-12-2116:45Logan Powelland all your help on Slack#2018-12-2116:45Logan Powell🙏#2018-12-2116:45thhellervery welcome#2018-12-2118:05Logan Powellare reader conditionals allowed in shadow? I'm getting an error trying to use them and just want to make sure I'm not barking up the wrong tree#2018-12-2118:05lilactownyes, they are#2018-12-2118:05Logan Powellok#2018-12-2118:05lilactownwhat’s the error you’re receiving?#2018-12-2118:06Logan Powell#2018-12-2118:06lilactownreader conditionals only are allowed inside of .cljc files#2018-12-2118:06Logan Powellfuck, thank you!#2018-12-2118:06Logan Powell😄#2018-12-2118:06lilactown😄 :+1:#2018-12-2118:07lilactownthere’s actually some much cooler things shadow-cljs can do with reader conditionals#2018-12-2118:07lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2018-12-2118:07lilactownit’s non-standard though#2018-12-2118:07Logan Powellwhoop#2018-12-2119:01richiardiandreaHello folks! question about tooling! So say I am working against a node-script target#2018-12-2119:01richiardiandreaand I do yarn shadow-cljs watch dev#2018-12-2119:01richiardiandreaam I also unnecessarily starting the web server machinery?#2018-12-2119:02richiardiandrea(I would expect that is started in :browser targets only#2018-12-2119:05richiardiandreaif that's the case I am interested in knowing if I can save some time in startup by contributing some tweak#2018-12-2119:39lilactownshadow-cljs starts a webserver for administrivia things#2018-12-2119:40lilactownyou probably see the log output where it’s starting it on port 9630#2018-12-2119:40lilactownunless you’re also seeing something like:
shadow-cljs - HTTP server for :workshop available at 
in which case I would expect that to not appear if you’re not configured your build to use the dev HTTP server options
#2018-12-2119:43richiardiandreawell I do not see it so that's probably already good then
Dec 21, 2018 11:39:24 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Dec 21, 2018 11:39:24 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - server version: 2.7.9
shadow-cljs - server running at 
shadow-cljs - socket REPL running on port 44729
shadow-cljs - nREPL server started on port 45909
shadow-cljs - watching build :repl
#2018-12-2119:43lilactownyep. the server at 9630 is a kind of admin UI for your builds#2018-12-2119:44richiardiandreaoh ok#2018-12-2120:32richiardiandreaopened a PR against shadow but I think I need some help#2018-12-2120:58ahungryhmm the solution to my jack in issue was to set this in Emacs: `#2018-12-2120:58ahungry
(add-to-list
          'cider-cljs-repl-types
          '(my-cljs-node-repl "(do (shadow.cljs.devtools.api/node-repl :dev))"))
#2018-12-2120:58ahungry(for shadow + nodejs repl without needing to start it via the CLI each time)#2018-12-2300:07vigilancetechwhen I'm in the repl (from emacs/cider) why would it give me an error in the shadow watch terminal that a variable is undeclared whereas in the repl it goes ahead and gives me its correct value?#2018-12-2313:32this.robIs it possible to have my shadow-cljs apps connect to the shadow-cljs server at something other than localhost while I'm developing? Instead of #2018-12-2313:33this.robe.g. if i'm running stuff in docker containers and want to have a container running the shadow-cljs server, and have others connect to it using the service name declared in a docker-compose file#2018-12-2314:55nilpunningI'm having trouble getting shadow-cljs working with deps.edn following these directions: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn. A basic example is here: https://github.com/nilpunning/shadow-deps. shadow-cljs start seems to go on forever and shadow-cljs watch app is failing:#2018-12-2314:55nilpunning#2018-12-2314:56thheller@nilpunning clojurescript 1.10.439 is required, older versions don't work (with shadow-cljs 2.7.x)#2018-12-2314:58nilpunningThat did it, you're the best! Thank you!#2018-12-2419:28orestisJust tried to use Shadow with IE11, and got an exception — possible because I’m loading my main bundle inside the head element and not the end of the body. Unfortunately I can’t work around that.#2018-12-2419:29orestisThis is in shadow.dom/append#2018-12-2419:29orestisThis works in chrome in safari macOS, not sure what’s the difference there.#2018-12-2419:35orestisFiled this: https://github.com/thheller/shadow-cljs/issues/422 — thanks for all the work and hope you’re getting some rest this holiday season 🙂#2018-12-2510:28Ivan FedorovHi fellas! Bumped into Uncaught Error: No protocol method IMapEntry.-key defined for type object: (:page-id "notes") Happens when code was generated with release compilation in secretary on some ubuntu linux (14.04 LTS). Same sources compile differently [;)] on macOS High Sierra and don’t cause any trouble after. Versions macOS shadow-cljs 6.4.1 lein 2.8.1 ubuntu shadow-cljs 6.4.1 lein 2.6.1#2018-12-2510:29thheller(:page-id "notes") what is that? that is not valid code?#2018-12-2510:30Ivan FedorovYep, this is an artifact after compilation on ubuntu system#2018-12-2510:30thhellercheck if lein deps :tree is different on the systems#2018-12-2510:31thhellermaybe you have something in your ~/.lein/profiles.clj?#2018-12-2510:31Ivan Fedorovthanks! a moment#2018-12-2510:38Ivan Fedorov#2018-12-2510:39thhellerhmm those don't affect the compiler. there is nothing system dependent in the compiler at all.#2018-12-2510:40thhellerdoes the error appear when compiling with shadow-cljs release your-build --pseudo-names?#2018-12-2510:41thhellerI suspect you have an externs issue. they behave very weirdly.#2018-12-2510:41Ivan Fedorovjvms may also be different, I think#2018-12-2510:41thhellershouldn't matter really#2018-12-2510:42thhellerit probably is just externs. you can confirm that if the error goes away with --pseudo-names pretty much#2018-12-2510:42Ivan Fedorovyep, trying it#2018-12-2510:49Ivan Fedorovissue persists#2018-12-2510:53thhellerhmm at least the error should change?#2018-12-2510:54thhellerdo you have a full stacktrace?#2018-12-2510:55Ivan Fedorovyup, full stracktrace
app.js?mtime=1545734833000:1642 Uncaught Error: No protocol method IMapEntry.-key defined for type object: (:page-id "notes")
    at $cljs$core$missing_protocol$$ (app.js?mtime=1545734833000:1642)
    at $cljs$core$_key$$ (app.js?mtime=1545734833000:1883)
    at app.js?mtime=1545734833000:10170
    at $cljs$core$seq_reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ (app.js?mtime=1545734833000:3895)
    at $cljs$core$Cons$$.$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$3$ (app.js?mtime=1545734833000:4523)
    at $cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ (app.js?mtime=1545734833000:3951)
    at app.js?mtime=1545734833000:10167
    at $cljs$core$array_reduce$cljs$0core$0IFn$0_invoke$0arity$04$$ (app.js?mtime=1545734833000:2864)
    at $cljs$core$IndexedSeq$$.$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$2$ (app.js?mtime=1545734833000:3016)
    at $cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$02$$ (app.js?mtime=1545734833000:3947)
$cljs$core$missing_protocol$$ @ app.js?mtime=1545734833000:1642
$cljs$core$_key$$ @ app.js?mtime=1545734833000:1883
(anonymous) @ app.js?mtime=1545734833000:10170
$cljs$core$seq_reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ @ app.js?mtime=1545734833000:3895
$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$3$ @ app.js?mtime=1545734833000:4523
$cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$03$$ @ app.js?mtime=1545734833000:3951
(anonymous) @ app.js?mtime=1545734833000:10167
$cljs$core$array_reduce$cljs$0core$0IFn$0_invoke$0arity$04$$ @ app.js?mtime=1545734833000:2864
$JSCompiler_prototypeAlias$$.$cljs$core$IReduce$_reduce$arity$2$ @ app.js?mtime=1545734833000:3016
$cljs$core$reduce$cljs$0core$0IFn$0_invoke$0arity$02$$ @ app.js?mtime=1545734833000:3947
$cljs$core$merge_with$$.$cljs$core$IFn$_invoke$arity$variadic$ @ app.js?mtime=1545734833000:10165
(anonymous) @ app.js?mtime=1545734833000:17692
$secretary$core$route_matches$$ @ app.js?mtime=1545734833000:17509
(anonymous) @ app.js?mtime=1545734833000:17716
$cljs$core$some$$ @ app.js?mtime=1545734833000:5440
$secretary$core$locate_route$$ @ app.js?mtime=1545734833000:17713
$secretary$core$dispatch_BANG_$$ @ app.js?mtime=1545734833000:17726
$app$routes$on_goog_navigate$$ @ app.js?mtime=1545734833000:17977
$JSCompiler_StaticMethods_fireListeners$$ @ app.js?mtime=1545734833000:17459
$goog$events$EventTarget$$.dispatchEvent @ app.js?mtime=1545734833000:17440
$app$routes$on_window_click$$ @ app.js?mtime=1545734833000:17970
#2018-12-2510:57thhellerwhere is the rest?#2018-12-2511:00Ivan Fedorovsorry, updated#2018-12-2511:02thhellerhmm. so the only thing I can think of thats actually different between the systems is the cache#2018-12-2511:02thhellertry deleting .shadow-cljs/builds#2018-12-2511:03thhellerthat'll reset the cache#2018-12-2511:03Ivan Fedorovsure! maybe .m2 as well for a good company?#2018-12-2511:03thhellerbut --pseudo-names didn't use the cache either so it really shouldn't matter#2018-12-2511:03thhellernah .m2 usually doesn't need to be deleted#2018-12-2511:06thhellerI assume the issue didn't happen with shadow-cljs compile your-build?#2018-12-2511:09Ivan Fedorovhaven’t tried on ubuntu server, will do in few mins#2018-12-2511:10Ivan FedorovmacOS compile and release always produced healthy bundles#2018-12-2511:12thhellerI have no idea how the OS could make any difference, never heard of any such issue#2018-12-2511:20Ivan FedorovAhem. Dear sir, please accept my resignation as I didn’t had a yarn.lock file in the repo index. Fixed it all.#2018-12-2511:22Ivan FedorovFound it when I tried to reproduce compile on the remote host.#2018-12-2511:22thhellerweird. how does that affect the CLJS code though?#2018-12-2511:22Ivan FedorovThank you for guidance and responsiveness! ❤️❤️🍺🍺#2018-12-2511:22Ivan FedorovI guess cljs might take some decisions based on env#2018-12-2511:23Ivan Fedorovor even different cljs versions?#2018-12-2511:23thhellerwell, best not to look to close at npm stuff 😉#2018-12-2511:24Ivan Fedorovis there a way to dump npm dep-tree used in compilation? If we’re interested#2018-12-2511:26thhellerbuild reports contain everything that went into the build but besides that there are only the common npm tools#2018-12-2511:48Ivan Fedorovany chance to send you a beer over Patreon or smth?#2018-12-2511:55thhellerstill need to set that up 😉#2018-12-2608:25kurt-o-sysjust wondering... just updated shadow-cljs and now, I seem to have a bunch of warnings:
------ WARNING #1 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/events.cljc:61:11
--------------------------------------------------------------------------------
 58 |       (if *handling*
 59 |         (console :error "re-frame: while handling \"" *handling* "\", dispatch-sync was called for \"" event-v "\". You can't call dispatch-sync within an event handler.")
 60 |         (binding [*handling*  event-v]
 61 |           (trace/with-trace {:operation event-id
-----------------^--------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.events/java
--------------------------------------------------------------------------------
 62 |                              :op-type   kind
 63 |                              :tags      {:event event-v}}
 64 |             (interceptor/execute event-v interceptors)))))))
 65 |
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:48:29
--------------------------------------------------------------------------------
 45 |   (let [cache-key [query-v dynv]]
 46 |     ;; when this reaction is no longer being used, remove it from the cache
 47 |     (add-on-dispose! r #(do (swap! query->reaction dissoc cache-key)
 48 |                             (trace/with-trace {:operation (first-in-vector query-v)
-----------------------------------^--------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
 49 |                                                :op-type   :sub/dispose
 50 |                                                :tags      {:query-v  query-v
 51 |                                                            :reaction (reagent-id r)}}
 52 |                               nil)))
--------------------------------------------------------------------------------

------ WARNING #3 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:111:4
--------------------------------------------------------------------------------
108 |   "
109 |
110 |   ([query]
111 |    (trace/with-trace {:operation (first-in-vector query)
----------^---------------------------------------------------------------------
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
112 |                       :op-type   :sub/create
113 |                       :tags      {:query-v query}}
114 |      (if-let [cached (cache-lookup query)]
115 |        (do
--------------------------------------------------------------------------------

------ WARNING #4 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:129:4
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------
#2018-12-2608:25kurt-o-sys
------ WARNING #5 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:305:34
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------

------ WARNING #6 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/subs.cljc:320:34
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.subs/java
--------------------------------------------------------------------------------

------ WARNING #7 --------------------------------------------------------------
File: mranderson048/re_frame/v0v10v2/re_frame/router.cljc:126:5
Use of undeclared Var mranderson048.re-frame.v0v10v2.re-frame.router/java
--------------------------------------------------------------------------------

------ WARNING #8 --------------------------------------------------------------
File: zprint/focus.cljc:100:47
cljs.core/-, all arguments must be numbers, got [#{nil clj-nil} number] instead
--------------------------------------------------------------------------------

------ WARNING #9 --------------------------------------------------------------
File: com/rpl/specter.cljc:1275:19
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------

------ WARNING #10 -------------------------------------------------------------
File: com/rpl/specter.cljc:1288:19
Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
#2018-12-2608:25kurt-o-sysAm I missing something?#2018-12-2610:35thheller@kurt-o-sys https://github.com/Day8/re-frame-10x/issues/219#2018-12-2610:36thhellerhttps://github.com/nathanmarz/specter/issues/267#2018-12-2612:43wombawombaI’m trying to use an NPM package that requires importing a CSS file. How can I do this with shadow-cljs? The readme for the package just says to do @import 'handsontable/dist/handsontable.full.css'; (https://github.com/handsontable/react-handsontable#handsontable-community-edition)#2018-12-2612:45wombawombaI guess this (https://github.com/thheller/shadow-cljs/issues/353) applies here?#2018-12-2616:25thheller@wombawomba CSS is not supported currently. you need to do that separately. I typically just use the node-sass CLI#2018-12-2616:28wombawombaAlright. Do I need to run that as a separate process, or can I get it to run together with shadow-cljs somehow?#2018-12-2616:28thhellerseparate for now#2018-12-2619:00this.robIs it possible to make shadow-cljs connect to a server running on a different host to localhost:9630 when running a build?#2018-12-2619:01thheller@rs it defaults to connecting to whichever url you load it from#2018-12-2619:02thhellerso if you load it'll try to connect to you can override which url it connects to by setting :devtools {:devtools-url ""}#2018-12-2619:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2018-12-2619:03this.robperfect, thanks!
#2018-12-2619:26this.robhmm not sure i'm understanding how this is suppose to work correctly... I am starting a shadow-cljs process with shadow-cljs server start, which will then be available at . I'm then running a couple of builds on different hosts, using shadow-cljs watch buildA and shadow-cljs watch buildB. At the moment these two builds start their own, new shadow-cljs processes instead of using the one already available at .#2018-12-2619:26this.robWhat I'd like is for those two build commands to reuse the already started shadow-cljs process#2018-12-2619:27thhellerah. you can't share a shadow-cljs server process between projects#2018-12-2619:28thhellerbut if you have one shadow-cljs server process running both watch should be using it#2018-12-2619:28thhelleryou can also just start shadow-cljs watch buildA buildB to run both#2018-12-2619:34this.robAh I see. Would it be a bad idea to share the server process? Or just something that hasn't been implemented?#2018-12-2620:30thhellerI looked into it but dependency management is annoying enough as it is#2018-12-2620:30thhellerso I won't be implementing it anytime soon#2018-12-2621:22this.robI can see how running across different hosts would make that even more annoying 😄#2018-12-2621:24this.robon another note... I've replicated the code here exactly, but my server isn't starting / stopping on initial shadow-cljs watch script or after changing anything in the src file#2018-12-2621:24this.robhttps://shadow-cljs.github.io/docs/UsersGuide.html#NodeHotCodeReload#2018-12-2621:25this.robit triggers a re-compile on change, but it doesn't seem to be running the :before-load-async and :after-load functions#2018-12-2621:25this.robhere's my full code: https://github.com/thisdotrob/shadow-cljs-node-hot-code-reload#2018-12-2621:25this.robany ideas?#2018-12-2622:41thheller@rs devtools aren't enabled by default for :node-script since they keep the process alive which isn't always what you want (eg. when building CLI scripts). you can set :devtools {:enabled true ...}#2018-12-2709:30this.rob@thheller thanks. Have set that flag, and also :autoload and :ignore-warnings to true: https://github.com/thisdotrob/shadow-cljs-node-hot-code-reload#2018-12-2709:30this.robbut it still isn't running the hooks :white_frowning_face:#2018-12-2709:34thheller@rs works for me?#2018-12-2709:34thheller
__filenamex /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js
starting server
http server running
stop called
stop completed undefined
__filenamex2 /mnt/c/Users/thheller/code/shadow-cljs/tmp/shadow-cljs-node-hot-code-reload/out/demo-script/script.js
start called
starting server
http server running
#2018-12-2709:42this.robMy bad, didn't realise you still had to run the script separately with node!#2018-12-2709:45this.robI was trying to replicate my other shadow-cljs project's setup which starts serving up a re-frame app straight automatically after compiling, but for node-script. More investigation needed simple_smile#2018-12-2709:46thhellerwell if its re-frame you probably open it in a browser?#2018-12-2709:46thhellernode script you need to run manually yes#2018-12-2709:52this.robYep open it in a browser, but I have :http-root and :http-port so it is being served up automatically after compiling#2018-12-2709:52this.robwas hoping to have a similar setup for my node server, with it starting automatically#2018-12-2709:53this.robperhaps this is beyond the scope of shadow-cljs' responsibilities though#2018-12-2709:53thheller@rs nothing starts automatically with a browser app. you need to open it otherwise nothing else happens. the http server literally just serves files nothing else.#2018-12-2709:54thhellernode server starting is out of scope yes since you may need stdin or just want a CLI script to exit#2018-12-2709:54thhelleryou can always use shadow-cljs node-repl and do things manually but it won't execute hooks#2018-12-2710:51orestis@thheller I’m trying to get started with a local fork of shadow — are there any more instructions than CONTRIBUTING.md ?#2018-12-2710:52thheller@orestis depends on what you want to do?#2018-12-2710:52orestisI want to diagnose and try and fix https://github.com/thheller/shadow-cljs/issues/422#2018-12-2710:52thhellerdon't need a local fork for that#2018-12-2710:53orestisI want to tweak the way that shadow injects the hud.#2018-12-2710:53thhelleryou can just put this file into your classpath https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#2018-12-2710:54orestisOh, that’s neat.#2018-12-2710:54thhellerthat should override whatever shadow-cljs ships#2018-12-2710:54thhellermight need this too https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/hud.cljs#2018-12-2710:55thhellerI can probably fix this if you provide a full stacktrace#2018-12-2710:55thhellerno idea how to get it in ie11 but I'm pretty sure there is a way to get it#2018-12-2710:55orestisUnfortunately IE11 on a VM isn’t exactly user friendly in that regard 🙂#2018-12-2710:55orestisBut let me see.#2018-12-2710:56thhelleryeah ie11 has horrible dev tools but I think the console still shows a trace#2018-12-2710:56orestis
shadow.dom.append.cljs$core$IFn$_invoke$arity$2 [Line: 867, Col: 1], shadow.dom.js
shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$2 [Line: 360, Col: 1], shadow.cljs.devtools.client.hud.js
shadow.cljs.devtools.client.hud.dom_insert.cljs$core$IFn$_invoke$arity$1 [Line: 342, Col: 1], shadow.cljs.devtools.client.hud.js
shadow$cljs$devtools$client$hud$connection_error [Line: 770, Col: 1], shadow.cljs.devtools.client.hud.js
Anonymous function [Line: 1038, Col: 1], shadow.cljs.devtools.client.browser.js
#2018-12-2710:57thhellerah perfect#2018-12-2710:57orestisThis is what I see in the “call stack” — unfortunately not source-mapped.#2018-12-2710:58thhellerso it fails to connect to the shadow-cljs server I guess#2018-12-2710:58thhellerconnection-error is trying to display a warning and that fails#2018-12-2710:58orestisI don’t think that’s it — my hunch is that body is not available yet when I load my code.#2018-12-2710:59thhellershadow$cljs$devtools$client$hud$connection_error is pretty clear in what it does 😉#2018-12-2710:59orestisAh, cool — yes, it wouldn’t be able to do the connection because it’s running in a VM.#2018-12-2710:59orestisBut still the hud is the one breaking, right?#2018-12-2711:00thhelleryou could run shadow-cljs compile your-build#2018-12-2711:01thhellerthat won't load the hud and stuff, so it can't error out on startup#2018-12-2711:01thhelleror you can set :devtools {:devtools-url ""}#2018-12-2711:01thhellerif the VM can connect to that server#2018-12-2711:02orestisI might need to proxy that shadow websocket anyway, because then things like browserstack can never work. I want to get my designers a way to see their changes live on many different browsers.#2018-12-2711:03thhellerok then you need to figure out why the websocket fails connecting#2018-12-2711:03orestisStill though, I think the fact that hud/dom-insert is using js/document.body is a little smelly 🙂 I’ll see if I can tweak that to make sure the error reporting works.#2018-12-2711:03thhellerits bad that it fails to show that error but thats not causing the error#2018-12-2711:04thhellerit can't show the error if there is no document.body 😉#2018-12-2711:09orestisYes, of course — this is caused because I load my CLJS in head (long story, unavoidable unfortunately). Many things break 🙂#2018-12-2711:09orestisIt’s funny how most of us now assume that JS is going to be loaded at the end of the body element.#2018-12-2711:10thhellerhead is not the issue here#2018-12-2711:11thhellerall of this happens async. I don't know why IE11 even attempts to connect while body is not present#2018-12-2711:11thhellerits supposed to finish loading first#2018-12-2711:11thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L397#2018-12-2711:15orestisI’m trying to override hud.cljs. I’ve placed it right in my source path, path is <source-path>/shadow/cljs/devtools/client/hud.cljs but my changes don’t seem to have any effect. Am I doing something wrong?#2018-12-2711:15thhellerprobably need to restart the server process if that is still running (ie. watch)#2018-12-2711:17orestisRegarding the timeout thing, I see here: https://github.com/thheller/shadow-cljs/blob/9752ddcf0502b559ccae66389f4e61e7d13bbd7c/src/main/shadow/cljs/devtools/client/browser.cljs#L371-L374#2018-12-2711:18orestisSo the moment this the websocket error happens, the hud tries to show the connection error and then blows up.#2018-12-2711:19orestisWhat would be the downside of replacing the setTimeout to a DOMContentLoaded event?#2018-12-2711:20thhellerdid ie11 have domcontentloaded? can't remember#2018-12-2711:20thhellerbut yeah that would be fine by me#2018-12-2711:21orestisOk, replacing files works, I’ll have a look about replacing that and report back.#2018-12-2711:22orestisPerhaps there’s a Google Closure way to do this safely.#2018-12-2711:23orestisIs there a minimum browser version for shadow?#2018-12-2711:25thhellerdunno. not sure I want to support ancient browsers. I hate ie11 enough for work I don't really want to deal with it elsewhere 😉#2018-12-2711:25orestisDOMContentLoaded goes back to IE9.#2018-12-2711:26thhellerok definitely not interested in supprting ie8 😉#2018-12-2711:26orestisWhat about sth like: (if js/document.body (current-behaviour) (try-later))#2018-12-2711:27orestisthis would be replacing the existing (js/setTimeout (ws-connect))#2018-12-2711:28orestisStill though, seems off to delay connecting the websocket until the document is ready.#2018-12-2711:28thhellerno it should always be async#2018-12-2711:28thhellerso other load events can fire first#2018-12-2711:59orestisOK, I’ve got this working — on to the next hurdle: getting a relative :devtools-url to work. It seems the code in env/ws-url expects a full url because it tries to replace http with ws.#2018-12-2711:59orestisI’d like to have my devtools-url be /shadow-cljs-server so that it goes to whatever the serving address is…#2018-12-2712:00thhellerit defaults to using the url you load the page from#2018-12-2712:00thhellersince that is usually what you want#2018-12-2712:00thhellerit must be a full url since its needed for ws and xhr requests#2018-12-2712:05orestisAh, what about if I want to keep the host the same but use another port?#2018-12-2712:07thhellerthat is the default?#2018-12-2712:08orestiswhoops, sorry, reuse the same port and host. So my webserver is responsible to proxy the traffic.#2018-12-2712:09orestisJust to clarify: I’m loading my page from . I want to instruct shadow to connect to . But I’m also loading my page from , so I want then the connection to be #2018-12-2712:11orestisI’ll make a PR for all this, BTW.#2018-12-2712:17orestisHm, replacing env.cljs doesn’t seem to take any effect. I wonder if all the google-closure defines at the top have anything to do with it.#2018-12-2712:18orestisI need to break for lunch but I’ll be back 🙂#2018-12-2712:30thhellerneed to restart the watch/server to replace the file I guess#2018-12-2712:35orestisYeah, I did that for the other cases but env.cljs is stubborn…#2018-12-2713:51orestisWhat a wild goose chase. Turns out the default behaviour of shadow is just right — it’s trying to connect to “whatever-host-you-have:9630” which should just work for all my use cases. But, IE11 inside that VM complains with: SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status Code: 200, OK#2018-12-2713:56thhellerit shouldn't answer with that though? should get an upgrade response? is a proxy or something active?#2018-12-2714:15orestisThis is definitely IE11 specific. Chrome inside that VM is working correctly with the default shadow settings.#2018-12-2714:16orestisI suspect something about security things but I’m not quite sure how to troubleshoot this.#2018-12-2714:18orestisTo clarify: shadow’s default that connects to ... works just fine when using chrome inside a VM and safari outside the VM, where original-host is different. It’s only IE11 that complains with that cryptic error.#2018-12-2714:19thhellerno idea what it might do differntly#2018-12-2714:37orestisI give up. IE11 on windows 10 manages to connect succesfully. Funnily enough, there, reloading only works with dev tools open. Otherwise I get a shadow hud saying: [reload failed] invalid calling object#2018-12-2714:38orestisIf I open the dev tools, then reload works as expected.#2018-12-2714:38orestisI’ll update my issue with all this info, and a PR for the websocket connection on document load.#2018-12-2714:38orestisThanks for the guidance!#2018-12-2714:39thheller@orestis I had one of those issues with IE before. forgot the details though. something to do with standards/quirks mode#2018-12-2714:40orestisHighly probable.#2018-12-2714:41orestisAll I want is my designers to be able to quickly preview CSS/markup changes on both IE11 and modern browsers. Having the devtools open is not a deal breaker for this, so I’ll stop exploring for now.#2018-12-2714:51orestisI’ve opened a PR for this. Thanks for all the help and for shadow itself 🙂#2018-12-2716:32orestisI wonder, is that barrage of document.writes something that shadow-cljs controls? Or does it come from some lower level?#2018-12-2716:33orestisI mean, the loading of the various clans-runtime stuff when in development mode. #2018-12-2716:33orestisIt makes working with browserstack (where the VM running the browser is far away) a tad painful. #2018-12-2717:26thheller@orestis you can set :devtools {:loader-mode :eval}. should make things faster.#2018-12-2717:26orestisThanks! #2018-12-2717:28orestisHave you considered having a patreon page or re-applying for Clojurists together? Your work is hugely important :)#2018-12-2717:29thhellerI have and I will. Just didn't have time this cycle#2018-12-2909:08heefooIs there any examples of libraries made using shadow-cljs ?#2018-12-2909:09thheller@heefoo you cannot currently publish libs with shadow-cljs. need another tool for that, I use lein. no need to compile anything, just need to publish the source files themselves#2018-12-2909:09thhellerso basically only need a project.clj with :dependencies and :source-paths. nothing else.#2018-12-2909:16heefoo@thheller thanks. Do you have any examples of apps ?#2018-12-2909:17heefoolibs...#2018-12-2909:18heefooI havent done any lib writitng but if i remember correctly there are other entries in project.clj i should have for a lib project#2018-12-2909:19thheller
(defproject my-lib "0.1.0"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[some/thing "1.2.3"]]
  :source-paths ["src/main"])
#2018-12-2909:19thhellerlein deploy clojars#2018-12-2909:19thhellerdone#2018-12-2909:20thhellerno need to depend on clojurescript or shadow-cljs in the lib itself#2018-12-2909:20thhellerjust continue using shadow-cljs.edn for everything else and just use project.clj for publishing#2018-12-2910:29heefoothanks @thheller#2018-12-2917:27ahungryhttps://github.com/ahungry/functional-riemann-client#2018-12-2917:27ahungryI'm working on an npm module written with shadow cljs#2018-12-2917:27ahungryThat way the lib is usable for Js or clojure easily#2018-12-2919:22hmaurerHi! I have a “library” for my Fulcro project in the main directory, i.e. src/main/my_project/core/lib.cljc. I would like to test it using devcards, so I created a file src/cards/my_project/core/lib.cljs (mirroring the main tree). I thought I would be apple to access methods define in my lib.cljc file but it looks like it’s not getting compiled as part of shadow-cljs watch cards. How can I remedy this? (I am posting my question here as well as on #fulcro as I think the answer is shadow-related)#2018-12-2919:37hmaurerI solved the problem by renaming my cards namespace to lib_cards, after which I could import the core/lib.cljc namespace and take it from there. I would rather have both share the same namespace though, so my question still stands 🙂#2018-12-2919:43thheller@hmaurer 2 files can't share the same namespace. that is only allowed if one is a macro namespace.#2018-12-2919:43hmaurer@thheller ah ok, thanks!#2018-12-2919:44hmaurer@thheller I had two files shared the same namespace, which didn’t work, so I renamed them. But now I’m getting “undefined function” errors everywhere. I assume this is a cache issue? (aka I should clear .shadow-cljs)?#2018-12-2919:45hmaureryep it was a cache error; clearing it fixed it#2018-12-2919:45hmaurer🙂#2018-12-2920:18koala punchhi, i’m having some trouble getting dirac to work with shadowcljs#2018-12-2920:18koala punchusing this as a guide: https://github.com/thheller/shadow-cljs/issues/167#2018-12-2920:19koala punchanyone have any luck with this?#2018-12-2920:22koala punch#2018-12-2921:02koala punchi think some sort of middleware being loaded by shadow is conflicting with the dirac one#2018-12-2921:02koala punchWe detected unexpected middleware setup in your nREPL server at <nrepl://localhost:8230>!#2019-12-3009:25darwinWe detected unexpected middleware setup... should not be an issue, it is just a friendly reminder, that you should double-check it you can suppress the check via {:skip-paranoid-middleware-setup-check true} passed as agent options#2019-01-0213:52orestisHas anyone managed to get devcards 0.2.6 working with shadow-cljs? The supplied example in https://github.com/shadow-cljs/examples/blob/master/deps-edn-re-frame-and-devcards/src/sniff/devcards.cljs doesn’t work for 0.2.6#2019-01-0213:56orestisSeems like devcards expects js/React to be present.#2019-01-0214:23thheller@orestis try including cljsjs.react before devcards#2019-01-0214:23thhellerthat sets up the global React#2019-01-0214:24orestisThanks, done that. It needs both React and ReactDOM. This got things working again, but I don’t see things updating visually (although I see the shadow HUD and the reloading of some files). I think I need to call something to re-render my reagent components, but I’m not sure what.#2019-01-0214:28orestis
(defn ^:export main
  []
  (js/console.log "starting devcards UI")
  (dc/start-devcard-ui!)
  (devcards.system/renderer @devcards.system/app-state))
#2019-01-0214:28orestishacky workaround#2019-01-0214:44thhelleryeah dunno what devcards needs. maybe relying on something figwheel specific.#2019-01-0215:38orestisIt does do some weird stuff in there (setting up some core.async channel etc and listening for figwheel events etc). But the above snippet works. I also filed an issue about it.#2019-01-0217:08heefooI am trying to experiment with the ivi library but i got a "DEBUG is not defined" when i require it#2019-01-0217:09heefoohttps://i.imgur.com/cPJ2yzH.png#2019-01-0217:09heefooivi is a virtual dom framework : https://github.com/localvoid/ivi#2019-01-0217:11heefooshadow-cljs minimal : https://i.imgur.com/tgFJNuh.png#2019-01-0217:14heefooand package.json : https://i.imgur.com/vzIfwkJ.png#2019-01-0217:14thheller@heefoo it seems to expect a non existant DEBUG global in the sources#2019-01-0217:14thheller
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Empty object.
 */
exports.EMPTY_OBJECT = DEBUG ? Object.freeze({}) : {};
//# sourceMappingURL=empty_object.js.map
#2019-01-0217:16thhellernode_modules\ivi-shared\dist\main\empty_object.js#2019-01-0217:16thhellerthat is not valid. not sure how thats supposed to work#2019-01-0217:17heefoohm#2019-01-0217:18thhellerah thought so. it expects you to configure webpack to replace that I guess.#2019-01-0217:18thhellerhttps://github.com/localvoid/ivi-examples/blob/efb9d9233d5f12e10054ba037a2fff4d2666daf0/packages/benchmarks/dbmon/webpack.prod.js#L23-L26#2019-01-0217:19heefooI see#2019-01-0217:19heefooI havent work with webpack for ages#2019-01-0217:20thhelleryeah not a great library if it expects you to do that#2019-01-0217:21thhelleras a quickfix you can set <script>window.DEBUG = false;</script> in your HTML before including the other JS#2019-01-0217:21heefooMakes sence#2019-01-0217:21heefoothanks#2019-01-0217:22heefooWould it work if i were to define it inside a cljs namespace ?#2019-01-0217:22heefoolike (goog.object/set js/window "DEBUG" false) ?#2019-01-0217:25thhellersure but you need to do it before including the ivi stuff#2019-01-0217:25heefoonow that i think it would have to be done before the ns declaration#2019-01-0217:25heefooyeah#2019-01-0217:25thheller(set! js/window.DEBUG false) should do it#2019-01-0217:26heefooindeed i think set! is intented for js vars#2019-01-0217:26heefoook Thanks thheller#2019-01-0217:26heefoo@thheller#2019-01-0308:11Daniel SchlaugHi everyone! I'm trying to use shadow-cljs to import an npm package that makes heavy use of jsx. It's my understanding that shadow-cljs does not directly support jsx and I understand that I could pre-compile any code in the local package but how I would go about pre-compiling the jsx in the external node module so that shadow-cljs would pick it up?#2019-01-0311:12thheller@daniel975 it is very uncommon that jsx is actually published to npm? typically the package is converted first. are you sure the package contains actual jsx?#2019-01-0311:16thhellerotherwise you'd need to run babel on the package to convert but I would not recommend doing so. webpack only packages likely have other issues.#2019-01-0320:01Daniel Schlaug@thheller I suspected that to be the case. The package is actually an internal module that we just pull down raw from git so it's a somewhat unusual package. I had an idea that I might make my cljs module have an index.js file that exports shadow cljs artifacts generated with compile npm. Not sure how that would impact my ability to add dependencies to the resulting hybrid module from other cljs modules though... I guess the other alternative would be to start converting our internal packages...#2019-01-0320:05thhellertypically all you need to do is run babel and let it convert the jsx files#2019-01-0320:05thhellerthere is an example here for the babel stuff https://github.com/shadow-cljs/examples/tree/master/babel#2019-01-0320:06thhellerproblem is that babel sometimes doesn't like running in node_modules. so I'd recommend converting and only publish "standard" JS to npm#2019-01-0320:14Daniel SchlaugIndeed, the latter sounds like simpler solution.#2019-01-0409:38metacriticalThere is some issue with “self-hosting”, I tried this example https://github.com/mhuebert/shadow-bootstrap-example Bootstrap build fails.#2019-01-0411:08thheller@metacritical fails how?#2019-01-0411:13thhellerah got it. will check it out soon#2019-01-0413:12metacritical@thheller Thanks, if you solve this issue i wont have to change my build to project.clj#2019-01-0417:32thheller@metacritical should be fixed in 2.7.10#2019-01-0417:33metacritical@thheller Is that gonna take a while? Because i am developing a Shadow-cljs + Electron App where i need clojurescript hosting in the front end.#2019-01-0417:34metacriticalCan you give a quick fix for now?#2019-01-0417:35thhellerit is fixed right now?#2019-01-0417:36metacriticalSo self hosting works in shadow-cljs ?#2019-01-0417:37lilactownCan you try the new version and confirm?#2019-01-0417:37metacriticalAaah#2019-01-0417:37metacriticalOK Thanks! will do now.#2019-01-0417:38thhellerthe example above should be working now yes.#2019-01-0417:38thhellershadow-cljs itself is not self-hosted though. it can only build builds that use self-hosted features 😉#2019-01-0417:43metacritical🙂 I understand shadow-cljs is not self hosted, my understanding is the way it compiles cljs is a bit different than say cljs build api or lein cljs-build. Lumo’s build Api doesnt even support self-hosting builds.#2019-01-0417:46thhelleryeah self-hosted builds require a few extra steps which shadow-cljs takes care of#2019-01-0417:57metacriticalOK so this is what i did#2019-01-0417:58metacritical#2019-01-0418:02metacriticalThe error in console : Download the React DevTools for a better development experience: https://fb.me/react-devtoolsYou might need to use a local HTTP server (instead of file://): https://fb.me/react-devtools-faq core.cljs:196 WARNING: Use of undeclared Var cljs.user/+ (anonymous) @ core.cljs:196 cljs$core$string_print @ core.cljs:9899 cljs$core$pr_with_opts @ core.cljs:10062 cljs.core.println.cljs$core$IFn$_invoke$arity$variadic @ core.cljs:10105 cljs$analyzer$default_warning_handler @ analyzer.cljc:510 cljs$analyzer$warning @ analyzer.cljc:712 cljs.analyzer.confirm_var_exist_warning @ analyzer.cljc:751 cljs.analyzer.confirm_var_exists.cljs$core$IFn$_invoke$arity$4 @ analyzer.cljc:816 cljs.analyzer.confirm_var_exists.cljs$core$IFn$_invoke$arity$3 @ analyzer.cljc:801 cljs.analyzer.resolve_var.cljs$core$IFn$_invoke$arity$3 @ analyzer.cljc:1184 cljs$analyzer$resolve_existing_var @ analyzer.cljc:1195 cljs$analyzer$analyze_symbol @ analyzer.cljc:3443 cljs$analyzer$analyze_form @ analyzer.cljc:3832 cljs$analyzer$analyze_STAR_ @ analyzer.cljc:3860 cljs.analyzer.analyze.cljs$core$IFn$_invoke$arity$4 @ analyzer.cljc:3880 cljs.analyzer.analyze.cljs$core$IFn$_invoke$arity$3 @ analyzer.cljc:3875 cljs.analyzer.analyze.cljs$core$IFn$_invoke$arity$2 @ analyzer.cljc:3871 cljs$analyzer$parse_invoke_STAR_ @ analyzer.cljc:3325 cljs$analyzer$parse_invoke @ analyzer.cljc:3380 cljs$analyzer$analyze_seq_STAR_ @ analyzer.cljc:3601 cljs$analyzer$analyze_seq_STAR__wrap @ analyzer.cljc:3605 cljs.analyzer.analyze_seq.cljs$core$IFn$_invoke$arity$4 @ analyzer.cljc:3629 cljs$analyzer$analyze_form @ analyzer.cljc:3833 cljs$analyzer$analyze_STAR_ @ analyzer.cljc:3860 cljs.analyzer.analyze.cljs$core$IFn$_invoke$arity$4 @ analyzer.cljc:3880 (anonymous) @ js.cljs:813 cljs$js$eval_STAR_ @ js.cljs:817 cljs.js.eval.cljs$core$IFn$_invoke$arity$4 @ js.cljs:894 app$renderer$core$eval_exp @ core.cljs:14 app$renderer$core$evaluate @ core.cljs:21 app$renderer$core$init_BANG_ @ core.cljs:29 (anonymous) @ core.cljs:31 VM269:1 Uncaught TypeError: Cannot read property ‘call’ of undefined at eval (eval at cljs$js$js_eval (js.cljs:124), <anonymous>1️⃣18) at cljs$js$js_eval (js.cljs:124) at Object.cljs$js$eval_STAR_ [as eval_STAR_] (js.cljs:842) at Function.cljs.js.eval.cljs$core$IFn$_invoke$arity$4 (js.cljs:894) at https://Object.app$renderer$core$eval_exp [as eval_exp] (core.cljs:14) at https://Object.app$renderer$core$evaluate [as evaluate] (core.cljs:21) at https://Object.app$rend#2019-01-0418:03thhelleryou need to call the bootstrap stuff#2019-01-0418:04thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-01-0418:04thheller
(defn start []
  (boot/init compile-state-ref
    {:path "/bootstrap"}
    compile-it))
#2019-01-0418:05metacriticalAha thanks a lot @thheller, i think this would work.#2019-01-0418:15metacriticalIt Works! Thanks a lot @thheller#2019-01-0520:36currentoorI’m trying to get CI tests working, followed the instructions in the manual but about 50% of the time my CI fails with this message
#!/bin/bash -eo pipefail
npx karma start --single-run
05 01 2019 20:23:40.760:WARN [watcher]: Pattern "/home/circleci/project/target/ci.js" does not match any file.
05 01 2019 20:23:40.766:INFO [karma-server]: Karma v3.1.4 server started at 
05 01 2019 20:23:40.766:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
05 01 2019 20:23:40.770:INFO [launcher]: Starting browser ChromeHeadless
05 01 2019 20:23:41.059:INFO [HeadlessChrome 71.0.3578 (Linux 0.0.0)]: Connected on socket -fOAgM3QhFtvOxByAAAA with id 55473730
HeadlessChrome 71.0.3578 (Linux 0.0.0) ERROR
  {
    "message": "ReferenceError: shadow is not defined\n    at eval (eval at <anonymous> (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n    at ContextKarma.start (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at ",
    "str": "ReferenceError: shadow is not defined\n    at eval (eval at <anonymous> (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)\n    at ContextKarma.start (/home/circleci/project/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at "
  }


Exited with code 1
#2019-01-0520:37currentooranyone ever deal with that?#2019-01-0520:37currentoorit runs fine locally#2019-01-0520:46currentooradding an ls before the karma command shows that the expected file target/ci.js is missing when the test fails#2019-01-0520:48currentooralso i noticed on a successful run shadow-cljs compile ci-tests prints [:ci-tests] Build completed. whereas on an unsuccessful build it doesn print that, however both return exit code 0#2019-01-0520:48currentooralso i noticed on a successful run shadow-cljs compile ci-tests prints [:ci-tests] Build completed. whereas on an unsuccessful build it doesn print that, however both return exit code 0#2019-01-0520:52currentoorAny idea why it would fail to finish compiling but not return an error?#2019-01-0521:21tony.kayI’m sort of guessing the package.json might have weird dependencies…some conflict that causes erratic resolution#2019-01-0521:21tony.kaynot sure why that causes a failure to emit a file though#2019-01-0521:21tony.kaybut deps are like that…when they get screwed up, weird things can happen#2019-01-0521:59thhellerunsuccessful builds should not exit with 0 but maybe the handling for that got messed up#2019-01-0521:59thhellerI'll try to confirm#2019-01-0522:00tony.kayI tried a difference ci image and it is working for now…goign to hit it a few more times and see if it fails. I confirm what @U09FEH8GN is seeing (we’re working on same project): it isn’t printing an error on build…just isn’t emitting code#2019-01-0522:00tony.kayWas using tools-deps image, now using openjdk8-tools-deps image (which is newer)#2019-01-0522:17tony.kay@U05224H0W just FYI. On the failing cases it was showing this: `#2019-01-0522:17tony.kay
shadow-cljs - config: /home/circleci/project/shadow-cljs.edn  cli version: 2.7.10  node: v10.15.0
shadow-cljs - starting via "clojure"
WARNING: requiring-resolve already refers to: #'clojure.core/requiring-resolve in namespace: datomic.common, being replaced by: #'datomic.common/requiring-resolve
NPM dependency "reakit" has installed version "0.15.13"
"^0.11.1" was required by jar:file:/home/circleci/.m2/repository/fulcrologic/fulcro-incubator/0.0.24/fulcro-incubator-0.0.24.jar!/deps.cljs
NPM dependency "react-icons" has installed version "3.2.2"
"^2.2.7" was required by jar:file:/home/circleci/.m2/repository/fulcrologic/fulcro-incubator/0.0.24/fulcro-incubator-0.0.24.jar!/deps.cljs
[:ci-tests] Compiling ...
added 104 packages from 62 contributors and audited 1976 packages in 2.047s
found 0 vulnerabilities
#2019-01-0522:17tony.kayAll BUT the compile completed#2019-01-0522:17tony.kayI’ve built it twice now on the new image without error#2019-01-0522:18tony.kaynow the output includes the additional line:
[:ci-tests] Build completed. (949 files, 814 compiled, 0 warnings, 23.88s)

#2019-01-0523:53tony.kayMore info. The container did not fix it after all 😞. So, I ran compiler with -v in CI and it looks like it is just stopping mid-compile…here are the last few lines:
<- Cache write: ucv/lib/form_encoding.cljc (7 ms)
-> Compile CLJS: ucv/lib/uism_extensions.cljc
-> Compile CLJS: ucv/ui/alert_test.cljs
-> Compile CLJS: ucv/ui/order_flow/shared.cljs
<- Cache write: ucv/util.cljc (11 ms)
<- Compile CLJS: ucv/ui/order_flow/shared.cljs (10 ms)
#2019-01-0600:29thhellerseems like it gets stuck compiling. do you run multiple builds concurrently? (I removed that since it was causing problems, depends on which version you are running though)#2019-01-0600:30thhellerah CI ... your process likely gets killed by OOM killer#2019-01-0600:31thhellertry to set :jvm-opts ["-Xmx2G"] or however much your CI machine allows#2019-01-0600:32thhellernot sure I can control the error code if OOM killer terminates it#2019-01-0619:42tony.kayweird that is is irratic, but yeah, I’ll try that#2019-01-0620:16currentoorwhere do those :jvm-opts go? inside the build options along with stuff like :target and :compiler-options?#2019-01-0620:16thhellertop-level in shadow-cljs.edn#2019-01-0620:16currentoorah thanks#2019-01-0620:17thhellernot sure if its actually the OOM killer but this was an issue with CI previously with very similar behaviour#2019-01-0620:17thhellerso "hoping" that its just that 😉#2019-01-0620:21currentoorseems plausible simple_smile#2019-01-0620:22currentoorit passed the first time#2019-01-0620:22currentoori’m going to run it a few more times#2019-01-0620:22thhellerare you on circleci by any chance?#2019-01-0620:22currentooryes#2019-01-0620:23thhellerah that makes it more likely I guess. It was killing when the proc reached 3gb IIRC#2019-01-0620:23currentoorand we’re on the free tier#2019-01-0620:23thhellerwhich it can reach on larger builds if not limited#2019-01-0620:24currentoorit’d be nice if the OOM killer was a little more transparent#2019-01-0620:24currentoorso the build succeeded the second time too!#2019-01-0620:26thhelleryeah I can't remember what it took to make that visible. it was logged somewhere obscure#2019-01-0620:26thhellermaybe syslog? can't remember#2019-01-0620:27currentoorworked the third time also#2019-01-0620:27currentoori think that was it#2019-01-0620:27currentoorthank you so much!#2019-01-0602:09hueypis there a way to kind of force shadow-cljs to not include a namespace? e.g. we get cljs.pprint in our bundle due to some bad DCE and would like to force it to be gone 😜 thinking maybe a hook could do this?#2019-01-0612:31thhellerthat is currently not possible with hooks. the closure compiler supports stripping by namespace so it could remove everything starting with cljs.pprint. the option for that however is not exposed since its kind of a footgun and easy to destroy your entire build using it#2019-01-0613:10thhellerso I just released 2.7.11 which exposes those options. I'll just document with a warning but basically you can now add :compiler-options {:strip-type-prefixes #{"cljs.pprint"}}#2019-01-0613:11thhellerthat will remove everything cljs.pprint related, which also includes every USE of cljs.pprint so beware 😉#2019-01-0613:11thhellerthis only applies to :release builds though#2019-01-0613:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_code_stripping#2019-01-0618:32hueypthis is amazing#2019-01-0618:33hueypthanks 🙂#2019-01-0607:05henrikI have a Node and browser build, with some shared code between the two. Remind me—is it recommended to split these into two separate projects, or can I stick them in the same one?#2019-01-0607:22lilactownstick em in the same!#2019-01-0607:32henrikFollow up question: when selecting a build with shadow.cljs.devtools.api/nrepl-select, how can I switch over to another build? Can I require shadow-cljs from within the build?#2019-01-0607:35lilactown:cljs/quit#2019-01-0607:35lilactownand then select another build#2019-01-0607:38henrikExcellent, thank you#2019-01-0607:41henrikIf only this could be done automatically depending on namespace.#2019-01-0611:37henrikOK, so I'm trying to do something really wonky to see if it works: running separate scripts in dev mode in the same browser tab at the same time. Doesn't work, even a little bit. Namespaces (cljs., goog., etc.), in assuming they're alone in the global scope, clash of course. Any ideas of how to make it work? Basically, I have two scripts, where either one, or both, might be in dev mode at the same time. One script calls stuff in the other one.#2019-01-0612:16orestisI think this is a limitation of ClojureScript in general. Can’t do it. #2019-01-0612:32thheller@henrik in general it is not advised to run 2 separate CLJS builds in the same app at all ever. dev or release. both will include their own version of cljs.core and won't be compatible with each other#2019-01-0612:42henrikAlright. So this essentially means that I couldn't have a CLJS-generated script sitting on a CDN somewhere, to be pulled into a site as a JS script, compiled and ready for consumption, if that site itself happens to use CLJS.#2019-01-0612:46thhellerwell that is ok. I was assuming you were running both builds#2019-01-0612:47henrikAh, OK! So the limitation is not "dev or release", only "dev"?#2019-01-0612:47thhelleryes, in that case 2 dev builds can't run in the same browser#2019-01-0612:48thheller2 release builds is fine#2019-01-0612:48thhelleror 1 release 1 dev#2019-01-0612:48henrikI admit, it probably doesn't happen much. A thing built in CLJS, targeted at a JS audience, but not available as CLJS library.#2019-01-0612:50thhellerhttps://github.com/uscensusbureau/citysdk does exactly that#2019-01-0614:13conanHi, just trying out shadowcljs for the first time. I'm making progress getting through all the compilation errors, but I keep getting this warning:
------ WARNING #1 --------------------------------------------------------------
 File: shadow/module/main/append.js:2

 variable shadow$umd$export is undeclared
--------------------------------------------------------------------------------
any clues as to what might be wrong would be super helpful, thanks
#2019-01-0614:17conanMore info: I'm compiling for node and running on AWS lambda. This is the execution error I get:
{
  "errorMessage": "Cannot find module 'bluebird'",
  "errorType": "Error",
  "stackTrace": [
    "require (internal/module.js:11:18)",
    "/var/task/main.js:494:240",
    "shadow$umd$export (/var/task/main.js:5:22)",
    "Object.<anonymous> (/var/task/main.js:9:3)",
    "Module._compile (module.js:652:30)",
    "Object.Module._extensions..js (module.js:663:10)",
    "Module.load (module.js:565:32)"
  ]
}
I can see the shadow$umd$export mentioned in there, so I suspect it's related
#2019-01-0614:42thheller"errorMessage": "Cannot find module 'bluebird'"#2019-01-0614:42thhellerthats the actual error I guess#2019-01-0614:42thhellertry npm install bluebird#2019-01-0614:43conanah thanks, i'm learning about npm as i go. i take it those deps aren't pulled in by leiningen?#2019-01-0614:43thhellerno npm stuff is not covered by leiningen#2019-01-0614:44conanok cool. can you recommend somewhere i can read about how to use the npm dependencies once i've done npm install bluebird (i've done yarn add bluebird, which i'm hoping does the same thing)?#2019-01-0614:45thhelleryes thats the same#2019-01-0614:45conanso in my case i'm trying to work out how to get these npm deps into AWS lambda, they don't seem to go into the target folder which is what i'm sending to AWS#2019-01-0614:46thhelleryeah I think you need to include the node_modules folder in your upload#2019-01-0614:46thhellerI don't know much about AWS
#2019-01-0614:47conanah ok, thanks#2019-01-0614:47conanyour help is much appreciated, and i'm writing a blog post about how to do this so hopefully it'll go a little further yet!#2019-01-0614:48thhellersomeone wrote an article not too long ago#2019-01-0614:48thhellerhttps://dev.to/royalaid/cljs-s-lambda-697#2019-01-0614:48thhellermaybe that helps?#2019-01-0614:50conanyeah that's what i've been following but it doesn't seem to cover npm deps#2019-01-0614:51thhellerah ok#2019-01-0614:51conanjust out of interest, when developing with shadow-cljs, how do you know which npm deps you need to install?#2019-01-0614:52thhellerwell typically they are installed automatically#2019-01-0614:52conanfor example, you add a clojurescript library, and when it runs it'll throw errors for all the missing npm libraries until you install them, right?#2019-01-0614:52thhellerbut you are most likely affected by the cljsjs compatibility stuff#2019-01-0614:52conanso i'm going through one by one, but it feels like i'm missing something simple#2019-01-0614:52thhellerthose can't install the deps automatically since the cljsjs deps don't declare their npm dependencies#2019-01-0614:53conanwhat's the workflow you would usually use for this?#2019-01-0614:53thhellerit is unfortunate that most cljs libs don't declare their npm dependencies properly#2019-01-0614:53thhellerthere typically is not workflow involved#2019-01-0614:53conanoh so it's a problem that can be resolved only in the libraries themselves#2019-01-0614:53conanok thanks!#2019-01-0614:54thhellerwhen using anything react related you probably just do yarn add react react-dom create-react-class#2019-01-0614:54thhellerbluebird is most likely coming from promesa#2019-01-0614:54conangood to know, i'm sure at some point i'll try out react yeah bluebird > promesa > kvlt#2019-01-0614:54thhellerso yeah its just libraries that don't declare npm deps properly since they typically just use cljsjs instead#2019-01-0614:54conani'm trying to make an http request but it seems super difficult#2019-01-0614:55conanoh, does cljsjs not work with shadowcljs?#2019-01-0614:55thhellerjust use (js/fetch "something")#2019-01-0614:55thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-01-0614:56conanwow ok, that'll take some learning, thanks!#2019-01-0614:57conanon that js/fetch, what is that? is there some js interop i can use to make http requests without having to use a cljs one?#2019-01-0614:57conani've always used cljs-http in the past#2019-01-0614:57thhellerah right you are on node#2019-01-0614:57conanbut that doesn't work in node#2019-01-0614:57thhellersorry js/fetch is for the browser#2019-01-0614:58thhellercljs-http should be working for node?#2019-01-0614:59conanno, it doesn't because there's no XmlHttpRequest in node, which cljs-http requires. i've also looked at kvlt, but that has the similar problem of needing other stuff, which is why i'm learning about npm#2019-01-0614:59thhellerotherwise the npm request lib is pretty popular I think#2019-01-0615:00conancool, maybe straight interop will be easier, although it seems to require npm as well which is the main problem#2019-01-0615:00conanthanks again#2019-01-0615:00thhellernode http package is built-in and should work just fine#2019-01-0615:04conanyeah it looks as though that's always available, but i'd have to write a bunch of code to handle chunked responses. i'm guessing that solving the npm problem will be easier, and it has obvious other benefits for the future#2019-01-0615:07conanincidentally i always get the variable shadow$umd$export is undeclared warning on compilation. is that something to worry about?#2019-01-0615:08thhelleruhm are you publishing shadow-cljs compile or shadow-cljs release?#2019-01-0615:09thhellershould only use shadow-cljs release when copying something to AWS#2019-01-0615:09thhellercompile/watch are only meant to run locally#2019-01-0615:11conani'm running yarn shadow-cljs release app#2019-01-0615:11conan
)$ yarn shadow-cljs release app; cd target; rm arch
ive.zip; zip -r archive.zip *; cd ..
yarn run v1.12.3
$ /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/node_modules/.bin/shadow-cljs release app
shadow-cljs - config: /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/shadow-cljs.edn  cli version: 2.7.9  node: v8.15.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app
[:app] Compiling ...
------ WARNING #1 --------------------------------------------------------------
 File: shadow/module/main/append.js:2

 variable shadow$umd$export is undeclared
--------------------------------------------------------------------------------

nil
[:app] Build completed. (130 files, 1 compiled, 0 warnings, 16.52s)
Done in 37.80s.
#2019-01-0615:12conanshadow-cljs.edn:
{:lein true
 :builds {:app {:target :node-library
                :exports {:handler server.main/handler}
                :output-dir "target"
                :output-to "target/main.js"}}}
#2019-01-0615:12thhelleroh. yeah ignore that. I'll fix that so it doesn't show up#2019-01-0615:12conancool, thanks#2019-01-0615:12thhellerthought you had some runtime error with that#2019-01-0615:12conanno, just a warning on compilation#2019-01-0615:37conanjust to wrap up, i went through all the npm errors one by one installing each dep and now it's working! in the end i used kvlt. thanks for your help!#2019-01-0622:33ribeloHow does the situation with react-native look like? Still possible? Deprecated?#2019-01-0622:43thheller@huxley has always been possible. just not as smooth as it could be since I don't do any react-native development myself and haven't worked on support for a while#2019-01-0622:43thheller:npm-module builds just work however#2019-01-0622:53ribeloCan I do something to make REPL work?#2019-01-0623:38thheller@huxley you need to require("shadow-cljs/shadow.cljs.devtools.client.react_native") from JS and set :runtime :react-native in your build config#2019-01-0623:38thhelleror require("./path-to-output-dir/shadow.cljs.devtools.client.react_native")#2019-01-0623:38thhellerdepends on which path you use#2019-01-0702:28heefoohas any one tried shadow-cljs with the latest react alpha ?#2019-01-0702:29heefooi get a " Hooks can only be called inside the body of a function component." that is not uncommon#2019-01-0702:33lilactownyes, I’m heavily using hooks with shadow-cljs#2019-01-0702:33lilactownare you using reagent @heefoo, by chance?#2019-01-0702:34heefooin general yes#2019-01-0702:34heefoobut i want to try it raw#2019-01-0702:35heefoofor once#2019-01-0702:35lilactownreagent components under the hood actually get created as classes, even though in CLJS we pass them around as functions#2019-01-0702:35lilactownHooks don’t work in class components, only function components#2019-01-0702:38heefoo@U4YGF4NGM https://i.imgur.com/zqbiFPu.png#2019-01-0702:38heefootried to test something like that#2019-01-0702:39lilactownyou’re calling your component as a function#2019-01-0702:39heefooi tried without#2019-01-0702:39lilactownyou need to pass your component as an element to render#2019-01-0702:39lilactown(.creatElement r example)#2019-01-0702:41lilactownif you want a library that gives you similar ergonomics as reagent (with hiccup syntax etc.) but uses just React and Hooks, you can try my library: https://github.com/Lokeh/hx#2019-01-0702:41heefooi've seen the library#2019-01-0702:41heefoois it yours ?#2019-01-0702:41lilactownyep#2019-01-0702:42heefoook it worked.#2019-01-0702:42heefooI feel total noob 😕#2019-01-0702:42heefooahahahaha#2019-01-0702:43lilactown😄#2019-01-0702:43lilactownthere’s a lot that reagent and JSX paint over for us. I got tripped up by the same thing#2019-01-0702:44heefooboth reagent and rum do their own scheduling#2019-01-0702:45lilactownthat’s correct. which means that when concurrent react becomes stable, they won’t yet be able to take advantage of all of it’s features#2019-01-0702:45heefooit seems like they should have their own virtual dom implemented instead of just using reacts#2019-01-0702:45heefooyes thats what i am thinking too#2019-01-0702:46heefoomoreover although i hadn't used them yet#2019-01-0702:46heefooreact hooks might be closer to reagent's style#2019-01-0702:46lilactownthere’s a lot of work just in React’s virtual dom diffing and component abstraction that they are reusing#2019-01-0702:47heefoosure but there are other lighter virtual dom sollutions#2019-01-0702:48lilactowntrue. you also get the whole React ecosystem of libraries, components, etc. 🙂#2019-01-0702:48lilactownthat’s the biggest value to me personally. which is why I started building hx#2019-01-0702:48heefoowell makes sense#2019-01-0702:49heefooi was thinking about that posibility too#2019-01-0702:49heefoobut didnt pas the createElement thing#2019-01-0702:49heefoo:X#2019-01-0702:51heefooI will be more tempting to try your library if there where any hook related exampples#2019-01-0702:51heefoojust letting you know#2019-01-0702:51lilactownthanks for the feedback. I have another project that I whipped up as a POC right when hooks came out: https://github.com/Lokeh/hooks-demo#2019-01-0702:52lilactownbut it’s not using the hx.react.hooks namespace#2019-01-0702:52heefoodamn#2019-01-0702:52heefooi should have cloned that 😛#2019-01-0702:52lilactown😄#2019-01-0702:53lilactownI’m kind of waiting for the official React support to land for hooks before doing an announcement to the community writ large#2019-01-0702:53heefoothanks i will just read your code#2019-01-0702:53lilactownsure thing#2019-01-0809:21heefoo@U4YGF4NGM i took a look on your code#2019-01-0809:22heefooalso in the hx library#2019-01-0809:22heefooI like the atomified type implementation#2019-01-0809:24heefooBut i wanted to ask you why do you use the same refernce to <-deref. It seems to me someone is going to lose refernce if they deref from different components and one unmounts.#2019-01-0702:36heefooi know, i have took a look on reagents code#2019-01-0702:37heefooi didnt do anything like that#2019-01-0716:39tbrookeI am looking at styling for a new shadow-cljs project - and from my research it looks like material-ui and semantic might have trouble because they have extensive cljs components that might conflict with shadow-cljs — I have also looked briefly and garden and some other similar libraries - I do not have complex styling needs — Any suggestions of what woul djust work for a Reframe Shadow-cljs app — mainly browser#2019-01-0716:48richiardiandreaWe use semantic UI but it is completely outside the shadow pipeline. We build using gulp and node-sass in a Makefile#2019-01-0716:54royalaidI am using Material-UI with Shadow to some success but inside a hobby project and it works super great. The project is moving towards a CSS-in-JS solution so you shouldn't have to worry about an additional style pipeline (https://material-ui.com/css-in-js/basics/). All that being said I haven't hit the edges of the library quite yet so you might want to kick the tires yourself first.#2019-01-0722:13royalaid@thheller Hey I am running into issue with using reagent's with-let#2019-01-0722:13royalaidIt appears to have also been encounter by @mhuebert before as well#2019-01-0722:13royalaidhttps://clojurians-log.clojureverse.org/shadow-cljs/2017-12-20#2019-01-0722:14royalaidSpecifically Cannot infer target type in expression (. c__36937__auto__ -ratomGeneration)#2019-01-0723:03thhellerwell either need to run off :infer-externs or live with the warning#2019-01-0723:03thhelleror fix it in reagent 😉#2019-01-0804:28Victor Gilhi guys, I built this toy sudoku app as an excuse for playing around with shadow-cljs, reagent, re-frame and re-frame-10x. code still needs a bit of cleanup but i've never been so excited about sudoku in my life :rolling_on_the_floor_laughing: demo is available here: https://baskeboler.github.io/cljs-sudoku (any comments are more than welcome)#2019-01-0820:06Whiskashow to i configure shadow-cljs server to proxy a http request to another server? ( i would like to send the requests made to /api/* into another server )#2019-01-0821:20thheller@mateus.pimentel.w https://shadow-cljs.github.io/docs/UsersGuide.html#_reverse_proxy_support#2019-01-0900:44Mark AddlemanI'm trying to use antizer library in clojurescript (https://priornix.github.io/antizer ) . When I run my build, I get The required namespace "cljsjs.antd" is not available, it was required by "brickmarket/ui.cljs". My deps.edn includes
cljsjs/antd               {:mvn/version "3.12.0-0"}
           antizer                   {:mvn/version "0.3.1"}
any guess what i'm doing wrong?
#2019-01-0900:45Mark Addlemani've tried running npm install cljsjs/antd but npm fails to install it.#2019-01-0905:23lilactownso you don’t need to include cljsjs/antd in your deps.edn#2019-01-0905:23lilactownyou will need to install antd via npm: npm install --save antd#2019-01-0905:25lilactownonce you’ve done that, you’ll need to create your own cljsjs.antd namespace that exposes antd. See https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-01-0917:50Mark AddlemanThanks!#2019-01-0906:35mavbozoi always get this message in chrome console shadow-cljs: reloading code but no :after-load hooks are configured! #2019-01-0906:37mavbozoalthough I have put :devtools {:before-load cljs.dev/stop :after-load cljs.dev/start} in my :builds profile#2019-01-0909:06thhellerdo not use namespaces starting with cljs.. they are reserved for CLJS itself. the hooks are not allowed in cljs.*#2019-01-0909:56mavbozothank you for the information#2019-01-0908:43romdoqI'm seeing intermittent issues when building a release, where it will fail with the error:
IllegalStateException: could not find where to put constant for module goog.labs.useragent.engine.js
        shadow.build.closure.ReplaceCLJSConstants.process (ReplaceCLJSConstants.java:60)
        ...
Any suggestions for what kind of thing should I be looking for to track down what might be triggering this?
#2019-01-0909:03romdoqit seems to have started occurring in a commit where I split some code out into its own file, with no other changes 😕#2019-01-0909:08thheller@mel.collins that is odd? do you have :depends-on configured correctly?#2019-01-0909:11romdoqwe're just using a single module at the moment, so we don't have any :depends-on configured#2019-01-0909:12thheller> I split some code out into its own file#2019-01-0909:12thhellerwhat does that mean then?#2019-01-0909:12thhellerjust an extra ns?#2019-01-0909:13romdoqyeah, I had an oversized myapp.views.main, and split out a bunch of the views into their own namespace#2019-01-0909:14thhellerthat is odd. what is your build config then?#2019-01-0909:15thhellerIllegalStateException: could not find where to put constant for module this should only happen when :modules are setup incorrectly. can't explain how it would happen otherwise.#2019-01-0909:15thhellerdo you have the correct closure-compiler version? yes if using shadow-cljs.end, maybe not if using deps/lein#2019-01-0909:15romdoqhmm, if I remove the .shadow-cljs cache dir the build works once, but then fails on subsequent attempts#2019-01-0909:17romdoqwe're not using deps or lein at this point#2019-01-0909:17thhellerthat is even weirder. do you do any kind of macro trickery?#2019-01-0909:17thheller(side-effecting macros)#2019-01-0909:17romdoq
:modules {:main {:entries [myapp.core]}}
#2019-01-0909:18romdoqI don't think there's any macro trickery#2019-01-0909:18romdoqnot that we've written anyway. I'm not sure about deps, but the deps didn't change when it started to break#2019-01-0909:19thhellerso when it starts breaking#2019-01-0909:20thhellerhmm I have no idea how it would even be confused about goog.labs.useragent.engine.js#2019-01-0909:20thhellerthere are no CLJS constants in that file#2019-01-0909:24thhellerso the only time I ever saw this error was with badly defined :modules.#2019-01-0909:24thhelleryou are using :target :browser I assume?#2019-01-0909:25thhellerit doesn't make sense that is only work once as the input to the compiler will be identical to the first one when caching is used#2019-01-0909:25romdoqThis is :target :npm-module and :runtime :browser#2019-01-0909:25thhellerah!#2019-01-0909:26thhelleroh. I guess I need to filter :modules. it is not allowed for :npm-module builds#2019-01-0909:26thhellerjust use :entries.#2019-01-0909:26thheller:build {:stuff {:target :npm-module :entries [myapp.core]}}#2019-01-0909:28romdoqoh interesting, I did not realise#2019-01-0909:29thheller:npm-module desugars to a pretty complex :modules configuration#2019-01-0909:29thhelleryou just basically added one module it didn't expect so it falls over#2019-01-0909:32romdoqhah, well it took its time falling over, since the config has been like that for months! Something about a camel's back 😄#2019-01-0909:32thhelleryeah still no idea why it would compile once at all#2019-01-0909:42romdoqYeah, that's fixed that IllegalStateException, thanks.#2019-01-0909:43romdoqbut we've another branch with the same happening for goog.dom.dom.js, even after with the :entries fix#2019-01-0909:44romdoqthat branch switched to using deps.edn though, which you mentioned something about?#2019-01-0909:51thhellerit is unlikely that this is related to bad dependencies#2019-01-0909:52thhellerjust make sure to remove :modules from all :npm-module builds#2019-01-0909:52thhellerI'll validate and ensure that in the future#2019-01-0909:54romdoqyeah, I just checked out a commit prior to the deps.edn change, and it's still complaining about goog.dom.dom.js. But this is after :modules has been removed!#2019-01-0909:55thhellersame error?#2019-01-0909:57romdoqthe heck? This branch is complaining about goog.labs.useragent.engine.js again. Same IllegalStateException, yeah.#2019-01-0909:57romdoqcould ^:private be a problem?#2019-01-0909:58thhellerThis branch. are you sure this branch has the updated build config? if you have a server instance running it may still be using an older version too?#2019-01-0909:58thhellerno#2019-01-0909:59romdoqyeah, I rebased on the updated config, and triple-checked that it was the right shadow-cljs.edn. No server instance running either.#2019-01-0910:04romdoqhuh, the first time I build I get IllegalStateException: could not find where to put constant for module goog.dom.dom.js, but subsequent times I get the same error but for goog.labs.useragent.engine.js again.#2019-01-0910:08thhellerI'm not sure what is happening. I've never seen that error in :npm-module builds before.#2019-01-0910:09thhellerif you can please send me the contents of the .shadow-cljs/builds/<your-build>/release directory. its all the cache files and generated JS. maybe I can find something?#2019-01-0910:10thhellerand the full build config? maybe there is some other option messing with things#2019-01-0910:11romdoqI'm still investigating right now, but I'll zip and send you some stuff after lunch if I don't find anything#2019-01-0910:24thhellermake sure you are on the correct directory on the correct machine. wouldn't be the first time that someone was debugging something locally but actually executing something via an ssh connection on a totally different machine 😉#2019-01-0910:32romdoqhah yeah, that's always a good one. Sadly not the case in this instance!#2019-01-0912:01romdoqokay, so this was unexpected. It seems the mere presence of an :options keyword in any view function is the trigger, even if the function isn't used.#2019-01-0912:02thhellerexample?#2019-01-0912:03romdoqI can use :options in re-frame subs or cljss/defstyles wihtout issue#2019-01-0912:03thhellerthe keyword is unlikely to be the issue#2019-01-0912:03thhelleror rather it is more likely that its the issue WHEN it is used or how#2019-01-0912:03thhellernot the keyword itself#2019-01-0912:04romdoqlol, now that I've said that I can't get it to break again#2019-01-0912:05thhellercljss does some fairly bad macro stuff. so maybe thats it#2019-01-0912:08romdoqright now
(defn secondary-config-mappings
  []
  {:options nil})
triggers the error, but
defn secondary-config-mappings
  []
  {:optionss nil})
does not. The function is not used anywhere in the code.
#2019-01-0912:09thhellerhmm I have an idea#2019-01-0912:09thhellerhmm no. not really#2019-01-0912:13romdoqhuh. If I put (def blah :options) in another file, the error doesn't trigger#2019-01-0912:13romdoqbut if it's in the same file as the above defn, the error still triggers#2019-01-0912:17romdoq@thheller do you still want a copy of the failing build files?#2019-01-0912:38romdoqapparently it's not just keywords, but any variable called options triggers it too 😕#2019-01-0912:40romdoqon second thought, that might be also related to keywords, since the only occurrences in this code was from deconstructing maps#2019-01-0912:42romdoqyeah, a basic function with an options argument didn't trigger the error#2019-01-0913:05thheller@mel.collins yeah the files would help. I cannot reproduce this in any way. build config would also help just in case there is something misconfigured#2019-01-0915:38ShaneLesterDoes shadow not detect changes to macros for live-reload / compile purposes? Or do we have something configured incorrectly? Just saw a case where we made a change to a macro, saved, nothing kicked off by shadow, changed a line outside of macro and saved, and it behaved normally.#2019-01-0915:40thhellerit should support live-reload for macros yes#2019-01-0915:40ShaneLesterHmmm okay. That at least gives us the “Okay something is wrong there” flag. haha. Thanks#2019-01-0915:42thhellertotally possible that its not entirely accurate since macros are a bit tricky#2019-01-0915:43ShaneLesterRight… I need to read about them a bit more to understand, I think.#2019-01-0916:09ShaneLesterWould it change anything that it’s a macro from a library? a Spec macro in this case.#2019-01-0916:10ShaneLesterAnd we only changed how we called it, not the macro itself, I was mistaken before#2019-01-0917:16cjsauerWhat is the recommended strategy for developing locally on both client (browser) and server code with shadow? Does it make sense to have two completely separate clj projects? Should I spin up my server project's REPL, start the system, etc....and then configure my client project's :proxy-url to point at the local server? Or maybe it's more appropriate to configure the client's :http-handler to reference the server's main handler fn? This would suggest that the client/server projects are one monolith, or that the client project depends on the server project somehow. Just trying to get a feel for what others have been doing...#2019-01-0917:18wilkerlucioI would separated a few source folders, start with shared, server, client, so most of the code goes in shared, and in the others only specific code that calls to specific host features (like node FS or browser fetch, etc...)#2019-01-0917:18wilkerluciothen in a single project, have one build for each case (client/server)#2019-01-0917:28cjsauerThat makes sense, and should be pretty straightforward with tools.deps and :local/root. What about "integration" between client/server though? I think what I'm confused about is how do I replace the shadow development server with my own server? Is the :http-handler setting the preferred approach?#2019-01-0919:01wilkerluciothose don't collide with each other, the shadow http is for pure cljs cases, what you gonna do is implement you own on the Node side (using express or whatever), then you run your server separated, maybe there is a way to hook on the shadow one, but I believe that would give you more headaches to deploy#2019-01-0918:59thheller@cjsauer I just put all the code in one repo and have multiple builds. easiest to share code that way#2019-01-0919:29cjsauer@thheller @wilkerlucio thank you, I think I've got it working now 👍#2019-01-1008:54orestisI’m observing something weird when using specs to validate a reagent atom — should I be careful when importing namespaces only for side effects (that is, to register specs etc)?#2019-01-1008:56orestisMy app.main (entry point) requires my app.state (and uses a bunch of functions) which in turn requires my app.spec — and uses nothing from there. However I get an error like so
main.js:3045 failed to load app.state.js Error: Unable to resolve spec: :base/count
    at Object.cljs$spec$alpha$the_spec [as the_spec] (alpha.cljs:121)
    at Function.eval [as cljs$core$IFn$_invoke$arity$5] (alpha.cljs:518)
    at Function.eval [as cljs$core$IFn$_invoke$arity$4] (alpha.cljs:513)
    at Object.cljs$spec$alpha$def_impl [as def_impl] (alpha.cljs:314)
    at eval (state.cljs:120)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:2188)
    at Object.env.evalLoad (main.js:3043)
    at main.js:3261
#2019-01-1008:57orestisWhere :base/count is defined in app.spec like so (s/def :base/count (complement neg-int?)) — and if I put that declaration in my app.state ns, the problem goes away.#2019-01-1008:58orestisIt’s my first time using spec from CLJS, so perhaps shadow CLJS might not be the culprit. I’m using :loader-mode :eval if it makes any difference.#2019-01-1009:01orestisOK, got it — I had two shadow-cljs builds running — one for running the tests in node, one for the browser. Stopping them both and running only the browser one seems to fix things, :loader-mode :eval still works.#2019-01-1009:16orestisOuch, adding cljs.spec to the project hits me with a 60kb of optimized javascript. I guess DCE isn’t working in this case?#2019-01-1012:02thheller@orestis yes spec is never DCE'd#2019-01-1012:06orestisBummer.#2019-01-1012:07thhellerI opened https://dev.clojure.org/jira/browse/CLJS-1701 a while ago but nobody seems to care 😛#2019-01-1012:33orestisVoted 🙂 — is there a workaround?#2019-01-1012:36thhellernope. note that the 60kb is pre-gzip. gzip'd its not so bad.#2019-01-1012:39orestisYeah, but still, 20kb of gzip was like a 15% increase of my build. I’m not dying, but would be good to fix.#2019-01-1012:39thhellercan't really fix it. can maybe reduce it a bit but also not by much.#2019-01-1012:40thhelleronly fix is not importing spec in the first place#2019-01-1012:40orestisYeah, I guess I can do that — but eventually I’d like to actually validate some things at runtime.#2019-01-1012:41thhellerthen there is no way around it anyways#2019-01-1012:41orestisCould be that the reason it’s not fixed yet is that people actually use it at runtime and gladly pay the price. I was a little bit surprised to see the gen.test stuff in there.#2019-01-1012:42thhellerit really cannot be fixed in the way it is written right now. so you basically need to rewrite the entire thing#2019-01-1012:43thhellerbut that still doesn't guarantee that code can actually be removed#2019-01-1014:45orestis@thheller I have to thank you (again) for coming up (and maintaining) shadow-cljs. It’s a fantastic tool. Please apply for Clojurists Together again.#2019-01-1015:24denik@thheller looking into now builders, wondering if shadow-cljs supports all requirements to make one? https://zeit.co/docs/v2/deployments/builders/developer-guide/#2019-01-1015:26denikhere are builders for other langs: https://github.com/zeit/now-builders#2019-01-1016:09thhellernot sure if Java is available to builders? need the JVM to compile. besides that is should be easy to create a builder#2019-01-1016:09denikI think it can be installed, see python and go#2019-01-1016:13thhellernot sure I understand what any of this does though 😛#2019-01-1016:14deniksame here, I’m puzzled. zeit now just has such an amazing dev experience, I’d love to use it with CLJS!#2019-01-1016:15thhellerno I mean why must this be built by them? why not upload the compiled js?#2019-01-1016:15thhellergoing to take forever if if has to download java/clojure/maven deps etc#2019-01-1016:26deniknot sure. they pride themselves with extremely fast builds / deploys https://twitter.com/rauchg/status/1060587045515493376#2019-01-1016:27denikmight also be that analyzer deps are cached#2019-01-1016:30thhelleralready hate that everything is expressed by filenames. gotta hate languages without proper namespacing#2019-01-1016:33denikcan’t have everything. the motive seems to be to cover as many langs as possible. the lowest common denominator of any popular lang is the file, so it makes sense. imho, it’s quite impressive, this is powered by 4 langs https://monorepo-v2.now.sh/#2019-01-1016:33deniksrc: https://github.com/zeit/now-examples/tree/master/monorepo#2019-01-1016:38thhellerso as far as I understand it each file is "deployed" indepedently#2019-01-1016:39thhellerso say you have 5 cljs namespaces#2019-01-1016:39thhellerthat will trigger 5 different cljs builds#2019-01-1016:39thhellerwhich is complete waste of resources#2019-01-1016:41denikit doesn’t look like it works that way#2019-01-1016:42denikhere’s the next builder taking a seq of files: https://github.com/zeit/now-builders/blob/master/packages/now-next/index.js#L79#2019-01-1016:42denikand the config determining how many builds a project has: https://github.com/zeit/now-examples/blob/master/nextjs-news/now.json#L6#2019-01-1016:43thheller> A builder can retain an archive of up to 100mb of the filesystem at build time.#2019-01-1016:44thhellerthats not enough to store a JVM download?#2019-01-1016:44denik¯\(ツ)/¯ how large are the deps for go / pythong / php?#2019-01-1016:45denikthese are supported and fast from a few demo’s I’ve seen#2019-01-1016:46thhellerguess those don't count towards the cache archive?#2019-01-1016:46thhellerno idea what is happening with any of this 😛#2019-01-1016:49denikequally clueless here. however, I think getting clojurescript into now would be great. it’s similar to the deployment part of datomic cloud, just for cljs and other langs. Since now is very popular among hobbyists the exposure of cljs in their builders could also attract / lower the bar for beginners#2019-01-1016:50deniknow dev seems to offer a local build process (I think with file watcher?) as well#2019-01-1016:52thhellerwell it is already trivial to run the code. building it is just tricky#2019-01-1016:53thhellernot sure what exactly it is building in the first place with just plan .js files for example#2019-01-1016:57denikthere might be a way to hack by compiling first and then building with the node and/or static builder#2019-01-1016:58thhelleryeah that is trivial#2019-01-1017:08thhelleralright this makes more sense now#2019-01-1017:11thhellerI guess it just needs one file to trigger everything but that file can be shadow-cljs.edn#2019-01-1017:11thhellersame as
{
  "version": 2,
  "builds": [
    { "src": "docs/package.json", "use": "@now/static-build" },
    { "src": "blog/package.json", "use": "@now/static-build" }
  ]
}
#2019-01-1017:12thhelleralright I'm intrigued 😉#2019-01-1017:16denik😎#2019-01-1114:34deniksince shadow-cljs is an npm module, this should be very straightforward, right?#2019-01-1114:41thhelleryes and no#2019-01-1114:42thhellerthe npm package is only a very thin layer to access the JVM stuff#2019-01-1114:43denikdoes the npm package handle installing the java, clojure if it’s not there or does it expect it on the classpath#2019-01-1114:43thhellerit expects java to be installed yes#2019-01-1114:43deniki see#2019-01-1217:05thheller@U050CJFRU I just did my first test now deployment. As expected it is trivial if you compile the code locally and just deploy the generated .js#2019-01-1217:06thhellercreating a custom builder would then just involve something that downloads the JVM and stuff. not sure thats worth the effort since debugging stuff is pretty annoying#2019-01-1217:06thhellerhttps://demo-now-7n7jyrfcg.now.sh/#2019-01-1217:06thheller
(ns demo.now)

(defn handler [^js req ^js res]
  (.end res "Hello World"))
#2019-01-1217:07thheller
:now-lambda
  {:target :node-library
   :exports-var demo.now/handler
   :output-to "out/demo-now/index.js"}
#2019-01-1217:07thhellershadow-cljs release now-lambda cd out/demo-now now#2019-01-1217:09thhellerhttps://github.com/thheller/shadow-cljs/commit/0b7b22855be0f2272e3b8e90fdf4e2f4e2a637f7#2019-01-1217:10thhellershould probably extract that into a proper example. just wanted to get something running quickly and this does the trick#2019-01-1217:10thhellerto be honest the now builders currently just look like a super terrible CI implementation#2019-01-1401:45denikthanks @thheller. Yes builders do look messy. Still when they work they work! Just want to write and deploy cljs quickly (and cheaply which lamdas are) #2019-01-1410:15thhellerright now "quickly" probably means compiling locally and deploying the compiled .js files directly. downloading java, maven deps, npm install on each build is probably way too slow when using a custom builder#2019-01-1410:15thhellercache is also max 100mb which is nowhere near enough.#2019-01-1410:15thhellerthe go builder also apparatently downloads go on each build and doesn't cache it#2019-01-1412:04jntnI have set up a free travis build that builds and deploys a shadow-cljs project to now.#2019-01-1412:04jntnhttps://github.com/jntn/haiku/blob/master/.travis.yml#2019-01-1412:04jntnWorks like a charm 🙂#2019-01-1020:07Whiskashow can i ensure i’m not running two versions of react at the same time?
#2019-01-1020:08Whiskasi am already using :exclusions [cljsjs/reac cljsjs/react-dom]#2019-01-1020:08Whiskasand importing react from npm#2019-01-1020:09lilactownin shadow-cljs, React won’t be loaded from cljsjs whether you exclude it or not#2019-01-1020:09lilactownwhat’s your package.json look like?#2019-01-1020:10lilactownand are you loading any other bundles on the webpage you’re running your CLJS code?#2019-01-1020:18leocardosoHas anyone used shadow-cljs with single-spa?#2019-01-1020:57thheller@mateus.pimentel.w shadow-cljs ensures that cljsjs is not used. so no need to worry about including it.#2019-01-1020:57thheller@leocardosoti many people do yes#2019-01-1021:20thosmosI'm coding two very different but related builds with different package.json files: one a :node-library running Google Cloud Functions, and one a browser app that communicates with those functions via Firebase. I'd also like to share some common code between them. Is there a way to specify different package.json files per build in one shadow-cljs and build these both from one shadow-cljs server run, or is it best to run two separate shadow-cljs instances?#2019-01-1021:21thosmosAlso, is there a way to run a watch on a node-library and prevent the repl and websockets stuff loading? It's causing errors in the local firebase cloud functions emulator. I'm only able to get release builds to work with it, and it'd be nice to just have the release build get triggered when the code changes, but otherwise have it be exactly the same code as a release build.#2019-01-1021:22thheller@thosmos what I recommend doing is keeping a dedicated directory for your node builds/packages#2019-01-1021:22thhellersomething like https://github.com/thheller/shadow-cljs/tree/master/packages#2019-01-1021:22thhellerso each npm package gets its own directory with its own package.json#2019-01-1021:23thhellerand the CLJS isn't kept in that directory at all. the compiler output just goes there#2019-01-1021:23leocardoso@thheller https://single-spa.js.org/#2019-01-1021:23thhellereg. https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L27-L36#2019-01-1021:24thheller@leocardosoti oh. didn't realise that is a framework. no not aware of anyone using that#2019-01-1021:24leocardosoi mean the single spa framework#2019-01-1021:24leocardosoahhh#2019-01-1021:24leocardosook#2019-01-1021:25thheller@thosmos what kind of issue do you get with the functions emulator? you can just disable the websockets stuff with :devtools {:enabled false} (like in the above config)#2019-01-1021:26thosmosah yes I just saw that in your example, but I missed it in the manual#2019-01-1021:27thosmosThe emulator error is
error: SHADOW import error /Users/thomas/Develop/take2/experiments/threshold-functions/functions/.shadow-cljs/builds/gcf/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
...
Error: Cannot find module 'ws'
#2019-01-1021:28thhellernpm install ws?#2019-01-1021:29thosmosah, now it's working with :devtools {:enabled false}#2019-01-1021:30thosmosI'm still getting an error firebase > error: no "source-map-support" (run "npm install source-map-support --save-dev" to get it) but I think I remember a shadow config to disable source-maps#2019-01-1021:32thosmosok, :compilar-options {:source-map false} fixed that, so now it's working great! Wow, I'm so impressed with shadow-cljs Thank you!#2019-01-1021:32thhelleryou may have more luck with :npm-module instead of :node-library if the emulator is so picky#2019-01-1102:15hueyphttps://github.com/thheller/shadow-cljs/commit/fe33a76fbd7454f4ede149bb123b7a6cf8741a2c#diff-5823118fcf420ad359fbb92728de1339R96 — would this line be a reasonable place to filter warnings via namespace? 🙂#2019-01-1102:23hueypor basically — how to not get warnings on every reload for library code#2019-01-1102:23hueypthat I can’t change~#2019-01-1110:52thheller@U0KHZ4HNG it is only supposed to warn once for library code?#2019-01-1110:53thhellerthe :from-jar is supposed to filter everything where the source file is in a jar, ie. library#2019-01-1111:24thhellerwhich library is causing warnings?#2019-01-1123:06hueyphmm, good point … our build system is a bit bespoke (we use BUCK) so at times our jars aren’t jars … but in this case I think they are in fact jars. its stuff like om.next warning about *logger*, etc. we also execute everything from the devtools api, not the command line, if that matters, e.g. (server/start!), (shadow/watch :foo)#2019-01-1123:06hueypI’m very much on board with the warnings in our namespaces — they’ve found actual bad stuff so far 😜#2019-01-1123:07hueypI’ll try and dig in and see the root cause of why :from-jar isn’t hitting our case#2019-01-1102:44tony.kayI just built a custom target type for nubank workspaces for shadow to auto-scan…was pretty easy. Thanks @thheller for making hooks to make that possible!#2019-01-1114:38mitchelkuijpersDamn that is way simpler than I would have expected#2019-01-1119:18tony.kayYeah, right?#2019-01-1110:55thheller@tony.kay what kind of auto-scan? I have some built-in workspaces support but didn't quite figure out how to configure things like preloads and other dev stuff. would be interested to see what you built#2019-01-1112:19wilkerlucio@thheller https://github.com/nubank/workspaces/pull/23#2019-01-1112:38thheller@wilkerlucio @tony.kay nice.#2019-01-1115:06thosmosIs there a way to get Cursive to resolve npm requires? I'm having an issue where doing something like (ns my.ns (:require ["firebase/auth" :as fb-auth])) is showing up marked as unresolved. If not, is there a way to trick it?#2019-01-1115:11thheller@thosmos unfortunately not. I don't think string requires are undestood at all at this point. let alone npm resolve.#2019-01-1115:13thosmosIs there a way I could pre-package it somehow so that I could do (:require [firebase]) and have cursive resolve it. Maybe with externs? I guess this is what cljsjs does?#2019-01-1115:14thhellercljsjs doesn't really set any namespace aliases so there isn't much to resolve#2019-01-1115:14thhelleryou only (:require [cljsjs.react]) without alias and use the global js/React#2019-01-1115:14thosmosoh right#2019-01-1115:14thhellerthe problem only appears when you try to alias it#2019-01-1115:17thosmosSo if I wanted it to resolve all the fns I'd need to create stubs for each namespace including each fn signature? Would that theoretically work? I imagine that an externs file could be used to auto-generate this.#2019-01-1115:18thhellerno idea how you'd solve this. I just turned the warning off in Cursive#2019-01-1115:19thhellerdon't know enough about how cursive deals with any of this#2019-01-1115:19thosmosok thanks. I still much appreciate being able to code directly against the required symbol rather than js/whatever#2019-01-1115:19thhellershould probably open an issue and ask#2019-01-1115:19thosmosI know that it sometimes asks to generate stubs for some deps, but I have no idea what that means#2019-01-1115:19thhelleryeah me neither#2019-01-1115:21wilkerlucio@thheller @tony.kay just tried using the new target, I have an issue because my old main had some requires that were used by all the other things, but none of then require it (specs file and workspace extension things), is there a way to indicate that those should be loaded before anything else? I tried just adding a new file that requires those, but the topological order is getting wrong and the code is trying to use the specs before they are loaded#2019-01-1115:21wilkerlucioI know I could just require it everywhere, but the point is trying to avoid it#2019-01-1115:23thhellercould probably change the target to allow you to specify these in config#2019-01-1115:23thhellersimilar to :devtools {:preloads [some.ns]}#2019-01-1115:25wilkerluciocan I just add those to :entries?#2019-01-1115:26thhelleryou can but the target doesn't use that so you need to adjust the target code to use it#2019-01-1115:27thheller
(assoc-in [::modules/config :main :entries]
  (-> '[]
      (into (get config :entries []))
      (into dynamically-resolved-namespaces)
      (conj 'nubank.workspaces.shadow-cljs.mount))))
#2019-01-1115:46thosmosAre you aware of any IDE that provides editor introspection based on js externs, even if it's only available in javascript? This might be easy to leverage for CLJS.#2019-01-1115:54thhellerI don't know anything that provides accurate introspection based on npm packages#2019-01-1115:55thhellerfor JS source maybe but not the garbled prebuilt mess thats sometimes on npm#2019-01-1116:09wilkerlucio@thheller that worked great 🙂#2019-01-1116:58wilkerluciosometimes in my CI the tests are failing with ../deploy/bin/shadow-karma-test: line 9: echo: write error: Resource temporarily unavailable, had anybody here had this problem? ideas what could be about?#2019-01-1116:59wilkerlucioit only fails sometimes, I would say about 30% of the runs#2019-01-1117:09thhellerhmm no idea#2019-01-1117:15wilkerlucioI wonder if some IO resource is taking too long to respond and causing it#2019-01-1117:20thhellerwhat is it doing in that script?#2019-01-1117:20thhellerdoesn't look like any java error#2019-01-1122:39clj-daveHi there! Is there anyway to pass data to shadow-cljs through the command line that can be accessed in the shadow-cljs edn file?#2019-01-1122:39clj-daveI'd like to read environment variables and pass them to my build via goog defines#2019-01-1211:01thheller@davidcerezoinigo I generally recommend staying away from environment variables for builds since they are typically abused for something that should be runtime configuration to instead be used for build configuration#2019-01-1211:02thhellerbut you can use the reader macro #shadow/env "THE_KEY" in the config#2019-01-1211:02thheller:closure-defines {some.thing/foo #shadow/env "FOO"}#2019-01-1212:49Jonrun into several issues when I was introducing shadow-cljs to my friend today. not confirmed. 1. when :target :node-script is used with :modules {:main {:init-fn a.b/c}}, I saw no warnings on running shadow-cljs.edn. 2. ":after-load x.y/reload" is written in the configs while the real namespace is a.b/reload, 3. I added ["fs" :as fs] and save file, is how replaces and import fs. however it throws an error. restarting the process then it will be ok.#2019-01-1212:52thheller@jiyinyiyong I don't understand what you mean with 3.? what error does it throw?#2019-01-1212:53Jondidn't note down that error.#2019-01-1212:54Jonsomething looked like couldn't find that namespace#2019-01-1212:54thhellerI'm gonna need a full error report and preferably reducible example. I'm not going to try and guess what you were seeing#2019-01-1212:55thheller1/2 are known. Configs need more validation.#2019-01-1212:55Jonokay. I would copy the error messages next time I see it.#2019-01-1219:14Chasehello! I'm trying to do the free reagent course but using emacs/cider instead of atom. can someone please take a look at the project's shadow-cljs.edn file and help me switch out proto-repl so that I can use cider. I keep getting errors when trying to connect the repl about my middleware. https://github.com/jacekschae/learn-reagent-course-files/blob/master/giggin/shadow-cljs.edn#2019-01-1219:15thheller@chase-lambert you just take out the proto-repl and add cider-nrepl with the version matching your cider config#2019-01-1219:16Chasei thought that was it but maybe i'm using the wrong version. let me find out how to check my cider config#2019-01-1219:16thhellerdoes it not tell you on connect? I thought it used to#2019-01-1219:18thhellerthere are some instructions here but I don't know how current they are. cider seems to be changing a lot. https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2019-01-1219:19Chasedo i want to use shadow or shadow-select if I've already got the server running?#2019-01-1219:19Chasecider does change a lot! I also failed to set my config to only use cider stable. this tech game is hard for me this week!#2019-01-1219:20thhellernot sure I understand what you mean by "shadow or shadow-select"#2019-01-1219:23Chaseahh. when you connect-cljs in cider it asks for host, port, and then Clojurescript repl type. it has two options for shadow-cljs. shadow and shadow-select. Then it also asks for build type so I select dev and it gives me this error:
WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
shadow.user> ExceptionInfo no build with id: :dev  clojure.core/ex-info (core.clj:4739)WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
shadow.user> ExceptionInfo no build with id: :dev  clojure.core/ex-info (core.clj:4739) 
#2019-01-1219:24thhellerthe build is called :app if you are using the default giggin config#2019-01-1219:24thhellerhttps://github.com/jacekschae/learn-reagent-course-files/blob/master/giggin/shadow-cljs.edn#L10#2019-01-1219:29Chasehmmm, ok. still didn't work but it's a little different. Cider is telling me this: CIDER 0.20.0snapshot (package: 20190112.721), nREPL 0.4.5 but if I put that in the dependencies instead of [cider/cider-nrepl "0.19.0"] I get a dependency error when starting the server#2019-01-1219:29thhellerput in what?#2019-01-1219:29Chase
WARNING: No Clojure project was detected. The
refactor-nrepl middleware was not enabled. (You can mute this
warning by customizing `cljr-suppress-no-project-warning'.)
shadow.user> To quit, type: :cljs/quit
[:selected :app]
cljs.user> 
#2019-01-1219:30thhellerthat looks correct now?#2019-01-1219:31Chasebut it says shadow-cljs - connection closed still on the browser. what's a simple expression I can throw in the repl to see if it's working? something like (js/alert "It's working!")?#2019-01-1219:31thhellerit probably still fails to connect due to your strange VM setup#2019-01-1219:32thhellerthe browser is trying to connect to the shadow-cljs process via websocket#2019-01-1219:32Chaseoh. damn that is frustrating. I have it open in both my linux "container" and my regular os.#2019-01-1219:32thhellerand that likely is the problem here#2019-01-1219:32thhelleropen the browser console and check what it says#2019-01-1219:34Chasewait it worked! It is in my linux browser but the bottom left corner is just blank instead of the green shadow-cljs connection open or whatever I thought it would be. Sweet!#2019-01-1219:35Chasethanks again for helping me out. I know i'm probably making things overly difficult. But boy howdy is it frustrating to not even be able to get set up. I'm learning though.#2019-01-1219:41thhellercan't comment on cider anymore. I quit using it a long time ago, got too tired of it breaking 😉#2019-01-1219:41Chasewhat do you use now?#2019-01-1219:41thhellerCursive#2019-01-1220:25hueypI’m getting a compile warning
------ WARNING #5 --------------------------------------------------------------
 File: xxx/animate.cljc:34:21
 variable ReactTransitionGroup is undeclared
--------------------------------------------------------------------------------
it seems to closure optimize fine when I grep the output … but I’m worried I’m missing what its warning me about 🙂
#2019-01-1220:25hueypthis is during a release build#2019-01-1220:27hueypthis is with infer externs / npm package react-transition-group and doing the cljsjs hack of (js/goog.exportSymbol "ReactTransitionGroup" react-transition-group) (we’re still migrating …)#2019-01-1220:35hueypsimilar warning with Raven -- compiled output: https://gist.github.com/eyston/9b60e0896bb344ffd4055637d79e6a48 — I think that sa is the goog.exportSymbol 😜#2019-01-1220:36hueypso it gets all the externs right, it just seems upset at the top level even tho the exportSymbol is right there#2019-01-1221:01thheller@U0KHZ4HNG where or how do you access the ReactTransitionGroup?#2019-01-1221:01hueypjs/ReactTransitionGroup.CSSTransition#2019-01-1221:01hueyp
(js/React.createElement
            js/ReactTransitionGroup.CSSTransition
            (clj->js props)
            #(f (keyword %)))
#2019-01-1221:01hueypalso — this warning is before the final output — like I get two groups of warnings, its in the first#2019-01-1221:01thhellerhmm that alone should prevent that warning?#2019-01-1221:01hueypif that matters (or whats the distinction between the two sets?)#2019-01-1221:02thhellerclosure optimization warnings are separate from cljs compiler warnings yes#2019-01-1221:02hueypthat was my understanding of the extern infer guide — js/* should be fine#2019-01-1221:02hueypwell .. they are both during closure I think? at least it seems that way … or maybe I’m misinterpreting#2019-01-1221:03hueyp
-> Closure - Optimizing ...
------ WARNING #1 --------------------------------------------------------------
 File: com/cognitect/transit.js:649:8

 variable module is undeclared
--------------------------------------------------------------------------------
#2019-01-1221:03hueypthis is the first group, and it happens after the Closure - Optimizing ... step#2019-01-1221:03hueypand the second group is after …#2019-01-1221:03thhelleryeah that is one known#2019-01-1221:03hueyp
[:widget] Build completed. (437 files, 303 compiled, 1 warnings, 75.64s)

------ WARNING #1 --------------------------------------------------------------
 File: om/next.cljc:493:4
--------------------------------------------------------------------------------
#2019-01-1221:03hueypso the first group — thats the clojurescript compiler? second group = closure?#2019-01-1221:04thhellerfirst one is closure#2019-01-1221:08thhellercheck if .shadow-cljs/builds/<your-id>/release/shadow.externs.js contains ReactTransitionGroup.#2019-01-1221:10hueypoh awesome, I was curious how to see what it infer’d 🙂#2019-01-1221:11hueypuh — should everything be on ShadowJS.prototype.* ?#2019-01-1221:12hueyp
/** @const {ShadowJS} */ var FormData;
/** @const {ShadowJS} */ var PropTypes;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var requestAnimationFrame;
this is at the top, the rest is on ShadowJS — no ReactTransitionGroup
#2019-01-1221:13hueypbut it does have the externs for ReactTransitionGroup itself, e.g.
ShadowJS.prototype.CSSTransition;
#2019-01-1221:18hueypsome old cljsjs stuff might still be on our classpath if that could be an issue ;/#2019-01-1221:28thhellerno cljsjs is completely ignored#2019-01-1221:28thhellerdoesn't matter if its on the classpath or not#2019-01-1221:41hueypwe have our own extern file as well — would it be reasonable to add /** @const {ShadowJS} */ var ReactTransitionGroup; plus the handful of others not picked up?#2019-01-1221:41hueypit seems to pick up all the properties correctly which is all that will matter once we migrate away from the cljsjs shims#2019-01-1221:42hueypI think#2019-01-1221:57thhellernot sure if you can add the externs def to your file. closure might complain.#2019-01-1221:57thhellerthere is also https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2019-01-1221:57thhellerglobal:ReactTransitionGroup#2019-01-1222:01hueyp👍#2019-01-1222:01hueypthanks — sorry for taking up your time on just a warning 😜#2019-01-1402:59grounded_sageI'm getting this error on an existing project I am revisiting and not sure where to start on fixing it.
cp: cannot stat 'PREFIX/example-deps.edn': No such file or directory
#2019-01-1403:23grounded_sageI've changed machines and thus downloaded new version of shadow etc#2019-01-1403:50grounded_sageSeems to be related to using the :deps config option#2019-01-1403:55grounded_sagenvm this seems to be a clj on linux issue as I can't even run clj repl#2019-01-1423:54Mark AddlemanI would like to develop my server-side code in the same JVM as is delivering the HTML and javascript in order to avoid CORS issues. Ideally, I would start shadow-cljs and then connect to the nREPL server from Cursive and be off to the races. I couldn't find reference to this workflow in the shadow-cljs docs but I could have easily missed something.#2019-01-1423:59lilactown@mark340 so you have a Clojure service?#2019-01-1423:59Mark AddlemanYes. The browser and the server communicate using sente#2019-01-1500:00lilactownso your Clojure service should serve up your index.html and JS file#2019-01-1500:00Mark AddlemanIt will do that in production. During development, I'd like shadow-cljs to serve them up to get the benefits of live reloading.#2019-01-1500:01Mark AddlemanUnless there is a method for getting shadow's live-reloading through my Clojure service#2019-01-1500:03lilactownlive-reloading is handled through the JS code that is generated by shadow-cljs#2019-01-1500:03lilactownshadow-cljs' HTTP server is only a helper for people who are developing against some external service#2019-01-1500:04Mark AddlemanOh, interesting. Is there some example of manually loading the necessary JS code?#2019-01-1500:04lilactown? what do you mean?#2019-01-1500:05lilactownyou put the generated JS script on the page#2019-01-1500:07Mark AddlemanI think I'm very confused 🙂 In my current workflow, I have some cljs source and an index.html file. shadow-cljs serves the index html and my compiled cljs. There must be some additional JS that shadow-cljs injects in order to manage live reloading. Is that correct?#2019-01-1500:09lilactownyour index.html should be including a JS file, correct?#2019-01-1500:10lilactowne.g. js/main.js. that JS is generated by shadow-cljs. it is your CLJS app's code#2019-01-1500:10lilactownshadow-cljs, when in development mode, adds to your compiled code the stuff required for hot-reloading#2019-01-1500:10lilactownso you only ever need to load the one JS bundle, in this case js/main.js#2019-01-1500:11Mark Addleman> shadow-cljs, when in development mode, adds to your compiled code the stuff required for hot-reloading#2019-01-1500:11Mark AddlemanThis is the piece I was missing#2019-01-1500:11Mark AddlemanI had assumed it was a separate JS file#2019-01-1500:11Mark AddlemanThanks!#2019-01-1500:11lilactownsure thing!#2019-01-1701:05thosmos@mark340 there's also a way to run JVM server code within the JVM server that shadow-cljs starts. There's info in the manual about that. https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-01-1514:08orestisI wonder how easy it is to add your own test runners for shadow-cljs, if e.g. I’d like to integrate Kaocha-CLJS, would it be possible? I’ve made an issue for Kaocha here: https://github.com/lambdaisland/kaocha-cljs/issues/2#2019-01-1514:09thhellerno that would most likely not be possible#2019-01-1514:09thhellerbut shadow-cljs has testing stuff built-in#2019-01-1514:10thhellerno idea what kaocha offers over those#2019-01-1514:11orestisI like the nice pretty-printed output of Kaocha for Clojure. The shadow test runner uses the default clojure.test reporting AFAICT?#2019-01-1514:12thhellerit does but you can switch that to whatever you like#2019-01-1514:12orestisI’ve never used Kaocha-CLJS, but it seems it’s connecting to a CLJS repl via a websocket and gets the results out, then pretty-prints via Clojure.#2019-01-1514:13thhellerI have not used it any kaocha neither CLJ nor CLJS so I have no idea what even the goal is#2019-01-1514:13thhelleror the difference rather over normal lein test#2019-01-1514:13orestisI haven’t used lein test so I don’t know what the “normal” is either 😄#2019-01-1514:14thhellerok lets call it clojure.test#2019-01-1514:14thhellerthat I know#2019-01-1514:14orestisLet me rephrase my X/Y problem then — how can I get a pretty diff when my shadow-ran CLJS test fails?#2019-01-1514:14thhellerif you show me what a pretty diff is I can probably tell you#2019-01-1514:14thhellerdunno what that means#2019-01-1514:15orestishttps://github.com/lambdaisland/deep-diff#2019-01-1514:15orestishttps://github.com/lambdaisland/deep-diff/raw/master/screenshot.png#2019-01-1514:15thhellerthat doesn't have a cljs impl. we can't use that easily without a whole bunch of extra crap we don't really want when running tests#2019-01-1514:16thhellereg. I consider it vitally important to run tests against COMPILED builds#2019-01-1514:17thhellernot some REPL eval'd code#2019-01-1514:17orestisFor sure. I’m just showing that library as an example of what a “pretty diff” looks like#2019-01-1514:18thhellerwould this be considered "pretty"? https://github.com/pjstadig/humane-test-output#2019-01-1514:18orestisI don’t have any strong preference on what should be the ideal pretty diff, but something that helps me narrow down the difference between two possible huge maps would be nice.#2019-01-1514:18thhellerI think thats the one most commonly used#2019-01-1514:19orestisYeah that’s what I’m after. Colors are nice, but secondary. Seems like I can just require that in my namespace and it’ll do the correct thing…#2019-01-1514:20thhellerdon't like that it messes with the internals of cljs.pprint but I guess yes you just require it#2019-01-1514:20thhellerhave not used that either. just saw it before somewhere#2019-01-1514:22thhellerthis is the default test runner. you can write your own pretty easily#2019-01-1514:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#2019-01-1514:22orestisDoesn’t seem to work under node:
ERROR in (select-tag-simple) (TypeError:NaN:NaN)
toggling a tag on and off works
expected: (= true (gamma.state/tag-selected? selected-state tag-id1))
  actual: #object[TypeError TypeError: Cannot read property 'append' of undefined]
#2019-01-1514:23thhellerguess it expects a DOM? no clue#2019-01-1514:23orestisYeah I’ll keep hunting. Point taken about running tests against compiled builds — makes total sense.#2019-01-1514:24thhellerproblem with koacha will be that is directly interops with the cljs analyzer and compiler#2019-01-1514:24thhellerthat means that it won't understand any of the shadow-cljs features such as npm integration#2019-01-1514:25orestisSeems like I should just look for a working pretty-printing library for cljs.test.#2019-01-1514:26thhellerdunno how hard porting deep-diff would be. probably pretty hard as pretty much all the libs used are CLJ only.#2019-01-1514:29orestisSeems to be a known issue: https://github.com/pjstadig/humane-test-output/issues/37#2019-01-1514:30orestisAnd possibly trivial to fix — I’ll see if I can do it tomorrow.#2019-01-1514:31thhellerseems like the only thing really required is the pretty printing#2019-01-1514:32orestisBTW: https://twitter.com/cljtogether/status/1085152627489333251#2019-01-1514:32thhellermore than happy to to do the test integration stuff#2019-01-1514:32thhelleralready applied#2019-01-1514:33orestisI’ll keep you posted — ideally this should be something that shadow doesn’t need to change to accommodate (though perhaps in the spirit of reasonable defaults, could provide out of the box if needed).#2019-01-1514:33thhellerfor the browser test target I already hooked up cljs-test-display which is great#2019-01-1514:34thhellersomething like that just for node would be golden#2019-01-1514:35orestisI’d actually prefer to run my tests on a browser, but node was the easiest to start with (to run unit tests in a very light weight manner). How do you run CLJS tests in CI? Headless chrome?#2019-01-1514:36thhellerI don't at all but others use the karma stuff#2019-01-1514:38orestisAh, good to know. I’ll see how that looks like. Gotta run, thanks for everything (once more!)#2019-01-1516:51richiardiandreaAgree that something like cljs-test-display for node would be awesome 😄 #2019-01-1519:03Daniel HinesI know hardly anything about how cljs works under the hood, so forgive me if this is a dumb question. I want to compile a cljs library into a single script file, load that file from a browser window into a script tag, and start using the library. Is that possible? Would I use shadow-cljs to do that?#2019-01-1519:05lilactown@d4hines short answer, no#2019-01-1519:06lilactownwell, actually, I'm wrong#2019-01-1519:07lilactownshadow-cljs (and the regular CLJS compiler) supports something called module splitting#2019-01-1519:07lilactownso you could, as part of your build, have your library built as one module and your application built as another module#2019-01-1519:08lilactownbut if you want to be able to distribute that pre-built library and use it in other builds external to your application, it won't work#2019-01-1519:08lilactowndoes that kind of make sense? 😬#2019-01-1519:10Daniel HinesWhat you're saying makes sense. Why it is so does not make sense. What I'm trying to do sounds really trivial (in my head, anyway), and we do it in JS all the time: write a script that attaches a useful function to some global var, run that script from the browser, then reference that global var. Why is that so hard in cljs?#2019-01-1519:10thheller@d4hines you mean use the library directly from JS?#2019-01-1519:11thhellerit is not hard in CLJS. you can totally do that#2019-01-1519:11thhellerthe context matters though. how do you want to use it is the more important question?#2019-01-1519:16Daniel HinesYeah, context will help. Are you guys familiar with hyperfiddle? http://www.hyperfiddle.net It's basically a fiddle environment that sits on Datomic - write a query, write a quick view in cljs, and boom - you have a scrappy little app running on datomic cloud somewhere. It already can load custom script tags, which makes it pretty easy to load vanilla js stuff, but I'd like to consume cljs libs from this environment.#2019-01-1519:18lilactownI have a desire for this same kind of capability (different context, same use case). I explored it a few weeks ago and wasn't able to find a way to do it easily#2019-01-1519:19lilactownthe problem is that when your CLJS code is compiled, it bundles with it things like the CLJS data structures and google closure code, that is incompatible with other separate CLJS bundles#2019-01-1519:20lilactownso e.g. two CLJS applications, built from separate projects, will have their own copies of the vector/map/etc. data types. which means that if you try and pass a vector from one bundle to the other, the data types won't be compatible. the thing you passed it to will treat it as a foreign JS object#2019-01-1519:21Daniel HinesOk, so it's fundamentally a Google Closure thing, right?#2019-01-1519:21Daniel HinesNot necessarily a Clojure thing?#2019-01-1519:22lilactownthere's definitely some interplay there. it's the way the CLJS compilation process works#2019-01-1519:23lilactownwhat I would love is the ability to create a bundle that left out all of that stuff, and could be placed on a page with a foreign CLJS bundle. but when I asked dnolen about it, he said it wasn't supported at all#2019-01-1519:24lilactownunfortunately for me, this was a fundamental requirement for the project I'm building. so what I ended up doing is serializing/deserializing the data across those bundle boundaries 😕#2019-01-1519:25Daniel Hines... Well, our code is homoiconic. How terrible is that really?#2019-01-1519:26Daniel Hines(granted, as soon as you reference anotehr npm lib, that's broken)#2019-01-1519:26lilactownwell, you can't pass code between the bundles without including self-hosted CLJS#2019-01-1519:27lilactownI'm just sending EDN back and forth, without behavior#2019-01-1519:29Daniel HinesIs this why self-hosted is a big deal?#2019-01-1519:29thheller@d4hines are you going to use the library from JS code or from CLJS?#2019-01-1519:29Daniel HinesCLJS.#2019-01-1519:29thhellerso you are compiling CLJS? why have it pre-compiled then?#2019-01-1519:30Daniel HinesThat's a good question: maybe I don't have to?#2019-01-1519:30lilactown@d4hines do you have to compile your CLJS code before you put it on hyperfiddle?#2019-01-1519:30Daniel HinesNo, you write it in the fiddle, like in JSFiddle or CodePen#2019-01-1519:31thhellerso the fundamental problem is that CLJS builds generally include all of cljs.core and some of the google closure library#2019-01-1519:32thhellerso if you already have CLJS in the page from hyperfiddle#2019-01-1519:32thhellerthen CLJS from your lib#2019-01-1519:32thhellerthen CLJS from your extra code#2019-01-1519:32thhellermeans 3 separate cljs.core instances on the page#2019-01-1519:32thhellerwhich is bad#2019-01-1519:33thhelleryou could strip out all of cljs.core and assume it provided#2019-01-1519:33thhellerbut that only work when using no optimizations#2019-01-1519:33thhellermeaning huge builds#2019-01-1519:34thhellerclojurescript is different than JS because it has macros#2019-01-1519:35thhellerso even if you strip out cljs.core you still need access to the macros somehow when compiling your lib code#2019-01-1519:35thhellerso you could potentially end up compiling against a different CLJS version#2019-01-1519:35thhellerin short it is not advised at all to do this in CLJS#2019-01-1519:35thhelleryou can make something work but its gonna suck big time#2019-01-1519:36thhellerif you just want a standalone library that provides a JS API thats not problem#2019-01-1519:37lilactownit sounds like hyperfiddle already has self-hosting. so if your library is self-host compatible, you might be able to do what you were saying where you load the file and eval it#2019-01-1519:38Daniel HinesSelf-hosting in hyperfiddle means running the backend services yourself. You're talking about the host language right?#2019-01-1519:38lilactownI mean "self-hosted ClojureScript"#2019-01-1519:39lilactowni.e. you can (eval '(println "foo")) in ClojureScript#2019-01-1519:39lilactownin "normal" CLJS projects, this isn't supported (and usually isn't needed 😉 )#2019-01-1519:40lilactownthere are ways to setup your project to use it though. it sounds like hyperfiddle already does, since it's executing your CLJS code in the browser#2019-01-1519:40Daniel HinesYes, that's all true.#2019-01-1519:41Daniel HinesThat will break down as soon as an external lib (like an npm lib) is referenced though, right?#2019-01-1519:41lilactownright, if you need some external dependency, you'll need to load that too#2019-01-1519:41lilactownand reference that in a way that it can be accessed on the page#2019-01-1519:42lilactownhonestly I would ask @dustingetz how he would try and do this 😛 he's building hyperfiddle#2019-01-1519:43Daniel HinesI was just chatting with him.His solution (and this sounds much more practical), is to just host hyperfiddle yourself, and include whatever deps you need at build time. I just wondered why we can't do what JS can do, which ya'll answered very well (thanks!)#2019-01-1519:44thhellerwe can do everything JS does. its not different really, JS has pretty much the same restrictions#2019-01-1519:45thhellerjust remember that you are not just using YOUR library. you are also using cljs.core and some of the closure library#2019-01-1519:45thhellerto compare with that a JS library assume that your JS lib wants to use immutable-js + lodash or so#2019-01-1519:46thhellerso you are paying the extra overhead for loading those too#2019-01-1519:46thhellerif you accept that then CLJS is no different#2019-01-1519:46thhelleryou just can't do jQuery style libs where everything assumes that there is a global jQuery loaded somewhere#2019-01-1519:47thhellerstitching things together via some global variables won't work#2019-01-1519:47Daniel HinesNot even with eval?#2019-01-1519:47Daniel HinesLike lilactown was saying?#2019-01-1519:48thhellereval fundamentally needs access to the source which isn't what you wanted AFAICT#2019-01-1519:48thhellerand no not even with eval#2019-01-1519:50lilactownso, for my use case. I am building a dev tool that I want to allow people to extend with their own 3rd party plugins#2019-01-1519:50lilactownwould I be able to instruct people building those plugins how to build their CLJS code in a way that could interface with my main dev tool application?#2019-01-1519:51lilactowncause right now, the solution I have is to communicate via stringified-EDN or transit and hand them a DOM node to render their plugin to 😕#2019-01-1519:52thheller@lilactown not sure I understand but no you cannot pass CLJS collection instances between different cljs.core versions#2019-01-1519:52thhellerthey will not be compatible#2019-01-1519:52lilactownright. I've gotten that far#2019-01-1519:52thhellernormal JS interops works as normal
#2019-01-1519:53lilactownwould I be able to instruct people building those plugins how to build their CLJS code in a way that could use my application's version of cljs.core?#2019-01-1519:53lilactownand React#2019-01-1519:54thhellerif you are fine using no optimizations at all?#2019-01-1519:54thhellerbut generally no that won't work#2019-01-1519:54lilactownit is a developer tool 😜#2019-01-1519:55thhelleryou want to build something REBL like right?#2019-01-1519:55lilactownOK, I'll have to think on that. there will be times that this lives on the same page as a user's application at development time, so I also need to make sure I don't clobber their application's cljs.core etc.#2019-01-1519:55lilactownyeah#2019-01-1519:56thhellerthats gonna be much much much harder in CLJS than CLJ#2019-01-1519:56thhellerproblem is ensuring the library code uses the same version of everything your code uses#2019-01-1519:57thhellerbut unoptimized code can be combined at will#2019-01-1519:57thhellerjust need to "trick" the loader a little#2019-01-1519:58Daniel HinesI really appreciate the explanations guys. #2019-01-1519:58lilactownwith shadow-cljs, would :output-wrapper be able to ensure I don't clobber a user's application?#2019-01-1519:59thhellernot sure what you mean by that#2019-01-1519:59thhellerI thought the goal is to incorporate user code into yours?#2019-01-1519:59thhellerbut honestly don't waste your time trying to do this#2019-01-1520:00thhellerprotocols and all that stuff won't work properly#2019-01-1520:00thhellerits just gonna be annoying as hell to work around all the limitations#2019-01-1520:00lilactownthere's 3 types of things that might be living on the page: - user's application - REBL application - 3rd party REBL viewers#2019-01-1520:01thhellerah ok. yeah don't do that#2019-01-1520:01thhellerload REBL code in an iframe or so#2019-01-1520:01thhellerdo not load it in the users application#2019-01-1520:02thhellerbut yes :output-wrapper would isolate everything#2019-01-1520:02lilactownwell. right now, I'm compiling the REBL application and keeping it to one module. so it should be isolated#2019-01-1520:02lilactownthe user's application communicates to it via EDN + some JS interop#2019-01-1520:04lilactownwhat I'm trying to figure out now is how the 3rd party REBL viewers will hook into the REBL application#2019-01-1520:06thhellerprobably want to use a plain JS API#2019-01-1520:06thhellerno CLJS collections#2019-01-1520:06thhellernot sure how that would work in a REBL style application given its protocol heavy nature#2019-01-1520:07lilactownatm, the user installs a library in their application code that handles serializing and sending data to the REBL application, and listening for events and calling nav / datafy#2019-01-1520:08thhellerbut thats gonna be pretty inefficient#2019-01-1520:08lilactownyep 🙃#2019-01-1520:09lilactownin my testing I haven't noticed any real perf problems. but I've yet to use it in really complex applications#2019-01-1520:09lilactownbut the upside, is that it works in Node.js too#2019-01-1520:10lilactownand eventually JVM Clojure#2019-01-1520:10lilactownit just connects over a websocket#2019-01-1520:10thhellerstill no clue how any of that would actually work though#2019-01-1520:10thhellernav + datafy are protocols and sometimes on metadata#2019-01-1520:10thhelleryou can't serialize objects that have those in metadata#2019-01-1520:11thhellerwell you can but you are gonna lose the meta impls#2019-01-1520:11lilactownthe way it works right now is that when you want to send something to the REBL app, you tap> it#2019-01-1520:11thhellergotta go, bbl#2019-01-1520:13lilactownthe library the user installed, adds a tap listener that adds the data as an entry to a global atom and sends it over the wire for viewing with an ID that it can use to reference the entry in the atom#2019-01-1520:17lilactownanytime the REBL app needs to call nav or datafy, it sends an event back to the user's application to call nav or datafy on the entry in the atom and then send the result back to the REBL app#2019-01-1600:28hueypdoes anyone know how to kinda tell shadow-cljs of a dependency that doesn’t exist in package.json? in my example, jquery w/ bootstrap ;/#2019-01-1600:35thheller@hueyp https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global#2019-01-1600:40hueypI don’t think I get it … are you saying move jquery to a CDN? or we can actually configure npm bootstrap to have a direct dependency on our npm jquery?#2019-01-1600:41thhellerI was assuming you already loaded jquery by other means?#2019-01-1600:41thhellerwhy else would it not exist in package.json?#2019-01-1600:41hueypbootstrap’s package.json doesn’t actually list jquery as a dependency … but it really is … its a bad package tbqh#2019-01-1600:41hueypour current answer is — shove the dependency in ourselves 😜#2019-01-1600:41hueypseeing if this works …#2019-01-1600:41thhellerthen add jquery to your deps?#2019-01-1600:42thhellerpeerdependencies are pretty common in npm world#2019-01-1600:42thhellerperfectly normal for you to add it#2019-01-1600:42hueypoh … we can actually define bootstrap’s peer dependencies?#2019-01-1600:43thhellerno you add bootstrap and jquery to your deps#2019-01-1600:43thhellerthats how it works in node land#2019-01-1600:43hueypwe have both, and both get loaded, but the order they get loaded is not guaranteed to be correct* as bootstrap doesn’t list a dependency on jquery, but it really has one#2019-01-1600:44hueyplike — its a bad package.json#2019-01-1600:44thhellerwasn't that fixed ages ago? I submitted a patch ages ago which was merged#2019-01-1600:44thhellerbut you can control the load order by just requiring jquery before bootstrap#2019-01-1600:45hueyp👍#2019-01-1610:24metacritical@thheller I am writing this bootstrapped electron app, when i pass the option {:verbose true} to eval-str it dumps build messages as console.error messages to the devtools area, i presume that it is because *out* is mapped to console ? I am right in thinking that? And if so can i map it to something else ? I want to map out such that these debug messages are visible in a text area in the app instead of devtools console. Would it be possible to do that?#2019-01-1610:24metacriticalThanks is advance.#2019-01-1611:09lsnapeHi, is there a way to suppress compiler warnings that are caused by 3rd-party code?#2019-01-1611:34thheller@metacritical since bindings don't work well in async environments (ie. CLJS) you kinda have to pick one logger. so either everything goes to console or everything goes to wherever you set *out* to. you can call (set-print-fn! (fn [foo] ....)) to control where prints goes.#2019-01-1611:35metacritical@thheller Aha, i actually want to get all console messages in one place, this is helpful. Thanks.#2019-01-1701:10thosmosis there a way to turn off devtools for just one module in a dev build that has devtools enabled? my webworker is failing because it's loading the devtools stuff and turning it off in the module section doesn't seem to do anything:
:devtools   {:http-root  "admin/public"
                               :http-port  1337
                               :after-load threshold.admin.core/reload
                               :preloads   [fulcro.inspect.preload  threshold.admin.development-preload]}
                  :modules    {:main   {:init-fn threshold.admin.core/main
                                        :entries [threshold.admin.core]}
                               :worker {:devtools {:enabled false}
                                        :entries [threshold.admin.worker.core]
                                        :depends-on #{:main}
                                        :web-worker true}}

#2019-01-1706:00caleb.macdonaldblackWhat are some good ways to bring in variables from system environment variables? I'm currently using a macro with direnv, however I think I'm having some caching issues#2019-01-1707:13lilactownsystem environment variables is usually a code smell. why are you using env vars in a browser app?#2019-01-1708:23caleb.macdonaldblackI have multiple environments develop, staging & production each with it's own backend infrastructure. I compile on CircleCI where I use the git branch to decide what environment variables to use. My application is compiled with those environment variables.#2019-01-1708:24caleb.macdonaldblackI'm injecting them kind of like how create-react-app does it for ReactJS https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables#2019-01-1716:14lilactownwe do similar, but we have other ways of discerning which env we’re in. e.g. by host name, or by a global var on the page inserted by the back end#2019-01-1716:14lilactownthat way our builds are portable. it seems weird to have to compile your app for each environment#2019-01-1723:10caleb.macdonaldblackI'm hosting static html files so I can't insert them dynamically with a web server.#2019-01-1710:40thheller@caleb.macdonaldblack I generally recommend avoiding environment variables for browser builds and instead passing data to the build from HTML#2019-01-1710:40thhellerbut you can use #shadow/env "FOO" in the build config to access environment variables#2019-01-1710:41thhelleror use :cache-blockers to prohibit caching of files that use side-effecting macros https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2019-01-1710:42caleb.macdonaldblackWhat do you mean by passing data from html?#2019-01-1710:42thheller@thosmos how is it failing? devtools should be disabled for webworkers?#2019-01-1710:43thheller@caleb.macdonaldblack I generally recommend using an init function. (defn ^:export init [some-config] ...) <script>your.ns.init({"url":"http://..."});</script>#2019-01-1710:44thhelleralternatively <script>var MY_CONFIG = {...};</script> and then accessing js/MY_CONFIG#2019-01-1710:45thhellerthat pattern makes most sense if you have a dynamic webserver and not just static html files though#2019-01-1710:45thhellerbut you could just use an index.html + index-ci.html or so#2019-01-1710:49caleb.macdonaldblackYea Im using static html files but I can see how incredibly useful that method would be for dynamic stuff. Im not sure what you meant by index-ci.html though. Are you suggesting multiple index-*.html files with different configs for my environments and the copying that file to index.html when I deploy?#2019-01-1710:50thhellerif you are not using a dynamic web server yes. you can either copy or generate different html files depending on the environment#2019-01-1710:54caleb.macdonaldblackOkay. From your suggestions I think I prefer the #shadow/env method for static hosting plus it works well with my current setup. However I really like the other method for dynamic web servers. Thanks a lot for the help. #2019-01-1716:33aisamuHi! I'm getting a ReferenceError: garden is not defined, but I can't figure out why. It happens while using cljs code as a regular module on webpack. The CLJS code targets :npm-module and is generated with the compile task. The component in question uses https://github.com/matthieu-beteille/cljs-css-modules, and adding garden.core on the ns that uses it "solves" the problem. The compiled webpack bundle contains modules for cljs-css-modules, garden and my component, as expected. cljs-css-modules contains a __webpack_require__ pointing to garden's module. Without garden.core explicitly required, my component's module contains a __webpack_require__ to cljs-css-modules but it fails. With garden.core require outside the ns (via a macro that outputs a require), the module gains a goog.require('garden.core') but it still fails. With garden.core explicitly imported on the component, the webpack module gains a __webpack_require__ to the garden module, a garden=$CLJS.garden and a goog.require('garden.core'). Everything works. What is confusing me is that cljs-css-modules imports garden.core, and my code both requires and webpack_requires cljs-css-modules. Is it expected to have to require garden again?#2019-01-1716:36thheller@aisamu which shadow-cljs version are you on? (should be fixed in latest)#2019-01-1716:37aisamuOh, forgot! version: 2.7.8 node: v9.11.2#2019-01-1716:38thhellertry 2.7.15#2019-01-1716:38aisamuWill do, thanks!#2019-01-1716:53aisamuIt works beautifully! Thanks again!#2019-01-1800:19lilactownI ran into a really bizarre thing today#2019-01-1800:22lilactownevaluating a module that contained code instantiating this type:
(deftype MockRemote [query-map error-map]
  dp/IDataRemote
  (query! [this query config]
    (-> (p/delay 100)
        (p/then
         (fn []
           (when (contains? error-map query)
             (throw (error-map query)))
           (if (contains? query-map query)
             (query-map query)
             (query-map :mock/default)))))))
completely failed in a release build
#2019-01-1800:22lilactownthe offending line: (p/delay 100)#2019-01-1800:23lilactown(p is promesa.core)#2019-01-1800:25lilactownthe error at runtime:
Error: 1
    at modulemanager.js:588
    at $goog$module$ModuleLoadCallback$$.execute (moduleloadcallback.js:60)
    at $JSCompiler_StaticMethods_callCallbacks_$$ (moduleinfo.js:324)
    at $JSCompiler_StaticMethods_onError$$ (moduleinfo.js:287)
    at $JSCompiler_StaticMethods_dispatchModuleLoadFailed_$$ (modulemanager.js:1261)
    at $JSCompiler_StaticMethods_requeueBatchOrDispatchFailure_$$ (modulemanager.js:1193)
    at $goog$module$ModuleManager$$.$APP.$JSCompiler_prototypeAlias$$.$handleLoadError_$ (modulemanager.js:1146)
    at $JSCompiler_StaticMethods_evaluateCode_$$ (moduleloader.js:373)
    at $goog$module$ModuleLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (moduleloader.js:256)
    at $JSCompiler_StaticMethods_fireListeners$$ (eventtarget.js:284)
    at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.dispatchEvent (eventtarget.js:381)
    at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (bulkloader.js:168)
    at $goog$net$BulkLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleEvent_$ (bulkloader.js:118)
    at $JSCompiler_StaticMethods_fireListeners$$ (eventtarget.js:284)
    at $goog$net$XhrIo$$.$APP.$JSCompiler_prototypeAlias$$.dispatchEvent (eventtarget.js:381)
    at $JSCompiler_StaticMethods_onReadyStateChangeHelper_$$ (xhrio.js:867)
#2019-01-1800:25lilactownchanging it to
(p/promise
         (fn [resolve _]
           (js/setTimeout #(resolve "resolved") 100)))
resolved the issue
#2019-01-1809:43joelsanchezsay I want to distribute a cljs component through clojars. the component has some css and depends on some npm modules. - how do I indicate that the component depends on certain npm modules? - how do I deal with css? I know I can put it under resources, but is there a better way? thx#2019-01-1809:45thhellerfor the deps you can includes a deps.cljs with {:npm-deps {"the-dep" "version"}}#2019-01-1809:47thhellercss is highly dependent on what users use to build their css. don't think there is a good way for this currently. css support is still in the planning stages for shadow-cljs.#2019-01-1809:52joelsanchezthank you for the npm-deps tip. regarding the css, re-com is just bundling it inside resources/public/assets/css and I think that's good enough#2019-01-1810:02thhellerno thats bad#2019-01-1810:03thhellerwell the path is bad imho#2019-01-1810:03thhellerbut I guess it works when using a using a java webserver serving the public resources#2019-01-1810:06joelsanchezwhat do you suggest? the main user of this "component" is me. I'd like to @import it in my scss code but I won't be able to if it's a resource#2019-01-1810:06joelsanchezmy plan was to simply require it in the HTML code along the css file compiled from scss#2019-01-1810:07thhelleryeah need something to copy it to the filesystem so sass can find it#2019-01-1810:09joelsanchezI already have code to run the scss compiler from clojure, more code to move files around won't bother me much but, regarding the path, is it a good idea to do this? resources/{groupId}/{artifactId}/{version}/main.css?#2019-01-1810:09joelsanchezor without the version#2019-01-1810:34thhellernah without version. I would just namespace it normally. resources/your/lib/foo.css#2019-01-1811:28cmalHi, I split my code using the method described on https://shadow-cljs.github.io/docs/UsersGuide.html#_modules , but :advanced optimization errors Uncaught ReferenceError: Oe is not defined. I tried :simple optimization, no error occurs. Is that related to the code splitting during :advanced?#2019-01-1811:29thheller@cmal try :advanced with shadow-cljs release your-build --pseudo-names to find out what Oe is. I always use :advanced with :modules so it should work#2019-01-1811:30cmalok#2019-01-1811:31thhellerare you doing anything with the code after shadow-cljs is done with it? any other processing like adding a wrapper or so?#2019-01-1811:31thhellerand do you load modules in the correct order?#2019-01-1811:31cmalyep#2019-01-1811:32cmalI added prepend and append#2019-01-1811:32thhellerdo they create a function wrapper?#2019-01-1811:32cmalwrap those in a (function(){...}.call(this); and call a exported method#2019-01-1811:32thhellerok don't do that. use :output-wrapper true#2019-01-1811:32thhellerthat does that and ensures things work correctly#2019-01-1811:33cmalok. But can I append a method call?#2019-01-1811:33thhellersure#2019-01-1811:34thheller:modules just assumes everything is in a global scope by default#2019-01-1811:35thhellerif you wrap it that won't be true#2019-01-1811:36thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper#2019-01-1811:38cmalThank you very much. It works perfectly now!#2019-01-1817:34hoopeshi, is it possible to shadow-cljs release some-build and get source maps?#2019-01-1817:36justinbarclayThis is what I use
:app
  {:target :browser
   :output-dir "./min"
   :compiler-options {:source-map true}
   :modules {:application {:init-fn app.core/run}}}}}
#2019-01-1817:36justinbarclayYou can read more about it here: https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options#2019-01-1817:38thhellercorrect. :compiler-options {:source-map true}#2019-01-1817:59theaspHello, is there an easy way to use libs that use :foreign-libs in deps.cljs?#2019-01-1820:50thheller:foreign-libs are intentionally not support at all. so no there is no way to use it with shadow-cljs. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-01-1818:14hoopes@emoarmy thanks very much!#2019-01-1818:48Pavel KlavíkHi, I am building a full stack web app and currently using lein and cljsbuild for compilation. (Based on reframe lein template.) I am thinking of switching to shadowcljs for npm support. What is the workflow for web server compilation, to produce uberjar?#2019-01-1818:49lilactownpretty much the same as cljsbuild#2019-01-1818:50lilactownif you're deploying an uberjar with your front-end CLJS compiled code inside of it (e.g. in resources), then you'll run the CLJS compilation step first. Then create the uberjar. Then deploy the uberjar#2019-01-1818:50Pavel Klavíkis it recommended to use shadow-cljs from lein project file?#2019-01-1818:51lilactownsure! shadow-cljs works wherever you need CLJS#2019-01-1818:51lilactownwhat a lot of people do is put their CLJ (Java) dependencies in their project.clj, and their CLJS dependencies in their shadow-cljs.edn#2019-01-1818:54Pavel KlavíkI see, do you have an example of some simple project so I could take a look how is everything set up?#2019-01-1818:57alexandergunnarsonI wonder — could I use React Native as the host for shadow-cljs? https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html says that First you need a “host” build which will be your “app” (currently limited to :browser builds).#2019-01-1818:57alexandergunnarsonBasically what I have is some code that needs to be run in a bootstrapped environment that I want to be able to be run in both simple and advanced compilation modes in both the browser and in React Native. Also in simple mode I'd like it to be able to be auto-reloadable like Figwheel. I know shadow-cljs can do most of this but the things in question are 1) advanced compilation mode for bootstrapped and 2) bootstrap + React Native#2019-01-1818:58alexandergunnarsonA big ask, I know 😄 If there's code to be written I'd be happy to lend a hand. But if there's an out-of-the-box solution I'll take that#2019-01-1819:07lilactownso I know off the bat that advanced compilation + bootstrapped don't mesh#2019-01-1819:10lilactownI'm not sure if anyone's tried to put bootstrapped CLJS in React Native before#2019-01-1819:10lilactowncould be interesting#2019-01-1819:14alexandergunnarsonHmm, that’s disappointing @lilactown… I had figured that if I used google-closure-compiler-js or rather the JS version of google-closure-compiler it might work#2019-01-1819:18alexandergunnarsonBasically what I’m needing is for the source language to be the same as the compilation language. This is because I’m trying to create a type system that is able to leverage arbitrary spec-like predicates by evaluating them at compile time to elide as many runtime checks as possible.#2019-01-1819:19alexandergunnarsonI assume that requires a bootstrap build#2019-01-1819:20lilactownI have no idea what you're talking about lol#2019-01-1819:20alexandergunnarsonSo like (defmacro abc [] (do-this-in-cljs-not-clj)) e.g. (defmacro abc [x] (js/parseInt x))#2019-01-1819:21lilactownstill not clear to me. this sounds like what reader conditionals are for#2019-01-1819:21alexandergunnarsonCurrently when compiling CLJS, any code inside macros is evaluated in CLJ#2019-01-1819:22alexandergunnarsonOnly the code outputted from the macro is evaluated in CLJS#2019-01-1819:22alexandergunnarsonSo like in CLJS if you did (defn abc [x] (js/parseInt x)) that’s fine, but (defmacro abc [x] (js/parseInt x)) it would fail off the bat since you can’t defmacro in CLJS without bootstrap anyway#2019-01-1819:22alexandergunnarsonEhh never mind, maybe I answered my own question#2019-01-1819:23lilactownoh?#2019-01-1819:23alexandergunnarsonWhat are you surprised about haha?#2019-01-1819:24lilactownI'm still trying to figure out what your question is 😅 and what the answer is#2019-01-1819:24alexandergunnarsonNever mind haha I think I answered it#2019-01-1819:26lilactownI think if I'm understanding correctly, you actually want shadow-cljs, the tool to run in CLJS?#2019-01-1819:26alexandergunnarsonNo, I don’t think so#2019-01-1819:27lilactownbecause you want to evaluate these CLJS forms at compile-time, not at run-time?#2019-01-1819:28lilactownshadow-cljs is a JVM program, so it's always going to evaluate your macros etc. at compile-time in a JVM context#2019-01-1819:29lilactownI haven't explored this at all, but maybe something like lumo, which is a completely self-hosted compiler, could do what you're looking for#2019-01-1819:30lilactownshadow-cljs bootstrap' support is simply going to push those macro expansions to runtime, which it doesn't sound like is what you want?#2019-01-1819:30alexandergunnarsonOhh okay yeah then perhaps shadow-cljs is not what I’m looking for#2019-01-1819:31alexandergunnarsonI do want to evaluate the CLJS forms at compile-time#2019-01-1819:31alexandergunnarsonThough I’m not sure Lumo supports useful things like auto-reloading etc.#2019-01-1819:31alexandergunnarsonMight have to hack this together#2019-01-1819:31lilactownthat's true#2019-01-1819:32lilactownI'm curious why you need the compile-time evaluation context to be the same as the runtime?#2019-01-1819:34alexandergunnarsonI’m trying to build a type system. An example might be this: (t/defn append! [s #?(:clj (t/isa? java.lang.StringBuilder) :cljs (t/isa? js/StringBuffer)), x string?] #?(:clj (.append s x) :cljs (.join s x)))#2019-01-1819:34alexandergunnarsonSo a typed function that takes a StringBuilder in CLJ or js/StringBuffer in CLJS#2019-01-1819:34alexandergunnarsonAnd appends it#2019-01-1819:35alexandergunnarsonThe type system will need to know at compile time whether callers of append! are indeed providing a js/StringBuffer or not#2019-01-1819:36alexandergunnarsonSo like (append! 123 "abc") would fail whereas (append! (js/StringBuffer.) "abc") would succeed, both at compile time#2019-01-1819:36lilactownhow will your CLJS program know at compile time it's providing a StringBuffer?#2019-01-1819:38alexandergunnarsonIf you wrap it in a macro, e.g. let’s call it t/dotyped, it can analyze the forms and see in (js/StringBuffer.) that it’s a constructor (`new` form), which returns a class of whatever the first argument is (in this case js/StringBuffer). The compiler can then evaluate the symbol 'js/StringBuffer to the actual class#2019-01-1819:39lilactowncan it?#2019-01-1819:39alexandergunnarsonThen do an inheritance (well, equality) check of the evaluated symbol against the actual js/StringBuffer#2019-01-1819:39alexandergunnarsonI’ve got it to work with something similar in CLJ (and much more complex things)#2019-01-1819:39alexandergunnarsonI don’t see why it couldn’t in CLJS if the compiler were written in JS/CLJS#2019-01-1819:40lilactownwhat about this:
(def str-buf #(js/StringBuffer.))

(append! (str-buf) "abc")
?
#2019-01-1819:41alexandergunnarsonGood point — it would only know the type of str-buf which is a js/Function; it wouldn’t have any knowledge about the internals of str-buf#2019-01-1819:41alexandergunnarsonHowever#2019-01-1819:41alexandergunnarsonThis is why I would use t/fn in that case#2019-01-1819:41alexandergunnarsonSo like (def str-buf (t/fn [] (js/StringBuffer.)))#2019-01-1819:41alexandergunnarsonIn that case the compiler would know what the return type of str-buf is#2019-01-1819:42lilactownso, I haven't done too many things w.r.t. type systems / prog langs#2019-01-1819:42alexandergunnarsonBecause the type of str-buf would be (t/ftype [> (t/isa? js/StringBuffer)]) i.e. a function that takes no args and returns a js/StringBuffer, when str-buf is called, (dotyped (append! (str-buf) "abc") would know the type#2019-01-1819:42lilactownbut it sounds like at some point you're going to have to eval the entire program with this strategy#2019-01-1819:42alexandergunnarsonYes incrementally#2019-01-1819:43alexandergunnarsonThat’s what macros do anyway in CLJ#2019-01-1819:43alexandergunnarsonYes they emit code but then that code is evaluated in CLJ#2019-01-1819:43lilactownwell, no. macros operate on clojure code#2019-01-1819:43lilactownit doesn't evaluate the users code#2019-01-1819:43alexandergunnarsonI’m speaking only about compile time#2019-01-1819:44lilactownwhy does it need to be able to evaluate js/StringBuffer at compile time, though?#2019-01-1819:44lilactownwhy not look for the symbol?#2019-01-1819:45alexandergunnarsonThat is definitely one strategy#2019-01-1819:45alexandergunnarsonBut I want this to work for arbitrary predicates#2019-01-1819:45alexandergunnarsonNot just concrete classes / interfaces#2019-01-1819:45lilactownI think you're walking into a quagmire 😉#2019-01-1819:46alexandergunnarsonThe type system does work in Clojure 🙂#2019-01-1819:46lilactownevaluating arbitrary predicates at compile time is an open area of research. see experimental languages like Idris that implement dependent types#2019-01-1819:47lilactownbut I'm not going to dissuade you! best of luck#2019-01-1819:47alexandergunnarsonFor instance (t/defn f [m (t/and t/map? my-arbitrary-predicate)] ....), then (t/dotyped (f {:a 1 :b 2})) can be checked at compile time#2019-01-1819:48alexandergunnarsonGranted, in the case of (t/fn [m t/map?] (f m)), my-arbitrary-predicate will have to be checked at runtime#2019-01-1819:48alexandergunnarsonSo there are quagmire-y things to be sure#2019-01-1819:50lilactownand what happens if I'm running in a context that doesn't have js/StringBuffer?#2019-01-1819:50alexandergunnarsonThen it fails#2019-01-1819:50alexandergunnarsonWith something like “cannot resolve symbol”#2019-01-1819:50lilactownat runtime?#2019-01-1819:51alexandergunnarsonNo at compile time (assuming a CLJS-in-CLJS compiler)#2019-01-1819:51alexandergunnarsonOf course maybe the runtime has a different environment than the compile-time environment i.e. runtime has js/StringBuffer, compile-time doesn’t#2019-01-1819:51alexandergunnarsonBut I feel like that point you’re on your own haha#2019-01-1819:51lilactownwell that happens all the time on the web 🙂#2019-01-1819:52alexandergunnarsonI mean yeah this is why if you’re using the type system on things that may or may not be there you might have to polyfill as a fallback#2019-01-1819:52alexandergunnarsonOr just don’t use those things that may or may not be there#2019-01-1819:53alexandergunnarsonThere may be other strategies of course, like not using the type system for those things, or falling back to runtime type checking in those cases#2019-01-1819:55lilactowni guess my point is that I don't know what you buy for moving your type system to run in CLJS at compile-time#2019-01-1819:57alexandergunnarsonPerhaps the effort is more than it’s worth, I don’t know#2019-01-1819:59alexandergunnarsonBut it seems like more of a pain to support an arbitrary predicate that uses some CLJS-specific thing but can only be symbolically analyzed (i.e. does the symbol js/StringBuffer equal the symbol js/StringBuffer?)#2019-01-1820:00alexandergunnarsonFor instance if you did (t/defn f [x my-arbitrary-predicate] ...) and (t/dotyped (f "asd")) you could run my-arbitrary-predicate in CLJ at compile-time to figure out type-satisfaction, whereas in CLJS you’d always have to resort to runtime type checking#2019-01-1820:00alexandergunnarsonMaybe that’s a small price to pay to stay within the non-bootstrapped ecosystem, not sure#2019-01-1820:02alexandergunnarsonPerhaps what I’ll do for CLJS is only do symbolic analysis falling back to runtime checking to begin with. Then for those use cases where that isn’t good enough, weigh that against switching to bootstrapped CLJS. I can’t think up all the cases ahead of time, to be fair#2019-01-1820:03alexandergunnarsonAnyway thanks for your help!#2019-01-1820:04lilactownbut I think that the fact that js/StringBuffer in your type-checking program is the same as js/StringBuffer at runtime is only accidental#2019-01-1820:05lilactownit's equivalent in sound-ness as checking the symbol#2019-01-1820:05lilactownanyway, fun chat 🙂 I'll leave you be! Sorry for sticking my nose in#2019-01-1820:06alexandergunnarsonYeah fun chat! 🙂 If you want to keep talking about it that’s fine! I just didn’t want to be a pain with my counterarguments haha#2019-01-1820:06alexandergunnarson'js/StringBuffer' in your type-checking program is the same as 'js/StringBuffer' at runtime is only accidental → I get what you’re saying. For instance js/StringBuffer might mutate or something, or be completely different in compilation than at runtime#2019-01-1820:08alexandergunnarsonClojure doesn’t have any of these (ahem) fun little intricacies… it would be nice for CLJS to, well, play just as nicely as CLJ does haha#2019-01-1820:10lilactownwell, Clojure does too#2019-01-1820:10alexandergunnarsonClojure definitely has its own idiosyncrasies#2019-01-1820:11alexandergunnarsonBut none so frustrating as the compile-time platform being (completely — not just like V8 vs SpiderMonkey) different than the runtime platform#2019-01-1820:12lilactownhost interop is kind of easiest thing to point at, but even something like:
(def a 1)

;; nested in some other code
   .... (def a "foo")

(defn inc-a []
  (+ a 1))
#2019-01-1820:12alexandergunnarson
;; nested in some other code
   .... (def a "foo")
My answer is just don’t do that haha
#2019-01-1820:12lilactownwhat you end up doing is either using static analysis at a best guess (walking the AST, checking symbols, etc.), or you have to evaluate the persons entire program#2019-01-1820:13alexandergunnarsonYou can find out a surprising amount of information — no “best guess” required — but yes if you look at the whole program, and evaluate key parts of it#2019-01-1820:13lilactownbeing able to evaluate (def a 1) and resolve that to a Number or java.lang.Integer doesn't buy you any more guarantees#2019-01-1820:13alexandergunnarsonTrue#2019-01-1820:14alexandergunnarsonIf you did (t/def a 1) then the type of a would be (t/value 1) which is a lot more useful than Number or java.lang.Integer#2019-01-1820:14alexandergunnarsonI guess you could also just do a normal def and it would resolve from the environment#2019-01-1820:14alexandergunnarsonBut yeah you would have to evaluate the whole program#2019-01-1820:15alexandergunnarsonAnything that’s top-level anyway — anything that the (CLJ) compiler would normally evaluate#2019-01-1820:15lilactownand you'll have to load any dependencies at compile-time as well#2019-01-1820:15alexandergunnarsonThat’s already done in CLJ though, no?#2019-01-1820:16lilactownit doesn't evaluate the dependencies#2019-01-1820:16alexandergunnarsonPerhaps my understanding of CLJ compilation is flawed but I would be surprised#2019-01-1820:16alexandergunnarsonThat’s interesting to me what you say#2019-01-1820:17alexandergunnarsonLike if ns A depends on ns B which is not in your source code (e.g. let’s say it’s in a jar on the classpath imported via Leiningen), my understanding was that the compiler evaluates ns A, and in order to do that, has to evaluate ns B#2019-01-1820:17alexandergunnarsonOf course if it’s a Java class then it just loads the class (but may not necessarily use it in such a way that its static block is run as in Class/forName)#2019-01-1820:18lilactownso this gets murky because CLJ isn't a compiled language, and CLJS is#2019-01-1820:18alexandergunnarsonThat’s fair#2019-01-1820:19alexandergunnarsonOr as some say, “the bytecode is the .js file”#2019-01-1820:19lilactownI'm not sure how CLJ evaluation or AOT works#2019-01-1820:19lilactownunder the hood#2019-01-1820:20alexandergunnarsonFor CLJS compilation my understanding is that it works kind of like you seem to be getting at — it doesn’t actually evaluate the code, but rather analyzes it just enough (macroexpanding in the process) to generate JS code#2019-01-1820:20lilactownright#2019-01-1820:21alexandergunnarsonYeah so I’m suggesting that it would be much easier to enforce the contracts of the type system if the code were actually able to be evaluated, just as CLJ evaluates it#2019-01-1820:21alexandergunnarsonSo yeah Lumo might be what I’m looking for#2019-01-1820:21lilactownhmm#2019-01-1820:22alexandergunnarsonLike (t/defn [x my-arbitrary-predicate] ...) requires that my-arbitrary-predicate will have had to have been evaluated at compile time, not just symbolically analyzed, to truly enforce it#2019-01-1820:22alexandergunnarsonCLJ plays nicely with that; CLJS does not (barring e.g. Lumo)#2019-01-1820:24alexandergunnarsonSo perhaps I’m misunderstanding what bootstrapping actually does; I thought [bootstrapping] = [CLJS in CLJS] = [CLJS compiled (well, transpiled) to JS via a CLJS compiler]#2019-01-1820:26alexandergunnarsonOr is bootstrapping just CLJS compiled as usual by CLJ, but provided with a compiler such that cljs.core/eval works at runtime?#2019-01-1820:27lilactownthe latter#2019-01-1820:27lilactown"self-hosting" is what you're looking for#2019-01-1820:27alexandergunnarsonOhhh so self-hosting ≠ bootstrapping?#2019-01-1820:27lilactownthey are related, but what you want is a self-hosted compiler#2019-01-1820:27alexandergunnarsonYes I do#2019-01-1820:28alexandergunnarsonThanks so much for the clarification haha this explains quite a few things#2019-01-1820:30lilactownsure thing!#2019-01-1912:55gravI have a shadow-cljs server running which I’d like to use for both development and release. Can I do something like
BACKEND=localhost npx shadow-cljs start
# from repl: (shadow.cljs.devtools.api/watch :my-app)
# do some development ... then release:
BACKEND= npx shadow-cljs release my-app
#2019-01-1912:55gravthat is, setting the environment differently for dev and release, given the same server?#2019-01-1912:56gravI know there’s --force-spawn but in my case I have several builds, so reusing the server would be of great benefit#2019-01-1913:42thheller@grav no. that is why I do not recommend using environment variables at all. you can however use the REPL to modify your build config however you want#2019-01-1913:42thheller
(defn my-release []
  (-> (api/get-build-config :your-build)
      (assoc-in [:closure-defines '] "foo.bar")
      (api/release* {})))
#2019-01-1913:42thhellerwith api being shadow.cljs.devtools.api#2019-01-1913:42thhelleryou can run this via shadow-cljs run your.util/my-release#2019-01-1913:43thhelleror (your.util/my-release) from the REPL#2019-01-1913:43thhellerbe careful when using it at the REPL though. this returns the entire build state and will blow up your REPL if it tries to print that since it fairly large#2019-01-1913:45grav@thheller very nice! thank you! 🙂#2019-01-1913:50thheller@grav there is also https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-01-1913:50thhellerso just :release {:closure-defines {your.backend/url "foo.bar"}} will take care of everything#2019-01-1913:55thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2019-01-1914:06gravAh, that also looks interesting. I need to share the values with the rest of my home-made setup, so I’ll probably be using environment variables (`#shadow/env`) at least for the release part. Or I’ll make the rest of my tooling integrate with the shadow-cljs.edn file and let that be the source of truth#2019-01-1914:08thhellerthe most flexible is just using run with a custom release function as you can make any edit you want. environment variables always seem very brittle to me so I don't use them ever#2019-01-1914:08thhelleractually I recommend passing variables such as your at runtime rather than build time#2019-01-1914:09thhellerie. call your.app.init({"backend":"foo.bar"}) from HTML#2019-01-1914:10thhellereasier to adjust and everything uses the same build. no need to recompile to change backend url (good when you have multiple environments)#2019-01-1914:10gravthey certainly are. I have a lot of bash scripts interacting with the aws cli. porting those to cljs would be an option, but the aws apis are often more tedious than the cli.#2019-01-1914:10thhellergenerating platform specific HTML is generally much easier to generate and test
#2019-01-1914:10gravyes, that might be a good option … but i’d need to generate the html then#2019-01-1914:10gravyup#2019-01-1914:11gravwell, a lot of options to evaluate 🙂 in any case, it’s cool how flexible shadow-cljs is!#2019-01-1914:12gravdo you have any good stories about integrating with AWS Lambda? Currently I’m using serverless together with a cljs-plugin that supports Lumo, but it’s pretty slow#2019-01-1914:13gravI’m wondering if the same plugin could support shadow-cljs instead …#2019-01-1914:14thhellerno, not currently. I hope to get the clorurists together funding to better document and enhance support for those#2019-01-1914:15gravOk. I see there’s already a GH issue about supporting Shadow-cljs. https://github.com/nervous-systems/serverless-cljs-plugin/issues/15#2019-01-1914:15thhellerI haven't used AWS at all so can't comment on anything related#2019-01-1914:15thhellerI did a few tests regarding the zeit now platform recently and that was pretty easy#2019-01-1914:15thhellerhttps://github.com/thheller/shadow-cljs/commit/0b7b22855be0f2272e3b8e90fdf4e2f4e2a637f7#2019-01-1914:15thhellerbut AWS is a bit more complicated than that I guess#2019-01-1914:16gravOh that’s pretty interesting. Maybe now could be an option for my use-case. I’ll have to look into that.#2019-01-1914:17thhellerin that example I just do shadow-cljs release now-lambda and cd output-dir; now#2019-01-1914:17gravcool#2019-01-1914:17thhellerstill running here https://demo-now-7n7jyrfcg.now.sh/#2019-01-1914:18thhellerpretty smooth overall. I'm still thinking about creating a custom builder for their platform so that you don't have to compile locally at all#2019-01-1914:18thhellerbut currently that seems like a bit of overkill given how easy it already is#2019-01-1914:20gravSure. I’m building on an AWS Fargate instance currently which just has a copy of my local setup and checks out the source. Pretty generic#2019-01-1914:20gravAnd cheap 🙂#2019-01-1914:21gravBut of course, leaving even that to http://zeit.co would be a lot easier.#2019-01-1914:22thhellerhere is one setup using travis to build and push to zeit from there https://github.com/jntn/haiku/blob/master/.travis.yml#2019-01-1914:27gravcool#2019-01-2001:34hmaurerPlaying with shadow tonight and just found out about the dashboard (to turn builds on/off, etc). It’s awesome; great work @thheller! 🙂#2019-01-2010:54thhellerso much left to do for the UI though 🙂#2019-01-2014:05hmaurerAre there any features you would like to add, over the top of your head?#2019-01-2013:08wombawombaIt seems like shadow-cljs (2.7.16) will only occasionally reload my css code when I modify it. Any idea what could be the cause? How can I debug this?#2019-01-2013:11wombawombaIf I keep saving my file, it eventually reloads, but it typically takes 3-5 saves.#2019-01-2013:17wombawombaFWIW I’m running shadow-cljs watch app on OSX#2019-01-2013:18thheller@wombawomba not sure. nothing in that area of the code was touched for a very long time#2019-01-2013:19thhelleryou can set
:verbose true

 :log {:level :debug}
#2019-01-2013:19wombawombayeah, I had the same issue in 2.3.0 before upgrading#2019-01-2013:19thhellerin the top level shadow-cljs.edn config#2019-01-2013:21wombawomba@thheller I set those options and I seem to get more verbose logging, but nothing is printed on CSS reloads#2019-01-2013:22wombawombamaybe I just have a rogue shadow-cljs process somewhere and this is some kind of race condition?#2019-01-2013:22thhellerpossible although both should be reloading the css then#2019-01-2013:22wombawombanope, that’s not it#2019-01-2013:24thhellerhmm yeah the css reload doesn't log anything#2019-01-2013:24thhelleryou can check the browser console websocket if you get the css reload message#2019-01-2013:24thhellerit does reload fine for me#2019-01-2013:25wombawombaI do get the message in the browser, but only when the reload actually works#2019-01-2013:25wombawombacan I run a checked out version of shadow-cljs somehow, and add my own logging?#2019-01-2013:26wombawombaalso, where in the code does the CSS reloading happen?#2019-01-2013:27thhelleryou can just clone the repo and run lein install#2019-01-2013:28wombawombahmm… how do I run the lein installed code?#2019-01-2013:29thhellerjust start your shadow-cljs normally after install#2019-01-2013:29wombawombaoh okay, neat#2019-01-2013:30thhellerthis is pretty much the only thing related to css update on the server#2019-01-2013:30thhellerhttps://github.com/thheller/shadow-cljs/blob/1361d7af7cc22241b86990392aa260b45ea61711/src/main/shadow/cljs/devtools/server/worker.clj#L369#2019-01-2013:30wombawombaalright#2019-01-2013:30thhellerfs-watch is used for everything file watching related#2019-01-2013:31thhelleryou can add a log here#2019-01-2013:31thhellerhttps://github.com/thheller/shadow-cljs/blob/7e03bc1e53ce48cc537e699d4d561dd328d6b0c5/src/main/shadow/cljs/devtools/server/worker/impl.clj#L826-L844#2019-01-2013:31thhellerthats the code that takes the fs-watch events and forwards them to the websockets#2019-01-2013:32thhellerhttps://github.com/thheller/shadow-cljs/blob/23be4ff6b32efc9ba406cc7e4eeae7c75dfce5d1/src/main/shadow/cljs/devtools/client/browser.cljs#L178-L193#2019-01-2013:32thhellerthats the client update side#2019-01-2013:32wombawombathx#2019-01-2013:50thhellerare you running in a container or otherwise mounted filesystem maybe? maybe the fs-watch just misses the event#2019-01-2013:57wombawombanope, just straight up OS X#2019-01-2013:58wombawombabut I think I’ve solved the problem 🙂#2019-01-2015:19wombawomba@thheller here’s an issue and PR: https://github.com/thheller/shadow-cljs/issues/430 https://github.com/thheller/shadow-cljs/pull/431#2019-01-2016:44thheller@wombawomba which editor do you use? the order of events seems to depend on how the editor saves actual files#2019-01-2016:45wombawombaI used Neovim#2019-01-2016:46wombawombawhat’s weird is that fsnotify always correctly detects the writes as a single file change (see “Additional Details” at the bottom of the issue)#2019-01-2016:47thhellerI suspect that neovim creates a temp file and then moves/renames that file to replace the old one#2019-01-2016:48thhellerI think emacs does that too#2019-01-2016:48thhellereditors are weird that way 😛#2019-01-2016:59wombawombayup, seems like it (depending on config): https://stackoverflow.com/questions/13563627/how-does-vim-save-files#2019-01-2017:56wombawombaSo I just upgraded from shadow-cljs 2.3.0 to 2.7.16, and this seems to have broken the way I use auth0-lock (https://github.com/auth0/lock). My dependency is "auth0-lock": "^11.13.0" and I require it via (:require [auth0-lock :refer [Auth0Lock]]). In shadow-cljs 2.3.0 Auth0Lock is an object, but in 2.7.16 it’s nil. Any idea why?#2019-01-2018:59wombawombaplayed around with different shadow-cljs versions, and it seems like it fails starting with shadow-cljs 2.4.8 (https://github.com/thheller/shadow-cljs/releases/tag/2.4.8)#2019-01-2019:00wombawombafor the versions where it fails, I get the following error in the browser console:#2019-01-2019:00wombawomba
shadow.js.js:82 Uncaught TypeError: Cannot read property 'lib' of undefined
    at auth0.min.js:9
    at auth0.min.js:9
    at createCommonjsModule (auth0.min.js:9)
    at auth0.min.js:9
    at auth0.min.js:9
    at Object.shadow$provide.module$node_modules$auth0_js$dist$auth0_min (auth0.min.js:9)
    at shadow.js.jsRequire (shadow.js.js:79)
    at Object.shadow$provide.module$node_modules$auth0_lock$lib$utils$cdn_utils (cdn_utils.js:8)
    at shadow.js.jsRequire (shadow.js.js:79)
    at Object.shadow$provide.module$node_modules$auth0_lock$lib$i18n (i18n.js:37)
#2019-01-2019:06thheller@wombawomba that is odd. try settings :js-options {:variable-renaming :local} in your build config#2019-01-2019:06thhellerthat was the previous default#2019-01-2019:07thhellerunfortunately it seems that some npm libs only work with one setting while the others only work with the other#2019-01-2019:16wombawomba@thheller yeah that worked#2019-01-2019:16wombawombathanks!#2019-01-2115:40orestisSo in https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run I see: $ shadow-cljs clj-run my.build/release as a thing I could do, but when I do: $ shadow-cljs clj-run dev.build/main --start-server I get:
$ shadow-cljs clj-run dev.build/main --start-server
shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn  cli version: 2.7.16  node: v10.15.0
shadow-cljs - starting via "clojure"

Unknown option: "--start-server"

Usage:
  shadow-cljs <action> <zero or more build ids>

...
#2019-01-2115:41orestisPassing no arguments calls my function just fine…#2019-01-2115:47leocardosoHi, I'm trying to set cljs.core/*target* to "default" but apparently is not working#2019-01-2115:48leocardosoMy config is#2019-01-2116:10thheller@orestis try shadow-cljs clj-run dev.build/main -- --start-server?#2019-01-2116:14thheller@leocardosoti it is "default" by default? what is it for you? :npm-module doesn't set it explicitely at all#2019-01-2212:45leocardosoIt's default rsrs, sorry my fault, I have another problem with webpack#2019-01-2117:06orestisThanks @thheller that does the trick.#2019-01-2117:10orestisIs there a built-in way for shadow to open up a web browser the first time a compilation finishes? Or should I cook something up with build hooks?#2019-01-2117:13thhellerno built-in way no, hooks could certainly do that though#2019-01-2117:31orestisOh if you are taking feature requests for the UI, having a link next to builds which have a built-in http server (or a custom-supplied link for more complex stuff) would be ideal for my use case (a launchpad for our designers)!#2019-01-2117:32orestisI’m trying to make a one-stop-shop command for our designers to use — would it make more sense to use shadow-cljs as a launching pad (have the tools call my code) or flip it around (have my code run the tools)? I’m leaning towards the first, since I can then piggy-back on shadows background server for other things as well.#2019-01-2117:48thheller@orestis that actually already used to be there. just removed it by accident I guess#2019-01-2117:49thhelleras for running background processes as part of shadow-cljs that is also planned#2019-01-2117:49thhellerhttps://github.com/thheller/shadow-cljs/issues/381#2019-01-2117:50thhellerI couldn't decide when to start them though and not sure if its actually worth doing it since other tools can do it already#2019-01-2117:50thhellerhttps://www.npmjs.com/package/npm-run-all#2019-01-2117:50thhellerhttps://www.npmjs.com/package/foreman#2019-01-2117:51orestisYeah it’s not hard to do that. I’m actually now just writing a build.clj file that uses hawk/watch! to reload clojure stuff (for the server) and SCSS and who knows what else 🙂#2019-01-2117:51orestisNot sure if this is the best approach but everything is already there and I can have direct control over what happens so why not do it myself… it’s only glue code.#2019-01-2117:52thhelleryeah in my work project I have an ugly watch.js script using chokidar to run things on file change#2019-01-2117:53thhellerugly but has been working fine for 3 years or so 😉#2019-01-2118:07knubiehaving a bit of trouble :requireing this npm on my project: https://github.com/hexenq/kuroshiro#2019-01-2118:07knubieusing (:require ["kuroshiro" :default Kuroshiro] brings back a nil Kuroshiro#2019-01-2118:08knubieusing (:require ["kuroshiro" :as Kuroshiro]) returns #js {} (empty object)#2019-01-2118:09knubieI’ve been looking at the dist files to try and figure out what’s going on but haven’t been able to come up with anything: https://unpkg.com/kuroshiro@1.1.2/#2019-01-2118:09knubieanyone run into something similar?#2019-01-2118:17thheller@steedman87 any messages in the browser console during load?#2019-01-2118:19knubieno messages that I can tell aside from an error when i try instantiate it#2019-01-2118:19knubiee.g. (Kuroshiro.) ;; => Uncaught TypeError: module$node_modules$kuroshiro$lib$index is not a constructor#2019-01-2118:22thheller@steedman87 it works fine for me?#2019-01-2118:22knubie🤔 that’s weird#2019-01-2118:22knubiei’ve been able to require and use other npm packages in this project#2019-01-2118:23thhellercheck your node_modules/kuroshiro files. maybe something got lost or so?#2019-01-2118:23knubieI’ll try reinstalling#2019-01-2118:24thheller
$ shadow-cljs browser-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn version: 2.7.16
shadow-cljs - connected to server
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (134 files, 35 compiled, 0 warnings, 4.25s)
[6:1]~cljs.user=> (require '["kuroshiro" :as k])
nil
[6:1]~cljs.user=> k
#object[Kuroshiro]
[6:1]~cljs.user=> (k.)
#object[Kuroshiro [object Object]]
[6:1]~cljs.user=>
#2019-01-2118:26knubiereinstalling the module did the trick 😅#2019-01-2118:26knubiethanks for helping troubleshoot @thheller#2019-01-2118:28knubieshadow-cljs is awesome, it blows all of the other tools i’ve used out of the water#2019-01-2118:32knubieoh, that’s interesting. I’m getting the same issue again#2019-01-2118:33thhellercheck whats in your node_modules/kuroshiro directory and if it matches what unpkg shows#2019-01-2118:33thhellersometimes npm does weird stuff when installing nested dependencies and stuff#2019-01-2118:33knubiethanks, I’ll take a look#2019-01-2118:39knubieok I think it was just because I was using :default instead of :as#2019-01-2118:41thhelleryeah :default is kinda of weird since npm packages can't decide how they want to package stuff#2019-01-2118:42thhellerbeen thinking about doing what webpack does to ensure both work the same#2019-01-2118:42thhellerbut kinda don't like that 😞#2019-01-2118:43orestisCan I somehow hook into the shadow hud so I can report errors if say an SCSS compilation fails?#2019-01-2118:43thhellerpeople should write standard code and not have tools work around their issues 😛#2019-01-2118:43knubiethe mix of commonjs and es6 modules is a real pita#2019-01-2118:44thheller@orestis not really. you can send messages to the websocket but the client won't know what to do with them#2019-01-2118:52orestisSeems like it should be straightforward to expose the hud controls from your end — if I could have hud-show/hud-warn/hud-error/hud-hide with even just a single string it would be nice.#2019-01-2118:52orestis(Sorry to ask like this — I’m just having such a great time building this 🙂 )#2019-01-2118:52orestisIf you prefer I submit a PR I could do that.#2019-01-2118:52thhellershowing stuff is not hard#2019-01-2118:52thhellerclearing it at the appropriate time and not have it interfere with other stuff is the hard part#2019-01-2118:55orestisHm, yes. Would it then make sense for shadow to expose just a way to call some fully qualified function with some arguments on demand? So getting the UI right is up to the consumer (could just put a console.log to start with), but it’s the websocket connection that’s tricky to get.#2019-01-2118:56orestisJust to clarify, by on-demand I mean that I could from a clojure REPL, using shadow’s API, to send a message to the websocket, which then shadow would then interpret as just calling any arbitrary function.#2019-01-2118:56orestisOr am I just thinking of a REPL?#2019-01-2118:57thhellerI would be up for letting you send custom messages through the websocket and exposing a subscribe method on the client you can use#2019-01-2118:58thhellercalling functions directly is ok too but a little more tricky#2019-01-2118:58thheller(ensuring code is loaded and stuff)#2019-01-2119:00orestisYeah makes sense. The function to call would already be in some pre-loaded dev-helper namespace on my end, so I wouldn’t have to worry about it being loaded, but I get that getting right in the general sense would not be trivial. I’m not sure how dynamic CLJS can be — i know it has some limitations compared to Clojure.#2019-01-2119:05thhellerwell if I add the custom messages you can use them to call functions 😉#2019-01-2119:06orestisHehe, I can’t think what the API would look like — it’s late 😄#2019-01-2119:06orestisThanks so much again for all this.#2019-01-2119:08thhellerso the CLJ side (api/send-to-client! :the-build-id {:whatever :you :like 1})#2019-01-2119:09thhellerclient side (env/subscribe! the-msg-handler-callback) which would be (fn [msg] ...)#2019-01-2119:09thhellerso you'd add a :preload that does the subscribe#2019-01-2119:09orestisAnd env comes from requiring shadow.cljs.client.something.env ?#2019-01-2119:10thhellerthis one https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/env.cljs#2019-01-2119:10thhellerbut yeah#2019-01-2119:10orestisCool!#2019-01-2119:11orestisI need to get away from the computer. Apologies for keeping asking questions at this time of night…#2019-01-2119:11orestisThanks again!#2019-01-2119:44thheller@orestis in 2.7.17 I added (shadow.cljs.devtools.api/send-to-runtimes! build-state-or-id some-msg) for the CLJ part which you can call from a hook or the REPL or any other code#2019-01-2119:45thhellerit will send the message (any EDN value) to all connected runtimes (browsers)#2019-01-2119:45thhelleron the client you can sub via (shadow.cljs.devtools.client.env/subscribe! ::some-id (fn [msg] ...))#2019-01-2119:46thhellerneeds ::some-id so that when code that calls subscribe! gets reloaded it overwrites the old instead of adding a second one#2019-01-2119:47thhelleryou can experiment with calling functions from https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/hud.cljs but the chances are high that will somehow interfere with regular operations#2019-01-2119:48thhellerso probably would want to add some to show messages and stuff yourself#2019-01-2119:48orestisOh wow. #2019-01-2119:48orestisThanks for this! I’ll play around tomorrow. #2019-01-2119:54thhellerhave fun. let me know what you come up with 🙂#2019-01-2211:42thheller@orestis there is something in the shadow-cljs devtools you might be interested in also. I never finished it but it is capable of compiling code on demand. if you have a running watch for a browser build try this in the browser console#2019-01-2211:42thhellershadow.cljs.devtools.client.browser.compile("(prn :foo)", function(result) { console.log(result); })#2019-01-2211:43thhellerbasically the compile function lets you request a compile on the server and you'll get the raw compilation results#2019-01-2211:43thhellerI could finish that to return the actual eval result instead#2019-01-2211:44thhellersaw you asking about self-hosted stuff and that is pretty close without any of the self-hosted parts#2019-01-2211:44thhellerlimited to dev builds with a running watch of course but I was planning to use it to embed a REPL into the page directly and stuff#2019-01-2211:45thhellerbut you can also do full self-host stuff if you want https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-01-2212:23orestisI want to be able to show a textarea that people can type hiccup, and render it as it happens. Amazingly, you can go some way towards that using just cljs.reader/read and get some EDN back, that reagent will happily try to render — but in this case symbols get turned into strings, while I want to look them up in my actual build.#2019-01-2212:28thhelleryeah you could do that with the compile function in theory#2019-01-2212:31orestisDoes it return something now?#2019-01-2212:31thhelleryes. raw compilation results.#2019-01-2212:32thhellerits not exactly user friendly right now but you do get a :js field#2019-01-2212:32thhellereg. :js "cljs.core.prn.call(null,new cljs.core.Keyword(null,"foo","foo",1268894036))"#2019-01-2212:33thhellerwhich you could eval#2019-01-2212:34thheller(js/goog.globalEval (:js ...))#2019-01-2212:41orestisThis kinda works — but I don’t get anything back from globalEval, do I?#2019-01-2212:42thhelleryou do get back whatever you eval'd#2019-01-2212:42orestisI seem to get back undefined — but side effects like print work.#2019-01-2212:42thhellerprn returns nil#2019-01-2212:43thhellertry to compile("(fn [x] (+ 1 x))", ...)#2019-01-2212:43orestisI’m trying
(shadow.browser/compile "(inc 1)"
                        (fn [result]
                          (let [src (get-in result [:actions 0 :js])
                                res (js/goog.globalEval src)]
                            (js/console.log src "=" res))
                          ))
#2019-01-2212:43thhellerthat should return something?#2019-01-2212:43orestisAnd I see printed: ((1) + (1)) – "=" – undefined — I would expect to see a 2 somewhere.#2019-01-2212:44thhellerhmm odd#2019-01-2212:44orestisIf I surround the (inc 1) with a prn, I do see 2 printed, so I think it’s something to do with JS not having expressions?#2019-01-2212:45thhellerah right#2019-01-2212:45thhellertry to compile (fn [] (inc 1)) that should give you back a function you can call to get the actual result#2019-01-2212:46orestisHm, that errors with: SyntaxError: Unexpected token '.'. Expected an opening '(' before a function's parameter list.#2019-01-2212:46orestisThe generated JS is:
(function cljs$user$cljs.user.cljs(){
return ((1) + (1));
})
#2019-01-2212:47thhellerah right its not compiled in the correct repl context#2019-01-2212:47thhellerok I'll fix that later#2019-01-2212:48thhellerthe compile is a bit too low level I guess 🙂#2019-01-2212:48orestisCool stuff though! This would fit my use case very nicely. I hope to be able to demonstrate/document that somewhere when it’s finished.#2019-01-2212:57orestisI’m confused with how to update shadow-cljs — I do npm upgrade -g shadow-cljs and I did see
$ npm update -g shadow-cljs
/Users/orestis/.nvm/versions/node/v10.15.0/bin/shadow-cljs -> /Users/orestis/.nvm/versions/node/v10.15.0/lib/node_modules/shadow-cljs/cli/runner.js
+ 
— but when invoking shadow-cljs again I still see 2.7.16…
#2019-01-2213:06leocardosoanyone already have this problem Error: clojure is not defined using :target :npm-module ? I'm using webpack too#2019-01-2213:36thheller@orestis the global install is not relevant if you have (which you should) a version local in your project#2019-01-2213:36thhellerso npm install shadow-cljs in your project should update it there (without the -g)#2019-01-2213:36orestisAh, so the global install is just a nicety?#2019-01-2213:36thheller@leocardosoti which version are you on?#2019-01-2213:37thheller@orestis yes, pretty much only for CLI convenience but otherwise unnecessary. it will always use the version installed in your project#2019-01-2213:40leocardoso@thheller latest#2019-01-2213:41thhellerit is most likely related to something using clojure.string (or similar clojure.*) directly without a require for it#2019-01-2213:41thhellerbut the latest version should have relaxed that requirement as long as it was required somewhere#2019-01-2213:42leocardosoyeap, this is an example: https://github.com/Day8/re-frame/blob/v0.9.4/src/re_frame/interceptor.cljc#L19#2019-01-2213:42thhelleryeah like that exactly#2019-01-2213:43leocardosobut okay i'll try to update everything#2019-01-2213:43thhellerensure that you have the latest version and restarted the server process after updating (eg. the watch)#2019-01-2213:45leocardosookay, thanks!#2019-01-2213:45thhelleras long as clojure.set is required somewhere before the re-frame stuff is loaded it should work#2019-01-2214:32thheller@orestis FWIW it work if you use (js/goog.global.eval the-code). guess globalEval doesn't like return values#2019-01-2318:31jstaabIs there a way to get a socket repl for my cljs build that I can use remotely (I'm trying to make a plugin for kakoune)? I can netcat to the socket repl and start a shadow repl, but it appears to back me out to the top-level repl when I run further commands:
➜  core git:(cljs) ✗ echo "(shadow/repl :test)" | nc localhost 58218
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[10:0]~shadow.user=> [10:1]~cljs.user=> nil
[10:0]~shadow.user=> %                                                                                                
➜  core git:(cljs) ✗ echo "(prn :x)" | nc localhost 58218
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[11:0]~shadow.user=> :x
nil
[11:0]~shadow.user=> % 
#2019-01-2318:58souenzzocan shadow-cljs accept output-dir from CLI? something like clj -A:shadow-cljs -m shadow.cljs.devtools.cli release prod --output-dir "resource/public" ?#2019-01-2321:02thheller@jstaab if you nc an echo it will end with closing stdin which means closing the REPL#2019-01-2321:04thhellerif you open a regular socket and keep sending normally it will keep you in the REPL#2019-01-2321:06thheller@souenzzo that is not supported by default. you can either use :release specific config or use clj-run though#2019-01-2321:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-01-2321:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-01-2321:07thheller
(defn release [path]
  (-> (shadow/get-build-config :your-build-id)
      (assoc :output-dir path)
      (shadow/release* {})))
#2019-01-2321:07thhellershadow-cljs run your.util/release resource/public#2019-01-2321:08thheller@jstaab I plan on adding support for prepl this weekend, probably better suited if you want to build tools on top of it#2019-01-2322:39jstaab@thheller awesome, thanks for the tip! Also, from what I've seen of prepl, it looks way nicer to code against. Thanks for your hard work!#2019-01-2411:00r0manHello, I'm using the material-components-web-react package with shadow-cljs. I use the material components in the browser, but also on Node.JS for server side rendering. This used to work fine, but now that I'm trying to update the material-components-web-react package I see the following error in Node.JS:#2019-01-2411:00r0man#2019-01-2411:01thhellertry node require("@material/textfield/constants.js")#2019-01-2411:01r0manThe code works fine in the browser. but only fails on Node. I guess this has something to do with the Javascript module system not being compatible. Any ideas how to solve this?#2019-01-2411:03r0man#2019-01-2411:03r0manso, this looks like a problem with the package?#2019-01-2411:04thhellerthere is a flag in node to enable support for ES6 modules#2019-01-2411:04thhellerforgot what it was though#2019-01-2411:05thhellerbut yeah for the browser stuff is rewritten#2019-01-2411:05thhellerfor node it just uses node which doesn't yet unterstand impot/export without flags#2019-01-2411:05thhellerhttps://nodejs.org/api/esm.html#2019-01-2411:05thhellernot sure how well this works though#2019-01-2411:06r0manDoesn't seem to work either#2019-01-2411:07thhellerah right it is strict and would require .mjs extension#2019-01-2411:07thhellermaybe this works https://www.npmjs.com/package/esm#2019-01-2411:10r0man@thheller Cool, that did the trick! Thank you! 🙂#2019-01-2412:58thheller@neo2551 shadow-cljs by default does not support dependencies per build. you currently can only emulate that when using project.clj or deps.edn#2019-01-2413:33r0manIs there a way to set :closure-defines from the command line? I would like to pass the current git commit into the build.#2019-01-2413:34thheller@r0man see the answer I gave @souenzzo yesterday about clj-run#2019-01-2413:34thheller
(defn release [path]
  (-> (shadow/get-build-config :your-build-id)
      (assoc :output-dir path)
      (shadow/release* {})))
#2019-01-2413:35thhellerjust switch to (assoc-in [:clojure-defines 'your.ns/git-commit] the-commit)#2019-01-2413:36r0manperfect, I didn't see that. thanks again!#2019-01-2413:38Jan KDoes anyone know a public project that uses the rum library and builds with shadow-cljs? Rum has some cljsjs dependencies on react stuff and I'm not sure how to replace them to make it work, an example would be great.#2019-01-2413:38thheller@jkr.sw shadow-cljs should be taking care of that already. what is the problem?#2019-01-2413:39David Pham@thheller Thanks a lot for your answer#2019-01-2413:41Jan KThe JS generated by shadow-cljs doesn't seem to contain react. I don't get any errors in console, but my components aren't rendering. The JS file is about 130 Kb smaller than what falls out of lein-cljsbuild, and build report isn't showing any react/rum code.#2019-01-2413:42thhellerdo you have any manual cljsjs/* files in your project?#2019-01-2413:42Jan KNo#2019-01-2413:43thhellerhow are you using it?#2019-01-2413:44Jan KAt this point I just have rum in my shadow-cljs.edn dependencies (and use rum in my CLJS code).#2019-01-2413:44thhellerrum mostly generates code via macro which means the code is in your namespaces not rum namespaces#2019-01-2413:45thhellerthat should be all you need#2019-01-2413:46Jan KWhy is my build report missing react though? I've seen it in the examples#2019-01-2413:46thhellernot sure. it should definitely be there#2019-01-2413:47thhellerplease run shadow-cljs clj-repl and ( "cljsjs/react.cljs")#2019-01-2413:48Jan Kthat seems to work: #object[java.net.URL 0x55589ef5 "jar:file:/home/jan/.m2/repository/thheller/shadow-cljsjs/0.0.16/shadow-cljsjs-0.0.16.jar!/cljsjs/react.cljs"]#2019-01-2413:48thhellerok that is fine#2019-01-2413:48thhellerwhich build :target do you use? any custom :js-options?#2019-01-2413:49Jan K
{:mybuild
  {:target :browser
   :modules {:main {:init-fn my-ui.common/on-js-reload}}}}}
#2019-01-2413:50thhellerok that should be fine#2019-01-2413:50thhellerno errors in the browser console?#2019-01-2413:51Jan Knone#2019-01-2413:52thhellerand what are you doing in the :init-fn?#2019-01-2413:52Jan Kjust a println, I can see that in the console#2019-01-2413:52thhellerno render?#2019-01-2413:55Jan KNo, I mount my rum component in another place at top level of the main cljs file. That's probably the issue, I think I don't have any main cljs file set anywhere in the shadow-cljs build#2019-01-2413:55thhellerah ok. shadow-cljs just isn't including what you want then#2019-01-2413:56thheller
{:mybuild
 {:target :browser
  :modules {:main {:entries [your.actual.main-ns]}}
  :devtools
  {:after-load my-ui.common/on-js-reload}}}
#2019-01-2413:56thhelleryour probably want something like that#2019-01-2413:57thhellershadow-cljs only includes whatever is actually required from your config#2019-01-2413:57thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2019-01-2413:57thhellerso you were probably relying on the fact that cljsbuild just includes everything it finds#2019-01-2414:01Jan KYes I was missing the :entries bit (in lein-cljsbuild I have that as :main). It's working now! Thank you very much!#2019-01-2414:05thhellercould just use :init-fn to call what you are now calling at the top level instead of calling it#2019-01-2414:05thhellerthat ensures that its only called once even if you live-reload that file#2019-01-2414:08hoopesSo here's probably a dumb idea. Everytime I run my app, I get warnings from library code. For example:
[:app] Build completed. (1038 files, 8 compiled, 4 warnings, 11.03s)

------ WARNING #1 --------------------------------------------------------------
 File: zprint/focus.cljc:100:47
--------------------------------------------------------------------------------
  97 |         #_(println "range-ssv: start:" start "nwpath:" nwpath)
  98 |         start (skip-whitespace-ssv ssv start)
  99 |         ssv-next (next-ssv ssv start)
 100 |         end (if (and ssv-next (not= start 0)) (dec ssv-next) (dec (count ssv)))]
-----------------------------------------------------^--------------------------
 cljs.core/-, all arguments must be numbers, got [#{nil clj-nil} number] instead
--------------------------------------------------------------------------------
 101 |     #_(println "range-ssv:" [start end])
 102 |     [start end]))
--------------------------------------------------------------------------------

------ WARNING #2 --------------------------------------------------------------
 File: com/rpl/specter/impl.cljc:786:6
--------------------------------------------------------------------------------
 783 |          val))
 784 | 
 785 |      (mk-late-fn-records)
 786 |      (mk-late-fn)))
------------^-------------------------------------------------------------------
 Use of undeclared Var com.rpl.specter.impl/java
--------------------------------------------------------------------------------
 787 | 
 788 | #?(:clj
 789 |    (defn static-fn-code [afn args]
 790 |      `(~afn 
There's not much I can do about them except to open an issue on the repo or try to fix them myself. I was wondering if it made sense for some sort of option in shadow-cljs.edn for :ignore-warnings-from-namespaces or :only-show-warnings-from-this-ns-list, so I could more easily see warnings/errors from code I actually control. If there already is something like this that I'm not aware of, my apologies for the large message. Thanks for listening!
#2019-01-2414:28Jan KThese build reports are really a great feature. I wouldn't have guessed that just requiring cljs.pprint yields almost +100 Kb after optimizations#2019-01-2415:17orestisIt seems like you can’t have both an :http-handler fn, and a :proxy-url, right? Because the proxy will take over.#2019-01-2415:18orestisSo if I want to do something fancy, I need drop the proxy-url and do the proxy on my own.#2019-01-2415:26orestisIs there some reliable way at runtime (that is, no macros) to get the filename of the file where a function was defined? OK to only work in dev mode.#2019-01-2416:19thheller@hoopes I agree that its unfortunate. I opened issues on the libs I know about and most of them are fixed already. https://github.com/nathanmarz/specter/issues/267#2019-01-2416:19thhellernot sure if there was an actual specter release though.#2019-01-2416:20thhellerdon't know how I feel about ignoring warnings#2019-01-2416:20hoopesyeah, i know it would be a gross hack#2019-01-2416:20hoopesbut it would make it a lot easier to see what i screwed up 🙂#2019-01-2416:20thhellerwould it be enough to make warnings in code from libs just "shorter" so they don't show a source excerpt?#2019-01-2416:20thheller(since you can't do anything about them anyways)#2019-01-2416:21hoopesor even a different color, or whatever - maybe the non-lib errors are brighter, something that i can tell at a glance that it's actually my code, and not something i can (somewhat) safely ignore#2019-01-2416:22thheller@jkr.sw yeah currently cljs.pprint can't be optimized by Closure at all so it gets really huge. https://dev.clojure.org/jira/browse/CLJS-2885#2019-01-2416:23thheller@orestis no that info would only be available via macros#2019-01-2416:25thhellerproxy stuff is currently not as flexible as I'd like so yeah it current is one or the other not both#2019-01-2416:25thhellerif you need more advanced server setups you should be using your own anyways#2019-01-2416:26thhellerthe server doesn't need to do anything special for shadow-cljs. just serve the files, nothing else.#2019-01-2416:27thheller@hoopes I'll start by re-ordering the warnings I guess. So warnings from local code come before library code#2019-01-2416:27thhellerright now they are in dependency order which isn't useful for that#2019-01-2416:28hoopesthis is just my personal preference, so feel free to ignore, but the easiest ones to see are at the bottom (especially when you get the warnings over and over), so i'd prefer "mine" at the end#2019-01-2416:29thhellerhmm true#2019-01-2416:29hoopesbut saying i'd prefer to the BDFL of shadow-cljs is a little presumptuous, so do what you think is best 🙂#2019-01-2416:31thhellerits tricky. don't want to print too much but also not too little 😛
#2019-01-2416:33thhellerif only there was a way to not do all this in the terminal and have a richer interface for warnings 😉#2019-01-2416:33hoopeslike some sort of page, on a web of some kind#2019-01-2416:35thhellerlike http://localhost:9630/builds/app but better 😉#2019-01-2418:15souenzzoAfter move to lein-tools-deps broke my shadow-cljs build. "release" build still works But when I use (shadow/watch :main) from repl:
[:main] Build failure:
The required namespace "goog" is not available, it was required by "cljs/user.cljs".
I still use :lein {:profile "+dev,+client,+webdev"} (slurp (io/resource "cljs/user.cljs")) ;; => (ns cljs.user)\n (it's a empty namespace, I used it long time ago, now it's empty)
#2019-01-2418:18thhellercheck (io/resource "goog/base.js") look like the closure lib may be missing?#2019-01-2418:19souenzzoPoints to
#object[java.net.URL
        0xb705e1b
        "jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
When i slurp it, it shows a lot of js
#2019-01-2418:27thhellerhmm that looks fine#2019-01-2418:28thhellernot sure whats happening then#2019-01-2418:29thhellerwhere is cljs/user.cljs from though? shadow-cljs doesn't ship with one?#2019-01-2418:34souenzzomy dev/cljs/user.cljs that is in my classpath#2019-01-2418:37souenzzoThe required namespace "goog" is not available, it was required by "cljs/user.cljs". now with (io/resource "cljs/user.cljs") ;;=> nil#2019-01-2418:49souenzzosame after rm -rf .shadow .cljs ...anything-that-i-can-rm I also moved from graalvm into JVM11#2019-01-2418:49thhellerI use Java11 so thats fine#2019-01-2418:52thhellercheck if there are maybe multiple version on the classpath?#2019-01-2418:52thheller
(-> (Thread/currentThread)
    (.getContextClassLoader)
    (.getResources "goog/base.js")
    (enumeration-seq))
#2019-01-2418:53souenzzojust one "jar:file:/home/souenzzo/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"#2019-01-2418:53thhelleryou did test the resource using the actual shadow-cljs REPL with all the aliases activated right?#2019-01-2418:53thhellerwhat is (io/resource "shadow/build.clj")?#2019-01-2418:54souenzzo"jar:file:/home/souenzzo/.m2/repository/thheller/shadow-cljs/2.7.16/shadow-cljs-2.7.16.jar!/shadow/build.clj"#2019-01-2418:54thhellerhmm whats all correct#2019-01-2418:54thhellerI have no idea what is up#2019-01-2418:55thhelleryou did delete .shadow-cljs and restarted shadow-cljs after doing that I assume?#2019-01-2809:50souenzzoAfter put some jar's on maven Move back to lein without lein-tools-deps. I hope that on the next lein-tools-deps try it not occur#2019-01-2420:07denikquick question: is there a command to watch a build in advanced compilation?#2019-01-2420:08thhellerno. that must be triggered manually since they generally take too long for watch#2019-01-2420:09denikgot it. loading a js library into the client at runtime. trying to call it errors out, likely due to advanced compilation#2019-01-2420:09denikwondering what the best approach to debug this is#2019-01-2420:10thhellershadow-cljs release your-build --pseudo-names#2019-01-2420:10thhelleror shadow-cljs check your-build#2019-01-2420:10thhellercheck isn't totally reliable but sometimes can help spot externs issues#2019-01-2420:10thhellerand always set :compiler-options {:infer-externs :auto}#2019-01-2420:12denikwhat’s the difference between true/auto for infer-externs?#2019-01-2420:13thheller:auto enables it for all your sources#2019-01-2420:13thhellertrue requires you to (set! *warn-on-infer* true) for every source you want to enable it for#2019-01-2420:20joelsanchezI seem to get this when using checkouts#2019-01-2420:20joelsanchezZipException too many length or distance symbols java.util.zip.InflaterInputStream.read (InflaterInputStream.java:164)#2019-01-2420:21joelsanchezrelevant trace:
[java.util.zip.InflaterInputStream read "InflaterInputStream.java" 164]
               [java.io.FilterInputStream read "FilterInputStream.java" 133]
               [java.io.BufferedInputStream read1 "BufferedInputStream.java" 284]
               [java.io.BufferedInputStream read "BufferedInputStream.java" 345]
               [sun.nio.cs.StreamDecoder readBytes "StreamDecoder.java" 284]
               [sun.nio.cs.StreamDecoder implRead "StreamDecoder.java" 326]
               [sun.nio.cs.StreamDecoder read "StreamDecoder.java" 178]
               [java.io.InputStreamReader read "InputStreamReader.java" 184]
               [java.io.BufferedReader fill "BufferedReader.java" 161]
               [java.io.BufferedReader read1 "BufferedReader.java" 212]
               [java.io.BufferedReader read "BufferedReader.java" 286]
               [java.io.Reader read "Reader.java" 140]
               [$fn__11010 invokeStatic "io.clj" 337]
               [$fn__11010 invoke "io.clj" 334]
               [clojure.lang.MultiFn invoke "MultiFn.java" 238]
               [$copy invokeStatic "io.clj" 406]
               [$copy doInvoke "io.clj" 391]
               [clojure.lang.RestFn invoke "RestFn.java" 425]
               [clojure.core$slurp invokeStatic "core.clj" 6871]
               [clojure.core$slurp doInvoke "core.clj" 6862]
               [clojure.lang.RestFn invoke "RestFn.java" 410]
               [shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath$fn__25207 invoke "npm_deps.clj" 164]
               [clojure.core$map$fn__5587 invoke "core.clj" 2747]
               [clojure.lang.LazySeq sval "LazySeq.java" 40]
               [clojure.lang.LazySeq seq "LazySeq.java" 49]
               [clojure.lang.Cons next "Cons.java" 39]
               [clojure.lang.RT next "RT.java" 706]
               [clojure.core$next__5108 invokeStatic "core.clj" 64]
               [clojure.core.protocols$fn__7852 invokeStatic "protocols.clj" 169]
               [clojure.core.protocols$fn__7852 invoke "protocols.clj" 124]
               [clojure.core.protocols$fn__7807$G__7802__7816 invoke "protocols.clj" 19]
               [clojure.core.protocols$seq_reduce invokeStatic "protocols.clj" 31]
               [clojure.core.protocols$fn__7835 invokeStatic "protocols.clj" 75]
               [clojure.core.protocols$fn__7835 invoke "protocols.clj" 75]
               [clojure.core.protocols$fn__7781$G__7776__7794 invoke "protocols.clj" 13]
               [clojure.core$reduce invokeStatic "core.clj" 6748]
               [clojure.core$into invokeStatic "core.clj" 6815]
               [clojure.core$into invoke "core.clj" 6807]
               [shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invokeStatic "npm_deps.clj" 168]
               [shadow.cljs.devtools.server.npm_deps$get_deps_from_classpath invoke "npm_deps.clj" 157]
               [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 204]
               [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 199]
#2019-01-2420:22joelsanchezim running shadow-cljs as a library, i.e. executing (shadow-cljs.npm-deps/main {} nil) from my program#2019-01-2420:23thhellerweird. maybe a broken .jar file on the classpath?#2019-01-2420:23thhellerI had this before on linux where is somehow put an empty .jar file on the classpath#2019-01-2420:24thhellerthe classpath scanner filters those but npm-deps doesn't I guess#2019-01-2420:28thheller@joelsanchez try this in the REPL#2019-01-2420:28thheller
(doseq [url (-> (Thread/currentThread)
                (.getContextClassLoader)
                (.getResources "deps.cljs")
                (enumeration-seq))]
  (try
    (slurp url)
    (catch Exception e
      (prn [:failed url e]))))
#2019-01-2420:28joelsanchez#2019-01-2420:29joelsanchezseems it happens because I use checkouts though#2019-01-2420:29joelsanchezleiningen doing weird stuff#2019-01-2420:29thhellercheck jar -tvf /home/joel/.m2/repository/ventas-core/ventas-core/0.0.12-SNAPSHOT/ventas-core-0.0.12-SNAPSHOT.jar#2019-01-2420:29thhellerthe jar file just seems broken#2019-01-2420:31joelsanchez#2019-01-2420:31joelsanchezwelp my jar is a bit full of crap but it didnt fail#2019-01-2420:32joelsanchezguess if I remove that js stuff from the jar, which shouldn't be included anyway, it will work#2019-01-2420:33thhellerthats odd that it doesn't complain though#2019-01-2420:33thhellerbut yeah that pretty clearly demonstrates why resources/public is a bad idea as a default 😉#2019-01-2420:34joelsanchez😅 thx#2019-01-2420:34thheller> "too many length or distance symbols"#2019-01-2420:34joelsanchezyes, seems a polite way of saying "your jar's full of crap"#2019-01-2420:34thhellerguess maybe it really is just too many files 😛#2019-01-2420:53joelsanchezI removed all of that from the jar, executed lein install, jar -tvf now shows much less files, but I get a different error now#2019-01-2420:53joelsanchezgo figure#2019-01-2420:54joelsanchezI swear this didnt happen before checkouts#2019-01-2420:54joelsanchezbut dont worry, it's not critical#2019-01-2421:05thhellerno idea. never had issues with checkouts and been using them in my work project for years#2019-01-2421:06thhellerespecially since it doesn't have an issue reading the checkout#2019-01-2421:06thhellerthat should be a path not jar#2019-01-2422:42Bravihello everyone. has anyone used shadow-cljs with om-next?#2019-01-2422:42BraviI’m getting the following warning
ident? already refers to: cljs.core/ident? being replaced by: om.util/ident?
#2019-01-2422:50thhellerso?#2019-01-2422:51thhellerom-next is pretty much dead AFAICT use fulcro#2019-01-2422:53thhellercljs.core/ident? was added not too long ago. so om.next would need to exclude it to get rid of the warning#2019-01-2423:17Bravithanks @thheller, I wasn’t aware of that..#2019-01-2423:18BraviI’ve been with re-frame for a long time, but I wanted to add SSR to my website, so basically to have an isomorphic app#2019-01-2423:18Bravibut it seems to be a pain with re-frame and I was trying to find alternative#2019-01-2423:18thheller#fulcro 🙂#2019-01-2423:19Bravi:+1: I’ll have a look into it now 🙂#2019-01-2508:19orestisTrying to integrate graphiql into a CLJS page. I get this log message on the shadow-cljs build:
[2019-01-25 09:09:15.405 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/graphql-language-service-interface/dist/GraphQLLanguageService.js", :requires [{:line 149, :column 30}]}
— the graphiql thing appears correctly but it’s broken in weird ways. Might the above log message have anything to do with it?
#2019-01-2508:28orestisProbably not, here’s the code in question:
customRules = void 0;
            customRulesModulePath = projectConfig.extensions.customValidationRules;

            if (customRulesModulePath) {
              /* eslint-disable no-implicit-coercion */
              rulesPath = require.resolve('' + customRulesModulePath);

              if (rulesPath) {
                customRules = require('' + rulesPath)(this._graphQLConfig);
              }
              /* eslint-enable no-implicit-coercion */
            }
#2019-01-2508:28orestisHopefully there shouldn’t be any of those customValidationRules#2019-01-2508:54orestisHah, stupid codemirror. Needs to have the CSS mounted and parsed before it can do its thing. Got it working 🙂#2019-01-2509:23thhelleryeah don't worry about the warning. it just has a dynamic require which is not currently supported#2019-01-2511:29orestisOMG javascript is annoying. I want to use the rangy npm module, which exposes just a single “rangy” global object - but! if you require some other file present in the node_modules lib folder, it mutates the global rangy object. Is there any way to do this with shadow-cljs? I’ve tried copying the rangy-textrange.js file in my classpath, but I can’t figure out a way to require it from CLJS. Shadow complains it can’t be found.#2019-01-2511:30thhellernot sure I understand. JS libs do this often#2019-01-2511:30thhellerare you sure you want to use a lib that hasn't been updated in 4 years? thats not a good sign is JS land 😉#2019-01-2511:31orestisI want to use paren-soup to show a nice cljs editor in a browser, and it depends (via cljsjs) on that.#2019-01-2511:31orestisThere’s an updated fork I should look at though.#2019-01-2511:32thhellerbut what exactly is the problem? the lib looks pretty straightforward?#2019-01-2511:33orestisThe npm package.json says that main is rangy-core.js. Which is what I get when I do :require ["rangy" :as rangy] in shadow.#2019-01-2511:33orestisBut, I also need to somehow require rangy-textrange.js, which adds a few methods to the global rangy object.#2019-01-2511:33thhellerso do it?#2019-01-2511:33orestisHow? 🙂#2019-01-2511:34thheller
["rangy" :as rangy]
    ["rangy/lib/rangy-textrange"]
#2019-01-2511:35orestisdoh#2019-01-2511:35orestisI didn’t realize you could do that, because I mistyped it first and got the message about installing the npm package 🙂#2019-01-2511:36thhellercan also just do ["rangy/lib/rangy-textrange" :as rangy]#2019-01-2511:36thhellerpretty much the same as including both#2019-01-2511:36orestisOk, hurdle overcame. Still paren-soup doesn’t work as I’d expect it to 😞#2019-01-2511:36orestisThanks!#2019-01-2511:37thhellerdo you have the cljsjs shims setup correctly? https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-01-2511:41orestisYep. I’m getting it loaded just fine, it’s just that it’s not doing what it’s supposed to do.#2019-01-2511:41orestisIt does some things, so it’s loading right.#2019-01-2511:41thhellerah ok. no idea what its supposed to be doing 😉#2019-01-2511:42orestisI think I’ll go for CodeMirror if I want some nicely formatted snippets there.#2019-01-2511:42thhellercodemirror + parinfer works well#2019-01-2511:46orestisCool, there’s a plugin for it. I’ll play around with that.#2019-01-2511:47thhellerI use it here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/pages/repl.cljs#2019-01-2511:48thhelleryou can see it in action at http://localhost:9630/repl if you have shadow-cljs server running#2019-01-2511:48thheller(click connect on the :clj line thing)#2019-01-2515:27orestisI’m already doing a bunch of work in a custom build namespace — starting my API server in the background, watching the filesystem and compiling SCSS etc, and now I want to be able to send some commands from the hosted cljs build to the shadow/clojure server running the watch. At what point does it make sense for me to use shadow-cljs as a library, instead of launching it via the command line?#2019-01-2516:02orestisWhaaaat, there’s already an hud/open-file function I can use? I was about to go down that path on my own 🙂#2019-01-2516:26thheller@orestis yes. see https://shadow-cljs.github.io/docs/UsersGuide.html#hud#2019-01-2516:39orestisIt’s the gift that keeps on giving!#2019-01-2516:44thhelleras far as other commands are concerned: I think at that point it makes sense opening your own websocket connection to a custom server#2019-01-2516:45orestisYeah, I’ll cross that bridge if I need to. I like to keep in shadow land if I can, then my backend server won’t need to worry about this (since it’s a dev-only concern) and I don’t want to bring yet another web server into the mix.#2019-01-2519:34richiardiandreareading all this prepl business I am worried about the fact that prepl will receive way less love than nrepl (check the activity boom in the last months)...so...would nrepl still be supported for the time being by shadow?#2019-01-2519:35thhellernrepl isn't going anywhere#2019-01-2519:35thhellerto be honest prepl doesn't seem to solve any of the issues tools have today#2019-01-2519:35richiardiandreacool thanks, I am relieved 😄#2019-01-2519:35richiardiandreayeah that's what I think as well#2019-01-2519:36thhellerbut it is better than normal socket repl#2019-01-2519:36thhellerjust another option really. nothing regarding nrepl will change#2019-01-2519:36richiardiandreaagree, at least is not character-based 😄#2019-01-2519:36richiardiandreathank you Thomas for confirming#2019-01-2521:15David PhamIs it possible that the cider/shadow-cljs combo does not handle well pprint?#2019-01-2521:15David PhamI am using cider 0.20 and I can’t get my repl to get pprint :/#2019-01-2605:28richiardiandreaHave the same problem#2019-01-2609:49David PhamThanks! I wondered if I was alone#2019-01-2522:12lilactown@neo2551 you can print, but not pprint?#2019-01-2607:34currentoorHas anyone used jsPDF with shadow? doing this causes 14 identical errors in the JS console#2019-01-2607:34currentoor
(ns foo.bar 
  (:require ["jspdf" :as jspdf]))

(jspdf.)
#2019-01-2607:34currentoorjspdf.min.js:formatted:1787 jsPDF PubSub Error t.existsFileInVFS is not a function TypeError: t.existsFileInVFS is not a function#2019-01-2607:35currentoorbut if i load jsPDF from a CDN, then it works fine via (js/jsPDF.)#2019-01-2607:36currentoorand the weird thing is, if i have the lib loaded from a CDN, then the shadow require version works without error also#2019-01-2607:36currentoorcould that mean shadow/npm is not pickup a transitive dependency, but it is loaded when i use the CDN?#2019-01-2609:49David Pham@lilactown exactly. I can use the repl normally, but can’t pprint#2019-01-2610:54thheller@currentoor jsPDF looks like a terrible package. is leaks a bunch of stuff into the global scope#2019-01-2611:01thhellernot sure what webpack is doing differently#2019-01-2611:07thhellerI suspect that jsPDF relies on those leaked globals in some way but closure decides to rename them at some point#2019-01-2611:07thhellerwhich would explain why the CDN + require'd version work together since the CDN version creates those globals#2019-01-2619:07currentoorhmm looks like it’s the leading PDF builder in JS, is there anything that can be done? (i guess using the CDN is the backup)#2019-01-2619:17thhellerI can't figure out what closure is doing that messes things up#2019-01-2619:17thhellerif I just take the source directly it loads normally#2019-01-2619:18thhellerso it must be something that closure does but I can't figure it out#2019-01-2619:20thhellerI'm think about ways to do this https://github.com/thheller/shadow-cljs/issues/173#2019-01-2619:20thhellersince this is a case of .min.js it would fix the issue 😉#2019-01-2619:21thhellerbut the package doesn't follow any established JS packaging standards and just does something random it seems#2019-01-2619:25currentooroh wow thanks for doing all this#2019-01-2619:26currentooryou always go above and beyond, thank you so much!#2019-01-2619:26thhellercan't let a random npm package defeat me 😉#2019-01-2619:26currentoorhah#2019-01-2619:27currentoorthe other option is pdfkit, but that was having browserify issues#2019-01-2619:27currentoorit looks like it requires browserify to work#2019-01-2619:27currentoori do have the option of requiring either library in a script tag, so i might just do that#2019-01-2619:28currentoori didn’t know packages could be tied to browserify like that#2019-01-2619:29currentoorseems like a weird thing to be tied down to#2019-01-2619:29thhellernah the docs are probably just old#2019-01-2619:29thhellerlet me see whats weird about that package 😉#2019-01-2619:32thhellerhmm no indeed it requires a browserify plugin#2019-01-2619:32thhellerhttps://www.npmjs.com/package/brfs#2019-01-2619:35thhellergotta love the shit people come up with to build their libs 🙂#2019-01-2619:38currentooryeah it’s crazy 😅#2019-01-2620:15thhellerFWIW you can fix the issue by doing (set! js/window.existsFileInVFS (fn [] false))#2019-01-2620:15thhellerdon't know why it is trying to use that from the global or why its different in webpack#2019-01-2620:15thhellerbut that fixes it (if you do it before calling the jsPDF constructor)#2019-01-2620:31thhellerha I found it ...#2019-01-2620:31thhellerclosure compilation strips the "use strict"; for some reason#2019-01-2620:50thhellerhttps://github.com/google/closure-compiler/issues/2055#2019-01-2620:50thheller> I'm closing this - it's not well understood, but it is by design.#2019-01-2701:03currentoorthat is strange#2019-01-2613:38metacritical@thheller I am writing a electron + shadow.cljs app and i have a particular use case where once the app is loaded i am trying to read some config written in cljs file that is not in the namespace. i.e
(defn load-global-config
  ([] (load-file “~/.b42/init.cljs”))
  ([config-file] (load-file config-file)))
I am getting an error goog.nodeGlobalRequire is not a function. Also it seems the foreign-lib is also not supported. Could there be a possible way to to this in an electron app?
#2019-01-2614:19thheller@metacritical I have no idea what you are asking. that code snippet does not tell me anything. you can't load .cljs at runtime unless you are using self-hosted CLJS#2019-01-2614:19thhellerforeign-libs are not supported that is correct. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-01-2614:21thhellerby load-file I assume you mean cljs.core/load-file which is only for self-hosted CLJS and not usable otherwise#2019-01-2614:22thhellerdon't see how foreign-libs are involved in that though#2019-01-2614:23thhellerits a different story if the file you want to load is just EDN data you want to access#2019-01-2614:23thhellerbut actual CLJS code you want to evaluate will only work in a self-hosted environment#2019-01-2614:31metacritical@thheller I understand what you are saying so my next question is can i have a self hosted clojurescript with a target
:node-script
#2019-01-2614:32thhelleryes, but it will require some work on your part.#2019-01-2614:32thhellerI added support for browser based self-hosted stuff a while ago#2019-01-2614:32thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-01-2614:33metacriticalYes and i used it, and it is great!#2019-01-2614:33thhellerso you'd basically need to take this namespace#2019-01-2614:33thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/bootstrap/browser.cljs#2019-01-2614:33thhellertake out all the browser related parts and write a node.js implementation#2019-01-2614:35thhellerin essence you want to read the "index" from the filesystem#2019-01-2614:35metacriticalAha, the current shadow docs has :bootstrap as a target to support the self hosting in browser, how would node target be?#2019-01-2614:35thhellerand subsequent files as well#2019-01-2614:35thhellerinstead of requesting things via XHR and stuff#2019-01-2614:36thhellerthe bootstrap stuff is identical, the generated index is identical. no changes there.#2019-01-2614:36thhelleronly the "bootstrap" namespace that loads everything is different#2019-01-2614:37metacriticalI understand, so i should submit a patch for this?#2019-01-2614:37thhellernot needed. you can do this in your app, nothing in shadow-cljs itself needs to change to support this#2019-01-2614:37thhellerif you build it general enough I'll consider accepting a PR to include it#2019-01-2614:38thhellerbut bootstrapping can be optimized for your particular needs#2019-01-2614:38thhellerso making something general might not be optimal depending on what you are actually trying to do#2019-01-2614:38metacriticalAah, sure thats actually helpful thankyou!#2019-01-2614:39thhelleralso things are a bit more complicated for electron if you want to support loading files from .asar and stuff#2019-01-2614:40metacriticalCurrently i am not considering .asar support! but what you suggested is quite helpful.#2019-01-2720:53thhellerso I'm personally finding this warning very annoying since the last CLJS release and close to disabling it by default#2019-01-2720:53thhelleranyone else annoyed by this?#2019-01-2720:53thheller
------ WARNING #1 --------------------------------------------------------------
 File: loom/alg_generic.cljc:494:19
--------------------------------------------------------------------------------
 491 |         offset (mod idx bits-per-long)
 492 |         mask (bit-set 0 offset)
 493 |         value (aget new-bitmap chunk)
 494 |         new-value (bit-or value ^Long mask)]
-------------------------^------------------------------------------------------
 cljs.core/bit-or, all arguments must be numbers, got [any Long] instead
--------------------------------------------------------------------------------
 495 |     (aset new-bitmap chunk new-value)
 496 |     new-bitmap))
 497 |
 498 | (defn bm-get
--------------------------------------------------------------------------------
#2019-01-2720:54thhellerthe :invalid-arithmetic warning in general I mean. not that particular source.#2019-01-2720:55thhellerso all <...>, all arguments must be numbers, ....#2019-01-2720:55thhellerimho all I have seen to far were "wrong"#2019-01-2813:54aisamuHi! check is giving me a warning that I'm not sure how to address:
helpers.cljs:
101:     if (isa? (type p) clojure.lang.MapEntry)
------ WARNING #56 -------------------------------------------------------------
 File: .........../helpers.cljs:101:24
 Property lang never defined on clojure
#2019-01-2813:58thheller@aisamu that should be cljs.core/MapEntry. clojure.lang.MapEntry does not exist in CLJS#2019-01-2813:59thhellerbetter yet use (map-entry? p)#2019-01-2814:00thhellerdoes that not produce a warning during normal compilation?#2019-01-2814:02thhellerwow indeed it produces no warning#2019-01-2814:02thhellerthats a bug I'd say#2019-01-2814:22thhellerhttps://github.com/thheller/shadow-cljs/issues/432 I'll investigate later#2019-01-2814:30aisamuOh, thanks a lot!#2019-01-2814:40yuhanWhat's the simplest way to get my clojurescript app to read some text from a file and display it on the web page?#2019-01-2814:40idiomancyis shadow cljs a figwheel-like autoreloading situation for browser apps?#2019-01-2814:45yuhanSeems like a really basic task but I've been struggling with it for the past hour - maybe there's some fundamental concept that I'm not understanding ?#2019-01-2814:47yuhanI have a Clojure library that processes inputs and outputs images and text files, trying to get the simplest possible thing together with Clojurescript for a browser-based dashboard to the functions#2019-01-2814:48yuhanenter something in a text field, and the backend runs and shows the generated image and text from the clj script on the browser page#2019-01-2814:49idiomancy@qythium clojure library? dumb question maybe, but its built for clojure script right?#2019-01-2814:50yuhanYes, as far as I understand the usual model is to have a cljs frontend which somehow interfaces with a clj backend#2019-01-2814:52idiomancyintersting, so its a client/server combo?#2019-01-2815:29thheller@idiomancy shadow-cljs does far more than figwheel. but yes for browser builds it does offer the same features that figwheel does including life reload and css reload#2019-01-2815:29idiomancyokay, outstanding#2019-01-2816:27thheller@qythium that is not an easy question to answer. you'll need a HTTP server. the client would send a POST request to the server which would then reply with the results. gets a bit trickier with images since the browser can't send a POST request for images. sounds really basic but really isn't. 🙂#2019-01-2816:38yuhanWith images at least I can have a [:img {:src ...}] tag and have the clj code write directly to the source location.. is that a completely wrong way of going about things?#2019-01-2816:38yuhanand why does there seem to be no equivalent way of displaying text from a source file?#2019-01-2816:44thhellerget the notion of source file out of your head 🙂#2019-01-2816:44thhellerin a web context you don't want browser randomly accessing your files 🙂#2019-01-2816:45thhellerso yeah you can simply serve some text if that is all you want#2019-01-2816:45thheller[:iframe {:src ...}] would do the same as the :img above#2019-01-2816:45thhellerbut that is rarely the solution you want#2019-01-2816:46thhellerdepends on your app of course but for text sending a XHR is generally preferred#2019-01-2816:46yuhanoh.. alright#2019-01-2816:46yuhansorry, I'm really not experienced at all in the web dev side of things#2019-01-2816:47yuhanis there a minimal example of a client/server app with that sort of communication that I can look at?#2019-01-2816:49thhellerpretty much all examples that have some kind of server code#2019-01-2816:50yuhanhmm, I'll go and look around again#2019-01-2816:51yuhanI assume you meant the Compojure / Ring libraries which do the message handling?#2019-01-2816:52thhellerany kind of server will do. I would use fulcro/pathom but that is probably major overkill for what you want#2019-01-2816:52thhellernot sure if there are any reagent/re-frame examples with server side code#2019-01-2816:53thhellerthere should be I just don't know any#2019-01-2816:56yuhanI find that most of the tutorials and examples out there seem to assume a full working knowledge of the javascript ecosystem and web architecture, can be pretty overwhelming 😕#2019-01-2816:56thhellerhttp://www.luminusweb.net/ maybe?#2019-01-2816:58thhellerlots of moving parts but yeah the "getting started" experience overall is still pretty bad for clojure#2019-01-2816:59yuhanI tried Luminus some time ago and it seemed really overkill for what I had in mind, there were so many different interconnected parts spread over many files - is that really the sort of minimal setup needed?#2019-01-2817:00thhelleroh no that is really really far from minimal#2019-01-2817:01thhellerthat is more minimal https://gist.github.com/weavejester/585915#2019-01-2817:01thhellermaybe the wiki helps https://github.com/ring-clojure/ring/wiki#2019-01-2817:02thhelleror maybe http://pedestal.io/index#2019-01-2817:03yuhanAh, thanks for all the pointers! I'll try working my way up from there 🙂#2019-01-2817:40thhellerI just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "2e5d464f4a4159034d42445d6e1c0019001f16"}, :content ("[email protected]")}. One thing I tried to tweak is how warnings are handled in the console. So if you have lots of warnings in libraries you don't control they should be less annoying now.#2019-01-2817:40thhellerplease try it and let me know if you have any ideas how to improve it further#2019-01-2818:01wilkerlucio@thheller just tried 2.7.18, but getting this:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/wilker.lucio/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/spec/gen/alpha.cljs:35:3
--------------------------------------------------------------------------------
  32 |   (apply @quick-check-ref args))
  33 |
  34 | (def ^:private for-all*-ref
  35 |   (dynaload 'clojure.test.check.properties/for-all*))
---------^-----------------------------------------------------------------
StringIndexOutOfBoundsException: String index out of range: -1
	java.lang.String.substring (String.java:1931)
	clojure.core/subs (core.clj:4986)
	clojure.core/subs (core.clj:4981)
#2019-01-2818:04wilkerlucio(I didn't had this in 2.7.15, trying versions in the middle to see if I can find where it stopped working#2019-01-2818:05wilkerlucio2.7.17 works fine, 2.7.18 doesn't compile#2019-01-2820:25thhellerwhat the heck#2019-01-2820:25thhellerthanks I'll fix it#2019-01-2820:27thhellerhmm weird. I do not get that error when compiling that namespace#2019-01-2820:33hoopessorry to +1 that, but i got it as well#2019-01-2820:34thhellerdo you have the rest of the stacktrace or does it cut off there?#2019-01-2820:34hoopes#2019-01-2820:35wilkerlucio@thheller maybe you have to require spec?#2019-01-2820:35thhellerI have#2019-01-2820:35thheller+ the test.check stuff#2019-01-2820:36thhellerok its clear where the error happens. just not sure why I can't reproduce it#2019-01-2820:44thheller@wilkerlucio @hoopes should be fixed in 2.7.19. thanks for the report.#2019-01-2820:44hoopes#hero#2019-01-2820:45thhellerstill no clue why it doesn't happen for me though#2019-01-2820:45wilkerluciomaybe some weird dep we have#2019-01-2820:45hoopeschecking now#2019-01-2820:46wilkerluciochecking here too#2019-01-2820:48thhellerI could reproduce the error manually. just no idea why it didnt' happen when compiling those files#2019-01-2820:48wilkerlucioI noticed something, in the past I had some highlight.js warnings and they used to came in yellow color, now they are white, not sure if was intentional, but other than that the compilation is good now! thanks man!#2019-01-2820:48hoopesyeah, it compiled - i got more warnings on this run, but no giant error#2019-01-2820:48thhellerthat is intentional. warnings you can't "fix" should be de-emphasized now#2019-01-2820:48hoopesthanks very much!#2019-01-2820:48wilkerlucio
------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: common_core/schema.cljc:121:32
 Use of undeclared Var common-core.schema/clojure
--------------------------------------------------------------------------------
and a lot of those now ^^^ 😛
#2019-01-2820:48thhellerso warnings in files you don't control only show with source excerpts once#2019-01-2820:49thhellerthose may be actual real errors#2019-01-2820:49wilkerlucioprobably, this is an internal lib but most people don't try it with cljs, so I have to go there an fix it#2019-01-2820:50thhellerhmm how many warnings do you have? 🙂#2019-01-2820:52wilkerlucioreal ones seem 6#2019-01-2820:52thhellercan you check what it warns about? might be some clojure.lang.... symbol#2019-01-2820:53hoopes
------ WARNING #5 - :undeclared-var --------------------------------------------
 Resource: bide/core.cljs:176:36
 Use of undeclared Var bide.core/EventType
--------------------------------------------------------------------------------
#2019-01-2820:53thhellerit didn't warn about clojure.lang.MapEntry which I wanted to fix#2019-01-2820:53wilkerlucio
------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: cljs_time/internal/parse.cljs:139:27
 Use of undeclared Var cljs-time.internal.parse/Interval
--------------------------------------------------------------------------------

------ WARNING #2 - :undeclared-var --------------------------------------------
 Resource: cljs_time/internal/parse.cljs:340:31
 Use of undeclared Var cljs-time.internal.parse/Interval
--------------------------------------------------------------------------------

------ WARNING #3 - :undeclared-var --------------------------------------------
 Resource: cljs_time/coerce.cljs:29:18
 Use of undeclared Var cljs-time.coerce/UtcDateTime
--------------------------------------------------------------------------------

------ WARNING #4 - :undeclared-var --------------------------------------------
 Resource: common_core/schema.cljc:121:32
 Use of undeclared Var common-core.schema/clojure
--------------------------------------------------------------------------------

------ WARNING #5 - :undeclared-var --------------------------------------------
 Resource: common_core/schema.cljc:122:32
 Use of undeclared Var common-core.schema/clojure
--------------------------------------------------------------------------------

------ WARNING #6 - :undeclared-var --------------------------------------------
 Resource: pushy/core.cljs:88:39
 Use of undeclared Var pushy.core/EventType
--------------------------------------------------------------------------------
#2019-01-2820:53hoopeshttps://github.com/funcool/bide/blob/master/src/bide/core.cljs#L185#2019-01-2820:53hoopeswhich then became a runtime error in the app...#2019-01-2820:53hoopesReferenceError: EventType is not defined#2019-01-2820:53thhellerah hehe crap.#2019-01-2820:54thhellerI know why that one happens ...#2019-01-2820:54hoopesi got the same first three as @wilkerlucio too - cljs-time warnings#2019-01-2820:57thhellerI'll add those to the test build I guess 🙂#2019-01-2821:07thhellerok those warnings are fix. apart from the common-core.schema/clojure. Those are probably some invalid clojure classes like clojure.lang.MapEntry was so the warnings are probably legit#2019-01-2821:12hoopesby fixed, do you mean 2.7.20? (sorry, not sure what you mean by "fixed")#2019-01-2821:12thhellershould be fixed in 2.7.20#2019-01-2821:12hoopesgotcha#2019-01-2821:12wilkerlucio@hoopes I also found that same runtime error you described, is that fixed as well @thheller?#2019-01-2821:13thhellerthe cljs.spec.alpha.gen should be fixed#2019-01-2821:14wilkerlucioawesome, thanks#2019-01-2821:15thheller@wilkerlucio if you get a chance please check what your internal lib uses. good chance the warnings are actually legit but would like confirmation.#2019-01-2821:18thhellerI'd like to add something to CI that catches things like that but not sure how#2019-01-2821:18thhellerall my builds went through without error or warnings 😞
#2019-01-2821:19wilkerlucioI'm pretty sure they are legit 🙂#2019-01-2821:19wilkerluciolike I told you, this is a cljc file, but 90% of the people only try it in clj#2019-01-2821:19wilkerlucioI keep fixing things there#2019-01-2821:19thhelleryeah but the bidi and pushy weren't so would be nice to catch those issues in CI#2019-01-2821:20wilkerluciolet me do a quick check here#2019-01-2821:21wilkerlucioactually, this is what I found in the line looking at the sources:#2019-01-2821:21wilkerlucio
clojure.lang.IPersistentVector
                               clojure.lang.IPersistentSet
#2019-01-2821:21thhellermaybe I'll just add top10 most used CLJS libs and include their main namespaces#2019-01-2821:21wilkerlucioare those supposed to be available on cljs? I'm not sure#2019-01-2821:21thhellerok those are legit warnings then#2019-01-2821:21thhellerno, those are java interfaces for CLJ only#2019-01-2821:21wilkerluciook, makes sense then#2019-01-2821:22thhellerwould be cljs.core/PersistentVector and Set in CLJS#2019-01-2821:22thhellerthose did not cause errors at runtime?#2019-01-2821:23thhellerblank use of clojure.lang.MapEntry caused runtime errors#2019-01-2821:23thhellermaybe the code isn't used in CLJS#2019-01-2920:19heyarnei have a problem that pops up sometimes... i'm running the build server, watching some builds, and then i'm refactoring some code. creating new namespaces and moving functions around, and all the namespaces that have not been around when shadow-cljs was started are not picked up. can i easily fix this?#2019-01-2920:51thhelleryou can come up with a reproducible example 😉#2019-01-2920:52thhellerthings should be picked up automatically, its a bug if they are not.#2019-01-2920:53thhellernot aware of any problems related to that though#2019-01-3012:35heyarneoh ok... i'll try to do that. good to hear that it's not supposed to be like that. well, kinda good. 😉#2019-01-2923:40thhellerI just release {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7d0e151c19120a501e11170e3d4f534a534f4c"}, :content ("[email protected]")}. if you were getting "illegal reflective access" warnings on startup please give it a try and let me know if they are gone (they should be)#2019-01-2923:40thhellerstartup messages in general should be a bit less noisy#2019-01-2923:40thheller
$ shadow-cljs clj-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/clojure-cli/shadow-cljs.edn  cli version: 2.7.20  node: v10.13.0
shadow-cljs - server version: 2.7.20 running at 
shadow-cljs - nREPL server started on port 54298
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[1:0]~shadow.user=>
#2019-01-2923:41thhellersomething like that#2019-01-3017:02aisamuHi! Are build reports supported on :npm-module targets? This the output I get with after clearing the cache and node_modules:
...
[:npm] Build completed. (163 files, 104 compiled, 0 warnings, 35.70s)
shadow-cljs - config: /home/jenkins/jakarta/shadow-cljs.edn  cli version: 2.7.22  node: v9.11.2
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
        clojure.core/ex-info (core.clj:4739)
...
Caused by:
NoSuchFileException: .shadow-cljs/release-snapshots/npm/latest/goog.debug.error.js.map
        sun.nio.fs.UnixException.translateToIOException (UnixException.java:86)
        sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:102)
        sun.nio.fs.UnixException.rethrowAsIOException (UnixException.java:107)
        sun.nio.fs.UnixFileSystemProvider.newByteChannel (UnixFileSystemProvider.java:214)
        java.nio.file.Files.newByteChannel (Files.java:361)
        java.nio.file.Files.newByteChannel (Files.java:407)
        java.nio.file.Files.readAllBytes (Files.java:3152)
        shadow.build.closure.SourceMapReport.getByteMap (SourceMapReport.java:57)
        shadow.cljs.build-report/extract-report-data/fn--991/fn--993 (build_report.clj:126)
....
#2019-01-3017:05aisamu(`.shadow-cljs/release-snapshots/npm/latest/goog.debug.error.js.map` is indeed missing, but out of the 33 goog.* ns's in that folder, only 7 have sourcemaps)#2019-01-3017:06thhelleroh. yeah thats a bug.#2019-01-3017:07thhellerthose files were completely removed by DCE and are only there for compatibility reasons#2019-01-3017:07thhellerie. .shadow-cljs/release-snapshots/npm/latest/goog.debug.error.js is empty#2019-01-3017:08thhellerbut build report for npm-module isn't very useful since you are going to consume it somewhere else anyways#2019-01-3017:08thhellereg. you let webpack fill in your npm requires#2019-01-3017:13aisamuOK! I was mostly interested on checking whether the fdef's I wrote were leaking into prod, since everything is always on the classpath. (not enabled, since I'm not using orchestra, but present and unnecessarily increasing the payload)#2019-01-3017:20thhellerfdefs will never be removed if they are in a namespace that was included in the build#2019-01-3017:21thheller(unless you manually hide them behind some (when ^boolean js/goog.DEBUG (s/fdef ...)))#2019-01-3017:21thhellerspec in general doesn't work with DCE unfortunately#2019-01-3017:30aisamuYup, those were my fears... but it's nice to have a confirmation! Thanks for being so helpful!#2019-01-3020:24aisamuHello again! Is it expected to get a compilation error when using #shadow/env with an unset var on release builds?
$> npx shadow-cljs release npm
...
-> Closure - Optimizing ...
Closure compilation failed with 1 errors
--- goog/base.js:3
Invalid CLOSURE_DEFINES definition
The compile task works without issue, and setting the var to nothing or the empty string also works (e.g. $> THE_VAR= npx shadow-cljs release npm) The config contains
:closure-defines {the.ns/THE_VAR #shadow/env "THE_VAR"}
and the.nscontains a (goog-define THE_VAR)
#2019-01-3020:29thheller@aisamu if you only care about the THE_VAR in development use the :dev map#2019-01-3020:29thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2019-01-3020:30thheller:dev {:closure-defines {the.ns/THE_VAR ....}}#2019-01-3020:32thhellerand just set :release {:closure-defines {the.ns/THE_VAR ""}}#2019-01-3020:32thhellerit may not like nils#2019-01-3020:32thhellernot sure#2019-01-3020:33aisamuI might need it for both, but I can go around it by checking that it exists before calling shadow. Thanks! (yup I believe goog-defines can't be nil)#2019-01-3020:34thhellerI can fix it so it doesn't return nil when not found#2019-01-3020:43aisamuThat'd be very nice, thanks!#2019-01-3020:35thhellerI never recommend using env vars so the feature isn't used much 😛#2019-01-3020:41aisamuYup, I read that! And I see that it's also not on the manual, so I'm well aware I'm playing with fire here... It's mostly to be compliant with the existing webpack project that uses the cljs modules#2019-01-3020:57thheller@aisamu should be fixed in 2.7.23#2019-01-3020:58aisamuAgain, thanks a lot!#2019-01-3101:02knubiedoes clojure.test.check.clojure-test/defspec work with shadow-cljs’s built-in test runner?#2019-01-3106:43thheller@steedman87 if you use the latest version yes. older versions didn't.#2019-01-3112:28knubieOh, wow I was several versions behind. They new in-browser test runner looks amazing!#2019-01-3112:29knubieAnd of course defspec works now 😁#2019-01-3112:30thhellerits using the wonderful https://github.com/bhauman/cljs-test-display now#2019-01-3113:41aisamuHey! Are requires outside of nss supported in shadow (or cljs, for that matter) This (admittedly old) blog indicates that it would be possible https://anmonteiro.com/2016/10/clojurescript-require-outside-ns/. When trying it on a cljc file, it fails with:
CompilerException: java.lang.RuntimeException: Feature should be a keyword: (require (quote [clojure.spec.alpha])), compiling:(.../spec.cljc:12:35)
regardless of it being wrapped in a #?:clj, #?:cljsor nothing
#2019-01-3114:46thhellerno they are not supported since it doesn't provide any feature you wouldn't get by putting in in the ns in the first place#2019-01-3114:46thhelleryou can't do conditional includes that way if that is what you were trying to do#2019-01-3114:47thheller@aisamu ^#2019-01-3114:59aisamuOk, thanks! That is precisely what I'm trying to achieve... is it possible with some other technique? #2019-01-3115:03thhellerofficially no, unofficially https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2019-01-3120:13Pavel KlavíkHi, I am trying to get shadow-cljs setup running. I am using Cursive and would like to connect its REPL to the browser session. After starting shadow-cljs watch app, I get: shadow-cljs - nREPL server started on port 9000 When I connect to it, it is a Clojure REPL instead, not connected to browser. (Things like (js/console.log "Test") fail with RuntimeException.)#2019-01-3120:14thhellerthat is normal and intended#2019-01-3120:15thhelleryou need to switch the CLJ repl to the CLJS repl of your build#2019-01-3120:15thhellerso (shadow/repl :app)#2019-01-3120:16knubie@thheller did that change from (shadow/nrepl-select :build-id)?#2019-01-3120:16thheller(shadow.cljs.devtools.api/repl :app) in case the alias isn't setup correctly#2019-01-3120:16thheller@steedman87 no. repl automatically calls nrepl-select when in nrepl context#2019-01-3120:16knubieah good to know#2019-01-3120:22Pavel KlavíkI see, that is little bit confusing.#2019-01-3120:23Pavel KlavíkAny way to automate this, so I don't have to type it on every start?#2019-01-3120:25lilactownI'm not sure if Cursive has this built in, but in Emacs/CIDER when I run my ClojureScript jack-in command in a shadow-cljs project, it asks me which build I want to select and runs that command for me#2019-01-3120:26thheller@pavel.klavik you can create a custom REPL command and bind it to a key#2019-01-3120:26thhelleror just use the REPL history#2019-01-3120:26Pavel Klavíkok, that solution is good enough#2019-01-3120:42Pavel Klavíkbtw. the tool looks great, it is good that I finally can easily add JS libraries to the project 🙂#2019-02-0117:10austinbirchHello, Wondering if anyone can help me with a NodeJS + CLJS setup. I’ve got an app already written in CLJS for the browser, but there’s some code in there I want to share with an already written NodeJS server app. My plan is to separate out the shared code into its own library; using shadow-cljs :node-library target to be able to build a JS version for use on the NodeJS server, and pull the library into the CLJS browser app as a normal CLJS dependency. Does that sound sensible? The next question I have after having trying the above is: when I’m developing this library, how can I get live reloading / REPL based workflow with a :node-library target? I’ve tried running the shadow-cljs watcher in one terminal, calling node ./dist/lib.js and then shadow-cljs cljs-repl lib to connect a CLJS repl but live reload doesn’t seem to pick up changes after file save (but I can get changes if I eval the code changes within the REPL).#2019-02-0117:12thheller@austinbirch live-reload is a bit more restricted in node-library since we can't modify things after they were exported#2019-02-0117:12thhellerso live-reload from within CLJS should work but if you the stuff loaded from node can't#2019-02-0117:14thhellerbut it should work depending on what you do. may need to manually enable it though :devtools {:autoload true}#2019-02-0117:14thheller(if you don't have other hooks configured, eg. :after-load)#2019-02-0117:19austinbirchAh, I should have also mentioned that I set :devtools {:autoload true} and had live reloading working with :node-script (but then this isn’t consumable as a npm dependency). Maybe I should just create a :node-script build for development and a :node-library build for release?#2019-02-0117:19thhellerI wouldn't recommend that. you want your dev build to be as close as possible to release#2019-02-0117:20thhellerotherwise you'll end up debugging release builds endlessly 😛#2019-02-0117:20austinbirchYes (been there…!)#2019-02-0117:21thhellerbut live-reload should work fine in node#2019-02-0117:21thhellerjust the exports themselves can't be reloaded#2019-02-0117:21lilactownis your NodeJS service written in JS?#2019-02-0117:21lilactownor CLJS?#2019-02-0117:23austinbirchI actually might have been testing by updating the exported function, so maybe that’s it. If I export functionA that calls functionB, update functionB and save the file, would you expect that the live reload would run the new functionB?#2019-02-0117:23austinbirch@lilactown existing project written in JS#2019-02-0117:26thhelleryes that should work#2019-02-0117:26austinbirchI will try now and get back to you. Thanks so much for all the help!#2019-02-0117:27thhellervar x = require("your-cljs.js"); x.foo();#2019-02-0117:27thhellerthe foo can't be updated#2019-02-0117:27thhellersince node saves that references internally#2019-02-0117:28thhellerbut whatever that foo calls internally can be updated normally#2019-02-0117:32austinbirchJust tried and that’s working perfectly now. Very pleased!#2019-02-0117:32austinbirchThanks again for your help.#2019-02-0117:34austinbirchWhen I was testing I’m pretty sure I had something like:
(defn exported-fn
  []
  "returning 1")
and was just updating the string to see live reloading work. So your explanation above makes perfect sense. Easy for me to just have the exported function call others in the CLJS namespace and work from there.
#2019-02-0117:35thhelleryeah I tried making the exports dynamic once but it had a bunch of issues so I opted out of that#2019-02-0117:43austinbirchMakes sense. I better get back to actually writing the code now then 🙂#2019-02-0118:19colinkahnCan you have browser tests that autorun on changes?#2019-02-0118:22colinkahnI see that it runs shadow-cljs: call shadow.test.browser/start when the code reloads, but this doesn't seem to actually update the UI with new tests#2019-02-0118:25thhellerjust tested and works fine here.#2019-02-0118:26colinkahnweird, any suggestions to help debug?#2019-02-0118:26thhellerversion?#2019-02-0118:27colinkahncli version: 2.7.24 node: v8.9.4#2019-02-0118:28thhellerserver version?#2019-02-0118:28colinkahnserver version: 2.7.24#2019-02-0118:28thhellerhmm yeah thats what i just tested with#2019-02-0118:28colinkahnActually, I just found it#2019-02-0118:29colinkahnI was running it in the Brave browser and it wasn't working, works fine in Chrome#2019-02-0118:29thhellerhmm ok. don't have brave installed#2019-02-0118:30thhellermaybe it doesn't like the notifications?#2019-02-0118:30colinkahnmy assumption is its some security thing perhaps#2019-02-0118:30colinkahnit will ask if I want to receive notifications#2019-02-0118:31thhellertry :closure-defines {cljs-test-display.core/notifications false}#2019-02-0118:31thhellernot sure. gotta go.#2019-02-0118:31colinkahnno worries, i'll try that#2019-02-0118:33colinkahnoh nice, that did work, thanks!#2019-02-0118:46colinkahnAh, actually no, that wasn't specifically my issue, it is that if I add a new test with deftest that test isn't run, regardless of whether it's Brave or Chrome#2019-02-0118:42ccanncan anyone recommend getting started with https://github.com/minimal-xyz/minimal-shadow-cljs-browser versus the shadow-cljs lein template?#2019-02-0120:21thheller@ccann I recommend https://github.com/shadow-cljs/quickstart-browser#2019-02-0120:22ccannthank you#2019-02-0120:22thhellerthey are all pretty similar though. so its really up to you#2019-02-0120:22ccann👍#2019-02-0120:25ccannI know this isn’t necessarily a beginner forum, but whenever I kill my repls and then restart (via cider-connect-clj&cljs -> shadow -> app) I get Stale Client! in the browser window … which goes away if I hard-refresh the page#2019-02-0120:34thheller@ccann this is absolutely a beginner forum 🙂 unfotrunately I can't help with cider issues as I know nothing about that#2019-02-0120:34thhellerstale client is the message you get when you load js that was not compiled by the current watch#2019-02-0120:34ccannit seems to work anyway 🙂#2019-02-0120:34thhellerdepending on which server you use it may be a cache issue#2019-02-0120:34ccannokay interesting, thanks!#2019-02-0121:34souenzzoI'm trying to move a figwheel project to shadow, but when I run (server/start!) I get:
Execution error (NoSuchFieldError) at shadow.build.closure.JsInspector/getFileInfo (JsInspector.java:161).
PARSE_RESULTS
#2019-02-0121:37thheller@souenzzo likely a bad version of the closure compiler on the classpath#2019-02-0121:37thhellershould be [com.google.javascript/closure-compiler-unshaded "v20181125"] or later#2019-02-0201:38kanaHello. I'm trying to use shadow-cljs with Calva, and there is no progress. I can connect to repl via shadow-cljs cljs-repl frontend, but Calva says Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected? Shadow works in lein mode, so I added [cider/cider-nrepl "0.20.0"] into project.clj, then I added it into shadow-cljs.edn, no effect. Can someone help me?#2019-02-0205:43lilactown@kana what steps are you taking when you try to connect to Shadow-cljs via Calva?#2019-02-0205:54eccentric JWhat’s the best way to have code that only runs in development mode? In figwheel-main I configured an extra env/dev source path.#2019-02-0207:26eccentric JNevermind, able to achieve it with the :dev and :release configs. Shadow-cljs is amazing!#2019-02-0209:02thhelleryou can't change the classpath in build configs?#2019-02-0214:45eccentric JWas able to change the :main with the :dev and :release.#2019-02-0209:06thheller@richiardiandrea can you name some of the npm libs you use in your azure builds or other node builds? I'm working on the one-file bundler thing and need examples of libs people actually use#2019-02-0215:37richiardiandreaSure, Bunyan, node-postgres, @azure/cosmos, ajv, request...just by memory#2019-02-0209:07thhellerneed to test this a bit#2019-02-0209:07thhellerI know that this won't work with all node libs but if webpack can do it so should we 😉#2019-02-0210:33kana@lilactown 1. install shadow via lein 2. add shadow-cljs.edn
{:lein true
 :builds {:frontend ...}}
3. add [cider/cider-nrepl "0.20.0"] to lein (not shadow-cljs) deps 4. start shadow
lein run -m shadow.cljs.devtools.cli watch frontend
5. trying start repl
lein run -m shadow.cljs.devtools.cli cljs-repl frontend
6. trying to connect via Calva 7. getting
This looks like a shadow-cljs coding session.
Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?
#2019-02-0210:33thheller@kana do not do this#2019-02-0210:33thhellerdo not launch using lein. that is pointless.#2019-02-0210:34thhellerjust run shadow-cljs watch frontend and shadow-cljs cljs-repl frontend#2019-02-0210:34thhellerit will use lein internally when appropriate#2019-02-0210:34kanabut shadow-cljs just runs lein#2019-02-0210:34thhellernot exactly#2019-02-0210:34thhellerit will use lein to run the watch that is correct#2019-02-0210:34kanaokay, but it doesn't work too#2019-02-0210:35thhellerbut if a "server-mode" process is running (eg. the watch) then it won't run lein and instead connect to the server process#2019-02-0210:35thhellerso cljs-repl will not run through lein but instead connect to the previous watch#2019-02-0210:35thhellerdid you wait for watch to start fully before running cljs-repl?#2019-02-0210:36thhellerlein run -m shadow.cljs.devtools.cli cljs-repl frontend this will NEVER work when launched through lein#2019-02-0210:36kanaYes. As I say, cljs-repl frontend fully works from cli#2019-02-0210:37kana
$ npm run shadow-cljs watch frontend
...
# another terminal
$ npm run shadow-cljs cljs-repl frontend

> 
#2019-02-0210:39kanaBut Calva returns the same in "Calva says"
This looks like a shadow-cljs coding session.
Failed starting cljs repl for shadow-cljs build: :frontend. Is the build running and conected?
#2019-02-0210:43thhellerdid you use calva connect?#2019-02-0210:44kanaWow#2019-02-0210:46kanaI just trying to connect to cljs repl separately from clj repl, by "Attach ClojureScript repl" command, but when I am trying to connect to clj repl, it always successfully connected to cljs repl#2019-02-0210:47kanaThanks a lot, you are saved a lot of my time!#2019-02-0213:56kanaThere was only one rebuild after cljs change (in log), but there were two reloads in browser
{:lein true
 :builds {:frontend
          {:output-dir "resources/public/js"
           :target :browser
           :modules {:main {:entries [waifoo.client]}}
           :asset-path "js"
           :devtools {:watch-dir "resources/public/css"}}}}
css folder didn't has changes
#2019-02-0213:59thhellerI'm not sure what you mean with "two reloads"#2019-02-0213:59thhellerthe :watch-dir is incorrect and should be resources/public#2019-02-0213:59thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2019-02-0214:00thheller:asset-path should also be /js#2019-02-0214:00thhelleralso prefer absolute paths, will save you later#2019-02-0214:02thheller(but that doesn't affect live-reload in any way)#2019-02-0214:02kanaafter any change in cljs, the module will be launched in the browser twice#2019-02-0214:02thhellerwhat does that mean to you?#2019-02-0214:02thhelleris a function executed twice?#2019-02-0214:03thhellerby default shadow-cljs doesn't run anything and only reloads you code#2019-02-0214:03kanaokay, I have a tolplevel code in module#2019-02-0214:03thhellerdo you have any hooks configured?#2019-02-0214:03kana
(defonce x (atom 0))
(println "RELOADING" (swap! x inc))
#2019-02-0214:03kanaat first run we will se "RELOADING 1"#2019-02-0214:04kanaafter every single change we will see "RELOADING 2" and "RELOADING 3" after second#2019-02-0214:04thhellerwhat is a "change" to you? assuming editing it in an editor?#2019-02-0214:04kanayes#2019-02-0214:04thhellera simple touch src/your/file.cljs triggers 2 reloads?#2019-02-0214:05kanait doesn't trigger any reloads#2019-02-0214:06thhellerit should. are you sure you touched the correct file?#2019-02-0214:06thhellerjust trying to rule out your editor doing stuff that could trigger the second reload#2019-02-0214:07kanasorry, it triggers only 1 reload#2019-02-0214:07kanadoes it mean, that it is something with editor#2019-02-0214:07kanaoh, maybe parinfer#2019-02-0214:07thhellervery likely yes#2019-02-0214:08thhellerthe live-reload code is pretty fast so it just probably gets triggered twice#2019-02-0214:08thhellereg. you save the file, then run some on-save hook which saves it again#2019-02-0304:26thosmosI'm getting an error when Cursive tries to generate stubs:
No such namespace: react, could not locate react.cljs, react.cljc, or JavaScript source providing "react" in file file:/Users/thomas/.m2/repository/thheller/shadow-cljsjs/0.0.16/shadow-cljsjs-0.0.16.jar!/cljsjs/react.cljs
I'm guessing this is because I don't have a node_modules in my base directory? I DO have one in my subdirectory and am using :js-options {:node-modules-dir "client"} to tell shadow-cljs where it is. I'm wondering what the right way is to use shadow-cljsjs. Do I need to add exclusions for deps that use cljsjs, like this?
{:deps {thheller/shadow-cljsjs    {:mvn/version "0.0.16"}
        fulcrologic/fulcro        {:mvn/version "2.7.2"
                                   :exclusions  [cljsjs/react
                                                 cljsjs/react-dom
                                                 cljsjs/react-dom-server
#2019-02-0304:37lilactown@thosmos in general case, shadow-cljs just ignores cljsjs deps and looks in node_modules#2019-02-0304:37lilactownnot sure about the cursive error#2019-02-0304:38lilactownis that an error showing in Cursive, or in your shadow-cljs compilation output?#2019-02-0304:40thosmoscool, so maybe if I add those deps back in it won't affect shadow-cljs but will get rid of the error in Cursive. It's a cursive error.#2019-02-0305:12lilactownyeah, I would try that#2019-02-0308:46thheller@thosmos Cursive doesn't use shadow-cljs to generate the stubs so I suppose it uses :npm-deps with the default compiler options#2019-02-0308:47thhellerdunno why it is trying to generate stubs for the cljsjs shims though. seems odd#2019-02-0309:13thhellerah I guess its just compiling normally and picks those namespaces over the normal foreign-libs#2019-02-0310:35heyarnei just saw that doo supports coverage supports via istanbul and karma-coverage. did anybody manage to set this up with the :karma target?#2019-02-0310:36thhellernot sure what that is but I imagine you configure it in karma.conf.js?#2019-02-0310:37thhellerhttps://github.com/karma-runner/karma-coverage#2019-02-0313:42lxsameer@thheller hi there#2019-02-0313:42lxsameerI'm gonna give a talk in our locale clojure group about shadow-cljs#2019-02-0313:43lxsameerwhat are the killer features of shadow in compare to cljsbuild and figwheel ?#2019-02-0314:08thheller@lxsameer probably need to ask someone that has used those tools recently.#2019-02-0314:09thhellerI'd probably highlight the npm integration, overall speed, simplicity and reliability (ie. no constant lein clean or the like)#2019-02-0314:10lxsameer@thheller I'm one of them. For me the dynamic code loading and ease of use are super useful#2019-02-0314:10thhellermore fine tuned build targets so no manual fiddling with build settings and such#2019-02-0314:10lxsameercool#2019-02-0314:10thhellerits also pretty much the only "full stack" tool currently#2019-02-0314:10lxsameer@thheller also are you working on any new feature whether released or in development which you think it might be worthy to mention#2019-02-0314:11thhellerie. figwheel only does development stuff but isn't concerned with release builds much#2019-02-0314:12thhellernah better talk about what is there not what might be#2019-02-0314:13thhellernpm integration alone is enough for most people coming from that world#2019-02-0314:14lxsameercool, thanks friend#2019-02-0314:15thhellerthanks for giving a talk about shadow-cljs! if I can help with prep let me know#2019-02-0314:16lxsameerno problem. To be honest I recently wanted to write a piece of software for my editor and i didn't want to use JVM, so I used shadow-cljs for the first time with node support,#2019-02-0314:16lxsameerand I was totally impressed by it#2019-02-0314:17lxsameerit's really cool. SPECIALLY the npm support#2019-02-0315:09heyarnehow much more does shadow-cljs do for npm support? https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules sounds like it should work fine by now, even though my last experience was that shadow-cljs really smoothed things out#2019-02-0315:23thheller@arne-clojurians the npm support in shadow-cljs is implemented from scratch and has no relation to the article you linked or the :npm-deps feature in CLJS#2019-02-0315:24thheller:npm-deps is IMHO a dead end and will never work reliably enough (given the current state of wild-west JS on npm)#2019-02-0315:24thhellereven the official statement is not to use :npm-deps and use webpack instead these days#2019-02-0315:25thhellerI wrote a couple posts on the subject a while ago if you are interested#2019-02-0315:25thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2019-02-0315:25thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2019-02-0315:25thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2019-02-0315:26thhellerTL:DR: gave up :advanced optimizations for npm dependencies but instead gained almost full compatibility#2019-02-0315:27thhellerso shadow-cljs does a whole lot more and is somewhat modeled after what webpack does#2019-02-0315:31heyarnecool, thanks!#2019-02-0317:45mattlyis there a way to trigger a rebuild on a resource change, because say I have a macro that inlines a .graphql file into my code?#2019-02-0317:46thheller@mattly nothing built-in currently besides the usual touch src/main/some/file.cljs#2019-02-0317:46mattlyheh, thanks, that's what I've been doing#2019-02-0317:47thhellerie. when you modify the .graphql file you have another tool trigger the touch#2019-02-0317:47mattlyat least with VSCode I can just save the file and it will touch it as opposed to emacs which requires some dirtiness#2019-02-0317:47thhelleryou can trigger recompiles via the REPL too#2019-02-0317:48thheller(assuming you marked the file that uses the .graphql as uncacheable that would be enough)#2019-02-0319:16achikin@thheller I have a conceptual question. Maybe it sounds a bit naive, but why not turn things around and run the compiled clojurescript code through webpack alongside with npm modules and let webpack create the final bundle?#2019-02-0320:08thheller@achikin you can do that with :target :npm-module. I explained my reasoning here https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html#2019-02-0320:25thhellersomeone with more patience should certainly explore that avenue more though. I couldn't stand looking at the webpack code ... too much JS 😛#2019-02-0412:01Karol WójcikIs there some example project which uses shadow-cljs with leiningen instead of shadow-cljs with npm?#2019-02-0412:46thheller@kwcharllie379 do you mean completely without npm or just managing dependencies with lein?#2019-02-0412:47thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2019-02-0412:47Karol WójcikI would like to manage dependencies with lein and also be able to attach dirac agent#2019-02-0412:47thhellerdirac is not supported I think#2019-02-0412:49Karol WójcikIs there way to attach it somehow? via repl-options?#2019-02-0412:49Karol WójcikOr should I stick to devtools for now?#2019-02-0412:50thhellerI don't know. never used dirac, dont' know how it works#2019-02-0412:51Karol WójcikIt’s just a clone of devtools https://github.com/binaryage/dirac#2019-02-0412:51thhelleryeah not quite. it requires server-side support and that part I have no idea about#2019-02-0412:52thhellerbut last time I checked it interfaced directly with cljs.analyzer and stuff#2019-02-0412:52thhellerso shadow-cljs is out of the picture at that point#2019-02-0412:53thhellermaybe it would work. I don't know, someone else would need to dig into it a bit#2019-02-0417:05darwinhi, maybe I could shed some light on it, dirac agent is non-issue, it is just a proxy between nrepl server and dirac’s client in web browser, the problem is nrepl middleware responsible for translating clojurescript to javascript on server side, shadow-cljs uses their own middleware (originally forked from piggieback), dirac uses their own middleware - dirac would have switch using shadow-cljs middleware for this job#2019-02-0417:06thhellernothing ever forked from piggieback in shadow-cljs 😉#2019-02-0417:07thhellerI'm just trying to emulate it so other tools are happy 😉#2019-02-0417:07darwinI guess I had a similar issue with figweel, I wanted to use it’s cljs compiler state to drive evals of cljs code coming from dirac REPL#2019-02-0417:07thheller@darwin what do you actually need for dirac though? I'd expect that access to the compiler env is enough?#2019-02-0417:07darwinI had to do some glue code to bridge it#2019-02-0417:07darwinhttps://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/figwheel.clj#2019-02-0417:08darwinwe would have to do something along these lines: https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#dirac--figwheel#2019-02-0417:09thhelleryeah I couldn't follow those graphs. didn't compute in my head.#2019-02-0417:10darwinyep, it gets too complex, even I cannot keep it in my brain RAM#2019-02-0417:14thhellernot quite sure why you doing all this nrepl mess when you are running something in the same VM already#2019-02-0417:17thheller(diract.agent/boot! {:eval-fn ... :env compiler-env-atom}) seems to me like it would be#2019-02-0417:17thhellerseems like those are the only two things you need#2019-02-0417:17darwinjust correction, I wanted to write that dirac middleware was forked from piggieback, did a wrong edit there ^ 🙂#2019-02-0417:17thhellereval-fn as a function taking a string or form and returning the result#2019-02-0417:18thhellernot sure why the whole nrepl stuff is necessary but I honestly don't know at all what you do so you probably have your reasons 🙂#2019-02-0417:19darwinI don’t remember the reasons, but the thing was created without prior design incrementally, the figwheel support was added later#2019-02-0417:20darwinI started with piggieback + nrepl proxy (dirac agent) until I realized it won’t work in some cases and then I needed to rewrite it#2019-02-0417:21darwindirac agent does not necessary need to run inside the same JVM, only nrepl middleware has to#2019-02-0417:22thhellerwell how often is that important 😉#2019-02-0417:24darwinnever#2019-02-0417:25darwinbtw. here it the high-level code responsible for eval: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/utils.clj#L121 I need cljs compiler which is either normal cljs or figwheel, compiler env is part of nREPL session state I believe (same what piggieback does)#2019-02-0417:27darwinhttps://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/utils.clj#L133 here is the dirty job: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/eval.clj#L219 I don’t remember why it has to be so complex, but it had to be for some reason#2019-02-0511:09mhueberthmm, was :external-config at some point explained in the docs? I recall reading about it at some point, and it saved my bacon yesterday, but I can’t find a good explanation anywhere#2019-02-0512:02mhuebertI’ve posted a gist of one way I have been handling injection of environment variables using a shadow-cljs build hook and juxt/aero: https://gist.github.com/mhuebert/a87795a74bf3f3452e6b032f1c7ee25d#2019-02-0512:04mhuebertIt seems like a bit more ceremony than I would like but is the cleanest way I have found (so far) to satisfy all my requirements.. I would be very happy to discover ways to simplify it#2019-02-0512:47thhellerI guess it is time I finally write down how to do runtime configuration for CLJS 🙂#2019-02-0512:48thheller:external-config and the macro approaches break the assumptions made by the caching stuff so it very likely breaks caching in some way#2019-02-0512:49mhuebertyes, whenever that config changes, the whole app recompiles#2019-02-0512:49thhelleryeah thats the nuclear option I added for external config#2019-02-0512:49thhellersince there is no other way to tell what it may affect 😛#2019-02-0512:50mhuebertI tried another approach where I compared the prev-config to current-config, and conditionally added just the env namespace to :cache-blockers if things had changed, but that never worked for the first compile#2019-02-0512:50mhuebertso changes to the config while the server wasn’t running, or re-running with a different release flag, wouldn’t get picked up#2019-02-0512:51mhuebertthat actually looked like it might be a bug or nuance with how :cache-blockers works#2019-02-0512:51thhelleryou can skip the hook though and just
(defn release
  "Build :browser release, with advanced compilation"
  ([] (release "local"))
  ([release-flag]
   (-> (shadow-config/get-build! :browser)
       ;; note, we add ::release-flag to our build-config, we need this later.
       (assoc-in [:compiler-options :external-config ::env] (read-env :release))
       (shadow/release* {}))))
#2019-02-0512:52mhuebertfor release that would work, but not for watch#2019-02-0512:53mhuebertfor watch we need something to happen to on every recompile, no?#2019-02-0512:53thhellerwell the problem here is that you are treating runtime configuration like you would in clojure#2019-02-0512:53thhellerbut what you are actually turning it into is compile time constants#2019-02-0512:54thhellerwhich isn't actually what you want#2019-02-0512:54mhuebertit is both runtime and compile time configuration
#2019-02-0512:54mhuebertthe stuff is also exposed to macros, for DCE etc#2019-02-0512:54thhellereek 😛#2019-02-0512:56mhuebertthe idea is to have a single config map which gives you the same benefits as goog-define-ing things#2019-02-0512:56mhuebertread via aero so you can pull in system environment variables or keep things in the edn directly#2019-02-0512:57thhelleryou only get goog-define via actual goog-define#2019-02-0512:57mhuebert
(defmacro goog-define*
       "Like goog-define, but reads `k` from `env/config` at compile time "
       [name k default]
       `(~'goog-define ~name ~(get config k default)))
#2019-02-0512:57mhuebert^works with the above approach#2019-02-0512:58thhellerhmm ok so you use them as actual goog-defines just with different defaults#2019-02-0513:02thhellerhmm I think your hook solution is the cleanest way#2019-02-0513:02mhuebertso the single config map is exposed as a plain map in cljs-land, and then i only use that goog-define* bit when I want DCE. We also have some clj scripts which rely on the config being available in clojure-land (generating static html from hiccup, some other deploy-related tasks)#2019-02-0513:02thhelleryou just can skip the entire custom build function#2019-02-0513:03thhellerah nope .. you have three profiles#2019-02-0513:03mhuebertre: the custom build function, i just couldn’t figure out how to pass in my own command line argument#2019-02-0513:03thhellermeh ... I hate env variables so much for compiling stuff#2019-02-0513:04thhelleralright 2second example: in a browser app I recommend passing runtime config via the HTML#2019-02-0513:04thhellerso assuming you generate it on the server#2019-02-0513:05thhelleryou call <script>your.app.init(some-json-config-data);</script>#2019-02-0513:05thhelleror you load it via xhr (depends on the app you have)#2019-02-0513:05thhellerthings like the url you use in your example should probably come from the html directly since the server probably knows these things#2019-02-0513:06thhelleror if just static stuff you just have a index-dev.html index-staging.html index.html for prod#2019-02-0513:06mhuebertyeah, server or compile environment. this is all just deployed to s3 but we generate the index.html from hiccup in a post-compile build hook#2019-02-0513:07mhuebertso it would just be index.html but generated specifically for the current env#2019-02-0513:07thhelleryes#2019-02-0513:08thhellerI tried describing my approach a long time ago https://code.thheller.com/blog/web/2014/12/20/better-javascript-html-integration.html#2019-02-0513:08thhellerthis is what I do#2019-02-0513:08mhuebertand currently that build hook can seamlessly read from the same app.env/config var that is exposed to cljs#2019-02-0513:09mhuebertand we can also put things like :devtools false in the same config map, which needs to be a compile-time flag to keep stuff out of prod builds#2019-02-0513:10thhellerdo you have an example of something that should actually be a compile time constant?#2019-02-0513:10thhellerie. something that affects DCE?#2019-02-0513:10mhuebertwell, our devtools flag#2019-02-0513:11mhuebertwe have an additional tab that is only visible in dev and sometimes staging, and includes a bunch of extra stuff that we don’t want bundled always#2019-02-0513:11thhellerwould that not be solved by using :preloads [your.app.dev-stuff]?#2019-02-0513:12mhueberthmm. not in the way it currently works, it is used as a conditional in a few places#2019-02-0513:12thhelleror do you constantly check (when devtools (do-more-stuff))?#2019-02-0513:12thhellerhmm ok#2019-02-0513:12mhueberteg. in routing (cond-> routes env/devtools? (merge {.. dev routes ..}))#2019-02-0513:13thhellerhmm that for example probably won't be properly DCE'd by closure#2019-02-0513:13thhellerdid you verify that is actually removed and not just disabled?#2019-02-0513:14thhelleror is that a pure closure-define?#2019-02-0513:14mhuebertthat is a closure-define#2019-02-0513:14mhuebertusing that goog-define* macro which reads from the env map at compile time#2019-02-0513:15mhuebertso, a “pure” closure-define but derived from our canonical config#2019-02-0513:16thhellersure. you don't actually gain anything by making it a goog-define since you are never redefining it#2019-02-0513:16thhellerjust something that ends up as (def devtools? false) would have the same effect as far as closure is concerned#2019-02-0513:17thhellereg. (def devtools? (get-config :devtools false))#2019-02-0513:17mhuebertah. that is good to know#2019-02-0513:17thhellerif the get-config is a macro and just emits literals you don't need extra goog-define gimmicks#2019-02-0513:17thhellerhmm although ...#2019-02-0513:19thhellerhmm I'm not sure I can think of a clean way to do this#2019-02-0513:20thhellerdo you ever use watch with a non-dev release-flag?#2019-02-0513:20mhuebertyeah, sometimes I use a prod release flag if i want my local build to talk to the prod api server#2019-02-0513:25thhelleryou could always skip all this entirely#2019-02-0513:25thhellerand just generating a static src/app/env.cljs before starting the compile#2019-02-0513:26thhellerno macro trickery and compiler magic required 😛#2019-02-0513:27mhueberthm. if that is done in a build hook, would shadow notice changes to that file “in time” to invalidate its cache if it has changed?#2019-02-0513:28mhuebertif config variables are read from a static/unchanging map, can DCE still happen? eg. (when (:devtools static-config) ...)#2019-02-0513:28thhellerhmm good point#2019-02-0513:28thhellerno that won't work#2019-02-0513:29thhellerbut the code you generate can just emit a static variable#2019-02-0513:30thhellergenerating something like
(ns app.env)

(def devtools? false)

(def config {:url "foo.bar"})
is easy enough
#2019-02-0513:33mhuebertyeah.. that code-generation looks to me more complicated than what we are doing, where there is a straightforward config map#2019-02-0513:33thhellerwith lots of macro trickery 🙂#2019-02-0513:36mhuebertyeah. although, the macro trickery has a straightforward API once it’s set up, and there is no uncertainty about where a given environment variable is coming from. if you know the release flag, there is just one edn file where you can always look things up. and changes are picked up during recompile#2019-02-0513:36thhellerhmm can't really think of anything other than what you already do#2019-02-0513:37thhellerI could add an option that lets you modify the config before it is used#2019-02-0513:37mhuebertso maybe it is the most minimal thing that solves for the constraints/requirements we’ve accepted#2019-02-0513:37mhuebertis :cache-blockers supposed to work on first compile?#2019-02-0513:37thhellerbut that still wouldn't solve the extra "release-flag" argument#2019-02-0513:38thheller:cache-blockers complete blocks all cache for the namespaces mentioned. yes it works on the first compile#2019-02-0513:38mhuebertnpm run lets you add command line parameters after a --, which are then passed to the underlying script, eg. npm run watch -- staging. that’s actually what we have set up. i could imagine something similar for shadow, allowing parameters at the end to be passed in as command-line-args or something, but I haven’t thought a lot about that.#2019-02-0513:39thhellersure that would be easy but where would you read them?#2019-02-0513:39mhuebertok. I think there might be a bug there, as my previous attempt was dynamically setting :cache-blockers in :compile-prepare stage, and on the first compile it wasn’t recompiling everything that I added to it#2019-02-0513:40mhuebertI would read the *command-line-args* from build hooks#2019-02-0513:40thhelleryou can't really modify the config on :compile-prepare#2019-02-0513:40mhuebertok. in :compile-prepare is where I am setting :external-config#2019-02-0513:41mhuebertthat’s where I re-read the environment and update app.env/config#2019-02-0513:42thhellerhmm yeah but the watch logic will not trigger recompiles if you modify the config there#2019-02-0513:42mhueberthm. i guess that could explain why it wasn’t working on the 1st compile, but seemed to work later#2019-02-0513:43thhelleryou can just set (ns ^:dev/always app.env) to never cache it#2019-02-0513:43mhuebertthat slows everything down a lot#2019-02-0513:44thhellercache-blockers does the same no?#2019-02-0513:44mhuebertyeah, but i was only adding it to :cache-blockers when the config changed#2019-02-0513:45mhuebert
(-> build-state
        (assoc ::prev-config public-config)
        (update-in [:shadow.build/config :cache-blockers] (if env-changed?
                                                            #(conj % 'web3.env)
                                                            #(remove #{'web3.env} %))))
#2019-02-0513:45thhellerthat has no effect#2019-02-0513:45mhuebertthat seemed to work as intended except for the 1st compile#2019-02-0513:46mhuebertbut maybe it was always only affecting the next compile?#2019-02-0513:47thhellerso assuming the file is not compiled and cached already#2019-02-0513:47thhellerin watch the file will be compiled once and after that kept in the compiler state#2019-02-0513:47thhellerif the file is touched on the filesystem the version in the compiler state is invalidated#2019-02-0513:48thhellerif a file is in the compiler state and not otherwise affected it won't be recompiled#2019-02-0513:48thhellerso if you add cache-blockers after it is already compiled nothing happens?#2019-02-0513:49thhellerah no it works but since the first compile was cached and written to disk#2019-02-0513:49thhellerthe next time you compile if can load that#2019-02-0513:49thhellermeh this makes my head hurt even thinking about it 😛#2019-02-0513:49mhueberthehe#2019-02-0513:51mhueberti think i need to have a look at the source#2019-02-0513:52thhellerhmm no I can't see how changing cache-blockers affects anything once a file is compiled and in memory#2019-02-0513:53thhellerconfig changes typically trigger a fill reconfigure and recompile#2019-02-0513:53thhellersource file changes only trigger a partial recompile#2019-02-0513:55mhuebertyou mean this part
(let [output (get-in state [:output resource-id])]
    ;; skip compilation if output is already present from previous compile
    ;; always recompile files with warnings
    (if (and output (not (seq (:warnings output))))
      output
      (maybe-compile-cljs state src)
      ))
#2019-02-0513:56thhelleryes#2019-02-0513:58mhuebertwell, now i am wondering how it was working before#2019-02-0514:01mhuebertso seq-compile-cljs-sources uses that code, par-compile-cljs-sources calls maybe-compile-cljs directly without that output check but is not used for partial incremental compiles#2019-02-0514:02thhellerseriously?#2019-02-0514:02mhuebertunless i am misreading#2019-02-0514:02thhellerhehe indeed#2019-02-0514:03thhellerah nvm. it does the same logic though#2019-02-0514:03thhellerhttps://github.com/thheller/shadow-cljs/blob/cbd91dfad8b972773b50a8b26dee032af90185da/src/main/shadow/build/compiler.clj#L890#2019-02-0514:03mhuebertah, yes#2019-02-0514:06mhuebertwell, this isn’t so important anyway, for our purposes :external-config is fine, and we can live with recompiling everything when config changes, as that is not so often. I guess in a hyper-optimised world we would figure out how to add a particular namespace to the list of things-to-recompile from within a :compile-prepare hook.#2019-02-0514:09mhuebert(update state :output dissoc resource-id)?#2019-02-0514:09thhellerwould something like shadow-cljs release app --config-hook "(your.ns/some-fn 1 2 3)" help?#2019-02-0514:10thhellerso (your.ns/some-fn config-from-file 1 2 3) would be called whenever the config is loaded?#2019-02-0514:10thhelleryes if you remove the :output it will recompile#2019-02-0514:11thheller(shadow.build.data/get-source-id-by-provide state 'app.env) will you you the proper resource-id#2019-02-0514:12thhellerprobably should use (shadow.build.data/remove-source-by-id state resource-id) instead of just removing the output#2019-02-0514:14mhuebertif we remove ’app.env, would namespaces that depend on app.env also recompile?#2019-02-0514:15thhellerdepends on if it was cached before#2019-02-0514:15mhueberti am thinking about the --config-hook thing, i don’t fully follow how that fits in#2019-02-0514:15thhellersince the logic will load a cached file from disk when not in memory#2019-02-0514:16thhellerif the cache logic decides that the disk cache was ok then no recompiles happen at all#2019-02-0514:16thheller(not even app.env)#2019-02-0514:16mhueberthmm. so this wouldn’t really trigger a recompile then, because the file isn’t changing#2019-02-0514:17thhelleryes#2019-02-0514:17mhuebertwe would need to remove it from the output and also add it to cache-blockers#2019-02-0514:18thhellerdo you actually need app.env/config on the clojure side?#2019-02-0514:18mhuebertyes - not just the DCE stuff (ie. in macros) but also scripts that generate HTML, interop with Sentry#2019-02-0514:19mhuebertwhich are all triggered in build hooks#2019-02-0514:19thhellerright now it sounds like you are abusing builds hooks a little bit too much 🙂#2019-02-0514:20mhuebertlike
:build-hooks [(app.build/load-env)
                                  (app.build/compile-static-assets-hook)
                                  (app.sentry/push-source-maps!)]
#2019-02-0514:20mhuebert🙂#2019-02-0514:21mhuebertthey are reliable workhorses#2019-02-0514:22thhellerwhy not
(defn release
  "Build :browser release, with advanced compilation"
  ([] (release "local"))
  ([release-flag]
   (-> (shadow/get-build-config! :browser)
       ;; note, we add ::release-flag to our build-config, we need this later.
       (assoc ::release-flag release-flag)
       (shadow/release* {})
       (compile-static-assets)
       (send-source-maps-to-sentry)
       )))
#2019-02-0514:22thhellerseems overkill to run all the hooks all the time in watch? granted I don't know what you do in them but probably the first thing you do is check if they should actually run?#2019-02-0514:25mhuebertyeah, the sentry fn starts with (when (= :release (:shadow.build/mode build-state)) ...)#2019-02-0514:26mhuebertthe static assets are affected by changes to config, so i want those to recompile, and all the heavier bits are memoized so it adds max handful-of-milliseconds#2019-02-0514:27mhueberti previously had these things in the watch/release functions like you have there#2019-02-0514:29thhellerwhat made you move them into hooks?#2019-02-0514:32thhellerI like how far you are pushing things with hooks and stuff though#2019-02-0514:32thhellerinteresting to see what they are used for 🙂#2019-02-0514:33thhellerseems all ok ... just probably want something cleaner for the command line stuff#2019-02-0514:38mhuebertbefore, there were multiple commands that had to be run / coordinated at the right time, in order to get a correct build#2019-02-0514:38mhuebertnow, running the shadow build ensures that everything is created declaratively / at the right time / using a consistent environment#2019-02-0514:39mhuebertit is not really possible to compile the app without simultaneously creating all the appropriate assets#2019-02-0514:40mhuebertit has made it easier for onboarding / booting up in new environments, there is little to remember#2019-02-0514:40mhuebertI think at one point I was hoping to do away with the custom release/watch scripts altogether,#2019-02-0514:40mhuebertthe only reason they are there is for the release flag#2019-02-0514:41mhuebertoverall the build hooks let me substantially simplify our whole build/deploy process#2019-02-0514:41mhuebertthe scripts are hid behind npm scripts, so in practice we run npm run watch -- staging and then it delegates to shadow’s clj-run#2019-02-0514:42thhellerI have been thinking about ways to make configs adjustable from the command line#2019-02-0514:42thhellerie. load the config from the file but also merge in extra values#2019-02-0514:42mhuebertthat has been helpful as i have been able to evolve how this stuff works without breaking anyone’s habits#2019-02-0514:43thhellerI could add shadow-cljs release browser --config-merge '{:some "data"}' for example#2019-02-0514:44thhellercljs.main lets you specify multiple --compile-opts and merges them together#2019-02-0514:44thhellerthat is a good idea imho#2019-02-0514:44mhueberthmm that could be useful. would that be added to shadow’s config and validated according to that schema, or could we put arbitrary keys there#2019-02-0514:44mhuebertif you want to see some real abuse of build hooks, https://github.com/mhuebert/js-interop-example/blob/master/shadow-cljs.edn#L15#2019-02-0514:44thhelleryou could add anything. config spec validation is open.#2019-02-0514:45thhellerhehe wow#2019-02-0514:50thhellerI would probably have outsourced the html generation to an external config somewhere but if you like it there that is fine 🙂#2019-02-0514:51mhuebertfor any real project i would do that#2019-02-0514:51thhellerI've been thinking about this whole static site generation business a lot the past few weeks#2019-02-0514:51mhuebertbut for just a quick sketch i didn’t want to have to create an extra file#2019-02-0514:51mhuebertand 90% of the time for these cljs projects, all i need in terms of HTML is a title, and a couple style tags and script elements#2019-02-0515:13aisamuFor one-off experiments I use the test runner and overwrite its DOM with cljs 😂#2019-02-0514:52mhuebertwhat kind of use-cases are you focused on?#2019-02-0514:53thhellernothing in particular. just looking at what the rest of the world is doing/using#2019-02-0514:53thhellerit all doesn't really fit what I'm doing for work stuff#2019-02-0514:54thhellerjust interested to see what others are doing really#2019-02-0514:54thhellerI have probably never written anything that didn't have a massive backend that was at least as big as the frontend#2019-02-0514:55mhuebertthat function in the build hook, write-assets!, makes use of the :output-dir and :asset-path in the shadow build config, and in :release mode it appends content hashes to paths#2019-02-0514:55thhellerbut the "get something simple out" part for CLJ(S) still sucks compared to something like gatsby or so#2019-02-0520:57gklijsI'm about to transform what's now a tiny cms with nginx-clojure to a static site. First goal is just static html, which should be quite easy, since the back-end is already set up to generate the whole page with just the key of the main content. The cljs part is really simple apart from the cms stuff, just some menu things and image modals.#2019-02-0522:22thosmosMy current app is basically a static thing hosted on Firebase hosting and using Firebase firestore. The goal will be to generate static HTML for each route and use code splitting and module loading per route change, basically like https://zeit.co/now, except on firebase. I'm looking into ways to generate the HTML. I'll probably wind up doing it the same way I did last time with a headless browser that spits out the HTML.#2019-02-0522:22thosmoswould be cool if someone made a shadow-cljs builder for Now#2019-02-0522:23thosmosI looked into doing it, but seemed like more than a few hours of work.#2019-02-0522:27thosmosAlso this looks really interesting: https://github.com/faceyspacey/react-universal-component#2019-02-0522:42thhellerI did some experiments with zeit but as of now I wouldn't want to build a builder for it#2019-02-0522:42thhelleryou are only allowed 100mb cache for builds which isn't even enough for the JVM you'd need to download#2019-02-0522:44thhellercompiling things locally and just using now tools to push them seems best#2019-02-0522:46thhelleror via CI of course. eg. https://github.com/jntn/haiku/blob/master/.travis.yml#2019-02-0514:55mhuebertyeah#2019-02-0514:56thhellerI always use the manifest.edn for that https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifest#2019-02-0514:57thheller(granted that I always have a server that consumes that file at runtime)#2019-02-0514:57mhuebertthis project has a big backend for the api server, but it doesn’t generate any html, the web app is all on s3#2019-02-0515:00mhuebertso deployment happens via aws CodeBuild, a remote box performs the shadow build and spits all the html / js to disk#2019-02-0515:00mhuebertall triggered by pushing to specific branches on GitHub#2019-02-0515:02mhuebertI have used manifest.edn as well. i ended up writing something more general because we needed the same cache-busting stuff for generated html and css also#2019-02-0515:02mhuebertour hosting is configured to cache everything except index.html et al very aggressively#2019-02-0515:04thhelleryeah makes sense. Just surprised that shadow-cljs is used to drive it all#2019-02-0518:53souenzzoMy JVM returns
(System/getProperty "java.version")
=> "11.0.1"
There is 2 ways to get "11" in my system
{"java.specification.version" "11"
 "java.vm.specification.version" "11"}
https://github.com/thheller/shadow-cljs/blob/1485cbefc62d781ca5bc1ddf3464833c75771f2e/src/main/shadow/cljs/devtools/server/npm_deps.clj#L12
#2019-02-0604:57jorda0megafor the calva plugin in vscode, is there a way to pretty print the results on the terminal window?#2019-02-0615:07anmonteiro@thheller Hey Thomas, I think we might have run into a weird bug in shadow cljs#2019-02-0615:07anmonteiroshadow.cljs.util/is-jar? does a simple endsWith check to see if the string is a jar#2019-02-0615:07anmonteirohowever in our internal setup, Buck generates directories that end with .jar ¯\(ツ)/¯#2019-02-0615:08anmonteirothat’s causing a weird error in our build#2019-02-0615:08thhelleroh?#2019-02-0615:08thhellerhehe doh#2019-02-0615:08anmonteiro
FileNotFoundException: /Users/anmonteiro/Documents/github/ladder/buck-out/gen/src/ladder/__common_lib__/common.jar (Is a directory)
        java.util.zip.ZipFile.open (ZipFile.java:-2)                        
        java.util.zip.ZipFile.<init> (ZipFile.java:219)               
        java.util.zip.ZipFile.<init> (ZipFile.java:149)             
        java.util.jar.JarFile.<init> (JarFile.java:166)              
        java.util.jar.JarFile.<init> (JarFile.java:130)           
        shadow.build.classpath/find-jar-resources* (classpath.clj:455)
        shadow.build.classpath/find-jar-resources* (classpath.clj:452)
        shadow.build.classpath/find-jar-resources (classpath.clj:579)
        shadow.build.classpath/find-jar-resources (classpath.clj:553)     
        shadow.build.classpath/find-resources (classpath.clj:627)    
        shadow.build.classpath/find-resources (classpath.clj:625)            
        shadow.build.classpath/index-path* (classpath.clj:854)        
        shadow.build.classpath/index-path* (classpath.clj:851)
        clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
        clojure.core/reduce (core.clj:6827)             
        clojure.core/reduce (core.clj:6810)                               
        shadow.build.classpath/index-classpath/fn--1940/fn--1941 (classpath.clj:973)
        clojure.lang.Atom.swap (Atom.java:37)                              
        clojure.core/swap! (core.clj:2352)                        
        clojure.core/swap! (core.clj:2345)                        
        shadow.build.classpath/index-classpath/fn--1940 (classpath.clj:973)
        shadow.build.classpath/index-classpath (classpath.clj:972)   
        shadow.build.classpath/index-classpath (classpath.clj:967)    
        shadow.build.classpath/index-classpath (classpath.clj:969)
        shadow.build.classpath/index-classpath (classpath.clj:967)
        shadow.cljs.devtools.server.common/fn--6874 (common.clj:89)   
        shadow.cljs.devtools.server.common/fn--6874 (common.clj:87) 
#2019-02-0615:08anmonteirothis is the relevant stack trace#2019-02-0615:08thhelleryeah I can fix that#2019-02-0615:08anmonteiroexpanded with a little more info#2019-02-0615:09anmonteiro@thheller this is using 2.7.25 btw#2019-02-0615:09anmonteiroI tried to override is-jar? with:
(defn is-jar? [^String name]
  (let [f (java.io.File. name)]
    (and
     (not (.isDirectory f))
     (.endsWith (str/lower-case name) ".jar"))))
#2019-02-0615:09thhelleryeah the check just naively assumes that things ending in .jar are actually jars not directories#2019-02-0615:09anmonteirobut that doesn’t work either because name is just "common.jar" in this case#2019-02-0615:09anmonteiroso I think it’d need to be the full path#2019-02-0615:09anmonteironot sure if that makes things harder or not 😛#2019-02-0615:10thhellernah easy fix.#2019-02-0615:11anmonteirotoot#2019-02-0615:15anmonteirothis also only started happening when I bumped shadow from 2.7.12 to 2.7.25#2019-02-0615:15anmonteironot sure why that would be, but it could be my fault instead of shadow’s#2019-02-0615:15anmonteirogiven that our dep management is pretty gnarly#2019-02-0615:16ccannkind of new to this bit — is there any way to specify a path in shadow-cljs.edn to an npm dependency’s CSS such that it works in dev and in a release artifact?#2019-02-0615:18ccannah I think this is one of those “use other tools for now” bits yeah?#2019-02-0615:19thhellerno CSS is not supported currently#2019-02-0615:20ccannokay cool#2019-02-0615:20ccanndo you know of any tools ppl reach for in this instance?#2019-02-0615:28thhellerI use the node-sass CLI#2019-02-0615:28thhellerhttps://github.com/sass/node-sass#command-line-interface#2019-02-0615:19thheller@anmonteiro nothing in that regard really changed since 2.7.12 so maybe something in your build setup changed?#2019-02-0615:19anmonteiroyeah that might be the case, I need to investigate further#2019-02-0615:22thhellerdoes buck only do this for release builds? some dev features treat files in jars a bit differently and won't warn as aggressively for example#2019-02-0615:22anmonteiroI’m not sure#2019-02-0615:29anmonteirohrm so the difference between 2.7.25 and 2.7.12 in our setup is that the directory ending in .jar is never in the dep graph in 2.7.12#2019-02-0615:29anmonteiroI’m still not sure why that is though#2019-02-0615:32thhellerthat is weird. the error happened when the classpath was indexed which happens before any CLJS compilation is even involved#2019-02-0615:32thheller@anmonteiro 2.7.26 should fix it#2019-02-0615:33anmonteiro💥#2019-02-0615:33anmonteirotrying now#2019-02-0615:33anmonteiroI actually built a jar from master now that I saw your commit#2019-02-0615:33anmonteiro😛#2019-02-0615:33anmonteiroyeah I think it did work#2019-02-0615:33anmonteirothanks!#2019-02-0615:33thhellerwas about to push a release anyways since I wanted to test a new feature I was working on 🙂#2019-02-0615:49anmonteiro@thheller soo there’s another “issue” in 2.7.26 related to this#2019-02-0615:49anmonteiroyou’re now throwing an error classpath entry that is not a directory or jar file#2019-02-0615:49anmonteirobut I’m not sure if you need to be this strict#2019-02-0615:49thhellerwhat the heck? that was supposed to never happen?#2019-02-0615:49anmonteirowe have a shared library .so in the classpath that is neither a jar nor a directory 😛#2019-02-0615:50thhellerthat is allowed? I though java would blow up if you do that?#2019-02-0615:50anmonteiroI think it is, for bindings to native code#2019-02-0615:50anmonteirothrough the JNI#2019-02-0615:50anmonteiroI can work around this one, just wanted to provide feedback#2019-02-0615:51thhellerpretty sure that still needs the full filename and can't be the classpath entry itself#2019-02-0615:52anmonteirothis seems to be allowed#2019-02-0615:52anmonteirowe’ve had this for a while and java hasn’t complained#2019-02-0615:53anmonteirowrt why we started hitting this, did you perhaps change anything between 2.7.12 and 2.7.25 wrt. laziness / eagerness?#2019-02-0615:53thhellernothing related to classpath indexing#2019-02-0615:57thheller@anmonteiro pushed 2.7.27 that just silently ignores anything but directories or regular files that end in .jar#2019-02-0615:57anmonteirothank you sir#2019-02-0615:58thhellerthe last related change to the classpath was in 2.7.6 which reworked how symlinks are handled#2019-02-0615:58anmonteiro@thheller does clojurescript need to be a hard dependency for shadow btw?#2019-02-0615:59thhellerno but also yes#2019-02-0616:00thhelleryes because sometimes things are added in master that break shadow-cljs. like when 449 added new bindings in cljs.analyzer that would cause nullpointerexceptions since shadow-cljs didn't properly bind them#2019-02-0616:00thhellerbut since adding them older releases don't work since those bindings don't exist#2019-02-0616:01thhellermost of the time master just works, just sometimes things break so its safer to always set a depdendency#2019-02-0616:01anmonteiroyeah being a hard dep for API compat makes sense#2019-02-0616:01anmonteiroI just asked because we use the "slim" classifier and were getting the normal AOTed compiler on every shadow dep resolution#2019-02-0616:02anmonteiroin fact the whole reason why I found this bug in the first place was because we had 1.10.516 on shadow 2.7.12 and it was telling me clojure.edn didn’t exist#2019-02-0616:02anmonteiroso I went to upgrade shadow#2019-02-0616:03thhellerhmm if you had 1.10.516 you should have had clojure.edn? your dep should always be picked over the shadow-cljs dep?#2019-02-0616:04anmonteiroso it compiled fine without trouble#2019-02-0616:04anmonteirobut when I changed the config.edn file, the browser said the bundle was out of date#2019-02-0616:04anmonteiroand the terminal gave a warning that clojure.edn didn’t exist so it would skip compilation#2019-02-0616:05thhelleroh you are using shadow-cljs straight from npm to resolve deps I assume?#2019-02-0616:05thhelleryeah that currently does not allow setting custom CLJS versions#2019-02-0616:05anmonteiroI don’t know what those words mean 😄#2019-02-0616:05thhelleryou are not using deps.edn or project.clj for deps#2019-02-0616:06thhellerthe npm package is rather strict because people in the past had old clojurescript in their :dependencies#2019-02-0616:07thhellerit should warn if you have have clojurescript in shadow-cljs.edn :dependencies#2019-02-0616:07anmonteiroah#2019-02-0616:07anmonteirothat might be the case#2019-02-0616:07anmonteiro(I didn’t set it up)#2019-02-0616:08thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L214#2019-02-0616:09thhellerI've never used buck. kinda curious to see what it does now 🙂#2019-02-0616:09anmonteiroit’s a pretty frankensetup#2019-02-0616:10anmonteirothis would be the (very outdated) extracted version of it https://github.com/ladderlife/loonie#2019-02-0616:23thhellershadow-cljs already does pretty extensive caching and validation thereof#2019-02-0616:24thhellershouldn't need anything beyond just keeping the .shadow-cljs/builds directory around between compiles#2019-02-0616:55anmonteiroBuck’s notion of caching is a little different, and more holistic#2019-02-0616:59anmonteiro@thheller last issue we’ve found with Shadow#2019-02-0616:59anmonteirowe’re running a fork of shadow actually, because the source maps were embedding our entire source code in production 🙂#2019-02-0616:59anmonteirohttps://github.com/ladderlife/shadow-cljs/commit/8e18cb6219c749219d3d45e778af3b6e7e085aa1#2019-02-0617:00anmonteiro^ this is the current diff we applied to shadow#2019-02-0617:00anmonteirobut we aren’t sure that’s the correct patch#2019-02-0617:00thhellerhappy to make this configurable#2019-02-0617:00anmonteirowe’d love to not run a fork too 🙂#2019-02-0617:00thhellerbut what good are source maps without the sources?#2019-02-0617:01anmonteirowell in the stacktraces we report to sentry we just need to get the filenames and line numbers#2019-02-0617:01anmonteirowe’d rather keep our code private#2019-02-0617:06thhellermakes sense. I'll take a look at it later. https://github.com/thheller/shadow-cljs/issues/434#2019-02-0617:06anmonteirothanks!#2019-02-0623:29thhellerI could use some help in testing this new thing I added today https://clojureverse.org/t/smaller-builds-with-lots-of-js-dependencies/3742#2019-02-0623:30thhellersome before/after numbers would be nice and if it actually works for your builds#2019-02-0711:30anmonteiro@thheller am I right in assuming that we don’t need to use cljs.core/resolve when code splitting with shadow?#2019-02-0711:31thhelleryes and no. all resolve really gives you is the var so if you want to call something from a namespace you otherwise have no access to that is one option#2019-02-0711:32thhelleror you can skip all that and call it via js/#2019-02-0711:33thhellereg. you load a module that includes some.ns/foo. calling (some.ns/foo) may cause a compiler warning. but (js/some.ns.foo) is fine since it doesn't try to load analyzer data for the call#2019-02-0711:33anmonteirohttps://github.com/thheller/shadow-cljs/blob/0e28c615cd75d4cbce27ede7a8f7f70785d42c86/src/repl/code_split/a.cljs
#2019-02-0711:33anmonteiro^ in this example you call (.then #(code-split.c/in-c "from-a"))#2019-02-0711:34anmonteiroshould that be wrapped in resolve then?#2019-02-0711:34thhellerI personally would never use resolve since produces too much code for what you really want#2019-02-0711:34anmonteiroI know it will give a warning, the reason for my original question was to know whether shadow had a special case for this#2019-02-0711:34thheller(eg. the entire var metadata)#2019-02-0711:35anmonteirowhat’s the tradeoff here though?#2019-02-0711:35anmonteiroliving with warnings?#2019-02-0711:35anmonteiroI mean, I’m doing this via a macro so I could just add a ^::ana/no-resolve 😉#2019-02-0711:35thheller
(defn test-fn []
  (-> (loader/load "c")
      (.then #(js/code_split.c.in_c "from-a"))))
#2019-02-0711:36thhellerworks fine without warnings, just need to manually munge it#2019-02-0711:36anmonteirothoughts on my sneaky approach?#2019-02-0711:36thhellerI have plans for making this nicer but nothing concrete yet#2019-02-0711:36thhellersure if you want to write an extra macro for this 😉#2019-02-0711:37anmonteiroyeah that’s a given#2019-02-0711:37thhellerI want this to be possible (loader/load 'code-split.c/in-c (fn [the-val] ...))#2019-02-0711:37anmonteirowe need to write the macro anyway#2019-02-0711:38anmonteirootherwise we’re repeating too much code#2019-02-0711:38thhellerie. load a specific var and let the compiler figure out which module it is in#2019-02-0711:38anmonteirothat sounds nice#2019-02-0711:39thhellermost of my dynamic loading code ends up "cheating" like this currently#2019-02-0711:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/routing.cljs#L107#2019-02-0711:40thhellerso I want to get rid of that 😉#2019-02-0711:41thhellerthe closure compiler folks are apparently working on dynamic import(...) support so that may be another solution in the future#2019-02-0711:41thheller(more similar to what webpack does regarding code-splits)#2019-02-0711:43anmonteironot sure how that would work within Closure#2019-02-0711:43anmonteirobut I’ve been away from the internals for a while#2019-02-0711:44thhelleryeah the entire :modules stuff would need a rework#2019-02-0711:45thhellerbut could potentially end up with something simpler. I do like to have strict control over what my modules look like but webpack is certainly easier to use in that regard#2019-02-0711:45thhellerjust use import(...) and let it split how it likes which is good enough for most cases#2019-02-0712:35anmonteiro@thheller successfully code splitting with React.Suspense metal#2019-02-0713:17orestisOhh that’s nice @anmonteiro — are you using Reagent for that?#2019-02-0713:17anmonteironop#2019-02-0713:17anmonteiroom.next#2019-02-0713:51anmonteiro@thheller got a couple minutes to chat about module loading?#2019-02-0713:55anmonteiroso right now the module loading support in shadow cljs assumes that the modules will be loaded from the current host / origin#2019-02-0713:55anmonteirothis doesn’t really work for us because we host our scripts in a CDN#2019-02-0713:56anmonteiroto make it work, we’d need support for a custom prefix in Shadow’s module loader#2019-02-0713:56anmonteiroor the alternative might be to write our own#2019-02-0713:56anmonteirodepending on what you’d want to support / maintain#2019-02-0713:58anmonteiroor maybe this is already supported and I’m not aware of it#2019-02-0715:23lmanolovHello @thheller, importing of http://recharts.org/ stopped working on 2.7.26 and later versions. I have created a simple test case here: https://github.com/lmanolov/minimal-shadow-cljs-browser/commit/2a1cc97dba7b396f0a005121249db3671282f7dd On 2.7.25 everything works great. On 2.7.26 and later I get the following error:#2019-02-0715:23lmanolov
shadow.js.js:133 Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).default is not a constructor
    at Object.shadow$provide.module$node_modules$recharts$lib$util$Events (Events.js:13)
    at shadow.js.jsRequire (shadow.js.js:122)
    at Object.shadow$provide.module$node_modules$recharts$lib$chart$generateCategoricalChart (generateCategoricalChart.js:63)
    at shadow.js.jsRequire (shadow.js.js:122)
    at Object.shadow$provide.module$node_modules$recharts$lib$chart$LineChart (LineChart.js:9)
    at shadow.js.jsRequire (shadow.js.js:122)
    at Object.shadow$provide.module$node_modules$recharts$lib$index (index.js:376)
    at Object.shadow.js.jsRequire (shadow.js.js:122)
    at Object.shadow.js.require (shadow.js.js:158)
    at app.main.js:4
#2019-02-0716:08lilactownis there a way to tell shadow-cljs that cljs.core et. al. will be provided separately?#2019-02-0716:08lilactownwe have an npm library that is used both in a vanilla JS app with web pack, and a CLJS app with shadow-cljs#2019-02-0716:09lilactown(it’s actually an bunch of separate libraries, some written in JS some in CLJS)#2019-02-0716:09lilactownwe’d like to be able to import into both as an npm lib#2019-02-0716:09lilactownbut right now it is (of course) importing all of cljs.core with the CLJS npm lib#2019-02-0716:11thheller@anmonteiro this is sort of supported via :asset-path as it is just blindly prepended before the file url. so you could use :release {:asset-path ""} which will end up loading #2019-02-0716:11anmonteiroI think I’ve figured that out too 🙂#2019-02-0716:11anmonteiroI think I’m fighting this one last error now#2019-02-0716:12thheller@lubo which recharts version is that? did you maybe upgrade that version too while upgrading shadow-cljs?#2019-02-0716:14lmanolov@thheller the recharts version is 1.4.2 and I haven't changed it while upgrading shadow-cljs#2019-02-0716:15thhellerwell in your example you are using a version range so are you sure that didn't change?#2019-02-0716:15thhellerI'm looking at it now, just want to make sure 😉#2019-02-0716:18anmonteiromy module loading is failing even though I see a successful request for it in the network pane#2019-02-0716:19lmanolov@thheller I just checked with the exact version "recharts": "1.4.2" and it works with 2.7.25 but fails with 2.7.26#2019-02-0716:20thhellerdo you use the :minimize-require option added in that version?#2019-02-0716:21lmanolovno. I have just changed the shadow-cljs version. shall I try this option?#2019-02-0716:21thhellerno I'm just ruling out places I need to look 😉#2019-02-0716:30anmonteiro@thheller do you know how to enable the goog.log logger in prod?#2019-02-0716:30anmonteirobesides setting DEBUG to true..#2019-02-0716:30thhellernot sure no#2019-02-0716:35anmonteiroapparently goog.log.ENABLED#2019-02-0716:51thheller@lubo found the problem, for some reason the compiler thinks the "events" package is unused and just doesn't emit the code for it#2019-02-0716:51thhellerI changed how that is detected so I guess I missed something#2019-02-0716:51thhellerfixing.#2019-02-0716:52lmanolovThanks!#2019-02-0717:40ccannnoob question here: is it possible to access environment vars at compile time? (via cljs or shadow-cljs)#2019-02-0717:40thhellervia macros yes but should be avoided#2019-02-0717:41ccannis the recommendation to avoid env vars entirely and use compiler optiosn?#2019-02-0717:41thhelleryou can use :closure-defines {some.goog-define/var #shadow/env "FOO"} in the config#2019-02-0717:42thhellerthat will use the FOO env var in place of that var#2019-02-0717:42thhellerso in the ns you just do (goog-define THING "default value")#2019-02-0717:43ccannwow, okay, great! thank you#2019-02-0717:43ccannI missed that in the docs#2019-02-0717:43thhellerthis question has come way too often in recent times ... I'll definitely write some docs about this soon 🙂#2019-02-0717:43thhelleryeah its not in the docs 😉#2019-02-0717:43ccannahh there we go haha 🙂#2019-02-0717:46ccannif you have a patreon or donations page or similar please let us know 😄#2019-02-0717:59ccannis it possible that this technique ignores the default value of goog-define?#2019-02-0718:00thhellerwell you are replacing it with the FOO env vars so yes thats kinda the point 🙂#2019-02-0718:01ccannoh ok so if FOO isn’t set it won’t default to "default value"#2019-02-0722:41thhellerI changed this behavior in 2.7.30 and now no FOO will actually use the default value instead of an empty string.#2019-02-0722:42thhellerAlso documented things a bit here https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2019-02-0718:01thhellerif you only want to do that for release builds you can do :release {:closure-defines {some.goog-define/var #shadow/env "FOO"}}#2019-02-0718:01thhelleryes it will use an empty value if FOO is not set#2019-02-0718:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-02-0718:02ccannawesome#2019-02-0718:02thhellerall this is a bit messy at the moment. I have plans to make this a bit cleaner#2019-02-0718:40thheller@lubo should be fixed in 2.7.29. thanks for the report.#2019-02-0719:06lmanolov@thheller I checked it with 2.7.29 and it works perfectly. Thank you very much for the quick fix!#2019-02-0719:39anmonteiro@thheller I’m absolutely in love with:
Module Entry "ladder.views.api" was moved out of module ":static-pages".
It was moved to ":main" and used by #{:static-pages :main}.
#2019-02-0719:39anmonteirowell done#2019-02-0719:40anmonteirotells me I need to remove a require#2019-02-0719:40anmonteirowhich I tend to forget 😓#2019-02-0719:40thhellerhehe yeah me too 🙂#2019-02-0719:53anmonteiro@thheller the only thing that feels weird to me having done code splitting in bare CLJS is how module ids become strings out of keywords#2019-02-0719:54anmonteiromaybe this is for historical reasons / backwards compat?#2019-02-0719:55thhellerI added a new thing today which might be useful to some people here. https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-02-0719:56thheller@anmonteiro the shadow.loader is written in JS since I wanted to be able to use it without CLJS. eg. create a tiny initial loader that then loads the rest#2019-02-0719:57thhellercljs.loader always makes the assumption that cljs.core is in the base which I didn't want to force#2019-02-0719:57thhellerbut yeah it should probably support keywords, I don't like that part either#2019-02-0719:57anmonteirohttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#2019-02-0719:57anmonteirofrom what I see it just gets an argument and forwards it#2019-02-0719:57anmonteiroso that argument could actually be anything#2019-02-0719:58thhellerno it must be a string since the module manager expects a string#2019-02-0719:58anmonteiromaybe if it were a keyword you’d have to str it?#2019-02-0719:58anmonteirogotcha#2019-02-0719:58anmonteiroyeah, and that would introduce a dependency on cljs.core#2019-02-0719:58anmonteirothat makes sense#2019-02-0719:58thhelleryeah but the real problem I want to remove is that you need to remember which module to load#2019-02-0719:58thhelleryou should just be loading namespaces and let it figure out which module it is in#2019-02-0719:59thhellerit could still call id.toString() and remove : if it starts with that#2019-02-0719:59thhellerthat would make it work with keywords without depending on cljs.core#2019-02-0720:02thhellerbbl#2019-02-0722:39thheller@mhuebert this may be useful for your builds, new in 2.7.30. https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2019-02-0723:43mhuebertLooks great!#2019-02-0809:58anmonteiro@thheller I’m seeing flaky builds on our build with shadow related to (I think) macroexpansion#2019-02-0809:59thhellerhow so?#2019-02-0809:59anmonteiroin a macro we expect a Clojure var to exist (we resolve a symbol) but the result of resolve is coming up nil on and off#2019-02-0810:00thhellerthat probably is related to parallel compilation (which is why resolve is a bad idea)#2019-02-0810:00anmonteirohah!#2019-02-0810:00anmonteirothat makes sense#2019-02-0810:00anmonteiroresolve is on the Clojure side btw#2019-02-0810:00anmonteiroduring macroexpansion#2019-02-0810:01thhellerif you have no explicit dependency on a namespace there is no guarantee it will be compiled when you expect it to#2019-02-0810:01anmonteirowe have an explicit dependency on that namespace under a :clj reader conditional#2019-02-0810:01anmonteirowhich is why this feels puzzling to me#2019-02-0810:02anmonteiroI’ll try with :parallel-build false#2019-02-0810:03thhellerthat is not supported 😉#2019-02-0810:03thhellerhang on a sec and lets track this down properly 😉#2019-02-0810:03thhelleryou call resolve in a macro to resolve a CLJ var?#2019-02-0810:03anmonteiroyeah#2019-02-0810:03anmonteirohow is that not supported? 😄#2019-02-0810:03anmonteiroI thought it was#2019-02-0810:04anmonteirolet me give you a proper example#2019-02-0810:05anmonteiro
(defmacro lazy-load
  [module-id comp-sym]
  (let [comp-var (ana/resolve-var (dissoc &env :locals) comp-sym)
        comp-name (with-meta (:name comp-var) {:cljs.analyzer/no-resolve true})]
    `(LazyComponent. ~(get-query @(resolve comp-sym))
                     (fn []
                       ;; shadow loader callback, not important right now
                       (-> (~(with-meta 'shadow.loader/load {:cljs.analyzer/no-resolve true})
                            ~(name module-id))
                           (.then (fn []
                                    (resolve# (cljs.core/js-obj "default" ~comp-name)))))))))
#2019-02-0810:05anmonteiro@thheller ^ this is literally the code I’m running#2019-02-0810:05anmonteirothe important part is ~(get-query @(resolve comp-sym))#2019-02-0810:06anmonteirothat’s a fully qualified symbol for which we have a require in the NS declaration (on the Clojure side)#2019-02-0810:06anmonteirothe goal here is basically to inline the Om Next query to allow for code splitting - but that’s not important right now#2019-02-0810:15thhellerhmm I don't get it? why are you calling resolve? that looks like you are trying to resolve a CLJS var using CLJ resolve?#2019-02-0810:16thheller(with-meta 'shadow.loader/load {:cljs.analyzer/no-resolve true}) this also doesn't make sense to me?#2019-02-0810:16thhellerand what is resolve#?#2019-02-0810:17anmonteirothat’s not the part that’s throwing#2019-02-0810:17anmonteiroI actually elided the code a little bit, resolve# is a js/Promise.resolve#2019-02-0810:17thhellerdoesn't make it any more correct#2019-02-0810:17anmonteiro~(get-query @(resolve comp-sym))#2019-02-0810:17anmonteirothis is the part that runs in Clojure#2019-02-0810:18thhelleryes, but why?#2019-02-0810:18thhellercan you gimme an example of the use of that macro?#2019-02-0810:18anmonteirobecause we need that value without requiring the namespace where it’s in#2019-02-0810:19anmonteiroOm Next needs to know the query for the entire app statically#2019-02-0810:19anmonteirowhich is at odds with code splitting#2019-02-0810:19anmonteiroso we inline it at build time#2019-02-0810:20anmonteiroopen to other suggestions if you’re seeing something I’m not#2019-02-0810:21thhelleralright I don't think this is ever going to work properly#2019-02-0810:21thhellerthe code-split means that you are relying on namespaces that are not available yet#2019-02-0810:21thhellerneither at runtime nor at compile time#2019-02-0810:21anmonteirothey are available at compile time#2019-02-0810:21anmonteirothese are all cljc files#2019-02-0810:21anmonteiroor they should be available#2019-02-0810:22thhellerah I was missing that part#2019-02-0810:22thhellerso these queries exist in CLJ land as well?#2019-02-0810:22anmonteirowe have requires for all these namespace in the clj side#2019-02-0810:22anmonteiroyeah#2019-02-0810:22anmonteirothese builds are flaky, they’re not 100% wrong all the time#2019-02-0810:22anmonteirosometimes they work, sometimes they don’t ¯\(ツ)/¯#2019-02-0810:23thhellerFWIW I'm using code-splitting in fulcro without issues regarding queries. they are just adjusting based on what the current route is#2019-02-0810:23anmonteiroyeah I know#2019-02-0810:23anmonteirowe use a different scheme#2019-02-0810:23anmonteirofor historical reasons it’s too much code to move#2019-02-0810:23anmonteirowe need to adapt#2019-02-0810:24thhellerdo you have an example of a component that gets lazy loaded please?#2019-02-0810:25anmonteiroI really don’t think that matters in this case#2019-02-0810:25anmonteirothey’re standard (defui Component static om/IQuery (query [this] [:query :here]) ... #2019-02-0810:26thhellerhmm but how is the query handled at runtime when the idents are missing?#2019-02-0810:27anmonteirowe have a different setup, it’s not really om next anymore#2019-02-0810:27anmonteirowe don’t need any metadata#2019-02-0810:27thhellerah ok#2019-02-0810:28thhellerso I'm assuming that you are calling (lazy-load :foo some.other.ns/foo) correct?#2019-02-0810:29anmonteiroyep!#2019-02-0810:30thheller
(defmacro lazy-load
  [module-id comp-sym]
  {:pre [(keyword? module-id)
         (qualified-symbol? comp-sym)]}
  `(LazyComponent. ~(get-query @(resolve comp-sym))
     (fn []
       ;; shadow loader callback, not important right now
       (-> (shadow.loader/load ~(name module-id))
           (.then (fn []
                    (cljs.core/js-obj "default" ~(symbol "js" (comp/munge comp-sym)))))))))
#2019-02-0810:30thhellerthis is what I would do#2019-02-0810:30thhellerthe flakiness may be due to reloading issues#2019-02-0810:31thhellermacro reload in general only loads namespaces with the macros themselves#2019-02-0810:31thhellerit doesn't track their dependencies or reload those#2019-02-0810:31anmonteirohrm#2019-02-0810:31anmonteirothis shouldn’t be reloading anything actually#2019-02-0810:32anmonteiroit’s just building the test builds from scratch#2019-02-0810:32thhellerthen cache might get in your way#2019-02-0810:32anmonteiro@thheller I think you missed what the issue was too#2019-02-0810:32anmonteiroyou changed the part that has the comment that says not important right now#2019-02-0810:32thhellersince the query data will just magically become part of the compilation#2019-02-0810:32anmonteirothe part that’s actually failing is the othe rone#2019-02-0810:32anmonteiroalso in this build we have :build-options {:cache-level :off}#2019-02-0810:33thhellerhmm ok so no cache#2019-02-0810:33anmonteiroI think I’m slowly disproving your theories, apologies#2019-02-0810:33anmonteirolet me give you the entire build config#2019-02-0810:33anmonteiroinstead of throwing pieces at you#2019-02-0810:33thhellerhow is it failing when it fails?#2019-02-0810:33anmonteiro
{:cache-root (str temp-dir "/.shadow-cljs")
         :builds {:karma {:target :karma
                          :output-to (str out-dir "/test.js")
                          :ns-regexp (str "^(" (string/join "|" namespaces) ")$")
                          :build-options {:cache-level :off}
                          :js-options {:node-modules-dir node-dir}}}}
#2019-02-0810:35thhelleruhm I'm assuming you are generating the config somehow?#2019-02-0810:35thhellersince that isn't a valid config 😉#2019-02-0810:36anmonteirook sec#2019-02-0810:36anmonteirowhat’s missing?#2019-02-0810:36thhelleryour confirmation that this is generating the actual shadow-cljs.edn 😉#2019-02-0810:37anmonteirooh yeah sec#2019-02-0810:37thhellerok thats fine then#2019-02-0810:37anmonteirothere’s definitely base-config (edn/read-string (slurp shadow-edn)) in here#2019-02-0810:38anmonteiroyeah we’re merging that in#2019-02-0810:38anmonteiroI think those are the relevant bits anyway#2019-02-0810:38thhellerso please expand on what you mean by flaky#2019-02-0810:38thhellerhow is it failing?#2019-02-0810:39anmonteirook so, relevant parts of the stack trace:
File: /var/lib/buildkite-agent/builds/buildkite-5dc4755b74-2mfgf-1/ladder-life/ladder/buck-out/gen/src/ladder/__views-next_cljs_cljs_classpath__/views-next_cljs_symlink_tree.jar/ladder/views_next.cljc
null
#:clojure.error{:source "ladder/views_next.cljc", :line 438, :column 32, :phase :macroexpansion, :symbol ladder.ui/lazy-load}
ExceptionInfo:
	cljs.analyzer/macroexpand-1*/fn--2050 (analyzer.cljc:3792)
	cljs.analyzer/macroexpand-1* (analyzer.cljc:3789)
	cljs.analyzer/macroexpand-1 (analyzer.cljc:3835)
	cljs.analyzer/analyze-seq (analyzer.cljc:3870)
	cljs.analyzer/analyze-form (analyzer.cljc:4061)
	cljs.analyzer/analyze* (analyzer.cljc:4109)
	cljs.analyzer/analyze (analyzer.cljc:4129)
	cljs.analyzer/analyze (analyzer.cljc:4114)
#2019-02-0810:39anmonteirothis is not very informative#2019-02-0810:39anmonteiro
Caused by:
NullPointerException:
	clojure.core/deref-future (core.clj:2300)
	clojure.core/deref (core.clj:2320)
	clojure.core/deref (core.clj:2306)
	ladder.ui/lazy-load (ui.cljc:344)
	ladder.ui/lazy-load (ui.cljc:336)
#2019-02-0810:39anmonteiro^ this is more#2019-02-0810:41thhellerok I suspect that this is due to your namespace setup and parallel-build#2019-02-0810:42thhellertry :compiler-options {:parallel-build false}. forgot that I added support for that not too long ago#2019-02-0810:42anmonteirooh so that actually does something?#2019-02-0810:43thhelleryes it compiles in dependency order which should make things more predictable#2019-02-0810:43anmonteirodo you think adding cache-blockers in this case would do anything?#2019-02-0810:43thhellerit still might fail though#2019-02-0810:43thhellernot if you already have all cache disabled anyways#2019-02-0810:43anmonteiroyeah I’m gonna try something different too#2019-02-0810:43anmonteirorelated to our internal setup#2019-02-0810:43thhelleryou may wanna try :cache-level :jars#2019-02-0810:44anmonteiroif you say caching is affecting things here#2019-02-0810:44thhelleroh wait .. .nvm you don't have jars 😛#2019-02-0810:44anmonteiroyeah we don’t#2019-02-0810:44anmonteirobuck extracts them#2019-02-0810:44thhellerthat was before you said it is disabled#2019-02-0810:44anmonteiroright#2019-02-0810:44anmonteiroI meant other type of caching#2019-02-0810:44anmonteirowe have a “tainted clojure worker”#2019-02-0810:44anmonteirowhich is a type of clojure worker that we keep around in a pool#2019-02-0810:45anmonteirothat has done other compilation stuff before#2019-02-0810:45anmonteirothat we reuse, to avoid starting up#2019-02-0810:45anmonteiroso if you say caching might be a problem here, I’m gonna force this to run in a regular worker#2019-02-0810:45thhellerwell that may be a problem regarding the CLJ part of things#2019-02-0810:45anmonteirowhich is what’s happening here 🙂#2019-02-0810:46thhellerbut if it is loading the same files that is not a problem#2019-02-0810:46thhelleronly a problem if you have multiple versions of the same CLJ namespace#2019-02-0810:48thhellerthe NPE likely happens when you try to (lazy-load :foo 'some.other/thing) and some.other/thing isn't loaded on the CLJ side#2019-02-0810:48thhellerwhich may be a missing require that would sometimes get loaded by other namespaces during parallel compile#2019-02-0810:48thhellerso it may appear to be available sometimes given how busy your compile threads are#2019-02-0810:50thhellerwithout parallel-build and a clean worker the build should always fail with the NPE in the case of a missing require on the CLJ side#2019-02-0810:52anmonteiro@thheller the require is 100% not missing#2019-02-0810:52anmonteiroand it’s in the classpath for sure too#2019-02-0810:52anmonteiroI’ve triple checked#2019-02-0810:53anmonteirothe thing I haven’t ruled out yet is the tainted persistent worker#2019-02-0810:54thhelleryou can always add a (prn [:resolve (resolve comp-sym)]) in the macro#2019-02-0810:55anmonteiroI did#2019-02-0810:55thhellerthat will only confirm that the symbol is nil but still#2019-02-0810:55anmonteiroyeah the result of resolve is nil#2019-02-0810:55thhelleryou can add the (prn [:loading-that-namespace]) to the namespace the resolve is referencing#2019-02-0810:55thhellerwhich will probably be missing#2019-02-0810:56anmonteiroindeed, I’ll try that#2019-02-0810:56thhellerof you can fire a require for the sym to ensure#2019-02-0810:56thhelleralthough you gotta be careful with that or use the new require thing in 1.10#2019-02-0810:57anmonteiroyeah that’s the last option#2019-02-0810:57anmonteiroyeah requiring-resolve might help me here#2019-02-0810:57thhellerthe one that locks the require#2019-02-0810:57thhelleryeah that one#2019-02-0810:57anmonteiroor however it’s called#2019-02-0810:57thhellerotherwise one thread may start the require and another thread may start using it while it is still loading#2019-02-0811:31anmonteiro@thheller I think moving it to the non-tainted worker made it work - even though the build is taking a lot longer (expected). so I’ll just use requiring-resolve, otherwise the build time is infeasible#2019-02-0811:32thhellerwithout any caching the build times can go up very significantly yes#2019-02-0811:33thhellerparallel-build shouldn't make that much of a difference overall, depends on how parallelizable your compile is#2019-02-0811:35anmonteirono I mean we have a bunch of “targets” that we build separately (because Buck)#2019-02-0811:35anmonteiroso we really need to have some compile cache (especially on the Clojure side) between building and running those targets#2019-02-0811:35thhellerah#2019-02-0811:35anmonteirothat’s what the tainted worker does for us#2019-02-0811:36anmonteirobtw this is also why we want Clojure to have a stable ABI#2019-02-0811:36anmonteiroit would make all this much easier#2019-02-0811:37anmonteiro@thheller maybe I can nerdsnipe you into making ClojureScript have a stable ABI 😛#2019-02-0811:37anmonteiroe.g. through shadow#2019-02-0811:38thhellerwhat does that mean to you?#2019-02-0811:38anmonteirorequiring-resolve made the build work instantly#2019-02-0811:38anmonteiroit means that if you can have truly separate compilation#2019-02-0811:39anmonteirosay you have namespaces:
A
  /   \
B     C
#2019-02-0811:40anmonteirotriggering a change in C shouldn’t need for A or B to get recompiled#2019-02-0811:40anmonteiroand this goes further than having the transit cache too#2019-02-0811:40thhellerthats already how it works?#2019-02-0811:40anmonteiroit’s not, really#2019-02-0811:41thhellerwell I guess you want to isolate it more by keeping it entirely out of process#2019-02-0811:41anmonteirobecause if you compile A and exit#2019-02-0811:41anmonteirothen compile B#2019-02-0811:41anmonteirothe 2nd run still does some work for A#2019-02-0811:41thhellerwell it reads the compiler cache for A#2019-02-0811:41thhellerbut thats it?#2019-02-0811:42thheller(assuming you have cache enabled of course)#2019-02-0811:42anmonteiroI don’t think that’s the only work it does#2019-02-0811:43thhellerit doesn't do any compiler work, it does a bit to restore cache into the right places and stuff#2019-02-0811:43anmonteiromaybe in the example I gave it is#2019-02-0811:43anmonteirobut once you have a more complex dep graph there’s lots of work happening that wouldn’t need to happen#2019-02-0811:44thhellerhmm no not really. the caching stuff ensures that only the work that needs to happen actually does happen#2019-02-0811:44thhellervalidating the cache and loading it is a bit of work yes but involves no actual compiler work#2019-02-0811:45anmonteiroI’m pretty sure I’m forgetting something here
#2019-02-0811:45anmonteiroI’m fuzzy on the details#2019-02-0811:45thhellerwell cache invalidation sometimes invalidates too much#2019-02-0811:46anmonteirothe gist of the issue is: if you have a build tool that calculates your dep graph already, you don’t need the cljs compiler trying to do it for you too#2019-02-0811:46anmonteiroand then all the consequences that that entails#2019-02-0811:47thhellerwell but how does your tool compute the dep graph? that is a non trivial task?#2019-02-0811:47thhellerie. parse all the ns forms of all namespaces, account for macros, npm dependencies, resolve all those with all the "browser" rules and stuff#2019-02-0811:48anmonteiroBuck does#2019-02-0811:49anmonteirowe parse the NS deps#2019-02-0811:49anmonteiroand hand it to buck#2019-02-0811:49anmonteirothen we auto generate a file with all the deps#2019-02-0811:49anmonteirogiven it needs to be static#2019-02-0811:52thhellera rather big chunk of shadow-cljs is determining when to cache and when to recompile#2019-02-0811:52thhellerso I don't quite unterstand why you'd want to repeat that in buck#2019-02-0811:53anmonteiroit’s not that we want#2019-02-0811:54anmonteiroit’s that Buck already does it for us#2019-02-0811:54anmonteiroand has a distributed cache, so if we built something on CI, Buck just downloads it to our laptops#2019-02-0811:55anmonteiroin fact we actually let Shadow take over when building CLJS#2019-02-0811:55anmonteiroso we don’t actually enforce the Buck best practices when using Shadow#2019-02-0811:56thhelleris there some extra data I could output that would be useful for Buck?#2019-02-0811:56anmonteirosimply because we’d need to get out of our way to do it with lots of custom / brittle code#2019-02-0811:56anmonteiroI’m not sure. I’m gonna raise that question internally#2019-02-0811:56anmonteiroI don’t think it’s that easy#2019-02-0811:57anmonteirothe whole compilation model would need to be different#2019-02-0811:59thhelleris your Buck interface to CLJS something open source?#2019-02-0812:03anmonteirohttps://github.com/ladderlife/loonie/tree/master/tools/clojurescript#2019-02-0812:03anmonteirothis is very outdated#2019-02-0812:03anmonteirobut it’s how we used to do it with the bare CLJS compiler#2019-02-0812:03anmonteiroshadow now takes over#2019-02-0812:15thheller> The biggest benefits of using buck come from using the artifact cache. It's especially useful if you have several developers working on the same codebase since the cache can be distributed. You may also see better CI times with buck caching if you configure your CI to cache the buck-out directory between runs.#2019-02-0812:15anmonteiroyup!#2019-02-0812:15thhellercache .shadow-cljs/builds and you get that for CI as well#2019-02-0812:15anmonteiroright but we already bought into buck#2019-02-0812:15anmonteirojust so we get that for Clojure code too#2019-02-0812:15anmonteiroto be fair this might be one of those things where you have to experience it to believe it#2019-02-0812:16anmonteiroI was this way too#2019-02-0812:19thhelleryeah I don't know Buck at all so I don't know how it does things#2019-02-0812:22thhellerthis is a verbose compile log of a test build that is fully cached#2019-02-0812:23thheller#2019-02-0812:23anmonteiroso rephrasing my earlier statement#2019-02-0812:23thhellerso those are pretty much the steps Buck would have to replicate#2019-02-0812:23anmonteiroI believe that Shadow and the ClojureScript compiler do have intermediate caching and cached builds#2019-02-0812:23anmonteiromy problem is that the ABIs are not stable or public#2019-02-0812:24anmonteiroimagine that in my earlier A, B, C example#2019-02-0812:24anmonteiroif you added one function to A that neither B or C used#2019-02-0812:24anmonteirothose are gonna get recompiled anyway#2019-02-0812:24anmonteirothat kind of fine grained control is something that we could implement if there was actually an ABI#2019-02-0812:24thhelleryes that is true. given the dynamic nature of CLJ(S) that is probably never going to change#2019-02-0812:24anmonteirobrb lunch#2019-02-0812:25thhellerit is something I have been thinking about quite a bunch since it could also speed up live-reloads#2019-02-0812:26thhellerie. you have (defn foo [] 1) in some namespace#2019-02-0812:26thhelleryou change it to (defn foo [] 2) all namespaces that require this will be fully recompiled#2019-02-0812:26thhelleralthough the signature didn't change so its pointless to do that#2019-02-0812:27thhellerso during namespace compiling you track what signatures you used from other namespaces and check if they changed#2019-02-0812:28thhellerthat is quite doable ... but then you add macros and everything goes completely crazy 🙂#2019-02-0812:29thhellerthen you do a requiring-resolve in some macro and things get even more crazy 🙂#2019-02-0812:44anmonteiroyeah#2019-02-0812:44anmonteironow you get it 🙂#2019-02-0813:21thheller@anmonteiro this is somewhat related. how would you teach Buck that also depends on demo/test.md. https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-02-0813:22anmonteirooh that’s trivial I think#2019-02-0813:22thhellerside-effecting macros is not something other languages have to deal with 🙂#2019-02-0813:22anmonteiroBuck targets depend on other targets#2019-02-0813:22anmonteiroso you’d make one target that encompasses the resources folder#2019-02-0813:22anmonteiroand make your JS bundle target depend on that#2019-02-0815:28jlmrHi! When coding clojure I’m using a socket repl (in conjunction with REBL). Now I’m trying to add clojurescript using shadow-cljs, I’m a bit stuck on how to get everything working together. I’m using deps.edn. Can anyone point to a working example?#2019-02-0815:58thheller@jlmr not sure that works yet. I haven't run REBL yet since it doesn't seem to like Java11 and Windows#2019-02-0815:59thhellerI'm not sure what it needs or if its even supposed to be supported#2019-02-0816:09jlmrOk, good to know. For now I got everything going, but without REBL#2019-02-0818:06eccentric JHello I’m trying to use clojure/tools.cli with shadow-cljs but I’m seeing a couple of warnings:
------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: clojure/tools/cli.cljc:126:17
--------------------------------------------------------------------------------
 123 |          (recur options (into extra-args (vec (rest args))) nil)
 124 |
 125 |          (and (opt? opt) (nil? spec))
 126 |          (throw (Exception. (str "'" opt "' is not a valid argument")))
-----------------------^--------------------------------------------------------
 Use of undeclared Var clojure.tools.cli/Exception
--------------------------------------------------------------------------------
 127 |
 128 |          (and (opt? opt) (spec :flag))
 129 |          (recur ((spec :assoc-fn) options (spec :name) (flag-for opt))
 130 |                 extra-args
--------------------------------------------------------------------------------

------ WARNING #2 - :undeclared-var --------------------------------------------
 Resource: clojure/tools/cli.cljc:228:25
--------------------------------------------------------------------------------
 225 |   (when *assert*
 226 |     (let [unknown-keys (keys (apply dissoc map spec-keys))]
 227 |       (when (seq unknown-keys)
 228 |         (binding [*out* *err*]
-------------------------------^------------------------------------------------
 Use of undeclared Var clojure.tools.cli/*err*
--------------------------------------------------------------------------------
 229 |           (println (str "Warning: The following options to parse-opts are unrecognized: "
 230 |                         (s/join ", " unknown-keys)))))))
 231 |
 232 |   (select-keys map spec-keys))
--------------------------------------------------------------------------------
#2019-02-0820:43thhellerthe warning looks legit. CLJS doesn't have a Exception class. I guess someone didn't actually test this much.#2019-02-0820:44thhellercljs also doesn't have *err*#2019-02-0820:50eccentric JOof ok thanks again. I’ll see if an error was reported and report one if it doesn’t.#2019-02-0818:23eccentric JShould I use a different library?#2019-02-0818:31conanI'm getting a compilation error every time I run yarn shadow-cljs watch app:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/mnt/c/Users/conan/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/
cljs/core.cljs:999:14
--------------------------------------------------------------------------------
 996 |     (if (js/isFinite o)
 997 |       (js-mod (Math/floor o) 2147483647)
 998 |       (case o
 999 |         ##Inf
--------------------^-----------------------------------------------------------
No reader function for tag Inf

--------------------------------------------------------------------------------
1000 |         2146435072
1001 |         ##-Inf
1002 |         -1048576
1003 |         2146959360))
--------------------------------------------------------------------------------
Any ideas why? I found some discussion of this error that referred to tools.reader, but it's old and my lein deps :tree says I'm using [org.clojure/tools.reader "1.3.2"]. https://clojurians-log.clojureverse.org/shadow-cljs/2017-10-03
#2019-02-0818:48eccentric JWhat is your use case for tools.reader over the built-in read-string?#2019-02-0820:42thhellercljs.reader/read-string actually uses tools.reader so there isn't any difference#2019-02-0820:42eccentric JOh I see, thanks.#2019-02-0912:41conanIt's a transitive dep pulled by shadow-cljs, I don't use it directly.#2019-02-0819:17idiomancyAnyone ever run into Invariant Violation: Target container is not a DOM element. with shadow? I do have the script tag after the root node in the body#2019-02-0819:18lilactownguessing this is a React app?#2019-02-0819:18lilactownwhat's the code you're using to render#2019-02-0819:18idiomancyreframe. just a sec..#2019-02-0819:19idiomancyI mean, reagent technically. but its... oh...#2019-02-0819:20idiomancy(re/render [admin-panel] (.getElementById js/document "app")) lol, copypaste from old deps.edn code. should be "root" 😂#2019-02-0819:21idiomancyworks now, thanks for the sanity check @lilactown#2019-02-0820:41thheller@conan that is indeed a tools.reader conflict. you can check if you actually get the version you expect by using shadow-cljs clj-repl and ( "cljs/tools/reader.cljs")#2019-02-0912:43conanYep, here's the output:
[1:0]~shadow.user=> ( "cljs/tools/reader.cljs")
#object[java.net.URL 0x1d579f90 "jar:file:/mnt/c/Users/conan/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar!/cljs/tools/reader.cljs"]
#2019-02-0912:43conanlooks like 1.3.2, which I understand to be correct?#2019-02-0820:44thhellerdo you have a profile or something else that may affect the classpath?#2019-02-0912:45conanno profiles, I'm using :lein true and :target :node-library, maybe they affect the classpath? here's my shadow-cljs.edn:
{:lein true
 :builds {:app {:target :node-library
                :exports {:handler conan.core/handler}
                :output-dir "target"
                :output-to "target/main.js"}}}
#2019-02-0912:46thhellerare you sure you are getting the correct versions of the other deps?#2019-02-0912:46conanhere's my project.clj:
(defproject conan "0.1.0-SNAPSHOT"
  :min-lein-version "2.7.0"
  :dependencies [[com.cemerick/url "0.1.1"]
                 [com.taoensso/timbre "4.10.0"]
                 [io.nervous/kvlt "0.1.4" :exclusions [org.clojure/clojurescript]]
                 [org.clojure/clojure "1.10.0"]
                 [org.clojure/core.async "0.4.490"]
                 [thheller/shadow-cljs "2.7.11"]]
  :source-paths ["src/cljs"])
#2019-02-0912:46thhellerclojure 1.9+, clojurescript 1.10.516?#2019-02-0912:49conani have clojure 1.10 but clojurescript 1.10.439. i don't actually specify clojurescript in my deps as i assumed it would be better to let shadow-cljs choose, should i be explicit?#2019-02-0912:49thheller2.7.11 with 439 is correct#2019-02-0912:50conanyeah it all looks like it checks out#2019-02-0912:50thhellerI don't know honestly .. debugging dependency issues is hard. just don't use project.clj#2019-02-0912:50thhellercould be something in your .lein/profiles.clj#2019-02-0912:51thhellerif I use that project.clj the deps look ok#2019-02-0912:51conanoh good idea, but i don't actually have a .lein/profiles.clj. didn't think of it though#2019-02-0912:52thhellereverything compiles and runs fine for me using your project.clj and config#2019-02-0912:53thhellerrunning npx shadow-cljs node-repl since I have none of you sources#2019-02-0912:53thhellerbut that compiles cljs.core which fails for you#2019-02-0912:55conanyeah that seems to be the problem. i'm guessing there are no compilation errors in there...#2019-02-0912:56thhellerthe error you posted is a rather old one and was caused by invalid tools.reader versions#2019-02-0912:56thhellerbut since you checked that you have the correct one#2019-02-0912:56thhellerI don't know what else to check#2019-02-0912:56conanyeah i think there must be something else getting in the way#2019-02-0912:56thhellerif you remove lein and move the dependencies to shadow-cljs.edn and still run into this issue let me know#2019-02-0912:57thhellerotherwise I don't know#2019-02-0912:58conanthanks very much for your help. i'll try starting a new project from scratch and slowly introducing stuff until it breaks (or doesn't). maybe it's just a gremlin ¯\(ツ)/¯#2019-02-0912:59thhellerthere isn't really anything you need to change#2019-02-0912:59thhellerjust try it in your current state#2019-02-0913:00thhellerdo NOT change anything other than removing :lein true and copying :dependencies to shadow-cljs.edn#2019-02-0913:00thhellerif that works you have at least isolated it to leiningen#2019-02-0913:00thhellerstarting from scratch will tell you nothing#2019-02-0823:10jstaabHey there, I'm trying to get a quick turnaround when developing a library against another application I have by running watch on the library and copying the bundle over to my app's node_modules folder and restarting the (create-react-app, which wraps webpack) dev server there. It appears to work fine when I run release, but if I watch, I get Error: browser bootstrap used in incorrect target. Any reason for this or way I can get it to work? I'm using es6 modules, which I believe compile down to require calls. I tried the solution here: https://github.com/thheller/shadow-cljs/issues/376 but it's not exactly my situation and it seemed to make things worse.#2019-02-0823:13currentoorI know in a macro definition we can use (boolean (:ns &env)) to detect if this macro is being used in CLJS code, but is there a way to detect, in a macro, that this macro is being called in regular browser cljs or nodejs?#2019-02-0909:25thheller@currentoor at compile time no. at runtime you can check cljs.core/*target* (will be nodejs) for node targets#2019-02-0909:26thhelleryou could in theory check that at compile time by checking the compiler env but thats not really recommended#2019-02-0909:28thheller@jstaab you don't seem to be using :npm-module? a dev build generates many files and cannot be loaded by webpack unless you use :npm-module#2019-02-0913:41thhellerWould anyone be interested in a new feature that could reduce the startup time of shadow-cljs by about 50% but would require running a separate command that can take a minute or so to run whenever the classpath changes?#2019-02-0913:42thhellerI kinda decided that its not worth the effort but all the code is pretty much finished#2019-02-0913:43thhellerI don't restart shadow-cljs often enough so startup time doesn't matter much to me but others may feel different#2019-02-0913:43thheller(this would be achieved by generating an AppCDS archive as described here https://mjg123.github.io/2017/10/04/AppCDS-and-Clojure.html)#2019-02-0913:45thhellerunfortunately this cannot be pre-generated or so and cannot be shared amount projects since the classpath must match#2019-02-0916:21jstaab@thheller that would be a net gain for me, but might cause some friction for first time adopters if first-run was excessively slow. It would only serve to amplify startup time complaints I'd imagine. By the way, I do love the client-server architecture; that's so much the way to go. As for your suggestion above, I'll try npm-module. I had moved away from that to browser for some reason; I can't remember what problems I'd had.#2019-02-0921:19dpsuttonwondering if anyone might have some insight. My real goal is to use oauthjs but this has a dependency on querystring. So in a blank project, npm i querystring and then in an ns form (:require ["querystring" :as qs]) yields:
[:app] Build failure:
The required JS dependency "querystring" is not available, it was required by "beta/main.cljs".

Searched in:/home/dan/projects/clojure/beta/node_modules

You probably need to run:
  npm install querystring
but
[
#2019-02-0921:21dpsutton(this is the symptom i observe when trying to consume oauthjs but a smallest reproduction)#2019-02-0921:39jstaabI was able to follow those steps and had no trouble. How are you setting up shadow-cljs? The only thing I can think of is the js-provider options: https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider#2019-02-0921:41dpsutton
{:source-paths ["src"]
 :dependencies []
 :builds       {:app {:output-dir "target/"
                      :asset-path "."
                      :target     :browser
                      :modules    {:main {:init-fn beta.main/main!}}
                      :devtools   {:after-load beta.main/reload!
                                   :http-root  "target"
                                   :http-port  8080}}}}
this is how i'm setting it up. have i missed something?
#2019-02-0921:41dpsutton
[
#2019-02-0921:46dpsuttonshadow 2.7.30#2019-02-0921:52jstaabHmm same node and shadow on my end. What happens if you require from node? e.g. node -e 'console.log(require("querystring"))'#2019-02-0921:53jstaabThough I'm not sure if that has anything to do with how shadow resolves dependencies#2019-02-0921:55thheller@dpsutton do you have shadow-cljs installed in your project?#2019-02-0921:56thhellerIIRC querystring is one of those packages that needs a browser polyfill which gets installed when you install shadow-cljs in your project#2019-02-0921:59thhellerjust npm install shadow-cljs in your project (never rely on the global install)#2019-02-0922:02thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/npm.clj#L306 via https://github.com/webpack/node-libs-browser#2019-02-0923:11dpsuttonI didn't have shadow-cljs installed. Doing that seems to have cleared everything right up.#2019-02-0923:12dpsuttonthanks for being so helpful and thorough with your documentation#2019-02-1012:10sogaiuis there an easy way to turn off the nrepl server that starts up with shadow-cljs watch?#2019-02-1012:12thhellerwhy would you?#2019-02-1012:12thhellerno one ever asked for that so there is currently no option to do so#2019-02-1012:12thhellerwould be easy to add though#2019-02-1012:14sogaiuah thanks -- not using nrepl, don't need it to be running -- less resource use, less open ports, etc.#2019-02-1012:30thheller@sogaiu in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c9baa1a8ada6bee4aaa5a3ba89fbe7fee7faf8"}, :content ("[email protected]")} you can set :nrepl false and/or :socket-repl false to disable them#2019-02-1012:33sogaiusounds great! will give it a try#2019-02-1012:50sogaiu@thheller adding :nrepl false to shadow-cljs.edn seems to work as expected in 2.7.31, thanks a lot 🙂#2019-02-1012:55dpsuttonWhat is your workflow if you don't mind sharing. I'm just curious#2019-02-1013:07sogaiuat least in the case of writing packages in cljs for atom or extensions for vscode, nrepl does not seem necessary#2019-02-1016:52lilactownis there a way to inform shadow-cljs to pick up new versions of npm deps I installed?#2019-02-1017:22thhellerthat should happen automatically? npm source files are watched once used#2019-02-1017:35lilactownhm, I ran npm i to grab new React versions that were in my package.json and I had to restart the shadow-cljs process to get it to pick up#2019-02-1110:03thhellershould be fixed in 2.7.32#2019-02-1017:38lilactownI tried shadow/stop-worker and re-running shadow/watch too, was still getting errors due to not being on latest React#2019-02-1017:39thhellerthat doesn't do anything. the cache is shared between workers so restarting the worker won't restart the cache#2019-02-1017:39lilactowngotcha#2019-02-1017:41thhelleropen an issue please. can't check right now but it is supposed to be working.#2019-02-1017:42lilactownkk#2019-02-1018:20Mark AddlemanThe socket repl is not starting up. nRepl server starts and I get a log statement shadow-cljs - nREPL server started on port 9000. There is no corresponding statement for the socket repl. The relevant bits of my shadow-cljs.edn file are
:socket-repl {:port 9001}
 :nrepl  {:port 9000}
#2019-02-1018:21Mark AddlemanAt least, I think those are the relevant bits of the shadow-cljs config. I must be missing something 🙂#2019-02-1020:29thheller@mark340 did you try connecting to post 9001? it just isn't printed but it should be started#2019-02-1021:10Mark AddlemanSo it is. The repl is started but no log output#2019-02-1021:15Mark AddlemanThanks!#2019-02-1020:38hmaurerReally silly question but I have some css files in resources/ which are exposed by my web server and which I include in a page. Is there a way to get the page to live-reload when I change the css? (preserving everything; just updating the css)#2019-02-1020:39hmaurerah nevermind#2019-02-1020:39hmaurerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2019-02-1020:40hmaurergot my answer 🙂#2019-02-1021:11gravAnything to do about an error like this:
[:app] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/qr-scanner/qr-scanner.min.js"]]}
ExceptionInfo: failed to convert sources
  ...
Caused by:
RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Source map's "sources" and "sourcesContent" lengths do not match.
	com.google.javascript.jscomp.PrebuildAst.prebuild (PrebuildAst.java:79)
...
#2019-02-1021:11gravIt is this npm package that’s the issue: https://github.com/nimiq/qr-scanner#2019-02-1021:12thhelleryou can remove //# sourceMappingURL=qr-scanner.min.js.map from the node_modules/qr-scanner/qr-scanner.min.js file#2019-02-1021:13thhellerfirst time I've seen this error. guess clojure is really strict about incorrect source maps#2019-02-1021:14gravCool, will try that!#2019-02-1021:15gravThat did the trick. Thanks!#2019-02-1021:16thheller> Lightweight: 33.7 kB (12 kB gzipped) minified with Google's closure compiler.#2019-02-1021:16thhellerhttps://github.com/nimiq/qr-scanner/blob/master/gulpfile.js#L10#2019-02-1021:17thheller...#2019-02-1021:17thhellerthats not minified at all 😛#2019-02-1021:22gravIsn’t whitespace_only a kind of minification?#2019-02-1021:22thhellerwell yeah its removing whitespace ...#2019-02-1021:23thhellerdoesn't matter much since shadow-cljs will minifiy it properly for you 😉#2019-02-1021:23gravwhich is pretty cool 🙂#2019-02-1021:28gravBtw awesome experience with using npms in general .. after the first error I just npm installed another qr-reader and required that one, without needing to restart, reload or anything. Can any js build pipeline do that?#2019-02-1021:29thhellernot a clue. I basically never used any JS tools in anger 😛#2019-02-1021:30gravhehe 🙂 so shadowcljs is out of anger? great anger management - hats off to you 🙂#2019-02-1021:31thhellerhad to get rid of my own frustrations when working with CLJS somehow 😉#2019-02-1103:00eoliphantis it possible to run say watch with a config that’s passed in without a shadow-cljs.edn? I want to do something like this from figwheel
(fig/start {:id "dev"
              :options {:main (symbol main)
                        :nrepl-port 7002
                        :output-to "target/public/cljs-out/main.js"}
              :config {:watch-dirs paths}})
I have a little code visualizer, that updates a page as you make changes, in a ‘target’ project. got it working with figwheel, but need to to get it working with shadow since most of my ui code uses shadow and figwheel doesn’t understand the string requires, etc. I was poking through the devtools api, and it seems like watch can take a map, but i’m not clear on how that ‘maps’ to whats in the normal config file I guess as a workaround I could create a separate build for it in the project that it’s looking at. but I was trying to keep it as self-contained as possible
#2019-02-1106:20mattlyI'm having a weird issue where despite my locally installed-in-node_modules folder, I have react 16.8.1, but for whatever reason the version getting compiled into my build is 16.7.0#2019-02-1106:23mattlymy guess is there's an old dependency from the project that relied on this and I have a cache to clean#2019-02-1106:24mattly... indeed, rm -rf .shadow-cljs worked#2019-02-1108:40thheller@eoliphant that use-case is not currently supported. you can instruct it to watch without a config file just fine but running the complete shadow-cljs instance isolated is not supported. one design choice I made is only allowing one shadow-cljs runtime per JVM. shadow-cljs.edn is also required currently.#2019-02-1108:40thhellerIf you explain your use-case a bit more I can maybe relax some of those requirements#2019-02-1108:41thhellermaybe the embedded API already solves most of your issues https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2019-02-1109:53thheller@mattly I just fixed a bug where changes to node_modules files were not picked up properly by running watch processes#2019-02-1109:53thhellerare you 100% certain that you fully restarted the watch before wiping .shadow-cljs?#2019-02-1109:54thhellerit should never be possible to get into a state where a freshly started shadow-cljs picks up files that no longer exist or of the wrong version#2019-02-1109:56thhellersince 2.7.32 it also shouldn't be possible to get into that state while watch is running#2019-02-1112:49Saikyunhey, I'm trying to get chlorine working with shadow-cljs. but for whatever reason when running shadow-cljs there is no socket connection being opened
$ npx shadow-cljs server
shadow-cljs - config: ...\shadow-cljs.edn  cli version: 2.7.32  node: v10.15.1
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server for :app available at 
shadow-cljs - server version: 2.7.32 running at 
shadow-cljs - nREPL server started on port 53349
#2019-02-1112:49Saikyunhow do I solve this?#2019-02-1112:50thhellernot sure I understand the question? which "socket connection"?#2019-02-1112:50Saikyunsorry, I mean the socket repl#2019-02-1112:50SaikyunI've seen that in many examples of shadow-cljs a socket repl is started when running shadow-cljs#2019-02-1112:51thhellersocket repl is started by default yes#2019-02-1112:51thhellerit just doesn't log anything on startup?#2019-02-1112:51Saikyunit isn't for me though, so wondering if I'm doing something wrong#2019-02-1112:51Saikyunhm, but it does in some examples, like at the bottom here: https://github.com/thheller/shadow-cljs/wiki/REPL#2019-02-1112:52thhellerthat was removed a very long time ago#2019-02-1112:52thhellerif you want to find the port you can check .shadow-cljs/socket-repl.port#2019-02-1112:52Saikyunoh, okay#2019-02-1112:53thhellerthe socket repl is started regardless of the log message#2019-02-1112:53SaikyunI see, thanks#2019-02-1112:53thhellerby default a random port is used#2019-02-1112:53SaikyunI couldn't find it anywhere in the docs 🙂#2019-02-1112:53thhelleryou can set a fixed port by setting :socket-repl {:port 12345} in the shadow-cljs.edn#2019-02-1112:53thhellernobody seemed to be using the socket-repl so I removed the extra print#2019-02-1112:54Saikyunah, I see. thanks for the info 🙂#2019-02-1112:55thhellerthe nrepl log message is only there because of cider#2019-02-1112:55SaikyunI'm not sure, but I think chlorine is the most fully featured atom clojure package, and it uses socket repl#2019-02-1112:55SaikyunI'm super new to cljs overall though, so I don't know#2019-02-1112:56thhellerI have not tested chlorine yet since its still relatively new#2019-02-1112:57thhellerbut yeah I didn't want people looking for random port numbers on startup. tools should just check .shadow-cljs/socket-repl.port instead#2019-02-1112:58thhelleror you set a fixed port up to you 🙂#2019-02-1112:58Saikyunokay. it'd be neat to have the fixed port in the docs at least 🙂#2019-02-1113:02Saikyunhah, I got it to work now! thanks a lot @thheller#2019-02-1113:06thhelleradded https://shadow-cljs.github.io/docs/UsersGuide.html#socket-repl#2019-02-1113:07Saikyuncool, awesome 🙂#2019-02-1113:20eoliphantHey @thheller thanks for the clarification. Based on what you're saying I think, I'll just need to add a build, etc. Basically, I have a little lib that I use to create a sorta generic domain/attribute model. From that model I can generate datomic/relational schemas, APIs, etc. I have a visualizer that uses plantuml, and just spits out an SVG, but I also started working on one that's interactive and dynamically rendered with JS. So the goal was include the lib, and setup a deps alias that runs the viewer against the target ns. Based on what you mentioned about only allowing one shadow instance, what I was trying to do probably won't work. But conversely, adding a :my-viewer build to a project isn't a big deal either#2019-02-1113:21thhelleryou can start builds without having them in the config just fine#2019-02-1113:21thhelleryou just can't start the server without a shadow-cljs.edn#2019-02-1113:23thhelleryou can run (shadow.cljs.devtools.api/watch* build-config {})#2019-02-1113:23thhellerthere build-config is a map as it would appear in the shadow-cljs.edn with an extra :build-id key#2019-02-1113:23thheller{:build-id :your-viewer :target :browser ...}#2019-02-1113:24thhellerI'm unsure why this needs to be a dynamic build though?#2019-02-1113:24thhelleror built at all for that matter? does it not just require some data?#2019-02-1114:18eoliphanthmm.. I might be conflating the terms (server, build, etc) a bit and as we’re talking about this, I just realized there’s already a ‘shadowy’ lol, model for what I want to do. In say, fulcro apps, workspaces are conceptually the same thing I’m doing, a different ‘view’ of some portion of my application code. Just adding a ‘build’ and the setup code, is probably fine. Well the way my stuff works, is that I have a DSL, that jams stuff into an internal datascript db (imagine spec’s global registry). So if I add an attribute in say the `mydomain.person’ namespace, that should be reloaded, which updates the db, and my dynamic view shold get updated as well#2019-02-1114:23thhellerah so you are relying on somethat that is generated at runtime?#2019-02-1114:23thhellerso must be run as part of the normal code?#2019-02-1114:24eoliphantyeah well I guess it’s technically read/compile time. but the idea was to make the data available for generators and what have you, but also, at application runtime.#2019-02-1114:25eoliphantand yeah the ‘domain defintions’ are part of the normal app code#2019-02-1114:42thhellermaybe some architecture like fulcro-inspect makes sense? ie. user adds a preload?#2019-02-1116:09eoliphantah yeah, I think the preload would be a good way to genericize it#2019-02-1208:19levitanonghi all, what is the idiomatic way of getting all the dependencies a la lein deps? I’m running docker, and I want to be able to cache the dependencies, so I don’t have to download each time i shadow-cljs release in my CI pipeline#2019-02-1208:20thhellershadow-cljs info will do that (assuming you have :dependencies actually in shadow-cljs.edn)#2019-02-1208:22levitanong@thheller would shadow-cljs info still work if I used deps.edn for dependencies?#2019-02-1208:23thhellerno.#2019-02-1208:23thhellerjust call clojure with some opts in that case#2019-02-1208:23thhellerclojure -Stree or something#2019-02-1208:27levitanongHmm. I’m already doing that, but somehow shadow-cljs release still ends up downloading the dependencies all over again.#2019-02-1208:27thhelleryou probably don't have shadow-cljs itself explicitely in your deps.edn?#2019-02-1208:28levitanong… oooh, that could be it!#2019-02-1208:28thhellershadow-cljs automatically adds it on startup#2019-02-1208:29thhellera "dirty" way to make shadow-cljs download the deps would be shadow-cljs clj-eval 1#2019-02-1208:29thhellerbut that will start the entire process which adds a couple secs and isn't strictly necessary#2019-02-1208:30levitanonggot it 🙂 thanks, @thheller!#2019-02-1208:31thhellerI can maybe add something that works with lein and deps.edn#2019-02-1213:22mauricio.szaboWhy does, sometimes, my shadow-cljs compiles a code that have the error: ReferenceError: $cljs is not defined#2019-02-1213:23mauricio.szaboI can't reproduce exactly what happens, but it's common when I'm developing a code in one machine and change to another#2019-02-1215:46thhellerno idea. never seen that?#2019-02-1215:48thhellersince $CLJS is only used in development builds are you maybe trying to load a development build compiled on one machine on the other? that is never supported and should not be done.#2019-02-1217:48mauricio.szaboNo, it normally occurs when I'm developing on one machine, then I pull the repository from another one and try to compile with shadow-cljs watch <build-id>. Most of the time it solves by deleting .shadow-cljs folder, target, node_modules, and trying again.#2019-02-1217:48mauricio.szaboOnce I had to upgrade shadow-cljs because nothing else solved it#2019-02-1218:26lilactownare you committing the .shadow-cljs folder and/or the build files?#2019-02-1221:32mauricio.szaboNo, I'm not commiting any build files#2019-02-1222:00thhellernothing should ever require deleting .shadow-cljs so I'm kinda curious what you are doing#2019-02-1222:02thhellercan you tell me more about your setup? I don't understand what $cljs is? Is that just because you typed the message by hand maybe? shadow--cljs has zero references for $cljs only $CLJS?#2019-02-1222:27mauricio.szaboI'm using shadow-cljs with lein to develop Chlorine, and now I'm trying some integration tests in the branch full-editor-tools of my repl-tooling repo (https://github.com/mauricioszabo/repl-tooling/)#2019-02-1222:28mauricio.szaboToday I updated my repository on another machine to keep developing the branch and it complained about missing showdown dependency from NPM (never heard of it).#2019-02-1222:28mauricio.szaboI've instaled and fired up electron on my UI, and saw that error on console.log 🙂#2019-02-1222:29mauricio.szaboHave no idea what happened too...#2019-02-1222:32thhellernot sure how electron is related to any of that?#2019-02-1222:32thhelleror showdown. shadow-cljs certainly doesn't require that?#2019-02-1222:51mauricio.szaboI'm using shadow-cljs to emit a JS so I can render on electron#2019-02-1222:51mauricio.szaboshowdown, I have no idea why it asked.#2019-02-1222:52mauricio.szabo(on my home's machine it didn't ask for showdown too)#2019-02-1222:07thhellerhahaha Latest commit dead100 5 hours ago#2019-02-1222:08thhellernice hash start 🙂#2019-02-1222:12thhellerjust did a git reset to clean up some stuff I was testing and ended with HEAD is now at dead100 .... was a bit confused for a second 😉#2019-02-1222:39gravHm, what to do about shadow-cljs - connection closed!? In the inspector I get `WebSocket network error: The operation couldn’t be completed. (OSStatus error -9807.) cljs$core$IFn$_invoke$arity$variadic — browser.cljs:25:97`#2019-02-1222:40thhellerthe error seems to be Invalid certificate chain.#2019-02-1222:40thhellerusing ssl?#2019-02-1222:41gravYes - ah, maybe I did not install the cert on the client correctly. It’s iOS 12#2019-02-1222:41gravIt’s just that it doesn’t really complain about SSL, and there’s no “lock with a cross” or similar#2019-02-1222:42thhellerI just googled OSStatus error -9807 since I also have no idea what this is about. it certainly is nothing from shadow-cljs#2019-02-1222:42gravI’ve installed the cert successfully on the Mac, and there it works in Safari#2019-02-1222:42gravAh, okay. I wasn’t so lucky with my googling (edit - quotes helped)#2019-02-1222:43thhelleroh did you maybe not configure the ssl in shadow-cljs but some other server isntead?#2019-02-1222:43thhelleras the websocket connection goes to the shadow-cljs server#2019-02-1222:48gravi do use shadow-cljs for ssl - using the default config as per the guide.#2019-02-1222:48thhellertry to connect to (thats where the websocket connects to)#2019-02-1222:48gravIt seems to work just fine, both with Safari and even Chrome on an Android (although the latter still shows https://#2019-02-1222:49gravwill do#2019-02-1222:49grav(oh, it’s >)#2019-02-1222:49thheller#2019-02-1222:49grav#2019-02-1222:50grav#2019-02-1222:51thheller#2019-02-1222:51grav#2019-02-1222:51thheller#2019-02-1222:51grav#2019-02-1222:52thheller
#2019-02-1222:53thheller#2019-02-1222:53thheller#2019-02-1222:53grav#2019-02-1222:54grav#2019-02-1222:54thheller#2019-02-1222:55thheller#2019-02-1222:56thheller#2019-02-1222:59grav#2019-02-1223:03thheller#2019-02-1223:04grav#2019-02-1223:06grav#2019-02-1223:37reset#2019-02-1223:38thheller#2019-02-1223:39thheller#2019-02-1223:39thheller#2019-02-1223:40reset#2019-02-1223:44reset#2019-02-1223:45lilactown#2019-02-1223:45reset#2019-02-1223:46thheller#2019-02-1223:46reset#2019-02-1223:47thheller#2019-02-1223:48reset#2019-02-1223:48reset#2019-02-1223:48lilactown#2019-02-1223:48thheller#2019-02-1223:49thheller#2019-02-1223:49reset#2019-02-1223:49reset#2019-02-1223:49thheller#2019-02-1223:50reset#2019-02-1223:50thheller#2019-02-1223:51thheller#2019-02-1223:51reset#2019-02-1223:56reset#2019-02-1300:03reset@thheller @lilactown this 100% solved my problem. I can’t thank you enough#2019-02-1300:04lilactownsure thing! 😄 the idea is that, when you change bits of your application, you need to completely re-render your application to make sure you clear out any references to the old values#2019-02-1300:04resetThis was actually something I was searching for!#2019-02-1300:05resetThe documentation is great, but there has been a lot for me to learn. I came from C++, Rust, and Erlang into Clojure back in July. I hadn’t touched the web, javascript, or Java in a really long time#2019-02-1300:05lilactownyeah for sure. it’s all a bit overwhelming 😅#2019-02-1300:06resetI think it’s worth the effort so far. Quite an amazing ecosystem once you wrap your head around it#2019-02-1300:06resetI’ve never been able to iterate so quickly#2019-02-1300:06lilactownjust for completeness: if, in the future, you want to make sure something doesn’t get reloaded, you can use defonce instead of def#2019-02-1300:07lilactowne.g. (defonce app-state (r/atom {}))#2019-02-1300:07resetBrilliant#2019-02-1300:07lilactownthat way your application re-renders, but your state stays the same so you don’t have to click around a bunch to get back to where you were#2019-02-1300:07resetI literally just tagged my app-state with that now#2019-02-1311:39jlmrHi, I’m having trouble getting css-refresh to work in an electron app. I’m using the {:devtools {:watch-dir "<path>"}} config but it’s not working. Anyone any tips?#2019-02-1311:47jlmrOk it gets weirder: after refreshing the electron app, css refresh works 1 time.#2019-02-1312:29jlmrI’ve found some more detail: 1) When I start the electron app, the css tag in index.html looks like this: <link rel="stylesheet" type="text/css" href="css/main.css"> 2) Editing the css file at that point will trigger a refresh: shadow-cljs: load CSS css/main.css. 3) The page refreshes and the css changes are reflected in the app. The dom is also modified, the css tag now looks like this: <link rel="stylesheet" type="text/css" href="css/main.css?r=0.8158209164608885"> 4) New css file edits no longer trigger refreshes. 5) After manually editing the css tag using Chrome devtools to again look like it did at step 1 refreshing again works a single time. Could this be a bug? What is the purpose of the ?r=<number? that gets added to the css tag?#2019-02-1312:36thheller@jlmr ?r=... is used to ensure no cache is used#2019-02-1312:38jlmr@thheller, thanks. So that part is supposed to stay 🙂. Do you have any pointers on how I could get css refresh going?#2019-02-1312:39thhellerwhat do the devtools have to say about this? does it just report a 404?#2019-02-1312:39thhellerguess it maybe doesn't like ? since it is loading files from the filesystem#2019-02-1312:41jlmrDevtools doesn’t complain at all, but it’s only reloading css once after starting the Electron app#2019-02-1312:42jlmrIn the console I also don’t see a message indicating that shadow-cljs is loading the css (except for that one time)#2019-02-1312:44thhellerno "request" in the network tab?#2019-02-1312:47jlmrnope, only on the very first reload#2019-02-1312:45thhellerI don't think I ever tested css reload in electron#2019-02-1312:45thhellerfeel free to open an issue. I can look into it a bit later#2019-02-1312:48jlmrWill do, thanks!#2019-02-1407:38jlmr@thheller 76bda07 fixed it! Thanks for the quick fix!#2019-02-1313:34metacriticalHi @thheller I was trying to bootstrap cljs on node.js in a electron app, you suggested previously to look at browser.cljs in shadow to do that, but i have encountered an issue when i load the bootstrap files it gives error while loading the analysis cache. Can you please look at the code and see what am i doing wrong ? https://github.com/42Org/b42/blob/temp/src/app/main/bootstrap/node.cljs#2019-02-1313:36thhelleruhm that looks like a completely incorrect use of core.async#2019-02-1313:36thhellertry building it without core.async#2019-02-1313:41thheller(go (>! fchan data)) this should absolutely be avoided. just use (async/put! fchan data) if all you care about is putting a value on a chan#2019-02-1313:41thhelleror better yet async/offer!#2019-02-1313:44thhellerI can't look this properly right now. maybe later.#2019-02-1314:55metacritical@thheller Will try what you suggested. Also it would be great if you do look at it when you have time, i would highly appreciate that. Thanks is Advance.#2019-02-1321:11hyoois it possible to watch “release” mode instead of “dev” mode in shadow-cljs? I want to modify and test codes in a single js like an release build because of network limitation.#2019-02-1321:16thheller@hjfirst no that is not possible. set :devtools {:loader-mode :eval} in your build config if you want to reduce the number of files loaded (still fairly large though)#2019-02-1321:17hyoohmm.. I see. thanks.#2019-02-1321:18thhellerhttps://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-02-1321:19hyoocool. let me read and try it. thanks for info!#2019-02-1321:50hyoo@thheller {:loader-mode :eval} helps a lot since it reduces the file numbers! 🙏#2019-02-1322:00thheller@metacritical I implemented the full node bootstrap myself. it required tweaking the node build targets a bit anyways. should now work fine in 2.7.33.#2019-02-1322:00thhellerexample configs https://github.com/thheller/shadow-cljs/blob/5b01afa38dcccbc5b13bb8ff21d7179f028c5836/shadow-cljs.edn#L409-L427#2019-02-1322:00thhellerexample use https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/bootstrap_script.cljs#2019-02-1322:04thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/bootstrap/node.cljs#2019-02-1322:06thheller@jlmr css reload in electron should also be fixed in 2.7.33#2019-02-1403:06metacritical@thheller This is so awesome! Thankyou!#2019-02-1408:44metacritical@thheller Now that we have a self-host mode in shadow probably this needs to be fixed https://github.com/thheller/shadow-cljs/blob/483a25b522895225b63321e39bbc081dfba8c58b/src/main/shadow/build/closure.clj#L603#2019-02-1408:45thhellerno? what does that have to do with anything?#2019-02-1408:46thhellerif anything ever calls goog.nodeGlobalRequire it is because of a bug that needs to be fixed#2019-02-1408:49metacriticalwell i would want to call load-file which calls this.#2019-02-1408:50manuelhi, with latest cider-nrepl, I get this when using shadow-cljs watch:
[2019-02-14 09:49:48.486 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
	clojure.lang.Compiler.load (Compiler.java:7647)
	clojure.lang.RT.loadResourceScript (RT.java:381)
	clojure.lang.RT.loadResourceScript (RT.java:372)
	clojure.lang.RT.load (RT.java:463)
	clojure.lang.RT.load (RT.java:428)
	clojure.core/load/fn--6824 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
	clojure.core/load-lib/fn--6765 (core.clj:5948)
	clojure.core/load-lib (core.clj:5947)
Caused by:
FileNotFoundException Could not locate nrepl/middleware/caught__init.class, nrepl/middleware/caught.clj or nrepl/middleware/caught.cljc on classpath.
	clojure.lang.RT.load (RT.java:466)
	clojure.lang.RT.load (RT.java:428)
	clojure.core/load/fn--6824 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
	clojure.core/load-lib/fn--6765 (core.clj:5948)
	clojure.core/load-lib (core.clj:5947)
	clojure.core/load-lib (core.clj:5928)
	clojure.core/apply (core.clj:667)
	clojure.core/load-libs (core.clj:5985)
#2019-02-1408:51thhellerlooks like something is broken there?#2019-02-1408:52manuelyou mean on cider-nrepl side?#2019-02-1408:52manuelbecause I only bumped the dependency in my shadow-cljs.edn#2019-02-1408:53thhellershadow-cljs is using clojure 1.10 now. guess there is something in the ns form that it doesn't like anymore?#2019-02-1408:53metacriticalSeems like a nrepl issue#2019-02-1408:53thhellerhttps://github.com/clojure-emacs/cider-nrepl/tree/master/src/cider/nrepl/middleware#2019-02-1408:53thhellerno caught.clj?#2019-02-1408:54thhellerhttps://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl.clj#L7#2019-02-1408:54thhellerbut required there. not sure where that is supposed to be coming from#2019-02-1408:54manuelI see, I'll report the issue to them. Thanks 🙂#2019-02-1408:54thhellerhttps://github.com/clojure-emacs/cider-nrepl/commit/e8f857b4e451c8090db65d4e60fab84d66121600#diff-c4f3b7ef4e74edc103db85e3f9fa4518#2019-02-1408:55thhellerlooks like someone maybe forgot to commit it#2019-02-1408:55thhellerpretty sure that has nothing to do with bumping shadow-cljs though#2019-02-1408:55thhellercider probably also updated?#2019-02-1408:56manuelyes, I upgraded it this morning#2019-02-1408:56manuelbut I've only seen this issue on shadow-cljs watch#2019-02-1408:56manuelnote that shadow-cljs compile works just fine, so yes, it's cider-nrepl related#2019-02-1408:56thhellercompile doesn't start an nrepl server so it doesn't load cider.nrepl#2019-02-1408:59metacritical@thheller There is a nodeGlobalRequire implementation here https://github.com/clojure/clojurescript/blob/9a8196ebfe4265feda88a06de84affb9df469012/src/main/cljs/cljs/bootstrap_nodejs.js#2019-02-1409:00manuel@thheller yep, I was just saying that shadow-cljs works fine 😉#2019-02-1409:00thheller@metacritical yes I know that. nodeGlobalRequire is bad and should not be used#2019-02-1409:01metacriticalSo i should just manually load a cljs file in bootstrapped env and eval it?#2019-02-1409:02thhellerwell what are you trying to do?#2019-02-1409:02thheller(load-file "./some/thing.cljs")?#2019-02-1409:02metacriticalyes#2019-02-1409:02thhellerthat would never work since it can only load .js files as no compilation is done#2019-02-1409:03thhellerI honestly don't know why this is even a thing that exists#2019-02-1409:03metacriticalaah that makes sense.!#2019-02-1409:04thhellermaybe it is used by something internally. I don't know but you definitely cannot use it to load .cljs files#2019-02-1409:04metacriticalThat is helpful i would do a custom load file then. Thanks a lot!#2019-02-1409:26thheller@manuel I guess it was just the outdated nrepl dep. Try 2.7.34#2019-02-1409:30manuelworks now, thank you. I only get this warning:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by mranderson048.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval8306$fn__8307 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of mranderson048.orchard.v0v3v0.dynapath.v0v2v5.dynapath.defaults$eval8306$fn__8307
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
#2019-02-1409:30thhellernot something I can control#2019-02-1409:30thhellertell them 😉#2019-02-1409:31manuelsure thing#2019-02-1409:31thhellerThey are still probably testing with Java8 which won't have those warnings#2019-02-1413:31thhellerI just pushed 2.7.35 with new logic for the built-in development HTTP servers. Old configs should still work so no changes required (unless you want to). Please let me know if something breaks in your dev setups. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-02-1415:24mhuebert@thheller trying this out now. my push-state routes don’t seem to be working, I have :dev-http {8701 "public"} - localhost:8701/ loads my index.html file from /public correctly, but localhost:8701/intro gives me Not found. Missing index.html.#2019-02-1415:25thhelleroh right .. forgot about that#2019-02-1415:25thhellerfixing#2019-02-1415:32thheller@mhuebert thx for testing. fixed in 2.7.36.#2019-02-1415:36mhuebertworks for me, thanks!#2019-02-1415:34dpsutton@manuel I saw your woes too late. M-x cider-jack-in-clojurescript adds the correct -d nrepl:0.6.0 for you. The jack-in-X commands have gotten very good (in my experience) lately#2019-02-1415:38manuelthanks @dpsutton 🙂#2019-02-1415:40dpsutton:+1: (and if it doesn't work correctly I consider it a bug)#2019-02-1417:02metacriticalWoW three minor version number bumped in a day.#2019-02-1417:03metacriticalSlack Driven Development actually works.#2019-02-1417:04dpsuttoni would attribute this to @thheller being fantastic for the community#2019-02-1417:19grounded_sage@thheller how far along are you with doing a simple Gatsby JS clone / SSR story. Last I remember you were going to use Fulcro? I’m growing interested in Fulcro and also prefer not to do redundant work. So if there is a repo to watch I would love to know :)#2019-02-1417:44thhellerno time to work on anything related to that. others have done SSR with fulcro and pathom would make hooking up some kind of storage trivial#2019-02-1417:42metacriticalTrue @thhelleris awesome.#2019-02-1422:53richiardiandreais there a trusted deps.edn and shadow-cljs docker container folks use?#2019-02-1509:37thhelleryou gotta be kidding me ... what year is this 😛#2019-02-1509:37thheller> MongoDB's JIRA is currently down for maintenance.#2019-02-1513:25anmonteiro@thheller I opened https://github.com/thheller/shadow-cljs/pull/439 earlier today. Happy to discuss it here#2019-02-1513:25anmonteirono pressure to review it though#2019-02-1513:31thheller@anmonteiro looks straightforward. will merge later. the entire goog loader stuff has changed a lot and doesn't work at all anymore with the new closure-library release. we'll see what else needs changing 😉#2019-02-1513:32anmonteirooh no#2019-02-1513:32anmonteirothis one is present currently in the old goog release though#2019-02-1513:32anmonteirowe’re on 1.10.516#2019-02-1513:33thhelleryeah I don't know why I even exposed those methods. probably never tested them.#2019-02-1513:33thhellerin all my experiements the only thing that made an actual difference in initial loading time was <link rel="preload" ...>#2019-02-1513:34thhelleryou can always interact with the mm instance directly if you need#2019-02-1513:34thheller(.prefetchModule shadow.loader/mm "foo") should work#2019-02-1513:39anmonteirowould that be amenable to advanced compilation?#2019-02-1513:39anmonteiroI didn’t do that because they’re not exported through “exportSymbol”#2019-02-1513:43thhellerfrom where are you calling the functions? from inside code that was :advanced compiled or from HTML?#2019-02-1513:48anmonteiroI was calling it from the HTML but I won’t need to do it#2019-02-1515:19mhuebertRandom question about externs inference: if there is a (.val ^js snapshot) in the codebase, does that mean “val” will never be renamed anywhere, or only for things that the compiler thinks might have the same type as snapshot?#2019-02-1515:19mhuebertMy recollection is that it would be universal#2019-02-1515:35thhellerit depends. If Closure can identify the type it can be renamed, if not it won't be. so generally in CLJS code nothing will ever be renamed if the name exists in the externs#2019-02-1518:16mhuebertok. so the ^js hint there does not mean that val will be added to the inferred externs#2019-02-1519:24thhellerno, it will be added#2019-02-1619:2541ph4_Ph4unhmm.. Okay totally n00b question. Since shadow-cljs allows the use of nodejs or browser REPL, are there any actual configurations that would really benefit from using Lein or is that option more for people who simply prefer it?#2019-02-1619:2641ph4_Ph4unI haven't got an opinion either way and just getting to use both so.. just curious 🙂#2019-02-1619:26thhellermost people use lein when they have some other CLJ code (eg. server-side) they need to work with as well#2019-02-1619:27thhellernothing build related is affected by whether you use lein, tools.deps or shadow-cljs standalone#2019-02-1619:2741ph4_Ph4unah I see. So as a configuration for a full stack project.#2019-02-1619:27thhelleryeah#2019-02-1619:2841ph4_Ph4unYeah I'm actually gonna playaround using NodeJS instead of just JVM BEs but I'm going to be using lein on other projects in the future so I set it up just to familiriaze myself#2019-02-1619:28thhellerbut it also fine to use shadow-cljs.edn for CLJS and lein for CLJ completely separate. that is what I do.#2019-02-1619:2941ph4_Ph4unhmmm.. hmmm.. I see! Well this clarifies nicely 🙂#2019-02-1620:1941ph4_Ph4unhmm.. some clarifications about building a node scripts 🙂#2019-02-1620:2041ph4_Ph4un#2019-02-1620:2041ph4_Ph4unSo let's assume I have arbitary project foo where I'm defining a core.cljs having a main function#2019-02-1620:2141ph4_Ph4unDoes this seem to be in order? Am I correct to assume that next thing leiningen needs is a notion of where the sourcecode files are?#2019-02-1620:22thhellerwhy are you using lein if you are not familiar with lein?#2019-02-1620:23thhellerbut yes you need :source-paths ["src"] or so in project.clj and the file located in src/foo/core.cljs (or whatever your source path is)#2019-02-1620:2341ph4_Ph4unlike previously said, it's likely I need to use it in the future and just thought I might as well begin now#2019-02-1620:24thhellerit will be trivial to switch later. no need to do it now 😉#2019-02-1620:2441ph4_Ph4unI know it's additional and without familiarity just adds complexity currently 🙂 that's why ask does it actually have additional benefits#2019-02-1620:25thhellerno benefits in using project.clj over shadow-cljs.edn. just more complicated 😉#2019-02-1620:2541ph4_Ph4unyes, I've noticed 😄#2019-02-1620:2641ph4_Ph4unbut since I started configuring might as well check it trough. Write a memo about it and then move in to what I actually use 😄#2019-02-1620:2741ph4_Ph4unI hate to just leave stones unturned if I've started. So yeah. I'll just verify it's in order#2019-02-1620:2941ph4_Ph4unokay verified, time to strip the clunkyness off#2019-02-1620:33thhellerbasically the only difference is that :source-paths and :dependencies are either in shadow-cljs.edn or project.clj#2019-02-1620:33thhelleras far as the runtime and builds are concerned nothing else is different#2019-02-1620:3441ph4_Ph4unyup. I'll add Leiningen when I'm actually using some non JS based BE or have more bigger production environment at hand#2019-02-1620:3541ph4_Ph4unI haven't really even Clojure before. Only Common Lisp before 😄#2019-02-1620:3641ph4_Ph4unAs usual, when you start you really have too many options and not really an idea how to filter the useful parts of the information#2019-02-1620:37thhelleryeah thats why shadow-cljs doesn't use any of the other tools by default#2019-02-1620:37thhellercomplicated enough if you keep everything to one tool 🙂#2019-02-1620:3941ph4_Ph4unYeah I can dig that. Sometimes I throw up into my mouth a bit when I look at what some of my webpack+others configurations have become like#2019-02-1620:43thhelleryeah it can get quite out of hand nowadays. too many tools, too many languages, too many different idioms.#2019-02-1709:32thhellerI just pushed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "a6d5cec7c2c9d18bc5caccd5e694889e8896"}, :content ("[email protected]")}. The most significant change in this release is the bump of the Closure Library. CLJS used to update that regularly but stopped about 2 years ago. There may have been breaking changes in the Closure Library so please help testing if you use a lot of goog stuff.#2019-02-1721:29hmaurerAnything noteworthy in this bump? (feature-wise)#2019-02-1721:41thhellermostly the user config stuff and new closure library. the other stuff is mostly about adjustments for the new closure lib#2019-02-1709:33thhelleralso new https://shadow-cljs.github.io/docs/UsersGuide.html#user-config which may be useful for some (especially for things like cider-nrepl)#2019-02-1804:15Jonhttps://clojureverse.org/t/whats-your-most-frequently-used-features-in-shadow-cljs/3791/2#2019-02-1808:32flowthingThe specs in shadow.cljs.devtools.cljs-specs don't seem to allow destructuring like this: (defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}]). In particular, it seems to be the combination of :or and destructuring a namespaced keyword that's the problem. The specs allow (defn foo [{:keys [quux] :or {quux :quuz}}]), for instance. I'm on shadow-cljs v2.8.0.#2019-02-1808:33thheller(defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}] this is not valid. (defn foo [{:keys [baz/quux] :or {quux :quuz}}] should be.#2019-02-1808:37flowthingWell, I'll be damned. I guess my code's never actually hit the :or path. Thanks!#2019-02-1808:38thhellerit may work due to the way destructuring is implemented#2019-02-1808:38flowthingI tried it out in the REPL, it doesn't seem to work.#2019-02-1808:38thhellerthey are somewhat "open" to interpretation#2019-02-1808:39flowthing
$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -m cljs.main
ClojureScript 1.10.520
cljs.user=> (defn foo [{:keys [baz/quux] :or {baz/quux :quuz}}] quux)
#'cljs.user/foo
cljs.user=> (foo {})
nil
cljs.user=> (defn foo* [{:keys [baz/quux] :or {quux :quuz}}] quux)
#'cljs.user/foo*
cljs.user=> (foo* {})
:quuz
#2019-02-1808:40flowthingI guess it seems kinda logical that :or {baz/quux ,,,} would work, but on the other hand, I guess you could argue that quux is the name of the variable the value is bound to and therefore makes more sense.#2019-02-1808:41flowthingAnyway, TIL! Not the first time I've gotten destructuring wrong without any indication that it's not actually working...#2019-02-1808:41thhelleryeah the core specs aren't enabled in CLJS by default yet so it lets some things slide#2019-02-1808:41flowthingYeah.#2019-02-1809:20ouvasamHi, Has someone already used AirBnB DateRangePicker with reagent ? Can't make it work ... thanks#2019-02-1810:00thhellerwhat have you tried? what error do you get?#2019-02-1810:50r0man@thheller I'm testing 2.8.0 on one of my projects and get an error from the babel worker trying to process a file from @material/textfield#2019-02-1810:51r0man#2019-02-1810:51r0manany idea?#2019-02-1810:53thhellerhmm looks like something got renamed that shouldn't have been#2019-02-1810:54thhellerdid that work previously?#2019-02-1810:54r0manyes, it worked with previous versions of shadow-cljs#2019-02-1810:55thhellerok I'll check it out#2019-02-1810:56r0manok, thanks. if you need more info. let me know.#2019-02-1811:06thhellerok I can reproduce it but not exaclty sure why anything changed. will investigate#2019-02-1811:07r0manok#2019-02-1812:02thheller@r0man should be fixed in 2.8.1. still unsure why this wasn't a problem previously but I can't reproduce the problem anymore#2019-02-1812:05r0manok, thanks. I'll try ...#2019-02-1812:12r0man@thheller yes, this fixed the issue. thanks!#2019-02-1812:12r0manbut I run into another issue with my nodejs server. 😕#2019-02-1812:12r0man#2019-02-1812:12r0mando I need to change anything for the new module manager. I'm using the cljs.loader namespace at the moment#2019-02-1812:17thhellerwhy or how are you using cljs.loader in a node env?#2019-02-1812:18thheller(cljs.loader is now aliased to use shadow.loader, but cljs.loader would have the same issue above)#2019-02-1812:19r0manI have some files that use the module manager in the frontend. I guarded the calls to loader/set-loaded with this:#2019-02-1812:19r0man#2019-02-1812:19thhellerthe underlying goog module loader stuff changed a bunch in the new release so I'm not surprised there are issues#2019-02-1812:19r0manso on node I only require the cljs.loader namespace#2019-02-1812:21thhellerplease paste the contents of /home/roman/workspace/burningswell/web/.shadow-cljs/builds/server/dev/out/cljs-runtime/goog.loader.activemodulemanager.js#2019-02-1812:22r0manwhen I look at goog.loader.activemodulemanager.js I see a require for the "asserts"#2019-02-1812:22r0manyes, 1 mom#2019-02-1812:22thhellershould be starting with goog.loadModule(...)#2019-02-1812:22r0man#2019-02-1812:22thhellerhmm yeah thats how it supposed to look#2019-02-1812:23r0manis this comment before the require a problem? shouldn't, right?#2019-02-1812:23r0manon line 6#2019-02-1812:23thhellerI didn't test this in a node env so I suppose something is weird there#2019-02-1812:23thhellerah .. I know#2019-02-1812:25r0manhttps://github.com/google/closure-library/blob/master/closure/goog/loader/activemodulemanager.js#L71 has the comments above#2019-02-1812:25thhellernah thats all fine#2019-02-1812:26thhellerthe node builds replace goog.require with one that isn't aware of goog.loadModule stuff#2019-02-1812:26thhellerso var asserts = goog.require("goog.asserts"); just ends up as nil#2019-02-1812:26thhellersince goog.require usually doesn't return anything#2019-02-1812:27thheller#2019-02-1812:27r0manah. ok#2019-02-1812:27thhellercan you try adding this to your src/shadow/cljs/node_bootstrap.txt and recompile#2019-02-1812:28thheller
var SHADOW_REQUIRE = function(name) {
  if (goog.isInModuleLoader_()) {
    return goog.module.getInternal_(name);
  }
  return true;
};
#2019-02-1812:28r0manin my project?#2019-02-1812:28thhelleryes#2019-02-1812:28r0man1 sec#2019-02-1812:29thhellerthat used to only be
var SHADOW_REQUIRE = function(name) {
  return true;
};
#2019-02-1812:30r0man:+1: yes, that worked!#2019-02-1812:31r0manalso module loading seems fine now#2019-02-1812:32thhellerok thx. I'll see if the goog.require override is required at all anymore. maybe I can just remove that hack entirely.#2019-02-1812:33r0manok, thanks for you help. I just recently switched to shadow and it is really nice!#2019-02-1812:37thheller@r0man btw in shadow-cljs you don't need to call set-loaded!. the tool takes care of that for you#2019-02-1812:38r0manonly the shadow.loader or also for cljs.loader?#2019-02-1812:38thhellercljs.loader is aliased to shadow.loader regardless of what you require 😉#2019-02-1812:38thhellerso you are always using shadow.loader 😉#2019-02-1812:39thhellercljs.loader doesn't work with the new closure library at all yet#2019-02-1812:39thhelleryou can keep the call if you want, you just don't need it#2019-02-1812:39thhellerI never liked that you had to add it manually in normal CLJS#2019-02-1812:39r0manalright. didn't know that.#2019-02-1812:45r0manone more question regarding modules. at the moment I have 1 module for each of my routes, like /signin, /signup etc. those module depend at the moment on 1 shared modue which contains most of the cljs code and all stuff that is shared among more than 1 module. the shared module is quite big at the moment and also contains stuff like vega & d3 which is not needed on the /signin and /signup pages. it's still moved into the shared module because 2 other modules depend on it. does shadow or the closure module loader support multiple shared modules?#2019-02-1812:46thhelleryes you can construct pretty much any graph#2019-02-1812:47thhelleryou can even create "pseudo" modules#2019-02-1812:47orestisI’m seeing Error building classpath. Specified aliases are undeclared: [:shadow-cljs-inject["r""e""b""l""-""1""1"]] when using -A:rebl-11 or -A rebl-11 in recent shadow 2.8.1#2019-02-1812:47r0manok, I'll try again. I run into issues in the past.#2019-02-1812:48thheller@r0man say you have 2 pages that you know have common deps which should not be in :shared#2019-02-1812:49thheller:modules {:foo {:entries [] :depends-on #{:shared} :uses-foo {:entries [your.page.foo] :depends-on #{:shared :foo} ....}#2019-02-1812:49thhellerugh that gets ugly#2019-02-1812:50thheller
:modules
{:shared
 {:entries []}
 :foo-shared
 {:entries []
  :depends-on #{:shared}}
 :page-a
 {:entries [your.app.page-a]
  :depends-on #{:shared}}
 :page-b
 {:entries [your.app.page-b]
  :depends-on #{:shared :foo-shared}}
 :page-c
 {:entries [your.app.page-c]
  :depends-on #{:shared :foo-shared}}
 }
#2019-02-1812:51thhellerthings that are used in all 3 pages are moved to :shared#2019-02-1812:51thhellerthings that are only used by b+c are moved to :foo-shared#2019-02-1812:53thhellerthe :entries [] is a shortcut when you don't have any specific namespaces that should be moved there#2019-02-1812:54thheller@orestis hmm that looks weird 🙂#2019-02-1812:55thhelleroh doh#2019-02-1812:55orestis./node_modules/.bin/shadow-cljs -A:rebl-11 clj-run ... is the actual command line#2019-02-1812:57thhelleryeah the merging is just messed up due to the user-config stuff I added#2019-02-1813:02r0man@thheller yes, that was my understanding. I just run into problems. I'm trying again. I think I also need to add :default true to my main module, right?#2019-02-1813:03thhellerno, only if you have 2 modules that both have no :depends-on#2019-02-1813:05thhelleryou can pin dependencies to certain modules and shadow-cljs will warn you if they are moved out due to some requires#2019-02-1813:06thhellerie. in :foo-shared {:entries [cljs.core] ...} will warn you since :page-a needs cljs.core#2019-02-1813:06thhellerits a bit annoying that this has to be setup to manually currently#2019-02-1813:09r0manok, I'll try again with this information. thanks for your guidance#2019-02-1813:09thheller@orestis should be fixed in 2.8.2#2019-02-1813:51r0man@thheller I run into another issue with my nodejs release build. I'm using "simple" optimizations. the code that breaks is the following:#2019-02-1813:52r0man#2019-02-1813:52r0manand the error:#2019-02-1813:52r0man#2019-02-1813:53r0manthe compiled code looks the same in shadow-cljs 2.7.36 and 2.8.2:#2019-02-1813:53r0man#2019-02-1813:55r0manI'm setting Document to a polyfill for server side rendering#2019-02-1813:56r0manmaybe another tweak needed for the nodejs require?#2019-02-1814:10thhellerhmm looks identical to me too#2019-02-1814:11thheller@r0man what does the use look like? the definition looks fine but where is it used?#2019-02-1814:11r0manwhat do you mean by "use"?
#2019-02-1814:12thhellerhow is Document used? by what?#2019-02-1814:12thheller
ReferenceError: Document is not defined
    at /home/roman/workspace/burningswell/web/out/burningswell/server.js:2663:800
#2019-02-1814:12thhellerwhat happens there?#2019-02-1814:12r0manI think it's this line: (set! js/Document html/Document)#2019-02-1814:14thhellerplease verify#2019-02-1814:16r0man#2019-02-1814:16r0man#2019-02-1814:16thhellerjust look at the actual source please#2019-02-1814:17r0manso it blows up on the set! call.#2019-02-1814:17thhelleradd (prn html) please#2019-02-1814:18thhellerI'm confused by this worked before and not now. I don't see any obvious difference?#2019-02-1814:19r0man#2019-02-1814:19r0manthis is what I have for html#2019-02-1814:19thhellerlooks fine to me#2019-02-1814:20thheller(set! js/Document ...) is kinda questionable and should probably be (set! js/goog.global.Document ...) but I don't see a reason why it shouldn't work now if it did work before#2019-02-1814:21r0manlet me try the goog.global#2019-02-1814:21thhellertry (prn html/Document) while you are at it#2019-02-1814:23r0manthis fixed it: (set! js/goog.global.Document html/Document)#2019-02-1814:25r0manand printing (prn html/Document) ;=> #object[Document]#2019-02-1814:25thhellerweird. I have no clue why that was fine previously?#2019-02-1814:25r0manas before#2019-02-1814:26r0manok, so is goog.global the recommended way to set globals in closure?#2019-02-1814:26thhelleryes#2019-02-1814:27r0manalright. thanks again! I hope I didn't ruin your day#2019-02-1814:29thhellerkinda curious to find out why it worked before 😛#2019-02-1814:33r0manhehe, let me know if you have an idea#2019-02-1815:25r0man@thheller I'm afraid I found another issue with the module manager in advanced compilation#2019-02-1815:25r0man#2019-02-1815:25r0manit happens when I load a module#2019-02-1815:25r0manit looks like the module info is not available#2019-02-1815:26r0man(prn (.-moduleInfoMap (loader/getModuleManager))) ;=> #js {}#2019-02-1815:27r0manand it breaks over here: https://github.com/thheller/shadow-cljs/blob/01a0b4810047c719ae528f5ff2bdd26b0dcfe4fd/src/main/shadow/loader.js#L80#2019-02-1815:34r0manto me it looks like the module infos are not available. if I type shadow$loader into the browser console it prints {}#2019-02-1815:36r0manso the modules are not registered here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#L20#2019-02-1815:38r0manwith a "none" build the module info is available#2019-02-1815:45r0manI looked at my main module and I do find the populated shadow$loader object at the very beginning.#2019-02-1815:46r0manhowever, somewhere later in the same file this gets reset by the following code: var shadow$loader = {}#2019-02-1815:54r0manso I guess the first var shadow$loader = {"uris": { ... }}; is emitted by shadow-cljs to make the module info available. but the 2nd var shadow$loader = {} comes from the goog.provide("shadow.loader"); call in loader.js, which unfortunatly resets this information again#2019-02-1817:08thheller@r0man shadow.loader isn't really supposed to work on a node env. how do you see a populated shadow$loader object in the beginning?#2019-02-1817:30thhellerI can probably shim some functions so that is just treats all modules as loaded given there is only ever going to be one for node#2019-02-1819:23metacritical@thheller I am trying to use cljs.analyzer namespace specially a ànalyze-file` defn in it, but while building it seems to be giving a error!#2019-02-1819:23metacriticalAny ideas i should try?#2019-02-1819:24thhellerwhat is the error?#2019-02-1819:24thhellerhow are you using it?#2019-02-1819:42metacriticalI am trying to analyze a cljs file on demand.the error is Use of undeclared Var cljs.analyzer/analyze-file `#2019-02-1819:43thhelleranalyze-file is only available in CLJ#2019-02-1819:44thhellerhttps://github.com/clojure/clojurescript/blob/f289ffee2270567f7976d45012a0a52c38eb6488/src/main/clojure/cljs/analyzer/api.cljc#L120#2019-02-1819:46heyarneSo I have a pretty minimal cljs file with reagent, but somehow the reload hook is ignored. I can't spot the error, am I missing something?
(ns reagent-movable.core
  (:require [reagent.core :as r]
            ["react-movable" :refer [List]]))

(defn reload! []
  (.. js/window -location reload))

(defonce state (r/atom (vec (map #(str "Item " %) (range 1 11)))))

(defn movable []
  (let [items @state]
    [:ul
     (for [[idx item] (map-indexed vector items)]
       ^{:key idx} [:li item])]))

(defn app []
  [:div
   [:h1 "Movable list below"]
   [movable]])

(defn ^:export ^:dev/after-load start []
  (println "Mounting component...")
  (r/render [app] (.getElementById js/document "app")))
#2019-02-1819:47thhelleruhm I don't think you can add two metadata hints that way?#2019-02-1819:48thhellertry
(defn start
  {:export true
   :dev/after-load true}
  []
  (println "Mounting component...")
  (r/render [app] (.getElementById js/document "app")))
#2019-02-1819:51heyarnedoesn't change anything?#2019-02-1819:51heyarnealso as per the docs:#2019-02-1819:51thhellerhmm no seems fine in clojure#2019-02-1819:51heyarne> It is possible to add multiple pieces of metadata by chaining the metadata reader macros together. For example: ^:dynamic ^ints obj would apply both the :dynamic flag and ints type-hint to obj. Metadata chains from right to left (left takes precedence).#2019-02-1819:51thhelleryeah I wasn't sure#2019-02-1819:51heyarnepretty sure it worked in another project#2019-02-1819:51thhellerwhat happens on compile? any warnings?#2019-02-1819:51thhellerit should get picked up as far as I can tell?#2019-02-1819:52heyarnethis is the repo#2019-02-1819:52heyarnehttps://github.com/heyarne/reagent-movable#2019-02-1819:52metacritical@thheller aah i guess copying that function and manually analyzing should do the trick! Thanks!#2019-02-1819:53lilactown
(defn
  ^{:export true
    :dev/after-load true}
  start
  []
  (println "Mounting component...")
  (r/render [app] (.getElementById js/document "app")))
#2019-02-1819:53lilactown@arne-clojurians ☝️#2019-02-1819:54lilactowndoes that fix it?#2019-02-1819:55thheller@arne-clojurians that repo doesn't contain the code you posted?#2019-02-1819:55heyarnei pushed it seconds after, sorry#2019-02-1819:55thhellerah hehe#2019-02-1819:56heyarnejust stopped the watcher and rmrfed /.shadow-cljs, now it's working 😕#2019-02-1819:56heyarne:shrug:#2019-02-1819:56heyarnewith the ^:export ^:dev/after-load syntax btw. 🙂 if anyone wants to save a few keystrokes in the future#2019-02-1819:58heyarnethe meta data wasn't getting picked up at all. also when I removed the export. so maybe it was some kind of cache invalidation bug? it'll be hard to reproduce though#2019-02-1820:44thhellerno that can't affect the cache invalidation#2019-02-1820:45thhellerI wish people would stop deleting .shadow-cljs as the first instinct 😛#2019-02-1820:46thhellerdestroys all chances of ever finding out what was happening and fixing it 😞#2019-02-1821:54heyarneoops. next time i'll mv it#2019-02-1821:54thhellera restart would have been enough probably#2019-02-1821:55thhellerI'd guess that the watch maybe just got into a weird situation and either stopped recompiled completely#2019-02-1821:55thhelleror had some stuck state that wasn't cleaned properly#2019-02-1821:55thhellereither would have been fixed by simply restarting the watch#2019-02-1909:49r0man@thheller good morning. the problem I described yesterday happens in the browser#2019-02-1909:49r0manif I print (prn (.-moduleInfoMap (loader/getModuleManager))) I get an empty map.#2019-02-1909:50r0manbut I think it should contain the module information#2019-02-1909:50thhellerthat depends on where you print it. why are you printing it?#2019-02-1909:51thhellershadow$loader should only be assigned once? do you see it reassigned again in the code somewhere?#2019-02-1909:51r0manwell, just before I load a module with (loader/load "my-module" callback)#2019-02-1909:51r0manthis call fails with the following exception:#2019-02-1909:51thhellerand what is the problem you are looking into again?#2019-02-1909:52r0man#2019-02-1909:53r0manI'm trying to get my modules working again under advances optimizations. it used to work, but doesn't anymore with shadow 2.8.2.#2019-02-1909:53r0manwhen I look at my main module I see this in the beginning:#2019-02-1909:54thhellerhmm I never used that form. can you quickly try (-> (loader/load "my-module") (.then callback))?#2019-02-1909:54thhellerI suspect that the execOnLoad maybe was changed in the new closure lib (lots changed there)#2019-02-1909:54r0man#2019-02-1909:55r0manand in the middle of the main module there's other javascript that looks like this:#2019-02-1909:55r0man#2019-02-1909:55r0manwhich I think wipes out the module information.#2019-02-1909:55r0manyes, I'll try the promise version#2019-02-1909:55thhellerhmm thats odd#2019-02-1909:56r0manbut I think it will have the same problem#2019-02-1909:56thhellerit may just be closure re-using the variable though#2019-02-1909:56thhellerit does weird optimizations like that#2019-02-1909:57r0manthe 2nd snippet I showed is the actual shadow.loader code, I think#2019-02-1909:57r0manwhich uses the same namespace as the module info#2019-02-1909:59thhellerI really don't get why it is reassigned for you. I can't find any second assign in my code#2019-02-1910:00r0manhmm, strange#2019-02-1910:00r0manso at which point in your code is the shadow.loader namespace emitted#2019-02-1910:01r0manare you using pseudo-names to look at the js?#2019-02-1910:01thhellerat the top as it should be#2019-02-1910:01thhellerboth. tried with and without pseudo-names#2019-02-1910:01r0manand the module info comes after that?#2019-02-1910:03thhellervar shadow$loader = {"uris":{"demo":["/js/demo.js"],"extra":["/js/extra.js"]},"infos":{"demo":[],"extra":["demo"]}};#2019-02-1910:03r0manfrom the code I pasted above I don't understand how this can work. in the generated code I have, either the module info will wipe out the shadow.loader namespace or the other way around#2019-02-1910:04thhelleryes but I don't get where your second shadow$loader assignment is coming from#2019-02-1910:04thhellerthat doesn't make sense to me#2019-02-1910:04r0manif the shadow.loader code gets evaluated first, you might be lucky and the definitions are in the runtime by the time the module info wipes out the namespace#2019-02-1910:04r0manI think it's the shadow.loader namespace#2019-02-1910:05thheller
;var $shadow$loader$ml$$ = new $goog$module$ModuleLoader$$;
$shadow$loader$ml$$.$sourceUrlInjection_$ = !0;
var $shadow$loader$mm$$;
!$module$contents$goog$loader$activeModuleManager_moduleManager$$ && $module$contents$goog$loader$activeModuleManager_getDefault$$ && ($module$contents$goog$loader$activeModuleManager_moduleManager$$ = $module$contents$goog$loader$activeModuleManager_getDefault$$());
$shadow$loader$mm$$ = $module$contents$goog$loader$activeModuleManager_moduleManager$$;
$shadow$loader$mm$$.$loader_$ = $shadow$loader$ml$$;
#2019-02-1910:21r0man@thheller What's directly in front of the ";"? first character on the first line?#2019-02-1910:21r0manhere is where I have the var shadow$loader = {}#2019-02-1910:22thhelleruhm some other code from another namespace#2019-02-1910:22thhellerbut the problem is clear now#2019-02-1910:22thhellerat least in my setup#2019-02-1910:22r0manwhich I think comes from this line https://github.com/thheller/shadow-cljs/blob/01a0b4810047c719ae528f5ff2bdd26b0dcfe4fd/src/main/shadow/loader.js#L1#2019-02-1910:22r0mangoog.provide("shadow.loader");#2019-02-1910:23thhellerno the ns alias would be $shadow$loader#2019-02-1910:24r0manbut that's not what I'm seeing#2019-02-1910:24r0manit's the same!#2019-02-1910:24r0manat least in my file 🙂#2019-02-1910:24thhelleryes. but you are looking at the wrong thing#2019-02-1910:24thhellerI can reproduce this 100% if :module-loader is missing from the config#2019-02-1910:25thhellertry deleting all your output files and recompile again after restarting shadow-cljs#2019-02-1910:25thhellerjust to ensure nothing is stuck somewhere and you are looking at the correct files#2019-02-1910:25r0manok#2019-02-1910:26thheller
var $goog$module$ModuleLoader$EventType$EVALUATE_CODE$$ = new $goog$events$EventId$$("evaluateCode$0"), $goog$module$ModuleLoader$EventType$REQUEST_SUCCESS$$ = new $goog$events$EventId$$("requestSuccess$1"), $goog$module$ModuleLoader$EventType$REQUEST_ERROR$$ = new $goog$events$EventId$$("requestError$2");
function $goog$module$ModuleLoader$EvaluateCodeEvent$$() {
  $goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$EVALUATE_CODE$$);
}
$goog$inherits$$($goog$module$ModuleLoader$EvaluateCodeEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$RequestSuccessEvent$$() {
  $goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$REQUEST_SUCCESS$$);
}
$goog$inherits$$($goog$module$ModuleLoader$RequestSuccessEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$RequestErrorEvent$$($moduleIds$jscomp$9$$, $opt_error$jscomp$4$$) {
  $goog$events$Event$$.call(this, $goog$module$ModuleLoader$EventType$REQUEST_ERROR$$);
  this.error = $opt_error$jscomp$4$$ || null;
}
$goog$inherits$$($goog$module$ModuleLoader$RequestErrorEvent$$, $goog$events$Event$$);
function $goog$module$ModuleLoader$LoadStatus$$() {
  this.$responseTexts$ = this.$requestUris$ = null;
  this.$loadRequested$ = !1;
  this.$errorFn$ = this.$successFn$ = null;
}
;var $shadow$loader$ml$$ = new $goog$module$ModuleLoader$$;
$shadow$loader$ml$$.$sourceUrlInjection_$ = !0;
var $shadow$loader$mm$$;
!$module$contents$goog$loader$activeModuleManager_moduleManager$$ && $module$contents$goog$loader$activeModuleManager_getDefault$$ && ($module$contents$goog$loader$activeModuleManager_moduleManager$$ = $module$contents$goog$loader$activeModuleManager_getDefault$$());
$shadow$loader$mm$$ = $module$contents$goog$loader$activeModuleManager_moduleManager$$;
$shadow$loader$mm$$.$loader_$ = $shadow$loader$ml$$;
$goog$global$$.shadow$loader && function() {
  $shadow$loader$mm$$.$setAllModuleInfo$($goog$global$$.shadow$loader.infos);
  var $uris$jscomp$6$$ = $goog$global$$.shadow$loader.uris;
  $shadow$loader$mm$$.$setModuleUris$ ? $shadow$loader$mm$$.$setModuleUris$($uris$jscomp$6$$) : ($goog$object$getKeys$$($uris$jscomp$6$$).forEach(function($key$jscomp$115$$) {
    var $trusted_uris$$ = [];
    $uris$jscomp$6$$[$key$jscomp$115$$].forEach(function($uris$jscomp$6$$) {
      var $key$jscomp$115$$ = new $goog$html$TrustedResourceUrl$$;
      $key$jscomp$115$$.$privateDoNotAccessOrElseTrustedResourceUrlWrappedValue_$ = $uris$jscomp$6$$;
      $trusted_uris$$.push($key$jscomp$115$$);
    });
    $uris$jscomp$6$$[$key$jscomp$115$$] = $trusted_uris$$;
  }), $shadow$loader$mm$$.$setModuleTrustedUris$($uris$jscomp$6$$));
}();
#2019-02-1910:26thhellerfwiw#2019-02-1910:05r0manI'm just experience the case that the shadow.loader namespace gets emitted AFTER the module info. in your case it seems to be the other way around#2019-02-1910:05thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#2019-02-1910:06thhellerwhat do you mean? do you not have var shadow$loader = ... assignment at the very top of the file?#2019-02-1910:06thheller
var shadow$provide = {};
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
    Math.imul = function (a, b) {
        var ah  = (a >>> 16) & 0xffff;
        var al = a & 0xffff;
        var bh  = (b >>> 16) & 0xffff;
        var bl = b & 0xffff;
        // the shift by 0 fixes the sign on the high part
        // the final |0 converts the unsigned value into a signed value
        return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
    }
}

var shadow$loader = {"uris":{"demo":["/js/demo.js"],"extra":["/js/extra.js"]},"infos":{"demo":[],"extra":["demo"]}};
#2019-02-1910:06thhellerlike that?#2019-02-1910:06thhellerthat should be the absolutely only assignment ever#2019-02-1910:07r0manyes, I have that. but in the same file the shadow.loader code is emitted after this module info declaration#2019-02-1910:07thhellerthe code that translates the shadow$loader into the actual runtime data is coming way later#2019-02-1910:07thhellerthat is normal yes#2019-02-1910:07r0manwhich I think wipes the module info out#2019-02-1910:07thhellerplease stop for a second#2019-02-1910:07thhellerlets clean up our understanding of the situation#2019-02-1910:08thhellera) your COMPILED code contains two assigns for shadow$loader?#2019-02-1910:08thhellerdoes matter where#2019-02-1910:09thhellerie if you grep your compiled code for shadow$loader = that should only find ONE occurence#2019-02-1910:09thhelleroh fuck .. I have a guess#2019-02-1910:10thhellerdo you have :module-loader true in your build config?#2019-02-1910:10r0manyes, I have :module-loader true.#2019-02-1910:10thhellerhmm doh#2019-02-1910:10r0manI think I tried without, but let me check again#2019-02-1910:10thhellerno it should be in there#2019-02-1910:10thhellerbut again please answer my question#2019-02-1910:10thhellerhow many assignments are there?#2019-02-1910:11r0man2#2019-02-1910:11thhellerthe correct one at the top and the empty one later?#2019-02-1910:11r0manbut, let's clarify this also. shadow$loader is getting assigned 2 things. the module info and the shadow.loader namespace, right?#2019-02-1910:12r0manso this file: https://github.com/thheller/shadow-cljs/blob/01a0b4810047c719ae528f5ff2bdd26b0dcfe4fd/src/main/shadow/loader.js#2019-02-1910:12thhellerok I reproduced the problem now#2019-02-1910:12r0manand the module info which is then used by the shadow.loader namespace#2019-02-1910:12thhellerif I remove :module-loader true from my config it breaks like yours#2019-02-1910:12thhellerI guess I messed up the automatic detection of that flag#2019-02-1910:13thhellerit is supposed to be detected automatically so you don't have to set it#2019-02-1910:13thhellerplease check if you have :module-loader true in your config in the correct place#2019-02-1910:14thheller:module-loader true :modules {...}#2019-02-1910:14r0manjust right above :modules, yes#2019-02-1910:14thhellerhmm typo?#2019-02-1910:15r0manno, it's fine#2019-02-1910:15thhellerI can definitely reproduce it when it is not set but adding it fixes everything#2019-02-1910:15thhellerwell. I'll fix it so you don't need to ever set it#2019-02-1912:09metacriticalHi @thheller I am trying to add a ~/.b42 into the classpath in shadow-cljs.edn :source-paths but i think it doesnt resolve ~as home directory.#2019-02-1912:13jlmrHi, I’m getting [:did-not-find <name-of-ns>] errors for namespaces that do exist. What does this error indicate?#2019-02-1912:28thheller@metacritical yes it doesn't resolve source paths at all. I wouldn't expect that to work in any java setup?#2019-02-1912:28thheller@jlmr that happens in your (in-ns 'foo.bar) without having done (require 'foo.bar) first#2019-02-1912:32jlmrOk, thanks, will look at it further#2019-02-1912:32jlmrFor some reason the errors are not occuring now 🙂#2019-02-1912:34thhellerhttps://github.com/thheller/shadow-cljs/issues/398#2019-02-1912:36metacritical@thheller Thanks!#2019-02-1916:20idiomancySo, I'm getting this reference error when importing this js lib, and I see that is seems to be looking for an underscored version of the library. is that relevant to the problem? ReferenceError: module$node_modules$aws_appsync$lib$index is not defined#2019-02-1916:21idiomancy#2019-02-1916:21idiomancy#2019-02-1916:25idiomancyseems to have sorted itself out, actually... I think it must have been outside the compile path for that build#2019-02-1918:13wilkerlucio@thheller I noticed something a bit weird, I have in my project my own cljsjs files for some libs that we do override impl, I noticed if I put a .js file in the cljsjs ns and try to require it, shadow can't find it, but moving to a different folder cljsjs-mine for example makes it work, seems like its doing special threatment for cljsjs, is that expected?#2019-02-1918:14thhelleryes that is expected#2019-02-1918:15thhellerotherwise it would start inspecting all the files in cljsjs which would include all the foreign libs#2019-02-1918:16thhellerI'm probably removing the classpath indexing soon though since its not really all that useful#2019-02-1918:17thhellerthen I could lift that restriction#2019-02-1918:40wilkerluciocool, thanks for the clarification#2019-02-2002:06currentooris there a way to force shadow-cljs to output a node script that packages all code and dependencies into a single file? it looks like the default behavior requires me to npm install where i end up running node, ideally i only send a single self-contained file, much like an uberjar#2019-02-2006:56levitanonghi everyone. are release artifacts supposed to look for things in /workdir/.shadow-cljs/builds/{{project}}/dev/out/cljs-runtime/?#2019-02-2006:58thheller@levitanong no, that is not part of a release build. note the dev in the path.#2019-02-2006:59thheller@currentoor that is currently experimental and still has a bunch of issues that need to be resolved https://github.com/thheller/shadow-cljs/issues/290#2019-02-2015:52currentoorEverything I ever want from shadow-cljs is either there or already in the process of getting there. You’re awesome!#2019-02-2015:54thhellerI need testers for that feature. you can test it today on your builds and let me know about packages that break or don't compile#2019-02-2006:59levitanong@thheller so this is weird. I’m building a node script, ran a release on it, and when i ran it in docker, it gave me a bunch of errors about not finding '/workdir/.shadow-cljs/builds/image-gen/dev/out/cljs-runtime/goog.debug.error.js'#2019-02-2006:59thhellerthen you are not using the correct file#2019-02-2006:59thhellera release build will definitely not contain any references like that#2019-02-2007:00levitanongwon’t a release build simply overwrite a dev build artifact if they have the same name?#2019-02-2007:01thhelleryes it would#2019-02-2007:01thhellertypically#2019-02-2007:01levitanongAnd i don’t think i’m doing anything weird like renaming things… so I don’t see how i could be using the wrong file#2019-02-2007:02thhellerwell run shadow-cljs release the-build and look at the output#2019-02-2007:03thhellera dev build can be identified pretty easily it will start with something like
#!/usr/bin/env node
(function(){

var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/script/dev/out/cljs-runtime';
#2019-02-2007:03thhellera release build will not contain that path and start directly with minified code#2019-02-2007:07levitanongooh, that’s useful. thanks!#2019-02-2008:05p-himikI'm trying to use shadow-cljs with https://github.com/juxt/kick.alpha and https://github.com/juxt/edge The issue with the first one: it has a file called injector.cljs that imports figwheel which I don't use and don't have in the classpath. I think shadow-cljs tries to compile every single cljs file on the classpath, and it fails on this one while building the :npm build. Is this really an issue (I haven't gotten the project to work yet, so can't check)? If so, what would be the correct way of fixing it? If not, can I remove the :npm build from the shadow-cljs configuration data to remove the error message? The issue with the second one is that it wants me to add all publicly available web resources to the classpath, including the ones that are generated in target. There are some JS files there as well and because of that, shadow-cljs spams a huge number of warnings about "provide conflict", like provide conflict for #{pathetic.core} provided by pathetic/core.cljs and {"/cljs-runtime/cljs-runtime.pathetic.core.js" #{pathetic.core}}. I think it's possible to fix it by not adding target to the classpath and altering request handlers so that they look there. But to be honest, I have no idea whether that would work with the release uberjar. Another potential way to fix it would be to still have target in the classpath for the server and not have it for shadow-cljs. The only issue here is that I have to write some code to create the correct set of aliases for :deps in the shadow-cljs configuration data, but I think it could be done. But is there another way to solve this that's perhaps more preferable?#2019-02-2008:46thheller@p-himik shadow-cljs only compiles files that are actually required. so injector.cljs must be required from somewhere.#2019-02-2008:48thhellercan't find an injector.cljs in the edge repo? ah its in the kick repo whatever that is 😛#2019-02-2009:51metacritical@thheller I am trying to use compile-strin bootstrapped clojurescript instead of eval-strand it returns a nullfor a string like "(.log js/console \"HI\")"#2019-02-2009:52metacriticalPlease do try and let me know what you get. I tried the same thing with lein based project and it works, so could it be due to some way shadow bootstraps the compiler?#2019-02-2010:05thheller@metacritical I don't even know what compile-str is so I can't say whats its supposed to return. if you paste the full code I can maybe tell you what is wrong#2019-02-2010:05thhellerwithout any code I can't help#2019-02-2010:09metacritical@thheller Well it is supposed to compile cljs to js#2019-02-2010:10metacriticalIt is in the same namespace as cljs.js#2019-02-2010:10metacriticalhttps://cljs.github.io/api/cljs.js/compile-str#2019-02-2010:13metacriticalI think it will be better if i give you the context of what i am trying to do. I am trying to write a electron app that has bootstrapped cljs so that it can eval config files at runtime. but i am unable to get the ambient environment functions when i eval it so i thought i will do a global eval against node ‘vm’ by translating the cljs code to js.#2019-02-2010:54thhellercan't say anything about that but I can compile things just fine#2019-02-2010:54thheller
(ns demo.bootstrap-script
  (:require
    [cljs.js :as cljs]
    [cljs.env :as env]
    [shadow.cljs.bootstrap.node :as boot]))

(defn print-result [{:keys [error value] :as result}]
  (prn [:result result]))

(def code "(.log js/console \"HI\")")

(defonce compile-state-ref (env/default-compiler-env))

(defn compile-it []
  (cljs/compile-str
    compile-state-ref
    code
    "[test]"
    {:eval cljs/js-eval
     :load (partial boot/load compile-state-ref)}
    print-result))

(defn main [& args]
  (boot/init compile-state-ref {} compile-it))
#2019-02-2010:54thhelleroutputs [:result {:value "console.log(\"HI\");\n"}]#2019-02-2012:49p-himik@thheller It's very strange - I can't find it anywhere. The relevant ns is indeed added to the list of preloads but only if I explicitly tell kick.alpha to use figwheel. And there are no messages in the logs mentioning that if was used. Is there any way to find out what exactly has made shadow-cljs compile a particular file?#2019-02-2013:50thheller@p-himik shadow-cljs clj-repl then (shadow/find-resources-using-ns 'that.thing.inector)#2019-02-2013:52thhellerbut if the edge stuff modifies the classpath or so it may not find whatever is using it#2019-02-2013:53thhellerthere is this in the repo. not sure what this is about. https://github.com/juxt/kick.alpha/blob/master/src/juxt/kick/alpha/providers/shadow_cljs.clj.txt#2019-02-2013:54thhellerI don't know what edge is about or what it needs so I'm absolutely clueless about whats going on#2019-02-2014:04p-himikThanks, I'll try that. The file that you linked is not used because the authors of kick don't use shadow-cljs. I just copied that file to my project and modified it a bit for my needs.#2019-02-2014:07p-himikYeah, of course that call returns just #{}.#2019-02-2014:40thhelleryou can just replace that file with one that just defines the ns and nothing else#2019-02-2014:41p-himikI won't resolve to such easy fixes. I need to know the truth! 🙂 I'll try to dig around for a bit.#2019-02-2014:42thhellerwell if you do that it will be much easier to find out why it is included#2019-02-2014:43thhellerbut can you explain a little bit what any of this does?#2019-02-2014:44thhellerwhy are there a billion directories with only one file each?#2019-02-2014:45p-himikAh, gotcha. But I'm almost positive it's injected dynamically in some way. But I'll do that, sure. "Any of this" - you mean kick? Not sure to what directories you're referring.#2019-02-2014:51p-himikStill #{}.#2019-02-2014:52thhellerif you have a build running that has the empty version injected#2019-02-2014:52thhelleropen up http://localhost:9630#2019-02-2014:53thhellernavigate to the build and recompile it#2019-02-2014:56thhellerthere is a "Build Namespaces" at the bottom#2019-02-2014:57thhellerselect the injector and it will tell you how it got included#2019-02-2014:57p-himikOooh, neat! But here's the issue - the problem is only reproducible with the :npm build that's injected automatically. And I don't see this build in the UI. Maybe I can try just copying it so it becomes an explicit build.#2019-02-2014:57p-himikFor my :main build, there's no injector in the list of namespaces.#2019-02-2014:58thhellerah ... I missed the part where you are using the built-in default :npm build#2019-02-2014:58thhellerthat indeed does compile everything unless you configure it#2019-02-2014:58thhellerso don't use that 🙂#2019-02-2014:59thhellerconfigure it like this
{:npm
 {:target :npm-module
  :entries [your.main.ns]
  :output-dir "node_modules/shadow-cljs"}}
#2019-02-2014:59p-himikWait a second, I don't use it anywhere. I have no idea what it's for even - I just copied your code from load-cljs-edn.#2019-02-2014:59thhellerthat will only include the :entries and their deps#2019-02-2015:00thhellerah now I get it#2019-02-2015:01thhelleryou are just loading the config and start every build defined in it#2019-02-2015:01thhelleryeah don't do that 🙂#2019-02-2015:01p-himikAh, I see! In hindsight, that was kinda obvious and stupid of me. 🙂 Thanks!#2019-02-2015:02thhellerwhat is this kick stuff even for?#2019-02-2015:04p-himikIt's a build system that should make it easy to automate stuff. E.g. restart your whole build chain and server when you enter (reset) in the REPL. It can also help in situations where you don't want to restart everything, e.g. you need to reload some components without dropping all active connections. But I just started using it and I've never used anything like it before, so I can't really tell you anything really useful about it.#2019-02-2015:05thhellerbut why would you want to restart shadow-cljs when you restart your server?#2019-02-2015:05thhellerthey shouldn't be coupled in the first place?#2019-02-2015:08p-himikWell, I can add one thing. In my previous project, I had to either specify some paths two times or to parse shadow-cljs.edn within the main code to make the server know about all of the resources. Here, it's launched using the single source of truth, config.edn. It contains everything you want it to contain, and since it uses aero, you can avoid duplication entirely. I need to restart shadow-cljs if I e.g. change a path. In some cases I had to restart it when I added something - don't really recall the details but I think it had to do something with a macros and a new namespace. But I can make it so that shadow-cljs is not restarted if I don't want it to be restarted. And since it's all in the same JVM that's still running, it doesn't take that much time anyway.#2019-02-2015:09p-himikMaybe their example will give you a better idea of what it can do: https://github.com/juxt/edge/blob/master/main/resources/config.edn#2019-02-2015:12thhellerhmm I see#2019-02-2015:13thhelleryeah shadow-cljs isn't really meant to be used that way. the assumption that there is a shadow-cljs.edn and hardcoded and not optional (currently)#2019-02-2015:13thhellerso your builds need to be defined in there#2019-02-2015:13thhellereverything else is fine#2019-02-2015:15thhellerso basically you'll need a shadow-cljs.edn with the builds define like normal#2019-02-2015:15thheller
:kick/shadow-cljs
{:build-to-start [:foo :bar]}
#2019-02-2015:15thhelleryou then start those builds in the provider thing#2019-02-2015:16thhelleryou could define the builds "outside"#2019-02-2015:16thhellerbut currently there are several things that are tied to the config#2019-02-2015:16p-himikHmm, I thought I could get away with just using (shadow.cljs.devtools.server/start! (dissoc config :builds)) and (shadow.cljs.devtools.api/watch (assoc build :build-id build-id)) while feeding it the config that was preprocessed the same way you do it.#2019-02-2015:17thhellereg. when you edit the config it will automatically trigger a recompile with the new config#2019-02-2015:17thhelleryou can get away with it to some degree yes#2019-02-2015:18thhellerjust absolutely not recommended and I make no guarantees that it will work reliably#2019-02-2015:18thhelleralso how do you do a release build in that setup?#2019-02-2015:21p-himikHmm. But using shadow-cljs.edn again brings that problem of having either to copy some values or to parse shadow-cljs.edn. I'll see how it works out with the common config - maybe that's "some degree" is well within my needs. To be honest, I have never made a CLJ app release, so I'm yet to find that out.#2019-02-2015:21thhellercopy which values?#2019-02-2015:22p-himik:output-dir needs to be specified for both shadow-cljs and for the server to serve the generated files.#2019-02-2015:23p-himikSame with :asset-path, I think.#2019-02-2015:23thhellerhow often do you change the :output-dir? I haven't changed mine in 4 years 😛#2019-02-2015:25p-himikTrue. But just having it being specified in multiple places makes things harder to reason about, especially when you work with other people and have different projects that use different approaches while still using shadow-cljs. And I don't like to rely on anyone's memory when it can be avoided, including my own. 🙂#2019-02-2015:27thhellerI'm trying to understand the architecture. I suppose the main/deps.edn is the primary source for deps#2019-02-2015:29p-himikIndeed.#2019-02-2015:30thhellerso why not put shadow-cljs.edn right next to that main/deps.edn. make it use :deps {:aliases [:dev]}#2019-02-2015:30thhellerand run them separately#2019-02-2015:30thhelleror if you really prefer you can run the embedded version just fine#2019-02-2015:31thhellerbut if you move the config into the config.edn thing I don't understand how you build a release build then?#2019-02-2015:32thhellerhow is this done for the figwheel sutff?#2019-02-2015:33thhellerI can't figure out where the release build happens in the repo?#2019-02-2015:34p-himikSince I've never done that before, I'm not really sure what issues you have in mind. In the edge repo they have bin/onejar:
#!/bin/sh

clojure -Sdeps '{:deps {pack/pack.alpha {:git/url "" :sha "0878b52b7718e4b348a500dce0b3edc5b555a4f1"}}}' -m mach.pack.alpha.one-jar "
And in the documentation it says to release the app with:
$ ../bin/onejar -A:prod --args '-m edge.main' project.jar
#2019-02-2015:35thhellerthat seems to be the server side stuff#2019-02-2015:35thhellerhow is the CLJS compiled in :advanced?#2019-02-2015:35thhellerI can see the config but don't quite get how it is built#2019-02-2015:38thhellerI certainly hope that figwheel/scss/shadow-cljs aren't running in production servers 😛#2019-02-2015:38p-himikThat's not my plan, at least. 🙂 Let me see...#2019-02-2015:41thhellerso this entire edge architecture commits several sins in my view#2019-02-2015:41thhellerhow do you even deal with dependency conflicts?#2019-02-2015:42thheller
lib.ig.yada/deps.edn
3:        integrant {:mvn/version "0.6.3"}
phonebook-api/deps.edn
6:  integrant/integrant {:mvn/version "0.7.0"}
#2019-02-2015:43thhellerhow does that not get even more out of date the longer the project lives? 😛#2019-02-2015:43thhellerwhy are they spread all over the place 😛#2019-02-2015:43thhellerhow do you ever audit all deps ...
#2019-02-2015:43p-himikThese pieces are not really parts of the main projects. They're local libraries.#2019-02-2015:44thheller
edge.asciidoctor/deps.edn
4:  integrant/integrant {:mvn/version "0.8.0-alpha2"}
#2019-02-2015:44p-himikAnd they work like local libraries. And dependency resolution works the same way as it does in Java in general.#2019-02-2015:45thhellerok, I don't have to like it. I can still help you figure out how to best integrate everything#2019-02-2015:47p-himikThank you. I'll keep banging against all the new walls here, and if my head starts to hurt I'll come back.#2019-02-2015:47thhellerlet me know if you find where the release build for CLJS is produced#2019-02-2015:47thhellerso far I can't find it#2019-02-2015:48thhelleror the scss for that matter#2019-02-2015:53lilactown@dominicm might be able to provide some help fyi#2019-02-2015:54thhellerI think I figured it out#2019-02-2015:55dominicmHaven't read up, but ask away#2019-02-2015:55dominicmThe dependency problem is real, but no worse than when you have libraries.#2019-02-2015:58lilactownI think the original question was here: https://clojurians.slack.com/archives/C6N245JGG/p1550649905397600#2019-02-2015:58thhelleryeah I couldn't figure out how the release build is produced for the CLJS code#2019-02-2015:58thhellerbut I think its the build alias and the kick oneshot! thing#2019-02-2015:58dominicmThere's a oneshot multi method for performing production asset builds, the code lives mostly in kick, but has a main in edge under lib.edge.kick iirc#2019-02-2016:00dominicmI don't love the production build code yet. So I suspect it will go through some evolutions.#2019-02-2016:01dominicmYou're right about the reset, but we solve it by only restarting servers if the config has changed.#2019-02-2016:02dominicmIt used to be a var def'd in a namespace, but that was changed to integrate it with config.edn better.#2019-02-2016:05dominicmI think we had some projects where shadow-cljs.edn was not expressive enough for us, and we wanted to use the API and aero tags because of that.#2019-02-2016:11anmonteiro@thheller what would this do in practice? https://github.com/thheller/shadow-cljs/commit/e8ed39ad2081b34f219c74c9c893143c3ee794ea#2019-02-2016:12thhellersuppose you have a (:require ["react" :as r]) in your code but don't use it#2019-02-2016:12thhelleror only use it on a function that itself was not used#2019-02-2016:12anmonteiroI feel like upgrading shadow from 2.7.29 (?) to 2.8.2 may have broken some of our code#2019-02-2016:12thhellerpreviously react would still be included in the build#2019-02-2016:12anmonteirobut I haven’t pin pointed exactly what#2019-02-2016:12thhellerupgrade to 2.8.5#2019-02-2016:12anmonteiroI did#2019-02-2016:12thhellerthat should fix most of the funkiness#2019-02-2016:12anmonteiroI’m on 2.8.5 now I think#2019-02-2016:13thhellerdo you use lots of the closure lib stuff?#2019-02-2016:13anmonteiroyeah we’re on 2.8.5 and seeing broken stuff#2019-02-2016:13anmonteirothis is related to jQuery#2019-02-2016:13thhellerbroken how?#2019-02-2016:13anmonteiroso only in advanced#2019-02-2016:14anmonteiroI haven’t exactly pinpointed what is broken, but I’m getting this error: TypeError: b.modal.modal is not a function#2019-02-2016:14thheller.modal.modal?#2019-02-2016:14anmonteirowhere b should be a React component instance, modal a ref#2019-02-2016:14anmonteiroref to js/$#2019-02-2016:14anmonteiroand modal.modal the Bootstrap modal function#2019-02-2016:14anmonteirobad naming but this.jqueryref.modal()#2019-02-2016:14anmonteirobasically#2019-02-2016:15thhellerah hmm not sure why that would be different?#2019-02-2016:15anmonteirome neither but the code hasn’t been touched since March 2018#2019-02-2016:15thhellerdid you accidentally also update react when upgrading shadow-cljs?#2019-02-2016:15anmonteirono we upgraded React 2 weeks ago and this worked fine since#2019-02-2016:15thhellergiven all the version range crap defaults in node and stuff?#2019-02-2016:15thhellerhmm ok#2019-02-2016:16anmonteirothis is either (missing) externs or JS deps stuff#2019-02-2016:16anmonteirodid anything change in shadow recently wrt externs?#2019-02-2016:16thhelleroh shit#2019-02-2016:16anmonteiro😞#2019-02-2016:17anmonteirok reverting the PR#2019-02-2016:17thhellerdo you maybe have some JS requires for only the side effects?#2019-02-2016:17anmonteiromaybe?#2019-02-2016:17anmonteirooh yeah we do 😄#2019-02-2016:17anmonteiro(:require ["bootstrap"]#2019-02-2016:17thhellerhehe oops yeah they will be removed now#2019-02-2016:17anmonteirofor jQuery plugin injection#2019-02-2016:17anmonteiro😄#2019-02-2016:17thhellerdoh didn't think about that case#2019-02-2016:17thhellerhehe doh#2019-02-2016:18anmonteiroso the commit I pointed out is the bad one?#2019-02-2016:18anmonteirosomehow it jumped to sight#2019-02-2016:18thhelleryeah#2019-02-2016:20anmonteiroI’m gonna revert and upgrade to the next one once you fix this#2019-02-2016:20anmonteirothanks for the help#2019-02-2016:21thheller@anmonteiro release is building. give it a min or so. will be 2.8.6#2019-02-2016:21anmonteirooh kk#2019-02-2016:23thhellerok should be available. sorry about that.#2019-02-2016:23thhellerthe idea sounded good in my head and worked nicely for the tests I did#2019-02-2016:24thhellerjust forgot that you may want things only for their side effects 😛#2019-02-2016:24lilactownstupid side effects!#2019-02-2016:26lilactownso, question about shadow.loader: we are heavily using it in a project to load modules as needed on our web pages. it sounds like 2.8 upgrades GCC which might impact this. anything I should be aware of out of the gate?#2019-02-2016:27thhellerno it should work as before#2019-02-2016:27thhellerassuming you are using 2.8.6. the previous releases were all bad due to a bad :language-out default#2019-02-2016:28lilactownok. good to know#2019-02-2016:28thhellerI tried my best to make it work again. it changed a whole bunch if the closure library but it works fine in all my builds#2019-02-2016:28thhellerso it should be fine#2019-02-2016:29lilactownwe're also currently troubleshooting an issue with IE 11 where a few certain modules just won't load. I'm heading into the office now to investigate 😛 one of the problems we're running into is that it's hard to know why a module might fail to load/run. any tips on how to get more insight into that?#2019-02-2016:30lilactowne.g. another issue we had was, a module wouldn't load when cookies was off; turns out it was referring to js/localStorage at the top level and throwing an exception, but we weren't getting any kind of indication that was happening. just the promise returned by shadow.loader never resolved#2019-02-2016:30thhellergiven the awful state of the IE11 devtools not really#2019-02-2016:31thhellerwell do you have an error handler attached?#2019-02-2016:31lilactownyes#2019-02-2016:31thheller
(-> (loader/load "extra")
    (.then fn-to-call-on-load fn-to-call-on-error))
#2019-02-2016:31thhellerso the second fn is also never triggered?#2019-02-2016:31lilactowni'll verify but that's the behavior we were seeing#2019-02-2016:32thhellerIE11 also doesn't like console IIRC#2019-02-2016:32thhelleronly when the devtools are open#2019-02-2016:32lilactownyeah I'm exploring that too.#2019-02-2016:33thhellerI would expect the loader to properly propagate errors#2019-02-2016:33thhellerbut who knows#2019-02-2016:33lilactownI almost gave up on web dev the first time I had to track down a bug due to that 😛#2019-02-2016:34anmonteiro@thheller btw to make module loading work for us we had to monkey patch google closure#2019-02-2016:34anmonteirowhich is… fun#2019-02-2016:35lilactownwhat did you end up patching?#2019-02-2016:35anmonteiro
(.setSourceUrlInjection loader false)
         (.setDebugMode loader true)
         (set! (.-usingSourceUrlInjection_ loader) (fn [] false))
#2019-02-2016:35anmonteirowe need to force this google.loader.moduleLoader.prototype.usingSourceUrlInjection_ function to always return false#2019-02-2016:36anmonteiroto force the module loader into debug mode#2019-02-2016:36thhellerwhy is that a problem?#2019-02-2016:36anmonteirootherwise it uses XHR + eval and our content security policy doesn’t allow that#2019-02-2016:36anmonteirowe want it to add script tags to the DOM#2019-02-2016:37thhellerinteresting#2019-02-2016:37anmonteiroto be clear what we disallow is eval, not xhr#2019-02-2016:37anmonteiroit was actually fun to debug (in hindsight), because our bundles were coming back with status 200 but there was a stupid runtime error from the loader#2019-02-2016:39thhellerwonder why there is no built-in flag for this. I'd expect google to also disallow eval#2019-02-2016:39anmonteiroyeah.. I wondered the same#2019-02-2016:39anmonteirothe Closure Library documentation is also not the best#2019-02-2016:39anmonteiroI don’t think many people use it outside Google + ClojureScript#2019-02-2016:39thhelleryeah the module loader also now requires a method call that wasn't there previously#2019-02-2016:39thhellernot documented at all. fun times.#2019-02-2016:40anmonteirohopefully fixed in Shadow?#2019-02-2016:40anmonteiroand we can just keep doing what we were doing downstream? 🙂#2019-02-2016:40thhelleryeah it injects the needed code#2019-02-2016:40anmonteiro var trustReason = goog.string.Const.from("generated by compiler"); ?#2019-02-2016:41thhelleryeah that was a fun one too#2019-02-2016:41anmonteirouh#2019-02-2016:41anmonteiroI might have to touch that code#2019-02-2016:41thhellerso weird. closure library is full of those "safe" constructs to ensure things are "trusted"#2019-02-2016:41thhellerI really wonder how google injects the module loader config#2019-02-2016:42anmonteirois setModuleUris not there anymore?#2019-02-2016:42thhellernope its gone#2019-02-2016:42anmonteiro😞#2019-02-2016:42anmonteirowe’re monkey patching that code too#2019-02-2016:42thhellersetModuleTrustedUris now#2019-02-2016:42anmonteiroto add the CDN prefix for our modules#2019-02-2016:43thhellerdon't monkey patch stuff. just tell me that you need a setting for something 😉#2019-02-2016:43thhellerbut :asset-path takes care of that no?#2019-02-2016:43anmonteirothen we need to be able to prefix the module URIs with the CDN path#2019-02-2016:43anmonteirowe don’t know it at compile time#2019-02-2016:43anmonteiroit’s a chicken-egg problem#2019-02-2016:43anmonteirowe need to compile the CLJS for Buck to output the compiled hash#2019-02-2016:44anmonteirothat’s how we guarantee we don’t do work if nothing changes in our CLJS#2019-02-2016:44anmonteirothe hash stays the same#2019-02-2016:44anmonteiroin fact, our server “tells” the HTML what the CDN asset path is#2019-02-2016:45anmonteiroso I’m currently doing:
(->> (js/Object.keys old-uris)
              (run! (fn [k]
                      (let [links (->> (gobj/get old-uris k)
                                       (map (fn [path]
                                              (build/static-url path)))
                                       into-array)]
                        (gobj/set uris k links)))))
         (gobj/set js/goog.global.shadow$modules "uris" uris)
         (js/shadow.loader.mm.setModuleUris
          (gobj/get goog.global.shadow$modules "uris"))
#2019-02-2016:45thhelleryou can use :module-loader :no-inject so it doesnt inject the shadow$modules variable#2019-02-2016:45thhellerwhich you can just set via HTML instead for example#2019-02-2016:45anmonteirohaving a way to not do this would be appreciated, but it’s not a strong need from our side#2019-02-2016:45anmonteiroah, interesting#2019-02-2016:46anmonteirothe user guide only mentions :module-loader true 😛#2019-02-2016:46thhelleryeah its well hidden 😉#2019-02-2016:47thhellerbasically the build output generates the module-loader.edn file (or .json)#2019-02-2016:47thhelleryou can use that data. rewrite it and emit in into html#2019-02-2016:47thheller<script>var shadow$modules = <the-json>;</script>#2019-02-2016:47thhellersomewhere before the JS include#2019-02-2016:48thhellerhttps://github.com/thheller/shadow-cljs/blob/f396caecf908b3e135a58f1af5aa433b1ce19326/src/main/shadow/build/targets/browser.clj#L654-L658#2019-02-2016:48thhellerI've done this in the past but stopped caring about busting caches along the way#2019-02-2016:49thhellerbut yeah there had to be a different way of getting that info there#2019-02-2016:49thhellersince adding the hashed urls to the file changes the hash of that file 😉#2019-02-2016:50anmonteirowhat does “inject the loader data” mean?#2019-02-2016:50thhellerinject the shadow$modules var into the code (was shadow$loader previously, renamed because of a weird renaming bug)#2019-02-2016:52anmonteirohrm so ideally I’d like something in the middle#2019-02-2016:55thhellerlike what?#2019-02-2016:57anmonteirolike, a function to map over the URIs and prefix them 😛#2019-02-2016:57anmonteirobut I might be asking too much#2019-02-2016:57anmonteiroit’s OK to say no 😛#2019-02-2016:57thhellerso you only know the prefix at runtime not at build time?#2019-02-2016:57anmonteiroalso, it might be that the deploy hasn’t fully completed, but I’m seeing the same runtime error with shadow 2.8.6#2019-02-2016:58anmonteiroyeah I only know the prefix at runtime#2019-02-2016:58anmonteiroin the JS thing#2019-02-2017:00anmonteiro@thheller yeah 2.8.6 didn’t fix our thing#2019-02-2017:00anmonteiroreverting to 2.7.29#2019-02-2017:01thhellerwhat is the problem?#2019-02-2017:02anmonteirosame one#2019-02-2017:02anmonteiromodal.modal thing#2019-02-2017:03thhellerhmm odd#2019-02-2017:03anmonteiroagreed#2019-02-2017:04thhellerthe code removal is definitely disabled#2019-02-2017:04anmonteirothis could be between 2.7.29 and 2.8.X#2019-02-2017:05anmonteiroI don’t have too much insight into what the problem would be#2019-02-2017:05thhellerhmm if you handle the caching and stuff it might be the new minimize-require default#2019-02-2017:06thhellerthat will definitely break if you use files from different builds together#2019-02-2017:06anmonteirowhat’s that#2019-02-2017:06anmonteirocaching is definitely sorted out#2019-02-2017:06thhellerhttps://clojureverse.org/t/reducing-the-build-size-when-using-lots-of-js-dependencies/3742/2#2019-02-2017:07thhellerI enabled that by default#2019-02-2017:07anmonteiro😄#2019-02-2017:07anmonteirok trying#2019-02-2017:07thheller:js-options {:minimize-require false} to disable#2019-02-2017:10anmonteirotrying that now#2019-02-2017:15anmonteiro@thheller wait so, minimize-requires is disabled in dev, and enabled in prod?#2019-02-2017:15thhelleryes#2019-02-2017:16thhellerno need to optimize for size in dev builds#2019-02-2017:16anmonteiroso would it also break in bad ways if I enabled it in dev?#2019-02-2017:16anmonteiroto experiment#2019-02-2017:16thhellerno its fine, just causes some additional recompiles if your JS deps change#2019-02-2017:17anmonteiroI mean, assuming that’s what’s breaking our bundle#2019-02-2017:17anmonteirowould it be repro’ed in dev?#2019-02-2017:18thhellerhmm it might?#2019-02-2017:18anmonteirotrying#2019-02-2017:18thhellershadow-cljs takes extra care to ensure everything is recompiled and invalidated correctly#2019-02-2017:18thhellerbut I'm unsure what all your buck stuff does so maybe it decides to not recompile something when it should?#2019-02-2017:18thhellerI don't know 😛#2019-02-2017:19anmonteirohm#2019-02-2017:19anmonteiroin dev we don’t have buck#2019-02-2017:19anmonteiroso it’d be shadow all the way#2019-02-2017:19thhelleryeah then it will probably work#2019-02-2017:30p-himikIs the --npm flag actually used? I can't find where it's handled.#2019-02-2017:31thhellerno it just tells the server that it was started by the npm script#2019-02-2017:32thhellerdoesn't have any effect on builds and stuff. I think the only case that actually used it was removed a while ago#2019-02-2017:36p-himikOK, good. I was starting to think I'm becoming blind. 🙂 So, an interesting thing. Right now kick only supports figwheel. And both release build and debug watch are ran with explicitly specified :source-paths. The reason is that the output dir inside target is added to the classpath - I think just to make the server aware of the resources there during the runtime. But when you specify {:deps true}, shadow-cljs ignores :source-paths. I can fix it in my project by explicitly specifying a filtered list of aliases for :deps (the directories inside target are added to the classpath by dedicated aliases). But would be interesting to know if there's a better way.#2019-02-2017:40thhelleruhm I don't follow#2019-02-2017:40thhelleryou can't add :source-paths dynamically#2019-02-2017:41p-himikWell if I use shadow-cljs dynamically then I can change anything. But not when {:deps true} is set, yes.#2019-02-2017:42thhellerI'm confused. you cannot change the :source-paths once the JVM is running#2019-02-2017:43thhellerfigwheel isn't actually changing source paths, it is changing input paths#2019-02-2017:43thhellerdifferent things#2019-02-2017:43thheller:source-paths in figwheel are used as inputs to the CLJS compiler#2019-02-2017:43thhellerso the JVM doesn't know about them#2019-02-2017:43thhellermeaning they can't contain macros#2019-02-2017:44thhellerwhich I found profoundly annoying#2019-02-2017:45thhelleror I'm completely missing what you are talking about ... also possible.#2019-02-2017:48p-himikOhhh. So when I use shadow-cljs by using server/start! and api/watch, I'm reusing the classpath, and none of :deps, :lein, :source-paths (and probably other keys) are in effect.#2019-02-2017:49thhellercorrect#2019-02-2017:49thhellerthey only apply when shadow-cljs is started#2019-02-2017:49thhellerwhen you use the embedded mode they have no effect at all#2019-02-2017:49thhellerand just use the classpath you are on#2019-02-2017:50p-himikDamn. So I cannot add target to the classpath at all. Hence, I must have an additional static files handler that looks specifically under target.#2019-02-2017:51thhellerwho uses target? why do you need it on the classpath?#2019-02-2017:53p-himikThe edge project has the server set in such a way so that the one and only static files handlers looks for files only in the public directory inside any of the classpath paths. resources is on the classpath, so resources/public is used for some regular static files. target/dev or target/prod is also on the classpath, so target/{dev,prod}/public is used to serve some generated static files. At least, that's my understanding.#2019-02-2018:00thhellerok but that sounds like it is already added to the classpath?#2019-02-2018:01p-himikYeah, it's added because the manual says to use -A:dev:build:dev/build where :dev/build is just {:extra-paths ["target/dev"]}.#2019-02-2017:54anmonteiro@thheller :minimize-requires false still makes it break#2019-02-2017:55thhellerdoes your dev build work with 2.8+?#2019-02-2017:57anmonteiroyeah#2019-02-2017:57anmonteiroI’m on 2.8.6#2019-02-2018:00thhellerhmm#2019-02-2018:00anmonteiro@thheller I’m bisecting locally but there might be a change this was introduced between 2.8.2 and 2.8.5#2019-02-2018:02thheller2.8.3 changed shadow$loader to shadow$modules so with your hack active that will break depending on which one you rewrite#2019-02-2018:02anmonteirowe don’t have modules in production yet#2019-02-2018:03thhellerhmm so its just missing the boostrap stuff? thats weird#2019-02-2018:12anmonteiroI don’t know what’s happening#2019-02-2018:12anmonteirobut our upgrade from 2.8.2 to 2.8.5 is what broke it 100%#2019-02-2018:13thhellerwait I thought all 2.8 releases broke? you downgraded to 2.7.x?#2019-02-2018:14thhellerthis may cause all sorts of weird issues#2019-02-2018:14thhellerhttps://github.com/thheller/shadow-cljs/commit/2d4d49d70fc03781763b631f1ecbf84023238588#2019-02-2018:15thhellermaybe try :language-in :ecmascript6?#2019-02-2018:15thhellerdon't set :language-out :ecmascript6 or higher as certain optmizations don't yet work with es6+#2019-02-2018:15thhellercould try less though#2019-02-2018:16thhellerneed :language-in es6+ since closure library now contains es6 code (eg the new module loader stuff)#2019-02-2018:32anmonteirotrying language-in#2019-02-2019:18anmonteirook so it isn’t language-in either 😕#2019-02-2019:23anmonteirothe only other commit that stands out to me is https://github.com/thheller/shadow-cljs/commit/e8f85964bebbcd830f81514b203dd47038815f4d#2019-02-2019:54anmonteiro@thheller does this commit look fishy to you ^ ?#2019-02-2019:54thhellerno?#2019-02-2019:54thhellerlooks like it does exactly what it should?#2019-02-2019:54anmonteiroso state is being updated to just contain :virtual?#2019-02-2019:54anmonteiroI might be ways off, but it looks weird#2019-02-2019:55thhellervirtual sources are generated by the compiler and should not be compiled by closure#2019-02-2019:55anmonteiroall the other commits in the version range look fine to me#2019-02-2019:55anmonteirooh I get it#2019-02-2019:55anmonteiro->> got me#2019-02-2019:56thhellerits just copying the source to :output without compiling#2019-02-2019:56thhellerbut that code isn't used in :release mode at all anyways#2019-02-2019:56anmonteirokk#2019-02-2019:57anmonteiroI’ll try 2.8.3, and 4#2019-02-2019:57anmonteirosee which one is broken#2019-02-2019:57anmonteirowe’re currently running 2.8.2 in prod and all is fine#2019-02-2019:57anmonteiro2.8.5 and 2.8.6 are broken for us#2019-02-2019:57thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/compiler.clj#L1220-L1225#2019-02-2019:59anmonteirowhat about this?#2019-02-2020:10thheller:release doesn't call convert-goog only :dev does#2019-02-2020:11thhellerotherwise the closure lib files got converted twice which worked but produced annoying warnings#2019-02-2020:12anmonteiroI’m not sure what that means#2019-02-2020:12anmonteiroconverted twice because Closure’s last pass would also convert them?#2019-02-2020:13thhellerclosure started including files that can't be loaded like the other closure files in dev mode#2019-02-2020:13thhellerso they need to be converted in dev to something that can be loaded#2019-02-2020:14thhellerin release mode that would lead to compiling the files twice, once for the conversion and once for the optimizations#2019-02-2020:15thhellereg. this can't be loaded without processing first https://github.com/google/closure-library/blob/master/closure/goog/loader/activemodulemanager.js#2019-02-2020:15thhellerbut I don't see how this is related to your problem#2019-02-2020:16thhellerbut there haven't been many commits since 2.8.2 so I don't know whats up#2019-02-2020:16thhellerdid you try a release build without buck?#2019-02-2020:16thhellerjust to rule out issues there?#2019-02-2020:20anmonteirowe’re not using code splitting in these builds#2019-02-2020:22anmonteiroI really don’t think Buck is the problem here#2019-02-2020:22anmonteirowe’re only using it to know where targets should be output to#2019-02-2020:22anmonteiroshadow is still in control#2019-02-2020:23anmonteirowe’re literally calling (shadow/release* build-config {:verbose true})#2019-02-2020:23thhellerhmm ok#2019-02-2020:24thhellerdid you try 2.8.3/4 yet?#2019-02-2020:24anmonteirotrying 2.8.3 now#2019-02-2020:24anmonteirothe feedback loop is a little slow for this#2019-02-2020:30anmonteiroso 2.8.3 is broken#2019-02-2020:30anmonteirotherefore there are only 2 possible commits that could have done this 😛#2019-02-2020:31anmonteiroand we’re not using code splitting so I don’t think it could’ve been the loader -> modules one?#2019-02-2020:34thhellerdepends on whether your do anything with shadow$loader?#2019-02-2020:34thhellercan't see how that would possible affect a missing bootstrap .modal either#2019-02-2020:36thhellerand you are sure 2.8.2 is working and wasn't just a fluke?#2019-02-2020:37anmonteiro100%#2019-02-2020:38thhellerso you require "jquery" and "bootstrap"? maybe I can reproduce something on my end#2019-02-2020:38anmonteirough#2019-02-2020:39anmonteiroI don’t think I can produce a minimal example easily#2019-02-2020:40thhellerdid you try logging whatever b was in b.modal.modal?#2019-02-2020:41thhellerhaha#2019-02-2020:41thhellerI can actually reproduce it#2019-02-2020:41anmonteiro😮#2019-02-2020:41thhellerjust include jquery and bootstrap#2019-02-2020:41anmonteiro
(ns cljsjs.ajquery
  (:require ["jquery" :as jquery]))

(js/goog.exportSymbol "$" jquery)
(js/goog.exportSymbol "jQuery" jquery)
#2019-02-2020:41thhellerin release mode the .modal is gone
#2019-02-2020:41anmonteirothis is our jquery shim#2019-02-2020:41anmonteirook nice#2019-02-2020:42anmonteirothat you can repro#2019-02-2020:42anmonteiroI wonder if $ is being mangled so some thing?#2019-02-2020:42thheller
["jquery" :as jq]
    ["bootstrap"]
    ))

(js/console.warn "modal" (.-modal (jq "#app")))
#2019-02-2020:42thhellerundefined in release#2019-02-2020:42anmonteiro@thheller wait so if you revert https://github.com/thheller/shadow-cljs/commit/e8f85964bebbcd830f81514b203dd47038815f4d#2019-02-2020:42anmonteirodoes it work then?#2019-02-2020:43thhellerit does not#2019-02-2020:44thhellerI'll bisect a bit#2019-02-2020:45anmonteirothanks#2019-02-2020:46thhellergah I'm an idiot#2019-02-2020:51thhellerno idea why 2.8.2 still worked for you. the first commit you linked is responsible#2019-02-2020:51thhellerhttps://github.com/thheller/shadow-cljs/commit/e8ed39ad2081b34f219c74c9c893143c3ee794ea#2019-02-2020:51thhellerI only disabled half of it .. the code that actually removed the require call was still being used#2019-02-2020:51thhellershould work again in 2.8.7#2019-02-2020:51thhellerthats what I get for working on 2 things at once 😛#2019-02-2020:55anmonteirohahaha#2019-02-2020:55anmonteirothanks#2019-02-2021:27anmonteiro@thheller confirmed fix in 2.8.7#2019-02-2101:59neupshHello, I have a shadow-cljs project and I run npm alias (`shadow-cljs watch :main :renderer`) for my development workflow. I wanted to add a project.clj and move my dependencies to it (in :profile {:cljs... so I get a decent intellij + cursive support. I just moved the dependencies to the project file and added :lein {:profile "+cljs"} in my shadow-cljs.edn. Now i am getting the following exception:#2019-02-2101:59neupsh`#2019-02-2101:59neupsh#2019-02-2101:59neupshDoes anyone know what I could be doing wrong?#2019-02-2102:00neupshMy project.clj looks like below:#2019-02-2102:00neupsh
(defproject example-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License" :url ""}

  :dependencies [
                 [org.clojure/clojure "1.10.0"]
                 ;[org.clojure/clojure "1.9.0"]
                 [org.clojure/clojurescript "1.10.520"]
                 ;; Needed for shadowcljs if run using lein
                 [thheller/shadow-cljs "2.8.7"]
                 ]

  :profiles {:cljs
             {:dependencies [[reagent "0.8.1"]
                             [re-frame "0.10.6"]
                             [clj-commons/secretary "1.2.4"]
                             [cljs-ajax "0.8.0"]
                             [day8.re-frame/re-frame-10x "0.3.6-react16"]


                             [binaryage/devtools "0.9.10"]
                             ]

              ;:target-path "target/%s"
              :source-paths ["src"]}}
  )
#2019-02-2103:10neupshI tried changing the shadow-cljs version in my project.clj (package.json still has the latest version: 2.8.7) down up to 2.7.7 where it still fails. Then if i use 2.7.6 it works fine#2019-02-2107:09thheller@neupsh that is caused by a dependency conflict. check lein with-profiles +cljs deps :tree#2019-02-2107:09thhellerclosure versions should be
[com.google.javascript/closure-compiler-unshaded "v20190121"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
#2019-02-2114:03neupshThank you! It was the dependency conflict.#2019-02-2107:14thhellerit might work if you list shadow-cljs first#2019-02-2109:23p-himik
Invalid configuration
-- Spec failed --------------------

  {:output-dir ...,
   :compiler-options ...,
   :build-hooks ...,
   :modules ...,
   :module-hash-names ...,
   :devtools ...,
   :build-id ...,
   :asset-path "",
               ^^
   :target ...}

should satisfy

  non-empty-string?
By why? Why can't I just write /main.js in my index.html?
#2019-02-2109:25thhelleruse :asset-path "."#2019-02-2109:26thhellerthe paths it emits is simply (str asset-path "/" filename)#2019-02-2109:26p-himikYeah. 🙂 But I mean, why this spec at all, why not just string??#2019-02-2109:26thhellerbecause you should be using a subdirectory#2019-02-2109:27thhellerthe intention is that :output-dir is a directory dedicated to the output of shadow-cljs#2019-02-2109:27thhellerotherwise I make no guarantees that it won't overwrite your stuff#2019-02-2109:27p-himikSubdirectory != server path. I can output to a separate directory and still use {:asset-path "."}.#2019-02-2109:29thhellerI can change the spec. It just doesn't fit into my mental modal to put everything at the "root"#2019-02-2109:31thhellerjust use ".". otherwise I have to special case everything for empty ...#2019-02-2109:36p-himikYep, sure.#2019-02-2110:41lsnapeMorning, are there any known issues with the shadow's module loader on Chrome 72?#2019-02-2110:42thhellerdepends on the version you are on. some problems were in between 2.8.0 - 2.8.6#2019-02-2110:42lsnapeAh! Let me check#2019-02-2110:42thhellernot aware of any issues in older versions#2019-02-2110:42lsnape2.6.23#2019-02-2110:43lsnapeI'll upgrade to latest. Worth a try#2019-02-2110:43thhellerno issues I'm aware of no.#2019-02-2110:44thhellerwhats the problem?#2019-02-2110:48lsnapeWe're getting undefined object console errors in module-loaded namespaces.#2019-02-2110:48lsnapeFor objects that are explicitly required in at the top of the namespace, so they should be available!#2019-02-2110:49lsnapeRecompiling with latest...#2019-02-2110:49thhellerdid you try shadow-cljs release your-app --pseudo-names to identify what is missing?#2019-02-2110:49lsnapeNot yet, but will do#2019-02-2110:58lsnapeCan reproduce with 2.8.7. And one of my colleagues says it works with release builds. More info incoming...#2019-02-2111:00thhellerI'm on chrome 73 beta but never had an issue with modules#2019-02-2111:04lsnapeHere is the compiled JS of the module-loaded namespace.#2019-02-2111:05lsnapeIt's blowing up on line 13 trying to access sandi.main.view.content_STAR_#2019-02-2111:06lsnapeCuriously, if I access sandi.main.view just after the requires then it works!!#2019-02-2111:07lsnape(sandi.main.view is a transitive require of the module-loaded namespace; it's not required anywhere else at the point when this file is loaded)#2019-02-2111:08thhellerhmm not sure I understand the last comment?#2019-02-2111:09lsnapesandi.onboarding.view requires sandi.main.view. It's not required anywhere in the shared module.#2019-02-2111:09thhellersandi.onboarding.view is one of your :entries in the modules?#2019-02-2111:09lsnapeyep:
:onboarding {:entries [sandi.onboarding.view]
                                       :depends-on #{:shared}}
#2019-02-2111:10thhellerok. you can open and open your build#2019-02-2111:10thhellerclick compile or force-compile when the watch is running#2019-02-2111:10thhellerat the bottom it shows the module infos#2019-02-2111:10thhellercheck if the file is in the correct module#2019-02-2111:10thheller(don't see a reason why it wouldn't be but helps to verify)#2019-02-2111:11lsnapeAppears to be yes#2019-02-2111:11lsnapeThat's pretty neat btw!#2019-02-2111:11thhellerwell it will be neat once I actually come up with a proper design for all this UI stuff 😉#2019-02-2111:12thhellerare there any other errors during the load?#2019-02-2111:12lsnapeIt's not that bad.#2019-02-2111:13thhellersomething that would prevent the ns from loading correctly?#2019-02-2111:13thhellereg. add a (prn :loaded) just after the content* definition?#2019-02-2111:13lsnapeA few more errors, quite noisy so hard to see what's relevant.#2019-02-2111:15lsnapeThat prn is shown after the errors are reported.#2019-02-2111:16thhellerso something doesn't work correctly during load I guess#2019-02-2111:16lsnapeand if I (def x sandi.main.view/content*) after the requires then I can see it loads with no errors.#2019-02-2111:18lsnapeSo sandi.onboarding.view/content is being called before sandi.onboarding.view/content* is loaded.#2019-02-2111:23lsnapeAnd I can confirm the on-load function for that module is called before we try to resolve sandi.onboarding.view/content*.#2019-02-2111:24thhellercan't comment on that since I don't know what any of it does 😛#2019-02-2111:24lsnapeSorry! The code checks that the on-load is called before trying to resolve view for that module.#2019-02-2111:25thhellerwhat is on-load?#2019-02-2111:25lsnape
(-> (loader/load (name module-id))
          (.then #(on-load! module)
                 #(on-error module)))
#2019-02-2111:26thhellerand what does that do? what is module?#2019-02-2111:30lsnapemodule is hash-map. It's used to initialise that module (set state in the app-db etc.). Crucially though, after on-load! is called a flag is set that allows the view in the module to be resolved.#2019-02-2111:31lsnapeThis stuff has been working well and not been touched in quite a while. That's not to say there's not a latent bug in it!#2019-02-2111:33thhellerno idea. maybe I can guess something if you paste the errors you get on startup?#2019-02-2111:35lsnape
Uncaught TypeError: Cannot read property 'view' of undefined
    at sandi$onboarding$view$content (/dist/cljs-runtime/sandi.onboarding.view.js:16)
    at Object.G__95768__1 (cljs.core.js:3993)
    at Object.G__95768 [as call] (cljs.core.js:4166)
    at reagent.impl.component.js:130
    at Object.reagent$impl$component$wrap_render [as wrap_render] (reagent.impl.component.js:153)
    at Object.reagent$impl$component$do_render [as do_render] (reagent.impl.component.js:201)
    at day8.re_frame_10x.js:105
    at Object.reagent$ratom$in_context [as in_context] (reagent.ratom.js:61)
    at Object.reagent$ratom$deref_capture [as deref_capture] (reagent.ratom.js:70)
    at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (reagent.ratom.js:1485)
#2019-02-2111:36thhellerwhy is re-frame-10x in that trace?#2019-02-2111:38lsnapeGood question. It is used in the project, but I'm pretty sure removing it had no effect.#2019-02-2111:54lsnapeWell a workaround for now is to (def chrome-72-hack sandi.view.main/content*) at the top of each module view namespace, and I think I'm right in saying it'll be DCE in release (not that it matters all that much).#2019-02-2111:56thhellerwhy happens if you (js/console.log sandi.view.main/content*) instead and use it as normal?#2019-02-2112:17lsnapeYes that works.#2019-02-2112:58thhellerlogging it fixes the problem? or just the log works?#2019-02-2115:15lsnapeLogging under the require fixes the problem, just like def'ing .#2019-02-2112:00joelsanchezit seems that when I compile my cljs for production this call: (.-token js-object) is munged and doesn't work anymore, is my only choice to use aget?#2019-02-2112:01thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-02-2112:01thheller(.-token ^js js-object)#2019-02-2112:01thhellerNEVER aget#2019-02-2112:02joelsanchezI knew you'd reply if I mentioned I would use aget, your worst enemy#2019-02-2112:02joelsanchez🙂 thank you#2019-02-2113:12WhiskasWhich chart lib do you guys like using with clojurescript?#2019-02-2113:38joelsanchez@mateus.pimentel.w I wrapped chartjs some time ago https://github.com/JoelSanchez/ventas/blob/master/src/cljs/ventas/components/chart.cljs#2019-02-2114:08Whiskas@joelsanchez cool, there is a guide to use it?#2019-02-2114:08Whiskasi tried using react-chartjs directly#2019-02-2114:08Whiskasbut with no success#2019-02-2114:08Whiskasthe chart was’nt drawn#2019-02-2114:09joelsanchezthat wrapper served me well at the time, to draw realtime traffic stats#2019-02-2114:09joelsanchezthe code might be a bit bad but you can base yourself off it#2019-02-2114:09joelsanchezchartjs is quite easy#2019-02-2114:11Whiskasi’m having a problem with it not being renderized#2019-02-2114:11Whiskasjust wanted a react component to draw the graphs hah, i’m gonna try again#2019-02-2200:38souenzzoI'm getting Uncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class but when I click on the browser exception bidi.js:276 it point's to HTML file. Bidi is a indirect dep from fulcro and it's on 2.1.5 I have no idea from where it error come from.#2019-02-2200:44souenzzoIt's not from bidi/bidi. it's from goog.i18n.bidi#2019-02-2200:44souenzzoOh I will bum my closure compiler#2019-02-2208:48thheller@souenzzo this is likely caused by an invalid charset encoding set in your html (or none set at all)#2019-02-2208:48thhellertry <meta charset="utf-8"> or Content-Type: text/html; charset=utf-8 if you control the server side#2019-02-2316:18Pavel Klavíkhi, I am trying to get shadow-cljs running with luminus template with +cljs, but I cannot get it working#2019-02-2316:20thhellerwhat is the problem?#2019-02-2316:21Pavel KlavíkI generated the following shadow-cljs.edn:
{:source-paths ["src/cljs"]
 :dependencies [[binaryage/devtools "0.9.10"]]
 :nrepl        {:port 9000}
 :builds       {:app {:target           :browser
                      :output-dir       "target/cljsbuild/public/js"
                      :asset-path       "/js/main.js"
                      :modules          {:main {:init-fn exp.core/init!}}
                      :compiler-options {:infer-externs :auto}
                      :devtools         {:http-root    "public"
                                         :http-port    3449
                                         :http-handler shadow.http.push-state/handle
                                         :after-load   exp.core/mount-components}}}}
#2019-02-2316:23Pavel Klavíkbut I get errors that js files in subdirectories are not found: http://localhost:3000/js/main.js/cljs-runtime/goog.debug.error.js net::ERR_ABORTED 404 (Not Found)#2019-02-2316:23thheller:asset-path "/js/main.js" is wrong#2019-02-2316:23thheller:asset-path "/js"#2019-02-2316:23Pavel Klavíkok, that makes sense 🙂#2019-02-2316:23thhellerthe files will be put into :output-dir as <module-id>.js, so main.js in your case#2019-02-2316:26Pavel Klavíkcool, it seems to work now, thanks#2019-02-2316:27Pavel Klavíkhow does the hot code reloading work in this case? I understand that shadow-cljs runs its own server on port 3449 which connects to the browser via websockets and updates the website with exp.core/mount-components when the source files are updated.#2019-02-2316:27Pavel Klavíkbut in this case, the server runs on port 3000, so how does shadow-cljs update it?#2019-02-2316:27thhellershadow-cljs runs a server in 9630 that handles the live reload#2019-02-2316:28thhellerthe one you started on 3449 is just a completely static webserver for serving files#2019-02-2316:28thhellerwhich you don't need if you have the files served on 3000#2019-02-2316:28Pavel KlavíkI see, so basically as files are served from 3000, they contain in development information that they should connect to 9630 and listen for updates there?#2019-02-2316:29thhelleryes#2019-02-2316:29Pavel Klavíkcool, might be useful to explain this somewhere in shadow-cljs user guide (or maybe it already is explained there), because I found that quite puzzling#2019-02-2316:32thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#http#2019-02-2316:35Pavel Klavíkthx, makes sense now, when I understand everything better, but still little bit difficult for beginners to understand. In the future, I might write some beginners tutorial about all these things.#2019-02-2406:47bbssI'm having an issue with closure using JavaScript from a worker. I extend a class from an external library, this works for the non :web-worker true. But when importing the class into a worker I get
Uncaught ReferenceError: $jscomp is not defined
Which seems to be part of the closure runtime. Importing the class that I extend into the worker does work. I'm not sure how to fix it, maybe I can include something manually/pass flags to closure to make this work. Any ideas?
#2019-02-2408:54thhellerI'm not sure I understand what you are doing#2019-02-2408:54thhelleryou have a build with multiple :modules where one uses :web-worker true?#2019-02-2408:55thheller$jscomp is used by the closure lib for its polyfills#2019-02-2408:55thhellerit should be created in the default base module which should be imported by the worker module#2019-02-2408:55thhellerso it should be available?#2019-02-2409:32bbss
:target :browser
...
:modules    {:shared {:entries []}
                                  :worker-shared {:entries []
                                                  :depends-on #{:shared}}
                                  :app {:entries [app.client]
                                        :depends-on #{:web-shared}}
                                  :filter-worker {:entries [app.filter-worker]
                                                  :depends-on #{:worker-shared}
                                                  :web-worker true}}
I have a .js file that imports a class from the a node_modules lib and extends it. This works when importing that JS file in :app module, but it doesn't work when importing in the :filter-worker.
#2019-02-2409:33thhellercan you check the shared.js? it should contain /** @const */ var $jscomp = $jscomp || {}; right at the top?#2019-02-2409:34bbssYes, it does.#2019-02-2409:34thhellerand filter-worker.js should contain the importScripts("shared.js") right at the top? + worker-shared.js?#2019-02-2409:34bbssit does not#2019-02-2409:35thhellerhmm I think I never built this for a shared worker module#2019-02-2409:35thhellerfilter-worker.js doesn't contain any importScripts?#2019-02-2409:36thhelleroh wait nevermind. importScripts is only for release mode#2019-02-2409:36thhellerah yeah .. that makes sense now#2019-02-2409:36bbssokay, it contains the string but no direct calls afaik#2019-02-2409:37thhelleryeah forgot that dev mode workers work differently#2019-02-2409:37thhellerand they just don't inject the polyfills correctly#2019-02-2409:37thhellerplease open an issue. I can fix it later#2019-02-2409:37bbssOkay sure, great!#2019-02-2409:38thhellerhmm#2019-02-2409:40thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#L480#2019-02-2409:40thhellerthat should check goog-base and web-worker if you want to try fixing it#2019-02-2409:40thhellerI'll be back later#2019-02-2409:40bbssOkay, I'll check it out! Thanks a lot!#2019-02-2409:41bbssMaking issue now.#2019-02-2410:15bbssIncluding :goog-base true in my module seems to have fixed it!#2019-02-2412:06chrispsHow can I make shadow-cljs make use of clojure 1.10 ??#2019-02-2412:06chrispsI’ve added that as a dep#2019-02-2412:07chrispsAnything else I need to do?#2019-02-2413:18thheller@chris.schreiner 1.10 should be used by default in recent releases?#2019-02-2414:02chrisps@thheller Yes indeed, I was running an older version of shadow-cljs#2019-02-2417:18mhuebertcame across what appears to be an odd compiler renaming bug, https://github.com/thheller/shadow-cljs/issues/447#2019-02-2517:42thhellerhttps://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2019-02-2518:19richiardiandreaI am on 2.8.10 has somebody started seeing the following?
[:az] Build failure:
The required JS dependency "bufferutil" is not available, it was required by "node_modules/ws/lib/BufferUtil.js".

Searched in:/home/arichiardi/git/laputa/scrutinize-fn/node_modules

You probably need to run:
  npm install bufferutil

See: 
#2019-02-2518:22richiardiandreaand
You probably need to run:
  npm install utf-8-validate
#2019-02-2518:24thhellerif thats a dev build intended as a one-file output you probably want to :keep-as-require #{"ws"}#2019-02-2518:24thhellerno clue what those packages are#2019-02-2518:26richiardiandreaso is the one-file feature causing that? because it looks like those are required by ws#2019-02-2518:27thhellernot really#2019-02-2518:28thhellerit does try to require them ... but has a fallback and seems to work without?#2019-02-2518:28thheller
try {
  const bufferUtil = require('bufferutil');
  const bu = bufferUtil.BufferUtil || bufferUtil;

  module.exports = {
    mask(source, mask, output, offset, length) {
      if (length < 48) _mask(source, mask, output, offset, length);
      else bu.mask(source, mask, output, offset, length);
    },
    unmask(buffer, mask) {
      if (buffer.length < 32) _unmask(buffer, mask);
      else bu.unmask(buffer, mask);
    },
    concat
  };
} catch (e) /* istanbul ignore next */ {
  module.exports = { concat, mask: _mask, unmask: _unmask };
}
#2019-02-2518:28richiardiandreauhm ok let me try to uninstall and try :keep-as-require #{"ws"}#2019-02-2518:28thhellerbut unless you are using ws in your release build you can safely ignore that#2019-02-2518:29thhelleror just :devtools {:enabled false}#2019-02-2518:29richiardiandreagot it...I have one final question#2019-02-2518:30richiardiandreaI still have a problem with one internal lib that Gcc cannot transpile#2019-02-2518:30thhellerscoping the settings to :release {:js-options {:js-provider :shadow}} would also be best probably#2019-02-2518:30thhellerno point in single file for dev really#2019-02-2518:30richiardiandreayeah you're right#2019-02-2518:30richiardiandreadoes :output-feature-set support :no-transpile?#2019-02-2518:31thheller:output-feature-set :es-next will basically keep everything as is#2019-02-2518:31thheller:no-transpile never worked#2019-02-2518:32thhellerif you use a feature the GCC doesn't support and can't parse no setting will save you#2019-02-2518:32richiardiandreaOk cool I have tried :es8 will try that next #2019-02-2518:33thhellerif it fails to parse it can't work since we need to process it#2019-02-2518:33richiardiandreaYeah I kind of guessed that ..weird is that this module comes from a TypeScript project that in theory compiles to es6#2019-02-2518:34thhellerwhats the error? closure has some known issues with some ES6 code I think#2019-02-2518:34richiardiandreaStill the one I posted on the issue let me fetch that#2019-02-2518:35richiardiandrea> Closure compilation failed with 2 errors > --- node_modules/...dist/execution/hydration.js:48 > This code cannot be converted from ES6. Undecomposable expression: Please rewrite the yield or await as a separate statement.#2019-02-2518:36thhellertry bumping the closure compiler to [com.google.javascript/closure-compiler-unshaded "v20190215"]#2019-02-2518:36thhellerthey changed something regarding that I think#2019-02-2518:36thhellerdidn't test that release yet#2019-02-2518:36thhellerah doh#2019-02-2518:36thhellerhttps://github.com/google/closure-compiler/commit/640fd3f705dd5f015278abfd756b6a793ceecc73#2019-02-2518:37thhellerit isn't in the release yet#2019-02-2518:37thhellerbut doesn't the language setting take care of this?#2019-02-2518:38richiardiandreaI am trying things ...#2019-02-2518:38thhellerneed minimum :es8 to keep generators/async/await as is#2019-02-2519:18richiardiandreathis is what TypeScript produces - monkey patching facepalm
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};

...

function hydrateFrameMembersAsync(args) {
    return (agg, val) => __awaiter(this, void 0, void 0, function* () {
        const doc = yield agg;
        const docWrapper = support.createDocumentWrapper(doc, args.triggerContext || {});
        return Object.assign({}, doc, { [val.name]: yield hydrateDocumentMemberAsync(docWrapper, args.eventData, val.definition, args.lookups, args.pointer) });
    });
}
#2019-02-2519:31thhellerand that still complains with :es8?#2019-02-2519:52richiardiandreayeah...#2019-02-2520:07richiardiandreaDoes shadow expose --allow_method_call_decomposing GCC option?#2019-02-2520:13richiardiandreaI see...well I guess I will need to wait for the next release..#2019-02-2520:37thhellernot currently. you can add it here to test https://github.com/thheller/shadow-cljs/blob/8332a74780b1565a75de560ccb7715eb8e0ed4c3/src/main/shadow/build/closure.clj#L97#2019-02-2520:56thhellerhmm the code you posted compiles fine for me? I get no errors even with just :es6?#2019-02-2520:57thhellergranted that I just added it without actually using it#2019-02-2520:57thhellerbut just included in a file works fine#2019-02-2520:58richiardiandreaoh yeah well, that might be something else then#2019-02-2521:02richiardiandreaI mean, maybe the error is in the other parts of my code#2019-02-2518:58richiardiandreaI'll try (meeting now)#2019-02-2520:18richiardiandreatried many combinations of the language settings and it seems none worked, I will probably need to wait for the next release of GCC#2019-02-2521:23hlollihas someone experienced
bidi.js:276 Uncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class
    at new RegExp (<anonymous>)
    at bidi.js:276
from goog.i18n.bidi ?
#2019-02-2521:27hlollialso from the shadow-cljs hud, pops an error when I get an error
hud.cljs:301 reload-failed TypeError: r is not a function
#2019-02-2521:32thheller@hlolli that is caused by an incorrect charset encoding in your html#2019-02-2521:32thhelleradd <meta charset="utf-8"> to your HTML#2019-02-2521:35hlollithanks @thheller that fixed the bidi.js error.#2019-02-2521:36hlollithe other one probably react/reagent bug introduced after bumping, digging deeper.#2019-02-2521:36thhellerthat is an error that occured while loading your code. should get it if you just reload the page#2019-02-2521:37thhellerprobably nothing to do with shadow-cljs#2019-02-2521:39hlolliIm getting "r is not a function", and the only stacktrace showing my cljs code is the init react render. Yes that hud error also gone. So all on my side now :=)#2019-02-2521:58hlolliok now I get what's happening, by bumping react-dropzone, the whole spec changed, and instead of using props, it expects a function callback in the child element, don't ever remember seeing such a thing in react.
<Dropzone onDrop={this.onDrop}>
        {({getRootProps, getInputProps, isDragActive}) => {
          return (
            <div
              {...getRootProps()}
weird..
#2019-02-2522:02lilactownfunction-as-children is a common pattern in React-land#2019-02-2522:03lilactownsee: Context Consumer components#2019-02-2522:06hlolliit's a small webapp Im making, the whole page is a html5 filedrop, I wonder if this function as child patterns causes severe slowdown of the whole webapp, given that the whole app is a child of the filedrop. In which case, I'd just css it to do the same but be a sibling of the rest of the webapp.#2019-02-2522:08hlollibut first time I see this, especially as an interface. Thus far, function as child has been mostly a cause of error messages 😛#2019-02-2522:10lilactownfunction-as-children is pretty gross to work with in Reagent (syntax wise). but you shouldn't see a significant slow down#2019-02-2522:12lilactownyou might find that my wrapper library for React fits your use case better than reagent: https://github.com/Lokeh/hx#2019-02-2522:13lilactownit makes using patterns like function-as-children much easier than reagent#2019-02-2522:15hlolliit's small enough app that I can test your react wrapper. Bit off topic here, but I do get the classic: react-dom.development.js:507 Warning: Functions are not valid as a React child.#2019-02-2522:16hlollisorry, slack had me on overwrite mode suddenly, (so I typed forever)#2019-02-2522:17hlollidoes hx work with re-frame?#2019-02-2522:18hlolliany react component works with re-frame, so this question falls on itself.#2019-02-2522:28lilactownre-frame depends on reagent for it's RAtom and scheduler#2019-02-2522:28lilactownso you'll have to include both reagent and hx, and use React-Reagent interop to use hx components in reagent and vice versa#2019-02-2522:29lilactownI have a fork of re-frame that removes all of the reagent dependencies, but I'm not ready to publish it as an project I'm willing to support#2019-02-2522:30lilactownthere is definitely a way to use just re-frame and hx, and include reagent just for it's RAtom implementation, but I haven't tested this#2019-02-2522:33hlolliI see, as long as hx just returns a react element, should be fine, inlineing (hx/f may not be pretty within a reagent app. For a small functioning webapp, hx makes sense.#2019-02-2522:34hlollispeaking for myself here, as soon as state becomes big and many side effects, re-frame is a headache saver. But pure reagent I use a alot.#2019-02-2522:35lilactownyou shouldn't have to call hx/f much. using defnc will create react components for you#2019-02-2522:38richiardiandrea@thheller so you where saying that :no-transpile in that case above would still try to transpile? there is no way to say "please don't touch this JS"?#2019-02-2607:47thheller@richiardiandrea :no-transpile doesn't mean anything at all. if you set :output-feature-set :es-next it will leave all features the GCC supports as they are. it will not "transpile" them. features it does not support will still break. we always NEED to process the code and at least change the require/import/exports. so no there is no "please don't touch this JS" option. if you output "standard" javascript :es-next is as close as you'll ever get to :no-transpile.#2019-02-2616:03richiardiandreaOk got it thanks for expanding on that#2019-02-2607:50thhellerGCC must be able to parse the code that is pretty much the only limitation currently#2019-02-2609:49pwalshSharing here on suggestion of @thheller#2019-02-2612:38r0man@pwalsh I'm using apollo client and do server side rendering on nodejs. I have chosen https://github.com/macchiato-framework and it works ok.#2019-02-2616:02lilactownwe’ve been using the same for about 10 months now and are pretty happy#2019-02-2716:05pwalsh:+1:#2019-02-2614:01fbielejecShadows spec doesn't like the following destructuring syntax:
(defn pending-button [{:keys [:pending? :pending-text] :as opts
                       :or {:pending-text "Sending..."}} & children]
(...))
-- Spec failed --------------------

  (... [{:keys [:pending? :pending-text],
         :as opts,
         :or {:pending-text "Sending..."}} ... ...] ...)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input
or
should satisfy
  vector?
-- Relevant specs -------
:shadow.cljs.devtools.cljs-specs/param-list:
#2019-02-2614:02thheller@fbielejec it doesn't like it because its invalid 🙂 should be a symbol#2019-02-2614:02wilkerlucio:pending-text should be pending-text (in the :or section)#2019-02-2614:03wilkerlucioand altough clojure accepts keywords in the :keys section, its also more idiomatic to use symbols there 😉#2019-02-2614:03fbielejectrue, way more unforgiving then other compilers though 😄 It comes from a forms library#2019-02-2614:04wilkerlucioa chance to send a pull request 😄#2019-02-2614:04thheller
Clojure 1.10.0
user=> (defn x [{:keys [:foo] :or {:foo 1}}])
Syntax error macroexpanding clojure.core/defn at (REPL:1:1).
{:keys [:foo], :or {:foo 1}} - failed: vector? at: [:fn-tail :arity-n :bodies :params] spec: :clojure.core.specs.alpha/param-list
({:keys [:foo], :or {:foo 1}}) - failed: Extra input at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-list
#2019-02-2614:05thhellerplain clojure 1.10 agrees (no shadow-cljs involved)#2019-02-2614:10thheller@fbielejec FWIW although it is "accepted" in normal CLJS it doesn't actually work so I guess nobody every ran into this.
cljs.user=> (defn x [{:keys [:foo] :or {:foo 1}}] foo)
#'cljs.user/x
cljs.user=> (x {})
nil
#2019-02-2614:10thheller
cljs.user=> (defn x [{:keys [:foo] :or {foo 1}}] foo)
#'cljs.user/x
cljs.user=> (x {})
1
#2019-02-2614:11fbielejec+1 for shadow for specing and catching it early 🙂#2019-02-2621:19souenzzohello. I'm trying to use #fulcro + react native I already had success rendering stuff like (r/createElement rn/View #js {} (r/createElement rn/Text #js {} "helloaa")) I can require (without use) fulcro.client.primitives with no errors But when I require (without use) fulcro.client it thows undefined is not a object (evaluating 'goog.loader.activeModuleManager.setDefault') it thows in goog.module.modulemanager.js:674:32 I'm using shadow-cljs + :target :npm-module#2019-02-2621:19thheller@souenzzo did you see https://github.com/thheller/fulcro-expo?#2019-02-2621:20souenzzoI will check this repo#2019-02-2621:20thhellersetup with expo should be about the same#2019-02-2621:20thhellerthere is a note about the bug you see. fulcro.client.mutations requires cljs.loader but doesn't use it#2019-02-2621:21thhellerthe goog.loader.activeModuleManager namespace doesn't seem to work correctly in react-native but it shouldn't be required anyways#2019-02-2621:22thhellerhttps://github.com/thheller/fulcro-expo/blob/master/src/main/fulcro/client/mutations.cljc is from fulcro master 5 days ago with just the cljs.loader require removed#2019-02-2621:22thhellerforgot to open an issue about this in the fulcro repo#2019-02-2621:22souenzzo:target :react-native nice!#2019-02-2621:41souenzzoworking with :target :npm-module. tnkx @thheller I will try to move into target react-native. I'm (intentionally) not using expo so it may be a little different.#2019-02-2621:41thhellerthere is nothing specific to expo in :target :react-native#2019-02-2621:41mdhaney@thheller I was looking for that ticket to add to it. I noticed a similar issue with the fulcro.client.routing namespace - it includes cljs.loader and it does use it, which broke things for me. Fortunately, the new routing in Fulcro-incubator doesn’t use it, so in the process of converting to that. I’ll add a comment when you create the ticket, although not sure Tony will want to mess with it, since I think he plans to make the new routing the default soon. Other than that everything is working great, even release build and publishing to Expo! Much better development experience than figwheel-bridge, and hot reload is much quicker, almost instantaneous for small changes like tweaking the style of a component.#2019-02-2621:50mdhaneyOne thing I’m curious about - it looks like you are handling externs/type-hints automatically with js/require, or something like that? Because I didn’t add any type hints and was expecting my first release build to have a bunch of extern errors, but it worked perfectly out of the box.#2019-02-2621:52thhelleryes, there is some extra inference work shadow-cljs does#2019-02-2621:52thhellermostly about properly propagating hints on js/... calls and :require namespaces#2019-02-2621:53thhelleryou'll still probably want to turn :infer-externs :auto on though as it isn't 100% https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-02-2621:55mdhaneyWell, it does a heck of a lot better job than the cljs compiler. Before switching to shadow, I tried externs inference and never could get it working right, ended up switching to using oops to access JS stuff via string name (which was a royal pain, and stinks for optimization). #2019-02-2710:12anmonteiro@thheller I think Closure has some polyfill support, does shadow do allow me to polyfill e.g. Promise?#2019-02-2710:14anmonteirowould it just be a matter of seting the output language to :es3for example?#2019-02-2710:14thhelleryes, but use :output-feature-set. the :language-out is sort of deprecated. https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options#2019-02-2710:15anmonteiroah#2019-02-2710:15anmonteirothanks#2019-02-2710:15thhellerbut currently if you use js/Promise from CLJS it won't be polyfilled in development#2019-02-2710:15thhelleronly in release#2019-02-2710:16anmonteirothat’s fine#2019-02-2710:16anmonteirowhat’s the default for output-feature-set?#2019-02-2710:16thheller:es5#2019-02-2710:16anmonteiroshould that polyfill Promise?#2019-02-2710:16anmonteirobecause it wasn’t working in IE11#2019-02-2710:17thhellerI think promises are es5? not actually sure#2019-02-2710:17anmonteirooh > ES5 did not have promises.
#2019-02-2710:17anmonteirofrom https://stackoverflow.com/questions/38424517/es5-vs-es6-promises#2019-02-2710:17anmonteiroso it isn’t polyfilling when it should?#2019-02-2710:17anmonteiroor maybe it doesn’t by default?#2019-02-2710:18thhellerhttps://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects#2019-02-2710:18thhellerECMAScript® 2015 was that es5 or es6? naming is confusing 😛#2019-02-2710:18anmonteirothat’s es6#2019-02-2710:20thhelleryou may need to set :compiler-options {:rewrite-polyfills true}#2019-02-2710:20thhellerI can never remember if thats on by default or not#2019-02-2710:24anmonteiroah#2019-02-2715:10thheller@souenzzo @mdhaney 2.8.11 fixes the goog.loader issue on react-native and it should now load properly without errors. can't actually use it due to metro but at least it won't break when loading.#2019-02-2717:02souenzzoworking! thnks#2019-02-2716:05anmonteiro@thheller do you maintain a changelog for shadow?#2019-02-2716:05anmonteirothe changelog in the repo was last updated a year ago 😜#2019-02-2716:06anmonteiroalso, would shadow.loader.init work for the CDN use case I mentioned?#2019-02-2717:19thheller@anmonteiro yes that was the intent. set :module-loader-init false in the config an manually call shadow.loader.init(""), so only the prefix#2019-02-2717:19anmonteirocool#2019-02-2717:19anmonteirotrying that right now#2019-02-2717:19thhellerbut I'm not too happy with that API so it may change#2019-02-2717:19anmonteirokk#2019-02-2717:19anmonteiroif you could let me know I’d appreciate it#2019-02-2717:19anmonteiroeither here or tag me on a PR or commit?#2019-02-2717:20anmonteiroif you remember#2019-02-2717:20thhellerwill try#2019-02-2717:20anmonteirothx#2019-02-2717:20thhellerchangelog kinda died. still need to set something up that generates that automatically#2019-02-2717:22thhellerright now @jiyinyiyong kindly generates the release info for https://github.com/thheller/shadow-cljs/releases which is kinda nice#2019-02-2717:22anmonteirooh cool#2019-02-2717:22anmonteirowill check that out#2019-02-2810:25anmonteiro@thheller hey thomas, me again#2019-02-2810:25anmonteiroWe’ve pushed and reverted code splitting to prod about 3 times now#2019-02-2810:26thhellerhey#2019-02-2810:26anmonteironote that all I’m gonna say is very empirical, as I can’t get a clear repro#2019-02-2810:26anmonteirowe’re seeing this weird issue where apparently everything seems to work on a merged commit, but whenever someone merges another commit to master and we deploy the bundles break in subtle, horrific ways#2019-02-2810:27anmonteiromy current hypothesis is that symbols are not “stable” (?) across different compilation runs?#2019-02-2810:27thhellerdo you "mix" compilation results?#2019-02-2810:28thhellermeaning one module from a previous build reused in another?#2019-02-2810:28anmonteiroI certainly hope not#2019-02-2810:28thhellerthen yes symbols are not exactly stable#2019-02-2810:28thhellerdo you use :module-hash-names?#2019-02-2810:28anmonteironope, what’s that?#2019-02-2810:28anmonteirochecking the guide#2019-02-2810:28thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing#2019-02-2810:29anmonteiroalso, could :fn-invoke-direct true be weird here?#2019-02-2810:29thhellerotherwise cache might get in your way in that a user may have an older version of a module cached and mix it with a module from another build#2019-02-2810:29thhellerwhich will not work#2019-02-2810:30anmonteiroI don’t think we need that#2019-02-2810:30anmonteiroBuck generates its own hash out of compilation and we have “immutable compilation artifacts”#2019-02-2810:30thhellerok but how do you use the hash?#2019-02-2810:30anmonteiroto serve the bundle on the server side#2019-02-2810:30thhellerhow though?#2019-02-2810:31anmonteirothe Buck SHA gets generated after compiling the assets#2019-02-2810:31anmonteirowe use to SHA as the path to upload it to the CDN#2019-02-2810:31thhelleryes but how do you get the hashes into the module loader data?#2019-02-2810:31anmonteiroah#2019-02-2810:31anmonteirowe embed it in the HTML as transit#2019-02-2810:31anmonteirowe read that from the JS, and call shadow.loader.init#2019-02-2810:32thhellerok so you set the shadow$modules var manually?#2019-02-2810:32thhellerand not inject it?#2019-02-2810:32anmonteirono, I call shadow.loader.init#2019-02-2810:32thhellerthat only supports a prefix?#2019-02-2810:32anmonteirohrm#2019-02-2810:32thhellerah ... the path#2019-02-2810:33thhellerso ?#2019-02-2810:33anmonteirois there something I’m missing?#2019-02-2810:33anmonteiroyeah!#2019-02-2810:33thhellerok yeah thats fine#2019-02-2810:33thhellerso it is guaranteed that all files from one build are in the same directory?#2019-02-2810:33anmonteiroto be precise: https://ddw3p1oh0ex89.cloudfront.net/assets/b/03703cffd7d3273643cddc57dbba4d0b1213d793/static/js/ladder/main.js#2019-02-2810:34thhellerand NEVER re-used or shared between builds?#2019-02-2810:34anmonteiroyeah..#2019-02-2810:35anmonteironote that my assumption could be wrong too#2019-02-2810:35thheller> my current hypothesis is that symbols are not “stable” (?) across different compilation runs?#2019-02-2810:35thhellerwhy would that matter then?#2019-02-2810:35anmonteiroyes that one#2019-02-2810:35thhellersymbols are only "stable" between builds if you preserve the .shadow-cljs/builds/<your-build-id>/release directory which you probably don't do#2019-02-2810:35anmonteirook let me establish the symptom first#2019-02-2810:36thhellerstable as in cljs.core.assoc will be assigned the same short name in between builds#2019-02-2810:36thhellerand not xT in one and fY in annother#2019-02-2810:36anmonteirofor code splitting we generate a thunk like you do in shadow.lazy#2019-02-2810:36thhellerbut that really only matters to increase cache hits#2019-02-2810:36anmonteiroin fact your recent shadow.lazy addition is very similar to what we do#2019-02-2810:36anmonteirowhich validated our approach somehow 😛#2019-02-2810:37anmonteiroand what I think I’m seeing (again, I don’t get a clear repro so some things are very subjective) is that the symbol I embed in the thunk cant be found#2019-02-2810:39thhellerso the symptom with "mixed" code would be that module-b was compiled against module-a where cljs.core.assoc was named xT. Another build however assigned xT to cljs.core.conj. Now the module-b is suddenly calling cljs.core.conj in places where it expects to call cljs.core.assoc. Obviously breaking in horrific ways.#2019-02-2810:39anmonteirobut all I get (for now) is undefined is not an object (evaluating 'M.h')#2019-02-2810:40thhellerdid you try compiling with shadow-cljs release your-build --pseudo-names and check what that is?#2019-02-2810:40anmonteiroI did try with pseudo-names#2019-02-2810:40thhelleror lookup the original name in case you have source maps?#2019-02-2810:40anmonteiroand couldn’t repro, or badly#2019-02-2810:40anmonteiroI think I got 1 repro with pseudo-names#2019-02-2810:40anmonteiroand it said cst$sym$... doesn’t exist#2019-02-2810:40anmonteirosomething from the constants table#2019-02-2810:40thhellershadow-cljs doesn't use the constants table#2019-02-2810:41anmonteirodo you use cst$sym names at all?#2019-02-2810:41thhellerinstead it optimizes the constants using a closure compiler pass#2019-02-2810:41thhellerso they can never be missing really 😛#2019-02-2810:41anmonteiroI saw cst$sym$$props__auto__NNN for sure#2019-02-2810:41thhelleryes of course that are the generated constants#2019-02-2810:41anmonteiroah#2019-02-2810:42thhellerhmm do you use js->clj on random JSON data?#2019-02-2810:43thhelleror does the page include other global JS that may override symbols from the CLJS compilation?#2019-02-2810:43thhellerdo you use the :output-wrapper? https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper#2019-02-2810:43thhellerit is not on by default for multi module builds#2019-02-2810:43anmonteiroshould I be using :output-wrapper explicitly?#2019-02-2810:44anmonteiroI thought it was the default#2019-02-2810:44anmonteiro@thheller so that would explain why I can’t repro in dev / staging#2019-02-2810:44anmonteirobc we have a bunch of external analytics scripts running in prod#2019-02-2810:45thhelleryeah that is probably it then#2019-02-2810:45anmonteirothat could certainly explain why we don’t see it sometimes#2019-02-2810:45thhellergoogle analytics is a common offender when replaces something from the build#2019-02-2810:45anmonteirobut then we see it in the next build#2019-02-2810:45thhellerindeed#2019-02-2810:46anmonteiroI’ll try that, thanks for help!#2019-02-2810:46anmonteiro@thheller do you have a donation page for Shadow?#2019-02-2810:46thhellerworking on it 😛#2019-02-2810:46anmonteirowe’re putting aside some money for CIDER right now#2019-02-2810:46anmonteirocould also set aside some budget to help out Shadow#2019-02-2810:47anmonteiro@thheller this is important. Ping me directly when you’ve set it up please.#2019-02-2814:11thhellerSince you all keep asking I finally started setting up my Patreon: https://www.patreon.com/thheller#2019-02-2814:16thheller@anmonteiro ^ 😉#2019-02-2814:17anmonteiro💥#2019-02-2814:12thhellerI have no clue what I actually should do there so suggestions are very welcome#2019-02-2814:52anmonteiro@thheller btw broken again with :output-wrapper…..#2019-02-2814:53anmonteiroI’m sure this is my own fault but I’ve been at it for so long that I’m running out of clues#2019-02-2815:01thheller@anmonteiro did you try source maps? does that provide any hint at all?#2019-02-2815:01anmonteirosource maps are very confusing#2019-02-2815:01thhellerdo you js->clj at all?#2019-02-2815:01anmonteiroand don’t indicate the right lines#2019-02-2815:01anmonteiromaybe because of macros?#2019-02-2815:01anmonteirojs->clj where, for example?#2019-02-2815:01anmonteirolike, what would it impact?#2019-02-2815:06thhellerjs->clj has this problem with misidentified fast-path protocols#2019-02-2815:07thhellerthere should be an open issue about that, let me see if I can find it#2019-02-2815:07thhellerit mostly shows if you use js->clj on JSON data that has short property names with numeric values. eg. {"x":4}#2019-02-2815:08thhellerhttps://dev.clojure.org/jira/browse/CLJS-2050#2019-02-2815:09jeremyshello, quick question, I am trying to use shadow-cljs from a repl. When I use shadow.cljs.devtools.api/watch :a-build I get a “missing instance” error. From what I understand the exception comes from shadow.cljs.devtools.server.runtime/get-instance. Do I need to start something before using the watch fn?#2019-02-2815:09thheller@jeremys you need to start the embedded server first: https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2019-02-2815:10anmonteirohrm we do use js->clj in some places, but I don’t think they’d be in this code path#2019-02-2815:11thheller@anmonteiro the problem shows in extremely weird ways. like showing errors on completely unrelated parts of the code that should not be called at all#2019-02-2815:11jeremys@thheller oh ok thanks mate!#2019-02-2815:11anmonteiro@thheller that’s what I’m seeing#2019-02-2815:11anmonteiro> showing errors on completely unrelated parts of the code that should not be called at all#2019-02-2815:13anmonteirobut I can’t repro locally#2019-02-2815:14anmonteiroeven when serving the optimizd bundle#2019-02-2815:15thhellerdo you test with the same data?#2019-02-2815:15anmonteiroprobably not#2019-02-2815:16thhellerI spent days trying to debug this in the past until I finally figured out what was causing it and stopped using js->clj for JSON data 😛#2019-02-2815:16thhellerbut could be something else entirely of course. Just sounds very familiar 🙂#2019-02-2815:17thhellerbut you said you saw the issue with :pseudo-names which probably rules this out since the issue can't really happen with that#2019-02-2815:20anmonteiroI don’t know anything anymore#2019-02-2815:21thhellerjust in case did you try running shadow-cljs check your-build? It might provide a clue#2019-02-2815:21anmonteirocan I just use cognitect.transit to read JSON data?#2019-02-2815:22thhellernot generic JSON data no#2019-02-2815:22anmonteiro@thheller is there a way to run check as a library?#2019-02-2815:22thheller(shadow.cljs.devtools.api/check :build-id)?#2019-02-2815:23anmonteirotrying#2019-02-2815:23anmonteirocan it be run in dev?#2019-02-2815:23thhelleryes#2019-02-2815:23thhellerits not as useful as I'd like it to be since it reports too many false positives but something it can find hidden externs issues#2019-02-2815:24thhellerit just does a release build and runs the GCC type checker over it#2019-02-2815:26anmonteirook#2019-02-2815:26anmonteiro673 warnings#2019-02-2815:26anmonteirolet’s see#2019-02-2815:37thhellerhmm yeah it goes a little overboard on some things#2019-02-2817:09hlollijs.js:132 shadow-cljs - failed to load 59 how can I find out what module is number 59?#2019-02-2817:09thhellerdev or release?#2019-02-2817:09hlollirelease#2019-02-2817:10thhellerhmm actually that info isn't exported anywhere. you can set :js-options {:minimize-require false}#2019-02-2817:10thhelleror source maps?#2019-02-2817:11hlolliyes, it lists it in source maps, I get three "failed to load" messages with different numbers, but only one stacktrace#2019-02-2817:12thhellerhmm you don't get the error in dev?#2019-02-2817:13hlolliyup, it's lazy-cache module, npm ls lazy-cache shows a prompt module that Im using, wondering if I should remove it...#2019-02-2817:13hlolliso only release#2019-02-2817:15hlolliahhh ok, sorry totally my fault, for some reason, I'm loading a nodejs module, I have some code that I share between node and browser, and it didn't get DCE#2019-02-2817:16thhelleryeah. I actually implemented removing unused JS requires but that had very bad consequences 😛#2019-02-2817:20hlollidid you keep that setting optional for brave users?#2019-02-2817:21thhellerno. removed entirely. may come back in a different form at some point, maybe as a warning of sorts.#2019-02-2817:21thhellereg. ns foo.bar required "xyz" but didn't use it#2019-02-2817:21hlollibut I can avoid this by seperating the common code better. This release did work when I compiled in November with same namespaces that required the same modules.#2019-02-2817:21hlolliah I see#2019-02-2817:22thhellerI generally check if the build report is clean and doesn't contain stuff it shouldn't#2019-02-2817:23hlolliit makes sense in my case that it's included, a bit, I'm requireing 2 functions from a namespace that requires the unwanted module, but these functions don't call the module.#2019-02-2819:39souenzzofeature request:
(defn get-manifest
  [id]
  (-> (shadow/get-build-config id)
      :output-dir
      (str "/manifest.edn")))
Or maybe return manifest from (shadow/release :id)
#2019-02-2819:51thhellerhmm?#2019-02-2819:51thhellerwhat part in particular are you looking for?#2019-02-2819:52thhelleryou can use (-> (shadow/get-build-config id) (shadow/release* {}) (extract-whatever-info-you-need))#2019-02-2819:53thhellerrelease* returns the full build state after compilation which contains everything the manifest contains?#2019-02-2819:53thhellerrelease doesn't return anything on purpose since its meant to be used from the REPL#2019-02-2819:53thhellerin which case returning the build state for example blows up the REPL since it prints forever#2019-02-2819:55thhellerhttps://github.com/thheller/shadow-cljs/blob/21bc80f36598de6aaad0e12059991c1f8095ec9e/src/main/shadow/build/targets/browser.clj#L305-L318#2019-02-2819:55thhellerthats the extracted manifest data. you can probably limit it to the stuff you actually need#2019-02-2819:56thheller
(or (::closure/modules state)
    (:build-modules state))
#2019-02-2819:56thhelleronly release builds will have the :shadow.build.closure/modules data#2019-02-2821:29neupshHi, is there a easy shadow-cljs project/template to get started with creating addons/extensions for browsers like firefox and chrome?#2019-02-2821:39thheller@neupsh it is still kinda undocumented but it works and is used by people. https://github.com/thheller/shadow-cljs/issues/279#2019-02-2821:40thhellerhttps://github.com/fulcrologic/fulcro-inspect/blob/master/shells/chrome/manifest.edn#2019-02-2821:40thhellerhttps://github.com/fulcrologic/fulcro-inspect/blob/master/shadow-cljs.edn#L26-L28#2019-02-2821:41thhellerdon't know of any template, forgot what the other project was but there was another open source one#2019-02-2821:42thhellerat this point it probably won't change much anymore and I just have to finish the documentation#2019-03-0102:21eoliphanthi, I’m trying to use the grommet react lib with shadow, and I’m running into some issues, getting a bunch of failed to load messages, (e.g. failed to load module$node_modules$grommet$components$Box$Box), in looking at the node_modules layout it ‘seems’ like it should be ok. For example, there’s a node_modules/grommet/components/Box/Box.js During the compile, there’s one info/warning [2019-02-28 21:06:26.501 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/grommet/components/hocs.js", :requires [{:line 41, :column 11}]} In hocs.js theres some node code, that return require(.. is line 41
if (process.env.NODE_ENV !== 'production') {
  doc = function doc(component) {
    return require("./" + component + "/doc").doc;
  }; // eslint-disable-line

}
#2019-03-0102:33richiardiandreais there any docker image for shadow and lein that folks are using? I have found https://hub.docker.com/r/urbanslug/shadow-cljs but the link to github seems broken#2019-03-0103:00eoliphantnvm, just saw https://github.com/thheller/shadow-cljs/issues/428#2019-03-0116:32thhellerhttps://www.reddit.com/r/Clojure/comments/aw6roi/what_shadowcljs_is_and_isnt/#2019-03-0116:37thhellerhttps://twitter.com/thheller/status/1101521772174815237#2019-03-0120:00idiomancyanyone happen to know if there would be a way of expressing this in shadow? (the first line, I mean):
global.WebSocket = require('ws');
require('es6-promise').polyfill();
require('isomorphic-fetch');

#2019-03-0120:01idiomancythat like, assignment to the global scope#2019-03-0120:01thheller(set! js/goog.global.Thing ...)#2019-03-0120:01idiomancynice. thanks#2019-03-0120:01thheller(:require ["ws" :as ws]) (set! js/goog.global.WebSocket ws)#2019-03-0120:02idiomancybloody compiler wizard, you are#2019-03-0209:47heyarneI'm experiencing a bug and I'm not sure how to provide useful information on it. The situation goes like this: I start up shadow-cljs, my project compiles. I create a new folder, a new nested namespace... so theres airsonic-ui.components.*, where '*' means several different namespaces already existing. I create airsonic-ui.components.sortable.views, the namespace cannot be required. shadow-cljs warns me that it doesn't exist. I move airsonic-ui.components.sortable.views up to airsonic-ui.components.sortable, it's found. Any idea what might be going on here?#2019-03-0209:48thhellerhmm might be that new directories aren't watched properly automatically?#2019-03-0209:49thhellerwhich OS do you use?#2019-03-0209:53heyarneLinux#2019-03-0209:57thhellerhmm indeed. can reproduce. new directories just aren't picked up. wonder why this wasn't reported before#2019-03-0209:58thhellermaybe it works properly on macOS since that uses a different watcher#2019-03-0209:58thhellerwill fix#2019-03-0209:58heyarneAh sweet!#2019-03-0209:59heyarneAgain: it's amazing how responsive you are in this channel. Thanks so much! 🙌🙌🙌#2019-03-0210:06thhellerok. indeed a bug that probably only happens on windows/linux. will need to verify for macOS#2019-03-0210:06thhellerwonder why I never ran into this before 😛#2019-03-0210:06thhellerguess I don't create a new directories often enough 😛#2019-03-0210:13heyarneIt's actually a question that I ask myself often enough. I have a re-frame project and there are several components... some of them have their own events and subscriptions, some are only views. Do I always create main-namespace.comp.views or is main-namespace.comp enough? I guess it's a question of how defensive you write your code.#2019-03-0210:14thhellerhmm yeah I don't use re-frame so the .subs .views nested namespaces aren't that common for me#2019-03-0210:14thhellerbut I do create new packages sometimes. guess that always coincided with a restart or so#2019-03-0210:20thheller@arne-clojurians should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "abd8c3cacfc4dc86c8c7c1d8eb998593859a98"}, :content ("[email protected]")}#2019-03-0210:53heyarneCan confirm that it's working 🙂#2019-03-0210:53heyarneThis is amazing! Bug + fix in less than 30 minutes. Again, thanks!#2019-03-0213:55thheller@anmonteiro wow I think I may have found the reason you were running into problem with :modules, well maybe. do you set :language-out in your config?#2019-03-0218:27anmonteiro@U05224H0W I do - what’s up?#2019-03-0218:28anmonteiroBut I think I might not have been using it before#2019-03-0220:03anmonteirowait, no, we don’t set :language-out I don’t think?#2019-03-0220:03anmonteirowe set :feature-set :es5#2019-03-0221:00thhellerso what I noticed is that GCC defaults to using strict mode, ie. it will emit "use strict"; in front of each module#2019-03-0221:01thhellerthat has certain implications for cross module code so that one module can't always see code from the other#2019-03-0221:01thheller:language-out :ecmascript5 does adjust the feature set but it also disables strict mode#2019-03-0221:02thhellerI'll add that back as the default since it actually does more than just configure the :output-feature-set which I previously assumed#2019-03-0221:03thhellermaybe just setting :compiler-options {:language-out :ecmascript5} solves your problem#2019-03-0221:04thhellerbut since you tried :output-wrapper true the :language-out probably won't actually fix your problem since :output-wrapper works with strict mode#2019-03-0215:09metacriticalInteresting article on why no webpack https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html#2019-03-0215:19thhellercurrently writing another post showing how to use :modules properly which will hopefully make it a bit clearer why the "double-bundle" appraoch using webpack is bad 🙂#2019-03-0215:19thhellerI kinda want to add a challenge: build this with CLJS but without shadow-cljs 😉#2019-03-0215:20thhellerkinda unfair though since shadow-cljs was kinda built for exactly the scenario I setup 😉#2019-03-0218:47mhueberthmm, getting this isLoaded error when i call lazy/loaded? here. i am printing + js/logging the loadable above, so it itself is not undefined#2019-03-0218:54mhuebertfurther digging, if I call lazy/load on the loadable, I get the error “Unknown module: app”#2019-03-0218:55mhuebert:app is definitely one of my modules#2019-03-0220:59thhellerdo you have :module-loader true in your config?#2019-03-0221:00thhellerthats currently required#2019-03-0221:05thhellerthe problem is likely cause when a module id is used that doesn't actually exist#2019-03-0221:05thhellerit won't exist if :module-loader true is not used#2019-03-0221:05thhellerotherwise it should be there#2019-03-0222:13mhuebertAh that would be the problem#2019-03-0218:57mhuebertanother issue, I have a bunch of code that is shared between browser + nodejs. the browser build uses module splitting, while the nodejs build doesn’t. I am getting “Could not find module…” errors when trying to compile the node app.#2019-03-0219:09mhuebertI don’t use any of that stuff from node, i think it would be nice if there was just a runtime error if I ever tried to load one of the loadables#2019-03-0220:59thhellergood point. I'll see if I can think of something proper#2019-03-0312:11mhueberthmm. now I am getting errors like Uncaught ReferenceError: $spark_web$views$account$index$index$$ is not defined. this is happening after the module loads, which I verified by adding a logging statement via :append. I can see in the source of the account module that it is defining that thing, function $spark_web$views$account$index$index$$($var_args$jscomp$814$$) {...}, but it isn’t being set on the window object. if I manually add this line below it, window.$spark_web$views$account$index$index$$ = $spark_web$views$account$index$index$$;, then it loads correctly.#2019-03-0312:12mhuebertI tried setting :output-wrapper false, didn’t seem to have an effect#2019-03-0312:16mhuebertmaybe there is something weird with how my functions are being defined#2019-03-0312:17thheller@mhuebert yeah I discovered that bug yesterday#2019-03-0312:17thhellerfor now set :compiler-options {:language-out :ecmascript5} in your build config. I'll finish a release later that adds that default back.#2019-03-0312:18thhellerthe issue is that GCC defaults to strict mode so the function declared in the module files isn't visible globally#2019-03-0312:18thhellerie. the files start with "use strict"; when they shouldn't#2019-03-0312:19thhellerit should work with :output-wrapper true though#2019-03-0312:37mhuebert@thheller it works with that ecmascript setting. I might have put :output-wrapper in the wrong place#2019-03-0312:37mhuebert:compiler-options#2019-03-0312:37mhuebertoh nevermind I think misunderstood what you were saying#2019-03-0312:43thhelleryeah false won't work. true should.#2019-03-0312:43thhellerif defaults to false when using multiple modules#2019-03-0312:44mhueberti see that the warnings about module entries being moved have been improved#2019-03-0312:44mhuebertthis new setup feels much cleaner than before#2019-03-0313:16austinbirchHello all, does anybody know a workaround to only trigger a download of deps.edn dependencies whilst this issue is still open: https://github.com/thheller/shadow-cljs/issues/362? I’m sure I’ve read something somewhere about triggering a download of dependencies for deps projects, but can’t seem to find it.#2019-03-0314:34thheller@austinbirch you can just add shadow-cljs to your deps.edn and use clj to download the deps. clj -Stree or so#2019-03-0314:50austinbirch@thheller ah, okay. That works - thanks very much.#2019-03-0315:17bedersHas someone been able to successfully use atlaskit components with shadow-cljs? (see https://atlaskit.atlassian.com/packages/core/global-navigation ) I'm hitting a
You probably need to run:
  npm install querystring
caused by a dependency:
node_modules/url/url.js
And I'm not sure how I can troubleshoot it. I installed querystring, but the problem is not going away. querystring has a regular index.js which seems to be the top level module.
#2019-03-0316:10bedersSolved adding this to a build:
:js-options {:resolve {"querystring" {:target :npm
                                                    :require "querystring/index.js"}}}
#2019-03-0317:07thhellerno. you need to add shadow-cljs to your package.json.#2019-03-0317:08thhellerits one of those packages that is overriden by https://github.com/webpack/node-libs-browser#2019-03-0322:55thhellerhttps://github.com/thheller/shadow-cljs/issues/454#2019-03-0315:38sveri@thheller Hi Thomas, first of all, thanks for the awesome work. In case you got some time, I just created this issue: https://github.com/thheller/shadow-cljs/issues/453 and I am here for today if you want me to try some things out 🙂#2019-03-0316:59minhnnhow to change namespace in cljs.user#2019-03-0317:20thhellerin the REPL I assume? (require 'some.other.ns) then (in-ns 'some.other.ns)#2019-03-0320:48p-himik@thheller Thanks for the new article on code splitting! It's good to have an overview of this functionality. In the article, you mention shadow.lazy but it's not actually used anywhere. Also, demo.util/lazy-component is used but there's no implementation. Is this an exercise for the reader or will there be any addition to the article? I saw the code splitting example in your examples repo but it's very simplistic and doesn't have anything about lazy loading components.#2019-03-0320:49thhellerthe article is still in progress. I'm finishing things right now and will publish the full example with code#2019-03-0320:50thhellermeant to only publish the draft without making it public yet but did it wrong 😉#2019-03-0320:50thhellerI'll ping you once I finished it#2019-03-0322:12thhellerhttps://twitter.com/thheller/status/1102330984899506176#2019-03-0322:13thheller@p-himik https://github.com/thheller/code-splitting-clojurescript#2019-03-0409:04p-himikAwesome, thanks!#2019-03-0410:28heyarneHm... when starting the shadow-cljs server it tells me the nrepl-middlware can't be found on the classpath. How would I debug this? The dependency is added to the [shadow-cljs.edn](https://github.com/heyarne/airsonic-ui/blob/53748941c0d1b5439ff5774fe9e872c5ded06d3d/shadow-cljs.edn#L18).#2019-03-0410:29heyarneAlso CIDER seems to pass the dependency explitly as well: [nREPL] Starting server via /usr/bin/npx shadow-cljs -d nrepl:0.5.3 -d cider/piggieback:0.3.10 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.20.0 server...#2019-03-0410:29thhellerwhat does it say on startup?#2019-03-0410:30heyarne#2019-03-0410:31thhellerhmm you probably need to update shadow-cljs. there were a bunch of changes in nrepl and cider-nrepl not too long ago and I believe nrepl 0.6.0 is required now#2019-03-0410:31thhellernewer shadow-cljs versions provide the nrepl 0.6 version#2019-03-0410:31thhellerprobably also need to bump cider-nrepl to 0.20.0 since the CLI inject adds that version#2019-03-0410:32thhellerthe nrepl.middleware.caught ns is part of nrepl now and wasn't previously#2019-03-0410:32thhellerso either bump shadow-cljs or include [nrepl "0.6.0"] in your deps as well#2019-03-0410:36heyarneseems to work fine with 2.8.14, thanks!#2019-03-0410:45deplectGoodday everyone, was wondering if there is an idiomatic way of recognising I am either in a development build or I am performing a release build in shadow-cljs. Mainly to configure timbre and to disable some functionality I want in the dev builds vs production builds#2019-03-0410:46thhellerI recommend using https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines
#2019-03-0410:46thhelleryou can also use goog.DEBUG which is a built-in closure-define which will be false in release builds#2019-03-0410:47deplect@thheller thank you again Thomas#2019-03-0410:50thhelleryou can also use :preloads if you want to add namespace you'd rather not use in a release build. https://shadow-cljs.github.io/docs/UsersGuide.html#_preloads#2019-03-0410:50thhellereg. create a your.app.logging-dev namespace and include it via :preloads#2019-03-0412:28lkonstantinovhey - i am having some problem with shadow and httpurr (or probably promesa) when using advanced compilation#2019-03-0412:28lkonstantinovI guess some sort of extern failure#2019-03-0412:29lkonstantinov#2019-03-0412:32thhellerturn on externs inference https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-03-0412:32thhelleryou can also use shadow-cljs release your-app --pseudo-names#2019-03-0412:33thhellerwill make it easier to figure out that is getting renamed there#2019-03-0412:33lkonstantinovsec#2019-03-0412:35lkonstantinovseems to be the same with :infer-externs :auto#2019-03-0412:37thhellerinfer-externs will only warn you about stuff#2019-03-0412:38thhelleryou need to add the ^js hints whenever it warns about something#2019-03-0412:38thhellerbut yeah that tells you that .caught is getting renamed when it shouldn't but it seems to be something in promesa#2019-03-0412:38thhellerso you won't get a warning about that since its not in your code#2019-03-0412:39thhelleryou can fix this via https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2019-03-0412:39lkonstantinovyeah, i was hoping it was some sort of known problem with promesa 🙂#2019-03-0412:39lkonstantinovthanx#2019-03-0412:39thhelleryou can also probably just use :simple optimizations for node#2019-03-0412:39thheller:compiler-options {:optimizations :simple}#2019-03-0412:39thhellerthat will avoid dealing with externs#2019-03-0412:40lkonstantinovlet me see if i can get it working with the custom externs first, but yes - :advanced is not really needed for node, so if push comes to shove...#2019-03-0412:49lkonstantinovperfect, worked with adding two externs - caught and on 🙂 --pseudo-names was excellent#2019-03-0417:51pvillegas12After adding a lib in the package.json, how do I require it in my cljs file?#2019-03-0420:34thheller@pvillegas12 https://shadow-cljs.github.io/docs/UsersGuide.html#npm#2019-03-0420:34thhellertypically just (:require ["that-package" :as x]) in your ns#2019-03-0420:35pvillegas12:+1: @thheller I would that example more prominently 😄#2019-03-0423:16hlolliany cider users encountered this with cider-nrepl 0.21.0 or later?
[2019-03-05 00:14:50.420 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
CompilerException java.io.FileNotFoundException: Could not locate nrepl/middleware/caught__init.class or nrepl/middleware/caught.clj on classpath., compiling:(cider/nrepl.clj:1:1)
#2019-03-0423:17hlolliah I only had to scroll bit up to see this mentioned 😛#2019-03-0423:19hlollinot an error in shadow-cljs 2.8.14#2019-03-0423:29dpsuttoni think you need -d nrepl:0.6.0#2019-03-0423:30hlolliI think it must be included with the newest shadow-cljs, since it works just by bumping shadow.#2019-03-0423:31hlolliI somehow thought shadow-cljs updated it self automatically, is that featured turned off now?#2019-03-0423:31lilactownno, shadow-cljs will correspond with whatever is installed in your local project#2019-03-0423:32lilactowneither via npm or whatever classpath solution you use (deps.edn/leiningen/boot) if you use their integration#2019-03-0423:33hlolliah I see, I'm on npm. Ok, makes more sense in terms of reproduceable builds, to have this declerative. But cosy for development. I use ncu -a which bumps all my npm deps, including shadow, so not a problem for me.#2019-03-0504:07flyboarderboot-shadow has been updated to use shadow-cljs 2.8.14#2019-03-0504:07flyboarderhttps://github.com/degree9/boot-shadow#2019-03-0504:09flyboarder@thheller smoothest update to the boot task yet, shadow is great!#2019-03-0512:50biscuitpantsignoring obvious security holes, would it be possible to run a shadow-cljs build server on an AWS instance, and connect to the cljs-repl that is exposed? such that you can hot load CLJS code from a remote repl#2019-03-0514:37thheller@biscuitpants sure but lots of the assumptions build into the system is that files are loaded locally from disk#2019-03-0514:37thhellerso loading them purely over the REPL may not work properly#2019-03-0515:45biscuitpantshmm okay, and if we had all the source on disk too? so we are only compiling new code into an existing project#2019-03-0515:46biscuitpantsso process would be: git checkout develop of our project -> start shadow build -> connect via remote repl and switch to cljs and compile#2019-03-0515:47biscuitpantsto test i guess its just a matter of running shadow and opening the port it listens on, eh?#2019-03-0515:50thhelleryeah#2019-03-0518:20mhuebertHmm, running into a weird bug with Maria (trying to get it using latest dependencies). the first time I compile/watch, it works. after I make a change and recompile, on reload I get a whole pile of Namespace "goog.debug.Error" already declared. errors from goog.provide. I keep getting these errors even after I refresh the browser. Killing the shadow process and compiling from scratch, then it works again.#2019-03-0518:20mhuebertHmm, running into a weird bug with Maria (trying to get it using latest dependencies). the first time I compile/watch, it works. after I make a change and recompile, on reload I get a whole pile of Namespace "goog.debug.Error" already declared. errors from goog.provide. I keep getting these errors even after I refresh the browser. Killing the shadow process and compiling from scratch, then it works again.#2019-03-0518:39mhuebertworking on a minimal repro#2019-03-0519:18mhueberti’ve got it to happen twice in an extremely minimal project, but not in any predictable way#2019-03-0519:19mhuebertit somehow breaks the state, this time I was able to fix by going into the repl and manually restarting the :browser build#2019-03-0519:56mhuebertwell, I can semi-reliably reproduce it in Maria by starting a watch, going into a namespace and hitting spacebar + return a couple of times, then reloading the page. it’s usually (not always) broken after one or two compile cycles. I can unbreak it via (shadow/stop-worker :live) and then (shadow/watch :live). it will load successfully, then break again soon after a bit of editing. i don’t have to do anything with the :bootstrap build.#2019-03-0520:00thhellerhmm weird. that is the error you'd get when loading things that are already loaded#2019-03-0520:01thhellercan I run maria locally? without setting up a bunch of stuff? 😛#2019-03-0520:33mhuebertWith -A:release yes#2019-03-0520:35mhuebertshadow-cljs watch live trusted bootstrap with however you add the -A:release to that#2019-03-0520:44thhellerhmm npm install fails with a gigantic wall of text#2019-03-0520:45thheller
> 
#2019-03-0520:46thheller+ another 1000 lines or so since it seems to attempt to compile node-sass#2019-03-0520:57thheller
$ shadow-cljs -A:release watch live trusted bootstrap
shadow-cljs - config: /mnt/c/Users/thheller/code/oss/maria/editor/shadow-cljs.edn  cli version: 2.8.14  node: v10.13.0
shadow-cljs - starting via "clojure"
Downloading: appliedscience/js-interop/0.1.11/js-interop-0.1.11.pom from 
Error building classpath. Manifest type not detected when finding deps for lark/tools in coordinate {:git/url "", :sha "113b9f6f8d8ff7a3c35864fb5f50c20be61c729e", :deps/root "tools"}
#2019-03-0521:05mhuebertHmm#2019-03-0521:06mhuebertlet me figure this out, haven’t seen it before but I see it is happening on circleci too#2019-03-0521:10thhellerI just cloned the other repos then it at least seems to start#2019-03-0521:15thhellerok seems to be running. looks a bit weird because css is missing#2019-03-0521:15thhellerwhat do I do now?#2019-03-0521:17mhueberti am getting rid of the webpack thing as I wanted to deprecate that stage anyway. but I don’t know why you got the lark/tools error, that part works for me#2019-03-0521:18thheller
------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /mnt/c/Users/thheller/code/oss/maria/editor/src/maria/live/source_lookups.cljs:117:40
--------------------------------------------------------------------------------
 114 | (defn var-source
 115 |   "Look up the source code corresponding to a var's metadata"
 116 |   [{{meta-file :file :as meta} :meta file :file name :name :as the-var} cb]
 117 |   (if-let [logged-source (some-> (get @live-eval/evaluated-sources-by-filename meta-file)
----------------------------------------------^---------------------------------
 Use of undeclared Var lark.eval/evaluated-sources-by-filename
--------------------------------------------------------------------------------
 118 |                                  (source-of-top-level-form the-var))]
 119 |     (cb {:value logged-source})
 120 |
 121 |     (if-let [source-name (some-> (namespace name)
--------------------------------------------------------------------------------
`
#2019-03-0521:19mhuebertoh, i just renamed that var locally - pushed the new commit of lark/tools, 05bc43a10e8a72ba552cc87fd2794eb9db6f06c7#2019-03-0521:22mhueberti am just working on getting this building in circleci again#2019-03-0521:23thhelleroh I think I found the problem without having actually reproduced it#2019-03-0521:23thhellerthe live+trusted builds use the same :output-dir#2019-03-0521:24thhellerthat is not a good idea in dev mode and questionable in production a bit too#2019-03-0521:24thhellereach build should have its own directory#2019-03-0521:24thhellerotherwise the dev files will override each other#2019-03-0521:25mhuebertahhh#2019-03-0521:25mhuebertwell that would explain the weird nature of these errors#2019-03-0521:25thhelleryeah it would definitely cause weird stuff to happen#2019-03-0521:26thheller:async-require true this isn't required anymore. it is detected at runtime.#2019-03-0521:27thhellerI'm not actually sure the shared output-dir causes these errors but it might#2019-03-0521:27mhueberti’ll try it now#2019-03-0521:30mhueberti think that was it#2019-03-0521:31mhuebertnot seeing errors any more, and different-builds-overwriting-each-other would explain everything i was seeing#2019-03-0521:31mhuebertalthough..#2019-03-0521:31mhuebertlooking at the example i had set up, i had two different output-dirs there#2019-03-0521:32mhuebert
{:deps true
 :dev-http {8000 "public"}
 :builds {:browser {:target :browser
                    :modules {:app {:entries [shadow-ex.core]}}
                    :output-dir "public/compiled"
                    :asset-path "/compiled"}
          :bootstrap {:target :bootstrap
                      :output-dir "public/js/compiled/bootstrap"
                      :entries [shadow-ex.core]
                      :exclude [cljs.js]}}}
#2019-03-0521:33mhuebertbut, i am not seeing any problems in maria now#2019-03-0521:34mhuebertthank you!#2019-03-0520:01tomcI'm trying to convert a figwheel-based cljs project to shadow-cljs so that I can compare the dev experience. I have a javascript library (not from npm) under :foreign-libs in my figwheel config. How do I translate that to shadow-cljs?#2019-03-0520:02thhellerwhat kind of javascript lib?#2019-03-0520:02thhellercommonjs? es6?#2019-03-0520:03tomcneither, it just defines a function in the global scope#2019-03-0520:05thhellerdoes it have a goog.provide?#2019-03-0520:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-03-0520:07thhellerbasically you can skip all the foreign-lib stuff and just require the file directly#2019-03-0520:07tomcLooks like this is exactly what I need. Thank you.#2019-03-0520:08tomcGreat work on the shadow-cljs docs by the way. Nice to use a clojure project that holds the user's hand a bit.#2019-03-0603:56flyboarderIs anyone else getting this when running test builds for node-test no "source-map-support" (run "npm install source-map-support --save-dev" to get it) when source-map-support is installed….#2019-03-2710:40manuelhi everybody, I have a problem with my shadow-cljs project. I am trying to use carbon-react, so these are the steps I did: - yarn add react react-dom create-react-class carbon-react - yarn Then I used its components:
(ns carbon-example.dashboard.views
  (:require ["carbon-react/lib/components/app-wrapper" :as AppWrapper]
            ["carbon-react/lib/components/navigation-bar" :as NavigationBar]
            [re-frame.core :as rf]))

(defn- navbar
  []
  (fn []
    [:> NavigationBar]))

(defn panel
  []
  (fn []
    [:> AppWrapper
     [navbar]]))
But shadow-cljs compile carbon-example doesn't work:
shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn  cli version: 2.8.24  node: v8.15.1
[:carbon-example] Compiling ...
The required JS dependency "core-js/modules/es7.symbol.async-iterator" is not available, it was required by "node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js".

Searched in:/home/manuel/7bridges/code/carbon-example/node_modules

You probably need to run:
  npm install core-js/modules/es7.symbol.async-iterator

See: 
#2019-03-2710:41manuelThis is my shadow-cljs.edn file:
{:builds
 {:carbon-example {:asset-path "/js"
                   :modules {:main {:entries [carbon-example.core]}}
                   :output-dir "resources/public/js"
                   :target :browser}}

 :dependencies [,,,]

 :dev-http {8020 "resources/public/"}

 :devtools {:http-root "resources/public"
            :http-port 8020}

 :nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]
         :port 8777}

 :source-paths ["src"]}
#2019-03-2710:42thheller@manuel I'd guess that that is a version conflict somewhere, or just a missing peer dep#2019-03-2710:42thhellerdid you see this message?
npm WARN 
#2019-03-2710:42thhelleron npm install carbon-react#2019-03-2710:42manuelyes, I added those as well#2019-03-2710:44manuelrunning npm ls, the problem seems to be:
├─┬ 
An old version of core-js.
#2019-03-2710:44thhellerso carbon-react depends on "core-js": "^2.6.3",#2019-03-2710:44thhellerbut I also have {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "284b475a4d05425b6819061a061f"}, :content ("[email protected]")} installed#2019-03-2710:44thhellerprobably works if you just add core-js to you deps with the proper version#2019-03-2710:45thhellerso it doesn't get the nested install#2019-03-2710:45manuellet me try#2019-03-2710:46manuelI did: - yarn add - shadow-cljs compile carbon-example Now I get:
shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn  cli version: 2.8.24  node: v8.15.1                                                                                                  
[:carbon-example] Compiling ...                                                                                                                                                                                      
failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js                                                       
{:relative-to #object[java.io.File 0x6164b3a2 "/home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js"], :entry "../../utils/helpers/tags"}                   
ExceptionInfo: failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js                       
#2019-03-2710:47thhellerwtf is that pattern ... first time I see this#2019-03-2710:49manuelme too 🙂#2019-03-2710:50thhellerok yeah ... they have a weird directory structure I didn't know was allowed#2019-03-2710:51thhellerI'll see if I can add support for that in a bit#2019-03-2710:52manuelthank you, but no worries, we are testing different JS/CSS toolkits, so it may be the only case.#2019-03-2710:54thhellershouldn't be that hard. just never saw that pattern before#2019-03-2711:26thheller@manuel should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8cffe4ede8e3fba1efe0e6ffccbea2b4a2beb9"}, :content ("[email protected]")}#2019-03-2711:27manuelI'll try it asap and report back, thanks for the quick fix!#2019-03-2711:47manuel@thheller fantastic, it works. Thanks again.#2019-03-2713:53ccannhow might one go about adding the output-name from manifest.edn into index.html?#2019-03-2714:59ccannI ended up doing this with sed:
- run: HASH=$(sed 's/.*:output-name \"main\.\([a-zA-Z0-9]*\)\.js\".*/\1/' public/js/manifest.edn)
      - run: echo $HASH
      - run: sed -n "s|\"/js\/main\.js\"|main.$HASH\.js\"|g" public/index.html
if anyone has a better idea
#2019-03-2715:50thheller@ccann if you just have a static HTML file you can generate that via :build-hooks or clj-run.#2019-03-2715:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2019-03-2715:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-03-2717:45ccannSweet, I used clj-run and it works great. Thanks!#2019-03-2813:54heyarneI'm thinking about writing an in-browser ClojureScript REPL with some extra goodies (very focused on a specific task; essentially if *1 points to a specific kind of data, this data is displayed)#2019-03-2813:54heyarneI have no prior experience with self-hosted ClojureScript; where would I start?#2019-03-2813:56thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html I guess#2019-03-2813:56heyarnemerci!#2019-03-2814:00thhellerI don't know much about self-hosted myself, hurts my head thinking about it 🙂#2019-03-2820:13Nolandid i see recently that :node-library targets could be made single-file or am i imagining things?#2019-03-2820:50Nolanclosely related to this: https://github.com/thheller/shadow-cljs/issues/297. currently i deploy aws lambdas by copying and zipping all of node_modules. cant tell if there was ever a final decision about allowing the source files to basically just be concatenated or if that introduced edge cases to the point of not being worthwhile#2019-03-2821:00thheller@nolan I worked on that a bit here https://github.com/thheller/shadow-cljs/issues/290 but I honestly don't recommend using it#2019-03-2821:00thhelleryou could use something like https://github.com/zeit/ncc that'll work a bit more reliable#2019-03-2821:02Nolangot it. not a major thing for me currently, but foresee a few lambdas having unnecessarily larger node_modules in the future. thanks a million for the guidance as always @thheller#2019-03-2909:27orestisI need to (conditionally?) import a polyfill to support a JS library (react-boostrap, sigh, doesn’t work on IE11). Needs Object.assign. Is there a recommended way to do this with shadow-cljs/clojurescript? Should I load it conditionally directly in the HTML?#2019-03-2909:57orestisThere’s more to this — I actually need to make sure to load some polyfills before any 3rd-party code is loaded. I’m using for now a https://polyfill.io script element, but I would prefer if the contents of the returned polyfill to be prepended to my final bundled file, but without passing through google closure optimizations at all.#2019-03-2910:05thheller@orestis you can set :compiler-options {:language-out :ecmascript3} and it should add the closure polyfill for that#2019-03-2910:05orestisI’m writing an issue about it since it seems to be more complicated than that (due to Closure polyfill and React weird interactions)#2019-03-2910:06thhelleralternatively you can set :compiler-options {:closure-injected-libs #{"util/assign"}}#2019-03-2910:06orestisIs it language-out or :output-feature-set#2019-03-2910:06thhellerfor this part :language-out is probably better#2019-03-2910:07thhellernote that this only really applies to release builds so if you are testing with development builds that may not work#2019-03-2910:08orestishttps://github.com/thheller/shadow-cljs/issues/468#2019-03-2910:08thhellerbut since its fairly common for JS libs to unconditionally ship their own polyfills you may end up with multiple versions and the same polyfill#2019-03-2910:08thhellerwhich may not work#2019-03-2910:09orestisYeah that’s extremely annoying. I see for example that react-bootstrap depends on babel runtime…#2019-03-2910:09orestisI need it for development as well — our designers need to be able to test in IE11 while in dev mode to fix CSS and other things.#2019-03-2910:10thhellerI would honestly recommend keeping the polyfills as a separate script element which you can make conditional for only IE#2019-03-2910:13thheller@orestis in the github issue please provide at least some source reference on how I would reproduce the problem#2019-03-2910:13thhellerwhich npm module (+ version) to include and so on#2019-03-2910:13orestisOh sorry. Doing this right now.#2019-03-2910:13thhelleralso the actual error you run into#2019-03-2910:14thhellerI know it sucks extracting that for IE ...#2019-03-2910:17orestisDo you prefer a sample project? Or just library versions etc?#2019-03-2910:17thhellersample project would be great#2019-03-2910:22orestisLet me see how minimal it can get.#2019-03-2910:26thhellermake sure you have the correct versions installed#2019-03-2910:26thhellerthere might be some version conflicts#2019-03-2910:27thhellerplease check which version is in node_modules/@babel/runtime/package.json#2019-03-2910:27thhellershould be "^7.3.4"#2019-03-2910:46orestisMade a minimal repro here: https://github.com/orestis/shadow-polyfill-issue#2019-03-2910:47orestisObviously has to be tested with IE11#2019-03-2910:48orestisThanks so much for taking some time to look into this. It’s not a high priority for me, so please don’t feel any pressure at all.#2019-03-2910:49thheller
:compiler-options
        {:rewrite-polyfills true
         :language-out :ecmascript3}
#2019-03-2910:49thhellerthis works in release mode#2019-03-2910:52orestisThanks! Checking with the actual app to see.#2019-03-2910:56orestisCan I nest compiler options under “release”?#2019-03-2910:56thhellersure but that doesn't matter as those only apply to release anyways#2019-03-2910:56thhellerwill have no effect in dev#2019-03-2910:59orestisDoesn’t seem to fix the problem for the actual app… making sure I actually have the correct things.#2019-03-2911:03orestisNo luck 😞#2019-03-2911:04orestisThere might be other things in my actual application that trigger this in other ways.#2019-03-2911:04thhellerI made this demo ns#2019-03-2911:04thheller
(ns 
  (:require
    ["react-bootstrap" :as bs]
    ))

(defn init []
  (js/console.log js/Object js/Object.assign))
#2019-03-2911:04thhellerit loads fine in IE11 when the :compiler-options set#2019-03-2911:04thhellerfails with the .assign error if not#2019-03-2911:04thheller
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :dev-http
 {9005 "public"}

 :builds
 {:app {:target :browser
        :modules {:main {:init-fn }}
        :compiler-options
        {:rewrite-polyfills true
         :language-out :ecmascript3}
        }}}
#2019-03-2911:05thhelleragain only in shadow-cljs release app#2019-03-2911:05orestisAh, but that doesn’t exercise the code inside react-bootstrap, it looks?#2019-03-2911:05thhellernot for compile or watch#2019-03-2911:06thhelleryes, but the error you posted happens during load#2019-03-2911:06thhellerif you get past the load stuff then its probably a different error#2019-03-2911:06orestisThat’s true, in release mode the error happens during load. In dev mode it’s shadow catching the error and reporting it.#2019-03-2911:07thhellerjust forget about development mode for now#2019-03-2911:07thhelleronly interested in release as that is currently the only thing that can potentially work#2019-03-2911:07thhellerdev is busted and won't work regardless#2019-03-2911:08orestisI’ll see about my minimal repro in release mode and report back after lunch. Thanks for looking into this!#2019-03-2911:47thheller@orestis it works if you set :js-options {:rewrite-polyfills true} + the :compiler-options#2019-03-2911:48thhellereven seems to work in dev mode#2019-03-2911:48thheller
:js-options
         {:rewrite-polyfills true}
         
         :compiler-options
         {:language-out :ecmascript3
          :rewrite-polyfills true
          :infer-externs :auto}
#2019-03-2911:49thhellerit worked in my test since I used Object.assign in the CLJS sources which caused the polyfills to be added#2019-03-2911:49thhellerbut the JS sources are processed in a separate pass so it must be enabled there manually#2019-03-2912:10orestisCan confirm that the js-options fixes the Object.assign issue. The broken Symbol.for polyfill though seems to linger on, probably need to wait for a Google Closure compiler bump for this? Seems the issue is fixed upstream (or at least closed).#2019-03-2912:11thhellerwhat issue is that?#2019-03-2912:16orestishttps://github.com/facebook/react/issues/13414 , traced to https://github.com/google/closure-compiler/issues/3052#2019-03-2912:17thhelleryes I saw that. how to do I reproduce that though?#2019-03-2912:17thhellerI'm in the process of bumping the closure compiler anyways so it may just work#2019-03-2912:17thhellerstill need a way to reproduce that to test#2019-03-2912:18orestisMy minimal repro example shows that#2019-03-2912:18orestisCorrect rendering#2019-03-2912:20orestis(building… 😄 )#2019-03-2912:20orestisIE11 with broken Symbol polyfill rendering#2019-03-2912:21thhellerah ok#2019-03-2912:21orestisFor some reason, it’s 60107 wherever a react fragment appears. I haven’t been able to get any meaningful google hits for this so potentially you’ll get another number.#2019-03-2912:21thhellerdidn't notice that 😛#2019-03-2912:22orestisDo I have to go to ES3 or should just rewrite polyfills do it?#2019-03-2912:24thhellerthe symbol issue also doesn't work with the latest closure compiler version#2019-03-2912:26thhellerhmm but it looks like thats not a react issue#2019-03-2912:27thhellerif I do this the fragment renders correctly (just removed hx)#2019-03-2912:27thheller
(defn ^:dev/after-load render []
  (react-dom/render
    (r/createElement r/Fragment nil
      (r/createElement "div" nil "content 1")
      (r/createElement "div" nil "content 2"))
   (js/document.getElementById "main")))
#2019-03-2912:29orestisCould be on subsequent renders?#2019-03-2912:30orestisProbably not, hx should only render once.#2019-03-2912:30orestisIn any case, I’ll shrug this. Could be nice to have a self-contained bundle with all the necessary polyfills, but probably best to just load them in HTML.#2019-03-2912:31orestisSorry for taking up your time#2019-03-2914:26lilactownMight be something wrong with hx. Feel free to file an issue#2019-03-3000:31Daniel HinesHi all. For some reason, nREPL doesn’t start when I run shadow-cljs watch app#2019-03-3000:31Daniel HinesIt worked fine for me on the lein shadow template, which I based my config on.#2019-03-3000:31Daniel HinesHere’s my current config:
{:source-paths
 ["src"]

 :dependencies [[binaryage/devtools "0.9.7"]
                [cider/cider-nrepl "0.20.0"]
                [datascript "0.18.2"]
                [posh "0.5.5"]
                [org.clojure/clojure "1.10.0"]
                [org.clojure/clojurescript "1.10.520"]
                [org.clojure/core.async  "0.4.490"]
                [reagent "0.8.1"]]

 ;; set an nrepl port for connection to a REPL.
 :nrepl        {:port 8777}

 :builds
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"

        :modules
        {:main
         {:entries [rectangles.core]}}

        :devtools
        ;; before live-reloading any code call this function
        {:before-load rectangles.core/stop
         ;; after live-reloading finishes call this function
         :after-load rectangles.core/start
         ;; serve the public directory over http at port 8700
         :http-root    "public"
         :http-port    8700
         :preloads     [devtools.preload]}
        }}}
#2019-03-3000:31Daniel HinesWhat am I doing wrong?#2019-03-3000:32thhellerdoes it log something on start?#2019-03-3000:35Daniel Hines
shadow-cljs - config: /Users/d4hines/repos/rectangles/shadow-cljs.edn  cli version: 2.8.25  node: v8.12.0
shadow-cljs - connected to server
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (207 files, 1 compiled, 0 warnings, 5.02s)
#2019-03-3000:35Daniel HinesIt was showing the nREPL info, and then it cut out with some change I made.#2019-03-3000:35thhellershadow-cljs - connected to server#2019-03-3000:35thhellerthere is a server isntance still running#2019-03-3000:35thhellershut that down and do a clean restart#2019-03-3000:36Daniel HinesOoooh, thanks! That worked!#2019-03-3000:36Daniel HinesMuch appreciate it 🙏#2019-03-3019:48hjrnuneshi, can anyone pls point me to docs on :> usage? As in [:> :div props child0 child1] thanks!#2019-03-3019:49hjrnunesspecifically, I'm trying to use this https://www.npmjs.com/package/react-masonry-css with shadow-cljs#2019-03-3020:08thheller@hjrnunes don't know where the docs are, probably better to ask in #reagent#2019-03-3020:09hjrnunes@thheller i got it, thanks!#2019-04-0116:21heyarneI have some problems with karma on circle-ci 😕 some tests just fail, rerunning them succeeds https://circleci.com/gh/heyarne/airsonic-ui/32#2019-04-0116:22heyarnewith "some tests" i mean some test runs, not some tests out of the whole test suite#2019-04-0116:22heyarnelanguage is hard#2019-04-0116:22heyarnehttps://circleci.com/gh/heyarne/airsonic-ui/33 is the same code, just rebuilt#2019-04-0116:32lilactownFWIW I've been using karma tests on circle-ci for a month or so now and had no issues#2019-04-0116:32lilactownhere's my karma.conf.js: https://github.com/Lokeh/hx/blob/master/karma.conf.js#2019-04-0116:58heyarne@lilactown do you use it locally, too?#2019-04-0116:58lilactownnope. I use the graphical test runner#2019-04-0116:59heyarneBecause I've been using it in the background to continuously watch and build#2019-04-0116:59heyarneGraphical test runner?#2019-04-0116:59lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test#2019-04-0116:59heyarneAh#2019-04-0117:05thheller@arne-clojurians it seems like compilation didn't finish before the tests are run#2019-04-0117:05thheller
shadow-cljs - config: /home/circleci/repo/shadow-cljs.edn  cli version: 2.8.25  node: v10.15.3
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[:test] Compiling ...

> 
#2019-04-0117:08thhellerthere have been issues before with circleci killing build processes running OOM. not sure how big your build is but it seems to help to set :jvm-opts ["-Xmx2G"] (limiting the JVM to max 2gig ram)#2019-04-0117:12heyarneHm I might just dump karma altogether. Or run a config similar to lilactown's. As much as I like having the tests run in the background permanently it's also quite fragile with complaining about syntax errors every so often yada yada#2019-04-0117:12heyarneThe browser-test might serve me just as well. 🙂#2019-04-0117:13thhellerthere are no syntax errors#2019-04-0117:13heyarnePlus if there are any contributors I don't have to tell them to install chrome#2019-04-0117:13heyarneNot on circleci, no#2019-04-0117:13thhellerit just isn't finished compiling. figure out why and the problem goes away#2019-04-0117:13heyarneBut with the --watch feature#2019-04-0117:13thhellerah ok#2019-04-0117:14heyarneooh wow stackoverflow sure is pretty today#2019-04-0117:14heyarnei already forgot about that font, it used to be everywhere for a time#2019-04-0209:42crankyadmin👋:skin-tone-2: I'm attempting to use a service worker to cache some files locally on the client machine.#2019-04-0209:43crankyadmin
; "main.js" is the name for the bundle entry
        :modules  {:main           {:entries [<snip>.]
                                    :init-fn <snip>.
                   :service-worker {:entries    [<snip>.viewer.service-worker]
                                    :depends-on #{:main}
                                    ;:web-worker true
                                    }}
#2019-04-0209:43crankyadminBut I keep getting `service-worker.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined at service-worker.js:1` in the console in Chrome.#2019-04-0209:44crankyadminBut I keep getting service-worker.js:1 Uncaught ReferenceError: SHADOW_ENV is not defined at service-worker.js:1 in the console in Chrome.#2019-04-0209:44crankyadminI've more or less lifted the service worker source from https://github.com/gja/pwa-clojure/blob/master/src-svc/pwa_clojure/service_worker.cljs#2019-04-0209:44crankyadminCould anyone possibly point me in the right direction?#2019-04-0209:51thheller;:web-worker true this needs to be true, otherwise things aren't loadable in a worker env#2019-04-0209:52crankyadminYep, tried that too... gives a different error, two secs and I'll grab that.#2019-04-0209:53crankyadminWith :web-worker true I get uncaught ReferenceError: importScripts is not defined#2019-04-0209:54thhellerhmm do service workers not support that?#2019-04-0209:54crankyadminLooks like something is borked...#2019-04-0209:54thhellernot actually sure they ever did but I thought they did#2019-04-0209:55thhellerto be honest CLJS is complete overkill for service workers, something like https://developers.google.com/web/tools/workbox/ seems much more practical#2019-04-0209:57thhellerseems like importScripts should be supported? https://www.w3.org/TR/service-workers-1/#importscripts#2019-04-0209:59crankyadminI'm stumped....#2019-04-0210:00thhellerservice workers are weird. do you maybe have one already running that didn't update correctly or so?#2019-04-0210:02thhellercheck the service-worker.js. it should start with importScripts("main.js")#2019-04-0210:02thhelleryou are missing a "shared" module in your build config#2019-04-0210:02thhellerthe way you have it setup now your service worker will load the entire app as well#2019-04-0210:03thheller
:modules
{:shared
 {:entries []}
 
 :main
 {:init-fn <snip>.!
  :depends-on #{:shared}}
 
 :service-worker
 {:entries [<snip>.viewer.service-worker]
  :depends-on #{:shared}
  :web-worker true
  }}
#2019-04-0210:04crankyadminCool. Give me a sec and I'll give it a try.#2019-04-0210:04thhellerthat won't affect the error you see though#2019-04-0210:05crankyadmin😞#2019-04-0210:06thhellercan't try this right now. you can open an issue and I'll look at it later#2019-04-0210:06crankyadmin👍:skin-tone-2: Cheers pal#2019-04-0301:11markxHello! Is there a way to eval in cljs on node?#2019-04-0304:15markxWell, I mean, cljs doesn’t have it. Is it possible that shadow-cljs provide this function?#2019-04-0306:49Stefan@markx Do you mean something like this? https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library#2019-04-0308:28thheller@markx you mean https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html just for node?#2019-04-0316:16markxKinda, but not really. Current I have the need to dynamically load code source at runtime. There are clojure.core/load and clojure.core/load-file, but not available in cljs. So I’m wondering if this is possible via shadow-cljs.#2019-04-0316:18lilactownin order to evaluate code at runtime, you have to follow the steps in that blog post#2019-04-0316:19lilactownnormally the CLJS compiler is not included in your bundle. in order to use eval, you have to include it#2019-04-0322:42markxGreat, so it could eval. Does it still only support browser though? I’ll need to use it on nodejs to load local files.#2019-04-0322:43thhellerI added support for node. you just use the shadow.cljs.bootstrap.node ns instead of the browser one#2019-04-0322:44thheller
(ns demo.bootstrap-script
  (:require
    [cljs.js :as cljs]
    [cljs.env :as env]
    [shadow.cljs.bootstrap.node :as boot]))

(defn print-result [{:keys [error value] :as result}]
  (prn [:result result]))

(def code "(prn ::foo) (+ 1 2)")

(defonce compile-state-ref (env/default-compiler-env))

(defn compile-it []
  (cljs/eval-str
    compile-state-ref
    code
    "[test]"
    {:eval cljs/js-eval
     :load (partial boot/load compile-state-ref)}
    print-result))

(defn main [& args]
  (boot/init compile-state-ref {} compile-it))
#2019-04-0322:45thheller
:bootstrap-script-host
  {:target :node-script
   :main demo.bootstrap-script/main
   :output-to "out/demo-bootstrap/script.js"

   :compiler-options
   {:optimizations :simple}

   :devtools
   {:enabled false}}

  :bootstrap-script-support
  {:target :bootstrap
   :output-dir "out/demo-bootstrap/bootstrap"
   :exclude #{cljs.js}
   :entries [cljs.js demo.macro]
   :macros []
   :js-options
   {:js-provider :require}}
#2019-04-0322:45thhellerhttps://github.com/thheller/shadow-cljs/blob/fd3288fc3f36b9130e1af61d302f371667cadfa7/shadow-cljs.edn#L405-L423#2019-04-0322:47markxThat could work. I’ll try. Thanks!#2019-04-0315:50Hendrik Poernama
{:deps {:aliases [:dev :test]}
 :builds ...}
If I am using deps.edn and define multiple aliases, which one is used for development and which one is used for release build? For example, if I have cider-nrepl in the dev alias, will it get included in release build? From my experiment, it looks like shadow-cljs is doing the right thing, but would like to know how.
#2019-04-0315:56lilactown@poernahi shadow-cljs release uses the same classpath as for development#2019-04-0315:56lilactownanything that's not referenced in your CLJS files will not be included#2019-04-0315:56lilactownin this case, cider-nrepl is a Clojure dep so there's no way it will end up in your release 😉
#2019-04-0316:08publicmayhemHi! Is there a way of pulling clj/cljs dependencies from private s3 repos? I've looked for something like this in doc but cannot see anything
:repos
               {"s3-private-snapshot" {:url ""}
                "s3-private-release" {:url ""}}
#2019-04-0316:17Hendrik Poernama@lilactown thanks!#2019-04-0317:25thheller@robert.law yes, use :repositories not :repos though. same as in lein. this is the lib used for that https://github.com/s3-wagon-private/s3-wagon-private#2019-04-0318:26publicmayhemthanks that worked#2019-04-0322:53markxCurrently I’m trying to build an web app, including both clojure backend and cljs SPA. I think the backend will already have a http server for the api, so I’m looking to use this server to host static assets too, e.g. js files. But on dev, I also want shadow-cljs’ dev http server, so I can have hot-loading and everything. Is it possible to reuse my clojure http server as the shadow-cljs dev server?#2019-04-0322:54thhellerthe hot-reloading is not coupled to the dev http server#2019-04-0322:54thhellerit works with any webserver#2019-04-0322:54thhellerso just make your CLJ server serve the static files and you are good to go#2019-04-0322:55markxwow that’s great! Is there any magic in the dev http server?#2019-04-0322:55thhellersafe caching defaults I guess#2019-04-0322:56thhellerusual CLJ servers cache too much which is a bit annoying sometimes#2019-04-0322:56markxSo we should still prefer the dev server, if we can?#2019-04-0322:57thhelleryou can use a setup like this#2019-04-0322:57thheller
:dev-http
 {8081
  {:root "public"
   :proxy-url ""}}
#2019-04-0322:57thhellerthe CLJ server is running on :8080 and serves everything BUT the static files#2019-04-0322:57thhellerso the caching rules of the dev server apply for the static files#2019-04-0322:58thhelleryou could of course just set the proper cache rules for your server#2019-04-0322:59thhellerits just setting the cache-control: private, no-cache header#2019-04-0322:59thhellershould be easy enough with most CLJ servers#2019-04-0323:01thhellerbut really the dev http servers just serve files#2019-04-0323:01thhellernothing special about the server at all#2019-04-0323:01thhellerthe websocket stuff is handled by the server running on :9630, nothing to do with the dev http server#2019-04-0323:05markxGreat! I’ll give it a try. Thanks!#2019-04-0323:07thhellerFWIW I'm currently working on an app using pedestal on the backend#2019-04-0323:07thhellerI just added an interceptor that sets the cache header (and don't use the shadow-cljs server at all)#2019-04-0323:39markxThanks for the recommendation. Anything special you like about it over Ring?#2019-04-0409:31thheller@markx I actually don't like it much. the interceptor design is better in general but some design choices are weird#2019-04-0410:42orestisI liked the fact that Pedestal was ready to go for “production” with some logging etc (and also I liked the interceptor concept). No regrets so far for using it, as you can reuse all the ring middleware out there.#2019-04-0414:55Michael PorterHi, I'm fairly new shadow-cljs, but very impressed so far. I'm having an issue though where I get a Uncaught ReferenceError: regeneratorRuntime is not defined message in the browser console. I'm using the npm workbox-precaching package (in a service worker) and the error is occurring in one of the source files this uses (`node_modules/workbox-core/_private/quota.mjs`). It seems that this file (that uses async/`await`) is getting transpiled to ES5 and the transpiled version is expecting a global regeneratorRuntime to be defined:
var executeQuotaErrorCallbacks = function () {
  var _ref = global.shadow.js.babel.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
    var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback;

    return regeneratorRuntime.wrap(function _callee$(_context) {
Has anyone come across this before?
#2019-04-0415:36Michael PorterAs a workaround, I've found I can get this to work by prepending the JS file that defines regeneratorRuntime (https://raw.githubusercontent.com/facebook/regenerator/master/packages/regenerator-runtime/runtime.js) to my worker.js file that shadow-cljs generates. Is there a mechanism in shadow-cljs that will allow me to prepend some JS to a module?#2019-04-0417:39thheller@mike469 what do you require? by default it should be using the node_modules/workbox-precaching/dist/workbox-precaching.prod.js. which doesn't work either but for different reasons?#2019-04-0417:43Michael PorterI'm doing (:require ["workbox-precaching/precacheAndRoute.mjs" :refer (precacheAndRoute)]) currently which is causing the regeneratorRuntime error. I don't seem to have a dist dir in node_modules/workbox-precaching#2019-04-0417:45thhellerhmm which version do you use? I just installed {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6b1c041900090413461b190e080a080302050c2b5f4559455b"}, :content ("[email protected]")}#2019-04-0417:46thhellerbut yeah including the .mjs directly will skip the prod file#2019-04-0417:46Michael Portermy current versions are: ` "workbox-precaching": "^4.1.1", "workbox-routing": "^4.2.0", "workbox-strategies": "^4.2.0"#2019-04-0417:47Michael Porternot sure why there would be no dist, I just npm install'd them#2019-04-0417:48thhellerso the problem is that the babel parts are not meant to rewrite the async/await at all#2019-04-0417:48thhellerbut for some reasons they do#2019-04-0417:49thhellerI'm only using babel to rewrite import -> require since it works differently than what the closure compiler does#2019-04-0417:50thhellernon standard behavior that is the cause of many headaches ...#2019-04-0417:52thhellerhmm yeah the code is pushing my simple babel interop a bit too far#2019-04-0417:53Michael Porterhmm I see, so have you managed to get workbox-precaching working with shadow-cljs previously? Perhaps I just need to figure out why I'm missing the 'dist' versions?#2019-04-0417:53thhellerno I haven't worked with that through shadow-cljs#2019-04-0417:53thhellerI tried using the workbox cli directly and use that output#2019-04-0417:54thhellerthe dist files don't work either so don't worry about it#2019-04-0417:55Michael Porterah ok, so is it babel that inserts the regenerator references?#2019-04-0417:55thhelleryes#2019-04-0417:55thhellerthe problem is polyfilling ...#2019-04-0417:55thhellerthat is currently not configurable for node_modules files#2019-04-0417:56thhellerit shouldn't touch this at all and just leave async/await as they are as server workers support that#2019-04-0417:56thhellerso usually you'd set :compiler-options {:output-feature-set :es7} (or whatever async/await was)#2019-04-0417:56thhellerand the compiler would leave it alone#2019-04-0417:57Michael Porteryes I did try that but found it had no effect#2019-04-0417:57thhellerbut that doesn't yet work for node_modules since it goes through some naive babel processing first#2019-04-0417:58thhellerI had to go through babel since babel added some non-standard ESM->CJS interop that lots of npm libs rely on#2019-04-0417:58thhellerthe google closure compiler only allows the strict interop and breaks many packages#2019-04-0417:58thhellersomething like https://github.com/google/closure-compiler/issues/3308#2019-04-0418:00thhellerI can try something maybe that helps#2019-04-0418:02Michael PorterFYI adding the regenerator-runtime/runtime.js verbatim to the start of my generated worker js bundle does fix it for me in this instance#2019-04-0418:02thhelleryes but the point is that all that is not required#2019-04-0418:02Michael Porter(I'm only testing in dev mode currently)#2019-04-0418:02thhellerservice-workers support async/await so they should not be rewritten to add that huge regenerator crap#2019-04-0418:05Michael PorterRight yes understood. I have to go out now but thanks for your help and drop me a message if you want me to try anything out#2019-04-0508:03flowthingI inherited a project that has functions like this in dev.clj:
(defn start []
  (shadow.server/start!)
  (shadow/watch :app)
  (start-app))

(defn stop []
  (app/stop)
  (shadow.server/stop!))
However, my understanding is that restarting the shadow-cljs server should only be necessary if dependencies change. Is that correct? In other words, it would be better to start the shadow-cljs server via npx shadow-cljs server app and then just start/stop the shadow-cljs watcher in the start and stop functions?
#2019-04-0508:03flowthingI don't know that there's a downside to restarting the shadow-cljs server, though.#2019-04-0509:02thheller@flowthing yes only changing dependencies should require a restart. stop! stops all running watch processes an in turn kills all REPL state/connections#2019-04-0509:02thhelleryou can still use the embedded server. just don't call stop!#2019-04-0509:29flowthingAll right, thanks. The way this project is set up is that you're supposed to call lein repl :headless, then connect to the nREPL with your IDE, and then run (start). This way (stop) doesn't kill the REPL.#2019-04-0509:30thhelleryeah I do that for my CLJ setups as well#2019-04-0509:30thhellerjust run shadow-cljs separately#2019-04-0509:30thhellerbut it is a bit annoying to manage multiple REPL connections#2019-04-0509:31thhellerso I understand why some people might prefer dealing with only one connection#2019-04-0509:31flowthingRight. I guess the choice between starting the shadow-cljs server from the command line or using the embedded server here is mostly a matter of preference, then?#2019-04-0509:32thhelleryeah. I think things are more reliable if you leave shadow-cljs running independently but otherwise things work the same#2019-04-0509:33flowthingGotcha. Many thanks, both for the answers and for shadow-cljs itself!#2019-04-0510:47gravIs it possible to switch between connected clients from the cljs repl? Couldn’t find anything in the docs.#2019-04-0510:49thheller@grav not currently no. the web ui at http://localhost:9630 lets you select which client you connect to but that API isn't accesible elsewhere currently#2019-04-0510:49thhellermostly because tools wouldn't use it anyways#2019-04-0510:51thhellerthe logic currently picks the first connected client#2019-04-0510:57gravOk, but the repl accessible via the Web ui isn’t a cljs one?#2019-04-0510:58gravOh, the ones for the clients are.#2019-04-0510:58gravThat’s good enough for me - it allows me to delete the caches on the various clients when I mess up 🙂#2019-04-0511:00gravBtw, I eventually got both iOS and Android to connect to both https and ssl with live-reload and everything. I just needed to explicitly tell iOS to trust my custom root cert, and I needed to setup port forwarding via Chrome DevTools for both https and wss and use localhost from Android.#2019-04-0511:02gravBeing able to inspect both devices directly from IntelliJ would be freakin’ awesome, but at least the repls in Shadow CLJS’ web-ui brings me some of the way 🙂#2019-04-0519:07feelextraHello, i'm trying to use shadow-cljs for writing a ClojureScript script on Node.js I get an error
No such namespace: js
The instructions that got me there: 0. Configure shadow-deps.clj:
{:source-paths ["src"]

 :dependencies []

 :nrepl        {:port 3333}

 :builds
 {:app {:target :node-script
        :main demo.script/main
        :output-to "out/demo-script/script.js"
        :output-dir "public/js"
        :asset-path "/js"

        :modules
        {:main
         {:entries [demo.script]}}}}}
1. shadow-cljs node-repl app:
cli version: 2.8.26  node: v10.9.0
shadow-cljs - server version: 2.8.26 running at 
shadow-cljs - nREPL server started on port 3333
[0:0]~cljs.user=> 
2. Connect to the Remote Configuration nREPL port 3333 in Cursive, open REPL and see this message:
Connecting to remote nREPL server...
Clojure 1.10.0
3. Evaluate (shadow/repl :app) in the REPL
(shadow/repl :app)
To quit, type: :cljs/quit
=> [:selected :app]
4. Evaluate (js/console.log "working?") 5. Receive the error Any idea how to solve this?
#2019-04-0519:36feelextraI figured something out on this link [shadow-cljs guide by loganpowell](https://github.com/loganpowell/shadow-proto-starter#using-protorepl): > For Node development - unlike when targeting the browser - you'll use:
(shadow.cljs.devtools.api/node-repl)
After evaluating that expression I don't get the error anymore, so I guess the instruction #3 should be replaced with this, in the instruction list I've described above.
#2019-04-0610:04thheller@icyiceling184 shadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code).#2019-04-0610:04thhellersomething seems to be missing from the steps you posted#2019-04-0610:04thheller(shadow/repl :app) is not possible unless a watch for app is running#2019-04-0610:04thhellerso you maybe have that running elsewhere?#2019-04-0610:05thhellerbut yeah just using node-repl is fine and recommended#2019-04-0613:42feelextra@thheller Thank you for the prompt reply! After having processed the detailed information you provided me I was able to reach a setup with the shadow-cljs watching the build and being able to connect to a node process via nREPL. Apparently these were the points I needed to know: 1. > shadow-cljs node-repl does not take a build argument. it starts a generic node REPL that doesnt have anything else loaded (none of your script code). I now understand that there are multiple ways to start up a Node.js process: - On terminal: shadow-cljs node-repl - On terminal: node out/demo-scripts/script.js - In a REPL at shadow.cljs ns: (shadow.cljs.devtools.api/node-repl) Therefore the quote on the shadow-proto-starter link I gave above is a bit misleading in instructing to use the third option without providing context on the other options available. 2. > (shadow/repl :app) is not possible unless a watch for app is running On the steps that I had followed above, this command was absent, so I can see why (shadow/repl :app) failed for me. At this point, having watch compile my main namespace on changes isn't actually doing anything for me aside from spitting warnings:
(process.on "SIGINT" on-signal-interruption)
 Use of undeclared Var demo.script/process

 (process.getuid)
 Use of undeclared Var demo.script/process
I was also trying to setup :devtools config to work, but didn't get a lot of success there out of the box, so i'm gonna let it go for now. So right now I don't have a good reason to have watch running, so I'm going to avoid that and just connect to a Node.js process and re-evaluate the namespace i'm working on upon changing the file. I also have start, stop functions that do some I/O for me which I have to do before and after re-evaluation. Moving forward I might want to set that up with the :before-load and :after-load build hooks. When I decide to try do that, and am stuck again I'll post a minimal reproduction to try and pinpoint the problem I ran into.
#2019-04-0613:43thheller(process.on ...) is not valid code. that should be (js/process.on ...)#2019-04-0613:49thheller@icyiceling184 you must differentiate between the REPLs a bit. There is either a *generic* REPL like node-repl or browser-repl. These are not coupled to a specific build.#2019-04-0613:49thhellerthen there is a build REPL where you can REPL into a specific build configued in your :builds#2019-04-0613:50thhellerthe difference between the two is basically that the build REPLs also do other stuff on their own (eg. running your :main function, hot-reload, etc)#2019-04-0613:50thhellerthe generic REPLs do nothing on their own, only what you make them do#2019-04-0613:53thhellerso node out/demo-scripts/script.js this doesn't start a node REPL. that starts a build REPL, your build just happens to be running in node. so yes it is running a node REPL but that is not the same thing as node-repl#2019-04-0613:54thhellerI know its confusing ...#2019-04-0613:54thhellerso basically if you want hot-reload use a build and REPL into that#2019-04-0613:54thhellerif you don't just use node-repl#2019-04-0613:55thhellerhttps://github.com/minimal-xyz/minimal-shadow-cljs-nodejs here is a minimal setup if you want to try#2019-04-0614:31feelextra@thheller Re: > (process.on ...) is not valid code. that should be (js/process.on ...) Hmm I can see that the build compiler doesn't warn about js/process. however the evaluation seems to work just fine when I don't use js/ for process object:
process.version
=> "v10.9.0"
js/process.version
=> "v10.9.0"
> I know its confusing ... Yep! very confusing 🙂 > so basically if you want hot-reload use a build and REPL into that > here is a minimal setup if you want to try Thanks! it's so useful to have this setup. *UPDATE*: The :devtools configs for :before-load-async and :after-load are working for me! Very nice... my workflow is now so much easier with performing some start / stop functions that do some IO (right now for me it's mounting some directory on start and unmounting it on stop, but the same could work for other things like starting up a server and stopping it). I would like to write about this sometime
#2019-04-0614:32thheller@icyiceling184 although process.version works it should be avoided since it won't work in different contexts. if you want to use "global" node variables like process you should use them via js/process.#2019-04-0623:42caleb.macdonaldblackMy shadow-cljs browser project seems to be having some compatibility issues on older versions of safari 7 & 8. Could anyone point me in the right direction as to what I should look into in order to understand more about this? Sorry if this is the wrong channel for this question#2019-04-0705:31orestis@caleb.macdonaldblack see https://github.com/thheller/shadow-cljs/issues/468#issuecomment-480494400 for some polyfill related stuff #2019-04-0705:34caleb.macdonaldblackThanks!#2019-04-0705:32orestisYou might need to look into either polyfills or es3#2019-04-0705:32orestisNot sure if these versions of safari support es5 (they should)#2019-04-0708:29thheller@caleb.macdonaldblack what kind of compatibility issues?#2019-04-0708:29thheller@caleb.macdonaldblack what kind of compatibility issues?#2019-04-0708:45caleb.macdonaldblackWith an older browser. Im not as experienced in dealing with these issues so I was looking for some direction. It looks like a need some polyfills for a number of missing features such as fetch and object.assign in order to work with older versions of safari. Im using https://polyfill.io.#2019-04-0708:47thhellerif you tell me exactly which errors you get I can maybe tell you how to fix them#2019-04-0708:47thhellereg. are the errors occuring in CLJS code or in some imported npm libs?#2019-04-0709:00caleb.macdonaldblackThank you for your help. Although at this point I'm not sure if I need any more help at the moment. Those two issues with fetch and object.assign I was able to resolve with a polyfill. After that I was able to load the app at least. I have more issues with css after which I stopped working on this. I'm going to talk to the project owner tomorrow and discuss whether or not it's worth investing more time in this issue. I'm also not sure if the issue is with cljs or an npm lib as I don't have source maps setup and I was investigating the issue with advanced compilation with http://browserstack.com. However I'm pretty sure it's an npm library though, I'm not doing fetch or object.assign with js interop or anything.#2019-04-0709:01thhelleryeah its probably the npm libs then#2019-04-0709:02thhellerusing something like https://polyfill.io is fine. you could also make shadow-cljs do it but if you have something that works you can just use that#2019-04-0709:03caleb.macdonaldblackIs that done using :prepend as mentioned in the issue that orestis linked?#2019-04-0709:03thhellerno, see my last comment.#2019-04-0709:04thheller> :compiler-options {:rewrite-polyfills true :output-feature-set :es3#2019-04-0709:06caleb.macdonaldblackI did try that, however I had another issue where I used let instead of var directly in the index.html file that I didn't know about at the time so I guess I assumed it wasn't working. I'll remove the polyfill now and give that a try.#2019-04-0709:07thhellerpolyfill detection in npm code is not as reliable as I'd like it to be so it might not work#2019-04-0709:09caleb.macdonaldblackNah that didn't work for me sorry.#2019-04-0709:09caleb.macdonaldblack#2019-04-0709:09caleb.macdonaldblackforgive me sending the screenshot. I'm using a browserStack vm#2019-04-0709:10thhellerok yeah thats a bug then. it is supposed to detect the polyfills properly and Object.assign is definitely one of them#2019-04-0709:11caleb.macdonaldblackI posted my shadow-cljs.edn just to rule out any mistakes I may have made setting those compiler options#2019-04-0709:12thhellerlooks good#2019-04-0709:17caleb.macdonaldblackIf I was to guess I'd say https://github.com/aws-amplify/amplify-js that I use for auth is the library causing my errors. I can see a few instances where they use Object.assign#2019-04-0709:18caleb.macdonaldblackLet me know if there is anything I can do to help you debug this issue or further clarify it's not a mistake on my end#2019-04-0709:30thhellerI'll see if I can figure it out.#2019-04-0709:34caleb.macdonaldblackOh I also had one other polyfill issue with performance.now that I forgot to mention. I didn't find that here though: https://cljs.github.io/api/compiler-options/rewrite-polyfills, so I'm not sure if shadow could help me there#2019-04-0709:35thhelleryeah thats not available as a polyfill (in closure)#2019-04-0709:45thhellerdo the errors happen directly on load or do you need to call something specific first?#2019-04-0723:16caleb.macdonaldblackOn load I believe. I still get the error after omitting the .init() call.#2019-04-0810:06thhellerin 2.8.28 I added a new :js-options {:babel-preset-config {:targets {:safari 7}}} which lets you configure babel to inject certain polyfills into JS code#2019-04-0810:07thhellerso basically this config https://babeljs.io/docs/en/babel-preset-env#options#2019-04-0810:07thhellerthat should take care of all polyfill issues#2019-04-0823:07caleb.macdonaldblackAmazing! Thank you so much#2019-04-1108:08caleb.macdonaldblackSorry I just got around to testing this and I'm still not able to get this to work for me. I've added :js-options {:babel-preset-config {:targets {:safari 7 :ie 11}}} and :compiler-options {:rewrite-polyfills true :output-feature-set :es3} to my shadow-cljs and neither safari 7 nor ie 11 seem to have any polyfills. ie Is missing Promise and safari is missing Object.assign.#2019-04-1108:08caleb.macdonaldblackAnd I've updated shadow-cljs to the new version aswell#2019-04-1108:17thhelleryou shouldn't need the :compiler-options#2019-04-1108:17caleb.macdonaldblackI did try without that also and had the same effect#2019-04-1108:18thhellerhow big is the .shadow-cljs/babel-worker/babel-worker.js file?#2019-04-1108:19caleb.macdonaldblackThere isn't one#2019-04-1108:19caleb.macdonaldblackthere is no babel-worker directory#2019-04-1108:20thhelleroh#2019-04-1108:21thhellerright .. my bad ...babel is only used for ES6+ code in node_modules, so if you only import ES5 code the polyfills won't trigger#2019-04-0709:11caleb.macdonaldblack#2019-04-0715:00mauricio.szaboIs there any reason that newer versions o Shadow-CLJS are not printing the socker REPL port on start, only the nREPL?#2019-04-0715:01thhellerno specific reason other than I wanted to reduce the amount of "spam" at the start#2019-04-0715:01thhellerwould have removed the nrepl message but cider is looking for it still 😞#2019-04-0715:02thhellerif you need to know the port you can either configure a fixed port or look at the .shadow-cljs/socket-repl.port file#2019-04-0715:18mauricio.szaboAh, ok. Also, one more thing: I'm adding tests to a project and I saw the :node-tests target. But somehow, when I import clojure.test or cljs.test, it seems that cljs.test/assert-expr is missing. Is this a known issue?#2019-04-0715:19thhellernot sure how those are related?#2019-04-0715:19mauricio.szaboNo, they are not, sorry 🙂#2019-04-0715:19thhellersounds like you are maybe using cljs.test in clojure?#2019-04-0715:20mauricio.szaboNo, this is a test namespace only for ClojureScript#2019-04-0715:21thhellercan you paste some code?#2019-04-0715:21thhellerand the actual error you get?#2019-04-0715:23mauricio.szabo
(ns paprika.collection-test
  (:require [clojure.test :refer [deftest testing is assert-expr] :include-macros true]
            [paprika.collection :as coll]))
#2019-04-0715:24mauricio.szaboAnd the error:
1 | (ns paprika.collection-test
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.test/assert-expr does not exist
--------------------------------------------------------------------------------
   2 |   (:require [clojure.test :refer [deftest testing is assert-expr] :include-macros true]
   3 |             [paprika.collection :as coll]))
   4 | 
#2019-04-0715:24mauricio.szabocli version: 2.8.26 node: v10.6.0#2019-04-0715:24thhellerwhy do you :refer that?#2019-04-0715:25mauricio.szaboThis library here uses assert-expr to extend clojure.test: https://github.com/nubank/matcher-combinators#2019-04-0715:25mauricio.szaboAnd I was getting this error while trying to use it on shadow-cljs, and then I tried to fix this bug#2019-04-0715:26thhellerit does exist so the error is definitely weird#2019-04-0715:30mauricio.szaboI'll try to test on other targets and if it works, should I open an issue?#2019-04-0715:32thhellerI can reproduce it with any build yes#2019-04-0715:32thhellerlooking into why#2019-04-0715:39thheller@mauricio.szabo that function is only used by macros so it must be implemented in CLJ#2019-04-0715:40thhellercljs/test.cljs exists as well as cljs/test.cljc#2019-04-0715:40thhellerso the CLJS side uses cljs/test.cljs and imports cljs/test.cljc as macros#2019-04-0715:41thhellerso the CLJS side only sees cljs/test.cljs + the macros defined in cljs/test.cljc#2019-04-0715:41thhellersince assert-expr is not a macro its not visible as it wouldn't be usable anyways#2019-04-0715:41thhelleryou can still extend it on the CLJ side of things#2019-04-0715:41thhellerjust not directly in CLJS#2019-04-0715:41thhellerso this is working as expected#2019-04-0715:42thhellergets me every time 😛#2019-04-0717:57mauricio.szaboThanks for the help! #2019-04-0800:10mauricio.szaboOkay, with your help I was able to fix the original library. It does gets me that the library is originally using lein-cljsbuild, and it does compile there. Is shadow-cljs stricter than lein-cljsbuild?#2019-04-0810:02thhellerIIRC nubank had a couple other projects that were written in CLJC but never really used from CLJS#2019-04-0810:03thhellerbut yeah the default cljs compiler is sometimes a little less strict and lets some things pass without verifying#2019-04-0716:15wilkerluciohello, I just did a bump for an old project, and then shadow its failing with this:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.classpath/resource "com/wsscode/pathom/viz/d3-attribute-graph.js"] [:shadow.build.classpath/resource "com/wsscode/pathom/viz/detect-element-size.js"] [:shadow.build.classpath/resource "com/wsscode/pathom/viz/d3-trace.js"]]}
ExceptionInfo: failed to convert sources
	shadow.build.closure/convert-sources*/fn--12072 (closure.clj:1434)
	shadow.build.closure/convert-sources* (closure.clj:1404)
	shadow.build.closure/convert-sources* (closure.clj:1292)
	shadow.build.closure/convert-sources (closure.clj:1621)
	shadow.build.closure/convert-sources (closure.clj:1549)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1016)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1009)
	shadow.build.compiler/compile-all (compiler.clj:1264)
	shadow.build.compiler/compile-all (compiler.clj:1128)
	shadow.build.api/compile-sources (api.clj:252)
	shadow.build.api/compile-sources (api.clj:244)
	shadow.build/compile (build.clj:373)
	shadow.build/compile (build.clj:364)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:293)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:279)
	shadow.cljs.devtools.server.worker.impl/eval14932/fn--14934 (impl.clj:640)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14646/fn--14647/fn--14655 (util.clj:293)
	shadow.cljs.devtools.server.util/server-thread/fn--14646/fn--14647 (util.clj:292)
	shadow.cljs.devtools.server.util/server-thread/fn--14646 (util.clj:265)
	java.lang.Thread.run (Thread.java:748)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

INTERNAL COMPILER ERROR.
Please report this problem.

Unexpected module type: SCRIPT
  Node(NAME d3): com/wsscode/pathom/viz/d3-attribute-graph.js:8:14
  const svg = d3.select(element)
  Parent(GETPROP): com/wsscode/pathom/viz/d3-attribute-graph.js:8:14
  const svg = d3.select(element)

  Node(SCRIPT): com/wsscode/pathom/viz/d3-attribute-graph.js:1:0
import * as d3 from "/node_modules/d3/dist/d3.node.js";
  Parent(ROOT): [source unknown]
you know how to go around that?
#2019-04-0716:17thheller@wilkerlucio what is this orginially? import * as d3 from "/node_modules/d3/dist/d3.node.js"; just import ... from "d3";?#2019-04-0716:17wilkerlucioits: import * as d3 from "d3";#2019-04-0716:18wilkerluciohttps://github.com/wilkerlucio/pathom-viz/blob/index-explorer/src/core/com/wsscode/pathom/viz/d3-trace.js#L1#2019-04-0716:20thhellerthe easy fix is probably not using ESM import/export but rather write it in commonjs#2019-04-0716:20thhellerclosure changed a bunch of stuff recently and I guess has problems with this now#2019-04-0716:20thhellerI'll try to figure out why#2019-04-0716:21wilkerlucioyou mean switch to require and module.exports?#2019-04-0716:21thhelleryeah#2019-04-0716:22thhellerI'm doing something related right now anyways so I'll check out whats happening#2019-04-0716:23wilkerluciothanks, I'll try replacing and see how it goes#2019-04-0716:26thhellerah it might be my incremental compilation#2019-04-0716:27thhelleryeah, found it#2019-04-0716:36thhellerit all works fine when compiling from scratch but incremental compilation is busted#2019-04-0716:36thhellerguess the faking I did to make that work doesn't work anymore 🙂#2019-04-0716:59thheller@wilkerlucio try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "70031811141f075d131c1a0330425e485e4247"}, :content ("[email protected]")}. the entire situation currently is a bit messy since the JS world can't decide how to do ESM->CommonJS interop properly#2019-04-0716:59thhellerkeeps changing constantly#2019-04-0717:07wilkerlucio@thheller awesome, just confirmed it fixed the build :+1:#2019-04-0717:18wilkerlucio@thheller I just got a different problem, this is code is the fulcro inspect, and now chrome is complaining about encoding:
/Development/third-part/fulcro-inspect/shells/chrome
Error
Could not load file 'out/cljs-runtime/goog.i18n.bidi.js' for content script. It isn't UTF-8 encoded
#2019-04-0717:18wilkerluciois that a setting I can change to force utf-8 for everything?#2019-04-0717:21wilkerlucionevermind, seems some transient issue, disabling and reenabling the extension got it back :man-shrugging:#2019-04-0717:30thhellerweird indeed#2019-04-0717:30thhellerit is utf-8 for everything by defualt#2019-04-0720:52wilkerlucio@thheller actually, the problem persists, the extension is not getting loaded, complaining about encoding, i'm working on something else but later I'll get back more to it#2019-04-0720:54thhelleryou can set :compiler-options {:closure-output-charset "ASCII"} but that defaults to utf-8 so no idea why it would complain#2019-04-0720:54thhellerin normal browser things that is fixed by adding the <meta charset="utf-8"> or content-type header#2019-04-0720:55thhellerthings certainly haven't changed in this regard for a very long time#2019-04-0721:17wilkerluciono lucky here, it keeps complaining about that bidi i18n file -.-#2019-04-0721:17wilkerlucioI was already using :compiler-options {:closure-output-charset "US-ASCII"} before#2019-04-0721:17wilkerlucioI tried now removing, using just ASCII, but none worked#2019-04-0721:25wilkerlucioI can confirm it gets back working when I reverted shadow to version 2.7.6#2019-04-0721:25wilkerlucioI can try finding the version that introduced the problem, you think that might be due to some change in closure or maybe cljs?#2019-04-0721:26thhellerit probably isn't the shadow-cljs version, only the bumped closure-compiler version#2019-04-0721:32thheller
$ file out/demo-browser/public/js/cljs-runtime/goog.i18n.bidi.js
out/demo-browser/public/js/cljs-runtime/goog.i18n.bidi.js: UTF-8 Unicode text, with very long lines
#2019-04-0721:32thhellercan you check your file?#2019-04-0721:33thhellerwhen I open the file it does indeed look messed up though#2019-04-0721:33thhellerwonder why#2019-04-0721:34thhellerhmm I found this https://github.com/google/closure-compiler/issues/1704#2019-04-0721:39wilkerlucioI opened here, the file looked fine and in utf-8 🤔#2019-04-0721:39wilkerluciobut now for some reason with the reversed version I'm getting a lot of weird bad things happening...#2019-04-0721:39thheller/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ऀ-῿"#2019-04-0721:39thhellerthis looks broken#2019-04-0721:40wilkerlucioI have that here too#2019-04-0721:40wilkerluciohave you seen something like this? after reverting the version I'm getting all sorts of errors that I never saw before:#2019-04-0721:40wilkerlucio
string.js:58 Uncaught TypeError: Cannot read property 'startsWith' of undefined
    at string.js:58
(anonymous) @ string.js:58
util.js:92 Uncaught TypeError: Cannot read property 'contains' of undefined
    at Object.goog.labs.userAgent.util.matchUserAgent (util.js:92)
    at Object.goog.labs.userAgent.browser.matchOpera_ (browser.js:44)
    at useragent.js:126
goog.labs.userAgent.util.matchUserAgent @ util.js:92
goog.labs.userAgent.browser.matchOpera_ @ browser.js:44
(anonymous) @ useragent.js:126
util.cljs:187 Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
util.js:92 Uncaught TypeError: Cannot read property 'contains' of undefined
    at Object.goog.labs.userAgent.util.matchUserAgent (util.js:92)
    at Object.goog.labs.userAgent.browser.matchChrome_ (browser.js:125)
    at devtools$formatters$available_QMARK_ (formatters.cljs:17)
    at devtools$core$is_feature_available_QMARK_ (core.cljs:17)
    at util.cljs:246
    at Object.devtools$util$install_feature_BANG_ [as install_feature_BANG_] (util.cljs:246)
    at Function.cljs$core$IFn$_invoke$arity$1 (core.cljs:51)
    at Function.cljs$core$IFn$_invoke$arity$0 (core.cljs:44)
    at preload.cljs:11
goog.labs.userAgent.util.matchUserAgent @ util.js:92
goog.labs.userAgent.browser.matchChrome_ @ browser.js:125
devtools$formatters$available_QMARK_ @ formatters.cljs:17
devtools$core$is_feature_available_QMARK_ @ core.cljs:17
(anonymous) @ util.cljs:246
devtools$util$install_feature_BANG_ @ util.cljs:246
(anonymous) @ core.cljs:51
(anonymous) @ core.cljs:44
(anonymous) @ preload.cljs:11
browserevent.js:248 Uncaught TypeError: goog.debug.freeze is not a function
    at browserevent.js:248
(anonymous) @ browserevent.js:248
string.cljs:227 Uncaught TypeError: goog.string.isEmptySafe is not a function
    at Object.clojure$string$blank_QMARK_ [as blank_QMARK_] (string.cljs:227)
    at Object.cljs$spec$alpha$fn_sym [as fn_sym] (alpha.cljs:124)
    at alpha.cljs:154
    at Function.G__50065__1 [as cljs$core$IFn$_invoke$arity$1] (alpha.cljs:154)
    at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:132)
    at Function.cljs$core$IFn$_invoke$arity$1 (alpha.cljs:160)
    at Object.cljs$spec$alpha$with_gen [as with_gen] (alpha.cljs:217)
    at primitives.cljc:497
#2019-04-0721:40wilkerlucioalso its complaining about not finding functions that I'm sure are there#2019-04-0721:41wilkerlucioItried cleaning .shadow-cljs and the outputs, but the problem persist, so weird, I just reverted 😛#2019-04-0721:41thhellerreverted what?#2019-04-0721:42thhellerI found one problem with the output-charset in that it didn't apply in dev builds#2019-04-0721:42wilkerluciothe shadow version, to get the charset working#2019-04-0721:42thhellersetting it to ascii then produces /** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8- which looks better#2019-04-0721:42wilkerlucioI'm trying cleaning the node modules, maybe something got bad there#2019-04-0721:45lilactownI experienced this when I switching between shadow-cljs versions. you have to clean everything#2019-04-0721:45lilactownspecifically between 2.7 and 2.8 which upped the closure version#2019-04-0721:45thhellerwhy is nobody telling me that? 😛#2019-04-0721:46lilactownhaha 😅 sorry, it’s hard sometimes when I’m dealing with stuff at work all day#2019-04-0721:46wilkerlucio@lilactown can you tell me exactly what everything is? I tried cleaning: node_modules, .shadow-cljs and build targets, but doesn't seem to fix#2019-04-0721:47thheller@wilkerlucio try 2.8.28 with :closure-output-charset "US-ASCII". that should now be properly applied everywhere#2019-04-0721:47thhellerpreviously it only applied to release builds#2019-04-0721:48lilactownto fix the startsWith error, I make sure that I clear: - .shadow-cljs - any build output and rebuild. if that doesn’t work, do it a second time 😛#2019-04-0721:49thhellerif you run into this again. PLEASE DO NOT DELETE ANYTHING!#2019-04-0721:49thhellermakes it impossible to figure out what is happening#2019-04-0721:49thhellerdo you still have the broken state?#2019-04-0721:49wilkerlucio@thheller I'm right now with the bad setup going on, I was just updating to try the latest#2019-04-0721:50lilactownmy hypothesis is that it’s diff versions of closure lying around between builds#2019-04-0721:50wilkerluciobut I can stay in the bad one if you wanna look at something#2019-04-0721:50thhelleralright. can you zip up your cljs-runtime dir of that build and send it to me?#2019-04-0721:51thhellerah wait crap its chrome extension#2019-04-0721:51wilkerluciook, let me just try rebuilding and check if the problem persist, not sure what my current output is about#2019-04-0721:51wilkerluciono#2019-04-0721:51wilkerluciothe issue was in a workspaces build#2019-04-0721:51wilkerlucionot on the chrome ones#2019-04-0721:52thhellerthe only real guess I have is that you still have a shadow-cljs instance running#2019-04-0721:52thhellerrunning two processes at the same time causes problems#2019-04-0721:52wilkerluciohumm, I do actually, if they are from different projects they can still mess with each other?#2019-04-0721:52thhellerhmm no thats fine#2019-04-0721:52thhellerjust two processes writing the same output-dir causes problems#2019-04-0721:53wilkerluciomeh, now the problem went away#2019-04-0721:53lilactownmy co-workers and I experienced the startsWith error anytime we switched branches that used diff shadow-cljs versions (one 2.7.x, one 2.8.x)#2019-04-0721:54wilkerlucioI'm bumping to the latest again now to check the encoding thing#2019-04-0721:56wilkerlucioon the first run it get again the bad encoding, cleaning everything up and trying again#2019-04-0721:57wilkerlucio@thheller encoding issue seems to persist in 2.8.28#2019-04-0721:57thhellerdid you try wiping the output dir?#2019-04-0721:57wilkerlucioyes#2019-04-0721:58wilkerluciothe compiled file still includes:
/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ऀ-῿" + "‎Ⰰ-\ud801\ud804-\ud839\ud83c-\udbff" + "豈-﬜︀-﹯﻽-";
/** @private @type {string} */ goog.i18n.bidi.rtlChars_ = "֑-ۯۺ-ࣿ‏\ud802-\ud803\ud83a-\ud83b" + "יִ-﷿ﹰ-ﻼ";
/** @private @type {RegExp} */ goog.i18n.bidi.htmlSkipReg_ = /<[^>]*>|&[^;]+;/g
;
#2019-04-0721:58thhelleryou set :compiler-options {:closure-output-charset "US-ASCII"} and do a clean compile or whatever?#2019-04-0721:58wilkerlucioyup#2019-04-0721:58thhellerthat is definitely not the output produced if US-ASCII is set#2019-04-0721:58wilkerluciorm -rf .shadow-cljs/ shells/chrome/out/ shells/chrome/js/ and then compile#2019-04-0721:58thhellerdid you check that the correct version is used on startup?#2019-04-0721:58wilkerluciorunning one more time:#2019-04-0721:59wilkerlucio
wilkerlucio:fulcro-inspect wilker.lucio$ rm -rf .shadow-cljs/ shells/chrome/out/ shells/chrome/js/
wilkerlucio:fulcro-inspect wilker.lucio$ npm run dev-chrome -- -A:local/pathom:local/pathom-viz

> 
#2019-04-0721:59thhellershadow-cljs - server version: 2.8.28 running at ?#2019-04-0721:59thhellerneed to check the server version. cli version doesn't mean anything really.#2019-04-0721:59thhellerok#2019-04-0722:00wilkerluciosame thing#2019-04-0722:01thhellerhttps://github.com/fulcrologic/fulcro-inspect#2019-04-0722:01thhellerthis is the repo right?#2019-04-0722:01wilkerlucioI'll try again, killing any shadow instance running before doing it again#2019-04-0722:01wilkerlucioyeah, but at master#2019-04-0722:01wilkerlucioand maybe I have uncommited things#2019-04-0722:01wilkerluciolet me check#2019-04-0722:02wilkerluciook, if you go to branch index-explorer now it will be a mirror of what I have#2019-04-0722:02wilkerlucioups, pushing#2019-04-0722:02wilkerluciook, now pushed#2019-04-0722:04thheller
Error building classpath. Could not find artifact com.wsscode:pathom:jar:2.2.13 in central ()
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.wsscode:pathom:jar:2.2.13 in central ()
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:422)
#2019-04-0722:05wilkerlucioups, sorry, a little messy deps at this moment, but you dont actually need this to build I guess, try going 2.2.12 and see if it works#2019-04-0722:06thheller
Error building classpath. Could not find artifact com.wsscode:pathom-viz:jar:1.0.5 in central ()
org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.wsscode:pathom-viz:jar:1.0.5 in central ()
#2019-04-0722:06thheller😛#2019-04-0722:06wilkerluciohahaha, that's why you saw my aliases XD#2019-04-0722:06wilkerluciohumm, maybe we can just try master bumping shadow? those encoding things I believe are not new#2019-04-0722:07thheller
[:chrome-devtool] Build failure:
The required namespace "com.wsscode.pathom.viz.index-explorer" is not available, it was required by "fulcro/inspect/ui_parser.cljs".

[:workspaces] Build failure:
The required namespace "com.wsscode.pathom.viz.index-explorer" is not available, it was required by "fulcro/inspect/ui_parser.cljs".
#2019-04-0722:07wilkerlucioyeah, master should not have index-explorer, that's the new thing I'm working on#2019-04-0722:09thhellerI think I know whats happening. just a sec to confirm#2019-04-0722:11thhellerhmm nope all good#2019-04-0722:14wilkerlucio@thheller just got myself back on that that startsWith issues again#2019-04-0722:15thhellerok please check the cljs-runtime/goog.string.js file? is it empty?
#2019-04-0722:16wilkerluciothere is cljs-runtime/goog.string.string.js, that contains things#2019-04-0722:16thhellerright#2019-04-0722:16thheller/** @private @type {string} */ goog.i18n.bidi.ltrChars_ = "A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0900-\u1fff" + "\u200e\u2c00-\ud801\ud804-\ud839\ud83c-\udbff" + "\uf900-\ufb1c\ufe00-\ufe6f\ufefd-\uffff"#2019-04-0722:16thhellerthis is in the goog.i18n.bidi.js I get when I bump fulcro-inspect master to 2.8.28#2019-04-0722:17wilkerluciofull build with errors: https://www.dropbox.com/s/a02izgbu4zuq31e/workspaces.zip?dl=0#2019-04-0722:17thhellerso US-ASCII is doing what it should?#2019-04-0722:17wilkerluciostrange, just didn't worked for me, it keeps compiling with the utf chars#2019-04-0722:17wilkerlucioI can try to do on master#2019-04-0722:17wilkerluciomaybe something got affected by the new things#2019-04-0722:18wilkerluciolets do this, I'll get myself back to 2.7.6 so I can continue working, because I'm in the middle of trying to release 3 things at once that depend on each other#2019-04-0722:19wilkerlucioonce those are out we can have a simpler way to reproduce the setup#2019-04-0722:19thhelleryeah I'll see if I can figure it out with the files you sent me#2019-04-0722:25thhellerok what the heck#2019-04-0722:27thhellerfor some reason the goog.string.internal ns is just missing#2019-04-0722:29wilkerlucioI just noticed I wasn't cleaning the output folder for the workspaces build#2019-04-0722:29wilkerlucioseems to work fine rebuilding after cleaning that up#2019-04-0722:29thhellerthat would make sense if the main.js is just outdated#2019-04-0722:30thhellersince the goog.string.internal.js file definitely exists. the main.js just isn't loading it#2019-04-0722:30thhellerI can't see how that would happen other than main.js not getting written properly#2019-04-0722:30wilkerluciowhat you think about having a shadow-cljs cleanup command?#2019-04-0722:30wilkerlucioI ask because I found myself frequently missing one or other folder#2019-04-0722:31wilkerlucioshadow could use the build info to delete everything without missing#2019-04-0722:31thhellerI'd rather have it in a place where that is never necessary and the build just does the correct thing#2019-04-0722:31wilkerlucioyeah, just so tempting to have it, hehe#2019-04-0722:32wilkerluciobut I agree, having it will reduces the chance of an actual fix#2019-04-0722:32thhelleryeah but then it ends up like it does in lein where the first question always is did you run lein clean?#2019-04-0722:32thhellerI don't want to get to that point#2019-04-0722:32thhellerI'd rather fix the bugs ...#2019-04-0722:33thhellerI might be dropping some exceptions if the file maybe fails to write?#2019-04-0722:33thhellerI can't see how main.js gets outdated with what is in cljs-runtime since it is written after those files are written#2019-04-0722:33thhellerthat doesn't make sense to me#2019-04-0722:34thhellerits also always getting written. that file is never cached#2019-04-0722:34wilkerlucioconsidering that was a minor version change, which means google closure changes, many of those out of your control, what if we detected the version change and auto-clean when that happens?#2019-04-0722:34thhellerlike I said .. there is nothing to clean#2019-04-0722:35thhellermain.js is always written, blindly .. there is no check if it exists or not#2019-04-0722:35thhellerthe other files check if they exist and are newer than the source#2019-04-0722:35thhellerchanging dependencies ensures that they are written again#2019-04-0722:35wilkerluciohumm, but this seems like some closure dep got missing in the process, as I understand those separated files are still used in the dev runs, irhgt?#2019-04-0722:36thhellerno the file isn't missing#2019-04-0722:36thhellerthe file exists#2019-04-0722:36thhellerit just isn't getting loaded at all#2019-04-0722:36thhellerSHADOW_ENV.load({}, ["goog.debug.error.js","goog.dom.nodetype.js","goog.string.string.js",#2019-04-0722:36thhellerlast line in main.js#2019-04-0722:36thhellerthat is not the correct file order#2019-04-0722:36thhellerit looks outdated#2019-04-0722:37thhellerSHADOW_ENV.load({}, ["goog.debug.error.js","goog.dom.nodetype.js","goog.asserts.asserts.js","goog.reflect.reflect.js","goog.math.long.js","goog.math.integer.js","goog.string.internal.js","goog.string.string.js"#2019-04-0722:37thhellerthis is what I get when I compile#2019-04-0722:37thhellernot the internal.js loading before string.js#2019-04-0722:38thhellerso your main.js just looks outdated. I just don't know how that could happen#2019-04-0722:39wilkerlucioconsidering this is happening when I'm rolling back, maybe it was a bug from that version you already fixed?#2019-04-0722:39thhellernope#2019-04-0722:40thhellerthis is the last time that part of the code changed https://github.com/thheller/shadow-cljs/commit/8ee74c5cf2d88f0236bd6d8be2ba1ceb98d04f3b#2019-04-0722:40thhellerhttps://github.com/thheller/shadow-cljs/blame/64d2c9842329c8f1e72506b12188f0514740ddcd/src/main/shadow/build/targets/browser.clj#L624#2019-04-0722:41thhellerso nothing has changed there for a long time and definitely not since 2.7.x#2019-04-0722:41thhellerthis was 2.3.x era or so#2019-04-0722:42thhellerit also is compiling completely find on my machine (your fulcro-inspect master)#2019-04-0722:42thhellerso I have no clue whats happening#2019-04-0722:43thhellerdo you maybe have the main.js file open in an editor?#2019-04-0722:43thhellershadow-cljs writes the new one, editor overwrites it with the state it has?#2019-04-0722:43wilkerlucioyou think using of local alias deps might be having something to do with it?#2019-04-0722:44wilkerluciono, I don't have that open#2019-04-0722:44wilkerlucioat most maybe intellij is trying to read it in background#2019-04-0722:46thhelleris this running in a container or so? network drive?#2019-04-0722:46thhelleranything weird where things aren't written directly to disk?#2019-04-0722:47wilkerlucionope, no container or anything like that#2019-04-0722:47wilkerluciojust local ssd drive, io issues should be at minimum#2019-04-0722:48thhellerI'm out of ideas. I have never seen this.#2019-04-0722:48thhellerlet me check how spit deals with exceptions#2019-04-0722:49thhellerhmm not at all .. so you should at least be getting an exception if it fails to write#2019-04-0722:51thheller@wilkerlucio does the encoding thing at least work now?#2019-04-0722:51wilkerlucioin 2.7.6 it always had worked for me, I'm sticking to this version for now#2019-04-0722:52thhellerok#2019-04-0722:53wilkerluciothanks for hanging on the debugging#2019-04-0723:01thhellerjust for sanity's sake check if you maybe have an old JVM process lingering on somewhere in the background#2019-04-0723:02thhellerone long forgotten process just working along in the background would explain this behavior#2019-04-0723:12wilkerlucioI did checked for that, but no, I made sure that was no shadow process running before starting the compilation#2019-04-0810:02manuelHi everybody. Is there a way to reference a local project as a dependency in shadow-cljs.edn? Like :local/root does in deps.edn, I mean.#2019-04-0810:03thhelleronly if you use deps.edn#2019-04-0810:04thhelleryou could just add the :source-paths manually too but nothing like :local/root without deps.edn#2019-04-0810:04manuelI see, thank you#2019-04-0814:41hoopesHi, in my shadow-cljs.edn file i have :source-paths [ "dev" "src" "test" ] - in the dev directory, i have company/repl.cljs, and add :repl-init-ns company.repl - when i then load the page, i get a 500 error with the message clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "company/repl.cljs"] {:resource-id [:shadow.build.classpath/resource "company/repl.cljs"]. I've also tried just putting user.cljs in there, but get the same error. Is there something obvious I'm missing? to start the repl, i'm running shadow-cljs cljs-repl my-project-id.#2019-04-0814:43thhellersomething seems off about your error#2019-04-0814:43thheller500 error doesn't make sense?#2019-04-0814:43thhelleryou are running shadow-cljs watch your-build I presume?#2019-04-0814:43hoopesyes sir#2019-04-0814:43thhellerand that completed successfully?#2019-04-0814:44hoopesyes, and that's where the error is being printed, in the watch terminal#2019-04-0814:44hoopes
Apr 08, 2019 10:16:42 AM io.undertow.server.Connectors executeRootHandler
ERROR: UT005071: Undertow request failed HttpServerExchange{ POST /worker/files/sif/4ef2910a-fa9c-4a38-b142-fcbfbc831193/34c60217-4ac5-46a3-b75c-7567c23309ca request {Accept=[*/*], Accept-Language=[en-US,en;q=0.9], Accept-Encoding=[gzip, deflate], Origin=[], User-Agent=[Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36], Connection=[keep-alive], Content-Length=[427], content-type=[application/edn; charset=UTF-8], Referer=[], Host=[]} response {Cache-Control=[private, no-cache]}}
clojure.lang.ExceptionInfo: no output for id: [:shadow.build.classpath/resource "company/repl.cljs"] {:resource-id [:shadow.build.classpath/resource "company/repl.cljs"]}
#2019-04-0814:44thhelleroh. the company.repl namespace probably isn't included by any other means right?#2019-04-0814:44hoopesfull error#2019-04-0814:45thhellertry adding it to :preloads#2019-04-0814:45hoopesah, no - i thought the source-path would somehow imply it was required#2019-04-0814:45thhellerI guess I don't account for :repl-init-ns not being part of the build#2019-04-0814:45thhellerprobably should#2019-04-0814:45thhellerfor now just add it to :devtools {:preloads [company.repl]} for your build#2019-04-0814:47hoopesthat was it, it's working now#2019-04-0814:47hoopesthanks!!!!!#2019-04-0814:47thhellerhttps://github.com/thheller/shadow-cljs/issues/474#2019-04-0814:47hoopesreally appreciate it#2019-04-0814:54mssvery weird error that I’m having trouble debugging. trying to get a bare bones shadow-cljs compilation working with my app via lein. have my :depencencies and :source-paths set in my project.clj and :lein true set at the top level of my shadow-cljs config. receiving the error Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:67:5).. I’ve stripped down everything in my project.clj to be absolutely bare bones with just dependencies and src-paths, yet still encountering this error#2019-04-0814:55mssjust declaring everything in shadow cljs and not using lein works for getting my js built. working with a clj/cljs codebase tho and would prefer to not have to duplicate my dependencies declaration for the different platforms#2019-04-0814:55thhellercheck lein deps :tree#2019-04-0814:56thhellerthere should be a [com.google.javascript/closure-compiler-unshaded "v20190325"] dependency#2019-04-0814:56thhellerif you still have a cljsbuild or figwheel plugin running they might be adding older versions of that dep#2019-04-0814:57mssyep that’s exactly the conflict#2019-04-0816:05StefanThe blog post I wrote about my adventures with shadow-cljs and react native navigation was published today: https://040code.github.io/2019/04/02/react-native-navigation-and-clojurescript/. (Here you are @haiyuan.vinurs.) Thanks again @thheller!!#2019-04-0817:03rastandyhello everyone#2019-04-0817:03thhellerhey#2019-04-0817:03rastandyI’v just started to use shadow-cljs, pretty nice tool, thanks to everyone involved.#2019-04-0817:04rastandyI’m hitting a problem in my project config right now, I’m really stuck trying to understand why it’s not working. My project file looks like this:#2019-04-0817:05rastandy{:source-paths [“src”] :dependencies [[cider/cider-nrepl “0.21.0"]] :builds {:app {:target :node-script :output-to “target/main.js” :main server.main/main! :devtools {:after-load server.main/reload!} :js-options {:resolve {“oauth2" {:target :file :file “/src/js/oauth2.js”}}}}}}#2019-04-0817:06rastandythe problem here is the :js-options keyword, the compiler continues to tell me this:#2019-04-0817:06rastandy[:app] Build failure: Wrong number of args (4) passed to: shadow.build.npm/js-resource-for-file#2019-04-0817:06thhellerwhy are you doing that?#2019-04-0817:07rastandy@thheller good question. Because I wasn’t able to import some functions from a js file I have in my project, so I tried to specify this file in the project config#2019-04-0817:08thhellerso you want to include that file directly in your project? it is not an override for something within node_modules?#2019-04-0817:08rastandyMy import doesn’t work:#2019-04-0817:08rastandy(ns server.google-sheet (:require [“fs” :as fs] [“googleapis” :as g] [“oauth2” :as auth :refer (listFiles oAuth2Client)] [clojure.pprint :as pp] [promesa.core :as p]))#2019-04-0817:08rastandy@thheller no, it’s not an overwrite#2019-04-0817:08thhellerok yeah then you should skip the :resolve config completely#2019-04-0817:09thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-04-0817:09thhellerand just require the file directly#2019-04-0817:09rastandyok, but then importing functions from the js file results in the imported symbols being null#2019-04-0817:10thhellerwhat module format do you use? import/export ESM or require/module.exports commonjs?#2019-04-0817:10thhellerthe .js file that is#2019-04-0817:10rastandythe module.exports flavour#2019-04-0817:10thhellerok that should work fine then?#2019-04-0817:11rastandyI think so, but hey, at least you directed me on the right track again, I was fighting with the wrong configuration settings#2019-04-0817:11lilactown@rastandy try logging auth and see what's in there#2019-04-0817:11thhelleras a quick test make sure the file is on the classpath#2019-04-0817:11rastandyI will check the .js file correctness#2019-04-0817:11thhellerthen fire up shadow-cljs browser-repl#2019-04-0817:12thhellerthen (require '["/path/to/file.js" :as x])#2019-04-0817:12thheller(prn x)#2019-04-0817:15rastandyuhm I’m using cider-connect-cljs, it works but right now it’s not finding the .js file#2019-04-0817:16rastandylet me check again the path#2019-04-0817:16thhellerwith your :source-paths ["src"] and the file at src/js/oauth2.js it would be (require '["/js/oauth2.js" :as x])#2019-04-0817:17thheller(js/console.dir x) is sometimes better than (prn x) so maybe try that too#2019-04-0817:19rastandyI’ve included the js file in my server.main namespace#2019-04-0817:19rastandythe file is loaded from the app and some code is executed, I see the output in the stdout#2019-04-0817:19rastandybut when importing, the ns is null#2019-04-0817:20thhellercan you please test why I asked?#2019-04-0817:20thhellerskip cider or anything else#2019-04-0817:20rastandy(ns server.google-sheet (:require [“fs” :as fs] [“googleapis” :as g] [“./oauth2” :as auth :refer (listFiles oAuth2Client)] [clojure.pprint :as pp] [promesa.core :as p])) (prn auth)#2019-04-0817:20thhellerdon't use prn then#2019-04-0817:20rastandy(prn auth) is null#2019-04-0817:20thhellerand the file actually has exports?#2019-04-0817:20rastandyoh ok, will skip cider#2019-04-0817:21rastandyyes: module.exports = { authorize, listFiles, oAuth2Client };#2019-04-0817:21thhellercan try shadow-cljs node-repl since this is node stuff#2019-04-0817:21rastandyok#2019-04-0817:21thhellerjust want to eliminate all other factors and that is the quickest way to do it#2019-04-0817:25rastandyI’m not able to change namespace in the node-repl 😞#2019-04-0817:25rastandysorry forget that#2019-04-0817:25thhellerdon't change the namespace#2019-04-0817:25thhellerjust require#2019-04-0817:25rastandyit was a typo#2019-04-0817:26thhellerliterally just shadow-cljs node-repl then (require '["/server/oauth2.js" :as x]) (js/console.dir x) nothing else#2019-04-0817:27rastandyyes it loads the file, I can see the output from some statements in the js file#2019-04-0817:27thhellerand what is x?#2019-04-0817:28rastandy#js {:default #js {:authorize #object[Function], :listFiles #object[Function], :oAuth2Client #object[OAuth2Client [object Object]]}}#2019-04-0817:28lilactownlooks like it's loading as esm#2019-04-0817:28thhellerah right ... closure is rewriting it "incorrectly"#2019-04-0817:29thhellerprobably best to just switch the file to use export { authorize, listFiles, oAuth2Client } instead.#2019-04-0817:29rastandyI’m not that into JS modules…#2019-04-0817:29thhellerdoes it matter for this file? is anyone else using it?#2019-04-0817:30rastandyno, only me#2019-04-0817:30thhellerwell that is the quick and easy fix I can offer#2019-04-0817:30thhellerthe other way is [“./oauth2” :default oauth] and then oauth/listFiles etc#2019-04-0817:30rastandyOk, but does that imply something else?#2019-04-0817:31thhellerno doesn't imply anything else#2019-04-0817:31thhellerits just the annoying situation in that the JS world cannot decide on how to do ESM->CommonJS interop#2019-04-0817:31rastandyI made the change in the file: export { authorize, listFiles, oAuth2Client };#2019-04-0817:31thhellerand the closure compiler only supports strict mode currently#2019-04-0817:31rastandynow when requiring the module I get:#2019-04-0817:32thhellerwhich means commonjs files only get a default export#2019-04-0817:32rastandy[:result {:type :repl/error, :ex #error { :cause “closure errors” :data {:tag :shadow.build.closure/errors, :errors [{:resource-name “server/oauth2.js”, :source-name “server/oauth2.js”, :line 93, :column 0, :msg “A file cannot be both a CommonJS module and an ES6 module.“}]}#2019-04-0817:32thhellerdid you remove the module.exports?#2019-04-0817:32thhellercan't have both#2019-04-0817:32thhelleror whatever else is in line 93#2019-04-0817:32rastandyyes#2019-04-0817:33rastandyline 93 is this:#2019-04-0817:33rastandyexport { authorize, listFiles, oAuth2Client };#2019-04-0817:33thhellerand is there a require or exports or module.exports reference before that?#2019-04-0817:33thhellerclosure already decided to treat that file as commonjs before it gets to line 93#2019-04-0817:33rastandygosh! Yes there are requires at the top of the file, sorry#2019-04-0817:34rastandyI’m pretty lost in JS modules land#2019-04-0817:34thhellerhmm hang on ...#2019-04-0817:35thhellersomething odd is happening here#2019-04-0817:36thhellerbecause commonjs files on the classpath that have require should not be rewritten by closure#2019-04-0817:36thhellerwhich version are you on?#2019-04-0817:38rastandyshadow-cljs - config: /Users/arusso/Development/clojurescript/ask-scopus/shadow-cljs.edn cli version: 2.8.26 node: v11.13.0 shadow-cljs - server version: 2.8.26 running at http://localhost:9630#2019-04-0817:38thhellerhmm#2019-04-0817:39thhelleralright there seems to be a bug#2019-04-0817:39thhellerwhere node targets are treated differently than browser one#2019-04-0817:40rastandysorry @thheller maybe it’s better to report with complete files#2019-04-0817:40thhellerI have the issue reproduced now so its fine#2019-04-0817:40rastandyah ok#2019-04-0817:54joshkhtotally new to shadow-cljs but i'm excited to start building some node modules! when following the shadow-cljs repo's readme and also with the minimal-shadow-cljs-browser i get the following error in the browser:
bidi.js:276 Uncaught SyntaxError: Invalid regular expression: /[Ö‘-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class
    at new RegExp (<anonymous>)
    at bidi.js:276
any ideas? 🙂
#2019-04-0817:55thhellerinvalid charset used in the HTML#2019-04-0817:55thhelleradd <meta charset="utf-8"> to your html#2019-04-0817:56joshkhheyo, that did the trick. thanks!#2019-04-0817:58joshkhnext question. the repo's readme refers to :node-script as a build target where as the docs refer to :node-library. which one am i after?#2019-04-0817:59thhellerdepends on what you want to build?#2019-04-0818:00joshkhah, they're different. got it. i was hoping to play around with cljs and aws nodejs lambdas.#2019-04-0818:00thhellerfor that you want :node-library#2019-04-0818:01rastandy@thheller thank you very much for you rhelp#2019-04-0818:02joshkhgreat, thanks! really looking forward to all the great things i've heard about shadow-cljs.#2019-04-0818:03thheller@rastandy I just pushed 2.8.29 that fixes the broken commonjs interop. so it should be working correctly now, no need for :default#2019-04-0903:04mauricio.szaboAh, that was a bug? I'll upgrade too#2019-04-0818:04thhellermight need to undo the changes if you switched to :default#2019-04-0818:04thhellerif you switched to import/export that is fine#2019-04-0818:05thheller@joshkh there was a post about shadow-cljs + aws here https://dev.to/royalaid/cljs-s-lambda-697#2019-04-0818:05thhellermaybe that helps#2019-04-0818:13rastandy@thheller thank you very much! I’ll confirm if it’s working, thank you again#2019-04-0819:37joshkh> maybe that helps immensely. thanks for sharing!#2019-04-0820:56eoliphantquick question, I’m trying to figure out the best way to handle a ‘lib’ project. Say I have a project with some common fulcro components and it uses a few react libs, then I want to pull it in to my main ui app, via say clojure deps. I guess I’d need to the main app’s package json also include any of the lib projects npm dependencies?#2019-04-0820:58thhelleryou can include a deps.cljs file with {:npm-deps {"whatever" "version"}} in the lib#2019-04-0821:16Daniel HinesI may just be misunderstanding things, but it seems like when I run shadow-cljs watch app, and open my browser, then connect via a CIDER repl, that there are two distinct contexts. For example, I have an atom defined with defonce - in the browser, it has one value, but at the REPL, it ahs another. Is there a way to unify these two contexts?#2019-04-0904:55richiardiandreaThe atom should be contain the same because you are eval-ing code in the same runtime...unless your REPL and your Chrome tools are talking to different runtimes like Thomas suggested.#2019-04-0821:19thhellerdo you open the correct REPL?#2019-04-0821:20thhellerI don't know much about cider sorry but shadow-cljs cljs-repl app would give you the REPL into the browser#2019-04-0821:21thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cider dunno how current this is#2019-04-0822:01eoliphantAh ok cool#2019-04-0909:18manuelWith latest shadow-cljs (`2.8.29`), I am getting this on shadow-cljs watch:
/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:3497                                                                                                                            
!0,Hg.Ya="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717",Hg.Hb=function(b){return Vb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717")};return new Hg(a,oe)$
function Oi(a){try{var b=a[0];return b.l?b.l(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].qb(null),b;throw c;}}function Pi(a,b){b=Hi(b,Ni(function(c){a[2]=c;a[1]=4;return Oi(a)}));return z(b)?(
a[2]=H(b),a[1]=4,vh):null}                                                                                                                                                                                           
                                                                                                                                                                                                                     
                                                                                               ^                                                                                                                     
                                                                                                                                                                                                                     
TypeError: Invalid value used as weak map key                                                                                                                                                                        
    at WeakMap.set (native)                                                                                                                                                                                          
    at d (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1790:192)                                                                                                             
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:282                                                                                                                 
    at Array.map (<anonymous>)                                                                                                                                                                                       
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1795:259                                                                                                                 
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1700:229                                                                                                                 
    at presets (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1794:267)                                                                                                       
    at z (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1826:376)                                                                                                             
    at /home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1825:87                                                                                                                  
    at e.buildRootChain (/home/manuel/7bridges/code/cinvat-explorer/.shadow-cljs/babel-worker/babel-worker.js:1830:93) 
#2019-04-0909:19thhellerwhat the heck is that 😛#2019-04-0909:19manuel😄#2019-04-0909:20manuelstill trying to figure it out#2019-04-0909:23thhellerI updated the babel stuff to the "new" babel7#2019-04-0909:23thhellerbut the used API is kinda tiny so not a clue#2019-04-0909:23thhellerprobably doesn't like something you do in the code?#2019-04-0909:24thhellerdoes it tell you which file it failed to convert? it should?#2019-04-0909:25manuelno worries. I trashed the node_modules directory in the root of my project and re-installed the dependencies I need via npm. It works just fine as usual now. Sorry for the noise.#2019-04-0911:45ouvasamHi, does someone can get airbnb react-dates(latest version) work with reagent ?#2019-04-0912:19thheller@ouvasam the general way should work? (:require ["react-dates" :as rd]) then in reagent [:> rd/Thing {:foo "bar"} ...]#2019-04-0912:22ouvasamHi @thheller, no i can't make it work. It ssems that something change from version 13 and it use react-with-styles I did already try sometimes ago but went with another lib, but i really want to be able to use it.#2019-04-0912:22ouvasam"As of v13.0.0 of react-dates, this project relies on react-with-styles. If you want to continue using CSS stylesheets and classes, there is a little bit of extra set-up required to get things going. As such, you need to import react-dates/initialize to set up class names on our components. This import should go at the top of your application as you won't be able to import any react-dates components without it."#2019-04-0912:23ouvasam#2019-04-0912:24thhellerand what does that produce?#2019-04-0912:24thhellerlooks correct to me?#2019-04-0912:25ouvasamSomething like this but it doesn't open selector or nothing#2019-04-0912:25ouvasam#2019-04-0912:27thhellerthat looks like css is missing?#2019-04-0912:28thhellermaybe it is opening just not anywhere visible because of missing styles?#2019-04-0912:31ouvasamNormally css should be included via import 'react-dates/lib/css/_datepicker.css'; But i included it in the html with a link tag. When focusing on a field the dom should change, but it is not the case for me#2019-04-0912:33thhellerwell in your example you have hardcoded :start-date and :end-date?#2019-04-0912:51ouvasamYes but nothing change even if i use r/atom#2019-04-0912:51thhellerdo the callbacks trigger?#2019-04-0912:52thheller:on-dates-change #(println "on date change")?#2019-04-0913:02ouvasamThe handler is never called since i cannot change the date#2019-04-0913:05thhellerthe handler is the thing changing the date so it should be called?#2019-04-0914:04lilactownusing the :chrome-extension target, I’m not sure how to setup my background script#2019-04-0914:05lilactownmy build config:
{:target :chrome-extension
   :extension-dir "extension"
   :manifest-file "extension/manifest.edn"
   :outputs
   {:devtools {:output-type :chrome/shared
               :init-fn punk.ui.chrome.devtools/init!}
    :background {:output-type :chrome/shared
               :init-fn punk.ui.chrome.background/init!}
    :panel {:output-type :chrome/shared
            :init-fn punk.ui.chrome.panel/init!}
    }}
#2019-04-0914:05lilactownrelevant manifest.edn:
:background {:persistent false
              :scripts ["out/background.js"]}
#2019-04-0914:06lilactownah. I need the bg-shared#2019-04-0914:06thheller:background {:output-type :chrome/background#2019-04-0914:06lilactownoo fancy#2019-04-0914:08lilactownare there docs for :chrome-extension yet?#2019-04-0914:08thhellerno#2019-04-0914:17lilactownOK I see my script loaded in the background page, but I don’t see any output#2019-04-0914:18lilactownex I currently have this in my background ns:
(defn init! []
  (log "bg init"))
#2019-04-0914:18lilactownbuild config is now:
:background {:output-type :chrome/background
                 :init-fn punk.ui.chrome.background/init!}
#2019-04-0914:18thhellerIIRC log output from background page is in the original devtools#2019-04-0914:19thhellernot the nested ones#2019-04-0914:19thhelleror the other way .. its weird#2019-04-0914:19lilactowno_O#2019-04-0914:19lilactownI have 3 devtools open lol#2019-04-0914:19thhellermight need to open the background page#2019-04-0914:19thhellerI can't remember really#2019-04-0914:20lilactownyeah, I have the background page open (I think)#2019-04-0914:23lilactownbackground page console is empty#2019-04-0914:24lilactownmy devtools page is where all my REPL output seems to go#2019-04-0914:25lilactown#2019-04-0914:28lilactownand the console for the page I’m inspecting is blank#2019-04-0914:30lilactowndoes :type :chrome/background take an :init-fn or something else?#2019-04-0914:30lilactownI don’t actually see my namespace even loaded#2019-04-0914:31thhellermaybe only supports :entries not actually sure#2019-04-0914:31thhellerits been a while since I worked on that#2019-04-0914:31lilactowndo I need to include any of the other .js files like shared.js or bg-shared.js?#2019-04-0914:31thhelleryou don't include either?#2019-04-0914:32lilactownfor the background script, I’m just include background.js atm#2019-04-0914:32thhelleryou have html for your background page? shouldn't have?#2019-04-0914:32lilactownchrome docs say I can just give it a JS file and I think it generates an HTML page for me#2019-04-0914:33lilactown
:background {:persistent false
              :scripts ["out/background.js"]}
#2019-04-0914:33thhelleruhm wait you have your own manifest?#2019-04-0914:33thhellerright .. don't do scripts#2019-04-0914:33lilactown☝️ that’s what I wrote in my manifest.edn#2019-04-0914:33thhellerjust leave that out completely#2019-04-0914:34lilactownk, trying#2019-04-0914:34thheller:chrome/background takes care of it#2019-04-0914:34lilactownhmm, lots of errors now#2019-04-0914:35lilactown#2019-04-0914:35thhellersorry I don't have time to look at that further now#2019-04-0914:35lilactownnp#2019-04-0914:36thhellerdig into the shadow/build/targets/chrome-extension.clj file#2019-04-0914:36thhellermaybe that makes sense and you can figure it out#2019-04-0914:37lilactownFWIW I restarted my shadow-cljs process. I’m now getting errors about websockets. it looks like the background page is trying to connect to the shadow-cljs process#2019-04-0914:38lilactownah no, it’s still the old errors preventing it. nvm. I’ll dig into it#2019-04-0914:48thhellersee https://github.com/fulcrologic/fulcro-inspect/blob/master/shells/chrome/manifest.edn#L11-L18#2019-04-0914:50lilactownsigh. I’m sorry thheller. I cleared out my .shadow-cljs and it started working 😞
#2019-04-1219:39mauricio.szaboSometimes I have the same problem too, but I'm still not able to reproduce it in a consistent way...#2019-04-0914:58thhellerthat should absolutely NEVER be necessary#2019-04-0914:58thhellerif it is its a bug#2019-04-0914:59thhellerI really need to figure out why is happening for you guys .. I have never had a problem where deleting anything was necessary#2019-04-0914:59lilactownthe next time I see the startsWith error, I’ll zip up my builds folder and send it your way#2019-04-0914:59thhellerI already identified that problem with the code Wilker sent me, just can't explain how it happens#2019-04-0915:00lilactownyeah super strange. I thought it had something to do with switching between diff versions of the closure library#2019-04-0915:00lilactownsince it was occurring so frequently when we would switch between branches with different shadow-cljs versions#2019-04-0915:01thhelleryes that would cause such a problem but the file that triggers the bad behavior should be written correctly always#2019-04-0915:01lilactownbut in this project, I’ve only ever used latest shadow-cljs. I was modifying shadow-cljs.edn and the manifest.edn, and my new background page exhibited the same behavior#2019-04-0915:02thhelleryeah dunno .. can't concentrate on this now .. gotta fix other work stuff#2019-04-0915:02lilactown:+1:#2019-04-0915:46mssis there any way to change the CLOSURE_BASE_PATH output by a browser compilation? I’d like it to output a relative path but it’s prepending a /, making it an absolute path and breaking dep resolution#2019-04-0915:48thhellerset :asset-path in your config#2019-04-0919:36lilactownfor some reason, in my background script i have a namespace that won’t load unless I trigger it to compile that namespace#2019-04-0919:37lilactownit loads in my :browser target fine#2019-04-0919:37lilactown
(ns punk.ui.encode
  (:require [cljs.reader :as reader]))

(defn write [x]
  (prn-str x))

(defn read [x]
  (reader/read-string x))
#2019-04-0919:41thhellersounds like the other issue again. please check the background.js#2019-04-0919:41thhellerthere should be some load instructions#2019-04-0919:41thhellerit might be missing that file?#2019-04-0919:47lilactownhm. right off hand, I don’t see the load instructions#2019-04-0919:47lilactownanything I can CTRL-F for?#2019-04-0919:47thhellerpunk.ui.encode#2019-04-0919:47lilactownthat’s definitely not anywhere in background.js#2019-04-0919:48thhellerah no wait .. nvm#2019-04-0919:48lilactownbut I don’t see any other load instructions so I might be looking in the wrong place#2019-04-0919:48thhellerit is using chrome for loading#2019-04-0919:48thhellerneed to reload the chrome ext probably#2019-04-0919:48lilactownahhh#2019-04-0919:48thhellersince the manifest changed#2019-04-0919:49lilactownso I’ll need to do that anytime I add a new ns?#2019-04-0919:49thhellercurrently yes#2019-04-0919:49lilactown:+1:#2019-04-0923:43Daniel HinesCan someone translate to a noob what this means and what I should do instead?
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/d4hines/repos/rectangles/src/rectangles/view.cljs:14:20
--------------------------------------------------------------------------------
  11 | (prn fps-div)
  12 | (add-watch fps :fps
  13 |            (fn [k r o n]
  14 |              (set! (.-innerHtml fps-div (str "<p>" n "<p>")))))
--------------------------^-----------------------------------------------------
Error in phase :compilation
dot prop access with args
{:form (. fps-div -innerHtml (str "<p>" n "<p>"))}
ExceptionInfo: dot prop access with args
#2019-04-0923:47MnoI have no idea, but my best guess would be it doesn’t like you passing arguments when trying to access the innerHtml?#2019-04-0923:48Mnomaybe possibly it’s like this (set! (.-innerHtml fps-div) (str "<p>" n "<p>"))#2019-04-0923:49Daniel Hines(def fps-div (. js/document -getElementById "fps"))#2019-04-0923:49Daniel HinesAlso fails the same way.#2019-04-0923:50Mno🤔#2019-04-0923:51Mnomaybe (def fps-div (.getElementById js/document "fps"))#2019-04-0923:53MnoIIRC the .-something was to access a property, and method calls were just (.whatever whatever-you’re-calling-it-on arguments)#2019-04-0923:54MnoI found this on stack overflow, it seems like what you’re trying to attempt. :man-shrugging: I dunno.#2019-04-0923:55lilactown@d4hines that’s invalid syntax#2019-04-0923:55lilactownwhat Mno is saying is correct#2019-04-0923:56MnoI’m giving myself a gold star #2019-04-0923:57Daniel HinesAha! Thanks guys.#2019-04-0923:58lilactownyour first example would be (. fps-div innerHtml (str “<p>” n “<p>”)) for proper syntax. but also, I’m not sure you can call node.innerHtml as a function?#2019-04-1000:08wilkerlucio@d4hines you could also use (gobj/set (.getElementById js/document "fps") "innerHtml" (str "<p>" n "<p>"))#2019-04-1000:08wilkerluciogobj => goog.object#2019-04-1000:09Daniel HinesThanks!#2019-04-1008:55thheller@lilactown @wilkerlucio can you confirm that .shadow-cljs is a git ignored directory in your projects? just a guess but maybe git messes with the .shadow-cljs dir when switching branches? probably not but who knows 😛#2019-04-1011:01wilkerlucio@thheller yup, its confirmed, and in my case I wasn't switching branches, just the shadow-cljs version#2019-04-1012:39rastandyhello @thheller, I’m sorry to bother you again but my js file importing adventure is not finished yet#2019-04-1012:40rastandynow it seems that everything works if I call functions from the js file that do not depends on imported modules#2019-04-1012:41rastandybut when I use a more complex function with external dependencies the compiler complains like in this case:#2019-04-1012:41rastandynode target/main.js SHADOW import error /Users/arusso/Development/clojurescript/ask-scopus/.shadow-cljs/builds/app/dev/out/cljs-runtime/server.google_sheet.js /Users/arusso/Development/clojurescript/ask-scopus/.shadow-cljs/builds/app/dev/out/cljs-runtime/server/oauth2.js:17 fs.readFile(‘credentials.json’, (err, content) => { ^ TypeError: fs.readFile is not a function at Object.readFile [as auth_init] (/Users/arusso/Development/clojurescript/ask-scopus/.shadow-cljs/builds/app/dev/out/cljs-runtime/server/oauth2.js:17:5) at /Users/arusso/Development/clojurescript/ask-scopus/.shadow-cljs/builds/app/dev/out/cljs-runtime/server/google_sheet.cljs:8:1 at global.SHADOW_IMPORT (/Users/arusso/Development/clojurescript/ask-scopus/target/main.js:64:44) at /Users/arusso/Development/clojurescript/ask-scopus/target/main.js:2195:1 at Object.<anonymous> (/Users/arusso/Development/clojurescript/ask-scopus/target/main.js:2199:3) at Module._compile (internal/modules/cjs/loader.js:805:30)#2019-04-1012:42rastandyobviously I have the const fs = require(‘fs’); in the js file#2019-04-1012:44rastandyand the [“./oauth2” :as auth] in the clojurescript namespace. In fact an dependency-free hello-world function from the js file is correctly imported and called from the CLJS namespace.#2019-04-1012:53thheller@rastandy and what is console.log(fs) in the oauth2.js file?#2019-04-1012:55rastandy@thheller well, it’s {}#2019-04-1012:56rastandybut if I call “node src/oauth2.js” it works#2019-04-1012:56thhellerthat doesn't mean anything#2019-04-1012:58thhellerthe commonjs support is sketchy#2019-04-1012:58rastandy@thheller I mean that the import is correct in the js file#2019-04-1012:58rastandy@thheller so you suggested me to use another module system?#2019-04-1012:58thhelleryes but that is irrelevant. shadow-cljs just fails to rewrite the require properly#2019-04-1012:59rastandy@thheller ok#2019-04-1012:59thhellerESM support should be a bit better yes#2019-04-1012:59thhellerI can see about the commonjs require later, busy with other stuff currently#2019-04-1013:00rastandy@thheller can you point me to some docs to convert my js file to ESM and import it correctly in CLJS? Sorry I’m pretty ignorant in JavaScript modules land#2019-04-1013:00thhellerjust plain ESM, nothing special regarding CLJS#2019-04-1013:00thhellerand no I don't have a guide handy.#2019-04-1013:00rastandy@thheller I can only thank you for your help and support, thank you very much!#2019-04-1013:01rastandy@thheller I’ll find one, many thanks#2019-04-1013:10rastandy@thheller great! Converting in ESM module everything works! Many, many thanks.#2019-04-1014:46Francescohello, I am struggling with shadow-cljs and hope you could help me (or point me somewhere), is there any way to run browsers tests (or karma test) in watch mode? (to be more explicit, re-run affected tests only whenever something changes in the code/tests)#2019-04-1014:47thhellerthats what :browser-test does?#2019-04-1014:48thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test#2019-04-1015:04Francescowell, actually yes. I am really sorry for the stupid question but your answer really helped me, thanks 🙂#2019-04-1017:35lilactownrandom question: does shadow-cljs send the form that was evaluated to the browser when you evaluate at the REPL?#2019-04-1017:36thhellerI think the source is included, not the form#2019-04-1018:15Daniel Hines> source is included, not the form What does that mean? Aren’t they equivalent?#2019-04-1018:15thheller"(foo)" vs (foo) (an actual list with foo symbol)#2019-04-1018:16Daniel HinesOh, gotcha. So source = string, form = data.#2019-04-1018:22tomcI'm converting a figwheel-based project to shadow-cljs and finding that compilation w/ shadow-cljs fails on reagent's with-let macro, complaining that the vars referenced in the output of that macro are undeclared. Any possible causes come to mind?#2019-04-1018:23thhellerancient version of reagent?#2019-04-1018:24tomc0.8.1, I think that's the latest stable (checking now...)#2019-04-1018:24tomcyeah that's the latest#2019-04-1018:24thhellerthat should be fine I think#2019-04-1018:25thhellerhttps://github.com/reagent-project/reagent/issues/420#2019-04-1018:25thhellermaybe its not released yet?#2019-04-1018:27tomcwith-let has been in reagent for several releases now - it seems to me that the macro is evaluating just fine but the code it's outputting includes references to vars shadow-cljs doesn't know about for whatever reason. I'm also seeing warnings about "provide conflicts" due to re-frame and some others putting compiled assets in their jars - think it's possible that's related?#2019-04-1018:29thhelleryeah thats probably not helping#2019-04-1018:29thhellerwhat kind of warnings do you get?#2019-04-1018:30tomcPretty sure it's the same situation you talked about here: https://github.com/thheller/shadow-cljs/issues/473, ignoring the stuff about that person's macros + ns problems.#2019-04-1018:31tomcActually, some of the complaints are about goog libs, so maybe I have something else going on. For example: [2019-04-10 14:30:26.531 - WARNING] provide conflict for #{goog.labs.userAgent.engine} provided by goog/labs/useragent/engine.js and {"/out/goog/labs/useragent/engine.js" #{goog.labs.userAgent.engine}}#2019-04-1018:32thhelleryeah if compiled code is on the classpath that causes issues#2019-04-1018:32thhellerthings in public/* are already filtered#2019-04-1018:32thhellerdo you also have out/*?#2019-04-1018:35tomcI do not have an out, just target, which I've been rm -rfing after the failed builds to make a clean slate. There are other possible complications w/ my build setup. I'm using lein for my deps + source-paths because some of my deps are stored in a private s3 bucket. My shadow-cljs config file is pretty simple though: {:lein {:profile "+dev-client"} :builds {:app {:output-dir "target/admin/client/public/js/compiled/" :asset-path "/" :target :browser :modules {:main {:entries [kc.admin.user]}} }}}#2019-04-1018:35thheller...#2019-04-1018:35thhellerI mean in the error messge#2019-04-1018:35thhellerI need to know your actual errors to help. not errors someone else had.#2019-04-1018:36thheller> [2019-04-10 14:30:26.531 - WARNING] provide conflict for #{goog.labs.userAgent.engine} provided by goog/labs/useragent/engine.js and {"/out/goog/labs/useragent/engine.js" #{goog.labs.userAgent.engine}}#2019-04-1018:36thhellerthis means there was an "unexpected" source file in /out/goog/labs/useragent/engine.js on the classpath, which can be in a jar. doesn't need to be one of YOUR paths#2019-04-1018:38tomcOk, I will look for something on the classpath containing the offending files. Thanks for the help.#2019-04-1018:39thhellerrun shadow-cljs clj-repl then ( "the/path/it-reports-in-the-error")#2019-04-1018:39thhellerthat'll tell you where its coming from (might need to strip the leading /)#2019-04-1018:47tomcYeah, that did it, thanks. Turns out the culprit was that same re-frame-utils lib from that issue. I didn't even realize it was in my project.clj. 🙃#2019-04-1018:50tomcI see the manual has a "what to do when things don't work" section that basically just says "ask on slack". Would you be interested in a PR describing this issue and its resolution in that section?#2019-04-1018:51thhellerI'd rather make the classpath filter smarter so people don't run into it anymore 😉#2019-04-1018:52thhellerhttps://github.com/thheller/shadow-cljs/issues/477#2019-04-1018:53tomc👍#2019-04-1018:53tomcThanks again#2019-04-1107:13caleb.macdonaldblackI'm not sure what I'm doing wrong here. I'm trying to get the latest version of shadow-cljs running. I've replicated the issue in docker so I think I can rule out my local environment being misconfigured. It works with the previous version I was using which is 2.4.24. Here is a repo with a minimal configuration where I still get the issue: https://github.com/CalebMacdonaldBlack/shadow-cljs-issue-2.8.29#2019-04-1107:13caleb.macdonaldblackHere is a stack trace of the issue I get#2019-04-1107:13thhellerthat is a version conflict on the closure-compiler#2019-04-1107:14thhellerand a bad clojurescript version as well#2019-04-1107:14thhellerthats why I don't recommend using lein ...#2019-04-1107:15caleb.macdonaldblackI'm using lein because I'm using cursive. What ide do you use?#2019-04-1107:15thhellerit should be clojurescript [org.clojure/clojurescript "1.10.520"]#2019-04-1107:15thhellerand
[com.google.javascript/closure-compiler-unshaded "v20190325"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
#2019-04-1107:15thhellerI use Cursive.#2019-04-1107:16thhellershadow-cljs pom and import pom.xml to create project#2019-04-1107:16thhelleryou can use lein just fine ... just need to deal with the dependency conflicts yourself#2019-04-1107:31caleb.macdonaldblackOkay that is really cool. I was only using lein because I didn't think there was any other way to resolve the project. But importing as a maven project with pom.xml worked perfectly. So I was able to remove project.clj and move deps to shadow-cljs.edn. I then removed clojure and clojurescript dependencies from the deps and I don't need the closure compiler stuff either.#2019-04-1107:31caleb.macdonaldblackAlso adding that stuff to lein worked as well#2019-04-1107:32caleb.macdonaldblackbut definitely better to ditch lein altogether#2019-04-1107:33caleb.macdonaldblack@thheller What do you recommend for managing deps for a standard clojure project without cljs? Would I manually write a pom.xml to do this?#2019-04-1107:33caleb.macdonaldblackOr perhaps continue using lein for clj projects?#2019-04-1107:34thhellerI use lein for everything that has CLJ things#2019-04-1107:34thhellerto make Cursive happy in CLJ+CLJS projects I add a dummy profile where I copy me cljs deps#2019-04-1107:35thhellerbut don't actually use that profile and just use shadow-cljs.edn for the CLJS parts#2019-04-1107:35thhellerjust need to make cursive aware of the extra deps somehow#2019-04-1107:35thhellerbut I never run CLJS compiles through lein (other than the shadow-cljs project itself where I kinda have to)#2019-04-1107:37caleb.macdonaldblackOkay thanks again. I really appreciate your help.#2019-04-1114:10danierouxhi all, I'm stumped on getting a socket-repl running with shadow. :socket-repl {:port 9000} does not seem to be it.#2019-04-1114:12thhellerthats it?#2019-04-1114:12thhelleryou can check the .shadow-cljs/socket-repl.port file to see the port the socket repl is opened on#2019-04-1114:12thhellerdefaults to random but with that config it should be 9000#2019-04-1114:14danierouxshadow-cljs node-repl app does not create that file, or open a socket repl. What am I missing?#2019-04-1114:14danieroux(I am building a node app, not a browser one)#2019-04-1114:17thhellernode-repl does not take a build argument. it just starts a generic node repl.#2019-04-1114:18thhellerbut it should start the socket-repl regardless#2019-04-1114:18thhellerdoes it say "connected to server" on startup?#2019-04-1114:21thhellerjust tested on a fresh npx create-cljs-project foo-test cd foo-test configure :socket-repl {:port 9000} in shadow-cljs.edn and then npx shadow-cljs node-repl#2019-04-1114:21thhellerworks fine and as expected#2019-04-1114:23thheller(if you are going to connect remotely anyways you could use shadow-cljs server instead)#2019-04-1114:40danierouxshadow-cljs server gives:
shadow-cljs - server version: 2.8.29 running at 
shadow-cljs - nREPL server started on port 59717
#2019-04-1114:41thhellerok. then your socket repl should be ready while that is running#2019-04-1114:41thheller(and there should be a .shadow-cljs/socket-repl.port file to verify that)#2019-04-1114:52danierouxAh, got it now. I expected a "Socket Repl" message. And I had the socket-repl option on the :app level 😕#2019-04-1114:52danierouxThank you @thheller!#2019-04-1117:28sakalliis there a getting started tutorial or sample conf for a basic node backend app to start playing around with limited clojure(script) knowledge? (using cider)#2019-04-1118:08claudiuhttps://github.com/lambdaisland/npmdemo/tree/master/shadow-cljs or https://github.com/minimal-xyz/minimal-shadow-cljs-nodejs#2019-04-1118:10claudiuNot much to it. https://shadow-cljs.github.io/docs/UsersGuide.html#target-node would also recommend https://github.com/funcool/promesa and https://github.com/appliedsciencestudio/js-interop libs if you plan on a lot of js interop#2019-04-1118:13sakallithanks @U3LP7DWPR will look at those!#2019-04-1120:48lilactownusing :chrome-extension, can I build a content script without it showing up in manifest.json?#2019-04-1120:49lilactownI’m trying to inject it programmatically, but shadow-cljs plugs it into the manifest causing Chrome to complain it’s missing certain fields#2019-04-1120:50thheller:chrome/content-inject not :chrome/content-script probably?#2019-04-1120:51thhelleror just :chrome/single-file#2019-04-1122:38lilactowncool! thx#2019-04-1215:38firstclassfuncHey all, working on a node application that requires exporting methods from defrecord I am using the ^:export tag on the method, but I can’t seem to resolve it through :exports in shadow-cljs.edn any clues?#2019-04-1215:45lilactownyou can't export methods on a defrecord#2019-04-1215:45lilactownyou should create a wrapper function and export that#2019-04-1215:52firstclassfunc@lilactown In advanced compilation you can
 but I guess I am left to creating factory functions for now..
#2019-04-1215:53lilactownhm, I've never seen that tbh#2019-04-1217:08firstclassfuncactually did get this to work. I was calling the method in the deftype definition when I needed to require it from the defprotocol definition#2019-04-1220:20mauricio.szaboJust a feedback: yesterday I started a toy project in Clojure. I've missed multiple things that are shadow-specific, like the ability to control reloads of code, the hooks after compiling, the watch of files and auto-run tests. So thanks to change my perception of ClojureScript from a clumsy language to one that I really like to use 🙂#2019-04-1220:48cobyAgreed, the hot-module reloading with the REPL integration is world-class. 🙂 Re: auto-run tests, you might be interested in lein-test-refresh https://github.com/jakemcc/lein-test-refresh#2019-04-1301:24talgiatHi there, I’m looking for a way to use shadow-cljs to recompile sass files, I’ve looked into the build hooks but not sure if that can be done. Figwheel has similar capabilities via writing a custom script, and I thought you can do it using a hook, but seems like watching the sass source folder in watch mode doesn’t invoke the compile-prepare stage with the sass files that were changed. I know you can run some other watcher, but I believe one of the goals of shadow-cljs is to reduce the number of build tools and processes running, so it’ll be nice to find a way to do that.#2019-04-1308:48thheller@talgiat there is a very basic "plugin" feature that I started working one quite a while ago. I isn't documented since I'm still not sure I want to go with that route so I wouldn't make any guarantees that it stays the way it is but you could definitely build all kinds of things with that#2019-04-1308:48thhellerit works like this https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L17#2019-04-1308:49thheller:plugins just takes a vector of symbols#2019-04-1308:49thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/dummy_plugin.clj#2019-04-1308:50thhellerso that points to demo.dummy-plugin/plugin which is just a map#2019-04-1308:51thheller:start should be a function. :stop should be a function that will be called with whatever :start returned when the server shuts down#2019-04-1308:51thhellerso for example you could start a sass process in :start, return the process handle and kill it in :stop#2019-04-1308:52thhellerI haven't explored this further but in theory this is enough#2019-04-1308:52thheller:build-hooks are indeed not a good fit for something like sass since sass compilation is independent of CLJS#2019-04-1311:33orestis@talgiat I’ve done this by wrapping kickstarting the shadow CLJS build processes from my own code. I could share something come Monday. #2019-04-1312:26thhellerthere is also stuff like run-p from npm. https://github.com/mysticatea/npm-run-all/blob/HEAD/docs/run-p.md#2019-04-1314:53talgiatthanks @thheller is there an option to watch some folder with shadow (same way that the build works), so I can watch the sass folder and run sassc command on file chagnes? I saw watch under worker.clj but not sure if that’s something too internal to use. @orestis a code sample would be great#2019-04-1314:55orestis@talgiat I basically just use the hawk library (shadow already depends on it) to run sass-clj#2019-04-1314:55thheller@talgiat there is something yeah. shadow.cljs.devtools.server.fs-watch#2019-04-1314:55thheller
(fs-watch/start
  {}
  [(io/file "some" "dir")]
  ["scss"]
  (fn [updates]
    (prn [:scss-updates updates])
    ))
#2019-04-1314:55talgiatok, yeah was just looking at that#2019-04-1314:56thhellerfirst {} is config, which you don't really need#2019-04-1314:56thhellersecond [...] is an array or java file instances (eg. via )#2019-04-1314:56thheller["scss"] is the file extensions to watch#2019-04-1314:56talgiatgreat, so I can start that in the plugin#2019-04-1314:57thhelleryes. but make sure to (fs-watch/stop what-start-returned) also#2019-04-1314:57talgiatyeah, for sure#2019-04-1314:57talgiatit’s like figwheel with component start and stop lifecycle#2019-04-1314:58thhelleryeah kind of#2019-04-1319:49mauricio.szaboHow do I get a CLJS repl using node-test target? When I try to connect to a REPL, I'm getting "No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code."#2019-04-1319:50thhellerthat is not supported. tests are supposed to run once and exit (since we need the exit code)#2019-04-1319:51thhelleryou can however just shadow-cljs node-repl (require 'your.ns) (your.ns/the-test)#2019-04-1319:51thhellerthat will run a test#2019-04-1319:52thhelleror use the cljs.test methods to run them (eg. (cljs.test/run-tests) for all#2019-04-1319:54mauricio.szaboOh, I think the documentation must be outdated: it say "The node process exit code will not be returned when using :autorun", so I though I could use it to run a REPL#2019-04-1319:55thhellerno that is accurate. you just misunderstand what :autorun does#2019-04-1319:56thheller:autorun executes the tests the a watch build completes. the node process running the tests will still exit. the shadow-cljs process however continues.#2019-04-1319:56thhellerso there is no "exit code" in that sense#2019-04-1319:56thhellernothing you could use in a meaningful sense#2019-04-1319:57mauricio.szaboWhat's the preferred way to develop code targeting Node.JS? Right now I'm using two targets, one to autorun tests and one to compile the project. Is there another way you recommend?#2019-04-1319:57thhellerdocs could probably explain that in more detail but the work the node process does remains the same#2019-04-1319:58thhellerthat is up to you. I tend to do it the same way I do CLJ development ... using the REPL#2019-04-1319:59thheller:node-script targets I usually run with :devtools {:enabled false} since I want them to exit when they "complete"#2019-04-1319:59thhellerotherwise the websocket for the devtools keeps everything running#2019-04-1320:02mauricio.szaboYes, I do use the same way, but in Clojure mode I require a test namespace even when none of my "main" namespace doesn't require it. On CLJS, this is not really possible, so that's why I'm using another target#2019-04-1320:02thhellerI don't understand what you mean#2019-04-1320:04mauricio.szaboFor example, when I use :node-script I need a :mainfunction - my tests namespaces are not included on the :main namespace#2019-04-1320:04mauricio.szaboSo when I save a test file, it doesn't get compiled...#2019-04-1320:04thhelleryes but what does that have to do with anything?#2019-04-1320:04mauricio.szaboand in Clojure mode I can force a "require" and run it by the REPL#2019-04-1320:05thhellerwell you could use :devtools {:preloads [your.test-ns]}#2019-04-1320:05thhelleryou can do that repl require in CLJS too?#2019-04-1320:07mauricio.szaboI think I missed the documentation part about :preloads. Great to know! I'll check it. Thanks 🙂#2019-04-1320:07thhellerwell it isn't exactly meant for tests but you can abuse it for that#2019-04-1320:12mauricio.szaboI'll check out and post if it works for me. Thanks again 🙂#2019-04-1320:15lilactown@mauricio.szabo what stops you from running (require 'your.test-ns) at the REPL?#2019-04-1320:17lilactownFWIW I keep the devtools on because most of my :node-scripts are servers#2019-04-1320:22mauricio.szaboIn my experience this tends to confuse reloads. Maybe newer versions have fixed this issue though... I'll probably need to revisit my workflow :)#2019-04-1320:24lilactownyou will probably have to (require 'your.test-ns :reload) again if you make changes#2019-04-1416:52talgiat@thheller thanks for all the tips, got it working with the plugin. One thing I noticed is that I get multiple calls to shutdown with the plugin, not sure why. Another question is can I pass arguments to the plugin from the build config? It also seems the the plugins are set globally and not per build.#2019-04-1417:24thheller@talgiat yes plugins are once per server. you can change :depends-on to :depends-on [:config] and :start (fn [config] ...)#2019-04-1417:24thhellerconfig is the shadow-cljs.edn content#2019-04-1417:24thhellerso you can add your own keys there#2019-04-1417:24thheller:sass/config {:foo :bar} or so#2019-04-1417:27thhellerplugins can in theory access all server functionality and hook into anything. just none of it is documented. 😛#2019-04-1418:31lilactowntrying to use latest devcards, I get an error:
The required namespace "cljsjs.marked" is not available, it was required by "devcards/util/markdown.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  fo more information.
I’m guessing this is devcards not specifying this correctly in deps.cljs. any work arounds?
#2019-04-1418:36talgiat@thheller thanks! I guess it’s semi documented, because I can read the source code 😁. Few other questions: so does the plugin knows which build is currently running? is it called before any build is invoked (just trying to understand the lifecycle of the whole build system and the point where plugins are called). Also did you run into cases where a plugin shutdown is called multiple times before?#2019-04-1418:50talgiatAnother question: can build hooks get access to the full shadow-cljs.edn content and not just the build state? (I guess I can use shadow.cljs.devtools.config/load-cljs-edn, but thought there might be something else)#2019-04-1419:32thheller@lilactown https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-04-1419:33thheller@talgiat build specific stuff should probably be in the build config which is at :shadow.build/config in the build state (passed into the hooks)#2019-04-1419:34thhellerplugin is started when the runtime is started. so in server-mode once. stop should only be called when the runtime is shutdown#2019-04-1419:35talgiatI need the sass/config to be visible to the plugin and for a hook#2019-04-1419:35talgiatThat’s why I’m asking #2019-04-1419:37thhellerin the build hook you can get access to the full runtime via (shadow.cljs.devtools.server.runtime/get-instance!)#2019-04-1419:38thhellerthats a map that'll contain a :your.plugin-ns/plugin key#2019-04-1419:38thhellerwhich is the whatever was returned by :start#2019-04-1420:18Nolanhello, i am following this gh issue: https://github.com/thheller/shadow-cljs/issues/250#2019-04-1420:18Nolani have created a ~/.shadow-cljs/config.edn file with the following contents#2019-04-1420:18Nolan
{:proxy
 {:host "localhost"
  :port 8099}}
#2019-04-1420:18Nolanthat is the proxy configuration i use for everything#2019-04-1420:19Nolanhowever shadow-cljs still fails to resolve the dependencies#2019-04-1420:19Nolanany help is appreciated#2019-04-1420:19thhellerdoes it work if you move the config into the shadow-cljs.edn? I changed how the global config is handled so that might not be working anymore?#2019-04-1420:20Nolani will try, please hold on#2019-04-1420:22Nolanyes, that worked#2019-04-1420:22Nolanthanks theller#2019-04-1420:22Nolanalthough it is a bit unsatisfactory to have to commit my proxy configuration?#2019-04-1420:23thhellerhttps://github.com/thheller/shadow-cljs/issues/483#2019-04-1420:24Nolangreat, glad ur so active!#2019-04-1420:24thhellershould fix it soon. maybe a bit later. doing other stuff right now.#2019-04-1423:11Daniel LeongI'm interested in playing with shadow-cljs for a node module I'm working on, but I'm having trouble getting started with the repl. I've set the build :target to :npm-module and :runtime to :node, but after shadow-cljs watch lib and shadow-cljs node-repl I still get "No application has connected to the REPL server" when I try to evaluate forms over cider from Vim#2019-04-1423:14Daniel LeongI imagine at some point there will be a bin component to it that I can set as :main and run, but primarily I want to architect this as a library, and hope to have the normal clojure repl experience evaluating forms and executing tests.#2019-04-1423:14Daniel LeongAm I missing something?#2019-04-1423:15thhelleryes 😛#2019-04-1423:15thhellershadow-cljs watch lib and node-repl are completely unrelated#2019-04-1423:16thhellerif you want to REPL into teh` lib` build YOU need to launch a node process that loads the compiled code#2019-04-1423:16thheller:main is not a thing for :npm-module#2019-04-1423:16thhellerwhat are you building?#2019-04-1423:17thhellera CLI script? a library?#2019-04-1423:17Daniel LeongIs require('./dist/whatever.core' not sufficient to load the compiled code?#2019-04-1423:17thhellerit is .. but for :npm-module its a bit trickier#2019-04-1423:17Daniel LeongIt’s a library that might also have a CLI mode if installed globally#2019-04-1423:17Daniel Leongeventually#2019-04-1423:17thhellerso you probably want to use :node-library instead#2019-04-1423:18thhellerOR in the .js files you do the require in you also require("./dist/shadow.cljs.devtools.client.node")#2019-04-1423:18thhellerthis is taken care of by :node-library but must be done manually for :npm-module#2019-04-1423:19Daniel LeongOooh I see. I missed the part where it said :npm-module is intended to be part of the project#2019-04-1423:20thhellerdocs are a bit outdated and incomplete#2019-04-1423:23thhellerif you want a normal clojure REPL experience just forget about build configs completely for now#2019-04-1423:23thhellerand just shadow-cljs node-repl#2019-04-1423:24thhellerand just use the :node-repl build id when selecting a REPL instead of :lib#2019-04-1423:24thheller(assuming cider/vim supports that)#2019-04-1423:24Daniel LeongAha okay, interesting#2019-04-1423:24thhellerbut that is as close as you'll get to "clojure REPL"#2019-04-1423:25Daniel LeongI was able to connect to node with :node-library but I’ll also give the :node-repl thing a shot#2019-04-1423:25thheller(meaning it won't watch source files at all, or hot reload anything ever)#2019-04-1423:25Daniel LeongGotcha#2019-04-1423:25Daniel LeongThanks for your help!#2019-04-1510:54MarcinHeya, I have a problem using react-swipeable-views with shadow-cljs. When I go with yarn add react-swipeable-views it fails on the app start, giving me could not find module-entry: @babel/runtime/helpers/builtin/interopRequireDefault - most probably because that’s ES6 module. @thheller any clue on this one? I don’t want to use cljsjs lib for that.#2019-04-1513:26ClashTheBunnyES6 modules have not been supported in the past, has that changed recently?#2019-04-1514:29thheller@piczmar.rss that is most likely caused by a dependecy conflict. es6 modules are supported just fine.#2019-04-1514:30thhellercheck the dependencies in node_modules/react-swipeable-view/package.json#2019-04-1514:30thheller@babel/runtime and which one is installed in node_modules/@babel/runtime/package.json#2019-04-1514:31thheller@clashthebunny ES6 modules have been supported for a long time#2019-04-1514:34thheller@marcinszyszko I think its just the usual npm nonsense. the file node_modules/@babel/runtime/helpers/builtin/interopRequireDefault.js does not exist#2019-04-1514:34thhellernode_modules/@babel/runtime/helpers/interopRequireDefault.js does, so just without the builtin path. guess the path changed somewhere#2019-04-1514:36thhellergotta love npm 😉#2019-04-1521:41MarcinThanks! Cleaning it up actually solved the issue 🙂#2019-04-1514:56maxp@thheller could you help me with one thing that I did not understand well I'd like to build single :node-script that could be run without node_modules. I set {:js-provider :closure} but how to resolve built-in nodejs modules? like "fs" or "crypto"?#2019-04-1514:57thheller@maxp that is currently experimental. see https://github.com/thheller/shadow-cljs/issues/290#2019-04-1514:57thheller :js-options {:js-provider :shadow :keep-native-requires true} is what you need#2019-04-1514:58talgiatis there something like lein-ancient for shadow-cljs to check the project dependancies need to be updated?#2019-04-1514:59thhellercurrently no#2019-04-1515:09maxp@thheller thank you very much. But I had to install bufferutil and utf-8-validate - that stuff used in try { require(...) } ... no workaround here?
#2019-04-1515:09thhellerhmm?#2019-04-1515:09thhellernot sure what you mean?#2019-04-1515:15maxpthere is such code in node_modeuls/ws/lib/BufferUtil.js `try { const bufferUtil = require('bufferutil'); module.exports = Object.assign({ concat }, bufferUtil.BufferUtil || bufferUtil); } catch (e) / istanbul ignore next / {#2019-04-1515:16thhellerdo you use the ws package?#2019-04-1515:17thhelleroh right during development .. you probably want to add :keep-as-require #{"ws"} for development#2019-04-1515:17thhellersince that won't be in release builds#2019-04-1515:17thhellerstill need to add that automatically#2019-04-1515:17maxpnot me, it installed in dependencies. as I understand. may be clj-http required it#2019-04-1515:17thhellerits shadow-cljs assuming you are using watch or compile?#2019-04-1515:19maxpI use shadow-cljs watch and shadow-cljs server#2019-04-1515:19thhelleryeah just add :keep-as-require #{"ws"} then you should be fine#2019-04-1515:31maxpGreat! it Works!#2019-04-1515:33maxp@thheller could you please explain to me how to add plain javascript file to the project build (not npm module).#2019-04-1515:33thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-04-1515:34maxpthank you#2019-04-1515:34thhellerif you can write the file in ES6 syntax though#2019-04-1515:34thhellercommonjs has some issues#2019-04-1515:34thhellerso import/export vs require#2019-04-1516:12maxpif some one interested in building 'single executable js' there is working example - https://github.com/maxp/rss2tlg#2019-04-1516:43talgiat@thheller I’m trying to run shadow with lein profiles, but running into problems. When you use lien with profiles do I need to add shadow in lein dependencies? also even if I do that I still run into issues.#2019-04-1516:44thhellerthats a dependency conflict on the closure-compiler dep#2019-04-1516:44thhellerthe way lein deals with dependency conflicts is by picking whatever comes first#2019-04-1516:45thhellerso if anything has a dependency on clojurescript and thus closure-compiler it'll be picked#2019-04-1516:45thhellereven if shadow-cljs depends on newer versions#2019-04-1516:45thhellerso you need to resolve those conflicts#2019-04-1516:46thhellershould be fixed by adding these deps
[org.clojure/clojurescript "1.10.520"]
[com.google.javascript/closure-compiler-unshaded "v20190325"]
[org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
#2019-04-1516:47thhellerif you run through shadow-cljs.edn that is taken care of automatically#2019-04-1516:47talgiatI’m not running the lein command, I’m running shadow-cljs just using lein with a profile to pull dependencies and paths (it’s really just for dependencies)#2019-04-1516:49thhellerthen you are using the lein command#2019-04-1516:49thhelleror rather shadow-cljs is running it#2019-04-1516:50thhellerwhen you use :lein ... in shadow-cljs.edn the JVM is launched using lein#2019-04-1516:50thhellerso all its quirks apply#2019-04-1516:51talgiatI see, yeah seem to be working now#2019-04-1516:52talgiatThe documentation says: “When executing directly via lein you must manually include the thheller/shadow-cljs artifact in your :dependencies. This is automatically added when launching via shadow-cljs.”#2019-04-1516:52talgiatbut I’m not doing that, so I found it a bit confusing that I needed to include shadow in the lien dependencies#2019-04-1516:53thhellerI'm also confused what you are doing exactly 😛#2019-04-1516:53talgiatSince we’re using lein ancient to check for updates, I didn’t want to rewrite it for shadow#2019-04-1516:53talgiatalso we still use lein to build the server side code#2019-04-1516:54talgiatSo I thought I’d just put the client deps in the lein profile and pull them from there with shadow lein config#2019-04-1516:54thhellerso you are using :lein {:profiles ["foo"]} in your config?#2019-04-1516:54talgiatnope#2019-04-1516:54talgiat:lein {:profile “client”}#2019-04-1516:55thheller:profile is not a thing#2019-04-1516:55talgiatwhat?#2019-04-1516:55thhellerwell regardless. IF :lein is a true-ish thing in shadow-cljs.edn#2019-04-1516:56talgiat{:lein {:profile “+cljs”}#2019-04-1516:56thhellernvm. I thinking of deps.edn#2019-04-1516:56talgiatthat’s from the doc#2019-04-1516:56thhelleryeah .. sorry got confused for sec#2019-04-1516:56thhellerso :lein {:profile "+cljs"} means that when you run shadow-cljs watch thing#2019-04-1516:56talgiatyeah#2019-04-1516:56thhellerit'll execute lein run -m shadow.cljs.devtools.cli watch thing#2019-04-1516:56thhellerbasically#2019-04-1516:56talgiatyeah#2019-04-1516:57talgiatI saw that#2019-04-1516:57talgiatbut you need shadow in the lein dependencies for that#2019-04-1516:57thhellerbut it'll also run update-in [:dependencies] conj shadow-cljs or whatever the exact thing is#2019-04-1516:57thhellerso no you do not need to add shadow-cljs#2019-04-1516:57talgiatoh#2019-04-1516:57thhellerIF you run through shadow-cljs#2019-04-1516:58thhellerif you use lein normally it is better to add the shadow-cljs dependency manually#2019-04-1516:58talgiatI still get: java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class,#2019-04-1516:58talgiatI ran: shadow-cljs compile app#2019-04-1516:59talgiatwatch is the same#2019-04-1516:59thhellerwhich lein version do you have?#2019-04-1516:59talgiatgood question#2019-04-1516:59talgiat2.7.1#2019-04-1517:00thhellerhmm just add the shadow-cljs dependency#2019-04-1517:00thhellerthe inject might not work and isn't really all that reliable anyways#2019-04-1517:00thhellerI'll check later#2019-04-1517:00talgiatOk thanks#2019-04-1517:01thhellerhttps://github.com/thheller/shadow-cljs/issues/485#2019-04-1517:06talgiatIt all works when you add the dependancy#2019-04-1517:07talgiatMight be good to think about plugin architecture so we can build stuff like lein ancient and the likes#2019-04-1517:07thhellerno need for plugins#2019-04-1517:07talgiatAs far as I understand plugin at the moment are just for watch process#2019-04-1517:07thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-04-1517:08thhellershadow-cljs run some.lib/ancient#2019-04-1517:08thhellerplugins are for things that need access to the runtime#2019-04-1517:08thhellerancient wouldn't need that at all#2019-04-1517:09thhellerI'm going to build that eventually#2019-04-1517:09thhellertime is a factor there 😉#2019-04-1517:09thhellerit isn't much code to write that ... just something not high on my priority list#2019-04-1517:09talgiatright#2019-04-1517:10talgiatwell it’s not really a plugin, just need access to shadow-cljs to read the dependencies key#2019-04-1517:10talgiatit’s really just a slurp of a file#2019-04-1517:10talgiatsince it’s edn#2019-04-1517:10thhellerwell you can just (slurp "shadow-cljs.edn") and get :depdendencies yeah#2019-04-1517:10talgiatjust didn’t want to rerwrite the whole ancient code again#2019-04-1517:10talgiatOr copy it 🙂#2019-04-1517:11talgiatGot actual features to deliver!#2019-04-1517:23talgiatAnother question, does devtools from one build target impact the other?#2019-04-1517:24talgiatI have http-port and http-root in test build target but it seem to apply also when I watch app build target#2019-04-1517:26thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-04-1517:26thhellerstill supported in :devtools but yes they are all always started#2019-04-1517:27thhellersince otherwise the HTTP server wouldn't be available if you used shadow-cljs compile foo while the server instance is running#2019-04-1517:27thhellerI changed the config to make that more apparent#2019-04-1517:58talgiat@thheller got it. Thanks for being super responsive, the clojure community needs more people like you.#2019-04-1518:57martinklepschThe Clojure community also needs more people who allow people like Thomas to spend more time on their projects 🙂 https://www.patreon.com/thheller#2019-04-1520:00MnoWell I’ve tried googling but it wasn’t particularly helpful#2019-04-1520:01MnoAnybody know what to do when the (I’m guessing closure) compiler returns something like
Closure compilation failed with 1 errors
--- node_modules/vega-lite/build/vega-lite.js:8535
This code cannot be converted from ES6. extending native class: Array
#2019-04-1520:03MnoI was trying to use Oz, and I think I was managing to install the (cljsjs) dependencies correctly (npm install vega-lite and then creating the namespace (
(ns cljsjs.vega-lite
  (:require ["vega-lite" :as vega-lite]))

(js/goog.exportSymbol "VegaLite" vega-lite)
), I’m not sure where to start.
#2019-04-1520:08thheller@hobosarefriends maybe :compiler-options {:output-feature-set :es6} fixes it?#2019-04-1520:08thhellerif you can live with es6 output that is#2019-04-1520:12Mnooh I tried :js-options {:language-out :ecmascript6}#2019-04-1520:12MnoI’ll give this one a whirl#2019-04-1520:13thheller@hobosarefriends try :output-feature-set instead, should be more reliable#2019-04-1520:15Mnookidoke trying that.#2019-04-1520:16MnoWell now I have another different issue, so I guess that worked#2019-04-1520:16MnoThanks mate.#2019-04-1522:45MnoIs there a way to require a specific version of an npm package? (according to the package-lock I do seem to have both versions) in the namespace? (like :require ["#2019-04-1607:29thheller@hobosarefriends just install that specific version via npm?#2019-04-1609:00briemensI wrote some code in shadow-cljs that I want to extract into a reusable library. What is the best way to go about? The code/lib will only be consumed from clojurescript/shadow-cljs itself. I prefer not to compile to a node-library or npm-module which requires explicit exports. Should I bundle it as a jar instead or just symlink the code? Thanks!#2019-04-1609:06thhelleryou mean you want to package it as a CLJS library?#2019-04-1609:06briemensThat sounds about right 🙂#2019-04-1609:07thhellerI currently recommend lein for that since shadow-cljs doesn't have anything built-in for that yet#2019-04-1609:07thhelleror you just use deps.edn with :local/root#2019-04-1609:08thhellerreally up to you if you want to push it to clojars or not#2019-04-1609:09briemensaha, thanks for the tip/hint. At least I read the docs properly 😉#2019-04-1609:09briemensI have some boiler plate stuff that I want to reuse. So cljs import/export would be awesome#2019-04-1609:11thhellerby far the easiest method is probably just using the :source-paths directly#2019-04-1609:11thhellerso :source-paths ["src/main" "../other-lib/src/main"]#2019-04-1609:11briemensI will try that. That's probably all I need for now#2019-04-1609:12briemensThanks @thheller!#2019-04-1609:12thhellerthis is good if you want to use deps.edn https://clojure.org/guides/deps_and_cli#_using_local_libraries#2019-04-1609:13briemensSo I just create a deps.edn file next to shadow-cljs.edn#2019-04-1609:13thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2019-04-1609:16briemens:man-bowing: Thank you! I have something to dig into.#2019-04-1612:26MnoWell I have more than 1 version installed because reasons#2019-04-1613:09wonko7Hi all! I know this is a stupid question, but my keywords are failing me for a google search: const parse = require('csv-parse/lib/sync') how does this translate as a :require ?#2019-04-1613:26kszabohttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages See react-virtualized example#2019-04-1613:44wonko7thanks, got it 🙂#2019-04-1613:19wonko7I expected this to work: (:require [csv-parse :as csv]) ... (def parse-csv (-> csv .-lib .-sync)) but .-lib is undefined#2019-04-1614:53hoopesso i don't have hard data to back this up yet, but i seem to need to use shift-reload to get markup changes recently. I'll be happy to try to build a simple repro case, but was wondering if anyone had the same issue before i do?#2019-04-1614:54hoopesi'm using chrome, and the js console is telling me it's reloading the appropriate modules#2019-04-1615:18lilactownyou might not have the correct reload hooks setup?#2019-04-1615:19lilactownare you re-rendering your app on reload?#2019-04-1615:26hoopesyeah, it was working - i think i had shadow 2.7.17 ? just upgraded#2019-04-1615:27hoopesi will try to put together a simple proof app - i could totally be doing something stupid, but just wanted to see if that was a known issue.#2019-04-1615:28hoopesit happened to a couple people on my team recently, is why i was asking. but we're all working on the same app, so could def be a code problem#2019-04-1615:29lilactownI had a number issues after we upgraded to 2.7.x to 2.8.x due to the closure library update. I had to clear my build output and cache#2019-04-1615:29lilactownI’ll let @thheller comment because I think if there is an issue, he might want to peek at your .shadow-cljs folder so hold off on deleting that 😬#2019-04-1615:44thhellerI'm gonna need more details ... actual errors with stacktraces or so#2019-04-1615:44thhellerhard to guess "random" errors#2019-04-1615:45Nolanis there a particular way to invoke shadow-cljs from npm/`node` without a global installation? e.g. in some directory where i’ve just npm install’d with a package that declares shadow-cljs as a dependency. running shadow-cljs ... is showing shadow-cljs: command not found#2019-04-1615:46Nolanbut i see the bin key in package.json, which makes me think that should work#2019-04-1615:46thhellerno package should ever have a dependency on shadow-cljs?#2019-04-1615:46thhellernpx shadow-cljs should work#2019-04-1615:47thhellershadow-cljs should always be in devDependencies though#2019-04-1615:47Nolanright, sorry, it is a devDependency. apologies#2019-04-1615:48NolanI’ll try with npx, i think thats probably what I’m looking for#2019-04-1615:48thhellerFWIW even with a global install it will always use the version installed in the project itself#2019-04-1615:52Nolanright, that I do know. I’ve just been wading into building a project as part of a remote pipeline, and theres no global installation there, so the build.sh was failing. Didn’t want to redundantly install it globally. I feel pretty good about the npx addition, I think that’s the secret sauce.#2019-04-1615:53Nolanwill know soon. Thanks a million again @thheller#2019-04-1615:53thhelleryou can just call the ./node_modules/.bin/shadow-cljs directly too#2019-04-1615:54thhellerbut thats sort an implementation detail of npm so probably best to stick with npx#2019-04-1615:56Nolanagreed, but thats good to know#2019-04-1615:59Nolannpx was just the stuff. Huge appreciation for you @thheller!#2019-04-1616:36hoopes@thheller fwiw, there are no errors - everythign looks just like it should, except i need a shift-reload to get markup changes to show up - i'll build the repro app (if i can). otherwise, if nothing off the top of your head, don't worry about it. thanks.#2019-04-1616:36thheller> get markup changes to show up -#2019-04-1616:36thhellerwhat does that mean?#2019-04-1616:37thhellerI have no context for what you are doing#2019-04-1616:37thhellerI'm guessing react? reagent? re-frame?#2019-04-1616:38thhellershift-reload? do you use the built-in dev-http servers? otherwise caching might be an issue? active service-worker?#2019-04-1616:38thhellertooo many factors#2019-04-1616:51hoopesyeah, sorry - using re-frame, changing some prop on a div (for instance), and it doesn't auto-show-up#2019-04-1616:51hoopesthe js console says it's reloading the module, but the DOM doesn't refresh#2019-04-1616:52hoopesignore me until i have something useful to tell you#2019-04-1616:52thhellerreloading the code doesn't do anything to your DOM#2019-04-1616:52thhelleryou need a :dev/after-load hook to trigger a re-render#2019-04-1616:53thhellerif you are doing that you might need to also clear the re-frame subscription cache in that hook#2019-04-1616:53hoopesok, will try it out. thanks very much!#2019-04-1619:18thheller@lilactown do you have a function/macro in hx that will just return a react element?#2019-04-1619:19thhellerah hx/f right?#2019-04-1619:21lilactownyeah. (hx.react/f [:div "asdf"])#2019-04-1619:22lilactownthe whole lib was supposed to be a clever setup for hxf = "hiccup transform" 😅 kinda got lost along the way#2019-04-1619:24thhellerI'm running some benchmarks of cljs react wrappers since I wanted to compare my new one 😉#2019-04-1619:24dpsutton@lilactown was the f function one you wanted to rename recently?#2019-04-1619:25thheller
react x 3,449,728 ops/sec ±2.64% (93 runs sampled)
reagent x 398,044 ops/sec ±1.78% (93 runs sampled)
shadow x 1,851,920 ops/sec ±3.58% (94 runs sampled)
hx x 50,539 ops/sec ±1.04% (89 runs sampled)
#2019-04-1619:25thhellerhow come hx is so slow? 😛#2019-04-1619:25lilactown@dpsutton no#2019-04-1619:27dpsuttonjust wondering since you mentioned the original intent got lost#2019-04-1619:30lilactownit’s a fair guess 😄 but this is what I want to rename: https://github.com/Lokeh/hx/pull/46#2019-04-1619:26lilactown😂 I’ve literally never benchmarked it. not surprised it’s slow#2019-04-1619:26lilactownthe hiccup parser is super naive#2019-04-1619:27lilactownwould you send me the benchmark you created at some point?#2019-04-1619:27lilactownI’d really like a starting point to start tuning hx#2019-04-1619:28thhellerhttps://gist.github.com/thheller/106db0c13c221be3793b481f7a4eb8bc#2019-04-1619:28thhellerjust trying to render something simple that you may have in an app#2019-04-1619:30thhellerjust wanted to get a baseline. mine is faster than react when running without NODE_ENV=production 😛#2019-04-1619:32thhellergetting sucked into the benchmark hole again ...#2019-04-1619:49lilactownhm yeah. it’s going to take awhile to tease out why hx is so slow#2019-04-1619:49lilactownthe hiccup parsing does kind of a lot. lots of little corner cases it’s taking care of right now…#2019-04-1620:14lilactownis shadow.grove.react macro-based?#2019-04-1620:14thhelleryes. can't get that fast with interpreted vectors#2019-04-1620:15lilactownyeah.#2019-04-1620:16thheller
react x 284,902 ops/sec ±0.31% (97 runs sampled)
reagent x 173,311 ops/sec ±1.83% (93 runs sampled)
shadow x 269,805 ops/sec ±1.73% (94 runs sampled)
hx x 42,893 ops/sec ±1.29% (91 runs sampled)
rum x 244,721 ops/sec ±0.58% (96 runs sampled)
#2019-04-1620:16thhellerrum is doing pretty good too#2019-04-1620:16lilactownisn't rum also macro-based?#2019-04-1620:16thhelleryes#2019-04-1620:17thhellerwell in my trivial example it is, it also has an interpreted fallback. unsure how often that kicks in though#2019-04-1620:18lilactownyeah. I think my goal for hx would be at least as fast as reagent 😛#2019-04-1620:18thhelleryeah it seems rather slow right now#2019-04-1620:18lilactownI think that reagent does some caching behind the scenes#2019-04-1620:19thhellercould be. I'm surprised how fast it actually is#2019-04-1620:19lilactownthere's also a bunch of things that hx does to rewrite props as a JS obj that could be memoized#2019-04-1620:20thhellerwould have expected it to be much slower as well given all the vector/map construction#2019-04-1620:21lilactownyeah. I think it caches “native” hiccup#2019-04-1620:23thhellerevery time I look at :advanced compiled code I'm amazed at the optimizations closure does#2019-04-1620:23wilkerlucio@thheller had you tested with Fulcro dom macros as well? I'm curious how it compares to the others#2019-04-1620:23thhelleroh good point. I'll add that#2019-04-1620:32thheller@wilkerlucio doing excellent as expected
react x 281,008 ops/sec ±1.15% (96 runs sampled)
reagent x 170,642 ops/sec ±1.75% (93 runs sampled)
shadow x 269,498 ops/sec ±1.78% (96 runs sampled)
hx x 41,602 ops/sec ±1.26% (92 runs sampled)
rum x 244,612 ops/sec ±0.27% (97 runs sampled)
fulcro-dom x 262,460 ops/sec ±1.40% (95 runs sampled)
#2019-04-1620:39thheller@wilkerlucio FWIW the (fulcro-dom/div :.card ...) variant only seems to run interpreted and is much slower than {:className "card"}.#2019-04-1620:50wilkerluciointeresting, and I think there is no reason for that, this could be generated at compilation time#2019-04-1620:50wilkerlucio@U0CKQ19AQ do you see any thing blocking this?#2019-04-1620:51wilkerluciooh, actually, no it can't, maybe the non localized can, but the localized dom needs to see the dynamic var to determine which class is rendered (and use the correct prefix)#2019-04-1620:57thhellerI'm using fulcro.client.dom in the test. don't know about the localized stuff#2019-04-1620:57thhellerdoes that work outside components?#2019-04-1620:59thhellerupdated the benchmark do be a bit more dynamic which makes fulcro slower. probably hitting a slow pass again#2019-04-1620:59thhellerhttps://gist.github.com/thheller/106db0c13c221be3793b481f7a4eb8bc#2019-04-1621:00thheller
react x 87,861 ops/sec ±1.61% (89 runs sampled)
reagent x 51,563 ops/sec ±2.03% (91 runs sampled)
shadow x 98,100 ops/sec ±0.11% (95 runs sampled)
hx x 6,055 ops/sec ±9.97% (94 runs sampled)
rum x 80,311 ops/sec ±0.33% (94 runs sampled)
fulcro-dom x 29,496 ops/sec ±1.83% (87 runs sampled)
#2019-04-1621:00thhellerunsure how shadow is faster than react suddenly 😛#2019-04-1621:02thhellerprobably map being slower than reduce#2019-04-1621:13tony.kay@thheller the kw variant should be triggering the macro, which should be doing all of the processing at compile time…it should end up raw react in source#2019-04-1621:13tony.kaythat is how it is designed…if it isn’t working, then it is a bug#2019-04-1621:14thhelleryeah dunno. I didn't investigate further.#2019-04-1621:14thhellerit probably was caused by me omitting the {} props#2019-04-1621:15thhellerso it tried to eval the args since the macro couldn't determine that#2019-04-1621:15tony.kayAh, yes…if there are children it is impossible to know if the child is a function making props or a child#2019-04-1621:15thheller
react x 109,719 ops/sec ±0.73% (93 runs sampled)
reagent x 51,251 ops/sec ±2.37% (91 runs sampled)
shadow x 97,151 ops/sec ±0.12% (97 runs sampled)
hx x 6,039 ops/sec ±11.34% (94 runs sampled)
rum x 80,007 ops/sec ±0.91% (94 runs sampled)
fulcro-dom x 83,931 ops/sec ±1.78% (92 runs sampled)
#2019-04-1621:15thhellerperf is good overall if you are careful enough#2019-04-1621:16tony.kayso yes, if you want full performance you’ll have to include a literal empty map of props…docs should prob note that; however, the time in those functions compared to everything else is less than 2% of the time…so it is useless to optimize that IMO#2019-04-1621:16tony.kayit’s one of those microbenchmarks that means little in real life#2019-04-1621:16thhelleryeah I like wasting time on irrelevant performance optimizations 😉#2019-04-1621:17tony.kayThere are much more profitable things to optimize, though#2019-04-1621:18thhelleryeah but also much more complex probably 😉#2019-04-1621:19tony.kaywell, and I’ve already got some of them written…just not released yet 😉#2019-04-1621:19tony.kaynowhere near tested and hardened enough#2019-04-1621:20tony.kaybut I expect Fulcro 3 to be about 10-25x faster on targeted refresh#2019-04-1621:21thhellersweet#2019-04-1621:21thhellerI'm messing with react hooks on the side currently#2019-04-1621:21thhellerand I really do not like them 😛#2019-04-1621:21tony.kayperhaps more…I can eliminate path-meta, the client parser, integrate basis-t calcs into db->tree, eliminate the need to render from root. So, one of my complex apps can take 80ms to render a refresh…I think that’ll turn into something under 10.#2019-04-1621:22tony.kayFunny: I actually really like hooks#2019-04-1621:22thhellerI like the idea too but building something even remotely complex is just super annoying#2019-04-1621:22tony.kayat least what I’ve played with. I’ve got a useFulcro hook working that lets you use a plain function as a fulcro component#2019-04-1621:23tony.kayoh, I would not use them for vanilla js/react 😜#2019-04-1621:23tony.kaybut then I only use vanilla in baking#2019-04-1621:24tony.kayI like that I can use a state hook to get a function that I can then use to do targeted props updates#2019-04-1621:24thheller:rolling_on_the_floor_laughing:#2019-04-1621:24tony.kayI can do that with the component-based ones too, of course…but it ends up just a little cleaner because useState doesn’t accidentally collide with other state#2019-04-1716:09wilkerlucio@thheller I'm with you on the hooks thing, to me they feel like re-frame subscriptions adopted at react level scale, same scaling issues (hard to reason over time)#2019-04-1716:11thhellermy concern is that everything happens in the render function so if you aren't careful about allocation you end up allocating way too much garbage#2019-04-1716:11thhellereg. (react/useState {:my {:initial "state"}})#2019-04-1716:12thhellerthe map will be allocated in each render but only used the first time#2019-04-1716:12thhellermoving that to a def outside to safe the allocation just makes the code ugly#2019-04-1716:14thhelleruseContext is pretty much the only thing that is much much much nicer#2019-04-1716:14thhellerall the other stuff is icky on some level 😛#2019-04-1721:25tony.kaywhat garbage do you suspect with useState? It’s stable stuff stored on the instance…I’m not crazy about the “order dependent” implementation, but as a tool at the js level that we can wrap with better constructs I’m not seeing the problem @thheller#2019-04-1721:26tony.kayoh sorry#2019-04-1721:26tony.kayI reread your comment#2019-04-1721:26tony.kayI see your point#2019-04-1721:28tony.kaybut then I’m defaulting my values to nil, because there is no real component-local state I care about…I’m seeing it as a way to do “setProps” on a component that causes a refresh without colliding with other ppls use of component-local state.#2019-04-1721:28tony.kayand like you said, useContext is a hell of a lot better than lifecycle methods#2019-04-1721:29tony.kaybut less useful to me without the mechanism of useState#2019-04-1721:59thhelleryeah abusing useState as .forceUpdate is ok#2019-04-1722:00thhellerI feel we could do so much more with access to the underlying fiber handle though#2019-04-1722:01thhellerbeing limited to their hooks sucks since we could do cool tricks with macros to avoid all the stuff that otherwise can become costly#2019-04-1722:01thhellerbut having worked with it a bit more I guess I'm indifferent. components have their pros/cons just like hooks#2019-04-1801:18tony.kayI’m hoping using hooks internally in Fulcro will reduce code size. We’ll see. I’m fine keeping the class-based stuff around (and of course kind of have to).#2019-04-1801:19tony.kaybut you’re right, having access to more internals as a documented and stable thing would be nice#2019-04-1620:50wilkerlucioso fulcro and shadow ones are quite close#2019-04-1621:10lilactownit’s funny how much variance hx has too#2019-04-1621:10thhellerprobably allocating too much and running into GC issues#2019-04-1621:11thhellerI'm happy with my lib. Given that it isn't optimized for react but rather the replacement I'm building for it 😉#2019-04-1621:12thhellerenough time wasted with benchmarks though#2019-04-1704:11orestisCould you share the benchmark code? Would be nice to have around!#2019-04-1708:08thhellerI did here https://gist.github.com/thheller/106db0c13c221be3793b481f7a4eb8bc#2019-04-1708:09thhellermy lib isn't public yet though. will publish at some point when its ready.#2019-04-1708:47joelsanchezhello @thheller, I think the documentation regarding nrepl middleware needs to be updated. including the latest shadow-cljs with no nrepl exclusions, you need to use shadow.cljs.devtools.server.nrepl04/... middleware for things to work, and the documentation just mentions the old version https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2019-04-1708:59thhelleryeah. I can probably remove the old implementation now. or rather just flip it. nobody should be using .nrepl04 directly#2019-04-1711:24vinursi create a project from luminus, and then i try to change its cljsbuild to shadow-cljs, and its dependencies by deps.edn, but when i execute shadow-cljs compile app, it show warnning, i don’t know what’s this means#2019-04-1711:24vinurs#2019-04-1711:24vinurs@thheller i follow your example https://github.com/thheller/lumifoo, but i don’t know how to fix this#2019-04-1711:25vinurs@thheller this is my repo, https://github.com/vinurs/admin could u help me?#2019-04-1712:11hlolli@haiyuan.vinurs you need to fix your source path#2019-04-1712:12hlolliFrom maybe “src” to”src/cljs”#2019-04-1712:12vinursin the shadow-cljs.edn, i set this#2019-04-1712:13hlolliYes :src I think, at my phone so dont remember#2019-04-1712:13hlolliOr :source-paths#2019-04-1712:13vinurs#2019-04-1712:14vinurs#2019-04-1712:14hlolliThe namespace represent the filepsth starting the the root of the innermost source path#2019-04-1712:15hlolliOh could you paste the result of “tree ./src” in the shell?#2019-04-1712:15vinurs#2019-04-1712:16vinurs#2019-04-1712:16hlolliWait you have lein true and use deps?#2019-04-1712:16vinursyes#2019-04-1712:17hlolliChange :lein true to :deps true#2019-04-1712:17vinursbecause i want to share deps with lein and shadow-cljs
#2019-04-1712:17hlolliOr no wiat#2019-04-1712:17hlolliAdd :src into your deps.edn file#2019-04-1712:17vinurs:lein true :deps {:aliases [:cljs]}#2019-04-1712:17vinursthis is what i’ve set in shadow-cljs#2019-04-1712:17hlolliAnd there same as you have in :source-paths#2019-04-1712:18hlolliDeps is in control of the source path if you use it#2019-04-1712:18vinurs:source-paths [“src/cljc” “src/cljs” “env/prod/cljs”]#2019-04-1712:18hlolliBecause source path is actually classpath, and deps takes care of tje classpath#2019-04-1712:18hlolliYes put this in deps.edn#2019-04-1712:18vinursit has been there#2019-04-1712:19hlolliNot in the file you sent above, or I am terribly blind#2019-04-1712:19vinurshttps://github.com/vinurs/admin#2019-04-1712:20hlolliYou have :deps and :aliases#2019-04-1712:20vinursthe test i’ve push to the github#2019-04-1712:20vinursyes#2019-04-1712:20hlolliBut youre missing source patha#2019-04-1712:20vinursso , i need to set paths in the deps.edn?#2019-04-1712:21hlolliYes, if you have deps.edn take care of the deps, shadow wil hand over the responsibility of classpath to depsedn#2019-04-1712:21hlolliSame with leiningen I assume.#2019-04-1712:21hlolliBut preferably yu should have lein and shadow point to deps.edn but thats maybe a matter of taste#2019-04-1712:23hlolliAs far as i remember its :paths not :source-paths#2019-04-1712:23hlolliIn deps.edn#2019-04-1712:23vinursbecause some times cljs and clj need the same library, so i want to share deps between clj and cljs, that is lein and shadow-clj, so i use deps.edn#2019-04-1712:24hlolliYes thats good thinking, but the :lein true you have in shadow-cljs.edn seems redundant to me#2019-04-1712:24hlolliJust use :deps true instead and use in leiningen the deps middleware#2019-04-1712:26vinursi changed, but it does no effect#2019-04-1712:26hlolliCant be :) you have now :paths :aliases and :deps in deps.edn?#2019-04-1712:29vinursok now#2019-04-1712:30vinurs#2019-04-1712:30vinursset this in deps.edn#2019-04-1712:30vinursbut, i think this should be cljs only, so i set it in the alias :cljs#2019-04-1712:31hlolliNana its fine that its global#2019-04-1712:31vinursand in shadow-cljs i use :deps {:aliases [:cljs]}#2019-04-1712:31hlolliUhh its really unneccecary#2019-04-1712:32vinursbut now it’s global, so in lein, the paths will auto import? does it conflict with clj’s src/clj?#2019-04-1712:33hlolliNo because you can only have 1 compiler reading at any given time. Cant have clj and cljs running as 1 compiler#2019-04-1712:35vinursbut in project.clj, i have this setting: :source-paths [“src/clj” “src/cljc”]#2019-04-1712:35vinursoh, i see, the clojure compiler doesn’t read cljs file#2019-04-1712:35hlolliOk. You dont want deps edn to take care of the deps for leiningen then?#2019-04-1712:36vinursactually, i do want, but i don’t know how to set seperately for clj and cljs, so i set in project.clj before#2019-04-1712:37hlolliLook at the leiningen deps middleware/plugin. Then you dont neeed to set classpaths in leiningen, 1 source of truth for both shadow and lein, that would be clean#2019-04-1712:38vinurs[lein-tools-deps “0.4.5”]#2019-04-1712:38vinursi use this#2019-04-1712:39hlolliAh yeh i see now you have it setup right. If you give me 10 mins I can run your app#2019-04-1712:40hlolliBut need then to add the resource path to deps edn too#2019-04-1712:40hlolliThats lein side tough, your problem is with cljs source path#2019-04-1712:40vinursyes, i want to move all deps to deps.edn#2019-04-1712:42vinurssome deps are cljs only, is there anyway i can seperate it from global?#2019-04-1712:43vinursi read the doc, and found aliases#2019-04-1713:07hlollisorry long 10 minutes, testing now#2019-04-1713:11vinursthanks#2019-04-1713:23hlolli@haiyuan.vinurs its taking some time, are you using leiningen to generate the index.html?#2019-04-1713:23vinursyes#2019-04-1713:24hlolli
Caused by: java.lang.RuntimeException: could not find a non empty configuration file to load. looked in the classpath (as a "resource") and on a file system via "conf" system property
#2019-04-1713:24polymerisHello How do I handle local clojurescript dependencies with shadow-cljs? I.e. I have foo/shadow-cljs.edn and a bar/shadow-cljs.edn, and want bar to depend on foo. If this was leiningen, I'd go into foo and do lein install, then that would copy the artifact to my local maven cache, and I would depend on it from bar normally. Is there a shadow-cljs equivalent?#2019-04-1714:08thhellerlibrary dev is currently not covered by shadow-cljs. so either lein or deps.edn works. if your foo doesn't add any deps you can just do :source-paths ["src/main" "../foo/src/main"] in shadow-cljs.edn of bar#2019-04-1714:09thhellerlein install in foo and just using the dep in bar also works fine#2019-04-1714:09thhellerif I ever get around to it I'll add a shadow-cljs install equivalent 😛#2019-04-1714:15polymerisYeah, I think I'll have lein handle that for now. Thanks!#2019-04-1714:39polymerisThen again, if foo has npm dependencies, and I do lein install the resulting jar won't include those deps or any reference to them :(#2019-04-1714:51thhelleryou can add a deps.cljs with {:npm-deps {"the-lib" "version"}} to foo#2019-04-1714:56polymerisOhhh.. but then I'd have to keep that in sync with foo's package.json?#2019-04-1715:21thhelleryeah#2019-04-1715:23polymerisI'll try this thing, I guess https://github.com/colindresj/package-json-to-deps-cljs#2019-04-1715:23polymerisThanks for all the help!#2019-04-1713:24vinursi mv the resource dir to deps.edn#2019-04-1713:24hlolliI remove the jvm opts and sass, dont have sass#2019-04-1713:24hlolli(I dont..)#2019-04-1713:25hlolli@polymeris I'd use leiningen for this usecase to create a jar#2019-04-1713:41polymerisThanks. I was trying to avoid having 2 tools, but maybe it makes sense#2019-04-1713:45hlolliyes I think this is one of the case where shadow-cljs wont solve, to package clojure sourcefiles.#2019-04-1713:46hlolliyou can have a fairly minimal leiningen file that only has the source files set up and lein jar will produce the jar you need to iinstall into your maven path#2019-04-1713:58polymerisI just wanted to have everything handled by npm to make things easier for people coming from that ecosystem#2019-04-1713:58polymerisMaybe if npm could install lein 🤔#2019-04-1714:02hlolliTheres a lein runner in npm. But you should ofc only upload compiled js respurces to npm#2019-04-1713:27hlolli@haiyuan.vinurs Caused by: java.lang.RuntimeException: could not start [#'admin.config/env] this is beyond the scope of shadow-cljs, I'll just create a index.html, confirm if the paths are correct, then you can ask for lein question on different channel#2019-04-1713:28vinursok#2019-04-1713:29vinursthe code i pushed to the github works well in my pc#2019-04-1713:30vinursnow, the problem is that, when i in emacs cider-jack-in, then it start a nrepl, and then in terminal, i type: shadow-cljs watch app, then in chrome i visit http://127.0.0.1:3000/, but it shows#2019-04-1713:30vinurs#2019-04-1713:31vinursit seems that the compiled app.js doesn’t affect#2019-04-1713:31vinursbut the js has been there#2019-04-1713:32vinursthere is app.js in my home.html#2019-04-1713:33hlolli#2019-04-1713:34hlolliignore the html, but shadow-cljs is working fine#2019-04-1713:34hlolliok make sure you don't have any figwheel or anything connected to clojurescript operating in your leiningen file#2019-04-1713:35hlollijust tell your dev ring handler to load the shadow-cljs artifacts and that's it#2019-04-1713:39vinurs#2019-04-1713:40vinurs:resource-paths [“resources”] the resource-paths in project can not be removed#2019-04-1713:41hlolliresource path is another example of a classpath, just add it into :paths in deps.edn#2019-04-1713:42vinursi’ve added, but it seems doesn’t affect#2019-04-1713:42hlolliand I'd refactor your project.clj file, I think the source of this mess is there, for example all the dependencies you have under your profiles, you don't need it with deps.edn, and figwhell cand shadow are solving the same problem in development so you don't want any cljsbuild or leiningen running#2019-04-1713:43hlolliyou can ofc have deps.edn aliasaes#2019-04-1713:44hlolliwhat resource doesn't work for you?#2019-04-1713:44vinurswait a minute#2019-04-1713:47vinursi’ve tried again, works ok now#2019-04-1713:49vinursthere is another problem, that is the compiled app.js init doesn’t executed#2019-04-1713:50vinurs:modules {:app {:entries [admin.core]}} :devtools {:after-load admin.core/mount-components}}}}#2019-04-1713:50vinursthis is setting in my shadow-cljs#2019-04-1713:50vinursit seems that mount-components doesn’t execute#2019-04-1713:52hlolli(r/render [#'page] (.getElementById js/document "app"))#2019-04-1713:52vinurs#2019-04-1713:52vinursthis is mount-components#2019-04-1713:52hlolliah it's fine, though denoting page as a variable is unusual#2019-04-1713:53hlolliI see @haiyuan.vinurs you have :devtools in the wrong map#2019-04-1713:54hlolli{:app {:devtools not {:app {} :devtools {}}#2019-04-1713:55hlollisorry Im blind, it is like that, I'm leaving anyway, maybe @thheller can see why it fails 😄#2019-04-1713:55vinursah#2019-04-1713:55vinurs😆#2019-04-1713:56hlollialternative is to just execute the function in that file (mount-components) at the bottom#2019-04-1713:56vinursok, i try it first#2019-04-1714:06thhellerwell you've been busy 😛#2019-04-1714:06thheller@haiyuan.vinurs did you figure it out or still need help?#2019-04-1714:11vinursyes, need help#2019-04-1714:12vinurshttps://github.com/vinurs/admin#2019-04-1714:12vinursall code has been pushed#2019-04-1714:12thhelleralright: first issue is the source-paths#2019-04-1714:12vinurswhen i visit the homepage, it seems doesn’t execute the mount-components function#2019-04-1714:12thhelleryou can either use shadow-cljs.edn to manage them, or deps.edn or project.clj#2019-04-1714:13thhellerif you set either :deps or :lein in shadow-cljs.edn the :source-paths and :dependencies there will have no effect at all#2019-04-1714:14thhellerand what do you actually want to use? the repo has everything so I'm not sure what you actually want#2019-04-1714:14thhellerdeps.edn or project.clj?#2019-04-1714:14vinursdeps.edn#2019-04-1714:15thhelleralright then you probably want to remove :source-paths from project.clj as well#2019-04-1714:15vinursyes#2019-04-1714:15thhellerI'm not sure how lein-tools-deps works though but you are currently setting :source-paths in 3 places which is just confusing#2019-04-1714:15thhellerthere should be only one place where all of this is configured#2019-04-1714:15vinursso all set in the deps.edn?#2019-04-1714:16thhelleryes probably the best#2019-04-1714:17vinursthis is project.clj, lein may use different source paths in different env, how can i do this?#2019-04-1714:17thhellerI don't know. check lein-tools-deps docs.#2019-04-1714:18vinursok, i do this later, there is another problem#2019-04-1714:18thheller
:dev
        {:compiler-options {:closure-warnings {:global-this :off}
                            :source-map true
                            :optimizations :none
                            :pretty-print true}}
        :release
        {:compiler-options {:optimizations :advanced
                            :pretty-print false
                            :closure-warnings
                            {:externs-validation :off
                             :non-standard-jsdoc :off}}}
#2019-04-1714:18thhellerthis makes no sense#2019-04-1714:18thhelleryou can leave it in but you are just setting the already used defaults again#2019-04-1714:19vinursok, i removed it#2019-04-1714:19thheller
:compiler-options {:closure-warnings
                   {:global-this :off
                    :externs-validation :off
                    :non-standard-jsdoc :off}}
#2019-04-1714:20vinursi need to add this?#2019-04-1714:24thhellerno clue. I assume you had it in there for a reason?#2019-04-1714:19thhelleris probably what you want#2019-04-1714:19vinursis there any error with this?#2019-04-1714:21thhellerlooks fine#2019-04-1714:22thheller
{:deps {:aliases [:cljs]}
 :builds
 {:app {:target :browser
        :output-dir "resources/public/js"
        :asset-path "/js"
        :compiler-options {:closure-warnings
                           {:global-this :off
                            :externs-validation :off
                            :non-standard-jsdoc :off}}
        :modules {:app {:entries [admin.core]}}
        :devtools {:after-load admin.core/mount-components}}}}
#2019-04-1714:22thhellerAFAICT that should be the config you need#2019-04-1714:24thhellerwhat is the problem?#2019-04-1714:25vinursi changed the shadow-cljs.edn#2019-04-1714:25vinursit also doesn’t effect the app.js#2019-04-1714:25thhellerwhat does that mean?#2019-04-1714:25thhellerresources/public/js/app.js is the file shadow-cljs will create#2019-04-1714:26thhelleryou should be loading it at /js/app.js#2019-04-1714:26vinursyes, app.js has been created,#2019-04-1714:26thhellerI can't find where the HTML is created that loads the file#2019-04-1714:27thhellerbut what is the issue?#2019-04-1714:27vinursthe content is just the html content, but in html i wrote {% script “/js/app.js” %}, and when i visit this page, i want the html execute the mount-components function, it a render#2019-04-1714:27vinursadmin/resources/html#2019-04-1714:27vinurshome.html#2019-04-1714:28thhellerah. you expect :devtools {:after-load admin.core/mount-components} to call mount-components?#2019-04-1714:28vinursyes#2019-04-1714:28thhellerthat is not what that does. that tells the devtools to call that function after it has loaded code#2019-04-1714:28thhellerit has nothing to do with your normal app flow#2019-04-1714:28thhellerso you want :modules {:app {:init-fn admin.core/mount-components}}#2019-04-1714:29thhellerthat will make it run the function on initial load#2019-04-1714:29thhelleroh no#2019-04-1714:29thhelleryou actually want the init! fn#2019-04-1714:30thhellerso :modules {:app {:init-fn admin.core/init!}}#2019-04-1714:30thheller
{:deps {:aliases [:cljs]}
 :builds
 {:app {:target :browser
        :output-dir "resources/public/js"
        :asset-path "/js"
        :compiler-options {:closure-warnings
                           {:global-this :off
                            :externs-validation :off
                            :non-standard-jsdoc :off}}
        :modules {:app {:init-fn admin.core/init!}}}}}


;; admin.core js

(defn ^:dev/after-load mount-components []
  (rf/clear-subscription-cache!)
  (r/render [#'page] (.getElementById js/document "app")))
#2019-04-1714:30vinursah haha#2019-04-1714:30vinursthanks#2019-04-1714:30thhellerthat is what I'd do probably#2019-04-1714:31vinursworks now#2019-04-1714:31thheller^:dev/after-load tells the devtools to call that function after loading code. I think its cleaner there than in the build config#2019-04-1714:31thhellerworks the same though#2019-04-1714:32thhellerthe luminus template has to be the most complicated template ever 😛#2019-04-1714:32thhellerthere has to be an easier way to do this#2019-04-1714:33vinursyes, the author said would change to shadow-cljs next month#2019-04-1714:33vinurs😆#2019-04-1714:33vinursif i change the mount-components to this, then i need to set :modules {:app {:init-fn admin.core/init!}} this?#2019-04-1714:49thhelleryes it is meant that way by looking at the code#2019-04-1714:50thhellermount-components only re-renders code#2019-04-1714:50thhellerinit! actually does all the app initialization stuff#2019-04-1714:51lilactownwhat options can I pass to shadow/release to get e.g. readable names?#2019-04-1714:52vinursthanks very much @thheller#2019-04-1715:16lilactownseems like (shadow/release :thing {:debug true}) works 😄#2019-04-1715:23thheller@lilactown --pseudo-names would be :pseudo-names true#2019-04-1715:23thheller:debug is pseudo-names + source-maps#2019-04-1715:23lilactownrandom question: is there a way to get chrome to tell me what JS corresponds to a line in a source map file?#2019-04-1715:23lilactownah. I might just disable or elide source-maps#2019-04-1715:24thhellerthats why those are separate options 😉#2019-04-1715:24lilactownwell it’s being helpful in that I know what part of my CLJS code is slow. but I want to see the JS now 😛#2019-04-1715:24lilactownany tricks you know of?#2019-04-1715:25lilactownseems like if it can go JS line -> source map, i should be able to go the other way!#2019-04-1715:25thhellerJS code after optimizations or before? 😛#2019-04-1715:25lilactownafter optimizations I guess#2019-04-1715:26thhellerI just use pseudo names for that. the names are close enough so you can figure out where it came from in the CLJS code#2019-04-1715:26thhellercan't jump directly from CLJS loc -> JS loc since the code may be changed in ways that make that impossible 😛#2019-04-1715:31thheller@lilactown there might be tools similar to this buried in the closure compiler stuff that allow going that way? https://clojureverse.org/t/server-side-decoding-of-javascript-sourcemaps/1591/3?u=thheller#2019-04-1715:59vinurs#2019-04-1716:00vinurswhen i do lein uberjar, it output these#2019-04-1716:00vinurs@thheller#2019-04-1716:00vinursis it need to set somthing?#2019-04-1716:01thhellerno. safe to ignore those ...#2019-04-1716:02thheller{:type :shadow.build.closure/invalid-closure-warning, :key :non-standard-jsdoc, :level :off, :shadow.build.log/level :warn} this means you can remove :non-standard-jsdoc from the build config#2019-04-1716:02thhellersince it doesn't seem to exist#2019-04-1716:05vinursok, it seems that it doesn’t need to move deps from project.clj to deps.edn, shadow-cljs can read deps from project.clj well#2019-04-1716:07thhelleryeah just project.clj is fine. thought you wanted to use deps.edn#2019-04-1716:07thhellershadow-cljs doesn't read deps from project.clj in any way however. it just uses lein to launch itself.#2019-04-1716:07thhellerso whatever is configured there applies#2019-04-1716:07vinurs😆,i don’t know that shadow-cljs can read the deps from project.clj before#2019-04-1716:07vinursjust now i tried it and works ok#2019-04-1716:08thhellerif you have :lein true in your config shadow-cljs watch app literally runs lein run -m shadow.cljs.devtools.cli watch app#2019-04-1716:08vinursoh, i see#2019-04-1716:09thhellerproject.clj is never parsed in any way#2019-04-1716:09vinursor i just run shadow-cljs watch app the same effect?#2019-04-1716:09vinursshadow-cljs watch app#2019-04-1716:09thhelleryes thats what I mean. you run shadow-cljs watch app and that internally just calls lein run -m shadow.cljs.devtools.cli watch app for you#2019-04-1716:10thhelleryou don't ever need to call lein yourself. its just what is done internally.#2019-04-1716:10vinursi see, thanks#2019-04-1720:38kennyI was looking at https://github.com/thheller/netlify-cljs and wondering if the same setup would work for a project using deps.edn instead of Lein.#2019-04-1721:04thheller@kenny the project doesn't actually use lein. netlify just enables maven caching if it finds the project.clj#2019-04-1721:04thhellerno clue if it does the same for deps.edn?#2019-04-1721:04kennyI tried it and got:
Executable 'clojure' not found on system path.
#2019-04-1721:05thhellerhttps://github.com/netlify/build-image/blob/xenial/run-build-functions.sh#L394-L412#2019-04-1721:06thhellerdoesn't look like it supports deps.edn yet#2019-04-1721:07thhellerlein isn't used to do anything other than caching deps#2019-04-1721:10kennyGotcha. I was able to get it to work with the following:
curl -O 
chmod +x linux-install-1.10.0.442.sh

install_dir=/opt/buildhome/clojure
mkdir -p ${install_dir}
./linux-install-1.10.0.442.sh --prefix ${install_dir}

echo "Installing Clojure to ${install_dir}/bin"
export PATH="${install_dir}/bin":$PATH
#2019-04-1721:11thhellerthat still won't cache the maven deps though#2019-04-1721:11kennyRight but at least it'll build. Unfortunate about caching though.#2019-04-1721:12thhellershadow-cljs unfortunately has too many deps so builds got way too slow for my taste without cache 😛#2019-04-1721:13kennyYeah... Right now I am using manual deploys to Netlify on CircleCI but I'd really like to take advantage of the deploy and branch previews.#2019-04-1721:15thhellermaybe they'd be open to adding support for deps.edn and maybe shadow-cljs.edn even#2019-04-1721:15thhellersince I'm not actually using the platform I didn't bother asking#2019-04-1722:40dpsuttonNetlify builds my shadow project just fine#2019-04-1816:47kennyAre you using deps.edn with private repo Git deps ?#2019-04-1816:47dpsuttonah no. sorry i missed that part. simple public repo on lein i think#2019-04-1802:31flyboarder5 | (defmethod h/do! ::/grid -------------------------------^------------------------------------------------ uikit_hl/grid.cljs [line 5, col 25] Invalid keyword: ::/grid. -------------------------------------------------------------------------------- Any ideas channel?#2019-04-1802:45flyboardernvm, that is a perfect error and I clearly dont know how to use keywords XD#2019-04-1802:45flyboardercorrect kw is ::grid#2019-04-1803:45flyboarderHmm, it would seem any namespaced keyword throws this error, including ::ns/my-name and :my.ns/my-name#2019-04-1803:55lilactownthe first one I would expect, the second I would not#2019-04-1803:55flyboarder@lilactown those are both valid namespaced keywords#2019-04-1803:56lilactownonly if ns is aliased to something#2019-04-1803:56flyboarderyes#2019-04-1803:56flyboardereither way shadow throws#2019-04-1804:03flyboarderAs a note im on 2.8.14#2019-04-1804:54flyboarderoddly :my-ns/my-name works#2019-04-1807:32thheller@flyboarder ::/grid is not a valid keyword. ::ns/my-name is valid if you have a (:require [some.thing :as ns]) otherwise it is not. :my.ns/my-name is always valid.#2019-04-1807:33thheller::grid is always always dependend on ns, so (ns foo.bar) ::grid makes :foo.bar/grid#2019-04-1814:35flyboarder@thheller in 2.8.14 ::ns/grid and :my.ns/grid both throw invalid keyword errors#2019-04-1814:37flyboarderWhere :my-ns/grid works fine, seems it doesn’t like dots or auto resolving#2019-04-1814:43flyboarderSpecifically I wanted to use the first case, where I have my namespace aliased, however when that failed I tried using the fully qualified namespace which is also failing. #2019-04-1816:30thheller@flyboarder :my.ns/grid throws? that sounds questionable?#2019-04-1816:32flyboarder@thheller yes, I assumed it should work #2019-04-1816:32flyboarderAlso the aliasing throws as well#2019-04-1816:34thhellercan you please show the actual error because I find this quite unbelievable#2019-04-1816:34flyboarderSure one sec#2019-04-1816:35thhellerI can't even remember when namespaced keywords were added. so I doubt there is even a tools.reader version that didn't support it, ruling out dependency conflicts?#2019-04-1816:38flyboarder@thheller here it is with fully qualified name#2019-04-1816:38flyboarder
39 |   (grid/grid :match true :uikit-hl.width/1-1-s true :uikit/width-1-1-s true :uikit/child-width-1-1-s true :uikit/child-width-1-3-m true; :class [:uk-grid-collapse]
-----------------------------------------------------^--------------------------
app/ui.cljs [line 39, col 47] Invalid keyword: :uikit-hl.width/1-1-s.

--------------------------------------------------------------------------------
#2019-04-1816:39thhellerwell that its a different story. keywords cannot start with a number so :uikit-hl.width/1-1-s is invalid because of that#2019-04-1816:40thhellernothing to do with the ns#2019-04-1816:42flyboarder@thheller is that a cljs thing? it works in a clojure repl#2019-04-1816:42flyboarderhttps://repl.it/repls/GrippingStainedAstronomy#2019-04-1816:42flyboarderah it seems (keyword 1) returns nil#2019-04-1816:42flyboarderbut ::2 works#2019-04-1816:42dpsutton
user> :a/1
RuntimeException Invalid token: :a/1  clojure.lang.Util.runtimeException (Util.java:221)

cljs.user> :a/1

clojure.lang.ExceptionInfo: [line 1, col 5] Invalid keyword: :a/1. {:type :reader-exception, :ex-kind :reader-error, :file nil, :line 1, :col 5}
#2019-04-1816:42thhellernope its just as invalid in Clojure. https://github.com/edn-format/edn#symbols#2019-04-1816:43thheller> Symbols begin with a non-numeric character and can contain alphanumeric characters#2019-04-1816:43thheller> Keywords follow the rules of symbols, except they can (and must) begin with :#2019-04-1816:43flyboarderand yet this works :2#2019-04-1816:44dpsuttoni think this comes up a little. the reader accepts a bit more than the spec says#2019-04-1816:44thhelleryeah the reader isn't as strict as it should be sometimes#2019-04-1816:44dpsuttonbut they are invalid and can break in future versions#2019-04-1816:44thhellerI think that is only for historic reasons though#2019-04-1816:45flyboarderok so I really need to rethink the naming of these keywords#2019-04-1816:45flyboarderthanks everyone - I just learned so much in the past 5 minutes#2019-04-1816:47flyboarderreally nice to know that shadow correctly detected this problem, I just didn’t know enough to resolve it#2019-04-1816:48thhellerthats not shadow recognizing it. thats tools.reader so you'd get that error anywhere#2019-04-1903:25vinurswhen i in emacs, and run cider-jack-in-clj&cljs, it output this error#2019-04-1903:25vinursdoes this a shadow-cljs error ? or cider?#2019-04-1907:52thheller@haiyuan.vinurs when you run in embedded mode you need to start the server instance yourself. https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2019-04-1910:29vinurs@thheller thanks, it works now#2019-04-1910:43vinurshttps://github.com/sunnylqm/react-native-storage i want to integrate this to my project,#2019-04-1910:43vinursthe chrome shows this error#2019-04-1910:44thhellerwhich shadow-cljs version do you use?#2019-04-1910:44vinurs2.8.31#2019-04-1910:49thhellermeh#2019-04-1910:53thhellerI don't know. the library just uses a regeneratorRuntime global variable without any indication where that is supposed to come from#2019-04-1910:53thhellerI know its a babel thing#2019-04-1910:54thhellerI think you are supposed to require something else to make that global available#2019-04-1910:54thhellerI don't know why the lib is bundled that way#2019-04-1910:55thhelleryou can probably use this ["react-native-storage/src/storage" :refer (Storage)]#2019-04-1910:56thhellerbut honestly you will be way better off skipping the entire library. writing a similar version that stores EDN or transit will be much more useful#2019-04-1910:56vinursfailed#2019-04-1910:56vinurs#2019-04-1910:56vinursi just want to use html5 localstorage, so i found this library can use in both broswer and react-native, so i want to integrate it#2019-04-1910:58thhelleryou can set :js-options {:babel-preset-config {:targets {:chrome 74}}}#2019-04-1910:58thhellerthat will make it skip trying to rewrite the class ... extends definitions#2019-04-1910:59thhellerseriously though .. don't use that library#2019-04-1911:12claudiuHi. Silly question.. is there any trick for nodejs or browser repl to send the promise result, after evaluating a form ?#2019-04-1911:12claudiulike
(-> get-db-result
  (prom/then (fn [x]
   (fn-send-to-repl x))))
#2019-04-1911:24vinurs#2019-04-1911:24vinursit seems should require as this#2019-04-1911:41vinurshow can i translate this code to cljs?#2019-04-1911:42vinurs#2019-04-1911:42vinursi tried this, it seems have been save in localstorage, but i can not load it#2019-04-1913:48vinurs#2019-04-1913:49vinursfound the answer#2019-04-1916:26lilactownare there any tools for visualizing the namespace graph of a CLJS project?#2019-04-1917:52thhellerI don't know any#2019-04-1917:55lilactownI'm guessing that information is available somehow?#2019-04-1917:57thhelleryeah. there is no official API to get it but it is there#2019-04-2010:03David Pham@thheller do you think it is feasible to target react native web with shadow-cljs?#2019-04-2011:59thheller@neo2551 probably? unless it relies too much on webpack or so#2019-04-2012:19David PhamGuess I will have to try and see xD#2019-04-2021:24wilkerlucioI have a combined setup that I still need to compile parts with lein, so I have to explicitly say the deps version, but every time I need to do a large bump I get lost in which versions are shadow expecting now. is there a way for me to check which are the versions that shadow wants at a given point?#2019-04-2021:26wilkerlucioI just found the project.clj seems to have the correct ones, its safe to pull from there?#2019-04-2021:26thhellerwhat do you mean?#2019-04-2021:27wilkerluciofor example, I'm bumping from shadow 2.7.30 to 2.8.32, in my project.clj I have
[org.clojure/clojurescript "1.10.439"]
                 [com.google.javascript/closure-compiler-unshaded "v20181125"]
#2019-04-2021:27wilkerlucioso I have to know what to bump those to#2019-04-2021:27thhellerah right. yeah project.clj is probably the best source#2019-04-2021:28thhellerdeps.edn doesn't work for shadow-cljs because there are java sources that need to be compiled#2019-04-2021:28thhellerwhich deps.edn doesn't support#2019-04-2021:29thhellernvm ... you are using the maven verison anyways#2019-04-2021:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/project.clj#L39-L47#2019-04-2113:38Nolanhi, i think this issue might not have been resolved as expected: https://github.com/thheller/shadow-cljs/issues/483#2019-04-2113:39Nolaneven after upgrading to version 2.8.32, i still am only able to pull dependencies when i specify proxy configuration via the shadow-cljs.edn file in project root#2019-04-2119:49thhellerit should be :maven {:proxy ...} in ~/.shadow-cljs/config.edn#2019-04-2119:49thhellerI still need to document this properly#2019-04-2412:22NolanOkay, yeah, that worked. Thank you!!#2019-04-2113:41Nolan
> shadow-cljs compile app
shadow-cljs - config: /Users/hch429/side-projects/clojurescript/my-web-app/shadow-cljs.edn  cli version: 2.8.32  node: v10.12.0
shadow-cljs - updating dependencies
shadow-cljs - dependency update failed - Failed to collect dependencies at quil:quil:jar:3.0.0
#2019-04-2116:00wilkerluciojust got this warning, but sounds weird:
------ WARNING #1 - :invalid-arithmetic ----------------------------------------
...
--------------------------------------------------------------------------------
  32 |   (let [formatted-points (misc/cents->display points)]
  33 |     (if (pos? points)
  34 |       (str "+ " formatted-points)
  35 |       (str "- " (- formatted-points)))))
-----------------------^--------------------------------------------------------
 cljs.core/-, all arguments must be numbers, got [#{string clj-nil}] instead
--------------------------------------------------------------------------------
Is there a different way to get a negative version of a number other than that?
#2019-04-2116:05lilactownit sounds like the issue is you're passing a string into -. why are you doing that?#2019-04-2116:06lilactowndo you want it to display as a negative number?#2019-04-2116:11wilkerlucioits a formatting thing, its rendering a string with "- 45" for example, its adding the space between the minus and the number (and has to invert the number to avoid the minus duplicated)#2019-04-2116:13wilkerlucioseems like that got inference lost#2019-04-2116:19lilactownsounds like you'll want to invert the number before converting to string if you want to appease the warning#2019-04-2116:26wilkerluciojust realized the warnings is accurate indeed, formatted-points is a str out of misc/cents->display, so calling - on it is wrong#2019-04-2119:10macrobartfastafter running:
npx shadow-cljs watch frontend
I get:
shadow-cljs - starting via "clojure"
Executable 'clojure' not found on system path.
I'm not sure where to start, any thoughts?
#2019-04-2119:11lilactownsounds like you have :deps true in your shadow-cljs.edn#2019-04-2119:12macrobartfastand, I do!#2019-04-2119:12lilactownand you don’t have clojure installed on your system#2019-04-2119:12macrobartfastI wasn't quite sure how to do the second... fumbled through https://raphamorim.io/using-clojure-as-cli#2019-04-2119:12macrobartfastbut that isn't probably what is meant by installing clojure on my system.#2019-04-2119:13lilactownit is#2019-04-2119:13lilactownhowever, those steps are unneeded#2019-04-2119:13macrobartfastah ok#2019-04-2119:14lilactownis there a particular reason you are using :deps true?#2019-04-2119:14macrobartfastah, only that it was part of a project I cloned...#2019-04-2119:14lilactownthat will obviate the next steps I might suggest#2019-04-2119:14lilactownis this a boilerplate you cloned, or a particular project that youre working on?#2019-04-2119:15macrobartfasthttps://github.com/jackrusher/gespensterfelder#2019-04-2119:15macrobartfastthat.#2019-04-2119:15lilactownah OK. kind of annoying that the author uses :deps true#2019-04-2119:15lilactownwhatever#2019-04-2119:15macrobartfastah ok... way over my head... but learning...#2019-04-2119:16macrobartfastI want a fun way to play with webgl stuff interactively...#2019-04-2119:16macrobartfastand, you know, see pretty things in my browser.#2019-04-2119:17macrobartfastsetting :deps to false spewed promising things, then
The required namespace "applied-science.js-interop" is not available, it was required by "gespensterfelder.cljs"
#2019-04-2119:18lilactownthe problem: shadow-cljs can usually be in charge of downloading, providing and building clojurescript libraries. in that case, you put your dependencies in the shadow-cljs.edn file. the author has elected to tell shadow-cljs, “Hey don’t bother managing my dependencies for me. Instead, use my system’s clojure installation and feed it the deps.edn file in my project to download and provide dependencies for me.”#2019-04-2119:18macrobartfastah ok... yeah... :deps false for me, then, probably, in general.#2019-04-2119:18lilactownwell#2019-04-2119:19macrobartfastI want to make interactive webgl things that update from websocket/SSE events and so on...#2019-04-2119:19macrobartfastand develop interactively.#2019-04-2119:20macrobartfastI actually don't understand why anyone would not want to be doing that today.#2019-04-2119:20lilactown😄#2019-04-2119:21lilactownOK, so you can either: 1. install clojure on your system. if you have brew setup, it’s as easy as brew install clojure 2. use this shadow-cljs.edn file instead: https://gist.github.com/Lokeh/e8e1ec026e1021f1b1818efd79d7cbef#2019-04-2119:22lilactownI added a :dependencies key + value in the shadow-cljs.edn file based on the deps.edn in the repo you posted: https://github.com/jackrusher/gespensterfelder/blob/master/deps.edn#2019-04-2119:22macrobartfastoh nice!#2019-04-2119:25macrobartfastcompiling... (eyes bulging in anticipation)...#2019-04-2119:26macrobartfastyay!!😀#2019-04-2119:26macrobartfastyou rock.#2019-04-2307:37henrikHas anyone seen these errors before?
[2019-04-23 11:34:14.200 - INFO] :shadow.build.classpath/jar-cache-write-ex - {:file #object[java.io.File 0x31ab3dc7 ".shadow-cljs/jar-manifest/1555996365252-java-io-0.1.13.jar.manifest"]}
NoSuchMethodError com.cognitect.transit.TransitFactory.writer(Lcom/cognitect/transit/TransitFactory$Format;Ljava/io/OutputStream;Ljava/util/Map;Lcom/cognitect/transit/WriteHandler;Ljava/util/function/Function;)Lcom/cognitect/transit/Writer;
	cognitect.transit/writer (transit.clj:157)
	cognitect.transit/writer (transit.clj:139)
	shadow.build.cache/write-stream (cache.clj:9)
	shadow.build.cache/write-stream (cache.clj:8)
	shadow.build.cache/write-file (cache.clj:26)
	shadow.build.cache/write-file (cache.clj:24)
	shadow.build.classpath/find-jar-resources/fn--10810 (classpath.clj:558)
	shadow.build.classpath/find-jar-resources (classpath.clj:557)
	shadow.build.classpath/find-jar-resources (classpath.clj:528)
	shadow.build.classpath/find-resources (classpath.clj:608)
	shadow.build.classpath/find-resources (classpath.clj:600)
	shadow.build.classpath/index-path* (classpath.clj:839)
Tons and tons of them. Probably one for every dep I have.
#2019-04-2307:38henrikShadow-cljs 2.8.33#2019-04-2307:57thheller@henrik do you use :lein or :deps in shadow-cljs.edn? look like there maybe a dependency conflict on the transit dep?#2019-04-2308:03henrikAh, :deps#2019-04-2308:05henrikTransit is pulled in transitively from cljs-http and datomic-cloud respectively. #2019-04-2313:18souenzzoIn my datomic cloud I use
{:aliases {:cljs {:override-deps {com.google.guava/guava     {:mvn/version "27.1-jre"}
                                  org.clojure/tools.reader   {:mvn/version "1.3.2"}
                                  org.clojure/core.async     {:mvn/version "0.4.490"}
                                  com.cognitect/transit-java {:mvn/version "0.8.337"}}
                  :extra-paths   ["src/app" "src/web"]
                  :extra-deps    {thheller/shadow-cljs                            {:mvn/version "2.8.32"}
                                  com.google.javascript/closure-compiler-unshaded {:mvn/version "v20190325"}
                                  ch.qos.logback/logback-classic                  {:mvn/version "1.3.0-alpha4"}
                                  org.clojure/google-closure-library              {:mvn/version "0.0-20190213-2033d5d9"}
                                  org.clojure/clojurescript                       {:mvn/version "1.10.520"}}
                  :main-opts     ["-m" "shadow.cljs.devtools.cli"]}}}

#2019-04-2308:05henrikI'll have a look, thanks#2019-04-2308:06thhellershould be using [com.cognitect/transit-clj "0.8.313"]#2019-04-2308:09henrikdatomic-cloud uses 0.8.2xx. I have no idea why, but it tends to rely on old libs.#2019-04-2314:55Francescohello, is shadow-cljs providing any util in order to inject generated bundles/scripts in the html when using :module-hash-names?#2019-04-2315:00souenzzoshadow outputs manifest.edn next to main-<sha>.js You can use it do get the names#2019-04-2315:39lilactownthheller, awhile ago you said that the dependency graph for namespaces is there; is there any way I could get at it?#2019-04-2317:46thheller@lilactown (-> (shadow/get-config :the-build) (shadow/compile* {}) (:shadow.build/info))#2019-04-2317:47thhellercontains a :sources vector which has what they provided and required#2019-04-2317:47thhelleryou can build the graph from that#2019-04-2318:11lilactown😄 thanks! I'll try it out sometime soon#2019-04-2400:59caleb.macdonaldblackI recently removed project.clj and starting using only shadow-cljs.edn for my project. Since then, whenever I create a new test deftest I need to delete .shadow-cljs and restart shadow-cljs otherwise my new test is not detected. Any idea what's up with that? I'm using karma for my tests.#2019-04-2407:09orestisIs npm/node strictly needed to start a shadow build?#2019-04-2407:10orestis(Trying to run a release build on a CI server, would like to not install node just to kick-start shadow-cljs if it’s avoidable)#2019-04-2407:10orestisThough I guess I have to do npm install anyway right? So probably never mind 🙂#2019-04-2407:11thheller@orestis if you don't have any JS deps you can get away without node/npm. otherwise you'll need it#2019-04-2407:13thheller@caleb.macdonaldblack that sounds odd and I doubt that you really actually need to delete the .shadow-cljs folder and for the record DON'T delete the folder#2019-04-2407:13thhellerotherwise its impossible to track down what was wrong#2019-04-2407:13thhellerif I could make the folder undeleteable I would#2019-04-2407:15thhellerif you walk me through what you are doing I can maybe help?#2019-04-2408:45romain@thheller I really liked your post "What shadow-cljs is and isn't" 🙂. I think it would be good for newcomers and users a post about shadow cljs & figwheel. The latter is well known for clojurescript development but it might confuses people when choosing tools & solutions#2019-04-2408:46thheller@romain yeah I've been meaning to write a post like that but I have never used figwheel myself so I don't feel qualified to talk about it 😛#2019-04-2408:48thhellerI'm planning to write a couple more posts on that front though, just busy with other stuff currently#2019-04-2409:03romain@thheller Haha ok 🙂. When I wanted to do cljs after a long period, I saw shadow-cljs but I was wondering "eeh what about my figwheel? I don't understand how it will plug into" whereas shadow is a different entry in cljs world#2019-04-2409:05thhellerwell yeah the next post I sort of started writing is "hot-reload in shadow-cljs"#2019-04-2409:05thhellerthat'll certainly contain a section comparing to figwheel#2019-04-2409:05thhellerand hopefully make it clear that hot-reload is possible without figwheel 😉#2019-04-2409:14romainI should dive into shadow someday ^^'#2019-04-2412:00Robin JakobssonDoes anyone know what X Compilation failed. means, in regards to an imported npm project (`@ionic/react`)?#2019-04-2412:01thhellerdepends on the rest of the error?#2019-04-2412:02Robin Jakobssonit's followed by errors in file: /Users/robin/Code/my-project/node_modules/@ionic/core/dist/esm/es5/ionic.core.js#2019-04-2412:03thhellerI think thats using dynamic import which is not currently supported#2019-04-2412:04Robin Jakobssonahaaa, yes - I believe it does.#2019-04-2412:04Robin Jakobssonare there any known workarounds?#2019-04-2412:06thhellerI guess you have to use webpack#2019-04-2412:08Robin JakobssonOk! Thanks for the quick response, and for your work on shadow-cljs 👍 !#2019-04-2416:00eoliphanthi, I;m running into an issue with the “fannypack” react lib.
[:main] Build failure:
The required JS dependency "reakit/styled" is not available, it was required by "node_modules/fannypack/lib/styled/index.js".

Searched in:/Users/erichkoliphant/Dropbox/projects/fannypack-app/node_modules

You probably need to run:
  npm install reakit/styled
...
; the call in in the index.js file that's causing the issue

Object.defineProperty(exports, '__esModule', { value: true });

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var selector = require('./selector.js');
var space = require('./space.js');
var styled = require('reakit/styled');
Not exactly sure which flavor of JS weirdness is causing this particular issue
#2019-04-2416:21thheller@eoliphant I don't understand? thats a normal commonjs require. nothing special about it? do you have reakit installed? and made sure its the correct version?#2019-04-2416:26eoliphantyeah, after you walked through a few issues, with some other libs, I was looking for some of the more common things that pop up. But that “looks” ok. Yeah, reakit is installed, so I dunno, if there’s somethign else that’s hinky with their packaging, and I can do say ["reakit" :refer (styled)] in my code with no problem#2019-04-2416:29thhellercheck node_modules/reakit/package.json version and see if that matches the version fannypack expects#2019-04-2416:29thhellerI'm guessing it doesn't#2019-04-2416:30thheller["reakit" :refer (styled)] is not require("reakit/styled"). it would be ["reakit/styled" :as styled]#2019-04-2419:36eoliphantah right.. will check it out#2019-04-2420:11deplectquick question, is it possible to work with "local" jars with shadow-cljs#2019-04-2420:12deplectI am splitting some work between two projects, and am publishing to clojars, but want to develop locally#2019-04-2420:12deplecton the libs#2019-04-2420:12thhellerif you mean :local/root then you need deps.edn for that#2019-04-2420:13deplectlet me search for this in the docs#2019-04-2420:14deplectI believe that will do the trick, thanks @thheller!#2019-04-2420:47deplectI placed a deps.edn in my project root, and restarted the shadow-cljs process, it seems to still point to my .m2 directory. Doing something wrong? I have also defined the lib in de :dependencies section.#2019-04-2420:48deplect[io.monetashi/yesod "0.1.1"] in :dependencies#2019-04-2420:48deplect`{:deps {io.monetashi.yesod {:local/root "~/Sites/clojure/libs/io.monetashi.yesod"}}}` in deps.edn#2019-04-2420:49thheller@deplect if you have :deps in your shadow-cljs.edn config then :dependencies and :source-paths in shadow-cljs.edn have no effect#2019-04-2420:49thhellerif you just add a deps.edn that will have no effect. you need to tell shadow-cljs to actually use it.#2019-04-2420:50thhellerso either :deps true or :deps {:aliases [:cljs]} or so if you want to use a deps.edn profile.#2019-04-2420:50deplectok, thank you again#2019-04-2501:19Daniel HinesI’m developing an add-in for Excel. I’m currently on Mac, so my JS runtime appears to be an embedded Safari. When I load the page in Excel, Shadow tells me there was a websocket error. This is the only thing in the logs:
shadow-cljs: websocket error – Event
Selected Element
<html>…</html>
#2019-04-2501:19Daniel HinesAny ideas on how to troubleshoot this?#2019-04-2501:23Daniel HinesOh, this may be important: I’m serving the app over a different http server that’s using SSL (not using the built in shadow server)#2019-04-2501:31Daniel HinesProblem solved (or, sidestepped, anyway). I found out I didn’t need https in the first place. When served over http with shadows built in server, everything works fine.#2019-04-2507:31thhelleryeah if you serve over https you need to configure https for the shadow-cljs server as well#2019-04-2513:25deplectGoodday everybody, I am working on getting my tests running automatically on every change. The combintaion of shadow-cljs watch test and a :autorun true should allow for test to run automatically no? After rebuid#2019-04-2514:12thheller@deplect assuming you are using :target :node-test for the :test build config yes#2019-04-2514:49deplect@thheller yes I am using this, but no autotest on change. Now configured with an npm watch. Tried many combinations but did not succeed. The test do not run on a shadow-cljs watch test#2019-04-2514:50deplectIt this is not intended, I will try to get that working.#2019-04-2514:51thhellerwould help to see your config and test#2019-04-2514:51thhellerit is intended to work of course#2019-04-2514:52deplectI will post it as a gist one moment#2019-04-2514:52deplecthttps://gist.github.com/monetashi-io/9672604ad70621bfde7e090d67121b54#2019-04-2514:53thhelleroutput may be going to the wrong process if you have a shadow-cljs server instance running#2019-04-2514:53thhellernot sure that is managed properly#2019-04-2514:53deplectI have one watch dev running and a watch test#2019-04-2514:54deplectlet me close the watch dev#2019-04-2514:54thhelleryou can run shadow-cljs watch dev test to run two targets in one process#2019-04-2514:55deplect@thheller wonderfull, learning something everyday :-)😎#2019-04-2514:55thheller
;; remove :dev alias on production deploy
 :deps {:aliases [:dev]}
#2019-04-2514:55thhellershadow-cljs -A:dev watch dev test also conditionally sets the alias#2019-04-2514:56deplectthank you again @thheller, I discovered the -A flag but now can use it#2019-04-2514:57thhellerhmm yeah I tested. the :autorun process is directed to the wrong output#2019-04-2514:58deplectI get a test output when I run both dev and test#2019-04-2514:59deplectso seems to work here#2019-04-2514:59thhellerhttps://github.com/thheller/shadow-cljs/issues/487#2019-04-2515:35souenzzoHow to find why cljs.pprint is present in my final bundle?#2019-04-2515:37thheller@souenzzo open the UI at http://localhost:9630#2019-04-2515:37thhellerselect the build, compile it and there is a little util in the bottom#2019-04-2515:38thhellerselect box with all the namespace from the build#2019-04-2515:38thhellerselect cljs.pprint and it'll tell you who included it#2019-04-2515:39thhellerUI sucks but answers that question 😉#2019-04-2518:20tony.kaywhen upgrading from 2.8.3 to 2.8.33 I get a babel error on semantic-ui-react. I’ve tried pinning babel to the version in that library, but it doesn’t help…any ideas why this would break on this upgrade?#2019-04-2518:21tony.kayTrying versions in between. 2.8.20 seems to work#2019-04-2518:42tony.kaylooks like .26 was the latest version that worked#2019-04-2518:46tony.kayso it looks like .27 had some changes to configurability of babel…but I see no docs on it anywhere. Any suggestions on what options might fix it to work like .26?#2019-04-2519:49thheller@tony.kay please expand on "babel error" ... no clue what that means#2019-04-2519:50thhellerI indeed upgraded babel to a newer version so totally possible that something that worked before doesn't work anymore#2019-04-2519:51thhellersemantic-ui-react compiles and loads fine for me so some more details are required:P#2019-04-2520:07tony.kay@thheller
[:main] Compiling ...
/Users/tonykay/owsy/gondola-client/.shadow-cljs/babel-worker/babel-worker.js:3497
!0,Hg.Ya="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717",Hg.Hb=function(b){return Vb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers243717")};return new Hg(a,oe)}function Oi(a){try{var b=a[0];return b.l?b.l(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].qb(null),b;throw c;}}function Pi(a,b){b=Hi(b,Ni(function(c){a[2]=c;a[1]=4;return Oi(a)}));return z(b)?(a[2]=H(b),a[1]=4,vh):null}
                                                                                                                                                                                                                                                                                                                    ^

TypeError: Invalid value used as weak map key
    at WeakMap.set (<anonymous>)
    at d (/Users/tonykay/owsy/gondola-client/.shadow-cljs/babel-worker/babel-worker.js:1790:192)
#2019-04-2520:08tony.kay
babel failed?
{:file "/Users/tonykay/owsy/gondola-client/node_modules/semantic-ui-react/dist/es/lib/AutoControlledComponent.js"}
#2019-04-2520:09tony.kaybabel runtime installed is 7.3.1 in node_modules#2019-04-2520:09tony.kaySUI wants 7.1.2, and I’ve tried pinning that…but it does not seem to help#2019-04-2520:50thheller@tony.kay which semantic-ui version?#2019-04-2520:51thhellerI somehow doubt that this is related to the babel runtime since that is not what is compiling all of this#2019-04-2520:58martinklepschI'm having an interesting situation where a node script never exits despite clearly being done. But once I kill the shadow-cljs worker it exits.#2019-04-2520:59martinklepschAnd prints "REPL client disconnected"#2019-04-2521:00tony.kay@thheller semantic-ui-react 0.85.0#2019-04-2521:01tony.kaypackage.json is
{
  "dependencies": {
    "keycloak-js": "^4.8.3",
    "element-resize-detector": "^1.1.14",
    "intl-messageformat": "^2.2.0",
    "karma": "^4.0.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cljs-test": "^0.1.0",
    "lodash": "^4.17.11",
    "natives": "^1.1.6",
    "raven-js": "^3.25.2",
    "react": "^16.4.1",
    "react-autocomplete": "^1.8.1",
    "react-dom": "^16.4.1",
    "react-icons": "^2.2.7",
    "react-number-format": "^4.0.5",
    "react-transition-group": "^2.2.1",
    "reakit": "^0.11.2",
    "semantic-ui": "^2.3.1",
    "semantic-ui-react": "^0.85.0",
    "shadow-cljs": "2.8.26",
    "showdown": "^1.8.6"
  }
}
#2019-04-2521:02thheller@martinklepsch the websocket connection will keep the node process alive. set :devtools {:enabled false} if you want your process to exit when done.#2019-04-2521:04tony.kayinterestingly, there is this warning when using .26 of shadow (which works):
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/semantic-ui-react/dist/es/lib/AutoControlledComponent.js:269:2
 JSDoc annotations are not supported on return.
--------------------------------------------------------------------------------

#2019-04-2521:04tony.kaywhich is the same file that 27 barfs on#2019-04-2521:05thheller27 was the first version to use the babel v7 version I think#2019-04-2521:05martinklepsch@thheller thanks — what do I lose by disabling the devtools for a node script?#2019-04-2521:05thhellernothing if you didn't use them in the first place 😉#2019-04-2521:06thhellerwebsocket connection is providing the REPL and hot-reload stuff#2019-04-2521:06thhellerwhich is not very useful if you are building CLI type scripts#2019-04-2521:06thhellersince you actually want them to exit when done#2019-04-2521:07martinklepschright — I do use the node repl a lot but I guess that will still work...#2019-04-2521:07martinklepschthanks for the quick answer, much appreciated 🙌#2019-04-2521:13thhellerhmpf this is frustrating. the file compiles just fine for me without any issues#2019-04-2521:13thhellerha! no it fails#2019-04-2521:14thheller@tony.kay FWIW setting :js-options {:babel-preset-config {:safari 11}} fixes it. checking why it fails without config.#2019-04-2521:50currentooris there a way to start the server & watch all the builds?#2019-04-2521:50currentoorin one command#2019-04-2521:51thhellershadow-cljs watch all your builds#2019-04-2521:51currentoorcool#2019-04-2521:51currentoorthanks!#2019-04-2521:51thhellerthere should maybe be a --all switch or so. listing all the build ids may be tedious 😉#2019-04-2521:58thheller@tony.kay :js-options {:babel-preset-config {}} also fixes it ... I guess TypeError: Invalid value used as weak map key is the equiv of a NullPointerException#2019-04-2521:59thhellerwill release fix that doesn't pass null to babel shortly#2019-04-2521:59tony.kaycool, thanks 🙂#2019-04-2522:05thhellershould be fixed in 2.8.34#2019-04-2522:51tony.kayconfirmed working#2019-04-2522:51tony.kaythanks#2019-04-2603:17polymerisis it possible to set the nREPL port by build so I can have both tests and the browser target running at the same time?#2019-04-2606:35thheller@polymeris why would that require different ports? you can just open multiple connections?#2019-04-2614:48polymerisOh, just to avoid shadow-cljs complaining about the port already being bound#2019-04-2614:48thhellerwhat do you mean?#2019-04-2614:49thhellerthat only matters if the port conflicts with other projects? one project only needs one nrepl port and can serve many builds under that port?#2019-04-2614:52polymerisHmm, maybe I am doing it wrong. But I am running shadow-cljs watch browser and shadow-cljs watch test in parallel, and since they both try to use the same port for nREPL, one of them will complain#2019-04-2614:53thhellerok first of all it is fine to just run shadow-cljs watch browser test in one process#2019-04-2614:53polymerisohhh#2019-04-2614:53thhellerif you start shadow-cljs watch browser and shadow-cljs watch test at the same time manually#2019-04-2614:53thhellerthey both don't detect each other and start a "fresh" JVM instance each#2019-04-2614:53thhellershadow-cljs has a built-in server-mode which you are then not using#2019-04-2614:54thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_server_mode#2019-04-2614:54thhellerso you could also just run shadow-cljs server to let the server start#2019-04-2614:54thhellerand then run 2 separate watch instance that will just use the running server instead of starting their own JVM instances#2019-04-2614:55thhellerbut the easiest thing is probably just shadow-cljs watch browser test#2019-04-2614:55polymerisThat makes a lot of sense#2019-04-2614:55polymerisThanks!#2019-04-2606:41thhellerall builds can be running at the same time and you can either switch between the REPLs#2019-04-2606:42thhelleror open one connection per build#2019-04-2612:15Bravihello people. I'm trying to use react-pose (https://popmotion.io/pose/learn/popmotion-get-started/) with reagent through shadow-cljs 🙂 This might actually be a reagent question, but I thought I would start here Basically, the example says to do
const Box = posed.div();
and this is what I do in cljs
(:require ["react-pose" :default posed])


(def box (.div posed))
but then I cannot render this and I have tried the following ways:
[:> box]
[box]
(reagent/as-element [:> box]
#2019-04-2612:17thhellerand what doesn't work?#2019-04-2612:17thheller[:> box] should be what you need#2019-04-2612:18Bravi
env.cljs:191 error when calling lifecycle function one.core/start TypeError: Cannot convert a Symbol value to a string
#2019-04-2612:18Bravithis is what I get if I do that#2019-04-2612:21thheller@bravilogy that looks like you are maybe trying to print the result of that call?#2019-04-2612:21thhellerthat in general doesn't work for react elements#2019-04-2612:22BraviI'm trying to render it like you posted above 😞#2019-04-2612:22thhellerwhat do you do in one.core/start?#2019-04-2612:22thhelleris there a prn in there?#2019-04-2612:23Bravi
(defn start []
  (reagent/render-component [hello-world]
                            (. js/document (getElementById "app"))))
#2019-04-2612:23Bravi
(defn hello-world []
  [:> box])
#2019-04-2612:24thhellermaybe this isn't allowed and it needs an actual arg? (def box (.div posed))#2019-04-2612:24thheller(def box (.div posed #js {}))#2019-04-2612:25Braviok I'll play around with it some more#2019-04-2612:25Bravithank you#2019-04-2612:26BraviI can't find a nice react animation library that would worked great with reagent 😄#2019-04-2612:26BraviI tried react-spring as well, but since their new version is using hooks, it makes it difficult#2019-04-2612:28thhellerhmm yeah dunno what the plan for that is in reagent#2019-04-2617:10richiardiandreais anybody using shadow for AWS lambdas? Can I peek at your shadow-cljs.edn 😄 ?#2019-04-2617:46clojuregeeki'm following the example from the docs for shadow-cljs compile npm . .. no errors but when i try to use the package in node
> var x = require("shadow-cljs/demo.foo");
{ Error: Cannot find module 'shadow-cljs/demo.foo'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
#2019-04-2617:46clojuregeekany ideas?#2019-04-2619:03clojuregeeknevermind i figured it out, but i think i'll submit a PR to explain it for the next guy#2019-04-2619:37thheller@clojuregeek what was the issue? the :npm-module docs are a bit light and could definitely be improved#2019-04-2619:41clojuregeek@thheller the default shadow-cljs.edn has src/main whereas I has my files in src/demo/foo.cljs#2019-04-2619:41clojuregeekso i think it just needs to update if you are using the new shadowcljs.edn to set the src#2019-04-2619:42thhelleryeah#2019-04-2619:48thhellerfixed#2019-04-2619:56clojuregeekthanks 🙂#2019-04-2622:38martinklepsch@richiardiandrea using it with google cloud functions, happy to share if that would help#2019-04-2622:39richiardiandrea@martinklepsch thanks a lot! I think I have a good setup now:
{:source-paths ["lambda-src"]
 :builds {:aws {:target :node-library
                :exports {:handler ingest-events.aws/handler}
                :output-to "ingest-events/index.js"
                :js-options {:js-provider :shadow
                             :keep-native-requires true}
                :release {:compiler-options {:source-map true
                                             :optimizations :simple}}}}}
#2019-04-2622:39richiardiandreathis way I am producing a self-container index.js exposing the handler only#2019-04-2622:40martinklepschyeah, that's similar to what we're doing#2019-04-2622:40martinklepschwe use exports-var but not much of a difference#2019-04-2622:42richiardiandreacool awesome thank you again 😄#2019-04-2700:21wiseman@thheller hi! i’ve just started using shadow-cljs, and i love it! it’s just so fun and easy--it really shines in comparison to the clojurescript alternatives. i just wanted to let you know, and say thank you.#2019-04-2710:10deplectGoodday everybody, this is more of a general question in splitting up code in their own libs to be included in the main deps.edn as a dependency. In combination with the {:local/root "source-libs/io.monetashi.yesod"} option while in development.#2019-04-2710:11deplectNow is the question, when this library needs node modules, how do I ensure those are included when I build my main project in shadow-cljs?#2019-04-2710:12thheller@deplect in your lib you can include a deps.cljs with {:npm-deps {"the-dep" "version"}}#2019-04-2710:16deplect@thheller amazing, wonderful how this is structure. Find it hard to find this information online, on how to structure projects for code reuse. 🙏 🙏#2019-04-2710:17thhelleryeah. its a tough topic and I don't know what the best approach is myself#2019-04-2710:18thhellerI certainly have my own preferred way but there are too many other ways people do it#2019-04-2710:18thhellerso I don't want to force my way on everybody since the other ways are just as valid 😛#2019-04-2710:19deplectHahaha, yes, a few years back I was working in checkouts and something called lein voom. Worked ok, until it didn't. Whenever you write an article explaining your way I would be very interested 🙂#2019-04-2710:21thhellerit currently involves checkouts 😉#2019-04-2710:22thhellersometimes I just add :source-paths ["src/main" "../the-other-lib/src/main"]#2019-04-2710:23thhellerI have not adopted deps.edn at all because my main projects (work and shadow-cljs) have .java sources which deps.edn doesn't deal with#2019-04-2710:29thhellerI kinda like the checkouts approach to be honest since it is not committed to version control#2019-04-2710:35deplectdoes this also work with a shadow-cljs project, if I place my libs there using a deps.edn?#2019-04-2710:36thhellerno#2019-04-2710:36thhellerif you use deps.edn you only get what deps.edn provides#2019-04-2710:36thhellerif you use lein it would work#2019-04-2710:36deplectthey need to be leiningen projects, check#2019-04-2719:23wodinHi. I'm new to shadow-cljs. I quite like what I've seen of it so far, and it seems less magic to me than what I've tried in the past, although there's still lots I don't understand. I am now trying to convert a project using lein, figwheel, cljsbuild etc. to shadow-cljs, but I'm running into an error that I have not been able to figure out. I am using historian and I get the following error from the historian code when I try to compile: > Use of undeclared Var historian.core/off-the-record where off-THE-RECORD is a macro. This works fine using lein, so I'm not sure what's wrong. I've tried a few things, but I'm not really sure where to look. Any ideas? https://github.com/wodin/shadow-historian-test#2019-04-2720:02thheller@esiotrot hmm the macros are setup incorrectly in historian. it works because of this https://dev.clojure.org/jira/browse/CLJS-2454 which shadow-cljs sort of fixed#2019-04-2720:17wodin@thheller Thanks. So it's a bug in historian that just happens to work with lein?#2019-04-2720:18thhelleryeah kind of. macros in .cljc files are tricky about about 90% of the libs I looked it do it "wrong"#2019-04-2720:19thhellerrelying on certain "bugs" in the compiler to make it work#2019-04-2720:21thheller
(ns historian.core
  {:doc "Manage states for your atoms. (Easy undo/redo)"
   :author "Frozenlock"
   :quote "The present is the least important time we live in. --Alan Kay"}
  #?(:cljs (:require-macros [historian.core :refer (off-the-record)])))
#2019-04-2720:21thhellerthis should be the ns form in historian#2019-04-2720:22thhellerthen users of that lib would not need to worry about an extra :require-macros [historian.core] themselves#2019-04-2720:30wodinI actually tried using require-macros but was not able to get it to work. Thanks for the info.#2019-04-2720:32thhellerI'm debating whether or not I add support for this particular "bug". is the historian author "active"? would it be feasible to get a fix released quickly?#2019-04-2720:39wodinNo idea. Looks like the latest commit was 5 months ago.#2019-04-2720:41lilactownI've seen frozenlock on here in #clojurescript. Might be worth opening an issue or pinging him#2019-04-2721:02thhellerhttps://github.com/reagent-project/historian/pull/3#2019-04-2918:45stefanI believe I’ve followed the steps in the Quick Start section and everything looks to be working with the exception of nothing showing in the browser’s console log#2019-04-2918:46stefan#2019-04-2918:46stefanthis is my init function#2019-04-2919:08hoopeshttps://cljs.github.io/api/cljs.core/enable-console-printBANG did you try that function?#2019-04-2919:08hoopeslike right above the println#2019-04-2919:14stefanI get this error when I add that function Use of undeclared Var garray/clone#2019-04-2919:15stefanThe instructions I’m following are here https://github.com/thheller/shadow-cljs#quick-start#2019-04-2919:16stefandoesn’t specify the need to set anything up regarding logging though
#2019-04-2919:50talgiatWe’re having issues with upgrading to re-frame-10x latest version (0.4.0). When running the dev builds npm install is ran trying to install the specific versions in deps.cljs of re-frame-10x. I didn’t find an options to turn that off. I saw this issue on re-frame-10x https://github.com/Day8/re-frame-10x/issues/188 but not sure what’s the exact status.#2019-04-2920:21thheller@talgiat the install logic should only trigger if the dependency is not already in package.json?#2019-04-2920:21thhellerso if you have react in your package.json already it should not attempt to install react from deps.cljs?#2019-04-2920:23thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/npm_deps.clj#L201-L214#2019-04-2920:25talgiatyeah we have react in the deps#2019-04-2920:26talgiat#2019-04-2920:26talgiatstill tries to install#2019-04-2920:27talgiatwe do import the dependancies from leiningen#2019-04-2920:36stefan#2019-04-2920:37stefanso on save this code recompiles, and I see the shadow-cljs icon in the bottom left of the browser…but the page does not reload#2019-04-2920:37stefanIf I reload manually I see my changes#2019-04-2920:42thheller@talgiat it still triggers the install of the older version? it really shouldn't?#2019-04-2920:42talgiatYeah#2019-04-2920:43thheller@stefan.age you need to define an :dev/after-load hook that will re-render your page https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2019-04-2920:43thhellereg. (defn ^:dev/after-load init [] ...)#2019-04-2920:44thheller@talgiat it doesn't for me. do you have any weird path setups? eg. package.json not in the same directory as shadow-cljs.edn?#2019-04-2920:44stefanoh beautiful, thanks @thheller#2019-04-2920:45talgiatNo#2019-04-2920:45thhellerso the problem is that is installs an older version of react over the one you have already installed?#2019-04-2920:46talgiatYes#2019-04-2920:46talgiatI have package-lock as well#2019-04-2920:48thhellerso I just created a dummy new project, npm install react react-dom create-react-class manually to get latest version#2019-04-2920:49thhellerthen added re-frame-10x dep and started shadow-cljs#2019-04-2920:49thheller
shadow-cljs - dependencies updated
NPM dependency "react" has installed version "^16.8.6"
"16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.8.6"
"16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
NPM dependency "create-react-class" has installed version "^15.6.3"
"15.6.2" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
running: npm install --save 
#2019-04-2920:49thhelleras expected it only installs what it should?#2019-04-2920:50thheller
{
  "name": "deps-cljs-test",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "shadow-cljs": "2.8.35"
  },
  "dependencies": {
    "create-react-class": "^15.6.3",
    "highlight.js": "^9.12.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-flip-move": "^3.0.1",
    "react-highlight.js": "^1.0.7"
  }
}
#2019-04-2920:51thhellerafter the install#2019-04-2920:51thhellerthe next start still complains about the version conflicts but besides that everything is fine and no install is triggered?#2019-04-2920:51thheller
$ shadow-cljs server
shadow-cljs - config: /mnt/c/Users/thheller/tmp/deps-cljs-test/shadow-cljs.edn  cli version: 2.8.35  node: v10.13.0
NPM dependency "react" has installed version "^16.8.6"
"16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.8.6"
"16.3.0" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
NPM dependency "create-react-class" has installed version "^15.6.3"
"15.6.2" was required by jar:file:/home/thheller/.m2/repository/day8/re-frame/re-frame-10x/0.4.0/re-frame-10x-0.4.0.jar!/deps.cljs
[2019-04-29 20:50:58.607 - WARNING] TCP Port 9630 in use.
[2019-04-29 20:50:58.612 - WARNING] TCP Port 9631 in use.
[2019-04-29 20:50:58.617 - WARNING] TCP Port 9632 in use.
shadow-cljs - server version: 2.8.35 running at 
shadow-cljs - nREPL server started on port 57985
#2019-04-3000:12talgiatyeah why it installs in the first place?#2019-04-3000:12talgiatalso it installs an older version of hightlight.js#2019-04-3000:12talgiatI thought that if the package is installed it should not complain#2019-04-3007:37thheller@talgiat there seems to be a misunderstanding here? it installs exactly the versions that it should https://github.com/Day8/re-frame-10x/blob/master/src/deps.cljs#2019-04-3007:37thhellerit does NOT install the dependencies you already had listed#2019-04-3007:38thhellerit only complains ...#2019-04-3007:38thhellerI can remove the warnings since I guess they are annoying but everything is working as intended here#2019-04-3007:38thhellerif you have any different behaviour and see an actual running: npm install --save + react etc then that is a bug#2019-04-3013:57sundbpIt seems if I put proxy info in the HOME/.shadow-cljs/config.edn file it isn't picked up. Does that seem plausible? Same info in the shadow-cljs.edn file and all is ok#2019-04-3014:26sundbp@thheller are the proxy settings supposed to be read from that file?#2019-04-3014:30sundbpAh. Needed to be under :maven, found it by searching source.#2019-04-3014:59Heikki HämäläinenDoes any one know a working example for minimal AWS Clojurescript shadowcljs Lambda which makes https requests? I have unfortunately problems to get different http clients to work when deploying lambdas. I have tried cljs-https where I am getting “errorMessage”: “Cannot find module ‘xmlhttprequest’” when running in AWS. Running local Node works just fine. Also aws-sdk works quite well. The problems start in AWS after adding cljs-http client. If anyone is interested to help me, I have pushed minimal cljs-app to github which contains the code which I have tried. https://github.com/hjhamala/shadow-cljs-lambda-test/blob/master/create-job/src/core.cljs#2019-04-3015:16thheller@heikki.hamalainen what is the problem? I don't have any of the serverless stuff installed so I can't run your example. maybe I can help if you tell me the errors?#2019-04-3015:16thheller“errorMessage”: “Cannot find module ‘xmlhttprequest’” did you try npm install xmlhttprequest?#2019-04-3015:18Heikki Hämäläinen#2019-04-3015:19thheller"Cannot find module 'xhr2'" this is the message node gives if node_modules/xhr2 doesn't exist#2019-04-3015:19thhellersame for xmlhttprequest#2019-04-3015:27Heikki Hämäläinen@thheller You are a life saver 🙂 Now I understand. shadow-cljs release app does not add node_modules to target directory. I just zipped the target and didn understand the need to add node_modules also. AWS-SDK is most likely included in Lambda runtime so it worked without it. I am beginner in clojurescript so I assumed that target contains full software package like lein uberjar.#2019-04-3015:29thhellerthere is currently experimental support for creating completely standalone .js files but that wouldn't work with cljs-http since it does a "dynamic" (js/require "xmlhttprequest") which this wouldn't cover#2019-04-3015:29thhellerhttps://github.com/thheller/shadow-cljs/issues/290#2019-04-3015:30thhellerbut just including node_modules is the more reliable option for now#2019-04-3015:30Heikki HämäläinenOk, thank for your quick response. Problem solved and development can continue 🙂#2019-04-3021:18talgiat@thheller adding highlight.js fixed that. I think the warning printing is a bit confusing, so removing it will be nice#2019-04-3021:37damienHi all, quick question wrt shadow-cljs on React Native. I understand how JS interop works via npm from the docs, but is there also anything that would prevent me from using Reagent's :> syntax for importing and wrapping existing React components? Our UI team has a nice set of elements that I would like to reuse.#2019-04-3021:40thheller@damienstanton you can use them just fine there is just one issue currently in that importing them might be tricky#2019-04-3021:40thhellerdepends on how the components are written. plain JS would be easy, JSX/flow/ts etc make things harder#2019-04-3021:42damienSounds good then - they are plain JS, with no external jsx templates or cross-compilation with TS/etc.#2019-04-3021:43thhelleryou can try https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-04-3021:43thhellerthings are really easy if you just put the JS modules into node_modules though#2019-04-3021:44thhellersince then metro can deal with the importing and you aren't limited by what shadow-cljs may not support#2019-04-3021:44damienperfect, I think this is exactly what I need. Thanks @thheller!#2019-04-3023:41caleb.macdonaldblackHi I'm having issues getting karma to detect additional tests. With my current configuration I have shadow watching and karma running. If I change or delete tests, they're detected by karma and it logs them fine. However when I add a new test karma does not detect or log the new test. I have to delete .shadow-cljs to get it to detect it. Here is a bare bones repo of my configuration where I can replicate the issue on my machine: https://github.com/CalebMacdonaldBlack/shadow-karma-example#2019-04-3023:45caleb.macdonaldblackbrowser tests refresh fine, however I prefer karma because I don't need to use the browser console to see my log statements and I get nice diffs#2019-05-0108:54thheller@caleb.macdonaldblack that was indeed a bug. fixed in 2.8.36.#2019-05-0109:00caleb.macdonaldblackThanks, that fixed it. 👍#2019-05-0116:38lilactownmy asset-path needs to change depending on where it's deployed. - locally: /assets/app/js - deployed on server: /some-path/assets/app/js before we were doing something silly: had it configured to be ../assets/app/js this worked until we added a child route 😛 /some-path/foo/bar breaks it any advice?#2019-05-0116:43polymerisIs it an option to move the local assets to /some-path?#2019-05-0116:44lilactownI'm considering that now but it would be annoying to have to support different behavior in code like that#2019-05-0117:29thheller@lilactown :asset-path "/assets/app/js" :release {:asset-path "/some-path/assets/js"}?#2019-05-0117:29thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-05-0117:30thhellershadow-cljs release app --config-merge '{:asset-path "somewhere/else"}'#2019-05-0117:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2019-05-0117:36anmonteirodo reload hooks need to be configured in the entry point namespace?#2019-05-0117:37thhellerno they can be anywhere#2019-05-0117:37anmonteiroI’m probably doing something wrong because shadow is telling me no :after-reload hooks are configured#2019-05-0117:37anmonteirorelevant config:#2019-05-0117:38anmonteiro
:widget {:target :browser
                   :dev {:output-dir "resources/static/js/widget"
                         :asset-path "/static/js/widget"}
                   :release {:output-dir "widget"}
                   :devtools {:after-load ladder.reconciler/live-reload!
                              :watch-dir "resources"}
                   :modules {:main {:entries [ladder.widget.ui]
                                    :init-fn ladder.widget.ui/run}}}
#2019-05-0117:39thhellerI would recommend using the metadata always nowadays but it should be fine? assuming of course that the ladder.reconciler ns is actually included in the build?#2019-05-0117:40anmonteiroit definitely is#2019-05-0117:40anmonteiroit’s clearly not fine 🙂#2019-05-0117:40anmonteiro#2019-05-0117:40thhellerdoes the name actually match?#2019-05-0117:40anmonteirolol#2019-05-0117:40anmonteironice#2019-05-0117:41anmonteiroyeah that namespace doesn’t exist…#2019-05-0117:41anmonteiromy bad#2019-05-0117:41thhellerhehe config could probably validate that after compile 😛#2019-05-0117:45thhellerhttps://github.com/thheller/shadow-cljs/issues/493#2019-05-0120:36richiardiandreado you folks think that shadow-cljs could successfully be compiled by the GraalVM compiler?#2019-05-0121:07lilactownp sure the CLJS compiler uses eval for macros#2019-05-0121:22thheller@richiardiandrea no that will never be possible#2019-05-0121:22thhellerwell shouldn't say never probably but in its current form it is not possible to load and compile code inside a native image#2019-05-0121:23thhellerso shadow-cljs could in theory be compiled to a native image#2019-05-0121:23thhellerbut it couldn't load any other depdencencies or macro code#2019-05-0121:24thhellerat least thats my understanding of the current limitations of native-image#2019-05-0122:08richiardiandreaI don't enough either 😄 There use to be a problem with dynamically change class loaders but a tool like shadow probably should not do that (unless it does 😃)#2019-05-0122:53caleb.macdonaldblack@thheller Does shadow-cljs automatically attempt to install missing cljsjs npm packages?#2019-05-0208:02thhelleronly those that actually properly declare their npm dependencies which most of them don't do#2019-05-0123:11polymerisWhat would the advantage be of compiling with GraalVM? If you want independence from the JVM, self-hosting would probably be easier? (relatively speaking, I am sure it's not "easy", either)#2019-05-0123:14richiardiandrea@polymeris the advantage is mainly startup time. The Cljs compiler is inevitably tied to the JVM now and I don't think this will change in the future. So the only other thing you can do as of this point in time is GraalVM#2019-05-0208:02thheller@richiardiandrea shadow-cljs doesn't do any classloader magic BUT once native-image is compiled you can't change the classpath at all#2019-05-0208:03thhellerso you could create a native-image on the client after all :dependencies were configured but that is completely impractical#2019-05-0208:03thhellerstartup time really isn't much of a factor if you use server mode properly#2019-05-0216:12richiardiandreaWill except that my colleagues always complain when CI is slow 😄 but maybe that it more of a people's problem#2019-05-0216:14thhellercaching makes a big diff. do you have that setup properly?#2019-05-0216:15richiardiandreaIn CI no, unfortunately we were on Azure#2019-05-0216:16richiardiandreaThey are slowly adding it to Azure so maybe soon this problem will go away#2019-05-0216:17thhellerno clue how azure CI works but if you can persist some state between builds it should be easy#2019-05-0216:19thhellertypical CI caching is pretty shitty for this actually since it usually just takes a hash of some file which isn't enough#2019-05-0216:20thhellerjust some disk space that you can store stuff on would be enough#2019-05-0216:32richiardiandreayeah I think I will need to do that#2019-05-0208:04thhellerappcds can cut it by 50% almost but has the same classpath limitations#2019-05-0208:04thhellerI experimented with adding a shadow-cljs appcds command to the create archive#2019-05-0208:04thhellerbut that takes a couple min to create#2019-05-0208:04thhellerso for that time to pay of you kinda have to start shadow-cljs 20x or so#2019-05-0216:13richiardiandreaIt would be worth adding it for CI builds#2019-05-0208:05thhellerso I decided not to add it#2019-05-0214:25deplectI noticed something in the version 2.8.33 when trying to load multiple aliases like shadow-cljs -A:dev -A:nrepl this works with clj. It only takes the last from what I can deduce. Is there some trick to get them both to load?#2019-05-0214:25thhellershadow-cljs -A:dev:nrepl should work#2019-05-0214:26deplectyes! Thanks again @thheller 😎#2019-05-0215:37StefanHi guys, got myself an interesting challenge again. I’m trying to write a React Native app that uses WebAudio. From what I’ve been able to find, this requires using a native webview in my app, for which I use the react-native-webview (https://github.com/react-native-community/react-native-webview) module. The API of that web view requires that Javascript is injected into it as a string. I want that to be ClojureScript, so I want to use shadow-cljs to compile the clojurescript to javascript, in my app read that javascript file and inject its contents into the webview. So my question is: can I tell shadow-cljs somehow to output everything in a single file, even in dev mode, instead of the multitude of files that are created by default?#2019-05-0215:41thhellerit might not work but try setting :devtools {:loader-mode :eval} in the build config#2019-05-0215:42thhellerand you'll probably need to use compile not watch to create the audio build#2019-05-0215:42thhellersomehow doubtful that the life reload stuff would work#2019-05-0215:48StefanThanks @thheller I’ll give it a shot. I was not expecting the live reload to work for the audio part. It would be extremely cool to have a REPL in there though, that would beat any JS dev tool out there for embedded web views 🙂#2019-05-0215:49Stefan(What does this “loader-mode” do, do you have documentation for it?)#2019-05-0215:49thhellermaybe it works .. depends on what the webview can do (ie. websocket)#2019-05-0215:50thhellerhttps://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-05-0217:42wiseman@heikki.hamalainen i don’t know if your issue is completely resolved, or if this helps, but i don’t use a dynamic require with cljs-http and xhr2: https://github.com/r0man/cljs-http/issues/94#issuecomment-426442569#2019-05-0217:43wiseman(though i’ve stopped using cljs-http because of https://github.com/r0man/cljs-http/issues/121)#2019-05-0316:18ennCan somebody help me understand why I need a watch to run a REPL? (Or maybe I'm misunderstanding that requirement?)#2019-05-0316:18ennI'm having difficulty understanding the different options--`clj-repl`, cljs-repl, node-repl#2019-05-0316:19ennnode-repl seems like what I want but I don't understand what "It has access to all your code via the usual means." in the docs means.#2019-05-0316:43lilactown@enn what are you trying to do? develop an app? just play at the REPL?#2019-05-0316:48enn@lilactown I am trying to develop an AWS Lambda node function. I need one dependency loaded (the AWS JS SDK).#2019-05-0316:49ennI don't have any Clojurescript background, only Clojure. Most of the documentation I can find presumes a level of familiarity with third-party tools (node, npm, yarn) that I do not have.#2019-05-0316:50enn(In production, the AWS lambda runtime automatically has the AWS SDK available, as I understand it. But I would like to also have it available locally in an instance with a REPL so I can iterate on my code without needing to deploy constantly)#2019-05-0316:52lilactowngotcha#2019-05-0316:53lilactownso CLJS is different than Clojure, in that the process that takes Clojure code and turns it into something the platform executes is separate from the process it actually evaluates in#2019-05-0316:54lilactownso the typical way of working on an application is to have a watch running (which is compiling your ClojureScript code) and a Node.js process running which is connected to that watch.#2019-05-0316:55lilactownyour REPL code then would go through that same compilation process before being sent to the Node.js process to be evaluated#2019-05-0316:55ennI think it's that third point that I am most confused about#2019-05-0316:56ennhow do I get a REPL where that compilation will happen?#2019-05-0316:57thheller@enn shadow-cljs node-repl and then (require '["aws-sdk" :as aws]) should get you started without any watch#2019-05-0316:57thhellerwatch is only required if you have an actual build you want to do#2019-05-0316:57thhellerif you just want the normal REPL workflow like you'd do in CLJ node-repl is fine#2019-05-0316:58ennI get this error:
[0:0]~cljs.user=> (require '["aws-sdk" :as aws])
repl/require failed { Error: ENOENT: no such file or directory, open '/Users/elinaeher/clubhouse/backend/salesforce-lambda/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$aws_sdk.js'
#2019-05-0316:59lilactownyou will need to run npm i aws-sdk in the local directory#2019-05-0317:00thhellerhmm odd#2019-05-0317:00thhellerhow "wrong" is that path?#2019-05-0317:00thheller/Users/elinaeher/clubhouse/backend/salesforce-lambda is that your project directory?#2019-05-0317:00ennyes#2019-05-0317:01thhellerhmm the node repl should make sure that the file exists before trying to load it?#2019-05-0317:02thhellercan you check the contents of the /Users/elinaeher/clubhouse/backend/salesforce-lambda/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime directory? it should have a bunch of .js files?#2019-05-0317:02ennafter installing aws-sdk with node I am able to require it in the CLI repl. If I connect with CIDER though I am not in a clojurescript repl and it doesn't work#2019-05-0317:02enn@thheller there is a bunch of js in there but I don't see anything that looks like AWS#2019-05-0317:03thhellershadow.js.shim.module$aws_sdk.js well that would be the only one#2019-05-0317:03enneverything starts with cljs, goog, shadow, or clojure#2019-05-0317:03ennah I do see that#2019-05-0317:04thhellerhmm so the file exists but node doesn't find it?#2019-05-0317:04thhellerare you one a weird network drive or some other non-standard filesystem that maybe doesn't like the $?#2019-05-0317:05ennnope#2019-05-0317:06lilactownbut it's working now right?#2019-05-0317:06ennwell kind of#2019-05-0317:07ennnot in the nrepl#2019-05-0317:07ennonly in the CLI repl#2019-05-0317:07ennI'm fine doing the watch workflow if that is a better way to do this#2019-05-0317:07ennjust as long as I can get a REPL where I can run my code interactively#2019-05-0317:07thhellerthats no different really#2019-05-0317:07ennok#2019-05-0317:08thhellerwhat is your nrepl setup? do you use lein/deps.edn or just plain shadow-cljs.edn?#2019-05-0317:08ennin this repo I just have a minimal shadow-cljs.edn#2019-05-0317:09thhellerI know basically nothing about CIDER so if things works without it I can't help much#2019-05-0317:09thhellerdid you try https://shadow-cljs.github.io/docs/UsersGuide.html#cider ?#2019-05-0317:10ennI have tried basically that flow ... I don't understand this part though: https://shadow-cljs.github.io/docs/UsersGuide.html#_connect_the_javascript_environment#2019-05-0317:10enn> If you haven’t already done so, connect a JavaScript runtime to the shadow-cljs server. For example, for browser development, browse to http://localhost:8080. What would the node equivalent be?#2019-05-0317:11thhellerwell ... M-x cider-connect-sibling-cljs I have no clue what that does#2019-05-0317:11thhelleryou can just run shadow-cljs node-repl separately and select the :node-repl build in cider#2019-05-0317:12thhelleror run (shadow.cljs.devtools.api/node-repl) in the cider CLJ REPL#2019-05-0317:12thhellerbut I have absolutely no clue how cider handles nrepl sessions and such#2019-05-0317:12ennok#2019-05-0317:17justinbarclayI don’t think it’s cider-connect-sibling-cljs he wants, but cider-connect-cljs https://cider.readthedocs.io/en/latest/clojurescript/#using-shadow-cljs#2019-05-0317:17ennLeaving CIDER out of it for now, I am still having problems connecting a watch and a repl#2019-05-0317:18enn
$ shadow-cljs watch app
shadow-cljs - config: /Users/elinaeher/clubhouse/backend/salesforce-lambda/shadow-cljs.edn  cli version: 2.8.36  node: v8.11.3
shadow-cljs - server version: 2.8.36 running at 
shadow-cljs - nREPL server started on port 61441
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (44 files, 2 compiled, 0 warnings, 1.24s)
$ shadow-cljs cljs-repl app
shadow-cljs - config: /Users/elinaeher/clubhouse/backend/salesforce-lambda/shadow-cljs.edn  cli version: 2.8.36  node: v11.12.0
shadow-cljs - connected to server
[1:1]~cljs.user=> (require '["aws-sdk" :as aws])
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
[1:1]~cljs.user=>
#2019-05-0317:19thhellerwatch doesn't manage your node process. so you need to run node <the-output-to>.js manually#2019-05-0317:19ennaha#2019-05-0317:20ennDo I need to restart node when the output file changes or does node automatically reload?#2019-05-0321:13richiardiandreaWhat does reload mean in this context, do you want to launch the process again? If that's the case then Thomas' solution is the best (or use nodemon). However if you want more of a REPL-driven development you can keep the process going and shadow will reload the namespaces for you. Am I right @thheller? Hopefully 😃#2019-05-0317:21thhellernode doesn't reload anything. you can tell shadow-cljs to reload via the hooks#2019-05-0317:21thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2019-05-0317:22lilactownto use node-repl with cider: 1. run shadow-cljs node-repl 2. wait for nREPL server started on port <x> 3. In Emacs, M-x cider-connect and do localhost, port <x> 4. Once in the CLJ REPL, run (shadow/repl :node-repl)#2019-05-0317:26ennOK. That works, but CIDER does not register that it is a CLJS REPL. However, if I start it with cider-jack-in-cljs per the link that @emoarmy posted, and run node target/main.js separately, it does work and CIDER does pick on it being a CLJS REPL. Thank you for your help, everyone.#2019-05-0318:40jjttjjI'm using a PixelBook with Google's linux VM "Crostini". I believe I need browsers to use penguin.linux.test as a host instead of localhost for websocket connections. Is there setting that I can use to change the websocket host with shadow-cljs?#2019-05-0318:41thheller@jjttjj browser build?#2019-05-0318:41jjttjjyes#2019-05-0318:41thhellerthe browser build will default to connecting to the host you used to access the page#2019-05-0318:42thhellerso if you use it should be using that host as well?#2019-05-0318:42jjttjjok great, that works, thank you!#2019-05-0318:43thhelleryou can also configure it but if that works its probably the easiest way#2019-05-0318:44jjttjjyeah this is probably best thank you#2019-05-0415:30StefanCan shadow-cljs support a module like this in a react-native target? https://github.com/IgorBelyayev/React-Native-Local-Resource#2019-05-0622:12denikGIVE THIS MAN MORE STARS #2019-05-0415:32thhellernot sure I understand what that does but looks like a native module so shadow-cljs has nothing to do with that#2019-05-0415:32thhellerbut you kinda don't need it#2019-05-0415:32thhellersee https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-05-0419:39Stefan> Don’t include 5mb of text this way, load it at runtime instead. I guess that rules my use case out, the compiled JS code that I want to load is already 4.5mb and I hardly have any code of my own yet 😉#2019-05-0419:40thhellerI guess its less of an issue in react-native since its just loading locally#2019-05-0419:43StefanThat’s true. Everything ends up in the app bundle one way or another.#2019-05-0415:33thhelleryou can use that other thing too though#2019-05-0415:33thhellerjust use (js/require "./my_resource.txt")#2019-05-0415:34Stefanahhh js/require right#2019-05-0415:34thhellerjust need to adjust the path properly#2019-05-0415:34thhellerso probably (js/require "../my_resource.txt") or so#2019-05-0415:34thhellerdepends on where you keep the file#2019-05-0415:35StefanCool thanks! I’ll also check the other method you mentioned! :+1:#2019-05-0415:36Stefan(In this case the file that I’ll be reading is the output of another shadow-cljs target 🙂 )#2019-05-0415:36thhellerright. how is that going? 😛#2019-05-0415:38StefanStill plodding along 🙂 I’m going to write a blog post about this when I’m done, titled something like “the 42 things I learned this holiday about react native, webviews, web audio in react native, and doing all that using clojurescript” 🙂#2019-05-0417:04AlexanderHey folks – I'm trying to get browser hot loading and the browser REPL working when shadow is running behind a secure HTTPS -> HTTP proxy (nginx w/proxy_pass). My app loads over https:// but tries to connect the primary server's websocket using ws://, which causes a mixed content error. Is there a way to get a wss:// scheme without telling shadow to handle the SSL itself (because it's already behind a secure proxy)?#2019-05-0417:06thheller@alexander_clojurians https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2019-05-0620:21martinklepsch@thheller on the proxy support stuff (I'm working with Alexander) — with the :devtools-url parameter we can get things to work but it's a little impractical in the context of every developer having their own URL and reading this configuration from the environment before starting shadow-cljs. We were wondering if it might make sense to default to wss:// if the devtools are loaded on a page that already uses https://? This would cover our use case without additional configuration and might be a reasonable default? Could be this breaks something else of course but just wanted to give a bit more context on the situation.#2019-05-0621:49thhellerthe issue is that by default shadow-cljs connects to itself#2019-05-0621:50thhellerso it'll connect to #2019-05-0621:50thhellerif it connects to that'll fail if shadow-cljs has no ssl configured#2019-05-0621:50thhelleryou can just configure ssl in shadow-cljs then it'll use wss anyways#2019-05-0621:51thhellerbut that depends on having access to the cert#2019-05-0621:51thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_ssl#2019-05-0622:52martinklepschright, in this case shadow doesn't have access to the cert because it sits behind a proxy that shadow doesn't know about#2019-05-0622:53martinklepschI see how the https -> wss default could break things though so I guess we'll configure things using the devtools url option#2019-05-0622:55thhellerIf you can think of something that would work for your case I can take a look at implementing it#2019-05-0622:55thhellerjust not sure what your setup and problem is#2019-05-0623:17martinklepschWe run shadow locally behind something custom (similar to ngrok) that forwards shadow's ports. The idea is that you can access that on other devices or that coworkers can access it from anywhere. The server is nginx with custom certs set up. Shadow does not know about these certs. This is intentional since we still want to be able to access things via localhost. In the case of a request going through nginx https:// is used but with out the devtools-url Shadow will try to use ws:// which causes "insecure content" errors. Does this clarify things a bit more?#2019-05-0623:21thhellerso by default it will connect to the document hostname + server port#2019-05-0623:22thhellerso if you open it'll connect to #2019-05-0623:22thhellerhmm just setting the port doesn't work though#2019-05-0623:23thhellerwhy does everyone need a custom :devtools-url?#2019-05-0623:23thhelleryou could just add a local hosts entry and use a hostname isntead of ip?#2019-05-0623:31martinklepschI'm not sure I understand the hosts suggestion. Not 100% if relevant but we'd have an instance of this application for every coworker, each with a different public URL#2019-05-0623:32thhellerah ok#2019-05-0623:33martinklepsch> if it connects to that'll fail if shadow-cljs has no ssl configured I think my thinking here is: if shadow is loaded on an https:// page — wouldn't it make sense to assume the websocket connection should also use wss://. In fact in most browsers it just won't work otherwise due to insecure content restrictions, I think?#2019-05-0623:33thhelleras I explained .. it can't#2019-05-0623:34thhellerthe issue is that shadow-cljs connects to itself DIRECTLY. it does not go through your nginx#2019-05-0623:34thhellerthats what :devtools-url is for .. it tells it where to connect to instead#2019-05-0623:34martinklepschahh, so it doesn't use whatever is in the URL bar and will always use localhost?#2019-05-0623:34martinklepschIs that what you're saying? That might be where my confusion is coming from 😅#2019-05-0623:34thhellerit does use the URL from the document#2019-05-0623:34thhellerjust not the port#2019-05-0623:35thhellerthe default is using document.location.hostname#2019-05-0623:35thhellerand it adds the server port#2019-05-0623:35thhellerso becomes #2019-05-0623:35martinklepschright, we expose that server port as shadow expects it#2019-05-0623:35thhellersince wouldn't answer the websockets#2019-05-0623:37martinklepschright — so if it takes the hostname, it could also take the protocol?#2019-05-0623:37thhelleryou are not listening to me 😛#2019-05-0623:37martinklepsch(sorry if I'm asking naive questions, just trying to wrap my head around this)#2019-05-0623:37martinklepsch😄#2019-05-0623:37martinklepschsorry 🙂#2019-05-0623:37thhellerit cannot take the protocol because it cannot connect to since that has no ssl configured#2019-05-0623:38martinklepschright, but in our case it has 😄#2019-05-0623:38martinklepschbecause we proxy stuff through to shadow#2019-05-0623:38thhellerhmm?#2019-05-0623:38thhelleryou proxy 9630?#2019-05-0623:39thhellerI'm confused now ... I was assuming your proxy is serving the normal document. so or whatever that is, ie. port 443#2019-05-0623:41martinklepschyes, it's doing that but it's also proxying 9630 otherwise the document served under https:// couldn't connect to that port#2019-05-0623:41thhellerI'm so confused right now#2019-05-0623:42martinklepschsorry, I'll come back in a minute with better details#2019-05-0623:42martinklepschthanks for all your help and sorry this is a bit confusing 😄#2019-05-0623:43thhelleryou have configured an additional server that only acts as a proxy#2019-05-0623:43thhellerso forwards port 443 AND 9630 to someone elses machine?#2019-05-0623:44thhellerand as well#2019-05-0623:44martinklepschyes. in practice both ports forward to a port on localhost and those ports are ssh forwarded to a local machine#2019-05-0623:44thhellerbut both foo and bar are running the same shadow-cljs build?#2019-05-0623:45martinklepschno, foo and bar might be shadow-cljs builds on two different machines (i.e. people's computers)#2019-05-0623:45thhellerno what I mean is the same config is used for those builds?#2019-05-0623:45martinklepschah, yes#2019-05-0623:46thhellerthats why :devtools-url is a problem in the first place?#2019-05-0623:46martinklepschwhat we'd have to do with how things work now is have a different devtools-url for each machine (arguably could be much worse)#2019-05-0623:46martinklepschyes#2019-05-0623:46martinklepschsounds like we're approaching shared understanding 🎉#2019-05-0623:46thhellerok. so I can add a simple :force-ssl option so it just uses wss#2019-05-0623:47thhellersince now ssl is dependent on having ssl configured in shadow-cljs#2019-05-0623:47martinklepschyeah, that's kind of what we were thinking of but it should only force SSL if the document is loaded via https#2019-05-0623:47martinklepschbecause for local dev we will still mostly want to use basic localhost stuff#2019-05-0623:48thhellerhttps://github.com/thheller/shadow-cljs/blob/a784a335e0fb5e01936cb5e222d62cf12ac7ff19/src/main/shadow/cljs/devtools/client/env.cljs#L45-L66#2019-05-0623:50martinklepschright, I guess we'd need to customize the (when ssl ,,,) somehow so that it also takes the document's protocol into account#2019-05-0623:50thhellerwell you could just set it directly 😉#2019-05-0623:51thhellerI'll figure out a way to do this tomorrow 😛#2019-05-0623:52martinklepschyou mean set ssl via goog-define?#2019-05-0623:52martinklepschawesome! no urgency to this to feel free to sit on it for a bit 🙂#2019-05-0623:53martinklepschGood night & thanks again 🙌#2019-05-0623:54thhellerhttps://github.com/thheller/shadow-cljs/issues/496#2019-05-0417:35Alexander@thheller thank you, that helped#2019-05-0418:06Stefan@thheller I’ve been following this channel for a while now. Would it be an idea to add a troubleshooting / FAQ section to your user manual?#2019-05-0418:07thhelleryou tell me 😉 I rarely read the docs myself 😛#2019-05-0418:08Stefanhehe I didn’t expect you would need to 😉#2019-05-0418:10StefanDon’t get me wrong, I think the manual is very good. It’s really complete and has a lot of detail. I feel that it can be even better somehow, I’m just not sure exactly how. Maybe it’s because I’m a beginner in CLJ(S).#2019-05-0704:31Jonif those conversation happen on GitHub issues, people would find them with Google..#2019-05-0704:32JonGoogle is the entry for FAQ.#2019-05-0418:10thhellerIt can most definitely be better .. just takes a large amount of time and I also suck at writing#2019-05-0418:11thhellerso any suggestions are welcome#2019-05-0418:11thhelleroftentimes the problem is that you don't know what you are looking for
#2019-05-0418:11thhellerso having such a huge document doesn't help#2019-05-0418:14StefanI think for me it’s maybe about the “information density” of the document. I’ll give it a thought.#2019-05-0418:15StefanOh by the way the fact that it’s a one page document is awesome, it makes it very easy to search for things.#2019-05-0418:37thhellerif you know what you are searching for yes 😉#2019-05-0419:33lilactownI was thinking the other day about having a search bar at the top and maybe some additional organization / tagging to enable searchability#2019-05-0419:33lilactowntypically what I do is open up the user guide, Ctrl-F what I’m looking for, if I don’t find it I come ask here 😛#2019-05-0419:38StefanYeah me too, but indeed sometimes it is hard to know what exactly you’re looking for, especially as a beginner.#2019-05-0419:48raymcdermottI’m trying to get {:js-provider :shadow} working and hitting a few weirdo deps issues#2019-05-0419:49raymcdermottfor example a library is calling require to throw an error but shadow insists the lib must be installed#2019-05-0419:49thhellerhmm?#2019-05-0419:49raymcdermott#2019-05-0419:49raymcdermottis there a way to ignore it?#2019-05-0419:50thhelleryou can use :keep-as-require #{"crypto"} (in :js-options)#2019-05-0419:51raymcdermottoh, cool - thanks#2019-05-0419:52thhelleris crypto not a built-in for node? maybe its missing from my list#2019-05-0419:52thhellerhmm wait is this for the browser?#2019-05-0419:52thhelleror the one-file node thing?#2019-05-0419:53raymcdermottit’s for node, but yes it’s built in for node but not for earlier versions#2019-05-0419:53thhellerhmm weird its in the list though#2019-05-0419:53thhellerhttps://github.com/thheller/shadow-cljs/blob/7bf19e30ae34929d971569de75b000cf281bb81d/src/main/shadow/build/resolve.clj#L75#2019-05-0419:54thhellerso :keep-as-require shouldn't do anything since its already in that set#2019-05-0419:54raymcdermottyou’re right, same problem#2019-05-0419:54raymcdermottthis is what I have….#2019-05-0419:55raymcdermott#2019-05-0419:55thhellerwell maybe its just actually missing the crypto.randomBytes?#2019-05-0419:55thhelleroh you are missing the imporant bit#2019-05-0419:55thheller:keep-native-requires true in :js-options#2019-05-0419:56thhellerotherwise it'll actually try to bundle everything#2019-05-0419:56thheller(and in the crypto case use a polyfill package)#2019-05-0419:58raymcdermottI want it to bundle as much as needed - I can’t access npm in the deployed environment#2019-05-0419:59raymcdermottbut OK I’ll add that in#2019-05-0420:05thhelleryes but its want you want#2019-05-0420:06thhellernative requires are just the node built-in packages so you don't need npm for that#2019-05-0420:06thhellerwithout :keep-native-requires it works like the browser which wouldn't have access to node built-ins so they need to be bundled too#2019-05-0420:07raymcdermottah ok … I am a bad manual reader 🙂#2019-05-0420:07thhellerwell its an alpha experimental everything will break kind of feature 😉#2019-05-0420:08raymcdermottyeah, it’s not playing out that well in real time#2019-05-0420:08thhelleryou can just use the normal shadow-cljs stuff without :js-provider :shadow and post process the file with something like https://github.com/zeit/ncc#2019-05-0420:09thhellerthats probably a lot more reliable in practice#2019-05-0420:09raymcdermottok, good to know - thanks#2019-05-0420:25Stefan@thheller I think I just managed to load the code generated by my :browser target into a React Native Webview. I just injected the code, I’m not yet calling it. Would you expect that it is running a repl client (or what is the term)? Should I be able to connect to it, and if yes: how?#2019-05-0420:29thhellerREPL requires that watch is running#2019-05-0420:29thhellerand you probably need to configure :devtools-url since the default browser logic won't work https://shadow-cljs.github.io/docs/UsersGuide.html#_proxy_support#2019-05-0420:30thheller:devtools-url "" or whatever your ip is#2019-05-0420:31thhellerno clue what the webview is capable of though#2019-05-0420:32thhellertry gaining access to the console output if possible#2019-05-0420:32StefanThe webview should be the whole thing, the same thing that is powering Chrome/Safari, so websockets etc should be available#2019-05-0420:32thhellerso you can see if something is logged#2019-05-0420:32StefanYeah well that’s not easy. I think I’ll have to use reactortron or something for that.#2019-05-0420:33StefanFor debugging purposes I’m now just appending html to document.body.innerHTML 🙂#2019-05-0420:34StefanActually reactortron won’t help either because it won’t redirect console.log output#2019-05-0420:37StefanOh my it’s even easier than I imagined 🙂 🙂 🙂 It’s running a repl allright and I can simply use shadow-cljs cljs-repl to connect. Hurray! 🎉#2019-05-0420:38StefanBeat that, react-devtools, ha!#2019-05-0420:39StefanDid I mention shadow-cljs and you are awesome?! 🙂#2019-05-0422:18polymerisHello A JS library I am trying to use (in the browser) is throwing with Uncaught TypeError: process.nextTick is not a function. I know next to nothing about JS/node/etc, so I might be wrong, but from what I gather, process is a node global that exposes that function, and shadow does mock part of that global which it then passes to the library when it's required: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js#L55 It does, however not mock or polyfill nextTick. So my question is: Can I monkey-patch shadow.js.process? How? Or can I somehow replace the whole process thing with a polyfill from webpack/browserify or similar? (I think the library is designed to run with webpack)#2019-05-0422:20polymeris(i'd rather not add webpack to the build chain if I can avoid it)#2019-05-0422:23thhellerhmm yeah looks like my "ported" version of process is out of date#2019-05-0422:24thhelleryou can just monkey patch it in your code via (gobj/set shadow.js/process "nextTick" js/goog.async.nextTick) or so#2019-05-0422:26thhellermight need to do it in a namespace that is required before the JS code#2019-05-0422:26thhellerin case the JS uses it directly on load#2019-05-0422:29polymerisThank you, I'll try that!#2019-05-0422:30thhellerdon't forgot to require goog.async.nextTick and shadow.js in the namespace that does that#2019-05-0501:01polymerisIt seems to help, thank you. The error went away, haven't checked if it is behaving correctly.#2019-05-0508:07raymcdermott@thheller hey Thomas, just want to say thanks for the ncc tip - it’s a life saver and would have been a tough tool for me to find independently#2019-05-0508:45Stefan@thheller The solution I was so happy about yesterday is working on iOS, but not on Android; I’m getting “failed to load” errors for every line SHADOW_ENV.evalLoad("shadow.animate.js", true , "goog.provide [...] (from the file compiled with :devtools {:loader-mode :eval}). I’m not sure how to get more details about this error, I have gotten this by changing console.log to add its argument to document.body.innerHTML… Does this ring any bells? Any hints?#2019-05-0508:46thhellerwell why did it fail to load? there should be more info#2019-05-0508:46thhellerconsole.warn("failed to load", path, e);#2019-05-0508:46thhellermaybe you do not capture all of those args#2019-05-0508:47thhellerneed to know what e is#2019-05-0508:47Stefanright i’ll try#2019-05-0508:49Stefanpath is the first parameter to evalLoad; e is empty… (`JSON.stringify(arguments)` yields {"0":"failed to load","1":"audio.engine.js","2":{}})#2019-05-0508:50thheller
try {
      goog.globalEval(code);
    } catch (e) {
      console.warn("failed to load", path, e);
    }
#2019-05-0508:51thhellerit might just not be stringify-able. try accessing e.message or e.stack#2019-05-0508:53Stefanmessage: “goog.provide is not a function”. This function is in fact in the javascript string, I checked…#2019-05-0508:55StefanEarlier I noticed another difference between iOS and Android webview. Not sure if related. When I declare functions and inject them into the webview (using injectedJavaScript), I could not call them directly on Android. As a work-around I assigned them to the document (e.g. document.play = play) and then called document.play(), that worked…#2019-05-0508:55StefanIn other words: maybe something about the scope where these functions are declared in or something?#2019-05-0509:01thhellerhmm thats odd. appears like the global scope is different from the scope that loaded the initial file#2019-05-0509:02Stefan#2019-05-0509:04thhelleryou can change the generated output#2019-05-0509:04thhellerand swap the goog.globalEval(code); with just eval(code);#2019-05-0509:05thhellerthat might work#2019-05-0509:05StefanEverywhere you mean I guess?#2019-05-0509:05thhellerit only occurs once#2019-05-0509:06thhellereval is weird if you can't eval in the global scope#2019-05-0509:09StefanI see a couple of invocations (inside if (!COMPILED && goog.defineClass.SEAL_CLASS_INSTANCES). I’ll tinker a bit with it. I gotta do some family stuff, can’t delay anymore 😕 I’ll try later.#2019-05-0509:09thheller
try {
      goog.globalEval(code);
    } catch (e) {
      console.warn("failed to load", path, e);
    }
#2019-05-0509:09thhellerthis part ... that only occurs once#2019-05-0509:10StefanYes indeed, thanks#2019-05-0509:11Stefan#2019-05-0509:12StefanMaybe I commented out too many of those SHADOW_ENV.evalLoad.#2019-05-0509:13StefanNo that wasn’t it.#2019-05-0509:14thhellerits a different error at least#2019-05-0509:17StefanThere’s some more when I uncomment all code again.#2019-05-0509:17Stefan#2019-05-0509:17thhellerwell you can't comment out anything#2019-05-0509:17thhellerthey all need to be loaded#2019-05-0509:17thhellerso if one fails they all fail#2019-05-0509:17StefanYeah I was just seeing what would happen#2019-05-0509:18StefanThe last screenshot is with everything loaded again#2019-05-0509:18thhelleryeah as I said .. if one fails they all fail#2019-05-0509:18thhellerand the first fails because the scope isn't right#2019-05-0509:19thhellerI don't know why the scope is different or how is different compared to the android version#2019-05-0509:19thhellerand I can't dig into it#2019-05-0509:20StefanI understand, know that you have confirmed that that is likely indeed the problem, I’ll investigate further. I’ll let you know; thanks!#2019-05-0602:06steveb8nQ: I’m struggling with interop to https://github.com/FezVrasta/react-popper. Does anyone have sample code for this? I have it working for an older version but I want to use the latest and I can’t get the react refs working properly in reagent#2019-05-0602:31lilactownrender props are pretty difficult to use in reagent#2019-05-0602:45lilactownthis worked for me:
(ns popper-example.core
  (:require [reagent.core :as r]
             ["react-popper" :as rp]
             [applied-science.js-interop :as j]))

(defn popper-example []
  [:> rp/Manager
   [:> rp/Reference
    (fn [props]
      (let [ref (j/get props :ref)]
        (r/as-element [:button {:type "button" :ref ref}
                       "Reference element"])))]
   [:> rp/Popper {:placement "right"}
    (fn [props]
      (let [{:keys [ref style placement arrowProps]} (j/lookup props)]
        (r/as-element [:div {:ref ref :style style :data-placement placement}
                       "Popper element"
                       [:div {:ref (j/get arrowProps :ref)
                              :style (j/get arrowProps :style)}]])))]])

(r/render [popper-example] (.getElementById js/document "app"))
#2019-05-0603:06steveb8nWorked first time. Thanks a lot!#2019-05-0603:52steveb8n@U4YGF4NGM any chance you’d be willing to show me how to style it (using Emotion I presume). That’s not obvious either#2019-05-0603:53steveb8nI worked out emotion styling for react-select but this is very different#2019-05-0603:59steveb8nI also found https://github.com/bwalex/verktyg but I’d prefer to avoid another dep if it’s not too much interop#2019-05-0604:02lilactownSeems straight forward. Pass in classes / styles to the elements you render in the render prop#2019-05-0604:10steveb8nyes it should be but I don’t do js interop much so the incantation is not obvious to me#2019-05-0604:11steveb8nI’ll keep trying#2019-05-0604:24steveb8nok. got it. I see what you mean. sorry for the noise#2019-05-0604:38lilactown No problem! duckie #2019-05-0602:45lilactown@steveb8n#2019-05-0610:57teawaterwireI always forget why we need the global and local installation of shadow-cljs?
$ npm install --save-dev shadow-cljs
$ npm install -g shadow-cljs
#2019-05-0611:50thheller@teawaterwire you don't need the global install#2019-05-0611:50thhelleryou only need it if you want to use shadow-cljs ... instead of npx shadow-cljs ...#2019-05-0612:29teawaterwiremakes sense, thanks!#2019-05-0611:51thhelleryou need it in the project to ensure that other dependencies are installed in the project#2019-05-0611:51thhelleralso to make your project reproducible and not rely on some global install#2019-05-0612:12hlolli@thheller I read somewhere that you tried getting react-native hot reloading to work without expo, was it a struggle, you think it's possible to implement?#2019-05-0612:14Stefan@hlolli Maybe you read my posts here about it? I had trouble with it because I also wanted to use “React Native Navigation” (from Wix). With Thomas’ help I was able to get it working, see https://github.com/svdo/CLJSReactNativeNavigation. With normal react-native stuff it should just work with shadow-cljs, no difficulties that I know of.#2019-05-0612:16hlolli@stefan.van.den.oord nice! There have been no difficulties so for, I can turn on "Live Reload" on the iPhone simulator, but I can't see if the websockets are connecting.#2019-05-0612:16StefanYou actually don’t need to turn “live reload” or “hot reloading” on in the simulator; shadow-cljs uses a different mechanism for live reloading.#2019-05-0612:17hlolliok good to know, it's a new territory for me, I'll pop up some questions after digging trough your code 🙂 thanks again#2019-05-0612:18StefanSure but remember that my code is needlessly complicated if you’re not using React Native Navigation…#2019-05-0613:34thheller@hlolli the "complicated" bit was only that react-native wants a react component class registered as the root#2019-05-0613:34thhellerand that doesn't mix too well with hot-reloading because we can't swap it after#2019-05-0613:35thhellerwith a bit of hackery it is easy to overcome though. see https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L59#2019-05-0614:37hlollido you enable something in the simulator, because I'm using this code character by character, and a nested compinent isn't updating, except via CMD+R#2019-05-0614:38thhellerdefine nested component?#2019-05-0614:39hlolliA react component that's not root but a child#2019-05-0614:40hlolliso child component is probably a better lingo?#2019-05-0614:40thheller
(defn start
  {:dev/after-load true}
  []
  (render-root (r/as-element [root])))
#2019-05-0614:40thhelleryou have this right?#2019-05-0614:40hlolliyes, exactly this#2019-05-0614:40thheller
(defn root []
  [:> rn/View {:style (.-container styles)}
   [:> rn/Text {:style (.-title styles)} "Hello!"]
   [:> rn/Image {:source splash-img :style {:width 200 :height 200}}]])
#2019-05-0614:40thhellerand here you render something new?#2019-05-0614:41thhellerit should update just fine ... with the same caveats react usually has of course#2019-05-0614:41hlolliah, ok, maybe it's because my root is routes#2019-05-0614:42hlollithere were same caveats with the react-native-router, going to look better at the repo which @stefan.van.den.oord sent me#2019-05-0614:42thhellerin this design it MUST be a function. it cannot be anything else#2019-05-0614:42thhelleryeah the router thing had multiple roots which we had to work arround#2019-05-0614:42hlolliyes it's a function#2019-05-0614:42hlolliok, I'll noise down for now 🙂 looking into this#2019-05-0614:42hlollithanks#2019-05-0613:36thhellerits basically the same code I used for expo https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/expo.cljs#2019-05-0613:48lilactownI wonder if that will get better soon. I know the RN team is working on a re-architecture and supporting more modern React development practices#2019-05-0613:49thhellerI'm pretty much done with react so I don't care anymore 😛#2019-05-0613:49thhellerthe hack works well enough though so it doesn't really matter#2019-05-0613:51lilactownlol! what are you eschewing React for now these days?#2019-05-0613:52thhellerwell .. in true lisp fashion I wrote my own thing of course 😉#2019-05-0613:52lilactown😄#2019-05-0613:53thhellerI was never quite happy with react but told myself that the value of react is in the ecosystem not react itself#2019-05-0613:53thhellerthat entire argument went out the window with hooks#2019-05-0613:54lilactownoh?#2019-05-0613:54thhellerwell ... its changing everything and is even for unfriendly for CLJS than components were#2019-05-0613:55thhellercan't change equality semantics of the inputs check so forever doomed to work around it#2019-05-0613:55lilactowninteresting#2019-05-0613:55thhellercan't use hooks within components either so have to replace everything with something new#2019-05-0613:55thhellerwhen I'm doing that anyway I can get rid of react entirely in the process#2019-05-0613:56thhellerof course thats not something you should ever do if you actually care about 3rd party react components#2019-05-0613:56thhellerI don't ... 🙂#2019-05-0613:56lilactown😄#2019-05-0613:56lilactownI see your points#2019-05-0613:58thhellerof course my thing might fail completely and I may just go back to React ...#2019-05-0613:58thhellerbut I started building a new app and tried to do so with hooks and I don't like the experience one bit#2019-05-0613:59lilactownthat’s the fun bit. I think there’s plenty of places to explore outside of the React model#2019-05-0613:59lilactownSvelte, Ember, Phoenix LiveView are all things I’m watching. it would be interesting to explore those in a CLJ(S) way.#2019-05-0613:59lilactownespecially LiveView#2019-05-0613:59thhellerI have sort of a hybrid of svelte and react#2019-05-0614:00thhellerperformance close to svelte but programming model of react#2019-05-0614:00thhellerI'll probably write a blog post about the ideas behind it#2019-05-0614:00lilactownif we could leverage more static analysis of CLJS code it would be pretty cool to see the kind of compile-time tricks we could play with it#2019-05-0614:01thhellerI think they are worth talking about#2019-05-0614:01lilactownthat would be really cool!#2019-05-0614:01thhelleryeah macros are a super power here#2019-05-0614:02lilactownright. we have the tool chain built into the language. seems like we should be able to leverage that far better than the JS ecosystem#2019-05-0614:02thhellerbut the real killer is protocols 🙂#2019-05-0614:02lilactownhow do protocols help in this case?#2019-05-0614:03thhellerI'll explain in the blog post#2019-05-0614:04lilactownwhat a tease 😂#2019-05-0614:04thhelleryou can do magic stuff if your main constraint isn't create ReactElement objects 🙂#2019-05-0614:04lilactowngotcha#2019-05-0614:04lilactownyes, ReactElements are annoying because you can’t extend them without extending js/Object#2019-05-0614:06lilactownno idea if that’s what you’re talking about, but I just remember running into issues when I first started building hx since I wanted to build it using only protocols. funnily, the lack of OO-ness in React internals bites us#2019-05-0614:07lilactownplus I wanted to do weird things like datafy and nav React elements, React components#2019-05-0614:07thhellerprotocols with react make no sense yeah#2019-05-0614:07lilactownI’m also curious, the dislike of the Hooks experience: was that using hx? anything in particular you didn’t like other than the equality semantics?#2019-05-0614:08thhellerno my own thing I did the benchmarks for a week ago or so#2019-05-0614:08lilactownah, I thought that was this new thing#2019-05-0614:08thhellerhttps://gist.github.com/thheller/106db0c13c221be3793b481f7a4eb8bc see shadow-render#2019-05-0614:09thhellerwell I have been building "my own thing" for 5 years now#2019-05-0614:09thhellernever anything worth talking about and typically just got deleted 😉#2019-05-0614:10thhellerbut this one seems different enough and so far is more promising than all other attempts combined#2019-05-0614:10lilactownI’m very interested now#2019-05-0614:12thhellerdon't hold your breath .. these experiments don't have a high survival rate 😉#2019-05-0614:13lilactownhahaha. well, I’m just interested in trying to get outside of my React box in general#2019-05-0614:13thhellerbut the protocol thing seems worth talking about as a concept for react alternatives in CLJS#2019-05-0614:13lilactownI think I’m becoming myopic in my view of web dev lately#2019-05-0614:14lilactownI kinda realized after debating with yogthos for the billionth time about React that maybe I need to chill and take a wider view of what’s out there#2019-05-0614:15thheller
(defprotocol IConstruct
  (as-managed [this env]))

(defprotocol IManageNodes
  (dom-insert [this parent anchor])
  (dom-first [this]))

(defprotocol IUpdatable
  (supports? [this next])
  (dom-sync! [this next]))
#2019-05-0614:15thhellertease 😛#2019-05-0614:15thhelleryeah the CLJS world sometimes looks like there is only React#2019-05-0614:16thhellerwhich I used to think is a good thing .. now not so much anymore#2019-05-0614:17lilactownyeah#2019-05-0614:17thhellereveryone used to make fun of angular when v1 wasn't compatible with v2#2019-05-0614:18thhellerbut react with hooks isn't much better when you can't use them in class components#2019-05-0614:18lilactowneh I think it’s much better than v1 to v2#2019-05-0614:18lilactownangular was a whole-app thing. class components and react hooks can live side-by-side in the project#2019-05-0614:18thhelleryeah not really#2019-05-0614:18lilactownyou just have to choose#2019-05-0614:19lilactownwhen you create an individual component#2019-05-0614:19thhellersay you move your state management stuff into a hook#2019-05-0614:19thhellernow you have to rewrite all your class components that used the old way#2019-05-0614:19lilactownhm. I would move it into context, and then each component can consume it in whatever way is best#2019-05-0614:20thhellerright .. context sssssssuuuuuuuuuuuuuuuuucks with class components 😛#2019-05-0614:20lilactownex. for class components, you might use a context Consumer component#2019-05-0614:20lilactown😅 yeah I hate the function-as-child pattern, especially compared to hooks#2019-05-0614:21thhelleryeah context with hooks is good#2019-05-0614:21lilactownan HoC is a thing to help clean up the boilerplate#2019-05-0614:21lilactownI see your point that it makes it so that you essentially split your development paths: one API for class components, one API for hooks#2019-05-0614:22thhellerHoC ... yeah where was this site that listed the react trees of doom? 😛#2019-05-0614:22lilactownbut it’s still much better than angular v1 to v2#2019-05-0614:23lilactownI was moving to React after angular v1.4 and saw the explosion in my rear-view mirror 😎#2019-05-0614:23thhelleryeah maybe I exaggerated a bit ... still to me it felt like writing in a new fragmework#2019-05-0614:23thhellerdidn't feel like the previous react anymore#2019-05-0614:23thhelleralso simple things like (react/useState {:hello "world"}) deeply offend me#2019-05-0614:24thhellersince the map is just gonna be thrown away after the first render#2019-05-0614:25thhellerso I did (def init-state {:hello "world"}) and (react/useState init-state)#2019-05-0614:25thhellerwhen then started to look like a component again 😛#2019-05-0614:26thhellerdunno ... the problem I have with hooks is really just about the inputs array#2019-05-0614:26lilactown😄 yes. there are pros and cons to returning a closure (like reagent does) vs creating the closure implicitly like React does#2019-05-0614:26thhellerand how it doesn't fit with cljs types#2019-05-0614:27thhellermaybe we get access to the lower level APIs some day .. that would be nice#2019-05-0614:27lilactownI actually think it’s fine#2019-05-0614:27thhellerbut ... I wouldn't count on it so I'm out#2019-05-0614:27lilactownthe inputs array was a red herring (IMO) I chased for like a couple weeks#2019-05-0614:28lilactownfundamentally you have the exact same problems using any aggregate JS value#2019-05-0614:29lilactownI ended up creating a useValue hook that handles clojure equality for things like deps, but in practice I haven’t used it. https://github.com/Lokeh/hx/blob/master/src/hx/hooks.cljs#L108#2019-05-0614:29thhellerthe nice thing is since we have hicchup as a basis switching between frameworks doesn't mean throwing away your entire HTML 🙂#2019-05-0614:30lilactownv true 😄#2019-05-0614:31thheller[:div.card {:on-click [::inc]} foo]#2019-05-0614:31thhellerI also wanted declarative events ... 😉#2019-05-0614:31lilactownthat looks slick#2019-05-0614:34lilactownbut yeah, IMO the inputs deps are the wrong place to optimize. I think we want to optimize by memoizing components and efficient state updates. if you maintain referential identity (e.g. aren’t passing in literals every render) then you can take advantage of the tools the same way JS React does#2019-05-0614:34thhellerquite the opposite. if you do it wrong everything will be slow.#2019-05-0614:35thhellerso you have to think about the from the start#2019-05-0614:35lilactownI think that React kind of helps you do it right by convention, no?#2019-05-0614:36lilactownfor example, you rarely are doing something like (useEffect foo [{:bar "baz"}])#2019-05-0614:36thheller(let [ev-handler (react/useMemo #(handle-some-event clojure-data) #js [clojure-data])] ...)#2019-05-0614:36thhellerdoesn't work#2019-05-0614:36lilactownit does though#2019-05-0614:37thhellerit does only if the clojure-data is actually identical?#2019-05-0614:37thhellereg. if its something you got from props it isn't#2019-05-0614:38lilactownright, which is (IME) usually the case#2019-05-0614:38thhellerwell it fulcro style apps it is#2019-05-0614:39lilactownthat depends. if you’re re-creating the clojure data on every render, then yes it’s not going to memoize correctly#2019-05-0614:39thhellerI'm over optimizing here .. I know that its not a big deal#2019-05-0614:39thhellerits just one of those things ...#2019-05-0614:39lilactownin my experience, I’m usually depending on something that is in useState or a callback function#2019-05-0614:40lilactownthe former case, identical? works great. the latter case, there’s useCallback (gross but it’s a solution)#2019-05-0614:40lilactownI think it is a big deal. these things can sink the UX of an app#2019-05-0614:41lilactownone day your app is slow and you have to optimize 10,000 places 😬 that’s not fun#2019-05-0614:42lilactownI think it’s kind of annoying in that it is making us all think about how to leverage immutability again#2019-05-0614:43lilactownwe had it kinda figured out with class components + sCU, and reagent and Om went a long way to covering it up (for me at least)#2019-05-0614:43lilactownnow we gotta figure it out again. and it’s kinda turning out that it’s more about following React idioms than using actual immutable data#2019-05-0614:45lilactownI think that even if we could customize the equality, that we would find out that all the places where we were doing deep equality of clojure data would be a bottleneck as well and end up optimizing it the same way we are now 😛#2019-05-0614:45lilactownanyway, sorry, I’ll stop ranting. I need to learn to shutup more..#2019-05-0614:46thhellerone issue is also that all library hooks are going to use JS objects#2019-05-0614:47lilactownit’s annoying yeah.#2019-05-0614:48thhellerso just things like const props = useSpring({opacity: 1, from: {opacity: 0}}) already suck#2019-05-0614:48lilactownwhat’s actually more annoying is how good mhuebert’s js-interop lib is#2019-05-0614:48lilactownI think I’m going to throw out parts of hx and use it instead 😛#2019-05-0614:48thhelleryeah .. worth adding to core imho#2019-05-0614:49lilactowndefinitely. I imagine they won’t, but holy crap is it good#2019-05-0614:49thhellerwell I don't quite think the extra symbol syntax is needed#2019-05-0614:49lilactownand it helps a lot with what you’re saying. but I agree that CLJS-native hooks are always better#2019-05-0614:49thhellerbut still nice regardless#2019-05-0614:49lilactownI mostly just appreciate the lookup#2019-05-0706:38ouvasamHi, I am trying to add handsontable on my project but get some errors. I did install it via :
npm install handsontable @handsontable/react
` and get the following errors
[:app] Build failure:
The required JS dependency "core-js/library/fn/object/get-prototype-of" is not available, it was required by "node_modules/babel-runtime/core-js/object/get-prototype-of.js".

Searched in:..../webapp/node_modules

You probably need to run:
  npm install core-js/library/fn/object/get-prototype-of

See: 
Did someone face the same problem ?
#2019-05-0706:54thheller@ouvasam this is likely caused by a version conflict on the core-js lib#2019-05-0706:54ouvasamThanks thheller. DO you know if there is a way to resolve this?#2019-05-0706:55thhellercheck which version is in node_modules/core-js/package.json#2019-05-0706:55thhellerand then which version node_modules/@handsontable/react/package.json depends on#2019-05-0706:55thhellerthen might need to add the core-js version that the table thing wants to your own package.json dependencies#2019-05-0707:00ouvasamThere are two packages installed handsontable and @handsontable/react. The one that cause the problem is handsontable. When installed it install the /cdn-cgi/l/email-protection dependency. I did do yarn add /cdn-cgi/l/email-protection which is the one specifed in the hadnsontable/packages.json but the problem is the same#2019-05-0707:01thhellermake sure that node_modules/core-js/package.json is actually the correct version you want#2019-05-0707:02ouvasamIt is#2019-05-0707:03ouvasamBut there is another one in babel-runtime which is 2.4.0#2019-05-0707:03thhellershadow-cljs doesn't used nested installs#2019-05-0707:03thhellerso only node_modules/core-js matters#2019-05-0707:03thhellerbut yeah you need the matching version#2019-05-0707:04thheller> The required JS dependency "core-js/library/fn/object/get-prototype-of" is not available, it was required by "node_modules/babel-runtime/core-js/object/get-prototype-of.js"#2019-05-0707:04thhellerso might need to match babel-runtime too#2019-05-0707:07ouvasamSeems to be good if i do yarn add /cdn-cgi/l/email-protection#2019-05-0707:07ouvasamMany thanks !
#2019-05-0707:36ouvasamThe problem now is that handsontable require core-js 3.0.0 and i get the following error
[:app] Build failure:
The required JS dependency "core-js/modules/es.object.get-own-property-descriptor" is not available, it was required by "node_modules/handsontable/commonjs/index.js".

Searched in:/..../webapp/node_modules

You probably need to run:
  npm install core-js/modules/es.object.get-own-property-descriptor

See: 
`
#2019-05-0707:48ouvasamIs it possible to install multiple version of core-js ?#2019-05-0707:54thhellerno#2019-05-0707:56ouvasamDo you know if there is a workaround for this ? babel-runtime require 2.4 and handsontable require 3.0.0#2019-05-0707:56thhellerfigure out who uses babel-runtime and upgrade trhat#2019-05-0715:43macrobartfastin way over my head here as I desperately avoid starting a new big project in vanilla react...#2019-05-0715:44macrobartfastbut definitely not clear on how I can have a re-frame/shadow/figwheel type setup.#2019-05-0715:44macrobartfastdo all those things play together, or are there better alternatives to some of those things that do?#2019-05-0715:44macrobartfastre-frame and figwheel (in emacs via cider) are just what I'm used to.#2019-05-0715:45macrobartfastthe rabbit holes are getting bigger.#2019-05-0715:59lilactownre-frame is a CLJS library so no problems there#2019-05-0716:00lilactownshadow-cljs fills the role of figwheel and leiningen (or deps.cli, whatever dependency manager you were using)#2019-05-0716:02lilactownwhat I do when I start a project:
mkdir my-app
npm init
npm i -D shadow-cljs
npx shadow-cljs init
Open up the shadow-cljs.edn file in Emacs, then add a basic build for whatever platform I need. e.g. a browser build: https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser
#2019-05-0716:02lilactownyou can also add any dependency coordinates to the shadow-cljs.edn file like reagent, re-frame#2019-05-0716:03lilactownif you're using reagent, you'll also need to install react via NPM: npm i react react-dom create-react-class#2019-05-0716:04lilactown@macrobartfast if this is a bit much, this might be helpful: https://github.com/shadow-cljs/quickstart-browser#2019-05-0716:05lilactownit's using quite an outdated version of shadow-cljs, so you'll want to bump that in the package.json. but everything else should work fine 🙂#2019-05-0719:46ennWhen I start an nREPL server (using shadow-cljs server), and have my build running (using node target/output.js), I can connect and interact with the REPL with CIDER. However, all output (e.g. from println) goes to the node process instead of the REPL. Is there any way I can force output to go to the REPL for debugging?#2019-05-0719:54lilactownnot for Node.js atm#2019-05-0719:55lilactownAFAIK#2019-05-0720:08ennOK, thanks--helpful to know that so I don't spend time messing with my config.#2019-05-0808:31teawaterwireWe're scratching our heads on this one:#2019-05-0808:34teawaterwirewe put together a minimal repo with only the Portis javascript package. We run shadow watch etc and when we open the browser console we get this error. Their compiled cdn version works, so they suggest it's coming from our build tools (shadow) https://github.com/multis/shadow-portis-test#2019-05-0808:40teawaterwireversion with their cdn bundle: https://github.com/multis/shadow-portis-test/commit/a887f49ad2724301920bf0cd87fc3baf6663faa8 — it works#2019-05-0809:58teawaterwirewe will use the cdn way https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global but still wondering what's happening when we include it in the package 😅#2019-05-0810:15teawaterwirecdn resolve works https://github.com/multis/shadow-portis-test/tree/cdn-resolve#2019-05-0813:25teawaterwireWould it be because of the way we require the package?
const Portis = require('@portis/web3');
->>
(:require ["@portis/web3" :as Portis])
#2019-05-0813:50lilactown@teawaterwire when I changed the import to ["@portis/web3/es" :default Portis] it works#2019-05-0813:51lilactownit seems that shadow-cljs is pulling in the UMD bundle by default, and there’s some problem with that#2019-05-0813:51lilactownnot sure why#2019-05-0820:01teawaterwireI'm still confused 😄#2019-05-0820:16natePortis seems to define its browser field to be "browser": "umd/index.js", https://docs.npmjs.com/files/package.json#browser#2019-05-0907:48teawaterwireCould this be an incompatibility between Typescript export vs shadow require ?#2019-05-0907:49thhellershadow-cljs by default uses browser or main. You can configure it to use module instead but that has .. issues ...#2019-05-0907:49thhellerI can look into the portis thing later ...#2019-05-0907:56teawaterwirethat'd be amazing 🙂 — we spent the entire day yesterday on it, and we're running out of ideas 😅#2019-05-0908:36thhellerI took a quick look but have absolutely no clue what is going on#2019-05-0908:36thhellerif the /es version works just use that#2019-05-0908:44teawaterwireunfortunately when we use the /es version in our real app we have issues with missing nested deps [image:DC214CD9-896A-42B5-A261-0CF2C5C71198-34588-000200ABBA362829/756D6B87-199A-4947-9AD2-30249E0FC7CA.png]#2019-05-0908:45teawaterwire(thanks for taking a look!)#2019-05-0814:07teawaterwirewow - yeah it works with the 'es' import! Thanks for finding that! 🙌#2019-05-0821:19ennI'm trying to figure out how to get my exports working correctly for an AWS Lambda function. In shadow-cljs.edn I have :exports-var foo/handler and :output-to foo.js My source file is src/foo.cljs which defines a single-segment namespace foo. My package.json contains "name": "foo". To deploy the lambda I zip up foo.js, node_modules, and package.json into foo.zip. In AWS my lambda is configured with the handler foo.handler. However, when I run it I see this in the Cloudwatch logs:
START RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc Version: $LATEST
Unable to import module 'foo': Error
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /var/task/foo.js:522:273
    at shadow$umd$export (/var/task/foo.js:5:22)
    at Object.<anonymous> (/var/task/foo.js:9:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
END RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc
REPORT RequestId: 0a3fb784-486e-482b-bb3c-ec8ccf0ed0bc  Duration: 33.06 ms      Billed Duration: 100 ms         Memory Size: 256 MB     Max Memory Used: 76 MB
What am I missing?
#2019-05-0821:30ennYou can see in the stacktrace that it is finding and loading the compiled foo.js. So it's something in the contents of the compiled output that is wrong.#2019-05-0907:41thheller@enn you are using it incorrectly. just use :exports {:handler foo/handler}#2019-05-0907:42thheller:exports-var would be :exports-var foo/exports and then in (ns foo) (def exports #js {:handler handler})#2019-05-0913:33enn@thheller I actually started with :exports. I see the same error.#2019-05-0913:37thheller@enn there seems to be something doing a (js/require "foo")?#2019-05-0913:38ennYes, some part of the AWS Lambda machinery I imagine. But I don't have visibility into that.#2019-05-0913:38thhellerI don' tthinkg to ... since its after the shadow-cljs code is laoded#2019-05-0913:39thhellerIf you create a reproducible example I can take a look#2019-05-0913:40thhellerbut its a really simple setup and other are using it#2019-05-0913:40ennhm, ok. I will see what I can do.#2019-05-0913:41thhellerhttps://github.com/royalaid/minimal-shadow-cljs-nodejs/blob/master/shadow-cljs.edn#2019-05-0913:41thhellerhttps://github.com/royalaid/minimal-shadow-cljs-nodejs/blob/master/src/server/main.cljs#2019-05-0913:41thhellerthats all you should need#2019-05-0923:10colinkahnI’m having issues with using :preloads, here’s my config:
{:deps true
 :nrepl {:port 9000
         :middleware [cider.nrepl/cider-middleware
                      cider.piggieback/wrap-cljs-repl]}
 :builds
 {:stories {:target :npm-module
            :module-loader true
            :output-dir "out/stories"
            :devtools {:preloads [some.namespace.i.want.loaded.first]}}}}
#2019-05-0923:11lilactownwhat’s the issue?#2019-05-0923:12colinkahnafaict the file isn’t loaded, I have a println in it which I assume I should see when the page loads#2019-05-0923:13colinkahnbtw this is a modified version of the storybook example: https://github.com/shadow-cljs/examples/tree/master/cljs-storybook#2019-05-1008:08thheller@colinkahn :preloads are not supported for :npm-module. shadow-cljs can't tell which namespace you are going to load so it can't tell which namespace it has to load before that#2019-05-1013:38colinkahn@thheller ah ok, that makes sense.#2019-05-1013:42colinkahnI did find a way around it in this specific case by importing a file directly into the .storybook/config.js file#2019-05-1017:17colinkahn@thheller i’m trying to upgrade the storybook example to the latest storybook version (5.0.11) and having no luck. Wondering if you’ve tried this#2019-05-1017:18colinkahnit hangs and eventually gives an out of memory warning when compiling storybook#2019-05-1017:25thhellerI don't use storybook no. not a clue whats different but it should work the same as before?#2019-05-1017:27colinkahnI suspect the bottleneck is something like a babel transform it’s applying to all files, which obviously that’s quite a few for what’s generated in the build.#2019-05-1017:29thhelleryou can probably put the simple .babelrc into the output dir so it doesn't process with babel at all#2019-05-1017:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/.babelrc#2019-05-1017:30thhellerjust put that file into the out dir#2019-05-1017:30thhellerpreviously I added that to the .storybook dir https://github.com/shadow-cljs/examples/blob/master/cljs-storybook/.storybook/.babelrc#2019-05-1017:31thhellermaybe the updated storybook just doesn't use that file anymore?#2019-05-1017:32colinkahnit still supports it afaict, adding it into the out dir has the same result. So maybe a webpack thing?#2019-05-1017:35thhellerusually just need to figure out where to put the files#2019-05-1017:44colinkahnNot sure what the full effect of this will be, but it works. I added a .storybook/webpack.config.js with the following:
module.exports = async ({ config }) => {
  config.module.rules = [];
  return config;
};
#2019-05-1210:19StefanI’m almost done getting all the basics in place for my new cljs / react native project. I got all the web audio / embedded webview stuff working, including injecting my clojurescript-compiled-javascript into the webview. (REPL inside that webview is working on iOS but not on Android; there it says “shadow-cljs - connection closed!“, but I didn’t yet look into that). I’m currently trying to get binaryage/devtools to work. According to the shadow-cljs user manual, if I understand correctly, all it should take is adding the dependency. It isn’t installed then though in my react-native target, and when I try to force it (`(devtools/install!)`) it says it is not installing under advanced builds. But I’m just running watch, so that should not be an advanced build, right? Any ideas?#2019-05-1210:26StefanOh wait that’s strange, after forcing recompile and having :autoload triggered, cljs-devtools is installed properly, but only because of the explicit devtools/install that I have in there. 🤔#2019-05-1211:12thheller@stefan.van.den.oord cljs-devtools is only installed automatically for the :browser target. I'm not sure if react-native even supports it at all#2019-05-1211:51StefanRight, I suspected as much, thanks.#2019-05-1211:55thhellerbtw you don't need to call install or reference the devtools at all ... just add :devtools {:preloads [devtools.preload]}#2019-05-1211:55thhellerhttps://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-via-preloads#2019-05-1211:55StefanYeah I know but I was just trying to force it 🙂#2019-05-1211:56StefanAnd that preloads thing shouldn’t normally be necessary either with shadow (in browser) right?#2019-05-1211:56thhellernot sure what forcing means but the preload literally just calls install#2019-05-1211:56Stefan🙂 Just to make sure, ignorance on my part 🙂#2019-05-1211:57thhellercljs-devtools uses a feature that as far as I know only the chrome devtools support#2019-05-1211:57thhellerso I'd be rather surprised if it actually worked in a react-native webview#2019-05-1211:57thhellergiven that there is no graphical console to begin with?#2019-05-1211:58StefanWell you can still use “remote debugging” which works with chrome, so I’m actually hopeful that it may still work.#2019-05-1211:58Stefan#2019-05-1211:58StefanThat’s from my react native app (but only after reload, not initally).#2019-05-1211:58thhellerright yeah that should work if you add the preload#2019-05-1212:00StefanNot sure why initially it doesn’t want to install and mentions :advanced, but I think I may have to look up in the cljs-devtools sources what kind of check they are doing for that.#2019-05-1212:46darwinyou can disable the check via https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/util.cljs#L234#2019-05-1212:47darwinit looks like devtools.version namespace is not present in your case, advanced build check assumes it gets munged#2019-05-1213:05StefanYes with that pref it indeed works, thanks! :+1:#2019-05-1212:00thhelleralways need to remember that metro actually processes all the sources before they get loaded#2019-05-1212:01thhellerso whatever that may be doing might get you in trouble there#2019-05-1212:01thhellerit might also be that the react-native target doesn't support preloads at all#2019-05-1212:01thhellercan't remember if I added it there 😉#2019-05-1212:01thhellerwill check later, gotta go#2019-05-1212:02StefanI think that might be the case. Cheers!#2019-05-1401:18wilkerlucioI'm trying to use this library https://rete.js.org/#/, but seems like it depends on some webpack magic to work, when I try to require it I get
js.js:133 Uncaught ReferenceError: regeneratorRuntime is not defined
    at rete.common.js:418
    at rete.common.js:415
    at Object.shadow$provide.module$node_modules$rete$build$rete_common (rete.common.js:396)
    at Object.shadow.js.jsRequire (js.js:122)
    at Object.shadow.js.require (js.js:158)
    at com.wsscode.wise.client.ui.rete.core.js:5
, I guess it may be some webpack polyfill, not sure, is there any way around it?
#2019-05-1401:39mssis there syntax for specifying a local cljs dependency for a shadow-cljs project similar to lein-install?#2019-05-1401:44wilkerlucio@mss not directly, but you can add directly to the source-paths, or use deps.edn, its local deps support works with shadow#2019-05-1401:45msswill do, appreciate the help#2019-05-1407:09vinurshttps://github.com/luminus-framework/luminus-template/issues/436#2019-05-1407:09vinurshello, i’ve a question that lein shadow doesn’t read the ~/.shadow-cljs/config.edn ?#2019-05-1407:11thheller@haiyuan.vinurs lein-shadow is a 3rd party project I have no control over and no it does not read that config#2019-05-1407:11thhellerI assume you mean for it to pick up the :dependencies listed there?#2019-05-1407:11vinursyes#2019-05-1407:11thhelleryou'll need to list that in the project.clj#2019-05-1407:12vinursyes, i’ve tried that and it works ok, so i found the problem, so i ask this question#2019-05-1407:12vinurssorry i don’t know this is a 3rd party project, i’ll look at it#2019-05-1407:13thhellerhttps://gitlab.com/nikperic/lein-shadow#2019-05-1407:13thhellerI recommend using the regular shadow-cljs cmd. you only lose functionality by moving to lein-shadow and gain absolutely nothing (IMHO)#2019-05-1407:14vinurs👌#2019-05-1409:27caleb.macdonaldblackWhat would be the right way to do dev dependencies in shadow-cljs without leiningen?#2019-05-1409:27caleb.macdonaldblackAnd dev source paths#2019-05-1409:28thhellernot supported#2019-05-1409:28caleb.macdonaldblackIf I put them under :dependencies would that bloat my production build?#2019-05-1409:30thhellerno, :dependencies have no affect on the build size#2019-05-1409:30thhellerthe build decides what ends up in it not the classpath#2019-05-1409:32caleb.macdonaldblackOkay thanks 🙂#2019-05-1409:57thheller@caleb.macdonaldblack when building :browser targets always check the build reports https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-05-1416:42kennyDoes a Build Report compile the app or does the app need to be compiled first?#2019-05-1416:49thheller@kenny it'll do a release build. no need to compile it yourself#2019-05-1416:51kennyCool. Can it use an existing build to run faster?#2019-05-1416:51thhellerno#2019-05-1416:51thhellerwell. it'll use the cache of release builds yes#2019-05-1416:52thhellerso yeah doing a release first will actually make the build report faster#2019-05-1416:52thhellerbut might actually not#2019-05-1416:52kennyHmm. Just added it to my CI and it actually takes 1s longer to run than the release build.#2019-05-1416:52lilactownwhat can i pass to (shadow/release) to tell it to use simple/none optimizations?#2019-05-1416:53thhellerhmm yeah the build reports do kinda require their own thing since they adjust some settings to get all the necessary info#2019-05-1416:53thhellerand those may actually hurt the normal release cache#2019-05-1416:54thheller@lilactown :none is not possible. otherwise just set the usual :compile-options {:optimizations :simple}#2019-05-1416:54lilactownso (shadow/release {:compile-options {:optimizations :simple}}) ?#2019-05-1416:54thhellerif you want to do it via release options and not in the config itself use (shadow/release :build-id {:config-merge [{:compiler-options ...}]})#2019-05-1416:54lilactownah k#2019-05-1416:54kennyGotcha. Not a big deal. Was trying to figure out if it should go in it's own build step or just be added to the release step given it'd run fast.#2019-05-1416:55thheller@kenny one setting that must be set is :compiler-options {:source-map true}#2019-05-1416:55kennySeems like a very useful tool though. Thanks! Will always output one as a build artifact. Great to compare build sizes after adding deps.#2019-05-1416:55thhellerso that would invalidate the cache since that isn't true by default for release builds#2019-05-1416:56kennyWhen would it be useful to have that setting be true for release builds?#2019-05-1416:56thhellerif you want source maps 😉#2019-05-1416:56kennyI guess you'd only want them in a release build for debuggery?#2019-05-1416:57thhellerthat depends .. some people always use them with things like sentry or so#2019-05-1416:58kennyAh, that's a good idea.#2019-05-1416:59lilactownhrm annoying. datascript isn’t working for me in advanced optimizations, but works in simple 😧#2019-05-1417:00thhellerdatascript requires externs because its written incorrectly#2019-05-1417:00lilactown>_<#2019-05-1417:00kennyWe use datascript in our released app and it works.#2019-05-1417:00thhellerhttps://github.com/tonsky/datascript/pull/216#2019-05-1417:01thhellerI didn't look into why they are required but they are ...#2019-05-1417:03lilactownvery annoying. wish they had this in the manual.#2019-05-1417:04lilactowndo I need to create my own externs or can I just list there’s?#2019-05-1417:04thhellerwell the externs are bundled#2019-05-1417:04thhellerjust via :foreign-libs which shadow-cljs doesn't support#2019-05-1417:04thhellerjust include :externs ["datascript/externs.js"] in your :compiler-options#2019-05-1417:07lilactownthat worked! thanks!#2019-05-1417:05thhelleror find out what is getting renamed and fix it 😉#2019-05-1417:08lilactownmaybe when I have free time 😂#2019-05-1417:06kennyWe use FontAwesome's React package in our app. After generating a build report, I see the icons deps take up nearly 30% of the build size. We explicitly import icons which supposedly allows tree shaking to work. I'm guessing that however FontAwesome expects tree shaking to work is not the same way it works in shadow-cljs? Is there way to make it work or no dice?#2019-05-1417:07thhellerI don't know the fontawesome package but if you require separate files it should work#2019-05-1417:07thhellerif you use :refer (That Icon) then that has no effect#2019-05-1417:07thhellerthat'll always import all#2019-05-1417:08kennyIs that the same as this?
(:require
  ["@fortawesome/free-solid-svg-icons" :as solid-icons])
solid-icons/faCircle
#2019-05-1417:08thhellerthat imports all#2019-05-1417:08thheller["@fortawesome/free-solid-svg-icons" :as solid-icons] only that matters. there is no DCE for npm packages#2019-05-1417:09thhellerbut all the icons are in that file so no luck#2019-05-1417:09kennyAh. Looks like FontAwesome expects you to use Webpack 2.#2019-05-1417:10kennyThis might do it: https://fontawesome.com/how-to-use/with-the-api/other/tree-shaking#deep-imports#2019-05-1417:11thhellerthat isn't supported#2019-05-1417:11thhellercan't support babel/webpack specific hacks#2019-05-1417:12thhelleroh actually that would work yes#2019-05-1417:12thhellerhmm actually I have no clue#2019-05-1417:12thhellerthe file does exist#2019-05-1417:13kennyTo clarify, when I do this
(:require
  ["@fortawesome/free-solid-svg-icons" :as solid-icons])
it imports an index.js file. If I were to do this:
(:require
  ["@fortawesome/free-solid-svg-icons/faCoffee" :as fa-coffee])
it'd import faCoffee.js?
#2019-05-1417:14thhelleryes#2019-05-1417:14thheller["@fortawesome/free-solid-svg-icons/faCoffee.js" :as fa-coffee] also works if you want to be sure 😉#2019-05-1417:14kennyAnd when I run a build, it will just throw the code (minified?) into the final JS file?#2019-05-1417:15thhellerit'll include just that file yes#2019-05-1417:15thhelleras long as you don't include the index anywhere else#2019-05-1417:15thhellerthe index contains all icons#2019-05-1417:15thhellerthe faCoffee.js only contains one icon#2019-05-1417:17kennyGotcha. Curious, given this library supports tree shaking, does that mean it'd be compatible with closure's tree shaking?#2019-05-1417:17thhellerno#2019-05-1417:17thhellerwell given how simple the lib is probably#2019-05-1417:18thhellerbut webpack tree shaking and closure tree shaking are two very different things#2019-05-1417:18thhellerso I wouldn't hold my breath#2019-05-1417:20kennyHow are they different?#2019-05-1417:20kennyThey use the same terminology - "dead code elimination". A bit annoying how everything is so overloaded.#2019-05-1417:21thhellerif you figure it out let me know 😉#2019-05-1417:21thhellerthe fundamental difference is that closure operates on one global scope#2019-05-1417:21thhellerso it can do things webpack can't do#2019-05-1417:21thhellersince webpack can't move stuff out of the scope they are declared in#2019-05-1417:22kennyOh I see. If I know that all the npm deps I use would be compatible with Closure, is there a way to enable it?#2019-05-1417:23thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-provider switch to :closure#2019-05-1417:23thhellerI haven't tested this in a rather long time and wouldn't consider it supported at this time#2019-05-1417:23thhellerbut if you are lucky 😉#2019-05-1417:24kennyHa. I'll try it for fun.#2019-05-1417:24thhelleryou'll probably run into issues with react and react-dom#2019-05-1417:24thhellerlast time I tried they required manual externs#2019-05-1417:25kennyOh, yeah - we definitely use those. I assumed it'd "just work" given how popular those are.#2019-05-1417:25thhellerthey never worked without externs#2019-05-1417:26thhellerwell .. I'm not actually sure ... it has been years sind I tried#2019-05-1417:27thhellerbut unless they changed their builds they would probably still be required#2019-05-1417:29kennyI get a bunch of new warnings when compiling 🙃#2019-05-1417:30kennyfor example:
------ WARNING #9 --------------------------------------------------------------
 File: node_modules/react-dom/cjs/react-dom.production.min.js:176:316
 unreachable code
--------------------------------------------------------------------------------
#2019-05-1417:30thhellerI warned you 😉#2019-05-1417:31kennyYep - no worky 🙂#2019-05-1417:33kennyDoes anyone do crazy stuff like run webpack on their build?#2019-05-1417:33thhellerthat would be crazy indeed#2019-05-1417:34thhellerespecially if you expect the webpack tree shaking stuff to trigger since that will not#2019-05-1417:37kennyIncluding the specific fontawesome js files does the trick 👍:skin-tone-2:#2019-05-1417:58thheller@wilkerlucio I saw the ticket regarding class. do you have an actual example where this fails? which class?#2019-05-1417:58thhellergotta be careful with code on npm since its often babel rewritten code which has other semantics than ES6 has#2019-05-1418:01wilkerlucio@thheller I was doing in browser, I'm loading strait from script tags, those using native ES6 classes, you can see the discussion I have around it yesterday: https://clojurians.slack.com/archives/C03S1L9DN/p1557803014008100, please let me know if you need more clarifications about it#2019-05-1418:02thhellerso the Rete.Control isn't an actual ES6 class if you used the npm version?#2019-05-1418:03wilkerlucio@thheller I'm not sure, I wasn't able to use that loading from NPM (that issue we discussed on the polyfill)#2019-05-1418:04thhellerwhat did you use then?#2019-05-1418:04thheller
var Control =
/*#__PURE__*/
function () {
  function Control(key) {
    _classCallCheck(this, Control);

    _defineProperty(this, "key", void 0);

    _defineProperty(this, "data", {});

    _defineProperty(this, "parent", null);

    if (this.constructor === Control) throw new TypeError('Can not construct abstract class');
    if (!key) throw new Error('The key parameter is missing in super() of Control ');
    this.key = key;
  }

  _createClass(Control, [{
    key: "getNode",
    value: function getNode() {
      if (this.parent === null) throw new Error('Control isn\'t added to Node/Input');
      if (this.parent instanceof Node) return this.parent;
      if (!this.parent.node) throw new Error('Control hasn\'t be added to Input or Node');
      return this.parent.node;
    }
  }, {
    key: "getData",
    value: function getData(key) {
      return this.getNode().data[key];
    }
  }, {
    key: "putData",
    value: function putData(key, data) {
      this.getNode().data[key] = data;
    }
  }]);

  return Control;
}();
#2019-05-1418:04wilkerlucio
<script src=""></script>
    <script src=""></script>
    <script src=""></script>
#2019-05-1418:04thhellerthis is the "class" in the npm package#2019-05-1418:04thhellerright yeah the min is the same there#2019-05-1418:05thhellerthere is not a single use of class in that package#2019-05-1418:05wilkerluciointeresting, still having the problem when trying to call the construct, maybe that generating the native class somehow?#2019-05-1418:06thhellerwell things are a bit more complicated depending on what you are trying#2019-05-1418:06thhellerif you are trying the Reflect way with a rewritten class like that it won't work#2019-05-1418:07thhellerthe rete package only contains babel-rewritten code#2019-05-1418:07wilkerluciothe issue I'm having is how to extend it and call the parent constructor#2019-05-1418:07wilkerluciobecause its required by the api design#2019-05-1418:07thhellereven though the package contains a build/rete.esm.js file but thats still rewritten by babel and not ES6 code#2019-05-1418:08wilkerlucioand their docs point to use of native classes, so I'm not sure whats going on inside of it#2019-05-1418:08thhelleryes I understand but if you are trying to do this with ES6 ways that won't work#2019-05-1418:08thhellersince its not an ES6 class#2019-05-1418:08thhellerthey probably assume that you'll use babel which would rewrite the code in a compatible way?#2019-05-1418:09wilkerluciothey provide docs for the .min usage as well, also suggesting usage of ES6 classeasa#2019-05-1418:09wilkerluciohttps://rete.js.org/#/docs#2019-05-1418:10thhellerthat might be but the code does NOT contain ANY es6 classes#2019-05-1418:10wilkerlucioyou have a guess why/how parent constructor calling is blocked?#2019-05-1418:11thheller
function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}
#2019-05-1418:11wilkerlucioha 😛#2019-05-1418:11wilkerlucioso they polyfill the check#2019-05-1418:12thhellerhttps://cdn.jsdelivr.net/npm/rete@1.3.0/build/rete.esm.js#2019-05-1418:12thhellerthats the non minified version .. a bit more readable but the same code#2019-05-1418:13thhellerthere is nothing ESM about it ... but lots of packages on npm pretend to be ESM when they are not#2019-05-1418:13thhellerwell its ESM because of the import/export#2019-05-1418:13thhellerbut not because of any other language features#2019-05-1418:13wilkerlucioyeah, but seems like this is just mimics the ES6 behavior#2019-05-1418:13thhellerno it really doesn't#2019-05-1418:14thhellerwell ... you need to adjust what you are trying#2019-05-1418:14wilkerlucioI mean mimics in the sense it blocks direct calls to the constructor fn (using that validator)#2019-05-1418:14thhellerin your ticket you mention Reflect.setPrototypeOf(B.prototype, A.prototype) and stuff#2019-05-1418:14thhellerthis will NOT work if you don't have an actual ES6 class#2019-05-1418:14thhellerand you don't (in the case of Rete)#2019-05-1418:15wilkerluciogotcha, but still that wasn't the main problem, sorry to insist in this point, but the real blocker to me is the parent constructor, fixing prototypes is easy, but thanks for pointing it, I'll improve the example there#2019-05-1418:15thhellerI'm not super sure how the babel-rewritten stuff expects inheritence to work#2019-05-1418:16thhelleryes I understand that you want to do that#2019-05-1418:16thhellerand that I fully agree that CLJS should support that#2019-05-1418:16wilkerluciois not that I want, its required by the lib, unless there is some way around that I'm missing#2019-05-1418:16thhellerbut the issue here is not with actual ES6 classes#2019-05-1418:16thheller
function _inherits(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function");
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      writable: true,
      configurable: true
    }
  });
  if (superClass) _setPrototypeOf(subClass, superClass);
}
#2019-05-1418:16thhelleryou probably need to mimic that#2019-05-1418:21wilkerluciothanks, I'll try that#2019-05-1418:22thhellerI can't find an actual example of how to use the rete stuff in your discussion in #cljs-dev#2019-05-1418:23thhelleronly the code to construct the class but not where its actually used?#2019-05-1418:23thhellerhow would you trigger the error?#2019-05-1418:32wilkerluciothat's a bit far in the setup, in the construction of the editor, but you can replicate by simply trying to instantiate the class#2019-05-1418:35wilkerlucioraw messy stuff, but this is my setup for init it:#2019-05-1418:35wilkerlucio
(fp/defsc ReteEditor
  [this {::keys []}]
  {:pre-merge         (fn [{:keys [current-normalized data-tree]}]
                        (merge {::editor-id (random-uuid)} current-normalized data-tree))
   :ident             [::editor-id ::editor-id]
   :query             [::editor-id]
   :componentDidMount (fn []
                        (go-catch
                          (let [container (gobj/get this "editorContainer")
                                editor    (js/Rete.NodeEditor. "
#2019-05-1418:35wilkerlucio
(def NumControl
    (js-class
      {::extends     js/Rete.Control
       ::constructor (fn [emitter key readonly]
                       (let [this (js-this)]
                         (.call js/Rete.Control this key)
                         (gobj/set this "render" "react")
                         (gobj/set this "component" ReactNumControl)
                         (gobj/set this "props" {:emitter emitter :ikey key :readonly readonly})))}))
#2019-05-1418:37thhellerI have no clue whats going on there 😛#2019-05-1418:37wilkerlucio
(defn js-class [{::keys [constructor] :as definition}]
  (let [c     (or constructor (fn []))
        proto (gobj/get c "prototype")]
    (doseq [[k v] (dissoc definition ::constructor)]
      (case k
        ::extends
        (goog/inherits c v)

        (gobj/set proto (name k) v)))
    c))
#2019-05-1418:38thhellerthats not the part I'm looking for#2019-05-1418:38thhellerI know how to do that part ... I need Rete to use the class#2019-05-1418:38thhellersomehow#2019-05-1418:38wilkerluciothe use is in the Fulcro component, num-comp (new NumComponent)#2019-05-1418:39thhellerwithout fulcro#2019-05-1418:39thhellerpreferably without react even#2019-05-1418:39thhellerjust rete#2019-05-1418:39wilkerluciothat's not actually possible, hehe, rete depends on some rendering to create some parts of it, but you can ignore the react/fulcro part, its just one container element and using componentDidMount to start#2019-05-1418:40wilkerluciohere you can see a full demo from Rete: https://codepen.io/Ni55aN/full/xzgQYq/#2019-05-1418:40wilkerlucioI mostly copied from that#2019-05-1419:07thheller@wilkerlucio
(defn NumComponent
  {:jsdoc ["@constructor"]}
  []
  (this-as this
    (.call (js/Object.getPrototypeOf NumComponent) this "Number")
    this))

(set! NumComponent -prototype
  (js/Object.create r/Component.prototype
    #js {:constructor
         #js {:value NumComponent
              :writeable true
              :configurable true}

         :builder
         #js {:value
              (fn [node]
                (this-as this
                  ;; do stuff
                  ))}

         :worker
         #js {:value
              (fn [node inputs outputs]
                ;; do stuff
                )}}))

(js/Object.setPrototypeOf NumComponent r/Component)
#2019-05-1419:07thhellerwith
["regenerator-runtime/runtime"]
    ["rete" :as r]
#2019-05-1419:08thhellerno clue if it actually works .. can't untangle this OOP crazyness 😛#2019-05-1419:09thhellerbut new works and the .name seems to get assigned properly#2019-05-1419:18wilkerlucio@thheller maybe something is wrong, I got Uncaught TypeError: Object.getPrototypeOf(...).call is not a function#2019-05-1419:19wilkerluciorunning new ns.NumComponent() on the console#2019-05-1419:20wilkerluciook, I fixed that line, swiped with: (.call (gobj/get (js/Object.getPrototypeOf NumComponent) "constructor") this "Number")#2019-05-1419:20wilkerlucionow it works! 🙂#2019-05-1419:22wilkerluciothanks for looking it up, really helpful#2019-05-1419:25wilkerluciobut there is something about that puzzling me, I don't really understand how (.call (gobj/get (js/Object.getPrototypeOf NumComponent) "constructor") this "Number") works, the way I'm seeing it, the constructor in NumComponent is a js value, which contains a value to NumComponent, how does that line figures the parent constructor and call it? its some JS magic going on inside?#2019-05-1419:27thhellerI just took what the babel stuff does and didn't question it 😉#2019-05-1420:10neupshI want to write a small library for myself in cljc where I expose apis that work for both clojure and clojurescript. Some of the implementations for these apis will use java/clojure external libraries and npm libraries using reader conditionals so that I can and export it as jar files and use them in both clojure and clojurescript world. Is there a way to achieve this with a shadow-cljs? Is there any template for such kind of library projects?#2019-05-1420:10thhellershadow-cljs currently does not support publishing libraries#2019-05-1420:11thhelleryou can just use a simple project.clj and use lein though#2019-05-1422:43lilactownalright, back to my chrome extension after awhile. I think I ran into this before, but I’m currently getting: [chromex] an error occurred during the call to chromex.ext.tabs/execute-script: Could not load file 'out/content-script.js' for content script. It isn't UTF-8 encoded.#2019-05-1422:47chadharringtonI am a first-time shadow-cljs user. In trying it out today, I hit an INTERNAL COMPILER ERROR :slightly_frowning_face: I created a minimal reproduction in this repository: https://github.com/Dept24c/viz-min The README has instructions on how to reproduce the error. Can anyone help me with this?
#2019-05-1422:48thheller@chad.harrington please include the full error you get#2019-05-1422:49chadharringtonIt's pretty big, but it starts with: `[:app] Compiling ... [:app] Build failure: failed to convert sources {:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/empty "shadow$empty.js"] [:shadow.build.npm/resource "node_modules/base64-js/index.js"] [:shadow.build.npm/resource "node_modules/ieee754/index.js"] [:shadow.build.npm/resource "node_modules/isarray/index.js"] [:shadow.build.npm/resource "node_modules/buffer/index.js"] [:shadow.build.npm/resource "node_modules/viz_DOT_js/full.render.js"]]} ExceptionInfo: failed to convert sources shadow.build.closure/convert-sources-simple*/fn--14326 (closure.clj:1809) shadow.build.closure/convert-sources-simple* (closure.clj:1803) shadow.build.closure/convert-sources-simple* (closure.clj:1684) shadow.build.closure/convert-sources-simple (closure.clj:1960) shadow.build.closure/convert-sources-simple (closure.clj:1912) shadow.build.compiler/maybe-closure-convert (compiler.clj:1016) shadow.build.compiler/maybe-closure-convert (compiler.clj:1009) shadow.build.compiler/compile-all (compiler.clj:1267) shadow.build.compiler/co mpile-all (compiler.clj:1128) shadow.build.api/compile-sources (api.clj:256) shadow.build.api/compile-sources (api.clj:248) shadow.build/compile (build.clj:377) shadow.build/compile (build.clj:368) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:304) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:290) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:887) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:850) shadow.cljs.devtools.server.util/server-thread/fn--16766/fn--16767/fn--16775 (util.clj:304) shadow.cljs.devtools.server.util/server-thread/fn--16766/fn--16767 (util.clj:303) shadow.cljs.devtools.server.util/server-thread/fn--16766 (util.clj:276) java.lang.Thread.run (Thread.java:748) Caused by: RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. An enclosing scope is required for change reports but node LABEL 13 [length: 2] [source_file: node_modules/viz_DOT_js/full.render.js] doesn't have one. Node(F OR): node_modules/viz_DOT_js/full.render.js:13:4095 function Rv(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=a;while(1){j=c[f>>2]|0;if(!j){k=6;break}if((c[j>>2]|0)==(b|0))b...`#2019-05-1422:52thhelleryeah its a closure compiler issue as expected. too tired to look into it now. headed to bed.#2019-05-1422:54chadharringtonOkay. Thanks.#2019-05-1422:49lilactownmy guess is the clojure compiler sees an empty (:require) in your ns form#2019-05-1422:49thheller@lilactown dunno what that means. it should be utf-8#2019-05-1422:49thhellerINTERNAL COMPILER ERROR typically is a closure ocmpiler issue#2019-05-1422:50lilactown@thheller my googling says I should set the :closure-output-charset to "US-ASCII"#2019-05-1422:51lilactownI tried that but it’s still not working. let me try cleaning things out#2019-05-1505:34caleb.macdonaldblackAnyone know what could be causing Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: qualified-keyword? in this context, compiling:(shadow/jvm_log.clj:74:10) when running shadow-cljs watch app? Specifically in regards to this issue: https://github.com/reagent-project/reagent-template/issues/166#2019-05-1505:37caleb.macdonaldblackI actually cannot replicate this issue myself. Perhaps java or node needs to be updated?#2019-05-1505:41caleb.macdonaldblackMaybe somehow a version of Clojure < 1.9 is being run?#2019-05-1505:56caleb.macdonaldblackShadow is using :lein true and the project.clj has clojure 1.10 specified so unless that's changed I'm not sure why shadow-cljs would start with a different version of clojure#2019-05-1507:43thheller@caleb.macdonaldblack what is the actual project.clj?#2019-05-1507:45caleb.macdonaldblack#2019-05-1507:45caleb.macdonaldblackYea clojure 1.8.#2019-05-1507:45caleb.macdonaldblackThat will be it then#2019-05-1507:45caleb.macdonaldblackI must have been looking at the project.clj for the template instead of what was generated#2019-05-1507:47caleb.macdonaldblackOkay thanks for that. I should be able to fix this now#2019-05-1511:31Jon#2019-05-1511:31JonI added Google Analytics on http://shadow-cljs.org and here's the results of past days.#2019-05-1511:32Jon#2019-05-1511:32Jon#2019-05-1512:20chrisblomWhat may cause the "Stale client! You are not using the latest compilation output"? I keep getting this error, also after recompiling and refreshing#2019-05-1513:14chrisblomfound the cause: i used another keyword than :main in [:builds :browser :modules] in the shadow-cljs.edn#2019-05-1513:52thheller@chrisblom totally fine to use a different keyword. just need to adjust the html loading the main.js accordingly#2019-05-1514:36chrisblomthanks, i did not notice these had to be aligned#2019-05-1515:22thhelleryeah the keyword controls the name of the output file#2019-05-1517:09chadharrington@thheller Any thoughts on https://github.com/Dept24c/viz-min ? I'd appreciate any insights you have. Thank you for your hard work on this project.#2019-05-1518:36chadharringtonI just noticed that one of the reproduction instructions in README.md was incorrect... I have fixed that in the GitHub version.#2019-05-1518:39thhellerI really can't offer any insights here. Its a bug in the Closure Compiler.#2019-05-1518:40thhellerit has issues processing the full.render.js file ... which is huge ... 1,9mb ...#2019-05-1518:42thhellerhttps://github.com/mdaines/viz.js#2019-05-1518:42thhellerit is also archived .. so seems like a dead project?#2019-05-1520:02chadharringtonOkay. Thanks for looking into it. I appreciate it.#2019-05-1518:14Jacob HaagI am having an issue with a npm module that I was formerly using as a cljsjs package. formerly when using cljsjs we had
(:require [cljsjs.fuse])

(.search
       (js/Fuse.
        js-coll
        fuse-options)
       query)
which in the past worked but when we changed it too
(:require ["fuse" :as fuse])

(.search
       (js/Fuse.
        js-coll
        fuse-options)
       query)
I've been getting the following error
ReferenceError: Fuse is not defined
    at eval (eval at <anonymous> (), <anonymous>:3:1)
Any ideas of the issue?
#2019-05-1518:16polymerisI think you can just do fuse instead of js/Fuse#2019-05-1518:33thhelleryes js/Fuse is accessing a global which doesn't exist. so just use the name you created via :as fuse instead.#2019-05-1518:56wilkerlucioand you may need to change :as to :default to use it, depends on how the module is been exported#2019-05-1518:57wilkerluciobut for this case specific, if you want, I have a Fuzzy wrapper version that works both on Shadow and Figwheel: https://github.com/wilkerlucio/fuzzy-cljs#2019-05-1518:57wilkerluciohttps://clojars.org/com.wsscode/fuzzy#2019-05-1518:58Jacob HaagNice, @U066U8JQJ I'll take a look at that#2019-05-1518:58wilkerlucioI remember I had to copy and to some small changes to make that work, I think that's reason I did that#2019-05-1518:58Jacob HaagI've been getting the error
TypeError: Cannot call a class as a function
    at e$jscomp$1 ()
When trying to create an object
#2019-05-1518:59wilkerlucioare you using new?#2019-05-1519:00wilkerlucio(can be (new Fuse) or (Fuse.))#2019-05-1519:00wilkerluciothe errors makes it look you are calling the constructor as a fn#2019-05-1519:01thheller@U994BRXMF (fuse. ...) not (fuse ...)#2019-05-1519:03Jacob Haagaha, no error message! @thheller#2019-05-1519:57jerome@thheller have you (or anyone else) noticed Chrome 74+ crashing in development mode? We're struggling with something right now, and it's probably not shadow-cljs, but wanted to rule it out since it only happens in development.#2019-05-1520:12thhellerchrome crashing?#2019-05-1618:24jeromeSince Chrome 74 we're seeing an "Aw snap" error message in all tabs pointed at our development server. Chome stack trace dumps seem to indicate something trying to access an address in memory it doesn't have access to. I doubt it's actually shadow-cljs, but since it's only in our dev environment and doesn not occur for QA or production builds I wanted to see if you've ever seen crashing like this. If not, don't worry about it, as it's most likely not our problem. :+1:#2019-05-1618:49thhellernot a clue what could be causing this. did you maybe start using a new npm dependency or so recently that does weird stuff?#2019-05-1618:54thhellerI haven't seen any crashes myself during regular development#2019-05-1618:55thhellerI think I had an infinite loop once that ended up crashing the tab but that was clearly my fault#2019-05-2415:59koz@U3A815DU0 is this Chrome 74+ crash still happening to you? it’s happening to multiple people here and we’re not quite sure what’s causing it.#2019-05-2416:04jeromeYes @U3GKNM1CK it's still happening to us, and we have no idea what's causing it to the point it's driving us nuts. For what it's worth, we have seen it happen once in a relatively clean project started with lein new shadow-cljs your-project +reagent while prototyping with material-ui. It seems to happen whenever there's a very specific unknown error rendering components.#2019-05-2416:05jeromematerial-ui is not yet in place in our production app where we see the most crashes#2019-05-2416:05kozThe only thing I can think of is that we have a pretty large application with a good amount of namespaces. Right before chrome crashes, I usually get a message ultimately stating that one of my NPM modules is now nil. I’m wondering if there is any crazy garbage collection happening in Chrome 74+ that is cleaning up things loaded in dev via goog.require if a lot of memory is being used by the tab and crashing the browser if it tries to reference the required module. Some evidence to support this is that in the Chrome logs, it says (93)] mach_vm_read(0x7ffee0423000, 0x2000): (os/kern) invalid address (1) when the crash happens, and it seems like the crash happens after a GC happens, since when I monitor the JS memory usage, it goes up, then goes down, then crashes#2019-05-2416:08jeromeWe've seen a "memory address access not authorized" error [or something like that] during these crashes when hooked into the chrome process debugger if that helps any.#2019-05-2416:10kozinteresting - i’ll keep looking into it and update with anything i find. it’s interesting that you got it to happen with material-ui, i’ll see if i can create a simple repro as well that might crash more consistently#2019-05-2416:58koz@U3A815DU0 I’m wondering if the Chrome 74 crashes are a byproduct of the new bytecode flushing feature in the V8 engine (https://v8.dev/blog/v8-release-74#bytecode-flushing) - can you please try shutting down Chrome and re-launching it from the terminal using /Applications/Google\ Chrome --js-flags="--no-flush_bytecode" and let me know if you still run into this issue?#2019-05-2417:43jerome^^ I'll give it a shot and socialize the flag here so others do too. Will report results early next week. :+1:#2019-05-2417:44kozawesome, hope it helps!#2019-05-2417:52thhellernothing we do should be able to crash chrome so this is very suspicious#2019-05-2417:53thhellereveryone involved using macOS?#2019-05-2417:55koz@thheller I am using macOS - I don’t think it’s shadow crashing chrome, if I were to bet it’s trying to reference code brought in through the Closure module loader after they are being flushed out by GC. The V8 docs on the subject say: > In order to reduce V8’s memory overhead, we have implemented support for flushing compiled bytecode from functions during garbage collection if they haven’t been executed recently. In order to enable this, we keep track of the age of a function’s bytecode, incrementing the age during garbage collections, and resetting it to zero when the function is executed. Any bytecode which crosses an aging threshold is eligible to be collected by the next garbage collection, and the function resets to lazily recompile its bytecode if it is ever executed again in the future.#2019-05-2417:58thhellercan you try using https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518 and see if it still crashes?#2019-05-2417:59thhellerbut if I understand correctly this also happens in production builds where shadow-cljs is no longer involved?#2019-05-2419:36koz@thheller i think this only happens in development#2019-05-2419:41kozwe seem to already be using :loader-mode :eval in our shadow-cljs config#2019-05-2419:42kozwe haven’t been able to repro in a release build so far#2019-05-2420:00thhellerdoes it happen if you have the chrome devtools open or closed?#2019-05-2420:18kozI’ve been able to repro with it both open and closed#2019-05-2420:19thhellerhmm thought maybe the devtools would cause this but guess not#2019-05-2420:19kozyeah originally i thought it was the (very large) source maps but happened with source maps turned off in devtools and also with devtools closed (i’ll re-confirm now)#2019-05-2420:21thhellercan you try in incognito with extensions disabled?#2019-05-2420:21kozi removed all of my extensions to reduce variables that could be causing this#2019-05-2420:21kozlet me run in incognito just in case#2019-05-2420:22thhellerdid you try this with shadow-cljs compile vs watch? don't think that the websocket would be causing issues but who knows#2019-05-2420:23thhelleralso try :optimizations :simple with a release build maybe?#2019-05-2420:26kozyeah got it crashing with incognito with dev tools closed. the only thing that’s reliably fixing it for me is starting Chrome with the --js-flags="--no-flush_bytecode" flag. I’ll try a compiled version with simple optimizations now.#2019-05-2420:26kozdefinitely something with that new V8 feature though#2019-05-2420:27kozalso since it happens in Chrome 74, 75, and 76. Firefox and Safari are fine#2019-05-2420:28thhellerhmm I'm on chrome beta so I've used 74 for a while and on 75 now#2019-05-2420:29thhellerI never had any crashes .. I'm on windows though so that might be a factor#2019-05-2420:29kozit only happens if 1) i’m doing something super memory exhaustive or 2) leave the page open for a while and then take an action. yeah not sure if it happens on windows#2019-05-2420:35kozand it usually happens after i make a change to the app which triggers code that requires a NPM module which it can no longer find. which aligns with the V8 change that removes functions during garbage collection after a set period of time.#2019-05-2420:36thhellerbut it should only be removing the jit compiled code#2019-05-2420:36thhellerit should just be using the "slow" version again until the jit kicks in again#2019-05-2420:40kozdoesn’t appear to be happening using the release build#2019-05-2420:41thhellerhmm thats odd#2019-05-2420:41thheller:simple is pretty much the same as :advacned as far as the npm packages are concerned#2019-05-2420:44kozcan it have something to do with goog.require’s cache of the node modules getting garbage collected somehow?#2019-05-2420:45thhellernode modules don't use goog.require#2019-05-2420:45kozoh#2019-05-2420:45thhellerbut goog.require is basically a noop, it doesn't do anything#2019-05-2420:46thhellergoog.require is basically just metadata to ensure everything is loaded properly#2019-05-2420:46kozi see#2019-05-2420:46thhellerbut it doesn't trigger any loading itself if everything is loaded#2019-05-2420:46thhellerand shadow-cljs ensures everything is loaded#2019-05-2420:46thhellerbut regardless of that nothing here should be crashing chrome 😛#2019-05-2420:47thhellergoogle pays money for chrome crash bugs so maybe try reporting it 😉#2019-05-2420:47kozhaha ok, i’ll have to try to make a simple, consistent repro case#2019-05-2420:51thhelleryeah I'd be interested to see that#2019-05-1520:03emil0rAnyone got an idea on how to get https://material-ui.com/layout/grid/ to work with reagent? Looked at the reagent react interopability page, but I can’t seem to get it to work. I was working on the first variant of Basic grid#2019-05-1520:04jeromeWe're about to start playing with this. See if https://github.com/reagent-project/reagent/blob/master/examples/material-ui/src/example/core.cljs helps, and I'll try to remember to circle back to this once I have a working example#2019-05-1520:22emil0rGot it work#2019-05-1520:23emil0rIt’s a bit cumbersome. Will have to think about how to create some helper classes#2019-05-1520:23emil0rHow much js <-> clj conversion cost?#2019-05-1602:58andreortizAnyone have any issues deploying to heroku? I have a test project here: https://github.com/andreortiz82/middlemancljs It continues to crash due this error Executable 'java' not found on system path.. I’ve added the heroku/[ruby nodejs java] buildpacks but I’m still missing the proper incantations. Anyone else run into this? Any resources or tips would be much appreciated. Thank you! :+1:#2019-05-1607:05attentiveI really love Shadow-CLJS, but find I'm still having an issue getting the CLJS repl to function the way that I want for the :react-native target …#2019-05-1607:07attentiveAt the moment when I run rlwrap shadow-cljs cljs-repl app to connect to my app (running under react-native android alongside the Metro bundler I get a mysterious websocket error message. I feel like this wasn't always happening but remain unsure on the cause.#2019-05-1607:38thheller@attentive shadow-cljs can pick the wrong IP so the REPL client may fail to connect to the actual shadow-cljs instance.#2019-05-1607:38thhellertry running shadow-cljs watch app --verbose and it'll tell you which IP it used#2019-05-1607:38attentiveYes … I've got a more minimal instance of an issue now that's still perplexing me#2019-05-1607:38attentiveI'm pretty sure we've been over this once before so forgive my confusion#2019-05-1607:39thhelleryou can configure the IP to use via shadow-cljs watch app --config-merge '{:local-ip "123.123.123.123"}' or :local-ip ... directly in the build config#2019-05-1607:40thhelleror what is that mysterious websocket error message?#2019-05-1607:41attentiveOkay I seem to have two separate, and unrelated issues. The issue with guessing the IP might be affecting my main project, but on this minimal version of your Expo example with Expo removed, I get "no source by provide: " exception info once the REPL appears to have connected.#2019-05-1607:42thhellerplease never abbreviate error messages#2019-05-1607:42thhellerpost the full thing if you can 🙂#2019-05-1607:43attentiveCan do!#2019-05-1607:43attentive
yarn run v1.12.3
$ rlwrap shadow-cljs cljs-repl app
shadow-cljs - config: /home/tom/dev/trm/rn-rf-shadow/shadow-cljs.edn  cli version: 2.8.8  node: v8.15.0
shadow-cljs - connected to server
[4:1]~scout.dev-preloads=> (foo)
[:result {:type :repl/error, :ex #error {
 :cause "no source by provide: scout.dev-preloads"
 :data {:provide scout.dev-preloads}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "no source by provide: scout.dev-preloads"
   :data {:provide scout.dev-preloads}
   :at [shadow.build.data$get_source_id_by_provide invokeStatic "data.clj" 182]}]
 :trace
 [[shadow.build.data$get_source_id_by_provide invokeStatic "data.clj" 182]
  [shadow.build.data$get_source_id_by_provide invoke "data.clj" 179]
  [shadow.build.data$get_source_by_provide invokeStatic "data.clj" 185]
  [shadow.build.data$get_source_by_provide invoke "data.clj" 184]
  [shadow.cljs.repl$process_read_result$fn__12538$fn__12539 invoke "repl.clj" 431]
  [shadow.cljs.repl$process_read_result$fn__12538 invoke "repl.clj" 407]
  [shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 405]
  [shadow.cljs.repl$process_read_result invoke "repl.clj" 381]
  [shadow.cljs.devtools.server.worker.impl$fn__13210 invokeStatic "impl.clj" 784]
  [shadow.cljs.devtools.server.worker.impl$fn__13210 invoke "impl.clj" 745]
  [clojure.lang.MultiFn invoke "MultiFn.java" 234]
  [shadow.cljs.devtools.server.util$server_thread$fn__12888$fn__12889$fn__12897 invoke "util.clj" 292]
  [shadow.cljs.devtools.server.util$server_thread$fn__12888$fn__12889 invoke "util.clj" 291]
  [shadow.cljs.devtools.server.util$server_thread$fn__12888 invoke "util.clj" 264]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 748]]}}]
[4:1]~scout.dev-preloads=> 
#2019-05-1607:45thhellerok I'm assuming you have set :repl-init-ns scout.dev-preloads whithout repeating said ns into the :preloads?#2019-05-1607:45thhellerhttps://github.com/thheller/shadow-cljs/issues/474#2019-05-1607:45attentiveNo, I've got both set (but will remove and check now)#2019-05-1607:46thhelleroh right ... :preloads doesn't currently work for :react-native#2019-05-1607:46thhellerI'm pushing a release that takes care of that in a few minutes#2019-05-1607:46attentiveOh, well!#2019-05-1607:46attentiveThank you 😄#2019-05-1607:49attentiveFor what it's worth, the repo I'm working with is here https://github.com/Trailmarker/rn-rf-shadow, it's a modified version of the Expo / re-frame example that was created by @pez …#2019-05-1607:51thheller@attentive try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "8af9e2ebeee5fda7e9e6e0f9cab8a4b2a4b9bd"}, :content ("[email protected]")}. that should fix the :preloads related REPL issue#2019-05-1607:53attentiveNice, thank you#2019-05-1608:06attentiveOkay, getting some joy here, thanks! I've now got scout.dev-preloads in both :repl-init-ns and :preloads, and after restoring it to the :preloads vector I can execute (foo 1 2) correctly from that namespace after the REPL connects. This looks very promising.#2019-05-1608:08attentiveI've pushed the repo above with the changes that brought me to a working state#2019-05-1608:08attentiveCheers once again for your support @thheller#2019-05-1612:40pez@attentive if you think my project should be updated with the same I'd welcome a PR.#2019-05-1612:47attentiveI'll take a look back at it, just jumping back on now to see if I can get this all working with my private repo#2019-05-1612:52hlolli@thheller I'm experimenting with haul and react-native for sourcemaps, which uses webpack, I'm looking into the source-map-loader, and it seems it calls fs.readFile according to a regex of the source map url at the bottom. The problem seems to me, I could be wrong, that the source map url doesn't include the file path, to the directory, only the name of the sourcemap file without path to it. Could I add that to the js output from shadow side?#2019-05-1612:57Jeff DierckmanI work in a corporate environment where they have recently blocked all access to external repo managers like maven, npm, etc. and have instead set up an internal Nexus repo that we are to use. I can add a .npmrc file in my project to set the repo for npm to use, but I could not figure out how to set the repository that shadow itself uses to pull down its dependencies. Any suggestions?#2019-05-1613:00hlolli@jeff.dierckman use tools.deps for dependency resolution and add the repository from there?#2019-05-1613:03Jeff Dierckman@hlolli thanks. I'll give that a shot.#2019-05-1613:05thheller@hlolli I'm not sure what you are asking? the source map doesn't require any other external files#2019-05-1613:05thhellerits all included in the sourcesContent array#2019-05-1613:06thheller@jeff.dierckman you can control maven related settings via :maven {:repositories {...}} in shadow-cljs.edn#2019-05-1613:06hlollilike this here //# sourceMappingURL=app.components.button.js.map I'd want it to be //# sourceMappingURL=build/app.components.button.js.map or smth, maybe it doesn't make sense?#2019-05-1613:06thhellersourceMappingURL is a relative path#2019-05-1613:07thhellerso app.components.button.js.map is in the same directly as app.components.button.js#2019-05-1613:07thhellernot sure what build/ is?#2019-05-1613:07hlolliyes, I'm wondering if webpack is noticing that, build/ would be the path from the root directory of the project#2019-05-1613:08thhellerthe resolve rules for sourceMappingURL are quite simple to webpack should find it properly#2019-05-1613:09thhellerhow does haul work with metro?#2019-05-1613:09hlolliit's this loader here https://github.com/webpack-contrib/source-map-loader/blob/master/index.js it also looks for sourceRoot#2019-05-1613:09thhelleror is it a complete replacement?#2019-05-1613:10hlolliit works great! btw, no need for the updateRoot hack#2019-05-1613:10hlolliforceUpdate I mean#2019-05-1613:10hlollibut it's bit unstable, had to use next directly from their github to make it work, so soon it will get more stable#2019-05-1613:10hlolliI was fighting metro all day long yesterday, got sick of it.#2019-05-1613:11thhelleryeah its no fun 😛#2019-05-1613:11hlollithey transform the js and then concatinate into a huge file, and trying to keep sync of the source maps is hell#2019-05-1613:11hlolliI was trying to parse the source maps and recalculate the new positions, gave up#2019-05-1613:12thhellerand what is the issue with the source maps in particular?#2019-05-1613:12hlollino, they work fine, they just source map the js output, but it's fully debuggable, so I'm just tryign to get source mapping to the cljs sources#2019-05-1613:13thhelleryes and what is the issue with that?#2019-05-1613:13thhellererror? stack trace?#2019-05-1613:13hlolliright now, with Haul, it's source mapping the js output, ignoring the .map files from shadow#2019-05-1613:13hlolliso I'm just console logging the source-map-loader#2019-05-1613:13hlollino error#2019-05-1613:14thhellerso they are loaded?#2019-05-1613:16hlolliI think not, I think it resolves without source maps, but I'll investigate further so I'm sure about it, all I can say that this res callback from info https://github.com/webpack-contrib/source-map-loader/blob/master/index.js#L97 is never called, but regex match 2 finds the the sourcemapurl, so something in between is failing#2019-05-1613:17thhelleruhm I don't think that code would ever be called?#2019-05-1613:17thhellerasync.map(missingSources, there should never be missing sources?#2019-05-1613:18thhellerthe entire if should be skipped#2019-05-1613:18hlollihmm#2019-05-1613:18thhellerhttps://github.com/webpack-contrib/source-map-loader/blob/master/index.js#L109#2019-05-1613:18thhellerlog the map there?#2019-05-1613:18hlolli60sec..#2019-05-1613:21hlolliI can post, but it logs many source maps#2019-05-1613:22hlollia source map of sources, mappings, (basically all the .map files I have)#2019-05-1613:22hlolliwhich means it should load 🙂#2019-05-1613:26hlolliprobably a question of setting the right "devtool" option#2019-05-1613:27thhellerI can't remember if I ever got source-map-loader working before#2019-05-1613:27hlolliyour webpack example includes it#2019-05-1613:28thhellerthat doesn't mean it actually worked#2019-05-1613:28hlolliyes :=)#2019-05-1613:28thhellerit was also 2 years ago which is like 10 generations in js land#2019-05-1613:28thhellerdoesn't mean it still works that way 😛#2019-05-1613:30hlolliyes, I'm now just getting webpack_require__ and namespace.file.js in my source maps#2019-05-1613:30hlollimust be some devtools option.. try them all 🙂#2019-05-1613:31thhellerwhat does haul do exactly? how does it skip metro?#2019-05-1613:31hlolliit creates a server, bundles, compiles#2019-05-1613:32hlollidetects simulator/emulators#2019-05-1613:32thhellerI mean react-native/metro has some kind of custom source map format#2019-05-1613:32thhellerhow is that supported by haul?#2019-05-1613:33hlolliI don't think they support it, if they use metro at all, then it's the last step. They claim that symlink between files work, maybe eliding the need for a single bundle? Not sure.#2019-05-1613:34thhellerI don't really have time to dive into this now but if you figure out how to tell the native app which JS to load we can do all of this without metro properly#2019-05-1613:34hlollino that's different reason#2019-05-1613:34thhellerbut I couldn't find a way without losing pretty much all features#2019-05-1613:35thhellerhttps://clojureverse.org/t/exploring-react-native-expo-with-shadow-cljs/1969#2019-05-1613:35hlolliyes, it's a dirty buisness this react-native#2019-05-1613:35thhellerI only tried emulating what expo did there and that already proved not worth it in the end#2019-05-1613:36hlolliI already ruled out expo long ago, makes no sense to be ejected, nothing that expo gives me that pure metro/shadow can't give me.#2019-05-1613:36hlolliIt works well as soon as you need native modules 🙂#2019-05-1613:36thhellerdisregard expo it is not relevant#2019-05-1613:36thhellerI meant to say that I already tried bypassing metro before#2019-05-1613:36thhellerand it didn't work out too well in the end#2019-05-1613:37hlolliI see, does expo bypass metro? I thought they were togeather#2019-05-1613:37thhellerno its built on top of metro#2019-05-1613:37hlolliyes#2019-05-1613:37thhellerbut what that did is running metro standalone as a single command#2019-05-1613:37thhellerand shadow-cljs would then generate that into its output#2019-05-1613:37thhellerinstead of the other way#2019-05-1613:38thhellerso shadow-cljs was in control of source maps and that worked fine#2019-05-1613:38hlolliah nice#2019-05-1613:38thhellerexpo was only relevant since it allowed a way to "hack" which .js file was loaded by the runtime#2019-05-1613:39thhellerbut in the end the extra features provided by the metro development server#2019-05-1613:39thhellerweren't easy to replicate so I didn't pursue that direction any further#2019-05-1616:33Chasemy apologies for crossposting but I'm not sure if I'm having a cider issue or a shadow-cljs issue: when trying to run and connect to a shadow-cljs app I'm getting a ton of nrepl middleware warnings and then get errors when trying to connect to the repl (using cider/cider-nrepl and cider/piggieback with vim fireplace). https://pastebin.com/se1cJESJ This was working a few weeks ago but I'm on a fresh install so don't know what has changed. any clues? this is the error message I get when trying to connect: https://pastebin.com/ZueFshz0 relevant portion of shadow-cljs.edn:
:dependencies [[binaryage/devtools "0.9.10"]                                                  
                [cider/cider-nrepl "0.21.1"]                                                   
                [cider/piggieback "0.4.1"]                                                     
                [reagent "0.8.0"]]
#2019-05-1616:33thhellerpiggiback isn't required and won't do anything#2019-05-1616:34Chaseinteresting. I've always had to do :Piggieback :app to get my vim-fireplace repl connection switched to cljs#2019-05-1616:35thhellerthat is unrelated (and will continue to work)#2019-05-1616:36thhellerthe error however looks like some older version of nrepl is used?#2019-05-1616:36thhellerwhich shadow-cljs version is that using?#2019-05-1616:37Chaseshadow-cljs - config: /home/chaselambert/projects/learn-reagent-course-files/giggin/shadow-cljs.edn cli version: 2.3.30 node: v12.2.0#2019-05-1616:37Chasei took out piggieback dependency but no change in error behavior#2019-05-1616:37thhelleryeah you need to update shadow-cljs#2019-05-1616:39Chaseglobally or within that project? might be a dumb question#2019-05-1616:40thhellerglobal never matters since the version in the project is always used. so in the project 😉#2019-05-1616:44Chaseand we are back up and running! thank you so much! I'll let the tutorial author know about that old shadow-cljs dependency#2019-05-1621:09martinklepschHey 🙂 I'm getting The required namespace "cljsjs.prop-types" is not available, I think last times this has been fixed by just installing the appropriate npm package but the error sticks around#2019-05-1621:10martinklepschI checked that shadow-cljsjs handles prop-types which it seems to do#2019-05-1621:10martinklepschoh but wait, just seeing that that change is only 8 days old#2019-05-1621:11martinklepschupdating and I guess that will be it 🙂#2019-05-1708:37Juho LeinonenHello, I’m using shadow-cljs to build a reagent + re-frame app. What should I call during development in the :after-load function so that all components would be re-rendered with the changes in the code? I have tried calling (r/render [main-view] (.getElementById js/document "app")) again in that function and reagent.core/force-update-all, but the changes don’t seem to appear in the browser. Sorry if it’s more of a reagent question.#2019-05-1708:40thhellerhey. the issue isn't reagent its re-frame. I can't remember the exact name but something like (re-frame.core/clear-subscription-cache!) or so (in the after-load)#2019-05-1708:41thhellertypically you just re-render everything via r/render#2019-05-1708:42thheller
(defn ^:dev/after-load start
  []
  (r/render [app]
    (.getElementById js/document "app")))

(defn ^:export init
  []
  (router/start!)
  (rf/dispatch-sync [:initialise-db])
  (start))
#2019-05-1708:45Juho LeinonenThank you. I’ll take a look in that function and return with my findings then 🙂#2019-05-1710:14Juho LeinonenThat didn’t seem to work 😕 Maybe I have done something wrong elsewhere.#2019-05-1712:13thheller@juholei look at the browser console. shadow-cljs tells you what it is doing. if all that looks in order your code might be doing stuff that can't be hot-reloaded properly#2019-05-1712:27Juho LeinonenYeah the after-load function gets called correctly with shadow-cljs and re-frame subscriptions and events get their changes loaded correctly, so I guess I have something wrong with my views somewhere.#2019-05-1712:28thhellerif you keep references to potentially reloaded code in the state somewhere this can be the problem#2019-05-1713:24Juho LeinonenYeah it might be just that. I just noticed if I make changes to my front end routing related files (using reitit), then the changed views also update. And reitit puts a reference to the current view component to the app state, so seems like that may be the problem. Thanks for your help 🙂#2019-05-1716:06Jacob HaagHey all, I am playing around with the :release portion of my shadow-cljs project and have noticed that the released artifacts are trying to connect to . I'm not sure why this is required and if not was wondering how to disable this, any ideas?#2019-05-1716:07lilactownit looks like your build has the shadow-cljs development stuff included. are you sure you’re running your release code?#2019-05-1716:08thhelleryeah that doesn't look like a development build#2019-05-1716:10thhellermake sure you are loading the correct output files. by default those will be the same as your development files so you might have something cached if the server doesn't handle that properly#2019-05-1716:16Jacob HaagOkay, currently I am outputting the release'd files to a different location than the dev's, however, I can take a look at the caching, that might be the issue#2019-05-1716:16thhellerand did you adjust your HTML to load those files?#2019-05-1716:17thhelleryou can easily tell if you are loading the actual release build by the size and number of requests made#2019-05-1716:18Jacob HaagThat's a good point, I'll dig in there#2019-05-1718:11teawaterwireCuriosity question: how does shadow implement hot reloading? It doesn't say what library it uses in the manual https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2019-05-1719:01thheller@teawaterwire what do you mean by library? shadow-cljs handles the reloading stuff, no library used#2019-05-1719:09thhelleras far as the reloading is concerned it is pretty trivial to do given that everything is evaled in the same scope and namespaced#2019-05-1719:10thhellerso unlike regular JS we can manipulate that scope easily and just replace definitions on the fly#2019-05-1719:20teawaterwireoh I see - sweet! Everybody's talking about figwheel but Shadow is actually doing hot reloading on its own as well 🙂#2019-05-1719:21teawaterwire(sorry I was under the impression that Shadow used a library underneath - I was wrong 😄 )#2019-05-1719:22thhellermost of the magic happens here#2019-05-1719:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/env.cljs#L194-L233#2019-05-1719:23thhellerwould actually be much less code if it wasn't for all the async support#2019-05-1719:24thhellerworks a bit differently in figwheel but figwheel made the concept popular#2019-05-1719:29teawaterwireinteresting! So many goodies included in Shadow 🌟#2019-05-1720:04MatrixNormHi. Is there an example of smooth development workflow with service worker? Say I want to build main.js and service-worker.js. They should be independent: if service-worker.js recompiles main.js shouldn't reload and vice versa. If service-worker.js changes browser should be notified to run unregister/register code.#2019-05-1720:08thhellerI typically recommend using something like https://developers.google.com/web/tools/workbox/ for service workers#2019-05-1720:08thhellerdon't feel like CLJS much to offer in that area since its 90% ugly js interop#2019-05-1721:01MatrixNormMost simple thing like
{:main                  {:entries  [foo.core]}
 :service-worker {:entries  [foo.sw]
                              :depends-on #{:main}
                              :web-worker true}}
kinda "works" because there is reload notification in a browser when code in foo.sw is updated. Of course nothing happens because service-worker.js is not included in a page. But at least there is a hope to hook into (defn handle-message [{:keys [type] :as msg}] or smth like that and run unregister/register code for service-worker. msg map has all info to get to know when foo.sw is recompiled.
#2019-05-1721:03thhelleryou can always trigger the sw reload from the REPL#2019-05-1721:04thhellerservice workers are kinda special so I would probably make a separate build for them#2019-05-1721:04MatrixNormThanks, I didn't think about repl#2019-05-1721:04thhellersince they'll be responsible for loading your actual app code you can't really make them dependent on the app code#2019-05-1801:35carkhI'm trying to make a chrome extension, there is many moving parts, so i output the extension itself to resources/public/js/extension and set the output-dir for the background script in resources/public/js/extension/background. Compilation works, then I add the extension to chrome targeting resources/public/js/extension (where my extension manifest is). The trouble is that now chrome is looking for the modules with /resources/ as root rather than resources/public/js/extension So how can i ask shadowcljs (or maybe the clojurescript compiler?) to root the js lookup in resources/public/js/extension` ?#2019-05-1801:38carkhIn other words, right now chrome tries to load but i want it to try loading #2019-05-1801:42carkhah got it :asset-path "/background"#2019-05-1802:03carkhnow for hot code reloading ...shadowcljs is trying to open a websocket at .... which of course doesn't work, how can i tell it to use my already running server at ?#2019-05-1802:11carkhah for posterity : :devtools-url "" in :devtools key of shadow-cljs.edn#2019-05-1808:12thheller@carkh its not documented well but shadow-cljs can build chrome-extension directly which fixes all those issues https://github.com/thheller/shadow-cljs/issues/279#2019-05-1808:15carkhoh wow, i've been worrying about the module thing, but didn't investigate that yet#2019-05-1808:15carkhnice#2019-05-1808:15carkhdidn't have any trouble with switching repls though#2019-05-1808:23carkhlooking at the issue, you have browser-action and content-script, is it also possible specify the options-page ?#2019-05-1808:25carkhthat's another compilation that might benefit form modules#2019-05-1808:25thhellerit probably is yeah#2019-05-1808:26thhellerhaven't looked at it in a while but I think I covered all possible built targets#2019-05-1808:26carkhvery nice, i'll try to switch to this new workflow and maybe tell you how it goes if you'd like that#2019-05-1808:27thhellersince its all built on modules you can pretty much build everything#2019-05-1808:27thhellersince all that really matters is how the code gets loaded#2019-05-1808:28thhelleropts pages looks the same as the other html driven options#2019-05-1808:30thhellerso you can probably set :output-type :chrome/page-action for the module#2019-05-1808:30thhellersorry ... this stuff really needs docs#2019-05-1808:30carkhdon't be sorry, already awesome that this exists at all#2019-05-1808:34thhellerhere is one extension that uses this stuff maybe that helps in some way https://github.com/fulcrologic/fulcro-inspect/blob/master/shells/chrome/manifest.edn#2019-05-1808:34thhellerhttps://chrome.google.com/webstore/detail/fulcro-inspect/meeijplnfjcihnhkpanepcaffklobaal#2019-05-1808:35carkhhah i'm using it, and actually am using fulcro for the options page#2019-05-1817:01nickmbaileyis using eval from the shadow-cljs repl supported?#2019-05-1817:01nickmbaileyi'm seeing:#2019-05-1817:01nickmbailey
[0:0]~cljs.user=> (eval '(+ 1 2))
Error: cljs.core/*eval* not bound
#2019-05-1817:01nickmbaileyis there some other setup i need to do#2019-05-1817:05carkh@nickmbailey afaik there is no eval with clojurescript#2019-05-1817:07carkhself hosted clojurescript probably has it if necessary
#2019-05-1817:08nickmbaileyi see#2019-05-1817:57thheller@nickmbailey eval in CLJS requires using the self-hosted compiler. shadow-cljs does support building everything you need for that but doesn't run it itself. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-05-1818:11carkh@thheller so i switched to the :chrome-extension target as we discussed. And I hit the repl switching problem. I have several running javascript instances under the single chrome-extension build, and i can only invoke the repl on a per build basis... any workaround i should be aware of ?#2019-05-1818:13thhellerif you are using nrepl not really no#2019-05-1818:14carkhmhh that's a problem, no auto-completion in cider when in the wrong repl ... too bad i like that whole build target thingie =(#2019-05-1818:14carkhthanks anyways !#2019-05-1818:14thhellerauto completion should work. I don't think that calls eval?#2019-05-1818:16carkhi don't quite know why but it doesn't ... when in a build's repl that doesn't "link" to the current buffer no auto-complete in cider#2019-05-1818:17carkhprobably uses some nrepl magic to get the live state#2019-05-1818:18carkhvery much not my expertise =)#2019-05-1818:18thhellerthat all should work since it shouldn't try to eval#2019-05-1818:18thhellereval is the only issue since with multiple runtimes it is not clear how to do that consistently#2019-05-1818:18thhellerbut I know nothing about cider so can't help much#2019-05-1818:20carkhno big deal i'll go back to the old way which was working fine, in the meantime i got better organisation out of this escapade#2019-05-1818:21carkhtoo bad i'll be losing the modularisation, maybe just use the chrome-extension target for release#2019-05-1818:29nickmbaileyis there a way to dynamically define vars in clojurescript?#2019-05-1818:29nickmbaileyi'm using intern in a macro in clojure but thats not available in clojurescript#2019-05-1818:29nickmbailey(was previously playing with eval, hence the earlier question)#2019-05-1818:31thhellerdynamically as in a macro yes, at runtime no#2019-05-1818:34nickmbaileywell it should be fine to happen at compile time but eval wasn't working so i switched to intern which lets it happen at runtime#2019-05-1818:34nickmbaileyso i guess i can switch to self hosted clojurescript#2019-05-1818:34nickmbaileyand eval#2019-05-1818:35thhellerwhat are you trying to do exactly?#2019-05-1818:35thhellertypically you should just have the macro emit (def ...) forms#2019-05-1818:36thhellerthe super dynamic clojure style Var creation via actual Var calls will not work even in self-hosted CLJS since there are no vars at runtime#2019-05-1818:39nickmbaileyi'm making a macro that makes builder fns for plumatic/schema map keys so:
(crazy-macro foo {:a Int})
creates a var like
foo-a
. the problem is i want it to also support
(crazy-macro bar (merge foo {:b Int}))
which means i need the evaluated version of the map
#2019-05-1818:40nickmbaileyin regular clojure just eval'ing the form works, or using intern to inject the vars at runtime also works#2019-05-1818:41thhellerwhy does it create vars?#2019-05-1818:42nickmbaileywell they are builder functions#2019-05-1818:42nickmbaileyit creates vars via defn#2019-05-1818:42thhellerwhat does that mean? 🙂#2019-05-1818:42thhellerbuilder functions sound like OOP mess to me?#2019-05-1818:43nickmbaileyheh i don't disagree with that#2019-05-1818:43nickmbaileyits a bit of a crazy idea#2019-05-1818:44thhellerif you can stomach adding several megabytes of JS to your build I guess self-host is something you can try#2019-05-1818:44thhellerbut otherwise I would probably look for better solutions#2019-05-1818:45nickmbaileyyeah i'll probably abandon this for clojurescript for now heh#2019-05-1820:18nickmbaileyit seems like when shadow-cljs is compiling a .cljc file and it runs into a reader conditional it picks the ":clj" option#2019-05-1820:18thhellerif you are loading the ns as a macro yes#2019-05-1820:19nickmbaileyhmm why is that?#2019-05-1820:20thhellerhmm? its the same as anywhere else?#2019-05-1820:20thhellermacros in CLJS are written in Clojure#2019-05-1820:21nickmbaileyright, i'm trying to make the macro do nothing in clojurescript#2019-05-1820:21thhellerany particular reason you are writing that in a .cljc file?#2019-05-1820:22thheller.cljc is kinda mind bending when it comes to macros and stuff so I would recommend avoiding it as much as possible#2019-05-1820:22thhelleryou can't use reader conditionals to decide what code a macro should emit#2019-05-1820:23nickmbaileyhmm well i'm trying to use reader conditionals around the defmacro call completely#2019-05-1820:23nickmbailey
#?(:cljs (defmacro...) :clj (defmacro...)
#2019-05-1820:23thhelleryeah thats not gonna work 🙂#2019-05-1820:23nickmbaileyheh#2019-05-1820:23thhellerthat would be for self-hosted macros#2019-05-1820:24nickmbaileyok but i should be fine if i just split into clj and cljs files?#2019-05-1820:24thhellerthe trick commonly used in macros that should emit different code for CLJ or CLJS is checking the &env#2019-05-1820:25nickmbaileyah#2019-05-1820:25thheller#?(:clj (defmacro foo [& args] (if (:ns &env) :cljs :clj)))#2019-05-1820:28thhellerso (foo 123) used in CLJS will end up just returning :cljs#2019-05-1820:28thhellerand :clj if called in CLJ#2019-05-1820:29thhelleryou need (ns the.ns #?(:cljs (:require-macros [the.ns]))) self-require for macros#2019-05-1820:30nickmbaileyhmm i'm using :refer-macros#2019-05-1820:30nickmbaileyis that the same?#2019-05-1820:30thhellerno#2019-05-1820:31thhellerwell yes ... but don't do that. this way is much simpler.#2019-05-1820:31thhellerlets others using the.ns completely skip worrying about macros and just use them as you would in CLJ#2019-05-1820:32nickmbaileyah i put that in the file where the macro is defined#2019-05-1820:32nickmbaileygot it#2019-05-1820:32thhellerso (ns (:require [the.ns :as x])) (x/foo) works#2019-05-1820:47nickmbailey@thheller that got me up and running, thanks for the help!#2019-05-1820:47nickmbaileyand more generally thanks for shadow-cljs heh#2019-05-1912:23StefanHi! Can also suppress the automatic injection of binaryage/devtools selectively in some of my :browser targets?#2019-05-1912:24Stefan(Rationale: The shadow-cljs compiled code that I run in my embedded WebView does not support the devtools and therefore raises a warning.)#2019-05-1913:03thheller@stefan.van.den.oord :devtools {:console-support false}#2019-05-1914:02Stefanhttps://github.com/shadow-cljs/shadow-cljs.github.io/pull/25#2019-05-1917:55dangercoderanyone with an example github project where you use material ui directly via npm?#2019-05-1917:59dangercoderah, cool. I found some very useful examples in the official docs. 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2019-05-1920:04dangercoderI just imported material ui: (require '["@material-ui/core" :as x]) and it seems like toolbar is empty. Anyone with any tips on how I can "find the bug"?#2019-05-1920:05dangercoderall the others are e.g #Object[WithStyles] but toolbar is #js {}#2019-05-1920:32dangercoderI wonder how this is even possible..#2019-05-2112:45souenzzo(require '["@material-ui/core/Toolbar" :as raw-Toolbaw]) Then (def Toolbar (.-default raw-Toolbar))#2019-05-2113:31dangercoderI had some issues with npm I think, this has been solved 🙂#2019-05-1920:49thheller@jarvinenemil what is toolbar supposed to be? your example only defines x?#2019-05-2003:58dangercoder@thheller sorry, bad example. Toolbar is a part of ["@material-ui/core/Toolbar" :default tool-bar]. I installed material-ui with npm and got it working. The other material ui components that I require looks like this #Object[WithStyles] but Toolbar is just empty #js {}.#2019-05-2005:11caleb.macdonaldblackI have a script in CircleCI to deploy my webapp. But sometime app.js fails to generate and it doesn't get uploaded. Any ideas of what could cause that?#2019-05-2005:12caleb.macdonaldblackI'm generating and deploying two seperate shadow-cljs projects with different shadow-cljs.edn files with shadow-cljs release app. They are run one after the other too#2019-05-2006:45thheller@jarvinenemil see the documentation about :default, you should probably try :as tool-bar instead. :default is currently in a weird situation. https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-05-2007:20dangercoderthanks, ill try it out. will report back. I am planning on putting together a repository showcasing how to use material ui with shadow-cljs, (app-bar, etc..) 🙂#2019-05-2007:24dangercodera bit wierd that i tried both before though, but ill have a look once i get home#2019-05-2017:35dangercoderIt works now, I think it was some NPM issues.#2019-05-2017:35dangercoderI have to improve my bug search skills though#2019-05-2006:46thheller@caleb.macdonaldblack CircleCI is notorious for killing build processes for consuming too much memory. so the OOM killer just hard terminates the process and pretends that everything is fine.#2019-05-2006:47thhellerput something like :jvm-opts ["-Xmx3G"] into your shadow-cljs.edn#2019-05-2006:48caleb.macdonaldblack@thheller So it will kill a process for a command in my bash script and continue with the remaining commands like normal?#2019-05-2006:48thhelleryeah the exit code is lost for some reason I haven't figured out yet#2019-05-2006:48thhellerbut many people have had this problem before#2019-05-2006:49caleb.macdonaldblackWow, thanks. If that works I never would've figured that out on my own.#2019-05-2018:11dangercoderI just got material ui working, then I restarted my repl and it stopped working. Anyone has any ideas? Or have also had problems with material ui with shadow?#2019-05-2018:11dangercoderI just got material ui working, then I restarted my repl and it stopped working. Anyone has any ideas? Or have also had problems with material ui with shadow?#2019-05-2018:12dangercoder
(:require
   ["@material-ui/core" :as mui]))

(defn header []
  [:> mui/AppBar {:position "static"
                  :color "primary"
                  :style {:background-color "#43a047"}}
   [:> mui/Toolbar 
    [:> mui/Typography {:variant "h6"
                        :color "inherit"}
     "BH"]
    [:> mui/Button {:color "inherit"} "Login"]]])

(defn app []
  [:div
   [header]])
#2019-05-2018:15lilactownWhat does “stopped working” mean?#2019-05-2018:15stefanI haven’t had any issues so far, my imports are structured like
["@material-ui/core/Button" :default button]
            ["@material-ui/core/Switch" :default switch]
            ["@material-ui/core/Textfield" :default textfield]
            ["@material-ui/core/FormControl" :default form-control]
            ["@material-ui/core/FormControlLabel" :default form-control-label]
            ["@material-ui/core/InputLabel" :default input-label]
            ["@material-ui/core/Typography" :default typography]
            ["@material-ui/core/Select" :default select]
            ["@material-ui/core/MenuItem" :default menu-item]
            ["@material-ui/core/Dialog" :default dialog]
            ["@material-ui/core/DialogTitle" :default dialog-title]
            ["@material-ui/core/Paper" :default paper]
            ["@material-ui/core/styles" :rename {withStyles with-styles}]
            ["@material-ui/icons/Add" :default add]
#2019-05-2018:17dangercoderthis is the error i keep on getting#2019-05-2018:18dangercoderLooks like some hot reloading issue?#2019-05-2018:23dangercoder@U9MJTSS9K which version of material-ui are you on?#2019-05-2018:23stefan^3.9.3#2019-05-2018:23dangercoderhmm.. same here, wierd.#2019-05-2018:23stefanlooks like one of the hiccup forms is returning nil#2019-05-2018:24stefanfrom the error message#2019-05-2018:28dangercoderin the chrome tools it warns: it fails to load the material ui components e.g module$node_modules$$material_ui$core$Paper$Paper#2019-05-2018:34stefanI think it may be how you are requiring the components#2019-05-2018:35stefandoes it work if you switch to
(:require ["@material-ui/core/AppBar" :default AppBar])
#2019-05-2018:35dangercoder
(:require
   ["@material-ui/core/AppBar" :default app-bar]
   ["@material-ui/core/Toolbar" :default tool-bar]
   ["@material-ui/core/Button" :default button]
   ["@material-ui/core/Typography" :default typography]
   ["@material-ui/core/Menu" :default menu]
   [reagent.core :as r]))

(defn header []
  [:> app-bar {:position "static"
               :color "primary"}
   [:> tool-bar
    [:> typography {:variant "h6"
                    :color "inherit"}
     "App-Title"]]])

(defn app []
  [:div
   [header]])
updated to this
#2019-05-2018:36dangercoderdoes not help 🙂 same error#2019-05-2018:36dangercoderit fails to load the node modules somehow#2019-05-2018:58dangercoderNow it works again.#2019-05-2018:58dangercoderran: npm dedupe npm ls and added (to shadow-cljs.edn):
[com.google.javascript/closure-compiler-unshaded "v20190325"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
😄 ...
#2019-05-2023:43cheppreyI have a very small shadow-cljs app running, connected to REPL w/ Emacs. I have a core.async go-loop that starts up and parks waiting for input from a channel. What happens to the go-loop when I 1) hit Save in the editor, does that original go-loop keep running? Does an additional go-loop get created each time I hit Save? Do I need to add some kind of lazy-init/singleton/safeguard logic to ensure the go-loop is only created once? Is there a recommended pattern to follow? And then 2) same questions, except for hitting Reload in the browser (rather than Saving sourcecode)#2019-05-2103:47polymeris1) the original channel should stay open 2) you'll lose all state (including channels)#2019-05-2023:45chepprey(and lmk if this is a better question for the core.async channel, which I just now learned exists)#2019-05-2104:32bbssI'm hitting an error with shadow-cljs release and I'm not sure what is causing it. shadow-cljs watch still works fine.#2019-05-2106:59thheller@bbss since you are using lein I'd suspect a bad closure-compiler version?#2019-05-2106:59bbssokay, sounds reasonable, how can I specify?#2019-05-2106:59thhellerfirst check via lein with-profiles +cljs deps :tree#2019-05-2107:00thhellershould be
[com.google.javascript/closure-compiler-unshaded "v20190325"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
#2019-05-2107:01bbss
[thheller/shadow-cljs "2.8.36"]
   [com.bhauman/cljs-test-display "0.1.1"]
   [com.cognitect/transit-clj "0.8.313"]
   [com.cognitect/transit-cljs "0.8.256"]
   [com.google.javascript/closure-compiler-unshaded "v20190325"]
   [com.wsscode/pathom "2.2.7" :exclusions [[org.clojure/data.json] [fulcrologic/fulcro] [camel-snake-kebab]]]
     [com.wsscode/spec-inspec "1.0.0-alpha2"]
     [edn-query-language/eql "0.0.3"]
#2019-05-2107:01bbssmight be here, my shadow-cljs version is older than cli I'm using#2019-05-2107:01thhellerthat looks like it should#2019-05-2107:02bbss
[thheller/shadow-cljs "2.8.36"] -> [org.clojure/google-closure-library "0.0-20190213-2033d5d9"] -> [org.clojure/google-closure-library-third-party "0.0-20190213-2033d5d9"]
#2019-05-2107:02thhellerwhat is your :modules config? the exception looks like something isn't quite right with the modules#2019-05-2107:03bbss
:main     {:target     :browser
                     :output-dir "resources/public/js/main"
                     :asset-path "/js/main"
                     :build-hooks [(gsv.api.mutations/recalc)]
                     :modules    {:shared {:entries []}
                                  :web-shared {:entries []
                                               :depends-on #{:shared}}
                                  :worker-shared {:entries []
                                                  :depends-on #{:shared}}
                                  :app {:entries [gsv.client]
                                        :depends-on #{:web-shared}}

                                  :fetch-worker {:entries [gsv.fetch-worker]
                                                 :depends-on #{:worker-shared}
                                                 :web-worker true}
                                  :filter-worker {:entries [gsv.filter-worker]
                                                  :depends-on #{:worker-shared}
                                                  :web-worker true}}
#2019-05-2107:06thhellerhmm that looks ok#2019-05-2107:07thhellerthe exception looks like the compiler pass responsible for moving keywords#2019-05-2107:07thhellercan't find a common module to place a keyword in#2019-05-2107:08thhellerbut in your case it should be always finding :shared at the very least#2019-05-2107:11bbsshmm, any type of change I did that could have brought this about?#2019-05-2107:27thhellerhttps://github.com/thheller/shadow-cljs/blob/de065f237031f2e8233642c96b0030477ce2be30/src/main/shadow/build/closure/ReplaceCLJSConstants.java#L52#2019-05-2107:27thhellernot a clue. the error looks like targetModule is null which shouldn't really happen#2019-05-2107:30thheller
/**
   * Finds the deepest common dependency of two modules, including the
   * modules themselves.
   *
   * @param m1 A module in this graph
   * @param m2 A module in this graph
   * @return The deepest common dep of {@code m1} and {@code m2}, or null if
   *     they have no common dependencies
   */
  public JSModule getDeepestCommonDependencyInclusive(
#2019-05-2107:30thhellerso it should only return null if there is no common module#2019-05-2107:30thhellerbut it should always be at least shared#2019-05-2107:30thhellertry adding an explicit :shared dependeny to all :modules maybe?#2019-05-2107:31thhellermaybe something isn't right with transitive deps?#2019-05-2107:31thhellereg. :app {:entries [gsv.client] :depends-on #{:web-shared :shared}}#2019-05-2107:48bbssTrying that.#2019-05-2107:51bbssjust adding it to :app wasn't enough but adding that to the other worker modules seems to have done the trick! Thanks @thheller!#2019-05-2107:51thhellerhmm strange#2019-05-2107:51thhellerwould have expected the logic the account for transitive deps but I guess it doesn't#2019-05-2107:51bbssoh wait#2019-05-2107:52bbssmaybe I ran it in the wrong window.. 😕#2019-05-2107:52bbssgive me a moment#2019-05-2107:52bbssno, that does seem to be the case 🙂#2019-05-2109:57rap1dsHi all 👋 Is there something I'm missing here? I have my code under src/ and tests under test/ and I added them both to source-paths but yarn shadow-cljs compile test just doesn't find the test namespace under test/. All seems to work fine and the test namespace is found when I move the test namespace under src. Here's my shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths ["src" "test"]

 :deps true

 :builds
 {:flex-cli {:target :node-script
             :output-to "target/main.js"
             :main sharetribe.flex-cli.core/main}
  :test {:target    :node-test
         :output-to "target/tests.js"
         :autorun   true}}}
And when I run yarn shadow-cljs compile test it doesn't find any tests:
➜  flex-cli git:(master) ✗ yarn shadow-cljs compile test
yarn run v1.9.4
warning package.json: No license field
$ /Users/mikko/Documents/Projects/sharetribe/flex-cli/node_modules/.bin/shadow-cljs compile test
shadow-cljs - config: /Users/mikko/Documents/Projects/sharetribe/flex-cli/shadow-cljs.edn  cli version: 2.8.37  node: v10.11.0
shadow-cljs - starting via "clojure"
[:test] Compiling ...
========= Running Tests =======================

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (27 files, 1 compiled, 0 warnings, 1,63s)
✨  Done in 10.35s.
The test file under test/sharetribe/flex-cli/hello_world_test.cljs looks like this:
(ns sharetribe.flex-cli.hello-world-test
  (:require [cljs.test :refer-macros [deftest is]]))

(deftest failing
  (is (= "hello" "world")))
So what I'm expecting is that the yarn shadow-cljs compile test would find and run the test which should fail. What I actually see is that the compile doesn't find the test. Any tips what am I doing wrong or how to debug further? Thanks!
#2019-05-2110:28rap1dsAhaa! Found it. :deps true was the reason here. Turning it to false fix it and now the test is found.#2019-05-2110:31rap1dsAnd of course then I need to set :paths in deps.edn#2019-05-2111:07thhellerif you set :deps true the :source-paths from shadow-cljs.edn do not apply and only use the ones defined in deps.edn#2019-05-2111:47rap1dsYeps, that seems to be the case and makes totally sense now#2019-05-2208:31rastandyhello everyone#2019-05-2208:31rastandyI have a strange problem when importing an ES6 module in a cljs file.#2019-05-2208:32rastandywhen trying to call an async function from the ES6 module, the following error appears:#2019-05-2208:32rastandyreturn $jscomp.asyncExecutePromiseGeneratorProgram(function($jscomp$generator$context) { ^ ReferenceError: $jscomp is not defined at Object.authClient$$module$js$oauth2 [as authClient]#2019-05-2208:32rastandy#2019-05-2208:33rastandythe js module works like a charm when used by javascript code#2019-05-2208:33rastandyI’m really stuck#2019-05-2215:09Alex K@thheller I've been using shadow to compile a lambda for an Alexa skill, but I've hit a problem when using the juxt/tick library. It works fine with development compile, but some functions break when compiling for release. I assume something with the optimizations. Release mode does however work fine with browser target, but not with node-script/library. For all I know it could be some problem with the library, but since it worked with the browser target I figured I'd best ask here first. I put together a repro here: https://github.com/AlexSKaye/shadow-cljs-node-release-repro#2019-05-2215:37thheller@rastandy do you require rewriting async/await code to polyfills would it be ok to assume a modern browser target?#2019-05-2215:37thhellerthe error you get is from missing polyfills. not sure why they are missing but not needing them in the first place would be the easiest solution#2019-05-2215:41thheller@noxdeleo looks like missing externs. in the browser case shadow-cljs processes all the JS and can easily generate the externs#2019-05-2215:41thhellerfor not that doesn't happen so the externs are missing#2019-05-2215:44thhellerI would recommend avoiding that library ...#2019-05-2215:45Alex KOk, thanks.#2019-05-2215:45thhellerseriously too much code ...#2019-05-2215:46thheller500kb for just a time lib?#2019-05-2215:48thheller@noxdeleo you can run shadow-cljs check app to get some insights into which externs are missing#2019-05-2215:51Alex KWow, I didn't realise it was quite that big. Running check app gives several hundred warnings. Guess I'm hunting for another library.#2019-05-2215:51thhelleryeah check isn't super useful because of the noise it reports#2019-05-2215:51thhellerbut the last few warnings are from the tick/core.cljc ns#2019-05-2215:51thhelleronly those matter the rest can probably be ignored#2019-05-2215:54rastandy@thheller thanks for your answer, I’m sorry I forgot to say that my environment is node.js v12.2.0#2019-05-2215:56thhellerso you are targeting node? not the browser?#2019-05-2216:03rastandy@thheller yes, and I must say that wrapping not calling directly the problematic function, but calling another async function that calls the problematic one, solved the problem#2019-05-2216:03rastandyI can share part of the code if you wish#2019-05-2216:04thhellerI'm asking because for node you can turn off the polyfill rewriting completely#2019-05-2216:04thhellerso that problem would solve itself#2019-05-2216:04rastandynot now I’m at work but if it smells like a bug I can report#2019-05-2216:04rastandy@thheller oh ok, I’ll check how to do that then#2019-05-2216:04thhellerjust set :compiler-options {:output-feature-set :es8} or :es2018#2019-05-2216:05rastandytrying right nonw#2019-05-2216:07rastandy@thheller you are awesome#2019-05-2216:08rastandy@thheller that was the problem! Thanks, and sorry for my incompetence in Javascript land#2019-05-2216:36colinkahnIs there a way to pass -Sdeps when using :deps true?#2019-05-2216:36thhellerno, but you can bypass the shadow-cljs command if you need to#2019-05-2216:36thhellershadow-cljs compile app is the same as clj -m shadow.cljs.devtools.cli compile app#2019-05-2216:37thhellerso clj -Sdeps ... -m shadow.... works#2019-05-2216:37colinkahnThat’s awesome, thanks!#2019-05-2218:31sethCan anyone tell me how to get a single bundle in development? We're currently seeing 6170 files loaded, and Chrome is choking on the last couple thousand with net::ERR_INSUFFICIENT_RESOURCES. Developing a project with material-ui.#2019-05-2218:32seth:compiler-options {:optimizations :advanced} is doing the trick for release, but seems to have no effect on dev.#2019-05-2218:44raul.guajardoI am trying to run tests based on unit, integration, or acceptance tests. currently the namespaces look something like this
blah.bleh.integration.core-test
blah.bleh.unit.core-test
for some reason the regex is not working and all tests are being ran. Any help appreciated
#2019-05-2314:16raul.guajardoBUMPING: since apparently we don't use threads#2019-05-2219:10sethUpdate to my above question, :loader-mode :eval seems to have done the trick, as per: https://clojureverse.org/t/any-chance-we-could-reduce-the-bundle-size-in-development/3690/2#2019-05-2219:29thheller@satwood how do you get to 6k files? that seems like a lot 😛#2019-05-2219:29thhellerFWIW this is the original :loader-mode article https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-05-2220:10seth@thheller Yes, it is a lot! 😆 This is how:
(:require [reagent.core :as r :refer [atom]]
           ["@material-ui/core" :as mui]
           ["@material-ui/core/styles" :refer [createMuiTheme]]
           ["@material-ui/core/colors" :as mui-colors]
           ["@material-ui/styles" :as mui-styles]
           ["@material-ui/icons" :as mui-icons]
           ["@material-ui/system" :as mui-system])
#2019-05-2220:10sethThank you for the link to the original article! 🙌#2019-05-2220:15thhelleryeah you definitely should try to reduce it to the things you actually use#2019-05-2220:15thhellerotherwise your build is going to be gigantic#2019-05-2220:16hlollithink it's possible to connect to a shadow-cljs repl with npm-module target on react-native platform?#2019-05-2220:17thhellersure, its what the :react-native target does#2019-05-2220:17hlolliso npm-module is unneccecary?#2019-05-2220:18thhellerdepends. is everything CLJS or do you have existing JS and want to include some CLJS?#2019-05-2220:18hlolliI'm testing Haul, so I need webpack compatability#2019-05-2220:19thhellerhmm so you have a manual index.js or so?#2019-05-2220:19thhellerthats used as the haul entrypoint?#2019-05-2220:19hlolliyes I have index.js#2019-05-2220:20hlollithat's webpack's entry, and some hmr patches#2019-05-2220:20thhellerin the index.js you require("./foo/your.app")?#2019-05-2220:20hlolliyes#2019-05-2220:20thhellerok in the file you can add something like if (process.env.NODE_ENV == "development") { require("./foo/shadow.cljs.devtools.client.react-native"); }#2019-05-2220:21thhellerand in your build config set :runtime :react-native#2019-05-2220:21hlolliah ! I see it now, I did set the :react-native runtime#2019-05-2220:21hlollibut now finally see that devtool file, only saw env, hud and browser#2019-05-2220:22thheller:npm-module just doesn't have clearly defined entries so it can't add :preloads#2019-05-2220:22thhellerpreloads still cause the code to be compiled#2019-05-2220:23thhelleryou just have to load it yourself#2019-05-2220:23hlolliyes, looks like an easy workaround to me#2019-05-2220:23thhelleryou can try using the :react-native target btw#2019-05-2220:23thhellerthat takes care of all of this and should be loadable by haul#2019-05-2220:24hlolliyes, if I can drop the hmr for shadow's reload, it would make sense#2019-05-2220:24thheller(it uses :npm-module in development)#2019-05-2220:24hlolliwhich I should#2019-05-2220:24thhellerI don't know what special hooks haul requires#2019-05-2220:25thhellerbut the react-native target is basically just an :npm-module build with a generated index.js#2019-05-2220:25hlolliyes that sounds about the same with haul#2019-05-2220:25thhellerso you can either use that index.js directly#2019-05-2220:25thhelleror create a dedicated index.js for haul and require("./foo/index.js") from there#2019-05-2220:27hlolliI'll try that now, requireing that devtool doesn't make shadow detect an environment, but that could be my side...#2019-05-2220:27thhellernot sure what you mean by that#2019-05-2220:27hlollinevermind#2019-05-2220:33hlolli
shadow.user> (shadow.cljs.devtools.api/nrepl-select :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user> :a
REPL command timed out.
cljs.user> :a
REPL command timed out.
it connects, but times out, never actually used the nrepl with metro/vanilla-react-native so I don't know what to expect 🙂
#2019-05-2220:34thhellerthat might be for a variety of reasons#2019-05-2220:34thhellercheck the react native log#2019-05-2220:34thhellerreact-native log-ios or whatever that command was called#2019-05-2220:35thhellerREPL should be working normally but I have no clue what you are doing to the code 😉#2019-05-2220:36hlolli
2019-05-22 20:35:35.535 10517-11493/com.hlolli W/unknown:ReactNative: Calling JS function after bridge has been destroyed: RCTDeviceEventEmitter.emit(["websocketMessage",{"data":"{:type :repl/invoke, :name \"<eval>\", :js \"new cljs.core.Keyword(null,\\\"a\\\",\\\"a\\\",-2123407586)\", :source \":a\", :source-map-json \"{\\\"version\\\":3,\\n \\\"file\\\":\\\"<eval>\\\",\\n \\\"sources\\\":[\\\"<eval>\\\"],\\n \\\"lineCount\\\":1,\\n \\\"mappings\\\":\\\"\\\",\\n \\\"names\\\":[],\\n \\\"sourcesContent\\\":[\\\":a\\\"]}\\n\", :warnings [], :id 2}","type":"text","id":2}])
#2019-05-2220:37thhellerabsolutely no clue what that means 😛#2019-05-2220:37hlolliok at least there's a clue, Sherlock Holmes mode on#2019-05-2220:41hlollijust a restart and now it works#2019-05-2220:45hlolliit happens tough after every hot module reload, then the context which shadow is connected to is destroyed and new one is made#2019-05-2220:45hlollicould I have the HMR reload some js file to sync it? like that devtools file?#2019-05-2220:46thhellerby HMR you mean something haul does? because you should absolutely disable anything reloading related that haul does#2019-05-2220:46hlollino that's an opt-in#2019-05-2220:46hlolliI can turn it off#2019-05-2220:46hlolliI'll do that now 🙂#2019-05-2221:36hlolligiving up on Haul. Better than Metro, but only by a margin. Better to use their server code and push shadow-cljs code directly from a bundle into a emulator/device. Not sure how much work that would be.#2019-05-2301:51vigilancetechHas anyone here gotten the demo to work with msys2?#2019-05-2306:58thhellerwhat is msys2?#2019-05-2307:33thheller@hlolli the way the current :react-native target works seems to be the only one thats reliable enough. the re-natal/figwheel-bridge approach also works ok-ish but the problem I found with that is that initialization becomes async. so you have to render a temporary "app is loading" component and then swap in the real one once it is loaded#2019-05-2307:33thhellerthat implies having a different setup for development than production#2019-05-2307:33thhellerand also causes problem for things like react-native-navigation as far as I understand it#2019-05-2307:35thhellerif the RN folks just fix their source map support everything would be done#2019-05-2307:35thhelleras far as I can tell thats the only real issue left#2019-05-2309:28hlollistacktraces, and clojure compile errors (hud), they would come hand in hand with a source map support?#2019-05-2309:33thhellerstacktraces require source maps yes#2019-05-2309:35thhellerfor compile errors all the data we need to available in the compiler#2019-05-2309:35thhellerso metro doesn't factor into any of that#2019-05-2314:43nateHello, is there a way to require json files, doing something like this (:require ["./multisig-abi.json" :as multisig-abi]) ?#2019-05-2314:44natefor context I need to read a JSON file as part of a firebase function I'm writing#2019-05-2314:52MnoMaybe JSON.parse from javascript would help? It would give you a js object which you can pass through js->clj if needed.#2019-05-2314:55nateI'll have to first read the file from disk then, any suggestions on how to do that without having to for example evaluate clojure at compile time by wrapping slurp in a macro ?#2019-05-2314:57nateThe other option is to just rewrite the content of the json file in a def#2019-05-2315:00MnoThe only way I would know is using slurp unfortunately.. but maybe that would work.#2019-05-2315:00MnoI found this though maybe it’s useful? https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-05-2315:10nateAwesome, this is exactly what I needed. Thanks :+1:#2019-05-2315:21MnoNo problem! good luck!#2019-05-2317:56msshi there, newbie-ish q about the cljs compiler. I might be asking this in the wrong place, but using shadow to do my compilation so figured I’d try this channel first. is there a way to bundle all generated code up in a single file (like in advanced optimizations), except with no optimizations applied? I’m outputting a node script that’s preloaded on electron webviews. closure modules in non-advanced comp modes try and resolve deps based on relative paths, which doesn’t work in this case as there’s a separate hostname prepended to every dep load. e.g. an output with a main fn in /my/local/lib.js which requires /my/local/dep.js is preloaded onto . when /my/local/lib.js tries to load /my/local/dep.js, it does so as . apologies if that’s a bit confusing. please let me know if so and I can clarify. if anyone has any ideas for how to solve this besides just programming w/ advanced mode turned on, I’m all ears#2019-05-2319:47lilactownI recall thheller was working on a :single-file bundle option for node scripts but I think he ran into some blockers#2019-05-2321:24thheller@mss you can set :devtools {:loader-mode :eval} which creates a single file. you'll need to use the :target :browser though since :node-script isn't really the correct target for webviews. see https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-05-2412:28carkh@thheller is possible there would be a bug somewhere in module separation for the :chrome-extension target ?#2019-05-2412:28carkhsome of my namespaces are suddenly missing, even after cleanup and restart#2019-05-2412:28carkhnamespaces which are shared between different parts of the extension#2019-05-2412:34carkhis this even a shadow-cljs concern or rather a clojurescript one ?#2019-05-2412:34carkhor even closure =/#2019-05-2412:35carkhand is it posssible to deactivate modularisation on the :chrome-extension target ?#2019-05-2412:53carkhaahhaa ! looks like the extension needed to be reloaded from the manage extension page in chrome#2019-05-2412:53carkhsorry for the noise#2019-05-2413:26Jacob HaagHey there, so I am using Cursive for development and have been trying to integrate it with shadow-cljs. I have followed the instructions to connect to the nrepl port via a remote repl. I am able to do this succesfully, however when the repl is spun up and I try to run js/alert I get an error. Any ideas?#2019-05-2413:26Jacob HaagI am trying to connect to the :app build#2019-05-2413:26Jacob Haag#2019-05-2413:26Jacob Haag#2019-05-2413:26Jacob Haag#2019-05-2413:28thheller@carkh yeah adding/removing namespaces currently requires reloading the extension since the manifest changes#2019-05-2413:29thheller@jacobhaag17 the REPL always starts out in CLJ mode so you need to switch it to CLJS first. You do that by calling (shadow/repl :app)#2019-05-2413:30Jacob HaagThanks 🙂#2019-05-2413:31Jacob HaagAlso I'd just like to applaud you on being so responsive 👏#2019-05-2414:38StefanWhich editor currently gives the “best” shadow-cljs experience? I’m reasonably happy with VSCode/Calva so far, but haven’t really tried others.#2019-05-3022:02mauricio.szabo@U9MJTSS9K if you want, I'm developing Chlorine, an Atom package that works with Socket-REPL and aims to be shadow-cljs friendly. (It needs to be, because I'm developing the plug-in in Shadow-CLJS and debugging it with itself 🙂)#2019-05-3022:03stefancc: @UGNFXV1FA#2019-05-3022:06mauricio.szaboAh, there were two Stefans with different capitalizations 🙂#2019-05-3105:52Stefan@U3Y18N0UC sounds good I’ll check it out! (And thanks other @U9MJTSS9K 😉)#2019-05-2414:46kszaboI’m pretty happy with my spacemacs + cider setup#2019-05-2414:49StefanSpacemacs, that’s new to me. Earlier this week I heard Stuart Halloway say in one of his talks: > Asking somebody to use Emacs is, like, “did you just ask me to go f*ck myself?!” Does that also apply to Spacemacs? 😉#2019-05-2414:53lilactownI think that Spacemacs is one of the most friendly ways to get started with Emacs (I use it everyday, and it finally got me over the line after trying Emacs twice before)#2019-05-2414:53lilactownbut it still has a learning curve
#2019-05-2414:54lilactownI know that thheller uses IntelliJ + Cursive. IMO that has the most "IDE friendly" experience#2019-05-2414:56StefanRight I was a bit put off by this: > Cursive does not currently support resolving dependencies via shadow-cljs.edn. You can run shadow-cljs pom to generate a pom.xml and import that using the IntelliJ.#2019-05-2416:30polymerisThat's not as bad as it sounds. Yes, if you change your deps you have to run shadow-cljs pom manually, but that's it. The re-import will happen automatically.#2019-05-2414:56lilactownah#2019-05-2414:57Bravi+1 for Spacemacs. It used to be a very steep learning curve, but there are loads of videos on youtube these days that will get you started. I used to be a vim user and I switched to Spacemacs about 2 years ago. I've used Spacemacs at work for Go, Python, JS, Haskell and I use it for all of my Clojure projects. It's an extremely productive tool#2019-05-2414:59StefanI’m installing Spacemacs. I’m already learning about 25 new things at the same time in this space, might as well add that too 😉#2019-05-2415:07cheppreymy $.02 - if you're not already a Lisper I strongly recommend trying parinfer regardless of which editor you settle on. (I know "paredit" also exists but I thought the parinfer concept looked better). As a 20-year non-lisp Java veteran, the whole worry about getting your parens nested properly has been a complete non-issue. Parinfer is just terriffic, I think it's actually been one of the most helpful things to understanding Lisp/Clojure.#2019-05-2415:30Stefan@chepprey I hear you. This week I listened to a podcast with Shaun Lebron about this. Especially “smart mode” sounds cool, but it seems that isn’t supported in many editors yet.#2019-05-2415:54cheppreyYa, I use Emacs and I don't think smartmode is there yet. Even so, parinfer (in indent mode) just feels like magic, you simply indent your code where you know the logical nestings need to be, and the parens just go in there by magic. It's like you get to "think the code" more directly, and the paren details just appear automatically. Mind blowing.#2019-05-2613:53StefanCan I use “static image loading” (https://facebook.github.io/react-native/docs/images.html) also from ClojureScript when using shadow-cljs? That would be including the automatically loading of @2x and @3x variants… Second question: How could I have found the answer to the first question myself? I couldn’t find the answer by web searching and searching in ClojureVerse and Zulip… 😞#2019-05-2614:02orestisNot uncommon for people not to talk about stuff like that - so you’re not doing anything wrong! Asking here or on ClojureVerse (or reddit, or indeed everywhere) is usually a good idea.#2019-05-2614:03orestis(Two negations, sorry!)#2019-05-2614:03orestisSince you’re talking about react native I’d look around for the relevant channels too. It’s a smaller community that does react native with ClojureScript...#2019-05-2614:23thheller@stefan.van.den.oord like this? https://github.com/thheller/reagent-expo/blob/master/src/main/test/app.cljs#L14#2019-05-2618:11StefanThanks guys! I was told that this community is very supportive, but it still amazes me how much that is true! @thheller That worked. The relative path starting with ‘..’ was the missing part, didn’t occur to me to try it that way.#2019-05-2618:41jimmyI’m having some trouble with a bootstrapped web worker. I’ve made a minimal reproducible case. Here it is hosted (check the console). https://shadow-bug.jimmyhmiller.now.sh/ and here is the source https://github.com/jimmyhmiller/PlayGround/tree/529f7276139574a7b34066c501f9b17dd8f5efca/shadow-debug The worker is getting a document not defined error. It appears that this is the culprit. https://github.com/thheller/shadow-cljs/blob/d93af50a6b5e54553762ab273102a3cd16139b6d/src/main/shadow/cljs/bootstrap/browser.cljs#L37-L43 If I change this to use js/eval everything works. Do I have some configuration wrong or is this a bug when trying to do bootstrapped web workers?#2019-05-2619:31thheller@jimmy that code assumes it is running in a normal browser context. webworkers should probably have their own version but if it works I'd be fine to change that#2019-05-2619:31thhellershould be (js/goog.globalEval ...) though#2019-05-2619:37jimmy@thheller The doc string says it is for optimization purposes. I’m happy to make a PR changing it to js/goog.globalEval, but want to make sure it isn’t going to cause any performance regressions. Any benchmarks I need to run as part of the PR?#2019-05-2619:38thheller(js/eval ...) never gets JIT optimized so it runs substantially slower. js/goog.globalEval should be ok#2019-05-2619:38thhellerplease put the file into your classpath first#2019-05-2619:39thhellerand actually run it since I have no setup to verify that it actually works as intended in a webworker after that#2019-05-2619:39thhellerwell I guess I do since you made the repo#2019-05-2619:40jimmyNot sure I will get around to it today. But I will definitely make sure things are working in the browser and in the web worker before submitting.#2019-05-2619:55jimmyThanks for the quick help and great project#2019-05-2809:20Ahmed HassanDo I need to include thheller/shadow-cljs {:mvn/version "2.8.37"} in deps.edn file when using shadow-cljs with Clojure Deps and CLI? I am using npx shadow-cljs watch main command for compilation.#2019-05-2809:21thhelleryes, that is recommended#2019-05-2809:22thhellerit isn't strictly required since it will inject itself but for other tooling purposes it is better if you include it manually#2019-05-2809:22Ahmed HassanWhen I include it. Following error is thrown on requiring the namespace in clj shell `Syntax error (FileNotFoundException) compiling at (cookies.clj:1:1). Could not locate clj_time/core__init.class, clj_time/core.clj or clj_time/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.`#2019-05-2809:22thhellerI wish I never added the auto-inject 😕#2019-05-2809:23thhellerhmm that looks like it might be a dependency conflict?#2019-05-2809:24thhellershadow-cljs has the dependency on ring-core but excludes clj-time#2019-05-2809:24thheller
[ring/ring-core "1.7.1"
    :exclusions
    ;; used by cookie middleware which we don't use
    [clj-time]]
#2019-05-2809:24thhellerlike like maybe that exclusion is added to your ring dep?#2019-05-2809:24thhellermight be a bug in tools.deps?#2019-05-2809:25Ahmed HassanI'm using Pedestal, not Ring for server.#2019-05-2809:26thhellerpedestal uses some ring middlewares IIRC?#2019-05-2809:26thhellersomething is loading the cookies.clj which is probably from ring#2019-05-2809:27thhellercheck clj -Stree#2019-05-2809:27thhellerin case you aren't already doing this I would recommend putting all CLJS related deps (including shadow-cljs) into a dedicated :cljs (or so) alias#2019-05-2809:32Ahmed HassanI have put it in :dev alias. with CLJS and binaryage/devtools.#2019-05-2809:39thheller@ahmed1hsn I just tested and it seems to be a bug in tools.deps. you can "fix" it for now by simply including the clj-time dep manually#2019-05-2817:19hlolliI'm building on windows, and constantly hit with a missing node-module readable-stream/writeable.js. Someone had this before?#2019-05-2817:24hlolliI'm in an emulator so I can't copy paste, but it's being called from stream-browserify, which is from node-libs browser, which is required by shadow-clj#2019-05-2817:38hlollinevermind, I need my glasses, mix up the plural readable-streams to singular readable-stream#2019-06-0117:42kanwei@thheller Was profiling my app and noticed that there were a lot of reflection warnings in shadow-cljs. Any interest in fixing these if I start working on that?#2019-06-0119:44thheller@kanwei sure. not sure they matter too much since there isn't much native interop going on in performance sensitive code#2019-06-0202:57cheppreyWhen I save changes from emacs, my "state" (like any atoms that get defined) are all reset. But any "running" go-loops seem to multiply. I'm not sure how to avoid this. If I define an "started-up" atom flag to guard against a go-loop getting spun up more than once, my flag gets reset back to false each time I save changes, so I can't prevent multiple go-loops from starting up. How can I enforce having any go-loop only starting up one time, regardless of how many times I hit save in my editor?#2019-06-0203:42gklijsThere is defonce to prevent declaring multiple times. The second time it will reuse the same atom. Might also fix the starting multiple go-loops. Something else to watch out for is having functions executed instead of only defined. So reloading will just update functions and nothing else.#2019-06-0204:26cheppreyThanks! I'll give defonce a try. Not sure I follow the bit about functions executed vs defined on "reload" (does "reload" mean browser reload? or save in editor? or both?)#2019-06-0206:11gklijsFor example you could have something like (start-loop "foo" "bar") somewhere but then you start a new loop each time the code reloads. So you want to either start it by some action, or in some file that is not reloaded.#2019-06-0212:31cheppreyAhhh ok, good call-out. Thanks again 👌#2019-06-0207:44Ahmed HassanWhat does this error mean in cider-nrepl while connecting with cider-connect-sibling-cljs?#2019-06-0207:45yendais loading of cljs modules implemented on react-native?#2019-06-0207:52thheller@ahmed1hsn that means the embedded server was not started. see https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2019-06-0207:57Ahmed Hassan@thheller when embedded server is started I don't need to run npx shadow-cljs watch main? Because I have already running this command in another shell before runnning cider-connect-sibling-cljs.#2019-06-0207:57thheller@yenda as far as I know react-native and/or metro do not support loading code dynamically#2019-06-0207:58thheller@ahmed1hsn if you have shadow-cljs watch running then you do not need the embedded server. you are likely just not connected to the correct shadow-cljs instance#2019-06-0207:59thhellerI don't use emacs so I can't help much. don't know how current this is https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2019-06-0208:28Ahmed HassanHow do I find correct shadow-cljs instance?#2019-06-0208:28Ahmed HassanIt's still giving same errors.#2019-06-0208:31yenda@thheller they have introduced inline requires fairly recently#2019-06-0208:31thheller@ahmed1hsn the easiest way is to configure a fixed port for nrepl and connect to that remotely https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2019-06-0208:34thheller@yenda hmm it seems to be built directly on require so no cljs :modules would not work for that#2019-06-0209:20Ahmed Hassan@thheller it works.#2019-06-0220:01flyboarderAre we still not able to disable source map support?#2019-06-0220:01flyboarder
SHADOW import error /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/app/cljs-runtime/app.server.js
/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539
      throw new TypeError('Line must be greater than or equal to 1, got '
      ^

TypeError: Line must be greater than or equal to 1, got null
    at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:539:13)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/node_modules/source-map/lib/source-map-consumer.js:604:22)
    at mapSourcePosition (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:199:42)
    at wrapCallSite (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:343:20)
    at /Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:378:26
    at Array.map (<anonymous>)
    at Function.prepareStackTrace (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:377:24)
    at process.emit (/Users/matt/.boot/cache/tmp/Users/matt/Projects/cannabit/cannabit-identity/ukm/fyoiyj/node_modules/source-map-support/source-map-support.js:431:52)
    at process._fatalException (internal/process/execution.js:123:25)
#2019-06-0220:01flyboarderI am getting this when I try to use express-session#2019-06-0220:05thhellerI don't see shadow-cljs in that stacktrace anywhere?#2019-06-0220:05thhelleris it just failing to parse the source map and swallows the actual error?#2019-06-0220:12flyboarder@thheller that seems likely#2019-06-0220:12flyboarderanyway to disable source maps?#2019-06-0220:13flyboarderin release I get Maximum call stack exceeded#2019-06-0220:13thhellerwell it would help to find out whats wrong. :compiler-options {:source-map false} disables them#2019-06-0220:13emil0r#2019-06-0220:14emil0rGetting that error when trying to use mqtt.js#2019-06-0220:14emil0rand the file exists under node_modules >_<#2019-06-0220:14emil0rshadow$provide[“module$node_modules$process_nextick_args$index”] = function(global,process,require,module,exports,shadow$shims) { ‘use strict’;#2019-06-0220:14emil0retc#2019-06-0220:15emil0rbit perplexed as i had it working with figwheel#2019-06-0220:16thhellerhad what working? please provide some example code I can run or so#2019-06-0220:17emil0r(mqtt/connect (:uri mqtt-opts) (clj->js (:opts mqtt-opts))) is the offending line#2019-06-0220:17emil0rand mqtt is required with [“mqtt” :as mqtt]#2019-06-0220:17emil0rhad it working in another project where i’m using figwheel#2019-06-0220:18emil0rlogs show it starts to connect and then complains about a missing function in process.nextTick#2019-06-0220:18thhellerand for figwheel you used cljsjs?#2019-06-0220:18emil0rbut it appears that the file providing process is there#2019-06-0220:18emil0ryeah#2019-06-0220:18emil0rinstalled mqtt via yarn#2019-06-0220:19thhellerfor figwheel?#2019-06-0220:19emil0rno, for this project#2019-06-0220:19emil0rcljsjs for the figwheel project, yarn for this project#2019-06-0220:20thhellerwell I know why process.nextTick is missing. just need to figure out why its not missing in the cljsjs packages since process.nextTick is usually a node function#2019-06-0220:21thhellerand doesn't normally exist in the browser#2019-06-0220:22emil0rit appears to be compiled though. is it an issue of ordering? it’s required at a later stage?#2019-06-0220:23thhellerhmm yeah the polyfill is included. you can get the same if you just use (:require ["mqtt/dist/mqtt" :as mqtt]) instead#2019-06-0220:24thhellerI should probably update the process polyfill that shadow-cljs includes. seems to be a bit dated by now#2019-06-0220:24emil0rdid the trick#2019-06-0220:25thhellerhttps://github.com/thheller/shadow-cljs/issues/502#2019-06-0220:26emil0rhow do you track down these errors @thheller? years and years of experience with the npm ecosystem or is there rhyme and reason to it?#2019-06-0220:26thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js#L36-L74#2019-06-0220:26thhellerthats where process comes from in browser builds#2019-06-0220:27thhellerso its clear why process.nextTick doesn't exist#2019-06-0220:27thhellerbut typically JS libs do something and don't use process in browser builds#2019-06-0220:27thhellerguess this one doesn't#2019-06-0220:27thhelleronly having the minimal polyfill because of that#2019-06-0220:28thhellerbut the polyfill I copied has nextTick support now so I guess that should be added#2019-06-0220:28thhellerhttps://github.com/defunctzombie/node-process/blob/master/browser.js#L134#2019-06-0220:36emil0r:+1::skin-tone-2:#2019-06-0314:02lxsameerhey folks, beside environment variables, I'm looking for a solution to set a value for both clj and cljs per build basis. Any suggestion ?#2019-06-0318:53thheller@lxsameer what kind of value do you mean?#2019-06-0318:56lxsameera string , currently I'm using env variables , but i was wondering if there is a better way through shadowcljs#2019-06-0318:58thhellerI meant what do you want to do with it?#2019-06-0318:58thhellerwhy do you need it accessible in CLJ?#2019-06-0318:58thhellerin a macro?#2019-06-0318:59lxsameeryupe, based on that value i load a different edn file and feed some part of it to cljs#2019-06-0319:02thhellerthere is no clean way to do this. why do you need to load it at compile time?#2019-06-0319:03thhellerI mean there are a couple of ways to do this. just none of them are "clean"#2019-06-0319:04thhellerso if you can avoid it at all you should 😛#2019-06-0319:04lxsameerthanks man 😉#2019-06-0322:48Piotr RoterskiHey, clojurians! 👋 Anyone had luck with getting shadow-cljs to work with kee-frame in luminus generated app? An app generated with lein new luminus demo-app +kee-frame +shadow-cljs when running lein shadow watch app throws:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/pk/.m2/repository/thheller/shadow-cljs/2.8.37/shadow-cljs-2.8.37.jar!/shadow/cljs/devtools/client/hud.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.cljs.devtools.client.hud
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.core.async/go does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [shadow.dom :as dom]
   4 |     [shadow.xhr :as xhr]
   5 |     [shadow.animate :as anim]
--------------------------------------------------------------------------------
the error happens deep inside shadow-cljs lib. I'm new to clojure so I'm not sure how to approach this - do I have any chance of debugging this or should I just try different lib/versions?
#2019-06-0406:59thhellerthis is caused by having an old core.async version on the classpath#2019-06-0407:00thhellermake sure its [org.clojure/core.async "0.4.490"] or higher#2019-06-0500:25Piotr RoterskiThat was it! I added core.async to kee-frame exclusions and as a separate dep in project.clj:
[kee-frame "0.3.3" :exclusions [metosin/reitit-core org.clojure/core.async]]
[org.clojure/core.async "0.4.490"]
and it worked! Thank you!!
#2019-06-0323:03lilactown@pt.roterski I'm guessing it's pulling in an old version of ClojureScript. verifying...#2019-06-0323:34Piotr RoterskiThanks for reply! It's [org.clojure/clojurescript "1.10.520" :scope "provided"] in generated project.clj which, according to https://clojurescript.org/ , is the current version.#2019-06-0323:49NolanHas anyone run into issues running browser targets on ie10 and below? Runs great elsewhere. The console shows:
shadow-cljs - failed to load 15
shadow-cljs - failed to load 20
SCRIPT5009: 'Set' is undefined
SCRIPT5009: '<primary ns>' is undefined
Can’t be sure if this is specific to Shadow or not and haven’t done much digging quite yet, but curious if anyone has seen this.
#2019-06-0323:49NolanWould also be interested in ideas around where to begin debugging the failed to load <#> console warnings#2019-06-0323:52Nolanie11 seems great. this is output from {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d4a7bcb5b0bba3f9b7b8bea794e6faecfae7e3"}, :content ("[email protected]")}#2019-06-0402:27lilactownIt looks like Set is only supported in IE11 and above#2019-06-0402:28lilactownYou might need a polyfill. I don't think CLJS depends on it; are you using any npm libs that might need it?#2019-06-0403:46Nolani definitely could be. appreciate your input, thats really helpful.#2019-06-0403:48NolanI think it’s react; https://github.com/facebook/react/issues/11429#issuecomment-342148046#2019-06-0412:06yuhanwhat's the recommended way of integrating shadow-cljs into an existing clojure+deps.edn project?#2019-06-0412:07yuhanIf I add a shadow-cljs.edn file in the project root and use :deps true does this mean the clj and cljs sides are sharing the same dependencies?#2019-06-0412:09thheller@qythium depends on how you want to integrate everything#2019-06-0412:09thhelleryou could create a :cljs alias or so in deps.edn or you could just keep CLJS deps in shadow-cljs.edn#2019-06-0412:09thhellerthe recommended workflow is to just keep things separate#2019-06-0412:10thhellerCLJS doesn't gain anything by being integrated into a CLJ project#2019-06-0412:10thhelleryou can however just integrate it like any other library#2019-06-0412:13yuhankeeping it separate sounds good, so that means I'll have to have 2 JVM processes running in development? One for my existing clj project and the other running Shadow and the cljs repl#2019-06-0412:13thhelleryeah thats what I do typically#2019-06-0412:14thhellermost people seem to opt for the embedded version however so you only have one JVM running#2019-06-0412:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2019-06-0412:14thhellerbut that often means fighting with dependencies a bit more#2019-06-0412:15thheller:deps {:aliases [:cljs]} and a :cljs alias in deps.edn is OK if you want to keep all dependencies in one place#2019-06-0412:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2019-06-0412:17thhellerits fine to embed really, you don't lose any features. just can get a bit annoying when fighting dependency conflicts#2019-06-0412:19yuhanah, so that's what happens when I "connect-clj&cljs" in Cider?#2019-06-0412:20yuhandoes not embedding mean having 2 separate nREPL ports to connect to?#2019-06-0412:21thhelleryes#2019-06-0412:21thhellerif you use emacs it is probably best to go with the embedded route#2019-06-0412:22thhellerin Cursive it sort of doesn't matter since it doesn't rely on nrepl as mcuh#2019-06-0412:23yuhangot it, thanks! I'll try it both ways and see :)#2019-06-0413:30yuhanLooks like there's some sort of dependency issue with the [dali "0.7.4"] library, including it in the dependencies causes the error
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
 at java.base/java.lang.ClassLoader.defineClass1(Native Method)
 at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
 at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
 at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
 at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
 at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
 at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
 at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
 at shadow.build.classpath$pom_info_for_jar.invokeStatic(classpath.clj:355)
 at shadow.build.classpath$pom_info_for_jar.invoke(classpath.clj:346)
 at shadow.build.classpath$find_jar_resources_STAR_.invokeStatic(classpath.clj:439)
 at shadow.build.classpath$find_jar_resources_STAR_.invoke(classpath.clj:427)
 at shadow.build.classpath$find_jar_resources.invokeStatic(classpath.clj:554)
 at shadow.build.classpath$find_jar_resources.invoke(classpath.clj:528)
 at shadow.build.classpath$find_resources.invokeStatic(classpath.clj:608)
 at shadow.build.classpath$find_resources.invoke(classpath.clj:600)
 at shadow.build.classpath$index_path_STAR_.invokeStatic(classpath.clj:839)
 at shadow.build.classpath$index_path_STAR_.invoke(classpath.clj:836)
 at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
....
#2019-06-0413:31yuhanany idea how I should go about resolving this?#2019-06-0413:35thhellerhmm odd. might be https://clojure.atlassian.net/projects/TDEPS/issues/TDEPS-130#2019-06-0413:35thhellerhttps://github.com/stathissideris/dali/blob/master/project.clj#L15#2019-06-0413:40yuhanoh, so I have to manually add those excluded deps?#2019-06-0413:40thhellerdunno#2019-06-0413:41yuhantrying that out now-#2019-06-0413:41thhellermight fix it but I'm not sure which package that class is from#2019-06-0413:45yuhanthat was it, adding xerces/xercesImpl {:mvn/version "2.12.0"} to the deps list fixed the startup - although I haven't tried using the library#2019-06-0413:54yuhanI don't think it's specifically a tools.deps issue though, created an empty shadow-cljs project with only a single dependency on dali and the error still came up#2019-06-0421:08exit2Hello, I’m trying to move a figwheel project to shadow and I’m seeing this error around requiring macros#2019-06-0421:08exit2
Error in phase :compile-syntax-check
FileNotFoundException: Could not locate clojure/core/match__init.class, clojure/core/match.clj or clojure/core/match.cljc on classpath.
#2019-06-0421:09thhellercore.match not on the classpath?#2019-06-0421:09thhellercore.match not on the classpath?#2019-06-0421:12thhellercheck if core.match is in your deps.edn?#2019-06-0421:15exit2Ah yes thats it, thanks!#2019-06-0423:44exit2I can’t seem to match my ns correctly for my repl, I’m trying to call a (start) fn which is in my source paths, but I’m unable to resolve the symbol#2019-06-0423:44exit2
{:source-paths ["dev/server" "src/client"]
 :deps   {:aliases [:dev]}
 :nrepl  {:port 9000}
 :builds {:main {:target     :browser
                 :output-dir "resources/public/generated/js/dev"
                 :asset-path "/generated/js/dev"

                 :modules {:main {:entries [admin.core]}}

                 :devtools {:http-port  3000
                            :preloads   [devtools.preload
                                         fulcro.inspect.preload]}}}}
#2019-06-0423:49lilactownhow are you trying to call it?#2019-06-0500:52exit2@lilactown after running my main, I’m trying to call (start) in the browser repl#2019-06-0503:03lilactownWhat namespace?#2019-06-0503:03lilactownWhat namespace?#2019-06-0503:39exit2its saying “user” for the ns, but none of my functions are available#2019-06-0503:42lilactownWhat ns is your functions in?#2019-06-0504:02exit2(ns user)#2019-06-0504:03exit2which is in dev/server/user.clj#2019-06-0504:03lilactownThat's a clj file. Your trying to use it in cljs?#2019-06-0504:04exit2yes, I wasn’t sure if that mattered or not#2019-06-0509:21mitchelkuijpersIt seems I am running into this bug: https://github.com/thheller/shadow-cljs/issues/502 Does anyone know if there is workaround for this?#2019-06-0509:30thhellerdepends on the lib that is using that?#2019-06-0511:41mitchelkuijpersI think this is problem: https://www.npmjs.com/package/readable-stream#2019-06-0512:05thhellertry 2.8.38. should work now#2019-06-0512:09mitchelkuijpersWorks you are an absolute legend#2019-06-0509:35mitchelkuijpersI am trying to use the readoc React component and I get this error:
Error: Error downloading  
process.nextTick is not a function
    at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
    at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)

TypeError: process.nextTick is not a function
    at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
    at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
    at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
    at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
    at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
    at new Promise (<anonymous>)
    at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)
#2019-06-0509:37mitchelkuijpersI am trying to use the redoc React component and I get this error:
Error: Error downloading  
process.nextTick is not a function
    at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
    at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)

TypeError: process.nextTick is not a function
    at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
    at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
    at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
    at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
    at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
    at new Promise (<anonymous>)
    at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)
#2019-06-0510:22lxsameerhey folks, is there any way to instruct shadow-cljs to not include a namespace in the final build ?#2019-06-0510:23thhellerdepends on what you mean by that#2019-06-0510:23thheller:preloads already deal with that#2019-06-0510:24lxsameerlet me describe what I'm trying to do#2019-06-0510:25lxsameerI have like several functions in my cljs code, i have a macro which reads a configuration file and create a new function that calls two of these functions in cljs#2019-06-0510:26lxsameerthose cljs functions spread through several NSs, in order for the macro to work i need to either require all of those namespaces#2019-06-0510:26lxsameeror i have to be able to manipulate the ns form ( for requirements ) on compile time to avoid having all the functions in the final build#2019-06-0510:27lxsameernow I'm looking for my options to deal with this problem#2019-06-0510:27thhellerI don't get it?#2019-06-0510:28thhellerI mean why do you need to "un-require" one namespace?#2019-06-0510:29lxsameerto avoid having it in my final build.#2019-06-0510:29thhellerbut you said the created function needs it?#2019-06-0510:30lxsameercreated functions uses only two function out of possible 10 ( based on the configuration ).#2019-06-0510:30lxsameerso for example i have these functions: ns-a/A , ns-b/b, ..... ns-z/Z.#2019-06-0510:31lxsameerI create a function using a macro based on some configuration that may only use two of them#2019-06-0510:32lxsameersince in cljs app i don't know which before hand and I can't manipulate the ns form of the main namespace ( the one which i use the macro in it )#2019-06-0510:32lxsameeri have to require all the namespaces from ns-a to ns-z#2019-06-0510:32lxsameerthis way all of them are going to end up in my build#2019-06-0510:33thhellerI still don't get it sorry.#2019-06-0510:33thhellerwhy is it a problem that those namespaces are included#2019-06-0510:33lxsameerthey're big#2019-06-0510:33thhellerwhat does the macro do that requires functions from separate namespaces?#2019-06-0510:34thhellerwhy are they big?#2019-06-0510:34thhellerwhy not just move the code the macro uses to a "better" place?#2019-06-0510:34lxsameereach of those namespaces are a different SPA application by themselves#2019-06-0510:34thhellerwould help if you have an example I can look at#2019-06-0510:34lxsameersure#2019-06-0510:35lxsameersend you a link#2019-06-0510:39lxsameer@thheller https://gitlab.com/devheroes/webman/blob/master/src/clj/webman/pages.clj#L48#2019-06-0510:39lxsameerthis is the macro#2019-06-0510:39lxsameerI included it's expansion in the comment below it as well#2019-06-0510:40lxsameerhttps://gitlab.com/devheroes/webman/blob/master/src/cljs/webman/views.cljs#L44#2019-06-0510:41lxsameerand here i tried to use the macro#2019-06-0510:43thhellerso what I would suggest here is not using a macro in the first place#2019-06-0510:44thhelleroption a) generate a .cljs files from your config and just compile that file normally#2019-06-0510:45thhelleroption b) use the build config to control which namespaces go into a build#2019-06-0510:45thhellerand have the namespaces "register" themselves in some kind of registry on load#2019-06-0510:46lxsameera) seems simple and easy, can i do this with preloads ?#2019-06-0510:46lxsameerb) do you mean via modules ?#2019-06-0510:46thhellerjust do it via a clojure function (completely outside the build process)#2019-06-0510:48thhellerb) could be modules but doesn't have to be#2019-06-0510:48lxsameerso can you please explain it a bit more#2019-06-0510:49thheller:modules {:app {:init-fn webman.core/init :entries [webman.page.foo webman.page.bar]}}#2019-06-0510:49thheller(ns webman.page.foo (:require [some.registry :as reg])) (reg/add-page ::foo {:bla "blubb"})#2019-06-0510:50lxsameerOh I see#2019-06-0510:50thhellerin the build config you just control which namespaces are used in the build#2019-06-0510:51lxsameerso what will happen if webman.core requires a ns which is not in the :app entries ?#2019-06-0510:51thhellerand the namespaces sort of configure themselves#2019-06-0510:51thhellerit doesn't require anything. thats the point#2019-06-0510:51thhellerit never calls anything directly#2019-06-0510:51thhellerif calls things only through the registry#2019-06-0510:51thhellerregistry could be just an atom#2019-06-0510:52lxsameerAhhhhhh, i got it now#2019-06-0510:52lxsameercoool#2019-06-0510:52lxsameerthanks a lot man#2019-06-0511:13lxsameer@thheller it's totally possible to alter the build configuration via a hook for :configure stage, right ?#2019-06-0511:13thhellerdepends on what you mean by alter#2019-06-0511:14thhelleryou can adjust the configuration yes#2019-06-0511:15lxsameerlike adding more entries to a module#2019-06-0511:15thhelleryes that would be possible although not really recommended#2019-06-0511:16thhellerif you are thinking about doing that I would STRONGLY suggest going with option a) instead#2019-06-0511:17thhellerbuild-hooks are several orders of magnitude more complex than a simple clojure function that spits out something like (ns app.main (:require [foo.bar])) with all the namespaces you are trying to dynamically add#2019-06-0511:17thhelleronly because you can in theory solve the problem using the build tool doesn't mean you should#2019-06-0511:18lxsameeryou have a very good point#2019-06-0511:20thhelleryou can use the clj-run feature to generate it so shadow-cljs run webman.generate path/to/config.edn path/to/output.cljs#2019-06-0511:21lxsameerthanks for your time man#2019-06-0511:22thhellercould of course just run it via clj directly. no need to involve shadow-cljs#2019-06-0511:24thhellerbut its much easier to verify that the output you wanted is correct just by looking at the generated output#2019-06-0511:25thhellerand just compiling it as a normal file will be much more reliable as well#2019-06-0511:25thhellerbuild hooks that deal with configuration aspects always get problematic since you are then responsible to keeping everything in sync#2019-06-0511:25thhellereg. retrigger a recompile if the extra build config changes etc#2019-06-0511:32lxsameeri see what you mean, I'll go with the option A. thanks friend#2019-06-0515:10ShaneLesterAnyone else all of a sudden getting Use of undeclared Var cljs.core/destructure-map on compiles today?#2019-06-0619:29JustinJust wonder if you by chance figured this out? I'm also getting the same warnings.#2019-06-0515:59carkhi have a strange behavior here ... In dev mode I require [datascript.transit :as dst] the namespace compiles fine, but when i try to make use of it, it says datascript.transit is null... which it is : (log js/datascript.transit) indeed is null, while (log js/datascript) has the whole datascript namespaces showing#2019-06-0515:59carkhwhere should i look ?#2019-06-0516:08carkhok scratch that, that's again the lack of refresh of the extension for added namespaces to a background page#2019-06-0518:39thheller@shanelester55 uhm did I mess something up? I was working on a CLJS patch that changes destructuring a bit#2019-06-0518:40thhellerthat change was not supposed to be part of the release 😛#2019-06-0518:41thhellerhmm where do you get that?#2019-06-0518:50thhellerwow yeah the AOT release contained my patched clojurescript version for some reason#2019-06-0518:51thhellersorry about that .. fixed in 2.8.39#2019-06-0519:24stefan
If your project uses React 16 and Reagent 0.8.0-alpha2 (or higher) then you will need to add the qualifier -react16 to the version, e.g. [day8.re-frame/re-frame-10x "VERSION-react16"]
#2019-06-0519:24ShaneLesterawesome, thanks for the quick response. I am giving it a shot right now#2019-06-0519:26stefanWould the syntax for the above be something like in my shadow-cljs.edn
...
:dependencies
 [[day8.re-frame/re-frame-10x "0.4.0-react16"]]
...
#2019-06-0519:26stefanI receive an error when I try to build that#2019-06-0519:28stefan
cli version: 2.8.37  node: v12.3.1
shadow-cljs - updating dependencies
shadow-cljs - dependency update failed - Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central ()
DependencyResolutionException Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central ()
	org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:355)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:806)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:707)
	clojure.core/apply (core.clj:657)
	clojure.core/apply (core.clj:652)
	cemerick.pomegranate.aether/resolve-dependencies (aether.clj:815)
#2019-06-0519:29stefanI’m trying to install re-frame-10x. If I ignore the -react16 qualifier I can see the re-frame-10x panel but it is not reflecting the info in the app-db, it is just empty#2019-06-0519:43thheller@stefan.age there does not seem to be a 0.4.0-react16 version? https://clojars.org/day8.re-frame/re-frame-10x/versions#2019-06-0519:45stefanah ok, maybe that instruction doesn’t apply to 0.4.0#2019-06-0522:21devoHow do polyfills work with shadow-cljs? Been having an issue recently trying to play around with a browser js dependency from cljs due to a dependency requiring util and stream.#2019-06-0522:56devoactually looks like I can just resolve those from the window. Now running into closure compilation complaints about duplicate classnames in dependencies. Search goes on :man-shrugging:#2019-06-0607:52thheller@devo could you be a bit more specific? what exactly is your issue?#2019-06-0607:58thhellerutil and stream are among the packages that have automatic browser polyfills so I'm not exactly sure what you are asking?#2019-06-0614:44devosorry, my issue was that I had to be explicit about how to resolve those in the shadow-cljs.edn file. i.e.
:js-options {:js-provider :shadow
                              :resolve
                              {"process"
                               {:target :global
                                :global "window.process"}
                               "util"
                               {:target :global
                                :global "window.util"}
                               "stream"
                               {:target :global
                                :global "window.stream"}
                               "buffer"
                               {:target :global
                                :global "window.buffer"}
                               "string_decoder"
                               {:target :global
                                :global "window.string_decoder"}
                               "events"
                               {:target :global
                                :global "window.events"}
                               "crypto"
                               {:target :global
                                :global "window.crypto"}
                               "querystring"
                               {:target :global
                                :global "window.querystring"}
                               "url"
                               {:target :global
                                :global "window.url"}}}
#2019-06-0614:44thhellerno. that config is entirely unnecessary#2019-06-0614:45thhellerit should not be needed at all#2019-06-0614:45thhellerremove the :resolve completely and tell me the error you get 😛#2019-06-0614:47devo
C:\Users\Devo\source\repos\compiler_repro>npx shadow-cljs compile main
shadow-cljs - config: C:\Users\Devo\source\repos\compiler_repro\shadow-cljs.edn  cli version: 2.8.39  node: v10.5.0
WARNING: The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
[:main] Compiling ...
The required JS dependency "process" is not available, it was required by "node_modules/prop-types/checkPropTypes.js".

Searched in:C:\Users\Devo\source\repos\compiler_repro\node_modules

You probably need to run:
  npm install process

See: 
#2019-06-0614:47thhellerright. I assume you are just missing the shadow-cljs dependency in the project#2019-06-0614:48thhellerie. no shadow-cljs in your package.json#2019-06-0614:48devooh shoot 😅#2019-06-0614:48thhellerit brings in the node-libs-browser dep which is missing here#2019-06-0614:53devothanks! That worked! Now I just need to figure out the closure exceptions I'm seeing. Is there an easy way to work around closure exceptions in dependencies? error itself
[:main] Compiling ...
Closure compilation failed with 1 errors
--- node_modules/n3/lib/N3DataFactory.js:45
Multiple classes cannot share the same name.
#2019-06-0616:44thhellerhmm yeah dunno what that one is about#2019-06-0608:45mhueberthm, possible bug with module-spitting. in an advanced build I’m seeing the error:
ReferenceError: $cljs$cst$keyword$pro_SLASH_review$$ is not defined
the :pro/review keyword is also used in another module. if I rename that keyword (in the other module), then this error goes away and I get the same error with another similarly-used keyword.
#2019-06-0608:47mhueberti can try to make an isolated repro#2019-06-0608:47mhuebertnot sure if it is shadow-specific in any way#2019-06-0608:48mhuebertone related issue: https://clojure.atlassian.net/browse/CLJS-3063#2019-06-0608:54thheller@mhuebert this can happen if you module dependencies aren't configured "correctly"#2019-06-0608:55mhuebertok. when listing :depends-on, do you have to list all the transitive dependencies?
#2019-06-0608:55thhelleryes#2019-06-0608:55thhellerI thought that was implicit but it isn't for some reason#2019-06-0608:55mhuebertah. i wasn’t doing that. maybe thats the issue.#2019-06-0608:55thhellerdidn't have time to look into that in detail yet#2019-06-0608:55thhellerthat linked CLJS issue is not a problem in shadow-cljs#2019-06-0608:58thhellerthe problem you see can also happen if you "share" build outputs from different build passes#2019-06-0608:58thhellerso make sure that all files you load belong to the same build#2019-06-0608:58thheller(you had the problem with 2 builds in one output-dir before IIRC)#2019-06-0608:59mhuebertyeah. this project has only one build, and i’ve tried to keep those out-dirs separate now 🙂#2019-06-0609:00thhelleralso make sure you are loading things in the correct order#2019-06-0609:01mhueberti think i had mistakenly listed a module that I am lazy-loading, as a :depends-on of my root module#2019-06-0609:01mhuebertso then the root modules assumes “hey this exists”#2019-06-0609:02mhuebertwhen i actually only load it later#2019-06-0609:02thhellermight be yeah#2019-06-0609:02mhueberti had a confused mental model of how to put this stuff together#2019-06-0609:03mhuebertthe manual-listing-of-transitive-dependencies, is that from cljs proper#2019-06-0609:04thhellerfrom the Closure Compiler kind of#2019-06-0609:05thhellerbut should be easy to fix in shadow-cljs#2019-06-0609:06thhellerjust always assumed that closure would do this automatically#2019-06-0609:06mhuebertyeah i would have thought so too. seems obvious#2019-06-0609:08thhellerto be fair the constant extraction code is from me#2019-06-0609:08thhellerso it sort of could be blamed on me#2019-06-0609:09thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure/ReplaceCLJSConstants.java#L45#2019-06-0609:09thhellerthat code does seem to need to full transitive deps#2019-06-0609:11mhuebertso we’d need to do a pass over the module config to build up the graph?#2019-06-0609:12thhellersomething that populates :depends-on yes#2019-06-0609:13thhellerhmm nah .. probably enough in the JSModule construction code#2019-06-0609:14thhellerif you open an issue I'll take care of it later#2019-06-0610:20Ahmed HassanWhen I run node script.js it gives following error. I've puppeteer in package.json and installed with npm install.#2019-06-0610:36thhellerwhere is the rest of the error ...#2019-06-0610:36thhellerthere should be a stacktrace with the actual error#2019-06-0611:28Ahmed Hassan#2019-06-0611:33thhellerand the package is properly installed in the directory of script.js? ie. /home/maverick/Desktop/automat/node_modules/puppeteer?#2019-06-0611:35thhellerError: Cannot find module 'puppeteer' thats the node error for missing packages#2019-06-0611:41Ahmed HassanThanks. I had installed puppeteer-core but was requiring puppeteer.#2019-06-0615:46metacriticalCan i bundle a cljs lib i created in shadow-cljs as a jar?#2019-06-0616:41thhellershadow-cljs currently has no support for creating jars no#2019-06-0616:41thhellerI'd recommend lein#2019-06-0617:45metacritical@thheller Aah, i thought there is something missing in the docs. Thanks though!#2019-06-0618:16knubieI’m trying to add a new build to my config but getting this error when running the compiled js file: Uncaught Error: browser bootstrap used in incorrect target#2019-06-0618:17knubieit’s just a simple file that runs (js/console.log "foo") any one know what causes this error?#2019-06-0618:18knubieConfig looks like this.#2019-06-0618:18knubieI’m requiring it in my main js file as a worker, so maybe that has something to do with it#2019-06-0618:18knubieoh, nevermind, just saw that there is a worker section in the docs#2019-06-0618:19knubiei’ll have a look at that#2019-06-0619:47Drew Verleecloned and followed the instructions here https://github.com/thheller/reagent-expo. When i tried to run cider-connect-cljs w/ shadow i got a java.lang.RuntimeException "Invalid token: :" any ideas where to start?#2019-06-0620:46thheller@j.lum07 that should be fixed in 2.8.39?#2019-06-0620:47thheller@drewverlee I don't use emacs so no clue what that means ... having a full stacktrace would be useful?#2019-06-0621:20Drew Verlee#2019-06-0621:20thhelleris there any clue about what it is trying to read?#2019-06-0621:24thhellermake sure you have the proper cider-nrepl versions and so on#2019-06-0621:24thhellerI really don't know enough about emacs to be of much help#2019-06-0701:27Drew Verleeah ok thanks.#2019-06-0621:10JustinThat worked! Thanks @thheller!#2019-06-0714:47dangercoderAre there any guides on how to get a static webapp working with shadow-cljs? I want to host it on a cdn. Saw this post before https://clojureverse.org/t/creating-websites-with-shadow-cljs-gatsby-or-next-js/2912#2019-06-0804:10neupshhi, I am trying to try geom library from here: https://github.com/thi-ng/geom I have added {:mvn/version "0.0.908"} in my deps.edn and just included [thi.ng.geom.webgl.core :as gl] in require section of one of my cljs file. I get the following compilation error:
Status
X Compilation failed.

------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/user/.m2/repository/thi/ng/geom-webgl/0.0.908/geom-webgl-0.0.908.jar!/thi/ng/geom/webgl/core.cljs:628:40
--------------------------------------------------------------------------------
 625 |                      (let [ctx (.getContext canvas (first ids) attribs)]
 626 |                        (set! (.-onselectstart canvas) (constantly false))
 627 |                        (if ctx ctx (recur (next ids))))
 628 |                      (catch js/Error e (recur (next ids))))))]
----------------------------------------------^---------------------------------
Error in phase :compilation
Can't recur here at line 628 thi/ng/geom/webgl/core.cljs
--------------------------------------------------------------------------------
 629 |        (or ctx (err/unsupported! "WebGL not available")))))
 630 | (defn clear-color-buffer
 631 |   [^WebGLRenderingContext gl r g b a]
 632 |   (.clearColor gl r g b a)
--------------------------------------------------------------------------------
#2019-06-0804:11neupshHas anyone seen this error or been able to use the geom library in your projects?#2019-06-0808:51yuhanStrange, that definitely looks like a syntax error#2019-06-0808:51yuhanThe version you're using is a few years outdated, have you tried with the latest 1.0.0-RC3?#2019-06-0814:14neupsh@qythium yes!! thank you very much. There are a lot of changes on the latest snapshot including refactoring of namespaces as well. I got past all the compilation errors now.#2019-06-0822:51tony.kay@thheller I’ve run into an issue where I can’t get a macro to update. I tried adding :cache-blockers to config, but no go (it’s not a side-effecting macro, but it is split as helper functions among files)#2019-06-0822:54tony.kayeven if I turn build options caching off it still doesn’t work#2019-06-0822:55tony.kaywhich is really weird to me…all I can think of is that it can’t see that the helper function in another namespace should affect the macro#2019-06-0822:59tony.kayyeah, confirmed: If I write supporting code for a macro in a CLJ namespace, then write the top-level macro in a CLJC namespace (with conditional compile of the macro to CLJ only), then changing anything in the CLJ impl namespace is not picked up. If I move them together into the same file it works as expected.#2019-06-0907:37thheller@tony.kay yeah macros with dependencies aren't tracked properly currently. see https://github.com/thheller/shadow-cljs/issues/495#2019-06-0916:33tony.kayGot it, thanks. It isn’t that bad to have to put them in the same ns.#2019-06-0907:38thhellerif a restart doesn't fix it you might have some AOT compiled code on the classpath#2019-06-0907:38thhellerotherwise you currently only can reload the macro related things via the REPL#2019-06-0910:57pezHello. I am switching to bundling the Calva vscode extension using Webpack (from not really bundling it at all). It works fine for production builds, but I get WARNINGS when the cljs is compiled by the dev watcher:
WARNING in ./cljs-out/cljs-lib.js 70:56-63
    Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
     @ ./calva/nrepl/jack-in.ts
     @ ./calva/extension.ts
(`jack-in.ts`) is the first place where the cljs-lib is imported) Then the extension fails to load with the following message:
Activating extension 'betterthantomorrow.calva' failed: ENOENT: no such file or directory, open '/.shadow-cljs/builds/calva-lib/dev/out/cljs-runtime/goog.debug.error.js'.
I’m a bit stumped on what could be going on here. Anyone else with an idea?
#2019-06-0911:02pezSo, I get that warning, and the crash, when running anything else but shadow-cljs release, (e.g. compile or watch). With release things are dandy.#2019-06-0911:13pezThe only mention of Webpack in the user manual is with the :npm-module target. But that has proven not to work for Calva builds. (Or, at least, didn’t work last time I tried it.)#2019-06-0911:31thheller@pez if you use webpack you need :npm-module. no other way around it#2019-06-0911:46pezOK. Let’s hope I can use it this time then. 😃#2019-06-0911:47pezWhat are my other options? I am not wed to Webpack. Maybe I can use shadow for bundling?#2019-06-0917:57TrevorHi folks, what's the proper way to include a React component from Material-UI in a way that works in Cursive? I'm trying to load this file into the REPL
(ns app.common.CenteredContainer
  (:require
    [reagent.core :as r]
    ["@material-ui/core/Grid" :default Grid]
    ))

(defn centered-container
  [props & children]
  [:> Grid (merge {:container  true
                   :spacing    0
                   :direction  "column"
                   :alignItems "center"
                   :justify    "center"
                   :style      {:minHeight "80vh"}} props)
   children])

(def CenteredContainer (r/reactify-component centered-container))
And I get this error in the Cursive CLJS REPL:
Syntax error macroexpanding clojure.core/ns at (CenteredContainer.cljs:1:1).
((:require [reagent.core :as r] ["@material-ui/core/Grid" :default Grid])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
When I remove the Material-UI require, I can then send forms to the REPL just fine, but if I have it, I get the above error. Using VS Code Calva I can interact with the in-editor REPL just fine. Maybe this is a question for #cursive ? Thought I'd try here though since it sounds like this might be specific to Shadow CLJS? Thanks!
#2019-06-1003:22Jonhttps://twitter.com/jiyinyiyong/status/1137767127090323456#2019-06-1008:40thheller@trevor670 looks like you are trying to eval the ns in a CLJ REPL rather than a CLJS REPL#2019-06-1013:17TrevorThanks @thheller, I do choose 'CLJS' from the cursive REPL dropdown, but is there something else I should do too?#2019-06-1013:19thhellerthat select box does nothing#2019-06-1013:19thhelleras I said you need to eval (shadow/repl :your-build-id). that will also automatically switch the select box#2019-06-1013:22Trevorawesome! Thanks!#2019-06-1016:47Trevorhahahahahaha it wooooorks!!! Thanks @thheller!!#2019-06-1008:40thhellermake sure you switched to your build REPL first via (shadow/repl :your-build-id)#2019-06-1008:41thheller@jiyinyiyong yeah that data isn't very accurate. It doesn't parse project.clj or deps.edn. only package.json and pom.xml#2019-06-1014:23mynomotoHi, does shadow expose a socket prepl? Looking at the docs looks like it doesn't.#2019-06-1014:30thheller@mynomoto it does. :socket-repl {:port 1234} in shadow-cljs.edn#2019-06-1014:31mynomoto@thheller is that a simple socket-repl or a prepl?#2019-06-1014:31thhellersimple socket repl#2019-06-1014:33mynomotoOk, the tooling I want to use depends on a prepl. Is there a way to get one currently?#2019-06-1014:34thhellersame way you'd get one everywhere else#2019-06-1014:34thhellerbut in general prepl isn't well supported currently#2019-06-1014:35mynomotoI'm on tooling bleeding edge. @olical conjure uses one for clojurescript on figwheel land, I want to try it over shadow.#2019-06-1014:36thhellerI didn't spend too much time on prepl yet since it doesn't solve the "upgrade" problem#2019-06-1014:36mynomotoWhat is the upgrade problem?#2019-06-1014:36thhellerstarting a CLJS prepl from a CLJ prepl#2019-06-1014:37thhellerfeel free to open an issue about prepl. I can look into it in a few days#2019-06-1014:38mynomotoOk, thanks!#2019-06-1015:10OlicalInterested in the upgrade problem since I never really saw it as a problem. I know with nREPL and stuff you connect to a Clojure REPL then somehow hop into a ClojureScript context (which I never really understood). As far as I know with prepl that's not the way you'd handle it, you just start two prepl ports, one for CLJ and one for CLJS. Which Conjure is designed around.#2019-06-1015:11OlicalIf you have an existing ClojureScript instance running, say, through figwheel. You can get the eval context and actually give that to the ClojureScript prepl server. This means you can basically attach a prepl server to any evaluation environment, I think.#2019-06-1015:11OlicalSee here for a little example of plugging a prepl server into figwheel https://oli.me.uk/2019-03-22-clojure-socket-prepl-cookbook/#figwheel_and_prepl#2019-06-1015:11OlicalIt worked really well for me 😄 I'd imagine the flow would be similar for shadow-cljs.#2019-06-1015:21lilactownFunnily, I don’t really understand how one can have a prepl in CLJS :zany_face: I should look into this soon#2019-06-1015:24lilactownYou’re still running the CLJS prepl server in the JVM process, right? Or is it somehow starting the repl in the JS process?#2019-06-1015:28OlicalIt'll still require a Clojure JVM I think yeah. I haven't used it much other than making sure it works. As that post shows though, you can plug a prepl into some other eval environment, it doesn't need to start it but it can. So you can have it boot it's own node instance to run in or you can jack it into something that's already running. (such as figwheel / shadow)#2019-06-1019:39dangercoderDoes anyone use shadow-cljs and aws lambda? What libraries are you using?#2019-06-1020:28tianshulooks like expo had a update on AppEntry.js.#2019-06-1020:56stefanis there a beginner walkthrough for adding my own font files to a shadow-cljs project?#2019-06-1100:19tony.kayDid something change with respect to modules that isn’t documented? I can build a code-split app with the last of the shadow 2.7 series, but if I use latest it tells me it cannot find my module.#2019-06-1100:20tony.kaywhen I look at shadow.loader.mm.moduleInfoMap is it empty#2019-06-1100:23tony.kayIt does build an output file though:
SHADOW_ENV.load({}, ["book.demos.dynamic_ui_main.js","shadow.module.ui-main.append.js"]);
#2019-06-1100:23tony.kayhttps://github.com/fulcrologic/fulcro-developer-guide/blob/master/shadow-cljs.edn#2019-06-1107:19thheller@tony.kay only the initialization logic changed. in general that should only be an issue if you use shadow.loader before it was initiated#2019-06-1115:12tony.kayBut I was using cljs.loader, so I thought that didn’t apply. It’s ok I guess. I’m making shadow-cljs a requirement in Fulcro 3, so it won’t matter 🙂#2019-06-1115:12thhelleryou can use cljs.loader thats fine#2019-06-1115:12thhellerits just a timing issue. can't use it before its initialized#2019-06-1115:13tony.kayI’m triggering it from a user mouse button press#2019-06-1115:13thhellerif you just use :init-fn as intended it won't be a problem#2019-06-1115:13tony.kayok, I’ll do that. Thanks 🙂#2019-06-1115:13thhellerhmm that should definitely work#2019-06-1115:13tony.kaythat was my thought 😉#2019-06-1115:14thhellerI'll try to take a look later#2019-06-1115:16tony.kayin the meantime, I’ll add init fn 🙂#2019-06-1115:23tony.kayAh, is this new?
You only need to add :module-loader true to your build config. The loader will always be injected into the default module (the one everything else depends on).
#2019-06-1115:24tony.kayI didn’t have that#2019-06-1115:24thhellerno that was always there#2019-06-1115:25tony.kayI think that fixed it. My bad, it seems 🙂#2019-06-1115:26tony.kayit worked without that option in the 2.7 series for some reason#2019-06-1115:28thhellerhmm yeah it should be optional but I need to figure out a better way to see if its needed automatically first#2019-06-1107:20thhellerI'd recommend using :init-fn which ensures that doesn't happen#2019-06-1107:21thhellerotherwise you might need to call (shadow.loader/init "") manually wherever your init happens?#2019-06-1107:21thhellercan't find the actual init for the book code?#2019-06-1107:23thheller@stefan.age font files are not related to CLJS compilation in any way so any non-webpack example of adding fonts will work#2019-06-1107:23thhellerie. a tiny bit of CSS @font-face#2019-06-1109:37p-himikI just an interesting error on a new project:
The required JS dependency "process" is not available, it was required by "node_modules/prop-types/checkPropTypes.js".
The peculiar thing is that in an old project, prop-types is also used by some library, but it works fine.
#2019-06-1109:38p-himikAlthough I have no idea how it's all supposed to work given that the apparent source of the error is this line: if (process.env.NODE_ENV !== 'production') {. I think process.env is available only for nodejs targets, not for browser targets. And yet the old project somehow works.#2019-06-1109:39thhellerinstall shadow-cljs in the project.#2019-06-1109:44p-himikThat worked, thank you. But how is that supposed to work in production, given that the manual recommends installing shadow-cljs as a dev dependency?#2019-06-1109:44thhellerdev dependency is fine#2019-06-1109:45thhellerhaving only the global install is not fine#2019-06-1109:51p-himikI don't think that's the case. I just removed node_modules, ran npm i --production=true, and finally shadow-cljs release main. It gave me the same error about missing process.#2019-06-1109:54thhelleruhm don't do that#2019-06-1109:54thhellernpm i --production=true#2019-06-1109:54thhellerit doesn't affect the build in any way#2019-06-1109:54thhellerand you need dev dependencies to build stuff#2019-06-1109:57p-himikOh, right. I remember now reading somewhere that you don't agree with the split of prod and dev dependencies because CLJS compilation deals with dead code anyway. But there's some virtue to it still. E.g. there are dependencies required only for testing, profiling, debugging, tracing. And while they won't end up being in the released JS file, their installation takes time. And if we think about CLJ dev dependencies, they also take space when you don't ship your whole app in a single uberjar.#2019-06-1109:58thhellerno you are misunderstanding how things work#2019-06-1109:59thhellerthink about it for one second. assuming you don't have the global shadow-cljs install (which you shouldn't rely on anyways) and you only have shadow-cljs in your dev dependencies (which you should)#2019-06-1109:59thhellerhow would you invoke shadow-cljs with npm i --production=true#2019-06-1110:00thhellerhaving shadow-cljs installed in the project was pretty much ALWAYS required. it just sort of worked sometimes if you had the global install#2019-06-1110:04thhellerproduction=true is only for runtime for node apps, nothing that requires building will ever work with that#2019-06-1110:08p-himikI see, thanks. > how would you invoke shadow-cljs with npm i --production=true lein yada-yada-yada. Or via the code, in my case: juxt/kick.apha - we've talked about it some time ago. > having shadow-cljs installed in the project was pretty much ALWAYS required So ideally, we should have 3 scopes instead of just prod and dev: running in production, running in development, building. And the shadow-cljs dependency would fit only in the building scope, right?#2019-06-1110:12thhellerto be accurate here. it isn't the missing shadow-cljs that causes the issue here. it is the missing https://github.com/webpack/node-libs-browser which shadow-cljs depends on (eg. for process)#2019-06-1110:13thhellerdunno why you'd split development and building. "development" seems to cover that in my mind#2019-06-1110:14thhellerin case of browser things. NOTHING is required for "running in development" since the produced build output contains everything#2019-06-1110:15thhellerdon't make things more complicated than they already are 😛#2019-06-1110:15thhellerjust keep it at prod/dev#2019-06-1110:19p-himikYeah, I probably described it poorly. I meant it more like a composition thing. The building scope is extracted to a separate one because it's common for every other scope. And the development scope just always includes the building one, yes. > just keep it at prod/dev But that's exactly what I'm trying to do! 😄 I just didn't realize that including shadow-cljs as a dev dependency doesn't mean that it's useful only during the development. So in my case, I'll probably just move it to the main list of dependencies, to make the dev list contain only the things that are not even supposed to be downloaded for the production build.#2019-06-1110:20thhellerno don't do that#2019-06-1110:21thhellerwell .. I guess you can but it wouldn't be idiomatic in case you ever build a node app#2019-06-1110:22thhellershadow-cljs release is still a development thing. only the output is a production thing.#2019-06-1110:28p-himikOh. I must admit I've never touched node. And hopefully, never will. > shadow-cljs release is still a development thing So the production image building process is considered a development step? And "production" is only "running the production build"? See, that's why the three hypothetical scopes are still somewhat useful. I guess it's just profiles in terms of lein/`deps.edn`, but AFAIK package.json doesn't support anything like it. I just remembered another point towards not downloading dev dependencies during the production build. Apart from the saved space, it's also a safeguard against including something dev in the production env.#2019-06-1110:29thhellernot installing dev dependencies to build is just not an option#2019-06-1110:30thhellerif you want to split into more profiles you can do that but even for deps.edn you can't build an uberjar without some kind of dev dependency#2019-06-1110:31thhellerand putting things into dev dependencies IS you safeguard against installing dev stuff in production#2019-06-1110:31thhellerwe are talking about the browser here anyways so it doesn't make sense to talk about production deps in any way#2019-06-1110:32thhellersince the browser can't use your node_modules folder anyways#2019-06-1110:32thhellerdoesn't matter whats in it#2019-06-1110:36p-himik> you can't build an uberjar without some kind of dev dependency Interesting point, thanks. Looking into all kinds of uberjars is still on my radar. So far, the experience has been far from pleasant. > since the browser can't use your node_modules folder anyways > doesn't matter whats in it Yes, I realize that. But I don't quite realize how that could ever work without profiles and without dead code elimination. So, generally speaking, how does that even work in the browser JS world? Suppose I have some... I don't know, React debugging library that must be built into the application code in order to work. Obviously, you don't want to use it in production at all. But at the same time, if you have to use dev dependencies during the release image build process, how do you prevent that debugging library from ending up in the production code?#2019-06-1110:37thhellerwell that where the if (process.env.NODE_ENV !== 'production') { comes into play#2019-06-1110:37thhellerthat lets you do conditional requires in node#2019-06-1110:38p-himikNo-no-no, browser JS.#2019-06-1110:38thhellerthat is browser JS#2019-06-1110:38thhellerwebpack AND shadow-cljs compile that away#2019-06-1110:38thhellerso that only the conditional requires are removed#2019-06-1110:39thhellerbasically it is inline as a constant#2019-06-1110:39thhellerif ("development" !== 'production') {#2019-06-1110:39thhellerthe closure compiler then takes care of removing the "dead" code#2019-06-1110:41p-himikThat's why I wrote "and without dead code elimination" 🙂 Is the DCE our only hope here? Did things not work at all before it has been brought into the JS ecosystem?#2019-06-1110:42thhellerhehe the fun times are ahead of us since with ESM you can't do the conditional require anymore#2019-06-1110:42p-himikI feel like something like that is going on in the Python world right now, with requirements.txt. Since there are no scopes and profiles anywhere, people just write multiple files with all kinds of suffixes, and then write scripts to use different files in different environments.#2019-06-1110:42thhellerso they have to come up with new fun ways to do things#2019-06-1110:42p-himikOh wow. The fun never ends, does it.#2019-06-1110:43thhelleryeah. so far it looks like this is our future https://github.com/WICG/import-maps#2019-06-1110:44thhellerbut its still planning stages. nothing implemented yet.#2019-06-1110:45thhellerthe other path using dynamic import() is even more fun ..#2019-06-1110:45thhellerJS is a complete mess 😞#2019-06-1110:46thhellerto be fair though conditional requires aren't exactly easy or nice in CLJS#2019-06-1110:52p-himikWell at least they bring this point there. > JS is a complete mess 😞 And it pains me to see that CLJS cannot avoid some of it, even if we forget about imports at all. But to be honest, I'm still reluctant to just throw everything together during the release process. Imagine you have hundreds of MBs of libraries that are only useful during debugging. And that DCE has some bugs. What would you do?#2019-06-1110:53thhellerfirst of all things won't compile at all if you are relying on DCE to remove things#2019-06-1110:53thheller(if the deps are missing)#2019-06-1110:54p-himikOh no, I don't. There are dev preloads.#2019-06-1110:56thhellerthen you didn't rely on DCE 😉#2019-06-1110:56p-himikGod dammit.#2019-06-1110:57p-himikSo if a library is in node_modules and nothing ever imports that library, it won't end up in the release JS files even if DCE is not used?#2019-06-1110:57thhellerno just like CLJS only things that are actually required will be used in a build#2019-06-1110:58thhellerjust having files sitting there does nothing#2019-06-1110:59p-himikHmm. I guess I got confused by Java/CLJ. Hard to say at this point.#2019-06-1111:02p-himikAnyway, thank you for the discussion. It has definitely been fruitful for me - now I know how to shave this yak a bit better.#2019-06-1111:04thhellerto be fair here the java/CLJ parts could use some yak shaving as well#2019-06-1111:04thhellerwe pretty much are content with including an entire dependency in an uberjar#2019-06-1111:05thhellereven if we only used one class out of potentially thousands#2019-06-1111:07p-himikDoes uberjar'ing include only the dependencies that are explicitly imported? So if I use conditional imports, do I somehow have to explicitly make sure that the required dependencies end up being in the uberjar? Regarding single classes, or functions in case of CLJ - yes, Rich Hickey had a talk on it, a quite good one.#2019-06-1111:08thhellerno uberjar just includes everything in the source .jar file#2019-06-1111:08thhellerthere are tools that remove unused stuff but they don't work for CLJ#2019-06-1111:08p-himikAh. So it's even worse. If I forget to remove something from deps.edn and never use it, it will still be there.#2019-06-1111:09thhelleryep#2019-06-1111:10thhelleralthough only in size, they still won't be loaded at runtime#2019-06-1111:10thhellerjust dead bytes in the uberjar#2019-06-1115:30mccraigmccraigi'm currently looking at moving my boot driven cljs compilation over to shadow... and wondering whether to keep boot around or not. what other tools do people use for doing things like [a] dynamic configuration of closure-defines (from e.g. envvars) and [b] less compilation#2019-06-1115:32thhellerpeople mostly just use shadow-cljs#2019-06-1115:33thhellerthis lets you override closure-defines from the CLI, similar to env vars I guess https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2019-06-1115:33thhelleror just env vars https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2019-06-1115:34mccraigmccraigah, cool, i can definitely use that#2019-06-1115:35mccraigmccraigand for things like less/sass compilation, do people generally use node stuff directly ?#2019-06-1115:41thhelleryeah#2019-06-1119:04idiomancyis there an equivelant to webpacks copy-webpack-plugin thay copies over static assets to the output directory? I want to put some ES6 node_modules during build over there#2019-06-1119:46idiomancyactually I suppose I need the html plugin... the one that recursively converts imports in html files. but then again, I may be able to simply use webpack 🤔#2019-06-1119:04idiomancythe ES6 stuff never interacts with the cljs stuff#2019-06-1119:21credulousHi! I’m trying to get a project working using shadow-cljs and the cli/deps tools. It’s a re-frame app. Everything seems to be working as expected… except I can’t get the actual browser DOM to update when I make changes to the source files.#2019-06-1119:22credulousHere’s the app core.cljs:#2019-06-1119:22credulous
(ns alexandria.core
   (:require
     [reagent.core :as reagent ]
     [re-frame.core :as rf ]
     [day8.re-frame.http-fx]
     [alexandria.events]
     [alexandria.subs]
     [alexandria.routes :as routes]
     [alexandria.views :as views]
     )
   )

 (defn main-panel
   []
   [:h1 "Alexandria"]

 ;  (let [active-panel (rf/subscribe [:active-panel])]
 ;    [views/show-panel @active-panel]
 ;      [:div [:h2 "Alexandria "]]
 ;    )
 )

 (defn mount-root
   []
   (rf/clear-subscription-cache!)
   (println "mounting root")
   (reagent/render [main-panel]
                   (.getElementById js/document "app")
                   ))

 (defn ^:export init
   []
 ;  (routes/app-routes)
   (println "Initializing")
   (rf/dispatch-sync [:initialize-db])
   (mount-root))
#2019-06-1119:23credulousI’ve reduced it to just putting a h1 on the page. That works. When I change the string “Alexandria”, or change the h1 to an h2, shadow compiles it fine, the shadow-cljs dashboard page shows a compilation, and the shadow-cljs icon at the bottom left of the browser window appears. But the text on the page doesn’t change - the actual DOM doesn’t get updated.#2019-06-1119:24credulousI’m making some boneheaded mistake or omission, but I haven’t been able to find it.#2019-06-1119:25isak@credulous in your shadow-cljs.edn, do you have something like {:devtools {:after-load alexandria.core/mount-root}} ?#2019-06-1119:25credulousNope!#2019-06-1119:26isaki'd try that, or code changes wont re-render app, AFAIK#2019-06-1119:28isakin case you don't already have that key, the path is [:builds <something> :devtools ...]#2019-06-1119:28credulousYup, adding now…#2019-06-1119:30credulousThat did the trick, thanks!#2019-06-1120:26lxsameerhey folks, I'm using re-frame with shadow-cljs, when i update my component code and save it, hot code reload works and i can see in the console that my namespace re-evaluates but the dom doesn't update, i have to do a full refresh to see the dom changes#2019-06-1120:26lxsameerhow should i debug this#2019-06-1120:38thheller@lxsameer see the above conversation. do you have a lifecycle (ie. after-load) configured to re-render your app? https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2019-06-1120:38thhellermount-root in the above example#2019-06-1120:41lxsameerinteresting#2019-06-1120:42lxsameerthanks#2019-06-1120:48lxsameeractually it doesn't work in my case, apparently it's a caching issue, i changed the namespace but the log messages are still for the old one#2019-06-1120:51thhellerlook at the browser console. shadow-cljs will tell you what its doing. the rest is up to you#2019-06-1120:51lxsameerif i block my main namespace would it recompile the whole project on each change ?#2019-06-1120:52thhellerblock?#2019-06-1120:52thhellermain namespace?#2019-06-1120:52lxsameernever mind#2019-06-1120:57lxsameerthis is my browser log, http://dpaste.com/1934KF3#2019-06-1120:57lxsameeri don't get what you mean by "shadow-cljs will tell you what its doing. the rest is up to you"#2019-06-1120:57lxsameerit's connected by it shows no reaction to changes#2019-06-1120:58thhellerhmm?#2019-06-1120:58thhelleris there a warning in the bottom left?#2019-06-1120:59thhellerwhats with all the 404?#2019-06-1120:59lxsameerthat's a css file#2019-06-1121:00thhelleryou are using a regular watch I presume?#2019-06-1121:00thhellerwhat does that log show?#2019-06-1121:01lxsameerthe interesting this here is that , I removed the console.log expression for line 4 and 5#2019-06-1121:02lxsameerI'm using shadow/watch fn#2019-06-1121:02lxsameerthe log stuck in compiling#2019-06-1121:02lxsameerwhich is weird#2019-06-1121:05thhellerdunno what you are doing. it definitely shouldn't be stuck#2019-06-1121:05lxsameeri'm stoping the worker#2019-06-1121:05lxsameer*stopping#2019-06-1121:05thhellertry restarting maybe? is you CPU at max?#2019-06-1121:05lxsameerno#2019-06-1121:05thhellerinfinite loop or something?#2019-06-1121:05thhellerone core at max?#2019-06-1121:06lxsameeri don't think so#2019-06-1121:06lxsameerno all the cores are working but not more that 20%#2019-06-1121:07lxsameerstop-worker stuck as well#2019-06-1121:07thhellercall (shadow.cljs.devtools.server/reload!)#2019-06-1121:07lxsameerI had to close the session#2019-06-1121:10lxsameerthe problem seems to be solved, i just fired up a new repl#2019-06-1121:11lxsameeris there a way to manually invalidate the cache for a namespace ?#2019-06-1121:12thhellertouch src/foo/bar.cljs?#2019-06-1121:13lxsameerno I mean via clojure, I was reading about the compiler cache in the docs#2019-06-1121:13thhellerwhy would you need to?#2019-06-1121:14lxsameerapparently if I want to use macros with side effects i should black list the namespace right#2019-06-1121:14lxsameersorry add the ns in :cache-blockers#2019-06-1121:15lxsameerso shadow won't cache that ns#2019-06-1121:15thhelleror use (ns ^:dev/always foo.bar)#2019-06-1121:16lxsameerok in this case it make sense to let the developer invalidate the cache for that ns in specific cases#2019-06-1121:16lxsameerfor example I know when my macro would do the side effect and i can just invalidate the cache in that situation otherwise i still can benefit form the cache#2019-06-1121:20thhellerthat would be possible but currently there is no API for that#2019-06-1121:21lxsameerthanks#2019-06-1123:24grantDoes anybody have a suggestions for trying to debug an npm package that will give me an object when I :require it, but doesn't seem to have the export I am looking for?
-->
(require '["basicchart" :as bc :refer (BasicChart)])
-->
-->
bc
-->
#js {...}
-->
-->
BasicChart
-->
nil
-->
#2019-06-1123:53lilactown@grant it would help to know what’s inside the object 😛#2019-06-1123:53lilactownI can’t find the lib you’re talking about on npm#2019-06-1123:56grantThat one was more an example. I can't share the code on the actual package, unfortunately, and I only have the minimized version myself.#2019-06-1200:04grantAlso why I was hoping for suggestions on things to look for or places to explore. It's a react component. And if I copy the code out of node_modules and into my source (require '["/name.js" :as n :refer (Component)]) gives me the same result. Their code comes in both es and cjs versions, the cjs seems to load, but shadow throws an exception when I try to require the es version directly.#2019-06-1200:09lilactownI would console.log the object, and see if the Component is in object#2019-06-1200:09lilactownright now it’s hard to tell what you’re experiencing#2019-06-1200:09lilactownyou should be able to see a key :Component in the #js {…}#2019-06-1200:10lilactown(using console.log here might be better than e.g. println)#2019-06-1200:10lilactownyou should be able to do something like: (.-Component n)#2019-06-1200:10lilactownand see the component you’re trying to :refer to#2019-06-1200:11lilactownif it’s just not there, I don’t know. I’d have to look at the code. there might be some other documentation they have on how to import that might be more illuminating#2019-06-1200:13lilactowne.g. it might be in some submodule "basicchart/BasicChart" or if it’s using the ES module it might be behind a default key#2019-06-1200:14grantYea, I tried the console.dir and looked, the component isn't there. I tried their example code. It was JSX, so I put it through babe and added that code into my project. No dice there either.#2019-06-1200:14lilactownhow do they import it in their example code?#2019-06-1200:16grant#2019-06-1200:17grantI wasn't sure if maybe their code didn't get along with the closure compiler, or if there was something with that exception shadow was throwing.#2019-06-1200:17lilactownsounds like their docs are just wrong?#2019-06-1200:18lilactownunfortunately I can’t really help you without more information#2019-06-1200:19grantYea, I figured it was a long shot. If it was my code I'd just share it.#2019-06-1200:19grantThe shadow exception is just Exception in thread "async-thread-macro-9" java.lang.RuntimeException: java.lang.Exception: Not supported: class clojure.lang.ExceptionInfo
#2019-06-1200:20grantAnd seems to complain about transit things in the stacktrace.#2019-06-1200:21lilactowngo ahead and post the whole stacktrace#2019-06-1200:21lilactownthis only shows up when compiling with this require?#2019-06-1200:23grantOnly when compiling the es version of their package code placed directly into my source path.#2019-06-1200:24lilactownbut not with the cjs version#2019-06-1200:24lilactowni’m not sure how shadow-cljs treats JS files on the classpath tbh. I think it might do some special things for node_modules that it might not do for normal JS on the classpath#2019-06-1200:24grant#2019-06-1200:25grantCorrect, just the es, not the cjs version.#2019-06-1200:26grantYea, was mostly just trying to get datapoints, hoping to find a clue.#2019-06-1200:27grantThanks for trying to help @lilactown, I appreciate you taking the time.#2019-06-1208:28thheller@grant do you have the full exception trace? ... 20 more seems top be cutting of the relevant parts?#2019-06-1208:29thhelleras for the JS object see https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-06-1208:30thheller(js/console.dir x) is probably the most useful thing. I've seen JS packages that only have one default export and add properties onto that#2019-06-1208:30thhellerso if the object has a default property you might find what you are looking for there#2019-06-1209:58yuhanI have extra-dependencies specified in a deps.edn alias that I only want pulled in for a :dev build, how can this be done?#2019-06-1210:05thhelleryou can't#2019-06-1210:05thhellerwell you could with just clj#2019-06-1210:06thhellerclj -A:foo shadow.cljs.devtools.cli watch app#2019-06-1210:15yuhanoh okay, would you consider a feature request for such a mapping to be specified in the shadow-cljs.edn file?#2019-06-1210:16yuhansomething like {:builds {:dev {:deps/aliases [:dev] ...} ...}}#2019-06-1210:16thhelleroh I forgot. you can also do shadow-cljs -A:foo watch app#2019-06-1210:16thhellervia the config is not an option no#2019-06-1210:17thhelleryou should not have a build named :dev#2019-06-1210:17thhellerthat is not how it works in shadow-cljs#2019-06-1210:19yuhanoh.. why not? From what I understood builds can be used as a way to pull in dev dependencies and additional source paths/compiler optimizations#2019-06-1210:19thhellerno builds can not affect anything classpath related#2019-06-1210:20thhellercompiler options yes but nothing that affects dependencies or source paths#2019-06-1210:21thhellerthe classpath applies to the entire started JVM#2019-06-1210:22thhellerso if you run 2 builds and both would like different dependencies that wouldn't work#2019-06-1210:23thhellerthat being said you can do all of this via clj directly#2019-06-1210:23yuhanoh right, because you can start multiple builds on a single server#2019-06-1210:23yuhanthanks for clearing that up :)#2019-06-1212:24grant@thheller I am trying to figure out a good way to get the full stack trace. I am seeing it on the console output of the terminal running npx shadow-cljs server. I'm triggering it by doing the (require ...) in the browser based repl that server provides.#2019-06-1212:25thhellertry with shadow-cljs browser-repl instead, the web interface might not route some output properly maybe#2019-06-1213:42talgiatHi, can I point to different lein configurations in different builds, for example in test build I want to include more dependancies#2019-06-1213:53talgiatThe actual problem is not being able to use test check generators when connecting to nrepl started by shadow watch test#2019-06-1213:54talgiatgetting the following error:
(gen/generate (s/gen ::open?))
Error: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
#2019-06-1214:28thhellerdid you require clojure.test.check.generators?#2019-06-1214:33talgiatyes I did#2019-06-1214:33talgiatin the repl#2019-06-1214:33talgiatso from one terminal window I ran shadow-cljs watch test#2019-06-1214:34credulousHi! I’m having some trouble getting my dev setup going - I’m trying to use httpkit and compojure on the server side and shadow-cljs for all the javascript. Thanks to help from @isak yesterday, I got changes to my reagent components live-reloading in the browser. However I can’t seem to get changes to the .css file to reload.#2019-06-1214:34talgiatand from the other shadow-cljs cljs-repl test#2019-06-1214:35credulousI do have
:devtools {:after-load alexandria.core/mount-root
                            :http-root "/"
                            }
in my shadow-cljs
#2019-06-1214:35thheller/ is definitely not correct#2019-06-1214:35credulousI’ve played with what to put in :http-root#2019-06-1214:35thhellerit should be the path to your http root directory#2019-06-1214:35credulousMy compojure routes are serving out of /public#2019-06-1214:35thheller/public?#2019-06-1214:35thhelleryou mean public in your project dir?#2019-06-1214:36credulousYes, sorry for being unclear#2019-06-1214:36credulousshadow-cljs is compiling to /public/js/ in my project dir, that seems to reload well#2019-06-1214:37credulousThe css file is in /public/css/, it also loads fine from the browser.#2019-06-1214:37thhellerplease be careful in your use of /#2019-06-1214:37thhellerdo you actually mean /?#2019-06-1214:37credulousI’m all ears#2019-06-1214:37thhelleryour absolute file system root?#2019-06-1214:37credulousNope, I certainly don’t mean that#2019-06-1214:38thhellerthe path are relative to your project root UNLESS you start them with /#2019-06-1214:38thhellerso it most certainly should be :watch-dir "public"#2019-06-1214:38thheller:http-root does nothing if you don't actually use that webserver#2019-06-1214:38credulousOK#2019-06-1214:40credulouschanged {:http-root "public"} to {:watch-dir "public"} but still no joy#2019-06-1214:41credulousReloads changes to the cljs files but not to the css file.#2019-06-1214:41thhellerand the css file is in public/css/foo.css with your css file included in the HTML via <link rel="stylesheet" href="/css/foo.css">?#2019-06-1214:42credulousYes#2019-06-1214:43credulous
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e0928f8486928599a0ad8183a28f8f8bcdb0928fce888994928f8e889582ce888f8d85"}, :content ("[email protected]")}
#2019-06-1214:43credulous
<html>
  <head>
    <script src="/js/main.js"></script>
    <script src=""></script>
    <link rel="stylesheet" type="text/css" href=""></link>
    <link rel="stylesheet" type="text/css" href="/css/alexandria.min.css"></link>
    <meta charset="utf8" />
    <title>Alexandria</title>
  </head>
  <body>
    <div id="app">Hello from Alexandria dsf</div>
    <script>alexandria.core.init()</script>
  </body>
</html>
#2019-06-1214:45thhellerlooks fine#2019-06-1214:46credulousHere’s the actual build definition, perhaps I did something boneheaded#2019-06-1214:46credulous
{:source-paths ["src/cljs"]

  :dependencies [[bidi "2.1.6"]
                 [cider/cider-nrepl "0.22.0-beta1"]
                 [cljs-ajax "0.8.0"]
                 [com.andrewmcveigh/cljs-time "0.5.2"]
                 [kibu/pushy "0.3.8"]
                 [re-frame "0.10.6"]
                 [reagent-utils "0.3.3"]
                 [day8.re-frame/http-fx "0.1.6"]
                 [refactor-nrepl "2.4.0"]
                 [reagent "0.8.1"]]

  :builds {:alexandria {:target :browser
                 :output-dir "public/js"
                 :asset-path "/js"
                 :modules {:main {:entries [alexandria.core]}}
                 :devtools {:after-load alexandria.core/mount-root
                            :watch-dir "public"
                            }
                 }}

  :nrepl { :port 8777 }
#2019-06-1214:47thhellerlooks fine#2019-06-1214:47credulousBah#2019-06-1214:47credulousRestarted shadow-cljs server after changing to watch-dir and it works now#2019-06-1214:48credulousSorry to bother you! But thanks for the help!#2019-06-1214:49credulousBy the way, I love this system. I’ve actually been able to build up my shadow-cljs.edn and deps.edn from scratch and understand it all. I was never able to do that with lein or figwheel. Thanks for your work.#2019-06-1214:49credulouswhich says more about me than it does about either lein or figwheel, but there it is.#2019-06-1214:49thhellernot really. I couldn't do that either 😛#2019-06-1313:34sogaiui was just helped by: https://code.thheller.com/blog/shadow-cljs/2017/10/15/externs-the-bane-of-every-release-build.html#covering-the-last-few-percent -- for some reason, vscode.Position is not handled by inference (though vscode.Range is), i guess. would reporting this somewhere possibly help to improve the current inferencing?#2019-06-1314:02thhellerhow did you use it in code?#2019-06-1319:39lgesslerhi all, when i navigate to my dev server in chrome, I get a bunch of ERR_INSUFFICIENT_RESOURCES--it seems like too many requests for individual .js files are going out and chrome is choking. it works fine in firefox though. has anyone run into this issue before? i haven't even written much code in this project yet, so i'm not sure what to try#2019-06-1319:42lgessler(fwiw it looks like the .js file count is so high because i have material-ui as a dep, though of course i'd like to avoid the solution "stop using material-ui" 😬)#2019-06-1320:12lilactownI think you might be running into this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=958108#2019-06-1320:56thheller@lgessler you can try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-06-1321:29sogaiu@thheller i used it like this:
(defn position
  [r c]
  (vscode.Position. r c))

(defn range
  ([p1 p2]
   (vscode.Range. p1 p2))
  ([r1 c1 r2 c2]
   (vscode.Range.
    (position r1 c1)
    (position r2 c2))))
where above there was (def vscode (js/require "vscode"))
#2019-06-1321:50thhelleryeah thats not a supported construct for externs inference#2019-06-1321:50thhelleryou should use the proper (:require ["vscode" :as vscode]) and then vscore/Range#2019-06-1322:06sogaiu@thheller thanks!#2019-06-1322:09sogaiuthat seems to work 🙂#2019-06-1401:18lgessler@thheller incredible!! that did the trick, thank you for all your hard work 🙂#2019-06-1406:52lxsameerhey folks, how can I run a clojurescript function from CLI ? something like clj-run but for clojuresctip#2019-06-1407:02sogaiuyou don't mean something like lumo's -e flag by any chance?#2019-06-1407:07lxsameerhmmm, no more like -m for lein#2019-06-1407:07lxsameerbut for clojurescript#2019-06-1407:08lxsameerhmm i guess with lumo i can set the classpath and evaluate the function i want using the full path#2019-06-1407:08lxsameerbut does shadow supports something like this ?#2019-06-1408:46thheller@lxsameer that what :node-script is for. building that is. running things is not supported.#2019-06-1410:06lxsameeri see. I'm using node-script at the moment. I kinda needed this feature to integrate js tools in my env, for example PostCSS.#2019-06-1410:07lxsameershadow makes it easy to use npm modules it would've been awesome if this functionality exists#2019-06-1411:09thhellerit will never exist since it wouldn't be practical#2019-06-1411:09thhellermakes sense in lumo but not for anything that has to spin up an entire JVM first#2019-06-1411:10thhellerjust adds like 5sec to startup time#2019-06-1411:10thhellerwhich is impractical for scripting#2019-06-1411:10thhellerif you just build it once and run many times later you don't pay for that startup anymore#2019-06-1411:10thhellerso builing actual scripts makes more sense#2019-06-1411:16thhelleractually I shouldn't say that this will never exist since you can pretty trivially do this via clj-run. the command may just get a bit long#2019-06-1411:16thhellershadow-cljs run your.tool your.cljs.main output-to/foo.js or so#2019-06-1411:49maxtCan I get a cljs nrepl when using shadow embedded? When I use shadow-cljs start on the commandline, it opens port 9000 and I can connect to it using Cursive. Is there a way to get the same behaviour when starting shadow from a repl with (shadow-server/start!)?#2019-06-1411:52thhellerthe behavior is the same?#2019-06-1411:53maxtI'd like it to be, but start! doesn't open port 9000#2019-06-1411:53thhellerassuming you have that configured in shadow-cljs.edn as normal?#2019-06-1411:54maxtYes, I'm using the same config as I do when I start it from comman dline#2019-06-1411:54thhellerbut why do you want to start another nrepl server if you are already connected to one?#2019-06-1411:56maxtWell maybe I missunderstand something, but I think the one I have is for clj and I'd like a cljs one too#2019-06-1411:57thhellerhow did you get the first one?#2019-06-1411:57thhellerlein with project.clj?#2019-06-1411:57thhellerthe nrepl should defintely be started using start! though#2019-06-1411:57maxtCursive, with the nREPL and deps selected.#2019-06-1411:59thhellerhmm I'm not sure how you'd configure middleware with that method#2019-06-1411:59thhellerin theory you just need the shadow-cljs middleware loaded#2019-06-1411:59thhellerbut the shadow-cljs nrepl server should be working#2019-06-1412:00maxtI'll restart it and post what it says at start#2019-06-1412:01thhellerjust call stop! 😉#2019-06-1412:01thhellerbut JVM restart works too of course#2019-06-1412:02maxtJust wanted to be 100% sure I have a clean slate#2019-06-1412:06maxtNow it does start on port 9000 just fine. I'm so sorry to take your time with a crap question like that 😕 Thank you for always being so supportive#2019-06-1413:09pez@thheller about that Webpack problem I talked about the other day. (I'm building a :node-library since I had to eject trying to build it as an :npm-module after a lot of hard trying to make that work). I'm pondering my options. Since it works for release builds, I think I can try build the extension with Webpack only for those, and then use my current build config for development. (I am not sure I can make this work, but I think so.) However, is it just a fluke that it works for release builds, or is it something I can rely on?#2019-06-1413:10thhellerwhat is the problem with :npm-module?#2019-06-1413:10thhellerwhy do you need webpack?#2019-06-1507:19pezI don’t remember the details about :npm-module problems, just that I, with your assistance, couldn’t make it to work. It was something with the entry point.#2019-06-1507:22pezWebpack is what the vscode packager suggests that I pack my extension with for releases. And when I do that it shrinks it down from thousands of files and 20 MB. To one file of 1.6 MB.#2019-06-1509:08thheller@pez I can't remember the :npm-module problems either but it should be working fine. just may need to create one additional file manually or so. thats the part that :node-library basically does for you.#2019-06-1509:08thhellernot sure what webpack does that shadow-cljs release wouldn't do?#2019-06-1509:09thhelleror do you use many JS deps that need to be bundled as well? not sure how exactly vscode exts are packaged#2019-06-1510:20pezSo, in Calva, the cljs-lib is a small library, giving the TypeScript code (which is most of the code) access to some clojure facilities, like the cljs.reader and clj-fmt. The vsce packager greates a zip file with file extension .vsix, in which cljs-lib.js, created by shadow-cljs release is just one of the files. If I include Webpack in the build chain, it bundles all the js files into one, and vsce stops complaining about that I should use webpack. And the extension installs much faster and works excellently.#2019-06-1510:22pezAs for :npm-module problems. You and I really gave that a shot, back then. But we reached a point where you said, “use :node-library instead”. Which is where I am now. I can of course try with :npm-libarary again, but I don’t like the idea of spending days to again find out it won’t work. 😃#2019-06-1510:28thhellerwell :node-library is never gonna work with webpack during development and what you describe is easily possible with :npm-module#2019-06-1510:28thhellerwould help to remember why that was causing issues but I can't 😛#2019-06-1510:33pezI think I can give it a quick try and we'll see if it works or at least what the problem is.#2019-06-1510:41thhellerFWIW going through webpack is still gonna limit your development capabilities#2019-06-1510:41thhellerso live reload and REPL will be questionable regardless#2019-06-1510:50pezYou're right. Which points me in the direction of trying to not use webpack for dev and only for release. Which brings me back to the question about if you think I can rely on that the release build are currently working swell.#2019-06-1510:57thhellerhmm?#2019-06-1511:03pezYeah, so when I let webpack bundle things it works, but only in realease. In dev there are references to things in the .shadow-cljs dir that don't resolve. But, as you say, I might lose the repl and hot reload anyway with webpack, so not worth trying to solve that resolve problem.#2019-06-1511:06thhelleryes :node-library will NEVER work with webpack during development#2019-06-1511:06thhellerbasically all targets make certain assumptions about the runtime they are gonna be using#2019-06-1511:07thheller:node-library as the name implies assumes it will be running in node which is not true if you package it with webpack first#2019-06-1511:07thhellerit also assumes it can use the node runtime facilities to load code dynamically which is also not possible when using webpack#2019-06-1511:08thhellerso the only thing you'd gain with :npm-module+webpack during development is that it becomes loadable#2019-06-1511:08thhellerlive-reload and REPL probably won't work reliably#2019-06-1511:37pezI’ll avoid webpack for dev. And things the release build with webpack works, I can safely use that?#2019-06-1511:47thhelleryes release builds are just one file and don't do any dynamic loading#2019-06-1513:27mhueberthm, I am running into an obscure issue with shadow.loader in a production build. Module loading isn’t working, and I’ve determined that shadow.loader.initCalled is undefined. The problem goes away when I enable --debug mode, which makes me think maybe it has something to do with an advanced-mode name collision of some kind. I haven’t been able to reproduce locally, only when it is built on our CI server. (Just posting here in case some possible avenue to look at comes to mind, i’ll keep debugging)#2019-06-1513:30thhellerdo you get an actual reference to shadow.loader.initCalled in the optimized code?#2019-06-1513:30mhuebertI get a reference to the shadow.loader object,#2019-06-1513:31mhuebertit doesn’t contain an initCalled key#2019-06-1513:31mhueberthmm. if I call init I do see shadow.loader.init was already called!#2019-06-1513:32thhellerhow do you get a reference to that object?#2019-06-1513:32mhuebertwindow.shadow.loader#2019-06-1513:33thhelleryeah thats only the exported stuff#2019-06-1513:33thhellerclosure will have rewritten that and may have removed the property#2019-06-1513:34mhuebertok. probably unrelated to the issue then.#2019-06-1513:34thhellerwhat is the issue?#2019-06-1513:35mhuebertit repeatedly tries to load the same modules, and fails, only returning 1 as the error (which i believe just means ’consecutive errors`#2019-06-1513:35mhuebertrepeated network calls for the same module:#2019-06-1513:35thhellerassuming thats a 200 ok response?#2019-06-1513:35mhuebertyes#2019-06-1513:36thhellerit may be throwing an error on load#2019-06-1513:36mhuebertall 200#2019-06-1513:36thhellerie throwing an exception when the code is evaluated#2019-06-1513:36thhelleryou can try loading the code directly without the loader#2019-06-1513:36thhellerjust via normal <script> tags in the correct order#2019-06-1513:36thhellermakes debugging a bit easier#2019-06-1513:38mhuebertwill try that.#2019-06-1513:52mhuebertoh… maybe this is a caching issue. When I load modules normally I append a hash as a query param, eg. dropify.js?v=<hash>#2019-06-1513:52mhuebertthe module loader could be getting invalid/old versions#2019-06-1513:53mhueberti’ll try a script tag without the query param to double check.#2019-06-1513:55thhellerthen use :module-hash-names true 😉#2019-06-1514:53mhuebertSo, caching was indeed the issue. And using :module-cache-names was the solution. #2019-06-1521:17MudgeHey there, how do I specify what the init function is used when using :modules {:entries something.core} ?#2019-06-1521:18MudgeInside the :builds map#2019-06-1521:18MudgeAnybody here?#2019-06-1521:27thheller:modules {:main {:init-fn some.core/init}}#2019-06-1521:33MudgeThanks but I want to use the entries map too#2019-06-1521:33thhellernothing stopping you from doing that#2019-06-1521:34thheller:modules {:main {:init-fn some.core/init :entries [foo.bar]}}#2019-06-1521:34Mudgeohhh, thanks!#2019-06-1521:36Mudge@thheller I just started using shadow-cljs today. I really like it#2019-06-1522:12MudgeIs the manifest.edn needed in the release version of the build? Could I remove it or would that mess stuff up?#2019-06-1522:12MudgeIs it needed to make code splitting work?#2019-06-1522:19thhellerit is not needed no#2019-06-1522:20Mudgeokay, thanks#2019-06-1602:10MudgeWhy is the manifest.edn map in a list?#2019-06-1602:10Mudgeah, for multiple modules I guess#2019-06-1602:39Mudgemakes sense#2019-06-1602:55MudgeIt seems like the manifest.edn should not be generated in the same place as the target output, because the target output needs to be public, but it seems that the manifest.edn should not#2019-06-1605:55mojoHello, new to shadow-cljs; I'm in the process of migrating an application over from figwheel-main and am encountering an error with the npm module viz.js https://www.npmjs.com/package/viz.js. viz.js is an Emscripten transpile of graphviz (which is C) to asm javascript so the javascript itself (in full.render.js in the viz.js package) is pretty hairy!#2019-06-1605:57mojoI follow the instructions at the bottom of the viz.js author's page https://github.com/mdaines/viz.js/wiki/Usage and the shadow-cljs user guide (section 11) and require viz.js into my code as so#2019-06-1605:57mojo["viz.js/viz.js" :as Viz] ["viz.js/full.render.js" :refer (Module render)]#2019-06-1605:59mojoand get a shadow error#2019-06-1605:59mojoCaused by: RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. An enclosing scope is required for change reports but node LABEL 15 [length: 2] [source_file: node_modules/viz_DOT_js/full.render.js] doesn't have one. Node(FOR): node_modules/viz_DOT_js/full.render.js:15:4095#2019-06-1606:00mojoso, not really needing viz.js to be attempted to be further compiled, I set the following option in my shadow-cljs.edn#2019-06-1606:00mojo:js-options {:js-provider :require}#2019-06-1606:01mojobut unfortunately this seems to cause breaks around other existing dependencies in my project, for example [io.nervous/kvlt "0.1.4"]#2019-06-1606:02mojoAny tips on how to get this particular npm module to work (as an npm module) would be much apprecicated.#2019-06-1610:01thheller@mojo yeah the emscripten packages seem to confuse the closure compiler. :js-provider :require is only for node environments and doesn't work in the browser.#2019-06-1610:01thhellerfor viz you probably need to stick with https://github.com/mdaines/viz.js/wiki/Usage#using-a-script-tag for now#2019-06-1610:03thhellerit used to be compilable though https://github.com/thheller/shadow-cljs/issues/173#2019-06-1610:03thhellerbut yeah this option is still missing#2019-06-1610:05thheller> A hack to put Graphviz on the web.#2019-06-1610:06thhellera 2MB+ package is really not that practical for the web 😛#2019-06-1610:28mojoGot it - thanks for the steer. Yes - as the description says it's a (clever) hack 🙂 I also have Graphviz mounted as an AWS lambda but then realised that sending my company's data out over the web is not policy compliant hence the need for the hack! Would be supportive of the option to provide a list of modules which don't go through any compilation processing.#2019-06-1611:15mojoWorked perfectly - thank you#2019-06-1611:19mojoOne other thing to mention. I had also tried the approach of requiring the .js files as set out in section 11.2 of your excellent documentation, but had no luck with that approach - it couldn't find the modules even though I'd followed the suggested directory structure. Is that approach also only for the
node
environments? If so, as a newbie coming to the documentation, that wasn't immediately obvious to me and could well be worth clarifying
#2019-06-1611:19mojolol - still yet to get the hang of backticking in Slack 🙂#2019-06-1611:20thhellernot sure what you mean?#2019-06-1611:21thhellerthe require you had was correct#2019-06-1611:23mojoyes - requiring as a node module. Well, when that didn't work and before posting here, I always tried the approach laid out in section 11.2.1 of your documentation - requiring the js files correctly. The reason I tried that as well was that pretty sure I read there that any source .js files under a js/ would not be passed through compilation#2019-06-1611:24mojoso wondered alternative approach is valid for the :browser target? (and I just hadn't got it quite right) - or only for other targets?#2019-06-1611:24thhellerno that is incorrect. quite the opposite actually. the files will go through :advanced optimizations#2019-06-1611:24thhellernode_modules will only do :simple which already fails for viz.js so :advanced is unlikely to work#2019-06-1611:32mojoThe line that confused me was actually in the following section 11.2.3 - Notice how src/js is not added to :source-paths and will not be added to the classpath. Obviously, I must have speed read too much and jumped ahead thinking that between the two sections, there was a way to exclude .js files from the compiler but still be able to require them. my bad. thanks for clarifying#2019-06-1616:28lilactownI’m trying out that weird trick mfikes posted in #cljs-dev:
(do (declare ^{:arglists '([a b c] [a b & cs])} create-element)
    (set! create-element react/createElement))
and currently seeing this warning during compilation:
18 | (defn tag-render [{:keys [title body]}]
-------^------------------------------------------------------------------------
 Wrong number of args (5) passed to hiccup-next.react/create-element
--------------------------------------------------------------------------------
  19 |   #h/n [:div {:class "card"}
  20 |         [:div {:class "card-title"} title]
  21 |         [:div {:class "card-body"} body]
  22 |         [:div {:class "card-footer"}
--------------------------------------------------------------------------------

#2019-06-1616:34thhellerhow the heck is that even compiling? reader literals aren't supported like that?#2019-06-1616:35lilactown😄 what do you mean?#2019-06-1616:36thheller#h/n this isn't supported (in shadow-cljs)#2019-06-1616:36lilactownwhy not? it’s a perfectly valid ns’d symbol…#2019-06-1616:37thhellerbecause its nonsense to do this in code#2019-06-1616:37lilactownoh are custom reader tags not supported at all you mean?#2019-06-1616:37thhelleryes, no custom reader tags during compilation. at runtime is fine but not during compilation#2019-06-1616:37thhelleralso the arglist trick is sort of a cheat an probably doesn't support varargs#2019-06-1616:40lilactownhmm. I was getting some issues with the reader tags at first. I was able to work around it by having the CLJS namespace require the macro namespace#2019-06-1616:49lilactownshould I not expect reader tags to continue to work with shadow-cljs?#2019-06-1616:49lilactownhere’s my current experiment: https://github.com/Lokeh/thumps#2019-06-1616:50thhellerthey are not supported until I hear to compelling reason why they should be#2019-06-1616:51thhellerthe issue is that you are doing things during read-time. so you basically have to turn of caching since it impossible to tell what its going to do#2019-06-1616:52lilactownhmm. is there a significant difference between doing things at read-time vs. macro-time from the perspective of caching?#2019-06-1616:53thheller
(ns my-app.core
  (:require [hiccup-next.core]
            [hiccup-next.react :refer [<>]]))

(defn Mycomponent [props]
  (let [name (goog.object/get props "name")]
    (<> [:div {:style {:color "green"}}
         [:span "Hello, " name]
         [:ul
          (for [n (range 10)]
            (<> [:li {:key n} n]))]])))

(react-dom/render (<> [MyComponent {:name "Sydney"}])
  (. js/document getElementById "app"))
#2019-06-1616:53thhellerwhat do read-tags give you that you can't already do with function/macros?#2019-06-1616:53thhellerI totally get their use for actual data#2019-06-1616:53thhellernot so much for pure code#2019-06-1616:55thhellerthe difference with read-tags versus macros is that their dependency is never declared in the code#2019-06-1616:55thhellerso by looking at the ns form you can't tell that the namespace is gonna use hiccup-next.react unless you require it#2019-06-1616:55thhellerand if you require it you could just use a normal macro/refer#2019-06-1616:58lilactownI am starting to see the tradeoffs yes I’m just still not sure about your mention of caching. probably my naivety about how shadow-cljs works#2019-06-1616:59lilactownhonestly it’s just an experiment. I kind of like the aesthetics of #hiccup vs (hiccup)#2019-06-1617:00lilactownyou get the whole data-is-code / code-is-data thing goin’ on 😛 aesthetically#2019-06-1617:00thhellerexcept its not#2019-06-1617:00lilactownand it allows you to seamlessly do things like shove elements over the wire and back (which is something we’re doing at work atm in a different way)#2019-06-1617:02thhellerthe caching issue is due to the undeclared dependency stuff I mentioned#2019-06-1617:03thhelleryour code doesn't declare that is depends on something and therefore won't be invalidated if that something changes#2019-06-1617:03lilactownah yes, I have experienced this while developing the reader tag code#2019-06-1617:04lilactownbut I don’t expect that would impact people consuming it#2019-06-1617:04lilactownah, unless they register a new element keyword e.g. (register-element! :my-app/foo FooComponent)#2019-06-1617:06lilactownactually that would be in the react namespace which is required everywhere it’s used#2019-06-1617:07lilactownalthough it’s still global mutable state in a macro namespace so would probably still have issues#2019-06-1617:08thhelleryes quite bad#2019-06-1617:14lilactownthe one concrete thing I think I like about #h/n ... vs (h/n ...) is ease of typing 😛 I basically write hiccup like I have been trained with Reagent / hx, then stick the tag on the beginning at a few places and I’m done#2019-06-1617:14lilactownbut it’s not a strong technical argument#2019-06-1617:15lilactownhow mad will you be if other people start using it?#2019-06-1617:16thhellercouldn't care less 😛#2019-06-1617:16lilactowncool! 😄#2019-06-1617:17thhellerFWIW I have been down this road in CLJ when it was introduced#2019-06-1617:18thhellerI need a bunch of time stuff so I naturally added things like #time/duration {:minutes 30} etc#2019-06-1617:18thhellerI also used it over the write and stuff so it felt great#2019-06-1617:19thhelleruntil it got a total maintenance disaster and caused all sorts of weird issues with AOT#2019-06-1617:19thhellerin the end (time/duration {:minutes 30}) works just as well and has no such issues#2019-06-1617:20thhellerso if anyone wants to learn that lesson that is fine by me#2019-06-1617:20thhellerbut I won't be debugging any issues related to it 😉#2019-06-1617:21lilactown😬 😅#2019-06-1617:22lilactownyeah I haven’t tried it in CLJ much at all#2019-06-1617:23lilactownI started down the road of creating a CLJ implementation of React string rendering again… then got frustrated and gave up for now#2019-06-1617:25lilactownI was telling roman01la that I think it would be really nice to have a react.clj lib that was separate from a specific hiccup library / ui framework like rum / hx / uix / etc.#2019-06-1617:25lilactownthat would take some normalized format {:type "div" :props {...}} and implement turning those trees into an HTML string#2019-06-1617:26lilactownand then the rest of us can muck about with syntax / macros / extensions and processing on top of it instead of copying + pasting and rewriting the same code#2019-06-1617:27lilactownbut it’s a lot of work. there’s a lot of corners of HTML to cover#2019-06-1617:27lilactownI don’t think rum does it 💯#2019-06-1617:29thhellerwell the only way you are going to solve that properly is by not using react 😉#2019-06-1617:30lilactownhaha, well I think either way we have to write the code to cover those corners 😛 just React’s already done it in the browser for us!#2019-06-1617:34lilactownI am seeing a clear benefit of separating hiccup and the underlying rendering engine (whether it be React’s VDOM or something else)… there’s lots of different things we can do to improve the hiccup syntax experience, extensions, etc. that doesn’t really have anything to do with rendering HTML#2019-06-1617:34thhellersemantics are all that matter#2019-06-1617:35thhellerotherwise is just changing (:require [hiccup-next.react :refer [<>]]) to (:require [[something.else :refer [<>]])#2019-06-1617:36thhellerone thing I did in my experiments is making events declarative#2019-06-1617:36thheller[:div {:onClick (fn [e] ...)} ...] is bad for server rendered code#2019-06-1617:37thhellerand annoying on the client#2019-06-1617:37thheller[:div {:on-click [:foo 1 2 3]} ...] good on the server and client#2019-06-1617:38lilactownright! and separating the syntax from the engine that actually produces the resulting HTML/JS allows others to extend the semantics further without breaking compatibility with the engine#2019-06-1617:39thhelleryes, things should be as declarative as possible#2019-06-1617:39lilactownput another way, we could build that semantic on top of React and it would continue to work with other React components once parsed & compiled#2019-06-1617:40thhellerI'm not interested in react anymore personally#2019-06-1617:40lilactownyes, that’s just an example#2019-06-1617:42lilactownone of the reasons people have asserted that React isn’t needed and is inefficient is because we have hiccup. that we should use hiccup, instead of React’s VDOM#2019-06-1617:43lilactownand I was kind of on board with this argument for awhile, but now I think that coupling the syntax we use for writing code to the rendering engine is probably bad#2019-06-1617:46lilactownthere are other reasons to eschew React, but I think that “using hiccup AND <underlying VDOM implementation> is inefficient” is a problem with hiccup, not the VDOM 😛#2019-06-1617:46thhellerthe true superpower we have is macros so we should use them#2019-06-1617:47thhellerhiccup in itself is still too inefficient#2019-06-1617:47lilactownyes! 100% agreed#2019-06-1700:37caleb.macdonaldblackCan I shadow-cljs watch two builds in the same page at the same time? When I try to do this shadow-cljs watch app logger one of them cannot load properly because of 404s on the scripts it loads#2019-06-1701:08aisamuDoes it also happen when you shadow-cljs watch app, load shadow-cljs' UI and click the logger build?#2019-06-1702:18caleb.macdonaldblackYeah it does
#2019-06-1702:56aisamuHmmm. Watching works here with multiple builds (3+), so it's definitely possible! Are they perhaps sharing the output-dir? Does the second build work flawlessly when started alone?#2019-06-1902:34caleb.macdonaldblackYeah, they work fine alone#2019-06-1902:34caleb.macdonaldblackAlso they share the output-dir#2019-06-1905:29aisamuI suspect the issue is sharing the output-dir#2019-06-1707:46danielnealreact does give us react native, so for now I'm locked in to it...#2019-06-1708:32pyrHi, Since shadow-cljs and cljsjs don't play well with each other, are there documented ways of making things like soda-ash work well?#2019-06-1708:50pyrlooking at it, the adapt-react-class can be called on semantic-ui-react directly I suppose#2019-06-1709:16thheller@caleb.macdonaldblack you cannot load 2 dev builds on the same page in the browser#2019-06-1709:18thheller@pyr https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs works for all packages#2019-06-1709:40p-himikWhat would be the preferred way of writing a macro that is supposed to expand to CLJS code that uses Shadow-CLJS-style requires? E.g. I have
(:require ["@material-ui/core" :as core]
          [reagent.core :as reagent])
in my CLJS ns declaration. I then write some boilerplate code for each MUI component that I'd like to shove in a macro. I think I can get away with just assuming that reagent and core aliases are available when the expanded CLJS code is compiled. But is there a better alternative?
#2019-06-1709:42thhelleroption a) is creating "wrapper" functions in the macro ns. (defn foo [...] (core/foo ...))#2019-06-1709:43thhelleroption b) pass whatever material thing you are wrapping into the macro (the-macro core/thing ...)#2019-06-1709:43thhelleryou can in theory get the alias from the compiler env too but thats a bit shadow-cljs specific#2019-06-1709:44thhelleralso don't ever require "@material-ui/core" directly, be more specific with the requires#2019-06-1709:44thhellerotherwise you are adding a lot of maybe unused code#2019-06-1709:48p-himikNot sure I understand (a). Where would that core come from? "@material-ui/core" is not available for CLJ. Or did you mean basically what I said, so that function would end up being called only in the expanded code? What about a macro that does something like \(do (require ["@material-ui/core" :refer [Toolbar]]) (... using Toolbar))`? Yes, sure - I oversimplified the ns declaration a bit. I require only the things that I need.#2019-06-1709:50thhellerthats option b I mentioned?#2019-06-1709:56thhellerwould help to know what the macro actually is supposed to do#2019-06-1709:56thhellerwhy do you need to wrap MUI?#2019-06-1709:57p-himikNo-no. Option (b) I don't even consider as long as there are other alternatives - it still leaves quite a bit of boilerplate. OK, give me some time to actually come up with something. My macro-fu is not what it's supposed to be.#2019-06-1710:02mhueberti’m not sure it’s currently possible to avoid boilerplate with material-ui. AFAIK we need to have each specific component we want as an individual :require inside of ns, and we can’t manipulate ns forms with macros#2019-06-1710:03mhuebertmaterial-ui recently added support for tree-shaking but I don’t think it works with cljs#2019-06-1710:04thhelleryeah that currently doesn't work. I have some ideas on how to make it work but it is a lot of work I currently don't have time for#2019-06-1710:04mhuebertyeah i saw some of your discussions about that somewhere. this stuff seems difficult and a moving target#2019-06-1710:05thhelleryeah its a cutting-edge feature in webpack so doesn't seem "final" yet#2019-06-1710:05thhellernot many packages support it either yet so we'll see#2019-06-1710:07p-himikIdeally, it would be something like this:
(defmacro defcomponent [cljs-name args]
  ;; Intended usage:
  ;; (defcomponent app-bar [{:keys [classes color position] :as props} & children])
  ;; (defcomponent toolbar [{:keys [classes component disable-gutters variant] :as props} & children])
  ;; The full props specification is needed for correct parameters info during development.
  ;; E.g.in Cursive, `defcomponent` could be resolved as a function, making Cursive show that
  ;; `app-bar` accepts [{:keys [classes color position] :as props} & children] as parameters.
  (let [;; "app-bar" -> "AppBar"
        comp-name (string/join (map
                                 string/capitalize
                                 (string/split (name cljs-name) #"-")))]
    `(do
       (require ["@material-ui/core" :refer [~comp-name]])
       (let [comp (reagent.core/adapt-react-class ~comp-name)]
         (defn ~cljs-name [& props+children]
           (into [comp] props+children))))))
#2019-06-1710:08p-himikThere should also probably be (require [reagent.core]) but you get the idea.#2019-06-1710:09mhuebertisn’t require only a REPL thing in cljs?#2019-06-1710:09thhelleryeah thats not possible#2019-06-1710:10thheller:refer is kind of a trap here since it doesn't do what you think it does#2019-06-1710:10thhellerwebpack style tree shaking is not support for JS packages as mentioned above#2019-06-1710:11thhelleryou actually need different requires to make that work#2019-06-1710:11thheller(:require ["@material-ui/core/Button" ...])#2019-06-1710:14thhellerbut generating requires dynamically is not possible in any way#2019-06-1710:15p-himikYou're giving me too much credit. 😄 I don't have any idea what any of this is supposed to be doing. And I've never been a proper JS developer. Hmm, but (:require ["stuff/core" :refer [Component]]) seems to work just fine, just as (:require ["stuff/core/Component" :default Component]).#2019-06-1710:15thhellerif does work just fine yes#2019-06-1710:16thhellerbut if you require @material-ui/core you will require the "meta" package#2019-06-1710:16p-himikAh, I see.#2019-06-1710:16thhellerwhich includes EVERY component the package provides#2019-06-1710:16thhellerso it adds about 1.2mb to you JS#2019-06-1710:16thhellerwhich can't the DCE'd yet#2019-06-1710:17thhellerso you should avoid doing that unless you are actually using all of them#2019-06-1710:17thhellerif you don't care about size then :refer is not very useful on its own#2019-06-1710:17p-himikAnd I guess Shadow-CLJS can't just magically turn :refer-like :require to a :default-like one, right?#2019-06-1710:18thhelleryes that is not currently supported#2019-06-1710:18p-himikI mean in principle, given the mess in the way different packages export stuff.#2019-06-1719:51James Acklinhello! this is perhaps an elementary question, but i am attempting to require a JS (react) module relative to the current namespace as outlined in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js). i'm unable to get relative paths working (`shadow$provide is not defined`), but if i drop the js module in node_modules, it seems to resolve. are there special considerations i'm perhaps overlooking? i am not importing from the same directory, so i may not fully understand what is meant by "This is unlike node which expects relative requires to always resolve to physical files." thank you!#2019-06-1720:26thheller@james.acklin do you have more details? which version do you use? which build target? build config?#2019-06-1720:26thhellerwhat does the JS do?#2019-06-1720:44MudgeOnce I watch a build with shadow-cljs is there a way to unwatch it without shutting down the server?#2019-06-1720:44James Acklini am using shadow-cljs 2.8.37, the :npm-module build target (which is then imported by storybook-react), and the JS exports a function which returns an SVG with a bunch of child paths#2019-06-1720:45James Acklinfrom shadow-cljs.edn:
:stories {:target :npm-module
            :output-dir ".storybook-compiled"
            :devtools {:enabled false}}
#2019-06-1720:46thhellerhmm :npm-module might not support that style of js require#2019-06-1720:46James Acklinahh, got it#2019-06-1720:47James Acklini also control this library, so i may just implement a pure clojurescript variant just to keep things simple#2019-06-1720:47thhellerit might work if you use ES6 style import/export#2019-06-1720:47James Acklinokay, i will try that as well#2019-06-1720:48thhellerit might be possible to get this to work with npm-module. I never tried before#2019-06-1720:48thhellernpm-module has all sorts of special cases 😛#2019-06-1720:48James Acklinyes! others on my team are discovering that as well#2019-06-1720:48James Acklinthanks for the help and for the excellent tool#2019-06-1721:39dabrazheHi. Does anyone has a template or sample shadow-cljs project for AWS lambda deployment with Serverless Framework ?#2019-06-1722:30richiardiandreaI don't have a template, but it is very simple - I am using:
{:source-paths ["lambda-src"]
 :builds {:aws {:target :node-library
                :exports {:handler ingest-events.aws/handler}
                :output-to "ingest-events/index.js"
                :js-options {:js-provider :shadow
                             :keep-native-requires true}
                :release {:compiler-options {:source-map true
                                             :optimizations :simple}}}}}
#2019-06-1809:18dabrazhe@richiardiandrea How does your serverless yaml look like?#2019-06-1812:04Ahmed HassanWhat is difference between (:require ["module-name" :as module-name]) and (:require ["module-name"])? Reference: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2019-06-1812:10Ahmed HassanSimilar one: (:require ["moment" :as moment]) vs (:require ["moment"]).#2019-06-1812:20pyr@thheller thanks for the pointer#2019-06-1812:49thheller@ahmed1hsn (:require ["moment"]) has no alias so you it will be included in the code but you can't reference it#2019-06-1812:56Dmytro BuninI have an issue with the building the project in the ci (in docker container). When we build the project it sometimes throws an error
shadow-cljs - dependencies updated
[:app] Compiling ...
IllegalStateException: could not find where to put constant for module goog.structs.map.js
And I am not sure if this is the issue with some gitlab optimizations or with the way we have set up the project. I can reproduce it locally (sometimes), but it is really inconsistent locally and it fixes itself when it breaks like that. We also noticed that removing the .shadow-cljs directory in the pipeline makes this issue happen less often. If anyone can point me in some direction would be cool 🙂
#2019-06-1812:57thhellerhmm never seen that before. is that an :npm-module build?#2019-06-1812:58Dmytro Buninyes it is#2019-06-1813:00thhellerhmm not a clue sorry#2019-06-1813:10thheller@dmytro.bunin the only clue I can offer is that that error message is from the part of the code that is supposed to move cljs constants (ie. keywords) to their proper places. in this case it is trying to move into a namespace it isn't supposed to be moved to. dunno why that would happen though since there are no keywords in goog.* code. it might be that there is a keyword where this is the only common dependency which should also never happen because that is supposed to be cljs.core.#2019-06-1813:11thhellermaybe you have some bad namespace that use code without actually requiring it?#2019-06-1813:11thhellerie. using (clojure.string/foo ...) in an ns that doesnt have a (:require [clojure.string ...])#2019-06-1813:45Dmytro Buninwouldn’t it then consistently fail?#2019-06-1813:49thhellerI don't know what you failure conditions are#2019-06-1814:03Dmytro Buninalright, thanks for help, at least there is a direction now to look at#2019-06-1814:45carkh@thheller we've been investigating troubles with the lack of pretty printing of edn in cider's repl with @bozhidar... turns out that the troubles look like shadow-cljs specific#2019-06-1814:45carkhhere is what he says about it : You might also open some GitHub issue for @thheller pointing him to https://github.com/nrepl/piggieback/commit/8e0ff8911a1a7ad012dba19d3be6d7c0515d418d and subsequent commits. Changes that had to be done for Piggieback to play well with nREPL 0.6.#2019-06-1814:46carkhit is my understanding that shadow-cljs bypasses piggieback#2019-06-1814:47thhellerand what would be the issue?#2019-06-1814:47thhellerI really do not have time to debug cider issues currently so I can only provide minor guidance to where to look maybe#2019-06-1814:48carkhthey had to make some changes to piggieback that might not have been reflected in your implementation of it#2019-06-1814:48thhellerand what would that changes be? that commit just adds some comment AFAICT#2019-06-1814:49thheller ;; TODO :printed-value was removed in nREPL 0.6.0#2019-06-1814:51carkhis can see some changes in piggieback.clj, though i couldn't tell what these do at all#2019-06-1814:52carkhmainly the enqueue function i guess#2019-06-1814:52thhellerthats irrelevant since shadow-cljs doesn't use it#2019-06-1814:52carkhi wouldn't know =)#2019-06-1814:53thhellerI really just need a nrepl message log of how it supposed to be#2019-06-1814:53thhellerthen diff that with what shadow-cljs sends#2019-06-1814:53carkhi think i can do that#2019-06-1814:54thhelleralso some nrepl documentation maybe?#2019-06-1814:55carkhi have no knowledge of anything, i can cut/paste the nrepl-messages buffer for shadow-cljs (not pretty printing) and figwheel (pretty printing works)#2019-06-1815:02carkhwell that doesn't show anything different, only the printed value has new-lines in it for figwheel and not for shadown-cljs#2019-06-1815:02carkh#2019-06-1815:02thhellermight be some middleware changes then#2019-06-1815:02thhellermight be related to this https://github.com/nrepl/piggieback/blob/master/src/cider/piggieback.clj#L215-L218#2019-06-1815:05thhellerplease open an issue .. I'll look into it when I have more time#2019-06-1815:06carkhsure thanks#2019-06-1821:10credulousHi, I’m doing something wrong trying to use a React component but I’m out of ideas. I’m trying to use react-select.#2019-06-1821:10credulousI have this entry in my packages.json: "react-select": ""#2019-06-1821:11credulousIt successfully installed and there is a react-select/ directory in node_modules#2019-06-1821:11credulousI have this namespace declaration:#2019-06-1821:11credulous
(ns alexandria.views
  (:require 
    ["react-select" :default Select]
    [reagent.core :as r]
    [re-frame.core :as rf]
    [re-frame.db :as db]
    [alexandria.mapbox :refer [mapbox ]]))
#2019-06-1821:11credulousBut when I eval it I get:#2019-06-1821:12credulous
The required JS dependency "react-select" is not available, it was required by "alexandria/views.cljs".

Searched in:/Users/rodfrey/dev/terrapin/alexandria/node_modules

You probably need to run:
  npm install react-select

See: 
fireplace.vim: Something went wrong: {'status': ['done'], 'id': 'fireplace-MacBook-Pro.hitronhub.home-1560792001-475', 'session': ['ef44ac71-4693-4684-91aa-9673224c2965'], 'err': 'The required JS dependency "react-select" is not available, it was required by "alexandria/views.cljs".^@^@Se
arched in:/Users/rodfrey/dev/terrapin/alexandria/node_modules^@^@You probably need to run:^@  npm install react-select^@^@See: 
#2019-06-1821:12thhelleryou can't just point at a git repo and expect that to work#2019-06-1821:12thhellerthat package most likely has its own build step#2019-06-1821:12credulousThe maintainer of that package says to import it using import Select from 'react-select';#2019-06-1821:13credulousOK I thought it built correctly but I’ll go back and double check#2019-06-1821:14thhellerthats the file you'd get from the direct npm package#2019-06-1821:14thhellerhttps://unpkg.com/react-select@3.0.4/dist/react-select.cjs.js#2019-06-1821:14thhellerit doesn't exist in the git repo (and neither do the other files)#2019-06-1821:15thhellerwhy do you need the git repo? why not just npm install the regular package?#2019-06-1821:18credulousBecause I was being a moron - npm i react-select failed and the author seems to only use yarn. In any event, I changed the package.json entry to "react-select": "^3.0.4" and cleaned everything out and did npm install#2019-06-1821:19credulousAgain there’s a react-select directory in node_modules. But I get the same error.#2019-06-1821:19thheller/Users/rodfrey/dev/terrapin/alexandria/node_modules/react-select?#2019-06-1821:19credulousSorry for the git:// red herring#2019-06-1821:20thhellermake sure its not empty. npm sometimes acts funky and leaves empty directories#2019-06-1821:20credulous
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "44362b202236213d04092527062b2b2f6914362b6a2c2d30362b2a2c31266a2c2b2921"}, :content ("[email protected]")}
#2019-06-1821:21credulousthe dist folder is full’o’code too.#2019-06-1821:21thhellerlooks fine#2019-06-1821:22thhellerdid you try restarting the process? it sometimes gets confused if you mess with node_modules too much#2019-06-1821:22credulousRestarted shadow-cljs server:#2019-06-1821:22credulous
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "6c1e03080a1e09152c210d0f2e030307413c1e03420405181e030204190e4204030109"}, :content ("[email protected]")}
#2019-06-1821:23thhellerthats not a restart. notice the shadow-cljs - connected to server#2019-06-1821:23credulousoh wait, I have a background server, I forgot I did that#2019-06-1821:26credulousThat was it. Thanks, I feel like a buffoon, but at least I’m a buffoon who’s moving forward#2019-06-1821:54haywoodanyone ever seen an issue during development where the JS console outputs a lot of googl.string.isNumeric is not a function and other seemingly Google Closure issues. The issue is resolved when building for production#2019-06-1821:54haywoodthe network tab shows the myriad of JS dependencies have resolved#2019-06-1821:56thhellergoogl? that shoul be goog?#2019-06-1821:57haywoodthis was seen on a co-workers machine who doesn’t normally run this project. we ruled out a lot of differences between our environments, mostly just Node versions, since everything else is declared in project.clj/package.json.#2019-06-1821:57haywoodYea, I miss-typed#2019-06-1821:57thhellerproject.clj might install a conflicting closure-library version?#2019-06-1821:58thhelleralthough it should be doing that everywhere#2019-06-1821:58thhellercheck for conflicts lein deps :tree#2019-06-1821:58thhellershould be
[com.google.javascript/closure-compiler-unshaded "v20190325"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
#2019-06-1822:05haywoodhm, yea it’s in there. Also odd that compiling a production bundle works#2019-06-1822:07thhellerare you sure the correct files are getting loaded? maybe bad cache or so#2019-06-1907:42Dmytro Bunin@thheller about the yesterday issue, clj-ajax library has a dependency on some javascript file which has a symbol that is not really defined. So thanks for the pointers 🙂#2019-06-1907:43thhellerdo you have the code causing the problem? maybe I can prevent that causing an issue in the future?#2019-06-1907:46lucmartensI’ve made a minimal example reproducing above issue: With cljs-ajax build fails sometimes: https://gitlab.com/lucmartens/cljs-pipeline-test/merge_requests/1/diffs Without it seems to succeed: https://gitlab.com/lucmartens/cljs-pipeline-test/merge_requests/2/diffs#2019-06-1907:49thhellerthanks. I'll see if I can figure something out#2019-06-1909:53thheller@luc.martens that example repo doesn't have a build config? .. nevermind its the npm module default#2019-06-1910:02thheller
IllegalStateException: Could not find where to put constant cljs$cst$keyword$body. Used by [ajax.easy.js, ajax.xhrio.js, ajax.xml_http_request.js, ajax.ring.js, ajax.interceptors.js, ajax.protocols.js], selected common dep goog.structs.map.js
        shadow.build.closure.ReplaceCLJSConstants.process (ReplaceCLJSConstants.java:61)
#2019-06-1911:40lucmartensNice, that’s a lot more clear#2019-06-1910:02thhellerimproved the error message a bit 😉#2019-06-1914:09rnandan273I have been a user of luminus web framework. Now they have introduced +shadow-cljs as one of the profiles that is used via the lein-shadow plugin. However i am having issues running lein shadow compile app. Any thoughts?#2019-06-1914:23deadghosthttps://github.com/deadghost/shadow-npe I'm getting NullPointerException. Any ideas?#2019-06-1914:57thhellerlooks like a bug in the closure compiler#2019-06-1917:25deadghosthmm how should I proceed here?#2019-06-1917:26deadghostcompiler bugs aren't an everyday occurrence for me#2019-06-1917:26deadghostand is up there on things I don't want to hear#2019-06-1917:27deadghostthinking: don't use the specific library, deep dive and maybe fix it on the library level, deep dive and submit an issue for the closure compiler#2019-06-1918:11thhellerwell yeah thats tough. need to find the actual problematic code first which isn't easy since it imports so much#2019-06-2000:18Chris O’DonnellJust want to say that it is totally awesome that shadow-cljs automatically recompiles and hot reloads in the browser when you change a dep brought in via deps.edn's :local/root.#2019-06-2010:11steveb8nlikewise it’s awesome that it doesn’t need a restart when you add a new npm dep and install it in the background#2019-06-2017:42David PhamIs it possible to run Kamera with shadow-cljs?#2019-06-2017:42David Phamhttps://github.com/oliyh/kamera#2019-06-2018:09MarcinHey all, what do you usually do when you want to have on your frontend app a separate configuration for dev (e.g. using links like localhost:8080 instead of prod services) and a different one for production?#2019-06-2018:51deadghost@marcinszyszko https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-06-2018:51deadghost@marcinszyszko https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-06-2019:05Marcin@deadghost I thought about it, but it won’t work that well with websockets, like wss://#2019-06-2019:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-06-2019:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2019-06-2019:15Marcinthat’s what I thought. Thank you @thheller!#2019-06-2019:34neupshI have shadow-cljs watch app running, and I am making changes in the code. When I make changes in the existing namespaces, they get reloaded automatically but when I create a new namespace and require them in the existing namespace, i get the following error:
The required namespace "<new namespace>" is not available, it was required by "<existing ns>.cljs"
#2019-06-2019:34neupshis it normal to re-run that everytime i add a new namespace?#2019-06-2019:35neupsh(I am using shadow-cljs expo template if it matters)#2019-06-2019:35thhellerno, that should work as expected#2019-06-2019:36thhellerthere might be a race condition if for some reason the new file is saved way after (500ms+) the existing file#2019-06-2019:37thhellerie. the existing file is saved, then some time passes, then the new one is saved#2019-06-2019:40neupsh@thheller looks like the new file is not even "watched" at all. I made edits only one the new file now (the existing has the new namespace required which resulted in the failure mentioned above) and saved it but no activity on the shadow-cljs ouput#2019-06-2019:41neupshis there a way to see logs to figure out whats going on here?#2019-06-2019:41neupshor a way to force reload the files without exiting shadow-cljs?#2019-06-2019:42thhellerif you use a separate shadow-cljs server process you can just restart the watch#2019-06-2019:42thheller:log {:level :debug} will print a bunch of stuff#2019-06-2019:43neupshi will try those.. thanks a lot#2019-06-2019:45thhellermake sure you are on a somewhat recent version too. there was a related bug a year ago or so#2019-06-2019:55neupsh@thheller i see correct behavior when i run shadow-cljs server and select the build from the web interface. May be it was one off issue. I will keep an eye on it#2019-06-2019:55neupshThanks#2019-06-2109:24timovanderkampHi, Im running 2 react apps with shadow-cljs on 1 document which is causing react-errors. Im using output-wrapper configurations for both apps https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper. The react error is telling me that there are probably multiple copies of React loaded#2019-06-2109:29thhellerwell are you?#2019-06-2109:29thhellershadow-cljs will include one unless you configure it otherwise#2019-06-2109:30thhellersame for the other react parts I guess?#2019-06-2109:31timovanderkampBoth have an own version of React#2019-06-2109:32timovanderkampwhich might be a problem#2019-06-2109:32timovanderkamphttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs Could this be a problem? That each app exports react to the global variable “React”#2019-06-2109:36thhelleryes that would be a problem. but having 2 versions of react on the page is the actual problem#2019-06-2109:36thhellerwhy are the 2 builds not combined?#2019-06-2109:36thhelleryou are duplicating everything. not just react but also react-dom and probably other dependencies#2019-06-2109:37thhelleradding a lot of unncessary bytes overall#2019-06-2109:38mitchelkuijpersThis is because we are creating a addon for JIRA, where everyone needs to package it's own version#2019-06-2109:39mitchelkuijpersWhich absolutely sucks but that is we way Atlassian wants us to do this...#2019-06-2109:39thhellerthen you must avoid the cljsjs.* packages. using (:require ["react" :as x]) will not expose the global#2019-06-2109:40mitchelkuijpersI was afraid of this, so we need to patch Fulcro 😞#2019-06-2109:41thhellerwell you can try using the require redirect and use react from a different lib#2019-06-2109:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global#2019-06-2109:42thhellerbut then you are relying on some foreign defined version of react which is kinda bad 😛#2019-06-2109:42mitchelkuijpersYeah and fulcro contains code like this: js/React.createElement#2019-06-2109:42mitchelkuijpersI don't think we can patch that right?#2019-06-2109:43thhellerin a release build you can maybe cheat that but in development no#2019-06-2109:43mitchelkuijpersOh that would be fine 😛#2019-06-2109:44mitchelkuijpersI could probably just add a string/replace then#2019-06-2109:45thhellerwell in a release build using output-wrapper everything is in its own scope#2019-06-2109:45thhellerso the js/React only needs to come from that scope#2019-06-2109:45thhellerso in theory if you get var React = the.actual.react; into the output-wrapper that should be fine#2019-06-2109:46mitchelkuijpersthat makes sense#2019-06-2109:46thhellerso what I would probably try is creating a dummy ns that abuses js* and is loaded first#2019-06-2109:47thheller(ns hack.react (:require ["react" :as react] ["react-dom" :as react-dom])) (js* "var React = {};" react) (js* "var ReactDOM = {};" react-dom)#2019-06-2109:47thhellerstill need to replace the cljsjs shims so they don't export a global#2019-06-2109:48mitchelkuijpersThat will be easy#2019-06-2109:48thhellerload that namespace first before anything else loads react#2019-06-2109:48mitchelkuijpersNice I will try this out, thank you so much#2019-06-2109:48mitchelkuijpersYes makes sense#2019-06-2109:48thhellereither by using :modules {... {:entries [hack.react ]}} or by just requiring it first in whatever ns is loaded first#2019-06-2109:49mitchelkuijpersAwesome, will report back if it works#2019-06-2109:49mitchelkuijpersIf you are interested in that 😛#2019-06-2109:49thhelleryeah let me know. maybe I can come up with other hacks if it doesn't 😉#2019-06-2113:58mitchelkuijpersWell this is annoying:
2019-06-21 15:57:52.567 - INFO] duplicate resource cljsjs/react/dom.cljs on classpath, using jar:file:/home/mitchel/.m2/repository/thheller/shadow-cljsjs/0.0.18/shadow-cljsjs-0.0.18.jar!/cljsjs/react/dom.cljs over file:/home/mitchel/Development/atlas-crm/atlas-crm-kit/src/cljsjs/react/dom.cljs
[2019-06-21 15:57:52.577 - INFO] duplicate resource cljsjs/react.cljs on classpath, using jar:file:/home/mitchel/.m2/repository/thheller/shadow-cljsjs/0.0.18/shadow-cljsjs-0.0.18.jar!/cljsjs/react.cljs over file:/home/mitchel/Development/atlas-crm/atlas-crm-kit/src/cljsjs/react.cljs
#2019-06-2113:58mitchelkuijpersit keeps choosing the wrong one#2019-06-2113:59mitchelkuijpersHmm wait I think order matters just as in maven#2019-06-2114:02mitchelkuijpersStupid classpaths#2019-06-2114:46mitchelkuijpersI fixed it by forking shadow-cljsjs#2019-06-2114:50mitchelkuijpersUnfortunately it does not work:#2019-06-2114:51mitchelkuijpersOh and for extra fun we use modules, so it generates this:#2019-06-2115:12mitchelkuijpersSo if you have any other hacks I am all ears#2019-06-2116:19thhelleroh that should have been (js* "var React = ~{};" react)#2019-06-2116:19thhellerbut yeah with modules things might get trickier#2019-06-2116:19thhellerbut it might work so definitely try it first#2019-06-2116:19thhellerah no nvm it won't work#2019-06-2116:20thhellerwell the global is the problem so its not easily fixable#2019-06-2120:08mitchelkuijpersThnx will think about this some more#2019-06-2212:14mitchelkuijpersDamn it seems to work!#2019-06-2212:28mitchelkuijpersNope false alarm 😞#2019-06-2212:31mitchelkuijpersIt is weird this: (js* "var React = ~{};" react) results in React=null;#2019-06-2220:55thhellerit isn't for me?#2019-06-2220:55thheller
(js* "var React = ~{};" r)

(js/console.log "react" r js/React (identical? r js/React))
#2019-06-2220:55thhellerwith (:require ["react" :as r])#2019-06-2409:32mitchelkuijpersSo I have created this:
(ns atlas-crm.server.react-hack
  (:require ["react" :as r]
            ["react-dom" :as rd]))

(js* "var React = ~{};" r)
(js/console.log r)
(js* "var ReactDOM = ~{};" rd)
(js/console.log rd)
And this results in:
React=null;console.log(nl_avisi_atlascrm.A0);ReactDOM=null;console.log(nl_avisi_atlascrm.L7a);
#2019-06-2409:47thhellerthat makes no sense at all.#2019-06-2409:48thhellercan you try changing the name? (js* var WTF = ~{};" r) or so#2019-06-2409:48mitchelkuijpersSure#2019-06-2409:48thhellermaybe it has some sort of conflict on the React name?#2019-06-2409:48mitchelkuijpersI also find this in resulting JS now: nl_avisi_atlascrm.A0.createElement,a,b,c#2019-06-2409:49mitchelkuijpersSo that seems correct#2019-06-2409:49mitchelkuijpersI am trying it out now with the new name#2019-06-2409:51mitchelkuijpersomg the var definition fixes al of the renaming.. that is interesting#2019-06-2409:55mitchelkuijpersWTF=null;console.log(nl_avisi_atlascrm.A0);#2019-06-2409:56mitchelkuijpersAnd now the rest of the code is React.createElement,a,b,c again#2019-06-2409:57thhellerI guess its a problem in the closure compiler since React is declared in the externs and you are not allowed to reassign it maybe?#2019-06-2409:57mitchelkuijpersAh maybe that is problem, but it does rename all the references#2019-06-2409:57mitchelkuijperswhich is good 😛#2019-06-2409:57mitchelkuijpersFor our use case#2019-06-2409:58thhellerhmm?#2019-06-2409:58thhellerrename how?#2019-06-2409:58mitchelkuijpersSo our code now contains instead of:
React.createElement,a,b,c
nl_avisi_atlascrm.A0.createElement,a,b,c
#2019-06-2409:59thhellerso you are not using the global in those cases?#2019-06-2409:59thhelleryou are phrasing this confusing. I don't know what you mean#2019-06-2409:59mitchelkuijpersAll of the cljsjs code get replaced by the correct var#2019-06-2409:59mitchelkuijpersSorry#2019-06-2409:59thheller> And now the rest of the code is React.createElement,a,b,c again#2019-06-2410:00thhellerwhich is it? your last statement looks like you mean the other case#2019-06-2410:00mitchelkuijpersAfter I added the
(js* "var React = ~{};" r)
(js* "var ReactDOM = ~{};" rd)
It changed all the code to:
nl_avisi_atlascrm.A0.createElement,a,b,c
#2019-06-2410:00thhellerthats exactly what you want#2019-06-2410:01mitchelkuijpersYeah that is awesome#2019-06-2410:01mitchelkuijpersbut unexpected I guess?#2019-06-2410:01thhellerdepends, what is the definition of nl_avisi_atlascrm.A0?#2019-06-2410:02thhellerit isn't unexpected. it is exactly how :modules is supposed to work. I just don't get why it is assigning var React=null;#2019-06-2410:02thhellerthat makes no sense to me#2019-06-2410:03mitchelkuijpers
nl_avisi_atlascrm.A0=(6)
#2019-06-2410:03thhellerthat looks correct to me#2019-06-2410:03thhelleris it probably a renamed shadow.js.jsRequire call#2019-06-2410:03mitchelkuijpersAwesome, yeah the only weird part is that it assignes React=null#2019-06-2410:03thhellertry with shadow-cljs release build --pseudo-names#2019-06-2410:04thhellerits fine if it assigns React to null if its never used again#2019-06-2410:04thhellerit is not fine if something else still references React#2019-06-2410:04mitchelkuijpersYeah but it does it in the global scope#2019-06-2410:04mitchelkuijpersYeah that is the only problem#2019-06-2410:04mitchelkuijpersBut I could even make regex after which removes that code 😛#2019-06-2410:05thhellerbut there should be no react in the global scope? isn't the goal to get rid of that?#2019-06-2410:06mitchelkuijpersSo we are embedded in another application, So if that application decides to use React we don't want to set that to null#2019-06-2410:06thhellerah right#2019-06-2410:06mitchelkuijpers
nl_avisi_atlascrm.$module$node_modules$react$index$$.createElement.apply(null, $arr$jscomp$166$$);
#2019-06-2410:06mitchelkuijpersthis seems correct 👍#2019-06-2410:07thhelleralso check the assignment of nl_avisi_atlascrm.$module$node_modules$react$index$$#2019-06-2410:10mitchelkuijpersSorry I gotta go be back in a hour or so#2019-06-2410:10mitchelkuijpersFighting with my terminal and escaping#2019-06-2410:12thhellerif it works I'd just regex out the react=null assignment for now. no idea where that is coming from or if that somehow can be removed otherwise#2019-06-2410:25mitchelkuijpersYeah we will be doing that probably#2019-06-2410:31mitchelkuijpersI found this btw:
nl_avisi_atlascrm.$module$node_modules$react$index$$ = nl_avisi_atlascrm.$shadow$js$require$$(6); 
#2019-06-2410:31mitchelkuijpersThat seems to be correct#2019-06-2410:32thhelleryep#2019-06-2410:33mitchelkuijpersI had to fork shadow-cljsjs btw to get this working#2019-06-2410:34mitchelkuijpershttps://github.com/mitchelkuijpers/shadow-cljsjs So do you want me to try removing the externs to see if it assigns React?#2019-06-2410:35thhellerwhy did you need to fork for that? just put the files into your source paths?#2019-06-2410:35mitchelkuijpersI did that but shadow kept insisting that the shadow-cljsjs files win
#2019-06-2410:36thhellerfiles on the source path should win always?#2019-06-2410:36mitchelkuijpersNo we have a shared modules#2019-06-2410:36mitchelkuijpersbecause we have about 6 projects who work like this#2019-06-2410:37mitchelkuijpersAnd we don't want to copy all of this stuff around#2019-06-2410:37thhellerhmm ok#2019-06-2414:00mitchelkuijpersIt all works, thank you so much for all the help#2019-06-2115:37colinkahnI’m having some trouble importing an npm package, specifically router5. When I require it via ns (like: (:require ["router5" :as router5]))) and try to use one of the exported functions (`createRouter`) I get TypeError: module$node_modules$router5$dist$index.createRouter is not a function, and looking at the actual export it is in fact an empty object. But, if I’m in the browser repl and do (require '["router5" :as router5]) I can use the exported functions just fine.#2019-06-2115:39colinkahnAlso, node_modules/router5/dist/index.js is a commonjs file, with exports like:
exports.RouteNode = RouteNode;
exports.transitionPath = transitionPath__default;
exports.createRouter = createRouter;
exports.cloneRouter = cloneRouter;
exports.constants = constants;
exports.errorCodes = errorCodes;
exports.default = createRouter;
#2019-06-2115:43colinkahnActually if I change those exports to be module.exports = everything works fine…#2019-06-2115:45colinkahnStill weird that it works when I do (require ...)#2019-06-2116:21thheller@colinkahn add a (js/console.dir router5) to the file using it#2019-06-2116:21thhellerseems to me like it should be working when it works in the REPL?#2019-06-2116:35colinkahn@thheller not sure what’s different now, but yeah, console.dir worked, and then console.log worked, and now everything works. Is there some cache besides the output dir that could be holding onto some local change? I’m not eager to get it to break again but it is a bit worrisome that it didn’t work one minute and now it does#2019-06-2116:56Ahmed HassanHow we can build a library to be used by ClojureScript projects with Shadow-cljs?#2019-06-2116:59Ahmed HassanOne option is node-library which I think is npm deployable. But how can a .jar file be made which can be deployed on Clojars?#2019-06-2117:33lilactown@ahmed1hsn shadow-cljs doesn’t provide a way of bundling CLJS for publishing as a library. I typically use leiningen and lein deploy to publish to e.g. clojars or other maven repo#2019-06-2117:33lilactownthe important thing is, you don’t need to compile your clojurescript code at all#2019-06-2117:34lilactownyou just put the CLJS sourcefiles in a jar and upload it#2019-06-2117:54Ahmed HassanThanks @lilactown. What about npm dependencies I required in the deployed library? Will users of library have to include npm modules in package.json and just start using it?#2019-06-2117:57Ahmed HassanAnd if there are other CLJS dependencies with .jar format, they can be included in :dependencies in project.clj. Right?#2019-06-2118:07lilactownCLJS dependencies can be included in project.clj and will be automatically installed yeah.#2019-06-2118:08lilactownThere's not a dependable way to install npm dependencies automatically, so I usually include it as part of the installation instructions to manually install them via npm when adding it to their project#2019-06-2119:07thheller@ahmed1hsn for JS dependencies you can add a deps.cljs to your .jar with {:npm-deps {"foo-bar" "1.2.3"}}#2019-06-2203:00Mark AddlemanAny hints how to use shadow-cljs to create JS usable for gmail add-ons? I cannot figure out build target type to use to create an entrypoint function#2019-06-2308:05thheller@mark340 I don't know anything about gmail add-ons. if you have a basic JS example I can maybe tell you how to do it CLJS#2019-06-2318:04Mark AddlemanThe basic challenge is GMail add-ons need a javascript entry function (the entry function is referenced by the GMail add-on manifest file). Of course, the entry function name cannot be mangled by the closure compiler using advanced compilation. For some reason, declaring it ^export doesn't work. I looked at the resulting javascript and cannot find a clear function definition with the exported name. I found an example of doing this using the ClojureScript compiler directly: https://github.com/plexus/gas-of-life The basic approach is to create a snippet of javascript that are the entry point functions. They call into the 'real' functions written in clojurescript. Then, tell the clojurescript compiler that these snippets are a foreign library. The resulting javascript (again, using advanced) incudes the js snippet verbatim so gmail can find the entrypoints. Essentially, it seems my code is a foreign library for itself 😕 I want to believe there's a more straightforward solution but I cannot find another magical incantation to make it work.#2019-06-2408:48thhelleruhm did you actually use ^export because that would be wrong?#2019-06-2408:48thhellerhttps://github.com/plexus/gas-of-life/blob/master/src/entry_points.js#2019-06-2408:49thhellerjudging from that file you need an onOpen callback defined?#2019-06-2408:49thhelleryou can do that in your ns by doing (defn ^{:export "onOpen"} your-on-open [e] ...)#2019-06-2408:49thhellerjust ^:export isn't enough because that would create a fully qualified name#2019-06-2408:50thhellerdunno why he created that extra file. guess it isn't well known that the :export takes an actual string as well#2019-06-2416:34Mark AddlemanAh, that could be it! I'll give it a try. Thanks!#2019-06-2414:40publicmayhemHow do I start up a dev http server that supports a specific set of CORS headers? From the userguide I tried adding in :push-state/headers element into the :devtools config but had no effect? All I need is for the dev server to offer a single index.html page with specific CORS support so my re-frame app can login via aws-cognito#2019-06-2415:56thhellercan you point me to the AWS docs that explain the CORS headers needed? I don't understand why it is needed?#2019-06-2417:21publicmayhemI’m writing a serverless app that will allow user to login via aws cognito over ajax, then it will call several lambda fns via api gateway, that is the plan. For development on my local machine, I need to allow the browser to post ajax to aws, hence the cors. I’m sure there are possible routes for logging in, but for accessing api gateway I definitely need cors.#2019-06-2417:23publicmayhemIf there is no way at present to simply tell devtools to inject cors headers into responses, then I will add a small handler to do this for me, but thought I would ask, as most things seem to have been thought out already#2019-06-2417:23thhellerhmm maybe I'm missing something but you posting against some AWS host does not require CORS locally?#2019-06-2418:07publicmayhemSorry if I’m not clear. I’m developing the app via shadow-cljs which is serving the app locally via devtools server. I’m creating a form in re-frame which will capture login details and send to AWS cognito via Ajax (this is where it will need cors permissions). Once logged in, it has access to AWS Lambda resources via api gateway again via Ajax which requires cors. The server provided by shadow-cljs needs to give my browser permission to access AWS resources cross origin. #2019-06-2418:08thhellerno it doesn't?#2019-06-2418:08publicmayhemOh?#2019-06-2418:08thhellerthe server answering the AJAX request has to set CORS headers#2019-06-2418:08thhellerthe server serving the initial page is not involved in that?#2019-06-2418:11publicmayhemHmm, u think I’m barking up the wrong tree then. Will see what I can get working#2019-06-2418:11thhellerfrom what I understand of what you are trying to do yes#2019-06-2418:11publicmayhemThx#2019-06-2414:43souenzzoUnused extern imports like
(ns  (:require ["@material-ui/core/AppBar" :as mui-AppBar]))
(def app-bar (factory-apply mui-AppBar)) ;; app-bar isn't used
Will be included in final bundle?
#2019-06-2415:47thhelleryes#2019-06-2415:48pezI listened to the ClojureScript podcast episode about npm interop, @thheller . Got curious about the Closure compiler's advanced compilation... Do you know if it makes any attempt to make the generated code more suited for gzipping?#2019-06-2415:49thhellerwhat is gripping?#2019-06-2415:52lilactowngrepping?#2019-06-2415:52thhellerstill no clue what that would mean in that context#2019-06-2416:01pezDamn autocorrect. Gzipping. #2019-06-2416:03thhelleryes, it is optimizing for that#2019-06-2416:08thhellerIIRC there was an article about that on the closure tools blog https://closuretools.blogspot.com/#2019-06-2416:08thhellerbut can't remember exactly where#2019-06-2416:09thhellerbut the gist is that closure tries to minimize the number of properties it generates on classes and such. and rename them in a way that has as much re-use as possible#2019-06-2416:10thhellerie. all locals and function args args are renamed after the same pattern (eg. a,b,c,d,...)#2019-06-2416:10thhellerbut I think webpack does that too nowadays#2019-06-2416:11thhellerbut some of the more advanced patterns don't work too well in CLJS since we don't type-hint our code#2019-06-2416:11thhellerand some of those things require fully typed code#2019-06-2416:35pezThanks! Some of the gzip optimizations require fully typed code? I'll go read that blog. I had a specific idea I was wondering about. #2019-06-2416:42thhellersome of the optimizations require typed code. some of those are relevant to gzipping since it can pick better names#2019-06-2416:42thhellerproperty ambiguation or whatever that is called#2019-06-2418:32ro6I'm new to shadow-cljs and enjoying it a lot so far. Thanks for the good work @thheller! I'm trying to use https://github.com/kylefox/jquery-modal in throwing together a prototype and wondering if there's something special I should do to get that library to load. Right now it seems the $(...).modal() fn it's supposed to add to jQuery isn't available. Maybe just require it somewhere to make sure the module loads?#2019-06-2418:39ro6All I had to do was
(:require ["jquery-modal"])
and everything worked.
#2019-06-2603:32aaron51Running a react-native shadow-cljs build in Docker, and devtools on the phone is trying to connect to a ws:// URL that’s only accessible inside the Docker container (`<ws://169.254.32.96:9630/ws/...`>). Related line in react-native.cljs - https://github.com/thheller/shadow-cljs/blob/89acb664f800af48344288e963873bf8972ee9fb/src/main/shadow/cljs/devtools/client/react_native.cljs#L206 The ws connect fails so the app crashes with the React Native red screen every 30 seconds. Related GH issue? https://github.com/thheller/shadow-cljs/issues/482 Are there any workarounds? Can we specify the websocket hostname in shadow-cljs.edn?#2019-06-2603:41aaron51The every-30-second crash seems to come from heartbeat! https://github.com/thheller/shadow-cljs/blob/0e28c615cd75d4cbce27ede7a8f7f70785d42c86/src/main/shadow/cljs/devtools/client/react_native.cljs#L244#2019-06-2608:05thheller@aaron51 you can currently configure the ip/host to connect to via shadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}' or just the :local-ip in the build config itself#2019-06-2608:15thhellershould work if you give it a hostname#2019-06-2610:25orestisI am having some weird issue — did something change recently? ["react" :as React] now returns an empty javascript object, and I get cascading failures about how .createContext etc is not a function.#2019-06-2610:35orestisTrying to roll back some dependency upgrades to see if something in my package.json is playing up.#2019-06-2611:00thhellertry restarting shadow-cljs#2019-06-2611:00thhellersometimes the cache gets confused if you mess with node_modules files too much#2019-06-2812:14orestisTurns out I can reproduce this after doing a release build, followed by a dev build. The dev build then breaks. Removing .shadow-cljs fixes it. I can reproduce this 100% of the time.#2019-06-2611:01thhellerbut no nothing changed in that regard#2019-06-2611:01orestisI’ve done numerous times — I’ll try once more 🙂#2019-06-2611:01thhellermake sure you are actually restarting the server instance#2019-06-2611:01thhellerif it says connected to server on startup you did not restart the server isntance just the watch#2019-06-2611:02orestisGood point — yes, I am — I’m also nuking node_modules and .shadow_cljs (but I’m keeping a copy around 😉 )#2019-06-2611:10Nolanupdated shadow-cljs version, and i had to add proxy in shadow-cljs.edn at root of project directory#2019-06-2611:11Nolanin the previous version, shadow-cljs read the proxy from ~/.shadow-cljs/config.edn#2019-06-2611:11thhellerI assume you mean maven proxy?#2019-06-2611:11Nolanyes#2019-06-2611:11thhellerthose settings were moved to :maven {:proxy ...} in ~/.shadow-cljs/config.edn#2019-06-2611:12Nolansorry yeah, my config is
{:maven
 {:proxy
  {:host "localhost"
   :port 8099}}}
#2019-06-2611:12thhellerlooks good#2019-06-2611:14Nolansorry, false alarm, i was using the global install of shadow-cljs which was on an older version#2019-06-2612:41orestisTurns out that doing a blind npm update is dangerous. Something somewhere broke everything. Manually editing the package.json versions to the same numbers fixes the issue.#2019-06-2614:15Olicalflash backs to when I was a full time JS dev I love that whatever is in my project.clj or deps.edn is what I'll get. No ambiguity. The whole ^2.1.3 automatic bumping thing scared the living daylights out of me.#2019-06-2616:16orestisIs yarn any better at this?#2019-06-2616:18OlicalNot as I recall, no. It's more of a cultural problem than a software one I think? Well, I see it as a problem personally. I think lockfiles help but things can still bump mysteriously in transitive things?#2019-06-2618:20orestisJust had a read - npm install does bump non-fixed transitive dependencies, and then updates your lock file... but npm ci does not. Yarn has more same defaults. #2019-06-2612:44orestisOr it was just a combination of cache issues?#2019-06-2700:48Daniel HinesHey guys. I’m trying running one http server on my Mac on port 8700. On a Windows VM, another http server is running on 3375. In my browser in Windows, when I hit my IP on 8700, everything works great. However, when I add main.js as a script on one of the pages running on 3375 in Windows, when it loads, I’m getting the following errors:#2019-06-2701:34Daniel HinesIf you look at the screenshot, it's asking for the goog scripts on localhost, but they aren't hosted there - it's on a different url and port#2019-06-2701:45aisamuIUC, this looks like a job for the proxy. It'll search for files locally and forward to the proxy when not found#2019-06-2701:46Daniel HinesIs there like a one liner cli tool you know of to do that? #2019-06-2701:48Daniel HinesScratch that - I see your post below#2019-06-2700:49Daniel HinesThe problem is obvious - those files aren’t hosted on that port. Any suggestions on a solution? Some config in Shadow, perhaps?#2019-06-2701:04Daniel HinesIf theres no easy fix on the shadow-cljs side, I can probably work things from the other direction.#2019-06-2701:20wilkerlucio@d4hines maybe this? https://github.com/fulcrologic/fulcro-inspect/blob/master/shadow-cljs.edn#L15#2019-06-2701:25Daniel HinesSo if my shadow-cljs http server is hosting my code at http://my-ip:8700, I set :devtools-url to that?#2019-06-2701:37aisamu> shadow-cljs will then use the :devtools-url as the base when making requests. It is not the final URL so you must ensure that all requests starting with the path you configured (eg. /shadow-cljs/*) are forwarded to the host shadow-cljs is running on.#2019-06-2701:47Daniel HinesOh, this must be the prxy you mentioned in the thread#2019-06-2701:40aisamuThere's also support for a proxy: https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy#2019-06-2709:31thheller@d4hines the default logic of shadow-cljs will try to load the JS from the current document location. so if you access the initial HTML via it'll attempt to load the files from 8700#2019-06-2709:32thhelleryou can override that behavior via :devtools-url or the proxy config as pointed out above#2019-06-2709:33thhelleranother thing that also works is just setting a full host in the :asset-path config option. so :asset-path ""#2019-06-2712:15Daniel HinesAh! This helped a bunch! I’m so close now. The only remaining error is this one:#2019-06-2712:15Daniel Hinesbrowser.cljs:343 WebSocket connection to ‘<ws://localhost:9630/ws/worker/app/60bb278c-7f0a-4cfc-9db2-5b4aec3572e5/2ddbda70-5ea9-4725-a1c2-1aa32811f7e4/browser>’ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED#2019-06-2712:17Daniel HinesFor this, it looks like, according to 4.4.4 in guide, I need to set something like:
:http {:port 9630 :host "my-ip"}
#2019-06-2712:26Daniel HinesI added that config, and I get the following output in the console:
shadow-cljs - server version: 2.8.39 running at 
#2019-06-2712:26Daniel HinesHowever, I still get the above error, where it’s looking for websockets on localhost.#2019-06-2712:42thhellerthis is the same underlying issue#2019-06-2712:42thhellerfor this you'll need to set :devtools-url properly#2019-06-2712:43Daniel HinesI was just about to post that I did exactly that and it’s working!#2019-06-2712:43Daniel HinesThanks a ton for your help!#2019-06-2719:25mauricio.szaboThe "build report" feature is not working for me: I run shadow-cljs run shadow.cljs.build-report <my-build-id> report.html and it raises an error: NoSuchFileException: .shadow-cljs/release-snapshots/dev/latest/main.js#2019-06-2719:26mauricio.szaboDo I need to do some step before I run build-report?#2019-06-2720:53thheller@mauricio.szabo build reports currently only work with :browser builds? do you use :browser?#2019-06-2720:54mauricio.szaboNo, I'm using node_script. Sorry, I think I've missed this information on the documentation.#2019-06-2720:55thhellerdon't think it mentions that#2019-06-2720:55thhellerin theory it could work for node-script but haven't done the work to make it work#2019-06-2720:55thhellerseems less important anyhow given that size is not really a concern for node-script builds#2019-06-2722:18mauricio.szaboAlso, how do I contribute to the documentation? On the "editor integration" part I could add Chlorine, socket REPL package for Atom, as it currently supports shadow-cljs out of the box 🙂#2019-06-2811:22staskhi, anyone tried using amazon-cognito-identity-js directly, without aws-amplify? having a weird issue here: i have a namespace where i require cognito like this:
(ns xt.auth
  (:require
    ["amazon-cognito-identity-js" :refer [CognitoUserPool]]))
And then i use it like this:
(defn user-pool [config]
  (CognitoUserPool. #js {:UserPoolId (:pool-id config) :ClientId (:client-id config)}))
Everything works when i load that namespace in REPL. Once i load it in browser (as dependency of another namespace), i’m getting error saying that CognitoUserPool is not a constructor. And it stops working in REPL too. (same error, not a constructor) Sometimes (not sure what’s the pattern yet), if i then reload the namespace in REPL, it starts working again, but once i refresh the browser, it stops working.
#2019-06-2816:51mccraigmccraigin a multi-module project, how are people setting versions of the internal project dependencies for shadow ? i.e. we build each module to a jar, install it locally and then use the dependency - with lein, the version is specified by slurping from a file in project.clj, but i can't do that in shadow#2019-06-2816:53mccraigmccraigis a :configure hook a sane way to go ? or, i'm already using gulp to coordinate the result of the webapp build... i could also just modify the shadow-cljs.edn file from gulp - unless there's something obvious i'm missing ?#2019-06-2914:31pez@thheller can I wish for the .nrepl-port file to be created even if [:nrepl :port] is set? Calva uses this file’s creation as a signal in its jack-in process (because limitations in the vscode API:s).#2019-06-2914:46mauricio.szaboIs there a way to ask for Shadow to not try to resolve a JS dependency, and just maps to a specific require? The reason for that is that while developing an atom package I found out that I can compile it with :js-provider :shadow to avoid using node_modules. This made the package smaller, installs faster, and when Atom starts the package adds waaay less time on startup time#2019-06-2914:47mauricio.szaboBut as the target is as node library, sometimes dependencies tries to require('fs') for example, and shadow's compilation complains that it can't find the module for it#2019-06-2915:37thheller@pez .shadow-cljs/nrepl.port is always generated?#2019-06-2915:38thheller@mauricio.szabo see https://github.com/thheller/shadow-cljs/issues/290#2019-06-2919:40mauricio.szaboJust... Wow! Thanks a lot, it works perfectly!#2019-06-2915:42pez@thheller , alright, I'll run a few more tests with it, maybe I jumped to the conclusion. (Probably did.)#2019-06-2915:43thhellerjust remember to use the correct file. .nrepl-port is wrong and kind of unreliable since it doesn't want to interfere with lein creating one#2019-06-2915:46pezAh, maybe that's what happening. So I should be looking in the .shadow-cljs dir instead? Calva doesn't treat shadow special with this file today, but maybe it should. #2019-06-2915:47thhelleryes, always use the .shadow-cljs/*.port files#2019-06-2915:48pezRoger that. I'll need to look closer at jack-in for shadow web projects anyway, I noticed today. #2019-06-2915:51pezAnother thing, while I am at this. When using the nrepl op for loading a file. With figwheel (both flavors) i get a result back. But not with shadow. This puzzles me a bit. What could be causing that?#2019-06-2915:52pez(The result is from the last form in the file.)#2019-06-2915:53thhellerits possible the result isn't sent#2019-06-2915:58pezI'll look closer at which messages I get. Maybe there is something else I can use to signal that the operation has been carried out.#2019-06-2918:45roooorHi guys, just getting started with clojure and im trying to run a basic project on my windows machine. When I run watch it runs the project for a minute or two and then exits#2019-06-2918:45roooorheres a screen shot of the process#2019-06-2918:45roooor#2019-06-2918:49roooortried to add
:fs-watch {:watcher :polling}
to shadow-cljs.edn but that didn't alleviate the issue
#2019-06-2920:40thheller@qwazilla I'm developing on windows myself and I can assure you that windows does not require any special settings#2019-06-2920:41thhellerI don't know why it would exit like that#2019-06-2920:42thhellerdo you connect to the process in any way (REPL via your editor or so) or does it just exit after the first build?#2019-06-3002:00roooor@thheller I installed the Calva extension for VScode but never ran any REPL through the ide itself. Only connecting to the project via browser.#2019-06-3002:01roooorim going to try running one of the example projects in the repo and see if i get the same results#2019-06-3007:54gerryHi I want to ask a question regarding the abandoned foreign-libs in shadow (sorry I am just setting things up with shadow so I am a very new user). I am trying to switch from figwheel to shadow and in my project I am using the monaco editor. Right now I have set up a webpack project just to import monaco and do some language configuration stuff. Then in my cljs project I just use foreign-libs with the usual global-exports option. How should I go about this in shadow?#2019-06-3008:41thheller@gerry I recommend just including the webpack generated code separately via its own script tag and accessing the globals it exports normally via (js/thatGlobal.foo.bar)#2019-06-3008:41thhellerassuming the monaco-editor still has its weird own packaging style that shadow-cljs can't process#2019-06-3008:51gerryOk I see.. Yeah it still has this weird packaging. I wanted to include it via cljs in order for the closure compiler to do its magic and have an optimized build. There is no other way around it right?#2019-06-3008:55thhellerforeign-libs does not process the JS in any way so the result you get is the same#2019-06-3008:56thhellerI doubt that monaco would survive the closure compiler processing#2019-06-3008:58gerryOh ok I mistakenly thought that foreign-libs would feed the JS through closure. Thanks a lot for clarifying#2019-06-3008:59thhelleryeah it is just prepended as is. not processed at all#2019-06-3009:00gerryI see, thanks for taking the time to help me! Have a nice day#2019-07-0122:45David Pham@thheller you write in your reagent-expo repository we should deactivate expo live reloading to let shadow-cljs manage states. Do you have any idea how?#2019-07-0208:28thheller@neo2551 open the expo menu thing. shake the device or two finger tap or whatever mechanism there is#2019-07-0208:28David PhamThanks!#2019-07-0208:44danielneal(apple-D on the simulator)#2019-07-0400:30neupshhi, what is the equivalent of the following in a cljs repl (shadow-cljs)?
var ice = require('./assets/ice.jpg');
#2019-07-0400:32neupshI tried
(def ice (js/require "./assets/ice.jpg"))
but it seems to see "require" is not defined
#2019-07-0400:33neupshrepl/invoke error, [ReferenceError: Can't find variable: require]#2019-07-0400:35neupshi also tried
(require '["./assets/ice.jpg" :as ice])
but it just sits there
#2019-07-0400:36neupshFWIW I am using it in expo project#2019-07-0408:10thheller@neupsh see https://github.com/thheller/reagent-expo/blob/master/src/main/test/app.cljs#L10-L14#2019-07-0408:10thhellerrequire is a compile time construct (in Expo/RN) so it doesn't work via the REPL#2019-07-0420:44p-himikJust tried to use react-vega and got an interesting error (paths truncated for brevity):
package in /.../node_modules/d3-scalespecified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["build/d3-scale.js"], :package-dir #object[java.io.File 0x58381a04 "/.../node_modules/d3-scale"]}
ExceptionInfo: package in /.../node_modules/d3-scalespecified entries but they were all missing
I think there's a space missing in d3-scalespecified. And d3-scale is missing from node_modules so it looks like the message "package d3-scale specified entries but they were all missing" is a bit misleading since it's the package itself that's missing.
#2019-07-0420:45p-himikOh no, not again. It's in /.../node_modules/vega-scale/node_modules/d3-scale/.#2019-07-0420:48p-himikAnd it's not even a git url dependency! NPM, WTH?#2019-07-0500:27pberganzaHas anyone here tried to use react-router with shadow-cljs? I'm trying to use hx and react-router. If I try to navigate using the address bar to a route like // it fails saying it cannot find a LOT of scripts located at //js/cljs-runtime/.js (I think it tries to take the first part as the root "/"). If it's only / it works perfectly. (Tried with the same component). Both work perfectly if I navigate within the app using anchors.#2019-07-0505:56pberganzaI tried replacing react-router with reitit, accountant and clerk and I'm still having the same issue.#2019-07-0506:26p-himikWhat is your :asset-path?#2019-07-0508:17thhelleryeah you are likely including your JS via a relative path. make sure your :asset-path starts with a / and your <script tag including the initial JS does as well#2019-07-0515:54pberganzaomg... that's it. Of course... thanks a lot! I wouldn't have figured that out myself. ❤️#2019-07-0516:33Ahmed HassanHow I can check which dependencies are included in build?#2019-07-0516:35Ahmed HassanI've declared dependencies in : dependencies vector in shadow-cljs.edn.#2019-07-0516:38Ahmed HassanThe required namespace "' is not available, ...#2019-07-0516:38Ahmed HassanBut it is showing error given above.#2019-07-0516:39Ahmed HassanWould using deps.edn instead of shadow-cljs.edn solve this problem?#2019-07-0517:16thheller@ahmed1hsn no. which dependency did you add? and did you restart the shadow-cljs process after adding it?#2019-07-0518:18Ahmed Hassan[keechma/toolbox "0.1.6"]#2019-07-0518:48Ahmed HassanThanks it got solved, I was using old dependencies.#2019-07-0517:43chrisblomi'm building a cljs frontend (using shadow-cljs) and a clj backend (using deps.edn). I'm running the frontend with shadow-cljs watch and the backend with a normal repl. A disadvantage to running is that the dev server for the frontend is running on a different port than the backend. Is there a way to run the dev shadow cljs server in the same process and port than the backend server?#2019-07-0517:45thhelleryou can just serve the output-dir normally using your CLJ server#2019-07-0517:45thhellerthey are normal static files#2019-07-0517:48chrisblomah yes, that should work, but it will not offer the reload-on-edit that shadow-cljs offers right?#2019-07-0517:49thhellerthat will work as normal. the webserver serving the files is not involved in that#2019-07-0517:49thhellerthe only thing you need to watch out for when serving the files yourself is proper cache invalidation#2019-07-0517:49thhellerotherwise you may get weird results#2019-07-0517:50chrisblomoh cool, thanks, will give this a try#2019-07-0612:15mhuebertHm, working on a :npm-module target, and requiring some JS files from cljs using (:require ["/abs-path-to-js" :as my-js]). Compiles, but when that js file is evaluated I get a ReferenceError: shadow$provide is not defined#2019-07-0612:31mhueberttoying around, I added a shadow$provide = {}, then see another error - the pattern in these re-emitted js files is
shadow$provide.module$foo = function() {...}
module.exports = module$foo
..and module$foo is not defined
#2019-07-0612:31thhellerthe js file should be ES6+. commonjs doesn't work#2019-07-0612:31thhellerie. import/export not module.exports/require#2019-07-0612:31mhuebertah#2019-07-0613:51mhuebertI’m getting some weird errors working with js files that depend on other js files https://gist.github.com/mhuebert/6898da15723a26da485a984bc3249022#2019-07-0614:15mhuebertone example fails at runtime, referencing a variable that isn’t defined except in the other js file. identity$$module$ftest$util instead of module$ftest$util.identity#2019-07-0614:16mhuebertthe other one fails at compile time:
import * as util from './util'
export const IDENTITY = (x) => util.identity(x)
#2019-07-0614:30mhuebertmade an issue https://github.com/thheller/shadow-cljs/issues/521#2019-07-0615:19thhellerhmm yeah the problem there is the :npm-module target#2019-07-0615:20thhellerthe direct JS support sort of only works in the browser since it sort of relies on having a shared global scope#2019-07-0615:20thhellernot sure about the closure compiler error though#2019-07-0615:21thhellerit might work with a newer closure compiler version#2019-07-0615:27mhueberthm ok. So using (js/require "..") would be more reliable#2019-07-0615:28thhelleryeah. I'm thinking about adding an option that skips the shadow-cljs transpilation of the JS files#2019-07-0615:28thhellerand just copies them to the output-dir as is#2019-07-0615:28thhellerso node can do the require stuff#2019-07-0615:29mhuebertfor what I am trying to do, I think that would be ideal#2019-07-0615:29mhuebertI am trying to avoid an extra transpile step, the env I’m deploying to doesn’t support import/export#2019-07-0615:29thhellerbut that requires a bit of work so for now I'd stick with js/require probably#2019-07-0615:29mhuebertk. how do relative paths work with js/require in shadow?#2019-07-0615:30thhellerall files are in the :output-dir so whatever you require must be relative to that#2019-07-0615:31mhuebertthat’s simple#2019-07-0700:55mhuebertis there a way to report errors during lazy module loading?#2019-07-0700:56mhueberterrors seem to be completely silent#2019-07-0700:56mhuebert(well, until eventually ModuleManager reports error code 1)#2019-07-0708:03thhellerhmm good question. never had that problem.#2019-07-0708:03thhellerI think the whole module loading stuff uses the default closure logging stuff#2019-07-0708:03thhellerso it should log everything if you set that up correctly#2019-07-0816:50mhuebertModuleManager has a registerCallback fn that lets you add a callback for errors, but this is only called after it has attempted to load a script a few times, and doesn’t pass you the actual error#2019-07-0818:11mhuebertwell, found a way to listen for errors during module loading: https://gist-press.com/mhuebert/dfdf5dd94bbb944e995dc475c4421f4c I think it’s kind of crazy that ModuleManager’s default is to silently swallow errors. (I saw a comment in the source where they wonder if they should throw, so they have been thinking about this)#2019-07-0818:16thhellerdid you not test setting up the closure logging stuff?#2019-07-0818:17thhellerthere is definitely logging related code#2019-07-0818:17thheller
goog.log.warning(
        this.logger, 'Loaded incomplete code for module(s): ' + moduleIds, e);
etc
#2019-07-0818:49mhuebertIt wasn’t obvious to me how to actually use it. I enabled debug mode in one of the namespaces but it didn’t have an effect #2019-07-0818:51mhuebertI’d also want these errors to be observed in production, maybe that’s also possible with the logging setup #2019-07-0818:51mhuebertHave to dig up plexus‘ blog post on this #2019-07-0819:20lilactownI've experienced this before as well, and your gist was super helpful. Thanks!#2019-07-0819:31mhuebertso, following plexus’s nice post (https://lambdaisland.com/blog) I found the four lines of code necessary to get goog logging to work#2019-07-0819:31mhuebertbut it’s not very useful#2019-07-0819:32mhuebertno stacktrace or clue as to where the issue is#2019-07-0819:32lilactownyeah, same experience here#2019-07-0819:32lilactownI think adding the custom logging is much more useful#2019-07-0819:32mhuebertFWIW
(ns ... 
  (:require [goog.debug.Console :as Console])
  (:import [goog.debug Console]))
(.setCapturing (Console.) true)
(Console/autoInstall)
#2019-07-0819:33mhuebertyeah#2019-07-0819:33mhuebertgoog also has not figured out how to get its own code to work with DCE#2019-07-0819:34mhuebert(not that it’s big, but)#2019-07-0819:40mhuebertoh: I spoke too soon, I am now seeing a debug stacktrace#2019-07-0819:40mhuebert#2019-07-0819:44mhuebertis it possible to set a global log level w/ goog.log?#2019-07-0819:44mhuebertor is it only per logger#2019-07-0819:44lilactowntaoensso's timbre does this for us I think#2019-07-0819:47mhueberthere is a reasonable default w glog:
(:require [goog.debug.Logger.Level :as Level]
            [goog.log :as glog])
(:import [goog.debug Console])

(.setCapturing (Console.) true)
(.setLevel (glog/getLogger "") Level/WARNING)
#2019-07-0819:51mhueberti’ll also add that to the gist… it adds 1.5kb but presumably may be useful for other errors cropping up from goog stuff#2019-07-0709:12dabrazhewhen connecting on shadow nrepl port i am getting the clj repl. how do I start cljS repl from it these days?#2019-07-0709:13thhellerassuming you have the watch for the build already running you just switch to it#2019-07-0709:13thheller(shadow.cljs.devtools.api/repl :the-build-id)#2019-07-0709:15dabrazhei am getting [:no-worker :the-build-id]#2019-07-0709:15thhellerthat should be the actual id of your build obviously#2019-07-0709:16dabrazhei've started it as .. server start#2019-07-0709:16dabrazhewhere do i find the build ID#2019-07-0709:16thhelleryour build config#2019-07-0709:16thheller{:builds {:this-is-the-build-id {:target :browser ....}}}#2019-07-0709:17thheller:app or whatever you have#2019-07-0709:17thhellershadow-cljs.edn#2019-07-0709:18dabrazheaaah#2019-07-0709:20dabrazheshould the watch be running or sever start is enouhg#2019-07-0709:20thhellerthe watch needs to be running if you want a REPL for your build#2019-07-0709:21thhellerhow you start the watch is up to you. either from the command line or from the CLJ REPL via (shadow.cljs.devtools.api/watch :the-build-id)#2019-07-0709:25dabrazheit's started, but..
cljs.user=>
[:selected :app]
1

No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
#2019-07-0709:27dabrazhei guess i am missing smth basic.#2019-07-0709:39thhelleryes. what build do you have? if its :target :browser you need to open the browser and load your JS#2019-07-0709:39thhellerif you just want a REPL to play with you can just run (shadow.cljs.devtools.api/browser-repl) or (shadow.cljs.devtools.api/node-repl)#2019-07-0709:40thhellerthat'll just give you a REPL without being tied to a build#2019-07-0709:44dabrazhethe build is node
:builds {:app {:target :node-library
                :exports {:handler server.main/handler}
                :output-dir "target"
                :output-to "target/main.js"}}}
#2019-07-0709:47thhelleryeah that would require running the target/main.js via node or so#2019-07-0709:47dabrazhei guess the trick is to start the node repl, not the broswer : )#2019-07-0709:47thhellerjust use node-repl#2019-07-0709:48dabrazheyes, it' s working! Thank you Thomas, you are a star!#2019-07-0714:13thedavidmeisterhow do i point to something local for a dependency?#2019-07-0714:13thedavidmeisteror a specific github commit?#2019-07-0714:14thhellerfor that you must use deps.edn#2019-07-0714:33thedavidmeisterthanks i'll have a look#2019-07-0714:57thedavidmeisterhmm i'm getting#2019-07-0714:58thedavidmeister
Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
#2019-07-0715:14thhellerassuming you configured deps.edn?#2019-07-0715:14thhellerthen you need to add thheller/shadow-cljs to your dependencies#2019-07-0715:20thedavidmeister@thheller in addition to or instead of npm install?#2019-07-0715:20thhellershadow-cljs is two parts. the JS parts that do the CLI stuff and the JVM parts that do the actual compilation#2019-07-0715:21thhellerso yes you need both#2019-07-0715:26daviwilI don't see it explicitly mentioned in the User Guide, but is the :dump-core compiler option supposed to work in cljs builds? I'm finding that even when setting that to true, cljs.js/dump-core still returns nil#2019-07-0715:27thheller:dump-core is not supported. if you need self-hosted support you should follow this https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-07-0715:27daviwilexcellent, thank you! I hadn't run across this post yet#2019-07-0715:45thedavidmeister@thheller thanks#2019-07-0717:53jimmyI can’t get npx shadow-cljs watch ... with :http-root to work on any version of shadow-cljs later than 2.6.x. I tried a personal project, the re-frame example[1], and the quickstart browser example[2]. Every time I run them everything other the than index (js,css,etc) fails to load with a 404. I tried changing to the new format suggested by issue 436[3] and got the same behavior. There are no sym-links involved in any of this. I am on mac. I tried node versions 8 and 10, with no difference in behavior. The index.html is loading and making changes to it are reflect, but no other resources are loaded (in same directory or otherwise). Serving that folder with something like simple-http works perfectly fine. I am on mac os catalina, so that could be the issue. I can’t really follow the code for the dev server. I do know based on adding print statements to my personal project that the js and css files are ultimately making their way to the push state handler[4], where they are then turned in 404s. If there is any way I can help debug this issue I’d be happy to. I wanted to check on here first to make sure I’m not missing something obvious. [1] https://github.com/shadow-cljs/examples/tree/master/re-frame [2] https://github.com/shadow-cljs/quickstart-browser [3] https://github.com/thheller/shadow-cljs/issues/436 [4] https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/http/push_state.clj#2019-07-0721:53thheller@jimmy what is your actual config? which version are you on? there are no issues I know of related to the dev http servers#2019-07-0722:00jimmyAll I did was take the quickstart above clone it and change the version to the latest. I then tried the last 5 or so versions. Tried 2.7.0. Still didn't work. Tried 2.6.0 and it worked.#2019-07-0722:10lilactown@jimmy I cloned the shadow-cljs/examples repo, and ran the following commands:
cd shadow-examples/re-frame
npm i
npm i -D shadow-cljs # currently installs 2.8.40
npm run watch # shadow-cljs watch app
After letting the build complete, I am able to load both the compiled code and CSS
#2019-07-0722:11lilactownI am on macOS Mojave 10.14.4, so that might be relevant as you said#2019-07-0722:16lilactownfor clarity, I am able to see the build files loaded by going to http://localhost:8280#2019-07-0722:17lilactownit looks like there may have been one or more changes to the dev server between 2.6 and 2.7. @jimmy could you try some of the intermediate versions?#2019-07-0722:22lilactownit looks like a lot of changes occurred between 2.6.14 and 2.6.24 so you might start between those two versions#2019-07-0813:06Ahmed Hassan
#2019-07-0813:06Ahmed Hassan#2019-07-0813:06Ahmed Hassan#2019-07-0813:07isak@ahmed1hsn do you see the heads-up display that the code has loaded?#2019-07-0813:08Ahmed Hassan@isak yes I do.#2019-07-0813:08Ahmed Hassan@isak yes I do.#2019-07-0813:17aisamuThis might mean that the code was loaded correctly, but it's not being picked up by the running application. Are you able to trigger a simple println via the :after-load configuration?#2019-07-0813:19aisamuI assume keechma is able to do hot code reloading properly, given the example: https://keechma.com/annotated/graph-data/ (right at the bottom) There are a lot of gotchas with that in general, so it's useful to ensure all the steps are executing correctly.#2019-07-0817:16Ahmed HassanThis is console log of shadow-cljs after saving changes to outcry_mobile/ui/main.cljs. Problem is that changes visible in running application. Behavior and look of UI remains same after this.#2019-07-0817:18Ahmed HassanYes I'm already doing steps mentioned in above link.#2019-07-0817:18thhellerand what do you do in the start fn?#2019-07-0817:18thhellershadow-cljs has done its job. everything else is up to you.#2019-07-0817:20Ahmed Hassan(defn ^:dev/start start [] (print "startt") (reload))#2019-07-0817:20thheller^:dev/start that does nothing#2019-07-0817:20thhellerwhat does the (reload) do?#2019-07-0817:21Ahmed Hassan(defn reload [] (let [current @running-app] (if current (app-state/stop! current start-app!) (start-app!))))#2019-07-0817:22thhellerso that probably on calls stop! right?#2019-07-0817:22thhellerassuming current exist it'll call stop!#2019-07-0817:22thhellerunless you call start-app! in stop! that probably is your problem?#2019-07-0817:22Ahmed Hassanstart-app! is callback, which is called after stop!.#2019-07-0817:25thhellerah ok#2019-07-0817:26thhellerbut why do you have a stop callback and then actually only stop on reload?#2019-07-0817:26Ahmed Hassancurrent is app-definition/app-config here.#2019-07-0817:31Ahmed Hassanlook at https://keechma.com/annotated/graph-data/ last lines of code at right here.#2019-07-0817:32Ahmed Hassanstop callback is optional param.#2019-07-0817:33Ahmed HassanYou can just have (app-state/stop! current) called and app would be stopped. But you would have to start it again yourself.#2019-07-0817:33thhellerthats what shadow-cljs does though#2019-07-0817:33thhelleryou have a stop callback which is called BEFORE your code is reloaded#2019-07-0817:33thhellerthen your code is loaded#2019-07-0817:34thhellerand start is called#2019-07-0817:35thhellerall you really need to do is re-render your app#2019-07-0817:35Ahmed HassanSo, we need to stop! in ^:dev/before-load and start-app! in ^:dev/after-load. right?#2019-07-0817:36thhellerthose annotations do not exist. don't know where you got them from#2019-07-0817:36thhellerit is :dev/before-load and :dev/after-load#2019-07-0817:38thhellerbut you seem to have them configured in the build config already since they are getting called#2019-07-0817:38thhellerdon't need to do both#2019-07-0813:08isakdo you have something like this in shadow-cljs.edn? https://github.com/mhuebert/shadow-re-frame/blob/master/shadow-cljs.edn#L31#2019-07-0813:09Ahmed HassanI'm using keechma.#2019-07-0813:09isakyea, though I assume it has some kind of call to render the UI, right?#2019-07-0813:10isaksomething like this needs to get called after the code is reloaded: https://github.com/mhuebert/shadow-re-frame/blob/master/shadow-cljs.edn#L31#2019-07-0813:10Ahmed Hassanyeah, though I have reload hooks setup according to stop and start app.#2019-07-0813:11isakhm ok, I guess I don't know enough about keechma to be able to help#2019-07-0814:49thheller@ahmed1hsn the browser console should tell you what shadow-cljs is doing#2019-07-0816:12hlolliis this what the chat up here is refering to?
shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn  cli version: 2.8.40  node: v10.15.2
shadow-cljs - starting via "clojure"
Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
#2019-07-0816:15thhelleryes. as of 2.8.40 you must add the shadow-cljs dependency to deps.edn manually#2019-07-0816:17hlolliI see, I noticed that my cli version was 2.8.40 and my project was 2.8.36. I'll add it, thanks!#2019-07-0816:29carkhhum what could cause shadow-cljs to just close after a little while ... after encountering the problem, i have updated to 2.8.40 on both npm and in my project and it still just closes after about a minute or so#2019-07-0816:29carkhthe project was working fine a couple weeks ago#2019-07-0816:29thhellerhow are you using it?#2019-07-0816:29thhellerit should never be doing this on its own#2019-07-0816:30carkhi tried as a base line ...npx shadow-cljs server .... with deps.edn#2019-07-0816:30carkhis there some kind of log i could find ?#2019-07-0816:31thhellerno really no#2019-07-0816:31thhellerso you run npx shadow-cljs server and then do what?#2019-07-0816:31thhellernothing and it will exit after a minute or so?#2019-07-0816:31carkhexactly#2019-07-0816:31carkhi do nothing#2019-07-0816:32carkhlast cli line is "shutting down ..."#2019-07-0816:32thhellerand it actually starts normally? not like throws exception all over the place on startup?#2019-07-0816:32carkhso it's gracefull at least =)#2019-07-0816:32carkhnothing#2019-07-0816:33carkhsome npm warnings about missing package.json, but that was always there#2019-07-0816:33thhellerthat shutdown should only happen if you CTRL+C or CTRL+D the npx process#2019-07-0816:33thhellerwarnings?#2019-07-0816:33carkhnpm WARN cark.tags No description#2019-07-0816:34carkhi don't have a package.json, but that never was a problem#2019-07-0816:34thhelleryou should always have one. how are you getting your npm packages otherwise?#2019-07-0816:34carkhmanually#2019-07-0816:35carkhi have the package-lock.json#2019-07-0816:35thhellerhow do you get that if you don't have a package.json?#2019-07-0816:35carkhit just appears when i install npm packages#2019-07-0816:36carkhi'll take the time to make one and see if that fixes anything, though i have my doubts#2019-07-0816:37thhellerit probably won't but you should still have one regardless. seems weird to not have one.#2019-07-0816:37thhellerbut yeah shadow-cljs itself definitely won't exit unless some exit condition is reached#2019-07-0816:37thhellerie. the npx process is killed or closed#2019-07-0816:38carkhi watched memory usage, looked like not so bad#2019-07-0816:38thhellermaybe something else is killing node processes? or java processes?#2019-07-0816:39carkhhum i've been using kaocha for days at a time recently and i think it has both java and node cljs running#2019-07-0816:40thhellerand you are doing absolutely nothing to the process? not even starting a watch or whatever?#2019-07-0816:40carkhlet me close absolutely everything and report back#2019-07-0816:46carkhyep same thing, looks to be about 1 min after it's "ready", i'll try an empty project#2019-07-0816:47thhellercan you paste the entire log?#2019-07-0816:47carkh#2019-07-0816:48thhellerrunning: cmd /C npm install --save #2019-07-0816:48thhellerthats one reason to have a package.json so it doesn't do that all the time#2019-07-0816:48carkhyes that thing is different i think#2019-07-0816:48carkhohh ok#2019-07-0816:50carkhso i started a new app npx create-cljs-project acme-app#2019-07-0816:50carkhand same thing, only faster#2019-07-0816:50carkh#2019-07-0816:52thheller
C:\Users\thheller\code\tmp\acme-app> npx shadow-cljs server
shadow-cljs - config: C:\Users\thheller\code\tmp\acme-app\shadow-cljs.edn  cli version: 2.8.40  node: v11.9.0
shadow-cljs - updating dependencies
Retrieving thheller/shadow-cljs/2.8.40/shadow-cljs-2.8.40.pom from 
Retrieving thheller/shadow-cljs/2.8.40/shadow-cljs-2.8.40-aot.jar from 
shadow-cljs - dependencies updated
[2019-07-08 18:51:16.283 - WARNING] TCP Port 9630 in use.
shadow-cljs - server version: 2.8.40 running at 
shadow-cljs - nREPL server started on port 51194
#2019-07-0816:52thhellerwth 😛#2019-07-0816:53carkhnice indenting you got there =)#2019-07-0816:54thhellerits not exiting at all#2019-07-0816:54carkhyes must be something on my end obviously or you would have an uproar in thic chan =)#2019-07-0816:55carkhi just have no idea on how to debug it#2019-07-0816:55carkhhum looks like i'm on ancient 1.8 java version#2019-07-0816:55thhellerme neither#2019-07-0816:55thheller1.8 is fine#2019-07-0816:56carkhnpw 9.7.1, npm 6.10.0#2019-07-0816:56thhellermaybe you have some over eager anti-virus stuff or so going crazy?#2019-07-0816:56carkhah that could be it#2019-07-0816:57thhellerno clue why it would be killing node processes but these programs tend to do lots of nonsense 😛#2019-07-0816:57carkhthat's the one thing that changed, i'll test and tell you in a little while#2019-07-0816:58thhellerdo you get a windows firewall dialog? asking if you are allowed to use port 9630?#2019-07-0816:58thhellerthose something disappear into the background#2019-07-0816:59carkhno firewall, but malawre byte updated and is again "pro" for a little while, this has some port watching stuff i think#2019-07-0816:59carkhthat was it, thank you so much#2019-07-0816:59carkhit works, at least for now =)#2019-07-0817:00thhellerwoho#2019-07-0817:00David PhamHello everyone :) I am using the reagent-expo repository, with an updated expo SDK to 33 and set the target to web. I blocked request from /sockjs-node/* to allow hot reloading from shadow-cljs, but every time I compile the cljs code, expo also compile the web, but the website does not update. Anyone has some experience on how to solve this?#2019-07-0817:01thhellerdisable expo reloading in the app itself?#2019-07-0817:01thhellerno need to block requests?#2019-07-0817:01David PhamIt is web, so I can’t find the expo option for it #2019-07-0817:02David PhamIt works perfectly on mobile #2019-07-0817:02thhellerwhat does that mean? "It is web"?#2019-07-0817:02David PhamIn the targets of the app.json, you can add “web” so that expo uses react native web #2019-07-0817:03thhellerso its not actually react-native but a pure browser?#2019-07-0817:03David Phamhttps://blog.expo.io/expo-cli-and-sdk-web-support-beta-d0c588221375#2019-07-0817:03thhellernot a clue about that. never tested that#2019-07-0817:04thhellerthere probably is an option to disable the live-reload. just blocking the requests is not enough since it likely still has some sort of other connection open#2019-07-0817:08David PhamOk i will try to dig in! Thanks a lot for your help and for the tool!#2019-07-0817:09David PhamYou really made my path to cljs much easier!#2019-07-0817:49neupsh@neo2551 It does hot load the code for me. I have https://github.com/neupsh/rn-rf-shadow which is fork from PEZ's repo based off of thheller's repo#2019-07-0817:50David PhamI tried to understand what is the difference between theller version and the repo though lol#2019-07-0817:50David PhamThanks for answering on github :)#2019-07-0818:07David PhamOk it works on your repo! @neupsh #2019-07-0819:06David PhamOk i got it, in reagent-expo the main in package.json in the file in node_module, whereas in the other repos, the main is ./app/index.js#2019-07-0914:51knubiewhat’s the best way to determine whether you’re in dev/release mode in your clojurescript code?#2019-07-0914:56mccraigmccraig@steedman87 we use closure defines for such things#2019-07-0914:56knubie@mccraigmccraig Just found that on the users guide!#2019-07-0914:56knubiethanks 🙂#2019-07-0915:58neupshHello, when i try to use expo-three node module in a shadow-cljs expo project, I get this error:
Uncaught Error: Cannot find module './suppressWarnings'
This happens when i require THREE from expo-three module. I can see that the supressWarnings.ts file is there in the repo where Three.ts file is in this repo: https://github.com/expo/expo-three/blob/master/src/Three.ts Is this because the exported object is suppressExpoWarnings but the filename is suppressWarnings? I am weak on JavaScript and not sure if it is because of the way shadowcljs compiles the ts files or if there something else I am missing.
#2019-07-0916:03neupshHere is the repo for that issue: https://github.com/neupsh/rn-rf-shadow/tree/test-threejs * clone, yarn watch on one terminal, and once it compiles, yarn web to open the react-native-web app on browser (if it does not automatically open the browser you can open http://localhost:19006/#2019-07-0916:10thheller@neupsh please paste the full error.#2019-07-0916:13neupsh#2019-07-0916:13neupsh@thheller ^^#2019-07-0916:13thhellerso thats not a shadow-cljs problem then#2019-07-0916:14thhellerno clue how the expo web stuff works but looks like it uses webpack#2019-07-0916:17thhellermight be that the expo-three stuff just doesn't support the web target?#2019-07-0916:21thhelleryou should try creating a pure JS expo web project and see if it works there#2019-07-0916:21thhellerI'd be very surprised#2019-07-0916:30neupsh@thheller from what I have gathered expo-three works on web as well. There is this project which demos it: https://github.com/EvanBacon/Expo-Pillar-Valley#2019-07-0916:31thhellerwhich version of expo-three did you use?#2019-07-0916:32thhellerah nvm its in the repo#2019-07-0916:32thhellersorry I don't have time to look into this more closely right now#2019-07-0916:32thhellermaybe ask in some expo channel or so#2019-07-0917:22neupsh@thheller no problem thanks for looking at it. I will try to figure out more but looks like plain java script projects do not have this issue. In any case if anyone else have any suggestions I am open for it 🙂#2019-07-0917:35thheller@neupsh one thing that looks different is that the expo project above has a webpack.config.js which seems to do a whole bunch while your project has none. https://github.com/EvanBacon/Expo-Pillar-Valley/blob/master/client/webpack.config.js#2019-07-0917:36neupshThanks for the pointer @thheller I will take a look#2019-07-0920:41clojuregeekI want to start my shadow-cljs with code to run my integration tests and i am using the start! function to start the server .. but i don't see how to pass in params for the port - https://github.com/thheller/shadow-cljs/blob/555befb961f204849524011eeafba1ab665c538a/src/main/shadow/cljs/devtools/server.clj#L409#2019-07-0920:42thheller@clojuregeek which "port"?#2019-07-0920:44clojuregeekmy server runs at localhost:8890 .... and my dev server is localhost:8888#2019-07-0920:45thhellerplease define what kind of server you are talking about more detailed#2019-07-0920:45thhellershadow-cljs starts a http server, a nrepl server, a socket repl server and depending on config dev http servers#2019-07-0920:45thhellerall of them with their own purpose and port#2019-07-0920:46thhellerby "your server" I presume you talk your CLJ http server?#2019-07-0920:47thhelleryou can use that server to serve the JS files created by shadow-cljs#2019-07-0920:47thhelleryou do not need to use the http server shadow-cljs provides for that#2019-07-0920:49clojuregeekok so i can run my tests using the http server and not run an additional server just for tests#2019-07-0920:50thhellerdon't know enough about what your tests do#2019-07-0920:50thhellerbut yes you can probably run them without shadow-cljs even running#2019-07-0920:50clojuregeekthey are webdriver tests#2019-07-0920:50thhellerok then it is probably enough to just compile once and then run the tests without having shadow-cljs running#2019-07-0920:50thhellerunless you want to REPL into your tests and so on#2019-07-0920:51clojuregeeki was using node to run them but it apparently doesn't respond sometime so my boss changed to start the server with code#2019-07-0920:52clojuregeekthanks for your help#2019-07-0920:54thhellerin general for tests I recommend not combinging compilation with actually running them#2019-07-0920:54thhellerso you first compile separately#2019-07-0920:54thhellerand then run them#2019-07-0920:55thhellerso its easier to identify when compilation actually failed#2019-07-0920:57clojuregeekok#2019-07-1011:17martinklepschhas anyone seen this exception before?#2019-07-1011:20thheller@martinklepsch looks to me like (shutdown-agents) was called maybe?#2019-07-1011:21thheller
$ clj
Clojure 1.10.1
user=> (shutdown-agents)
nil
user=> (future 1)
Execution error (RejectedExecutionException) at java.util.concurrent.ThreadPoolExecutor$AbortPolicy/rejectedExecution (ThreadPoolExecutor.java:2055).
Task 
#2019-07-1011:22martinklepschyeah that would make sense but the only places where I can find shutdown-agents are not being ran… will investigate a bit further 🙂#2019-07-1216:43martinklepschturned out some code changed and we were calling shutdown agents 🙂#2019-07-1216:43martinklepsch@U05224H0W just fyi ☝️#2019-07-1011:22martinklepschjust wanted to check if anyone is like “ah yeah, that’s that!”#2019-07-1011:22martinklepsch🙂#2019-07-1011:23thhellerits definitely not shadow-cljs doing that#2019-07-1014:50aisamuHi! Related to this issue reported on #cljs-dev (https://clojurians.slack.com/archives/C07UQ678E/p1562770098327500), I'd just like to add that shadow-cljs seems to swallow the NPE (but unfortunately still emits invalid JS):
goog.provide('cljsbug.wat.shadow.core');
goog.require('cljs.core');
cljsbug.wat.shadow.core.a = cljs.core.rand_nth(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [null], null));
if(cljs.core.truth_(cljsbug.wat.shadow.core.a)){
( * (2));
} else {
}
#2019-07-1016:48thhellerthat one is probably fixed in CLJS master. forgot what the ticket issue was but it was a compiler bug#2019-07-1016:49thhellerI think it is this one https://github.com/clojure/clojurescript/commit/1fcce719377d0d1ecc1b197ed8023c48b3f5c720#2019-07-1101:23aisamuConfirmed that it works! Thanks!#2019-07-1109:34donavanHi, we have a pure cljs project built with shadow-cljs that has a need for headless browser based integration tests. We normally use https://github.com/igrishaev/etaoin for this but after reading the manual I can't see an obvious way of writing the tests in clj. Has anyone done this before? I'd rather avoid bringing in another build tool for this.#2019-07-1109:49polymerisYou mean writing them in cljs? I don't think that's possible with etaoin. You'd have to switch to something JS-based, e.g. cypress#2019-07-1109:50polymerisOr did you mean that you want shadow-cljs to run clj?#2019-07-1109:50polymerisshadow-cljs clj-run could help#2019-07-1110:23donavanThe latter. I would probably just use boot to run the clj tests before trying to do it myself with clj-run. I was just wondering if there was a simple solution I was missing with shadow-cljs#2019-07-1114:27thhellerclj-run is that simple solution. you just create a clojure function in some namespace and call that using clj-run#2019-07-1114:27thhellerbut shadow-cljs is focused on CLJS so running CLJ stuff might be better served using boot or so#2019-07-1111:38fbielejecHi, I wrote a small post on using shadow to target (vanilla) react-native codebase and run it on an iOS simulator in Linux (using vbox) https://www.blog.nodrama.io/react-native-xcode-linux/ There is an accompanying repository here: https://github.com/fbielejec/shadow-cljs-react-native The resulting workflow is quite snappy and non-obtrusive - hopefully someone can find it useful.#2019-07-1212:58jlmrHi, I’m trying to make a Jupyter Lab Extension using ClojureScript and shadow-cljs. However, I’m stuck right at the beginning and am unsure about which environment to target (`:browser`, :node-library or :npm-module), and how to configure shadow-cljs.edn and package.json. A template for a Javascript Extension can be found here: https://github.com/jupyterlab/extension-cookiecutter-js/tree/master/%7B%7Bcookiecutter.extension_name%7D%7D. Furthermore the JupyterLab documentation states the following: “An Extension is a valid npm package that meets the following criteria: • Exports one or more JupyterLab plugins as the default export in its main file. • Has a jupyterlab key in its package.json which has “extension” metadata. The value can be true to use the main module of the package, or a string path to a specific module (e.g. “lib/foo”). • It is also recommended to include the keyword jupyterlab-extension in the package.json, to aid with discovery (e.g. by the extension manager). It would be great if someone could point me in the right direction!#2019-07-1213:01thhellerlooks like :node-library would be what you want#2019-07-1213:09jlmrThanks, will try to get it going this way#2019-07-1213:15jlmr@thheller I’m now getting TypeError: "FS.readFileSync is not a function" in the browser console#2019-07-1213:15jlmrI think it is because shadow-cljs is somehow invoking that function#2019-07-1213:16thhellerno its because it isn't running in node#2019-07-1213:16thhellera release build will probably work#2019-07-1213:16thhellerjust not watch or compile#2019-07-1213:17thheller:node-library as the name implies is meant for things that run in node#2019-07-1213:17thheller:npm-module is probably a better fit then#2019-07-1213:20jlmrI’ve been trying this way a couple of hours ago, but had trouble with getting the js exports right#2019-07-1213:17thhellerI can take a look at this stuff a bit later and probably create an example#2019-07-1213:19jlmrThat would be great of course!#2019-07-1213:17thhellernever used the jupyter stuff before though#2019-07-1213:22thhelleryeah it works a bit differntly there#2019-07-1213:22thhellerbasically you create a namespace#2019-07-1213:23thhellerwith a bunch of (def ^:export thing ...)#2019-07-1213:23thhellerand then use the JS file for that ns as the main in package.json#2019-07-1213:23thhellerso "main":"./lib/your.ns.js" or so#2019-07-1213:24thhellershould be {:target :npm-module :entries [your.ns] :runtime :browser}#2019-07-1213:25jlmrThanks, I will try it this way. It could be that :runtime :browser was the part I was missing earlier#2019-07-1213:29thhellerthere could be a dedicated :target :jupyter that takes care of all of that but I never used it before#2019-07-1213:29thhellerbut thats the intent of the :target abstraction#2019-07-1213:53jlmr@thheller one more question: I think I have the basics configured correctly now, because Jupyter is no longer complaining when I build and import the extension. However I don’t think my code is actually executed when I open Jupyter. Jupyter expects the extension object as the “default export in the extension main file”. How can I set my (def ^:export extension #js {:stuff :here}) to be the default export?#2019-07-1213:54thhelleruhm that might not work because CLJS renames default but maybe it does. so it would just be (def ^:export default ...)#2019-07-1213:55jlmrNope that did’nt do the trick unfortunately#2019-07-1213:58thhellerthen CLJS probably renamed it to default$ since default used to be a reserved symbol#2019-07-1213:58thhellerbut you can create a manual extra .js file and use that as main#2019-07-1213:59thhellerand just do something like import { x } from "./lib/your.ns.js" and export default x;#2019-07-1214:02thhellerwith (def ^:export x ...) in your CLJS ns of course#2019-07-1214:05jlmrAwesome, that did the trick! 🎉 Thanks a lot for all the help. Now on to the actual work of writing the extension 🙂#2019-07-1217:20neupshit would help others if you may be create a project template/scaffolding if you have spare time 🙂#2019-07-1308:41jlmr@U3MRWH35M might do that if I manage to get it working and packaged correctly #2019-07-1414:22jlmr@U3MRWH35M I made a PR for shadow-cljs/examples: https://github.com/shadow-cljs/examples/pull/14#2019-07-1513:07neupshnice. Thanks 🙂#2019-07-1216:44martinklepschhow do you require e.g. the crypto or fs module from node?#2019-07-1219:46thheller(:require ["fs" :as fs]) and (fs/readFileSync ...) or so?#2019-07-1216:44martinklepschor should I just use goog.crypt? 🤔#2019-07-1217:13martinklepschended up just using goog.crypt 🎉#2019-07-1217:49wilkerlucio@martinklepsch on node you can call (js/require ...) directly, but I guess if you use strings on the :require block it works as well#2019-07-1218:06currentoori’m having trouble figuring out how to map var { createCanvas } = require("canvas"); to the namespace require in cljs#2019-07-1218:06currentoorI tried
(ns ucv.controller.barcode
  (:require
    ["canvas" :as createCanvas]))
#2019-07-1218:06currentoorand
(ns ucv.controller.barcode
  (:require
    ["canvas" :refer [createCanvas]]))
#2019-07-1218:07currentoorbut neither work#2019-07-1218:07neupsh@currentoor the second one looks correct#2019-07-1218:09neupshif createCanvas was exported default, (which does not look like the case looking at var { createCanvas } = require("canvas");, it would have been (:require ["canvas" :as canvas :default createCanvas])#2019-07-1218:09neupshcan you try `#2019-07-1218:09currentoorah yeah i’ll try#2019-07-1218:09neupsh
(ns ucv.controller.barcode
  (:require
    ["canvas" :as canvas]))

(def createCanvas (.-createCanvas canvas))
#2019-07-1218:10neupshi had success with this second approach (instead of :refer) with react-native/expo components#2019-07-1218:11currentoornope that didn’t work either#2019-07-1218:11currentoorthis does work though
(def canvas (js/require "canvas"))
(js/console.log (.-createCanvas canvas))
#2019-07-1219:48thheller@currentoor (:require ["canvas" :refer [createCanvas]]) would be the correct translation#2019-07-1219:49currentoor@thheller yup that works, thank you!#2019-07-1220:11neupsh@currentoor what is different between your second form and @thheller's answer? (just curious, i see both as same)#2019-07-1220:12currentoornothing, i think when trying different requires i got my repl into a bad state#2019-07-1220:12neupshah ok#2019-07-1221:37nateHello, I'm trying to require and use WalletConnectProvider as it is defined here https://github.com/WalletConnect/walletconnect-monorepo/blob/53206bb3a6c9a7205942271f0433877f51763327/packages/web3-provider/src/index.js#2019-07-1221:37nateit's declared as export default function WalletConnectProvider (opts) {}#2019-07-1221:38nateI've required it as ["@walletconnect/web3-provider" :default WalletConnectProvider] and used (new WalletConnectProvider ...)#2019-07-1221:39natebut I get this error message:#2019-07-1221:39nate#2019-07-1221:39nateany ideas ?#2019-07-1221:44thhellerwhat is i?#2019-07-1221:47thhellerhard to say what that is but it always helps to use ["@walletconnect/web3-provider" :as x :default WalletConnectProvider] and then logging (js/console.dir x) to verify if the properties you are looking for actually exist#2019-07-1221:55natelogging x gives me:#2019-07-1221:55thhellerok so :default is probably correct then#2019-07-1221:47thhellerie. if there is a .default property#2019-07-1221:49estevamHas anyone ever had a problem running shadow-cljs with chrome 75? My browser freezes in a project we have in my company. It works with previous versions of chrome, though. In chrome's network, almost all requests show (pending) forever 🤔#2019-07-1221:54thheller@estevam.machado if you import a whole lot of files it can get a bit slow to use. never seen a full freeze though#2019-07-1221:54thhelleryou can try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518 and see if that improves things#2019-07-1222:01teawaterwirewill :loader-mode :eval be set as default in the future?#2019-07-1222:11thhellerno#2019-07-1618:42wilkerlucio@thheller why? does thigns are breaking?#2019-07-1618:42wilkerlucioI'm wondering because of @estevam.machado, this seems to happen to a lot of Linux users at my workplace, my guess our app is getting too large, getting from slow down to total freeze#2019-07-1618:49estevam@thheller thank you very much, it worked! But I am also wondering why will it not be the default in the future 🤔#2019-07-1619:17thhellerit makes the compile cycle slower and only benefits builds with a lot of files#2019-07-1619:17thhellerI have some other ideas about reducing the number of files which should be better in all cases#2019-07-1309:11sogaiuanyone have a working shadow-cljs.edn sample configured to work with dirac?#2019-07-1311:47sogaiufor future reference, here's something that might turn up something relevant: https://github.com/search?q=filename%3Ashadow-cljs.edn+dirac#2019-07-1413:07Marcin@thheller I know that we can create web workers easily, but is there a way to create a service worker? That would need to be in the root folder, instead of e.g. /js#2019-07-1415:02thhellerthe only service worker I created so far I did create with https://developers.google.com/web/tools/workbox/#2019-07-1507:35MarcinGot it, thank you!#2019-07-1415:03thhellernot sure CLJS is all too useful for service workers given that 99% of it is native JS interop#2019-07-1420:22David PhamMaybe not Shadow-cljs/ClojureScript specific question, but anyone has some insights on using web workers? Are they good/bad ideas? What are the rookie mistakes with them?#2019-07-1501:24vinursanyone use ant-design with shadow-cljs?#2019-07-1501:25vinursi use modularized antd and set .babelrc but it seems that the js and css file are not import modularly#2019-07-1509:13thheller@haiyuan.vinurs what is modularized antd?#2019-07-1509:15vinurshttps://ant.design/docs/react/introduce#2019-07-1509:15vinursthat is only import the js and css that used#2019-07-1509:17thhellerso you do (:require ["antd/es/date-picker" ...]) and so on?#2019-07-1509:44Ahmed HassanWould this also require css related to antd/es/date-picker?#2019-07-1509:46thhellerno. shadow-cljs does not support CSS#2019-07-1509:56Ahmed HassanIs there a way for this in ClojureScript?#2019-07-1509:57Ahmed HassanLike import 'antd/es/date-picker/style/css';#2019-07-1509:58thhellerno#2019-07-1509:59thhelleryou can just use something like node-sass and import it there#2019-07-1514:36vinurssorry for late reply, so the best way is that i include the ant-design.min.css in my html file?#2019-07-1604:05Ahmed Hassan@haiyuan.vinurs yes.#2019-07-1509:17thhellerthe babel plugin won't do anything#2019-07-1519:35alpoxHi all! I have a short question about the usage of shadow-cljs with electron. Everything works well until now except the usage of the fs module in the renderer process. From the main process it is no problem to (require '["fs" :as fs]) and get the fs module. But from the renderer process, all I get is an empty map: #js {} while for the modules path and url i get the right modules. I cannot figure out how this happens. Does anyone have an input to this?#2019-07-1520:15thheller@alpox you are probably using the wrong build config. the renderer process should have :js-options {:js-provider :require}#2019-07-1520:21alpoxHi @thheller many thanks for awesome shadow-cljs!#2019-07-1520:21alpoxSetting that option for the renderer process sadly led to a whole series of: Uncaught ReferenceError: require is not defined 😞#2019-07-1520:23alpox#2019-07-1520:33thhellerhmm did they change that or did you disable it in the electron config?#2019-07-1520:34thhellerit used to be able to use require directly?#2019-07-1520:38alpoxI don't have an electron config so that should be the default. I have the feeling that I have some tooling problem with CIDER. I hope that it works with that option once I get around it!
#2019-07-1520:47alpoxOk I deleted .shadow-cljs and the errors vanished except that the behavior with the fs module is still the same with the :js-options {:js-provider :require} option#2019-07-1520:47alpoxMeaning I still get an empty map#2019-07-1520:48alpox#2019-07-1520:51thhellerand what do you get if you do (js/require "fs")?#2019-07-1520:57alpox#2019-07-1520:59alpoxThis happens with and without the js-provider set to :require#2019-07-1521:00alpoxI tested now multiple times and the require is not defined errors always appear with :require set as js-provider, the fs problem occurs with and without#2019-07-1521:00alpoxI guess electron does something special to provide those node modules for the renderer#2019-07-1521:01thhellerjust to be clear though this is a regular electron renderer window? not a normal browser?#2019-07-1521:01thhellerbut yeah fs and such are typically only used in the main process#2019-07-1521:02thhellerrequire should definitely be available though#2019-07-1521:02thhellerah. see https://stackoverflow.com/questions/44391448/electron-require-is-not-defined#2019-07-1521:02alpoxYes it is a regular electron renderer window from a newly setup project#2019-07-1521:02thhellerAs of version 5, the default for nodeIntegration changed from true to false.#2019-07-1521:03alpoxOhhh my. But they really should put a hint to that in their documentation where they say that node modules are available everywhere 😄#2019-07-1521:03alpoxI'll try that - thanks for the hint!#2019-07-1521:10alpox#2019-07-1521:10alpoxWonderful 🙂 @thheller so the error was somewhere totally different than I expected. Thanks for the fast help!#2019-07-1603:11ScotHey, I noticed that cuerdas doesn't work with shadow-cljs. Cuerdas bundles xregexp.js as a resource, but shadow-cljs seems to be messing with it. Running npm install xregexp doesn't help, it then gives another error:
The required JS dependency "core-js/library/fn/array/is-array" is not available, it was required by "node_modules/@babel/runtime-corejs2/core-js/array/is-array.js".

Searched in:<my-project>/node_modules

You probably need to run:
  npm install core-js/library/fn/array/is-array
Neither this instruction, nor npm install core-js help. Has anyone else had success using cuerdas "2.2.0" on the client with shadow-cljs?
#2019-07-1613:53stefanDoes npm install work?#2019-07-1615:08thhellercore-js unfortunately has a bunch of incompatible versions#2019-07-1615:10thhellerit should be working normally but you might just have some version conflicts#2019-07-1607:46agCan someone explain how to use shadow with CIDER? I was able to get an absolute minimum with shadow-cljs.edn and a single :dev build targeted for :node-script, it works when I do shadow-cljs watch dev in one terminal window and node target/app.js in the other, but I just want to CIDER-jack-in. When I jack-in-cljs: - it first prompts me with the type of REPL, to which I say “shadow”, there’s also “shadow-select”, which I believe is the same thing. - then it prompts me again for a build, I choose :dev, - then it prompts me for the third time, asking if I want to launch a browser (wtf?). Anyway, it kinda works, but what bothers me - it doesn’t print anything, anywhere (unlike when I run the app like above). My :devtools {:after-load function, I can’t tell if it’s firing or not. I tried setting (enable-console-print!) and (node/enable-util-print!) - it’s not printing#2019-07-1607:51agI also tried setting up deps.edn with shadow-cljs - and failed at that as well. Anyway - my end goal is to run Puppeteer scripts, I believe I have to use :target :node-script for that. But why it’s not printing anything? prn doesn’t appear to be working, neither js/console.log. It’s not complaining, there’s simply no output anywhere#2019-07-1607:53agI probably can figure out how to set some elisp vars in .dir-locals.el so it doesn’t bother me with those silly prompts, but I can’t figure out how to print#2019-07-1610:26thheller@ag I can't help with the cider side of things since I don't use it. as for the shadow-cljs side of things you should NEVER call any of the enable-print methods since that messes with the print methods shadow-cljs already sets up#2019-07-1610:28thhellerthe print output is currently only available in the process in the launched node process#2019-07-1610:28thhellerhttps://github.com/thheller/shadow-cljs/issues/373#2019-07-1614:26deadghost@ag https://www.blog.nodrama.io/shadow-cljs-cider/ I followed that and it seemed to be working ok (for browser target)#2019-07-1615:33lilactown@ag when it prompts for the build, type dev not :dev#2019-07-1615:33lilactownno colon#2019-07-1615:34lilactownit prompts you to open a browser because most people are using CLJS in the browser.#2019-07-1615:34lilactownyou also still must run the node process in a terminal#2019-07-1615:37lilactown@ag so the full steps should be: 1. Run cider-jack-in-clojurescript 2. Select shadow 3. Choose dev 4. Press n to not open a browser Once the build has completed once, in a terminal run the command: node target/app.js and you should see your console.log println etc. show up in the Node process terminal#2019-07-1622:25Daw-Ran LiouCan dev http server redirect not just to index.html but also other files? Currently I have the below files under the public folder. There are both static pages (`index.html`, log-in.html, and sign-up.html) and my single page app (`app/index.html`). I want the single page app to handle all the routing under the path /app/*, for example /app/profile. However, when loading /app/profile, the dev server falls back to public/index.html. Any suggestion is welcome.
public/index.html
public/log-in.html
public/sign-up.html
public/app/index.html
#2019-07-1622:56alpox@dawran6 I didn't check it locally but did you try to set multiple roots?:#2019-07-1622:57alpoxI'd imagine the roots to be setup as ["public/app" "app"]#2019-07-1623:07Daw-Ran LiouThanks. I just gave it a try but it didn’t work because path /app/profile does not match any file under those two roots, and thus the default handler was called.#2019-07-1623:12Daw-Ran LiouBut I think you gave me a direction. The :push-state/index key might be the one I am looking for.#2019-07-1623:14alpoxAh good. I hope it will work out with it.#2019-07-1623:20Daw-Ran LiouThis might not be exactly what I want but hope it’ll work. The right way to do it might be to write a custom handler:#2019-07-1623:21Daw-Ran LiouThanks again for helping out @alpox 🙂#2019-07-1623:38alpox@dawran6 No problem. I'm sure you'll figure out something that works for you 🙂#2019-07-1708:47thheller@dawran6 that currently is not supported and I would suggest using a regular webserver or so for that. something that would match your production setup more closely#2019-07-1713:09talgiatIs there a way to see the hot reloaded compiled javascript code when looking in the devtools Sources tab?#2019-07-1713:17thhellerit should show up normally?#2019-07-1713:29talgiatI’m seeing the version of the original js file when I loaded the page#2019-07-1713:30talgiatthe cljs is updating just not the js#2019-07-1716:32Daw-Ran LiouThank you for responding @thheller#2019-07-1802:52superstructorre-frame-10x has a bug when using shadow-cljs whereby require like [react-highlight.js :as react-highlightjs] leads to an exception due to not binding the correct value, whereas ["react-highlight.js" :default react-highlightjs] does work. As a library, I will need to maintain support for both standard CLJS/figwheel and shadow-cljs with any fix. Any guidance on how one supports both please ?#2019-07-1807:23thheller@superstructor the problem is with how the CLJSJS package is created. it is basically doing the "unwrapping" of the default export. https://github.com/cljsjs/packages/blob/master/react-highlight/resources/main.js#2019-07-1807:23thhellerthat should be module.export = Highlight; and re-frame-10x should be using [react-highlight.js :as react-highlightjs] and then later when using it react-highlightjs/default in the adapt-class call#2019-07-1807:24thhellerotherwise I can't think of a quick way to make this work both ways#2019-07-1807:28thhelleror alternatively just the typical cljsjs alias namespace with global variable. like most other packages#2019-07-1807:28thhellerthe problem is just that it is using the react-highlight.js ns which maps directly to the npm package#2019-07-1807:28thhellerand the variable it exports does not match what you get when you require the package directly because of its Highlight.default unwrapping#2019-07-1808:35superstructorThanks for the comprehensive investigation and help @thheller! The issue is clear now. I'll think about the most pragmatic solution.#2019-07-1808:51thheller@superstructor just thought of a much simpler solution#2019-07-1808:52thhellerin re-frame-10x when using the react-highlightjs you could just use (or react-highlights/default react-hightlightjs)#2019-07-1808:52thhellerso shadow-cljs would use the /default but the rest would use the other one#2019-07-1808:53thhellerno need to change other dependencies or so that way#2019-07-1808:53Marcin@thheller I have a problem referencing JS file from JS file from CLJS. Any JS referenced from CLJS works fine, but got different errors when I import another file here. An example#2019-07-1808:54Marcinexport in this scaler looks like this export const scaleImage = () ....#2019-07-1808:55MarcinIt worked the first time the compilation went through. After some changes (and the reload) it stopped working#2019-07-1808:56thhellerhmm dunno. you can try deleting the .shadow-cljs/builds dir and restarting the build#2019-07-1808:56thhellermaybe some bad cache in the conversion code?#2019-07-1808:56thhellerlooks like it should work#2019-07-1809:00Marcinok, trying. Cheers!#2019-07-1809:35Marcinworks! Thank you!#2019-07-2407:54Marcin@thheller it happens every now and then when the hotreload hits after touching (nested) imported js file - then I need to delete builds folder from shadow-cljs and it starts to working again. It’s quite easy to reproduce it: - call JS file from CLJS - call JS file methods from the above JS file (as an import)#2019-07-2407:56Marcinworkaround for me here is to pass callbacks or partially run functions in promises from CLJS, but it doesn’t seem to be a solution#2019-07-2408:07thhellerdo you have an actual reproducible example?#2019-07-1814:36superstructor@thheller Hah thanks 🙂 👍 I also thought to go down this route.#2019-07-1815:42superstructorI released re-frame-10x 0.4.2 that fixes compatibility with shadow-cljs as per above. Thanks @thheller!#2019-07-1818:59mssin the process of formatting a project as a monorepo using modules each with a deps.edn + shadow-cljs.edn. shadow is installed globally via yarn. I moved everything over in a way that I thought was correct but now when running shadow-cljs compile my-app I’m getting an error:
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
when I explicitly add shadow to my deps.edn, this goes away. confused why that might be the case, as it wasn’t listed in my deps.edn pre monorepo migration
#2019-07-1819:28thheller@mss you must add shadow-cljs to your deps.edn as of the latest version#2019-07-1904:58currentoorcan i have node_modules in a different directory than the top level?#2019-07-1904:59currentoori have a project that outputs builds for the browser and node#2019-07-1904:59currentoorand some of the node deps aren’t installable on CI#2019-07-1905:00currentoorideally i’d have different profiles in package.json, but i don’t think that’s possible#2019-07-1907:36jcbHas anyone come across this error before and how to resolve it? Running shadow-cljs... [:app] Compiling ... ------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- nil Thanks!#2019-07-1907:43thheller@currentoor it is possible to set :js-options {:node-modules-dir "some/nested/path"} in your build config#2019-07-1907:44thheller@jcb those are just warnings. not errors. not currently possible to resolve it since its a problem in the transit lib#2019-07-1907:50jcbthanks @thheller, I'm trying to track down why a request to the server that works in dev would fail after uberjar#2019-07-1907:50thhellerit is not that. that causes no problems.#2019-07-1907:51thhellerwhat is the error you see?#2019-07-1907:56jcbthis is in luminus, so I'll take it there after I've been through some things. But essentially - In dev I'm sending a request for an edn file with some frontend config stuff in it. However, after compilation this fails. It not so much the error itself as the disparity between the dev experience (where everything just kind of works!) and the compiled code that is leading me down many rabbit holes.#2019-07-1907:57thhellerwell how does it fail? what do you do with this edn config?#2019-07-1907:58thhellerremember that :advanced compiled builds are much less dynamic and certain dynamic things you can do in dev builds wont work#2019-07-1908:00jcbI just swap it into a key in a state atom so that I can change some bits of the UI#2019-07-1908:00thhellerthat sounds fine#2019-07-1908:00thhellerdoing dynamic JS lookups or so wouldn't be#2019-07-1908:01thhellerbut you still didn't mention what the actual error is#2019-07-1908:03jcbsorry I've been trying to trace it back as I've been working through I've made many new errors. The initial problem was something along the lines of "replace" and "map" on null#2019-07-1908:04jcbso I guess it's something to do with the way the request is returning#2019-07-1908:04thhellerso a null pointer usually indicates that something is null when it shouldn't be#2019-07-1908:05jcbthe structure itself was returning and readable in the chrome console#2019-07-1908:05thhellerthat can happen if you for example access a JS property and the GCC decides to rename the name of that property#2019-07-1908:05thhellerie. enable :compiler-options {:infer-externs :auto} in your build config and check the warnings (if there are any)#2019-07-1908:07jcbI did that and there was a warning about some things from goog.history and goog.events but they seemed unrelated#2019-07-1908:09thhellerthey might be but they might not be#2019-07-1908:09thhellerfeel free to post them here. I can probably tell you#2019-07-1908:09thhelleryou can also try shadow-cljs release your-build --debug to make things a bit easier to debug#2019-07-1908:11jcbthank you! I will post them in a bit. I'm using luminus so should I add that into the uberjar tasks?#2019-07-1908:12lmanolovHi. Has somebody noticed a problem with too many generated JS files in dev mode? I guess I have too many NPM dependencies (like material-ui) but I don't see an easy way to reduce them. Currently, when I try to open the app in dev mode the browser does 1470 requests. I guess the real number is about 2900 including the .map files. The Chrome-based browsers (including Opera and Vivaldi) sometimes display error "net::ERR_INSUFFICIENT_RESOURCES" but most of the time just hang. Currently only Firefox can open the application but unfortunately, some tools like re-frisk don't work. Is there an option to combine the NPM resources in a single JS file in dev mode to reduce the number of requests?#2019-07-1908:17jcbtwo infer warnings - (swap! session assoc :page (match-route (.-token event))))) -------------------------------------------------------^------------------------ Cannot infer target type in expression (. event -token)#2019-07-1908:17jcband (events/listen js/window EventType.KEYDOWN 648 | (fn [e] (reset! press (.-keyCode (.-event_ e)))))) -----------------------------------------------------------^-------------------- Cannot infer target type in expression (. e -event_)#2019-07-1908:28thheller@lubo try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-07-1908:29thheller@jcb yeah that warning can be ignored. you can add (fn [^goog e] ...) to make that warning to away#2019-07-1908:30thhellernot sure what event_ is though. doesn't look like something you should be using directly#2019-07-1908:31thhellerso that may be the actual problem#2019-07-1908:31thhelleryou can try (fn [^js e] ...) which will cause externs for event_ to be added. maybe that fixes it#2019-07-1908:33jcbthank you I'll try it - it could be a problem but the request problem seem to be more about how formats are being en/decoded#2019-07-1908:34thhellerunlikely given that most apps use either EDN or transit or both and usually don't have any issues#2019-07-1908:35thhellerJSON is known to have some edge cases when using js->clj but EDN/transit don't have those issues#2019-07-1908:36jcbok, thanks for your time on this, I'll keep fumbling through 😅#2019-07-1908:42lmanolov@thheller Thank you very much! The :loader-mode :eval option reduced the number of requests from 1470 to 30 and the Chrome-based browsers can open the application now#2019-07-1911:47andrewzhurovGreetings, fellow clojurians! I seem to face an npm dependency issue, trying to add: https://github.com/funcool/cuerdasp into a deps.edn + shadow-cljs project I was unable to reproduce the same issue in a clean project, my dilettante guess would be that issue is caused by npm dependency clash package.json
"version": "0.0.1",
"private": true,
"devDependencies": {},
"dependencies": {
    "bootstrap": "^4.3.1",
    "core-js": "^3.1.4",
    "create-react-class": "^15.6.3",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-transition-group": "^4.2.1",
    "sass": "^1.18.0",
    "xregexp": "^4.2.4",
    "yarn": "^1.13.0"
    }
core-js is being required by xregexp and also create-react-class I don't have an idea of how it can be resolved (being new with using npm deps in cljs and shadow-cljs), any hints?
#2019-07-1911:51thheller@brownmoose3q check which version of core-js xregexp depends on via node_modules/xregexp/package.json. then make sure to install that version.#2019-07-1911:51thhellermight be 2.x not 3.x#2019-07-1913:43andrewzhurov
npm i --save 
did the trick! ta!
#2019-07-1917:06currentoor@thheller I noticed the user manual doesn’t mention :js-options {:node-modules-dir "some/nested/path"} anywhere, would you like a PR that adds a tiny note about it?#2019-07-1917:09thhellersure why not#2019-07-1917:09Lucas SennaHi! I’m facing the following issue when running tests with shadow-clj configured with :ci {:target :karma}:
{
    "message": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n    at ci.js:229378:1",
    "str": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n    at ci.js:229378:1"
  }
The line that throws the error the is a transpilation of a js class extension:
$jscomp.inherits(ShuffleLoader$$module$nubank$shuffle$common$ui$shuffle_loader, module$node_modules$react$index.PureComponent);
Shadow-clj compiles and runs the app perfectly, the error only appears when running tests.
#2019-07-1917:10thhellerhmm might be that the polyfills aren't inserted correctly for the karma build#2019-07-1917:11thheller$jscomp is the var the GCC uses for polyfills#2019-07-1917:11thhelleryou probably should set :compiler-options {:output-feature-set :es6} so it doesn't transpile classes#2019-07-1917:12thhellerdon't really need to assuming you are running the tests in a somewhat recent platform#2019-07-1917:17Lucas SennaYep, our target is only a single evergreen browser. Changing the :compiler-options did the trick. Thank you very much!#2019-07-1917:22thhellerFWIW if you use any newer features in the JS like async/await you can bump that up to :es7 or :es8#2019-07-1919:07currentoorhas anyone seen this error?
{:clojure.main/message
 "Execution error at shadow.build/eval16057$loading (build.clj:1).\nUnable to resolve spec: :clojure.core.specs.alpha/args+body\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.Exception,
  :clojure.error/line 1,
  :clojure.error/cause
  "Unable to resolve spec: :clojure.core.specs.alpha/args+body",
#2019-07-1919:08currentoorshadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn cli version: 2.4.5 node: v10.16.0#2019-07-1919:10currentoorah it’s because my node_modules are in a subdirectory now…#2019-07-1919:14thhellerthat doesn't look related to node_modules?#2019-07-1919:20currentoorright i’m launching the server with npx shadow-cljs server#2019-07-1919:21currentoori agree it doesn’t look node_modules related, but calling npx ... in the same directory as my node_modules (now i have two in two separate dirs) launches the server#2019-07-1919:22thhelleryou should launch it in the directory with your shadow-cljs.edn#2019-07-1919:22thhellerit'll do that anyways#2019-07-1919:22currentoorbut my shadow-cljs.edn and deps.edn are top level, so maybe i need a top level node_modules that just has shadow-cljs in it?#2019-07-1919:23thhelleryes#2019-07-1919:23thhellerwell not really but that controls which version you get#2019-07-1919:23thheller(of the npm package)#2019-07-1919:24currentoorgood grief, i find it baffling that JS with all it’s mindshare doesn’t have the notion of profiles in their dependency management#2019-07-1919:24thhellerI don't see how this has anything to do with JS#2019-07-1919:25thhellerits purely a clojure startup problem#2019-07-1919:25thhelleronly guess I have is that you are using an older clojure version that doesn't have those specs?#2019-07-1919:25thhellerbut that would be odd given that its a new style error message#2019-07-1919:25thhellertry deleting your .cpcache dir so deps.edn does its thing again#2019-07-1919:26thhellermaybe that got messed up somehow#2019-07-1919:26currentoorthis all would be a non-issue if in package.json i could just specify two profiles and do npm install --profile browser#2019-07-1919:26currentoorin one context and npm install --profile node in another context#2019-07-1919:26thhellernot sure what you mean. this is a CLJ exception. CLJ never touches any JS whatsoever#2019-07-1919:27thhellerso whatever is happening is has nothing to do with npm/JS#2019-07-1919:27currentoori’m sorry i’m not being very articulate#2019-07-1919:27currentooryou’ve already been immensely helpful, i should stop complaining 😅#2019-07-1919:27currentoorabout JS#2019-07-1919:28thhellerJS is a mess. I totally agree with that but can't blame it for everything 😉#2019-07-1919:29currentoorbut just in case you know, is there a way specify two different sets of dependencies in one package.json?#2019-07-1919:30currentoorlike how in deps i can say these deps are for only for a particular build#2019-07-1919:30currentoorand the other deps are for all builds#2019-07-1919:31thhellerwell people typically use dedicated directories with dedicated package.json files#2019-07-1919:32currentoorright and i’m having trouble getting that approach to work with my shadow-cljs setup#2019-07-1919:33thhelleryes. I'm doing that in several places#2019-07-1919:33currentoorok so it is possible#2019-07-1919:33thhellerBUT it is absolutely impossible that :node-modules-dir prevents your process from starting#2019-07-1919:33thhellerthat is why I want to get JS out of this discussion#2019-07-1919:33thhellerfocus on what you are doing exactly#2019-07-1919:33currentoorright i understand#2019-07-1919:34thhelleryou have a shadow-cljs.edn presumably with a :deps and deps.edn#2019-07-1919:34currentoorhmm i wonder if omitting npx might work#2019-07-1919:34currentooryes#2019-07-1919:34thhellerso then please run shadow-cljs clj-repl in that directory#2019-07-1919:34thhellerwith or without npx shouldn't really matter#2019-07-1919:35currentoortrying#2019-07-1919:35currentoornope i get the same error#2019-07-1919:36thhellerplease paste the FULL error#2019-07-1919:36currentoori haven’t added :node-modules-dir just have package.json and node_modules in a subdirectory#2019-07-1919:37currentoorsorry that was a little messed up#2019-07-1919:37currentoori’ll make a gist#2019-07-1919:37currentoor#2019-07-1919:38currentoordo you need the rest of the stacktrace?#2019-07-1919:38thhellerwhat do you have set for :deps in shadow-cljs.edn?#2019-07-1919:39currentoor:deps {:aliases [:test :cljs :dev]}#2019-07-1919:39thhellerso then run clj -A:test:cljs:dev please#2019-07-1919:39currentoorrunning#2019-07-1919:40currentoorthat was able to spin a repl#2019-07-1919:40thhellerand then (require 'shadow.cljs.devtools.cljs-specs)#2019-07-1919:40currentoor
user=> (require 'shadow.cljs.devtools.cljs-specs)
nil
#2019-07-1919:41thhellerdo you have shadow-cljs in your deps.edn?#2019-07-1919:41thhellerif so which version?#2019-07-1919:42currentoorunder the alias :dev i have it thheller/shadow-cljs {:mvn/version "2.8.21"}#2019-07-1919:42thhellerso far everything looks good#2019-07-1919:42thhellerthe rest of the stacktrace from above maybe?#2019-07-1919:43currentoor#2019-07-1919:45thhellerwhich clojure version is that?#2019-07-1919:46currentoor1.10.1-beta2#2019-07-1919:46currentoori tried deleting both .cpcache and .shadow-cljs no luck#2019-07-1919:47thhellerrun the previous clj command again please#2019-07-1919:47thhellerand check ( "clojure/core/specs/alpha.clj")#2019-07-1919:47currentoorsure#2019-07-1919:48currentoor
~/s/ucv (feature/barcode-scanner↑2|✔) $ clj -A:test:cljs:dev
Clojure 1.10.1-beta2
user=> ( "clojure/core/specs/alpha.clj")
#object[java.net.URL 0x5efb3259 "jar:file:/Users/currentoor/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar!/clojure/core/specs/alpha.clj"]
#2019-07-1919:49thhellerhmm yeah I get that same version#2019-07-1921:50currentooris there a reason why :js-options {:node-modules-dir "..."} would work for a :browser target but not :node-script#2019-07-1922:13currentoorwell i see you’re using it in shadow-cljs itself, so it should work#2019-07-1922:13currentoorperhaps i need to :keep-native-requires#2019-07-1923:19dfcarpenterI'm using shadow-cljs and VSCode/Calva and trying to reload a file with several functions I am making changes to. (require 'my.ns :reload-all) but this doesn't seem to work. Is this an effect of the caching? Do I need to turn this off completely when developing?#2019-07-1923:25pez@dfcarpenter , there is something going on with loading files with Calva and shadow-cljs. I'm struggling to figure it out. Meanwhile, try selecting the whole file and then evaluate the selection.#2019-07-2007:51thheller@currentoor it doesn't make sense for :node-script#2019-07-2007:52thheller:node-script is just going to use direct js require calls and let node do the resolving. so it'll automatically "adapt" to the node_modules dir whereever you execute the script#2019-07-2010:59deplectgood day everybody, starting a fresh shadow-cljs project and looking for some quality templates to boot from. Ideally I would like it to be re-frame and circle-ci ready. Searching online I found the examples and a lein template of last year shadow-reframe. Any help greatly appreciated 🙂#2019-07-2011:01sogaiu@deplect would also be interested in what you turn up 🙂 have you tried a filename:shadow-cljs.edn search on github already? e.g. something like: https://github.com/search?q=filename%3Ashadow-cljs.edn+re-frame#2019-07-2011:10deplecthai @sogaiu no i did not, going to do this right now 🙂#2019-07-2011:36deplectafter some searching, I started extracting a skeleton out of an previous project#2019-07-2013:05deplectwhen I want shadow-cljs to do nothing more than install the deps needed for itself and the shadow-cljs.edn file, how would I do this?#2019-07-2014:29lilactownshadow-cljs typically is installed via npm#2019-07-2014:30lilactownfirst make sure you have a package.json (`npm init` will generate one) then npm i -D shadow-cljs#2019-07-2121:31dfcarpenterDoes anyone use shadow with the Atom editor Chlorine package? I can't seem to either load files or get much of anything to happen in the editor repl.#2019-07-2122:11mikebFunny you should ask @dfcarpenter I am looking to do exactly that as well. Heck I'm not even that far along, still trying to get a hello world running for the browser.#2019-07-2122:26tianshuI think one thing should be noticed on the document is that how to rebuild when build failed without quiting the clojure repl.#2019-07-2122:45SocksI just setup a small barebones app. i'm running npx shadow-cljs watch <build-id> and everything is working as expected, except, i have to manual refresh the browser to see dom changes. Is there a way to have it refresh when i make changes?#2019-07-2122:50tianshu@brewmasterv do you have a config at [:builds your-build :devtools :after-load]#2019-07-2122:51tianshuthat should be a function which will be called when compiling finished after you make a change.#2019-07-2123:01Socksthanks!#2019-07-2204:10superstructor@dfcarpenter try Visual Studio Code with Calva unless your really keen on Atom. Atom appears to be dieing a slow death these days.#2019-07-2209:29romainI have setting variables depending of the environment (dev, test, prod), how can I store and import them?#2019-07-2209:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2019-07-2209:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2019-07-2209:33romainI just saw these ^^' So I can make 3 files (one for each environment) and use config-merge (preferred over shadow-env) when building the project?#2019-07-2209:34thheller3 files?#2019-07-2209:34romainI wanted to store the variables in a EDN file for example#2019-07-2209:34thhellerwell you probably should load that configuration file in your app then#2019-07-2209:34thhellerand not make it part of your build?#2019-07-2209:36romainI have to differentiate the environment, for example URL of my API is different if I'm in dev env or prod env#2019-07-2209:36pez@dfcarpenter also check in #chlorine for what you can expect to work. (If you haven't, of course)#2019-07-2318:25dfcarpenterThanks. I did realize where I was going wrong.#2019-07-2211:13tianshuwhere the SHADOW_ENV is defined.#2019-07-2212:28thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/config.clj#L104#2019-07-2213:05tianshuthanks!#2019-07-2222:01bedersanyone else having trouble using the latest #fulcro with shadow-cljs?#2019-07-2222:01bedersI'm getting this:
Execution error (IllegalStateException) at com.google.common.base.Preconditions/checkState (Preconditions.java:823).
Externs must contain builtin for env BROWSER: whatwg_console.js
#2019-07-2222:02thhellerlooks like maybe a dependency conflict?#2019-07-2222:02bedersmy dependencies (:lein true) are:
[
   [thheller/shadow-cljs "2.8.41"]
   [binaryage/devtools "0.9.7"]
   [fulcrologic/fulcro "2.8.4"]
   ]
#2019-07-2222:02thhellercheck lein deps :tree#2019-07-2222:03bedersouch. a lot indeed#2019-07-2222:03bedersthanks for the hint!#2019-07-2222:03bedersalso: love shadow-cljs!#2019-07-2222:04bedersI really don't need fulcro, but I wanted to use pathom which has a visualizer which uses fulcro. Oh well.#2019-07-2222:22currentoormy code is able to compile fine the first time but when i save a file (whitespace change) i get this uncaught error in the JS console
#error {:message 
"The map literal star … ven number of forms."
, :data {:type :reader-exception, :ex-kind :reader-error}}
#2019-07-2223:09currentoorfigured it out#2019-07-2223:09currentoorthis project had this poorly formatted code#2019-07-2223:09currentoor
(let [color (.hcl js/d3 color)
      color (.brighter color .9)]
  (.toString color))
#2019-07-2223:09currentoorthe complier emitted a warning but still compiled#2019-07-2223:09currentoorhowever the edn message shadow-cljs was pushing to the client was malformed#2019-07-2308:36thhellerhmm not sure how that would ever happen. do you have something reproducible for this?#2019-07-2222:22currentoorthe message is The map literal starting with :prefix contains 5 form(s). Map literals must contain an even number of forms.#2019-07-2222:23currentoorthe stacktrace is
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:168
(anonymous)	                                  @	browser.cljs:349
#2019-07-2222:24currentoori see the shadow-cljs websocket is connected#2019-07-2222:28currentoori see the offending message from the websocket, it’s huge and it does indeed have a malformed map#2019-07-2222:28currentoorbut AFAIK shadow-cljs server constructs this message#2019-07-2222:29currentoorare there certain deps that are incompatible with shadow-cljs?#2019-07-2222:34romain@thheller --config-merge is used to override vars in shadow-cljs.edn but you cannot use it to define custom vars? I would like to do something like shadow-cljs build app --env=dev, so I have to manage it inside my app and not with shadow-cljs?#2019-07-2300:36tianshuwhat situation may cause this, when calling a function in repl it's said to be undefined, but it actually works. SOLVED, solved this by hard reload browser.#2019-07-2304:35currentooranyone figure out how to use moment.js with shadow-cljs?#2019-07-2308:37thheller@romain you probably want to use https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2019-07-2308:39thheller@currentoor what is there to figure out?#2019-07-2308:39romain@thheller oh yes! it seems pretty cool, thanks 😄#2019-07-2316:24currentoor@thheller
["moment" :default moment]
doesn’t work but it turns out they intentionally have the ES6 importable code in
["moment/src/moment" :default moment]
#2019-07-2316:24currentoorwhich works as expected#2019-07-2320:07thheller@currentoor ["moment" :as m] probably works too. :default is kinda dependent on how the package is packaged#2019-07-2320:07thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-07-2320:16wilkerlucio@currentoor I suggest you check https://date-fns.org/ too, its a more modern and functional friendly time API#2019-07-2320:23currentoor@U066U8JQJ this is a legacy project that i’m upgrading to shadow-cljs and newer fulcro#2019-07-2320:23currentoorpersonally i like this#2019-07-2320:23currentoorhttps://github.com/juxt/tick#2019-07-2320:23currentoorif i have clj on the backend, then i can write my logic in cljc#2019-07-2320:18tianshu@thheller I have a cljs file whenever I save the file it will recompile but only generating the code of ns form in javascript#2019-07-2320:19tianshulooks very wierd#2019-07-2320:21tianshuThis is the code generated, but actually there should be a very simple hello function.
goog.provide('xycp.frontend.event.http');
goog.require('cljs.core');
goog.require('cljs_http.client');
goog.require('cljs.core.async');
goog.require('re_frame.core');

//# sourceMappingURL=xycp.frontend.event.http.js.map
#2019-07-2320:22thheller@doglooksgood how is it defined?#2019-07-2320:23tianshuwhat define means? you mean where is the file?#2019-07-2320:24thhellerwhat is the actual CLJS code ?#2019-07-2320:25tianshu
(ns xycp.frontend.event.http
  (:require [cljs-http.client :as http]
            [cljs.core.async :refer [<! go]]
            [re-frame.core :as re-frame :refer [reg-fx]]))

(defn hello [] 1)
this is the code
#2019-07-2320:25tianshuand I think the file path is correct, matching the namespace.#2019-07-2320:25tianshueven I change the requires, the generated file will totally not change#2019-07-2320:25tianshubut the modify time will be updated#2019-07-2320:26thhellerdunno. hard to say. it should definitely contain that function#2019-07-2320:27thhellermaybe you have some weird special character in the file? some unicode characters don't show up but can cause all kinds of weird stuff to happen sometimes#2019-07-2320:27tianshuIf I delete this file, it will not be regenerated#2019-07-2320:30tianshu@thheller no unicode I think, just tried delete very thing in this file#2019-07-2320:30tianshuhow can I investigate deeper?#2019-07-2320:30thhellernot a clue. did you try a proper restart?#2019-07-2320:31tianshulet me have a try. It definitely have some cache stuf#2019-07-2320:31tianshuit regenerate the js#2019-07-2320:31tianshubut still with old content#2019-07-2320:35tianshuRestart will generate a proper content. @thheller#2019-07-2320:36tianshuI think I found something.#2019-07-2320:43thhellerFWIW there are known race conditions and other problems if you combine the REPL with the regular live-reload#2019-07-2320:43thhellerso using both can definitely cause issues#2019-07-2320:43tianshuemm, looks like once the graph is created, it will not change#2019-07-2320:44thhellerif you create it via the REPL first that is possible yes
#2019-07-2320:44tianshuIf add :dev/always in an non-toplevel namespace, will cause the similar issue#2019-07-2320:44thhellerbecause it will not have a file associated with it then#2019-07-2320:45tianshuno need for a fix, but like me, I don't know this and run into this kind of issue twice today...#2019-07-2320:45thhellerwell having a reproducible example would certainly help#2019-07-2320:46thhellerI'm only guessing here. I don't know about any actual reproducible issue. otherwise I'd fix that.#2019-07-2320:47tianshushould evaluating a ns form being supported?#2019-07-2320:47thhellersure#2019-07-2320:47tianshubasically it's not necessary, but editors allow this.#2019-07-2320:49tianshuanyway I can continue my work it's good news for me.#2019-07-2408:08sogaiu@thheller is ^js a shadow-cljs specific feature?#2019-07-2408:13thhellerno#2019-07-2408:14thhellerit works in plain CLJS in pretty much the same way#2019-07-2408:15sogaiuthanks!#2019-07-2408:18sogaiu@thheller i looked for annotation docs and found some, but didn't find anything specifically mentioning just ^js -- do you happen to know of any?#2019-07-2408:18thhellerhttps://clojurescript.org/guides/externs#externs-inference#2019-07-2408:19thhellerthe guide tells you to use "typed" annotations like ^js/Foo.Bar but I decided to skip those in shadow-cljs#2019-07-2408:19thhelleryou can still use them they just won't be used for anything specific#2019-07-2408:19thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html#2019-07-2408:25sogaiuso, if i write ^js/something it will be treated the same as ^js?#2019-07-2408:26sogaiu> By using the ^js tag metadata we are just telling the compiler that this is a native JS value and we are going to need externs for it. In shadow-cljs the /Foo.Bar type info is optional. You can still use it if you like but shadow-cljs won’t bother you if you don’t.#2019-07-2408:50thhelleryes#2019-07-2413:14heyarneWhat is the recommended workflow for developing node scripts? I'm using emacs w/ CIDER and I find it a bit clunky… I have to start the cljs repl myself and it crashes a lot (when requiring something that doesn't exist for example); my experience in the browser was waaaay smoother#2019-07-2413:30thhellercan't comment on the cider parts since I don't use emacs#2019-07-2413:30thhellerfor regular shadow-cljs I would just use shadow-cljs node-repl and go#2019-07-2413:31thhellera regular :node-script build for the actual script then#2019-07-2414:12heyarneHm… it always shows the cljs-repl as pending if I do that, even though I can run code in the repl itself#2019-07-2414:12heyarneWeird#2019-07-2414:12heyarneThat seems to be a CIDER issue, thanks!#2019-07-2417:27Karol WójcikWhat is correct way to import file ./src/infrastructure/config.js from another (to be specific) ./src/api/client/schemas/login.js file. From the login.js I tried to import the configuration via:
const config = require('../../../infrastructure/config.js')
But I'm receiving the undefined
#2019-07-2417:29thhellerthats not CLJS code? need more context 😛#2019-07-2417:35Karol WójcikWell it's still CLJS code, because it's then required by the api/client/core.cljs via ["./schemas/login" :as login] Project configuration:
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [[mount "0.1.16"]
  [funcool/promesa "2.0.1"]]

 :builds {:api         {:target    :node-script
                        :output-to "target/api.js"
                        :ns-regexp "^api.*"
                        :main      api.server/main!
                        :devtools  {:after-load api.server/reload!}}
          :worker      {:target    :node-script
                        :output-to "target/worker.js"
                        :ns-regexp "^worker.*$"
                        :main      worker.setup/main!
                        :devtools  {:after-load worker.setup/reload!}}
          :worker-test {:target    :node-test
                        :output-to "target/worker-test.js"
                        :autotest true
                        :ns-regexp "^test.worker.*"}}}
#2019-07-2417:36Karol WójcikTree of the project#2019-07-2417:37thhellerand what is in config.js?#2019-07-2417:38Karol Wójcik
config.js

const providers = {
  someProvider: {
    scope: [{
      name: "shopping-lists"
    }]
  }
}

const allowedProviders = Object.keys(providers)

export const configuration = {
  ...providers,
  allowedProviders
}
#2019-07-2417:38thhellertry sticking to one concept#2019-07-2417:38thhellerdon't mix export with require#2019-07-2417:38thhellereither use only import/export or require/module.exports#2019-07-2417:38thhellerdo not mix#2019-07-2417:49Karol Wójcik@thheller I've just changed require to export import Here is how ./src/api/client/schemas/login.js looks like
import joi from '@hapi/joi'
import { configuration } from '../../../infrastructure/config.js'

console.log(configuration)
Error message: TypeError: Cannot read property 'configuration' of null
#2019-07-2418:16Karol Wójcik@thheller Is it even possible to import one .js file from another .js file and then import it in cljs file? Or should I use webpack to join all js files together?#2019-07-2418:17thhelleryes thats possible and should be working fine#2019-07-2418:17thhellerBUT#2019-07-2418:17thhellerit is somewhat unreliable in a node environment#2019-07-2418:17thhellerI'm not sure how to make it more reliable#2019-07-2418:18thhellergiven that you are targetting node however you could just import the .js files directly and not have shadow-cljs process them in any way#2019-07-2418:20Karol WójcikThat's true. I will use nodejs.require then 🙂 Thanks for pointing me that 🙂#2019-07-2418:22thhellerit might be more reliable if you actually just use require and module.exports#2019-07-2418:22thhellerso exports.configuration = ... instead of the export const configuration #2019-07-2418:23thhellerclosure does very strict rewriting of ES6 type code that doesn't play well with hot-reload style dev builds currently#2019-07-2417:52Chaseany of you folks happen to be (neo)vim & fireplace users? I'm trying to follow a tutorial that uses shadow-cljs and can no longer get my repl connected. I included cider/cider-nrepl and cider/piggieback as dependencies and get the following warnings when starting the repl: https://pastebin.com/LPrmeKmz#2019-07-2417:53ChaseCan I just ignore those? When trying to actually connect vim to the running repl I get this warning and further stacktrace:
[2019-07-24 12:37:11 - SEVERE] Unhandled REPL handler exception processing message {:id ae40bfe8-e180-4ad0-33de-ceb5d15054f3, :op classpath}
java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'nrepl.transport/Transport found for class: clojure.tools.nrepl.transport.FnTransport
#2019-07-2418:16thhellerlooks like you might be using an outdated nrepl version?#2019-07-2418:18tianshu@karol.wojcik sorry for interrupting you, I see there's a crypt.cljs in your screenshot. I'm searching for a library for doing AES in cljs, any sugeestions?#2019-07-2418:19thheller@doglooksgood https://google.github.io/closure-library/api/goog.crypt.Aes.html#2019-07-2418:21tianshuawesome#2019-07-2418:22Chasei'm using "0.21.1" which appears to be the latest. hmmm#2019-07-2418:24thheller@chase-lambert no they changed the artifact id#2019-07-2418:25thhellerthats the newer one https://clojars.org/nrepl/versions/0.6.0#2019-07-2418:28Chaseoh.my.god. Thank you! Wow. The folks over on the vim channel are going to kill me.#2019-07-2419:12tianshu@thheller Looks like I need some features like InitVector that goog not support. I found a library called "crypto-js", but looks like there's something not correct in cljs.#2019-07-2419:19tianshuhttps://github.com/brix/crypto-js this will not work, the error is Cannot read property 'charAt' of undefined
(ns foo.bar
  (:require ["crypto-js" :as CryptoJS]))

((.. CryptoJS -enc -Base64 -parse)
 "aGVsbG8n")
This is the JS version
var CryptoJS = require('crypto-js');

var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
#2019-07-2419:24tianshu@thheller Am I do the correct translating? If it is, I think there's something wrong with shadow-cljs.#2019-07-2419:25tianshualso there's a html version, to ensure it can be run on browser environment.
<!DOCTYPE html>
<html>
  <head></head>
  <body>

    <script src="node_modules/crypto-js/crypto-js.js"></script>
    <script>
var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
    </script>
  </body>
</html>
#2019-07-2419:30tianshuI submit an issue for this.#2019-07-2419:45Karol Wójcik@doglooksgood It's not problem with shadow. Try this:
(.. crypto/enc -Base64 (parse "hello"))
#2019-07-2419:46tianshu@karol.wojcik so what's going on here, very strange#2019-07-2419:47tianshuI can even confirm CryptoJS.enc.Base64.parse and (.. CryptoJS -enc -Base64 -parse) are totally equal. tried in the console and repl.#2019-07-2419:48tianshuBut calling in console with JavaScript will work, calling in repl with ClojureScript will fail, they are in one environment.#2019-07-2419:51Karol WójcikDid you try my example?#2019-07-2419:52tianshusorry, haven't notice that. where is the example?#2019-07-2419:52Karol Wójcik
(.. crypto/enc -Base64 (parse "hello"))
#2019-07-2419:53tianshuohh, it works#2019-07-2419:54tianshucan you have a explain?#2019-07-2419:55Karol WójcikI'm not 100% sure, but as I understand the property access does not makes the js function invokable.#2019-07-2419:56Chasehey @thheller, what's the latest with piggieback and shadow-cljs these days? Now that I can connect with clojure I'm having problems getting the cljs repl connected. I used to just put :Piggieback :app and it worked. Shadow-cljs says it's watching build :app I have the cider/piggieback dependency loaded in.#2019-07-2419:57tianshuI think in this case, sometimes invokable. there're some functions works like CryptoJS.enc.Utf8.parse#2019-07-2420:13tianshuhttps://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html @karol.wojcik It's not invokable, it's missing the context for this. this post have a great explain.#2019-07-2420:17elaroussHi, i'm using shadow-cljs, the live reloading works great, except when i create a new namespace inside a package (folder) and require it somewhere, where it says : The required namespace X is not available, it was required by Y, so i need to kill the shadow-cljs server and restart it, is there a better way to do this? i've tried shadow/stop-worker and then shadow/watch again but no luck#2019-07-2420:22neupshI have the same problem as @ichigo as well. I have 2.8.40#2019-07-2420:22tianshu@ichigo did you eval the namespace before save the new created file?#2019-07-2420:28neupsh@doglooksgood nice catch. I think that is the issue. I have been used to intellij automatically saving files and sometimes don't save manually. I just tried saving the file manually before using it and it worked. I will keep an eye on it to see if not saving was the cause. @ichigo let us know if that fixed it for you or not#2019-07-2420:31elaroussthanks @doglooksgood, @neupsh i'll try that 👍#2019-07-2420:37tianshuI'm using Emacs, get an different error. But evaluating the namespace before you save that file(let shadow-cljs compile it) will cause problem.#2019-07-2420:50elaroussso i've tried 2 things: 1. create a package with a namespace, define a function inside it, require it in another namespace, this didn't work, even after evaluating the namespace after. 2. same as before, but after creating the function i evaluated the namespace and then require it, this works 🎉#2019-07-2420:29isakHow are people handling watching other assets like CSS during development? Do you just start multiple processes, or is it possible to add this to the normal shadow-cljs commands with the hooks? (E.g., start webpack as the build is configured)#2019-07-2421:09lilactownI use css-in-js on my current app but I think the other option is to run node-sass or whatever as a separate process#2019-07-2421:28neupshThere was a way to specify shadow-cljs to build only one js file instead of injecting a lot of <script> tags for node_modules in the html during development. Anyone remember how to do that?#2019-07-2421:29thheller@neupsh :devtools {:loader-mode :eval} in the build config#2019-07-2421:29neupsh@thheller thank you 🙂#2019-07-2421:43isak@lilactown hm, how are you making css-in-js work with shadow?#2019-07-2421:44lilactownby css-in-js I mean something like emotion#2019-07-2421:44isakah ok, interesting#2019-07-2501:52Nolandoes anyone have any experience exporting npm packages that work in the browser as well?#2019-07-2501:57Nolani apologize if this question is misguided. the manual is a painstaking cliff hanger (https://shadow-cljs.github.io/docs/UsersGuide.html#_creating_code_npm_code_packages). i guess im primarily curious whether a webpack workflow would appropriately handle making a :node-library output browser compatible#2019-07-2502:30lilactownYes it should#2019-07-2502:31lilactownRather, node-library should output a webpack-compatible bundle#2019-07-2502:43Nolanright, getting more familiar with it. seems like its working well. using this tool has never stopped being positively delightful#2019-07-2509:12tianshu@isak I'm trying to write style in cljs, with runtime insertion by library like cljss or herb. not know how will it work in the end yet.#2019-07-2513:21isakinteresting :+1::skin-tone-2:#2019-07-2511:12Karol WójcikDoes shadow-cljs fully supports macro system?
(ns infrastructure.util
  (:require
   [clojure.tools.macro :as macro]
   [promesa.core :as p]))

(defmacro defn-handler
  [name & attrs]
  (let [[aname [fn-args & fn-body]] (macro/name-with-attributes name attrs)
        args-count (count fn-args)
        afn `(fn ~fn-args 
I've just created macro which is used to define the express.js handlers.
(defn-handler get-login-status
  [req res] 
  (println req res))
For some reason code works perfectly fine but the shadow-cljs outputs a warning:
#2019-07-2511:28tianshuI've seen a lot of times like something is undeclared but actually it exists. usually cased by how the namespace is created. is it created by file require or by repl evaluation.#2019-07-2511:30Karol Wójcik@doglooksgood Ok found one bug. The last warning about undeclared is fixed. So there is one left about "wrong number of args passed".#2019-07-2511:35tianshutry a macro expand?#2019-07-2511:49Karol WójcikOk I see why 😛#2019-07-2511:49Karol WójcikThanks @doglooksgood#2019-07-2511:49tianshu😶#2019-07-2511:49staskIs there olical/depot or lein-ancient equivalent for shadow-cljs managed projects?#2019-07-2511:50tianshuyou can use deps.edn or leiningen to manage dependencies, is easy for shadow-cljs to use them. so all the tools are available now.#2019-07-2511:51stask@doglooksgood yeah, was hoping there is something shadow-cljs specific, thanks#2019-07-2511:59thheller@karol.wojcik that is not how macros work in CLJS. they need to be declared in a CLJ namespace (.clj or .cljc)#2019-07-2513:15Vincent CantinHi, does shadow-cljs supports dynamic require() in the JS code? I have problem with this JS code that does not work well (not sure yet how):
const required = require(`../vectors/${name}`);
    vector = required.default || required;
#2019-07-2513:15Vincent CantinIt works fine when used from a JS project.#2019-07-2513:23thheller@vincent.cantin no that is not supported. you can do it when building for node by just using js/require directly but it is not supported otherwise#2019-07-2513:24Vincent Cantinthank you#2019-07-2516:00lilactownI’ve been thinking about a way to include and instrument specs that wouldn’t have production runtime cost#2019-07-2516:02lilactownif each ns my-project.thing had a corresponding my-project.thing-spec, we could watch for the creation of those files and add their require to a ns that was included via a preloads-like method at dev-time#2019-07-2516:06lilactownI’m thinking of building this as a standalone tool but could be nice as a shadow-cljs feature too#2019-07-2516:08thhelleryou could build it as a simple shadow-cljs build hook#2019-07-2516:15lilactownhmm interesting. does the build state have information about files on the classpath that aren’t included in the dependency graph?#2019-07-2518:22wilkerlucio@lilactown had you tried #ghostwheel? it has a stub thing that can pretty elide all specs and fdefs in prod, both for Clj and CLJS#2019-07-2518:22wilkerlucio(the spec part is coming on the next release, but the alpha of it works fine so far)#2019-07-2518:37lilactownI haven’t#2019-07-2518:37lilactowndoes it also elide clojure.spec itself?#2019-07-2518:38lilactownatm I see cljs.spec.alpha + cljs.spec.gen.alpha + cljs.spec.test.alpha taking a combined ~100kb#2019-07-2518:39lilactown(ungzipped)#2019-07-2518:44Chaseyesterday I was advised to switch my dependency from cider/cider-nrepl "0.21.0" to nrepl "0.6.0" which worked in letting me hook vim into the running nrepl. But I now don't have access to cider and all it gives me, including functionality from other plugins that require cider. The folks at #cider tell me they are very different dependencies but I can't get both the nrepl and the cider-nrepl dependencies in this shadow-cljs to work together. Any advice on how to get Cider working right (outside of emacs, I'm using vim)?#2019-07-2519:30thheller@chase-lambert nrepl and cider-nrepl are 2 different things so you need both#2019-07-2519:30thhellerjust need to match the proper versions#2019-07-2519:43thheller@lilactown you can brute force remove all of spec with this https://shadow-cljs.github.io/docs/UsersGuide.html#_code_stripping#2019-07-2519:43thhellerbut that'll break a bunch of stuff is something actually needs to use spec at runtime#2019-07-2519:44thhellerotherwise you can always include "extra" stuff during dev via :preloads#2019-07-2520:00thhellerI kinda like your idea of automatically include *.thing-spec namespaces for dev builds but instrumentation is tricky enough. automating it entirely and getting that right reliably might be tricky#2019-07-2521:20lilactown😁 yeah. I was thinking of having it enabled via a config flag like:
:auto-spec true
;; or
:auto-spec {:only #{app.foo-spec app.bar-spec}}
;; or
:auto-spec {:except #{app.baz-spec}}

;; additional
:auto-spec {:include #{app.specs}}
#2019-07-2521:22lilactownmaybe have a parameter for controlling whether it included libs or not too#2019-07-2521:22lilactowndepending on how it actually shakes out in practice#2019-07-2600:21Nolanin a release for the :browser target, has anyone experienced local paths appearing in the build artifact? im trying to figure out where that might be leaking in#2019-07-2600:22Nolan_where:"/Some/local/path" is in the shadow provide exports#2019-07-2603:23caleb.macdonaldblackI've never uploaded a package to clojars before. I'm looking to wrap an npm library and publish that on clojars. Could anyone help me understand the build and publish process or point me somewhere I can learn more about it?#2019-07-2607:31thheller@nolan that is probably something doing a require("package.json"). some js packages do that#2019-07-2607:34Nolanconfirmed that this is whats happening. not a problem was just curious where that might be coming from. thanks a million as always @thheller#2019-07-2607:35thhellerfeel free to open an issue about that. the fields added by npm/yarn should probably be removed so they don't pollute the build#2019-07-2607:38Nolanill open one to keep it on the radar and easy to track. its not a particularly harmful thing but seems extraneous to the artifact and worth being aware of#2019-07-2607:39thhelleryeah I want to look into what webpack does for this case#2019-07-2609:49romainHm... I just tested the template (shadow-cljs + reagent) by @jacek.schae https://github.com/jacekschae/shadow-reagent It works in watch mode, but when I do compile or release, index.html is throwning this error TypeError: app.core is undefined whereas file exists and is set in shadow-cljs.edn
:modules
        {:main
         {:entries [app.core]}}
#2019-07-2609:51thhellerlook at the console and make sure you are not getting a 404 for the JS?#2019-07-2609:52thheller(in case you open index.html directly of the filesystem you need to change the path)#2019-07-2609:52thhellerit assumes you are using a webserver#2019-07-2610:11romainYes I wanted to open it directly. I just had to change paths in index.html, sorry for the noise 😉#2019-07-2619:37tianshuhttps://github.com/thheller/shadow-cljs/issues/530#issuecomment-515574124 I think it's a little hard to avoid something even you knew it.#2019-07-2619:40thheller@doglooksgood wouldn't just using whatever the load-file-in-repl command is in emacs/cider solve this problem? that should be working normally?#2019-07-2619:41thhellerI fully agree that this situation is bad ... but I cannot easily fix it without possible breaking someone elses workflow#2019-07-2619:41thhellerthere should not be a problem in a purely driven REPL workflow#2019-07-2619:42thhelleronly if you combine the REPL workflow with the hot-reload the problem appears#2019-07-2619:42thhellerstrictly speaking you also don't need to restart shadow-cljs. just the watch but thats besides the point#2019-07-2619:43tianshuwhat cider-load-file does is let you select a file, then it load.#2019-07-2619:44thhellerI don't know anything about cider but any clj/s REPL has a built-in command for load-file which force loads the actual file from disk#2019-07-2619:44thhellershould be something for that in cider just no clue what the name is#2019-07-2619:44tianshuIt's more like a function, you can write (cider-load-file "some.clj") in elisp. but as almost every tutorial they will teach user use a command called C-c C-k, that is cider-load-buffer. will load current buffer.#2019-07-2619:45thhellerif that translates to a load-file then that should be fine#2019-07-2619:45tianshuno that simple, because cider have many commands, like it can load a file from beginning to current cursor position.#2019-07-2619:46tianshuit can also only re-evaluate the current ns form to let require change affected.#2019-07-2619:47thhelleryes but fundamentally there SHOULD be a way to fix you problem just via the REPL#2019-07-2619:47thhellerthe issue you reported is due to the REPL workflow not playing nice with the hot-reload#2019-07-2619:48thhellerwhich you can however fix with a pure REPL solution (without restarting anything)#2019-07-2619:48thhellerI'm just not sure how to reliable find a solution that works in an acceptable manner for both workflows#2019-07-2619:48thhellerI'm probably overthinking it and should just throw away intermediate REPL state#2019-07-2619:49thhellerbut that might then create problems for someone that prefers the REPL as the ultimate truth#2019-07-2619:49tianshuwhat is the another workflow in this context, and how that will be broken#2019-07-2619:49thhellersaving a file reverting REPL state#2019-07-2619:50thhellerjust the reverse of what you described#2019-07-2619:50thhelleryou eval something at the REPL like (defn foo [] 2) but in the file you have (defn foo [] 1)#2019-07-2619:50thhelleryou save the file, it gets loaded and your REPL state is "reverted"#2019-07-2619:51thhellerit is just fundamentally a problem with hot-reload and REPL combined#2019-07-2619:51thhellerin your workflow you can probably get rid of hot-reload entirely#2019-07-2619:52thhellersince you can do everything directly at the REPL also#2019-07-2619:52tianshuThe Clojure didn't have a hot-reload. But in Clojure, When you save a file and load it, it will revert the REPL state.#2019-07-2619:53thheller... if you load it at the REPL yes#2019-07-2619:53thhellerbut that is the point#2019-07-2619:53thhellerYOU have to trigger the reload. which you can do with a load-file right now.#2019-07-2619:53tianshuyeah, not matter how you load the file, it will finally be loaded via REL#2019-07-2619:53thhellernot exactly#2019-07-2619:54thhellerif you take your repro example and run it in clojure#2019-07-2619:54thhellerjust adding the :require to foo.core will NOT trigger a reload of bar.core from disk#2019-07-2619:54thhellersame as it is in shadow-cljs right now#2019-07-2619:54tianshuthat's because there's no hot-reload stuff#2019-07-2619:55tianshuwhat If I run a timer, auto load the file#2019-07-2619:55thhelleryes ... you are misunderstanding what I'm saying#2019-07-2619:55thhellerYOU are triggering the reload#2019-07-2619:55thhellerif you do it manually or via some other kind of timer or whatever does not matter#2019-07-2619:55thhellerYOU are telling the runtime to LOAD the file from disk#2019-07-2619:56thhellerin hot-reload you are NOT telling the compiler anything#2019-07-2619:56thhellerso it tries to do its best effort to try to understand what you want#2019-07-2619:56thhellerwhich in the issue reported is NOT what YOU expected#2019-07-2619:56thhellerbut it might be what someone else expected#2019-07-2619:56thhellerthat is all I'm saying#2019-07-2619:56thhellerjust trying to think of something that doesn't break either workflow#2019-07-2619:57thhellerbut I don't think that is possible#2019-07-2619:57thhellerso the "safe" guess is probably to throw away the REPL state and just reload from disk#2019-07-2619:58thhellerwhat is done right now matches the behavior of Clojure#2019-07-2619:58thhellerbut it does not match the expected hot-reload behavior#2019-07-2619:58tianshuI understand your point now, but how hot-reload work shouldn't be understand as "When I save the file, file content will be loaded in the REPL"?#2019-07-2619:59tianshuwill this match the behavior in Clojure?#2019-07-2619:59thhelleras you said .. there is no hot-reload in clojure#2019-07-2619:59tianshuClojure do have a few hot-reload stuff#2019-07-2619:59thhellerfor example in Cursive there is a "sync files in REPL" command which I use quite frequently#2019-07-2619:59thhellerit'll just load all the files I changed in the REPL#2019-07-2620:00tianshubut rarely people use it, that what I mean you won't care about this workflow in Clojure. That doesn't mean you can't hot-reload in Clojure.#2019-07-2620:00thhellerno the point is that this is done automatically#2019-07-2620:00thhellerthe issue wouldn't exist if YOU told the runtime to do this#2019-07-2620:00tianshuyeah, that is automatically#2019-07-2620:01thhellerin cursive for example it will safe the file if I switch app focus#2019-07-2620:01thhellerso if I alt+tab to a browser or so#2019-07-2620:01thhellerit'll save all files#2019-07-2620:01thhellerwith hot-reload it automatically loads all those files even if I didn't mean to#2019-07-2620:02thhellerso if say I was working on a function that was in a working state#2019-07-2620:02tianshuwhat if you do what I do in cursive, cursive didn't restrict that#2019-07-2620:02thhellerbut now I broke it since I wanted to look something up in the docs or so#2019-07-2620:02thhellerthe hot-reload will blow away the REPL state even though I didn't want it to#2019-07-2620:03thhellerthats why I mean that hot-reload and REPL are somewhat at odds with each other#2019-07-2620:03tianshuI can't understand this case, cause If I don't want hot-reload triggered, I just NOT save the file.#2019-07-2620:04thhelleras I said ... I use the "save on focus lost" as a default in Cursive#2019-07-2620:04thhellerso I don't even notice it (or could stop it)#2019-07-2620:04tianshuThat's the thing that it matches the usage in cursive, but not in Emacs#2019-07-2620:05thhelleryes ... but you see how there are multiple workflows and how fixing one can break another?#2019-07-2620:05thhellerjust saying that I want to consider a proper solution first before coming up with a quick fix that fixes your particular problem#2019-07-2620:06tianshuThe only way I think can fix both is add a priority config.#2019-07-2620:07thhellerwell the real problem I want to fix first is that reloading the browser makes the problem worse#2019-07-2620:07thhellerreloading the browser should definitely bring everything into the expected state#2019-07-2620:07thhellersince all REPL state is gone anyways#2019-07-2620:08tianshuIf reload can bring everything correct, this issue is kind of fixed IMO.#2019-07-2620:09thhellerthe issue should be fixed just fine if you issue a load-file manually#2019-07-2620:09thheller(whatever cider command that is)#2019-07-2620:10tianshuBut I want to say, in Clojure, there're some auto test libraries, that will auto reload test when file is saved.#2019-07-2620:10thhellerload-file as in the nrepl command#2019-07-2620:11tianshuI don't think so.#2019-07-2620:11tianshuthe problem is I can break the state very easily#2019-07-2620:11tianshuof course, I know when it happen, so I avoid this.#2019-07-2620:11thhellerI can fix the problem state in your repro with a simple load-file#2019-07-2620:12thhellerbut that really doesn't matter ... we completely agree that the current state is bad and needs to be fixed#2019-07-2620:12thhellerjust need to think about the fix for a bit#2019-07-2620:13tianshuThe problem is in Clojure you don't have to do this. I don't know how the workflow you mentioned will work with auto-test-refresh in Clojure.#2019-07-2620:14tianshuBut in Clojure , you only care about the namespace.#2019-07-2620:14thhellernot sure what you are refering to currently#2019-07-2620:15tianshuI mean, there're some Clojure library have hot-reload works as the way I expect.#2019-07-2620:15tianshulike auto rerun test when saving the file.#2019-07-2620:16thhellerthat is relevant why? I mean I just said that we agree that this needs to be fixed?#2019-07-2620:16tianshuI mean, user care about the running state.#2019-07-2620:17tianshuSo there should be a way to configure how running state be affected.#2019-07-2620:17thhellerlets define it this way: when you use hot-reload you care more about that the state of the REPL matches what is saved in files#2019-07-2620:17tianshuI just want to provide some possible solution.#2019-07-2620:17tianshunot argue about something.#2019-07-2620:18thhellerand you do not care about the state of the REPL itself#2019-07-2620:19tianshuIf the reload problem get fixed, I think I have an idea for the workflow problem#2019-07-2620:19tianshuthat is indicator, telling your current file is not sync with the repl state.#2019-07-2620:20thhellerthat would be a really hard problem though#2019-07-2620:20tianshuohh, I know.#2019-07-2620:21thhellerI think it should be fine if I fix the real problem in that a browser-reload fixes the actual problem instead of making it worse#2019-07-2620:21thhellerrequiring a full shadow-cljs build restart shouldn't be required#2019-07-2620:22tianshuin this case, just reload the browser?#2019-07-2620:22tianshuthat will be fine#2019-07-2620:23thhellerthat this "empty" file exists in disk is the real problem
goog.provide('bar.core');
goog.require('cljs.core');

//# sourceMappingURL=bar.core.js.map
#2019-07-2620:23thhellersince that prevents the browser-reload from fixing itself#2019-07-2620:23tianshuwhat will this file be looks like if that is fixed? the content of repl or the content of file?#2019-07-2620:24thhellerfile#2019-07-2620:24tianshu😢 I think we are talking in the wrong direction for about a long time#2019-07-2620:25tianshuIf this is the content of file, all goes well.#2019-07-2620:25tianshuabsolutely will fix my problem#2019-07-2620:26thhelleryes, funny enough that is the weird problem to fix#2019-07-2620:27thhellerin your repro you first SAVE bar.core. shadow-cljs watch kicks in and finds that the file is not used in the build so it is not compiled#2019-07-2620:27thhellerthen you define the ns in the REPL#2019-07-2620:27thhellerthen you add the require. require will find the ns loaded in the REPL and not recompile the file#2019-07-2620:27thhellersince bar.core is never changed it isn't automatically replaced#2019-07-2620:28tianshuthat's the expected behavior#2019-07-2620:28tianshuI said, user care about the running state.#2019-07-2620:28thhellerno now you are misunderstanding me#2019-07-2620:29tianshuI'm not misunderstanding#2019-07-2620:29thhellerI mean that is the order of events in the code#2019-07-2620:29thhellerthere is no step in this order of events where I can generate the correct file#2019-07-2620:29thhellerwithout adding an extra step that does not exist yet#2019-07-2620:29tianshuI think you misunderstanding the purpose of the repro#2019-07-2620:30tianshumy repro is how to get the bad state#2019-07-2620:30tianshunot show how it won't work in this kind workflow.#2019-07-2620:30thhelleryes and I'm telling you how it ends up in that bad state from the view of shadow-cljs#2019-07-2620:31tianshuI was thinking you are telling me, the file should be never load, unless I trigger something#2019-07-2620:31thhellerno, you CAN do that right now without me changing anything#2019-07-2620:31thhellerbut you should NOT be forced to#2019-07-2620:32tianshulet me have a try#2019-07-2620:33tianshuno no no, the problem is not here#2019-07-2620:33thheller(load-file "/full/path/to/bar/core/cljs") in the REPL however that is done in cider should fix it#2019-07-2620:33tianshuit is when after hot-reload#2019-07-2620:34tianshuafter hot-reload, the output js file is empty#2019-07-2620:34tianshuthat is my problem#2019-07-2620:34thhellerif you do an actual load-file it should not be empty#2019-07-2620:34tianshulet me try#2019-07-2620:34thheller(require 'bar.core :reload) is broken so that does not fix it#2019-07-2620:34thhellermust be an actual load-file#2019-07-2620:35thhellerI know what the problem is ... just need to find a proper way to fix it in the actual implementation#2019-07-2620:35thhellerand that is surprisingly confusing#2019-07-2620:37tianshu#2019-07-2620:37tianshuthe color..
#2019-07-2620:37tianshuI'm trying#2019-07-2620:45tianshucan't reproducing..#2019-07-2620:46thhellerreproduce what?#2019-07-2620:51tianshuhow can I do load file in shadow-cljs repl without cider#2019-07-2620:51tianshujust require?#2019-07-2620:51thheller(load-file "/full/path/to/bar/core.cljs")#2019-07-2620:52tianshu
[:result {:type :repl/error, :ex #error {
 :cause "symbol bar.core already provided by [:shadow.cljs.repl/resource \"bar/core.cljs\"], conflict with [:shadow.build.classpath/resource \"bar/core.cljs\"]"
 :data {:provide bar.core, :conflict [:shadow.cljs.repl/resource "bar/core.cljs"], :resource-id [:shadow.build.classpath/resource "bar/core.cljs"]}
#2019-07-2620:53tianshuI got this#2019-07-2620:54tianshuI do this after I refresh the browser#2019-07-2620:59thhellerhmm dunno it worked when I tested it last#2019-07-2620:59thhellerbut regardless the underlying problem is the same#2019-07-2620:59thhellertwo competing resources with no clear rules which to use#2019-07-2621:02tianshuis this an error from shadow server?#2019-07-2621:02thhelleryes#2019-07-2621:02tianshuso when I refresh the browser, the state won't change#2019-07-2621:03thhellerrefreshing the browser does not affect the server#2019-07-2621:03tianshuso the namespace will be associate with the repl resource forever?#2019-07-2621:04thhellerload-file should be overwriting that but could be that it doesn't#2019-07-2621:05tianshuemmm#2019-07-2621:06tianshulooks like this is the only problem need to be solved.#2019-07-2621:08thhelleryeah I'll fix it eventually. too tired now though.#2019-07-2710:19jaccarmacHey there, been fiddling with a toy project to learn Shadow and core.async, and I'm somewhat confused by behavior. It's possibly just me not understanding how core.async works.#2019-07-2710:20jaccarmacI'm using a third party JS library in a Node script, and outputting to a Node script. When I use that lib API with callbacks, everything works fine, but when I sub in core.async stuff things still work but Node hangs rather than exiting when the callback completes#2019-07-2710:20jaccarmacThe core.async example with doseq also hangs.#2019-07-2710:21jaccarmacIs that just inherent to the way that core.async works when outputting to a script rather than the browser, or am I misusing core.async in some other way?#2019-07-2710:21thhellerprobably misusing it in some way#2019-07-2710:21thhellercore.async works the same in node or browser#2019-07-2710:29jaccarmacI see, esp. when checking the examples I was referring to again.#2019-07-2710:30thhellerthe only difference in node vs the browser is the "exit" condition of the process#2019-07-2710:31jaccarmacIs there an idiomatic way to exit after the core.async "callback" is done?#2019-07-2710:31thhellersince the browser never exits you just might be waiting for something else that keeps the node process alive#2019-07-2710:31thhellerdepends on how you define done#2019-07-2710:31jaccarmacOr should I just be manually calling into Node exit things?#2019-07-2710:31thhellerfor example when using a :node-script build with watch the websocket connection used for the watch itself will keep the process alive#2019-07-2710:32thhellerso you might want to disable the devtools via :devtools {:enabled false}#2019-07-2710:32thhellershouldn't need to force exit the node process by calling it manually otherwise#2019-07-2710:32jaccarmacWell, I have code examples if you're up for a super-quick look. http://chiselapp.com/user/jaccarmac/repository/junkcode/artifact/932673eaa4187131: Callback-enabled, exits after printing. http://chiselapp.com/user/jaccarmac/repository/junkcode/artifact/31587b684a610646: core.async, doesn't exit after printing.#2019-07-2710:33jaccarmacI'm using watch but only for the compilation part (or so I thought), running the output script manually each time.#2019-07-2710:34thhellerwell first of all the if looks broken#2019-07-2710:34thheller
#(do (if %1
                       (js/console.log %1)
                       (put! data-chan %2))
                     (close! data-chan)))
#2019-07-2710:34thheller(if <pred> <then> <else>)#2019-07-2710:35thhellerso if true you just log but never put?#2019-07-2710:35jaccarmacCorrect#2019-07-2710:35jaccarmac(that's not the way things are going to be permanently, was only worried about the happy path)#2019-07-2710:36jaccarmacIn the failure case I'm pulling a nil out of the channel at the end thanks to the close, though.#2019-07-2710:37thhellerand how are you running this?#2019-07-2710:38jaccarmacnode extract.js#2019-07-2710:38thhellerwith shadow-cljs watch or not?#2019-07-2710:38jaccarmacYep with watch#2019-07-2710:39thhellerdo you have devtools disabled?#2019-07-2710:39jaccarmacI hadn't realized that kept a REPL connect open#2019-07-2710:39jaccarmacWhoops 😬#2019-07-2710:41thhellerdunno why it wouldn't be kept alive with the callback example though#2019-07-2710:41thhellerthe behavior there should be the same#2019-07-2710:43jaccarmacLooking back I only started using watchafter I added async things#2019-07-2710:43jaccarmacSo it was changing two variables when I thought I was only changing one.#2019-07-2710:44thhellerfor CLI type scripts I recommend just disabling the devtools#2019-07-2710:44jaccarmacSkimmed the docs and mistakenly believed that hot code reloading was only happening if I explicitly setup hooks.#2019-07-2710:44jaccarmacDuly noted.#2019-07-2710:44thhellerjust use shadow-cljs node-repl if you want an actual REPL#2019-07-2717:01anmonteiroIs there a way to have Shadow treat warnings as errors?#2019-07-2717:01anmonteiroif I were dealing with CLJS directly I’d call cljs.analyzer/with-warning-handlers but that seems to have no effect in shadow#2019-07-2719:02thheller@anmonteiro there is not but happy to add a flag or something#2019-07-2719:26anmonteiro@thheller would love that. we’d like to treat most warnings as errors#2019-07-2719:51thhellerso in CLJS there is currently {:warnings true|false|{<warning-type true/false}}#2019-07-2719:51thhellerI could either add {:warnings :error} to treat all warnings as errors#2019-07-2719:51thheller{:warnings {:undeclared-var :error}} to pick specific things that should be errors#2019-07-2719:52thhelleror add a "new" key for something like :warnings-as-errors true/false or :warnings-as-errors #{:only :these}#2019-07-2719:53thhellerthe :warnings-handlers approach seems a bit icky to me and not really user friendly#2019-07-2720:16anmonteiro@thheller I like a hybrid of some of those#2019-07-2720:16anmonteiro{:warnings {:undeclared-var :error}}#2019-07-2720:16anmonteirohrm#2019-07-2720:17anmonteirowait that doesn’t allow for the other one#2019-07-2720:17thhellerI think I prefer the :warnings-as-errors true for all and with a set for more control#2019-07-2720:17anmonteiro> I could either add {:warnings :error} to treat all warnings as errors > {:warnings {:undeclared-var :error}} to pick specific things that should be errors#2019-07-2720:17anmonteiroactually these two are not mutually exclusive#2019-07-2720:17thhellertouching :warnings might cause troubles later on the compile#2019-07-2821:22anmonteirothe only advantage I see with :warnings over :warnings-as-errors is that you’d be able to turn warnings off#2019-07-2823:20thheller@anmonteiro :warnings is a standard CLJS feature so turning them off is possible regardless#2019-07-2900:04anmonteirooh it is?!#2019-07-2900:05anmonteiroI thought :closure-warnings was a thing#2019-07-2900:05anmonteirobut not warnings#2019-07-2900:06anmonteirointeresting how that doesn’t let you treat some warnings as errors#2019-07-2900:06anmonteiroseems like a useful feature that could even be implemented upstream#2019-07-2908:03thhelleryeah :compiler-options {:warnings {:undeclared-var false}} would disable that warning#2019-07-2908:03thhellercurrently it is just a boolean but adding :error to throw instead of warning would be pretty straightforward. just not sure if it breaks other places that only expect a boolean#2019-07-2910:29stevechanhello#2019-07-2910:30stevechan#2019-07-2910:31stevechanI want import shadow-cljs compiled js in the react jsx file#2019-07-2910:31stevechanbut i get this Error#2019-07-2915:36knubieI’m having some trouble with the closure-defines feature#2019-07-2915:37knubiewhen i add something like {:closure-defines {my-app/FOO true}}, then try to use it somewhere, the compiler returns: Use of undeclared Var my-app/FOO#2019-07-2915:38knubieI think I must be missing a step, or misunderstanding how it works#2019-07-2915:39thheller(ns ) (goog-define FOO false)#2019-07-2915:39thhellerwould be configured by :closure-defines { true}#2019-07-2915:39knubieEven with (ns ) (goog-define FOO false) I still get that compilation error#2019-07-2915:40thhellerhow do you use it then?#2019-07-2915:40knubieI’m using it in a different namespace#2019-07-2915:40thhellerand that namespace has a (:require [ ...])?#2019-07-2915:40thhellercan't use it without a proper require#2019-07-2915:40knubieah, that’s probably it#2019-07-2915:41knubiethanks @thheller!#2019-07-2915:41knubielove shadow-cljs, I try to promote it whenever I can#2019-07-2916:57Karol WójcikDo you know some of clojurescript cljs.test pretty printer with colorful expected actual structures which works seamlessly with shadow-cljs?#2019-07-2919:41thheller@karol.wojcik I do not but let me know if you find one#2019-07-2920:28Karol Wójcik@thheller Maybe you have some ideas how to integrate any of javascript frameworks with clojurescript? I'm trying to find a one which allows to call the test by it's name, because I doubt it can work another way.#2019-07-2920:29thhellernot a clue. I don't write a whole lot of tests 😛#2019-07-2920:13kasukoI'm getting a strange error when I run npx shadow-cljs compile dev#2019-07-2920:13kasuko
shadow-cljs - config: /Users/victor/Ericsson/code/cenx/apps/frontend/eric-cenx-ui/shadow-cljs.edn  cli version: 2.8.41  node: v12.7.0
Execution error - invalid arguments to shadow.cljs.devtools.api/loading at (api.clj:1)
#2019-07-2920:15kasukoI only have a single build#2019-07-2920:15thhellerthat is indeed weird given that var doesn't exist#2019-07-2920:15kasuko
{:dev {:target :browser
        :output-dir "resources/public/js/compiled/"
        :asset-path "/js/compiled"
        :modules {:app {:entries [epiphany.core]}}}}
#2019-07-2920:16kasuko#2019-07-2920:16thhellerdoes npx shadow-cljs clj-repl work?#2019-07-2920:16kasukoThen it outputs the above report#2019-07-2920:17kasukoNope, clj-repl does the same thing#2019-07-2920:17wilkerlucioI just got an error that I found a bit bizarre, this is what I see:
------ ERROR -------------------------------------------------------------------
 File: /.../common/ui/layout.cljs:572:26
--------------------------------------------------------------------------------
 569 | 
 570 | (def css-button
 571 |   {:background-color "transparent"
 572 |    :border           "1px solid #c49dc9"
--------------------------------^-----------------------------------------------
.../common/ui/layout.cljs [line 572, col 26] Invalid number: 1px.
#2019-07-2920:17wilkerluciodoes that makes sense to anyone?#2019-07-2920:18thheller@wilkerlucio verify that " is actually ". I seen all sorts of weird stuff when copying " from skype or some other office crap#2019-07-2920:19wilkerlucioyes, and that line wasn't changed on my branch#2019-07-2920:19wilkerluciobut still causing the build to fail somehow#2019-07-2920:19wilkerlucioouch, I maybe have found it#2019-07-2920:20wilkerluciono, still not working, that was other string changed, but still a valid "#2019-07-2920:20thheller@kasuko I'm guessing this is some sort of dependency conflict. make sure you have the "correct" core.async versions and so on#2019-07-2920:23kasukoYep that was exactly it. I am converting an old project from leiningen to shadow-cljs and it had an old version of core.async#2019-07-2920:20thhellermake sure there are no other unicode chars hidden in there#2019-07-2920:20wilkerlucioand works on my machine, but not on ci -.-#2019-07-2920:22wilkerluciook, I'll keep debugging, that was some github merged suggestions, may have to do with it#2019-07-2920:23thhellernot really any other ideas. the error you get is directly from tools.reader so before any analysis/compilation happens#2019-07-2920:46wilkerlucioyeah, was something weird, after I pull and push it got back working :man-shrugging:#2019-07-3012:58orestisHi, I’ve upgraded shadow to 2.8.41 and I’m seeing some issue with my UI not re-rendering any more when I edit “leaf” dependency files. But it’s super weird because I see that Shadow HUD, I see that it picked up the changed file and its dependees, it called my :dev/after-load function, but my app isn’t rerendering at all. Editing a file further up the chain does the trick.#2019-07-3012:58orestisI can’t reproduce it any more after a browser restart, it was a new file that I added, not sure what the culprit was. I’m doing just plain saves and waiting for shadow to pick up things, no REPL interactions.#2019-07-3013:00thhellernothing has changed with reloading in quite a while so I somehow doubt that the upgrade affected anything that wasn't there before?#2019-07-3013:01thhellerI'll be writing an in-depth blog post about hot-reload in shadow-cljs soon to hopefully clear up how everything works#2019-07-3013:02thhellerso it easier to track down why something might not work as you'd expect#2019-07-3013:06orestisYeah I’m not sure what’s going on. After some recent upgrades (npm + shadow) I had this weird issue where I had to nuke everything from orbit every now and then. I’ve never seen this before with shadow, so I’m tempted to blame npm for this.#2019-07-3013:07thhellerthere are some known problems with making too many changes in node_modules while shadow-cljs is running#2019-07-3013:08thhellerie. npm install some-big-package-with-lots-of-dependencies#2019-07-3013:08thhelleror rather updating those packages#2019-07-3013:09thhellerbut besides that I'm not aware of any issues#2019-07-3014:23pezI get Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath. when starting up one of my projects using 2.8.41. My project used to be usingh 2.8.8, and if I go back to that things work.#2019-07-3014:24thhelleryou are likely using deps.edn which changed and you must now add theller/shadow-cljs to your deps.edn manually#2019-07-3014:30pezThanks. That works great.#2019-07-3014:38pezI'm working with Calva jack-in and trying out different test projects I have. I run into problems with that deps.edn project on Windows. Since it needs clojure to run it also needs Powershell. I can make that happen, with some work. Would you say that checking for the existence of deps.edn is enough for detecting this situation before launching, @thheller?#2019-07-3014:39thhellernot sure I understand the question?#2019-07-3014:40pezLet me add some more context... 😃#2019-07-3014:43pezOn Windows clojure can only be invoked in a Powershell environment. So if I just launch the process npx, this project fails. For general clojure-cli projects I therefore run clojure in a powershell.exe process. Thinking I could do the same for shadow projects that need clojure.#2019-07-3014:44thhellerI don't see why shadow-cljs is involved in this question? just run shadow-cljs normally. it'll do the right thing on windows?#2019-07-3014:44thheller(I fixed the windows powershell support a couple releases ago)#2019-07-3014:45thhellershould be working normally now#2019-07-3014:45thhellercan't remember if it was 2.8.40 or earlier#2019-07-3014:51pezOK. So maybe that was when I tried with 2.8.8... It behaves differently with 2.8.41 indeed, but still seems to need some special quoting on my part. I get this error now:
> Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/cider-nrepl:0.21.1 watch :app <

npx: installed 92 in 12.938s
shadow-cljs - config: e:\rn-rf-shadow\shadow-cljs.edn  cli version: 2.8.41  node: v10.16.0
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - starting via "clojure"
Unknown option: "-i"
Unknown option: "-n"
Unknown option: "-p"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-F"
Unknown option: "-o"
Unknown option: "-r"
Unknown option: "-m"
Unknown option: "-a"
Unknown option: "-t"
Unknown option: "-o"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-p"
Unknown option: "-u"
Unknown option: "-t"
Unknown option: "-F"
Unknown option: "-o"
Unknown option: "-r"
Unknown option: "-m"
Unknown option: "-a"
Unknown option: "-t"
#2019-07-3014:52thhellerwhat the heck is that?#2019-07-3014:52thhelleroh I think I had that before yes#2019-07-3014:52thheller-d cider/cider-nrepl:0.21.1 that is the issue#2019-07-3014:52pezI've seen it before too. Been fighting with powershell for several days now..#2019-07-3014:53thhellerright yeah I forgot. feel free to open an issue about that#2019-07-3014:53thhellerpowershell handles command line args in a weird way to that probably needs to be adjusted somehow#2019-07-3014:54thhellerone of the reason I opted to remove the dependency injection for shadow-cljs itself#2019-07-3014:54thhellerjust causes way more issues than it solves#2019-07-3014:54thhellerso it probably works fine if you just add it to the deps.edn and run normally#2019-07-3014:56pezCalva jack-in needs the injection way of doing things. I'll open an issue.#2019-07-3015:08pezHere: https://github.com/thheller/shadow-cljs/issues/534 Let me know if I should add/retract something to make it usable.#2019-07-3015:13thhellerwhats funny about the error is that shadow-cljs NEVER actually passes any of those args to powershell#2019-07-3015:13thhellerso I have no clue where that error is even coming from other than that it fails parsing the -Sdeps EDN data#2019-07-3015:14thhellerprobably needs to be escaped or something. I'll take a look when I get a chance#2019-07-3015:21pezI got it with some of my attempts to escape the jack-in command for clojure. Could be the slash there that gets things interpreted as an options... #2019-07-3018:46thheller@pez try 2.8.42. hope that sorts out all the powershell escaping issues#2019-07-3020:02pez@thheller that seems to fix it. However now i run into something else. It works on my Mac still, but on my (virtual) Windows I get this:
npx: installed 92 in 8.673s
shadow-cljs - config: e:\rn-rf-shadow\shadow-cljs.edn  cli version: 2.8.42  node: v10.16.0
shadow-cljs - starting via "clojure"
failed to start service
{:id :cljs-watch}
ExceptionInfo: failed to start service
        shadow.runtime.services/start-many/fn--9540 (services.clj:135)
        shadow.runtime.services/start-many (services.clj:126)
        shadow.runtime.services/start-many (services.clj:105)
        shadow.runtime.services/start-all (services.clj:144)
        shadow.runtime.services/start-all (services.clj:139)
        shadow.cljs.devtools.server/start-system (server.clj:370)
        shadow.cljs.devtools.server/start-system (server.clj:242)
        shadow.cljs.devtools.server/start! (server.clj:493)
        shadow.cljs.devtools.server/start! (server.clj:411)
        shadow.cljs.devtools.server/start! (server.clj:414)
        shadow.cljs.devtools.server/start! (server.clj:411)
        shadow.cljs.devtools.server/from-cli (server.clj:625)
        shadow.cljs.devtools.server/from-cli (server.clj:601)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:665)
        clojure.core/apply (core.clj:660)
        shadow.cljs.devtools.cli/lazy-invoke (cli.clj:24)
        shadow.cljs.devtools.cli/lazy-invoke (cli.clj:21)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:131)
        shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
        shadow.cljs.devtools.cli/main (cli.clj:179)
        shadow.cljs.devtools.cli/main (cli.clj:134)
        clojure.core/apply (core.clj:669)
        clojure.core/apply (core.clj:660)
        shadow.cljs.devtools.cli/-main (cli.clj:221)
        shadow.cljs.devtools.cli/-main (cli.clj:219)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:665)
        clojure.main/main-opt (main.clj:514)
        clojure.main/main-opt (main.clj:510)
        clojure.main/main (main.clj:664)
        clojure.main/main (main.clj:616)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.main.main (main.java:40)
Caused by:
IOException: Incorrect function.

        sun.nio.fs.WindowsWatchService$Poller.implRegister (WindowsWatchService.java:433)
        sun.nio.fs.AbstractPoller.processRequests (AbstractPoller.java:260)
        sun.nio.fs.WindowsWatchService$Poller.run (WindowsWatchService.java:595)
        java.lang.Thread.run (Thread.java:748)
It's this project: https://github.com/PEZ/rn-rf-shadow
#2019-07-3020:13thhellerweird. never seen that before 😛#2019-07-3020:14thhellermaybe related to this?#2019-07-3020:14thhellerhttps://stackoverflow.com/questions/25390927/filechannel-trylock-causes-java-io-ioexception-incorrect-function#2019-07-3020:17pezWow, Windows...#2019-07-3020:15thhellerhttps://stackoverflow.com/questions/122400/what-are-reserved-filenames-for-various-platforms#2019-07-3020:15pezIt could be because I am running the project from a network share (mounting the project on the Mac in Virtual Box).#2019-07-3020:23camdenanyone using shadow-cljs to build cypress tests written in cljs? i'd be curious to know how you're doing it, from a high level!#2019-07-3020:42pez@thheller, indeed I only get that Incorrect function error when I run the project from that virtual box network mount. Things work if I run the project from the ”harddrive” of the Windows virtual machine.#2019-07-3102:10Chris O’DonnellIs there a way to download a project's dependencies without compiling with shadow-cljs? For context, I'm working on a build dockerfile, and I'd like to download dependencies before copying the source directory in for caching purposes.#2019-07-3102:12Chris O’DonnellAlso, I'm using deps.edn to write my dependencies.#2019-07-3102:57Chris O’DonnellRealized I could create a separate, dummy build and compile that without copying in the full source directory, using that compile to download dependencies. Should be a good enough workaround.#2019-07-3105:16lilactownhttps://github.com/thheller/shadow-cljs/issues/362 @codonnell#2019-07-3107:20thheller@codonnell if you use deps.edn anyways just call clj directly, eg clj -Stree or so#2019-07-3107:20thhellerdon't need to do an actual compile for anything#2019-07-3108:09orestisI’m so mad at the npm world right now. Bumping react-bootstrap from 1.0.0-beta9 to 1.0.0-beta10 just opens a huge can of worms.#2019-07-3108:10orestisDoes shadow-cljs have parity with webpack on how it resolves node modules? I can’t imagine that people in JS land go through this all the time, but perhaps I’m wrong and they do.#2019-07-3108:12thhellerit does not have parity on purpose. it is way stricter.#2019-07-3108:12thhellerbut JS people go through this all the time too 😛#2019-07-3108:12thhellerwhats the problem?#2019-07-3108:16orestisWell, I’m not sure I understand entirely — things fail to load because some js error. The latest is from Vega.js complaining about "renegeratorRuntime" is undefined.#2019-07-3108:16orestisI rolled back my update because I have more important things to do and things work again.#2019-07-3108:17thhellerrenegeratorRuntime is some babel thing for transpiled code that needs to be included separately for some reason#2019-07-3108:17orestisAnother one was _uncontrollable.default is undefined which probably relates to the uncontrollable package. What’s the root issue? Who knows.#2019-07-3108:17orestisYeah I tried putting nested dependencies at the top. I’ve also tried yarn, not sure if that was a good idea.#2019-07-3108:17thhellerjust add (:require ["regenerator-runtime/runtime"]) before your JS requires#2019-07-3108:18orestisOh, I have to require that?#2019-07-3108:18orestisOK, good to know. I’ll try that next time I go through this excursion.#2019-07-3108:18orestisBut it’s fricking bonkers :face_with_symbols_on_mouth:#2019-07-3108:18thhellerthe .default is usually a problem with commonjs VS es6 code#2019-07-3108:19thhellerit is madness yes#2019-07-3108:19thhellershould be getting better with webpack5 since they are dropping a bunch of those ugly hacks#2019-07-3108:19thhellerforcing people to pay more attention when making packages#2019-07-3108:20thhellernow webpack just accepts all sorts of crap and as long as it works in webpack people don't pay attention if things are actually correct or not#2019-07-3110:26Chris O’DonnellThanks. I tried that and found that a bunch more dependencies were downloaded when I compiled. In the cold light of morning it's now obvious that the reason for that is I didn't call clojure with the dev alias. picard-facepalm#2019-07-3110:26thhellerhehe#2019-07-3111:14orestisDoes shadow pick up “nested” node_modules dependencies? (not sure what the right terminology is). Like, node_modules/react-overlays/node_modules/uncontrollable — when there is a top-level node_modules/uncontrollable as well?#2019-07-3111:17thhellerno it does not. only top level works#2019-07-3111:18orestisAh, that’s why I’m having trouble then. There’s version conflicts and apparently that works fine in the npm world.#2019-07-3111:19thhellerwell it works fine in that you'll have 2 uncontrollable packages included in your build 😉#2019-07-3111:19thhellerwhich is nonsense IMHO 😛#2019-07-3111:20orestisYeah, and of course uncontrollable released a version 7.0 who’s only change is to break the default exports. Now all the consumers have to change, and of course not everyone has done yet.#2019-07-3111:20orestisI’ll just wait a couple of weeks and try again…#2019-07-3111:20orestisThe churn! The churn!#2019-07-3111:20thhellerfun times 😛#2019-07-3111:26thhellerbut yeah stuff like that is gonna get way worse for a while when webpack 5 is released#2019-07-3111:26thhellerbut its good news for us since then more packages should follow the "strict" packaging that closure expects#2019-07-3111:55orestisGood to know that they’re getting their act together. Now to resist the urge to rewrite all my dependencies…#2019-08-0101:13colinkahnIf I had a macro like (defjson my-json "/some/path/to.json") and that macro slurped in the json file at the path is there a way to tell shadow-cljs that when I change the file at "some/path/to.json" it should recompile the cljs file I've used the macro in?#2019-08-0105:19tianshuI think you can't. why not write edn in a clojure file, that can be auto reload I think.#2019-08-0107:10thheller@colinkahn see https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745. if you use that helper function it'll recompile. otherwise it won't#2019-08-0111:46danielnealHey, I’ve just asked a question on the new http://ask.clojure.org about source maps for react native in shadow-cljs - if anyone has any ideas or leads please chime in! https://ask.clojure.org/index.php/8294/there-approaches-source-maps-working-with-react-native-shadow#2019-08-0210:30thhellercould you help me by setting up a very basic figwheel/react-native project that has an actual source mapped error? I can't seem to figure out how to get that working#2019-08-0210:31thhellerthe redbox from react-native never shows anything mapped?#2019-08-0210:31thhellerI mean it doesn't even map its own built-in stuff?#2019-08-0210:39thhelleror am I just expecting to much? (js/console.log "foo") is mapped correctly#2019-08-0210:39thhellerjust errors are not#2019-08-0210:41danielnealah sure, so the red box never shows anything - it’s only ever in chrome#2019-08-0210:41danielneallet me see if I can set up a project#2019-08-0210:41danielnealI’m using expo is that ok?#2019-08-0210:41thhellercurrently trying without expo#2019-08-0210:42thhellerdunno if expo adds anything special#2019-08-0210:42thhellerbut should be ok with expo. if I get it to work there I can probably get it to work without#2019-08-0211:04danielnealI’m trimming back one of our working projects; we diverged a fair bit from the template over time, might take a little bit of time. It’s quite informative to do so I’m glad to be doing it 🙂#2019-08-0211:06thheller
(def styles
  ^js (-> {:container
           {:flex 1
            :backgroundColor "#fff"
            :alignItems "center"
            :justifyContent "center"}
           :title
           {:fontWeight "bold"
            :fontSize 24
            :color "blue"}}
          (clj->js)
          (rn/StyleSheet.create)))

(defn bad-press [e]
  (js/console.log "pressed the bad button")
  (throw (ex-info "button pressed" {})))

(defn root []
  (react/createElement rn/View #js {:style (.-container styles)}
    (react/createElement rn/Text #js {:style (.-title styles)} "Hello!")
    (react/createElement rn/Button #js {:onPress (fn [e] (bad-press e))
                                        :title "error"})))
#2019-08-0211:06thhellerthats what was testing with#2019-08-0211:06thhellerthe js/console.log is properly mapped in chrome#2019-08-0211:07thhellerbut the throw is not#2019-08-0211:35danielnealI’ll put this up on git in a mo - it’s a bit rough around the edges apologies#2019-08-0211:35danielnealjust to double check - have you got “pause on caught exceptions” on#2019-08-0211:36danielnealmight just be that#2019-08-0211:45thhelleroh doh#2019-08-0211:45thhellerI didn't check the "pause on caught exceptions"#2019-08-0211:45thhelleronly eht pause on exception#2019-08-0211:46thhellerok that works as expected then#2019-08-0211:46danielnealah brilliant ok#2019-08-0211:46thhellerbut can you confirm that the chrome console still shows to stacktrace#2019-08-0211:46thhellerand the redbox stacktrace from RN doesn't show the mapped sources either?#2019-08-0211:47danielnealI’ve never seen the redbox show mapped sources#2019-08-0211:47danielnealchrome seems to be ok - it’s just that particular example is called from react native code so there’s no other user/ code-mapped stack frames#2019-08-0211:47thhellerok .. then I got it working I guess 😛#2019-08-0211:48thhellersomehow expected the redbox to show mapped sources#2019-08-0211:49danielnealoo have you got it working with shadow-cljs?#2019-08-0211:50danielneal#2019-08-0211:50thhellerdepends on how we define working but yes#2019-08-0211:50danielnealnice!#2019-08-0211:51danielneal^ this is definitely working enough for me -#2019-08-0211:51danielnealit takes it from being almost impossible to debug an error in a large project to being possible#2019-08-0211:52danielnealwhat did you have to do to get it to work with shadow?#2019-08-0211:52thhelleradjust how the code is loaded#2019-08-0212:04danielneal🙂 brilliant - am pumped about this 😄#2019-08-0119:29colinkahn@thheller thanks for link. I think I have a special case though because I’m using the :npm-module target and while (r/inline "/my/path") inlines the resource it doesn’t recompile the file i’m using it in when the resource changes during the watch. This does work for the :browser target though.#2019-08-0119:30colinkahnA bit more info, i’m using the output from :npm-module within storybook, but I’ve confirmed that it’s shadow not rebuilding the files by looking at the generated source in my out dir#2019-08-0119:30thhellerlook at the compiler log instead#2019-08-0119:31thhellerit should be starting a new compile? it certainly isn't limited to the :browser target?#2019-08-0119:32colinkahnI see it compiling my :stories build, saying it has compiled 1 file. Can I run w/ a debug flag to see which file it’s compiling?#2019-08-0119:33thhellershadow-cljs watch app --verbose yes#2019-08-0119:39colinkahn@thheller
[:stories] Compiling ...
-> build target: :npm-module stage: :resolve
-> Resolving Module: :main
<- Resolving Module: :main (31 ms)
<- build target: :npm-module stage: :resolve (34 ms)
-> build target: :npm-module stage: :compile-prepare
<- build target: :npm-module stage: :compile-prepare (0 ms)
-> Compile CLJS: project/ui/stories/button_stories.cljs
<- Compile CLJS: project/ui/stories/button_stories.cljs (20 ms)
-> Cache write: project/ui/stories/button_stories.cljs
<- Cache write: project/ui/stories/button_stories.cljs (19 ms)
-> build target: :npm-module stage: :compile-finish
<- build target: :npm-module stage: :compile-finish (0 ms)
-> build target: :npm-module stage: :flush
-> NPM module flush: /Users/colinkahn/code/project-web/out/stories
<- NPM module flush: /Users/colinkahn/code/project-web/out/stories (34 ms)
<- build target: :npm-module stage: :flush (35 ms)
[:stories] Build completed. (412 files, 1 compiled, 0 warnings, 0.23s)
#2019-08-0119:40colinkahnwhich looks right, but if I go to the built file it’s unchanged#2019-08-0119:41thhellerand you are checking /Users/colinkahn/code/project-web/out/stories?#2019-08-0119:41colinkahnyes, specifically out/stories/project.ui.stories.button_stories.js#2019-08-0119:47thhellerdunno. can't test right now. will check when I get a chance. would help if you create a reproducible example#2019-08-0119:48colinkahnOk cool, yeah i can throw something up on github#2019-08-0120:24colinkahn@thheller https://github.com/colinkahn/inline-with-npm-module#2019-08-0123:01isakIs it possible to have an :after-load for a module instead of for a build? (Tried the obvious thing and it had no effect)#2019-08-0206:51thheller@isak you can define the hooks via metadata https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2019-08-0214:39isak@thheller nice, thanks!#2019-08-0215:41teawaterwirei'm trying to setup ci on Gitlab for my shadow-cljs project, but everytime it does shadow-cljs release app it fetches again the clojure dependencies, is there a way to configure Shadow so i can try this approach for cache https://gitlab.com/gitlab-org/gitlab-ce/issues/52407#note_133093686 ?#2019-08-0217:06nateit should be possible if you could point shadow-cljs to use a different directory for retrieving maven repositories, does shadow-cljs use env variables like MAVEN_OPTS ?#2019-08-0217:51mavbozoi upgraded my shadow-cljs to latest version 2.8.42, and everytime I run shadow-cljs server, I get this error
shadow-cljs - config: /home/mavbozo/yolo/znet/machine/shadow-cljs.edn  cli version: 2.8.42  node: v11.6.0
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
Execution error (IllegalStateException) at com.google.common.base.Preconditions/checkState (Preconditions.java:823).
Externs must contain builtin for env BROWSER: whatwg_console.js

Full report at:
/tmp/clojure-9009315503829928826.edn

#2019-08-0217:53mavbozoI tried to downgrade the version and It works fine in shadow-cljs version 2.8.39
shadow-cljs - config: /home/mavbozo/yolo/znet/machine/shadow-cljs.edn  cli version: 2.8.39  node: v11.6.0
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server version: 2.8.39 running at 
shadow-cljs - nREPL server started on port 41083
#2019-08-0218:15nateis there a way to override :mvn/local-repo variable from shadow-cljs ?#2019-08-0220:23thheller@nisehl :maven {:local-repo "foo"} in shadow-cljs.edn#2019-08-0220:25thheller@mavbozo thats odd. do you happen to have some closure-library stuff in your dependencies?#2019-08-0220:25thheller@teawaterwire shadow-cljs info will download all deps when using shadow-cljs.edn to manage deps#2019-08-0223:20ro6is it possible to have a .cljc and .cljs file with the same name and namespace?#2019-08-0302:47souenzzohttps://blog.fikesfarm.com/#2019-08-0407:27thhellerif the .cljc is strictly a macro namespace yes. otherwise no.#2019-08-0305:18mavbozo@thheller i've narrowed the problem down to having "shadow-cljs": "2.8.40" in package.json & [fulcrologic/fulcro "2.8.12"] in shadow-cljs.edn's :dependencies. If I removed the fulcrologic/fulcro 2.8.12, shadow-cljs server works. I've created a demo repo here https://github.com/mavbozo/shadow1#2019-08-0306:52thheller@mavbozo try [fulcrologic/fulcro "2.8.12" :exclusions [org.clojure/clojurescript org.clojure/core.async]] instead#2019-08-0307:07mavbozostill get same error with dependencies
:dependencies
 [
  [fulcrologic/fulcro "2.8.12" :exclusions [org.clojure/clojurescript org.clojure/core.async]]
  ]
#2019-08-0307:09thhellerfor some reason fulcro declares way too many dependencies#2019-08-0307:17thhellerhttps://github.com/fulcrologic/fulcro/issues/319#2019-08-0307:18thhelleradd org.clojure/google-closure-library and com.google.javascript/closure-compiler-externs to the exclusions#2019-08-0307:18thhellerhopefully it starts working then?#2019-08-0307:32mavbozoYES!!. it works. also works in shadow-cljs 2.8.42. Thank you. Thank you so much.#2019-08-0509:07thhellerhttps://twitter.com/thheller/status/1158303405691035648#2019-08-0510:31tianshu@thheller do you mean if use loader-mode :eval, source map problem is already fixed?#2019-08-0510:37tianshuI also want to know what is the down side or limitation of eval loader-mode, for it is not the default loader-mode.#2019-08-0510:57thheller@doglooksgood no. master has the switch to eval as a default but it is incomplete and cannot be used yet#2019-08-0510:57thheller:loader-mode is only a thing for browser builds currently#2019-08-0510:57thhellerreact-native is still a work in progress
#2019-08-0510:58tianshuthat's make sense. The vote is for how to handle image only?#2019-08-0510:59thhellerthe vote is how to handle require in general but mostly affects images yes#2019-08-0510:59thhellerbut with the eval stuff in master it is currently not possible to use images so that needs to be solved before I can release that#2019-08-0511:19tianshuok, I'm go for a vot#2019-08-0511:23tianshuI think most people is considering js/require is the non-magic way. But it is the magic in React-Native.#2019-08-0518:49alexeizHi. I have a problem with setting up emacs/cider with shadow-cljs following this doc: https://shadow-cljs.github.io/docs/UsersGuide.html#_launch_the_clojurescript_repl after cljs.repl> prompt appears, if I try to call anything I get 'no applicaiton has connected to the repl server' it looks like it can be a problem with my app type, :node-script any ideas?#2019-08-0518:50alexeizshadow-cljs.edn is here: https://pastebin.com/JpmhZpNg#2019-08-0519:11thheller@alexeiz you need to run the actual :node-script yourself to REPL into into#2019-08-0519:11thhellerif you just want a node REPL you can run shadow-cljs node-repl#2019-08-0519:11thhellerbut I don't know how that is integrated with emacs#2019-08-0519:11thhelleryour config is fine and you'd just need to run node target/main.js#2019-08-0519:11thhelleronce that is running you can eval things in the REPL#2019-08-0519:14alexeizsorry, it doesn't make sense to me. I ran shadow-cljs node-repl in another terminal, it said shadow-cljs - connected to server, but emacs REPL still gives the same error#2019-08-0519:39thheller@alexeiz I'm sorry but I don't know how cider works either. It should ask you which build to connect to and in this case it would be :node-repl#2019-08-0519:42alexeizI just tried it, the error I get is 'no build with id: :node-repl'. The only thing that works is ':app' because it's defined in my shadow-cljs.edn#2019-08-0519:45alexeizand in fact this is what the user guide says too#2019-08-0519:50thhelleryes and that will work if you just run the node process manually#2019-08-0519:50thhellerI really cannot comment on the cider side of things#2019-08-0520:07alexeizhow exactly will that work? can you be more specific?#2019-08-0520:08alexeizwhat you suggested earlier does not work, I get 'no build with id: :node-repl' error.#2019-08-0520:09thhellermore specific on what? if you want to REPL into :app you need to run node target/main.js manually elsewhere#2019-08-0520:09thhellerif you want to REPL into node-repl I can't help you since I have no clue how cider handles that#2019-08-0520:10thhellerthe error you get might be from cider trying to start a node-repl build which would be incorrect#2019-08-0520:10alexeizmy current main does nothing (defn main []), node target/main.js immediately exits#2019-08-0520:10alexeizremind you it's a nodejs script#2019-08-0520:10thhellerwell ok the you probably want node-repl but I cannot comment about the cider parts#2019-08-0520:11thhelleryou'll see that if you run shadow-cljs node-repl you get a REPL right away#2019-08-0520:12thhelleryou can switch to that via nrepl but I have no clue how to do that in cider#2019-08-0520:12thheller(I commented in #cider)#2019-08-0520:14lilactown@alexeiz it doesn’t sound like shadow-cljs node-repl is what you want. What should happen is: 1. Run cider-jack-in-cljs, choose shadow for repl type, and then enter your node app build ID. If it asks you to open a browser window, say no. 2. Once you see the “build completed” message for the first time in the CIDER REPL buffer, in a terminal session run node <path/to/output.js> like configured in your shadow-cljs.edn If you have devtools enabled, it should start the app and keep it open, hot loading your changes while you develop your app#2019-08-0520:19thheller@lilactown it is better to just use node-repl since there is no point linking to a specific build if you just want a REPL#2019-08-0520:21ChrisIs there a trick to getting node_modules to be accessible in a CLJS repl for a :browser configuration? I'm trying to use the aws-sdk and I keep getting a module$node_modules$aws_sdk$lib$aws error#2019-08-0520:21ChrisEr, ReferenceError: module$node_modules$aws_sdk$lib$aws is not defined#2019-08-0520:21colinkahnThis maybe my own misunderstanding about how macros get compiled, but I put together a gist for a usecase I have that won’t recompile when I change a .clj file that .cljc file depends on that exports a macro I’m using: https://gist.github.com/colinkahn/2bbeac1573f923e187301704a7283cd3 What I’m seeing is that if you change something in settings, like the foo def, no matter which file you save that won’t be recompiled with project.module or project.core.#2019-08-0520:23thheller@colinkahn yes macro dependencies are not tracked properly and trigger no recompiles. see https://github.com/thheller/shadow-cljs/issues/495#2019-08-0520:25colinkahn@thheller what’s the difficulty of tackling something like that? I’d be interested in trying to fix it if you think it’s not too hard.#2019-08-0718:01thhellerthe macro reload issue should be fixed in 2.8.45#2019-08-0520:26thhellerhard to say. I'm not sure how I'm gonna address this myself yet#2019-08-0520:27thhellerbut I'll do it in the next few weeks as part of the CT funding#2019-08-0520:27colinkahnOh awesome!#2019-08-0520:28thhellerits not a super easy problem though so i'd say medium to hard maybe#2019-08-0520:28colinkahnIf it helps I can create a reproduction repo and add to that ticket#2019-08-0520:28thhellerno need thx#2019-08-0520:29Chris@thheller - if we're building a :browser target can we still access the NPM modules automatically? The docs seem to suggest that should be straightforward - but for some reason I can't get things to work in my REPL - is there a :browser example with npm dependencies anywhere that I could take a look at?#2019-08-0520:30thheller@chris547 yes that generally should work. just fire up shadow-cljs browser-repl and run (require '["whatever-from-npm" :as x])#2019-08-0520:31thhellernot 100% of all packages work though so look at the console log if something throws on load or so#2019-08-0520:31thhellermay need some additional config sometimes#2019-08-0520:31ChrisOkay great, thanks for responding - I'll try that right now#2019-08-0520:42Chris@thheller - that appears to work - thanks! That wasn't working with a watch but the browser-repl seems to be much better#2019-08-0520:48thhellerit should be working normally with watch#2019-08-0520:48thhellerbrowser-repl is just a watch with a default config#2019-08-0520:50Chrisokay, let me take a closer look now that I have somethign working to compare with#2019-08-0520:52Chris@thheller - I think the problem is that when I try to connect via Cursive to the nREPL port - things don't work well - but running shadow-cljs browser-repl does from the resulting prompt#2019-08-0520:53thhellerthat shouldn't make the difference at all#2019-08-0520:53thhellerit certainly doesn't affect the npm processing in any way#2019-08-0521:03Chris@thheller - thank you for your patience - it looks like if i connect with Cursive and then run (shadow/watch :browser-repl) (shadow/repl :browser-repl) then I can connect like the prompt#2019-08-0521:04ChrisI had named my target :frontend and was trying to use those commands with :frontend#2019-08-0521:05thhellerwell you should connect to the REPL for your build if you have one#2019-08-0521:05thhellerso if you have a watch for :frontend running you should REPL into that too#2019-08-0521:06thheller(shadow/watch :browser-repl) won't work if its not already running#2019-08-0521:12ChrisI think I have my :frontend configuration somehow different than :browser-repl - is there an example configuration you can point me to for browser+npm dependencies?#2019-08-0521:21thhellerthere is no configuration you need to set#2019-08-0521:23thhellerthe absolute most basic :browser config should just work out of the box#2019-08-0521:30Chris@thheller - okay it seems to be there's a difference between `(ns io.foo.organization (:require ["aws-sdk" :as AWS]))` and (require '["aws-sdk" :as AWS]) - when I run the latter it seems to load the module, but the ns require seems to not load the AWS var properly#2019-08-0521:33thhelleris there a stacktrace in the browser console?#2019-08-0521:34thhellerthe ns require should be fine since it does exactly the same#2019-08-0521:40ChrisNo stacktrace when I execute ns however, when I try to reference AWS I get this:
ReferenceError: module$node_modules$aws_sdk$lib$aws is not defined
    at eval (eval at <anonymous> (), <anonymous>:1:1)
    at 
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
    at WebSocket.<anonymous> ()
#2019-08-0521:41Chrisbut then I can execute (require '["aws-sdk" :as AWS]) in the same namespace and then the AWS reference begins to work properly#2019-08-0521:43thhellerah you execute ns in the REPL?#2019-08-0521:43thhellerI thought you were loading the file normally#2019-08-0521:43thhellertotally possible that there is a bug related to ns in the REPL#2019-08-0521:44ChrisYes, I connect, then open the file in Cursive and execute the ns s-expression in the REPL#2019-08-0521:45thhellerand that works in a freshly launched shadow-cljs browser-repl but not in a regular :browser build?#2019-08-0521:46Chrislet me verify#2019-08-0521:47thhellerI'm off to bed now, will take a look tomorrow#2019-08-0521:48ChrisThe result is the same - the ns command returns nil but does not create the AWS references in the :brower-repl version#2019-08-0615:02Chris@thheller - just closing the loop on this - the namespace I was working in was in a file that wasn't referenced by anything in my app namespace. I was starting a REPL then trying to load this new ns in the REPL - at that point it wouldn't load npm references in the ns macro and so I had to use the (require..) function in the namespace. Thinking on it overnight I realized that this new ns wasn't referenced by the app and so I added it to the app's ns and now things work. So, I don't know if that's intended or not but it looks like there just has to be a path to the desired ns at repl startup or else things get a little off. Thanks for your help and for making such a great tool.#2019-08-0615:02thhellerit is already fixed in master. there was a race condition. so it would try to create the variable for the aws import before they were loaded#2019-08-0615:03thhellerwill make a release later today where everything should be working as expected#2019-08-0615:10Chris:exploding_head: - wow - amazing that it's fixed already. Thanks for caring so much about it!#2019-08-0616:30thheller2.8.43 is out. let me know if things still don't work right#2019-08-0616:32ChrisGreat, will update and try again - thanks!#2019-08-0618:29ChrisYes, that seems to have fixed it - thanks again for the quick turn around!#2019-08-0521:50Chrisokay, thanks @thheller - appreciate your time!#2019-08-0618:54kasukoHello, while migrating our application to shadow-cljs I am running into issues trying to get the code to run with a release. The code runs fine in dev mode. However, when I run it as a release I get an Invarient Violation from React. It seems like React is eating up the error so I can't figure out what is going wrong. Is there a way I could do the advanced compilation but some how set the NODE_ENV to development so React will give me the error?#2019-08-0619:02StefanI’m a shadow-cljs beginner really, so I don’t have the answer, but do you know about shadow-cljs check? Maybe it helps, I would have liked to know about it earlier a few months ago 🙂#2019-08-0619:05kasukoI have run shadow-cljs check and it gives me some warnings. Most warnings are in external library code, but none that seem like they would break only in a release#2019-08-0619:29thhellerhmm no that is not currently overrideable#2019-08-0619:29thhellerdo you have :infer-externs :auto turned on? it is most likely related to missing externs and using property access for something https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-08-0714:41kasukoWhew! That was a crazy issue. Ultimately it had little to do with shadow-cljs. We had an in-house JavaScript library called paradigm and when we did the original interop with lein we just had it provide the same namespace that the global object provided paradigm. However when I followed the technique described to convert CLJSJS packages things went wrong in a weird way when released. Somehow the code was optimizing in a way that js/paradigm was resolving to the cljs paradigm namespace rather than the paradigm that we exported globally. I have no clue why this was happening only on a release build but worked fine in dev. Changing the namespace to avoid clashing with the global object fixed it.#2019-08-0619:22neupshI cannot seem to make "release" build of my firebase app work. My development build runs fine. If I serve the js files compiled using shadow cljs normal build using firebase serve, the app works, but if i do shadow-cljs release main (main is the app build), and do firebase serve I get errors for firebase. It does not initialize firebase and app does not show up. Is there a way to test advanced build using shadow-cljs?#2019-08-0619:22neupshI tried
:dev {:compiler-options
                      {
                       :optimizations :advanced
                       :closure-defines {re_frame.trace.trace_enabled? true
                                         day8.re-frame.tracing.trace-enabled? true

                                         ;goog.DEBUG false
                                         }}}
#2019-08-0619:22neupshbut for the main build but i cannot seem to force shadow-cljs to do :advanced optimizations on the build#2019-08-0619:30thheller@neupsh there is shadow-cljs release main --debug#2019-08-0619:30thhellerbut re-frame trace stuff won't work in release builds#2019-08-0619:31neupsh@thheller I have only used tracing on :dev,#2019-08-0619:33neupsh@thheller is there a way to force :optimizations :advanced on the normal (non-release) builds? using that key value on compiler-options did not seem to create advance optimized builds#2019-08-0619:36neupshWhat I am facing is : Uncaught TypeError: firebase.initializeApp is not a function on the "release" version#2019-08-0619:48thhellerpretty much the only difference between dev and release is advanced#2019-08-0619:49thhellerwhat is firebase in your app?#2019-08-0619:56neupshit should be https://github.com/firebase/firebase-js-sdk/blob/master/packages/firebase/app/index.ts#L19#2019-08-0619:57neupshbut since I am using https://github.com/deg/re-frame-firebase, i think it is getting initialized twice (wrongly in release build)#2019-08-0619:57neupshwhen i debug, I can see it is just an object instead of the actual firebase object in the js code, but since this only happens in advanced optimization, i am not sure why it is happening#2019-08-0619:58thhellerit is more important to know how YOU use it. in your code I mean#2019-08-0619:58thhellernot the node_modules code#2019-08-0619:59thhellerthat re-frame lib for example is depending on a global variable#2019-08-0619:59neupshi use the re-frame-firebase library. I don't call firebase directly.#2019-08-0619:59neupshmay be it is in conflict with the firebase I have in the package.json file. Let me try to remove the one in package.json and try again#2019-08-0620:01thhellerno you need it in package.json#2019-08-0620:01thhelleras far as I can tell this should be working or not at all (so also not in dev)#2019-08-0620:01thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/firebase/app.cljs#2019-08-0620:02thhelleryou are basically relying on this "shim" to create the global js/firebase that library uses#2019-08-0620:02thhellerI'm gonna take a wild guess and say that it is expecting an older version#2019-08-0620:02thhellerand you probably just have a newer version isntalled#2019-08-0620:02thheller[cljsjs/firebase "5.7.3-1"]#2019-08-0620:03thhellercheck which version you have under cat node_modules/@firebase/app/package.json#2019-08-0620:12neupshi do have newer version 🙂#2019-08-0620:13thhelleryou might be able to copy this file to your src directory#2019-08-0620:13thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/firebase/app.cljs#2019-08-0620:13neupshthank you for the pointers. I will check more. I am surprised that it works with shadow normal build#2019-08-0620:13thhellerand change it to
(ns 
  (:require ["@firebase/app" :default firebase])
#2019-08-0620:13thhelleryes that surprises me too#2019-08-0620:16thhellerwhich version do you have? I want to test something#2019-08-0620:18neupsh
"name": "@firebase/app",
  "version": "0.4.11",
...
#2019-08-0620:18neupshthat is from your command#2019-08-0620:18neupshthis is from my pagckage.json: "firebase": "^6.3.1",#2019-08-0620:18neupshi think 6.3.1 is the general version and 0.4.11 is the "app" module version#2019-08-0620:19thhellerhmm yeah makes sense#2019-08-0620:19neupshI am very new to front end development so still confused with alot of things 🙂#2019-08-0620:19thhellerwelcome to the madness that is JS 😉#2019-08-0620:19neupshhaha#2019-08-0620:21thhelleroh before I forgot which build target do you use?#2019-08-0620:22thhellerit is working fine for me in a :browser build#2019-08-0620:23neupshit is browser#2019-08-0620:24neupshI am 99% sure it is because of that reframe library#2019-08-0620:24thhellerwith multiple :modules maybe?#2019-08-0620:25neupshi only have one :modules {:main {:entries []}}#2019-08-0620:26thhelleryeah I'm unsure why it would be working in dev but not release#2019-08-0620:27thhelleryou can try making a release build and then when loading it in the browser you can check via the console if there is a firebase variable#2019-08-0620:27thhellerthere should be#2019-08-0620:27neupshi can actually see it in the global variable#2019-08-0620:28thhellermaybe try compiling with shadow-cljs release main --pseudo-names and debug it in the browser#2019-08-0620:28thhellershould be some clue in there#2019-08-0621:45neupshI will try that.#2019-08-0700:17benwen@neupsh I've been trying to elucidate that exact behavior myself for the last three weeks. I also use re-frame-firebase#2019-08-0700:19benwenSimilarly, I’ve traced it down to a double declaration of “var firebase” that in the re-frame-firebase initialization scope overloads the goog.exportSymbol’s firebase. I’ll try the above recommendations too and report back if that helps debug. Thank you.#2019-08-0701:09neupshIn the "advanced optimized" js if i search for "firebase" I see two places where that var is assigned a value. One for global and one for local (in scope of that reframe lib node module init function).#2019-08-0701:11neupshThe global one has correct value right after it is assigned, but the local scoped one is initialized as an empty object and then for each modules (sub modules?) they are added as properties of the "firebase" local object. Now, this object may have those submodules, but it does not have the "initializeApp()" method as it is never added to that object.#2019-08-0701:12benwenyes, in the debugger, at the point firebase.initializeApp is called, firebase is a nearly empty object, with properties (this is from my recent memory, so may be missing things)#2019-08-0701:14benwen{auth: {}, database: {}, firestore: {}} which is also initialized in that containing scope by a similar assignment to the var firebase = {app: {}} (I’m using :simple optimizations, so the app: {} nor other empties are being optimized out, forgot to mention that)#2019-08-0701:14benwenimmediately prior to use of say firestore, there’s a dummy dec’l firebase.firestore = {}#2019-08-0701:15benwenBTW, did you get --pseudo-names to do anything useful, I’m on the horns of that now, with a … TypeError : $s$$.substring is not a function#2019-08-0701:16benwenseems to be on the second call leading up to that form#2019-08-0701:16benwenSeparately, I have a minimal app that exhibits this “firebase.initializeApp not a function” behavior that I can share#2019-08-0702:35neupsh@U20AW42V7 I have not got around to try that yet 🙂 I only get to play with clojure(script) off work.#2019-08-0703:49neupshTried to spend some time without any progress.. I will continue tomorrow. Lets get to the bottom of this 🙂#2019-08-0706:56thheller@U20AW42V7 please share the repo if you can. happy to dig into that#2019-08-0707:00benwen@thheller I’m in the middle of cleaning it up right now, thank you. Last minute npm wrestling.#2019-08-0707:13benwenhttps://github.com/benzenwen/re-frame-firebase-shadow-cljs-interaction-test/tree/master#2019-08-0707:15thhellerthanks. I'll take a look#2019-08-0707:15benwenApologies for letting /semantic sneak in there! Thank you for shadow-cljs. Am going to turn in for the evening.#2019-08-0707:45benwenone last thing, I have a fork of shadow-cljsjs and/or re-frame-firebase that seems to supress the :dev build warning:#2019-08-0707:45benwen‘‘’ Warning: Firebase is already defined in the global scope. Please make sure Firebase library is only loaded once. shadow$provide.module$node_modules$$firebase$app$dist$index_cjs @ index.cjs.js:484 shadow.js.jsRequire @ js.js:63 shadow.js.require @ js.js:97 (anonymous) @ firebase.app.js:3 ‘’'#2019-08-0707:45thhellerI found the problem I think#2019-08-0707:45benwenoh, that’s encouraging#2019-08-0709:04thhelleryeah problem is fixed in master. will make a release a bit later#2019-08-0713:33neupshOMG @thheller I could not thank you enough 🙂#2019-08-0714:31benwen@thheller Thank you, that is awesome! 🙏#2019-08-0717:59thhellerfixed in 2.8.45#2019-08-0718:04neupshI can confirm it works now. Thank you very much @thheller#2019-08-0718:11neupshI have another issue with "styling" and layout on the advanced build (material-ui) but that may not be related to this issue. I will create another thread if needed one.#2019-08-0719:27benwenThank you @neupsh for bringing up the issue. I thought I was going crazy. Was starting to dig through shadow-cljs codebase.#2019-08-0713:01Chris@thheller Is there an issue around anonymous functions in CLJS/shadow-cljs? When I execute (fn [foo] foo) it returns the following stack trace:#2019-08-0713:01Chris@thheller Is there an issue around anonymous functions in CLJS/shadow-cljs? When I execute (fn [foo] foo) it returns the following stack trace:#2019-08-0713:01Chris
SyntaxError: Unexpected token .
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at 
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at 
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
    at WebSocket.<anonymous> ()
#2019-08-0713:02ChrisHowever, calling (fn foo-fn [foo] foo) seems to work as expected#2019-08-0713:17thhellernothing that I know of but I'll look into it#2019-08-0716:19thhellerthere is indeed something buggy going on. wonder why that happens though#2019-08-0716:19thhellerit is trying to eval (function cljs$user$cljs.user.cljs(foo){\r\nreturn foo;\r\n}) which is invalid JS#2019-08-0717:58thhellerfixed in 2.8.45. was only causes by anon-fns defined directly in the REPL, not nested ones. guess thats why nobody complained about that before#2019-08-0718:27ChrisNice, thanks for fixing so quickly! Really appreciate it - I"ll verify it shortly#2019-08-0714:10denikrunning into this on the command line.. ideas?
shadow-cljs release app
shadow-cljs - config: /Users/den/Dropbox/dev/code/zeal/shadow-cljs.edn  cli version: 2.8.42  node: v8.11.1
shadow-cljs - connected to server
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:381).
shadow.cljs.devtools.cli
#2019-08-0715:41neupshwhat version of java are you using?#2019-08-0716:01thheller@U050CJFRU how did you start the server? if you are starting the server in a custom embedded way and intent on using the command line you need to require shadow.cljs.devtools.cli wherever you start the server#2019-08-0807:53denik@thheller ah! 💡💡💡. I started it embedded but wanted to build from the command line. Ended up building from the REPL (embedded as well) so it all worked out in the end. good to know, thanks!#2019-08-0715:24andrewzhurovShort: Is there a way to supply additional :dependencies for a build? as with clj's :extra-deps Long: In a shadow-cljs project, I'm having two build aliases, which are being used as
shadow-cljs watch local
shadow-cljs release prod
I'm using re-frisk as a dependency, How would I include re-frisk as dependency only for :local build? i.e. not include it in :prod
#2019-08-0715:35neupshare you looking to add dev dependencies?#2019-08-0715:36neupshI use something like below:
{:builds
 :dependencies [[re-frisk "version"]]
 {:local
  {:target :browser
   :devtools {:preloads [[re-frisk.preload]]}}
   :dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
         :extra-deps {
                        nubank/workspaces {:mvn/version "1.0.9"},
                        binaryage/devtools {:mvn/version "0.9.10"}
                        day8.re-frame/re-frame-10x {:mvn/version "0.4.1"}
                        day8.re-frame/tracing {:mvn/version "0.5.1"}
                        }
                 }

  :prod
  {:target :browser}}
 }
#2019-08-0715:39neupshI also use deps.edn to define that :dev like:
{:paths [...]
 :deps {;actual deps here
            }
:aliases {:dev {:extra-paths [...]
                        :extra-deps {...}
              }
}
` and in shadow-cljs.edn :
{:deps {:aliases [:dev]}
 :builds {:local ...}} 
...
}
#2019-08-0715:40neupshinstead of dependencies in the shadow-cljs.edn file#2019-08-0719:32andrewzhurovyea, I am curious how to have a dependency in the run-time of a build, cool that we've got this smart inference of deps-in-use https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_script#2019-08-0716:03thheller@brownmoose3q it doesn't matter if re-frisk is on the classpath or not. it is only included in a build if the build uses it. its presence on the classpath is not relevant#2019-08-0719:26andrewzhurova neat feature, eases dev's life :+1:#2019-08-0719:30andrewzhurovha.. My mind was seeking for the solution, ability to supply an extra dep, filtering other approaches The spot in the doc about inferring deps-in-use jumps in your eyes straight away. 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_script#2019-08-0716:03thheller:preloads are only used in development builds so it automatically won't be included in the release build#2019-08-0720:11Daniel LeongIs there a way to get compile warnings/errors via nrepl? With figwheel when I use the load-file op it responds with err messages (ex: {'id': '874b6a4f-5419-4acc-3f82-bdca8708ac7d', 'session': 'acf389b9-51cb-4231-8499-1a9ee17fa53d', 'err': 'WARNING: No such namespace: str, could not locate str.cljs, str.cljc, or JavaScript source providing "str" at line 24 /path/to/file.cljs^@'}) but shadow-cljs just responds with a {'status': ['done'] ...} message#2019-08-0720:12thhellererrors are reported to whereever the watch was started. did you maybe not start the watch via nrepl in the first place?#2019-08-0720:13Daniel LeongAh, no I usually start the watch via cli and connect to nrepl via vim/fireplace#2019-08-0720:21Daniel LeongI tried starting the watch over nrepl by evaluating the (shadow/watch :app) API but load-file still just returns ['done']#2019-08-0720:22Daniel LeongI used shadow-cljs start to start a background server, if that makes a difference#2019-08-0720:25Daniel LeongTo be clear, the CLI (if I do shadow-cljs watch :app) and the webpage (via the HUD/overlay) both report the errors just fine, but I was hoping to also get them via the nrepl connection for displaying in Vim#2019-08-0720:30thhellerplease open an issue. too tired to look into it now. could be that load-file errors just aren't properly forwarded to all places#2019-08-0720:30Daniel LeongWill do, thanks!#2019-08-0807:48carkh@thheller you told me shadow-cljs now works with powershell (i didn't check that). But i don't have the cli tools for powershell anymore and it still works. Are you first checking the regular cmd path ?#2019-08-0807:48carkhor maybe my version of shadow-cljs is old#2019-08-0807:49thhellerno it isn't checking anything, it just directly executes the powershell cmd (assuming Windows and using deps.edn)#2019-08-0807:49thhellerwasn't aware there were usable alternatives#2019-08-0807:49thhellercan add a check if needed though#2019-08-0807:50carkhi was just curious as to how it is working here =)#2019-08-0807:50thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L411-L414#2019-08-0807:52carkhi'm guessing we're going inside powershell,n then out to get my cli#2019-08-0807:52carkhas long as it works it's all fine#2019-08-0807:52carkhthanks#2019-08-0809:43hlolliI'm not sure if it's my side or shadow's. It seems that on react-native with shadow version 2.8.41 or later sometimes failes to spit big chunk of the .js files. This happens on mac and on our ci build, but on my local linux, the js files are filled with correct data (not unlikley due to cache-ing). The error is goog is not defined, but I cant imagine what causes half of the file's data to go missing.#2019-08-0809:46hlollihere's from mac
cat tests/tests.first_test.js
goog.provide('tests.first_test');
goog.require('cljs.core');
test("Adds 1 + 2 to equal 3",(function (){
return expect(((1) + (2))).toBe((3));
}));
#2019-08-0809:46hlolliand here is from (likely) cached linux
var $CLJS = require("./cljs_env");
var $jscomp = $CLJS.$jscomp;
require("./cljs.core.js");
var module$shadow_js_shim_module$react=$CLJS.module$shadow_js_shim_module$react || ($CLJS.module$shadow_js_shim_module$react = {});
var clojure=$CLJS.clojure || ($CLJS.clojure = {});
var cljs=$CLJS.cljs || ($CLJS.cljs = {});
var shadow=$CLJS.shadow || ($CLJS.shadow = {});
var goog=$CLJS.goog || ($CLJS.goog = {});
var reagent=$CLJS.reagent || ($CLJS.reagent = {});
var app=$ || ($ = {});
var taoensso=$CLJS.taoensso || ($CLJS.taoensso = {});
var module$shadow_js_shim_module$create_react_class=$CLJS.module$shadow_js_shim_module$create_react_class || ($CLJS.module$shadow_js_shim_module$create_react_class = {});
var tests=$CLJS.tests || ($CLJS.tests = {});
var module$shadow_js_shim_module$react_navigation=$CLJS.module$shadow_js_shim_module$react_navigation || ($CLJS.module$shadow_js_shim_module$react_navigation = {});

$CLJS.SHADOW_ENV.setLoaded("tests.first_test.js");

goog.provide('tests.first_test');
goog.require('cljs.core');
test("Adds 1 + 2 to equal 3",(function (){
return expect(((1) + (2))).toBe((3));
}));

module.exports = tests.first_test;

//# sourceMappingURL=tests.first_test.js.map
#2019-08-0809:52hlollithis doesn't happen in 2.8.37, so for my mac, this truncation only happens 2.8.41+#2019-08-0810:43thheller@hlolli not sure which truncation you are talking about? the output you showed is "old". that is not the current output format#2019-08-0810:43hlolliyes that's right, it's old, after nuke-ing the lockfile and node_modules, I can reproduce it on mac and linux.#2019-08-0810:44hlolliwith a new output format, I guess we need to change the way we require index.js?#2019-08-0810:44thhellerplease take a step back and explain what your actual problem ist#2019-08-0810:44thhellerthe source files that are generated have changed#2019-08-0810:44thhellerso comparing them the old stuff is pointless#2019-08-0810:44hlolliok, my initial reaction was that this change was the bug#2019-08-0810:45thhellerindex.js require should be the same but depending on what you were doing it maybe changed?#2019-08-0810:46hlollifor example "jest --verbose tests/*" where
"testMatch": [
            "**/*+(_test).js"
        ]
is my matcher
#2019-08-0810:46thhellerhow are tests relevant to a :react-native build?#2019-08-0810:46hlollithis will try to open files that don't have the goog in its environment#2019-08-0810:47hlolliwe are testing react-native app and this worked fine before#2019-08-0810:47thhellerI still don't get what you are doing#2019-08-0810:48thhellerthe only file you were supposed to be using was <output-dir>/index.js#2019-08-0810:48thhellerall of the others were implementation details and not intended for direct use#2019-08-0810:48hlolliwe were doing
import './app/shadow.cljs.devtools.client.react_native';
import { init } from './app/app.core';
init();
so we were using it wrong.
#2019-08-0810:48thhelleruhm you are using some old setup?#2019-08-0810:49thhelleryou should just be calling import "./app/index.js"#2019-08-0810:49hlolliyes, I knew about the index file, since it worked, we didn't change it. But I'll change it now 🙂#2019-08-0810:49thhellerit was never meant for you to be used that way#2019-08-0810:49thhellerif you want to use this that way#2019-08-0810:49thhellerjust switch to :npm-module target#2019-08-0810:50thhellerbut then source maps still won't work#2019-08-0810:50hlolliI'm all for better source maps! Excited to see them#2019-08-0810:50thhellerfor them to work I had to switch the output format#2019-08-0810:50thhellerwhich is why everything is now in index.js itself#2019-08-0810:51thhellerand the "supporting" files are only there because otherwise metro throws an exception when an error is thrown in the app#2019-08-0810:51thhellerthey aren't actually used for anything#2019-08-0810:51thhelleronly index.js matters and contains all code#2019-08-0810:51hlolliah I see#2019-08-0810:51hlollicleaver#2019-08-0810:52thhellerif you want to run tests with jest I'd suggest creating a secondary :npm-module build#2019-08-0810:52hlolliyes, exactly#2019-08-0810:52thhellerthat output will still behave as before#2019-08-0810:52hlollimakes all sense now#2019-08-0813:27Daniel LeongI thought I would poke around on my nrepl issue and ran into an issue following the CONTRIBUTING.md, is it out of date?#2019-08-0813:27Daniel Leong
lein with-profiles +cljs repl
Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1).
Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1).
Error loading shadow.cljs.devtools.server.nrepl: Syntax error compiling at (shadow/cljs/devtools/server/nrepl.clj:1:1).
Syntax error compiling var at (/private/var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/form-init6039849328054616621.clj:1:10151).
Unable to resolve var: shadow.cljs.devtools.server.nrepl/cljs-load-file in this context

Full report at:
/var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/clojure-2400420031541069613.edn
Subprocess failed
REPL server launch timed out.
Error encountered performing task 'repl' with profile(s): 'base,system,user,provided,dev,cljs'
REPL server launch timed out.
#2019-08-0813:29thhellernot sure what that is about. I start everything with that command?#2019-08-0813:29thheller
$ lein -v
Leiningen 2.9.1 on Java 11.0.2 OpenJDK 64-Bit Server VM
#2019-08-0813:30SaikyunI'm trying out react native + shadow-cljs, and I've managed to turn off live reload for the mobile, but do you know how to do it for expo web?#2019-08-0813:30Daniel Leong
lein -v
Leiningen 2.9.1 on Java 1.8.0_144 Java HotSpot(TM) 64-Bit Server VM
#2019-08-0813:30thheller@saikyun I did not try expo web at all yet so I don't know anything about that#2019-08-0813:31Saikyunall right, thanks. it seems like shadow-cljs will work great with it -- the cljs-reload is super fast, sadly after expo (or metro?) is done "compiling" it reloads the whole page, resetting all state x)#2019-08-0813:31Saikyunit's almost comical how I see the cljs-changes before it starts reloading#2019-08-0813:32Saikyunlol, I "solved" it; I could just turn off the expo-process#2019-08-0813:33thhellerhehe#2019-08-0813:34Saikyunanyway, I'll come back if I find anything helpful#2019-08-0813:56p-himikIs there any way to set optimizations to :none for {:js-options {:js-provider :shadow}}? Debugging with source maps is PITA.#2019-08-0813:58p-himikFound this in a seemingly relevant context:
;; :whitespace or :simple work but some patterns really require the DCE done by :simple
;; eg some conditional imports done by react&friends
So apparently the answer is no. Oh well.
#2019-08-0814:02thhelleryeah :simple is a must but you can use {:source-map false :pretty-print true :variable-renaming :off}#2019-08-0814:02thhellerthat should be relatively close to the original#2019-08-0814:02thhellerbut what are you debugging precisely?#2019-08-0814:04p-himikHmm. Do I just put those right in :js-options? I'm trying to debug a nice library called react-beautiful-dnd. Not sure why, but it seems that the source maps are not aligned with the source code itself - breakpoints are set on different lines, and when they hit I get a completely different context from what I'd expect. I'll try cleaning everything and rebuilding.#2019-08-0814:06thhellersource maps might be off by one line. couldn't figure out how to fix that yet#2019-08-0814:15thhelleroh and yes under :js-options#2019-08-0814:18p-himikIt seems that apart from the line numbers, the names are also off. There can be a variable x with some particular content but in the Scope panel its content resides within y. Whereas y could not possibly have such a value. But it may be an issue with V8 (I think?) optimizing some variables away. It basically removes some of the variables completely, and you cannot disable it. Drives me nuts.#2019-08-0814:19p-himikThanks, I'll try the options.#2019-08-0814:27thhellerif you have something reproducible I can take a look. I got some experience debugging weird JS code 😉#2019-08-0815:05p-himikThank you for the offer, I appreciate it. Beware though - I might just follow up on it if I get really stuck. 🙂#2019-08-0816:27p-himikOh... that would explain it. Check out this minified JS:
var _action$payload = action.payload;
      state = _action$payload.critical;
      action = _action$payload.dimensions;
state and action have been used before but now a piece of code const {critical, dimensions} = action.payload; has been turned into that abomination with variable reuse.
#2019-08-0818:31thhellernot sure what you mean?#2019-08-0818:39p-himikWhen const {critical, dimensions} = action.payload is represented as is, the Scope panel should correctly display variables named critical and dimensions. However, the above code is compiled into that snippet with var _action$payload which reuses variables. Because of that, the Scope panel now displays the value of action.payload.critical as belonging to the state variable. Of course, it is correct from the POV of the compiled code. But in this case, I can just throw away the original source code since it can't help me at all because of all the renaming and reuse.#2019-08-0818:40p-himikI wonder - is there a way to have only DCE optimization to avoid all those issues with reuse and code shuffling in general?#2019-08-0818:45thhellernot sure, there might be config option but its not exposed if there is#2019-08-0818:46thhellerif you can reproduce the error I'm still willing to look into it 😛#2019-08-0900:12p-himikHere's the SSCCE: https://github.com/p-himik/shadow-cljs-optimizations-test After you compile it with npm ci && shadow-cljs compile main, check the file at public/js/cljs-runtime/module$node_modules$react_beautiful_dnd$dist$react_beautiful_dnd_cjs.js and look for INITIAL_PUBLISH must come after a IDLE phase. Compare the following few lines to the code after the same string at node_modules/react-beautiful-dnd/src/state/reducer.js.#2019-08-0900:13p-himikNote that this is not an error per se. It's just the way the CLJS compiler reuses the variables that's annoying and makes the debugging much harder due to source maps not working in this case.#2019-08-0910:42thhellercan you describe what the actual problem is though? not sure what I'm supposed to be looking for exactly?#2019-08-0910:42thheller(no readme in repo)#2019-08-0910:56p-himikMy message with the link is basically the readme in this case. 🙂 If you mean the actual problem that I was trying to debug - that was not my intention to show it in this case. The issue is rather domain-specific and basically results from me trying to hammer a square peg into a round hole simply because there are no rounds pegs available. And I think I got it in the end - it works for now. The intention of the repo is to show how the optimizations make it much harder to debug anything for no apparent reason, even with those :js-options. Since between us you're the the only one with the relevant domain knowledge, I thought that maybe this behavior can somehow be changed, if that makes sense.#2019-08-0910:58thhellerwell I can't really help if I don't know what the problem is 😛#2019-08-0910:58thhellerI can maybe enable :whitespace again for debugging purposes#2019-08-0910:59thhellermaybe thats more useful for debugging#2019-08-0911:00p-himikOK, maybe I described it wrong. The essence of the problem is that code like const {a} = b; is compiled into something like variable_used_before = b.a; instead of just const a = b.a;. The variable reuse is what makes it hard to debug since the old value is now hidden and the name how has wrong semantics.#2019-08-0911:01p-himikBut if I understand it correctly, that's probably an issue with the CLJS compiler itself - I have no idea if Shadow-CLJS can even do anything in this case.#2019-08-0911:02thhellerthe CLJS compiler is not involved in any of that at all#2019-08-0911:02thhellerit is purely done by the google closure compiler#2019-08-0911:02thhellerand the cause of that rewrite is :simple optimizations#2019-08-0911:03thhelleryou are only describing that the code looks weird (which it does)#2019-08-0911:03thhelleryou are not saying WHY you are looking at that code in the first place#2019-08-0911:04thhelleroptimized code isn't intended to be readable#2019-08-0911:05thhellernode_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js this is the file shadow-cljs uses in the first place#2019-08-0911:05thhellerso there isn't even any const use in there
#2019-08-0911:10p-himikAh, right, thanks - I mixed up Google Closure and CLJS compilers. I guess in an ideal world the original JS files would not be changed at all for the development build, except maybe for DCE. Because e.g. the code like const {a} = b; can already be run in the modern browsers, which should probably be used for the main development workflow anyway. > you are not saying WHY you are looking at that code Because it's not relevant to the issue with the compiler itself. 🙂 "Give a man a fish" and all that. > optimized code isn't intended to be readable I agree. But because we have to run some optimizations even during development, it makes debugging hard - that's my whole point. > node_modules\react-beautiful-dnd\dist\react-beautiful-dnd.cjs.js this is the file shadow-cljs uses in the first place Oh... OK. Well const itself doesn't change anything thought - that file still got the naming correct. E.g. the relevant section has critical = _action$payload.critical which in the compiled version looks like state = _action$payload.critical. Again - there is no error here of any kind. It just makes it much harder to understand what's going on during debugging, regardless of the reason why someone is trying to understand what's going on.#2019-08-0911:12thhelleryeah whitespace would make that easier#2019-08-0911:12thhellerat the cost of losing DCE which will end up loading more code than needed#2019-08-0911:13thhellerbut given that you are only doing this for debugging it probably doesn't matter too much#2019-08-0911:23p-himikAwesome! Yes, I don't think loading extra code makes any significant difference for the development process. But it may differ for someone, so maybe making it configurable would make sense. But what about the "some patterns really require the DCE done by :simple" comment? Is there no way to somehow combine :whitespace and DCE or even have just DCE without any other optimizations?#2019-08-0815:18Daniel LeongHmm if I comment out the :nrepl-middleware in the :cljs profile it starts up#2019-08-0815:21Daniel LeongAh, also if I change the ..server.nrepl to ..server.nrepl04 in the :nrepl-middleware map#2019-08-0818:38thhellerstill wonder why it works for me and on CI but not on your machine#2019-08-0818:46Daniel Leong:shrug:#2019-08-0818:00David Pham@saikyun how do you turn off the expo-process?#2019-08-0818:03neupsh@saikyun you can't turn off the live reload, but you can workaround it#2019-08-0818:04neupshyou can block requests to /sockjs-node/* in chrome (didn't work on firefox)#2019-08-0818:05tianshufailed to use latest expo with latest shadow-cljs
error SHA-1 for file /home/tianshu/sandbox/expo-proj/awesome/app/rn-input.android.is (/home/tianshu/sandbox/expo-proj/awesome/app/rn-input.android.is) is not computed. Run CLI with --verbose flag for more details.
node v10.16.0 shadow-cljs 2.8.45 expo 34.0.1
#2019-08-0818:31thheller@doglooksgood not sure what that is about. it is not an error from shadow-cljs#2019-08-0818:37Saikyun@neo2551 Ctrl-C#2019-08-0818:37Saikyun@neupsh thanks for the tip 🙂#2019-08-0818:41David PhamThanks :)#2019-08-0819:15tianshu@thheller just saw your reply on clojureverse. I switch to :react-native and it works great!#2019-08-0915:13kasukoHas anyone encountered Chrome throwing insufficient resource warnings in dev mode because it's trying to fetch too many JS files?
GET  net::ERR_INSUFFICIENT_RESOURCES
#2019-08-0915:20neupshtry
:devtools {
                   :loader-mode :eval
}
#2019-08-0915:21neupsh:loader-mode :eval in :devtools of your build in shadow-cljs.edn#2019-08-0915:23kasukoGiving it a go#2019-08-0915:56kasukoNot sure if it's related but now I seem to be unable to compile my application#2019-08-0915:59kasukoOh, that only happens if I try npx shadow-cljs watch app without a running server#2019-08-0915:59kasukoIf I start the server first then watch the app it works fine.#2019-08-0915:59kasuko@U3MRWH35M What does the :loader-mode :eval do?#2019-08-0916:11neupshessentially creates one <script... tag instead of many#2019-08-0916:11neupshhttps://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-08-0917:40kasukoThanks! Also shocking that article contains the exact answer someone else just asked in channel, you have psychic powers or something 😛#2019-08-0918:13neupshlol . I had read that article when it came out, but didn't need it recently. so i had to ask what was that configuration to do that in the channel some weeks back. now I remember it pretty good.#2019-08-0915:14kasukoCurrently converting a large project from Leiningen to Shadow-CLJS and the number of requests went from 675 with lein+figwheel to 1739 requests with shadow-cljs#2019-08-0915:20kasukoThe memory on my machine doesn't appear to be under much strain and I have tried completely restarting chrome#2019-08-0915:59alpoxI have a short question regarding import/requires of npm libraries. Some libraries - for example RXjs and Material-UI export their components in isolation (So the import would be basically ["@material-ui/core/Button" :as Button]) - which is the recommended import. I remember this enables easier Tree-Shaking for Webpack. Is there any downside in just importing multiple exports at once ["@material-ui/core" :refer [Button CircularProcess]] in shadow-cljs? I guess google closure should be able to remove unnecessary code well enough or am I mistaken?#2019-08-0917:35kasuko@alpox Well completely independant of your question I was linked this article to solve my unrelated problem, but it contains exactly your answer https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-08-0917:37kasukoThe article was written a year ago, I can't believe it uses the EXACT same example you provided.#2019-08-0917:38kasukoAs for your thoughts on the Google Closure compiler, I do know that the code from NPM is only run through :simple optimizations which means it won't do dead code removal#2019-08-0917:39kasukoSo including the full import will allow Shadow CLJS to only bundle the needed dependencies (simmilar to tree shaking webpack)#2019-08-0917:41alpox@kasuko Wonderful. Thanks! It works like charm 🙂#2019-08-0917:43alpoxI tried it before without loader-mode set to eval and the icons import took years when I referred to the whole icons namespace. It works now as before with a specified import 👍#2019-08-0917:53thheller@alpox :refer does nothing for DCE. you need the specific imports for now#2019-08-0917:53alpoxOh okay. Thanks for the response @thheller. I guess I'll have a big list of them then 😄#2019-08-0918:14kasuko@alpox Sorry didn't mean to indicate that the :loader-mode solved your question. I was stating that the article which solved a completely different problem had a "side rant" in it that actually answered your question#2019-08-0918:34deadghostI'm looking at code splitting. https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/app.cljs I take it there's currently no way to require a lazy loading namespace in :require and I need to def lazy-component wrap each fully qualified namespaced component. Is that right?#2019-08-1005:45thheller@deadghost yes if you directly :require the namespaces will be moved to that module and cannot be code-split#2019-08-1005:45thhellerlazy-component however is just a proof of concept that combines it with React components#2019-08-1005:46thhelleryou could just as well load an entire map for example if you want to group something#2019-08-1015:08gerreddoes shadow support service workers today?#2019-08-1015:11gerredi see web workers and maybe this is enough and I'm not as familiar as I'd like to be.#2019-08-1015:11gerredan new Worker vs navigator.serviceWorker#2019-08-1015:11gerredobviously I could still do it myself#2019-08-1016:26thheller@gerred yes the :web-worker true option also works for service workers#2019-08-1016:30gerred@thheller killer, thank you. would I just bind to the install/activate/fetch events? there's no higher level abstraction there yeah?#2019-08-1016:30gerred(i wouldn't want there to be, just making sure I understand correctly)#2019-08-1016:30thhelleryeah no abstraction at all. you do everything via interop#2019-08-1016:30gerred:+1:#2019-08-1016:30gerredkiller thank you#2019-08-1016:31thhellerI generally recommend using a better suited tool like https://developers.google.com/web/tools/workbox/#2019-08-1016:31thhellersince its mostly declarative type stuff#2019-08-1016:33thhellerbut I've only experimented with super basic service workers so CLJS might get better the more you do (if you do)#2019-08-1016:48gerredoh that's a good point#2019-08-1016:48gerredyeah I'd eventually at least like to develop my own toolkit, fortunately I'm not in a position where I need to be systemic about it#2019-08-1016:51tianshuis it possible to get the asset-path in code?#2019-08-1016:51thhellerjs/CLOSURE_BASE_PATH#2019-08-1016:52thhelleroh no wait thats only for dev builds#2019-08-1016:52thhellerno there is not#2019-08-1016:52tianshuokay#2019-08-1016:53tianshuwhat about to get it at compile stage via macro?#2019-08-1016:54thhellernot really no#2019-08-1016:54thhellerwhat do you need it for?#2019-08-1016:55thhellerI'd probably suggest using a closure-define?#2019-08-1016:57tianshuI want write a macro which used to define style in cljs. when the macro expand, generating css file to somewhere#2019-08-1016:57thhellerdon't#2019-08-1016:57thhellerside-effects during compilation are not a good idea#2019-08-1016:58thhellereg. they break caching#2019-08-1017:00tianshuif some cljs using this macro is already compiled, it will be cached and won't compile again?#2019-08-1017:00thhelleryes#2019-08-1017:02tianshubut does it matter if this macro will be used only in application code, not used as a dependency for library#2019-08-1017:03thhellerdepends on how you end up doing things#2019-08-1017:04tianshuI want to generate css, with following features 1. always keep the class property sync with the selector in css. 2. less runtime stuff, as static as possible 3. manipulate style with functions#2019-08-1017:04thhelleryou can do it of course. I just don't reocmmend doing side effects during macro expansion#2019-08-1017:05thhellerhttps://github.com/thheller/shadow/wiki/shadow.markup#2019-08-1017:05thhelleryou can look at the impl of that maybe#2019-08-1017:06thhellerdoesn't generate extra .css files but instead injects the css at runtime#2019-08-1017:10tianshuvery similar to my demand#2019-08-1017:13tianshuwhat is the proper way to invoke something in Clojure via CLJS#2019-08-1017:14tianshujust for development convenient#2019-08-1114:11mccraigmccraigis per-build-target :source-paths / :dependencies config possible in shadow, or do i need to include all test stuff in the top level ?#2019-08-1114:18p-himikI don't think it's possible with just shadow-cljs.edn but it's definitely possible with shadow-cljs.edn + deps.edn.#2019-08-1114:22mccraigmccraigha, that'll be something for the future then... i've had enough fiddling about with build-systems time (moving from boot-cljs -> shadow-cljs) to last me for a little while#2019-08-1114:54p-himikOh, but you won't need anything but Shadow-CLJS, even if you use deps.edn. It's just an additional flag in shadow-cljs.edn: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2019-08-1114:56mccraigmccraigit's the clj builds in the rest of the multi-module project still using lein which are stopping me... they will all need converting to deps.edn ...#2019-08-1115:03p-himikWell, Shadow-CLJS also supports Lein - just scroll a bit above. It doesn't describe a way to directly call shadow-cljs while specifying profiles but I bet you could do it if you launch it via lein itself.#2019-08-1115:09mccraigmccraigi definitely don't want more lein in the build 😬... all the clj build will be moving to deps.edn at some point soon, and i'm using gulp to run shadow atm, which is working very nicely#2019-08-1115:51thhellersource-path and dependencies are global yes. usually it doesn't matter whats on the classpath though since the build decides what goes into it not the classpath#2019-08-1115:08cjsauerRunning into TypeError: shadow.js.shim.module$react_native.Text is not a function while trying to use :react-native target. ns looks like this:
(ns my-app.mobile
  (:require ["expo" :as ex]
            ["react-native" :as rn]
            [rum.core :as rum]
            [shadow.expo :as expo]
            ))

(rum/defc root
  []
  (rn/Text #js {} "TEST"))

(defn ^:dev/after-load mount
  []
  (expo/render-root (root)))

(defn start!
  []
  (mount))
Seems like "react-native" is defaulting to some kind of shadow shim, but I’m likely doing something wrong…
#2019-08-1115:12cjsauerOh…I have to “adapt” the react element:
(rum/defc root
  []
  (r/createElement rn/Text #js {} "TEST"))
#2019-08-1115:12cjsauerWhere r is required like ["react" :as r]#2019-08-1115:12cjsauerWorks now 👍#2019-08-1115:14cjsauerLoving this source map support in react native. Amazing work.#2019-08-1115:52thhelleryou were calling (rn/Text #js {} "TEST") but Text is a react element not a function#2019-08-1115:53thhellerdunno how it works in rum but in reagent you'd use [:> rn/Text "Test"]#2019-08-1116:26cjsauerIndeed. Came up with this for now:
(defn >$
  [class props & children]
  (apply r/createElement class (clj->js props) children))

(def view (partial >$ rn/View))
(def text (partial >$ rn/Text))
#2019-08-1116:27cjsauerSeems to work fine using rum#2019-08-1116:28cjsauerI’m guessing the :> helper in reagent is doing something similar#2019-08-1117:02neupshis there a way to expose the shadow-cljs required module through the current namespace?#2019-08-1117:02thhellernot sure what that means?#2019-08-1117:03neupshfor example, if I have
(ns my.ns
  (:require ["@firebase/app" :refer [firebase]]))

(def firebase firebase)
#2019-08-1117:04neupshit would be nice to expose the backing "firebase" for when i need it in repl?#2019-08-1117:04thhelleryeah like that. just don't use the same name#2019-08-1117:04thheller(def firebase firebase)#2019-08-1117:04thhellerthat is a self reference and invalid#2019-08-1117:04neupshaah#2019-08-1117:05thheller
(ns my.ns
  (:require ["@firebase/app" :as x]))

(def firebase x/firebase)
#2019-08-1123:10TrevorHi folks, would shadow cljs be the appropriate tool to help with a Phaser 3 game written in clojurescript? (expect a bunch of js interop)#2019-08-1204:35tianshuIf ClojureScript is, the shadow would be a good tool.#2019-08-1207:23superstructorIs there a way to declare NPM dependencies in libraries so that those deps will be included in dependant projects that depend on those libraries ? i.e. how to declare transitive NPM deps without having to duplicate it in every dependent project ?#2019-08-1207:33thheller@superstructor you can include a deps.cljs with {:npm-deps {"foo" "version"}} in your .jar#2019-08-1207:57superstructorOk thanks, but that will just issue a warning not actually provide the deps ? Is there a good way to also provide transitive deps ? @thheller#2019-08-1207:59thhellerhmm?#2019-08-1207:59thhellershadow-cljs will run an npm install on the packages listed in deps.cljs on startup? (if they aren't already in package.json)#2019-08-1208:00thhellerunsure what you mean about a warning?#2019-08-1208:06superstructorIs that behaviour any different between using the Node.js shadow-cljs CLI and running via lein with lein run -m shadow.cljs.devtools.cli and :lein true ?#2019-08-1208:06thhellerno#2019-08-1208:07thhellerwhich warning are you refering to? makes things easier if I know what you are talking about 😛#2019-08-1208:08superstructorAh I see it is the difference between :npm-deps and :foreign-libs ? For example
The required namespace "react" is not available, it was required by "day8/re_frame_10x/inlined_deps/reagent/v0v8v0/reagent/core.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  for more information.
You may just need to run:
  npm install react
#2019-08-1208:09thheller:foreign-libs is a different mechanism. has nothing to do with :npm-deps#2019-08-1208:10thhelleryou do need a deps.cljs at the root in your distributed .jar file#2019-08-1208:10superstructorOk I think that is clearer now. So that is for libs, but for apps themselves you still need to have your own mechanism for npm deps like package.json ?#2019-08-1208:10thhelleryes that mechanism is for libs (which you asked about 😛)#2019-08-1208:10superstructorOk awesome, that is clear. Thank you! 😄#2019-08-1208:10superstructorIn the user guide there is only one mention of :npm-deps. May I ask where the source is and if you accept pull requests on docs ? I also wanted to add :external-config to the compiler options which is missing.#2019-08-1208:11thheller:external-config is not a thing in the compiler. it is purely community convention?#2019-08-1208:12thhellerdocs are here https://github.com/shadow-cljs/shadow-cljs.github.io#2019-08-1208:12superstructorNot sure. :compiler-options { :external-config {:devtools/config {:features-to-install [:formatters :hints]}}} does work for cljs devtools.#2019-08-1208:12thhelleryes but that is done by cljs-devtools by directly looking at the compiler-options#2019-08-1208:14superstructorMy bad, you are correct. After looking it up I see it does (get-in @cljs.env/*compiler* [:options :external-config :devtools/config]). 👍#2019-08-1208:15thhelleryeah as far as CLJS is concerned there is only compiler-options#2019-08-1208:15thhellerbut it is a map which you can add anything to in theory#2019-08-1208:15thheller(shadow-cljs actually respects the key with regards to caching but thats it)#2019-08-1208:16thhellerit is only under the :external-config key because of figwheel which had "strict" validation of the compiler-options map#2019-08-1208:16thhellerand would complain about unknown keys#2019-08-1208:16thhellerso they added the "convention" for external-config and tooling-config#2019-08-1208:16thhellerbut its purely on the library side#2019-08-1208:16superstructorI see. Thanks I wasn't aware of that history.#2019-08-1208:17superstructorOne more question re earlier :npm-deps / :foreign-libs. For something like re-frame that needs to maintain compatibility with multiple build systems would it be recommended to simply declare both ?#2019-08-1208:19thhellerIIRC there are open issues about that which I commented on?#2019-08-1208:19thhellerbasically just include a deps.cljs#2019-08-1208:20thhellerhmm can't find it. maybe not.#2019-08-1208:21thhellerjust using cljsjs/react etc works but is helped by including a deps.cljs with :npm-deps#2019-08-1208:22thhellerbasically as far as shadow-cljs is concerned just include a deps.cljs#2019-08-1208:22thhellerI thought that was actually added a while ago but I might be wrong#2019-08-1208:23superstructorI can't see one in reagent or re-frame. react itself is probably a reagent PR to be more accurate. That explains how things should be going forward so it is clear, thank you! 🙂#2019-08-1208:34superstructorAre you familiar with the lein-shadow plugin @thheller?#2019-08-1208:35thhellerif that is the luminus thing yes#2019-08-1208:35superstructorThis one: https://gitlab.com/nikperic/lein-shadow#2019-08-1208:36thhelleryeah that one#2019-08-1208:37superstructorIn my opinion, the implementation has too much coupling of different tasks/concepts, but regardless my follow up question is: Currently it gets :npm-deps out of project.clj. Might it make more sense from a design perspective for such a plugin to get that out of deps.cljs directly ?#2019-08-1208:37superstructorBecause then 1. apps and libs using lein could both declare npm-deps in the same way; and 2. when working directly in a libs repo, there would otherwise be duplication of deps between project.clj and deps.cljs.#2019-08-1208:38thhellerwasn't aware it was doing anything with :npm-deps at all#2019-08-1208:39thhellerapps should just be using package.json IMHO#2019-08-1208:39thhellerlibs should use deps.cljs#2019-08-1208:39thhellerthe problem is that npm is a total mess#2019-08-1208:39superstructorYep it generates package.json from :npm-deps key in project.clj. A bit of a hack, but it works.#2019-08-1208:40thhellerso you NEED to hold onto your package.json AND the lockfiles (eg. package-lock.json) if you want anything remotely reliable#2019-08-1208:40thhellerso anything that bypasses using npm directly is going to mess things up#2019-08-1208:40superstructorRe your comment libs should use deps.cljs - If you are working directly in a libs project (in this case, it behaves like an 'app') you would need to duplicate deps between both package.json and deps.cljs ?#2019-08-1208:41thhellerthis is NOT maven where you can somewhat rely on dependencies not chaning unless you change them#2019-08-1208:41superstructorYep, correct. But if you choose to serialise package.json as deps.cljs; i.e. it is repeatable. Then it is OK ?#2019-08-1208:41thhelleryes for libraries I maintain a package.json for development#2019-08-1208:41thhellerand then just manually copy over deps.cljs when needed#2019-08-1208:42thhellerwell "repeatable" is questionable#2019-08-1208:42superstructorOk, so I guess that answers my question. That if you want to do that manual step automatically (ala lein-sahdow) :npm-deps should be taken from a deps.cljs not from project.clj.#2019-08-1208:42thhellerIt sort of works and I don't have a better solution is what I'd say#2019-08-1208:43thhellerproblem with taking it from deps.cljs is that you need to run a JVM with the full classpath to get them#2019-08-1208:43thhellerwhich is much slower than just taking a :npm-deps map#2019-08-1208:44thhellerI think that apps should maintain a package.json. period. don't outsource it to anything else.#2019-08-1208:44thhellerit is annoying enough as it is. don't make it worse.#2019-08-1208:45thhellerlibraries with deps.cljs is problematic but works ok-ish until you run into version conflicts#2019-08-1208:45thhellerthen it becomes bad again#2019-08-1208:45thhellerI honestly have no solution to these things so I'm all ears for better solutions#2019-08-1208:46superstructorThanks. That's a good summary of the issues.#2019-08-1208:46superstructorI think the distinction between apps and libs becomes less interesting once your a lib developer, because then you run the lib as an 'app' (i.e. not a transitive dep) and you end up maintaining a package.json there too.#2019-08-1208:47superstructorSo you end up duplicating deps in 2 files at every layer of your dependency tree, which does suck.#2019-08-1208:47superstructorNot only duplicating between files, but duplicating between dependent projects.#2019-08-1208:48thhelleras a lib developer you'll need to be much more careful with you declared dependencies anyways#2019-08-1208:48thhellerso I think it is ok to manually maintain a deps.cljs#2019-08-1208:48thhelleragain ... this isn't maven. options for managing dependencies are much more limited#2019-08-1208:49thhellerfor apps ... you will eventually need to maintain your own package.json#2019-08-1208:49thhellerthere is simply no way around that#2019-08-1208:49superstructorWould it be worth considering shadow-cljs being responsible for managing/generation of package.json based on deps.cljs as a standard or is that a space you don't want to go ?#2019-08-1208:50thhellerI'm pretty close to completely replacing npm and just downloading and managing dependencies manually#2019-08-1208:50thhellerbut no. the deps.cljs handling shadow-cljs currently does is all I'm willing to do#2019-08-1208:51thhellerthat is: read all found deps.cljs with :npm-deps on startup, do a best effort conflict resolution, run npm install if the package is not in package.json already#2019-08-1208:51thhellereverything else SHOULD be in package.json#2019-08-1208:52thhellerotherwise we need to replicate every single tooling related thing npm does#2019-08-1208:52thhellerwhich is just silly#2019-08-1208:52superstructorOk thanks, it is clear what the current extent of responsibility is 👍 Yeah, if you choose to replace npm completely that would obviously avoid the mess and solve the issue, but npm does a lot of stuff. Its questionable how much of that CLJS users would actually need though for shadow-cljs to be viable.#2019-08-1208:53superstructorAs-in, if shadow-cljs did ever download/manage deps directly itself, I'm not sure it would actually need to cover 100% of npm's feature set related to that.#2019-08-1208:54superstructorBut yeah, I get its also a big scope increase, best avoided if possible.#2019-08-1208:54thhellerthe reason I haven't done that already is because it would only be practical for browser builds#2019-08-1208:55thhelleras that is the only thing that doesn't actually need the node_modules folder structure#2019-08-1208:55thhellerbut most things do actually need that stuff (eg. node, react-native) so if we were to manage dependencies we'd have another system to worry about deps#2019-08-1208:56thhellerso yeah I'm probably never touching that although I have thought about it a lot#2019-08-1208:56superstructorYeah that would be a formidable maintenance burden.#2019-08-1208:58thhellermy recommendation if you want to avoid the npm horrors as best you can: use package.json, managed via npm install etc. and keep the lock files in version control#2019-08-1208:59thhellerversion ranges in npm are a nightmare and everything uses them#2019-08-1209:00thhellerso there is no guarantee that 2 people running npm install the-thing will end up with the same dependencies#2019-08-1209:00superstructorYep, that's burned me before.#2019-08-1209:00thhellerhttps://npm.github.io/how-npm-works-docs/npm3/non-determinism.html#2019-08-1209:00thhellerthings have gotten a bit better since lock files#2019-08-1209:00thhellerbut shit still happens#2019-08-1209:01superstructorYep, software is hard.#2019-08-1209:02superstructorThanks again for all the insights. Much appreciated. If I think up any possibly reasonable solutions to this I'll definitely ping you.#2019-08-1209:02thhelleryeah combining to two different package managers is not that easy#2019-08-1209:04superstructorAbsolutely, its a tough position to be in. Overall, I want to say despite that shadow-cljs is amazing work and a huge leap forward in CLJS development. Its a good problem to have! It wasn't long ago that every time I needed a new JS dep it required a PR to CLJSJS!#2019-08-1209:05thhelleryeah. although sometimes I wonder if we should maybe avoid using most JS deps 😉#2019-08-1209:05thhellerI'm definitely at a stage where I try to avoid them as much as possible#2019-08-1209:06thhellertoo many times were I try to upgrade one tiny dep with a minor version bump and everything breaks 😛#2019-08-1209:06thhellerand things seem to be getting worse not better in that regard#2019-08-1209:08thhellerhope that webpack5 will bring back some order to the chaos 😛#2019-08-1209:08superstructorYeah, its a blessing and a curse. Unfortunately its non-trivial to replace all the JS things with CLJS things.#2019-08-1209:08superstructorThe set of functionality available in JS is always going to be greater than CLJS, so interop is a key part of CLJS's strength just like Clojure and the JVM w/ Java libs.#2019-08-1209:09thhelleryeah absolutely. it is the reason I'm in this in the first place#2019-08-1209:10thhellerbut there are still a bunch of widely used npm packages that aren't very high quality#2019-08-1209:10thhellerso in general the "quality" of JVM libs is much better (whatever that means)#2019-08-1209:10superstructorTrue.#2019-08-1209:11thhellerJS world is also still rapidly changing so I guess its something we have to live with for a while#2019-08-1209:12thhellerto be fair to JS though they need to solve things that JVM mostly doesn't care about#2019-08-1209:12thhellereg. code size#2019-08-1209:13superstructorYep. Its nice to be insulated mostly from that churn by abstractions in the CLJS world, but the interaction at the interop/deps layer is going to be a pain point for awhile.#2019-08-1209:15superstructorIt'll be interesting to see how things play out. Looks like JS is becoming very much a compile target, esp with asm.js, TypeScript etc.#2019-08-1209:17thhelleryeah, its probably be going to completely different (again) in a couple of years#2019-08-1209:17thhellernpm isn't even 10 years old after all 😛#2019-08-1218:22David PhamSo a selling feature of CLJS would also be reliability of dependencies?#2019-08-1222:51superstructorI started a PR on reagent to add deps.cljs as per above - https://github.com/reagent-project/reagent/pull/441 @thheller#2019-08-1308:38Saikyunis there a way to start a shadow-cljs repl on the browser-side in an existing js-project?#2019-08-1308:40Saikyunwhat I wish to do is something akin to:
let wish = require('shadow-cljs.wishful-repl');
wish.startRepl();
and then be able to connect to it using e.g. cider-mode or inf-clojure-mode, and eval cljs-code in the context of the browser page 🙂 I hope I'm making sense
#2019-08-1308:40thhellerthat is possible but what is the point?#2019-08-1308:41thhellersince you used require I'm going to guess that something like webpack is used#2019-08-1308:42thhellerwhich means all code is isolated and not accessible like CLJS code would be#2019-08-1308:42thhellerso you basically only get access to the DOM?#2019-08-1308:43Saikyunoh, I guess that makes sense. I was hoping to do something akin to what you can do in jvm/clr, where you can start clojure and poke at the classes etc#2019-08-1308:44thhelleryeah thats not really possible in JS#2019-08-1308:44SaikyunI figured I could do that by "exposing" variables by putting references under window#2019-08-1308:44Saikyune.g. window.reactRoot = ... then in the repl js/window.reactRoot#2019-08-1308:44thhelleryeah but you are much better of poking at those variables using the browser devtools#2019-08-1308:44Saikyunor similar 🙂#2019-08-1308:44Saikyunhm, I see#2019-08-1308:45SaikyunI generally feel very comfortable playing around with stuff using the repl, but maybe I should get more used to the devtools#2019-08-1308:45Saikyunthanks for the input anyway 🙂#2019-08-1308:46Saikyunalso thanks for a great tool, shadow-cljs is what has made me appreciate cljs 🙂#2019-08-1308:47thhellerI don't want to stand in the way of your ideas so you could just make a regular :browser build and load that normally alongside your JS project#2019-08-1308:47thhellerBUT that will eventually cause issues with conflicts and so on#2019-08-1308:47thhellerso be very careful and expect bugs 😛#2019-08-1308:49Saikyunah okay, that is good to know. and thanks for the warning, haha.#2019-08-1308:50Saikyunone of the things I had in mind is when Sean Cornfield used clojure to generate tests for java-classes/functions by speccing them. I really like spec/generation, so I figured that could be one way to do it 🙂#2019-08-1308:51Saikyunbut I'm not sure how feasible it is to do it "from the outside", as you're saying, the js-world might be too walled off 😕#2019-08-1308:52Saikyundo you think it'd be more feasible to do it the other way around, create a shadow-cljs browser-project, and require all js-libs through cljs? or would they be equally opaque?#2019-08-1309:06thhellerequally opaque#2019-08-1309:06thhellerunlike JVM/Java the JS doesn't have a namespacing system#2019-08-1309:07thhellerso you can't really look up a class by name for example#2019-08-1309:07thhelleralso there is no built in reflection/introspection like the JVM has#2019-08-1309:07thhelleryou are basically just looking at arbitrary JS objects (if you can even get them)#2019-08-1309:08Saikyunah, I see. maybe it'd make more sense to just use a testing library built for js then#2019-08-1309:16thhellerIMHO the CLJS repl is fairly limited when it comes to inspecting pure JS objects#2019-08-1309:16thhellermuch better to do that via the browser console/devtools#2019-08-1310:34Saikyunall right @thheller. I've had some success using appliedscience/js-interop 🙂#2019-08-1313:51Olicalyou might reaaaaly like this too https://github.com/mfikes/cljs-bean#2019-08-1313:52Saikyunthanks @olical. what does this give me that js-interop doesn't? 🙂#2019-08-1313:53OlicalOh, I'm not sure exactly, that's also a good library. But if you want an easy way to print JS objects as Clojure data structures cljs-bean should help a lot. I think it does some magic around the conversion so you can use regular CLJS data functions then convert it back to JS objects without sacrificing performance. Depends on your usecase I guess.#2019-08-1313:55Saikyunthat does sound interesting 🙂 js-interop comes with its own get-in etc#2019-08-1313:56OlicalYep, so you can either go down the route of "leave it as JS and use functions that are aware of that fact" or the other route of "wrap it in a thin layer that lets you use all other ClojureScript functions you'd use with normal data". Honestly depends on your preference. You might find cljs-interop faster for all I know.#2019-08-1313:57OlicalI've used it before and enjoyed it, I do like the idea of only having to learn like 1-3 functions though, then I get to use all of the cljs.core functions.#2019-08-1313:57OlicalUp to you really! Just another option which might suit you better or worse.#2019-08-1313:58Saikyunyeah, I really appreciate the suggestion 🙂 was just curious about the differences. being able to use "standard" functions sure sounds nice#2019-08-1314:00OlicalIf you've got something that works, might as well stick with it. If I was starting fresh and had to do a lot of JS interop I'd be tempted by both. Just have to try it out I guess.#2019-08-1314:00SaikyunI'm currently just dabbling with cljs, so I'm not really into any big project 😄 so trying different things out sounds fine#2019-08-1314:01OlicalExperimenting with functions and tools at the REPL is one of my favourite things about the ecosystem, playing with stuff is good :+1:#2019-08-1314:03Saikyunindeed ^^#2019-08-1318:24tianshu#2019-08-1318:26tianshuIs my problem relative to shadow-cljs? My chrome format cljs data like this, but I want the following way#2019-08-1318:27tianshu#2019-08-1318:36tianshuSorry, I think I miss the cljs-devtools dependencies.#2019-08-1319:41nateHello, does anyone know if the loader code works with re-frame events ? https://shadow-cljs.github.io/docs/UsersGuide.html#_loading_code_dynamically#2019-08-1319:42nateIt doesn't seem to work to load a module dynamically and then try to dispatch a re-frame event defined in that module (for my case, calling re-frame/dispatch in the fn-to-call-on-load callback)#2019-08-1319:53thheller@nisehl I need some more information to comment. depends on how your code is structured and so on#2019-08-1321:52nateHey, actually after investigating, I was passing (rf/dispatch ...) instead of a fn (eg. #(rf/dispatch ...) to the loader as a callback. My bad, all good. I confirm you can load modules that contain re-frame event definitions (eg. (rf/reg-event-fx...) dynamically#2019-08-1403:20QuestI want to do a xhrio GET against another service I'm running on local during development. The shadow-cljs server is at localhost:8280, and as a result any attempts to run an async HTTP request (GET https://google.com for instance) are forced to the same uri.
GET  404 (Not Found)
Since shadow-cljs is the thing serving the page during development, how can I get it to include the CORS headers? I noticed that it has some code to do this at https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web/api.clj#L180 , but I'm not clear on how to get it to activate
#2019-08-1403:22Questthe default re-frame template using +handler will allow you to bring a server up on localhost:3000, but it doesn't seem possible to hit#2019-08-1408:00thheller@quest that is not how CORS works. the server answering the request has to include CORS headers. not the server serving the initial page.#2019-08-1415:10QuestAh, I was quite confused then. I thought the initial page would be responsible for "setting permissions" in this case -- thank you for educating my dense self 😅#2019-08-1419:10QuestGot it working. Notes in case a future person sees this: • Make sure to include the protocol in the GET requests from your client - ex: • If you're using Ring on the serverside, you can use ring-CORS https://github.com/r0man/ring-cors • If you're using Aleph with Compojure (my case), see https://github.com/muhuk/aleph-middleware Your routes should look like so:
(def handler
  (-> (compojure/routes
       (GET "/"         [] root-handler)
       (GET "/healthz" [] healthcheck-handler)
       (route/not-found "No such page."))
      (middleware.cors/wrap-cors :access-control-allow-methods #{:get}
                                 :access-control-allow-headers #{"content-type"}
                                 :access-control-allow-origin #"[\s\S]+")
      (params/wrap-params)))
Note the #"[\s\S]+" regex -- this matches any incoming request, but you can also use it to limit the origin. tested with [aleph "0.4.6"], [aleph-middleware "0.2.0"], [ring-cors "0.1.10"], [compojure "1.6.1"]
#2019-08-1419:24thhellerwhy are you adding CORS when you are running the server anyways?#2019-08-1419:24thhellerjust have that server serve the .js files that shadow-cljs has generated#2019-08-1419:24thhelleror you could use the reverse proxy support https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy#2019-08-1419:32QuestMainly lack of expertise in getting the tooling setup -- the origin server is Boot based & I'm not sure how to correctly integrate all of the clientside re-frame-template into it, plus getting cider-jack-in-cljs working with it. Though it sounds like I could blindly have the Boot webserver serve the client's resources/index.html from the filesystem?#2019-08-1419:32thhelleryes#2019-08-1419:33QuestHmm. I'll give that a shot then, definitely cleaner than CORS-ing everything for development mode. The dev-http-proxy would also work fine, but seems like a less clean solution.#2019-08-1419:39thhelleryeah its purely there for convenience in case you don't control the server#2019-08-1419:40thhellerbut if you do it is best to just use that server to serve the files
#2019-08-1419:40thhellersince you are going to do that in production anyways#2019-08-1419:53QuestMakes sense. I've been building my stack on localhost but have yet to operationalize it & I've been wondering about where to serve the browser resources. You've been quite responsive today -- appreciate the advice subbed to your Patreon @ https://www.patreon.com/thheller#2019-08-1419:56thhellerthanks! happy to help.#2019-08-1408:00thheller> and as a result any attempts to run an async HTTP request (GET https://google.com for instance) are forced to the same uri.#2019-08-1408:01thhellerthat also isn't true. nothing is forcing the same URI. you are just passing nil to the URL#2019-08-1411:35danielnealhey @thheller I’ve got a branch of our production react native app running on shadow-cljs and it all seems to be working great!#2019-08-1411:36danielnealThe code is much slicker now, too really nice to get rid of all those extraneous bits (like figwheel-bridge.js)#2019-08-1411:37danielnealI have one question - occassionally I get this error No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code., when I’m running shadow-cljs watch app in one terminal, shadow-cljs cljs-repl app in another, and expo-cli start --lan -c in the third.#2019-08-1411:38danielnealWhen I get this error, I’ve been quitting and restarting everything, but I was wondering if there was a better way, or something I need to watch out for as the likely cause.#2019-08-1412:36thheller@danieleneal that just means that the expo app has not connected back to the shadow-cljs process#2019-08-1412:36thhellerthe websocket connect may have failed#2019-08-1412:36thhellercheck the logs. there should be a websocket connected message when you start the app#2019-08-1412:36thhellerbut your app needs to be running if you want to use the REPL#2019-08-1412:48thhelleroh and there should be any need to restart anything except maybe the expo app#2019-08-1412:49sogaiui encounter a similar issue when working with vscode extensions compiled using shadow-cljs -- i have been restarting everything to get my cljs-repl back. i hadn't checked my logs, but will do so next time i encounter this situation.#2019-08-1415:32danielnealInterestingly I see
WebSocket connected!
REPL init successful
Running application on iPhone SE
in the logs sometimes, but still get the can’t connect issue. It’s almost like it’s connected to somewhere else
#2019-08-1415:32danielnealI’ve noticed that the watch and the cljs-repl have different nrepl ports, is this relevant?#2019-08-1416:54thheller@danieleneal check if you maybe have 2 shadow-cljs processes running#2019-08-1416:54thhellercljs-repl doesn't have an nrepl port at all?#2019-08-1419:15jpmonettashi everybody, I'm trying some experiments with cljs and this npm library https://github.com/projectstorm/react-diagrams/tree/v5.3.2, a nice library to handle diagrams with react, but for some reason the shadow-cljs output isn't working. I created a very basic example in js and compiled it with webpack and it works, replicated the same in cljs and compiled with shadow-cljs and browser console shows like it is missing some stuff (some stuff works, but some other fail) So far played with :js-provider and optimizations but can't make it work and don't know how to debug it further, any ideas?#2019-08-1419:17thhelleryou shouldn't need to adjust anything#2019-08-1419:17thhellerwhat is the error?#2019-08-1419:18jpmonettas
Uncaught TypeError: Cannot read property 'BaseModel' of undefined
    at o.t$jscomp$0.PortModel [as constructor]
#2019-08-1419:19jpmonettasI tried to step thru the working and non working apps but they are different#2019-08-1419:19jpmonettasif I change the output to es6, then I see a different error#2019-08-1419:32thheller@jpmonettas it all looks find to me when I import it. how do I trigger an error?#2019-08-1419:32jpmonettasyeah that works, this triggers a error#2019-08-1419:33jpmonettas
(ns test.storm
  (:require ["@projectstorm/react-diagrams" :as storm]
            ["react" :as react]
            ["react-dom" :as react-dom]))

(defn doit []
  (let [engine (doto (storm/DiagramEngine.) (.installDefaultFactories))
        model (storm/DiagramModel.)
        node1 (doto (storm/DefaultNodeModel. "Node 1" "rgb(0,192,255)") (.setPosition 100 100))
        port1 (.addOutPort node1 "Out")
        node2 (doto (storm/DefaultNodeModel. "Node 2" "rgb(0,192,255)") (.setPosition 400 100))
        port2 (.addOutPort node2 "In")
        link1 (.link port1 port2)]
    (.addAll model node1 node2)
    (.setDiagramModel engine model)
    (react-dom/render
     (react/createElement
      (storm/DiagramWidget.
       #js {:className "srd-demo-canvas"
            :diagramEngine engine}))
     (js/document.getElementById "app"))))

#2019-08-1419:34jpmonettaspackage.json dependencies being
"dependencies": {
    "@projectstorm/react-diagrams": "5.3.2",
    "closest": "0.0.1",
    "create-react-class": "^15.6.3",
    "dagre": "^0.8.4",
    "lodash": "^4.17.15",
    "mathjs": "^6.0.4",
    "pathfinding": "^0.4.18",
    "paths-js": "^0.4.10",
    "react": "^16.9.0",
    "react-dom": "^16.8.6",
    "webpack": "^4.39.2",
    "webpack-cli": "^3.3.6"
  },
#2019-08-1419:34thhellerpretty sure you are using that incorrectly#2019-08-1419:35thheller
(react/createElement
        storm/DiagramWidget
        #js {:className "srd-demo-canvas"
             :diagramEngine engine})
#2019-08-1419:35jpmonettasthis is the code that works for me in js
import {
    DiagramEngine,
    DiagramModel,
    DefaultNodeModel,
    LinkModel,
    DiagramWidget,
    DefaultLinkModel
} from "@projectstorm/react-diagrams";
import * as React from "react";
import * as ReactDOM from "react-dom";


//1) setup the diagram engine
var engine = new DiagramEngine();
engine.installDefaultFactories();

//2) setup the diagram model
var model = new DiagramModel();

//3-A) create a default node
var node1 = new DefaultNodeModel("Node 1", "rgb(0,192,255)");
node1.setPosition(100, 100);

let port1 = node1.addOutPort("Out");

//3-B) create another default node
var node2 = new DefaultNodeModel("Node 2", "rgb(192,255,0)");
node2.setPosition(400, 100);

let port2 = node2.addInPort("In");

// link the ports
let link1 = port1.link(port2);

//4) add the models to the root graph
model.addAll(node1, node2, link1);

//5) load model into engine
engine.setDiagramModel(model);

//6) render the diagram!
ReactDOM.render(
  React.createElement(DiagramWidget, {className: "srd-demo-canvas", diagramEngine: engine}, null),
  document.getElementById("app")
);
#2019-08-1419:35thhelleryeah exactly#2019-08-1419:36thhellersee how you were constructing the (storm/DiagramWidget. ...)?#2019-08-1419:36thhelleryou are supposed to just pass it as a react element type#2019-08-1419:36thheller> React.createElement(DiagramWidget, {className: "srd-demo-canvas", diagramEngine: engine}, null),#2019-08-1419:37jpmonettasfacepalm#2019-08-1419:37jpmonettaslet me try that#2019-08-1419:37thhelleryou wrote the equiv of new DiagramWidget(), ...#2019-08-1419:38thhellerother stuff looks correct though#2019-08-1419:38jpmonettasyeah, I tweaked that a bunch of times and got the wrong thing#2019-08-1419:39thhellerit seems to do something when I run it#2019-08-1419:40jpmonettasyeah that is working now, sorry for all that, my bad!#2019-08-1419:40jpmonettasthanks a lot @thheller!#2019-08-1419:41jpmonettasand thanks for shadow-cljs!#2019-08-1419:42thhellerthat lib looks nice. might be useful for a visualization I've been thinking about#2019-08-1420:13jpmonettasyeah looks great#2019-08-1420:14jpmonettasjust figured out if I don't do :compiler-options {:output-feature-set :es6} I still see the same error I was seeing before#2019-08-1420:21thhellerunlikely this is actually needed. try actually restarting your watch, maybe it is in a confused state or something#2019-08-1420:21thhellerbut if you are fine with es6 that works too, nothing wrong with that (and actually better unless you need to support IE10 or so)#2019-08-1420:23jpmonettastried stopping, cleaning .shadow-cljs and commenting/uncommenting that toggles between working and that reported error, no idea#2019-08-1420:23jpmonettasbut I'm ok with that, I'm trying to build a dev tool, so no need for old browsers support#2019-08-1420:24thhelleryeah then its best to go with as little transpilation as possible#2019-08-1502:21Aklscchello, guys, I have some problems with using shadow-cljs, leiningen and cursive IDE in Intellij. I want to start a repl of clojurescript in the Intellij, and do as following: Add a port config in
clojure
:nrepl {:port 9600}
Add I add a Clojure REPL of Remote with the Host 127.0.0.1, and Port 9600. Start shadow-cljs Server in Terminal I open a terminal and do:
# app is the app-id
$ shadow-cljs watch app
Run the REPL to connect the Server in Intellij I click the green button of the run in the left-top of of Intellij. As default, it will connect a clojure REPL, and I can't switch it to clojurescript REPL. How should I do? And I also want to load the project to REPL, too. Is there anyone having an experience about it?
#2019-08-1502:25AklsccAnd my build target is npm-module, then use it in Expo App.js.#2019-08-1507:41thheller:npm-module is tricky with regards to REPL setup. can you not use the proper :react-native target?#2019-08-1507:46Aklscc@thheller. I use the` npm-module` in App.js, it's convenient, so I don't think more about it. The :react-native target is enough simple?#2019-08-1507:49thhellerdunno what you are doing#2019-08-1507:49thhellerif you use :npm-module you must set :runtime :react-native in your build config#2019-08-1507:49thhellerand then manually in App.js require("./app/shadow.cljs.devtools.client.react-native")#2019-08-1507:50thhellerthat performs the REPL setup client side#2019-08-1507:50thhellerin cursive you then call (shadow.cljs.devtools.api/repl :app) to switch to the CLJS repl for :app#2019-08-1508:07Aklscc@thheller. It works well to switch clojure REPL to clojurescript's. I'm using Expo and React Native to do an app. After do as above, any input will get No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.#2019-08-1508:08thhelleryes that means that your app has not loaded the necessary REPL js#2019-08-1508:08thhellerwhich you do with the require I added above#2019-08-1508:08thhellerOR it could be that the websocket just failed to connect#2019-08-1508:09thhellernote that only the :npm-module target has to do this manual setup#2019-08-1508:24Aklscc@thheller. I think it's beacause of configuration in App.js. What should I do after require("./app/shadow.cljs.devtools.client.react-native") in App.js? Are there another operations in App.js? At beginning, I just refer npm-module compiled and export a App(), just as default of expo init yields.#2019-08-1508:41AklsccYes, maybe something about websocket, I start expo and run it on IPhone, then it print WebSocket disconnected with a long Map.#2019-08-1508:43thhellerno that is all you need to do#2019-08-1508:43thhellerbut given that you run on an iPhone which connects over the network#2019-08-1508:44thhellerit might be picking the wrong IP to connect to#2019-08-1508:44thhellercheck shadow-cljs watch app --verbose#2019-08-1508:44thhellerit'll log the IP it is using on start#2019-08-1508:44thhellerand if that is the wrong one you can override it with shadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}'#2019-08-1508:45thhelleror set :local-ip in your build config#2019-08-1509:33AklsccI'm so sorry bothering you again. But it still doesn't work after I try to set local-ip. I don't know how the shadow-cljs work and which ip to set for it. It's My work environment:#1. start shadow-cljs and expo on two terminals; #2. set shaodw-cljs nREPL port 9600, which in localhost and LAN, you can connecnt it in any one; #3. set Cursive nREPL remote host and port 127.0.0.1:9600; #4. Run app on IPhone by QR code with LAN option#2019-08-1509:34thhellerlocalhost is not correct#2019-08-1509:35thhellerand you are configuring the wrong thing#2019-08-1509:35AklsccI also try to set Cursive nREPL Remote with LAN as host. It doesn't work too.#2019-08-1509:35thhelleryou need to configure the part where your iPhone connects to your PC#2019-08-1509:35thhellerso the IP of your machine on the network#2019-08-1509:35thhellerI don't know what that is so I cannot tell you#2019-08-1509:35thhellerbut cursive is not involved in this process#2019-08-1509:36thhellerwhich OS are you on?#2019-08-1509:37AklsccLinux.#2019-08-1509:37thhellerso do you know how to look up your network ip? might be something like ifconfig but I can't remember#2019-08-1509:37thhellergoogle that part. nothing to do with either react-native or shadow-cljs. purely your OS IP is needed#2019-08-1509:38thhellerusually something like 192.168.1.5 or so#2019-08-1509:43AklsccI have try it, use the IP of my OS. But it doesn't work, and the repl print No application has .... too#2019-08-1509:43thhellerok what did you do?#2019-08-1509:45Aklsccset local-ip as the IP of my OS#2019-08-1509:45thhellerhow exactly?#2019-08-1509:46Aklsccthe cursive repl print No application has ....#2019-08-1509:46thhelleryes. please tell me exactly where you set the local ip#2019-08-1509:46thhellerthe full command#2019-08-1509:46thhellerand preferably the full build config#2019-08-1509:46thhellerit matters where you set it#2019-08-1509:47thhellerI can currently only guess what you are doing#2019-08-1509:47thhellerwhich makes this process extremele slow#2019-08-1509:47thhellerThe message is telling you what your react-native app on your iphone has not connected back to the shadow-cljs process#2019-08-1509:48thhellerit doesn't matter what you have configured in cursive for that part#2019-08-1509:51AklsccOk. I will give a specific list of it. I'm sorry for that, thanks for your sincere help. I'm a rookie in Clojure, so there are many thing unknown.#2019-08-1509:53thhelleryeah. I'm writing a REPL troubleshooting guide currently. hopefully that explains things a bit better than I can do here in slack#2019-08-1512:08Aklscc@thheller. This a specific configuration list. Maybe It can express more.#2019-08-1512:10AklsccI have run it by use ":target :react-native" successfully. But when use ":npm-module" as ":target", it seems websocket problem.#2019-08-1512:11AklsccIn the latest version-2.8.47, you even can't run a expo start if config as above.#2019-08-1512:23thheller"The operation couldn’t be completed. Connection refused"#2019-08-1512:23thhellerthis is the relevant error here#2019-08-1512:23thhellerthe expo app fails to connect to the shadow-cljs process#2019-08-1512:24thhellerwhich according to your ip config would be running at http://192.168.50.244:9630#2019-08-1512:24thhelleryou can just test an open that in a regular browser#2019-08-1512:25thheller(from your iphone)#2019-08-1512:25thhellercould be that you have a firewall blocking that access#2019-08-1512:25thhelleror that it isn't the correct IP#2019-08-1512:28thhellerI'm unsure why the react-native target works though.#2019-08-1512:28thhelleris there any particular reason you are using :npm-module?#2019-08-1512:30AklsccThe ip of http://192.168.50.244:9630 has the content of "loading...", and the title is my app name.#2019-08-1512:32AklsccMaybe the target :npm-module have some problem when work with expo?#2019-08-1512:32AklsccI use react-native as target, works well.#2019-08-1512:33thhellerwell why are you using :npm-module?#2019-08-1512:33thheller:target :react-native is meant for expo as well#2019-08-1512:36thhellerthe page should also show more than "Loading ..."#2019-08-1512:36AklsccI learn the expo docs first, it looks like use App.js as a entry file is very simple, and needn't manually add AppRegistry. So I do it as in clojurescript.#2019-08-1512:37thhellerhttps://github.com/thheller/reagent-expo here is expo example#2019-08-1512:37AklsccOkay, I will try it, really thank you.#2019-08-1503:50tianshuHi, @thheller. In development, shadow-cljs will generated bunch of files, can I separate entry files from other files? since the release mode there should be only entry files, I want to keep the directory clean. I can add a second path to source paths, I just wonder can I tell shadow-cljs to put the file there?#2019-08-1507:42thheller@doglooksgood the files are generated there to stop a metro exception from happening#2019-08-1507:42thhellerif they aren't there metro will throw an exception when displaying redbox/yellowbox dialogs#2019-08-1507:42thhellerthey aren't technically used for anything#2019-08-1507:43thhellerrelease builds don't use them so you could just rm -rf app/* && shadow-cljs release app#2019-08-1507:43thhellerjust clean them before you make the release build#2019-08-1512:32danielnealdumb question I couldn’t figure out from the docs - where do I put an init function that I want to be called only in dev.#2019-08-1512:33danielnealThinking about preloads, but should the function then be at the top level in the namespace or does it need some metadata#2019-08-1512:33danielneal(it’s a websocket reconnection for remote inspection)#2019-08-1512:47thhellerdev only code goes into :preloads yes (and you just run the code directly)#2019-08-1515:35kasukoAlright, 99% done my conversion from lein to shadow-cljs. Latest issue, I am trying to replace our dependency on the lein-cljfmt plugin. I am trying to run cljfmt using shadow-cljs run but it looks like shadow-cljs is trying to consume my --file-pattern argument for itself.#2019-08-1515:36kasuko#2019-08-1515:36thhellertry npx shadow-cljs run cljfmt.main/-main -- fix --file-pattern '\/[^.]+\.clj[sxc]?$' src test#2019-08-1515:40kasukoAwesome works perfectly! Thanks!#2019-08-1515:40thhellerhttps://github.com/thheller/shadow-cljs/issues/545#2019-08-1515:40thhellerSo I don't forget to fix this properly again 😉#2019-08-1515:41thheller-- is sort of convention on linux or so#2019-08-1515:45kasukoYa, I've definitely seen an used that often when dealing with git ... just didn't think to try it with shadow-cljs#2019-08-1517:14malchHello! I'm trying to use shadow-cljs with Cider, but got this error:
user> (server/start!)
Aug 15, 2019 8:05:01 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.7.2.Final
Aug 15, 2019 8:05:01 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.7.2.Final
Aug 15, 2019 8:05:01 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 2.3.2.Final
shadow-cljs - server version: 2.8.42 running at 
shadow-cljs - nREPL server started on port 9876
:shadow.cljs.devtools.server/started
user> (shadow/watch :app)
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (175 files, 1 compiled, 0 warnings, 2.73s)
:watching
user> (shadow/nrepl-select :app)
Execution error (IllegalStateException) at shadow.cljs.devtools.api/nrepl-select (api.clj:377).
Can't change/establish root binding of: *nrepl-cljs* with set
last two lines
#2019-08-1517:14malchcould someone help me?#2019-08-1517:15thheller@malch the middelware isn't loaded. dunno how to configure that though#2019-08-1517:16thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2019-08-1517:16thhellermight need to use the ns shadow.cljs.devtools.server.nrepl04 instead of shadow.cljs.devtools.server.nrepl#2019-08-1517:16thhellerdepends on your nrepl version#2019-08-1517:18malchthank you, will try to investigate further#2019-08-1517:30malch@thheller Thank you! nrepl04 middleware worked perfectly simple_smile#2019-08-1519:13tianshu@thheller thanks for the reply, I'm very sorry I didn't point out I want specify a output-to at :browser target. I want make my src/main/resources/public/compiled directory clean. Of course I can delete it before build.#2019-08-1519:52dobladezhi... not specific to shadow-cljs at all, but: Any recommendations or common practice to separate CLJ vs CLJS deps (in the same source tree)? All open projects I've looked at seem to keep all deps together... which I don't like#2019-08-1520:17thhellerwhen using lein I usually create a :cljs profile there I put my CLJS deps (eg. the shadow-cljs project itself)#2019-08-1520:17thhellerI have also just put CLJS deps in shadow-cljs.edn and server side in a separate deps.edn#2019-08-1520:18thhellerit really is up to you, so if you don't like keeping it together .. don't 😛#2019-08-1520:22dobladezthanks#2019-08-1520:22dobladezis there a way to tell shadow-cljs the name of the deps.edn file? (say, deps.cljs.edn?).#2019-08-1520:23thhellerno? wasn't aware that was even an option clj supported?#2019-08-1520:24dobladezI'm using lein-tools-deps... which has the option to do so#2019-08-1520:24dobladezbut yes... most tooling around deps expects deps.edn#2019-08-1520:25dobladezin project.clj, this seems to work: :lein-tools-deps/config {:config-files [:install :user "./deps.clj.edn"]}#2019-08-1520:25thhellerwell if you tell me which command line option it is I can add it#2019-08-1520:25thhellercan't use lein-tools-deps#2019-08-1520:26dobladezsure, I'm just saying... for the server-side piece (using lein) that's one way I found which might work#2019-08-1520:27thhellerif you want to find out how they did it I'd be happy to accept a PR for that#2019-08-1520:28dobladezI'll take a look#2019-08-1520:28dobladezthanks again!#2019-08-1520:28dobladezusing profiles sounds like a valid option too#2019-08-1520:29tvaughanHas anyone successfully compiled a rum project using shadow-cljs? I used npm to install react, react-dom, and create-react-class per https://shadow-cljs.github.io/docs/UsersGuide.html#_missing_js_dependency and https://github.com/thheller/shadow-cljs/issues/199. When I try to compile a simple hello-world application that does nothing other than require rum.core I get The required JS dependency "object-assign" is not available, it was required by "node_modules/react/cjs/react.production.min.js". Yes, I'm aware I could also use npm to install object-assign, but this just doesn't seem right to me. Sorry, I'm sure this is a question that's repeatedly asked. I've looked at a lot of examples and I don't see anything different between them and what I have. PS - I did repeatedly npm install all missing dependencies and it does eventually compile.#2019-08-1520:31thhellerobject-assign should have been installed when you did npm install react since it is listed as one of its dependencies? https://unpkg.com/react@16.9.0/package.json#2019-08-1520:32thhellermaybe try restarting the shadow-cljs process#2019-08-1520:32thhellerit sometimes gets into a confused state if too many node_modules folders are modified#2019-08-1520:32tvaughanYes, it was installed underneath react/, not at the top-level of node_modules/ which appears to be required by shadow-cljs#2019-08-1520:33thhellerwhy was it installed nested?#2019-08-1520:33tvaughanI have no idea#2019-08-1520:33tvaughanI just ran npm install react ...#2019-08-1520:35tvaughanThis is on Ubuntu 18.04 which has npm v3.x#2019-08-1520:35thhellerwell you definitely need a newer npm version in that case#2019-08-1520:35thhellerthat is like ancient history#2019-08-1520:35thhellerwhat is node -v?#2019-08-1520:36tvaughan
# node -v
v8.10.0
#2019-08-1520:38thhellerand npm -v?#2019-08-1520:38thhellernode is also kinda old but that would be ok#2019-08-1520:38thhellera lot has changed in npm however so I'd definitely upgrade that since it has gottan way more reliable#2019-08-1520:39tvaughan
# npm -v
3.5.2
#2019-08-1520:40thhelleryeah definitely upgrade that#2019-08-1520:40tvaughanTrying now...#2019-08-1521:01tvaughanOK. So I upgrade though I don't think that matters. Witness:
# npm install -g ...
# ll /usr/lib/node_modules/                                                                                                                                                  
drwxr-xr-x 1 root root 4096 Aug 15 20:52 ./
drwxr-xr-x 1 root root 4096 Aug 15 20:51 ../
drwxr-xr-x 3 root root 4096 Aug 15 20:52 create-react-class/
drwxr-xr-x 8 root root 4096 Aug 15 20:51 npm/
drwxr-xr-x 5 root root 4096 Aug 15 20:52 react/
drwxr-xr-x 5 root root 4096 Aug 15 20:52 react-dom/
Vs
# npm install ...
# ll node_modules/
drwxr-xr-x 25 root root 800 Aug 15 20:55 ./
drwxr-xr-x 19 root root 608 Aug 15 20:55 ../
drwxr-xr-x  3 root root  96 Aug 15 20:55 .bin/
drwxr-xr-x 10 root root 320 Aug 15 20:55 asap/
drwxr-xr-x 20 root root 640 Aug 15 20:55 core-js/
drwxr-xr-x  9 root root 288 Aug 15 20:55 create-react-class/
drwxr-xr-x  9 root root 288 Aug 15 20:55 encoding/
drwxr-xr-x 10 root root 320 Aug 15 20:55 fbjs/
drwxr-xr-x  8 root root 256 Aug 15 20:55 iconv-lite/
drwxr-xr-x  6 root root 192 Aug 15 20:55 is-stream/
drwxr-xr-x 14 root root 448 Aug 15 20:55 isomorphic-fetch/
drwxr-xr-x  7 root root 224 Aug 15 20:55 js-tokens/
drwxr-xr-x 10 root root 320 Aug 15 20:55 loose-envify/
drwxr-xr-x 13 root root 416 Aug 15 20:55 node-fetch/
drwxr-xr-x  6 root root 192 Aug 15 20:55 object-assign/
drwxr-xr-x 17 root root 544 Aug 15 20:55 promise/
drwxr-xr-x 14 root root 448 Aug 15 20:55 prop-types/
drwxr-xr-x  9 root root 288 Aug 15 20:55 react/
drwxr-xr-x 18 root root 576 Aug 15 20:55 react-dom/
drwxr-xr-x  9 root root 288 Aug 15 20:55 react-is/
drwxr-xr-x  9 root root 288 Aug 15 20:55 safer-buffer/
drwxr-xr-x 12 root root 384 Aug 15 20:55 scheduler/
drwxr-xr-x  5 root root 160 Aug 15 20:55 setimmediate/
drwxr-xr-x 12 root root 384 Aug 15 20:55 ua-parser-js/
drwxr-xr-x  8 root root 256 Aug 15 20:55 whatwg-fetch/
# nodejs -v
v12.8.1
# npm -v
6.10.2
Looks like global installs cannot be supported by shadow-cljs
#2019-08-1521:02thhelleruhm global install?#2019-08-1521:03thhellernot sure why you'd be doing that but if npm is installing things differently there then yes that isn't supported#2019-08-1521:04tvaughanBecause I'm building a docker image...#2019-08-1521:04thhellernot sure why that matters?#2019-08-1521:05tvaughanI want the dependencies saved in the docker image#2019-08-1521:05thhellerbut why does it have to be a global install for that?#2019-08-1521:05thhellerthat also seems like kind of a bad idea given that you can't manage dependencies well that way?#2019-08-1521:06tvaughanThey're specified explicitly#2019-08-1521:07tvaughanThanks for the help @thheller!#2019-08-1521:16lilactownYou shouldn't use global npm modules#2019-08-1521:21tvaughanThe only other alternative is to check-in node_modules/ into the repo. Is this the recommended approach?#2019-08-1602:23TrevorIs there a story for shadow-cljs in the react native world?#2019-08-1603:12stevechanhttps://github.com/thheller/shadow-cljs/issues/167#2019-08-1603:14stevechanI run this issues example : https://github.com/kurtharriger/shadow-cljs-examples/tree/dirac#2019-08-1603:14stevechan#2019-08-1603:16stevechanBut I get this Error.#2019-08-1603:17stevechan@darwin @thheller#2019-08-1611:40darwindo you have something like his user.clj working? he is explicitely starting dirac agent inside his nrepl server here: https://github.com/kurtharriger/shadow-cljs-examples/blob/dirac/dev/user.clj#L6#2019-08-1611:41darwinthat is the thing which should start listening server for dirac extension in the browser#2019-08-1616:16stevechanI don’t know how to make the dirac.agent work.#2019-08-1616:17stevechanIt’s can’t working.#2019-08-1616:18stevechanIt’s can’t working for starting dirac agent.#2019-08-1616:18darwinI’m sorry I cannot provide better guidance than what is described in the docs here: https://github.com/binaryage/dirac/blob/master/docs/installation.md#start-dirac-agent#2019-08-1616:21stevechanYes, I know this. Thanks, but i can work it in figwheel.#2019-08-1616:21stevechanI can’t work it in shadow-cljs.#2019-08-1616:22stevechanDo you have shadow-cljs + dirac example?#2019-08-1616:24stevechanBecause i need debug npm package in the ClojureScript by dirac .#2019-08-1616:24darwinno, I don’t use shadow#2019-08-1616:25stevechanI tried it many times and couldn’t start dirac agent.#2019-08-1616:26stevechanlike lein repl :#2019-08-1616:26stevechan#2019-08-1616:28stevechanrich Thanks Antonin。#2019-08-1616:28stevechanI will continue to try it.#2019-08-1616:29thheller@U1RJA2RT9 last time I checked dirac was not supported. can't remember the exact details but I doubt that has changed.#2019-08-1616:30stevechan😭 @thheller alright, Thanks.#2019-08-1604:31sogaiu@trevor670 have you seen this? https://clojureverse.org/t/upgrading-the-react-native-support/4669#2019-08-1607:18thheller@trevor670 the documentation for :react-native is still incomplete but here is an example with expo https://github.com/thheller/reagent-expo and without https://github.com/thheller/reagent-react-native#2019-08-1611:15alpoxAt the moment, most errors I get during development with shadow-cljs are very unspecific and it gives me a very hard time to track down the issues:#2019-08-1611:15alpoxIs it possible that I set some wrong configuration - or missed something in the configuration? I was looking at source-map settings but I saw they should be enabled by default in dev mode#2019-08-1611:16thhellerwhat did you send to the REPL?#2019-08-1611:16thheller(foo 1 2 3) when foo is nil#2019-08-1611:16thhellerwould cause that error above#2019-08-1611:17alpoxI see, this is probably what is happening - what is missing for my eyes is a reference to where this happens in my codebase#2019-08-1611:17thhellerwell in something you eval'd from the REPL#2019-08-1611:17alpoxOr can a position not be found when I send functions by eval to the REPL?#2019-08-1611:18thhellerit can to some extent but it is not super accurate over time#2019-08-1611:18alpoxI thought it might be possible when I eval it through my editor integration (Not directly in the REPL)#2019-08-1611:18thhellerthat makes no difference at all#2019-08-1611:19alpoxAh okay, thanks for clearing that up 🙂#2019-08-1611:20thhelleryou can try setting "pause on exceptions" in chrome#2019-08-1611:20thhellerthat might show source mapped code or at the very least the JS that was running#2019-08-1611:23thheller@alpox you might also want to upgrade shadow-cljs. in the recent released I tweaked some REPL stuff and previously some compiler warnings were lost#2019-08-1611:24thhellerso there might be some more helpful errors in case you are stuck on an "older" version (ie. last week) 2.8.48 shows warnings more reliably#2019-08-1611:27alpoxOh wow. I've been programming JS / Web stuff for a long time but didn't ever find out about "Pause on exceptions". Shame on me. Thanks @thheller! That makes my life quite a bit easier 😄#2019-08-1611:29alpoxI'll give the upgrade a try too 🙂 thanks again#2019-08-1618:46stefanIn JS, webpack-dev-server allows me to manually type URLs that utilize dynamic routes into the address bar (during development). Is there a way to configure shadow-cljs to the the same? If I try to type anything other than the root page I get an error.#2019-08-1619:22thheller@stefan.age what error? the default is to support push state style urls?#2019-08-1619:22stefan
This site can't be reached The webpage at  might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE
#2019-08-1619:23stefanThat route works if I navigate to it using the app#2019-08-1619:23stefanbut not when typing it in directly#2019-08-1619:24thhellerwhat response does it send?#2019-08-1619:24thhellertry curl -v -H "Accept: text/html" or so#2019-08-1619:25stefan#2019-08-1619:25stefan
% curl -v -H "Accept: text/html"                                                                                                                          ✹
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3000 (#0)
> GET /graphiql HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.54.0
> Accept: text/html
>
< HTTP/1.1 404 Not Found
< Connection: Keep-Alive
< Cache-Control: private, no-cache
< Server: Aleph/0.4.4
< Content-Type: application/octet-stream
< content-length: 0
< Date: Fri, 16 Aug 2019 19:25:44 GMT
<
* Connection #0 to host localhost left intact
#2019-08-1619:25thhellerAleph?#2019-08-1619:26thhellerthat is not the shadow-cljs server. it doesn't use aleph?#2019-08-1619:26stefanI also have a proxy-url to my back end, which uses aleph#2019-08-1619:26thhellerwell yeah the proxy support forwards all requests is doesn't know to the proxy#2019-08-1619:27thhellerso that server would need to reply#2019-08-1619:28stefanah ok#2019-08-1619:30thhellerwebpack-dev-server supports a bit more detailed config where it you tell it to only proxy certain paths and so on#2019-08-1619:30thhellerthat would be easy to add but it not currently supported#2019-08-1619:31stefangotcha, I think that’s what I was looking for. Will just see if I can tweak the server a bit. thank you!#2019-08-1619:37thhellernote that you don't actually have the use the dev-http server shadow-clsj provides#2019-08-1619:37thhellerany webserver will do#2019-08-1619:38thhellerso you could just have your regular server serve the .js files#2019-08-1619:38thhellerwill be closer to your production setup that way#2019-08-1622:11Joe ChasingaHi :spock-hand: I was told that I could get some help with integrating reagent with existing ReactJS code base here.#2019-08-1704:27QuestSometimes I start up shadow-cljs via M-x cider-jack-in-cljs, but it fails with below output
[:app] Configuring build.
[:app] Compiling ...
shutting down ...
user> 
*** Closed on Fri Aug 16 21:22:00 2019 ***
Is there a way to view the exception causing compilation to fail, some sort of logs? In my scenario right now, running lein dev still works without any errors in the browser console on page load
#2019-08-1707:45thheller@quest see https://github.com/thheller/shadow-cljs/issues/546#2019-08-1707:45thhellerit isn't normal that it is shutting down immediately. so it is likely getting killing by your OS.#2019-08-1707:45thhellercould be just because it is running out of memory#2019-08-1707:45thhelleror could be for other reasons (eg. anti-virus)#2019-08-1707:46thhellerthere likely is no exception to log. might also have something to do with cider-jack-in-cljs. not the slightest clue what that does.#2019-08-1707:47thheller@jo.chasinga see https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module#2019-08-1707:49thhellera rather old example showing how to integrate in a create-react-app app https://github.com/thheller/reagent-react-integration/blob/shadow-cljs/src/index.js#2019-08-1708:18malch[thheller/shadow-cljs "2.8.48"] stopped working with Cider. It throws
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
[WARNING] No nREPL middleware descriptor in metadata of #'cider.piggieback/wrap-cljs-repl, see nrepl.middleware/set-descriptor!
Syntax error compiling var at (/tmp/form-init5310097246403534856.clj:1:9214).
Unable to resolve var: shadow.cljs.devtools.server.nrepl04/cljs-load-file in this context
on lein repl
#2019-08-1708:19thheller@malch it only stops working when you use custom stuff 😉#2019-08-1708:19thhellerin this case you need to adjust your middleware#2019-08-1708:19thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2019-08-1708:19thhellerI changed it and there is only one now#2019-08-1708:22malchtrying now#2019-08-1708:23thhelleroh crap .. does cider still have hardcoded references to piggieback?#2019-08-1708:25malch:shrug:#2019-08-1708:25malchsimple_smile#2019-08-1708:30thhellerI'm so tired of working around that mess 😛#2019-08-1708:30malchbesides, 2.8.48 for some reason changes my :init-ns#2019-08-1708:31malchto shadow.user#2019-08-1708:32malchI can stick with 2.8.47 for now, no problem here#2019-08-1708:32thhellerplease describe the setup you use#2019-08-1708:32thhellerthe default shadow-cljs.edn only setup shouldn't have changed#2019-08-1708:32thhelleras far as custom setups go I make no guarantees#2019-08-1708:33malch
{:lein true
 :nrepl {:port 9876}
 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/public/js/compiled"
                :modules {:app {:init-fn rpquest.main/main}}}}}
#2019-08-1708:34thhellerthe lein part I need. that is all fine#2019-08-1708:34malch
(defproject rpquest "0.1.0-SNAPSHOT"
  :min-lein-version "2.8.3"
  :source-paths ["src/clj" "src/cljc" "src/cljs"]
  :resource-paths ["resources"]
  :clean-targets ^{:protect false} ["resources/public/js/compiled"
                                    :target-path]
  :auto-clean false
  :dependencies [[aero "1.1.3"]
                 [aleph "0.4.7-alpha5"]
                 [integrant "0.7.0"]
                 [integrant/repl "0.3.1"]
                 [metosin/reitit "0.3.9"]
                 [metosin/ring-http-response "0.9.1"]
                 [org.clojure/clojure "1.10.1"]
                 [re-frame "0.10.8"]
                 [reagent "0.8.1"]
                 ;; [thheller/shadow-cljs "2.8.47"]
                 [thheller/shadow-cljs "2.8.48"]
                 ;; [thheller/shadow-cljs "2.8.42"] - yes
                 ;; [thheller/shadow-cljs "2.8.45"] - yes
                 ;; [thheller/shadow-cljs "2.8.47"] - yes
                 ]
  :profiles {:dev {:source-paths ["dev/clj"]
                   :repl-options {:nrepl-middleware [
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-load-file
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-eval
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-select

                                                     shadow.cljs.devtools.server.nrepl04/middleware
                                                     ]}}
             :uberjar {:aot :all
                       :main rpquest.main }}
  :uberjar-name "rpquest.jar")
#2019-08-1708:35malchlittle messy, was testing simple_smile#2019-08-1708:35thhelleroh, yeah just find a bad thing in the nrepl init code#2019-08-1708:35thhellerthe :init-ns thing was called mistakenly#2019-08-1708:36thhellerthat looks all ok but where is your cider stuff?#2019-08-1708:37malchoh, profiles.clj
#2019-08-1708:37malch
{:user {:plugins [[lein-ancient "0.6.15"]
                  [jonase/eastwood "0.3.6"]
                  [lein-bikeshed "0.5.2"]
                  [lein-cljfmt "0.6.4"]
                  [lein-count "1.0.9"]
                  [lein-hiera "1.1.0"]
                  [lein-kibit "0.1.7"]]
        :dependencies [[nrepl "0.6.0"]]
        :aliases {"anc" ^{:doc "Check all dependencies for updates"}
                  ["do"
                   ["ancient" "check-profiles" ":all" ":check-clojure"]
                   ["ancient" ":all" ":check-clojure"]]
                  "anc-up" ^{:doc "Upgrade all dependencies interactively"}
                  ["do"
                   ["ancient" "upgrade" ":interactive" ":all" ":check-clojure"]
                   ["ancient" "upgrade-profiles" ":interactive" ":all" ":check-clojure"]]
                  "anc-snapshot" ^{:doc "Check all dependencies for updates, allow snapshots"}
                  ["ancient" ":allow-all" ":all" ":check-clojure"]
                  "dev" ^{:doc "Run development repl"}
                  ["repl" ":headless"]
                  "dev-clean" ^{:doc "Run fully clean development repl"}
                  ["-U" "do" "clean" ["repl" ":headless"]]
                  "deps-dev" ^{:doc "Run lein deps with repl profile"}
                  ["-U" "with-profile" "repl" "deps"]}}
 :repl {:plugins [[cider/cider-nrepl "0.22.0-beta10"]
                  [refactor-nrepl "2.5.0-SNAPSHOT"]]}}
#2019-08-1708:38thhellerhmm I must be missing something. where is the cider nrepl middleware being configured?#2019-08-1708:38malch
:profiles {:dev {:source-paths ["dev/clj"]
                   :repl-options {:nrepl-middleware [
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-load-file
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-eval
                                                     ;; shadow.cljs.devtools.server.nrepl04/cljs-select

                                                     shadow.cljs.devtools.server.nrepl04/middleware
                                                     ]}}
             :uberjar {:aot :all
                       :main rpquest.main }}
#2019-08-1708:39malch:repl-options inside?#2019-08-1708:39thhellerthats the shadow-cljs middleware#2019-08-1708:39thhellerbut where is cider?#2019-08-1708:39malch
:repl {:plugins [[cider/cider-nrepl "0.22.0-beta10"]
                  [refactor-nrepl "2.5.0-SNAPSHOT"]]}
#2019-08-1708:39malchthat's all the config I needed#2019-08-1708:40thhellerhmm ok. I guess the plugins then add it dynamically#2019-08-1708:40malchyeah#2019-08-1709:04thheller@malch try 2.8.49. I added back the missing piggieback descriptor I deleted accidentally#2019-08-1709:05malchsure, trying now#2019-08-1709:09malch@thheller
Error loading shadow.cljs.devtools.server.nrepl04: Syntax error compiling var at (shadow/cljs/devtools/server/nrepl_impl.clj:21:5).
Syntax error compiling var at (/tmp/form-init1375884670700473546.clj:1:8600).
Unable to resolve var: shadow.cljs.devtools.server.nrepl04/middleware in this context
#2019-08-1709:12thhellerI really need better test cases for this crap#2019-08-1709:13malchsorry 😉#2019-08-1709:23thhellertry 2.8.50#2019-08-1709:29malchseems to be working, thank you!#2019-08-1800:36JeremyHi Thomas, everyone. I'm trying to use @date-io/moment in conjunction with @material-ui/pickers as described at https://material-ui-pickers.dev/getting-started/installation (except via cljs). When I :require ["@date-io/moment" :default MomentUtils], the cljs repl tells me (undefined? MomentUtils) => true. MomentUtils seems to be built from a TypeScript export default class. The js rendition looks like var MomentUtils = (function () { function MomentUtils (_a) {...}; ...; return MomentUtils; }()); module.exports = MomentUtils#2019-08-1800:39JeremyOther js libs are coming across fine. Is there something about the way MomentUtils is implemented which causes shadow-cljs to leave it undefined?#2019-08-1805:04Jeremy(could it be something to do with https://clojure.atlassian.net/browse/CLJS-3138 ?)#2019-08-1807:24thheller@clojure475 no it is related to default exports. They only work when the code is actually shipped as ESM but most of the time it is shipped as pre-compiled CommonJS. see the section about default exports here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-08-1807:24thhellermost likely you just need ["@date-io/moment" :as MomentUtils]#2019-08-1807:25Jeremythank you!#2019-08-1807:26Jeremynaturally I've now gone down an adjacent rabbit hole#2019-08-1807:27thhelleryeah it is an annoying situation currently. all currently released versions of webpack have a sort of hack to cheat CommonJS<->ESM interop so it sort of works in webpack#2019-08-1807:27thhellerbut webpack5 will be removing that hack#2019-08-1807:28thhellerso things should become cleaner in the future#2019-08-1807:28JeremyI'm pretty sure I tried :refer [MomentUtils], but might not have tried :as#2019-08-1807:29Jeremythanks for all your incredible work; I'm fiddling with juxt/tick now... and hand-shimming js-joda in the spirit of shadow-cljsjs... how do we get ourselves into these situations!?#2019-08-1807:38thhellerI wish those shims weren't necessary but mixing cljsjs and npm is a recipe for disaster so you have to pick one and I went with npm#2019-08-1807:44Jeremyrightly so#2019-08-1815:42Maksymhi I have just installed shadow cljs and expo and I'm truing to run a project, have anybody faced such error?
λ shadow-cljs watch app
shadow-cljs - config: D:\Dev\clojure\rn-rf-shadow\shadow-cljs.edn  cli version: 2.8.50  node: v10.9.0
shadow-cljs - starting via "clojure"
Exception in thread "main" java.io.FileNotFoundException: -A:dev (The system cannot find the file specified)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:110)
        at clojure.lang.Compiler.loadFile(Compiler.java:7083)
        at clojure.main$load_script.invoke(main.clj:274)
        at clojure.main$script_opt.invoke(main.clj:336)
        at clojure.main$main.doInvoke(main.clj:420)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at clojure.lang.Var.invoke(Var.java:430)
        at clojure.lang.AFn.applyToHelper(AFn.java:195)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
#2019-08-1815:59MaksymI have intuition that I have this error because I work on Windows and I made a trick to use clojure, by default I has only clj in console.#2019-08-1816:25thheller@titov on windows it is expected that you are using the "official" windows distribution. see https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows#2019-08-1816:35Maksym@thheller yeah I've just wanted to write that my approach was wrong, for those who will have this error in future don't follow my path don't install clojure with choco and don't create copy of clj.bat with name cljure.bat, use developers instructions#2019-08-1816:39thhellerI wasn't aware there are other approaches. If there are other solutions in other package managers I can add some kind of detection#2019-08-1816:56MaksymThere is a way: https://chocolatey.org/packages/clojure#2019-08-1816:57MaksymBut it does not work properly as I understood it only gives clj without clojure#2019-08-1816:57thheller1.6? that seems extremely old?#2019-08-1816:57thheller12/14/2014#2019-08-1816:58MaksymVery old#2019-08-1817:01thhellerdeps.edn didn't even exist back then so that seems like an entirely different thing?#2019-08-1817:08Maksymidk, definitely I'm not going to use it heh, the author of choco package should update his module#2019-08-1817:09thhellerjust don't use deps.edn. then you don't have to deal with any of this and just let shadow-cljs handle everything 😛#2019-08-1817:18MaksymOk, I have just launched rn-rf-shadow project on my phone, imma play with it 😄#2019-08-1818:55Maksymhow can I connect to REPL server of my app?#2019-08-1910:26Phil JacksonHey all. When spec'ing functions, where do you call instrument in your dev environments?#2019-08-1910:27Phil JacksonEspecially so that stuff is re-instrumented when something changes.#2019-08-1913:28Karol Wójcik@thheller Is there way to use this https://www.npmjs.com/package/webpack-bundle-analyzer with shadow-cljs or with regular cljs compilation?#2019-08-1914:51thheller@karol.wojcik why would you if you can use https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-08-1917:11Karol WójcikThanks @thheller#2019-08-1914:51thhellerbut no you can't use that with shadow-cljs#2019-08-1915:02isakThat build report is one of my favorite things in shadow, soo useful :+1::skin-tone-2:#2019-08-1915:11mccraigmccraigit was one of the principal driving factors for us having just moved to shadow#2019-08-1915:09Phil JacksonIs that report built after advanced compilation?#2019-08-1915:09thhelleryes#2019-08-1915:11Phil JacksonVery cool.#2019-08-1917:34tianshu@thheller If I have a macro and a ^:dynamic variable used for some initial setup. how can I change this variable and make sure it happen before macro expansion. will put it before the macro usage work?#2019-08-1917:34thhellerhmm?#2019-08-1917:35tianshuhmm, sorry for my bad explain. assume I have a macro alert and a variblae *should-alert*#2019-08-1917:36tianshuIf I set should-alert to false, alert macro will expand to nothing. If I set should-alert to true, alert macro will expand to something.#2019-08-1917:37tianshusince shadow-cljs use parallel compile, will the order matter?#2019-08-1917:37thhellerdon't do that#2019-08-1917:38tianshu😂#2019-08-1917:39tianshuis there a correct way for this kind of requirements#2019-08-1917:39thhellerbindings are unreliable to begin with and using that binding will break the caching#2019-08-1917:40thhellerdo you want to control this via build config or how did actually set *should-alert*?#2019-08-1917:41tianshuIn my case, the *should-alert* is something like a global configuration.#2019-08-1917:42isakAnyone able to get this to work with shadow? https://github.com/Engelberg/better-cond For me it says failed to require macro-ns "better-cond.core"#2019-08-1917:42thhelleryes but how did you set it? or how do you want to set it? build config a good place?#2019-08-1917:42tianshuIt's a bit long, so I want set it in .cljs file.#2019-08-1917:43thhellerhow?#2019-08-1917:43tianshu
(set-xxx! {...})
#2019-08-1917:43thheller@isak what else does it say?#2019-08-1917:44thheller@doglooksgood I need to complete example to be able to make any recommendations. I do not yet understand what you are trying to do.#2019-08-1917:44thhellerwhat does set-xxx! do?#2019-08-1917:44tianshuThere's a complete, but not too much code example#2019-08-1917:45tianshuhttps://github.com/DogLooksGood/mcss#2019-08-1917:45isak@thheller Here is the whole error: https://gist.github.com/isaksky/eb18e32a33ceab2b619957b055187ecd#2019-08-1917:45thheller> FileNotFoundException: Could not locate better_cond/core__init.class, better_cond/core.clj or better_cond/core.cljc on classpath#2019-08-1917:46tianshuI want use macro to generate CSS string, one thing I have to deal with is vendors. I want configure which vendor used on which property.#2019-08-1917:46thhellerdid you properly restart the shadow-cljs server instance after adding the dependency?#2019-08-1917:46isakyea, I did#2019-08-1917:47thhellerlooks like you didn't though#2019-08-1917:47thhellerwhen you restart the watch make sure it doesn't say connected to server ...#2019-08-1917:48thhellerotherwise you have a server instance still running#2019-08-1917:49thheller@doglooksgood what you are trying to do is a really really really bad idea and will essentially require that cache is entirely disabled#2019-08-1917:49thhellerit will not work with caching at all.#2019-08-1917:49isakhmm, it doesn't say that#2019-08-1917:50thhellerthen please try running shadow-cljs clj-repl and then ( "better_cond/core.clj")#2019-08-1917:51isakok, it says nil#2019-08-1917:51thhellerthen you didn't add the dependency properly#2019-08-1917:51thhellerhow did you add it?#2019-08-1917:52isakI just added [better-cond "2.1.0"] to shadow-cljs.edn :dependencies, like the rest of them#2019-08-1917:52thhellerand clj-repl didn't say connected to server?#2019-08-1917:52isakno#2019-08-1917:53thheller
$ shadow-cljs clj-repl                                                               shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn  cli version: 2.8.50  node: v10.13.0
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[6:0]~shadow.user=>
#2019-08-1917:53thhellerie. it doesn't say this?#2019-08-1917:53isakIt said this for me:
$ /mnt/c/src/xportal/assets/node_modules/.bin/shadow-cljs clj-repl                                                                                              shadow-cljs - config: /mnt/c/src/xportal/assets/shadow-cljs.edn  cli version: 2.8.41  node: v11.13.0                                                            shadow-cljs - server version: 2.8.41 running at                                                                                            shadow-cljs - nREPL server started on port 55813                                                                                                                shadow-cljs - REPL - see (help)                                                                                                                                 To quit, type: :repl/quit  
#2019-08-1917:53tianshuyes, I know, it is side effects. so I want a side effects free way to achieve this. there's only one another way I know is let user define a new macro, with some options passed in.#2019-08-1917:57thheller@isak and you added the dependencies properly to /mnt/c/src/xportal/assets/shadow-cljs.edn?#2019-08-1917:57thhellernot indented incorrectly or something?#2019-08-1917:57thheller[foo.bar "1.2.3" [better-cond ...]] something like that?#2019-08-1917:58thheller@doglooksgood the only way I can recommend right now is moving that data into the build config#2019-08-1917:58thheller:compiler-options {:external-config {:mcss {:the-data true}}}#2019-08-1917:58isakyea it was correct. But now I just for run re-arranged it in the dependency list, and now i'm not getting that error - strange#2019-08-1917:58thhelleryou can get that in the macro via (get-in @cljs.env/*compiler* [:options :external-config :mcss])#2019-08-1918:00tianshuwhere I put this config?#2019-08-1918:00thhellerin your build config#2019-08-1918:02thhellerit is not a great solution but any change to :external-config will invalidate the cache so at least recompiles will happen#2019-08-1918:03thhellerchanging dynamic bindings will not invalidate the cache otherwise#2019-08-1918:03tianshuwhere can found some doc for this? you mean even I change the build config, a recompile will happen?#2019-08-1918:03thhellerthere are no docs on this since it isn't recommended to do this#2019-08-1918:04thhellerbut it is something that other libraries have done#2019-08-1918:04thhellerhttps://github.com/binaryage/cljs-devtools/blob/2c32e41f1c7b13c9a404d4d80b39b37eda729163/src/lib/devtools/prefs.clj#L9-L13#2019-08-1918:05thhellerbut yes shadow-cljs is setup to recognize changes in :compiler-options and trigger recompiles accordingly#2019-08-1918:06thhellerdoing side-effect in macros is still bad though. you could maybe build something on top build hooks https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2019-08-1918:06thhellerbut thats a bit more involved and would only work with shadow-cljs#2019-08-1918:06tianshuI see, so a :external-config in compiler options.#2019-08-1918:07thhellerI gotta go right now. I'll be back in about 2 hours. maybe we can continue then if you still need help#2019-08-1918:07tianshuokay!#2019-08-1919:20tianshu@thheller I found another way, don't know if it is good or not. If put those default configuration in a file mcss.defaults.clj, and let user provides an overwrite version if he wants. is it a good idea? since shadow support this.#2019-08-1919:21tianshusince there's only source code, it should works fine with cache.#2019-08-1919:24thhellerhmm yeah but you are still abusing the macro system for things it isn't meant to do#2019-08-1919:50tianshu🙃#2019-08-1920:03gravIs there a way of excluding shadow-cljs itself when generating the pom.xml file with shadow-cljs pom? (apart from mangling the resulting xml with xquery or something)#2019-08-1920:03thhellerwhy would you want to?#2019-08-1920:04thhellerit is only meant as a helper for tools like Cursive since it can't import shadow-cljs.edn projects#2019-08-1920:04gravI’m abusing it for some other tooling. I’m trying to create a classpath for Lumo#2019-08-1920:05gravSo my strategy is currently to 1. create a pom 2. install deps via maven 3. generate a class path with maven 4. using that classpath with lumo#2019-08-1920:06thhellerseems like you should be using deps.edn for that? clj -Spom and clj -Spath?#2019-08-1920:06gravYeah, maybe you’re right. I guess the reason I’m using pom.xml in the first place is because of Cursive#2019-08-1920:07gravBut that can use deps.edn.#2019-08-1920:08pmooserI'm trying out shadow-cljs on a new project at work, and with bootstrapped cljs repl, I get intermittent errors when loading the page that only occur if we're including the bootstrap repl functionality. It looks like "sometimes" things are being loaded twice, which results in an avalanche of errors from goog.provide (I think). Does anyone have any pointers on how you would debug this ? I've compared to example projects and don't quite see what I am doing that would cause this.#2019-08-1920:09thhellerdid you follow https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html?#2019-08-1920:09thhellerwhat is bootstrap repl functionality?#2019-08-1920:11pmooser@thheller Yes, I believe I followed that. I will review the code now to verify it. What I mean when I say "bootstrap repl functionality" is that if I leave the build as-is but remove references to my repl namespace (which requires cljs.js), the errors seem to disappear.#2019-08-1920:11pmooserI will go review that article you presented now and compare to my project - back shortly.#2019-08-1920:12thhellerwithout cljs.js in the build the self-hosted support won't be added?#2019-08-1920:12thhellerisn't that the main interface for everything in self-hosted?#2019-08-1920:30pmooser@thheller Yes, I realize that. I'm just saying, the errors are particular to that NS being included. I have no idea what causes them. This hasn't happened in previous things I've done using cljsbuild instead of shadow-cljs. I'm just trying to get it resolved. So to answer your previous question, our code does follow that article - I found a couple differences (we were initializing our compiler state to an empty state instead of the default state as you did) , and we were passing some namespaces to load-in-init in the configuration for the init call, but changing these things doesn't seem to result in anything different than what I am seeing. It is a bit challenging to evaluate because it does not happen on every reload - sometimes it doesn't even happen for many reloads.#2019-08-1920:30pmooserAt this point, I've thought I fixed it multiple times, due to this intermittency, but it always seems to come back.#2019-08-1920:30thhellercljs.js is the reason#2019-08-1920:30thhellerif that is included the necessary data is added for self-hosted support for the build#2019-08-1920:31thhellerif it isn't added the data isn't there so the bootstrap process is affected#2019-08-1920:31pmooserHow would I have a repl without including cljs.js ? It depends on what you mean by 'including' I suppose ?#2019-08-1920:32thhellerplease clarify what you mean by REPL#2019-08-1920:32pmooserI mean in my shadow-cljs.edn I have that excluded from the bootstrap build.#2019-08-1920:33pmooserI have a namespace, let's say it's called "repl" - that namepace has a require (as your example also does) which includes things like cljs.js, cljs.env, tools.reader, etc. This namespace implements a graphical repl (using reagent) which calls "eval-str" to implement a repl.#2019-08-1920:34pmooserIn a manner that as far I can tell is identical to: https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2019-08-1920:34pmooserThat is what I mean by repl. Does that make sense now ?#2019-08-1920:34pmooser(when I say it to identical to your example, I only meant insofar as how it calls eval)#2019-08-1920:35thhellerkind of yes. but my example USES the cljs.js namespace. so would you want to NOT include it?#2019-08-1920:35pmooserI need to include it#2019-08-1920:35thhellerdon't you need cljs.js/eval-str?#2019-08-1920:35pmooserI only removed it to try to help diagnose what the problem is#2019-08-1920:35thhelleryou removing it WOULD cause the problem?#2019-08-1920:35pmooserOk, I am obviously communicating really poorly --#2019-08-1920:36pmooserI need to include it. If I include it, hundreds of errors spew intermittently upon reloading my page.#2019-08-1920:36thhellerand what are you loading on that page?#2019-08-1920:36pmooserI only mentioned removing it (ie, commenting out requiring cljs.js and code that calls eval) to say that under those conditions, the errors don't occur (but of course my app doesn't "work" because those features have to be disabled).#2019-08-1920:37thhellerok. to make it clear if you remove that require things WILL break. so don't remove it and lets stop talking about that.#2019-08-1920:37pmooserI am not sure how to answer what I am loading. I am not evaluating anything by default at all. The page is a reagent page with a few buttons on it and nothing terribly interesting happening by default.#2019-08-1920:37thhellerso what is your build config?#2019-08-1920:38thhellerI am asuming that you have a build config with a :modules {:whatever { ...}}} and then loading the generated whatever.js file in the browser?#2019-08-1920:38thhellerdo you maybe load that file multiple times?#2019-08-1920:38thheller(directly from your HTML)#2019-08-1920:39pmooserIn the browser portion of the build config, I have a modules entry like this:#2019-08-1920:39pmooser
:modules          {:main {:entries [myapp.core]}}
#2019-08-1920:40thhellerso how do you load the main.js file?#2019-08-1920:40pmooserI have a script tag in the head like this:#2019-08-1920:41pmooser
<script src="/js/main.js"></script>
#2019-08-1920:41thhellergood. and that is the only time /js/main.js is included?#2019-08-1920:41thhellernot a second one in the body or something#2019-08-1920:41pmooserYes, but I do call a main() fn in the body like this:#2019-08-1920:41pmooser
<script>myapp.core.main();</script>
#2019-08-1920:41pmooser(I assume that is OK)#2019-08-1920:42thhelleryes that is ok. not ideal but ok.#2019-08-1920:42thhellerso what does the main fn do?#2019-08-1920:43pmooserMain in this case essentially does some loading of external resources (via http calls) and once that stuff is done, it calls this fn as its last thing:#2019-08-1920:43pmooser
(defn render-app
  []
  (let [app (.getElementById js/document "app")]
    (r/render [home-page] app)))
#2019-08-1920:44thhellerso and when do the errors start happening?#2019-08-1920:45pmooserThe errors happen part-way through initialization as far as I can tell - they start spewing almost immediately upon page reload, and there are hundreds of them.#2019-08-1920:45thhellerok are you properly dealing with the async aspects?#2019-08-1920:46thhellereg. in my example the boot/init fn is called and it takes a callback#2019-08-1920:46thhellerit is NOT safe you use anything before that has completed its work and the callback was called#2019-08-1920:46pmooserMy callback doesn't happen to do anything there - but I'm not calling eval-str by the time these errors occur anyway.#2019-08-1920:47pmooserIs that what you mean, that I should ensure no one can be calling eval until the init-cb occurs ? I can do that work but that isn't what is happening regardless.#2019-08-1920:47pmooserThe intermittency is what is confusing - I am trying to force it to happen now by reloading over and over but at the moment I can't get it to occur.#2019-08-1920:47thhellerI can only guess what is happening. what you are describing sounds like things are initialized multiple times#2019-08-1920:48pmooserI 100% agree with that -#2019-08-1920:48thhellerwell intermittency can be caused by async events happening in a different order#2019-08-1920:48thhellerdue to timing being different and so on#2019-08-1920:49pmooserThe load errors are a signal (since they are provide complaining) but I can verify that it is definitely loading namespaces multiple times when it occurs.#2019-08-1920:49thhellerwell for one you should remove your manual <script>myapp.core.main();</script> call#2019-08-1920:49thhellermove your <script src="/js/main.js"> to the bottom of your page right above your </body>#2019-08-1920:49pmooserWhat's the alternative to that main call, since loading the script itself doesn't launch the app ?#2019-08-1920:50pmooser(what I mean is, it's not like there is a call to (main) at the end of some ns or something)#2019-08-1920:50thhellerand switch your build config to :modules {:main {:init-fn myapp.core/main}}#2019-08-1920:50pmooserah!#2019-08-1920:50pmooserOk#2019-08-1920:50pmooserThank you, I will give that a try.#2019-08-1920:50thhellerthat at least ensures that part of the code is all loaded in the correct order and initialized correctly#2019-08-1920:52thhellerbut your setup seemed otherwise correct so that likely wouldn't change anything#2019-08-1920:52pmooserOK, I'm getting a compiler error, I need to figure out what I did wrong.#2019-08-1920:52thhellerjust trying to eliminate potential timing issues#2019-08-1920:53pmooserOk, fixed my compilation issue. Yes, I understand, and I appreciate the help.#2019-08-1920:53pmooserI also understand why you are worried about the asynchrony.#2019-08-1920:53pmooserI wonder if I can add some debugging code to dump a stack on load to try to see where the two calls would be originating from.#2019-08-1920:53thhellerthe browser devtools network requires might provide a clue#2019-08-1920:54thhellerthey show what triggered the load#2019-08-1920:54pmooserOh? Fantastic.#2019-08-1920:54pmooserI will try to see if I can get some insight from that.#2019-08-1920:54pmooserFor the time being, I will commit the changes you suggested about how I invoke main - thank you for that.#2019-08-1920:55pmooserWhen it occurs it again (assuming it does), I will see if I can diagnose using the network info from devtools.#2019-08-1920:55pmooserThank you !!#2019-08-1920:55thhellerif you use the regular REPL together with your custom self-hosted REPL things will likely go very wrong#2019-08-1920:55thhellerso that might be another cause#2019-08-1920:58pmooserI don't tend to use those things together so I don't think that is probably it, but I am glad to know that.#2019-08-2002:48QuestI have an inconsistently occurring bug to report -- In Emacs, if I start M-x cider-jack-in-cljs it usually (90% of time) fails with below output. One in 10 runs inexplicably succeeds.
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (608 files, 1 compiled, 0 warnings, 3.68s)
To quit, type: :cljs/quit
user> [:selected :app]
shutting down ...
cljs.user> 
*** Closed on Mon Aug 19 18:38:22 2019 ***
If I delete the
[:app] Build completed. (608 files, 607 compiled, 0 warnings, 16.99s)
To quit, type: :cljs/quit
user> [:selected :app]
cljs.user> 
Starting via lein dev works fine 100% of the time. Deleting the folder .shadow-cljs/builds/app/dev/ana/northstar seems to raise the success rate to around ~50%
#2019-08-2002:48Questoutput from the nrepl-server buffer:
shadow-cljs - server pid exists but server appears to be dead, proceeding without server.
shadow-cljs - config: /Users/quest/repos/ns/browser/shadow-cljs.edn  cli version: 2.8.46  node: v12.8.0
shadow-cljs - running: lein update-in :dependencies conj [nrepl "0.6.0"] -- update-in :dependencies conj [cider/piggieback "0.4.0"] -- update-in :dependencies conj [refactor-nrepl "2.4.0"] -- update-in :dependencies conj [cider/cider-nrepl "0.21.1"] -- run -m shadow.cljs.devtools.cli --npm -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.21.1 server
shutting down..
#2019-08-2002:55Quest* Whether I launch the browser or not (when prompted) seems to have no effect. * Deleting .shadow-cljs/builds/app/dev/ana/cljs seems to raise success rate to 100%. I notice that it's a 5MB+ folder, which probably causes the compilation step to take longer. * However deleting .shadow-cljs/builds/app/dev/ana/re_frame still results in a noticeable amount of failure -- but it's only a 500K library, so maybe similar to deleting my ana/northstar/browser (project's) folder#2019-08-2002:57QuestMy guess is some sort of race condition that's negated by sufficiently increased compilation time. Unfortunately the guess is all I have, but I'll assist with troubleshooting however possible#2019-08-2002:59QuestRunning on OSX Mojave 10.14.6, GNU Emacs 26.2#2019-08-2006:00thheller@quest try limiting the amount of RAM shadow-cljs uses by setting :jvm-opts ["-Xmx2G"] (or 1G) in project.clj#2019-08-2016:50QuestCan confirm -- setting :jvm-opts ["-Xmx1G"] in project.clj :profiles -> :dev completely fixes it. Doesn't seem to matter if it gets 1G or 2G. (FYI to anyone later reading this, tried setting it in shadow-cljs.edn with no effect, so make sure you set it in project.clj)#2019-08-2016:51thhelleryes, when using lein you must set it in project.clj#2019-08-2016:51thhellerstill would like to know why it runs out of memory when running in cider but not otherwise though 😛#2019-08-2016:51Quest@thheller Thanks for the help. I was quite baffled by this for the last week -- I recall that you recommended bumping memory a few days ago, but I thought the cause was something else 😅#2019-08-2016:52thheller1G is usually enough unless you have really big builds then :advanced compilation might require more#2019-08-2016:52Questyeah, that I'm not sure of. only guess is the extra CIDER dependencies increasing mem-usage past some critical threshhold#2019-08-2017:55kasukoSo I was running into something similar, when a I would run shadow-cljs watch app without the server running and I would get the attached error. This ran fine if I started the server ahead of time. Sure enough limiting the RAM helped. I have no clue why running this with more RAM causes this to break. If I run the command while providing 4GB to Java it will cause the same issue. (I'm sitting at 6GB in use out of 16GB right now, so it's not running out of memory) EDIT: Just to be clear, this issue is FIXED by adding :jvm-opts ["-Xmx2G"] to my shadow-cljs.edn file. I was just wondering if there was any reason why that fix works?#2019-08-2018:09thhelleron CircleCI reaching a certain amount of memory caused the OOM Killer from the OS to kill the process#2019-08-2018:09thhellerso maybe something similar exists on OSX? I'm not sure#2019-08-2018:10thhellermight be something in emacs itself that causes the kill#2019-08-2018:11thhellersomething from the OS must be doing that. the JVM doesn't kill itself and neither does shadow-cljs#2019-08-2018:17thhellerI'd be very curious to find out what is happening but dunno where to look and this has never happened to me either#2019-08-2019:20QuestDid some more testing. If I set :jvm-opts ["-Xmx4G"] in project.clj, it gives the shutting down.. start message at least 30%+ of the time. Values of 1G or 2G seem 100% stable. Setting :jvm-opts in shadow-cljs.edn seems to have no effect regardless of 1G, 2G, or 4G#2019-08-2019:23QuestNo idea why this is -- but here's a standing offer to help troubleshoot if you get any ideas#2019-08-2019:24Quest(My system is at 18 / 32gb, so don't think it's related to OOM)#2019-08-2019:30thhellerdunno I also have 32gb with about 16gb free#2019-08-2019:30thhellerthe only thing I don't have is emacs and cider#2019-08-2019:30thhellerno clue what does#2019-08-2020:46Questdid some more testing, can repro the shutdown >50% time with /usr/local/bin/npx shadow-cljs watch app#2019-08-2020:47Quest#2019-08-2020:48QuestTried to look through the OSX kernel logs but didn't notice anything suspicious. I'm out of ideas for now :man-shrugging:#2019-08-2020:48Quest(did try setting :jvm-opts in shadow-cljs.edn to 1/2/4G values, didn't seem to make a difference)#2019-08-2020:49thhelleris that with cider being connected or completely standalone?#2019-08-2020:49Questcompletely standalone via /usr/local/bin/npx shadow-cljs watch app#2019-08-2020:51thhellerno clue. the only thing triggering a shutdown should be either the JVM process getting killed, the node process getting killed or explicitely calling (shadow.cljs.devtools.server/stop!)#2019-08-2020:52QuestPossible that it's self killing due to requesting too many threads too quickly & getting execution denied? seems tied to OSX somehow. Running on a 2019 macbook pro.. wonder if an artificial Thread/sleep at some point in startup would "fix" this#2019-08-2020:52Quest(remembering that deleting the 5MB cljs folder from .shadow-cljs cache made the issue go away 100% of the time for that run)#2019-08-2020:53thheller[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 242]#2019-08-2020:53thhellerthe thread pool is getting shutdown, no overload in sight#2019-08-2020:56thhellerplease try running shadow-cljs clj-repl and just let it sit for a bit#2019-08-2020:56thhellersee if shuts down on its own too#2019-08-2020:56thhellerof not try running (shadow/watch :app {:verbose true}) after a bit#2019-08-2020:57Questinitialized to shadow.user=> just fine, letting it sit a minute#2019-08-2021:00Quest#2019-08-2021:03Questa subsequent run got through the [:app] Build completed (608 files, 1 compiled, 0 warnings, 4.34s) and gave me back the [1:0]~shadow.user=>, so seems that we did trigger a shutdown somehow#2019-08-2022:00thhellercurious that it even gets to the build completed message since the shutdown is triggered somewhere in the middle#2019-08-2022:01thhellerbut I guess the work is already queued so it just keeps going and waits with the actual shutdown#2019-08-2022:02thhellerotherwise looks fine. nothing suspicious except the shutdown getting triggered in the middle#2019-08-2022:02thhellerwhich java -version do you use?#2019-08-2022:58Quest
> java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
#2019-08-2023:02QuestI can try a different one if you'd like, just let me know which#2019-08-2106:52thhellerno idea. you could try jdk11 or 12 maybe but I'd be very surprised if that changes anything#2019-08-2106:53thhelleryou could maybe try running (shadow/compile :app) to see if that also gets terminated#2019-08-2106:53thhellerand then maybe (shadow/release :app)#2019-08-2106:53thhellerthe compilation process is almost identical so I presume they are all going to be shut down#2019-08-2106:54thhellerbut release won't include all the re-frame-10x code so it might survive due to using less resources#2019-08-2006:01thhellerdunno why deleting cache files changes your success rate since compilation recreates the exact same state again anways#2019-08-2006:02thhellerno clue what emacs does when running processes. maybe it is somehow monitoring the processes or causes it to have other resource constraints#2019-08-2006:04thhellerbut other people have reported issues with cider as well and limiting the memory seems to help#2019-08-2012:36jpmonettashi everybody! is there a place in shadow-cljs.edn to add es6 js files I want to add locally (not coming from npm). My use case is that I'm using a library that needs me to provide it objects that extends from others and I think I prefer to leave those as es6 js code instead of replicating that in clojurescript with goog.object/extend etc#2019-08-2012:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-08-2012:37thhellerjust put it next to your .cljs files#2019-08-2012:40jpmonettasthanks a lot!#2019-08-2018:27tianshucan react and react-dom be benefit from optimizations of closure compiler?#2019-08-2018:27tianshuthe react-dom bundle size is pretty large#2019-08-2018:28thhellerin theory they can but it is not recommended and requires tweaking by hand#2019-08-2018:28thhellercould also break with any new release and most OTHER libraries don't work#2019-08-2018:29thhelleralso doesn't make it that much smaller#2019-08-2018:29thhellerso not worth the effort#2019-08-2018:29tianshuI want to reduce the bundle, in my case now it's about 370kb but use on not so good network#2019-08-2018:29thhelleris that gzip'd?#2019-08-2018:29tianshuYes, gzip'd#2019-08-2018:30thhellerhmm yeah thats a bit large. did you create a build report? https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-08-2018:30tianshuYes#2019-08-2018:31tianshu#2019-08-2018:31tianshuThere're few dependencies I have plan to remove, like expound#2019-08-2018:32thhellerclojurescript seems too large? maybe you included cljs.pprint?#2019-08-2018:32tianshuI don't know why, is it normal?#2019-08-2018:32thhellerclick the little expand icon in front of clojurescript#2019-08-2018:33tianshuIt's about 5731 lines of cljs#2019-08-2018:33tianshucljs/core.cljs 232.04 KB cljs/pprint.cljs 98.44 KB cljs/analyzer.cljc 95.13 KB cljs/spec/alpha.cljs 54.73 KB cljs/spec/gen/alpha.cljs 23.27 KB cljs/spec/test/alpha.cljs 12.15 KB cljs/stacktrace.cljc 5.56 KB cljs/reader.cljs 3.46 KB#2019-08-2018:33tianshuOhh, pprint#2019-08-2018:33thhellerhmm do you use self hosted stuff?#2019-08-2018:33tianshuno#2019-08-2018:34thhellerhmm then cljs.analyzer shouldn't be in there either
#2019-08-2018:34tianshuwait, what you mean by self hosted#2019-08-2018:34tianshuIs that if I use it in macro, that cljs will be included as well?#2019-08-2018:34thhellerdepends on how you included it?#2019-08-2018:35tianshuJust like pprint, I didn't use it, just forgot to delete the require in ns form#2019-08-2018:35thhellerif you use the web UI (default at http://localhost:9630)#2019-08-2018:35thhellerthere is a little UI thingy to tell you why a namespace was included in a build#2019-08-2018:36tianshuwait a moment, I'm going to start this#2019-08-2018:37thhellerpprint unfortunately isn't compatible with DCE in the way it is currently written https://clojure.atlassian.net/browse/CLJS-2885#2019-08-2018:39tianshuweb UI looks great#2019-08-2018:39thhellerif you select your build and hit compile#2019-08-2018:39thhellerit'll have a "Build Namespaces" select box at the bottom#2019-08-2018:40thhellerselect cljs.analyzer and it'll tell you why it is included (which namespace included it)#2019-08-2018:40thhellerbut I guess you already found it 😉#2019-08-2018:40tianshureitit.coercion.spec -> spec-tools.core -> spec-tools.impl -> cljs.analyzer.api -> cljs.analyzer#2019-08-2018:40tianshu....sad#2019-08-2018:41thhellerinteresting. someone should open a bug report there 😉#2019-08-2018:42tianshuthe spec-tools is using this...#2019-08-2018:42thhelleryeah but it very likely doesn't actually need it#2019-08-2018:42thhellercljs.analyzer.api is very likely only used from the CLJ macro side#2019-08-2018:42thhellerso including it in the CLJS side is pointless#2019-08-2018:43tianshucljs.spec is also not so small#2019-08-2018:43thhelleryep https://clojure.atlassian.net/browse/CLJS-1701#2019-08-2018:44tianshuI found one thing, report is not support if there's multiple modules?#2019-08-2018:44thhellersure it is#2019-08-2018:44thhellerhttps://code.thheller.com/demos/build-report/huge.html example report has multiple#2019-08-2018:45tianshubut In my project it doesn't, I have two moudles, one is :base :base {:entries []}#2019-08-2018:46tianshu:strip-type-prefixes #{"cljs.spec"} where can I put this#2019-08-2018:46tianshuI also just want to remove all spec#2019-08-2018:46thhellerdoesn't work for spec anymore#2019-08-2018:47thhelleran empty :base module doesn't make sense when you only have 2 modules#2019-08-2018:47tianshuIn my dev build, I have another module called devcards, main and devcards both depends on base#2019-08-2018:48thhellerdev build? you are likely using shadow-cljs wrong if you have a build named :dev#2019-08-2018:48thhellerthats not how it works at all 😛#2019-08-2018:48tianshuno, actually it is app.#2019-08-2018:48thhellerdevcards should likely be its own build#2019-08-2018:48thhellerdefinitely wrong to include that as a :module#2019-08-2018:49tianshushould I make it a build?#2019-08-2018:50thhellera good rule to remember for :modules is that you should only use them if and only if ONE user may end up using ALL modules#2019-08-2018:50thhellerie :devcards likely won't be used by your users and only by you during development#2019-08-2018:50thhellertherefore it should be in a different build#2019-08-2018:51tianshuBut If I make it another build, I know I can start two build in shadow, but Can I connect to two browser environment in one cljs repl?#2019-08-2018:51thhellershadow-cljs watch app devcards starts two builds#2019-08-2018:52thhellerno to the REPL. they are separate#2019-08-2018:52thhellerbut they would be anyways?#2019-08-2018:52thhelleryou likely aren't loading your app and devcards in the same browser tab?#2019-08-2018:52tianshuYou know, cider (basically except cursive) rely on repl to provide auto-completion and many other features.#2019-08-2018:53thhellerCursive doesn't rely on that no#2019-08-2018:53tianshuYes, I know#2019-08-2018:53tianshubut it's easy to solve, I can just start two emacs instances#2019-08-2018:53thhelleryou can also just load your main entries in the devcards build#2019-08-2018:53tianshuI'll make it another build.#2019-08-2018:54thhellerso they have the code loaded#2019-08-2018:54thhellerbut yeah cider relying on nrepl so much may be a problem with too many builds#2019-08-2018:56tianshuyes, it is#2019-08-2018:56tianshuI just remove pprint#2019-08-2018:56tianshuhow can I easily remove all specs? I have a few cljc file#2019-08-2018:56thhellerunfortunately can't#2019-08-2018:57tianshualright#2019-08-2018:57thhellerneed to do something like this https://github.com/wilkerlucio/pathom/blob/master/src/com/wsscode/pathom/core.cljc#L24#2019-08-2018:58tianshugood#2019-08-2018:58thhelleror move all specs in a separate files and include them via :preloads#2019-08-2018:58tianshuHow can I add conditional dependencies depend on :dev and :release with tools-deps#2019-08-2018:59thheller:preloads#2019-08-2018:59tianshu:preloads?#2019-08-2018:59tianshucurrently I have devtools, but it appears in the report.#2019-08-2018:59thhellerin the build report?#2019-08-2019:00tianshuyes#2019-08-2019:00thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_preloads#2019-08-2019:00tianshuNo, I mean#2019-08-2019:00tianshuIn the WEB UI#2019-08-2019:00thhellerif you included that properly via preloads then it shouldn't be in there#2019-08-2019:00thhellerthe web ui shows you what you built#2019-08-2019:00tianshubut pprint is still in report#2019-08-2019:01thhellerso if you pressed the compile button it shows you a :dev build#2019-08-2019:01tianshuand in web UI I found it is required by devtools#2019-08-2019:01thhellerpress the release button instead to see the release deps/namespaces#2019-08-2019:03tianshuI'm trying to regenerate a report#2019-08-2019:04tianshuorg.clojure/clojurescript is still 400k#2019-08-2019:05thhellerwell whats in it?#2019-08-2019:05thhellerwith spec that seems about right#2019-08-2019:06tianshuYes, only one thing, cljs.analyzer. I have to switch a router to remove that.#2019-08-2019:06tianshuOH, I can patch that maybe#2019-08-2019:07tianshuhttps://github.com/metosin/spec-tools/blob/master/src/spec_tools/impl.cljc#L17#2019-08-2019:08thhellerhttps://github.com/metosin/spec-tools/blob/master/src/spec_tools/impl.cljc#L5#2019-08-2019:09thhellercan probably switch that to :clj instead#2019-08-2019:11thhellerI hate .cljc so much. so misunderstood and often used incorrectly#2019-08-2019:11tianshusometimes i like it because can share code, especially configuration.#2019-08-2019:12thhelleryeah but it is so easy to get wrong, especially with macros#2019-08-2019:12thhellerI guess they are doing this to support the self-hosted stuff but even then it seems wrong#2019-08-2019:15thhellerbut yeah conditional code include is tough and needs a better solution#2019-08-2019:16tianshudon't know the reason, maybe caused by eval loader#2019-08-2019:16tianshusometimes, the chrome hangs#2019-08-2019:18thhellerdepends on how much code you load I guess. from your build-report it doesn't seem too excessive. but dunno how much dev stuff you add (eg. re-frame-10x adds a whole lot)#2019-08-2019:18tianshuoften happened when I switch build#2019-08-2019:18tianshunot happened in common usage#2019-08-2019:18thhellerdunno. never happens for me so you'll have to debug a bit yourself#2019-08-2019:20tianshuI copy that file change that macro to always return nil. I think it won't affect anything in my project#2019-08-2019:20tianshucljs is 296 kb now#2019-08-2019:25tianshuI was trying to use module split in my project, and it works pretty good. however it won't load module in a browser, (that is our mainly target browser), no tools or any information to debug. So have to give it up.#2019-08-2019:26tianshuThe result is good to me now, it's gizp'd 300kb. I'm going to remove a few more things. thanks for the great help today!!#2019-08-2019:26tianshushadow is awesome!#2019-08-2019:30Questshadow-cljs is a great tool & the level of support thheller provides here is exceptional. If you agree, please consider subbing https://www.patreon.com/thheller/overview to keep it rolling 🙂#2019-08-2019:56metehan
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/spill"
  "src/test"]

 :dependencies
 [[org.clojure/core.async "0.4.500"]
  [reagent "0.8.1"]
  [re-frame "0.10.6"]
  [bouncer "1.0.1"]
  [com.andrewmcveigh/cljs-time "0.5.2"]
  [clj-commons/secretary "1.2.4"]
  [venantius/accountant "0.2.4"]
  [binaryage/oops "0.7.0"]
  [binaryage/devtools "0.9.10"]
  [day8.re-frame/re-frame-10x "0.3.7-react16"]
  [day8.re-frame/tracing "0.5.1"]]

 :builds {:app {:output-dir "web/root/js/shadow"
                :asset-path "js/shadow"
                :target :browser
                :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
                :preloads [devtools.preload day8.re-frame-10x.preload]
                :modules {:app {:init-fn spill.app.core/init}}
                :main "spill.app.core"
                :devtools {:http-root "web/root"
                           :http-port 8080}
                :compiler-options {:optimizations :none}}}}
#2019-08-2019:57metehanwith this configuration i can't run re-frame-10x#2019-08-2019:57metehanwhat i am doing wrong#2019-08-2020:11stefan#2019-08-2020:11stefanthat config works for me#2019-08-2020:14stefanI think moving :preloads into :devtools, and adding re-frame.trace/trace-enabled? true to your :closure-defines map may do it#2019-08-2020:20thheller:main "spill.app.core" that does nothing and can be removed#2019-08-2020:20thheller:compiler-options {:optimizations :none} also does nothing and can be removed#2019-08-2020:20thhellerbesides that I think it may require an extra closure-define?#2019-08-2020:21thhelleroh and :preloads belongs in :devtools#2019-08-2020:21thhelleror into :modules {:app {:init-fn ... :preloads [...]}}#2019-08-2020:26metehan@thheller @stefan.age thank you very much it's working now 🙂#2019-08-2022:18isakIs it possible to configure something like an :asset-path to go along with [:devtools :watch-dir] ? Watch-dir does not work for me, and I think it is because the URLs are not generated like :watch-dir expects (just /some/path under :watch-dir) - in my case I have a prefix.#2019-08-2112:56thhellernot sure I understand you question? can you provide an actual example of paths?#2019-08-2113:11isakI have this in my HTML: /f/css/front_dev.css , and in [:devtools :watch-dir] I have this: resources/public/css#2019-08-2113:15isakSo I think this code won't trigger: https://github.com/thheller/shadow-cljs/blob/1d3ad7ce422fde4d595868b0e9ed8ade94ee175e/src/main/shadow/cljs/devtools/client/browser.cljs#L166-L190#2019-08-2113:16thhellerso the actual files lives in resources/public/css/f/css/front_dev.css?#2019-08-2113:18thhellerwatch is assuming it is watching files that are directly served by a webserver#2019-08-2113:18thhellerif it is not then it won't work#2019-08-2113:18isakNo, the actual paths lack the /f/ there#2019-08-2113:19thhellerso what is /f/? why does that exist?#2019-08-2113:19isakIt just makes the hosting easier. For example for the main build, I have this:
:output-dir "resources/public/js/compiled"
	 :asset-path "/f/js/compiled"
and therefore that part works
#2019-08-2113:19thhellerthe system would expect you to use :watch-dir "resources/public" and then put the actual file into resources/public/css/front_dev.css and use /css/front_dev.css as the path in HTML#2019-08-2113:20thhellerstill doesn't explain what the /f is#2019-08-2113:20isakyea, but that is because there is no equivalent of the asset path for the watch dir, though#2019-08-2113:20isakits just a "virtual directory" on the web server that hosts everything under "resources/public"#2019-08-2113:21thhellerwhy is it a virtual directory? why is it not an actual directory?#2019-08-2113:23isakIt is kind of a routing simplification, since this is clojurescript being added to a legacy application#2019-08-2113:24thhellersorry I don't follow how that plays into anything? why not just create resources/public/f/css/front_dev.css? and have you webserver serve resources/public like every web server out there?#2019-08-2113:26isakIt already has a different public directory#2019-08-2113:26thhellerand you can't put files there?#2019-08-2113:28isakI can, but then I'd have other problems with source control#2019-08-2113:29thhellerI can't think of an easy way to do this right now. I don't want to overcomplicate the config#2019-08-2113:31isakOk, I'll look into the hard way#2019-08-2113:31thhellerI could maybe add a secondary attribute to the <link tag itself that is used to compare#2019-08-2113:32thhellerright now it only checks the href but it could also check something like <link rel="stylesheet" href="/f/css/front_dev.css" data-css-path="/css/front_dev.css" />#2019-08-2113:33thhelleror some other html attribute that lets you specify which actual file this is supposed to be#2019-08-2113:33isakyea that would work. though isn't this conceptually the same as asset-path, just for the css?#2019-08-2113:35isak{:watch-dir "resources/public" :watch-asset-path "/f"}#2019-08-2113:35thhellerhehe. just looked at the code and guess what ...#2019-08-2113:36thheller{:watch-dir "resources/public" :watch-path "/f"}#2019-08-2113:36thhelleralready exists 😛#2019-08-2113:36isakomg 🙂#2019-08-2113:37thhellerI can't even remember that I ever added that#2019-08-2113:38thhellerwasn't even that long ago 😛#2019-08-2113:38thhellerbut that should do what you need right?#2019-08-2113:38isaknice, and it is implemented? yea, sounds perfect#2019-08-2113:39thhelleryeah apparantly has been there for about 6 months 😛#2019-08-2113:42isakwow that worked, thanks!!#2019-08-2113:46thhelleradded it to the docs as well now. maybe this time I won't forget this exists 😉#2019-08-2113:46isak🙂#2019-08-2100:08dpsutton@quest in further investigation is CIDER still a possible culprit? I have more time now to investigate with you if you’re still working on it#2019-08-2100:10QuestDon't think so -- happened upon a threadpool exception on one of those runs, so my current theory is that OSX is sometimes nuking the process due for unknown reasons. Appreciate the follow-up though!#2019-08-2100:10dpsuttonFor sure. Good luck to you and feel free to ping if I can help more#2019-08-2100:11Questthanks. we've chatted a bit more a thread https://clojurians.slack.com/archives/C6N245JGG/p1566280843100200?thread_ts=1566280843.100200&amp;cid=C6N245JGG but nothing is apparent#2019-08-2100:34dpsuttonYeah I read through it. I’m a bit confused because there’s no lein involved so I expected the jvm settings from the shadow edn file to work#2019-08-2102:18QuestYou're not wrong... no idea why it doesn't. For posterity, this is my shadow-cljs.edn file with the jvm-opts set. It's the vanilla re-frame-template https://github.com/Day8/re-frame-template#2019-08-2106:50thhelleras soon as you set :lein true the :jvm-opts have no effect since lein will be starting the JVM.#2019-08-2103:35superstructor@quest Thanks for using re-frame-template and investigating the cider issue. Do you think the :jvm-opts is something I should add to the +cider profile ? If it reliably solves the issue then at least cider users won't get any bad surprises when using the template ?#2019-08-2105:50Quest@superstructor I'd recommend it... setting :jvm-opts ["-Xmx1G"] seems to reliably fix the issue 100% of the time. If nothing else, might be worth mentioning on the re-frame template README. This issue could be just on OSX though -- I'm not sure about Windows/*nix. Without the option & with the .shadow-cljs cache already present, it seems to pass/fail every other launch#2019-08-2119:48superstructorDone and released. Thanks 🙂#2019-08-2107:39thheller@quest FWIW I can run with -Xmx16G just fine. it should be dying 100% for you with that right?#2019-08-2107:45thhelleryou could maybe try running clj -J-Xms16G (note -Xms not -Xmx) which sets the min amount of RAM#2019-08-2107:46thhellerso it should in theory die instantly if the OS is killing it just because of RAM?#2019-08-2107:46thhellerwell maybe not. it just reserves the memory but doesn't actually use it#2019-08-2108:35thhellerfun little debug utility I just added to master. finds top level forms generating a big chunk of JS.#2019-08-2108:35thheller(in this case forms above 45000 bytes)#2019-08-2108:38thhellernot super useful but interesting to see how much code some forms generate#2019-08-2108:38thheller> Form produced 643580 bytes of JavaScript#2019-08-2109:33mccraigmccraigsounds interesting to me @thheller - output size is a top priority for us atm, and selected info finer-grained than per-namespace sounds useful#2019-08-2109:34thhellerI'd stick to build reports for since this number really doesn't mean much.#2019-08-2109:35thhellerfor example the above generated 643kb is just because it is a macro generating a large (do ...) but all the code is fully removable#2019-08-2109:36thhellerbut can still be interesting to know. I have done a fair bit of size tuning myself over the years but the build reports have been the only truly useful thing so far#2019-08-2109:36thhellerother than digging into the actual sources directly and getting rid of bad concepts that prevented DCE#2019-08-2109:36thhellerbut for that you kinda need to know how DCE works 😉#2019-08-2109:36mccraigmccraigah, yeah, if the reported output is all removable, that makes it a less useful metric#2019-08-2109:37thhellerworst offender currently is cljs.spec when only used for fspecs and instrument stuff. meaning not actually at runtime in release builds#2019-08-2109:38thhellerit still all ends up in the code if you aren't careful#2019-08-2109:39thheller(and npm deps of course) 😉#2019-08-2109:43mccraigmccraighmm - are there any docs around what being careful constitutes - i'm not at all sure we're not missing some tricks#2019-08-2109:44thhellerfirst of all I'd say: don't worry about it#2019-08-2109:45thhellerthen look at the build reports. eliminate as many JS deps as you can. then start looking at CLJS code and eliminate the obvious offenders (eg. cljs.pprint)#2019-08-2109:45thhelleronly dig deeper into namespaces using more than like 100kb or so#2019-08-2109:46thhellerunfortunately it isn't possible to tell the actual gzip contribution so there may be code that compresses way better than other code#2019-08-2109:48thhellerone common offender for me is reagent due the the amount of keywords it might generated#2019-08-2109:48thhellerbut it doesn't really make sense to optimize the amount of keywords either#2019-08-2109:49thhellerie. not worth worrying about those bytes since there are bigger fish to fry 😉#2019-08-2111:15mccraigmccraigyeah, we've only got one namespace in the 100kb size range, a couple in the 50kb range, and a lot much smaller - total output size 2.8MB atm. using the build report to figure out how best to modularise seems like the biggest win for us atm#2019-08-2112:46metehanwhen I run shadow cljs I run this command too sass --watch web/scss/spill/spill.scss web/root/css/app.css to get my sass compiled. Is there any way to run this with shadow?#2019-08-2112:54thhellernot currently but maybe soon 😉#2019-08-2113:01metehancool, btw shadow is great since yesterday I was playing with it. thanks for making this 🙂#2019-08-2114:07defaI’m trying to set up a project with a pedestal backend and re-frame frontend using clj/deps.edn and shadow-cljs but I can not figure out how to put things together. How to I configure the pedestal backend to be used by shadow-js or am I getting something completely wrong?#2019-08-2114:08thhellershadow-cljs just output files and your pedestal backend should serve them#2019-08-2114:08thhellerthats as far as the connection goes. pedestal doesn't need to know anything about shadow-cljs#2019-08-2114:11thhellerin your pedestal service conf you can set ::http/file-path "public"#2019-08-2114:11thhellerand have shadow-cljs output to public/js (does so by default)#2019-08-2114:11thhellerwhich you then access via (or whatever your module name was)#2019-08-2114:13defaI stared modifying the re-frame lein template and got confused by the :http-handler option: https://github.com/Day8/re-frame-template/blob/ed85dc98ad383fd03d61acaa8a2092af89bee8c0/src/leiningen/new/re_frame/shadow-cljs.edn#L22#2019-08-2114:13defa… in the :devtools section of shadow-cljs.edn.#2019-08-2114:13thhellerdunno why that is in the that template but it is not used if you use your own pedestal backend#2019-08-2114:20thheller@superstructor the config generated by the template is unnecessarily complex and could be modernized a bit#2019-08-2114:21thhellerit generated this
{:lein   true

 :nrepl {:port 8777}

 :builds {:app {:target          :browser
                :output-dir      "resources/public/js/compiled"
                :asset-path      "/js/compiled"
                :dev             {:modules          {:app {:entries [devtools.preload
                                                                     day8.re-frame-10x.preload
                                                                     dummy-10x.core]}}
                                  :compiler-options {:closure-defines {re-frame.trace.trace-enabled?        true
                                                                       day8.re-frame.tracing.trace-enabled? true}}}
                :release         {:modules          {:app {:entries [dummy-10x.core]}}
                                  :compiler-options {:optimizations :advanced
                                                     :pretty-print  false
                                                     :closure-defines {goog.DEBUG                           false
                                                                       re-frame.trace.trace-enabled?        false
                                                                       day8.re-frame.tracing.trace-enabled? false}}}
                :devtools        {:http-root    "resources/public"
                                  :http-port    8280
                                  :preloads     [devtools.preload
                                                 day8.re-frame-10x.preload]
                                  :after-load   dummy-10x.core/mount-root}}}}
#2019-08-2114:21thhellerand could be this
{:lein true

 :nrepl {:port 8777}

 :dev-http {8280 "resources/public"}

 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules {:app {:init-fn dummy-10x.core/init
                                :preloads [devtools.preload
                                           day8.re-frame-10x.preload]}}
                :dev {:closure-defines {re-frame.trace.trace-enabled? true
                                        day8.re-frame.tracing.trace-enabled? true}}}}}
#2019-08-2114:22thhellerI'll see if I can throw together a PR#2019-08-2118:54superstructorThanks for the review and PR @thheller Much appreciated! I have merged and will release shortly.#2019-08-2119:48superstructorReleased 🙂#2019-08-2114:26defa@thheller thanks! so there are two http-servers running: pedestal and the one that is started by shadow-cljs.#2019-08-2114:26thhelleryou don't need the one started by shadow-cljs if you have your own backend#2019-08-2114:44defaGuess I have messed up my project somehow… will start with a clean slate and read the docu again.#2019-08-2114:45thhellerthere isn't much to it. if you share some config I can probably tell you where you went wrong.#2019-08-2115:04defathanks in advance, here is my config: https://pastebin.com/dtSykUxd#2019-08-2115:05thheller
:npm-deps   [
                                   {:keycloak-js "^6.0.1"}
                                   ]
this is invalid and doesn't do anything
#2019-08-2115:05thhelleryour pedestal setup is missing#2019-08-2115:05thhellermainly your service config#2019-08-2115:08defaservice.clj: https://pastebin.com/hMdUt7Gk#2019-08-2115:09thhellerok so the server is configured to run at 8080 and serving the resources/public dir#2019-08-2115:09thhellerso everything should be working fine if you open http://localhost:8080#2019-08-2115:10defaI got it to the point where everything seems to work but the automatic reload. I get the HUD showing up and telling me view.cljs has been reloaded but the page does not update.#2019-08-2115:11thhellerright you removed the hook config#2019-08-2115:11thhelleropen the telifit-web/core.cljs#2019-08-2115:12thhellerand change (defn mount-root [] to (defn ^:dev/after-load mount-root []#2019-08-2115:12thhellerthis will well shadow-cljs to call that function after it has reloaded code#2019-08-2115:12thhellerand that fn will re-render your ui#2019-08-2115:14defaThanks a lot 🙂 … it is working now. Will also have a look at your response to @superstructor regarding the unnecessarily complex shadow-cljs.edn#2019-08-2115:16thheller
{:deps {:aliases [:cljs]}
 :source-paths ["src/cljs"]
 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules {:app {:entries [telifit-web.core]
                                :preloads [devtools.preload
                                           day8.re-frame-10x.preload
                                           re-frisk.preload]}}
                :dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true
                                                           day8.re-frame.tracing.trace-enabled? true}}}
                }}}
#2019-08-2115:38defaI had a look at you pull request for the template and applied the changes to my code.#2019-08-2115:39defaThank you very much for your support. Not only shadow-cljs is impressive but also your support to the community in general!#2019-08-2119:49superstructorReleased @thheller's improvements to the template. Thanks 🙂#2019-08-2120:14thheller@superstructor cool. can you tell me how to test that template locally? I always forget 😛#2019-08-2122:55superstructorYeah its a bit magic. Anytime you run the lein new re-frame... command within the re-frame-template project dir lein will use that copy and not look for the jar.#2019-08-2118:29Quest*Edit: found the known issue affecting CIDER pprinting https://github.com/thheller/shadow-cljs/issues/510#2019-08-2120:14thhellerif you want REPL pprint you can set :devtools {:repl-pprint true}#2019-08-2120:15thhellerbut cider seems to expect some of its own stuff to do the pprint and I have no clue how that side works#2019-08-2120:25QuestI don't blame you, went digging through the code this morning and had a rough time of it. I added what little I could figure out at https://github.com/thheller/shadow-cljs/issues/510#issuecomment-523633532#2019-08-2123:56Quest@thheller just setting :devtools {:repl-pprint true} got it working in CIDER! Thank you & documented this at https://github.com/thheller/shadow-cljs/wiki/Cider#2019-08-2118:33QuestFrom thheller's response it sounds like something is stripping newlines between the browser -> Emacs REPL output. I get a single line of EDN output on my setup#2019-08-2119:10jpmonettashi! what can I use so a namespace gets reloaded but def with atoms aren't redefined? defonce doesn't seem to work for me#2019-08-2120:38thhellerdefonce is exactly for that case. dunno why it wouldn't work though? what is your build setup?#2019-08-2121:18jpmonettasthis is my shadow-cljs.edn
{:source-paths ["src/cljs"]
 :dependencies [[day8.re-frame/http-fx "0.1.6"]
                [dorothy "0.0.7"]
                [reagent "0.8.1"]
                [re-frame "0.10.8"]
                [datascript "0.17.1"]
                [re-com "2.5.0"]]
 :dev-http {9500 "resources/public/"}
 :builds {:app {:output-dir "resources/public/js/"
                :asset-path "/js"
                :target :browser
                :compiler-options {:output-feature-set :es6}
                :modules {:main {:init-fn clograms.core/init}}
                :devtools {:after-load clograms.core/mount-root}}}}
#2019-08-2121:19jpmonettasif I add ^:dev/once to the ns that has the atom then everything is fine (but I can't reload code there)#2019-08-2121:19thhelleruhm defonce is an actual (defonce the-atom (atom {})?#2019-08-2121:19jpmonettasit is exactly that#2019-08-2121:19jpmonettas(defonce storm (atom {}))#2019-08-2121:20thhellerok that shouldn't be reassigned then? unless you are manually calling (reset! storm {}) or something?#2019-08-2121:21thhelleryou can verify that it is only set once by doing (defonce storm (do (prn :init-the-atom) (atom {}))#2019-08-2121:22jpmonettasyeah I'm seeing the :init-the-atom again when reloading#2019-08-2121:23thhellerthats odd. is the name maybe conflicting with something?#2019-08-2121:24jpmonettaswow you are right, I have an alias with the same name facepalm#2019-08-2121:24thhellerns alias? that doesn't matter#2019-08-2121:25jpmonettasyeah ns alias#2019-08-2121:25jpmonettaswell, that did the trick#2019-08-2121:25jpmonettasI renamed the atom to storm-atom and now I only see the :init-the-atom once#2019-08-2121:26thhellerand what was the ns alias?#2019-08-2121:26jpmonettas(:require ["@projectstorm/react-diagrams" :as storm])#2019-08-2121:27thhellerah ok its a JS alias. I guess that might confuse things#2019-08-2121:27jpmonettasnow it works, thanks again!#2019-08-2119:24leontalbotHi! I am injecting on any live site (with a chrome extension) my app js (js/main.js) produced by shadow-cljs#2019-08-2119:25leontalbotI am getting 404 errors when page tries to load “https://www.a-live-site.com/js/cljs-runtime/…”#2019-08-2119:26leontalbotI would want the page to look for “http://localhost:3000/js/cljs-runtime/…”#2019-08-2119:26leontalbotIs there a way to do that?#2019-08-2119:27leontalbotI suppose this is obvious, but can’t find out#2019-08-2119:27leontalbotthanks!#2019-08-2119:29leontalbotI was able to serve a release build, but not ideal when I want a reload workflow for development#2019-08-2120:08msshey all, have a kind of funky situation where I’m targeting an electron browser window with node integration enabled but loading my js via a script tag. I’d like to load it via the script tag as opposed to bundling the file with my electron distribution so code updates are automatic and don’t require an app update. setting my target to :browser w/ the associated config options leads to my getting weird errors like The required JS dependency "path" is not available... despite path being installed and available in the correct dir. setting the target to :node-script appends an #!/usr/bin/env node to the output file, which doesn’t actually work in a browser context when loaded via a script tag. anyone have an idea for either 1) how to specify that node requires are kosher in a :browser target or 2) strip the #!/usr/bin/env node heading from the output file in a :node-script target?#2019-08-2120:31thheller@leontalbot there is support for building chrome extensions directly. did you use that or did you use :browser? https://github.com/thheller/shadow-cljs/issues/279#2019-08-2120:39leontalbotI used Tampermonkey + :browser#2019-08-2120:40leontalbotinteresting, so that could fix the wrong cljs-runtime urls app needs to get?#2019-08-2120:40thhelleryou can control which URL it is trying to connect to via :devtools-url https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2019-08-2120:40thhelleror just :asset-path "..."#2019-08-2120:40thhellerbut the whole things isn't really designed to be injected into arbitrary pages#2019-08-2120:41thhellerand can very easily break#2019-08-2121:03leontalbot:asset-path works, then getting CORS error#2019-08-2121:09thhelleryou might get a bit further by setting :devtools {:loader-mode :eval}#2019-08-2121:09thhellerbut yeah injecting a dev build is gonna break in various ways#2019-08-2201:34leontalbotwell, :loader-mode :eval works! thanks! only thing is I see “connection fail” bottom left warning on ui#2019-08-2207:05thhellerthat is controlled by :devtools {:devtools-url ""} since that by default will try to use the current document.location#2019-08-2120:37thheller@mss :node-script is for node scripts. it is not intended to run in the browser. you can use the regular :target :browser and set :js-options {:js-provider :require}#2019-08-2207:24Aklscchey, guys. I use clojurescript to call some javascript library function, but this will make this in the called function invalid. Is it relative to the compiler? @thheller#2019-08-2207:25thhellerhow do you call it?#2019-08-2207:25thheller(.thatFn the-object 1 2 3) will keep the-object as this?#2019-08-2207:26thheller.bind and other tricks don't work so well with CLJS currently#2019-08-2207:26AklsccNo, the bare javascript function must call by ((.-thatFn obj) arg1 arg2)#2019-08-2207:27thhellerwhy not (.thatFn obj arg1 arg2)? whats the point of getting the fn off the object first?#2019-08-2207:27AklsccIt's npm library for javascript.#2019-08-2207:28thhelleryou are not calling (obj.thatFn)(arg1, arg2) in JS either?#2019-08-2207:29Aklscc(.-fn obj arg1 arg2) I also try it, but doesn't work too.#2019-08-2207:30thhellerremove the -#2019-08-2207:30thheller.-fn is short for getting that property`. (.fn ...) is short for calling that fn#2019-08-2207:31Aklscc(.-fn obj) will get the function, so the first way doesn't matter, I have verified it.#2019-08-2207:32thhelleryes exactly. (.-fn obj) will GET the function. (.fn obj) will CALL the function#2019-08-2207:33AklsccI know, thank you. You are right!#2019-08-2217:59CharlesHi everyone. I'm trying to learn clojurescript to create an AWS lambda, but I'm having trouble getting a REPL working in emacs/spacemacs. I create REPL via cider-jack-in-clojurescript and see [nREPL] Starting server via npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.0-beta11 server. After Select ClojureScript REPL type: node, I see [nREPL] Direct connection to localhost:37269 established, but I get an error Unhandled java.lang.AssertionError Assert failed: (keyword? repl-env). I'm using version 2.8.51, node 10.16.3, and spacemacs /cdn-cgi/l/email-protection#2019-08-2218:01CharlesMy shadow-cljs-edn:
{:source-paths ["src"]
 :dependencies []
 :builds {:app {:target :node-library
                :exports {:handler test.main/handler}
                :output-dir "target"
                :output-to "target/main.js"}}}
#2019-08-2218:17David PhamYou need to add the dependencies to cider as well#2019-08-2218:19David Pham#2019-08-2218:20David PhamAnd you also need piggieback#2019-08-2218:20David Phamhttps://docs.cider.mx/cider/basics/clojurescript.html#2019-08-2218:20David PhamThis is how I got it working
#2019-08-2219:03CharlesI have cider-nrepl and piggieback installed. The repl seems to work if I choose custom and do (shadow/watch :app) (shadow/node-repl :app)#2019-08-2219:20superstructorIs there a way to print out the deps.cljs :npm-deps dependency tree ?#2019-08-2219:22mynomotoHi, I'm having trouble with a react-native project, expo is trying to connect to the wrong websocket because it is getting the wrong lan ip. How can I override the ip being used?#2019-08-2219:22mynomotoUsing https://github.com/thheller/reagent-expo#2019-08-2219:30thheller@superstructor no. there is no tree. its a flat map but you can use npm list or so after they are installed#2019-08-2223:48superstructorok thanks, but is there a way to see what jar/deps.cljs each dependency comes from ?#2019-08-2306:28thhelleryou can do this
(->> (ClassLoader/getSystemResources "deps.cljs")
     (enumeration-seq))
#2019-08-2306:28thhellerthen just slurp and read them#2019-08-2306:50superstructor👍 Thanks. Is this something you'd be interested in being part of the shadow-cljs command line or is it better for me to add it to something like lein-shadow (i.e. build tool problem) ?#2019-08-2306:51thhellerdunno what do you want to do with it?#2019-08-2306:51thhellerin shadow-cljs package.json is the source of truth. deps.cljs stuff is only added if it is not already in package.json#2019-08-2307:00superstructorSo for example in re-frame-10x there are some important transitive deps: https://github.com/Day8/re-frame-10x/blob/master/src/deps.cljs#2019-08-2307:01superstructorThen I have some other closed-source libs that also add transitive deps.#2019-08-2307:01superstructorSo my thinking was it would just be good to see where these deps came from.#2019-08-2307:01superstructorLike, if you wanted to update one and not duplicate it in the current project.#2019-08-2307:02thhellerhmm yeah sounds useful#2019-08-2307:03superstructorIt's not urgent, so have a think about it. If you think its not the responsibility of shadow-cljs itself I'm happy to add it to lein-shadow.#2019-08-2307:03thhelleryou could create a function that does that and run it via shadow-cljs run some.util/show-npm-deps#2019-08-2307:04thhellerdoesn't need anything special from shadow-cljs so it would work with other tools too#2019-08-2307:05superstructorYeah could do the same with lein plugin. 👍#2019-08-2219:34mynomotoMy issue is probably related to https://github.com/thheller/shadow-cljs/issues/482#2019-08-2219:47mynomotohttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native has the solution#2019-08-2220:56teawaterwirewe have a module that represents one namespace, we're pulling a function from a npm package - it works fine on the dev environment but once we build the app we have this error Uncaught ReferenceError: $jscomp is not defined when calling toAscii#2019-08-2221:00thhellerdo you not use :advanced? that name shouldn't exist anymore?#2019-08-2221:05thhellerwhich build target is this? $jscomp is used by the closure compiler for polyfills.#2019-08-2222:06teawaterwirebuild target is browser so maybe it's just because we dont' have the latest version of shadow ? (ping @UCK2PHQ59 )#2019-08-2222:09thhellercan you tell which part of the code is trying to use $jscomp?#2019-08-2222:11teawaterwireyeah it seems to be when calling that#2019-08-2222:12teawaterwire#2019-08-2222:14thhellertry using shadow-cljs release app --pseudo-names#2019-08-2222:14thhellereasier to find the source that way#2019-08-2222:15thhellerbut it appears to be inside some of the JS code#2019-08-2222:15thheller:compiler-options {:output-feature-set :es6} might do it if you can live with that#2019-08-2222:16thhellerwould help to know which polyfill is missing though#2019-08-2222:28teawaterwirewith --pseudo-names i get this#2019-08-2222:31teawaterwirethe namehashed fn is this one#2019-08-2222:32teawaterwirehow come we don't have this error when not lazy loading this namespace/module?#2019-08-2223:34teawaterwirethe :compiler-options {:output-feature-set :es6} worked!#2019-08-2221:17aisamuHi! Updating shadow-cljs from 2.8.39 to 2.8.45 (or .51) is unfortunately breaking our REPL setup on the final NPM build of our project. We checked for the usual culprits but nothing did the trick except reverting to 2.8.39. This is an :npm-module that's being consumed by a Webpack project. From JS we have
window.CLOSURE_BASE_PATH = '/javascripts' // Should match our assets location
  require('cljs/shadow.cljs.devtools.client.browser')
After the update, the REPL connects as usual but apparently cljs.core isn't loaded:
cljs.user> 3
3
cljs.user> (first [1 2])
ReferenceError: cljs is not defined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js), <anonymous>:1:1)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js:878:16)
    at eval (webpack-internal:///./build/cljs/shadow.cljs.devtools.client.browser.js:887:44)
[...]
Is there something else we could try? Thanks!
#2019-08-2221:39thhellerhmm that is probably caused by the introduction of the global-eval fn. https://github.com/thheller/shadow-cljs/commit/1470c6d2d06195d01ba2b486ef6f730c36b51840#2019-08-2221:41thhellerhmm not sure what to do about the. I introduced the global-eval to fix another issue#2019-08-2221:42thhelleryou could try copying the current browser.cljs https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs and just replacing the #(global-eval .. with (js/eval ...#2019-08-2221:43thhellerseems weird this doesn't work though. I thought I ensured the npm-modules properly exports to global#2019-08-2221:43thhellertoo tired to think about that now. if you open an issue I'll take a look over the weekend#2019-08-2314:10aisamuhttps://github.com/thheller/shadow-cljs/issues/550 Please let me know if you need anything else. (Testing the global-eval substitution is still queued up, trying to find a breach on the schedule) Thanks again!#2019-08-2222:09aisamuWill give that a try, thanks!#2019-08-2301:09teawaterwireanyone else getting this error with the latest shadow?#2019-08-2301:25teawaterwireignore me, upgrading to [cider/cider-nrepl "0.21.1"] fixed it#2019-08-2305:44AklsccHey, is there anyone use reagnet? Why we can't do this to update Component:
(def content (r/atom 0))
(js/setInterval (fn []
                  (swap! content inc)
                  (println @content)) 1000)

(defn home []
  [:> rn/View {:style (styles :container)}
       [:> rn/Text @content]])
If I try to define atom in global, and there is no update for rn/Text.
#2019-08-2305:44AklsccHey, is there anyone use reagnet? Why we can't do this to update Component:
(def content (r/atom 0))
(js/setInterval (fn []
                  (swap! content inc)
                  (println @content)) 1000)

(defn home []
  [:> rn/View {:style (styles :container)}
       [:> rn/Text @content]])
If I try to define atom in global, and there is no update for rn/Text.
#2019-08-2309:41p-himikIf you mean reagent then many people use it. Not sure what you mean by "any update will invalid", the code seems fine to me. Try asking in #reagent#2019-08-2407:54Aklscc@U2FRKM4TW I have edit my problem. Thanks for your help. I have teseted the case, it really doesn't work correctly to update. I think that because global update or state change will not result in rerender.#2019-08-2309:29danielnealI’ve been trying out the react native code-splitting… getting an error
[:app] Build failure:
Module Entry "riverford.mobile-app-orders.db.catalog" was moved out of module ":default-products".
It was moved to ":index" and used by #{:default-products :default-categories}.
#2019-08-2309:30danielnealthis is my config#2019-08-2309:30danielneal
{:app
  {:target :react-native
   :init-fn riverford.mobile-app-orders.core/init
   :output-dir "app"
   :infer-externs :auto
   :devtools {:autoload true}
   :chunks {:default-products riverford.mobile-app-orders.db.catalog/default-products
            :default-categories riverford.mobile-app-orders.db.catalog/default-categories}}}
#2019-08-2309:38p-himikWhen I use any third-party tool to compile some resource into something that browser understands, I have to make sure that its output resides within :watch-dir, right? Otherwise it seems that Shadow-CLJS won't know that something has changed and won't notify the browser.#2019-08-2309:39p-himikIf that's the case, would it make sense to support multiple :watch-dir?#2019-08-2309:47p-himikWith corresponding entries in :watch-path.#2019-08-2309:49p-himikMy particular use-case: - Vendored CSS from a third-party library that I sometimes change within my main project's repo - Main SCSS file that gets compiled into CSS inside target - Some CSS from node_modules that I copy with build hooks into target. If I watch just the vendored dir, I won't get any notifications on the changes within target, and vice versa. If I set :watch-dir "." then I get notified but there's no reload since I get specify the correct :watch-path.#2019-08-2310:28thhellercan you provide an actual example of paths. I can only guess what you are actually doing since there are so many possible variants#2019-08-2310:29thhellerie. you generate a file into public/css/main.css and that is loaded via /css/main.css served by a webserver with root public#2019-08-2310:29thhellerthat is the default assumption#2019-08-2310:30thhellerno clue what "vendored dir" means to you#2019-08-2310:33p-himikThis should be close enough to what I have: resources/vendored/a.css -(web server)-> /static/vendored/a.css resources/b.scss -(scss compiler)-> target/dev/b.css -(web server)-> /static/b.css node_modules/lib/c.css -(build hook)-> target/dev/lib/c.css -(web server)-> /static/lib/c.css Does this make sense?#2019-08-2310:36thhellernot exactly. what is your webserver serving?#2019-08-2310:36thhellerresources or target?#2019-08-2310:36thheller(or both)?#2019-08-2310:36thhellerneed to know the actual web server root#2019-08-2310:38thhelleralso define build hook? actual shadow-cljs build hook?#2019-08-2310:43p-himikIt serves anything that goes to the left of "-(web server)->" above, so both resources and target. There are multiple roots. Yes, an actual shadow-cljs build hook that just copies a bunch of specified files from one location into another.#2019-08-2310:45thhellercan you share your actual http config? your paths confuse me#2019-08-2310:45thheller/static checks resources AND target/dev?#2019-08-2310:46thhellerit is not a good idea to directly server resources btw#2019-08-2310:47thhellerI usually just have ONE public dir and generate everything into public/css or so and everything in there is .gitignore'd#2019-08-2310:47thhellerloading 3 different css files is not great performance wise#2019-08-2310:53p-himik> can you share your actual http config That's a bunch of CLJ code in terms of yada and integrant - not really usefult, I think. > /static checks resources AND target/dev? Yes! There is a priority and the server just tries to find the first matching path. > it is not a good idea to directly server resources btw In my case, it only contains the stuff the needs to be served, with the exception of SCSS files, so I don't think it's a big deal. > loading 3 different css files is not great performance wise Is there really a noticeable performance difference though? Especially when the files themselves are relatively small, and the browser downloads them in parallel anyway. But you gave me the idea. I started using SCSS just a few days ago. Before that, there was no way to combine multiple CSS files into one. But with SCSS, I think I should be able to do that.#2019-08-2310:54thhellerwell resources might be but I'm assuming that is packaged as an uberjar at some point?#2019-08-2310:54thhellerso if you serve the root directly anyone can load /b.scss if I understand your setup correctly#2019-08-2310:55thhellerbut yeah I would suggest compiling all css files into one before serving it#2019-08-2310:55p-himikNope. My experience with all kinds of uberjars has been far less than pleasant so I still serve the whole project on Heroku as a Git source tree.#2019-08-2310:56thhellerbut even then /b.scss is accessible?#2019-08-2310:57thhellerI keep my web resources out of uberjars too and just serve regular files#2019-08-2310:58thhellerperformance wise it isn't a super huge deal to serve 3 files but it also doesn't cost much to combine them first#2019-08-2310:58thhellerbetter gzip, less requests#2019-08-2311:00p-himik> but even then /b.scss is accessible? Sure, it should be if I deploy it (haven't deployed yet since I started using SCSS). Yeah, I can see how it can potentially be an issue. > I keep my web resources out of uberjars too and just serve regular files Oh, I don't use uberjars at all. Couldn't make it work on Heroku as it just crashes with OOM during the startup process. Tried uberjar, onejar, capsure. I may mix some names up - has been a minute since I tried that.#2019-08-2312:19p-himikHeheh. Tried @importing vendored CSS - worked just fine. But it's not as easy with files from node_modules. E.g. TinyMCE has a whole load of all kinds of files that are loaded dynamically depending on the settings you provided it during runtime. I just thought that maybe I could also get rid of the build hook but apparently that's not the case.#2019-08-2312:31p-himik> I usually just have ONE public dir and generate everything into public/css or so and everything in there is .gitignore'd @thheller How do you deal with multiple assets of different kinds? E.g. I have a bunch of JS files (some code that's not available in NPM) - I can probably move that to src and ship it within main.js. But there are also all sorts of images and manifests:
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
Plus the /favicon.ico and /browserconfig.xml and other stuff like that.
#2019-08-2314:24thhellerusually just keep everything in the public directory (added to git, except generated files)#2019-08-2314:24thhellerand my webserver serves the public directory#2019-08-2314:25p-himikOr, so it contains both generated and manually created content. I see, thanks.#2019-08-2314:25thhelleryes my public/css and public/js dirs are gitignored and files are just generated into those dirs#2019-08-2314:26thhellereverything else is just normal files. I have added image processing with hashing in the past but not every project needs that#2019-08-2414:38p-himikTo be honest, the more I think about it, the less I like the idea of having generated files outside of target. Extra entry in .gitignore, extra step to prevent IDEA from indexing it. And juxt/kick.alpha supports setting only a single target directory at the moment, so CSS generated from SCSS and JS generated from CLJS all go into one place. Which makes sense IMO.#2019-08-2414:40p-himikIf you don't have anything against making :watch-dir and :watch-path support vectors (without losing the support for plain strings of course), I'd be happy to create a PR.#2019-08-2414:52p-himikHmm, on the other hand - do I need to watch files that I don't change? I probably don't. So watching just target should be sufficient in my case.#2019-08-2310:26thheller@danielenealwhen using code splitting you have to make sure that chunks don't directly depend on each other#2019-08-2310:26thhellerand you have to split on the namespace level#2019-08-2310:27thhellercan't use the same namespace to define chunks#2019-08-2310:27thhelleralso kinda looks like you are trying to split out data? not actual code?#2019-08-2310:50danielnealyeah was trying to split out a bunch of json data#2019-08-2310:50thhellerwhy not use actual .json files for that then? 😛#2019-08-2310:51danielnealI do, they’re big json files was wanting to get them lazily loaded#2019-08-2310:51thhelleryes. do that with actual .json files?#2019-08-2310:52thhellerin the code above you would have done (js/require "./default-products.js") somewhere. why not just do (js/require "./default-products.json")?#2019-08-2310:52thhellerno need to involve the CLJS build into that?#2019-08-2310:54danielnealah I see. I’d been trying to speed up some loading by avoiding loading the json file until it was needed. I thought that perhaps just having (js/require "./default-products.json") where I used it wasn’t enough to stop the app trying to parse the json at startup. Perhaps it was working to do that, but it wasn’t making much of a difference#2019-08-2310:55thhellerwell did you do the react-native RAM bundle side of things?#2019-08-2310:56thhellerotherwise the code splitting won't do anything since everything is loaded on startup#2019-08-2310:56danielnealoh 😄 ,#2019-08-2310:57danielnealI think expo doesn’t let you do that yet 😭#2019-08-2310:58thhellerno clue. without this https://facebook.github.io/react-native/docs/performance#ram-bundles-inline-requires you don't need code splitting#2019-08-2310:59thhelleras far as I understand everything using the RAM bundle makes loading "lazy". otherwise everything is loaded eagerly#2019-08-2313:51jpmonettashi! I'm trying to use macros in a shadow-cljs project and I'm getting Can't take value of macro clograms.diagrams/xx, it is a very simple macro defined in the same namespace but in a .clj file, any ideas?#2019-08-2313:53jpmonettasnvm, just figured out, weird error message#2019-08-2314:53mccraigmccraigusually happens when you attempt to refer to a macro anywhere other than in the first position of a form @jpmonettas#2019-08-2314:53mccraigmccraige.g.#2019-08-2314:53mccraigmccraig(defmacro foo [] :foo) (identity foo)#2019-08-2315:06jpmonettasyeah but in this case was because I had a (:require-macros [clograms.diagrams]) but wasn't adding a :refer to the macro, somehow was seeing the macro and complaining with the wrong warning#2019-08-2315:36dhdhello i need a bit of help here. i am running into an error getting started with clojurescript and shadow-clj What i did and that works: Command I ran to create a new app lein new re-frame example +cider +10x +garden +re-com +routes +less Running the repl using npx: npx shadow-cljs browser-repl --> this works where it creates a REPL and launches a browser window What I am trying now: run clojurescript repl using EMACS, CIDER, SHADOW-CLJS (cider-jack-in-cljs) The error i am getting is:
error in process sentinel: Could not start nREPL server: npx: installed 91 in 3.274s
shadow-cljs - config: /Users/davesh/sandbox/prototypes/example/shadow-cljs.edn  cli version: 2.8.51  node: v12.9.0
shadow-cljs - running: lein update-in :dependencies conj [nrepl "0.6.0"] -- update-in :dependencies conj [cider/piggieback "0.4.1"] -- update-in :dependencies conj [refactor-nrepl "2.5.0-SNAPSHOT"] -- update-in :dependencies conj [cider/cider-nrepl "0.22.0-beta11"] -- run -m shadow.cljs.devtools.cli --npm -d nrepl:0.6.0 -d cider/piggieback:0.4.1 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.0-beta11 server
Executable 'lein' not found on system path.
#2019-08-2315:37dhdit’s odd because i have lein on my classpath:
EMACS:
(setenv "PATH" (concat "/usr/local/bin:/Library/TeX/texbin:" (getenv "PATH")))
(push "/usr/local/bin" exec-path)
(push "/Users/dhruv/bin" exec-path)

OSX:
$ which lein
/Users/dhruv/bin/lein
#2019-08-2315:46dpsutton(shell-command-to-string "which lein") what does that return?#2019-08-2315:47dhdohh. it’s empty string#2019-08-2315:47dpsuttonhttps://github.com/purcell/exec-path-from-shell is highly recommended to solve these problems#2019-08-2315:48dhdthank you so much!#2019-08-2316:34David PhamAnyone tried to use extremely big npm package with shadow-cljs? #2019-08-2316:35David PhamI try to use react-chart-editor from plotly but I can never reach the homepage because the dependencies are toooo big. (Similar to what happens if you load @material-UI/icons#2019-08-2318:31p-himik@neo2551 With icons the issue is that there's no tree shaking so even unused code ends up in the bundle. Maybe it's the case with react-chart-editor. If so, try requiring only the stuff that you need.#2019-08-2318:32p-himikNot as x :refer [a b c] but as x/a :as a.#2019-08-2318:32David PhamThanks I will try that!#2019-08-2319:17thheller@neo2551 not sure what "toooo big" means for you. I've seen upwards of 20mb load without issue? if you have too many files to load you can try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-08-2319:51David PhamThanks I am trying that.#2019-08-2319:51David PhamI am trying to load react-chart-editor. I think all the icons are killing it.#2019-08-2319:54David PhamIT worked :)#2019-08-2319:55David PhamYou are hero @thheller #2019-08-2412:29StefanI have some time for my react native app again. All the spikes are pretty much done, I’m starting the actual app now. So I’m starting from scratch with a new react native app. I make the minimal modifications to use CLJS and hot loading with shadow, the same ones as before, and guess what: it doesn’t work 😞 I’ve been looking at docs, forums, zulip, cannot find a solution. What am I doing wrong?
(ns app.core
  (:require [reagent.core :as r :refer [atom]]
            ["react-native" :as rn :refer [AppRegistry, Platform]]))

(defn app-root []
  [:> rn/View
   [:> rn/Text "First line"]
   #_[:> rn/Text "------------------"]
   [:> rn/Text "Second line"]
   [:> rn/Text "Hi!!!!"]])

(defonce app-root-ref (atom nil))

(def updatable-app-root
  (with-meta app-root
    {:component-did-mount
     (fn [this]
       (println "did mount")
       (reset! app-root-ref ^js this))}))

(defn init []
  (.registerComponent AppRegistry
                      "Han"
                      #(r/reactify-component updatable-app-root)))

(defn reload {:dev/after-load true} []
  (.forceUpdate ^js @app-root-ref))
The only real difference with before that I can think of, is that I’m using RN 0.60 now.
#2019-08-2412:36StefanOh wait that method apparently only works when changing children of app-root, not on app-root itself.#2019-08-2412:36StefanAccidental complexity 😞#2019-08-2412:38Stefan(thanks duckie )#2019-08-2501:58sifou biriI’m trying to move @thheller fulcro expo example from F2 to F3 (current one) after but I’m getting
Module app registry is not registered call-back module
, the code in question is:
(defonce app (app/fulcro-app
               {:render-root! expo/render-root}))

(defn  init
       {:dev/after-load true}
      []
      (app/mount! app Root :i-got-no-dom-node)
      (js/console.log "Loaded"))

 
` Where app comes from [com.fulcrologic.fulcro.application :as app] Any ideas?
#2019-08-2507:34zebuI'm just trying shadow-cljs for the first time, I'm getting an error when I include reagent in the shadow-cljs dependencies#2019-08-2507:34zebu
The required namespace "react" is not available, it was required by "reagent/core.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  for more information.
You may just need to run:
  npm install react
#2019-08-2507:35zebuI have done npm install react etc#2019-08-2507:35zebu
npm install react react-dom create-react-class
#2019-08-2507:35thhellermake sure you did that in the correct directory#2019-08-2507:35thhellerthere should be a <project>/node_modules/react/package.json for example#2019-08-2507:36zebuI don't have the node_modules folder there#2019-08-2507:37thhellerdo you have a package.json in your project dir?#2019-08-2507:37thhellerotherwise run npm init -y in your project dir first#2019-08-2507:37thhellerwhat did you use to start the project?#2019-08-2507:38zebuit is an old project, can't quite remember, some lein template#2019-08-2507:39thhelleryeah that likely won't have a package.json so you should create that via npm init -y#2019-08-2507:39zebuthat worked#2019-08-2507:40zebu
npm init -y
#2019-08-2507:40zebuand then#2019-08-2507:40zebu
npm install react react-dom create-react-class
#2019-08-2507:40zebuthanks 🙂#2019-08-2509:59thedavidmeisteri am struggling to see how :npm-deps works#2019-08-2509:59thedavidmeisteri put it in both my deps.edn and a deps.cljs file in src somewhere#2019-08-2510:00thedavidmeisterit just complains with "you probably need to run: npm install auth0-js"#2019-08-2510:02thedavidmeisterwait... i got it#2019-08-2510:02thedavidmeisterhttps://www.reddit.com/r/Clojure/comments/72wf86/shadowcljs_js_dependencies_going_forward/dnm06x6/#2019-08-2510:03thedavidmeister"at the root of the classpath"#2019-08-2510:03thedavidmeisterthose words missing from the docs#2019-08-2510:03thedavidmeisterhttps://shadow-cljs.github.io/docs/UsersGuide.html#publish-deps-cljs#2019-08-2510:03thedavidmeister@thheller ^^#2019-08-2510:04thhellerthat is only for publishing libraries#2019-08-2510:04thhelleryour JS dependencies are managed via package.json#2019-08-2510:04thedavidmeisteroh?#2019-08-2510:05thhellerit is assumed that you use npm install react or so to manage JS deps (which will add it to package.json)#2019-08-2510:06thedavidmeisteri just put deps.cljs at the top of my classpath and shadow cljs did an npm save#2019-08-2510:06thedavidmeisterwhich... yes... put it in package.json#2019-08-2510:07thedavidmeisterso what's that all about?#2019-08-2510:08thhellernpm uses package.json so we need to put it there. I only recommend using deps.cljs when publishing libraries. Otherwise use package.json directly AND keep your package-lock.json in version control too.#2019-08-2510:09thedavidmeisterpublishing where?#2019-08-2510:09thedavidmeisterwhat is a library in your mind?#2019-08-2510:09thheller[reagent "0.8.1"]#2019-08-2510:09thhelleranything you use as a dependency. not your actual project for a SPA or whatever#2019-08-2510:10thhellerpublished to clojars or any other maven repo#2019-08-2510:10thedavidmeisterthis is a library published to clojars and used downstream by an SPA#2019-08-2510:11thedavidmeisterand i have a demo site in the repo that is an SPA on github pages#2019-08-2510:11thedavidmeisterso both i think#2019-08-2510:12thhellerthe SPA should manage its dependencies via package.json#2019-08-2510:13thedavidmeistershould i also have a deps.cljs?#2019-08-2510:13thhellerthe SPA no#2019-08-2510:13thhellerdeps.cljs does nothing except transfer the dependencies to package.json#2019-08-2510:13thedavidmeisterare you talking about the downstream SPA or the github pages demo SPA in the library repo?#2019-08-2510:14thhellerthat doesn't matter really. you are making this more complicated then it is#2019-08-2510:14thedavidmeisterwhat does the deps.cljs do?#2019-08-2510:14thhellerif you publish a library the deps.cljs should be provided as a convenience so downstream users have that dependency automatically installed#2019-08-2510:14thedavidmeisterok#2019-08-2510:15thhellereverything you are actually building yourself SHOULD use package.json#2019-08-2510:15thedavidmeisterwell i do need to do that#2019-08-2510:15thedavidmeisterbecause this is a library i am publishing#2019-08-2510:15thedavidmeisterand there is a dependency on an npm package#2019-08-2510:15thedavidmeisterauth0-js#2019-08-2510:15thhelleryes that is fine. you can have both but package.json is the source of truth and will be used over deps.cljs#2019-08-2510:16thedavidmeisterok good to know thanks#2019-08-2510:16thhellerdeps.cljs npm-deps are only only transfered if they are not contained in package.json already#2019-08-2510:16thedavidmeisterright, that makes sense#2019-08-2510:16thedavidmeisterso uh#2019-08-2510:16thedavidmeisternext question#2019-08-2510:16thedavidmeisteri did ["auth0-js" :as auth0-js] in my :require#2019-08-2510:16thedavidmeisterUse of undeclared Var hoplon-auth0.api/auth0-js#2019-08-2510:20thhellerhow did you use it?#2019-08-2510:20thhellerhelps a lot if you show the actual full warning 😉#2019-08-2510:21thedavidmeister
------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /home/thedavidmeister/hoplon-auth0/src/hoplon_auth0/api.cljs:28:2
--------------------------------------------------------------------------------
  25 | 
  26 | (defn web-auth
  27 |  []
  28 |  (auth0-js.WebAuth.
--------^-----------------------------------------------------------------------
 Use of undeclared Var hoplon-auth0.api/auth0-js
--------------------------------------------------------------------------------
  29 |   hoplon-auth0.data/web-auth))
  30 | 
  31 | (defn authorize
  32 |  ([] (authorize nil))
--------------------------------------------------------------------------------
#2019-08-2510:21thhelleryeah its a namespace alias so it should be (auth0-js/WebAuth.)#2019-08-2510:22thedavidmeistereeeey#2019-08-2510:22thedavidmeisternice#2019-08-2510:22thedavidmeisteri knew it would be something dumb like that#2019-08-2510:22thedavidmeisterthanks#2019-08-2521:10warnsbergHi! Is it possible to use git dependencies in shadow-cljs.edn?#2019-08-2521:10warnsbergCan’t seem to find anything in the user guide and the deps.edn syntax doesn’t seem to be working#2019-08-2521:10warnsberg(I’m trying to experiment with https://github.com/roman01la/uix specifically)#2019-08-2523:33sogaiu@warnsberg perhaps not exactly what you are asking for, but if you don't mind using :deps true in shadow-cljs.edn + supply a deps.edn, may be that's one way?#2019-08-2604:08warnsbergThat sounds like a fine solution to me! I'll try that, thanks 🙏#2019-08-2600:32cjsauerWanted to drop in and say that the latest :react-native support has been amazing to use. I’m currently using it to control an external credit card reader over bluetooth and it’s been a joy poking it from the REPL. Thanks for all your had work Thomas 🙏#2019-08-2608:19thhellerhttps://twitter.com/thheller/status/1165901599920787457#2019-08-2612:20thedavidmeister@thheller yes thanks for this, i got it working in hoplon too, which is something i never quite got happening in boot 🙂#2019-08-2619:06felipethomeHi! Someone already had the error ERR_INSUFFICIENT_RESOURCES, when downloading the clojurescript files in Chrome in development mode? (shadow version 2.8.51)#2019-08-2619:08thhellersome people seem to be affected by this. try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-08-2619:22felipethomeIt worked. Thanks!#2019-08-2619:29felipethomeIs there any feature that we will miss because of the addition of :loader-mode :eval?#2019-08-2619:32thhellerno, just slightly higher recompile times#2019-08-2619:33thhellerI plan on adding a sort of middle ground as the default once I can figure out how 😉#2019-08-2619:33thhellerreally need to do something about those npm libs with excessive amounts of files#2019-08-2619:34felipethomeNice! Thank you!!!#2019-08-2622:18souenzzoafter bump some deps [2019-08-26 19:17:00.010 - WARNING] :shadow.cljs.devtools.server.reload-macros/macro-missing - {:ns-sym clojure.spec.test.check} It keep spamming forever in the repl, every 1 sec.#2019-08-2623:04souenzzoReproduce: https://github.com/souenzzo/fulcro-pathom-realworld-example-app#2019-08-2623:04souenzzoNot related to shadow-cljs, workspaces nor test.check. I really dont know where is come from.#2019-08-2706:25thhellerthe warning is already removed in master. just didn't cut a release yet.#2019-08-2706:25thhellerhow to I reproduce though? just run it?#2019-08-2706:45thhellerreleased 2.8.52 with the fix#2019-08-2711:55souenzzoyou are the best ❤️#2019-08-2706:19manuel@thheller just want to say "thank you!" for the hot-reloading capabilities. Amazing stuff as usual.#2019-08-2707:36iku000888My chromium browser gives up loading the js files from the dev-http server(after about 2 seconds) saying the parser is blocked because of document.write(). Has anyone seen this happen? shadow-cljs version is 2.8.51 and works fine on firefox 😭#2019-08-2707:37thhellertry https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-08-2707:37thhellerseems like a lot of people seem to run into issues lately#2019-08-2707:44iku000888Wow that was fast! Will give it a spin. Thanks 😉#2019-08-2707:47iku000888Darn it works like a charm ❤️ Thanks!#2019-08-2709:34Ivan FedorovHello, fellas! Do you have any friendship recipes for building cljs via lein shadow release app? Found this https://gitlab.com/nikperic/lein-shadow But it fails on a call to Closure.
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:68:5).
...
Caused by: java.lang.NoSuchFieldException: getRegisteredGroups
        at java.base/java.lang.Class.getField(Class.java:1958)
#2019-08-2709:35Ivan FedorovSame if I run lein run -m shadow.cljs.devtools.cli compile app#2019-08-2709:35thheller@ognivo that is caused by a dependency conflict. try adding
[com.google.javascript/closure-compiler-unshaded "v20190819"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
to your deps
#2019-08-2803:31superstructorJust a note, I find it better to exclude these deps from clojurescript which then allows the versions to be pulled in from the shadow-cljs dependency. So then shadow-cljs controlls the versions of these. E.g. https://github.com/Day8/re-frame/blob/master/project.clj#L6 @ognivo @thheller#2019-08-2809:18Ivan FedorovYes, I should start to do this. Thanks!#2019-08-2709:36thhellerand probably also [org.clojure/clojurescript "1.10.520]#2019-08-2709:36thhelleror just don't lein 😉#2019-08-2709:37Ivan FedorovPersonally, I don’t lein, but this time I do it for the boys 😉#2019-08-2710:01thedavidmeisterany idea why the repl would not be showing any console logs#2019-08-2710:01thedavidmeisteror error?#2019-08-2710:01thedavidmeisteri'm doing node repl-node/main.js#2019-08-2710:01thedavidmeistershadow-cljs watch app#2019-08-2710:01thedavidmeistershadow-cljs cljs-repl app#2019-08-2710:03thhellerexplain "console logs"?#2019-08-2710:04thedavidmeisterprn and (.log js/console ...)#2019-08-2710:05thhellerjs/console logs will show in the output of the actual node process. so node repl-node/main.js#2019-08-2710:05thhellerprn can only be captured partially so will most likely also only show up there#2019-08-2710:06thedavidmeisterok, actually it does work#2019-08-2710:06thedavidmeisteri think my actual problem is promises#2019-08-2710:06thedavidmeisterany reason why a .then wouldn't complete and/or be able to log from inside the callback?#2019-08-2710:09thhellerwell therein lies the problem. the async nature of JS doesn't play well with bindings#2019-08-2710:09thhellerso it is hard to capture async output#2019-08-2710:09thhellerthe node process should still show the output though#2019-08-2710:09thedavidmeisterthat makes more sense than prn randomly not working#2019-08-2710:15thedavidmeisterok, nm i found the issue#2019-08-2710:16thedavidmeisterthanks#2019-08-2710:16thedavidmeisterseems my API auth randomly stopped working so .then wasn't happening, it's .catch now >.<#2019-08-2711:43Ivan FedorovThis helped with my exception.
[com.google.javascript/closure-compiler-unshaded "v20190819"]
   [org.clojure/google-closure-library "0.0-20190213-2033d5d9"]
Thank you Mr Heller!
#2019-08-2719:05felipethomeHi! When the target is :karma adding :loader-mode :eval is useful?#2019-08-2719:17thhellerprobably not#2019-08-2719:18felipethomeIs there a chance that Chrome headless can suffer from ERR_INSUFFICIENT_RESOURCES and the browser would hang forever, reach the Karma timeouts and then fail the tests?#2019-08-2719:21thhellerno. karma doesn't load separate files. it is just one big file#2019-08-2809:19Ivan FedorovIs there a section on the tutorial on how shadow resolves, for instance, react subdependency for reagent?#2019-08-2809:24thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-deps ?#2019-08-2810:50Ivan FedorovI mean reagent itself depends on cljsjs/react, but as I understand, in the shadow-cljs’s context it’ll be used only for externs. It would be super cool to have a single place to see all deps that make their way into the release bundle. I know pom.xml, but AFAIK it only lists cljs part.#2019-08-2810:50Ivan FedorovNot urgent, though#2019-08-2810:50thhellerthis will tell you exactly what is in your build https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-08-2810:50Ivan FedorovI can submit a card on github, if you would like to have it on the horizon#2019-08-2810:51Ivan Fedorovah cool#2019-08-2810:51Ivan Fedorovthanks#2019-08-2811:07Ivan FedorovWhoa, build report is very nicely done, good job!#2019-08-2812:42kasukoIs there anyway to split up the release build process between what requires Node and what requires the JVM? I know the answer is most likely no, but I had to ask before spending a bunch of time making my own Docker image. Trying to get our new shadow-cljs project into our GitLab CI and I need to build the project in a Docker image. If I can split the steps I can just use the official images for Node and Java. If not I have to build my own in house Docker image that has both.#2019-08-2815:25thheller@kasuko not sure what you mean by "what requires Node"? or what the docker image has to do with this? there are plenty of images that have node+JVM available?#2019-08-2817:20kasukoUnfortunately due to security policies at my company I can only use approved Docker images. We have a node and a jdk image approved and I was curious if it was possible to split up the build. So I could compile all the Clojurescript in a Docker image that just had JDK then package all the Javascript up in the image that has Node.#2019-08-2817:25souenzzo
FROM node as node

RUN npm install

FROM clojure

COPY --from=node node_modules

RUN clj -A:cljs:build

RUN aws s3 put target/out.js s3://
#2019-08-2817:25souenzzosomething like it?#2019-08-2818:30kasukoYa exactly#2019-08-2818:46thhellernpm isn't required technically so the above example would work with shadow-cljs#2019-08-2818:46thhellerclj -m shadow.cljs.devtools.cli release your-build#2019-08-2818:47thhellerjust need the node_modules folder and the package.json so it doesn't try to install deps from deps.cljs#2019-08-2912:12kasukoAwesome, I will give this a go! I honestly didn't expect this to pan out.#2019-08-2818:00cap10morganI'm trying to use some protobuf-generated JS in a shadow-cljs app. When I generate it with "commonjs" output format it works but needs unsafe-eval in the Content-Security-Policy header, which I'd rather avoid. But when I generate it with "commonjs_strict" output it doesn't work. Here's the diff (`---` is working but unsafe; +++ is safe but non-working): https://gist.github.com/cap10morgan/b9f283fa8035b8c0bc527b0911eed1fb Anyone know if / how I can use the +++ version in a shadow-cljs app?#2019-08-2818:11tianshuCan I do this in shadow-cljs? https://github.com/tomconnors/problems/blob/reagent-preact/project.clj#L40 Looks like this create a namespace for a npm dependency.#2019-08-2818:40thheller@cap10morgan I have a hard time deciphering that gist. can just just post the 2 separate variants not as a diff?#2019-08-2818:41thhellernever done any protobuf stuff with generated code but there should be something easy that just works#2019-08-2818:43thheller@doglooksgood see https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve ie. :js-options {:resolve {"create-react-class" {:type :npm :require "preact-compat/lib/create-react-class"}}}#2019-08-2818:43thhellersimilar to this webpack aliasing https://github.com/developit/preact-compat#usage-with-webpack#2019-08-2818:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm even has preact as example 😉#2019-08-2818:49tianshuawesome!#2019-08-2818:51cap10morgan@thheller Yeah, thanks. I'm trying out a slightly different approach. I'll post both files if it doesn't pan out.
#2019-08-2818:58cap10morgan@thheller OK, yeah, didn't work. Here are the 2 versions I'm trying now: - working but not safe: https://gist.github.com/cap10morgan/7331bd6dedd6b6fb662e8bbe6f179632 - not working but safe(r) (uses ES6-style import statements but I get the error goog is not defined when I run it): https://gist.github.com/cap10morgan/b1b0a0f151b02809b084a568c13ac2fc#2019-08-2819:04cap10morganI'm trying to use the library in CLJS with (:require ["path/to/js_file" :as game-lib]) in both cases.#2019-08-2819:07thheller@cap10morgan hmm does it have another output format for closure directly?#2019-08-2819:07thhellerlooks very much like closure js?#2019-08-2819:08cap10morganIt does yeah, but that output is very different in that it's all separate files. I was trying to see if I could get it to work in one file first. But if the closure way is best, I'll bite the bullet. 🙂#2019-08-2819:08thhellerdoes it have goog.provide/goog.require calls at the top?#2019-08-2819:09cap10morganyes#2019-08-2819:10thhelleryes that would be best#2019-08-2819:10thhellerdon't need JS interop at all then and get full benefit of :advanced#2019-08-2819:10cap10morganOK I'll dig into that then. Thanks for the pointer!#2019-08-2819:11thhellerjust put the files on the classpath. ie. generate into src/gen and :source-paths ["src/main" "src/gen"]#2019-08-2819:11thhellerthen import like regular cljs/closure namespaces#2019-08-2819:11thheller(:require [proto.game.Whatever :as x]) or so#2019-08-2819:11cap10morganI like it#2019-08-2820:00tianshushadow-cljs - failed to load module$node_modules$preact_compat$dist$preact_compat What does this error mean? this file is exists.#2019-08-2820:01tianshuI got this error in the console of browser. the compile is succeed.#2019-08-2820:03tianshuOhh, preact-compat is for preact 8, I'm using the version 10#2019-08-2820:14cap10morgan@thheller Alas, one of the protobuf plugins we're using isn't compatible with closure-style JS. The best I can do is this CommonJS strict version (which I can't get working in shadow-cljs): https://gist.github.com/cap10morgan/2d29db3e9a3f8326dde71a56a21c6d7d#2019-08-2820:37cap10morganOh, I think I figured it out. Pretty simple in the end. Because it's extending exports with proto, I can just refer to game-lib/game.Thingy in my CLJS code.#2019-08-2820:44thhellerI would suspect that closure-js style results in a substantially smaller JS file in the end#2019-08-2820:45thhellerso might be worth getting that to work#2019-08-2900:01Karol WójcikI'm trying to connect to the repl in react-native-runtime. The tool I'm using is react-native-cli. Here is the shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [[binaryage/devtools "0.9.10" :scope "test"]]

 :builds
 {:app
  {:target     :npm-module
   :runtime    :react-native
   :output-dir "target"
   :compiler-options {:infer-externs :auto}
   :devtools {:autoload true
              :async-require true}}}}
index.js
/**
 * @format
 */

if (__DEV__) {
    require('./target/shadow.cljs.devtools.client.react_native');
    require('./target/forg.dev.devtools').install();
}

import { AppRegistry } from 'react-native';
import { Application } from './target/forg.root';
import { name as appName } from './app.json';

AppRegistry.registerComponent(appName, () => Application);
#2019-08-2900:02Karol Wójcik#2019-08-2900:02Karol WójcikAnyone a clue how to fix this?#2019-08-2907:05thheller@karol.wojcik don't use :npm-module. use :react-native#2019-08-2907:11Karol Wójcik@thheller Thank you very much. I think I'm very close to the working solution. Here is the list of steps I'm doing to have REPL/Hot module reloading enabled. Ok I'll post the update since i found partially working solution. 1. git clone https://github.com/FieryCod/forg 2. yarn shadow-cljs watch app 3. ln target/index.js index.js 4. Run emulator 5. jack-in & run yarn start What partially works: REPL - successfully connected but every command results in timeout What does not work at all: Hot reloading - change in cljs file indeed refreshes the application but content remains the same#2019-08-2907:13thhellersee this https://github.com/thheller/reagent-react-native#2019-08-2907:14thhellerhttps://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L64#2019-08-2909:57Karol WójcikYou are a god! Indeed after using this snippet the hot-reloading works like a charm ❤️ Thank you @thheller. What about the REPL? is it doable?#2019-08-2911:10thhellershould just work?#2019-08-2911:10thhellerjust some limitations in adding new JS requires and so on#2019-08-2911:17Karol WójcikOk I found an issue. I had nrepl port setup in .edn. @thheller I know that you hear it almost everyday, but I want to thank you for all your effort you put in development & maintenance & support of shadow-cljs. It's pleasure to use it!! You did great job!!#2019-08-2911:18thhellerthanks 🙂#2019-08-2907:14thhellerneed this pattern to have live-reload#2019-08-2907:14vinursi use shadow-cljs check app, this result the following warning,#2019-08-2907:14vinursand require [“react-native-navigation” :as RNN :refer [Navigation]]#2019-08-2907:14vinurswhat’s the warning meaning?#2019-08-2907:15thhellerthat check isn't very reliable 😉#2019-08-2907:15thhellerit can't properly work with code it doesn't see#2019-08-2907:19vinursi meet with a problem, when i run shadow-cljs compile app, the my app works ok, but if i use shadow-cljs release app, it outputs error#2019-08-2907:24thhelleryeah sounds like an externs problem#2019-08-2907:24thhellertry running shadow-cljs release app --pseudo-names#2019-08-2907:25thhellerdefinitely enable :compiler-options {:infer-externs :auto}#2019-08-2907:48vinursshadow-cljs release app --pseudo-names, another error#2019-08-2907:49thheller@haiyuan.vinurs yes that means that you need externs for .props since it is getting renamed to .$props$ or .Ad in actual release#2019-08-2907:49thhellerso you create externs/app.txt and add one line with props#2019-08-2907:50vinurs
(defn register
  ([key]
   (register key nil))
  ([key options]
   (let [get-props
         (fn [this]
           {::key key
            ::id (-> this .-state .-id)
            :component-id (-> this .-props .-componentId)})

         wrapper
         (crc #js
              {:displayName
                (str key "Wrapper")

                :getInitialState
                (let [id (swap! id-seq-ref inc)]
                  (fn [] #js {:key key
                              :id id}))

                :componentDidMount
                (fn []
                  (this-as
                   ^js this

                   (bind-component this)
                   (swap! mounted-ref
                          assoc-in [key (-> this .-state .-id)] this)))

                :componentWillUnmount
                (fn []
                  (this-as
                   ^js this

                   (swap! mounted-ref update key dissoc (-> this .-state .-id))))


                ;; FIXME: forward other lifecycles the same way
                :navigationButtonPressed
                (fn [params]
                  (this-as
                   ^js this

                   (let [{:keys [navigation-button-pressed]}
                         (get @screens-ref key)

                         props
                         (get-props this)]

                     (js/console.log "navigationButtonPressed"
                                     key
                                     (boolean navigation-button-pressed)
                                     (pr-str props))
                     (when navigation-button-pressed
                       (navigation-button-pressed
                        (js->clj params :keywordize-keys true)
                        props)))))

                :componentDidAppear
                (fn []
                  (this-as
                   ^js this

                   (js/console.log "componentDidAppear" key)))

                :componentDidDisappear
                (fn []
                  (this-as
                   ^js this

                   (js/console.log "componentDidDisappear" key)))

                :render
                (fn []
                  (this-as
                   ^js this

                   (let [{:keys [render]}
                         (get @screens-ref key)

                         props
                         (get-props this)]

                     (js/console.log "render" key (pr-str props))
                     (-> (render props)
                         (r/as-element)))))})]

     (when (not (nil? options))
       (set! (.-options wrapper)
             (fn [passProps] (clj->js options))))
     (register-component key (fn [] wrapper)))))
#2019-08-2907:50vinursthis is a function for wix react-native-navigation#2019-08-2907:51vinursi should modify this function?#2019-08-2907:57vinurs
--------------------------------------------------------------------------------
  27 |          (fn [this]
  28 |            {::key key
  29 |             ::id (-> this .-state .-id)
  30 |             :component-id (-> this .-props .-componentId)})
---------------------------------^----------------------------------------------
 Cannot infer target type in expression (. (.-props this) -componentId)
--------------------------------------------------------------------------------
  31 |
  32 |          wrapper
  33 |          (crc #js
  34 |               {:displayName
--------------------------------------------------------------------------------
#2019-08-2907:57vinurscheck shows this#2019-08-2907:57thhelleryeah that is missing a hint#2019-08-2907:57thheller (fn [^js this]#2019-08-2908:00vinursok now#2019-08-2908:00vinursthanks#2019-08-2910:36joshkhi recently migrated a reagent based figwheel project to shadow-cljs. shadow-cljs is definitely watching my src directory, recompiling my code, popping up syntax errors in the browser etc. but for some reason my ^:dev/after-load fn isn't being called, and so my reagent/react components aren't reloaded. any hints for debugging?
(defn ^:dev/after-load re-render
  "Re-render the app when figwheel reloads"
  []
  (mount-root))
i've also tried explicitly setting {:devtools {:after-load myapp.re-render in my shadow-cljs.edn file with no luck.
#2019-08-2911:09thheller@joshkh what does the browser console say?#2019-08-2911:12thhellerthis might be relevant and help? https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2019-08-2917:42joshkhapologies for my late reply. i ended up clearing my .shadow-cljs folder when switching some local branches around and then it worked? 🙂#2019-08-2922:44jiangtsare there any examples of how to use shadow for a chrome extension? Couldn’t seem to find it in the docs#2019-08-2922:44jiangtsparticularly, looking for an example for content scripts, since they cannot load more scripts#2019-08-2922:50hlollisome time ago I did chrome extension target, but I doubt it still works haven't worked with chrome-extensions for a while now. https://gist.github.com/hlolli/265b9183566a4c5829d7ee355e3d0998#2019-08-3001:08eccentric JWhen my computer sleeps, my browser disconnects from the shadow-cljs websocket for reloads. Is there a way to reconnect or do I need to refresh?#2019-08-3001:16eccentric JOh good news turns out you can run shadow.cljs.devtools.client.browser.ws_connect() from js console and it will reconnect.#2019-08-3012:50Michaël Salihi@thheller Is there a similar way to reconnect websocket for :react-native target ? Via the REPL ? shadow.cljs.devtools.client.react-native.ws-connect ?#2019-08-3012:51thhellerwell ... if the REPL is disconnected you can't trigger anything from the REPL?#2019-08-3012:52thhellerthe JS would be similar though. shadow.cljs.devtools.client.react_native.ws_connect()#2019-08-3012:59Michaël SalihiYes you're right...for RN we must to kill and relaunch shadow-cljs watch to restore a websocket <-> REPL connection 🙂#2019-08-3013:04thhellerwell not really#2019-08-3013:15Michaël SalihiI don't understand ? I missing something ?#2019-08-3013:15Michaël SalihiA better solution?#2019-08-3013:20thhellerI opened https://github.com/facebook/react-native/issues/26087 but nobody seems to care#2019-08-3013:21thhellerI still need to add something on the shadow-cljs side so there is an easy way to get rid of the "bad" websocket connection#2019-08-3013:43Michaël SalihiGood to see you try to make things happen in RN side, sad to see there no answer 😕 I remember, we had a discussion about this on an issue that I had open : https://github.com/thheller/shadow-cljs/issues/544#issuecomment-521799837#2019-08-3013:46Michaël SalihiAs the link of the RN issue you had provided are closed and someone says : > wave hey all, as mentioned by @PeterKruzlics above, this was fixed in v0.57.6 so I'll go ahead and close this now. I thought it was solved. Maybe it is a regression because this problem continue to occur with the last version of RN#2019-08-3014:02thhellerno clue. I don't do regular RN development but I tested the shadow-cljs side of things and it is definitely RN keeping the websocket open#2019-08-3001:35sogaiu@jiangts fwiw, there's one in this project: https://github.com/Lokeh/punk2/blob/master/shadow-cljs.edn - also, the following query might provide more examples: https://github.com/search?q=filename%3Ashadow-cljs.edn+chrome-extension#2019-08-3004:27cjmurphyRunning npx shadow-cljs server I constantly get these messages. This is on the latest (2.8.52).#2019-08-3007:34thheller@jiangts there is some support for chrome extensions, just missing documentation currently. see https://github.com/thheller/shadow-cljs/issues/279#2019-08-3007:34thhellerit is in use here: https://github.com/fulcrologic/fulcro-inspect/blob/master/shadow-cljs.edn#L18-L20 https://github.com/fulcrologic/fulcro-inspect/blob/master/shells/chrome/manifest.edn#2019-08-3007:35thheller@cjmurphy that can't be on 2.8.52 since that completely removed the warning#2019-08-3007:52cjmurphyThanks, yes needed to change the version in deps.edn as well as package.json.#2019-08-3008:20scknkkrerHi guys, I wanted to create a simple app. Everything is fine, except; browser.cljs:360 Refused to connect to '' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback..#2019-08-3008:22scknkkrerThen, I wanted to create a Certificate from KeyChain on my Mac.#2019-08-3008:22thhellerwhich http server do you use? it seems to setup CSP? thats overkill during development?#2019-08-3008:22scknkkrerI found this documentation. But, my result is different from Step 2. https://certsimple.com/blog/localhost-ssl-fix#2019-08-3008:23thhellerplease answer my first question before we dive deeper into SSL 😛#2019-08-3008:24scknkkrerOk. Sorry. 😂#2019-08-3008:25scknkkrerBut I’m so newbie. 🙄#2019-08-3008:25thhellerthat is why we go step by step 😉#2019-08-3008:26thhellerthat error you get is caused by a webserver serving a CSP header (Content-Security-Policy) which is restricting what you are allowed to do in the page#2019-08-3008:26thhellerthat is overkill for development since you want to do everything#2019-08-3008:28scknkkrerI’ve just end up with this information. But you are a good teacher. Go on. 😇#2019-08-3008:30thhellertell me about your setup? what are you building? what is your build config?#2019-08-3008:31scknkkrerA newly, fresh setup from CLI. Nothing special. I’ve change nothing yet. I found a documentation but, As I said, I can’t go through it.#2019-08-3008:34thhellerplease share more information. I cannot possibly guess what you mean by "fresh setup from CLI".#2019-08-3008:35scknkkrerSorry, here is my shadow-cljs.edn file content:
{:lein   true

 :nrepl {:port 8777}

 :builds {:app {:target          :browser
                :output-dir      "resources/public/cordova/www/js/compiled"
                :asset-path      "/js/compiled"
                :optimizations   :whitespace
                :modules         {:app {:init-fn com.kctech.qulak.mobile.core/init
                                        :preloads [devtools.preload]}}
                :devtools        {:http-root    "resources/public/cordova/www"
                                  :http-port    8280}}
          :browser-test
          {:target :browser-test
           :ns-regexp "-test$"
           :runner-ns shadow.test.browser
           :test-dir "target/browser-test"
           :devtools {:http-root "target/browser-test"
                      :http-port 8290}}

          :karma-test
          {:target :karma
           :ns-regexp "-test$"
           :output-to "target/karma-test.js"}}}
#2019-08-3008:35scknkkrerhttps://clojurians.slack.com/archives/C6N245JGG/p1567153235069400#2019-08-3008:35thhelleroh. so this is running in cordova and not a regular browser?#2019-08-3008:36scknkkrerI can’t see the content in Safari too.#2019-08-3008:36scknkkrerAnd, this Error log was Safari’s.#2019-08-3008:36thhellerhow did you open it in safari?#2019-08-3008:36thhellerhttp://localhost:8280 I presume?#2019-08-3008:37scknkkrerOk, shadow-cljs server to start server and REPL.
shadow-cljs - config: /Users/sckn/projects/business/qulak/mobile/com.kctech.qulak.mobile/shadow-cljs.edn  cli version: 2.8.52  node: v12.4.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm server
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.52 running at 
shadow-cljs - nREPL server started on port 8777
Yeap, as you said.
#2019-08-3008:38thhellerand when you open http://localhost:8280 in safari you get the above error?#2019-08-3008:40thhellerwhat is in your "resources/public/cordova/www/index.html"? does it have a <meta http-equiv="Content-Security-Policy" ...?#2019-08-3008:41scknkkrerYeap.#2019-08-3008:42thhellerok. that HTML tag is causing your issues. you can either remove it completely or adjust it to allow the connection to the shadow-cljs server#2019-08-3008:42scknkkrerI was deleted the tag, ‘on the wrong .html’. Now it’s good. Thank you.#2019-08-3008:43scknkkrerAnd, I’m nice Googler, how can I help you @thheller?#2019-08-3008:45thhellerhelp with what?#2019-08-3009:21scknkkrerWith your problem.#2019-08-3009:21scknkkrerAnd, have you guys any expriences with Cordova + Shadow-Cljs ?#2019-08-3011:29mccraigmccraigi do!#2019-08-3011:30mccraigmccraigwe moved our cordova+cljs+re-frame app over to shadow a few months ago#2019-08-3011:31mccraigmccraigwe were using boot-cljs before, but our js bundle was getting large and we need to modularise, so shadow's build-reports and easy modularisation convinced me#2019-08-3011:32mccraigmccraigthe shadow bit was easy... once i got compile working there were no problems at all#2019-08-3011:32scknkkrerI have a working app. Re-frame + ReAgent. I want to implement a prototype over Cordova. I’ve created a new re-frame template from leiningen which contains shadow-cljs configuration. And then, create a Cordova app with cordova create bla com.kctech.bla.bla Bla. But, I couldn’t handle the process. I compile my application. Run with cordova. It pops-up some errors.#2019-08-3011:33scknkkrerWhat is the developing Cordova app process ? I want to implement all the UI specific work with browser. But I need the see on Mobile too.#2019-08-3011:34scknkkrerHow can I implement a minimal template with these templates ? @U0524B4UW, or Am I wrong at something ?#2019-08-3011:34mccraigmccraigwe have two different build targets (one web, one cordova) and a few things in the codebase which isolate most of the code from the differences - we target web, ios and android#2019-08-3011:35scknkkrerIs there a guide on this topic ? What are gotchas ? What are pitfalls ?#2019-08-3011:36scknkkrerHow should I seperate web and Cordova buildings ?#2019-08-3011:36mccraigmccraigi would start with one of the basic cordova templates, and add in re-frame ... i can't really show you any minimal examples, 'cos our app is rather large now#2019-08-3011:38scknkkrerSo, what do you think about how I start ? Creating a leintemplate and adding cordova in it ? And, at least, can you show me or tell me anything about how should I keep my Project Structure ?#2019-08-3011:40mccraigmccraigwe have separate shadow targets for web and cordova... although the only real difference (apart from closure defines) is that the cordova target puts the build output into the cordova project www directory#2019-08-3011:40mccraigmccraigso we have a monorepo with directories like#2019-08-3011:40mccraigmccraig
cordova
  -config.xml
  -www/
web
  -shadow-cljs.edn
  -src/
  -test/
  -target/
#2019-08-3011:44mccraigmccraigyou can get live-reloading working in simulator and on-device in cordova by redirecting (with window.location=) to your shadow http server#2019-08-3011:45mccraigmccraig(whether a build does such a redirect is something we specify with closure defines)#2019-08-3011:47scknkkrerAnything else, should I know ? It seems simple.#2019-08-3011:47thheller@U0524B4UW what is the point of the redirect?#2019-08-3011:48scknkkrerand also, yes. Why ?#2019-08-3011:48mccraigmccraigcordova loads from a file: url - but to live-reload you need to be loading from the shadow http: url#2019-08-3011:49scknkkrerAnd, how can I bundle my application into one single JS file. Same as we did without shadow-cljs ? with :simple or :advanced compilation flags ?#2019-08-3011:49thheller@U3JJH3URY shadow-cljs release app#2019-08-3011:50mccraigmccraigi think re-natal does something clever with a webdav mount, but the simple redirect works ok for cordova#2019-08-3011:50scknkkrerOh, what about during development ?#2019-08-3011:50thhellershadow-cljs watch app?#2019-08-3011:51thheller@U0524B4UW you may just need to set :devtools-url properly? eg set :devtools {:devtools-url ""}#2019-08-3011:52thhellerthe config logic defaults to connecting to the same URL you used to access the page. which obviously fails if that is a file://...#2019-08-3011:53mccraigmccraigoh, cool - that could work - we already had the redirect thing working previously with boot-cljs, so i just ported that, but that sounds neater#2019-08-3011:54scknkkrerOne last question, how should I implement my development and production build configurations. I was reading the documentation but, I have to implement a prototype, I’m in a rush.#2019-08-3011:54scknkkrer@thheller, you rock today!#2019-08-3011:54mccraigmccraigalthough... redirecting to the shadow http: url has the advantage that triggering a page-reload on-device does the right thing - restarts the app at the latest build - that wouldn't be the case with :devtools-url would it @thheller?#2019-08-3011:55thhellernot sure what you mean. a reload does the exact same thing?#2019-08-3011:56thheller@U3JJH3URY look at any shadow-cljs example. the workflow is always to use shadow-cljs watch app during development and then use shadow-cljs release app to create a production build. they both use the same config.#2019-08-3011:57mccraigmccraigif my page url remains file:... then a page reload will reload the files deployed to the device... whereas the shadow build may have moved on since then (since each shadow build does not redeploy the cordova app, and if it did would lose all the app state)#2019-08-3011:57scknkkrer@thheller, thank you!#2019-08-3011:58mccraigmccraigbut if my cordova app has been redirected to the shadow http:... url, then i will get the latest build when reloading#2019-08-3011:59thhellerdoes cordova not load the code from disk?#2019-08-3011:59mccraigmccraigit loads from the device disk - which is not the shadow output directory#2019-08-3011:59thhellerI know next to nothing about cordova or its tools#2019-08-3012:00thhellerI'm confused. how do you load the shadow output then?#2019-08-3012:00mccraigmccraigyou do a cordova build, when creates an ios/android archive, which then gets loaded onto the simulator/device with ios/android tools#2019-08-3012:02thhellerah and that isn't rebuilt automatically?#2019-08-3012:02thhellerin react-native things just happen automatically so I assumed that was true there also#2019-08-3012:03mccraigmccraigno - and if the archive was rebuilt automatically, then the deploy process (think installing a new version of an app) would lose all the app state#2019-08-3012:03mccraigmccraigafaiui re-natal remote-mounts the cljs build directory to the device using webdav, which is a very nice trick#2019-08-3012:04mccraigmccraigso file:... reload just works on RN#2019-08-3012:04scknkkrer@U0524B4UW, Local Storage datas too ?#2019-08-3012:04mccraigmccraigbut not on cordova#2019-08-3012:05mccraigmccraig@U3JJH3URY what about local-storage ?#2019-08-3012:05scknkkrerWhen I re-build my app, are they gone too ?#2019-08-3012:05scknkkrer*they goes too ?#2019-08-3012:06mccraigmccraigno, local-storage and caching both work as you would like - they are preserved across app-upgrades by the o/s#2019-08-3012:06mccraigmccraigif you remove and re-install the app they will be cleared, but just upgrading preserves them#2019-08-3012:10mccraigmccraig@U3JJH3URY a question - why are you going with cordova rather than RN ? (if i was starting an app today, i would probably go with RN - when i started yapster, RN only had an official iOS target and a beta android target, cordova was the only game in town for ios+android+web on a single codebase)#2019-08-3012:24scknkkrer@U0524B4UW, Because, I have a background on this project. Already got a SPA with Clojurescript with well designed theme.#2019-08-3012:24scknkkrerI can’t let it throw away, and start with new design.#2019-08-3012:25scknkkrer*can’t throw it away#2019-08-3012:25mccraigmccraigah, yeah, you already said that, doh! 😬#2019-08-3012:25scknkkrer**Sorry for my bad English.#2019-08-3012:26scknkkrerOne little question @U0524B4UW.#2019-08-3012:26mccraigmccraigbetter than my rendering of your native language i'm sure @U3JJH3URY#2019-08-3012:26mccraigmccraigsure#2019-08-3012:26scknkkrerCan I ship all my builds into one, single project with shadow-cljs ?#2019-08-3012:27scknkkrer@U0524B4UW, I’m working on my English. I hope it gets better soon.#2019-08-3012:28mccraigmccraigdo you mean ship all your cljs builds into a single cordova project ?#2019-08-3012:28mccraigmccraigif you mean that, then yes, you can do that#2019-08-3012:28scknkkrerMy builds; - Web --Browser-- - Desktop --Electron-- - Mobile --Coming with Cordova - AWS --Some back-end. 😇 - And importantly, my business-logic code.#2019-08-3012:29scknkkrerNö. I mean, shipping all my builds into one project. And manage them with that one.#2019-08-3012:30scknkkrermerging my builds. I think it would be the right phrase.#2019-08-3012:31mccraigmccraigso, just have a single shadow-cljs module, which gets bundled and deployed to a bunch of different platforms - web/desktop/mobile etc ?#2019-08-3012:34scknkkrerYeah, maybe.#2019-08-3012:35scknkkrerI didn’t read the shadow-cljs documentation yet. It seems that It can solve my problem.#2019-08-3012:35scknkkrerOr, I was wrong ?#2019-08-3012:35thhellerit is totally fine to have 6 seperate builds in one shadow-cljs.edn#2019-08-3012:35thhellercan have as many as you want#2019-08-3012:36mccraigmccraigthat's what we do with web+cordova ... if you have a cljs backend too, i would guess your backend bundle would be quite different from your front-end bundle, so you may want to use some modules#2019-08-3012:38thhellerjust use different builds#2019-08-3012:39thheller:builds {:ios {...} :android {...} :backend {...} ...}#2019-08-3012:40scknkkrerAnd, are you guys feel any performance differences between figwheel and shadow-cljs builds ?#2019-08-3012:41thhellerI have never used figwheel in any real projects but I'm told shadow-cljs is quite a bit faster#2019-08-3012:42mccraigmccraigdunno about figwheel - our shadow-cljs build is considerably faster than our old boot-cljs build. i have no idea why though - dyu know why @thheller ?#2019-08-3012:43thhellerwell I did a bunch of performance optimizations to make things faster#2019-08-3012:43thhellerbut I have never used boot-cljs either so can't make a comparison#2019-08-3012:44scknkkrerquite a bit you said ? My whole life was a lie. How this thing compile my project within 4 secs ? How ? I’d bad feelings about my poor Mac. But it looks ok now. 😂#2019-08-3012:46thhellerI really don't know what the other tools do so I can't comment. I just know what I did in shadow-cljs 😉#2019-08-3012:46mccraigmccraigit's the same cljs+closure compiler underneath isn't it @thheller? what dark-magic did you do ?#2019-08-3012:46thhellerpay attention to performance I guess 😉#2019-08-3012:46thhelleralso implemented proper caching so that makes a big difference#2019-08-3012:47thhellerboot-cljs didn't cache IIRC#2019-08-3013:00scknkkrerWait. @thheller, did you shadow-cljs ?#2019-08-3013:00scknkkrer*did you create#2019-08-3013:01thhelleryes#2019-08-3013:02scknkkrerOMG. I’m writing a book. Can we arrange a meet, whenever you want. Also, until then, I will gather my questions about tool and your black-magic. 😂#2019-08-3013:02scknkkrer*an online meeting.#2019-08-3013:06thhellerwell thats what the docs are for. they should answer most questions.#2019-08-3013:06thhellerI also blogged about a few implementation details https://code.thheller.com/#2019-08-3013:07mccraigmccraigquick perf test of boot-cljs against shadow-cljs doing advanced compilation on our app - i ran builds twice, timing the second build#2019-08-3013:07mccraigmccraigboot devapp-advanced 473.78s user 18.71s system 250% cpu 3:16.78 total#2019-08-3013:07mccraigmccraiggulp release-yapdev-web 228.66s user 6.41s system 324% cpu 1:12.36 total#2019-08-3013:07scknkkrerI’d some specific questions. But no problem.#2019-08-3013:08mccraigmccraig(the gulp build drives shadow) - so the gulp/shadow build was roughly twice as quick as the boot build#2019-08-3013:09thhellerthe second build will have the cache ready so it should be faster vs no cache#2019-08-3013:10thheller@U3JJH3URY happy to answer questions but prefer to do it in text form so others can find the answers too.#2019-08-3013:15mccraigmccraigi didn't blat my .shadow-cljs directory, so cache was probably already there... having deleted .shadow-cljs and building again:#2019-08-3013:15mccraigmccraiggulp release-yapdev-web 321.94s user 30.53s system 387% cpu 1:30.96 total#2019-08-3013:15mccraigmccraigso even without cache shadow has a 25% performance boost over boot... more like 50% with cache#2019-08-3013:18thhellermaybe you are using an older clojurescript version in boot? CLJS itself got a bunch of perf updates?#2019-08-3013:18thhellermaybe you don't have :parallel-build true enabled in boot? (it is always on for shadow-cljs)#2019-08-3013:19thhellerbut yeah dunno. I did a lot of tweaks all over the place 😛#2019-08-3013:20mccraigmccraigboth done with cljs 1.10.339... :parallel-build might be a thing though - cpu usage does look higher for shadow#2019-08-3013:22mccraigmccraiganother small thing might be apples/orange build steps - those are full app builds, and iirc boot build steps are sequential, whereas we use parallel tasks in gulp to do the lessc build#2019-08-3013:22mccraigmccraigbut anyway, shadow feels significantly faster which make us 😃#2019-08-3017:06kasukoDoes shadow-cljs utilize the checkouts directory like leiningen or some similar functionality? I can symlink node dependencies, now I just have to figure out how to symlink cljs dependencies#2019-08-3017:07thhellerI'm not sure I understand the question. checkouts is not supported no but you can just add :source-paths ["src/main" "checkouts/foo/src/main"]#2019-08-3017:07thhellernot sure why you are symlinking node dependencies or cljs dependencies?#2019-08-3017:09kasukoFor development using multiple packages. Our main application is re-frame but we have an in-house Javascript component library. If we want to change a component and use it in the main application we use symlinks to allow them to use the latest version of each in development#2019-08-3017:10thhellerso you link node_modules/some-lib to somewhere/else/some-lib?#2019-08-3017:10kasukoYes, using lerna#2019-08-3017:11thhelleryou could use deps.edn with :local/root for that#2019-08-3017:11thhelleror lein checkouts#2019-08-3017:12kasukoSo I would have to switch away from using shadow-cljs.edn to manage my dependencies?#2019-08-3017:13thhelleryes#2019-08-3017:14kasukoIf I use deps.edn I can still use the shadow-cljs server right?#2019-08-3017:15thhelleryes. you only move your dependencies and source paths to deps.edn. everything else stays the same.#2019-08-3017:15thhellerwell you probably need to manage some dependency conflicts but otherwise it stays the same#2019-08-3017:16kasukoWhew, not willing to give that awesomeness up 😛#2019-08-3106:59Karol WójcikI'm receiving strange error while connected to node-repl. Everytime I want to autocomplete a symbol I receive:
No implementation of method: :-evaluate of protocol:
   #'cljs.repl/IJavaScriptEnv found for class: nil
I don't know whether it's some sort of cider internal issue or I'm doing something wrong. Steps to reproduce: 1. shadow-cljs.edn configuration
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [[instaparse "1.4.10"]]

 :builds
 {:app
  {:target           :npm-module
   :entry            forg.parser.core
   :output-dir       "target"
   :compiler-options {:infer-externs :auto}
   :devtools         {:autoload      true
                      :loader-mode   :eval
                      :repl-pprint   true
                      :async-require true}}}}
2. cider-jack-in-cljs 3. start node-repl via shadow-cljs start node-repl 4. choose node-repl from cider 5. try to autocomplete and error'll occur
#2019-08-3107:16thheller@karol.wojcik thats nrepl stuff. it appears there were some changes.#2019-08-3107:46Karol WójcikI see. Shadow-cljs support nrepl 21.0. Am I right? Ok wait. Even when I change the nrepl dependency it will still doesn't work since the emacs bindings has been changed as well. 🤔#2019-08-3107:54thhellerthere is nrepl and cider-nrepl#2019-08-3107:55thhellercider-nrepl is the thing causing trouble#2019-08-3107:55thhellercider-nrepl always needs the version matching cider AFAICT#2019-08-3108:03thhellerwell yeah they added clj-suitable which assumes it is working with figwheel#2019-08-3108:32thhellerah ok there is some conditional code so it isn't used with shadow-cljs#2019-08-3108:33thheller@karol.wojcik which shadow-cljs version are you on? guessing one before the nrepl changes#2019-08-3108:33thhelleralso btw :async-require in your build config does nothing. you can remove it#2019-08-3108:43David PhamCider-Nrepl is annoying because they keep breaking it lol#2019-08-3109:13Karol Wójcik@thheller I'm using shadow-cljs "2.8.52"#2019-08-3109:22OlicalHello! I was wondering if anyone's ever had to get the compiler environment out of shadow cljs to pass to something else? There's someone in #conjure wondering how to hook shadow up to a prepl server which I know requires the compiler environment. I'm not a shadow user though 😬 so I'm not sure what to advise.#2019-08-3110:28thheller@olical I'm currently doing some REPL work. Might get around to implementing prepl support too.#2019-09-0518:21rafaeldelboniHey @thheller do you have any update about this, is there anywhere I can follow this development? Sorry to disturb#2019-09-0518:35thhellerwell the implementation is ready. I just don't like it. it makes the same "sacrifices" that the other REPL implementations do and doesn't account for the differences CLJS REPLs have from clojure#2019-09-0518:35thhellerso tired from the "make it look like clojure" compromises#2019-09-0518:42thhellerhttps://github.com/thheller/shadow-cljs/issues/508 for progress#2019-09-0518:44rafaeldelboniThanks a lot, subscribed. There some tooling using prepl now, this would help a lot people playing around with that. Again, sorry for disturbing#2019-08-3110:29thhellergetting the compiler env it relatively easy but since only the worker is supposed to modify it you couldn't do anything with it except read from it#2019-08-3110:29OlicalOoo, well you might like https://github.com/Olical/propel as a reference. Or https://oli.me.uk/2019-03-22-clojure-socket-prepl-cookbook/#2019-08-3110:30thhellerwell I already have a working impl in a branch. I just wanted to solve the "upgrade" issue so that you don't need a separate socket for each build etc#2019-08-3110:31thhellerbut that isn't solvable without substantial changes to prepl itself which is never gonna happen#2019-08-3110:31thhellerso might as well just use a socket per REPL#2019-08-3110:36OlicalYeah, I do socket per repl#2019-08-3110:36OlicalI think it's kind of expected#2019-08-3116:20hayley@thheller is issue #508 the appropriate thing to subscribe to to be notified when socket prepl support gets included? https://github.com/thheller/shadow-cljs/issues/508#2019-08-3116:21thhelleryes#2019-08-3116:21hayleythanks!#2019-09-0102:14Drew Verleeif you configure your shadow-cljs.edn to use deps. Then do you need tell both about source-paths?/paths?#2019-09-0106:19tianshu@drewverlee it will use paths in deps.#2019-09-0107:09thheller@drewverlee no, just deps.edn will be used then#2019-09-0114:18Drew VerleeThanks!#2019-09-0118:59Drew VerleeGiven i'm importing some javascript file i have on my class path and it in turn does a project import, should i have to do anything special? Currently i get an missing dep error e.g core.cljs: ... require ... ["./some/path/main.js :refer (Foo)"] And in main.js `import bar from "some/other/path/bar" It complains that i should install some/other/path/bar.#2019-09-0119:55thheller@drewverlee one path is not like the other. the import needs to use the same path style as the cljs version#2019-09-0119:55thhellerotherwise it'll attempt to load from npm#2019-09-0119:56thhellerso the path must start with either / or ./ or ../#2019-09-0119:57Drew VerleeAh ok. I didn't prepend the slash#2019-09-0206:40dazldhey! I can see that shadow puts the nrepl port into a file called .shadow-cljs/nrepl.port - is there anyway to get cursive to pick this up automatically?#2019-09-0206:40dazldhttps://github.com/dazld/frontend-playground < I’ve put together some boilerplate and wanted to update the readme#2019-09-0206:42thhellernot yet https://github.com/cursive-ide/cursive/issues/2216#2019-09-0216:36David PhamIs there a guide to integrate Dirac to shadow-cljs?#2019-09-0216:48darwin@neo2551 no, AFAIK, I’d like to look into it#2019-09-0216:50darwinI guess, we will need something like this: https://github.com/binaryage/dirac/blob/master/examples/figwheel-main/src/repl/dirac_figmain/repl.clj, run shadow-cljs nREPL server, start there Dirac Agent and teach dirac middleware to understand shadow-cljs internals#2019-09-0217:49joshkhi'm attempting to use react-bootstrap with shadow-cljs and i'm seeing a weird behaviour. loading the compiled js in the browser throws an exception [1] only on the first load and nothing is rendered, and then any subsequent hot-reload renders the button just fine. can anyone seem what i'm doing wrong? 🙂
(ns myproject.views
  (:require
    [reagent.core :as r]
    ["react-bootstrap" :refer [Button]]))

(defn home-panel []
  (fn []
    [(r/adapt-react-class Button) {:variant "primary"} "Test 1"]))
[1]
Uncaught TypeError: (0 , _uncontrollable.default) is not a function
    at Object.shadow$provide.module$node_modules$react_overlays$Dropdown (Dropdown.js:306)
    at shadow.js.jsRequire (js.js:63)
    at Object.shadow$provide.module$node_modules$react_bootstrap$Dropdown (Dropdown.js:19)
    at shadow.js.jsRequire (js.js:63)
    at Object.shadow$provide.module$node_modules$react_bootstrap$index (index.js:84)
    at Object.shadow.js.jsRequire (js.js:63)
    at Object.shadow.js.require (js.js:97)
    at myproject.views.js:6
#2019-09-0218:37thheller@joshkh I suspect that you have a dependency conflict somewhere#2019-09-0218:37thhellercheck if the node_modules/react-bootstrap/node_modules folder exists#2019-09-0218:37thhellerand if so which dependencies are in it#2019-09-0218:45joshkhlooking at the node_modules/react-bootstrap/node_modules/package.json i do see some potential conflicts, mainly react and react-dom which i have in my own root package.json. how might i go about resolving dependency conflicts? in figwheel land i would use a combination of :excludes and top level dependencies.#2019-09-0218:45thhelleruhm that isn't what I asked#2019-09-0218:45thhellernode_modules/react-bootstrap/node_modules/package.json this shouldn't even exist?#2019-09-0218:46thhellerdid you mean node_modules/react-bootstrap/package.json ?#2019-09-0218:46joshkhah sorry, long day at work. there is no node_modules directory in node_modules/react-bootstrap.#2019-09-0218:46thhellerwhen npm installs a package with a dependency conflict it installs conflicts in a nested node_modules directory#2019-09-0218:47thhellerso that package didn't have any conflicts, its deps may still have though#2019-09-0218:47thhellerI forgot what the npm command for this was#2019-09-0218:48thhellernpm list or something#2019-09-0218:48joshkhokie dokie, i'll dig into it. thanks for the help!#2019-09-0218:48thheller(0 , _uncontrollable.default) this looks very suspiciuous though so might be something else#2019-09-0218:49joshkhyeah. and all subsequent hot-reloads work just fine.
#2019-09-0218:57thhelleryeah found the problem#2019-09-0218:58thhellerreact-bootstrap requires react-overlays which wants "uncontrollable": "^6.0.0"#2019-09-0218:58thhellerbut react-bootstrap installs "uncontrollable": "^7.0.0"#2019-09-0218:58thhellerreact-overlays has the nested install (so node_modules/react-overlays/node_modules/uncontrollable/...)#2019-09-0219:06joshkhah, gotcha! thanks for digging into it. i'm only just reacquainting myself with npm after spending a long time (happily) avoiding it.#2019-09-0219:07joshkhis there an idiomatic way to resolve it?#2019-09-0219:16David PhamReferring to this chapter from the documentation (https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js), I am trying to mix javascript and clojurescript. I converted my JSX files with Babel, however the following line import React, { Component } from 'react'; leads me to the error Requested module does not have an export "Component". when I import the file. Does anyone have an idea how to solve this issue?#2019-09-0219:23thheller@neo2551 yeah that is not supported and wouldn't work in webpack5 either#2019-09-0219:23thhellerthey just currently have this compatibility mode that still allows this, just won't in the future#2019-09-0219:23thhellerimport React from "react"; and React.Component should do it#2019-09-0219:23David Phamok! Thanks a lot!#2019-09-0219:28thheller@joshkh not sure that can actually be resolved. in webpack it'll happily use 2 versions of the same library but that isn't supported in shadow-cljs because I think that is nonsense#2019-09-0219:35joshkhwebpack craziness is what drove me to shadow-cljs. 😉 i understand#2019-09-0219:53David Pham@thheller Are there anyway to get something else than the default export?#2019-09-0219:54thhellerwhat do you mean?#2019-09-0219:54David PhamIn the example you provided me for importing react#2019-09-0219:54David Phamis there a way to get React is the default export#2019-09-0219:54thhellerthey should all be properties of the React export#2019-09-0219:55thhellerbut no direct :refer#2019-09-0219:55David PhamI understand, I am trying to explain my problem with the example of react#2019-09-0219:55David Phamand apply it to other libraries#2019-09-0219:55thhellerreact itself is packaged as commonjs, shadow-cljs and closure-compiler only support strict-style commonjs -> ESM interop (as will webpack5)#2019-09-0219:56David Phamguess, I will have to study JS(hit) a bit#2019-09-0219:56thhellerand with strict interop the ESM can only use a default export from commonjs#2019-09-0219:57thhellerit depends on how the package is packaged. if is it actual ESM code or commonjs (ie. compiled by babel)#2019-09-0219:57thhellerthe situation is a bit icky currently as many packages are switching from the compatible style to the strict style#2019-09-0219:58thhellerthus breaking those that still expect the compatible style#2019-09-0219:58thhellerit is a complete mess 😛#2019-09-0219:58David Pham🙂#2019-09-0219:58David PhamSorry for the newbee questions xD#2019-09-0219:58thhellerif you have specific examples I can make suggestions but it is a pretty broad topic#2019-09-0219:59David PhamI am trying to improt this type of dependencies#2019-09-0219:59David Phamhttps://github.com/plotly/react-chart-editor/blob/master/src/index.js#2019-09-0219:59thhellerthe webpack folks have been talking about this for a while now https://www.youtube.com/watch?v=p-MhcctQBlY#2019-09-0219:59thhellerbut it still isn't out yet so we'll see how that goes#2019-09-0220:00David PhamThanks, I am totally new to JS, I started UI on the web with shadow-cljs, so have been totally protected from all that. xD#2019-09-0220:00thhellerwell not totally protected since you are exposed to all npm packages 😉#2019-09-0220:01thhellermight actually be smoother in webpack for now given that it still supports the old stuff#2019-09-0220:01David PhamYes, I accept a bit of impurity (Clojure is meant to be practical xD)#2019-09-0220:01thhellerwhat is the actual problem though?#2019-09-0220:01thhellerI hope you are not trying to put react-chart-editor on the classpath and import directly?#2019-09-0220:01David PhamI would like to use this statement in a custom jsx file import PanelMenuWrapper from 'react-chart-editor';#2019-09-0220:02David Phamnope, I am trying to build custom js file, export them through babel#2019-09-0220:02thhellerthat doesn't look right?#2019-09-0220:02thhellerimport RCE from "react-chart-editor"; and then RCE.PanelMenuWrapper?#2019-09-0220:02David Phamnope, because PanelMenuWrapper becomes the default exort#2019-09-0220:02David Phamand the default export is not one that embeeds all of them#2019-09-0220:03thhellerno, there is only one default export#2019-09-0220:03David PhamPlotlyEditor is the default export#2019-09-0220:03thhellerwith the name that you give it. the name is completely up to you.#2019-09-0220:03thhellerjust like clojure (:require [some.thing :as whatever-you-want])#2019-09-0220:03thhellerthe alias has no relation to the actual name#2019-09-0220:04David Phamthanks for the precision! The issue is the default export is a (extremely restricted) subset of the exposed variable in the index.js file#2019-09-0220:05David Pham
import PlotlyEditor from './PlotlyEditor';
import DefaultEditor from './DefaultEditor';
import EditorControls from './EditorControls';
import {EDITOR_ACTIONS} from './lib/constants';

export {DefaultEditor, EditorControls, EDITOR_ACTIONS};

export * from './lib';
export * from './components';
export * from './default_panels';

export default PlotlyEditor;
#2019-09-0220:05thhellerdon't ever look at the source code#2019-09-0220:06thhellerit is lying to you more often than not#2019-09-0220:06David Phamhaha, the best advice ever xD#2019-09-0220:07thhellerthe easiest way I find to inspect what is going on is doing#2019-09-0220:07thhellershadow-cljs browser-repl#2019-09-0220:07thheller(require '["react-chart-editor" :as x])#2019-09-0220:07thheller(js/console.dir x) then look at the object in the browser-repl browser console#2019-09-0220:08thhellerone thing you can also do is just use commonjs#2019-09-0220:08thhellerso in your .js files just use const RCE = require("react-chart-editor");#2019-09-0220:08thhellerthat isn't subject to the commonjs->ESM interop stuff#2019-09-0220:08David Phamohhhh this seems cool#2019-09-0220:09thhellerso RCE might have the full set of properties#2019-09-0220:09David Phamthe funny stuff is#2019-09-0220:10David Phamthe cljs version works, I get full access to everything.#2019-09-0220:10David Phambut not the jsx#2019-09-0220:10thhellertry the commonjs style (ie. use require not import)#2019-09-0220:12David Phamnope, still gives me PlotlyEditor#2019-09-0220:12David PhamAlthgough Babel translate it to#2019-09-0220:12David Phamconst RCE = require('/node_modules/react-chart-editor/lib/index.js');#2019-09-0220:13thhellerI think you mean shadow-cljs did that part?#2019-09-0220:14thhellerbabel should leave it as require("react-chart-editor")?#2019-09-0220:15David Phamthe shadow-cljs part works totaly fine#2019-09-0220:15thhelleryes but please be clear in which files you are talking about#2019-09-0220:15David PhamThe workflow is: custom JSX -> babel -> cljs#2019-09-0220:15thhelleryou have JSX. that is transformed by babel, that is then transformed by shadow-cljs#2019-09-0220:16David PhamI am editing the custom JSX file#2019-09-0220:16thhellerso check the babel output what that does#2019-09-0220:16thhellerI hope you are not putting node_modules on the classpath?#2019-09-0220:17David Phamnope 🙂#2019-09-0220:17David Phamconst RCE = require('react-chart-editor');is the output babel#2019-09-0220:17thhellergood 🙂#2019-09-0220:17thhellershadow-cljs adjusts the paths so you know which files were actually used#2019-09-0220:18thheller(and to work around a problem in the Closure Compiler)#2019-09-0220:18David Phamshadow-cljs is great 🙂#2019-09-0220:18thhellerbut yeah RCE should have all the stuff you want?#2019-09-0220:19David Phamnope, when I enter console.log(RCE.Button); I get undefined#2019-09-0220:19thhellerhmm actually it might not have#2019-09-0220:19David Phamfunnily enough on shadow-cljs I get something xD#2019-09-0220:19thhellerbut then shadow-cljs should have either?#2019-09-0220:20David Phamyes shadow-cljs have either. This is what kills me xD. I can write better js in cljs than in js#2019-09-0220:20thhellerso if you console.log(RCE) in the JS you get different output then (:require ["react-chart-editor" :as x]) and (js/console.log x)?#2019-09-0220:21thhellerthat should match?#2019-09-0220:21David Phamnope.#2019-09-0220:21David PhamJS -> undefined, cljs -> {default f} and when you open it you get the whole shebang of objects.#2019-09-0220:22thhellerwith console.log(require("react-chart-editor"))?#2019-09-0220:23thhellerthat shouldn't be undefined?#2019-09-0220:23thhelleroh or does it throw an error in the browser console while loading?#2019-09-0220:23thhellerthat isn't handled well currently#2019-09-0220:23David PhamI get f PlotlyEditor(props) for js, against the expected {default: f, ...}#2019-09-0220:25thhellerhmm thats weird#2019-09-0220:25thhellerbut we are talking about require here yes? definitely not import?#2019-09-0220:26David Phamyes#2019-09-0220:26David Phamdefinitively require#2019-09-0220:26David PhamI copy past your code#2019-09-0220:26thhellerso there is no import in the file at all anymore I mean?#2019-09-0220:26David Phamlet me try again#2019-09-0220:26David Phamwith a minimal example#2019-09-0220:27David Phamok, with minimal example, it still output the default export from index.js#2019-09-0220:28David Pham
const RCE = require('react-chart-editor');

console.log(RCE.PanelMenuWrapper);
console.log(require('react-chart-editor'));
const CustomEditor = function (props, context) {
  return React.createElement("div", null);
};

export default CustomEditor;
#2019-09-0220:29David Phamgot undefined, and PlotlyEditor as output in the browser#2019-09-0220:29thhellertry console.dir(RCE)#2019-09-0220:29thhellerand don't mix module styles#2019-09-0220:30David Phamƒ PlotlyEditor(props)#2019-09-0220:30thhellermodule.exports.default = CustomEditor#2019-09-0220:30thhellergeez how gigantic is this react-chart-editor package#2019-09-0220:30thhellerseems like it is downloading the entire internet right now#2019-09-0220:31David Phamyou remember when I asked you how to load npm packages in the browser and you said to me to use the "eval" option somehwere in the config?#2019-09-0220:31David Phamthis was because of that XD#2019-09-0220:32thhelleryeah. are the no smaller alternatives? 😛#2019-09-0220:33David PhamI wish. 🙂 My rationale was that it would require me a lot of work to rewrite the stuff in re-frame.#2019-09-0220:33David PhamThey have a two way communication between the editor and plot, and plotly have a gigantic amount of options.#2019-09-0220:33David Pham(obviously I could start small), but I doubt my employer would accept me saying: I can't use JS, so I reimplemented the wheel xD#2019-09-0220:36David Phambut if it does not work, I will just go with the slow way, it is just annoying. I tried to reimplent some part directly in CLJS, but the I don't understand how they bind this in their subcomponent.#2019-09-0220:38David PhamWell thanks, I need to go to sleep but it was really nice and enjoyable to talk to you @thheller#2019-09-0220:39thhellerhope you find a way to sort it out 😛#2019-09-0220:59David PhamReinventing the wheel#2019-09-0220:59David PhamWorks all the time #2019-09-0221:02thhellerit is completely possible that you are just running into an edge case in the shadow-cljs JS support#2019-09-0221:02thhellernot many people use it and it definitely can have issues 😛#2019-09-0312:45kasukoDoes anyone have advice on writing multiple shadow-cljs libraries for use in Javascript? Our application was at one time fully CLJS and in one project. Now due to business reasons the company is writing more pure Javascript libraries. We are using shadow-cljs to utilize our previous code in a JS ecosystem. However, I personally do not want to get rid of CLJS, so if I can use shadow-cljs to write libraries that can be used in Javascript (which it appears I can) I'd be ecstatic. However, before I go and write a bunch of libraries with Shadow CLJS I was wondering if I should take into account things like Clojure's Core being included multiple times, etc?#2019-09-0312:59thheller@kasuko writing mulitple libraries in CLJS and including them in a regular JS builds is not a good idea#2019-09-0312:59thhellerincluding cljs.core multiple times is really bad as you mentioned#2019-09-0312:59thhellerbut also the libraries will not be compatible with each other#2019-09-0313:00thhellerwhat you can do is create a :npm-module build that outputs all CLJS you want to use in the JS build#2019-09-0315:55kasukoIs it possible to do some kind of code-splitting with that? For example if I build an authentication library I want to be able to provide that without including every libary#2019-09-0316:16thhellernot sure what you mean#2019-09-0316:16thhellercode splitting would be done by webpack or whatever you use on the JS side#2019-09-0316:17thhellerbut CLJS in general is not great for writing JS libraries. :advanced optimizations really aren't suited for that#2019-09-0316:17thhellerand the code is too big with :simple#2019-09-0316:18David PhamCan shadow-cljs replace Lumo for writing shell scripts? Since you can call node your_output_cljs.js?#2019-09-0316:18thheller@neo2551 depends. :node-script is meant to build scripts which you can run later yes#2019-09-0316:19thhellerbut the edit -> compile -> run delay makes it impractical if you just want some ad-hoc scripting#2019-09-0316:19thhellerbut once the output is built it'll be faster than lumo since it doesn't have to load the compiler first#2019-09-0316:20David PhamHum... I usually shadow-cljs watch app when I am writing my script :)#2019-09-0316:20David Pham(I just avoid to call the side effects part haha)#2019-09-0316:20thhelleryeah thats fine. but you still have to run shadow-cljs first (which takes some time to start)#2019-09-0316:21David PhamBut once it is built, the output would have be optimal with node?#2019-09-0316:21thhelleryes (and it doesn't rely on shadow-cljs anymore, unlike lumo)#2019-09-0316:22David PhamYep, perfect! (You should totally sell this as cool feature) :)#2019-09-0500:00sogaiuas a recent user of this feature i'm curious whether the resulting js would be dependent on the installed node version.#2019-09-0509:08thhelleryes, it is just a javascript file.#2019-09-0510:01sogaiuthanks -- so it seems like recompilation might be necessary when using with different node environments#2019-09-0510:47thhellerno it doesn't?#2019-09-0511:20sogaiuah, right, as you said the product is just a js file so if node's behavior changes, that potentially affects all js files regardless of where they originate. thanks for the deconfusion.#2019-09-0316:22David PhamHell, i don’t understand shell scripts #2019-09-0316:35sjharmsAs a very new person to Shadow-cljs, I was wondering where I could find a tutorial or guide on setting up a project with deps.edn, clojure cli, shadow-cljs and re-frame. Is there one that exists?#2019-09-0316:36sjharmsStory so far: 1. Install NPM 2. Install shadow-cljs 3. Install clojure cli 4. Copy deps.edn from https://github.com/Day8/re-frame/blob/master/deps.edn 5. shadow-cljs init 6. npm init#2019-09-0316:38kszabowell it’s not exactly what you asked for but Fulcro3's new template is a full CLJS SPA with all of the build tools above, just with Fulcro3 instead of re-frame: https://github.com/fulcrologic/fulcro-template#2019-09-0316:45sjharmsThanks I will take a look! As a beginner its hard to compare and contrast the available options#2019-09-0316:48kszabosure thing, I would start with fulcro3 today, having developed multiple apps with re-frame, it’s way more framework-y, but it provides way more in return. See the docs for further info: http://book.fulcrologic.com/fulcro3/#2019-09-0316:41thheller@sjharms https://www.learnreframe.com/?ref=uk29i#2019-09-0316:42thhellerdoesn't use deps.edn though#2019-09-0316:42thhellerthe setup part is free https://www.jacekschae.com/learn-re-frame-free#2019-09-0316:42thhellerthe setup part is free https://www.jacekschae.com/learn-re-frame-free#2019-09-0316:43sjharmsThanks! I really like his courses (and purchased the reagent one), I was just trying to build up a list of steps to bootstrap up to his first lesson#2019-09-0316:43sjharmsie it already starts with https://github.com/jacekschae/learn-re-frame-course-files/blob/master/increments/03-dev-setup/shadow-cljs.edn#2019-09-0317:30thhellerI guess you can use some of the templates like https://github.com/Day8/re-frame-template#2019-09-0409:19flowthingAfter updating to 2.8.52, when I run shadow-cljs watch app, I get an error like this: RejectedExecutionException: Task Deleting the .shadow-cljs directory makes it go away, but it reappears when I restart shadow-cljs with an existing .shadow-cljs directory. Anyone come across the same issue?#2019-09-0409:20flowthingI'm trying to upgrade from 2.8.39, which works fine.#2019-09-0409:22flowthingStacktrace:
RejectedExecutionException: Task 
#2019-09-0409:23thhellerhow do you run shadow-cljs? using lein/deps.edn? embedded?#2019-09-0409:23flowthing#2019-09-0409:26flowthingActually, just a moment...#2019-09-0409:26thhellerothers have reported running into this occasionally but I have never been able to reproduce#2019-09-0409:27thhellerand I have no clue how this could happen other than trying to actually interrupt a build#2019-09-0409:28flowthingRight. It is certainly weird. I can certainly try to look into it, but I'm not sure where I'd even start.#2019-09-0409:29thhellermake sure you only have one shadow-cljs instance running for the project#2019-09-0409:30flowthingOK, will double-check.#2019-09-0409:32thhellerdo you connect a REPL before this happens? or does it happen on its own by just running shadow-cljs watch app?#2019-09-0409:33flowthingHappens on its own.#2019-09-0409:33flowthingHere's a fuller terminal output:
shadow-cljs - config: /Users/eerohe/Code/ci/shadow-cljs.edn  cli version: 2.8.52  node: v11.15.0
shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app
Warning: implicit hook found: lein-environ.plugin/hooks
Hooks are deprecated and will be removed in a future version.
NPM dependency "highlight.js" has installed version "^9.15.10"
"9.15.8" was required by jar:file:/Users/eerohe/.m2/repository/day8/re-frame/re-frame-10x/0.4.2/re-frame-10x-0.4.2.jar!/deps.cljs
shadow-cljs - server version: 2.8.52 running at 
shadow-cljs - nREPL server started on port 50001
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
shutting down ...
shutting down ...
[:app] Build failure:
RejectedExecutionException: Task 
#2019-09-0409:34thhellershutting down ...#2019-09-0409:34thhellerso the server is actually shutting down#2019-09-0409:34thhellerothers have reported this happening due to memory issues#2019-09-0409:34thhellertry setting :jvm-opts ["-Xmx2G"] in project.clj#2019-09-0409:34flowthingWill do.#2019-09-0409:34thhellerto limit to maximum 2gig ram#2019-09-0409:35thhellercan use 1G#2019-09-0409:35thhelleror 512M#2019-09-0409:35thheller1G is typically enough#2019-09-0409:35thhellerdunno why it works with older versions though. I didn't change anything that would affect memory issues#2019-09-0409:36flowthingBy the way, I also get this if I remove the :lein key from my shadow-cljs.edn:
[2019-09-04 12:34:47.608 - WARNING] :shadow.cljs.devtools.server.fs-watch-hawk/hawk-start-ex
ArityException Wrong number of args (0) passed to: clojure.core/juxt
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	hawk.core/watch! (core.clj:79)
	hawk.core/watch! (core.clj:59)
	shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:41)
	shadow.cljs.devtools.server.fs-watch-hawk/start* (fs_watch_hawk.clj:29)
	shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:102)
	shadow.cljs.devtools.server.fs-watch-hawk/start (fs_watch_hawk.clj:100)
	clojure.lang.Var.invoke (Var.java:399)
	shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:26)
	shadow.cljs.devtools.server.fs-watch/start (fs_watch.clj:11)
	shadow.cljs.devtools.server/start!/fn--16824 (server.clj:435)
#2019-09-0409:37thhellerhmm what are your :source-paths then?#2019-09-0409:37flowthingIn my shadow-cljs.edn? None, so that's probably the issue. Maybe disregard that for now, would probably need to make more extensive changes to my shadow-cljs.edn to eliminate Leiningen. 🙂#2019-09-0409:38flowthingSeems like increasing memory might've done the trick...#2019-09-0409:38thhelleryes if you remove lein you need to transfer :source-paths and :dependencies#2019-09-0409:38thhelleryou actually decreased memory#2019-09-0409:38thhellerthe JVM defaults to using a higher limit#2019-09-0409:39flowthingHm, doesn't Xmx specify the maximum memory allocation pool?#2019-09-0409:39thhellermaximum heap size yes#2019-09-0409:41flowthingI always thought that was platform-specific in some way. 🤔#2019-09-0409:41thhelleryeah it is#2019-09-0409:42thhellerthe default is 8gb on my machine (32gb ram)#2019-09-0409:43thhellerjava -XX:+PrintFlagsFinal -version | grep HeapSize#2019-09-0409:43thhellershows your platform default#2019-09-0409:43thheller size_t MaxHeapSize = 8573157376 {product} {ergonomic}#2019-09-0409:44flowthingRight, seems to be 4GB for me.#2019-09-0409:44flowthingLearned something new in addition to finding a fix for my issue. Huge thanks once again for your help!#2019-09-0409:44thhelleryeah so something in the OS seems to be killing the shadow-cljs process#2019-09-0409:44thhellerare in on OSX by any chance?#2019-09-0409:44flowthingYes.#2019-09-0409:45thhellerso far I think everyone reporting this was on OSX#2019-09-0409:45thhellergood to know for the future 😛#2019-09-0409:50flowthingJust as a sanity check, I tried copying my :dependenciesand {:dev {:dependencies ,,, }} from project.clj into shadow-cljs.edn wholesale and specifying :source-paths and the issue doesn't occur.#2019-09-0409:51thhellerdo you maybe have additional lein plugins or ~/.lein/profiles.clj or so adding extra deps?#2019-09-0409:52flowthingGood point, I could try disabling those.#2019-09-0409:52thhellerbut yeah running through lein consumes slightly more memory since it starts 2 JVMs#2019-09-0409:52flowthingYep.#2019-09-0409:55flowthingReplacing my ~/.lein/profiles.clj (which loads some plugins) with an empty map also solves the issue.#2019-09-0409:56thhellergood to know#2019-09-0410:07flowthinghttps://gist.github.com/eerohele/87a37812729f87d8b27cd9d3ca94e5e3 Made this in case someone else tries googling the same issue.#2019-09-0410:09thhellerthe exception is just a symptom of the shutting down .... so thats the real problem#2019-09-0410:13flowthingRight, thanks; updated the Gist to reflect that.#2019-09-0413:10kaaninhoHey! I am using shadow-cljs and want to get integration with Emacs. Putting [cider/cider-nrepl "0.18.0"] in the shadow-cljs.edn file (under :dependencies) works fine. But when I remove it there and instead paste it into user config file ~/.shadow-cljs/config.edn it breaks. Some ideas?#2019-09-0413:11thheller~/shadow-cljs/config.cljs should be ~/shadow-cljs/config.edn?#2019-09-0413:12kaaninhosry typo.#2019-09-0413:14thhellercan you paste the actual content?#2019-09-0413:15thhelleroh and which version are you on? cider-nrepl 0.18 is kinda old#2019-09-0413:15kaaninho
{:dependencies
 [[cider/cider-nrepl "0.18.0"]]

 :deps-aliases [:cider]}
#2019-09-0413:16thhellershould work fine?#2019-09-0413:18kaaninhoIn Emacs, it finds the correct Port, but after choosing that, I get error in process filter: Wrong type argument: stringp, nil#2019-09-0413:19kaaninho(After saying [nREPL] Direct connection to localhost:60273 established)#2019-09-0413:19dpsuttonwhat does m-x cider-version report?#2019-09-0413:20kaaninhoCIDER 0.22.0snapshot (package: 20190817.800)#2019-09-0413:21dpsuttoninstead of 0.18.0 use 0.22.2 for your cider-nrepl version#2019-09-0413:19thhellerI have no clue about the emacs side of things. you can run shadow-cljs clj-repl and then ( "cider/nrepl.clj") to verify it is actually on the classpath#2019-09-0413:20thhelleror just (System/getProperty "java.class.path") and look for the cider entry#2019-09-0413:22kaaninhoThe first one gets me a nil - that shouldn't be, should it?#2019-09-0413:22thhellerhmm that should not be nil#2019-09-0413:22thhellerwell actually no clue since I don't know if thats the correct filename#2019-09-0413:23thhellerbut should be correct#2019-09-0413:23dpsuttonthe client is 0.22 and cider-nrepl is 0.18. No clue what it should be. Bump the dep to [cider/cider-nrepl "0.22.2"]#2019-09-0413:24kaaninhoI did, doesn't work#2019-09-0413:24thhellerwhich shadow-cljs version?#2019-09-0413:24dpsuttonsame error?#2019-09-0413:24kaaninhoYes#2019-09-0413:24kaaninhoshadow-cljs - server version: 2.7.9#2019-09-0413:25thhellerupdate that. can't remember which version I added support for ~/.shadow-cljs/config.edn. it may be too old for that#2019-09-0413:25thheller2.8.52 is current#2019-09-0413:26kaaninhoAh, I'll try that! Reporting back... .#2019-09-0413:32mccraigmccraigi'm getting compile errors from an ns :require form which works in shadow-cljs node-repl with (require <...>). the form is:
["google-libphonenumber"
             :refer [PhoneNumber]
             :rename {PhoneNumber.CountryCodeSource ccs
                      PhoneNumberFormat pnf
                      PhoneNumberUtil pnu}]
am i doing something obviously wrong ?
#2019-09-0413:36kaaninhoNow it's connecting and asking about the build (`:app`). After that I don't get a cljs-repl tho and can't eval buffers. In the clj-repl is the warning
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.[:app] Build completed. (1647 files, 1618 compiled, 0 warnings, 49,33s)
pasted.
#2019-09-0413:38thheller@mccraigmccraig this isn't allowed PhoneNumber.CountryCodeSource ccs and should never work#2019-09-0413:39thhellerpurely accidental when it does#2019-09-0413:39mccraigmccraigoh, lol, ok#2019-09-0413:40thhellerbut what is the compile error?#2019-09-0413:40mccraigmccraig
------ WARNING #3 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:3:7
 variable pnu is undeclared
--------------------------------------------------------------------------------
------ WARNING #4 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:8:200
 variable ccs is undeclared
--------------------------------------------------------------------------------
------ WARNING #5 -  -----------------------------------------------------------
 Resource: er_model/util/phone_number.cljc:186:83
 variable pnf is undeclared
--------------------------------------------------------------------------------
#2019-09-0413:41mccraigmccraigso it's complaining about the aliases in the ns form#2019-09-0413:41thhellerand the ns form was?#2019-09-0413:41mccraigmccraig
(ns er-model.util.phone-number
  (:require
   [plumbing.core :refer [assoc-when defnk]]
   #?(:cljs ["google-libphonenumber"
             :refer [PhoneNumber]
             :rename {CountryCodeSource ccs
                      PhoneNumberFormat pnf
                      PhoneNumberUtil pnu}]))
  #?(:clj
     (:import
      [com.google.i18n.phonenumbers
       PhoneNumberUtil
       PhoneNumberUtil$PhoneNumberFormat
       Phonenumber$PhoneNumber
       Phonenumber$PhoneNumber$CountryCodeSource])))
#2019-09-0413:41thhellerthat is incorrect#2019-09-0413:41thhellerhmm no wait#2019-09-0413:42thhellerI hate cljc so much ... this is so unreadable 😛#2019-09-0413:47thhellerit compiles fine for me?#2019-09-0413:47thhelleralthough I tested in a cljs file#2019-09-0413:48mccraigmccraighmm. i got rid of the wrong :rename, but i'm still getting errors relating to the other :rename symbols#2019-09-0413:49mccraigmccraigi'll try just getting rid of all the :renames and see how that goes#2019-09-0413:49thheller
(ns demo.cljc
  (:require
    #?(:cljs ["google-libphonenumber"
              :refer [PhoneNumber]
              :rename {CountryCodeSource ccs
                       PhoneNumberFormat pnf
                       PhoneNumberUtil pnu}])))

(js/console.log ccs pnf pnu)
#2019-09-0413:49thhellerthis compiles and runs fine for me although ccs is undefined#2019-09-0413:51mccraigmccraigyeah, it works fine for me in the node-repl... and ccs is an attribute of PhoneNumber which is where i was going with the accidentally working PhoneNumber.CountryCodeSource thing#2019-09-0413:51mccraigmccraigjust doesn't compile from the .cljc#2019-09-0413:51thhellerworks fine for me#2019-09-0413:51thhellerwhich version? using lein/deps?#2019-09-0413:52kaaninhoGotta go, ty for helping me, @thheller and @dpsutton#2019-09-0413:52kaaninho🙂#2019-09-0413:55mccraigmccraigcli version: 2.8.39 node: v12.5.0 and not using lein or deps directly#2019-09-0414:12mccraigmccraigodd. the PhoneNumberFormat and PhoneNumberUtil objects don't seem to be there when compiling, although they do when running the repl#2019-09-0414:12mccraigmccraigbut the PhoneNumber object is there in both cases#2019-09-0419:57mccraigmccraigfinally got it to work @thheller , and ditched the .cljc in favour of two small equivalent .cljs and .clj files - much easier to read#2019-09-0419:58thhellerstill would like to find out what was causing the issue for you though 😛#2019-09-0419:59mccraigmccraigi'm not sure why, but in the google-libphonenumber lib the PhoneNumberUtil and PhoneNumberFormat don't work in the :require but are accessible as properties of the default export - https://gist.github.com/mccraigmccraig/1e8dafda6d86ea6ae0018b492992ee40#2019-09-0419:59thhellerit compiled absolutely fine for me in .cljc and .cljs#2019-09-0419:59thhelleryou are using it incorrectly#2019-09-0420:00mccraigmccraigoh, how ?#2019-09-0420:00thheller:as sets up a namespace alias. so you should NOT be using (.-PhoneNumberUtil phone-number) and use the correct phone-number/PhoneNumberUtil instead#2019-09-0420:01mccraigmccraigok, cool - i initially tried to :refer [PhoneNumber PhoneNumberUtil PhoneNumberFormat] but that lead to nils for PhoneNumberUtil and PhoneNumberFormat#2019-09-0420:02thhellerwhat?#2019-09-0420:02thhellerphone-number/PhoneNumberUtil would be nil then as well?#2019-09-0420:02thhellersomething weird is going on in your setup if it is?#2019-09-0420:02mccraigmccraiglet me try again, now i've got it all simplified#2019-09-0420:03thheller:refer and :rename work absolutely fine for me#2019-09-0420:04mccraigmccraigi'm using :refer in lots of other namespaces without issue...#2019-09-0420:04mccraigmccraignever used :rename before, but i was trying to duplicate what a cljsjs lib was doing#2019-09-0420:05mccraigmccraigok, well now the :refer works fine, so i have no idea what was causing my issue before#2019-09-0420:06mccraigmccraigi'm sorry if i wasted your time#2019-09-0420:06mccraigmccraigyep, this compiles and tests pass now: https://gist.github.com/038776041d6d49e27bb6a7536bd8baf2
#2019-09-0420:13thheller:rename should work fine except for the Thing.X so a dot is technically questionable#2019-09-0420:13thhellerit kinda works but it isn't really recommended to do that#2019-09-0422:40eagI'm trying to use highcharts to create a reagent component. I think I'm having trouble with an Extern, I can't get it to work. The example I followed uses cljsjs and obviously works here. https://ingesolvoll.github.io/posts/2018-12-04-revisited-how-to-use-a-charting-library-in-re-frame/ I added :compiler-options {:infer-externs :auto} to my shadow-cljs.edn But the mount-chart function blows up with an undefined argument. Highcharts How can I make that symbol stick ?
(ns prod-inv-ui.views
  (:require
   [reagent :as r]
   ...
   ["highcharts" :as hc]))

(defn mount-chart [comp]
  (hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))

;; with cljsjs
;; (defn mount-chart [comp]
;;   (.chart js/Highcharts (r/dom-node comp) (clj->js (r/props comp))))

(defn update-chart [comp]
  (mount-chart comp))

(defn chart-inner []
  (r/create-class
   {:component-did-mount   mount-chart
    :component-did-update  update-chart
    :reagent-render        (fn [comp] [:div])}))

(defn chart-outer [config]
  [chart-inner @config])
#2019-09-0507:02thheller@eag it would help to know what you actual error is? I don't see anything that would require externs?#2019-09-0507:03thhellerI see an error but that would blow up in development also?
(defn mount-chart [comp]
  (hc/chart Highcharts (r/dom-node comp) (clj->js (r/props comp))))
there is an extra Highcharts that seems undefined? and should just be
(defn mount-chart [comp]
  (hc/chart (r/dom-node comp) (clj->js (r/props comp))))
#2019-09-0507:08eagIf I do that, take out the Highcharts, I get this.
highcharts.js:271 Uncaught TypeError: Cannot read property 'series' of null
    at c$jscomp$1.Chart.init (highcharts.js:271)
    at c$jscomp$1.Chart.getArgs (highcharts.js:271)
    at new c$jscomp$1.Chart (highcharts.js:270)
    at Object.c$jscomp$1.chart (highcharts.js:270)
    at Constructor.prod_inv_ui$views$mount_chart (views.cljs:14)
    at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:194)
    at Constructor.componentDidMount (factory.js:666)
    at commitAllLifeCycles (react-dom.development.js:17335)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
#2019-09-0507:09eagwith hc/Highcharts I get an undefined symbol...#2019-09-0507:14thhellerseries is likely expected to be a prop? did you check what you are passing to it? try logging (js/console.log (clj->js (r/props comp))) in the mount-chart fn?#2019-09-0507:15thhelleralso check if you are using the correct version? you just might have a different highcharts version from the one defined in cljsjs?#2019-09-0507:31eagOk. It's working. Thank you for the prompts. My config variable was not dereferenced. And i don't really need the externs... Sorry about that, I got mislead by all the examples I've been reading.#2019-09-0513:28aisamuHi! We've observed compilation failures when using the explicit (. var -field) form inside some forms (`if`, when, but not do)
;; Both work
(.-ok response)
(. response -ok)

;; Works
(if (.-ok response)
  true
  false)

;; Fails
(if (. response -ok)
  true
  false))

  19 |  (if (. response -ok)
--------^-----------------------------------------------------------------------
Error in phase :compilation
IllegalArgumentException: no conversion to symbol
	clojure.core/symbol (core.clj:596)
	clojure.core/symbol (core.clj:589)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:849)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:837)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:840)
	cljs.analyzer/confirm-var-exists (analyzer.cljc:837)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:357)
	shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:142)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1269)
	cljs.analyzer/resolve-existing-var (analyzer.cljc:1264)
Latest (`2.8.52`) also contains the issue, unfortunately. We've quickly tested it without shadow and it doesn't seem to break there 😞
#2019-09-0513:30thheller@aisamu what is response? does it also not work when changing the name?#2019-09-0513:39thhellerand what is the rest of the stacktrace? is this inside some other macro maybe trying to rewrite it? (eg. core.async)#2019-09-0513:53thhellerhmm I found it ... trying to figure out why it happens ... looks to me like a bug in CLJS#2019-09-0515:13thhellerhttps://clojure.atlassian.net/browse/CLJS-712#2019-09-0519:50aisamuThank you! I'm assuming you've already figured most of it out, but response is a #js object. Using a regular CLJS map or changing the names give us the same error. Surprisingly, running it on app.klipse.tech doesn't seem to break things!#2019-09-0519:51thhellerklipse uses the self-hosted compiler#2019-09-0519:51thhellerthe bug is getting fixed in CLJS properly https://clojure.atlassian.net/browse/CLJS-3163#2019-09-0519:52thhellerhesitant to add a temporary workaround#2019-09-0519:53aisamuNot a problem - the alternative version (.-ok works as expected!#2019-09-0515:39kennyI get these sorts of errors after restarting shadow-cljs a few times:
{:type java.io.FileNotFoundException
   :message "/home/kenny/compute_software_mono/projects/ui/src/compute/ui/login/views.cljs (Too many open files)"
   :at [java.io.FileInputStream open0 "FileInputStream.java" -2]}
Typically the only way to fix it is restarting my computer. Anyone know of a better solution?
#2019-09-0515:40thhellerhmm odd. are the old processes maybe hanging around for some reason?#2019-09-0515:40thhellerotherwise all the files they had open should be closed?#2019-09-0515:41kennyMaybe. I tried killall node but no node processes are found.#2019-09-0515:41thhellercheck java. the node process only starts the real java process#2019-09-0515:42thhellerwhich OS is that? looks like linux? maybe you are running into some kind of system limits for other reasons?#2019-09-0515:44kennyOh. Will try killing all java. Was using a a hand-rolled lib to run multiple processes at once that could've left processes running. Switching to npm-run-all in hope that it is better at killing processes. I'm on Ubuntu. I've set that file limit pretty high.#2019-09-0515:45kennyStill got the exception after killall java 😞#2019-09-0515:45thhellermaybe try debugging with lsof or so to see who has all those open files#2019-09-0515:46kennyThe output of that command is so massive. Any idea what to look for?#2019-09-0515:46thhellerbeen a while since I've done that. can't really remember all the details#2019-09-0515:47kennyIt's a 50+ mb file so pretty overwhelming 😵#2019-09-0515:47thhellerlsof | grep .cljs maybe#2019-09-0515:47thhellersee if there are other processes with those files still open#2019-09-0515:47kennyIt only ever happens with shadow-cljs. There's gotta be a shadow process still running somewhere.#2019-09-0515:48thhellerwell depending on the size of your build it has to open a lot of files 😛#2019-09-0515:49kennyYeah... There can't be more than 60 namespaces. Guessing it's the node_modules that is the issue.#2019-09-0515:49thhelleryeah thats easily thousands of files 😛#2019-09-0515:51kennyIntelliJ was the only thing holding onto .cljs things and that was just a few maven deps. e.g. /home/kenny/.m2/repository/rewrite-cljs/rewrite-cljs/0.4.4/rewrite-cljs-0.4.4.jar#2019-09-0515:51kennyI start shadow-cljs with npx. Perhaps that is hiding the actual process somehow?#2019-09-0515:52thhellernot really hiding. it starts a node process, that starts the actual java process#2019-09-0515:52kennyI would've expected killall java to have worked then#2019-09-0515:52thhellerwell are there any left? 😛#2019-09-0515:53thhellerit should certainly kill shadow-cljs yes#2019-09-0515:53kenny
killall java
java: no process found
#2019-09-0515:57kennyStill a mystery. Just going to restart so I can get work done again 🙂#2019-09-0515:57thhellerdunno. something must have all those files open 😛#2019-09-0515:57thhellerdon't restart#2019-09-0515:58thhellerotherwise the issue is gone again and no chance to debug further#2019-09-0515:58thhellerps aux | sed 1d | awk '{print "fd_count=$(lsof -p " $2 " | wc -l) && echo " $2 " $fd_count"}' | xargs -I {} bash -c {}#2019-09-0515:58thhellerhttps://stackoverflow.com/questions/21752067/counting-open-files-per-process#2019-09-0516:00thheller
find -maxdepth 1 -type d -name '[0-9]*' \
     -exec bash -c "ls {}/fd/ | wc -l | tr '\n' ' '" \; \
     -printf "fds (PID = %P), command: " \
     -exec bash -c "tr '\0' ' ' < {}/cmdline" \; \
     -exec echo \; | sort -rn | head
seems nicer 😛
#2019-09-0516:03kennyToo late 😬 I'm sure I can reproduce it if needed. I usually only start shadow-cljs once per day. Today I restarted it a few times because I was updating deps.#2019-09-0516:03thhelleryeah check the next time when you run into it#2019-09-0516:04kennyI did see that SO post and tried a few of the commands in it. I don't think they gave me anything obviously wrong. Though, on one of them, it wasn't clear what the columns it was outputting meant.#2019-09-0516:05kennyOh, now this is interesting. First time running after a restart and I got it. The only thing I've changes is my deps.#2019-09-0516:06kennyThat find command returns nothing.#2019-09-0516:07kennyThe ps is the one that outputs two columns. Any idea what the columns mean? First one is, maybe, pid and second is open files?#2019-09-0516:07thhelleryes exactly#2019-09-0516:08nateHello, does dynamic module loading work with multimethods ?#2019-09-0516:08thheller@nisehl depends on what you mean by that?#2019-09-0516:09thhellerloading modules dynamically will add their defmethod definitions yes#2019-09-0516:10nateah that was what I meant, if I have a defmethod defined in a module that I chose to lazy load later, doesn't seem to be registred here, but i'll investigate and let you know, might be something else causing the issue#2019-09-0516:11nate(in the case of defmulti being defined in core and defmethod in a lazy loadable module)#2019-09-0516:11thheller@nisehl remember that the load is async so if you trigger the load and immediately call the defmulti then the code will not have loaded yet#2019-09-0516:12nateI do check if ready? before making calls#2019-09-0516:12thhellerand is it ready?#2019-09-0516:13thhellerjs/console.log is your friend 😉#2019-09-0516:14nateI'm using shadow.lazy/ready? and shadow.lazy/load, is it async for every function ?#2019-09-0516:16nateI'm defining a specific noop fn called init in my separate modules, I call it using lazy/load and once it's lazy/ready?, I consider all parts of the said module as ready, am I doing it wrong ?#2019-09-0516:16thhellerready? is not async. load is#2019-09-0516:17thhellerdepends. how do you load lazy/load?#2019-09-0516:17nate(lazy/load (lazy/loadable mynamespace.mymodule/init))#2019-09-0516:18thhellerthat only triggers the load but does not wait for it#2019-09-0516:19thheller(-> (lazy/load (lazy/loadable mynamespace.mymodule/init)) (.then (fn [init-fn] the-defmethod-is-ready-now))#2019-09-0516:19nateyes I didn't past all the code but along the chain, in .then() is all the module to be considered loaded ?#2019-09-0516:19thhelleryes#2019-09-0516:19nateoh cool#2019-09-0516:19natethanks !#2019-09-0516:22ShaneLesterAnyone have a sort of autoformatter-on-save set up to work with shadow before I hack one together myself?#2019-09-0516:24thhellerseems like something your editor should do? 😛#2019-09-0516:24ShaneLesteryeah. true. I kinda want to do it this way so that I force other people working on my project to format in the same way. haha.#2019-09-0516:24ShaneLester(we all use diff editors)#2019-09-0516:26kennyHmm. So I recently switched to PopOS, which is a flavor of Ubuntu. I think this may have reset my ulimit file limit.
ulimit -n
4096
cat /proc/sys/fs/file-max
1000000
Still getting the too many open files exception...
#2019-09-0516:27thhelleryes but who has those files open?#2019-09-0516:27thheller4096 is easy to reach when using a couple npm packages#2019-09-0516:28kennyI can't figure out a way to get it to go any higher. I've tried 5 different methods and none of them let me set it higher.#2019-09-0516:30kennyI've set the limits in /etc/security/limits.conf to 500000. I've set /etc/sysctl.conf fs.file-max to 1000000.#2019-09-0516:35thhellerthat goes far beyond my linux knowledge 😛#2019-09-0516:35David PhamIs it prohibited to have lein and shadow-cljs in the same project? Some nice facilities are built only with lein.#2019-09-0516:35thhellerno why would it be?#2019-09-0516:36thhelleryou can run them separately, make shadow-cljs use lein or run shadow-cljs embedded in your lein process#2019-09-0516:36thhellerall fine#2019-09-0516:38kennySame... It's mind boggling how difficult this is.#2019-09-0516:43David Pham@thheller thanks a lot for your answer!#2019-09-0516:55kennyThis is super weird:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4d26282323340d3d223d60223e"}, :content ("[email protected]")}
#2019-09-0520:22kennyI updated to PopOS 19.04 and it solved the issue. Very strange. Happy to be able to get some real work done now 🙂#2019-09-0522:27knubieHas anyone run into the issue where localhost:8021 (tests) always displays shadow-cljs - Stale Client! You are not using the latest compilation output!?#2019-09-0522:44thheller@steedman87 either your server is caching or you changed the output files but didn't update the html accordingly#2019-09-0612:28knubie@thheller thanks for the response, the issue was that I changed the :test-dir setting, but forgot to update the [:devtools :http-root] setting. 👍#2019-09-0601:11gerredanyone encounter this while making a build report?#2019-09-0601:11gerred"Could not locate shadow/cljs/build_report__init.class"#2019-09-0601:18gerredthink I ran into the problem 🙂#2019-09-0601:25gerredyep PEBKAC#2019-09-0613:30mccraigmccraigis it possible to connect a repl to a :node-test watch ? i'm guessing not, but it would be nice#2019-09-0613:31thhelleris node-repl not enough?#2019-09-0613:32thhellernode-test disables REPL and hot-code loading so it doesn't interfere with actually running tests#2019-09-0613:34mccraigmccraigwhat i actually wanted was hot-code loading in the node-repl#2019-09-0613:37mccraigmccraigi want a nice workflow for writing cljs tests - ideally combining repl exploration alongside clojurescript.test execution#2019-09-0613:38thhellerthat is probably all possible already. if you describe what a want a bit more I can tell you how to set it up#2019-09-0613:40mccraigmccraigsure - i've got a bunch of .cljc/cljs tests which i'm running with a shadow-cljs watch <node-test-target> - i'd like to be able to do repl exploration with hot-code-loading on the same code the tests are exercising#2019-09-0613:40mccraigmccraigi can do shadow-cljs node-repl for exploration, but there's no reloading afaics#2019-09-0613:42thhellerso you are using :autorun I presume? for the node-test build?#2019-09-0613:43thhellerthe issue with :node-test is that it is supposed to exit the process once it has run all tests#2019-09-0613:43mccraigmccraigyes - https://gist.github.com/42fc375d0374117de3e8d55fda88feee#2019-09-0613:43thhellerI'm not going to change that part#2019-09-0613:43mccraigmccraigyep, i figured that was why i couldn't run a repl against that target#2019-09-0613:44mccraigmccraigi'm not attached to doing it any particular way though... i just want to be able to combine repl exploration with running tests#2019-09-0613:44thhellerit is technically possible to enable the hot-reload for node-repl but it is not currently accessible in a nice way#2019-09-0613:44thhellerwell you can just run the tests from the REPL?#2019-09-0613:45thhellerjust call (cljs.test/run-all-tests) or so#2019-09-0613:45mccraigmccraigbut can i get hot-reload in the node-repl, so i can iterate ?#2019-09-0613:46thhellerwell .. the problem is that it won't do anything useful#2019-09-0613:46thhelleryou are better off using the REPL to reload the files#2019-09-0613:47mccraigmccraigoh, can i (require ... :reload) in the repl ?#2019-09-0613:47thhellerload-file works a bit better so I'd use that#2019-09-0613:47thhellermost editors have a built-in function for that. dunno what you are using#2019-09-0613:48mccraigmccraigi'm using emacs, but i haven't been using CIDER for cljs stuff, 'cos i'm already using it for clj stuff, and running multiple CIDER sessions concurrently is painful#2019-09-0613:49thhellercider definitely has something for load-file#2019-09-0613:49mccraigmccraigyep, but i'm just using a terminal for cljs repl atm#2019-09-0613:49thhellerI gotta go, be back in an hour or so#2019-09-0613:49mccraigmccraignp, i'll play around with CIDER and see what i can get to work.. thanks @thheller#2019-09-0615:23mccraigmccraiggot it all working with CIDER and the node-repl @thheller - sadly CIDER doesn't integrate nicely with cljs.test (in the way it does with clojure.test) but the repl / reload workflow is great#2019-09-0616:09mccraigmccraigso i ended up starting a shadow server with : shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d refactor-nrepl:2.4.0 -d cider/cider-nrepl:0.21.2-SNAPSHOT node-repl then i could do M-x cider-connect-cljs and choose a shadow repl and node-repl build, and it works about 100x better than any cljs repl i ever used before#2019-09-0708:18jiangtsquestion: I have a codebase that I’d like to migrate to shadow. The codebase makes pretty extensive use of :libs, basically, a fair amount of code is written in Google Closure JS and consumed by cljs code. Does shadow have a story for consuming such js files? these JS files can be run through advanced compilation as well…#2019-09-0710:17thheller@jiangts just put them on the regular classpath. no need to configure them any further#2019-09-0710:18thhelleras long as they have goog.provide and goog.provide they should be found normally#2019-09-0713:15scknkkrerGuys, any documentation about using JSX files directly with Clojurescript project via shadow-cljs ?#2019-09-0713:16scknkkrerI found it! https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects Thanks @thheller!#2019-09-0713:41gerredoh that's handy#2019-09-0715:59scknkkrerWhen I wanted to use Babel transpiled js files with my shadow-cljs project. I’ve seen this error. I fetch the shadow-examples from git. But, same is at the {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0c6e6d6e69604c69746d617c6069"}, :content ("[email protected]")}. TypeError: undefined is not an object (evaluating 'module$node_modules$react$index.default.createElement')#2019-09-0715:59scknkkrer*`babel` example.#2019-09-0716:00scknkkrerAny solution ?#2019-09-0808:13David PhamDid you check your node modules?#2019-09-0905:35AklsccHey, I'm sorry to bother you. I'm curious whether it is necessary to write the properties and functions for all objects in app.txt, which refer to: https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs Actually, if it dosen't afford, some warning appear. But it seems that it will not affect the compile result. It's a compile mechanism, but I also want to get some solutions about it. It's too trouble to add them manually.#2019-09-0906:20thheller@180338742 try using https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-09-0906:20thhellerbut what is the problem? are you sure it is externs related?#2019-09-0906:31Aklscc@thheller Maybe a little related. I want to avoid the externs, which also the clojurescript official suggestion. And with app.txt also a kind of externs, is it?#2019-09-0910:12levitanong@thheller is there any way I can help bring about preamble support? This would be useful for conforming to licenses like MIT and Apache 2.0#2019-09-0910:13thheller@levitanong its already supported?#2019-09-0910:13thhellerwell, it could be better I suppose since pasting a license into your build config would suck#2019-09-0910:14thhellersee :prepend https://shadow-cljs.github.io/docs/UsersGuide.html#_modules#2019-09-0910:24levitanong@thheller oh! I looked at this: https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options. Perhaps a line could be added saying instead of preamble, use prepend?#2019-09-0910:25levitanongBut yes, pasting a license to my build config isn’t ideal 😛#2019-09-0910:27thhellerwell the intent is to use the CLJ api for emore complex things#2019-09-0910:28thheller(-> (shadow/get-build-config :your-build) (update-in [:modules :main] assoc :prepend (slurp "whatever.doc")) (shadow/release*))#2019-09-0910:28thhellerin a custom defn and invoked via shadow-cljs run your.build/fn#2019-09-0910:28levitanongOh that’s funky! Never thought to use it in that way#2019-09-0910:29levitanongThanks for the tip!#2019-09-0914:56aisamuHi! Applying the proposed change (`global-eval` -> js/eval on src/main/shadow/cljs/devtools/client/browser.cljs) seems to fix the CLJS REPL breakage on 2.8.52! I'm not sure whether that's good or bad news, though 🙂#2019-09-0916:03thheller@aisamu well it breaks the :browser builds again 😉 only fixes :npm-module#2019-09-0916:04thhellerI will find a proper way to fix that, just didn't think of anything good yet#2019-09-0916:04thhellerwant to avoid hacks 😉#2019-09-0916:09aisamuYup, tested only :npm-module! We can stick to 2.8.39 without issue 🙂#2019-09-0916:36gerred@thheller 👋 hey! does shadow-cljs support css-in-js in compilation, that is to say, turning all of the CSS modules into .css files?#2019-09-0917:11aisamuIIRC, no. We have css-in-js (via garden) and also regular clj tasks to accomplish the css file generation#2019-09-0918:17gerred:+1:#2019-09-0918:35thhellerno it does not. but you can use the same approach described here to compile your own .css -> .js and include the .js files https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2019-09-0918:36gerredthat makes sense. thank you!#2019-09-0918:18StefanHi! I’m trying to use https://github.com/yamill/react-native-orientation. I put this in my ns:
(ns app.core
  (:require [reagent.core :as r :refer [atom]]
            ["react-native" :as rn :refer [AppRegistry, Platform]]
            ["react-native-orientation" :default Orientation]))
I then try to use it: (js/console.log "Orientation:" Orientation), but it is undefined. In the verbose compile output, I see that it is being flushed (`<- Flush: shadow.js.shim.module$react_native_orientation.js (1 ms)`). What am I doing wrong? (I have infer-externs auto enabled)
#2019-09-0918:34thheller@stefan.van.den.oord try ["react-native-orientation" :as Orientation]#2019-09-0918:43Stefan@thheller Thanks, that worked. How could I have known this? I did follow the manual correctly I believe? (https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages)#2019-09-0918:44thhellersee the section about :default exports#2019-09-0918:44Stefan(Just trying to be more conscious of your time in the future 🙂 )#2019-09-0918:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-09-0918:46StefanRight. So can I propose to add that to that table? So in the cell with :default add: > or: (:require ["module-name" :as defaultExport]) if the module is a commonJS module#2019-09-0918:47Stefan(I’ll make a PR if you agree)#2019-09-0918:47StefanI can also add a (“see also”) link in the table to that section about default exports.#2019-09-0918:48thhellerhold off on that. I suspect there is going to be a few more changes in the future when more packages are actual ESM packages#2019-09-0918:50thhellerthings are gonna be ugly for a while#2019-09-0918:55StefanOk, no problem. Let me know if/how/when I can help you…#2019-09-0918:56Stefan(I already made the change locally, so I can easily make the PR 😉 )#2019-09-0918:35stefan@stefan.age#2019-09-0918:36thhelleroops. sorry.#2019-09-0919:39chadhsis there a way to include local javascript files rather than npm installed packages with shadow-cljs?#2019-09-0919:41chadhsi’ve got this kinda edge case where i can install the library i need and it’s dependency via npm, but shadow-cljs doesn’t like it, as the higher level library includes the other like this#2019-09-0919:41chadhs
const AuthenticationContext = require('expose-loader?AuthenticationContext!adal-angular')
#2019-09-0919:45chadhshere’s the error i get
[:app] Build failure:
The required JS dependency "expose?AuthenticationContext!adal-angular" is not available, it
 was required by "node_modules/nm-adal/index.js".                                         

Search in:
        src/project/node_modules
You probably need to run:
  npm install expose?AuthenticationContext!adal-angular

See: 
#2019-09-0920:13thhelleruhm no clue what that is 😛#2019-09-0920:13thhellerseems like it is expecting a dedicated build tool#2019-09-0923:53chadhsYeah think that’s a webpack thing#2019-09-1001:00iku000888Hi, I am trying to produce a docker image that contains the release build artifact in drone ci. While attempting to run shadow-cljs release I get the following. Any hints?
[:app] Compiling ...
Killed
The command '/bin/sh -c cd my-app; clojure -A:shadow release app' returned a non-zero code: 137
#2019-09-1001:00iku000888I can produce the docker image while on my laptop FWIW#2019-09-1004:04gerred137 is OOM typically#2019-09-1004:05gerredand likely drone ci is running docker in docker.#2019-09-1004:05gerredwhich does not run any sort of overlay, but rather a virtual FS that has exponential memory growth, which is fine, you just need to be aware of it#2019-09-1004:06gerredso a couple options @iku000888#2019-09-1004:06gerred1) you increase RAM if you can, especially while using DIND#2019-09-1004:06gerred2) use a daemonless image builder. there's a few out there - kaniko, buildah, jig (JVM), makisu (i'm partial to makisu) 3) mount the host's docker socket, which is not always viable on hosted services#2019-09-1004:09gerredthere's a few other tools there too#2019-09-1004:10gerredwe can discuss more in #devops #cloud-native if you'd like, this is my day to day fun 😄#2019-09-1004:31iku000888@gerred Thanks! This is really helpful. Will dig a little bit more.#2019-09-1008:21thheller@iku000888 you can cap the memory used by the JVM via :jvm-opts ["-Xmx1G"] in shadow-cljs.edn. if you need I could add other ways to add that so you don't need to put it into the config#2019-09-1008:21iku000888Oooh that is also something I did not look into#2019-09-1008:22iku000888Thanks, will look into that as well 😉#2019-09-1015:16Mandimby RaveloarinjakaHello, I would like to use debux (https://github.com/philoskim/debux) in my project but I was wondering how I can specify dependencies depending on the context (dev vs release).#2019-09-1015:17Mandimby RaveloarinjakaAs per the documentation, [philoskim/debux "0.5.6"] should be used in dev code and [philoskim/debux-stubs "0.5.6"] in production code#2019-09-1015:21Mandimby RaveloarinjakaFYI, for the moment, I ended up adding [philoskim/debux "0.5.6"] in my dependencies but I made sure to only use the provided macros in a repl/comment context so that the code never get required in the release#2019-09-1103:28Jon#2019-09-1103:28Jonhttps://web.dev/samesite-cookies-explained#2019-09-1103:28Jondoes it affect shadow-cljs' built in HTTP server?#2019-09-1114:28thhellerthe server already sets SameSite=strict?#2019-09-1716:49Jonin Chrome Canary. when it's not set, it defaults to Lax.#2019-09-1716:49JonChrome stable should be fine at current. But it will upgrade soon I think.#2019-09-1716:49Jonnot sure the time Chrome turn on it for all websites. I think that would affect quite some sites.#2019-09-1716:50Jonsorry I didn't see the notification earlier..#2019-09-1716:56thhellerthe cookie is already set so we should be fine#2019-09-1917:47Jonno waring now in 0.8.53. cool#2019-09-1103:29JonChrome Canary has this issue. Although it affects on cookies mostly. Just feel quite annoying#2019-09-1114:12gleisonsilvaHey guys! May you can help me... I'm not able to got a React component working with Shadow-cljs... I think it may something with the way I need to import... On the samples, the import is made that way:
import * as WebDataRocksReact from './webdatarocks.react';
The package, on NPM, is just "webdatarocks". I did the import this way:
["webdatarocks" :as wdr]
But when I try to use this component, I get an error "Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for"... In the component's doc, I should do
<WebDataRocksReact.Pivot />
In clojurescript I can't figure out how to instantiate... I've tried thinks like
[:> wdr/Pivot {}]
or
[:> wdr/WebDataRocksReact {}] 
None works...
#2019-09-1114:16gleisonsilvaI think this "." (dot) in import as well on component name is what troubles me...#2019-09-1114:30thheller@gleisonsilva try shadow-cljs browser-repl and then (require '["webdatarocks" :as wdr]) + (js/console.dir wdr)#2019-09-1114:30thhellerin the browser console you should see the object and inspect it further#2019-09-1114:31thhellerif there is a Pivot property then wdr/Pivot should work#2019-09-1114:36gleisonsilvaHey @thheller, there isn't...#2019-09-1114:37thhellerhmm thats just a function#2019-09-1114:37thhellerdo you maybe need to instantiate it?#2019-09-1114:38gleisonsilvathe docs don't tell that https://www.webdatarocks.com/doc/integration-with-react/ https://github.com/WebDataRocks/pivot-react/blob/master/src/App.js#2019-09-1114:39gleisonsilvaDo you have some suggestion on how can I instantiate it?#2019-09-1114:40thhelleryou need this file also https://github.com/WebDataRocks/pivot-react/blob/master/src/webdatarocks.react.js#2019-09-1114:40thhellerthis isn't in the npm package so I guess they expect you to write this yourself?#2019-09-1114:41thhellerprobably best to skip the JS version and just write it directly in reagent#2019-09-1114:42thheller
componentDidMount() {
			var config = {};
			config.container = ReactDOM.findDOMNode(this);
			this.parseProps(config);
			this.webdatarocks = new window.WebDataRocks(config);
		}
#2019-09-1114:42thhellerthis seems to be the relevant part#2019-09-1114:42gleisonsilvaRight. I'll try! Thk u very much!#2019-09-1114:48gleisonsilva@thheller looking through the code, I can see that the webdatarocks.js has the react parts#2019-09-1114:48gleisonsilvaThere is a way to import like in the example, like "webdatarocks.react"??#2019-09-1114:48thhelleryuck#2019-09-1114:49thhellerthe ./webdatarocks.react import is a local import#2019-09-1114:49thhellerit is not in the npm package#2019-09-1114:49thhellerbut it appears to export those to a global object if the global React exists#2019-09-1114:50thhellerwhich is bad practice. the package in general doesn't seem very high quality#2019-09-1114:51thhellerimport * as WebDataRocksReact from './webdatarocks.react'; is just importing ./webdatarocks.react.js relative to the App.js#2019-09-1114:52thhelleryou can maybe access js/WebDataRocksReact if there is a global js/React (which there normally isn't)#2019-09-1114:52gleisonsilvaGot it. I'll try the other way so...#2019-09-1114:52gleisonsilvaTks#2019-09-1305:46David PhamAnyone managed to connect shadow-cljs & Cider to the REBL?#2019-09-1310:06myguidingstarhow to import css with shadow-cljs? things like in plain js import "react-image-lightbox/style.css";#2019-09-1310:07thhellernot supported#2019-09-1310:10myguidingstarso is it possible to create a js file with the above content and include in the shadow-cljs build somehow?#2019-09-1310:11thhellerthat is a css file#2019-09-1310:11thhelleryou just build your css separately#2019-09-1310:11thhellerI usually use node-sass#2019-09-1310:12thhelleryou can just copy node_modules/react-image-lightbox/style.css into public/css/react-image-lightbox.css and include it via <link rel="stylesheet" href="/css/react-image-lightbox.css"> in your HTML#2019-09-1310:12thhellerhow much you want to automate that is up to you#2019-09-1310:13thhellershadow-cljs currently does not process CSS in any way#2019-09-1310:13myguidingstarI see. Thanks#2019-09-1313:45David Pham@thheller are you on GitHub sponsor?#2019-09-1313:46David PhamI am supporting you through patreon, but GitHub would match my donation for a year :)#2019-09-1315:40thheller@neo2551 not yet. I applied though.#2019-09-1316:20deadghostI'm trying to write/use a macro and am getting Use of undeclared Var myproject.views.home/*clojure. Looks like the kind of error where I'm missing something obvious (like maybe needing to require clojure somewhere)#2019-09-1316:44thheller@deadghost hard to tell without more info. is *clojure your macro?#2019-09-1316:45thhellerthe error is exactly that. something is trying to access myproject.views.home/*clojure and it doesn't exist. no more to that error than that.#2019-09-1317:31deadghostnope defcomponent#2019-09-1318:15thheller@deadghost well the *clojure must be coming from somewhere. If you want help you need to provide more code. it is impossible to guess what you are doing#2019-09-1319:12mokrHi, I’m new to shadow-cljs. Is there a way to get hot reloading of plain js files? Usecase: I usually write d3.js code in clojurescript, but I would like to try to write that part in plain js instead. My project is base on the Luminus template.#2019-09-1319:13thhellernot really. it works in some limited fashion but I wouldn't call it reliable#2019-09-1319:13mokrOK. How do I go about trying the limited variant?#2019-09-1319:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-09-1319:15thhellercode must be written in ESM style so import/export no require/module.exports#2019-09-1319:18mokrThanks, I skimmed that doc quickly earlier today, but I’ll read it more closely. I believe my use case is rather simple, so I’m optimistic. Thanks for the quick reply!#2019-09-1320:35Saikyunhello, playing around with expo + shadow-cljs. I'm currently using shadow-cljs cljs-repl in order to connect with a repl to the app running on my phone, this works well, which is fantastic! my only problem is that when adding new requires I have to run shadow-cljs compile, and then reload the app. this seems to disconnect shadow-cljs cljs-repl. I was wondering if there was a way to reconnect it? my computer is pretty slow, so it generally takes a while to restart everything#2019-09-1320:37Saikyun@mokr I remember doing something like deleteing modules I wanted to be reloaded in a function that runs whenever shadow-cljs recompiles. e.g. in such a function:
(defn start
  {:dev/after-load false}
  []
;; delete stuff here
)
maybe that can help? 🙂
#2019-09-1320:38SaikyunI think something like this: delete require.cache[require.resolve('./b.js')] 🙂#2019-09-1320:41Saikyunas always, great job thheller. I've managed to get opengl + cljs on mobile working thanks to your amazing tool 😄#2019-09-1320:53David PhamOpenGL inside expo?#2019-09-1321:26Saikyun@neo2551 yeah, using three and expo-gl.GLView 🙂#2019-09-1321:35thheller@saikyun I'm confused about what you said. you must have a shadow-cljs watch running for your build, so running compile is pointless?#2019-09-1321:35thhelleryou will however need to reload the react-native app#2019-09-1321:36thhellersince the requires are filled by exp/react-native and that cannot be done at the REPL#2019-09-1321:36thhelleryou only ever need to restart shadow-cljs when :dependencies change. no other restarts are ever required if you use shadow-cljs server#2019-09-1409:51Saikyun@thheller nah, I'm not running shadow-cljs watch, since that triggers webpack which takes a lot of cpu (and eventually restart the app)#2019-09-1409:51thhelleruhm you cant have a REPL without a running watch?#2019-09-1409:51SaikyunI run shadow-cljs compile once, then I run shadow-cljs cljs-repl in order to connect with a repl 🙂#2019-09-1409:52Saikyunwell, apparently I can :S#2019-09-1409:52thhellernot possible 😛#2019-09-1409:52Saikyunwell, I do it either way, I don't know what to say#2019-09-1409:53Saikyunwith only yarn start and shadow-cljs cljs-repl I manage to connect to a repl, and then run code on the mobile#2019-09-1409:53thhellerwell sorry should have been more clear. cljs-repl starts the watch if it is not running#2019-09-1409:53Saikyunoh, I see. 🙂#2019-09-1409:54Saikyunbut it doesn't automatically recompile either way#2019-09-1409:54thhelleryeah thats true#2019-09-1409:54thhellerbut still. if you run shadow-cljs server separately#2019-09-1409:54thhelleryou can restart cljs-repl quickly without it taking a long time#2019-09-1409:55Saikyunoh, that's a great step! thanks a lot#2019-09-1409:55SaikyunI didn't realise you could only run the server.#2019-09-1409:55SaikyunI've generally just used watch, but since I don't want the automatic recompiles atm I sadly have to turn it off#2019-09-1409:55Saikyunthanks for the help either way, this will speed things up a lot!#2019-09-1409:56Saikyunsadly I can't afford a new computer, and when the repl is actually set up it's very quick either way 🙂 so it was just restarting that was bothersome#2019-09-1409:56thhellerthere might still be weird things happening in that setup. it isn't really intended to be used that way 🙂
#2019-09-1409:56thhellerbut yeah when in doubt use the web UI at http://localhost:9630#2019-09-1409:57thhellerthat lets you restart the build without restarting the server and so on#2019-09-1409:57Saikyunah thanks. I haven't used the web ui#2019-09-1409:58Saikyungenerally the setup works okay at least 🙂 as you've said I need to compile and restart when I add new requires, but other than that it works well 🙂#2019-09-1409:58SaikyunI hope to be able to shut down webpacks autocompile sometime, but I've already spent 2-3 hours in vain#2019-09-1409:58thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#dont-forget-about-the-repl#2019-09-1409:58Saikyunhaven't really gotten any replies when inquiring at their forum/slack#2019-09-1409:59thhellersee the section about the REPL lower down#2019-09-1409:59Saikyunohhh#2019-09-1409:59Saikyunthat's amazing#2019-09-1409:59Saikyunwow, shadow-cljs is so full of good stuff, haha#2019-09-1409:59Saikyunthanks for taking the time to help me#2019-09-1410:00SaikyunI hope to make some sort of example repo when I have a "stable" setup, so this stuff will help as well#2019-09-1410:04Saikyunokay, so this is really awesome. using (shadow.cljs.devtools.api/watch :app {:autobuild false}) in a shadow-cljs clj-repl, I don't have to restart any repl processes. my repl connection starts saying No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code., but as soon as the app has finished restarting it works again 🙂#2019-09-1410:04Saikyunthanks a lot for your help!#2019-09-1410:23Saikyunhm, or maybe I did have to restart. oh well#2019-09-1410:25Saikyunthe shadow-cljs server process started giving me:
[2019-09-14 12:24:48.771 - WARNING] :shadow.cljs.devtools.errors/format-error
SocketException Broken pipe
#2019-09-1410:26thhellerneed more context. that doesn't mean much and wouldn't require a restart#2019-09-1411:43Saikyunsorry, I'm not sure what caused it to happen, so that's why I didn't write more. I'll come back when I can reproduce it. good to know that it shouldn't require a restart#2019-09-1412:29Saikyunit happened again. what I did was run (shadow.cljs.devtools.api/watch-compile! :app), then kill the app then start it again. when I do that it seems like the cljs-repl still thinks it's connected (when I try to eval things, I get Timeout while waiting for REPL result.). I could solve this by stopping the watch (using stop-watch) then starting it again.#2019-09-1412:45thhelleryou do react-native right? that has a known problem in that it doesn't disconnect websocket connections when the app is reloaded#2019-09-1412:58Saikyunyeah, react-native. ah, that makes sense then.#2019-09-1412:58Saikyunusing stop-worker (not stop-watch) works though, so no biggie 🙂 still don't need to restart#2019-09-1412:59joshkhsilly question i'm sure, but does shadow-cljs require clojure, or can it compile clojurescript using just node and the shadow-cljs package?#2019-09-1412:59thhellerit is written in clojure and requires a JVM#2019-09-1413:00thhellerso no#2019-09-1413:00joshkhthat's what i thought. thanks 🙂#2019-09-1413:02joshkhi'm attempting to stitch together a heroku buildpack to compile a webapp using shadow-cljs without having to build a runnable uberjar. potentially just serving the compiled js via express. have you come across a project like that before?#2019-09-1413:03thhellernot really sure how a "runnable uberjar" factors into CLJS?#2019-09-1413:03thhelleryou mean a CLJ webserver?#2019-09-1413:03joshkhit's more of a heroku factor and how it handles clojure projects by default#2019-09-1413:04joshkh(and lein)#2019-09-1413:04thhelleryou just need java#2019-09-1413:05joshkhbut yes, a web server of some sort is needed of course#2019-09-1413:06thhelleryou could do that in node via express or something yes#2019-09-1420:23dazldnothing urgent, but wondering if there’s a way to change the colours of the shadow console messages?#2019-09-1507:58thhellerthere is not but if you open an issue I can add an option for that eventually 🙂#2019-09-1509:01dazldhttps://github.com/thheller/shadow-cljs/issues/559#2019-09-1420:23dazldthey’re a little hard to read on a dark dev tools background#2019-09-1507:27alexandergunnarsonHey! Any idea what might be causing a random WebSocket disconnection on load?#2019-09-1507:27alexandergunnarson#2019-09-1507:27alexandergunnarsonNot immediately apparent from a Google search#2019-09-1507:27alexandergunnarsonMy main namespace is really small and my config isn’t too complex
(ns deft.client.search)

(defn ^:export -main [& args]
  (enable-console-print!)
  (println "Hello shadows!"))

(defn reload! [& args]
  (println "reloaded!"))
#2019-09-1507:28alexandergunnarson#2019-09-1507:28alexandergunnarsonThis is the only output from the server
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.52 running at 
shadow-cljs - nREPL server started on port 50145
shadow-cljs - watching build :local/client.search
[:local/client.search] Configuring build.
[:local/client.search] Compiling ...
[:local/client.search] Build completed. (157 files, 1 compiled, 0 warnings, 3.00s)
#2019-09-1507:59thheller@alexandergunnarson uhm only guess I have is that build ids must be simple keywords? (ie. no namespace)#2019-09-1614:44alexandergunnarsonBy the way your intuition was right — works now. Thanks so much!#2019-09-1507:59thhellerthat should really be validated better I guess 😛#2019-09-1508:00thhellersurprised it works at all to be honest#2019-09-1515:08alexandergunnarsonHaha nice, okay! I will fix that! Thanks 🙂#2019-09-1610:50flowthingHow do I use jQuery UI with shadow-cljs? jQuery works fine if I just do npm install --save jquery and then (:require ["jquery" :as jq]) and (jq "#foo"), but I can't figure out how to bring jQuery UI into the picture so that I can its methods.#2019-09-1610:51thhellerwell what did you try? or what example are you using?#2019-09-1610:52flowthingI couldn't find any examples. If you can point me to any, much appreciated. I tried (:require ["jquery-ui"]) and (require ["jquery-ui" :as jqu]) and then (.tooltip (jqu "#foo")).#2019-09-1610:53thhelleris jquery-ui even on npm?#2019-09-1610:53thhellerI guess it is#2019-09-1610:53flowthingYep.#2019-09-1610:54thhellersince it modifies the jquery object you probably use (:require ["jquery" :as jq] ["jquery-ui"])) and then use jq with tooltip and such#2019-09-1610:54thhellerat least that is how jquery worked without npm 😉#2019-09-1610:55thhellerbeen a while since I used it#2019-09-1610:56flowthingYeah, I tried that, but it doesn't work. (I get (intermediate value)(intermediate value)(...).tooltip is not a function). Well, I'll keep looking into it. This is a step in migrating an app away from using jQuery UI, so another option is just to bite the bullet and rewrite the code not to use jQuery UI.#2019-09-1611:02thhellerhmm how did you use it previously?#2019-09-1611:03thhelleryou can just include it separately in the page if needed#2019-09-1611:03flowthingYeah, true, that's one option.#2019-09-1611:05thhelleras far as I can tell there are separate js files per "widget" though#2019-09-1611:06thhellerthe the entire jquery-ui package isn't really using commonjs#2019-09-1611:07flowthingRight, seems like it. I'll need to see which NPM packages I actually need to require.#2019-09-1611:07thheller(:require ["jquery" :as jq] ["jquery-ui"] ["jquery-ui/ui/widgets/tooltip"])) might work#2019-09-1611:08thhellerit is all separate .js files working on a global jQuery object#2019-09-1611:09thhellerbut might be a hassle to include all the dependencies in the right order#2019-09-1611:10thhellerI would recommend just building what you need separately on their webpack and including the entire file in its own script tag#2019-09-1611:11flowthingYes, looks like that might be the best option. ["jquery-ui/ui/widgets/tooltip"] works, but as you said, would need to figure out which dependencies to require as well.#2019-09-1611:11flowthingMany thanks for the help!#2019-09-1612:48MaksymDoes anyone have example of how to use "react-navigation-stack" in shadow-cljs? I can't pass one error:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object>

This error is located at:
 in RTCView (at View.js:45)
 in View (at AppContainer.js:98)
...
My code in app.cljs is:
(ns 
  (:require
   ["expo" :as ex]
   ["react-native" :as rn]
   ["react" :as react]
   [reagent.core :as r]
   [re-frame.core :as rf]
   [example.events]
   [example.subs]
   ["react-navigation-stack" :as ReactNavigationStack]))

(def text (r/adapt-react-class (.-Text rn)))
(def view (r/adapt-react-class (.-View rn)))
(def app-registry (.-AppRegistry rn))

(def styles
  ^js (-> {:container
           {:flex 1
            :backgroundColor "#fff"
            :alignItems "center"
            :justifyContent "center"}
           :label
           {:fontWeight "normal"
            :fontSize 15
            :color "blue"}}
          (clj->js)
          (rn/StyleSheet.create)))


(defn app []
  (r/create-class
   {:reagent-render
    (fn [props]
      [view {:style  (.-container styles)}
       [text {:style (.-label styles)} "Home page"]
       ])
    }))

(def routes {:Home         {:screen            (r/reactify-component app)}})
(defn app-root []
  ; [c/view {:style  (.-container styles)}
   [(r/adapt-react-class ((.-createStackNavigator ReactNavigationStack)
                          (clj->js routes)
                          (clj->js {:initialRouteName "Home"})))])
   
(defn init []
  (rf/dispatch-sync [:initialize-db])
  (.registerComponent app-registry "main" app-root)
  )
#2019-09-1612:50thheller
(defn app-root []
  ; [c/view {:style  (.-container styles)}
   [(r/adapt-react-class ((.-createStackNavigator ReactNavigationStack)
                          (clj->js routes)
                          (clj->js {:initialRouteName "Home"})))])
#2019-09-1612:52thhellerthis seems kinda weird. you likely shouldn't recreate that stack on every render?#2019-09-1612:55Maksymyeah you right but in first place I would like to see this code working#2019-09-1612:58thhellersorry I don't know much about react-native or react-anvigation but it looks like you are missing the createAppContainer call maybe? https://github.com/react-navigation/stack/blob/master/example/App.js#L141-L161#2019-09-1613:00MaksymI'm not sure if I need it, let me try your code#2019-09-1612:57thheller
(ns 
  (:require
    ["expo" :as ex]
    ["react-native" :as rn]
    ["react" :as react]
    [reagent.core :as r]
    [re-frame.core :as rf]
    [example.events]
    [example.subs]
    ["react-navigation-stack" :as ReactNavigationStack]))

(def styles
  ^js (-> {:container
           {:flex 1
            :backgroundColor "#fff"
            :alignItems "center"
            :justifyContent "center"}
           :label
           {:fontWeight "normal"
            :fontSize 15
            :color "blue"}}
          (clj->js)
          (rn/StyleSheet.create)))

(defn app []
  [:> rn/View {:style (.-container styles)}
   [:> rn/Text {:style (.-label styles)} "Home page"]])

(def routes {:Home {:screen (r/reactify-component app)}})

(defonce nav-stack
  (ReactNavigationStack/createStackNavigator
    (clj->js routes)
    #js {:initialRouteName "Home"}))

(defn app-root []
  [:> nav-stack {}])

(defn init []
  (rf/dispatch-sync [:initialize-db])
  (rn/AppRegistry.registerComponent "main" app-root))
#2019-09-1612:57thhellermaybe like this? won't play nice with hot-reload though#2019-09-1613:02Maksymit's giving same error sorry 😞#2019-09-1613:07thhellerthen you might need to rest of the code from that example app?#2019-09-1613:36MaksymI almost burned my kitchen while I was working on this xd I'm going to create sample project and I will send link here#2019-09-1614:25MaksymHere I have a repo with simple use of react-navigation-stack, clone it to reproduce my error. After cloning you will need to run yarn install then shadow-cljs watch app and after project compiles in second terminal run yarn start. @thheller can you take a look, please?#2019-09-1614:26thhellerlink?#2019-09-1614:27Maksymhttps://github.com/Kruszylo/rn-rf-shadow (sorry 😄 )#2019-09-1614:30thhellerand which JS example are you working off?#2019-09-1614:32thhellerI don't do react-native development so somebody else can probably provide more help#2019-09-1614:32thhellerI can help you translate a JS example but thats about it#2019-09-1614:35MaksymI used the source code of another clojurescript project#2019-09-1614:35thhellerJS example of react-navigation-stack#2019-09-1614:36MaksymI don't have it I built my code after I read source code of another project which uses react-navigation#2019-09-1614:37thhellerreact-navigation or react-navigation-stack?#2019-09-1614:37thhellerI have no clue what either of those are btw#2019-09-1614:38Maksymreact-navigation, I use react-navigation-stack because they made updates and moved some code to react-navigation-stack#2019-09-1614:39MaksymOkay, np thank you Thomas I appreciate your interest 😄#2019-09-1614:41MaksymDoes anyone else can help me? I still have this error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Repo to reproduce: https://github.com/Kruszylo/rn-rf-shadow#2019-09-1614:41thhellerlook at the explanation of that error#2019-09-1614:41thhellerit means that you are trying to render something that isn't a react element#2019-09-1614:42thhellerI suspect that it is the result of createStackNavigator, which probably isn't a react component#2019-09-1614:49MaksymI tried to wrap it with r/reactify-component:
(defonce nav-stack
  (r/reactify-component (ReactNavigationStack/createStackNavigator
   (clj->js routes)
   #js {:initialRouteName "Home"}))) 
did not help
#2019-09-1614:53thhelleryou are trying the wrong thing#2019-09-1614:54thhelleryou can't just turn something that isn't a react component into one#2019-09-1614:54thhellersee this https://github.com/react-navigation/stack/blob/master/example/App.js#L161#2019-09-1614:54thhellerthey are passing the result of createStackNavigator to createAppContainer#2019-09-1614:54thhellerand that in turn is used in the AppRegistry.registrComponent call#2019-09-1614:55thhelleryou are missing all of that#2019-09-1615:04David Pham@titov if you want to use react navigation with re-frame, here are a small discussion #2019-09-1615:04David Phamhttps://github.com/seantempesta/cljs-react-navigation/issues/13#2019-09-1615:05David PhamThe trick is to create a native dispatcher and an effect and call it whenever you switch panel.#2019-09-1615:05David PhamSimilar to the advice in react navigation.#2019-09-1615:25arohnerI’m trying to convert a project over to shadow-cljs from cljsbuild/figwheel. I’m seeing
[:frontend] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
. I have react in my package.json. How should I deal with reagent requiring cljsjs/react?
#2019-09-1615:25MaksymThank you guys, I fixed my error with your advices and source code of https://github.com/matthiasn/meins I have simple example of usage react-navigation-stack.#2019-09-1615:26thheller@arohner npm install react?#2019-09-1615:27thhellerI mean did you actually install it? just adding to package.json doesn't do anything#2019-09-1615:27arohnerderp. I was assuming shadow-cljs would implicitly resolve dependencies#2019-09-1615:28thhellernah installing is done via npm#2019-09-1616:33metehan
`shadow-cljs - starting via "clojure"
Executable 'clojure' not found on system path.
D:\Dev\Spill\spill_reactnative
λ  [master ≡]clojure
Clojure 1.10.1
user=>
#2019-09-1616:34metehanwhen i write "clojure" clojure runs but shadow-cljs says i don't have it in my system path#2019-09-1616:35thheller@m373h4n you might have an older version without the powershell support?#2019-09-1616:35thhellerassuming you have the "official" tools.deps powershell version?#2019-09-1616:35thhellerwhich shadow-cljs version? you omitted that line 😉#2019-09-1616:36metehanshadow-cljs - config: ...\shadow-cljs.edn cli version: 2.8.39 node: v10.16.0 🙂#2019-09-1616:37thhelleryeah upgrade. I think I added support for that arround .43 or so#2019-09-1616:38metehanthank you i'll do it now 🙂#2019-09-1616:39alexandergunnarsonHey! quick question — how should I handle Java paths? I have Java files and shadow-cljs appears to not be compiling them#2019-09-1616:40thhellernot supported. this is a CLJS build tool. no support for java.#2019-09-1616:40alexandergunnarsonYes, I mean it supports building CLJ of course so I figured I’d ask 🙂#2019-09-1616:40alexandergunnarsonAny way to add to the classpath?#2019-09-1616:40thhellerdoesn\'t support building CLJ#2019-09-1616:40alexandergunnarsonThought it built macro files#2019-09-1616:41thhellerit runs clojure but thats about it#2019-09-1616:41thhellerno building involved with CLJ#2019-09-1616:42alexandergunnarsonBy building I mean compiling and using macros, not creating/deploying artifacts#2019-09-1616:42alexandergunnarsonI think we’re on the same page though#2019-09-1616:43alexandergunnarsonSo is there a way to add to the classpath (where pre-compiled Java classes are)? Or do I need to e.g. deploy a local snapshot jar with the compiled Java files and add to the dependencies in shadow-cljs.edn?#2019-09-1616:44thhellerjust add it as a source path#2019-09-1616:44thheller:source-paths ["target/classes" ...]#2019-09-1616:44alexandergunnarsonGot it#2019-09-1616:45alexandergunnarsonThanks!#2019-09-1616:45thhellerI recommend using lein for the CLJ parts though#2019-09-1616:51alexandergunnarsonYeah I’m doing the equivalent of that#2019-09-1616:51alexandergunnarsonWorking great now! Really impressive tool you’ve made 🙂#2019-09-1618:21alexandergunnarsonHey, so, suddenly I’m seeing this error after quitting the shadow-cljs server and restarting the build:
:clj : loading namespace deft.untyped.logic
:clj : loading namespace deft.untyped.fn
:clj : loading namespace deft.untyped.error
[:local.client.search] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/alexandergunnarson/Creating/Code/deft/src/all/deft/untyped/error.cljc
Exception: No namespace: deft.untyped.error found
        clojure.core/the-ns (core.clj:4162)
        clojure.core/ns-publics (core.clj:4189)
        clojure.core/ns-publics (core.clj:4189)
        shadow.build.macros/find-macros-in-ns (macros.clj:63)
However "src/all" is included in the shadow-cljs.edn’s :source-paths. One thing I thought might be the issue is this:
(ns deft.untyped.error
...
#?(:cljs (:require-macros
           [deft.untyped.error :as self])))
However, this namespace uses the same paradigm, and is already loaded prior to the error ns:
(ns deft.untyped.logic
...
#?(:cljs (:require-macros
           [deft.untyped.logic])))
#2019-09-1618:21alexandergunnarsonPrior to quitting the server and restarting the build, this namespace compiled just fine#2019-09-1618:22alexandergunnarsonIf I connect via nREPL to shadow-cljs, (require 'deft.untyped.error) works just fine#2019-09-1618:22thheller
:clj : loading namespace deft.untyped.logic
:clj : loading namespace deft.untyped.fn
:clj : loading namespace deft.untyped.error
#2019-09-1618:23thhellerwhat are those?#2019-09-1618:23alexandergunnarsonLogs I’ve added just after namespace declarations#2019-09-1618:23alexandergunnarsonSo like
(ns <whatever> ...) 

(log-that-stuff) 

...
#2019-09-1618:24thhellershadow-cljs clj-repl and (require 'deft.untyped.error) works?#2019-09-1618:24thhellerno nrepl please#2019-09-1618:24alexandergunnarsonI tried just the nREPL; let me try that ^^^#2019-09-1618:24thhellerjust removing variables#2019-09-1618:24alexandergunnarsonYes#2019-09-1618:24alexandergunnarsonWorks#2019-09-1618:24thhellerand (find-ns 'deft.untyped.error)#2019-09-1618:24alexandergunnarsonWell#2019-09-1618:24alexandergunnarsonYeah I was about to say — that doesn’t work#2019-09-1618:25alexandergunnarsonLet me try load-file#2019-09-1618:26alexandergunnarsonAhh there you go
[2:0]~shadow.user=> (load-file "/Users/alexandergunnarson/Creating/Code/deft/src/all/deft/untyped/error.cljc")
Syntax error (ClassNotFoundException) compiling at (src/all/deft/untyped/error.cljc:77:1).

deft.Error
I think I cleared out the Java stuff without recompiling it when I deleted the target directory. The logs didn’t allude to a class not being found
#2019-09-1618:26alexandergunnarsonAnyway sorry to bother you!#2019-09-1618:26thhellerweird. that error should have been visible somewhere#2019-09-1618:27alexandergunnarsonYeah I’ve seen the ClassNotFoundException show up before in shadow-cljs, but not this time for whatever reason#2019-09-1619:47Ivan FedorovIs there a rule of a thumb to understand when live reload is gonna to reload the page and when it can do hot update? My app grew and now it’s a reload every time#2019-09-1619:49thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2019-09-1619:49thhellerit is NEVER gonna reload the page#2019-09-1619:50thhellerthat is something your code is doing if that is happening#2019-09-1619:51Ivan FedorovCool, thanks for the fast response!#2019-09-1707:51Aleh AtsmanCan somebody provide me with example how can I create simple node-script project and start repl sesstion so that I can connect from nvim to it?#2019-09-1707:56thhellernpx create-cljs-project foo then cd foo npx shadow-cljs node-repl#2019-09-1707:56thhellerdunno about nvim though#2019-09-1707:57Aleh AtsmanYes that’s exactly what I did#2019-09-1707:58Aleh Atsmanwhen I try to execute some form in nvim i get Fireplace: no default ClojureScript REPL#2019-09-1707:58Aleh AtsmanI tried to call :Piggieback :app but no results#2019-09-1707:59thhellerdid you connect to the shadow-cljs server?#2019-09-1707:59Aleh Atsmanvia :Connect#2019-09-1707:59Aleh Atsman?#2019-09-1707:59Aleh Atsmanyes#2019-09-1707:59thhellerno clue. I have never used vim-fireplace#2019-09-1707:59thhellerIf you are starting nREPL some other way, run :FireplaceConnect host:port.#2019-09-1708:00Aleh Atsmanyes#2019-09-1708:00Aleh Atsmanit is connected to nrepl#2019-09-1708:13thhellerdunno. if you used shadow-cljs node-repl you'd do :Piggieback :node-repl#2019-09-1708:23Aleh AtsmanTried that too, doesn’t work, can’t execute anything from within the nvim#2019-09-1708:24Aleh AtsmanDo I need to add what ever special to config, like dependency, ports, whatever. Or should it work just out of the box ?#2019-09-1708:24thhellerdepends. how did you connect? do you use lein/deps.edn?#2019-09-1708:25Aleh AtsmanI created project using npx create-cljs-project hello-node#2019-09-1708:25Aleh Atsmancreated one cljs file#2019-09-1708:26thhellerand how did you connect? the default random port printed on startup?#2019-09-1708:26Aleh Atsmanyes it is connected for sure#2019-09-1708:26Aleh AtsmanI did manually typed host:port#2019-09-1708:26thhellerI don't know. if I look at this error you might not have provided enough args? https://github.com/tpope/vim-fireplace/blob/master/autoload/fireplace.vim#L512#2019-09-1708:30thhellermaybe try :Piggieback (cider.piggieback/cljs-repl :node-repl)?#2019-09-1708:30thhellercan't quite decipher what the vim script is doing#2019-09-1708:30Aleh AtsmanOk I started shadow-cljs node-repl, Connected, Runned Piggieback :node-repl and tried to run Eval (+ 1 1) and got Fireplace: session closed#2019-09-1708:30Aleh AtsmanThe same with :Piggieback (cider.piggieback/cljs-repl :node-repl)#2019-09-1708:31thhellerno clue what that means#2019-09-1708:34Aleh AtsmanI don’t see nvim section in Editor Section in docs, maybe it is not supposed to work at all#2019-09-1708:38thhellerseveral people use it and it is definitely supported#2019-09-1708:38thhellerI just don't know anything about it so I can't add it to the docs#2019-09-1708:45Aleh AtsmanI definitely connected to nrepl, I can execute clj, but not cljs#2019-09-1708:48thhellerno clue how to debug the fireplace side sorry. does it have a log of some kind?#2019-09-1708:50Aleh Atsmanok, finally#2019-09-1708:50Aleh AtsmanCljEval (shadow/repl :node-repl)#2019-09-1708:50Aleh AtsmanAnd it works now#2019-09-1708:50Aleh Atsman🚀#2019-09-1708:51thhellerweird because thats what :Piggieback :node-repl should end up calling#2019-09-1708:58Aleh Atsmani love and hate clj so much :exploding_head:#2019-09-1709:23sbI loaded successfully BlueprintJS with shadowjs. Works at many cases, maybe my poor react knowledge.. could you help me what I forget or how to rewrite to cljs? https://blueprintjs.com/docs/#core/components/popover.dark-theme
(defn PopOver []
 [:> bp/Popover {:content  [:div 
                            [:> bp/Menu {:large false}
                             [:> bp/MenuItem {:text "test1"}]
                             [:> bp/MenuItem {:text "test2"}]
                             [:> bp/MenuItem {:text "Test3"}]]]
                 :enforceFocus false
                 ;:position "Position.BOTTOM_LEFT" ;;error
                 :interactionKind "HOVER"}
  [:> Button {:variant "info"}  "hello"]]
)
and require with ["@blueprintjs/core" :as bp] .. my problem is how to add content section and position part of the code
#2019-09-1709:24sboriginal code https://github.com/palantir/blueprint/blob/develop/packages/docs-app/src/examples/core-examples/popoverInteractionKindExample.tsx#2019-09-1709:24thheller:content expects a react element but you are passing a cljs vector#2019-09-1709:25thhellerdo a (reagent/as-element [:div ...])#2019-09-1709:25sb@thheller thanks!!#2019-09-1709:25thheller:position bp/Position.BOTTOM_LEFT#2019-09-1709:26sbthanks!!#2019-09-1709:27sbWorks fine, thank you very much 🍻#2019-09-1716:32DanI'm new to ClojureScript and trying to get my head around how the front-end is set up. We're using ClojureScript, shadow-cljs, Leiningen and Reagent. I am just a bit confused about the dependencies around React. We're using Leiningen for our dependencies and have Reagent and shadow-cljs as dependencies. Do I still need to require React in the package.json file?#2019-09-1716:33lilactownyes#2019-09-1716:33thhellerJS dependencies are manage by package.json and npm yes#2019-09-1716:34DanOk, so in layman terms, there is one version of React used in the app and it's required in one place, package.json#2019-09-1716:35thheller"required" isn't the word I would use, it is only installed based on package.json#2019-09-1716:35thhellerwhat is used in the build is defined by your code#2019-09-1716:35thhelleryou can have thousands of things in package.json but that wouldn't mean they are actually included in a build#2019-09-1716:36DanWe have some :exclusions in the project.clj file - cljsjs/react etc - I think it's the cljsjs part I don't understand - basically how it's all connected. I come from React/Vue background and am used to just having one package listed#2019-09-1716:36gerred(closure compiler is :+1: about dead code elimination)#2019-09-1716:37thhellerthose exclusions don't really do much so you can remove them or keep them#2019-09-1716:37thhellershadow-cljs doesn't use them regardless#2019-09-1716:37thhellerpackage.json managed JS dependencies, project.clj managed CLJ/CLJS dependencies#2019-09-1716:38DanOk. So if we didn't use shadow-cljs (for example) and just reagent - where would that be pulling React from?#2019-09-1716:38thhellercljsjs#2019-09-1716:39DanOk, I thought shadow-cljs replaced cljsjs#2019-09-1716:39thhellerit does. but you asked about what happens if you didn't use it#2019-09-1716:41DanSo we can run just Reagent and shadow-cljsjs - I think I was getting confused as we run
[thheller/shadow-cljs "2.8.52"]
                 [thheller/shadow-cljsjs "0.0.20"]
#2019-09-1716:41thheller[thheller/shadow-cljsjs "0.0.20"] this you don't include at all#2019-09-1716:42thhellercljsjs is npm packages pre-packed as MAVEN dependencies#2019-09-1716:42thhellerCLJS uses maven by default#2019-09-1716:42thhellershadow-cljs skips cljsjs and accesses npm directly#2019-09-1716:42DanOk great. So ideal basic setup would be
[reagent "0.9.0-rc1"]
     [thheller/shadow-cljs "2.8.52"]
and then
"dependencies": {
        "react": "^16.9.0",
        "react-dom": "^16.9.0",
    }
#2019-09-1716:42thhelleryes#2019-09-1716:43DanPerfect#2019-09-1716:43DanThen I can remove all the :exclusions for cljsjs#2019-09-1716:43thhellershadow-cljsjs is about providing compatibility with packages that assume you don't have direct access to npm. described here https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-09-1716:43thhellershadow-cljs brings that in by default, you never need it manually#2019-09-1716:44thhellerbasically don't worry about those at all unless you run into specific problems#2019-09-1716:45thhelleryou can keep the exclusions or remove them. shadow-cljs doesn't care#2019-09-1716:45thhellerif you keep them the dependencies won't be downloaded#2019-09-1716:45DanCool. So how does having reagent in lein then access the packages in json - is that what shadow-cljs is taking care of?#2019-09-1716:45thhellerif you don't they are only downloaded once and then cached so no big overhead at all#2019-09-1716:45thhelleryes#2019-09-1716:48DanSorry, my last question, in the documents say it's recommended to run shadow-cljs as a standalone NPM version - but it doesn't say why that is recommended?#2019-09-1716:48thhellermore streamlined setup for CLJS#2019-09-1716:48thhellerlein is built for clojure and does a lot of stuff CLJS doesn't need#2019-09-1716:49thhellerbut if you need lein for other reasons that is totally fine#2019-09-1716:49DanSo would be advisable to remove from lein and add to package.json?#2019-09-1716:49DanWe have a lot of stuff in lein - I'm just trying to strip down the front end as it's a bit of a mess#2019-09-1716:50thhelleruhm no thats not how that works#2019-09-1716:50thhelleryou declare CLJS dependencies in project.clj#2019-09-1716:50thhellerbut you can also declare them in shadow-cljs.edn directly (and skip using project.clj completely)#2019-09-1716:50thhellerit is only about :dependencies and :source-paths#2019-09-1716:52thhellerwe are still managing 2 separate package managers. there is npm for JS and maven for CLJ/CLJS#2019-09-1716:52DanOk, makes sense. So for a new project, probably declare it in shadow, but we have quite a few depends in lein so probably best to keep it there for the moment#2019-09-1716:53thhellerone is controlled by package.json the othe other by shadow-cljs.edn or project.clj or deps.edn#2019-09-1716:53thhellershadow-cljs uses the exact same dependency resolution library as lein so moving them over would be easy#2019-09-1716:53thhellerbut you can keep project.clj if its working for you#2019-09-1716:53DanAh, OK - well better to have 2 scripts than 3!#2019-09-1716:54DanThank you very much for the help - a lot clearer now!#2019-09-1723:38currentoorIs it possible to make shadow-cljs build a release mode in dev with hot code reload? I’m trying to investigate an issue I only see in the release mode.#2019-09-1723:40thhellerno thats technically impossible#2019-09-1923:12tony.kay@thheller Just FYI, what we wanted was to resolve to React’s production js file while in dev mode. I used :js-options to map react and react-dom straight to the prod min files. That seemed to work.#2019-09-2008:20thhelleroh yeah thats fine. I was referring to the hot code reload part of the question. 🙂#2019-09-1723:41currentooryeah i figured#2019-09-1723:41thhellerwhats the issue?#2019-09-1723:42currentoora component breaks my app in one particular context but not another, I’m on a beta release of fulcro, so it could very well be a bug in fulcro 3, trying to figure out what’s going wrong#2019-09-1723:42currentoorthis component is loosing it’s dynamically bound variables#2019-09-1723:42thhellershadow-cljs release app --debug or shadow-cljs release --pseudo-names might provide clues if you are not using that yet#2019-09-1723:43currentooryup using those, very handy#2019-09-1723:43thhellershadow-cljs check app might be useful but has a lot of false positives#2019-09-1723:43thhellerso often more noise than actual help. but maybe 😉#2019-09-1723:43currentoornow that i think about it, i wonder if react’s async render stuff is not compatible with the way fulcro binds dynamic vars#2019-09-1723:43currentoori’ll check thanks#2019-09-1723:44thhellerif you use lazy seqs in render that can be a problem yes#2019-09-1723:44thhellerin dev they are "forced" by react's validation stuff but that isn't active in release builds#2019-09-1723:44thhellerso lazy seqs aren't eval'd at the correct time#2019-09-1812:40DanWhen I run npx shadow-cljs watch stories I get the following error:
npx: installed 91 in 3.066s
shadow-cljs - config: /Users/.../shadow-cljs.edn  cli version: 2.8.52  node: v10.16.3
shadow-cljs - connected to server
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:436).
shadow.cljs.devtools.cli
I'm unsure what is causing this error? Is it shadow-cljs related or Storybook etc
#2019-09-1813:01DanLooking at this...#2019-09-1813:01Danhttps://github.com/thheller/shadow-cljs/issues/180#2019-09-1813:01DanI am running [org.clojure/core.async "0.3.465"] so it should still work...#2019-09-1813:54thheller@studio not related to that at all#2019-09-1813:55thhellerI'm guessing you are running an embedded server that you started via (shadow.cljs.devtools.server/start!)?#2019-09-1813:55thhellerif so you must also (:require [shadow.cljs.devtools.cli]) in the ns that starts the server to ensure that it is loaded#2019-09-1813:55thhellerand FWIW shadow-cljs uses [org.clojure/core.async "0.4.500"]#2019-09-1814:06DanAh, yes that seems to have fixed the issue#2019-09-1814:06Dan
[shadow.cljs.devtools.cli]
[shadow.cljs.devtools.api :as shadow-cljs]
[shadow.cljs.devtools.server :as shadow-server]
#2019-09-1814:08DanThen get No config for build "stories" found. Build id required. - It must not be picking up my stories config in shadow-cljs.edn#2019-09-1814:09thhellerwell is it defined correctly?#2019-09-1814:09Dan
{:lein true
 :builds {:frontend {:target :browser
                     :output-dir "resources/app/public/js"
                     :asset-path "/js"
                     :modules {:main {:entries [frontend.core]}}}}
          :stories  {:target :npm-module
                     :output-dir "resources/app/public/js"
                     ;; storybook already handles all reloading
                     :devtools {:enabled false}}}}
#2019-09-1814:10thhellerhelps if you use paredit or so. parens don't match#2019-09-1814:10thhellerproperly indented you get
{:lein true
 :builds {:frontend {:target :browser
                     :output-dir "resources/app/public/js"
                     :asset-path "/js"
                     :modules {:main {:entries [frontend.core]}}}}
 :stories {:target :npm-module
           :output-dir "resources/app/public/js"
           ;; storybook already handles all reloading
           :devtools {:enabled false}}} }
#2019-09-1814:11DanAh, sorry, still getting the hang of the syntax. There's an Atom Paredit so will look into that
#2019-09-1814:11thhellerparinfer is also good and easier to get started with#2019-09-1814:11thhellersaves you from issues like that one#2019-09-1814:12DanStorybook have updated their story syntax, once I get this up and running I could update your example code?#2019-09-1814:12thhellerif there aren't too many changes sure 🙂#2019-09-1814:13DanThey have cleaned it up, looks a lot easier to create stories...#2019-09-1814:13Danhttps://storybook.js.org/docs/basics/writing-stories/#2019-09-1814:15DanHmm still get No config for build "stories" found. :face_with_monocle:#2019-09-1814:16thhellermake sure you have your parens correctly balanced#2019-09-1814:16thhellerin the above :stories wasn't in :builds, I didn't paste the corrected version#2019-09-1814:16thhellerjust a version that highlighted your mistake better#2019-09-1814:26DanRight, parinfer has saved the day#2019-09-1816:19mccraigmccraighey @thheller, some of my devs are seeing the "too many open files" error during shadow builds... they have large ulimit -n ( 30720, which seems like it should be enough). blatting their .shadow-cljs directory seems to fix the problem temporarily, but it still seems to crop up after a while. were on cli version: 2.8.52 node: v12.5.0 (which is later than https://github.com/thheller/shadow-cljs/issues/261 fix)... any ideas ?#2019-09-1816:20thhellerif I could prevent people from ever deleting .shadow-cljs I would ...#2019-09-1816:20thhellerNEVER do that please#2019-09-1816:21thhellermakes it impossible to debug what is happening#2019-09-1816:21thhellernext time you run into that at least make a copy or so#2019-09-1816:21thhellerit is likely creating too many cache files? which means you are accessing too many npm files maybe?#2019-09-1816:21mccraigmccraigwe can make a copy next time it happens...#2019-09-1816:21thhellerit creates 2 cache files per npm file (one source, one source map)#2019-09-1816:22thhellerso if you access 1000 npm files thats already 3k#2019-09-1816:22thhellerand not unlikely at all to access more than 1k#2019-09-1816:24thhellerbut yeah .shadow-cljs is just cache, which will just be written again so it should end up at the same values after one build#2019-09-1816:24thhellerdo you maybe run several builds in parallel or so?#2019-09-1816:24mccraigmccraigfind .shadow-cljs | wc is returning 7118 for me atm... well within my 32k ulimit#2019-09-1816:24thhellerlast time I checked there were no file leaks anymore. so in case it happens again try to find out which files are open#2019-09-1816:25thhellerthats only the cache files though. it'll still have the files from node_modules open#2019-09-1816:25thhelleruse lsof or something maybe?#2019-09-1816:25mccraigmccraiganyway, i've given instructions to keep .shadow-cljs next time it happens and get an lsof dump#2019-09-1816:28mccraigmccraigwe don't run several builds in parallel - we do have a bunch of different builds and we do feed --config-merge EDN to those builds#2019-09-1816:45mccraigmccraighere's an lsof dump @thheller - almost all the files are .jars from ~/.m2#2019-09-1816:47mccraigmccraigthere aren't any source files from the project directory, or cache files from the .shadow-cljs directory there#2019-09-1816:47thhellerhmm odd. how many jars are there?#2019-09-1816:48mccraigmccraig10440#2019-09-1816:49thhellerwhat the heck? the same open multiple times I guess?#2019-09-1816:50mccraigmccraigyep - there are definite repeats#2019-09-1816:50mccraigmccraigevery jarfile i've looked at so far is open twice#2019-09-1816:56mccraigmccraigoh, wow - promesa-1.9.0.jar is open 142 times!#2019-09-1816:57mccraigmccraigand reagent-0.8.1.jar 362 times#2019-09-1816:58thhellerweird#2019-09-1817:05mccraigmccraigis it shadow opening jarfiles, or is that down to the cljs compiler ?#2019-09-1817:13thhellerwell it is opening whenever a file in them is accessed yes#2019-09-1817:13thhellerbut the classloader is doing that#2019-09-1817:13thhellerI would expect it to close right after?#2019-09-1819:02mccraigmccraighmm... well something is going awry - does each run of the compiler create a new classloader perhaps ?#2019-09-1819:06mccraigmccraigi can't remember whether random access in a zipfile makes any sense and thus whether it would make sense for a classloader to hold jars open to load future class requirements from#2019-09-1819:08mccraigmccraigpresumably this is an issue of shadow server mode though, and restarting the shadow server should make everything good#2019-09-1819:12mccraigmccraigwe'll try that next time it happens#2019-09-1819:23alexandergunnarsonHey @thheller! Not quite sure how to phrase this question/concern but I’ve been having quite a few very cryptic and laborious-to-isolate errors and I wonder whether shadow-cljs could report them in a more user-friendly or easy-to-debug way. I’ve been able to work through them with a mix of 1) (set! (.-onerror js/document) (fn [...] (log-pretty-error ...))), 2) bisecting the code by commenting out parts till I get to the error, and 3) just restarting the build. 2) and 3) have proven particularly time-consuming. Here’s an example of something (I still don’t know what it is — have to do good ol’ option 2 and 3 till I figure out) :
[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException: java.lang.String cannot be cast to clojure.lang.Named

        clojure.core/namespace (core.clj:1597)
        clojure.core/namespace (core.clj:1597)
        shadow.build.compiler/write-cached-cljs-resource/spec-filter-fn--11841 (compiler.clj:707)
        shadow.build.compiler/write-cached-cljs-resource/fn--11844 (compiler.clj:713)
        clojure.core/fn--8429/fn--8431 (core.clj:6840)
        clojure.core.protocols/iter-reduce (protocols.clj:49)
        clojure.core.protocols/fn--8140 (protocols.clj:75)
        clojure.core.protocols/fn--8140 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
        clojure.core/reduce (core.clj:6828)
        clojure.core/fn--8429 (core.clj:6830)
        clojure.core/fn--8429 (core.clj:6830)
        clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
        clojure.core/reduce-kv (core.clj:6856)
        clojure.core/reduce-kv (core.clj:6847)
        shadow.build.compiler/write-cached-cljs-resource (compiler.clj:711)
        shadow.build.compiler/write-cached-cljs-resource (compiler.clj:677)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:832)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:762)
        shadow.build.compiler/par-compile-one (compiler.clj:895)
        shadow.build.compiler/par-compile-one (compiler.clj:850)
        shadow.build.compiler/par-compile-cljs-sources/fn--11897/iter--11919--11923/fn--11924/fn--11925/fn--11926 (compiler.clj:968)
        clojure.core/apply (core.clj:665)
        clojure.core/with-bindings* (core.clj:1973)
        clojure.core/with-bindings* (core.clj:1973)
        clojure.core/apply (core.clj:669)
        clojure.core/bound-fn*/fn--5749 (core.clj:2003)
        java.util.concurrent.FutureTask.run (FutureTask.java:266)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
        java.lang.Thread.run (Thread.java:748)

[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException:

[:local.client.search] Compiling ...
[:local.client.search] Build failure:
ClassCastException:
I’m happy to post more of these sorts of things as I come across them. Had quite a few yesterday but I worked through them. (By the way those last ClassCastExceptions have no stack trace and it’s not obvious whether they relate to the first one) ^^^ Solved this particular issue by method #3. Doesn’t fix the crypticness but good to know it’s at least an available option.
#2019-09-1819:27mccraigmccraigthe plot thickens. after restarting there are only 546 open jarfiles, but the build still fails with too-many-open-files - so it looks like the open jarfiles are not the root cause of the problem. whatever is the cause is not yet clear - there are only 2044 files in the .shadow-cljs directory#2019-09-1819:29mccraigmccraigcurrently trying to capture an lsof dump during compilation, since perhaps whatever open files are causing the issue are getting closed after compilation fails#2019-09-1820:10thheller@alexandergunnarson that error indeed sucks but I have never seen that so kinda not sure whats happening#2019-09-1820:11thhellerit appears to be spec related maybe?#2019-09-1820:13thhellerthat part of the code deals with caching specs. do you do any black magic with spec? custom implementations or so?#2019-09-1820:23alexandergunnarsonInteresting; yeah now I’m seeing the spec-filter-fn#2019-09-1820:23alexandergunnarsonI do a few black magics with it 🙂#2019-09-1820:23alexandergunnarsonI think this was a case of for whatever reason I was defining a spec incorrectly (e.g. transposing docstring with keyword name) and it got swapped into the spec cache#2019-09-1820:24alexandergunnarsonSo I have a slightly custom s/def that does like (s/def :whatever/spec-name "docstring" {:meta-stuff "if you want"} some-spec)#2019-09-1820:24alexandergunnarsonI was erroneously doing (s/def "docstring" :whatever/spec-name)#2019-09-1820:24alexandergunnarsonAnd I think that bad data got swapped in#2019-09-1820:32thhellerhmm weird that that is allowed#2019-09-1820:32thhellerbut yes that would cause that error#2019-09-1820:40alexandergunnarsonMakes sense! Well anyway I will keep you posted of similarly odd/cryptic errors I get haha#2019-09-1820:40alexandergunnarsonMaybe there’s a pattern in terms of usability enhancements#2019-09-1820:43thhellerwell if you do stuff that no one else has done before there likely aren't good error messages there 😉#2019-09-1820:47alexandergunnarsonHeh good point 😉#2019-09-1820:48thhellerhttps://github.com/thheller/shadow-cljs/commit/356289b3ae44753099d9cbe5f79765af5cdf69e2#2019-09-1820:48thhellerwon't break the entire build if it happens again 😉#2019-09-1821:00alexandergunnarsonOkay cool haha — thank you thank you! If you were a customer support person I’d rate you a 12/10!#2019-09-1821:01alexandergunnarsonToo bad there’s not much money in open source… even if it is an awesome tool… ah well, Patreon#2019-09-1821:14Quest+1 on that: thheller provides tons of great support here. https://www.patreon.com/thheller for those who want to show a little love#2019-09-1901:29vinurshello, anyone meet this error when shadow-cljs release app#2019-09-1901:29vinurswhen just shadow-cljs compile app it works ok#2019-09-1901:33alexandergunnarsonAre you doing some sort of Closure-unsafe object access? Like (.-field something) as opposed to (goog.object/get something "field")?#2019-09-1907:37thhellerthis is outdated advice. for code it is absolutely fine to use (.-field something). you just need to "tag" it either directly or indirectly as js to tell the compiler to not rename it. so either (.-field ^js something) or `(fn [^js something] ...). see https://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html#2019-09-2806:56alexandergunnarsonOh, nice! My awareness of this was coming purely from the vanilla CLJS compiler. Don’t profess to know much about shadow-cljs yet 🙂#2019-09-2808:21thhellerthis is a standard CLJS feature as well. https://clojurescript.org/guides/externs#externs-inference#2019-09-1901:39vinurs
(ns app.core
  (:require [reagent.core :as r :refer [atom]]
            ["react-native" :as RN :refer [AppRegistry]]))

(defn app-root []
  [:> RN/View {:style {:flex-direction "column"
                       :margin 40
                       :align-items "center"
                       :background-color "white"}}
   [:> RN/Text {:style {:font-size 30
                        :font-weight "100"
                        :margin-bottom 20
                        :text-align "center"}}
    "Hi Shadow!"]])

(defn init []
  (.registerComponent AppRegistry
                      "YsjApp"
                      #(r/reactify-component app-root)))

#2019-09-1901:39vinursthis is all the code#2019-09-1901:46vinursoh, because i use the [reagent “0.9.0-rc1”]#2019-09-1901:46vinurs0.8.0 works ok#2019-09-1906:28danielgrosseI don't know if this belongs here, but I have a problem with shadow-cljs and cider. I jackin with clj&cljs and everything works as expected. except when I want to add dependencies via cljr. Then I get a message The refactor-nrepl middleware isn’t available! Did you remember to install it? From the code of clj-refactor it tests the availability of (cljr--op-supported-p "find-symbol"). But I thought, CIDER is injecting all the relevant parts in its jackin call. So anyone has a clue how I get this running?#2019-09-1907:39thhellerno clue, probably just need to add the refactor-nrepl dependency manually?#2019-09-1906:41pyrHi!#2019-09-1906:41pyrI have a working shadow-cljs#2019-09-1906:43pyrproject which depends on 3rd-party npm modules, so far so good#2019-09-1906:45pyrI was wondering whether from that project I could somehow distribute and package it into a form that would be consumable by lein based projects#2019-09-1907:41thheller@pyr you best bet is to create cljsjs packages that provide those npm modules. shadow-cljs would continue using npm directly but others would fall back to cljsjs#2019-09-1907:42thhellerotherwise you can add instructions on how to do it via webpack but that'll require manual work on the consumer side#2019-09-1908:51pyr@thheller thanks!#2019-09-1910:53mccraigmccraig@thheller so i've got an interesting lsof output from my shadow build which is failing with Too many open files - https://gist.github.com/mccraigmccraig/230d72c25b3a36d31c57fc5369ad0aab#2019-09-1910:53mccraigmccraigthere are a tonne of vnode: FD unavailable entries... don't know what they are yet#2019-09-1910:55mccraigmccraighmm. although that might just lsof reading structures which are in the middle of initialisation#2019-09-1911:34thheller@mccraigmccraig I don't know what that is. you were using lein right? could you try without that?#2019-09-1911:36mccraigmccraigno, we're not using lein - just the shadow-cljs cli (invoked as a child_process.spawn from gulp)#2019-09-1911:36thhellerhmm how come you have so many java dependencies then? I see cassandra and stuff?#2019-09-1911:37mccraigmccraigyeah, that's gotten transitively from our model module - it's has both clj and cljs stuff in it#2019-09-1911:37mccraigmccraigit's just pulled in as a jar in the shadow build though#2019-09-1911:38thhellerwell it doesn't matter too much. what is strange is that the clojure and clojurescript jars are open so many times#2019-09-1911:38mccraigmccraigyeah#2019-09-1911:39thhellerbut I'm guessing thats the classloader, nothing I can do about that#2019-09-1911:40mccraigmccraigi've now upped my ulimit -n to 262144, which seems ridiculously overspecified, and i'm still seeing the error#2019-09-1911:41thhellerwhat exactly do you do in the build?#2019-09-1911:41thhellerdo you have side effecting macros that work on files maybe?#2019-09-1911:43mccraigmccraignothing unusual - there are macros, but no side-effecting macros#2019-09-1911:46thhellerand you are just using a plain setup? no extra special build hooks or so?#2019-09-1911:47mccraigmccraigwe call shadow-cljs from gulp, but it's just a plain setup once running shadow-cljs#2019-09-1911:47thhellercould you remove that part?#2019-09-1911:49mccraigmccraigyep, trying that now#2019-09-1911:49thhelleror maybe look at the java process with visualvm. maybe try a heap dump#2019-09-1911:50thhellerI don't really know. any obvious file leak would show up for me too but there aren't any#2019-09-1911:52mccraigmccraigyep, still get the issue with the shadow-cljs command issued manually#2019-09-1911:52mccraigmccraigour command is this
shadow-cljs --config-merge '{:output-dir "target/yapster-web/js" :compiler-options {:closure-defines {er-webui.env/app-deployment-platform "web" er-webui.env/api-url "" er-webui.env/expected-api-version "2.6.0" er-webui.env/client-build-version "2.6.0.0" er-webui.env/sentry-release "yapster-2.6.0.0" er-webui.env/log-level "info"}}}' release yapdev
#2019-09-1911:53thhellercan you run with --verbose please?#2019-09-1911:53thhellersee when exactly it starts going wrong?#2019-09-1911:54mccraigmccraighttps://gist.github.com/b020ebbbe95013e0490bf812a25c17e2#2019-09-1911:56mccraigmccraigit's as if the ulimit on the build process is getting lowered#2019-09-1911:58thhellermy linux knowledge is limited so I don't know how to control that at all#2019-09-1911:59gerredhave you tried setting it in limits.conf?#2019-09-1911:59mccraigmccraigi'm on macos ... the maxfiles ulimit on my shell process is massive - 262144#2019-09-1911:59gerredif shadow-cljs is using a subshell, it could be getting reset on a per-subshell basis.#2019-09-1912:00thhellerdunno what subshell means but I think not. shadow-cljs is a npm script which then starts the java process#2019-09-1912:00mccraigmccraigdoesn't seem to be @gerred - if i create a bash or zsh subshell it's still got ulimit -n of 262144#2019-09-1912:01gerredhmm#2019-09-1912:01thheller@mccraigmccraig you can try setting :compiler-options {:parallel-build false} in your build config#2019-09-1912:01gerredsubshell would be the Java process shelling out is all that means. 🙂#2019-09-1912:01thhellerthat'll make things slower but doesn't use as many threads#2019-09-1912:01gerredor any os.exec action in node#2019-09-1912:02mccraigmccraigyeah, although i'm pretty sure java doesn't reset max-open-files#2019-09-1912:02thhellerI'm using https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options#2019-09-1912:03mccraigmccraigbut if i could find out how to query the ulimits on another process on macos i could find out... so easy on linux, haven't yet found out how on macos#2019-09-1912:03gerredspawnSync will inherit from the ulimit in the shell it's run from so you're good there#2019-09-1912:03gerredi think#2019-09-1912:03gerredand that's consistent with what @mccraigmccraig is seeing#2019-09-1912:04gerredactually that could be tested real quick...#2019-09-1912:04gerred1s.#2019-09-1912:06thhellerdunno how it would leak anything. cache is definitely closed after is is read https://github.com/thheller/shadow-cljs/blob/10553565f796281ce5fdf1b569c0c7ea2f4dabe9/src/main/shadow/build/cache.clj#L35#2019-09-1912:07mccraigmccraig:compiler-options {:parallel-build false} didn't change anything#2019-09-1912:08gerred😮#2019-09-1912:08thhellerwhich java version?#2019-09-1912:08gerred#2019-09-1912:09gerred#2019-09-1912:09gerredthat's not at all what I expected to happen. going to run that in a docker container now..#2019-09-1912:09mccraigmccraiguh, wat ?#2019-09-1912:09mccraigmccraigso spawnSync is maybe setting a ulimit#2019-09-1912:10gerredand trying one more thing..#2019-09-1912:10thhellertry spawnSync("ulimit", ["-n"], {stdio: "inherit"})#2019-09-1912:10gerredoh good point, missed that.#2019-09-1912:10thhellerthats how shadow-cljs calls things#2019-09-1912:12gerred➜ spawnsynctest node index.js 24576#2019-09-1912:12gerredsame deal#2019-09-1912:12gerredso looks like it's only inheriting the actual pipes.#2019-09-1912:12gerredwhich makes sense from the docs since it's inheriting the pipes, not the current shell 🤔 but i'm still not expecting to get separate ulimits#2019-09-1912:14gerredok trying something..#2019-09-1912:16mccraigmccraighowever... for me the output of
const { spawnSync } = require("child_process");
spawnSync("ulimit", ["-n"], {stdio: "inherit"});
is 262144
#2019-09-1912:16mccraigmccraigwhich is inherited#2019-09-1912:16gerredso maybe that's a mac shell thing.#2019-09-1912:17gerredif you go to my original (console.log version with the default stdio) is it the same?#2019-09-1912:17mccraigmccraigyes, same#2019-09-1912:21DanDoes shadow-cljs support default exports? Like export default { title: 'foo'};#2019-09-1912:21DanI am struggling to see even a basic example online#2019-09-1912:21gerred@mccraigmccraig hmmm thought.#2019-09-1912:21DanSomething like (defn ^:export ?#2019-09-1912:22gerredout of curiosity (then I gotta jump) try running it inside a docker container?#2019-09-1912:22thheller@studio in which context? it doesn't support outputting ESM but for commonjs you can just do (def ^:export default ...)#2019-09-1912:26mccraigmccraig@gerred yeah, i'm trying it on a deb container on a linux kernel now#2019-09-1912:26DanI am trying to get Storybook's new format working which is based on ES6 modules:
storiesOf('atoms/Button', module)
  .add('text', () => <Button>Hello</Button>)
  .add('emoji', () => <Button>😀😎👍💯</Button>);
is now:
export default { title: 'atoms/Button' };
export const text = () => <Button>Hello</Button>;
export const emoji = () => <Button>😀😎👍💯</Button>;
#2019-09-1912:27DanBut seem to be stuck at the first hurdle 😞#2019-09-1912:29thhellerand you are using :npm-module I presume?#2019-09-1912:30thheller(def ^:export default #js {:title "atoms/Button"}) (defn ^:export text [] (reagent/as-element [:button "Hello"]))#2019-09-1912:32thhellerit might be that storybook is actually trying to parse the ESM however in which case this wouldn't work since we are outputting commonjs#2019-09-1912:32thhellerit also doens't work in "strict ESM" mode#2019-09-1912:33DanYep :stories {:target :npm-module#2019-09-1912:35DanWhere has the reagent stuff come from?#2019-09-1912:35thhellerare you not using reagent?#2019-09-1912:36DanWe will be in the future, I am just trying to get the most basic setup going atm#2019-09-1912:36thheller(:require [reagent.core :as reagent])#2019-09-1912:37DanStupid question, why would I need to use that? This is just basic JS at this point? export const text etc#2019-09-1912:39DanWe already use their React
(:require
    ["@storybook/react" :refer (storiesOf)]
    ["@storybook/addon-actions" :refer (action)]))
#2019-09-1912:40thhellerfrom the example code I presume you need to return a react element#2019-09-1912:40thhellerwhich is what () => <Button>Hello</Button>; does#2019-09-1912:40DanHmm, sorry, I pasted old code from your original demo. It's now:
import React from 'react';
import { Button } from '@storybook/react/demo';

export default { title: 'Button' };

export const withText = () => <Button>Hello Button</Button>;
#2019-09-1912:43DanSo in this scenario am I better to rely on Reagent or the React dependency in package.json?#2019-09-1912:44thhelleralways package.json for JS dependencies#2019-09-1912:44thhellerbut you need both, reagent and react#2019-09-1912:44thheller
(ns foo.bar
  (:require
    [reagent.core :as reagent]
    ["react" :as react]
    ["@storybook/react/demo" :refer (Button)]))

(def ^:export default #js {:title "Button"})

(defn ^:export withText []
  (reagent/as-element [:> Button "Hello Button"]))
#2019-09-1912:45thhellerI can make an example without reagent but you are likely going to use that anways?#2019-09-1912:45thheller
(ns foo.bar
  (:require
    ["react" :as react]
    ["@storybook/react/demo" :refer (Button)]))

(def ^:export default #js {:title "Button"})

(defn ^:export withText []
  (react/createElement Button nil "Hello Button"))
#2019-09-1912:47DanThe end goal of the app will be using Reagent and probably Re-frame.#2019-09-1912:48DanI guess either way I would need to reference react or reagent so better if the Story file matched the real cljs file I guess#2019-09-1912:52thhellernot sure what you mean by that#2019-09-1912:52thhellerthe examples I pasted should work#2019-09-1912:52thhellerif they don't storybook might be trying to process the JS files directly#2019-09-1912:52thhelleryou might have more fun with https://github.com/nubank/workspaces since its all cljs#2019-09-1912:53gerredi've been needing to check out workspaces.#2019-09-1912:56DanSo this works
(ns frontend.ui.component.button-stories
  (:require
    [reagent.core :as reagent]
    ["react" :as react]))

(def ^:export default #js {:title "Button"})

(defn ^:export withText []
  (reagent/as-element [:button "Hello"]))
#2019-09-1912:57DanBut is also tries to process the default export as a component.#2019-09-1912:57Dan#2019-09-1913:12DanI guess because we explicity named it#2019-09-1913:22thhellerno we didn't#2019-09-1913:29DanWe created a global variable with the name of default - is how I understood it#2019-09-1913:30thhellerit is not a global variable no#2019-09-1913:30thhellerand export default creates an .export property just like what we did#2019-09-1913:30DanOk, I must have misunderstood this https://cljs.info/cheatsheet - apologies#2019-09-1913:31thhellerwell yeah this is specific to the npm-module target#2019-09-1913:31thhellerin general this creates a namespaced global var yes#2019-09-1913:31thhellerso we'd have a foo.bar.default#2019-09-1913:31thhellerbut the :npm-module is turning that into module.exports.default = ...#2019-09-1913:33DanAh, ok that makes sense#2019-09-1913:38DanSo if I change the title, for example, then the hot reload in Storybook breaks can't redefine non-configurable property "default" Storybook can't be trying to access the files directly if they worked on initial load?#2019-09-1913:40thhellerI don't have the slightest clue how storybook does anything#2019-09-1913:40thhellermy total experience with it is like 30min making the old example#2019-09-1913:47DanThanks for the help! Looks like Storybook might not be a good fit - too many abstractions and dependencies when used in a Clojure project 😞#2019-09-1914:54vinurs2.8.53 error in process filter: The shadow-cljs ClojureScript REPL is not available#2019-09-1914:55thheller> process filter#2019-09-1914:55thhellerwaht is that?#2019-09-1914:55thhellerand what is that entire message? it is not produced by shadow-cljs#2019-09-1914:56dpsuttonSounds like emacs?#2019-09-1914:57vinurswait a minute, maybe update broken#2019-09-1915:01vinursthe same error#2019-09-1915:01vinurs[nREPL] Establishing direct connection to localhost:53629 ... [nREPL] Direct connection to localhost:53629 established error in process filter: user-error: The shadow-cljs ClojureScript REPL is not available error in process filter: The shadow-cljs ClojureScript REPL is not available#2019-09-1915:01vinursin emacs i use cider-connect-cljs#2019-09-1915:02thhellerthis is not a shadow-cljs error so I can't say what it means#2019-09-1915:26mccraigmccraigok @thheller - found something interesting - downgrading shadow-cljs from 2.8.52 down to the version we were previously using, 2.8.39, seems to fix our too-many-open-files issue#2019-09-1915:26thhellerare you sure thats not just because it wiped the cache?#2019-09-1915:27thhellermight be back if you run a second time?#2019-09-1915:28mccraigmccraignope, i've already run it half a dozen times#2019-09-1915:28mccraigmccraigpreviously it was borking 2-3 runs after a cache clear#2019-09-1915:29mccraigmccraigit's not a macos only issue either - one of my devs is on an ubuntu laptop, and he encountered the issue too#2019-09-1915:31thhellerno clue. I mostly worked on REPL issues and some of the react-native stuff#2019-09-1915:32thhelleryou are just running shadow-cljs release ... right? there is no server-mode instance running prior?#2019-09-1915:33mccraigmccraigthis is just shadow-cljs release ... - users have also seen the issue with watch builds#2019-09-1915:34thhelleryes but with release no server-mode is started. so half of the stuff isn't even running in that case#2019-09-1915:34thhellerjust trying to narrow down the issue#2019-09-1915:34thhellerstill don't have the slightest clue what might be happening#2019-09-1915:36thhellerif you have too much time you can try running each try each version to see when it started failing#2019-09-1915:36thhellerthere aren't many commits per release so should be easy to identify#2019-09-1915:37thhellercan't find anything going over commit history that would be related to this#2019-09-1915:38mccraigmccraigi'll do a binary chop - i certainly don't want to be stuck on an old release!#2019-09-1915:39thhellerhttps://github.com/thheller/shadow-cljs/commit/a21c3fcc42c48aef1d3734fe4c88936d51775e43 thats the only thing thats potentially opening/closing many files#2019-09-1915:39thhellerbut it won't even run in release mode#2019-09-1916:27mccraigmccraig@thheller it looks like it's /cdn-cgi/l/email-protection where the issue first arises#2019-09-1916:30mccraigmccraigwhich includes the commit you referenced earlier https://github.com/thheller/shadow-cljs/commit/a21c3fcc42c48aef1d3734fe4c88936d51775e43#2019-09-1916:36mccraigmccraiga simple git revert of that commit causes conflicts, which are beyond my ability to fix in a couple of minutes, so i haven't tested out the hypothesis that it's that commit which is to blame#2019-09-1918:47thheller@mccraigmccraig if you happen to run into this while watch is running could you try shadow-cljs clj-repl (separate terminal) and dump @shadow.build.macros/active-macros-ref?#2019-09-1918:48mccraigmccraigyep @thheller i can do that#2019-09-1921:24thheller@mccraigmccraig try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "57243f363338207a343b3d241765796f796263"}, :content ("[email protected]")}. I added some caching so the macro stuff doesn't touch so many files. maybe that helps?#2019-09-1923:16mccraigmccraigthat seems to fix the problem @thheller - i ran about 6 builds consecutively without issue - i've switched our dev branch to {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "c8bba0a9aca7bfe5aba4a2bb88fae6f0e6fdfc"}, :content ("[email protected]")}, so i should get some more reports from my other devs tomorrow#2019-09-2008:28thhellerwho knew that checking for a last modified timestamp could be that expensive 😛#2019-09-2008:40mccraigmccraigohhh... so was it the URLConnection which is holding files for file: URLs open then ?#2019-09-2008:41thhellerno, that was fixed a while ago. the change was only that it caches those lookups for files in .jar#2019-09-2008:41thhellerguess the JVM is doing something weird with them#2019-09-2009:57mccraigmccraiggot a first report in from a non-me dev now @thheller - 2.8.54 is confirmed to resolve the too-many-open-files issue!#2019-09-2009:58thhellerwoho!#2019-09-2009:58mccraigmccraigthank you for the excellent support#2019-09-2009:58thhellermaybe also upgrade to .55 for the emacs users. I accidentally broke the cider detection mechanism#2019-09-2009:59mccraigmccraigoh, cool - we're mostly CIDER users, so i'll do that#2019-09-2009:59thhellerthanks for all the testing. wouldn't have guess the cause with that.#2019-09-2009:59mccraigmccraigyw#2019-09-2009:59mccraigmccraigbtw - what drives you on shadow ? is it part of your job, or a side-project ?#2019-09-2010:00thhellerstarted out as something I needed for work myself. now fun side-project, maybe my job soon when I do consulting and stuff around it 😉#2019-09-2010:10mccraigmccraigwell i'm bought into it - if/when you are thinking about it, let's talk about how we (yapster) can contribute to your ongoing work on shadow#2019-09-2011:34thhellerfor now there is https://www.patreon.com/thheller maybe github sponsors when it becomes available. code and documentation contributions are also very welcome but not sure which parts of the code are easy to contribute to 😛#2019-09-2002:46Aklsccshadow-cljs compiles the RegExp has some problems, such as following code:
(let [v (js/RegExp. "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$")]
    (.test v p))
Then there is a compiler error:
main.cljs [line 55, col 54] Unsupported escape character: \d.
#2019-09-2002:46Aklscc@thheller#2019-09-2003:23dpsutton#2019-09-2003:24dpsuttonseems its not shadow but cljs#2019-09-2003:25dpsutton
new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$").test("foo")
false
#2019-09-2005:16AklsccYes, RegExp seems doesn't work for this, but # does, please try it. And shadow-cljs can't compile "#" pattern too.#2019-09-2006:44Aklscc@U11BV7MTK#2019-09-2003:25dpsuttonbut works in a js console#2019-09-2005:44malchHey, @thheller! I'm getting The shadow-cljs ClojureScript REPL is not available from CIDER with the new {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "e4978c85808b93c987888e97a4d6cadccad1d0"}, :content ("[email protected]")} Do I need to change something?#2019-09-2005:45malchLooking at this code: https://github.com/clojure-emacs/cider/blob/15c4ef0aca4d709e70a70f556a8dfb3ff6a49497/cider.el#L696-L699#2019-09-2005:45malchLooks like Cider expects shadow.repl to be present, was it changed?#2019-09-2007:48malchSorry, only now saw your comment in #cider channel simple_smile#2019-09-2008:38thheller@malch I just released {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83f0ebe2e7ecf4aee0efe9f0c3b1adbbadb6b6"}, :content ("[email protected]")} which brings back that ns for cider. doesn't do anything but should fix the detection.#2019-09-2008:44malchThank you! I could've also created it myself simple_smile#2019-09-2008:49Aklscc@thheller I'm sorry to bother you, but I have search much about RegExp in cljs. It looks like a compiler fault, which doesn't support some formats of the RegExp? 😂#2019-09-2008:51thheller@180338742 the error you posted is the reader complaining. has nothing to do with regexp. you probably just need to escape the string properly?#2019-09-2008:51thheller
(let [v (js/RegExp. "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[^]{8,16}$")]
    (.test v p))
#2019-09-2008:52thheller\\d not \d#2019-09-2010:26Saikyunhey @thheller I've made some progress with three.js + expo + shadow-cljs. I'm however experiencing some lag. it might be because I'm producing a lot of objects, but I also wanted to ask how much :compiler-options {:optimizations :advanced} affect this. when running shadow-cljs release app I had to set them to :simple in order to get the app to run. would this affect performance a lot?#2019-09-2010:27SaikyunI've looked a bit at externs for three.js, and it seems possible to autogenerate them. however when I use :compiler-options {:infer-externs :all} I get some 400 warnings. it'd take some time to fix those, so I just wanted to ask beforehand if you knew if there'd be any significant performance (in terms of fps) gains, or if I should focus on other things (e.g. not creating as many objects per frame)#2019-09-2010:28SaikyunI understand that this is a tricky question, so don't sweat it if it's too complex#2019-09-2010:37SaikyunI think the performance is OK when building however (using `expo build:android), so maybe it doesn't matter that much#2019-09-2011:22thheller@saikyun as the manual mentions, don't use :infer-externs :all. :auto is enough and all you can fix anyways.#2019-09-2011:22thheller:advanced will be "smaller" so it'll probably load faster. runtime performance should be the same as :simple#2019-09-2012:01Saikyun@thheller thanks for the info. :))#2019-09-2015:10danielnealalso make sure you do performance testing with expo dev set to off#2019-09-2015:10danielnealI think in dev mode there’s a lot more things going on#2019-09-2017:08deadghostIf I'm requiring in ["@material-ui/core/styles" :refer [makeStyles]], what's the fully qualified name of makeStyles since @material-ui.core.styles/makeStyles will try to deref?#2019-09-2017:08deadghostI'd like to use makeStyles in a macro#2019-09-2017:16thhellercan't easily access that from a macro currently#2019-09-2017:17thhelleryou can use (cljs.analyzer/resolve-var &env 'makeStyles)#2019-09-2017:18thhelleror use a helper function which might be better depending on your use case#2019-09-2017:18thheller(defn do-something [x] (makeStyles x)) and call do-something from the macro#2019-09-2018:13deadghostyep the latter works fine#2019-09-2019:24ennIs anyone successfully using CIDER with shadow-cljs? Every time I try to cider-jack-in-cljs I get a REPL which tells me: No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.#2019-09-2019:32cheppreyTry cider-connect-cljs instead of jack-in, emacs will ask you a few questions like host, port, and type (i don't have access to my cljs environ so I can't be specific)... you'll give it for ex localhost 8888 shadow and your shadow target code like dev or app or however you set it up#2019-09-2019:33cheppreyand make sure your browser is up and running & talking to your shadow command after you do the shadow-cljs watch [app]#2019-09-2020:00thheller@enn https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime
#2019-09-2020:02enn@thheller how do I start the runtime if it's node, not the browser? @chepprey I've tried both ways, it does not seem able to connect when I enter the nREPL port number output by npx shadow-cljs server. There is no browser here, this is node.#2019-09-2020:02thheller> 14.3.2. :target :node-script, :node-library These targets will have produced a .js file that are intended to run in a node process. Given the variety of options however you’ll need to run them yourself. For example a :node-script you’d run via node the-script.js and on startup it’ll try to connect to the shadow-cljs server. You should see a WebSocket connected message on startup. The output is designed to only run on the machine they were compiled on, don’t copy watch output to other machines.#2019-09-2020:03thhellerif you just need a node repl use shadow-cljs node-repl#2019-09-2020:03thhellerand connect to the :node-repl build. however that is done in cider I don't know#2019-09-2020:04ennHmm. It does not ask me for a build when I connect, only when I start from within CIDER with cider-jack-in.#2019-09-2020:05ennand the REPL I get when I run cider-connect-cljs and put in the nrepl port number output when running shadow-cljs node-repl is a Java REPL#2019-09-2020:14thhellerit ALWAYS starts out as a clojure REPL#2019-09-2020:14thhelleryou need to switch it to the REPL of the build you want#2019-09-2020:14ennOK#2019-09-2020:14thhellerI do not know the command in cider to do that#2019-09-2020:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cider#2019-09-2020:15thhellerI do not know if this is still current#2019-09-2020:15thhellerI don't know anything about cider and it seems to change constantly so no idea#2019-09-2020:20mccraigmccraig@enn i use cider-connect-cljs then set the host and port then choose the cljs repl type as shadow-select then give the node-repl build#2019-09-2020:20mccraigmccraigthat puts me straight in a cljs repl#2019-09-2020:21ennOK, that's good to know. After choosing shadow-select I get error in process filter: Wrong type argument: stringp, nil in the minibuffer, and I never get to choose a build. So likely I have some package version mismatch somewhere. The story of Emacs....#2019-09-2020:23lilactown@enn your original problem was you need to run node path/to/output/script.js#2019-09-2020:28lilactownto do a plain node-repl in Emacs (basically, a CLJS REPL without an associated build) I do: 1. cider-jack-in which lands me in a CLJ REPL 2. (shadow/node-repl) which lands me in a CLJS REPL where I don’t need to start an external process like node path/to/build/output.js or a browser window#2019-09-2020:28lilactownfrom there i can also type :cljs/quit to go back to the CLJ REPL and start/stop/REPL in to my other builds#2019-09-2020:40lilactownin other news, I’m attempting to transition a lein-figwheel project to shadow-cljs and it is rough#2019-09-2020:41lilactownlots of cljsjs I have to proxy myself, several of which don’t have exact same versions on npm… shadow-cljs actually using the core specs on our bad code… etc. 😛#2019-09-2021:38lilactownI’m running into a real weird spec error#2019-09-2021:39lilactownthe code:
(condp = tag
  ...
      :clojure.spec.alpha/invalid
      (throw (ex-info
               "Visual Segment Value Was Invalid"
               {:value value
                :explain-data (spec/explain-data :visual-segment/value value)})))
#2019-09-2021:39lilactownthe error:
478 |     (condp = tag
-----------^--------------------------------------------------------------------
Syntax error macroexpanding cljs.core/let.
Call to cljs.core/let did not conform to spec.
-- Spec failed --------------------

  ([... :clojure.spec.alpha/invalid ... ...] ...)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^

should satisfy

  any?

-- Relevant specs -------

:shadow.cljs.devtools.cljs-specs/bindings:
  (clojure.spec.alpha/and
   clojure.core/vector?
   shadow.cljs.devtools.cljs-specs/even-number-of-forms?
   (clojure.spec.alpha/* :shadow.cljs.devtools.cljs-specs/binding))

-------------------------
Detected 1 error
#2019-09-2021:40lilactownchanging clojure.spec.alpha/invalid to anything else alleviates the error 😵#2019-09-2021:54thhellerdo you have something reproducible? (condp = tag :clojure.spec/invalid :foo) works fine#2019-09-2021:55thheller(condp = :clojure.spec.alpha/invalid :foo :bar) this fails with the error?#2019-09-2021:56thhellerfails in clojure too though#2019-09-2022:07lilactownhm#2019-09-2022:07thhellerhmm (let [x :clojure.spec.alpha/invalid] x)#2019-09-2022:07thhellerseems like a bug 😛#2019-09-2022:08lilactown😬#2019-09-2022:19thhellerhttps://clojure.atlassian.net/projects/CLJ/issues/CLJ-1966 Created June 21, 2016, 4:02 PM 😞#2019-09-2022:22thheller@lilactown workaround: (def INVALID :clojure.spec.alpha/invalid) and then use INVALID in the condp#2019-09-2022:22lilactownthat works! thx#2019-09-2022:23thhellername is of course up to you 😉#2019-09-2022:26lilactown(def blame-alex-miller ...)#2019-09-2022:26lilactownjk jk jk#2019-09-2123:35mdhaney@thheller I just sent a PR to fix a problem with the latest versions of Expo. It’s a simple change, but without it things break with Expo 35 which was released a couple of days ago. Let me know if you have any questions or concerns.#2019-09-2205:51sogaiuis there a reason why shadow-cljs watch <build-id> seemingly compiles every time? is it possible to get it to not compile initially but just watch for changes if there's already something appropriate compiled?#2019-09-2208:32thheller@sogaiu it must always "compile" initially. if there is a cache it is mostly just loading the cache though.#2019-09-2208:33sogaiuthanks#2019-09-2208:34thhelleryou can see what exactly it is doing via shadow-cljs watch app --verbose#2019-09-2208:34sogaiuaha, will give that a try#2019-09-2208:36sogaiulots of cache reading and flushing 🙂#2019-09-2208:50sogaiui have an electron app setup with a :node-script build (main) and a :browser build (renderer). if i restart shadow-cljs (control-c and then invoke watch again), the renderer seems to be reachable again but not main (:node-script). is there something special i need to do to re-establish a connection to the js-runtime for main?#2019-09-2208:51thhellernot sure what you mean. if you really kill the shadow-cljs process ALL REPLs will be disconnected and not be able to reconnect again#2019-09-2208:51thhellerbut if you have a server instance running only one watch may have been killed?#2019-09-2208:51thhellerdepends on how you run things?#2019-09-2208:52thhellerif you start the watch did it say connected to server on startup?#2019-09-2208:59sogaiui start with: yarn shadow-cljs watch main renderer and after the builds complete, i launch the electron app from the command line. i don't see "connected to server" in the output. when i control-c for shadow-cljs, i see: shadow-cljs - Connection closed! in white text on a red background in the electron app when i subsequently start the watch with: yarn shadow-cljs watch main renderer, i see very similar output to the first time (including no "connected to server") if i issue control-r to the electron app, the devtools console of the electron app reports: shadow-cljs Websocket connected! and i am able to reconnect to a cljs-repl for renderer via the command line and succesfully evaluate code. however, i still see the white text on red background indicating "shadow-cljs - Connection closed!" and no successful connection to a repl for main's js-runtime.#2019-09-2209:01thhellerhmm is the page containing that error reloaded too?#2019-09-2209:01thhellermaybe thats just not reloaded so it doesn't remove the error?#2019-09-2209:02sogaiuwill check once again -- may be i was mistaken about the white text subsequent to the control-r issuing#2019-09-2209:04sogaiusorry, my mistake -- upon reloading, the white text on red background does go away. however, it is still the case that there is no successful connection to a repl for main's js-runtime.#2019-09-2209:04thhellerwell I suspect that the main isn't restarted if you control-r#2019-09-2209:05sogaiuyes, that makes sense. i guess i can just kill the app...i don't suppose there's a way around that.#2019-09-2209:05thhellerprobably need to restart electron if you restart shadow-cljs#2019-09-2209:05thhellerwhy do you restart shadow-cljs in the first place?#2019-09-2209:06sogaiui am guilty of not taking good notes regarding this. will try to do so.#2019-09-2209:22sogaiuah, i remember why i'm restarting -- it's because i'm testing tooling i'm making that works with shadow-cljs, and i'm testing it's ability to reconnect upon shadow-cljs restart 🙂#2019-09-2311:15DanI need a specific Babel preset that I have set in a local .babelrc file within a module's folder. I don't want Babel's default transformation of ES6 module syntax to commonjs, so have set it to false (https://babeljs.io/docs/en/6.26.3/babel-preset-env#modules). This doesn't seem to be working. Does shadow-cljs do any other transformation that would effect this?#2019-09-2312:04thheller@studio can you clarify what you are trying to do? "withing a module's folder" can mean many different things? is it in node_modules?#2019-09-2312:10DanI have decided to persevere with getting Storybook running - after researching it further, the issue is that Storybook is expecting ES Modules and Babel by default is using commonjs so there is a conflict. I have a custom babel config file (https://storybook.js.org/docs/configurations/custom-babel-config/#docs-content) but it doesn't seem to be getting picked up as there are still errors surrounding the use of default#2019-09-2312:16thhellerthat explains nothing sorry#2019-09-2312:16thhellershadow-cljs does not produce ES Modules. no matter how you configure it, babel isn't even involved in that part#2019-09-2312:17thhellercan you setup a sample project for this? maybe I can help if you show me some actual code#2019-09-2312:17thhellerbut it seems to me you are trying things that'll never work#2019-09-2312:18DanSure, I'll set up a quick repo now.#2019-09-2313:06Danhttps://github.com/danchristian/shadow-storybook-demo#2019-09-2313:07DanIt loads Storybook fine - if you change a string, like the buttons text, then it reloads and errors with can't redefine non-configurable property "default". It also loads "Default" as a story, which is wrong, there should only be one story which is "Normal".#2019-09-2313:09DanThis all seems to be related to how export default is treated.#2019-09-2313:14thheller> added 1084 packages from 869 contributors and audited 36312 packages in 113.036s#2019-09-2313:14thhellerisn't npm fun ....#2019-09-2313:43thheller> webpack built efa024dd49af14b30e80 in 70472ms#2019-09-2313:44thhellerand they complain that shadow-cljs is slow 😉#2019-09-2313:44thheller@studio I seem to have got it working#2019-09-2313:45Dan:face_with_monocle: How?!#2019-09-2313:45thhellerrequired changing some of the code generated by :npm-module#2019-09-2313:46DanWas it to do with Babel's modules?#2019-09-2313:47thhellerno#2019-09-2313:47thhellernot involved at all#2019-09-2313:47Dan😐#2019-09-2313:51DanWhat was the cause?#2019-09-2313:52thheller@studio try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ed9e858c89829ac08e81879eaddfc3d5c3d8db"}, :content ("[email protected]")}#2019-09-2313:58DanDoesn't error locally! Let me try on the full prod build with Reagent etc#2019-09-2313:58DanI'm unsure why it hangs around 69% for so long when building#2019-09-2314:04thhellerprobably processing the cljs.core. takes forever#2019-09-2314:09DanEverything seems to work, unless you change the name of the function: (defn ^:export normal [button] "Hello") (defn ^:export normalXXX [button] "Hello") this._data[id] is undefined Do you get that too? Changing anything else, the reload works as expected.#2019-09-2314:11thhellerdidn't try. no time to look into that sorry#2019-09-2314:12thhellerI would recommend staying as far away as possible from this#2019-09-2314:12thhellerit is always going to be a hack when used with CLJS#2019-09-2314:12DanFrom Storybook?#2019-09-2314:13thhelleryes#2019-09-2314:13DanCripes#2019-09-2314:13DanNot good news!#2019-09-2314:14DanI will have a think - thank you!#2019-09-2409:13uoslJust a tip: there are some clojurescript libs similar to storybook that could be worth checking out. https://github.com/bhauman/devcards https://github.com/nubank/workspaces#2019-09-2315:15mynomotoDoes anyone use jest with shadow-cljs? How do you setup the project?#2019-09-2318:11ennWhat does [:no-worker :app] mean when attempting to start a CLJS REPL for the build :app?#2019-09-2318:15thhellerthat the watch isnt running#2019-09-2318:20ennthank you#2019-09-2318:23mynomotoIs there some workaround for the dynamic import problem? https://github.com/thheller/shadow-cljs/issues/486#2019-09-2318:28thhelleryeah, don't use it 😉#2019-09-2318:30mynomotoWell it comes from a library, so forking it should be the best bet?#2019-09-2318:31thhellerhttps://github.com/google/closure-compiler/issues/2770#2019-09-2318:31thhellercan't do much until the closure compiler supports it#2019-09-2318:34mynomotoOk, thanks. Is this related or is it another kind of problem?
SHADOW import error /home/project/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$react_native.js
/home/project/node_modules/react-native/Libraries/Utilities/warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
      ^^^^^^^^^^

SyntaxError: Missing initializer in const declaration
    at new Script (vm.js:80:7)
    at createScript (vm.js:274:10)
    at Object.runInThisContext (vm.js:326:10)
    at Module._compile (internal/modules/cjs/loader.js:664:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
#2019-09-2318:35thhellerlooks to me like you are trying something that isn't supposed to work?#2019-09-2318:35thhellerie. importing react-native without metro?#2019-09-2318:37mynomotoThat would explain it, thanks. I wasn't aware that I could not import react-native without metro.#2019-09-2318:37thhelleryeah thats typescript or flow#2019-09-2318:38thhellerrequires preprocessing before you can run it. so metro.#2019-09-2318:38mynomotoI guess that this makes a lot more complicated testing react-native apps using shadow-cljs.#2019-09-2318:40thhellerdunno. how are they usually tested? shouldn't be much more complicated than those setups#2019-09-2318:41mynomotoI'm not sure either, I'm coming from the cljs side. For the look of what I read it involves lots of babel.#2019-09-2318:46thhellerI didn't look into testing react-native at all. if you have a reference example I can maybe tell you if its possible or not to get this going#2019-09-2318:56mynomotoOk, thanks. I think I have to do more exploration on the js side of this.#2019-09-2408:47g7sSo, I want to require a google closure compatible library and I see in the docs that there is no :libs option, so I just go ahead and :require as normal?#2019-09-2408:59thhelleryes, just put it on the classpath as normal#2019-09-2409:06thhellerthe closure library started using goog.module as well if you need a reference https://github.com/google/closure-library/blob/master/closure/goog/i18n/dateintervalsymbols.js#2019-09-2409:12thhellerI'm not sure this works with CLJS code though as that still uses the "old" goog.require and discards the return value#2019-09-2409:13thhellerso it might only work with the declareLegacyNamespace thing#2019-09-2409:21g7syeah I just checked and shadow doesn’t work with the new goog.module. I guess I have to switch to the old format until CLJS supports the new format.#2019-09-2409:22thhellercan you give me an example of what you tried?#2019-09-2409:22g7sofc#2019-09-2409:22thhelleryou could just use ES6 which works sort of fine#2019-09-2409:23thhellerdidn't spend much time on goog.module. seems like ES6 would be a better choice overall#2019-09-2409:25g7sIf I use ES6 will I get all the benefits of advanced closure compilation?#2019-09-2409:25thhelleryep#2019-09-2409:26thhellerbut there are rough edges when trying to import JS from npm in ES6 code#2019-09-2409:26thhellerso you might be better of using the old format#2019-09-2409:26thhellerwell .. can't import from npm at all there#2019-09-2409:26thhellerso depends on what you really need 😛#2019-09-2409:26g7sFor the specific use case I do not want to import anything from npm#2019-09-2409:26g7sso I guess it is fine#2019-09-2409:27g7sSo the question is why google uses goog.module in the first place instead of just using es6?#2019-09-2409:27donavanMorning 🙂 I assume there is a way to exit the build when there is an exception during the build but I can't seem to find it. Am I missing it in the docs somewhere?#2019-09-2409:28thhellerexit a build?#2019-09-2409:29donavanYeah, we had an exception thrown during a hook invocation but shadow cli exited with a 0 so our CI job didn't fail#2019-09-2409:35thhelleryes, exceptions in hooks are caught and logged#2019-09-2409:35thhellerthey aren't supposed to throw 😉#2019-09-2409:36thhellerwhat are you doing that you want to throw?#2019-09-2409:39donavanAh ok, well we pushed a bug in a supporting library that trickled down to some missing config in the shadow build and didn't catch it in CI. We thought we were just missing some piece of config or the correct cli args to get the build to fail fast. We can add in some detection on our side. Thanks!#2019-09-2409:41thhellerI could totally remove this restriction and let hooks throw#2019-09-2409:42thhellercan't remember why I added that in the first place#2019-09-2409:44donavanI personally think it would be better if exceptions thrown in during any build stage caused the build to exit with a non-zero status; perhaps when passed a cli flag so as to not effect current behaviour?#2019-09-2409:53thhelleragreed. try {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "abd8c3cacfc4dc86c8c7c1d8eb998593859e9c"}, :content ("[email protected]")} it should properly fail if a hook fails#2019-09-2409:54donavanAwesome, will do#2019-09-2410:08donavanThanks, that works perfectly#2019-09-2409:27g7sI mean if advanced compilation works#2019-09-2409:28thhellerhistoric reasons. ES6 didn't exist when goog.module was introduced#2019-09-2409:28thhellerclosure compiler didn't support ES6 for a long time#2019-09-2409:29g7sI see.. still their styleguide mentions nothing about ES6 only goog.module#2019-09-2409:29g7sOk thanks for the info 🙂#2019-09-2409:30g7sTo give you a hint of the test I did was to define a goog.module such as this#2019-09-2409:30g7s
goog.module('test.Foo');

class Foo {
    /**
     * @param {string=} a
     */
    constructor(a) {
        /**
         * @type {string}
         */
        this.a = a || "G7S";
    }

    /**
     * @return {string}
     */
    say() {
        return "Hello " + this.a;
    }
}


exports = Foo;
#2019-09-2409:31g7sand then :require it in a cljs namespace#2019-09-2409:31g7sbut returns undefined#2019-09-2409:31g7sswitching it to goog.provide works as expected#2019-09-2409:32thheller
goog.module('demo.googClass');
goog.module.declareLegacyNamespace();

class Foo {
    /**
     * @param {string=} a
     */
    constructor(a) {
        /**
         * @type {string}
         */
        this.a = a || "G7S";
    }

    /**
     * @return {string}
     */
    say() {
        return "Hello " + this.a;
    }
}

exports.Foo = Foo;
#2019-09-2409:32thheller[demo.googClass :refer (Foo)]#2019-09-2409:32thhellerthis works fine#2019-09-2409:33thheller(changed the name to fit into my shadow-cljs dummy test namespaces)#2019-09-2409:37g7sYeah I see that it works with the declareLegacyNamespace thing#2019-09-2409:38g7sI will either use this for now or migrate to es6#2019-09-2409:38g7sthanks again for your help!#2019-09-2409:39thhellerin case you are interested#2019-09-2409:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/es6.js#2019-09-2409:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/browser.cljs#L14#2019-09-2409:41thhelleres6 should mostly work without tricks#2019-09-2409:43g7sthanks this is helpful#2019-09-2413:25mynomoto@thheller it turned out that using the :npm-module target and running jest on the test files did the trick for testing snapshots for react-native components. shadow already supports it, thanks!#2019-09-2415:49jimberlageAnyone know what I need to do to get a test picked up by shadow-cljs? I have a file, test/my_project/core_test.cljs, and in shadow-cljs.edn I have :source-paths ["src" "test"], as well as a build defined as {:test {:target :node-test :output-to "unit-tests.js" :autorun true}}. However, when I go to run shadow-cljs release test, I see
[:test] Compiling ...
========= Running Tests =======================

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (27 files, 1 compiled, 0 warnings, 4.51s)
#2019-09-2415:49jimberlageThere’s a deftest statement in the test file, with two assertions.#2019-09-2415:50thhellerdid you restart after changing source-paths?#2019-09-2415:51jimberlageYup#2019-09-2415:51thhellerno other warnings on startup?#2019-09-2415:52jimberlageI fat-fingered shadow-cljs restart. My bad. Thanks for the help though!#2019-09-2416:04jimberlageAlthough when I do run tests, I get an error like this:
/Users/jberlage/toto/node_modules/react-native-keychain/index.js:2
import { NativeModules, Platform } from 'react-native';
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:872:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at /Users/jberlage/toto/unit-tests.js:750:684
    at Object.<anonymous> (/Users/jberlage/toto/unit-tests.js:842:3)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
Regression, or should I just lose the :node-test target entirely for react-native projects? The tests are limited to stuff that would compile and run on node, but perhaps I can’t avoid importing something that will break.
#2019-09-2416:05thheller@jimberlage ask @mynomoto he got tests running for react-native. no clue whats involved. I only know that they can't run directly in node without compilation#2019-09-2416:05jimberlageGotcha#2019-09-2416:05thhellersee the comment above about jest#2019-09-2417:26Drew VerleeSo a npm package i need to use is including (what seems to be) compiled javascript in the main js file. They then used that compiled js in the package. 1. Any idea's why someone would handle deps that way? 2. Any idea why it would interfere with importing the package? Prior to removing it, i couldn't import the package correctly.#2019-09-2417:39thhellerdo you have an example? sounds a bit abstract to me?#2019-09-2417:49thhelleris it using dynamic import()?#2019-09-2420:03Drew Verleethanks, ill grab u an example in a bit#2019-09-2417:31arohnerUsing shadow.cljs.devtools.api, is there a way to get the number of build warnings? I would like to assert they’re zero#2019-09-2417:33thhellerwould warnings-as-errors help? Antonio asked for that a while ago but I forgot about it#2019-09-2417:33thhelleryou can in theory get the warnings but the API isn't pretty#2019-09-2417:35arohneryeah, warnings-as-errors would work#2019-09-2417:36arohnerhow do I do that?#2019-09-2417:36arohnerI see config in shadow-cljs and clojurescript compiler to ignore warnings, but not to treat them as errors#2019-09-2417:37thhelleryeah thats not in yet but I have a few minutes so should be easy to add#2019-09-2417:47thheller@arohner @anmonteiro {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "53203b32373c247e303f392013617d6b7d666b"}, :content ("[email protected]")} adds :compiler-options {:warnings-as-errors true} or :compiler-options {:warnings-as-errors #{:undeclared-var}} to only error out on specific ones#2019-09-2417:47anmonteiro🎉#2019-09-2417:48anmonteirothat’s awesome, thanks#2019-09-2417:48thhellershould have opened a ticket. I forgot about it completely 😛#2019-09-2417:48anmonteiro@thheller that reminds me, we were seeing an issue yesterday that I wanted to talk to you about#2019-09-2417:48anmonteiroan NPM package ended up in our 2nd bundle and it errored out because $jscomp wasn’t in scope#2019-09-2417:49anmonteirothe reason being we have :output-wrapper true in the main bundle so $jscomp is never in the global scope#2019-09-2417:49anmonteirois this expected? I thought :output-wrapper true could work with modules?#2019-09-2417:50thhellerhmm an npm package shouldn't end up using $jscomp#2019-09-2417:51thhellerit likely just wanted to use $jscomp but :advanced compilation got rid of it or renamed it#2019-09-2417:51thhellerpolyfills are currently a bit ugly since it still does the separate compilation steps#2019-09-2417:52thhellerdo you know which npm package wanted to access $jscomp?#2019-09-2417:55lilactownI had a gcc module that had errors referring to $jscomp the other day#2019-09-2417:56lilactownclearing out my build output seemed to fix it - this was in the middle of moving from figwheel to shadow so not sure what the actual cause was#2019-09-2417:59thhellerhmm there might be problems with polyfills and caching? polyfills aren't handled very cleanly currently#2019-09-2418:59David Pham@thheller did you ever work with graaljs?#2019-09-2419:04thhellerI did a few experiments yes but no actual use#2019-09-2419:00anmonteiro@thheller sorry dropped the ball on this#2019-09-2419:01anmonteirouh it was an NPM package that needed a polyfill#2019-09-2419:01anmonteirothat’s what it was#2019-09-2419:01anmonteirohttps://github.com/dchest/tweetnacl-js#2019-09-2419:01anmonteirothis is the package#2019-09-2421:41anmonteiro@thheller another question I have regarding treating warnings as errors (I haven’t gotten around to trying it yet): I assume a warning in a third party dep won’t fail my build?#2019-09-2421:41anmonteirojust warnings in our own code#2019-09-2421:59thhellerno any warning will fail#2019-09-2421:59thhellerI could add a flag though#2019-09-2422:00anmonteirothat’d be helpful - I think we have deps that warn right now that we can’t upgrade#2019-09-2422:01thhelleropen an issue so I don't forget please#2019-09-2422:01thhellerabout to head to bed#2019-09-2422:20anmonteirowill do#2019-09-2509:44thheller@anmonteiro any suggestion on how to name such an option? I fail to come up with a name. I'm thinking about something that lets you "ignore" warnings in specifc namespaces so :something #{ns.with.warnings} wouldn't error out for warnings in that ns. could allow wildcards like some-lib.*.#2019-09-2515:44anmonteiro:warnings-as-errors {:ignore #{ns.*} :warning-types #{:undeclared-var}}#2019-09-2515:44anmonteiromaybe?#2019-09-2515:46thhelleryeah probably best that way#2019-09-2607:29rap1dsWould it make sense to add a top-level config, something like :ignore-warnings-in-ns #{ns.*} instead of adding the :ignore in :warnings-as-errors? We also have a dep that causes warnings and we can't really do anything about them, so I'd prefer just to ignore those warnings altogether and then let all other warnings throw errors.#2019-09-2607:53thhellerI was thinking about adding something like :defaults {:compiler-options ...} at the top level. so config that applies to all builds#2019-09-2617:08joshkhgiven the popularity of react-bootstrap, i'm hoping someone can help. when i require react-bootstrap:
(ns myproject.core
  (:require ["react-bootstrap" :as bs]))
i get the following runtime exception:
TypeError: (0 , _uncontrollable.default) is not a function
i think last time i asked about this error regarding another npm module, the cause had to do with a transitive dependency conflict?
#2019-09-2617:09thhelleryes, that is caused by a version conflict#2019-09-2617:09joshkhi've tried with both 0.8.0 and 0.9.0-rc1 in my shadow-cljs.edn :dependencies#2019-09-2617:10thhellerhmm?#2019-09-2617:10joshkhhmm. and like last time, triggering a hot-reload fixes the problem#2019-09-2617:11thhellerthats a version conflict on the npm package not the CLJS side#2019-09-2617:11thhellerso package.json#2019-09-2617:12miguelbHi everyone, still relatively new to cljs and shadow but I just wanted to confirm something, given this code:
(ns demo.foo)
(defn hello [who]
  (str "Hello, " who "!"))
(defn generate-exports []
  #js {:hello hello})
and this config
:builds
 {:lib {:target      :node-library
        :output-to   "package/lib.js"
        :exports-fn  demo.foo/generate-exports}}
and this command: shadow-cljs release lib I’m getting a “lib.js” size of 98k. Does that seem right?
#2019-09-2617:12joshkhgot it. and i think last time you said there's no easy solution, as juggling multiple versions on the NPM side is crazytalk#2019-09-2617:13joshkh@miguelb that's pretty small all things considered, and way smaller when automatically gzipped by the server/browser.#2019-09-2617:17thheller@miguelb yes. there isn't much use in checking the size of dummy code since most of it is cljs.core and stuff#2019-09-2617:17thhellerthink of it like that lib included immutable-js + lodash or so#2019-09-2617:19miguelbah ok, I’m starting to evaluate writing libraries in cljs for use at work so I wanted to see how much overhead I would be bringing along#2019-09-2617:20miguelb@joshkh @thheller thanks again for the input#2019-09-2617:22joshkh@thheller i think last time you did some digging on my behalf. any advice for identifying the conflict myself?#2019-09-2617:24lilactown@miguelb IMO writing libs in CLJS for JS is not tenable right now, exactly because most of the time you don’t want the overhead of CLJS core data structures and standard library in your library code#2019-09-2617:25joshkh^ even when the target is a nodejs library? is 98kb a big deal server-side?#2019-09-2617:25miguelbsorry, not server side#2019-09-2617:26miguelbit would be for browser#2019-09-2617:26miguelbthough none of the libraries I was thinking about doing have any browser specific in them.#2019-09-2617:27lilactown@joshkh even for Node.js I would ask: why? writing libraries in CLJS is not it’s forte#2019-09-2617:27lilactownI’m often far more tempted to write libs in JS and a small wrapper in CLJS, than the other way around#2019-09-2617:28lilactownCLJS and it’s standard library and data structures really only shine in application development#2019-09-2617:32joshkhthanks for sharing, and i do agree that writing one-off cljs libs for any js based project is not ideal.#2019-09-2617:33lilactownit’s tough when you want to transition to using Clojure but your app is written in JS already#2019-09-2617:33joshkhthat being said i've had success replacing large portions of js based projects with self contained cljs projects, but they were full apps with their own api, and ended up being the same file size in the end.#2019-09-2617:33miguelb@lilactown that’s exactly the situation i’m in#2019-09-2617:47thheller@lilactown I disagree. you can write libraries pretty well in CLJS. just not those typical micro libraries with one function in them. writing something bigger that would bring in something like immutable-js+lodash etc in JS wouldn't be much different.#2019-09-2617:49lilactownyeah I wouldn’t adopt a library that brought in immutable.js or (probably) lodash either. IMO those are app-level abstractions that aren’t really useful in a library#2019-09-2617:50lilactownit’s the same as a library including core.async. Don’t do that to me! I’ll use core.async in my app and bridge the gap if I need your lib, or maybe install a peer lib that provides that interop#2019-09-2617:53thhellercore.async I agree but for me that pretty much also counts for Promise stuff#2019-09-2617:53thhellerI can totally see big libs using immutable-js or so internally. like a database implementation or something like apollo#2019-09-2617:53thhellerstuff that exposes a "normal" API and just does a lot of stuff behind the scenes but doesn't actually expose immutable-js to the outside#2019-09-2617:56thhellerbut overall it is best to use CLJS for CLJS and don't do too much JS 😉#2019-09-2617:56lilactownhehe#2019-09-2617:56lilactownI borderline agree for those larger libs#2019-09-2617:57lilactownsomething like immutable-js (or CLJS’ data) is likely to be too general purpose for a lot of cases too#2019-09-2617:57lilactownbut the scale does start to tip in the favorable direction I agree#2019-09-2617:57miguelbso is there hope to gradually changing over a larger JS app with CLJS?#2019-09-2617:59thhellerdepends on what you are changing from. if you have to go back and forth all the time it probably isn't worth it#2019-09-2617:47thhellerthe problem only comes when you include multiple of those libs in one JS project#2019-09-2617:48thheller@joshkh if you wouldn't mind asking that question again somewhere others can find it too (http://ask.clojure.org, stackoverflow or so)#2019-09-2617:49thhellerI can give you some hints how to track it down#2019-09-2617:50joshkhgreat idea, and thanks @thheller. i was already finding it frustrating not being able to find my previous question on slack.#2019-09-2617:50thhellerindeed. I know I tracked it down last time but also can't remember#2019-09-2618:09joshkhfor when (if ever) you find the time, thanks again @thheller https://ask.clojure.org/index.php/8665/compiling-shadow-projects-transitive-dependency-conflicts#2019-09-2618:56kanweiTrying to get react-select to work but it's not#2019-09-2618:56kanwei
/js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$$emotion$core$dist$core_browser_cjs
shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:36
shadow$provide.module$node_modules$react_select$dist$react_select_browser_cjs @ /js/cljs-runtime/module$node_modules$react_select$dist$react_select_browser_cjs.js:3
shadow.js.jsRequire @ /js/cljs-runtime/shadow.js.js:34
shadow.js.require @ /js/cljs-runtime/shadow.js.js:55
eval @ /js/cljs-runtime/doublethedonation.integrations.records.js:9
goog.globalEval @ mp360.js?updated=20190805:827
env.evalLoad @ mp360.js?updated=20190805:2174
(anonymous) @ mp360.js?updated=20190805:2633
/js/cljs-runtime/shadow.js.js:36 shadow-cljs - failed to load module$node_modules$react_select$dist$react_select_browser_cjs
#2019-09-2618:59thhellermight be the same problem I just described here https://ask.clojure.org/index.php/8665/compiling-shadow-projects-transitive-dependency-conflicts?show=8666#a8666#2019-09-2619:02joshkh(and thanks for the response!)#2019-09-2619:02thhellerreact-select loads fine for me, so most likely a version conflict with some other lib you have#2019-09-2619:05kanweiit seems to be failing on emotion/core but nothing else uses it#2019-09-2619:05kanweii'll mess around#2019-09-2619:05thhellerwhere is the rest of the error? there should be more?#2019-09-2619:06thhellerie. actual exceptions? not the yellow parts in the console log?#2019-09-2619:24kanweiok it had to do with the fact that inferno-compat doesn't have React.createContext#2019-09-2619:26kanweibut now when i require ["react-select" :refer [Select]]#2019-09-2619:26kanweiand do
[:> Select {:options [{:value "Chocolate" :label "Chocolateee"}]}]
#2019-09-2619:26kanweiit's creating
<undefined options="[object Object]"></undefined>
#2019-09-2619:54thhellerwell you are on your own if you use custom setups like inferno and stuff#2019-09-2619:55thhellerdon't know anything about react-select. you might need to pass more options?#2019-09-2619:56thhellerand dunno if reagent converts converts nested props?#2019-09-2619:56thhellermight need clj->js?#2019-09-2620:07kanweihad to use ["react-select" :default Select]#2019-09-2620:09kanweijavascript is mad confusing#2019-09-2620:19thhelleryeah and it'll get worse before it gets better 😞#2019-09-2620:20kanweihttps://darongmean.com/post/react-native-cljs-es6-import-export/#2019-09-2620:20kanweioh it's from https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages nice#2019-09-2701:11jmmkOn https://shadow-cljs.github.io/docs/UsersGuide.html, it states > It is not recommended to separate source files by extension (eg. src/clj, src/cljs, src/cljc). For some reason this is widely used in CLJS project templates but it just makes things harder to use. But as soon as I did this, shadow-cljs started trying to compile my .clj and failed due to different dependencies under different profiles. What's the advantage of not splitting them? Why does splitting "make things harder to use"?#2019-09-2707:05thhellershadow-cljs never compiles .clj files? it only loads them when they are used as macros?
#2019-09-2707:07thheller"harder to use" is subjective of course but macros tend to become annoying IMHO. they are written as .clj files yet are meant for CLJS. so do you put them in src/clj or src/cljs or src/cljc?#2019-09-2707:08thhelleryou can of course split things into src/frontend src/backend or whatever. I just don't like splitting by file extension. feels pointless IMHO.#2019-09-2713:37jmmk@thheller I figured out what it was: user.clj is picked up by shadow-cljs, and mine included other .clj files#2019-09-2713:44thhellerit is picked up by clojure, shadow-cljs can't do anything about that#2019-09-2703:34dpsuttonat work we serve our product through figwheel and some custom networking setup so its ssl and a local domain. however figwheel's websocket happily goes over . I'm having trouble setting up a similar situation with shadow. Is this possible?#2019-09-2707:16thhelleryou can configure :devtools {:devtools-url ""} in the build config#2019-09-2707:16thhellerthat should make it connect to unless you enable SSL in shadow-cljs?#2019-09-2707:17thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2019-09-2707:17thhellerdoesn't have to be a proxy so I should probably adjust those docs a bit 😛#2019-09-2704:12dpsuttonseems you can't specify a different host for the ws. also hitting a lot of errors like failed to load aclaimant.dashboard_v2.pages.tasks.list.js TypeError: re_frame.std_interceptors.fx_handler__GT_interceptor is not a function#2019-09-2707:31thhellernot sure what this might be about? maybe just load ordering? ie. the tasks.list ns not properly requiring re-frame.std.?#2019-09-2706:28vinursthe 2.8.58 version show this when auto reload#2019-09-2707:09thheller@haiyuan.vinurs auto reload done by react-native/expo or shadow-cljs?#2019-09-2707:11vinursshadowcljs#2019-09-2707:11thhellerbut only the second part of the error message is from CLJS#2019-09-2707:11thhellerRequiring module "build/index.js", which threw an exception:#2019-09-2707:12thhellerthis part is not from the hot-reload in shadow-cljs#2019-09-2707:12thhellerso something else must be triggering that load?#2019-09-2707:13vinurssorry#2019-09-2707:14vinursi found that i enable the react-native autoload#2019-09-2707:14vinurshot-reloading#2019-09-2707:15vinurs^_^ok now#2019-09-2713:08Daniel LeongIn what situation would shadow-cljs give this error?
Module Entry "wish.worker.core" was moved out of module ":worker".
It was moved to ":app" and used by #{:app :worker}.
#2019-09-2713:17thheller@dhleong88 you likely specified wish.worker.core and the entry for the :worker module. But something from the :app module also did a direct require for wish.worker.core.#2019-09-2713:17thhellerso (:require [wish.worker.core ....]) somewhere#2019-09-2713:17thhellercode splitting doesn't allow that#2019-09-2714:02Daniel LeongNope, it’s totally isolated. I’m converting an existing project from leiningen#2019-09-2714:03thhellerit doesn't have to be a direct require#2019-09-2714:03thhellercould be ns.a -> ns.b -> wish.worker.core#2019-09-2714:03thhellersomething in the chain somewhere requires it#2019-09-2714:03Daniel LeongCould doing something at the repl cause it? My tooling uses load-file and such#2019-09-2714:03Daniel Leong
☁  wish [dhleong/shadow-cljs] ag wish.worker.core
shadow-cljs.edn
44:                          :worker {:entries [wish.worker.core]

project.clj
136:     :compiler     {:main                 wish.worker.core
146:     :compiler     {:main                 wish.worker.core

src/cljs-worker/wish/worker/core.cljs
1:(ns wish.worker.core
It’s not required anywhere
#2019-09-2714:04thhellerREPL could cause this yes but not when it is happening right when the build is first started#2019-09-2714:05Daniel LeongOkay, sorry I should have clarified. A fresh server stop/start resolves it, it just occurs sometimes if I’m working on the worker#2019-09-2714:06Daniel LeongHow might I avoid creating this association? Is the only way to clean it up when made restarting the server?#2019-09-2714:07thhellerthis would happen if you are in say in your main ns (in-ns 'wish.main) and then do (require '[wish.worker.core :as x])#2019-09-2714:11thheller(probably. don't actually know)#2019-09-2714:13Daniel LeongHmm alright good to know, thanks. Hopefully I can figure out what my tooling is doing and avoid that#2019-09-2714:17Daniel LeongHere’s an unrelated proposal: how would you feel about some mechanism to ask the client to try to reconnect to the server? I see in the code that you don’t want to auto-reconnect because the server config may have changed, but for example if I just close my laptop lid I get disconnected; the server is still running and I know it hasn’t changed, but right now I still have to reload the page to reconnect#2019-09-2714:19thhelleryou can probably just call shadow.cljs.devtools.client.browser.ws_connect(); in the browser console#2019-09-2714:19Daniel LeongAwesome. Thanks!#2019-09-2714:21Daniel LeongOkay last one (sorry for the barrage): is there a way to suppress warnings from dependencies? specter, for example, produces:
------ WARNING #2 - :undeclared-var --------------------------------------------
 Resource: com/rpl/specter.cljc:1275:19
 Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------

------ WARNING #3 - :undeclared-var --------------------------------------------
 Resource: com/rpl/specter.cljc:1288:19
 Use of undeclared Var com.rpl.specter/java
--------------------------------------------------------------------------------
#2019-09-2714:21thhellerupgrade specter?#2019-09-2714:22thhellerhttps://github.com/redplanetlabs/specter/issues/280#2019-09-2714:22thhellerhmm it might not actually be fixed yet. can't tell#2019-09-2714:24thhellerthere is no way to suppress those warnings. don't actually want to do that since it actually produces bad code that should be fixed#2019-09-2714:25Daniel LeongAlright, I suppose that’s fair. Thanks again!#2019-09-2719:40isak@thheller What about if it is just something like 'you're shadowing uuid from clojure.core'? The problem is even if it is bad practice/bad code/whatever, the person using the dependency may not be in a good position to get it fixed, and then this behavior is just training them to ignore all warnings, because it is 90% spam from dependencies.#2019-09-2719:44thheller@isak you can turn off specific warnings via :compiler-options {:warnings {:that-type false}}#2019-09-2719:44thhellerbut its still spam that should be fixed#2019-09-2719:45thhellerwhats the point of warnings if everybody ignores them#2019-09-2719:48isak@thheller ok, good to know. I agree it should be fixed, but if the person reading the warning is powerless to do so, it seems like there'd be a lot of cases where it is not worth seeing every time#2019-09-2719:53isakIn most static languages I've tried, you never see compilation warnings triggered by your dependencies. It seems to be kind of a default with dynamic languages, seems pretty strange to me.#2019-09-2719:53dpsuttonI imagine go has similar things? Consuming does as source versus artifact I suppose#2019-09-2719:55isakYou're probably right, though it might be kind of a special case, because doesn't it do stuff like refuse to compile if you have an unused import?#2019-09-2719:59thhellerwell in the case of java or so you don't actually have the source so you aren't compiling that#2019-09-2720:00thhellerif anyone has suggestions I'm totally willing to change stuff#2019-09-2720:00thhellerbut I also know if I add the option to ignore warnings thats the first thing people will enable by default#2019-09-2720:00thhellerjust like lein clean is the default fix all#2019-09-2720:01thhellerwarnings are also kinda weird in CLJS since some of them should definitely be errors#2019-09-2720:01thhellerand some of them are probably ok and can be ignored#2019-09-2720:02isakFor java, you could call it an implementation detail, no? I mean if compiling .java files as as fast as reading the .class files, I don't expect people would normally care what happened under the hood. Though if that switch were made I don't think they would cheer about getting warned about "your dependency foo has an unused variable in this file", for example#2019-09-2720:03isakyea, you are right. Maybe it is hard to have a good solution as long as that is the case with CLJS.#2019-09-2720:16thhellerwell the best path is to fix the warnings. they are there for a reason after all.#2019-09-2720:16thhellerproblem is that normal CLJS doesn't warn in some cases. doesn't mean the code is correct just nobody knows.#2019-09-2720:17thhellerand since only shadow-cljs warns people often don't seem to care much#2019-09-2720:18dpsuttonattempting to switch from figwheel to shadow revealed quite a few warnings in our code and bidi#2019-09-2721:01rafaeldelboniIs normal the npm / clojar versions being different? Right now we have 2.8.58 / 2.8.59, I’m trying to use the new prepl support#2019-09-2721:12thheller@rafaeldelboni oh. pushed 2.8.59 to npm. forgot to push again. npm was failing when I tried pushing last time#2019-09-2721:23rafaeldelboniThanks!#2019-09-2905:10markxHi! Has anyone used weavejester/impi with shadow-cljs? I’m a little lost about the setup of pixi.js#2019-09-2905:17markxAlso something I’m confused about but maybe not related to shadowcljs: impi depends on [weavejester/pixi "4.2.3-0"], which I think should be from cljsjs, but why it’s a separate package in clojars? I mean, there’s already a cljsjs/pixi on clojars, then why do we need another weavejester/pixi?#2019-09-2905:23markxmaybe @weavejester would know? ☝️#2019-09-2906:26markxAh I found out how to!#2019-09-2907:55thheller@markx https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2019-09-2910:01pezIs there a way to get shadow-cljs to only update dependencies and not run anything?#2019-09-2910:02thhellershadow-cljs classpath should do the trick in newer versions#2019-09-2910:02pezHow new? 😃#2019-09-2910:03thheller2.8.53+#2019-09-2910:03pezHaha, I had 52. Thanks! Will try now.#2019-09-2910:04pezAwesome. Seems to be exactly what I needed.#2019-09-2911:28hmaurerHello! Is it possible to generate a NPM library with exports with shadow?#2019-09-2911:32thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library#2019-09-2911:46martinklepschI’m having a strange issue where I get Unresolved var p/alet (https://github.com/funcool/promesa/blob/3.0.0/src/promesa/core.cljc) in one build but in another build where I’m also using that macro there is no warning.#2019-09-2911:47thhellermaybe a different promesa version?#2019-09-2914:08martinklepsch😅 indeed …. wrong branch, that didn’t have the newest version#2019-09-2914:54thedavidmeister@thheller any idea why cljs.nodejs.require = require; would appear in a compiled file when the target is :karma?#2019-09-2915:25thedavidmeisternm i figured it out#2019-09-2917:06thhellerthats the cljs.nodejs ns#2019-09-3016:41firstclassfuncHey guys, checking here before I go off on a deep dive, has anyone been able to create https://nodered.org/ modules with shadow-cljs?#2019-09-3017:26ssdevHello all. I'm trying to modify a shadow-cljs pipeline to reload the browser when some sass is compiled into css. I'm attempting to use the watch-dir feature but so far it hasn't worked. If I manually reload the browser, I see the change, but the watch-dir command doesn't seem to pick it up. Am I missing anything?
:main {:target :browser
                        :asset-path "/js/main"
                       :modules {:main {:entries [demo.client]}}
                       :devtools {:watch-dir "resources/public/styles"
                                         :after-load demo.client/restart
                                           :preloads [fulcro.inspect.preload demo.development-preload]}}
#2019-09-3017:38thheller@ssanders you likely want :watch-dir "resources/public" as the path your css uses is likely /styles/foo.css#2019-09-3017:38thheller@gary001 from the looks of it :node-library should suffice#2019-09-3017:52ssdevAh yes, that was it. Thought I tried that... Thanks @thheller#2019-09-3018:08Saikyun@thheller sometimes when saving then running (shadow.cljs.devtools.api/watch-compile! :app) quickly it seems like it compiles using "old" code. is there a function I could call to force it to use "fresh" sources?#2019-09-3018:09thheller(Thread/sleep 500)? 😛#2019-09-3018:10Saikyunhaha :'D#2019-10-0101:54knubieis it possible to stop a watch from the clj-repl?#2019-10-0104:07lilactownstop-worker#2019-10-0101:55knubiewithout stopping the server#2019-10-0102:36knubie(unrelated:) what does it mean when i :require an NPM module and it results in an empty js object?#2019-10-0102:58knubiesomehow i got the require to work by going into the node_modules directory of that package and touching the main js file, thereby trigger a recompile#2019-10-0103:04knubieok but now all of the other files it's requiring are null#2019-10-0103:34knubieI think I figured out the issue, that module was for node and I was trying to run it in the browser#2019-10-0208:58Abhinav SharmaHello everyone, Background I have a question regarding the way shadow-cljs handles browser connections - I experimented with connection an app to chromium and firefox, the chromium app was the one running, when I did (shadow/repl :main) and later I opened the same localhost in the firefox one. Curiosity I was wondering whether there’s a way to inspect the network calls in both browsers. From my initial experimentation it seems that the level of integration is definitely tighter with the first browser where I connected with (shadow/repl :main). I read the shadow-cljs user guide but couldn’t find any config as such - please let me know if it’s possible or not.#2019-10-0208:59thhellernot really sure what you are asking. the REPL only ever talks to one browser (typically the first one connected).#2019-10-0213:22Abhinav SharmaHi @U05224H0W, That is what I concluded as well, I was just curious whether it was possible to replicate the same session in two browsers or not.#2019-10-0213:47thhellerno it is not. too many things that could go wrong if they connect at different times and miss a command or so#2019-10-0214:50Abhinav SharmaHmm, interesting. Thanks for the clarification @U05224H0W :+1:#2019-10-0209:02thhellerso if you triggered the request from the REPL then only one browser will do that request#2019-10-0218:00lilactownI’m getting an error when trying to use a goog JS namespace again:
Uncaught ReferenceError: $jscomp is not defined
    at statsBar (stats_bar.js:13)
    at Constructor.eval (d3.cljs:25)
    at Constructor.reagent$impl$component$custom_wrapper_$_componentDidMount (component.cljs:189)
    ...
#2019-10-0218:01lilactownThe offending file#2019-10-0218:01lilactownthe stacktrace is pointing at line 13 where it refers to getRequiredKey#2019-10-0218:09thhelleruhm thats not how you write goog namespaces. please write plain ES6 instead.#2019-10-0218:09thhellerpolyfills probably aren't injected properly if you write ES6 code this way#2019-10-0218:09thhellerie. it fails because of how GCC rewrote const [width, height] ... (probably)#2019-10-0218:10thhelleror just set :output-feature-set :es6 or up so it doesn't rewrite those at all#2019-10-0218:10thhellerthen it doesn't require polyfills#2019-10-0218:20lilactownI’ll give that a shot#2019-10-0218:20lilactownmoving this from lein-figwheel. I think it had the output set to es6 and I probably didn’t do the same in my shadow config#2019-10-0218:21thhellerCLJS or figwheel won't process those files at all in dev#2019-10-0218:21lilactownahh#2019-10-0218:21thhellerso you likely just lived without polyfills#2019-10-0218:21thhellerbut be careful if you write the files like that#2019-10-0218:22thhellersince statsBar and getRequiredKey will actually be global functions#2019-10-0218:22thhellerthey aren't namespaced so would conflict with any other code#2019-10-0218:22thheller(if you have others declaring var or so)#2019-10-0218:22lilactownI’ll make a note#2019-10-0218:23lilactownnot code I wrote, will probably migrate to CLJS at some point#2019-10-0218:24thhellerI'm not entirely sure why the $jscomp polyfills are missing though. they should be added#2019-10-0218:34lilactownmaybe an ordering issue?#2019-10-0218:34lilactownbut it isn’t executing until I switch to the screen with the graphs, so that doesn’t make sense to me#2019-10-0218:35thhellerwell it would only happen if the statsBar function is called#2019-10-0218:47lilactownhmm, I’m still getting the same error after changing compiler options#2019-10-0218:48lilactown
{:target :browser
                :modules {:main {:entries [amperity.web.dev
                                           amperity.web.prod]}}
                :output-dir "resources/public/js/compiled/"
                :asset-path "js/compiled/"
                :compiler-options {:language-in :es6
                                   :output-feature-set :es6
                                   :devcards true}
                :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true
                                        "day8.re_frame.tracing.trace_enabled_QMARK_" true}}
                :preloads [day8.re-frame-10x.preload
                           devtools.preload]
                :external-config {:devtools/config {:features-to-install
                                                    [:formatters :hints :async]}}}
#2019-10-0218:53lilactownstatsBar is still getting compiled to: var $jscomp$destructuring$var0 = $jscomp.makeIterator(getRequiredKey(options, "dimensions"));#2019-10-0219:00lilactownclearing out my build cache fixed it #sorrynotsorry#2019-10-0309:05thhellerhttps://github.com/thheller/shadow-cljs/commit/efd7d443ce7735405e41994543c37cb25189b367#2019-10-0309:05thhellershould be fixed in future releases#2019-10-0316:18lilactown❤️#2019-10-0219:01thhelleroh yeah the cache might not be invalidated properly for those files#2019-10-0219:01thhellerit kinda presumes that the only closure JS files are from the closure library which won't change 😛#2019-10-0219:02lilactownmakes sense#2019-10-0221:29isakIs it possible to access state gathered via compilation (e.g., a macro that writes to an atom) right before the build finishes and the information is (possibly) discarded?#2019-10-0221:48lilactown@isak are you talking about during when you have a watch running, or during a release build?#2019-10-0221:56isak@lilactown this is during a release build#2019-10-0222:20lilactownI’m not sure#2019-10-0222:21lilactownwhat are you trying to do exactly?#2019-10-0222:31isak@lilactown I'd like to make a translation function/macro that automatically makes the texts/text-ids available for translation (by upserting them to a database)#2019-10-0222:32isakSimilar to this library for elixir: https://github.com/elixir-gettext/gettext#2019-10-0222:44lilactownfirst knee-jerk hacky way would be to write to a file during macro time and then after compilation, have a script that does the upsert#2019-10-0222:45lilactownbut doing effects during macro time is rife with potential problems#2019-10-0223:08isak@lilactown interesting. Do you know what kind of issues may arise? Another way that could work is to walk the AST if shadow provides one in a build hook. ( I think I remember seeing something about this )#2019-10-0223:27lilactownmainly during dev time when you’re watching the app, macros happen right after read time so e.g. they’ll get run on every incremental compilation of that file#2019-10-0223:27lilactownbut also the order in which files get compiled isn’t guaranteed deterministic, so if you depend on ordering you might be in trouble#2019-10-0223:28lilactownshadow also doesn’t recompile everything in the dependency graph in one go, so if your dependent namespaces also have side effects that need to be run all at once, you’re in trouble#2019-10-0223:28lilactown(last one again talking about during dev time while watching the file system)#2019-10-0223:29isakOk, I was thinking I'd just make the macro pass-through to a function in development, so it sounds like the file-appending strategy would work#2019-10-0223:31lilactownI'd be pretty interested to know of a good solution for i18n / localization in first class cljs. If you figure out how to do it well and can share it, I'd greatly appreciate it#2019-10-0223:33isakWill do, thanks for the help#2019-10-0308:36thheller@isak I started some proof of concept regarding i18n a while ago but never had a real need to finish it https://github.com/thheller/cljs-i18n-api#2019-10-0308:37thhellerthe idea was exactly to collect all strings in the metadata and then extract it later via :build-hooks#2019-10-0314:47isak@U05224H0W oh nice! I will try to build on this.#2019-10-0314:48thhellerthere isn't much to build on. the only relevant part is this: https://github.com/thheller/cljs-i18n-api/blob/master/src/cljs/i18n.clj#L55-L56#2019-10-0314:48thhellerit will store the things in the the analyzer data for the namespace#2019-10-0314:48thhellerthat will ensure that it works properly with caching and so on#2019-10-0314:49thhellerdon't store it globally. it must be per ns and combined after the build if needed#2019-10-0314:49thhellerotherwise it won't work with caching enabled#2019-10-0314:49isakright. And this same `*compiler* will be available in a build hook?#2019-10-0314:49isakgood to know, thanks#2019-10-0314:49thhellerit is the same basic idea as this https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-10-0314:50thhellerno build hooks have direct access to the full shadow-cljs build-state#2019-10-0314:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2019-10-0314:51thhellerso you'll find the data in (get-in build-state [:compiler-env :cljs.analyzer/namespaces 'the.ns :your/key])#2019-10-0314:52isakgot it, thanks 🙂#2019-10-0314:52thhellerremember to use namespaced keys for your data to avoid interfering with the normal compile data#2019-10-0314:53isakright#2019-10-0223:19cjsauerI realize this is likely not its use-case, but for toy examples it’s convenient to use :dev-http {8000 {:handler }} as a cheap way to test out client-server interactions. However, when eval’ing server functions, I’m finding that they aren’t picked up until I “bump” the shadow-cljs.edn file, causing shadow to restart the server. Is there a better way to reload server changes?#2019-10-0308:34thhelleryou can use the CLJ REPL to reload CLJ code#2019-10-0400:09cjsauerI have a Clojure REPL using cider-connect-sibling-clj in emacs, would that have the http server in-process? After reloading the ns with my handler in it, subsequent HTTP requests from the cljs app don’t appear to invoke the newly eval’d code.#2019-10-0400:10cjsauerMight be a question for #cider#2019-10-0223:54tony.kayI’m trying out react native support…seeing this:
Exception in thread "async-dispatch-5" java.lang.RuntimeException: java.lang.Exception: Not supported: class cljs.tagged_literals.JSValue
        at com.cognitect.transit.impl.WriterFactory$1.write(WriterFactory.java:65)
        at cognitect.transit$write.invokeStatic(transit.clj:167)
        at cognitect.transit$write.invoke(transit.clj:164)
        at shadow.cljs.devtools.server.common$fn__15653$fn__15654.invoke(common.clj:59)
        at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
        at clojure.core.async.impl.channels$chan$fn__1714.invoke(channels.clj:300)
        at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj:83)
        at clojure.core.async.impl.ioc_macros$put_BANG_.invokeStatic(ioc_macros.clj:992)
        at clojure.core.async.impl.ioc_macros$put_BANG_.invoke(ioc_macros.clj:991)
        at shadow.cljs.devtools.server.web.api$eval36151$fn__36154$fn__36208$state_machine__6737__auto____36227$fn__36229.invoke(api.clj:82)
and so forth. Seems to happen during the flush stage…UI says:
Compiling ...
Flush: cljs/core.cljs
#2019-10-0307:02bbssI'm following https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html But it's not working out too well, I'm getting several errors in the process:
shadow.module.shared.append.js:189 Uncaught TypeError: Cannot read property 'env' of undefined
    at shadow.module.shared.append.js:189
which is on:
shadow.cljs.bootstrap.env.set_loaded(["goog.i18n....
And when running the after-load hook I get:
Uncaught Error: Namespace "goog.debug.Error" already declared.
#2019-10-0308:31thheller@bbss looks like you are using multiple modules? if so you must ensure that shadow.cljs.bootstrap.env is one of your :entries of the :shared module#2019-10-0308:39thheller@tony.kay I'm not sure how this happens. seems like a #js ... value creeps into a websocket message when it shouldn't. not sure how it would get there. do you have #js literals in some metadata maybe? ns/def/defn?#2019-10-0311:33bbssthanks @thheller, errors are gone! 👍#2019-10-0312:17exit2I’m working on porting a projecting from figwheel to shadow. Do I need to have a deps.edn or can I continue to define my deps in my project.clj?#2019-10-0312:19bbss@njj answered here: https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2019-10-0312:20exit2awesome, thanks!#2019-10-0413:24gleisonsilvaHey guys! How are u? I'm trying to use this component https://www.npmjs.com/package/react-columned in a app with Shadow-cljs, but I couldn't figure out how to instantiate this component... I've required like this ... ["react-columned" :as Columned] ... and mount the component like this:
[:> Columned
    [:img {:alt "Image 1" :src ""}]
    [:img {:alt "Image 2" :src ""}]
    [:img {:alt "Image 3" :src ""}]]
But it doesn't work... what I'm doing wrong?
#2019-10-0414:02ouvasamHi @gleisonsilva i think that you should use [react-columned :default Columned] instead#2019-10-0414:39gleisonsilvaI'll try! Tks @U0F7M1KA7#2019-10-0414:02ouvasam:default in place of :as#2019-10-0419:57mafcocinconewb question: When starting the nREPL with shadow-cljs (doing this both via Spacemacs/CIDER and from the CLI), I get the following error: No Clojure project was detected. The refactor-nrepl middleware was not enabled. I have not had much luck chasing this down on the interweb and was wondering if anyone here might be able to point me add a helpful answer or at least in the right direction. Seems pretty obvious but I can't reconcile the error message with my shadow-cljs.edn configuration, which looks correct to me. I can DM the configuration to anyone that is willing to help should that be necessary. Thanks!#2019-10-0419:58dpsuttonmost likely refactor-nrepl doesn't understand that shadow-cljs.edn is a project root#2019-10-0420:00dpsuttonhttps://github.com/clojure-emacs/refactor-nrepl/blob/master/src/refactor_nrepl/core.clj#L65#2019-10-0420:00dpsuttonnone of this is shadow's fault or even concern#2019-10-0420:07mafcocincoThanks @dpsutton. That makes sense. I'll file an issue with refactor-nrepl.#2019-10-0501:45papachani miss something. When i get a look at some shadow-cljs.edn file i dont see any clojurescript version or dependence. i understand shadow-cljs use webpack. but it dont need any clojurescript api to compile clojure code?#2019-10-0510:08thhellershadow-cljs does not use webpack#2019-10-0510:08thhellerthe shadow-cljs version is controlled by whichever version you have installed in your package.json#2019-10-0510:09thhellerand it has a default clojurescript dependency to ensure you are using a compatible version and not some 5 year old release or so#2019-10-0510:10thhellerso basically the :dependencies listed in shadow-cljs.edn have [thheller/shadow-cljs "..."] added automatically#2019-10-0512:47papachanCool Thomas thank for your explanation. I was wondering which magic was running with shadow-cljs#2019-10-0512:47papachanso shadow-cljsforce dev to use the latest clojurescript version#2019-10-0502:36rbergerHow does one include css from node packages so its available to my app? Is there a better way than just copying it manually from the node_modules/<package>/dist/css into resources/public/css and adding it to my index.html as an asset?#2019-10-0510:12thheller@rberger you can use any tool you like to process css. I personally mostly use node-sass but just copying might be enough as well#2019-10-0518:49rbergerI don't need to process the CSS. I'm incorporating a HOC from the AWS Amplify Javascript package. I get the JS no problem with the very nice node import features of shadow-cljs. But wondering if there is an equally elegant way to incorporate the associated CSS. The manual process works, but I'm just wondering if there are other conventions or mechanisms of pulling in the CSS from node packages.#2019-10-0518:51rbergerOn a related note, I did get AWS Amplify Authentication integrated very nicely with re-frame using shadow-cljs. I did have to manually copy in the CSS from the AWS Amplify UI dist from the node_modules https://github.com/omnyway-labs/re-frame-re-com-amplify-shadow-cljs#2019-10-0518:51rbergerHeh, funny the include picked CSS as the language#2019-10-0518:53thhellerwith node-sass I typically have a main.scss that includes all the other stuff I want. so @import "node_modules/foo/bar.css"#2019-10-0518:53thhellernode-sass will then compile and minify everything together#2019-10-0518:53rbergerAh, ok, I'll look into that. I'm pretty new to the modern JS / node environment. Thanks!#2019-10-0518:53thhellera regular Makefile will do 😉#2019-10-0518:54rbergerI included garden just because it was in the re-frame scaffolding. Makefiles!#2019-10-0617:22dazldif you’d like an example of using a makefile to build shadow and sass, here’s one: https://github.com/dazld/shadow-cljs-sass/blob/master/resources/leiningen/new/shadow_cljs_sass/Makefile#2019-10-0617:23dazldhttps://github.com/dazld/shadow-cljs-sass/blob/master/resources/leiningen/new/shadow_cljs_sass/main.scss and this is where sass is importing normalize.scss from npm#2019-10-0607:29dabrazheHi guys, I'd like to ask your view on my cljs setup and possible improvements 1 Using Cursive on ItelliJ idea 2 shadow-cljs edn has :build config (app in this case) , and dependencies listed in the :dependencies map and the nrepl port 3 other JS dependencies are added with yarn add xxxlib and a record is added to package json 4 to add/remove dependencies I have to restart the shadow-cljs server 5 to connect to repl in Cursive I created a Clojure configuration in IntelliJ with the specified nrepl port 6 once the server is started I launch the configuration and then start a repl command from the context menu to start cljs node repl I do find it a rather verbose process, especially when I need to add new dependencies, to repeat the steps 3-6 every time. Is there a simpler way?#2019-10-0608:36Space GuyYou shouldn't have to restart like that on adding new JS yarn add dependencies. The guide does still recommend a restart on adding new CLJ/CLJS :dependencies, though#2019-10-0608:43Space GuyThere are tools to add CLJ libraries at runtime (pomegranate, tools.deps 'add-lib') but I haven't found them very reliable for CLJS libraries ("x.cljs is classpath as a resource, but shadow/figwheel can't see it")#2019-10-0609:16p-himikSome thoughts: 2. I don't think Cursive is able to read shadow-cljs.edn, so you may want to use either :deps true (my preference) or :lein true. 4-5-6. Personally, I rarely use CLJS repl - with hot reload, I find it simple enough to just make a change and see how it works. With that being said, I embed shadow-cljs so that when I start my app in dev environment, shadow-cljs is already running.#2019-10-0609:20thheller@dennisa that is pretty much what you have to do. restarting when :dependencies change is the only way to ensure everything works reliably. I have been experimenting with adding them dynamically but it hasn't been worth the hassle to be honest#2019-10-0609:21thhelleryou don't need to restart when JS deps change though#2019-10-0617:19dazldhey @thheller - thank you for adding that log-style option, to fix the unreadable text in dark mode. I’m not sure how to use it though - env var?#2019-10-0617:39dazldhah, not in 2.8.59#2019-10-0617:40dazldi guess once it’s there it’ll be something like (goog-define shadow.cljs.devtools.client.env/log-style "color: white")?#2019-10-0617:49dazldI did a dirty thing while waiting:
(set! shadow.cljs.devtools.client.browser/devtools-msg
        (fn devtools-msg [msg & args]
          (js/console.log.apply
            js/console
            (into-array
              (into [(str "%cshadow-cljs: " msg) "color: #5981D8;"]
                    args)))))
🙂
#2019-10-0618:45thheller@dazld oh sorry. though I mentioned it in the ticket. you set :devtools {:log-style "color: green;"} in your build config#2019-10-0619:18thhelleroh actually that isn't released yet#2019-10-0619:21thheller@dazld I just released 2.8.60 where :devtools {:log-style "color: green;"} should work#2019-10-0621:45dabrazheThank you all for responses! @p-himik how do you embed it? Because that what I’d like to achieve: having the whole chain start automatically in shadow cljs node repl. #2019-10-0705:07p-himikI don't think it makes sense to go into detail on how I embed it simply because: 1. I use https://github.com/juxt/kick.alpha 2. I don't usually use CLJS REPL However, you still can embed it yourself. Despite thheller saying that it was not created with embedding in mind, doing so was quite easy in my case. The main thing is to call shadow.cljs.devtools.server/start! and shadow.cljs.devtools.api/watch with the required arguments.#2019-10-0705:10p-himikThe source code of shadow-cljs is easy to read in understand for the most part. Well, at least when we talk about all of the plumbing and not actual compilation, and plumbing is exactly what you need.#2019-10-0705:30p-himikBut given that you want it all to run within Cursive REPL, you may end up having to understand what's going on on a deeper level and write quite a bit of code. Cursive REPL has some limitations: https://github.com/cursive-ide/cursive/issues/835 https://github.com/cursive-ide/cursive/issues/2215#2019-10-0710:03thheller@p-himik shadow-cljs was absolutely built with embedding in mind. it just works better if you let it take full control instead of trying to fit it into another system#2019-10-0710:19p-himik@thheller Well, that were your words about some of its components not being made for embedding. 🙂 After all, load-cljs-edn and its callers are still used in many places.#2019-10-0710:21p-himikAlso, what does it mean to "work better" in this context? The output is the same (at least, it works the same way), the UX is better in my case, the integration with the rest of the build system is better.#2019-10-0710:22thhellerwell, yes it is not as customizable as some people would like. that was never the goal though.#2019-10-0710:22thhellerworks better as in takes care of the most common dependency conflicts so you don't have to#2019-10-0710:22thhellerserver-mode#2019-10-0710:22thhelleretc#2019-10-0710:22thhelleronce embedded and running it works exactly the same yes#2019-10-0710:24p-himikHmm, I have never had to deal with any dependency conflicts. And when I had to, standalone shadow-cljs was giving me just the same errors. But maybe that's because I embed the whole shadow-cljs server process, I don't know.#2019-10-0710:24thhelleryou didn't. you also know how to fix them if you have them. beginners don't.#2019-10-0710:25p-himikYeah, makes sense.#2019-10-0710:25thhellerbut just to make this clear: embeddable operation is absolutely a goal of the entire thing#2019-10-0710:25thhellerI would consider it a must-have feature#2019-10-0710:26thhellerjust overriding certain behavior like where the config comes from is not really a goal or something I'd want to support still#2019-10-0710:31p-himikWhere does the aversion come from? After all, there are definitely use cases where someone would want to change some of the behavior. E.g. write some custom config loader to support custom reader macros, like in juxt/aero.#2019-10-0710:31thhellerhaving to support it outside of code#2019-10-0710:32thhellerit will leak into some template that some people will use. then people come asking questions since all of the docs don't apply to their setup.#2019-10-0710:32thhellerand I can't answer any of them because they use a setup I don't know#2019-10-0710:34thhellerthe entire thing is already complex enough, don't need to make it more complex for little gain. you can already do everything you could possible want via the CLJ API if you really need to#2019-10-0710:40p-himik> you can already do everything you could possible want via the CLJ API Hmm. Can I change :js-options via CLI options? Because I only want some of them enabled iff I have to debug the compiled JS and not for the regular development. As an alternative - is it possible to inherit builds, in a way? So that I can have two builds with exactly the same config except for the :js-options value.#2019-10-0710:40thhellerI said CLJ not CLI, but yes you can change :js-options from the command line#2019-10-0710:41thhellershadow-cljs release app --config-merge '{:js-options {:whatever true}}'#2019-10-0710:42thhellersame works for (shadow/release :app {:config-merge [{:js-options {:whatever true}]}) but note the extra vector#2019-10-0710:42thhellerbut it is only an additive merge currently, so you can't simply dissoc values#2019-10-0710:43thhellerhappy to add a (shadow/release :app {:config-rewrite some-fn}) if that would make sense#2019-10-0710:43thhellermostly didn't because no idea how to do that from the CLI#2019-10-0710:47thhellerthere is also shadow-cljs release app --debug or --pseudo-names meant to aid debugging#2019-10-0710:47thhellerif that should set some :js-options it isn't currently setting I'm happy to change that#2019-10-0710:47thhellerie. it currently only sets :compiler-options {:pretty-print true :pseudo-names true} for --pseudo-names#2019-10-0710:51p-himikYeah, I know - I meant CLI of whatever I embed shadow-cljs into. Should've made it more precise. Nice, thanks! To be honest, :config-merge already looks a bit sketchy to me, let alone :config-rewrite. 🙂 At this point, I cannot really say if that will be more useful for the tool in general. As you have probably guessed by now, my personal choice would still be to allow heavy customization and adopt the caveat emptor principle. It should scale well and if something leaks and becomes popular enough and remain broken enough to cause a lot of angry noises, it may just be useful enough to actually include it in the main tool. Or create a separate tool/plugin with a separate maintainer. But that's all just thinking out loud, don't take it to heart.#2019-10-0710:54thhellerif you provide a clear description/example of what exactly you want to do I can think about it#2019-10-0710:54thhelleryou can already do builds that aren't defined in the config file at all#2019-10-0710:56thheller"allow heavy customization" it isn't clear what you mean but if you clarify I'm happy to see what can be done#2019-10-0711:51p-himikA few things that I think are missing or suspicious (given my past experience and what I could quickly find in the code): 1. Some of the resolvers and mutations in shadow.cljs.devtools.graph.builds use shadow-cljs.edn and it's impossible to override this behavior. But I have no clue what the resolvers and mutations do (the graph functionality seems to be used only in tests and the dev webserver), so maybe it's completely justified. 2. NREPL :init-ns cannot be changed. But that's not really an issue since, I think, it's possible to write and use a custom middleware that does it. 3. Impossible to embed build report generation because it reads the EDN config. Right now I have to generate a shadow-cljs.edn file specifically for this feature every time I need. 4. The code from compile, release, check, make-runtime, with-runtime could be reused if it accepted an optional config map. Right now I have a copy of these functions in my own code that just adds a single config argument. That's pretty much all I could find and/or had experience with. As I mentioned before, I don't use shadow's CLJ[S] REPL at all, so maybe there are some things there as well. Given these, and all potential cases where the EDN file could be assumed to exist, "allowing heavy customization" probably means something like "make the config customizable with with-bindings". BTW it seems there's a support for plugins but it's undocumented. Is it something internal?#2019-10-0712:46thheller@p-himik 1. the graph stuff is internal and not part of the public API (yet), it is mostly for the UI or just experiments. 2. :init-ns can be changed via :nrepl {:init-ns the.ns}? 3. happy to add a function that takes a build config and creates a build report for it 4. compile,release,check are functions that are meant to be used directly from the REPL. compile*, release* take a config directly and don't touch shadow-cljs.edn#2019-10-0712:48thhellerplugins are undocumented, sort of experimental until someone actually has a use case for them (I failed to come up with something useful)#2019-10-0712:57p-himik2. Yes, but it can be provided only within the file:
(let [config
      (config/load-cljs-edn)

      init-ns
      (or (get-in config [:nrepl :init-ns])
          (get-in config [:repl :init-ns])
          'shadow.user)]
  ...)
3. Awesome! 4. Indeed, and that's exactly what I'm doing. However, order to make sure that nothing breaks, I still have to do exactly what release and similar methods do under the hood: call rt/init, rt/start-all, runtime/set-instance!, runtime/reset-instance!, rt/stop-all in the correct way. And preserving the logging is also nice. It's about 40 lines in total if I preserve the original code as much as possible.
#2019-10-0713:02thhelleryou are most definitely touching things you shouldn't be touching if you call rt/start-all#2019-10-0713:02thhellerif you properly describe what you want to do I can add functions to do exactly that#2019-10-0713:02thhellerbut if you are going into the internals that aren't part of any public API then you are on your own#2019-10-0713:03thhellerthe stuff is designed exactly for the internal use after all. it was never meant to be used from the outside#2019-10-0713:07p-himikSo ideally, I should only have to use stuff from the api namespaces, right? OK, let's see. This is the code for the api/release function:
(defn release
  ([build]
   (release build {}))
  ([build opts]
   (try
     (with-runtime
       (let [build-config (config/get-build! build)]
         (release* build-config opts)))
     :done
     (catch Exception e
       (e/user-friendly-error e)))))
So, I can provide my custom config to the release* function, that's good. But release also calls with-runtime which in turn calls make-runtime, so let's look at its code:
(defn make-runtime []
  (let [config (-> (config/load-cljs-edn!)
                   ;; just in case someone gets the idea to put :server-runtime true into their config
                   (dissoc :server-runtime))]

    (log/debug ::runtime-start)

    (-> {::started (System/currentTimeMillis)
         :config config}
        (rt/init (common/get-system-config config))
        (rt/start-all)
        )))
Notice that cheeky (config/load-cljs-edn!) that spoils the fun.
#2019-10-0713:12thhellerhappy to change that if you create a github issue describing how exactly you want to call things#2019-10-0713:13p-himikWill do, thanks!#2019-10-0713:13thhellerthe runtime isn't something you should ever need to mess with but I can make it more explicit so that it can be passed in instead using bindings#2019-10-0713:14p-himikWell, and I really don't want to. 🙂 I just want to alter the config. The main issue is that I cannot get those modifications to the runtime.#2019-10-0713:16thhellerits just written this way because I didn't want users at the REPL having to worry about managing and passing around a runtime#2019-10-0713:18p-himikYeah, sure, I get the motivation. And adding optional arguments should not change that. BTW, you don't really want to introduce config bindings and instead prefer to use explicit arguments, right?#2019-10-0713:20thhellerso far as I understand it your problem is the "runtime" handling#2019-10-0713:20thhellermeaning that if none is running one is initialized with a hardcoded load-cljs-edn!#2019-10-0713:21thhellerand I hate bindings yes, want to avoid them at all cost whenever I can#2019-10-0713:23p-himikYes! And runtime initialization with a custom config is not in the API. Can you give a bit of context on why you hate them? I've never used them myself. Are they hard to debug with/reason about/something else?#2019-10-0713:24thhelleryou have always been able to initialize with a custom config#2019-10-0713:24thheller(shadow.cljs.devtools.server/start! the-config-map)#2019-10-0713:24thhellerthe issue is that you don't really need the full "server" runtime#2019-10-0713:25thhelleras that starts too much stuff you don't need if you just want a release build#2019-10-0713:25thhellerso in effect there is a missing "give me a minimal runtime"#2019-10-0713:25thhellerwhich is what make-runtime does#2019-10-0713:26thhellerbut since I never though someone would want to customize that I never exposed it#2019-10-0713:26p-himikAh, right. Everything is just the way you describe, yes.#2019-10-0713:28thhellernot sure whyI hate bindings so much. something about "hidden" function arguments just bothers me#2019-10-0713:28thhellerif a function needs something it should be passed in#2019-10-0713:34p-himikI think it's just a question of whether this lack of referential transparency worth saving the effort to pass the same arguments over and over and over again, especially if 80% of the use cases are happy using the default values. At least, that's how it looks like in the clojure.core code that has quite a few dynamic vars. And I always just pass some sort of a context around instead. But I only develop applications - I've never written anything that other developers would use.#2019-10-0713:40thheller"runtime" is meant to capture "shared" services. so things that can be shared between builds. for a singular release build that obviously isn't very useful and a hinderence in the API#2019-10-0713:40thhellerit is however crucial for server-mode#2019-10-0713:40thhellerand I'll happily pass around one extra arg all day if saves me from using a binding
#2019-10-0713:45p-himikYeah, I get that.#2019-10-0621:51dabrazhe@thheller dynamic restart on :dependencies change is not really an issue, it doesn’t happen too often, and most are ok with restarting lein or boot. It’s the whole verboseness that bothers me, I’d like to create one command to achieve editor integration with repl, if possible. #2019-10-0710:05thhellercan't do much about the cursive side of things#2019-10-0710:06thhellernrepl is also a bit of a hurdle#2019-10-0710:07thhelleryou can probably just create a REPL command in cursive to do it all for you#2019-10-0702:04currentoorIs there a way to specify a Clojure flag per build? So then my macros can see it at compile time?#2019-10-0702:05currentoorsimilar to a JVM property, but per build#2019-10-0710:04thheller@currentoor that is generally not a good idea since those flags won't be accounted for in the caching logic#2019-10-0710:04thhellerso changing them won't invalidate the cache#2019-10-0710:04thhellerwhat kind of flag do you have in mind though? is that cross-platform macro or just a macro expanding CLJS code?#2019-10-0715:51currentoor@thheller I’ve got macros and functions that need to emit different stuff depending on whether I’m targeting the browser or react native#2019-10-0715:51thhellerdo you have an example?#2019-10-0715:54currentoor
#?(:cljs
   (defsc ErrorBoundary [this {:keys [body-fn]}]
     {:shouldComponentUpdate    (fn [np ns] true)
      :getDerivedStateFromError (fn [error]
                                  {:error true
                                   :cause error})
      :componentDidCatch        (fn [error info]
                                  (log/error :componentDidCatch (ex-message error)))}
     (let [{:keys [error]} (comp/get-state this)
           error-msg (div :.ui.error.message
                       (div :.header "Error Encountered")
                       (dom/p "Please try again or contact support if error persists."))]
       (if error
         error-msg
         (try
           (body-fn)
           (catch :default error
             (log/error error :render-try-catch)
             error-msg))))))

#?(:cljs (def ui-error-boundary (comp/factory ErrorBoundary)))

#?(:clj (defn error-boundary* [[first-arg :as body]]
          `(let [real-parent# comp/*parent*]
             (ucv.util/ui-error-boundary
               {:body-fn (fn [] (comp/with-parent-context real-parent#
                                  ~(if (css-k? first-arg)
                                     `(divs 
#2019-10-0715:54currentoori can simplify that example if it’s too much#2019-10-0715:55currentoorbut essentially it’s just a component that catches exceptions in render and renders an error message#2019-10-0715:58currentoorone of the major schisms is, in browser i need to use DOM in RN i need to use that other stuff#2019-10-0715:58currentoorbut ideally i want to re-use components and their queries#2019-10-0716:00thhellerI might be blind but what exactly is the react-native specific stuff?#2019-10-0716:02thhelleralso .. how can you get any work done with all those reader conditionals? my brain hurts from looking at that little snippet#2019-10-0716:04thhellerand somehow I'm missing why this is a macro at all?#2019-10-0716:40currentoorlol fair enough, sorry for the pain 😅#2019-10-0716:40currentoori’ll come up with something simpler#2019-10-0716:45thhelleran actual use is more important, now how it is implemented#2019-10-0716:45thhellerso how would you use (error-boundary ...)#2019-10-0716:48currentoor
(div :.ui.container
  (util/error-boundary :.ui.basic.segment :.ui.middle.aligned.celled.list.massive
    (map ui-tax-list-item (sort-by :tax/title entities))))
#2019-10-0716:49currentoorit prevents errors from bubbling up#2019-10-0716:49thhelleryeah I know about react error boundaries#2019-10-0716:50lilactown@currentoor why do you care if it’s react native or not?#2019-10-0716:50thhellerbut I don't quite know why react-native is different from react-dom#2019-10-0716:51lilactownI guess you wouldn’t use div in react-native#2019-10-0716:51currentoor^ exactly#2019-10-0716:51wilkerlucio@currentoor maybe better than to abstract that part away? for those common components you could have primitives that change according to the build (by using different source paths, with same ns name)#2019-10-0716:52wilkerlucioso you could have ui/block instead of dom/div / rn/View, makes sense?#2019-10-0716:54currentoordifferent source paths with the same name? not sure what you mean#2019-10-0716:54wilkerlucioex: src/ui-rn/my_project/ui.cljs, src/ui-dom/my_project/ui.cljs#2019-10-0716:55wilkerlucioso the RN build uses the first, the DOM build uses the later, so when importing you get the right one#2019-10-0716:55thhellerdon't ever use different source-paths, that is absolutely horrible#2019-10-0716:55wilkerlucio@thheller what you suggest instead?#2019-10-0716:55thhellerproper software architecture ...#2019-10-0716:56thhellersorry .. that different source-paths stuff triggers me 😛#2019-10-0716:56wilkerluciowell, in this case, we need a switch depending on the build, and one source has no relation to the other, they are like interfaces in my POV#2019-10-0716:56wilkerlucio(also worst, loading the wrong one may break the build)#2019-10-0716:56thhelleryou can use #?(:react-native (do-one-thing) :browser (do-that-other-things) :cljs (the-default-thing))#2019-10-0716:57lilactownyeah I would use reader conditionals#2019-10-0716:57wilkerluciois there a way to define custom ones like this?#2019-10-0716:57lilactownshadow lets you define your own yes#2019-10-0716:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2019-10-0716:57wilkerluciocool, I didn't knew that one 🙂#2019-10-0716:58wilkerluciothe only downside I see with that is lock on shadow, I don't mind, but for libraries I wouldn't do that#2019-10-0716:58thhellerbut in all honesty you should do this properly via application config probably#2019-10-0716:58thheller(def runtime-config (atom {}))#2019-10-0716:58thheller(defn init [] (swap! runtime-config assoc :error-boundary some-fn))#2019-10-0716:59thhellerand react-native/browser just initialize differently#2019-10-0716:59wilkerlucio@thheller but how to deal with the fact that some required files will be available in one target but not the other? doens't that still require reader conditionals to do :require?#2019-10-0716:59thhellerthat way you can ensure that react-native specific stuff is only loaded in react-native and so on#2019-10-0717:00thhellerheck you could probably do this as part of the fulcro app#2019-10-0717:00thhellerreader conditionals are pretty cancer. host specific stuff should be hidden behind protocols or something#2019-10-0717:01wilkerlucioand I'm curious, what's about the different source paths that triggers you so much? (asking because I have done that a couple times, and I can't see much problem from it, but I guess you have more context than I do)#2019-10-0717:01thhellernames are supposed to be unique#2019-10-0717:02wilkerluciowell, they still are, I see them as a "implementation fork", for the compiler there is only one (unless you try to do multiple builds at the same time, which would be crazy with this setup)#2019-10-0717:02currentoor@thheller this approach could work for functions but not macros#2019-10-0717:02thhellerthey aren't unique anymore if you have 2 versions#2019-10-0717:02thhellerthey might be unique because you only included one but still#2019-10-0717:03thheller@currentoor I still haven't seen why this is a macro?#2019-10-0717:03currentoorbecause it wraps the body in a try/catch#2019-10-0717:04thheller
(div :.ui.container
  (util/error-boundary :.ui.basic.segment :.ui.middle.aligned.celled.list.massive
    #(map ui-tax-list-item (sort-by :tax/title entities))))
#2019-10-0717:05thhellerdunno what those keywords are about though#2019-10-0717:05currentoorlol yeah, i should stop trying to have my cake and eat it too#2019-10-0717:05currentoorthose keywords generate nested divs#2019-10-0717:05currentoorwith those class names#2019-10-0717:05thhellerbut you could just as well pass a function that you call within the try/catch#2019-10-0717:06currentoorright that’s the syntactic sugar the macro provides#2019-10-0717:06currentoorbut i agree it’s possible#2019-10-0717:06thhelleryou can use the macro of course, but that seems like a lot more code than adding # 😉#2019-10-0717:08currentoorat risk of triggering you again, @wilkerlucio suggestion is looking attractive#2019-10-0717:09thhellerI won't stop you. If that works for you go ahead.#2019-10-0717:10currentooradding RN to a browser project after writing a lot of code is proving cumbersome#2019-10-0717:10currentoor@thheller thanks for the discussion, always helpful simple_smile#2019-10-0717:12currentooroh wait if i do your approach, of putting the error-boundary-fn in the app config, then have the macro use it#2019-10-0717:12currentoorthen i can have it all without separating source paths#2019-10-0717:13currentoorthe differences in environment can be encapsulated inside that function and the macro just gives the syntactic sugar#2019-10-0717:20thheller@wilkerlucio @currentoor this is how I would recommend dealing with this https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2019-10-0717:25thhellerhope that makes sense somehow. the point is that this doesn't require ANY special compiler magic, config or reader conditionals. You just define a "common" shared interface in your code and provide separate implementations when needed#2019-10-0717:25thhellerguess I have done too much java with interface too much in the past#2019-10-0717:26wilkerlucioI like this solution idea, I would just don't do with records, a map with the fns works the same (I'm the one triggered by records/protocols :P)#2019-10-0717:27thhelleryeah pure fns work just fine. I just use protocols whenever something is a bit more stateful#2019-10-0717:28thhellerif you already have an env you pass arround anyways (like in pathom) things are even easier since you don't need to "interface" ns#2019-10-0717:31thhellerswitching :source-paths is of course similar to this as it replaces the concrete implementation without defining an actual interface#2019-10-0717:31thhellerjust hate juggling source paths and conditional requires and all that stuff#2019-10-0717:47currentooryeah i like this approach too#2019-10-0717:47currentoorthanks!#2019-10-0719:20papachanCan we open a browser url just after compilation run?#2019-10-0719:27ChrisHas anyone seen this issue with shadow-cljs REPL (CLJS)?
(defn add "Add Two numbers" [a b ] (+ a b))
=> nil
(defn add  [a b ] (+ a b))
=> #'io.example/add
nil being returned from defn when a docstring is present but the var returned when no docstring?
#2019-10-0721:27dazldI’m using goog.DEBUG to conditionally run code in dev, but what’s a good way of conditionally requiring something?#2019-10-0721:27dazldI can see the dependencies for this code in the production build, even though the debug code has been removed#2019-10-0721:36thheller@chris547 interesting. works fine in the browser but not in node. not exactly sure why.#2019-10-0721:37thheller@dazld "removed"? conditional requires are only possible with some dirty tricks?#2019-10-0721:37dazldI don’t want development dependencies bundled - something like datafrisk, for example#2019-10-0721:38thhellerthen don't require them?#2019-10-0721:38dazldheh, but I do want them in dev 🙂#2019-10-0721:38thhellerwell, how do you require them?#2019-10-0721:39thheller:preloads are meant for stuff like that#2019-10-0721:39dazldyou mention strip-type-prefixes#2019-10-0721:39dazldhm, well, the usual way#2019-10-0721:39thhellerif you require it elsewhere in the code it is up to you to remove it#2019-10-0721:40thhellercode stripping is probably not a good idea, it is kind of a nuclear option that shouldn't be used 😛#2019-10-0721:41dazld
(ns foo.bar
  (:require [dev.library :as d]
            [goog :as g))

(defn thing []
  (when g/DEBUG
    (d/some-function)))
#2019-10-0721:41dazldie, in prod, i’d like dev.library and the code behind the DEBUG not to be there#2019-10-0721:41dazldassuming this is the only place dev library is used#2019-10-0721:42dazldor in all places it’s used, it’s behind a DEBUG#2019-10-0721:42thhellerlikely requires a type hint (when ^boolean g/DEBUG ...)#2019-10-0721:42thhellerbut the require can't be removed that way#2019-10-0721:42dazldwould advanced notice that it’s not being used?#2019-10-0721:42thhelleryes and no#2019-10-0721:42dazld(works ok without a hint btw)#2019-10-0721:43thhellerif you follow very strict code style then yes#2019-10-0721:43thhellerbut a lot of code isn't removeable#2019-10-0721:43thhellerI suggest running a build-report to see how much is actually included#2019-10-0721:43dazldi just looked at the file sizes#2019-10-0721:44dazldit’s 40kb bigger, gzipped 😞#2019-10-0721:44thhellercreate a build report, 40kb doesn't mean anything. seems like a regular CLJS build#2019-10-0721:45thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-10-0721:47dazldthat’s a really nice feature, thanks#2019-10-0721:47dazldthe dev library is in there 😞#2019-10-0721:48thhellerso it wasn't removed#2019-10-0721:48thhellerbut as I said. you likely need the type hint#2019-10-0721:48thhellerit works without yes, but the type hint slightly alters the generated code which means it works better with :advanced#2019-10-0721:49dazldah hah! ok#2019-10-0721:49thhellerbut you can easily verify if its actually removed via
(defn thing []
  (when g/DEBUG 
    (js/console.log "thing debug wasn't removed")
    (d/some-function)))
#2019-10-0721:49dazldthe stuff behind the guard is removed fine#2019-10-0721:49dazldbut the require is still bundled#2019-10-0721:50dazldlet me give it another go#2019-10-0721:50thhelleryes, conditional requires are not possible#2019-10-0721:50thheller(well they are but only with tricks)#2019-10-0721:50dazldwhat’s the preloads thing you mentioned?#2019-10-0721:51thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_preloads#2019-10-0721:52dazldheh sorry#2019-10-0721:56Chris@thheller - thanks for confirming I wasn't crazy - do you think this is a CLJS or shadow/node issue? I'm new to CLJS and don't know where to start looking#2019-10-0721:56dazldo.O cljs.pprint is 96KB!#2019-10-0721:57thheller@chris547 it is a shadow-cljs issue. can't figure out what though.#2019-10-0721:58Chris@thheller Okay, I'll revert to the previous version that I was using and see if it was working there to try to give a baseline#2019-10-0721:59thhellerit wasn't#2019-10-0722:00thhellerthe comment destroys it. no clue why though.#2019-10-0722:00thheller
/**
 * foo
 */
(function() {
  cljs.user.x = function cljs$user$x(a) {
    return a;
  };
  return new cljs.core.Var(
    function() {
      return cljs.user.x;
    },
    new cljs.core.Symbol("cljs.user", "x", "cljs.user/x", -156439873, null),
    cljs.core.PersistentHashMap.fromArrays(
      [
        new cljs.core.Keyword(null, "ns", "ns", 441598760),
        new cljs.core.Keyword(null, "name", "name", 1843675177),
        new cljs.core.Keyword(null, "file", "file", -1269645878),
        new cljs.core.Keyword(null, "end-column", "end-column", 1425389514),
        new cljs.core.Keyword(null, "source", "source", -433931539),
        new cljs.core.Keyword(null, "column", "column", 2078222095),
        new cljs.core.Keyword(null, "line", "line", 212345235),
        new cljs.core.Keyword(null, "end-line", "end-line", 1837326455),
        new cljs.core.Keyword(null, "arglists", "arglists", 1661989754),
        new cljs.core.Keyword(null, "doc", "doc", 1913296891),
        new cljs.core.Keyword(null, "test", "test", 577538877)
      ],
      [
        new cljs.core.Symbol(null, "cljs.user", "cljs.user", 877795071, null),
        new cljs.core.Symbol(null, "x", "x", -555367584, null),
        "cljs/user.cljs",
        8,
        "x",
        1,
        1,
        1,
        cljs.core.list(
          new cljs.core.PersistentVector(
            null,
            1,
            5,
            cljs.core.PersistentVector.EMPTY_NODE,
            [new cljs.core.Symbol(null, "a", "a", -482876059, null)],
            null
          )
        ),
        "foo",
        cljs.core.truth_(cljs.user.x) ? cljs.user.x.cljs$lang$test : null
      ]
    )
  );
})();
#2019-10-0722:00thhellerthats the JS generated for (defn x "foo" [a] a)#2019-10-0722:00thheller
(function() {
  cljs.user.y = function cljs$user$y(a) {
    return a;
  };
  return new cljs.core.Var(
    function() {
      return cljs.user.y;
    },
    new cljs.core.Symbol("cljs.user", "y", "cljs.user/y", 558816894, null),
    cljs.core.PersistentHashMap.fromArrays(
      [
        new cljs.core.Keyword(null, "ns", "ns", 441598760),
        new cljs.core.Keyword(null, "name", "name", 1843675177),
        new cljs.core.Keyword(null, "file", "file", -1269645878),
        new cljs.core.Keyword(null, "end-column", "end-column", 1425389514),
        new cljs.core.Keyword(null, "source", "source", -433931539),
        new cljs.core.Keyword(null, "column", "column", 2078222095),
        new cljs.core.Keyword(null, "line", "line", 212345235),
        new cljs.core.Keyword(null, "end-line", "end-line", 1837326455),
        new cljs.core.Keyword(null, "arglists", "arglists", 1661989754),
        new cljs.core.Keyword(null, "doc", "doc", 1913296891),
        new cljs.core.Keyword(null, "test", "test", 577538877)
      ],
      [
        new cljs.core.Symbol(null, "cljs.user", "cljs.user", 877795071, null),
        new cljs.core.Symbol(null, "y", "y", -117328249, null),
        "cljs/user.cljs",
        8,
        "y",
        1,
        2,
        2,
        cljs.core.list(
          new cljs.core.PersistentVector(
            null,
            1,
            5,
            cljs.core.PersistentVector.EMPTY_NODE,
            [new cljs.core.Symbol(null, "a", "a", -482876059, null)],
            null
          )
        ),
        null,
        cljs.core.truth_(cljs.user.y) ? cljs.user.y.cljs$lang$test : null
      ]
    )
  );
})();
#2019-10-0722:00thhellerthats (defn y [a] a)#2019-10-0722:01thhelleronly difference I can see is the leading comment#2019-10-0722:01thhellerI suspect it is because of the newline (in the comment)#2019-10-0722:04Chrisyeah you're right - it was broken in 2.8.45 too#2019-10-0722:05Chrishow did you generate that JS like that?#2019-10-0722:06thhellerinternal API magic 😉#2019-10-0722:08thhelleryeah it is definitely the commend breaking it. fun stuff.#2019-10-0722:08Christhere's teh 1,1,1 in the first one and the 1,2,2 in the second#2019-10-0722:09ChrisI just started working on a cljs node backend - but would this potentially break all code running in node (assuming it was documented with a docstring?)#2019-10-0722:15thhellerno, only stuff eval'd at the REPL directly#2019-10-0722:15thhellerbut yeah I need to rethink the REPL code I think. thats what I get for trying to be clever I guess#2019-10-0722:16thhellerfix it but thats just another hack#2019-10-0722:22thheller@chris547 should be fixed in 2.8.61#2019-10-0722:22thhellerrather dirty fix, will need to think a bit harder about an actual clean fix#2019-10-0722:24TrevorSo I just wanna check my understanding. shadow-cljs and it's ability to work with package.json essentially accomplishes the same thing you would get using cljsjs libs with :foreign-libs and :global-exports? I'm trying to figure out if I can find some way to get intellisense with material-ui and was thought maybe the cljsjs path would get me that, but from what I've looked at it looks like cljsjs is just another way to package js libraries into your clojurescript app. Is that right?#2019-10-0722:25TrevorAnd is there a way with Spacemacs or Cursive that I could get some kind of autocomplete for material-ui? Something like
(ns your.namespace
  (:require [cljsjs.material-ui :as mui]))
(mui/Grid ...) 
or something
#2019-10-0722:28Chris@thheller - Awesome, thank you so much for the fix - I'll update and hopefully will get back to learning more cljs 🙂#2019-10-0722:28thheller@trevor670 I'm not aware of aynthing that would get you autocomplete for JS deps#2019-10-0722:29thhellernot sure why you'd think cljsjs would change any of that#2019-10-0722:29TrevorYeah that's what I was worried about, when I stop and think about what that would mean I realize that would be a pretty dramatic accomplishment. It would have to like process typescript .d.ts files to generate all the function definitions and stuff#2019-10-0722:29thhellerits just a fact of life that there is no completion for that stuff#2019-10-0722:30dpsuttonThere’s experimental support in CIDER for this with the recent clj-suitable completion package but there’s still some rough edges#2019-10-0722:31thhellerrough edges .. thats putting it mildly 😛#2019-10-0722:31TrevorI'm very new to clojurescript, I initially though cljsjs was something that was more involved (like cljs bindings or something) but I just realized that it's just automating config stuff#2019-10-0722:32TrevorBut based on what you said, definitely sounds like there isn't something I'm missing then! Wanna use material-ui I gotta just type it in#2019-10-0722:32thhelleryeah cljsjs just prepends javascript. doesn't process it in any way#2019-10-0722:40TrevorAnd that's the main sell of shadow-cljs right? Now adding npm dependencies is as simple as updating a package.json instead of doing the other config in project.clj and deps.edn? It's way closer to normal js dev workflows?#2019-10-0722:41thhellerit is one of the features yes. wouldn't call it the main feature but it is one of them yes.#2019-10-0722:42TrevorYeah definitely does more than that! Thanks for all your work and answering my questions!#2019-10-0722:50thhellerI know that IntelliJ ultimate actually supports JS completion for npm packages but I'm not sure if Cursive would be able to tap into that#2019-10-0722:50thhellerseems like a lot of work and probably not very reliable#2019-10-0722:33Chris@thheller - looks like it worked! thanks again for being so responsive - your help today and in the past is one of the main reasons I don't bother even looking at anything other than shadow-cljs!#2019-10-0805:33sogaiui was using multiple socket connections to shadow-cljs, thinking to have one with a current namespace set to one namespace and others set to other namespaces. when i do in-ns in one, all of the other connections appear to have their current namespace affected. is this the expected behavior?#2019-10-0805:33sogaiuthis was after doing shadow/repl in each#2019-10-0805:35Saikyunhey @thheller I have a yarn link:ed package in node_modules (let's call it lul). whenever I modify the contents of lul, and then trigger a compile using (shadow.cljs.devtools.api/watch-compile! :app), it seems that it won't "recompile" lul. is there something I can do to fix this? 🙂#2019-10-0805:37Saikyunoh wait, maybe this was no fault of shadow-cljs. I restarted yarn, and then it works. never mind then : ]#2019-10-0807:25orestisVery often recently I’ll see the warning “Stale Client! <...>” — is the workaround to always have the Chrome dev tools open and disable the network cache?#2019-10-0807:29p-himikI see it only when I restart shadow-cljs server/worker. Do you see it without any restarts?#2019-10-0807:31orestisSometimes I’ll delete all caches, I’ll restart shadow-cljs and still see it.#2019-10-0807:38p-himikAnother reason for that is if you serve a stale JS bundle with your web server. At least, I've made such an error in the past where I was caching manifest.edn during development.#2019-10-0809:29thheller@U7PBP4UVA the shadow-cljs caches don't matter for this error. it is your output that is cached or just plain out of date. sometimes people forget to adjust their paths in the HTML after changing the :output-dir in their config?#2019-10-0809:29thhellerif you are not using the built-in http servers than it might be your server just using too lax cache headers#2019-10-0809:31thhellerchrome caches very aggressively if you don't tell it not to#2019-10-0809:31thhellerso most webservers using the defaults just let chrome cache too much#2019-10-0809:32thhellerThe server should be setting Cache-Control: private, no-cache at the very least#2019-10-0809:41orestisAh, yes, I’m using my own server. I’ll make sure I’ll set the correct headers — thanks!#2019-10-0809:43orestisBTW, the Stale Client warning is a very good one! I can’t imagine the frustration if caching is in play and you didn’t know. Thanks!#2019-10-0809:54thhelleroh it is there because I had that problem so many times before 😛#2019-10-0810:58David PhamLol#2019-10-0811:44Chris@thheller This morning, I went to a different computer, updated shadow-cljs to 2.8.61 - started a REPL/node and now the defn with a docstring is returning nil instead of the var - I swear it worked yesterday on my other computer after the fix - is there some sort of cache I'm not seeing?#2019-10-0811:45thhellerno. are you sure you upgraded correctly? ie. if you use project.clj or deps.edn just updating package.json isn't enough?#2019-10-0811:45thhellerand/or are you sure you restarted after updating? sometimes easy to forget a running server instance. shouldn't say connected to server ... on startup#2019-10-0811:46Chrisyeah, i ran npm upgrade and it set the value in the package.json#2019-10-0811:46Chrisi'm going to restart the computer#2019-10-0811:46Chrisjust to make sure#2019-10-0811:46Chrisbrb#2019-10-0811:46thhellerwhy would you do that? 😛#2019-10-0811:46Christo make sure I'm not connecting to some weird ghost process - this is super weird 🙂#2019-10-0811:47ChrisI know (defn add "add numbers" [a b] (+ a b)) worked on my other machine#2019-10-0811:47thhellerjust run shadow-cljs stop#2019-10-0811:47Chrisk#2019-10-0811:48thhelleralways look at the printed messages on startup#2019-10-0811:48thheller
$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn  cli version: 2.8.61  node: v10.13.0
shadow-cljs - connected to server
cljs.user=> 
#2019-10-0811:49thhellerdon't want to see the "connected to server" if you changed dependencies#2019-10-0811:49Chris
shadow-cljs - config: /home/chris/Projects/its-nancy-land-app/shadow-cljs.edn  cli version: 2.8.61  node: v10.16.3
shadow-cljs - server not running
<- that's what i get after stopping
#2019-10-0811:50thhellerok, and what shadow-cljs - server version: ... running at do you get? 🙂#2019-10-0811:51Chris
> shadow-cljs watch frontend server

shadow-cljs - config: /home/chris/Projects/CloudRepo/its-nancy-land-app/shadow-cljs.edn  cli version: 2.8.61  node: v10.16.3
#2019-10-0811:51ChrisI restarted IntellIj/Cursive#2019-10-0811:51ChrisI was using the REPL there#2019-10-0811:51Chrislooksl ike that fixed it#2019-10-0811:51thhellerthat is only the npm part#2019-10-0811:51Chrisodd, since I was doing a remote repl connection#2019-10-0811:52Chrisohhh#2019-10-0811:52Christhis?#2019-10-0811:52Chrisshadow-cljs - HTTP server available at http://localhost:8700 shadow-cljs - server version: 2.8.45 running at http://localhost:9630 shadow-cljs - nREPL server started on port 8450#2019-10-0811:52thhellersee. 2.8.45, you didn't actually upgrade#2019-10-0811:52Chrisyeah, i just saw that too 🙂#2019-10-0811:53Chrisah, i didn't update the project.clj file#2019-10-0811:53Christhanks for helping me discover that#2019-10-0811:54Chrisso I need to update the project.clj and package.json#2019-10-0811:54thhellerproject.clj is probably enough#2019-10-0811:55thhellerthe npm package is just for the command line stuff, changes very rarely#2019-10-0811:55Chrisokay makes sense#2019-10-0811:55Christhanks for your help!#2019-10-0811:56ChrisYou have a gofundme/patreon/something where people can donate?#2019-10-0811:57thhellerhttps://www.patreon.com/thheller 🙂#2019-10-0811:58ChrisThanks - and you also have the Clojure community funding? (I forget what that thing is called)#2019-10-0812:00thhelleryes, https://www.clojuriststogether.org/ is currently funding me#2019-10-0812:13g7sI have a JS library (closure compatible) that uses ES6 classes: class Foo extends Bar {} that compiles to $jscomp.inherits(Foo, Bar); which means that it needs $jscomp (which is the es6 closure runtime polyfill) defined. This runtime is only included with simple optimizations (and up) per https://github.com/google/closure-compiler/issues/1138 but shadow-cljs in development mode is in :none mode thus $jscomp is undefined.#2019-10-0812:15g7sNow, say that I have extracted this $jscomp polyfill into a js file (as this guy suggested https://github.com/google/closure-compiler/issues/1138#issuecomment-347902571 ). Is there any way I can include this in my dev build?#2019-10-0812:15thhellerdo you happen to have a reproducible example for that?#2019-10-0812:16thhellerI would suggest just bumping the language level so it just stays ES6#2019-10-0812:16thhellereither everywhere or just for dev#2019-10-0812:16g7shmm no atm#2019-10-0812:16g7sok yeah that would be a solution#2019-10-0812:16thheller:compiler-options {:output-feature-set :es6} or :dev {:compiler-options {:output-feature-set :es6}}#2019-10-0812:16thheller(in the build config of course)#2019-10-0812:16g7ssure#2019-10-0812:17g7sBecause I wanted to use this library in a web worker I also tried to importScripts the $jscomp runtime but it fails with weird errors#2019-10-0812:18thhelleryeah the polyfills handling in :dev builds is tricky and buggy#2019-10-0812:18thhellerdepending on which version you are on you might need to delete the .shadow-cljs/builds cache#2019-10-0812:18thhellerI fixed a bug in the last release where cache wasn't invalidated if you changed :output-feature-set#2019-10-0812:19g7sok I will clear the cache and try again#2019-10-0812:25g7sthat worked 🙂 thanks @thheller#2019-10-0812:39mccraigmccraigi've got a CIDER nrepl session connected to a shadow watch build cljs-repl, with a browser attached... mostly seems to work fine, but print output seems to be lost - i.e. (prn "foo") executes but i can't see the output - can i configure something to get print output ?#2019-10-0812:40thhellertry shadow-cljs cljs-repl the-build and (prn :foo)#2019-10-0812:40thhellerif that prints correctly its a cider issue#2019-10-0812:40thhellerif it doesn't its a CLJS side issue, could be caused by calling (enable-console-print!) after shadow-cljs initialized its logging#2019-10-0812:41mccraigmccraigsame result with shadow-cljs cljs-repl#2019-10-0812:42thhellerok, so do you mess with set-print-fn! in any way? directly or indirectly via enable-console-print! or some such?#2019-10-0812:43thhelleryou should basically never call any of those 😛#2019-10-0812:43mccraigmccraigok, i found the offending (enable-console-print!) in our codebase 😊#2019-10-0812:43thhellershadow-cljs already does the setup for all of that#2019-10-0812:43mccraigmccraigi killed it with 🔥#2019-10-0815:28Wes HallHello you fine people. I am afraid I have a potentially dumb question... 🙂#2019-10-0815:33Wes HallI am wondering if anybody is doing hiccup->html generation as part of their shadow-cljs build and how they are going about it. I am only just starting to play with the tool (fine, fine work by the way). My M.O. with this stuff is often to dive in and start trying to use something for things it wasn't intended for 😉, but i had this bright idea of using a build hook to generate a little index.html into the build directory on compile. Potentially I would do this with some garden->css too, so I have one watcher process that just assembles everything. I am sure this probably constitutes ridiculous abuse of the tool, but in any case, it doesn't really work because build hooks are not watched or reloaded on change, so you have to restart the watch process for any changes to take effect thus somewhat nullifying the concept. I suspect the right answer here is to stop trying to use shadow-cljs for stuff it wasn't really intended to do and just use some kind of npm concurrently trick to start seperate watcher processes for each thing, but I thought I would check in with the community here first in case there is a better option I am missing.#2019-10-0815:38ChrisMy initial thought is that shadow-cljs is mostly for compiling to JS and that can be plugged into other pipes for hiccup->html#2019-10-0815:39Chrisso separate watchers would seem to be the way to go to keep things separate#2019-10-0815:39Chrisbut there are hooks you can add at development time that can run everytime code is reloaded#2019-10-0815:39Chris:before-load-async in your build configuration#2019-10-0815:40Chrisunder :devtools#2019-10-0815:52fbielejecI'm playing with the serverless framework, created a toy project: https://github.com/fbielejec/shadow-cljs-serverless Allthough the deployed endpoint works fine I'm struggling to get a nice local workflow going. Serverless provides an offline plugin https://www.npmjs.com/package/serverless-offline for just that, but with the shadow-cljs in a watch mode I get compilation errors after touching the sources:
Error: No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object]
    at Object.cljs$core$missing_protocol [as missing_protocol] (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:312:3)
    at Function.cljs$core$IFn$_invoke$arity$4 (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:854:1)
    at Function.cljs$core$IFn$_invoke$arity$4 (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/core.cljs:4509:6)
    at Object.cljs$spec$alpha$def_impl [as def_impl] (/ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/spec/alpha.cljs:312:5)
    at /ClojureProjects/shadow-cljs-serverless/api/cljs-runtime/cljs/spec/alpha.cljs:1384:1
    at global.SHADOW_IMPORT (/ClojureProjects/shadow-cljs-serverless/api/graphql.js:70:44)
#2019-10-0815:53Wes HallYeah, I looked at those too but I assume they run inside the browser when it is the target meaning quite limited access to the file system. I think you are probably right re: other pipelines. I think my aversion is just in having multiple processes all doing the "watch" work. Would probably be nice to have a single generic watcher with plugins.#2019-10-0815:57isak@wesley.hall what do you mean by this? > it doesn't really work because build hooks are not watched or reloaded on change#2019-10-0815:58isakDo you mean the browser doesn't reload with your settings, or that there is no hook that executes at the time you want?#2019-10-0815:58isak(I think I am doing similar things to what you want to do.)#2019-10-0816:01Wes Hall@isak The lifecycle hooks are written in clojure but these hooks are loaded at the start of the watch processes and any subsequent changes are not loaded until you restart the watch process. You can edit the clj files but triggering a new build (by changing the cljs files), while it does cause the hooks to be rerun, it is code that was read at the start of the watch process and not the latest changes that are executed.#2019-10-0816:01lilactownshadow-cljs is meant to turn CLJS into JS#2019-10-0816:01lilactownit doesn’t really support much else#2019-10-0816:02lilactownif you’re trying to use hiccup in your CLJS code, that will get compiled just fine. if you’re trying to compile hiccup to some static html, outside of your CLJS code, it doesn’t currently support that#2019-10-0816:04lilactownthe question comes up a lot when people want to add Sass compilation, and thheller usually tells people it’s a better idea to run a separate watcher#2019-10-0816:05isak@wesley.hall If you want dynamic reload of the hook itself, that may be tricky, but if you are able to write a function that watches+writes (and can remain stable), that is pretty easy to add in via the hooks#2019-10-0816:05Wes Hall@lilactown Cool, I suspected that was probably the case. It's probably more a matter of me watching to "reuse" the watch process than start other ones. The docs on the build hooks do say something to the effect of, "this is a very powerful extension point", so I am probably just testing how far I can push this, but fully understand what is meant here is, "extend it to do more cljs->js stuff", rather than abuse it for other usages.#2019-10-0816:05isakI'd disagree with @lilactown on this, I found it very easy to add other watchers to, and other compile steps#2019-10-0816:06lilactownit would be good to probably have a real-world use case for build hooks#2019-10-0816:07isakI think you can even get shadow-cljs to reload the page at arbitrary times, stuff not related to it's own build events, since you have access to the build runtime#2019-10-0816:07lilactownAFAICT build hooks are good for triggering additional effects based on changes to CLJS files#2019-10-0816:07Wes Hall@isak Yeah, I had thought about writing the hooks as relatively static code that does the dynamic loading within them. I can see how that might be done fairly easily. Then we probably get into best practice stuff.#2019-10-0816:08lilactownthey are not good for, e.g. reading and compiling files that don’t show up on the classpath (.scss/.graphql/etc.)#2019-10-0816:08lilactownit sounds like what you’re trying to do is a little different, but similar in spirit to those things#2019-10-0816:08lilactownyou want to watch a .clj file and dynamically reload it on change#2019-10-0816:08Wes HallIn the garden case, very similar to .scss yes#2019-10-0816:09lilactownand do some additional compilation#2019-10-0816:10lilactownI think there are two challenges to this: 1. you will need to figure out how to get shadow-cljs to watch those files (probably the stopper) 2. you will need to read the file from disk on each change#2019-10-0816:10isakhere is what I added at work to watch our custom CSS build: https://gist.github.com/isaksky/f693864aeedef8b54c1163342b36d788#2019-10-0816:11isakso then that just starts that watcher in the dev build#2019-10-0816:12lilactownso you’re starting your own watcher and shelling out to the external process#2019-10-0816:13lilactownI suppose it’s nice because the code gets run when shadow-cljs is run#2019-10-0816:14lilactownI think the problem you were running into @wesley.hall is you need some way to reload the Clojure files you’re interested in compiling. I’m not sure the best way to do that#2019-10-0816:15lilactownit might be reading them in from disk, it might be reloading them from the classpath, not sure#2019-10-0816:20Wes HallIt's actually simpler than this in my little test case. My clj hook code literally just says, "convert this embedded hiccup to html and spit it to this file". It's because the hiccup is embedded in the hook clj code that means it doesn't "see" the changes until I restart the watcher. I am kind of leaning towards just running different watch processes for each thing now. I think I was more or less here just to see if somebody was going to say, "oh, just set :reload-hooks true in the build config" 🙂. The interesting thing though is both @isak and myself are really just looking for ways to embed our own little jobs into the watcher process. This does somewhat support my previous idea that there might be a space for a generic watcher application into which jobs can be configured. i.e. "if these files change, pass them through shadow-cljs, if these ones change, pass them through the garden compiler" etc etc. I've had this effect before actually. The delights gain by a solid live reload / watcher process are so great that you want the process to do "all the things" 🙂#2019-10-0816:23Wes HallIn @isak's case, I guess since he is starting a seperate watcher in his code, he could equally do that using an npm script and concurrently and keep the two things entirely separate. So that might be a matter of taste.#2019-10-0816:24Wes HallIn any case, thank you gentlemen. I now have a clearer picture of what I need to look at. Appreciate the opportunity to bounce it around a little. As always, community delivers 🙂#2019-10-0817:15isak@wesley.hall Agreed, and I think Thomas was talking about adding something like that eventually ( file-watch -> run arbitrary code/process helper). Though the good thing is it isn't too bad to add it yourself in the meantime.
#2019-10-0817:47thheller@isak you :build-hook things "leaks". it is never shutdown if you edit the build config file while watch is running#2019-10-0817:57isak@thheller Hmm ok, is there an event for that? For :configure, it says it is only run once#2019-10-0817:58thhellernot currently no. but I also don't get why this is running as part of a build?#2019-10-0817:59isakIt's so people don't need to start multiple consoles to run the build in development mode#2019-10-0818:00isak(full build, not just clojurescript)#2019-10-0818:00thhellershadow-cljs run dev/setup and
(ns dev
  (:require
    [shadow.cljs.devtools.api :as shadow]))

(defn setup
  {:shadow/requires-server true}
  []
  (start-your-watcher)
  (shadow/watch :your-build))
seems like a better choice?
#2019-10-0818:05isakhm, it is not obvious to me why. Also, when you say it leaks, do you mean if the hook is removed in a shadow-cljs.edn update?#2019-10-0818:05thhellerif you modify the build-config while watch is running the old build-state is thrown away and a new one is created with the new config#2019-10-0818:06thhellerit looks like your mk-watcher starts a background thread that will never exit?#2019-10-0818:06isakok, but if it is thrown away, then how does it leak?#2019-10-0818:06isakleaks in the sense that it doesn't get thrown away immediately, having to wait for the GC?#2019-10-0818:06thhellerhttps://github.com/juxt/dirwatch/blob/master/src/juxt/dirwatch.clj#L99#2019-10-0818:07thhellerthat ws is never closed. all associated threads will continue running#2019-10-0818:07isakah 😬#2019-10-0818:08thheller(and since you kept a copy of the build-state that is also never GC'd)#2019-10-0818:09thhelleryou could use the plugin support, since that actually supports lifecycles fully. but it isn't documented or tested much 😛#2019-10-0818:09thhellerhttps://github.com/thheller/shadow-cljs/blob/1fb0b087a2051645ed6e7e9cfe179c51a67c9052/src/dev/demo/dummy_plugin.clj#2019-10-0818:10thhelleractivated via https://github.com/thheller/shadow-cljs/blob/1fb0b087a2051645ed6e7e9cfe179c51a67c9052/shadow-cljs.edn#L16#2019-10-0818:10thhellerbasically the :start fn is called when the server starts, and :stop is called when it ends#2019-10-0818:11isaksounds good. Does it get any arguments (e.g., to detect dev vs release)?#2019-10-0818:16thhellerit isn't coupled to a build#2019-10-0818:17thhellerit is coupled to server-mode#2019-10-0818:17thhellerwhich you probably don't use for release builds#2019-10-0818:17thhellerso the plugin isn't started if you just run shadow-cljs release your-build#2019-10-0818:22Wes HallOk, that plugin feature is definitely nice 🙂#2019-10-0818:23thheller@isak @wesley.hall my challenge for both of you would be to build whatever you want to build AS IF shadow-cljs did not exist at all. just CLJ functions and then show me why it needs to be intergrated into a shadow-cljs build 😛#2019-10-0818:24thhellertypically if you just have a CLJ function turns out to be a enough. since you can run that from the REPL or CLI#2019-10-0818:25thhellerhooking it up so it is executed when shadow-cljs runs is then the easy step#2019-10-0818:26thhellerbut coupling yourself too much to shadow-cljs specifics makes it really hard to run things independently#2019-10-0818:26thhellerand in my experience you always want to be able to run/debug things independently#2019-10-0818:26thhellerdon't make things more complicated than they need to be just because it might safe you 5seconds of time per day#2019-10-0818:37Wes Hall@thheller I just want to hijack the workflow. It's probably just cheating. The "wrapper" html is a stupidly trivial example anyway because it changes so rarely. For garden and css (which is obviously more dynamic), I can just use one of the (apparently several) services built for watching and compiling garden. It's just a matter of it feeling nicer to do in a single process. It's not really that much of a big deal. I don't really want you try to convince you to create another webpack, because at the same time I am asking all these questions, I am acutely aware of the impact trying to support every little usecase has on projects like this. Just really wanted to know if there was a cleverer solution that I was missing that was in regular use. When you have a compilation tool like this, that ultimately moves stuff from src to dist, the obvious problem is that it's now not just my js that needs to go into dist, but probably some html and some css (and indeed, images, fonts, etc etc). I am just trying to figure out the neatest way to get them there.#2019-10-0818:52thheller@wesley.hall I understand what you want but the question I have is "why does copying CLJS to dist have to be coupled to copying html/css to dist?" why can't they be 3 different steps?#2019-10-0818:54thhellerI know your answer .. I just want to challenge your assumptions. you want to run one command, so my answer is that that one command shouldn't be shadow-cljs but something else that triggers those 3 steps (one being shadow-cljs)#2019-10-0818:55thhellerI don't even think webpack is doing this is a good way#2019-10-0818:55thhellerhave you ever looked at a 2 year old webpack config that nobody can upgrade anymore?#2019-10-0818:55Wes HallYes, which is one of my two possible solution right now. The trouble there of course is that the "one step up" from shadow in the "standard" setup is npm, which dumps me in node land, which not only makes me sad, but means not only do I need a new process but I need a new JVM...#2019-10-0818:56Wes Hall@thheller Definitely not advocating for webpack 🙂#2019-10-0819:00thhellerset the shadow--cljs run example I posted above#2019-10-0819:00thhellerthat gets you one JVM doing things#2019-10-0819:00thhellerwhich you could also replace by clj -m#2019-10-0819:01Wes Hall@thheller Yeah, I saw that. The run option I actually didn't know about. Is this documented anywhere? Does it just clj with shadow on the classpath or is there more to it than that?#2019-10-0819:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-10-0819:02thhellerit is a bit more but not much#2019-10-0819:02Wes HallAhhh, must have missed this in the docs. Thank you 🙂#2019-10-0819:04Wes HallI do want to reiterate by the way, how great shadow-cljs is. I am really just working on a toy project here, playing with the tools and seeing how cljs to the browser looks in 2019 because i've been buried in backend stuff for a while. Clojurescript and the ecosystem around it has come on a long way apparently, and I appreciate greatly the part you have played in that. Cheers 🙂#2019-10-0819:23Wes Hall...and, yes, this clj-run functionality appears to be exactly what I am looking for. Thanks for that too.#2019-10-0819:46isak@thheller Agreed for that example, appreciate the tips.#2019-10-0908:50wonko7Hi! is there a way of checking what clojure dependencies could be updated?#2019-10-0916:02beetlemanif you using deps.edn you can use: https://github.com/Olical/depot#2019-10-0908:56thhellernot built-in no#2019-10-0915:57tony.kay@thheller I’ve got an additional “hint” on that weird tagged literal leaking to transit write while compiling: It seems to happen when I’m using deps :local/root. I switch between that and normal version when working on Fulcro bugs. It does it under the following conditions (so far, these seem the only way I get it): Build target is :react-native, and I’m using a dependency that has heavy use of CLJC through :local/root in deps.#2019-10-0916:02tony.kayConfirmed. If I put Fulcro out as a SNAPSHOT and use :mvn/version, then I don’t get the shadow-cljs exception about the tagged literal#2019-10-0916:02thheller@tony.kay can you try with the latest version? I added an additional try/catch that should assist with debugging#2019-10-0916:03tony.kayI’m using .61#2019-10-0916:03thhellerthen it should be printing the full EDN data (in the server log, so don't start in the background)#2019-10-0916:03tony.kayI’m using shadow-cljs server#2019-10-0916:03tony.kaywhat should I do instead?#2019-10-0916:04thhellerno thats it#2019-10-0916:04thhellerno log?#2019-10-0916:04tony.kaystand by…it looked the same to me. I’ll repro#2019-10-0916:04thheller
:transit-str
   {:depends-on []
    :start
    (fn []
      (fn [data]
        (let [out (ByteArrayOutputStream. 4096)
              w (transit/writer out :json)]
          (try
            (transit/write w data)
            (.toString out)
            (catch Exception e
              (log/warn-ex e ::transit-str-failed {:data data})
              (throw e))))))

    :stop (fn [x])}
#2019-10-0916:05thhellerI added that try/catch and it should trigger the log/warn-ex stuff#2019-10-0916:05tony.kayah, there is more#2019-10-0916:05tony.kayhold on#2019-10-0916:05tony.kaykind of a boat load#2019-10-0916:05thhellerso we can at least tell which data triggered the problem#2019-10-0916:05tony.kaywhere do you want it?#2019-10-0916:05thhellergist?#2019-10-0916:05thhelleremail? <mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2019-10-0916:07tony.kayok, I’ll get it to you#2019-10-0916:11tony.kaySeems like this function from Fulcro is confusing it:
(let [update-fn (fn [component f args]
                  #?(:cljs (.setState component
                             (fn [prev-state props]
                               #js {"fulcro$state" (apply f (gobj/get prev-state "fulcro$state") args)}))))]
  (defn update-state!
    "Update a component's local state. Similar to Clojure(Script)'s swap!

    This function affects a managed cljs map maintained in React state.  If you want to affect the low-level
    js state itself use React's own `.setState` directly on the component."
    ([component f]
     (update-fn component f []))
    ([component f & args]
     (update-fn component f args))))
and I do get a warning about .setState…it’s the warning thta is being passed through
#2019-10-0916:11tony.kay
:resources 269, :compiled 4, :warnings [{:source-excerpt {:start-idx 452, :before ["     (get-in cst (if (sequential? k-or-ks) k-or-ks [k-or-ks])))))" "" "(let [update-fn (fn [component f args]"], :line "                  #?(:cljs (.setState component", :after ["                             (fn [prev-state props]" "                               #js {\"fulcro$state\" (apply f (gobj/get prev-state \"fulcro$state\") args)}))))]" "  (defn update-state!" "    \"Update a component's local state. Similar
#2019-10-0916:12thhellerfound it I think#2019-10-0916:12tony.kaywell, other than those are strings?#2019-10-0916:12tony.kayok#2019-10-0916:12tony.kay🙂#2019-10-0916:12thheller:extra {:warn-type :target, :form (. component setState (fn [prev-state props] #object[cljs.tagged_literals.JSValue 0x7713c25e "#2019-10-0916:13tony.kayah#2019-10-0916:13thheller:extra is warning data and the :form it warns about is probably something like (fn [prev-state props] #js{:foo ...})#2019-10-0916:14thhellerwith :local/root the :infer-externs :auto logic kicks in and starts warnings about stuff#2019-10-0916:15thhellerwith the files in .jar those warnings are not triggered#2019-10-0916:16thhellerI'll clean up the warning since :form isn't used for anything anyways#2019-10-0916:17tony.kaycool, that explains it.#2019-10-0916:18thhellerwill release a fix later, be back later#2019-10-0916:19tony.kayk, thanks#2019-10-0916:19thhellerthanks for the log!#2019-10-0916:20tony.kayI’m also seeing warning that make no sense to me when using react native target. When I use (:import [ ErrorCode]) and then use something like (.-EXCEPTION ErrorCode) without a ^js meta marker I get a warning about Cannot infer target type in expression (. ErrorCode -EXCEPTION)…I expected imports to “just work”#2019-10-0916:22tony.kayoh, maybe that isn’t a class 😕#2019-10-0916:25tony.kayno, it’s an enum, so it should be imported#2019-10-0921:06thheller@tony.kay both issues should be fixed in {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4b38232a2f243c66282721380b796573657d79"}, :content ("[email protected]")}#2019-10-0921:13tony.kaysweet#2019-10-0921:44pmooserWhen I use instaparse and require instaparse.core from a cljs project using shadow-cljs, I see a bunch of warnings. However, they all seem to come from :clj portions of feature expressions (or whatever we call them these days in clojure). Is anyone else familiar with this, or understand why it might be happening?#2019-10-0921:45pmooser(the warnings all originate from java stuff that is meaningless in cljs, which is why presumably they're in :clj blocks instead of the :cljs part)#2019-10-0921:46thheller@pmooser an example?#2019-10-0921:48pmooser
------ WARNING #3 - :protocol-invalid-method -----------------------------------
 Resource: instaparse/gll$macros.cljc:51:4
 Bad method signature in protocol implementation, CharSequence does not declare method called charAt
#2019-10-0921:49pmooserAnd now I see when I do a require like this:#2019-10-0921:49pmooser
[instaparse.core :as insta :refer-macros [defparser]]
#2019-10-0921:49thhellerare you compiling for self-hosted?#2019-10-0921:49pmooserI get the following error from shadow-cljs:#2019-10-0921:49pmooser
The required namespace "instaparse.macros" is not available, it was required by "instaparse/core$macros.cljc".
"instaparse/macros.clj" was found on the classpath. Should this be a .cljs file?
#2019-10-0921:49pmooserYes, I have 2 builds, one for self-hosted bootstrap.#2019-10-0921:49thhellerlooks like self-hosted? the library may just not be compatible with self-hosted?#2019-10-0921:49pmooserCan I still use it, if I just don't use it dynamically?#2019-10-0921:50pmooser(what I mean is, I use self-hosted for a REPL I've implemented, but I don't need to use instaparse in the REPL)#2019-10-0921:50pmooserI don't really understand how the two builds interact.#2019-10-0921:51thhellerthe :bootstrap build is controlling what is available to use in self-hosted code eval'd in the browser#2019-10-0921:53thhelleryou are probably just a bit generous with your :entries?#2019-10-0921:54pmooserOk, that makes sense. I'm sure you're right - entries includes my core namespace, and I included instaparse there.#2019-10-0921:54pmooserThanks @thheller, that all makes sense now.#2019-10-0921:55thhelleryeah, only include namespace there that you want your users to be able to actually use#2019-10-0921:55thhellerincluding all the "base" code usually isn't required#2019-10-0921:55pmooserSure. I mean honestly in my ideal world they could use any namespace. But I understand that cljs has limitations in this regard.#2019-10-0921:55pmooser(that is why :entries is as broad as I could make it previously)#2019-10-0921:56thhellerit isn't easy to write macros that run in all hosts equally#2019-10-0921:56thhellernot sure if some adjustments could fix it for instaparse, might be possible to get that working but not sure. could also just exclude the macros.#2019-10-0921:57pmooserSure. And I'm sure there are many subtleties I don't understand. I still hope someday we end up in a completely self-hosted cljs world. But I'm not sure we're ever really going to get to "clojure in clojure" like Rich used to talk about a decade ago.#2019-10-0921:57pmooserI think excluding that ns in the bootstrap build for now works perfectly fine.#2019-10-0921:57pmooserAnd thank you for your patience in helping me!#2019-10-0921:58thhellerself-hosted will always mean that the build is gigantic which makes it a no-go for most apps#2019-10-0921:58thhellercan't ship 5mb of JS normally#2019-10-0922:01pmooserI understand. I expect that to be less and less of a problem in the future, especially for certain classes of apps.#2019-10-0922:02thhellerI doubt that. If anything we need to get filesize down not up.#2019-10-0922:03pmooserI think historical trends seem to go the opposite direction of your predictions.#2019-10-0922:06thhellerhttps://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d4 explains pretty well why it likely won't change until some major breakthrough in the "mobile" world#2019-10-0922:10pmooserThis looks interesting, and I will read it, but talking about performance budgets loading CNN on mobile phones doesn't speak to what I'm talking about. That's why I said "for certain classes of apps". I don't think a news site on a random phone is exactly in the domain of having a self-hosted REPL which you can use to write code at runtime. Anyway, this is almost certain outside the core of shadow-cljs discussion. Thank you for the article - I will finish reading it.#2019-10-0922:13thhellersure certain apps don't care much about size. just saying that a "completely self-hosted cljs world" is not even a goal at this point, at least shadow-cljs will never go there.#2019-10-0922:16pmooserI'm sure there is a lot I don't understand about the cljs compilation world, but since shadow-cljs isn't the compiler or the runtime, I didn't expect that being a goal or not was contingent on shadow-cljs's perspective on the relative importance of being completely self-hosted.#2019-10-0922:21thhellernot sure how to answer that. all I can tell you that if you want something completely self-hosted without a JVM required then you'll never find that in shadow-cljs#2019-10-0922:22pmooserSure, I'm sure you're right, and I don't think it seems to currently be a goal for the clojure folks either at this point.#2019-10-0922:24thhellermaybe once a full JVM can run in WASM 😉 but then we'll be north of 100MB which makes it even less of an option 😛#2019-10-0922:27pmooserYes, and at that point I will agree with you that's undesirable and also won't ever happen. 🙂#2019-10-0922:27pmooserAnyway, thanks again for your help.#2019-10-1007:30flowthingI've read the relevant bits of the user guide, but I don't really understand how to set up CSS reloading. My CSS file is at resources/public/css/main.css, and my HTTP server serves it at /assets/css/main.css. What do I need to set as the values of :watch-dir and :watch-path so that CSS reloading works?#2019-10-1009:01ouvasamI think this should work :watch-dir "resources/public"#2019-10-1009:30thhellershould be :watch-dir "resources/public" :watch-path "/assets"#2019-10-1009:34flowthingThat works, many thanks!#2019-10-1012:00Lucy WangHi guys, I'm experiencing constantly the REPL server crash after a while
$ shadow-cljs watch app
shadow-cljs - config: /path/to/shadow-cljs.edn  cli version: 2.8.61  node: v10.16.3
..... (after a while ) ....
[:app] Compiling ...
[:app] Build completed. (68 files, 1 compiled, 0 warnings, 0.04s)
shutting down ...
Worker shutdown.
Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1155)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at nrepl.transport$bencode$fn__5929.invoke(transport.clj:116)
        at nrepl.transport.FnTransport.send(transport.clj:41)
        at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159)
        at nrepl.middleware.print$send_nonstreamed.invoke(print.clj:138)
        at nrepl.middleware.print$printing_transport$reify__6306.send(print.clj:174)
        at nrepl.middleware.caught$caught_transport$reify__6341.send(caught.clj:58)
        at shadow.cljs.devtools.server.nrepl_impl$send.invokeStatic(nrepl_impl.clj:32)
        at shadow.cljs.devtools.server.nrepl_impl$send.invoke(nrepl_impl.clj:19)
        at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invokeStatic(nrepl_impl.clj:49)
        at shadow.cljs.devtools.server.nrepl_impl$worker_exit.invoke(nrepl_impl.clj:45)
        at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941$fn__6943.invoke(nrepl_impl.clj:207)
        at shadow.cljs.devtools.server.nrepl_impl$repl_init$fn__6916$state_machine__2842__auto____6941.invoke(nrepl_impl.clj:205)
        at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:973)
        at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:972)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:977)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
        at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2860.invoke(ioc_macros.clj:986)
        at clojure.core.async.impl.channels.ManyToManyChannel$fn__655.invoke(channels.clj:265)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        ... 2 more
#2019-10-1012:00Lucy WangI got this for both :target :node-script and :target :browser. The shadow-cljs watch app command is still running there though.#2019-10-1012:02Lucy Wangis this a known bug?#2019-10-1012:38thheller@wxitb2017 are you on OSX by any chance?#2019-10-1012:39Lucy Wangyeah!#2019-10-1012:39thhellerhmm yeah multiple people have been reporting this on OSX. it seems like something in the OS is starting to kill the shadow-cljs process when it reaches a certain memory usage#2019-10-1012:40thhelleryou can set :jvm-opts ["-Xmx1G"] to limit it to 1gig of RAM (either in shadow-cljs.edn or project.clj in case you use lein)#2019-10-1012:40thhellerthat has fixed it for everyone so far#2019-10-1012:40thhellerI still haven't figured out why it is getting killed by the OS#2019-10-1012:41Lucy WangBut the "shadow-clj watch app" process is still there.#2019-10-1012:41thhellerhmm?
shutting down ...
Worker shutdown.
means the shadow-cljs instance shut down
#2019-10-1012:42Lucy Wangah, so the "shadow-cljs watch app" is a node process, which wraps the java process, right?#2019-10-1012:42thhelleryeah exactly#2019-10-1012:42Lucy WangI see, makes sense#2019-10-1211:06Lucy WangOk, I attached a cursive debugger to the shadow-cljs java process and added a breakpoint, and it seems it's the health check from java->npm that leads the worker shutdown#2019-10-1211:07Lucy Wang#2019-10-1211:07thhellerso the node process is getting killed?#2019-10-1211:07Lucy Wangnope, it's still there#2019-10-1211:07Lucy WangI guess there's some subtle problem of the health check loop#2019-10-1211:07thhelleroh do you maybe have a firewall or something that could be blocking the TCP socket?#2019-10-1211:07Lucy Wangmaybe only on OSX#2019-10-1211:08thhellercan you turn on :log {:level :debug} in shadow-cljs.edn? the exception should be logged and might provide a clue?#2019-10-1211:08Lucy Wangfirewall? but the bug is non-deterministic here#2019-10-1211:09Lucy Wanggood idea, I'll add that#2019-10-1211:09thhellerthe way this works is the node process opens a TCP socket that the JVM process frequently connects to and checks if its still there#2019-10-1211:10thhellerotherwise there were problem where the JVM process kept running when the node process was killed#2019-10-1211:12thhellerit is odd that this doesn't happen immediately though#2019-10-1211:16thhellerwonder why the cursive debugger shows e = null#2019-10-1211:30Lucy Wangyeah I was wondering that too#2019-10-1211:31Lucy Wangbtw I just changed the interval from 1s to 10s, and installed it by lein install. So far so good for the last 20minutes.#2019-10-1211:31Lucy WangI suggest 1) increase the interval, at least to e.g. 3s. 2) maybe only abort when failed 3 times in succession#2019-10-1212:57thhellerthanks for digging into this. I'd still rather find out what is happening in the first place before trying to work around it though. a local TCP connect every second shouldn't be a problem. maybe I'll change it to a heartbeat style and just leave the connection open for longer#2019-10-1213:29Lucy WangMakes sense, thx!#2019-10-1012:41thhellerOSX + lein seems to be the most common setup where this happens#2019-10-1012:41Lucy WangI use purely shadow-cljs#2019-10-1012:44thhelleryou can also assign less or more RAM. depends on how much your machine has I guess. would be interesting to find out when it starts crashing 😛#2019-10-1012:45Lucy Wangsure, I already applied the 1G limit and restarted it. Would report back if that helps. Thx a lot!#2019-10-1112:09Lucy WangI tried "-Xmx1G" and "-Xms2G -Xmx5G" etc., none of them made any difference 😞 @thheller#2019-10-1114:47thhellerhey. did you try using less?#2019-10-1114:47thheller-Xmx512M?#2019-10-1114:48thhellercould you try running some of the commands listed here? https://stackoverflow.com/questions/726690/what-killed-my-process-and-why#2019-10-1114:48thhellerso dmesg | grep -E -i -B100 'killed process'#2019-10-1114:48thhellerI'd really like to find out why the process is getting killed#2019-10-1114:49thhelleralthough it may not even be the OOM killer that is actually doing it#2019-10-1115:05thhellerhow much actual RAM do you have btw?#2019-10-1200:49Lucy WangI'm using a mac, with 32GB RAM 🙂 And btw according to my traceback shared earlier, I doubt it's some code in the shadow-cljs/nrepl that crashed the java process http://paste.openstack.org/raw/783109/ (pay attention to Exception in thread "async-dispatch-7" java.lang.Error: java.net.SocketException: Socket closed )#2019-10-1016:10Sean PoulterDoes anyone know if there are docs for how to build the Shadow CLJS client-side code without optimizations? I’ve been trying to troubleshoot CSS reloading and was hoping to step through this code in the browser: - Source: https://github.com/thheller/shadow-cljs/blob/2.8.51/src/main/shadow/cljs/devtools/client/browser.cljs#L166-L199 which ends - In our app: /<CLOSURE_BASE_PATH>/shadow.cljs.devtools.client.browser.js My plan was to: - Clone the repo - Change the optimizations (???) - Run the “build all” script - Use npm link to use the <repoDir>/packages/shadow-cljs and shadow-cljs-jar packages in our app - Rebuild our app and step through the less minified code :crossed_fingers: Does that sound like it’d work?#2019-10-1016:11thheller@sean.poulter I'm confused. there are no optimizations applied in watch or compile builds? only release builds and those won't contains the client/browser.cljs?#2019-10-1016:14Sean PoulterIt’s a watch build on the app end, yea.#2019-10-1016:15Sean PoulterI guess that means it’d have to be modified on our end. 🤔#2019-10-1016:15thhellerno, but I don't understand what you are actually trying to do#2019-10-1016:16thhellerthe steps you described wouldn't do anything#2019-10-1016:16thhellerbrowser.cljs is compiled as part of your project#2019-10-1016:16thhellerif you want to use the chrome debugger to debug something in it#2019-10-1016:16thhelleropen the "Sources" tab in the chrome devtools#2019-10-1016:17thhellerselect the /js/cljs-runtime/shadow/cljs/devtools/browser.cljs and set a breakpoint#2019-10-1016:17thhelleryou can just take the browser.cljs and add it into one of your :source-paths if you want to make modifications#2019-10-1016:17Sean PoulterI’ve got that far. It’s minified and a bit confusing without a source map.#2019-10-1016:18thhellerthats not the .cljs file#2019-10-1016:18thhellerit also isn't minified, it is compiled .js code#2019-10-1016:18Sean PoulterThanks for correcting me on that, yes.#2019-10-1016:19thheller#2019-10-1016:19thhellerit should be showing those like this#2019-10-1016:20thhellerthere might be .js variant of that namespace and a .cljs variant#2019-10-1016:20thhellermight be quicker if you just describe the problem you are seeing 😛#2019-10-1016:21Sean PoulterAh. We must have source maps off. It’s a bit different on our end and just the compiled JS under (no domain):#2019-10-1016:22Sean PoulterThanks for your patience with this. I’ve dropped into the Clojure world from JavaScript. 😓#2019-10-1016:22thhellerit is normal that things might be listed twice#2019-10-1016:23thhelleryou can't even turn off source maps in development so unlikely they are off#2019-10-1016:24lilactowntangent: how would I turn on source maps in release?#2019-10-1016:24thheller:compiler-options {:source-map true}#2019-10-1016:24lilactownthx!#2019-10-1016:26thheller@sean.poulter there isn't much to CSS reloading, it is watching a directory via either :watch-dir or the http root. lets say public. You have a public/css/foo.css. it will attempt to reload /css/foo.css. you can specify :watch-path "/x" which would make it try to reload /x/css/foo.css#2019-10-1016:26Sean PoulterSo the watch-path is prepended to the link href?#2019-10-1016:28thhellerit is prepending :watch-path to the PATH of the .css file it is trying to reload yes#2019-10-1016:28thhellerbut if the <link doesn't already use that path, it won't reload because it will think it is a different file#2019-10-1016:29Sean PoulterI'll give that a try. We're using a proxy to use local code against a prod backend which is at server.localhost:port/extra-path/css/foo.css.#2019-10-1016:29Sean PoulterI gave it a try and it didn't work, so I've gone down a rabbit hole trying to figure out why.#2019-10-1016:30thhelleruhm how is CSS reloading going to work then?#2019-10-1016:30thhellerit can't reload CSS from a different server?#2019-10-1016:30Sean Poulter("I gave it a try" meaning, trying to follow the docs with the watch dir and watch path not working.)#2019-10-1016:31Sean PoulterThe JS hot reloads and its served from the same folder.#2019-10-1016:31thhellerif you have <link rel="stylesheet" href=""> it is never going to reload that CSS#2019-10-1016:31Sean PoulterIt's honestly quite confusing to me.#2019-10-1016:32Sean PoulterIt's a <link href="/css/foo.css"/>.#2019-10-1016:32thhellerok. that should be fine then?#2019-10-1016:32thhellerunless you proxy just proxies that directly to the other server?#2019-10-1016:32Sean PoulterShould be! Oooh. 🤔#2019-10-1016:33thhellerall CSS reloading does is perform the request again#2019-10-1016:33Sean PoulterIt's loading our local CSS, just not reloading it.#2019-10-1016:34Sean PoulterYea. So all of this is why I was trying to figure out how to step through where it's deciding it's not working.#2019-10-1016:35Sean PoulterThanks so much for talking it through! I'll go dig into the watch-path and also figure out my source maps. :)#2019-10-1016:37thhellerjust don't look under (no domain)? I only have the .js files there too#2019-10-1016:40thhellerbut to repeat: you have <link href="/css/foo.css"/>. that means it will only reload files that have :watch-dir + /css/foo.css, so if :watch-dir "public" then public/css/foo.css#2019-10-1016:45thhellercheck the browser console if an actual request is triggered. you might just get the old css back from the server?#2019-10-1016:46Sean PoulterI'll report back when I figure it out. It worked beautify when I configured the example in the README to build to dist. It doesn't make the request or log to the console. From the compiled code it looked like it was a path problem.#2019-10-1016:47thhelleryou can watch the websocket messages in the chrome devtools#2019-10-1016:48thheller#2019-10-1016:48thheller{:type :asset-watch, :updates #{"/css/foo.css"}}#2019-10-1016:48thhellerif that path doesn't match your link path then nothing happens#2019-10-1514:55Sean PoulterJust to follow-up: 1. Thank you again! 👏 2. Watching the messages on the web socket helped. 3. The CSS reloading works great just with :watch-path "/foo/bar". I think my trouble was caused by missing the leading / on the :watch-path. :man-facepalming: 4. It also needed to have :watch-dir "dist" ’cause we weren’t using the default public folder.#2019-10-1018:33tony.kay@thheller is there a way to figure out how a particular thing is getting into the output? I’m working on native in a shared source project and react-dom keeps leaking in…really painful figuring out how#2019-10-1018:33tony.kaywhen I grep the output it isn’t obvious#2019-10-1018:36tony.kaysome dump of the dep graph#2019-10-1018:50thheller@tony.kay the web UI has a thing. after you hit comile or watch there is a "Build Namespaces" select box#2019-10-1018:51thhellerselect any namespace and it'll tell you how it ended up in the build#2019-10-1018:51thhellerthe JS deps you'll find under shadow.js.shim.*#2019-10-1018:51thhellerreally need to make that interface better and create a REPL fn for it or so 😛#2019-10-1018:53flyboarder@thheller trying to import a custom class, getting a type error TypeError: Cannot read property 'prototype' of undefined#2019-10-1018:53flyboarder
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { OAuthStrategy } = require('@feathersjs/authentication-oauth');

class AzureB2CStrategy extends OAuthStrategy {
  constructor(...args) {super(...args);}
  authenticate({error}, params) {
    super.authenticate(error, params);
  }
}

module.exports = AzureB2CStrategy
#2019-10-1018:53flyboarderThen in my require ["./azureb2c.js" :as AzureB2CStrategy]#2019-10-1018:56thhellerlook ok to me, did you check if your requires are correct?#2019-10-1018:57thhellerOAuthStrategy might just be nil/undefined?#2019-10-1018:58flyboarderYeah I was able to confirm this works ["@feathersjs/authentication-oauth" :as auth] then (def OAuthStrategy (obj/get auth "OAuthStrategy"))#2019-10-1018:58thhelleris this node or the browser?#2019-10-1018:58flyboardernodejs#2019-10-1018:59thhellerdid you try :compiler-options {:output-feature-set :es7}?#2019-10-1018:59thhellerI think even :es8 might be fine for node#2019-10-1019:00flyboarderI’ll try with that again, I was using :es6#2019-10-1019:00thhellerhmm no that wouldn't make a diff then#2019-10-1019:00thhellerare you sure you are looking at the correct thing?#2019-10-1019:01flyboarderyeah the stack trace is pointing to the super in constructor#2019-10-1019:01thhellerdid you check the compiled output?#2019-10-1019:02flyboarderwhere should I look?#2019-10-1019:02thhellerfor node builds it is in .shadow-cljs/builds/<the-id>/dev/out/cljs-runtime/*.js#2019-10-1019:04flyboarder#2019-10-1019:04flyboarderno cljs-runtime folder#2019-10-1019:04flyboarderI could be on an old version#2019-10-1019:05thhellerno that hasn't changed in years#2019-10-1019:05thhellerdid you specify a custom :output-dir? or is it not :node-script?#2019-10-1019:06thhellerfor :npm-module its just your :output-dir#2019-10-1019:06flyboarderah yes I did#2019-10-1019:06flyboarder#2019-10-1019:06thhellerthats not the js file?#2019-10-1019:07thhellerthe js file should start with module$...#2019-10-1019:07thhellerthe file you posted is the degree9.auth.azureb2c ns#2019-10-1019:08flyboarderoh ok#2019-10-1019:08flyboarder#2019-10-1019:09thhellerthat doesn't look like :es6 output#2019-10-1019:09thhelleroh wait .. that may have the same caching bug#2019-10-1019:10thhellertry wiping the .shadow-cljs/builds cache#2019-10-1019:10thhellerit may not invalidate properly if you change :output-feature-set?#2019-10-1019:10flyboarderkk i’ll try that#2019-10-1019:11thheller
shadow$provide.module$degree9$auth$azureb2c = function(
  global,
  process,
  require,
  module,
  exports,
  shadow$shims
) {
  require("shadow.js.shim.module$$feathersjs$authentication");
  var OAuthStrategy = require("shadow.js.shim.module$$feathersjs$authentication_oauth")
    .OAuthStrategy;
  global = function(args) {
    for (
      var $jscomp$restParams = [], $jscomp$restIndex = 0;
      $jscomp$restIndex < arguments.length;
      ++$jscomp$restIndex
    )
      $jscomp$restParams[$jscomp$restIndex - 0] = arguments[$jscomp$restIndex];
    return (
      OAuthStrategy.apply(
        this,
        $jscomp.arrayFromIterable($jscomp$restParams)
      ) || this
    );
  };
  $jscomp.inherits(global, OAuthStrategy);
  global.prototype.authenticate = function($jscomp$destructuring$var2, params) {
    OAuthStrategy.prototype.authenticate.call(
      this,
      $jscomp$destructuring$var2.error,
      params
    );
  };
  module.exports = global;
};
#2019-10-1019:12thhellerthats the compiled code, definitely polyfilled which it shouldn't do when using :es6+#2019-10-1019:13thhellerdunno which JS version added ...args, it node supports that natively bump it to whatever language version that is 😛#2019-10-1019:15thhellerhmm no cache is definitely invalidated correctly if :output-feature-set changes#2019-10-1020:18flyboarder#2019-10-1020:19flyboarder@thheller this is with es-next as output-feature-set#2019-10-1020:19flyboarderSame type error#2019-10-1020:29flyboarderSo it seems that any use of super in my js files fails#2019-10-1020:48flyboarderOk so it looks like the files are in TypeScript that I am trying to require via the JS, npm has the compiled js tho#2019-10-1022:02thheller@flyboarder I think you are just not doing the config properly? when I set :es6 I get
shadow$provide.module$demo$test = function(global, require, module, exports) {
  require("shadow.js.shim.module$$feathersjs$authentication");
  ({
    OAuthStrategy: global
  } = require("shadow.js.shim.module$$feathersjs$authentication_oauth"));
  class AzureB2CStrategy extends global {
    constructor(...args) {
      super(...args);
    }
    authenticate({ error }, params) {
      super.authenticate(error, params);
    }
  }
  module.exports = AzureB2CStrategy;
};
//# sourceMappingURL=module$demo$test.js.map
#2019-10-1022:05thhellerdunno how to check if that actually works but you are definitely not doing the config correctly if you still gets the transpiled version afterwards#2019-10-1113:11jaimeHow do you handle cache busting & copying the index.html to the target directory where main.js file is generated? Eg. Reference to main.js without cache busting
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script src="main.js"></script> <--- no cache busting
</body>
</html>
In webpack there is a plugin where you can add hash main.[hash].js and define a path where your index.html template is located, and it will copy it to the target directory
#2019-10-1114:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing#2019-10-1120:35jaime@thheller thank you for link. I got the hash working. However it is still not obvious to me how to put the hashes filename in index.html on every build? Would you mind sharing an example? #2019-10-1120:41thhelleryou read the manifest.edn, you read your input index.html. you str/replace the data or however fancy you want to get#2019-10-1120:44thhellerhttps://gist.github.com/thheller/e42d618a65ffadb0e2aa313d72600f86#2019-10-1120:45thhellersomething like that#2019-10-1120:45thhelleryou can use anything for this really#2019-10-1120:45thhellerdoesn't have to be clojure#2019-10-1120:46thhellerI can create a full example tomorrow if this isn't clear enough
#2019-10-1121:00jaimeCool. I think it is enough. I will try to make it work. Then maybe I will send a PR to update docs. #2019-10-1121:00jaimeThanks a lot :)#2019-10-1121:12jaimebtw, I have an idea. It may not be the scope of shadow-cljs. But I’m interested on your opinion. What if we tell shadow-cljs where the index.html (lets call it template) is located so that it can copy it in the output-dir? Then inside the index.html template, we can define text that can be replaced by an actual value later. For instance any text that starts with $<NAME>.
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>$__DOC_TITLE</title>
</head>
<body>
  $__SCRIPTS <-- will include all scripts
</body>
</html>
The naming conventation is just an example. Also, on how to get the value needs further thought.
#2019-10-1121:15jaimeIf you think it’s something that can be added as an improvement. I’m interested on doing it#2019-10-1121:20thhelleryou can already do this via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run or https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2019-10-1121:34jaimebuild-hooks are awesome! Thanks a lot, I have something to learn more about 😄#2019-10-1114:36isak@jaime.sangcap A custom script that spits out the html, reading "manifest.edn" for prod builds#2019-10-1116:36tslockeI did shadow-cljs release app for the first time (in a while at least). Now when I go back to watch I'm getting loads of errors where it seems the JS objects for the CLJS namespaces don't exist. e.g. Cannot set property 'global' of undefined, where global is the first defn in that namespace. I've tried clearing everything in .shadow-cljs, and in the js/out dir, but it's still broken. Any ideas?#2019-10-1116:38thhellerbad browser cache?#2019-10-1116:39tslockeI don't think so. I've been right clicking on the reload button (Chrome) and doing "Clear cache and reload"#2019-10-1116:40thhellerand you are sure you are loading your actual output files? not some older files from some older directory or so?#2019-10-1116:41tslockePretty sure, but I'll double check that#2019-10-1116:44tslockeTurned source maps off to get the actual path of the JS file, confirmed the timestamp is from 2 minutes ago. Same for main.js#2019-10-1116:46tslockeARGH nvm. It's a name clash with something I'm assigning to js/window :face_palm:#2019-10-1117:04ghaskinshi all…im running up against something that I don’t understand: basically trying to compile with :react-native target, and am including some .js and getting “ReferenceError: Can’t find variable: shadow$provide”#2019-10-1117:04ghaskinsany help appreciated#2019-10-1117:05ghaskins(the .js in this case is generated by the protoc compiler and imported in cljs with a (:require)…this pattern works in :browser but seems to blow up in :react-native#2019-10-1117:07ghaskinsI can see that shadow-cljs did in fact incorporate the generated .js, but it places a reference to shadow$provide that doesnt seem to be fulfilled#2019-10-1117:08thhellerso you have a (:require ["./some.js" :as x])? with some.js being some generated code?#2019-10-1117:08ghaskins@thheller yes#2019-10-1117:09ghaskinsor something close to that, anyway..i think the .js is omitted#2019-10-1117:09ghaskinslet me look#2019-10-1117:09thhelleryeah thats fine#2019-10-1117:10ghaskins(I basically borrowed from a poc I did successfully with :browser#2019-10-1117:10thhellerhmm that should work but it might have a scoping issue#2019-10-1117:10thhellercan you adjust the generated code to use import/export? so ES6 modules?#2019-10-1117:11ghaskinslet me check how I ran the protoc compiler#2019-10-1117:11thhelleror maybe the closure JS style?#2019-10-1117:14thhellerthis should just work. let me see if I can reproduce#2019-10-1117:17ghaskinsforgive me, i am not a js expert so im fumbling around a bit#2019-10-1117:17ghaskinsI generated the code with the “commonjs” import_style#2019-10-1117:17ghaskinshttps://developers.google.com/protocol-buffers/docs/reference/javascript-generated#closure#2019-10-1117:18ghaskinswhich I believe was necessary to get it to work in the :browser target#2019-10-1117:18ghaskinsif I understand what you are saying above, I should try the closure style#2019-10-1117:18ghaskinsbut im not sure about the ES6 modules option#2019-10-1117:19thhellerthe closure JS option is likely the best yes#2019-10-1117:19ghaskinsok, ill try that#2019-10-1117:19thhellerbut then it becomes a regular namespace, so you import it by whatever name it generated#2019-10-1117:19thhellergoog.provide('proto.example.high_score.Ponycopter'); (lol)#2019-10-1117:19thhellerwould be (:require [proto.example.high_score.Ponycopter :as lol])#2019-10-1117:19ghaskinsgot it#2019-10-1117:20ghaskinsok, let me give that a whirl and report back, ty!!#2019-10-1117:20thhellerES6 is also ok#2019-10-1117:20thhellercommonjs should work too though#2019-10-1117:20ghaskinsim sure I am doing something wrong somewhere along the way#2019-10-1117:21thhellerit is totally possible this just has an issue for react-native#2019-10-1117:21thhelleryou can try if it works in a release build. I'd suspect that it does.#2019-10-1117:22ghaskinsfwiw: this tool generates a project with the structure I am using#2019-10-1117:22ghaskinshttps://github.com/ghaskins/re-frame-native#2019-10-1117:22ghaskins(though in my current iteration, I have abandoned lein-shadow and dropped back to raw shadow-cljs.edn#2019-10-1117:23ghaskins(thrashing around trying to solve the problem)#2019-10-1117:23ghaskinsbut all permuations seem to have the same fundamental problem of the missing shadow$provides call#2019-10-1117:23ghaskinsanyway, i will play with the generated code type as you suggested#2019-10-1117:27thhellerhow does anyone get anything done with react-native ... the last time I ran this project it worked fine#2019-10-1117:28thheller
react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:transformClassesWithDexBuilderForDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See 
20 actionable tasks: 2 executed, 18 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at 

BUILD FAILED in 31s

error Failed to install the app. Make sure you have the Android development environment set up: . Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at 

BUILD FAILED in 31s

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
    at buildAndRun (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
    at C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Command.handleAction (C:\Users\thheller\AppData\Roaming\npm\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)
#2019-10-1117:30thhellerhmm nevermind ... just ran react-native run-android a second time and that worked#2019-10-1117:30thheller@ghaskins I have reproduced the error though, looking into that#2019-10-1117:31martinklepschIs it possible to set goog.DEBUG to true for advanced builds?#2019-10-1117:31thhellerES6 module works though, although I only tested with export const foo = "foo";. no clue what the protoc generated files look like#2019-10-1117:31thheller:closure-defines {goog.DEBUG true}?#2019-10-1117:32martinklepschYeah, that’s what I’ve been doing but my marker code isn’t showing up#2019-10-1117:34martinklepschlet me play around a bit more#2019-10-1117:34martinklepschjust wanted to ensure it’s meant to work 🙂#2019-10-1117:35thhellerthat is definitely meant to work yes#2019-10-1117:37thheller@ghaskins found the problem#2019-10-1117:45thheller@ghaskins should be fixed in 2.8.64#2019-10-1118:50ghaskinsthanks for the quick turnaround. Ill confirm the fix now#2019-10-1118:57ghaskinsdef seems fixed, thanks!#2019-10-1118:58ghaskinsran into another problem, but it might be on my end#2019-10-1120:03ghaskinsits not really clear what the problem is, but there seems to be an issue with .js transitives now#2019-10-1120:04ghaskinsI tried to build a stripped down use case, and I succeeded though the error is slightly different#2019-10-1120:04ghaskinshttps://www.dropbox.com/s/wzdt2kapag5ave8/shadowbug.tgz?dl=0#2019-10-1120:04ghaskinsin essence, it seems there is some kind of problem referencing something like google-protobuf/google/protobuf/any_pb.js, even though that is included in the “google-protobuf” package#2019-10-1120:05ghaskins(again, i am open to the notion that its “operator error” ;)#2019-10-1120:06ghaskins(i cant say that my tool generated a competent android config..i run iOS here)#2019-10-1120:06ghaskinsappreciate any insights#2019-10-1120:08ghaskinsit boils down to this: https://gist.github.com/ghaskins/251954237da2bf03be6a740a51fe3c6a#2019-10-1120:08ghaskinsL15 to load#2019-10-1120:23thhelleryou might have more luck if you copy the generated JS files to some dir#2019-10-1120:23thhellerassuming you are using :output-dir "app"#2019-10-1120:24thhellercopy the generated files to <project>/proto next to <proto>/app#2019-10-1120:24thhellerthen include the protobuf stuff via (def x (js/require "../proto/whatever.js"))#2019-10-1120:25thhellerbut what would be absolutely ideal is just using closurejs generated output#2019-10-1120:25thhellerbut I'm not exactly sure how that output looks#2019-10-1120:28thhellerhow do I get protoc? I want to try this myself now#2019-10-1120:47thhellerthis has to be the worst bundled thing I have ever seen#2019-10-1120:47thhellerwhat even is this project structure 😛#2019-10-1120:47thheller(the protobuf stuff that is)#2019-10-1121:32thhellerI give up. this has to be the absolute worst managed package I have ever seen. seriously. I have seen some crazy bad packages but this takes the absolute top rank#2019-10-1121:51thhellersince I hate giving up ... I got it working#2019-10-1121:51thhellergeez this is bad 😛#2019-10-1122:06thheller@ghaskins I hope this helps a bit https://github.com/thheller/cljs-protobuf#2019-10-1201:42ghaskinswow, you are awesome#2019-10-1201:42ghaskinsill check it out#2019-10-1201:42ghaskinsthank you#2019-10-1202:01ghaskinswhat I cant figure out is this all worked perfectly when I target :browser, but I think I see what you are seeing#2019-10-1202:02ghaskinsif I use commonjs output, :react-native output seems to be missing my generated source….if I use closure output, it cant find the google provided exports#2019-10-1209:01thhellereven for the browser it makes much more sense to use the closurejs style#2019-10-1209:01thhellerit'll be fully :advanced compatible and result in a way way smaller build#2019-10-1213:47ghaskinsYeah, I think I ran into a problem which led me to try commonjs…but I no longer recall what the issue was#2019-10-1213:48ghaskinsin any case, I did check my browser apps and it looks like they were using shadow-cljs 2.8.55 (vs 2.6.64 in react-native) so I was wondering if there was a regression#2019-10-1213:48ghaskinsbut I updated the browser app to 2.8.64 and it still works fine (even with the basic commonjs flow) so it does seem like there is some kind of difference#2019-10-1213:49thhellerdon't get hung up too much on whether this works in the browser or not#2019-10-1213:49ghaskinsit seems like the google-protobuf npm package doesnt get included in the same way, but I dont understand why#2019-10-1213:49thhellerusing the closure JS style is 100% better regardless of the platform you are on#2019-10-1213:49ghaskinsok#2019-10-1213:50ghaskinsill try to digest your working example and report back#2019-10-1213:50ghaskinsthanks for the time (and shadow-cljs is awesome, btw, so thanks for that too)#2019-10-1213:50thhellerthe commonjs code is basically just a wrapper around the closure JS code#2019-10-1213:58thhellerif there is something the closureJS stuff can't do that the commonjs variant would be able to let me know#2019-10-1213:58thhellerI'm confident that the closureJS variant will be able to do anything, it just might not come pre-packaged in some way#2019-10-1213:59thheller(google doesn't seem to care much about packaging this stuff cleanly)#2019-10-1117:50thheller@martinklepsch just tested and it definitely works. only thing that might cause trouble if you are mixing strings and symbols. :closure-defines should only be symbol keys but in case you have strings also the merge rules might delete one value if there is a conflict#2019-10-1117:52simonkatzCan I tell shadow-cljs or NPM what to do when there are dependency conflicts? (Something like :exclusions in Leiningen, perhaps?) I’m getting this:
NPM version conflict for "react" in deps.cljs (will use A)
A: "16.9.0" from jar:file:/Users/xxxx/.m2/repository/reagent/reagent/0.9.0-rc1/reagent-0.9.0-rc1.jar!/deps.cljs
B: "16.8.6" from jar:file:/Users/xxxx/.m2/repository/re-com/re-com/2.6.0/re-com-2.6.0.jar!/deps.cljs
#2019-10-1117:53thhellerhmm you control which version is installed#2019-10-1117:53thhellerits just warning you that deps.cljs specified different versions#2019-10-1117:54simonkatzAh, right. Thanks!#2019-10-1117:59simonkatzHmmm. So, yes, you’re right, I am specifying the version of react (in package,json). But I if I had conflicts in the transitive dependencies of my :dependencies, might I have to specify (as a top-level dependency) which version I want? And live with the warnings?#2019-10-1118:00thhellernpm doesn't really have a mechanism for this and deps.cljs is kinda dirty anyways#2019-10-1118:01thhellerI may just remove the warning#2019-10-1118:01thhellerI don't know how to solve this cleanly#2019-10-1118:03simonkatzOK; I see. Thanks. (I’m new to npm so still getting to grips with the basics.)#2019-10-1118:06thhellerit likely is fine. CLJS dependencies declaring JS dependencies directly is kind of a new thing so there are some kinks that need to be worked out#2019-10-1118:42lilactownI’ve run shadow-cljs check app and I am seeing a bunch of places that have the following warning: ShadowJS expressions are not callable This could totally be because I’m doing some weird shit with npm/cljsjs transition. what exactly does this warning pertain to, though?#2019-10-1118:42lilactownhere’s an example line it’s calling out:
(-> (js/$ ".floating-scrollbar") (.floatingScroll "destroy"))
#2019-10-1118:57thhellerdon't pay too much attention to the check output. the closure typechecking isn't really meant to be used the way I'm using it#2019-10-1118:58thhellertoo much overall noise anyways#2019-10-1214:37thhellerhttps://twitter.com/thheller/status/1183022207976574976#2019-10-1215:00papachan@thheller wow thats a great help Thomas ! i was playing with macros a time ago#2019-10-1215:22papachanBTW do you have an idea why i cannot compile this macro with clojurescript?
(defmacro str->int [s]
  `(js/parseInt s))
#2019-10-1215:35thheller@papachan define "cannot compile". When I read "cannot compile" I try this and it compiles just fine
$ clj
Clojure 1.10.1
(defmacro str->int [s]
  `(js/parseInt s))
#'user/str->int
#2019-10-1215:36thhellerso the macro is technically fine. just something in your use isn't. also why is this a macro and not a regular defn? no point in making this a macro?#2019-10-1215:37papachanhmm ok let me try something again#2019-10-1215:39papachanah i see now#2019-10-1215:39papachanits a warning#2019-10-1215:40papachan
18 |   (js/console.log (str->int "1"))

-------------------------^------------------------------------------------------

Use of undeclared Var server.macros/s

BUILD-WARNING in server/main.cljs at [18:19]
	Use of undeclared Var server.macros/s
#2019-10-1215:41thhellerso the macro expanded to something using server.macros/s#2019-10-1215:42thhelleroh right. I didn't see it at first#2019-10-1215:42thhelleryour macro is indeed wrong#2019-10-1215:43thheller
(defmacro str->int [s]
  `(js/parseInt ~s))
#2019-10-1215:43thhellerotherwise the macro expands to (js/parseInt server.macros/s) since it is just expanding the regular s symbol#2019-10-1215:44thhellerbuy you want to use the actual value that was passed to the macro instead#2019-10-1215:44thhellerthats why ~s (look up unquote)#2019-10-1215:44thhellermaybe this helps https://blog.klipse.tech/clojure/2016/05/05/macro-tutorial-3.html#2019-10-1222:56papachanoh yeah you are right, its working pretty well now ! 🙂#2019-10-1222:56papachanthank for your link reference, i will read it 🙂#2019-10-1215:45thhellerbut seriously. this shouldn't be a macro in the first place 😉#2019-10-1218:38erwinrooijakkersHi#2019-10-1218:38erwinrooijakkersI try to run shadow with an npm package#2019-10-1218:39erwinrooijakkersNamely zenroom#2019-10-1218:39erwinrooijakkersBut when I add it and import it in the require#2019-10-1218:39erwinrooijakkerspackage.json:
{
  "name": "zenroom-example",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "shadow-cljs": "2.8.64"
  },
  "dependencies": {
    "core-js": "^3.2.1",
    "core-util-is": "^1.0.2",
    "create-react-class": "15.6.3",
    "react": "16.8.6",
    "react-dom": "16.8.6",
    "regenerator-runtime": "^0.13.3",
    "zenroom": "0.9.5"
  }
}
#2019-10-1218:39erwinrooijakkersI get the message:#2019-10-1218:39erwinrooijakkersThe required JS dependency "core-util-is" is not available, it was required by "node_modules/readable-stream/lib/_stream_readable.js". Note: this only happens when I change a file and shadow-cljs pushes changes to the browser.#2019-10-1218:40erwinrooijakkersWhen doing npm i core-util-is or npm i --save core-util-is the error remains#2019-10-1218:40erwinrooijakkersOnly way to avoid it is by removing the [zenroom] import in the view#2019-10-1218:40erwinrooijakkers
(ns zenroom-example.views
  (:require
   [re-frame.core :as re-frame]
   [zenroom]
   [zenroom-example.subs :as subs]))
#2019-10-1218:40erwinrooijakkersAny solution for this?#2019-10-1218:41erwinrooijakkersFrom the documentation this should be the way to do an npm import#2019-10-1219:00erwinrooijakkersVia lein dev I see this: The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".#2019-10-1219:00erwinrooijakkers
You probably need to run:
  npm install readable-stream/writable.js
#2019-10-1219:00erwinrooijakkers
npm install readable-stream/writable.js
npm ERR! Error while executing:
npm ERR! /usr/local/bin/git ls-remote -h -t 
npm ERR!
npm ERR! ERROR: Repository not found.
#2019-10-1219:00erwinrooijakkersCode in readable-stream/writeable.js
module.exports = Stream;

var EE = require('events').EventEmitter;
var inherits = require('inherits');

inherits(Stream, EE);
Stream.Readable = require('readable-stream/readable.js');
#2019-10-1219:00erwinrooijakkersHmm#2019-10-1219:02erwinrooijakkersNot the first one: https://clojurians-log.clojureverse.org/shadow-cljs/2018-08-17#2019-10-1219:02erwinrooijakkersTry removing node_modules and package.json apparently#2019-10-1219:03erwinrooijakkersStill same#2019-10-1219:03erwinrooijakkersThe required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".#2019-10-1219:19thheller@erwinrooijakkers I don't know what zenroom is but it looks like it just isn't supposed to run in the browser?#2019-10-1219:19thhellerit also seems dead with 12 weekly downloads? https://www.npmjs.com/package/zenroom#2019-10-1219:19thhellerand there is a deprecated message on the repo https://github.com/DECODEproject/zenroomjs (and it is archived)#2019-10-1219:22thhellerand it appeared the package used wasm, which shadow-cljs currently doesn't support#2019-10-1219:41erwinrooijakkersAha thanks! 🙂#2019-10-1219:43erwinrooijakkersIt does work in the browser there are examples on https://dev.zenroom.org/demo/#2019-10-1219:43erwinrooijakkersIt’s not dead, it’s just born. The npm package is indeed refering to deprecated repo#2019-10-1219:44erwinrooijakkersIt does use wasm yes#2019-10-1219:44erwinrooijakkersI do see an error exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info. when running#2019-10-1219:45erwinrooijakkersAnyway I get an object that’s accessible now in the browser, I’ll try to use that#2019-10-1219:45erwinrooijakkersThanks for the feedback! I appreciate it#2019-10-1219:52erwinrooijakkersHmm errors like failed to load shadow.module.app.append.js TypeError: "module$node_modules$zenroom$index.script is not a function". So this approach is not the right one. I wonder how to run it in a browser at all 🙂#2019-10-1219:57erwinrooijakkersAh this helped:
(:require [zenroom :default zenroom])
#2019-10-1219:58erwinrooijakkersNow (js/Object.getOwnPropertyNames zenroom) lists all its properties scriptkeysconfdataprintsuccessverbosityzenroom_execzencode_execerrorinitreset__debug#2019-10-1219:58erwinrooijakkers🙂#2019-10-1219:58erwinrooijakkersSo something is working#2019-10-1219:59erwinrooijakkersBut the wasm error uncaught exception: abort("abort(\"both async and sync fetching of the wasm failed\"). Build with -s ASSERTIONS=1 for more info."). Build with -s ASSERTIONS=1 for more info. might be due to limitations of shadow-cljs?#2019-10-1220:50thheller@erwinrooijakkers wasm is not supported, so you are not going to get this running with shadow-cljs#2019-10-1416:11erwinrooijakkersI see. I also see the shadow-cljs issue related to wasm: https://github.com/thheller/shadow-cljs/issues/397. What makes it difficult to use wasm from shadow-cljs? I mean the npm package uses it, not shadow-cljs itself?#2019-10-1416:13thhellershadow-cljs bundles the npm package. it doesn't know how to bundle .wasm. if you load wasm manually it all works completely fine, there just is no "standard" for packaging .wasm yet and I haven't had the time to implement it the way webpack did#2019-10-1416:14erwinrooijakkersAh okay so I can include the wasm file#2019-10-1416:16erwinrooijakkersAnd for including an npm package in a plain javascript project it does work?#2019-10-1416:19thhellerI don't know how to explain this#2019-10-1416:20erwinrooijakkersOkay 🙂#2019-10-1416:20erwinrooijakkersI look up information on how wasm is bundled in npm#2019-10-1416:20thheller.wasm is just a file. it is normally loaded at runtime via some JS calls#2019-10-1416:20erwinrooijakkersYes#2019-10-1416:20thhellerit basically does a HTTP to load it, just like loading a .css file or so#2019-10-1416:21thhellerbut the file somehow needs to get out of node_modules/whatever/foo.wasm to your public/wasm/foo.wasm or so#2019-10-1416:21thhellerso that you can load /wasm/foo.wasm#2019-10-1416:21erwinrooijakkersAh exactly#2019-10-1416:21erwinrooijakkersAnd that is not a standard location?#2019-10-1416:22thhellerhow that happens isn't defined in any standard and there are no conventions for it#2019-10-1416:22thhellerand webpack instead just inlines the complete file b64 encoded#2019-10-1416:22thhellerso it doesn't need to do an extra request#2019-10-1416:22thhellerthat is the part shadow-cljs doesn't support currently#2019-10-1416:23erwinrooijakkersAh I see#2019-10-1416:23thhellerbut your npm library likely expects it to work like that or something#2019-10-1416:23thhellerI don't know#2019-10-1416:23thhellerhaven't looked at the source#2019-10-1416:23thhellerit likely either does a require("./foo.wasm") or import("./foo.wasm")#2019-10-1416:23erwinrooijakkersThanks this clears things up!#2019-10-1416:24thhellerand shadow-cljs only supports loading actual .js files#2019-10-1307:27CrispinJust a quick question about shadow-cljs. Does shadow-cljs support JVM servers? I have cljc codebase, with clj server code and cljs client code. Can I build my cljs artifacts with shadow-cljs with a JVM based server uberjar containing that artifact?#2019-10-1308:24StefanHi @thheller, I’d like to bounce an idea off you if you don’t mind. I am designing a novel way to build cross-platform mobile apps, without React Native. It uses JavaScript as the main language for programming application logic. Hence I need a bundler. I was wondering if it would be a good idea to use shadow-cljs for that. I target my solution at JavaScript devs, so you could write apps using only JavaScript. I could of course use webpack or something like that, but using shadow-cljs has the added benefit that people could also use ClojureScript if they want, without any additional configuration. Would you say this use of shadow-cljs aligns sufficiently with what you intend it to be? This is of course important to make my solution “future proof”. Also, one issue I see (which I’m not sure if I can solve by configuring shadow-cljs) is that the user’s code as compiled by shadow-cljs gets “scoped” (e.g. module$demo$foo) so it’s “clumsy” when you need to call this from a native web view in iOS/Android. Thanks for sharing your thoughts!#2019-10-1308:37thheller@stefan.van.den.oord it could technically work yes but the focus is purely on CLJS. so while the occasional JS include works fine building actual full JS projects has more than a few rough edges. (eg. no externs inference for JS)#2019-10-1308:42StefanYeah I guess that’s what I felt as well. Back to the hammock 😉 Thanks!#2019-10-1308:48thhellerif you only allow pure strict ES8 code or so then everything would be fine#2019-10-1308:49thhellerbut I'm assuming you want access to npm and commonjs#2019-10-1308:49StefanYeah indeed, it should be as open as possible to other dependencies. And clojurescript preferably 🙂#2019-10-1308:50thhelleryeah, then things get a lot more complicated#2019-10-1308:40thheller@retrogradeorbit I'm not quite sure what you are asking. shadow-cljs produces .js files. those files you can include uberjars like normal. you can run that as part of lein uberjar yes, although I typically recommend doing something like shadow-cljs release app && lein uberjar instead#2019-10-1309:12Crispinok cool. so I could still generate my existing jar with leiningen, and use shadow-cljs to build the js artifacts. Thanks!#2019-10-1405:03bbss#2019-10-1408:13thheller@bbss that kinda looks like you have a dependency conflict somewhere? which shadow-cljs version is this? looks like it might be kinda old?#2019-10-1408:15bbssI just updated the shadow-cljs to latest git version afaict, maybe it's a conflict, but this does run compile with lein +cljs profile.#2019-10-1408:16bbssah, scratch that, not latest version#2019-10-1408:16thhelleruhm you upgraded to the latest git?#2019-10-1408:16bbssupdated but seems not on path#2019-10-1408:16bbssyes#2019-10-1408:16bbsssorry.. checking with newest#2019-10-1408:17thhellerdon't use a git checkout of shadow-cljs#2019-10-1408:17thhellerespecially not with deps.edn :local/root#2019-10-1408:17thhellerit is not compatible. it does require compiling a few extra files which deps.edn doesn't support#2019-10-1408:18bbssokay#2019-10-1408:19thhellerthere are some .java files that need to be compiled, which lein does but deps.edn doesn't#2019-10-1408:19thhellerso that would explain why it works with lein maybe?#2019-10-1408:24thhellerthat NPE however was caused a while back when an incompatible CLJS version was used#2019-10-1408:25thhellerbut you seem to have the correct CLJS version, so it probably just is an old shadow-cljs version? can't see which version that is. doesn't appear to be the latest since the souce doesn't match (ie. compiler.clj:881 isn't par-compile-cljs-sources)#2019-10-1408:28bbssI was on 2.8.18, now updated to 2.8.64.#2019-10-1408:29bbssGetting
"Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n"
#2019-10-1408:34thhellerlooks like a classpath issue to me?#2019-10-1408:34bbssalright, adding shadow-cljs to deps.edn gets me further#2019-10-1408:36ts1503Hello guys. I’ve started a new project with shadow-cljs and I’m trying to integrate shadow-cljs with leiningen, but getting this warning at the compile-time and it brakes the hot reload
shadow-cljs - running: lein with-profile +cljs run -m shadow.cljs.devtools.cli --npm watch app
[2019-10-14 11:03:20.312 - WARNING] provide conflict for #{minorodata.app.subs} provided by cljs/minorodata/app/subs.cljs and {"/minorodata/app/subs.cljs" #{minorodata.app.subs}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.db} provided by cljs/minorodata/app/db.cljs and {"/minorodata/app/db.cljs" #{minorodata.app.db}}
[2019-10-14 11:03:20.314 - WARNING] provide conflict for #{minorodata.app.events} provided by cljs/minorodata/app/events.cljs and {"/minorodata/app/events.cljs" #{minorodata.app.events}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.app.router} provided by cljs/minorodata/app/router.cljs and {"/minorodata/app/router.cljs" #{minorodata.app.router}}
[2019-10-14 11:03:20.315 - WARNING] provide conflict for #{minorodata.core} provided by cljs/minorodata/core.cljs and {"/minorodata/core.cljs" #{minorodata.core}}

#2019-10-1408:37thheller@sergey.tkachenko looks like you might have you :source-paths configured badly? maybe :source-paths ["src" "src/cljs"]?#2019-10-1408:37ts1503my lein config#2019-10-1408:38ts1503and I’ve added {:lein {:profile "+cljs"} in the shadow-cljs.edn#2019-10-1408:39ts1503all listed files in the warnings lives in the src/cljs folder#2019-10-1408:39thhellerand do you have an extra :source-paths outside :profiles? otherwise I believe it defaults to :source-paths ["src"]?#2019-10-1408:40ts1503@thheller no I don’t have extra source-paths#2019-10-1408:41ts1503#2019-10-1408:41thhellerthen add an extra :source-paths []. or :source-paths ["src/clj" "src/cljc"]#2019-10-1408:41thhellerpretty sure it otherwise defaults to adding src#2019-10-1408:43bbssI'm extending some es6 classes that's now giving me trouble:
[:main] Compiling ...
[:main] Build failure:
Closure compilation failed with 10 errors
--- main/gsv/ui/HighPitchMapController.js:1
Requested module does not have an export "clamp".
--- main/gsv/ui/HighPitchMapController.js:2
Requested module does not have an export "Controller".
--- main/gsv/ui/HighPitchMapController.js:3
Requested module does not have an export "WebMercatorViewport".
--- main/gsv/ui/HighPitchMapController.js:3
Requested module does not have an export "normalizeViewportProps".
--- main/gsv/ui/HighPitchMapController.js:4
Requested module does not have an export "LinearInterpolator".
--- remaining errors ommitted ...

#2019-10-1408:43thhellerso you were on a rather old version previously?#2019-10-1408:44bbssYes, 2.8.18#2019-10-1408:44bbssBut this still works with lein#2019-10-1408:44bbssAny way I should probably fix those issues..#2019-10-1408:44thhelleryou are in charge of your dependencies if you use lein or deps.edn#2019-10-1408:44thhellertherefore you must resolve conflicts. deps resolves conflicts differently than lein does#2019-10-1408:45bbssah, that makes sense. Thanks 🙂#2019-10-1408:45thhellerso check how they resolved and sort out the differences. most likely a different closure-compiler verison being used#2019-10-1408:45ts1503@thheller :source-paths [] fixed the problem )) Thanks 👍#2019-10-1408:46thhelleryou seem to be using import { Controller } from "something" maybe?#2019-10-1408:46bbssYes#2019-10-1408:46bbsshttp://deck.gl#2019-10-1408:46thhellerso the issue with JS interop currently is that the closure compiler ONLY accepts "strict" interop#2019-10-1408:47thhellerwhich means import { Controller } only works if the "something" was actual ESM code#2019-10-1408:47thhellerBUT since we are treating node_modules code differently it never is actual ESM code#2019-10-1408:48thhellerfor a while the closure compiler (like webpack) allowed a non-strict variant where this still worked#2019-10-1408:48thhellerso the only way to do this now would be import X from "something" and then X.Controller#2019-10-1408:48thhellerit is a bit annoying that it works that way but we are kinda at the mercy of the closure compiler#2019-10-1408:49thhellerbut webpack is going to be strict-only with v5 also so that'll make things "better" I hope#2019-10-1408:52thhellerI presume that you just had an older version due to lein dependency rules?#2019-10-1408:52bbssOkay, this is useful information for me, I am looking to extend that library from cljs, and was kinda hoping I could just magically use shadow-cljs. But in case that won't work out I'll need to understand more about the module importing. So far usually I can get by with js-options resolve.#2019-10-1408:52bbssMight be..#2019-10-1408:53thhelleryou can use it. just need to adjust your import statements.#2019-10-1408:54thhellerthe whole CommonJS<->ESM interop story in the JS world is a complete mess#2019-10-1408:54thhellerwould have been better if they didn't even start with ESM in the first place#2019-10-1408:55thhellernow it is a breaking change for most JS code out there since babel/webpack at first added a "compatibility" mode that can't actually work if you follow the spec#2019-10-1409:00bbssgetting a lot more warnings, but it compiles! Thanks!#2019-10-1409:02thhellercan you tell me why you are trying to use a git checkout of shadow-cljs in the first place?#2019-10-1409:03bbssI always feel a bit scared when adding an npm dependency, so I hope they figure out something out wrt a spec that will work for everyone, also still having weird issues with aws-amplify for example, thankfully after digging around their code-base and trying several js-options resolve things that worked out eventually.#2019-10-1409:03thhellerwhat :resolve are you messing with?#2019-10-1409:04thhellerit should never be necessary to adjust :resolve for node_modules packages?#2019-10-1409:04bbssA while back (months) I needed a fix you had just pushed so that's why I tried to build from a fresh git pull.#2019-10-1409:05bbssAh well it's a :browser build. but I needed
:js-options {:resolve {"util" {:target :npm
                                                :require "./util"}
                                        "querystring" {:target :npm
                                                       :require "query-string"}}}
#2019-10-1409:05thhellerdon't need those#2019-10-1409:05thhellerif you do need those then you don't have shadow-cljs installed in the project#2019-10-1409:05thhellerwhich I should really make a hard error again#2019-10-1409:06thhelleryou need to install npm install shadow-cljs in your project so that it brings in the node-libs-browser package. which provides browser polyfills for util as well as querystring#2019-10-1409:06thheller(which are otherwise node built-in packages that don't run in the browser)#2019-10-1409:07bbssI think that was what "fixed" it at the time. But admittedly I just use amplify publish for pushing my front-end now, and haven't wanted to touch that code for updating. Ah, that makes sense! I'll try that 🙂#2019-10-1409:08thhellerif installing shadow-cljs in the project doesn't fix it then you may just have a dependency conflict on the npm side#2019-10-1409:08thhellerI wish things were easier .. believe me 😛#2019-10-1409:09bbssI can imagine, shadow-cljs is great though!#2019-10-1412:54credulousHi! I’m a member of that crowd who loves clojure/script, but has struggled with tooling every time I’ve tried to start a project. I’m going to try again! With shadow-cljs of course.#2019-10-1412:55credulousSo: hoping for some views on current best practices on a couple issues:#2019-10-1412:55credulous1) Is there any reason to configure a project as full stack (server + client in one project) versus having two distinct projects? and#2019-10-1412:56credulous2) Is there any particular reason beyond personal taste to use clojure on the server versus using nodejs? I never considered nodejs as a possibility until I started reading shadow-cljs docs, but the unanswered question for me are the advantages to that approach.#2019-10-1412:58thheller@credulous if you want to share code between client/server it can make it easier if you just have one project. still can use 2 different tools though, lein for CLJ and shadow-cljs for CLJS for example#2019-10-1412:59thheller2) I would never personally write anything in node.js if using clojure is also an option
#2019-10-1412:59thhellernode is just a horrible platform to build one, clojure on the JVM is soooo much better it doesn't even compare 😛#2019-10-1413:00credulousOK! Enough of the shadow-cljs docs are given over to nodejs integration that I wondered if I was missing out on something.#2019-10-1413:00thhellerthe difference is really in node vs the JVM#2019-10-1413:01credulousVery helpful, thanks. I think I’ll do two projects because in retrospect a lot of my difficulties have been in having two repls going in one editor, etc. and I’ve never been that bothered by code sharing between server and client.#2019-10-1413:02credulousAnd I’ll use lein for the server. Awesome, thanks#2019-10-1414:14isak@sandbags If you post your question here, I'm sure someone can help you. What is the syntax you are trying to use for js?#2019-10-1414:23sandbagsOkay it looks like I may have answered my own problem in trying to write it up. However it throws up a question, what worked for including a 3rd party JS file was (:require ["jstest" :as jstest]) however none of js/jstest, src/js/jstest or /src/js/jstest with or without a ".js" extension worked. From my reading of the docs I thought it should be prefixed by 'src/js/` as this is the folder the .js file is in within my project. If anyone can tell me what I missed I'd be grateful. Thanks (and thanks @isak for suggesting i post here because I had to re-try several things to write up what I had done so far and then thought to try with no path!)#2019-10-1414:24sandbagsActually I say it worked, the lein dev compilation phase is not erroring out anymore about the dependency, Cursive is still not resolving it. But maybe it can't from where it lives. Yep, I can find my code in the app.js file. Looks good from here.#2019-10-1416:05jherrlinHey! I have problem with what I think is the combination of shadow-cljs and ptaoussanis's Sente. Using re-frames lein template to generate a new project with: lein new re-frame re-learn +10x +cider +handler +re-com. Have a minimal app where I want to send a message back and forth between client and server. But i get failed: Error during WebSocket handshake: Unexpected response code: 500 and ERROR [taoensso.sente:1058] - WebSocket error: [object Event] all the time. Have used Sente with lein and figwheel before without any hassle. Anyone got an idea?#2019-10-1416:18thheller@sandbags not exactly sure what your question is. there are two different kinds of ways shadow-cljs can include JS. there is npm and then there is the classpath. in case of the classpath prefixing with src/js is exactly the wrong thing to do. I tried explaining the classpath https://shadow-cljs.github.io/docs/UsersGuide.html#_the_classpath and https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2019-10-1416:18thhellerin short if you have a src/js/jstest.js file then :source-paths needs to include src/js and you include the file via /jstest.js#2019-10-1416:24thheller@jherrlin do you connect to the correct websocket server? and what does your "handler" look like?#2019-10-1416:27thhellerif I run the command you posted a src/clj/re_learn/server.clj is created#2019-10-1416:27thhellerdo you actually run and connect to that server?#2019-10-1418:45jherrlin@thheller The handler looks like this:
(def dev-handler (-> #'routes
                     wrap-reload
                     ring.middleware.keyword-params/wrap-keyword-params
                     ring.middleware.params/wrap-params
                     (ring.middleware.defaults/wrap-defaults
                      ring.middleware.defaults/site-defaults)
                     ))
It looks to me like the ws request is to the correct host and port.
#2019-10-1418:46jherrlinThe project in all its glory is here: https://github.com/jherrlin/sente-example#2019-10-1418:46thhellerthe generated template starts the server on :3000 so it looks like :8280 is the shadow-cljs http server?#2019-10-1418:46thhelleryeah don't use the shadow-cljs server#2019-10-1418:46thhellerit is likely that sente doesn't support that#2019-10-1418:47jherrlinokey, make sense#2019-10-1418:47thhellerjust run lein run -m shadow-sente.server separately#2019-10-1418:47thhellersente might only support http-kit I'm not sure#2019-10-1418:47jherrlinokey, ill try that#2019-10-1418:47thhellershadow-cljs doesn't use http-kit#2019-10-1418:47jherrlinthen http-kit will kick in_#2019-10-1418:48thhellerhttps://github.com/jherrlin/sente-example/blob/master/src/clj/shadow_sente/server.clj#2019-10-1418:48thhellerlooks like it yes#2019-10-1418:48jherrlinyeah, sente needs the http-kit here#2019-10-1418:48jherrlinthank you soo much for your help!#2019-10-1418:48thhellerhttps://github.com/ptaoussanis/sente#getting-started seems like it might support other servers as well#2019-10-1418:49thhellerbut yeah just run it separately. it is safer that way#2019-10-1418:49jherrlinyeah, it got for some other servers to, but i have used http-kit before and that worked good#2019-10-1418:50thhelleryou are not going to run this through shadow-cljs in production anyways#2019-10-1418:50thhellerso best to keep it separate from the beginning#2019-10-1418:53jherrlinso happy for your help, will try to work it out!#2019-10-1419:20jherrlingot it working ❤️#2019-10-1416:31jherrlin@thheller had to leave the computer. Will respond when I am back. Thanks for responding!#2019-10-1417:42sathyaHi guys, I ran into this issue when running shadow-cljs watch app ? This seems to be caused by code signing requirement enforced by OSX catalina (root cause seems to be the dynamically loaded https://github.com/gjoseph/BarbaryWatchService). I suspect this might cause issues with figwheel as well.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: dlopen(/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp, 1): no suitable image found.  Did find:
	/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp: code signature in (/private/var/folders/r3/hf3d1qyj6d707240ymkh2yx40000gn/T/jna7357045320253869696.tmp) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Has anyone faced the same issue ?
#2019-10-1417:45thheller@sathya no clue what that is. you can turn off using that watcher via :fs-watch {:hawk false}. It'll use the default JVM watcher then#2019-10-1417:47thhellerseems like that might be a problem for all catalina installs. hawk or the underlying BarbaryWatchService is only used on macOS because the default JVM file watch is kinda slow and has a 2sec delay which bothered people#2019-10-1417:48sathyaaha, thanks for the quick response. I will give that a go now.#2019-10-1417:49thhellerhttps://github.com/wkf/hawk thats the alternate watcher#2019-10-1417:54sathyagreat, thanks. I think i have to make do with the polling watcher for now (great perk for upgrading this soon ;)). I figured the config actually needs to be :fs-watch {:watcher :polling}.#2019-10-1417:54thheller:fs-watch {:hawk false} didn't work?#2019-10-1417:55lilactown🤔 i’m about to upgrade to catalina. hopefully this doesn’t hit hot reload perf too bad#2019-10-1417:56thheller:polling is basically telling hawk to use the JVM watcher ... which is kinda the same as not using hawk in the first place#2019-10-1417:56thhellercatalina seems to break a lot of stuff#2019-10-1417:56thhellertwitter is full of upgrade horrors 😛#2019-10-1418:03sathya> :fs-watch {:hawk false} didn't work? Just realised that I had downgraded to shadow-cljs 2.6.0 to test something. :fs-watch {:hawk false} works with 2.8.64, but not with 2.6.0 :fs-watch {:watcher :polling} works with both versions 🙂#2019-10-1418:05thhellerok yeah probably added that after 2.6.0#2019-10-1418:56sandbags@thheller hrmm… this is puzzling. I assume by :source-paths you are talking about project.clj rather than shadow-cljs.edn. My :source-paths doesn't include src/js, only src/clj and src/cljs, perhaps I missed an instruction or implied good practice there. However I can reference the files using :js-options :resolve and (:require ["foo" :as foo]) (where my JS file is src/js/foo.js). From what you are saying it seems what I've done shouldn't work, or is only working accidentally perhaps.#2019-10-1418:57thheller@sandbags that is the point. you need to include it in your :source-paths#2019-10-1418:57sandbagsIt's been a long time since i did any CLJS and the last time was using Figwheel so I am trying to catch up with all the changes#2019-10-1418:57thhellerlearn what the classpath means#2019-10-1418:57thhellerreally that is the concept you need to understand for this to make any sense at all#2019-10-1418:57thhellerdo not mess with :js-options, that is wrong for what you are trying to do#2019-10-1418:57sandbagsyeah i'll read your link, thanks#2019-10-1419:19sandbagsOkay so I did read this before, but perhaps not as closely. I have amended my shadow-cljs.edn as you indicated, removing js-options and adding a source-paths including ['src/js'] (I think my confusion here was that using the re-frame template doesn't include source-paths). However every variant of the :require statement I tried ("/jstest", "/jstest.js", "jstest", "jstest.js") gets "The required JS dependency "jstest" is not available". The file in question is src/js/jstest.js.#2019-10-1419:20thhellerso then you missed another important section#2019-10-1419:20thhelleryou are using :lein true or some form of :lein in shadow-cljs.edn yes?#2019-10-1419:20sandbagsAck… i hadn't noticed that at the top.#2019-10-1419:20thhellerthen :source-paths in shadow-cljs.edn have no effect whatsoever. lein is in charge of managing them, so you need to adjust it there#2019-10-1419:20sandbagsSo it's pulling them from project.clj#2019-10-1419:21sandbagsexcept, i had added it so the :source-paths in project.clj already#2019-10-1419:21sandbagsjust messing around to see what i might be missing#2019-10-1419:21thhellerso what did you add? :source-paths ["src/clj" "src/js" ...]?#2019-10-1419:22thhellerand where is your actual file?#2019-10-1419:22sandbagsin project.clj: :source-paths ["src/clj" "src/cljs" "src/js"] the file is src/js/jstest.js#2019-10-1419:22sandbags(I'm using the re-frame template if that helps)#2019-10-1419:22thhellerdid you restart after adjusting the :source-paths?#2019-10-1419:23thhellerchanging :source-paths and :dependencies requires a full restart of shadow-cljs#2019-10-1419:23sandbagsyes#2019-10-1419:23sandbagsbut i'll do it again to be sure#2019-10-1419:23thhellerso then (:require ["/jstest.js" :as x]) should do it (with no additional config in :js-options at all)#2019-10-1419:24sandbagsAh, yes the "/" is important#2019-10-1419:24thhelleryes, very important#2019-10-1419:24sandbagsokay I think i have it now, thanks#2019-10-1419:25sandbags(i had but had been messing about with variants so didn't have the "/" at the beginning any more)#2019-10-1419:25sandbagsI appreciate the help, thank you.#2019-10-1419:25thhellerotherwise the rules kick in and it'll try to look up in node_modules#2019-10-1419:25sandbagsright#2019-10-1420:06thheller@sathya anything noticeably different after disabling :hawk?#2019-10-1420:51mateusz-fiolkaHi. As I understand I can use :handler inside of dev-http to provide my own request handling. Is there a way for me to add some jvm deps that I could use inside of the handler?#2019-10-1420:54mateusz-fiolkaAh, ok I've found :deps#2019-10-1420:56thhellerjust add regular :dependencies or :deps in case you are using deps.edn#2019-10-1420:56mateusz-fiolkaThank you 🙂#2019-10-1420:56thhellerbut seriously consider running your http server separately (without shadow-cljs)#2019-10-1420:57thhelleryour production setup won't run inside shadow-cljs either so your dev stuff shouldn't either#2019-10-1420:57thhellerkeep things as similar as possible otherwise it'll just end in headaches#2019-10-1420:57mateusz-fiolkaThis is private app running on my local machine#2019-10-1420:58mateusz-fiolkaSo shadowcljs will be running on production 🙂#2019-10-1420:58thhellereek 😛#2019-10-1420:58mateusz-fiolkaAnd the server part will be fairly minimal and stable#2019-10-1421:37lilactownI’m getting a strange error under advanced optimizations that’s fixed when I enable pretty-print and psuedo-names#2019-10-1421:37lilactownany hints?#2019-10-1421:38thhellerexterns, likely js->clj if you use that#2019-10-1421:39thhellercould also be another conflict with in case you are using other JS on the page or creating globals manually#2019-10-1421:40lilactownit only came about when I code split the app into two bundles#2019-10-1421:41thhellerok then you have a conflict with a global on the page#2019-10-1421:41thhelleryou can likely fix it if you just set :output-wrapper true#2019-10-1421:41thhellerthat only defaults to true when using one module#2019-10-1421:41thhellersay you have google analytics on the page#2019-10-1421:42thhellerif you don't have externs for that than its ga global will clash with one of the variables the CLJS outputs creates#2019-10-1421:43thheller:output-wrapper is the easy quick fix#2019-10-1421:43thhellerbut makes your output larger by a small percentage so its usually ok#2019-10-1421:43lilactownthat’s in :compiler-options?#2019-10-1421:43thhelleryes, correct#2019-10-1421:44thhellerI should probably make it the default always and let people disable it in case they want to optimize#2019-10-1421:46lilactownyep, that fixed it#2019-10-1421:46lilactownthanks for the help thheller! 😄#2019-10-1421:47thhellerhttps://github.com/thheller/shadow-cljs/issues/573#2019-10-1422:12isaki ran into this too 🙂#2019-10-1423:42lilactownhrm another weird error related to the output wrapper, now that it’s on:
core.cljs:111 Uncaught ReferenceError: $APP is not defined
#2019-10-1423:43lilactownweird is that I cannot reproduce this locally#2019-10-1423:56lilactownnvm, PEBKAC#2019-10-1423:57lilactownrace condition because I’m trying to append dependent scripts to the page#2019-10-1509:53thhelleryeah things must be loaded in order. it is recommended to use the module loader for more complex scenarios.#2019-10-1506:58JocoHi channel, I have somewhat of a noob question: I have a multi-build shadow-cljs project where one of the builds is a nodejs app. When I use shadow-cljs watch [build-name], I don't see logging from the app like I do when I do a shadow-cljs compile [build-name] && node app.js -- any idea why?#2019-10-1509:54thhellerwell you still need top call node app.js? you don't seem to be doing that for the watch? shadow-cljs does not run node for you.#2019-10-1517:33JocoHey, thank you so much for the response. I completely missed that. What's the best way to start/stop node as a part of watch? :build-hooks?#2019-10-1517:40thhelleryou do it manually. that is the best way.#2019-10-1517:41Jocoalrighty -- thanks#2019-10-1508:11MacrozI just created a simple ClojureScript on Node.js + Shadow-CLJS project and can't seem to get CIDER to notice it. I run cider-jack-in-cljs and I get a complaint that I'm not in a Clojure project even though I'm editing a CLJS file in a directory which has the shadow-cljs.edn at parent. Just trying to confirm that one should not be having to jump hoops here and it should "just work".#2019-10-1508:11Macrozrunning npx shadow-cljs etc. from command-line works#2019-10-1508:12MacrozI get this particular message >>> Are you sure you want to run `cider-jack-in' without a Clojure project? (y or n)#2019-10-1508:19MacrozIf I no then nothing will start, if I answer yes then I get another error about missing ClojureScript#2019-10-1509:55thhellermight be better to ask in #cider. I can't help since I don't use emacs myself#2019-10-1508:18erwinrooijakkersHi all, we use shadow-cljs release prod --source-maps to compile our clojurescript to javascript. We now need to compile the code to make it IE-proof too. The usage of Babel was suggested by a javascript developer here. Is this idiomatic to do in cljs too? If so, how do we include it in the build pipeline?#2019-10-1511:08dazldhttps://polyfill.io might be your friend before jumping through more transpile hoops.#2019-10-1511:09dazldhttps://polyfill.io/v3/supported-browsers/#2019-10-1511:09thhellerno. there are already enough ways to do this in shadow-cljs. don't use anything external.#2019-10-1511:09dazldoh, for polyfills too? stuff like promise / fetch..?#2019-10-1511:09thhelleryes#2019-10-1511:10dazlddoes it create bundles per browser, or put all the polyfills for all browsers into the same thing?#2019-10-1511:10thhellerwell you can always add external polyfills too ... but that could end up including 3 separate polyfills#2019-10-1511:10thhellerone for node packages, one for CLJS code and one manual#2019-10-1511:11dazldah, packaging is different, i think#2019-10-1511:11dazldesm/umd etc#2019-10-1511:11thhellernot sure what that means#2019-10-1511:11dazldecmascript modules, universal module definition etc#2019-10-1511:11thhelleryes I know what the words mean#2019-10-1511:11thhellerjust not what YOU mean in this context#2019-10-1511:12thhellerif you are talking about the "new" pattern of including things via script with nomodule and type="module" then that is not currently supported#2019-10-1511:13dazldno, just polyfilling features#2019-10-1511:13thhellerbut you could easily build two separate outputs, one with polyfills and one without#2019-10-1511:13dazldyou could, but you’d need a bundle per browser#2019-10-1511:13dazldand then UA sniffing on serve#2019-10-1511:13dazldwhich is what polyfill does.#2019-10-1511:13dazldor put it all into one bundle, which is a bit icky#2019-10-1511:13dazlddunno, there’s tradeoffs in all scenarios#2019-10-1511:14thhellerpolyfills are always icky yes#2019-10-1511:15thhellerbut not everything can be polyfilled ... so the problem needs to be solved differently#2019-10-1511:15dazldit’s true, there is a threshold.#2019-10-1511:15dazldi’d still try polyfiling legacy as a first step. if it doesn’t work, can drop back to more complex approaches.#2019-10-1511:16thhellerI should probably document how this is supposed to work in shadow-cljs#2019-10-1511:16dazldthat would be great!#2019-10-1511:16thhelleryeah that suggestions is just bad and will not fix anything#2019-10-1511:17dazlddepends on which problem. the thing you mention about packaging code for node vs browsers isn’t going to be fixed by it, but stuff like missing array methods will be.#2019-10-1511:17thhellerit isn't even a complex approach .. so please don't suggest "custom" approaches BEFORE trying the actual built-in#2019-10-1511:17dazldfair enough - i’ve been using polyfills for this problem for years, so would be curious what approach you have in mind.#2019-10-1511:18thheller:js-options {:babel-present-env {:targets {:ie 8}} is probably all you need#2019-10-1511:19thhellerusing https://babeljs.io/docs/en/babel-preset-env basically#2019-10-1511:19thhellerbut yeah if you want this to be "optional" you need 2 separate builds. which is kinda dirty currently#2019-10-1511:20dazldcool, but .. that does have the drawbacks of outputting legacy js - so, things like weakmaps would be downpiled..?#2019-10-1511:20dazldor polyfilled in place#2019-10-1511:20thhelleryes ... BUT this might be happening regardless of what you are doing outside the build#2019-10-1511:21dazldalso true.#2019-10-1511:21dazldyay browsers.#2019-10-1511:21thhellerbasically if you include polyfills separately the build will not know about it#2019-10-1511:21thhellerso it will include whatever it thinks it needs#2019-10-1511:21dazldgot it.#2019-10-1511:21thhellerso the only way to do this properly is to create however many builds you need, targetted at each specific browser and served accordingly#2019-10-1511:21thhellerits messy#2019-10-1511:23thhellernot claiming its perfect in shadow-cljs, it isn't by far#2019-10-1511:23thhellerbut including 3rd party polyfills is strictly worse in pretty much all cases#2019-10-1514:01erwinrooijakkersThanks all!#2019-10-1609:45erwinrooijakkersHmm looking at polyfills that might be the quickest fix for now. Include polyfills in IE browsers only via a script conditional. Then there’s also no configuration needed with separate builds per environment. I understand the code size will be larger and the page will be slower so it’s suboptimal.#2019-10-1609:46erwinrooijakkersAdvantage is that also the sentry-sdk javascript will start to work in IE#2019-10-1609:47erwinrooijakkersBecause that now crashes with Object.assign that is not recognized#2019-10-1609:47erwinrooijakkersSo we did not even get the frontend IE errors in Sentry#2019-10-1609:50thhellerif you configure :js-options {:babel-preset-config {:targets {:ie "8"}}} and use the sentry stuff from npm then everything will likely work as expected#2019-10-1708:18erwinrooijakkersAh of course thanks#2019-10-1509:56thheller@erwinrooijakkers is the "bad" code part of your CLJS code or part of npm packages? where does it fail?#2019-10-1514:06erwinrooijakkersI’ll have to check#2019-10-1511:38vinursanyone use cljs-http in react-native?
(go (let [response (<! (http/get ""
                                 {:with-credentials? false
                                  :query-params {"since" 135}}))]
      (prn (:status response))
      (prn (map :login (:body response)))))
i test the code, it output the error
TypeError: Cannot read property 'chan' of undefined
    at eval (eval at <anonymous> (), <anonymous>:1:53)
    at eval (eval at <anonymous> (), <anonymous>:108:3)
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$react_native$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$react_native$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
    at WebSocket.eval ()
#2019-10-1511:43thhellerdid you eval this at the REPL? well I can see that you did. I mean did you eval the ns properly too?#2019-10-1511:44thhellerit might be a problem in the REPL. or does this also happen if you load the app regularly?#2019-10-1511:45thhellermaybe there is some subtle code loading issue. so please try using this in actual code (without the REPL)#2019-10-1511:48vinursyes, i tried, when not in repl it works ok#2019-10-1511:48vinurswhy i can not evel it in the repl?#2019-10-1511:51thhellerI don't know. I'll look into it#2019-10-1511:51vinurs^_^ thanks#2019-10-1511:57thheller@haiyuan.vinurs if you have something reproducible it would help immensly if you add it to https://github.com/thheller/shadow-cljs/issues/574#2019-10-1511:58vinursok#2019-10-1512:03vinurs@thheller i retry it, but it now works in repl#2019-10-1512:03vinursstrange#2019-10-1512:03thhelleryeah. I suspect that it works if the code is initially loaded from the build directly#2019-10-1512:04thhellerbut when loaded at the REPL has some scoping issues so can't find the actual code#2019-10-1513:09ghaskins@thheller im seeing an issue and there are two datapoints that I suspect are related#2019-10-1513:10ghaskinsI get this during compilation with “release”: https://gist.github.com/ghaskins/de98175b39fd994e7e5a30740c3a3941#2019-10-1513:12ghaskinsand then this on the phone sim#2019-10-1513:12ghaskinshttps://gist.github.com/ghaskins/5bf2d06f569ff79fe043c5ae4e5c3823#2019-10-1513:12ghaskinsso, if i had to guess, for reasons that are unclear, shadowcljs isnt seeing my reference to .registerComponent and tree-shaking the react-native lib out#2019-10-1513:14ghaskinsI tried to annotate with ^js as I was advised to do in a different context…however, here it doesnt seem to have any effect#2019-10-1513:14ghaskinsim not sure if I need something else (e.g. ^foo)#2019-10-1513:21thheller@ghaskins yeah that code seems bad but I can't tell without seeing more of it#2019-10-1513:21thheller
17 | (defn register-componnet [name root]
  18 |   (.registerComponent ^js app-registry name #(r/reactify-component root)))
#2019-10-1513:21thhellerwhat is app-registry?#2019-10-1513:21ghaskinstheres nothing secret, happy to share#2019-10-1513:22ghaskinshttps://gist.github.com/ghaskins/02396da6a7ae7a3bfc2106b8166be76e#2019-10-1513:22ghaskinshttps://gist.github.com/ghaskins/f43cc2608bbd993efe2ad68a772b1168#2019-10-1513:22thhellerwhat is this mess? 😛#2019-10-1513:23ghaskinshah…me stumbling around trying to learn a bunch of stuff at once#2019-10-1513:23ghaskinsWIP#2019-10-1513:23ghaskinsapologies#2019-10-1513:23thheller(:require ["react-native" :as rn]) (rn/AppRegistry.registerComponent name ...)#2019-10-1513:23ghaskinsin essence, app-registry is the output of an (oget+)#2019-10-1513:24thhellerthats how it should be done#2019-10-1513:24thhellerban cljs-oops from your codebase. seriously. do not use it. not even once.#2019-10-1513:24p-himikThat's the first I see someone disliking cljs-oops. What's wrong with it?#2019-10-1513:26thhellerit is working around issues in the CLJS compiler that have been either fixed for years OR better adressed via :infer-externs#2019-10-1513:28p-himikOK, so it may be unneeded. But is it actually a bad practice to still use it? You say that "shadow-cljs can no longer do its job for externs inference" - what are the repercussions?#2019-10-1513:29thhellerthe error you see above#2019-10-1513:29ghaskins@U2FRKM4TW at least in my case, it caused advanced compilation to fail by eliding a reference actually in use#2019-10-1513:30p-himikTo be honest, I have never seen it with cljs-oops. 🙂 And I use NPM quite a lot. Maybe I was just lucky, I dunno.#2019-10-1513:30thhelleralthough I'm not entirely sure why you get an externs inference warning with the ^js tag added#2019-10-1513:30ghaskinsyeah, that was strange…that fixed it the last time I ran into this#2019-10-1513:30ghaskinsbut I also wasn’t using clj-oops before#2019-10-1513:31thheller@U2FRKM4TW have you ever tried NOT using cljs-oops and just straight interop instead? I mean with shadow-cljs, not before?#2019-10-1513:31thhelleryou can use cljs-oops if you really want to, I just don't think it is necessary#2019-10-1513:32danielnealI used it extensively before I knew about shadow-cljs 😄#2019-10-1513:33thhelleryeah I get why people use it#2019-10-1513:33p-himik@thheller I definitely started using shadow-cljs way past after I started using cljs-oops. I started using oops exactly because I had nasty issues with externs, and I hate cljsjs with passion. Another advantage of cljs-oops, albeit a dubious one, is that Cursive doesn't scream at me with yellow "cannot be resolved"s.#2019-10-1513:33thhellerbut ever since :infer-externs it really isn't useful anymore IMHO#2019-10-1513:34p-himikI should definitely read up on it.#2019-10-1513:34danielnealyeah the infer-externs is great, and just being able to use a ^js tag is genius#2019-10-1513:34thheller(rn/AppRegistry.registerComponent name ...) just take this example#2019-10-1513:34thhellerrn is a namespace alias for "react-native"#2019-10-1513:35thhellershadow-cljs sees that and automatically adds AppRegistry and registerComponent to the externs#2019-10-1513:35thhellerso neither of them are renamed#2019-10-1513:35danielnealAt first I thought the check wasn’t working for me but it turns out I’d put it in the top level shadow-cljs config instead of under :compiler-options. So there’s that 😄#2019-10-1513:36thhellerwith cljs-oops its just a string somewhere. I'm assuming that cljs-oops emits something like rn["AppRegistery"]#2019-10-1513:36thhellerwhich isn't exaclty best practice#2019-10-1513:36ghaskinshttps://gist.github.com/ghaskins/86edd136392f841819300eca2da2255c#2019-10-1513:36ghaskinsworking like a champ, now#2019-10-1513:36ghaskinsthank you#2019-10-1513:36ghaskinsim a little confused why all the other ogets work, but, progress#2019-10-1513:40p-himik@thheller Yeah, it generates exactly that:
(defn gen-key-get [obj key]
  (case (config/key-get-mode)
    :core `(~'js* "(~{}[~{}])" ~obj ~key)           
    :goog `(goog.object/get ~obj ~key)))
Another pro of using it though - you can write selector like :a.?b.c instead of its cumbersome equivalent. Would the issue be remedied if cljs-oops emitted code like x.y instead of x["y"]?
#2019-10-1513:48thheller(some-> a .-b .-c) seems fine to me but thats subjective I guess#2019-10-1513:49thhellerit can't really emit x.y#2019-10-1513:50p-himikAnd also different from what I wrote. 🙂 And cljs-oops also has ! "punch" access. Why not? Can't it write something like (~'js* "(~{}.~{})" ~obj ~key) when key contains a valid JS identifier? Sorry, I've never dealt with such macros that emit JS code.#2019-10-1514:04thhelleryeah can't get into this too much right now but it can't work. especially not when things are called as a function as it was in the example of (defn get-obj [name] (oget+ ReactNative name))#2019-10-1514:05p-himikYeah, I'm not considering the + variety at all. I don't think externs inference would work here either if the names of keys are truly dynamic.#2019-10-1514:07thhelleryes but thats the point. in code they are never "truly dynamic"#2019-10-1514:07p-himikOK, I read up a bit on externs inference. It seems that if I use cljs-oops then this mechanism is completely unneeded for me. And vice versa - if I don't need any of the additional features of cljs-oops, I can stick to the inference. I don't see a clear winner as it doesn't seem that using externs inference would produce smaller or more optimal code.#2019-10-1514:07thhellerin data yes, thats why you use different access patterns for data vs code#2019-10-1514:12thhellerthe issue with cljs-oops is that the code is not future proof#2019-10-1514:12p-himikRegarding 'in code they are never "truly dynamic"' - of course. But specifying everything in a truly static manner that's visible to shadow-cljs could easily end up in creating an AbstractSingletonProxyFactoryBean with all of the consequences. Sometimes it's much easier and simpler to just get a key with a check that it exists, in a dynamic manner.#2019-10-1514:12thhellergranted that future is uncertain and we may not actually ever get there but still#2019-10-1514:13thhellernot sure I understand that comment#2019-10-1514:14thhellerthe problem is :advanced and you need to understand what that is doing. you simply cannot mix using x.y in one place and x["y"] in another#2019-10-1514:15thhellerit is one of the "rules" of the closure compiler#2019-10-1514:39p-himikWell, nothing is truly future proof. We have multiple sets of versions of dependencies, tools, and languages that work together. Everything else makes our bits rot and we're responsible for keeping them fresh. About that "truly dynamic" comment. Consider this code:
(defn f1 [k]
  (oget+ js/Lib k))

(defn f2 [k]
  (case k
    :a (.-a js/Lib)
    :b (.-b js/Lib)
    :c (.-c js/Lib)))
We know what js/Lib is, so we can write f2, easy. But look at how it compares to f1, how much more code there is. And if we want all of the keys to be accessible, we have to keep f2 and js/Lib in sync. Unless there's some option that I'm missing. Note that replacing (f1 :a) with just (.-a js/Lib) is not possible in the general case. E.g. because it immediately removes the ability to iterate over keys. > the problem is :advanced and you need to understand what that is doing Yep, guilty here. I assume that I have some superficial knowledge, but at the same time it completely contradicts what I see - despite all the advanced compilations, I still see my code working with the x["y"] kind of access. To be fair, I just checked all of the instances of oget in one of my projects, and about 90% of them access fields that GCC cannot change (DOM API, external libraries). But the rest 10% access fields that come from NPM libraries. And they still work just fine for some reason! Again - maybe I'm just lucky. > you simply cannot mix using x.y in one place and x["y"] in another If x.y is a known extern (either via externs inference or via explicit externs) and if my understanding of the concept of externs is anywhere near correct, GCC will not rename y to anything. In this situation, using x["y"] should be just fine. When x.y is not a known extern, GCC can rename it to anything under :advanced. And that's exactly where using cljs-oops can bite me, right? I'm more and more interested in why my usage of NPM libraries doesn't explode...
#2019-10-1515:19isak@U2FRKM4TW here is an example:#2019-10-1515:20isakhttps://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250Avar%2520Person%2520%253D%2520function()%2520%257B%250A%2509this.age%2520%253D%252099%253B%250A%257D%250A%250Avar%2520p%2520%253D%2520new%2520Person()%253B%250Aconsole.log(%2522ViaProp%2522%252C%2520p.age)%253B%250A%250Avar%2520key%2520%253D%2520%2522age%2522%253B%250Aconsole.log(%2522ViaKey%2522%252C%2520p%255Bkey%255D)%253B%250A#2019-10-1515:22p-himikOh, thanks, nice! Huh. It's able to substitute k = 'age', p[key] with a.key but it doesn't replace that a.key with a.a.#2019-10-1515:24isakyea, but maybe they don't bother because in many cases the key won't be known at compile time like this simple example, and then advanced would be even harder to reason about#2019-10-1515:36p-himikThere seems to be a more robust reasoning because the README of cljs-oops states: "Google Closure compiler rewrites string literals to dot property access whenever possible." So it seems to rely on it.#2019-10-1515:36p-himikAnd "String names explicitly prevent minification of key names which must stay intact."#2019-10-1515:38isak@U2FRKM4TW only for that "callsite" though, which doesn't help you if the property has been renamed elsewhere#2019-10-1515:40p-himikYes, of course. I just realized that I don't understand yet another thing. Suppose I use (.-field lib) where lib comes from NPM. Why do we even need externs here? Let GCC rename field to something else both in CLJS and in JS code. Or is it simply because GCC cannot really tell without the externs that field in CLJS is the same field as in JS?#2019-10-1515:46isakExterns is for code that is not processed by GCC compiler. It can rename such cases if both the JS and CLJS runs through it. But for shadow, it explicitly does not run npm deps via GCC, because it causes too many problems. I think that is a feature people tried to add to the clojurescript compiler, but they failed#2019-10-1515:53p-himikOh, right, I remember now... It is processed by GCC but only the :simple level of optimizations is used. Which is exactly why cljs-oops is able to work at all. OK, I think I understand now, thanks! And consequently, now I see why using cljs-oops indeed adds something to the set of moving parts. Although I'm still unsure whether it's worth it to dump it at this point or not.#2019-10-1516:02isakOh, you're right. Yea, I'm kind of in the same boat, (not clj-oops but reagent.interop). Haven't tried converting it to all prop access yet.#2019-10-1516:28thhelleryes, the npm code is only running through :simple in a separate compilation step. thats why we still need externs in the CLJS parts. running everything through advanced doesn't work.#2019-10-1516:28thhellerbut if we are ever able to run everything through advanced then cljs-oops becomes a problem. because it mixes direct property access with string access#2019-10-1516:29thhellershould we get to a future where everything is written in strict ESM, then it may actually become a possibility to run everything through advanced#2019-10-1516:29thhellerbut we aren't close to that in any way#2019-10-1513:24ghaskinsah, good to know#2019-10-1513:24ghaskinsi will try that, thank#2019-10-1513:24ghaskinsthanks#2019-10-1513:25ghaskinsi assume the same goes for similar aget approaches#2019-10-1513:25thhellerthe issue with cljs-oops is that shadow-cljs can no longer do its job for externs interence and stuff#2019-10-1513:25thhellerdon't use aget either#2019-10-1513:25ghaskinsroger#2019-10-1513:25thhelleruse proper JS interop, like the language intended#2019-10-1513:26ghaskinsyeah, always good advice..problem is, im a clojure/jvm guy so im a stranger in a strange land on js#2019-10-1513:26ghaskinsbut im learning, thank you#2019-10-1514:52dpsutton@thheller do you remember the reason that CIDER and shadow don't work when using node-script target? I thought that was a known issue but don't remember any details#2019-10-1516:04isakHow is javascript source processed? (Not npm deps, I mean .js under /src). GCC Advanced? (assuming the CLJS is advanced)#2019-10-1516:20thheller@dpsutton not sure what you mean? that should work fine. or are you referring to the https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime?#2019-10-1516:20dpsuttonyes i think so#2019-10-1516:22lilactownworks just fine for me#2019-10-1516:28Macroz@U4YGF4NGM do you mean you have a CIDER + shadow-cljs + node-script running?#2019-10-1516:28Macrozfor me CIDER does not find the project#2019-10-1516:29lilactownyes, my last job was spent mostly developing a node script using shadow-cljs#2019-10-1516:29Macrozdid you use cider-jack-in-cljs?#2019-10-1516:29lilactowntypically I would cider-jack-in-clj and then start the build, but I had many builds in my project#2019-10-1516:30lilactowncider-jack-in-cljs should work#2019-10-1516:30MacrozI must be missing something but no idea what it is
#2019-10-1516:30MacrozI basically just created the shadow-cljs sample project and changed it to node-script but CIDER doesn't find the project#2019-10-1516:30lilactownif you’re in a project dir with a shadow-cljs.edn file, CIDER should pick it up#2019-10-1516:30Macrozyes#2019-10-1516:30lilactownwhat version of CIDER are you using?#2019-10-1516:30Macrozall my previous projects have been lein/figwheel and that works fine#2019-10-1516:31MacrozI'm using 0.24#2019-10-1516:31lilactownhmm that’s newer than me. should be fine#2019-10-1516:31MacrozI just upgraded because I thought that maybe there's something#2019-10-1516:31lilactownI’m on 0.22#2019-10-1516:32lilactowncan you push your repo and I’ll peek at it?#2019-10-1516:32Macrozit wasn't working for me before upgrade, not sure what version that was#2019-10-1516:32Macrozcan you try https://github.com/thheller/shadow-cljs#quick-start and change to node-script?#2019-10-1516:32MacrozI followed that one myself#2019-10-1516:34MacrozI'll try to recreate my problem and push it if I still hit it#2019-10-1516:37lilactownit worked for me#2019-10-1516:37Macrozhmm I got some other problem now#2019-10-1516:38Macrozthanks a bunch anyway! I was looking for confirmation that it should work as advertised without jumping through hoops#2019-10-1516:39lilactown1. npx create-cljs-project acme-app 2. Add build to shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :builds
 {:backend
  {:target :node-script
   :main 
   :output-to "target/backend.js"
   }}}}
3. Create
(ns )

(defn init []
  (prn "init"))
4. in CLJS buffer, M-x cider-jack-in-cljs 5. Select shadow for REPL type. type backend for build ID. 6. In a terminal, run node target/backend.js
#2019-10-1516:41Macrozyes indeed it does not give the problem#2019-10-1516:41Macroznow I shall have to try to compare these two projects ...#2019-10-1516:47Macrozhmm it broke again#2019-10-1516:49lilactown?#2019-10-1516:49MacrozI'll push my repo so you can try#2019-10-1516:50lilactownI won’t be able to get to it for a bit#2019-10-1516:50Macrozit doesn't work for me anymore though it did and I fail to see why#2019-10-1516:51Macroz@U4YGF4NGM it's ok, here it is anyway https://github.com/Macroz/shadow-test#2019-10-1516:51MacrozI'll try to recreate from empty again and see if that works#2019-10-1516:52Macrozping @dpsutton here is what doesn't work for me#2019-10-1516:52lilactownwhat’s the behavior when you say it “doesn’t work”?#2019-10-1516:53Macrozcider-jack-in-cljs does not find the project#2019-10-1516:53Macrozit did for a moment, now I fail to see what changed#2019-10-1516:53lilactownand you’re in /src/main/shadow_test/core.cljs?#2019-10-1516:53Macrozyes#2019-10-1516:54lilactownat this point I would bring it to #cider might be a bug#2019-10-1516:54MacrozI did#2019-10-1516:54Macrozlooking for more info now#2019-10-1516:54lilactownyeah it has nothing to do with #shadow-cljs. shadow-cljs works fine with node-script, I don’t know what dpsutton was talking about#2019-10-1516:55Macrozshadow-cljs does indeed work here because I can build the project fine, just that CIDER does not find it#2019-10-1516:55Macrozand it was nice to hear from you and confirm that it should work#2019-10-1516:55MacrozI still don't have clear steps for repro#2019-10-1517:03dpsuttoni was referring to the missing js runtime error#2019-10-1517:03dpsuttonyour step 6 is the solution as i understand it#2019-10-1517:03lilactownyeah, that’s not a problem. just people not understanding how CLJS works#2019-10-1517:04lilactownCLJS requires you to run a JS process. for web stuff it’s the browser window. for node it’s the node script#2019-10-1517:05MacrozI get my error in step 4#2019-10-1517:07MacrozI don't understand how it could work for a while, then again not. I have now three projects and none of them work#2019-10-1517:07Macrozsome race condition in my Emacs/CIDER setup?#2019-10-1517:11MacrozAFAIK I'm not doing anything strange#2019-10-1517:19Macrozok strangeness continues#2019-10-1517:19MacrozI delete-package clj-refactor , comment it out in my .emacs, restart emacs, doesn't work uncomment clj-refactor in .emacs then start emacs and let it reinstall clj-refactor, now it works#2019-10-1517:20Macrozrestart emacs and it stops working#2019-10-1517:22Macrozso cider-jack-in-cljs works in shadow-cljs project iff I have just reinstalled clj-refactor Emacs package#2019-10-1517:22dpsuttoncan you try it without clj-refactor installed at all?#2019-10-1517:23dpsuttonand what exact error are you seeing? i know clj-refactor doesn't know that shadow is a project root. but i think its just a warning that clj-refactor won't be enabled and everything should work fine#2019-10-1517:23Macrozso if I delete-package and restart without it, doesn't work#2019-10-1517:23Macrozexact error is >>> Are you sure you want to run `cider-jack-in' without a Clojure project#2019-10-1517:24dpsuttoncan you elaborate on exactly what "doesn't work" means#2019-10-1517:24MacrozI get that error in a shadow-cljs project#2019-10-1517:24MacrozI should instead be able to jack in#2019-10-1517:24MacrozCIDER does not recognize my shadow-cljs project#2019-10-1517:24Macrozonly after fresh install of clj-refactor package ...#2019-10-1517:25Macrozthe shadow-cljs project is as in the github project earlier in this thread created by the shadow-cljs quickstart guide#2019-10-1517:25dpsuttoncan you put it on github exactly as you have it?#2019-10-1517:25Macrozit is there#2019-10-1517:25dpsuttonlink?#2019-10-1517:26Macrozscroll up a bit#2019-10-1517:26Macrozshadow-test#2019-10-1517:26Macrozhttps://github.com/Macroz/shadow-test#2019-10-1517:37MacrozI'm trying with a clean .emacs and I'm seeing it working#2019-10-1517:43dpsuttonyeah works for me#2019-10-1518:12MacrozI'll bisect my .emacs in a bit#2019-10-1518:59MacrozAFAIK it's my own fork of clojure-mode that is slightly out of date#2019-10-1519:00Macrozso that's where the list of project files is kept#2019-10-1519:01Macrozit's missing the one for shadow#2019-10-1519:01Macrozlogical that it's the reason why the project is not found but surprising that the code is there#2019-10-1519:01Macrozhave to rebase to origin/master#2019-10-1519:02Macrozthanks @U4YGF4NGM and @dpsutton for working this out with me#2019-10-1516:20thheller@isak it depends on how you write the code#2019-10-1516:20thhellerES6 is going through GCC advanced#2019-10-1516:21thhellerCJS is treated the same as node_modules, so no :advanced#2019-10-1516:22isak@thheller hm, how can I tell? I didn't think about ES6 when writing, but did for example "goog.provide(...)" at the top, and followed the Closure JS rules#2019-10-1516:23thhelleryes if you write in the closureJS style that also goes through advanced#2019-10-1516:23thhellerbasically if you use require it goes with commonjs#2019-10-1516:24thhellerif you use import/export it is treated as ESM and advanced#2019-10-1516:24isakah, cool. got it, thanks.#2019-10-1516:24thhellerit is kind of in a weird spot for interop reasons#2019-10-1516:24thhellercommonjs <-> esm interop that is#2019-10-1516:25thhellershould prefer esm whenever possible but that gets a bit tricky when mixing with commonjs (ie. node_modules)#2019-10-1516:31beetlemanRecently I started extracting shadow-cljs hooks which I used into the library, maybe it will be handy for somebody: https://github.com/beetleman/shadow-cljs-hooks/#2019-10-1516:34thhellersweet#2019-10-1517:12beetlemanIt's need bit more love to being sweet but I will work on it;)#2019-10-1517:13thhellerI added a similar hook recently btw https://github.com/thheller/shadow-cljs/commit/2d0af30dd064c28e5c74846af5272a9e24276fb0#2019-10-1517:13thhellerbut it just takes a pre-made index.html and replaces the script paths#2019-10-1517:13thhellernot yet documented, was going to use this as a documentation example#2019-10-1517:16beetlemanI wanted to have something similar to https://github.com/jantimon/html-webpack-plugin/blob/master/README.md#2019-10-1517:17thhelleryep, me too. just something really simple so I don't have to explain too much 😉#2019-10-1517:17thhellerso less complex than yours#2019-10-1517:17beetlemanCopy file hook looks good to.#2019-10-1517:19beetlemanI play now with idea his to make management of images simpler#2019-10-1517:20beetlemanSomething like https://www.npmjs.com/package/image-webpack-loader#2019-10-1517:20thhelleryeah seems useful. although I probably wouldn't do it as a hook#2019-10-1517:22beetlemanPartly. As configuration, rest as macro with return path#2019-10-1517:22beetlemanIts initial idea#2019-10-1517:22thhellerI would probably have it "index" the files and copy if needed#2019-10-1517:23thhellerand then provide a data file like {"/img/foo.png" "/actual/path/img.hash.png"} or more complex if needed#2019-10-1517:23beetlemanCopy dir can be good enough#2019-10-1517:23thhellerand then load that file at runtime#2019-10-1517:23thhellerotherwise changing an image will require recompiling JS which makes no sense to me 😛#2019-10-1517:26beetlemanI do not know source code of shadow-cljs but I saw hooks and want something morw user friendly like webpack have;)#2019-10-1517:27beetlemanI'm not started worked on images. But my idea was similar to your. But I must work on implementation/#2019-10-1518:21mruzekwHas anyone been able to set up shadow-cljs to work well with AWS lamda functions? I’d like to use Zeit Now. Basically all *.cljs files in the /src/api folder would be compiled into the build/api folder as JS files and then the build files would be shipped via now#2019-10-1518:24thhellerthere are examples for both zeit and aws out there#2019-10-1518:29thhellerI made a netlify example a while ago. zeit is pretty much the same https://github.com/thheller/netlify-cljs#2019-10-1518:43David PhamAnyone has a guide about web workers? I read shadow-CLJS documentation but I am not sure if I understand everything and if there is anything else to know to use webworkers #2019-10-1518:44thhellerwhat do you want to know?#2019-10-1518:44thhellerhard to write something more generic than the docs 🙂#2019-10-1518:56mruzekwI’m following this for shadow-cljs on zeit now https://github.com/jntn/haiku#2019-10-1518:57mruzekwWhat I can’t figure out is how to add multiple functions beyond haikus#2019-10-1518:57mruzekwIs there anyway without adding a new build for each lambda?#2019-10-1519:03thhellernot sure how that works either. not sure if they need to be bundled separately or if you can have multiple in one bundle#2019-10-1519:04mruzekwI can look into that, but I think this example is based on a folder/file pattern#2019-10-1519:05mruzekwThus any new function would be src/api/fn -> api/fn/index.js#2019-10-1519:05mruzekwBut there might be a way to map functions from one single file with multiple exports#2019-10-1519:05mruzekwThat would mean updating now.json though, which sounds preferable#2019-10-1519:06thhellerit would be easy to have shadow-cljs generated multiple files#2019-10-1519:06thhelleror just writing a tiny bit of boilerplate JS by hand#2019-10-1519:08David Pham@thheller Is there anything else to know about webworkers? #2019-10-1519:10thhellerdepends. what do you want to build?#2019-10-1519:14David PhamDelegate some computation off the main thread to avoid blocking#2019-10-1519:15thhellerthe difficult part is often the data sharing#2019-10-1519:15thhellerif you have to serialize too much back and forth that it is often not worth doing in the first place#2019-10-1519:18David PhamThe communication could be async though right? I am not so concerned about speed, more about blocking the UI#2019-10-1519:19thhellerno sync is not possible#2019-10-1519:19thhellerall async always#2019-10-1519:32David PhamThanks a lot!! :)#2019-10-1519:10mruzekw> it would be easy to have shadow-cljs generated multiple files By an existing config? Or something that would need to be built?#2019-10-1519:11thhellersomething that might need to be built. it is mostly about figuring out how zeit/aws want stuff to be organized#2019-10-1519:11thhellerand outputting it in that style#2019-10-1519:14thhellerbut thats the entire point of the :target abstraction in shadow-cljs#2019-10-1519:14thhellerfigure out the minimal amount of config needed and implement it 😛#2019-10-1519:17mruzekwSure, how are targets implemented?#2019-10-1519:17mruzekwIs there a concept of target-plugins?#2019-10-1519:17thhellerit isn't really documented but the defaults are here https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2019-10-1519:18thhellerie :target :browser responds to browser.clj in that dir#2019-10-1519:18thhelleranyone in theory could write those since it also accepts symbols :target my.custom/stuff#2019-10-1519:18thhellerbut given that there is no documentation I don't really expect anyone to write these just yet 😛#2019-10-1519:23thhellerbasically it is one function that gets called repeatedly going through the stages#2019-10-1519:23thhellersame as build hooks#2019-10-1519:23mruzekwOkay, thanks. I will look into this for the long-term#2019-10-1519:25mruzekwFor reference, the expected output for zeit is flexible
{ "src": "/api", "dest": "/my-api.js" },
    { "src": "/users", "methods": ["POST"], "dest": "/users-api.js" },
    { "src": "/users/(?<id>[^/]*)", "dest": "/users-api.js?id=$id" },
#2019-10-1519:25mruzekwBased on the config#2019-10-1519:26thhellerand those files then each just have a singular export?#2019-10-1519:26thhellerlike module.exports = function(req) ... or whatever?#2019-10-1519:26mruzekwThere is the zero-config option which behaves like:
{
            "src": "/api/(.*)",
            "dest": "/api/$1"
        }
#2019-10-1519:26mruzekwYes#2019-10-1519:26mruzekwAnd since they’re separate functions, the dependencies would be bundled in each#2019-10-1519:28thhellernot sure what you mean by that. the /my-api.js has to be self-contained without require of its own?#2019-10-1519:29thhellerI built this some time ago which basically had the config for stuff in metadata in CLJS#2019-10-1519:29thhellerhttps://github.com/thheller/shadow-cljs/issues/297#2019-10-1519:29thhellerthe compiler would then use it for structure the output#2019-10-1519:29thhellermaybe something like that would work for zeit too#2019-10-1519:30thhellerI had plans to build examples for more of these platforms .. but it is really time intense to figure out how they all work#2019-10-1519:30mruzekwEach function should be considered isolated, I’m assuming deps would need to be bundled with each#2019-10-1519:31mruzekwSure, happy to help given it fits with what I’m already working with#2019-10-1519:32mruzekwYou could also either document the symbol usage or open up some way for people to build plugins and download those#2019-10-1519:32mruzekwMight take the load off of doing it all yourself#2019-10-1519:33thhellerwell, if I knew how to document this stuff properly I would#2019-10-1519:33thhellerbut there is so much stuff to consider on certain platforms#2019-10-1519:33thhellerjust compare browser.clj vs node_script.clj or so#2019-10-1519:34thhellerone is trivial, the other is not 😛#2019-10-1519:34mruzekwhaha indeed#2019-10-1519:34thhellerthe basic setup is always the same, configure stuff, tell the compiler which files it should compile, then "post-process" everything into the right shape#2019-10-1519:35mruzekwpost-process === post closure?#2019-10-1519:35thhellerpre and post yes#2019-10-1519:36mruzekw:compile-prepare :compile-finish#2019-10-1519:36thhellermost of the custom works happens in :flush#2019-10-1519:36mruzekwWhen you say document properly, what do you mean?#2019-10-1519:36thhellersince thats the part actually writing stuff to disk#2019-10-1519:37thhellerwell document the internal "build api" basically#2019-10-1519:37mruzekwI see#2019-10-1519:37thhellerbasically what the compiler needs is :modules config#2019-10-1519:38thhellerall build targets use that abstraction#2019-10-1519:39thhellerso :node-script basically just is syntax sugar for :modules {:main {:entries [that.main.ns] :append-js "that.main.ns.main(process.argv)"}}#2019-10-1519:39thhellerwith a bit more platform related stuff#2019-10-1519:40thhellerso for the zeit stuff there would probably be one shared module and then one per fn#2019-10-1519:40thhellerand just combined again later. or something like that#2019-10-1519:41mruzekwGotcha#2019-10-1519:42thhellerwell yeah .. documentation needs to be written ...#2019-10-1519:42mruzekwIs there an example of the :node-script to :modules mapping?#2019-10-1519:43mruzekwErr, more examples? Just to grasp the concept#2019-10-1519:43mruzekwOr is this more of a conceptual thing rather than technical#2019-10-1519:43thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/node.clj#L82-L86#2019-10-1519:44mruzekwGot it#2019-10-1519:46mruzekwCool, well I’ll give this a look later on and see what I can do to help#2019-10-1519:46mruzekwHave to peace out for now#2019-10-1519:46mruzekwThanks!#2019-10-1520:40Macrozsigh so what's the best way to solve advanced compilation problems (I have set optimization simple, pretty-print, pseudo-names and)#2019-10-1520:40Macroz
TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
#2019-10-1520:41Macrozno problem in dev mode, only in release build (also with --debug)#2019-10-1520:45Macrozlooks like it's a line with clj->js#2019-10-1520:57Macrozchanging to advanced compilation fixes that but then one of the npm dependencies breaks#2019-10-1520:59Macroz^js tagging that one method call works#2019-10-1520:59Macrozbut I wonder what breaks cljs.core when using optimization simple#2019-10-1521:33David PhamWhat are the disadvantage of using deps.edn with shadow-CLJS? #2019-10-1603:59Jon#2019-10-1603:59Jonnoticed I have so many jar files on my disk... each shadow-cljs is >10M size.#2019-10-1604:00Jonthey are installed in node_modules/.#2019-10-1604:01Jon16M x 120 ~= 1.8G#2019-10-1604:57sogaiuthe good part is that i know how to get extra disk space when i'm getting lower 🙂#2019-10-1604:58superstructor@thheller We have observed significant performance regressions with console.log in shadow-cljs vs upstream ClojureScript (e.g. figwheel) with large and complex nested data structures. Are you aware of any issues regarding that ? I think it has to include vectors to trigger the issue i.e. heavily nested {:key [ { ... } ...]} and not just {:key {... { ... }}. We are working on a reproducible test case but just wanted to get feedback from you before we work more on that.#2019-10-1604:59superstructorWhen I say 'performance regressions' it is on the order of milliseconds (upstream cljs) vs 30 seconds (shadow-cljs) for some data structures.#2019-10-1609:06thhellerthe only difference I can think of is the built-in minimal console formatters support vs using cljs-devtools?#2019-10-1609:14thhellertry either using cljs-devtools (just add the dependency) or :devtools {:console-support false}#2019-10-1716:48superstructorStill slow with both, working on trying to pull a reproducible test case out of the app with the issue.#2019-10-1716:54thhellerdid your figwheel setup have either of those though?#2019-10-1716:54thhellershadow-cljs has one by default, figwheel only if you configure it#2019-10-1716:55thhellerthat is pretty much the only thing that even has the potential to make console.log slow#2019-10-1606:36MacrozShould :after-load fire for :node-script apps? I get :before-load-async but not :after-load?#2019-10-1609:07thheller@macroz well did you call the callback argument passed to :before-load-async? otherwise it won't proceed.#2019-10-1609:09thheller@jiyinyiyong that is the maven library handling the download of :dependencies. last time I tried changing how that was handled (and downloaded less) you complained about it not working with the chinese firewall and stuff#2019-10-1610:34Jon#2019-10-1610:34JonI still have problem downloading the jar sometimes when I use latest versions which has not been mirrored.#2019-10-1610:35Jonso I use this script to download.#2019-10-1610:36Jonmost times it's downloaded from the mirror.#2019-10-1610:36Jonforgot about details of last conversion on that...#2019-10-1610:38Jonbut it's true npm packages takes really large disk space. normally 35M for https://github.com/TopixIM/woodenlist#2019-10-1610:38Jon142M for https://github.com/jimengio/ts-workflow#2019-10-1610:39thhellermaybe I'll revisit the different download strategy. makes sense given how many people use deps.edn/project.clj anyways#2019-10-1610:39thhellerjust backed off last time due to china not working#2019-10-1610:40Jonmuch better now since I use mirror and the script.#2019-10-1609:09thhellercompared to how many other node_modules you have installed I guess it is probably fine 🙂#2019-10-1609:15doesntmeananythingDoes anyone know how to turn on profiling in production with React developer tools using shadow-cljs? Dev environment seems to support that just fine by default, although I don't see an explicit option anywhere. The official doc refers to CRA and Webpack configs in order to enable this option: https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977#2019-10-1609:17Macroz@thheller thanks that did the trick, the callback where the done-call was wasn't called#2019-10-1609:17MacrozI only saw the stop being called#2019-10-1609:24Macrozthe NPM library I have doesn't seem to have a suitable teardown for live reload#2019-10-1609:25thhellerthen it probably doesn't do anything async and you just call (done) directly?#2019-10-1609:37Macrozit starts a server on a port and I had to add a manual wait for it to close to be able to bind again#2019-10-1609:37Macrozso now I wait for the port to be free then call done#2019-10-1609:18thheller@andrey.krasnov.pm seems like :js-options {:resolve {"react-dom" {:target :npm :require "react-dom/profiling"}}} https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2019-10-1609:22doesntmeananythingWhoa, thank you very much! Testing now...#2019-10-1609:55johndonneHi! I'm trying to use basscss in my project. Basically I need to load the css contained in the basscss node module, which I installed with npm. How to do this?#2019-10-1610:03thhellershadow-cljs has no support for CSS so you need a different tool for this#2019-10-1610:03thhellerit likely just contains a single .css file#2019-10-1610:03thhellerso you could just copy that to wherever your web files live and access it directly#2019-10-1610:03thhellercp node_modules/basscss/whatever.css public/css/bass.css#2019-10-1610:06johndonneOK thanks I will try 🙂#2019-10-1615:35Daniel LeongIs it intended that :repl {:middleware} doesn’t get applied from the global config.edn to every project?#2019-10-1618:54Johanwhy would shadow-cljs tell me I have a stale client when it compiles without issues?#2019-10-1618:56p-himikYou probably have a cache issue. 8 days ago someone asked the same question, you can still find the thread via the search box.#2019-10-1619:07JohanThanks but I have cleared cache in chrome, disabled caching in the network tab, and I'm using the built in server. Still see this message.#2019-10-1619:13JohanI tried restarting and also deleteing .cpcache and .shadow-cljs folders.#2019-10-1619:15lilactownmight be some sort of directory/file mismatch#2019-10-1619:15lilactownmake sure your index.html is pulling in the right js file, that you’re building the right build in the right dir, etc.#2019-10-1619:34JohanYepp, thank you, I was trying to use /workspaces/js/main.js instead of /js/workspaces/main.js. Editing index.html solved it.#2019-10-1619:30jamescroftI've tried all of the different ways of importing npm packages (listed here: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages) but I keep running into the SHADOW import error .shadow-cljs/builds/renderer/dev/out/cljs-runtime/shadow.js.shim.module$react_dnd_html5_backend.js. I'm trying to import the npm package react-dnd-html5-backend version 9.4.0. I'm importing other packages without problem#2019-10-1619:41thhellerwhats the actual error? this is just telling you WHAT failed. the WHY is either further up or down depends on the error#2019-10-1619:49jamescroft@thheller This is what I'm seeing. I think it may be because I'm developing an electron app and the target is set to node-library.#2019-10-1619:50jamescroftIf I just try and require the package using the electron node then I see this error:#2019-10-1619:50jamescroft#2019-10-1619:51jamescroftSo, is it because the package i'm requiring is using an import HTML5Backend and that syntax isn't supported for node-library?#2019-10-1619:51thhellerthe syntax isn't supported by node#2019-10-1619:52thhellerhas nothing to do with shadow-cljs#2019-10-1619:52thhellerbut if you do a browser build that file will be transpiled#2019-10-1619:52thheller:node-library just uses require and lets node resolve it. which seems to fail because of the import#2019-10-1619:54jamescroftok, understood. I'm not doing a browser build because some of the other packages required are node specific and aren't supported in the browser. I'll add another build and see if I can find a way to separate out the code into a browser package and a node package.#2019-10-1619:55thhellerI think node has some experimental support for import and stuff#2019-10-1619:55thhellerbut I think it is behind some flag#2019-10-1619:55thhellerand not sure if you can enable it for electron#2019-10-1619:57lilactownhow would you even use react-dnd in node#2019-10-1619:58jamescroft@U4YGF4NGM it's an electron app so it's a weird mix of node and the browser. You have a browser window but you can also use node packages#2019-10-1619:59lilactownI’m not sure how the build process is working but I would ensure that you are only including that library in the build that gets loaded in the electron window, not the backend script#2019-10-1619:59lilactownunless I’m mistaken#2019-10-1620:00thheller@U4YGF4NGM you can use require directly in the "renderer". so in the browser.#2019-10-1620:00lilactown😵#2019-10-1620:00jamescroftI'm using a node library (https://github.com/automerge/hypermerge) for the state management. I can require this in the browser#2019-10-1620:01jamescroftEven though it wouldn't work in a regular browser#2019-10-1620:01thhelleryou can use sort of a hybrid build I guess#2019-10-1620:02lilactown
$ npm i react-dnd-html5-backend
npm WARN 
#2019-10-1620:02thhellerhttps://github.com/thheller/shadow-cljs/issues/290#2019-10-1620:02thhellerso you could use :keep-native-requires true and :keep-as-require #{"the-libs" "that-work"}#2019-10-1620:02thhellerbut probably best to just have 2 separate builds#2019-10-1620:02lilactownyou could also try and import it via the react-dnd-html5-backend/dist/cjs instead#2019-10-1620:03thhelleryeah that might also work#2019-10-1620:03jamescroftThanks for the suggestions. Will explore the two builds and cjs approaches 👍#2019-10-1620:08jamescroft["react-dnd-html5-backend/dist/cjs" :default HTML5Backend] seems to be working 🎉#2019-10-1621:16jimberlageIs there any obvious reason why (js/require "./assets/images/my-image.png") wouldn’t work in a react native project? I’ve checked that the file exists. Getting an error that it “doesn’t exist in the Haste module map”#2019-10-1702:21ghaskins@U4QC052UQ one thing to note/check is that the path is relative to the shadow-cljs :output-dir, not the top-level of your project. Since I typically do something like
:output-dir "target"
, for me I would typically need “../assets/images…
#2019-10-1713:47jimberlageAh, I didn’t consider doing ... Good call!#2019-10-1621:16jimberlageI’m suspecting that something about the way I’m requiring the image is off#2019-10-1621:25lilactownbizarre broken compiled output in dev mode (haven’t tested release):
amperity.admin.ui.srv.authn.logout_BANG_ = (function amperity$admin$ui$srv$authn$logout_BANG_(){
if(cljs.core.truth_(amperity.admin.ui.srv.authn.web_auth)){
return .logout(({"clientID": amperity.admin.ui.srv.env.auth0_client_id, "returnTo": amperity.admin.ui.srv.authn.current_root_uri()}));
} else {
return null;
}
});
offending CLJS code:
(defn logout!
  "Log the user out of Auth0."
  []
  (when web-auth
    (.logout ^js web-auth
             #js {:clientID env/auth0-client-id
                  :returnTo (current-root-uri)})))
#2019-10-1621:25lilactownnote the .logout(...)#2019-10-1621:37lilactownremoving the when fixes it 😵#2019-10-1706:13heefoowhat happens if you substitute when with if ?#2019-10-1708:53thheller@lilactown thats a known bug in CLJS. I think the fix is in master. can't remember the ticket number, something related to type-inference#2019-10-1711:43ghaskins@thheller following up on the cljs-protobuf conversation: im trying to untangle the next problem (adding grpc-web on top of google-protobufs#2019-10-1711:44ghaskinswhen I go with a closure-based output, I see an error like this#2019-10-1711:44ghaskins
The required namespace "grpc.web.GrpcWebClientBase" is not available
#2019-10-1711:44ghaskinsI see its defined here: https://github.com/grpc/grpc-web/blob/8b501a96f427603ee600d3ff0291eff932fb54a1/javascript/net/grpc/web/grpcwebclientbase.js#2019-10-1711:45ghaskinshowever, when referencing it purely from the npm “grpc-web” package, I see#2019-10-1711:45ghaskinshttps://gist.github.com/ghaskins/1a65d1650d39f8810cef79ade407ac0c
#2019-10-1711:46ghaskinsso, if I had to guess, something about the way the community packages the npm package loses the export in translation#2019-10-1711:46ghaskinsis that a good summary of the problem?#2019-10-1712:21thheller@ghaskins don't try to use this npm packages#2019-10-1712:21thhellerjust copy the contents of https://github.com/grpc/grpc-web/tree/8b501a96f427603ee600d3ff0291eff932fb54a1/javascript into the src/protobuf dir#2019-10-1712:21ghaskinsyeah, im using your approach to jspb on grpc-web#2019-10-1712:22ghaskinsyep, thats what I am doing now#2019-10-1712:22ghaskinsit seems to work, though I saw one thing in release builds that might be an issue#2019-10-1712:22ghaskinsstill investigating#2019-10-1712:22ghaskinsty#2019-10-1712:22ghaskinsis this a common problem, or something inherent to how the pb/grpc community is packaging for npm?#2019-10-1712:23thhellerthe thing about all of this is that the "greater" JS ecosystem has no clue how to consume closure JS code#2019-10-1712:24thhellerso to get this all accessible to the npm world they "wrap" everything in some boilerplate code to make it work with npm#2019-10-1712:24thhellerand that is always strictly worse than just consuming the closure JS code directly#2019-10-1712:24thhellerwhich is no problem for use given that we use the closure library + compiler anyways#2019-10-1712:25thhellerBUT since that is not a "common" thing in the JS ecosystem#2019-10-1712:25thhellerthere are not "pure" closure JS packages#2019-10-1712:25thhellerie. you could put the grpc-web stuff into a .jar and publish it as a regular library#2019-10-1712:25thhellerbut they (ie. google) doesn't even do that for the closure-library itself#2019-10-1712:28thhellerwhats the release build issue? this should be working out of the box as far as I can tell (no custom config)#2019-10-1712:37ghaskinsstill investigating, but preliminary issue seems to be that the “typeUrl” field in any.js was renamed to “om”#2019-10-1712:38ghaskinsright now, trying to clean up so I can reproduce more scientifically#2019-10-1712:38ghaskinsill post back my findings, and with reproduction steps if I can#2019-10-1712:38thhellerthat would be normal behavior in advanced optimized code#2019-10-1712:39thhellerwhy is that a problem though?#2019-10-1712:39ghaskinsit might be exposing a different issue#2019-10-1712:39thhellerit would only be a problem is you are accessing typeUrl incorrectly in your own code?#2019-10-1712:39ghaskinsit materialized as not recognizing the message type#2019-10-1712:39ghaskinsyeah, it could just be that (or some other substrate related to it#2019-10-1712:40thhellerso just to be clear. you have removed ALL references to npm code from this?#2019-10-1712:40ghaskinsthats what I am doing now#2019-10-1712:40thhellerit will not work if you mix it with ANY npm code#2019-10-1712:40ghaskinsto be clear: ive removed the “google-protobuf” and “grpc-web” npm packages, but I have others#2019-10-1712:40ghaskinsi assume that is ok#2019-10-1712:40thhelleras long as they aren't protobuf related that is ok yes#2019-10-1712:41ghaskinsok#2019-10-1712:41ghaskinslet me get a clean run in and ill report back#2019-10-1712:41ghaskinsi suspect if its even an issue, its an issue like you mentioned (something else, probably my code, doing the wrong thing)#2019-10-1712:43thhellerFWIW you can prevent it from changing the name via externs#2019-10-1712:44thhellerjust create a externs/app.txt with typeUrl#2019-10-1712:44thhellerthen it won't rename that field. although you should find out why renaming it is a problem because it shouldn't be#2019-10-1712:47ghaskinsah, awesome#2019-10-1712:47ghaskinsty, i will keep that in my backpocket#2019-10-1717:56ghaskins@thheller so i confirmed this does indeed break for release, and I think I understand why#2019-10-1717:56ghaskinsin essence, I am using a flow like (js->clj (.toObject pb)) so I can use clojure’s destructuring#2019-10-1717:57ghaskinse.g.
(let [{:keys [typeUrl]} (js->clj ..)])
#2019-10-1717:58ghaskinsnot just here, where the Any type is not that difficult to work with either way#2019-10-1717:58ghaskinsbut for custom types, etc#2019-10-1717:58ghaskinsis there any way to disable the field renaming for an entire module?#2019-10-1717:59ghaskinsjust curious if I need to abandon the .toObject approach#2019-10-1717:59ghaskinsbut it does strike me that renaming fields with ABI implications is probably not ideal#2019-10-1719:58thhellerusing js->clj just for the destructuring is a really bad idea. performance and code wise#2019-10-1719:58thhellerbut yes that would break with renaming enabled#2019-10-1719:58thhellerthere is no way to turn it off other then by specifying all the field names in the externs#2019-10-1720:05ghaskinsyeah, you are probably right. Of course, my use is not quite as simplistic and crude as I imply above. Generally I just run js->clj on message receipt and then the map is passed around, destructured as needed.#2019-10-1720:05ghaskinsbut point taken#2019-10-1720:06ghaskinsbut it would seem that if I want to use jspb and advanced, I have little choice#2019-10-1720:06ghaskinsthanks again for the help#2019-10-1720:11thhelleryou can always go back to the npm version and we can try to figure out why that wasn't working#2019-10-1720:11thhellerit could also be fixed in the code without externs but that requires modifying the generated sources which isn't great#2019-10-1721:08ghaskinsis that simply because the commonjs code cant be optimized?#2019-10-1721:19thhellerit is optimized but not with :advanced#2019-10-1721:20thheller:advanced optimizations is really the ultimate goal since it makes your code sooooo much smaller which is good in pretty much all environments#2019-10-1721:20thhellermakes your app start faster and so on#2019-10-1721:21thhelleranother way out is just turning off the propery renaming globally#2019-10-1721:21thhelleryou were writing a react-native app IIRC#2019-10-1721:21thhellerso code size isn't the most important thing in the universe#2019-10-1721:21thheller:compiler-options {:property-renaming false} will turn off the renaming globally#2019-10-1721:21thhellerno externs needed after that point#2019-10-1721:22thheller:compiler-options {:optimizations :simple} will be substantially bigger#2019-10-1721:37ghaskinsawesome on property-renaming#2019-10-1721:37ghaskinswill give that a shot#2019-10-1721:37ghaskins(yes I am currently working on react-native#2019-10-1721:37ghaskinsand agree size isnt super critical#2019-10-1721:38ghaskinsoddly, :simple blows up in xcode when I try to archive the .ipa#2019-10-1721:39thhellerthe output easily goes to several MB with :simple#2019-10-1721:39thhellermaybe it contains code patterns it doesn't like#2019-10-1721:40thhellerthe react-native metro packager also had issues with :simple I believe#2019-10-1721:43ghaskinsyeah, IIRC, :advanced is about 400k and :simple is ~5.5MB#2019-10-1721:44ghaskinsfor this particular app#2019-10-1721:44thhellerdoh#2019-10-1721:44ghaskinsanyway, code cranks on trying to package up the main.jsbundle in a node process and eventually hits an OOM threshold and dies#2019-10-1721:44thheller:property-renaming should only add like 20% or so#2019-10-1721:44ghaskinsthat might be perfect#2019-10-1721:45ghaskinsI had resolved myself to worse, already, heh#2019-10-1721:45ghaskins(i.e. shipping :none or dropping my beloved destructuring)#2019-10-1721:45thheller:none is worse than :simple 😛#2019-10-1721:46ghaskinsyeah, except it completes AND runs#2019-10-1721:46ghaskinstwo key criteria, heh#2019-10-1721:46thhellermaybe consider using https://github.com/mfikes/cljs-bean instead of js->clj#2019-10-1721:46thhellerit isn't perfect but waaaaaaay better than js->clj#2019-10-1721:47ghaskinsawesome, ty#2019-10-1721:47ghaskinswill check that out#2019-10-1721:47thhellerstill suffers the renaming problem though#2019-10-1721:47ghaskinsyeah, im about to fire up :property-renaming#2019-10-1721:47ghaskinsthat might be perfect#2019-10-1721:50thhellerit might still blow up though since :advanced won't be able to identify that you are actually using the property#2019-10-1721:50thhellerso it may just decide to remove it entirely#2019-10-1721:51ghaskinsah, i can see how that might be#2019-10-1721:51thhellerbut just to repeat. adding externs is probably the easiest and fastest way to fix it#2019-10-1721:51thhellereither via interence type hints or just manual externs/app.txt#2019-10-1721:52thhellerthen you don't have to worry about renaming or removal#2019-10-1721:57ghaskinsas you suspected, things werent quite right with just the property-renaming, though i dont quite understand what actually happened#2019-10-1721:58ghaskinsI did observe that :typeUrl was left unperturbed, but there were other :advanced related issues that cropped up#2019-10-1721:59ghaskinswhat I dont get is why those worked when propety renaming was enabled.#2019-10-1721:59ghaskinsoh well#2019-10-1721:59ghaskinsi now know my options, anyway#2019-10-1722:02thhelleryeah :advanced can be tough sometimes#2019-10-1712:29thhellerbut you have to use it correctly still, so no (:require ["grpc-web" ...])#2019-10-1712:30thhellerjust make sure that all code you generate uses the closure JS output#2019-10-1712:31thhellernever mix it with commonjs or so#2019-10-1712:31thhellereither go purely this way or purely npm#2019-10-1714:13vinurs
(let [username (r/atom "")]
  (swap! username "admin"))
i eval this, it outputs
TypeError: f.call is not a function
    at Object.eval [as cljs$core$ISwap$_swap_BANG_$arity$2] ()
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] ()
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] ()
    at cljs$core$swap_BANG_ ()
    at eval (eval at <anonymous> (), <anonymous>:2:29)
    at eval (eval at <anonymous> (), <anonymous>:3:3)
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$react_native$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$react_native$handle_message ()
#2019-10-1714:14p-himikswap! expects a function. You probably wanted to use reset!.#2019-10-1714:15vinursoh, i see, thanks#2019-10-1714:43sbis that possible run npx command via shadow.api? eg ‘npx sass --watch sass/main.scss:public/css/main.css’#2019-10-1714:45thhellerno#2019-10-1714:45thhellerjust run it separately#2019-10-1714:45sbok, thanks. yes, in this case!#2019-10-1714:46thhellerthere are enough tools that only focus on running things in parallel. use one of those#2019-10-1719:23magraHi! shadow-cljs works fine and fast. But once in a while my app stops working (fulcro) and shadow-cljs in the browser reports that semantic-ui node modules can not be found. Restarting the browser does not help, but terminating shadow-cljs and doing a new jack-in (from cider) and all is well again. How do I force a recompile from the connected repl without restarting the dev environment? when I type :cljs/quit and then (shadow.cljs.devtools.api/watch :main) it says "already watching".#2019-10-1719:49lilactownyou can try (shadow.cljs.devtools.api/stop-worker :main) and then run the watch again#2019-10-1719:55magraThanx!!#2019-10-1719:57thheller@magra any more info on "when" it stops working? might it be relating to running npm install or so while the watch is running?#2019-10-1720:05magra@thheller Last time it happened after I did a restart on the fulcro server. That does a (tools-ns/refresh). I did not issue a manual npm install before the last occurance.#2019-10-1720:10thhellerdo you have shadow-cljs running in embedded mode?#2019-10-1720:10thhellerin which case tools.namespace will definitely mess things up badly#2019-10-1721:43magraI don't think so.#2019-10-1723:34emccue
shadow-cljs - config: C:\Users\Ethan\Development\vrtest\shadow-cljs.edn  cli version: 2.8.64  node: v10.16.3            shadow-cljs - socket connect failed, server process dead?
shadow-cljs - server version: 2.8.64 running at 
shadow-cljs - nREPL server started on port 49330
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build completed. (134 files, 1 compiled, 0 warnings, 3.18s)
#2019-10-1723:34emccuestarting up a new project with shadow-cljs and i am not able to connect over http#2019-10-1723:35emccuefollowing the readme directly#2019-10-1723:35emccue
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :builds
 {:frontend
  {:target :browser
   :dev-http {8080 "public"}
   :modules {:main {:init-fn vr/init}}}}}
#2019-10-1723:35emccuewith the regular command npx shadow-cljs watch frontend#2019-10-1723:35emccuemy suspicion is that "server connect failed, server process dead?" error is to blame#2019-10-1723:43emccueaaand i put :dev-http in the wrong place#2019-10-1723:43emccueignore me#2019-10-1723:55emccue
(init)
Hello World
=> nil
(js/console.log "A")
Syntax error compiling at (REPL:1:1).
No such namespace: js
#2019-10-1723:55emccuemaybe a cursive question#2019-10-1800:01emccueand shadow/repl was the ticket#2019-10-1800:17emccue#2019-10-1800:17emccueokay#2019-10-1800:18emccuethis one seems like it is an actual error and not just me being stupid#2019-10-1800:18emccuemaybe#2019-10-1800:19emccue#2019-10-1800:19emccuethis file is some bonkers js#2019-10-1800:19emccueif it even is js#2019-10-1804:22lilactownthat looks like Flow or TS#2019-10-1804:28lilactownhttps://github.com/facebook/react-360/issues/143#2019-10-1804:29lilactown@emccue ☝️ it looks like it’s expected to be used with the react-native bundler#2019-10-1804:29lilactownseems like bad form#2019-10-1805:00emccuegross#2019-10-1805:42gibb@ghaskins How are you finding the grpc-web development experience so far?#2019-10-1808:56thheller@emccue I added a new :js-provider recently which may become handy for this. basically you set :js-options {:js-provider :external :external-index "foo/index.js"}}#2019-10-1808:56thhellerthat creates a foo/index.js with all JS requires used in the build#2019-10-1808:56thhellerthe intent is that you build foo/index.js with whatever external tool you prefer (so in your case react-native metro, but could be webpack, parcel, etc)#2019-10-1808:57thhelleryou then include that output file completely separately in the HTML#2019-10-1808:57thhellerjust needs to be included before the shadow-cljs output#2019-10-1808:57thhellerand the generated file will make the JS deps available to the CLJS output#2019-10-1808:57thhellerbasically just an automated way for the webpack setup described in the official docs#2019-10-1812:48danielnealI’m using this lib and struggling to get the right incantation to refer some of its components https://github.com/kmagiera/react-native-reanimated#2019-10-1812:48danielnealI have this
["react-native-reanimated"
    :default Animated
    :refer
    [Easing
     Easing.inOut
     Easing.ease
     Transition
     Transition.Together
     Transition.Change
     Transition.Sequence
     
     Transition.Out
     Transitioning
     Transitioning.View]]
#2019-10-1812:49danielnealso far, and I’m trying to use a component called Animated.View which is in the default export (Animated)#2019-10-1812:49danielnealI think the . is causing some problems#2019-10-1812:49danielnealI get the error
152 |     [Animated.View {:style (merge (s [:absolute-fill :bg-ui0])
------------^-------------------------------------------------------------------
 Use of undeclared Var buoyancy.entry-point/Animated
#2019-10-1812:49danielnealI can workaround by doing (def animated-view (.-View Animated))#2019-10-1812:49danielnealbut I was wondering if there was a more elegant way#2019-10-1813:53thheller@danieleneal hmm yeah that isn't very elegant. the . isn :refer is also kind of problematic#2019-10-1813:54thhellerI could change the default resolve rules to also account for :default as it does with :as but the handling of . is already quite bad and even worse in normal CLJS#2019-10-1813:54thhellerhttps://clojure.atlassian.net/browse/CLJS-712#2019-10-1814:19danielnealjs libraries always manage to find some way to be different#2019-10-1814:19danielneal😂#2019-10-1814:19thhellerindeed 😛#2019-10-1814:20thhellerbut the . interop in CLJS is a bit undefined#2019-10-1814:20thhellerIMHO Animated.View should just work and I might add a change that enables that#2019-10-1814:20thhellerjust need to think about what might possibly break in the process 😛#2019-10-1814:22danielnealah that would be awesome but can appreciate it might be gnarly. I’ll stick with my workaround for now#2019-10-1815:11ghaskins@thheller after playing with react-native a bit, im curious as to your insights into what role Metro plays when you have a tool like shadow-cljs in front of it#2019-10-1815:12ghaskinsis it largely unnecessary such that we could evolve the react-native flow to consume shadow output directly?#2019-10-1815:12thhellermetro is in front of it, it is the final bundler#2019-10-1815:12ghaskinsor does it still perform some important functoion#2019-10-1815:12ghaskinsunderstood...it just seems largely redundant#2019-10-1815:13thhelleryes, it would be if they followed any kind of standard in packaging#2019-10-1815:13ghaskinsheh#2019-10-1815:13thhellerunfortunately they decided that it is ok to use non-standard JS (Flow mostly) in their packages#2019-10-1815:13thhellertherefore shadow-cljs can't process it unless I add support for JS and all other kinds of non standard stuff they decided to add#2019-10-1815:13ghaskinsI wasnt sure if it was injecting hooks, etc, into the final bundle, or whether it was just re-optimizing the already optimized shadow output#2019-10-1815:14thhellershadow-cljs basically just produces one file that metro is going to include like any other .js file#2019-10-1815:14ghaskinsgot it, so they are infusing other stuff#2019-10-1815:15ghaskinsi figured that was the case, but wasnt sure#2019-10-1815:15thhelleryeah they provide the require results (so all JS dependencies, shadow-cljs doesn't process any of them for rn)#2019-10-1815:15thhellerthey also re-optimize a bit since we can't tell them that isn't necessary#2019-10-1815:16thhellerI don't know why they thought they needed to invent their own bundler for this#2019-10-1815:17thhelleror rather why they thought it was a good idea to follow no standards at all 😛#2019-10-1815:17ghaskinsyeah, me either..though im sure they are not thinking about non-js workflows either#2019-10-1815:18thhellerwell the write-your-own-bundler is ok .. that is what shadow-cljs does after all#2019-10-1815:18thhellerthe non-standard stuff is the problem. otherwise shadow-cljs or webpack would just work as alternatives#2019-10-1815:18ghaskinsright..im sure it made sense at some level if you are looking at providing turnkey support for pulling in a bunch of human edited js/jsx#2019-10-1815:19ghaskinsbut for consuming compiler output from something like shadow-cljs, it makes less sense#2019-10-1815:20ghaskinsbut yeah, im surprised they didnt just reuse webpack or something#2019-10-1815:20ghaskinsoh well#2019-10-1815:20thhellerthere is https://github.com/callstack/haul which replaces metro entirely I think#2019-10-1815:21thhellerso in theory it is possible to now use the default tools at all#2019-10-1815:21thhellerbut it is probably best to stick to the "official" stuff#2019-10-1816:18ghaskinsyeah, i agree with that sentiment...at least until one has an understanding when the rules may be bent/broken#2019-10-1816:18ghaskinswhich I do not yet possess#2019-10-1902:33mattlyI'm seeing a problem with my release build where the transpiled version of goog.string/format isn't making it into the build#2019-10-1902:34mattlyUncaught TypeError: ne.format is not a function#2019-10-1902:38sogaiu@mattly it's not by any chance that one needs to require goog.string.format in order to use goog.string, right? (cf. text starting "Sometimes" at: https://clojurescript.org/reference/google-closure-library#requiring-a-function)#2019-10-1902:39mattlyno.#2019-10-1902:39mattlythat would presumably at least cause warnings in development#2019-10-1902:39sogaiuit seems like it would, yes. there is theory and there is practice though, sometimes 🙂#2019-10-1902:41mattlyok wait,#2019-10-1902:42mattlygoog.string/format is an alias to goog.string.format ?#2019-10-1902:42mattlyand the compiler that this is the standard library for isn't smart enough to know that?#2019-10-1902:43mattlyindeed#2019-10-1905:31sogaiusorry, my bad -- i can just use the --silent flag to yarn.#2019-10-1907:04thheller@mattly the namespace structure in the closure library isn't very strict so sometimes a singular function is split into a separate "namespace" which actually is just a function. so sometimes it doesn't map cleanly to the CLJS namespacess. goog.string.format is an actual "provided name" which you require via (:require [goog.string.format]) but since it isn't an actual namespace we have to use it via (:require [goog.string.format] [goog.string :as gstr])) (gstr/format ...)#2019-10-1911:27Pavel KlavíkHi, I am trying to get Hello world Web Worker example working from the guide, but I am getting a mysterious runtime error. My shadow-cljs.edn configuration:
{:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:main   {:entries [orgpad.client.core]
                                                     :init-fn orgpad.client.core/init}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:main}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load orgpad.client.core/mount-root
                                            :watch-dir  "resources/public"}}
The code in orgpad.client.core/init:
(let [layout (js/Worker. "/js/compiled/layout.js")]
    (.addEventListener layout "message" (fn [e] (js/console.log "Layout message recieved:" e)))
    (.postMessage layout "Hello World!"))
The Web Worker code:
(ns orgpad.client.layout.webworker.core)

(js/self.addEventListener
  "message"
  (fn [^js e]
    (js/postMessage (.-data e))))
The runtime error:
Uncaught ReferenceError: Node is not defined
    at Object.hickory$core$node_type [as node_type] (core.cljs:37)
    at core.cljs:39
    at layout.js:2937
    at Array.forEach (<anonymous>)
    at Object.env.load (layout.js:2933)
    at layout.js:2969
to the line (aget js/Node (str type "_NODE"))) where js/Node is not known. It points to one of my dependencies [hickory "0.7.1"], not used in Web Worker at all.
#2019-10-1911:28thhellerit is used in the webworker#2019-10-1911:28thhelleryou use :depends-on #{:main} which means all the code from :main will be loaded in the worker#2019-10-1911:29thhelleryou should define a :shared module and have :main and :layout depend on that#2019-10-1911:30thheller
:modules          {:shared {:entries []}
                   :main   {:init-fn orgpad.client.core/init
                            :depends-on #{:shared}}
                   :layout {:entries    [orgpad.client.layout.webworker.core]
                            :depends-on #{:shared}
                            :web-worker true}}
#2019-10-1911:30thhelleryou can leave :entries empty for shared which means all code used in both :main and :layout will be moved there#2019-10-1911:33Pavel KlavíkNow i get: Uncaught ReferenceError: SHADOW_ENV is not defined at main.js:1#2019-10-1911:34thhellerdid you load the shared.js?#2019-10-1911:34Pavel KlavíkNo, how should I load it?#2019-10-1911:34thhellerneed 2 script tags in the HTML#2019-10-1911:34Pavel Klavíkok#2019-10-1911:34thhellermake sure shared is loaded before main#2019-10-1911:35Pavel Klavíkit seems to work, thx#2019-10-1914:33Filipe Silvaheya, should shadow-cljs watch test with a config such as
{...
 :builds
 {:test
  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true}}}
run the tests on every rebuild?
#2019-10-1914:34Filipe SilvaI see shadow-cljs compile test building and running the tests, but shadow-cljs watch test only seems to build and rebuild, but not run them#2019-10-1914:34thhellerthe output may be routed incorrectly if you have a shadow-cljs server (or other watch) running elsewhere#2019-10-1914:36Filipe Silvaah that was it!#2019-10-1914:36Filipe Silvait was a bit unexpected to me, is it a bug or the intended behaviour?#2019-10-1914:37thhellerbug I guess. watch runs in a different thread that doesn't capture the *out*/*err* bindings, so it'll use the default of the server#2019-10-1914:39Filipe SilvaI could see it going both ways really, depending on what the intended experience is (watch the server console or watch the command console)#2019-10-1914:40thhellerit probably shouldn't be using *out* at all#2019-10-1914:40thhellerand instead write to the build log directly#2019-10-1914:40thhellerwhich is then routed to out or the UI or whatever#2019-10-1914:41thhellerprobably should be wherever the build log goes#2019-10-1914:44thhellerfeel free to open an issue. I'm stuck behind something else so can't fix that right now#2019-10-1915:47Filipe Silvano urgency in this really, but I'll open an issue for it to be recorded#2019-10-1916:01Filipe Silvaturns out there's a good one already: https://github.com/thheller/shadow-cljs/issues/487#2019-10-1916:04thhelleroh hehe#2019-10-1916:19Pavel KlavíkI have set :before-load and :after-load functions to restart the Web worker. It works fine when I do changes in the code outside of Web worker, but it does not reload correcly when I just update WW code. I have even tried to reload it via Shadow-cjls REPL.#2019-10-1916:35Pavel KlavíkDevtools are set as follows:
:devtools         {:after-load  orgpad.client.core/mount-root
                                            :before-load orgpad.client.core/stop-web-workers
                                            :watch-dir   "resources/public"}
#2019-10-1916:35Pavel Klavíkit displays the shadow-cljs icon when changing WW code and it detects errors, but no reloading occurs#2019-10-1918:29thheller@pavel.klavik what does the browser console say?#2019-10-1919:14Pavel Klavíknothing#2019-10-1919:20thheller@pavel.klavik do you maybe have the console filtering too much? it should be showing something?#2019-10-1919:22thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html maybe this helps?#2019-10-1920:02Pavel Klavíkno filtering, normally it displays shadow-cljs: load JS ..... shadow.cljs.devtools.client.browser.js:48 shadow-cljs: call orgpad.client.core/mount-root#2019-10-1920:02Pavel KlavíkI will take a look at the link but I am not likely doing anything strange#2019-10-1920:04Pavel KlavíkThis is the full shadow-cljs.edn:
{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]
                [reagent-utils "0.3.3"]
                [re-frame "0.10.6"]
                [day8.re-frame/http-fx "0.1.6"]
                [hickory "0.7.1"]
                [binaryage/devtools "0.9.10"]
                [bidi "2.1.5"]
                [com.taoensso/sente "1.14.0-RC2"]
                [venantius/accountant "0.2.4"]
                [com.cemerick/url "0.1.1"]]
 :nrepl        {:port 9000}
 :builds       {:client {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:shared {:entries []}
                                            :main   {:init-fn    orgpad.client.core/init
                                                     :depends-on #{:shared}}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:shared}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load  orgpad.client.core/mount-root
                                            :before-load orgpad.client.core/stop-web-workers
                                            :watch-dir   "resources/public"}}}}
#2019-10-1920:06thhelleryeah looks fine#2019-10-1920:07thhellerany warnings? warnings would prevent a reload ... but would also log something#2019-10-1920:10Pavel Klavíkno#2019-10-1920:10Pavel Klavíkisn't the problem that the Web worker namespaces are not detected as part of the main app, so not reloaded?#2019-10-1920:11Pavel Klavíkthe changes are propagated, so if I modify WW and then modify the app code, everything gets reloaded and WW is updated as well#2019-10-1921:02thhelleroh right I forgot about the web worker stuff#2019-10-1921:02thhellerhmm yeah still haven't found a good strategy for those#2019-10-1921:38erwinrooijakkersHi, I am trying to include the zenroom npm package that uses a wasm file in shadow-cljs. There’s an example blogpost (https://www.dyne.org/using-zenroom-with-javascript-react-part3/) on how to use the library in React, where it’s described to put the .wasm file in the public folder so it’s served on /zenroom.wasm. Also some code needs to be changed so that the javascript wrapper looks for the wasm in that path, and does not try to find it locally. I did the same steps, but I get the error >failed to load zenroom_example.views.js TypeError: “C.then is not a function” This code comes from the wrapper.js:
require("core-js/stable");

require("regenerator-runtime/runtime");

var _zenroom = _interopRequireDefault(require("../dist/lib/zenroom.js"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var C = (0, _zenroom.default)();
Which loads some file via a relative path. It might be the case that this does not work with shadow-cljs? I had to include the npm packages core-js and regenerator-runtime in the packages.json before I got to this error. I noticed that shadow-cljs minifies all the npm packages and serves it under for example /js/compiled/cljs-runtime/module$node_modules$zenroom$dist$wrapper.js. So just to be sure I also served the wasm under js/compiled/cljs-runtime/zenroom.wasm, but that does not change anything. Is this problem related to the wasm not compiling? Or due to the relative path? I changed the relative path loading to _interopRequireDefault(require("/js/compiled/cljs-runtime/module$node_modules$zenroom$dist$lib$zenroom.js")); but that did not fix hte problem. Can anybody help me include this package with wasm and requires? Full source code is at: https://github.com/transducer/zenroom-example
#2019-10-1921:52thheller@erwinrooijakkers that repo contains no sources to look at#2019-10-2015:35erwinrooijakkersOops src was in gitignore for some reason#2019-10-2015:35erwinrooijakkersRemoved it 🙂#2019-10-2015:49erwinrooijakkersIt works!!!#2019-10-2015:50erwinrooijakkerswasm to resources and changing what was said in the blogpost was enough#2019-10-1922:01thhelleryou might have more luck if you just include zenroom separately with webpack or so#2019-10-1922:03thhellerI'll take a closer look tomorrow if you add the sources, going to bed now#2019-10-2015:52erwinrooijakkersIt works now so not necessary to look into it. Thanks for all the support!#2019-10-2011:14yendaI there a way to specificy the websocket port on the device? It looks like :http -> :port is only for the host, but on the device the ws port changes everytime and I don't know how to forward the port with adb. As a result I get an error about ws not able to connect from 192.x.x.x:3449 (desktop) to 192.x.x.x:random-port (device)#2019-10-2011:15yendaand this https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native doesn't seem to be the culprit because the IPs are correct#2019-10-2011:18thheller@yenda not sure I understand the question. adb isn't involved in this. The running app will need to connect to the shadow-cljs instance. shadow-cljs is never trying to connect to anything, so there is no port to forward?#2019-10-2011:21yendaok sorry I guess I'm a bit confused about how the different parts of the tooling are connecting together. I get a red screen when the app starts about ws failing to connect from the device address on a random port to the port and host that is in my :http config#2019-10-2011:21thhellerthe device is always going to use a random port, that is fine. the only fixed port is the shadow-cljs port#2019-10-2011:22thhellerwhat is the exact message? and are sure the host is reachable from the device?#2019-10-2011:23thhellerit may be on another network (eg. when using an emulator)#2019-10-2011:23thhellershadow-cljs also sometimes gets confused and picks the wrong network adapter to use for the IP#2019-10-2011:23thhellertry shadow-cljs watch app --verbose#2019-10-2011:23yendaI'm using real device#2019-10-2011:24thhellerit'll log which IP it is using on startup, but that should be the same as the logged error#2019-10-2011:24thhellerok then you can easily test on the device by opening a browser and visiting the host:port#2019-10-2011:26yendait can't be reached#2019-10-2011:27thhellerand is it the actual shadow-cljs UI?#2019-10-2011:29yendaon desktop I see shadow UI at http://192.168.1.169:3449#2019-10-2011:29yendaon device site can't be reached#2019-10-2011:29thhellerright so things aren't on the same network?#2019-10-2011:31yendaoh ok I can access it on device by not setting a host (so it uses localhost) and adb receiver tcp:3449 tcp:3449#2019-10-2011:31thhellerwhy not just wlan?#2019-10-2011:32thhellerthis shouldn't require adb but I don't know much about android so should be fine#2019-10-2011:32yendawell I can access the page but I still have this websocket error#2019-10-2011:34yenda"WebSocket connect failed:failed to connect to /192.168.1.169 (port 3449) from /192.168.0.11 (port 49278) after 10000ms It was trying to connect to: <ws://192.168.1.169:3449>"#2019-10-2011:35thhellerhmm dunno. I have never needed adb for any of this. Just using the wlan in my local network#2019-10-2011:35yendaoh I see, the phone is on WLAN but the desktop is on ethernet#2019-10-2011:36thhellerthat should still be the same network? well, depends on your network setup I guess#2019-10-2011:37yendathanks that was the issue#2019-10-2011:38yendathe phone was not on the same LAN I didn't know it was using it, I thought everything was done through adb#2019-10-2011:45thhelleryeah nothing in shadow-cljs assumes adb but maybe some react-native stuff does. I don't actually know.#2019-10-2011:45thhelleras far as shadow-cljs is concered it is regular network stuff#2019-10-2012:26dabrazheHi all. Does project.clj need anything more than this below? I am using Idea with Cursive; dependencies are in shadow-cljs .edn
(defproject mininal-cljs "0.0.1"
  :dependencies
  [[thheller/shadow-cljs "2.7.8"]])
#2019-10-2012:36thheller@dennisa the question is unclear. do you intent to use project.clj only for Cursive purposes or do you actually intent to use :lein true?#2019-10-2013:18dabrazheOnly for Cursive integration. If there's a better way please let me know.#2019-10-2013:22thhellerI would recommend running shadow-cljs pom and then using the generated pom.xml to create the Cursive project#2019-10-2013:22thhellerthen whenever you change :dependencies you just re-run shadow-cljs pom#2019-10-2013:23thhellerOtherwise with project.clj you'll need to manually copy the :dependencies so Cursive knows about them#2019-10-2021:54dabrazheI'm bit confused, I was under impression that there's no need to include the dependencies in project.clj any longer, just a dummy file from the user guide. What is use case for adding them to project.clj?#2019-10-2021:55thhelleryou don't need them there for shadow-cljs#2019-10-2021:56thhellerbut Cursive does not read shadow-cljs.edn so it doesn't know about your dependencies#2019-10-2021:56thhellerso if you want cursive to understand your code and not complain about code it cannot find then you need to copy the dependencies#2019-10-2021:56thhellerjust use pom.xml. you don't lose anything and it much easier to keep updated#2019-10-2021:58dabrazheok, how can I go from pom to project.clj?#2019-10-2022:00dabrazhecan I reference it somehow? cause copying is very tedious#2019-10-2022:02thhellerI dont understand that question#2019-10-2022:02thhelleryou call shadow-cljs pom#2019-10-2022:02thhellerand use the generated pom.xml in cursive to create your project#2019-10-2022:03thhellerno project.clj at all#2019-10-2022:03thhellernew project from existing sources -> pom.xml#2019-10-2022:03thhellerif that doesn't do anything you may need to enable the maven plugin in cursive#2019-10-2120:13dabrazheThanks, I tried and it seems to work. I guess it's ok to reimport the project everytime#2019-10-2120:52thhelleryou don't need to reimport#2019-10-2120:52thhellercursive will ask you to update if pom.xml changes, which you do by just calling shadow-cljs pom again#2019-10-2611:13dabrazhegreat! it seems to be importing now. not that I see much difference from the previous situation ) it was not complaining either. That's why I thought I only need to specify dependencies in the shadow edn and package json, not in project.clj#2019-10-2014:41valtteriHello, I was wondering if anyone here is doing something with Shadow + Serverless Framework and would like to share your experiences? I just gave it a spin and got it working quite easily. Superb docs @thheller 💯!#2019-10-2014:45valtteriI’m still trying to figure out if I want to use :shadow or :require :js-provider with AWS Lambda. On the other hand I’d like to minimize “upload time” to lambda but on the other hand I don’t want to make the lambda to do too much work on initialization. I’m a bit tempted to just shove all my deps into the output js-file, which I guess :shadow would do?#2019-10-2014:51pezI have a strange regression in Calva. It opens two REPL connections, one for clj and one for cljs. It starts by making an nREPL sessions clone and uses this for it’s clj session. Then it clones this session and promotes it to a cljs REPL. Not sure where the regression happens, but at least in 2.8.59->64 what happens is that the clj session also gets promoted to cljs. And with 2.8.2 this does not happen. I’ll try to bisect where the change happens now, since it seems like the right thing to do.#2019-10-2015:01thheller@valtteri here is a bit more background on the "package everything" stuff for node https://github.com/thheller/shadow-cljs/issues/290#2019-10-2015:01thhellerit is supported but it might be better to just use :require and post-process with ncc or similar tools#2019-10-2015:06thheller@pez hmm I changed a bunch of nrepl stuff so totally possible that something broke. I might have a guess related to clone in that shadow-cljs already put something in the session which is then cloned and re-used#2019-10-2015:06thhellerdo you send something before the actual clone?#2019-10-2015:18pez@thheller I’ll have to analyze if I send something before I clone. Maybe I do, querying * ns* maybe. In any case, the change happens between 2.8.52 and 2.8.53. Shall I file an issue? I might not have a super clean repro…#2019-10-2015:19thhellerwould be super helpful to get a full trace of the messages. with shadow-cljs on the classpath you can run clj -m shadow.nrepl-debug 5000 5001#2019-10-2015:19thhellerthat would open a TCP server on port 5000 which forwards to 5001#2019-10-2015:19thhellerso 5001 would be the actual nrepl server and your editor connects to 5000#2019-10-2015:20thhellerit just prints all the messages going back and forth#2019-10-2015:20thhellerhttps://github.com/thheller/shadow-cljs/blob/f711e781f12ca4bd85435e9e3eda0cfc5887a07b/src/main/shadow/nrepl_debug.clj#L64#2019-10-2015:21pezVery cool. Doing it!#2019-10-2015:23thhellerI think already know what is happening though#2019-10-2015:30pezI don’t know how to get shadow-cljs on the classpath. I get
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/nrepl_debug__init.class, shadow/nrepl_debug.clj or shadow/nrepl_debug.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
#2019-10-2015:52thhellerwell you need to recent version#2019-10-2015:53thhellercan't remember when I added it by it likely was after .53#2019-10-2016:19pezI’m using latest.#2019-10-2016:30thhellerand it is not in some alias?#2019-10-2017:02thhelleryou can just use shadow-cljs run shadow.nrepl-debug 5000 5001 too of course. just used clj as an example#2019-10-2018:57pezI get this:
$ shadow-cljs run shadow.nrepl-debug 5000 59546
shadow-cljs - config: /Users/pez/Projects/calva/shadow-cljs.edn  cli version: 2.8.64  node: v12.8.1
shadow-cljs - connected to server
[:server-ready 5000 59546]
[:client-accepted #object[java.net.Socket 0x196e2f92 "Socket[addr=/127.0.0.1,port=59714,localport=5000]"]]
[:msg :client 36]
[:msg :client 23]
[:msg :client 90]
[:msg :client 72]
[:msg :client 72]
[:msg :client 87]
[:msg :client 160]
[:msg :client 72]
[:msg :client 87]
And in the tab where I start the watcher:
$ npx shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.1 watch :calva-lib :test
shadow-cljs - config: /Users/pez/Projects/calva/shadow-cljs.edn  cli version: 2.8.64  node: v12.8.1
shadow-cljs - server version: 2.8.64 running at 
shadow-cljs - nREPL server started on port 59546
shadow-cljs - watching build :calva-lib
shadow-cljs - watching build :test
[:calva-lib] Configuring build.
[:test] Configuring build.
[:test] Compiling ...
[:calva-lib] Compiling ...
[:calva-lib] Build completed. (83 files, 2 compiled, 0 warnings, 3,14s)
========= Running Tests =======================

Testing calva.fmt.editor-test

Testing calva.js-utils

Testing calva.fmt.formatter-test

Testing calva.fmt.util-test

Ran 21 tests containing 88 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (78 files, 1 compiled, 0 warnings, 4,10s)
[:msg :target 115]
[:msg :target 79]
[:msg :target 133]
[:msg :target 180897]
[:msg :target 133]
[:msg :target 133]
[:msg :target 1953]
[:msg :target 88]
[:msg :target 79]
[:msg :target 180897]
[:msg :target 97]
[:msg :target 112]
[:msg :target 79]
[:msg :target 269351]
[:msg :target 133]
[:msg :target 79]
#2019-10-2018:59pezThen when evaluating something in the CLJ session: this:
[:msg :client 129]
[:msg :client 237]
And this:
[:msg :target 98]
[:msg :target 197]
[:msg :target 80]
#2019-10-2019:02pezThat was before starting the app. Starting that and evaluating *ns*, I get this:
[:msg :client 129]
[:msg :client 101]
[:msg :client 130]
[:msg :client 131]
[:msg :client 104]
[:msg :client 118]
[:msg :client 132]
[:msg :client 104]
[:msg :client 240]
And this:
[:msg :target 2530]
[:msg :target 530]
[:msg :target 150]
[:msg :target 299]
[:msg :target 350]
[:msg :target 391]
[:msg :target 150]
[:msg :target 350]
[:msg :target 113]
[:msg :target 80]
#2019-10-2019:04pezEvaluating the same thing in the CLJS session, I get this:
[:msg :client 129]
[:msg :client 130]
[:msg :client 131]
[:msg :client 132]
[:msg :client 240]
And this:
[:msg :target 57121]
[:msg :target 57121]
[:msg :target 57121]
[:msg :target 57121]
[:msg :target 113]
[:msg :target 80]
#2019-10-2019:04pezLet me know if I can do something more/else.#2019-10-2020:00thhelleroh right. the output is written to target/nrepl-debug/*.log.edn#2019-10-2020:01thhellerthe stdout output is just about the size of the messages that were written#2019-10-2020:30pezI thought it might be some codes that made sense to you. 😃#2019-10-2020:32thhellerhmm why does it send so many clone requests?#2019-10-2020:33thhellercider-nrepl sure sends a lot of stuff over the wire#2019-10-2020:34pezThe clone requests are from Calva, though. There are three, right?#2019-10-2020:35thhellerlooks like it yes#2019-10-2020:35pezSo, one is to get a fresh clone to start from, then one clone for CLJ and one for CLJS.#2019-10-2020:36thheller
;; ----------------------------------------
;; -- FROM  :client
;; ----------------------------------------
{:op "eval",
 :session "8f0aa4a2-fb9e-4419-b032-45736496c675",
 :code "nil",
 :id "9"}
#2019-10-2020:36thhellerwhy you eval'ing nil? was that for the test?#2019-10-2020:36pezNot intentionally. Not sure what that is.#2019-10-2020:36pezWhich line?#2019-10-2020:37peznvm, found it.#2019-10-2020:39pezI think that is something pretty recent. To get a message back with current namespace. (I could be wrong, haven’t checked yet.)#2019-10-2020:42thhellerwonder why it is sending ns-list so much although nothing changed#2019-10-2020:42thhellerdoesn't matter regarding out problem though#2019-10-2020:42thhellerbut I think I know what happens#2019-10-2020:43pezI don’t recall what ns.list is right now.#2019-10-2020:44pezIf you see more funny stuff there, that you think Calva is initiating, let me know.#2019-10-2020:44thhellercan't find anything problematic your client is sending. other than that it may be sending too much#2019-10-2020:44thhellerbut I've seen nrepl stuff being rather "chatty" before so thats not uncommon#2019-10-2020:45pezyeah, very chatty#2019-10-2020:46pezThere is traffic on hover and stuff, that I might have been spawning off, b/c I didn’t think of avoiding that when doing the test.#2019-10-2020:46thhelleryeah. I think I just misunderstood how the nrepl middleware works#2019-10-2020:46pezBut whatever happens, visavi the problem, happens somewhere in the very start.#2019-10-2020:47thhellerI thought if I tell it https://github.com/thheller/shadow-cljs/blob/92bb8076f6d1774bdbcf32dc8b0e14ce949c769a/src/main/shadow/cljs/devtools/server/nrepl.clj#L49#2019-10-2020:47thhellerso which messages it should handle that it also only gets those#2019-10-2020:47thhellerbut I guess everything passes through it instead#2019-10-2020:48thhellerso I just need to filter out the clone stuff so make sure shadow re-inits the session#2019-10-2020:48thheller(I think)#2019-10-2020:50pezMakes some sense to me, even if not completely following. I have yet to sit down with nrepl and really try to grok it.#2019-10-2021:21thhellernrepl is seriously frustrating ... I fixed your problem but now cursive breaks ...#2019-10-2022:37thhellerif you get a chance try 2.8.65. I think your issue should be fixed.#2019-10-2107:21pezNow tried it. It is better, but not yet quite right. Now the first cljs clone is behaving, but the second one I clone from that clone is not a cljs session. In this log I did the following: 1. Connected Calva. This should: 1. Make a fresh clone, A 2. Clone the first CLJ session, B-CLJ, from A (used for backing the editors for .clj files) 3. Clone the second CLJ session, C-CLJ, from B-CLJ (used for the CLJ REPL prompt). 4. Clone the first CLJS session, D-CLJS, from B-CLJ (used for backing the editors for .cljs files) 5. Promote D-CLJS to a CLJS session. 6. Clone the second the second CLJS session, E-CLJS, from D-CLJS (used for the CLJS REPL prompt) Note that Calva does not promote E-CLJS, since it relies on it being cloned from the already promoted D-CLJS. What happens with 2.8.65 is that D-CLJS works as expected. But E-CLJS is still a CLJ session. So in the log file I continue to show this by: 1. Start the node-js app. 2. Evaluate a cljs/js thing in the editor (D-CLJS), this works as expected 3. Evaluate a clj think in the editor (D-CLJS), this also works as expected: bigdec does not exist. 4. Evaluate a cljs/js thing at the CLJS REPL prompt (E-CLJS), this does not work as expected. 5. Evaluate a clj thing at the CLJ REPL prompt (E-CLJS), this does not work as expected: bigdec exists. 6. For good measure I evaluate some clj things at the CLJ REPL prompt (B-CLJ), and they work as expected I hope I got all this right now…#2019-10-2107:21pezAnd the log…#2019-10-2107:25pezDidn’t want to upload as edn, trying zipped.#2019-10-2108:48thhellerhmm yeah I didn't expect that someone would clone a CLJS session#2019-10-2108:48thhellersince technically that makes no difference to not cloning it#2019-10-2108:49thhellersince bindings don't really work in an async context the cloning can't actually create a session that is truly independent of the other one#2019-10-2108:49thhellerbut that should still work on the nrepl side of things. I'll think about it. Shouldn't be that hard to figure out#2019-10-2110:03pezI think I do it that way because that is what I do with the CLJ sessions. I have never realized that it doesn’t really matter in the CLJS case. I can check for that and skip cloning for CLJS, in case it gets hairy for you to untangle it.#2019-10-2110:04thhellermaybe I'm wrong but I don't think that it will work. you can maybe try by eval'ing 1 in one session and then 2 in the cloned one#2019-10-2110:04thhellerthen check *1 in the original and see what you get#2019-10-2110:05thhellerif you get the correct 1 I'd be surprised#2019-10-2110:05thhellerin shadow-cljs you wouldn't get 1 but maybe figwheel/piggieback does some magic I'm not aware of#2019-10-2110:21pezI tested that immediately when you told me it would work like that. 😎 Mind blown. #2019-10-2110:24thhellerand did it work like that? 😛#2019-10-2110:26pezYeah. Also in figwheel it works like that. #2019-10-2110:28thhellergood to know#2019-10-2110:28thhellerbut yeah sessions aren't really possible in CLJS given the async nature (and lack of proper binding support)#2019-10-2110:39pezNaturally, I’d like to keep as much of the semantics of cloning as I can, but this could be dealt with client side now that I have been enlightened. Just let me know what you decide to do with the issue, and I’ll adapt.#2019-10-2110:39thhellerwell clone should in effect to absolutely nothing#2019-10-2110:40pezYeah, and in .65 it does something. 😃#2019-10-2110:40thhellerall state will be shared between the clones so there is really no point in cloning in the first place#2019-10-2110:41thhellerI will need to think about how to actually allow cloning without going back to the previous behavior#2019-10-2110:41pezFair enough. It can actually be a bit confusing in the client code if it looks like it is a separate clone, when it isn’t.#2019-10-2110:42pezI’ll fix that. So .65 will then be OK from a Calva perspective.#2019-10-2110:43thhellerdon't change too much ... I'm still in the great REPL internals overhaul ... there may be changes upcoming that'll actually make this work#2019-10-2111:12pezCool. Question. If I clone a new CLJ session for the second CLJS session, will that be a separate session? I’m guessing not, but as I’m not at the keyboard and can test it, you probably know without having to try 😃#2019-10-2114:39pezI think CIDER also clones the cljs session: https://clojurians.slack.com/archives/C0617A8PQ/p1571620670136300#2019-10-2016:28erwinrooijakkersI created a file build.clj as per the doc (https://github.com/thheller/shadow-cljs/wiki/Custom-builds):
(ns build
  (:require [shadow.build :as build]
            [shadow.build.targets.browser :as browser]))

(defn custom [{::build/keys [stage mode config] :as state}]
  (let [state (browser/process state)]
    (println "hello" stage)
    state))
I placed it in src/clj since that is in the :source-paths. My shadow-cljs.edn prod build is as follows:
{:lein   true
 :nrepl {:port 8777}
 :builds {:prod {:target :browser
                 :output-dir "resources/public/js/compiled"
                 :asset-path "/js/compiled"
                 :modules {:app {:entries [zenroom-example.core]}}}}}
When I do shadow-cljs release prod this custom build step is not called. How do I include the custom build step?
#2019-10-2016:29thheller:target controls that? so :target build/custom#2019-10-2016:29erwinrooijakkersAha#2019-10-2016:30thhelleryou might want to check out :build-hooks. they are way easier than custom builds#2019-10-2016:31erwinrooijakkersI only want to extend the normal browser build to change one file a bit#2019-10-2016:31erwinrooijakkersbuild-hooks seem perfect for that#2019-10-2016:31erwinrooijakkersThanks#2019-10-2021:24David PhamDid anyone manage to make Dirac work with shadow-cljs?#2019-10-2021:25thhellerno. dirac uses the cljs.analyzer API directly, meaning shadow-cljs isn't even in the picture for the stuff it is doing#2019-10-2021:30David PhamOuch. Is there a way to use the repl while Chrome Devtool is on a breakpoint?#2019-10-2021:38thhellernot that I can think of no#2019-10-2101:26Lucas Barbosahttps://clojurians.slack.com/archives/C0617A8PQ/p1571620670136300 Anybody seen this before?#2019-10-2101:40lilactown@lvbarbosa yes I’ve seen this, I think it’s a CIDER bug#2019-10-2101:40lilactownsometimes it works when I press enter a few times in the REPL, esp. with a CLJS buffer open next to it#2019-10-2101:40lilactownseems finnicky#2019-10-2101:50Lucas BarbosaSeems like it works if I cider-set-repl-type to cljs#2019-10-2101:52Lucas BarbosaNope, goes back to clj mode after a while :(#2019-10-2102:17dpsuttonwhat version of shadow-cljs are you on? I remember seeing this in the past#2019-10-2102:20Lucas Barbosa@dpsutton {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "42312a23262d356f212e283102706c7a6c7477"}, :content ("[email protected]")}#2019-10-2102:20Lucas BarbosaI am trying to rollback cider to an older version to see what happens#2019-10-2102:21dpsuttonand what version of CIDER?#2019-10-2102:21Lucas Barbosapreviously on 0.23, now trying 0.21#2019-10-2102:35Lucas BarbosaSame thing.. I'll try to downgrade shadow-cljs now Nothing. Went back to a few months ago and still have the same problem. I have no idea on what it might be#2019-10-2105:49David PhamI usually do shadow-CLJS watch app#2019-10-2105:49David PhamAnd then cider-connect-cljs#2019-10-2113:12Lucas BarbosaScreen Shot 2019-10-21 at 10.12.06 (3).png#2019-10-2113:12Lucas BarbosaSame thing with watching the build on terminal and connecting to the repl#2019-10-2113:14Lucas BarbosaThe repl work, but it is "disconnected" from the project files. I can't evaluate code in the cljs buffer, nor cider-switch-to-repl-buffer while in .cljs files. I just noticed that the repl buffer says "clojure" and not "clojurescript". Is that an evidence of something?#2019-10-2113:17Lucas BarbosaI forgot to include cider-nrepl this time#2019-10-2113:18Lucas BarbosaAlright, now there's the old message: "WARNING: No Clojure Project was detected" Still can't switch to repl buffer/evaluate code in source files. What versions of cider and shadow-cljs are you using? @UEQGQ6XH7 Screen Shot 2019-10-21 at 10.17.19 (3).png#2019-10-2113:19David PhamTry to your shadow-cljs.edn file on GitHub #2019-10-2113:20David PhamAnd we can maybe find your problem #2019-10-2113:20David PhamSeems to work #2019-10-2113:20Lucas BarbosaIt is the default acme sample app from shadow-cljs: npx create-cljs-project acme-app#2019-10-2113:21David PhamI am at work but I will try to check #2019-10-2113:21David PhamBut you have access to the repl?#2019-10-2113:21Lucas BarbosaIf I do a cider-set-repl-type and change the repl to cljs, it works for a while, but then it goes back to clj mode and stops working on cljs files#2019-10-2113:21David PhamBy the way yes#2019-10-2113:22David PhamThe issue that the repl does not say clojureSciprz is an issue#2019-10-2113:22David PhamPiggiebsck #2019-10-2113:22David PhamOr cider-connect-CLJS #2019-10-2113:23Lucas Barbosa
:dependencies
 [[cider/piggieback "0.4.2"]
  [cider/cider-nrepl "0.23.0-SNAPSHOT"]]
#2019-10-2113:23Lucas BarbosaThis is what I'm using#2019-10-2113:23Lucas BarbosaDoes the ordering matter?#2019-10-2115:52thheller@lvbarbosa I changed something in the latest release that may be causing these issues. can you try 2.8.64 and see if those problems are still there?#2019-10-2116:00Lucas Barbosahttps://clojurians.slack.com/archives/C0617A8PQ/p1571620670136300#2019-10-2116:00Lucas BarbosaThanks @thheller, it worked after a downgrade!#2019-10-2116:00thhellerdoh!#2019-10-2116:07Lucas Barbosa@thheller I went to 2.8.64 and it works also! I was on 2.8.52 previously#2019-10-2116:08thhellerthx for the info. getting this nrepl stuff to work as expected has been a struggle#2019-10-2116:15Lucas BarbosaI can imagine... thank you so much for the effort! #2019-10-2116:15Lucas BarbosaI'll take a deeper look at the tool in the future#2019-10-2117:51thheller@lvbarbosa @U0ETXRFEW could you try 2.8.66? I think it should be fixed but I have no clue how to use emacs so I can't test myself#2019-10-2117:52Lucas Barbosaof course, just a sec#2019-10-2117:53pezI have no clue how to use emacs, either. But I'll try with Calva. 😎#2019-10-2117:54Lucas Barbosa@thheller works fine on Emacs!#2019-10-2117:55thhellerwell lets hope it is correct this time#2019-10-2117:55thhellerI'm sure there still stuff wrong 😛#2019-10-2117:56Lucas BarbosaThis is my first time doing cljs, so I'm not an "advanced" user. I'll keep an eye on things, but it works for what I need right now#2019-10-2118:04pezYes, this behaves like 2.8.52 in Calva. Thanks!!#2019-10-2105:49David PhamMake sure to have piggieback as well#2019-10-2109:08bbssI recently updated to 2.8.64 and that was working on one project, but on a different project I am getting
CompilerException: java.lang.RuntimeException: Unable to resolve symbol: read+string in this context, compiling:(shadow/cljs/devtools/server/repl_system/clojure.clj:113:32)
still works when I manually include 2.8.16 (which was what I was using before iirc) so I not a big issue right now.
#2019-10-2109:08thheller@bbss thats a bad tools.reader version on the classpath#2019-10-2109:09thhelleroh no wait .. its an old clojure?#2019-10-2109:09bbssit shouldn't be..#2019-10-2109:09bbss
org.clojure/clojure {:mvn/version "1.9.0"}
, kinda old.
#2019-10-2109:09thhellerthat may require 1.10?#2019-10-2109:09thhelleryeah I think it was added in 1.10#2019-10-2109:14bbssalright, that worked, time to fix the issues that come with the higher version closure compiler now.#2019-10-2109:16thhellerwhich one?#2019-10-2109:16thhellerstill can't use the very latest. that needs fixes in CLJS itself#2019-10-2109:17bbssWell the one that came with .64.. I had some troubles with importing js a certain way in the other project.#2019-10-2109:17bbssAnd in this case it was complaining it couldn't find process and I had to npm install it, I'm thinking that was the thing you mentioned earlier when I said I had to include js-options to get my build to work. e.g. npm install shadow-cljs#2019-10-2109:18bbssand that made my build succeed with the latest versions so all good 👍#2019-10-2113:30knubieis it possible to generate source maps for releases?#2019-10-2114:58Drew Verleein https://shadow-cljs.github.io/docs/UsersGuide.html#_preloads it mentions it adds cljs-devtools (https://github.com/binaryage/cljs-devtools) to preloads as long as the dep is on the path (in dependencies). When i do this, cljs-devtools formatting feature is enabled but not the "hints" feature (https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#what-is-the-hints-feature). Any hint on how to enable this in the shadow setup?#2019-10-2114:58Drew Verleei tried adding features to install [:formatters :hints] to my devtools map#2019-10-2115:48thheller@drewverlee that goes into the :compiler-options {:external-config {:devtools/config ...}} not :devtools#2019-10-2115:49thheller@steedman87 sure, :compiler-options {:source-map true}#2019-10-2116:19knubieCan't believe I missed that in the user docs#2019-10-2121:54thhellerI was accepted into the Github Sponsors Beta some days ago ... still kinda clueless about the tiers stuff. any comments are welcome#2019-10-2121:54thhellerhttps://github.com/sponsors/thheller#2019-10-2122:31David PhamI am gonna sponsor you through GitHub then :)#2019-10-2122:31David PhamWith the matching mechanism it will double :)#2019-10-2122:36dpsuttonis there a reason to prefer github to patreon? happy to switch if there's a benefit for you @thheller#2019-10-2122:38thhellerwell github matches so it is 2x but I'm happy either way 🙂#2019-10-2122:39dpsuttoni'll move it over then 🙂#2019-10-2122:52isakUsing shadow-cljs, is possible to pre-process/manipulate code before it gets sent to the ClojureScript compiler?#2019-10-2122:54thhelleryes, but it isn't recommended since it can destroy source maps and so on#2019-10-2122:55isakgodmode#2019-10-2122:57thhellerIDDQD!#2019-10-2122:58thhellerwhat do you want to do?#2019-10-2123:01isakConsidering enabling something like this feature in Elixir (Phoenix), where one can give a name to a set of imports/requires, and then use them in any file:
defmodule MyAppWeb.UserController do
  use MyAppWeb, :controller
  ...
#2019-10-2123:03isakKind of to avoid stuff similar to this (though I don't use fulcro):#2019-10-2123:06isakMay not be worth it in Clojure, since namespaces tend to be bigger, though part of the reason for that is also how bad ns is, so not sure#2019-10-2123:09lilactownis ns a regular macro in CLJS?#2019-10-2123:15thhellerno, it is a special form#2019-10-2123:17thheller@isak changing what the ns does is not really possible from the outside. it already is complicated enough as it is#2019-10-2123:17thhelleryou also rarely use all of them in the fulcro case, I usually have no more than 3 often just 1#2019-10-2201:54Nolanhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html this is an awesome, excellent blog post. much appreciated @thheller 🙏#2019-10-2206:02gibbI’d like to start with a simple shadow-cljs and reagent project to try out some things. Ideally it would support live reload and not have any additional libs like routing and such. Any recommendations for lein templates perhaps?#2019-10-2416:47Filipe SilvaI've also made https://github.com/filipesilva/create-cljs-app#2019-10-2416:50Filipe Silvait's targetted for people familiar with the npm ecosystem, so if that's you I hope it will make sense#2019-10-2618:09gibbThanks @UJVKWJTGE that looks great as well!#2019-10-2210:49mikethompson@gbson there is re-frame-template (but it does have re-frame also) https://github.com/day8/re-frame-template#2019-10-2407:44gibbThanks! I ended up using that one and stripping re-frame.#2019-10-2212:17SchpaaAnyone knows how to integrate appliedscience/js_interop into a clojurescript project? https://github.com/appliedsciencestudio/js-interop#2019-10-2314:52mhuebert@Schpa - just curious, was there some other method of install that you were expecting?#2019-10-2212:29SchpaaI just teared it apart and manually installed everything, but I was really stumped here…#2019-10-2212:56thheller@schpaencoder there is no npm install a-thing for clj(s), so we always add :dependencies manually#2019-10-2212:57Schpaa@thheller yeah, thats what I finally did#2019-10-2212:57Schpaa@thheller anyway, thanks for responding#2019-10-2213:18roklenarcicI am running into a problem because I use Java 12 that shadow-cljs run dies with the error:
shadow-cljs - starting ...
Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
#2019-10-2213:27thhellerI'm on JDK13 btw, so I'm pretty confident all this works#2019-10-2213:18thhellerthat isn't because of shadow-cljs#2019-10-2213:19thhellerthat is because you have a bad dependency. looks like an old CLJS version maybe?#2019-10-2213:19thhellerdo you use lein/deps.edn?#2019-10-2213:20roklenarciclein is used but I ran this with yarn#2019-10-2213:20thhelleryou run yarn. that runs the shadow-cljs npm script. that runs lein when you use :lein true or so#2019-10-2213:21roklenarciclein false#2019-10-2213:21thhellerso just shadow-cljs.edn?#2019-10-2213:21roklenarcicyeah#2019-10-2213:21thhellerwhich shadow-cljs version?#2019-10-2213:23roklenarcicversion: 2.1.6#2019-10-2213:23thhelleryeah, that needs an upgrade then 🙂#2019-10-2213:23thheller2.8.66 is the latesst#2019-10-2213:24roklenarcicit's weird because in package.json I see "shadow-cljs": "2.8.58"#2019-10-2213:25thhellerwhats in your shadow-cljs.edn?#2019-10-2213:25thhelleror which package.json file? the only in the project itself?#2019-10-2213:26roklenarcicthe one in the project itself#2019-10-2213:26thhellercheck the node_modules/shadow-cljs/package.json, maybe that is outdated?#2019-10-2221:06thhellercan't wait to show everyone the feature I just merged 🙂 haven't been this excited about a feature in a long time 🙂#2019-10-2221:07thhellerand its only like 5% done but still cool 🙂#2019-10-2221:40sogaiusounds revolutionary 🙂#2019-10-2222:14isakI just read the doc. Cool!#2019-10-2312:43romain@thheller any info or teaser ? 🙂#2019-10-2314:26wilkerluciomaybe here? https://github.com/thheller/shadow-cljs/commit/ea109e5bd3dfee2143b2b5131b79a5a7b17ba9dc#2019-10-2312:44thhellerworking on it. hopyfully later today#2019-10-2317:29David PhamIs shadow remote like developing on a remote VM machine and push the state to the web browser xD?#2019-10-2320:30thhellerall will become clear soon I hope 🙂#2019-10-2320:34thhellerjust think REBL but with support for CLJ, CLJS in the browser, node, react-native and whatever else 😛#2019-10-2320:45dpsuttoni'm stoked#2019-10-2321:26David PhamI want this :)#2019-10-2321:26David Pham😍#2019-10-2321:27David PhamThanks a lot for your work on shadow-CLJS, you made my journey in CLJS so fun and I still enjoy it thanks to your tool, but also your guides and documentation!#2019-10-2322:16thhellerI should not be recording videos this late ... but hopefully this is coherent enough to make some sense https://youtu.be/9pBatlu9IWY#2019-10-2322:17thheller(video is still processing, so maybe best to wait a little)#2019-10-2322:17thhellerI also just released version 2.8.67 that includes what the videos shows#2019-10-2322:18thhellerjust include shadow.remote.runtime.browser or shadow.remote.runtime.node in your build (via :preloads or the REPL)#2019-10-2322:40dpsuttonamazing!#2019-10-2322:40isakwow, looks really useful. Think I can delete re-frisk already 🙂#2019-10-2322:42thhellerprobably a bit early to be deleting anything. the UI still needs a ton of work#2019-10-2322:44isakre-frisk uses js/alert, so 🙃#2019-10-2323:29papachanis there any lein template with shadow-cljs and karma?#2019-10-2323:53sogaiu@thheller thanks for the video -- the incremental fetching for the tool-router-runtime-addressing-print-problem idea looks great!#2019-10-2404:55David PhamThis is a crazy good new feature!! I will love it. (Can you maybe put colors in pretty print?)#2019-10-2408:42thhelleryeah, but more important things first 😛#2019-10-2409:24superstructorAwesome feature. Thanks for your efforts @thheller! 🙂 We'll look at feasibility of direct integration of shadow-cljs in re-frame-10x at some point.#2019-10-2409:26thheller@superstructor although I'm working on this inside the shadow-cljs project for now all the underlying shadow.remote stuff is actually meant to be standalone at some point.#2019-10-2409:27thhellerand re-frame-10x could act as a "runtime" itself too#2019-10-2409:27thhellerbut I'll get into more details on that in the future. just wanted to show an early preview 🙂#2019-10-2409:58Shuai LinAnyone here has experience making shadow-cljs working together with dirac ? They seems not "compatible" with each other ...#2019-10-2409:59thhellerCurrently they are not compatible that is correct yes#2019-10-2409:59Shuai LinOh, just spotted https://clojurians.slack.com/archives/C0J01U7MY/p1571676963003500#2019-10-2409:59thhellerI'll happily help anyone that is interested to work on this#2019-10-2409:59thhellerbut I don't have time to dig into this too much myself for now#2019-10-2410:00thhellerI don't know what it needs but currently is makes direct use of the cljs.analyzer API I believe which means shadow-cljs can't intercept anything#2019-10-2410:00Shuai Lin@thheller I have very shallow knowledge about both, AFAIK 1) shadow-cljs has its own nrepl middleware (not using piggieback) to bootstrap a CLJS repl 2) and so does diract - it uses its own implementation Is that the major blocker?#2019-10-2410:02thhelleryes#2019-10-2410:02thhellerI think so at least. I don't really know what the dirac middleware does#2019-10-2410:05Shuai Lin@thheller IIUC 1. for a normal cljs repl, it's like clj repl -> piggleback mw (or whatever) -> websocket in browser/node. 2. For diract its clj repl -> dirac mw -> dirac agent -> websocket in chrome devtools -> program being debugged#2019-10-2410:06Shuai LinThe thing makes dirac shine is it can evaluate exprs even when a breakpoint is hit and the program suspended, because its eval goes through chrome devtools. While others like shadow-cljs/figwheel can't do that because their eval are based on "user-mode" websocket code which is a no-go when bp is hit Ofc there are other stuff from diract like pretty-printing cljs var names, but this is the biggest sell for me#2019-10-2410:09thhellerin theory it should be possible to make this use the shadow-cljs API#2019-10-2410:09thhellerbut given that it doesn't use any of the default cljs.repl stuff that might be a lot of work#2019-10-2410:10thhellerthe stuff I'm currently working on may actually be relevant for this but it is a bit too early#2019-10-2410:10Shuai Linwhat is it 🙂 ?#2019-10-2410:16thhellerhttps://clojureverse.org/t/introducing-shadow-cljs-inspect/5012#2019-10-2410:18thhellerthe shadow.remote stuff would be relevant for dirac. right now it isn't capable of eval but it will hopefully be soon.#2019-10-2412:08danielnealThis looks awesome!!!! Going to try out this afternoon hopefully, think it will be a game changer for react native debugging#2019-10-2412:15thhellerI haven't actually tested react-native yet since the test project I had for this doesn't work anymore for some reason#2019-10-2412:15thhellerbut it should work#2019-10-2413:16souenzzo[SOLVED] I'm trying to require static resources like this https://facebook.github.io/react-native/docs/images#static-image-resources Should I use js/require or import "as a library" in :require from ns? - Use (js/require "./../../resources/img.png")#2019-10-2414:03danielneal@thheller works on react native a treat - got our whole re-frame db in there, it’s bloody brilliant!!#2019-10-2414:54David PhamIs it possible to write a NodeJS server with Shadow-CLJS?#2019-10-2415:04mruzekw@neo2551 Yes, you want :target :node-script in your build#2019-10-2416:24darwin@thheller I would like to look into integrating dirac with shadow at some point, basically all I need is access to cljs compiler which is used by shadow-cljs - with figwheel I run dirac nrepl middleware in the same JVM as figwheel, so it can query figwheel’s state and use all “builds” and their relevant :compiler-env states#2019-10-2416:25darwinit is a bit fragile and hacky, because I touch internal figwheel’s state, but it works: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/figwheel.clj#2019-10-2416:27thhelleryeah I looked at that in the past but couldn't quite figure out how it all worked together#2019-10-2416:27darwinbtw. that code is a bit more involved because I also let user call figwheel repl api through dirac repl command: https://github.com/binaryage/dirac/tree/master/examples/figwheel-main#you-can-control-figwheel-main-via-dirac#2019-10-2416:27thhellerdo you only need the compiler-env to read or do you actually modify it?#2019-10-2416:28darwincljs compiler could modify it (and typically will)#2019-10-2416:28darwine.g. when you def something
#2019-10-2416:28thhelleryeah thats the main issue. if you use the compiler directly shadow-cljs can't do anything#2019-10-2416:29thhellerand shadow-cljs wraps the default compiler to make its additions#2019-10-2416:29darwinwell, you have to do it yourself to get compiled js code to be sent to client#2019-10-2416:29darwindirac must do the same thing, whatever it is#2019-10-2416:31darwinplease note that I use compiler API at lower level, because compilation env could be affected by locals on stack, so I don’t only give it cljs code string, but also prepare env with locals on stack (when stopped on a breakpoint)#2019-10-2416:32darwinI need to do something like this: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/eval.clj#L52-L62#2019-10-2416:36thhellerhmm probably not the approach I would have taken#2019-10-2416:36thhellerwouldn't it be easier to just eval (fn [the locals listed as args] (whatever-you-need-to-eval-using locals))#2019-10-2416:37valtteriI wrote a simple health-checker using Serverless Framework and shadow-cljs. https://github.com/vharmain/serverless-healthcheck#2019-10-2416:37thhellerso when you eval the generated JS you get a function#2019-10-2416:37thhellerthat you then call with the locals if you already have them?#2019-10-2416:37thhellerno need to mess with the compiler state for that 😛#2019-10-2416:38darwinnot sure if this would work well, at least it would mess with stack, in case of another breakpoint in that code, user would see that wrapper function#2019-10-2416:39darwinbut :locals is supported cljs state config, why not use it? I have to mess with env anyways, for example to set current ns#2019-10-2416:40darwinthat wrapper function could also interfere with return statements maybe, not sure if this would be a real issue#2019-10-2416:40darwinthrown exceptions would have it on stack, etc.#2019-10-2416:40thhelleryeah, again I don't really know what you are doing#2019-10-2416:41thhellerfrom that I'm seeing in that file you won't have much luck integrating shadow-cljs#2019-10-2416:41thhelleras it pretty much replaces all of the cljs.repl API and doesn't support it#2019-10-2416:41darwinit does what piggieback does, but adds a bunch of tweaks#2019-10-2416:42darwinit is using repl api here: https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/eval.clj#L252#2019-10-2416:42thhellershadow-cljs doesn't support piggieback either and replaces that itself#2019-10-2416:42thhellernothing from cljs.repl is supported. some of it could be but most of it can't#2019-10-2416:44darwinhere it is passing the compiler-env, which it got from figwheel (or created by dirac): https://github.com/binaryage/dirac/blob/master/src/nrepl/dirac/nrepl/eval.clj#L238#2019-10-2416:45thhellernone of those things are supported 😛#2019-10-2416:45darwinbut at some point you have to use cljs compiler and pass some compiler-env to it, no?#2019-10-2416:45darwinwhy not exposing it to me?#2019-10-2416:47thhellerbecause it isn't "just" the CLJS compiler#2019-10-2416:47thhellershadow-cljs modifies it. the analyze as well as the "emit"#2019-10-2416:49darwinok, let me ask differnt way, when you receive user input as string, you have to turn it into js code, and then send it back to client for js eval - turning it into js code could be some fn call [cljs-code-string env] -> js-code-string#2019-10-2416:49darwinwhy not exposing this api?#2019-10-2416:49darwinin your current impl env is probably always empty, but you can pass-through it for me down to cljs-compiler#2019-10-2416:50thhellerI can provide that extremely easily yes#2019-10-2416:50thhellerthat is indeed how the entire REPL "compiler" code works#2019-10-2416:51thhellerbut it works a bit differently API wise ...#2019-10-2416:52thhellerif you clone the shadow-cljs repo and run lein with-profiles +cljs repl#2019-10-2416:53thhellerthen (require '[shadow.cljs.repl-test :as x]) then (test-repl-anon-fn)#2019-10-2416:53thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/repl/shadow/cljs/repl_test.clj#L143-L149#2019-10-2416:53thhellerjust for a "sample", this isn't an actual test#2019-10-2416:53thhellerbut this outputs the "repl state" which will include the generated JS#2019-10-2416:54thhellerthere is no actual "eval" anywhere the REPL code .. you can process a bajillion things without ever evaling anything#2019-10-2416:54thhellersince that doesn't affect the generated code at all#2019-10-2416:54thhellerbut this API isn't exposed since no one asked for it before#2019-10-2416:55thhellerall it does it generate instructions which the runtime will then execute#2019-10-2416:55darwinyou mean runtime on the client side (js), right?#2019-10-2416:59thhellerto save you the time to eval. this is what you'd get back
:repl-actions
 [{:type :repl/invoke,
   :name "<eval>",
   :js "(function (foo){\r\nreturn foo;\r\n})",
   :source "(fn [foo] foo)",
   :source-map-json
   "{\"version\":3,\r\n \"file\":\"<eval>\",\r\n \"sources\":[\"<eval>\"],\r\n \"lineCount\":1,\r\n \"mappings\":\"AAAA,AAAKA;AAAL,AAAUA\",\r\n \"names\":[\"foo\"],\r\n \"sourcesContent\":[\"(fn [foo] foo)\"]}\r\n",
   :warnings []}]}
#2019-10-2416:56darwinwill be back in 10mins#2019-10-2416:58thhelleryes#2019-10-2417:01darwinI could probably use this api, but I would need some additional support. Current ns could be “emulated” by emitting in-ns code, but :locals would be better than wrapping it with fn, also need support for source maps somehow#2019-10-2417:04thheller
{:shadow.cljs.repl/repl-state true,
 :current-ns cljs.user,
 :repl-sources
 [[:shadow.build.classpath/resource "goog/base.js"]
  [:shadow.build.classpath/resource "goog/debug/error.js"]
  [:shadow.build.classpath/resource "goog/dom/nodetype.js"]
  [:shadow.build.classpath/resource "goog/asserts/asserts.js"]
  [:shadow.build.classpath/resource "goog/reflect/reflect.js"]
  [:shadow.build.classpath/resource "goog/math/long.js"]
  [:shadow.build.classpath/resource "goog/math/integer.js"]
  [:shadow.build.classpath/resource "goog/string/internal.js"]
  [:shadow.build.classpath/resource "goog/string/string.js"]
  [:shadow.build.classpath/resource "goog/object/object.js"]
  [:shadow.build.classpath/resource "goog/array/array.js"]
  [:shadow.build.classpath/resource "goog/structs/structs.js"]
  [:shadow.build.classpath/resource "goog/functions/functions.js"]
  [:shadow.build.classpath/resource "goog/math/math.js"]
  [:shadow.build.classpath/resource "goog/iter/iter.js"]
  [:shadow.build.classpath/resource "goog/structs/map.js"]
  [:shadow.build.classpath/resource "goog/uri/utils.js"]
  [:shadow.build.classpath/resource "goog/uri/uri.js"]
  [:shadow.build.classpath/resource "goog/string/stringbuffer.js"]
  [:shadow.build.classpath/resource "cljs/core.cljs"]
  [:shadow.build.classpath/resource "clojure/walk.cljs"]
  [:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"]
  [:shadow.build.classpath/resource "clojure/string.cljs"]
  [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"]
  [:shadow.build.classpath/resource "goog/string/stringformat.js"]
  [:shadow.build.classpath/resource "cljs/repl.cljs"]
  [:shadow.cljs.repl/resource "cljs/user.cljs"]],
 :repl-actions
 [{:type :repl/invoke,
   :name "<eval>",
   :js "(function (foo){\r\nreturn foo;\r\n})",
   :source "(fn [foo] foo)",
   :source-map-json
   "{\"version\":3,\r\n \"file\":\"<eval>\",\r\n \"sources\":[\"<eval>\"],\r\n \"lineCount\":1,\r\n \"mappings\":\"AAAA,AAAKA;AAAL,AAAUA\",\r\n \"names\":[\"foo\"],\r\n \"sourcesContent\":[\"(fn [foo] foo)\"]}\r\n",
   :warnings []}]}
#2019-10-2417:05thhellerthat is the full repl-state. note the :current-ns. you can just assoc :current-ns 'whatever.sym#2019-10-2417:07darwinok, :source-map-json looks like what I need#2019-10-2417:09darwinso what about adding :locals support in your repl? IMO you should just pass it through to analyzer#2019-10-2417:01darwinin dirac I inline source maps with generated js#2019-10-2417:04thhelleryou don't even need that#2019-10-2417:04darwinand maybe something else I’m not aware of right now, I wrote this code 3+ years ago, and I don’t have the context in my head#2019-10-2417:09thhelleryeah me throwing random bits of information at you probably doesn't help#2019-10-2417:09thhellerwrite an empty function that you need and I'll provide the implementation#2019-10-2417:10thhellerlike (defn please-generate-js-for-me [in-this-ns the-cljs-code-as-string])#2019-10-2417:10thhellermaybe the extra locals as a map or so#2019-10-2417:11thhellernothing compiler-env related, I can set all that up myself if needed#2019-10-2417:11darwinwhat happens when cljs compiler throws? e.g. clojure macro throws?#2019-10-2417:12thhelleryou get the exception?#2019-10-2417:12darwincurrently dirac is able to communicate it to client side with a stack trace#2019-10-2417:12darwinalso dirac can capture all println stuff done in macros, etc#2019-10-2417:12darwinand send it to client side#2019-10-2417:13thhellerthen you capture *out*?#2019-10-2417:13darwinyes, but at lower level#2019-10-2417:13darwinat Java level#2019-10-2417:14thhellersorry I don't really want to get into this too deeply now#2019-10-2417:14thhellerif you clearly define what you need I can set that up for you#2019-10-2417:14thhellertalking directly to the cljs.compiler just isn't going to work since shadow-cljs can't do its stuff that way#2019-10-2417:15darwinok, will think about it a bit…#2019-10-2417:15thhellerbut the same stuff is still possible, just accessed differently#2019-10-2417:23DerekWhat happens to calls to tap> in a production build?#2019-10-2417:24thhellerright now they are left as is but don't do anything#2019-10-2417:24thhelleryou could potentially even strip them from completely using https://shadow-cljs.github.io/docs/UsersGuide.html#_code_stripping#2019-10-2417:25thheller:strip-type-prefixes #{"cljs.core.tap_GT_"}#2019-10-2417:25thhellerhaven't tried that yet 😛#2019-10-2417:25thhellerbut I'd like a tap> variant that is automatically removed in release builds#2019-10-2417:26thheller(tap> something) will just do nothing so thats totally fine without any overhead#2019-10-2417:26thheller(tap> {:some thing :foor "bar"}) or so would however still construct that map, and then throw it away which is overhead we don't need/want#2019-10-2510:22Heikki HämäläinenIs there any way to get compilation warnings and node output to same terminal output? My current setup is to run in one terminal “shadow-cljs watch <target>” then in another “node <target>.js” and after that connect Cursive REPL to nrepl. This leads to situation where REPL output is in one window, node output (like logging) in one and compilation in one. Is there some way to redirect outputs to combined view somehow?#2019-10-2510:38thheller@heikki.hamalainen currently that is not possible no. it sort of works if you run node-repl (without a build) via the Cursive nREPL#2019-10-2510:39thhellerso you run shadow-cljs server#2019-10-2510:39thhellerconnect with cursive as usual and run (shadow/node-repl)#2019-10-2510:39thhellerbut that is only a REPL, it doesn't watch#2019-10-2510:43Heikki HämäläinenOk, watch is still needed so I will still continue to run multiple terminals. Thanks for the reply. I needed to check this out because I was thinking that perhaps I have misunderstood something.#2019-10-2510:46thhellerthe issue is that I don't want to "hijack" the default node streams#2019-10-2510:46thhellersince you run node target.js separately I'd have to mess with process.stdout and process.stderr#2019-10-2510:46thhellerwhich I'm not really comfortable with 😛#2019-10-2510:47thhellerbut the Inspect work I previewed yesterday is meant to address this in a different way anyways 😛#2019-10-2510:48thhellerso you wouldn't use prn or console.log for debugging output but tap> instead#2019-10-2510:48thhellerstill doesn't end up in Cursive though 😉#2019-10-2510:50Heikki HämäläinenYes, that looks promising. Should be easy to add tap> to timbre logging as a middleware.#2019-10-2510:52thhellermaybe. I don't use timbre so not really sure what it does.#2019-10-2511:24Heikki Hämäläinentimbre is a logging library which is quite used in Clojure community: https://github.com/ptaoussanis/timbre#2019-10-2511:24thhelleryes I know what it is. but I don't know what it does internally to do what it does#2019-10-2511:25thhellerlike what happens if you attempt to log a really large value?#2019-10-2513:22p-himikUsing :module-hash-names changes actual file names. I'm thinking how to handle the same issue with my CSS files. Another approach would be to add a dummy query parameter so I don't have to rename anything or create some convoluted logic on my web server. But changing actual file names is more robust and explicit as it's a 1-to-1 match (for practical reasons only, because MD5) to the actual code. Do you have any thoughts on how it should be handled with CSS? Do you any example source code that deals with this issue?#2019-10-2513:27thhellerI do but its part of my work code and hasn't been touched in 5 years or so#2019-10-2513:27thhellernot something I would want to share 😛#2019-10-2513:28thhellerI prefer changing the filename over the query parameter but query should be fine. many sites do that.#2019-10-2513:30p-himikYeah, understandably so, because it should be easy to implement. But it still leaves a possibility for nasty errors where "it works on my machine". OK, thanks anyway. I'll try to think of something not too outlandish. After all, It's already a mixed codebase where UI is in CLJS and the server is in Python. 🙂#2019-10-2513:32thhellerI used a ruby script since back then my backend was still ruby#2019-10-2513:33thhellerit just takes a bunch of css files. minifies them and renames with the hash. then writes a manifest.json which the server reads so it knows about the names#2019-10-2514:58Filipe Silva@thheller I'm seeing some odd behaviour for :node-test targets on windows only#2019-10-2514:59Filipe Silvathe target looks like this:
{:e2e
      {:autorun true,
       :ns-regexp "e2e.*",
       :output-to "out/e2e.js",
       :target :node-test},
#2019-10-2514:59Filipe Silvaon linux and macos it runs swell#2019-10-2514:59Filipe Silvabut on windows it runs twice#2019-10-2514:59Filipe Silvaand since this particular test interacts with the FS, one test interferes with the other#2019-10-2515:00Filipe SilvaI think it exits with the exit code of the first run, because the second one fails but the run does not fail#2019-10-2515:00Filipe SilvaI say it runs twice because the output looks like this:#2019-10-2515:00Filipe Silva
Run yarn e2e
yarn run v1.19.1
$ shadow-cljs compile e2e
shadow-cljs - config: D:\a\create-cljs-app\create-cljs-app\shadow-cljs.edn  cli version: 2.8.67  node: v12.13.0
shadow-cljs - connected to server

[:e2e] Compiling ...
========= Running Tests =======================

Testing e2e.core
shadow-cljs - socket connect failed, server process dead?
[:e2e] Compiling ...
========= Running Tests =======================

Testing e2e.core
rm: could not remove file (code EBUSY): test-app/node_modules/clj-kondo/unpacked_bin/clj-kondo.jar
rm: could not remove directory (code ENOTEMPTY): test-app/node_modules/clj-kondo/unpacked_bin
rm: could not remove directory (code ENOTEMPTY): test-app/node_modules/clj-kondo
rm: could not remove directory (code ENOTEMPTY): test-app/node_modules
rm: could not remove directory (code ENOTEMPTY): test-app
#2019-10-2515:01Filipe Silvayou can see an example in https://github.com/filipesilva/create-cljs-app/runs/275004200#2019-10-2515:01Filipe SilvaI think I saw this happening only after I began using a background server via shadow-cljs start#2019-10-2515:02thhellerI thought the docs mention this.#2019-10-2515:02thhellerdo not use :autorun#2019-10-2515:02thhellerever#2019-10-2515:02thhellerI wish I never added it to begin with#2019-10-2515:03thhellerthe output does indeed look weird but I'm not willing to look into anything that uses :autorun#2019-10-2515:03Filipe Silvaok#2019-10-2515:03Filipe SilvaI did not see a reference to that in https://shadow-cljs.github.io/docs/UsersGuide.html#2019-10-2515:03thhellerrun shadow-cljs compile e2e && node out/e2e.js or so#2019-10-2515:03thhellerseparate compilation from the actual running of the tests#2019-10-2515:04Filipe Silvawill do#2019-10-2515:04Filipe Silvawas the user guide the wrong place to look for this information? I usually use it as my main resource but it does say it is a WIP#2019-10-2515:05thheller
:autorun	
(boolean, optional) Run the tests via node when a build completes. This is mostly meant to be used in combination with watch. The node process exit code will not be returned as that would have to forcefully kill the running JVM.
#2019-10-2515:05thheller
The node process exit code will be set to 0 when successful and 1 on any failures. (The node process exit code will not be returned when using :autorun.)
#2019-10-2515:05thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test#2019-10-2515:06Filipe Silvaok I see now, I should not rely on the exit code#2019-10-2515:06thhelleryou SHOULD rely on the exit code#2019-10-2515:06thhellerjust not with :autorun#2019-10-2515:06thhellerjust don't use it ... ever ...#2019-10-2515:07Filipe Silvayes I meant with autorun 😄#2019-10-2515:07thhelleronce compile finishes you can even shutdown shadow-cljs before running the tests. it won't be required for the actual tests#2019-10-2515:09thhellerthis github CI thing looks nice. how do you like it so far?#2019-10-2515:10Filipe SilvaI like it a lot, but there are some nuances#2019-10-2515:11Filipe SilvaI like it because it's one of the only CIs that offers free Windows runs, which I believe are required for OSS to treat windows users as first class citizens#2019-10-2515:11Filipe Silvathe other one is azure pipelines, and tbh gh-actions is really just pipelines in the background#2019-10-2515:11Filipe Silvait is not as fully featured as stuff like circleci#2019-10-2515:12Filipe Silvait doesn't have cache right now, but I'm into their private feedback org and was told it it's one of the things they are working on right now#2019-10-2515:12Filipe Silvaintegrations are top notch though#2019-10-2515:13borkdudeit also doesn't have ssh access like circleci#2019-10-2515:13borkdudewhich has been essential for me when debugging a build#2019-10-2515:13thhellerguess I'll stick with circleci for now. works ok after all.#2019-10-2515:13borkdudebut it seems to be faster than circleci for e.g. graalvm builds (minus the caching issue)#2019-10-2515:14Filipe Silvayeah ssh is missing too, but circleci is the only one with it so it's not really a common feature. although it's a super useful one, also saved me a bunch of times.#2019-10-2515:15Filipe SilvaI asked them about ssh once and they said it was on their radar, but no news so far#2019-10-2515:15borkdudedoes gh actions also do Windows builds?#2019-10-2515:16Filipe Silvayes#2019-10-2515:16Filipe SilvaI do ubuntu/osx/windows on it#2019-10-2515:16Filipe Silvahttps://github.com/filipesilva/create-cljs-app/runs/275004200 for instance#2019-10-2515:17borkdudeI love that artifacts are downloadable on gh-actions, contrary to circleci#2019-10-2515:18borkdudeby anyone I mean#2019-10-2515:19Filipe SilvaI'm conflicted about that#2019-10-2515:19Filipe Silvacircleci has a way to make downloadable artifacts#2019-10-2515:20Filipe SilvaI used artifacts on that run as workspace files are used in circle#2019-10-2515:20Filipe Silvawhich isn't great, I don't want people to download that single js file#2019-10-2515:20Filipe SilvaI just don't want to double build when not necessary#2019-10-2515:23borkdudeI have pasted a link to an artifact in circleci many times for people to preview something#2019-10-2515:23borkdudeinstead I could just say "go look at the build for this commit and download the artifact"#2019-10-2515:26Filipe SilvaI'm a bit confused, I expect that to work#2019-10-2515:26Filipe Silvawe just started to do it in https://github.com/angular/angular/pull/33321#2019-10-2515:27Filipe Silva@thheller what is the intended workflow for :node-test targets via watch, but without autorun? Is it to have some node watcher waiting to rerun the out file?#2019-10-2515:28thhellerdepends on what you want. I typically don't want tests to run whenever I safe a file#2019-10-2515:28thhellerI mostly run tests in the REPL#2019-10-2515:29thhellereg. you could create a keyboard shortcut REPL command that runs the tests on keypress via the REPL#2019-10-2515:30Filipe Silvahm... trying to emulate the overall watch functionality for things like karma setups#2019-10-2515:30Filipe Silva(although this isn't using karma and I don't want karma atm)#2019-10-2515:31thhellerhttps://www.npmjs.com/package/chokidar-cli#2019-10-2515:31Filipe Silvafor the target audience, I would prefer a single process that runs in the background#2019-10-2515:31Filipe Silvayeah that or nodemon sounds like the best approach#2019-10-2515:31thhellerchokidar out/e2e.js -c "not out/e2e.js"#2019-10-2515:31thhelleryou can use :autorun if you really need to, I just don't recommend it#2019-10-2515:32thhellermaybe I should add something like :autorun-in-watch-only true or so#2019-10-2515:32thhellerso it doesn't attempt to :autorun with compile#2019-10-2515:32Filipe Silvais it possible to override :autorun for the same target? e.g. shadow-cljs watch test --autorun or something#2019-10-2515:32thhellershadow-cljs watch test --config-merge "{:autorun true}"#2019-10-2515:33Filipe Silvaif autorun isn't recommended for compile I think it makes a lot of sense to disable it it, or provide an alternate explicit flag#2019-10-2515:33Filipe Silvathank you for explaining this to me#2019-10-2515:35Filipe SilvaI'll add these as defaults to my starter project:
"test": "shadow-cljs watch test --config-merge \"{:autorun true}\"",
    "test:once": "shadow-cljs compile test && node out/test.js",
    "e2e": "shadow-cljs compile e2e && node out/e2e.js",
#2019-10-2515:36thhellermaybe use "test" and "test:watch"?#2019-10-2515:37Filipe SilvaI actually agree with that but it turns out it's surprising for a lot of the target audience#2019-10-2515:37thhellerat least my expectation is for test to do a test once#2019-10-2515:37thhellerhmm ok#2019-10-2515:37Filipe SilvaI know right#2019-10-2515:37Filipe Silvain Angular CLI we flipped the meaning once and there was a lot of pushback#2019-10-2515:38Filipe Silvacertain communities have surprising expectations for defaults#2019-10-2515:39thhellereasy to get used to something like that I guess#2019-10-2515:39Filipe Silvayou know how e2e tests are by definition slow things that test a lot of stuff? a longstanding issue we've had is to have e2e watch mode#2019-10-2515:39Filipe Silvawhich I cannot fathom anyone could truly want#2019-10-2515:39Filipe Silvahttps://github.com/angular/angular-cli/issues/2861#2019-10-2515:40Filipe Silvahere we're event talking about e2e using protractor, which is slow and defaults to running in a visual mode#2019-10-2515:41thhelleryeah for me thats a problem with :autorun already#2019-10-2515:41thhellernot uncommon for a test for take a couple seconds#2019-10-2515:42thhellerespecially build related stuff ... if that blocked the normal watch I'd be pretty annoyed#2019-10-2515:43Filipe Silvayeah same here#2019-10-2515:54martinklepschI’m getting a couple of infer warnings for a library that I’m using httpurr: http://sprunge.us/dhCr7W — is this something that should be addressed at the library level or an issue with Shadow CLJS?#2019-10-2516:10thhellerneither I guess#2019-10-2516:11thhellerthey can be renamed since they are from the closure library#2019-10-2516:12thhelleryou could add typehints to make the warnings go away but they aren't required#2019-10-2516:52martinklepschright, but that’s kind of annoying, no? having to modify third party code to hide warnings that are false negatives…#2019-10-2517:08thhelleryou shouldn't be getting warnings for third party code (in .jar files)#2019-10-2517:10thhellerI guess the problem is .gitlibs#2019-10-2517:10thhelleryou can open an issue about those. since they are actually files they are treated as-if they are your project files#2019-10-2517:10thhellerso you get warnings, but probably shouldn't#2019-10-2519:57martinklepschAh ok! That makes a lot of sense I’ll open an issue :) #2019-10-2516:15rschmuklerHey all! Has anyone gotten refactor-nrepl working in a tools.deps project? I'm getting an error on cider startup that says:
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0-SNAPSHOT and n/a, respectively.
Looking at the jack in command:
[nREPL] Starting server via /usr/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.22.4 server
And I've even got them explicitly listed as dependencies:
refactor-nrepl              {:mvn/version "2.5.0-SNAPSHOT"}
    cider/cider-nrepl           {:mvn/version "0.22.4"}
#2019-10-2516:15rschmuklerAny tips on where to go from here?#2019-10-2516:21bbssdo I need to do something to get babel to work with shadow-cljs? I'm trying to require a jsm module from three.js, but shadow-cljs is erroring with:
internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module 'babel-core'
Require stack:
- /project/.shadow-cljs/babel-worker/babel-worker.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
...
...
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/project/.shadow-cljs/babel-worker/babel-worker.js'
  ]
#2019-10-2516:22thhellerhmm?#2019-10-2516:23thhellerplease don't cut stacktraces 😛#2019-10-2516:23bbss#2019-10-2516:24thhellerdid you try adding custom plugins/presets?#2019-10-2516:24bbssno#2019-10-2516:25bbssI'm not using babel myself in this project.#2019-10-2516:26thhellerhmm not sure what that is about#2019-10-2516:27bbssI'm trying to require https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GLTFLoader.js there is also https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js But that doesn't work either.#2019-10-2516:27thhellerhow do you require it?#2019-10-2516:28bbss["three/examples/jsm/loaders/GLTFLoader" :refer [GLTFLoader]]#2019-10-2516:29thhellerwhere do you get this error?#2019-10-2516:29bbsson my project build shadow-cljs watch main#2019-10-2516:30thhellerwhen or where?#2019-10-2516:30thhellersome log context helps a lot#2019-10-2516:32bbss#2019-10-2516:35thhellerhmm thats a weird one#2019-10-2516:35bbssThe weird land of JS modules and transpilation..#2019-10-2516:35thhellerit is the babel package contained in shadow-cljs#2019-10-2516:36thhellerbut I don't get why it would try to require("babel-core")#2019-10-2516:36thhellercertainly not at
at /Users/baruchberger/work/nursico/.shadow-cljs/babel-worker/babel-worker.js:399:229
    at Object.<anonymous> (/Users/baruchberger/work/nursico/.shadow-cljs/babel-worker/babel-worker.js:404:3)
#2019-10-2516:37thhellercan you delete that file and restart shadow-cljs?#2019-10-2516:37thhellermaybe you have some old version for some reason?#2019-10-2516:37bbssI tried deleting .shadow-cljs a couple times before#2019-10-2516:38thhellerhmm then this should be reproducible#2019-10-2516:38thhellerplease open an issue. doing other stuff currently that I want to finish first#2019-10-2516:38bbssalright, let me set-up a reproduce case tomorrow#2019-10-2516:39bbsswill do, thanks!#2019-10-2517:00richiardiandreamight an old question, today I bumped my shadow and I get:
shadow-cljs - starting via "clojure"
Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
	at clojure.lang.RT.load(RT.java:466)
	at clojure.lang.RT.load(RT.java:428)
...
#2019-10-2517:01thhellermissing thheller/shadow-cljs dep in deps.edn#2019-10-2517:01thhellerit is no longer auto injected#2019-10-2517:04richiardiandreaoh ok#2019-10-2517:04richiardiandrealet me try that#2019-10-2517:04richiardiandreaoh this was through cider master, does it mean that has to change too?#2019-10-2517:05richiardiandrea(well should cider auto-inject is not maybe a q for you I know :D)#2019-10-2517:05thhellernot sure what you mean#2019-10-2517:05thhellercider still injects itself so that should still work#2019-10-2517:05thhellershadow-cljs just doesn't because that was causing more annoying issues than actually helping#2019-10-2517:10lilactown@richiardiandrea if you add shadow-cljs as a dep it will fix it#2019-10-2517:11richiardiandrealooks like it did fix it indeed#2019-10-2517:11tekacs#2019-10-2517:13tekacsThis is the issue I’m running into (it’s less pleasant with a lot going on). I’m hoping it’s something well known that folks have run into, since IDEA project debugging can run on for a very long time.#2019-10-2517:13thheller@tekacs Cursive doesn't support js/#2019-10-2517:13tekacs😂 thank you :)#2019-10-2517:14tekacsI have relatively little use for it, so I guess I’ll just keep them to few places and not worry about it :)#2019-10-2517:26davewoI am looking to run shadow-cljs behind a reverse proxy (to develop w/ https locally). Is it possible to allow shadow to have the app connect to shadow's websocket on a proxy port (say 9640) but still listen for the WS on 9630?#2019-10-2517:27davewoI see the SSL config guidance in the documentation, but hoping to be able to just configure SSL once on my proxy#2019-10-2517:38thheller@davewo see :devtools-url in the docs#2019-10-2518:04mruzekwIs there a good template / general wisdom for keeping a frontend CLJS along-side a CLJ backend app in the same repo?#2019-10-2518:05mruzekwI kind of want to have a hard separation where shadow-cljs is used in frontend/ and lein in backend/#2019-10-2518:06mruzekwBut I’ve also seen something like src/main/clj and src/main/cljs#2019-10-2519:36thhelleri recommend using your namespaces to separate stuff. I usually have src/main/my/company/frontend/app.cljs or so with a src/main/my/company/server.clj#2019-10-2519:36thheller:source-paths works but IMHO gets annoying as soon as you have code that you want to use on both platforms#2019-10-2519:37mruzekwAnd I just might#2019-10-2519:37mruzekwThanks#2019-10-2612:09papachanthis week i tried this one lein new reagent <project name> +shadow-cljs from lein. and it worked pretty well. it run a backend and also compile cljs to javascript with shadow-cljs. Now i include Karma to the project and suprisely it run fine!#2019-10-2518:14David RenoI’m struggling a bit with Spacemacs/Cider and shadow-cljs. I see https://shadow-cljs.github.io/docs/UsersGuide.html#cider but it’s not helping. Is there any kind of procedure to follow to ensure that each step is complete? I’m thinking of something like this: 1. run java -v and verify version > 8 2. run node -v and verify version > 6 3. do <this thing> to make sure your paths are set correctly 4. run npx shadow-cljs init 5. edit shadow-cljs.edn and set :source-paths to values <something> 6. verify configuration by doing <this smart thing> 7. start emacs, open shadow-cljs.edn 8. start the n-repl and connect from cider by running M-x cider-jack-in-cljs 9. everything else… Looking for something that’s going to stop me before I go to far without having the basics correct.#2019-10-2518:20dpsutton@dcreno ignore cider until everything works on the command line. Then it should hopefully run in CIDER just fine#2019-10-2519:20David RenoI think it does but I’ll run through it one more time.#2019-10-2519:24David Renonpx create-cljs-project t2 works fine and creates a skeleton directory. npx shadow-cljs node-repl starts and produces a working (seeming) REPL and a web-page available on .#2019-10-2519:25dpsuttonperfect. now do cider-jack-in-cljs and it should work. and node your-script.js or whatever to have the runtime#2019-10-2519:27David RenoFrom *Messages*
[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server...
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: env: node: No such file or directory
#2019-10-2519:28David Renoand
error in process sentinel: Could not start nREPL server: env: node: No such file or directory
#2019-10-2519:28dpsuttonthat's emacs saying it has no idea what node is#2019-10-2519:29dpsuttonsame as if node wasn't on your path for your terminal#2019-10-2519:29David RenoI vaguely remember installing node and seeing that it wanted me to set PATH a certain way, sure I didn’t. May need to uninstall/reinstall and read better.#2019-10-2519:29dpsuttonthat might not be necessary#2019-10-2519:30David Reno
➜  ~ which node
/Users/dreno200/n/bin/node
#2019-10-2519:30David Reno
➜  ~ node --version
v10.17.0
#2019-10-2519:30dpsuttonlook at exec-path that's emac's path. you need to add node to the emacs path in the same way you do it for shells#2019-10-2519:41David Reno(getenv PATH) doesn’t show /Users/dreno200/n/bin, working on finding right zsh file to add it to…#2019-10-2519:52dpsuttonyou can call directly (add-to-list 'exec-path "/Users/dreno200/n/bin")#2019-10-2519:53David Renoyeah, used setenv to put it in the path and got this now:
[yas] Prepared just-in-time loading of snippets successfully.
Loading /Users/dreno200/.emacs.d/.cache/company-statistics-cache.el (source)...done
[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server...
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn  cli version: 2.8.67  node: v10.17.0
shadow-cljs - connected to server
server already running

 [2 times]
error in process sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn  cli version: 2.8.67  node: v10.17.0
shadow-cljs - connected to server
server already running
Will need to play with it a bit.
#2019-10-2519:57dpsutton> server already running#2019-10-2519:58dpsuttonits already started and they are fighting over the port#2019-10-2519:59David RenoMaybe I should have stopped the CLI first. #2019-10-2520:22David Renoshutdown npx shadow-cljs node-repl from CLI, now getting this in *Messages*:
error in process sentinel: Could not start nREPL server: shadow-cljs - config: /Users/dreno200/Documents/dev/t2/shadow-cljs.edn  cli version: 2.8.67  node: v10.17.0
===== ERROR =================
Executable 'java' not found on system path.
=============================
However, I java is in /usr/bin:
➜  t2 which java
/usr/bin/java
➜  t2 java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
➜  t2
and I have it set in emacs as the first item in the PATH environment variable with (setenv). Seems to clearly be a path problem though.
#2019-10-2520:50dpsuttonthere's a package https://github.com/purcell/exec-path-from-shell which might be helpful for you#2019-10-2520:54David Renoyeah, that just seems so much easier, but then again, I only use emacs for Clojure and Scheme.#2019-10-2521:31David Renoprogress: spacemacs PATH is set by PATH environment variable in .spacemacs.env. Even though it’s documented to append multiple PATH statements, it seems it was somehow confused. By reducing the statements to one and shortening, I got the right path in there (i.e. one with node and java). Now when running cider-jack-in-cljs it seems to work by prompting for a REPL type (I chose node), and starting a browser window pointing to . *Messages*:
[nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.0 -d cider/cider-nrepl:0.22.0-SNAPSHOT server...
[nREPL] server started on 50825
[nREPL] Establishing direct connection to localhost:50825 ...
[nREPL] Direct connection to localhost:50825 established
Visit '' in a browser? (y or n) y
helm: Error: Trying to run helm within a running helm session
Quit [3 times]
I’ll try to find a shadow-cljs troubleshooting doc and a place where I can add advice about verifying that node and java are in the path as reported by (getenv PATH). Thanks for your help!
#2019-10-2521:33dpsuttonare both your front end and backend run through shadow?#2019-10-2521:33David RenoI don’t even know what that means.#2019-10-2521:33David Renolol#2019-10-2521:34David RenoI’m trying to use shadow for everything because it seems well thought out.#2019-10-2521:34dpsuttonok. so both front end and back end are shadow-cljs#2019-10-2521:34dpsuttondon't choose node then. choose shadow-cljs and then choose the build#2019-10-2521:34David Renook, I’ll start it again.#2019-10-2521:35David Renoshadow choices are shadow or shadow-select.#2019-10-2521:36dpsuttonchoose shadow#2019-10-2521:36dpsuttonand there's gonna be two different choices. the first is what repl you want. there you are gonna choose shadow-cljs. the next will be which shadow build do you want. and you want to choose whatever you named your backend build
#2019-10-2521:36dpsuttonin your shadow-cljs.edn file#2019-10-2521:36David Renoah, and then it prompts for build and suggests dev which I suppose corresponds to whatever is in the shadow-cljs.edn file.#2019-10-2521:37David Renoare there docs about this because I am not seeing anything like this anywhere. Certainly appreciate your help but don’t want to be a drag.#2019-10-2521:41dpsuttonthe first choice is from CIDER. you need to say which repl you are using. if its figwheel, figwheel-main, shadow-cljs. unfortunately cljs tooling is a bit all over the map. but you're doing shadow-cljs and its a great product and that's what you say there all the time#2019-10-2521:41dpsuttonthe second choice is from shadow but CIDER is asking for you. from the docs of shadow, when you run npx shadow-cljs watch [build] this choice is asking you which shadow build you want to run#2019-10-2521:41David Renoseem to have it working now, can eval within spacemacs and see the little green bars on the left of the s-exps as I eval them.#2019-10-2521:42dpsuttonoutstanding!#2019-10-2521:42dpsuttonwelcome to the cljs community#2019-10-2521:42David Renothanks again for sticking with me.#2019-10-2521:42dpsuttonof course#2019-10-2521:42dpsuttonwhen you have shadow questions ask in #shadow-cljs and any CIDER related questions, from absolute beginner to how to modify and submit a patch come to #cider#2019-10-2523:46currentoorIs there a way to change the import statements in a JS dependency? I want to use react-native-base (UI kit) in both a web page and mobile app, by swapping our "react-native" with "react-native-web" Here’s how the react native base docs suggest doing it with webpack https://github.com/GeekyAnts/NativeBase-KitchenSink/tree/web-support#to-create-new-react-app#2019-10-2608:36thheller@currentoor see https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve. so :js-options {:resolve {"react-native" {:target :npm :require "react-native-web"}}}#2019-10-2608:37thhellerthats the addAlias stuff basically. dunno what the rest of it does though#2019-10-2614:51currentoor@thheller thanks I’ll give it a shot#2019-10-2614:53currentoorWait but will that apply inside an npm dep or only to cljs code?#2019-10-2614:54currentoorMy understanding is it’s for cljs only#2019-10-2614:55thhellerwhat do you mean?#2019-10-2614:55thhellerit'll apply for every require shadow-cljs will resolve#2019-10-2615:03currentoorWill it affect code I’m getting from node_modules?#2019-10-2615:14currentoorI want to change the import statements in an npm dependency #2019-10-2615:20thhelleryes#2019-10-2616:00currentoorAwesome #2019-10-2618:22currentoorthanks#2019-10-2614:55thhellerin JS and CLJS#2019-10-2615:02dpsutton@thheller i saw the thread where you mentioned CIDER isn't starting up the best way. I'll put the two startup commands in this thread and wonder what is the preferred way it should work?#2019-10-2615:02dpsutton
(defun cider-shadow-select-cljs-init-form ()
  "Generate the init form for a shadow-cljs select-only REPL.
We have to prompt the user to select a build, that's why this is a command,
not just a string."
  (let ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s))")
        (options (or cider-shadow-default-options
                     (completing-read "Select shadow-cljs build: "
                                      (cider--shadow-get-builds)))))
    (format form (cider-normalize-cljs-init-options options))))

(defun cider-shadow-cljs-init-form ()
  "Generate the init form for a shadow-cljs REPL.
We have to prompt the user to select a build, that's why
this is a command, not just a string."
  (let* ((form "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch %s) (shadow/nrepl-select %s))")
         (options (or cider-shadow-default-options
                      (completing-read "Select shadow-cljs build: "
                                       (cider--shadow-get-builds))))
         (build (cider-normalize-cljs-init-options options)))
    (format form build build)))
#2019-10-2615:02dpsuttonthese are the two startups. Essentially > "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch %s) (shadow/nrepl-select %s))"#2019-10-2615:03dpsuttonor > "(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select %s))"#2019-10-2615:04thhellerone issue is that it only lists the builds that it finds in shadow-cljs.edn#2019-10-2615:04thhellerit should at least list the 2 "specials" meaning the node-repl and browser-repl#2019-10-2615:05thhellerthey are not dependent on any build config#2019-10-2615:05thhellersimilar to launching a default node repl for CLJS#2019-10-2615:05dpsuttonyes. we had some back and forth on that recently. its trying to be helpful. Where might other builds be located? I was trying to give an example of how that list might not be exhaustive in the future#2019-10-2615:05thhellerjust add 2 hardcoded defaults, they are built-in so you don't have to list them in the config#2019-10-2615:05dpsuttonooh, really. that never clicked for me. i had wanted that feature and didn't realize it was there the whole time 🙂#2019-10-2615:05thhellerbut they are started differently#2019-10-2615:06thhellerso (shadow.cljs.devtools.api/node-repl)#2019-10-2615:06thhelleror browser-repl#2019-10-2615:06dpsuttonok. and is it invalid for a user to define their own build named browser-repl or node-repl?#2019-10-2615:06dpsuttonie, we can unequivocally do that when the build choice is browser-repl?#2019-10-2615:07thhellerhmm it probably should be yeah 😛#2019-10-2615:07thhellerbut it isn't currently#2019-10-2615:07dpsuttonok. and for clarity, could they be named "quick-browser-repl" or something to distinguish that if you have a proper build laid out you should probably use that?#2019-10-2615:08dpsuttoni'm assuming these are for new projects so you can get to work but not really applicable for established projects. i'd hate for someone thinking they want a browser repl and getting the default one without their stuff#2019-10-2615:10thhellerno. just assume browser-repl and node-repl to be reserved#2019-10-2615:10thhellerno one is gonna name their build that#2019-10-2615:11thhellerthey are just as applicable to established projects#2019-10-2615:11thhellerit is very much like in CLJ#2019-10-2615:11thhelleryou can either run lein repl#2019-10-2615:11thhellerthe lein uberjar and java -cp that-uberjar.jar clojure.main -r#2019-10-2615:11thhellerboth ways get you a REPL but with very different semantics 😛#2019-10-2615:11dpsuttongreat analogy#2019-10-2615:12thhellersometimes you just want a REPL and build from there#2019-10-2615:12dpsuttonthanks. i'm gonna go get this into CIDER today#2019-10-2615:12thhellergreat, thx#2019-10-2615:13dpsuttonone more question, does that work even in the absence of shadow-cljs.edn?#2019-10-2615:13thhelleryes#2019-10-2615:13dpsuttonok. thanks much#2019-10-2615:14thhellerwell, thinking about it npx shadow-cljs server won't start without a config#2019-10-2615:14thhellerso it would only work when you connect remotely to some embedded shadow-cljs instance I guess#2019-10-2615:15dpsuttonok. the check nil'ed out when there was no file and that sounds ok for now then as well#2019-10-2615:15dpsuttonbut i'll play around with it. its possible that at the point this is run shadow is assumed already started#2019-10-2615:17thhellerdunno if this helps but browser-repl is basically just a hardcoded :target :browser build#2019-10-2615:17thhellerhttps://github.com/thheller/shadow-cljs/blob/c2795128a30f45b870cb6b64763fbf2277ab53e9/src/main/shadow/cljs/devtools/api.clj#L514-L521#2019-10-2615:17thhellerwith one extra thing that it will try to open the browser automatically#2019-10-2615:18thhellersame for node-repl trying to run an actual node process#2019-10-2615:25pezCalva would distinguish between a build named :node-repl and the node-repl using the leading :. But, yeah, it is inviting confusion to name your build like that. 😃#2019-10-2615:26thhelleryeah but they have to be special because they do extra stuff#2019-10-2615:27thhellerjust make sure that you don't send (shadow.cljs.devtools.api/watch :browser-repl) since that'll just complain about build not found#2019-10-2615:27pezIf such a build was configured, it would work right?#2019-10-2615:29pez@U11BV7MTK, here might be some inspiration for you. This is what Calva asks for when jacking in to a shadow-cljs project:#2019-10-2615:31dpsuttonthat's the current behavior unfortunately. someone recently put the default builds in but they are sent as regular builds#2019-10-2615:32pezAnd then it asks where to connect. And the user can at any point choose to connect to a different build/repl. Not sure how this would work in CIDER, but in Calva there is only one CLJS REPL at a time connected.#2019-10-2615:32dpsuttonoh it can take multiple @pez?#2019-10-2615:32dpsuttoncan watch several and then nrepl select a single?#2019-10-2615:32pezYes, it can take multiple builds at start up, so that shadow starts watchers for all of them. Then single for the connect step.#2019-10-2615:34thhelleryou can switch between REPLs at will once the watch is running#2019-10-2615:34pezYeah, so Calva supports that.#2019-10-2615:34dpsuttonthat's quite nice. the more i use cljs tooling the more i want the magic to go away 🙂#2019-10-2615:34thhellerso if shadow-cljs browser-repl is running externally#2019-10-2615:35dpsuttoni've made a cljs-repl-type that just ensures piggieback is there and then use the api of your build tool#2019-10-2615:35thhelleryou are actually allowed to (...api/nrepl-select :browser-repl)#2019-10-2615:35dpsuttoni'm not sure the auto stuff is more helpful than obscuring what tools are actually available#2019-10-2615:35dpsuttonah interesting#2019-10-2615:35pezVery cool. I wonder if Calva could support that in some easy way…#2019-10-2615:35thhellerI would love if more of the stuff was done via nrepl messages#2019-10-2615:35pezWhich auto stuff?#2019-10-2615:36thhellerand less via hijacking eval and hope some bindings exists#2019-10-2615:36dpsuttonthe cljs startup commands. they are done for you and not displayed#2019-10-2615:36dpsuttonyou'd like an explicit :cljs/eval op in nrepl rather than the way it works now?#2019-10-2615:38thhellerI'm not sure honestly. the major issue I have with nrepl is that it is built with solely CLJ in mind#2019-10-2615:38thhellerthat means its "session" support is an atom that ONLY allows vars as keys#2019-10-2615:39thhellerthose vars are bound in the context of eval#2019-10-2615:39thhellerbut that doesn't translate to CLJS at all#2019-10-2615:40thhellerdunno ... the stuff I'm doing with the Inspect feature and shadow.remote is basically a new REPL protocol#2019-10-2615:41thhellergave up trying to get this working with nREPL#2019-10-2615:41thhellerso I really have no idea how to make it better 😛#2019-10-2616:18pez@thheller: I am trying to get my react-native + re-frame project up to date again. I based it on your example once. It works, but when I do yarn start after a while I get this warning:
WARNING in /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Performance/Systrace.js 1:2947-2954
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/react-native/react-native-implementation.js
 @ /Users/pez/Projects/rn-rf-shadow/app/index.js
 @ multi /usr/local/lib/node_modules/expo-cli/node_modules/react-dev-utils/webpackHotDevClient.js /Users/pez/Projects/rn-rf-shadow/app/index.js
And after that a lot of errors like this one
ERROR in /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components/AnimatedImage.js
Module not found: Error: Can't resolve '../../../Image/Image' in '/Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components'
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/components/AnimatedImage.js 1:23-54
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Animated/src/Animated.js
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableRow.js
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js
 @ /Users/pez/Projects/rn-rf-shadow/node_modules/react-native/Libraries/react-native/react-native-implementation.js
 @ /Users/pez/Projects/rn-rf-shadow/app/index.js
 @ multi /usr/local/lib/node_modules/expo-cli/node_modules/react-dev-utils/webpackHotDevClient.js /Users/pez/Projects/rn-rf-shadow/app/index.js
Any idea where I should look for the source of these? Things still work, but it is hard to develop with all those errors…
#2019-10-2616:51thheller@pez looks to me like you have the hot-reload stuff from react-native enabled. that still needs to be disabled.#2019-10-2616:51thhellerotherwise those are all errors from inside neact-native internals so I have no clue. none of those sources are processed by shadow-cljs.#2019-10-2617:28pezThanks, I’ll figure it out. #2019-10-2622:24darwinrunning shadow-cljs start from command line works without warnings, but when I try to run (shadow.cljs.devtools.server/start!) from my test runner I get a ton of warnings about “<xxx> provide conflict for <yyy>” I made sure I’m running it from the same dir, not sure where would be a difference. Thanks for help.#2019-10-2622:26thhelleryou get those warnings too for start, they just end up in the .shadow-cljs/*.log files#2019-10-2622:26thhellerstart starts in the background, you'd get them with shadow-cljs server too#2019-10-2622:27thhellerprovide conflicts just mean that something on your classpath is duplicated#2019-10-2622:28darwinok thanks, I will hunt it down, it looks like my compiled assets are on the classpath for some reason#2019-10-2622:29darwinand when I have you here, it would be handy for me to use :lein option in shadow-cljs.edn, it works from command-line, but seems to be ignored when running as a library#2019-10-2622:29darwinjust wanted to get confirmation#2019-10-2622:30thhellernot sure what you are asking#2019-10-2622:30thhellerwhen running as a library you already started it so the :source-paths and :dependencies or :lein in shadow-cljs.edn don't matter at all#2019-10-2622:30thhellerthey are only used when you use shadow-cljs itself to start things?#2019-10-2622:31darwinshadow.cljs.devtools.api/watch etc. seems to be reading shadow-cljs.edn as-is, without looking at :lein or doing anything about it#2019-10-2622:31thhellerI don't understand what you are talking about sorry#2019-10-2622:31thhellerwhat do you expect?#2019-10-2622:32thhellerof course it won't look at :lein, it is already running?#2019-10-2622:33thhellerwatch will read the config file yes, it must get the :builds entries#2019-10-2622:33darwinhm, maybe I’m misunderstanding whole client-server architecture of shadow-cljs, I want to run it inside my JVM alongside my other stuff#2019-10-2622:34thhelleryes. you did that when running server/start!#2019-10-2622:34darwinso I can call shadow.cljs.devtools.api/get-worker and get repl-state from there#2019-10-2622:34thhellerall fine#2019-10-2622:34thhelleryour JVM is now the shadow-cljs server#2019-10-2622:34darwinah, I mean build-state, for shadow.cljs.repl commands#2019-10-2622:35darwinok, good, but when I start it this way, it won’t respect :lein correct?#2019-10-2622:35thhelleryou are confusing the heck out of me right now#2019-10-2622:35thhellerwhat effect would :lein even have at that point?#2019-10-2622:35thhellerYOU started a JVM that you called start! in#2019-10-2622:35darwinit would give :source-paths and :dependencies#2019-10-2622:36thhellerno other JVM will be started. your :source-paths and :dependencies apply from however you started YOUR JVM#2019-10-2622:36thhellerthats the point of embedded mode 😛#2019-10-2622:37darwinok, now I get it, I thought it was doing some dynamic classpath stuff#2019-10-2622:38thhellerno, nothing at all. I experimented with that a bit but that was causing nightmares when running inside lein or boot or clj. basically anything where shadow-cljs wasn't in full control of the JVM#2019-10-2622:38darwinok, thanks for your help, will try to move forward, working on that dirac integration#2019-10-2622:40thhelleryou might be interested in the plugin stuff I have sort of sketched out but never quite finished#2019-10-2622:41thhellerso you could run inside shadow-cljs maybe? seems a weird route to embed shadow-cljs in diract? you don't embed figwheel right? connect to nrepl instead?#2019-10-2622:42thhelleror is this just for testing stuff?#2019-10-2622:51thhellerI would probably advise not working on this right now. the shadow.remote stuff I'm using for the Inspect stuff will most likely become part of the "official" API#2019-10-2622:51thhellerand it will contain many parts that you'll likely need that aren't really otherwise exposed right now#2019-10-2622:52darwinif shadow.remote is what I think it is, I would like that approach, I would connect to well-known port to shadow-cljs server and ask it to convert cljs-source -> js-source for me#2019-10-2622:52darwinlike you would do in your web repl#2019-10-2622:53thhelleryes, that will be part of it indeed#2019-10-2622:53darwinI just hit a show stopper in the approach I wanted to do, you patched clojurescript compiler, so I cannot have normal compiler and shadow-cljs living in peace in the same JVM#2019-10-2622:54thhelleryeah thats gonna get you in trouble#2019-10-2622:55thhelleralthough I tried to be non-invasive and just add stuff that won't do anything when using the cljs.compiler directly#2019-10-2622:56darwinthis remote approach will be much more flexible#2019-10-2622:56darwinI will just need support for :locals and querying current ns#2019-10-2818:50ro6Is there a way to ensure a particular ns gets loaded early? Kinda like :preloads but also in the release build? I have some (extend-type ...) calls that I want to be available everywhere in the browser environment without having to require the ns. Or would the preferred way just be to require the ns in each of the "init" namespaces that Shadow knows about?#2019-10-2818:57thheller@robert.mather.rmm it is generally bad practice to rely on some side-effect during loading, but the order of :entries will be preserved in your config#2019-10-2818:58thhellerso you can configure :modules {:main {:entries [that.side-effect-ns ]}}#2019-10-2905:01gdubsHello! Newb here! I’m having a problem requiring javascript modules from cljs. I’ve created a super-simple reproduction (~4 lines). Googling my error comes up with nothing. Can anybody help me? I’m compiling with npx shadow-cljs compile npm.#2019-10-2905:02gdubs@cachapline8 ☝️#2019-10-2906:45David Pham@gdwarner you should have builds configuration in your shadow-CLJS.edn#2019-10-2906:46David PhamIf you target node, you can check this repo#2019-10-2906:46David Phamhttps://github.com/minimal-xyz/minimal-shadow-cljs-nodejs#2019-10-2906:47David PhamIn perticular this file #2019-10-2906:47David Phamhttps://github.com/minimal-xyz/minimal-shadow-cljs-nodejs/blob/master/shadow-cljs.edn#2019-10-2907:58witekHi. I have a problem with a macro, after I switched from figwheel to shadow-cljs. My macro (defmacro assert ...) lives in kunagi_base/utils.cljc. I have no :require-macros or anything like that in my code. With figwheel this worked fine. Shadow-cljs gives me this error: Use of undeclared Var kunagi-base.utils/assert. Any suggestions? Thank you!#2019-10-2908:03thheller@gdwarner and what is your error? that snippet says nothing without more context#2019-10-2914:50gdubsThere’s a stacktrace in the bottom of the snippet: ReferenceError: shadow$provide is not defined#2019-10-2914:51thhelleroh oops. I missed that it was expandable#2019-10-2914:51thhellerok that error is because :npm-module defaults to :runtime :browser but you are using it in node#2019-10-2914:52thhelleryou need an actual build config like :builds {:npm {:target :npm-module :runtime :node :output-dir "node_modules/shadow-cljs"}}#2019-10-2914:52thhellerthat would match what you have now but run in node#2019-10-2908:04thheller@witek see https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html you might have been relying on https://clojure.atlassian.net/browse/CLJS-2454#2019-10-2908:05thheller#?(:cljs (:require-macros [kunagi-base.utils])) is likely missing in that ns#2019-10-2908:47witekWhen using release, I get Uncaught TypeError: Cannot read property 'g' of undefined. Wasn't there a way to create release output with hints to the real (not shortened) names?#2019-10-2909:17thheller@witek shadow-cljs release app --pseudo-names will make the names slightly more recoginizable but you probably want to turn on https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs if you haven't already#2019-10-2909:50flightcubsTrying to use shadow-cljs in Cursive with the pom.xml method. Should Cursive be able to resolve references to node modules (or javascript references such as (.log js/console "...")), or is it expected that it doesn’t?#2019-10-2909:51flightcubsFound previous questions regarding this, sorry about that 🙂 https://clojurians.slack.com/archives/C6N245JGG/p1572023469012800#2019-10-2909:52flightcubsDoes that apply for js in general (including the npm packages)?#2019-10-2911:32thhellerI'm not sure about the state of JS support in Cursive. it has never worked for me so I'm not sure if its suposed to work.#2019-10-2911:34flightcubsGot it - thanks 🙂#2019-10-2912:37orestisI’m still seeing problems when restarting the shadow-cljs build. The process is, I kill shadow-cljs to add a new dependency in deps.edn, then start it again. Then a bunch of errors appear, at their root:
TypeError: module$node_modules$react$index.createContext is not a function
    at eval (routes.cljs:10)
    at eval (routes.cljs:10)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:827)
    at Object.env.evalLoad (main.js:2174)
    at main.js:2412
#2019-10-2912:38orestisIf I delete all compiled output, the shadow-cljs cache, and node_modules, then starting the build again, everything compiles fine.#2019-10-2912:40orestisI get a lot of similar errors too: TypeError: _react.default.createContext is not a function, TypeError: React.forwardRef is not a function, TypeError: module$node_modules$react$index.memo is not a function and similar.#2019-10-2912:41thhellernot much I can say about that. maybe you have some bad browser cache?#2019-10-2912:41thhellerwhat setup do you use? the shadow-cljs http servers or something custom?#2019-10-2912:42orestisCustom http server, but with browser cache disabled.#2019-10-2912:42thhellernext time this happens. DO NOT DELETE ANYTHING!#2019-10-2912:42orestisIs there any way I could trouble shoot this?#2019-10-2912:43thhellerimpossible to tell what is happening if you wipe everything#2019-10-2912:43thhellerat least copy it somewhere#2019-10-2912:43orestisRoger that. I’ll keep a copy of the .shadow-cljs, node_modules and the compiled output.#2019-10-2912:51thhelleralso keep more errors ... excerpts of errors are pretty much pointless. it is likely one error cascading out and causing all the rest#2019-10-2912:53thhellerservice workers can also be a big problem, any cache really.#2019-10-2912:53orestisIs there something I should be looking for?#2019-10-2912:53thhellerI don't know#2019-10-2912:54orestisIt looks like that React itself has some issue. It could be some dependency but I can’t be sure at this point.#2019-10-2912:54thhellerit looks to me like react isn't loaded at all#2019-10-2912:54thhellereverything is undefined#2019-10-2912:56orestisYep, that seems to be the case. One thing that I see in the compiled output is that while I have a “main.js” file which is 11MB, there’s also a whole bunch of individual files under cljs-runtime.#2019-10-2912:57thhellersounds normal#2019-10-2912:57thhellerare you sure the "old" shadow-cljs instance was actually dead?#2019-10-2912:57thhellerthings will get weird if 2 shadow-cljs instances write to the same output-dir#2019-10-2914:53gdubs@neo2551 I’m targeting node, but with the npm-module variant. The docs say that I can use the default shadow-cljs.edn via the ‘covenience mode’. https://shadow-cljs.github.io/docs/UsersGuide.html#_convenience_mode .#2019-10-2914:53thhelleryeah that should mention that is a convenience mode for webpack#2019-10-2914:54thhellerit works if you stay in CLJS only#2019-10-2914:54thhellerbut the JS support needs to know which runtime you are running in#2019-10-2914:54gdubstrying… hopefully that is the missing piece#2019-10-2914:57gdubsSame problem.#2019-10-2915:00thheller@gdwarner try adding :entries [hi] to the build config?#2019-10-2915:01thhellerdefinitely a bug since it is supposed to work without, but maybe a quick fix#2019-10-2915:03gdubsStill no worky with the config below. Regardless, I appreciate your help!#2019-10-2915:04gdubsdoes it matter: hi vs “hi”. Or do I need to include “hello” since that’s what I’m trying to require?#2019-10-2915:04thhellerthats not in the build config#2019-10-2915:04thhellershould be in :builds :app#2019-10-2915:05gdubsah#2019-10-2915:05thhellersymbol vs string matters yes. always a symbol for CLJS namespaces#2019-10-2915:06thhellerbut you only need to list the "entries". meaning namespaces accessed from elsewhere (eg. require in node). it'll include its dependencies automatically#2019-10-2915:06thhellerbut yeah its just a global missing#2019-10-2915:08thhellerany particular reason you are using :npm-module? :node-library and :node-script are much better generally#2019-10-2915:09thhellerquick fix might be global.shadow$provide = {} before running the require in node#2019-10-2915:09gdubsI want to call my clojure lib/module from javascript. I don’t think I want node-script, but node-library may be appropriate. I have no intention of actually creating an npm module.#2019-10-2915:10gdubsAs I’m still getting the same error, even with entries, I’ll try node-library.#2019-10-2915:10thhellerhang on#2019-10-2915:10thhellertry the quick fix I just mentioned#2019-10-2915:10gdubswill do#2019-10-2915:10thhellerso I know if it works without having to test myself 😛#2019-10-2915:11thhellerbut yeah node-library has a better structure and better "output"#2019-10-2915:11thhellerhas nothing to do with actually publishing to npm at all#2019-10-2915:12gdubsok, your suggested fix eliminated the stack trace I was seeing.#2019-10-2915:12gdubswoohoo#2019-10-2915:12thhellerif you don't mind please open an issue with the initial snippet you pasted#2019-10-2915:13thhellerwill look into it later#2019-10-2915:13gdubssure thing#2019-10-2915:13gdubsthank you very much!#2019-10-2915:18cjsauerIf one of my deps is described as “cljs support coming soon”, but contains (temporarily) incorrect .cljc files, is there a way to tell shadow to ignore that dep during cljs compilation? I don’t intend to use it from cljs, but do want it on my classpath at the clj REPL.#2019-10-2915:19thheller@cjsauer not sure what you mean. what is the actual problem you see? just files on the classpath shouldn't hurt unless you use them?#2019-10-2915:21cjsauerWhen I add this specific dependency to my project, it breaks cljs compilation by throwing a bunch of warnings about undefined vars in my test files. Removing the offending dep fixes things. I’m guessing that the bad .cljc files in that dep are causing cljs compilation to fail in some way.#2019-10-2915:21thhellerbreaks how ...#2019-10-2915:22thhellerit doesn't matter whats on the classpath UNLESS you actually :require a file#2019-10-2915:23thhelleror do you add the dependency via deps.edn :local/root or gitlibs and use a test target?#2019-10-2915:24cjsauerYes, forgot to mention I’m using {:deps {:aliases [...]}}#2019-10-2915:24thhellerthat isn't what I asked 😛#2019-10-2915:24thheller:local/root or gitlibs was the important bit 😛#2019-10-2915:24cjsauerSorry picard-facepalm, no it’s a normal :mvn/version style dependency#2019-10-2915:25cjsauerI don’t require this specific dep in the *-test.cljs files that the warnings point to… 🤔#2019-10-2915:25thhellerwhat does it say exactly?#2019-10-2915:26thhellerI mean it should be telling you who required something if thats not found?#2019-10-2915:26cjsauerIt points at about 6 of my deftest macros with an undeclared var warning, for example:
(deftest entity-ids->lookup-set
Use of undeclared Var my-app.client-test/entity-ids->lookup-set
#2019-10-2915:27thhellerI'm confused. how is that related to adding a dependency?#2019-10-2915:28thhellerseems to be warning about your namespaces?#2019-10-2915:28cjsauerYeah…not sure…removing the dependency also removes all of those warnings strangely enough.#2019-10-2915:28thhellerwhat dependency is that?#2019-10-2915:28cjsauerThis is datahike#2019-10-2915:28thhellerplease full info#2019-10-2915:29thhellerwith version#2019-10-2915:29cjsauer[io.replikativ/datahike "0.2.0"] https://github.com/replikativ/datahike#2019-10-2915:30cjsauerAttempting to compile the .cljc files in that repo fails with all kinds of exceptions, because the cljs support isn’t there yet. My thought was those files were somehow tripping up my own compilation. But: >it doesn’t matter whats on the classpath UNLESS you actually :require a file#2019-10-2915:31thhellerno. unless a file is included somehow it is not compiled#2019-10-2915:31thhellerit doesn't matter what is in the file#2019-10-2915:31thheller> Attempting to compile the .cljc#2019-10-2915:32thhellerso we want to figure out WHY it is attempting to compile#2019-10-2915:32thhellerBUT your issues seem related to something else#2019-10-2915:32cjsauerAh sorry, by that I meant cloning that repo and running their cljs tests doesn’t work (which is expected). It fails compilation.#2019-10-2915:33thhellerI'm lost ... what are you doing?#2019-10-2915:33thhelleryou are cloning actual datahike and run the tests?#2019-10-2915:34thhellerplease don't throw in unrelated info .. this is confusing enough as it is 😛#2019-10-2915:34cjsauerThis was when I thought maybe datahike’s cljc files was to blame >BUT your issues seem related to something else This is likely the case now that I know shadow is likely not touching any datahike code#2019-10-2915:34thhellerplease restate your problem. the actual warnings you see ... not your diagnosis.#2019-10-2915:35thhellerI'm completely lost and don't know what your problem is anymore#2019-10-2915:35thhellera) you have working tests#2019-10-2915:35thhellerb) adding the datahike dependency breaks those working tests?#2019-10-2915:36thhellerc) NONE of your code actually has a datahike require? anywhere?#2019-10-2915:43cjsauerSure, let me restate#2019-10-2916:02cjsauera) Yeah, I have working tests using the :browser-test build target. I can open the resulting build up in the browser and see All tests passed. b) I add the datahike dependency to my deps.edn file, and then rerun my :browser-test build, which results in a bunch of warnings, but I just found that there is one interesting one:
Resource: datascript/core.cljc:586:36
 Use of undeclared Var cljs.reader/register-tag-parser!
c) Correct. None of my code has made any attempt to require or use datahike yet. So, there seems to be some conflict between datascript and datahike that I think is likely unrelated to shadow (apologies for the noise here). The key thing missing from my understanding of shadow was this: >it doesn’t matter whats on the classpath UNLESS you actually :require a file
#2019-10-2916:03thhellerplease run shadow-cljs clj-repl and ( "cljs/reader.cljs")#2019-10-2916:05cjsauer
#object[java.net.URL 0x72d5daf9 "jar:file:/Users/calvin/.m2/repository/org/clojure/clojurescript/1.10.520/clojurescript-1.10.520.jar!/cljs/reader.cljs"]
Seems to exist and load just fine. Likely a dep conflict like you mentioned. I’ll keep investigating. Thanks for your help 🙏
#2019-10-2916:05thhellerdid you potentially get a bunch of warnings on startup about "provide conflicts"?#2019-10-2917:03cjsauerOh! Yes I did. I hadn’t even noticed those.#2019-10-2917:04cjsauer#2019-10-2917:06thhelleris that /private something you did?#2019-10-2917:07thhellerotherwise there are some compiled files on the classpath that shouldn't be#2019-10-2917:23cjsauerHm…not intentionally. I can’t seem to find that directory anywhere on my filesystem. Commenting out the datahike dependency causes all of these conflicts to disappear…this /private folder doesn’t exist in the datahike jar file either 🤔#2019-10-2917:35thhelleryou can check via ( "private/js/out/cljs/reader.js") which dependency include that#2019-10-2917:36thhellerhttps://github.com/thheller/shadow-cljs/issues/584#2019-10-2917:36thhellerI'll remove this particular behavior so that extra "bad" output doesn't cause trouble#2019-10-2917:41cjsauerAha, it looks like replikativ’s hasch lib is the culprit for that specific conflict:
( "private/js/out/cljs/reader.js")

#object[java.net.URL 0x698e4e6c "jar:file:/Users/calvin/.m2/repository/io/replikativ/hasch/0.3.5/hasch-0.3.5.jar!/private/js/out/cljs/reader.js"]
#2019-10-2917:45thhellerindeed. the jar is 2.1mb ... with a bunch of dev output#2019-10-2917:53cjsauerI’ll keep an eye on that issue. Thanks again for your time, and for shadow.#2019-10-2916:03thhellercould also just be a dependency conflict#2019-10-2916:03markxAny suggestion on how to move everything into a new directory, e.g. dist/ when run npm run build? I understand this might not be shadowcljs’ job, but wonder how people do it.#2019-10-2916:04thhellerwhat is npm run build?#2019-10-2916:06markxIt’s the npm-script. I usually config something like
"scripts": {
    "start": "shadow-cljs watch app",
    "build": "shadow-cljs release app"
  },
#2019-10-2916:06thhellerso why do you want to copy it? why not just have shadow-cljs write the output dir you actually want?#2019-10-2916:07thhellerif you really need to copy you can just use "build": "shadow-cljs release app && cp dist somewhere" or so?#2019-10-2916:28markxIt’s just my preference to have everything built to a separate folder. If you dev and release in the same folder, say public/js/, then do you commit this folder in VCS, say git? I do want to commit the release version, but then I will always see it changing in git status when I dev.#2019-10-2916:30markxsomething like shadow-cljs release app && cp dist somewhere would work, but then before I copy, I assume I need to clean up the dev files? But shadow-cljs doesn’t have a clean command, so…#2019-10-2916:31markxJust wondering how others do it, if one ever does.#2019-10-2916:33Filipe Silvain https://github.com/filipesilva/create-cljs-app/blob/master/template/package.json I instead use a clean command#2019-10-2916:33Filipe Silva
"start": "shadow-cljs watch app",
    "build": "yarn clean && shadow-cljs release app",
    "clean": "rimraf public/js"
#2019-10-2916:33Filipe Silvafor the same reasons really#2019-10-2916:34Filipe Silvawhen deploying dist/, I don't want to include the non-prod js files that get produced there#2019-10-2916:55markxAh nice. So I can clean, build, and copy.#2019-10-2916:56markx@filipematossilva do you have any plans to add something like react-scripts for create-cljs-app?😁#2019-10-2917:11Filipe Silvaso abstracting away all the tools in a separate package, right?#2019-10-2917:12Filipe SilvaI thought about it but I think that runs a bit contrary to the clj ethos... although this starter is directed to js folks#2019-10-2917:20Filipe SilvaI also don't feel that confident in my knowledge of the "best" way of doing things#2019-10-2917:41thheller@filipematossilva would you mind changing the default generated config a bit. I'd rather it used the newer :dev-http config#2019-10-2917:42thhellerso instead of
{:builds
   {:app
      {:asset-path "/js",
       :devtools {:http-port 3000, :http-root "public"},
       :modules {:main {:init-fn app.core/main}},
       :output-dir "public/js",
       :target :browser},
    :e2e
      {:ns-regexp "e2e.*",
       :output-to "out/e2e.js",
       :target :node-test},
    :test
      {:ns-regexp "app.*-spec$",
       :output-to "out/test.js",
       :target :node-test}},
 :dependencies [[reagent "0.8.1"]],
 :nrepl {:port 3333},
 :source-paths ["src" "e2e"]}
you do
{:builds
 {:app
  {:asset-path "/js",
   :modules {:main {:init-fn app.core/main}},
   :output-dir "public/js",
   :target :browser},
  :e2e
  {:ns-regexp "e2e.*",
   :output-to "out/e2e.js",
   :target :node-test},
  :test
  {:ns-regexp "app.*-spec$",
   :output-to "out/test.js",
   :target :node-test}},
 :dependencies [[reagent "0.8.1"]],
 :nrepl {:port 3333},
 :dev-http {3000 "public"}
 :source-paths ["src" "e2e"]}
#2019-10-2917:42thhelleralso kinda not very clojure-ish with all the , and incorrect indentation 😛#2019-10-2917:44thhellertop-level :dev-http instead of nested :devtools {:http...} is the newer format#2019-10-2921:34aisamuGood to know! And where would :http-resource-root and :preloads fit into this new pattern?#2019-10-2921:35thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-10-2921:35thheller:dev-http {3000 "classpath:public"}#2019-10-2921:36thheller:preloads stay were they are since they are actually build related#2019-10-2921:36thhellerbut you can also move them into individual :modules#2019-10-2921:36aisamuGreat, thanks!#2019-10-2917:46Filipe Silvaregarding the config changes, yes let me add it#2019-10-2917:47Filipe Silvaregarding the indentation, that is the default for zprint-clj https://github.com/kkinnear/zprint#2019-10-2917:48Filipe SilvaI couldn't find another formatter that had a good npm distro#2019-10-2917:48Filipe Silvais there a canonical config for these formatters that matches what people use?#2019-10-2917:50thhellerbtw you can always run clojure code using https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-10-2917:51thhellerso you can run any clojure code you want (eg. zprint)#2019-10-2917:51thhellerif a shadow-cljs server instance is running you won't even pay for startup time#2019-10-2917:52Filipe SilvaI had no idea, that sounds pretty handy!#2019-10-2917:52thhellerthere are some clj -m zprint.main <deps.edn examples in the zprint readme#2019-10-2917:53thhellershadow-cljs run zprint.main would be the same#2019-10-2917:57thhelleralthough I guess the <deps.edn would be a problem#2019-10-2917:58thhellerbut that could be fixed#2019-10-2918:01Filipe Silvaso right now shadow-cljs run lets me run a given function in a clj namespace I have#2019-10-2918:02Filipe Silvabut to use it directly as shown in https://github.com/kkinnear/zprint#clojure-cli might not work currently, is that right?#2019-10-2918:07Filipe SilvaI trying just doing run zprint.main without any modification to shadow-cljs.edn besides adding the dependency, and it seems to print the formatted output
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1c777d7175775c4e595831442d5f2a"}, :content ("[email protected]")}
#2019-10-2918:07Filipe Silvait's very slow though#2019-10-2918:34Filipe Silva(btw the dev:http change is now published)#2019-10-2918:46thheller@filipematossilva have you read about server mode and how it functions? (regarding the "slow" comment)#2019-10-2919:23Filipe SilvaI'm familiar with it insofar as using shadow-cljs start in the background to speed up further commands.#2019-10-2919:23Filipe SilvaI didn't try it with this command though#2019-10-2919:23Filipe Silvalet me try#2019-10-2919:24thhelleror shadow-cljs server yes#2019-10-2919:24thhellerbut yeah the point is to get rid of the startup delay. so in general the server should always be running when you are developing#2019-10-2919:24thhellermaking startup time a non issue#2019-10-2919:25Filipe SilvaYes you are right, it is much faster now. Especially the second and subsequent runs.#2019-10-2919:30Filipe SilvaI need to think a bit about this usage pattern... It feels pretty powerful insofar as it provides direct access to all these clj tools. But I'd need to see if I could get a 1-to-1 correspondence as far as functionality goes. The npm zprint wrapper allows formatting all files and writing them back to the same place, and that sounds like it'd need a custom function to do. But a custom function is also a good example of how a user can customize it.#2019-10-2919:33thhellerI just wanted to mention it. just in case there is something available in clj but not on npm#2019-10-2919:34thhellerthe zprint defaults seem to suck for code but there was a big discussions about formatters a while ago#2019-10-2919:34thhellerguess CLJ is too flexible syntax wise to find an "agreeable" standard#2019-10-2919:35Filipe SilvaI remember seeing a discussion on clojureverse I think#2019-10-2919:35Filipe Silvait looked stalled#2019-10-2919:35thhelleryeah its a bit easier in JS and especially JSON configs since they are least maintain insertion order#2019-10-2919:36Filipe SilvaI had an unrelated question for you#2019-10-2919:36Filipe Silvaare the npm wrappers today the same as described in https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html?#2019-10-2919:36thhellerhmm?#2019-10-2919:37Filipe Silvaso something like
// node_modules/lib/foo.js
shadow$provide["module$node_modules$lib$foo"] = function(module, global, process, exports, require) {
    var foo = 1;
    exports.hello = function() { return foo; };
}

// node_modules/lib/bar.js
shadow$provide["module$node_modules$lib$bar"] = function(module, global, process, exports, require) {
    var foo = require("module$node_modules$lib$foo");
    foo.hello();
}
#2019-10-2919:37thhelleryes, mostly the same#2019-10-2919:38Filipe Silvain regards to module usage, I assume these wrappers can never avail from code motion, right?#2019-10-2919:38thhellerhmm?#2019-10-2919:39Filipe SilvaGCC has a nice feature called code motion, where it can "split" the content of a given JS file if part of it is used in one module but not the others#2019-10-2919:39thhelleryes I know#2019-10-2919:39Filipe Silvaso for instance
// node_modules/lib/foo.js
shadow$provide["module$node_modules$lib$foo"] = function(module, global, process, exports, require) {
    exports.hello = function() { return 1; };
    exports.world = function() { return 2; };
}
#2019-10-2919:39thhellerno, the npm content is never "split"#2019-10-2919:39Filipe Silvaok#2019-10-2919:40thhellerbut it is moved into the proper modules when it can#2019-10-2919:40thhellerie. if module B uses something the others don't they will be in B#2019-10-2919:40Filipe Silvais there a way to exclude certain modules from the wrapper?#2019-10-2919:41thhellerdon't understand the question#2019-10-2919:41thhelleryou can't not wrap the code#2019-10-2919:42Filipe SilvaI was trying to imagine how would code motion be used for npm libraries, assuming the library was in a GCC friendly format#2019-10-2919:42thhellerif everything was strict ES6 then we would just enable GCC for everything#2019-10-2919:42thhellerwith all its glory#2019-10-2919:43thhelleruntil then we run in "compatibility" mode#2019-10-2919:44thhelleryou can't select one library to go with the full mode while others don't#2019-10-2919:44thhellerthats leads to the externs mess we already have to deal with#2019-10-2919:45thhellerI experimented with all of this a very long time. basically it never works. there are barely and "strict" ES6+ modules on npm (that also only depends on other strict ES6+ code)#2019-10-2919:46Filipe SilvaI don't mean for the general case though#2019-10-2919:46thhellerdo you have an actual example?#2019-10-2919:47Filipe Silvayeah, now that I think about it I do#2019-10-2919:47Filipe Silvaso for instance I could try to import @angular/core. It is published in ES2015 among other formats. It is also annotated for GCC via tsickle (a TS wrapper to annotate TS output for GCC).#2019-10-2919:48Filipe Silvanevermind that there's no way in hell angular will properly work in cljs#2019-10-2919:48Filipe Silvabut that library is full ES2015#2019-10-2919:48Filipe Silvathen separately I also had momentjs, which is in crazy format#2019-10-2919:48Filipe SilvaI import them both from my app#2019-10-2919:49Filipe Silvabut neither has an interdependency#2019-10-2919:49Filipe SilvaI would like to tell shadow-cljs "try to import angular/core in full GCC mode, but keep momentjs in compat"#2019-10-2919:49thhellerthat doesn't work#2019-10-2919:50thhelleryou can "fake" it by copying node_modules/@angular/core/esm5/* to src/main/angular or so#2019-10-2919:51thhellerthen import it via (:require ["/angular/index.js" :as angular])#2019-10-2919:51thhellerclasspath JS will follow be processed by the GCC and advanced#2019-10-2919:52thhellerbut that means you can't use any libraries that want to use angular#2019-10-2919:52Filipe Silvayes, that limitation I did expect#2019-10-2919:52thhellerand you'll need a whole bunch of externs for all the code it consumes#2019-10-2919:53thhellersince there is no externs inference for JS code#2019-10-2919:53Filipe Silvaso back to the old externs way#2019-10-2919:53thhellerwell you can always turn of the renaming#2019-10-2919:53Filipe Silvayeah but that kinda defeats the purpose of trying to optimize these further#2019-10-2919:54thhellervar PlatformRef = /** @class */ (function () {#2019-10-2919:54thhellerwhy does it not use class? 😛#2019-10-2919:54Filipe Silvabecause that's es5 code in ESM format#2019-10-2919:54Filipe Silvathere's also es2015 code in another folder#2019-10-2919:54Filipe Silvathe esm2015 one#2019-10-2919:55thhellerah right#2019-10-2919:55Filipe Silvawhen you said this doesn't work, do you mean that it's not a feature that is available or that there's no reasonable way such a feature could be developed?#2019-10-2919:56thhellerwell, not going to call it impossible. I certainly can't implement it in a reasonable way.#2019-10-2919:57thhellerif you had perfect externs then it is possible yes#2019-10-2919:57thhellerBUT that only applies when mixing code#2019-10-2919:59Filipe SilvaYou mentioned there is no extern inference for js code. I imagined that the wrapped npm libs got some sort of extern inference.#2019-10-2920:00Filipe Silvais it that they don't actually get any extern inference?#2019-10-2920:01thheller"they" don't need inference, if by they you mean the npm libs#2019-10-2920:01thhellerthe :advanced parts need externs for the code not part of the advanced compilation (ie. npm code)#2019-10-2920:01thhellerif you process some of the npm libs as part of advanced#2019-10-2920:02thhellerthen they also don't need externs. but you still need externs for others#2019-10-2920:02thhellerAND if you have npm libs accessing the advanced code you'll need externs for those parts#2019-10-2920:02thhellerso the closure compiler doesn't rename those either#2019-10-2920:02thhellerits a mess#2019-10-2920:03thhellerthe current state of npm just doesn't allow anything more than what is currently done#2019-10-2920:03Filipe Silvano I don't think there's ever going to be a solution for the re-entrant case#2019-10-2920:04Filipe Silvawhere by re-entrant I mean going from "compat" back to "full gcc" code#2019-10-2920:04Filipe Silvawhich is probably me misusing the word#2019-10-2920:04thhellerwith enough info about what is used it is possible#2019-10-2920:04thhellerbut getting that info might not be possible 😛#2019-10-2920:04Filipe Silvayeah but no one is going to bother getting all that#2019-10-2920:05Filipe Silvawhich is why shadow-cljs filled up this need so well#2019-10-2920:05Filipe Silvafull npm compat is sweet#2019-10-2920:06thhellerbitter sweet maybe 😛 I kinda regret exposing us to that world sometimes#2019-10-2920:06Filipe Silvatbh that's what drew me to shadow-cljs instead of any other setup#2019-10-2920:07thhelleryeah, sometimes you just want access to all that stuff#2019-10-2920:07Filipe SilvaI'm from a JS background and it's a hard sell to have a huge overhead to all the stuff you already know#2019-10-2920:08thhelleryeah, same for me with Clojure .. already had 10+ years of experience with Java so having access to that was sort of the killer argument#2019-10-2920:08thhellersame for the JS parts ... just felt like missing out#2019-10-2920:09thhellerbut the npm/JS ecosystem is a lot more messy 😛#2019-10-2920:09thhellerwe'll see how this evolves. I forsee a lot of breakage if they ever adopt more ESM code#2019-10-2920:10Filipe Silvaatm some libraries publish it under non-standard package.json entry points, like module, esm, or es0215#2019-10-2920:11thhellerI know#2019-10-2920:11thhellerthe problem is interop#2019-10-2920:11Filipe Silvawhich means that the resolver needs to know to look these up... and it gets messy#2019-10-2920:11thhellerso 100% commonjs is fine#2019-10-2920:11thheller100% esm would be great#2019-10-2920:11thhellermixing ... is just painful 😛#2019-10-2920:11thheller(shadow-cljs knows about those btw)#2019-10-2920:12thhellerjust doesn't use them by default#2019-10-2920:12Filipe SilvaI sorta expected the wrapper to handle the interop well enough, it's similar to the webpack wrapper#2019-10-2920:12thhellerthe problem is the non-strict interop that babel/webpack had#2019-10-2920:12thhellerwebpack v5 will remove it so we'll see how that goes#2019-10-2920:13thhellerimport { aThing } from "some-common-js" can't work in strict mode#2019-10-2920:13thhelleronly import foo from "some-common-js" + foo.aThing#2019-10-2920:13thhellerbut lots of code relies on the babel interop mode#2019-10-2920:14thhellerwhich means all code moving to the strict variant will break the packages not yet moved#2019-10-2920:14thhellerfun times ...#2019-10-2920:14Filipe Silvafor all the good webpack did, it also messed stuff up a bit by letting people write packages that only work on webpack pipelines#2019-10-2920:14thhellerindeed. although babel takes some of the blame too#2019-10-2920:14Filipe Silvalike all the require('something.css') and defaulting resolving .wasm extensions by default#2019-10-2920:15Filipe Silvahuge burden on consumers#2019-10-2920:15thhellerI understand the need for all of that. just wish they hadn't built it on top of require#2019-10-2920:15thhellerheck even require.asset("something.css") or so would have been better#2019-10-2920:16Filipe Silvayeah something that just wasn't overloading the default stuff that much#2019-10-2920:16Filipe Silvawebpack ended up doing something similar to what I was asking about, where they pulled out esm code into one giant scope, but bail on a number of circumstances#2019-10-2920:17Filipe SilvaSo imagine this case then: - I have cljs code - I have some es2015 libs that sometimes call each other, but never call non-es2015 libs - I have non-es0215 libs that call each other, but not es2015 libs would this case work by having the es2015 libs in advanced mode?#2019-10-2920:17Filipe SilvaI know this isn't something that would just generally work, I'm mostly thinking of a case where I am very familiar with my dependencies#2019-10-2920:18thhellerthere is no mode for it but that would be possible yes#2019-10-2920:18thhellerbut even some libraries that boast to be es2015 aren't#2019-10-2920:18thhellereg. lodash-es#2019-10-2920:18Filipe Silvaand if I switched it a bit to the point where the es2015 libs called non-es2015 libs, but not the other way around?#2019-10-2920:19thhellerif you have externs for the non-es2015 parts#2019-10-2920:19Filipe Silvacouldn't those get figured out by shadowcljs the same way it does when cljs calls a compat-mode npm lib?#2019-10-2920:20thhelleres2015 then effectively becomes the same as CLJS code#2019-10-2920:20thhellerkind of but not really#2019-10-2920:21thhellerJS is just handed to the GCC to do its thing. it would need to do the same kind of processing that is done for CLJS#2019-10-2920:21Filipe Silvayeah that makes sense#2019-10-2920:21thhellercurrently when processing the npm JS code#2019-10-2920:22thhellerit looks for module.exports (and variants thereof) and collects the exported names as externs#2019-10-2920:22thhellerbut in practice that is actually not a good idea and doesn't work when the JS code isn't processed by shadow-cljs (eg. react-native, node-script, node-library, ..)#2019-10-2920:23thhellerso the code is mostly relying on externs inference in CLJS#2019-10-2920:24Filipe SilvaI didn't actually understand that... I thought "extern inference" meant "looking through js code to try and figure out externs" but now I understand it means "looking through CLJS to figure out npm lib externs"#2019-10-2920:25thhellerexterns inference is done in CLJS code#2019-10-2920:25thhellerit looks at the code and tries to figure out if something you accessed will be coming from npm#2019-10-2920:25thhellerwhen it can't figure that out it will warn#2019-10-2920:25thhellerin many cases it is easy to figure out (:require ["some-npm-lib" :refer (foo bar)])#2019-10-2920:26thhellereasy to add the refers to externs#2019-10-2920:26thheller
(defn wrap-baz [x]
  (.baz x))
#2019-10-2920:26thhellernot easy to know if baz is safe to rename or requires externs#2019-10-2920:26thhellerthat's why it would warn https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-10-2920:27thhellerthe JS processing and extra externs gathering is only supplemental#2019-10-2920:27thhellerand not active when building non-browser targets basically#2019-10-2920:29Filipe Silvaif I wanted to take a stab at doing that three tier approach, would you be open to accept contributions?#2019-10-2920:30thhellerif you supply an example project that can be tested against 😛#2019-10-2920:30thhelleradding that is like 10 lines of code or so#2019-10-2920:31Filipe Silvayes I'd provide involved test cases#2019-10-2920:32Filipe Silvait seems like an interesting entry point in contributing to shadow-cljs#2019-10-2920:32thhellerI'd first try to find an actual practical example#2019-10-2920:32thhellerlike something that people would actually use. not some hypothetical thing that doesn't actually exist in the wild#2019-10-2920:33thhelleryou can fake it with zero code changes and just a few symlinks today (or file copies)#2019-10-2920:35Filipe Silvayeah a real example would also give a good indicator of the benefit#2019-10-2920:35Filipe SilvaI imagine the benefit is that the es2015 libs get a dramatic cut in size#2019-10-2920:35Filipe Silvabut maybe that ends up not being true#2019-10-2920:36thhellerthe potential is there for sure#2019-10-2920:40Filipe Silvaoh I think I have an interesting example#2019-10-2920:40thhellerbut I can think of a billion things that can still to wrong#2019-10-2920:40thhellerusing ES6+ code still has a few issues in the way it is currently implemented#2019-10-2920:40thhellerpretty much only works for :browser builds#2019-10-2920:41Filipe Silvayes I don't have any illusions that code on npm will always find way to break#2019-10-2920:41Filipe Silvanpm was never really built with forwards compat in mind#2019-10-2920:41Filipe Silvaso imagine I have a bunch of non-es-2015 libs#2019-10-2920:41Filipe Silvaand then I bundle them via rollup#2019-10-2920:42Filipe Silvakinda of how the cljs recommended they were bundled via webpack instead#2019-10-2920:42Filipe Silvabut this time the output is actually a giant es2015 module#2019-10-2920:42Filipe Silva(that probably is broken because of some weird lib)#2019-10-2920:43Filipe Silvaif it's not broken though, GCC takes over and might do some good because it got a lot of es2015 to work with#2019-10-2920:43Filipe Silvaand since it's a giant es2015 module, gcc can do codemotion#2019-10-2920:43thhellerI thought rollup also only did it for all esm?#2019-10-2920:44thhelleror does it support the mixed thing?#2019-10-2920:44Filipe Silvano, you can config for commonjs compat#2019-10-2920:44Filipe Silvahttps://github.com/rollup/rollup-plugin-node-resolve#2019-10-2920:44Filipe Silvaactually let me check that this produces es2015...#2019-10-2920:45Filipe Silvasorry this is the right one https://github.com/rollup/rollup-plugin-commonjs#2019-10-2920:45Filipe Silvacompat isn't as good as webpack, but it exists#2019-10-2920:45thhellernever used rollup on anything real#2019-10-2920:45Filipe Silvathis of course is subject to all the pitfalls in random code we discussed#2019-10-2920:46thhellerI added a new :js-provider :external not too long ago#2019-10-2920:46thhellerwhich lets you use webpack to create to create an "external" package#2019-10-2920:47thhellersomething like the official CLJS webpack guide recommends, just automated#2019-10-2920:47Filipe Silvain angular cli we're actually experimenting with doing rollup inside webpack... because webpack has a lot of trouble making code in lazy chunks tree shakeable#2019-10-2920:47thhellereek lazy chunks#2019-10-2920:47Filipe Silvaso we process all the es2015 code with rollup, then pass on that output (including lazy modules) to webpack#2019-10-2920:48thhellerI'm scared of libraries actually using import()#2019-10-2920:48thhellerand top-level await#2019-10-2920:48thhellerthe JS world sure has crazy ideas ...#2019-10-2920:48Filipe Silvawith webpack the problem is this: - if you have a single chunk, maybe webpack will do module concatenation and everything is in a single scope, then Terser can do tree-shaking - if you have multiple chunks module then concatenation breaks down, and the webpack module loader indirection stops Terser tree-shaking#2019-10-2920:49thhellerseems like something they could fix with all the funding they have 😛#2019-10-2920:49Filipe Silvarollup, similar to GCC, performs tree-shaking with bundling information#2019-10-2920:50Filipe Silvaso those are the only two JS tools today that can actually handle tree shaking across chunks/modules#2019-10-2920:50Filipe Silvathey probably could but are trying to do build caching as their main focus atm I think#2019-10-2920:52Filipe Silvawhich is why I think shadow-cljs is in a really good place to take advantage of es2015 libs#2019-10-2920:53Filipe Silvacontrary to most of the js ecosystem, the clj ecosystem is not averse to non-js toolchains like java#2019-10-2920:53Filipe Silvathe pure js GCC implementation is pretty much unusable, so realistically GCC needs java#2019-10-2920:56Filipe Silvaanyway I'll try to setup a few realistic test cases, then some mock cases that explore it a bit more, then try a implementation#2019-10-2921:04thhellerhappy to guide you through it. it will mostly be about changing the resource type from :shadow-js to just :js 😛#2019-10-2921:05thhellerhttps://github.com/thheller/shadow-cljs/blob/989590bb373e56b1d0ccf3a4029e2d3ec294ffe3/src/main/shadow/build/resolve.clj#L187#2019-10-2921:05thhellerso the logic there would need to change#2019-10-2921:08Filipe Silvacool, thank you for the pointer#2019-10-2921:08Filipe SilvaI'll look there after the test cases#2019-10-3009:55orestis@thheller Sorry to bother you again with this. Some more info with the broken stuff I'm seeing whenever I restart shadow-cljs. This seems to be the "root" error, AFAICT.#2019-10-3009:58thhellerno it is not the root#2019-10-3009:58thhellerit is just telling you that it failed to load that module. the reason that it failed is somewhere else#2019-10-3009:58thhellerabove or below, can't remember right now#2019-10-3009:58thhellerjust paste everything?#2019-10-3009:59orestis
try {
        moduleFn.call(
          module,
          goog.global,
          shadow.js.jsRequire,
          module,
          module["exports"]
        );
      } catch (e) {
        console.warn("shadow-cljs - failed to load", name);
        throw e;
      }
#2019-10-3009:59orestisIt's a huge log that doesn't copy well -- but this snippet shows shows that the root error is below.#2019-10-3010:00orestisThe only "error" in the console is at the very end:
main.cljs:105 Uncaught TypeError: nosco.routes.start_routing_BANG_ is not a function
    at Object.nosco$views$main$start [as start] (main.cljs:105)
    at admin:14
nosco$views$main$start	@	main.cljs:105
(anonymous)	@	admin:14
#2019-10-3010:00thhelleralso not the root#2019-10-3010:01thhellerwell it might be ... the problem is that it might not exist because loading it failed#2019-10-3010:01thhelleror it might not exist because of other reasons#2019-10-3010:01thhellerno way for me to tell without seeing more errors#2019-10-3010:01orestis
main.js:2176 failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function
    at Object.shadow$provide.module$node_modules$react_redux$lib$components$Context (Context.js:11)
    at shadow.js.jsRequire (js.js:63)
    at Object.shadow$provide.module$node_modules$react_redux$lib$components$Provider (Provider.js:15)
    at shadow.js.jsRequire (js.js:63)
    at Object.shadow$provide.module$node_modules$react_redux$lib$index (index.js:8)
    at shadow.js.jsRequire (js.js:63)
    at Object.shadow$provide.module$node_modules$react_beautiful_dnd$dist$react_beautiful_dnd_cjs (react-beautiful-dnd.cjs.js:14)
    at Object.shadow.js.jsRequire (js.js:63)
    at Object.shadow.js.require (js.js:97)
    at eval (/js/cljs-runtime/nosco.views.page_list.js:8)
#2019-10-3010:02thhellerplease ignore all "failed to load" errors#2019-10-3010:03thhellerwell .. are there any others I mean?#2019-10-3010:03orestisThat's the whole console log#2019-10-3010:04orestisNot sure if there's a better way to paste it...#2019-10-3010:05thhellerok failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function that seems to be the actual error#2019-10-3010:05thhellernow .. to diagnose this further. please shutdown shadow-cljs completely#2019-10-3010:05thhellerDO NOT DELETE ANYTHING!#2019-10-3010:05thhellerjust kill shadow-cljs#2019-10-3010:06thhellerthen start the watch again and please verify that it does NOT say connected to server on startup#2019-10-3010:06thhellerthat it is indeed restarting#2019-10-3010:06orestisDone. BTW the offending file looks like so:
shadow$provide["module$node_modules$react_redux$lib$components$Context"] = function(global,require,module,exports) {
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports["default"] = exports.ReactReduxContext = void 0;

var _react = _interopRequireDefault(require("react"));

var ReactReduxContext = _react["default"].createContext(null);

exports.ReactReduxContext = ReactReduxContext;
var _default = ReactReduxContext;
exports["default"] = _default;
};
#2019-10-3010:06thhellerlooks exactly like it should#2019-10-3010:06thhellerwell not exactly but close enough#2019-10-3010:07orestisNo other shadow running, verified by jcmd, here's the new startup log
shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn  cli version: 2.8.55  node: v12.9.0
shadow-cljs - starting via "clojure"
INFO  [main] org.xnio  - XNIO version 3.7.3.Final
INFO  [main] org.xnio.nio  - XNIO NIO Implementation Version 3.7.3.Final
INFO  [main] org.jboss.threads  - JBoss Threads version 2.3.2.Final
shadow-cljs - server version: 2.8.53 running at 
shadow-cljs - nREPL server started on port 61137
#2019-10-3010:07thhellerok and the compile finished with "Build completed"?#2019-10-3010:08orestis
[:main] Build completed. (852 files, 851 compiled, 0 warnings, 31,49s)
#2019-10-3010:08thhellerwhat the heck? why did it compile so many files?#2019-10-3010:08orestisAnd now everything works because I was poking around before, and renamed something in .shadow-cljs/builds/main/dev/. I have the original files around.#2019-10-3010:09thheller...#2019-10-3010:09thheller😛#2019-10-3010:09orestisI was hoping to do some debugging on my own before bothering you!#2019-10-3010:09thhelleryou are not bothering me when reporting bugs/problems#2019-10-3010:09thhellerI WANT to hear about them .. otherwise they never get fixed#2019-10-3010:10thhellerif people resort to the standard lein clean practice before compiling ... just because ... I'll consider this project failed.#2019-10-3010:10thhellerthat is simply not acceptable to me 😛#2019-10-3010:11thhellerunfortunately the cache files alone don't help much in debugging#2019-10-3010:11thhellerbut yeah the thing to look out for if you change depdendencies#2019-10-3010:12orestisOK, just by killing the server and restarting shadow, I have the same problem.#2019-10-3010:12orestisNo new files, no new dependencies.#2019-10-3010:12thhelleris that you actually restarted and there is no second shadow-cljs instance running#2019-10-3010:12thhellergood!#2019-10-3010:12thhellernow it is in the broken state? what was the last "Build completed"?#2019-10-3010:12orestisThis time, [:main] Build completed. (851 files, 1 compiled, 0 warnings, 5,92s)#2019-10-3010:12thhellergood#2019-10-3010:13orestisBroken state, browser console.log is like the one I pasted#2019-10-3010:13thhellernow please make sure you have the browser cache completely cleared?#2019-10-3010:13thhellerI assume there is no Service Worker running?#2019-10-3010:13orestisYep, browser cache is disabled, serving files with Cache-Control: private, no-cache, no-store#2019-10-3010:13orestisNo service worker or fancy stuff#2019-10-3010:14thhellerok. do you use multiple :modules or just one?#2019-10-3010:15orestisSingle module.#2019-10-3010:15thhellerso you have a rather large .js file that is loaded I presume?#2019-10-3010:15orestis
{:target :browser
         :output-dir "dev-resources/public/main/js"
         :asset-path "/js"
         :modules {:main {:entries [nosco.views.main]}}
         :compiler-options {:infer-externs :auto}
         :devtools {:watch-dir "dev-resources/public/main"
                    :loader-mode :eval}
         :release {:output-dir "gamma-dist/main/js"
                   :closure-defines {nosco.routes/WORMHOLE-EXIT true
                                     nosco.controllers/ALL-FEATURE-FLAGS-ENABLED false}
                   :module-hash-names true
                   :cache-blockers #{gamma.translate}
                   :build-hooks [(gamma.translate/write-pot-file "translations/gamma.pot")
                                 (gamma.translate/clear-messages)]
                   :build-options {:manifest-name "manifest.json"}}}
#2019-10-3010:15orestisThat's the build conf, single large .js file, deps.edn for dependencies.#2019-10-3010:16thhellerok then check the dev-resources/public/main/js/main.js file#2019-10-3010:17orestis11MB. I can share if it helps?#2019-10-3010:17thhellerthat'd be good yes#2019-10-3010:17thheller<mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2019-10-3010:17thhellerok one thing that I would suggest#2019-10-3010:18thhellerit looks like you have a top level function call directly in your nosco.views.main?#2019-10-3010:18thheller(start)?#2019-10-3010:21orestisNo, that's called by index.html:
<script src="/js/main.js"></script>
    <script>
      nosco.views.main.start(document.getElementById("main"))
    </script>
#2019-10-3010:22orestisThe code for that is
(defn ^:export start [el]
  (reset! EL el)
  (add-watch nosco.controllers/app-state :main-render
             (fn [_ _ _ s]
               (js/console.log "new state is " s)
               (let [{:keys [user siteConfiguration]} s]
                 (when (and user siteConfiguration)
                   (js/console.log "initial render")
                   (react-dom/render
                    (hx/f [Main])
                    el)))))
  (routes/start-routing!))
#2019-10-3010:22thhellercan you take out the start call for a second?#2019-10-3010:23thhellerjust to remove some errors#2019-10-3010:24thhellerwhat does nosco.views.page_list do?#2019-10-3010:24thhellerseems like it does some code on load?
#2019-10-3010:24orestis#2019-10-3010:25orestis
(ns nosco.views.page-list
  (:require
   [hx.react :as hx :refer [defnc]]
   [hx.hooks :refer [useState useContext]]
   [nosco.ui.table :as table]
   [nosco.ui.components :as components]
   [cljs-bean.core :refer [bean ->clj ->js]]

   ["react-beautiful-dnd" :refer [DragDropContext Droppable Draggable]]))


(def initial-items
  (mapv #(hash-map :order % :id (str "oid-" %) :title (str "Item " %)) (range 10)))
#2019-10-3010:25orestisApart from a defining a bunch of components, that's the only "work" it does.#2019-10-3010:54thheller@orestis I found something suspicious#2019-10-3010:55thhellerSHADOW_ENV.evalLoad("module$node_modules$React$index.js"#2019-10-3010:55thhellerSHADOW_ENV.evalLoad("module$node_modules$react$index.js"#2019-10-3010:55thhellerI guess that can be considered a bug#2019-10-3010:55thhelleryou are including 2 versions of react on the page#2019-10-3010:56thhellerdo you have a (:require ["React" ...] somewhere in your code or is that caused by some library?#2019-10-3010:58orestisI’ll check! Thanks for the detective work.#2019-10-3011:02thhellernosco.controllers seems to be it#2019-10-3011:03orestisYup, that's it.#2019-10-3011:03orestis ["React" :as React] -- in all other files, there is ["react" :as React]#2019-10-3011:04thhellerI have no clue why that would break stuff but it is one suspicious thing I found#2019-10-3011:04orestisI'm on macOS which I is case insensitive, so the filename resolves to the correct file I guess.#2019-10-3011:05orestisHow should I debug this now? Changing the import and relying on hot reload threw an error.#2019-10-3011:06thhellerwell that'll require a full page reload#2019-10-3011:06thhellerit is in a state that can't be hot-reloaded otherwise#2019-10-3011:06thhellernot sure this is the cause of your issues ...#2019-10-3011:06thhellerjust looked weird when looking through the code#2019-10-3011:06orestisStill the same error. Would force compile help?#2019-10-3011:07thhellerwhat error?#2019-10-3011:07orestisThere might be a chance that with all other react libraries, something else might be doing the same thing, but I think that various CI tools would catch it.#2019-10-3011:08orestisSame errors in browser console.#2019-10-3011:08orestisShould I restart something?#2019-10-3011:11thhellerhmm maybe try wiping the cache#2019-10-3011:11thhellerI think this might be the cause of all sorts of weird issues#2019-10-3011:11orestisSo that would be .shadow-cljs/builds/main? Is that the "root" cache?#2019-10-3011:11thhelleryes#2019-10-3011:13thhellerI think this might be the actual cause of your problems .. let me know if it happens again#2019-10-3011:13orestisAnd should it be done while shadow is running? Or should I stop shadow, wipe the cache, start again?#2019-10-3011:13thhellerstopping the build would be enough#2019-10-3011:15thhellerok I think I found the bug causing this ... something I've been meaning to address for a while#2019-10-3011:15thhellerbut yeah it should be fixed in you stick to "react" only#2019-10-3011:15orestisThings are working again (but they always work if I blow away the cache). I'll start over again and see what happens.#2019-10-3011:17orestisWorks! Many thanks for helping here. Final question, is calling the start function from HTML discouraged?#2019-10-3011:26thhellerno that is fine. from the stacktraces it just looked like things were going wrong while loading because of the start call#2019-10-3011:27thhellerbut they weren't ...#2019-10-3011:28orestisCool. I've just noticed your Github sponsor page is online, so... 😄#2019-10-3011:29thhellerthanks 🙂#2019-10-3011:30thhellerstill trying to figure out how your bug actually happens ... seems like it should either always happen or never#2019-10-3011:30thhellernot quite sure why it breaks after a restart#2019-10-3011:32thhellerbut I added an additional check that should make the error easier to find 😛#2019-10-3011:37orestisHappy to help if I can.#2019-10-3014:51orestis@thheller I think case-(in)sensitivity is a major theme in my codebase 😄. Just found a case where importing date-fns/parseIso (wrong) vs date-fns/parseISO (correct) was breaking. The funny thing is that: (:require ["date-fns/parseIso" :as parseIso]) was returning something (an empty js object), which then broke downstreams consumers.#2019-10-3015:10thheller@orestis that problem should be fixed in master#2019-10-3015:32orestisSuper!#2019-10-3015:33khellangDoes anyone have a quick example on how to generate a basic index.html using manifest.edn?#2019-10-3015:36thhellerI added something basic recently that does that#2019-10-3015:36thhellerwell it doesn't generate html, but it can update html 😛#2019-10-3015:36Derekhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/html.clj#2019-10-3015:36thhellerbasically you create and basic html file you want#2019-10-3015:36thhellerlike this one https://github.com/thheller/shadow-cljs/blob/master/out/demo-browser/index.src.html#2019-10-3015:37thhellerand in your build config
:build-hooks
   [(shadow.html/copy-file
      "out/demo-browser/index.src.html"
      "out/demo-browser/public/index.html")]
#2019-10-3015:37thhellerbasically that'll replace the <script src="/js/base.js" defer></script> with <script src="/js/base.<hash>.js" defer></script>#2019-10-3015:39thhellergenerating the HTML is also very easy if you use something like hiccup#2019-10-3015:42khellanghmm#2019-10-3015:42khellangcan I use shadow.html directly in shadow-cljs.edn?#2019-10-3015:42khellang> Could not locate shadow/html__init.class, shadow/html.clj or shadow/html.cljc on classpath.#2019-10-3015:43thhellerit is rather new so you probably need to bump versions#2019-10-3015:51khellangbumped version, this time it ran, but I don't see the file#2019-10-3015:52khellangI see the build should've logged something if the source path was wrong#2019-10-3015:58thhellermaybe the warning is only visible if you run with --verbose#2019-10-3016:02khellangah, {:type :shadow.html/source-does-not-exist, :source "public/js/index.src.html", :shadow.build.log/level :info}#2019-10-3016:03thhellerit should probably just throw instead 😛#2019-10-3016:03khellangbut the file is there 🤔#2019-10-3016:03khellangoh ffs#2019-10-3016:03khellang:man-facepalming:#2019-10-3016:03thhellerthis needs to be an actual file, not a classpath resource 😛#2019-10-3016:04khellangit's not in the js folder 😂#2019-10-3016:04thhellerhehe#2019-10-3016:04khellangjeez#2019-10-3016:05khellangI think it's time to go home... thanks so much for shadow-cljs and your help 🙂#2019-10-3016:05khellangit worked now#2019-10-3018:50Pavel KlavíkHi, I am trying to call a constructor for JS object from npm as follows:
(:require ["bezier-js" :as bezier])
(bezier/Bezier. x1 y1 x2 y2 x3 y3)
The object is from this library: https://pomax.github.io/bezierjs/#constructor. I am getting this error:
TypeError: module$node_modules$bezier_js$index.Bezier is not a constructor
    at orgpad$client$util$geom_link$create_quadratic_bezier_from_control_point (orgpad/client/util/geom_link.cljs:39:9)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js), <anonymous>:1:73)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:16)
    at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:838:44)
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:145:108)
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:836:46)
    at shadow$cljs$devtools$client$browser$handle_message (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:921:37)
    at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:294:151)
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:273:90)
#2019-10-3018:54Pavel KlavíkI can access functions from that module, i.e.,
(.quadraticFromPoints bezier ...)
#2019-10-3018:54lilactown@pavel.klavik unfortunately, how to import foreign JS can often vary depending on how the JS is packaged#2019-10-3018:55sogaiuis there a way to use new in this situation?#2019-10-3018:55lilactownyou should (js/console.log bezier) to see what the exported object is#2019-10-3018:56lilactownbased on their docs, I would expect that you would use the bezier as the constructor but it’s hard to know for sure#2019-10-3018:56thheller@pavel.klavik pretty good chance it should be (bezier. x1 y1 x2 y2 x3 y3)#2019-10-3018:57Pavel Klavíkcool, it works#2019-10-3018:57thhellervar Bezier = require('bezier-js')#2019-10-3018:57thhellertranslates to the above#2019-10-3021:47kennyI'm trying to use https://github.com/Pikaday/Pikaday. shadow-cljs fails the build with
The required JS dependency "moment" is not available, it was required by "node_modules/pikaday/pikaday.js".
However, the GitHub library page says "No dependencies (but plays well with Moment.js)". Why does shadow think it needs it?
#2019-10-3021:51kennyIs there a way to tell shadow that I actually don't need a dependency? The error message seems to hint that shadow isn't sure: "You probably need to run:"
You probably need to run:
  npm install moment
#2019-10-3021:51thhellertry :js-options {:resolve {"moment" false}} in your build config#2019-10-3021:52thhellerthere is no "standard" for optional dependencies#2019-10-3021:52thhellerso shadow-cljs can't tell#2019-10-3021:53kennyOh gotcha. That'd be useful to have here: https://shadow-cljs.github.io/docs/UsersGuide.html#_missing_js_dependency.#2019-10-3021:53kennyThat does fix it btw.#2019-10-3021:54thhellerthis pattern is rather uncommon#2019-10-3021:55kennySure. Still seems useful. Pretty widely known lib - 6.8k stars.#2019-10-3021:55thhellerhttps://github.com/Pikaday/Pikaday#commonjs-module-support#2019-10-3021:56thhellerthe library seems rather old given that it uses browserify as an example#2019-10-3104:00mattlyI'm trying to use the new shadow-inspect feature and getting this:#2019-10-3104:01mattly#2019-10-3104:07mattlythat was from preloads, if I just require it in my root namespace, I get The required namespace "shadow.remote.runtime.browser" is not available, it was required by "xxxxx/main.cljs".#2019-10-3104:21mattlyand from the repl:#2019-10-3104:22mattly#2019-10-3107:21thheller@mattly that is all still undergoing massive changes. the namespace was moved to shadow.remote.runtime.cljs.browser#2019-10-3108:08thheller@mattly also note the shadow-cljs - server version: 2.8.52. so you are still an old version. need to update deps.edn when using that#2019-10-3114:30mattlyHuh, I didn’t realize shadow-cljs.server didn’t get updated along with the cli, it’s not in my does#2019-10-3112:51heefoo@thheller does shadow-cljs work with Conjure ?#2019-10-3112:52thhellerno clue, I use Cursive#2019-10-3112:52heefooI am trying to connect to the socket repl without any luck#2019-10-3112:53OlicalI'm going to try and get it working over lunch, I just need to know how to swap from the Clojure context into the ClojureScript one from within the prepl socket.#2019-10-3112:55thhelleryou can't switch it in prepl. prepl doesn't allow that. thats why I added this? https://github.com/thheller/shadow-cljs/issues/508#issuecomment-535866881#2019-10-3112:58OlicalSure, sorry, I think I worded that really poorly. I was under the impression when you connect to that prepl it isn't a ClojureScript environment but that was 2nd hand information, I'll try it for myself.#2019-10-3112:59OlicalThank you for adding prepl support in the first place! I'll try to get Conjure + shadow-cljs prepl documented somewhere, I just have 0 / negative free time right now.#2019-10-3113:01heefooFrom what i understand they should be able to work out of the box, yet i get Error from :frontend java.io.IOException: Stream closed#2019-10-3113:02OlicalAh, interesting, let me have a go. If I get it working I'll add a link / guide here https://github.com/Olical/conjure/wiki#2019-10-3113:02OlicalGimmie 20 minutes#2019-10-3113:03heefoo🙂 thanks, the stream closed error is pretty generic, i wasnt sure if it is helpfull#2019-10-3113:04OlicalThat just means the socket is kicking you off just after you connect which could be because node / your browser isn't running / ready to evaluate JavaScript on the behalf of shadow-cljs... I think...#2019-10-3113:04OlicalBuilding a demo repo#2019-10-3113:04OlicalWhile I eat katsu curry 😅#2019-10-3113:05thhellerI can change it so it doesn't kick you off but instead waits for a runtime? if that makes sense#2019-10-3113:06thhellerit sends out {:tag :err :msg "No available JS runtimes!"} currently before kicking#2019-10-3113:06OlicalHmm that could be pretty neat 🤔 might help in scenarios where you refresh the browser or something? Would it be able to hook you up to the new environment?#2019-10-3113:06OlicalIf not, no worries. With Conjure you just hit one key combo and it'll reconnect whatever it can anyway.#2019-10-3113:07Olical(`<localleader>cu` or :ConjureUp)#2019-10-3113:07thheller> Ah I understand what you mean now, thanks for the explanation! I would argue you go for the first environment and maybe disconnect the prepl if there's nothing there, that way the client will know it's reconnecting to a new environment.#2019-10-3113:07thhelleryour words 😛#2019-10-3113:07Olicallol, sounds good then, thanks past me!#2019-10-3113:08heefoo@U38J3881W with (`<localleader>cu` or :ConjureUp) i get disconnected immediately#2019-10-3113:09OlicalYep, trying to repro and investigate now, I've been putting off investigating for a while.#2019-10-3113:19OlicalHmm, sorry to bother you @thheller, I'm just trying to netcat into a prepl I started, I'm using npx shadow-cljs node-repl with what I think is some super basic config
{:builds
 {:demo
  {:target :node-script
   :modules {:main {:init-fn conjure-demo.main/init}}}}
 :prepl {:demo 36751}}
It starts up okay but I get the no runtimes error. If you think I'm just configuring / starting it wrong I'll go dig through docs now. If you think this looks okay then maaaaybe something is wrong?
#2019-10-3113:20Olical(not even using Conjure right now, just trying to netcat into the port)#2019-10-3113:20thhelleryou used node-repl. that isn't related to :demo in any way#2019-10-3113:20Olical🙃 I'm a shadow-cljs noob and I should've really learned earlier. I'll dig the docs.#2019-10-3113:20thheller:prepl {:node-repl 36751}#2019-10-3113:20OlicalThanks!#2019-10-3113:21thhellerthat should do it#2019-10-3113:21OlicalOh so node-repl is like a built in "build"#2019-10-3113:21thhelleryes#2019-10-3113:21OlicalThat's cool#2019-10-3113:22OlicalBut I guess I could watch demo or something too.#2019-10-3113:24OlicalHmm, no output from the netcat but a big ol' blob of EDN in the shadow-cljs stdio#2019-10-3113:24Olical[:repl-unknown {:type :repl/session-start, :id "67bcbfa5-55...#2019-10-3113:25thhellertry browser-repl .. I think node-repl is missing some things#2019-10-3113:25OlicalAh, interesting!#2019-10-3113:27heefooI am trying browser-repl the last 10 minutes and getting stacktraces#2019-10-3113:29heefoo` [:app] Build completed. (405 files, 1 compiled, 0 warnings, 6.62s) 32 Exception in thread "Clojure Connection repl 1" clojure.lang.ExceptionInfo: failed compiling file:out/clojure/browser/event.cljs {:file #object[java.io.File 0x72769185 "out/clojure/browser/event.cljs"], :cloj 33 ure.error/phase :compilation} `#2019-10-3113:29OlicalI might know what that is and might be able to patch it in shadow for you, hang on.#2019-10-3113:29thheller
$ nc localhost 12345
(js/console.log "foo")
{:tag :ret :ns cljs.user :form "(js/console.log \"foo\")" :ms 1 :val nil}
#2019-10-3113:30OlicalYeah, so :val is coming back as data, it needs to be a string.#2019-10-3113:30OlicalThat's the Clojure contract and I think something I patched in ClojureScript.#2019-10-3113:31OlicalIt needs to be a string because you can't parse some things that came from another environment, such as records and reader conditionals. So you can pr-str it in the eval environment but then you need to turn it into a string to make sure the prepl data is parseable in ANY environment. Then the prepl client can decide to keep treating the response as just a string or it can try to parse it in whatever way it deems correct.#2019-10-3113:31thhelleroh right#2019-10-3113:32OlicalSo yeah, don't provide data as data in a prepl payload from an env because the string serialisation doesn't always match up on the other end.#2019-10-3113:32thhelleri'll fix that#2019-10-3113:32OlicalI can patch it if you don't have time but yeah, small nuance that I know of. I should really write up a "prepl spec" that I've inferred since it isn't documented.#2019-10-3113:32OlicalI've been patching Clojure and ClojureScript to bring both of their prepl implementations inline with each other 😬#2019-10-3113:34Olicalhttps://github.com/Olical/conjure-shadow-cljs-example demo repo is here for when it returns strings 😄#2019-10-3113:37OlicalOh the other thing to check: When an exception is caught it should return the data in :val as a string (output of Throwable->map I think?) then set :exception to true on the top level of the message.#2019-10-3113:38OlicalI have a patch going into the next ClojureScript version which sets this :exception flag.#2019-10-3113:38OlicalAnd one into the next Clojure version which allows reader conditionals (ClojureScript already has them).#2019-10-3113:49heefooshould i open an issue somewhere ?#2019-10-3113:50heefoojust to keep track when/if the problem has ben solved ?#2019-11-0413:22Olicalhttps://oli.me.uk/clojure-prepl-for-tool-authors/ for future reference, I've written up how prepls should respond / work#2019-10-3112:55thhellermeaning each build gets its own prepl port#2019-10-3116:38bcaccinoloHi, how can I require a package with shadow-cljs ? Like this fs = require('fs');#2019-10-3116:39thheller(ns (:require ["fs" :as fs]))#2019-10-3116:40thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2019-10-3116:40bcaccinolothanks ! 🙂#2019-10-3117:18mazinHave a question about node_module resolution https://github.com/thheller/shadow-cljs/issues/547 as a concrete example, im currently using the package react-bootstrap. when building with the :browser target, the build fails because react-bootstrap has the dependency @restart/hooks, which we dont find since we arent traversing child node_modules directories. what is the correct way to handle this? do i install @restart/hooks in the parent node_modules directory? if so, are upgrades of sub dependencies like @restart/hooks expected to be handled manually?#2019-10-3119:38Filipe Silvahttps://github.com/thheller/shadow-cljs/issues/547 kinda surprises me#2019-10-3119:39Filipe Silvapackage manager hoisting (pulling nested packages to the toplevel) is considered an implementation detail#2019-10-3119:39Filipe Silvadifferent package managers handle hoisting differently#2019-10-3119:39Filipe Silvasome don't hoist at all#2019-10-3119:41Filipe SilvaI think I've seen cases with yarn where the resolution for a conflict was to hoist neither#2019-10-3120:59thheller@mazin you install @restart/hooks in the same package.json where you installed react-bootstrap#2019-10-3120:59thhellerbasically you manually resolve the conflict. that saves you from including the same package twice. thats the whole reason it doesn't look into nested folders#2019-10-3121:57mazinok thanks, that makes sense. what's the reason for avoiding looking into nested folders for packages that only appear once in the entire project, nested or otherwise? if the main motivation is to avoid including duplicate packages, seems ok to recurse nested folders and include packages that are only found once#2019-10-3121:58thhellernever heard of a case where something is installed nested without conflicts?#2019-10-3122:03mazinnevermind, believe i misunderstood. thanks!#2019-11-0117:30p-himikI started writing this post as a question but it ended up as just a rant about JS and an appreciation for shadow-cljs. 🙂 I was trying to help a friend that uses TypeScript with a plotting library that I use in CLJS called BokehJS. Since I don't include BokehJS in my build at all (I just put some CDN links into <script>s and use the created global object), I have never had any problems with it. The thing is, BokehJS relies on another library called FlatBush and requires it like this: - TS: import FlatBush = require("flatbush") - Distributed JS: var FlatBush = require("flatbush") - Compiled JS: var FlatBush = __webpack_require__(/*! flatbush */ "./node_modules/flatbush/index.js"); - Compiled JS in CDN: var FlatBush = require(394) On the other hand, FlatBush uses: - Source JS: export default class Flatbush - Distributed JS: a bunch of boilerplate that tries to use module.exports, define, and just global - Compiled JS: __webpack_require__.d(__webpack_exports__, "default", function() { return Flatbush; }); - Distributed JS in BokehJS CDN: same boilerplate as in just distributed JS. Because of this difference, it's easy to use BokehJS as a CDN library but not that easy when you want to have it in your build. Namely, it results in TypeError: FlatBush is not a constructor because __webpack_require__(/*! flatbush */ "./node_modules/flatbush/index.js") returns the whole module, which is an object with a field default. We spent a few hours on this. Apparently, one must use a Babel plugin called add-module-exports in such situations, but it also proves to be not an easy task for all sorts of reasons. Finally, I decided to give it a go in shadow-cljs, expecting to come up with a few new questions. And it... just worked? Heh. Awesome, thank you! BTW would it work in vanilla CLJS, without shadow-cljs?#2019-11-0119:26Filipe Silvavanilla js doesn't have a module loader#2019-11-0119:27Filipe Silvathis kinda boils down to different handling of commonjs/import interop, especially in the case of namespace imports#2019-11-0119:28Filipe Silvahttps://2ality.com/2019/04/nodejs-esm-impl.html#interoperability might give some insight on this problem in general#2019-11-0118:50coder46334Hi! When I try to evaluate a file with calva or cider, I get an error like this#2019-11-0118:50coder46334
Evaluating file: nodemap2.cljs
symbol re-frame2.items.nodemap2 already provided by [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], conflict with [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]
{:provide re-frame2.items.nodemap2, :conflict [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], :resource-id [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]}
ExceptionInfo: symbol re-frame2.items.nodemap2 already provided by [:shadow.cljs.repl/resource "re_frame2/items/nodemap2.cljs"], conflict with [:shadow.build.classpath/resource "re_frame2/items/nodemap2.cljs"]
	shadow.build.data/add-provide (data.clj:91)
#2019-11-0118:50coder46334I couldn't find anything on google, any hints?#2019-11-0119:48thheller@p-himik I don't quite follow what you described? just including a bunch of stuff via <script> tags will work with vanilla CLJS yes?#2019-11-0121:50p-himikI meant that including a fully-fledged NPM module has worked with shadow-cljs, despite that a plain JS+Webpack project has some serious issues with, if I understand correctly, combining CommonJS and ES6 modules. Would the same work with vanilla CLJS?#2019-11-0121:52thhellervanilla CLJS doens't support npm at all#2019-11-0121:53p-himikHuh? https://clojurescript.org/guides/javascript-modules#2019-11-0121:58thhellerthat is generating output that only runs in node#2019-11-0121:59thheller(it doesn't actually process anything from npm)#2019-11-0122:08p-himikOh, I see. Thanks!#2019-11-0122:09thheller:npm-deps tries to but is basically never works#2019-11-0119:49thheller@publicz hmm that looks like the namespace was first defined in the REPL and than loaded via the filesystem. I thought I fixed that a while ago though? are you an on older version maybe?#2019-11-0120:48Nolandoes anyone have any recommendations on externs debugging? ive worked through a few in the past, and generate-extern/the webclient always seem to more or less do the trick, but ive encountered a new one that seems like it should be straightforward, but is failing spectacularly. whats strange to me is that its failing at b.createReactClass. reagent/react was obviously working just fine prior to adding the new library (which is ES6, no less!), so its throwing me off that it seems like that would be any problem. for some detail:
;; imports look like:
(ns some.ns
  (:require ,,,
    ["gsap/TextPlugin" :refer [TextPlugin]] ;; these are coming from npm/node_modules
    ["gsap" :refer [gsap]]))

;; auto-generated externs look like:
var gsap = {
    // ... long, seemingly correct list
}

;; node_modules/gsap/dist/gsap.js module looks like:
// ...
exports.default = gsap;
exports.gsap = gsap;

Object.defineProperty(exports, '__esModule', { value: true });
let me know if anything pops out.
#2019-11-0120:49Nolani suppose im looking for a model of how to interpret the output of :infer-externs#2019-11-0120:52thheller@nolan what output/error do you get?#2019-11-0120:54thhellerto debug externs related things you pretty much don't need to look at node_modules code at all#2019-11-0120:56Nolanlet me get the exact error. its basically b is nil where b is some munged name, and then when i click into the error, the line that triggers the error (at least says firefox) is a call to b.createReactClass#2019-11-0120:56thhellerno I meant the :infer-externs output#2019-11-0120:57thhellernot the runtime error#2019-11-0120:57thhellerthe runtime error you can sort of figure out by compiling with shadow-cljs release app --pseudo-names#2019-11-0120:58Nolanah, well, with :all there are ~245 of them (as you warn in the manual 😂), but let me get that instead#2019-11-0120:59thhelleryeah don't use :all#2019-11-0121:02Nolanso here is the (single) output of :infer-externs :auto:
------ WARNING #1 - :infer-warning ---------------------------------------------
 File: /Users/nolan/dev/nuid/site/src/nuid/site/routes.cljs:59:16
--------------------------------------------------------------------------------
  56 |                     js/location.search
  57 |                     js/location.hash)]
  58 |          (js/ga "send" "pageview" #js {"page" p}))
  59 |        (route! (.-token event))))
----------------------^---------------------------------------------------------
 Cannot infer target type in expression (. event -token)
--------------------------------------------------------------------------------
  60 |     (.setEnabled true)))
  61 | 
--------------------------------------------------------------------------------
which i suppose is relatively straightforward, but whats interesting is that that code has been the same for a long time and hasnt caused release issues in the past
#2019-11-0121:02Nolanim hoping its not as simple as hinting that expr…ill feel very stupid#2019-11-0121:03thhellerwarnings will warn you about situations cannot figure out if externs are needed or not#2019-11-0121:03thhellerin this case event looks to be from goog.History or so. which means no externs are needed, but the compiler can't tell#2019-11-0121:04thhellerthis likely has nothing to do with your issue#2019-11-0121:04Nolanright. it would make sense that this wouldnt be the cause#2019-11-0121:04Nolanthats good to hear, at least#2019-11-0121:06thhellershadow-cljs release app --pseudo-names will likely help more#2019-11-0121:08Nolanalright ill look into that#2019-11-0121:08Nolanthanks @thheller!!#2019-11-0121:12Nolanalright, so ive got that output—its kind of a monster but its definitely readable.#2019-11-0121:13Nolanlooking through to see if anything particularly “identifying” pops out, so far it looks like a lot of react/reagent calls#2019-11-0121:13Nolanfunction $reagent$impl$template$vec_to_elem$$ is the top-level function that fails#2019-11-0121:13thhellerthe error alone should contain all the info you need#2019-11-0121:13Nolan
TypeError: "$JSCompiler_temp$jscomp$1970_JSCompiler_temp$jscomp$2730_JSCompiler_temp_const$jscomp$1971_c$jscomp$inline_1109_comp$jscomp$12_f$jscomp$inline_2750_jsprops$jscomp$inline_1100_n$jscomp$186_props$jscomp$inline_1098_tag$jscomp$18_temp__5737__auto__$jscomp$inline_1105$$ is undefined"
is what im seeing
#2019-11-0121:14thhellerwhaaaaaaaaat the heck is that? 😛#2019-11-0121:14thhellernever seen that name before 😛#2019-11-0121:14Nolanid doubt it, but ill try to see if chrome shows anything more interesting#2019-11-0121:14thhellerI've never seen it generate such a long name#2019-11-0121:15thhellerso undefined errors always point to something being undefined BEFORE#2019-11-0121:15Nolanim starting to get a feeling it has to do with something perf related that gsap is doing. its pretty hsyterical how different the package size is with and without pseudo-names#2019-11-0121:15Nolanall the more incentive to root this out!#2019-11-0121:16thhellerpseudo-names is only for debugging 🙂#2019-11-0121:16thhelleropen the source and look for that variable name maybe. should be easy to find 😛#2019-11-0121:17thhelleris this a browser build?#2019-11-0121:17Nolanno doubt 😄. ill take a look. and yeah, this is a browser build#2019-11-0121:18Nolannot much interesting use of compiler options, either—just :externs and :infer-externs:
:compiler-options {:externs ["externs/isotope.ext.js"
                             "externs/gsap.ext.js"
                             "externs/gsap.textplugin.ext.js"
                             "externs/gsap.easepack.ext.js"]
                  :infer-externs :auto}
#2019-11-0121:19thhellerjust remove all of them#2019-11-0121:19thhellerdo not ever use :auto. it'll just confuse you more than actually help.#2019-11-0121:20Nolanoh, ok#2019-11-0121:20Nolannice#2019-11-0121:20thhellerdon't ever use generated externs#2019-11-0121:20thhellerthats mostly just noise that doesn't actually help anything#2019-11-0121:20Nolanthis is golden information#2019-11-0121:21Nolanive just sort of thrown together what seems to have a shot at working, and ship once it does#2019-11-0121:21Nolansolid procedure 😂#2019-11-0121:21thheller:infer-externs :auto and work through them#2019-11-0121:22thhellerthe token error you can fix by adding (.-token ^goog event) or (.-token ^js event)#2019-11-0121:22thhellerdoesn't matter really#2019-11-0121:22Nolanill recompile and check it out now that ive removed the manual externs#2019-11-0121:25Nolanso without the manaul externs, release warns about the first lib (`isotope`) that i think will get rid of the need for that first manual extern entry. but doesnt seem to find any problems with the rest. let me see what the error looks like now#2019-11-0121:25thhellerin general you only need externs for the stuff you actually use#2019-11-0121:25thhellerso the problem with generated externs is just that they generate too much#2019-11-0121:25Nolanyeah, they do#2019-11-0121:25thhellerlike hundreds or thousands even if you just need one#2019-11-0121:26Nolanand once i had an issue (back in my cljsjs days) where the generated extern was like 400k lines#2019-11-0121:26thhellerexactly#2019-11-0121:26Nolanand that isnt an exaggeration. it was just like pure nesting#2019-11-0121:26Nolanwas so brutal#2019-11-0121:30Nolan:infer-externs output is way, way cleaner. its awesome to start getting a better understanding of how to act on this#2019-11-0121:34Nolanso the error is still that opaque monster. my intuition is that something is being pulled out from under reagent/react by gsap. gsap tweens are described by JS objects, so i have quite a few #js { ,,, } in there.#2019-11-0121:36Nolanid rejoice for an immutable-all-the-way-down version of gsap. or just an implementation in cljs. im sure transients would suffice for hot paths, more or less#2019-11-0121:36Nolananyway, will let you know if i find anything interesting#2019-11-0121:36thhelleryou can also try shadow-cljs release app --debug which will give you pseudo-names + source maps#2019-11-0121:37Nolanill try that. source maps might help#2019-11-0121:38Nolanare there any pitfalls (beyond the obvious mutability) of using #js { } w.r.t. compilation and hinting? or does that play a role#2019-11-0121:38Nolannot* play a role#2019-11-0121:39thhellernot really#2019-11-0121:39thhellerif you just create them that is fine and doesn't need anything extra#2019-11-0121:39thhellerif you actually modify the objects yourself that may need externs#2019-11-0121:40thhellerbut :infer-externs will warn you about those#2019-11-0121:40thhellerso no warnings = all good#2019-11-0121:41Nolanright on. it could be that gsap internally mutates them—which would actually make some sense as an explanation for this error#2019-11-0121:42thhellerbtw make sure you have a shadow-cljs server instance running if you call shadow-cljs release repeatedly#2019-11-0121:42thhellerit'll safe you a bunch of time 😛#2019-11-0121:42Nolanthe benefits of spending time in the shadow-cljs slack are just innumerable#2019-11-0121:47Nolanso source maps help identify that it seems to have to do with a ratom, which is actually super helpful because that limits the space of where things could be going wrong pretty significantly. the bummer is that the trace doesnt even touch any of my files:
TypeError: "<that monster name> is undefined"
    $reagent$impl$template$vec_to_elem$$ component.cljs:338
    $reagent$impl$template$as_element$$ template.cljs:409
    $reagent$impl$template$make_element$$/</< template.cljs:483
    $cljs$core$IKVReduce$_kv_reduce$arity$3$ core.cljs:5649
    $cljs$core$_kv_reduce$$ core.cljs:700
    $cljs$core$reduce_kv$$ core.cljs:2562
    $reagent$impl$template$make_element$$ template.cljs:481
    $reagent$impl$template$native_element$$ template.cljs:359
    $reagent$impl$template$vec_to_elem$$ template.cljs:385
    $reagent$impl$template$as_element$$ template.cljs:409
    $reagent$impl$component$wrap_render$$ component.cljs:104
    $reagent$impl$component$static_fns$$</</< component.cljs:128
    $reagent$ratom$deref_capture$$ ratom.cljs:37
    $reagent$ratom$run_in_reaction$$ ratom.cljs:504
    $reagent$impl$component$static_fns$$< component.cljs:143
    React (12) ...
#2019-11-0121:49thhellermaybe you have something that is [undefined ...]? so not a regular [:div ...]?#2019-11-0121:50coder46334@thheller It was the version! The re-frame template used shadow-cljs 2.8.55, the .69 works. Thanks a lot!#2019-11-0121:51thheller@nolan which reagent version is this?#2019-11-0121:51Nolanhmm. i wonder if it has to do with fragments. i dont dynamically compute any [<thing> ,,,] anywhere, but i do make pretty heavy use of fragments, which could be easily changed#2019-11-0121:51Nolan0.8.1#2019-11-0121:52Nolanand "create-react-class": "^15.6.3", "react": "^16.10.2", "react-dom": "^16.10.2"#2019-11-0121:54thhellerhmm so in that version it is doing a cache lookup on a JS object#2019-11-0121:54thhellermaybe try a different version?#2019-11-0121:54Nolanoh no… hold on.#2019-11-0121:54thhellerhmm probably won't change much#2019-11-0121:55thhellerother versions also had that#2019-11-0121:55Nolani simultaneously hope and dont hope ive found it#2019-11-0121:55Nolanyour [undefined ,,,] comment got me thinking#2019-11-0121:56thhellerthe code looks to be related to props name caching#2019-11-0121:56thhellerso maybe [something {undefined "foo"} ...]?#2019-11-0121:57Nolanthats a great point, and will be the first thing i look into after i eliminate what i must admit would be the most classical of user errors#2019-11-0121:59Nolan😂 ugh. ok. i see exactly what happened here. RESOLVED!#2019-11-0121:59Nolanthere was a part of a component that i had wrapped in (when ^boolean js/goog.DEBUG ,,,) and well…#2019-11-0122:01Nolannothing like feeling dumber than a box of rocks on a friday afternoon, but the upside is that the package size is down#2019-11-0122:01Nolanthanks a million for your help @thheller, i would have gone down 1000x more rabbit holes otherwise#2019-11-0122:02Nolanand i get to get rid of these silly externs that were essentially silently doing nothing… thats the real victory#2019-11-0203:44tekacsI… assume that I shouldn’t be doing this:
:closure-defines
 {"shadow.cljs.devtools.client.env.ssl" true}
This configuration works perfectly for me. I’m doing this because whilst I have an SSL section in my shadow-cljs.edn (my dev-http at https://<hostname>:3000 works), my REPL/devtools connection was using ws://<hostname>:9630 rather than wss://<hostname>:9630. I’m reverse port forwarding onto the real host. Any chance that someone could point out the error in my config? I tried reading a bunch of places in the shadow-cljs source, but wasn’t sure how to pull off this behaviour in particular. https://gist.github.com/tekacs/95e2e78f806bc72c9695504426c930a4 Intended behaviour: - Bind to localhost:3000 over SSL for my dev-http - Bind to localhost:9630 over SSL for my main server - Visit https://<hostname>:443 for my dev-http server (due to ssh -R '*:443:localhost:3000 <hostname>` - Have the client use wss://<hostname>:9630 for devtools connections (due to another -R to that SSH)
#2019-11-0205:15jorda0megahas anyone been successful in loading a custom font through AppLoading Font.loadAsync in expo?#2019-11-0208:57thheller@tekacs there is :devtools {:devtools-url ""}, see https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2019-11-0208:58thhellerthe dev-http server is completely separate and isn't involved in the websockets setup#2019-11-0208:59thhellerI didn't know ssh could be used for https proxying#2019-11-0212:05Filipe Silvais it possible to connect a repl to a :node-test target?#2019-11-0212:06Filipe Silvathe repl needs a running process, but when I try to connect node to the output (e.g. node out/test.js) it will run the tests and exit immediately, leaving no running process for the repl to use#2019-11-0212:07Filipe Silvamy usecase is that I would like to develop tests with editor support (vscode+calva), and the tooling needs to connect a repl#2019-11-0212:14thhellerno that is not supported and also pointless
#2019-11-0212:15thhellershadow-cljs node-repl (require 'your.test-ns) (cljs.test/run-tests 'your.test-ns)#2019-11-0212:16thhellerdoesn't even need a build config#2019-11-0212:16thheller:node-test is meant to run all tests and then exit the process#2019-11-0212:17thhellera REPL would prohibit that exit#2019-11-0212:17thhellerwhich effectively turns it into just a node-repl, but you had to run the process manually#2019-11-0212:23Filipe Silvaok, I suppose that I can use the repl directly#2019-11-0212:24Filipe Silvabut that doesn't make for a very smooth development flow, at least with my current knowledge#2019-11-0212:24Filipe Silvain Calva, I would like to jack in to a certain build, and connect to that builds repl#2019-11-0212:25Filipe Silvaso I guess I want a node-script target with a main that does (cljs.test/run-tests 'your.test-ns)#2019-11-0212:25thhellerno you don't#2019-11-0212:25thhelleryou want to jack into node-repl#2019-11-0212:25thhellerotherwise you have to run the actual node process#2019-11-0212:25thhellerwhich isn't "very smooth"#2019-11-0212:26Filipe Silvaif I jack into the node-repl, I have to still do (require 'your.test-ns) (cljs.test/run-tests 'your.test-ns) right?#2019-11-0212:27thhelleryes. maybe I just don't understand what you are actually trying to do#2019-11-0212:27thhellerwith :node-test the tests run ONCE and then exit#2019-11-0212:27thhellersuppose it doesn't exit and just waits for REPL stuff#2019-11-0212:28thhellerwhat else is it supposed to do now?#2019-11-0212:28thhellerwhat exactly do you want to do at the REPL?#2019-11-0212:29Filipe SilvaI don't want to do anything specific at the repl myself, but to have tooling support in the editor I need to connect a running repl#2019-11-0212:29Filipe Silvaotherwise I don't get code completions, or repl execution, etc#2019-11-0212:29Filipe Silvathe total steps seem the same the repl way: - jack in - select the a build? (not sure if this is always needed in calva) - select node-repl - input (require 'your.test-ns) (cljs.test/run-tests 'your.test-ns) - have tooling support in vscode the node-script way: - jack in - select node-script target - select node-script target repl - run node the-output.js and leave running - have tooling support in vscode#2019-11-0212:30thhellernode-script way is missing node the-output.js#2019-11-0212:30Filipe Silvayes, you are right#2019-11-0212:30Filipe SilvaI have to do that in a console somewhere and leave it running#2019-11-0212:30Filipe Silvaadded now#2019-11-0212:30thhellerand that part you skip with node-repl#2019-11-0212:30thhellerno extra console#2019-11-0212:30thhellerno extra command#2019-11-0212:31Filipe Silvathere is one less console command, but one more command in a repl#2019-11-0212:31thhellerand it lets you run tests selectively#2019-11-0212:31thhellervs. always everything#2019-11-0212:31thhellerI run almost all my tests from the REPL#2019-11-0212:31Filipe Silvathe calva extension has some helpers for that#2019-11-0212:31Filipe Silva#2019-11-0212:32Filipe SilvaI don't know if they'll work though, because I was still setting it up and got hung on the repl bit#2019-11-0212:32thhellerembrace the REPL. it is the clojure way. 🙂#2019-11-0212:33thhellerthe calva stuff may actually be dependent on some nrepl middleware so it might not work with CLJS#2019-11-0212:33thhellernot sure what exactly it does#2019-11-0212:33thhelleryou can also just jack into node-repl and run the tests separately (if you just want completion and stuff)#2019-11-0212:34thhelleror just use Cursive which has all the tooling even without the REPL 😉#2019-11-0212:34Filipe Silvait might be the clojure way but it's also one of those things that isn't obvious and that requires you to figure out how to plug everything together in a unfamiliar way#2019-11-0212:35Filipe Silvamaybe cursive is better, but if I have to leave my day to day editor for another way, and configure that from scratch, before I can start being productive... well that's an extra overhead#2019-11-0212:35thhellerso the problem is that calva needs a REPL connection for its tooling support#2019-11-0212:35Filipe SilvaI can do all that, and it might be better. But does it mean there's no point to trying to use Calva? There must be a point#2019-11-0212:36thhellerbut you are only working on :node-test so you don't have an actual REPL?#2019-11-0212:36thheller:node-test is only meant to be supplemental to an actual other build that does stuff#2019-11-0212:36thhellerwhy not connect to that REPL?#2019-11-0212:36thhellerCalva is great, totally fine to use it#2019-11-0212:37thhellerI'm just not convinced that building all tooling on top of the REPL is the best way to go#2019-11-0212:38thhellerI'm trying to understand what workflow you are actually trying to achieve#2019-11-0212:38thheller(mine is likely very different, I barely "test" at all, I run code at the REPL)#2019-11-0212:40Filipe Silvaok, let me try and describe the workflow I was going for#2019-11-0212:40Filipe SilvaI have some tests that are meant to be ran on node#2019-11-0212:41Filipe SilvaI would like to: - open vs code - jack in use calva - get tooling in the test namespaces (completions, eval code) - use the calva commands to run tests (sometimes all of them, sometimes only some of them)#2019-11-0212:41thhellerI don't know what the calva test commands do#2019-11-0212:42thhellerdo they work over the REPL or do they run a separate process?#2019-11-0212:42Filipe Silvathat's a good question, let me try to figure it out#2019-11-0212:44thhellerok I don't like Calva anymore. It is still mostly typescript 😛#2019-11-0212:44thhellerthough it was more CLJS these days 😛#2019-11-0212:46thhellerok from the looks of it uses the REPL#2019-11-0212:46thhellerand as expected some nrepl middleware#2019-11-0212:46thhellerbut that middleware doesn't support CLJS#2019-11-0212:46thhellerso I guess you are out of luck and can't really run the tests using calva commands#2019-11-0212:47Filipe Silvaso, having this config:
{:builds
 {:test-dev
  {:main async-interop.interop-tests/main
   :output-to "out/test-dev.js"
   :target :node-script}
  :test
  {:ns-regexp "async-interop.*-tests$"
   :output-to "out/test.js"
   :target :node-test}}
 :dependencies [[org.clojure/core.async "0.4.500"]]
 :dev-http {3000 "public"}
 :nrepl {:port 3333}
 :source-paths ["src/main" "src/test"]}
and this namespace with tests
(ns async-interop.interop-tests
  (:require
   [async-interop.interop :refer [p->c]]
   [async-interop.interop :refer-macros [<p!]]
   [cljs.test :refer-macros [deftest is]]))

(deftest interop
  (is true))

(defn main [])
I jack in, select test-dev to build, select the test-dev repl connection
#2019-11-0212:47Filipe SilvaI run the Calva: run all tests command#2019-11-0212:47Filipe SilvaI get this error in the calva pane#2019-11-0212:47Filipe Silva#2019-11-0212:48Filipe Silvamaybe thats related to the middleware you just mentioned#2019-11-0212:48thhellerthat is an odd error#2019-11-0212:51Filipe Silvaif I try to use the node-repl as you mentioned, I can run the tests and get results#2019-11-0212:51Filipe Silva
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "97fcf6fafefcd7c5d2d3bacfa6d4a1"}, :content ("[email protected]")}
#2019-11-0212:52Filipe Silvabut if instead of the node-repl I connect to a cljs-repl for the target, I do not see test results#2019-11-0212:52Filipe Silva
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f19a909c989ab1a3b4b5dca9c0b2c7"}, :content ("[email protected]")}
#2019-11-0212:52thhellerI'm unsure what is causing that error above#2019-11-0212:53thhellerthat is expected. the output goes to whereever test-dev is running#2019-11-0212:53thhellerhttps://github.com/thheller/shadow-cljs/issues/373#2019-11-0212:53Filipe Silvayes that is what is happening#2019-11-0212:53Filipe Silva
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d3b8b2bebab893819697fe8be290e5"}, :content ("[email protected]")}
#2019-11-0212:57Filipe Silvahttps://github.com/BetterThanTomorrow/calva/issues/311#2019-11-0212:57Filipe SilvaI suppose that's the whole story#2019-11-0212:57Filipe Silva> This is due to that cider-nrepl doesn't yet support running cljs tests. Something that might not be fixed all that soon. clojure-emacs/cider-nrepl#555#2019-11-0212:58thhellerhttps://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/test.clj#2019-11-0212:59thhellerto me it looks like that works directly with clojure.test. so no CLJS support#2019-11-0212:59Filipe SilvaI'll add this context to the calva issue, and use the node-repl to run tests manually#2019-11-0213:00Filipe Silvais there a way to run a single test via the node-repl?#2019-11-0213:01thhellertests are callable functions#2019-11-0213:01thhellerso (deftest some-test ...) is callable as (some-test)#2019-11-0213:03thhellerI'm not a fan of cljs.test. I think it is implemented in a needlessly complex way which makes it really annoying to use#2019-11-0213:04thhellereverything is done via macros#2019-11-0213:07Filipe Silvahm.... I didn't know, that, but it opens up another approach#2019-11-0213:15thhellerlots of the problems with tooling is that most of it pretends that clojurescript is like clojure#2019-11-0213:15thhellerso it tries to treat them the same .. which they simply aren't#2019-11-0213:17Filipe SilvaI was trying this approach instead: - open vs code - jack in using calva to a node-test target, then use node-repl - got tooling in the test namespaces (completions, eval code) - then tried to run the individual test functions in the calva repl window#2019-11-0213:18Filipe Silvathat got me another odd Calva error#2019-11-0213:18Filipe Silva#2019-11-0213:19thhellerI thought I fixed that error. which verison are you on?#2019-11-0213:19Filipe Silva
$ yarn list shadow-cljs
yarn list v1.17.3
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ 
#2019-11-0213:19thhellerthat is only the npm package#2019-11-0213:20thhellerdo you use deps.edn/project.clj?#2019-11-0213:20thheller(if you do they might have a different version)#2019-11-0213:20Filipe SilvaI am using a shadow-cljs.edn
{:builds
 {:test-dev
  {:main async-interop.interop-tests/main
   :output-to "out/test-dev.js"
   :target :node-script}
  :test
  {:ns-regexp "async-interop.*-tests$"
   :output-to "out/test.js"
   :target :node-test}}
 :dependencies [[org.clojure/core.async "0.4.500"]]
 :dev-http {3000 "public"}
 :nrepl {:port 3333}
 :source-paths ["src/main" "src/test"]}
#2019-11-0213:20thhellerok#2019-11-0213:20Filipe Silvawhen shadow-cljs starts it lists these versions#2019-11-0213:20Filipe Silva
shadow-cljs - config: d:\sandbox\async-interop\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.69 running at 
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :test-dev
#2019-11-0213:20thhellerok good#2019-11-0213:22thhellerhmm yeah I thought I fixed that issue but I guess I didn't#2019-11-0213:22thhellerhappens when (ns foo.bar) is first eval'd at the REPL#2019-11-0213:22thhellerand then loaded from a file#2019-11-0213:23Filipe Silvayes I think that's what happens in my editor, because I have Calva configured to automatically load the namespace on save#2019-11-0213:23Filipe Silvaso I guess it loads the NS at the repl, then shadowcljs detects the file changed and loads from the file?#2019-11-0213:24thhellernot sure#2019-11-0213:25thhellerah right. the bug I fixed was require itself#2019-11-0213:26thhellerdidn't fix load-file#2019-11-0213:35thhellerhttps://github.com/thheller/shadow-cljs/issues/587#2019-11-0213:40Filipe Silvasubscribed to it, thank you for all of your help on this#2019-11-0213:40Filipe SilvaI'll do a write-up on the calva issue with the test I did today#2019-11-0214:44pez> ok I don’t like Calva anymore. I heard that! 😃#2019-11-0214:59pez> - jack in using calva to a node-test target, then use node-repl @filipematossilva: curious, how did you “use node-repl”?#2019-11-0215:01Filipe SilvaI used jack in, selected a target, then selected node-repl from this window#2019-11-0215:01Filipe Silva#2019-11-0215:05pezCool. That's what you're supposed to do. 😎 You can then switch between the build you started at jack-in and node-repl at will. (In case that is not made clear enough by Calva)#2019-11-0215:06Filipe SilvaI didn't know I could, I often just reloaded the vscode window... but I did notice I could do something of the sort on the buttons in the status bar, just never tried much#2019-11-0215:38pezThe command is Calva; Select CLJS Build Connection. Maybe not the best name for it… but, yeah, the status bar has a button for it as well.#2019-11-0215:39Filipe Silvaok#2019-11-0215:39Filipe SilvaI tested several approaches#2019-11-0215:39Filipe Silvaand logged the results here#2019-11-0215:39Filipe Silvahttps://github.com/filipesilva/calva-testing#2019-11-0215:39Filipe Silvathat repo can be used to test#2019-11-0215:40Filipe Silvaon calva's side, the test commands don't work on cljs: https://github.com/BetterThanTomorrow/calva/issues/311#2019-11-0215:42Filipe Silvaon shadow cljs's side two bad interactions happen with calvas repl window - the test output isn't shown for node repls (https://github.com/thheller/shadow-cljs/issues/373) - running a test build without autoron and with node-repl fails to load the namespace https://github.com/thheller/shadow-cljs/issues/587#2019-11-0215:42pezI’m painfully aware that test commands do not work for clks…#2019-11-0215:48pezFrom the calva-testing repo: > running tests by name in Calva repl shows nil return, must check separate calva output pane Not sure what the nil results are about, but you can use the Calva setting for async output routing to get Calva to show that output in the REPL window instead of the Output pane. (So at least one inconvenience less.)#2019-11-0215:49Filipe SilvaI think that's https://github.com/thheller/shadow-cljs/issues/373#2019-11-0215:49Filipe Silvabut maybe that's not the whole story#2019-11-0215:49Filipe Silvaatm the best shot seems to be running tests on a autorun node-test build to get around https://github.com/thheller/shadow-cljs/issues/587#2019-11-0215:51pezI use auto-run but stay connected to my app-build. So I start both my app build and my test build at jack-in and then connect to the app build. auto-run keeps watching the files and reruns the tests when the files change.#2019-11-0216:40Filipe Silvayeah for browser apps I do something similar#2019-11-0217:15dpsutton@thheller can you confirm that its never valid to use shadow.cljs.devtools.api/nrepl-select on browser-repl or node-repl? This is meant only for a named build?#2019-11-0217:36thheller@dpsutton that is valid for :browser-repl and :node-repl yes#2019-11-0217:37dpsuttonah so i was incorrect.#2019-11-0217:38thhellerthey need to be running though#2019-11-0217:38thhellerso maybe there should be a separate op for starting a browser-repl/node-repl but not switching to it#2019-11-0217:39thhellerbut when they are running you can select them like any other build repl#2019-11-0217:39thhellerthey are regular builds after all, just with a hardcoded config and some extras#2019-11-0217:40dpsuttonand by running there needs to be a shadow-cljs server browser-repl ?#2019-11-0217:40thhellerthats not a command#2019-11-0217:40thhellerthere needs to be a running server instance yes#2019-11-0217:40thhellershadow-cljs server#2019-11-0217:41thhellerto start a browser REPL you can run (shadow.cljs.devtools.api/browser-repl)#2019-11-0217:41thhellerthat will start it and switch#2019-11-0217:44dpsuttonbut there can only be on server running at a time?#2019-11-0217:44dpsuttonit seems that CIDER always starts a server so there's no good way for it to do this kind of stuff#2019-11-0217:45thhellerhmm?#2019-11-0217:45thhellerI thought it starts the server and connects to it? that is all you need?#2019-11-0217:48dpsuttonyeah. there's two repl types for shadow in CIDER. the normal one and then one called shadow-select which doesn't start a watch. I'm trying to figure out how the select version works and what needs to be running for that to make sense.
This kind of CLJS REPL is very helpful for cases when you are already watching
one or more shadow builds in shadow either after having launched the server in
a terminal or from within Cider.
This patch also refactors option normalization out of figwheel-main so that it
can be reused by every other function.
#2019-11-0217:49thhellerwhats the normal one?#2019-11-0217:49thhellerselect only switches the nrepl session to CLJS. it doesn't do anything regarding shadow-cljs itself. it is strictly for nrepl purposes.#2019-11-0217:50dpsutton/usr/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT server and then running (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch <build>) (shadow/nrepl-select <build>))#2019-11-0217:50dpsuttonso in this case, if you choose browser-repl, it doesn't watch and select, just shadow/browser-repl#2019-11-0217:50thhellerok that is start the watch and switch the nrepl to it (two commands)#2019-11-0217:51thhellerbrowse-repl is basically watch+select in one#2019-11-0217:51thhellerif you call browser-repl repeatedly it'll just select#2019-11-0217:52thhellercan you remove that require btw?#2019-11-0217:52thhelleror well it doesn't matter much I guess#2019-11-0217:54thhellerthe first session you connect to is a regular CLJ REPL#2019-11-0217:54thhelleris that used for anything else other than clone+select to CLJS?#2019-11-0217:56dpsuttonlet me back up and show the problem that I'm trying to solve. If you choose :browser-repl the above startup command doesn't work. So I understood that you had to not do watch and nrepl-select for the built in repls but just call shadow.cljs.devtools.api/special-repl instead#2019-11-0217:56dpsutton
npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0-SNAPSHOT clj-repl

(shadow.cljs.devtools.api/watch :browser-repl)
Execution error (ExceptionInfo) at shadow.cljs.devtools.config/get-build! (config.clj:153).
no bulid with id: :browser-repl
#2019-11-0217:56dpsuttonand this confirms that this behavior doesn't work for the built in repl types i think#2019-11-0217:57thhelleras I said ... you cannot watch the "special" builds#2019-11-0217:57thhellerso you run them via separate commands#2019-11-0217:57dpsuttonright. so i need spacial behavior for when the user uses a special repl. But you can nrepl-select the "special" builds?#2019-11-0217:58thhellerI'm confused. if you call the special REPL is will already switch#2019-11-0217:58thhellerif the use switches out of it you CAN nrepl-select it again yes#2019-11-0217:59thheller(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :browser-repl) (shadow/nrepl-select :browser-repl))#2019-11-0217:59thhellerthat is not valid and is replaced by#2019-11-0217:59thheller(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/browser-repl))#2019-11-0217:59thhellerthe end result is the same#2019-11-0217:59thhellerthe user can send :cljs/quit which will drop the session back to CLJ#2019-11-0218:00thhellerit will not actually terminate the REPL though#2019-11-0218:00thhelleryou can nrepl-select :browser-repl to get back to it#2019-11-0218:02dpsuttonawesome. thanks#2019-11-0218:03dpsuttonhmm. (shadow.cljs.devtools.api/nrepl-select :browser-repl) -> [:no-worker :browser-repl]#2019-11-0218:04thhellerdid you run (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/browser-repl)) first?#2019-11-0218:04thhellernrepl-select is ONLY for switching#2019-11-0218:05dpsuttonto an already running build?#2019-11-0218:05thhelleryes#2019-11-0218:05dpsuttongotcha. ok.#2019-11-0218:05dpsuttonthanks much#2019-11-0304:22caleb.macdonaldblackIs there anyway to set a port in shadow-cljs.edn using an environment variable?#2019-11-0304:22caleb.macdonaldblackI'm using #shadow/env "NREPL_PORT" however it's failing because it's gettting a string and expecting a number#2019-11-0304:22caleb.macdonaldblackI'm trying to set the nrepl, http-server and devtools ports with env vars#2019-11-0308:45thheller@caleb.macdonaldblack that isn't supported no. why are you trying to do that? the default is to use random ports and you looking at .shadow-cljs/nrepl.port to get the actual port#2019-11-0308:47caleb.macdonaldblackI'm trying to run two docker-compose stacks. One for testing and one for develop where they have different DBs.#2019-11-0308:48caleb.macdonaldblackI ended up running two instances of the web app as two shadow builds#2019-11-0308:48thheller?#2019-11-0308:52caleb.macdonaldblackSo I have a local test db and a local dev db. My test db can be polluted with various test data. I want my local development db not to be effected by the tests. So I need my backend running in two environment, one for dev and one for test. My front-end is compiled with the backend url baked in. So I just run two instances of my front-end with different backend urls.#2019-11-0308:52caleb.macdonaldblackI'm running everything in docker so it's executed similar to how it is in CI#2019-11-0308:53thhellerbut what does the DB have to do with shadow-cljs?#2019-11-0308:53caleb.macdonaldblackA shadow build communicates with a test backend which communicates with a tests db#2019-11-0308:54caleb.macdonaldblackand I want to run the test and develop build simultaneously#2019-11-0308:54thhellerI do not understand your setup#2019-11-0308:54caleb.macdonaldblackMy tests are UI tests so they navigate to web app and point & click#2019-11-0308:54thhellerwhat does the build have to do with which db it is talking to?#2019-11-0308:55caleb.macdonaldblackI specify the backend url (test or dev) as a environment variable. Which is picked up in shadow-cljs as a closure-define#2019-11-0308:55thhellerand that is your mistake#2019-11-0308:56thhellerdon't make it part of the build at all ... and all your problems go away#2019-11-0308:56thhellerinstead as recommended create a init fn that is called on startup#2019-11-0308:56thhellerthat function either takes an argument with config#2019-11-0308:57thhellerOR looks up some variable set before#2019-11-0308:57thheller<script>your.app.init({db: "some-url"});</script>#2019-11-0308:58thhelleror <script>var MY_CONFIG = {url: "some-url"};</script> and :init-fn and it accessing js/MY_CONFIG#2019-11-0308:58thhellerthat way you have ONE build that doesn't need to be recompiled when changing backends#2019-11-0308:58thhellerreducing the number of build variables that could cause issues#2019-11-0308:59thhellerso then the control is in the hands of the HTML#2019-11-0308:59thhellerso you can either create a index-test.html and index-dev.html#2019-11-0308:59thhelleror have your server create the different configs and emit different HTML#2019-11-0308:59thhellerenvironment variables for build config are terrible#2019-11-0309:02caleb.macdonaldblackOkay so I was aware of everything up until the index-test.html/index-dev.html. I hadn't considered that. I always thought I would have to server side render the vars in and my front-end is not served up from my back-end. This is a good solution.#2019-11-0309:12caleb.macdonaldblackThanks#2019-11-0311:07caleb.macdonaldblackI'm not sure what I'm doing wrong here. It seems that :push-state/index is ignored completely#2019-11-0311:07caleb.macdonaldblackhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-11-0311:07caleb.macdonaldblackOr maybe I'm using it wrong idk.#2019-11-0311:09caleb.macdonaldblackIt's trying to server index.html#2019-11-0311:15thhellerhmm that might not work right now#2019-11-0311:15caleb.macdonaldblackActually no it was an issue with something else. I thought it wasn't looking for the file because the error said "Not found. Missing index.html."#2019-11-0311:15caleb.macdonaldblackBut I can see that is just hard coded in#2019-11-0311:15caleb.macdonaldblackI didn't map the file correctly in docker-compose.#2019-11-0311:15thhellerah yeah right. the index.html is hardcoded#2019-11-0315:14teawaterwirei have this case where Shadow can infer type on target:browser but not on target:node-library i'm curious to understand why 🤔#2019-11-0315:14teawaterwire(browser code)#2019-11-0315:15teawaterwirenode code#2019-11-0315:15teawaterwiregiving inference warning#2019-11-0315:15thhellerfor :browser it will actually process all JS and gather externs while processing#2019-11-0315:16thhellerfor :node-library it doesn't process and JS and lets node provide it#2019-11-0315:16thhellerso it can't find the val#2019-11-0315:16thhellerI maybe should not consider gathered externs for externs inference#2019-11-0315:17thhellerso the behavior is the same on all platforms#2019-11-0315:17teawaterwireoh i see - but could we gather externs also for node?#2019-11-0315:18teawaterwire(maybe using {:infer-externs :auto} as default would be good enough to warn the developper)#2019-11-0315:20thhellerno externs gathering for node no#2019-11-0315:20thhellertechnically it could but it would just be slow#2019-11-0315:20teawaterwirebecause node libraries are too big?#2019-11-0315:20thhellerIMHO externs inference is better#2019-11-0315:21thhellerno because the externs gathering is flawed. I only added it to make externs less of hassle#2019-11-0315:21thhellerexterns inference fixes that in a better way though#2019-11-0315:23teawaterwireok got it 👍#2019-11-0319:47Aleedis it possible to use datomic with shadow-cljs?#2019-11-0319:47thhellerdatomic doesn't support CLJS? so if you mean to use it in a CLJS build then it won't work no#2019-11-0319:49Aleedoh ok that must be the issue then. i'm using a :target node-script build#2019-11-0319:50thhelleryeah datomic only runs in Clojure. no support for CLJS as far I know.#2019-11-0319:51Aleedis there a different build I can use to get it working with shadow? or I have to integrate another build tool#2019-11-0319:51thhellerit will not run in CLJS. no matter what you use to build it. it doesn't support node or any other JS#2019-11-0319:52thhelleryou can build a CLJ server that talks to datomic and talk to that from CLJS but thats about it#2019-11-0319:52thhellerI don't use datomic so I'm not sure if they offer some kind of http api or so#2019-11-0319:55eoliphant@alidcastano check out something like Pathom (and it’s datomic plugin) if you’d like a datomic’ish API for your client#2019-11-0319:56eoliphanthey @thheller, running into an issue with the auth0-spa-js lib, they have a weird layout which i suspect is the problem but, not sure how to get around it#2019-11-0319:57thhellerwhats the problem? looks like any other JS package?#2019-11-0320:28eoliphantsorry stepped away, I thought there was normally an index.js or something that you’re looking for#2019-11-0320:28eoliphantin any case#2019-11-0320:29eoliphanthere’s their default export import createAuth0Client from "@auth0/auth0-spa-js";#2019-11-0320:29eoliphantBut (require '["@auth0/auth0-spa-js" :default createAuth0Client]) results in createAuth0Client being nil#2019-11-0320:30thhellerread the section about :default here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-11-0320:31thhelleryou probably either need :as or :refer#2019-11-0321:19darwinhi, just wondering where is shadow-cljs sever version coming from, I’m on a mac, running shadow-cljs directly from project dir with packages.json, latest shadow-cljs is installed in node_modules and other in global yarn, but running shadow-cljs server still gives me shadow-cljs - server version: 2.8.67 running at instead of expected 2.8.69#2019-11-0321:22lilactownAre you using deps.edn / leiningen integration @darwin?#2019-11-0321:22darwinyep, deps#2019-11-0321:23lilactownIt will use whatever version is in your deps.edn classpath#2019-11-0321:23darwinah, here you go, thanks a lot#2019-11-0321:23lilactownNpm version is ignored when using deps or lein integration#2019-11-0321:24darwinI don’t think so, looking at /usr/local/bin/shadow-cljs it tries to require code from node_modules first#2019-11-0321:24darwinso node_modules version should drive initial cli version#2019-11-0321:25darwinI have to keep them both in sync, I guess#2019-11-0408:33thhellerno real need to keep them in sync. the CLI npm package changes rarely. mostly fine to just update the clojure package#2019-11-0321:24eoliphantthanks @thheller :as did it#2019-11-0415:43Saikyunhey, sometimes when I start a repl connecting to a script running in :target :node-script standard out seems to be set to the node process, but I'd like it to go to the repl if possible#2019-11-0415:43Saikyune.g. when running (println "hello") I'd like "hello" to show up in the repl 🙂#2019-11-0415:44Saikyunam I missing something obvious? what's tricky is that sometimes the text do end up in the repl...#2019-11-0416:33thheller@saikyun the only time the text ends up at the REPL is when you use node-repl (not the build repl)#2019-11-0416:33thhellerhttps://github.com/thheller/shadow-cljs/issues/373#2019-11-0419:18mruzekwIs it possible to use :target :node-library with only ^:export to denote exports?#2019-11-0419:54thheller@mruzekw no. all exports must be configured but there are several options to do so#2019-11-0420:03mruzekwKk, I think a default export is the closest to what I want.#2019-11-0420:03mruzekwThanks#2019-11-0423:55ro6I'm trying to connect from Cursive to two repl runtimes simultaneously, both from the same build (`{:target :chrome-extension}`), one for the background script, and one for the content script. I'm able to use (shadow/repl-runtime-select ...) to switch between them, but what if I want to keep a repl open to each runtime at the same time, instead of switching?#2019-11-0423:57ro6I'm really just trying to work on the ergonomics, so if there's a different workflow approach that's great too.#2019-11-0423:58thhellerI assume you already have 2 REPLs running in Cursive?#2019-11-0423:58thhellerI mean connected twice?#2019-11-0423:59ro6I was doing it with a remote nREPL connection, since that seemed to play better with the Cursive tooling, but I could try two local Cursive repls.#2019-11-0423:59thhelleroh wait right#2019-11-0423:59thhelleryeah you can't currently switch that#2019-11-0500:00thhelleryou can sort of if you pass the runtime-id when switching the REPL#2019-11-0500:00thheller(shadow/nrepl-select :the-build {:runtime-id ...})#2019-11-0500:01ro6Ok. What I'm doing right now that works is:
:reql/quit
(shadow/repl-runtime-select :browser-extension
    (:runtime-id (first (shadow/repl-runtimes :browser-extension))))
(shadow/repl :browser-extension)
#2019-11-0500:02thhellerhmm or maybe not#2019-11-0500:02thhellerI don't know anymore to be honest#2019-11-0500:02thhellerthe nREPL stuff has been a little frustrating#2019-11-0500:03ro6I didn't realize I could pass a :runtime-id to nrepl-select, so I'll try that.#2019-11-0500:03ro6No worries, I realize I'm way in edge-use-case land here, but it's interesting nonetheless.
#2019-11-0500:03thhelleryou can't actually pass :runtime-id to the nrepl#2019-11-0500:04thhellerit currently only expects that as part of the nrepl message (which no tool actually sends)#2019-11-0500:04thhellerbut I could change it so it respects it if set via nrepl-select#2019-11-0500:05thhellerbut all of this is part of the stuff I'm currently working through#2019-11-0500:05thhellerso I hope it'll become a bit clearer in the future#2019-11-0500:06ro6No worries at all, I appreciate that it works as well as it does. I'm not really impeded here, just trying to make it more ergonomic so I can eval in different JS environments really efficiently.#2019-11-0500:12thhellerhttps://github.com/thheller/shadow-cljs/commit/7af6e7fc290871431611b88e31bd3f56e88c58e3#2019-11-0500:12thhellerthat should take care of it#2019-11-0500:12thhellerbut headed to bed now. will test and probably release tommorrow#2019-11-0500:12ro6It might require more tooling integration (eg from Cursive) but in my "ideal future" I'd be able to configure rules such that "send to repl" from a certain file automatically gets eval'd in a particular environment, rather than switching a session singleton. I'm not sure how practical such a system would be beyond what I'm doing, but maybe there's a more general "route eval requests to environments" behavior hiding in there.#2019-11-0500:12ro6Cool, thanks for your help!#2019-11-0500:13thhelleryes, I wish tools had support for "runtimes"#2019-11-0500:13thhellerbut the regular CLJS repls don't expose them so it would be shadow-cljs only right now#2019-11-0500:33lilactownI have an interesting problem I’m trying to tackle#2019-11-0500:33lilactownReact recently shipped native support for hot reloading components#2019-11-0500:35lilactownactually, before I type all this out and bother y’all with thinking through this, I’m going to do some experiments and see where I actually fall over#2019-11-0500:37lilactownthe problem I’m currently afraid of is if I use React’s way of performing an update without restarting the app, it might have some stale references to e.g. a utility function I just changed#2019-11-0500:39lilactownso I might need some way of determining what “kind” of change was done (in webpack they use some heuristic to determine of a file only exports components), and decide whether to run performRefresh or render#2019-11-0500:41lilactownafter writing it out, I'm pretty sure this will be an issue I need to tackle if I want to use the React hot reloading stuff#2019-11-0500:46lilactownI don't suppose there's any information that the before-load/`after-load` fns can be given to help with this?#2019-11-0501:09lilactownsince all def and defns are exported by default, I don't think I can rely on that heuristic to ensure only the React components in a particular file are used elsewhere. I'm thinking right now if I could annotate an ns with some metadata, and get fed that in my after-load hook, then I could rely on the programmer to reasonably discern if a ns is safe to just refresh and add the meta themselves#2019-11-0501:10lilactownex:
(ns ^:react/refresh my-app.components
 ,,,)
#2019-11-0501:41lilactownah interesting. I was reading figwheel docs, and it distinguishes between reloading and recompiling dependent namespaces. it's possible that by reloading dependent namespaces (not recompiling them) we can have the desired behavior.#2019-11-0501:42lilactownmy preliminary tests show it actually all works fine 😅#2019-11-0501:59lilactownah shoot. it only works one ns deep in the tree#2019-11-0502:00lilactowne.g. if I have namespaces a, b and c where a requires b requires c: a -> b -> c then if I change c, only b is reloaded.#2019-11-0502:15lilactownif we reloaded the entire dependency tree of c -> b - a then I think things would work correctly. I don't know how heinous that would be in large apps 😬#2019-11-0502:38vinursis there any example that shows how to call my component in react component, my own component is defined in cljs#2019-11-0505:20Saikyun@thheller thanks for the info! 🙂#2019-11-0508:20thheller@lilactown the last time I looked at the fast-refresh stuff it required processing the generated JS to extract the signatures of the hooks used#2019-11-0508:20thhellervery very very doubtful that'll work for CLJS#2019-11-0508:20lilactownIt doesn't. We can easily use macros to generate the signature#2019-11-0508:21lilactownI have a working poc of this#2019-11-0508:22lilactownThe only actual requirement is to register the signatures with the runtime somehow (Babel, macros, etc.) and to call a method to trigger a "refresh" on hot reload#2019-11-0508:29lilactownThe last real hurdle is to correctly get all references to my changed ns to reload correctly#2019-11-0508:29lilactownGoing to sleep. Will check back later#2019-11-0508:30thheller@haiyuan.vinurs how did you define your component? how is the JS code getting access to it? :npm-module + webpack?#2019-11-0508:33vinursi’ve solved the problem, in cljs ns pages.dashboard.questionnaire
(def ^:export QuestionnairePage
  (r/reactify-component
   (fn [a]
     (println "questionnaire page is" a)
     [:div "questionnaire page"])))
and in js
const { QuestionnairePage } = window.pages.dashboard.questionnaire
and i can use the component like this
<QuestionnairePage a="b" c={style} />
#2019-11-0510:00yyonchoHi - I have 2 npm packages generated by shadow-cljs that are a dependency of a third application. Is it possible to share the timbre configuration between the two packages in the packaging project?#2019-11-0510:18thhellersorry, I don't know anything about timbre#2019-11-0510:20thhellerit is not advisable to create 2 npm packages intended to be consumed in one project. they'll contain a lot of duplicated code#2019-11-0510:27roklenarcicI have a .clj file with a macro in it under src/asciidocs/core.clj, and then I have src/asciidocs/app.cljs file which declares (:require-macros [asciidocs.core :as core]). When I try to use the macro the shadow-cljs complains:
6 |   (println (core/load-asciidoc "resources/docs/cv.asc"))
------------------^-------------------------------------------------------------
No such namespace: asciidocs.core, could not locate asciidocs/core.cljs, asciidocs/core.cljc, or JavaScript source providing "asciidocs.core"
--------------------------------------------------------------------------------
I am not sure why this doesn't work. I thought I was supposed to have my cljs macros in a clj file like this.
#2019-11-0510:28thhellerread https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2019-11-0510:30roklenarcicthanks#2019-11-0511:02henrikIs there any way to get the compiler to not evaluate stuff in #?(:clj blocks? I don’t want to compile the required NS into CLJS just to get rid of an error, as it’s not otherwise used in this file.#2019-11-0511:04henrikOf course, I can just require something random, like #?(:cljs [clojure.string :as pc]) to get around it, or create a dummy NS to include for this purpose.#2019-11-0511:05thhellerdon't import it as a macro then?#2019-11-0511:05thhellerI'm confused about your question. you ask about :clj blocks but then fix it in :cljs block?#2019-11-0511:06thhellerah sorry ... now I understand. no that is not possible#2019-11-0511:06thhellerit has to be syntactically correct (so the alias needs to be resolvable)#2019-11-0511:07thhelleror just don't use .cljc 😉#2019-11-0511:07thhellerit is the reader failing here. not the compiler. it isn't eval'ing the :clj blocks. it is just trying to read and for that is must resolve the ::pc/input alias#2019-11-0513:30henrikAh, crud. Alright, I’ll make a dummy NS to use in these cases. I thought I’d colocate the defmutations for both frontend and backend to the same file for fun and profit.#2019-11-0511:11thhellermight be interesting to modify tools.reader so it doesn't try to resolve whenever it is in a read-cond block that isn't active#2019-11-0511:11thhellerdoesn't really matter what ::pc/input resolves to in those cases#2019-11-0513:04mhuebertnice result from the wild: I recently converted a fairly large client codebase to compile with shadow-cljs - live-reload became ~3x faster upside_down_parrot and more reliable (was previously getting lots of errors when refreshing the page during recompile)#2019-11-0513:13thhelleronly 3x? 😛#2019-11-0513:33henrikSpeaking of the wild, I don’t want to use the words “de facto cljs compiler” yet, but I feel like I’m seeing a lot more shadow-cljs out there these days as opposed to only a year ago or so. Have you seen any concrete indications as to this @thheller (Visitors to the site etc.)?#2019-11-0513:34thhellernumbers keep going up yes. no clue how it compares to others though#2019-11-0513:35thhellerthe yearly clojure survey seems to be a good indicator#2019-11-0513:35thhellerlast one was about 25% shadow-cljs. we'll see in the next one 🙂#2019-11-0514:12knubiedoes anyone have a good method of running single tests in a :node-test script?#2019-11-0514:13thhellershadow-cljs node-repl (require '[your.test-ns :as x]) (x/that-test)#2019-11-0514:24knubieThanks, that seems to work, but I'm using spectron (https://github.com/electron-userland/spectron), which is supposed to open up an electron instance to run the spec with webdriver. But running the spec in the REPL doesn't do that so maybe it's not possible from the node-repl?#2019-11-0514:26knubieor maybe it's because the tests are async#2019-11-0514:29knubiescratch that, I ran the test with a .catch and am looking into the error now#2019-11-0514:55knubie:face_palm: Had to run fixtures#2019-11-0516:34thhellerI guess the :node-script output could take additional command line args too#2019-11-0516:34thhellerso node the-output.js --only some.test/foo or so. if someone is interested in working on that#2019-11-0517:54knubiewouldn't that be possible without any changes to shadow-cljs?#2019-11-0517:55thhellersure if you write a custom runner#2019-11-0517:55thhellerthe default one doesn't take any command line args#2019-11-0517:57lilactownhey thheller, I made a short POC of what I'm trying to do with react's HMR support (react-refresh) here: https://github.com/Lokeh/react-hmr-cljs#2019-11-0517:58lilactownif you have time to look at it, I would greatly appreciate it#2019-11-0517:58lilactownI'm able to generate the signatures and get hot reloading of same-file changes working just fine#2019-11-0517:59lilactownhowever, in the example I have a dep-b and dep-c namespace where core depends on dep-b, and dep-b depends on dep-c. if I change the greeting in dep-c to be "Bonjour!", it won't pick up the change on hot reload until the next render#2019-11-0517:59thhellerthats missing an example how the use actually looks#2019-11-0517:59thhelleror I'm just blind 😛#2019-11-0517:59lilactownhm?#2019-11-0518:00thhelleryeah I'm just blind sorry 😛#2019-11-0518:00lilactownsorry yeah it's laid out a little weird. react-hmr.core has the example usage#2019-11-0518:59thhellernow you only need to figure out how to get rid of all the related code in production 😉#2019-11-0519:08lilactownyes, it’s easy enough to wrap in (when goog/DEBUG ...#2019-11-0519:09thhellernot so easy to get rid of the react-refresh require though 😉#2019-11-0519:10lilactowntrue. could be done with a preload and some alter-var-root / global JS shenanigans#2019-11-0519:10lilactownbut does my problem I need help with make sense?#2019-11-0519:12thhellerdon't know enough about the refresh stuff to comment. it likely happens because core didn't change it just cancels the re-render#2019-11-0519:13lilactownright, so the issue is that the react-refresh stuff only re-renders components that have had their “type” (the function component registered with the ID) changed#2019-11-0519:14lilactownthe way that they’re suggesting people implement it is to detect whether a file only exports components. if it exports anything else than components, then call React.render instead (and blow away the state)#2019-11-0519:15lilactownwhich is… one solution#2019-11-0519:15lilactownI would need to be able to somehow detect whether a namespace is “safe” to refresh in my after-load hook#2019-11-0519:15lilactownthe other option could be to reload the entire dependency chain#2019-11-0519:16lilactownwhich if you are editing a file that has many dependents, could be very onerous#2019-11-0519:16lilactownI think either way, I need some help from shadow-cljs / figwheel to make it work#2019-11-0519:18thhellersorry, don't know enough about react-refresh to make sense of that. Don't know why "only exports components" is relevant at all. makes no sense to me right now#2019-11-0519:19lilactownit’s a super dumb heuristic to try and detect, “does anything other than React call something from this file”?#2019-11-0519:23vinurswhen i require ant-design in cljs and build a browser target like main.js, is that all ant-design files will bundled in the main.js?#2019-11-0519:24thheller@haiyuan.vinurs yes if you require antd directly#2019-11-0519:25vinursis there a method exclude it?#2019-11-0519:25thhelleronly import what you actually need#2019-11-0519:26lilactownif I put what I’m asking for concretely, with my understanding of the problem: 1. would you be willing to add the ability for the load hooks to get passed any info about the ns that’s being loaded? symbol + metadata? 2. would you be willing to add a setting that would reload all dependent namespaces up to the entry point?#2019-11-0519:26vinursok, understand#2019-11-0519:27lilactowneither 1 or 2 would potentially allow me to solve the reloading problem. 2 I feel like might have the most potential for problems, but I don’t know the complexity for 1#2019-11-0519:28thheller1) the client side doesn't have that info. 2) I kinda chose not to add it https://github.com/thheller/shadow-cljs/issues/349#2019-11-0519:29lilactowncould that info could be passed to the client side from the compiler state?#2019-11-0519:29thhellerin theory yes.#2019-11-0519:30thhellerbut you'll first need to make a convincing case why it is necessary at all#2019-11-0519:30thhellerI mean react-refresh is not even released yet. not going to add features for it until the design is finalized#2019-11-0519:32thhelleralso would kinda like to understand it first#2019-11-0519:32lilactownyeah totally#2019-11-0519:33thhellerbut how do you even tell a component from a regular function?#2019-11-0519:33thhellerseems completely pointless to me?#2019-11-0519:34lilactownI agree that the heuristic they chose is not a good one#2019-11-0519:35lilactownthe way I understand react-refresh to work today, is each time a component is registered (e.g. via a reload of the namespace), if the ID already exists it marks that ID as dirty. when performReactRefresh is run, it then goes through the React tree from the root and re-renders all of the components marked as dirty. if the hooks “signature” has changed since the last refresh, it will re-mount the component instead of re-rendering.#2019-11-0519:38lilactownso the issue shows up when: - a function gets changed that some component uses inside of it’s render that’s not a registered component - that component’s namespace wasn’t reloaded, so it’s not marked as dirty - React doesn’t re-render it since it thinks it’s clean#2019-11-0519:38tslockeIs it possible for a macro to detect :dev vs :release, e.g. to elide logging code?#2019-11-0519:39thheller@tslocke in theory yes but you probably want your own setting for this#2019-11-0519:40thheller:compiler-options {:external-config {:your/key ...}}#2019-11-0519:41tslockeOK that's what I've been doing but I'm having trouble switching back to having the logging active after doing a release build. TBH I think I'm not clear on the correct way to do a release build, deploy it to the server, and then go back to developing.#2019-11-0519:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-11-0519:42thhellerhow did you access it exactly? and where did you put it?#2019-11-0519:42thhellerif you put it into the incorrect places or access it incorrectly the cache won't be invalidated#2019-11-0519:42thhellerthe correct way to make a release build is shadow-cljs release your-build#2019-11-0519:43tslockeI have it in my shadow-cljs.edn, under :builds -> :app -> :dev#2019-11-0519:43thhellerhave what in that#2019-11-0519:44tslockeWhen I run shadow-cljs release, it overwrites the same main.js as shadow-cljs watch - is that expected?#2019-11-0519:44thhellerif you configured it that way yes#2019-11-0519:44tslocke(have what) :compiler-options {:external-config {:your/key ...}}#2019-11-0519:44thheller:release {:output-dir "somewhere/else"} would change it#2019-11-0519:45tslockeOK, maybe that's the simplest way to fix the issue then - I'll have the release build go somewhere else#2019-11-0519:45thhellerrm -rf public/js && shadow-cljs release app && copy-public-js-to-server#2019-11-0519:46tslockeAnd I access it with (get-in @cljs.env/*compiler* [:options :external-config :logging])#2019-11-0519:46thhellerok looks good then. release builds don't share any cache with the watch/compile builds so they usually don't interfere#2019-11-0519:47mazinis there a way to specify the :lein option outside of the top level? context is that im trying to use lein with shadow and specify a different lein profile for :dev and :release within a build#2019-11-0519:47thheller@mazin just call lein directly then#2019-11-0519:47thhellerlein with-profiles +release run -m shadow.cljs.devtools.cli release app#2019-11-0519:47thhellersame as calling shadow-cljs release app (just with the extra profile)#2019-11-0519:47tslocke@thheller thanks so much. I'm once again amazed by how available you are to help out. Don't you get swamped?#2019-11-0519:48thhellerright now I'm just hanging out and reading stuff#2019-11-0519:48thhellerhelping out is more interesting 😉#2019-11-0519:48tslocke🙂#2019-11-0519:48mazingotcha, thanks so much.#2019-11-0520:15lilactownI went ahead and opened an issue on React to try and see if we can solve this without needing to change shadow-cljs 😛 https://github.com/facebook/react/issues/17281#2019-11-0520:15Filipe Silva@lilactown so is the concept of react-refresh that re-registered components get refresh, but nothing else does?#2019-11-0520:15lilactownexactly#2019-11-0520:16lilactownre-registered components get re-rendered (possibly re-mounted if the hooks signature has changed), otherwise all components are left alone#2019-11-0520:16Filipe Silvaso it's essentially partial dependency invalidation#2019-11-0520:17Filipe Silvawhich kinda makes sense because react only know how to invalidate and hot-reload a certain class of things, namely components#2019-11-0520:18Filipe Silvareact is saying "if you tell me when my stuff changes, I can make an honest effort at refreshing them because I know their semantics"#2019-11-0520:18Filipe Silvabut that's always been the problem at HMR in general... your app needs to work in a way amenable to HMR#2019-11-0520:19Filipe SilvaHMR concerns bleed into the application architecture#2019-11-0520:20lilactownThe thing that puzzles me right now is that, if React re-rendered the entire app, it would fix this most of the time I think#2019-11-0520:20lilactownSo I'm not sure why they only re-render the components which have changed#2019-11-0520:20Filipe Silvare-rendering the whole app is the sort of hot reload shadowcljs already has today, right?#2019-11-0520:21lilactownIt is except calling React.render also re-MOUNTS everything#2019-11-0520:21lilactownSo you lose all local state#2019-11-0520:22lilactownIf you could re-render the whole app without losing local state, you have achieved the dream 😂#2019-11-0520:24Filipe Silvaand this refresh thing re-renders without re-mounting?#2019-11-0520:25lilactownYes#2019-11-0520:26Filipe Silvathen I think what you need to make this work is the dependency graph that shadowcljs has around#2019-11-0520:27Filipe Silvathen you can reason about it and say things like "namespace.path changed so I will mark all components that depend on it dirty"#2019-11-0520:27Filipe Silvabut I guess that's why you wanted the component metadata in the first place?#2019-11-0520:28Filipe Silvaif you go down to the symbol level and still have the dependencies it might be easier#2019-11-0520:30Filipe Silvathen you could have some reverse mapping that says "this react component in refresh stuff maps to that cljs function" and also "this reload affected all these cljs symbols" and cross reference those#2019-11-0520:30lilactownyes, you can take the surgical approach where you analyze each components dependencies and detect whether any have changed#2019-11-0520:31lilactownyou can also take the sledgehammer approach, which is that shadow-cljs or figwheel could reload ALL dependent namespaces which would in turn mark any components within them as dirty#2019-11-0520:32lilactownboth of these require quite more work on the tooling side, which I understand why thheller is skeptical 😉#2019-11-0520:32thhelleryou could just keep a registry of all and :dev/after-load make it dirty yourself#2019-11-0520:33thhellerI saw a register! call somewhere already#2019-11-0520:34lilactownright, yes hmmm#2019-11-0520:37lilactowneach component gets roughly this emitted:
(def set-my-component-signature! (create-signature))

(def my-component ...)

(set-my-component-signature! my-component "hooks signature goes here")

(register! my-component "my-app.core/my-component")
#2019-11-0520:42lilactownI’m not sure how I would make it dirty. I suppose I could wrap each in a fn? that seems gross#2019-11-0520:43thhellerdunno either. does it use identity? like regular react or does react-refresh have different rulres?#2019-11-0520:44lilactownI assume it does#2019-11-0520:45thheller(register! my-component "my-app.core/my-component" (fn [new-component] (set! my-compoent new-component)) maybe#2019-11-0520:45thhellerprobably needs an indirect call then though#2019-11-0520:46thhellerso (defn actual-component* ...) and (defn component [...] (actual-compoent* ...))#2019-11-0520:54lilactownhmm not sure I get it yet#2019-11-0520:55lilactownI think the gist of the thing is to give the call to react-refresh-runtime/register a new function#2019-11-0520:57lilactownhow much work would it be to add support for doing a full recompile of dependent namespaces? if just to experiment with it in relation to react-refresh#2019-11-0520:57lilactownI want to see how bad it would be with a large project number of namespaces#2019-11-0521:21thhellernot easy to add right now. full recompile is also madness.#2019-11-0521:24lilactownYeah def not full recompile#2019-11-0610:44Filipe Silvaheya#2019-11-0610:45Filipe Silvawhile using the jack-in functionality on calva, I noticed an inconsistency related to shadow-cljs start#2019-11-0610:47Filipe SilvaIf I use shadow-cljs start followed by jacking in, nrepl and server information is never shown
$ yarn shadow-cljs start
yarn run v1.17.3
$ D:\work\learn-re-frame-course-files\cheffy\node_modules\.bin\shadow-cljs start
shadow-cljs - config: D:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - server starting ..................................... ready!
Done in 10.14s.
> Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.4 watch :app <

shadow-cljs - config: d:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - connected to server
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (691 files, 690 compiled, 0 warnings, 46.46s)
#2019-11-0610:49Filipe Silvathis stands in contrast with not using shadow-cljs start at all, which shows full server information#2019-11-0610:49Filipe Silva
> Executing task: C:\Program Files\nodejs\npx.cmd shadow-cljs -d cider/piggieback:0.4.1 -d cider/cider-nrepl:0.22.4 watch :app <

shadow-cljs - config: d:\work\learn-re-frame-course-files\cheffy\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.69 running at 
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (691 files, 1 compiled, 0 warnings, 9.60s)
#2019-11-0610:50pezMaybe shadow-cljs watch figures out that the server is running?#2019-11-0610:51pezPlease file an issue specifically about this on Calva. I might be able to figure something out…#2019-11-0610:53thheller@filipematossilva start runs the server in the background and exits. the output is still logged but to a logfile in the .shadow-cljs dir#2019-11-0610:53thhellershadow-cljs server will start in the forground and not exit#2019-11-0610:53thhellerwatch will use a running server if there is one, otherwise it'll become the server#2019-11-0610:54Filipe SilvaI didn't know about the .shadow-cljs/server.stdout.log (and .stderr.log) files#2019-11-0610:54Filipe Silvaindeed it is there#2019-11-0611:10Filipe Silva@pez here it is https://github.com/BetterThanTomorrow/calva/issues/452#2019-11-0611:11Filipe Silvanow I think this is the cause: > Since the nrepl.port file is also created on server startup and Calva looks for files created in .shadow-cljs, I suppose it will never see the file being created and just wait for that.#2019-11-0611:13Filipe Silvamaybe I can configure one of the regexes in the config sequence to make this work? https://github.com/BetterThanTomorrow/calva/blob/3756a88995ede225c1f84e4ebcec6b685e5f3125/src/nrepl/connectSequence.ts#L143-L154#2019-11-0611:16thhellerhow this is kinda intended to work is that a server is either started or already running#2019-11-0611:16thhellertools should only interact via the REPL#2019-11-0611:16thhellerit should never regex anything?#2019-11-0611:18Filipe SilvaI'm not sure what those regex are actually used for, but I imagine they parse the output of invoking the watch command#2019-11-0611:18Filipe Silvabecause jack-in also runs that automatically#2019-11-0612:16pezIt’s a long story. But anyway, I think we can figure something out. Thanks for filing the issue!#2019-11-0612:42David PhamI wondered if anyone got this error lately: I am using ^:dev-reload with shadow-cljs, so far so good, but I randomly get the following error whenever I update my app. (It happens with material-ui, so not sure it is something on reagent/shadow-cljs or material-ui)
component.cljs:338 Uncaught TypeError: Cannot read property 'call' of undefined
    at new transparency.components.drawer.drawer_react (component.cljs:338)
    at constructClassInstance (react-dom.development.js:14240)
    at updateClassComponent (react-dom.development.js:18351)
    at beginWork$1 (react-dom.development.js:20109)
    at HTMLUnknownElement.callCallback (react-dom.development.js:363)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:412)
    at invokeGuardedCallback (react-dom.development.js:467)
    at beginWork$$1 (react-dom.development.js:25731)
    at performUnitOfWork (react-dom.development.js:24639)
    at workLoopSync (react-dom.development.js:24615)
transparency.components.app_bar.app_bar_react	@	component.cljs:338
constructClassInstance	@	react-dom.development.js:14240
updateClassComponent	@	react-dom.development.js:18351
beginWork$1	@	react-dom.development.js:20109
callCallback	@	react-dom.development.js:363
invokeGuardedCallbackImpl	@	react-dom.development.js:412
invokeGuardedCallback	@	react-dom.development.js:467
beginWork$$1	@	react-dom.development.js:25731
performUnitOfWork	@	react-dom.development.js:24639
workLoopSync	@	react-dom.development.js:24615
performSyncWorkOnRoot	@	react-dom.development.js:24183
eval	@	react-dom.development.js:12239
exports.unstable_runWithPriority	@	scheduler.development.js:816
runWithPriority$2	@	react-dom.development.js:12189
flushSyncCallbackQueueImpl	@	react-dom.development.js:12234
flushSyncCallbackQueue	@	react-dom.development.js:12222
scheduleWork	@	react-dom.development.js:23602
updateContainerAtExpirationTime	@	react-dom.development.js:26946
updateContainer	@	react-dom.development.js:27076
legacyRenderSubtreeIntoContainer	@	react-dom.development.js:27680
render	@	react-dom.development.js:27757
reagent$dom$render_comp	@	dom.cljs:19
eval	@	dom.cljs:43
eval	@	dom.cljs:38
eval	@	core.cljs:77
transparency$core$mount_app	@	core.cljs:21
eval	@	VM47974:1
shadow$cljs$devtools$client$browser$global_eval	@	browser.cljs:233
eval	@	browser.cljs:236
shadow$cljs$devtools$client$env$repl_call	@	env.cljs:106
shadow$cljs$devtools$client$browser$repl_invoke	@	browser.cljs:236
shadow$cljs$devtools$client$browser$handle_message	@	browser.cljs:288
eval	@	env.cljs:185
shadow$cljs$devtools$client$env$process_next_BANG_	@	env.cljs:173
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:186
eval	@	browser.cljs:368
#2019-11-0612:43thheller
component.cljs:338 Uncaught TypeError: Cannot read property 'call' of undefined
    at new transparency.components.drawer.drawer_react (component.cljs:338)
#2019-11-0612:43thheller(something 1 2 3) when something is nil#2019-11-0612:43David PhamThe faulty code is this one: in reagent.impl.component#2019-11-0612:43David Pham
(defn create-class
  "Creates JS class based on provided Clojure map.

  Map keys should use `React.Component` method names (),
  and can be provided in snake-case or camelCase.
  Constructor function is defined using key `:getInitialState`.

  React built-in static methods or properties are automatically defined as statics."
  [body]
  {:pre [(map? body)]}
  (let [body (cljsify body)
        methods (map-to-js (apply dissoc body :displayName :getInitialState :constructor
                                  :render :reagentRender
                                  built-in-static-method-names))
        static-methods (map-to-js (select-keys body built-in-static-method-names))
        display-name (:displayName body)
        get-initial-state (:getInitialState body)
        construct (:constructor body)
        cmp (fn [props context updater]
              (this-as this
                (.call react/Component this props context updater) <<<<------------------------ THIS LINE
                (when construct
                  (construct this props))
                (when get-initial-state
                  (set! (.-state this) (get-initial-state this)))
                this))]
#2019-11-0612:44David PhamSo react/Component would be nil?#2019-11-0612:45thhellerappears to be yes#2019-11-0612:46David Phamin reagent?#2019-11-0612:46David PhamI am using the npm version of react.#2019-11-0612:46thhellerat new transparency.components.drawer.drawer_react (component.cljs:338)#2019-11-0612:47thhellerthe code you just posted?#2019-11-0612:47David PhamSo, I should just go inside reagent and change the requirement [react :as react] as ["react" :as react]#2019-11-0612:47David Phamyes.#2019-11-0612:47thhellerno, that doesn't matter#2019-11-0612:47thhellerdon't know why you bring up reagent though?#2019-11-0612:48David PhamBecause the call from the undefined comes from reagent#2019-11-0612:48David Phamat new transparency.components.drawer.drawer_react (component.cljs:338) is called from reagent#2019-11-0612:48thhellersorry I don't follow. that is not a regent namespace#2019-11-0612:49David Phamcomponent.cljs:338 is a reagent namespace#2019-11-0612:49David Phamreagent.impl.component.cljs#2019-11-0612:49thhellertransparency.components.drawer.drawer_react this part is what I'm asking about#2019-11-0612:51David Phamthis is not a part of react/reagent.#2019-11-0612:52David Phambut, whenever I ask chrome to debug on exception, it shows me reagent.impl.component namespace#2019-11-0612:52thhelleryes ... but it helps to know what transparency.components.drawer.drawer_react is#2019-11-0612:52David Pham
(defn drawer-react
  "The main components of the drawer. Refactor this tab to provides the tabs as
  argument."
  [{:keys [classes tabsPublic]}]
  (let [tabs-public tabsPublic
        tabs [[tabs-public (or @(subscribe [::drawer-displayed-sublists]) #{})]]]
    [:> mui-drawer
     {:open true
      :variant :persistent
      :class (cs (.-drawerPaper classes))
      :ModalProps #js {:onBackdropClick #(dispatch [:close-drawer])}
      :PaperProps #js {:class (cs (gobj/get classes "drawerPaperPaperProps"))}}
     [:div {:style {:width drawer-width}}
      [:div {:class (.-toolbarIcon classes)}
       [:> mui-icon-button {:onClick #(dispatch [:toggle-drawer])}
        [:> ic-chevron-left {:style {:color "white"}}]]]
      [list-divider classes]
      [:> mui-list {:style {:padding-top 0}}
       (into [:div] tabs)]]]))
#2019-11-0612:55thhellerhmm yeah dunno 😛#2019-11-0612:56David Phamhaha xD#2019-11-0612:56thhellerare you maybe messing with js/React in some way?#2019-11-0612:56David Phamnot at all#2019-11-0612:56David Phamnot defined though#2019-11-0612:56David Phamwhen I write it in the repl#2019-11-0612:56thhellergood#2019-11-0612:57David Phamwhat is weird, is that it only appears wheneever I reload the code#2019-11-0612:57David Phammaybe it is in the "updater" because it is undefined#2019-11-0612:58thhellerand when you debug react/Component is undefined?#2019-11-0612:59David Phamyes as well#2019-11-0612:59thhellerthere should be a global of some kind module$node_modules$react$...#2019-11-0612:59David Phamthat is defined#2019-11-0613:00thhellerbut that is what react/Component should be accessing?#2019-11-0613:01David Phamhum... I don't know. I might try to dig a bit deeper, maybe this is the answer. My issue is the bug is random#2019-11-0613:02David Phamonly at reload#2019-11-0613:02thhellerit looks like you are calling transparency$core$mount_app from the REPL?#2019-11-0613:02David Phamnope#2019-11-0613:03David PhamI rely on ^dev:after-load to reload the app#2019-11-0613:03David Pham
(defn ^:dev/after-load start []
  (rf/clear-subscription-cache!)
  (mount-app))
#2019-11-0613:03David Phammaybe I should not clear subscription cache xD#2019-11-0613:04thhelleryou should#2019-11-0613:05David PhamI should clear?#2019-11-0613:05David Phamor should not?#2019-11-0613:05thhelleryes, clear. otherwise the UI won't update.#2019-11-0613:07David Phamok, I will try to come back when I can pinpoint the issue. But it is an annoying bug as it completely mess up with hot reloading.#2019-11-0613:07thheller
shadow$cljs$devtools$client$env$repl_call    @    env.cljs:106
shadow$cljs$devtools$client$browser$repl_invoke    @    browser.cljs:236
shadow$cljs$devtools$client$browser$handle_message    @    browser.cljs:288
#2019-11-0613:07thhellerthis part I can't explain. that is not called as part of a normal reload cycle.#2019-11-0613:19David PhamHum... Ok I will try to see. I am trying to use your new inspect feature as well#2019-11-0613:19David Phamif that can help#2019-11-0613:21thhellerhmm no that runs separately and doesn't call that stuff either#2019-11-0613:22thhelleris your editor maybe sending stuff over the REPL?#2019-11-0613:22David PhamI am using emacs#2019-11-0613:22David Phamwith shadow-cljs#2019-11-0613:22David Phamand cider#2019-11-0613:23David PhamI execute shadow-cljs watch app#2019-11-0613:23David Phamand connect with cider-connect-cljs#2019-11-0613:23thhellerthat does send a bunch of stuff all the time#2019-11-0613:23thhellerbut not sure how it would affect the reload cycle#2019-11-0613:26David PhamGot call, maybe this is the reason. I will check.#2019-11-0613:59David PhamDid anyone got ReferenceError: $jscomp is not defined with google closure compiler?#2019-11-0614:11David PhamI got it, just had to output es6 in the clojure compiler#2019-11-0614:27FloTrying to create a prod deployment from shadow-cljs + compojure project: starting from a completely blank skeleton via lein new re-frame foo +10x +re-frisk +handler and then run a lein with-profile prod uberjar I get this error:
[:app] Build completed. (95 files, 46 compiled, 0 warnings, 29.20s)
Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method, or the namespace has not been AOT-compiled.
any ideas?
#2019-11-0614:28Flokept the :uberjar target in project.clj as is, i.e.:
:uberjar {:source-paths ["env/prod/clj"]
               :dependencies [[day8.re-frame/tracing-stubs "0.5.3"]]
               :omit-source  true
               :main         foo.server
               :aot          [foo.server] 
               :uberjar-name "foo.jar"
               :prep-tasks   ["compile" ["prod"]]} 
#2019-11-0615:18hlolli@web20 do you have (defn -main [] ...) in foo.server, and (:gen-class) in it's namespace decleration?#2019-11-0615:19Flo@hlolli yes#2019-11-0615:22hlollithis isn't a shadow-cljs problem, but looking at the source path, are you sure that ./env/prod/clj/foo/server.clj exists at this location?#2019-11-0615:24hlollialso, I would do :aot :all to be safe#2019-11-0615:40Flo@hlolli ha! no that's empty.. I assume lein prod would populate that path? even if I run lein prod (which runs -m shadow.cljs.devtools.cli release app), then env/prod/clj remains empty.#2019-11-0615:42hlolliI would segment the the dubug process. 1. make sure that shadow-cljs is producing .js files from .cljs sources. And then, debug the server. Source paths here in this case are left untouced, only your target directory and uberjar are written during compilation.#2019-11-0621:23Flo@hlolli fwiw, the issue was the following: The "prod" task contains an initial lein clean. So right after the "compile" :prep-task finished, it cleans its results, and then, naturally, the class cannot be found. Thanks for taking the time to take a look!#2019-11-0621:42hlolliclassic 😉 @web20#2019-11-0701:34lilactownAfter thinking about the react refresh problem some more, I think the best thing to try right now is to add the ability to reload all dependent ns#2019-11-0701:35lilactownthheller, would you be willing to help me if I tried to implement that in shadow-cljs to try it out?#2019-11-0701:35lilactownI'll try and write up a clearer rationale for it#2019-11-0714:24thheller@lilactown you can "test" this by copying this file https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L148 to your classpath#2019-11-0714:24thhellerand commenting out that check#2019-11-0714:24thhellerso (and #_(contains? compiled resource-id)#2019-11-0714:25thheller(I think that should be enough)#2019-11-0714:25thhellerit'll probably make reload very slow though#2019-11-0717:27lilactownit did reload the namespaces, but in my simple test it also reloaded React et. al. which broke the app#2019-11-0717:27lilactownquick question: what's the :always-load bit there? is that something I can annotate an ns with?#2019-11-0717:33thheller@lilactown the other case in the and must remain#2019-11-0717:33thhelleronly comment out the compiled check#2019-11-0717:34thhellerhmm or now that I think about it the npm sources won't have the :from-jar flag#2019-11-0717:34lilactownyeah#2019-11-0717:34thhellerso you can add another filter so it filters out all (str/starts-with? (str ns) "module$node_modules")#2019-11-0717:35lilactownthat will work for my test, but might that break hot loading of npm deps after (re)installation?#2019-11-0717:36thhellerwell whatever it is the "logic" would need to happen in exactly that place#2019-11-0717:36thhellerthere is nothing to change server side#2019-11-0717:36thheller(except maybe make more data available)
#2019-11-0717:37thhellerbut if you checkout the msg data the handle-build-complete fn receives you should find everything you could possibly need#2019-11-0717:38thhellerdon't really know why re-declaring a file plays a role in your setup though. it is going to be too slow for any practical uses anyways#2019-11-0717:43lilactownthe way react refresh is modeled, your macro outputs a call to a register function with a stable ID and a component. when you call register with a new component (not === to the last one), it marks it as dirty in the react refresh runtime and tells the react reconciler to re-render it or re-mount it#2019-11-0717:44thhelleryes, that part I understand#2019-11-0717:45thhellerbut why is it necessary to replace all of them?#2019-11-0717:46lilactownin the case where you update a namespace with a function or piece of data that components depend on, but isn’t a component itself, the dependent components won’t be refreshed#2019-11-0717:46thhelleryes, but that wouldn't be the case for regular JS either?#2019-11-0717:47thhelleror does it actually just reload all the code?#2019-11-0717:48lilactownyes, it is. the current strategy they suggest to people implementing this in webpack, rollup, etc. is: - if a module exports only components use react refresh - if a module exports anything other than a component, reload the page#2019-11-0717:49thhellerthat isn't the problem you are solving#2019-11-0717:49thhellersay my "module" only exports components#2019-11-0717:50thhellerbut it is still nested#2019-11-0717:50thhellerso a -> b -> c#2019-11-0717:50thhellerc is reloaded#2019-11-0717:50thhellera + b are not#2019-11-0717:50thhellerhow does refresh do its thing to re-render c? assuming that hte problem you are trying to solve is that starting from a short circuits since it wasn't changed#2019-11-0717:51lilactownin that case it’s fine, because a + b don’t need to be reloaded#2019-11-0717:51thhellerso why are you trying to solve the problem by reloading a+b?#2019-11-0717:51lilactownbecause if c isn’t a component, then the components that use it to implement some behavior aren’t reloaded#2019-11-0717:52thhellerwe are not talking about that case#2019-11-0717:52lilactownI am 😅#2019-11-0717:52thheller(which would be a full reload in react-refresh if I understand correctly)#2019-11-0717:53lilactownI guess I should back up#2019-11-0717:53lilactownI think the heuristic they use sucks#2019-11-0717:53lilactownit means that if your module contains anything other than components, can’t use hot reloading; reload the whole app!#2019-11-0717:54thhelleryes, just forget about what they are doing#2019-11-0717:54thhellerthe problem as I understand it is that doing the regular CLJS reload we have today is losing useState hook data (and others)#2019-11-0717:54lilactownright, if you call React.render again you lose all state and re-mount everything#2019-11-0717:54thhellerwhich react-refresh does some "magic" to preserve#2019-11-0717:54lilactownyep#2019-11-0717:55thhellerso the problem to solve is how to hook into that part only right?#2019-11-0717:55thhellerdon't care about the other nonsense#2019-11-0717:56lilactownI have the simple case working where when you edit a component, it refreshes correctly using the react-refresh stuff. the “magic” works#2019-11-0717:56lilactownthe case I’m working on now is how to handle the case where in webpack, rollup, etc. they decide to bail and reload the page#2019-11-0717:57lilactownwhere in the React component tree, you have:
<A>
  <B />   <---- uses `moduleC.foo`
</A>
when moduleC gets reloaded, but the module that contains components A and B are not reloaded, then B will not be refreshed
#2019-11-0717:58thhellerso what you are trying to solve is "shouldComponentUpdate" deciding to skip updates?#2019-11-0717:58lilactownno, I don’t think it has anything to do with shouldComponentUpdate#2019-11-0717:59thhellerhmm? but if you render from the root (as regular CLJS does) then it'll eventually reach the new moduleC.foo?#2019-11-0718:00thhellerunless it stops early because some component said "I don't need to render"#2019-11-0718:00lilactownah yes, another strategy that doesn’t use react-refresh might be to force a re-render from the root#2019-11-0718:02lilactownreact-refresh does some other magic that makes it so if you’ve changed a component in a certain way, it will re-mount that component, and it handles hooks in slightly different ways like restarting effects but keeps state#2019-11-0718:07lilactownthe example I created displays the problem I’m trying to solve: https://github.com/Lokeh/react-hmr-cljs/ I was actually able to get the behavior I want in that case by annotating the core ns as :dev/always#2019-11-0718:09thhellerwouldn't you get the same by just calling (start) after the (react-refresh/reload)?#2019-11-0718:10lilactownthat would re-mount the whole app, losing all state#2019-11-0718:12lilactownI’m not sure it will refresh child components as well, so just marking the top-level ns as :dev/always might not be enough. that’s why I’m experimenting if I can reload all dependent namespaces#2019-11-0718:13lilactownthe other option I think is we can do something similar to webpack, which is to apply some heuristic to see if a namespace is “safe” to refresh and if not, remount everything via React.render#2019-11-0718:13lilactownthat’s more problematic for Clojure because everything is public by default… so just checking to see if everything is a component would probably not work#2019-11-0718:14thhellerit still sounds like you are trying to solve the wrong problem to me#2019-11-0718:14thhellerreloading all namespace is going to be too slow. therefore experimenting with it is a dead end#2019-11-0718:15thhellerif the problem is just that the === on the component type fails then that is an easy fix#2019-11-0718:16lilactownI can’t tell if that is the problem yet. The first problem is you need to call register with a type and ID for each component you want to refresh, each time you perform a refresh#2019-11-0718:17thhellerthats easy?#2019-11-0718:19lilactownwell I’ve been trying to think of how to refresh only the dependent components. if I refresh every component… it might be easier#2019-11-0718:25lilactownif I could detect what components are in the dependency tree of a reloaded ns, without having to actually reload the ns they’re in, then that could improve the speed a lot#2019-11-0718:26thhelleryou are approaching this incorrectly I think#2019-11-0718:26thhellerlet me try what I have in mind#2019-11-0718:34lilactownokay. I appreciate it#2019-11-0718:52thhelleryeah don't know. I can't get it to refresh anything. not even the root itself#2019-11-0718:53thhellermight check it out a bit later ...#2019-11-0718:57lilactown? is my example not working? or were you trying something else#2019-11-0721:17Nolanseems pretty inconsequential in terms of affecting functionality, but is this warning something im causing? only happens for browser target, cant figure it out
------ WARNING #4 -  -----------------------------------------------------------
 Resource: node_modules/buffer/index.js:2
 constant module$node_modules$buffer$index assigned a value more than once.
Original definition at externs.shadow.js:3
--------------------------------------------------------------------------------
#2019-11-0810:36pezI seem to have lost my hotreload when hacking on calva-lib. I have tried some older versions of VS Code, but it is the same. Also some older versions of shadow-cljs, but same… I need some tips on how I can track this down. Totally horrible to be back in compile->restart land.#2019-11-0810:36thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2019-11-0810:39thhelleryou have a console for wherever calva-lib is running in right?#2019-11-0810:51pezYeah. It does have some strange cache-related error messages… Let me check…#2019-11-0810:59pezHmmm, no. Got rid of those messages, but still no hot-reload for me.#2019-11-0811:00thhellerwhat does the console say?#2019-11-0811:01thhelleroh and you are using :node-library so the hot-reload doesn't work for exported vars?#2019-11-0811:01pezRight now it says nothing.#2019-11-0811:02pezI have had hot-reload working…#2019-11-0811:04pezYes, that was it! My exported vars are usually very thin dispatchers so not really tried if hot reload works for them. It works for non-exported stuff.#2019-11-0811:05pezThen I am good, Just need to thin this one down. 😃 Curious about why it doesn’t work for those vars though.#2019-11-0811:07thhelleractually I can make that work. just never updated the initial "naive" implementation 😛#2019-11-0811:09pezCool. I can write my stuff explicitly with exported dispatch-only api, but would of course be nicer not to have to do it for that reason.#2019-11-0811:10pezAny chance I can some day get a non-flat export for my :node-library?#2019-11-0811:11thhellerthe reason it doesn't work right now is that basically in JS it is doing var something = require(".../calva-lib.js")#2019-11-0811:11pezI see. Makes sense.#2019-11-0811:11thhellerso something will be the {whatever: some-function)#2019-11-0811:11thhellerand we can't update something#2019-11-0811:11thhellerbut I can make it work by using getters for the actual object in development#2019-11-0811:12thhellerso we can switch what it actually accesses later#2019-11-0811:12thhelleror just hold onto the exported object and update that#2019-11-0811:12pezI’m good with just knowing what was going on, but if that is not tons of work for you, it is on my wishlist. 😃#2019-11-0811:15thhellerhttps://github.com/thheller/shadow-cljs/issues/589#2019-11-0811:17pezHave you written about the differences between npm-library and node-library are somewhere? I mean conceptually, but yeah, faturewise too.#2019-11-0811:18thhelleryou mean :npm-module?#2019-11-0811:18pezClojureScript is my first real contact with node land, so obvious things are not so obvious to me.#2019-11-0811:18pezYeah, I meant that. Haha.#2019-11-0811:18thheller:npm-module basically tries to expose the CLJS namespaces to JS#2019-11-0811:18thheller:node-library lets you collaps namespaces down to one single object#2019-11-0811:19thheller:node-library should be preferred in almost all cases (output is more efficient/compact)#2019-11-0811:20pezThe single object is flat though. Which a while had me try with :npm-module.#2019-11-0811:20pezNever got the entry point to work with that though.#2019-11-0811:21thhelleryeah if you basically just want to use the CLJS namespaces directly in JS then :npm-module is the way but it has other issues that makes it more complicated to work with#2019-11-0811:21thhellerie. hot-reload and REPL#2019-11-0811:23pezI love my :node-library. Will stay with it. Hopefully grow it a bit faster so that you start liking Calva more. 😃#2019-11-0811:25thhellerhehe#2019-11-0811:27thhelleryou are brave for still being able to work in typescript 😛#2019-11-0811:27pezIt is actually pretty sweet how when in cljs I can reach both the node and the clojure ecosystems.#2019-11-0811:28thhellerI want to throw my PC out the window every time I even look at TS code 😛#2019-11-0811:28StefanI worry for your office when you have to look at JS code then…#2019-11-0811:28pezActually it is not so much that I want it. It has been pragmatic, but also will become problematic. So will start a “background thread” bringing stuff over piece by piece.#2019-11-0811:29thhellerjust a big PC graveyard in my garden 😉#2019-11-0811:30papachanpicture pleaaaase!#2019-11-0811:30pezI have to admit I kinda like TypeScript a bit too. Mainly for its improvement over JS, but also it is quite nice with the IDE support you are rewarded with when you write types for things.#2019-11-0811:31thhelleryeah I have to admit that part is pretty nice#2019-11-0811:34pezBut Calva just got signature help rivaling that of TypeScript’s. So there is that approach as well. 😃#2019-11-0813:47jjttjjis it easy to get a workflow where I can get a clj and cljs repl simultaneously running for a project using emacs/cider?#2019-11-0813:51jjttjj(also using deps.edn)#2019-11-0813:55dpsuttoncider-jack-in-clj&cljs#2019-11-0813:56jjttjjwow, thanks!#2019-11-0814:32Saikyunis it possible to configure shadow-cljs.edn to match this call: (shadow.cljs.devtools.api/watch :app {:autobuild false}) when running shadow-cljs watch app?#2019-11-0814:32Saikyunhave tried setting :autobuild false in various places in shadow-cljs.edn but haven't been able to figure it out#2019-11-0814:33thhellerthere is not. feel free to open an issue though.#2019-11-0814:34Saikyunokay!#2019-11-0814:34David PhamWhy do people like Typescript by the way?#2019-11-0815:20gdubsI’ve got a super minimal example where my cljs ‘requires’ an adjacent .js file which requires an npm module, lodash. After compiling, and when I try to run it, I get Module not provided: shadow.js.shim.module$lodash. That file, shadow.js.shim.module$lodash.js is in my cljs-runtime dir.#2019-11-0815:21gdubsMy config file#2019-11-0815:21gdubs@thheller any ideas what I’m doing wrong?#2019-11-0816:55thheller@gdwarner do you have the actual code too?#2019-11-0816:56thhellerI'm assuming you have (:require ["./some.js" :as x]) and in that JS const x = require("lodash");?#2019-11-0816:59gdubsthat’s basically it#2019-11-0817:00thhellerI need to know if thats exactly it though 😛#2019-11-0817:01thhellerJS deps requiring NPM deps is in kind of a rough spot right now because the closure compiler changed something#2019-11-0817:01thhellerso it may work if you switch it to use import X from "lodash"#2019-11-0817:01thhellerif you have something reproducible that would help#2019-11-0817:01gdubs#2019-11-0817:02gdubsThere’s a lot of cruft in there from testing various things. Let me slim it down…#2019-11-0817:04thhellerI think I was relying on a bug in the closure compiler which they fixed#2019-11-0817:04thhellerso I kinda need to come up with a new strategy for this#2019-11-0817:04gdubshmm…#2019-11-0817:04gdubsSlightly slimmer…#2019-11-0817:04thhellerbut try it with ESM notation. so import/export. no require#2019-11-0817:04thhellercommonjs support is likely going away#2019-11-0817:05thhellerhaven't touched the JS support in a while. don't really recommend using it 🙂#2019-11-0817:08lilactownESM notation is working well for us atm#2019-11-0817:40gdubsruntime is nodejs 12, which doesn’t support ESM notation. 😞#2019-11-0817:40thhellerdoesn't matter. is is transpiled as part of the CLJS compilation#2019-11-0817:40gdubsaw_yeah#2019-11-0817:43gdubsOk. Another bane of my existence that I want to pick your brain about. We’ve got a javascript code base. We’d like to write new functionality in cljs. Our unit tests are using jest. Jest and the closure compiler don’t seem to like each other. goog is not defined. Do you know anything about this? I imagine getting to the bottom would require in-depth knowledge in either jest or closure or both.#2019-11-0817:43thhellerdon't know anything about jest sorry#2019-11-0817:45thhellerif the :node-library code isn't loaded properly then it may do some kind of processing that breaks the already brittle output 😛#2019-11-0817:52gdubsFrom what I’ve been able to figure out, jest messes with node’s require function. The other testing framework I tried, mocha, doesn’t have the same problem. But, its also interesting that jest seems to work fine with every other node library. I wonder if its related to closure’s heavy use of globals.#2019-11-0817:57gdubsjust to report back: ESM-style worked#2019-11-0818:35gdubsHuh… re the ‘jest’ problems I was having: I only have issues with development builds of the cljs. Release builds work fine. 👍#2019-11-0820:33pezWhat is the default optimizations for a :node-library target?#2019-11-0820:42thheller:advanced#2019-11-1110:32ElirazHello, I have an issue with shadow-cljs#2019-11-1110:32ElirazI keep getting this error when I try to watch / compile my dead simple app: Illegal UTF8 string in constant pool in class file jdk/nashorn/internal/runtime/linker/Bootstrap#2019-11-1110:33thhellerhmm never seen that one before#2019-11-1110:35thhellerseems like a general JVM error. what is your java -version?#2019-11-1110:35Elirazopenjdk version "13.0.1" 2019-10-15#2019-11-1110:36thhellerdid you try a different version?#2019-11-1110:38thhellerI'm on
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
#2019-11-1110:39thhellerruns without issues, maybe something is bad in your release?#2019-11-1110:40Elirazwhich means?#2019-11-1110:41Elirazmy java release or my simple app release?#2019-11-1110:42ElirazI can try install the openJDK 13.u33 and see if it works#2019-11-1110:46thhellerthe error is in a internal JDK class, nothing to do with shadow-cljs as far as I can tell#2019-11-1110:47thhelleror does running lein or something work?#2019-11-1110:47thhellerseems like that would fail as well?#2019-11-1110:53ElirazI'm sorry. i'm new to all this.. lein with what command?#2019-11-1110:55thhellerjust lein repl maybe?#2019-11-1110:59ElirazI just downgraded from Java 13.0.1 to Java 11 and it compiles#2019-11-1110:59Elirazweird.#2019-11-1111:00thhellermaybe there was just something broken in your release#2019-11-1111:02thhellereverything from jdk8 upwards should work fine. I usually upgrade when a new release is out and never had issues with v13, but I haven't tried the latest#2019-11-1111:13Elirazhow would I fix the broken release?#2019-11-1111:15thhellerI don't know. there is a jdk-13.0.1+9 release. maybe that fixes it? or just try the regular 13, not 13.0.1?#2019-11-1111:15ElirazI actually got here to question about the workflow with emacs and CIDER, would you usually jack-in? or connect to a watch? how would you get auto-complete in the editor ?#2019-11-1111:15thhellerI've never seen this error before and a quick google suggests it isn't very common either#2019-11-1111:16thhellerI don't use emacs so can't comment on any workflow issues#2019-11-1111:16ElirazI'll try or I'll just wait for a new release, I don't really care what JAVA version I'm running as long as it compiles to JS 😛#2019-11-1111:17thhelleryeah doesn't matter as far as shadow-cljs is concerned either#2019-11-1111:52Eliraznow JAVA 11 also doesnt work anymore.. ?!!#2019-11-1111:53ElirazI don't know.. changing back to 13 and to 11 makes it work#2019-11-1111:55Elirazwhere is the HTML file? I can't find it anywhere?#2019-11-1112:51ElirazHow would I connect from the nRepl to the browser? I mean, trying to run this code: (js/console.log "dsad") is not working from nRepl beacuse it says there's no js namespace#2019-11-1113:00aisamuHave you picked a CLJS REPL env after connecting to the Clojure REPL?
shadow.user> (shadow/repl :test-dev)
To quit, type: :cljs/quit
[:selected :test-dev]
cljs.user>
#2019-11-1113:01ElirazI guess not. thank you!#2019-11-1113:05Elirazany of you is using hx instead of reagent?#2019-11-1113:41Elirazhow can you rebuild from repl after adding dependency from npm ?#2019-11-1113:52thhellerwhat do you mean?#2019-11-1113:52thheller"after adding dependency from npm" means you ran npm install the-thing?#2019-11-1114:03Elirazyes#2019-11-1114:04Elirazafter adding a library how would you rebuild from the repl?#2019-11-1114:31thheller@eliraz.kedmi please specfiy what you mean by "rebuild"#2019-11-1114:31thhellerdo you just want to use the library#2019-11-1114:31thhelleror did you already use it and upgraded the version?#2019-11-1114:32thhellerif you just want to use it (require '["the-thing" :as x])#2019-11-1114:32ElirazI mean, when I'm installing a new library via npm, I want to use it in my files..#2019-11-1114:32Elirazyes, but that requires recompile the app, isnt it?#2019-11-1114:33thhellerI have no idea what you are doing#2019-11-1114:33thhellerplease describe your setup#2019-11-1114:33thhellerwhat kind of setup do you have?#2019-11-1114:33thhellerbuild config etc?#2019-11-1114:33thhellerare you working on a browser build?#2019-11-1114:33thhelleror node?#2019-11-1114:33thhellerwhich REPL do you use?#2019-11-1114:33Elirazokay. say I have the app running in dev mode with repl on. and now I'm adding the Material-UI library..#2019-11-1114:34thhellerby "app" I'm going to assume that you have a build config with :target :browser?#2019-11-1114:34ElirazI can't just require the button from that library now, I need to quit the repl and rebuild it#2019-11-1114:34Elirazyes#2019-11-1114:34thhellerok and when you say REPL you did shadow-cljs cljs-repl the-build?#2019-11-1114:34Elirazoh okay hmm#2019-11-1114:35ElirazI just jack-in with CIDER#2019-11-1114:35thhellerok, that works too#2019-11-1114:35thhellerso you do (require '["@material/core" :as x]) or whatever the package for that is nowadays#2019-11-1114:36ElirazI'm guessing that you could run a command from the repl that stops the watch and restarts it#2019-11-1114:36thhellerno you don't need to staop any watch or anything#2019-11-1114:36Elirazwell. it doesn't work if I don't restart#2019-11-1114:37thhellerwell then tell me what it told you after you ran the require I just told you?#2019-11-1114:37Elirazan error saying you can't have an undefiend as a react element#2019-11-1114:37Elirazit's like it does't know that new package#2019-11-1114:38thhellerso you skipped 3 steps ahead already I guess?#2019-11-1114:38thhellerdid you run the require I told you?#2019-11-1114:38Elirazthat's the behavior in regular React application#2019-11-1114:38ElirazI didn't run in the repl#2019-11-1114:38ElirazI put it on the file#2019-11-1114:38Elirazlike so#2019-11-1114:38Eliraz`(:require ["@reach/router" :refer [Router]] ["@material-ui/core" :refer [Button]] [hx.hooks :as hooks] [hx.react :as hx :refer [defnc]]))(:require ["@reach/router" :refer [Router]] ["@material-ui/core" :refer [Button]] [hx.hooks :as hooks] [hx.react :as hx :refer [defnc]]))`#2019-11-1114:39Elirazthe material is the new package for instance..#2019-11-1114:39ElirazIt didn't work until I quit the repl and reconnected again#2019-11-1114:39thhellerok then try adding ["@material-ui/core" :as x :refer [Button]]#2019-11-1114:39thhellerand try (js/console.log "mui" x)#2019-11-1114:39thhellersee what that says#2019-11-1114:40Elirazit's already working. I just though you need to restart the watch somehow#2019-11-1114:40ElirazI guess it's not required?#2019-11-1114:40thhellerno, that is not required#2019-11-1114:40Elirazgot it.#2019-11-1114:41ElirazBTW what's the command that builds a single js bundle file?#2019-11-1114:41thhellershadow-cljs release your-build#2019-11-1114:42Elirazthank you.#2019-11-1114:46ElirazI'm transferring an existing project to clojurescript, I currently do that in a very idiomatic way, how would you recommend to take advantage of the clojurescript power? any good courses you know about?#2019-11-1120:05lilactownI'm backing off of attempting to add an option for shadow-cljs to reload the whole dependency tree of a changed ns. You're right it's the wrong way to approach this. We shouldn't hamstring our tools to make React happy. Also it doesn't fix REPL-driven development 😖#2019-11-1120:06lilactownInstead I'm going to hack on React to see if I can add a command to refresh the whole app#2019-11-1120:23thhelleryour react-refresh work triggered me to work on my vdom stuff again. got it into a state where I might start using it for some of the shadow-cljs UI stuff. would be nice to get rid of react completely 🙂#2019-11-1120:29lilactownExcited to see more!#2019-11-1120:29lilactownSvelte has interested me in what a React-less world might look like...#2019-11-1120:39thhellermy stuff is more like 50% svelte 50% react#2019-11-1120:40thhellernow also has "hooks" although kinda different. can't come up with a different name though 😛#2019-11-1120:51thhellermaybe you fine folks have an opinion on this. I'm trying to decide the best way to define event handlers in my library. the goal is to have events "declarative" in the code that generates the actual event. so instead of creating a function you just create a vector of data.#2019-11-1120:52thhellernot [:div {:on-click (fn [e] ...)}] but [:div {:on-click [::some-event! 1 2 3]]#2019-11-1120:52thhellerI'm not sure I want all events to go through one big multi-method#2019-11-1120:52thhellerso experimenting defining them in the component definition. currently at 2 different approaches#2019-11-1120:52thheller
(defc dummy1
  {:init-state {:num 0}
   ::inc!
   (fn [env e]
     (sac/swap-state! env update :num inc))}
  [props {:keys [num] :as state}]
  []

  (<< [:div
       [:button {:on-click [::inc!]} "click me: " num]]))

(defc dummy2
  {:init-state {:num 0}}
  [props {:keys [num] :as state}]
  [::inc!
   (fn [env e]
     (sac/swap-state! env update :num inc))]

  (<< [:div
       [:button {:on-click [::inc!]} "click me: " num]]))
#2019-11-1120:53thhellerthe second vector after [props state] is "magic" for hooks. you can think of it as a special let if that helps
(defc dummy2
  {:init-state {:num 0}}
  [props {:keys [num] :as state}]
  (let [::inc!
        (fn [env e]
          (sac/swap-state! env update :num inc))]

    (<< [:div
         [:button {:on-click [::inc!]} "click me: " num]])))
#2019-11-1120:54thhellerprobably doesn't make much sense to ask this without explaining how all of it works#2019-11-1120:55thheller
(defnc my-refreshed-component
  [props]
  (let [[count set-count] (react/useState 0)
        [name set-name] (react/useState "React Refresh")]
    ;; kept it's state!
    ($ react/Fragment
      ($ :div {:style {:background "pink"}}
        ($ :div (b/greet name))
        ($ :div ($ :button {:onClick #(set-count inc)} "+ " count))
        ($ :div ($ :input {:type "text"
                           :value name
                           :onChange #(set-name (.. % -target -value))})))
      ($ :br)
      ($ z/component {:name "child in another file"})
      ($ :br)
      ($ z/memo-component {:name "memoized child in another file"}))))

(defc my-refreshed-component [props]
  [[count set-count] (react/useState 0)
   [name set-name] (react/useState "React Refresh")
   ::inc! #(set-count inc)
   ::set-name! #(set-name (.. % -target -value))]
  (<< [:div {:style {:background "pink"}}
       [:div (b/greet name)]
       [:div [:button {:on-click [::inc!]} "+ " count]]
       [:div [:input {:type "text"
                      :value name
                      :on-change [::set-name!]}]]]
      [:br]
      [z/component {:name "child in another file"}]
      [:br]
      [z/memo-component {:name "memoized child in another file"}]))
#2019-11-1120:57thhellerbasically the first let you pretty much always have anyways becomes "special" with "hook" semantics#2019-11-1121:02thhellerbut yeah the functions definitely need to go.#2019-11-1121:16thhellermaybe I'll just allow both styles .. they aren't mutually exclusive 😛#2019-11-1121:26lilactownwhat’s the upsell for using keywords instead of a bound symbol for events?#2019-11-1121:28thhellercan't differentiate between a bound symbol and a function created inline via :on-click (fn [e] ...)#2019-11-1121:28thhellermust get rid of function creation inline since they are never identical?#2019-11-1121:29thhellerthe main reason is that I want declarative events though. easier to translate for server-rendered code if there isn't (fn [e] ...) all over the place#2019-11-1121:30lilactowngotcha#2019-11-1121:30lilactownI think having a special “let” block is nice for setup that gets run on each render. I keep dancing with the idea of creating my own special let macro for certain purposes#2019-11-1121:31thhellerno the point is that it DOESN'T run on each render#2019-11-1121:31thhellerthat is my main gripe with hooks. all shit runs all the time.#2019-11-1121:31lilactownhmm. how does it know when to re-run things?#2019-11-1121:31thhellermagic#2019-11-1121:32lilactownhaha#2019-11-1121:33lilactownFWIW, I think on the surface it’s feasible to do enough static analysis at macro-time to determine values (like functions) that could be automatically memoized to maintain identity across renders#2019-11-1121:33thhellerno need#2019-11-1121:33lilactownthat’s my eventual goal with hx#2019-11-1121:34lilactownright, I’m dealing with React 🙂 greenfield is another story!#2019-11-1121:34lilactownif you have some way of determining when e.g. an effect or render should trigger through some other means, like a signal graph, then you don’t need to call it on every render#2019-11-1121:35thhelleryep. the value returned by the "hook" functions can implement a protocol#2019-11-1121:35thhellerso basically they can tell the component to invalidate their value#2019-11-1121:36thhellerwhen they do all subsequent hooks that used the binding will also run#2019-11-1121:37thheller
(defc dummy3 [props]
  [a (subscribe [:bar])
   b (subscribe [:x a])]

  (<< [:div b]))
#2019-11-1121:37thhellerre-frame ish style is easy#2019-11-1121:37thhellerb only runs again if a changes#2019-11-1121:38thhellerif b doesn't change render is skipped because a isn't used in render#2019-11-1121:39thhellerb of course can invalidate itself but that won't affect a#2019-11-1121:39lilactownI think where the friction starts with that approach is when you want to do something like React’s Concurrent mode. you have to figure out where scheduling all the work occurs.#2019-11-1121:39thhellernope. easy#2019-11-1121:39thhellerwell, yes that is the hard part but everything is in place for it#2019-11-1121:41lilactownif you let every state be mutated and trigger a re-render ad-hoc, then you either need to implement scheduling in the signal graph (not the component tree like React has), or you risk having state and what’s rendered diverge in degenerate cases#2019-11-1121:42thheller
(defc dummy4 [{:keys [id] :as props}]
  [{:keys [text]}
   (-> (js/fetch (str "/some/" id))
       (.then #(.json %))
       (.then js->clj))]

  [:div text])
#2019-11-1121:42thhellerI have scheduling in the signal graph#2019-11-1121:44thhelleractually it is all a whole lot simpler than React overall since I can do magic like this#2019-11-1121:44thhellerthe code the macro generates wouldn't be feasible to write in react#2019-11-1121:44thhellerso the model they came up with only looks like that because it is something people can actually write#2019-11-1121:45thhelleralthough I'm not too convinced about that given the manual [all, the, deps] args you need to construct#2019-11-1121:46thhellerbut they are exploring babel plugins and shit like that for that if I read that correctly somewhere#2019-11-1121:46thhellerso basically we can skip all that shit because of macros#2019-11-1121:46lilactownscheduling is about more than just fetching data (though it helps a ton with that). it also has to do with things that take up a lot of CPU. Concurrent mode allows React to prioritize certain renders higher than others, pause or abort them and restart them later#2019-11-1121:46thhelleryes I know#2019-11-1121:46thhellerI can do that now#2019-11-1121:46lilactownyeah the deps args stuff with hooks is tiresome but something we can just compile away#2019-11-1121:47thhellerextremely easy since everything is immutable anyways#2019-11-1121:47thhellercomponnents add themselves to a dirty "set"#2019-11-1121:47thhellerthat set is processed in tree-depth order#2019-11-1121:47thhellerparent node can "suspend" child updates until all ready (at some point, still pending)#2019-11-1121:48thhellercan stop processing at any point since the scheduler controls all work done#2019-11-1121:48thhellerI'm familiar with how react works ... there isn't anything in there that this can't do eventually#2019-11-1121:49thhellerand I won't have to throw promises to stop processing something#2019-11-1121:49lilactownnice yeah, just trying to level set my understanding. this sounds really cool!
#2019-11-1121:54thhelleri have a working todomvc but need something more complex to test all this on#2019-11-1121:59lilactownI’ve been dog-fooding hx on my own REBL clone; sounds like shadow-cljs’ UI is a good use case 😄#2019-11-1122:00thhelleryeah just need to figure out how to get all the fulcro bits just without react 😉#2019-11-1122:01thhellerthe db normalization stuff is not actually something I want to write 😛#2019-11-1122:04nickmbaileyis there a way to make shadow-cljs export everything in my code that isn't marked as 'private'?#2019-11-1122:05nickmbaileyadding the ^:export metadata to everything seems a bit tedious or possibly brittle#2019-11-1122:05thhellerwhy do you want to export everything?#2019-11-1122:06nickmbaileyi'm using clojurescript to share schema code between the backend and frontend#2019-11-1122:06nickmbaileyso i'm consuming this from regular javascript#2019-11-1122:07nickmbaileyand basically every schema definition in a namespace should be available to the javascript consumer#2019-11-1122:07thhellerwhat is a schema definition?#2019-11-1122:08thhellerto answer your question: no there is no way to make it export everything currently but that doesn't mean the couldn't be 😉#2019-11-1122:08thhellerproblem with exporting everything is that it prevents DCE#2019-11-1122:08nickmbaileyhttps://github.com/plumatic/schema#2019-11-1122:08thhellerbut not the renaming of stuff#2019-11-1122:09nickmbaileya single schema definition is just a var#2019-11-1122:09thhellerbut how is that used from JS?#2019-11-1122:11nickmbaileywe end up with a namespace that has a bunch of 'schemas' like User, Email, BookingRecord...#2019-11-1122:11nickmbaileyand then from js we take json blobs and coerce/validate them against a given schema#2019-11-1122:12nickmbaileyso in js its 'import * as schema from 'schema.general' followed by 'coerce(jsonBlob, schema.BookingRecord);'#2019-11-1122:13nickmbailey(what acronym is DCE btw heh)#2019-11-1122:13thhellerwell you could do it in a build-hook but since none of the api for that is documented it wouldn't be too easy I guess 😛#2019-11-1122:14thhellerdead code elimination#2019-11-1122:14nickmbaileyaha#2019-11-1122:14nickmbaileyyeah we want to prevent that entirely#2019-11-1122:14nickmbaileysince this is like a utility library most of it will look 'dead'#2019-11-1122:15thhelleryeah#2019-11-1122:15nickmbaileywell i suppose i can add export tag to everything...#2019-11-1122:15thhellersimplest way might be a macro that just adds the export#2019-11-1122:15thhellerso instead of (def ^:export foo {...}) (defexported foo {...}#2019-11-1122:15thhellerbut that isn't exactly better#2019-11-1122:16nickmbaileywe've been using this for awhile, we were just using the 'compile' target instead of the 'release' target. i was trying to bring our bundle size down by switching to release and that breaks everything heh#2019-11-1122:16nickmbaileywell we actually wrote an internal macro for building most of these schemas#2019-11-1122:16thhelleryou can always use :optimizations :simple#2019-11-1122:16nickmbaileyso thats not a bad option actually#2019-11-1122:16thhellerthat'll still be alot smaller than compile and doesn't need ^:export#2019-11-1122:16nickmbaileyok let me try that#2019-11-1122:16thhellerbut I'd say just export stuff. can't be that many things 😛#2019-11-1122:17nickmbaileyheh#2019-11-1123:44Nolan@thheller i regularly have small isolated/contained front-end projects pop up, and very much enjoy experimenting with alternatives when youre looking for external feedback (`hx` is another im excited to play with @lilactown). events as vectors seems like it could lead to some interesting datalog compatibility… i appreciated a lot of the ideas in factui, but thats unmaintained last i checked#2019-11-1123:46thhellerI'll let you know as soon as I'm comfortable with the code. there are still some cases I want to figure out first#2019-11-1123:47Nolani know exactly what you mean—enjoy the process#2019-11-1123:48thheller40.9 KB todomvc build looks promising 🙂 no more chunky react-dom nonsense 😛#2019-11-1123:49Nolanhallelujah.#2019-11-1123:50thhellergoing through some of the advanced optimized code to find obvious code issues makes the appreciate the closure compiler so much more#2019-11-1123:50thhelleralways insane to see what kind of optimizations it does 🙂#2019-11-1123:54Nolani havent dug into the advanced output itself enough to build an intuition of what it really does, but the artifact size difference alone is enough to instill a deep sense of appreciation for whatever its up to down there#2019-11-1123:57thhellerI have a (deftype ComponentConfig [component-name ...]) so it is constructed as (def x (ComponentConfig. "some.ns/foo-bar" ...))#2019-11-1123:57thhellerthat name however is only used in debugging code which is all removed#2019-11-1123:57thhellerso closure strips the entire property from the generated object#2019-11-1123:57Nolan😂#2019-11-1123:58thhellerno trace left in release builds#2019-11-1200:00Nolansounds uncannily similar to what happens to type info in ocaml (and probably other HMs), only for JS, which only makes it that much more insane#2019-11-1200:01nickmbaileydoes clojurescript metadata have to be attached inline? attaching the export metadata with 'with-meta' or 'vary-meta' doesn't seem to work#2019-11-1200:01thheller@nickmbailey yes, needs to be completely static. are you trying to attach the export meta in a macro?#2019-11-1200:02nickmbaileyyep#2019-11-1200:02thhellerthen try
`(def ~(with-meta the-sym {:export true}) ...)
#2019-11-1200:08Drew VerleeWhats the best way to inspect props that are passed in a react app at run time. Assuming a typical shadow-cljs setup in development mode? 1. The browsers react "components" view seems munged by the clojurescript, as in you just get "Object". i suppose thats workable because you can open it up. 2. There are contexts where it seems hard to even print the state, possible due to this issue: https://github.com/binaryage/cljs-devtools/issues/25. Though the fix at leasts lets you print the props without an error.#2019-11-1200:09thhellerhttps://github.com/Lokeh/react-hmr-cljs/blob/master/src/react_hmr/react.cljs#L15-L19#2019-11-1200:09thhellerincluding that bit of code should make it work#2019-11-1200:09thhellermaybe? not sure#2019-11-1200:10thhelleroh thats also in the gh issue#2019-11-1200:11Drew Verleeyea. 🙂 .That lets me print the props, which might be as good as it gets and all i need in this case. I'm just curious if i should be looking elsewhere, as this issue would seem to be very common place.#2019-11-1200:12thhellerI just (js/console.log ...) them like normal#2019-11-1200:13thhellerI don't use cljs-devtools most of the time though#2019-11-1200:18lilactownwhat I typically do is navigate to the component in the React DevTools, then click the “bug” to log the component and it’s state / props to the console#2019-11-1200:19lilactownthheller, I’m curious what your thoughts are (if any) about “dynamic” code splitting#2019-11-1200:20lilactownit seems to be getting quite popular in e.g. webpack / parcel / etc. to determine how to split the bundle based on usage of dynamic import()#2019-11-1200:20lilactownI see the appeal, as setting up an entrypoint can be onerous if you want to just lazy load a component or whatever#2019-11-1200:21thhelleryeah dunno. I don't like it that much but it requires less config#2019-11-1200:21thhellerI don't like import() creeping into libraries though. that seems like a horrible idea#2019-11-1200:22thhellerconfiguring :modules can be quite tedious so I definitely see the appeal#2019-11-1200:22lilactownyes definitely. especially since it relies on bundler behavior. maybe once dynamic import is in most browsers… but even then, dynamically importing a lib could cause a cascade of :poop: 😵#2019-11-1200:22thhelleryeah I don't like libraries deciding that my code should be split#2019-11-1200:23lilactownyeah. I’m wondering if there could be a way to macro-away some of the pain of :modules. I assume it would rely on something shadow-cljs specific…#2019-11-1200:24thhellerI experimented with a bunch of things a while ago but really the coming up with a good "graph" is the problem#2019-11-1200:24thhellerI certainly don't know enough graph stuff to figure that out 😛#2019-11-1200:24lilactownhehehe#2019-11-1200:25thhellerI kinda like that I can configure my modules how I like and fine tune when needed#2019-11-1200:25thhellerwith "automatic" webpack style config everything is kinda random and all sorts of weird sized chunks#2019-11-1200:25Nolanwhat would be neat is a cli tool that would do all the neato graph analysis and make a recommendation#2019-11-1200:26thhellerindeed. build that now please 🙂#2019-11-1200:29Nolanyeah, id love that. if only i knew literally anything about graphs#2019-11-1200:33lilactownI wish there was a way to at least separate the code you write to import from the module config#2019-11-1200:34lilactownOr is that what shadow.loader does now?#2019-11-1200:34thhellerhmm?#2019-11-1200:34thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2019-11-1200:34thhellerthat is the latest bit of "sugar", so you don't have any references of "modules" in your code. don't need to remember what something is in#2019-11-1200:37lilactownRight yes. I remember I wrote a bunch of module loader sugar for my last employer before that existed#2019-11-1200:38lilactownI didn't quite get to the point of resolving which module an ns existed in though#2019-11-1211:19levitanongshadow-cljs build hooks can specify what compilation stage they are relevant in, via shadow.build/stage. Is there additional support for other things like shadow.build/mode to control whether or not the hook activates in dev mode or release mode?#2019-11-1211:20thhellerjust check it in the build hook and do nothing if it doesn't match your intended mode#2019-11-1211:22levitanongYeah that was my fallback. Was curious 😅#2019-11-1211:27levitanong@thheller I’m getting warnings about the absence of refactor-nrepl and cider-nrepl when compiling from a clojure (i.e. starting the shadow-cljs server and compiling stuff). It doesn’t seem to stop me from compiling, but I just want to make sure with you what’s happening there. Like, should I actually require those two libs when compiling?#2019-11-1211:28thhellershadow-cljs doesn't use any of that#2019-11-1211:29thhellerit is probably your nrepl config#2019-11-1211:29levitanongAlright, cool. Thanks!#2019-11-1213:04orestisMuch as I love looking at efforts to do away with React, then I remember how much work is to actually produce a nice drag-and-drop component like react-beautiful-dnd and cry in my coffee.#2019-11-1213:14thhellerit is nice to tap into the react ecosystem sometimes ... but in my experience that has been more trouble than actual benefit. constantly breaking packages/apis or just overly bloated packages.#2019-11-1214:33orestisYeah, I’m in this situation. I decided to drop to the React ecosystem only when strictly necessary, even we end up with a bunch of “NIH” stuff. The recent hooks work has finally allowed us to make use of smaller dependencies that we could easily rewrite if we ever wanted to. Instead of relying, say, on the steaming pile of react-bootstrap.#2019-11-1213:16levitanong@thheller sorry to be bothering you so much. When I set :prepend on a build hook, the compiler seems to ignore it and compile the js with the previous value of :prepend. So if it’s unset, nothing is prepended. If it’s some value, it’ll be that value. Is this use case explicitly unsupported by build hooks?#2019-11-1213:17thhellerwhere do you set the :prepend? likely just in the wrong place#2019-11-1213:17levitanong@thheller (assoc-in build-state [:shadow.build/config :modules :main :prepend] licenses)#2019-11-1213:18thhellerand in which stage?#2019-11-1213:18levitanongI’ve tried it in both :configure and :compile-prepare#2019-11-1213:18levitanongneither seems to work#2019-11-1213:19thhellerright. hooks run after the original code#2019-11-1213:19thhellerso the :configure stage will already configure the modules#2019-11-1213:21thhellerso to adjust the config after the fact you have to dig a bit deeper#2019-11-1213:21thhelleror actually not that deep#2019-11-1213:21levitanongSo before this, I’ve been running a tools deps alias, modifying the config before calling release#2019-11-1213:22thheller(assoc-in build-state [:shadow.build.modules/modules :main :prepend] licenses)#2019-11-1213:22thhellerI think#2019-11-1213:22levitanongoh! i’ll try that 😄#2019-11-1213:24thheller:prepend-js would be a bit more complicated but :prepend should work like that#2019-11-1213:24thhellermaybe try update-in, just so it doesn't overwrite if something is already there#2019-11-1213:25levitanong@thheller doesn’t work yet 😞#2019-11-1213:26levitanongCould it be :shadow.build.closure/modules?#2019-11-1213:26thhellerthis is a :browser target right?#2019-11-1213:26thhellerclosure modules shouldn't be there yet?#2019-11-1213:26levitanongyup!#2019-11-1213:27thhellerthats after optimizations#2019-11-1213:29thheller:shadow.build.closure/modules is a copy of :shadow.build.modules/modules after optimizations. since that can adjust things#2019-11-1213:30thhelleroh wait .. it is the :build-modules#2019-11-1213:30thhellerwhich is a sorted vector of the modules#2019-11-1213:30thhellerdamn there are really too many places modules is used. should clean that up.#2019-11-1213:31thheller(assoc-in build-state [:build-modules 0 :prepend] licenses)#2019-11-1213:31levitanongthere’s also a :shadow.build.modules/config with similar looking stuff 😄#2019-11-1213:31levitanongoof, modifying a vector index is a little scary#2019-11-1213:31thhellerwell you can find it by :module-id#2019-11-1213:33thhellerbut 0 will always be the first base module with no dependencies#2019-11-1213:35levitanongtrying it out#2019-11-1213:36thhellerjust don't change the order or things will go bad 😛#2019-11-1213:39levitanongI tried (assoc-in build-state [:build-modules 0 :prepend] licenses) and it still doesn’t work. I ran (keys build-state) and I can’t find any :build-modules in the list. Could it be that my version is too old? I’m on 2.8.66, and when i checked the recent commits, there was nothing that jumped out at me that signaled that i needed to update.#2019-11-1213:39thhellerno that hasn't changed in years#2019-11-1213:39thhellerwhich stage?#2019-11-1213:40levitanong:configure#2019-11-1213:40thhellertry :compile-prepare#2019-11-1213:42thhellermodule config is actually done after configure. so :shadow.build.modules/config should have worked?#2019-11-1213:42thhelleroh doh .. I gave you the wrong key I think. should be :shadow.build.modules/config not :shadow.build.modules/modules#2019-11-1213:44thhelleryeah definnitely too many places where that config is kept 😛#2019-11-1213:45levitanonghahaha this is hilarious.#2019-11-1213:45levitanongOkay, so :build-modules works in :compile-prepare. Will try it out in :shadow.build.modules/config now#2019-11-1213:46thhellerit goes from the build config -> :shadow.build.modules/config. then after configure they are sorted and :build-modules is created (no longer a map)#2019-11-1213:46thhelleroptimize takes :build-modules and creates :shadow.build.closure/modules (including some of the GCC compiler data) otherwise the same#2019-11-1213:47thheller:flush then takes either of those keys to flush the output but :prepend must be set before so it doesn't mess with the source maps#2019-11-1213:48thhellerso is must happen before :optimize-prepare#2019-11-1213:50levitanongThat does feel quite convoluted 😅#2019-11-1213:51coder46334Hi! When I start shadow-cljs with :browser-test , insead of :app, my spec instrumentation doesn't work. The specs work with (exercise fully-qualified-ns/spec), but I can't instrument functions either through code or repl. Any ideas? I don't even know where to look#2019-11-1213:51levitanong@thheller okay, can confirm, :shadow.build.modules/config works when i do it in :configure#2019-11-1213:54levitanong@thheller thanks for the help!#2019-11-1216:44devirr@publicz try version 2.8.60. instrument and check works for me on that version. but when I upgrade it does not.#2019-11-1314:11coder46334Thanks, I'll try!#2019-11-1216:54thhellerwhat is the particular problem with instrument? I never use it myself but I'm not aware of anything that would have changed its behavior since 2.8.60?#2019-11-1216:57mruzekwI have a :node-library that I’d like to play with in a REPL, but I’m unsure how to load it#2019-11-1216:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2019-11-1216:59thhellermost likely shadow-cljs node-repl is good enough#2019-11-1217:00mruzekwI used that command, but when I (require 'myapp.backend.parser) It says it can’t find it#2019-11-1217:00thhellerwhat does it say exactly?#2019-11-1217:00mruzekw
{:type clojure.lang.ExceptionInfo
   :message "The required namespace \"myapp.backend.parser\" is not available, it was required by \"cljs/user.cljs\"."
   :data {:tag :shadow.build.resolve/missing-ns,
#2019-11-1217:01thhellerand that namespace does actually exist?#2019-11-1217:01thhellerie. :source-paths ["src/main"] and src/main/myapp/backend/parser.cljs#2019-11-1217:02thheller(or whatever setup you use for managing :source-paths)#2019-11-1217:02mruzekwUgh…the file is where it should be but I didn’t name the namespace correctly in the actual file :man-facepalming:#2019-11-1217:04mruzekwThank you#2019-11-1218:19wilkerluciotrying to start a new project here, using deps, but for reason I'm getting
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

#2019-11-1218:19wilkerlucioshadow 2.8.69#2019-11-1218:20lilactownadd thheller/shadow-cljs to your deps#2019-11-1218:20wilkerluciois this a new thing? I'm looking at old projects, it wasnt needed before#2019-11-1218:20lilactownthe npm module no longer adds itself to the classpath if you’re using deps.edn or leiningen#2019-11-1218:20lilactownyes, I think it was added in 2.8.60 or around there#2019-11-1218:20wilkerluciothanks!#2019-11-1218:49nickmbailey@thheller i got the export metadata addition working with a macro btw. thanks for the help#2019-11-1218:50nickmbaileydoes the googe closure compilation eliminate unused code from clojurescript core too?#2019-11-1218:50thhelleryep#2019-11-1218:50nickmbaileysweet#2019-11-1219:50devirr@thheller I got an require error on versions 2.8.61 and 2.8.64 (:target :node-script) when running cljs.spec.test.alpha/check but just tried on 2.8.69 and it works again. Sorry for the inconvenience#2019-11-1222:21rafhi there! first of all - thanks @thheller for the shadow-cljs - this tool makes working with ClojureScript a pleasure! second, I have some wired behavior when I start shadow-cljs from VS Code (and Calva). At first everything look OK, source code compile, server is starting (and I can see my app), but then when I change my file and save it I get such error message in the terminal: `Evaluating file: fire.cljs no source by id: [:shadow.build.classpath/resource "project/fire.cljs"] {:id [:shadow.build.classpath/resource "project/fire.cljs"]} ExceptionInfo: no source by id: [:shadow.build.classpath/resource "project/fire.cljs"] shadow.build.data/get-source-by-id (data.clj:167) shadow.build.data/get-source-by-id (data.clj:164) shadow.build.compiler/remove-dead-js-deps/remove-fn--12063/fn--12064 (compiler.clj:1089) clojure.core/complement/fn--5669 (core.clj:1441) clojure.core/filter/fn--5893 (core.clj:2817) clojure.lang.LazySeq.sval (LazySeq.java:42) clojure.lang.LazySeq.seq (LazySeq.java:51) clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59) clojure.core/chunk-next (core.clj:708) clojure.core.protocols/fn--8154 (protocols.clj:137) clojure.core.protocols/fn--8154 (protocols.clj:124) clojure.core.protocols/fn--8114/G--8109--8123 (protocols.clj:19) clojure.core.protocols/seq-reduce (protocols.clj:31) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/reduce (core.clj:6828) clojure.core/into (core.clj:6895) clojure.core/into (core.clj:6887) shadow.build.compiler/remove-dead-js-deps/remove-fn--12063 (compiler.clj:1091) clojure.core/update (core.clj:6196) clojure.core/update (core.clj:6188) shadow.build.compiler/remove-dead-js-deps/fn--12068/fn--12069 (compiler.clj:1097) clojure.core/map/fn--5866 (core.clj:2753) clojure.lang.LazySeq.sval (LazySeq.java:42) clojure.lang.LazySeq.seq (LazySeq.java:51) clojure.lang.RT.seq (RT.java:535) clojure.core/seq--5402 (core.clj:137) clojure.core.protocols/seq-reduce (protocols.clj:24) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8146 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/reduce (core.clj:6828) clojure.core/into (core.clj:6895) clojure.core/into (core.clj:6887) shadow.build.compiler/remove-dead-js-deps/fn--12068 (compiler.clj:1098) clojure.core/update (core.clj:6196) clojure.core/update (core.clj:6188) shadow.build.compiler/remove-dead-js-deps (compiler.clj:1095) shadow.build.compiler/remove-dead-js-deps (compiler.clj:1084) shadow.build.compiler/compile-all (compiler.clj:1347) shadow.build.compiler/compile-all (compiler.clj:1194) shadow.build.api/compile-sources (api.clj:256) shadow.build.api/compile-sources (api.clj:248) shadow.build.api/compile-sources (api.clj:260) shadow.build.api/compile-sources (api.clj:248) shadow.cljs.repl/repl-load-file* (repl.clj:292) shadow.cljs.repl/repl-load-file* (repl.clj:232) shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:832) shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:792) shadow.cljs.devtools.server.worker.impl/fn--13594 (impl.clj:876) shadow.cljs.devtools.server.worker.impl/fn--13594 (impl.clj:875) clojure.lang.MultiFn.invoke (MultiFn.java:234) shadow.cljs.devtools.server.util/server-thread/fn--13177/fn--13178/fn--13186 (util.clj:285) shadow.cljs.devtools.server.util/server-thread/fn--13177/fn--13178 (util.clj:284) shadow.cljs.devtools.server.util/server-thread/fn--13177 (util.clj:257) java.lang.Thread.run (Thread.java:834)` any ideas what am I doing wrong?#2019-11-1222:24rafI use the :browser target with only shadow-cljs.edn file (without lein)#2019-11-1300:37Drew Verleewhat does your shadow-cljs.edn file look like?#2019-11-1300:38Drew VerleeI feel this is a classpath or organizational issue. As in, maybe the build-id of the app isn't what your telling your repl to look for.#2019-11-1307:23rafHello 🙂#2019-11-1307:23rafthe shadow-cljs.edn looks so:#2019-11-1307:23raf{:source-paths ["src/dev" "src/main" "src/functions" "src/tools" "src/test"] :dependencies [[binaryage/devtools "0.9.10"] [reagent "0.8.1" :exclusions [cljsjs/react]] [re-frame "0.10.9" :exclusions [cljsjs/react]] ; [day8.re-frame/http-fx "v0.2.0"] [secretary "1.2.3"] [cljs-bean "1.5.0"] ;;https://github.com/mfikes/cljs-bean [cider/cider-nrepl "0.22.4"] [testdouble/clojurescript.csv "0.4.5"] ] ; :nrepl {:port 8777} :builds {:app {:target :browser :output-dir "public/js" :asset-path "/js" :modules {:app {:init-fn project.core/init :preloads [devtools.preload]}} :devtools {:http-root "public" :http-port 8000}} :browser-test {:target :browser-test :ns-regexp "-test$" :runner-ns shadow.test.browser :test-dir "tests/browser-test" :devtools {:http-root "target/browser-test" :http-port 8290}} :karma-test {:target :karma :ns-regexp "-test$" :output-to "tests/karma-test.js"} :functions {:target :node-library :output-to "functions/cljs-libs.js" :exports-var project.cloud-functions/declaration} :tools {:target :node-script :output-to "tools/tools.js" :main project.tools/main}}}#2019-11-1307:24raffor info, my shadow-cljs.edn looks so:#2019-11-1307:24raf{:source-paths ["src/dev" "src/main" "src/functions" "src/tools" "src/test"] :dependencies [[binaryage/devtools "0.9.10"] [reagent "0.8.1" :exclusions [cljsjs/react]] [re-frame "0.10.9" :exclusions [cljsjs/react]] ; [day8.re-frame/http-fx "v0.2.0"] [secretary "1.2.3"] [cljs-bean "1.5.0"] ;;https://github.com/mfikes/cljs-bean [cider/cider-nrepl "0.22.4"] [testdouble/clojurescript.csv "0.4.5"] ] ; :nrepl {:port 8777} :builds {:app {:target :browser :output-dir "public/js" :asset-path "/js" :modules {:app {:init-fn project.core/init :preloads [devtools.preload]}} :devtools {:http-root "public" :http-port 8000}} :browser-test {:target :browser-test :ns-regexp "-test$" :runner-ns shadow.test.browser :test-dir "tests/browser-test" :devtools {:http-root "target/browser-test" :http-port 8290}} :karma-test {:target :karma :ns-regexp "-test$" :output-to "tests/karma-test.js"} :functions {:target :node-library :output-to "functions/cljs-libs.js" :exports-var project.cloud-functions/declaration} :tools {:target :node-script :output-to "tools/tools.js" :main project.tools/main}}}#2019-11-1311:32thheller@raf I'm not sure what is going on. can you please post a regular github issue so I don't forget looking into it?#2019-11-1311:43raf@thheller sure, I will do that! thanks for looking at it 🙂#2019-11-1312:02sooheonWhen loading NPM packages the shadow way (i.e. (:require ["foo" :as foo])) I’m getting a spec error trying to load it into a repl:
Syntax error macroexpanding clojure.core/ns at (src/workspaces/app/demo_ws.cljs:1:1).
-- Syntax error -------------------

  (... (:require
        [com.fulcrologic.fulcro.components :as fp]
        [nubank.workspaces.core :as ws]
        [nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
        [com.fulcrologic.fulcro.mutations :as fm]
        [com.fulcrologic.fulcro.dom :as dom]
        ["reakit" :as rk]))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input

-- Relevant specs -------

:clojure.core.specs.alpha/ns-form:
  (clojure.spec.alpha/cat
   :ns-name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :attr-map
   (clojure.spec.alpha/? clojure.core/map?)
   :ns-clauses
   :clojure.core.specs.alpha/ns-clauses)

-------------------------
Detected 1 error
#2019-11-1312:02sooheonSeems like it’s because clojure does not expect strings in there. Is this expected?#2019-11-1312:02thhellerlooks like you are trying to eval CLJS in a CLJ REPL#2019-11-1312:03sooheonI’m pretty sure this is after running (shadow/repl :main)#2019-11-1312:03sooheonAnd the cursive repl window cljs is selected.#2019-11-1312:03thhellertry (js/alert "foo")#2019-11-1312:03thhellerif it complains about js namespace then you are in a CLJ REPL#2019-11-1312:07sooheonAh thanks, I must have messed up repl state somewhere. Restarting everything and making sure i”m in cljs repl fixed it#2019-11-1312:06vinurshow to require
import Storage from 'react-native-storage';
in cljs, i use [“react-native-storage” :default Storage], but the browser output
shadow-cljs - failed to load module$node_modules$react_native_storage$lib$storage_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
eval @ /js/compiled/cljs-runtime/core.js:6
goog.globalEval @ app.js:836
env.evalLoad @ app.js:2216
(anonymous) @ app.js:2901
#2019-11-1312:06thhellerthat doesn't look like a react-native app?#2019-11-1312:07thhellerwhat is the actual error though? this just tells you WHY failed to load, not why. the why is a different error?#2019-11-1312:07vinursthis library also can used in web#2019-11-1312:08thhellerwell what is the error then? looks like it doesn't#2019-11-1312:08vinursi just require it, and then output the message#2019-11-1312:09thhelleryes but there should be MORE errors. not just that one#2019-11-1312:09vinurs#2019-11-1312:10thhellerexactly#2019-11-1312:10vinurs
(ns core
  (:require [reagent.core :as r]
            [starter.browser]
            [utils.login]
            ["react-native-storage" :default Storage]
            [pages.dashboard.questionnaire]))


(defn ^:export init
  "auto init"
  []
  (let []
    (prn "thit is cljs init" ))
  )
#2019-11-1312:10thhellerregeneratorRuntime is not defined is the actual error#2019-11-1312:10thhellerI can't remember how to fix that. need to include some "regenerator/runtime" package or so manually#2019-11-1312:11thhellerits some babel bs#2019-11-1312:21vinursi install regenerator-runtime, and require it, ok now, thanks#2019-11-1312:11raf@thheller I've created the issue: https://github.com/thheller/shadow-cljs/issues/591#2019-11-1312:26sooheon@thheller there is of course nothing to be done for symbol resolution in cursive (or emacs) using shadow-style imports, correct? when people develop with js-land deps, there’s no code knowledge/goto/navigation?#2019-11-1312:34thhellernot that I'm aware of#2019-11-1312:59sooheonDo you know why loading the ns form might be returning twice?#2019-11-1313:00thhellerprobably not filtering events correctly. the ns form evaluated at the REPL has multiple effects#2019-11-1313:00thhellereach effect has a return value#2019-11-1313:00thhellerin this case first it is loading the async dependencies#2019-11-1313:00thhellerthen doing the JS stuff#2019-11-1313:02sooheonah ok#2019-11-1313:34Michael MackenzieI can't seem to reload namespaces in the REPL in my clojurescript app. Here's what I do (after running (shadow/repl :app) to enter in to the CLJS repl):
(use 'getfluentspanish.dom :reload)
Error in phase :compilation
Only [lib.ns :only (names)] and optionally `:rename {from to}` specs supported in :use / :use-macros; offending spec: [getfluentspanish.dom] at line 1 cljs/user.cljs
#2019-11-1313:35Michael Mackenzieit seems like namespaces just work way differently in the cljs repl#2019-11-1313:35Michael Mackenzie*ns* doesn't work either#2019-11-1313:35thhellerthey work very differently yes#2019-11-1313:35Michael Mackenzieis there a guide anywhere?#2019-11-1313:35thheller(require '[the.ns :as x] :reload) should work#2019-11-1313:35thhelleruse is generally not used in CLJS#2019-11-1313:40Michael Mackenzieit doesn't error out now, but it doesn't seem to reload#2019-11-1313:40thhellernow that I think about it .. it isn't even implement in the shadow-cljs REPL 😛#2019-11-1313:41Michael Mackenzielike i add new code, i see that it compiles in the shadow watcher, but the new code isn't available#2019-11-1313:41thhellerrequire should be working though. most people just use the hot-reload though#2019-11-1313:41thhellerhow are you using it?#2019-11-1313:42Michael Mackenzie(require '[getfluentspanish.dom :as dom] :reload)#2019-11-1313:42Michael Mackenzieadded a new function, it's just nil in the repl after#2019-11-1313:42thhellerno I mean how do you tell that the new code isn't available?#2019-11-1313:43Michael Mackenziein repl after reloading: dom/new-function --> nil#2019-11-1313:43Michael Mackenzienot calling it, just evaluating the symbol#2019-11-1313:43Michael Mackenzieand it says it's nil#2019-11-1313:43Michael Mackenzieand changes to another existing function don't show up#2019-11-1313:44Michael Mackenziei added some log lines and they only show up when i restart the terminal pane i have running lein shadow watch app, refresh the browser tab and restart the repl#2019-11-1313:44thhelleruhm I'm confused#2019-11-1313:44thhelleryou are using hot-reload and the REPL?#2019-11-1313:45Michael Mackenzie@thheller just found your post (https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html) and will definitely give this a read as well#2019-11-1313:45thhellerif the hot-reload already loads the code you don't need to reload it in the REPL?#2019-11-1313:45Michael Mackenziewell i don't have automatic reloading in the repl#2019-11-1313:45Michael Mackenziemy code recompiles#2019-11-1313:45Michael Mackenzievia lein shadow watch app#2019-11-1313:46Michael Mackenziei.e. i make changes, the browser reloads my code automatically#2019-11-1313:46thhellerand you REPL into app?#2019-11-1313:46Michael Mackenziebut my repl has a stale version#2019-11-1313:46Michael Mackenzieyes#2019-11-1313:46thhellerthen it will have the updated code#2019-11-1313:46thhelleralways#2019-11-1313:46Michael Mackenzie(shadow/repl :app)#2019-11-1313:46thheller(without you doing anything in the REPL)#2019-11-1313:47Michael Mackenzieunfortunately that doesn't seem to be happening#2019-11-1313:48thhellerunless you are on some ancient version it kinda can't not happen#2019-11-1313:48Michael Mackenzielet me take a look:#2019-11-1313:48thhellerreload loads the namespace#2019-11-1313:49thhelleryou can just use getfluentspanish.dom/new-function directly in the REPL#2019-11-1313:49Michael Mackenzie[thheller/shadow-cljs "2.8.39" :scope "provided"]#2019-11-1313:49thhellerthat is rather old#2019-11-1313:49Michael Mackenzieok i'll try updating#2019-11-1313:49thheller2.8.69 is latest#2019-11-1313:49thhellerbut pretty sure all of that also worked in that version#2019-11-1313:50Michael Mackenziei'll try bumping#2019-11-1313:56Michael Mackenziebumped the version and still not seeing updates within the repl#2019-11-1314:01Michael Mackenzieit seems like it's only happening with some namespaces#2019-11-1314:02Michael Mackenziethis "dom" namespace is new - i hadn't actually included it elsewhere in the project#2019-11-1314:02Michael Mackenziei was just manually playing with a new function in the REPL#2019-11-1314:03Michael Mackenziebut for example when i make changes to a namespace that contains a bunch of reagent components that are actually used on the website i'm developing, it: - is updated in the browser - automatically updates in the REPL#2019-11-1314:04Michael Mackenziemaybe it needs to be loaded by the browser to participate in the auto reload functionality?#2019-11-1314:06Michael Mackenzie@thheller that's the problem. once i included in a file loaded by the browser, it started to auto-reload#2019-11-1316:09Filipe Silvaheya#2019-11-1316:09Filipe SilvaI was trying to use devcards with shadow-cljs and finding it a bit hard to find information about that...#2019-11-1316:10Filipe Silvain https://clojurians-log.clojureverse.org/shadow-cljs/2018-04-01 there's some messages from 2018 that say it's mostly just importing devcards with macros, and then set the devcards compiler option to true#2019-11-1316:11Filipe Silvafrom that starting point the compilation works, but at runtime there's a couple of console warnings and nothings shows on screen#2019-11-1316:11Filipe Silva
main.js:2218 failed to load devcards.system.js ReferenceError: React is not defined
    at eval (system.cljs:321)
    at eval (system.cljs:321)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:836)
    at Object.env.evalLoad (main.js:2216)
    at main.js:2413
env.evalLoad @ main.js:2218
(anonymous) @ main.js:2413
main.js:2218 failed to load devcards.core.js ReferenceError: React is not defined
    at eval (core.cljs:117)
    at eval (core.cljs:117)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:836)
    at Object.env.evalLoad (main.js:2216)
    at main.js:2418
#2019-11-1316:12Filipe Silvathat namespace belongs to devcards, and points to this function#2019-11-1316:12Filipe Silva
(define-react-class DevcardsRoot
  (componentDidMount
   [this]
   (add-watch app-state :renderer-watch (fn [_ _ _ _] (.forceUpdate this))))
  (render [this] (main-template app-state)))
#2019-11-1316:13thheller@mike.a.mackenzie yes sorry, hot-reload only reloads sources actually used in the build. for the rest the regular REPL workflow should still work though.#2019-11-1316:13thheller@filipematossilva you can probably get away with importing cljsjs.react. that will create the React global#2019-11-1316:14Filipe Silvashould I be using shadow-cljsjs? I saw some references to it in https://github.com/bhauman/devcards/issues/156 but I couldn't figure out how I should use it#2019-11-1316:15thhellerthe problem you see is that devcards assumes there is a React global, because it was always there when using cljsjs.react#2019-11-1316:16thhellershadow-cljsjs provides shims to emulate that#2019-11-1316:16thhellershadow-cljs already depends on it, so it is always there. no need for you do do anything except add a cljsjs.react require somewhere#2019-11-1316:17Filipe Silvaok#2019-11-1316:17Filipe Silvadoing so shows an error that seems similar#2019-11-1316:17Filipe Silva
system.cljs:334 Uncaught ReferenceError: ReactDOM is not defined
    at Object.devcards$system$renderer [as renderer] (system.cljs:334)
    at eval (system.cljs:458)
#2019-11-1316:17thhellersame thing#2019-11-1316:17thhellercljsjs.react.dom#2019-11-1316:17Filipe Silvaah I tried [cljsjs.react-dom] and that failed, so that's it#2019-11-1316:18thhellerI don't know why devcards doesn't depend on those to ensure they exist#2019-11-1316:18thhelleryou might want to try https://github.com/nubank/workspaces#2019-11-1316:18Filipe SilvaI now see an UI with things that seem from devcards so it looks like it is loaded, will poke around more#2019-11-1316:19Filipe Silvathank you for your help#2019-11-1316:41Filipe Silvayeap, all well and good, uploaded it as https://github.com/filipesilva/shadow-cljs-devcards#2019-11-1316:48conanhello, i'm trying to get going with shadow-cljs and Cursive. I'm trying to re-create my old figwheel config, where I had a run configuration that would start figwheel in a Cursive REPL - one click, all in. I've got two problems: 1. I can't figure out how to start a cljs REPL instead of a clj one 2. I can't figure out how to start shadow in my run configuration I'm hoping there's somebody here who uses Cursive and might be able to help?#2019-11-1316:50thhellerI use Cursive myself. what was your figwheel setup?#2019-11-1316:52thhelleryou start a CLJS repl from a CLJ one#2019-11-1316:52thhellerso you connect to the CLJ REPL shadow-cljs provides
#2019-11-1316:52thhellerthen (shadow/repl :your-build) and that switches you to CLJS#2019-11-1316:53thhellerbind that do a custom REPL keybinding and you have your one click?#2019-11-1316:54conanI use a little script to kick everything off, by passing it in the parameters of a run configuration:
;; 
(require '[figwheel.main.api :as fig])
(fig/start "app")
#2019-11-1316:54conanWe do a lot of prototyping, which means changing deps. My goal is to restart a CLJS REPL in a single click#2019-11-1316:55thhellerand how did you run that script?#2019-11-1316:55conanCurrently, I'm only able to run shadow-cljs from a terminal, which means I have to go over there, kill the process, restart and so on#2019-11-1316:55conanThat script gets run by the Run Configuration, it's in the parameters field#2019-11-1316:55thhellerI mean how do you get a REPL?#2019-11-1316:56conan#2019-11-1316:56thhellerah so just a clojure.main REPL? no nrepl?#2019-11-1316:56conanSorry, I'm not sure I understand the question. I click the green Run arrow on my build configuration, and Cursive spins one up for me - compiling all the stuff on the way#2019-11-1316:56conanno, no nREPL#2019-11-1316:56conanthat's important, as it cuts down on a lot of starting/stopping stuff#2019-11-1316:57thheller
(require '[shadow.cljs.devtools.server :as server])
(require '[shadow.cljs.devtools.cli]) ;; if you want to use the shadow-cljs command line tools 
(require '[shadow.cljs.devtools.api :as api])
(server/start!)
(api/watch :app)
(api/repl :app)
#2019-11-1316:57conanah, yes this looks like what I need!#2019-11-1317:01conanjust trying it now#2019-11-1317:01thhellerdon't really recommend running that way but works if you have to 😛#2019-11-1317:01conanout of interest, why not?#2019-11-1317:02thhellertakes almost twice as long to start when going through lein#2019-11-1317:02conanI haven't been able to avoid that given that I'm using :lein true in my config#2019-11-1317:03conanI don't want to split out my frontend from my backend, and leiningen seems like the easiest way to keep it all together#2019-11-1317:04thhellerdo you not use a REPL for your backend?#2019-11-1317:07conanyes, i have a separate run config for that#2019-11-1317:07thhellerso you already have 2 separate JVMs anyways#2019-11-1317:07conanyep#2019-11-1317:08thhellerand I assume you have your CLJS dependencies in some extra profile?#2019-11-1317:08thheller:dev or :cljs or so?#2019-11-1317:09conanyes, currently i've put them in the :dev profile, although i actually wasn't sure about that#2019-11-1317:10conanok, it seems this works. i get a lot of :failed-to-compare errors, but the build still completes successfully#2019-11-1317:11conanlooks like something to do with check_npm_versions#2019-11-1317:11conanwould it be useful to write some docs to explain this and send a PR?#2019-11-1317:12thhellerdo you have an example?#2019-11-1317:14conan#2019-11-1317:14conangot over a hundred of 'em#2019-11-1317:17thhellerthats not normal#2019-11-1317:17thhellerwhat JVM do you run?#2019-11-1317:17conanJava 1.8.0_222 OpenJDK 64-Bit Server VM#2019-11-1317:17conanoh wait#2019-11-1317:18conansorry that was my ubuntu one. i run cursive in windows#2019-11-1317:18conanwindows is this: java version "1.8.0_202" Java(TM) SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)#2019-11-1317:18thhellerseems like nashorn is missing?#2019-11-1317:19conaner, what's that?#2019-11-1317:19conanoh ok, a javascript runtime that runs on the jvm#2019-11-1317:19thhellerthat seems to return nil? can you check in a CLJ REPL?#2019-11-1317:19thhellerhttps://github.com/thheller/shadow-cljs/blob/60e0966f1ec087eb6aba06b1fde9e93f9a10ab46/src/main/shadow/cljs/devtools/server/npm_deps.clj#L24-L30#2019-11-1317:20thhelleryes, a JS engine#2019-11-1317:20thheller(require '[shadow.cljs.devtools.server.npm-deps :as x])#2019-11-1317:20thheller(x/make-engine*)#2019-11-1317:20thhellerjust to verify that it actually returns nil?#2019-11-1317:21conanyeah i get nil from a clj REPL, although it was started with leiningen#2019-11-1317:21thhellerhmm weird. that should definitely work in jdk 1.8#2019-11-1317:22thhelleroh is it possible your are just running the JRE? not the JDK?#2019-11-1317:23conanthe REPL starts with "C:\Program Files\Java\jdk1.8.0_202\bin\java.exe"#2019-11-1317:24conanso it's a JDK#2019-11-1317:24thhellerodd. that should have nashorn#2019-11-1317:24conanyeah it seems to have been introduced with Java 8#2019-11-1317:25conan#2019-11-1317:25thhellernever heard of anyone else running into this before#2019-11-1317:26conanok i'll do some googling. thanks!#2019-11-1317:26conanyou've been super helpful#2019-11-1317:26thhellerare you sure that is actually the JVM used?#2019-11-1317:26thheller(intellij lets you select others)#2019-11-1317:26conanit's possible that Intellij uses a built-in one, but it prints out that path at the start of the REPL output#2019-11-1317:27thhellerstrange indeed#2019-11-1317:27conan#2019-11-1317:28conantell you what though, it's not on my path#2019-11-1317:28conanshould it be?#2019-11-1317:28thhellerJDK 13 is out btw 😉 jdk8 is like living in the stone age 😛#2019-11-1317:28conani've always had trouble with clojure and later versions, maybe it's time to give it a bump#2019-11-1317:28conannashorn seems to be deprecated now though#2019-11-1317:28thhellerno running java should be just fine#2019-11-1317:29thhelleryeah its deprecated but still here for now 😉#2019-11-1317:29thhellerthe check ultimately isn't important so its fine#2019-11-1317:29thhellerI can probably make it less noisy instead of failing so much 😛#2019-11-1317:29conani'll keep looking though, because it's very noisy#2019-11-1317:29conanwhat's it doing, out of interest?#2019-11-1317:30thhellercomparing npm package versions to spit out a small warning if they aren't what your packages expected#2019-11-1317:31thhelleronly uses nashorn because I had no interest in porting this to clojure 😛#2019-11-1317:31thhellerhttps://github.com/thheller/shadow-cljs/blob/60e0966f1ec087eb6aba06b1fde9e93f9a10ab46/src/main/shadow/build/js/semver.js#2019-11-1317:12thhellerdon't know what you mean#2019-11-1321:35lilactownhas anyone tried hooking up the node-repl to chrome's debugger?#2019-11-1321:37thhellerI've done it with :node-script builds#2019-11-1321:38thhelleryou can do it with (shadow/node-repl {:node-args ["--inspect-brk"]})#2019-11-1321:39lilactown:+1: awesome thanks!#2019-11-1402:51Quest@pez just wanted to say thanks for https://github.com/PEZ/rn-rf-shadow , got this up & running fast. a bit easier than my previous experience using re-natal I see that the README notes source-maps aren't working, but according to https://clojureverse.org/t/upgrading-the-react-native-support/4669/21 they might be after shadow-cljs 2.8.44. Will report back with my findings tomorrow#2019-11-1405:34pez@quest , cool! I get a bunch of warnings and errors when starting things up, but things work. Do you have those messages as well, or have you found out how to fix it?#2019-11-1407:11pezThis is related, me thinks: https://github.com/PEZ/rn-rf-shadow/issues/7#2019-11-1500:48QuestI don't have the log from starting up, but I did notice a lot of deprecations & some other warning that seemed concerning. The app is working, though#2019-11-1501:33QuestI can confirm that source maps & breakpoint debugging work in Chrome after Enable Remote JS Debugging is checked per https://facebook.github.io/react-native/docs/debugging (`CMD + M` on OSX.) Nice work @thheller#2019-11-1409:43conanIn the shadow-cljs user guide (Section 4.1 Source Paths), it says: > It is not recommended to separate source files by extension (eg. src/clj, src/cljs, src/cljc). For some reason this is widely used in CLJS project templates but it just makes things harder to use. https://shadow-cljs.github.io/docs/UsersGuide.html#_source_paths I've always done this for two reasons, first to make it easy to specify what's included in my frontend and backend builds, but also just to have things nicely separated when I'm developing. I'd be interested to hear why shadow recommends not to do this? I'm always up for simplifying things#2019-11-1409:59thheller@conan splitting source paths makes sense sometimes. splitting by file extension does not IMHO. say you write a macro file for CLJS that is never used in CLJ. do you put it in src/clj just because? src/cljc just makes sharing annoying too. I pretty much always use setups like src/main/my/amazing/frontend/* and src/main/my/amazing/server/*#2019-11-1409:59thhellerstill easy to separate out files when building uberjars etc. just exclude my/amazing/frontend*#2019-11-1409:59thhellersrc/frontend and src/backend works too#2019-11-1410:00thhellermy main gripe is separating by file extension thats all#2019-11-1410:01conanHmm, I see. It's sharing the code between the two that my src/cljc folder is for#2019-11-1410:01thhellersrc/main/my/amazing/shared works fine too#2019-11-1410:01conanI like the idea of being explicit about what each folder is for though, with frontend and backend for example. I've never come across a situation where that wasn't a 1:1 mapping with file extension though#2019-11-1410:02thhellerhave you written macros?#2019-11-1410:02conanOnly very occasionally, but also only ever in clj, for use in clj#2019-11-1410:03conanAnyway, this all feels like preference, so it's good that there's lots of flexibility. There's no technical advantage as far as shadow is concerned though?#2019-11-1410:04conanI can definitely see how the macro situation would cause me to rename my folders though#2019-11-1410:04thhellerif this setup works for you then use it#2019-11-1410:04thhellerI just think it is unnecessary confusing#2019-11-1410:04thhellershadow-cljs doesn't care what the names are as long as the source-path is setup correctly#2019-11-1410:05thhelleralso https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2019-11-1410:06thhellerso historically there may have been reasons as to why separating made sense#2019-11-1410:11conanoh good post, that answers a question i had about why :modules is needed too, thanks!#2019-11-1413:46Lucas BarbosaHey guys, Was there any significant change in the websocket connection from the browser to the repl from 2.8.68 to 2.8.69? If I do the update, my application doesn't connect to the repl anymore 🤔#2019-11-1413:47Lucas BarbosaThis message does not show up on the browser console in 2.8.69 to me:
shadow-cljs: WebSocket connected!
browser.cljs:26 shadow-cljs: REPL session start successful
#2019-11-1413:48thhellerno?#2019-11-1413:54Lucas BarbosaI wish I had more useful information, but this is what appears in my browser's console in 2.8.69:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
This is what appears in 2.8.68:
Installing CLJS DevTools 0.9.10 and enabling features :formatters :hints :async
client.cljs:356 Installing Fulcro Inspect {}
browser.cljs:26 shadow-cljs: WebSocket connected!
browser.cljs:26 shadow-cljs: REPL session start successful
Is there something I can do to provide more helpful context?
#2019-11-1413:55thhellerassuming you are running shadow-cljs watch the-build?#2019-11-1413:55Lucas BarbosaIn 2.8.68 I'm able to connect emacs to the repl using CIDER. In 69, I get a "no client connected to the repl" sort of message and I can't evaluate stuff#2019-11-1413:55Lucas BarbosaYes!#2019-11-1413:55thhellerany clue in the browser console?#2019-11-1413:56thhellerthere should be a websocket request open?#2019-11-1413:56thhellermaybe that is timing out or something?#2019-11-1413:56Lucas BarbosaI will take a look on the network tab. Didn't try it before, just a sec#2019-11-1413:57thhelleryou can try checking if shadow.cljs.devtools.client.browser exists in the browser console?#2019-11-1414:11Lucas BarbosaOk, so, on 2.8.69, there is no websocket connection attempt on the network tab in the console, and shadow.cljs.devtools.client.browser.cljs is loaded in the browser (prints in the thread)#2019-11-1414:12Lucas Barbosa#2019-11-1414:12Lucas Barbosa@thheller here#2019-11-1414:12thheller> (prints in the thread)#2019-11-1414:12thhellerwhat does that mean?#2019-11-1414:12Lucas BarbosaPrintscreens in the slack thread xD#2019-11-1414:13thhellerplease actually run what I pasted in the browser console#2019-11-1414:13thhellerif that namespace is loaded it should have connected directly on startup? no clue why it wouldn't have?#2019-11-1414:15Lucas BarbosaYes, the reference exists#2019-11-1414:16Lucas BarbosaIf I type shadow.cljs.devtools.client.browser.cljs in the console, I get an object back#2019-11-1414:17thhellerI'm assuming without the last .cljs?#2019-11-1414:17thhellerbecause that would be wrong?#2019-11-1414:17Lucas Barbosaoops, excuse me. Yes, without the .cljs suffix#2019-11-1414:17thhellerwhat is shadow.cljs.devtools.client.env.enabled?#2019-11-1414:18Lucas Barbosaundefined#2019-11-1414:18thhelleroh. do you use lein or deps.edn?#2019-11-1414:19thhellerhit up shadow-cljs clj-repl then ( "goog/base.js"). I'm guessing you have an old closure-library version#2019-11-1414:20thhellershould be 0.0-20191016-6ae1f72f#2019-11-1414:20Lucas BarbosaYes, we do use lein here!
shadow.user=> ( "goog/base.js")
#object[java.net.URL 0xdad8889 "jar:file:/Users/lucas.barbosa/.m2/repository/org/clojure/google-closure-library/0.0-20170809-b9c14c6b/google-closure-library-0.0-20170809-b9c14c6b.jar!/goog/base.js"]
#2019-11-1414:21Lucas Barbosawe do have a mismatch 🤔#2019-11-1414:21thhelleryes, that is the rather old one#2019-11-1414:21thheller
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2019-11-1414:21thhelleryou can add those manually I guess#2019-11-1414:22dpsutton@thheller what made you suspect an out of date google closure?#2019-11-1414:23thhellerthe .env/enabled is a goog-define and goog.define was changed in the latest closure compiler/library release#2019-11-1414:48p-himikshadow-cljs displays an empty error message when I do something stupid with macros:
;; test.clj
(defmacro dummy []
  `(defmulti x ~identity))

;; test.cljs
(dummy)
The error:
------ ERROR -------------------------------------------------------------------
 File: /.../test.cljs
Error in phase :compilation

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Not sure if that could be handled at all.
#2019-11-1414:58Lucas BarbosaI’ll try the dependency bump and let you guys know! Thanks for the awesome support @thheller !#2019-11-1415:52DerekIs there a way to not include a component in a release build? I guess other than module splitting, some sort of function/macro that depends on :shadow.build/mode#2019-11-1416:33isakAre you using advanced? If so, you can just rely on dead code compilation. Here is an example: https://github.com/day8/re-frame/blob/69a3fcd411369fff65404e7d6a924ce1968e2dba/src/re_frame/registrar.cljc#L37-L39#2019-11-1416:33isak( and here is debug-enabled? : https://github.com/day8/re-frame/blob/accc559010c8635020fb929f1a4b081b69f58d5f/src/re_frame/interop.cljs#L16 )#2019-11-1416:34DerekI’ll give this a shot. Thank you#2019-11-1415:58orestisI’m trying to implement code splitting based on https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html , but instead of reagent I’m using hx. Everything works fine, but hot reloading doesn’t seem to work. Shadow does detect the changed code, and does reload the changed namespace, and does call the “after-load” fn, but then React seems to skip over rendering the lazy component.#2019-11-1415:58orestisI’m using the “trick” to wrap the component in an extra level, but doesn’t seem to have any effect.#2019-11-1416:45thheller@orestis what did you try? the demo.util used in that post should be working with hot-reload#2019-11-1416:45thhellerbut you can't skip the step done in demo.util#2019-11-1416:49orestis
(defn lazy-component* [loadable]
  (React/lazy
   (fn []
     (js/console.log "still lazy?")
     ;; React lazy expects a promise, that returns an ES6 module with a React Component as default export
     (-> (shadow.lazy/load loadable)
         (.then
          (fn [root-el]
            (if-not js/goog.DEBUG
              ;; in production mode, just do that
              #js {:default root-el}
              ;; in dev mode, we need wrap the loaded component one
              ;; extra level so live-reload actually works since React
              ;; will keep a reference to the initially loaded fn and
              ;; won't update it
              #js {:default (fn [props]
                              (js/console.log "lazy render")
                              (js/console.log (@loadable #js {}))
                              (React/createElement @loadable props)
                              (hx/f [LazyComponentWrapper {:loadable loadable :props props}])
                              (hx/f [LazyWrap {:loadable loadable :props props}])
                              )})))))))
#2019-11-1416:49orestisI can’t even get the “lazy render” to log out.#2019-11-1416:49orestis^There’s a bunch of experiments with different approaches, but non of them work.#2019-11-1416:49thhelleryes cause they are all wrong 😛#2019-11-1416:50thhellerthe :default (fn [props] is called ONCE on initial load#2019-11-1416:50orestis*They work with the first render, but not on the hot reload.#2019-11-1416:50thhellerit'll never be called again#2019-11-1416:50thhellerso whatever will be happening again ... must deref the loadable#2019-11-1416:51thheller(r/reactify-component (fn [props] [@loadable props]))#2019-11-1416:51orestisRight, so I need to close over the loadable, and deref it again on render, right?#2019-11-1416:51thhelleryes#2019-11-1416:51orestisThat’s what the LazyComponentWrapper thing does, but it doesn’t seem to have any effect.#2019-11-1416:51orestis
(hx/defnc LazyComponentWrapper [{:keys [loadable props]}]
  (js/console.log "LOADABLE  dereffed" @loadable)
  [@loadable (bean props)])
#2019-11-1416:51orestisThe log doesn’t even print.#2019-11-1416:52thhellerwell that might be hx short circuiting because neither loadble nor props changed?#2019-11-1416:52thhellerdunno what it actually does#2019-11-1416:52orestisI think it’s React short-circuiting, because it’s a functional component.#2019-11-1416:53thhellerreact doesn't short circuit, unless you memo stuff#2019-11-1416:53orestishx doesn’t either — unless I’m very confused.#2019-11-1416:54orestisI’m knackered for the day, but thanks for the confirming the general approach — return a wrapper that will deref the loadable on every render, to get the latest version.#2019-11-1416:55orestisI’ll try a minimal shareable repro and see what happens.#2019-11-1423:07thhelleraaaaaaaaaaaaaarghh ... sabotaged by vscode ...#2019-11-1423:07thhellertrying to write a description of the component stuff I've been working on and vscode just deleted half of it ...#2019-11-1423:08thhellerpicard-facepalm#2019-11-1423:29thhellerseriously .. I don't even know how it got into the state it is in now ... pressing undo/redo just makes arbitrary changes and makes things worse#2019-11-1505:26pezIs this in a regular editor? Are you using macos? Checking because I have similar issues in Calva's REPL window, but only on Mac. #2019-11-1509:27thhellerwindows, regular vscode + vim#2019-11-1423:29thhellerW T F#2019-11-1423:29thhellerguess I'm done with vscode#2019-11-1423:30isakare you using vim-mode? i heard it has wierd interactions with the normal undo/redo system#2019-11-1423:30thhellerindeed I do#2019-11-1423:30isakah#2019-11-1500:15thhelleranyways .. wrote it all again in case someone is interested in the vdom stuff. still very far away from something actually usable but some of you seemed interested https://github.com/thheller/shadow-experiments/blob/master/doc/arborist-components.md#2019-11-1508:08AklsccHi, I'm so sorry to bother you. I have run a react-native project, and use a js file in it. The project looks like:
src
├── main
├       ├── main.clj
└── js_libs
├       ├── my.js
If I run it in product mode, works well. And I run it in development mode, then occurs an error:
Can't find variable: shadow$provide
eval
    [native code]
globalEval
    index.js:828:25
evalLoad
    index.js:2082:24
<unknown>
    index.js:2404:20
loadModuleImplementation
    require.js:331:6
<unknown>
    index.js:1
loadModuleImplementation
    require.js:331:6
guardedLoadModule
    require.js:197:45
global code
What's the shadow$provide? @thheller
#2019-11-1509:26thheller@180338742 the JS support currently has issues with commonjs code. try to use ESM import/export instead#2019-11-1510:48AklsccThank you~#2019-11-1511:21mpingHi all, is it possible to supply a handler-creating fn to :devtools opt?#2019-11-1511:22mpingcurrently the wiki states :http-handler shadow.http.push-state/handle#2019-11-1511:22mpingbut I want to wire my own handler, who is created by invoking a fn (defn make-handler [cfg]...)#2019-11-1511:24thhellerin my experience 100% of the time where you need handlers that actually do stuff you should be writing your own server#2019-11-1511:24thhelleryou are not going to run shadow-cljs in production either#2019-11-1511:25thhellerjust create your own CLJ server and use that#2019-11-1511:25thhellerthere is nothing the server needs to do for shadow-cljs to work#2019-11-1511:26mpingThats great insight; I guess my handler just needs to render the appropriate html file then?#2019-11-1511:26thhellerwhatever it would be doing in production too yes#2019-11-1511:26thhellerjust like production the only thing it will need to do is serve static files#2019-11-1511:27thheller(that could be a nginx or something sitting in front of it)#2019-11-1511:27thhellerI'm just assuming here that the handler you are talking about is an actual CLJ server-side "app"#2019-11-1511:46mpingthanks @thheller that clears it#2019-11-1512:51orestis@thheller After upgrading shadow and React to the latest version, hot-reloading lazy-loaded components with hx works -- here's an example repo for anyone curious: https://github.com/orestis/shadow-hx-lazy-load#2019-11-1513:22orestisAny clues about what brings in this "@" npm module? It only have date-fns imports.#2019-11-1513:25thhellerthat it likely datefns#2019-11-1513:25thhellerthe node_modules/date-fns/package.json is likely empty or doesn't exist at all#2019-11-1513:25thhelleror just wasn't read correctly#2019-11-1513:26thheller@ is just because it concats (str package-name "@" version) or something#2019-11-1513:26thhellerguess there can be cases where that is empty#2019-11-1514:05orestisNothing seemingly wrong with node_modules/date-fns/package.json#2019-11-1514:05orestis#2019-11-1514:06orestisAnd there's another date-fns later down the build#2019-11-1514:06thhellerdunno might just be a bug not identifying the package correctly#2019-11-1514:06thhellerif you can reproduce this feel free to open an issue#2019-11-1514:07orestis#2019-11-1514:07orestisThe "empty" row is the one of the first screenshot, the expanded date-fns is what I show now.#2019-11-1514:07orestisCool, I just wanted to see if you had any obvious insights. I'll try to repro.#2019-11-1514:31orestisInteresting: node_modules/date-fns/parseISO/index.js vs node_modules/date-fns/_lib/setUTCDay/index.js -- there's a _lib prefix in the last one.#2019-11-1514:40orestisHah, it's actually different files. Not sure why the reporting looks off, but the actual content is not duplicated as I thought -- so it's only a reporting glitch.#2019-11-1514:58orestisHm, shouldn't checking for js/goog.DEBUG result in DCE in release builds?#2019-11-1514:58thhellerif you hint it with ^boolean#2019-11-1514:58orestisAh, I thought that this was fixed in the CLJS compiler? I saw some discussion and "closed" ticket in cljs-dev.#2019-11-1514:59orestisThe code I see generated looks like: $APP.l(!1)&&(JO.displayName="nosco.views.page-list/DeletePagesButton")#2019-11-1514:59thhellermaybe in master. not in 520#2019-11-1514:59orestisAh, ok. I'll wait for it to land then.#2019-11-1514:59thhellerjust hint it#2019-11-1514:59orestisIt's in a library 🙂#2019-11-1515:01orestisI got a little bit obsessed with code size, having seen my build balloon to 2MB of JS, so now I'm testing out splitting code etc. Of course, most of it is huge JS libraries.#2019-11-1515:01thhellerhehe. yep JS will do that 🙂#2019-11-1515:03orestisYeah, bringing in their own polyfills even. And then when I wanted to use https://projectfluent.org, they hard-drop IE11 compatibility by extending Map so no polyfill can fix that 😞#2019-11-1515:05orestisIf a JS project exports both common.js and ESM versions, like
"main": "dist/react-beautiful-dnd.cjs.js",
  "module": "dist/react-beautiful-dnd.esm.js",
it seems shadow prefers the cjs one. Does it make any practical difference?
#2019-11-1515:13thhelleryou can try :js-options {:entry-keys ["module" "main"]} to pick module over main#2019-11-1515:13thhellerin my experience things break far more often since ESM->CJS interop is still somewhat undefined#2019-11-1515:38orestisThanks#2019-11-1602:00Joel HolmesIf I’m importing an NPM class with a period in it? import { Document } from 'react-pdf/dist/entry.webpack';#2019-11-1605:32lilactownI have a JS module I just added to my classpath:
import React from "react";

console.log(React);
logs undefined. I am able to require "react" in my CLJS ns' just fine
#2019-11-1605:35lilactownah, import * as React. forgot my JS for a sec...#2019-11-1609:31thheller@lilactown actually the import React would be correct but due to undefined CJS->ESM interop it is still import * for now#2019-11-1609:33thheller@holmes89 was there an actual question? importing with a dot is fine if that is the actual name of the file?#2019-11-1612:20Joel HolmesSorry my question was how do you use the import statement for a library that has a dot or an @ in it in the require statement in a cljs file?#2019-11-1613:31dotemacs@holmes89 does ["react-pdf/dist/entry.webpack" :as some-cool-name] work ?#2019-11-1620:14Filipe Silvaheya, is there a date for the next release?#2019-11-1620:57thheller@filipematossilva will try to do one tomorrow, kinda wanted to finish the UI CLJS eval parts but that was way more work than I anticipated 😛#2019-11-1621:00Filipe Silvano pressure from me, just wondering 😄#2019-11-1715:52martinklepschIf anyone here is using Vim (Fireplace): did you run into issues with seeing println output from CLJS REPLs?#2019-11-1715:52martinklepschAfter switching into a CLJS REPL using shadow.cljs.devtools.api/node-repl I am not seeing any println output anymore.#2019-11-1717:10thhellerhttps://github.com/thheller/shadow-cljs/issues/373#2019-11-1809:37martinklepschThanks. I’m connecting to a CLJ repl via cider and then run (shadow/node-repl) — if my reading of this issue is correct than println should at least work reliably on the first invocation of node-repl , but doesn’t for me. I will try reproducing with console shadow node-repl too#2019-11-1809:38martinklepschNote that this was working fine-ish with Emacs+Cider but is now not working with Vim+Fireplace.#2019-11-1809:39martinklepschPrinting works on the first node-repl instance but doesn’t on subsequent invocations. (Just confirming what is written down in the issue already.)#2019-11-1810:29thhellerevery editor seems to interpret the nrepl messages in a slightly different way. there doesn't seem to be a standard for that so I really don't know how everything is supposed to work. it all works fine in Cursive and that is what I test on. if you want to dig into why fireplace isn't happy I can change things (as long as that doesn't break any other editor).#2019-11-1811:12martinklepschCool, I’ll try to figure out whats going on there. Thanks for the context, wasn’t sure on which side this should be considered an issue #2019-11-1812:23thhellerthe problem likely is that the node-repl captures stdout/stderr and sends those without any nrepl message id#2019-11-1812:23thhellerfireplace likely either just drops them or displays them somewhere hidden#2019-11-1812:47martinklepschthat indeed sounds very likely#2019-11-1814:19grounded_sageI’m trying to pull material-ui into a shadow-cljs project and it fails to load on the browser#2019-11-1814:21grounded_sage#2019-11-1814:54thhellerlooks like they might have migrated to "strict" interop mode? react doesn't have a default export so _react.default doesn't exist#2019-11-1814:55thhellernot sure how to handle that yet#2019-11-1815:30grounded_sageIs there a version of materiaul-ui you know that is compatible @thheller?#2019-11-1815:54stefanwe are on 4.5.0 with no issues#2019-11-1816:02grounded_sageI still get an error on this for some reason.#2019-11-1816:05stefanhow are you requiring the material-ui components?#2019-11-1818:20grounded_sageRequiring like this ["@material-ui/core" :refer [Button]]#2019-11-1818:20grounded_sage
"dependencies": {
    ...
    "@material-ui/core": "4.5.0",
  }
#2019-11-1818:21grounded_sage#2019-11-1916:01stefanSorry, just saw this response. We are using the default export option, eg ["@material-ui/core/Button" :default button]. I wonder if that would work.#2019-11-1916:02stefanin cases where we want the named export ["@material-ui/styles" :rename {ThemeProvider mui-theme-provider}]#2019-11-1817:05kaoskoHow do I load npm modules into repl? I should be able to do that right?#2019-11-1817:05kaoskomy attempt fails with: (require '["three" :as three]) Execution error (ClassCastException..#2019-11-1817:27thheller@kaosko when reporting errors never ever shorten error messages. need to see the full error to make sense of it. I'm guessing you are in a CLJ REPL but can't say for sure without the full error#2019-11-1817:29kaosko(require '["three" :as three]) Execution error (ClassCastException) at java.lang.String/compareTo (String.java:111). clojure.lang.Symbol cannot be cast to java.lang.String#2019-11-1817:30thhellerok thx. that is indeed a CLJ error so you need to switch to CLJS first#2019-11-1817:30kaoskowith (shadow/dev :app)?#2019-11-1817:31thheller(shadow/repl :app)#2019-11-1817:32kaoskoah, that's it thanks! I got the (shadow/dev :app) from https://github.com/thheller/shadow-cljs/wiki/REPL#2019-11-1817:32kaoskoThe shadow.cljs.devtools.api/dev fn will turn your REPL into a CLJS REPL and auto-compile your project in the background: (shadow/dev :your-build-id)#2019-11-1817:33thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljs-repl#2019-11-1817:33thhellerthe wiki is outdated. I'll remove it.#2019-11-1817:33kaoskoI see, ok#2019-11-1817:33thhelleralthough dev might still work. I'm not sure 😛#2019-11-1817:33kaosko(shadow/dev :app) => :already-watching#2019-11-1817:36thhelleryeah, dev is watch+repl combined so it would only work when the watch isn't already running#2019-11-1817:41kaoskoyeah figured. shadow/repl was what I was missing#2019-11-1818:13daniel.spanielis there a hook on shadowjs build where I can put the git sha hash of the current commint into the config section of a file? I want to be able to have the current git sha on the client build so when I push a release to production the server can say "here is the current sha" and the client can check "here is what I have" and can tell the client "your ui version is old, please refresh"#2019-11-1818:14thhelleruse (ns foo.bar) and (goog-define SHA "some-default-to-compare-against")#2019-11-1818:15thhellerthen shadow-cljs release --config-merge "{:compiler-options {:closure-defines foo.bar/SHA actual-sha}}"#2019-11-1818:17thhellerdon't think this is a good idea but it should work#2019-11-1819:44grounded_sageI've now tried ["@material-ui/core/Button" :default Button] and using older versions of material-ui. I'm convinced I'm doing something wrong.#2019-11-2217:10erwinrooijakkersHi not really an answer perhaps, but we switched to Bulma instead of Material UI. Really happy with that choice. Bulma is CSS only so no need to import any javascript and has similar functionality. Not sure if it works for your case but wanted to let you know!#2019-11-1821:11daniel.spanielooo .. thanks @thheller.. will try and let you know how it works. is there better idea ? is there a better way that you can tell the users of an app that their UI is stale ?#2019-11-1822:27tony.kayv70 of shadow-cljs is crashing on me regularly:
14:09:56.270 [XNIO-1 I/O-7] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1
[2019-11-18 14:09:56.269 - WARNING] :shadow.cljs.devtools.server/cli-checker-shutdown
shutting down ...
14:09:56.273 [shadow-cljs-npm-process-checker] DEBUG io.undertow - stopping undertow server 
#2019-11-1822:27tony.kaywhen running in server mode#2019-11-1822:28tony.kayguess it isn’t so much a crash as some kind of automated shutdown? Annoying as hell, though#2019-11-1900:26thhellerwhat the heck?#2019-11-1900:27thheller@tony.kay you are using deps.edn right?#2019-11-1900:28tony.kayI am#2019-11-1900:29thhellerhmm let me test on macOS, maybe it does something linux/win don't#2019-11-1900:35thhellerhmm also working fine on macOS. @tony.kay is there anything special in your setup? can you check if .shadow-cljs/cli.check exists?
#2019-11-1900:36thhellerthe check was supposed to be more reliable, not less 😛#2019-11-1900:39thhellerthe node process will write a .shadow-cljs/cli.check every 2sec and the JVM process will check it to see if it keeps getting updated#2019-11-1900:39thhellerso that it can detect if the node process got killed#2019-11-1900:39thheller(solving a problem from a while ago that there would be zombie JVM processes if node got killed or exited)#2019-11-1901:15tony.kayI can check later..I’m cranking on something and just had to revert. Using straight deps.edn, and yarn for deps install#2019-11-1904:17Sean Poulter👋 Totally unrelated, but I listened to you on the defn podcast today. Hope you’re well. Loved your hobby project plans and curious if you’ve made any progress.#2019-11-1916:51tony.kayI’m well, but busy. Hobby project shaping up. Still building tools, networks, and a bit of a money buffer…but it is starting to take shape I think#2019-11-1901:45thhellerjust published {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "46352e272229316b252a2c350674687e687177"}, :content ("[email protected]")} ... hope that variant is actually more reliable ... unless you are still on java 1.8 I guess 😛#2019-11-1904:27Sean PoulterHey folks. Any tips on the best way to see test results in IntelliJ/Cursive (for a frontend ClojureScript project)? I’ve got the CI build running in one process, and karma started in the terminal. Thanks! Have a lovely day. :+1:#2019-11-1915:29Shuai Lin@thheller I just shot two PRs for allowing more user configs in ~/.shadow-cljs/config.ed. - https://github.com/thheller/shadow-cljs/pull/600 for custom :log - https://github.com/thheller/shadow-cljs/pull/601 for custom :nrepl PTAL.#2019-11-1915:31Shuai Linbtw what do you think about enabling travis/circle for the project? Even if I always test locally before submitting the patch, the green check mark would make me more confident about my PR 😄 (and I see there is already a circleci.yml file, so I guess it's just a matter of settings)#2019-11-2011:44Filipe Silva@thheller WDYT of setting up github actions instead of circle and testing across linux/osx/windows?#2019-11-2011:45Filipe SilvaI could set that up for you if you're interested#2019-11-2011:48thhellerthere are barely any tests to begin with so not all that useful currently#2019-11-2011:51thhellerit would be interesting to have some automated way that runs a "test" build for each new release#2019-11-2011:51thhellerdunno if that can be done with github actions#2019-11-2011:51Filipe SilvaI have something similar happening#2019-11-2011:51Filipe Silvahttps://github.com/filipesilva/create-cljs-app/blob/7dcdd62bfd1fa8c49a9f04c9e47dc73fb30d2472/.github/workflows/nodejs.yml#L51-L76#2019-11-2011:51thhelleralso don't know how to test stuff for real since most of the stuff breaking is either related to breaking JS deps or complicated watch stuff#2019-11-2011:52Filipe Silvain my case, releases are done automatically, and the release is tested if done#2019-11-2011:52Filipe Silvabut I think a workflow can also be set that is triggered on tags#2019-11-2011:52Filipe Silvae.g. you make the release manually, then push the tag, then the workflow runs on the tag#2019-11-2011:53Filipe SilvaI have some experience testing build tools... testing watch is really hard, but testing builds is easy as long as the build itself also contains an e2e#2019-11-2011:54thhellersomething like https://github.com/mfikes/patch-tender would also be nice#2019-11-2011:54thhellerbut I guess that doesn't matter too much#2019-11-2011:55Filipe Silvaso those tests become something like "I want to test that these latest changes will still make the test-project e2e work", then have test projects for the different targets#2019-11-2011:55Filipe Silvaso the patch tender is a canary build sort of thing, right?#2019-11-2011:55Filipe Silvathat can be done#2019-11-2011:55thhellerhmm now that I think about it forget about that#2019-11-2011:55thhellersometimes changes in CLJS may require changes in shadow-cljs#2019-11-2011:56Filipe Silvait's common enough to test canary but not on PRs#2019-11-2011:56Filipe Silvamore like a scheduled job#2019-11-2011:56Filipe Silvaonce a day/week/month#2019-11-2011:56thhellerrarely but it might happen so rather not have something that is broken for 6months or however long it takes till CLJS master is actually released#2019-11-2011:56Filipe Silvaso maybe a monthly canary check?#2019-11-2011:56Filipe Silvathen you'd get a mail saying that one broke#2019-11-2011:57Filipe Silvabut you don't get spammed all the time#2019-11-2011:59thhellernah not needed. I watch CLJS master anyways and pretty much know what will break shadow-cljs anyways#2019-11-2011:59thhelleroften before the commit even comes in via Jira#2019-11-2012:00thhellerits not that much stuff that will actually break shadow-cljs. last time it was a new binding that was added#2019-11-2012:00thhelleranyways .. pretty much the only thing that makes sense for me right now is more tests#2019-11-2012:01thhellerbut I don't know what or how to test stuff like hot-reload, file watching etc#2019-11-2012:01thhelleror all the possible build targets .. eg. :chrome-extension or :react-native#2019-11-2012:02thhellersimple builds aren't worth testing most of the time either#2019-11-2012:07Filipe Silvayeah I have no idea how to test the chrome and native targets#2019-11-2012:07Filipe Silvafile watch is testable but requires some finesse#2019-11-2012:08Filipe Silvasimple targets are nice to test size regressions#2019-11-2012:08Filipe Silvabut a couple of representative apps, like the https://github.com/jacekschae/conduit or others, would be better to test correctness#2019-11-2012:09thhelleryeah but as soon as you introduce JS deps I'm going to expect constant breakage#2019-11-2012:09thhellerand I'd rather not have to keep up with that mess 😛#2019-11-2012:09Filipe Silvawhy?#2019-11-2012:09Filipe Silvabecause of the unpinned transitive ones?#2019-11-2012:09thhellerbecause JS deps break constantly 😛#2019-11-2012:10Filipe Silvaas long as there's a lockfile, you should be getting the same js dep tree#2019-11-2012:11Filipe SilvaI agree that js deps do break constantly, but doing js deps well it is the main draw for shadow-cljs, so it sounds worthwhile to test#2019-11-2012:11thhellerin theory yes, in practice no. example from yesterday#2019-11-2012:11thhellerhttps://github.com/shadow-cljs/examples/issues/29#issuecomment-555711803#2019-11-2012:11thhellerthat example has a lock file but I can't install it anymore because of one the deps doesn't like me being on the newer node#2019-11-2012:12Filipe Silvawell that's a valid error, I guess that you updated the node version at some point#2019-11-2012:12Filipe Silvait still sucks, but is valid#2019-11-2012:12thhellerthats a nonsense error though. there SHOULD be zero chance that this works in node v9 but not v10?#2019-11-2012:12thhellerI'm betting this works with node v12#2019-11-2012:13thhellerits just a nonsense setting in that package 😛#2019-11-2012:13thhellerwell anyways ... I don't want to deal with node stuff breaking#2019-11-2012:13thhellerI can't even keep up with that breaking for the few examples#2019-11-2012:15Filipe Silvabut that's part of the problem, right?#2019-11-2012:15thhellerthe problem is node/npm not being very stable#2019-11-2012:15thhellerthere is no way I'm going to make that more stable#2019-11-2012:15Filipe Silvait was a surprise that the old example didn't run anymore because there was no test that verified it with a formal environment#2019-11-2012:16thhellerno it is impossible to keep the old examples running#2019-11-2012:16thhellerthings change too much. the storybook stuff works completely differently nowadays. it has basically nothing in common with the old code#2019-11-2012:16Filipe Silvahold on, I think there's a bit of conflating issues here...#2019-11-2012:17Filipe Silvathe test from 2 years ago should run given a same-ish set of dependencies, including environment dependencies#2019-11-2012:17Filipe Silvait should run without source changes#2019-11-2012:17thhellerbut it is pointless to keep that running#2019-11-2012:17thhellernobody is gonna want to use a 2 year old version of storybook#2019-11-2012:18thhellernone of the current docs are going to apply#2019-11-2012:18thhellerso at best it is a "hey, this is how it worked 2 years ago"#2019-11-2012:18Filipe Silvatbh my experience trying to get most cljs things working is that almost all examples I find are outdated, and I mostly scavenge config items from one and another#2019-11-2012:18thheller"but nowadays things are different, don't look at this"#2019-11-2012:19Filipe Silvait's still valuable to see how they worked, given that there's a reasonable guarantee that it still works (e.g. it's still tested and there;s an env that it works in)#2019-11-2012:20Filipe Silvaonce that exists, it's a matter of starting from that point and trying to make the new thing work#2019-11-2012:20Filipe Silvathe only thing that is truly mandatory to keep up to date for shadow-cljs is its own config items#2019-11-2012:20thhellerin theory yes. In practice if I can't clone an example and run it in my env it is probably pointless#2019-11-2012:21Filipe Silvato be fair that part isn't a node problem... clj suffers from that with java versions as well, doesn't it?#2019-11-2012:22Filipe SilvaI remember I installed the latest java and it turned out a bunch of things just broke in weird ways until I went back to 8 or something#2019-11-2012:22thhelleryeah sure this isn't node only. but it is much more common in node.#2019-11-2012:23Filipe Silvayes, the node dep system is a bit of a shitshow and things aren't very stable overall#2019-11-2012:23thhellerthe move off jdk1.8 was a bit messy indeed#2019-11-2012:26Filipe Silvais https://github.com/shadow-cljs/examples used for testing?#2019-11-2012:26thhellerno. I wanted to delete that repo for a while now#2019-11-2012:26thhellergood chance lots of them are not actually working anymore 😛#2019-11-2012:26Filipe SilvaI found it really useful last weekend tbh, when I was trying to do devcards#2019-11-2012:27Filipe Silvait's really really hard to find examples for cljs stuff#2019-11-2012:28thhelleryeah. I want better examples too but want to cut down on the JS parts#2019-11-2012:29thhellerto be fair there are fairly "stable" npm packages too. it isn't all bad.#2019-11-2012:29Filipe Silvapersonally I'd like even more JS parts since that's why I'm using shadow-cljs, but this is my consumer POV 😛#2019-11-2012:31thhelleryeah, that was my view a couple years ago. that is why I wrote all the npm support after all. nowadays I'd much rather not use anything from that world 😛#2019-11-2012:33Filipe Silvathat sounds a bit at odds with what I gather to be the point of shadow-cljs, but I imagine I'm too focused on my "use npm packages but with cljs" usecase to see the other large usecases#2019-11-2012:34thhellerthe point of shadow-cljs is CLJS compilation. supporting JS/npm is like 10% of that#2019-11-2012:35thhellereasier config, dedicated :target configs, etc is way more important (IMHO)#2019-11-2012:36Filipe SilvaI never actually tried running either lein or the official clj tools more than... twice, I think#2019-11-2012:36Filipe Silvaso I've never felt the difference between shadow-cljs and those#2019-11-2012:37Filipe SilvaI'm on windows, and the official clj tools need powershell to run, and that's not my day to day shell#2019-11-2012:37Filipe Silvaplus it doesn't have a lot of examples#2019-11-2012:38Filipe Silvalein seems great but what I really want is to keep access to the js ecosystem via npm so I don't see the point in using anything that doesn't give ergonomic access to that#2019-11-2012:38thhellergive it a try 😉 hopefully makes it clear how much more important the config stuff is over JS intergration 😉#2019-11-2012:39thhelleryou can get npm sort of via https://clojurescript.org/guides/webpack#2019-11-2012:39Filipe Silvaimho that approach is more of a POC than a real thing#2019-11-2012:40thhellerlots of people do use it that way though#2019-11-2012:40Filipe Silvamaybe it makes sense if you use just a few npm packages... but once you start leaning heavily into js deps it just goes out door#2019-11-2012:41Filipe Silvamanaging a second build system and the interface point between the two is just more work for things that don't need to be more work#2019-11-2012:42Filipe Silvatbh baseline cljs just makes the existing js world be second class citizen, while shadow-cljs makes it a first class citizen#2019-11-2012:43thhelleryes, I wanted to make that easier#2019-11-2012:43Filipe Silvaif you're a JS user (like me) why would you even consider trying cljs if the first step is to either let go of your existing ecosystem or maintain glue webpack builds? the overhead to start is very high like that#2019-11-2012:43thhellerBUT ... that means people are reaching for npm all the time. even when there are "better" choices directly in CLJS or in the Closure Library#2019-11-2012:44thhelleryes, this all needed to be more accessible for JS devs#2019-11-2012:45Filipe SilvaI get that impression, that the cljs world has much better options, but they are kinda hard to discover...#2019-11-2012:45thhellerbut there is a downside to it ...#2019-11-2012:46Filipe Silvathe incremental move from js to cljs is more manageable, you can start with your old stuff and move towards better stuff bit by bit, kinda like how TS got people to move over because you could just gradually opt into types#2019-11-2012:47thhellerincremental IMHO isn't that easy since idiomatic CLJS looks nothing like JS#2019-11-2012:47thhellerbut it should be possible to do regardless#2019-11-2012:48Filipe Silvait's true, the conversion isn't too straightforward#2019-11-2012:49Filipe Silvapersonally I'm having loads of fun trying to make stuff work... I was trying to hook up reacts testing-library to shadowcljs and devcards and it seems to be ok#2019-11-2012:49Filipe Silvacoming from the js world I'm really stupified by how better the dev ux things are#2019-11-2012:52thhellerone of the long term things I'd like to work on at some point is CLJS outputting plain ESM, no google closure stuff#2019-11-2012:52thhellerthat should make interop much much easier#2019-11-2012:52Filipe Silvahave I mentioned https://www.pika.dev/registry?#2019-11-2012:52thhellernot sure that is actually practical though#2019-11-2012:53thhelleryeah I've seen that#2019-11-2012:53Filipe Silvait's mostly a ESM registry, so that helps with the discoverability of those packages#2019-11-2012:53Filipe Silvapure ESM won't become a reality until node adopts it#2019-11-2012:53Filipe Silvawhich happened... I think last week#2019-11-2012:53thhelleryes a pure ESM world would be nice#2019-11-2012:54thhellerbut there are lots of problem with ESM that also need to be solved first#2019-11-2012:54thhellerimport maps, declared exports in package.json and so on#2019-11-2012:54Filipe Silvahttps://twitter.com/mylesborins/status/1194375751774064647?s=21#2019-11-2012:54Filipe Silvapackage exports also seem to be happening#2019-11-2012:54Filipe Silvahttps://nodejs.org/api/esm.html#esm_package_exports#2019-11-2012:55thheller> Experimental support for ECMAScript modules is enabled by default.#2019-11-2012:55thhellerstill experimental though 😉#2019-11-2012:55Filipe Silvayeah#2019-11-2012:55thhelleryes that all looks good#2019-11-2012:56thhellermight actually work in 5 years or so 😉#2019-11-2012:56Filipe SilvaI think the transition is going to be really bad though#2019-11-2012:56Filipe Silvanpm/package.json doesn't really have forward compat allowances#2019-11-2012:56thhellerindeed. really bad indeed.#2019-11-2012:56Filipe Silvapeople are going to start publishing es2015 packages and everything will just break is weird ways#2019-11-2012:56thhellercan see that already today when packages move to the "strict" CJS->ESM interop styles#2019-11-2012:57Filipe Silvaso yeah, 5 years sounds like the reasonable timeframe#2019-11-2012:57thhellerone of the reasons I want to get out of that world 😛#2019-11-2012:57thhelleronce its done it'll be better but the transition is gonna suck#2019-11-2012:57thhellerhope that a final webpack v5 release will speed that along a bit#2019-11-2012:58Filipe Silvabecause of the esm output option?#2019-11-2012:58Filipe Silvawebpack is a really bad tool for lib publishing overall imho#2019-11-2013:00thhellerno webpack v5 is moving to strict interop by default#2019-11-2013:01thhellerso import {foo, bar} from "x"; will break if x is a commonJS package#2019-11-2013:01thhelleronly import X from "x"; and X.foo will be allowed#2019-11-2013:01thhellerso that should kind of force more packages actually publishing ESM code#2019-11-2013:01thhellerbut we'll see about that 😛#2019-11-2013:02thhellerthe problem is the "compatibilty" mode that babel/webpack allowed#2019-11-2013:02Filipe Silvaahhh yeah that'll be good#2019-11-2013:02thhellerthat can never work when actually following the spec#2019-11-2013:03Filipe Silvathat's also the reason webpack was so widespread though#2019-11-2013:03Filipe Silvabecause thing just worked... sorta, probably, sometimes#2019-11-2013:04thhelleryeah I know .. it is tough. I'm not a huge fan of ESM either. the design seems silly in some parts#2019-11-2013:04Shuai Lin@thheller the reason I proposed to enable some CI is to make sure PRs have some minimum automatic checks, e.g. at least the clj compilation shall pass.#2019-11-2013:05Shuai Linon top of that it'll be good to have some test coverage to make sure new contribution doesn't break existing stuff.#2019-11-2013:05thhelleryeah how do I get that setup for PRs?#2019-11-2013:06Shuai Linfor travis it's as simple as a click in settings ui on http://travis.org#2019-11-2013:06Filipe Silvausing circleci you have to tick a box that says PRs should be built... sec#2019-11-2013:07Filipe Silva#2019-11-2013:08Filipe Silvaopen circleci, click settings cogwheel top right corner, follow image#2019-11-2013:08Shuai Linfor travis#2019-11-2013:10thhellerok thanks. should be enabled now#2019-11-2013:10thhellerbut yeah getting tests to cover that all is kinda hard 😛#2019-11-2013:11Filipe Silvait's not just about the overall coverage though#2019-11-2013:11Filipe Silvait also gives a lot more confidence to contributors#2019-11-2013:11Filipe Silvaand it also provides a blueprint of what commands they should run locally that are guaranteed to be up to date#2019-11-2013:12Filipe Silvatbh the CI config is the only script that's guaranteed to work in most projects#2019-11-1921:32donyormSo I'm working on a project with shadow-cljs, and I noticed that source-maps aren't working in firefox or chrome. Is that a known issue/do I need to specify any settings to fix that?#2019-11-1921:33thhellerthey are only enabled by default for compile/watch. release doesn't have them enabled by default.#2019-11-1921:34thhellerbut they should be working fine without extra settings in compile/watch#2019-11-1921:34donyormHmmmm, I'm using compile/watch#2019-11-1921:34donyormHere's my shadow-cljs.edn file if you need it#2019-11-1921:34donyorm#2019-11-1921:35thhellerdon't need to set :source-map true and :asset-path is likely the issue. looks like that should be /js?#2019-11-1921:35donyormOk, let me check#2019-11-1921:35thhelleryou can also remove the clojurescript dependency, shadow-cljs adds that by default#2019-11-1922:06aisamuUpgrading shadow-cljs from 68 to 72 is breaking our :npm-module project in a strange way. The shadow-cljs compilation works normally, but later in the process the files are called/consumed by webpack and it fails with:
/path/filename.js:37939
if(COMPILED){
^
ReferenceError: COMPILED is not defined
    at Object../build/cljs/cljs.core.js (/path/filename.js:37939:1)
    at __webpack_require__ (/path/webpack:/webpack/bootstrap:19:1)
    ...
I'm comparing the generated cljs.core.js and the /path/filename.js between the two versions, but sifting through 5.1mb of js will probably take a little while given the spurious (gensym) differences 😬
#2019-11-1922:07thhellercan you check a bit more of the code?#2019-11-1922:07thhellerwould like to know which part of the code that actually is#2019-11-1922:07thhellerjust search for COMPILED#2019-11-1922:12thhelleroh it is actually in cljs.core itself#2019-11-1922:15thheller@aisamu try 2.8.73#2019-11-1922:19aisamuThe error changed, but I'd call that progress 😛#2019-11-1922:19aisamu
/path/webpack:/build/cljs/cljs_env.js:181

      throw new Error('Namespace "' + name + '" already declared.');
^
Error: Namespace "goog.math.Long" already declared.
    at Object.module.exports../build/cljs/cljs_env.js.goog.module (/path/webpack:/build/cljs/cljs_env.js:181:1)
    at /path/webpack:/goog/math/long.js:143:5
    at Object.module.exports../build/cljs/cljs_env.js.goog.loadModule (/path/webpack:/build/cljs/cljs_env.js:474:1)
    at Object../build/cljs/goog.math.long.js (/path/filename2.js:50051:6)
#2019-11-1922:22thhellerhmm odd#2019-11-1922:23aisamuDid it twice after a full nuke to confirm 😕#2019-11-1922:28thhellerguess its best to stick with the older version for now#2019-11-1922:28thhellerneed to dig into :npm-module a bit more#2019-11-1922:31aisamuThanks! Please don't hesitate to reach out if you need more info/some testing#2019-11-2009:52Elirazhow would you setup the hot replacement ?#2019-11-2009:56Shuai Linread the manual from the beginning up to this section https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2019-11-2009:52Elirazhot reload#2019-11-2009:53Shuai Lin@thheller When targetting :node-script, does shadow-cljs provides some way to bundle all the code (including all npm deps) into one js file (for easier distribution)?#2019-11-2009:58thheller@linshuai2012 see https://github.com/thheller/shadow-cljs/issues/290#2019-11-2010:15thheller@eliraz.kedmi https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2019-11-2010:54Heikki HämäläinenI am using shadow-cljs in Gitlab enviroment where it is not possible to cache directories which are outside build directory (for example $HOME/.m2). What is the preferred way to set .m2 directory location?#2019-11-2010:54thhellerassuming you are actually using shadow-cljs.edn and not project.clj/deps.edn you can set :maven {:local-repo "maven"} or so in shadow-cljs.edn#2019-11-2010:55thhellerthat should put it all in the project directly#2019-11-2010:59Heikki HämäläinenYes, this seems to work. Maybe this can be added to user guide as well because some one else may find the same problem as well#2019-11-2011:23Heikki HämäläinenOne more question. Do I understand correctly that --config-merge cannot be used to merge configuration to root level of shadow-cljs.edn but only inside :builds -> :build-name map?#2019-11-2011:23thhelleryes, that is for merging build config only#2019-11-2011:24thhelleryou can set the maven config in ~/.shadow-cljs/config.edn#2019-11-2011:24thhellerbut maybe that doesn't work on gitlab? not sure?#2019-11-2011:24Heikki HämäläinenI think that it might work because I can create that file in the build pipeline. I will try and see what happens.#2019-11-2011:50Heikki Hämäläinen#2019-11-2013:04orestisUsing 'shadow-loader' (or more accurate, shadow-lazy), can I set up so that modules are loaded from an absolute URL and not from the "current" origin?#2019-11-2013:07thheller:asset-path controls that, just stick the entire URL in there#2019-11-2013:19orestisThanks#2019-11-2013:27orestisok, I'm calling release from Clojure, and I need to override the asset path. Should this work? (shadow/release :main {:asset-path "something"})#2019-11-2013:28thhellerwhy not put it into the config directly?#2019-11-2013:29thheller:release {:asset-path "//foo.com/js"}?#2019-11-2013:29thhelleror is it dynamic in some way?#2019-11-2013:29thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2019-11-2013:32orestisIt's dynamic, yes -- we unfortunately have a couple of environments and a semi-complicated setup.#2019-11-2013:32thheller(shadow/release :main {:config-merge [{:asset-path "something"}]})#2019-11-2013:34orestisWorks, thanks!#2019-11-2013:53orestisA lazy module that works well in development, fails to load in release mode. The error is something like shadow-cljs - failed to load – 329, how to debug this? is this a case for pseudo-names?#2019-11-2013:54orestisor I guess --debug ?#2019-11-2014:08orestisok, making some progress -- loading the module as a script, I get $jscomp is not defined, which I see in the main module wrapped inside an IIFE, so that's probably the culprit#2019-11-2014:11ElirazI keep getting your not viewing the latest compilation output#2019-11-2014:11Elirazwhy is that?#2019-11-2014:13ElirazI mean, I was not able to setup the hot-reload properly#2019-11-2014:14orestis@thheller I seem to be hitting https://github.com/google/closure-compiler/issues/1138#2019-11-2014:14orestis@eliraz.kedmi are you using the built-in shadow http server or your own? That error is usually a stale cache problem.#2019-11-2014:17ElirazI'm using the built-in.. maybe it's the way I'm using it? I simply jack-in using CIDER with nRepl#2019-11-2014:17orestisAre you starting a shadow watch build somehow?#2019-11-2014:17ElirazI'm not sure that's the proper way to activate the hot reload. however, when I change the code I do see the little CLJS logo spins and nothing changes#2019-11-2014:18ElirazI don't know, when I start I get into the repl and the server is up and running#2019-11-2014:22orestisDo you change the code via editing a .cljs file and saving?#2019-11-2014:22orestisOr by evaluating a function at the repl?#2019-11-2014:24ElirazI change a file and save#2019-11-2014:24ElirazI see that CLJS icon appears spins (like it's doing some calculations) and goes away#2019-11-2014:24Elirazbut nothing actually changes on the DOM#2019-11-2014:26orestisOK, and have you setup a function in your project to be called after load? i.e. something with ^:dev/after-load metadata?#2019-11-2014:26orestissee https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2019-11-2014:27ElirazNo, I have not. I don't know what that function suppose to do? I mean, what logic to put inside it?#2019-11-2014:31orestisAre you using reagent? If so you'd probably call (reagent/render ...), most probably the function you call to start your applicaiton.#2019-11-2014:32orestisShadow doesn't know what to do when it reloads your code -- you might have changed component but shadow tries to be framework agnostic. So it will put the new code in the browser, but you somehow need to re-render the DOM yourself. That's where these build hooks come in.#2019-11-2014:33Elirazgot it, so the start function#2019-11-2014:33ElirazI'm actually using hx#2019-11-2014:33ElirazI want to leverage the new hooks API#2019-11-2014:37orestis
(defonce EL (atom nil))
(defn ^:dev/after-load -render []
  (when @EL
    (react-dom/render
     (hx/f [Main])
     @EL)))
#2019-11-2110:29Elirazusing this method will keep the state of the app while reloading?#2019-11-2110:30Elirazalso, what is the Main function?#2019-11-2111:23orestisRegarding state of the app, that's a question of how you set it up. If it's global state that lives under a defonce then yes. If it's local state (react hooks) it will be gone.#2019-11-2111:23orestisThe Main is just the root component in that case.#2019-11-2113:59Elirazgot it. thank you#2019-11-2014:37orestisThat's what I use, with some weird hack to get the element#2019-11-2014:38orestisFeel free to jump into #hx#2019-11-2014:41orestisSo I'm trying to figure out what's the deal with my $jscomp issue -- I see a bunch of code in my lazy module that does things like $jscomp.arrayFromIterable, $jscomp.makeIterator and so on -- but no $jscomp definition in it. The main module almost immediately starts with
(function(){
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl .... 
#2019-11-2015:07orestisSo the docs say (https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper): "When using multiple :modules (a.k.a code splitting) this is not enabled by default since each module must be able to access the variables created by the modules it depends on." -- but it seems that's not entirely true. If I turn set :output-wrapper false then I get over my issue, $jscomp is public and everything works again, with the downside of having a ton of global variables.#2019-11-2015:20thheller@orestis yeah what is an issue I've been meaning to look into. you can fix it by either :output-wrapper false or :prepend-js "var $jscomp = {};" in the base module to pull it into the global scope#2019-11-2015:21thhellerfor some reason when using output-wrapper the var $jscomp just becomes $jscomp that isn't exported#2019-11-2015:28orestisAre you sure about the :prepend-js ? It doesn't seem to work, and I don't see how it could since it would run through optimisations. I tried :prepend to get it as a plain string but apparently due to JS scoping rules, the IIFE expression will still not "see it".#2019-11-2015:32thhellermight only work with :prepend not :prepend-js#2019-11-2015:32thhellerbut it should work with one of those#2019-11-2015:33orestis :append "window.$jscomp = $jscomp;#2019-11-2015:33orestisseems to do the trick#2019-11-2015:33orestisappend puts it inside the IIFE, prepend makes it go outside#2019-11-2015:34thhellerI'm not sure why this is necessary at all though. especially since :advanced should be renaming this but for some reason it doesn't#2019-11-2015:35thhellerit is a closure compiler thing though and kinda difficult to report#2019-11-2015:36orestisMade an issue here: https://github.com/thheller/shadow-cljs/issues/603 for Google's sake#2019-11-2019:01jjttjjanyone happen to know of an example usign shadow-cljs with klipse? when i require the klipse namespaces in my namespace, I get the following error:
The required namespace "cljsjs.codemirror.addon.edit.closebrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to  for more information.

I'm trying to shim that addon namespace as described in the shadow guide, but I'm having trouble figuring out the things i need to require and export. There's also a few more addons in that klipse namesace that will have to be shimmed.
#2019-11-2019:10donyormSo I'm still having issues with source-maps not actually working with shadow-cljs. The sourceMappingURL in a file appears to be a relative path, is that how's it supposed to work?
//# sourceURL=js/cljs-runtime/edu.unc.applab.clem.views.js
//# sourceMappingURL=edu.unc.applab.clem.views.js.map
#2019-11-2019:24thheller@donyorm as I said before this is controlled by :asset-path. if you set :asset-path "js" then yes it will be a relative path#2019-11-2019:24donyormok I did set asset-path to js#2019-11-2019:25donyormThis is my shadow-cljs.edn file now. But behavior is the same as before#2019-11-2019:25thhellerit should likely be /js otherwise your paths won't resolve properly as you use any kind of "routing"#2019-11-2019:27thhellerie. if you load the page via /some/thing then the browser will try to resolve /some/thing/js#2019-11-2019:27thhellerwith /js you force it to actually use /js#2019-11-2019:28donyormOk let me try that#2019-11-2019:28donyormChanging it to /js didn't seem to do much. Here's the source map part of the file:
//# sourceURL=/js/cljs-runtime/edu.unc.applab.clem.views.js
//# sourceMappingURL=edu.unc.applab.clem.views.js.map
#2019-11-2019:29thhellercan you please state your actual problem?#2019-11-2019:29thhellerthat looks exactly like it should?#2019-11-2019:29donyormThe source map is at /js/cljs-runtime/edu.unc.applab.clem.views.js.map Will that setup find it properly#2019-11-2019:29thhelleryes#2019-11-2019:31donyormBasically firefox isn't using source maps in error reporting (and presumably shadow-cljs/react/whatever is sending errors to the console) isn't using them either. Ex. I'll get the following stack-trace:
cljs$core$IFn$_invoke$arity$6 /js/cljs-runtime/cljs.core.js:13306
    cljs$core$IFn$_invoke$arity$5 /js/cljs-runtime/cljs.core.js:13288
    cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13276
    cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13564
    list_errors /js/cljs-runtime/edu.unc.applab.clem.views.js:102
    res /js/cljs-runtime/reagent.impl.component.js:134
    reagent$impl$component$wrap_render /js/cljs-runtime/reagent.impl.component.js:153
    reagent$impl$component$do_render /js/cljs-runtime/reagent.impl.component.js:201
    render /js/cljs-runtime/reagent.impl.component.js:227
Which doesn't give me much help in where to look in my own file
#2019-11-2019:32thhellerin which context is that thrown?#2019-11-2019:33thhellerI mean is it actually thrown or is it logged?#2019-11-2019:33donyormIt's part of a reagent component running in re-frame#2019-11-2019:34thhellerie. is something does console.warn(ex) then it won't have source mapping#2019-11-2019:34thhellerif it is actually uncaught it should be mapped#2019-11-2019:35donyormI think it's actually uncaught. I'll throw an exception in my own code just to be sure#2019-11-2019:35thhellertry something like
(js/setTimeout
  (fn []
    (throw (ex-info "omg" {})))
  2000)
#2019-11-2019:35donyormIt's possible react is catching something#2019-11-2019:35thhellerin your main code#2019-11-2019:35thhellerthat is mapped fine for me in firefox
#2019-11-2019:36thhellerif it is caught and logged I get a useless trace#2019-11-2019:36thheller
"Error: omg
    at new cljs$core$ExceptionInfo (/js/cljs-runtime/cljs.core.js:36930:10)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/cljs-runtime/cljs.core.js:36991:9)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (/js/cljs-runtime/cljs.core.js:36987:26)
    at eval (/js/cljs-runtime/demo.browser.js:19:29)"
#2019-11-2019:37donyormNow I'm getting this error
Source map error: Error: request failed with status 404
Resource URL:  line 827 > eval
Source Map URL: cljs.core.js.map
I wonder if my routing is messed up. Anyway for me to tell what url it's looking for the source-map at?
#2019-11-2019:37donyormThanks for the help by the way, I appreciate this#2019-11-2019:38donyormMissed the source map url#2019-11-2019:38donyormdoesn't seem to be using the asset-path#2019-11-2019:39thhelleryour config is fine but it appears you are using a custom webserver?#2019-11-2019:39thheller(there is no config for that in the config you pasted)#2019-11-2019:39thhellerso what is running at localhost:3000?#2019-11-2019:39donyormSorry forgot I was doing that separately#2019-11-2019:39donyormIt's a ring webserver#2019-11-2019:40thhellerdoes it serve properly?#2019-11-2019:40donyormThe code frontend and backend are running on the same machine so I needed to have ring server it up#2019-11-2019:40donyormAnd yes it does#2019-11-2019:40thhellerand you are accessing the page via http://localhost:3000?#2019-11-2019:40donyormYep#2019-11-2019:41thhellerand the script is included via <script src="/js/main.js">?#2019-11-2019:42donyormyes#2019-11-2019:42thhellertry setting :devtools {:loader-mode :script} in your build config#2019-11-2019:43thhellerdoubt that changes anything but who knows#2019-11-2019:44thhellerfirefox devtools are still kinda bad#2019-11-2019:44donyormThat did it#2019-11-2019:44donyormThanks#2019-11-2019:44thhellerhmm that should not have done anything 😛#2019-11-2019:45donyormWell I'll roll with it for now. Thank you so much for the help#2019-11-2019:48thhellerguess I broke firefox somehow. hot-reload doesn't trigger at all anymore for me#2019-11-2019:48donyormIt was being a little weird with me, but it's still working#2019-11-2019:54thhelleroh nvm .. just broke because I was messing with the compiler 😛#2019-11-2019:54donyormThat would do. Seems to be working fine for me, other than the fact that my server is not serving the proper mimetype for JS files. Guess I'll have to fix that#2019-11-2019:56thhellerI'll try to figure out why it isn't loading the source maps anymore. It used to work fine the last time I tested in Firefox#2019-11-2019:56thhellerand it is still working fine if errors are thrown at runtime#2019-11-2019:56thhellerbut no longer for anything logged while loading#2019-11-2021:11thheller@aisamu I'm not able to reproduce the goog.math.Long error you ran into yesterday. is it possible you are including two separate builds using the closure library in some way?#2019-11-2021:12aisamuHmmm, I'm not sure. It's definitely not the goal#2019-11-2021:24aisamuI'll dig some more, thanks for checking it 🙂#2019-11-2021:24thhellerI found one issue with :npm-module but I can't see how that possibly leads to your error#2019-11-2021:25aisamuWould you like me to check for something in specific? (e.g. I'd expect multiple requires to be de-duped by webpack, for example)#2019-11-2021:27thhellerif anything they would be completely separate builds. can't see how it would include the same build twice#2019-11-2022:15thhellertry 2.8.74, maybe that fixes it for reasons I can't explain 😛#2019-11-2111:31aisamuHahahah. Tried it but no luck 😕#2019-11-2119:29aisamuStill can't explain the failure, but noticed two major changes while diffing the failing js bundle: Some TLD's are now wrapped in a parenthesis
- cljs.core._STAR_print_newline_STAR_ = false;
+ (cljs.core._STAR_print_newline_STAR_ = false;)
goog.math.Lang is wrapped/provided differently
;;;;;;;;;;;;;
;; Old

goog.provide("goog.math.Long");
...
goog.math.Long = function(low, high) { ...}
...
goog.math.Long.getMinValue = function() { ... } 

;;;;;;;;;;;;;
;; New

goog.loadModule(function(exports) {
  ...
  goog.module("goog.math.Long");
  ...
  var Long = function(low, high) {...}
  ...
  Long.getMinValue = function() { ... }
  ...
  exports = Long;
  return exports;
});
module.exports = goog.math.Long;
:man-shrugging: Will keep digging....
#2019-11-2119:32thhellerlooks normal#2019-11-2119:33thhellerthe closure compiler/library moved to a new format for the goog.math.Long ns#2019-11-2119:34thhellerit works fine in the browser. maybe something weird going on for npm-module. it does work in node. I'll try to get a webpack test setup going#2019-11-2119:57aisamuOK! Thanks! I'll report back if I find something else#2019-11-2021:26grounded_sageI got this funny experience where I can't compile tailwind in a shadow-cljs project.#2019-11-2021:27grounded_sagenpx tailwind build styles.css -o output.css This command works normally but inside a folder that has a shadow-cljs project it doesn't??#2019-11-2021:28thhellerand how does it fail?#2019-11-2021:28thhellerI use tailwind myself and had no problems so far?#2019-11-2021:28grounded_sageIt takes styles.css which is
@import "tailwindcss/base";

@import "tailwindcss/components";

@import "tailwindcss/utilities";
and outputs the same content into output.css
#2019-11-2021:29grounded_sageIt doesn't actually create the styles. I remember you saying you used it so I don't see how this is happening.#2019-11-2021:29thhelleruhm the @import syntax requires postcss?#2019-11-2021:30thhellerhttps://tailwindcss.com/docs/installation/#2-add-tailwind-to-your-css#2019-11-2021:30grounded_sageOh yep#2019-11-2021:31grounded_sagejust a silly copy paste error#2019-11-2021:31grounded_sage😅#2019-11-2021:31grounded_sagethat's embarrasing haha#2019-11-2105:41QuestI'm using shadow-cljs to compile react-native to an Android emulator (code is forked from https://github.com/PEZ/rn-rf-shadow ) It works fine until I encounter an error. Sometimes they disconnect the CIDER nREPL (started via Emacs M-x cider-jack-in-cljs) with the runtime in the Android VM, then all REPL commands result in:
example.repl> (js/alert "test")
REPL command timed out.
Is there a way to recover from this state? Reloading the app via CMD+M (in the emulator) doesn't re-establish the connection from Emacs to the in-process nREPL
#2019-11-2108:52p-himikJust to make sure - does only js/alert timeout or any command (given that you haven't executed js/alert before it). The thing is - js/alert is blocking. The execution will not continue till you interact with the pop-up dialog.#2019-11-2109:34Questany command gives the REPL command timed out unfortunately#2019-11-2105:52Quest(note that the hot-reloading part of shadow-cljs still works fine, it's just the REPL connection that gets borked)#2019-11-2110:52thhellerthe problem is that in android the react-native app does not disconnect the websocket when you reload the app#2019-11-2110:52thhellerso shadow-cljs thinks that is still connected but never gets a reply back#2019-11-2110:53thhellerI added (shadow.cljs.devtools.api/repl-runtime-clear) to get rid of "stale" connections like that but it has to be called from a CLJ REPL#2019-11-2111:25QuestThanks @thheller, appreciate that there's a way to do this. I wrote a section for my README.md but wanted to repost here for channel record. Recover disconnected shadow-cljs REPL You might accidentally crash your react-native app on your emulator/browser with a big red error screen. You can hit Reload to restart the app into a working state, but putting any command into your shadow-cljs REPL will time out.
myapp.core> (js/alert "test")
REPL command timed out.
To recover this you'll need to: 1) Quit the CLJS REPL 2) Tell shadow-cljs to clear its REPL connection 3) Reconnect the CLJS REPL The following commands should achieve this.
cljs.user> :cljs/quit
;; wait at least 5 seconds for session cleanup
user> (shadow.cljs.devtools.api/repl-runtime-clear)
user> (shadow/repl :app)
#2019-11-2111:26thhellernote that the cleanup timeout is currently 5sec#2019-11-2111:27thhellerso if you do this to fast it might not kick the old session#2019-11-2111:28Quest👍 & updated the note#2019-11-2111:28thhellerno the wait has to be before repl-runtime-clear#2019-11-2111:28thhellernot before opening the REPL again#2019-11-2111:30QuestAhh, good catch. Fixed again#2019-11-2111:30thhelleralso only need to wait 5sec after reloading the actual app. so may not need to wait at all depending on how fast you do this 😉#2019-11-2111:31QuestHmm, my REPL never recovers from the disconnected state after hitting Reload . That's after I tank the app with something bad like (js/require "foo")#2019-11-2111:32Questthe manual steps fix it, but haven't observed autocorrecting behavior#2019-11-2111:32thhellerdunno. gotta go right now, be back later#2019-11-2111:33QuestNo sweat, gotta sleep soon myself. If you have any recommendations I'll try them tomorrow, but thanks either way 🙂#2019-11-2109:03orestisSo @thheller I noted that you mentioned in #cljs-dev that CLJS is stuck at an older version of Google Closure compiler -- is that something that carries over to shadow-cljs too or do you override the google closure dependency?#2019-11-2110:51thhellershadow-cljs uses the latest closure compiler and library. it does override those yes.#2019-11-2110:48Filipe SilvaI'm having some trouble using the main option for node-test targets... given this namespace:
(ns app.core-spec
  (:require [cljs.test :refer-macros [deftest is]]))

(deftest something (is true))
and config:
:test {:ns-regexp "app.core-spec"
         :output-to "out/test.js"
         :target :node-test}}
running the tests works:
$ shadow-cljs compile test && node out/test.js
shadow-cljs - config: D:\sandbox\devcards-test\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - socket connect failed, server process dead?
[:test] Compiling ...
[:test] Build completed. (47 files, 2 compiled, 0 warnings, 2.04s)

Testing app.core-spec

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
Done in 13.20s.
but if instead I require the test runner:
(ns app.core-spec
  (:require [cljs.test :refer-macros [deftest is]]
            [shadow.test.node :as stn]))

(deftest something (is true))

(defn main []
  (stn/main))
and alter the config to use my main
:test {:main app.core-spec/main
         :output-to "out/test.js"
         :target :node-test}}
no tests will be found:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3f545e5256547f6d7a7b12670e7c09"}, :content ("[email protected]")}
#2019-11-2110:50Filipe SilvaI also tried using both :main and :ns-regexp at the same time but that failed with a weird error#2019-11-2110:54Filipe Silva#2019-11-2110:55thhellerwhy are you trying to override :main?#2019-11-2110:57thhellerI think the issue with par-compile might be that it sets up a circular dependency if your ns-regexp matches your main ns#2019-11-2110:57thhellerpossible that I don't check that#2019-11-2110:58thhellermake sure that the "runner" doesn't match the regexp#2019-11-2110:59thhelleralso do yourself a favor and run shadow-cljs server separately. waiting 12sec to a test to run is horrible#2019-11-2111:00Filipe Silvayeah on the real project I start the server separately, I didn't do it here because I forgot#2019-11-2111:00Filipe SilvaI'm trying to override main because on my real setup there's some logic I need to run conditionally at the start#2019-11-2111:01Filipe Silvaso the intended usage is that both main and ns-regexp need to be set?#2019-11-2111:01thheller:ns-regexp controls which namespaces are included yes#2019-11-2111:02thhelleryou can leave it to something that doesn't match and include all the namespaces in the :main ns directly#2019-11-2111:02thhellerdoesn't matter really#2019-11-2111:03Filipe Silvathe user guide mentions that it defaults to "-test$"#2019-11-2111:03thhellerit does#2019-11-2111:03Filipe Silvaso I thought that if I set main without setting ns-regexp it would run the tests in the included namespaces in main, including itself#2019-11-2111:04thhellerTesting app.core-spec#2019-11-2111:04thhellerthat doesn't match -test?#2019-11-2111:05Filipe Silvait doesn't, so it falls into the case you suggested: > you can leave it to something that doesn't match and include all the namespaces in the :main ns directly#2019-11-2111:06Filipe Silvans-regexp didn't match anything but in main there was a test#2019-11-2111:06thhellerwell not really ...#2019-11-2111:07thhellerWHAT THE FUCK IS THIS NEW FUCKING SLACK SHIT#2019-11-2111:07Filipe Silvathe future is coming thheller, and it is annoying#2019-11-2111:08thhellerdrives me mad ... can't type :main anymore without it trying to make it something else#2019-11-2111:08thhellerso the way this works is that :ns-regexp is responsible for adding namespaces#2019-11-2111:08Filipe Silvait does get better though, on my work slack it started last week and everyone had the same reaction, this week no one seems bothered#2019-11-2111:09thhellerjust accepting everything is shit I guess ...#2019-11-2111:09thheller:main only controls running the tests and it loads the tests via a macro#2019-11-2111:10thhellerthats why the :main ns needs a {:dev/always true} annotation in the ns#2019-11-2111:10thhellerotherwise the macro can't update properly#2019-11-2111:10thhellerok slack ... just don't highlight ... thats fine ...#2019-11-2111:11thhellermight be a problem if you just delegate to the default runner ns#2019-11-2111:13thhellertotally possible this all has a bunch of issues. I basically only tested the default setup#2019-11-2111:14Filipe Silvaok, I think I'm starting to understand a bit better... so if I want to both have my own main (for init logic), and not match any ns (because I don't have dedicated test ns), is there an approach I can take?#2019-11-2111:14Filipe Silvayou mentioned just including the ns in the main ns#2019-11-2111:14Filipe Silvawill try that#2019-11-2111:15thhellerif you write your own main-ns I would suggest copying the default as is and only override what you need#2019-11-2111:15thhellerdo not delegate to it#2019-11-2111:16thhellerthe interaction with the macro is a bit funky#2019-11-2111:16thhellerhttps://github.com/thheller/shadow-cljs/blob/0aaa281853d113829d01a6ba09cc328578b969cc/src/main/shadow/test/node.cljs#L15#2019-11-2111:16thhellerthats the macro#2019-11-2111:17thhellerand the :main ns needs https://github.com/thheller/shadow-cljs/blob/0aaa281853d113829d01a6ba09cc328578b969cc/src/main/shadow/test/node.cljs#L2#2019-11-2111:18Filipe SilvaI tried these ns and it seems to run with main
(ns app.core-spec
  (:require [app.core-spec-two]
            [shadow.test.node :as stn]))

(defn main []
  (stn/main))
(ns app.core-spec-two
  (:require [cljs.test :refer-macros [deftest is]]))

(deftest something (is true))
#2019-11-2111:19Filipe Silvawill try the way you just mentioned#2019-11-2111:19Filipe Silvahmm, so the above finds and runs the single tests#2019-11-2111:20Filipe Silvabut using the ns as you said does not#2019-11-2111:20Filipe Silva
(ns app.core-spec
  {:dev/always true}
  (:require
   [shadow.test.env :as env]
   [cljs.test :as ct]
   [shadow.test :as st]))

;; FIXME: add option to not exit the node process?
(defmethod ct/report [::ct/default :end-run-tests] [m]
  (if (ct/successful? m)
    (js/process.exit 0)
    (js/process.exit 1)))

(defn main []
  (-> (env/get-test-data)
      (env/reset-test-data!))
  (st/run-all-tests))
#2019-11-2111:20Filipe Silva
$ shadow-cljs compile test && node out/test.js
shadow-cljs - config: D:\sandbox\devcards-test\shadow-cljs.edn  cli version: 2.8.69  node: v10.16.0
shadow-cljs - connected to server
[:test] Compiling ...
[:test] Build completed. (46 files, 1 compiled, 0 warnings, 0.82s)



Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
Done in 1.83s.
#2019-11-2111:20thhellerplease just out of habit STOP using the same namespace pattern for :mountain:#2019-11-2111:20thhellerok slack ... whatever ...#2019-11-2111:24orestishttps://quuxplusone.github.io/blog/2019/11/20/slack-rich-text-box/#2019-11-2111:27thhelleryeah thats it 😛#2019-11-2111:28thhellerhorrible for clojure especially I guess#2019-11-2111:28thhellerevery keyword will be a shitty emoji 😛#2019-11-2111:29orestisAnd ruby#2019-11-2111:29orestisHN thread (https://news.ycombinator.com/item?id=21589647) says to use /feedback to complain, let's see 🙂#2019-11-2111:20thhelleruse something like app.test-runner or so for :main#2019-11-2111:21thhellerplease setup a demo repo for this .. can't look into it further right now#2019-11-2117:03Filipe Silvaset up a repro, and I think there isn't anything to look into proper#2019-11-2117:03Filipe Silvahttps://github.com/filipesilva/shadow-cljs-node-test-variants#2019-11-2117:03Filipe Silvathis repo has 2 deftests#2019-11-2117:03Filipe Silvain one of them, devcards is also imported, but not used#2019-11-2117:04Filipe Silvarunning yarn test will run node-test test targets with ns-regexp, main pointing at a import of shadow.test.node, and main pointing at a copy of shadow.test.node#2019-11-2117:05Filipe Silvaboth ns-regexp and main pointing at a copy of shadow.test.node work as expected and show two tests running#2019-11-2117:05Filipe Silvamain pointing at a import of shadow.test.node only shows one test running (the one in the ns that doesn't import devcards)#2019-11-2117:06Filipe SilvaI don't know why the devcards import should be relevant, but you told me to use a copy anyway so I suppose it's related#2019-11-2117:06Filipe Silvamaybe because devcards also declares a deftest#2019-11-2111:21Filipe Silvaroger, will do#2019-11-2111:21Filipe Silvathank you for your time#2019-11-2115:18Elirazhow would I tell shadow-cljs where is my html file to take from?#2019-11-2115:19ElirazI mean, do I have to manually copy it to the build/target folder?#2019-11-2115:19thhellershadow-cljs has no support for processing html, so yes you copy it manually or with another tool#2019-11-2115:20Elirazokay. maybe I could use webpack here to do it#2019-11-2119:07Drew VerleeWhen trying to host my app, i'm noticing that the the requests by the browser triggered in the index.html to load the other assets (e.g main.js) are returning 404. I assume there is some path issue i need to resolve. I assume this is a function of the hosting service (in this case google bucket) but i wanted to ask here in case there is some configuration concept im missing. I dont think any of the production settings (e.g url hashing) would make a difference and i didnt see anything else listed.#2019-11-2119:11Drew Verleemaybe setting homepage in the package.json?#2019-11-2119:26thhellerif the initial load already fails then your path in the html is incorrect?#2019-11-2119:27thhellerI haven't used the google stuff before. I'm assuming you upload the files somewhere so make sure you upload all the files properly?#2019-11-2119:35Drew VerleeThanks heller. The issue seems to be that the requested url is missing the bucket name e.g. its requesting https://storage.googleapis.com/js/compiled/main.js but the file is at https://storage.googleapis.com/<bucket-name>/js/compiled/main.js#2019-11-2119:36thhellerthat means you use :asset-path "/js" and likely need "js"#2019-11-2119:36thhelleror just including the bucket-name if you know it#2019-11-2119:37Drew Verleebecause /js implies relative?#2019-11-2119:37thhellerno /js implies absolute from the domain root#2019-11-2119:37thhellerjs is relative to the current file#2019-11-2119:37thhellerthat'll become js/main.js loaded from index.html#2019-11-2119:38Drew Verleeoh#2019-11-2119:39Drew Verleethat will be it then#2019-11-2119:41thhellerif you just have one file you only need to change your HTML#2019-11-2119:42thhellerso that it loads <script src="js/main.js"> :asset-path does nothing for the initial file, only if you use multiple :modules#2019-11-2119:43Drew Verleewe do use multiple modules.#2019-11-2119:44thhellerok then :asset-path is relevant too. still need to change the html for the initial load though#2019-11-2119:52muhangaIs it possible to get some sort of debug in compilation process using console flags? I am trying to debug my configuration of :source-paths ["src" "env/dev"] (ns-es in "env/dev" are ignored for some reason).#2019-11-2120:06lilactown@muhanga do you mean that the namespaces are not found, even though the files exist on disk?#2019-11-2120:23muhanga@lilactown Yes. I have namespace 'tst.cards' declared in "env/dev" dir and it is ignored and not taken into compilation. I have :lein true enabled, but i am not sure how those two interract.#2019-11-2120:33lilactownwhat’s the file path to that namespace?#2019-11-2120:34lilactownenv/dev/tst/cards.cljs?#2019-11-2120:34lilactownare the source paths defined in a leiningen profile?#2019-11-2120:38muhanga@lilactown file path is env/dev/cljs/tst/cards.cljs . And source paths are defined in leiningen profile and i am able to build using lein.#2019-11-2120:39lilactownThat path is wrong. It will resolve the ns from the root of the source path#2019-11-2120:42lilactownit’s looking in env/dev/tst/cards.cljs and not finding the file#2019-11-2120:42lilactownif you want to nest it in that cljs directory then you need to add to the source-path instead#2019-11-2120:43lilactown:source-paths ["src" "env/dev/cljs"]#2019-11-2120:47muhangaOkay, this actually shed some light. Does shadow-cljs actually use :source-paths declared in lein config when :lein true is declared? Or it uses :cljsbuild\{build}\source-paths ?#2019-11-2120:48muhangaCause i think that anything inside :cljsbuild are actually ignored.#2019-11-2120:48lilactown:lein true will use the source-paths defined in your leiningen config. it does not use anything to do with cljsbuild#2019-11-2120:49muhangaNasty. so if i want to be able to build cljs using both lein and shadow i basially need to disable :lein true#2019-11-2120:49lilactownif you prefer to split your config and source paths between CLJ and CLJS, then what I typically do is use leiningen to manage CLJ dependencies and source paths and shadow-cljs.edn to manage CLJS dependencies and source paths#2019-11-2120:50lilactownyou can also specify a profile to use, if you prefer#2019-11-2120:50dpsuttonwhy do you want to be able to build with both lein and shadow?#2019-11-2120:50lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2019-11-2120:52muhanga@lilactown Ouch. I need to read docs again. And couple of time more.#2019-11-2120:54muhanga@dpsutton as of now i am trying to understand how shadow works so using it on existing lein project help me immensly. So i am trying to make them work in parallel. But more i try, more i think this is not really ideal approach to learning.#2019-11-2120:55dpsuttoni would branch and move over. if works PR#2019-11-2120:56dpsuttoni did exactly that and unfortunately we couldn't move over since we serve our front-end over https and local networking hyjinx but figwheel will happily connect an insecure websocket over ws not wss#2019-11-2121:02thheller@dpsutton :devtools-url "`http://localhost:9630``"` should work and also use ws:// even if you serve the initial page over https?#2019-11-2121:03thheller@muhanga any cljsbuild config is ignored but you can just setup regular :profiles {:dev {:source-paths ["src" "env/dev"]}} with :lein true#2019-11-2121:03David Pham@dpsutton there are some Clojure libraries that only works with lein#2019-11-2121:03dpsutton@thheller i'll try that this afternoon. thanks#2019-11-2121:03David Phamhttps://github.com/oliyh/kamera#2019-11-2121:04David PhamI wish I could use shadow-CLJS with that :)#2019-11-2121:05thhellerkinda tough if that uses figwheel directly 😛#2019-11-2121:05dpsuttonthat uses figwheel main?#2019-11-2121:06dpsuttonbut i'm sure it could be ported over. just no benefit i suppose. i don't think devcards require figwheel just its a bit easier#2019-11-2121:08thhellerdevcards works just fine in shadow-cljs#2019-11-2121:09thhellerbut kamera has a bunch of clojure code that is talking directly to figwheel#2019-11-2121:09thhellerso that all would need to be replaced#2019-11-2121:09thhellerdunno why it is talking to figwheel at all though#2019-11-2121:09muhangaBasically i am trying to bootstrap spring + reagent + d3 + devcards combo to shadow-cljs (with minimal changes of lein configs) and everyting expect devcards works very nice with shadow. Looks like i will need to bite the bullet and do some rewrites from scratch. Thank you all.#2019-11-2121:09thhellerwhich part of devcards doesn't work?#2019-11-2121:09dpsuttondevcards require a constant to be set. have you ensured that is set?#2019-11-2121:12muhanga@thheller for some reason devcards can't find react during initialization emiting bunch of "React is not defined"#2019-11-2121:12thhelleryes, that is because devcards doesn't declare its dependency on react in any way#2019-11-2121:13thhellerso you include [cljsjs.react] and [cljsjs.react.dom] in your code somewhere before including devcards#2019-11-2121:13thhellerthen it should be fine#2019-11-2121:25muhangaYep. It worked.#2019-11-2121:25muhangaI am happy camper now. Thank you very much for this bits and pieces of knowledge.#2019-11-2121:26David PhamHaha the devcard trick also took me a while to figure out #2019-11-2212:59thhelleranyone using :npm-module please let me know what you use it for so I can better decide what to do about it. currently a good chunk of the open shadow-cljs issues are about problems with :npm-module and it is becoming harder to maintain with each new closure compiler release. https://github.com/thheller/shadow-cljs/issues/605#2019-11-2603:11aisamuOh, my! We rely heavily on it, converting an existing JS webpack project into a CLJS one, piece by piece!#2019-11-2609:40thhelleryes but do you actually require separate namespaces? I mean from the JS code do you actually var x = require("wherever/one.ns.from-your-app") for more than 1 namespace?#2019-11-2214:15nickmbaileywe have a utility library that among other things we use to construct schema definitions for our domain and then share those definitions across all our codebases. this includes our frontend which is written in plain javascript. we bundle up this utility library using shadow-cljs with :npm-module and then we include it in our ui app the same as any other dependency#2019-11-2214:17nickmbaileymostly the schema definitions are responsible for taking a big json blob off the wire and coercing it into something useable in clojure/js as well as proving a useful error if it doesn't conform to the model we expect#2019-11-2214:17nickmbaileyhopefully that helps#2019-11-2214:19thhellerbut you are not using any of the :npm-module specific things? like require("./some-folder/one.simple.namespace") and require("./some-folder/another.namespace")?#2019-11-2214:19thhellerits just one primary export I presume like import { checkSchema } from "somewhere"?#2019-11-2214:21nickmbaileywell its spread across multitple files#2019-11-2214:21nickmbaileyso
import * as userSchema from 'utilityboss/public/utilityboss.schema.users';
#2019-11-2214:23nickmbaileyand another namespace for other collections of related things#2019-11-2214:37Lucas BarbosaI'm trying to use Google's OAuth api. I installed the npm library using npm install googleapis and I am trying to require it in my .cljs file. This is my ns form:
(ns app.core
  (:require [re-frame.core :as rf]
            [reagent.core :as reagent]
            ["googleapis" :refer [google]]))
The browser outputs the following error:
#2019-11-2214:37Lucas BarbosaDid I forget to do something? I tried scraping the Internet for more clues but I could not find anything#2019-11-2214:40Lucas Barbosa#2019-11-2217:14thheller> Node.js client library for using Google APIs. #2019-11-2217:14thheller@lvbarbosa are you sure those are supposed to work in the browser? quick glance at the docs suggests they are meant for node?#2019-11-2217:20thhelleryeah that definitely isn't made for the browser. looks like you are supposed to use this for the browser https://developers.google.com/docs/api/quickstart/js#2019-11-2220:33Lucas BarbosaSorry for the late response! facepalm my bad, I'll take a look on the one you referenced! Thanks a lot#2019-11-2217:21Drew Verleewhen building my app via shadow cljs watch app i get the following logs:
[:app] Build failure:
Module Entry "some.namespace.module.main was moved out of module ":module".
It was moved to ":main" and used by #{:module :main}.
I'm not sure what the logs are telling me. I understand there is a build failure. But is it saying the module move (i am trying to do code splitting) is the issue?
#2019-11-2217:22thhellerfor code splitting to work you can't have a direct require on the namespaces#2019-11-2217:22thhellerso likely something in your :main directly required something from :module#2019-11-2217:22Drew Verleeright#2019-11-2217:23lilactownyeah, what it's saying is: there's a dependency inside your :main module on the :module entry point#2019-11-2217:23lilactownif :main gets loaded without :module then it will break the code#2019-11-2217:24thhellerthe error just tells you that you did code splitting wrong as your ns require setup caused all code to me moved to one module and not where you intended things to go#2019-11-2217:43Drew VerleeEach ns becomes a module right?#2019-11-2217:43thhellerno#2019-11-2217:43thhellereach entry namespace plus all of its dependencies, becomes one module/chunk#2019-11-2217:44thhellerwith :depends-on setting up the relationships#2019-11-2217:47Drew VerleeThanks. So if my goal is to split the code up, ill have to make sure everything is lazyly imported. Is there a way to know the dependency tree so that i can systematically prune out deps?#2019-11-2217:48thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_report maybe#2019-11-2217:48Drew Verleee.g main -> foo -> bar main -> bar I can see main points to bar directly in the main ns, but how would i track down main -> foo -> bar. I assume this is the problem im having.#2019-11-2217:49thhellerwhen you open the shadow-cljs ui and run the build through that (default at http://localhost:9630) there is a basic interface to show dependencies#2019-11-2217:49thhellerselect the namespace and it'll show you everything that was responsible for including it#2019-11-2217:49thhellerno fancy visuals though#2019-11-2218:53Drew Verleethanks again 🙂 Assuming everything builds correctly. What would the error: Unknown module: <module name> imply?#2019-11-2218:59thhellerI don't know?#2019-11-2221:39padraicHi, I'm reading through the docs and am trying to do some in browser testing. The docs mention that it contains a built in test runner but I cannot seem to trigger it?#2019-11-2221:50thhellerwhat did you try?#2019-11-2221:59padraicI added the configuration in the docs and got the server up and running. I don't know how to get the tests to run in-browser is the thing#2019-11-2222:00thhellerwhich config did you add?#2019-11-2222:02padraic
:builds {:test     {:target    :browser-test
                     :test-dir  "target/test"
                     :ns-regexp "-test$"
                     :devtools  {:http-port          8021
                                 :http-root          "target/test"}}
#2019-11-2222:02padraicNo runner#2019-11-2222:02thhellersee the :http-port so you open #2019-11-2222:03padraicYes#2019-11-2222:04thhellerand that doesn't run the tests?#2019-11-2222:04padraicI got that far but there was no console output or any evidence of something happening#2019-11-2222:05thhellerthe page you should see is the test report?#2019-11-2222:08padraicLet me validate a thing or two and I'll get back#2019-11-2222:08thhellerthe result should look something like this https://github.com/bhauman/cljs-test-display#2019-11-2222:09padraicaah that's nice. I hope I'll get it going#2019-11-2222:16padraicI got it, had set the test-dir to be the same as the browser target#2019-11-2222:16padraicconflicting index.htmls#2019-11-2222:16padraicThanks!#2019-11-2300:07Drew VerleeWould it be helpful to create a spec for the shadow cls config? I could see that along with Bruce's spell spec lib going a long way to catching some configuration mistakes up front.#2019-11-2300:10thhellerthey are already partially spec'd#2019-11-2300:11Drew VerleeGreat, I'll take a look and see if I can do anything more.#2019-11-2300:16thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/config.clj and then each target extends the multispec https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj#2019-11-2300:16thhellercould probably do more though but I don't like closing down the config format too much. so to some degree I don't it want to complain about keys it doesn't know#2019-11-2300:17thhellermaybe only if they are somewhat close to some known keys#2019-11-2300:17thhellerdunno how the spell check stuff does stuff#2019-11-2310:02thhellerquestion for the compiler nerds here: what is the correct term for this in compiler terms? https://ask.clojure.org/index.php/8879/cljs-should-macros-support-lifting-vars-to-the-ns-level#2019-11-2317:02lilactownis this what Clojure refers to as "interning"?#2019-11-2317:07thhellerno, at least not in the context of String.intern or keywords#2019-11-2317:08lilactownI was thinking of https://clojuredocs.org/clojure.core/intern#2019-11-2317:09thhellerno. that would have the same issues. the issue is declaring the var outside the current context. so it doesn't have to check if the work was already done previously#2019-11-2317:10thhellerthere are plenty of other ways to do what I want to do ... but the variant with "lifting" the var would be the most efficient#2019-11-2317:10lilactownyeah I see what you're saying#2019-11-2317:11thhellerreify is one of the other examples that would benefit by this#2019-11-2317:11thhellerjust look at the code it currently generates to see why#2019-11-2317:12lilactownthe only potential stumbling block I can think of is keeping it semi-hygienic, right#2019-11-2317:12lilactownand Clojure is not historically all-in on hygienic macros so seems in line#2019-11-2317:13thhellerthis is completely "hygenic"? whatever that means ... 😉#2019-11-2317:15lilactownhehe, I'm referring to the chance of clashing with a var already def or interned in the namespace#2019-11-2317:15lilactownobviously gensym solves that. just thinking out loud#2019-11-2317:15thhelleryeah the chances of that are rather slim given the use of (gensym "fragment__")#2019-11-2317:16thhellerif I only knew the correct term for this I could look at other lisps and how they do it#2019-11-2317:16thhellerthey must be able to do this in some way#2019-11-2317:17thhellerwell I guess they might just automatically lift the def out of the current scope .. no clue.#2019-11-2317:18lilactownI think a lot of lisps would frown on this because it kind of breaks the mental model of local and hygienic macros#2019-11-2317:18lilactownso it might not be something that has all that much prior art#2019-11-2317:18thhellerreify is the prior art. it needs to do exactly this.#2019-11-2317:19thhellerin clojure thats no problem since it just generates a class outside of the var system#2019-11-2317:20thhellerin CLJS it can't. so it just dumps the code directly in there wrapped in an exists? check#2019-11-2317:21thhellerthis isn't something I made up ... I'm 100% sure there is a regular compiler term for this
#2019-11-2317:21thhellermy google fu just sucks 😛#2019-11-2317:22lilactownHoisting?#2019-11-2317:23thhellermaybe. not sure. dunno if that refers to moving it out of the current scope too#2019-11-2317:26thhellerI'll create some benchmarks too see if I'm just overthinking this .. probably not worth worrying about this so much if the JIT is gonna do this for us anyways#2019-11-2319:54lilactownI know that @U0FR82FU1 did some work in uix to hoist static data to a shared global ns. Might check that out and see if it gives you any ideas#2019-11-2311:58grounded_sageAny idea how I can resolve this problem?
The required JS dependency "@babel/runtime/helpers/interopRequireDefault" is not available, it was required by "node_modules/react-dates/lib/index.js".

Search in:
	/Users/user/my-project/node_modules
You probably need to run:
  npm install @babel/runtime/helpers/interopRequireDefault
When I run the npm install it gives me this
npm install @babel/runtime/helpers/interopRequireDefault
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@babel/runtime/helpers/interopRequireDefault" as it does not contain a package.json file.
#2019-11-2311:59grounded_sageI've trying to import the react-dates npm package#2019-11-2313:35awb99I would like to use shadow-cljs to require arbitrary npm and cljs dependencies from a self hosted clojurescript repl. I saw example at https://github.com/thheller/shadow-cljs/blob/0e28c615cd75d4cbce27ede7a8f7f70785d42c86/src/dev/demo/selfhost/simple.cljs. Now my question is to allow dependency definition at runtime - do I have to start shadow cljs via command line with generated settings files. Or would I rather run it via its compiler api?#2019-11-2313:37awb99What I want to do is provide dependencies for a few important cljs and npm dependencies out of the box. And then everything else should be fetched from npm / maven at runtime and be served to the load-fn in the browser repl.#2019-11-2314:08padraicIs there any reason to be using deps.edn aliasing to leverage shadow-cljs?#2019-11-2314:10David PhamI use deps.edn for local libraries #2019-11-2315:15thheller@grounded_sage likely a dependency conflict of @babel/runtime. ie. react-dates depending on a different version than present in node_modules/@babel/runtime#2019-11-2315:24grounded_sagehouse of cards land of JS#2019-11-2315:16thheller@hoertlehner the self-hosted stuff only supports "pre-packaging" npm dependencies. if you want to do it dynamically then you must build that yourself using regular self-hosted cljs stuff. shadow-cljs can't help for those.#2019-11-2315:17grounded_sage@thheller I'd like to know how I can fix this. But in the meantime I am using HTML date input element because I'm just prototyping atm.#2019-11-2315:19thhellermake sure all the right versions are installed. standard dependency conflict resolving.#2019-11-2315:20awb99@thheller Thanks Thomas! Could you point me to the location where you do the npm prepackaging in your code?#2019-11-2315:21thhellerI can but none of that will be relevant to the self-hosted stuff. It uses the Closure Compiler heavily which is written in Java and won't be available for self-hosted#2019-11-2315:21thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/bootstrap.clj#2019-11-2315:22thhellerthis does all the packaging but its mostly using standard shadow-cljs stuff#2019-11-2320:08Elirazhow do you check for dependencies update?#2019-11-2415:36martinklepsch@thheller I’m playing around with the prepl stuff and am trying to use a version of shadow-cljs with some changes locally. Is it “supported” to provide the shadow cljs deps via tools.deps :local/root?#2019-11-2415:37thhellernot really. shadow-cljs has a bunch of java sources that need to be compiled. deps.edn doesn't deal with this#2019-11-2415:38thhelleryou can sort of use it I guess if you run lein javac in the :local/root dir#2019-11-2415:38thhellerbut I don't really keep the deps.edn updated so that is probably out of date#2019-11-2415:38martinklepschOk, do you have a workflow you’d recommend as an alternative?#2019-11-2415:41thhellerdunno what kind of changes do you have in mind?#2019-11-2415:42thhelleropen the shadow-cljs repo itself. run lein with-profiles +cljs repl and (require 'repl) (repl/go)#2019-11-2415:42thhellerthats why I do. (shadow.cljs.devtools.api/watch :browser) or any of the other tests builds#2019-11-2415:42thhellerlein with checkouts works too#2019-11-2415:43thhellerjust lein install works if you have to. I've never really worked on shadow-cljs from inside another project#2019-11-2415:43martinklepschok cool, I’ll give using the test builds a try then#2019-11-2415:43martinklepschthanks#2019-11-2417:32p-himikIs it possible to have :source-map true but not have //# sourceMappingURL=....map in the built JS file?#2019-11-2417:34thhellerwhy would you want that?#2019-11-2417:35p-himikI want to upload the source map to a third-party logging service instead of having it available on the production website. Having sourceMappingURL doesn't really hurt but it produces an extra 404 error if there's no map when I open the dev tools.#2019-11-2417:36thhelleryou could put empty files there 😉#2019-11-2417:37p-himikYeah, true. Feels just a tad dirty though. 🙂 But it's probably what I'll do.#2019-11-2417:37thhellerif you open an issue I can see how much it would take to add that. probably not much.#2019-11-2417:41p-himikDone! I've started looking into it myself, but there are a few places where the line gets appended, and some of those places have scary FIXME so I decided to ask here instead.#2019-11-2418:22p-himikAnother question - my manifest.edn contains a duplicated entry within :entries . Is this OK/normal?#2019-11-2418:28thhellerhmm?#2019-11-2418:29p-himikFrom the prod version: :entries [hgs.platform.core hgs.platform.core].#2019-11-2418:30thhellerdo you have it configured as :entries [hgs.platform.core] :init-fn hgs.platform.core/init or so?#2019-11-2418:31thhellerdoesn't really matter if its duplicated though. its still just included once#2019-11-2418:33p-himikYep, that's exactly how the main module is configured. I see, thanks!#2019-11-2418:36thhelleryou can skip the :entries if its just the same ns as :init-fn#2019-11-2501:05chancyWhat might the shadow-cljsjs shim look like for a library that only calls (.getSelection js/rangy) and (.init js/rangy)?#2019-11-2506:05lilactownI think you can pretty much npm i rangy and then in a file: cljsjs/rang.cljs#2019-11-2506:05lilactown
(ns cljsjs.rangy
  (:require ["rangy" :as rangy])

(set! js/rangy rangy)
#2019-11-2501:06chancyI was attempting to try out in a shadow-cljs project.#2019-11-2506:02lilactowntrying to import some es6 code on the classpath#2019-11-2506:02lilactownhttps://gist.github.com/Lokeh/98dbbde0c3a9ed70518efedcf9ac6dbb#2019-11-2506:02lilactownimporting clojure_lexer.js fails#2019-11-2506:02lilactown
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(NAME LexicalGrammar): repl_interactor/webview/clojure_lexer.js:2:19
let toplevel = new LexicalGrammar();
  Parent(NEW): repl_interactor/webview/clojure_lexer.js:2:15
let toplevel = new LexicalGrammar();

  Node(SCRIPT): repl_interactor/webview/clojure_lexer.js:1:0
import { LexicalGrammar } from "/repl_interactor/webview/lexer.js";
  Parent(ROOT): [source unknown]
#2019-11-2511:34thhellerdon't ever cut errors off please ... always include the full stacktrace. even if it looks like garbage. INTERNAL COMPILER ERROR is from the closure compiler ...#2019-11-2512:20thhellerit compiles fine for me btw#2019-11-2512:20thhellerbut it does have issues when loading and using :es6 output or above#2019-11-2517:46lilactownhmm, I thought I had to use :es6 output to consume ESM from the classpath?#2019-11-2517:47lilactownI moved all the JS code into a separate folder and used npm link instead of putting it on the classpath, which seems to work#2019-11-2520:26thhellerthe issue is with class#2019-11-2520:26thhellerthat has its own scoping rules so it is not accesible from other files when using the debug loader#2019-11-2520:27thhellersetting :es5 will transpile class out so it works fine then#2019-11-2510:16conanJust thought I'd report back on my experience of running a shadow-cljs REPL with Cursive. After being pointed in the right direction (thanks!) I'm running this script:
(require
  '[orchestra.spec.test :as stest]
  '[shadow.cljs.devtools.api :as api]
  '[shadow.cljs.devtools.server :as server])
(server/start!)
(api/watch :app)
(api/repl :app)
(stest/instrument)
This starts and restarts the compilation in my REPL with a single click. There's a lot of output at startup, but just the compilation result under normal operation. The backend (clojure) half of the application runs in a regular REPL and is used to serve the compiled files, so I'm not using the built-in webserver. My non-Cursive colleagues can easily start a REPL with npx shadow-cljs watch app, although we haven't yet tried cider jack-in. I'm very happy with this setup, compilation is extremely fast (this is often a problem with WSL, figwheel is much worse) and the dev workflow has to be one of the best available in any language.
#2019-11-2511:25grounded_sageHow do I access this environment variable?
{...
 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :closure-defines {app.core/URL #shadow/env "APP_URL"}
   ...}}}
#2019-11-2511:27grounded_sage(js/console.log "This is the URL: " shadow.env/URL) This is where my current thoughts are but I can't seem to figure out how I am supposed to access it.#2019-11-2511:29thheller@grounded_sage you'd have (goog-define URL "some-default") in app.core and access that like any other (def URL ...) in that ns#2019-11-2511:31grounded_sageOh ok. Maybe I asked that the wrong way. I'm trying to access .env variables during a CI build. Or do the --config-merge thing. But I'm sure how I then access that in the app. I was just defining inline to test accessing it.#2019-11-2511:31grounded_sageI think I get it now though#2019-11-2511:31thhellerthe browser doesn't have environment variables so you can't access them dynamically#2019-11-2511:32thhellerI typically recommend staying away from environment variables entirely#2019-11-2511:32thhelleryou don't need them .. much better to properly configure your app at runtime#2019-11-2511:32thhellerthat is really a blog post I should write ... this question comes up so often#2019-11-2511:33grounded_sageYea I've been reading through discussions on Github issues and old slack messages. It's not super clear to me even from that haha#2019-11-2515:44g7sHas anyone any problems with react hooks and shadow? I can’t for the life of me figure out what is wrong with react giving me this error https://reactjs.org/warnings/invalid-hook-call-warning.html#2019-11-2515:44g7sI have put up a super simple example that reproduces it#2019-11-2515:45g7shttps://github.com/g7s/minimal-hooks-error#2019-11-2515:46g7sI am not sure that it has anything to do with shadow though#2019-11-2515:46g7sjust asking#2019-11-2515:56g7salso I’ve found this issue that maybe is related (again not sure) https://github.com/thheller/shadow-cljs/issues/516#2019-11-2516:01thheller@g7s the issue is that you are calling (Test). that is invalid you must create a react element for that instead. so (r/createElement Test #js{}) or so#2019-11-2516:02thhellerand not nothing to do with shadow-cljs, just react#2019-11-2516:03g7s@thheller thanks a lot that was it#2019-11-2516:03g7sI guess its not my day 😛#2019-11-2517:57DerekIs there anyway to configure which routes hit the dev-server reverse proxy and which fallback to index.html?#2019-11-2520:22thheller@dpassen1 no. for more complex cases I'd advise using an actual proxy that is made for that stuff 😛#2019-11-2720:14Ian MWe ended up overriding the :handler of the dev-server to conditionally proxy requests based on URI: https://gist.github.com/ian-moore/ddf9019f713e10dc5b62e065d0fcc8fc#2019-11-2521:33kennyTried updating from shadow 2.8.67 -> 2.8.74 and I get this console warning logged:
js.js:74 shadow-cljs - failed to load module$node_modules$react_calendar$dist$entry
This prevents a required npm dep from loading causing the app to crash. Is there some new configuration required to get the latest shadow-cljs to work? I have tried rm -rf .shadow-cljs as well, which does not fit it.
#2019-11-2521:33thhellerwhat is the rest of the error?#2019-11-2521:33kenny
js.js:74 shadow-cljs - failed to load module$node_modules$react_calendar$dist$entry
shadow.js.jsRequire	@	js.js:74
shadow.js.require	@	js.js:100
eval	@	/js/cljs-runtime/com…nents.calender.js:4
goog.globalEval	@	main.js:836
env.evalLoad	@	main.js:2216
(anonymous)	@	main.js:3060
#2019-11-2521:34thhellerthere should be more .. with the actual error at the bottom#2019-11-2521:34thhellermore?#2019-11-2521:34kennyThere's a separate line that has this:
failed to load compute.ui.components.calender.js Module not provided: ./Calendar.css
env.evalLoad @ main.js:2218
(anonymous) @ main.js:3060
#2019-11-2521:34kennyThen a bunch of React errors.#2019-11-2521:34thhelleryeah, all triggered by that#2019-11-2521:34thhellerI fixed that in master#2019-11-2521:35kennyRight#2019-11-2521:35kennyOh ok. Best to just stay on 2.8.67 for now?#2019-11-2521:36thhellerhang on. I can make a release with the fix#2019-11-2521:39thheller2.8.75 should be ready to go#2019-11-2521:41kennyFixed it! Thanks.#2019-11-2522:01thhellerhmm looks like that release is bad .. some AOT issue#2019-11-2522:18thheller2.8.76 in case you get some errors related to goog.define can't explain why that broke in the last release but AOT was behaving strangely before#2019-11-2523:43thhelleranyone around using shadow-cljs in a somewhat large app? especially those with lots of namespaced keywords? I added a few new compiler tweaks and would like to collect some before/after numbers regarding code size#2019-11-2600:11lilactownwe have a pretty large re-frame app at work#2019-11-2600:13thhellertry 2.8.76 and generate a build report and then one with :compiler-options {:shadow-keywords true} looking to compare the gzip size before/after#2019-11-2600:13thhellerimpact will be bigger with lots of namespaced keywords though#2019-11-2600:15thhelleroops :compiler-options not :js-options#2019-11-2600:28lilactownin our main bundle, • before: [JS: 4.19 MB] [GZIP: 1019.18 KB] • after: [JS: 3.99 MB] [GZIP: 960.59 KB] #2019-11-2600:28thhellerthats a decent chunk. thx.#2019-11-2600:28lilactown:+1:#2019-11-2600:28thheller(scary large build btw)#2019-11-2600:29lilactownPS we ship way too much code#2019-11-2600:29lilactown😂#2019-11-2600:30lilactownit’s my goal in life right now to at least get code splitting going so we can chunk out the loading process better#2019-11-2600:30lilactownon low-end machines it takes like 10s to download and load all the JS#2019-11-2600:31thhellerit'll probably melt a low-end phone 😛#2019-11-2600:31lilactownI only recently joined this project. unfortunately, re-frame is fighting me on that front… our code is laid out in a way that makes it harder to split#2019-11-2604:10superstructorIf from this experience you learn there is anything you think that would help in future re-frame releases to improve code splitting please let me know and I'll take the feedback into consideration 👍#2019-11-2604:44lilactownw.r.t., it adds to the problems because of the ability for any ns to fire off any event or subscribe to any subscription without noting the defining ns in it's requires#2019-11-2604:44lilactownthere's an implicit dependency in every ns on the fact that the event / fx / co-fx / subs have been registered already, that doesn't show up in it's dependency graph#2019-11-2607:26p-himikNot sure if that will haunt me in the future, but somewhat recently I started requiring namespaces where the events/subs are defined and using fully-qualified keywords with namespace aliases. That way, there's an explicit dependency graph and you never dispatch an event or subscribe to a sub that has not yet been registered.#2019-11-2703:28superstructorOn my own projects, I also do fully qualified keywords as per @p-himik's comment above. I havn't yet used fully qualified keywords in re-frame for long enough (only ~2 years) to say definitively that long term its a good or bad plan but so far so good. It's not official re-frame guidance but it is an option that gives fully qualified dependencies on all event / fx / co-fx / subs. @U4YGF4NGM#2019-11-2600:31lilactownyes luckily it is a SPA meant for enterprise desktop usage#2019-11-2606:5541ph4_Ph4unHey, dudes and dudettes!#2019-11-2607:0141ph4_Ph4unI have an unusual question, does shadow-cljs provide anyway to have optimization/minification on for hotreloaded code when running watch? I know that's generally a no no but I have a bit peculiar use-case here.. I'm figuring out to a way to compile code that I use in Screeps, which is a Coding Sandbox game. The thing is that the code works wonderfully when I build a node library in release mode and use that in the game. Naturally the watched dev version includes some Shadow-CLJS-related stuff so that doesn't work. I'm well aware that what I'm asking might be impossible, but I figured if someone smarter/more experienced one would have an idea? Otherwise it's really nice to use shadow-cljs and it's not so bad having to manually build your code for this specific case 🙂#2019-11-2608:59Elirazcan shadow-cljs work with lumo?#2019-11-2609:35thheller@theamazingekko hot-reload is impossible with optimized code so no its not possible to have a release "watch"#2019-11-2609:35thheller@eliraz.kedmi no#2019-11-2609:3641ph4_Ph4unThanks for the verification, assumed so 🙂#2019-11-2609:38thhellerif you run shadow-cljs server and then shadow-cljs release app whenever you need while that is running you at least won't pay for the startup cost each time#2019-11-2609:39thhelleror you can trigger the compile from the REPL too of course#2019-11-2609:4041ph4_Ph4unyup, been taking the REPL-route so far and it's good. Just wondered about the concept :)#2019-11-2611:17p-himikJust noticed that running release twice produces different files. Seems like Closure renames some objects in different ways. Is it possible to create the same output from the same input?#2019-11-2611:18thhellerdid you delete the cache between the builds?#2019-11-2611:18p-himikNope.#2019-11-2611:18thhellerso not running in CI or something?#2019-11-2611:19p-himikJust two consecutive release commands on my local machine. Removed only the js and js.map files in between.#2019-11-2611:19thhellerdid it recompile any CLJS?#2019-11-2611:19thhelleryou can't really get the same output unfortunately#2019-11-2611:20thhelleras soon as any compilation happens that used any kind of gensym#2019-11-2611:20p-himik> did it recompile any CLJS? Probably - it took some time and CPU. Ah yeah, gensym is in there somewhere. Although I would expect the order to be the same. But maybe that's not the case, or maybe the order doesn't matter.#2019-11-2611:21thhellergensym is using an incrementing number thats reset whenever you restart the JVM#2019-11-2611:22p-himikYeah, but since I restart it each time I run release, the numbers should've been the same. Unless there's some concurrent work being done.#2019-11-2611:22thhellerso with caching the ids may change#2019-11-2611:22thhellerthere is also parallel-build yes#2019-11-2611:22p-himikAhh, right. Damn.#2019-11-2611:22thhellerI wouldn't ever count on builds being identical#2019-11-2611:23thhellershadow-cljs adds a couple closure compiler options to "try" that#2019-11-2611:23thhellerbut that only really works if no CLJS compilation occurs .. which of course makes it pointless#2019-11-2611:24p-himikWell, one could hope. 🙂 It's pretty often that I make only backend changes but CI runs the same pipeline either way and releases the UI bundle. But it's not a huge deal. And module splitting should make the situation a bit better, I assume. Whenever I finally start using it, that is.#2019-11-2611:26thhellermaybe separate the frontend/backend CI 😛#2019-11-2611:28thhelleryou can check with shadow-cljs release app --verbose if any actual CLJS compilation occurs#2019-11-2611:28thhellerif not the builds should be the same. assuming of course that .shadow-cljs/builds is preserved between the builds (which may require additional CI config)#2019-11-2611:29p-himikAh, but that's more complicated and probably not worth my time. After all, I use macros and CLJC. Thanks, will try.#2019-11-2611:40p-himikYeah, a bunch of CLJS gets consistently recompiled on each run. So, I should look out for gensym and see if I can remove it. Is there anything else that I should look out for that could prevent a cached compilation result from being used?#2019-11-2611:41p-himikHuh. Just checked gensym usages in CLJS files. It's definitely used. Only those files are never recompiled.#2019-11-2611:42thhelleryou don't have to use it directly. any macro using gensym or auto# uses it for you#2019-11-2611:43thhellermaybe check why things get recompiled?#2019-11-2611:43thhellerI mean if they didn't change they should be cached. unless they have warnings or so.#2019-11-2611:44p-himikI'm trying to check a particular file by commenting out suspicious imports and pieces of code and running the release twice.#2019-11-2612:08p-himikAh, prettifying cache files and comparing them is much faster. Yeah, it's definitely gensym. But only at some very particular places, and not the others. The same 6 files, each and every time. The offending calls to gensym are made by doto and by cljs-oops. But I use them in a much greater number of files. It's interesting how only those 6 get different results.#2019-11-2612:09thhellerwhy are they getting recompiled though?#2019-11-2612:10p-himikBecause gensym returns different result in different runs.#2019-11-2612:10thhellerI feel like you are digging into something thats kinda pointless. using when uses gensym#2019-11-2612:10thhellerany macro basically does#2019-11-2612:11p-himikYep. At this point, I'm trying to understand why those particular 6 files are affected. And others are not.#2019-11-2612:11thhellerso you are trying to figure out why they are getting recompiled?#2019-11-2612:11p-himikYep. Not so much to fix it but to understand what's going on.#2019-11-2612:11thhellerdo you use clara-rules?#2019-11-2612:11p-himikNever heard of it.#2019-11-2612:12thhellerdo the files have warnings?#2019-11-2612:12thhellerdo you explictely block the cache?#2019-11-2612:12thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2019-11-2612:14p-himikNo warnings in those files. Only a couple of warnings from transit-js, and it's not used by those files. Nope, don't block anything.#2019-11-2612:14thhellerclosure compiler warnings aren't relevant to this cache#2019-11-2612:14thhelleractual CLJS warnings only#2019-11-2612:17p-himikNo warnings at all then. Just lines like these
<- Cache read: hgs/platform/abc/core.cljs (8 ms)
-> Compile CLJS: hgs/platform/abc/core.cljs
[...]
<- Compile CLJS: hgs/platform/abc/core.cljs (282 ms)
[...]
<- Cache write: hgs/platform/abc/core.cljs (32 ms)
and the differences in variables' names in the cached JS in {:output {:js "..."}}.
#2019-11-2612:17thhellerwhat the heck? is that from one compile?#2019-11-2612:17p-himikYep.#2019-11-2612:18thhellerso you did make changes?#2019-11-2612:18thhellerbecause it read the cache but decided not to use it?#2019-11-2612:18p-himikLet me double-check.#2019-11-2612:22p-himikYep, seems like it:
-> Cache read: hgs/platform/abc/core.cljs
<- Cache read: hgs/platform/abc/core.cljs (8 ms)
-> Compile CLJS: hgs/platform/abc/core.cljs
<- Compile CLJS: hgs/platform/abc/core.cljs (358 ms)
-> Cache write: hgs/platform/abc/core.cljs
<- Cache write: hgs/platform/abc/core.cljs (45 ms)
#2019-11-2612:23p-himikTwo consecutive runs with grep abc/core, the same output.#2019-11-2612:24thhellerso something happened that made it not use the cache#2019-11-2612:25p-himikJust in case it affects something - the file requires some JS files. Both from NPM and from a dir relative to src.#2019-11-2612:25thhellerANY change may affect it yes#2019-11-2612:25thhelleranything used by the file that changes will invalidate the cache (as it should)#2019-11-2612:28p-himikOh, but the files didn't change!#2019-11-2612:28p-himikNothing was changed.#2019-11-2612:28p-himikExcept the system time.#2019-11-2612:38thhellerhmm then I don't know. you can compare the cache files before/after to see what changed besides the generated code#2019-11-2612:40p-himik:compiled-at and some other timestamp-looking values (transit cached the keys, can't really tell without deserializing).#2019-11-2612:41thhelleryou can use (shadow.build.cache/read-file (io/file ".shadow-cljs/builds/foo/....")) in the REPL with the full path to the cache file#2019-11-2613:15p-himik*read-cache Ah, that was stupid. The JS files are not changed. But their timestamps are.#2019-11-2613:55souenzzo[SOLVED]how do shadow-cljs watch files? hawk {:mvn/version "0.2.11"}#2019-11-2614:33thheller@souenzzo thats only used on macos. otherwise the default JDK watcher is used.#2019-11-2614:36souenzzowhich ns do that?#2019-11-2614:38orestisHawk is the library that does that.#2019-11-2614:38thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/fs_watch_jvm.clj#2019-11-2614:39thhellerwhy do you ask?#2019-11-2614:47souenzzoBecause shadow-cljs watcher works extraordinarily well 🙂 I will study/try hawk for now https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/util/FileWatcher.java#2019-11-2614:48thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/fs_watch_hawk.clj#2019-11-2614:48thhellerthats the hawk parts#2019-11-2614:49thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/fs_watch.clj#L13#2019-11-2614:49thhellerbut again .. only used on macos#2019-11-2616:00orestisI thought hawk wraps some native library to give the same api as the native JVM — is that not the case?#2019-11-2616:00orestis> Like most clojure file watchers, hawk wraps the JDK 7 java.nio.file.WatchService API. This works great when Java has a native implementation for your platform of choice. However, this is not the case on OS X, so hawk also wraps the Barbary WatchService to provide performant monitoring even if you’re using a mac. An appropriate implementation is chosen automatically, so all you have to do is install hawk and relax.#2019-11-2618:22thhelleryes, using is on macos because of the barbary watchservice. hawk however does not provide the API I want so I had to wrap it.#2019-11-2614:34thheller@p-himik yes timestamp changes are enough to invalidate cache#2019-11-2616:31p-himikFixed it, no cache misses now! And the file name stays the same, so that's great. But why is this step still executed though? Is it really needed given that the output file is already there and none of the cache entries got stale?
<- Closure - Optimizing ... (46580 ms)
#2019-11-2811:13p-himik@thheller Hi. Would it be possible to skip this step if nothing has changed? Or did something change and --verbose somehow didn't show it?#2019-11-2811:20thhellerthere is no option currently but I could add a shadow-cljs release app --skip-optimize-if-unchanged or something#2019-11-2812:31p-himikHmm. Is there a reason to not make it the default behavior?#2019-11-2812:32thhelleryes, too much work to "verify" that it doesn't need to generate output#2019-11-2812:33thhellerie. it can't possibly know that the output files exists when using :module-hash-names true#2019-11-2813:37p-himikI think it could, if the manifest or cache contained all the relevant information, like hashes of all the source files that are fed into a particular version of GCC. But I have no idea how fragile that would be.#2019-11-2813:39p-himik(ah, definitely not the manifest - just the cache then)#2019-11-2616:59Pavel Klavíkhi, is it possible to get source maps working with Web Workers? Debugging the following errors is difficult otherwise:
Uncaught Error: nth not supported on this type cljs.core/PersistentArrayMap
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:6349)
    at eval (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.ops.js:23)
    at Object.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:36362)
    at Function.G__27279__2 [as cljs$core$IFn$_invoke$arity$2] (/js/compiled/cljs-runtime/cljs.core.js:14986)
    at eval (/js/compiled/cljs-runtime/cljs.core.js:8044)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:8045)
    at Object.eval [as cljs$core$IReduce$_reduce$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:10474)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/compiled/cljs-runtime/cljs.core.js:8198)
    at Object.orgpad$client$layout$webworker$ops$apply_ops [as apply_ops] (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.ops.js:177)
    at eval (/js/compiled/cljs-runtime/orgpad.client.layout.webworker.handle.js:71)
#2019-11-2618:26awb99I am trying to make a bundle with shadow-cljs that uses quil library, that has as transient dependency p5#2019-11-2618:28awb99cat package.json { "dependencies" : { "moment" : "^2.24.0", "p5" : "^0.10.2", "shadow-cljs" : "^2.0.41" } }#2019-11-2618:28awb99cat shadow-cljs.edn {:dependencies [[org.pinkgorilla/gorilla-renderable "2.1.2"] [quil "3.1.0"] [awb99/shapes "0.1.2"] [awb99.fortune "0.0.1"]], :source-paths ["src"], :builds {:gorilla {:target :bootstrap, :output-dir "out/gorilla", :exclude #{cljs.js}, :entries [fortune.core pinkgorilla.ui.gorilla-renderable quil.sketch quil.middleware quil.core "moment"]}}}#2019-11-2618:30awb99t\"; ignoring it"} {:line 98747, :column 13, :message "illegal use of unknown JSDoc tag \"submodule\"; ignoring it"} {:line 98748, :column 13, :message "illegal use of unknown JSDoc tag \"for\"; ignoring it"} {:line 99350, :column 13, :message "illegal use of unknown JSDoc tag \"submodule\"; ignoring it"} {:line 99351, :column 13, :message "illegal use of unknown JSDoc tag \"for\"; ignoring it"}], :resource-name "node_modules/p5/lib/p5.js", :js-requires [], :js-errors [{:line 69565, :column 0, :message "Invalid delete operand. Only properties can be deleted."}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false} ExceptionInfo: errors in file: /home/andreas/Documents/gorilla/kernel-cljs-shadowdeps/node_modules/p5/lib/p5.js shadow.build.npm/get-file-info* (npm.clj:549) shadow.build.npm/get-file-info* (npm.clj:472) shadow.build.npm/get-file-info (npm.clj:586) shadow.build.npm/get-file-info (npm.clj:583) shadow.build.npm/find-resource (npm.clj:677) shadow.build.npm/find-resource (npm.clj:638) shadow.build.resolve/find-npm-resource (resolve.clj:109) shadow.build.resolve/find-npm-resource (resolve.clj:80) shadow.build.resolve/fn--11285 (resolve.clj:235) shadow.build.resolve/fn--11285 (resolve.clj:211) clojure.lang.MultiFn.invoke (MultiFn.java:244) shadow.build.resolve/resolve-string-require (resolve.clj:349) shadow.build.resolve/resolve-string-require (resolve.clj:332) shadow.build.resolve/resolve-require (resolve.clj:545) shadow.build.resolve/resolve-require (resolve.clj:538) shadow.build.resolve/resolve-deps/fn--11240 (resolve.clj:51) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:49) shadow.build.resolve/resolve-deps (resolve.clj:33) shadow.build.resolve/resolve-symbol-require (resolve.clj:532) shadow.build.resolve/resolve-symbol-require (resolve.clj:491) shadow.build.resolve/resolve-require (resolve.clj:542) shadow.build.resolve/resolve-require (resolve.clj:538) shadow.build.resolve/resolve-deps/fn--11240 (resolve.clj:51) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:49) shadow.build.resolve/resolve-deps (resolve.clj:33) shadow.build.resolve/resolve-symbol-require (resolve.clj:532) shadow.build.resolve/resolve-symbol-require (resolve.clj:491) shadow.build.resolve/resolve-require (resolve.clj:542) shadow.build.resolve/resolve-require (resolve.clj:538) shadow.build.resolve/resolve-deps/fn--11240 (resolve.clj:51) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:49) shadow.build.resolve/resolve-deps (resolve.clj:33) shadow.build.resolve/resolve-symbol-require (resolve.clj:532) shadow.build.resolve/resolve-symbol-require (resolve.clj:491) shadow.build.resolve/resolve-require (resolve.clj:542) shadow.build.resolve/resolve-require (resolve.clj:538) shadow.build.resolve/resolve-deps/fn--11240 (resolve.clj:51) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-deps (resolve.clj:49) shadow.build.resolve/resolve-deps (resolve.clj:33) shadow.build.resolve/resolve-symbol-require (resolve.clj:532) shadow.build.resolve/resolve-symbol-require (resolve.clj:491) shadow.build.resolve/resolve-require (resolve.clj:542) shadow.build.resolve/resolve-require (resolve.clj:538) shadow.build.resolve/resolve-entry (resolve.clj:552) shadow.build.resolve/resolve-entry (resolve.clj:551) clojure.lang.PersistentVector.reduce (PersistentVector.java:343) clojure.core/reduce (core.clj:6827) clojure.core/reduce (core.clj:6810) shadow.cljs.util/reduce-> (util.clj:47) shadow.cljs.util/reduce-> (util.clj:46) shadow.build.resolve/resolve-entries (resolve.clj:563) shadow.build.resolve/resolve-entries (resolve.clj:554) shadow.build.targets.bootstrap/resolve (bootstrap.clj:56) shadow.build.targets.bootstrap/resolve (bootstrap.clj:48) shadow.build.targets.bootstrap/process (bootstrap.clj:278) shadow.build.targets.bootstrap/process (bootstrap.clj:271) clojure.lang.Var.invoke (Var.java:384) shadow.build/process-stage/fn--12425 (build.clj:148) shadow.build/process-stage (build.clj:145) shadow.build/process-stage (build.clj:137) error Command failed with exit code 1.#2019-11-2618:27awb99I am getting crazy errors, does anybody know why they come?#2019-11-2618:29thhellerwhat kind of errors?#2019-11-2618:31awb99I copied my configs nd the error ito the therad to keep the main chat clean#2019-11-2618:32thhellerhmm looks like p5.js does something weird ... check what happens in the :line it lists#2019-11-2618:32thheller:js-errors [{:line 69565, :column 0, :message "Invalid delete operand. Only properties can be deleted."}]#2019-11-2618:33awb99the error log is huge#2019-11-2618:33awb99I am trying to redirect it to a pastebin#2019-11-2618:34awb99but seems like I cannot redirect the error message itself#2019-11-2618:35awb99https://pastebin.com/Va3NgmnV#2019-11-2618:35awb99this link contains most errors#2019-11-2618:41thhellerI already pasted you the relevant one#2019-11-2618:41thhellerits a bunch of warnings .. which you can ignore. the :js-errors above is the one causing the crash#2019-11-2618:47awb99Thanks Thomas!#2019-11-2618:47awb99Can I see somewhere the version of the npm modules for which you have provided cljsjs wrappers?#2019-11-2618:48thhellerhmm? they don't have a "version"?#2019-11-2618:48thhellerI mean the wrappers don't have a version#2019-11-2618:48awb99Well, in the wrappers I dont see them at least.#2019-11-2618:48thhelleryou decide the version of the npm package?#2019-11-2618:49awb99But what if there is a breaking change in the library?#2019-11-2618:50awb99nevermind#2019-11-2618:50awb99your wrappers seem to all just set one symbol in the window#2019-11-2618:51awb99that wont break#2019-11-2618:52thhellerideally you wouldn't use those wrappers at all#2019-11-2618:53awb99So what happened to me is that the clojurescript compiler detected something bad in the npm bundle of p5 ?#2019-11-2618:53awb99the "delete this"#2019-11-2618:54thhelleryes#2019-11-2618:55awb99That is an amazing benefit of shadow-cljs!#2019-11-2618:57thhellerwell not really .. the code probably runs otherwise. if they'd run their code through a linter that would likely catch it too#2019-11-2618:58awb99but that one function would break#2019-11-2618:58awb99or throw exceptions#2019-11-2619:00thhelleryeah .. but people probably use p5 without it ever breaking#2019-11-2619:01thhelleryou can probably report that error ... maybe they care about fixing it#2019-11-2619:01awb99I will.#2019-11-2619:01awb99Good point!#2019-11-2619:05awb99https://github.com/processing/p5.js/issues/4158#2019-11-2619:05awb99Many thanks @thheller#2019-11-2620:50thhellerwow. nice response time on that issue 🙂#2019-11-2620:53aibaI'm using shadow with :target :react-native (based on the reagent-react-native template) and connecting to the cljs repl from emacs/cider. One unexpected behavior is that when I evaluate an expression over cider that throws an error, the trace is displayed in the simulator window, and no feedback is given in emacs/cider. Is that expected? Is there a way to get the exception to come back to emacs/cider so I can see it there?#2019-11-2620:54thhellerno clue. I don't do react-native development myself.#2019-11-2620:55thhellerthe eval happens in a try/catch so the react-native side probably intercepts the error somehow?#2019-11-2620:56aibaOK, so the eval is expected to wrap a try/catch and return the error to cider then#2019-11-2620:57aibaSo yeah, seems like something about the react-native environment is intercepting the exception. Any tips on how to track that down?#2019-11-2620:59thhellerI know next to nothing about react-native sorry 😛#2019-11-2621:10aibaYeah no worries, I just tried it with a regular :target :browser shadow project, and a similar thing happens, it just prints the error in the repl buffer instead of popping up a *cider-error* buffer. So I'm guessing that this is actually something to do with how shadow emulates piggieback.#2019-11-2621:14thhellerthats possible ... I don't use emacs so no clue what *cider-error* even is#2019-11-2621:25aibaDon't mean to belabor this, but if you're curious, there must be something in the piggieback repl protocol that tells cider that an error occured during evaluation, which cider uses to present some UI indicating this. It appears that shadow emulates piggieback in a way that cider doesn't get this info. If there's any interest in tracking this down, I'd be thrilled to help, but if you consider it too low priority, that'd be understandable.#2019-11-2621:27thhellerhappy to add whatever is needed but I have no energy to spend on tracking yet another cider nrepl issue myself#2019-11-2621:28thhellersince there are no docs for any of this it is likely just an nrepl message missing some field or something#2019-11-2621:28Pavel KlavíkHi, is it possible to get REPL for a Web Worker?#2019-11-2621:29thheller@pavel.klavik not currently no#2019-11-2621:29Pavel Klavíkand concerning the source maps I mentioned above? I am just able to get to Javascript code which is not very useful to debug Clojurescript#2019-11-2621:30Pavel Klavíksource maps in Web Worker#2019-11-2621:31thhellerI'm not sure why they don't work. I'd expect them to work. haven't used workers myself for years#2019-11-2621:33thhellerif you open an issue I can take a look when I have some time#2019-11-2621:33thhellerdeep in other stuff currently#2019-11-2621:35Pavel Klavíksure, I will produce some example and make an issue, thx#2019-11-2621:39Pavel Klavíkoutside of these two issues, I am quite happy with Web Workers support in Shadow, super easy to get it working#2019-11-2622:45kanweiis there any way to include CSS?
import DatePicker from "react-datepicker";
 
import "react-datepicker/dist/react-datepicker.css";
#2019-11-2622:50lilactownnot in your code. you can copy the datepicker .css file into the folder your js is hosted in and add it to your index.html#2019-11-2623:27kanweicool#2019-11-2703:51tianshucan I use some css file installed by npm install without copy them into resources/public? should I use webpack? or there is a some simpler way?#2019-11-2708:16gravA symlink might be a better way - I've used those with Git without problems.#2019-11-2708:16gravEg ln -s resources/public/styles.css node_modules/foobar/styles.css#2019-11-2716:42tianshu@U052XLL3A great idea!#2019-11-2717:29tianshubut, will symlink work on windows?#2019-11-2708:12gravUsing shadow-cljs and deps.edn together - what is the minimal amount of configuration necessary? Reading https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn, it's suggested to use :deps true in the shadow-cljs.edn config file, but below that, it's stated that one must add thheller/shadow-cljs to deps.edn, and the example states to add it in :extra-deps, which in turn seems to require an alias, according to both the example and the deps ref: https://clojure.org/guides/deps_and_cli#extra_deps. Using an alias in turn means that :deps true is not enough, since one need to specify the alias, eg :deps {:aliases [:cljs]} . If this is correctly interpreted, I'd suggest removing the :deps true example for the next newcomer 🙂#2019-11-2709:43p-himikBut the documentation isn't for newcomers, it's for everybody.#2019-11-2711:24gravSure, but if it's not possible at all to use :deps true, it might be a blocker, especially for newcomers.#2019-11-2713:11p-himikIt is possible!#2019-11-2713:13p-himikMoving some dependencies under aliases just makes sure that you don't bring unneeded stuff along. Well, most of the time. Since you don't need shadow-cljs to actually run release versions of applications, it makes sense to move it under an alias that's only used during the development and UI release.#2019-11-2722:58enocomI’m running tests for my browser application using the node-target, but now I have some code that uses js/window and am trying to use jsdom in a sensible way. The best I’ve come up with so far is conditional initialization in src files, i.e., if there is no window present, make a fake one with jsdom . I’m curious if there’s a better way, though. Would build hooks be a possible alternative? Does anyone have any experience with this problem?#2019-11-2801:18Filipe SilvaIn create-cljs-app I just made a node only entry point that adds jsdom#2019-11-2802:34enocomThanks! I’ll take a look!#2019-11-2723:35lilactownI prefer to use karma or some other headless browser to run my tests, rather than running tests in Node.js#2019-11-2801:11QuestHow can a library include EDN resources? Context: I wrote an internal "model" library that has some .edn files under /resources/definitions. The library parses these files and generates some Datomic/DataScript schemas + Clojure specs. I want these files to be included in the library when used by downstream projects, but the way I wrote the "inlining" causes no files to be loaded at all in those projects. My model library has this in deps.edn : :paths ["src/main/clojure" "resources"] It "inlines" resources with the following code:
(defn list-resource-files
  "Given a directory included on the classpath, returns seq of filenames"
  [directory]
  (let [in (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) directory)
        reader (BufferedReader. (InputStreamReader. in))]
    (loop [line (.readLine reader)
           files []]
      (if (some? line)
        (recur (.readLine reader) (conj files line))
        files))))

(defmacro inline-resources
  "Given directory name in resources, returns coll of file contents"
  [resources-path]
  (->> (list-resource-files resources-path)
       (map #(str resources-path "/" %))
       (map #(slurp ( %)))
       vec))

;; in consuming namespace
(inline-resources "definitions")
#2019-11-2801:17QuestI think I can answer why it's failing... In a project that consumes the library, this code is causing it to look at /consuming-project/resources/definitions, which turns out to have zero files. What I'm not clear on is how to workaround this. Short of just embedding the library's EDN in a .cljc file , is there any way to include resources/ from a library?
#2019-11-2801:18QuestIIRC lein did this and it "just worked". Also this might be a deps.edn question, can post there if it's more appropriate. Worth mentioning is that I need to consume these resources from both clojure & cljs, hence why I was trying to "inline" it in the first place.#2019-11-2810:00p-himikIs the relevant directory in the classpath when you run the app as is, not from a jar? If so, try using .#2019-11-2810:01p-himikAh, right - you're not just reading, you're listing the contents of a directory. Not sure how to do that.#2019-11-2810:52thheller@quest listing the contents of a directory is not supported for .jar files. you cannot "list" contents. you'll need to create an "index" file of some kind that lists the other files and then load them by name#2019-11-2810:53thhellerwell you can get fancy and list things by looking for the actual jar file and traversing that but that doesn't exactly respect the classpath#2019-11-2810:53thhellerand won't work if you need to run in any kind of application server/container#2019-11-2810:57thhelleror what I would actually recommend is not doing this as a macro at all#2019-11-2810:58thhellerinstead make a script for something that takes the definitions and creates actual cljs/clj or cljc files#2019-11-2810:58thhellerway easier to debug than a macro, way better from a compiler perspective#2019-11-2819:52QuestFigured I might be barking up the wrong tree, thanks for setting me straight. I'll try this approach#2019-11-2811:10thhelleroh and not to forgot way easier on the tools since they can actually see the files 😛#2019-11-2811:19tianshu@thheller I have a very small feature request, make the color of shadow-cljs log in browser console with dark mode looks nicer?#2019-11-2811:21thheller@doglooksgood you can set :devtools {:log-style "color: white;"} in your build config#2019-11-2811:21tianshuwow, great. it's configurable!#2019-11-2811:22thhellerunfortunately you cannot "detect" dark mode so there is no way to adjust dynamically#2019-11-2811:22thhelleractually I just thought of something "better" 😛#2019-11-2811:23tianshufor the default blue color, maybe there's RGB that looks good on both light and dark background?#2019-11-2811:24thhellerno clue. happy to take suggestions#2019-11-2811:27thhellerit think it might be enough if the messages are just bold#2019-11-2811:28thhellerso then dark mode should adjust the color automatically#2019-11-2811:28thhellerjust want the messages to be a little different from regular console logs#2019-11-2811:29tianshuyou mean don't want to use the color as the same as the ()?#2019-11-2811:30thhellercolor I dont' really care about#2019-11-2811:30thhelleronly need to be distinguish from regular console.log#2019-11-2811:31thhellermaybe an emoji or so#2019-11-2811:33tianshu#3390ff#2019-11-2811:33tianshuhow about this one#2019-11-2811:36tianshubut maybe not as sharp as the current in light mode, don't know if the contrast is too low.#2019-11-2811:37thhellerhmm that still doesn't look great in chrome darkmode#2019-11-2811:37thhellerbut more readable for sure#2019-11-2811:37thhellerI'll add that as the default color. thx.#2019-11-2811:51tianshumaybe bold is a better idea. I think this contrast is not enough for a few peoples. I'm very sensitive on contrast, so it's only okay to me.#2019-11-2811:59thhelleryeah I just removed color and added bold and 🠶#2019-11-2811:59thheller> 🠶 shadow-cljs: WebSocket connected!#2019-11-2811:59thhelleris distinctive enough I think#2019-11-2812:02tianshuthis looks great, I can't wait to use the newer version.#2019-11-2821:46QuestQuick note for channel, React-Native Webpack broke on the shadow-cljs 2.8.68 -> 2.8.69 release. If anyone corroborates this see https://github.com/thheller/shadow-cljs/issues/607#2019-11-2823:07Pavel KlavíkHi, what does mean the following error while building release target? Is it something I should address, or can be safely ignored?
NPM dependency "react" has installed version "^16.12.0"
"16.9.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
#2019-11-2900:40lilactownprobably OK to ignore. there haven’t been any breaking changes between 16.9 and 16.12#2019-11-2908:32orestisIs it possible to conditionally require a different namespace based on a goog-define variable?#2019-11-2908:36orestisI see https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading but that's for .cljc files and I want to use this from a .cljs file (stub out a mixpanel dependency in dev)#2019-11-2910:02romdoqI've just added a scoped JS dep with yarn, but Shadow doesn't appear to find its dependencies. I guess because yarn installs them in node_modules/@my-scope/my-package/node_modules? Anyone have any suggestions on how I could get these deps seen by shadow, aside from adding them all explicitly to my project's package.json?#2019-11-2910:24thheller@orestis conditional requires are not supported. you can however change what JS dependencies resolve to. https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2019-11-2910:25thhellerso :js-options {:resolve {"mixpanel" false}} would cause (:require ["mixpanel"]) to not do anything#2019-11-2910:25thheller@mel.collins yarn should not be installing the dependencies into a nested node_modules dir? it usually only does this in cases on version conflicts which you'll need to resolve#2019-11-2911:30romdoqAha gotcha, thanks. Got it in the main node_modules after fixing diverged react versions. What confused me was that the package it was complaining about wasn't depended on by anything else, and only existed in the one (nested) node_modules. But it seems that if any of the package's deps conflict, all of its deps go in the nested folder.#2019-11-2911:30thhellercould be .. don't know how yarn/npm handle this these days#2019-11-2915:20romdoqOkay, so I got my dep installed properly, but my next stumbling block is that when my ns requires ["@my-scope/my-package/feature" :as my-feature] it works perfectly when accessing the page of my :npm-module build, but in the test (`:target :karma`) build I get: "The required JS dependency "@my-scope/my-package/feature" is not available ...". Not sure what I could be missing. 😕#2019-11-2915:21thhellerwhen using :npm-module you are likely using webpack or something as the final bundler that'll provide the JS#2019-11-2915:22thhellerfor karma shadow-cljs will try to build it#2019-11-2915:22thhellerso if you have custom webpack config for the package that won't apply#2019-11-2915:22thhelleror if the package is written in typescript shadow-cljs won't recognize it#2019-11-2915:22thhellercould be affected by many things ...#2019-11-2915:36romdoqHmm, we do use webpack, but it looks like the released (npm) package works fine, just not the yarn linked version. I guess something, somewhere, isn't getting correctly pointed to the package's dist/ subdir to find the compiled (yup, from TypeScript) JS files.#2019-11-2916:02romdoqI'll pick this up again on Monday, with hopefully clearer eyes#2019-11-2921:35kstehnhey guys quick question is it possible to generate a test report xml-file that is compatible with circleci when the target for the test is :node-test ?#2019-11-2922:10thhellernot built-in no. you could make your own runner that generates it though.#2019-11-3013:58polymerisI have builds targeting :browser-test and :karma . Is there some easy way to exclude some (heavy) tests from the browser test suite only? Ideally on a test-by-test basis, not ns.#2019-11-3014:15polymerisnvm, just put the heavy tests in a separate ns and filtered with ns regexes#2019-11-3014:44thhelleryeah the ns filternig is rather limited currently#2019-11-3014:51polymerisUnrelated, but I use to have to monkey-patch nextTick: (gobj/set shadow-js/process "nextTick" goog.async.nextTick). Updated shadow-cljs from 2.8.36 to 76 and shadow-js/process is now undefined, however I remove the monkey patch and the tests pass. Did that implementation change or are my tests broken?#2019-11-3014:53thhellerthe implementation changed yes. now uses the full browser process polyfill#2019-11-3014:58polymerisGood to hear, thanks!#2019-11-3018:30sheluchinvim-salve says it supports Leiningen, Boot, and the Clojure CLI. Does that mean that if I use deps.edn with shadow-cljs, vim-salve will support it too? I'm presuming that to be the case based on this bit from the docs: > The new deps.edn can also be used to manage your :dependencies and :source-paths instead of using the built-in methods or lein. All shadow-cljs commands will then be launched via the new clojure utility instead. https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2019-11-3018:33thhellersorry don't know what vim-salve is#2019-11-3018:33sheluchinhttps://github.com/tpope/vim-salve#2019-11-3018:33thhelleryes I looked at that. still no clue what it does.#2019-11-3018:34thhellerif its just about starting a clojure jvm then yes deps.edn will work and you can use shadow-cljs via that#2019-11-3018:41sheluchinvim-salve is supposed to be helpful for setting classpath in vim, so that tools like vim-fireplace can better interact with the REPL to do things like reading docstrings and navigating to source. I'm fairly new to Clojure and trying to get my editor running smoothly, but still getting a few errors here and there. One thing I notice is that npx shadow-cljs classpath does not list the source path entries that shadow-cljs info produces. Is that normal? My understanding is that the classpath should be a combination of the given filesystem directory and .jar file entries, so if I have :source-paths ["src/main" "src/test"], I expect them both to be in the classpath.#2019-11-3018:42thhellerdo you use :deps or not?#2019-11-3018:42thhellerif you do :source-paths and :dependencies in shadow-cljs.edn are ignored#2019-11-3018:42sheluchinYes, {:deps {com.fulcrologic/fulcro {:mvn/version "3.0.1"}}.#2019-11-3018:43thhellerthe you configure :paths in deps.edn#2019-11-3018:44sheluchinAh, sorry, this is from shadow-cljs.edn: :deps {:aliases [:dev]}.#2019-11-3018:44sheluchinOkay, I will try that. Thanks very much.#2019-12-0123:10Pavel KlavíkHi, there seems to be a problem when using both Web Workers and Module hash names. I have the following shadow-cljs.edn:
{:target            :browser
                         :output-dir        "resources/public/js/compiled"
                         :asset-path        "/js/compiled"
                         :module-hash-names true
                         :modules           {:shared {:entries []}
                                             :main   {:init-fn    orgpad.client.core/init
                                                      :depends-on #{:shared}}
                                             :layout {:entries    [orgpad.client.layout.webworker.core]
                                                      :depends-on #{:shared}
                                                      :web-worker true}}
                         :compiler-options  {:infer-externs :auto}
                         :devtools          {:after-load  orgpad.client.core/mount-root
                                             :before-load orgpad.client.core/stop-web-workers
                                             :watch-dir   "resources/public"}}
#2019-12-0123:11Pavel KlavíkWhen I run the release version, I get the following error: Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://reorgpad.herokuapp.com/js/compiled/shared.js' failed to load. at https://reorgpad.herokuapp.com/js/compiled/layout.2C8E9F9F47AB1338B6ABF2B8D798D22B.js:1:1#2019-12-0123:12Pavel KlavíkWhere the actual name is shared.0A18608384A13578DC44FDC090CF8CC5.js#2019-12-0123:23thhelleryes :module-hash-names doesn't work when using workers#2019-12-0123:24thhellerthat is known and can't really be fixed 😛#2019-12-0123:24thhelleradding the hash of something to a file changes its hash#2019-12-0123:26thhelleradding it also messes up the source map#2019-12-0123:27thhellerso kinda no idea how to do this cleanly#2019-12-0123:28thhellerI've been thinking about adding something like shadow-cljs release app --config-merge '{:module-fingerprint "foo"}'#2019-12-0123:28thhellerso that would produce shared.foo.js and layout.foo.js#2019-12-0123:29thhellerso in theory you could provide a version number or git sha or whatever#2019-12-0123:29thhellernot really using a hash#2019-12-0123:33thheller@pavel.klavik did you report the source maps not working or was that someone else? in any case I reproduced that myself and :devtools {:loader-mode :script} seems to fix that#2019-12-0123:40Pavel KlavíkCouldn't the hash problem be solved by first compiling shared.js, this would produce the hash, then add it into layout.js and then computing hash for it?#2019-12-0123:40thhellerits all compiled in one go by the closure compiler#2019-12-0123:41thhellerI guess it could prepend the importScripts after the compilation though#2019-12-0123:43Pavel KlavíkThe source maps are fixed by what you suggested, thx.#2019-12-0123:43thhellerdunno the whole hash-names thing isn't solved very cleanly currently#2019-12-0123:44thhellerbut the web-worker case should be fixable I think. please open an issue so I don't forget#2019-12-0123:44Pavel Klavíksure#2019-12-0123:44Pavel Klavíkthe stuff with module-fingerprint does not work yet?#2019-12-0123:47thhellerno its just an idea#2019-12-0123:48thhellerbut I like it more than all the hashing stuff#2019-12-0123:48thhellersince you don't really get reusable files anyways between compiles#2019-12-0123:49thhellerseems better to use something a human can actually recognize (eg. version number or even using the git sha to lookup commits)#2019-12-0123:53Pavel Klavíkmakes sense, both solutions would be fine, at least as an alternative#2019-12-0123:54Pavel Klavíkof course, I can imagine that I will make commits only changing the server (which I have in the same repository) and it will change the client js name, but it does not seem like a big problem#2019-12-0123:55thhellerwell then you shouldn't trigger a CLJS build in the first place probably 😛#2019-12-0123:55thhelleryou'll very likely get different hashes currently already#2019-12-0123:56Pavel Klavíkya, currently it is not a big problem if the filename changes more often, but it is a big problem if someone uses old client version due to caches#2019-12-0123:56thhellerindeed#2019-12-0200:04thhelleralso added https://github.com/thheller/shadow-cljs/issues/609 so I don't forget#2019-12-0200:09Pavel Klavíkhow long do you think it might take to fix the naming issue?#2019-12-0200:26thhellermight take care of it tommorrow#2019-12-0200:26thhellertoo tired to do it now#2019-12-0200:48Pavel KlavíkCool, no rush, thx#2019-12-0207:39Saikyunhey, just wanted to say yet again, that shadow-cljs is such an amazing tool 🙂 very happy to be using it daily.#2019-12-0209:21iku000888Hi I am trying to consume vis-network as a npm-package using the ns require form
(my.ns
  (:require [reagent.core :as r]
            ["vis-network" :as vis]
            [clojure.string :as str]))
I run into https://github.com/visjs/vis-network/blob/c47be95c57caaa69ce31a6fca70fbf77f51fcac6/lib/network/modules/ManipulationSystem.js#L1206 this error with a release build so I am now doing a :simple build. I also noticed the following warning with the release build, but not sure whether it is related
Resource: node_modules/vis-network/dist/vis-network.min.js:2
 constant module$node_modules$vis_network$dist$vis_network_min assigned a value more than once.
Original definition at externs.shadow.js:4
Appreciate tips & pointers 🙂
#2019-12-0209:47thheller@iku000888 not sure what you mean. the warning you get can be ignored. what about the if you posted? looks like its checking the arity of a function? maybe one you passed in? (fn [arg1 arg2] ..)?#2019-12-0209:49iku000888Thanks for checking! Right, so in a non release build the function I pass in gets correctly invoked#2019-12-0209:49iku000888And with a release build throws an error with the pointed error message in the same context#2019-12-0209:50iku000888Happy to post a repro later#2019-12-0209:50thhellersorry I can't help much without seeing any code#2019-12-0209:51thhellerjust a random source location of some code I've never seen before doesn't help 😛#2019-12-0209:51iku000888No worries. I will try posting the repro method#2019-12-0209:58thhellerFWIW :advanced compilation will often remove function args if you don't use them. eg (fn [arg1 arg2] (use-only arg1))#2019-12-0209:58thhellerit'll optimize that to (fn [a] ...) since JS doesn't care if the arg is declared (usually)#2019-12-0210:30iku000888@thheller Happy to report that bumping from [thheller/shadow-cljs "2.8.69"] to [thheller/shadow-cljs "2.8.76"] fixed the issue 😂 😂#2019-12-0210:32iku000888FWIW here is the repro effort https://github.com/iku000888/reagent-shadow-cljs-vis-js if curious.#2019-12-0210:35iku000888Ah wait.. Copied 'optimization :simple#2019-12-0210:35iku000888:man-facepalming:#2019-12-0210:35thhelleryeah thats exactly the issue I said#2019-12-0210:36thhelleryou are not using the callback argument#2019-12-0210:36thhellerhttps://github.com/iku000888/reagent-shadow-cljs-vis-js/blob/master/src/my/dev.cljs#L23#2019-12-0210:36thhellerso the closure compiler will remove it from the argument list to make to code smaller#2019-12-0210:37iku000888Ahhhh#2019-12-0210:37thhellerit looks like you are supposed to call the callback though?#2019-12-0210:38thhellerjust do (callback) after you did the update?#2019-12-0210:38iku000888Yup that fixed it :+1:#2019-12-0210:39iku000888I did not need call it because I discard the object upon re-rendering, but now I am enlightened#2019-12-0210:44iku000888Thanks for the help @thheller 🙏#2019-12-0211:13thheller@pavel.klavik I added :release-version in 2.8.77 see https://shadow-cljs.github.io/docs/UsersGuide.html#release-version#2019-12-0211:26Pavel KlavíkThx, looking at it. I am currently building uberjar like this in project.clj:
["clean"
 ["run" "-m" "shadow.cljs.devtools.cli" "release" "client"]
 "compile"
 ["less" "once"]]
Any idea how to add the version there in the easiest way?
#2019-12-0211:28thhellerI'd probably create something like the release fn described here https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2019-12-0211:29thhellerand then just run -m my.build/release from lein#2019-12-0211:29thheller(shadow/release :my-build {:config-merge [{:release-version "v1"}])#2019-12-0211:29thhellernote the extra vector that is currently required (since you are allowed to use --config-merge multiple times too)#2019-12-0214:23romdoqI'm trying to upgrade the version of shadow-cljs that my :npm-module uses, but I'm finding that (from version 2.8.69) :closure-defines in shadow-cljs.edn isn't overriding the default values. Did something change in how that's configured? The documentation doesn't seem to differ from what I have. Though for my current purpose I should be able to use goog.DEBUG, since that appears to still get set.#2019-12-0214:28Pavel Klavík@thheller thx for the quick, got it working with git commit ids; for anyone running on Heroku, this is very useful: https://devcenter.heroku.com/articles/dyno-metadata#2019-12-0215:01romdoqHmm, apparently the defines weren't the only thing preventing my devtools from working. I'm currently using (js/require "ardoq-sheet-load/build/npm/shadow.cljs.devtools.client.browser") to load the devtools while my module is embedded in our main app. This worked previously, but appears to no longer be enough/correct?#2019-12-0215:23thheller@mel.collins if you are using project.clj or deps.edn then it is likely you just have a version conflict on the closure compiler/library releases#2019-12-0215:24thhellershould be
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2019-12-0215:27romdoqHmm, I don't have any of those in my deps.edn right now#2019-12-0215:55romdoq@thheller tried adding those versions explicitly, and it didn't change either of the issues I'm experiencing. 😞 For the defines issue, I can see in the browser console that $CLJS.CLOSURE_DEFINES contains myproject.core.EMBEDDED_DEV: true, but returning the value from a function within myproject.core returns false. 😕 To the devtools not working, I can see $CLJS.shadow.cljs.devtools.client.browser contains a bunch of functions and whatnot, so I guess it's being imported in some capacity, but none of the functionality is evident. Could the websocket be failing to connect silently? Not sure how to debug that. 😕#2019-12-0216:14romdoqHm. 2.8.68 is the most recent version where either of them work for me. Suggestions for fixing/debugging welcome, but otherwise I guess I'm going to have to stay on that release until I have more time/priority to investigate upgrading further. 😞#2019-12-0216:50thheller@mel.collins which version did you try? 2.8.77 should definitely work everything before .76 may have had a problem#2019-12-0216:50thheller.69 was the version that bumped the closure compiler/library so I'm fairly certain that is your issue#2019-12-0217:50colinkahnAre there any settings I can change to prevent “Too many open files” errors?#2019-12-0218:03thhellerbesides upgrading? haven't had any reports about that for a while now? which version are you on?#2019-12-0218:12colinkahn@thheller that did it! 2.8.51 -> 2.8.77 fixed it#2019-12-0221:43Pavel Klavík@thheller I was just testing :loader-mode :script and it works for WebWorker but source maps then don't work for the main code.#2019-12-0221:51thhellerhmm? I've been using workers all day and that worked fine?#2019-12-0221:54thhellermake sure you have :asset-path configured correctly though#2019-12-0222:04Pavel Klavík
:output-dir       "resources/public/js/compiled"
:asset-path       "/js/compiled"
#2019-12-0222:37thhellerlooks good. dunno why it wouldn't work then?#2019-12-0222:38Pavel KlavíkIt does display the error in a readable form, but when I click at a cljs file, Chrome opens the corresponding js files (and it states in the top that source maps are available, but it does not use them for whatever reason)#2019-12-0222:39Pavel Klavíkand when I set :loader-mode to default, everything works fine#2019-12-0222:39thhellerdunno. that uses the same source maps.#2019-12-0308:19cflemingHi all, I’m trying out shadow for some CLJS projects I have, it looks great so far. I have one question: I’m building code to deploy to AWS Lambda. I’m using :optimizations :simple , and I’d expected that to produce a single JS file. But it’s producing my :output-to file in a way that references a ton of other files under .shadow-cljs/builds - is that normal? Can I make it produce a single file without going to advanced optimisations?#2019-12-0309:45cflemingActually @U0510KXTU gave me the solution here, use release instead of compile.#2019-12-0309:12romdoq@thheller I was testing with 2.8.76, but 2.8.77 also has the same behaviour - defines are not being overridden, and devtools are not active (I'd guess because the define/s to enable the devtools aren't being overridden).#2019-12-0309:56Elirazhey, can shadow-cljs work with lumo ?#2019-12-0309:57thhellerno. why would it?#2019-12-0309:57ElirazHmmm so you won't have to deal with Java?#2019-12-0309:57thhelleryou mean install it once and never see it again?#2019-12-0309:58ElirazI know you don't really deal with Java, and still you need to configure it on every machine that you'd like to build your code..#2019-12-0309:58thhellerthe answer is no. shadow-cljs is written in Clojure and uses the Google Closure Compiler (written in Java). The Java requirement will stay.#2019-12-0309:59Elirazgot it. I thought that the Google Closure Compiler has a JavaScript variant.#2019-12-0310:00thhellerit does. but it is like 10x slower and also not extensible in the way the java version is#2019-12-0310:00Elirazokay. that's good to know.#2019-12-0310:01Elirazso lumo is not "there" yet.#2019-12-0310:02thhellernot sure where "there" is but lumo is an entirely different project with entirely different goals. dunno if it even supports "builds" nowadays, the focus was always scripting AFAICT#2019-12-0310:23romdoqOof okay, apparently I was wrong about devtools working in 2.8.68. In that version the websocket connects, but the browser doesn't appear to notice updates when shadow recompiles changed files. It appears that that stopped working for me in 2.8.56 . 😕#2019-12-0310:24thheller@mel.collins I'm working on that currently. I only verified in release builds and that did work fine#2019-12-0310:24thhellerbut dev builds do instead have issues with closure defines#2019-12-0310:25romdoqokay cool, thanks!#2019-12-0310:30thhellerwhy do you use :npm-module? I'm likely going to remove it given that it causes the most issues out of any builds#2019-12-0310:30thhelleroh nvm. you already answered that 😛#2019-12-0310:36thhellertry 2.8.78#2019-12-0311:07romdoq@thheller that seems to fix the defines, and the websocket is back! However, the hot reloading that stopped working in 2.8.56 is still broken. I thought it might be how I used my react components, but I don't get console logs about subscriptions being replaced (by re-frame) either.#2019-12-0311:12thhellerdo you get console logs about shadow-cljs doing stuff?#2019-12-0311:12thhellerI mean it should be logging something right?#2019-12-0311:13romdoqI get "websocket connected!" and "repl session start successful"#2019-12-0311:13romdoqand I can see a websocket message come through when a build completes 😕#2019-12-0311:14romdoqI mean in the network tab, not the console#2019-12-0311:14thhelleryou don't happen to have a reproducible example?#2019-12-0311:14thhellerI don't have a working webpack setup anymore ...#2019-12-0311:15thhellermaybe I can try setting one up later ... don't have any ideas about what might be happening right now#2019-12-0311:16romdoqI don't have a simple example, no. 😞 The only project I have is our main app, which is huge!#2019-12-0311:18sheluchinI'm new to Clojure(script) and I'm trying to get some clarity on how to run tests. I'm building a Fulcro application and I want the tests to be integrated with my editor, so I can run them from Vim and get the results right there. I have: • :deps {:aliases [:dev]} in shadow-cljs.edn • :paths ["src/app" "src/test"] in the top level of deps.edn • src/test/sheluchin/poker/core_test.cljs with these contents:
(ns sheluchin.poker.core-test
  (:require
    [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest test-numbers
  (is (= 1 1)))

(run-tests)
It's unclear to me which option I should be using for running the tests: node.js, browser, or karma. Is it absolutely necessary to define a build target specifically for testing, or can I forego that for the time being? What command should I be using to run the tests? If I just eval the (run-tests) form, it doesn't seem to pick up on updates to that file, so if I change the test to (is (= 2 1)) , save the file, and re-eval the (run-tests) form, all the test still shows as passing.
#2019-12-0311:19romdoqI can work with 2.8.55 for the time being, so no rush. @thheller Let me know if you need more info or testing from my side. Thanks for your work#2019-12-0311:21thheller@alex.sheluchin hot-reload in general only picks up changes from files used in the actual build (so no tests). you can use the :browser-test target for tests#2019-12-0311:22thhelleror I guess you could add the tests via :devtools {:preloads [your.foo.core-test]} in the regular build. that would make them hot-reload as well#2019-12-0311:23sheluchinAh, so even if I explicitly (require 'sheluchin.poker.core-test) after updating the file, it doesn't get picked up unless I shadow-cljs restart?#2019-12-0311:24thhellerto reload you'd do (require 'sheluchin.poker.core-test :reload) otherwise it'll not load anything if its already loaded#2019-12-0311:24thhelleror load-file is what I generally use (or rather my editor does)#2019-12-0311:25thhellerI don't think I have ever run a test as part of my regular build though#2019-12-0311:25thhellerno one has asked for that before either so support might not be great#2019-12-0311:25thheller(if you expect hot-reload, everything else should be fine)#2019-12-0311:26sheluchinFair enough, I won't go against the grain on that; I'll just set up the separate build target for testing.#2019-12-0311:27sheluchinWith a :browser-test build target, what's the usual way to run the tests? I'm guessing it's like everything else and has CLI and REPL equivalents?#2019-12-0311:28thhelleryou open the webpage. tests run on hot-reload#2019-12-0311:29sheluchinIf I want the results in my shell, is there a command I can call for that?#2019-12-0311:30thhellerkarma or node-test#2019-12-0311:30thhelleryou said fulcro application so I assumed webapp and that you need a browser#2019-12-0311:33sheluchinYep, it's a Fulcro webapp, but I want the results in my shell so I don't have to look at the browser. I understand that I need to have the builds active and need to have dev tools open to interact with the environment, but once that's done, I can receive the results in the shell as well as them being printed in the console?#2019-12-0311:35thhellerthats what karma would provide but you can't REPL into that at all#2019-12-0311:36sheluchinhmm#2019-12-0311:37sheluchinOkay, thanks for the advice and info. This should be enough for me to try a few things and see if I can get something to work how I want it. Much appreciated.#2019-12-0311:38thhellerif you want to run the tests from the REPL as part of your main build then just try the :preloads thing I mentioned#2019-12-0311:38thhellerif you want other automated stuff you are limited to what is currently provided#2019-12-0311:43sheluchinI'll provide some feedback after I figure out a setup that works for me. At this point I just want the testing to play nice with vim-fireplace and there's no definitive guide on that just yet. Thanks again.#2019-12-0313:11sheluchin
[1:1]~cljs.user=> (require 'sheluchin.poker.core-test :reload)

Testing sheluchin.poker.core-test

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
nil

[1:1]~cljs.user=> (load-file "sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
 :cause "file not on classpath"
 :data {:file-path "sheluchin/poker/core_test.cljs"}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "file not on classpath"
   :data {:file-path "sheluchin/poker/core_test.cljs"}
   :at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
 :trace
 [[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
  [shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
  [shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
  [shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
  [shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
  [shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
  [shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
  [shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
  [shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
  [clojure.lang.MultiFn invoke "MultiFn.java" 234]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 834]]}}]
[1:1]~cljs.user=>

+08:07 $ npx shadow-cljs classpath | tr ':' '\n'
shadow-cljs - config: /home/alex/repos/clojure-stuff/fulcrologic/poker/shadow-cljs.edn  cli version: 2.8.64  node: v8.11.1
src/app
src/test
...


+08:08 $ tree src/test/
src/test/
└── sheluchin
    └── poker
        └── core_test.cljs
I can require the namespace and it works fine, but load-file complains that the file is not in the classpath, although it clearly is.
#2019-12-0313:12thhellerwhat happens if you load-file first?#2019-12-0313:12thhelleroh wait ...#2019-12-0313:12thhellerload-file takes an actual file path#2019-12-0313:12thhellernot a resource path#2019-12-0313:13thheller(load-file "src/test/sheluchin/poker/core_test.cljs")#2019-12-0313:14sheluchin
[2:1]~cljs.user=> (load-file "src/test/sheluchin/poker/core_test.cljs")
[:result {:type :repl/error, :ex #error {
 :cause "file not on classpath"
 :data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "file not on classpath"
   :data {:file-path "src/test/sheluchin/poker/core_test.cljs"}
   :at [shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]}]
 :trace
 [[shadow.cljs.repl$repl_load_file_STAR_ invokeStatic "repl.clj" 254]
  [shadow.cljs.repl$repl_load_file_STAR_ invoke "repl.clj" 227]
  [shadow.cljs.repl$repl_load_file invokeStatic "repl.clj" 301]
  [shadow.cljs.repl$repl_load_file invoke "repl.clj" 299]
  [shadow.cljs.repl$process_read_result invokeStatic "repl.clj" 426]
  [shadow.cljs.repl$process_read_result invoke "repl.clj" 406]
  [shadow.cljs.devtools.server.worker.impl$do_repl_rpc invokeStatic "impl.clj" 797]
  [shadow.cljs.devtools.server.worker.impl$do_repl_rpc invoke "impl.clj" 751]
  [shadow.cljs.devtools.server.worker.impl$eval15200$fn__15201 invoke "impl.clj" 828]
  [clojure.lang.MultiFn invoke "MultiFn.java" 234]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773$fn__14781 invoke "util.clj" 285]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772$fn__14773 invoke "util.clj" 284]
  [shadow.cljs.devtools.server.util$server_thread$fn__14772 invoke "util.clj" 257]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 834]]}}]
[2:1]~cljs.user=>
#2019-12-0313:14thhellerwhich version are you on?#2019-12-0313:14sheluchinthheller/shadow-cljs {:mvn/version "2.8.52"}#2019-12-0313:14thhellerI only added support for relative paths recently#2019-12-0313:14thhelleryeah that version still required absolute paths#2019-12-0313:15sheluchinAh, I was thinking about upgrading shadow-cljs but I wasn't too confident if it would continue to be compatible with the Fulcro version I'm on.#2019-12-0313:16thhellerthat works fine (I'm using fulcro myself)#2019-12-0313:17thhellerthe only thing you need to watch out for is dependency conflicts when using deps.edn but generally it should be fine#2019-12-0313:17thhelleror just (load-file "/Users/whoever/projects/that-project/src/test/sheluchin/poker/core_test.cljs")#2019-12-0313:17thhelleror wherever the file lives 😛#2019-12-0313:18thhellerbut I fixed a bunch of REPL stuff since .52 so probably worth upgrading#2019-12-0313:18sheluchinOkay, guess that's homework for tonight or tomorrow. Looking forward to upgrading. Thanks! Off to work now.#2019-12-0314:26deasJust getting started with shadow-cljs, so please forgive me in case I am missing something.#2019-12-0314:28deasMigrating to shadow-cljs requires getting rid of all foreign-deps and hence, cljsjs deps, right?#2019-12-0314:33deasOk, appears I want thheller/shadow-cljsjs- sorry for the noise.#2019-12-0316:24ElirazHey, I was just wondering, is shadow-cljs using figwheel under the hood?#2019-12-0316:36thheller@eliraz.kedmi no it does not#2019-12-0316:37thheller@deas shadow-cljsjs includes a number of pre-made shims yes. it is included by default you don't need to depend on it#2019-12-0400:51AronHi. I am reading this https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration and there is this caution which I don't understand. It says use standalone version. Standalone what? Is it telling me to NOT use deps.edn to manage dependencies?#2019-12-0400:52thhellerstandalone as in dependencies managed by shadow-cljs.edn#2019-12-0400:53thhelleryou can use deps.edn but you have been warned when you run into dependency conflict issues and so on#2019-12-0400:53thhellerdeps.edn is a bit better dealing with those than project.clj but they can still happen#2019-12-0400:54AronI don't know enough to understand these tradeoffs, so I am inclined to take this as gospel : ). But it feels weird, I thought deps.edn is good.#2019-12-0400:56thhellerit is ...#2019-12-0401:59dpsuttonHa I originally read this as you saying “it is... the gospel”#2019-12-0400:59Aronso, what kind of dependency conflict issues can there be? I mean, if I would use only deps.edn for it? Is this something inherent to clojure/clojurescript ecosystem or just shadowcljs vs the other tools? Sorry if it's the wrong kind of question to ask.#2019-12-0401:01thhellershadow-cljs tries to ensure that you get clojurescript, closure-compiler, closure-library versions that are actually compatible#2019-12-0401:01thhellerif you use deps.edn you have to manage that yourself and keep it matched#2019-12-0401:02thhellerusually that works out .. sometimes it doesnt ...#2019-12-0401:03AronI see, I didn't realize there could be incompatibilities like that. Thanks for the explanation, I think I will use the built in for now : )#2019-12-0406:10Pavel KlavíkI am testing version 78 and my WebWorkers got broken:
;; for /browser-repl in case the page is reloaded
  ;; otherwise the browser seems to still have the websocket open
  ;; when doing the reload
  (js/window.addEventListener "beforeunload"
    (fn []
      (when-let [s @socket-ref]
        (.close s))))
#2019-12-0406:11Pavel Klavík
browser.cljs:406 Uncaught ReferenceError: window is not defined
    at browser.cljs:406
    at layout.js:2110
    at Array.forEach (<anonymous>)
    at Object.env.load (layout.js:2106)
    at layout.js:2142
#2019-12-0406:23Pavel KlavíkIt should probably be js/self instead of js/window in WebWorker.#2019-12-0407:29Eliraz@thheller Is it possible to make figwheel work with shadow-cljs#2019-12-0407:29Eliraz?#2019-12-0407:30Pavel KlavíkNot really needed, shadow-cljs has something like figwheel build in, everything works for free.#2019-12-0408:15orestisIs there a way to get the build size report as data, instead of as HTML? Would like to keep a history of build sizes etc somehow.#2019-12-0410:17thheller@pavel.klavik sorry I forgot to document since the feature is kinda unfinished. you can set :devtools {:browser-inject :name-of-the-main-browser-module}#2019-12-0410:17thhellerotherwise the browser devtools get injected into the shared module but they don't work in the workers#2019-12-0410:18thhellerworkers now have their own devtools inject so hotreload and REPL work#2019-12-0410:19thheller@orestis there is a .shadow-cljs/release-snapshot/the-build/latest/bundle-info.edn#2019-12-0410:22thhellerthe build-report stuff sort has its own versioning already built-in its just not accessible from the command line#2019-12-0410:50Pavel KlavíkHow does the repl for web workers work?#2019-12-0410:54thhellerjust like any other REPL ... but your editor might not support selecting it#2019-12-0410:54thhellerwhich editor do you use?#2019-12-0410:55thhelleryou can disable the worker inject (to disable hot-reload/REPL) via :worker-inject false#2019-12-0411:44deasAppears shadow-cljs does not support require outside ns, right?#2019-12-0411:45thhelleryes. curious why you'd want to use it? as it doesn't allow you to do anything you can't already do in the ns#2019-12-0411:49deasGot a conditional macro (depending on :compiler-options {:custom-stuff {...}}) choosing what goes into a build.
(prefs/if-cljs-kernel
 (require '[pinkgorilla.kernel.shadowcljs :as cljs-kernel])
 (require '[pinkgorilla.kernel.mock :as cljs-kernel]))
#2019-12-0411:49thhellerthat doesn't work. I mean it doesn't work in CLJS either. you can't make require conditional. CLJS stops parsing at the prefs/if-cljs-kernel#2019-12-0411:50deasRight in the middle of "migrate to shadow-cljs" work (new to it) so I might be missing something.#2019-12-0411:51deasIt worked before.#2019-12-0411:51deashttps://anmonteiro.com/2016/10/clojurescript-require-outside-ns/#2019-12-0411:52thhellerhmm worked where? its not supposed to work?#2019-12-0411:53deasWorked with figwheel and lein-cljsbuild.#2019-12-0411:54thhellerhmm strange. I thought it didn't run macros. guess I was wrong#2019-12-0411:55deasI get an error complaining that requirecannot be used anywhere other than in the ns form which is generally not true.#2019-12-0411:55thhellerFWIW you can set :build-options {:ns-aliases {pinkgorilla.kernel.shadow-cljs pinkgorilla.kernel.mock}}#2019-12-0411:55thhellerthat would make it use the mock ns whenever the shadow-cljs one was required#2019-12-0411:56deasNever heard of :ns-aliases, but this looks like it could do the trick.#2019-12-0411:56thhellerits shadow-cljs only and not documented but meant to solve exactly this problem 😛#2019-12-0411:57thhellerI'll see about require. my assumption always was that it also didn't run macros but I guess it does?#2019-12-0411:57thhellerit definitely doesn't work if if-cljs-kernel was a function#2019-12-0411:58thhellerrequire outside ns was really meant for scripts that didn't have an ns (which shadow-cljs doesn't support either)#2019-12-0411:59deasif-cljs-kernel is a macro which acts depending custom :compiler-options#2019-12-0411:59thhelleryeah I figured as much#2019-12-0412:05deas🙏 ...#2019-12-0412:08thhellerit analyzes indeed ...#2019-12-0412:10thhellerI swear this function is my arch nemesis https://github.com/clojure/clojurescript/blob/6ed949278ba61dceeafb709583415578b6f7649b/src/main/clojure/cljs/analyzer.cljc#L4326 😛#2019-12-0412:21deasAppears there is an issue with 2.8.78 😉
[:app] Build failure:
IllegalArgumentException: Wrong number of args passed to keyword: :ns-aliases
        clojure.lang.Keyword.throwArity (Keyword.java:98)
        clojure.lang.Keyword.invoke (Keyword.java:149)
        clojure.core/update (core.clj:6200)
        clojure.core/update (core.clj:6188)
        shadow.build/copy-ns-aliases (build.clj:251)
#2019-12-0412:22thhellerwhat the heck is that? 😛#2019-12-0412:25thhelleroh haha ... I'm dumb 😛#2019-12-0413:00deasNP. Likely still good enough! 😉#2019-12-0412:28Pavel Klavík@thheller I am running Cursive.#2019-12-0412:28thhellerfixed in 2.8.80#2019-12-0412:29thheller@pavel.klavik do you use nrepl?#2019-12-0412:32Pavel KlavíkYes, nrepl
#2019-12-0412:32thhellerunfortunately there is no easy way to select which runtime to talk to in nrepl#2019-12-0412:33Pavel KlavíkWhat would be another option?#2019-12-0412:34thhelleryou can run (shadow.cljs.devtools.api/repl-runtimes :todomvc-split) in the clojure REPL#2019-12-0412:35thhellerthat'd give you something like
[{:runtime-info {:runtime-type :browser,
                 :lang :cljs,
                 :build-id :todomvc-split,
                 :user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
                 :remote-addr "0:0:0:0:0:0:0:1"},
  :last-ping 1575462862870,
  :last-pong 1575462862872,
  :last-msg-received 1575462862872,
  :last-pong-runtime 1575462862871,
  :connected-since 1575462831938,
  :runtime-id "69b97643-1982-4922-b7cf-375bfa7496a8"}
 {:runtime-info {:runtime-type :worker,
                 :lang :cljs,
                 :build-id :todomvc-split,
                 :user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.56 Safari/537.36",
                 :remote-addr "0:0:0:0:0:0:0:1"},
  :last-ping 1575462863873,
  :last-pong 1575462863874,
  :last-msg-received 1575462863874,
  :last-pong-runtime 1575462863874,
  :connected-since 1575462832785,
  :runtime-id "ebd1298e-0201-430b-889b-30bc97eb0103"}]
#2019-12-0412:37thhellerhmm nevermind#2019-12-0412:37thhellerit doesn't work in nrepl 😛#2019-12-0412:38thhellerin theory you should be able to use (shadow.cljs.devtools.api/repl :the-build {:runtime-id "that-runtime-id-from-above"})#2019-12-0412:44Pavel KlavíkI will test it later. But i wouldnt mind to switch to some other repl, Cursive now supports SocketREPL as well.#2019-12-0412:45Pavel KlavíkNot very familar with repls, yet#2019-12-0412:45thhellerI think it doesn't really work anywhere right now#2019-12-0412:46thhellerpicking a runtime-id by hand is a bit annoying#2019-12-0412:46thhellerwould be neat if the editor just supported selecting runtimes. I did some experiments with that in the shadow-cljs UI but its all unfinished#2019-12-0412:47Pavel KlavíkI see, it is ok to do this when you dont do it that frequently.#2019-12-0412:47Pavel KlavíkIs it possible to run multiple instances with different runtimes?#2019-12-0412:48thheller"instances"? of what?#2019-12-0412:50Pavel KlavíkShadow is running nrepl on a port, and i open a window in Cursive which connect there. So the question is whether i can have multiple windows, one for each runtime?#2019-12-0412:50thhelleryou can open as many nrepl connections as you want yes. and each can talk to a different runtime yes.#2019-12-0412:51Pavel KlavíkI see. Than one could probably bind some keys to do the switching, I will take a look later.#2019-12-0412:51thhellerthats the idea behind runtimes as there can always be multiple in a browser env. ie. opening the page in chrome/firefox. or just using workers since they run in their own little world#2019-12-0412:53Pavel KlavíkI see. Make sense, running a page in multiple tabs.#2019-12-0412:53Pavel KlavíkCornerning hot reloading, I can basically remove restarting the web workers now?#2019-12-0412:54thhellermaybe? I'm still testing this myself. in theory hot-reload should be fine now#2019-12-0412:55Pavel KlavíkOk, I will test it later and will let you know.#2019-12-0413:06deas@thheller Would you mind rolling to 2.8.80? 😂#2019-12-0413:09thhellerhmm? I release 2.8.80 45 minutes ago or so?#2019-12-0413:21deasJust pulled and saw 2.8.79 came out today. Did not expect that I was already lagging. 🙂#2019-12-0413:21thhelleryeah I just pushed the fix to the problem you ran into with :ns-aliases#2019-12-0413:23deasStarted working on a PR alfready. Did not expect you to react at that pace. Thanks Thomas!#2019-12-0415:10scottloweIf I pass two target arguments to the shadow-cljs watch function, shadow-cljs shuts down once the targets are compiled. e.g.:
20:52 $ shadow-cljs watch dev test
shadow-cljs - config: /Users/scott/code/xxxx/shadow-cljs.edn  cli version: 2.8.52  node: v12.11.1
...
shadow-cljs - watching build :dev
shadow-cljs - watching build :test
[:dev] Configuring build.
[:test] Configuring build.
[:test] Compiling ...
[:dev] Compiling ...
[:dev] Build completed. (240 files, 1 compiled, 0 warnings, 3.65s)
[:test] Build completed. (240 files, 1 compiled, 0 warnings, 3.67s)
shutting down ...
Worker shutdown.
Worker shutdown.
Works fine and continues to watch when only one target argument is supplied. Am I doing this wrong?
#2019-12-0415:12thhellerthats not normal. you may be getting killed by the system?#2019-12-0415:12thhellerdo you use deps.edn/project.clj? you cut that bit of information out#2019-12-0415:15scottloweThanks. We use deps.edn#2019-12-0415:15scottloweThe section that I cut out in a failed attempt at helpful brevity was:
shadow-cljs - starting via "clojure"
[2019-12-04T10:13:14,521][INFO ][o.xnio                   ] XNIO version 3.7.3.Final
[2019-12-04T10:13:14,542][INFO ][o.x.nio                  ] XNIO NIO Implementation Version 3.7.3.Final
[2019-12-04T10:13:14,581][INFO ][o.j.threads              ] JBoss Threads version 2.3.2.Final
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.52 running at 
shadow-cljs - nREPL server started on port 8777
#2019-12-0415:16thhelleralright so you'd set :jvm-opts in deps.edn then#2019-12-0415:16thhellerbut try upgrading first#2019-12-0415:13thhelleralso try upgrading since I did a bunch of fixes which reduced resource use a bunch. 2.8.80 is latest#2019-12-0415:14thhellerit looks like you use macOS which seems to kill the shadow-cljs process sometimes for consuming too much memory#2019-12-0415:14thhelleryou can set :jvm-opts ["-Xmx1G"] in shadow-cljs.edn to constrain that#2019-12-0415:14thhellerbut upgrading will most likely take care of that#2019-12-0415:16scottloweThank you so much. That’s a good point about memory consumption. I will upgrade and if that doesn’t work, try tweaking the memory settings. Cheers for the incredibly fast response. shadow-cljs really is a fantastic project and a pleasure to use.#2019-12-0415:35scottloweconfirmed: Upgrading to 2.8.80 worked. No memory constraints required. Thanks again 🙂#2019-12-0416:48nickmbaileyman this had me thinking i was going insane https://github.com/thheller/shadow-cljs/issues/612#2019-12-0416:59thhellerno idea whats up with that but it caused upstream in CLJS#2019-12-0417:00nickmbaileyfun#2019-12-0417:00nickmbaileyi guess i can file a jira#2019-12-0417:20awb99I have a stupid question on how to use "deps.cljs" I have a project https://github.com/pink-gorilla/leaflet-shadow/blob/master/src/deps.cljs#2019-12-0417:21awb99In the project I use a few npm dependencies and then I publish the project to clojars#2019-12-0417:21awb99If now other projects require leaflet-shadow when I define a deps.cljs file#2019-12-0417:22awb99will then shadow cljs automatically get the transient npm dependencies ?#2019-12-0417:22awb99Provided the projects that use my project use shadow-cljs#2019-12-0417:23awb99Essentially my library is a slim wrapper around react-leaflet. So I think the right place to publish this lib to is clojars...#2019-12-0417:24awb99I want to avoid having to remember to require transient npm dependencies#2019-12-0417:31awb99Is this possible?#2019-12-0417:45mauricio.szaboHi there! I'm trying to rewrite a project that uses webpack+react to ClojureScript with Shadow-CLJS. The thing is, I don't want to do a "big rewrite", and instead I would like to start migrating existing react components to CLJS little by little.#2019-12-0417:47mauricio.szaboI though that using :node-library's target would allow me to integrate with webpack and all other tools on the React side, but its not working (because it needs some of the Node code, like readFileSync and others). I could use :npm-module but then I loose the ClojureScript REPL. Is there any alternative?#2019-12-0417:50aisamuWe're doing something similar with :npm-module as a target, going outside-in (i.e. from the leaves). We still use the REPL#2019-12-0417:51aisamuThese had to be added on the js entrypoint: (`cljs/` ` is a webpack alias pointing to the cljs build folder)
window.CLOSURE_BASE_PATH = '/javascripts' // Should match your assets location
require('cljs/shadow.cljs.devtools.client.browser') // REPL
require('cljs/shadow.remote.runtime.cljs.browser') // Shadow's Inspect
#2019-12-0417:54mauricio.szaboGreat, I'm gonna test right now 🙂#2019-12-0418:09mauricio.szaboJust for the record, if I add [shadow.cljs.devtools.client.browser] on one of the required namespaces, it works too 🙂#2019-12-0419:26thheller@hoertlehner yes that should work fine?#2019-12-0419:27thheller@mauricio.szabo :node-library presumes node not webpack + browser.#2019-12-0419:27awb99@thheller just a file in the src path named deps.cljs ?#2019-12-0419:27thhelleryes#2019-12-0419:27thhellerbut it only works in libraries#2019-12-0419:27awb99ok#2019-12-0419:28awb99but I dont add a reference to that file anywhere?#2019-12-0419:30thhellerno#2019-12-0419:31thhellerjust has to be in the classpath root in a library#2019-12-0421:26mauricio.szaboIs :npm-module able to run before/after load code?#2019-12-0421:27mauricio.szaboI'm not seeing it working on my setup#2019-12-0421:27mauricio.szabo(in fact, I'm not sure the hot reload is working either)#2019-12-0421:43thheller@mauricio.szabo in general hot-reload and REPL are a bit constrained when running through webpack. it sometimes work if you require the REPL ns separately from JS#2019-12-0421:43thhellersomething like if (process.env.NODE_ENV === "development") { require("./path-to-output/shadow.cljs.devtools.client.browser") }#2019-12-0422:54awb99@thheller cool - got transient dependencies going with deps.cljs -> very cool feature!!#2019-12-0511:43indyHey All, How do I use the Garden library to generate the CSS and then include it in my project? I understand (css [:h1 {:font-weight "bold"}]) will output the appropriate CSS string, but how do I create a CSS file from this and include it in my ClojureScript project? I'm using shadow-cljs as my build tool#2019-12-0511:44indyFor Leiningen there is lein-garden that will handle the cljs->css compilation#2019-12-0511:45deasAppears devcards is relying on global React (which is not what you get by default). What are you guys using instead? Storybook?#2019-12-0511:46thheller@deas you can require cljsjs.react before including devcards#2019-12-0511:46thhellerthat creates the shim global#2019-12-0511:46thheller@kslvsunil I don' know. I've never used garden myself.#2019-12-0511:47thhellerlein-garden looks like it only supports clojure though?#2019-12-0511:48thheller@deas might also need cljsjs.react.dom. I don't know why devcards doesn't require them directly itself#2019-12-0511:48thhellerI think https://github.com/nubank/workspaces is pretty great#2019-12-0511:50deas@thheller Appears devtools does not get much ❤️ these days. We don't have much to loose yet, so I guess it is time to depart now.#2019-12-0511:58Filipe Silva@deas https://github.com/filipesilva/create-cljs-app has an example of using devcards with react testing-library on shadow-cljs#2019-12-0511:59Filipe Silvait's true that devcards doesn't get a lot of attention, but I don't think storybook fills the same use case#2019-12-0511:59Filipe Silvadevcards is more exploratory, whereas storybook is more catalog-y#2019-12-0511:59thhellerstorybook also doesn't match CLJS very well since it expects to work with ESM code#2019-12-0512:02Filipe Silva@thheller how should devcards be importing react to be compatible with shadow-cljs by default? I can open an issue there. I think it's likely that devcards will need to get a version out soon because it doesn't support newer react versions well, and will want to include the newer reagent that does.#2019-12-0512:03thhellerjust (:require ["react" :as react]) should work. I believe the newer cljsjs/react packages have that setup correctly to emulate#2019-12-0512:03thhellernot sure though. haven't used default CLJS since forever ago 😛#2019-12-0512:14deasSorry for the noise, but appears I am running into every brickwall one could imagine ... 😢#2019-12-0512:14Filipe Silvaopened said issue https://github.com/bhauman/devcards/issues/165#2019-12-0512:19deasRunning compilevia lein :aliases ẁorks ... until it does not when calling the alias from :prep-tasks. Seems this signature error is not uncommon. Any suspect about the possible culprit?
Note: Recompile with -Xlint:unchecked for details.
Syntax error (NoSuchMethodError) compiling at (shadow/cljs/devtools/api.clj:1:1).
com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
#2019-12-0513:23thheller@deas thats a dependency conflict. looks like guava.#2019-12-0513:25deasMoving [thheller/shadow-cljs "2.8.80"] from :dev profile to default deps gets around it, but guess I don't want shadow-cljsending up in the (uber)jar.#2019-12-0513:26thhellerwell I recommend using shadow-cljs.edn for reasons such as this#2019-12-0513:26thhellerbut you can certainly resolve it in lein. just can't help you much.#2019-12-0513:27deasAlready got that. Actually, it was the moment I understood why you suggest it.#2019-12-0513:27deasDependency Hell(er). Sorry, could not resist. 😉#2019-12-0513:28thheller😛#2019-12-0513:28thhellerI believe one of the culprits is datomic using an older guava version than the closure compiler#2019-12-0513:28thhellerand the closure compiler being unhappy if it runs with an older guava version#2019-12-0513:29deasDatomic issues propagate all the way down to ... me? WTF? 😉#2019-12-0513:30deasFeels like navigating a mine field. :collision:#2019-12-0513:30thhellerthats why I keep my CLJS separate builds separate from my CLJ builds 😉#2019-12-0513:31deasVery reasonable. Now may be the time for me to swallow even more ...#2019-12-0513:32thhellerin the past I have done :backend and :frontend profiles in lein. that works reasonably well too#2019-12-0513:34deasAlso good point. Guess I better go out for a walk with the 🐶 and think about that for a moment. We still have a huge mess to untangle ahead of us ...#2019-12-0513:37deasActually, I expected to finish shadow-cljs migration today. Now I find there is a whole lot of yak to shave.#2019-12-0513:38thhellerwhich CLJS version did you use before? the closure compiler guava problem should have existed with plain 1.10.520 too I think#2019-12-0513:38deasAll things latest and greatest, so 1.10.597#2019-12-0513:38thhellerhmm odd#2019-12-0513:45deasAppears it is not uncommon to weed out transitive clojurescript deps. tumbleweed#2019-12-0611:00deasOut of dependency hell for the moment, but it is still hot around here. 🔥 😜#2019-12-0611:02thheller@deas btw I looked a bit over the CLJS sources yesterday and I'm fairly certain that your "conditional" require is not supposed to work and only works accidentally 😛#2019-12-0611:04thhellerCLJS has a bunch of those accidental things 😛#2019-12-0611:04deasWe are in the middle of cleaning up dependency hell.#2019-12-0611:04deasClojure, Java, ClojureScript, JavaScript ... horrible experience.#2019-12-0611:05thhellerhehe#2019-12-0611:05deasTons of details to suffer through.#2019-12-0611:07deasOh wait theres more: Missed python. Comes with it's very own mess (pip).#2019-12-0611:08thhellerprogramming is fun isn't it? 😛#2019-12-0611:09deasGet's even better once YAML enters the mix.#2019-12-0611:10deasNot sure which one of those is my favorite.#2019-12-0611:13thhelleronce you get to know the JS npm ecosystem up close and personal it'll definitely become your favorite ... thing to avoid ... :face_vomiting:#2019-12-0611:15deas☝️ One does not simply avoid the npm ecosystem.#2019-12-0611:17deasRemember Google closure maintainers struggling with node modules years ago. That still the case?#2019-12-0611:17thhellerI really hope they get their act together with this ESM stuff ... thus mess needs to end#2019-12-0611:17thhellerif you mean running random node_modules code through :advanced then yes that will never happen#2019-12-0611:18thheller(unless everything moves to strict standard ES6 or so ... so never)#2019-12-0611:23deasWonder how many really popular but messy node modules are out there. I mean, I would assume that React and others along those lines are pretty strict and clean by now.#2019-12-0611:23thhellerI wish ... quite the opposite actually. they also don't ship ESM at all. only precompiled stuff.#2019-12-0611:24deasAutocorrect? :rolling_on_the_floor_laughing:#2019-12-0611:26thheller😛#2019-12-0615:55HiHello, why https://github.com/day8/re-frame/blob/master/docs/CodeWalkthrough.md out of the box displays "Not found. Missing index.html." in the browser? Is there any bug reported on this or do I miss some dependencies?#2019-12-0617:44thhellerthe example tells you to open example.html? which url did you load? there is no index.html?#2019-12-0700:03mikethompsonThere was a docs bug. Corrected now.#2019-12-0616:10Hiin Active Builds window it sais client Watch starting ...#2019-12-0616:14royalaidHey @thheller, I don't want to clog up https://github.com/thheller/shadow-cljs/issues/611 with possibly off topic stufff so I figured I would move my questions here#2019-12-0616:17royalaidSo I removed the :rewrite-polyfills like you suggested but am still encountering the same error#2019-12-0616:18royalaidRunning a completely fresh recompile, cleaned out .shadow-cljs and my output folder (not that it is needed) I get....#2019-12-0616:20royalaid
Uncaught TypeError: $jscomp.initSymbol is not a function
    at okta-sign-in.entry.js:14983...
#2019-12-0616:20royalaidThe same... 😞#2019-12-0616:21royalaidCompiled with cli version: 2.8.80 node: v12.3.1 and running on server cli version: 2.8.80 node: v12.3.1 just to confirm#2019-12-0616:22royalaidNot sure that it matters in this case but we are using tools.deps for deps.#2019-12-0616:22royalaidAnything else you want to me to try or post?#2019-12-0617:27deasWhat is everybody using today? yarnor npm?#2019-12-0617:28aisamuWe're thankfully using yarn!#2019-12-0617:35deas"Thankful" sounds like we want to join you. 😜#2019-12-0617:37sogaiui've had far less problems with npm recently than before -- but am using both (depending very much on the project)#2019-12-0617:37deasSuffered enough already.#2019-12-0617:41Filipe SilvaI prefer npm because that generally leaves me closer to what most users are using#2019-12-0617:42Filipe Silvabut yarn has two things that help a lot: running any script as yarn scriptname and resolution to pin arbitrary packages#2019-12-0617:42Filipe Silvaso I end up using yarn for those#2019-12-0617:46sogaiuon a side note, i think one of the values of yarn was (is?) that it may have "motivated" improvements on npm's side :)#2019-12-0617:49deas@UG1C3AD5Z That is in fact what I was wondering: Did yarn get npm to do things properly and can we all get back to using the default thing.#2019-12-0617:51Filipe Silvanpm did improve a lot since yarn came along#2019-12-0617:52Filipe Silvaat the moment it's almost a matter of preference#2019-12-0617:52deas@UJVKWJTGE I'd say pinning matters a lot. I don't want to get different results every other day - when not changing code myself that is#2019-12-0617:52Filipe Silvaif you want to publish things you should still go with npm, because npm is the real registry#2019-12-0617:52Filipe Silvathat's different#2019-12-0617:52Filipe Silvathe thing that prevents you from getting different versions is the lockfile#2019-12-0617:53Filipe Silvaboth have a lockfile: yarn.lock and package-lock.json#2019-12-0617:53Filipe Silvathey have slightly different philosophies but both ensure subsequent installs where your direct deps don't change won't get different dep trees#2019-12-0617:53Filipe Silvawhen I mentioned resolutions, it's a different feature#2019-12-0617:54deasI know, but somehow what you said appeared as "`package-lock.json`is still not safe".#2019-12-0617:54Filipe Silvaoh no, that's even slightly safer than yarn.lock#2019-12-0617:55Filipe Silvapackage-lock contains more information than yarn.lock#2019-12-0617:55Filipe Silvathe thing I like about resolutions is that it lets you control transitive dep versions, which is very useful when they inadvertently break#2019-12-0617:58deasWe have tons of deps everywhere. For the project we are working on, I'd aim at maximum defense wrt to dependencies getting out of control.#2019-12-0617:59deasBeen using maven for ages, but still learnt a ton about many details that haven bitten me just recently.#2019-12-0617:48thheller@royalaid I can't reproduce your error. I can require @okta/okta-signin-widget just fine and it loads just find in dev and release builds. maybe you can try setting :compiler-options {:output-feature-set :es6} although it works without for me#2019-12-0618:01royalaidI will try and get an isolated repro#2019-12-0620:56royalaid@thheller my super janky repro so far hasn't triggered the issue so I am going to spend some more time trying to figure specifically why this is happening#2019-12-0620:56royalaidSo you not seeing the issue makes sense, it must be something that we are doing with our build#2019-12-0620:57thhellerif you use multiple :modules try setting :compiler-options {:output-wrapper false}?#2019-12-0708:05deasStill hoping I'll get away without getting into the details of shadow-cljs, so here is one more ... 😉#2019-12-0708:16deasshadow-cljs compile/`watch`give me a somewhat huge (12MB) module. That appears a bit odd for :none optimization. However, the cljs-runtime folder is 25MB and looks expected to me. Guess it all still somehow makes sense and there may be some desired redundancy. Could anyone please briefly explain how come the module may get that big?#2019-12-0710:03p-himikMaybe this will help: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2019-12-0710:04p-himikIf you don't use all that code, there's definitely some tight coupling that prevents it from being DCE'ed. Also multimethods in libraries that are imported but not used prevent DCE. Maybe some other things I'm not aware of.#2019-12-0710:48deasJust looking at compile/ watchso I assume this is :none and hence, no DCE involved. The release build appears fine and just as expected. Will check build-report.#2019-12-0711:22thheller@U06FLL69W see https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518#2019-12-0711:22thhellerthat has since become the default. if you'd rather use the "old" style of loading many separate files you can set :devtools {:loader-mode :script}#2019-12-0711:23thhellerbut this "huge" 12MB file is typically quite a bit faster to load#2019-12-0711:45deas@thheller Somehow felt that what I see is working as intended. And loading the "big" bundle is indeed fast - likely faster than loading hundreds of small files. Thanks for clarification.#2019-12-0711:46thhellerits easy to test out. just add the config bit I posted to the build while watch is running an reload the page#2019-12-0711:47thhellersee what feels best 😛 it kinda depends on how many files you load. if you use the built-in http server and enable caching both variants are pretty close on fast desktops#2019-12-0711:48thhellerno need to restart the watch between config tweaks#2019-12-0711:56deasHehe, was pleasantly surprised to see shadow watching build configuration as well. 😃 And :loader-mode :script indeed changes the size of the module as you pointed out. Again, thanks.#2019-12-0709:38royalaidSo a fresh recompile and it still complains BUT this time it is different#2019-12-0709:52royalaid#2019-12-0712:03mhuebertI think I’ve got a minimal repro of @royalaid’s issue, https://github.com/mhuebert/repro-shadow-Symbol#2019-12-0712:13thheller:compiler-options {:output-wrapper false} seems to fix that?#2019-12-0712:15thhellerit is a weird scoping issue regarding the $jscomp variable#2019-12-0712:16thhellerits weird that my fix for that doesn't work though#2019-12-0712:16mhuebertyeah, in the non-minimal build, :output-wrapper is necessary (setting to false causes some other error)#2019-12-0712:16thhellervery strange#2019-12-0712:18thheller
var $jscomp = {};
...
var $APP = {};
(function() {
  var $jscomp = $jscomp || {};
#2019-12-0712:18thhellerI'm declaring it outside the output-wrapper so it should be a global#2019-12-0712:18thhellerbut for some reason it isnt#2019-12-0712:22thhellerdid they change the behavior of var? I could have sworn this was supposed to work with var. let or const wouldn't.#2019-12-0712:22thhellerif I remove the second var $jscomp it works fine but no clue how to get the closure compiler to do that#2019-12-0712:25mhueberti have deja vu because I ran into this exact same var issue a few months ago but can’t remember the context#2019-12-0712:26thhellerI did change the :output-wrapper default to true so if you didn't set that manually before you wouldn't run into this#2019-12-0712:26thheller(it was only the default for single-module builds)#2019-12-0712:27thheller:compiler-options {:output-feature-set :es6} also works if you can live with that#2019-12-0712:31orestisAFK right now - but IIRC I tried a minimal reproduction of the above behavior and it doesn’t work. I can’t point to why (JavaScript scoping is weird) but in the issue I created, the workaround works. #2019-12-0712:32orestisI think it’s something with hoisting#2019-12-0712:32thhellerright window.$jscomp might be better#2019-12-0712:33thhellerI'll try to figure out what is going on exactly. should be easier given that I have a reproducible case now.#2019-12-0712:34orestisI made an experiment with just a global var and an iife, to see what can be done. Very easy to try things out. #2019-12-0712:34royalaid@thheller if something is up with how var is working it might explain the spec issue I and BadAlgorithm see on github#2019-12-0712:36royalaidThe var is defined here, in react.js#2019-12-0712:37royalaidand then is referred here in app-root.js but is somehow undefined#2019-12-0712:59royalaidyeah for some strange reason the code that should be setting up the start of the $cljs$spec$alpha$$ object just gives back#2019-12-0713:00royalaidThis is just after evaluating the above var#2019-12-0713:01royalaid#2019-12-0713:02royalaidShould it just be an empty object?#2019-12-0713:03thhellerit shouldn't exist at all ... nothing should be referencing that?#2019-12-0713:03thhellerit exists because of this https://clojure.atlassian.net/projects/CLJS/issues/CLJS-3055#2019-12-0713:04thhellerdoesn't really matter that it exists though. it shouldn't be used for anything#2019-12-0713:04royalaidgotcha#2019-12-0713:05thhellerdo a quick search for $cljs$spec$alpha$$. that should have zero references#2019-12-0713:05royalaidso then that still leaves the question as to why `
$cljs$spec$alpha$t_cljs$0spec$0alpha35496$$
is just defined and never assigned a value 😕
#2019-12-0713:07thhellerit might have been removed by DCE?#2019-12-0713:08thhellerthose types of vars are usually reify calls#2019-12-0713:12royalaidNvm, I am stumbling around and finding it now#2019-12-0713:12thhellermake sure it isn't moved to the other file though. it is typical for the closure compiler to "forward declare" something and then actually declare it later#2019-12-0713:12royalaid#2019-12-0713:12thhellerright yeah thats a reify call#2019-12-0713:12royalaidhmmmm#2019-12-0713:13royalaidso then this just isn’t called before it is used?#2019-12-0713:13royalaidor at least that could be one reason why?#2019-12-0713:13thhellerno?#2019-12-0713:13thhellerI mean I don't know but I doubt it?#2019-12-0713:14thhellerthis isn't CLJS where you have to define stuff before you use it. so as long as its declared somewhere in the file it won't matter 😛#2019-12-0713:15royalaidStill the vm says its undefined in that second script#2019-12-0713:15royalaidBUT#2019-12-0713:15royalaidwe see the definition in the first one#2019-12-0713:15royalaidand the calls to populate the object#2019-12-0713:16thhellerhow do you load the modules? are you sure its in the correct order? and not using async which would lead to race conditions? you can use defer?#2019-12-0713:17thheller<script src="a.js" async> <script src="b.js" async>? this will load scripts in undefined order (based on whichever loads faster)#2019-12-0713:17awb99Hi! My self hosted clojure that uses shadow cljs broke after upgrading from 2.8.40 to 2.8.80. Now the self hosted engine does not load certain dependencies anymore. Right now it looks like anything that depends on react no longer loads.#2019-12-0713:19thheller@hoertlehner if you use deps.edn/project.clj I'm gonna guess its a closure-compiler/closure-library dependency conflict#2019-12-0713:19awb99No#2019-12-0713:20awb99Only package json and shadow edn#2019-12-0713:20thhellerand what is the error?#2019-12-0713:20awb99At least to generate the bundles#2019-12-0713:20royalaiddefer isn’t an option as the init script for the app depends on the modules under it#2019-12-0713:20awb99It cannot load libraries#2019-12-0713:21thhellerdon't know what that means#2019-12-0713:22awb99Module not provided : 0#2019-12-0713:22awb99Module not provided : 5#2019-12-0713:22awb99This is in the browser console#2019-12-0713:22thhellerok that means that the generated code is not loaded#2019-12-0713:23thhelleryou can set :js-options {:minimize-require false} if you want to know what those numbers stand for#2019-12-0713:24awb99#2019-12-0713:24awb99Ahhh#2019-12-0713:24awb99Good trick#2019-12-0713:24awb99I solved it by usinf silver searcher#2019-12-0713:24thhellerit doesn't change anything. it just gives you the long module name instead of a number#2019-12-0713:24awb99To find the requires#2019-12-0713:25thhellerbut yeah those files you found there weren't loaded#2019-12-0713:25awb99Being able to see names and not numbers is already helpful#2019-12-0713:26thhellerI can only repeat what I warned about many times before .. this stuff isn't built for what you are trying to use it for 😛#2019-12-0713:26awb99As I see it this files have been generated and are being served in tbe web server#2019-12-0713:26thhellerthen check shadow$provide in the browser console#2019-12-0713:27thhellerit should have a 0 entry then#2019-12-0713:28awb99Shadow.provide[0]?#2019-12-0713:29thhellerno. shadow$provide. you have the code right there 😛#2019-12-0713:30awb99#2019-12-0713:31thhellerif its empty then EITHER it has not been loaded yet or used already#2019-12-0713:32thhellerif it has been used it is in shadow.js.files#2019-12-0713:33awb99#2019-12-0713:33awb99So it has been used then#2019-12-0713:33thhellerdo you mix bootstrap builds? there should either be numbers only or strings only#2019-12-0713:33thhellernot both#2019-12-0713:34thhellerand again ... mixing bootstrap builds is not possible, they will clash.#2019-12-0713:34awb99No#2019-12-0713:35thhellerthen I don't know what you are doing 😛#2019-12-0713:35thhellergotta go buy some food. bbl.#2019-12-0714:39dotemacsHello, I heard about shadow.cljs and slep on it for the longest time. Started using it recently and I’m just so happy with it, that I’m ranting and raving to everybody who’ll listen about how good it is! Thank you Thomas (& contributors) for such a great tool. One thing that I’ve stumbled upon, which now I can’t find a link to, is a discussion that was had here on Slack at some point in the past, when used with react-native project, with Android simulator, the REPL connection just goes stale. The advice here was to run repl-runtime-clear. My question is: what is the recommended way to do it? Bellow I’ll describe my setup and the approach, in some very obvious details, just in case. I use the REPL via CIDER with nREPL. In my shadow-cljs.edn I have a following setup:
...
 :nrepl {:port 3333}

 :builds
 {:app
  {:target :react-native
   :init-fn 
   :output-dir "react-native/app"
   :js-options {:js-package-dirs ["react-native/node_modules"]}
   :devtools {:repl-init-ns 
...
Once I start the REPL I specify shadow as the REPL type and :app as the build. This starts the REPL and starts the build, which once complete goes in the above specified ns . When the REPL goes stale, where I can’t even eval something like '2, I then do:
> :repl/quit
user> (require '[shadow.cljs.devtools.api])
user> (shadow.cljs.devtools.api/repl-runtime-clear)
user> (shadow.cljs.devtools.api/repl :app)
cljs.user>
At this point, I’ve recovered the REPL and can plough on as expected. Is this the recommended flow to clear the stale REPL session? If the answer is yes, what’s the way to create aliases that can be picked up, so that I don’t have to manually type up the full (require '[shadow.cljs.devtools.api])? Say like in leiningen projects where you can create dev/user.clj file where you can have the desired requires. And another, minor thing, once I’ve done the above, the ns I’m in, as shown by the prompt is cljs.user. But as soon as I enter something at the REPL, then the prompt changes to what I’ve set in my :devtools {:repl-init-ns config. Is there a config that I could set so that the REPL prompt can be updated automagically? Thanks
#2019-12-0715:43thheller@dotemacs I wish that repl-runtime-clear wasn't necessary at all but I haven't found a good way to solve that problem yet. your workflow seems fine. you can create a user.clj if you want.#2019-12-0715:43thhellerthe REPL showing the wrong ns is your editor. can't do much about that.#2019-12-0717:24dotemacs@thheller oh please don’t take it as criticism, I’m very grateful for your work on shadow.cljs! About adding of user.clj what is the recommended convention: • apart from having src under :source-paths , would you create something like dev/user.clj ? • or would you just put user.clj under src directory? • or is there some other way? What is the “shadow” way of doing it?#2019-12-0717:25thhellerthat has nothing to do with shadow-cljs really. its clojure doing this. I personally do not like using user.clj since that is always loaded unconditionally.#2019-12-0717:25thhelleryou can put it under src or dev (as long as thats in :source-paths too) it really doesn't matter#2019-12-0717:26thhellerit becomes relevant if you want to publish libraries#2019-12-0717:26thhellerthen you don't want to include your user.clj so I guess it is useful to stick with using dev#2019-12-0717:35dotemacsGot it, thanks for the explanation @thheller 👍#2019-12-0718:24jcbHi all, it seems that a few people using latest luminus template including shadow-cljs are having a weird issue compiling a jar - IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError . I'm unsure how to proceed. Thanks!#2019-12-0718:32thheller@jcb that happens when an incompatible closure-compiler version is used. most likely via some dependency conflict. should be these versions
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2019-12-0718:39jcbthank you!#2019-12-0719:03jcbSorry, I realise that I'm asking questions about something that you didn't write, but, that stepped me forward but that's opened up a number of other build issues -#2019-12-0719:03jcb------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- nil Closure compilation failed with 62 errors --- goog/array/array.js:42 The result of a goog.define call must be assigned as an isolated statement. --- goog/array/array.js:50 The result of a goog.define call must be assigned as an isolated statement. --- goog/asserts/asserts.js:50 The result of a goog.define call must be assigned as an isolated statement. --- goog/async/run.js:26 The result of a goog.define call must be assigned as an isolated statement. --- goog/async/workqueue.js:43 The result of a goog.define call must be assigned as an isolated statement. --- remaining errors ommitted ...#2019-12-0719:10thhellerthats likely still a version conflict on closure-library this time#2019-12-0719:15jcboh, I see. I still get the transit issues. but the rest have gone. Thanks again!#2019-12-0719:16thhelleryeah the transit stuff is annoying but can't do anything about that#2019-12-0719:16thhellersafe to ignore
#2019-12-0719:17jcblovely, thanks#2019-12-0811:17dabrazheWhich of these references to shadow do I really need ? And what about the versions, should they always be the same and how to keep track? project.clj
:dependencies
[[thheller/shadow-cljs "2.8.59"]]
..
#2019-12-0811:18dabrazhepackage.json
"devDependencies": {
  "shadow-cljs": "^2.8.53", ...}
#2019-12-0811:19thhellerideally they should be in sync. if you don't actually use the shadow-cljs command line then just project.clj is fine.#2019-12-0811:20dabrazheI am using shadow-cljs to start /stop the servers and release the app )#2019-12-0811:21thhellerthen its best to keep them in sync just in case something from the command line changes#2019-12-0811:21thhellerit does so rarely but it can happen#2019-12-0811:22thhellerideally don't use project.clj 😉#2019-12-0811:23dabrazheI am using project.clj because of Cursive, i 've understood it's needed for dependencies#2019-12-0811:23thhelleruse shadow-cljs pom and import the generated pom.xml in Cursive to create the project#2019-12-0811:23thhellerrun shadow-cljs pom again to update later, Cursive will pick up the changes automatically#2019-12-0811:26dabrazhealright, thank you. I also noticed that shadow version has somehow changed to node: v13.2.0 My project is at node 10.x , it won't clash, will it?#2019-12-0811:32thhellerno, that makes no difference in compile output#2019-12-0811:45dabrazheon another topic: can I safely manualy delete the target, node_modules folders ? I keep carrying some old libraries I am not using anymore..#2019-12-0811:50thhellertarget yes, if you have a package-lock.json or yarn.lock (if you use yarn) then you can delete node_modules "safely"#2019-12-0811:50thhellerotherwise you may end up with a completely different node_modules folder#2019-12-0811:53dabrazheI was thinking to delete the folders and run yarn again to rebuild them#2019-12-0811:54thhelleryes, but without a yarn.lock file the result of rebuilding them can be quite different#2019-12-0812:04dabrazheIsn't yarn is taking all the relevant dependencies form package.json and installs them anew?#2019-12-0812:05thhellerread up on non-determinism regarding npm/yarn. eg. https://yarnpkg.com/blog/2017/05/31/determinism/#2019-12-0812:06thhellerit has greatly improved over time but it still isn't anywhere near deterministic#2019-12-0812:06thhellerall of npm uses version ranges. so you might have had version 1.5 or something and get 1.8 after a new install#2019-12-0812:06thhellerand since they aren't good with breaking changes either that may have broken everything#2019-12-0812:06thhellerin short: keep a lock file and commit it to git#2019-12-0812:19dabrazhethanks, the javascript ecosystem is still quite a mystery to me : )#2019-12-0812:21thhellerit is to everyone 😉#2019-12-0902:53gordonkHi hopefully someone can help me out. I'm experimenting with shadow-cljs potentially to replace boot. I run shadow-cljs watch app (where app is browser target) . I receive the following errors
The required namespace "cljsjs.material-ui" is not available, it was required by "cljs_react_material_ui/core.cljs"
The required namespace "cljsjs.material-ui-svg-icons" is not available, it was required by "cljs_react_material_ui/icons.cljs"
I create the following cljsjs stubs.
(ns cljsjs.material-ui
  (:require ["material-ui" :as material-ui]))
and
(ns cljsjs.material-ui-svg-icons
  (:require ["material-ui-icons" :as material-ui-svg-icons]))
The build now completes successfully. I open up the app and see the following errors in the developer console.
failed to load cljs_react_material_ui.reagent.js ReferenceError: MaterialUI is not defined

failed to load cljs_react_material_ui.icons.js ReferenceError: MaterialUISvgIcons is not defined
I add the following symbols
(js/goog.exportSymbol "MaterialUISvgIcons" material-ui-svg-icons)

(js/goog.exportSymbol "MaterialUI" material-ui)
to their respective stubs, The result is that the MaterialUISvgIcons error disappears in the console but the MaterialUI error does not. Which I find confusing.
#2019-12-0910:12mhuebert@gordonk one thing you might try is material-ui/default#2019-12-0910:50thheller@gordonk see https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2019-12-0915:38superstructorTrying to re-use .shadow-cljs compiler cache between CI builds and found that e.g. 1. rm -rf .shadow-cljs && lein shadow compile karma-test ~10-14s compile 2. lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 1.) 3. Tar up and extract the .shadow-cljs dir results in 10-14s compile again!
tar -cz -f cache.tgz -C .shadow-cljs . 
 rm -rf .shadow-cljs
 mkdir .shadow-cljs
 cd .shadow-cljs
 tar zxf ../cache.tgz
 cd ..
 lein shadow compile karma-test
4. lein shadow compile karma-test ~1s compile (i.e. the .shadow-cljs dir left as-is from 3.) What am I missing that is invalidating the cache ? The tar command used is what GitHub Actions cache action uses to cache files. This would speed up e.g. re-frame CI and all our internal builds by about 30%. @thheller
#2019-12-0916:15thheller@superstructor everything related to the source files invalidates the cache. so you also need to "cache" your .m2 maven downloads so that they don't change and also your JS deps in node_modules in case you use any#2019-12-0916:16thhellerand changing the timestamps of any of your actual source files too of course#2019-12-0916:34Filipe Silvaso any git clone busts it#2019-12-0916:35Filipe Silvamaybe <https://stackoverflow.com/a/55609950/2116927> would help?#2019-12-0916:43Filipe Silvathe repro above didn't actually use git clone though, I was just overall thinking of how I tried to do the same with GH actions...#2019-12-0916:44Filipe Silvabut if git clone will bust the cache for commited source files, and tar will bust the cache for uncommited source files#2019-12-0916:44Filipe Silvathen I guess the shadow-cljs cache doesn't do much good in CI?#2019-12-0917:21thhellerthe timestamps of the cache files themselves don't matter#2019-12-0917:23thhellerjust having cache for maven based files should already speed things up substantially and that should be easy to do#2019-12-0917:34Hiwhy these examples launches with shadow-cljs but lacks repl? https://github.com/day8/re-frame/blob/master/docs/CodeWalkthrough.md#2019-12-0917:55Filipe Silva@thheller in the example above, step 3 and 4, it looked like something during the processed of tarring and untarring the shadow-cljs cache busted it#2019-12-0918:19superstructorCorrect simply tarring the .shadow-cljs cache files dir, deleting it, then untarring it invalidates the cache. No git, .m2 or source file changes. Is that expected ? @thheller#2019-12-0918:24superstructor@feikas sorry its not well documented but lein shadow supports any command shown by lein run -m shadow.cljs.devtools.cli --help e.g. lein do clean, shadow cljs-repl client#2019-12-0918:27superstructorIn fact, when I get time I should do a PR to lein-shadow to call shadow.cljs.devtools.cli help directly. At the moment the output of lein shadow --help is not entirely helpful.#2019-12-0920:43thheller@superstructor @filipematossilva maybe don't try to tar the entire .shadow-cljs dir. just do .shadow-cljs/builds#2019-12-0920:43thhellermaybe lein shadow does something? haven't checked what that does#2019-12-0921:07Aleedif we're using shadow with react native, is there a way to target different platforms - i.e. in js you'd have to have separate file extensions like ios.js , but was hoping maybe we could use reader conditionals like we do for :clj and :cljs#2019-12-0921:08lilactownshadow-cljs has support for custom reader conditionals#2019-12-0921:08lilactownit does require you to have separate builds per platform, though#2019-12-0921:09lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2019-12-0921:13Aleedwonderful, thanks for the link#2019-12-0921:53Aleedanyone able to run expo web with shadow-cljs? I'm following starter template online (https://github.com/PEZ/rn-rf-shadow) but getting a goog.globalEval not available error when I open browser window. opened up issue there, too: https://github.com/PEZ/rn-rf-shadow/issues/11#2019-12-0921:54thheller@alidcastano that issue is fixed in 2.8.81#2019-12-0922:27Aleed@thheller upgraded to that version but still seeing same error#2019-12-0922:28thhellerdid you upgrade the npm package or this https://github.com/PEZ/rn-rf-shadow/blob/master/deps.edn#L7?#2019-12-0922:28thhellerneed to upgrade the deps.edn, the npm package doesn't matter too much#2019-12-0922:29Aleedyea i had upgraded the npm package 😅 thanks#2019-12-1004:27Aleedwhat's the clj/cljs way of linking a dependency so you can use the local version rather than remote one? I know I can reference a dependency by local path but is there a way to do it without changing code?#2019-12-1007:03Shuai LinOne possible way is, in src/main of your project, create a symlink to the src directory of the local dep, e.g. src/main/foo where foo is a link to ~/dev/foo-project/src/foo#2019-12-1007:04Shuai LinOr if you use emacs, you can simply link a buffer of the local dep project to the cider session of your own project, so you can modify the source of the local dep project, and eval it in your repl#2019-12-1014:17bbssanother way if you use deps.edn is :local/root
{:paths ["src" "resources"]
 :deps {com.fulcrologic/fulcro {#_#_:mvn/version "3.0.3"
        ....                        :local/root "/Users/me/fulcro"}
        lilactown/hx {:mvn/version "0.5.3"}}}
#2019-12-1004:28Aleed(the js equivalent would be yarn link)#2019-12-1015:48conanHi everybody, I'm trying to get css reloading working, but I just can't figure it out. I'm not using the built-in web server, my app contains a web server that serves static assets. I've set my :watch-dir to "resources/public", which is the root that the web server serves from; still no changes are ever pushed (i see them when i reload the page). My css lives at resources/public/css/compiled, and is linked in the HTML as <link rel="stylesheet" href="/css/compiled/cue.css?cache-buster=<cache-buster>" />. What am I doing wrong?#2019-12-1015:48conanHi everybody, I'm trying to get css reloading working, but I just can't figure it out. I'm not using the built-in web server, my app contains a web server that serves static assets. I've set my :watch-dir to "resources/public", which is the root that the web server serves from; still no changes are ever pushed (i see them when i reload the page). My css lives at resources/public/css/compiled, and is linked in the HTML as <link rel="stylesheet" href="/css/compiled/cue.css?cache-buster=<cache-buster>" />. What am I doing wrong?#2019-12-1016:58conanmaybe there's something i need to run as part of the command i use to kick off shadow-cljs? at the moment i run npx shadow-cljs watch app#2019-12-1017:49thhellerit looks fine to me. maybe try without ?cache-buster? your webserver just may be caching to aggressively too and only serving the "old" content when another request is made?#2019-12-1017:49thhelleror maybe you configured something in the wrong place?#2019-12-1017:49thhellerkinda hard to tell without seeing your config#2019-12-1017:51thhellerit all looks correct from what you described#2019-12-1017:52conanyeah i thought it might be the cache-buster but that doesn't make a difference#2019-12-1017:53conanhere's my config
{:lein {:profile "+dev"}
 :builds
 {:app {:target :browser
        :output-dir "resources/public/js/compiled/"
        :asset-path "/js/compiled"
        :compiler-options {:infer-externs :auto}
        :dev {:compiler-options {:closure-defines
                                 {"day8.re_frame.tracing.trace_enabled_QMARK_" true
                                  "re_frame.trace.trace_enabled_QMARK_" true}}
              :devtools {:preloads [day8.re-frame-10x.preload]
                         :after-load user/after-load
                         :watch-dir "resources/public"}
              :external-config {:devtools/config {:features-to-install :all}}
              :pretty-print true
              :print-input-delimiter true
              :source-map true}
        :release {:compiler-options {:closure-defines {goog.DEBUG false}
                                     :optimizations :advanced}}
        :main cue.core
        :modules {:cue {:entries [cue.core]}}}}}
#2019-12-1017:53conansorry trying to make it more legible#2019-12-1017:54thheller:external-config needs to be in :compiler-options otherwise it has no effect#2019-12-1017:54thhellerpretty-print and source-map default to true and would other also need to be in :compiler-options#2019-12-1017:55conanoh cool thanks#2019-12-1017:55thheller:main cue.core does nothing#2019-12-1017:55thhellerother than that it looks fine#2019-12-1017:56conanyeah i don't think i've gone crazy here. ok could it be the way i run shadow, which is with this?
(require
  '[orchestra.spec.test :as stest]
  '[shadow.cljs.devtools.api :as api]
  '[shadow.cljs.devtools.server :as server])
(server/start!)
(api/watch :app)
(api/repl :app)
(stest/instrument)
#2019-12-1017:56conando i need to run something else to kick off the file watcher?#2019-12-1017:56thhellernope thats it#2019-12-1017:57thhellerdid you check the browser console/devtools? does it try to request css?#2019-12-1017:59thhelleryou can also set :log {:level :debug} in shadow-cljs.edn top level#2019-12-1018:00thhellerthat will log a bunch of extra stuff, including changed css files it found#2019-12-1018:04conani'll try that. no, i'm seeing nothing about css in the console, i'm pretty sure it's not watching for changes#2019-12-1018:05conanno, there's no output on css compilation#2019-12-1018:05thhellerit is independent and has nothing to do with CLJS compilation#2019-12-1018:06conanyeah that makes sense, i wouldn't expect the two to be connected#2019-12-1018:06conanalthough presumably there's some shared infra to push changes#2019-12-1018:07thhellerhmm nevermind I just checked. must have removed the log messages#2019-12-1018:07thhellerI don't get any either. css reload works though#2019-12-1018:09conanam i right to have "resources/public" as the value for my :watch-dir when my css lives at resources/public/css/compiled?#2019-12-1018:09conanand is served from /css/compiled/cue.css#2019-12-1018:14thhellerbasically you take watch-dir and append the path of the css#2019-12-1018:14thhellerthat should be the path in your filesystem#2019-12-1018:15thhellerso resources/public + /css/compiled/cue.css#2019-12-1018:15conanyeah makes sense.#2019-12-1018:16conanmy css compilation occurs in WSL, but shadow-cljs is runnign in windows. it's all on a windows filesystem though. could there be a problem with watching files on a windows filesystem?#2019-12-1018:16conanactually i can test that by editing, and no, that isn't the problem#2019-12-1018:17conanwell, thanks for your help. the only way forward i can see is to stop using my webserver and pass my handler to shadow-cljs and see if i can get that working. much appreciated as ever!#2019-12-1018:18thhellerthe webserver isn't even involved in this so it should be working fine. I know its working for others too#2019-12-1018:19thhellerbut you never answered my question about what the browser devtools show?#2019-12-1018:19thhellerI mean the request panel? does it do something?#2019-12-1018:19thhelleryou can also check if the websocket is receiving messages#2019-12-1018:20conanno, there are no requests#2019-12-1018:20thhellershould see messages like this one {:type :asset-watch, :updates #{"/css/foo.css"}}#2019-12-1018:20conanoh yeah let me check that#2019-12-1018:21conanno, i'm seeing only repl ping/pong#2019-12-1018:21thhellerother than that I don't really know. I'm on windows too so that shouldn't be an issue#2019-12-1018:25conansame deal running from a terminal inside wsl, so it's something to do with my project and not my environment#2019-12-1018:30conanoh. i read in the docs that :watch-dir was only needed for non-webserver setups, but your comment about the webserver not being involved makes me wonder whether i misunderstood?#2019-12-1018:31thhellerif you configure the built-in webserver it just implicitly also sets :watch-dir#2019-12-1018:31thhellernothing else to it#2019-12-1018:31thhellerif you reproduce this in a simple project I can take a look#2019-12-1018:32thhellerit is working fine for me so kinda hard to guess what might be going on for you#2019-12-1018:36conanyeah sure, ta#2019-12-1114:21conanI've stripped it down and have a small repro https://github.com/conan/css-reload#2019-12-1114:30conansame deal. tested using cursive and the command line, in windows, wsl and on mac. i'd be super grateful if you had time to cast an eye, but obviously only if you're curious.#2019-12-1116:08thhellerI rewrote the config to be
{:source-paths ["src/cljs"] 
 :dependencies
 [[reagent/reagent "0.8.1"]]
 :builds
 {:app {:target :browser
        :output-dir "resources/public/js/compiled/"
        :asset-path "/js/compiled"
        :compiler-options {:infer-externs :auto
                           :external-config {:devtools/config {:features-to-install :all}}}
        :devtools {:after-load user/after-load
                   :watch-dir "resources/public"}
        :modules {:css-reload {:entries [css-reload.core]}}}}}
#2019-12-1116:09thhellercss reload works fine after doing that#2019-12-1116:09thhellerI have no clue why it doesn't work when running through lein#2019-12-1116:09thhellerI don't have time right now to figure out why ... there are many things wrong with the config though#2019-12-1116:10thhellercore.async version is too old#2019-12-1116:10thhellercljs version is too old#2019-12-1116:10thhellerso I'm blaming some kind of dependency conflict on this#2019-12-1118:03conanAmazing thanks!#2019-12-1016:06Drew VerleeI'm trying to do some more code splitting on my project. I looked at the build report > main (default module> project files and picked a namespace that i dont believe needs to be loaded with the initial/default/main module. That is, i assume the namespace in question is shared by two modules which means its pushed into the default/main module. So if i make the shared namespace its own module then explicitly declear it a dep of the other ones, it wont be loaded with the main module: Before MainModule -> ns1 After MainModule -> XModule -> ZModule (ns1) YModule -> ZModule (ns1) I attempted to do just that, Then, when i try to build a report (or a build) I get an exception and then this message: Module Entry <Module Name> was moved out of module <Module Name> It was moved to <Module Name 2> and used by <some set of modules> I'm not sure what this is telling me. My intent was to create a new module (the <Module Name> from the msg above) so the message seems to be telling me that my it shouldnt create the new module because it was used by the other set of modules. Specifically, in that set of modules it lists the main module. Which from checking the dependencies isnt true. as in, main doesn't seem to depend on that module in any way.#2019-12-1016:47thheller@drewverlee that error is telling you that an entry-ns (so either :entries or :init-fn) specified for one module was moved out#2019-12-1016:48thhellerthe reasons for moving are most likely your :require setups somehow#2019-12-1019:01Drew VerleeThanks. So say i just have a small app with 3 namespaces: main, a, b. main requires a and b. So in shadow-cljs.end the setup would just be:
:modules 
{:main {:init-fn some.app.main/-main}
 :a {:entries [some.app.a} :depends-on #{:main}}
:b {:entries [some.app.a} :depends-on #{:main}}}
What would be an example of a something that would cause this error? Your implying something could be wrong with the requires? but i can't imagine what that could be. The app worked before the modules were added so in what scenario would it not work after modifying the shadow-cljs config to add modules.
#2019-12-1020:36thhellersome.app.main cannot require some.app.a or b directly#2019-12-1020:36thhellerand some.app.a cannot require some.app.b directly#2019-12-1020:36thhellerneither can b require a#2019-12-1020:36thhellerthats pretty much it#2019-12-1020:57Drew Verleesome.app.main cannot require some.app.a or b directly Concretely, you mean you cannot have: (ns some.app.main (:require [some.app.a :as a]) ? You have to use the lazy load functionality?#2019-12-1021:06thhelleryes#2019-12-1016:48thhelleralso make sure you set :depends-on correctly#2019-12-1017:31lilactownI have a JS file I’m including a CLJS lib that does this: import * as React from "react"; I tried to use import React from "react" at first, but I get an error when I execute the code from a REPL that React is undefined. Using the glob syntax fixed this. However, now a user has reported that trying to use it in React Native they receive this error:
--- helix/impl/class.js:1
Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import React from 'goog:shadow.js.shim.module$react';?
#2019-12-1017:32lilactownlink to issue: https://github.com/Lokeh/helix/issues/1 link to JS code: https://github.com/Lokeh/helix/blob/master/src/helix/impl/class.js#2019-12-1017:32thhellerfun right?#2019-12-1017:33thhellerdunno what to do ...#2019-12-1017:34lilactownis the ES6 code processed differently in browser vs RN?#2019-12-1017:34thhellerESM-CJS interop sucks big time#2019-12-1017:34lilactownI’m happy to do something hacky for now#2019-12-1017:36thhellerthe issue is the ["react" :as react] is equiv of import * as react ...#2019-12-1017:36thhellerso changing it to make import React work would break the CLJS parts too#2019-12-1017:36lilactownhrm yikes#2019-12-1017:37lilactownjust to confirm though, import * as React should work in e.g. browsers right?#2019-12-1017:37thhellerand what makes things worse it that this is an "upcoming" default ... meaning that most libraries have not adopted this yet#2019-12-1017:37lilactownit’s only when doing CJS interop w/ RN?#2019-12-1017:37thhellerso they would break too because they still expect import {createElement} from "react" or whatever to work#2019-12-1017:38thhellerin the browser I can sort of control it better#2019-12-1017:39thhellerbut RN builds the JS parts so I kinda can't do much#2019-12-1017:39thhelleror rather I dunno how to tell the closure compiler to "accept" this#2019-12-1017:39lilactownso is it RN that is complaining about the glob syntax, or shadow-cljs, or closure?#2019-12-1017:39thhellerdon't think its even possible#2019-12-1017:39thhellerclosure complaining about what shadow-cljs gives it I guess#2019-12-1017:40thhellerI honestly don't know why it works one way but not the other#2019-12-1017:40lilactownI wonder if it’s because I’m running it from a REPL#2019-12-1017:40lilactownlet me actually build some code with it#2019-12-1017:41thhelleryou can use commonjs that is less problematic#2019-12-1017:41thhellerbut .. no advanced for those parts anymore then#2019-12-1017:43lilactownhmm yeah, it compiles fine in my browser build. at least in dev mode#2019-12-1017:45lilactownthis is ~34 lines of code so I don’t think missing out on advanced compilation will be a big deal#2019-12-1017:45lilactownI also doubt it will be used super often, as it’s only used to construct a React class which is only necessary when using error boundaries#2019-12-1017:46lilactownso as long as it doesn’t “infect” other code too much with it’s lack of optimizations I am fine with switching to CJS#2019-12-1017:46thhellercommonjs has other issues though ... it just sucks all around to be honest#2019-12-1017:46thhellerI don't like the situation but I don't know what to do#2019-12-1017:46lilactownyeah 😞#2019-12-1017:47thhellerthe way it works now has the "highest" compatibility with most packages#2019-12-1017:47thhellerif I change something like 50% of them break#2019-12-1017:47thhellerit'll be better when webpack v5 comes out and people adopt (since it will also break there)#2019-12-1017:47lilactownwell this seems to only be a problem when using npm packages inside of a JS file on the classpath#2019-12-1017:47thhellerbut dunno how long that'll be and don't know what fun kind of changes the closure compiler throws into the mix until then#2019-12-1017:50lilactownit’s a shit show for sure 😞#2019-12-1019:46Aleed@U05224H0W can you maybe transpile it differently and output it to different file extensions, i.e. native.js versus web.js#2019-12-1019:48Aleedso is the syntax that is meant to work is this import * as react so that you can do this ["react" :as react] but react native isn't recognizing that syntax since it transpiles the JS itself (yet it has to be this way in es6 for the cljs import statement to work)#2019-12-1019:48Aleeddid I understand that correctly?#2019-12-1019:58Aleedtried to test this out in helix but doesn't look like shadow-cljs recognizes the different platform extensions. in either case, maybe that could be a solution since react native will look for .native.js before .js#2019-12-1020:49thheller@lilactown actually what I'd suggest is not importing react at all in the .js file#2019-12-1020:49thhelleryou are just exporting a function anyways#2019-12-1020:49thhellerso just pass Component as the first arg in the function#2019-12-1020:53lilactownah good idea#2019-12-1019:10Drew VerleeIs there anything written about how shadow is doing the code splitting under the hood? I orginal through it was using webpack but i'm not sure and one of the tutorials implies its not.#2019-12-1019:40Aleed@U05224H0W has an article on code splitting cljs, maybe it's what you're looking for https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2019-12-1019:41Aleed(ah I see it was linked in thread, nvm)#2019-12-1019:13lilactownit uses the google closure compiler#2019-12-1019:13lilactownhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2019-12-1022:02Thomas LisankieHi all, I'm trying to use shadow-cljs in a project and it seems to be getting stuck when I try to "watch" my app. Here's what happens (<https://gist.github.com/TomLisankie/eb7cedb746fd18b53393ae7e197ee928>) when I run shadow-cljs watch app from within my project directory and here's the shadow-cljs.edn (<https://gist.github.com/TomLisankie/ed0c3ab4e83c14aaf0bdf48b18594d47>). I thought it was just taking a really long time to start or something, but then I tried the same command in a different shadow-cljs project and it was pretty quick. I'm guessing it's something wrong with my configuration, but I can't seem to figure out what. Any help would be much appreciated.#2019-12-1022:08lilactown@thomas745 I don’t see anything wrong with that output#2019-12-1022:08lilactownwhat are you expecting to happen vs. what is happening?#2019-12-1022:11thheller@thomas745 shadow-cljs does not operate like figwheel. so if you are waiting for a REPL to show up that will never happen. instead you run shadow-cljs cljs-repl app separately to get your REPL when needed. the watch is independent of that#2019-12-1022:17Thomas Lisankie@lilactown I'm expecting my app to show up when I go to the localhost URL provided like it does with figwheel but instead I just get a shadow-cljs dashboard with a list of active builds. It also has a listing for active HTTP servers but there aren't any running I'm guessing since none are being listed#2019-12-1022:18lilactownah, you need to configure a dev HTTP server I believe.#2019-12-1022:18lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2019-12-1022:26Thomas Lisankie@lilactown That works. Thanks a lot!#2019-12-1105:03wisemanis there a way to specify a git dependency in shadow-cljs.edn ?#2019-12-1106:07Saikyun@wiseman maybe not the answer you want, but you can do it through deps.edn 🙂 https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2019-12-1106:33wisemanok, thanks, @saikyun#2019-12-1107:44Saikyunhappy to help 🙂#2019-12-1109:05deasAlmost x-mas, right? 🎄 😉 ...#2019-12-1109:13deasI am using cursive on a clj + cljs (+shadow-cljs) based project and I am aiming at a convenient way to get both repls up and jacked in - like running lein repl, just connecting to a single port and throwing clj/cljs forms from the editor against that single nrepl service. I may be missing something, but I am really having a hard time getting there (ugly :init-nsor even bypassing lein repland using lein run instead). How would you guys be doing this?#2019-12-1109:47thhellerCursive doesn't allow that if I understand you correctly#2019-12-1109:48thhellereach connection can only be in one state CLJ or CLJS not both#2019-12-1109:48thhellerso you'd have a secondary connection#2019-12-1109:48cfleming(which is something I’m planning to fix, but have not got to yet).#2019-12-1109:48thhellerwhich you can't start from purely clojure#2019-12-1110:26deas@cfleming IIRC - I had things working over a single repl session (with figwheel). Just had to switch the clj/cljs dropdown switch from time to time.#2019-12-1110:33deasThe issue with lein repl was that I found no way to get everything up without a manual step in between (launching shadow/watch). Hence, I stepped back from running lein repland started fiddling with lein run . However, I guess putting it all together may do the trick but still appears painful.#2019-12-1114:36conanDon't know if it helps, but I run one repl for backend and one for shadow. to keep things fast, i set up a clojure.main run configuration in cursive and put the path to a file containing this in the parameters:
(require
  '[shadow.cljs.devtools.api :as api]
  '[shadow.cljs.devtools.server :as server])
(server/start!)
(api/watch :app)
(api/repl :app)
That kicks off the shadow compilation right there in the repl, and means i can restart shadow with a single click.
#2019-12-1114:36conanseems like it might be possible to kick off your backend in that same script file as well? i don't think you'd be able to access its clj repl though#2019-12-1112:31SchpaaWhat does this error hint at? The result of a goog.define call must be assigned as an isolated statement. Only getting it at release build#2019-12-1112:31thheller@schpaencoder bad closure-library version on the classpath that is incompatible with the shadow-cljs version you are using#2019-12-1112:32thhellershould be these
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2019-12-1112:33Schpaa@thheller, oh, you mean the globally installed is in conflict with the project specific#2019-12-1112:34thhellerdunno you should only be getting this error when using project.clj or deps.edn to manage dependencies?#2019-12-1112:34thhellershadow-cljs itself should never have this conflict when using only shadow-cljs.edn?#2019-12-1112:34SchpaaI’m using the lein-shadow plugin#2019-12-1112:34thhellerthose are dependencies you wouldn't normally specify but somehow you are getting different versions#2019-12-1112:34thhellercheck lein deps :tree#2019-12-1112:35thhellerit'll tell you about conflicts#2019-12-1112:38SchpaaGot a ton of recommened exclusions, not sure what I am doing now#2019-12-1112:39SchpaaThe first one was [org.clojure/clojurescript “1.10.520”]#2019-12-1112:41Schpaaokay, I think I’ll dabble with this first, thanks for the input#2019-12-1112:50Schpaaodd, the error prevailes#2019-12-1112:50Schpaa
"user-namespace was evaluated"
[:fb] Compiling ...
Closure compilation failed with 18 errors
--- goog/array/array.js:42
The result of a goog.define call must be assigned as an isolated statement.
--- goog/array/array.js:50
The result of a goog.define call must be assigned as an isolated statement.
--- goog/asserts/asserts.js:48
The result of a goog.define call must be assigned as an isolated statement.
--- goog/base.js:213
The result of a goog.define call must be assigned as an isolated statement.
--- goog/base.js:236
The result of a goog.define call must be assigned as an isolated statement.
--- remaining errors ommitted ...
#2019-12-1112:53Schpaarelevant section from project.clj:
:builds {;; "firebase integration"
                         :fb {:target           :browser
                              :compiler-options {:infer-externs :auto}
                              :output-dir       "resources/public/fb/js"
                              :asset-path       "/js"
                              :infer-externs :yes
                              :modules          {:fb {:init-fn fb.core/init!
                                                      :entries [fb.core]}}
                              :build-hooks      []
                              :release          {:compiler-options {:optimizations :simple}}
                              :devtools {:http-port 8050
                                         :http-root "resources/public/fb"
                                         :watch-dir "resources/public/fb" :preloads [re-frisk.preload]}
                              :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
#2019-12-1115:25thhellerthat section of project.clj is actually completely irrelevant 😛#2019-12-1115:26thhellerit is only your :dependencies that matter here#2019-12-1115:26thhellersomehow you are getting bad versions of the closure-compiler and/or closure-library#2019-12-1113:31aisamuHi! Should we expect source-maps to work for :npm-module targets? They appear to be almost correctly generated, both for development and release. For development (`compile`), the source-maps aren't taking into account the shimming preamble. Deleting that and inspecting the maps with source-map-visualization[1] works as expected: Here's an example of what I'm calling a preamble:
var $CLJS = require("./cljs_env");
var $jscomp = $CLJS.$jscomp;
require("./cljs.core.js");
var module$shadow_js_shim_module$$material_ui$styles$ThemeProvider=$CLJS.module$shadow_js_shim_module$$material_ui$styles$ThemeProvider || ($CLJS.module$shadow_js_shim_module$$material_ui$styles$ThemeProvider = {});
[...]
var shadow=$CLJS.shadow || ($CLJS.shadow = {});
[...]
var module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded=$CLJS.module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded || ($CLJS.module$shadow_js_shim_module$$material_ui$icons$StarHalfRounded = {});
// empty line
$CLJS.SHADOW_ENV.setLoaded("cljs.namespace.js");
// empty line
Source maps for :browser-test worked out of the box! (I couldn't check release builds - the tool complained about missing sources) [1] - https://sokra.github.io/source-map-visualization/#custom
#2019-12-1115:11tslockeIs it correct that shadow-cljs doesn't have configurable dev and release dependencies, because they're not needed in CLJS? I ask because this library provides two versions, in order to elide logging code in production: https://github.com/philoskim/debux#two-libraries#2019-12-1115:28thheller@tslocke yes that is true and you need to use deps.edn or project.clj for that. unfortunately the debux library was written in a "bad" form that requires switching dependencies when it could have been written in a much "cleaner" style that didn't require that#2019-12-1115:29tslockeOK thanks#2019-12-1115:51thheller@aisamu I don't know about source maps. they are supposed to work BUT it is entirely depending on the tools to use when including that output somewhere else. since they are very likely going to process the JS again they need to take the "input" source maps (generated by shadow-cljs) into account when generating their own source maps for the output they produce#2019-12-1116:53aisamuYup! Those for :browser-test work flawlessly, but those for :npm-modules do not. They're loaded and served correctly (via source-map-loader on webpack) but the mappings are slightly off, and removing the preamble from the JS seems to fix the mapping (but breaks the file, of course) We never brought it up because we were using WP3 at the time, and attributed it to it!#2019-12-1117:13thhellerfeel free to open an issue. I'll try to figure it out when I have a bit of time#2019-12-1117:27aisamuDone! Thanks a lot!#2019-12-1115:51thhellerbut if the source maps generated by shadow-cljs don't match then thats a bug#2019-12-1115:52thhellerit should be accounting for the "preamble" already but maybe thats not accurate anymore#2019-12-1117:16Filipe Silva@thheller it seems like you and @plexus talked about making Kaocha work with shadow-cljs back last january https://github.com/lambdaisland/kaocha-cljs/issues/2#2019-12-1117:17Filipe Silvadid you think more about how it could work?#2019-12-1117:28thhellerI did not no. didn't seem to fit very nicely into the entire system.#2019-12-1121:26Filipe Silvais this something that could work with just the provided shadow-cljs node-repl without any changes to shadow-cljs?#2019-12-1121:27Filipe SilvaI was trying to figure out if it could power Calvas testing commands (e.g. "run this test") for cljs codebases#2019-12-1121:28thhellermaybe? I can't remember any of the details really#2019-12-1117:28thhellercljs.test is also kinda of a sore spot for me since the entire implementation is so needlessly complex ... uses way too many macros when it doesn't have to#2019-12-1117:56gravIf I do a release build while running a watch build, won't they conflict (ie mess up the development process), if I don't have a specific :release {:output-to "... clause in my configuration? (`:target :browser`)#2019-12-1118:15thhellerthey'll overwrite files yes#2019-12-1118:15thhellerbut the watch and release themselves won't interfere with each other during compilation#2019-12-1118:15thhelleronly the final output files#2019-12-1118:41theasp@thheller Is there a way to have builds spit out a native executable using nexe? Obviously I could just run it myself after the build. See https://clojurescript.org/guides/native-executables#2019-12-1118:42Yosevu KilonzoHello! I see a section on https://shadow-cljs.org/ about using shadow.resource for non-code resources. I think this is meant for single files only. What approach would I use to require a directory instead?#2019-12-1118:43thhelleryeah, you run that separately. you can build a hook to do that if you want if needed#2019-12-1118:43thhellerwhat would requiring a directory do?#2019-12-1118:43thhellerbut no its for separate files only#2019-12-1118:44Yosevu KilonzoOk, thanks. Is there a way to get all the files in a directory?#2019-12-1118:45thhellernot built-in no#2019-12-1118:47theasp@thheller build hook looks like what I want, thanks!#2019-12-1118:47Drew VerleeIs it possible to see the output of the final configuration if your using the :config-merge option? Specifically if i run (shadow/release <build-id> {:config-merge [{compiler-options {:optimizations :advanced}]}) I expect the build to use a configuration similar to as if i had a shadow-cljs.edn: {:builds {<build-id> {:release {:compiler-options {:optimizations :advanced}}} It would be nice to be able to easily verfiy i merged correctly.#2019-12-1118:48thhelleryeah thats about it. if you merge something complicated you are probably doing something you shouldn't be doing 😛#2019-12-1118:50Drew VerleeMy hesitation is because its not clear what the entry point of the merge is. The entire shadow-cljs.edn map or are we starting at the release key of the build A) root B) -> <build-id> :release#2019-12-1118:50thhelleryou are starting with the build config, which already has :release or :dev merged#2019-12-1118:51thhellerthen your extra merges are applied#2019-12-1118:53Drew Verleeso (shadow/release <build-id> {:config-merge [{compiler-options {:optimizations :advanced}]})` given a shadow-cljs {:builds {<build-id> {:release {:compiler-options {:optimizations :simple}}}`` would be: {:builds {<build-id> {:release {:compiler-options {:optimizations :advanced}}} ?#2019-12-1118:54thhellerscrap the :builds map that doesn't exist anymore#2019-12-1118:54thhelleryou only have {:build-id <build-id> :release {:compiler-options {:optimizations :simple}}}#2019-12-1118:55thheller:build-id is added automatically (taken from the outer map)#2019-12-1118:55thhellerso after the first step it only remains as {:build-id <build-id> :compiler-options {...}}#2019-12-1118:55thhellerthen config-merge is merged in#2019-12-1118:57thhellerconfig merge is basically always merged last so you can be sure that those values are used#2019-12-1119:50Drew VerleeThanks thheller. You have been a tremendous help. I only hope that i can pay it back at some point 🙂.#2019-12-1120:20Drew VerleeWere observing some unexpected behavior when trying to do some code splitting. This is a different issue then what i asked about yesterday. The questions from yesterday were because i was trying to gather more information about this issue. The issue stated directly is that when we split out a module the client fails to correctly load that module. The specific details of what i'm observing are below. So originally (prior to the app being in a buggy state) we have a shadow-cljs.end that looks like this:
##NOTE "..." just means information we can ignore.
{:modules
  {:main {...}
   :a    {:entries [...] :depends-on #{:main}}
   :b    {:entries [...] :depends-on #{:main}}}
This results in the main module including a namespace (will call it c_ns). The issue is that this namespace is really only a requirement of the a and b namespace (corresponding to the modules we declare above). Its my understanding that if i explicitly create a new module for c_ns then have the other two modules (:a and :b) depend on it. Then the c_ns wont be fetched as part of loading the main module. This is possible because once the modules depend on the namespace explicitly, the Google Closure compiler will know to not put it in the default module (main). Specifically if we make the shadow-cljs file such that its like this:
{:modules
  {:main {...}
   :a    {:entries [...] :depends-on #{:main :c}}
   :b    {:entries [...] :depends-on #{:main :c}
   :c    {:entries [...] :depends-on #{:main}}}
This process seems to work when applied to the first module we tried it on. However, on the second one we tried. It doesn't. In the working version what we see from our network traffic on the browser is. The app loads and we make a GET request for the module we split out. The react components correctly load and everything works as expected. In the version that DOESNT work. The app loads and makes 3 GET requests for the module we split out (possible retries). The react components don't correctly load. Specifically, a component that was loaded as part of react suspense never loads. Its stuck at "suspended = true". This component would correspond to module :a or :b (from above). The components that depend-no the module we are trying to split out. Additionally, This behavior is only observed when we use the compiler optimizations set to Advanced. Which in part is making it difficult for me to understand how to debug the issue, as i'm less sure how to get feedback.
#2019-12-1121:01thheller@drewverlee you are overcomplicating your description a bit and at the same time missing important details 😛#2019-12-1121:01thhellerHOW you do you load modules?#2019-12-1121:01thhellerassuming that your HTML page only includes <script src="/js/main.js"> or whatever path you have?#2019-12-1121:01thhellerthat uses shadow.loader?#2019-12-1217:36Drew Verlee@thheller Yes our HTML page includes <script src="/js/main.js"> For the module that isn't working were not using anything from shadow.loader. We were under the impression that just by declaring the modules in our shadow-cljs.edn file they would be re-organized as part of an optimization by the google closure compiler.#2019-12-1219:19Drew Verlee@thheller https://github.com/thheller/shadow-cljs/blob/2bceed2b6ac3b8cf5cae110d319553394aba8156/src/main/shadow/lazy.cljs#L28 This comment is probably relevent to our situtation. At least to understanding the feedback were getting. What specifically does it mean "when the eval failed"#2019-12-1219:31Drew VerleeIts also probably relevent that we have module-loader set to true#2019-12-1220:14thhellerso you are using shadow.loader. do you have errors during load?#2019-12-1220:14thhellerthey should be logged somewhere?#2019-12-1220:15thhellerthe easiest way to test is just including the modules directly in your html#2019-12-1220:16thhellerso just loading things eagerly. all the async loading stuff just complicates debugging#2019-12-1220:16thhellerif all that loads fine you can try the async stuff but debugging load issues otherwise is pretty painful#2019-12-1220:30Drew VerleeFor the module that is causing an issuue. I have tried both loading using the lazy component macro, which calls shadow lazy load. We also tried it without calling any shadow loader code directly, as we were under the impression that breaking them into modules was sufficient. The might be incorrect. Your suggesting I add logging around the shadow.lazy/load? I'll try including the modules directly in the HTML, thanks!#2019-12-1220:32thhellerjust add the three moduels in the proper order to your html#2019-12-1220:33thhellerif that throws no error during load start testing the async load stuff#2019-12-1220:33thhellerkinda hard to make suggestions since I know so little about what you are actually doign#2019-12-1220:33thhellercode splitting can be tricky for sure#2019-12-1221:14Drew VerleeThanks. We dont have async enabled. I assume that makes it less likely there are issues.#2019-12-1221:54thhellerof course you have async enabled when using shadow.lazy. that is all async#2019-12-1222:01Drew VerleeYes, i see what you mean. I was refering to that we dont have the async attribute enabled in our script tag when we load the main.js file.#2019-12-1222:03thhellerah ok#2019-12-1316:46Drew VerleeSo we added the module that was causing the issue to index.html. @thheller What i see from my dev tools console is: "Uncaught TypeEroor: cannot read property of 'prototype' of undefined." at spec/alpha.cljs:1300 at shadow/module/<offending module>/append.js:2 append.js is just : shadow.loader.set_loaded(); So my interpretation of that is that somehow set_loaded is being called with no arguments? Possible resulting in the above error. Does that seem reasonable?#2019-12-1316:50thhellerset_loaded takes no arguments so not thats not it#2019-12-1316:51thhellerwhich version is this?#2019-12-1316:53Drew Verleeversion "2.8.74"#2019-12-1319:23thhellercan you try with either .83 or .68?#2019-12-1319:36Drew Verleeyep will do.#2019-12-1320:30Drew VerleeI tried with .83 It seemed to have no effect on what happened.
#2019-12-1121:26papachanIs there any quick template with shadow-cljs including react as foreign-libs?#2019-12-1121:27thhellershadow-cljs doesn't even support foreign-libs so no 😛#2019-12-1123:00colinkahnI’m having an issue which I can’t reproduce with a minimal case, but goes away if I change the version of shadow I’m using. It seems unrelated to the build or the compiled files (I’ve removed the compiled files and restarted the build). Question is, is there some cache I can clear out outside of those things?#2019-12-1123:00colinkahnI’m having an issue which I can’t reproduce with a minimal case, but goes away if I change the version of shadow I’m using. It seems unrelated to the build or the compiled files (I’ve removed the compiled files and restarted the build). Question is, is there some cache I can clear out outside of those things?#2019-12-1123:14lilactownwhat is the issue?#2019-12-1123:39colinkahnusing st/instrument for some reason it starts to return an empty vector and stops instrumenting my fdefs#2019-12-1123:45colinkahnI dropped back a version of shadow-cljs and it started working again, but eventually stopped, so I bumped the version and again it worked. Really frustrating as I cannot see why it would stop working.#2019-12-1123:46lilactownthat is strange. it sounds like it might have to do with the build/analyzer caching? Not sure#2019-12-1123:46lilactownthere is another dir, .shadow-cljs, which has a builds dir that has the build cache#2019-12-1123:47lilactownit is typically verboten to remove this as it shouldn’t be necessary, but if clearing that out solves it, it might point us in the right direction to why it’s doing this#2019-12-1123:47lilactownwhat exactly are you instrumenting?#2019-12-1123:48colinkahn@U4YGF4NGM nuking .shadow-cljs made it work again#2019-12-1123:49colinkahnI’m instrumenting functions in some unit tests to stub return values.#2019-12-1123:52colinkahnThem failing seems completely unrelated to the code though, I had removed some changes to see if those had caused it before deleting .shadow-cljs and now have reintroduced it and everything is working fine :man-shrugging:#2019-12-1123:53lilactownSo your tests namespace instrument the functions inside the implementation namespace?#2019-12-1123:55colinkahnIt’s like: impl.cljs <= defn’s impl_specs.cljs <= fdefs impl_test.cljs <= st/instrument#2019-12-1123:56lilactownhmm#2019-12-1123:56lilactownand typically, what kinds of changes cause this to break?#2019-12-1123:57lilactownchanging impl.cljs or impl_specs.cljs or impl_test.cljs?#2019-12-1123:57colinkahncode wise I can’t pin it to anything I’ve done. just working on files, saving, tests autorefresh and run. At some point the tests stop working and I log st/instrument and it’s an empty vector.#2019-12-1200:00colinkahnNow I’m hoping it breaks again so I can inspect things more#2019-12-1200:04colinkahnsomething weird is that sometimes when I call st/instrumentable-syms it’s a set, other times it`s a vector, and when things weren’t working I remember running it and it was a vector with a ton of duplicates of the fdef’ed syms#2019-12-1200:16lilactownhttps://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/spec/test/alpha.cljc#L69 it looks like calls to instrument mutate some global state in the running compiler process, which probably doesn’t play well with the way namespaces are cached while building#2019-12-1200:18lilactownI’m not sure how this works in the vanilla cljs compiler, but I think an issue could be opened to fix this in spec.test#2019-12-1200:25colinkahn@U4YGF4NGM open an issue against ClojureScript itself?#2019-12-1200:23isak> Namespaces that are known to include side-effecting macros can be blocked from caching. They won’t be cached themselves and namespaces requiring them will not be cached as well. The clara-rules library has side-effecting macros and is blocked by default. You can specify which namespaces to block globally via the :cache-blockers configuration. It expects a set of namespace symbols. @colinkahn @lilactown #2019-12-1200:25colinkahnDefinitely trying this, thanks!#2019-12-1200:23isak(from the docs)#2019-12-1201:02colinkahnNot really having luck with :cache-blockers . I have: :cache-blockers #{cljs.spec.test.alpha clojure.spec.test.alpha}#2019-12-1208:18thheller@colinkahn there is already special support in the caching layer regarding specs so this shouldn't be necessary#2019-12-1215:07colinkahn@thheller besides using st/instrument a lot I don't think so. I set up replacement mock fns before each test case, but that doesn't seem like it should cause issues. Since there is some connection to the files in .shadow-cljs Is there something I can find in those files that might give a clue to what is causing it to break? I've looked in the folder but can't say I really understand what those files are doing.#2019-12-1216:13thhellerthose are the cache files. each build has its own cache. and each namespace has its own cache file in .shadow-cljs/builds/<the-build-id>/dev/ana/...#2019-12-1216:14thhellerwould help a lot to have something reproducible so I can see what you are actually doing#2019-12-1216:14thhellerthere were issues in the past with specs defining specs for other namespaces and such#2019-12-1216:14thhellermaybe something along that lines broke#2019-12-1216:14thhellerkinda hard to say#2019-12-1220:21colinkahn@thheller I was able to create a minimal reproduction here: https://github.com/colinkahn/shadow-cljs-instrument-issue#2019-12-1220:27colinkahnI was able to make it even more minimal. Reproducable with a single deftest without async:
(deftest test-1
  (st/unstrument)
  (is (= (set (st/instrument)) #{`app.core/foo})))
#2019-12-1220:41colinkahnI’m going to open an issue since I’ve played a bit more with this and don’t want keep posting stuff in here where it’s likely to get lost#2019-12-1220:46thhellerinstrument is rather tricky in CLJS since its a macro that does a bunch of weird stuff#2019-12-1220:47thhellernot sure they are supposed to work as part of a "test"?#2019-12-1220:47thhellerbut yes an issue would be good#2019-12-1220:50colinkahnAdded here: https://github.com/thheller/shadow-cljs/issues/618#2019-12-1220:51colinkahnI split the files a bit more and played with :cache-blockers and was able to get it no longer fail.#2019-12-1220:51colinkahnBut I think you mentioned that clojure spec was treated differently for caching and it seems like files that use it are not ignored in the same way that using :cache-blockers does#2019-12-1220:55thhellerI'll take a look. maybe I missed a cljs.spec change or so#2019-12-1220:55thhellerthanks for the repro#2019-12-1222:11colinkahn@thheller saw you fixed it, thank you!#2019-12-1208:18thhellerare you doing anything special with those specs?#2019-12-1209:05cflemingIn Shadow, can builds specify their source paths, or are they always specified at the top-level? For example, if I have a test build and I want to include my test sources for that but not for my production build, can I do that?#2019-12-1209:06thhellershadow-cljs by default only includes files in a build that are actually required somewhere#2019-12-1209:07thhellerso if your "production" build doesn't require any of the tests then it won't be in the build#2019-12-1209:07cflemingOk, great, thanks.#2019-12-1209:07thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2019-12-1209:07thhellerbut no there are no separate source paths per build#2019-12-1209:07cflemingOk, as long as I don’t actually need them that’s ok.#2019-12-1209:08thhelleryou can always use deps.edn or project.clj to sort of get that but in regular use it shouldn't be required#2019-12-1209:09cflemingNo, as long as I know that this is the idiomatic solution I’m fine with that.#2019-12-1214:10Michaël Salihi@thheller Hi Thomas, anything new about React-native and the websocket management ? Follow up your first pass about this the last summer ? > first pass to properly handle react-native not closing websockets#2019-12-1317:40Michaël Salihi@thheller As you don't do React native, there are a new advanced hot reloading feature (fast refresh) : https://facebook.github.io/react-native/docs/fast-refresh Maybe we can use it to "fix" the websockets problem ?#2019-12-1214:11thhellerI added a few REPL helper fns but nothing automated yet#2019-12-1214:12thhellerdunno how ... the react-native issue I opened was closed due to inactivity and nobody ever looked at it#2019-12-1214:12thhellerIMHO its a react-native bug and I hate working arround other peoples bugs#2019-12-1214:13thhellerI added (shadow.cljs.devtools.api/repl-runtimes-clear) to kick out "stale" sessions#2019-12-1214:13thhellerbut funny enough .. the react-native websockets sometimes keep responding#2019-12-1214:14Michaël Salihi> dunno how ... the react-native issue I opened was closed due to inactivity and nobody ever looked at it Yes, I see this 😖#2019-12-1214:14thhellerso they never go stale although the app was reloaded ...#2019-12-1214:14thhellerI don't do any react-native development myself so I never dug into it deeper#2019-12-1214:15Michaël SalihiThx for the information ! I will try about (shadow.cljs.devtools.api/repl-runtimes-clear)#2019-12-1215:54Michaël Salihi> IMHO its a react-native bug and I hate working arround other peoples bugs Totally, I understand you#2019-12-1217:24mauricio.szaboI'm having trouble using shadow-cljs, requiring a JS file that requires lodash. For example, if I have the following line on src/dependent.js:
import { size, isEqual } from 'lodash';
The following code on a .cljs file doesn't work:
(ns lod.main
  (:require ["/dependent" :as d]))
#2019-12-1217:24mauricio.szaboIt fails with:
Closure compilation failed with 2 errors
--- dependent.js:1
Requested module does not have an export "isEqual".
--- dependent.js:1
Requested module does not have an export "size".
#2019-12-1217:24mauricio.szaboIs this a known issue?#2019-12-1220:18thhellerthe issue is known yes. the closure compiler only really supports "strict" mode ESM interop so it complains when its fed commonjs code#2019-12-1220:18thhellersupport works a bit better when using require and module.exports so CommonJS instead of ESM#2019-12-1220:19thhellerbut that has other issues ... so doesn't work too well in other areas, mostly around requiring CLJS code from JS#2019-12-1300:41Aleedso assuming we're mostly using js inside cljs (not cljs code in js), then commonjs is prefered to esm?#2019-12-1300:37Aleedcan I only reference javascript packages in cljs? if so, how woould I go about referencing a js package in a macro?#2019-12-1300:46Aleedah i guess i'd wanna make sure it's only read and not evaluated until it reaches cljs#2019-12-1302:14aisamuMacros are pure CLJ. You can't directly use the JS code on the macro, but you can spit the CLJS code that will use it. (e.g. if your macro is spitting some code as in (react/createElement foo) , the CLJS file that uses it must require react)#2019-12-1316:42wilkerluciohello, I'm trying to port some old project from figwheel to shadow, but for some reason I'm getting this when I try to compile:
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
	at com.google.javascript.rhino.IR.name(IR.java:381)
#2019-12-1316:42wilkerlucioI check closure version, seems correct (coming from Shadow)#2019-12-1316:42wilkerlucioI check closure version, seems correct (coming from Shadow)#2019-12-1316:43wilkerluciofull error stack:#2019-12-1316:43wilkerlucio
Exception in thread "main" Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).
	at clojure.lang.Compiler.load(Compiler.java:7647)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:463)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:1523)
	at shadow.cljs.devtools.cli$eval1826$loading__6706__auto____1827.invoke(cli.clj:1)
	at shadow.cljs.devtools.cli$eval1826.invokeStatic(cli.clj:1)
	at shadow.cljs.devtools.cli$eval1826.invoke(cli.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:463)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at user$eval1809$fn__1813.invoke(form-init1501309315939750065.clj:1)
	at user$eval1809.invokeStatic(form-init1501309315939750065.clj:1)
	at user$eval1809.invoke(form-init1501309315939750065.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7166)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.Compiler.loadFile(Compiler.java:7573)
	at clojure.main$load_script.invokeStatic(main.clj:452)
	at clojure.main$init_opt.invokeStatic(main.clj:454)
	at clojure.main$init_opt.invoke(main.clj:454)
	at clojure.main$initialize.invokeStatic(main.clj:485)
	at clojure.main$null_opt.invokeStatic(main.clj:519)
	at clojure.main$null_opt.invoke(main.clj:516)
	at clojure.main$main.invokeStatic(main.clj:598)
	at clojure.main$main.doInvoke(main.clj:561)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:705)
	at clojure.main.main(main.java:37)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
	at com.google.javascript.rhino.IR.name(IR.java:381)
	at com.google.javascript.jscomp.VarCheck.<clinit>(VarCheck.java:94)
	at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:243)
	at cljs.closure__init.load(Unknown Source)
	at cljs.closure__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:2088)
	at cljs.repl$loading__5569__auto____6321.invoke(repl.cljc:9)
	at cljs.repl__init.load(Unknown Source)
	at cljs.repl__init.<clinit>(Unknown Source)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at clojure.lang.RT.classForName(RT.java:2207)
	at clojure.lang.RT.classForName(RT.java:2216)
	at clojure.lang.RT.loadClassForName(RT.java:2235)
	at clojure.lang.RT.load(RT.java:453)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:3894)
	at shadow.cljs.devtools.api$eval2856$loading__6706__auto____2857.invoke(api.clj:1)
	at shadow.cljs.devtools.api$eval2856.invokeStatic(api.clj:1)
	at shadow.cljs.devtools.api$eval2856.invoke(api.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)
	at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	... 68 more
#2019-12-1316:46wilkerlucionevermind, was some deps problem in the end#2019-12-1316:51thhelleryeah thats a bad guava version I think#2019-12-1319:34Wilson VelezHi, I’m changing an old project from fighweel to shadow, it used cljsjs/hightcharts#2019-12-1319:35Wilson Velezwhat should I use now highcharts npm or react-hightcharts npm?#2019-12-1319:43hlolli@wvelezva if you used cljsjs/hightcharts, then look at their extern file https://github.com/cljsjs/packages/blob/master/highcharts/resources/cljsjs/highcharts/common/highcharts.ext.js and it looks to me that you were relying on hightcharts and not react-hightcharts.#2019-12-1319:44mdhaney@thheller I was skimming this channel the other day, and someone mentioned a web socket issue with RN. Could you point me to the details of the issue? I’ve had some problems with websocket disconnects in development which I just attributed to flakey environment (I.e. going through ngrok), but I want to make sure it’s not something more serious.#2019-12-1319:44Wilson Velezsorry, wrong question, now that I’m using shadow, I would like to use the highcharts js more directly, avoiding the cljsjs#2019-12-1319:45hlolliit's all documented here https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2019-12-1319:46hlollior here to be more percise https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps#2019-12-1319:47Wilson Velezthanks @hlolli#2019-12-1319:44thhellerbasically the websocket stays connected in android when you do an app reload#2019-12-1319:46mdhaneyAh, ok. That’s not my issue. And it sounds like it would just be a dev issue anyway.#2019-12-1319:46mdhaneyThanks.#2019-12-1319:47thhelleryes, dev only. basically shadow-cljs just thinks that the REPL is still connected when it is not#2019-12-1319:47hlolliis there a good trick to have shadow-cljs run babel after compilation, I want to use https://emotion.sh/docs/@emotion/babel-preset-css-prop to transform my js.#2019-12-1319:48hlolliit's well documented babel + jsx and then import that. But I wonder with transformations on cljs sources (after compilation ofc, but before minification I'd assume).#2019-12-1319:49thhellerthats not supported#2019-12-1319:49thhelleryou could in theory do it in a :compile-finish hook but there is nothing built-in to do that#2019-12-1319:49thhelleralso will get quite messy dealing with source maps and stuff#2019-12-1319:49hlolliok np, I'll give compile-finish hook a try. Thanks#2019-12-1319:50thhellercheck :build-sources in the compile state. those are the resource-ids for all sources that were compiled. (get-in build-state [:output resource-id]) will get you the compile output :js is the generated JS for example#2019-12-1319:51hlolliah yes, I remember how huge data is being passed, good to know, otherwise I'd get lost 🙂#2019-12-1319:51thhellertry (tap> build-state) and look at it in the Inspect UI#2019-12-1319:52thhellerit has no problem with huge data 😉#2019-12-1319:52hlolliok nice#2019-12-1320:00lilactown@hlolli you’re going to struggle to use that because CLJS doesn’t emit JSX#2019-12-1320:00lilactowninstead of transforming your JS, you should probably figure out a way to transform your CLJS code to use emotion#2019-12-1320:02hlolliyes, it could be this wont work because of reagent. I think babel can be called on any js file, ancient or new.#2019-12-1320:04hlolliI'm using emotion at a company I'm freelancing for in jsx. And I'd do anything do get it working in cljs with css prop. Lifesaver.#2019-12-1320:05lilactownthe babel-plugin works when it transforms JSX to JS code, though#2019-12-1320:06lilactownso you can call it on any JS file, of course. it just won’t do anything unless you’re using JSX#2019-12-1320:06hlolliit depends on the transformer?#2019-12-1320:06lilactownI don’t understand your question#2019-12-1320:06lilactownI’m reading the source code for the babel-preset-css-prop plugin: https://github.com/emotion-js/emotion/blob/master/packages/babel-preset-css-prop/src/index.js#2019-12-1320:06hlollibabel is a tool that can be used to transform any kind of js tranformation#2019-12-1320:07hlolliah I see thanks for that point#2019-12-1320:08lilactownit takes JSX code <div css={color: green`} />` and hooks into the JSX parser to transform the css prop#2019-12-1320:08hlolliso you think it would make sense to rewrite this transformation in shadow? Or patch reagent?#2019-12-1320:08lilactownCLJS does not ever emit JSX, so you will never get any benefit from using that babel transform on your code#2019-12-1320:09hlolliI'm surprised, since babel can be used for polyfills, typescript and ecmascript proposals, and transform es5 to es6 etc.#2019-12-1320:09hlollibut in this case with that preset, it needs jsx true#2019-12-1320:10lilactownif you’re using reagent, I’m not sure what you should do. you could use a function or macro to parse a :css prop in a map and do the transformation#2019-12-1320:11hlolliI need to research, I think there's more to it. Because I should be able to pass it to className prop instead of css. But that doesn't work either. And I added this recently to a ts project and all I had to do was to add this babel preset and it works.#2019-12-1320:12lilactownyou can use emotion without the css prop, yes#2019-12-1320:13lilactown
(def my-styles (emotion/css #js {:color "green"}))

(defn my-component []
  [:div {:class my-styles} "Hello"])
#2019-12-1320:13hlolliin reagent, this isn't working#2019-12-1320:14hlolliI realized I forgot to try js/react directly. But I had tried reagent/createElement, which is the same as if it were in hiccup vector#2019-12-1320:14lilactown? I have no idea what you’re talking about#2019-12-1320:14lilactownlet’s take this to #reagent and stop cluttering #shadow-cljs#2019-12-1417:58wilkerluciohello, is there a way to bundle assets with packages for front-end usage with shadow these days? my case is that I'm writing a library to have the design system things of the company, and those could be used in many projects, for variables I can just use clojure code, but I'm wondering about things like fonts, is there a way to bundle the fonts with the package and use them from cljs?#2019-12-1504:38knubie@U066U8JQJ I don't believe it's documented in the user guide, but maybe shadow.resource might work for you? https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2019-12-1509:03thheller@wilkerlucio shadow-cljs doesn't have anything regarding "resources". mostly because its a huge topic and I'm not sure how to do it in a maintainable way thats also extensible enough#2019-12-1512:39vinurswhen use luminus with
lein new luminus test +reagent +shadow-cljs
then use
lein shadow release app
it output the errors
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
        clojure.lang.Reflector.getInstanceField (Reflector.java:397)
        clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
        shadow.build.closure/js-error-xf/fn--23982 (closure.clj:536)
        clojure.core/map/fn--5862/fn--5863 (core.clj:2742)
        clojure.core.protocols/iter-reduce (protocols.clj:49)
        clojure.core.protocols/fn--8140 (protocols.clj:75)
        clojure.core.protocols/fn--8140 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
        clojure.core/transduce (core.clj:6884)
        clojure.core/into (core.clj:6899)
        clojure.core/into (core.clj:6887)
        shadow.build.closure/log-warnings (closure.clj:1081)
        shadow.build.closure/log-warnings (closure.clj:1077)
        shadow.build.closure/log-warnings (closure.clj:1079)
        shadow.build.closure/log-warnings (closure.clj:1077)
        shadow.build.closure/optimize/fn--24199 (closure.clj:1185)
        shadow.build.closure/optimize (closure.clj:1170)
        shadow.build.closure/optimize (closure.clj:1161)
        shadow.build.api/optimize (api.clj:268)
        shadow.build.api/optimize (api.clj:262)
        shadow.build/optimize (build.clj:411)
        shadow.build/optimize (build.clj:403)
        shadow.cljs.devtools.api/release* (api.clj:350)
        shadow.cljs.devtools.api/release* (api.clj:336)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
        shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
        shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
        shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
        shadow.cljs.devtools.cli/main/body-fn--28515--auto----29104 (cli.clj:168)
        shadow.cljs.devtools.cli/main (cli.clj:167)
        shadow.cljs.devtools.cli/main (cli.clj:134)
        clojure.core/apply (core.clj:669)
        clojure.core/apply (core.clj:660)
        shadow.cljs.devtools.cli/-main (cli.clj:221)
        shadow.cljs.devtools.cli/-main (cli.clj:219)
        clojure.lang.Var.invoke (Var.java:388)
        user/eval12549 (form-init10468658607384081452.clj:1)
        user/eval12549 (form-init10468658607384081452.clj:1)
        clojure.lang.Compiler.eval (Compiler.java:7177)
        clojure.lang.Compiler.eval (Compiler.java:7167)
        clojure.lang.Compiler.load (Compiler.java:7636)
        clojure.lang.Compiler.loadFile (Compiler.java:7574)
        clojure.main/load-script (main.clj:475)
        clojure.main/init-opt (main.clj:477)
        clojure.main/init-opt (main.clj:477)
        clojure.main/initialize (main.clj:508)
        clojure.main/null-opt (main.clj:542)
        clojure.main/null-opt (main.clj:539)
        clojure.main/main (main.clj:664)
        clojure.main/main (main.clj:616)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.main.main (main.java:40)
how to debug this error?
#2019-12-1512:39thheller@haiyuan.vinurs thats a dependency conflict on the closuer-compiler version#2019-12-1512:40thhellerprefer using shadow-cljs.edn only so you don't have to deal with this ...#2019-12-1512:41vinursok, let me try it#2019-12-1515:12David PhamAny we could use this with Shadow-CLJS? https://github.com/weavejester/hashp/blob/master/README.md#2019-12-1515:32thhellerits CLJ only so no#2019-12-1516:27tianshuis that arborist not try to do the same like svelte is because wanna use arbitrary clojure code instead of dsl like svelte?#2019-12-1516:37thhellercan't say really. the mutable style svelte uses doesn't really fit too well into CLJS#2019-12-1516:38thhellerI'm just experimenting after all#2019-12-1517:20tianshuI looked at the compiled code of svelte, looks like it just simply recalculate all the variables in a component(in a function called instance), looks like it doesn't distinguish which variable is used by which node, will it really fast?#2019-12-1604:01cflemingI’m migrating my legacy cljsbuild app (for Cursive licensing) over to shadow. For the web part, I compile separate JS for separate pages, i.e. I have pages for buy, renew, quote etc. They share some code but currently I’m compiling them into separate JS. They all use the same output dir. I thought that in Shadow I’d be able to use modules within a single build for this, but when I try to configure this I get the error: “two modules without deps, please specify which one is the default”. I’m not sure what that means - should I be using separate builds for this?#2019-12-1605:34superstructorAre you using :depends-on @cfleming?#2019-12-1605:35superstructorE.g.
{...
 :output-dir "public/js"
 :modules
 {:shared
  {:entries [my.app.common]}
  :home
  {:entries [my.app.home]
   :depends-on #{:shared}}
  :login
  {:entries [my.app.login]
   :depends-on #{:shared}}
  :protected
  {:entries [my.app.protected]
   :depends-on #{:shared}}
#2019-12-1606:56cflemingNo, but in this case none of my modules depend on one another. They’re essentially independent apps.#2019-12-1607:43tianshuModules are used for dynamic load in one app, different apps should have their own build. localhost:9630 is the default web console of shadow-cljs, you can use it to start/stop your builds.#2019-12-1608:23cflemingOk, thanks - I’ll separate them into different builds then.#2019-12-1609:20thhellerno. definitely use :modules#2019-12-1609:21thhellerbut the difference to regular CLJS is that there is no default :cljs-base module.#2019-12-1609:21cflemingOk, what should I use for the default module, then?#2019-12-1609:21thhellerso as @U0G75S29H showed you need to declare one :shared module that all others depend on. you can use :entries []#2019-12-1609:21cflemingAh, ok, I’ll do that, thanks.#2019-12-1609:21thhellerthat'll move all actually shared code there#2019-12-1609:22cflemingSo when I deploy a production build, will that load two JS files for each page? The shared and then the page-specific?#2019-12-1609:22thhellerin the pages then just load shared.js and the-page-you-are-on.js via HTML#2019-12-1609:23cflemingRight, snap.#2019-12-1609:23thhellerno need to use the loader.#2019-12-1609:23cflemingOk, thanks, I’ll try that.#2019-12-1701:24cflemingSo this is what I ended up with:
:modules    {:shared      {:entries []}
             :pay         {:init-fn    site.pay/init!
                           :depends-on #{:shared}}
             :quote       {:init-fn    site.quote/init!
                           :depends-on #{:shared}}
             :buy         {:init-fn    site.buy/init!
                           :depends-on #{:shared}}
             :renew       {:init-fn    site.renew/init!
                           :depends-on #{:shared}}
However when I compile, I get the following:
[:site] Build failure:
Module Entry "site.buy" was moved out of module ":buy".
It was moved to ":shared" and used by #{:buy :quote}.
#2019-12-1709:29thhellerthis means that the site.buy ns was used somewhere in the :quote module. likely a direct (:require [site.quote ...])#2019-12-1709:29thhelleryou can either make the buy module depend on quote#2019-12-1709:29thhelleror move the shared code into an extra ns so it can be moved out#2019-12-1709:30thhelleror just combine quote/buy into one#2019-12-1710:35cflemingAh, I see - I’ll play with that tomorrow, thanks.#2019-12-1710:35cflemingIt’s amazing how much shadow has removed the incidental complexity in my project, it’s very nice indeed.#2019-12-1800:00cflemingIf I make my quote module depend on buy and shared, then I guess I need to load both in my HTML? i.e. I need shared.js, buy.js and quote.js in quote.html? Or is the shared code all moved out to shared.js?#2019-12-1800:02cflemingI remember seeing in the doc that shared code is moved to the leaves as much as possible, is Shadow smart enough to see that shared is common to both buy and quote, and to put the code required by both there?#2019-12-1800:10thhellerno you need to load them all. the goal is to move code as close to the "edges" as possible. the goal is to keep shared as small as possible#2019-12-1800:11cflemingAh, I see - thanks.#2019-12-1800:13cflemingIs the order of loading the modules in the HTML important? I know I have to load shared before quote, but is there a good way to know that I need (presumably) buy after shared but before quote?#2019-12-1800:19thhelleryes order is important. order is logical. all depends-on must be loaded before and that applies to all moduels being loaded#2019-12-1800:19cflemingYes, that makes sense, thanks.#2019-12-1607:38cflemingIf I understand the documentation correctly, if I have a :node-script build and I watch it, then hot code reloading should just work - is that correct? Is something logged somewhere when code is reloaded in that case?#2019-12-1609:24thheller@cfleming did you specify the lifecycle hooks? either (defn ^:dev/after-load do-something-after-reload [] ...)?#2019-12-1611:49Michaël SalihiA simple question about the syntax this hook (or hook in generally), this is exactly the same, right ? (defn ^:dev/after-load... vs (defn {:dev/after-load true}...#2019-12-1613:39thhelleryes#2019-12-1613:39thhellerwell no. the map has to come after the name but the ^ comes before 😛#2019-12-1614:19Michaël SalihiHaha Ok thx 🙂#2019-12-1609:24thhellerit should be logging something yes#2019-12-1609:24cflemingI hadn’t specified a hook, no - I’ll try that tomorrow.#2019-12-1609:25thhellerin node hot-reload is often tricky because so much state is kept in some callbacks somewhere#2019-12-1609:31cflemingYeah, in this case it’s a node script running a web server and a local dynamo - I guess I’ll have to shut all that down, reload and then restart them.#2019-12-1609:34thhelleralso see https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#things-to-avoid#2019-12-1609:35thhelleryou just might be handing off a reference to some function that can't be hot reloaded#2019-12-1609:35thhellerso instead of passing some-fn it may help to pass #(some-fn %) instead#2019-12-1609:45cflemingGreat, thanks - I’ll go through that checklist tomorrow.#2019-12-1620:39Aleedis it possible to run browser tests via terminal or is opening up browser required? and for node.js is there a way to have an automatic watching/running of tests similar to how browser tests run?#2019-12-1620:49aisamuYou can use the :karma target for cli tests (which has a "browser" runner as well IIRC)#2019-12-1703:28cflemingI have a website which talks to an API backend, both are CLJS using shadow. In my pages I make calls to the backend, in production they will call https://<my-domain>/path, but in local dev I want them to call . Is there a tidy way to do this? I thought about using the hosts file but that doesn’t allow me to switch from https to http or specify the port to use.#2019-12-1703:36cflemingActually it looks like Closure defines would work for this. So am I correct in thinking that if I do this:
(goog-define LOCAL true)
(def api-target (if LOCAL "<local-url>" "<prod-url>")
Then only one of those values will be compiled into the code? Or am I better to have the URL itself as the value of the define?
#2019-12-1704:10superstructorYes your correct only one value should be compiled in when using Closure defines.#2019-12-1704:10superstructorPersonally I inject the entire URL, instead of just a boolean, but I believe either way will have the same result i.e. only one value compiled in to the output JS.#2019-12-1708:30cfleming@U0G75S29H Thanks, yes, that’s what I ended up with, which seems to work well.#2019-12-1715:24superstructorAnytime @U0567Q30W 🙂 Thank you for Cursive! I spend about 50% of my time awake using it.#2019-12-1723:25cflemingGreat, I’m glad you’re still liking it!#2019-12-1721:35mikerodwhat’s the purpose of the ^clj type hint?#2019-12-1800:10thhellerin what context? I use it sometimes to make externs inference shut up#2019-12-1806:30mikerodJust wasn’t sure what it was for. Saw it mentioned in the guide and saw it in a few projects#2019-12-1806:31mikerodJust makes false positive warnings not show up then?#2019-12-1808:31cflemingI have an autotest build config that looks like this:
:test
                {:target    :node-test
                 :output-to "target/test/node-tests.js"
                 :autorun   true
                 :ns-regexp "-test$"}
#2019-12-1808:31cflemingHowever shadow-cljs watch test doesn’t actually run the tests:
~/d/c/lambda (master)> shadow-cljs watch test
shadow-cljs - config: /Users/colin/dev/cursive-site/lambda/shadow-cljs.edn  cli version: 2.8.77  node: v12.1.0
shadow-cljs - connected to server
shadow-cljs - watching build :test
[:test] Configuring build.
[:test] Compiling ...
[:test] Build completed. (115 files, 13 compiled, 0 warnings, 7.68s)
#2019-12-1808:33cflemingIf I ctrl-c the watch process and manually run the test script, the tests execute correctly. Is there something I’m missing here? Should I be able to watch two builds from the same project simultaneously in separate terminals?#2019-12-1808:36cflemingOh, actually here’s what’s happening: I have another build from the same project I’m watching in another terminal. The tests are being run in that terminal, not the test one.#2019-12-1810:15thhelleryeah I think there is an open issue about that. keep forgetting to change that.#2019-12-1812:19danielnealhey, anyone got any tips or pointers on setting up intellij with shadow-cljs. I use emacs, but I have a co-worker on Intellij just trying to get him up and running.#2019-12-1812:23danielnealDo we need to make a dummy project.clj or something along those lines?#2019-12-1813:31lecrossHi, did you ha a look at that section in the docs ? 😄 https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration#2019-12-1813:33lecrossi guess you’ll have to generate the pom.xml and import the project in intellij#2019-12-1813:37lecrossif you use cursive you’ll find guides in the docs here https://cursive-ide.com/userguide/leiningen.html#2019-12-1813:41superstructorAnother option is just to use lein w/ lein-shadow: https://gitlab.com/nikperic/lein-shadow https://github.com/day8/re-frame/blob/master/project.clj#2019-12-1813:43superstructorshadow-cljs is an outstanding compiler etc to use as a library, but lein is just a much more robust build tool and you also get wider compatibility (e.g. Cursive).#2019-12-1813:51thhellerI absolutely disagree. leiningen does jack shit for CLJS. it only makes sense for CLJ. it isn't even great for hybrid projects. a big chunk of problems people report are due to "mixing" CLJ and CLJS projects.#2019-12-1814:11danielnealIt turns out that it was actually working for my colleague off the bat, and he hadn’t realised! We were so sure we would have to do something fiddly 😄 😄 😄#2019-12-1813:47thheller@danieleneal you can run shadow-cljs pom and import the generated pom.xml in intellij for the project#2019-12-1814:01danielnealah great, thank you @thheller 🙂#2019-12-1814:18danielnealWe’ve got one unusually big file in the build report. It’s not especially interesting, as far as I can tell. Is this a red herring (like there’s always going to be one ‘big’ file, it’s just whichever file includes the big bits of cljs.core first) or something worth investigating - and if worth investigating - what’s the best way of diagnosing the culprit?#2019-12-1814:27thhellerthats definitely strange. cljs.core is listed separately#2019-12-1814:27thhellernever seen a file that big#2019-12-1814:28thhellermight be a macro generated a lot of code?#2019-12-1814:29thhellerall the files seem rather big#2019-12-1814:29thhelleror did you turn off :advanced?#2019-12-1814:32danielnealI’ll clean everything out and try again#2019-12-1814:32danielnealmight be a glitch#2019-12-1814:33danielnealthe actual js file looks small#2019-12-1814:36thhellerlooks small or is small?#2019-12-1814:36thhellerI mean the output .js file not the source .cljs file#2019-12-1814:37danielneal#2019-12-1814:38danielnealoop#2019-12-1814:38danielnealI did shadow-cljs release app then shadow-cljs run shadow.cljs.build-report app report.html#2019-12-1814:42danielnealI don’t think I switched off advance, but then I didn’t switch it on - it usually defaults to advanced - perhaps I need to run the build report differently#2019-12-1814:42danielnealthis is my first time digging in with it#2019-12-1814:43thhellerno this is all you need#2019-12-1814:43thhellerunless you set :optimizations :simple it will default to advanced#2019-12-1814:43danielnealcool, yep good#2019-12-1814:47danielnealI am bundling a couple of big json file, but they’re in a different files not the one that is marked as big in the report, and not required by that file#2019-12-1814:47danielnealI’m on 2.8.67, gonna try updating#2019-12-1814:47thhelleryou don't need to update#2019-12-1814:48thhelleryou don't need to look at other files#2019-12-1814:48thhellerjust look at exaclty that file#2019-12-1814:48thhellernothing else is revelevant#2019-12-1814:49danielnealI’m on react native, so at the moment, in release, I’ve got one big index.js.#2019-12-1814:49thhellerah#2019-12-1814:50thhellerhmm thats trickier then 😛#2019-12-1814:50thhellermaybe just create a browser build that uses that file#2019-12-1814:50danielnealah cool, good idea#2019-12-1814:51thhelleryou can look at the cache file too#2019-12-1814:51thheller.shadow-cljs/builds/the-build/dev/ana/...#2019-12-1814:51thhellerbut its a transit json file so#2019-12-1814:55danielneallook under output.js in that json file?#2019-12-1814:55thhellerhmm?#2019-12-1814:56danielnealin .shadow-cljs/builds/the-build/dev/ana/my/file theres a json file with an output js key which has the relevant compiled js#2019-12-1814:56danielnealbut it’s only 20kb#2019-12-1814:56danielnealit’s not advanced though#2019-12-1814:56thhellerI'm confused#2019-12-1814:57danielnealoh wait sorry I was looking under /release/ana#2019-12-1814:57thhellerthat is fine#2019-12-1814:58danielnealI wasn’t able to try the browser build route, I think I’d need to change some of my requires as lots are still using the old (js/require) style#2019-12-1814:59thhellerI've never seen a file get larger in :advanced so you are doing something weird#2019-12-1814:59thhellerthat is fine#2019-12-1814:59thhelleryour not supposed to actually RUN the code#2019-12-1814:59thhellerit just needs to compile#2019-12-1814:59thhellerso you get the .js file#2019-12-1815:00thhellerbut build reports are only really meant to browser builds anyways so maybe its just a bug#2019-12-1815:00thhellerI can't think of why it would be though#2019-12-1815:01thhellerI've deifnitely seen macros generate a whole bunch of code#2019-12-1815:01danielnealah ok. I’ll see if I can get the browser build working#2019-12-1815:01danielnealyeah, I know the core.async macros can make a lot of code, so I try to avoid them; we haven’t got any custom macros#2019-12-1815:01thhellerbut without seeing any code I can only guess#2019-12-1815:02thhellercore.async and inline large chunk of EDN data can lead to large files#2019-12-1815:02thhelleror any data really .. just edn is a bit bigger than others#2019-12-1815:03danielnealyeah, my guess is that perhaps one of my inlined chunk sof data is showing up in the report as in a different file, maybe I’ll try taking that out and seeing if that makes it smaller#2019-12-1815:03thhellerwell go into the cache directory#2019-12-1815:04thhellerlist all the cache files and sort by size#2019-12-1815:04thhellershould be easy to spot the big one#2019-12-1815:04thhelleror just run shadow-cljs release app --pseudo-names and try to figure it out from there#2019-12-1815:04thheller1.7mb chunk should be easy to find#2019-12-1815:07danielnealah yeah - the catalog.cljs (which contains the big inlined file) is big in the js but small in optimized, but the pause_orders is big in optimized but small in js column#2019-12-1815:07danielnealthanks for your help - looks like it’s ok bigness that is supposed to be there 🙂 just perhaps ended up in an odd place somehow#2019-12-1817:04Aleedhi i'm trying to use shadow-cljs with expo and next.js. expo actually has built in support for next.js so, since shadow supports expo, wanted to see if I could make it work with nextjs too but running into namespace "good.math.Long" already declared issue: https://github.com/thheller/shadow-cljs/issues/621 ideally i'd like to take advantage of nextjs web optimizations and ease of deployments but wanted to ask, is it even recommended using them together? has anyone successfully gotten it working?#2019-12-1912:35heyarneCan I see where a particular is required? Ideally the whole graph from the entry to the namespace? I have cljs/analyzer.cljc (which I could figure out thanks to npx shadow-cljs run shadow.cljs.build-report app) in my bundle and I'd like to know why.#2019-12-1913:17aisamu@arne-clojurians Programatically or once? That kind of info is available on the build's info page (localhost:9630) Scroll down and there'll be a drop-down. Pick your target ns and you'll be presented something like this:
Namespace: cljs.core.async via: cljs/core/async.cljs
Entries that led to the inclusion of this namespace
shadow.cljs.devtools.client.browser -> shadow.cljs.devtools.client.hud -> cljs.core.async
shadow.test.browser -> shadow.dom -> cljs.core.async
#2019-12-1915:55Vít KaliszI would like to start using Material-UI in my project. I started with some experimentation as follows:
(ns orgpad.client.views.widgets.md-button
  (:require ["@material-ui/core/Button" :as button]))

(defn md-button []
  [:> button/Button {:color :primary :variant :contained} "button"])
When calling md-button, the following error occurs:
react.development.js:168 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
How does the requiring work? Why does this occur?
#2019-12-1916:05thhellerread https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages especially the part about default exports#2019-12-1917:09tianshucan I let browser test use pprint?#2019-12-1917:10tianshusome output like
(not (= [{:foo/id {1 {:foo/id 1}}} {:bar/id {1 {:bar/id 1, :bar/foo [:foo/id 1]}}}] [{:bar/id {1 {:bar/id 1, :bar/foo [:foo/id 1]}}} {:foo/id {1 {:foo/id 1}}}]))
is really hard to read in the browser.
#2019-12-1918:30kenjI see shadow can generate a POM file to be used in Cursive IDE. Can someone point me in the right direction on how to import that such that depdencies are resolved by Cursive, and I can stop copy n pasting the deps into deps.edn to get Cursive symbol resolution and auto-complete to function?#2019-12-1918:31kenjI feel like this would be much easier if I had a Java background =/#2019-12-1918:32thheller@risinglight you click "create new project from existing sources" and select the pom.xml file#2019-12-1918:32thhellerthats it#2019-12-1918:32thhellerif that doesn't work you might not have the maven plugin installed#2019-12-1918:38kenjawesome, that seems to have done the trick!#2019-12-1918:45kenjI appreciate the help, and also building this kick ass tool. I feel like I might actually be able to tackle a CLJS side project now.#2019-12-2001:51pcjHas anyone been able to use anime.js with shadow-cljs?#2019-12-2005:27dpsuttonhttps://codeburst.io/create-a-revealing-animation-with-anime-js-25a49bc98cd7
#2019-12-2005:28dpsutton#2019-12-2005:44dpsuttonhttps://github.com/dpsutton/animejs-test#2019-12-2017:03pcjahh thank you! was trying to use ["animejs/lib/anime.es" :default anime]#2019-12-2017:08dpsutton:+1:#2019-12-2005:27dpsuttoni just did a POC. what issues are you having?#2019-12-2016:00salamgreetings, all! i’ve put together some instructions for setting up shadow-cljs and fireplace.vim integration as i could not find any up-to-date content on this. i would like to ensure this is THE up-to-date (and correct?) way to do it as of right now before i show this to others so that i don’t end up misleading them. would anybody care to spend 2 minutes of their time and help me review it? thanks a lot! the uri to the instructions is here: https://gist.github.com/finalfantasia/292b8432dc0072b2397ea4d694aab930#2019-12-2017:15Ian MI have done :Piggieback :module-name instead of the :CljEval , i am wondering what the difference is#2019-12-2017:30salami’m quite new to the cljs side of the things so i’m not sure. but based on the conversations here (https://github.com/thheller/shadow-cljs/issues/62 and https://github.com/thheller/shadow-cljs/issues/561) and fireplace.vim’s on-line documentation about :Piggieback:
*fireplace-piggieback* *fireplace-clojurescript*

To use a ClojureScript, invoke |:CljEval| with the command you would normally use to start a ClojureScript REPL.  For example:
>
        :CljEval (cider.piggieback/cljs-repl (cljs.repl.nashorn/repl-env))
<

...

The :Piggieback command is softly deprecated wrapper for invoking Piggieback.
i figured :CljEval might be the more generic way to go about adding cljs support to an nrepl session. i might be wrong though. :man-shrugging::skin-tone-2:
#2019-12-2017:49Ian Mthank you for sharing!!#2019-12-2017:56salamyou are welcome! it makes me happy to give back to the awesome community, even a tiny bit. 🙂#2019-12-2017:13Drew VerleeConcerning code splitting. What does it mean to depend-on another module? The docs say > The names of other modules that must be loaded in order for this one to have everything it needs. and the blog post says : > As explained above we will start with the `:main` module (becoming the `main.js` output) calling `(https://demo.app/init)` on load, it is the only module that can be loaded directly without loading any other. Then we define one module for each component and they all depend on the `:main` module since that will provide the common code such as `reagent`, `react` and of course `cljs.core`. `:module-loader true` just tells `shadow-cljs` that it needs to do a couple extra steps to allow loading the code dynamically. This seems straight foward, but to test my understanding. Say you have a react compoment A that contains another compoment B and both are made into modules. code looking like (not precise semantics of course) (lazy-load A) (defn A [] (.... (lazy-load B)) In this case it would seem wrong to say A depends on B because it doesn't necessarily contain what it needs to load. Or maybe another test question would be. If in the blog post, you dont say "depends-on" then what happens? Would each module re-load all the code shared between main and the individual modules?#2019-12-2017:22lilactownyes, I would say that it’s wrong to say A depends on B (or vice-versa) if both modules can potentially be loaded without the other being present#2019-12-2017:24lilactownit might be beneficial to have B depend-on A, if A is also lazy-loaded and has some code you don’t want to bundle with the main app#2019-12-2017:26lilactownin other words, if a module depends-on another, it means that the depended on module MUST be loaded BEFORE the module which depends on it#2019-12-2017:27lilactownall shared code between the two will be moved to the module which was depended on#2019-12-2017:27Drew Verlee> yes, I would say that it’s wrong to say A depends on B (or vice-versa) if both modules can potentially be loaded without the other being present So in this case, sense A contains B it doesn't need B to be loaded before. It will load B when it gets to that code.#2019-12-2017:28Drew Verleehitting this home hard because i think i straight up got it in my head the other way.#2019-12-2017:29lilactownright, ostensibly you have three modules: :main :A and :B#2019-12-2017:31lilactownin this case, you can load :A no problem without :B. so you wouldn’t say it depends-on :B. similarly, you can probably load :B without :A , since they’re both just React components and you might have other components which would lazy-load B somewhere else#2019-12-2017:31lilactownso you want to have a third module, in this case :main , which the compiler can move the code shared between modules :A and :B so it doesn’t get downloaded and loaded twice#2019-12-2017:36lilactownto say it another way again, depends-on is a way of specifying where shared code will be moved between a number of modules. So if you have:
{:main {:entries [app.core]}
 :A {:entries [app.A]
     :depends-on #{:main}}
 :B {:entries [app.B]
     :depends-on #{:main}}}
this will make it so that any shared code (such as React, or other library or application code shared between the two) will be moved into the module created from :main. Then when you load :A, it will only have code specific to that module. :A will kick off a dynamic, lazy load of :B, which will also only contain code that is needed to render the B component.
#2019-12-2017:37lilactownto say it even another way: depends-on is a way of specifying static dependencies on modules. in this case, you are dynamically loading another module so there’s no necessary static dependencies between the two#2019-12-2017:44Drew VerleeThat makes sense. This helps a ton. Thanks @lilactown#2019-12-2018:08Drew Verlee@lilactown In the case where compoment A contains compoment B and say another component (C) also contains B. If you said A depends on B and C depends on B it would mean that the code in B (that was unique to B and not in main) would be lazy loaded when A or C loaded as opposed to if you didnt declear those depends on then I imagine B's code would be loaded both times (when A loaded and when B loaded).#2019-12-2018:09lilactownnot quite#2019-12-2018:10lilactownif you said A depends on B and C depends on B then B would contain all of the shared code between and you would not be able to load A or C without first loading B#2019-12-2018:11Drew Verleewhat seems to happen is that the B module is then loaded as part of loading :main. For context we do have B depends on Main.#2019-12-2018:12lilactownthe goal of code splitting and modules is to: 1. only ever load a line of code once 2. optimize which code gets loaded when so you will never have a case where two modules contain the same code. if you do, that’s a serious bug#2019-12-2018:14Drew VerleeSo if you have a really big module (say its A). then code splitting can only make it larger because the more things it depends on the bigger package it will load due to bundled dependencies?#2019-12-2018:14lilactownI don’t understand what you mean in this context what “code splitting can only make it larger” means#2019-12-2018:15lilactownlet’s say you start with one big module. we’ll call it :app#2019-12-2018:16lilactownin this case, all of your code gets bundled into one app.js file and the client downloads it all upfront and it all gets run in the browser before your app starts#2019-12-2018:16lilactownlet’s say it’s 2mb big#2019-12-2018:17lilactownthen you say: “Ah! Many of our users don’t use feature, so we’ll split that out from the main bundle and lazy-load it if the user decides to use it!”#2019-12-2018:18lilactownso you create a new module, :feature , and you say:
{:app {:entries [app.core]}
 :feature {:entries [app.feature]
           :depends-on #{:app}}}
now you can lazy-load app.feature.
#2019-12-2018:21lilactownwhat the compiler does is analyze the app.feature namespace, and all of the namespaces it requires. if code or a namespace only appears in app.feature, then it will move that code into into the feature.js bundle. if code or a namespace appears in app.feature, and something that is required by app.core, then it will be moved into the app.js bundle. that way, when you load app.js it will have all of the code necessary for the app.core namespace with it. When you load feature.js, it will not contain any duplicate code that app.core and app.feature both need#2019-12-2018:22lilactownso let’s say app.feature was pretty hefty, maybe it included a couple NPM libs that were only used there, so the app.js bundle is now 1.1mb and the feature.js bundle is 0.9mb#2019-12-2018:22lilactownyou haven’t removed any code, but you will never load more than the 2mb that you originally started with#2019-12-2018:23Drew VerleeI did some quick diagrams and i think i understand. In addition to what you said, which i understand, here is another example. Before: A depends on main B depends on main If we add a C module and have B and A depend on it... A depends on main, C B depends on main, C C depends on main Then in the second version we have moved code that was in main to C and C will be loaded when we first load A or B and contain shared code for A and B. For a users stand point we speed up main loading and slowed down the first load of A or B (relative to what it was before).#2019-12-2018:23lilactownright, C must be loaded before A or B#2019-12-2018:24lilactown(I don’t think it will happen automatically for you. maybe shadow’s lazy loader is smarter than I think)#2019-12-2018:35Drew Verleei'm not sure what you mean by this: > I don’t think it will happen automatically for you. maybe shadow’s lazy loader is smarter than I think I was under the impression that to "load C" in this context where its a ns declared a module. You just use call the show lazy loader e.g https://github.com/thheller/code-splitting-clojurescript/blob/c9e1e9340c45969f3fc5b515fb9d095f28595c24/src/main/demo/util.clj#L3 Put another way, declearing modules in the shadow-cljs only does the code splitting. It doesnt tell your running app how to load (http request) the module. That macro helps the compiler know that it doesn't need to pull in that namespace and its deps. It also wraps your compoment so that its a js module with the component as the default.#2019-12-2018:40lilactownI mean that if you call (lazy-load 'app.B) I don’t think it will infer that it needs to lazy-load C before it. you need to load C first, then B#2019-12-2018:41lilactownif it’s only ever C that lazy-loads B, then you’re fine#2019-12-2019:03Drew VerleeSorry. Thats slightly confusing to me. In the example: A depends on main, C B depends on main, C C depends on main Given component A contains C and B contains C. I would assume that the code would look something like: main ns
(def lazy-A (lazy-component app.A/A))
(def lazy-B (lazy-component app.B/B))

(case route 
      "A" (lazy-A)
      "B" (lazy-B))
A ns
(:require [app.C])

(defn A [...] (C/lazy-C))
B ns (same as A) C ns
(defn C [...] ...)
(def lazy-C (lazy-component C))
#2019-12-2019:05Drew VerleeWould be correct. But i dont feel im explicitly telling it to load C before A or B. So do i need to call (C/lazy-C) before the route in the main ns?#2019-12-2019:07lilactownyour depends-on is backwards#2019-12-2019:07lilactownwhy would A and B depend-on C, if C is only ever loaded after A and B?#2019-12-2019:10lilactownwait I mis-read your example#2019-12-2019:11lilactownyour example doesn’t really make sense#2019-12-2019:12lilactownmy question is still relevant. Why would A and B depend on C, if you want C to only be loaded after A and B?#2019-12-2019:12lilactownthe way you have it written, though, C will not be lazy-loaded by A or B#2019-12-2019:12lilactownC must be already available in the browser, and lazy-C is redundant#2019-12-2019:13lilactownyour code will not work because main loads A and B, A and B expect C to be there and it will break#2019-12-2019:19Drew VerleeTwo possible independent things: 1) Given what you have told me. I'm not sure its necessary. However if i change: A depends on main, C B depends on main, C C depends on main To A depends on main B depends on main C depends on main Then i get the shadow warning about C moved into main. Which would be the opposite of what we want sense we want to decrease the size of main. 2) The code example is wrong. The A and B ns shouldn't have requires on C. Its not needed as the lazy-compoment macro declears that will look it up later at the realization point of the lazy load. I'm not sure point 2 changes your observation.#2019-12-2019:22lilactownhere’s what our bundle looks like if we do nothing#2019-12-2019:23lilactownhere’s what our bundle looks like once we’ve split out modules A and B#2019-12-2019:27Drew Verleewhy does the call to C contain Lazy A and Lazy B? Is (defn C ...) supposed to be (defn main ...)?#2019-12-2019:28lilactownit does not#2019-12-2019:28Drew Verleeoh, i was looking at the indentation level. Sorry.#2019-12-2019:29lilactownyeah that’s confusing #diagram-noob#2019-12-2019:27lilactownhere’s what your bundles look like according to your example#2019-12-2019:29lilactownthis is AFAICT, I’m ready to be proved wrong#2019-12-2019:32lilactownthis is I believe what you want#2019-12-2019:32lilactownif you get a message saying that C is moved into main, then that means you are explicitly requiring C in A and B somewhere#2019-12-2019:34Drew VerleeTo be clear the A and B ns doesn't require (e.g (ns (:require [...C]))) C directly, that was a mistake in my example that i tried to explain above. They would both use the lazy-component to load C.#2019-12-2019:34lilactownthen I’m not sure why you are seeing messages about C being moved into main#2019-12-2019:37Drew VerleeI think its because if a module is shared, then by default it goes into the default module (e.g main) unless you explicitly say other modules depend-on it.#2019-12-2019:40lilactownthe only way a module can be shared is if you put it in a require in a namespace#2019-12-2019:40lilactownin both A and B#2019-12-2019:40lilactownif you are truly lazy loading it, it will not appear in any namespace requires in A or B modules. that includes any namespaces that app.A and app.B requires#2019-12-2019:45Drew VerleeThe two statements seem to imply you can't share and lazy load the same module. To share: ns require C in A and B To lazy: dont ns require C in A and B But i might be "unable to see the forset through the trees". That is, im misreading details and not letting the full picture lend context.#2019-12-2019:50lilactownyes that’s correct#2019-12-2019:50lilactownif you require a namespace, it must be statically available when your namespace is evaluated#2019-12-2019:50lilactownif you lazy-load it, then you don’t care that it’s available when your namespace is evaluated#2019-12-2019:51lilactownI guess I would ask the question: why would want to share and lazy load the same module?#2019-12-2020:05Drew Verlee> share and lazy load the same module? That isn't a goal in itself. I believe i understand, your saying that its typical to lazy load the components (A and B) (e.g lazy-load A) and have those depend on a shared module (C). But its not necessary to lazy load the shared module. If fact, the sharing is done by the Google Closure compiler which needs that static require to do its job.#2019-12-2020:08lilactownright, I mean it might be lazy-loaded but it doesn’t need to be. C will be moved into a module that A and B depend on#2019-12-2020:08lilactownI created a barebones example of this: https://github.com/Lokeh/module-example#2019-12-2020:09lilactownthe above is how you would do it if you wanted to split the C namespace from the main module#2019-12-2020:10lilactownyou have A, B, C all split and depending on main. A and B lazy-load C#2019-12-2020:10lilactownif you wanted C to be separate from the main bundle, but A and B require it statically, then it’s a little more complicated#2019-12-2020:13lilactownyou’d have to do something like this:#2019-12-2020:13lilactownthis is what I meant by “loading C will not happen automatically for you” if you lazy-load A and B, but they have a shared module C, then you need to load the shared module before A and B#2019-12-2020:32thheller@drewverlee @lilactown I'm too tired too go through your entire conversation but one thing that stands out to me is the confusion what :depends-on means. You need to differentiate between "depends on" and "uses".#2019-12-2020:32thheller> In this case it would seem wrong to say A depends on B because it doesn't necessarily contain what it needs to load.#2019-12-2020:33thhellerA uses B. B may not be aware of A at all.#2019-12-2020:33thhellercode-splitting in CLJS/Closure really doesn't make too much sense at the component level#2019-12-2021:44Drew VerleeThanks Heller. I understand. I dont want to eat up too much of anyones times. I plan on writting a blog post that outlines what i learned so hopefully it can be of help to others.#2019-12-2208:48royalaidHey @thheller, I am trying to include lottie via http://airbnb.io/lottie/#/web?id=html-player-installation but when I try to load a namespace requireing with lottie:
(ns animation
  (:require ["lottie-web" :refer [lottie]]))

(defn load-animation
  [props]
  (.loadAnimation lottie props))
I get back:
Duplicate let / const / class / function declaration in the same scope is not allowed.
Googling around led me to https://github.com/google/closure-compiler/issues/3098, so I tried adding {:output-wrapper true} to the build and it didn't change anything. I am guessing that i will just have to require the js directly in the HTML instead of via npm .
#2019-12-2210:00thheller@royalaid looks like the closure-compiler doesn't like
function EffectsManager(){}
function EffectsManager(data,element){
    var effects = data.ef || [];
    this.effectElements = [];
    var i,len = effects.length;
    var effectItem;
    for(i=0;i<len;i++) {
        effectItem = new GroupEffect(effects[i],element);
        this.effectElements.push(effectItem);
    }
}
#2019-12-2210:01thhellerworks fine if I delete the empty duplicate. maybe open an issue for the lottie-web repo. that duplicate declaration definitely doesn't need to be there#2019-12-2219:48gravHey! I've created an AWS Lambda handler with Shadow-cljs using the :node-library target. I compile with release and everything works as expected, except that instead of using (set! ... I needed to use (aset ... to mutate a specific property in the context object that the handler received. How come this is necessary? I googled the difference between the two, but I still fail to understand why aset is needed in my case. The specific property is "callbackWaitsForEmptyEventLoop". Printing out (.-callbackWaitsForEmptyEventLoop context) yields nil, whereas (aget context "callbackWaitsForEmptyEventLoop") yields true which is supposed to be the default value, which is what lead me on the right path.#2019-12-2222:11royalaidIn advance weird things can happen with .- style access#2019-12-2222:11royalaidSee https://github.com/binaryage/cljs-oops#externs-from-hell#2019-12-2222:13royalaidThe reason the aget works is because the string "callbackWaitsForEmptyEventLoop" isn't renamed but .-callbackWaitsForEmptyEventLoop almost definetly is during an :advanced compile which is what release does.#2019-12-2222:14royalaidI am not sure why set! and aset act differently but my hope is that it is really just the way you are trying to access the result that is causing the issue#2019-12-2222:14royalaidalso also you shouldn't be using aget and aset on object, see https://clojurescript.org/news/2017-07-14-checked-array-access#2019-12-2222:15royalaidhttps://github.com/appliedsciencestudio/js-interop is a great library for doing this kind of work FWIW#2019-12-2222:15royalaidcc @grav#2019-12-2311:57gravThanks for the pointers! Using a library isn't optimal for Lambdas, since I want to keep the code size down. Seems js-interop is using cljs.core/unchecked-set, which according to KLIPSE is compiled to foo["bar"] = 42. @thheller had another solution, involving sticking to .- notation, adding additional externs checking, and type-hinting with ^js, when the compiler is clueless. This seems to be the better option.#2019-12-2223:57Bravihi everyone. has anyone ever used framer-motion with shadow-cljs?#2019-12-2223:58BraviI cannot make <motion.div animate={{ scale: 0.5 }} /> this work anyhow.. 😕 this is how I import it:
["framer-motion" :refer [motion]]
this is how I’m using it
[:motion/div {:animate (clj->js {:scale 0.5})} "Hello"]
#2019-12-2300:46dpsuttonThat keyword doesn’t seem like it could possibly work#2019-12-2301:10royalaidI think you might want [motion/div {:animate (clj->js {:scale 0.5})} "Hello"] or even [motion/motion.div {:animate (clj->js {:scale 0.5})} "Hello"]#2019-12-2301:10royalaidBut not having the setup in front of me makes it difficult#2019-12-2301:11royalaidOne thing you can try is to inspect the object motion in the browser console and see what attributes are on there to call into#2019-12-2308:19fjolnein addition to @royalaid answer, there’s a good summary of programmatic vs data field access by David Nolen#2019-12-2308:59thheller@grav turn on externs inference and add ^js tags for things it warns about. see https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2019-12-2311:50gravAwesome, thanks!#2019-12-2309:00thheller@bravilogy reagent interop with JS component is done via [:> (. motion -div) ...]. the slash notation (eg. motion/div) only works for actual namespace aliases, so things using :as in :require (eg. (:require ["thing" :as alias])) not :refer#2019-12-2315:15mruzekwI’d like to try out the Patching Libraries feature mentioned here: https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries But I don’t see an example of how to do it. I’d like to patch com.fulcrologic.fulcro-native.alpha.components.#2019-12-2315:16mruzekwMy current src looks like
src
  main
    app
      ...
#2019-12-2315:17mruzekwWould I put com/fulcrologic/fulcro_native/alpha/components next to main or app?#2019-12-2315:18thhelleryou put it so it matches the filename on the classpath#2019-12-2315:18thhellerso assuming your source path is src/main then src/main/com/fulcro....#2019-12-2315:18mruzekwOkay, makes sense! I’ll try that out. Thanks#2019-12-2315:19mruzekwA great feature btw#2019-12-2315:19mruzekwI was so confused on how to do something like yarn link in the CLJS world#2019-12-2315:25mruzekwWorks! Thanks again#2019-12-2319:13aisamuHi! We might have run into a dashes-vs-underscores bug. The documentation states that we can access CLJS ns's on consumed JS files using a goog: prefix (i.e. import something from "goog:namespace") When we use such a JS file from Shadow and the CLJS ns contains dashes, things break.
;;;;;;;;;;;
;; company/name_with_dashes.cljs

(ns company.name-with-dashes)
(def ^:export Thing '...)

;;;;;;;;;;;
;; company/folder-with-dashes/helper.js
import {Thing} from 'goog:company.name-with-dashes'

;;;;;;;;;;;
;; company/component.cljs

(ns company.component
  (:require ["company/folder-with-dashes/helper.js" :as helper]))
While running tests involving company.component via :browser-test, shadow issues a warning:
shadow-cljs - failed to load module$node_modules$company$folder_with_dashes$helper
shadow.js.jsRequire @ js.js:71

failed to load company.component.js ReferenceError: with is not defined
    at Object.shadow$provide.module$node_modules$company$folder_with_dashes$helper (helper.js:xx)
    at Object.shadow.js.jsRequire (js.js:63)
    at Object.shadow.js.require (js.js:97)
    at eval (/js/cljs-runtime/company.component.js:xx)
    at eval (<anonymous>)
    at Object.goog.globalEval (test.js:827)
    at Object.env.evalLoad (test.js:2174)
    at test.js:2373
env.evalLoad @ test.js:2176
Digging into module$node_modules$company$folder_with_dashes$helper reveals:
...
var _immutable = require("module$node_modules$immutable$dist$immutable"),
_googCompany = global.company.name-with-dashes
                              ;; ^ can't have dashes on JS symbol, right?
Other than renaming the involved files, would there be a workaround for this?
#2019-12-2319:16thhellermaybe try _ instead of -? otherwise rename ...#2019-12-2319:20aisamuUsing dashes (e.g. import {Thing} from 'goog:company.name_with_dashes') fails with The required namespace "company.name_with_dashes" is not available, it was required by "..." 😕#2019-12-2319:21thhellerhmm yeah. feel free to open an issue, should be easy to fix#2019-12-2319:21thhellerjust won't get to it in the next few days#2019-12-2319:22aisamuOK! NP - you really shouldn't:christmas_tree:simple_smile !#2019-12-2319:26Eric IhliIs it expected that when I reload a ReactNative app in the emulator while connected to the app's repl that the repl will lose connection to the app and an npx react-native run-android will be required to get the repl back? Here's the workflow that I'm using.
bash$ npx react-native run-android
emacsλ (inf-clojure-connect "localhost" 5555)
shadow.cljs => (shadow/repl :app)
cljs.user => (+ 2 2)
4
;; Make some code changes and reload the app in the emulator to render them.
cljs.user => (+ 2 2)
;; Long delay
Timeout while waiting for REPL result.
Then the only way I've found to get the REPL working again is to re-launch the emulator with npx react-native run-android. It's a painfully slow development loop, so I feel like I'm doing something wrong.
#2019-12-2319:28thhellerits a bug in react-native android. it keeps the old websocket connections open so shadow-cljs can't tell that they are gone#2019-12-2319:29thhelleryou can try (shadow/repl-runtime-clear) in the CLJ REPL#2019-12-2319:30thhellerand then (shadow/repl :app) again#2019-12-2319:31thheller(shadow/repl-runtimes) should list all connected runtimes#2019-12-2319:31thhellerwhy are you reloading the app though?#2019-12-2319:31Eric Ihli👍 That worked. Thanks. Saved me a lot of time troubleshooting.#2019-12-2319:32thhellerhot-reload should take care of things?#2019-12-2319:33Eric IhliWould hot-reload make a difference? Wouldn't that cause me to get into this disconnected state every time I save a file rather than just when I manually reload?#2019-12-2319:33thhellernot the react-native hot-reload or live-reload#2019-12-2319:34thhellerthe one shadow-cljs provides#2019-12-2319:34thhellerhttps://github.com/PEZ/rn-rf-shadow#2019-12-2319:34thhelleror do you want an actual app reload?#2019-12-2319:36Eric IhliMaybe I don't need to reload as often as I was. Most of my reloads are when I get a runtime error and the screen pops up that says "esc to dismiss" and "rr to reload" and I just hit "rr" to reload.#2019-12-2319:37Eric IhliBut with shadow's autobuilding/live-reloading maybe I could just make the code change, save the file, and hit "esc"?#2019-12-2319:37thhellerhmm I actually don't know#2019-12-2319:37thhellerI don't do react-native development myself#2019-12-2319:37thhellerno idea if it can recover from errors#2019-12-2320:24Eric IhliLooks like it theoretically might be able to, but it's not working for me. https://facebook.github.io/react-native/docs/fast-refresh If you edit a module that only exports React component(s), Fast Refresh will update the code only for that module, and re-render your component. You can edit anything in that file, including styles, rendering logic, event handlers, or effects.#2019-12-2321:22theasp@thheller how should a build hook print to stdout? This appears to print nothing, but works!
(defn exec [cmd]
  (let [{:keys [exit out err]} (apply sh cmd)]
    (if (zero? exit)
      (when-not (str/blank? out)
        (println out))
      (println err))))

(defn nexe
  {:shadow.build/stage :flush}
  [state src dest]
  (case (:shadow.build/mode state)
    :release
    (let [cmd ["nexe" "--output" dest src]]
      (print (fmt "Executing: %s" cmd))
      (exec cmd))

    true)
  state)
#2019-12-2321:39theaspNevermind, it does print... Needed to restart the shadow-cljs server#2019-12-2322:13thheller@ericihli fast-refresh doesn't work for CLJS. if you've never seen the hot-reload from CLJS in action I'd suggest looking at an example that has it built-in#2019-12-2322:14Eric IhliThanks. I'm trying to spin up the app from the link you pasted above right now. I'll dig through that code before going back to my own project again.#2019-12-2322:15thhellerhttps://github.com/thheller/reagent-react-native#2019-12-2322:15thhelleranother example I made with just react-native, no expo#2019-12-2322:27sparkofreasonI'm trying to do the bare minimum to run some CLJS code in a REPL for a library I'm developing. Is there a good example project I can crib from for configuring using deps.edn and Atom/chlorine?#2019-12-2322:35mauricio.szaboI think shadow support deps.edn. As for Atom, you'll connect to a socket repl (Chlorine will probably detect the port) and then use "Connect Embedded" from the command pallette#2019-12-2322:45sparkofreasonI'm just missing something in the configuration. I was able to connect the socket REPL, executed "Connect Embedded", but trying to eval from a .cljs file gives an error about not being connected to a ClojureScript REPL.#2019-12-2323:12thheller@dave.dixon shadow-cljs node-repl or shadow-cljs browser-repl#2019-12-2323:13thhellerno clue how to connect to those using atom/chlorine though#2019-12-2323:13thhellerregular nrepl should work. when in CLJ you can select them via :node-repl or :browser-repl build ids#2019-12-2412:09mauricio.szaboChlorine connects to a socket-repl, and then you just run a command that will start the ClojureScript REPL (and then you'll be connected in both CLJ and CLJS#2019-12-2412:11mauricio.szaboNo need to configure any port on Shadow-CLJS side too, it'll detect the current port based on .shadow-cljs/socket.port (or something like that :))#2019-12-2323:13thhellerhowever that works in atom ..#2019-12-2323:28Eric IhliAh hah. Zeroing in on my hot-reload/repl disconnect woes. I see in your example app you have a way of storing a reference to the root and you just swap it out in the after-load handler.
(defonce root-ref (atom nil))
(defonce root-component-ref (atom nil))
(defn render-root [root]
  (let [first-call? (nil? @root-ref)]
    (reset! root-ref root)
    ;; ...
And then re-natal has something similar.
(def cnt (r/atom 0))
(defn reloader [] @cnt [core/app-root])
;; Do not delete, root-el is used by the figwheel-bridge.js
(def root-el (r/as-element [reloader]))
I didn't copy from an example and don't have anything like that in my code.
#2019-12-2416:44sparkofreasonI'm getting this, reporting an error with no info about the error. Tried running with --verbose, same result. Is there a log or something where I might find more info?#2019-12-2419:41thhellerweird. no clue why that would happen. it should be printing the cause message? might be a nullpointerexception? those sometimes don't have stacktraces#2019-12-2420:34sparkofreasonYeah, not sure. I'm doing some compile-time voodoo, and I think this occurs when the result of a macro expansion winds up being gobbledygook because the code wound up with the string representation of a function, like {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0d6e616267787f68236e627f68297d7f64637961634d3c6f6838393b6f38"}, :content ("[email protected]")}. Not clear why that error would get swallowed though.#2019-12-2423:55thhellerdon't do compile time voodoo. just sayin' 😛#2019-12-2518:04souenzzoHello. I'm wrinting a tutorial for beguinners to setup a shadow-cljs project. I removed clojure from my path and I'm trying to run shadow-cljs watch demo https://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code
> @ start /home/souenzzo/src/demo
> shadow-cljs watch demo

shadow-cljs - config: /home/souenzzo/src/demo/shadow-cljs.edn  cli version: 2.8.83  node: v13.4.0
shadow-cljs - starting via "clojure"
Executable 'clojure' not found on system path.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `shadow-cljs watch demo`
npm ERR! Exit status 1
Is clojure really needed?
#2019-12-2521:03thhelleronly if you configure it to be ...#2019-12-2521:04thhellerdon't configure it to use deps.edn then you don't need clojure#2019-12-2612:53Philipp SiegmantelHello, I'm getting an NullPointerException when I try to compile my tests. My build config is simply
:test {:target :karma
                 :test-dir "resources/public/js/karma"}
Same thing happens with :browser-test and :node-test. Stack trace:
NullPointerException: 
	shadow.build.targets.karma/configure (karma.clj:23)
	shadow.build.targets.karma/configure (karma.clj:18)
	shadow.build.targets.karma/process (karma.clj:115)
	shadow.build.targets.karma/process (karma.clj:111)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--14115 (build.clj:148)
	shadow.build/process-stage (build.clj:145)
	shadow.build/process-stage (build.clj:137)
	shadow.build/configure (build.clj:358)
	shadow.build/configure (build.clj:261)
	shadow.cljs.devtools.api/compile* (api.clj:311)
	shadow.cljs.devtools.api/compile* (api.clj:308)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:35)
	shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
	shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
	shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
	shadow.cljs.devtools.cli/main/body-fn--16982--auto----17573 (cli.clj:168)
	shadow.cljs.devtools.cli/main (cli.clj:167)
	shadow.cljs.devtools.cli/main (cli.clj:134)
	clojure.core/apply (core.clj:669)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/-main (cli.clj:221)
	shadow.cljs.devtools.cli/-main (cli.clj:219)
	clojure.lang.Var.invoke (Var.java:393)
	user/eval152 (form-init10054527494778132590.clj:1)
	user/eval152 (form-init10054527494778132590.clj:1)
	clojure.lang.Compiler.eval (Compiler.java:7177)
	clojure.lang.Compiler.eval (Compiler.java:7167)
	clojure.lang.Compiler.load (Compiler.java:7636)
	clojure.lang.Compiler.loadFile (Compiler.java:7574)
	clojure.main/load-script (main.clj:475)
	clojure.main/init-opt (main.clj:477)
	clojure.main/init-opt (main.clj:477)
	clojure.main/initialize (main.clj:508)
	clojure.main/null-opt (main.clj:542)
	clojure.main/null-opt (main.clj:539)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
Googling didn't help much. Is this a known issue or should I file a bug report?
#2019-12-2614:07aisamuJust to be sure, did you follow https://shadow-cljs.github.io/docs/UsersGuide.html#target-karma? (Install karma, create a karma.conf.js, etc)#2019-12-2614:41Philipp SiegmantelI used the re-frame template and just reinstalled karma. Still get the NPE 😞#2019-12-2615:15aisamuDo you have an url for the template? (And the exact options you've used, if applicable)#2019-12-2615:21aisamuFrom https://shadow-cljs.github.io/docs/UsersGuide.html#_the_build, :output-to is not optional for :karma builds, and the NPE indeed points to that being the case (https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L23)#2019-12-2807:32Philipp SiegmantelThanks the npe went away woth an output-to argument.#2019-12-2821:33gravMessing with typehinting and the aws sdk. I'm trying to instantiate an SES thingy like this
(def ^js aws (js/require "aws-sdk"))
(defn my-handler ...
  (let [ses (aws.SES.)]
...
which on runtime errors out with "TypeError: wn.ld is not a constructor". Using shadow-cljs' simple externs, I can get it to work by simply adding the string "`SES`" to externs/my-build.txt, but I'd really like to get it working using typehinting. So far, I've tried:
(let [ses ^js (aws.SES.) ...
and
(let [ses (new ^js aws.SES)
but to no avail
#2019-12-2821:54martin hablakhello, is it possible to use nrepl-refactor or any kind of refactoring with shadow-cljs? (i’m using emacs)#2020-12-2921:04aisamuYes! Here's an example setup if you're using tools-cli:
;; ~/.clojure/deps.edn
{:deps {nrepl/nrepl {:mvn/version "0.7.0-alpha3"}
        cider/cider-nrepl {:mvn/version "0.23.0-SNAPSHOT"}
        refactor-nrepl {:mvn/version "2.5.0-SNAPSHOT"}}}

;; ~/.nrepl
{:middleware [refactor-nrepl.middleware/wrap-refactor]}
#2019-12-2822:30thheller@grav use (:require ["aws-sdk" :as aws]) in your ns and then (aws/SES.) that should take care of it#2019-12-2822:41grav@U05224H0W Thanks a bunch. Externs inference is black magic to me ... good to have a wizard at hand 🙂#2019-12-2822:31thheller@martin.hablak no clue. I don't use emacs but I'd guess that adding the dependency+middleware should make it work.#2020-12-3018:15pezI am trying to get this template project over to shadow-cljs, but am failing: https://github.com/enterlab/rente#2020-12-3018:16pezI’m at where I get these errors in the js console:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (style.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (main.js, line 0)
[Error] Refused to execute  as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type.
[Error] ReferenceError: Can't find variable: goog
	Global Code (0.0.0.0:14)
#2020-12-3018:17pezMy shadow-cljs looks like so:
{:dependencies
 [[org.clojure/core.async "0.4.490"]
  [com.stuartsierra/component "0.4.0"]
  [environ "1.1.0"]
  [ch.qos.logback/logback-classic "1.2.3"]
  [org.clojure/tools.logging "0.4.1"]

  [ring/ring-core "1.7.1"]
  [ring/ring-defaults "0.3.2"]
  [compojure "1.6.1"]
  [http-kit "2.4.0-alpha2"]

  [com.taoensso/sente "1.13.1"]
  #_[com.cognitect/transit-clj "0.8.313"]
  #_[com.cognitect/transit-cljs "0.8.256"]

  [org.clojure/tools.namespace "0.3.0-alpha4"]
  
  [reagent "0.8.1"]
  [org.webjars/bootstrap "4.2.1"]]

 :source-paths
 ["src" "dev" "resources/public"]

 :builds
 {:app {:target :browser
        :output-dir "resources/public/js"
        :asset-path "/public/js"
        :modules {:main {:entries []}}}}}
#2020-12-3020:08thheller@pez :asset-path looks incorrect. the server is likely using resources/public as a root? or probably should be?#2020-12-3020:21pezHmm, I have tried that, but going at it again, if I change the source-paths entry to just "resources", I get rid of the 404 errors. But now shadow-cljs shows a “Stale client” error.#2020-12-3020:23thhellerthe source paths in shadow-cljs are completely irrelevant to the server part#2020-12-3020:23thhelleryou are still running that through lein I presume?#2020-12-3020:25pezWithout the source path entry I git nil for any ( …) calls.#2020-12-3020:25thhellerwhat are you using for the server?#2020-12-3020:25pezTrying with only shadow, so no lein involved.#2020-12-3020:26thhellerI don't get the point of that template then?#2020-12-3020:26pezIt is ring with httpkit.#2020-12-3020:26thhellerand also there is no http config in the config file you pasted#2020-12-3020:26thhellerok so you are running the server through shadow-cljs run?#2020-12-3020:27pezactually trying with watch.#2020-12-3020:27thhelleryou lost me ... watch compiles CLJS ... it doesn't run a CLJ server#2020-12-3020:27thhellerdo you use :dev-http? or a http config in :devtools?#2020-12-3020:28thhellershadow-cljs is not made for CLJ development. you should probably be running it via lein or clj#2020-12-3020:29thhellerbut I don't even understand what you are trying right now#2020-12-3020:31pezMe neither, it seems. 😄 The server starts though… But I’ll go back to lein for that then.#2020-12-3020:32thhellerHOW are you starting it though?#2020-12-3020:32thhellerdid you add something to the config that isn't in the one pasted above?#2020-12-3020:33pezNothing added to the shadow-cljs.edn…#2020-12-3020:33thhellersorry then I don't know how you get a server running at :8888#2020-12-3020:33thhellermaybe something "old" leftover running?#2020-12-3020:34pezNo, that’s not it. If I quit the shadow-cljs process I have no server…#2020-12-3020:36pezDoes shadow see that there is a project.clj file there and using it somehow?#2020-12-3020:38pezNope. I can remove that and the server is still started…#2020-12-3020:39thhellerdo you have a user.clj that starts it?#2020-12-3020:40pezI hope not. Let me check…#2020-12-3020:41pezWell, yes, that’s it.#2020-12-3020:42pezhttps://github.com/enterlab/rente/blob/master/dev/user.clj#2020-12-3020:44thhellerthats not starting the server on its own?#2020-12-3020:48pezCorrect, I issue (run) as part of the jack-in. This is how the template is wired. I had forgotten about that part…#2020-12-3020:50pezI should probably go back to letting Leiningen deal with the server…#2020-12-3020:51thhellerthat doesn't do anything different really ... you should maybe try to understand what is going on though 😉#2020-12-3020:51thhellerbut yes .. use lein for the server#2020-12-3020:51thhellerrun it separately from shadow-cljs#2020-12-3020:55pezI expect to still have the stale client problem if I wire it up that way, but anyway.#2020-12-3020:57thhellerstale client likely means you are serving files from the wrong directory#2020-12-3020:57thhellerso sort out your paths properly. this template seems rather messy to me since I can't even figure out which paths it is serving#2020-12-3023:50pezI got it working. Not sure what was tripping things up, but cleaning the project seemed to have to do with it, Anyway, leaving things with using only shadow-cljs in dev, for now. I’m not doing anything fancy enough to need Leiningen, yet.#2020-01-0217:56royalaid@thheller is there a recommended way to build templates with shadow similar to create-cljs-app?#2020-01-0218:22thhellerdunno. I rarely use templates#2020-01-0218:22thheller$ npx create-cljs-project acme-app is pretty much all I have used since making it#2020-01-0218:23thhellerbut its only a basic project scaffold. no actual "template" stuff#2020-01-0220:01royalaidI have been playing around with a bunch of stuff that requires a fair bit of scaffolding, service workers, and want to make the setup process easier for people in the future#2020-01-0220:01royalaidSo I wanted to make sure that if tools existed I aligned with it#2020-01-0310:22tianshuFound something interest, with target :browser.
(defn foo [i]
  (throw (ex-info "hello" {:a 1})))
I can't get a meaningful stacktrace for this code, but I can get one for this
(defn foo [i]
  (throw (js/Error. "hello")))
#2020-01-0310:25thhellerand what is the problem?#2020-01-0310:26tianshuthe problem is I don't know where the error comes if that is an ex-info.#2020-01-0310:27thhellerand do you have an example of that?#2020-01-0310:27thhelleras far as I know ex-info only adds 2 or 3 elements to the stacktrace#2020-01-0310:27thhellerbut preserves the original#2020-01-0310:27tianshuyes, wait a moment.#2020-01-0310:29tianshuThis is the error for js/Error
main.js:2218 failed to load fullstack_explore.app.js Error
    at Object.fullstack_explore$app$foo [as foo] (app.cljs:6)
    at eval (app.cljs:8)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:836)
    at Object.env.evalLoad (main.js:2216)
    at main.js:2396
And this is the error for ex-info
failed to load fullstack_explore.app.js #error {:message "", :data {}}
env.evalLoad @ main.js:2218
(anonymous) @ main.js:2396
#2020-01-0310:29thhellerthat is from the REPL?#2020-01-0310:30tianshuNo, both are not. write it in the file, after compiled, reload the browser.#2020-01-0310:30tianshu
(defn foo [] (throw ...))
(foo)
The code looks like this, nothing more.
#2020-01-0310:31thhellererrors while loading are problematic#2020-01-0310:31thhellerdon't trigger that while loading#2020-01-0310:31thhellerdon't do anything while loading in general#2020-01-0310:31thheller
(defn foo [] (throw ...))

(defn ^:dev/after-load test-me []
  (foo))
#2020-01-0310:32thhellertry that. maybe thats better#2020-01-0310:33tianshutried, the result is basically the same#2020-01-0310:33tianshuthere is a difference, the stacktrace for ex-info becomes much longer#2020-01-0310:34tianshubut it's still meaningless for debug#2020-01-0310:35tianshu#2020-01-0310:35thhellerhmm right thats still during load#2020-01-0310:36tianshu#2020-01-0310:36tianshuand this one is for js/Error.#2020-01-0310:36thheller
(defn foo [] (throw (ex-info "foo" {:x 1})))

(js/setTimeout foo 1000)
#2020-01-0310:36thhellerthis shows the correct trace#2020-01-0310:36thhellerI don't know why ex-info behaves that way. nothing I can control or shadow-cljs does to it.#2020-01-0310:37tianshuyes, this show the correct trace#2020-01-0310:38tianshuI think I need to take a look at how it behavior in other environment, in cljsbuild#2020-01-0310:40thhellerthe loading is different so you'll probably get a different error#2020-01-0310:40thhelleryou can try setting :devtools {:loader-mode :script}#2020-01-0310:40thhellerthat loads things like other CLJS would and may throw a better error#2020-01-0310:40thhellerjust don't throw errors at load time and you'll be good 😉#2020-01-0310:49tianshuI found this because I tried to use some spec, a library called speced.def use ex-info for it's error.#2020-01-0310:50tianshuI found cljs.main doesn't have this issue.#2020-01-0310:50thhellerand did you try the different :loader-mode?#2020-01-0310:53tianshuwith :loader-mode :script it works correctly.#2020-01-0310:54tianshuohhh, maybe it's because the cljs-devtools...#2020-01-0311:00tianshuThe ExceptionInfo has a field for stacktrace, without devtools you get found the key :stack.#2020-01-0311:00tianshuis that because ExceptionInfo should extends something to make it display correctly. But when the error raised, this haven't been done.#2020-01-0311:02thhellerif you trigger the error during load then :loader-mode :script is basically what other CLJS does#2020-01-0311:02thhellerthe "optimized" :loader-mode :eval (the default) loads things differently and thus may change the stacktrace#2020-01-0311:03thhellerexceptioninfo does extend error and stuff#2020-01-0311:03thhellerI don't know why the error is displayed differently ... I can only tell you that loading is different#2020-01-0311:03tianshuokay#2020-01-0505:34vemvI could repro the behavior tianshu describes, and documented it in https://github.com/nedap/speced.def/issues/100#issuecomment-570865803 . It seems pretty unfortunate that when using a standard mechanism such as ex-info, error reporting will become drastically worse, if the error happened on load. Needless to say there are many cljs libs that can throw a ex-info at any point. i.e. this is not specific to my library. @ thheller - are you 100% sure this is not something shadow-cljs can handle? Otherwise, it'd seem worth it to create an issue in the cljs compiler, or such.#2020-01-0509:53thheller@vemv the issue is fixed by setting :devtools {:loader-mode :script} in your build config#2020-01-0514:13vemvI got that point, but given :eval is the default, people can get a bad experience by default if using libraries such as mine Also, this seems an easy-to-forget intricacy#2020-01-0515:17thhellerwell the problem is in throwing exceptions at load time. that is never good. with eval the source maps are likely loaded differently and maybe the browser then has trouble dealing with the stacktraces#2020-01-0515:18thhellerI really do not know. I could also just not catch any exceptions but that confused people more in the past#2020-01-0515:36vemv> that is never good. it is good if you are checking :pre and :post conditions, or similar mechanisms (spec-related solutions) I do not have an opinion on the right solution (for one thing I am unfamiliar with many compiler or shadow-cljs intricacies), but I'd like to point out that this is a reasonable problem to have. It's not urgent for me either, but I'd be happy if this was tracked in the right place (shadow-cljs or clojurescript).#2020-01-0517:22thhellerthe way I see it its a trade-off. faster loading via eval or slower loading but accurate errors during loading#2020-01-0517:22thhelleras far as I can tell runtime makes no difference its just the load time that is problematic#2020-01-0517:23thhellerI don't know what to do either. errors during load are problematic anyways since the program cannot continue after it. it gets into an undefined state so you have to reload the page anyways#2020-01-0517:24vemv> as far as I can tell runtime makes no difference its just the load time that is problematic scienced it myself, correct :)#2020-01-0517:29vemv> I don't know what to do either. errors during load are problematic anyways since the program cannot continue after it. it gets into an undefined state so you have to reload the page anyways I can see how there could be different programmer preferences around this. Personally I have no problem whatsoever with hitting Cmd + R if my program was so broken that it threw an exception on init. Maybe worth considering - document :script and :eval? Would be nice if programmers were aware of these tradeoffs upfront. At the same time, the root of the problem seems to lie in the js/Error <-> ex-info difference. By intution, there shouldn't be one. Would be interesting to determine what component is at fault (shadow, the compiler, etc)#2020-01-0518:11thhellershadow or the compiler isn't involved in this. it can only be the way ex-info is implemented#2020-01-0518:12thhellerbut it may just be a restriction of the javascript runtime that it only supports stacktraces for regular js/Error until it had a change to load the source maps and stuff#2020-01-0518:12thhelleryou can try subclassing Error and see if you can get it to work#2020-01-0518:12thhellershadow-cljs does nothing to ex-info in any way#2020-01-0518:18vemvalright! thanks for the clarification. > you can try subclassing Error and see if you can get it to work yes, I did try changing the error being thrown in my lib https://gist.github.com/vemv/e9a7534a5bc7f277395add3e7c23a291 , with success. However, since many things can throw ex-info at any point, probably I won't end up changing my thrown exceptions. Would not be a 100% solution. documenting the loader modes as mentioned might do the trick.#2020-01-0518:18thhellerwhen exactly does your error happen?#2020-01-0518:19thhellerlook like its your init fn#2020-01-0518:19thhellerso you can do it async whatever that is doing#2020-01-0518:20thheller(defn init [] (js/setTimeout foo 0))#2020-01-0518:20thhellerinstead of calling (foo) directly. or whatever you are doing#2020-01-0518:21vemvthe use case is: in a cljs app, I add 'spec checking' to defns somehow. could be :pre or instrumentation If for any reason (like programmer error) the specs fail, an error will be thrown during load time. seems a quite likely possibility regardless of the specific chosen 'spec checking' library#2020-01-0518:23thhelleryes. the problem is load time .. by making the call async you get out of load time#2020-01-0518:23thhellerfrom the stacktrace it looks like its your :init-fn call which is the LAST thing during load time#2020-01-0518:23thhellerso you have full control over when the error actually occurs#2020-01-0518:24vemv(defn init [] (js/setTimeout foo 0)) is interesting, however I can't/shouldn't control how consumers of my library structure their applications Documenting this intricacy seems far leaner/cleaner than suggesting workarounds or doing a best-effort approach to replacing ex-info -> js/Error everywhere. Don't you agree?#2020-01-0518:46thhellerI don't know. I never had this issue before .. I'll think about it#2020-01-0704:06tianshuis the async load behaves similar with adding a script tag in document?
#2020-01-0706:48thhellernot sure what you mean? which "async load"?#2020-01-0707:22tianshuI mean run the code in a js/setTimeout.#2020-01-0707:23tianshuanother thing I notice is that eval code in the repl facing the same problem. I can only get the meaningful error stack with js/Error.#2020-01-0707:27thhellerlikely a problem with eval then#2020-01-0707:28tianshuyes, problem exist even use :script loader-mode.#2020-01-0707:29thhellerthe loader mode only affects actual loading of code#2020-01-0707:29thhellerand the one using :script doesn't eval .. so makes sense#2020-01-0707:30tianshuyes, so this is a problem with eval code, not about the loader-mode.#2020-01-0707:30thhellerseems like it yes#2020-01-0516:46Kamila HerkováI am trying to import TextField from Material-UI. I am requiring using following code
(:require ["@material-ui/core/TextField" :default TextField])
However the symbol TextField is undefined and it shows following error:
TypeError: Cannot read property 'default' of undefined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:55)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at 
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at 
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
Please could you help me to figure this out.
#2020-01-0517:24thheller@kamila.herkova try shadow-cljs browser-repl and (require '["@material-ui/core/TextField" :as x]) then x or (js/console.dir x) or so#2020-01-0517:25thhellerJS libs are very inconsistent regarding :default#2020-01-0517:26thhellerit looks like :default should work though#2020-01-0517:27thhellermight be a REPL problem. try loading the file normally and see if it works then#2020-01-0517:42Kamila HerkováAfter running x it outputs this:
== JS EXCEPTION ==============================                                                                          
ENCODING FAILED, check host console                                                                                     ==============================================     
#2020-01-0518:02knubieI got the same error recently when running (remove [:a :b] #{:a})#2020-01-0518:08thheller@kamila.herkova that means it can't print the object. try (js/console.dir x) or (js/console.log x)#2020-01-0518:15Kamila HerkováAfter running (js/console.dir x) it returns nil .#2020-01-0518:17knubie@kamila.herkova Does it print nil in the developer tools js console?#2020-01-0518:21thhellerdir returns nil yes, check the browser console instead#2020-01-0518:22thhellerFWIW :default works for me#2020-01-0518:26Kamila HerkováIn browser console this is returned:
Object
default: [Exception: TypeError: Cannot read property 'default' of undefined at Object.get [as default] (node_modules/@material-ui/core/TextField/index.js:1:336) at Object.invokeGetter (<anonymous>:1:142)]
__esModule: true
get default: ƒ ()
length: 0
name: "get"
arguments: null
caller: null
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: index.js:11
[[Scopes]]: Scopes[2]
__proto__: Object
#2020-01-0518:47thhelleryeah there is had a default property#2020-01-0518:47thhellerso (require '["@material-ui/core/TextField" :default TextField]) and TextField should be working fine#2020-01-0518:48thhelleralthough it is weird that it is showing `default: [Exception: TypeError: Cannot read property 'default' of undefined at Object.get [as default] (node_modules/@material-ui/core/TextField/index.js:1:336) at Object.invokeGetter (<anonymous>1️⃣142)] ` for you#2020-01-0518:48thhellerI just get the regular property#2020-01-0518:49thhellerdunno why that might be though#2020-01-0518:53Kamila HerkováThe problem is that this is the printout after running (require '["@material-ui/core/TextField" :default TextField]) .#2020-01-0518:56thhellerdon't try printing it ...#2020-01-0518:57thhellerjust inspect it in the console. react uses js/Symbol and those aren't printable by default#2020-01-0518:57thhellerso it doesn't work in the REPL#2020-01-0520:03Kamila HerkováThis a minimal example of code where the problem occurs:
(ns project.text-field
  (:require ["@material-ui/core/TextField" :default TextField]))

(defn text-field []
  (js/console.log TextField)
  [:div]
And the following stacktrace:
#2020-01-0520:32thheller@kamila.herkova can't tell what isRequired is supposed to be but it might be caused by a dependency conflict. thats not so easy to debug unfortunately. for me it works in an empty test project so that makes dependency conflict more likely#2020-01-0600:59mpostmaI am using the reagent shadow-cljs template, but when building for release, the app is not mounted (the content of https://div.app is not replaced with the app content). In order to make it easier to debug, I have tried with the template alone, just building it to see if i had made a mistake somewhere, but I get the same result... So i guess there is someething wrong with the template... Is there anything wrong with my shadow-cljs.edn ?
{:lein         true
 :source-paths ["src"]
 :builds       {:app {:target     :browser
                      :output-dir "resources/public/js"
                      :asset-path "/js"
                      :modules    {:app {:entries [psw.core]}}
                      :devtools   {:after-load psw.core/mount-root}}}
 :dev-http     {3000 {:root    "resources/public"
                      :handler psw.handler/app}}}
I ran npx shadow-cljs release app please excuse my noobness :)
#2020-01-0600:59mpostmaAlso I get no message whathowever from the console, so I have no idea where to look#2020-01-0601:45mpostma#2020-01-0605:12royalaid@thheller usability question. I have a bunch of AWS javascript lambda's that are using shadow and each one runs its own repl with it's own dependencies. Is there a good clean way to work like this? I feel like I need to build something to manage all the REPLs.#2020-01-0609:47thheller@postma.marin where is your init! fn called? assuming from your HTML somewhere?#2020-01-0609:48thheller@royalaid work like this with what?#2020-01-0610:24mpostma@thheller you mean I should do something like :modules {:app {:entries [ydfg.core/init!]}}, ? because it causes that:
[markdown-to-hiccup "0.6.2"]
Invalid configuration
-- Spec failed --------------------

  {:target ...,
   :output-dir ...,
   :asset-path ...,
   :modules {:app {:entries [ydfg.core/init!]}},
                             ^^^^^^^^^^^^^^^
   :devtools ...,
   :build-id ...}

should satisfy

  unquoted-simple-symbol?

or

  string?
#2020-01-0610:25mpostmamy html is just this:
{:type :dtd, :data ["html" nil nil]}
#2020-01-0610:25thhellerno. in your current setup you have a init! fn in psw.core#2020-01-0610:26thhellerare you sure psw.handler/app emits that html?#2020-01-0610:26thhellersure you can change your config to call the init-fn ... but first you should figure out why it is different from dev/release in the first place#2020-01-0610:26thhellerunderstand your setup first ... then adjust it#2020-01-0610:27thhellersomething appears to be calling the init! if it works in dev mode?#2020-01-0610:28thhelleror does it not work at all? judging from your "when building for release" I assumed it works in dev#2020-01-0610:29mpostmawell there is a weird behaviour in dev mode, where I have to specify a route other than "/" the first time it is lauched for it to start, but I read that it might just be a server config issue + this trick don't work in release#2020-01-0610:29thhellerso you likely just want :modules {:app {:init-fn psw.core/init!}} in your config#2020-01-0610:31mpostmaif a do that it causes this compile error
Invalid configuration
-- Spec failed --------------------
  {:target ...,
   :output-dir ...,
   :asset-path ...,
   :modules {:app {:entries [ydfg.core/init!]}},
                             ^^^^^^^^^^^^^^^
   :devtools ...,
   :build-id ...}
should satisfy
  unquoted-simple-symbol?
or
  string?
#2020-01-0610:31thhelleryou didn't do what I pasted#2020-01-0610:32mpostmaoh yes, my bad#2020-01-0610:35mpostma@thheller thank you very much! it works :+1: have a nice day 🙂#2020-01-0614:18Vít KaliszI am trying wrap TextField a Material-UI component to use in my project called Orgpad. I have this minimal project here: https://github.com/vitkalisz/shadow-cljs-materialui.git where everything works just fine. However when doing the same in Orgpad, I get some ?dependency problem? screenshotted below, which persists even after I reduce the project to a minimal version similar to that in the example. (I am just rendering a TextField , I have commented out every other namespace - leaving just the one rendering the TextField, I have reduced shadow-cljs.edn to this:
{:source-paths ["src"]
 :dependencies [[reagent "0.9.0-rc4"]]
 :nrepl        {:port 9000}
 :builds       {:client {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :modules          {:main {:init-fn orgpad.client.core/init}}
                         :compiler-options {:infer-externs :auto}
                         :devtools         {:after-load orgpad.client.core/mount-root
                                            :watch-dir  "resources/public"}}}}
dependencies in package.json to this:
"dependencies": {
    "@material-ui/core": "^4.8.0",
    "create-react-class": "^15.6.3",
    "react": "^16.12.0",
    "react-dom": "^16.12.0"
  }
I ran npm install, npm clean-install and restarted shadow-cljs) Would somebody please help me figure out why there is this problem?
#2020-01-0614:47thheller@vitek.kalisz and the code? it appears that you are doing something like [foo] where foo is nil#2020-01-0614:49thhellerthe error you posted is not from the code you posted? (the code you posted compiles and runs fine for me)#2020-01-0615:40Adam BergmanHi!  I would be much helpful if anyone could point me in the right direction with this :)  I have made an new project with “lein new luminus adambergmanio +jetty +h2 +re-frame +reitit +shadow-cljs” When I try to run “lein uberjar” I get this exception:
clojure
[:app] Compiling ...
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
    clojure.lang.Reflector.getInstanceField (Reflector.java:397)
    clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
    shadow.build.closure/js-error-xf/fn--11573 (closure.clj:536)
    clojure.core/map/fn--5862/fn--5863 (core.clj:2742)
    clojure.core.protocols/iter-reduce (protocols.clj:49)
    clojure.core.protocols/fn--8140 (protocols.clj:75)
    clojure.core.protocols/fn--8140 (protocols.clj:75)
    clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
    clojure.core/transduce (core.clj:6884)
    clojure.core/into (core.clj:6899)
    clojure.core/into (core.clj:6887)
    shadow.build.closure/log-warnings (closure.clj:1081)
    shadow.build.closure/log-warnings (closure.clj:1077)
    shadow.build.closure/log-warnings (closure.clj:1079)
    shadow.build.closure/log-warnings (closure.clj:1077)
    shadow.build.closure/optimize/fn--11790 (closure.clj:1185)
    shadow.build.closure/optimize (closure.clj:1170)
    shadow.build.closure/optimize (closure.clj:1161)
    shadow.build.api/optimize (api.clj:268)
    shadow.build.api/optimize (api.clj:262)
    shadow.build/optimize (build.clj:411)
    shadow.build/optimize (build.clj:403)
    shadow.cljs.devtools.api/release* (api.clj:350)
    shadow.cljs.devtools.api/release* (api.clj:336)
    shadow.cljs.devtools.cli/do-build-command (cli.clj:29)
    shadow.cljs.devtools.cli/do-build-command (cli.clj:26)
    shadow.cljs.devtools.cli/do-build-commands (cli.clj:51)
    shadow.cljs.devtools.cli/do-build-commands (cli.clj:40)
    shadow.cljs.devtools.cli/main/body-fn--16106--auto----16696 (cli.clj:168)
    shadow.cljs.devtools.cli/main (cli.clj:167)
    shadow.cljs.devtools.cli/main (cli.clj:134)
    clojure.core/apply (core.clj:669)
    clojure.core/apply (core.clj:660)
    shadow.cljs.devtools.cli/-main (cli.clj:221)
    shadow.cljs.devtools.cli/-main (cli.clj:219)
    clojure.lang.Var.invoke (Var.java:388)
    user/eval140 (form-init5608872905668697635.clj:1)
    user/eval140 (form-init5608872905668697635.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:7177)
    clojure.lang.Compiler.eval (Compiler.java:7167)
    clojure.lang.Compiler.load (Compiler.java:7636)
    clojure.lang.Compiler.loadFile (Compiler.java:7574)
    clojure.main/load-script (main.clj:475)
    clojure.main/init-opt (main.clj:477)
    clojure.main/init-opt (main.clj:477)
    clojure.main/initialize (main.clj:508)
    clojure.main/null-opt (main.clj:542)
    clojure.main/null-opt (main.clj:539)
    clojure.main/main (main.clj:664)
    clojure.main/main (main.clj:616)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)
```
#2020-01-0615:41thheller@adambergman that is caused by a dependency conflict on the closure-compiler version#2020-01-0615:42thhellershadow-cljs expects these versions but you seem to be ending up with different ones#2020-01-0615:42thheller
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-01-0615:43thheller(happens when you use deps.edn or project.clj and include conflicting dependencies)#2020-01-0615:47Adam Bergman@thheller ah ok! thank you very for instant reply! (and for the work you are putting into shadow-cljs ^^)#2020-01-0615:48Adam Bergmanvery much*#2020-01-0616:36Adam BergmanHi again, sorry but I still have trouble fixing it. It seems that re-frame and reagent was the conflicting dependencies. At first I got this message: NPM dependency “react” has installed version “16.8.6" “16.9.0” was required by jar:file:/Users/adambergman/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs NPM dependency “react-dom” has installed version “16.8.6” “16.9.0" was required by jar:file:/Users/adambergman/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs [:app] Compiling ... IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError then I checked which reagent version (16.9.0) that was used in the latest re-frame version (0.11.0-rc3) and changed the re-frame to this version. Then I changed react and react-dom versions to “16.9.0”. When I run “lein uberjar” again after this I still get “IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError” but it is not complaing on different versions or anything like that.  Is there some way to create a new luminus project that works out of the box? Like using some version that is confirmed to work   Sorry for the inconvenience, I am new to clojure(script) and just trying to get get something running :D#2020-01-0616:39Adam BergmanI meant to say that I changed re-frame version to latest version and also changed reagent version to the version that was stated in re-frames deps.clj#2020-01-0616:41thhellerreagent and re-frame have nothing to do with this#2020-01-0616:41thhellerit is striclty and incompatile closure-compiler version#2020-01-0616:42thhellerone of the reasons I recommend running shadow-cljs standalone (no deps.edn/project.clj) so you don't have to deal with this crap#2020-01-0616:43thhelleryou can just add the dependencies I pasted above to you project.clj :dependencies list#2020-01-0616:43Adam Bergmanoh ok I have no idea what I am doing 🙂 ok I just tried to get an “template” app up and running using luminus.#2020-01-0616:44Adam Bergmanby running standalone how would I compile it#2020-01-0616:44Adam Bergmanthanks again i will try!#2020-01-0616:45thhellermaybe the luminus template is a bit out of date. I don't know any of the details there#2020-01-0616:45Adam Bergmanso i should use shadow-cljs separeate#2020-01-0616:45Adam Bergman?#2020-01-0616:45thhelleryou can use lein ... that is totally fine ... BUT then you have to sort out these kind of dependency conflicts#2020-01-0616:45thhellerif you use shadow-cljs.edn the tool sorts those out for you for the most part#2020-01-0616:46thhelleryou can run lein deps :tree and resolve the conflicts#2020-01-0616:46Adam Bergmanah ok!#2020-01-0616:46thhellerby either adding the :exclusions or adding the proper versions of the dependencies I pasted above#2020-01-0616:47Adam Bergmani will try with these dependencies first,#2020-01-0616:48Adam Bergmanthanks!#2020-01-0617:01Adam Bergmanit worked fine with the dependencies you provided 🙂 !#2020-01-0701:41knubieHas anyone gotten react native to work with shadow-cljs without expo?#2020-01-0706:48thheller@steedman87 sure. see https://github.com/thheller/reagent-react-native#2020-01-0711:31Eric IhliYeah I'm using it. Running into any particular issue @steedman87?#2020-01-0714:22knubieWas running into some issues / confusion around how to structure the app. This example project is really helpful, thanks @thheller!#2020-01-0716:05thhellerhttps://clojure.org/news/2020/01/07/clojure-2020-survey#2020-01-0716:35knubieRunning into another react-native issue that may not be specific to react native.#2020-01-0716:35knubieI’m trying to use this library: https://github.com/JulianBirch/cljs-ajax#2020-01-0716:36knubieWhich has this bit of code: https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs#L29-L34#2020-01-0716:36knubieThe conditional at the top should be false (because cljs.core/*target* returns “react-native”#2020-01-0716:37knubiebut I’m still getting an error when running my code: Unable to resolve module xmlhttprequest from …#2020-01-0716:38knubieI’m pretty sure that snippet of code is the culprit because I copy and pasted it into my code without including the lib and got the same error#2020-01-0716:38knubieReact native comes with xmlhttprequest, so the else branch should be able to run find (https://facebook.github.io/react-native/docs/network.html)#2020-01-0716:51thhellerrequire is a compile time construct in react-native#2020-01-0716:51thhellertherefore the compiler (metro) will try to resolve it and fail at compile time. it never gets to runtime.#2020-01-0716:52thhellerthere might be some way to tell metro to ignore it but I don't know. check with someone that actually uses react-native 😛#2020-01-0716:58knubiethat makes sense, thanks. I’ll do some more digging#2020-01-0717:00knubiemaybe it’s possible to just make a shim somehow?#2020-01-0717:02knubieMaybe using this: https://facebook.github.io/metro/docs/en/configuration#extranodemodules#2020-01-0717:04danielnealstrange, for me js/XMLHttpRequest returns the right thing#2020-01-0717:04danielnealand that snippet of code takes the correct branch#2020-01-0717:04danielnealwhich version of react native are you on?#2020-01-0717:06thhellerthe isn't about js/XMLHttpRequest at all#2020-01-0717:06thhellerthis is about react-native metro trying to include the (js/require "xmlhttprequest") since its done at compile time and it doesn't recognize the conditional#2020-01-0717:07danielnealah of course#2020-01-0718:41knubieCreating a shim and declaring it in extraNodeModules in metro.config.js seems to have done the trick.#2020-01-0719:03Brian AbbottDo users of Shadow-CLJS also integerate with FigWheel?#2020-01-0719:03dpsuttonno need#2020-01-0719:03Brian Abbottor do we see it as one vs the other?#2020-01-0719:04Brian Abbottwell, fig has the cool dom updater. But, maybe Shadow does that as well?#2020-01-0719:04dpsuttonyup#2020-01-0719:04lilactownshadow-cljs includes the same functionality as figwheel#2020-01-0719:05Brian AbbottOkay, good to know#2020-01-0719:05Brian Abbottwhen would one choose to use one over the other?#2020-01-0719:05dpsuttonhonestly, i wouldn't choose figwheel at all these days. shadow is too good#2020-01-0719:06dpsuttonand provides a killer feature in that @thheller does all the work to let you use npm deps as easily as possible in cljs#2020-01-0719:09Brian AbbottOkay, cool - I dont have a web or clojure background but, coming up to speed fast and, we are eval/re-eval’ing our dev/test/debug/profiling stack. We currently use FigWheel and, maybe we will have to look into making the move over to Shadow.#2020-01-0719:10dpsuttonif you have been wanting to be able to use proper npm deps rather than cljsjs versions its highly recommended. Also, Bruce just isn't working on figwheel any longer whereas @thheller is incredibly responsive and forward thinking.#2020-01-0719:31kanwei
The required namespace "goog.date.relative.getPastDateString" is not available, it was required by xxx
#2020-01-0719:31kanweigetting that error when I
(:import [goog.date.relative getPastDateString])
#2020-01-0719:31kanweiany idea why that would be not found?#2020-01-0719:36thheller@kanwei because its a function not a namespace most likely#2020-01-0719:36thheller(:require [goog.date.relative :as rel]) (rel/getPastDateString ...)?#2020-01-0719:40kanweiya that works thanx 🙂#2020-01-0804:55QuestThis might be more of a CLJS question so I can take it there if appropriate -- I'd like to access a property from some JavaScript namespaces in the CLJS layer. The JavaScript code to do this is supposed to be this:
import Constants from 'expo-constants';
const { version } = Constants.manifest;
On the CLJS side, I wrote my namespace declaration like this:
(:require ["expo-constants" :as expo-constants])
But when I try to access (.-Constants expo-constants), it just returns nil. I can run (type expo-constants) and it comes up as #object[Object] so it's something, but struggling to figure out how to access it further. Anyone have tips or troubleshooting ideas?
#2020-01-0806:18dangercoderGood morning, I'm having issues with deps.edn + shadow-cljs. I followed the official docs to figure out which alias to use for shadow-cljs :
:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.83"}
                          :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
When I try to execute the alias:
clj -A:shadow-cljs watch app
I get the following error: Error building classpath. Coordinate type not loaded for library :main-opts in coordinate ["-m" "shadow.cljs.devtools.cli"] Has anyone ran into similar issues?
#2020-01-0806:31dangercoderI'll look into it further after work.#2020-01-0809:50thheller@quest see https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages. it likely is (:require ["expo-constants" :default expo-contants])#2020-01-0901:55QuestDead on as usual, thanks @thheller. Properties such as (.-manifest expo-constants) became immediately accessible after using :default#2020-01-0809:52thheller@jarvinenemil is your intent to use clj? you can just run with shadow-cljs watch app if you configure :deps {:aliases [:shadow-cljs]}#2020-01-0809:52thhellerbut dunno about that error otherwise. comes from clj, not shadow-cljs. looks ok to me .. maybe ask in #tools-deps#2020-01-0810:31thheller@jarvinenemil I see it now ... you :main-opts is listed as part of the :extra-deps map. its a misplaced }.#2020-01-0812:20dangercoderThe problem with rising up very early in the morning and trying to do things 😄. Thanks a lot @thheller #2020-01-0812:22thhellermight be worth reporting to #tools-deps regardless. the error message could probably be clearer. it just confused me at first.#2020-01-0812:23dangercoderI think i had some other issues, when I was not using aliases No such var: ana/unwrap-quote im gonna continue this evening.#2020-01-0812:24thhellermight be a version conflict of some kind#2020-01-0813:40bbssI've upgraded a project to a newer version of shadow-cljs a while back and had some issues with the namespace wrt directory structure, at the time I solved it for shadow-cljs watch but now shadow-cljs release is giving me issues. I have two modules with :web-worker true, but I was getting this error:
[:main] Build failure:
Module Entry "shadow.cljs.devtools.client.worker" was moved out of module ":fetch-worker".
It was moved to ":shared" and used by #{:filter-worker :fetch-worker}.
I tried to move :web-worker into :worker-shared, and that builds, but I get "SHADOW_ENV is not defined" when it runs.
#2020-01-0813:40bbssMy whole modules:
:modules    {:shared {:entries []}
                                  :web-shared {:entries []
                                               :depends-on #{:shared}}
                                  :worker-shared {:entries []
                                                  :depends-on #{:shared}
                                                  :web-worker true}
                                  :app {:entries [main.gsv.client]
                                        :depends-on #{:web-shared :shared}}

                                  :fetch-worker {:entries [main.gsv.fetch-worker]
                                                 :depends-on #{:worker-shared :shared}
                                                 }
                                  :filter-worker {:entries [main.gsv.filter-worker]
                                                  :depends-on #{:worker-shared :shared}
                                                  }}
#2020-01-0813:41bbssUsing 2.8.83 now.#2020-01-0813:43thheller@bbss oh I didn't consider 2 separate workers in the current setup. I enabled REPL/hot-reload inside workers. you can disable that for now by setting :devtools {:worker-inject false}#2020-01-0813:43bbssOkay, trying. Thanks!#2020-01-0813:43thhelleror :worker-inject :worker-shared that might work too#2020-01-0813:45bbssHmm, having the same issue with both those options.#2020-01-0813:51thhellerare you setting it in the correct place?#2020-01-0813:51thhellerie. in the build config but in :modules or so?#2020-01-0813:52thhellerhmm wait nevermind. you are not actually setting :web-worker true on the workers. I think your entire setup isn't actually supported right now#2020-01-0813:53thhelleryou can set :devtools {:browser-inject web-shared} probably#2020-01-0813:53thhellerI need to think about shared worker code#2020-01-0813:53thhellerit might work fine if you don't set :web-worker true on the shared worker stuff#2020-01-0813:54thhelleronly on the actual worker output#2020-01-0813:54thhelleryeah that should work#2020-01-0813:54bbssI was setting web-worker true on the workers, but then I got the "was moved out of module" warnings.#2020-01-0813:54bbssTrying that.#2020-01-0813:55thhellerright yeah only actual workers can have :web-worker true because they get some extra boilerplate#2020-01-0813:56thhellerbut yeah you probably need to disable the worker-inject for now. didn't consider 2 workers for that#2020-01-0813:57thhellerso :devtools {:worker-inject false} and :web-worker true for both the workers but not the shared#2020-01-0813:57dpsuttonI'm giving an ignite presentation tonight to evangelize shadow-cljs and cljs. would love feedback in #off-topic from anyone with an opinion and 5 minutes to spare#2020-01-0813:58thhellerwhy #off-topic? totally on-topic in my view 🙂#2020-01-0814:00dpsuttonalso didn't want to distract while yall were working through an actual issue 🙂#2020-01-0813:59thhellerOOO? whats that 😛#2020-01-0813:59dpsuttonwanted responses from general cljs and clojure people as well#2020-01-0813:59dpsuttonhaha. gonna appeal to my c# friends#2020-01-0814:00thheller
mkdir app
npm init -y
npm i react create-react-class react-dom shadow-cljs
#2020-01-0814:00thhellernpx create-cljs-project app will take care of creating generic boilerplate and some config#2020-01-0814:01dpsuttonoh never seen create-cljs-project. i mention create-cljs-app but it gets a bit heavy with the headless browser it brings along#2020-01-0814:01thhellerso its a bit better then npm init but less "full" then create-cljs-app#2020-01-0814:02thhellerits been in the readme for a while now https://github.com/thheller/shadow-cljs#quick-start#2020-01-0814:04thheller<a href=""> thats invalid, missing https://#2020-01-0814:05bbssGetting
inspect_client.cljc:279 Uncaught ReferenceError: document is not defined
    at $fulcrologic$fulcro$inspect$inspect_client$install 
Removed the inspect preload and now getting
browser.cljs:430 Uncaught ReferenceError: window is not defined
    at browser.cljs:430
#2020-01-0814:06thhellerminor "semantic" issue (.setAppElement Modal "#app") should not be run at the top level, as it will re-execute on every hot-reload. stuff like that goes into the init fn .. which you confusingly called main 😉#2020-01-0814:07thhellerprobably not an issue in this case but in general that stuff goes into the init fn#2020-01-0814:07thheller@bbss then you also need to set :devtools {:browser-inject :web-shared :worker-inject false}#2020-01-0814:08thhellerI really need to figure out a way to make this config cleaner now that devtools in workers are supported. makes things slightly more complicated 😛#2020-01-0814:14dpsuttonthanks for the feedback so far. deployed those changes to the presentation and the site#2020-01-0814:16bbssWorkers load with that, but now I'm getting a bunch of warnings that are actually errors I expect:
shared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined

env.evalLoad @ shared.js:3199
(anonymous) @ app.js:1482
shared.js:3199 failed to load goog.crypt.base64.js TypeError: Cannot read property 'SAFARI' of undefined
etc..
#2020-01-0814:18thhellerthat might be a bad closure-library version? if you use deps.edn/project.clj thats a "common" conflict nowadays ...#2020-01-0814:18bbssalright, could be, investigating#2020-01-0814:20thhelleryou should have these versions or newer, but not older
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-01-0814:20thhellershadow-cljs.edn ensures that but can't for the others#2020-01-0815:03bbssAdded that and still have the warnings that sound like errors, they happen for the started workers too. But the application is working again! had to remove a bunch of code that was not warning or erroring but referring a missing library in the project.clj dependencies (I think that was what's wrong?)#2020-01-0815:03bbssSeeing if this works for release as well, thanks a lot once again @thheller!#2020-01-0815:04thhellerwarnings that sound like errors?#2020-01-0815:04bbss
shared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined
    at Object.goog.inherits (shared.js:1931)
    at eval (throttle.js:76)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:1817)
    at Object.env.evalLoad (shared.js:3197)
    at app.js:936
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:936
shared.js:3199 failed to load fulcro.client.network.js TypeError: Cannot read property 'ErrorCode' of undefined
    at eval (network.cljc:24)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:1817)
    at Object.env.evalLoad (shared.js:3197)
    at app.js:960
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:960
shared.js:3199 failed to load fulcro.client.primitives.js TypeError: goog.async.Throttle.base is not a function
etc..
#2020-01-0815:05bbssthey're console.warning but sound like serious errors.#2020-01-0815:05thhellerthose are definitely errors not warnings#2020-01-0815:05bbssright.#2020-01-0815:05thhellerit just warns that they happened when trying to load those files#2020-01-0815:06bbssOkay, but my code runs fine it looks like. 🤔#2020-01-0815:07thhellerare there more errors? seems like a cascading error to me where one problem causes all the others#2020-01-0815:08bbssThere are more errors, but I think it's maybe in code I'm not using anymore. Making big cuts in the codebase after refactoring.#2020-01-0816:05bbsswhen using release I'm getting
shared.js:2 Uncaught ReferenceError: $jscomp is not defined
    at shared.js:2
    at shared.js:1
Which I think is warned about with:
File: /Users/baruchberger/work/gsv/src/main/gsv/api/createIterable.js:89:8
--------------------------------------------------------------------------------
  86 |         if (prop === 'length') {
  87 |           return length;
  88 |         }
  89 |         if (prop === Symbol.iterator) {
--------------^-----------------------------------------------------------------
 variable $jscomp is undeclared
--------------------------------------------------------------------------------
  90 |           return iterator;
  91 |         }
  92 |         return source[prop];
  93 |       }
--------------------------------------------------------------------------------
#2020-01-0816:06bbssI think this has to do with polyfills of closure, but not sure how to fix it.#2020-01-0816:25thheller@bbss you can set :compiler-options {:output-feature-set :es6}#2020-01-0816:32thhelleranother option is adding :web-shared {... :prepend-js "window.$jscomp = {};"} .. there is an option issue about this I think. still need to dig into the closure compiler to figure out why this happens#2020-01-0816:47HukkaI made a short demo with plain shadow-cljs today (no backend at all, no lein etc.). The repl always complained about unused vars, whenever I accessed any vars defined in the source. I don't remember seeing that before, and googling didn't show anything. Any ideas what's up with that?#2020-01-0816:59bbss@thheller Thanks. Looks like the :output-feature-set :es6 + :prepend worked. Next issue is my js/window seems to be undefined. So many errors compared to earlier, did the closure compiler suddenly get a lot more strict or something?#2020-01-0817:35thhellerwindow is always undefined in workers?#2020-01-0817:44bbssYes, but in my main module.#2020-01-0817:50thhellerwhat has changed is the default of :compiler-options {:output-wrapper false}#2020-01-0817:50thhellerthis used to default to false in multi-module builds but now also defaults to true there#2020-01-0817:50thhellermaybe thats causing your issues?#2020-01-0818:04bbssHmm, I'll need to read-up on that. But I think it's started since a clojurescript + shadow-cljs (and more strict closure) update a while back. Worked for non-advanced builds though, but now running into issues with advanced. I can make it work with shadow-cljs compile for now.#2020-01-0903:25kennyOut of curiosity, if I have only one namespace that requires a npm module and namespace is never used, does shadow/closure know to not include the npm module?#2020-01-0909:39thheller@kenny if the namespace is included then the npm module will be included as well. if the namespace is not required anywhere the npm module won't be either.#2020-01-0915:32kennyIn the first sentence, by “included” do you mean required?#2020-01-0915:55thhelleryes#2020-01-0915:59kennyOk, so the be clear, if I have this ns in my project
(ns my-ns
  (:require
    ["some-npm-module" :as module]))
And my-ns and "some-npm-module" are never required by any other ns, "some-npm-module" will not be included in the output?
#2020-01-0916:01thhellercorrect#2020-01-0916:01kennyGreat, thanks!#2020-01-0909:40thhellerincluded but not used makes no difference. there is no DCE for npm modules so if you don't use something don't include it#2020-01-1004:13Eric IhliI'm trying to re-implement https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs to get a better understanding of how things work. I got the gist of it, but I'm stuck wondering why I need to reset the component reference before calling forceUpdate on the wrapper. Can anyone shed light on that? See the following code for reference. Thanks. https://github.com/eihli/cljs-react-native-starter/blob/1e7721b9d82b0a2163fb83f03534c341e5a59a77/src/example/core.cljs
(defn make-reloader [comp]
  (let [comp-ref (atom comp)
    ;; ...
    (rn/AppRegistry.registerComponent "ExampleApp" (fn [] wrapper))
    (fn [comp]
      (when-let [wrapper @wrapper-ref]
        ;; Why do we need to reset the component here?
        ;; Why doesn't calling forceUpdate on the parent-most component
        ;; cause everything to re-render?
        ;; Is there a downside to doing it this way? Is there an alternative?
        (reset! comp-ref comp)
        (.forceUpdate @wrapper-ref)))))
#2020-01-1004:14Eric IhliThe alternative that I'm confused about is mentioned at https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html under the section "Hooking up React". Is this not a viable alternative because we don't have a dom in ReactNative? Is it not possible to call a reagent function that requires a real dom?
(defn ^:dev/after-load start []
  ;; dummy prop that always changes
  (reagent/render [ui {:x (js/Date.now)}] dom-root))
#2020-01-1009:46thheller@ericihli in react-native you must register a "root" component on startup which react-native will then render. you can only register it once though, you cannot replace it afterwards in hot-reload. thats what the wrapper is for.#2020-01-1012:52Björn EbbinghausIs there a config key to specify the local repo location for the deps? Like with clojure you have: clojure -Sdeps '{:mvn/local-repo ".m2"}' I can't seem to find it.#2020-01-1012:56thhellerwell do you use deps.edn or shadow-cljs.edn?#2020-01-1012:57Björn Ebbinghausdeps are in deps.edn#2020-01-1012:57thhellerthen you declare it there?#2020-01-1013:00Björn EbbinghausI just want to set it in my CI and run it like this npx shadow-cljs compile ci-tests I don't want to permanently change it.#2020-01-1013:00thhellerif you use deps.edn you must use deps.edn related things to do stuff#2020-01-1013:01thhellerclojure -Sdeps '{:mvn/local-repo ".m2"} -m shadow.cljs.devtools.cli compile ci-tests#2020-01-1013:02thhelleror put it into the ~/clojure/deps.edn on the CI system#2020-01-1013:02thhellerthere is no setting in shadow-cljs.edn to "modifiy" the deps.edn config#2020-01-1013:02Björn Ebbinghausthe use of the cli ns is the solution. thank you!#2020-01-1013:26Eric IhliI mentioned above that I'm trying to better understand this https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs Does anyone see a real difference between the render-root there and the following? Through my surface-level testing and current understanding, they appear to function the same.
(defn make-reloader [comp]
  (let [comp-ref (reagent/atom comp)
        wrapper (reagent/create-class
                 {:render
                  (fn []
                    (let [comp @comp-ref]
                      (if (fn? comp) (comp) comp)))})]
    (rn/AppRegistry.registerComponent "ExampleApp" (fn [] wrapper))
    (fn [comp]
      (reset! comp-ref comp))))
#2020-01-1013:29Filipe Silvaheya is there a way using shadow-cljs run (or something else similar) of running clj-kondo like the lein/tools.deps example in https://github.com/borkdude/clj-kondo/blob/master/doc/jvm.md?#2020-01-1013:30thhellershadow-cljs run clj-kondo.main?#2020-01-1013:34Filipe Silvayeap that does it, will add to the guide there#2020-01-1013:34Filipe Silvathank you#2020-01-1014:21thheller@filipematossilva might be worth mentioning that if a shadow-cljs server (or shadow-cljs watch) is running the startup will be much faster#2020-01-1014:21thhellerotherwise starting a new JVM instance with shadow-cljs and kondo loaded will take forever#2020-01-1014:22Filipe Silvawill do#2020-01-1014:26Filipe Silvahttps://github.com/borkdude/clj-kondo/pull/697#2020-01-1016:36kennyI'm working with highcharts and have it required like this ["highcharts/highcharts" :as highcharts]. I'm then importing the histogram module like this ["highcharts/modules/histogram-bellcurve" :as histogram]. There is some issue with how I'm using the histogram module that I'd like to debug. When clicking an item in a stacktrace in the browser that points to some code in the histogram module, I get minified code. Is there a way to use the non-minified code for development and switch to the minified in production?#2020-01-1016:58kennyChanging the require to ["highcharts/modules/histogram-bellcurve.src" :as histogram] got me the source.#2020-01-1017:07kennyWoah ok. I'm a bit out of depth in js land at this point but something is broken in either shadow or highcharts. So you have to initialize the highcharts histogram module like this
(ns example
  (:require
    ["highcharts/highcharts" :as highcharts]
    ["highcharts/modules/histogram-bellcurve" :as histogram]))

(histogram highcharts)
However, if I do that, I will get an exception saying e is not a function. It's pretty useless because the file is minified. So I switch the histogram require to point to the source JS file: ["highcharts/modules/histogram-bellcurve.src" :as histogram] . After running the code, I get an exception giving me more info: "correctFloat is not a function". This "correctFloat" function is provided by some Utilities module. I end up changing the highcharts require to ["highcharts/highcharts.src" :as highcharts] in hopes I get some more information. After changing the require, everything works! Using the highcharts/highcharts results in a function missing. Any idea why this would happen and whether this is a shadow issue or a highcharts issue?
#2020-01-1017:22kennyIn the histogram-bellcurve.js file, there is this:
_registerModule(_modules, 'modules/bellcurve.src.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js'], _modules['mixins/derived-series.js']], function (H, U, derivedSeriesMixin) {
        var correctFloat = U.correctFloat,
I don't entirely know what this means but it appears that it is trying to lookup the correctFloat function at the path ["_modules"]["parts/Utilities.js"]["correctFloat"]. If I try to lookup that path in the browser console,
compute.ui.components.highcharts.h._modules["parts/Utilities.js"].correctFloat
=> undefined
I can, however, find other functions at that path
compute.ui.components.highcharts.h._modules["parts/Utilities.js"].arrayMax
=> fn
#2020-01-1017:23kennyIt appears like the correctFloat is entirely missing from the place the histogram-bellcurve module is looking for it. Could this be because it was DCE'ed? I thought shadow doesn't do that with npm modules. Or perhaps it's a highcharts issue?#2020-01-1017:24kennyIt wouldn't appear to be a highcharts issue since I can create a histogram here: https://jsfiddle.net/4vtb6q5e/#2020-01-1017:26kennyI can replicate this issue in both highcharts 8.0.0 and 7.2.1#2020-01-1017:30kennyI ran the minified highcharts.js file through an unminifier and uploaded it here: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0. On line 584 you can see the correctFloat being assigned to r: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L584. Line 116 has the definition for r: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L116. This function definitely exists in the code base then. Line 51 you can see it is defined within the parts/Utilities.js module: https://gist.github.com/kennyjwilli/37d7856abdd56b4ee282a869fbe0abd0#file-highcharts-unmin-js-L51#2020-01-1017:33kennySo somewhere between the file definition and page render, the correctFloat function is removed.#2020-01-1017:46kennyI added
<script src="https://code.highcharts.com/highcharts.js"></script>
to my index.html and set
:js-options {:resolve {"highcharts/highcharts" {:target :global
                                                :global "Highcharts"}}}
in shadow-cljs.edn. After doing so, things work as expected. It would seem like shadow is removing that function for some reason. Is there a way to fix this?
#2020-01-1018:14kennyDoes shadow expect that the imported npm module be pointing to a non-minified or minified version of the source?#2020-01-1018:24kennyIt seems like requiring highcharts/highcharts.src work in development and results in a minified version in production. I guess I'll go with that for now. This was quite confusing.#2020-01-1019:20thheller@kenny why ["highcharts/highcharts" :as highcharts]? the docs would suggest that ["highcharts" :as highcharts] would be the correct on to use?#2020-01-1019:22thhellerdoesn't matter in this case but it makes things really hard to follow if you don't follow the official docs#2020-01-1022:34kennyI could swear I tried that before and it didn't work. Just tried it again and it does.#2020-01-1216:00knubieAnyone using shadow-cljs with react-native? In my project every time I make a change to a cljs file it will update quickly (using Fast Refresh I assume?), but then a couple seconds later it will rebuild/re-download the bundle.#2020-01-1216:01knubieI’m wondering if there’s some configuration I can change, or a different way to set up the project that will avoid the re-downloading every time#2020-01-1216:48thhelleryou need to turn off all react-native reloading#2020-01-1216:50thhellerno clue how to do that but it interferes with the reloading shadow-cljs does#2020-01-1218:00knubiei see, i’ll give it shot thanks#2020-01-1322:05Eric IhliI ran into this problem. Ctrl-M in the emulator brought up the menu for me where I could disable fast-refresh.#2020-01-1322:08Eric IhliIf you're new to CLJS/RN like I am, I made a repo with a single commented file that has the bare-minimum setup. It helped me and if you're new too you might find it useful. https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs#2020-01-1322:12thheller@UJP37GW2K you never require devtools.core. if you need it you add it to your build config :devtools {:preloads [devtools.preload]}#2020-01-1322:12thhellerotherwise it'll be included in your release bbuilds#2020-01-1322:13Eric IhliAh. Thanks!#2020-01-1221:25Pavel KlavíkHi, I am trying to make TextInput from Material-ui working within our project, where the problem was reported by my colleagues couple days back: We require this:
["@material-ui/core/TextField" :default TextField]
We get the following error in the console:
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$SelectInput
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$Select @ Select.js:21
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$Select
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$Select$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$Select$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$TextField @ TextField.js:37
shadow.js.jsRequire @ js.js:66
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$TextField
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$TextField$index @ index.js:16
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:74 shadow-cljs - failed to load module$node_modules$$material_ui$core$TextField$index
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
(anonymous) @ orgpad.client.views.widgets.text_field.js:3
js.js:75 Uncaught TypeError: Cannot read property 'isRequired' of undefined
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$SelectInput (SelectInput.js:453)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$Select (Select.js:21)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$Select$index (index.js:16)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$TextField (TextField.js:37)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$TextField$index (index.js:16)
    at Object.shadow.js.jsRequire (js.js:66)
It was suggested that the problem is with a conflict of dependencies. Any ideas how to do debugging?
#2020-01-1221:26Pavel Klavíkthese are all the dependencies we currently use:
"dependencies": {
  "@material-ui/core": "^4.8.0",
  "bezier-js": "^2.4.4",
  "create-react-class": "^15.6.3",
  "deps": "^0.1.2",
  "process": "^0.11.10",
  "react": "^16.12.0",
  "react-dom": "^16.12.0",
  "react-motion": "^0.5.2",
  "webfontloader": "^1.6.28"
},
#2020-01-1221:29thhellerquick look at the code suggest prop-types is the problematic package#2020-01-1221:29thhellercheck which one material-ui expects and which one you have in node_modules/prop-types#2020-01-1221:30Pavel Klavíkwe have "/cdn-cgi/l/email-protection"#2020-01-1221:32thhellermight go deeper than that package too#2020-01-1221:32thhellercan't really tell where the isRequired is supposed to be coming from#2020-01-1221:33thhelleror rather it is trying default.isRequired and default is undefined#2020-01-1221:34Pavel Klavíkin the minimal working example, we have "/cdn-cgi/l/email-protection"#2020-01-1221:35thhellerI also have 15.7.2#2020-01-1221:35thhelleryou can also check node_modules/@material-ui/core/node_modules#2020-01-1221:35thhellerthats usually a clue if there are packages in there#2020-01-1221:36thhellershadow-cljs doesn't read those#2020-01-1221:38Pavel Klavíkya, there is on#2020-01-1221:38Pavel Klavíkone#2020-01-1221:38Pavel Klavíkwith 15.7.2#2020-01-1221:38Pavel Klavíkso what is the solution? adding this dependency directly into our project?#2020-01-1221:44thhellerno clue. might be.#2020-01-1221:45thhellermaterial-ui is one of those packages that constantly breaks#2020-01-1221:45Pavel KlavíkI have tested to add it and it runs fine 🙂#2020-01-1221:45thhellerI really wouldn't recommend using it#2020-01-1221:46Pavel Klavíkhmm, what are the alternatives? we basically want to get reasonable UI elements without spending much time with it#2020-01-1221:46thhellerdon't know#2020-01-1221:47Pavel Klavíkanyway, thx a lot for help, I will have to learn to read JS packages better#2020-01-1221:47Pavel Klavíkhopefully we get everything running soon#2020-01-1221:50Pavel Klavíkhow the npm modules have versions chosen? why did we got the older version for prop-types?#2020-01-1221:51thhellerits a common package. some other package you installed also depended on the older version#2020-01-1221:51thhellernpm list or something shows all installed packages#2020-01-1221:59Pavel Klavíkwhy is not the largest needed version installed? it seems that also react and react-motion depended on it#2020-01-1222:00thhellerdon't ask me .. I don't know how they handle this anymore#2020-01-1222:01Pavel Klavíkok, complexity lurks everywhere out there 🙂 anyway thx a lot#2020-01-1222:53JonRHi Folks, wondering if anyone has by chance tried using Rete.js with shadow-cljs?#2020-01-1222:54JonRI'm trying shadow-cljs out for the first time and hoping to use this lib. Installs fine via npm but when I try to require and use as in the examples the object import is empty#2020-01-1222:54JonRI can import other deps from node which are installed in the project just fine#2020-01-1222:55JonRFrom what I can see the library is a TS project using Rollup.js and ES#2020-01-1222:57JonRSo in short, hoping someone has tips in using an npm lib using babel, ts and rollup.js (most of which I generally understand but don't have experience with)#2020-01-1417:14just.sultanov@UQR2E9W15 Hi! I’m setting up shadow-cljs with monaco-editor and rollup.js too. Change the config a little bit and that will work with typescript. Maybe it can help you. https://github.com/just-sultanov/clj-monaco#2020-01-1718:40JonRHey @U1EQNSHL4 thanks so much for the tip! I ended up getting around rollup etc. by requiring the min file directly like so:
["rete/build/rete.min.js" :as rete]
#2020-01-1222:58JonRhttps://github.com/retejs/rete#2020-01-1300:07tony.kayIs there a way to reliably detect (in a macro) that shadow is doing a release build?#2020-01-1300:08tony.kayI guess I could just set something in the release config section and check that
#2020-01-1300:42tony.kayI figured out what I needed…nvm#2020-01-1306:20cflemingIs it expected that watch would work with a :node-script target? I have the following config:
{:target    :node-script
 :main      lambda.serve/main
 :output-to "target/local/lambda.js"
 :devtools {:before-load-async lambda.serve/stop
            :after-load lambda.serve/start}}}}
and in my lambda.serve ns I have:
(defn main [& args]
  (println "Hello")
  (js/console.log "Hello")
  ...etc etc...)

(defn start
  "Hook to start. Also used as a hook for hot code reload."
  []
  (js/console.warn "start called")
  (main))

(defn stop
  "Hot code reload hook to shut down resources so hot code reload can work"
  [done]
  (js/console.warn "stop called"))
#2020-01-1306:22cflemingWhen using shadow-cljs watch local I’m not seeing any signs in the log that either main, start or stop are being called.#2020-01-1306:22cflemingIs my expectation that log output would come out on the console with the build output correct?#2020-01-1307:55David PhamYou also need to run NodeJS against the output #2020-01-1308:01cflemingDoesn’t watch do that automatically? I would have thought it had to so that code reloading would work.#2020-01-1309:58cflemingThinking about it, I assume the code generated by watch contains code to connect back to the server. I’ll try when I’m back at my computer.#2020-01-1310:22thhellerwatch and hot-reload only work when running locally#2020-01-1310:23thhellerin your stop example you are not calling (done) so that would break hot-reload too since it'll wait for stop to complete#2020-01-1310:23thhellerbut otherwise watch is supported and should be working#2020-01-1310:24thhellercheck your dependencies though. shadow-cljs only works with the newer closure-compiler and closure-library versions. if you have the old one things break in weird ways#2020-01-1310:29cflemingI don’t have those in my shadow config, I thought the right versions were built into shadow and supplied?#2020-01-1310:30thhellerif you use only shadow-cljs.edn then yes you'll get the right versions#2020-01-1310:30thhellerif you offload dependencies to deps.edn or project.clj you might not#2020-01-1310:31thhelleryou only pasted the build config so I can't tell 😛#2020-01-1310:32cflemingHaha, fair enough. No, I’m not, just plain shadow.#2020-01-1310:32cfleming
{:source-paths ["src/shared" "src/deploy" "test" "src/local"]
 :dependencies [[com.andrewmcveigh/cljs-time "0.4.0"]
                [funcool/promesa "4.0.2"]
                [appliedscience/js-interop "0.1.21"]
                [cljs-bean "1.5.0"]]
 :builds       {:production
                {:target    :node-library
                 :compiler-options {:optimizations :simple}
                 :output-to "target/production/lambda.js"
                 :exports   {:webhook lambda.webhook/webhook
                             :buy     lambda.buy/pre-auth
                             :renew   lambda.renew/pre-auth
                             :quote   lambda.quote/quote}}
                :test
                {:target    :node-test
                 :output-to "target/test/node-tests.js"
                 :autorun   true
                 :ns-regexp "-test$"}
                :local
                {:target    :node-script
                 :main      lambda.serve/main
                 :output-to "target/local/lambda.js"
                 :devtools {:before-load-async lambda.serve/stop
                            :after-load lambda.serve/start}}}}
#2020-01-1310:33thhellerok that should be working fine#2020-01-1310:34thhellerdo you run it via node target/local/lambda.js or something aws or whatever cloud you use?#2020-01-1310:34cflemingAssuming that stdout goes to the same place as the compile output, I’m definitely not seeing main, stop or start being called.#2020-01-1310:34thhellerit definitely doesn't go to the same place as compile output#2020-01-1310:34thhellershadow-cljs will not run this code for you#2020-01-1310:34thhellerif goes whereever you run the code#2020-01-1310:35cflemingSo maybe that’s my misunderstanding, I thought that when using watch it would run the output automatically, so that shadow could reload - is that not the case? Do I have to run it locally using node?#2020-01-1310:35thhellerno shadow-cljs never runs code for you#2020-01-1310:35cflemingOk, got it - that’s my problem then 🙂#2020-01-1310:35thhelleryou have to open the browser or run node 😛#2020-01-1310:35cflemingThanks, I’ll do that when I’m back coding.#2020-01-1317:15p-himikI want to make a conditional preload coming from a conditional dependency (same condition), and I already use deps.edn. The best way to do this would be via --config-merge, right?#2020-01-1317:20thhellerI guess? how conditional is it? preloads are already dev-only so you can always include it without having it in the release build?#2020-01-1317:22p-himikRight now it's basically for experimenting, because sometimes dev dependencies seem to alter the runtime of the app. The condition is needed just to be able to run the server with different preloads an dev dependencies when needed.#2020-01-1317:30thhelleralter the runtime of the app in what way?#2020-01-1317:31thhellerseems like a bad dependency if it does that 😛#2020-01-1317:39p-himikYeah, probably. TBH don't remember the details and have probably removed the dependency by now - I just have it on my backlog to check how to do it. Anyway, thanks!#2020-01-1319:06jjttjjI have
(:refer-clojure :rename {get core-get})
In a cljc file and a function named get. The initial compilation is fine but then whenever I reload I get the warning:
get already refers to: cljs.core/get being replaced by: mylib.core/get
Is there something else I have to do to prevent this? Is this just a cljs thing unrelated to shadow?
#2020-01-1319:31darwinhave you tried :refer-clojure :exclude [get] instead? you can then refer to it via fully qualified symbol cljs.core/get#2020-01-1319:34jjttjjthat works! I noticed exclusion works, didn't think about referring to it fully qualified#2020-01-1319:35darwinmy wild guess is that this is a shadow-cljs bug, and that :rename is not properly handled#2020-01-1319:36thhellerthats possible. I've never used :rename with :refer-clojure before. didn't even know that was allowed to be honest 😛#2020-01-1413:11p-himikIt's a CLJS compiler bug: https://clojure.atlassian.net/browse/CLJS-2292#2020-01-1323:05kennyHow would I tell shadow-cljs about a static edn file that I load in a macro?#2020-01-1323:25thheller@kenny https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2020-01-1408:52Rohanhi all! i'm new to clojure(script) and looking at using it for some chrome extension development#2020-01-1408:52Rohani saw the issue explaining how to set up the build but I was wondering if content scripts support live reloading?#2020-01-1408:53Rohanif they did that give clojurescript a huge advantage over any other pipeline 🙂#2020-01-1409:43thhellerI can't remember. it might work?#2020-01-1410:19Rohanok i'll try to give it a shot#2020-01-1410:19Rohanis the github issue still the best source for explaining how to build a chrome extension?#2020-01-1410:24thhelleryeah. I haven't worked on it in a while#2020-01-1410:28ziltiIs there a way I can tell shadow-cljs to by default provide the goog.* namespaces? I am using a library that gives me The required namespace "goog.dom.query" is not available.#2020-01-1410:29thhellerwhat do you mean? that ns just doesn't exist?#2020-01-1410:30ziltiIt is a namespace from the Google Closure libraries. Since a library I use depends on it, a simple (:require ["google-closure-library"]) doesn't fix it#2020-01-1410:31thhellerthat ns doesn't exist in the closure-library version shadow-cljs uses#2020-01-1410:31thhelleryou cannot require the closure-library from npm#2020-01-1410:31ziltiHm, I see...#2020-01-1410:32ziltiSo it is probably an ns that got discontinued#2020-01-1410:32stijnHi, the certificate at https://shadow-cljs.org/ is expired#2020-01-1410:32thhellermight be. I don't know that ns but the closure folks like to remove stuff occasionally#2020-01-1410:33ziltiI noticed in general that the state of cljs libraries is desolate. Most seem to have been discontinued and are just waiting to stop working#2020-01-1410:33thheller@stijn thanks. someone reported that yesterday already. @jiyinyiyong constrols the server, I can't do anything about the cert.#2020-01-1410:34thheller@zilti which library is it?#2020-01-1410:34stijn@thheller ok, no worries, the (pretty awesome) docs are on github anyway :)#2020-01-1410:34ziltiThis specifically is enfocus, which relies on domina, which is the library that requires goog.dom.query#2020-01-1410:35thhelleryou can maybe find the last source of the goog.dom.query ns#2020-01-1410:35thhellerand just put it into your classpath#2020-01-1410:35ziltiEh, that is a crude hack, not a fix 😕 I'll look at the sources of the library when I have time. Maybe it is a rather straightforward fix.#2020-01-1410:36ziltiBut thanks for helping out#2020-01-1410:36thhellerunfortunately using the latest closure-compiler requires using a compatible closure-library version#2020-01-1410:37thhellerand we want the latest closure-compiler version because of better JS support#2020-01-1410:38ziltiUnderstandable#2020-01-1410:39thhellerto be fair it was deprecated in 2013 https://github.com/google/closure-library/commit/e451b9dbd265adb440f8cadea431736c10b00f76#2020-01-1410:40thhellerso domina was probably using a deprecated API from the beginning 😛#2020-01-1410:42ziltiIt's sad, there really is no maintained DOM manipulation library for cljs left#2020-01-1410:42ziltiEh, Domina probably started out using it when it wasn't deprecated yet, a substantial part of the code hasn't seen any updates since 8 years#2020-01-1410:42thhellerwell .. there is the closure library 😛#2020-01-1410:43ziltiYea, but when half your code consists of interop calls... Meh...#2020-01-1410:44thhellerI don't mind interop ... its one of the reasons I'm even using clojure(script) in the first place. imagine not being able to do that 😛#2020-01-1410:46ziltiWith Clojure you get by most of the time with using Clojure libs and rarely have to touch Java interop at all, which means more idiomatic code. But wanting to write idiomatic ClojureScript when almost all you have is interop just leads to a ton of annoying glue code#2020-01-1410:47thhelleryeah the CLJS community adopted React too much. everything else kinda got left behind. one might think that React is the only thing out there when looking at CLJS#2020-01-1410:51grounded_sageMr Clean is an interesting alternative. I'm not sure if it gets rid of your pain point @zilti. Gives a nice option where you can still lean heavily on how everyone else is building with cljs it's actively maintained as a side project. https://www.reddit.com/r/Clojure/comments/abc4pi/mr_clean_is_a_reagent_compatible_clojurescript/#2020-01-1410:52ziltiInteresting, I'll take a look#2020-01-1410:56thhellerFWIW I'm working on an alternative myself. nowhere near ready though.#2020-01-1410:57thhellermr. clean doesn't look that actively developed with only a snapshot release and no update in over a year?#2020-01-1410:58ziltiYea I just noticed that. Also basically undocumented#2020-01-1414:27rickmoynihanNot sure if anyone else is seeing this, but I’m getting a cert error on https://shadow-cljs.org/ in firefox:#2020-01-1414:27rickmoynihan#2020-01-1414:28thheller@rickmoynihan the ssl cert expired#2020-01-1417:56Eric IhliI just extracted a reagent form to a new namespace in a new file and something with hot-reload seems to have broken. This first example works fine, I can edit the text "Some title" and the app hot-reloads and I see the changes.
(defn text-input
  []
  [:> Text "Some title"])

(defn test-view
  [title]
  [:> View
   [text-input]])
But when I move text-input out into another namespace and edit the text there, I don't see the changes in the app until I manually reload, even though on save a build is triggered and the dev console reports that the ^dev/after-load function is being called.
(defn test-view
  [title]
  [:> View
   [:> Text "Title"]
   [other-ns/text-input]])
I've stopped and restarted shadow-cljs server, shadow-cljs watch :app , and npx react-native start --reset-cache. Any ideas on what this might be or how to troubleshoot it?
#2020-01-1417:56thhellermight be react deciding to skip the update since nothing changed#2020-01-1417:57thhellersee https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-01-1418:46lilactownwhat’s the ^dev/after-load function doing?#2020-01-1418:48Eric Ihli
(defn ^:dev/after-load start []
  (rf/clear-subscription-cache!)
  (reload views/app-container))
#2020-01-1418:50Eric IhliAnother bit of possibly useful info: I edit and save the file with my new-namespace and the dev/after-load function gets called but the view doesn't refresh. Then, I add a meaningless extra newline at the end of some other file (just so emacs sees a change and allows me to save it) and save it. Then the view that I was trying to hot-reload/hot-refresh actually refreshes.#2020-01-1420:01thheller@ericihli as I mentioned the re-render likely just stops at the test-view. it didn't change so reagent or react (don't exactly know who is reponsible) stops there.#2020-01-1420:03Eric IhliThat's the thread I'm pulling on now. I tried saving a reference to my outermost wrappers this and then using reagents (force-update @wrapper-this true) to nuke and re-render everything, but that resulted in the same behavior, no update.#2020-01-1420:05Eric IhliBut even that was just a trial and error theory. Maybe I'm misunderstanding which "this" I'm getting a hold of. Or maybe I'm misunderstanding what reagent's force-update does. So still have a lot of exploring to do.#2020-01-1420:18thhelleryou force update the outer most component. it starts rendering and may decide at any point to stop. in re-frame you'll usually have some subs or so which are invalidated so it'll continue#2020-01-1420:18thhellerbut your example has nothing to invalidate it#2020-01-1421:57lilactownone way you could perhaps fix it (though hacky) is to mark the namespace with app-container in it as dev/always#2020-01-1421:57lilactown
(ns ^:dev/always my-app.views
  ...)

(defn app-container ...)
#2020-01-1421:57lilactownthis will tell shadow-cljs to reload that namespace on every change#2020-01-1421:58lilactownwhich will create a new app-container function, helping React mark it as dirty#2020-01-1421:59lilactownI think that there are two different dev reloading modes for React Native. is that still correct?#2020-01-1422:21thhellerdon't use :dev/always, figure out the correct way to fix it instead. always makes everything slower.#2020-01-1422:32darwin@thheller just by chance, have you done any progress on exposing api for using alternative javascript engine for execution of generated js code? I’m still waiting for some support to integrate dirac#2020-01-1422:45thhellersorry still no clue what you exactly need#2020-01-1422:46thhellerif you put together a ticket/proposal I can look at it but without a reference of what you actually need I can't do much#2020-01-1422:46thhelleralso please lets not do any of this in slack. I can't remember what we talked about last time#2020-01-1422:47darwinok, I will try to prepare some ticket on github#2020-01-1422:51thhellerFWIW I'm still working on the "inspect" feature I started. currently getting rid of react but making good progress. once thats done I'll get back to the shadow.remote feature that inspect is built upon. that might be of interest for dirac#2020-01-1422:51thhellerI wrote a bit about that but the proper docs still need to be written https://github.com/thheller/shadow-cljs/blob/master/doc/remote.md#2020-01-1422:54darwinnice, will study it, I actually made some progress on shadow-cljs integration in dirac[1], but forgot most details one of the problems I remember is that I needed for you to pass some extra compilation env stuff down to cljs compiler (scope :locals) [1] https://github.com/binaryage/dirac/commit/a08d565a2f85072f8157ceafa6f4abd670058476#diff-7acb24e7dee86ee2bb972e97d74a6c92R24#2020-01-1517:37lilactownbringing this from #clojurescript: trying to use closure syntax leads to an error
failed to load workshop.core.js ReferenceError: $jscomp is not defined
    at Object.createComponent (classes.js:8)
#2020-01-1517:38lilactownhappy to create a github issue if it’s not a quick fix on my end#2020-01-1520:48thhellerif you intend to use class you should probably set :compiler-options {:output-feature-set :es6}#2020-01-1520:51lilactownDoes that mean gcc will output es6?#2020-01-1521:01thhelleryes#2020-01-1521:01thhellerbut thats the point right? I mean why else do you use class?#2020-01-1521:01thhellerhmm or was class es5? can't remember#2020-01-1521:02thhellermissing $jscomp is weird though. dunno what that is about#2020-01-1521:02thhellerdo you use :modules?#2020-01-1521:36lilactownClass was es6. But I'm using this purely to interop with React so I would expect gcc to be able to compile the classes to es5#2020-01-1521:36lilactownI'm not using modules. This is in a library#2020-01-1521:38thhellerwhy not write the "transpiled" version in regular CLJS then? 😛#2020-01-1521:41lilactownI want it to use actual classes if available#2020-01-1521:41lilactownDoing the transpiled version with actual classes doesn't work#2020-01-1521:43thhellerbtw
helix.impl = helix.impl || {};

helix.impl.classes = helix.impl.classes || {};
#2020-01-1521:43thhellerthis is not something you need to do#2020-01-1521:43thhellerthats what goog.provide does#2020-01-1521:43lilactownAh ok, wasn't sure#2020-01-1613:55Bravihi everyone. do we have a re-frame template for shadow-cljs? meaning something line lein new shadow-cljs +re-frame#2020-01-1613:59thhellerthe re-frame template uses shadow-cljs I think?#2020-01-1613:59thhellerhttps://github.com/day8/re-frame-template#2020-01-1614:00Bravioh#2020-01-1614:00Bravinice 😄#2020-01-1614:00Bravithanks @thheller#2020-01-1617:28darwin@thheller so there are only two loader modes? :eval (default) and :script (old one)#2020-01-1617:28thhelleryes#2020-01-1617:29thhellerwell :script technically has 2 modes#2020-01-1617:29thhellerasync and actual <script> tags, depending on whether you use <script async src="the-module.js"> or not#2020-01-1617:30thhellerone uses document.write to add script tags, the other fetches files and evals them#2020-01-1617:31thhellerso probably has the same issues as :eval. never tested.#2020-01-1617:34darwinI think both will work, the issue is probably that SHADOW_ENV.evalLoad is really running “anonymous” code which is not associated with any source file, so (logically) that source file is not created/tracked in the DevTools - devtools only creates “virtual” cljs files from sourcemap information (orange stuff in devtools resource tree)#2020-01-1617:35thhellerloading the source via fetch and eval'ing it is just as "anonymous"#2020-01-1617:35thhellerthere is no way chrome ties the eval to the file it just fetched#2020-01-1617:35darwinok, true#2020-01-1617:36darwinbut just the fact that it fetched the url could add it into DevTools and cljs source reference would work#2020-01-1617:36darwin(my guess)#2020-01-1617:37thhellermy guess is that it expects //# sourceURL= or something instead of just /js/cljs-runtime/foo.bar.js#2020-01-1617:38thhellerI can't remember if I ever tried this in a browser context. I tried it in react-native and that didn't work at all since you don't know the location#2020-01-1617:39thhellerI do remember that I played around with this a whole bunch ... wish I left more comments 😛#2020-01-1617:40darwin🙂 this stuff is still in flux, there used to be pretty bad bugs in devtools sourcemap implementation for example, so stuff could have changed since you last looked#2020-01-1617:41thhellerthats possible too .. it has been 2 years or so since I implemented that#2020-01-1617:41darwinthere are still issues between mapping locals, but it is low priorty for them to fix: https://github.com/binaryage/dirac/issues/53#2020-01-1617:42thhelleryeah its pretty unreliable in some situations#2020-01-1617:43darwinhere is the issue I have with breakpoints: https://github.com/binaryage/dirac/issues/64 is works only sometimes on simple code#2020-01-1617:43darwinit would help if cljs generated dev code on more lines (use more newlines to split logical js pieces like humans)#2020-01-1617:45thhellerby now I've seen enough generated JS to know what the CLJS looked like 😛#2020-01-1617:46darwinI see, that is what I tend to do as well, but I have to see the js files in devtools 🙂#2020-01-1617:54darwin@thheller good news, your guess was correct changing sourceURL to full url fixed the issue in :eval mode for me#2020-01-1617:55darwinsorry, I didn’t understand it at first because whenever I saw sourceURL I thought I’m reading sourceMappingURL, so I didn’t get it#2020-01-1617:56darwinhave to go, will updat the ticket later#2020-01-1617:56darwinshould be an easy fix, I hope#2020-01-1701:49samedhiHello. I am attempting to write a macro in cljs using shadow-cljs. https://gist.github.com/samedhi/f8c6aa8eb5ca435ffac808da27e85978 . I have sidestepped most of the issues with referring to clojurescript ns by using their full names rather than using :as and a symbols to the respective ns. However, I am just not sure how to refer to a a NPM package "firebase-admin" from within my cljs macro. Two questions: 1. Is there a better way of referring to cljs ns from my macro? Some seem to work and some don't, quick summary on why that is? 2. How do I refer to node packages from a clojure macro? In my case I am attempting to use ["firebase-admin" :as admin], but that does not work within my clj macro namespace.#2020-01-1701:57samedhiEnd goal is to have a testing helper that lets me write expressions like the following.
(deftest-function create-example-with-macro-test
  sut/create-example-cloudfx
  [doc1 "messages/message-1" {"foo" "bar"}
   doc2 "messages/message-2" {"foo" "baz"}]
  (t/is (not= (.get doc1 "foo") (.get doc1 "foo")))
  (t/is (not= "bar" (.get doc1 "foo")))
  (t/is (not= "baz" (.get doc2 "foo")))
  ;; And presumably also testing some side effect of the sut/create-example-cloudfx running
  )
#2020-01-1709:16thheller@samedhi you can't reference JS namespaces directly in macros without using resolve-var. the common thing I recommend is doing something like (ns foo.bar (:require ["thing" :as x])) (def thing-you-need-in-macro x/foo)#2020-01-1709:16thhellerand then using foo.bar/thing-you-need-in-macro in the actual macro#2020-01-1709:17thhelleralso follow https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-01-1709:17thhellerthen you have the place where to put it right there#2020-01-1709:26thhelleralso very little of this macro would actually need to be written by this macro#2020-01-1709:26thhellerI'd advise moving most of it out into a helper function and only use the macro to generate the boilerplate needed#2020-01-1712:08darwin@thheller just by chance do you remember how you added support for :default keyword into your ns analyze phase? as documented here: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-01-1712:08darwincljs compiler’s analyze is choking on it and complains about it#2020-01-1712:09darwinI tried to look into shadow-cljs sources, but I don’t see any explicit mention how it is handled#2020-01-1712:11darwinwhen I try to pass shadow-cljs ns-form with :default into vanilla cljs analyze it gives me “Only :as, :refer and :rename options supported in :require / :require-macros…”#2020-01-1712:53thheller@darwin I replaced the ns parser with one that I wrote. https://github.com/thheller/shadow-cljs/blob/5ee9efcb7cae4ec558227bd04aa9d083c8aefc7c/src/main/shadow/build/compiler.clj#L169#2020-01-1712:54thhellerthe feature was kinda rejected though: https://clojure.atlassian.net/browse/CLJS-2376#2020-01-1712:54darwinok, thanks, are you aware of anything else like :default which would cause error in ana/analyze in normal cljs?#2020-01-1712:55darwinif it is just :default, I can easily preprocess ns-forms before feeding them into cljs analyze#2020-01-1712:55thhellerthats the only non-standard thing yes#2020-01-1712:55darwinok, great, thanks#2020-01-1713:22bbssI'm messing about with yarn link to test some third party library feature that's not pushed to npm yet. Am I right to conclude shadow-cljs doesn't deal with links?#2020-01-1713:23thhellerdunno what yarn link does exactly. symlinks are fine#2020-01-1713:24bbssI think they create symlinks, but have some extra registry in ~/.config/yarn/...#2020-01-1713:24bbsswill try my hand at a manual symlink then 🙂#2020-01-1713:43bbssmade a symbolic link to the directory node_modules but still getting
Search in:
	/Users/baruchberger/work/gsv/node_modules
You probably need to run:
  npm install 

See: 
#2020-01-1714:05thhellerso does /Users/baruchberger/work/gsv/node_modules/deck.gl/package.json exist or not?#2020-01-1714:07thhellerI think http://deck.gl was one of those packages the closure compiler doesn't like? its from uber right?#2020-01-1714:56simongrayIf I want to develop a library in shadow-cljs that uses an NPM package, is there simply no way to distribute this as a jar that can be used in a non-shadow-cljs project?#2020-01-1714:56simongrayThe official documentation is a bit lacking in this area#2020-01-1714:57simongray> Please note that currently only `shadow-cljs` has a clean automatic interop story with `npm`. That may represent a problem for users of your libraries using other tools. You may want to consider providing a CLJSJS fallback and/or publishing extra documentation for `webpack` related workflows.#2020-01-1714:59simongraySo what does this mean in practice? Either I create a CLJSJS package in which case the business value of shadow-cljs diminishes or I distribute some kind of setup instructions with the library?#2020-01-1714:59simongrayWhat would that "extra" documentation look like, though?#2020-01-1715:17bbssYes, it's from uber, huge repo. https://github.com/uber/deck.gl/blob/master/package.json they seem to work with lerna for sub modules.#2020-01-1715:20bbssEither way no issue if this isn't supported for now 🙂.#2020-01-1715:33wilkerlucio@simongray there is a trick, you can add a deps.cljs in your source root, and there you can declare NPM deps, example: https://github.com/wilkerlucio/pathom-viz/blob/master/src/core/deps.cljs#2020-01-1715:34wilkerluciothem, if you use the CLJS library with Shadow, it will automatically install those deps#2020-01-1715:35wilkerluciooh, sorry, just noticed you asked for non-shadow, in that case will be hard considering that no other cljs build tools have proper support for NPM directly#2020-01-1715:35simongrayExactly. Hm, I think will investigate making a CLJSJS package instead then and probably just stick with figwheel.#2020-01-1715:36simongrayI was mainly interested in shadow-cljs for its NPM support.#2020-01-1715:37simongrayBTW I just saw your Conj talk last week! Really cool stuff :)#2020-01-1715:45thheller@simongray yeah you pretty much have to create a matching cljsjs package. if you configure things correctly shadow-cljs will use npm directly and the others will fall back to cljsjs#2020-01-1715:46thhelleror you can skip the cljsjs and provide manual instructions for people using webpack+cljs#2020-01-1715:48thhellerI don't know how many people actually use webpack+cljs though#2020-01-1815:46simongrayOk. Thanks for taking the time to answer!#2020-01-1716:49darwinaynone seen this error? “Requested module does not have an export <name>” it gets printed afte “Closure compilation failed with 2 errors”#2020-01-1716:51darwinI’m trying to convert react-three-fiber examples into cljs with shadow-cljs, and wanted to require their shader js files as is by following https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js (using absolute path)#2020-01-1716:54darwinI put this file[1] on classpath and then require it as ["/resources/shaders/Backface" :as BackfaceMaterial], shadow-cljs then complains ` [1] https://github.com/react-spring/react-three-fiber/blob/master/examples/src/resources/shaders/Backface.js#2020-01-1716:54darwin#2020-01-1716:54darwinbtw. three.js is properly specified in package.json#2020-01-1717:00darwinShaderMaterial is defined here: https://github.com/mrdoob/three.js/blob/dev/src/materials/ShaderMaterial.d.ts#L34#2020-01-1717:00darwinBackSide here: https://github.com/mrdoob/three.js/blob/dev/src/constants.d.ts#L43#2020-01-1717:43thheller.d.ts files are irrelevant. they aren't used in any way.#2020-01-1717:43thhellerclosure is picky about commonjs -> esm interop#2020-01-1717:44thhellersince it doesn't understand the way shadow-cljs processes JS it seems three as a commonjs dependency#2020-01-1717:44thhellerthus you can only do import Three from "three"#2020-01-1717:44thhellerand then use Three.BackSide in the code#2020-01-1717:44darwinok thanks, I think I can live with that#2020-01-1717:44darwinlet me try it#2020-01-1717:45thhellerbut .. given that you can't provide type hints in JS for inference it'll likely have problems with :advanced#2020-01-1717:45thhellerso you might need to provide externs#2020-01-1717:46darwinbtw. in the meanwhile I tried to attach Intellij Java debugger to the shadow-cljs process, I was able set breakpoints and break on them but no debug inspections were possible, it always displayed “Debug information is inconsistent”#2020-01-1717:46darwinnot sure how to fix this, google doesn’t help#2020-01-1717:47darwinthen I followed your “Hacking” docs and was able to replace some shadow-cljs sources with my copy, so I was able to work around it#2020-01-1717:47thhellerno clue. I have never tried that#2020-01-1717:49darwinI wonder if it is not related to the way how you prioritize “The shadow-cljs compiler ensures that things on your source paths are compiled first”#2020-01-1717:52thhellerno#2020-01-1717:52thhellerthats regular JVM logic#2020-01-1717:52thhellerthe classpath is just constructed by listing the source paths first#2020-01-1717:52thhellerit works like that is probably all other tools as well#2020-01-1717:53thhellernothing special about that#2020-01-1717:53darwinok#2020-01-1717:53darwinbtw. your suggestion worked, now it got compiled without issues#2020-01-1717:53darwinwant to get it working in dev mode first, will be solving advanced mode later#2020-01-1717:54darwinbtw. this is my first real shadow-cljs project and I’m impressed with the whole experience. Kudos!#2020-01-1718:26darwinI still seem to be unable to make it work. Cannot access Three.something , because it generates Three.default.something instead of Three.something in js#2020-01-1718:27darwinhttps://gist.github.com/darwin/8849ff09a5743d8a74d11d79695c93cf#2020-01-1718:28thhellerjust use require instead of import#2020-01-1718:28thhellerthe ESM import/export handling in closure is rather strict#2020-01-1718:29thhellercommonjs is a lot easier to work with 😛#2020-01-1718:31darwinhmm, const Three = require("three"); results in similar issue,#2020-01-1718:31thhellermaybe import * as three from "three" works#2020-01-1718:32darwinthis is result from plain require: https://gist.github.com/darwin/d0f1f7853f742aa9544034a9585fee4d#2020-01-1718:35thhellerhmm looks like closure still recognized the file as ESM#2020-01-1718:35thhellerneed to replace the export too#2020-01-1718:35thhelleror just add module.exports = 'foo'; or so#2020-01-1718:35darwinimport * as three from "three" works!#2020-01-1718:36thhellernot sure what the detection of closure is looking for#2020-01-1718:36thhellerah ok#2020-01-1718:36darwinthanks a lot, I wouln’t be able to solve this - I’m unfamiliar with all these details of JS modules#2020-01-1718:37darwinI almost wanted to hack it by storing three object in some global js var in cljs code and access it in the js file#2020-01-1718:40thhellerwouldn't that be the same as you have not with import *?#2020-01-1718:42darwinyep, now the generated code looks the same (just decorated to prevent clashes) not sure about advanced mode tough#2020-01-1718:43darwinbut it is dirty to go explicitely via globals, so I’m happy that at least one form of import worked 🙂#2020-01-1718:46thhelleryeah CLJS -> JS -> npm isn't something I spent much time on so it has rough edges#2020-01-1719:46p-himikI decided to give the AdoptOpenJDK 13 a try and it seems to work for the most part. But there are some bizarre errors that pop up intermittently during compilation. It seems that it always involves clojure.lang.KeywordLookupSite$1. Example 1:
------ WARNING #1 - :invalid-arithmetic ----------------------------------------
 File: /home/p-himik/dev/git/ensemble/src/hgs/strayhorn/named_expressions/views.cljs:26:5
--------------------------------------------------------------------------------
  23 |                                       (cst/split model ",")
  24 |                                       [])))
  25 |         roman-on-change #(on-change (cst/join "," %))]
  26 |     (fn [_ & {:keys [error]}]
-----------^--------------------------------------------------------------------
 cljs.core/unsafe-bit-and, all arguments must be numbers, got [#object[clojure.lang.KeywordLookupSite$1 0xae194d44 "
Example 2:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/p-himik/.m2/repository/com/cognitect/transit-cljs/0.8.256/transit-cljs-0.8.256.jar!/cognitect/transit.cljs:295:6
--------------------------------------------------------------------------------
 292 |   ([tag-fn rep-fn str-rep-fn]
 293 |      (write-handler tag-fn rep-fn str-rep-fn nil))
 294 |   ([tag-fn rep-fn str-rep-fn verbose-handler-fn]
 295 |      (reify
------------^-------------------------------------------------------------------
Syntax error macroexpanding cljs.core/deftype.
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.IFn
	clojure.spec.alpha/spec-impl/reify--2059 (alpha.clj:923)
Example 3:
------ ERROR -------------------------------------------------------------------
 File: /home/p-himik/dev/git/ensemble/src/hgs/ella/score_details/sequences/views.cljs:297:3
--------------------------------------------------------------------------------
 294 |     :children (mapv (fn [w] [rc/label :label w]) issues)]])
 295 | 
 296 | (defn question-panel [_game-id changeset-id q args]
 297 |   (let [{:keys [events subs]} args
---------^----------------------------------------------------------------------
Syntax error macroexpanding cljs.core/nil?.
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.IFn
#2020-01-1719:46p-himikCan you make any sense of it?#2020-01-1719:51p-himikCouldn't find anything on the warning about unsafe-bit-and. But the warning about ClassCastException is also mentioned here: https://github.com/thheller/shadow-cljs/issues/443 As well as OpenJ9 (aka AdoptOpenJDK I believe). I do embed shadow-cljs, but I definitely don't interact with the REPL in any way when these issues occur.#2020-01-1721:25sogaiure: "...as OpenJ9 (aka AdoptOpenJDK..." - iiuc, adoptopenjdk does have openj9 builds, but adoptopenjdk != openj9 adoptopenjdk also provides openjdk builds or may be i misunderstand?#2020-01-1806:54p-himikThanks, seems like you are correct.#2020-01-1720:31thheller@p-himik not a clue. I've been on openjdk 13 since it came out without issues#2020-01-1721:07mauricio.szaboYes, in my experience unless it's a simple project, is close to impossible to run shadow-cljs on OpenJ9. These errors happen sometimes, specially when I'm using macros or core.async#2020-01-1721:12thhellernever tried openj9. do other clojure apps work? don't know why shadow-cljs would break. its just normal clojure.#2020-01-1721:25mauricio.szaboYes, everything works fine. I remember that in the past I opened another bug on shadow because of OpenJ9 (something about detecting if a file was stale, if I'm not mistaken)#2020-01-1721:25mauricio.szaboThis one: https://github.com/thheller/shadow-cljs/issues/383#2020-01-1721:26mauricio.szaboTo be honest, I did not try other CLJS implementations like Figwheel, so it can be a ClojureScript compiler issue too...#2020-01-1721:58Eric IhliI'm curious if anyone would know of this to be a problem.
(defmacro slurp [file]
  (clojure.core/slurp (io/file (io/resource file))))
(ns ezmonic.e-data
  (:require [cljs.reader :as reader])
  (:require-macros [ezmonic.util :refer [slurp]]))

(defonce data
  (reader/read-string (slurp "number-to-word-tree.edn")))
I'm using that to read a 6MB file. Everything works fine in the emulator. But, when I create a release bundle and install it on my phone, the app freezes for 10 seconds when going to and coming from the background. (React Native)
#2020-01-1721:59thhellerparsing 6MB of EDN is really slow. the emulator is just too fast.#2020-01-1722:00Eric IhliI would not expect it to have to parse the EDN when going to/from the background though. I would only expect that on startup, no?#2020-01-1722:00thhellermaybe you aren't allowed to use that much memory?#2020-01-1722:00thhellerI don't do react-native development. maybe try asking in #cljsrn#2020-01-1722:01thhelleralso consider reading https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-01-1722:01thheller:require-macros is so ugly 😛#2020-01-1722:03thheller6MB of EDN source will be much more are runtime, do you have stats about memory use for the app?#2020-01-1722:05Eric IhliGood ideas. I'll take a look at the memory, and thanks for the link.#2020-01-1816:21Aleedis this object notation allowed in shadow? (foo.bar.baz) cljs docs says its supported (https://cljs.github.io/api/syntax/dot), but not sure why i'm receiving use of unresolved var#2020-01-1816:22Aleedspecifically the require looks like this [lib.core :refer [comp]] and i'm trying to use it like this (comp.view (comp.text "Hello World"))#2020-01-1817:49thhellerthat is not valid syntax no#2020-01-1817:50thhellerit is not valid for refer etc. pretty much only for global symbols#2020-01-1817:45dpsuttoni'm looking at adding a bit more support to clojure-lsp for shadow. The base for this is knowing the classpath for a project. I see that you can run shadow-cljs classpath and get the classpath but it unfortunately prints out some info that is unnecessary like config, node version, etc. Is there a way to get just the classpath info without any of this extra information?#2020-01-1817:50thheller@dpsutton the "extra" info is printed to stderr. the classpath info should be the only thing on stdout#2020-01-1817:50dpsuttonawesome. thanks#2020-01-1817:51dpsuttonindeed. thanks!#2020-01-1817:55jmckitrickI’m coming back to clojure and CLJS after a hiatus, and I’m curious how shadow-cljs compares to figwheel-main. Last I checked, shadow-cljs was superior for integrating nodejs libraries.#2020-01-1817:56thhellershadow-cljs still does way more than figwheel and still has better npm interop 😉#2020-01-1817:56sogaiu@dpsutton on a slightly related note, if invoking shadow-cljs via npx or yarn, those have flags to be more quiet in the output. for npx it's --quiet and for yarn it's --silent.#2020-01-1817:59dpsuttonare you saying that npx shadow-cljs classpath will put the stderr onto std out?#2020-01-1818:01sogaiui also used shadow-cljs classpath in a project and found that without the --quite and/or --silent flags was seeing extra output (if using yarn/npx). at least that was my recollection. i don't recall exactly what happens without them, but i found that using the flags seemed to help 🙂#2020-01-1818:02sogaiufor reference: https://github.com/sogaiu/alc.index-defs/blob/master/src/alc/index_defs/impl/paths.clj#L88#2020-01-1818:05sogaiunpx --help says:
--quiet, -q            Suppress output from npx itself. Subcommands will not
                         be affected.                                  [boolean]
#2020-01-1818:06dpsuttonAwesome. Thanks for the pointer. I bet that’s truly awful to figure out in the wild :)#2020-01-1818:07sogaiulol, wasn't fun for sure 🙂#2020-01-1817:58jmckitrick@thheller Ah, ok. It’s nice to be back. 🙂 What about rebel readline? I guess that doesn’t matter with cider, correct? Do you have feature list for comparison? I’m sure you hear this question all the time#2020-01-1817:59thhellerI can't do comparisons since I have never used figwheel or figwheel-main. rebel-readline is not supported but that doesn't matter with cider. cider has good support for shadow-cljs nowadays (I think, I use Cursive)#2020-01-1818:00dpsuttonit does 🙂 rebel readline is a terminal client and not necessary if you are using an integrated editor#2020-01-1818:19jmckitrickSo really, then, is there any reason I’d use figwheel-main? 😉#2020-01-1900:34mauricio.szaboNot for me 🙂#2020-01-1900:40mauricio.szaboSeriously, Shqadow does integrate better with any target I've tried. It is better on generating node (I'm using it currently on some devops projects and did some experiments with proton-native), node libraries (Chlorine is one of these, I also made a hubot script with it), browser (it can live-reload jQuery 😄) and so on#2020-01-1818:29jmckitrickI have a side question, as well. I recently spoke with a CTO who says the Google Closure compiler is really not that great. That’s the first time I’d ever heard that, and he’s been working with CLJS for quite some time. Have you found that to be the case? Just curious.#2020-01-1818:29jmckitrickI’d been singing praises of Closure over the usual (more common) JS ecosystem, but I don’t want to repeat misinformation.
#2020-01-1818:31sogaiuit would be interesting to hear more specifics regarding "really not that great" 🙂#2020-01-1818:32jmckitrickYes, I wish I had more to offer, but it was a brief conversation.#2020-01-1818:33thhellerit is "not that great" if you point it at random javascript from npm#2020-01-1818:33thhellerif you use it with code that is written for it (CLJS, Closure Library) it is absolutely fantastic with nothing else coming even remotely close in the JS world currently#2020-01-1819:04skrothhas anyone seen this error before? I get it when i do shadow-cljs release app#2020-01-1819:57tbrookeI am trying to add the following as a dependency in my shadow-cljs.edn file and I get “bad artifact coordinates” error - obviously bad formatting:
[metosin/malli {:git/url ""
               :sha     "1a1038d2473c6de784252b6ad42a6cc1e764ebcc"}]
How do I do this?
#2020-01-1820:00thheller@slack1490 that is caused by a dependency conflict. likely because you are using deps.edn or project.clj. you should have these versions
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-01-1820:02skroththanks! I'll look into it#2020-01-1820:22skrothawesome, got it going. thanks again#2020-01-1820:00thheller@tbrooke git deps are only supported if you manage dependencies via deps.edn. shadow-cljs.edn does not currently support them directly.#2020-01-1820:02tbrooke@thheller OK, Thanks#2020-01-1820:17thhellerSome people expressed interest in the web framework I'm working on. I wrote down some notes and started porting the shadow-cljs UI in case anyone is still interested. finally no more react 🙂 https://github.com/thheller/shadow-experiments https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#2020-01-1900:37mauricio.szaboWow, great! How does it compare, for example, with reagent/react/vue? Does it uses some kind of "virtual DOM", does it listens to changes on atoms?#2020-01-1911:53thhellerI wrote some more stuff here https://github.com/thheller/shadow-experiments/tree/master/doc#2020-01-1911:54thhellerthere is no full virtual DOM no. it can listen to changes on atoms yes#2020-01-1911:55thhellerI'll write more about this if I decide to make this an actual framework at some point 😛#2020-01-1820:19thhellernowhere near ready for public use but I can setup a basic example app if someone feels like experimenting#2020-01-1820:19thhellerthe next shadow-cljs release will include UI built on top of it so you'll see it in action there 😉#2020-01-1908:11p-himikIt seems there's an issue in FileWatcher. If a new directory is created with a bunch of files and then removed shortly thereafter, there can be a java.nio.file.NoSuchFileException:
Exception in thread "async-thread-macro-1" java.nio.file.NoSuchFileException: /%python-subdir-within-project%/__pycache__/flow_control.cpython-37.pyc.140019814933808
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
	at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:149)
	at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
	at java.base/java.nio.file.Files.readAttributes(Files.java:1763)
	at java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225)
	at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
	at java.base/java.nio.file.FileTreeWalker.next(FileTreeWalker.java:373)
	at java.base/java.nio.file.Files.walkFileTree(Files.java:2760)
	at shadow.util.FileWatcher.registerAll(FileWatcher.java:41)
	at shadow.util.FileWatcher.pollForChanges(FileWatcher.java:114)
	at shadow.util.FileWatcher.pollForChanges(FileWatcher.java:76)
	at jdk.internal.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
	at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:438)
	at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invokeStatic(fs_watch_jvm.clj:17)
	at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invoke(fs_watch_jvm.clj:16)
	at clojure.core$map$fn__5866.invoke(core.clj:2753)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.RT.seq(RT.java:535)
	at clojure.core$seq__5402.invokeStatic(core.clj:137)
	at clojure.core$apply.invokeStatic(core.clj:660)
	at clojure.core$mapcat.invokeStatic(core.clj:2783)
	at clojure.core$mapcat.doInvoke(core.clj:2783)
	at clojure.lang.RestFn.invoke(RestFn.java:423)
	at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invokeStatic(fs_watch_jvm.clj:46)
	at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invoke(fs_watch_jvm.clj:33)
	at shadow.cljs.devtools.server.fs_watch_jvm$start$fn__73779.invoke(fs_watch_jvm.clj:77)
	at clojure.core.async$thread_call$fn__34862.invoke(async.clj:484)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
#2020-01-1908:14p-himikJust to give some context - my project is a mix of Clojure, ClojureScript, and Python. I work with the Python code just by calling shell/sh.#2020-01-1908:21p-himikSo it seems like if a file is deleted when Files.walkFileTree is doing its job, there's a chance the whole walk will fail because of it. I guess somewhat of a fix would be to keep calling Files.walkFileTree until there's no NoSuchFileException.#2020-01-1911:28thheller@p-himik why is it watching that directory in the first place?#2020-01-1911:56p-himikBecause that directory is on the classpath.#2020-01-1912:16thhellerI already have a setting to ignore certain files/paths on the classpath#2020-01-1912:16thhellerhttps://github.com/thheller/shadow-cljs/blob/859809dba535f30788cc382a45cb1d045b24f008/src/main/shadow/build/classpath.clj#L922-L940#2020-01-1912:16thhellerthats not currently configurable but I could add an option to let you exclude __pycache__?#2020-01-1912:16thhellerwhy is it on the classpath though? seems like tmp files should not go there 😛#2020-01-1912:24p-himikThe Python sources are not tmp though. But Python creates __pycache__ right next to the sources. I could of course move Python sources out of the classpath altogether. But having them there gives a nice ability to not have to deal with arbitrary paths when some files are shared between CLJ and Python code.#2020-01-1912:28p-himikNot sure that code above would work though. E.g. I have src on the classpath. Somewhere in there are both CLJ and Python sources. __pycache__ will be created there as well - not at the top level.#2020-01-1912:29p-himikAlso, just excluding something doesn't solve the potential issue itself since you can reproduce it with arbitrary code. But one could argue that that's a problem with Files.walkFileTree. Not sure.#2020-01-1912:34thhelleryes but there first is a check if a directory should even be traversed#2020-01-1912:35thhellerso if it just stops at pycache__ the problem should be gone#2020-01-1912:36thhellerI'd advise keeping it off the classpath though ... I doubt python will be able to read them from there if you move to a uberjar#2020-01-1912:37p-himikThe check at shadow.build.classpath/get-classpath-entries? It would leave src in there. And then a FileWatcher would be created for src. And FileWatcher doesn't exclude anything.#2020-01-1912:38p-himikIf I move to an uberjar - how would I even use Python sources stored in there? I don't think I can use an uberjar at all at this point.#2020-01-1912:39p-himikThere's a plan to get rid of Python, which is nice. But the current plan is to replace it with Swift, which will make some things even worse. :)#2020-01-1912:52karthikHi, I’m new to Clojure world here. I’m using ClJS to create and deploy firebase functions. I’m using shadow-cljs to perform the compilation to the JS lib. I’m not sure where to ask this. But is it possible to jump to js library implementation during the development phase ? Say for eg: I am importing an express js library and want to jump to implementation.#2020-01-1915:44p-himikThis is an IDE issue, it's only tangentially related to build tools.#2020-01-1915:44p-himikFWIW, Cursive cannot do that.#2020-01-2418:17karthikAh okay. Thanks!! I tried Calva and Cursive and no luck.#2020-01-1917:40daniel.spanielIs there a way to write a hook for shadowjs to "run a clojure function" if a certain file changes in my repo ?#2020-01-1918:09thhellerno#2020-01-1918:10thhellerwell you can write one but nothing out of the box#2020-01-1918:45odinodinI’ve got a cljs-dependency which references a transitive dependency via js/ prefix (js/snabbdom), but even though I’ve added snabbdom to npm deps it fails#2020-01-1918:45odinodinany idea about how to fix this?#2020-01-1918:46odinodinI can reference snabbdom directly though, so I know it has been properly added to shadow-cljs#2020-01-1920:19thheller@odinodin if the library is just using js/snabbdom without any require for it you can create it by exporting that global variable in a namespace that included before that lib#2020-01-1920:20thhellerhttps://github.com/thheller/shadow-cljsjs/blob/master/src/main/cljsjs/react.cljs#2020-01-1920:20thhellersimilar to this#2020-01-1920:20thhellerjust need to make sure it is included before the lib tries to access js/snabbdom#2020-01-1922:34steveb8nQ: I’ve started running nodejs tests using the :autorun feature. this works great. when tests fail, the line numbers are for the .js artifact i.e. source maps are not used (by default). Is it possible to configure source maps in this mode so the line numbers are for the cljs source?#2020-01-2009:12mccraigmccraigwe use https://www.npmjs.com/package/source-map-support#2020-01-2009:13mccraigmccraigah, but you are looking at the autorunner... hmm - dunno there#2020-01-2022:53steveb8nthanks. I’ll try that out. worst case I’ll stop using the autorunner and use node watch to run the tests instead#2020-01-2016:48Eric IhliI'm trying to require a json object from a json file. (ns foo (:require ["test.json" as test-json])) compiles to SHADOW_IMPORT("module$src$test_json.js");, if I'm reading this correctly. Obviously that can't be found. I was expected this to work according to https://medium.com/technoetics/reading-data-from-json-files-in-react-native-3622744b75e3 saying import sample from '../dbstore/sample1.json'; would work.#2020-01-2016:49thhelleryou need to provide an actual path#2020-01-2016:50thhellerso ["./test.json" :as test-json]#2020-01-2016:50Eric IhliOh, sorry, I also have
:resolve {"test.json" {:target :file
                        :file "src/test.json"}}
#2020-01-2016:50thhelleryeah thats not how that works#2020-01-2016:50thhellerif you are in react-native you should be using js/require#2020-01-2016:50thhellerso not inside the ns#2020-01-2016:51thheller(def data (js/require "../path-to/file.json"))#2020-01-2016:51thhellerwhere the path is relative to the :output-dir#2020-01-2016:51Eric IhliAh. Ok. Thank you so much.#2020-01-2016:56thhellerFWIW :resolve is typically only used in cases where you can't change the code that does the require (eg. in libraries)#2020-01-2016:57thhellerif you can change the require that should be your first option. :resolve doesn't give require any new options otherwise#2020-01-2016:59Eric IhliI see. Thanks. That seems logical in hindsight.#2020-01-2022:28Adrian SmithI'm playing with uix: https://www.reddit.com/r/Clojure/comments/erdo6t/desktop_apps_in_clojurescript_and_qt/ but it doesn't exist on clojars appears it wants to be included with deps.edn via git shas: https://github.com/roman01la/uix I'd like to use hot code reloading with it so I'm looking at shadow#2020-01-2022:30Adrian SmithBuild error looks like https://i.imgur.com/81uErti.png though works ok if invoked via node out/main.js#2020-01-2022:28Adrian Smithbut not sure how to include uix as a dependency in shadow-cljs.edn#2020-01-2022:37thhellerjust use deps.edn#2020-01-2109:55Adrian Smithhmm uix library is specified in deps.edn - https://github.com/roman01la/proton-native-cljs/blob/master/deps.edn is that what you meant?#2020-01-2109:57thhellerno I mean use deps.edn with shadow-cljs https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2020-01-2110:38Adrian SmithThat worked thank you it builds, I have another error now but suspect it's not related to shadow#2020-01-2110:46thhellerwhat is it? I know roman sometimes likes to write weird code that reaches deeply into the compiler that may cause issues with shadow-cljs 😛#2020-01-2110:51Adrian Smithlol, there was an error coming out of react-proxy for this line: https://github.com/roman01la/proton-native-cljs/blob/master/src/app/core.cljs#L200 I've replaced that locally with the same code but behind a function called main! and updated my build's :main key to that function I now have a build without errors and running node out/main.js runs the app without error but there's no live reloading I can see shadow is recompiling though#2020-01-2110:52Adrian SmithI think this line https://github.com/roman01la/proton-native-cljs/blob/master/src/app/core.cljs#L204 is supposed to be the line for reloading and it has meta data but I don't know if that's enough I haven't told shadow about it otherwise#2020-01-2110:53thhellerhmm yeah thats figwheel. its ^:dev/after-load in shadow-cljs#2020-01-2110:59Adrian Smithah cool I think it's working I can see println output from update! I was assuming I could change the numbers on the calculator and immediately see that I don't think the update-proxy! thing is updating the react components properly#2020-01-2102:22Eric IhliHow would I delete something from the require cache in shadow-cljs/react native? Trying to time how long it takes to require a really big json object.
delete require.cache[require.resolve('./b.js')]
#2020-01-2108:45thheller@ericihli I doubt react-native can do that. shadow-cljs is not part of that loading process once metro is done#2020-01-2114:15Filipe Silvahi there#2020-01-2114:15Filipe SilvaI have a codebase that I am updating from shadow-cljs 2.8.67 to 2.8.83 (latest)#2020-01-2114:16Filipe Silvawhen this codebase is compiled in release mode, it shows an error at runtime that seems related to module loading#2020-01-2114:16Filipe Silva(this log is obtained with :pseudo-names true :pretty-print true on the compiler options)#2020-01-2114:17Filipe Silva
main.js:158 Error: 1
    at main.js:3498
    at $goog$module$ModuleLoadCallback$$.execute (main.js:17943)
    at $JSCompiler_StaticMethods_callCallbacks_$$ (main.js:3444)
    at $goog$module$ModuleInfo$$.$APP.$JSCompiler_prototypeAlias$$.onError (main.js:17977)
    at $JSCompiler_StaticMethods_dispatchModuleLoadFailed_$$ (main.js:3613)
    at $JSCompiler_StaticMethods_requeueBatchOrDispatchFailure_$$ (main.js:3579)
    at $goog$module$ModuleManager$$.$APP.$JSCompiler_prototypeAlias$$.$handleLoadError_$ (main.js:18099)
    at $JSCompiler_StaticMethods_evaluateCode_$$ (main.js:4227)
    at $goog$module$ModuleLoader$$.$APP.$JSCompiler_prototypeAlias$$.$handleSuccess_$ (main.js:18605)
    at $JSCompiler_StaticMethods_fireListeners$$ (main.js:3882)
#2020-01-2114:18Filipe Silvait's not super clear to me how to proceed in debugging it, or what might have changed between these versions of shadow-cljs#2020-01-2114:19Filipe Silvadoes anyone know what it might relate to, or how I can discover what it relates to?#2020-01-2114:19thhellerBTW you can run shadow-cljs release app --pseudo-names to set those options. don't need to actually put them into the config#2020-01-2114:19thhellerbut no I don't know what that is#2020-01-2114:19thhellerthe closure-library/compiler were updated inbetween those versions so maybe the affects things#2020-01-2114:20thhellerjust open chrome, check the "pause on exception" thing and try to figure out whats wrong from there#2020-01-2114:20Filipe Silvawill do, thank you#2020-01-2114:26Filipe Silvahm yeah, I found something that might make sense#2020-01-2114:26Filipe Silva
$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha62946$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$256$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
  return $APP.$cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $APP.$cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $APP.$cljs$spec$alpha$op_describe$$(this.$re$));
});
#2020-01-2114:26Filipe Silva
TypeError: Cannot read property 'prototype' of ...
#2020-01-2114:26Filipe Silvaupdating shadow-cljs probably brough a new version of spec (because we didn't pin it)#2020-01-2114:27Filipe Silvaand spec might have change alpha changes#2020-01-2115:14Filipe Silvayeah it seems to break when going from 2.8.71 to 2.8.72, which is when shadow updated cljs to 1.10.597#2020-01-2116:01thheller@filipematossilva maybe try setting :compiler-options {:output-wrapper false} in case you are using multiple :modules#2020-01-2116:01thhellerthat default changed to true as well (which is where the $APP comes from#2020-01-2116:19Filipe Silvahmm doesn't seem to make a difference#2020-01-2116:20Filipe Silvathe code changes, but the error is still the same#2020-01-2116:20Filipe Silva
$cljs$spec$alpha$t_cljs$0spec$0alpha28640$$.prototype.$cljs$spec$alpha$Spec$gen_STAR_$arity$4$ = $JSCompiler_unstubMethod$$(6, function($_$jscomp$322$$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$) {
  return $cljs$core$truth_$$(this.$gfn$) ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$ ? this.$gfn$.$cljs$core$IFn$_invoke$arity$0$() : this.$gfn$.call(null) : $cljs$spec$alpha$re_gen$$(this.$re$, $overrides$jscomp$11$$, $path$jscomp$62$$, $rmap$jscomp$11$$, $cljs$spec$alpha$op_describe$$(this.$re$));
});
#2020-01-2117:51includeHi. Can someone point me a simple tutorial on how to spin-up a new shadow-cljs project with +re-frame dep? I was flowing http://shadow-cljs.org but now success... thanks :)#2020-01-2117:52thhelleryou can try https://github.com/day8/re-frame-template#2020-01-2117:55includehi @thheller thanks fro your reply 🙂 So I saw that repo and I can run lein new re-frame foobar so the process to integrade shadow-cljs comes next?#2020-01-2117:57thhellerno the template already has everything setup#2020-01-2117:57includearrrggg... you are super right... I miss the "The base template includes..." text... arrgggg#2020-01-2117:57thhellerjust run cd foobar and npm install npx shadow-cljs watch app#2020-01-2117:59include@thheller yes got it 🙂 let me see if I can repl this#2020-01-2118:00includerunning npm install (I am behind a mad proxy that blcoks me everything suspicious... lets see if i can get it here)#2020-01-2118:01thhellerI think there is also lein dev but you are going to need npm for react/react-dom anyways so ... 😛#2020-01-2118:02includeI see some of them being installed 🙂 hope it works... I really need to start learning cljs 😄#2020-01-2118:06include(I am running this under a very old WSL setup with linuxbrew ... /me cuts wrists#2020-01-2118:07includeHello from re-frame#2020-01-2118:07include🙂#2020-01-2118:10include@thheller thanks. it's working. Yes lein dev does the trick also.#2020-01-2119:15Aleeddoes shadow-cljs only have built in support for expo? (not react native itself, once you eject)#2020-01-2119:44darwinjust wondering if there is any way how to affect convert-sources-simple* to not remove names from “anonymous” functions, e,g, when passing function myName(…) {} as a callback parameter, google closure rewrites it into function (...) {}, I understand that the name is not needed, but I have a special case where I need it, react devtools use that name for display in component tree#2020-01-2119:52lilactown@darwin it should only do that rewriting when using optimizations. presumably you would want to use React devtools during dev, when you aren’t using optimizations?#2020-01-2119:53lilactown(clarified message above)#2020-01-2119:54darwin@lilactown I looked through the shadow-cljs code and it seems that shadow is using closure compiler in :simple mode to transform all stuff required via npm - that is also reason why it is minified (speaking about dev mode)#2020-01-2119:54thheller@alidcastano shadow-cljs doesn't care at all. both expo and react-native work fine. I made some demos a while ago https://github.com/thheller/reagent-react-native or https://github.com/thheller/reagent-expo#2020-01-2120:06Aleedah interesting. I couldn't get hot reloading to work when using bare react native, but will make sure to look at example and try again. thanks!#2020-01-2120:06thhelleryeah you need some kind of helper since react-native doesn't allow switching the root component#2020-01-2120:07thhellerso you need something like https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L64#2020-01-2120:07thhellerothers have written other implementations, don't know where they are though#2020-01-2120:07thhellerI don't use react-native so there may be other/better ways#2020-01-2121:23Eric IhliHere's my implementation, heavy with comments (not necessarily all correct). https://github.com/eihli/cljs-react-native-starter/blob/master/src/example/core.cljs#2020-01-2121:25Eric IhliI also refer to this repo on occasion https://github.com/status-im/status-react It's a good example of a quite large app. Good ideas for structuring as you grow.#2020-01-2121:26Aleedgreat, thanks for the examples#2020-01-2119:56darwinmaybe I could use :js-options :resolve in this special case and point to raw sources I see in the npm package, but I’m not sure how to specify path in :resolve#2020-01-2119:57darwinand even when using :resolve it would still use closure?#2020-01-2119:58lilactownhere’s an example of a reagent component, and then two components imported from NPM. the names are maintained#2020-01-2119:58thheller@darwin :js-options takes all the regular :compiler-options. don't know why it removes names, are you sure they aren't already gone when using the npm package? maybe that has minified sources?#2020-01-2119:59darwin@lilactown most names are maintained because those are class names or function components referenced elsewhere in the code#2020-01-2119:59thheller:resolve only affects where the source comes from, it does not change how it is processed#2020-01-2119:59darwin@lilactown but some (small) number of componentc coud be implemented as “anonymous” functions with this name being stripped#2020-01-2120:00darwin@thheller ok, thanks for answers, I saw that in the code that it merges :js-options without :resolve key, I tried :optimizations :none as my first step and it seems to not affect the output#2020-01-2120:01darwinI’m 100% sure that the raw package tar does not contain the minified soures and the names I care about are present there#2020-01-2120:01darwinwhat about the babel? is it applied in this case? or it is applied only when requiring direct js files?#2020-01-2120:01darwinmaybe babel is responsible for this#2020-01-2120:02thhellerit is applied to ESM modules in node_modules only#2020-01-2120:03thhellermaybe try :js-options {:variable-renaming :off}, defaults to :local in :simple#2020-01-2120:08darwin@lilactown just FYI, this is the issue I’m after: https://github.com/react-spring/react-three-fiber/pull/284/files#diff-d81b214c993ae261a5867e92ef560fa8R44 they merged my requests, but I’m unable to get it through shadow, because something (closure-or-babel) is stripping those names even in dev mode#2020-01-2120:14thhellerhttps://github.com/thheller/shadow-cljs/blob/711a5776525afc9968346479b709e1975452a47a/src/main/shadow/build/closure.clj#L130-L137#2020-01-2120:14thhellermaybe that does something?#2020-01-2120:14darwinhmm :variable-renaming :off didn’t help, it was a good try btw. I’m always deleting both .shadow-cljs and out directory, just to be sure no caches confuse my results#2020-01-2120:15thhellerdoubtful that matters .. cache invalidated if you change options#2020-01-2120:15thhellermaybe the closure CompilerOptions has a setting thats just not exposed from the config#2020-01-2120:16thhellerit has like a million settings. if you find one that applies I can easily add it#2020-01-2120:16darwinok, thanks, I will tinker with it, there must be a way#2020-01-2120:17thhellerhttps://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/CompilerOptions.java#2020-01-2120:35darwin:js-options {:anon-fn-naming-policy :unmapped} helpful, it gives all anonymous functions names of variables/keys which appear immediately before such anon function, in my case it gives them the exact names I want but I’d like to have option to keep original names and maybe generate a new one only when there is no name in the first place#2020-01-2120:58darwin@thheller it looks I will need setRemoveUnusedVariables to be set to NONE, at least according to https://github.com/google/closure-compiler/blob/master/test/com/google/javascript/jscomp/IntegrationTest.java#L3825#2020-01-2121:06thhellerseems like this is the actual config https://github.com/google/closure-compiler/blob/892c9054d53fab1093dabd7ef08472d9fcc9a947/src/com/google/javascript/jscomp/DefaultPassConfig.java#L2349#2020-01-2121:06thhellerand that would suggest that :anon-fn-naming-policy :mapped or :unmapped should prevent the renaming?#2020-01-2121:06thhellerI'd expect it to keep the original name if it exists?#2020-01-2121:13darwinI think that anon-fn-naming policy would preserve the names, but some other previous pass removes them, so it sees no names and generates its own#2020-01-2121:19darwinbut maybe I’m wrong, I have to test it#2020-01-2121:22darwinbtw. https://gist.github.com/darwin/c75123726c56e965623eba07aa660e1b did what I wanted, but you might be right that that disables a lot of other stuff I would rather don’t touch#2020-01-2121:23thhellerdid you try :optimizations :whitespace?#2020-01-2121:23thheller:simple is kind of required but if you don't care about loading extra deps in dev it should be fine#2020-01-2121:26darwinI tried :js-options :optimizations :none and that did nothing#2020-01-2121:27thhellerwhat is it supposed to do? :none is not a thing in the closure compiler world#2020-01-2121:27thhellerits a CLJS only setting to literally not invoke the closure compiler at all#2020-01-2121:27thhellerso it'll end up using whatever defaults the closure compiler has#2020-01-2121:28thhellerno clue what those are but its not a reliable setting to use#2020-01-2121:30darwinah, I see#2020-01-2121:40darwinI’m a bit puzzled, now I’m trying to modify raw sources in node_modules, just to test different scenarios and it looks like my changes are not being picked up#2020-01-2121:41darwinmaybe it is time to go to bed 🙂#2020-01-2121:43darwinoptimizations whitespace are not allowed#2020-01-2121:44thhelleroh hehe right#2020-01-2121:45thhellerI disabled it because :simlpe is required for things like react#2020-01-2121:45thhellerotherwise it'll load both the dev and production variants#2020-01-2121:46darwincould you confirm that shadow feeds closure with raw files from node_modules? or where is the source?#2020-01-2121:46darwinit looks like my changes in node_modules have no effect, maybe I’m touching wrong files, but that is unlikely, I don’t see anything similar around#2020-01-2121:47thhellerit wraps the sources#2020-01-2121:47thhellerwhich file did you touch?#2020-01-2121:47thhellerquick look suggests it only includes the web.cjs.js file#2020-01-2121:47darwinexamples/node_modules/react-three-fiber/web.js and examples/node_modules/react-three-fiber/web.cjs.js#2020-01-2121:48darwinthe generated output from shadow looks like it took web.js#2020-01-2121:48darwinbecause web.cljs.js has some transformations which are not present in shadow’s output#2020-01-2121:49thhelleronly if you configured it to use the module entry then it'd use web.js#2020-01-2121:49thhellerotherwise it'll default to web.cjs.js#2020-01-2121:49thheller
"main": "web.cjs.js",
  "module": "web.js"
#2020-01-2121:49thhellerby default it uses main#2020-01-2121:49thhellerunless you directly include react-three-fiber/web (or any lib)#2020-01-2121:50darwinah, my bad, there are two places with similar code, I was dancing at the wrong location#2020-01-2121:51darwinnow it makes sense, let me do another round of tests to confirm if :anon-fn-naming-policy respects original names#2020-01-2121:55darwinok, confirmed, case closed :anon-fn-naming-policy :unmapped assings names to anon functions only if there is no previous name#2020-01-2121:56darwinso original names are kept and some new might get generated based on original sources which doesn’t hurt#2020-01-2121:56darwinthanks a lot for the help#2020-01-2212:09sundbpHi. Is there a typo on line 382 in shadow/cljs/npm/cli.cljs? Looks like the map isn't applied to clojure-args as I expect is the intention? @thheller#2020-01-2212:10thhellerits a transducer so it is used as intended?#2020-01-2212:10sundbpI've switched to use borkdude's deps.exe on Windows (aliased to also be named clojure), and getting an error where my aliases ends up treated as a file somehow#2020-01-2212:11sundbpAre you inserting a transducer into the prev vector?#2020-01-2212:11thhellerI assume you don't know what a transducer does? 😛#2020-01-2212:12thheller(into ["-command" "clojure"] (map powershell-escape) clojure-args)#2020-01-2212:12sundbpI am vaguely familiar, but not seen it applied the way it is in this expr#2020-01-2212:12thheller(into ["-command" "clojure"] (map powershell-escape clojure-args))#2020-01-2212:12thhellerthese prduce the same result#2020-01-2212:13sundbpI guess I'm missing how the transducer is applied to the clojure-args the way it is written#2020-01-2212:13thhellerif you use deps.exe that is no longer a powershell command I would presume#2020-01-2212:13sundbpIt is not. A normal exe file#2020-01-2212:13thhellerso I wouldn't be surprised if it doesn't work#2020-01-2212:14thhellerjust run things directly in that case#2020-01-2212:14thhellerclojure -m shadow.cljs.devtools.cli watch app is identical to shadow-cljs watch app#2020-01-2212:14sundbpIt takes the same args as the powershell thing. But seems the args get passed mangled for some reason#2020-01-2212:14thhelleryes .. they are escaped for powershell#2020-01-2212:15thhellerbetter yet run clojure -m shadow.cljs.devtools.cli server once#2020-01-2212:15thhellerand then use shadow-cljs as normal#2020-01-2212:16thhellerI don't know anything about deps.exe and don't have time to look into that right now#2020-01-2212:16thhelleryou can open a ticket and I'll look at it when I get a chance#2020-01-2212:16sundbpIt is a clojure implemented replacement for the bash (and powershell) scripts. Compiled via graalvm.#2020-01-2212:17sundbp(that I've added proxy support to and hence have an easier time getting to work in an enterprise Crap network setup)#2020-01-2212:17sundbpI'll try the direct version for now. Thanks#2020-01-2212:18thhellerrunning a random .exe is easier in an enterprise setup? seems like that would be the first thing to be prohibited 😛#2020-01-2212:22sundbpWell, compared to powershell modules to pass proxy info to the jvm, weirdly yes :)#2020-01-2212:23sundbphttps://github.com/borkdude/deps.clj#2020-01-2212:24thhelleras I said .. no time.#2020-01-2212:31sundbpDidn't mean to imply I want you to do anything :)#2020-01-2220:10Eric IhliIs there a way I can create a .js file in my project and have the build process send that file to the output-dir so another tool can pull it in with js/require? It looks like https://clojurescript.org/reference/dependencies#bundling-javascript-code would be an alternative. If I could do the following, then I wouldn't have to js/require, I could just (:require [my-lib])?
(cljs.build.api/build "src"
  {:output-to "out/main.js"
   :externs ["yayquery-externs.js"]
   :foreign-libs [{:file "yayquery.js"
                   :provides ["yq"]}]
   :optimizations :advanced})
But shadow doesn't work like that? https://shadow-cljs.github.io/docs/UsersGuide.html#publish-deps-cljs
#2020-01-2220:13Eric IhliAssuming I can't convert the file to cljs and do things proper.#2020-01-2220:23thhellerwhat exactly are you trying to do though? I mean why must shadow-cljs be involved in copying a file?#2020-01-2220:24thheller:foreign-libs is not supported by shadow-cljs and also doesn't do what you asked for#2020-01-2220:29Eric IhliNot that it must be. I'm just copying it over by hand now every time I re-generate it and it's been annoying enough that I'm looking for an alternative. Could be a separate watcher that I run somewhere. But that lead me to being curious if there was something possible with what I'm already using.#2020-01-2220:30thhellerhmm you generate it? why not generate it directly into output-dir?#2020-01-2220:31thhelleralso what kind of file is it? why must it be loaded via require and not CLJS directly?#2020-01-2220:34Eric IhliThis brings up another question I've been having but is probably more related to the react native workflow than shadow-cljs. Should I ever need to rm the output dir? Like, the docs on publishing for Android say to do a gradlew clean before a gradlew buildRelease. And the react-native cli has a react-native run-android --reset-cache . Is it ever necessary to rm -r ouput-dir/ ? That's kind of the reason I don't generate it straight to the output dir. I clean that directory occasionally and copy the file back over rather than re-generate it into the output dir.#2020-01-2220:35thhellerno clue. I don't do react-native development.#2020-01-2220:36thhellerany reasonable "cache" should be able to tell if a file changed or not#2020-01-2301:22tbrookeI have a project that uses Winston.js colors.js and moment-mini they all work fine with npm/yarn but under Shadow they all have: required JS dependency "async/series" is not available, it was required by "node_modules/winston/dist/winston/transports/file.js". and the recomendation to run: npm install async/serie When I try to run install it errors out and can’t find the repositories /usr/local/bin/git ls-remote -h -t @github.com/async/series.git it just seems to me that since this is occurring in 3 apparently unrelated instances - except for all using async/series and that it is fine in npm and only shows up in shadow I was thinking it must be trying to do something shadow doesn’t support#2020-01-2307:35HukkaIsn't Winston.js just trying to load the series script from the async package, so you should npm install async itself?#2020-01-2308:34thheller@tbrooke I don't know where you are getting that git command from. that is not how npm works. npm install winston and (require '["winston" :as w]) works absolutely fine for me#2020-01-2308:35thhellerthe async/series message is a bit wrong. it is the async package which should have been installed when installing winston since it is once of its dependencies#2020-01-2318:36lilactownwill js/foo.bar_baz get munged with optimizations?#2020-01-2318:45thhellerdepends. usually no.#2020-01-2318:46lilactownI don’t get a warning when I turn on externs inference, but it seems to break in release#2020-01-2318:47thhellerthen you might be running into https://github.com/thheller/shadow-cljs/issues/632#2020-01-2318:47thhellerie. you have a CLJs namespace starting with foo#2020-01-2318:48lilactownyes, that’s correct#2020-01-2318:48thhellerthen externs inference backs of and thinks you are in safe land#2020-01-2319:02lilactownwhat’s the best way to remediate it? other than renaming the global foo#2020-01-2319:03thhellerdepends. why is it a problem?#2020-01-2319:04thhellerthe logic why externs inference backs off is that it assumes you are working on JS code that is safe to rename#2020-01-2319:04thhellergiven that it could be js/cljs.core.assoc or js/goog.string.startsWith#2020-01-2319:04lilactownI have some external JS that sets foo.bar_baz and I need to get foo.bar_baz in some CLJS code#2020-01-2319:05thhellerthat seems like a problem on its own given that it clashes with the CLJS namespace structure?#2020-01-2319:10lilactownyeah, not ideal. code was written before my time#2020-01-2319:10lilactownI guess I’ll do gobj/get for now until I can refactor this#2020-01-2320:06darwinshadow-cljs just blew my mind, I switched my new project to release compilation and expected an evening full of pain and it worked out-of-the-box on first try!!! note that the project uses some non-trivial npm deps and also lazy loading of modules @thheller kudos!#2020-01-2320:07darwinhttps://github.com/binaryage/cljs-react-three-fiber/tree/master/examples#release-workflow#2020-01-2413:18dpsuttonjust saw your shadow-cljsjs package. You are insanely awesome @thheller#2020-01-2414:14papachanwow didnt knew about this: (shadow/nrepl-select :app) selecting app directly from repl#2020-01-2414:21kszaboyeah, it’s really powerful that you have the full API as fn calls at runtime#2020-01-2416:00Filipe Silva@thheller was attempting to update the codebase I had again#2020-01-2416:01Filipe SilvaI had a case with multi-modules there a lazy module failed to load unless I set :output-wrapper false when updating shadow-cljs from 2.8.67 to 2.8.68 (this release included a commit saying "make `:output-wrapper` for multi-module builds as well")#2020-01-2416:02Filipe Silvatracing the error I saw that shadow wrapper for a npm dependency would throw when using defineProperty on export#2020-01-2416:02Filipe Silvathe debugger shows that the properties were already there#2020-01-2416:02Filipe Silvalemme try to get a screenshot of the debugger...#2020-01-2416:05Filipe Silva#2020-01-2416:06Filipe Silvathe npm package in question is called emoji-mart#2020-01-2416:07Filipe Silvais this worth opening an issue for or is it known to happen?#2020-01-2416:09Filipe Silvain case it's relevant, we import it thus:
(:require
   [reagent.core :as r]
   ["emoji-mart/data/all.json" :as emoji-data]
   ["emoji-mart" :as emoji-mart])
#2020-01-2417:17thheller:output-wrapper causing problems is known. dunno about the exports thing, never seen that before#2020-01-2419:03Filipe Silvais it known to cause problems if it's true or false? or both 😄#2020-01-2419:06thhellerit is causing problems in some cases since making the default true ... but it is also known to fix other problems since making the default true. Can't win with this JS mess 😛#2020-01-2420:38Filipe SilvaI'll add these details in https://github.com/thheller/shadow-cljs/issues/611, it's the closes issue I could find#2020-01-2420:38Filipe Silvathank you#2020-01-2417:19lilactownthere was a blog post a few months ago about i18n I’m looking for. what I’m really looking for is an example of storing global state inside of the analyzer#2020-01-2417:23thhellerlike that https://github.com/thheller/cljs-i18n-api/blob/master/src/cljs/i18n.clj#L56 ?#2020-01-2417:29lilactownyes! 👏#2020-01-2417:50thhellernote that you can only write safely to the namespace that is currently getting compiled#2020-01-2417:50thhelleryou must never reach into other namespaces or the entire things will fail when caching is involved#2020-01-2417:52lilactownwhat about reading?#2020-01-2417:54thhellerif you require them properly that is fine#2020-01-2418:17thhellerso whats a good name for something that sits inbetween the frontend (ui) and backend (server) and handles their interaction?#2020-01-2418:19thhellerin my framework thing all non-ui code runs in a webworker but that should be optional. so calling everything worker seems weird 😛#2020-01-2418:19thhellernaming stuff is hard. I keep renaming stuff 😛#2020-01-2418:37lilactownmiddle-end!#2020-01-2418:38lilactowncontroller? feature code? application logic?#2020-01-2418:41dpsuttonComposer#2020-01-2419:42orestisMiddle something #2020-01-2419:43orestisInbetweener#2020-01-2419:43orestisMembrane#2020-01-2419:43orestis(Sorry I’ll shut up now)#2020-01-2421:32KamuelaShould this happen?
➜  new-app npx shadow-cljs node-repl
npx: installed 90 in 2.668s
shadow-cljs - config: /Users/kamuela/Code/new-app/shadow-cljs.edn  cli version: 2.8.83  node: v12.14.1
shadow-cljs - connected to server
cljs.user=> no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
SHADOW import error /Users/kamuela/Code/new-app/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
    throw e;
    ^

Error: Cannot find module 'ws'
Require stack:
- /Users/kamuela/Code/new-app/[stdin]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /Users/kamuela/Code/new-app/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
    at global.SHADOW_IMPORT ([stdin]:63:44)
    at [stdin]:2258:1
    at [stdin]:2266:3
    at Script.runInThisContext (vm.js:116:20)
    at Object.runInThisContext (vm.js:306:38) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/kamuela/Code/new-app/[stdin]' ]
}
#2020-01-2421:38dpsuttonnpm i shadow-cljs#2020-01-2421:38dpsutton(i think)#2020-01-2421:43KamuelaInteresting. Yeah that seemed to do the trick#2020-01-2502:43jmckitrickI generated a luminus project with shadow support, and I’m trying to start CIDER to connect to both CLJ and CLJS. I got this error:#2020-01-2502:43jmckitrick1. Unhandled clojure.lang.ExceptionInfo missing instance {} runtime.clj: 11 shadow.cljs.devtools.server.runtime/get-instance! runtime.clj: 8 shadow.cljs.devtools.server.runtime/get-instance! api.clj: 125 shadow.cljs.devtools.api/worker-running?#2020-01-2502:44jmckitrickIt’s been a while, but I’ve had CIDER running with shadow successfully, so I’m sure it’s just a step I’ve missed.#2020-01-2504:03dpsuttoncan you tell me the template startup command you used @jmckitrick? I'll give it a shot and see what happens for me#2020-01-2504:19dpsutton@jmckitrick the reason is that that's not a valid shadow-cljs project. They put the shadow-cljs.edn map inside project.clj and then use a plugin to re-extract it. That seems like just a weird thing to do#2020-01-2510:15thhellerthats what I said ... they insisted on the one-config-file-approach 😞#2020-01-2504:19dpsutton(not you, just the template being like this)#2020-01-2504:21dpsuttonjust pull the :shadow-cljs map out of project.clj and into a proper shadow-cljs.edn file and rip out that plugin. The downsides are that you'll have two config files. The upside is that all workflows and documentation will again apply to you. Seems like a steep price to pay to have a single file.
#2020-01-2504:26dpsuttonalthough it seems like this will side effect and write package.json and shadow-cljs.edn if you run the plugin once and then everything should work from there. just sounds like a bunch of headache for no real net gain#2020-01-2504:43jmckitrickAh, ok. Let’s try it….#2020-01-2504:48jmckitrick@dpsutton Am I better off starting clj and cljs, and connecting from CIDER, or starting both from within CIDER itself?#2020-01-2504:49jmckitrickHmm. Still having the same issue. Well, I’m going to call it a night and pick up tomorrow afternoon.#2020-01-2505:23dpsuttonuntil there's a shadow-cljs.edn file there's no hope of this working in CIDER. run lein shadow compile app and it should make a package.json file and a shadow-cljs.edn file. it copies all the deps over it seems instead of just the ones you need so probably prune that down. at that point excise all that junk and just embrace the two systems#2020-01-2505:25dpsutton#2020-01-2505:26dpsuttoni don't think it matters about clj and cljs separately. they ultimately end up doing the same thing. the important thing is that a valid shadow-cljs.edn file exists and you've run npm install. let the plugin do that once and then you should be good to go#2020-01-2510:18thheller@jmckitrick you need to start the shadow-cljs instance if you run it embedded in a regular CLJ project/REPL. see https://shadow-cljs.github.io/docs/UsersGuide.html#embedded. not sure about the cider parts but the "missing instance" is caused when trying to call shadow-cljs API method without a running server instance in that JVM, which you need to start in embedded mode.#2020-01-2513:36Philipp SiegmantelHello, I have a problem with the karma target. Everything works fine in the repl, but when I run karma, I get the following exception
TypeError: s.replace is not a function
      at Object.clojure$string$replace_all [as replace_all] (karma-test.js:49567:10)
      at Object.clojure$string$replace [as replace] (karma-test.js:49626:23)
      at Object.shadow$test$karma$indent [as indent] (karma-test.js:82522:23)
      at shadow$test$karma$format_log (karma-test.js:82613:214)
      at karma-test.js:29716:89
      at karma-test.js:29717:3
      at Object.sval (karma-test.js:23585:110)
      at Object.cljs$core$ISeqable$_seq$arity$1 (karma-test.js:23736:10)
      at Object.cljs$core$seq [as seq] (karma-test.js:16711:13)
      at karma-test.js:29690:36
The code I added is the following.
(defn summarize-results' [spec-check]
  (map (fn [x] (pprint/write (stest/abbrev-result x) :stream nil)) spec-check))

(defn check' [spec-check]
  (is (nil? (-> spec-check first :failure)) (summarize-results' spec-check)))
Does anybody have a solution? I already tried to add a "-test" postfix to the namespace the code is in.
#2020-01-2513:50thheller@philipp.siegmantel you are passing nil to something that expects a string#2020-01-2513:52thhellercan't tell what your functions are supposed to be doing or where you added them#2020-01-2513:53thhelleroh no wait you are not passing nil, you are passing something that is not a string when a string is expected#2020-01-2513:53thhellerso juding from the code something espects message to be a string but isn't#2020-01-2513:57Philipp Siegmantel@thheller With message you mean the second argument to is? That makes sense. I copied the code from somewhere but summarize-results' returns a seq not a string. Thank you for your help.#2020-01-2515:39thhellerI didn't even know is takes a second arg at all 😛#2020-01-2515:39jmckitrickWould it make sense to create the app from luminus without shadow then add it manually?#2020-01-2515:40thhellernot really?#2020-01-2515:41thhellerI mean sure it probably helps you understand the setup better and you don't have lein-shadow (which I don't recommend anyways)#2020-01-2515:41thhellerbut you can just use the generated code run it once so it creates the shadow-cljs.edn file and then remove lein-shadow entirely#2020-01-2516:25jmckitrickThis is what I get for not taking copious notes last time I worked on my project. I’m going to start from scratch shortly, but still using a luminus template. I’ll work my way through all the docs and hopefully get something working for my new project. #2020-01-2516:30jmckitrickSo you are saying move the shadow part of the project file into the standalone shadow edn file, right?#2020-01-2517:08dpsuttonlook at my output from my shell above#2020-01-2517:09dpsuttonthere is no shadow-cljs.edn file nor package.json file. Then i run lein shadow compile app and the plugin generates those files from the project.clj file. At this point you have a normal shadow-cljs.edn file. At this point, remove that plugin and delete the shadow-cljs entry in the project.clj file and pretend like that stuff never happened#2020-01-2517:14jmckitrickOk, got it.#2020-01-2517:16dpsuttonCIDER just starts up shadow normally and now will print out the startup commands so you can seem them. super straight forward and it should work on any standard shadow project. if you run into any issues open an issue on CIDER's github and i'll get it patched up for you#2020-01-2517:20jmckitrickOk, I’m getting there. When running CIDER and jack-in clj and cljs, I’m still seeing the ‘missing instance’ where @thheller says I need to be running shadow server. Does that sound right?#2020-01-2517:27thheller@jmckitrick it depends if you want to run shadow-cljs in embedded mode or not. if the instance is missing then you are likely connected to the luminus CLJ server. so you can either embed shadow-cljs into that or run it separate and connect to that instead.#2020-01-2517:30jmckitrickWhich one is best for getting full CIDER functionality in CLJ and CLJS?#2020-01-2517:31jmckitrickMaybe @dpsutton would have insight on that#2020-01-2517:32KamuelaIs the beginner guide from the website still up to date? It's from the middle of 2017#2020-01-2517:34thhellerwhich guide?#2020-01-2517:35Kamuelahttps://medium.com/@jiyinyiyong/a-beginner-guide-to-compile-clojurescript-with-shadow-cljs-26369190b786z#2020-01-2517:35KamuelaIt's linked on http://shadow-cljs.org as Beginner Guide#2020-01-2517:36thhelleryes thats still current#2020-01-2517:33dpsuttoni'm having a different experience. i ran the plugin so i had a shadow-cljs.edn file. I deleted the shadow-cljs key from project.clj. I then ran cider-jack-in-cljs from the shadow-cljs.edn file and the repl starts up.#2020-01-2517:33dpsutton
;;  Startup: /home/dan/projects/node/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0 server
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
#2020-01-2517:33dpsuttonthis is displayed in the repl buffer. its just running npx shadow-cljs and then shadow/watch :app, nrepl-select app#2020-01-2517:33jmckitrickok let me try that command, rather than clj and cljs#2020-01-2517:34jmckitrickI assume you didn’t start anything else, in other terminals?#2020-01-2517:34dpsuttoncorrect. everything through just the cljs command#2020-01-2517:35dpsuttondo them separately. you want to use lein for the backend and shadow-cljs for the frontend. it seems like jack in clj&cljs will use the same build tool for both#2020-01-2517:35jmckitrickBut I can still get CIDER to connect to both? I used to do that with the old figwheel.#2020-01-2517:38dpsutton#2020-01-2517:36dpsuttonyes. run cider-jack-in-clj and then separately cider-jack-in-cljs#2020-01-2517:42jmckitrickSo… cider-jack-in-cljs seems to work… I selected shadow, then the build, and it’s offering to open a page in the browser that shows active http servers.#2020-01-2517:42jmckitrickNow I’m going to try cider-jack-in-clj#2020-01-2517:43jmckitrickIt’s asking if I want to open a sibling session… I’m saying ‘yes’#2020-01-2517:43dpsuttonyes#2020-01-2517:43dpsuttonhttps://github.com/clojure-emacs/cider/issues/2786#2020-01-2517:44jmckitrickIt’s not letting me do both. Trying to connect to CLJ seems to silently fail.#2020-01-2517:45dpsuttonlets go to #cider#2020-01-2517:45jmckitrickok#2020-01-2517:50KamuelaThe Beginner Guide starts with > Say you have a project:
├── README.md
├── assets
│   └── index.html
├── package.json
├── shadow-cljs.edn
├── src
│   └── app
│       ├── lib.cljs
│       └── main.cljs
└── yarn.lock
And doesn't really explain how you would have gotten there in the first place, do you generally start a new shadow-based CLJS project with an npm-init and install, then include shadow-cljs.edn and plugin shadow at that point?
#2020-01-2517:51thheller@kamuela if you want that structure then you can start by cloning this repo https://github.com/minimal-xyz/minimal-shadow-cljs-browser#2020-01-2517:52thhelleror you can follow the "official" quickstart and use npx create-cljs-project foobar https://github.com/thheller/shadow-cljs#quick-start#2020-01-2517:52KamuelaAh right, that quick start isn't mentioned at all on http://shadow-cljs.org#2020-01-2517:54KamuelaProbably from the perspective of knowing any possible way to work with a shadow project that beginner's guide is still relevant, but from a new perspective I'd definitely say the create-react-app route is the preferred onboarding#2020-01-2517:54thhellerwell the issue is that shadow-cljs is a build tool. I don't really want to write framework specific things like create-react-app#2020-01-2517:54thhellerif you want that then its typically best to go with a template for the given framework you want#2020-01-2517:55thhellereg re-frame or fulcro#2020-01-2517:55thhellerthere is also create-cljs-app#2020-01-2517:58KamuelaGuess it depends on the use case you have in your head. If the majority of people have pre-existing apps, and you're speaking to an experienced audience, then I can see the message being more like a look at how we can simplify your dev experience. But for someone like me who's brand new, it's nice to have a create-cljs-project path to follow#2020-01-2518:01KamuelaAll I'm really saying is that the quick-start is great and the main site pushing the beginner's guide threw me a bit#2020-01-2518:02dpsuttonhttps://github.com/dpsutton/asg-ignite-presentation#2020-01-2518:03dpsuttoni did a presentation on getting up and running with shadow recently#2020-01-2518:03dpsuttonthere are links to a presentation site with the slides, link to a repo that i walk you through building, and a link to the site running the example app#2020-01-2518:04KamuelaThat Netlify bit is awesome#2020-01-2518:06dpsuttonYeah netlify and shadow are a dream together#2020-01-2607:30porkostomusI used your presentation several times and it worked great, thanks! But I find myself making shadow-reagent apps so frequently that I decided to take advantage of the Github template feature: https://github.com/porkostomus/shadow-reagent#2020-01-2518:30knubieIs there some specific configuration I need to add to get shadow-cljs’ hot code reload to work with react-native?#2020-01-2518:31thhelleryes, you need something like this https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L67#2020-01-2518:35thhellerspecific configuration isn't required, just the code needs to be actually hot-reloadable. which is what that snippet provides.#2020-01-2519:02knubieAlso need to disable React Native’s “fast refresh” right?#2020-01-2519:02thhelleryes#2020-01-2519:09knubieGot it working, thanks!#2020-01-2607:35dpsuttonI'm trying to switch my work app from a figwheel app to shadow. I'm partway there but i seem to be blowing up, lots of warnings failed to load re_frame.events.js Error: No protocol method IMapEntry.-key defined for type object: [object Object]. The websocket connects and then immediately says that it cannot parse the message. It seems almost that cljs isn't well defined#2020-01-2607:39dpsuttonall of the warnings happen before the websocket notification.#2020-01-2607:41dpsuttonthings seem to be compiling. resources/public/js/main.js is output. our custom backend is serving resources/public and i have an asset path of "/js"#2020-01-2609:19thheller@dpsutton likely very old versions of some libraries that incompatible with the CLJS release#2020-01-2609:20thhellerIMapEntry.-key is a common error for libs that used to call key on vectors which used to work but no longer#2020-01-2613:48Kamuela
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [reagent "0.9.1"]

 :dev-http {8080 "public"}

 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn }}}}}
And I get
shadow-cljs - config: /Users/kamuela/Code/acme-app/shadow-cljs.edn  cli version: 2.8.83  node: v12.14.1
===== ERROR =================
reagent is not ISeqable
=============================
when I try to run shadow-cljs watch frontend Top of app.cljs:
(ns 
  :require [reagent.core :as r])
#2020-01-2613:48thhellerthats invalid#2020-01-2613:48thheller
(ns 
  (:require [reagent.core :as r]))
#2020-01-2613:50KamuelaHmm, I still seem to get the same error with
(ns 
  (:require [reagent.core :as r]))
#2020-01-2614:10thhellerkinda hard to say what you are doing. that ===== ERROR ======= bit comes from the shadow-cljs command line. so not even the compiler#2020-01-2614:10thhellerwhat are you doing exactly?#2020-01-2614:11thhelleroh wait .. now I see it#2020-01-2614:11thhelleryour config is also incorrect 😛#2020-01-2614:11thheller
:dependencies
 [[reagent "0.9.1"]]
#2020-01-2614:13thhellerguess that should be validated better#2020-01-2614:14thheller@kamuela ^#2020-01-2615:41KamuelaThat did fix it#2020-01-2621:01dpsuttonsolved my woes. seems schema was doing shenanigans with mapentry. I dont' entirely understand what was going on but bumping this solved my woes. https://github.com/plumatic/schema/pull/393#2020-01-2621:18dpsuttoni'm trying to use waypoints.js. Its an IIFE that sets window.Waypoint = Waypoint. There seems to be no export or anything so when i try to add a require to "waypoints" shadow is recommending me to npm install waypoints which i've already done. Is there a way to "import" this and then use it like js/Waypoint. ?#2020-01-2621:18thhelleris that supposed to be a npm package?#2020-01-2621:18dpsuttonyes#2020-01-2621:19thhellerhttps://www.npmjs.com/package/waypoints#2020-01-2621:19thhellerthis one?#2020-01-2621:19dpsuttonyes#2020-01-2621:21thhellerthat package doesn't follow any package rules whatsoever#2020-01-2621:21thhellerlooks like its a jquery plugin of the pre-webpack days#2020-01-2621:22dpsuttonyeah it seems pretty crazy. it's just establishes it is taking over the global Waypoint binding and that's it.#2020-01-2621:23thhelleryou can still require it. the package just doesn't contain the proper settings. so shadow-cljs can't tell which file to include#2020-01-2621:23thhellerthere is no default index.js or main entry in package.json#2020-01-2621:23thhellerso you probably need to find the file you need#2020-01-2621:23thheller(:require ["waypoints/foo/bar/something.js"]) and then access via js/Waypoint#2020-01-2621:24thhelleror use a library thats actually sane#2020-01-2621:24dpsutton
waypoints/lib/noframework.waypoints.min.js
#2020-01-2621:24dpsuttondo i need to set some compiler setting reassuring that js/Waypoint will exist? Can't image that's statically known#2020-01-2621:25thhellerhmm?#2020-01-2621:25thhellershadow-cljs doesn't know where js/Waypoint comes from and doesn't care either#2020-01-2621:25thhelleryou just can't reference the exports in the require since it doesn't have any#2020-01-2621:26dpsuttonok. didn't know if it tried to figure out anything about js/Waypoint#2020-01-2621:27dpsuttoni think i'm close to having our app moved from lein-figwheel. thanks so much for your tremendous work#2020-01-2621:40royalaid@thheller is there a way for me to tell shadow to look for a package.json in a subfolder?#2020-01-2621:41royalaidOr if I can tell shadow where the deps.edn file is?#2020-01-2621:42royalaidI am trying to work around behavior in Cursive which requires module definitions to basically be defined with the folder name and Cursive will overwrite the modules when re-importing#2020-01-2621:44royalaidand because of how https://aws-amplify.github.io/ organizes its AWS Lambda fn's I have to have a specific folder structure inside the lambdas#2020-01-2621:45royalaidSee this image for a high level view#2020-01-2621:46royalaidIdeally I could move the shadow-cljs.edn and deps.edn files up one level and that would "magically" fix a lot#2020-01-2621:46royalaidbut I get if shadow can't do that because it makes assumptions about where the package.json is#2020-01-2708:02OzHi, small question about lifecycle hooks, I have a re-frame app that defines this hook in it's core namespace:
(defn ^:dev/after-load mount-root []
        (re-frame/clear-subscription-cache!)
        (reagent/render [views/main-panel]
                        (.getElementById js/document "app")))
#2020-01-2708:04OzI've added a :workspaces build in shadow-cljs.edn to support https://github.com/nubank/workspaces/ Now, whenever I update the code, the workspaces app goes blank because of this hook. Is there a way to disable it for that build, but keep it for the regular build?#2020-01-2708:32thheller@ozfraier I would recommend splitting the namespaces so this can't happen. there is currently no way to disable hooks per build. you can move the hook config to the build though. so no meta but :devtools {:after-load } in the build config#2020-01-2708:34thheller@royalaid shadow-cljs never even opens the package.json in your project. I assume you want to configure where it looks for actual npm packages and that you can configure per build via :js-options {:js-package-dirs ["addBankAccount/node_modules" ...]}#2020-01-2708:36thhellerand structure wise I would probably keep all sources in <project>/src/main and then just have it output separate files to <project>/lambdas/foo/... so each lambda can have its own config and stuff in its own folder#2020-01-2708:36thhellerenforcing that structure for everything seems rather cumbersome to me 😛#2020-01-2708:37royalaidYeah, it's because the cli tools zip the dir and just upload it after running your build step so it has to be a specific shape 😕#2020-01-2708:38royalaidI am sure I could make some magic happen but I would rather put that work towards business logic#2020-01-2708:38thhelleryes ... but the cljs sources and build related things don't need to be in there?#2020-01-2708:38thhellerone deps.edn + shadow-cljs.edn per lamda seems incredibly clunky#2020-01-2708:39royalaidThe node_modules and build output have to but that's it#2020-01-2708:39royalaidAnd it is clunky haha#2020-01-2708:40royalaidWhen I mentioned a while back about wanting a better way to work with multiple shadow instances this is what I was asking about#2020-01-2708:40royalaidAnd the lambdas can have separate deps so I am unsure how best to split the config#2020-01-2708:40thhellerhmm did I recommend not having multiple shadow instances back then? since that seems entirely unnecessary here 😛#2020-01-2708:40thhelleryou can just always load all deps#2020-01-2708:41thhellerthe build output will only contain whatever you actually used#2020-01-2708:41thhellerso unless you need different versions of the same package it is not a problem to always load everything#2020-01-2708:41royalaidThis is a very good point#2020-01-2708:41royalaidThen I can pull everything up into a single config#2020-01-2708:42thhellerFWIW I do this in shadow-cljs. all build configs in one shadow-cljs.edn and all deps in project.clj. then all the various output going to https://github.com/thheller/shadow-cljs/tree/master/packages#2020-01-2708:43royalaidI will put in some time moving all this around, thanks for the help#2020-01-2708:44Oz@thheller Thanks! I tried doing it but for some reason it didn't work, probably because I missed a turn somewhere. Eventually my setup had the workspaces app use an "#app" div just like my real app So I renamed it, and with some fiddling it seems to work now ^^;#2020-01-2708:46thhellerideally you would have a or .core or whatever namespace that handles all the initialization logic#2020-01-2708:47thhellerand you already have [views/main-panel] so your UI is already separate#2020-01-2708:47thhellerso your workspaces build just shouldn't include the main ns#2020-01-2708:47thhellerand go directly to views#2020-01-2717:02justinbarclayIs there anyway to force shadow-cljs to bind to 0.0.0.0? I'm running shadow-cljs 2.8.83 and I'm my config is:
;; shadow-cljs configuration
{:source-paths
 ["src"
  "test"]
...
 :builds
 {:dev
  {:target :browser
   :output-dir "resources/dev/public/js/compiled"
   :asset-path "/js/compiled"
   :js-options {:variable-renaming :local}
   :modules {:app {:init-fn app.core/main}}
   :devtools {:http-root "resources/dev/public"
              :http-port 3449}}}}
#2020-01-2717:02thhellerbind what exactly? the 3449 server?#2020-01-2717:03justinbarclaythe shadow-cljs dev http server#2020-01-2717:03thhellerso 3449?#2020-01-2717:03thhelleror the main server at 9630?#2020-01-2717:03thheller(both should be binding to 0.0.0.0 by default)#2020-01-2717:04justinbarclayI'm not sure exactly, but I am not seeing it bound to 0.0.0.0
✦ ❯ netstat -tulpn | rg LISTEN                                                                                                                                                                                                                                                                                                                                                                                                              09:35:16(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      1313/puma 3.12.1 (t
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      -
tcp6       0      0 127.0.0.1:36585         :::*                    LISTEN      472/java
tcp6       0      0 127.0.0.1:35625         :::*                    LISTEN      472/java
tcp6       0      0 :::5355                 :::*                    LISTEN      -
tcp6       0      0 :::44179                :::*                    LISTEN      472/java
tcp6       0      0 ::1:3000                :::*                    LISTEN      1313/puma 3.12.1 (t
tcp6       0      0 :::3449                 :::*                    LISTEN      472/java
tcp6       0      0 :::3451                 :::*                    LISTEN      472/java
tcp6       0      0 :::9630                 :::*                    LISTEN      472/java
#2020-01-2717:05thhellertcp6 0 0 :::3449 :::* LISTEN 472/java?#2020-01-2717:13justinbarclayyeah, I thought that would have worked too. My work has a kind of complicated dev set-up and I am trying to get it to work on Windows + WSL. I have shadow-cljs running on WSL and I can connect to it when using localhost:3449 from Windows. But generally my work uses and has code set-up to handle our dev environment from the url *. (for info on https://readme.localtest.me/). And when I try to connect to shadow-cljs on Windows from it can't find it. I'm trying to debug this and see if it's because it's not listening specifically on 0.0.0.0. The thought that led me down that path is because a rails webserver listening on port 3000 and bound to 0.0.0.0 is able to be reached by on Windows.#2020-01-2717:16thhellerhmm yeah the 3000 seems to have an extra listen on 127.0.0.1#2020-01-2717:16thhellerI'm on windows/wsl too but never tried http://localtest.me#2020-01-2717:17thhellerseems to run fine when started in windows#2020-01-2718:28justinbarclayJust a heads up, I've done some more testing on this using just node and both WSL and WSL2. With node, binding to port :: and 0.0.0.0 behaves the same on WSL. IE They're both accessible from . However, in WSL2 (which is what I run) only 0.0.0.0 is accessible from . So it looks like WSL2 is not correctly handling :: . Thanks again, talking to someone else running WSL really helped narrow this down.#2020-01-2718:54thhellerhmm that makes sense. I'm not on wsl2#2020-01-2717:19thhellerhmm also works fine for me when started in wsl?#2020-01-2717:20thhellerI don't really know. the default is to listen on 0.0.0.0 and thats I all pass into it#2020-01-2717:20thhellerI'm not specifying anythings related to ipv4/6 or further#2020-01-2717:30justinbarclayOk it must be something on my end then. I just tried recreating the acme-app from https://github.com/thheller/shadow-cljs#quick-start, and again I could connect on localhost:8080 but not #2020-01-2717:30justinbarclayThanks for the help 🙂#2020-01-2720:27lilactownwhat’s the appropriate way to emit a compiler warning?#2020-01-2720:34thhellercljs.analyzer/warning#2020-01-2818:19Griffin SmithDoes anyone have any info on why the :karma target wouldn't actually include any tests?#2020-01-2818:20Griffin Smithmy ns-regexp is unset, and I have tests in the test directory (which is on source-paths) with -test$#2020-01-2818:22Griffin Smithha! writing the above question helped me figure it out#2020-01-2818:22Griffin Smithtest was in the source-paths in shadow-cljs.edn but not in deps.edn#2020-01-2818:27lilactown@root you should only use one or the other (shadow-cljs.end or deps.edn) for source paths and dependencies#2020-01-2818:27lilactownif you have :deps true in your shadow-cljs.edn then the source-paths and dependencies will be completely ignored in that file#2020-01-2818:28thhellerI think I should add a warning for this 😛#2020-01-2818:42JHi 🙂. I’m wonder if it’s possible to alias npm lib? For example, react-native-web to react-native#2020-01-2818:45thheller@jean.boudet11 it is. see https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm#2020-01-2818:51JAwesome! Thanks#2020-01-2823:04Drew VerleeAre there offical docs for shadow-cljs inspect or is this still the best place to get started? https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012?#2020-01-2823:20thhellerI'm still rewriting the entire UI for this but instruction wise nothing has changed#2020-01-2904:57genekimWow. shadow-cljs is amazing! I’m amazed at how wonderful the CLJS REPL is, and how fast the code loads in the browser! Thank you for all your wonderful work, @thheller!#2020-01-2905:00genekimI have a question that I’m hoping someone with more npm experience can easily answer… . I was using the linkify npm module via cljsjs in a figwheel project. I’m trying to convert it over to shadow-cljs and for the life of me, I can’t figure out how to get the syntax of the require correct. In the GitHub repo, the instructions are: https://github.com/SoapBox/linkifyjs/
var linkify = require('linkifyjs');
require('linkifyjs/plugins/hashtag')(linkify); // optional
var linkifyHtml = require('linkifyjs/html');
So, following the instructions, I tried this:
(:require    
    ["linkifyjs" :as l]
    ["linkifyjs/hmtl" :s lh])
But I keep getting errors like:
The required JS dependency "linkifyjs/hmtl" is not available, it was required by "trello_workflow/io.cljs".

Search in:
	/Users/genekim/src.local/trello-workflow/node_modules
You probably need to run:
  npm install linkifyjs/hmtl

See: 
How does one get access to the linkifyHtml function? Many thanks in advance! And keep up all the great work, @thheller!!!
#2020-01-2905:04genekimPS: In my desperation to get things running again, I even tried switching to the goog.string.linkify library in Google Closure, but wow, their SafeHtml classes are way too effective — I couldn’t replicate all my dangerous hacks I was using! 🙂#2020-01-2905:17sogaiu@genekim it's not a matter of "linkifyjs/hmtl" -> "linkifyjs/html", right?#2020-01-2905:31genekimOMG. You’re right @sogaiu — I had a typo! (I’ve been banging my head on this for 90m. I think I had it right in an earlier iteration…) Wait, more typos… oh, hey!
lh
=> #object[Function]
(lh "")
=> "<a href=\"\" class=\"linkified\" target=\"_blank\"></a>"
Thank you so much!!! 🎉 🎉 🎉 🎉
#2020-01-2905:32sogaiu👍#2020-01-2905:33genekimPPS: @thheller Your documentation is superb. For the first time in three years, I finally have some reasonable understanding of what a classpath is! (Your description of the source-paths was a huge lightbulb moment for me.)#2020-01-2905:38sogaiualso very much appreciate the docs 👍 on a side note, i found the following seancorfield article to be very informative wrt classpaths and some clojure-related tooling: https://corfield.org/blog/2018/04/18/all-the-paths/#2020-01-2914:14genekimThank you!! Superb article!!! Thx to you and @U04V70XH6 !!!#2020-01-2907:01Mathieu PasquetHey, sorry didn't realize there are other channels! I posted in #clojurescript but maybe this is more appropriate. Here's a link to what I posted : https://clojurians.slack.com/archives/C03S1L9DN/p1580280756468800#2020-01-2908:13JHi 🙂. I’m wonder if there is a trick to have code splitting with expo and react-native for the web target?#2020-01-2908:29thheller@jean.boudet11 I did some prep work for that and it works in theory but I have no idea how to make react-native actually lazy load the code. it requires messing with some rather weird react-native/metro internals that I don't know how to get working. https://facebook.github.io/react-native/docs/performance#ram-bundles--inline-requires#2020-01-2908:34JOk thanks! In fact, expo can use react-native-web to target the web but in shadow-cljs the build target react-native . I try to use a target web for react-native-web without expo but not work for the moment because of ui-kitten.#2020-01-2908:48thhelleryeah no clue about any of that sorry.#2020-01-2908:53JNo problems 🙂 ! Thanks for your time and shadow-cljs#2020-01-2908:30thhellerdunno if thats even possible with expo#2020-01-2908:48p-himikAbout replacing the <latest> placeholder with "LATEST". It seems that in Maven 3, both "RELEASE" and "LATEST" are missing: https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution The maven-resolver-api that's used by tools.deps still seems to support "RELEASE" though, but I cannot find any specific information about it.#2020-01-2908:49thhellerhmm yeah might be "RELEASE", not exactly sure. I saw something used in a project that wasn't an actual version and was surprised to learn it worked 😛#2020-01-2909:10p-himikWell, the code of tools.deps does have a special clause for handling "RELEASE" and "LATEST" specifically. But I can't find any proper mention of these aliases in the tools.deps documentation as well. So maybe it's just legacy stuff left in there because Maven 2 used to support it, no idea.#2020-01-2909:12thhelleryeah I'm always wary of "magic" version numbers but having to look up the latest version isn't great either#2020-01-2909:19p-himikHmm. Now I think that for a build tool, using such an alias is not really appropriate though. It will lead to situations where I develop with one shadow-cljs version, test with another one, deploy with the third one. And just to avoid going to the homepage of every single library I use, I find https://github.com/Olical/depot quite sufficient. :)#2020-01-2909:21thhellerthats for finding newer versions. you still need to know at least one version to use it 😛#2020-01-2909:21thhellerthats one thing npm install thing actually got right#2020-01-2909:22thhellerI may add something like shadow-cljs find-versions reagent or something like that some day#2020-01-2909:22thhellerbut given that I already have a billion other features planned that'll probably take a while 😛#2020-01-2909:24p-himikRight, that makes sense. Maybe even shadow-cljs add-dep reagent or something like that. :) But that asks for a different project. Or maybe a PR for depot.#2020-01-2909:25thhellerI thought about add-dep a lot but its just not gonna work. programmatically editing shadow-cljs.edn (or deps.edn) destroys all the formatting and comments the user may have done#2020-01-2909:26thhellerand I'm very sensitive to my config file structure. it changing "randomly" is not something I would accept#2020-01-2909:26thhellerthats one thing EDN isn't great for#2020-01-2909:27thhellermight be doable with something like rewrite-clj but that is also rather difficult to use 😛#2020-01-2909:27thhellerI have some ideas on how to do it but who has the time to do it ...#2020-01-2909:32p-himikOh, right. Well, it should be possible to always add the requested dependency right at the end of the :deps map. Although it may require hooking into the EDN parser or even writing your own to know exactly where that } is (never tried or even read about rewrite-clj, no idea here). I'd argue that it would be enough for the vast majority of cases. And for the rest, the user can always fix the file manually, especially when using any VCS. The heavy lifting of getting the version and putting the coordinates into the file has already been done. But even just printing out the coordinates is much better than nothing, that's for sure.#2020-01-2909:33thhelleryeah and printing should be easy#2020-01-2909:35thhellerat some point I also wanted to generate build configs and such from templates but never could figure it out. I don't like templates that have even on incorrectly indented output :P#2020-01-2910:46royalaidHey @thheller just wanted to pop in and say I have started to refactor based on your recommendations. It is SO MUCH BETTER 🙌 ty again for the advice#2020-01-2912:10royalaidFinal total for that commit: 34 files changed, 185 insertions(+), 1965 deletions(-)#2020-01-2912:54Hideletions are good 😁#2020-01-2913:20thhellerlooks good 🙂#2020-01-2913:34jeeqI seem to be having trouble requiring js files into shadow-cljs (react native project). Am I importing it in wrong? My Error:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/jeeq/Documents/rnproj/src/js/rnproj/home.js:6:5
--------------------------------------------------------------------------------
   3 | 
   4 | function Home(props) {
   5 |   return (
   6 |     <Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
-----------^--------------------------------------------------------------------
primary expression expected
--------------------------------------------------------------------------------
   7 |       <G clipPath="url(#prefix__clip0)">
   8 |         <Path
   9 |           d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
  10 |           fill="#546BFB"
--------------------------------------------------------------------------------
It seems to be able to find the js file but not parsing it correctly. I have a line in my :require, [“./home” :as svghome :refer (Home)] home.js is svg converted to “appropriate” format by tool linked by react-native-svg (https://svgr.now.sh/)
import React from "react";
import Svg, { G, Path, Defs, ClipPath } from "react-native-svg";

function Home(props) {
  return (
    <Svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
      <G clipPath="url(#prefix__clip0)">
        <Path
          d="M11 16h2c.6 0 1-.4 1-1V8h1c.3 0 .6-.1.8-.3.4-.4.3-1-.1-1.4l-7-6C8.3 0 7.8 0 7.4.3l-7 6c-.4.4-.5 1-.1 1.4.1.2.4.3.7.3h1v7c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-3h4v3c0 .6.4 1 1 1z"
          fill="#546BFB"
        />
      </G>
      <Defs>
        <ClipPath id="prefix__clip0">
          <Path fill="#fff" d="M0 0h16v16H0z" />
        </ClipPath>
      </Defs>
    </Svg>
  );
}

export default Home;
#2020-01-2913:40thhellerthat is not a javascript file. that is a JSX file and JSX is not supported by shadow-cljs#2020-01-2913:46dimaHello! I’m configuring running tests in browser. Is there a way to know what ns is going to be reloaded in start fn call in runner-ns? Currently start would run whole test suite, but i’d like to run tests from recompiled ns only. I tried using build-hooks for that which is getting build-state object. Idea was to store recompiled ns somewhere in global var and then use it in runner-ns start fn.#2020-01-2913:48thhellerthat isn't currently supported no but I could make that data accessible#2020-01-2913:50dimathat would be awesome, thanks!#2020-01-2913:51thhellerplease open an issue on github so I don't forget. have to finish up some other stuff first but its a relatively easy add so should be quick once I'm done with this.#2020-01-2913:51dimaok, will do#2020-01-2913:58dimahttps://github.com/thheller/shadow-cljs/issues/644#2020-01-2913:52jeeq@thheller doh! Of course. Guess my mind was elsewhere. Thank you. I’ll try using babel to convert as suggested in the doc#2020-01-2915:33robert-stuttafordhow might i go about diagnosing the root cause of this?
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/robert/.m2/repository/org/clojure/clojurescript/1.10.597/clojurescript-1.10.597.jar!/cljs/core.cljs:999:14
--------------------------------------------------------------------------------
 996 |     (if (js/isFinite o)
 997 |       (js-mod (Math/floor o) 2147483647)
 998 |       (case o
 999 |         ##Inf
--------------------^-----------------------------------------------------------
No reader function for tag Inf

--------------------------------------------------------------------------------
1000 |         2146435072
1001 |         ##-Inf
1002 |         -1048576
1003 |         2146959360))
--------------------------------------------------------------------------------
#2020-01-2915:35robert-stuttafordhttps://stackoverflow.com/questions/48039878/cljs-core-cljs-line-988-col-14-no-reader-function-for-tag-inf says i need org.clojure/tools.reader 1.1.0` at least, but i've checked, i have org.clojure/tools.reader 1.3.2 on the classpath (according to clj -Stree )#2020-01-2915:35thhellerhmm yes that is normally cause by having a CLJS version that doesn't match its required tools.reader version#2020-01-2915:36thhellerare you sure you checked your -Stree with all the aliases active you'd have active for cljs?#2020-01-2915:38robert-stuttafordyes, with all aliases on, org.clojure/clojurescript 1.10.597 and org.clojure/tools.reader 1.3.2#2020-01-2915:39robert-stuttafordbit of a head-scratcher#2020-01-2915:40thhellertry running clj (with the aliases) and then ( "clojure/tools/reader.clj") (require first)#2020-01-2915:41robert-stuttafording...#2020-01-2915:41robert-stuttafordlooks correct
user=> ( "clojure/tools/reader.clj")
#object[.URL 0x1c7fd41f "jar:file:/Users/robert/.m2/repository/org/clojure/tools.reader/1.3.2/tools.reader-1.3.2.jar!/clojure/tools/reader.clj"]
#2020-01-2915:42thhellerhmm indeed#2020-01-2915:52Drew VerleeI have version 2.8.83 of shadow cljs and my shadow-cljs.edn file looks like so: {:app {:devtools {:preloads [shadow.remote.runtime.cljs.browser When i run shadow-cljs watch app it tells me the shadow.remote.runtime.cljs.browser ns isn't available. I'm not sure what else to try.#2020-01-2915:53thhellerare you sure you have 2.8.83? it is a common mistake for people using deps.edn/project.clj to update the the npm install but not the clj side#2020-01-2915:59Drew Verleefacepalm yes. thats the problem#2020-01-2916:03thheller@robert-stuttaford don't even know if the shadow-cljs version is relevant here but which one do you have?#2020-01-2916:06robert-stuttafordwould a discrepancy between package.json and deps.edn mess with that? package.json "^2.8.83" deps.edn "2.8.48"#2020-01-2916:06thhellerno, that doesn't matter#2020-01-2916:07thhelleronly guess I have is that you have some AOT compiled version of the old tools.reader on the classpath#2020-01-2916:07thhellercheck ( "clojure/tools/reader__init.class")#2020-01-2916:08robert-stuttafordmf! #object[.URL 0x49872d67 "jar:file:/Users/robert/.m2/repository/com/datomic/datomic-pro/0.9.6021/datomic-pro-0.9.6021.jar!/clojure/tools/reader__init.class"]#2020-01-2916:09thhellerboom! dunno if its possible to figure out what version thats actually from but thats likely the problem#2020-01-2916:10robert-stuttafordi'll try to exclude tools.reader on the datomic dep#2020-01-2916:10thhellerthat does nothing. it is packaged in that .jar#2020-01-2916:11thheller(btw I do recommend keeping CLJS dependencies separate because of stuff like that)#2020-01-2916:11thhellerthere is no reason to have datomic on the classpath when compiling CLJS#2020-01-2916:12thhelleris it possible to remove deps when a profile is activated? something like :override-deps {datomic false} or so?#2020-01-2916:12robert-stuttafordtotally hear you. i'll move to a cljs alias#2020-01-2916:12Drew Verleenow its telling me the build failed because clojure.datafy is not available. maybe I have clojure version 1.10.1 maybe that needs to be bumped?#2020-01-2916:12robert-stuttafordgreat question, i'll check#2020-01-2916:13thhellerdatafy should be in 1.10?#2020-01-2916:14thheller@drewverlee your CLJS build failed? maybe you also have a bad CLJS version?#2020-01-2916:33Drew Verleewell specifically it says:
The required namespace "clojure.datafy" is not available, it was required by "shadow/remote/runtime/shared.cljc".
"clojure/datafy.clj" was found on the classpath. Should this be a .cljs file?
Sorry. Ill just come back to this later. Im probably missing something obvious
#2020-01-2916:34thhelleryes, that is a CLJS error. so you very likely have an old CLJS version#2020-01-2916:35thhellershould be 1.10.597#2020-01-2916:16thhellerI should write a blog post "yes, you might have a dependency conflict. no, that wouldn't happen if you put your CLJS dependencies in shadow-cljs.edn as recommended" 😛#2020-01-2916:33robert-stuttafordwe switched our biggest codebase to shadow this week. knocked 40% off our build time.#2020-01-2916:33dpsuttoni'm still dragging ours over. i ran into some timing issues. i'm assuming we have some races in navigation now but they are working correctly. get errors on nav at the moment#2020-01-2917:18thhellerbenchmarking JS is extremely tedious ... anyone know of tools to automate this better?#2020-01-2917:19thhellerI'm trying to setup a system that runs various shadow-cljs+CLJS combinations through a benchmark suite and collect the results#2020-01-2917:19thhellerso I can compare and track runtime perf and maybe compile perf over time#2020-01-2917:20thhellerI've made one rather big change and I want to test if thats actually worth performance wise#2020-01-2917:21thheller
;;; fn invoke
{:standardDeviation 0.023446214753117665, :bindings "[val (rand)]", :maximum 1, :total 11, :expr "(simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00055}
{:standardDeviation 0.027376540573065246, :bindings "[val (rand)]", :maximum 1, :total 15, :expr "(simple-fn-indirect simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00075}
{:standardDeviation 0.029143094653764887, :bindings "[val (rand)]", :maximum 1, :total 17, :expr "(simple-fn-indirect-hinted simple-fn val)", :median 0, :minimum 0, :count 20000, :average 0.00085}
#2020-01-2917:22thhellercan't even get precise timing on node it seems#2020-01-2918:07jeeqSorry to keep bothering about something that may or may not be supported in shadow-cljs right now but I’m now trying to get the example in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects) to work in my project (expo/react-native not sure if this is the issue). example jsx I’m trying to get working:
import React from "react";

function myComponent() {
  return <h1>JSX!</h1>;
}

export { myComponent };
when I conver this jsx to js with babel as in the docs I get error message about shadow.js.shim… not being provided:
Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault

construct
    [native code]:0
_construct
    construct.js:30:26
Wrapper
    wrapNativeSuper.js:26:23
SyntheticError
    index.bundle?platform=ios&dev=true&minify=false&hot=false:31652:111
handleException
    ExceptionsManager.js:111:31
handleError
    setUpErrorHandling.js:23:40
ErrorUtils.setGlobalHandler$argument_0
    ErrorRecovery.fx.js:8:32
tryCatch
    runtime.js:45:44
invoke
    runtime.js:271:30
tryCatch
    runtime.js:45:44
invoke
    runtime.js:135:28
Promise.resolve.then$argument_0
    runtime.js:145:19
tryCallOne
    core.js:37:14
setImmediate$argument_0
    core.js:123:25
_callTimer
    JSTimers.js:146:14
_callImmediatesPass
    JSTimers.js:194:17
callImmediates
    JSTimers.js:458:30
callImmediates
    [native code]:0
flushedQueue
    [native code]:0
invokeCallbackAndReturnFlushedQueue
    [native code]:0
Without the import line and if I just set to return a simple number (i.e. return 2;) I’m able to use the exported module. It just seems to be confused when trying to import any modules. Any pointers?
#2020-01-2918:09thhellerwhat did you use to convert the JSX? that is likely incorrect#2020-01-2918:12thhellerbut you are using react-native anyways so you should figure out a way to let react-native compile the js files and not shadow-cljs#2020-01-2918:12thhellerthen you can skip the entire babel stuff#2020-01-2918:13jeeqjust used the example on the doc but with option for transform inlined
babel --plugins @babel/plugin-transform-react-jsx src/js --out-dir src/gen
#2020-01-2918:13thhellerlikely that means not requiring the file via ns and instead do (def thing (js/require "../path/to/home.js"))#2020-01-2918:14thhellerand what does the generated output file look like? it looks like it rewrote ESM import to require which it should not do#2020-01-2918:16jeeq
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", { value: true });
exports.myComponent = myComponent;
var _react = _interopRequireDefault(require("react"));
function myComponent() {
  return 8;
}
This is the output from babel
#2020-01-2918:16thhelleryeah it shouldn't do all the other stuff, only jsx#2020-01-2918:17thhellerI did a setup several years ago. maybe that still works? https://github.com/shadow-cljs/examples/tree/master/babel#2020-01-2918:17jeeqI’ll try to figure out if I can turn that off and also will try requiring with js/require#2020-01-2918:18jeeqCool. I’ll take a look at that as well. Thank you so much!#2020-01-2919:59Wilson VelezHi, I have a re-frame app from which I wanted to extract some functionality, and I want to share that funcitonality with other components I have done in the past#2020-01-2920:00Wilson VelezI’ve read that I can use lein to generate a jar, so I can do that locally, and then how can I include that generated jar in my component using shadow?#2020-01-2920:14thheller@wvelezva I can tell how it works if your library is public/open source. otherwise you are probably better off using deps.edn and putting the files in a git repo or local folder#2020-01-2920:32Wilson Velez@thheller ok, so I think I better use deps.edn#2020-01-2920:39Wilson Velezbut in general what I should create? a normal cljs component? I have to generate the js? or something like a jar, npm?#2020-01-2920:44Wilson Velezor can use lein to manage my dependencies and install the component like a jar?#2020-01-2920:45thhelleryou don't have to compile anything. the easiest way to share components is to just put them in their own namespace#2020-01-2920:45thhellertake the file and put them somewhere "shared"#2020-01-2920:46thhellerand then either add the path to that into your :source-paths or use lein install and add the dependency#2020-01-2920:46thhellerI'd recommend just files#2020-01-2920:47thhellereg. you have /code/project-a/src and /code/the-library/src#2020-01-2920:47thhellerin project-a/shadow.cljs.edn you put :source-paths ["src", "../the-library/src"]#2020-01-2920:48Wilson Velezoh, I didn’t know that was possible#2020-01-2920:48Wilson VelezI will give it a try#2020-01-2920:49Wilson Velezthank you#2020-01-2920:49thhellerthings get a bit more complicated if you want to declare dependencies in the library, at which point you should likely go with deps.edn#2020-01-2920:52knubieIs there a recommended way of rendering images in react native? I’m using the method described in this example https://github.com/PEZ/rn-rf-shadow/blob/master/src/main/example/app.cljs#L16#2020-01-2920:56thhellerwhat else would there be?
#2020-01-2920:57knubieI dunno but the Metro Bundler is giving an error, so I thought there might be a different way#2020-01-2920:58thhellerI don't know but I doubt it. whats the error?#2020-01-2921:00knubieReferenceError: SHA-1 for file …/assets/logo.png (…/assets/logo.png) is not computed#2020-01-2921:00knubieI think it might be that the “image is outside of my project”#2020-01-2921:01thhellerno clue. the path used must be relative to the :output-dir used in the build config#2020-01-2921:02knubiethat was it#2020-01-2921:02knubiethe image was in a directory above the react native project path#2020-01-3000:16jmckitrickNot long ago, it was suggested when using a luminus template with shadow, to remove the key from the project file and not use lein-shadow, What’s the recommended process to build the CLJS part of the uberjar?#2020-01-3000:17dpsuttonshadow-cljs release app#2020-01-3000:18dpsuttonprobably in your project.clj is still the instructions for the uberjar step and it just calls exactly that (or whatever incantation causes the plugin to call exactly that)#2020-01-3000:23jmckitrickOh, ok. Then uberjar will wrap that up, and it’s deployable as-is?#2020-01-3000:24dpsuttonsorta. the uberjar used to call out to the plugin. but just make it call out to shadow tocompile or make a script that calls shadow-cljs release app && lein uberjar. Two steps you need to do: compile your js and build a jar. how you get there is straight forward. if lein can just shell out you can do that. otherwise, ensure the build is present and then uberjar as normal. check the jar that your stuff is there and then never worry about this again#2020-01-3012:59jmckitrickI’ll try that, thanks. Like you said, the manual steps aren’t the issue, it’s getting lein to do it at the same time. I’ll figure it out.#2020-01-3007:41Philipp SiegmantelHello. I want to write a part of my application in typescript, but js file imports don't seem to work for me. My source tree looks like this.
.
├── clj
├── cljs
│   ├── client
│   │   └── exercises
│   └── test
│       └── client
├── gen
│   └── client
└── ts
    └── client
I need to require something from gen/client in the client.exercises.two namespace. I tried every variant of "./file", "./file.js", "/client/file", "client/file" and so on I can think of. My shadow-cljs.edn's :source-paths is ["src/cljs" "src/clj" "src/gen"]. I'm probably making an obvious mistake, but can somebody point it out for me?
#2020-01-3008:42thheller@philipp.siegmantel if you are in client.exercises.two namespace you are in the /client/exercises/two.cljs file so ../file.js or /client/file.js should work. (extension is required. not optional)#2020-01-3011:07Philipp Siegmantel@thheller I still can't require the js file. The concrete error message I get is
The required JS dependency "../boxes.js" is not available, it was required by "client/exercises/two.cljs".
or
The required JS dependency "/client/boxes.js" is not available, it was required by "client/exercises/two.cljs".
There is definitely a file named boxes.js in the right location.
gen
└── client
    └── boxes.js
Is there anything else I could have gotten wrong?
#2020-01-3011:09Philipp SiegmantelAlso the documentation says that the .js extension is optional, maybe this should be updated. https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2020-01-3011:45andrewzhurov@thheller Is it a sane design to have a shadow-cljs project-A depend on the source files of another shadow-cljs project-B? I am facing the need to create a custom build of a ReactJS component, to pack it into a stand-alone project would add up to granularity, seemed like a good idea.. However, 'project B' has node dependencies and when
project-A/deps.edn

{:deps {project-B {:local/root <path-to-project-B>}}}
project-A$ yarn
=> Installed dependencies of Project-A

project-A$ shadow-cljs watch dev
=> The required JS dependency <a-dependency-of-Project-B> is not available
=> Searched in:/<path-to-projects>/project-A/node_modules
#2020-01-3012:29thheller@philipp.siegmantel only other thing I can think of is that the .js file fails parsing and the error is lost somewhere#2020-01-3012:31thhellermake sure its valid JS without stage0 features#2020-01-3012:32thheller@brownmoose3q in project-b you can add a deps.cljs in your source path that includes {:npm-deps {"the-npm-dep" "version"}}#2020-01-3014:11andrewzhurovWorks, thanks! Found it also had been discussed here: https://github.com/thheller/shadow-cljs/issues/403#2020-01-3012:33Philipp Siegmantel@thheller the js file is simply
function hello() {
  console.log("Hello World from TypeScript!");
}
Should I report a bug?
#2020-01-3012:34thhellerif you reproduce it in a sample project first#2020-01-3012:34thhellerpretty sure the file needs some exports too#2020-01-3012:35Philipp SiegmantelI already tried an export default line, makes no difference.#2020-01-3012:35Philipp SiegmantelI will hack around for a bit, thank you for your help.#2020-01-3012:40thhellerjust tested it and it is working fine#2020-01-3012:41thhelleryou did add the source path and restart after doing so right?#2020-01-3013:01Philipp SiegmantelI just put together a minimal example that fails for me. give me a moment to create a repo.#2020-01-3013:02Philipp Siegmantelhttps://github.com/philipp-siegmantel/potential-shadow-cljs-bug#2020-01-3013:03Philipp SiegmantelAnd yes, I restarted and upgraded shadow-cljs with no effect.#2020-01-3014:12thhellerok .. thats it .. I'm adding a big fat warning ...#2020-01-3014:13thheller@philipp.siegmantel if you use :lein true then :source-paths in shadow-cljs.edn has no effect whatsoever and you need to configure it in project.clj instead#2020-01-3014:37thhellerhttps://github.com/thheller/shadow-cljs/commit/182bcae82f4c232ef7488f0a6090cc07a63cc747#2020-01-3014:42Philipp SiegmantelThen it was simply my ignorance. Thank you for helping. Shadow-cljs is a great pice of software.#2020-01-3015:15jeeq@thheller I was going through your babel example (https://github.com/shadow-cljs/examples/tree/master/babel) just now and found that checked in generated js (gen/demo/bar.js) is able to be used by shadow-cljs correctly and I’m able to load the page. However once I “npm run build” to generate new bar.js on my computer it seems to generate different js and gives me error (similar to what I saw yesterday on my project). I didn’t change anything in the example app. My babel’d js:
import React from "react";

var MyComponent = function MyComponent(_ref) {
  var key = _ref.key;

  console.log('child props', key);
  return React.createElement(
    "li",
    { key: key },
    "Hello JSX!"
  );
};

var MyDefaultComponent = function MyDefaultComponent(_ref2) {
  var children = _ref2.children;
  return React.createElement(
    "div",
    null,
    React.createElement(
      "h1",
      null,
      "Hello JSX!"
    ),
    React.createElement(
      "ul",
      null,
      children
    )
  );
};

export { MyComponent };

export default MyDefaultComponent;
#2020-01-3015:16jeeqModule load error#2020-01-3015:17thheller.js files requiring npm components has quite a few edge cases that currently aren't covered well#2020-01-3015:18thhellerno time to work on that. it should work if you do import * as React from "react";#2020-01-3015:25jeeqAh hmmm. It works with that import statement. Thank you. I just thought it was interesting my generated javascript was different from one that you checked in with the example app: Object.defineProperty and _interopRequireDefaults were all missing.#2020-01-3015:27thhellerthat example is from almost 2 years ago ... stuff has changed since then#2020-01-3015:27thhellerin babel and the closure-compiler and shadow-cljs#2020-01-3015:27thhelleralso you may have missed this file https://github.com/shadow-cljs/examples/blob/master/babel/src/js/demo/.babelrc#2020-01-3015:28thhellerwhich configures babel, so it is kinda important#2020-01-3015:28thhellerbut ... I'm sure all of that has also changed#2020-01-3015:32jeeqTotally understandable 🙂! I’ll try to dig in to see if I can replicate your results with current versions. Thank you so much for your time and effort!#2020-01-3023:35jmckitrickI’m running shadow-cljs release app with version 2.8.69, in an app that works fine in dev mode with hot-reloading, but I’m getting this error:#2020-01-3023:35jmckitrickIllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError#2020-01-3107:29David PhamTry to compile into es6 by setting the argument in your shadow-CLJS.edn file#2020-01-3107:29David Pham(Maybe update to 2.83?)#2020-01-3109:11thheller@jmckitrick that is caused by you using project.clj or deps.edn and not having the correct closure-compiler version (ie. dependency conflict). you need to resolve this, you should have
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-01-3109:13thhellerI think its time I write this down somewhere ... getting tired of repeating it ... why does everyone insist on using lein/deps.edn?#2020-01-3110:00thheller(note that the version changes between shadow-cljs versions, so if you have one pinned you must make sure it matches) ... or just use shadow-cljs.edn ....#2020-01-3110:46David Phamdeps.edn allows local libraries or git libraries #2020-01-3110:56thhelleryeah I know#2020-01-3111:50Jakub Holý (HolyJak)Hi! In JS I can do const logo = require('../../media/logo.svg'); and then use logo as html (e.g. in React's dangerouslySetInnerHTML={{ __html: logo }). What to people do in Cljs / shadow? I guess it is not supported to require a non-cljs resource. Thank you!#2020-01-3112:19Jakub Holý (HolyJak)Answered here https://clojurians.slack.com/archives/C03S1L9DN/p1580473104024800?thread_ts=1580472004.023600&amp;cid=C03S1L9DN#2020-01-3112:24Jakub Holý (HolyJak)@U05224H0W I have been searching the Dev Guide for how to embed non-code resources but couldn't find anything. Is shadow.resource/inline not mentioned there or have failed to search well? Perhaps "Table 1. ES6 Import to CLJS Require " could be extended to point to a description of this as people use in JS import/require for non-code resources? Or add a section between 12.2 and 12.3 (12.25 :)) called "Embedding resources from files"?#2020-01-3112:45thhellerwhat you are looking for isn't about embedding#2020-01-3112:45thhellerthe require('../../media/logo.svg') pattern is something from webpack and not supported by shadow-cljs in any way#2020-01-3112:46thhelleryes, the inline stuff can be used to inline svg but that only works for svgs#2020-01-3113:02Jakub Holý (HolyJak)Wouldn't it work also for CSS? I.e. anything text-based? IF it was an image I guess I would also need to run it through base64 and thus write my own include macro anyway?#2020-01-3113:05thhelleryes and no. in the case of webpack it will collect all the required css files and then create one final css file with all of them combined#2020-01-3113:05thhellerthe source is rarely inlined into the build#2020-01-3113:05thhellerthe images in general it usually just returns the path and copies to actual file to the path it returned#2020-01-3113:06thhellerinlining actually only happens if you configure webpack to do so#2020-01-3113:14Jakub Holý (HolyJak)ok, thank you!#2020-01-3112:33jmckitrickI’m perfectly happy using a better method, as long as I can build an uberjar with the result. Is there a better way?#2020-01-3112:33jmckitrickI had removed the shadow code from the project.clj, but put it back for building the uberjar.#2020-01-3112:50thheller@jmckitrick shadow-cljs release app && lein uberjar would be my recommendation. I really don't see the point lein doing everything but some people prefer that.#2020-01-3112:52jmckitrickHmm, that’s what I was doing.#2020-01-3112:53jmckitrickLet me try again, and post the results here.#2020-01-3112:55jmckitrick
~/d/b/bank1 ❯❯❯ shadow-cljs release app                                                                                                                                ⏎ master ✱
shadow-cljs - config: /Users/jmckitrick/devel/bank/bank1/shadow-cljs.edn  cli version: 2.8.69  node: v13.7.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app
NPM version conflict for "react" in deps.cljs (will use A)
A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
NPM version conflict for "react-dom" in deps.cljs (will use A)
A: "16.8.6" from jar:file:/Users/jmckitrick/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
B: "16.9.0" from jar:file:/Users/jmckitrick/.m2/repository/reagent/reagent/0.9.0-rc3/reagent-0.9.0-rc3.jar!/deps.cljs
[:app] Compiling ...
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
#2020-01-3112:56thhelleras I said before. you are running through lein. so YOU must ensure that the shadow-cljs version in project.clj gets the matching closure-compiler version it expects#2020-01-3112:57thhellerfrom the looks of it you actually have a newer version of shadow-cljs in project.clj, not .69.#2020-01-3112:57jmckitrickOk, let me fix that.#2020-01-3112:57jmckitrickBut I wasn’t using lein there…#2020-01-3112:57jmckitrickI used it for setup#2020-01-3112:58thheller> shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app #2020-01-3112:58thhellerif :lein is configured in shadow-cljs.edn it will use lein to run things#2020-01-3112:59jmckitrickI see… lein true#2020-01-3112:59thhellerif you remove that it will run shadow-cljs directly without lein#2020-01-3113:00thhellerBUT then you must move your dependencies and source-paths into shadow-cljs.edn as well#2020-01-3113:00jmckitrickOk, I think that’s the next step. I thought it was solved when I just deleted the shadow keys from project.clj#2020-01-3113:01jmckitrickI will come back to this. As long as I know I can get an uberjar for prod deployment, I can revisit the topic later.#2020-01-3113:01jmckitrickThanks for you help, meanwhile!#2020-01-3113:02thhelleruberjar will just copy all the files in the paths you have configured#2020-01-3113:02jmckitrickThe build did get farther, but broke looking for the correct namespace. I assume that’s what you were referring to, with setting up shadow-cljs.edn correctly with dependencies and paths.#2020-01-3113:02thhellerso if you have shadow-cljs output the files into a dir you want packaged#2020-01-3113:02thhellerthen it'll just work#2020-01-3113:02thhelleryes, source-paths#2020-01-3113:53jmckitrickI think I’ll start over, and begin with reading the manually entirely 😉#2020-01-3118:38rbergerAre there any examples or articles on building :chrome-extension with shadow-cljs? I couldn't find any so far. Thanks!#2020-01-3120:12thheller@rberger this is all that exists in terms of docs https://github.com/thheller/shadow-cljs/issues/279#2020-01-3120:12thhellerthe fulcro-inspect extension uses it#2020-01-3120:15rbergerThanks, saw the issues but will check out the fulcro-inspect, that should help... Also want to thank you so much for shadow-cljs. It really makes Clojurescript work wonderfully! Really helped in allowing us to take advantage of things like AWS Amplify: https://dev.to/rberger/aws-amplify-and-clojurescript-re-frame-part-1-3d3f#2020-01-3120:15rbergerCouldn't have made that work without shadow-cljs#2020-02-0101:13mpostmahello, I am trying to deploy my shadow-cljs/reagent app to github pages, but i can't make it work. When I use shadow-cljs watch app everything works just fine, but when i run shadow-cljs release app and try to open index.html or push the code to my github page, I get this js error : Error: No matching clause: . At first I thought that the app.js generated by the release command was faulty, but it seems to work just fine when i run it with a http server (lite-server). In all case the code is loaded just fine. It's just really confusing. What am I missing?#2020-02-0101:19mpostmathis is the repo if it helps: https://github.com/MarinPostma/pws#2020-02-0107:56sichacvahHello! Are there some examples or articles of testing react-native project with shadow-cljs?#2020-02-0109:12thheller@postma.marin my guess would be that your routing fails but its hard to say. you can run shadow-cljs release app --pseudo-names or shadow-cljs release app --debug (to get source maps). should be easier to tell where it fails then#2020-02-0110:57robert-stuttafordcan :target :browser live in :build-defaults?#2020-02-0111:08robert-stuttafordseems not#2020-02-0111:25thhellerno 😛#2020-02-0111:59mpostma@thheller thanks! 🙂 it was indeed a routing problem!#2020-02-0113:09jmckitrickI made progress. I got the CLJS part built with shadow, and then built the uberjar. When I run the app and view the start page, it’s missing JS. The console says:#2020-02-0113:10jmckitrickThe resource from "" was blocked due to MIME type ("text/html") mismatch (X-Content-Type-Options: nosniff).#2020-02-0113:53thheller@jmckitrick that is your server. looks like it tries to serve some other content under that url that isn't the JS. just open it in your browser normally and see what it is#2020-02-0113:55jmckitrickI went back to the dev build, and am starting over. I’ll worry about the uberjar when I’m ready for deployment.#2020-02-0113:55jmckitrickI think I had too many moving parts at once.#2020-02-0119:34jmckitrickSo loading that file in the browser gives me a 404 page#2020-02-0119:35jmckitrickSo the uberjar isn’t finding the payload generated by shadow, I assume.#2020-02-0119:35jmckitrickProbably a simple setting in my project file… just gotta find it.#2020-02-0120:28Saikyunhey @thheller, when running a prepl-server and a socket-server, if I connect to the prepl-server I can't seem to start a repl in the socket-server#2020-02-0120:28Saikyunafter connecting to the socket-server I get this:
shadow.user=> (shadow/repl :app)
null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:536).
Assert failed: (symbol? read-ns)
#2020-02-0120:28Saikyunis this something that's known, or should I create a repro + issue?#2020-02-0120:31thhellerdon't really understand what you are doing?#2020-02-0120:32thhellerneither prepl nor socket-repl are used frequently so yeah there are most certainly issues#2020-02-0313:36Saikyunah, all right.#2020-02-0313:37Saikyunsorry for being unclear, what I was doing is starting a prepl-server by putting {:prepl {:app 5555}} in shadow-cljs. I can connect to the prepl-server and it works fine. however, if I have a prepl-server running, and then connect to the socket-server, then I get the error I posted (`null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:536).`)#2020-02-0314:41Saikyuneither way, if it's not used much, don't bother about it. 🙂#2020-02-0314:53thhellerI just need to reproduce it before I can look at it#2020-02-0314:53thhellerby socket-server I assume you mean you also configured :socket-repl {:port 1234}?#2020-02-0314:54thhellerI'm mostly lacking context for what you are doing .. there are too many things that you could be doing so I can't tell#2020-02-0408:15SaikyunI can just make a repro-repo and send it to you instead 🙂#2020-02-0122:32darwinI have an interesting problem here, I require react as an npm module. I have a macro which emits react/createElement. I cannot do that in my macro because compiler complains (I guess due to that “react” is not normal namespace, it is coming from npm, with normal namespaces this normally works). When I create some alias (def my-create-element react/createElement) and emit my-ns/my-create-element instead. All works, but release build suffers from generating dynamic arity dispatch. Even if I specify explicit fixed arity (defn my-create-element [x] (react/createElement x)) it does not get inlined in advanced mode (verified with --pseudo-names). Any ideas, how could I reference react/createElement in my macro directly? js/React.createElement does not work. “React” is not avail at runtime due to way how shadow isolates npm modules (?)#2020-02-0122:47darwinthis is closest how I could get to what I want: https://github.com/binaryage/cljs-react-three-fiber/commit/1d23a5050c540a19804182dfcb1545eb09356f92 that dirty set! emits: window.reactCreateElement=$APP.vl.createElement I need a way how to reference that $APP.vl (react npm import in my macro)#2020-02-0123:15darwinok, after some tinkering with various ideas, I found a proper workaround: https://github.com/binaryage/cljs-react-three-fiber/commit/3838dd6f3871660e67aabf9280dc7a6e1d484bfc#2020-02-0209:18thheller@darwin FWIW I rewrote the entire parse-invoke/emit logic in the last few days to address cases where the compiler falls backs to generic ifn arity dispatch and there was no way to tell it not to#2020-02-0209:20thhellerso in master (def ^function my-create-element react/createElement) is possible and the compiler will always emit a direct function call in instead of the usual my_create_element.ifn1 ? ...#2020-02-0209:20thhellerthat means it'll also skip binding the args in case they aren't all values#2020-02-0213:16darwin@thheller thanks for this suggestion, it looks that this will be my preffered way how to directly refer to npm symbols I want to rename on my side, but since the code is in a library, I’m looking for some general solution which would work with vanilla cljs compiler as well, does it support ^function as well?#2020-02-0216:09thhellerit does not. I'm testing out the changes I'm making first and will eventually make a proper patch#2020-02-0213:50jmckitrickI’m seeing an odd error when building in release mode:#2020-02-0213:50jmckitrick
[:app] Compiling ...
------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared --------------------------------------------------------------------------------
#2020-02-0213:50jmckitrickI have transit in my dependencies, so….#2020-02-0213:53jmckitrickI actually have luminus-transit. If I include [com.cognitect/transit-clj "0.8.319"] I get a warning that it was ignored, and still see the above error.#2020-02-0213:53jmckitrickBut I feel I’m making progress. This is why my app.js is missing. I think.#2020-02-0213:53jmckitrickThought I wouldn’t think a warning would result in no output at all.#2020-02-0213:55jmckitrickIt works fine in ‘watch’ mode, however.#2020-02-0216:07thheller@jmckitrick thats not an error. those are warnings. safe to ignore those.#2020-02-0216:30jmckitrickHmm. I thought so too. But no app.js is being generated #2020-02-0216:40dakraI try to make a minimal cljs only app but I always get The required namespace "carcalc.core" is not available. I think I must have some stupid mistake somewhere but can't find it.. Does anyone see what's wrong with this repo? https://github.com/dakra/carcalc#2020-02-0217:49dpsutton:source-path should be :souce-paths#2020-02-0218:54dakraha. Thanks. I thought it's just a typo somewhere. Thank you very much#2020-02-0315:50mkarpHey everyone! I’m trying to figure out how I can send forms to be evaluated in the ClojureScript REPL while I’m in a Clojure REPL. I know I can run (shadow/repl :app) and then type in cljs commands, but is it possible to evaluate a single cljs form through Shadow’s API without interacting with the cljs REPL? Thanks!#2020-02-0316:01thheller@me1676 what would that look like? there is no command for that currently but it wouldn't be hard to add one#2020-02-0316:02mkarp@thheller Something like (shadow/eval-cljs :my-build-id '(js/console.log "Hello world")) would be awesome#2020-02-0316:02mkarpDoes it make sense?#2020-02-0316:03thhellerdepends on what you want to use that for. lots of "context" to consider when evaling forms, eg. (shadow/eval-cljs :my-build-id '(foo/bar "Hello world"))#2020-02-0316:04thhellermight need to be able to resolve foo (if its an alias)#2020-02-0316:05thheller(shadow/eval-cljs :my-build-id '(foo ::bar)) would also turn ::bar into :user/bar (or whatever CLJ ns you are currently in)#2020-02-0316:06mkarpRight. What about passing a string input? (shadow/eval-cljs :my-build-id "(js/console.log \"Hello world\")")#2020-02-0316:07thhellerthat would still need to take at least one additional parameter for the ns that should be compiled in#2020-02-0316:08thhellerand the overall problem that there may be multiple runtimes you need to deal with#2020-02-0316:09thhellereg. you are building a browser app and have it open in chrome and firefox#2020-02-0316:09thhellerwhich one does the eval go to? 😛#2020-02-0316:09mkarp🙂#2020-02-0316:09thhellerI'm currently working on some REPL related things ...#2020-02-0316:09thhellerit is a lot more complicated than it looks on the surface 😛#2020-02-0316:11mkarpTotally. After looking at the code, I walk away with a defeat for now 🙂 You know, I’d like to “just simply call” some cljs code 🙂#2020-02-1003:34mauricio.szaboI don't know if you're still looking for a way to evaluate code, and I probably am using internal APIs that are not meant to be used, but I just implemented it on Chlorine. So if you want to take a look: https://github.com/mauricioszabo/repl-tooling/blob/master/resources/shadow_commands.clj#L1-L28#2020-02-1013:33mkarpOh wow, thanks! I’ll try it out#2020-02-0316:11thhellerwould help to know what you want to use this for in the first place#2020-02-0316:11thhellerlike how smart does this need to be. do you need the result?#2020-02-0316:13mkarpYes, getting the result would be great#2020-02-0316:48yendaWhen building with shadow, is there a way to get the list of all dependencies (including transitive?)? Even something like this when I do compile but this only shows what isn't cached yet
Retrieving reagent/reagent/0.9.1/reagent-0.9.1.pom from 
Retrieving cljsjs/react/16.9.0-1/react-16.9.0-1.pom from 
Retrieving cljsjs/react-dom/16.9.0-1/react-dom-16.9.0-1.pom from 
Retrieving cljsjs/react-dom-server/16.9.0-1/react-dom-server-16.9.0-1.pom from 
Retrieving re-frame/re-frame/0.11.0/re-frame-0.11.0.pom from 
Retrieving reagent/reagent/0.9.1/reagent-0.9.1.jar from 
Retrieving cljsjs/react-dom-server/16.9.0-1/react-dom-server-16.9.0-1.jar from 
Retrieving cljsjs/react-dom/16.9.0-1/react-dom-16.9.0-1.jar from 
Retrieving cljsjs/react/16.9.0-1/react-16.9.0-1.jar from 
Retrieving re-frame/re-frame/0.11.0/re-frame-0.11.0.jar from 
#2020-02-0316:50thhellerwhat for specifically? the list you'd get would include shadow-cljs and all its deps?#2020-02-0316:51yendayes, I need it because we use a pure environment for our builds wit nix#2020-02-0316:52thhellernot sure what nix has to do with this but you can get a list via shadow-cljs classpath?#2020-02-0316:58yendawe have a script that gets all the deps from lein build and create a .nix where they are like this:
"" =
  {
    host = repositories.maven;
    path =
      "args4j/args4j/2.33/args4j-2.33";
    type = "jar";
    pom = {
      sha1 = "168b592340292d4410a1d000bb7fa7144967fc12";
      sha256 = "046pab6gz1bh6w1jfbabgxvkrnvncrj93lnmaya5qs6a1z7mccn2";
    };
    jar = {
      sha1 = "bd87a75374a6d6523de82fef51fc3cfe9baf9fc9";
      sha256 = "1mlyqrqyhijwkjx4sv2zfn2ciqfwpc08qq8w55rcxb941fxfmpci";
    };
  };
#2020-02-0316:58yendait's for reproducible builds#2020-02-0317:00yendaclasspath could potentially do the trick#2020-02-0317:00yendathere is no way to have the repo it's coming from?#2020-02-0317:01thhelleryou said lein so you gonna need to use lein? (assuming :lein set in shadow-cljs.edn)?#2020-02-0317:03yendano I'm replacing lein by shadow-cljs entirely#2020-02-0317:04thhellerand how did you do it with lein?#2020-02-0317:05yendalein with-profile prod cljsbuild once
_lein_cmd='yarn app:compile:android'
_repo_path=$(mktemp -d)

function filter() {
  sed -E "s;Retrieving ([^ ]+)\.(pom|jar) from $1.*;$2\1;"
}

echo "Computing maven dependencies with \`$_lein_cmd\`..." > /dev/stderr
trap "rm -rf ${_repo_path}; [ -f ${_project_file_name}.bak ] && mv -f ${_project_file_name}.bak ${_project_file_name}" HUP ERR EXIT INT

cd $GIT_ROOT

# Add a :local-repo entry to project.clj so that we always start with a clean repo
sed -i'.bak' -E "s|(:license \{)|:local-repo \"$_repo_path\" \1|" ${_project_file_name}
rm -rf ./${_repo_path}
$_lein_cmd 2>&1 \
  | grep Retrieving \
  | filter clojars  \
  | filter central  # NOTE: We could use `lein pom` to figure out the repository names and URLs so they're not hardcoded
#2020-02-0317:05thhellerthe url things are coming from isn't currently saved anywhere. the closest thing to "data" that is currently available would be in .shadow-cljs/classpath.edn#2020-02-0317:05thhellerit should be possible to include the URLs in that#2020-02-0317:05yendaso basically just piping and filtering the output of the line command#2020-02-0317:06thhellerbtw you could skip all that with one "trick"#2020-02-0317:08thhellerit is a bit madness IMHO but you can set :maven {:local-repo "local-m2"} and keep the <project>/local-m2 files in git#2020-02-0317:08thhelleror zip/unzip in some way when packaging#2020-02-0317:11yendaso you mean have all the jars in the repo?#2020-02-0317:12yendawe have them in the nix store#2020-02-0317:12thhellerI know absolutely nothing about nix so no idea what a store is#2020-02-0317:12yendaadding the URLs in the classpath looks promising#2020-02-0317:13thhellerjust saying that if this way the project is completely separate. it won't even talk to the internet when building#2020-02-0317:13thhellerit'll never fetch anything that isn't already present#2020-02-0317:14thhellerI'm not sure I can get the URL, need to check if pomegranate provides it#2020-02-0317:16thhelleropen an issue or I'll forget. working on other stuff currently#2020-02-0317:22yendaok thanks#2020-02-0412:07aisamuJust saying, a blog post on cljs+shadow+nix would be terrific!#2020-02-0318:43lilactownfor some reason when I try and use a namespaced keyword in a macro, shadow-cljs throws an error#2020-02-0318:45lilactown
[:dev] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/lilactown/Code/helix/src/helix/hooks.cljc:115:41
--------------------------------------------------------------------------------
 112 |      (cond
 113 |        ;; warn on typical errors
 114 |        (and (= (count body) 1) (symbol? (first body)))
 115 |        (do (hana/warn ::hana/simple-body env)
-----------------------------------------------^--------------------------------
helix/hooks.cljc [line 115, col 41] Invalid keyword: ::hana/simple-body.

--------------------------------------------------------------------------------
 116 |            nil)
 117 | 
 118 |        ;; deps are passed in as a vector
 119 |        (vector? deps) (deps->hook-body `(cljs.core/array 
this is in a :clj reader-conditional, and the hana namespace alias does exist in clojure (but not cljs)
#2020-02-0318:45lilactownwriting out the fully qualified namespace for the keyword works#2020-02-0319:45thhellercode must still be readable as CLJS. tools.reader must still be able to read the full form (and then throw it away). don't ask me why that is. has nothing to do with shadow-cljs#2020-02-0319:46lilactownI see. only in .cljc files I’m assuming?#2020-02-0319:48thhellernot really sure I understand that question. clj and cljs must both the readable always?#2020-02-0319:48thheller
(comment ::foo/bar)
Syntax error reading source at (REPL:1:19).
Invalid token: ::foo/bar
#2020-02-0319:49thheller(that is CLJ)#2020-02-0319:49lilactownlike I said above, in my namespace I have required another ns and aliased it to hana . I can evaluate ::hana/foo using a REPL#2020-02-0319:51lilactownmy question is trying to make sure that I understand the problem which is: I am trying to use a shorthand namespaced keyword in a .cljc file where I have not required/aliased that namespace in the CLJS portion, which is why it can’t be read#2020-02-0319:51lilactownit was poorly stated#2020-02-0319:54thhellerit must be resolvable for CLJS and CLJ. try to flip it and see what clojure does, ie. create an alias an CLJS and use it in CLJ (in a :cljs conditional)#2020-02-0319:54thhellerif that is different open an issue with tools.reader. if thats the same then thats just is how its supposed to be.#2020-02-0319:54thhellereither way there is nothing shadow-cljs can possibly do here#2020-02-0319:55lilactownunderstood, thanks#2020-02-0319:58thheller
$ clj test.cljc
Exception in thread "main" Syntax error reading source at (/mnt/c/Users/thheller/code/tmp/test.cljc:3:31).
        at clojure.lang.Compiler.load(Compiler.java:7642)
        at clojure.lang.Compiler.loadFile(Compiler.java:7573)
        at clojure.main$load_script.invokeStatic(main.clj:452)
        at clojure.main$script_opt.invokeStatic(main.clj:512)
        at clojure.main$script_opt.invoke(main.clj:507)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Invalid token: ::str/foo
#2020-02-0319:58thheller
$ cat test.cljc
#?(:clj ::foo :cljs ::str/foo)
#2020-02-0319:58thhellersame thing#2020-02-0405:31genekimNot sure where to post this… One of the things I’ve just discovered while switching a project to use shadow-cljs is that the newer version of .jsonp has a breaking change — it no longer takes a uri, but now it takes a TrustedResourceUrl. This breaks the cljs-http / jsonp library call. I’ve created a new patched version of jsonp that creates a TrustedResourceUrl, but… But it just hit me — seems like there should be a code path for the older versions of Google Closure http://goog.net, and one for the newer versions — how does one determine what version of the Closure compiler is being used? 🤔 Or to broaden the question, how do we tell which data structure to pass the jsonp function — a Uri or TrustedResourceUrl? Thank you!#2020-02-0405:33genekimPS: Here’s a link to the issue I’m working out of: https://github.com/r0man/cljs-http/issues/126#2020-02-0409:51thhellerhmm yeah that is unfortunate. I also had to adjust the module loader since the closure folks switched that to the "trusted" setup as well. it is rather annoying to deal with and I don't know how to keep it backwards compatible.#2020-02-0409:52thhellerunfortunately the closure-compiler version used is no longer compatible with the "old" closure-library version either#2020-02-0409:52thhellercan't stay on the older closure-compiler version because of important updates for the JS support ...#2020-02-0410:04thhellerbut CLJS should be getting an upgraded closure-compiler version sometime soon. that will also include a new closure-library version.#2020-02-0416:00genekimLooping @U0CKBRBD2 in on this as well. Just to explore the potential decisions — this is definitely out of my league here, but I can enumerate what I think the choices are? 1. Switch exclusively to “trusted” jsonp inside of cljs-http, thus breaking anyone not using newer version of clojurescript/closure compiler. (Seems like an unacceptable choice… definitely not in spirit with Hickey-ist norms. 🙂 2. Remain exclusively with old “untrusted” jsonp, which means anyone running with newer clojusrescript/closure compilers will no longer run. (Does that mean there’s a caveat in cljs-http that says, “use only this version if running this version of clojurescript/closure?” Yuck. I’d definitely probably not read those instructions and get it wrong. ) 3. cljs-http has to determine what clojurescript/closure version is being run dynamically, and pass appropriate parameters to jsonp accordingly. (Very appealing, but I have no idea how to do this. I wish there were .versionconstant or something… I’ll keep exploring #3. Maybe ask in another channel, too…#2020-02-0416:01genekim@thheller Can you confirm or comment on my thinking? Many thanks!!!#2020-02-0416:07thheller@U6VPZS1EK posted a reply here https://github.com/r0man/cljs-http/issues/126#issuecomment-581983199#2020-02-0416:09thhellerthere is no version flag or anything so comparing things would be difficult. I'm also not sure the "new" TrustedResourceUrl thing actually existed in the old version#2020-02-0417:08genekimVery cool idea of extending Uri with prototype! I’ll run with that idea, and see if I can make it work. PS: I was really “excited” to discover that Closure compiler generates compile time errors in “release mode” when attempting to do unsafe things. I actually really like static typing, although at times like this, I sure do love the escape hatches!! 😂 I appreciate the potential irony and logical inconsistency. 🙂#2020-02-0407:42ElirazHey, anyone knows about an i18n library that can integrate with hx ?#2020-02-0408:47orestisWhen an exception is raised during a macro evaluation, we see shadow-cljs going into a loop, trying to reload the build and hitting the same error over and over. Just a mild annoyance since fixing the problem gets you back to a stable state, just thought I’d raise it. #2020-02-0408:47orestisThis involves a file loaded through the shadow resource api. #2020-02-0409:54thheller@orestis didn't I fix that a long time ago? which version do you use?#2020-02-0409:56orestis2.8.72 -- I usually lag behind releases a bit, I'll check if it happens with the latest one#2020-02-0417:11mkarpHey @thheller! I have another question. Can you please let me know if it is possible to start a npx shadow-cljs server and then start two separate npx shadow-cljs watch :app1 and npx shadow-cljs watch :app2 with different class paths?#2020-02-0417:15thheller@me1676 no that is not possible#2020-02-0417:25thhellerwhy would it be. swapping the classpath should never be necessary. I haven't found a good reason for it. shadow-cljs only includes what is actually used. therefore you can have a billion things on the classpath and it won't make your build larger.#2020-02-0417:28thhellerevery other use in the wild I have seen seemed rather random and hacky IMHO. shadow-cljs offers plenty of other options for those "hacks" if needed.#2020-02-0419:18lilactownhow do I get shadow-cljs to ignore warnings at dev time#2020-02-0419:18lilactownI tried :devtools {:ignore-warnings true} which seems to match the user guide, but it still won’t hot reload#2020-02-0419:21thhellerdid you set it in the proper place in the build config?#2020-02-0419:22lilactown[:builds :app :devtools]#2020-02-0419:22lilactownI guess what I’m asking is, what is the proper place? it’s unclear from the user guide#2020-02-0419:23thhellerin the build config#2020-02-0419:25thheller(works fine for me)#2020-02-0421:11JHello 🙂 Is there a way to simulate the same behaviour of webpack I18nPlugin (replace translation on compile time) with shadow-cljs?#2020-02-0421:20thhellernot currently#2020-02-0515:28ackerleytngI'm trying to import fs in the renderer in an electron app - building the app with shadow-cljs. has anyone been able to do this successfully before?#2020-02-0516:34Wilson Velezis there a way to get the shadow.build/mode in a re-frame app?#2020-02-0516:35lilactowndo you mean you want to detect if it’s a dev build or a release build?#2020-02-0516:40Wilson Velezyes, but I’ve just realised I can use goog.DEBUG for that, right?#2020-02-0516:42lilactownyes, that’s correct#2020-02-0517:03Wilson Velez@U4YGF4NGM thanks!#2020-02-0611:51dimaHello, :js-options :resolve currently isn’t supported when building for react-native target - is there a reason it’s not supported?#2020-02-0613:23thheller@trybeee for react-native builds metro will be responsible for resolving packages. so you need to configure it there.#2020-02-0614:43dimaIn deps.edn i have reagent dependency which excludes cljsjs/react dependency. During the build, shadow compiler fails with “react dependency is missing” so i’d like to resolve it with :js-options {:resolve {"react" {:target :global :global "React"}} as i’m adding react.js to the page via another script#2020-02-0616:53thhelleryou said react-native? there are no pages? I'm unclear what you are doing?#2020-02-0616:54thhellerit complains about react missing only if the lib you used did (:require [react ...]) so not (:require ["react" ...])#2020-02-0616:55thhellerbasically all you need is a node_modules folder that includes react#2020-02-0616:55thhellera :react-native build won't actually use it .. but it will make the error go away#2020-02-0621:25dimaSorry for confusion, you’re right there is no pages in RN, i was talking about browser target. We have multiple targets in out config. For react-native target, we still want shadow to pull js dependency code from external file, similar to what cljs compiler option :foreign-libs does https://cljs.github.io/api/compiler-options/foreign-libs Also, library doing (:require [react]) is reagent as it depends on cljsjs/react (not react from node_modules).#2020-02-0621:31thheller(:require [react]) works fine in shadow-cljs IF node_modules/react exists#2020-02-0621:32thhellerI still don't get what your actual problem is though#2020-02-0621:33thhelleryou have a browser build that uses :js-resolve to pick react from a global, coming from somewhere else#2020-02-0621:33thhellerand your react-native build fails because it can't find react?#2020-02-0621:35thhellerso what shadow-cljs does if you have (:require [react]) it'll first check if thats a regular CLJS namespace#2020-02-0621:35thhellerif that does not exist it'll look for node_modules/react#2020-02-0621:35thhellerif that does not exist it'll fail#2020-02-0621:35thhellerif you have it installed somewhere else (which I assume if you use react-native you can use :js-package-dirs#2020-02-0621:36thhellerhttps://github.com/thheller/reagent-react-native/blob/master/shadow-cljs.edn#L15#2020-02-0713:31dimaThanks for pointing to :js-package-dirs option, it looks like that what i want. I basically want to point to the dir where to get “react” dependency from when building for react-native#2020-02-0613:42sichacvahHello! Somebody know how to configure tests in react native? Because if I try to start any test with react native component it fails with syntax error in warnOnce.js file#2020-02-0613:45thhellerhow did you compile the tests?#2020-02-0614:08sichacvahI tried as node-test or react-native#2020-02-0614:09thhellerthings need to be compiled by react-native/metro#2020-02-0614:09thhellerI can't tell you how testing works in RN but you are likely going to need to use whatever they provide#2020-02-0614:13sichacvahWhen I try to run with just (default test framework for react native) I faced ‘goof is not defined’ error.#2020-02-0614:21thhellerpeople in #cljsrn might know more. I don't use react-native myself so I can't help much#2020-02-0615:39sichacvahI found https://github.com/tkjone/demo-clojurescript-jest/blob/master/README.md project will try with it#2020-02-0613:42vikeriHi! I suspect that my production build in electron uses the dev version of React. I’m using re-frame and reagent and I have react och react-dom in my package.json. Does anyone know how I can tell which build is used. shadow-cljs is still quite new to me.#2020-02-0613:44thheller@vikeri which :target did you use?#2020-02-0613:45vikeri:browser#2020-02-0613:45vikeri(But I’m using electron)#2020-02-0613:45thhellerthen create a build-report for your :browser build via https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2020-02-0613:45thhellerit'll tell you exactly what it used#2020-02-0613:46thheller(unless you configured :js-provider :require in which case it is all electron providing the dependencies)#2020-02-0613:46vikeriI did configure :js-provider :require#2020-02-0613:46thhellerthen shadow-cljs is out of the picture as far as dependencies are concerned#2020-02-0613:47thhellerelectron might have a setting for process.env.NODE_ENV but I'm not sure how you'd set it#2020-02-0613:48vikeriOk thanks! I’ll look into it#2020-02-0613:48vikeriHuge kudos for making shadow-cljs such a great experience to use! 👏#2020-02-0622:14dottedmagHow do I use plain JS file with shadow-cljs that declares a global variable at the top? I required it (using an absolute path), but that does not cause this variable to be available via js/Var — is this expected? Is there a better way?#2020-02-0622:15dottedmag(as an aside - maybe someone has made @octocat/rest work from NPM? it seems to depend on a Node-only package, but somehow authors also produce a release for Web without this dependency)#2020-02-0622:19thheller@dottedmag declaring it in a file does not make it global. why does it need to be a global though?#2020-02-0622:20thhellerdid you mean https://www.npmjs.com/package/@octokit/rest?#2020-02-0622:20dottedmagYes, this one. Here's their bundle for Web: https://github.com/octokit/rest.js/releases/download/v16.43.1/octokit-rest.js#2020-02-0622:22dottedmagYou can see it's var Octokit = ...; — no AMD, not a ES6 package, so I'm at loss how to use it except <script> in HTML and use the global.#2020-02-0622:24thhellerwhy are you looking at that file?#2020-02-0622:24thhellernpm install @octokit/rest and (:require ["@octokit/rest" :as x]) what does that give you?#2020-02-0622:25dottedmagIt gives me The required JS dependency "os" is not available, it was required by "node_modules/os-name/index.js"#2020-02-0622:25dottedmag"os-name" is a transitive dependency of @octokit/rest#2020-02-0622:25dottedmagThis is for :browser#2020-02-0622:26thhellerah I guess you didn't follow the instructions and didnt install shadow-cljs in the project#2020-02-0622:26thhellernpm install shadow-cljs in the project should fix it#2020-02-0622:28dottedmagThanks, it worked.
#2020-02-0622:29thhelleros is one of those packages that needs a polyfill for the browser#2020-02-0622:29dottedmagHowever I have a couple of questions: • where are the instructions? I don't see it in section (2) of the guide • what did it do to make it work?#2020-02-0622:29thhellerthat polyfill is a dependency of shadow-cljs#2020-02-0622:31dottedmagOK, that answers my second question 🙂#2020-02-0622:32thhellerI guess it could be clearer in the docs#2020-02-0622:33dottedmagIndeed, the guide suggests to install shadow-cljs globally, and only reluctantly says "yes, you can install it local and use npx"#2020-02-0622:36dottedmagFiled #648 so it does not get lost#2020-02-0622:36thhellerit was enforced for a while but people complained 😛#2020-02-0622:37thhellerhttps://github.com/thheller/shadow-cljs/issues/454#2020-02-0622:53wisemani’m having an issue with the :node-test target combined with watch that makes me wonder if i’ve missed something basic. i have
:test
  {:target :node-test
   :output-to "out/node-tests.js"
   :autorun true}
and i run npx shadow-cljs watch script test. but when i change a file, it seems like only a subset of my tests are automatically run. if i explcitly do node out/node-tests.js then they all run. what am i doing wrong?
#2020-02-0622:57wisemanmy complete config is at https://gitlab.com/jjwiseman/advisory-circular/-/blob/master/shadow-cljs.edn#2020-02-0703:00preThis is taken from an example app with aws amplify + shadow https://dev.to/royalaid/cljs-s-aws-amplify-4f25 src/app.cljs:
(:require ["@aws-amplify/api" :refer [graphqlOperation] :default API]                                                                                                                                                                                                                                 
            ["@aws-amplify/pubsub" :default PubSub]                                                                                                                                                                                                                                                   
            ["/graphql/mutations" :refer [createTodo]]                                                                                                                                                                                                                                                
            ["/graphql/queries" :refer [listTodos]]                                                                                                                                                                                                                                                   
            ["/graphql/subscriptions" :refer [onCreateTodo]]                                                                                                                                                                                                                                          
            ["/aws-exports" :default awsconfig] ;; Important Diff, no period                                                                                                                                                                                                                          
            [applied-science.js-interop :as j])                                                                                                                                                                                                                                                      
                                                        
Local directory has src/graphql generated and corresponding js files (queries, mutations). The following require throws an error: The required JS dependency "/graphql/mutations" is not available, it was required by "app.cljs". What am I missing?
#2020-02-0708:40dottedmag@pri Do you have src in :source-paths?#2020-02-0721:42preyes, i'm an experienced clojure engineer, but haven't used a mixed cljs/js project with shadow yet#2020-02-0710:56g7sI introduced another dependency and I have a REPL open. Is there any way to reload the dependencies without restarting the REPL? The only thing I found is (shadow/reload-deps!) but it returns :shadow.cljs.devtools.api/standalone-only and is doing nothing#2020-02-0710:57thhellerCLJS dependencies require a restart#2020-02-0710:57g7scool thanks#2020-02-0719:50kennyI just ran npx shadow-cljs node-repl from the terminal and received this message. It appears to indicate I need to install the ws module. This is all that's in my package.json
{
  "name": "spec1-select",
  "dependencies": {},
  "devDependencies": {
    "karma": "4.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cljs-test": "0.1.0",
    "shadow-cljs": "2.8.83"
  }
}
#2020-02-0719:51kennyThis does not exit the JVM. I have to ctrl+c which the results in this message getting printed continuously
cljs.user=> Failed to read: clojure.lang.ExceptionInfo: Input/output error {:type :reader-exception, :line 1, :column 1, :file "repl-input.cljs"}
That will only stop when I ctrl+c again.
#2020-02-0719:52kennyAdding "ws": "7.2.1" to my package.json fixes this. Seems strange that this is required.#2020-02-0719:54kennyStill ctrl+c'ing after adding the ws module results in continuous printing of that Failed to read message.#2020-02-0720:14thhellerws normally is a dependecy of shadow-cljs so it should be installed. not sure why it wouldn't be#2020-02-0720:14thhellerthe repl process doesn't really expect the node process to crash on startup so I guess it doesn't handle that correctly#2020-02-0720:39ro6I'm working on a browser extension (using {:target :chrome-extension}) and trying to set up some functions in a user.cljc file to help me switch between the REPLs hosted by the background and content scripts. I have the logic figured out (using (shadow/repl-runtime-select ...)) , but the UX still isn't clean for a few reasons: 1. The base Clojure REPL loads shadow.user instead of my user ns 2. Shadow doesn't seem to load my user ns on initial compile into either the CLJ or CLJS REPLs (perhaps because nothing depends on it?) Is there a way to configure Shadow to load my user ns automatically in all of the REPLs (the default Clojure behavior)? Can I query the CLJS runtime from within? (similarly to the way shadow.cljs.devtools.api works from the base Clojure REPL)#2020-02-0720:43thhelleryou can set :devtools {:repl-init-ns some.ns} per build#2020-02-0720:55ro6Thanks for the quick response, that mostly made it a lot better, but there's still an issue. Once I've switched into the CLJS REPL for the first time, when I try to run a fn from my user ns, I get this error
(enter-content-script-repl)
no source by provide: user
{:provide user}
ExceptionInfo: no source by provide: user
	shadow.build.data/get-source-id-by-provide (data.clj:184)
	shadow.build.data/get-source-id-by-provide (data.clj:181)
	shadow.build.data/get-source-by-provide (data.clj:187)
	shadow.build.data/get-source-by-provide (data.clj:186)
	shadow.cljs.repl/repl-compile/fn--14867/fn--14868 (repl.clj:453)
	shadow.cljs.repl/repl-compile/fn--14867 (repl.clj:429)
	shadow.cljs.repl/repl-compile (repl.clj:427)
	shadow.cljs.repl/repl-compile (repl.clj:424)
	shadow.cljs.repl/process-read-result (repl.clj:515)
	shadow.cljs.repl/process-read-result (repl.clj:491)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:844)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:798)
	shadow.cljs.devtools.server.worker.impl/eval15787/fn--15788 (impl.clj:879)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325/fn--15333 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--15324 (util.clj:257)
	java.lang.Thread.run (Thread.java:830)
#2020-02-0720:56ro6enter-content-script-repl is a CLJC fn and has a CLJS portion that works fine once I manually load the ns.#2020-02-0720:58thhellerhmm yeah I think there was a bug when :init-ns isn't part of the actual build#2020-02-0720:58thhelleryou can maybe add :devtools {:preloads [the-repl-init-ns] :init-ns the-repl-init-ns}#2020-02-0720:58thhellerthat forces it to be compiled as part of the ubild#2020-02-0720:58ro6Cool, trying.#2020-02-0720:58thhellerI thought I had fixed that issue but maybe I didn;t#2020-02-0721:00ro6I'm on 2.8.83#2020-02-0721:02ro6Guess that is the latest release. Sometimes I have trouble keeping up, which is a good problem to have 🙂#2020-02-0721:08ro6The :preloads trick worked. Everything's nice and clean now. Would you like me to file an issue that :repl-init-ns should imply that the ns gets loaded?#2020-02-0721:10ro6Nevermind, found the existing. I'll pile on that one. https://github.com/thheller/shadow-cljs/issues/474#2020-02-0720:44thhellerfor the CLJ repl you can configure :repl {:init-ns user} at the top level#2020-02-0721:53jmckitrickSo I’m back again, trying to get my project to compile with shadow and then produce an uberjar. At some point running the uberjar task, the payload built by shadow in target/cljsbuild is being deleted. I’ve disabled :clean-targets in my project file, but it’s still happening.#2020-02-0721:53jmckitrickWhat’s the best way to have shadow build the app and put it in the right place for the uberjar task to find it and the app to serve it?#2020-02-0721:54thhellerI don't know what your uberjar setup is so kinda hard to answer#2020-02-0721:55thhellertypically people use :output-dir "resources/public/js so something like that in the shadow-cljs build config#2020-02-0721:55thhellerand lein by default will package resources into the uberjar (or configured via :resources-paths)#2020-02-0721:55jmckitrickThe project is generated by luminus, so those defaults should apply.#2020-02-0721:55jmckitrickOk, so I’ll start looking at ‘resources’#2020-02-0721:56thhellernote that is only the classpath root it will package#2020-02-0721:56thhellerso whenever things are served it would be /js/main.js or whatever your files are named#2020-02-0721:58thhelleras far as lein is concerned its just files in a dir. it doesn't need to know anything else about CLJS#2020-02-0721:58jmckitrickThat’s what I thought as well.#2020-02-0721:58thhellerand as far as shadow-cljs is concerned its just writing files into a dir, it doesn't care about lein either#2020-02-0722:00jmckitrickMaybe lein is running a clean before uberjar, and that’s what’s blowing away the js files.#2020-02-0722:00jmckitrickWell, that was it. All I did was change ‘output-dir’ per your suggestion.#2020-02-0722:02thhellerlein does clean if you tell it to clean yes#2020-02-0722:02jmckitrickI didn’t explicitly.#2020-02-0722:02thhellerjust clean manually if you have to via rm -rf resources/public/js && shadow-cljs release app && lein uberjar#2020-02-0722:02jmckitrickWill do!#2020-02-0722:03thhelleralso don't put CLJS in uberjars if you can help it ... 😛#2020-02-0722:04jmckitrickDefinitely not! lol#2020-02-0723:25preWith (:require ["/graphql/mutations"]) why does shadow throw a The required JS dependency "/graphql/mutations" is not available ..." when the source path is set to src and it contains src/graphql/mutations.js?#2020-02-0810:34thheller@pri one guess: you are using deps.edn or project.clj but configured said path in shadow-cljs.edn?#2020-02-1021:42preThe project structure is from a "working example" off a blog. source-path is set to src and deps in deps.edn, in shadow-cljs. In deps.edn the paths var is set to src.#2020-02-0822:51Gleb PosobinI am using shadow-cljs to generate a chrome extension. The content script does not seem to hot reload, while the background script reloads fine on file updates. I.e. init-fn in content script continues to println the same thing after page refresh it did when I loaded the extension in chrome. What could be wrong?#2020-02-0822:56Gleb PosobinBut when I unload and then load the extension again in Chrome, the content script behaves differently. So it compiles the changes, but they for some reason are not picked up by the running extension.#2020-02-0823:03darwinI’m not familiar with shadow-cljs support for chrome extensions, but in general hot reloading content script is really tricky, because eval of dynamic code prohibiter or restricted https://developer.chrome.com/extensions/contentSecurityPolicy#interactions#2020-02-0823:03darwinI don’t remeber the details but I ended up not supporting hot reloading of content scripts in chromex library.#2020-02-0823:10darwinI just briefly glanced over shadow-cljs sources and it looks like @thheller added support for hot-reloading of content script - maybe the feature is just broken for you#2020-02-0823:11darwinhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/chrome/content.cljs#L8#2020-02-0823:12Gleb PosobinI thought that the content security policy might be a problem. There is this message by @thheller with an example of a CSP that I thought would fix that, but it did not: https://github.com/thheller/shadow-cljs/issues/279#issuecomment-392007641#2020-02-0823:15darwinmaybe Chrome devs tightened the rules and what worked before no longer works, at least they have been nagging my chrome extension to review requrested permissions and explain them to the review team#2020-02-0823:15Gleb PosobinHmm, interesting, so the stuff in the function that I marked with ^:dev/after-load is indeed reloaded, but not in the init function.#2020-02-0823:21Gleb PosobinSo when I do this:
(defn ^:dev/after-load reloaded []
  (println "The content script was reloaded!"))

(defn init []
  (reloaded))
After changing the string in the reloaded function, the new string is printed in the console of the page. But when I reload the page after that, the old string gets printed.
#2020-02-0823:22Gleb PosobinLooks like the previous version of the content script is loaded on page refresh.#2020-02-0823:24darwinmake sure that the genearated source javascript file on disk is actually what you expect, this will rule out shadow-cljs not recompiling the file properly and the problem will be chrome caching the content script file itself somewhere (likely)#2020-02-0823:26Gleb PosobinThe file on disk is updated correctly.#2020-02-0823:28darwinnot sure how to tell chrome to reload whole content script javascript file#2020-02-0823:28darwinmanually you can go to extensions page and reload the extension via UI, I would expect that to load new version of on-disk file#2020-02-0823:29Gleb PosobinYes, that does reload the file correctly.#2020-02-0823:29darwinyou might also try to open devtools and check disabling caching in DevTools Settings (F1)#2020-02-0823:29darwinI mean disabling network caching when DevTools is open#2020-02-0823:30darwinnot sure if this would apply to content scripts as well, probaly not, but worth trying#2020-02-0823:32Gleb PosobinThat flag doesn't help =/#2020-02-0823:33darwinok, that is only related to page network requests, not extensions see this: https://bugs.chromium.org/p/chromium/issues/detail?id=112471#2020-02-0823:34darwinmerged with https://bugs.chromium.org/p/chromium/issues/detail?id=104610#2020-02-0823:37darwinbut since shadow-cljs already knows how to do hot reloading in theory it could add a workaround for this issue, content script init code could contain some test for stale content and request a clean hot-reload for you#2020-02-0823:42Gleb PosobinAdding :module-hash-names true to the shadow-cljs config helped with that.#2020-02-0823:43Gleb Posobin@darwin Thank you for your help!#2020-02-0823:45darwingood to know! maybe open an issue with this workaround so this knowledge does not get lost here on slack btw. I started with shadow-cljs just recently. I want to look into this :chrome-extension target soon, it looks like a hidden gem 🙂 … and maybe create an example shadow-cljs app using chromex#2020-02-0902:05rbergerThat would be a dream come true!#2020-02-0823:46Gleb PosobinAh, no, it didn't help facepalm#2020-02-0823:46darwin😞 you need to kick chrome extensions subsystem somehow, to reload the files#2020-02-0823:46Gleb PosobinYes, an example would be great! I struggled the first day or so to set everything up.#2020-02-0823:47darwinotherwise it will assume they didn’t change#2020-02-0823:48darwinmaybe you can do custom hack yourself, simple http get the js file in content script init code and eval it (the same way shadow-cljs evals the code during hot-reload)#2020-02-0823:48darwinit is dirty, but it should work#2020-02-0900:15Gleb PosobinI am having trouble finding how shadow-cljs is doing it in its source. Could you point me please?#2020-02-0900:24darwinI don’t know, the sources are too complex for me to understand just by reading them, if I had the project at hand, I would simply break in DevTools and look how shadow-cljs does it#2020-02-0900:24darwinit is probably using just eval#2020-02-0900:25darwintry to put breakpoint here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/boot/browser.js#L125#2020-02-0900:25Gleb PosobinOk, thank you!#2020-02-0900:27darwinor better put breakpoint into your reloaded fn and inspect the callstack#2020-02-0909:28rbergerI have attempted to make the chromex example/sample (https://github.com/binaryage/chromex/tree/master/examples/sample) work with shadow-cljs :chrome-extension I pretty much have the background page working (modulo some issue with the test-storage function). But the biggest problem is I can't figure out how to configure shadow-cljs to properly hook in the extension popup. I was just guessing it was related to the :browser-action but my guess is clearly not working. I am still pretty unwashed when it comes to cljs / shadow-cljs and chrome extensions. My attempt at this is at https://github.com/omnyway-labs/chromex-sample-shadow. The README details the issues. If anyone has any helpful hints, I would be greatly appreciated. It seems pretty close and once this is made to work, it could be a good template for building chrome extensions with shadow-cljs.#2020-02-0912:20darwin@rberger I will look into this today. Will try to use your project as my start point and try to make it work.#2020-02-0921:16rbergerThank you! Very much appreciated#2020-02-0916:49Gleb PosobinThe problem is that the outputs should be specified in manifest.edn, not in shadow-cljs.edn.#2020-02-0917:13cobyHello, so I'm trying to containerize a basic ClojureScript/shadow-cljs development environment using Lando (https://docs.lando.dev). So far I've got the dev server serving static HTML/JS as it should be, but the HMR server only ever reports {:type :client/stale} . Even when I ssh into the container and curl it directly:
$ curl 'localhost:9630/ws/worker/dev/ac9d0f31-11a6-4c6b-9c75-a6f6a5ed1756/8dcdadc5-c951-4188-9c08-c5881f658fe7/browser' -H 'Accept: */*' --compressed -H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Extensions: permessage-deflate' -H 'Sec-WebSocket-Key: kC/iKKLLhR2/TcOVtWVO7Q==' -H 'Connection: keep-alive, Upgrade' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Upgrade: websocket'
{:type :client/stale}
Not sure what to poke next to troubleshoot. Thanks!
#2020-02-0917:17cobyI should clarify that HMR works perfectly when I run shadow-cljs watch dev directly on my machine. So something about the container environment is keeping it from seeing and/or reporting fresh compilations.#2020-02-0917:22Gleb Posobin@rberger I made a pull request which should make things work.#2020-02-0921:20rbergerThanks, I woke up thinking that at least some of the configuration needed to be in the manifest.edn. The comments in https://github.com/thheller/shadow-cljs/issues/279#issuecomment-392007641 made it seem like some or all could/should be in shadow-cljs.edn.#2020-02-0918:00thheller@ctamayo :client/state means that the js files you loaded in your HTML were not produced by the watch you started. so I'm guessing you are serving old files or have some cache enabled that serves them#2020-02-0918:01darwin@rberger @posobin I got it working here as well: https://github.com/binaryage/chromex/commit/c73dedb0b0e2b43f2ead0aad8775782ec4016898#2020-02-0918:02darwinhad to hack shadow-cljs for now, to get source maps working: https://github.com/binaryage/chromex/commit/c73dedb0b0e2b43f2ead0aad8775782ec4016898#diff-cf6355f4ec475b1cac556fde53d8914aR188-R192#2020-02-0918:05coby@thheller is that determination made by proc-id? Here in ws.clj?
(not= proc-id (:proc-id worker-proc))
      (send-ws-error :client/stale)
#2020-02-0918:08cobyIf so, that could mean that the newer watch may not be generating new files at all, correct?#2020-02-0918:11thhellerplease do not assume that there is a bug in shadow-cljs regarding this#2020-02-0918:11thhellerthis is for sure a bug in whatever you are doing#2020-02-0918:11thhellerwatch puts files in a dir#2020-02-0918:11thhellerload those files#2020-02-0918:11thhellerthats about it#2020-02-0918:12thhellerload it with whatever webserver you want but you need to load exactly those files#2020-02-0918:12thhellersince you tried it with curl you can see the ID it sends#2020-02-0918:13thhellerI presume you got those from the outdated generated files#2020-02-0918:13cobyno no no, this is definitely a bug in my code. I'm just trying to understand how stuff works. 😄#2020-02-0918:13thhellerlike I said ... watch produces files in a dir, load those files. nothing else to it#2020-02-0918:14thhellerif you containerize stuff its easy to mess up paths and stuff#2020-02-0918:14thhelleror loading files from the container instead of the actual fs etc#2020-02-0918:18thhellerdon't know anything about the lando stuff so can't make suggestions on that front#2020-02-0918:18thhellerit could just be a bad browser cache#2020-02-0918:19cobyright, so what I'm trying to determine is what "paths and stuff" are likely to get messed up, so I know which direction to go in. So let me rephrase: it's possible that something about the paths and stuff make it so that the watch is not actually producing new files, or not putting them in the right place?#2020-02-0918:24cobyby "bad browser cache" do you mean the browser itself could be erroneously caching the result of a previous request to the WebSocket?#2020-02-0918:27thhellerwhich webserver do you use?#2020-02-0918:27thhellerthe websocket is not involved in this issue#2020-02-0918:28thhellerthe issue is that the JS you are loading is outdated. it thus has an outdated websocket URL, which the server is telling you.#2020-02-0918:28thhellerall you have to do is look at your :output-dir and make sure that is the actual files you are serving#2020-02-0918:29thhellerjust delete the entire dir and start the watch#2020-02-0918:29thhellerif the file re-appear you have the right folder#2020-02-0918:29thhellerif they don't you are not looking at the correct place#2020-02-0918:30cobyah, I see. Things are starting to make more sense. Thank you!#2020-02-0918:40darwinI just tried to compile the example chromex extension with shadow in release mode, backgropund page and content script work, but popup (browser action) was generated without dependencies This is the compilation output with --pseudo-names: https://gist.github.com/darwin/a2ce8ee9079f78842f62e9e89dfc6615#file-popup-js-L96 $chromex$ext$runtime$connect_STAR_$$ is missing#2020-02-0918:41darwinnot sure if this is caused by :chrome-extension :target: https://github.com/binaryage/chromex/tree/master/examples/shadow https://github.com/binaryage/chromex/blob/master/examples/shadow/shadow-cljs.edn#L23#2020-02-0918:42thhellerit has been a while since I looked at the chrome-ext target#2020-02-0918:42thhellerbut one thing to remember is that it defaults to using code-splitting#2020-02-0918:43thhellerso you are likely just not loading the shared file#2020-02-0918:43thhellerthere should be a shared.js in the output-dir#2020-02-0918:43thhellerin outs that use a html file you need to load both#2020-02-0918:44thhellerie. shared.js + popup.js#2020-02-0918:44thhellerotherwise the :output-type controls how the output is structured#2020-02-0918:44thhellerie. for content-scripts its just one file with no splits#2020-02-0918:44darwinaah, let me try it, btw. interesting is that in dev mode this worked event without shared.js#2020-02-0918:44darwinI would expect both modes to be broken#2020-02-0918:44thhellerme too#2020-02-0918:45darwinok, great this fixed it#2020-02-0918:46darwinso last standing issue is with source maps, devtools does not allow loading .map files from chrome-extension://…/something.map URLs#2020-02-0918:46darwinI had to start dev-server and serve those smaps separately#2020-02-0918:46thhellerI'm pretty sure that works absolutely fine for me#2020-02-0918:47thhellerare you sure you have the right paths though?#2020-02-0918:47darwinok, let me try that it again#2020-02-0918:48thhellercan't tell which mods you did to the output.clj#2020-02-0918:51darwinhttps://gist.github.com/darwin/f9e883eef4629d462edc871b6830a4d5#2020-02-0918:52darwinhttps://github.com/binaryage/chromex/blob/633fb70cd9aee6dcfc4a7e85cadd6a899724f85d/examples/shadow/shadow-cljs.edn#L16#2020-02-0918:56darwinI was able to reproduce the source map issue after removed that custom hack. In current Chrome and also in Chrome Canary. You have to open extension’s background page to get spam of `#2020-02-0918:57darwinlike this, source maps don’t work#2020-02-0918:57darwinthe urls are accessible when I open them in a separate tab#2020-02-0918:58darwinchrome canary hints on “chrome-extension://” is the issue#2020-02-0918:59thhellerwhy is that a problem?#2020-02-0918:59thhellerI get the same error though#2020-02-0918:59thhellerlook like valid maps to me#2020-02-0918:59darwinDevTools don’t see those source maps, so for example clicking on a link to source code in console does not work, it shows generated .js file , not cljs file as expected#2020-02-0919:00thhellerI would not expect anything to work if it tells you that parsing them failed#2020-02-0919:00thhellerso I'd first try to figure out WHY it failed to parse#2020-02-0919:01darwinthat is just a misleading message from current Chrome - Chrome Canary has it improved and communicates what went wrong#2020-02-0919:02darwinthis is how it looks in current chrome canary#2020-02-0919:02darwinthe source maps are perfectly ok, just the code responsible for loading sourcemaps for chrome devtools is picky about URL scheme#2020-02-0919:03darwinwhen I use my prefix-hack to load the same source maps via dev-server it works as expected#2020-02-0919:04thhellerbut why does it serve the file perfectly fine if you open it?#2020-02-0919:04thhellerthe files should be served by the chrome-ext#2020-02-0919:05thhellerit makes no sense to it to talk to http#2020-02-0919:05darwinwe would have to look how source maps download is implemented in Chrome DevTools#2020-02-0919:06darwinmaybe they are calling some internal chrome API which has some security hardening and uses different code path than is used when you load page in normal tab#2020-02-0919:06darwinif that makes sense#2020-02-0919:06thhellermaybe it needs to be allowed in the CSP in the manifest?#2020-02-0919:07darwinthis should not be related because DevTools is not the same context as extension itself#2020-02-0919:08darwinthis is the originating place for the error message: https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/sdk/SourceMap.js#L232 I’m digging further#2020-02-0919:12darwinbtw. this is long-standing issue, I never found a good solution for it, that is also why I advocated inlined source maps as option in shadow-cljs#2020-02-0919:13darwinI also did https://clojure.atlassian.net/projects/CLJS/issues/CLJS-1902, which is still waiting for merge#2020-02-0919:15thhellerI fairly confident that it worked the last time I worked on this#2020-02-0919:15thhellerbut that was quite a while ago so chrome probably just messed something up#2020-02-0919:15thhellerI'd rather not work around chrome bugs#2020-02-0919:16darwinthat devtools code finally uses this at the bottom: https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/host/ResourceLoader.js#L172#2020-02-0919:16thhellerit clearly has the right url and knows how to serve it#2020-02-0919:16thhellerit does serve it with text/plain though. maybe it doesn't like that for some reason?#2020-02-0919:16darwinso it depends on host implementation of that loadNetworkResource fn, and I guess that is picky about that chrome-extension:// URI#2020-02-0919:18darwinthat net::ERR_UNKNOWN_URL_SCHEME looks like coming from C++#2020-02-0919:19darwinat least I don’t see any trace of it in DevTools codebase itself#2020-02-0921:03kaoskoI have a leiningen multimodule build with shadow compiled reagent ui. now, shadow modules are meant for runtime modules and shadow doesn't seem to understand lein-modules. Is there a way to include cljs sources from a different lein-module? part of the ui is supposed to be deployed as a lib and shared between two different applications#2020-02-0921:19kaoskothe best I have for now is just to set the src path to my shared module. It's not too bad but requires everybody else to checkout the same layout even though they may not work on all of the other parts#2020-02-0921:07thhellerdon't really know that lein-modules are#2020-02-0921:07thhelleras far as shadow-cljs is concerned all it needs is a classpath#2020-02-0921:08thheller> part of the ui is supposed to be deployed as a lib and shared between two different applications#2020-02-0921:08thhellerthat also makes no sense to me. you mean the sources should be shared right? compiled output can't be shared between builds#2020-02-0921:16Gleb Posobin@thheller, do you have any suggestions on how to fix this? https://clojurians.slack.com/archives/C6N245JGG/p1581204099310900#2020-02-0921:16Gleb Posobin(sorry, looks like many questions about extensions today)#2020-02-0921:16kaoskothanks @thheller. lein-modules are https://github.com/jcrossley3/lein-modules but perhaps I need Leiningen checkouts instead. Yes, we'll I don't have the share lib/module yet, but yes I figured easiest just to share the source#2020-02-0921:17Gleb PosobinTldr: content scripts are hot reloaded when code changes, but on page refresh the old content script is loaded by chrome. How can I make my content script fetch the last script from shadow-cljs and execute it on page load?#2020-02-0921:18thhellerI really can't remember much details about chrome ext stuff#2020-02-0921:18thhellerbut pretty sure that some things can't be worked around since its just how chrome exts work#2020-02-0921:19thhellerie. load things once and then never look at the FS again#2020-02-0921:19thhellerI vaguely remember that you can reload the chrome ext via the REPL#2020-02-0921:19thhellerwhich will make it reload things from disk#2020-02-0921:20Gleb PosobinYeah, but if that script that is loaded only once says to load the main content script from shadow server, that file on disk doesn't need to be refreshed by chrome. I just had trouble finding where shadow-cljs does hot reloading in its sources.#2020-02-0921:21thhellerwhat does that have to do with anything? you said that works?#2020-02-0921:21Gleb PosobinThat should work, but I don't know how to do that.#2020-02-0921:21thhelleryou are confusing me 😛#2020-02-0921:22thhellerthis really isn't all that complicated. shadow-cljs writes files into a folder.#2020-02-0921:22Gleb PosobinBasically I want to do hot reloading not only on file changes, but also when the browser loads the page and executes the content script.#2020-02-0921:22thhellerwhether or not chrome will read those files I cannot control#2020-02-0921:23Ivan Kozhi guys how to get release-snapshot?#2020-02-0921:24thhellerwhat is a release-snapshot?#2020-02-0921:24Ivan Kozhttps://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9#2020-02-0921:24Ivan Kozwas it ever released?#2020-02-0921:24thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2020-02-0921:24Ivan Kozthank you#2020-02-0921:25thhellername changed to build report 😉#2020-02-0921:25Ivan Kozi'm a bit new to whole JS front thing, kinda confused =)#2020-02-0921:25darwinad that chrome ext caching problem - I proposed a kind of workaround, where content script code would init with a check for stale source code situation and did one initial hot-reload pass if stale content was detected but I guess this smells like a lot of hairy work#2020-02-0921:27darwinmaybe having content script impl setup as a dynamic module and doing intial dynamic module load every time on init could also fix it#2020-02-0921:28thhellermy guess would be that nothing will work#2020-02-0921:29thhellerI'm just assuming here that chrome loads the file from disk once and caches it#2020-02-0921:29thhellerso unless there is a way to tell it to reload that file from disk#2020-02-0921:29darwinthat dynamic module would be loaded via dev-server#2020-02-0921:29thhellerany magic other method that tries to read that file would also get it the cached version#2020-02-0921:29darwinthis is not how it works#2020-02-0921:30darwinit is cached by extension subsystem, that has little to do with regular network cache in chrome#2020-02-0921:30darwinand you could always add cache buster when loading module dynamically#2020-02-0921:31darwinin case regular network cache would be a problem (a separate one)#2020-02-0921:32darwinI think I could try to implement example of this tomorrow, content script would only contain dynamic module load, and that dynamic module would be the main content script implementation#2020-02-0921:32thhelleryou could just REPL into the thing and (js/chrome.runtime.reload)?#2020-02-0921:33darwinhmm, that could work as well, I wasn’t aware of this API#2020-02-0921:34thhellermaybe even just call that as part of the reload lifecycle?#2020-02-0921:34thhellerdunno exactly what it does#2020-02-0921:34thhellermaybe there are other methods like that#2020-02-0921:34darwin@posobin this is worth trying#2020-02-0921:35thhelleralso how do you inject the content-script in the first place?#2020-02-0921:36darwinI don’t understand the question, chrome extension injects it#2020-02-0921:38thhelleryou can inject it via code#2020-02-0921:38thhellerhttps://developer.chrome.com/extensions/content_scripts#programmatic#2020-02-0921:38thhellerwhich might take the latest code always and not have that cache issue?#2020-02-0921:39darwindunno, but it is another promising thing to try#2020-02-0921:39darwindefinitely executing it via code should be possible solution#2020-02-0921:40darwinif you are able to fetch fresh version via dev-server or similar side-channel#2020-02-0923:20darwinI just tried the js/chrome.runtime.reload and it is not a good solution it blows extension state, including background page and others#2020-02-0923:27Gleb PosobinThe runtime.reload is the same as reloading from the extensions setting page.#2020-02-0923:27darwinyep#2020-02-0923:28Gleb PosobinI am still trying to understand how shadow hot reloads the file.#2020-02-0923:29darwinI tried that idea with the dynamic code eval, I’m able to fetch it from dev-server, but I ran into issues with goog.provide, it throws when stuff gets redeclared#2020-02-0923:29darwin@posobin look into shadow/cljs/devtools/client/browser.cljs#2020-02-0923:30Gleb PosobinYeah, was looking at that.#2020-02-0923:33darwinit uses js/goog.globalEval#2020-02-0923:34darwinI think we could be able to hook do-js-reload and on content script init replay all reloads since last extension reload#2020-02-1000:43Gleb PosobinI haven't figured out the resources ids so far.#2020-02-1003:33Gleb PosobinWhew, I have finally done it.
(defn refresh-source []
  (let [this-file
        {:resource-id [:shadow.build.classpath/resource "ext/content.cljs"]
         :module :content-script :ns 'ext.content
         :output-name "ext.content.js"
         :resource-name "ext/content.cljs"
         :type :cljs
         :provides #{'ext.content}
         :warnings []
         :from-jar nil}]
    (shadow.browser/handle-build-complete
      {:info        {:sources [this-file] :compiled #{(:resource-id this-file)}}
       :reload-info {:never-load #{} :always-load #{}
                     :after-load
                     [{:fn-sym 'ext.content/loaded
                       :fn-str "ext.content.loaded"}]}})))
#2020-02-1003:33Gleb PosobinInit function has to call this with some timeout (I use 500ms) to let the shadow cljs make the connection I think, not exactly sure why.#2020-02-1003:35Gleb Posobincontent.cljs is the name of the content script file, loaded is the function that you want to run when the content script loads (not necessary to add any tags to it).#2020-02-1016:24darwin@posobin cool, but I wonder if this works more generally if you have multiple cljs files in the content script output#2020-02-1016:30Gleb PosobinYou can specify multiple files there.#2020-02-1016:30Gleb PosobinOr do you want to get the list automatically?#2020-02-1016:31Gleb PosobinFor that you would have to query the shadow cljs server for the list of changed files first, I have not seen such methods in its sources.#2020-02-1016:33darwinhere is what I did: 1. wrap js/shadow.cljs.devtools.client.browser.do_js_load and record all reloaded sources there 2. replay recorded sources on intial load in content script the problem is “where to record that data”, I ended up sending it to background page and requesting it back on initial load#2020-02-1016:33darwinbut your solution seems to be more straightforward#2020-02-1016:33darwinpeople just need to maintain that list of files to refresh#2020-02-1016:34darwinwhich is ok#2020-02-1016:34darwinI guess#2020-02-1016:34Gleb PosobinHow did you do that?#2020-02-1016:34Gleb PosobinI haven't figured out how to change the shadow sources.#2020-02-1016:35darwinsomething like this#2020-02-1016:35Gleb PosobinAh.#2020-02-1016:36darwinbtw, hooking that fn just for printing sources for your method could be helpful as well#2020-02-1016:36Gleb PosobinYeah, I was messing with the compiled output...#2020-02-1016:37Gleb PosobinBasically spent the whole day yesterday on that...#2020-02-1016:38darwinan alternative would be a macro which could give you all relevant namespaces in the content script project and you would synthetise resources (sources) from it#2020-02-1016:38Gleb PosobinAnd how do you request it on init?#2020-02-1016:39Gleb PosobinAlso how do I patch the shadow server?#2020-02-1016:39darwinwhy do you need to patch shadow server?#2020-02-1016:39darwinI use js sources recorded on client side#2020-02-1016:40darwinI basically replay all hot-reloads#2020-02-1016:40darwinit does not do a server roundtrip#2020-02-1016:40Gleb PosobinAh, you record it in background.#2020-02-1016:40Gleb PosobinNot on the server.#2020-02-1016:41darwinyes, do-js-load works on client side, it has :js with fresh source code#2020-02-1016:41Gleb PosobinYes, I understand that. I thought it was doing the post-message to server.#2020-02-1016:42darwinthis is request to reload sources on init load, didn’t finish this part properly background page then replies with all recorded sources and I feed it into do-js-load#2020-02-1016:44Gleb PosobinNice.#2020-02-1016:44darwinpotential optimization would be to prune all sources with the same resource it and use only the last one#2020-02-1016:45darwinbut in this form my code does not need to understand sources structure, it just records it and replays it on init load in the same order#2020-02-1018:22darwinI have it almost working, just struggle with Error: Namespace "..." already declared.#2020-02-1018:23darwinit looks like when I load the same js source it complains and when shadow-cljs does it, it works#2020-02-1018:28Gleb PosobinWait 500ms before requesting.#2020-02-1018:28Gleb PosobinThat solved it for me.#2020-02-1018:28Gleb PosobinThis exact problem.#2020-02-1018:29darwinwow, thanks, that fixed it#2020-02-1018:43darwinthis seems to work: https://github.com/binaryage/chromex/commit/16588dc73e4f2ec65ef27ce2d6a0ecf8d5f9e59d#2020-02-1018:46darwinas I wrote above, it could be a bit smarter and filter out all repeated resources and use only the most recent one for each
#2020-02-1018:51Gleb Posobin:+1:#2020-02-1019:05darwinhere: https://github.com/binaryage/chromex/commit/f508b6e25d2be5972c22fec7f460b31036ea43d1#2020-02-1019:06darwinI’m done for now, will leave it in experimental branch for people interested in something like this#2020-02-1019:06darwinif you discovered some better way how to do this, please let me know, thanks#2020-02-1021:17thhellerI really don't quite follow anymore what you are doing here but the solution looks crazy to me. there has to be a better way.#2020-02-1021:18thhellerto recap the problem is that a content-script does not load the correct source from disk once it has been injected right?#2020-02-1021:18thhellerie. did anyone bother too look at the actual content-script.js to see if it gets updated correctly?#2020-02-1021:19darwinthe problem is that content script lifetime is dependent on the hosted page - if you refresh the page in browser, the content script’s javascript context is destroyed and new instance of content script is injected into the page - unfortunately the extension subsystem injects cached version, because extension itself wasn’t refreshed (the background page is still running and want it to stay)#2020-02-1021:20thhelleryes, that is what I meant by not loading the correct source from disk#2020-02-1021:20thhellerso it keeps the source cached somewhere#2020-02-1021:21darwinwhen you have content script injected and don’t refresh the hosting page, and when you modify sources, shadow-cljs correctly hot-reloads changes, but these changes get lost on next page refresh#2020-02-1021:21thhellerslow down for a second please ... don't bring hot reload into this#2020-02-1021:21thhelleranswer that simple question .. is the file updated on disk?#2020-02-1021:21thhellerdid anyone ever check?#2020-02-1021:21darwinyes, the file is updated on disk#2020-02-1021:22darwinwe both checked independently#2020-02-1021:22thhellerand did you try the programmatic inject?#2020-02-1021:22darwinno, that sounds like too much work, I want declarative inject to work#2020-02-1021:24darwinif I understand it correctly, I would have to implement some process watching pages being opened and inject code depending on what page is opening#2020-02-1021:25darwinthen I would probably need my content script to be single file, which would limit build config, I guess#2020-02-1021:26thhellerthe way this is currently handled is already problematic so there needs to be a better way anyways#2020-02-1021:28darwinmaybe I could put some time in and fix this in chrome itself: https://bugs.chromium.org/p/chromium/issues/detail?id=104610#c1#2020-02-1021:28darwinthe solution would be for chrome extension sub-system to watch for modified files on disk in dev mode#2020-02-1021:29thhellerit is trivial to fix this by just generating a little bit different code#2020-02-1021:29darwinhow?#2020-02-1021:30thhellerlet me try to setup a simple reproduce for this first .. I still don't quite understand what this is all about#2020-02-1021:32thhellerah right I already have this setup ... in the chrome-ext build 😛#2020-02-1021:35darwinhave a link? I could test it as well here#2020-02-1021:36thhellerin the shadow-cljs repo#2020-02-1021:36thheller:chrome-ext build was commented out#2020-02-1021:49darwinbtw. if it was too much to setup, you could follow https://github.com/binaryage/chromex/tree/master/examples/shadow#2020-02-1021:52thhellerI'm sorry but that setup is so far away from my usual setups that I cannot follow it at all#2020-02-1021:53thhellerI don't like splitting things into multiple source paths like that when one would do 😛#2020-02-1021:54thhellerthe namespaces already describe what they do perfectly fine#2020-02-1021:56darwinIMO, if you perfectly understand what your build tool does, then yes, otherwise it is just defensive stategy which won’t hurt 🙂 this layout was created by me in leiningen + cljs-build plugin times#2020-02-1022:04Gleb Posobin@thheller steps to reproduce what's not working: load your extension example in browser, open any page, "▶️❤️◀️" will be printed in the console, change that string in content.cljs, reload the page, "▶️❤️◀️" will still be printed instead of a new string.#2020-02-1022:15thhelleryeah I have that#2020-02-1022:16thhelleralready have a fix for it ... just looking for others 😛#2020-02-0921:27Ivan Kozi'm not quiet understand what am i asking, but how do i specify js deps while shadow-cljs managed by lein? webjars?#2020-02-0921:28thhellerjs deps are handled via npm, so package.json. shadow-cljs does not use/support webjars.#2020-02-0921:29Ivan Kozso for a fullstack app that will be project.clj for backend deps and project.json for front?#2020-02-0921:30thhellerjs deps are managed in package.json/npm#2020-02-0921:30thhellerCLJS deps are handled by shadow-cljs.edn or project.clj or deps.edn (whatever you chose)#2020-02-0921:31Ivan Kozalright, i'll research more on that, thank you Thomas#2020-02-1011:23ikitommiwhat docker base images are people using with shadow-cljs + deps?#2020-02-1011:23ikitommi
FROM circleci/clojure:openjdk-11-tools-deps-1.10.0.414-node
seems to be an ok start..
#2020-02-1011:47g7sAfter this commit https://github.com/thheller/shadow-cljs/commit/8a90e62c6af3ece959d39b8d26c49d3bc72159b6 my web worker explodes with Uncaught ReferenceError: window is not defined and I guess it is because it tries to load /shadow/cljs/devtools/client/browser.cljs instead of /shadow/cljs/devtools/client/worker.cljs.#2020-02-1012:05g7sMy :modules config has this form
{:base {:entries [cljs.core]}

 :mod {:entries    [my.ns]
       :depends-on #{:base}}

 :worker {:entries    [my.ns.worker]
          :depends-on #{:base}
          :web-worker true}}
#2020-02-1015:19thheller@UKQS17P3L set :devtools {:browser-inject :mod}#2020-02-1015:58souenzzoI'm also in trouble with react-native target trying to access js/document. But I downgraded fulcro with shadow-cljs at once because I run out of time (so I can't be sure about shadow-cljs or fulcro issue).#2020-02-1016:05g7s@thheller it worked, thank you! Is this documented somewhere? I am usually referencing this guide https://shadow-cljs.github.io/docs/UsersGuide.html#2020-02-1016:24thhellerno I still need to document it. I added it because previously workers didn't support hot-reload but now they do#2020-02-1016:24g7sYes I saw that 🙂 pretty nice#2020-02-1016:25thhellerthought nobody was using web workers so I didn't bother documenting it yet 😛#2020-02-1016:28g7sNo problem, shadow keeps improving and it is what matters#2020-02-1015:12Robin JakobssonDoes shadow-cljs support using locally installed folders?
npm install <folder>:

Install the package in the directory as a symlink in the current project. Its dependencies will be installed before it's linked. If <folder> sits inside the root of your project, its dependencies may be hoisted to the toplevel node_modules as they would for other types of dependencies.
#2020-02-1110:06Robin JakobssonI haven’t had any success with this so far, if anyone finds anything - please let me know 🙂#2020-02-1016:54kennyI updated to the latest shadow-cljs 2.8.83 and now I see this in the Chrome console. I assume it must be using some character that my system does not have. I'm on Ubuntu 19.10.#2020-02-1022:27thhellerthis is the char 🠶?#2020-02-1022:27kennyThat appears as a box as well.#2020-02-1022:27kenny#2020-02-1022:28thhellerhttps://www.htmlsymbols.xyz/unicode/U+1F836#2020-02-1022:28kennyA page of boxes 🙂 I guess Ubuntu 19.10 does not have that built in?#2020-02-1022:28thhellerguess not 😛#2020-02-1022:29thhelleralthough there is an ubuntu at the bottom 😛#2020-02-1022:30kennyPerhaps the default font on Ubuntu is not Ubuntu?#2020-02-1022:30kennyOh, right - this computer is PopOS which is a flavor of Ubuntu. They definitely could use a different font.#2020-02-1022:32kennyhttps://github.com/pop-os/gtk-theme#recommendations > Interface: Fira Sans Book 10#2020-02-1022:32kennyEh, I don't really mind. It just looks a bit strange.#2020-02-1022:33thhelleryeah I removed color because it was causing problems for users with dark mode themes#2020-02-1022:33thhellerstill wanted something to "stand out" ... this seemed like a "standard" unicode char#2020-02-1022:34kennyWhat's it supposed to be? I'd like to put a picture to the "rightwards finger-post arrow" hjaha#2020-02-1022:45thheller#2020-02-1022:49kennyThanks 🙂#2020-02-1017:40g7sCan i goog-define some constant in some namespace ns.a and use it in another ns.b? This doesn't seem to work if I require the ns.a from ns.b#2020-02-1017:41g7sI tried to :refer also that constant but no luck#2020-02-1018:31mazinHello. I'm attempting to use https://github.com/priornix/antizer which is a wrapper around the antd package. Antizer pulls the antd package in through cljsjs, which causes bloat in my local development environment due to the size of the antd package. My thought was to change antizer to use shadow-cljs so we can target specific elements of the package, rather than importing the whole thing. We don’t know what the user would like to import, so I’m stuck on how to conditionally require parts of antd from antizer. One way I can think to handle this is to create a different file for each Antizer import that maps directly to an antd import. Ex: antizier.Button => antd/Button and then requiring the relevent element from antizier. Another way (that I think would work?) would potentially be to keep track of each distinct element that is called in antizier and calling (require) for each. Does anyone know of a better way to handle this?#2020-02-1018:50lilactown@mazin unfortunately requires must be static, so you cannot conditionally require things in CLJS. (require) is a macro that only works in development#2020-02-1019:25darwin@thheller would you accept a PR with this? https://gist.github.com/darwin/f9e883eef4629d462edc871b6830a4d5 …so I could drop my hacked version of shadow-cljs#2020-02-1021:15thhelleryeah ok. looks simple enough.#2020-02-1021:16darwincool, thanks, will prepare the PR, this is not urgent#2020-02-1022:54thhelleradded something that'll make you happy 😉#2020-02-1022:54thhellerhttps://github.com/thheller/shadow-cljs/commit/94c99bd609bf674e24b47964d37c89e57e838414#2020-02-1022:56darwinhallelujah! thanks a lot. so the PR is no longer needed I guess 🙂#2020-02-1022:59darwinbtw. this could also solve some old issues with dirac+node.js https://github.com/binaryage/dirac/blob/master/docs/node.md#source-maps#2020-02-1023:01thhellerI only added it because it seems to be the only way to make chrome exts load source maps#2020-02-1023:02thhellerit'll probably have issues on all other targets#2020-02-1023:02darwinyep, I didn’t find any good solution either#2020-02-1023:03darwinI still think adding that :source-map-prefix could be helpful for some future ad-hoc workarounds in similar cases when I want source maps to be server independently#2020-02-1023:03darwine.g. via dev-server or elsewhere#2020-02-1023:04darwinwe don’t need to document it, it will be just hidden option for desperate people like me who go digging… ;()#2020-02-1023:04thhelleras for the other stuff one option is instead of loading the content-script file directly#2020-02-1023:05thhellerit just loads a shim that loads the real files via fetch#2020-02-1023:05darwinI tried that, but gave up, fetch part was easy, but I was running into google.provide throwing that namespaces were already declared#2020-02-1023:05thhellerthat seems to work fine but requires adding https://developer.chrome.com/extensions/manifest/web_accessible_resources which is a bit annoying#2020-02-1023:06darwinbut you have better understanding of the whole closure thing, so you probably know how to do it properly#2020-02-1023:06thhelleryeah if you try to load the files over the old ones that happens#2020-02-1023:06thhellerjust don't load them over the old ones and you are fine 😉#2020-02-1023:08darwinnevcermind, I was probably doing some other mistakes, it wasn’t clear to me how to configure the build properly, that the code I’m fetching is a module which depends on what is already present in the shim#2020-02-1023:08darwinthat was the main issue, it contained the shim bootstrap code again#2020-02-1023:08darwinand that is why it was complaining#2020-02-1023:09darwinreading that link you posted, I didn’t run into this problem#2020-02-1023:09darwinI used js/fetch to get the files from dev-server running on localhost, and it worked#2020-02-1023:10thhellerprobably because you were still accessing files from the dev server isntead of the extension#2020-02-1023:11darwinI think it would be acceptable for dev mode, to have dev-server auto-configured#2020-02-1023:11thhelleryou can chrome.runtime.getURL("out/content-script.js")#2020-02-1023:11thhellerand fetch that#2020-02-1023:11darwinor you could tunnel this stuff through shadow-cljs devtools ws connection#2020-02-1023:11thhellerI'd rather not#2020-02-1023:12darwinok, so you found a solution without relaxing manifest rules? via chrome.runtime.getURL?#2020-02-1023:12thhellerno , that way requires the manifest config#2020-02-1023:12darwinah, ok#2020-02-1023:13thhellermaybe I'll just make it talk to the shadow-cljs server.#2020-02-1023:13thhellerneed sleep, might look at it more tomorrow#2020-02-1023:13darwinsure, thanks a lot#2020-02-1021:08hoppykind of getting back into shadow - and not getting something. My intent is to package my simple cljs file into a script that I can run anywhere node runs, but I get missing dependencies at runtime.#2020-02-1021:08hoppythey only appear in any of my files thusly:#2020-02-1021:08hoppy#2020-02-1021:08hoppywhat else do I need to do to get these included in the 'release' output?#2020-02-1021:16thheller@hoppy I recommend post-processing the file with https://github.com/zeit/ncc if you want to package ALL dependencies into the file#2020-02-1021:16thhellershadow-cljs has something built-in for that but ncc is more feature complete#2020-02-1021:40hoppythat helps - note, you have to have the stuff npm installed in the working dir (apparently)#2020-02-1106:29QuestAnyone have a shadow-cljs react-native template without expo? I tried booting up https://github.com/fbielejec/shadow-cljs-react-native but on my Android VM it immediately gives the red React-Native error with Unknown at the top (from NativeRunnable.java, not very helpful)#2020-02-1109:04thheller@quest not a template but this is the last example I made using only react-native https://github.com/thheller/reagent-react-native#2020-02-1112:07Quest@thheller Thank you. I appreciate your uncanny ability to have an answer for everything. I bumped the react+native/reagent/shadow-cljs & added APK release instructions, opened PR https://github.com/thheller/reagent-react-native/pull/4#2020-02-1112:10thheller@quest are you sure its safe to update the dependencies like that without touching the react-native dir (the generated files)?#2020-02-1112:11QuestI assume they were regenerated after npm install, but I can't say for certain. The build still works after updates on my box#2020-02-1112:13Questif it's a straightforward safe path I could run the react-native init AwesomeProject and update the PR after I'm up tomorrow#2020-02-1112:14thhellershould be fine I guess. thx.#2020-02-1112:15QuestAny time. I'm going to swap in re-frame into the template tomorrow, will release an example repo for that too.#2020-02-1112:18QuestLittle bit of context: I've been working on an app from the Expo re-frame template, but hit a point where I needed to access an Android API directly. You can do this with an ejected Expo app, but you lose many of the advantages of Expo.#2020-02-1112:20QuestAnd your app exists in a sad intermediate "not react-native vanilla" and "not expo" state, so you lose all of the simplicity of Expo and accuracy of documentation for vanilla react-native.#2020-02-1114:21Ivan KozGot a json parse exception on run shadow.cljs.build-report app target/build-report.html Illegal character ((CTRL-CHAR, code 0)): only regular white space (\r, \n, \t) is allowed between tokens file: .shadow-cljs/builds/app-release-snapshot/release/shadow-js/module$node_modules$object_assign$index.js#2020-02-1114:22Ivan KozIt was working fine before. Should i clean builds folder?#2020-02-1114:26darwinlook at node_modules/object_assign/index.js with hex editor, does it contain any zero bytes?#2020-02-1114:26darwinthe file could be corrupted for some reason#2020-02-1114:27darwine.g. (I can imagine) running npm install and some other tools stepping one each other toes when updating the files#2020-02-1114:30Ivan Kozyeah https://gyazo.com/f8ccf71498d34e5dca29f9808e106c6c.png#2020-02-1114:32Ivan Kozcleared the folder, works fine now#2020-02-1114:33darwinthere is probably something fishy in your setup which could cause clobbering those files#2020-02-1114:33darwin(my wild guess)#2020-02-1114:33Ivan Kozhappened for the first time, so i have no idea#2020-02-1114:34darwindidn’t you run any background process dealing with npm modules, e.g. npm install from terminal and concruently yarn install via IDE, or something like that#2020-02-1114:36Ivan Kozi don't think so, but i had a blackout this morning, probably related#2020-02-1114:36darwincould be a network error as well, and npm happily wrote incomplete file during update, hard to say#2020-02-1114:36Ivan Kozcljsjs provide extern files for react, while shadow-cljs uses npm, should i do something extra for google closure to work properly?#2020-02-1114:37darwinI use react direcly, without cljsjs, and it works out-of-the-box#2020-02-1114:37Ivan Kozi dont quiet understand whats going on with shadow-cljs yet#2020-02-1114:39Ivan Kozis it even normal to have 120+ kb of react, i've heard it's not very keen on dead code elimination#2020-02-1114:42thhellernpm code does not run through advanced compilation, so only very basic DCE is done#2020-02-1114:42Ivan Kozhow should i done it properly?#2020-02-1114:43Ivan Kozsay i wanna use rum and react#2020-02-1114:44thhellernot sure what you are asking? react-dom stays pretty much the same size it has on npm. so yes 120+kb is normal#2020-02-1114:45Ivan Kozalright, i'm not sure what am i asking either#2020-02-1114:48Ivan Kozit will get better with time, but for now i got a lot of blanks in my js knowledge#2020-02-1115:20defaI was trying to get re-frisk-remote working for a react-native app that I build using a shadow-cljs with deps managed in a deps.edn file. Since there is no leiningen involved I’m not sure how to start the the web (i.e. lein re-frisk). So I guess I make my own ‘plugin’ for tools.deps to get an equivalent server running? Probably the wrong channel to ask, though.#2020-02-1116:43p-himikI don't have any idea about react-native, but maybe re-frame-10x would work for you?#2020-02-1116:13thhellerI don't know what re-rrisk is or why it is a lein plugin in the first place sorry#2020-02-1119:55defaIt’s a debugging tool for re-frame based applications. re-frame is based around a single central app-db and re-frisk/re-frisk-remote can be used to trace and inspect the content of this db. The leinigen plugin spins up a web-server on the dev machine to provide the UI for traceing/inspecting the remote db. https://github.com/flexsurfer/re-frisk#2020-02-1119:58defaCurrently the inspect feature of shadow-cljs comes in handy and I can tap> re-frame’s app database. I will try to find some time to make the server component of re-frisk-remote standalone so I can use it with shadow-cljs and tools.deps.#2020-02-1118:28ikitommi@mazin there is also https://gitlab.com/synqrinus/syn-antd, can just require the components what one needs.#2020-02-1217:11mazinjust now seeing this. thank you!#2020-02-1120:03g7sCan i goog-define some constant in some namespace ns.a and use it in another ns.b? This doesn't seem to work if I require the ns.a from ns.b#2020-02-1120:37thheller@g7s as far as CLJS in concerned (goog-define THING "foo") is the same as (def THING "foo"). so you'd refer to it like any other def using a/DEBUG (assuming (:require [ns.a :as a]))#2020-02-1120:52g7sThen I must have done something weird.. I will check in the morning. Thanks!#2020-02-1120:57Aleedis it possible to have shadow-cljs pickup a certain file based on its "extension"? i.e. in js you could configure webpack or metro to pick up .native or .web extensions or do you have to create completely different namespaces for each platform?#2020-02-1120:57thhellerno thats not supported. not sure why it should be though. what exactly do you want to do?#2020-02-1120:59thhellerI wrote about how I deal with platform specific code some time ago, maybe that helps https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3 ?#2020-02-1120:59Aleedi'm creating a single, cross platform app with react-native and react-native-web most of the code will be the same, but sometimes a certain file/feature will have to be different. so in js i could differentiate it simply by differretn file extensions, i.e. feature.web.js feature.ios.js and a single import statement into the app import feature from 'feature'#2020-02-1121:00thhelleryes but that would still be different files?#2020-02-1121:02Aleedyeah, different files, but one import statement - so you can create a single app rather than a native app and a web app, with shared modules#2020-02-1121:03thhellerits not documented but shadow-cljs supports aliasing namespaces#2020-02-1121:03thhellerso you can configure :build-options {:ns-aliases {some.app.feature some.app.feature-web}}#2020-02-1121:04thhellerso whenever anything tries to access some.app.feature it would end up using some.app.feature-web instead#2020-02-1121:04thhellerie (:require [some.app.feature :as x]) would actually be (:require [some.app.feature-web :as x])#2020-02-1121:05Aleedthat will definitely work, thank you would it be possible to configure a convention globally?#2020-02-1121:06thheller:build-defaults {:build-options ...} would apply it to all configured builds yes#2020-02-1121:06Aleedin webpack for example, you have a list of extensions that are picked up, i.e., extensions: ['.web.js,' '.js']#2020-02-1121:06thhellerno thats not how that works#2020-02-1121:06thhellerthey need to be actual normal namespaces#2020-02-1121:06thhellerso the code you'd write in (ns some.app.feature-web)#2020-02-1121:06Aleedyeah, i understood your aliasing example#2020-02-1121:06thhellerthere aren't two files pretending to be the same file#2020-02-1121:07thhellerand no, I do NOT recommend using this#2020-02-1121:07thhellerwrite proper software and use something like the gist I pasted before#2020-02-1121:07thhellerns-aliasing should be the absolute last resort and pretty much only used if you don't have control over the code you need to alias#2020-02-1121:08thhellerwriting interfaces with different implementations is a common software pattern. use it.#2020-02-1121:12Aleedthank you for recommendation, will read gist again and reconsider. but, from what I can tell, in both cases you're creating different implementations* based on same interface, it's just about the ease of being able to import them into single app (you let the bundler handle importing them based on some convention)#2020-02-1121:14thhelleryeah dunno I've never build a real react-native/web hybrid so no clue how well that actually works#2020-02-1123:56royalaid@thheller So I just ran into a bit of footgun for the second time and I am not sure if shadow can help with this or what your advice is BUT here is the scenario: I am setting up segment to do tracking which requires you to use their analytics.js script from the window#2020-02-1123:57royalaidso I have an object on the JS window that is called analytics#2020-02-1123:57royalaidand then without putting it together until just now I had a namespace called analytics and then a file called segment so analytics.segment#2020-02-1123:58royalaidthis of course causes problems because shadow does exactly what you tell it and tries to make a analytics object but the two are basically in a race to get to the window spot first correct?#2020-02-1123:59royalaidand the way that this manifested made me feel crazy because I kept calling functions that I knew were defined but which CLJS couldn't find because Segment's script had replaced my NS#2020-02-1202:48Ivan Kozhow to disable eval loader mode, can't find it in the user guide, asking for educational purposes i need to turn evalLoad inlining off#2020-02-1203:12Quest+ Made a plain react-native example with re-frame. Forked off thheller's reagent example. Might be handy to anyone wanting this stack without Expo. https://github.com/Quezion/re-frame-react-native#2020-02-1209:25thheller@k.i.o :devtools {:loader-mode :script} in the build config#2020-02-1209:26thheller@royalaid yeah thats a problem. if I could go back in time I'd slightly change the namespacing system in CLJS since the nested stuff actually is causing more issues than it helps with but yeah its too late for that.#2020-02-1209:56mishathis is embarrassing, but I get
Compiling ...
Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:582).
com.google.common.collect.Streams
upon shadow-cljs compile app
#2020-02-1209:57thhellerdependency conflict, most likely guava. commonly caused by datomic#2020-02-1209:57mishaI am using it with {:deps true}, and got it from the very beginning, while calling watch, but then it magically got fixed by calling compile once.#2020-02-1209:58mishaThen I npm installed firebase and it blew up again#2020-02-1209:58mishais there something I can do to find the offender?#2020-02-1209:59thhellerfor deps.edn I'm not sure, probably clj -Stree (remember to enable all aliases you might have)#2020-02-1209:59mishaplus, it sounds naive, but it is strange to me to see java dependency conflict by installing js lib#2020-02-1210:00thhellerwhich JS lib do you mean?#2020-02-1210:00mishanpm install --save firebase#2020-02-1210:00thhellerfirst time you mention firebase but it has nothing to do with this#2020-02-1210:01thhellerother than that it triggers a code path that was previously unused#2020-02-1210:01thheller(ie. shadow-cljs processing the firebase JS)#2020-02-1210:01thhellerthe dependency conflict was there before#2020-02-1210:01mishamb unrelated question: what is the best practice to keep js and java(clj) deps separated in deps.edn when using shadow?#2020-02-1210:56defaI’m using two aliases :backend and :web with almost all deps defined within the alias (`:extra-deps`) and the source directories in :extra-paths. You can put common deps or shared sources in the top level :paths and :deps. In shadow-cljs.edn :
:deps {:aliases [:web]}
works for me and plays along nicely with Cursive IDE in IntelliJ IDEA. (hint: in cursive you need to enable your aliases in the deps panel).
#2020-02-1210:02thhellerdon't use deps.edn for CLJS ...#2020-02-1210:59defaIs this a general advice? I separate clj and cljs via aliases in deps.edn and it works fine.#2020-02-1211:00thhellerso do you really separate them or do you have top-level :deps and then a :cljs alias on top that inherits all the CLJ deps?#2020-02-1211:00defaOh, while reading on you suggest the same. Sorry.#2020-02-1211:01thhellermost people have CLJ top-level deps and just :extra-deps for CLJS#2020-02-1211:01thhellerwhich leads to problems like the discussed#2020-02-1211:01defa:deps []#2020-02-1211:02defaSo no global deps, only :extra-deps in the aliases.#2020-02-1211:02thhellerdeps.edn is totally fine for CLJ/CLJS. you just have to sometimes sort out dependency conflicts#2020-02-1211:02thhellerI don't like doing that so I keep them separate and never have to worry about that#2020-02-1211:02thhellerbut yeah deps.edn is "better" for some things like gitdeps or local paths#2020-02-1211:03thhellerso there are legit use-cases where it should be used#2020-02-1211:03defaMain reason for me is that this seems to be the only way to use Cursive propperly.#2020-02-1211:03thhelleryeah that too unfortunately 😛#2020-02-1211:05defaThis way it is just convenience to have backend and frontend in one project and IDE workspace. Probably not of an issue when using emacs or vim.#2020-02-1211:06thhelleryeah I have created "fake" dependency project.clj file before that just included ALL dependencies but wasn't actually used for anything#2020-02-1211:06thhellerbut that was before Cursive supported deps.edn 😉#2020-02-1210:02mishaok, an example: how do I depend on rum then?#2020-02-1210:03thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies#2020-02-1210:03misha(I am just trying to figure out how it might be connected, e.g. via clj*c* dep)#2020-02-1210:03thheller:dependencies [[rum "whatever-version"]] in shadow-cljs.edn#2020-02-1210:04thhellerI told you how it is connected#2020-02-1210:04thhellerthat class it can't find is from guava (which is a JVM library)#2020-02-1210:04thhellerwhich is used be the closure compiler AND datomic#2020-02-1210:04mishawill rum show up in clj deps too? e.g. "for server-side rendering". or should I dep it both in shadow and in deps.edn? as rum is cljc lib#2020-02-1210:06thhelleryou can only use one. *MY* recommendation is to use shadow-cljs.edn to declare CLJS dependencies and then deps.edn or project.clj for CLJ. yes there may be some overlap and things declared in both but that is not an issue#2020-02-1210:06mishathank you#2020-02-1210:06thhellerOR you can use deps.edn with a :cljs alias and a :clj alias with a common :shared one#2020-02-1210:06thhellerbut that is a bit cumbersome to use and might not actually save you from such conflicts#2020-02-1210:07mishaso if I will not solve the dependency jvm conflict, but move all cljs deps to shadow.edn, and will not use {:deps true} - js compilation should work, right?#2020-02-1210:08thhelleryou can solve it in deps.edn but you have to find the conflict and resolve it#2020-02-1210:08thhelleras I said before if you have datomic then that is the most likely cause#2020-02-1210:09thhellerbut yes moving all your CLJS related dependencies to shadow-cljs will most likely resolve the issue#2020-02-1210:10thhellerunless you add the one that is causing the actual problem ... then you are back where you started#2020-02-1210:11thhellerI haven't used deps.edn in a while ... maybe there is some easy way to make it tell you about version conflicts#2020-02-1210:11mishaI dont have datomic there. it'd be nice to make js compilation and jvm dep conflict - 2 separate issues. so moving deps over to shadow.edn now#2020-02-1210:15thhellerI'd at least try running clj -Stree once and see which guava version you get and from what#2020-02-1210:15thhellerthat'll probably be enough#2020-02-1210:15thhellerbut yeah I recommend shadow-cljs.edn so you don't have to worry about that at all#2020-02-1210:22mishaok, moving dependencies worked. so I can take care of conflict a bit later. Thank you again.#2020-02-1217:04p-himikThe example at https://github.com/highcharts/highcharts-react#example-with-custom-chart-component uses this:
import Highcharts from 'highcharts/highstock'
I can confirm that it's working at https://stackblitz.com/edit/react-4ded5d?file=index.js (at least, in Firefox). The table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages says that anything that looks like import defaultExport from "module-name"; should be written as (:require ["module-name" :default defaultExport]). I required this:
["highcharts/highstock" :as Highcharts-as]
["highcharts/highstock" :default Highcharts-default]
In runtime, Highcharts-as is the desired object, and Highcharts-default is undefined. Any idea why is there a discrepancy for this particular module?
#2020-02-1217:04lilactownit depends on whether the JS lib that gets loaded is CJS or ESM#2020-02-1217:04thhellerread the section about default https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2020-02-1217:09p-himikDo you think it makes sense to add a * to that table? Otherwise, it's not that clear that there are exceptions if you don't read further since the table appears like the ultimate authority.#2020-02-1217:11thhellerI don't know. many packages actually package code properly so that :default works even for CommonJS packages#2020-02-1217:11thhellersome don't ...#2020-02-1217:15p-himikFWIW, I would add a * or some other indication that a user should read further about :default in particular. :) Seems like I'm not the only one that doesn't read/remember everything, given the question about Highcharts in #clojurescript#2020-02-1316:00NiclasIs it possible to connect multiple clients to the nREPL server and “broadcast” REPL commands to all connected clients?#2020-02-1316:13dpsuttonhttps://github.com/clojure/tools.nrepl/wiki/Extensions check concerto. no idea if up to date and maintained#2020-02-1316:13dpsuttonoh, just saw this is in shadow. no idea then 🙂#2020-02-1316:17haywood👋:skin-tone-2: Does shadow not support importing node packages like ["@elastic/eui" :as eui]?#2020-02-1316:18haywoodI’m not sure what’s up with that @#2020-02-1316:24haywoodah, scoped packages#2020-02-1316:27haywood> sometimes people mistakenly think that `(:require ["foo/bar" :as x])` is something `shadow-cljs` specific when it is absolutely not #2020-02-1316:40thheller@haywood sure thats supported just fine#2020-02-1316:41haywoodyea that’s what I figured… gotta double check all of the variables#2020-02-1321:25p-himikOh. Wow. I think I just got some gray hair trying to understand what's going on. I have a project reagent-playground with a bunch of sources:
;; a.cljs
(ns reagent-playground.a
  (:require [reagent-playground.b :refer [f] :rename {f b-f}]))

(defn f [])

(js/console.log "A F" f)

;; b.cljs
(ns reagent-playground.b)

(defn f [])

;; core.cljs
(ns reagent-playground.core
  (:require [reagent-playground.a :as a]))

(js/console.log "A F2" a/f)
The JS console output is:
a.cljs:6 A F fnreagent-playground$a$f[]
core.cljs:5 A F2 undefined
#2020-02-1321:26p-himikSo a/f works inside a, but outside suddenly becomes undefined. It can be fixed by not requiring that b namespace along with :rename.#2020-02-1321:33thhellerlooks like a bug#2020-02-1522:34p-himikLet me know if you need any additional information.#2020-02-1523:31thhellerfeel free to open an issue otherwise this will get lost. I can at least confirm if its something shadow-cljs does or CLJS specific#2020-02-1607:32p-himikSure, done: https://github.com/thheller/shadow-cljs/issues/653#2020-02-1414:16robert-stuttafordis there a way to watch a release build? debugging advanced-comp issues#2020-02-1414:18robert-stuttafordi guess by putting :optimizations  `:advanced` on the dev build#2020-02-1415:39teodorluWould using an external tool like entr work for you?
find src | entr shadow-cljs ...
http://entrproject.org
#2020-02-1415:40teodorluThat way you don't expose yourself to any differences in behavior between running a "normal invocation" and a "partial reload" of sorts#2020-02-1417:00martinklepschAfter nuking node_modules to test some stuff I’m stuck with some shadow-cljs - failed to load errors. package.json and package-lock.json are the same so I’m a little confused what could be causing this.#2020-02-1418:20thhellerwhat kind of failed to load? there is some weird behavior if you delete too many node_modules files while a watch is running. it may not fully recover from that an may require a resatrt#2020-02-1418:26martinklepsch
module$node_modules$$firebase$firestore$dist$index_cjs
components.home.js TypeError: client.util.adapt_class is not a function
client.util.js TypeError: firebase.INTERNAL.registerComponent is not a function
#2020-02-1418:27martinklepschI did restart the build multiple times#2020-02-1418:17thheller@robert-stuttaford :optimizations does not apply to watch builds as it always forces :none. for debugging I suggest running shadow-cljs server and then shadow-cljs release app --pseudo-names or --debug whenever you make a change#2020-02-1418:18thhellerthat way you get reasonable fast feedback without waiting for shadow-cljs startup#2020-02-1418:18robert-stuttafordthank you, i'll do that#2020-02-1418:18Derekgit ls-files | entr shadow-cljs release app --psuedo-names#2020-02-1418:18robert-stuttafordit ended up being pretty fast without server anyway 😂#2020-02-1418:18Derekmight work for you with a server running#2020-02-1505:04robert-stuttafordis it possible to change the red colour that shadow prints in a cider emacs buffer to something else?#2020-02-1515:49p-himikIt seems that source maps are not used by the browser if I create a release build with :compiler-options {:source-map true}. Meanwhile, they are used with watch. Did I not add some flag?#2020-02-1515:56Ivan KozIf anybody using shadow-cljs with the Cursive, how do you connect to cljs watcher repl? Currently i'm calling (shadow.cljs.devtools.api/repl :app) manually, any better way to do it?#2020-02-1515:58thheller@robert-stuttaford color should be disabled if you are connected over nrepl? otherwise you may (alter-var-root! shadow.build.warnings/*color* (constantly false)).#2020-02-1608:32robert-stuttafordseems it's not the warnings, but the top-level status#2020-02-1608:32robert-stuttaford#2020-02-1608:33robert-stuttafordi tried the alter-var-root, it had no effect#2020-02-1608:33robert-stuttafordi'm using cider-connect-clj&cljs to connect to shadow's nrepl service#2020-02-1608:35thhelleruhm yeah that is not shadow-cljs making that red#2020-02-1608:35thhellerthat is never red#2020-02-1609:57robert-stuttafordok, thanks! i'll dig in cider!
#2020-02-1515:58thheller@p-himik should work fine? what do you mean by "not used"?#2020-02-1516:00p-himikIf I use shadow-cljs watch and trigger an exception in the browser, the stacktrace shows correct CLJS files, and I can open them in the browser. If I use shadow-cljs release, the stacktrace shows minified files. Of course, I cannot use shadow-cljs built-in debug server for this (I think), so I use python -m http.server in the directory with index.html.#2020-02-1516:01thhellerall that matters is that the .map file is created and that the .js file has a //# sourceMappingUrl ... at the bottom#2020-02-1516:01thhellerbeyond that I don't what would be different#2020-02-1516:02p-himikYes, the .map is there. And the sourceMappingUrl is there as well. In fact, the Python server shows that the source map is downloaded by the browser. But it's not used for some reason.#2020-02-1516:03thhellerin the chrome devtools sources tab#2020-02-1516:03thhellerit should show the original sources somewhere?#2020-02-1516:05thhellermaybe you are somewhere in the code it can't map. don't really know what you are doing#2020-02-1516:05thhellernormally source map coverage should be pretty good though#2020-02-1516:08p-himikYes, Chrome shows the CLJS sources there. I just throw an error when I click a button. With the release build, it results in this in the JS console:
Uncaught Error: Button clicked
    at main.js:593
    at Object.da (react-dom.production.min.js:17)
    at Oa (react-dom.production.min.js:18)
    at ub (react-dom.production.min.js:18)
    at wa (react-dom.production.min.js:18)
    at vb (react-dom.production.min.js:20)
    at O (react-dom.production.min.js:20)
    at P (react-dom.production.min.js:20)
    at Mi (react-dom.production.min.js:82)
    at ig (react-dom.production.min.js:289)
With the debug build, it results in the correct core.cljs file being mentioned with the correct line.
#2020-02-1516:10p-himikThe app itself is the smallest one created from https://github.com/shadow-cljs/lein-template/tree/master/resources/leiningen/new/shadow_cljs that uses the latest version of shadow-cljs and updated React stuff.#2020-02-1517:15p-himikAnd I'm pretty sure that the source map itself is just fine because: 1. There's no warning about it being malformed 2. I can see the original CLJS files in DevTools but I don't see any requests for them Do you have any idea why the source map is still not used for the stacktraces? Do you need anything from me to aid you?#2020-02-1517:24thhellerI really can't do anything if the trace is that deep in react#2020-02-1517:24thhellerin release the minified react version is used. react doesn't ship source maps so there is no possibility of mapping it back#2020-02-1517:28p-himikBut how would React affect my source code? I just removed React from the equation by just throwing an exception straight in the start function - same deal.#2020-02-1517:28p-himik#2020-02-1517:30p-himikNotice how it says main.js in the exception printout.#2020-02-1518:02thhellerah yeah I can explain that#2020-02-1518:02thhellerbut that has nothing to do with your actual error ...#2020-02-1518:02thhellerI'm assuming you are calling the init via :init-fn#2020-02-1518:02thhellerthat call itself has no source map#2020-02-1518:03thhellerand closure inlines it so init no longer exists and just directly throws at the top level#2020-02-1518:06p-himikAnd yet again, it's not that. :(
<script>reagent_playground.core.init();</script>
#2020-02-1518:06p-himikIt's still that example from your repo. :)#2020-02-1519:07thhellerI'm not sure what you are aftter#2020-02-1519:08thhellerthe init-fn call NEVER has source maps#2020-02-1519:08thhellerand if init just calls start then closure will inline that so there no longer is a start#2020-02-1519:08thhellerand adding an exported function really doesn't matter there at all#2020-02-1519:10p-himikI do not use init-fn.#2020-02-1519:11p-himikThat script tag above works. Meaning, the ^:export works. Meaning, the core/init function is not inlined anywhere.#2020-02-1519:11thhelleryes it is#2020-02-1519:12p-himikThen how is it being called from the HTML file?#2020-02-1519:12thhelleryou are misunderstanding how this works. look at the bottom of the JS file how exports are created#2020-02-1519:13thhellerbasically it'll have inline the body of start into init#2020-02-1519:13thhellerand then bound the resulting funciton to the "exported" name#2020-02-1519:15p-himikI have replaced (start) with just the exception. This is what I have in CLJS:
(defn ^:export init []
  (throw (js/Error. "Hi there")))
And this is what it ends up as in the compiled JS:
function Xf() {
    throw Error("Hi there");
}
#2020-02-1519:16thhellerwhat exactly are you looking for? that react error from previously isn't anywhere near what you are looking at now#2020-02-1519:18p-himikBut that's the whole problem, there's nothing I haven't described. I have the above code. In the debug mode, DevTools matches it with the source map. In the release mode, it does not - that is the problem.#2020-02-1519:44thhellerno your example is too simplistic#2020-02-1519:45thhellerdo something that actually survives advanced optimizations and isn't inlined#2020-02-1519:48thhelleralso don't throw in init ...#2020-02-1519:48thhellereven a setTimeout helps#2020-02-1519:57p-himikThe exact same issue with setTimeout.#2020-02-1520:06thhellerdo more stuff .. thats all I can say. add an event listener to body that after the fifth click throws or something#2020-02-1520:06thhellersomething that actually involves running code that is NOT react and NOT in init#2020-02-1520:12p-himikThat worked. Well, to some extent - it said that I had an error somewhere deep in cljs.core. But that's definitely not the case.#2020-02-1520:13p-himikThe code:
(defn do-bad-stuff [stuff]
  (throw (js/Error. stuff)))

(defn ^:export init []
  (.setTimeout js/window #(do-bad-stuff "From setTimeout 0") 0)
  (.setTimeout js/window #(do-bad-stuff "From setTimeout 100") 100))
#2020-02-1520:34thhellerbut still inlined 😛#2020-02-1520:35p-himikGod dammit... :)#2020-02-1520:37thhellereasy way to escape inline is multi methods 😛#2020-02-1520:38p-himikOr self-referencing, it seems.#2020-02-1520:39p-himikSo now I have this
(defn do-bad-stuff [delay]
  (.setTimeout js/window #(do-bad-stuff (+ delay 1000)) delay)
  (throw (js/Error. delay)))

(defn ^:export init []
  (do-bad-stuff 0))
compiled as this
var ca = function ca(a) {
    window.setTimeout(function () {
        var c = a + 1E3;
        return ca.a ? ca.a(c) : ca.call(null, c)
    }, a);
    throw Error(a);
};

function ia() {
    return ca(0)
}
and outputting this
Uncaught Error: 0
    at ca (main.js:4821)
    at Object.ia [as init] (main.js:4825)
    at (index):14
So it somehow became worse.
#2020-02-1520:51thhelleruhm thats still throwing in init ...#2020-02-1520:55p-himikThe subsequent throws that happen asynchronously have the exact same message.#2020-02-1520:58p-himikA new iteration:
(defn do-bad-stuff [delay]
  (.setTimeout js/window
               (fn []
                 (do-bad-stuff (+ delay 1000))
                 (throw (js/Error. delay)))
               delay))

(defn ^:export init []
  (do-bad-stuff 0))
var ca = function ca(a) {
    return window.setTimeout(function () {
        var c = a + 1E3;
        ca.a ? ca.a(c) : ca.call(null, c);
        throw Error(a);
    }, a)
};

function ia() {
    return ca(0)
}
Uncaught Error: 0
    at core.cljs:10374
#2020-02-1520:59p-himikSo: - Not inlined - Not throwing in init - Still wrong location#2020-02-1515:59thheller@k.i.o that is currently the only way. you can create a custom REPL command and bind it to a key to make it "easier"#2020-02-1515:59Ivan Kozgood idea, ty#2020-02-1516:18Ivan Kozcan shadow-cljs refresh page, reconnect when connection was closed?#2020-02-1516:18thhellerno?#2020-02-1516:18Ivan Kozalright#2020-02-1518:33Wilson VelezHi, I’m implementing a reframe app with highcharts.js, one the options the library has is to show a message when there are no data to draw, https://api.highcharts.com/highcharts/noData, but for it to works it need to include a js file, the file is inside the npm module (highcharts/modules/no-data-to-display.js), righ now I’m requiring
["highcharts/highstock" :as Highcharts]
["highcharts-react-official" :default HighchartsReact]
and it works fine, but without the no data label, how should I include this file?
#2020-02-1518:36Wilson Velezwhen I include the name as
["highcharts/module/no-data-to-display"]
I get > Compilation failed! > The required JS dependency “highcharts/module/no-data-to-display” is not available, it was required by “fund_performance/stockchart.cljs”. > > Search in: > /Users/wvelezva/dev/workspace/fund-performance/node_modules > You probably need to run: > npm install highcharts/module/no-data-to-display > > See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install
#2020-02-1518:38p-himikYou have a typo, it should be "modules".#2020-02-1518:45Wilson Velezthanks, now I don’t have the message but it doesn’t show the no data message#2020-02-1518:46Wilson Velezso, the way I’m including the file is fine?#2020-02-1518:50p-himikSince it doesn't complain anymore, it should be fine, yes. > The actual text to display is set in the lang.noData option Did you set the option?#2020-02-1518:56Wilson Velezthis is all the configuration I’m using
{:credits {:enabled false}
   :title ""
   :rangeSelector {:buttonPosition {:x -200}} ;;to hide the zoom buttons but letting the input dates visible
   :legend {:enabled true}
   :lang {:noData "There are no data to display or there are any Fund Selected"}
   :noData {:style {:fontWeight "bold"
                    :fontSize "15px"
                    :color "#303030"}}
   :plotOptions {:series {:showInLegend true
                          :events {:click #(.log js/console (str "p= " (.. % -point -x) " sn=" (.. % -point -series -name)))}}}
   :tooltip {:pointFormat "{series.name}: <b>{point.y:.1f}%</b>"}
   :series [{:type "line"
             :name "Random data"
             :data []}]}
#2020-02-1518:56Wilson Velez
:lang {:noData "There are no data to display or there are any Fund Selected"}
#2020-02-1518:59p-himikNo idea. If you convert this structure to JS recursively (i.e. with something like clj->js), then it looks fine to me. Does your data work in a pure JS environment?#2020-02-1715:00Wilson VelezHi @p-himik, sorry for the delay (family calls) 🙂, and thanks for your help, I created this fiddle, locally it also works https://jsfiddle.net/ju5oqme3/#2020-02-1715:01p-himik> locally it also works You mean, you got it working after all, so the case is closed?#2020-02-1715:10Wilson Velezno, plain js works#2020-02-1715:15p-himikCan you create a CLJS project on GitHub that has everything that you need and that looks just like that JS that works? So I could check it out and maybe see what's wrong.#2020-02-1715:19Wilson VelezI don’t want to abuse your help, I hope this isn’t too much trouble for you#2020-02-1715:50p-himikThat's why I don't try to create the project myself. :)#2020-02-1715:50p-himikBut if you create it, I can look.#2020-02-1716:27Wilson Velezhttps://github.com/wvelezva/highchart-cljs#2020-02-1716:27Wilson Velezsorry it take me too long, I’m not used to work with github#2020-02-1716:30p-himikDon't sweat it, I'm not just sitting and waiting. :)#2020-02-1716:33p-himikAn advice about Git - don't push before you check the contents of the commits. If you seen something out of place (like committed compiler cache), just amend the required commit, maybe with interactive rebase. And only then push. This way, it won't end up in the history. Right now, for example, Git had to download almost 10k files because of this. But the actual source code is just a few.#2020-02-1716:39Wilson Velezyes, I know, my bad#2020-02-1717:00p-himikGot it working.#2020-02-1717:01Wilson Velezwow#2020-02-1717:02Wilson Velezwhat was my problem?#2020-02-1717:02p-himikI figured it out from the source code of the no-data module, but turns out that there's also documentation for this: https://github.com/highcharts/highcharts#load-highcharts-as-a-commonjs-module#2020-02-1717:02p-himikNotice how they load modules.#2020-02-1717:03p-himikIt's not just a require or import. The also call the imported function on the Highcharts object.#2020-02-1717:05p-himikYou just need the replace the no-data require with this: ["highcharts/modules/no-data-to-display" :as no-data-module] And call (no-data-module Highcharts) somewhere at the top level or in init.#2020-02-1717:05Wilson Velezyes, I noticed that but it was complete “chinese” to me#2020-02-1717:06Wilson VelezI really know very little about modules, commonjs and the others#2020-02-1717:06Wilson VelezI didn’t know it was a function I thought it was some kind of import#2020-02-1717:07p-himikHeh, yeah, the proliferation of the ways to require JS stuff in the JS world makes it a swamp I dare not to venture into. That's why most of the time I just look at the compiled output and try to understand what's going on, while also debugging it in the browser.#2020-02-1717:10Wilson VelezI don’t know how to thank you!#2020-02-1717:11p-himikNo problem. :)#2020-02-1717:11Wilson Velezso this line makes two things
require('highcharts/modules/exporting')(Highcharts)
#2020-02-1717:11Wilson Velezone is the require#2020-02-1717:12Wilson Velezthe other is call the “module” function over the Highchart object#2020-02-1717:12p-himikYep.#2020-02-1717:12Wilson Velezmodule being, exporting or no-display-to-data in my case#2020-02-1606:09Gleb PosobinHow do I set web-accessible-resources with shadow for chrome-extension target? I want to include a content script css file. https://stackoverflow.com/questions/11553600/how-to-inject-css-using-content-script-file-in-chrome-extension#2020-02-1608:36thhelleryou put it into the manifest?#2020-02-1615:05Gleb PosobinWow, that worked, thank you.#2020-02-1807:45rberger@UQ4RJ22EA Im having the same problem and I tried putting it into the manifest.edn but it didn't work. The manifext.json was malformed I had tried:
:content-scripts [{:css ["re-frame-modal.css"]}]
and
:content-scripts {:css ["re-frame-modal.css"]}
neither produced manifest.json that was accepted by chrome extension loading. I could manually set the manifest.json and that would work. Could you show me what you put in the manifest.edn to get the css file to be accepted? Thanks
#2020-02-1817:54Gleb Posobin
:web-accessible-resources ["assets/content-style.css"]
:content-scripts [{:css ["assets/content-style.css"] :matches ["<all_urls>"]}]
#2020-02-2022:03rbergerThank you that worked great!#2020-02-1613:59joshkhhas anyone had success importing react-dnd? https://github.com/react-dnd/react-dnd my build fails when i require the necessary packages
["react-dnd" :refer [DragDropContext DropTarget DragSource DragLayer]]
with the following build failure
[:app] Build failure:
The required JS dependency "domain" is not available, it was required by "node_modules/@react-dnd/asap/dist/cjs/node/raw.js".

Search in:
	/Users/josh/src/rodeorockstar/genpoetry/node_modules
You probably need to run:
  npm install domain
i've also manually added domain yarn add domain and tried to require it directly with the same error message as above
#2020-02-1615:55thheller@joshkh you need to install shadow-cljs in the project#2020-02-1616:04joshkhnot sure how i missed that. thanks @thheller, that did the trick#2020-02-1619:04thosmosI just started getting an error about a CLJC file not finding itself to import macros from:
Failed reading cache for theta.log: failed to require macro-ns "theta.log", it was required by "theta.log"
The file is like:
(ns theta.log
  #?(:cljs (:require-macros [theta.log]))
This just started. Is this a cache problem?
#2020-02-1619:07thosmosoh, removing the caches helped uncover an error in a macro that was hidden by the cache fail error#2020-02-1704:34Gleb PosobinIs there a way to specify the name of the :chrome/single-file output? I want several files, each for a different extension page.#2020-02-1718:58dpsuttonjust made a clone of enjoyingthe.show a webapp that uses faceapi.js to do facial analysis. Got the code here if anyone wants to see the example: https://github.com/dpsutton/howamidoing-cljs#2020-02-1720:06neupshHi, fyi: The link for "enjoyingthe.show" in the readme is invalid#2020-02-1720:19dpsuttonthanks! updated#2020-02-1720:34dpsuttonhttps://wizardly-hugle-4d6f4b.netlify.com/#2020-02-1719:25Aleeddoes the :web-worker configuration work for node_modules? (I have a package that expected me to configure a worker loader w webpack so wondering if that's possible with shadow-cljs)#2020-02-1720:39dpsuttoni made a project using the latest core.async. On page reload and shutting down the server it would throw async errors from shadow's tooling. Is this a known issue or should i raise a new one (i know conflicts in versions in tooling versus app are never fun 😞 )#2020-02-1721:09martinklepschI’m writing some async tests and whenever there’s an unhandled promise rejection crashing the script I’d expect the script to return a non-zero status code. It seems that the script returns 0 though. This is on node.#2020-02-1721:10martinklepschHere’s a test that demonstrates what I mean
(deftest failing-async-test
  (t/async done
           (let [e (ex-info "foo" {})
                 p1 (p/promise e)]
             (p/catch p1 (fn [x]
                           (t/is (= :a x))
                           (throw (ex-info "test" {}))
                           (done))))))
#2020-02-1721:57thheller@martinklepsch dunno about the exit code but shadow-cljs does nothing to the node process regarding uncaught exceptions. you need to set that up yourself.#2020-02-1721:57thhellersee https://nodejs.org/api/process.html#process_event_unhandledrejection#2020-02-1721:58thheller@dpsutton "page reload and shutting down the server". how are those two things related?#2020-02-1722:00dpsuttonnot related. a page refresh triggers
Exception in thread "async-dispatch-4" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
	at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
	at shadow.undertow$fn$reify__15877$fn__15997.invoke(undertow.clj:322)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:748)
[:app] Compiling ...
[:app] Build completed. (1064 files, 1 compiled, 0 warnings, 6.11s)
^CRunning shutdown hook.
shutting down ...
#2020-02-1722:01dpsuttonand control-c on the command line to kill the server yeilds
#2020-02-1722:01dpsutton
Exception in thread "async-dispatch-2" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
	at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2931.invoke(ioc_macros.clj:991)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__680.invoke(channels.clj:265)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "async-dispatch-5" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
	at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:984)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__2931.invoke(ioc_macros.clj:991)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__680.invoke(channels.clj:265)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:748)
#2020-02-1722:01dpsuttonbut 5 of those#2020-02-1722:05thhellerstrange#2020-02-1722:05thhellerdid you require :reload or something while the watch was running?#2020-02-1722:06dpsuttonnope#2020-02-1722:06thhellercan't tell what code that relates to#2020-02-1722:06dpsuttonhttps://github.com/dpsutton/async-bug#2020-02-1722:07dpsuttonminimal repo. all that's important is the project requires newest async#2020-02-1722:07thhellerah#2020-02-1722:07thhellertry setting :aot false in the shadow-cljs.edn?#2020-02-1722:08dpsuttonbuild or toplevel?#2020-02-1722:08thhellerthere is another AOT compiled core.async version included otherwise#2020-02-1722:08thhellertop level#2020-02-1722:09dpsuttonthat seems to fix it. yes#2020-02-1722:09dpsuttonwant me to create an issue?#2020-02-1722:11dpsuttonor have i missed some documentation somewhere?#2020-02-1810:04thhellerI'll just bump the core.async version in the next release. dunno why it messes with AOT.#2020-02-1721:59thheller@alidcastano no, that doesn't work. no idea what webpack needs but :web-worker is intended for standalone use only (no further processing)#2020-02-1808:59simongrayEvery time I run shadow-cljs watch app unit-tests I get these warnings in the JS console:
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
...
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
The same problem was there before I made the unit-tests build, so I’m wondering why this even shows up. There is otherwise no mention of devtools in my setup. shadow-cljs.edn:
{:deps     {:aliases [:shadow-cljs :testing]}
 :dev-http {8000 "classpath:public"}
 :nrepl    {:port    9000
            :init-ns dev}
 :builds   {:app        {:target     :browser
                         :output-dir "resources/public/js/compiled"
                         :asset-path "js"
                         :modules    {:main {:init-fn user/start-dev}}}
            :unit-tests {:target   :browser-test
                         :test-dir "resources/public/js/test"
                         :devtools {:http-port 8001
                                    :http-root "resources/public/js/test"}}}}
deps.edn
{:paths   ["src" "resources"]
 :deps    {org.clojure/clojurescript {:mvn/version "1.10.597"}
           reagent                   {:mvn/version "0.9.1"}
           hickory                   {:mvn/version "0.7.1"}}
 :aliases {:testing     {:extra-paths ["test"]}
           :shadow-cljs {:extra-paths ["dev/src"]
                         :extra-deps  {thheller/shadow-cljs {:mvn/version "2.8.83"}}}}}
#2020-02-1809:05simongrayRemoving the portion with :devtools in shadow-cljs.edn or simply only running the app build, just breaks the unit-tests build and doesn’t mute the warnings anyway.#2020-02-1809:06simongrayThere is one more piece of information which is that I tried to set up a binaryage/devtools preload at some point, but didn’t commit to it and removed it again. I can’t remember if this issue was present before then or not, but is it possible that shadow-cljs has cached something along the way there?#2020-02-1809:54thheller@simongray looks like your paths are incorrect? you have :output-dir "resources/public/js/compiled" and classpath:public meaning that the files are accessed via /js/compiled/... but you have :asset-path "js" which likely should be /js/compiled if you have any kind of client side routing#2020-02-1810:15simongrayThank you!! 🙂 Changing it to
:asset-path "/js/compiled"
did the trick
#2020-02-1814:20paul ai'm trying to require some CLJC macros in my browser-targeting CLJS tests so that i can run some hacky code at compile time. i'm using shadow-cljs for my test builds, and i'm getting a build error without a stack trace; it just says Error in phase :compilation.#2020-02-1814:24paul aah, i found this post. i'll try reading this first: https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-02-1814:41paul aokay, so i'm trying that, and i'm still getting the same error...#2020-02-1815:44knubiedo source maps work with exceptions on react native? They seem to work with console logging, but not for stack traces#2020-02-1817:26jjttjjnot positive if this is a problem I'm having with shadow, but when using :deps true in shaodow, are there any issues with using local dependencies using :local/root ? It seems to not be recognizing macro namepsaces in the local dependencies#2020-02-1817:31thhellerlike what?#2020-02-1817:31thhellershould work fine#2020-02-1817:34jjttjjNevermind sorr#2020-02-1817:35jjttjjit seems an extenal thing I was using was using refer instead of refer-macros#2020-02-1817:35jjttjjshadow has no special behavior relating to the refering of macros right?#2020-02-1819:52thhellernot sure what you mean#2020-02-1901:05paul ai'm still having a hard time understanding what i need to do to define a macro and use it in my CLJS code at compile time. i read the blog post that i found, but i'm still getting the same Error in phase :compilation error, without a stacktrace.#2020-02-1901:07paul ait feels like the closest i've gotten is an error along the lines of "proj/ns.clj" was found on the classpath. Should this be a .cljs file?#2020-02-1901:08paul ai'm using the latest version of shadow-cljs and 1.10.x of CLJS.#2020-02-1901:15paul aotherwise, my shadow-cljs compilation output is just:
shadow-cljs - connected to server
[:test] Compiling ...
------ ERROR -------------------------------------------------------------------
 File: /path/to/frontend_test.cljs
Error in phase :compilation

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
#2020-02-1902:31QuestHas anyone had any luck getting private Maven repos to work in shadow-cljs? Latest I can find 2018 -- theller notes that it might work, but doesn't seem like anyone has figured out how. I'll just use deps.edn as a workaround, but curious if anyone did figure this out#2020-02-1902:31Quest(pertinent Slack log: https://clojurians-log.clojureverse.org/shadow-cljs/2018-02-27 )#2020-02-1920:30justinbarclayJust an update, weeks ago (so long ago the thread is gone) I reported a problem I ran into when running shadow-cljs on windows 10 and WSL2. Specifically, WSL2 has a problem right now where it doesn't properly bind the ipv6 address`::1` correctly. What this meant was that I couldn't connect to a shadow-cljs dev server through services like Anyways, it took me until today to find find an excuse to dig into this during work hours. But I found out that Java uses ipv6 by default and converts ipv4 addresses to their ipv6 equivalents. Ex 0.0.0.0 -> ::1 So if you're like me and need to force shadow-cljs to use an ipv4 binding you can set it as an option in env vars export _JAVA_OPTIONS="-.preferIPv4Stack=true" https://superuser.com/questions/453298/how-to-force-java-to-use-ipv4-instead-ipv6#2020-02-1921:00thhellerinteresting. you can also set :jvm-opts ["-.preferIPv4Stack=true"] in shadow-cljs.edn (or deps.edn/project.clj)#2020-02-1921:16justinbarclayInteresting isn't the term I'd use 😅. But that is a great alternative to using an env var, thanks for pointing that out 🙂#2020-02-1921:19thhellerhow is wsl2 otherwise? I'm hesitant to use it because of the "beta" windows and stuff#2020-02-1921:55gerredi'm using wsl2 with vscode remote through wsl2 for fun#2020-02-1921:55gerredit's fantastic.#2020-02-1921:55gerredit almost competes with my mbp 🙂#2020-02-1922:00justinbarclayYeah, I was hesitant on the beta problems as well. Which on the "fast ring", there have been several that have been several bugs that have bit me. However, the file system performance is leagues ahead of WSL1. The file system changes are particularly what has driven me to use WSL2, IE using git (and Magit) feel so much nicer on WSL2 than it ever did on WSL1. It's easy to dip your toes into WSL2 as well just fire up a second distro/image and set it to version two, no need to sacrifice your main dev environment.#2020-02-1922:07justinbarclayI think you could also export your current WSL dev environment, import it under a new name and set it to WSL2. In effect, copying your current set-up and seeing how it performs under WSL2.#2020-02-1922:08gerredneed to figure out REBL with X410 though#2020-02-1922:14thhellerhmm I guess I'll wait 😛#2020-02-1922:14thhellerfs performance is pretty much the only thing I really care about#2020-02-1922:50azHi, I’m trying to create a tiny browser editor that users can create a snippet of clojure -> send to the compiler -> compile and then insert back to the browser where it’s live and callable. Any thoughts on how to approach this?#2020-02-1922:51lilactownI would use bootstrapped clojurescript, rather than sending to a remote compiler#2020-02-1922:58azThanks so much!#2020-02-1922:51lilactownhere’s a blog post that might help getting you started: https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2020-02-1923:16dpsuttoni made it private but its quite easy to get codemirror running with shadow to have a nice cljs editing experience
(ns editor.main
  (:require [reagent.core :as r]
            [clojure.string :as str]
            ["codemirror" :as codemirror]
            ["codemirror/mode/clojure/clojure"]
            ["codemirror/addon/edit/matchbrackets"]
            ["codemirror/addon/hint/show-hint"]
            [shadow.resource :as rc]
            [cljs.reader :as edn]))
#2020-02-2006:20JHello 🙂 Does anyone try to use @material-ui/icons ? I have a weird error when I import:
["@material-ui/icons/Menu" :default menu-icon]  => Module not provided: module$node_modules$$material_ui$icons$Menu
The module exists on path node_modules/@material-ui/icons/Menu.js
#2020-02-2011:25aisamuThis looks OK. Is this the only icon that fails? I'd check your version of @material-ui/icons - you have to import it separately#2020-02-2115:06JYes @material-ui/icons is imported separately. Works with @material-ui/icons/esm/Menu#2020-02-2017:54paul aregarding my issue from a few days ago where i was getting compilation errors without a stack trace, it seems to have been because i was trying to inline in my CLJS file a weird Java object via a clojure macro. :shrug:#2020-02-2017:55paul athat said, i'm inlining over 4 MB of data...#2020-02-2017:59thhellereek don't do that 😛#2020-02-2020:21preI've used shadow-cljs before successfully. However a new project template with a reagent and a lein based project.clj deps, is throwing the following error on shadow-cljs watch: How do I debug this?
$ shadow-cljs watch app
shadow-cljs - config: /home/.../shadow-cljs.edn  cli version: 2.8.83  node: v12.3.1
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch appshadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:69:5).
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7115)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7095)
	at clojure.lang.Compiler.analyze(Compiler.java:6789)
	at clojure.lang.Compiler.analyze(Compiler.java:6745)
	at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3888)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7109)
    ...
    ...
Caused by: java.lang.NoSuchFieldException: getRegisteredGroups
	at java.base/java.lang.Class.getField(Class.java:1999)
	at clojure.lang.Compiler$StaticFieldExpr.<init>(Compiler.java:1284)
	at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:1006)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7107)
	... 188 more
#2020-02-2020:39lilactown@pri https://github.com/thheller/shadow-cljs/issues/488 seems relevant#2020-02-2020:40lilactownthe versions in the solution might be out of date, but the general advice is still good: make sure that you’re specifying the same clojurescript, closure-compiler-unshaded and google-closure-library versions as shadow-cljs#2020-02-2020:41thhelleryes that is caused be a conflicting closure-compiler version#2020-02-2021:05prethanks @lilactown @thheller. How do you expect future users of shadow, using future versions of cljs and lein would not run into this issue?#2020-02-2021:12thhellerI always recommend people use shadow-cljs.edn for dependencies .. then you don't have to worry about such things#2020-02-2021:13thhellerif you use lein then you must deal with conflicts .. that is your choice#2020-02-2021:13thhellerbut you really don't have to do much to sort it out in lein ... just figure out where you conflicts are coming from and fix them#2020-02-2021:13prethe following seems to be a better, fool proof way, to avoid future conflicts.
[org.clojure/clojurescript "1.10.597"
    :exclusions [com.google.javascript/closure-compiler-unshaded
                 org.clojure/google-closure-library
                 org.clojure/google-closure-library-third-party]]
#2020-02-2021:14thhellerlein deps :tree will likely tell you#2020-02-2021:14thhellerthat isn't fool proof either. you might still get bad versions from other things#2020-02-2021:14PrometheusHey does anybody have any experience with deploying shadow-cljs apps to heroku? Do I need to deploy it as a node app or is there another way? I see heroku only allows for lein apps when it comes to clojure.#2020-02-2115:49p-himikIf that's still relevant to you, I have a Clojure[Script] app on Heroku. But it's not as dev-friendly as it could've been right now because it wants you to use Lein - I had to strip down their build pack to a bare minimum and to write my own bash code to build CLJS with shadow-cljs.#2020-02-2021:16thhellerwhat do you want to "deploy"?#2020-02-2021:16Prometheusjust a webapp that I made with shadow-cljs#2020-02-2021:17Prometheusso in a browser I guess#2020-02-2021:17thhellerso its just client side JS, no server side?#2020-02-2021:17Prometheusmy experience with deploying webapps is minimal to say the least#2020-02-2021:17Prometheusno serverside no#2020-02-2021:17Prometheusjust a simple MVP proof of concept frontent reagent/re-frame app#2020-02-2021:17Prometheusfrontend#2020-02-2021:18thhellerI don't know anything about heroku but there likely is some option to deploy some static files?#2020-02-2021:18thhellerie. just copy them there?#2020-02-2021:18dpsuttonnetlify is amazing for static cljs sites#2020-02-2021:18Prometheusyes but it seems to want me to deploy it as a php app and mess around with the filenames, creating an index.php and renaming my index.html#2020-02-2021:19prelein provides a lot more functionality (plugins, cider integration, templates) than shadow/deps.edn/lumo, and likely not going away. I've used it for 6+ years and has a lot more stability. It would be better to document dependency issues while integrating with other tools, than to wait till someone has to stackoverflow them.#2020-02-2021:19Prometheusnetlify, I’ll check it out @dpsutton#2020-02-2021:22dpsuttonhttps://suspicious-archimedes-390f0a.netlify.com/#2020-02-2021:23dpsuttonhttps://github.com/dpsutton/asg-ignite-presentation#2020-02-2021:30PrometheusHmm this feels a little bit too easy if you ask me 😉#2020-02-2021:20Prometheus@pri so you’re saying I should just use lein?#2020-02-2021:22preNo. We should be aware of dependency conflicts while using multiple tools together. I only have this issue with lumo/shadow as they bundle their own versions.#2020-02-2021:21lilactownI don’t think he was replying to you, @peder.august#2020-02-2021:23thheller@pri it isn't easy to document those kind of issues. a) they likely change between versions b) they depend on whatever else you are using#2020-02-2021:23thhelleryour fix might not work for others, other fixes might not work for you#2020-02-2021:24thhellerits annoying I know ... I don't like it either but the closure-compiler folks aren't very concerned about backwards compatibility#2020-02-2021:24thhellerso sometimes they break stuff#2020-02-2021:24thhellerbut we still want to use semi recent versions because they also keep adding stuff thats relevant to the JS integration#2020-02-2108:44cfleming@thheller Congrats on a great performance by shadow in the state of Clojure survey, more REPL users than figwheel main now!#2020-02-2110:12thhellernumbers are skewed because of the 2 figwheel variants though 😉#2020-02-2110:24thheller> wtf does shadow-cljs do?#2020-02-2115:52p-himikTo be honest, that was my reaction as well when I first heard an advice about trying shadow-cljs out. "Wha... what? Why? Another build tool? No, I'm exhausted by their proliferation, thank you."#2020-02-2110:24thhellersome of the comments 😛#2020-02-2112:02sheluchinI'm trying to get a new Fulcro3 project started using lein instead of deps.edn as the Fulcro tutorial suggests. When trying to run npx shadow-cljs start, I get this in my error log:
Exception in thread "main" Syntax error compiling . at (shadow/build/closure.clj:69:5).
Followed by a massive stacktrace that - at least to me - doesn't contain anything useful in determining what the error is. How might I go about figuring out what the issue is? I'm not terribly familiar with build tools and it might very well be a simple error in my config files, but I don't know how to determine that.
#2020-02-2112:03thhellerstrange error. only thing I can think of is likely dependency conflicts#2020-02-2112:04sheluchinHmm, I could pair those down to bare essentials. I copied them over from a previous project, but went to latest shadow-cljs.#2020-02-2112:04thhellerwhat do you have in project.clj dependency wise?#2020-02-2112:12sheluchin
(defproject prj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [com.fulcrologic/fulcro "3.0.1"]]
  :main ^:skip-aot sheluchin.client
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}
             :dev {:source-paths ["src/prj/"]
                   :dependencies [[org.clojure/clojurescript  "1.10.520"]
                                  [thheller/shadow-cljs       "2.8.83"]
                                  [binaryage/devtools         "0.9.10"]]}})
                                  ; [cider/piggieback           "0.4.1"]]}})
                                  ; [fulcrologic/fulcro-spec    "3.1.4"]
                                  ; [com.fulcrologic/guardrails "0.0.9"]]}})
#2020-02-2112:16thhellertry
[org.clojure/clojurescript "1.10.597"
    :exclusions [com.google.javascript/closure-compiler-unshaded
                 org.clojure/google-closure-library
                 org.clojure/google-closure-library-third-party]]
#2020-02-2112:22sheluchinHmm, yeah, that worked. That's definitely not something I would have figured out lol#2020-02-2112:22sheluchinWhat's the reason?#2020-02-2112:28thhellerthe cljs version you had brought in an old closure-compiler version#2020-02-2112:30sheluchinShould I keep the exclusions then?#2020-02-2112:32thhellerprobably yeah#2020-02-2112:36sheluchinHow did you figure that out? Is it a reported issue or something?#2020-02-2112:57mishahttps://clojurians.slack.com/archives/C6N245JGG/p1582233238218400#2020-02-2112:57mishakappa#2020-02-2113:09g7sCan I have a :after-load/:before-load per module?#2020-02-2115:27thheller@g7s use the metadata then you can have as many as you want#2020-02-2115:27thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2020-02-2115:27thhellerthey'll only trigger if the namespace is actually loaded#2020-02-2115:28g7sI actually tried that and worked!#2020-02-2115:29g7sreally glad when things work as expected#2020-02-2116:19JuleffelHi all ! I'm new to shadowjs and trying to include [cljs-web3 "0.19.0-0-11"] to a re-frame project using shadow-cljs but I keep having this error while building:
The required JS dependency "web3" is not available, it was required by "cljsjs/web3.cljs".

Search in:
        /Users/jfleury/Documents/Git/multis-interview/node_modules
You probably need to run:
  npm install web3
I'm stuck on this, as when I run "npm install web3", it works, but package.json keeps being rewritten by the command lein-shadow - running shadow-cljs... somehow... I don't understand how to add a js package to project.clj... Can anyone help me on that ?
#2020-02-2116:20thhellercan't really help you with the lein-shadow parts since I don't recommend using it#2020-02-2116:21JuleffelDamn, I jsut copied the todomvc, it's used there 😕#2020-02-2116:20thhelleras for the web3 stuff you just install that that and require it directly (no cljsjs). (:require ["web3" :as web3]) or whatever the actual package name is#2020-02-2116:26JuleffelThanks, but the problem seems to be that I can't really install a npm package without adding something somewhere in project.clj or somewhere else, as the whole package.json is reset each time I launch my code... My project.clj is set like that:
(defproject xxx "lein-git-inject/version"

  :dependencies [[org.clojure/clojure        "1.10.1"]
                 [org.clojure/clojurescript  "1.10.597"
                  :exclusions [com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library
                               org.clojure/google-closure-library-third-party]]
                 [thheller/shadow-cljs       "2.8.83"]
                 [reagent                    "0.9.1"]
                 [binaryage/devtools         "0.9.10"]
                 [clj-commons/secretary      "1.2.4"]
                 [re-frame                   "0.11.0"]
                 [day8.re-frame/tracing      "0.5.3"]
                 [day8.re-frame/test         "0.1.5"]
                 [day8.re-frame/re-frame-10x "0.5.2"]
                 [cljs-web3                  "0.19.0-0-11"]
                 [district0x.re-frame/web3-fx "1.0.5"]]

  :plugins      [[day8/lein-git-inject "0.0.11"]
                 [lein-shadow          "0.1.7"]
                 [lein-shell           "0.5.0"]]

  :middleware   [leiningen.git-inject/middleware]

  :clean-targets ^{:protect false} [:target-path
                                    "shadow-cljs.edn"
                                    ;"package.json"
                                    ;"package-lock.json"
                                    "resources/public/js"]

  :shadow-cljs {:nrepl {:port 8777}

                :builds {:client {:target :browser
                                  :output-dir "resources/public/js"
                                  :modules {:client {:init-fn xxx.core/main
                                                     :preloads [day8.re-frame-10x.preload]}}
                                  :compiler-options {:closure-defines {re-frame.trace.trace-enabled?        true
                                                                       day8.re-frame-10x.debug?             true
                                                                       day8.re-frame.tracing.trace-enabled? true}}
                                  :devtools {:http-root "resources/public"
                                             :http-port 8280}}
                         :karma-test {:target    :karma
                                      :ns-regexp "-test$"
                                      :output-to "target/karma-test.js"
                                      :compiler-options {:pretty-print    true
                                                         :closure-defines {re-frame.trace.trace-enabled? true}}}}}

  :aliases {"dev-auto" ["shadow" "watch" "client"]
            "test-once"  ["do"
                          ["clean"]
                          ["shadow" "compile" "karma-test"]
                          ["shell" "karma" "start" "--single-run" "--reporters" "junit,dots"]]
            "test-auto"  ["do"
                          ["clean"]
                          ["shadow" "watch" "karma-test"]]
            "karma-watch" ["shell" "karma" "start" "--reporters" "junit,dots"]})
#2020-02-2116:28thhellerno clue. I recommend using shadow-cljs.edn and package.json for CLJS and not using lein-shadow#2020-02-2116:29Juleffelthx, I will dig on that#2020-02-2116:29thhellerthen you don't have those worries. I have never used lein-shadow and I'm not involved with it so can't help#2020-02-2116:30thhelleryou probably already have the generated shadow-cljs.edn#2020-02-2116:32Juleffelyes I have that#2020-02-2116:32thhellerthen you just npm install shadow-cljs in the project#2020-02-2116:32thhellerand npx shadow-cljs watch client#2020-02-2116:32thhellerand remove shadow-cljs.edn from the :clean-targets. otherwise lein will delete it#2020-02-2116:33thhellerand you can then remove the :shadow-cljs stuff as well. basically what the plugin does is copy that to shadow-cljs.edn#2020-02-2116:37JuleffelOk, thx !#2020-02-2116:49ShaneLester#2020-02-2122:23paul ai'm configuring my shadow-cljs builds incorrectly somehow, but i can't tell how. in my shadow-cljs.edn, the builds section looks like this:
{:source-paths
 ["src/cljc/"
  "src/cljs/"
  "test/cljs/"]

 :dependencies
 [[reagent "0.9.0-rc1"]
  [cider/cider-nrepl "0.22.0-beta8"]]

 :nrepl
 {:port 8202}

 :builds {:dev {:target :browser
                :modules {:main
                          {:entries [my-app.frontend]
                           :depends-on #{:cljs-base}}

                          :tracker
                          {:entries [my-app.tracker]
                           :depends-on #{:cljs-base}}

                          :cljs-base
                          {:entries []}}
                :output-dir "resources/public/assets/js"
                :asset-path "/assets/js"}

          :test {:target :browser-test
                 :test-dir "test/resources/public"
                 :devtools {:http-port 8021
                            :http-root "test/resources/public"}}}}
#2020-02-2122:25paul ait seems like the :test build configuration is clobbering the :dev build entirely; with my shadow-cljs.edn like that, if i do a dev build, i get a test build#2020-02-2122:26paul ai'm running shadow-cljs via emacs+cider, if that matters.#2020-02-2122:26lilactownis that your whole shadow-cljs.edn?#2020-02-2122:27paul ano - the rest is not very exciting, but i'll edit that message for completeness' sake#2020-02-2122:27lilactownhow are you serving the :dev files?#2020-02-2122:28paul ai don't know enough to answer that question#2020-02-2122:28paul ai believe that emacs is running the equivalent of shadow-cljs watch dev, which i guess runs a process that serves the files?#2020-02-2122:29lilactown> if i do a dev build, i get a test build how do you know you get a test build instead of a dev build?#2020-02-2122:29lilactowndo you go to a URL in your browser?#2020-02-2122:30paul aoh no, i'm mistaken. i believe shadow-cljs is just writing the compilation results to a place where my webserver can find them#2020-02-2122:31paul avarious reasons; my test builds take much longer than my dev builds; emacs launches a UI when it runs shadowc-ljs, and it takes me to the test page when i run the test builds#2020-02-2122:32lilactownI’m confused by what you’re saying here.#2020-02-2122:33lilactownemacs asks to launch a browser window when you start a shadow-cljs build, yes. does it perchance open your browser to localhost:8021?#2020-02-2122:33lilactownyou don’t have an http-server configured for your :dev build, which is why I ask#2020-02-2122:33lilactownso Emacs might just be guessing what to open#2020-02-2122:33paul aer, yeah, it does take me to localhost:8021.#2020-02-2122:34lilactownit’s unclear to me how you expect to actually interact with your web application#2020-02-2122:34paul aif i omit the :test build configuration entirely, emacs will take me to localhost:9630#2020-02-2122:34paul ai run a web server separately#2020-02-2122:34lilactown9630 is the sort of default shadow-cljs UI#2020-02-2122:34lilactownmy guess is emacs is just assuming which one to open based on your shadow-cljs.edn#2020-02-2122:36lilactownI’m struggling to see evidence that the :dev build is not running. when you open the page on your separate web server, do you not see your application running and changes not hot loading?#2020-02-2122:37lilactowndo you see messages in your REPL buffer saying :dev or :test are building?#2020-02-2122:38paul alast night i was seeing test builds. i restarted every thing and now things are fine... sorry for the goose chase, this seems to be user-error on my part 😕#2020-02-2122:38lilactownif it opened to localhost:8021, it’s going to show your last test build even if the watch isn’t running#2020-02-2122:43lilactownglad it’s working now for you, at least#2020-02-2122:49paul athat makes sense#2020-02-2122:50paul amy test builds take several minutes and i could swear that i was seeing those even when i had requested dev builds. that was another source of confusion, but maybe the primary confusion was the localhost:8021 vs localhost:9630 business.#2020-02-2122:50paul abut yeah, everything looks good now. thanks!#2020-02-2200:22ParenoidI'm following https://github.com/PEZ/rn-rf-shadow, and it's amazing!#2020-02-2200:24ParenoidI am noticing that every change to App.js in that case causes the hardware simulator to rebuild and load the app, whereas the non cljs expo approach automagically reloads the change fairly instantly without a rebuild and download the javascript bundle to the device... does anyone have experience with getting the latter thing going with cljs (or who can redirect me to a good channel to ask)?#2020-02-2200:29ParenoidOK, disregard all that... had to disable live reload on the expo app on my device and now it works as expected (as mentioned in the repo readme 😳 )
#2020-02-2200:29Parenoidit's a bit slower, but not bothersomely so... probably because of the cljs->js phase.#2020-02-2200:36Parenoidany random suggestions/thoughts/projects on this theme are welcome though (either here or by DM).#2020-02-2200:44Parenoidoookay... here is a more specific question: when following the 'Using Emacs with CIDER' approach at https://github.com/PEZ/rn-rf-shadow everything works, I can (js/alert "foobar") from the cljs.user> repl inside emacs, and everything is good... however, I can't cider-eval-defun-at-point anything inside my app.cljs buffer in emacs... is it possible to be able to do that?#2020-02-2200:54ParenoidI tried it all again this time using cider-jack-in-clj&cljs and when evaluating (+ 1 1) in directly in the emacs app.cljs buffer I got an java.lang.RuntimeException Unable to resolve symbol: + in this context error... hmm.#2020-02-2201:00Parenoidok, fixed... setting the buffer to clojurescript-mode fixed the problem.#2020-02-2221:11Kurt SysI have some issues with babel and shadow-cljs. I guess the babel version in shadow-cljs (2.7.0) I was using didn't support all the plugins (for rest destructuring) I need since one of the dependencies (luxon) needed to be upgraded due to some weird behaviour in chrome 80+. The first thing I tried: upgrade shadow-cljs. However, when upgrading to 2.8.83, I get this error:
$ yarn cljs:watch
yarn run v1.21.1
$ shadow-cljs watch app
shadow-cljs - config: .../shadow-cljs.edn  cli version: 2.8.83  node: v10.15.2
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: tap> in this context, compiling:(shadow/debug.clj:36:3)
	at clojure.lang.Compiler.analyze(Compiler.java:6792)
#2020-02-2221:13Kurt Sys(when I run just yarn babel ... , all works fine, so I'm sure I need an upgraded version of babel - so probably I need an upgraded version of shadow-cljs). However, not sure why shadow-cljs seems to have issues with watch app#2020-02-2221:14Kurt Sysbtw, in package.json, I have a script "cljs:watch": "shadow-cljs watch app"#2020-02-2221:14Kurt SysWhat am I missing?#2020-02-2221:15thhellertap> missing means you are not using clojure 1.10.1#2020-02-2221:15Kurt Sysoh, nvm, found it.#2020-02-2221:15Kurt Sys🙂#2020-02-2221:20Kurt Sysbesides the fact that it's (most probably) solved: is there a way to choose which version of babel is used when using shadow-cljs? (I added some to package.json, but they don't help out when running watch app...)#2020-02-2221:21thhellerthere is not no#2020-02-2221:25Kurt Sysok, thx...#2020-02-2313:57sheluchinCan anyone tell me why I'm getting the error at the top?
[2020-02-23 08:51:46.509 - WARNING] provide conflict for #{sheluchin.client} provided by app/sheluchin/client.cljs and {"/sheluchin/client.cljs" #{sheluchin.client}}


{:lein {:profile "+dev"}
 :nrepl     {:port 9000}

 :dev-http  {8000 "resources/public"}

 ; Ignored since :lein is set
 ; :source-paths ["src/app"]

 :builds    {:main      {:target        :browser
                         :output-dir    "resources/public/js/main"
                         :asset-path    "/js/main"
                         :dependencies  [[cider/piggieback "0.4.1"]
                                         [fipp "0.6.21"]]
                         :repl-options  {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}

                         :modules       {:main  {:init-fn sheluchin.client/init}}
                         :devtools      {:after-load sheluchin.client/init
                                         :preloads    [com.fulcrologic.fulcro.inspect.preload]
                                                       ; sheluchin.app.core-test]
                                         :repl-pprint true}
                         :compiler-options {:external-config {:guardrails {}}
                                            :closure-defines {'goog.DEBUG true}}}}}

(defproject app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [com.fulcrologic/fulcro "3.0.1"]]
  :main ^:skip-aot sheluchin.client
  :target-path "target/%s"
  :source-paths ["src/app"]
  :profiles {:uberjar {:aot :all}
             :dev {:source-paths ["src/app"]
                   :dependencies [[org.clojure/clojurescript "1.10.597"
                                    :exclusions [com.google.javascript/closure-compiler-unshaded]
                                                org.clojure/google-closure-library
                                                org.clojure/google-closure-library-third-party]
                                  [thheller/shadow-cljs       "2.8.83"]
                                  [binaryage/devtools         "0.9.10"]]}})
#2020-02-2313:58sheluchin
Invalid Filename, got app/sheluchin/client.cljs but expected sheluchin/client.cljs (or .cljc)

   1 | (ns sheluchin.client

   2 |   (:require

   3 |     [com.fulcrologic.fulcro.application :as app]

   4 |     [com.fulcrologic.fulcro.components :as comp :refer [defsc]]

   5 |     [com.fulcrologic.fulcro.dom :as dom :refer [div h1 h2 h3 button ul li]]
#2020-02-2314:00sheluchinI have :source-paths ["src/app"] set, so ns sheluchin.client should correspond to src/app/sheluchin/client.cljs, no?#2020-02-2314:06thhellerit should. did you restart lein/shadow-cljs after changing the paths?#2020-02-2314:07thheller(if you changed the paths while it is runing they won't apply)#2020-02-2314:13sheluchinHmm, thought I did that last time too, but doing it again for good measure seems to have fixed it.#2020-02-2322:15Aleedis tree shaking for node_modules not turned on by default? I'm running a build report and seeing that all of react-native-web (300kb 😬) is being included even though I'm only using a portion of it. reading docs it says advanced optimizations are only done if :js-provider is set to closure . which I imagine is the issue here. but if some of my other packages aren't compatible with closure compiler, is there way way to exclude them from advanced optimization, or to specifically include the packages I want optimized?#2020-02-2322:15Aleedis tree shaking for node_modules not turned on by default? I'm running a build report and seeing that all of react-native-web (300kb 😬) is being included even though I'm only using a portion of it. reading docs it says advanced optimizations are only done if :js-provider is set to closure . which I imagine is the issue here. but if some of my other packages aren't compatible with closure compiler, is there way way to exclude them from advanced optimization, or to specifically include the packages I want optimized?#2020-02-2322:19Aleedalso looks like all of clojurescript itself is being included (i.e. pprint and spec are bundled).. though not sure if that's bc other cljs deps are depending on it#2020-02-2322:31lilactownIn general external JS can't be tree shaken / DCE'd#2020-02-2322:41Aleedah so any JS package you include will include all its exports? i imagine we can’t post process cljs output with babel either 🤔 any workarounds for this?#2020-02-2322:42lilactownOften in large libs you can include just the files you need#2020-02-2408:58thhellernot all CLJS code is compatible with DCE either. thats why you see pprint and spec#2020-02-2408:58thhelleras for JS your requires should be as exact as possible (if possible at all)#2020-02-2322:43zilvinasuanyone successfully using shadow-cljs with emacs clojure-lsp with project generated npx create-cljs-project ? go to definition for the libs does not seem to work (:require [reagent.core :as r]) i.e. can’t jump to reagent code#2020-02-2322:47dpsuttonHow recent is your clojure-lsp? I think the patch to understand shadow-cljs project landed a few days ago. Also the parser hasn’t been updated for strings in the ns require form yet #2020-02-2322:50zilvinasuinstalling ==> Downloading https://homebrew.bintray.com/bottles/clojure-lsp-20200121T234305.catalina.bottle.tar.gz#2020-02-2322:50zilvinasumight be too old in homebrew, will try to install manually, thanks!#2020-02-2400:59dpsuttonDid that help?#2020-02-2408:11zilvinasuseems like homebrew formula is using this one: https://github.com/snoe/clojure-lsp/releases/tag/release-20200121T234305 so it is kind of the latest according to the github, though reinstalling it made it crash every time now#2020-02-2408:59zilvinasuPulled the repo and done lein bin to get the recent bin, since the one that is provided is not up to date, works now, thanks!#2020-02-2408:12Parenoidit looks like Enlive https://github.com/cgrand/enlive is abandonware (the "it hasn't needed attention and just works argument" notwithstanding [but correct me if I am wrong]).... last google group activity more than four years ago and last update other than the README half a decade ago...#2020-02-2408:12Parenoidare there other more current tools/approaches for getting data from the web commonly in use?#2020-03-0419:44ro6Have you looked at Hickory?#2020-02-2409:12thheller@patrickanium probably a better question for #clojurescript#2020-02-2409:45dakraAnyone used github actions to build a shadowcljs project? I would like to use https://github.com/peaceiris/actions-gh-pages to automatically build my shadowcljs project and publish it to gh-pages. Would be nice if I could use an existing action but couldn't find anything on the marketplace.#2020-02-2410:41thhellerI haven't looked into github actions at all yet. I suspect it is pretty straightforward though#2020-02-2410:43thhellerlooks like you can just use that one?#2020-02-2410:43thhellerhttps://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-gatsby#2020-02-2410:44thhellerjust switch the npm commands to only do npm run build#2020-02-2410:44thhellerand in your package.json set up a proper script for that#2020-02-2410:44thheller"scripts":{"build":"shadow-cljs release your-app"} or so#2020-02-2411:13zilvinasu@thheller just wanted to say thanks for shadow-cljs! been a while since I used CLJS, and with shadow-cljs it seems that things gotten better#2020-02-2413:06Saikyunwhen using :browser-target, and running shadow-cljs release app, what is the HTML-file supposed to call in order to call the init -function?#2020-02-2413:07Saikyunthis is how my index.html-file looks#2020-02-2413:07thhellerremove the init call completely and use :init-fn in the build config instead#2020-02-2413:07Saikyunbut when opening it after having released, my-ns isn't available as a global variable#2020-02-2413:07Saikyunah okay, thanks#2020-02-2413:08thhellerOR add ^:export to the init fn so its name is preserved#2020-02-2413:08Saikyunconfig file makes sense 🙂 I looked here and couldn't figure it out: https://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn#2020-02-2413:09Saikyunah, but now I see you use ^:export there#2020-02-2413:09Saikyunthanks!#2020-02-2414:04lambderhello All#2020-02-2414:04lambderthis is my shadow-cljs.edn#2020-02-2414:04lambder#2020-02-2414:04lambder
{:deps         true

 ;; set an nrepl port for connection to a REPL.
 :nrepl        {:port 8777}

 :builds       {


                :test {:target    :node-test
                       :modules          {:base {:init-fn token-streamer.main/init}}
                       :output-to "out/node-tests.js"
                       :ns-regexp ".*-test"
                       :autorun   true}

               }}
#2020-02-2414:04lambderwhen I run shadow-cljs compile :true#2020-02-2414:05lambderI'm getting this:#2020-02-2414:05lambder
[:test] Compiling ...
========= Running Tests =======================

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
===============================================
[:test] Build completed. (46 files, 1 compiled, 0 warnings, 1.52s)
#2020-02-2414:05lambderany idea why it doesn't see my tests?#2020-02-2414:10plexusmaybe my google fu is failing me, has anything been said before about bringing figwheel's "extra mains" feature to shadow-cljs?#2020-02-2414:11plexusas in any indication about how doable/hard/easy easy it would be, or if there's an alternative, or if there is a desire to have it or otoh a choice not to do it.#2020-02-2414:17thheller@lambder where are you tests? :modules does not apply to the :node-test target so if you expect that to do something it won't#2020-02-2414:17thheller@plexus you'd have separate builds?#2020-02-2414:19thhellerI have not seen a convincing use-case that wasn't solved better by a separate build#2020-02-2414:19lambder@thheller#2020-02-2414:19lambder#2020-02-2414:19thhellerand do you have :paths ["src" "test"] in your deps.edn?#2020-02-2414:20lambderno :paths#2020-02-2414:20lambderI hoped for defaults#2020-02-2414:20thhellerthe default is just ["src"]#2020-02-2414:20lambderI see#2020-02-2414:22lambder@thheller it worked. Thanks#2020-02-2414:23plexus@thheller they are a lot more lightweight than separate builds, that's really their main draw#2020-02-2414:24thhellerwhat does that mean to you? lightweight?#2020-02-2414:25thhelleror phrased the other way .. what is "heavy" about separate builds?#2020-02-2414:25plexuslightweight in the sense that every namespace only gets compiled once#2020-02-2414:27thhelleryou emulate extra-mains via modules if you really want to but I really don't quite see the point#2020-02-2414:28thhellerin several scenarios it'll make your main build slower#2020-02-2414:28thhellerand in many others your main build will recompiled when it doesn't need to#2020-02-2414:28thhellerie. you edit my.app.foo-test, no point in your main build doing anything for that#2020-02-2414:29plexusmight still be preferrable over having a handful of builds kick off in parallel. Thanks for the input.#2020-02-2414:30thheller:modules {:main {:entries [] :preloads [my.app-tests]}}#2020-02-2414:31thhellerthen in your HTML include the main.js and call the respectice "init" fn you want#2020-02-2414:31thhellerie. make 2 and one calls <script>my.app.init()</script> while the other calls the tests#2020-02-2414:32plexusmakes sense, and very helpful! :+1:#2020-02-2415:07dakra@thheller thanks. I managed to get the github actions for auto deploy to gh-pages to work. https://github.com/dakra/mui-templates#2020-02-2415:07dakrabut now I see that it works nice locally with e.g. shadow-cljs watch app but when I make a release shadow-cljs release app it doesn't show my chart and some things doesn't seem to work without any error output. I'm new to clojurescript, any tips to debug this or some common gotchas I've to look out for that makes the release different from the dev version?#2020-02-2415:10thhellershadow-cljs release app --pseudo-names or shadow-cljs release app --debug will make things a little more understandable#2020-02-2415:11dakrathank you very much. I'll check.#2020-02-2415:12thhellercheck if your paths are correct#2020-02-2415:13thhellerif you just get a 404 for your scripts then your paths just aren't correct#2020-02-2415:15dakraHmm. I don't see any difference with either --pseudo-names or --debug. I don't get 404 anywhere. it works almost as expected just recharts is not displayed and some css looks slightly wrong which is correct when I do the dev build.#2020-02-2415:16dakraIt's rendered here https://dakra.github.io/mui-templates/ and locally in dev mode it looks nice. (repo is https://github.com/dakra/mui-templates)#2020-02-2415:16thhellerI suspect that its just an externs issue then#2020-02-2415:16thhellerin your build config turn on :compiler-options {:infer-externs :auto}#2020-02-2415:17thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#externs#2020-02-2415:17thhellerhttps://github.com/dakra/mui-templates/blob/master/src/mui_templates/dashboard.cljs#L94#2020-02-2415:17thhellerthat is one candidate#2020-02-2415:18thhellerchange (fn [{:keys [classes] :as props}] to (fn [{:keys [^js classes] :as props}]#2020-02-2415:28dakraNice. Thank you very much again. that worked 🙂#2020-02-2415:28dakraThat was a bit difficult for me as a clojurescript beginner to debug as there was simply no error anywhere#2020-02-2420:42DerekLooks like the shadow dashboard on 9630 is busted
main.js:52 Uncaught Error: No protocol method IProfile.perf-start! defined for type object: [object Object]
#2020-02-2420:43Derekthis is with 2.8.84 and 2.8.85#2020-02-2420:49Derek2.8.83 continues to work as expected#2020-02-2421:38thheller@dpassen1 oops. fixed in 2.8.86#2020-02-2421:40Derekthanks. checking it out now#2020-02-2421:44Derekworks great. thanks for the quick update#2020-02-2501:07markxLooks like in ClojureBridge they still use figwheel instead of shadow-cljs. Anyone know why people would choose figwheel?#2020-02-2501:08EmmanuelOgawhy not?#2020-02-2506:57markxBecause shadow-cljs is better? I myself can’t think of any reason to choose cljsbuild and figwheel, so I’m curious. Let me rephrase my question, nowadays what advantage does figwheel (or maybe cljsbuild and all the cljsjs stuff) have over shadow-cljs?#2020-02-2501:08EmmanuelOgaboth are great tools#2020-02-2502:36lilactownSame reason people still use lein even though deps.edn exists. People have tools that work really well for them; why change?#2020-02-2504:16QuestI've switched from figwheel & lein to shadow-cljs and deps.edn in the last year. shadow-cljs provides significantly faster compile time but can be harder to get working with Emacs CIDER. One of the biggest reasons I was willing to try switching was thheller's top notch support in this channel. No regrets, though the compile time is the main benefit I've seen so far. On deps.edn vs lein... the startup time is the only real benefit I've realized yet, but there's some interesting things you can do with deps.edn. Just haven't needed them. It was a much harder switch than figwheel -> shadow-cljs though.#2020-02-2504:17dpsuttonwhat problems have you found with CIDER?#2020-02-2504:19QuestBiggest wall I hit was trying to use deps.edn to "wrap" shadow-cljs. Your startup invocation becomes clj -A:shadow-cljs watch app, but I couldn't find a way to get that working with cider-jack-in-cljs#2020-02-2504:20QuestI ended up just sticking with cider-jack-in-cljs + shadow-cljs , but my automation uses the clj -A:shadow-cljs release app alias to release the app as it avoids needing a docker image that has shadow-cljs installed#2020-02-2504:20Quest(The reason I needed deps.edn in the first place was to authenticate to a private maven2 repo)#2020-02-2504:21dpsuttonuse a prefix to edit the jack in command and type whatever you want#2020-02-2504:21dpsuttonC-u C-c M-J and then just type in clj -A:shadow-cljs watch app#2020-02-2504:22QuestI did mess around with that but could never quite get CIDER working. I suspected it had to do with the dependency injections or initialization hooks that CIDER does when running via clj vs shadow-cljs#2020-02-2504:23QuestI'll poke it real quick and see what error comes out, already deleted my previous logs#2020-02-2504:23dpsuttonif you can get a minimal example without any sensitive stuff i can poke around. I think bozhidar is working on cljs support and i want shadow to be first class in CIDER#2020-02-2504:25QuestThat's generous of you, thank you. I'll setup a public repo to demo this and get back to you tomorrow.#2020-02-2504:25dpsuttonping me with it in #cider and i'll check it out#2020-02-2507:22markxHa guess I’m not the only one with this question.#2020-02-2507:24SaikyunI didn't get far with figwheel, but from my experience shadow-cljs solves every problem I've ran into in a clean way: • dev http server • can run clojure code (as opposed to lumo et al) • repl ALL THE TARGETS • fantastic integration with npm packages since I personally prefer repl + load file / eval-defun, I'm finding shadow-cljs a lot faster to use than figwheel, which seems dependent on "hot reload" rather than eval#2020-02-2507:28markxYeah I know! That’s why I’m asking.#2020-02-2507:29markxI wish shadow-cljs was the default solution, and people advertise it as the default solutiton.#2020-02-2507:31SaikyunI guess one would have to ask in the #figwheel what they like about it, that they don't think shadow-cljs solves 🙂#2020-02-2507:31SaikyunI guess one could say that figwheel only solves one problem. I do however agree that I'd personally recommend shadow-cljs over figwheel. doesn't mean that figwheel is bad though 🙂#2020-02-2507:32SaikyunI think if you come from another programming language, maybe figwheel is easier to get started with? the docs for shadow-cljs are pretty intimidating 😄#2020-02-2507:32zilvinasuThere is an npm starter script you can use to generate shadow-cljs project (`npx create-cljs-project your-projec` )#2020-02-2507:34markxI came from a js+go+python background. I think figwheel and all the cljsbuild stuff are intimidating#2020-02-2507:34Saikyunsure, but that doesn't mean that it's easier to comprehend the tool 🙂 when you come from another language, you're generally used to very sparse tooling (`compile-binary source.ext`), so regardless of which tool you choose, it's going to feel like a lot. and shadow-cljs solves so many problems, so might be figwheel feels easier to get started with#2020-02-2507:34Saikyunthis is purerly conjecture on my part#2020-02-2507:35Saikyunhaha, I see 🙂 I got interested in cljs because of the nice figwheel youtube intro#2020-02-2507:35Saikyunthis one: https://www.youtube.com/watch?v=KZjFVdU8VLI#2020-02-2507:36Saikyunit was very easy to understand what problem figwheel solves#2020-02-2507:37Saikyunmaybe one ought to make a similar video for shadow-cljs? 🙂 looking here it's not immediately clear what problem shadow-cljs solves: http://shadow-cljs.org/#2020-02-2507:37Saikyunjust some thoughts ^^#2020-02-2512:11andrehttps://hackmd.io/@byc70E6fQy67hPMN0WM9_A/rJilnJxE8#2020-02-2515:36lilactownDoes shadow-cljs automatically load user.cljs if it’s on the classpath?#2020-02-2515:37lilactownI’m trying to write instructions for how best to include some code only at dev time. I think you could either put it in user.cljs, or put it in a preload#2020-02-2517:07thhelleruse a prelaod always#2020-02-2517:08thhellercljs/user.cljs is loaded but applies to all builds and REPLs so I wouldn't use it#2020-02-2517:11lilactownaha, thanks!#2020-02-2517:53knubieSpeaking of preloads, what’s the best way to set up spec instrumentation for a build? I tried calling instrument in a preloads namespace, but that didn’t work (I’m guessing because it gets called before the specs are defined?)#2020-02-2517:55knubie☝️ specifically trying to set up instrumentation for my tests build#2020-02-2518:09thhellerin your preloads namespace you need to require all namespaces that you want to instrument#2020-02-2518:09thhellerthat way it'll be loaded after those namespaces to ensure it can actually instrument them#2020-02-2518:13knubieI see, thanks thheller#2020-02-2521:13celwellHi, I'm running a fresh lein new re-frame todo +10x +cider +test and at localhost:9630 the Builds tab and the Inspect tab work fine, but the REPL tab just says Loading... forever. Any ideas to try?#2020-02-2521:46thhelleruse the cider REPL. the web thing is actually gone in the latest version. it'll return when I have more time to work on it#2020-02-2521:50cjsauerDoes shadow cache dependencies in the usual .m2 directory? I’m playing with Netlify and I see that my builds always have to re-fetch all dependencies during the shadow-cljs - updating dependencies phase.#2020-02-2521:52thhelleryes#2020-02-2522:21kaoskoI'm using three.js as a node module and importing it to my cljs app works just fine thanks to shadow. three.js also comes with some examples. is it possible to easily import these underlying modules as well, similar to how you can just do import { Ocean } from './jsm/misc/Ocean.js'; in js?#2020-02-2522:28thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2020-02-2522:42kaoskogreat thanks @thheller !#2020-02-2607:06kaoskorelated to requiring js files. now the js file wants to import stuff from the npm module that I've already required via shadow. How do I refer to it? as is, I get 'Cannot access "../../../build/three.module.js" from "jsm/misc/Ocean.js".' which makes a lot of sense. I suppose I could point :source-paths to the whole node-modules but it kind of defeats the purpose#2020-02-2610:23SaikyunI've fiddled around a lot with cljs + three.js. if you can give me a repro-repo I can help you 🙂#2020-02-2817:25kaoskothanks @UCG86LJFN this is not open source at the moment. anyway, you might be able to help me with it. Able to fix the files in /jsm to require three as a module instead of path, but they also import a lot of stuff from three that now hasn't been exported. How do I resolve that, any idea?#2020-03-0115:35kaoskojust for completeness, the issue was that shadow compiler doesn't ES6 style module imports, i.e.
import {
 Vector2
} from "three";
instead, I had to write it like this:
import * as three from 'three';
const { Vector2 } = three;
#2020-03-0413:40Saikyunseems strange to me. I've been able to do import { Vector2 } from "three". either way, nice that you fixed it 🙂#2020-02-2608:12tekacsI’d like to run /just/ the hot-reload and CLJS REPL parts of shadow-cljs, without exposing my computer’s clj-eval/etc. through the websocket to anyone passing by. I’ve been live editing my app in front of astonished (local network) users using shadow for some time now. Unfortunately, I can’t leave it running unsupervised or :gasp: expose it on the web, since the websocket/dashboard has clj-eval functionality, which opens up my computer to having arbitrary code run on it. If I’ve missed how to do this I’d love to hear about it — or if it’s not possible, I’d love to add support for it (perhaps whitelisting :supported_ops / :op ?)#2020-02-2608:12tekacsI’d like to run /just/ the hot-reload and CLJS REPL parts of shadow-cljs, without exposing my computer’s clj-eval/etc. through the websocket to anyone passing by. I’ve been live editing my app in front of astonished (local network) users using shadow for some time now. Unfortunately, I can’t leave it running unsupervised or :gasp: expose it on the web, since the websocket/dashboard has clj-eval functionality, which opens up my computer to having arbitrary code run on it. If I’ve missed how to do this I’d love to hear about it — or if it’s not possible, I’d love to add support for it (perhaps whitelisting :supported_ops / :op ?)#2020-02-2608:18zilvinasusorry if this is a dumb question, if it is listening on localhost rather than 0.0.0.0 how is it being exposed ?#2020-02-2608:40thhellerit is listening on 0.0.0.0 by default#2020-02-2608:41thhelleryou can change set by setting :http {:host "localhost"} in shadow-cljs.edn#2020-02-2608:41thhellerbut it is likely a good idea to run a local firewall?#2020-02-2617:57tekacs@U05224H0W my hope /was/ to run it in a way that’s accessible to multiple folks and keep running it for a while, so that it hot reloads for all of them. That is — I’d like to expose the hot reload and CLJS REPL aspects without the ‘run code on my machine.’ aspects. My suggested thought was to filter the operations that can be sent over the websocket, so as not to include :clj-eval/etc. Does that make sense?#2020-02-2617:59thhellerI think I may add a basic "trusted" check. so that some operation are only allowed from trusted clients. basically an IP check. defaulting to local only but maybe letting you add IPs via config#2020-02-2618:00thhellermaking those per OP is a bit overkill though#2020-02-2618:01tekacsMm, honestly even just having a configuration flag to turn off all of the ‘trusted’ operations would be super welcome.#2020-02-2618:01tekacsBut IP whitelisting would make it super effective (again, just across all trusted ops) — I could still get in to debug but allow others to see and hot reload it.#2020-02-2618:01tekacsLet me know if I can help at all.#2020-02-2618:17tekacsfor what it's worth, I set up the combination of: • Port forwarding 3000 -> 443 & 9630 to a domain • SSL with a keystore + {:closure-defines {shadow.cljs.devtools.client.env.ssl true}} and then was able to send folks to https://test-app.example.com and have them see my changes from wherever they were in real-time and debug their issues from the REPL (or the browser view, or even tap> from the clients and Inspect the results). It has made for a really interesting and capable development experience -- if the 'trusted/unsafe' operations could be IP whitelisted as you suggest, I would recommend this to most folks and see if I could bottle up the pattern and write something about it. :)#2020-02-2618:18thhellerwell as soon as you port forword the IP check will fail because the IP will be whatever does the tunneling 😛#2020-02-2618:30tekacsHaha I did think of that and wonder (given that your TCP termination would be local) — and then wrote it off without considering further.#2020-02-2618:31thhellerbut hot-reloading is separate from that anyways#2020-02-2618:31tekacsA cookie could work, perhaps? Trying not to create work. 😅#2020-02-2618:31tekacsYou already have ‘secret’ set, IIRC#2020-02-2618:32thhellerthe UI stuff already uses a cookie but anyone visiting the UI can get that cookie#2020-02-2618:32tekacsAh and it’s the same for every client?#2020-02-2618:32tekacsIf it were stored locally, we could whitelist it from the server side #2020-02-2618:32thhellerthere is not "login" so yeah#2020-02-2618:32tekacsIf it were unique per client#2020-02-2618:32tekacsJust a UUID#2020-02-2618:33thhellernah the secret is just a basic check so that you can't open the websocket without opening the UI first#2020-02-2618:33thhellerreally basic security check really#2020-02-2618:35tekacsI guess I could kill the HTTP side of the channel and only allow HTTP 101 to secure it 😂 — though I suspect it’s sent early :P#2020-02-2618:35tekacsBut more seriously #2020-02-2618:35thhellerfirst of all you need to separate what you want to allow access to in the first place#2020-02-2618:35thhellerhot-reload has nothing to do with any of the UI parts#2020-02-2618:35thhellerso blocking the UI is probably good enough#2020-02-2618:36tekacsIsn’t it over WS on the same port though?#2020-02-2618:36thhelleryes, but it doesn't have to be#2020-02-2618:36tekacsHm#2020-02-2618:36tekacsWould cljs REPL also be on the same WS?#2020-02-2618:37tekacsBecause if there were three ports#2020-02-2618:37thhellerok a bit of terminology so we understand each other#2020-02-2618:37thhellerruntime: anything running JS (eg. browser)#2020-02-2618:38thhellertool: anything sending tool command (eg. eval)#2020-02-2618:38thhellerrelay: shadow-cljs server#2020-02-2618:38thhelleraccess to the relay is open so you can open a runtime anywhere#2020-02-2618:39thhellerie. multiple browser, devices etc#2020-02-2618:39thhellertool connections should probably be restricted somehow#2020-02-2618:39thhellerthe compiled code is NOT a tool, it is only a runtime#2020-02-2618:39thhellerso there need to be no "security" there imho#2020-02-2618:40tekacsGot it#2020-02-2618:40thhellerrestricting the tool access based on IP is easy#2020-02-2618:40thhellerit also doesn't need to run on :9630#2020-02-2618:40thhellerjust currently does for (my) convenience#2020-02-2618:41tekacsRight, so three ports would be ideal from my point of view#2020-02-2618:41tekacsAs in — 3000, 9630 are forwarded#2020-02-2618:41tekacsThe third port I could just not forward #2020-02-2618:41tekacsAnd that would work perfectly from my POV#2020-02-2618:41tekacsPeople could access the site and runtime but not tool#2020-02-2618:42tekacsAnd the runtime has hot reload and the connection to the relay for cljs REPL into those clients IIUC#2020-02-2618:42tekacsDoes that seem correct?#2020-02-2618:42tekacsAnd thank you for taking the time to talk#2020-02-2618:55thhellerwell as soon as the tool access is restricted the UI might as well be too#2020-02-2618:55thhellersince it won't work without it#2020-02-2618:55thhellerI'll see if I can figure something out#2020-02-2608:39thheller@kaosko you just need to rewrite the require in those files to use the regular threejs from npm, ie. not a path#2020-02-2610:53xlfehello channel. thanks for shadow-cljs - i'm just getting started and trying to understand if I am working with shadow-cljs correctly. I have a shadow-server setup and shadow is watching my :app for a :browser target. I can connect in the browser, etc and my app works there without errors. I am using vim-fireplace to connect to the nREPL and edit code, etc. One thing I cannot get working is omni-completion for npm modules that shadow-cljs is handling.#2020-02-2610:54thhellerno clue what omni-completion is so you'll have to ask the vim-fireplace folks#2020-02-2610:55thhellerlikely it just doesn't support npm modules#2020-02-2610:55xlfeFor example, in one file i have a (:require such as ["@material-ui/core" :as mui]. I cannot get omni-complete to complete anything after mui/ namespace#2020-02-2610:55xlfeah right#2020-02-2610:55xlfei beleive it calls a nREPL message with :completion or something#2020-02-2610:55xlfeits used to tell you what is defined in a namespace on the fly (based on what you're typing)#2020-02-2610:57xlfedoes shadow-cljs "know" what externs each npm module provides?#2020-02-2610:58xlfesorry I think I mean "exports" rather than "externs"#2020-02-2610:59thhellernot precisely no#2020-02-2611:00xlfehmm ok. I should probably do a bit more thinking about the problem and digging into source. I used to have completion working (for example with material-ui) but that was using a cljsjs module where each export from the node module was explicitly defined in cljs#2020-02-2611:00xlfethanks for your help#2020-02-2611:20thhellerso what do people think. would your development setup be broken if it defaulted to localhost only? https://github.com/thheller/shadow-cljs/issues/660#2020-02-2613:45hlolligiven the fact that all human friendly distro default /etc/hosts to forward to localhost, then I wouldn't worry about defaulting to it. The people that have changed it (hopefully) know what they are doing and I guess could configure their setup differently.#2020-02-2615:15isakit sounds fine to me too#2020-03-0418:14magraI vote secure default#2020-02-2619:57neupshHello, does anyone have a nice little template to write web extensions (for firefox and chrome) using shadow-cljs?#2020-02-2620:17darwinfor chrome we have an example here, not sure if it is little or particulary nice tough 🙂#2020-02-2620:17darwinhttps://github.com/binaryage/chromex/tree/master/examples/shadow#2020-02-2620:22neupshThanks 🙂 Do you think it works with firefox as well?#2020-02-2620:22darwin#2020-02-2620:36thhellerI think firefox extensions are somewhat similar so it might work#2020-02-2620:36thhellerthe :chrome-extension target actually doesn't do anything chrome specific so it might work#2020-02-2620:40neupshThanks. I will give it a try#2020-02-2720:41neupshSo, i gave it a try today: • built the example using shadow-cljs • loaded the extension in chrome: worked • loaded the extension in firefox: worked with some warnings#2020-02-2720:41neupsh#2020-02-2705:37dpsuttonThe shadow users guide specifies that to use shadow-cljs with deps.edn you can add an alias with a different main. Using this from CIDER presents a problem as CIDER needs its own main to get nrepl started up and the middleware injected. It seems somehow we need to get the shadow server up and running. I tried (shadow.cljs.devtools.server/start!) and this is almost there. The problem is that this doesn't use the nrepl middleware so i just need to figure out how to get that up and going. Does anyone know of a good way to support this?#2020-02-2708:38thheller@dpsutton you need start! and the middleware. see https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2020-02-2708:45gravHow to I retrieve __dirname from a cljs repl attached to a node-script (compiled with shadow)?#2020-02-2708:47thhellerjs/__dirname#2020-02-2708:47thhelleractually it might not exist? its a special binding that only exists when loading files. so if it exists it likely is from the file that "loaded" the REPL code#2020-02-2708:50sogaiudoes (js* "dirname") not work?#2020-02-2708:50thhellerthat is exactly identical to js/__dirname. literally no difference in the emitted code#2020-02-2708:51sogaiuhmm...i thought one worked for me yesterday and not the other. i will double-check.#2020-02-2708:59sogaiuthanks - i see the same for both. must have been confused.#2020-02-2709:01sogaiui confirm "dirname is not defined" at a cljs-repl and that it works in a :node-script target in a cljs file.#2020-02-2709:03thheller__dirname is inherently tied to the current file ... REPL has no file so you probably shouldn't use it from the REPL 😛#2020-02-2709:35gravah ... 🙂 I guess what I meant was actually if I could use it from a node-script compiled with shadow. Not sure why I mentioned "repl" 😉 It seems Lumo handles it in a special way, so i thought maybe shadow also does? Already tried js/__dirname and it doesn't work. Edit: better link https://github.com/anmonteiro/lumo/commit/658732fb2b934569507db9cc9a845aea07918f0c#2020-02-2709:37grav... or maybe it actually does work in a non-repl context. Will try again#2020-02-2709:37thhellernot sure what you mean. in :node-script you can of course access it?#2020-02-2709:37gravYup - works fine 🙂#2020-02-2709:37gravSorry for the noise, the whole problem was me trying to use it from the repl#2020-02-2709:37thhellerwhy are you asking anways? it is rarely a good idea to use __dirname?#2020-02-2709:38gravI have some resources that I want to load - so I'd use __dirname for their base-path. Is there a better option?#2020-02-2709:38thhellerah, hmm yeah thats ok I guess#2020-02-2713:44sogaiugood to hear -- i used __dirname to enable working with a .wasm file.#2020-02-2709:39gravIt's for a puppeteer script, so I have to resolve file:///[some-path]/foo.html#2020-02-2710:07djanushey! I'm trying to get an app to compile with shadow-cljs using Boot, via boot-shadow (https://github.com/degree9/boot-shadow)#2020-02-2710:07djanusI'm getting this error:#2020-02-2710:08djanus
Compiling ClojureScript using shadow-cljs: release
[:web] Compiling ...
The required namespace "shadow.js" is not available, it was required by "braintree-2.26.0.min.js".
#2020-02-2710:09djanusthe braintree thing is my native dependency, but it doesn't refer to shadow.js in any way#2020-02-2710:09djanusI think it's some internal shadow-cljs thing#2020-02-2710:10djanusthe app builds fine with plain shadow-cljs, but I need to use Boot for now because of existing infrastructure#2020-02-2710:10djanushas anyone stumbled into something similar before?#2020-02-2711:20thheller@dj942 I suspect its a classpath issue. shadow/js.js should be on the classpath. boot does a lot of dynamic classpath magic so its easy to miss stuff#2020-02-2711:20thheller(all JS code depends on shadow.js since that is the glue putting it all together)#2020-02-2711:21djanusI just noticed that boot-shadow was using shadow-cljs 2.8.14; I've added an exclusion and manually specified 2.8.83, seems to be working now#2020-02-2719:51flyboarderCould you open a PR for this issue if updating fixes it, also where did you pin the new shadow version in your project?#2020-02-2815:54djanusI've pinned it in (set-env! :dependencies ...) in build.boot:
[degree9/boot-shadow "2.8.14-0" :scope "test" :exclusions [thheller/shadow-cljs]]
                   [thheller/shadow-cljs "2.8.83"]
#2020-02-2816:02djanusI'll try to whip up a PR when everything is working, but can't promise when#2020-02-2711:22djanus(had to bump clojure to 1.10 as well, because tap>)#2020-02-2711:22thhellerthats really no different#2020-02-2711:22thhellershadow.js existed in .14 too#2020-02-2711:23thhellerstill good to update though#2020-02-2711:23djanusyeah, i see#2020-02-2711:23djanusno idea why .83 is more boot-friendly#2020-02-2711:24djanusanother question: with shadow-cljs, are React externs necessary to produce working release builds of reagent apps?#2020-02-2711:24thhellerlikely no but maybe yes 😛#2020-02-2711:24djanusI'll check 🙂#2020-02-2711:25thhellerI haven't used manual externs in a long time 😛
#2020-02-2711:25thhellerjust turn on :infer-externs :auto and you probably won't need any#2020-02-2711:26djanusawesome! thanks for shadow-cljs#2020-02-2711:26djanusit's my first foray into it and I'm amazed at how polished it is#2020-02-2711:37robert-stuttafordfair warning: you need manual externs for datascript
:compiler-options {:infer-externs :auto
                   :externs ["datascript/externs.js"]}
#2020-02-2711:44djanusthanks! I'm not using datascript, but it's still handy to keep in mind#2020-02-2711:45djanus(it's also strange... why would a cljs library need externs?)#2020-02-2712:02thhellerbecause they don't follow the rules 😛#2020-02-2712:43rickmoynihanI’m trying to figure out how to require and use a react-modal (https://github.com/reactjs/react-modal) Modal component in my reagent/shadow-cljs project… I’ve added react-modal to package.json and re run yarn and added the line (:require ["react-modal" :as react-modal]) to my ns form#2020-02-2712:43rickmoynihando I need to add a line like: (js/goog.exportSymbol "Modal" react-modal) too?#2020-02-2712:43thhellerno#2020-02-2712:44thhelleronly if you want an actual js/Modal global (which you shouldn't)#2020-02-2712:45rickmoynihanhow do I get a handle on Modal?#2020-02-2712:45thhellerwhat do you mean? you have it right there? react-modal?#2020-02-2712:45rickmoynihanI was thinking it was like FlipMove here https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md#creating-reagent-components-from-react-components#2020-02-2712:46rickmoynihanreact-modal/Modal? gives me a reference error#2020-02-2712:46thhellerI'm not sure what you are asking? [:> react-modal ...]#2020-02-2712:47rickmoynihansorry slightly out of my depth in the react/js/cljs ecosystem#2020-02-2712:47thhellerif react-modal only has one export which is the actual modal then just use that directly#2020-02-2712:48thheller(:require ["react-modal" :as Modal]) then [:> Modal ...] if that makes it clearer?#2020-02-2712:48rickmoynihan👍 thanks that makes sense looks like it does just have one export too: https://github.com/reactjs/react-modal/blob/master/src/index.js#2020-02-2712:48rickmoynihanwill try#2020-02-2712:48thhellerok thats a default export#2020-02-2712:49thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-02-2712:49thhellerso it might be (:require ["react-modal" :default Modal])#2020-02-2712:49thhellerdepends on how the package is actually bundled unfortunately#2020-02-2712:58rickmoynihanok I think I’ve got it working now with :as Modal. Thanks a million for your help!#2020-02-2715:29DerekRelease 2.8.88 seems to have broken the Inspect tab for me#2020-02-2715:31Derek
worker.js:126 WebSocket connection to '' failed: Error during WebSocket handshake: Unexpected response code: 403
#2020-02-2718:57thheller@dpassen1 see https://github.com/thheller/shadow-cljs/issues/660. it restricts access to localhost by default. how are you accessing it?#2020-02-2719:00DerekRunning npx shadow-cljs watch app on my dev machine and opening up a web browser to port 9000 (we override the port for the shadow-cljs dashboard http server)#2020-02-2719:00Dereksame machine#2020-02-2719:00Derekno containers#2020-02-2719:01thhellerhmm forgot that websockets don't show the actual output#2020-02-2719:01thhellerhttp://localhost:9000/api/tool#2020-02-2719:01thhellerwhat do you get when you load that page?#2020-02-2719:01thhellerprobably using ipv6 by default?#2020-02-2719:03Derekipv6#2020-02-2719:03Derek
0:0:0:0:0:0:0:1 not trusted. Add :trusted-hosts #{"0:0:0:0:0:0:0:1"} in shadow-cljs.edn to trust.
#2020-02-2719:05thhellercan you add that to shadow-cljs.edn to test?#2020-02-2719:05thhellerI'll add it as a default too#2020-02-2719:05Derekyep#2020-02-2719:07Derekfixes it for me#2020-02-2719:35Derekwhen you work on shadow, what is your workflow? I was looking at adding a ‘name’ config option to the webservers for discoverability for our new engineers#2020-02-2720:47thhellerhttps://github.com/thheller/shadow-cljs/blob/master/CONTRIBUTING.md#2020-02-2720:48DerekThank you#2020-02-2720:48thhellerbut currently requires a bit of additional setup since https://github.com/thheller/shadow-experiments has no formal release yet but is required by the ui#2020-02-2720:48DerekAh. I think I saw this error last night#2020-02-2720:48Dereka grove ns that wasn’t found#2020-02-2720:49thhelleryeah you need to check out the experiments manually too#2020-02-2720:57DerekWould you be opposed (in advance) to naming http-servers?#2020-02-2720:58DerekWhen we start our app in development, we serve the dashboard at 9000, a version with api routes proxied to a local port on 9010, a version with api routes proxied to a remote dev instance on 9020, and the tests on 9999#2020-02-2720:59DerekI’d love to have some way of identifying them on the dashboard#2020-02-2721:07thhellerhow would you configure them?#2020-02-2721:09Derek
{:dev-http
 {9010
   {:root "..."
    :short-name "..."}
  9020
   {:root "..."
    :short-name "..."}
 ...}
#2020-02-2721:09Dereksomething like that#2020-02-2721:12thhellerI'd prefer :display-name#2020-02-2721:12Derekyeah#2020-02-2721:12thhelleror just :name is fine too I guess#2020-02-2721:12Dereki don’t want to shadow a built in#2020-02-2721:13thhelleryeah as you can tell from the pr-str maybe I don't quite know how to display them#2020-02-2721:14thhellerthe roots typically are enough for me#2020-02-2721:14DerekIf we had one, I’d agree#2020-02-2721:14DerekHow does shadow.experiments.grove/<< handle nil?#2020-02-2721:14thhellerits fine#2020-02-2721:15DerekOk cool. It makes sense to guard it behind a when or when-let#2020-02-2720:24otwieraczHmm. I wanted to use shadow-cljs just for REPL at this moment - so I had no builds defined (I do not target browser yet). But I was unable to run shadow-cljs in Calva in VSCode due to something something nil error (builds list was empty).#2020-02-2722:40pezSeems like an issue in Calva. #2020-02-2721:38kaoskodo I have some kind of version conflict with dependencies when I get this: The required namespace "goog.html.TrustedResourceUrl" is not available, it was required by "goog/html/safeurl.js".#2020-02-2721:38thhelleryes#2020-02-2721:38thhellerclosure-library#2020-02-2721:40thhellerkinda weird I guess but not sure what else it would be#2020-02-2721:41kaoskohow do I fix it?#2020-02-2721:42thhellerI don't know. what do you use? lein? deps.edn?#2020-02-2721:42kaoskolein#2020-02-2721:42thhellerlein deps :tree and fix the conflicts#2020-02-2812:57rickmoynihanDoes anyone have any idea what might be stopping a reagent component hot code reloading on save in shadow-cljs? The parent component re-renders on save fine; but changing code in the non-reloading component only works on a page refresh 🤔#2020-02-2813:00rickmoynihanI have a single ^:dev/after-load set on the exported fn that binds my app component to the DOM with r/render#2020-02-2813:03rickmoynihanahh I have some warnings I might want to clean up to do with unique prop keys#2020-02-2813:12rickmoynihanhmmm one thing that’s strange is the * Components view in chrome dev tools, shows the parent component is registered twice into the hierarchy; as a sibling next to itself… but only one of them has child components#2020-02-2813:12rickmoynihannone of the others are like this#2020-02-2814:17thheller@rickmoynihan hard to say without seeing some code#2020-02-2814:18thhellermaybe try setting :devtools {:reload-strategy :full} in your build config (only works if you have the latest shadow-cljs version)#2020-02-2814:32rickmoynihaninteresting that seems to work! 👍#2020-02-2814:32rickmoynihanwhat does it do exactly?#2020-02-2814:32rickmoynihanhold on checking manual 👀#2020-02-2814:33thhellerits not in the manual. added it recently because a lot of people seem to rely on it#2020-02-2814:34thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-02-2814:38rickmoynihan> It also is essential that all your data is kept in a central place since hot-reloading gets a lot more complex if data is spread all over the place. Even to the point of not being useful at all anymore. Does this mean it’s problematic having more than one r/atom?#2020-02-2814:39rickmoynihanI currently have a few defonce ’d r/atom s#2020-02-2814:43thhellerI don't use reagent. If that workflow works for you then keep doing it.#2020-02-2816:07knubieIs there a recommended way to cache dependencies? Currently I’m thinking of caching the ~/.m2/repository directory, and creating a hash from .shadow-cljs/classpath.edn to invalidate. (This is for a CI environment BTW).#2020-02-2816:08thhellercan't really use classpath.edn since it won't exist between CI runs?#2020-02-2816:08thhellerjust shadow-cljs.edn should be fine#2020-02-2816:08knubieOh, true#2020-02-2816:09knubieOh yeah haha, thank thheller!#2020-02-2817:59haywoodI’m getting a :shadow.build.npm/js-invalid-requires on this code:
return _interopRequireWildcard(require("".concat(
        /* webpackChunkName: "icon.[request]" */
        // It's important that we don't use a template string here, it
        // stops webpack from building a dynamic require context.
        // eslint-disable-next-line prefer-template
        './assets/' + typeToPathMap[iconType] + '.js')))
#2020-02-2818:00haywoodmy guess is it’s the dynamic path creation. does anyone have intuition if I should try to solve this on the shadow or library side?#2020-02-2819:00haywoodhttps://github.com/thheller/shadow-cljs/issues/486#2020-02-2819:00haywoodNM#2020-02-2819:53tekacsI was going to ask if client IP whitelisting could be updated to use ring.middleware.proxy-headers.wrap-forwarded-remote-addr (i.e. X-Forwarded-For) but for some baffling reason, it sets :remote-addr to the /last/ address in X-Forwarded-For which is a proxy and usually user-controllable, respecting what was user-sent (the /first/ address is the original client IP) :man-facepalming:#2020-02-2821:17thhellershadow-cljs doedn't use that middleware so I'm not sure what you are referring to#2020-02-2821:18tekacsI was going to propose its use, is all 🙂#2020-02-2821:18tekacsI solved my forwarding issue by port forwarding /to/ the network address of my local machine rather than loopback, which fixes :remote-ip to always appear to be 192.168.xx.xx rather than 127.0.0.1 🙂#2020-02-2821:19tekacsunfortunately still facing the issue in https://github.com/thheller/shadow-cljs/issues/662 (to which I replied, hopefully providing enough info now)#2020-02-2821:41Jakub Holý (HolyJak)I wonder, when I run npx shadow-cljs watch :main and then connect to the NRepl started by shadow, I have to execute (shadow/repl :main) in the repl to actually get into the cljs repl. Is there some way to automate this so that shadow/repl would start automatically instead of me typing it every time?#2020-02-2821:43thhellerunfortunately no since the client has to setup its sessions#2020-02-2821:56tekacsWith that last change the setup now works perfectly @thheller -- thanks so much for responding and working through this!#2020-02-2823:40colinkahnis getting The required namespace "cljs.user" is not available. when saving files via a connected repl a known issue?#2020-02-2900:47mynomotoI got those, then I created an empty namespace cljs.user and they were gone.#2020-02-2904:00fbelinesilly question: Is it possible to inject a dependency (like we do with lein profile) for a re-frame project with shadow-cljs?#2020-02-2907:04tianshuIt's the default namespace after cljs/quit configurable ? I want to back to shadow.user instead of user.#2020-02-2909:47thheller@fe.belineb no, only if you use project.clj/deps.edn to manage your dependencies#2020-02-2909:47thheller@doglooksgood that is a function of your tool most likely. nrepl should be restoring the ns you were previously in.#2020-02-2909:48thheller@colinkahn not sure. in which context?#2020-02-2919:11colinkahn@thheller If I'm watching multiple builds and I connect to one via nrepl/piggieback, when I save a file I'll get that compilation error for the connected build.#2020-02-2919:12colinkahnI can see if I can make a minimum repo later#2020-02-2912:21Ben RodenhäuserI have been setting up a shadow-cljs project, and hot reloading only worked after I added the last line below in shadow-cljs.edn:
:builds
  {:app
   {:target :browser
    :modules {:main {:init-fn app/init}}
    :devtools {:after-load app/init}}}} 
Is this expected? I can’t help but feel I did something wrong in order for that line to become necessary.
#2020-02-2914:01thheller@ben477 not sure what you mean. telling the compiler which function to call after reloading has always been necessary#2020-02-2914:05Ben Rodenhäuser@thheller Even better, looks like I didn’t do anything wrong then! (I am a shadow-cljs newbie). Thanks for the answer#2020-02-2915:09thheller@ben477 FWIW the more "modern" version uses metadata directly on the functions but using the build config is fine too https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2020-02-2923:12tekacsI'm using the library {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0766697363473329372937"}, :content ("[email protected]")} and finding that pulling in their Timeline component is pulling in their entire @ant-design/icons and @ant-design/icons-svg libraries. They've explicitly refactored in 4.0.0 to ensure that the icons can be tree shaken.#2020-02-2923:13tekacsMy import looks like:
(:require ["antd/es/timeline" :default ATimeline])

(def AItem (.-Item ATimeline))
I'm following their instructions for pulling it in modularly: https://ant.design/docs/react/introduce#Use-modularized-antd And the upstream library's import of icons (inside the distributed version of Timeline.js) looks like this:
import { LoadingOutlined } from '@ant-design/icons';
#2020-02-2923:13tekacsMy import looks like:
(:require ["antd/es/timeline" :default ATimeline])

(def AItem (.-Item ATimeline))
I'm following their instructions for pulling it in modularly: https://ant.design/docs/react/introduce#Use-modularized-antd And the upstream library's import of icons (inside the distributed version of Timeline.js) looks like this:
import { LoadingOutlined } from '@ant-design/icons';
#2020-03-0109:08thhellerit is modularized if you use the babel plugin to do it for you. since shadow-cljs doesn't use babel that doesn't work.#2020-03-0117:00tekacsI don't believe that's correct @thheller -- the manual option is an /alternative/ to the babel plugin (as per those docs), and all of the upstream files are in separate files. Again, note that ant-design 4.0.0 (which just came out) is designed this way -- versions prior to this definitely pulled in all of the icons as a monolithic chunk, but this time around they've split into many independent JS files for this exact reason...#2020-03-0117:03tekacs@ant-design/icons/LoadingOutlined.js is a file, which imports ../lib/icons/LoadingOutlined.js which imports @ant-design/icons-svg/lib/asn/LoadingOutlined.js Is the entire NPM library simply pulled in, even if only a subset of it is used (explicitly, through JS imports)?#2020-03-0117:09thhellershadow-cljs imports whatever it is told to import#2020-03-0117:09thhellerit does NOT perform webpack like tree shaking for npm deps#2020-03-0117:13tekacsThat makes perfect sense -- in manually following the imports around however (starting from the /inner/ JS file that the above imports), I don't see anything that should pull in the entire library. I'll try using JS tools to follow requires and figure out why this might be pulling in so much.#2020-03-0117:14tekacsI don't suppose there's any way to have shadow expose how or why it decided to pull in certain imports? Or a recommended way of checking that?#2020-03-0117:21tekacsSo it looks like, at a guess, this is happening because import { LoadingOutlined } from @ant-design/icons is only able to find the inner icon through @ant-design/icons/index.js and shadow keeps all of the files that are re-exported through there, rather than just the component that was required?#2020-03-0117:22thhelleronly @ant-design/icons this is relevant yes#2020-03-0119:03tekacsI approached this for now by overriding resolution for @ant-design/icons with an override file which re-exports only the used icons. I also filed an issue upstream to ask them to change their imports: https://github.com/ant-design/ant-design/issues/21744 I'll also spend some more time trying to understand: • Whether it's possible to use tsickle to generate externs for TypeScript NPM modules. • Whether there's an easier way to pre-process upstream modules for only the required imports and their dependencies.#2020-03-0121:12thhellerFWIW the main issue is that there is no real standard for any of this and that the closure compiler as such doesn't support it#2020-03-0121:12thhellerit would in theory be possible to implement but that would be a significant amount of work#2020-02-2923:14tekacsbut despite this, the build seems to pull in the entire library for both#2020-02-2923:18tekacsAnd I've validated (by replacing ATimeline and AItem with stubs) that if I remove the require above, that the build report loses all of the ant-design files, so it's definitely those requires that are pulling in the entire library.#2020-03-0104:38cobyI ran into that exact problem. My solution was to stop using ant-design. 😢#2020-03-0122:04tekacs@UH85MNSKE in case you ever want to come back to ant, here's my override file, which I provide to shadow-cljs like this:
:builds
{:app
 {:js-options
  :js-options
   {:resolve {"@ant-design/icons" {:target :file :file "overrides/ant-design-icons.js"}}}
  ... }}
#2020-03-0122:08cobyThanks! I really like the design system, I just didn't have time to figure out how to prune it :)#2020-03-0106:41deep-symmetryHello, everyone! I’m a Clojure developer diving for the first time into ClojureScript work, and was pointed at shadow-cljs in response to a question on the #clojurescript channel, and am already delighted at how it is helping me, but I am sure I will have a bunch of questions along the way. The first one is, I can’t seem to get a cljs REPL working in CIDER. And I fear the answer may simply be “that’s because your project doesn’t support that kind of operation.” But I want to be sure.#2020-03-0106:43deep-symmetryI’m building a Node library, whose purpose is a function that takes as input an EDN string and returns an SVG string. So, there is no server that is running, it’s just a script. Which might be why CIDER complains that there is no cljs REPL even after I seem to have jacked in?#2020-03-0106:50deep-symmetryHmm. I just tried killing everything and jacking back in, and get:
;;  Startup: /usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.23.0-SNAPSHOT server
;;
;; ClojureScript REPL type: node
;; ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
;;
Execution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:29).
Assert failed: (keyword? repl-env)
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0-SNAPSHOT (package: 20190618.716) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user>
#2020-03-0106:51deep-symmetrySo, it seems kind of connected, but when I do things in my .cljs buffer that needs a REPL, CIDER still complains about there being no CLJS REPL available.#2020-03-0108:03deep-symmetryBut there is no urgency: I have been able to complete my port to ClojureScript successfully! This is huge, I am finally going to be able to retire LaTeX, and will be able to create the kinds of beautiful packet diagrams that its bytefield package offered by instead using a Clojure-based DSL inside Asciidoc documents. Woo hoo!#2020-03-0108:39deep-symmetryHere’s the embryonic project, in case anyone’s curious: https://github.com/Deep-Symmetry/bytefield-svg#2020-03-0109:14thheller@deep-symmetry that doesn't look like you are using the correct setup on the cider side. this is not the command it should be using the shadow-cljs.
ClojureScript REPL init form: (do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))
#2020-03-0109:14thhellerI don't use cider and don't know how to configure it but that is the wrong command#2020-03-0223:59deep-symmetryIt turns out if I start npx shadow-cljs node-repl in the terminal before I try to connect CIDER, it works! This will make me much happier as I continue to evolve this project. And the ease with which shadow-cljs allowed me to build a Node module is just delightful.#2020-03-0109:15thhellerdunno how current/accurate this still is https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2020-03-0203:03deep-symmetryOk, thanks. I guess CIDER has fallen behind in their auto-configuration for shadow-cljs. (I didn’t change anything in the configuration.) Working without a REPL was painful, but thankfully it was only a small, focused task! Next time I do more ClojureScript work I will see if they have fixed it, or dig deeper.#2020-03-0112:20otwieraczHey, in shadow-cljs.edn I've got :main target of type :browser which produces UI. I also have .clj foo.core/init function for backend and API. What's the proper way of starting backend together with frontend? shadow-cljs watch main obviously only keeps .js file up to date.#2020-03-0112:21thhellershadow-cljs only handles CLJS related things. CLJ server you need to run separately#2020-03-0112:22otwieraczBut shadow-cljs also provides clj-repl... Was I wrong expecting shadow-cljs to cover both backend and frontend tasks?#2020-03-0112:22otwieracz(ie for full-stack apps?)#2020-03-0112:23thhellerit is literally in the name shadow-cljs#2020-03-0112:23thhellerit is written in CLJ so you can run CLJ code ... but there is no specific support for anything "backend"#2020-03-0112:29otwieraczSo for full stack it's expected to work with lein or boot?#2020-03-0112:39thhelleror plain deps.edn yes#2020-03-0112:40thhelleryou are not gonna be using shadow-cljs in production so why tie your development server to it#2020-03-0113:33otwieraczYeah, that's right.#2020-03-0113:34otwieraczBut it seems super useful for development to just fire shadow-cljs clj+cljs repl instead of clj and shadow separately.#2020-03-0205:04jjttjjIs it possible in shadow to depend on a library which bundles a js library and provides externs? specifically I'm trying to use https://github.com/cjohansen/dumdom . I have a shim file which looks like
(ns snabbdom
  (:require ["snabbdom" :as snabbdom]))

(js/goog.exportSymbol "snabbdom" snabbdom)
But this line is triggering an error: https://github.com/cjohansen/dumdom/blob/dd7cbae5e1b03892a068410e246cd44dcaeb8cbf/src/dumdom/core.cljs#L20
Failed to load dumdom/core.cljs TypeError: Cannot read property 'create' of null
    at Object.exports.init (snabbdom.js:39)
    at eval (core.cljs:23)
(All the properties of js/snabbdom used on that line are coming up nil)
#2020-03-0209:38thheller@jjttjj the issue is that the namespace can't be the same name as the exported symbol#2020-03-0209:38thhellerrename it to cljsjs.snabbdom and then manually ensure it is loaded before dumdom#2020-03-0218:03jjttjjthis worked, thanks!#2020-03-0210:25mkvlrgiving shadow a try on a new project and really impressed with it so far#2020-03-0210:26mkvlrcan I also do es6 module imports over http like in the first example in https://github.com/observablehq/runtime#observablehqruntime?#2020-03-0210:43thheller@mkvlr not currently no. seems like a really bad idea to do that too 😛#2020-03-0210:45mkvlrin the case of http://observablehq.com, I’m not so sure.#2020-03-0210:46mkvlrbut you’re probably right#2020-03-0210:47thhellerwell it probably isn't any worse than npm so there is that 😛#2020-03-0210:48thhellerbut its all mirrors to npm anyways so you get the same stuff#2020-03-0210:51mkvlrI was looking at the observable’s way to require notebooks as es6 modules.#2020-03-0210:55mkvlrso https://api.observablehq.com/@tmcw/hello-world.js?v=3 is https://observablehq.com/@tmcw/hello-world as a es6 module#2020-03-0210:56thhellerwell yeah but not exactly#2020-03-0210:56thhellerit still requires the runtime bits#2020-03-0210:56mkvlrright, but that I can require from npm#2020-03-0210:57mkvlrbut I think I can use import to import things from notebooks#2020-03-0210:57thhellernot sure what you are trying to build but what would you statically want to include a notebook in a build?#2020-03-0210:57thhellerthis runtime things seems explicitely built to be used dynamically?#2020-03-0210:58thhelleryou can always just curl the notebook and include it in your build if you really want#2020-03-0211:00mkvlrright, I’m also not quite sure what I’m building here yet 😼 well thanks for shadow & your help!#2020-03-0211:01thhellerFWIW adding support for an URL resolver wouldn't even be that hard but I'm not so sure it is a good idea#2020-03-0211:02thhellerthere is a lot of stuff going on in the JS world so we'll see where this all goes 😛#2020-03-0218:59jaimeHello. How to properly setup devcards in shadow-cljs? This does not seem to work
;; shadow-cljs configuration
{:source-paths
 ["src"
  "test"
  "tailwind.config.js"]

 :dependencies
 [[reagent "0.9.1"]
  [metosin/reitit "0.4.2"]
  [binaryage/devtools "1.0.0"]
  [devcards "0.2.6"]]
 

 :builds
 {
  :devcards {:target :browser
             :output-dir "devcards"
             :asset-path "/"
             :compiler-options {:devcards true
                                :source-map-timestamp true}
             :modules {:devcards {:entries [limeray.web.app-test]}}
             :devtools  {:http-port 9003
                         :http-root "devcards"}}}}

;; limeray.web.app-test

(ns limeray.web.app-test
  (:require
   [cljs.test :refer [testing is use-fixtures]]
   [devcards.core :as dc]
   [reagent.core :as r]
   [limeray.web.components :as ui]
   ["@testing-library/react" :as rtl])

  (:require-macros
   [devcards.core :refer [defcard deftest]]))

(enable-console-print!)


(defcard my-first-card
         (r/as-element [ui/date-picker]))


(defn ^:export init []
  (dc/start-devcard-ui!))
#2020-03-0219:00thhellerdo you call the init fn via the HTML?#2020-03-0219:10jaimeI just added it now
{:type :dtd, :data ["html" nil nil]}
BUt having this error
//cljs-runtime/devcards.core.js:101 Uncaught TypeError: devcards.system.start_ui is not a function
#2020-03-0219:14thhellerthe :asset-path is incorrect for one#2020-03-0219:15thhellernote the incorrect path with //#2020-03-0219:15thhellertry :asset-path "/"#2020-03-0219:18jaimeoh yeah sorry. I updated the build config, changing the asset-path and http-root under devtools
:devcards {:target :browser
             :output-dir "devcards"
             :asset-path "/"
             :compiler-options {:devcards true
                                :source-map-timestamp true}
             :modules {:devcards {:entries [limeray.web.app-test]}}
             :devtools  {:http-port 9003
                         :http-root "/"
                         :preloads [devcards.core]}}}}
#2020-03-0219:19jaimeI also added preloads#2020-03-0219:20jaimeHere is the screenshot of browser error#2020-03-0220:29thheller:http-root was correct. / is definitely incorrect#2020-03-0317:26jaimecan't make it work. I'll skip this for now. thanks a lot for your help#2020-03-0317:27jaime😅#2020-03-0414:34SchpaaHaving the same problem#2020-03-0414:34SchpaaReact is not defined#2020-03-0414:35SchpaaBut I’m using shadow from lein#2020-03-0414:37thhelleryou probably need to require cljsjs.react and maybe cljsjs.react.dom since devcards doesn't declare its dependency on react for some reason#2020-03-0414:40SchpaaI’ll try that#2020-03-0414:46Schpaano luck#2020-03-0414:48thhellerwhats the issue?#2020-03-0414:50Schpaagetting the exact same output as Jaime above#2020-03-0414:51thhellerand what is your config?#2020-03-0414:51SchpaaReact not defined and devcards.system.start-ui is not a func#2020-03-0414:51thhellerdid you ensure that you have required cljsjs.react *BEFORE* loading devcards?#2020-03-0414:51Schpaa#2020-03-0414:52Schpaa#2020-03-0414:52thhellerremove that preload#2020-03-0414:53thhellerotherwise isn't load devcards before the react ...#2020-03-0414:53thhellerand the :preloads isn't useful in the first place#2020-03-0414:54Schpaa“otherwise isn’t load devcards before the react ...” which means?#2020-03-0414:55SchpaaI can get it to work using plain shadow (without lein)#2020-03-0414:55thheller"otherwise it will load ..."#2020-03-0414:55Schpaasomething with those React definitions which gets lost#2020-03-0414:55thhelleryou shouldn't use lein-shadow. I hate that its the default but I absolutely advise against using it.#2020-03-0414:56thhellerwhat is your updated config?#2020-03-0414:56Schpaathe same, sans the preload#2020-03-0414:57thhellerdid you restart so lein-shadow can write it to disk so shadow-cljs can pick it up? (really stop using lein-shadow)#2020-03-0414:57Schpaayes I did#2020-03-0414:57thhellerand what is the error?#2020-03-0414:58Schpaasame thing#2020-03-0414:58Schpaano wait#2020-03-0414:58Schpaait works ??#2020-03-0414:58Schpaawtf#2020-03-0414:58SchpaaI dont like this#2020-03-0414:58Schpaaso you would recommend staying away from lein-shadow#2020-03-0414:59Schpaafirst time I hear this, but since its from you it counts#2020-03-0415:00thhelleryes, IMHO its a pointless plugin#2020-03-0415:00thhellerthe luminus authors wanted to have ALL config in project.clj#2020-03-0415:00thhellerwhich I personally think is pointless#2020-03-0415:00Schpaayeah, I get your point#2020-03-0415:00Schpaathanks for your input!!#2020-03-0219:01Felipe MarquesHi, guys, I'm trying to run a select a nrepl nrepl-select and starting it on a specific namespace, but I don't find any documentation for the opts parameter of the nrepl-select to use it. I tried to use init-ns but didn't work.#2020-03-0219:04thheller@marques.goncalves.fel that is not an option you can pass to nrepl-select. that needs to be configured directly on the nrepl server#2020-03-0219:07Felipe Marques@thheller sorry if it is a basic question. But in this case, this configuration would be in the shadow-cljs.edn correct? In trying to use the init-ns to get a repl directly in the dev namespace where I have a lot of utility functions that I use. But this is specific for me, I wouldn't like to pollute the shadow-cljs.edn with my specific dev environment.#2020-03-0219:09thhellerideally your editor would just issue the command to switch to a given namespace when you connect#2020-03-0219:09thhelleror you could maybe bind that to a key#2020-03-0219:09thhellerotherwise yes shadow-cljs.edn in the build config via :devtools {:repl-init-ns some.foo}#2020-03-0220:30tekacs@ctamayo ant-design fixed their imports upstream in response to my issue, so that tree shaking works out of the box with shadow now: https://github.com/ant-design/ant-design/issues/21744#2020-03-0220:35cobyNice! I'd seen they were working on it, thanks for the update#2020-03-0300:29deep-symmetryIs there a shadow-cljs equivalent to lein ancient?#2020-03-0309:24teodorluIf you're using Shadow-CLJS with deps.edn, you can use olical/depot. Here's my global deps.edn alias:
:outdated
       {:extra-deps {olical/depot {:mvn/version "1.8.4"}}
        :main-opts ["-m" "depot.outdated.main"]}
#2020-03-0317:09deep-symmetryThanks! At this point I only have a shadow-cljs.edn, I am unclear as to what adding a deps.edn would do, wouldn’t that be two different places to specify the dependencies which could get out of sync?#2020-03-0411:28teodorluYou can ask Shadow-CLJS to use deps.edn to speficy dependencies: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn This functionality is in place just to avoid the duplication you're (rightly) reluctant to create. The advantage being that you can plug into the rest of the ecosystem for deps.edn / tools-deps 🙂#2020-03-0416:14deep-symmetryThat’s awesome! Thanks so much for pointing me in that direction.#2020-03-0416:15deep-symmetryTime to learn deps.edn#2020-03-0308:28kaffeinHi friends! does anyone here have experience with code reloading in a Cordova + cljs + shadow-cljs stack please ? I am really interested if you could point me to a resource I can pick ideas from. Thanks in adv#2020-03-0319:04achikinDid anyone manage to make shadow-cljs work with Cursive?#2020-03-0319:04achikinI’ve managed to connect to remote shadow server, but Send to repl does not work properly#2020-03-0319:05achikin
(+ 1 1)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: + in this context
#2020-03-0319:05lilactownI think thheller (the author) uses Cursive as his main editor#2020-03-0319:05thhelleryep, works fine for me#2020-03-0319:06thheller@achikin I think you get that result if you (in-ns 'foo.bar) without having (require 'foo.bar) first, ie. switching before actually loading#2020-03-0319:06thhelleralso I think thats a CLJ error ...#2020-03-0319:08achikinStill the same after (in-ns)#2020-03-0319:08achikinLooks like Cursive does not pick up the namespace properly#2020-03-0319:09thhellermaybe you are doing something wrong 😛#2020-03-0319:10thhellerwhat are you doing?#2020-03-0319:10thhellerand which mode are you expecting to be in?#2020-03-0319:11achikin#2020-03-0319:11achikinI’m running shadow-cljs watch app in a separate terminal and trying to connect to it with Cursive remote repl#2020-03-0319:13thhellershadow-cljs doesn't create a port file you can use by default#2020-03-0319:13thhellerdid you enable that manually?#2020-03-0319:14achikinI have a script that copies that file from .shadow-cljs/nrepl.port to .nrepl-port#2020-03-0319:14thhellerah ok#2020-03-0319:14thhellerso you are then connected to the shadow-cljs CLJ repl#2020-03-0319:14thhellerwhat do you do next?#2020-03-0319:15achikinAh, that’s a clj repl…#2020-03-0319:15thhelleryes, always#2020-03-0319:15thhelleryou switch via (shadow.cljs.devtools.api/repl :app)#2020-03-0319:15thhellerDO NOT manually use the Cursive select box#2020-03-0319:16achikinWhich box?#2020-03-0319:16thhellerthere is a clj/cljs select box in the REPL window#2020-03-0319:16thhellerDO NOT EVER USE THAT! 😛#2020-03-0319:16achikinThat’s what I did 🙂#2020-03-0319:16thhellerok yeah thats your problem then#2020-03-0319:16achikinThank you!#2020-03-0319:17thhellerif you do the repl command above it should automatically switch to CLJS#2020-03-0319:17achikinIs there any way to make Cursive run (shadow.cljs.devtools.api/repl :app) automatically?#2020-03-0319:17thhelleryou can use :cljs/quit to switch back to CLJ#2020-03-0319:17thhellerno I don't think so#2020-03-0319:17thhellerbind it to a repl command and keyboard shortcut 😉#2020-03-0319:18achikinMaybe provide some custom :in-ns that contains that command?#2020-03-0319:19achikinI mean :init-ns#2020-03-0319:20thhellerno its mostly a nrepl session issue#2020-03-0319:20thhellerthe client session needs to be initialized so it must be something the client sends#2020-03-0321:11kaoskoI'm sure this is more of a node/closure/javascript question, but how the heck do I import a path? (I'm trying to import parts of three.js into my cljs app). All I get is: Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)#2020-03-0321:13dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-03-0321:15kaoskoyeah, from cljs I have no problem importing npm modules or even files paths from the source-paths, but this is inside a js file that wants to import other js files#2020-03-0321:15dpsuttonoh i see.#2020-03-0321:15dpsuttonhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#2020-03-0321:20kaoskothanks, incidentally I'm on that page. the original js did
import { OceanShaders } from "../shaders/OceanShaders.js";
but that results in undefined. any other form results in "Cannot import Closure files by path..."
#2020-03-0321:42Aleedif you’re consuming js files via shadow-cls make sure the js files you’re importing are inside a registered cljs path (or inside you’re node_modules)#2020-03-0322:18kaoskoyeah they are, I can require them in cljs#2020-03-0322:26thhellerwould help to have a complete example to look at. can't quite figure out what you are doing.#2020-03-0322:36kaoskoin cljs, I am doing:
(:require
 ["/jsm/misc/Ocean" :as ocean]
that Ocean.js tries to import OceanShaders.js with:
import { OceanShaders } from "../shaders/OceanShaders.js";
OceanShaders there passes compilation but comes up as undefined. Elsewhere, I rewrote a similar syntax to:
import * as three from 'three';
const {...} = three;
to make it work. If I try to rewrite similarly:
import * as OceanShadersLib from "../shaders/OceanShaders.js";
const {OceanShaders} = OceanShadersLib;
it'll fail with: Closure compilation failed with 1 errors jsm/misc/Ocean.js:64 Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
#2020-03-0322:37thhellersorry I need to see this in actual files otherwise my brain has issue putting things together 😛
#2020-03-0322:40kaoskoI could make a barebones project demonstrating this but you probably don't want to see all of these files, there's a lot. but this issue comes from closure compiler and I'm not quite sure why it cares#2020-03-0322:41thhellerwell .. first of all the closure-compiler does NOT understand how shadow-cljs processes npm deps#2020-03-0322:42thhellerso basically it doesn't see three#2020-03-0322:42thhellerso its absolutely easily possible for it to get confused#2020-03-0322:42thhellerespecially if you mix import/export ESM style with commonjs require#2020-03-0322:42thhellerand/or files NOT having either of those#2020-03-0322:43kaoskono, the three part is fine. it's importing from the the path that's the issue#2020-03-0322:43thhellershadow-cljs isn't really meant to compile JS projects. it is very lacking in that regard. its possible for easy stuff but I haven't put much work into the full support#2020-03-0322:44thhellerif you setup a reproducible example I can take a look but otherwise there are too many unknowns for me that I cannot reconstruct from slack threads#2020-03-0322:44kaoskoyes, I understand. I'm not sure though whether it's the closure compiler that is the limitation of if you could even do something about it in shadow#2020-03-0322:45kaoskoor, if there's something I can do to easily make it into a pseudo(?) module#2020-03-0322:47thhellermaybe ... impossible for me to say.#2020-03-0322:48kaoskoor, if I can just require it in cljs and just kind of make it visible to the js. I don't know, really don't know enough about all these npm, esm modules or requires#2020-03-0322:50thhellerlisten ... I do want to help you but I can't without knowing more about what you are doing#2020-03-0322:51thhellerI know a lot about npm, esm, modules, requires, etc but NOTHING about your actual code/setup so you might see the problem#2020-03-0322:54kaoskoyes, thanks for replying. I really just wanted to see if it's possible to work with an existing large js codebase and cljs. it's basically this: https://github.com/mrdoob/three.js/blob/dev/examples/webgl_shaders_ocean2.html#2020-03-0322:56kaoskothe latest version of three.js npm module includes all examples on the same level as the build folder#2020-03-0322:56kaoskobut it's really not packaged as an npm module#2020-03-0323:06kaoskoI was reading https://github.com/google/closure-compiler/wiki/JS-Modules and I guess the module resolution mode at least explains why referring to the npm module in js works. I don't know, perhaps passing the source-paths to the closure compiler with --js would work#2020-03-0323:06thhellerFWIW I compiled it just fine and have it running#2020-03-0323:07kaoskowhat's the closure compiler version you are using?#2020-03-0323:07thheller2.8.90#2020-03-0323:08thhellerbut :advanced doesn't work so I'd stop right there 😛#2020-03-0323:11thhellerI guess the thing I might have done differently is not using three from npm#2020-03-0323:12thhellerjust used the file from the build dir, moved it to the examples folder and adjusted the path accordingly#2020-03-0323:12thhellerbut yeah .. use webpack or something for large JS codebases. that is not the focus of shadow-cljs#2020-03-0323:21kaoskook, yeah I considered doing that, i.e. dropping the three.js as npm dependency but I had of course started from that end and things in general worked well with shadow and npm deps#2020-03-0323:22kaoskobut no, I'd rather drop or rewrite the js dependencies in cljs than integrate the rest with webpack#2020-03-0321:47Aleedcan we specificy specific node_modules to transpile in shadow-cljs config?#2020-03-0321:48Aleedi can’t find mention of this in docs, so either it’s undocumented or I imagine @U05224H0W you’ve decided against it? Building a react-native-web app and stumbled upon a module that isn’t transpiled 😓#2020-03-0322:26thhellerclarify what you mean by transpile#2020-03-0322:26thhellershadow-cljs performs no "transpile" from other JS dialects at all#2020-03-0322:42Aleedi.e. i’m getting an invalid token error because package includes es6 module statements#2020-03-0322:45thhellerlike what? I mean are you sure its es6 and not typescript or something?#2020-03-0322:59Aleed
export * from './SQLite';
^^^^^^

SyntaxError: Unexpected token 'export'
    at Module._compile (internal/modules/cjs/loader.js:896:18)
#2020-03-0323:01Aleedthe linked file is .js and only includes export statements so pretty sure it’s just that the node_module needs to be compiled?#2020-03-0323:27Aleedi’m going to be running into this a lot since not all react-native packages transpile their code. wondering how to best handle it#2020-03-0323:30thhelleruhm#2020-03-0323:30thheller
SyntaxError: Unexpected token 'export'
    at Module._compile (internal/modules/cjs/loader.js:896:18)
#2020-03-0323:31thhellerthat is an error from node?#2020-03-0323:31thhellerbut yeah SQLite isn't transpilable .. it is C.#2020-03-0323:31thheller(it'll not run in the browser)#2020-03-0323:32thhellerwell if thats the actual sqlite and not just a namespace named that way of course 😛#2020-03-0323:34Aleedah yeah sorry, in this specific case it’s a node error - i’m trying to use expo-sqlite in an electron app#2020-03-0323:35thhellershadow-cljs is not involved in loading the code then so there is nothing you can configure#2020-03-0323:35thhellermaybe you can configure electron to support ESM. in node thats behind a flag.#2020-03-0323:36Aleed
:desktop-main
  {:target :node-script
   :output-to "apps/desktop/dist/index.js"
   :main rf.app-desktop.main/start}
#2020-03-0323:36Aleed^ i’m using shadow for the main process too#2020-03-0323:37Aleedas a node script#2020-03-0323:37thhelleryep and you are relying on require. so shadow-cljs processes no npm deps whatsoever#2020-03-0323:38Aleedoh got it, that makes sense then#2020-03-0323:38Aleedthanks for explaining#2020-03-0321:56Pavel KlavíkHi, my build got recently broken on Windows 10 due to
Cannot run program "java" (in directory "M:\libs\myproject"):
  CreateProcess error=206, The file name or extension is too long
which basically means that leiningen computes too many classpaths. I was googling little bit around and one suggested solution is to add plugin
[lein-classpath-jar "0.1.0"]
Which solves that problem but creates a new problem while compiling shadow-cljs release build. I am doing this in lein by
["run" "-m" "orgpad.build/release"]
whose code is the following
(ns orgpad.build
  (:require [shadow.cljs.devtools.api :as shadow]))

(defn release []
  (let [version (System/getenv "HEROKU_SLUG_COMMIT")]
    (shadow/release :client {:config-merge [{:release-version version}]})))
But it fails with the error:
Warning: implicit hook found: lein-classpath-jar.plugin/hooks
Hooks are deprecated and will be removed in a future version.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
[:client] Compiling ...
The required namespace "orgpad.client.core" is not available.
Compiling directly using shadow-cljs release client works fine. Any ideas what is wrong?
#2020-03-0322:27thheller@pavel.klavik looks like your sources just aren't on the classpath maybe?#2020-03-0322:32Pavel Klavíkif I remove that plugin, everything compiles fine, haven't done any changes to it recently#2020-03-0322:33thhellerI don't know that plugin so no clue#2020-03-0322:34thhellermaybe you are activating different profiles? no clue what you whole setup looks like#2020-03-0322:57isakAre you sure lines 3+ are related to the first 2? Because I have the same thing, and get the first 2, but not the rest @pavel.klavik#2020-03-0323:17Pavel Klavíknot really, it is something which always displays when I start java app, not sure what they mean#2020-03-0323:18Pavel Klavíkis it possible to use different plugins for different lein rules? so I could fix it for now by having it only on lein run, but not on lein uberjar?#2020-03-0400:09Pavel KlavíkSo I studied little bit how leiningen profiles work and moved this plugin into my user profile, so my local development works but the plugin is not used during deployment. It works as a temporary solution and we will solve a better dev setup in the future.#2020-03-0412:36wilkerluciohello, is there a way to keep a watch running for a release build? wanting to debug something that only happens on release#2020-03-0412:49thhellerno, that would be impractical#2020-03-0412:50thhellerjust have a shadow-cljs server instance running and trigger shadow-cljs release app --pseudo-names manually when needed (or via a REPL keybind)#2020-03-0412:56mishaidk, why shadow-cljs even exists, if you can do this kappa: https://github.com/davesann/cljs-hash/blob/master/src/cljs_hash/md5.cljs#L5-L10#2020-03-0412:58thhellerhaha ... I don't know why that library exists when the closure library has a perfectly fine md5 impl 😛#2020-03-0412:58thhellerbut yeah don't do that 😛#2020-03-0413:04mishait's 7 years old, but yeah. discoverability is still somewhat a problem#2020-03-0413:09mishathank you for shadow-cljs again, it alleviates a lot of pain#2020-03-0413:41Saikyunhow would one use polyfill with shadow-cljs? 🙂 I need to target internet explorer... :'D#2020-03-0415:36Aleeddid you try just importing your polyfill file? you can even import in a js file and then require the cljs output yourself, i.e.
require('some-polyfill.js')
require('public/js/main.js')
#2020-03-0507:03Saikyunthanks for the info. I'm gonna try what thheller suggested first#2020-03-0414:22Schpaawho uses shadow-cljs with devcards?#2020-03-0414:25yendaWhen working on react-native screens, the code is recompiled but nothing is re-rendered unless the home screen or a top bar code is changed. Is it a limitation or just poor setup? (note that rn fast refresh is disabled)#2020-03-0414:27Pavel KlavíkHi, I am using shadow/release function to build my release. How can I detect that the build fail the rest of the build process as well?#2020-03-0414:35thheller@yenda upgrade to the latest version and try :devtools {:reload-strategy :full} in your build config#2020-03-0414:48yendadammit you are amazing#2020-03-0414:53yendathanks it works perfectly#2020-03-0414:36thheller@pavel.klavik I guess if it doesn't return :done? Its really meant as an api method for the REPL so it caches and pretty-prints exceptions#2020-03-0414:36thhellerI guess I could add a release! fn that just throws and doesn't catch the error#2020-03-0414:38achikinRegarding https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2020-03-0414:38achikinWhat happens if my js file requires e.g. semantic-ui-react itself?#2020-03-0414:38achikinWill shadow-cljs resolve it?#2020-03-0414:39thhellerit will but there are a couple known issues so it might not work#2020-03-0414:39achikinWhat kind of issues?#2020-03-0414:40thhellerwell it either works or it doesnt 😛#2020-03-0414:40thhellerthe biggest issue is mixing commonjs with ESM code#2020-03-0414:41thhellersince the closure-compiler thinks all npm code is commonjs it may effect how it treats the classpath js#2020-03-0414:39Pavel Klavík@thheller thx, will take a look#2020-03-0414:40achikinRe: babel jsx processing - is there any way to hook that into shadow-cljs server so I don’t need to run babel as a separate process?#2020-03-0414:41thhellerno, it is recommded to run it separately#2020-03-0414:46SaikyunI tried adding :js-options {:babel-present-config {:targets {:ie 8}}} to my shadow-cljs.edn, but I still get "Promise not defined" in iexplorer... any suggestions? 😄#2020-03-0414:52achikin:babel-preset-config#2020-03-0414:53achikinCould be a typo#2020-03-0506:28Saikyunoh, haha, nice catch!#2020-03-0414:46thheller@saikyun that only affects npm code, it has no effect if your CLJS code uses js/Promise#2020-03-0414:47Saikyunoh I see. is there a way to babel the cljs code as well?#2020-03-0414:48thhelleryou can use third party polyfills like https://polyfill.io/v3/ if you want to inject the polyfills only for ie#2020-03-0414:48Saikyunah, cool. I'll try that then#2020-03-0414:49Saikyunthanks!#2020-03-0415:03achikinWhat is :babel-preset-config? Is there any doc for it?#2020-03-0415:04thhellerno docs no since you basically should never ever use it#2020-03-0415:23yendathe hotreload of shadow is so much faster than react-native fast-refresh lambdalove#2020-03-0506:25SaikyunI just want to note that if even shadow-cljs hotreload feels slow (e.g. when iterating on an animation), putting the function call you want to play around with at the top-level then using a repl + load-file gives you amazing response times 🙂#2020-03-0506:25Saikyune.g. like so:
(defn start-animation [] ,,,)

(start-animation)
then load-file at the repl, preferably using a hotkey 😄
#2020-03-0506:26Saikyunif you want to go even faster (especially in a big file) you can use eval-defun, i.e. only eval the function you're modifying#2020-03-0506:27Saikyunand that's something that's hopeless with "regular" react native#2020-03-0514:54knubieI’ve noticed the hot reloading stops working a lot on my build, do you guys ever run into that? Any ideas for how to debug?#2020-03-0717:23yendahave you tried the config
:dev {:devtools {:autoload true
                            :reload-strategy :full
                            :after-load app.core/reload}}
#2020-03-0717:24yendaI had an issue with some routes never hot-reloading or only when some specific parts were changed, and :reload-strategy :full did the trick#2020-03-1013:28knubieHaven’t tried that, but sounds promising. Thanks!#2020-03-0415:32thhellergood to know. never seen fast-refresh in action yet 😛#2020-03-0415:33thhellerhttps://twitter.com/JacekSchae/status/1235171128441819137#2020-03-0416:14Chris LittleI'm curious about a note from a couple days ago, about :devtools {:reload-strategy :full} Before enabling :deps true , live reloading would include updates to files under node_modules. Now after enabling, I have to use reload-strategy to get that functionality. I'm just curious why the deps modes are different in this way?#2020-03-0417:09awb99is it possible to serve resources from classpath from jar files via the shadow-cljs devtools web server ?#2020-03-0417:48jplazaHello everyone 👋! Users of shadow-cljs: What would you tell a hesitant CLJS user like me who has been refraining from using shadow-cljs because it is not “the official tool”, to convince them of making the switch? Thanks in advance for your comments.#2020-03-0417:59aisamuIf you rely heavily on npm, don't think twice! It's not that much different, theller knows more about CLJS internals than I ever will and he's incredibly responsive here, even when we fail to read the extensive documentation :)#2020-03-0418:10kasukoI tell you this, if you are using the official tool then you're doing it the hard way and anything including shadow-cljs will be better. Of course this assumes you're using the actual "official" way which is compiling the source by using the cljs.jar file and running it manually. If however you are under the assumption some other way is the "official" way (like figwheel) then you've been misled and you're already off the beaten path!#2020-03-0423:46sogaiuout of curiosity, what is "the official tool"?#2020-03-0502:07jplazaI had a misconception about shadow-cljs, I thought it was some sort of fork of the CLJS compiler#2020-03-0502:07sogaiuthanks for the clarification#2020-03-0417:58thheller@jplaza what makes a tool official? shadow-cljs is just as official as figwheel is?#2020-03-0417:59thheller@hoertlehner sure, set :dev-http {8080 "classpath:foo"}#2020-03-0418:00thheller@chrislittle1986 :reload-strategy is not affected by using :deps true or not.#2020-03-0418:00awb99@thheller: thanks! Does :dev-http replace :devtools {:http-root "public" :http-port 8020}#2020-03-0418:01awb99?#2020-03-0418:01thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2020-03-0418:01thhelleryes, it replaced that quite some time ago#2020-03-0418:14awb99many thanks @thheller!!#2020-03-0418:12jplazaThanks @thheller for the reply and for creating this cool tool! I probably used an incorrect term. I’m really looking for better NPM support, having to rely on CLJS is a drag. What I’m kind of worried is: how would our source code be affected if npm support becomes official by the CLJS compiler?#2020-03-0418:13jplazaI’m probably not understanding how things actually work and asking non-sense but was worth the try 🙂#2020-03-0418:14thhellerthe method of including npm dependencies is an abtraction controlled via :js-provider. so should CLJS ever get "different" support its just another method you can select#2020-03-0418:22jplazaThanks again it seems I was making a big deal of it. It might be related to the fact the some years ago when I first saw shadow-cljs I thought it was some sort of cljs compiler fork#2020-03-0418:23thhelleryeah the name seems to confuse a lot of people#2020-03-0418:24thhellerbut even if it became a compiler fork ... does that really matter as long as everything you write is still standard CLJS code that you can at any time compile with other tools?#2020-03-0418:24thhelleryou can emulate the npm support shadow-cljs has today in regular CLJS by using the webpack method#2020-03-0418:25thhellerthe non-standard things are cleary marked in the docs and you don't have to use them#2020-03-0418:47jplazaI will definitely give it a try these days. Not having up-to-date npm deps is sometimes frustrating.#2020-03-0418:15thhellerbesides that as long as you don't use shadow-cljs specific features (there aren't that many) then you can just compile with the "default" cljs tools#2020-03-0418:17kasuko@thheller I'm here for the same problem as @chrislittle1986 though I'd like to clarify a bit. We are using shadow-cljs inside of a monorepo. We have other pure Javascript libraries in that monorepo. For development purposes we have been using npm link to symlink the dependencies inside our node_modules and that has been working great! If we make a change to the Javascript library shadow-cljs would pick-up the changes via the symlink and recompile and everything was awesome! However, we recently switched to using tools.deps for our maven dependencies so we could the use :local provider and get the same setup for our Clojurescript libraries. It seems like enabling :deps true has in some way prevented shadow-cljs from picking up changes to our Javascript files and recompiling now. These seems strange to me and probably is something else but I'm not sure where else to look.#2020-03-0418:19thhellerin general node_modules code is not hot-reloadable or only in a very limited way but I don't see how deps.edn affects it in any way#2020-03-0418:28kasukoIs there any difference between watching changes to required .cljs file and watching changes to required .js files?#2020-03-0418:30thhellernode_modules is watched differently yes but thats always the case. again not related to :deps true#2020-03-0419:14kasukoYep, you are right it appears to be a version thing. I bisected the change down to version 2.8.67 will pick up changes to .js files where as 2.8.68 no longers picks up changes to .js files#2020-03-0419:15thhellerright yes I changed node_modules watching#2020-03-0419:15thhellersince it was commonly watching way too many files that weren't hot-reloadable anyways#2020-03-0419:16thhellerbut yeah npm link behavior would likely change#2020-03-0419:20kasukoWould it be difficult to restore but behind a configuration flag? We rely pretty heavily on this feature.#2020-03-0419:21kasukoI can open an issue on GitHub and give it a go if you're open to an MR.#2020-03-0419:22thhelleryou rely on it how? the new logic only watches the package.json for modification (timestamp is enough) so "touch package.json" should be enough to trigger a shadow-cljs compile?#2020-03-0419:26kasukoFor example we have a Javascript library that we write all of our GraphQL queries in .graphql files. This library uses graphql-tag webpack-loader to compile those files into queries for ApolloClient (the GraphQL client we use) webpack watches for any changes to the .graphql files and will output new .js files which shadow-cljs read in from the node_modules directory (due to npm link) and would then reload any namespaces that use those compiled queries.#2020-03-0419:26kasukoWe can just constantly touch the package.json file but that's pretty much the equivalent of just re-running compile every time we make a change#2020-03-0419:29thhellerwhat kind of code does this generate? why do you have to do this as a npm module?#2020-03-0419:30thhellerif you open an issue I can take a look. I didn't consider that people would be actively working on npm packages while using them in shadow-cljs#2020-03-0419:30thhellerso I might reconsider supporting that again but I need to think about it first#2020-03-0419:31kasukoOkay, would an example setup in a repository help?#2020-03-0419:31thhellerit was definitely causing issues for other people since checking thousands of files every second is quite a lot of work that is pointless 99% of the time 😛#2020-03-0419:32thhellerexamples always help yes#2020-03-0419:32kasukoCool, I will get that set up and then create an issue#2020-03-0419:35Chris LittleAre there options in shadow-cljs to tell it to watch a specific folder under node_modules? That wouldn't be ideal in our case, since we'd have to start maintaining a list of npm link'd packages, but it seems like we have to do that for the "local" overrides in deps.edn anyway#2020-03-0418:20thhellerthe only "difference" that deps.edn might have is that more code can come from local files vs .jar files#2020-03-0418:20thhellerso if anything it might start reloading more?#2020-03-0514:57defaI’m using https://github.com/juxt/tick in a :react-native target and the app will crash when running as a production build: shadow-cljs release app there is some information related to this library and shadow-cljs: https://github.com/henryw374/tick-on-shadow-cljs-demo that does not help with production builds. However, using shadow-cljs compile app before ./gradlew assembleRelease to skip optimisations will result in a working app. Any hints? I read the excellent documentation to shadow-cljs but seem to have missed something. Thanks in advance!#2020-03-0515:21knubieCouple of things you can try in :compiler-options: :optimizations :simple and :infer-externs :auto#2020-03-0515:25defaI have :compiler-options {:infer-externs :auto} but there is no hint to what I could change to make thinks work. As a workaround :optimizations :simple probably works but having :advanced compilation working is preferred.#2020-03-0515:29defatick depends on js-joda-time which is normally pulled in with cljsjs based deps… so my guess is, that js-joda.time* gets yanked by the compiler because they are not considered as used. Just an idea…#2020-03-0515:40defaThe device log shows the crash as:
--------- beginning of crash
2020-03-05 16:39:19.966 1894-1923/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: , PID: 1894
    com.facebook.react.common.JavascriptException: TypeError: this.wh is not a function. (In 'this.wh()', 'this.wh' is undefined), stack:
    
#2020-03-0516:13thhellerthats definitely caused by missing externs#2020-03-0516:14thhellermight just be missing externs in the tick library since :infer-externs :auto only warns about your sources#2020-03-0516:14thhellerone quick way to find out what that originally was is running shadow-cljs release app --pseudo-names and looking at the log#2020-03-0516:15thhellerit'll be "`this.$someThing$` is undefined"#2020-03-0516:15thhellerthen you edit externs/app.txt and add someThing (one line)#2020-03-0516:15thhellerthat should fix it#2020-03-0516:26defaCool, thanks @U05224H0W will try later, when back at the keyboard...#2020-03-0517:21defaTried shadow-cljs release app --pseudo-names and only got one warning:
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit/impl/writer.js:256:8
 variable isObject is undeclared
--------------------------------------------------------------------------------
nil
but nothing like “`this.$someThing$` is undefined”
#2020-03-0517:24defaHowever running shadow-cljs check app gives me tons of warnings (> 500) many related to the tick library:
------ WARNING #547 -  ---------------------------------------------------------
 File: ~/.m2/repository/tick/tick/0.4.23-alpha/tick-0.4.23-alpha.jar!/tick/core.cljc:1055:61
--------------------------------------------------------------------------------
1052 |   LocalDateTime
1053 |   (in [ldt z] (.atZone ldt z))
1054 |   (offset-by [ldt offset] #?(:clj (.atOffset ldt (zone-offset offset))
1055 |                              :cljs (.atZone ldt (zone-offset offset))))
-------------------------------------------------------------------^------------
 Property atZone never defined on ldt__$1
--------------------------------------------------------------------------------
#2020-03-0517:24thhellerthe error you get at runtime#2020-03-0517:24thheller
--------- beginning of crash
2020-03-05 16:39:19.966 1894-1923/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
    Process: , PID: 1894
    com.facebook.react.common.JavascriptException: TypeError: this.wh is not a function. (In 'this.wh()', 'this.wh' is undefined), stack:
    
#2020-03-0517:24thhellerthis thing ...#2020-03-0517:24thhellercheck unfortunately produces a lot of noise#2020-03-0517:25defaOkay, sorry… thought with log you meant shadlow’s output.#2020-03-0517:25thhelleryou can comb through those and those look like likely candidates#2020-03-0517:25thhelleryou can also just include the tick externs it has by default if you want#2020-03-0517:37defaHere we go, found the missing externs in the device log:
E/ReactNativeJS: TypeError: this.$toLocalDate$ is not a function. (In 'this.$toLocalDate$()', 'this.$toLocalDate$' is undefined)
… put it in externs/app.txt, rebuild the apk and now it no longer crashes. Thank you very much Sir!
#2020-03-0517:38defaRegarding tick’s “externs it has by default”, where would I find those? Didn’t find them in the repo?#2020-03-0517:52thheller:compiler-options {:externs ["cljsjs/js-joda/common/js-joda.ext.js"]} in your build config#2020-03-0517:52thhellerhttps://github.com/cljsjs/packages/blob/master/js-joda/resources/cljsjs/js-joda/common/js-joda.ext.js#2020-03-0518:47defaOf course! I looked for the externs in tick 🙈#2020-03-0518:55defaSo I guess adding thheller/shadow-cljsjs as a dependency would have fixed the problem as well?#2020-03-0518:59thhellerno that wouldn't have done anything#2020-03-0518:59thhellerit isn't related to this in any way#2020-03-0518:59thheller(and shadow-cljs already depends on that anyways so it is always there ...)#2020-03-0521:33michael.heubergerMorning. Has anyone ever managed to resolve npm dependencies installed by shadow-cljs in cursive? Cursive always displays these as “x cannot be resolved”. This because the npm dependencies are in package.json but not project.clj - Cursive seems to only scan those in project.clj. Thoughts?#2020-03-0521:34cflemingSadly, this doesn’t work yet - it’s on my list to fix.#2020-03-0521:34michael.heubergerAh#2020-03-0521:36michael.heuberger@U0567Q30W is there a github ticket for that yet?#2020-03-0521:48michael.heubergermaybe this one? https://github.com/cursive-ide/cursive/issues/1804#2020-03-0521:50cflemingYou know, I actually don’t think there is an issue for that - 1804 is different, that’s about integrating Shadow directly into Cursive.#2020-03-0521:50cflemingIf you could file an issue that would be great.#2020-03-0522:01michael.heubergerhere you go https://github.com/cursive-ide/cursive/issues/2333#2020-03-0522:42cflemingThanks!#2020-03-0708:01tianshucan I make shadow-cljs only bundle parts of javascript that is required? or should I use double bundle with webpack instead?#2020-03-0708:32thheller@doglooksgood not sure what you mean. shadow-cljs always only bundles javascript that is required?#2020-03-0709:49tianshu@thheller I see, I means sometime a javascript file may include other files. like
require A from "a";
require B from "b";

module.exports {
  a: A,
  b: B
}
since there's an object that contains a and b, If I require this file in cljs, both a and b will be bundled no matter I use them or not.
#2020-03-0709:55tianshuBut in library like https://github.com/FortAwesome/react-fontawesome#explicit-import It is said, when using webpack, explicit import will let you to only bundle what you need. import { faCoffee } from '@fortawesome/free-solid-svg-icons' only include the faCoffee, even though '@fortawesome/free-solid-svg-icons' represent a index.js that require all files.#2020-03-0710:15thheller@doglooksgood yes that style is not supported. however you can probably just do ["@fortawesome/free-solid-svg-icons/faCoffee" :as faCoffee] (maybe :default not :as) to get the same effect?#2020-03-0710:28tianshuYes, I can use this way#2020-03-0710:30tianshuIs it possible to use closure compiler to optimize javascript library, or how can I know if a library can be optimized by closure compiler?#2020-03-0710:31thhellerif the library is purely strict ESM and only have strict ESM dependencies then in theory it can be optimized by the closure compiler#2020-03-0710:31thhellerin practice at least on npm that never happens#2020-03-0710:32thhellereg. react/react-dom is not provided as strict ESM#2020-03-0710:32tianshuESM means ES module?#2020-03-0710:32thhelleryes#2020-03-0710:34tianshuI just curious about, what if, ClojureScript do dead code eliminate by its compiler and don't rely on closure library and closure compiler ? is it a good direction in your sight?#2020-03-0710:35thhellerin theory that would be nice yes. in practice it doesn't work with a very large percentage of npm packages (I'd guess 90%+)#2020-03-0710:36thhellerif they ever get their act together and follow the standards then maybe that gets better over time. today it is not practical#2020-03-0710:37tianshuemm, why you think it doesn't work with most npm packages?#2020-03-0710:37thhellerI don't think .. I know 😛#2020-03-0710:38thhellerreasons vary .. either they include "dynamic" code that isn't compatible with the closure-compiler#2020-03-0710:38thhellermost of them ship as commonjs without strict ESM compatibility#2020-03-0710:38thhelleror just include some transpiled garbage ...#2020-03-0710:39thhelleryou can try setting :js-options {:js-provider :closure} in your build config#2020-03-0710:39thhellerthat will make everything go through closure-compiler :advanced compilation#2020-03-0710:39thhellerit has not worked in a single build I have tried#2020-03-0710:39thhelleryou can sort of get it to work with lots of manual tuning#2020-03-0710:40thhellerbut that is rarely worth the effort#2020-03-0710:40tianshuIf react and react-dom not work with closure compiler, my build will never work:joy:#2020-03-0710:41tianshuIf ClojureScript drop closure compiler, and act like a babel transpiler, is it possible?#2020-03-0710:41tianshutypo, label -> babel#2020-03-0710:41thhellersure, if you want to drop the closure-compiler. I have no interest in that.#2020-03-0710:46tianshuI don't see closure library is wildly used by clojurescript programmers and libraries. It almost provide everything but just not be considered as mainstream, and looks like few people and libraries use it.#2020-03-0710:47thhellerits not about the closure-library. it is about the closure-compiler.#2020-03-0710:47thhellermost people see it as a negative for some reason. for me its just positive so I have no interest whatsoever in efforts to replace it.#2020-03-0710:47tianshuI think closure library is part of the value of closure compiler?#2020-03-0710:48thhelleryes, it is a bonus#2020-03-0710:48tianshuyou mean closure compiler provide optimizations, that's good choice, no matter use closure library or not, you will still use closure compiler?#2020-03-0710:48thhelleryes#2020-03-0710:48tianshumake sense.#2020-03-0710:49thhellerFWIW I think it would have some value if the CLJS compiler just emitted strict ESM code#2020-03-0710:49thhellerthat would open up more tool options#2020-03-0710:50thhellerbut I would under no circumstance get rid of the closure-compiler in my builds#2020-03-0710:52thhellerbut many things we love in clojurescript and rely on are not possible with strict ESM code (eg. hot-reload, REPL) so it would need to be transpiled to something else to enable that#2020-03-0710:52thhellerwhich brings us basically back to where we are now 😛#2020-03-0711:07tianshuThree years before, the hot-reload is a magic, but know it's just a standard. Almost every JavaScript toolchain support that.#2020-03-0711:13thhellerdunno ... last time I tried it really didn't work all that well#2020-03-0711:13thhellerbut its been a while so presumably things got better#2020-03-0711:18tianshuI don't have any experience of F# and Fable(F# on JS), but how fable work is just implement a loader, and configure it in webpack.
{
        test: /\.fs(x|proj)?$/,
        use: {
          loader: "fable-loader",
          options: {
            babel: babelConf
          }
        }
}
#2020-03-0711:19thhelleryou seem to see webpack as a positive. I don't 😛#2020-03-0711:19thhellerif you want to build a loader go do that. many people would be interested in that I think.#2020-03-0711:20tianshuI don't think webpack is positive, it's too complex. But sometimes I still need that simply import some css or fonts.#2020-03-0711:20thhellerI made comments about why I'm not interested in webpack loaders in the past so you should be able to find it#2020-03-0717:32Aleedjust an fyi for others, I was curious and found the discussion here: https://github.com/thheller/shadow-cljs/issues/123#issuecomment-340246560#2020-03-0711:20tianshualright#2020-03-0711:21thhelleryeah we need a good tool for importing css or fonts#2020-03-0711:25tianshuthere are several levels, for I) I don't want use JS syntax, II) I don't want use JS build tool, III) I don't want use JS lib repository(npm), IV) I don't want JS dependency#2020-03-0711:25tianshu😂#2020-03-0711:28thhelleryep, some npm access is nice but it is never my preferred choice 😛#2020-03-0714:46frozarHi, I'm trying to put in place some test and I would like to know which namespace shadow-cljs found when it scan my project. Is there a way ask which test namespace has been found by shadow-cljs?#2020-03-0716:00thheller@fabien.rozar ask how? I mean do you want to ask "does namespace x.y.z exist?", meaning direct lookup by name?#2020-03-0720:07tekacsFor what it's worth I just use shadow.resource to load CSS into my app#2020-03-0720:08tekacsI wrote something small akin to style-loader and just use that#2020-03-0720:08tekacshttps://gist.github.com/tekacs/302eb450f99b511e609ca54de48eeb5e @doglooksgood#2020-03-0720:10tekacsshould be easy to do something very similar for fonts, etc.#2020-03-0720:14tianshu@tekacs thanks! The idea is load the file in macro and insert into <script> in runtime?#2020-03-0720:14tekacsright#2020-03-0720:14tekacsso rc/inline pulls the file into the build#2020-03-0720:14tekacsand tracks it as an incremental depenency#2020-03-0720:14tekacsso that if you change the CSS it instantly reloads#2020-03-0720:15tekacsand then the rest of the code simply puts it into the head as a script tag with a sourcemap#2020-03-0720:18tianshugreat, how about the untrack? I mean, when my code don't rely on a CSS file#2020-03-0720:20tekacssorry, what does that mean?#2020-03-0720:20tekacsyou mean unloading it, or ensuring that it's not pulled in?#2020-03-0720:29tianshuyes#2020-03-0720:30tianshuI guess shadow use this internally, so it should be okay.#2020-03-0720:30tianshufinally I could get rid off webpack.#2020-03-0813:27grumpletUI options#2020-03-0813:33frozar@thheller I was looking for a way to ask "shadow-cljs, list me the namespace you're able to find given the :source-paths I gave you". I was interested in this because the namespace of my tests was not detect, because the regex a supply didn't match it (silly thing). But I finally fix it ^^#2020-03-1006:30otwieraczHey, do you have any suggestions how to import https://adazzle.github.io/react-data-grid/docs/quick-start properly so I get the function? No matter what I try, I got undefined when checking with (goog/typeOf) or object (which seems empty) when trying with ["react-data-grid" :as ReactDataGrid]))#2020-03-1008:44ouvasamDid you you tried ["react-data-grid" :default ReactDataGrid]#2020-03-1008:44ouvasam?#2020-03-1008:44ouvasamor ["react-data-grid" :refer (ReactDataGrid)]#2020-03-1009:35otwieraczRight now I am fighting with other issue... I am not able to load webpage becasue:#2020-03-1009:37otwieraczthousands of errors like that#2020-03-1009:37thheller@UB0EMUD34 which version are you on? or did you manually set :loader-mode :script?#2020-03-1009:38otwieraczNo, I haven't.#2020-03-1009:38otwieracz"shadow-cljs": "^2.8.52"#2020-03-1009:39thhellerthen you can either set :devtools {:loader-mode :eval} in your build config or upgrade (which sets that as a default)#2020-03-1009:39thhellerdrastically reduces the number of requests which fixes cases like yours where you are loading too many files at once#2020-03-1009:52otwieraczLet me try...#2020-03-1009:57otwieraczStill thousands of requests with 2.8.91#2020-03-1009:57otwieracz
{:deps     {:aliases [:dev]}
 :nrepl    {:port    9000
            :init-ns user}
 :dev-http {8000 "resources/public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn spreadnotes.client/init}}
                   :devtools   {:after-load spreadnotes.client/init
                                :preloads   [com.fulcrologic.fulcro.inspect.preload]}}}}
#2020-03-1009:57otwieraczIs there something inherently wrong here?#2020-03-1009:58thhellerI don't see the :loader-mode?#2020-03-1009:59thhellerif you upgraded I guess you updated the npm install but no the reference in deps.edn?#2020-03-1009:59otwieraczah ok#2020-03-1009:59otwieraczlet me try once again...#2020-03-1010:03otwieraczcli version: 2.8.91 node: v8.17.0#2020-03-1010:03otwieraczstill thousands of files.#2020-03-1010:03otwieraczBut wait, maybe it didn't recompiled yet#2020-03-1010:04thhellerit says cli version
#2020-03-1010:04thhellerthe only version that matters here is whatever you have in deps.edn#2020-03-1010:04otwieracz(both deps and package.json are updated to .91 - but maybe it hadn't recompiled yet)#2020-03-1010:04otwieraczMaybe this was false alarm. 🙂 Let my try once again.#2020-03-1010:20otwieracz10 requests#2020-03-1010:20otwieraczawesome :]#2020-03-1010:20otwieraczThank you!#2020-03-1012:07Mikko HarjuHi, has anyone fiddled around with replumb + shadow-cljs? I'm trying to convert a personal project of mine to shadow-cljs and it uses replumb to provide cljs evaluation. Everything else seems to be working quite well but evaluation of anything that touches the CLJS runtime library (like trying to invoke let , def , +) raises a warning :undeclared-var , and it seems to think that the function should be found in the current ns.#2020-03-1012:16Mikko HarjuCould this have to do with the module not having all the necessary runtime-stuff in it? I'll try to look into that one.#2020-03-1012:30Mikko HarjuOK, it seems that there is indeed something different in the setup. If I explicitly evaluate
(js/goog.require "cljs.core")
(cljs.core/+ 1 1)
I get the expected output of 2. 🙂
#2020-03-1012:46thhellerself-hosted stuff is done via the :bootstrap target. pretty sure thats a full replacement to replumb though. see https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for an example#2020-03-1012:48Mikko HarjuWow. Cool 🙂 So I could ditch replumb alltogether and just use that one? I'll take a look. Can you elaborate a bit (if you have time) could replumb be used at all, what is the fundamental thing that is different in figwheel vs. shadow-cljs in this regard?#2020-03-1012:49thhelleryou can still use replumbs. just need to use the shadow bootstrap stuff#2020-03-1012:49Mikko Harju:+1:#2020-03-1012:50thhellerI honestly can't remember all the details but basically the :bootstrap target will pre-compile sources and the host build will just load them (instead of compiling itself)#2020-03-1012:50thhellerit works differently because this way there is one unified way to load stuff#2020-03-1012:51thhellermeaning adding dependencies and using them is easy#2020-03-1012:51Mikko HarjuOK. I'll dig into this. Thanks again!#2020-03-1012:51thhellerotherwise cljs.core was treated as special and extra deps were hard#2020-03-1013:02Mikko Harju@U05224H0W works now. I'll continue using replumb for now, but will consider transitioning to the one given in the blog post since it seems fairly straightforward. Thanks again!#2020-03-1013:04yendais there a way to export functions with :target :node-library so that they have the async keyword AWS lambda needs it and it looks like it's not working when just returning a promise in the cljs function that we export For async handlers, you can use return and throw to send a response or error, respectively. Functions must use the async keyword to use these methods to return a response or error. Here what the aws lambda doc is asking for:
const https = require('https')
let url = ""

exports.handler = async function(event) {
  const promise = new Promise(function(resolve, reject) {
    https.get(url, (res) => {
        resolve(res.statusCode)
      }).on('error', (e) => {
        reject(Error(e))
      })
    })
  return promise
}
#2020-03-1014:44yendanvm I was just confused, aws async lambda execution isn't what we wanted, it doesn't reply when the promise resolves, it just replies right away with empty 200 and keep execution going in the bg. The exported fn was working as expected#2020-03-1014:44thheller@yenda there is also no such thing as the async keyword at runtime. that is just syntax sugar for a function returning a promise#2020-03-1014:44thhellerso if you just return a promise then your function is effectively async#2020-03-1014:45yendayes I figured, thanks#2020-03-1017:50Prometheusany good libraries/tips and tricks for doing configuration (such as yogthos/config) in shadow-cljs?#2020-03-1019:47yendaif you want to read from a file or env variables , you can use a macro to slurp at compile time#2020-03-1019:49Prometheushmm what sort of macro would that look like?#2020-03-1110:20mavbozowe use a kind of load-config macro combined with :closure-defines goog/ENV like this code sketch
(defmacro load-config []
  `(if (= js/goog.ENV "prod")
     ;; prod config
     (load-from-file "prod-config.edn")
     ;; dev config
     (load-from-file "dev-config.edn")))
#2020-03-1110:22mavbozothe macro is just a .clj file (not .cljs file) and :closure-defines is in shadow-cljs.edn#2020-03-1111:44Prometheushmm cool so load from file and then set the variables#2020-03-1019:28davewoDoes the -A:alias cli option override {:deps {:aliases [:alias]}} in shadow-cljs.edn?#2020-03-1019:38thheller@davewo not overwrite, add#2020-03-1100:50MatDHi! I'm new to shadlow-cljs and I'm searching for a better testing workflow. I'm targetting a nodejs project and right now I have a :node-test target working, which is great, but the console output is a bit plain and I'm looking for editor integration to spot any failure more easily and focus on failing tests directly in an editor. I tried VSCode Calva, but the tests commands dont work with shadow-cljs yet. Is it better with Cursive or Cider ?#2020-03-1101:10cflemingI’m not sure about Cider, but sadly Cursive’s test integration doesn’t work with CLJS yet.#2020-03-1108:39pezCalva uses CIDER's tech for testing, so I doubt it will look any better there... Wdys@U051BLM8F?#2020-03-1108:41bozhidarSame with CIDER - the test middleware currently supports only Clojure.#2020-03-1108:42bozhidarHandling ClojureScript is not rocket science and would mostly involving piping some ClojureScript evals to the eval middleware, as obviously we can’t run ClojureScript directly, as we do with Clojure.#2020-03-1104:11dodoIs there a way to set repository infomation, like the maven using settings.xml or lein using ~/.lein/profiles.clj ?#2020-03-1107:15Mikko HarjuI'm using https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html as the basis for self-hosting a compiler in an application. It works well on development, but if I try to do release with it, it complains about not having access to goog -namespace. It seems to be loading the bootstrap stuff from the output folder I have assigned but the evaluation itself fails. I'm using re-plumb for now, is it something to do with that? Should I just stop using it and switch to the built-in one mentioned in the blog post instead?#2020-03-1107:22Mikko HarjuIf I test the https://github.com/mhuebert/shadow-bootstrap-example.git example and do a release build, it complains about the same:
base.js:5319 Uncaught ReferenceError: goog is not defined
    at eval (/js/bootstrap/js/75b50edc.cells.lib.js:1)
    at eval (<anonymous>)
    at Object.goog.globalEval (base.js:251)
    at Object.shadow.cljs.bootstrap.browser.script_eval (base.js:5513)
    at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (base.js:5516)
    at base.js:5526
    at goog.async.run.processWorkQueue (base.js:5326)
#2020-03-1107:23Mikko HarjuOn lein & figwheel the release build with simple optimizations worked. Do I need to deploy the development version as is in order for this to work with shadow-cljs?#2020-03-1109:09thheller@U32ST9GR5 you need to set :compiler-options {:optimizations :simple} for your "host" build. :advanced (the default) is not supported.#2020-03-1109:12thhelleroh and you might need to disable :compiler-options {:output-wrapper false} too#2020-03-1109:30Mikko Harju@U05224H0W the optimizations: simple was already in place. I'll add the output-wrapper and see what happens!#2020-03-1109:33Mikko Harjuoutput-wrapper: false solved the issue for me. Thanks again for your fast response. So, I'm guessing the output-wrapper is a function that basically hides the goog from being globally available and removing that fixes it.#2020-03-1109:34thhellerit hides all globals yes, goog is just the first that is accessed#2020-03-1109:34thhellercljs would be the next and so on#2020-03-1109:18Jakub Holý (HolyJak)Hello! Any tips for incrementally migrating a React app to ClojureScript? I.e. for a while I am going to have both cljs Fulcro components/files and React .jsx files in the same project, using each other. How do I compile this mess? The React files of course use .jsx and possibly require Babel. Thank you!#2020-03-1109:19thhellerprobably via :npm-module and sticking with webpack for a while#2020-03-1109:20thhelleroh no wait ... that way fulcro can't use your react components#2020-03-1109:20thhellerhmm then it is probably best to keep everything separate and assign things to a global that is shared#2020-03-1109:20thhellerlots of manual glue code required though#2020-03-1114:49Jakub Holý (HolyJak)Thanks a lot!#2020-03-1117:45thhelleranother option is trying to pass everything through shadow-cljs but processing the jsx via babel first. https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2020-03-1117:45thhellerbut if you use any webpack specific stuff that won't be very reliable#2020-03-1117:45thhelleralso often requires manual tuning the externs#2020-03-1118:40Jakub Holý (HolyJak)thank you!#2020-03-1109:51yendaNot sure about fulcro but with reagent that would be easy you make a react-native lib with your react app and use r/adapt-react-class to use the react components#2020-03-1110:01yendaIs there a way to not append #!/usr/bin/env node at the beginning of a node-script target, besides removing it afterward with sed? (in order to compile in the nodejs deps with webpack)#2020-03-1110:02thheller:hashbang false in the build config I think#2020-03-1110:03thhellerif you intend to consume from webpack you should likely be using :node-library though#2020-03-1110:09yendabut then I need to export a symbol? I just want to run node myfile.js#2020-03-1110:09thhellerwhat do you need webpack for then?#2020-03-1110:10thhellerah you want to bundle the deps so its self-contained?#2020-03-1110:12yendayes#2020-03-1116:01rickmoynihanDoes anyone use shadow-cljs with devcards or an equivalent, e.g. storybook?#2020-03-1117:43thhellerseveral people do yes. https://github.com/nubank/workspaces is neat#2020-03-1117:45rickmoynihanAhh thanks — I new I’d seen something else!#2020-03-1116:07yendais it possible that shadows silently fails to create the output file but still says done? I see the following in circle ci:
[:api] Compiling ...
Done in 37.24s.
and then from time to time a task fails saying the file doesn't exist, which I can confirm by running a ls after shadow, the file isn't there
#2020-03-1117:41thheller@yenda Done isn't from shadow-cljs it is from the CI#2020-03-1117:41thhellerin the pass this has happened when the CI system kills the shadow-cljs process because it was consuming too much ram#2020-03-1117:42thhellertry limiting the ram via :jvm-opts ["-Xmx1G"]. see https://shadow-cljs.github.io/docs/UsersGuide.html#jvm-opts#2020-03-1117:42thhellerdunno how high you can go before your CI starts killing#2020-03-1117:42thhellercircleci was something arround 3G I think#2020-03-1118:37yendathanks again! that looks like it was the culprit#2020-03-1207:09ikitommimigrating a project from lein+figwheel to shadow-cljs+deps. What is a good way to watch & compile less into css with this combo?#2020-03-1209:41thheller@ikitommi what did you use before? I typically just run the node command like tools separately which usually have some kind of built-in for watch. eg. https://github.com/sass/node-sass#command-line-interface#2020-03-1211:47ikitommithanks @U05224H0W, the project uses an old cljs-lib, which has less-fragments that need to be included in the project (https://github.com/metosin/komponentit/tree/master/src/less/komponentit), need to copy those into path if would like to use some node-based cli.#2020-03-1211:48ikitommihttps://github.com/Deraen/less4clj#clj integrates into clj cli it seems and sees the classpath of that lib too#2020-03-1211:49ikitommiare there any guidelines how to package and deploy cljs-libraries that have both cljs code & assets like less/sass-files that could be used from js-based cli’s too?#2020-03-1211:52ikitommiused he less4clj via lein before, swapping to clj cli removes the need for lein so I guess it’s ok.#2020-03-1211:55thhellerif you put things in libraries things get rather complicated for node cli tools#2020-03-1211:55thhellerI haven't used any of that kind#2020-03-1211:56thhellerI guess you'd need to do some kind of "extraction" step#2020-03-1211:56thhellerbut just using less4clj should be fine too#2020-03-1209:41thhellerdunno about less though#2020-03-1210:15roklenarcicI just use a hawk watch to compile#2020-03-1210:16roklenarcicbtw I am getting an error when compiling code with 2 modules: two modules without deps, please specify which one is the default#2020-03-1210:16roklenarcicI just wanted to emit an additional file for a worker#2020-03-1210:16thhelleryou are missing to declare the :depends-on properly#2020-03-1210:17thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2020-03-1210:17thhelleryou want/need the extra third shared module#2020-03-1210:17roklenarcicI have to make an empty shared module?#2020-03-1210:18thhellerits not empty. it'll collect all the shared code#2020-03-1210:19roklenarcicHm… the main module is added by nubank.workspaces.shadow-cljs.target which of course doesn’t know about my shared module#2020-03-1210:20roklenarcicI’ll just make the worker depend on main, it’s workspaces, so it’s not a biggie#2020-03-1210:22thhellerhmm yeah workers in test builds aren't covered well#2020-03-1217:57lvhHi! I'm porting an existing figwheel-main project to shadow-cljs. Everything works fine when I run shadow-cljs watch app from the command line. Using Emacs + CIDER with cider-jack-in-cljs, I get
[:app] Configuring build.
[:app] Compiling ...
WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0 (package: 
Everything else mostly works. I was expecting CIDER to inject that dep. Reading messages tells me:
[nREPL] Starting server via /home/lvh/.nvm/versions/node/v11.2.0/bin/npx shadow-cljs -d nrepl:0.7.0-beta1 -d cider/piggieback:0.4.2 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.0-SNAPSHOT server
... this suggests that refactor-nrepl isn't actually getting loaded. Any ideaas?
#2020-03-1217:58thhellerinjecting that into the classpath does not add the middleware automatically#2020-03-1217:58thhellerso you need to configure the middleware#2020-03-1217:59thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2020-03-1217:59lvhso :nrepl :middleware in ....#2020-03-1217:59lvhbeat me to it. Thanks!#2020-03-1222:17juhoteperiI can't get hot reload or HUD working when managing dependencies with Lein. Any ideas what could cause this? Seems like shadow.cljs.devtools.client.env defines are undefined.#2020-03-1222:18thheller@juhoteperi dependency conflict on the closure-compiler/closure-library#2020-03-1222:19thhellerneed the versions required by shadow-cljs, defaults from CLJS are too old.#2020-03-1222:19juhoteperiAh closure-library, I already excluded closure-compiler.#2020-03-1316:05andrea.crottiI noticed a couple of strange things, first that when I do shadow-cljs compile test && node out/node-tests.js already with the first step the test actually run#2020-03-1316:06andrea.crottieven if according to the doc they should only run when you execute them with node#2020-03-1316:06thhellerdo you have :autorun configured?#2020-03-1316:06andrea.crottithe other thing is that in CI even if there are test failures it's always reported as success, which I suspect means it's not returning something different from 0?#2020-03-1316:06andrea.crottiah yes I do have autorun#2020-03-1316:07andrea.crottimaybe I need two different profiles then? autorun is useful I guess while doing local dev#2020-03-1316:08thhellerCI systems are known for killing the shadow-cljs JVM when it starts consuming too much memory, so you may need to restrict it to less memory. see https://shadow-cljs.github.io/docs/UsersGuide.html#jvm-opts#2020-03-1316:08andrea.crottiah no I don't think that's the rason#2020-03-1316:08andrea.crottiit is definitively finishing normally#2020-03-1316:08thhellershadow-cljs compile test --config-merge "{:autorun false}"#2020-03-1316:09andrea.crottilet's see if that maybe fixes the return code problem as well#2020-03-1316:12andrea.crottiuhm no
~/p/p/footy (fix-test-run|…) $
shadow-cljs compile test --config-merge "{:autorun false}" && node out/node-tests.js
shadow-cljs - config: /Users/acrotti/projects/personal/footy/shadow-cljs.edn  cli version: 2.8.83  node: v13.10.1
shadow-cljs - connected to server
NPM dependency "react" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.12.0"
"16.8.6" was required by jar:file:/Users/acrotti/.m2/repository/re-frame/re-frame/0.10.9/re-frame-0.10.9.jar!/deps.cljs
[:test] Compiling ...
[:test] Build completed. (175 files, 1 compiled, 0 warnings, 0.56s)

c
Testing footy.handlers-test
Games = [:footy.handlers/games]
^R
e
FAIL in (specs-test) (cljs-runtime/day8/re_frame/test.cljc:99:18)
expected: (db/valid-db? (clojure.core/deref games) (clojure.core/deref players-list))
  actual: (not (db/valid-db? [:footy.handlers/games] [:footy.handlers/players-list]))
failed with args  [:footy.handlers/failed {:uri /games.edn, :last-method GET, :last-error , :last-error-code 0, :debug-message No Error, :status 0, :status-text Request failed., :failure :failed}]
~/p/p/footy (fix-test-run|…) $ echo $status
0
#2020-03-1316:12andrea.crottiso it always returns 0#2020-03-1316:12andrea.crottiI guess it's because it's not a real test runner it's just node?#2020-03-1316:13thhellerdunno the default test runner should definitely be setting the exit code https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#L12#2020-03-1316:14thhellerif you use a different test setup you may need to hook that up manually#2020-03-1316:15andrea.crottimm wait but
~/p/p/footy (fix-test-run|…) $ which node
/usr/local/bin//node
#2020-03-1316:15andrea.crottiso should I be running the node from shadow-cljs?#2020-03-1316:26thhellerhmm?#2020-03-1316:26thhellernode out/node-tests.js#2020-03-1316:26thhellerthats what should be returning 1 when tests fail#2020-03-1316:28thhellerbut I don't know how much you are modifying the defaults, so if you override :runner-ns for example it might not unless you hook it up correctly yourself#2020-03-1316:58andrea.crottiit's quite a trivial config#2020-03-1316:58andrea.crotti
:test {:target    :node-test
         :output-to "out/node-tests.js"
         :ns-regexp "-test$"
         :autorun   true}
#2020-03-1317:01thhellerthats fine#2020-03-1317:02thhellerbut I see some re-frame testing ns ... dunno how that works. maybe it doesn't use the default testing stuff and never triggers that error#2020-03-1317:02thhellerno clue without actually seeing the code#2020-03-1317:23andrea.crottiah ok let me try if disabling the rf test and making another test fail works#2020-03-1317:24andrea.crottiah yes that was it!#2020-03-1317:25andrea.crottithe rf test is just something like
(deftest specs-test
  (testing "Game map is valid"
    (rf-test/run-test-async
#2020-03-1317:25andrea.crottiit was the async#2020-03-1317:25andrea.crottirun-test-sync works fine#2020-03-1317:26andrea.crottimakes sense I guess, I use it in another project though and I never noticed these issues#2020-03-1317:26andrea.crottia different runner there though#2020-03-1317:27andrea.crottithanks a lot @U05224H0W I was not suspecting that at all#2020-03-1316:30thhellerjust run things without && in 2 separate steps ... makes it easier to figure out which part is actually failing#2020-03-1316:39frozarHi folks, I generate a package locally "toto-0.1.1.jar" and I would like to use it in a demo project. How can I configure "shadow-cljs.edn" to say to use my local package "toto-0.1.1.jar" instead of looking at any remote repositories?#2020-03-1316:40thhellerrun lein install to install it in your local repo. shadow-cljs will use that without looking at any remotes, just add the dependency by its regular name#2020-03-1316:45frozarThank you, I'll try that 🙂#2020-03-1316:46Derekconsider naming your local version toto-0.1.1-SNAPSHOT or something to make it clear#2020-03-1316:46thhellerno don't use snapshot versions#2020-03-1316:46thhellerthat might make it check remotes#2020-03-1316:47Derekoh really?#2020-03-1316:48thhelleryeah. can't remember the exact rules but snapshots will check remotes for the "latest" snapshot#2020-03-1316:48Derekah, because SNAPSHOT is a volatile label#2020-03-1316:50frozarIt works, thank you. Maybe I should use sanpshot anyway because it's also to send multiple time the same snapshot tag on a remote repository, so it's also a facility.#2020-03-1400:15QuestIn the last 8 days of #shadow-cljs channel history, thheller has posted 122 comments (15 / day.) This is grade A support -- even better than paid teams at some workplaces. If you like shadow-cljs, please consider supporting him via Patreon (https://www.patreon.com/thheller) or Paypal. (https://paypal.me/thheller) (Not affiliated, just an appreciative consumer.)#2020-03-1401:11thhellerdon't forget about https://github.com/sponsors/thheller 😉#2020-03-1410:26andrea.crottiprobably stupid question, but is it even possible to test re-frame handlers/subs with node?#2020-03-1410:26andrea.crottiI guess maybe I have to use a browser to test it, even if the subs/events are not really touching the dom at all, it seems not to work#2020-03-1417:42Ben Hammondn00b question; I'm trying to figure out how best to use shadow/intellij/deps/react/material-ui. Does shadow include a static file server to enable it to serve up the files it just compiled? or do I have to use npm/yarn (or something else) to view from browser? All the examples I can find use yarn start to serve up files and I'm wondering if that is mandatory, or if there is a more clojure-heavy way to do it#2020-03-1417:45Ben HammondMy background is in clojure/java, and not at all in NodeJS, so perhaps I am merely displaying that bias...#2020-03-1417:45Felipe MarquesIt provides it. If you have a config with this:
{:dev-http {8080 "public"}}
It will serve all the compiled files in the public folder through port 8080.
#2020-03-1417:45Ben Hammondperfect! thanks#2020-03-1417:46Felipe MarquesThere is also the :devtools option that you can put in a build, to configure stuff such as which function to run after the code has been reload at the browser.#2020-03-1417:47lilactownYou will need to install shadow-cljs via npm or yarn#2020-03-1417:48Ben Hammondyes I have done that#2020-03-1417:48lilactownThe shadow-cljs app itself is a clojure program, which yarn start or what have you just shells out to#2020-03-1417:48Ben Hammondbut I prefer to shuffle out of my comfort zone rather than stride#2020-03-1417:48lilactownIf you prefer to use deps.edn and Clojure aliases to start the program, that can be done#2020-03-1417:49Ben Hammondyes that is exactly what I am doing#2020-03-1417:49Felipe MarquesYou can also run it through clojure only. You add the dependency to the deps.edn and config a alias to run the main of Shadow-cljs. But I had problem connecting to the ClojureScript repl using this setting.#2020-03-1417:50lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2020-03-1417:51lilactownREPLing will depend on your editor. I’m not super familiar with Cursive. thheller (the author) uses it though#2020-03-1417:51Felipe MarquesI use emacs. It is a repl middleware problem. I just didn't took time to look into it.#2020-03-1417:51lilactownstarting a watch for your build will automatically start the dev-http server if you configure it in your shadow-cljs.edn#2020-03-1417:45jplazaI recently started playing around with shadow-cljs too and used npx create-cljs-project acme-app to bootstrap my app#2020-03-1417:46jplazaRunning npx shadow-cljs watch app will run a dev server#2020-03-1417:57Ben Hammondyeah, I'm trying to stay on the clojure toolset that I already understand, rather than the NodeJS one that I don't#2020-03-1417:57Ben Hammondwhich may cause me futher problems of course#2020-03-1418:03jplazaOh I see, but you will eventually have to surender and start learn node tooling if you want to do UI work, at least my opinion 😄#2020-03-1515:14pezIf I start watch like this: lein shadow -d cider/piggieback:0.4.2 -d cider/cider-nrepl:0.23.0 watch app test, does shadow load those dependencies? (I'm trying Calva with a fresh Luminus project, and it seems that the dependencies are not satisfied...)#2020-03-1515:40pezAnswering my own question. No, run like this, it is Leiningen that starts the CLJ REPL, and shadow starts the CLJS one on top of that. Is that correct, @thheller?#2020-03-1517:15thheller@pez I do not recommend using lein-shadow and I don't know what it does#2020-03-1517:15thhellerbut adding things to the classpath does not really affect the nrepl middleware#2020-03-1517:16thhelleralso shadow-cljs doesn't use piggieback at all so no point in adding it#2020-03-1601:38Pavel KlavíkHi, I have upgraded to Shadow-cljs 2.8.92 right now and I was getting the following new error during the compilation: #2020-03-1601:38Pavel Klavík
[:client] Build failure:
------ ERROR -------------------------------------------------------------------
 File: C:\Shared\orgpad\src\orgpad\client\subs\unit.cljs:47:38
--------------------------------------------------------------------------------
  47 |          {:size/keys [width height]} ((if show-content :unit/size :unit/title-size)
--------------------------------------------^-----------------------------------
Error in phase :compilation
ClassCastException: class clojure.lang.PersistentList cannot be cast to class clojure.lang.Named (clojure.lang.PersistentList and clojure.lang.Named are in unnamed module of loader 'app')
        clojure.core/name (core.clj:1595)
        clojure.core/name (core.clj:1589)
        shadow.build.cljs-hacks/shadow-parse-invoke* (cljs_hacks.cljc:783)
        shadow.build.cljs-hacks/shadow-parse-invoke* (cljs_hacks.cljc:730)
        cljs.analyzer/parse-invoke (analyzer.cljc:3690)
        cljs.analyzer/parse-invoke (analyzer.cljc:3688)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3935)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
        cljs.analyzer/analyze-seq (analyzer.cljc:3963)
        cljs.analyzer/analyze-seq (analyzer.cljc:3941)
        cljs.analyzer/analyze-form (analyzer.cljc:4150)
        cljs.analyzer/analyze-form (analyzer.cljc:4147)
        cljs.analyzer/analyze* (analyzer.cljc:4200)
        cljs.analyzer/analyze* (analyzer.cljc:4191)
        cljs.analyzer/analyze (analyzer.cljc:4220)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4213)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4211)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze-let-binding-init (analyzer.cljc:2273)
        cljs.analyzer/analyze-let-binding-init (analyzer.cljc:2271)
        cljs.analyzer/analyze-let-bindings* (analyzer.cljc:2293)
        cljs.analyzer/analyze-let-bindings* (analyzer.cljc:2282)
        cljs.analyzer/analyze-let-bindings (analyzer.cljc:2327)
        cljs.analyzer/analyze-let-bindings (analyzer.cljc:2326)
        cljs.analyzer/analyze-let (analyzer.cljc:2353)
        cljs.analyzer/analyze-let (analyzer.cljc:2337)
        cljs.analyzer/fn--1994 (analyzer.cljc:2391)
        cljs.analyzer/fn--1994 (analyzer.cljc:2389)
        clojure.lang.MultiFn.invoke (MultiFn.java:252)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3934)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
        cljs.analyzer/analyze-seq (analyzer.cljc:3963)
        cljs.analyzer/analyze-seq (analyzer.cljc:3941)
        cljs.analyzer/analyze-form (analyzer.cljc:4150)
        cljs.analyzer/analyze-form (analyzer.cljc:4147)
        cljs.analyzer/analyze* (analyzer.cljc:4200)
        cljs.analyzer/analyze* (analyzer.cljc:4191)
        cljs.analyzer/analyze (analyzer.cljc:4220)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze-seq (analyzer.cljc:3964)
        cljs.analyzer/analyze-seq (analyzer.cljc:3941)
        cljs.analyzer/analyze-form (analyzer.cljc:4150)
        cljs.analyzer/analyze-form (analyzer.cljc:4147)
        cljs.analyzer/analyze* (analyzer.cljc:4200)
        cljs.analyzer/analyze* (analyzer.cljc:4191)
        cljs.analyzer/analyze (analyzer.cljc:4220)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4213)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4211)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/fn--1962 (analyzer.cljc:2252)
        cljs.analyzer/fn--1962 (analyzer.cljc:2248)
        clojure.lang.MultiFn.invoke (MultiFn.java:252)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3934)
        cljs.analyzer/analyze-seq* (analyzer.cljc:3932)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3939)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:3937)
        cljs.analyzer/analyze-seq (analyzer.cljc:3963)
        cljs.analyzer/analyze-seq (analyzer.cljc:3941)
        cljs.analyzer/analyze-form (analyzer.cljc:4150)
        cljs.analyzer/analyze-form (analyzer.cljc:4147)
        cljs.analyzer/analyze* (analyzer.cljc:4200)
        cljs.analyzer/analyze* (analyzer.cljc:4191)
        cljs.analyzer/analyze (analyzer.cljc:4220)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4213)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/analyze (analyzer.cljc:4211)
        cljs.analyzer/analyze (analyzer.cljc:4203)
        cljs.analyzer/fn--1770/fn--1774 (analyzer.cljc:1655)
        cljs.analyzer/fn--1770 (analyzer.cljc:1655)
        cljs.analyzer/fn--1770 (analyzer.cljc:1648)
        clojure.lang.MultiFn.invoke (MultiFn.java:252)

--------------------------------------------------------------------------------
  48 |                                       unit-map)]
  49 |      [width height])))
#2020-03-1601:38Pavel KlavíkAfter changing the code to this:
(get unit-map (if show-content :unit/size :unit/title-size))
everything works, but the original code is correct as well.
#2020-03-1608:47thheller@pavel.klavik oops sorry about that. fixed in 2.8.93. thanks for the report.#2020-03-1623:11davewo@thheller we are trying to speed up our release build in a Dockerfile by attempting to cache .shadow-cljs between docker builds. We are seeing cache reads, followed by compiles and writes for files that have not changed between commits. What should I look for regarding inappropriate cache invalidations?#2020-03-1706:41hindolHi, on http://shadow-cljs.org I see None-code resources. Should this be Non-code resources? Wondering if this is a typo.#2020-03-1707:20thheller@davewo the cache includes the last-modified timestamps of the source files so if those change it will invalidate the cache. they probably change between CI builds right?#2020-03-1718:23davewoMost likely. So file content does not factor into cache invalidation, then?#2020-03-1719:20thhellercurrently only timestamp#2020-03-1707:21thheller@hindol.adhya not actually sure. I am German. maybe?#2020-03-1707:38hindolThink that's a typo then. "Non-code resources" is correct English for "resources that are not code".#2020-03-1710:20Ben HammondIs the DOM available to code that is called using :after-load hook? it is unreasonable to expect
(.getElementById js/document "app")
to be mountable?
#2020-03-1710:24Ben Hammondah I see my misconception; DOM gets built upon page refresh :after-load gets called upon recompilation#2020-03-1711:53thhellerno, your conception is wrong#2020-03-1711:53thheller:after-load gets called AFTER the recompiled code has been loaded#2020-03-1711:53thhellerYOU trigger the DOM refresh you want to do in after load#2020-03-1711:54thhellershadow-cljs does nothing to the DOM, only your code does#2020-03-1711:54thhellerand yes the "app" element is available unless you removed it from the dom yourself#2020-03-1710:36Ben Hammondmy restated question is: I configure schema-cljs.edn with my app module thus
:modules
        {:main {:entries []}}
and I have to fire up the app from with index.html like this
<div id="app"></div>
    <script src="js/main.js"></script>
    <script>my.app.main();</script>
and I'm complaining about having to repeat the classname of my app in two places: index.html and schema-cljs.edn but I supppose this is necessary because schema-cljs.edn goes away at release time but the app's main function will still have to get called
#2020-03-1710:36Ben Hammondis that right? or is there a smarter way to do things?#2020-03-1711:30tvaughan:entries is for the google closure compiler and the tree shaking that it does. You probably want to add :init-fn #2020-03-1711:53thheller@ben.hammond instead of entries use {:init-fn }. then you can remove the second script tag that calls the main#2020-03-1712:46Chris McCormickam i going crazy or was there a way to slurp a text file into a variable at compile time at some point using shadow-cljs?#2020-03-1712:46Chris McCormicklooking through the user guide but i can't figure out what to search on#2020-03-1712:46thhellerhttps://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2020-03-1712:47Chris McCormickthank you so much 🙏#2020-03-1716:20p-himikIn the shadow-cljs repo, why are there both project.clj and deps.edn? Was just nosing around after dnolen mentioned that CLJS 1.10.597 has a regression that leads to an increased bundle size and noticed that project.cljs has 1.10.597 while deps.edn has 1.10.520, which doesn't have the regression.#2020-03-1717:06thheller@p-himik I tested deps.edn but it is not used and not compatible#2020-03-1717:07thhellerthere are .java sources that need to be compiled#2020-03-1719:16aisamuHi! After adding day8.re-frame/http-fx {:mvn/version "v0.2.0"} to our project, it started failing on release builds with:
IllegalStateException: Could not find where to put constant cljs$cst$keyword$method. Used by [ajax.simple.js, ajax.xhrio.js, ajax.easy.js, sablono.core.js, ajax.interceptors.js, company.namespace.events.js, ajax.xml_http_request.js], selected common dep goog.structs.map.js
There's a reference to a similar issue on https://clojurians-log.clojureverse.org/shadow-cljs/2019-01-09, but we don't use :modules. What'd be the next thing to investigate?
#2020-03-1719:22aisamuThe build config is pretty straightforward:
{:target :npm-module
 :output-dir "build/cljs"
 :compiler-options {:infer-externs :auto
                    :source-map true}}
#2020-03-1720:03aisamuUsing an aliased require appears to have fixed it (e.g. [ajax.edn :as edn] instead of just [ajax.edn]) :man-shrugging:#2020-03-1720:55thheller:npm-module basically creates on :module per namespace. so you are definitely using :modules. I can't really remember the details from this previously. If you have something reproducible I can look at I can investigate further#2020-03-1818:17aisamuI tried coming up with a repro repo, but the commit that failed yesterday works today 😞. The parallel build order might be affecting it#2020-03-1819:21aisamuObserved on two different projects, (running shadow .68 and .93)#2020-03-1721:10frozar@thheller Hi, I daily use shadow-cljs ❤️ and it seems to have a minor security issue due to its dependencies to minimist :#2020-03-1722:41thhellerplease open a github issue. don't have time to look into that right now and it'll get lost in slack void#2020-03-1722:43frozar:+1:#2020-03-1807:52frozarI opened this issue : https://github.com/thheller/shadow-cljs/issues/672#2020-03-1721:27sogaiui think that might have to do with mocha#2020-03-1721:27sogaiubeing the one that eventually pulls in minimist#2020-03-1721:40sogaiunm, nice path there :)#2020-03-1803:46theeternalpulseI'm creating a new project from scratch, and when I try to connect to a clojurescript repl in cider it mentiones "no clojure project detected". Do I need to have something to indicate it's a clojure project?#2020-03-1804:35dpsuttonSounds like an old clojure-mode. Upgrade that to a more recent version that is aware of the shadow project file#2020-03-1804:43theeternalpulseactually I think I got it, was connecting to clojure rather than clojurescript repl#2020-03-1815:29jjttjjIs there an obvious reason https://github.com/hoplon/hoplon/blob/master/src/hoplon/core.clj won't compile with bootstrapped cljs? I tried removing all the java stuff but keep getting
{:error #error {:message Could not require hoplon.core, :data {:tag :cljs/analysis-error}, :cause #error {:message ns hoplon.core not available, :data {:ns hoplon.core}}}}
when i try to compile it (according to this guide (https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html).
#2020-03-1815:30jjttjjIs there a list of rules anywhere on how to make a library bootstrap compatible? Or any general tips for debugging this?#2020-03-1815:31dpsuttondoes bootstrapped look for clj files at all?#2020-03-1815:33jjttjjI also tried changing to cljc#2020-03-1815:35jjttjjstrangely, I have no issues with bootstrapping javelin macros (https://github.com/hoplon/javelin/blob/master/src/javelin/core.clj) directly, even though that's a clj file and has some java calls. But it seems like it's that library (which hoplon also depends on) which I suspect might be giving me the issues when trying to use hoplon. I could be wrong on that though#2020-03-1816:03jjttjjHmmm I removed all macros from hoplon and even then it doesn't work. (still getting " Could not require hoplon.core"). My bootstrap build looks like
:bootstrap-support
  {:target     :bootstrap
   :output-dir "public/bootstrap"
   :exclude    #{cljs.js}
   :entries    [cljs.js javelin.core cljs.analyzer hoplon.core]
   :macros     []}
#2020-03-1819:17thheller@jjttjj looks to me like hoplon macros aren't self-host compatible#2020-03-1819:19jjttjjWhat makes something not compatible? I removed all java calls#2020-03-1819:29thhellerI don't have a clue sorry ... far too complex to do a quick check#2020-03-1819:31jjttjjno problem, thanks!#2020-03-1819:40gravI'm trying to locate a problem with a version of an npm package. I'm running the compiler with npm shadow-cljs watch my-app and then starting node target/main.js Am I right that I only need to restart the node target/main.js part every time I test a different version of the npm package?#2020-03-1819:41thhellerif its a node-script build yes#2020-03-1820:26jjttjjwait can google closure js libraries effect self-host-ability ?#2020-03-1820:47thhellerno. they are already JS#2020-03-1820:48thhellerhttps://github.com/hoplon/javelin/blob/master/src/javelin/core.clj#L16#2020-03-1823:27jjttjjStrangely though, javelin and it's macros are working perfectly for me, the io ns is never used in that file. I had a local versiont that got rid of the io require and this line, which I don't think is valid cljs https://github.com/hoplon/javelin/blob/557b51ce14f31c391aefa8a22c8c2aa42db7b269/src/javelin/core.clj#L200 But strangely, after I got that working I went back to using the github/master version and it still worked fine. (I deleted caches several times too)#2020-03-1823:28jjttjjI think I'm just doing something unrelated and dumb because now I keep getting the same error on cljs only projects (even though for some reason javelin still works)#2020-03-1820:48thhellerthats one of the namespaces you can't use in self-hosted#2020-03-1821:19David PhamI am trying to use web workers in my workflow, and I am also using day8.re-frame-10x.preload for debugging in my :`preloads`in shadow-cljs. My issue is shadow-cljs might also preload the re-frame-10x in my web workers and it will throw an error because 10xrequires document.#2020-03-1821:20David PhamDoes anyone know a solution for this issue? I tried to specify a main and also put the :browser-inject :main as advised in the documentation, but I can't overcome this.#2020-03-1821:30David PhamI found a hack: don't preload it, and require the namespace (require 'day8.re-frame-10x.preload) in the repl after start.#2020-03-1821:34David PhamI don't know how difficult it is, but it could be interesting if we could specify where to inject the preloads similarly to :browser-inject#2020-03-1822:29JAtkinsHow can I use different stubs for debug and production? By this it looks like it's not possible? https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_script I'm trying to use [Debux](https://github.com/philoskim/debux), which has sperate deps for production stubs and development tracing.#2020-03-1900:21thheller@neo2551 :preloads can be specified per module, so just put it into the main module#2020-03-1900:22thheller@jatkin need to use lein/deps.edn to do classpath trickery#2020-03-1906:24Chris McCormickShould the :worker target be used for service workers as well? There is no mention of services workers in the docs as far as I can tell.#2020-03-1908:05emil0rIs it it possible to do with shadow-cljs what you can do with leiningen with regards to checkouts?#2020-03-1908:36thhelleryou can use lein or deps.edn but otherwise no#2020-03-1909:14Michaël SalihiHi @thheller, does that bring something (performance?), if we call the Reagent dependency like that in Shadow-CLJS project? :dependencies [[reagent "0.8.1" :exclusions [cljsjs/react cljsjs/react-dom]]] vs :dependencies [[reagent "0.8.1"]] We can see in your React native Expo example, Reagent is call wihtout exclusions: https://github.com/thheller/reagent-expo/blob/master/shadow-cljs.edn#2020-03-1909:14thhellerno, doesn't do anything#2020-03-1909:14thhellerwell it saves you from downloading 2 extra dependencies but thats it#2020-03-1909:16Michaël SalihiOK, perfect thx! Since this dependencies are already in ~/.m2 directory, I guess it doesn't care.#2020-03-1918:03Felipe MarquesI'm getting :missing-nrepl-middleware when running:
(shadow.server/start!)
(shadow.api/watch :app)
(shadow.api/nrepl-select :app)
From inside a repl started with cider through deps.edn. I thought cider would inject the nrepl middleware. Does anyone have any idea how to solve this?
#2020-03-1918:06dpsuttonYou need to add shadows middleware manually#2020-03-1918:06dpsuttonhttps://github.com/clojure-emacs/cider/issues/2812#2020-03-1918:10Felipe MarquesCool! Thanks!#2020-03-1918:30Felipe MarquesSorry to disturb you again. I'm trying to add this middleware through .dir-locals.el do you have any idea how to do that? I just found the cider-clojure-cli-parameters#2020-03-2000:39steveb8nrandom question: I’m trying to invoke a single file emitted by shadow via the graalvm polyglot context (i.e. from jvm clojure). It fails to load due to an error stating “org.graalvm.polyglot.PolyglotException: ReferenceError: global is not defined” I presume this is goog.global. My question is: could this work or am I trying to do something in the “too hard” basket?#2020-03-2000:40steveb8nextra info: graal polyglot does not support nodejs modules so it needs to be a single js artifact. for that reason, I used :node-script as the target#2020-03-2008:45thhelleras the :node-script name suggests that is meant for node ...#2020-03-2008:45thhellergraal would be its own target but I didn't look into that yet#2020-03-2023:40steveb8nah yes, of course. I had answered my own question without knowing it. thanks. I’ll go with the other architecture instead.#2020-03-2004:32sergey.shvetsHi, I'm new here! Thanks for the awesome compiler! I'm migrating from figwheel + cljs-oops/cljsjs/externs and couldn't be happier to throw away a few layers of dependencies and be able to use npm's packages!#2020-03-2004:34sergey.shvetsI have a question: I have lein managing my dependencies and can successfully build an app using lein-shadow plugin. But I don't understand how I can run a build-report using lein dependencies? I want to see what adds size to my package. Thanks!#2020-03-2008:46thhellerI don't recommend using lein-shadow but the config it generated should be enough to be able to run a regular build report#2020-03-2008:47thhellereither through shadow-cljs or via lein run#2020-03-2015:28sergey.shvetsThanks! It was giving me getSourceName not found error. But after I run lein shadow release app and then immediately build a report it worked. Not sure what was the problem, I'll dig deeper next time I generate a report.#2020-03-2017:14thhellerthat error points to a version conflict on the closure-compiler dependency#2020-03-2017:29sergey.shvetsGot it. Now I see what doc meant about weird java stack traces with lein and, indeed, I had a closure compiler in my dependency vector that was different from the one that shadow depends on. I removed any mentions of closure compilers in my dependency vector and will let shadow manage it for me. Everything seems to be back to normal. Thanks for all the help!#2020-03-2004:40sergey.shvetsRunning compilation before the report seems to solve the problem above and remove a weird java stack trace. Is it a requirement to run a compilation before generating a report?#2020-03-2006:11fabraohello all, how do I convert
import EStyleSheet from 'react-native-extended-stylesheet';
to clojurescript ?
#2020-03-2006:13fabraoI tried ["react-native-extended-stylesheet" :default EStyleSheet] and it´s giving Can´t find variable EStyleSheet#2020-03-2006:13fabraowhen using (EStyleSheet.create)#2020-03-2008:48thheller@fabrao (EStyleSheet.create) thats invalid, should be (.create EStyleSheet)#2020-03-2016:43davewo@thheller would you be interested in making the build cache aware of content of source files, instead of mod times? Tracking hashes in the cache perhaps? We are trying to keep our docker build self-contained and tracking file content would allow us to re-use the cache between docker builds.#2020-03-2017:02thheller@davewo open a ticket, I'll think about it#2020-03-2017:13davewohttps://github.com/thheller/shadow-cljs/issues/673 happy to help with a PR!#2020-03-2019:19martinklepschIs this meant to be the same:
shadow-cljs cljs-repl $BUILD_ID

(require '[shadow.cljs.devtools.api :as s])
(s/node-repl $BUILD_ID
#2020-03-2019:20martinklepschI’m seeing some weird differences around :node reader conditionals between those#2020-03-2019:21martinklepschspecifically the CLI invocation properly gets a REPL that has :node stuff read and the Clojure API one doesn’t#2020-03-2019:23martinklepschOh just realizing that I’m using the API wrong#2020-03-2019:47lambdamHello, I am discovering shadow-cljs for a personal project. I use Emacs. I'm used to figwheel way of working. When there is a compilation error (for any reason), the completion in Emacs ceases to work. This makes coding quite painful. It's not the case in figwheel. Will it change in future versions? Thanks#2020-03-2019:55dpsuttoncan you open an issue on cider's github issue tracker with a minimal repro and I can attempt to find out what's going on?#2020-03-2310:06lambdamSorry for late reply. Yes I'll take time for that. Thanks.#2020-03-2100:27knubieI’ve noticed that the :node-script build target requires node_modules to run, but the output from :browser doesn’t. Is it possible to make the :node-script build work like :browser such that it doesn’t need to install any node modules? For my use case I have a code base that runs in several environments; electron, browser, and node server. Most of the NPM dependencies are for the code that runs in the browser, but the node server also uses some of them when it server-side renders. When releasing the electron version those dependencies should go in "devDependencies" in the package.json so that they’re not included in the final build (the :browser build doesn’t seem to need them). However when I deploy the node server, I do need those dependencies in "dependencies" so that they’ll be installed on the server (the :node-script build seems to need them). Any ideas for the best way to configure this?#2020-03-2108:48thheller@steedman87 you can post-process the node-script output via https://github.com/zeit/ncc or so#2020-03-2118:54knubieAwesome, thanks for the tip!#2020-03-2123:26tony.kay@thheller I really miss the checkboxes for turning on/off builds…I have a project with 8 different targets, and depending on the task I often want to switch on/off several. The new interface makes that very tedious.#2020-03-2123:49thhelleryeah I'll add that back soon. kinda distracted at the moment.#2020-03-2202:46cobyoh, I was wondering if I did something to make those go away...glad to hear they're coming back 😄#2020-03-2213:30kwrooijenHi, is it possible to edit node modules and have those changes be picked up by shadow-cljs?#2020-03-2213:30kwrooijenFor debugging purposes
#2020-03-2214:06thheller@kevin.van.rooijen shadow-cljs no longer watches individual files in node_modules, it only watches package.json files for modifications. so you can touch node_modules/the-dep/package.json which should trigger a rebuild#2020-03-2214:29kwrooijenThanks, that does trigger a rebuild.#2020-03-2220:50deep-symmetryI successfully finished porting my big LaTeX documents to Asciidoctor/Antora with the help of a byte-field diagram generator I created as a node module using shadow-cljs. I had been using it straight out of Git, but today I just published it to npm (my first npm module) so I can start documenting it the way people will actually want to use it. But when I try to change my build pipeline to use it from the npm install instead of my local git repo, I am getting an error I can’t understand:
$ANTORA_DJ --fetch doc/dev_svg.yml --stacktrace
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
Error: ENOENT: no such file or directory, open '/Users/jim/git/dysentery/node_modules/bytefield-svg/.shadow-cljs/builds/lib/dev/out/cljs-runtime/goog.debug.error.js'
    at Object.openSync (fs.js:436:3)
    at Object.readFileSync (fs.js:341:35)
    at global.SHADOW_IMPORT (/Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:58:15)
    at /Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:2212:1
    at /Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:5:26
    at Object.<anonymous> (/Users/jim/git/dysentery/node_modules/bytefield-svg/lib.js:9:3)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
I am running the command inside my dysentery repository, where I have locally installed my bytefield-svg npm module. Its source is here: https://github.com/Deep-Symmetry/bytefield-svg
#2020-03-2220:52deep-symmetryDo I need to build it in a different way to publish it to npm or something?#2020-03-2220:54deep-symmetry(The error message is correct in that there is no .shadow-cljs directory in the npm-installed copy of bytefield-svg. That directory does exist in the git repo where I built the module to publish to npm. I am a total npm n00b, and pretty wet behind the ears when it comes to shadow-cljs as well, this project was my first non-JVM Clojure effort, so hopefully someone can help me understand what is going on!)#2020-03-2220:55thhelleryou cannot publish development builds to npm, they are only meant to run on the machine that compiled it#2020-03-2220:55thhelleryou must use shadow-cljs release your-build and publish that instead#2020-03-2220:56deep-symmetryOk, that makes sense. I will give it a shot. Does it make sense to set up an npm script for that?#2020-03-2220:57deep-symmetryIn your command line what is your-build?#2020-03-2220:57thhellerwhatever your build id is#2020-03-2220:58deep-symmetryI don’t know what a build id is. The name in package.json?#2020-03-2220:58thhellerhow do you use shadow-cljs now?#2020-03-2220:58thhelleri mean what command do you run#2020-03-2220:58thhellerit will have the build id in it ... its the key in the :builds map#2020-03-2220:58deep-symmetrynpm run build#2020-03-2220:59thhellerwell ... and what does that run?#2020-03-2220:59deep-symmetryYup, was just going there. 😄 It runs shadow-cljs compile lib so I am guessing the magic id is lib.#2020-03-2220:59thhellerit is#2020-03-2221:00deep-symmetrySo I will add a release script. Thanks! Trying…#2020-03-2221:07dpsuttonIs the npm script helpful at all? Maybe the simple shadow-cljs api might be beneficial for you while you’re learning. Way less indirection#2020-03-2221:12deep-symmetryAs it is, I have a devil of a time when I dabble in JS projects remembering if they use npm, yarn, or gulp to build; adding another tool seems even worse. But I understand where you are coming from.#2020-03-2221:13deep-symmetryAnyway, having to rebuild gave me a chance to update my dependencies on shadow-cljs and borkdude/sci, so at least 1.0.1 is more than a 1.0.0 that works! 😉#2020-03-2221:18deep-symmetryYes! The npm-installed version works now. Thanks again for your patient and clear help.#2020-03-2410:45teawaterwirei have this INFO warning with one module, i haven't noticed issues in my app so far but what could be the consequences of such an "invalid-required"
node: v11.13.0
shadow-cljs - server version: 2.8.51 running at 
shadow-cljs - nREPL server started on port 52448
[2020-03-24 11:42:40.454 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/eth-lib/lib/bytes.js", :requires [{:line 9, :column 193}]}
#2020-03-2412:34thhellertypically thats some kind of dynamic require in JS, so that would always fail#2020-03-2413:47teawaterwiregot it, dynamic require, interesting line in that library 😅
if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("c" + "rypto").randomBytes(bytes);else throw "Safe random numbers not available.";
#2020-03-2414:04thhelleryeah thats specifically to stop bundlers from bundling the crypto package since dynamic requires are still pretty much an unsolved problem#2020-03-2414:08teawaterwiremake sense - thanks!#2020-03-2414:35Ben HammondI have a cljs/React front end that I have been hosting with the shadow-cljs :dev-http I have a clojure backend running on pedestal/jetty I am now at the point where I would like to establish a websocket connection between the two; Ideally I would like to serve the front-end from Pedestal server AND connect a shadow-cljs repl to this session; When I serve the html pages from pedestal however, I cannot get the cljs repl started; I get > No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. I can see that shadow-cljs :run-dev somehow injects
 
into the webpage and I can see that Pedestal server does not do this and I presume that this is why it does not make a repl connection; Where does this repl websocket get injected? How can I get Pedestal server to do the same thing?
#2020-03-2414:39thheller@ben.hammond you don't need to configure pedestal in any way. the websocket connection is made to the shadow-cljs server which is completely separate#2020-03-2414:40thhellerthis also has nothing to do with :dev-http. that is strictly serving static files only.#2020-03-2414:41Ben Hammondoh so the REPL ws connection should be identical wherever the cljs files are server from#2020-03-2414:41thhellerthe .js files can be served by pedestal as they are just files#2020-03-2414:41thhellerthe websocket connection is made to the shadow-cljs server which is running on port 9630#2020-03-2414:42Ben Hammondah right I see I see thanks!#2020-03-2414:55wasserHope everyone is well. I’m working with Higcharts using https://github.com/kirjs/react-highcharts and things are going fine until I want to use the “Sankey” style chart (https://www.highcharts.com/demo/sankey-diagram). This is provided in a separate JS file (https://code.highcharts.com/modules/sankey.js). The Highchart fiddle just shows adding the sankey.js to your html and it works. Except it doesn’t since I’m using the npm package. I can’t figure out how to get the react component to find this extra code/module. I added the sankey.js to the html and even tried https://github.com/clarketm/highcharts-more, but that package doesn’t seen to include Sankey. I keep getting “Error: Highcharts error #17: https://www.highcharts.com/errors/17/?missingModuleFor=sankey missingModuleFor: sankey” Has anyone figured out how to get this to work?#2020-03-2415:55thheller@wasser you probably can import it from the highcharts npm module. check if you can find a sankey file in node_modules/highcharts#2020-03-2415:57thhellerdunno about the react parts though#2020-03-2416:34mauricio.szaboHi, I'm trying to use a node module on Shadow-CLJS, but it's not raising the error: '"module$node_modules$nrepl_client$src$nrepl_client is not defined"' The node module is nrepl-client, I'm trying to require it with ["nrepl-client" :as nrepl], shadow-cljs target is node-library#2020-03-2416:34mauricio.szaboIf I use js/require it works correctly#2020-03-2417:01defaI’m having trouble with my production build (targeting the browser). When loading index.html in the browser I get an error in the JavaScript console: ReferenceError: Can't find variable foo where my init-function is foo.core/init . In development mode everything works find…#2020-03-2417:05defaIn shadow-cljs.edn I tried:
:modules    {:main {:init-fn foo.core/init}}
and
:modules    {:main {:entries [foo.core]}}
my index.html looks like this:
<html lang="en">
  <head>
	<!-- ... -->
    <script src="/js/compiled/main.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script>foo.core.init();</script>
  </body>
</html>
#2020-03-2417:06defa… and in foo/core.cljs I have:#2020-03-2417:06defa
(defn ^:export init []
...)
#2020-03-2419:20thhellerdo you get any JS errors during load?#2020-03-2419:20thhellerlike any others I mean?#2020-03-2420:18defaYes, it happens during load…
TypeError: undefined is not an object (evaluating '$N.call')
	iO — main.js:1126:113
	cN — main.js:1128:348
	(anonymous function) — main.js:1061:406
	(anonymous function) — main.js:1061:441
	Global Code — main.js:1800
	
ReferenceError: Can't find variable: foo
	Global Code — 
where `
where line 18 of index.html is:
<script>foo.core.init();</script>
#2020-03-2420:49defaSolved. I used the --debug option when compiling my production code and it turned out that there was some debug code using cljs.pprint/pprint without explicitly requiring it. So shadow-cljs release foo --debug did the trick and produced some useful output to the JavaScript console in the browser to track down the problem. Instead of (evaluating '$N.call') in the logs above I got some hints to hat it was related to pprint#2020-03-2418:32wasser@thheller I found a sankey.js file in node_modules/highcharts/modules so tried adding ‘[“highcharts/modules/sankey.js”]’ to the namespace, but I still get the “error 17, missing module for sankey”. Do I need to add the dependency somewhere else?#2020-03-2419:20thhellerI have no idea sorry. maybe you need to initialize it somehow. highcharts probably has some docs for that?#2020-03-2419:44wasserThanks anyway. Maybe someone else has stubbled into this and got it sorted. #2020-03-2421:23David PhamDid you try to put the file somewhere else?#2020-03-2421:23David PhamLike where you have your usual highcharts dependency?#2020-03-2421:24David PhamWhat about removing the .js at the end of your import?#2020-03-2502:08wasserNone of those (putting the js file someplace, adding it to the html, dropping the .js) worked - stil getting “Error 17”. I found another react lib to try which apparently includes the sankey stuff directly so I don’t get the “Error 17", but if fails in a different way: “undefined is not an object (evaluating ‘t.chart’)” Now I’m trying to get some source-maps, so I have a chance of figuring out what this issue really is (shadow-cljs noob).#2020-03-2508:06thhellerthe issue likely doesn't have anything to do with shadow-cljs. I suspect that you just have to initialize the sankey module somehow. I can't tell you how though. the highcharts docs probably mention it with an example for npm. that you'd just need to translate.#2020-03-2519:14wasser@thheller - right you are! pawing theough the docs for react-jsx-highcharts I found the all important call: [“highcharts/modules/sankey” :as addSankeyModule] ... (addSankeyModule Highcharts)#2020-03-2501:44hkrishError with react-datepicker. I have been trying to use react-datepicker in my app with shadow-cljs. I installed react-datepicker and react-bootstrap, with pm. Then I required in the cljs namespace with ["react-datepicker" :as ds]. While compiling I am getting the following error: has anyone got this error before? Any hint is appreciated. Spent quite a bit of time on this.. IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError clojure.lang.Reflector.getInstanceField (Reflector.java:397) clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440) shadow.build.closure/js-error-xf/fn--11865 (closure.clj:536) clojure.core/map/fn--5862/fn--5863 (core.clj:2742) clojure.core.protocols/iter-reduce (protocols.clj:49) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8140 (protocols.clj:75) clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13) clojure.core/transduce (core.clj:6884) clojure.core/into (core.clj:6899) clojure.core/into (core.clj:6887) shadow.build.closure/log-warnings (closure.clj:1092) shadow.build.closure/log-warnings (closure.clj:1088) shadow.build.closure/convert-sources-simple* (closure.clj:1860) shadow.build.closure/convert-sources-simple* (closure.clj:1714) shadow.build.closure/convert-sources-simple (closure.clj:2000) shadow.build.closure/convert-sources-simple (closure.clj:1952) shadow.build.compiler/maybe-closure-convert (compiler.clj:1117) shadow.build.compiler/maybe-closure-convert (compiler.clj:1110) shadow.build.compiler/compile-all (compiler.clj:1368) shadow.build.compiler/compile-all (compiler.clj:1229) shadow.build.api/compile-sources (api.clj:255) shadow.build.api/compile-sources (api.clj:247) shadow.build/compile (build.clj:406) shadow.build/compile (build.clj:397) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:316) shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:302) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:942) shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:905) shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325/fn--15333 (util.clj:285) shadow.cljs.devtools.server.util/server-thread/fn--15324/fn--15325 (util.clj:284) shadow.cljs.devtools.server.util/server-thread/fn--15324 (util.clj:257) java.lang.Thread.run (Thread.java:834)#2020-03-2508:07thheller@hkrishnan2005 that is caused by a dependency conflict on the closure-compiler version. common if you use lein. you need to ensure that you have the version shadow-cljs wants which would be
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-03-2508:30Saikyunnot sure if this is related to shadow-cljs or not, but when working with swedish letters "åäö", they end up as "???" in the repl.#2020-03-2508:30Saikyunusing the browser-repl#2020-03-2508:31thhellerand which client? its all utf-8 so if you terminal doesn't show that properly its your terminal#2020-03-2508:32thheller
$ shadow-cljs browser-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (135 files, 134 compiled, 0 warnings, 6.31s)
cljs.user=> "åäö"
"åäö"
#2020-03-2508:32thhellerworks fine for me#2020-03-2508:34SaikyunI tried in both emacs and the terminal.#2020-03-2508:52hindol@saikyun What's your locale and LANG?#2020-03-2508:58Saikyun@hindol.adhya how do I check that? 🙂 unix-noob#2020-03-2508:59Saikyun
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d9b3b6b7b89993b6b7b8aaf494b8ba9bb6b6b2f489abb6"}, :content ("[email protected]")}
#2020-03-2509:17hindolOkay, try setting LANG to "UTF-8" and retry.#2020-03-2509:26Saikyunhow do I do that?#2020-03-2509:40hindolFor now, % export LANG="UTF-8"#2020-03-2509:40hindolIf that works, we'll set that permanently in a different way.#2020-03-2607:59Saikyunsadly, it didn't work#2020-03-2608:00Saikyunnow when I run locale it says that LANG="UTF-8", but I still get ??? when in the cljs-repl#2020-03-2618:34hindolSorry, that's all I can think of.#2020-03-3005:03Saikyunthanks for taking the time to help either way :)#2020-03-2513:33darwinI vaguely remember somone had issues with :refer-clojure :rename and shadow-cljs, I’m now facing an issue with :refer-clojure :only in my .clj file with macros, the file is expected to work, but fails with shadow-cljs with a stack trace originating from shadow.build.macros$load_macros, I didn’t find a relevant issue in shado-cljs github repo, just wondering if I should dig into it and create one#2020-03-2513:34thhellerno clue what you are referring to so yes create an issue or dig into it yourself 😛#2020-03-2513:35darwinok, thanks, will have to find a minimal repro#2020-03-2514:06darwinahh, I take it back, the problem is that I added clojure special form into :only, so it is not shadow-cljs problem at all, I was able to reproduce it with plain clj as well#2020-03-2603:39hkrish@thheller, that solved the problem Thank you so much. On my deps.edn, I added the following:
org.clojure/clojurescript                       {:mvn/version "1.10.597"
                                                 :exclusions
                                                              [com.google.javascript/closure-compiler-unshaded
                                                               org.clojure/google-closure-library
                                                               org.clojure/google-closure-library-third-party]}
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20191027"}
org.clojure/google-closure-library              {:mvn/version "0.0-20191016-6ae1f72f"
                                                 :scope       "provided"}
org.clojure/google-closure-library-third-party {:mvn/version "0.0-20191016-6ae1f72f"}
#2020-03-2609:07teawaterwireis it possible that the build generated by shadow-cljs release can include different versions of npm libs than the one generated by shadow-cljs watch ? (it sounds impossible just writing it 😅 but want to be sure as i'm having a weird bug between in my release build, and it's not a typical extern missing bug, more like a js library outdated and thus returning an error)#2020-03-2609:15thhellerlike what? it will definitely use the same node_modules/lib files#2020-03-2609:30teawaterwireyeah that makes sense 👍#2020-03-2609:31teawaterwirelike i get this error (when sending a eth transaction) with the release bundle and nothing with the dev bundle#2020-03-2609:33teawaterwireand it seems it's because the "value" i'm passing is a BigNumber and the library (encoding parameter for the eth transaction) should accept it, which it does in dev but not in release mode#2020-03-2610:40teawaterwirebut could be then the dynamic require issue#2020-03-3013:27teawaterwirei finally understand what is going on: the js library has a function to check if an object is a BigNumber, it does so by getting object.constructor.name which returns "BigNumber" in dev but a u in prod, because i'm requiring the bignumber.js lib in one of my cljs file it gets optimized. can i fix that with this method? https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2020-03-3015:43thhellerit'll prevent the rename yes#2020-03-3015:44thhelleryou can also turn off the renaming completely via :js-options {:property-renaming :off}#2020-03-3015:51teawaterwireah nice didn't know about that ! if i use the externs/app.txt i go with just the line "BigNumber" or i need smth different because it's a constructor?#2020-03-3015:57teawaterwireit doesn't seem to be working when i write :
# externs/app.txt
BigNumber
#2020-03-3016:00thhellerhmm those externs might not apply to node_modules code#2020-03-3016:00thhellerwhy is the lib checking the name? that seems dumb 😛#2020-03-3016:01teawaterwire😄 yeah it's not ideal https://github.com/ethereum/web3.js/blob/1.x/packages/web3-utils/src/utils.js#L50-L52#2020-03-3016:04teawaterwirecan i type hint smth here?
(ns my-ns
  (:require ["bignumber.js" :as BigNumber]))

(defn to-big-number [num]
  (BigNumber num))
#2020-03-3016:20thhellerI'm not actually sure the extrerns are applied at all to node_modules dependencies. usually they don't need any since they only run through :simple#2020-03-3016:20thhelleropen an issue, I can take a look later#2020-03-3016:46teawaterwirejust did 🙂 https://github.com/thheller/shadow-cljs/issues/677#2020-03-3017:19thhelleractually try :js-options {:variable-renaming false}#2020-03-3017:19thhellerit isn't a property after all#2020-03-3108:02teawaterwireit works! thanks 👍 hopefully it doesn't increase the size of the bundle too much 🙂#2020-03-3108:10teawaterwirefyi (in terms of bundle size) before:#2020-03-3108:10teawaterwireand after:#2020-03-3108:31thhelleryeah it does make things quite a bit larger#2020-03-3108:32thhellermaybe you should try to find out why the eth lib doens't just use instanceof? seems rather weird to me to be checking a name#2020-03-3108:39teawaterwireyeah good point i think it's because they're not including the actual BigNumber package but looking a bit further they're only calling isBigNumber once so i can find a work-around in my code 👍#2020-03-3108:45teawaterwireor i could rewrite this js function in my code no https://github.com/ethereum/web3.js/blob/e914ec3bf1ae3bd053ab86959c001280a2ea79f2/packages/web3-eth-abi/src/index.js#L99 ?#2020-03-3108:45teawaterwiremaybe too complex - i'll just go with the workaround 🙂#2020-03-3108:58teawaterwirei found that overriding the isBigNumber method seems to be working as well 🤓#2020-03-3109:09thhellerhehe#2020-03-2609:15thhellerbut sometimes those files do conditional stuff for development#2020-03-2609:16thhellerlike the dynamic require stuff#2020-03-2612:21martinklepsch@thheller Not sure if you remember but I’ve had some issues with source maps for node-library and node-script . After I earlier thought that everything is actually working I now created a repro case that exhibits the same problems I’m seeing in a larger code base: https://github.com/martinklepsch/shadow-cljs-broken-node-source-maps#2020-03-2612:25martinklepschLet me know if this is helpful, if there’s any more things that should be tested before considering this a bug#2020-03-2612:33thhellerwhy is that using :simple?#2020-03-2612:38martinklepschNo particular reason but verified similar behavior when not setting a custom :optimizations value#2020-03-2612:38martinklepschWill also give :whitespace a try#2020-03-2612:39thhellerwhitespace isn't supported#2020-03-2612:39martinklepschyup, just saw that 😅#2020-03-2612:39thhellerjust wondering why its simple. not something I ever tested with source maps#2020-03-2612:40martinklepschI think it might be an artifact from before using shadow#2020-03-2612:52thhellerit seems to be working ok-ish for me with :advanced. it just moving code all over the place so the actual source-maps.core ns/file doesn't exist anymore since its just inline elsewhere#2020-03-2612:52thhellerkinda difficult to analyze dummy code like this since its inlined so aggressively#2020-03-2612:54martinklepschlet me try with advanced in a more complex codebase#2020-03-2613:04martinklepschSeeing similarly off results with :advanced#2020-03-2613:05thheller
$ node -r source-map-support/register out/main.js 0
Error: boom
    at new $cljs$core$ExceptionInfo$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:11304:31)
    at Function.<anonymous> (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/source_maps/core.cljs:4:9)
    at $cljs$core$apply_to_simple$cljs$0core$0IFn$0_invoke$0arity$03$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:3890:15)
    at $cljs$core$apply$cljs$0core$0IFn$0_invoke$0arity$02$$ (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:3924:30)
    at /mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/cljs/core.cljs:10028:46
    at Object.<anonymous> (/mnt/c/Users/thheller/code/tmp/shadow-cljs-broken-node-source-maps/out/main.js:5698:3)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
#2020-03-2613:05thheller
(ns source-maps.core)

(defn main [x]
  (when (zero? (js/parseInt x 10))
    (throw (ex-info "boom" {:x x}))))
#2020-03-2613:06thheller
{:deps true
 :builds
 {:main
  {:target :node-script
   :main source-maps.core/main
   :output-to "out/main.js"
   :compiler-options {:source-map true}}}}
#2020-03-2613:06martinklepschLike sourcemap.clj returns lines in cljs-node-io.core as part of the stacktrace but the error is thrown elsewhere#2020-03-2613:07thhellerthat looks accurate when using --debug#2020-03-2613:07thhellerwithout it doesn't .. so dunno whats happening there#2020-03-2613:07martinklepschyou mean release --debug?#2020-03-2613:07thhelleryes#2020-03-2613:08martinklepschwhat is source-map-support/register?#2020-03-2613:08thhellerloading the node source map support#2020-03-2613:08thhellerotherwise it won't load any source maps at all#2020-03-2613:09martinklepschAh interesting, so that allows us to see source maps right in the stacktrace vs using sourcemap.clj? that’s convenient 😅#2020-03-2613:14thhelleryeah for development builds thats just loaded automatically. for release you have to load it#2020-03-2613:16martinklepschOk, I can reproduce --debug fixing the issue#2020-03-2613:30martinklepschinteresting, it seems like after installing source-map-support I get more reasonable mappings already#2020-03-2613:31martinklepschalso when looking them up with sourcemap.clj#2020-03-2613:34thheller--debug is basically :pseudo-names true + source maps#2020-03-2613:34thhellerso I suspect source maps work better because of pseudo-names giving everything names that would otherwise be stripped#2020-03-2615:50martinklepschafter a few more hours of fiddling with this I find that the only way I can remotely make it work is optimizations simple + pseudo-names and pretty-print but also there’s so many variables that I’m losing trust that I can actually hold the different combinations in my head 😄#2020-03-2617:10thhellerhmm yeah I dunno why its so weird, I don't do much node stuff so I can't really tell where the problem is#2020-03-2617:10thheller--debug seems to do the trick and that is all I use#2020-03-2714:12martinklepschI’ve tried setting pseudo-names and pretty-print individually but I’ll give --debug another try as well#2020-03-2714:34thheller--debug is basically :source-map true :pseudo-names true :pretty-print true#2020-03-2714:35thheller--pseudo-names is pseudo and pretty because sometimes its easier to debug without source maps#2020-03-2618:29cobyI'm troubleshooting an issue in IE11 - my compiled app throws the error "WeakSet is undefined." I did npm install --save weakset and included ["weakset"] in my top-level require, but I'm still getting the error. Do I need to explicitly set js/window.WeakSet? Declare an extern? The user guide says that everything should be polyfilled down to IE10+, but I think I must be taking that out of context or something. Thanks!
(ns multicare-dfd.core
  (:require
   ["weakset"]
   [reagent.core :as reagent] ,,, ))
#2020-03-2619:35thheller@ctamayo who/what uses weakset? for polyfills like that it is probably better to use a third party polyfill since modern browsers won't need it#2020-03-2619:36thhellersomething like https://polyfill.io/v3/#2020-03-2619:47coby@thheller I'm not actually sure what is using it. I'm a bit confused because npm ls weakset just shows that my top-level module is the thing including it. What do you mean by polyfills like that?#2020-03-2619:48thhellerweakset is a standard JS feature in newer versions but it doesn't exist in IE11#2020-03-2619:49thhellerso if its not your code using weakset then it is likely some library which assumes you are using a modern browser or polyfills#2020-03-2619:50cobyyeah that is my thought as well#2020-03-2619:53cobyso then I am misunderstanding this somehow: > By default the generated JS output will be compatible with ES5 and all "newer" features will be transpiled to compatible code using polyfills. This is currently the safest default and supports most browsers in active use (including IE10+). What does that mean, if not that shadow-cljs injects polyfills needed for IE10+? Based on what you're saying I'd expect WeakSet to fall under that umbrella#2020-03-2619:53thhellerthat only counts for CLJS output#2020-03-2619:53thhellernpm is different#2020-03-2619:54cobyah, so you think something is using an NPM dependency that in turn uses WeakSet?#2020-03-2619:54thhelleryes#2020-03-2619:55cobyI see. That makes sense.#2020-03-2703:57haywoodran into an issue where an npm package I was using had it’s own nested node_modules folder, and the require call in it’s code was importing the package in the root of my project’s node_modules directory, which came from another libraries dependencies. I don’t think this is wrong but does anyone know what’s happening in JS land that some dependencies get flattened out#2020-03-2703:58haywoodthe work around is to reroute the dependency, just looking for clarification
"history" {:target :npm :require "@elastic/search-ui/node_modules/history"}
#2020-03-2704:03haywoodhttps://github.com/thheller/shadow-cljs/issues/392#2020-03-2704:04haywoodfound some prior art#2020-03-2704:28haywoodI think I understand where you’re coming from by not supporting searching in a nested node_module directory, but new to clojurescript folks can get tripped up big time when encountering this. It’s not obvious what the issue is when you’re debugging “Why is it saying this function doesn’t exist on the package?”#2020-03-2704:30haywoodI’m going to try and solve this on the yarn side of the house, I get the logic behind sticking to flat dependencies. My coworker who’s new to Clojurescript was/is very frustrated by this 😞 And I do think it’s kind of a rare occurrence, just unfortunate to happen to him, and I didn’t know what was going on for a while. Looking through transpiled javascript dependencies is not fun.#2020-03-2721:09p-himikHave you dealt with the util package before? https://www.npmjs.com/package/util Should all users of shadow-cljs just run npm i util if some other package assumes that util is available?#2020-03-2721:10thhellerI'm guessing that you should install shadow-cljs in the project so the polyfills it depends on are also installed#2020-03-2721:10thhellerwhich I believe includes util#2020-03-2721:11thhellerhttps://www.npmjs.com/package/node-libs-browser#2020-03-2721:14p-himikAh, right... Yeah, I still have shadow-cljs installed in devDependencies. picard-facepalm#2020-03-2721:14p-himikThanks!#2020-03-2721:14thhellerthats fine? and where it should be?#2020-03-2721:15p-himikYou said about a year ago that it should be in the regular dependencies. This is not fine on Heroku, where it builds the production build, thus not installing anything in devDependencies.#2020-03-2721:15thhellerno I never said that#2020-03-2721:15thhellerI said you can't put it in there if you install dependencies with the production profile#2020-03-2721:16thhellerso don't install production dependencies if you intend to do "development"#2020-03-2721:17thhellerif your setup requires putting in into the dependencies then do it#2020-03-2721:17thhellerany regular setup is fine with devDependencies#2020-03-2721:19p-himikIIRC you said that it makes no sense to use dev because anything unneeded just won't be used at all, thus there's no point in this explicit separation. But never mind. The thing is, I didn't really need shadow-cljs as an NPM package in order to build the release version. And of course it broke when I upgraded tinymce-react. I'd blame tinymce-react for not specifying util as one of the dependencies. Hate this implicit stuff.#2020-03-2721:21p-himikGod dammit.
The required JS dependency "inherits" is not available, it was required by "node_modules/util/util.js".
Why does everything have to be implicit with all this stuff?
#2020-03-2721:22thhellerwebpack5 is gonna deprecate those implicit node packages so people will hopefully stop doing that#2020-03-2721:22thhellerbut who knows when that will be released. they've been talking about it for a while now.#2020-03-2721:25p-himikNo worries, there will always be some other thing that people start doing because it's "clever". :(#2020-03-2721:28thhellerI suspect most people do it because webpack just works that way. If it warned then people would likely pay more attention#2020-03-2721:30p-himikSo, I did move shadow-cljs to the regular dependencies. I even upgraded NPM and removed node_modules. And would you look at that. And of course it doesn't work.#2020-03-2721:30p-himikAt this point, I hate NPM with so much passion, it might be just enough to write a sensible alternative to it. Unless it exists?#2020-03-2721:30thhellerhmm? it should only install those nested if they already exist in the top lvl?#2020-03-2721:31p-himikNope, they don't exist.#2020-03-2721:31thhellerdid you keep your lockfile?#2020-03-2721:31thhellerneed to delete that too. otherwise you'll get exactly the same structure you had before deleting everything#2020-03-2721:32p-himikThat was it! Thanks.#2020-03-2721:32p-himikI was under the impression that the lock file is only useful with npm ci.#2020-03-2723:51Chris McCormick@p-himik you probably considered this already but an alternative way to structure your deployment is to keep a separate bare branch (like what gh-pages is for GitHub pages) and version only your production artifacts in there, and this is what you push up to Heroku, not your dev branch. Another way to do it is have a separate shadow-cljs declaration for generating your prod build artifact which builds to a different location than the dev version, and have the build artifact versioned also.#2020-03-2723:52Chris McCormickUsing these methods you don't need to even run npm install on the remote as everything is bundled into the artifact.#2020-03-2809:31p-himikHonestly, I don't like approaches where I need to version artifacts. It may make things easier for Heroku specifically, and specifically when I'm the only developer. But before switching to it, I would rather switch to something else entirely because I'm gradually getting more weary of Heroku. Anyway, thanks for the idea!#2020-03-2811:26Chris McCormickunderstood, totally get that as I am also weary of Heroku.#2020-03-2800:43lilactownwhat’s recommended for RN + shadow-cljs development these days, expo or react-native’s CLI?#2020-03-2802:37lilactownI went with react-native’s CLI#2020-03-2802:38lilactownI’m noticing with the latest shadow-cljs version, that preloads and :dev/after-load aren’t working#2020-03-2802:38lilactown:preload namespaces are never loaded and :dev/after-load are never run#2020-03-2804:25Aleediirc shadow-cljs does not work out of the box with react-native, only with expo. I’d recommend starting with expo anyway, since it’s easier to setup and use#2020-03-2808:32thhellerof course it works out of the box#2020-03-2808:32thheller@lilactown sounds like you are maybe using lein/deps.edn and have a dependency version conflict?#2020-03-2815:55lilactownI only have shadow-cljs and helix as dependencies. I am using deps.edn I was trying out just putting shadow-cljs in deps.edn; I haven’t installed it via npm. would that produce a similar effect?#2020-03-2816:12thhelleryou should always have it installed via npm but don't see how it would affect this#2020-03-2821:16lilactownThis is my deps.edn:
{:paths ["src"]
 :deps {thheller/shadow-cljs {:mvn/version "2.8.94"}
        lilactown/helix {:local/root "../helix"}}}
how would I look for a dependency conflict in this case?
#2020-03-2821:53thhellerlikely isn't a dependency conflict then#2020-03-2821:53thhellerjust check via clj -Stree to be sure though#2020-03-2821:53thhellerprobably something else if the versions are all correct. dunno what though.#2020-04-0116:48lilactownI don’t know what happened, but I restarted shadow-cljs a couple times and it started working :man-shrugging:#2020-04-0116:48lilactownshadow-cljs + react-native is super slick! I appreciate it a lot#2020-03-2808:33thhellerwhich causes goog.define to not work which in turn causes the devtools to not load at all#2020-03-2808:55otwieraczHey, I suddenly started getting errors:
The required JS dependency "core-js/library/fn/parse-int" is not available, it was required by "node_modules/@babel/runtime-corejs2/core-js/parse-int.js".

Search in:
        /c/Users/Slawek/Work/foo/bar/node_modules
You probably need to run:
  npm install core-js/library/fn/parse-int

See: 
My dependencies are:
:dependencies [[reagent "0.8.1"]
                [secretary "1.2.3"]
                [venantius/accountant "0.2.4"]
                [re-frame "0.10.5"]
                [day8.re-frame/http-fx "0.1.6"]
                [re-com "0.9.0"]
                [com.andrewmcveigh/cljs-time "0.5.2"]
                [re-frisk "0.5.3"]      ;NOTE enable only for debugging
                ]
have you seen something like that?
#2020-03-2808:55thhellernpm package version conflict#2020-03-2808:56otwieraczHow can I debug this?#2020-03-2808:58thhellernpm ls and see which packages are doubled#2020-03-2808:59thhellermostly look for core-js#2020-03-2811:56arttukaHi, if I have a CLJS library (from Clojars) with its own package.json file and I want to use that library in another project, do I have to declare the library's dependencies again in that project's package.json or can I somehow tell shadow-cljs to look at the library's package.json as well?#2020-03-2811:56thhellerthat library must include a deps.cljs file with {:npm-deps {"a-dependency" "version"}}#2020-03-2811:59arttukathanks! I tried to google this but failed to find an answer.#2020-03-2813:51SpacemanI installed shadow-cljs as follows:
npm install -g shadow-cljs
Then I created a shadow-cljs.edn file, with the following:
{:source-paths
 ["src/cljs" "src/cljc" "dev"]
 :dependencies
 []
 :builds
 {:app
  {:target :browser
   :output-dir "resources/public/js/compiled"
   :asset-path "/js/compiled"
   :modules {:myapp {:entries [myapp.system]}}}}}
Then in the already running clj repl, I do M-x cider-connect-sibling-cljs, and select the shadow repl option. But I get that shadow-cljs Clojurescript REPL is not available. How do I get shadow cljs to work?
#2020-03-2813:51thhellersame answer as in #cider 😛#2020-03-2820:40awb99I am using shadow-sljs with lein project.clj for dependencies,#2020-03-2820:41awb99will shadow-cljs respect :managed-dependencies ?#2020-03-2820:42thhellerlein handles that. shadow-cljs is never even looking at project.clj#2020-03-2820:44awb99:lein   {:profile "+cljs"}#2020-03-2820:45awb99But when I configure shadow-cljs to use leiningen for dependencies#2020-03-2820:48thhelleragain ... lein handles that 😛#2020-03-2820:49thhellerall shadow-cljs does is lein with-profiles +cljs run -m shadow.cljs.devtools.cli ...#2020-03-2820:49thhellerso whatever you configure in project.clj will apply but it has nothing to do with shadow-cljs#2020-03-2821:10awb99ahh#2020-03-2821:10awb99I get it.#2020-03-2821:10awb99So basically shadow-cljs is not parsing project.clj but instead will get the dependencies for the profile from leiningen.#2020-03-2821:16lilactownyeah, leiningen will be used to get dependencies and start the shadow-cljs application#2020-03-2821:23awb99thanks @thheller @lilactown#2020-03-2822:42knubieTrying to compile a release build targeting react native, but getting this error when compiling a release build (the regex seems to work fine in the emulator). Is there anyway of getting around this?#2020-03-2823:18thhellernever seen that error before. can't even tell where its from because there is no context/stacktrace#2020-03-2823:54knubie@thheller Maybe comes from the google closure compiler?#2020-03-2823:54knubieMore context#2020-03-2823:56thhelleryou can try :compiler-options {:output-feature-set :ecmascript-next}. that will basically not make it transpile anything.#2020-03-2900:05knubieOk I’ll give that a try thanks#2020-03-2910:12stevechan#2020-03-2910:13stevechanwhen i use the command clojure -A:cider:cljs:shadow watch jarvis , it’s will build success.#2020-03-2910:15stevechanbut i use the M-x cider-jack-in-cljs => chose shadow-cljs => chose :jarvis , i will get this Error: Build failure , The required namespace “shadow.remote.runtime.cljs.browser” is not available. #2020-03-2910:20stevechanthis is my shadow-cljs.edn file:
{:deps   {:aliases [:cljs]}
 :builds {:jarvis {:target :browser
                   :output-dir "resources/public/js"
                   :modules
                   {:jarvis {:init-fn functor-api.core/init!}}
                   :devtools
                   {:http-port  8801
                    :http-root  "resources/public"
                    :after-load functor-api.core/mount-components
                    :preloads   [shadow.remote.runtime.cljs.browser]}}

          :test {:target   :browser-test
                 :test-dir "src/test/resources/public/js/test"
                 :devtools
                 {:http-port 8821
                  :http-root "src/test/resources/public/js/test"}}}}
#2020-03-2910:21thhellerwhich shadow-cljs version do you use? in the deps.edn file?#2020-03-2910:22thhellerI don't know anything about cider so can't help much in that regard#2020-03-2910:23Ahmed Hassanshadow.remote.runtime.cljs.browser what is this preload?#2020-03-2910:35stevechan#2020-03-2910:25stevechan#2020-03-2910:26stevechan#2020-03-2910:27stevechan@thheller it’s my dep.edn#2020-03-2910:28thhellertry version 2.8.94. the version you have didn't have that ns#2020-03-2910:32stevechan@thheller build failure again.#2020-03-2914:39dpsuttonIf you’re on the latest cider the repl buffer should have the commands it’s running to get everything set up #2020-03-2914:45dpsuttoncouple questions for you though. When running this from the command line I see you use the shadow-cljs alias. Are you adding this to the startup command when cider-jack-in?#2020-03-2915:00dpsuttoni walked through an example here with thoughts:#2020-03-2915:00dpsuttonhttps://github.com/clojure-emacs/cider/issues/2812#2020-03-3122:24stevechanThanks :+1: , when i use clojure -A:cider:cljs:shadow watch jarvis , then i cider-connect-in-cljs , it’s work require shadow.remote.runtime.cljs.browser.#2020-03-2910:33stevechan#2020-03-2910:36thhellersorry I can't tell what cider is doing so I can only help with actual shadow-cljs output#2020-03-2910:41stevechan@thheller thanks 😄#2020-03-2911:31Quentin Le GuennecHi, is there a way to access the clojurescript compiler from a shadow project? I need to add a onclick handler to a DOM node (`onclick="console.log('hi')"`), for that I would need: (compile '(.log js/console "hi")#2020-03-2914:03thheller@quentin.leguennec1 that is not supported and not a good idea either#2020-03-2914:04Quentin Le Guennec@thheller why is that?#2020-03-2914:05Quentin Le GuennecI found another way around, by the way. Attaching an event works, no need for an onclick attribute#2020-03-2914:06thhelleryes, attach event handlers via code and not via html#2020-03-2914:06Quentin Le GuennecYeah#2020-03-2914:06Quentin Le GuennecI think that's what react does#2020-03-2914:07thhelleryes#2020-03-2914:07Quentin Le GuennecI'm trying to rewrite react#2020-03-2914:07Quentin Le Guenneclots of fun#2020-03-3000:15fabraohello, I know that import { Card } from 'antd'; -> ["antd" :refer (Card)] but const { Meta } = Card; ?#2020-03-3000:43lilactownuse JS interop#2020-03-3000:47fabraoI got it -> (def Meta (.-Meta Card))#2020-03-3003:47Bardia PourvakilAnyone have any idea why I’m not able to access my namespaces in my CIDER nrepl session into my shadow-cljs project ?#2020-03-3005:08Saikyunhow would one set some code from the http-server that is "injected" into my cljs-code? in my case I want to set an url to a server depending on which server my cljs-code is running from. like so:
server hosting cljs          rest api server
localhost                    localhost:1234
              
                     
#2020-03-3005:10Saikyunright now I use ring and just serve static files. was thinking that maybe one could modify something in the files when ring sends the static files#2020-03-3005:10Saikyunnow that I think about it, maybe this is a question for the server, not shadow-cljs... 🙂#2020-03-3005:20Saikyunis it possible to add more release-"variants"? so that I could do: shadow-cljs dev-release app and keep the server-config in :closure-defines?#2020-03-3008:51thheller@saikyun what I recommend is passing this stuff via HTML. so you call <script>your.app.init("the-server-url");</script> in your HTML and (ns ) (defn ^:export init [server-url] ...) in your code#2020-03-3116:30Saikyunaha, interesting. thanks for the tip 🙂 that sure is helpful#2020-03-3011:19David PhamI am developping a node-js script and it compiles to a single file. Is there a way to also compile all the dependencies from npm into that single file?#2020-03-3011:20David Pham(hello everyone)#2020-03-3013:10sogaiu@neo2551 i think thheller mentioned ncc the other day: https://github.com/zeit/ncc -- does that look relevant?#2020-03-3013:30David PhamI will try. Seems quite good. Thanks.#2020-03-3015:44thhelleryeah ncc is recommended#2020-03-3017:26martinklepschIs there a way to run shadow/node-repl with :reader-features #{:node} ? (i.e. without attaching to a specific build and with a “built in” runtime as node-repl provides)#2020-03-3017:30thheller@martinklepsch you can try via (shadow/node-repl {:config-merge [{:compiler-options {:reader-features #{:node}}]})#2020-03-3017:30thhellerthat might only work by accident though, not actually sure 😛#2020-03-3017:31thhellerotherwise you can open an issue, currently that build isn't very customizable#2020-03-3018:23martinklepsch@thheller that actually worked, great!#2020-03-3102:20awb99I have a question of sub-npm dependencies that are written to deps.cljs#2020-03-3102:20awb99If I require multiple projects that have deps.cljs#2020-03-3102:21awb99I guess the only way for shadow-cljs to find out about them, is to access the resources.#2020-03-3102:21awb99Now my question is,
#2020-03-3102:21awb99if multiple libraries are included, that all add the deps.cljs with the same location,#2020-03-3102:21awb99then this resources will override each other.#2020-03-3102:22awb99So basically, the deps.cljs files would need to be placed into UNIQUE locations#2020-03-3102:22awb99for each library.#2020-03-3102:22awb99Could this be the case?#2020-03-3105:17cobyI'm trying to serve a web worker but I'm running into Content Security Policy issues when the browser tries to init the worker. It appears the Content-Security-Policy header is not being sent. Am I using :push-state/headers wrong?
{:source-paths ["src"]

 :dependencies [[binaryage/devtools "0.9.7"]
                [reagent "0.8.0-alpha2"]]

 ;; serve the public directory over http at port 8700
 :dev-http {8700 {:root "public"
                  :push-state/headers {"Content-Security-Policy" "default 'self'"}}}

 :builds
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"

        :modules
        {:common {:entries []}
         :main {:entries [pwa.core]
                :depends-on #{:common}}
         :service-worker {:web-worker true
                          :depends-on #{:common}
                          :init-fn pwa.service-worker/init}}}}}
#2020-03-3108:27thheller@ctamayo the server doesn't set any CSP by default so you are likely setting it in your HTML?#2020-03-3116:19coby@thheller no, it's just the default generated index.html from lein new shadow-cljs pwa +reagent#2020-03-3116:19thhellerno clue what that generates#2020-03-3116:20cobyhttps://github.com/shadow-cljs/lein-template/blob/master/resources/leiningen/new/shadow_cljs/index.html#2020-03-3116:20cobyTL;DR, no http-equiv to be found#2020-03-3116:24cobyBack to basics for now, does my :push-state/headers look right?#2020-03-3108:28thheller@hoertlehner each library can have its own deps.cljs in the .jar it ships. they won't conflict.#2020-03-3108:36awb99@thheller many thanks for the clarification!#2020-03-3108:36awb99in case of web servers that serve from embedded resources, they ar eonly able to serve one version.#2020-03-3108:37awb99so I thought that this might be similar for shadow-cljs#2020-03-3108:37awb99seems you look deep inside the jars to find that out.#2020-03-3108:37thhellerwell generally it is true that names on the classpath must be unique#2020-03-3108:38thhellerbut instead of asking for one thing by name you can also ask for all the things using that name#2020-03-3108:38thhellerclassloader .getResource vs .getResources#2020-03-3108:39thhellerso there can always be multiple versions, there are just simple rules to determine which one is the "winner" when looking up a single one by name#2020-03-3108:39thhellersometimes it is useful to get all (eg. deps.cljs)#2020-03-3108:44awb99sure#2020-03-3108:44awb99I see.#2020-03-3108:44awb99perfect!!#2020-03-3111:58Ben HammondI'm trying to use the auth0 SinglePageApp client library like this
"dependencies": {
    "@auth0/auth0-spa-js": "^1.6.5",
and then from within cljs
(:require ["@auth0/auth0-spa-js" :as auth0]
...
(auth0/createAuth0Client auth0-config)
but I just see a
#2020-03-3112:04Ben Hammond
main.js:2226 failed to load uix.control_auth.js TypeError: module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.createAuth0Client is not a function
    at eval (control_auth.cljs:23)
    at eval (alpha.cljc:162)
    at eval (alpha.cljc:140)
and when I look in the repl I see that the namespace is a function
(require '["@auth0/auth0-spa-js" :as nsauth])
=> nil
(type nsauth)
=> #object[Function]
the resources/public/js/cljs-runtime/module$node_modules$$auth0$auth0_spa_js$dist$auth0_spa_js_production.js.map looks like
"names":[...,
"createAuth0Client",
...]
the original function is declared as
export default async function createAuth0Client(options: Auth0ClientOptions) {
so it IS default, (which I can call), but why cannot I call the real function? is it the ES8-only async causing linking problems?
#2020-03-3112:06Ben HammondI set my :compiler-options to
:compiler-options
        {:infer-externs :auto
         :closure-warnings {:global-this :off}
         :closure-defines {"goog.DEBUG" true#}
         :output-feature-set :es8}
but it doesn't seem to have helped...
#2020-03-3112:18thheller@ben.hammond nothing to do with your config#2020-03-3112:18thhellercreateAuth0Client is not a function#2020-03-3112:18thheller
(type nsauth)
=> #object[Function]
#2020-03-3112:19thhellerso its likely that you just call (nsauth config)#2020-03-3112:19thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2020-03-3112:48Ben HammondI'd like to understand why the actual named function call doesn't work though if I can#2020-03-3113:08thhellerthere is no such thing as a named function#2020-03-3113:08thhellersee the export default the only name that has is default#2020-03-3113:09thhellerbut that depends on how the package is actually bundled#2020-03-3113:23Ben Hammondah okay; that is the gap in my understanding#2020-03-3113:34thhellerwell not really. generally default exports don't have a name. it is just the default#2020-03-3113:35thhellerso import Foo from "@auth0/auth0-spa-js" is just as valid as import createAuth0Client from "@auth0/auth0-spa-js"#2020-03-3113:35thhellerthe importer defines the name, not the lib#2020-03-3113:35thhellerbut .. yeah it is subject to how things are bundled#2020-03-3113:35thheller:default exports are weird#2020-03-3116:30Saikyuncurrently teaching two people cljs using shadow-cljs, so far so good 🙂 thanks for making it such an enjoyable experience#2020-03-3117:27papachanIs there a template to publish shadow-cljs project to github page?#2020-03-3117:50hindolI did a few recently, e.g. https://github.com/hindol/genesis Let shadow write files to docs/ instead of the default public/ and in Github's repo settings, enable pages from docs folder.#2020-03-3117:52hindolEverytime you want to update the site, remember to 1) first clean existing built files, 2) npx shadow-cljs release app (assuming app is your build target) and 3) git push!#2020-03-3117:53hindolThe caveat is, you have to check-in the shadow built files.#2020-03-3120:39papachanThank you @UJRDALZA5#2020-03-3120:46hindolNo problem. Let me know if you face any issues.#2020-04-0100:28Chris McCormicksomething i have found useful is to configure two separate targets, one for dev and one for prod, and have the prod target build to a different place from the dev target. This way you don't have to do the cleaning step.#2020-04-0102:34papachangreat idea ! @UUSQUGUF3#2020-04-0105:18hindolThat's a great tip! @UUSQUGUF3 Is it possible to share the same index.html between two builds? By copying as part of the build step, perhaps?#2020-04-0108:47thhellerNO!#2020-04-0108:47thhellerthat is not how shadow-cljs is meant to be used!#2020-04-0108:47thhellerDO NOT USE DIFFERENT BUILDS FOR DEV/PROD!#2020-04-0108:47thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-04-0108:48thhellerif you just want a different output dir for release then do :release {:output-dir "foo"} in your build config#2020-04-0108:48thhellerno point in making totally different builds!#2020-04-0109:22Chris McCormickoh awesome, thanks for that :release :output-dir option :+1:#2020-04-0109:23Chris McCormickmy apologies for the fake news#2020-04-0109:24Chris McCormick@UJRDALZA5 in terms of build I use a Makefile to do the final build which invokes the production build and also copies files from public to build.#2020-04-0109:36hindolCan you please link to the repo if it's in the public domain?#2020-04-0111:31Chris McCormick:+1: will see if i can find a public one#2020-04-0111:33Chris McCormick@UJRDALZA5 https://github.com/infinitelives/px3d/blob/master/Makefile#2020-04-0111:33Chris McCormickthough here i am using the technique which @thheller said not to use, with the two different targets. so i should update that.#2020-04-0111:39hindolThanks for the link! Really helpful.#2020-04-0111:45Chris McCormickyou could also do it in Java if that is easier: https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2020-04-0112:22hindolThe deps.edn approach also looks interesting.#2020-04-0109:44frankiesardoHello 👋 I just noticed shadow-cljs is significantly slower to do hot code reloading than figwheel (I only have one dependency: material-ui). Is there something I am doing wrong? We're talking about < 1 second with figwheel and > 5 seconds with shadow#2020-04-0109:44frankiesardoHello 👋 I just noticed shadow-cljs is significantly slower to do hot code reloading than figwheel (I only have one dependency: material-ui). Is there something I am doing wrong? We're talking about < 1 second with figwheel and > 5 seconds with shadow#2020-04-0109:58kwrooijenHi, I used material-ui in the past, en I also had performance issues. The reason was that if you require material-ui core like this: ["@material-ui/core" :refer [Button Container]] You don't only require Button and Container, but everything in core. To prevent that I had to require each component individually. ["@material-ui/core/Button" :default Button] ["@material-ui/core/Container" :default Container] ... Maybe you're experiencing the same issue?#2020-04-0109:59frankiesardoOooh that makes sense, thanks I'll give it a try!#2020-04-0110:00frankiesardo["@material-ui/core/Button" :default Button] is it :default or :as ?#2020-04-0110:01kwrooijenhttps://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2020-04-0110:01frankiesardoAwesome#2020-04-0110:02kwrooijenAlso I think the reason we moved away from Material UI is because the newest version had incompatible React feature (for Reagent)#2020-04-0110:03frankiesardoDo you have a link for this issue? I'm using bare react but i'd be useful to know#2020-04-0110:08kwrooijenI can't seem to find it sadly. Sorry.#2020-04-0206:14Saikyun@frankie the issues I've found are: • TextField cursors acting up -- info & fix: https://github.com/reagent-project/reagent/blob/master/doc/examples/material-ui.md) • [:> Component (for ...)] acting up with seqs, solvable by writing (into [:> Component] (for ...)) -- -- https://github.com/reagent-project/reagent/issues/369 • material-ui has started using hooks, which are messy to use in reagent (imo). I've just avoided them, but supposedly they can be used -- info: https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#hooks#2020-04-0206:24kwrooijenAhh thanks @UCG86LJFN The hooks were my issue as well#2020-04-0109:44frankiesardo
"dependencies": {
    "@material-ui/core": "^4.9.8",
    "@material-ui/icons": "^4.9.1",
    "create-react-class": "^15.6.2",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "shadow-cljs": "^2.0.80"
  }
#2020-04-0109:59thheller@frankie I hope you are not actually using that version? that is like 2 years ago old?#2020-04-0110:00frankiesardoOh I used the shadow-cljs template to create a fresh one#2020-04-0110:06frankiesardoAfter using ["@material-ui/core/Button" :default Button] it is much faster now, thanks!#2020-04-0110:06frankiesardoA bit annoying to add a require for each component tho#2020-04-0110:08kwrooijenYeah it is. But I don't think there's another way since core automatically requires everything in a hardcoded way.#2020-04-0110:08kwrooijenI could be wrong though#2020-04-0110:09kwrooijenAnd maybe this is interesting, but haven't looked at it myself: https://github.com/arttuka/reagent-material-ui#2020-04-0110:09kwrooijen(editted the link)#2020-04-0113:58conanhas :target become a required field in a build in shadow-cljs.edn? all my builds have started complaining about it but i'm not sure why#2020-04-0113:58thheller:target was always required#2020-04-0114:01conanmust be something else then, ta#2020-04-0114:24jjttjjI have a function using shadow as a library to start shadow:
(defn start-shadow []
  (shadow-server/start!)
  (shadow/watch :app)
  (shadow/watch :bootstrap-support))
This always worked but very suddenly started giving me a stack overflow error:
#error {
 :cause nil
 :via
 [{:type java.lang.StackOverflowError
   :message nil
   :at [jt14$start_shadow invokeStatic "jt14.clj" 67]}]
 :trace
 [[jt14$start_shadow invokeStatic "jt14.clj" 67]
  [jt14$start_shadow invoke "jt14.clj" 66]
  [jt14$start_shadow invokeStatic "jt14.clj" 67]
  [jt14$start_shadow invoke "jt14.clj" 66]
  [jt14$start_shadow invokeStatic "jt14.clj" 67]
  [jt14$start_shadow invoke "jt14.clj" 66]
  [jt14$start_shadow invokeStatic "jt14.clj" 67]
  [jt14$start_shadow invoke "jt14.clj" 66]
...
It works if I do each one of the three steps sequentially in a repl but not when I call the start-shadow function. I tried updating my shadow dependency to the most recent version (from 8.69 to 8.94). Any clues what might be happening here? Is there a better way to fire up multiple watchers?
#2020-04-0114:27jjttjjAH nevermind#2020-04-0114:27jjttjji was doing something dumb#2020-04-0114:27thhellershadow-cljs watch app bootstrap-support#2020-04-0116:44ullrichToday I had a wonderful day writing CLJS code. It would not have been as good without shadow-cljs . Thank you ❤️#2020-04-0118:34Pavel KlavíkHi, I am trying to add https://github.com/ricardo-ch/react-easy-crop to my project. They say that it should be included by
import Cropper from 'react-easy-crop'
so I am adding it like this:
["react-easy-crop" :default Cropper]
But I am getting an error that
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
When printed, Cropper is undefined. Do I have to include it in another way?
#2020-04-0118:36thhellertry ["react-easy-crop" :as Cropper]#2020-04-0118:39Pavel Klavíkthanks, helped#2020-04-0118:41Pavel Klavíkbtw. wouldn't it be possible to infer the correct form automatically by Shadow-cljs compiler?#2020-04-0118:42thhellersure, just a lot of work given that there are about a billion different ways packages are written and detecting them all means work#2020-04-0118:42thhellerthe docs have a section about default exports#2020-04-0118:43Pavel Klavíkya, I know of that section, and it mostly works, but sometimes a different way is needed, it seems quite random to me#2020-04-0118:43Pavel Klavíkwouldn't it be possible to try out all other different ways and to write some info which one works?#2020-04-0118:50thhellerpossible yes but I'm not really interested#2020-04-0118:50thhellera lot in that area is still changing very much and its gonna change a lot more in the future#2020-04-0118:50thhellerso until the JS world has settled on an actual standard you'll just have to manually test sometimes#2020-04-0118:54thhellerespecially since this is going to be changing on a package by package basis once they adjust their packaging to adhere to the new standards#2020-04-0118:55Pavel KlavíkI see, hopefully this gets resolved#2020-04-0120:27colinkahnI’m sometimes getting a build error that looks like this:
[{:type clojure.lang.ExceptionInfo
   :message "aborted par-compile, [:shadow.build.classpath/resource \"re_frame/core.cljc\"] still waiting for #{re-frame.interop re-frame.interceptor re-frame.events re-frame.fx re-frame.registrar re-frame.router re-frame.std-interceptors re-frame.subs re-frame.cofx re-frame.db}"
   :data {:aborted [:shadow.build.classpath/resource "re_frame/core.cljc"], :pending #{re-frame.interop re-frame.interceptor re-frame.events re-frame.fx re-frame.registrar re-frame.router re-frame.std-interceptors re-frame.subs re-frame.cofx re-frame.db}}
   :at [shadow.build.compiler$par_compile_one invokeStatic "compiler.clj" 955]}] ...
What would cause these namespaces to be waited for like this?
#2020-04-0122:57thhellerabort only happens after 30sec of no progress#2020-04-0122:58thhellerso likely there is something blocking your compilation completely. might be a macro, not necessarily related to the listed namespaces at all#2020-04-0123:22colinkahn@thheller thanks, any tell tale signs for macros like this? I’m trying to think of how to debug/narrow it down.#2020-04-0208:32thhellerpar-compile compiles all namespaces in parallel with a limited number of threads#2020-04-0208:33thhellerso if all threads get stuck for some reason it'll abort after a while#2020-04-0208:33thhellerI haven't seen this reported for re-frame before so dunno why it would fail there#2020-04-0123:51OrdoFlammaeI'm trying to look into CLJS programming, and I keep running across shadow-cljs. However, it's hard to tell from the website what use-cases it's actually for (maybe just because I don't have the necessary vocabulary down XD). So I guess my question is, why would I use shadow-cljs?#2020-04-0123:54steveb8nthe main reason is easy access to NPM libs (for nodejs and browser builds) it also has excellent docs, tooling and active community here. the only downside I’ve encountered is it can be tricky (but not impossible) using code that uses cljsjs deps.#2020-04-0123:55OrdoFlammaeOK, thanks @U0510KXTU.#2020-04-0200:18Chris McCormickfor me personally the most important "use-case" is not spending hours tinkering with your build config, which i had to do with previous build systems. shadow-cljs has excellent defaults and powerful options for when the defaults don't suit.#2020-04-0201:31isakThe DX with shadow-cljs is so good, also the support (see #shadow-cljs), so at this point I think the better question is "why would you not?"#2020-04-0201:32OrdoFlammaeI dunno what DX stands for, but I'm probably not going to use shadow-cljs because I like to pick my own tooling. That'd be my personal reason. Also, I'm kind of liking Boot, and using shadow-cljs wouldn't let me use that.#2020-04-0201:42cobyDX stands for developer experience. 🙂 Using shadow-cljs does not preclude using Boot; there just isn't much built-in integration. But Shadow ships a Clojure API which looks pretty simple (I haven't had occasion to use it myself) and probably gets you a lot more than rolling your own CLJS compiler in Boot. https://shadow-cljs.github.io/docs/UsersGuide.html#_boot#2020-04-0201:53OrdoFlammaeOK. Thanks for the help all!#2020-04-0206:47Saikyunjust want to add that shadow-cljs has great repl support as well 🙂 both on the cljs-side and on the clj-side (e.g. when tinkering with macros)#2020-04-0208:32thheller@U010DM2MVQE I guess I'm biased but if you like spending hours configuring your build setup und digging into issues like hot-reload and repl support then don't use shadow-cljs. if you rather spend time working on your actual code then do use shadow-cljs. 😉#2020-04-0214:20aisamuHi! We're running into an issue with the type inference warnings (and the automatic externs inference, it appears) when we thread js field accesses with some-> instead of ->:
(def window (if (exists? js/window) js/window nil))
(def ^js jswindow (if (exists? js/window) js/window nil))

(js/console.log (-> js/window .-test))
(js/console.log (-> jswindow .-test))
(js/console.log (-> window .-test))

(js/console.log (-> js/window .-test .-identity))
(js/console.log (some-> js/window .-test .-identity))

(js/console.log (-> jswindow .-test .-identity))
(js/console.log (some-> jswindow .-test .-identity))

(js/console.log (-> window .-test .-identity)) ;; <---- Inference warning only here
(js/console.log (some-> window .-test .-identity))
It was observed on 2.8.68 and reproduced on 2.8.93. Is it expected/unavoidable?
#2020-04-0214:43thhellernot sure. please open an issue, can't look into that now.#2020-04-0214:50aisamuDone, thank you!#2020-04-0302:00beders(note to self: read the very good shadow-cljs manual)#2020-04-0307:58teodorluIt's so nice to have a manual that reads from the user's perspective, in an order that makes sense to the user.#2020-04-0316:33tony.kay@thheller thanks for the improved builds screen…much easier to control builds now in .94#2020-04-0318:06David PhamJust a small trick for anyone interested: you can combine deps.edn aliases and shadow-cljs.devtools.cli to have different paths and dependencies between you dev and release builds! I find it it really useful for environment variables for different process and you can have Clojure files instead of using the :closure-defines in shadow-cljs.edn. There is also the debugging library that forces to have different version between dev/prod for re-frame.#2020-04-0318:12David Pham@thheller thanks a lot for shadow-cljs. It made my journey into CLJS and front end extremely enjoyable :)#2020-04-0318:13David PhamThanks to you, I convinced the hire up in my unit to use CLJS as our default front end tool :)#2020-04-0321:47Felipe MarquesHi, I'm trying to init a repl on a specific namespace using the :repl-init-ns , but it does not seem to work. I'm connecting with the command (shadow.api/nrepl-select :app)#2020-04-0321:47Felipe MarquesAnyone has any idea?#2020-04-0321:48dpsutton> You may configure the namespace you start in when connecting by setting `:init-ns` in the `:nrepl` options. It defaults to `shadow.user`.#2020-04-0321:48dpsuttondid you try this?#2020-04-0321:50Felipe Marquesthis is for the clojure repl right?#2020-04-0321:50Felipe MarquesIn this case I want to set the initial namespace for the cljs repl#2020-04-0321:50dpsuttoni believe that's for the cljs repl#2020-04-0321:51Felipe Marquesok, let me try this#2020-04-0321:53Felipe Marquesit didn't work either 😞#2020-04-0321:57dpsutton
{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn app.main/init}}
        :output-dir "public/js"
        :target :browser
        :devtools {:repl-init-ns app.main}}}
 :dependencies [[reagent "0.8.1"]]
 :dev-http {3000 "public"}
 :http {:port 9631}
 :source-paths ["src"]}
#2020-04-0321:57dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#_repl_3#2020-04-0321:58dpsuttonmake sure its under devtools#2020-04-0321:59dpsuttonthe docs don't mention these should be under :devtools key in the build map. but the example shows it there#2020-04-0322:01Felipe Marquesyes, I'm following exactly this example. Everything seems right#2020-04-0322:02dpsuttonthat works for me#2020-04-0322:02dpsutton
~/p/c/asg-ignite-app ❯❯❯ shadow-cljs cljs-repl app
shadow-cljs - config: /Users/dan/projects/clojure/asg-ignite-app/shadow-cljs.edn  cli version: 2.8.83  node: v12.1.0
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.83 running at 
shadow-cljs - nREPL server started on port 63308
app.main=>
#2020-04-0322:05Felipe MarquesThis is the function that I run at Clojure REPL to start the ClojureScript repl
(defn start! []
  (shadow.server/start!)
  (shadow.api/watch :workspaces)
  (watch-with-profile :app :dev)
  (shadow.api/nrepl-select :app))
#2020-04-0322:05Felipe MarquesIs it different from running cljs-repl?#2020-04-0322:48Felipe MarquesYeah, it is definilty they way I'm starting. WIth command-line it starts in the correct ns.#2020-04-0322:03Felipe MarquesHumm, yeah, I imagine I might be doing something wrong#2020-04-0322:03Felipe MarquesI'll try to figure it out. Thanks for the help.#2020-04-0406:53David PhamDid you guys manage to enable pretty print with cider and shadow-CLJS?#2020-04-0407:53hindolWhat does this error mean? There are 29 of these in total.
------ WARNING #1 -  -----------------------------------------------------------
 Resource: 
 Failed to resolve sourcemap at out/cljs/pprint.js.map: out/cljs/pprint.js.map
--------------------------------------------------------------------------------
I was earlier using shadow-cljs.edn for dependencies and it was throwing the same set of warnings but still worked. Now I moved dependencies to deps.end and it stopped working entirely.
;; deps.edn
{:paths ["src"]
 :deps  {cljs-http            {:mvn/version "0.1.46"}
         reagent              {:mvn/version "0.10.0"}
         re-frame             {:mvn/version "0.12.0"}
         re-frame-utils       {:mvn/version "0.1.0"}
         thheller/shadow-cljs {:mvn/version "2.8.94"}}}

;; shadow-cljs.edn
{:builds   {:app {:asset-path "/js"
                  :modules    {:app {:init-fn com.github.hindol.twenty-nine/init}}
                  :output-dir "public/js"
                  :target     :browser
                  :http-root  "public"
                  :release    {:output-dir "../docs/js"}}}
 :deps     true
 :dev-http {3000 "public"}}
All the warnings started after I added re-frame-utils to the mix. I kind of need the FX and COFX stuff from the library. I am willing to copy those functions over if there is no easy fix.
#2020-04-0408:15David PhamDid you require the cljs.pprint namespce anywhere in your code? #2020-04-0408:18hindolYes, I have [clojure.pprint :as pp] in a couple of places. There are a bunch of other errors (total 29 of them, all same type of warning),
------ WARNING #21 -  ----------------------------------------------------------
 Resource: 
 Failed to resolve sourcemap at out/reagent/debug.js.map: out/reagent/debug.js.map
--------------------------------------------------------------------------------
------ WARNING #22 -  ----------------------------------------------------------
 Resource: 
 Failed to resolve sourcemap at out/reagent/dom.js.map: out/reagent/dom.js.map
--------------------------------------------------------------------------------
#2020-04-0408:18hindolSo, I think somehow this is some dependency conflict.#2020-04-0408:19hindolCan I see a dependency tree with shadow?#2020-04-0408:20thhellermy guess is that the re-frame-utils lib contains some compiled code it shouldn't#2020-04-0408:20thhellerand that confuses the compiler#2020-04-0408:21hindolHere is the one I pulled: https://github.com/den1k/re-frame-utils#2020-04-0408:21hindolWill you be kind enough to take a quick look at it?#2020-04-0408:24thhellerI did and yes it contains a bunch of files it shouldn't contain#2020-04-0408:24hindolAny pointers? I am willing to fork it and fix it.#2020-04-0408:24thheller
0 Thu Oct 05 10:21:04 CEST 2017 out/reagent/
 10627 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.cljs
 33164 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.cljs.cache.edn
 30952 Wed Jul 26 16:37:12 CEST 2017 out/reagent/core.js
 12618 Thu Oct 05 10:21:04 CEST 2017 out/reagent/core.js.map
   614 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.cljs
  2007 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.cljs.cache.edn
  2864 Wed Jul 26 16:37:12 CEST 2017 out/reagent/debug.js
  1150 Thu Oct 05 10:21:02 CEST 2017 out/reagent/debug.js.map
  2702 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.cljs
  7765 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.cljs.cache.edn
  6720 Wed Jul 26 16:37:12 CEST 2017 out/reagent/dom.js
  3362 Thu Oct 05 10:21:04 CEST 2017 out/reagent/dom.js.map
#2020-04-0408:25thhellerthe out folder shouldn't be included in the distributed .jar file#2020-04-0408:26hindolThat will be a change in the project.clj? I don't see how that is being included in the jar.#2020-04-0408:26David PhamI would copy the two files #2020-04-0408:26David PhamDirectly into my code base#2020-04-0408:27David PhamThere are two namespaces and only rely on re-frame and reagent [also the test maybe].#2020-04-0408:28hindolI wanted to fix it because re-frame FAQ links to it. Others may experience the same issue. https://github.com/day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md#solutions#2020-04-0408:32thhelleryeah I would just copy the source files into your project and remove the dependency#2020-04-0408:34thhellerthe files are there because the development output files weren't deleted before publishing, so they get published with it.#2020-04-0408:39hindolOkay, that's an easy fix then. Will open a ticket in the repo.#2020-04-0408:40hindolOh, it's already there. https://github.com/den1k/re-frame-utils/issues/5#2020-04-0408:40hindolShould have checked that first.#2020-04-0408:40thhellernormally shadow-cljs has protections against those files. dunno why they don't work#2020-04-0409:02hindolIt did work, even with the warnings. When I moved to deps.edn, it stopped working.#2020-04-0516:04papachanHello, since i enabled :deps true i have this error with devtools: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.#2020-04-0516:16papachanOk it was missing thheller/shadow-cljs {:mvn/version "2.8.94"}#2020-04-0517:18pithylessAnyone using nubank/matcher-combinators with Shadow? I'm requiring matcher-combinators.test in my cljc ns, but the :browser-test target is not picking up any such assertions: (is (match? 2 1)) If I switch to (is (= 2 1)) the error is reported and I have +1 assertions total.#2020-04-0519:33mauricio.szaboSee https://github.com/nubank/matcher-combinators/issues/83#2020-04-0519:35mauricio.szaboI also created a library (check) that wraps matcher-combinators for cases where you can't simply use kaocha#2020-04-0520:20pithylessThanks for confirming, I linked to the same issue in the next thread-reply. Also, thanks for pointing me to your library - https://github.com/mauricioszabo/check - I'll be sure to review the source tomorrow for some testing ideas. ;) I see you're also parsing and transforming the :match return value here: https://github.com/mauricioszabo/check/blob/master/src/check/core.cljc#L13-L24#2020-04-0517:23pithylessI'm wondering if this just won't work out of the box, without some additional plumbing; e.g. I've found Kaocha has some custom reporter plumbing - https://github.com/lambdaisland/kaocha/blob/master/src/kaocha/matcher_combinators.clj - or if I may have just missed something and someone has this working locally.#2020-04-0519:02pithylessLooks like this may be an open issue: https://github.com/nubank/matcher-combinators/issues/83#issuecomment-530370989#2020-04-0522:30papachanCan i use a different library for each build like this with shadow-cljs?
{:paths ["src/cljs"]

 :deps
 {thheller/shadow-cljs {:mvn/version "2.8.94"}
  binaryage/devtools {:mvn/version "1.0.0"}
  reagent {:mvn/version "0.10.0"}
  re-frame {:mvn/version "0.12.0"}
  day8.re-frame/http-fx {:mvn/version "v0.2.0"}}

 :aliases
 {:dev
  {:extra-deps
   {day8.re-frame/tracing {:mvn/version  "0.5.3"}}}
  :prod
  {:extra-deps
   {day8.re-frame/tracing-stubs {:mvn/version "0.5.3"}}}}}
#2020-04-0522:34papachanwell i am stucked by this error: [:app] Build failure: The required namespace "day8.re-frame.tracing" is not available, it was required by "frontend/events.cljs".#2020-04-0522:58papachanGot it working now. thanks. 👍#2020-04-0602:08OzA small question, I've installed a package on my project (vega-lite) using npm install some time ago. today I ran "npm install vega-lite" again, to get a new version. However, when I run shadow-cljs, it still uses the old version. How do I make it use the new version?#2020-04-0602:10OzI tried removing the package, and shadow-cljs noticed it's missing, but when re-installing it it still seems to compile the old version somehow#2020-04-0608:20thheller@ozfraier shadow-cljs should be using whatever is at node_modules/vega-lite. so make sure that is actually the version you want.#2020-04-0613:07OzOn node modules, the version in package.json is 4.9.0, But looking at the source in chromium development tools, it shows a file that starts with:
shadow$provide["module$node_modules$vega_lite$build$vega_lite"] = function(global,require,module,exports) {
var Buffer = require('buffer').Buffer;
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (global = global || self, factory(global.vegaLite = {}));
}(this, (function (exports) { 'use strict';

    var name = "vega-lite";
    var author = "Dominik Moritz, Kanit \"Ham\" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer";
    var version = "4.2.0";
    var collaborators = [
    	"Kanit Wongsuphasawat ()",
    	"Dominik Moritz ()",
    	"Arvind Satyanarayan ()",
    	"Jeffrey Heer ()"
    ];
etc...
At the address http://js/compiled/cljs-runtime/node_modules/vega-lite/build/vega-lite.js Which is maybe derived from ./resources/public/js/compiled/cljs-runtime/module\$node_modules\$vega_lite\$build\$vega_lite.js (which states the version as 4.2.0) I grepped the project, and this is the only vega-lite + 4.2.0 mention I found. Also, an error message says that the version running is 4.2.0. I wonder what may cause it.
#2020-04-0613:24thhellerwell did you look at that actual file?#2020-04-0613:25thhellerit wouldn't be the first time that package.json contains a different version than some constant in the code#2020-04-0613:26thhellerbut other than that did you restart after updating node_modules?#2020-04-0613:26thhellersometimes the cache seems to get confused and miss an update if too many files change#2020-04-0613:26thhellerrestart should fix it#2020-04-0613:26thhellerand are you sure you are in the correct folder?#2020-04-0613:26thhelleralso common source of error ...#2020-04-0613:28thheller<project>/node_modules/vega-lite assuming you didn't overwrite any path related stuff in your config#2020-04-0615:19OzRestarting didn't work, Hmm, I checked the actual file <project>/node_modules/vega-lite/build/vega-lite.js and it has version 4.9.0. Made sure I'm in the right folder.. Maybe the shadow-cljs.edn config can help?
{:lein   true
 :nrepl  {:port 8777}
 :builds {
          :app          {:target     :browser
                         :output-dir "resources/public/js/compiled"
                         :asset-path "/js/compiled"
                         :modules    {:app {:init-fn  crystal-web-client.core/init
                                            :preloads [devtools.preload
                                                       day8.re-frame-10x.preload]}}
                         :dev        {:compiler-options {:closure-defines {re-frame.trace.trace-enabled?        true
                                                                           day8.re-frame.tracing.trace-enabled? true}}}
                         :devtools   {:http-root "resources/public"
                                      :http-port 8280}
                         }
#2020-04-0615:26thhellerlooks fine#2020-04-0615:27thhelleryou can try wiping the resources/public/js/compiled dir or the .shadow-cljs/builds cache dir#2020-04-0615:28thhellerbut this is really basic cache invalidation and that should work fine#2020-04-0615:34OzWiping .shadow-cljs/builds did the trick, many thanks!#2020-04-0707:52thhellerClojurists Together is coming up and I'm thinking about applying for shadow-cljs. I just don't have anything in particular I want to work on. Do any of you have any suggestions about stuff I should be working on?#2020-04-0707:54sogaiumore remote / inspect development?#2020-04-0707:55thhelleryeah that is kinda what I want to work on but its too speculative and really not shadow-cljs specific#2020-04-0707:58thhellermaybe I'll make an update for the Inspect stuff I already built and apply with that separately#2020-04-0707:58thhellerIt is quite different now from the last video after all#2020-04-0707:58sogaiuah, so is the non-speculativeness an important criteria for the application? i thought the results here: https://www.clojuriststogether.org/news/q2-2020-survey-results/ sort of suggested that may be speculative things might be appreciated too?#2020-04-0707:59thhelleryes, but I'm asking specifically if there is something in shadow-cljs itself people would like to see#2020-04-0707:59sogaiuunderstood#2020-04-0708:00thhellergraaljs support has some up in the past and that would be interesting#2020-04-0708:00sogaiuthat does sound interesting#2020-04-0708:00thhellerbut probably not more than a few hours work#2020-04-0708:00sogaiushhh! :)#2020-04-0708:06mkvlrI’d love extra-mains support in shadow#2020-04-0708:07thhellerexplain?#2020-04-0708:08thhellerI know what extra-mains does in figwheel but I don't see why I would use it over separate builds?#2020-04-0708:17teodorluI'd also love to see more work on Shadow-CLJS Inspect. I'm aware that you intend for Inspect to be usable from outside of Shadow-CLJS, but that doesn't make it a "too risky" project, in my opinion. The fact that it can be decoupled from Shadow seems like a pure advantage to me. Sorry for adding a second reply that avoids your constraints, but Inspect is something I think could become fantastic. It might make sense to identify some Shadow-CLJS maintainance tasks to go along. I don't have any good recommendations there. Note that whereas one of the points of Clojurists Together is to fund the "boring work", there's plenty of interest in doing speculative work. Image source: https://www.clojuriststogether.org/news/q2-2020-survey-results/#2020-04-0708:19teodorluI also view Shadow as quite stable in its current state, with great docs. Maintainance work and documentation might be more of a critical task in other projects.#2020-04-0708:52mkvlr@thheller because compiling once instead of x times is less work?#2020-04-0708:52mkvlrwe are probably an outlier with a large number of targets in our codebase#2020-04-0708:53thhellerwell that depends I'd say. for my 6core/12thread CPU running two builds in parallel that may use the same namespace usually end up completing at the same time?#2020-04-0708:54thhellerand extra-mains produces overhead for the "main" build making that always slower and recompiling when it might not need to#2020-04-0708:55thhellerI'm not against adding it since it is fairly trivial to do so. I just don't have use for it myself so I need a proper use-case setup I can use for testing#2020-04-0708:55thhellerwhat do you mean by large number of targets?#2020-04-0708:56thhellerare they all rolled into one with extra-mains during development and then just split out for release builds?#2020-04-0708:57mkvlryes#2020-04-0708:57mkvlrwe have six targets total#2020-04-0708:57mkvlrincluding devcards#2020-04-0708:57thhellercan you clarify what target means for you? :target in shadow-cljs is likely not what you mean?#2020-04-0708:58thhellerso just different builds in shadow-cljs terms?#2020-04-0708:58mkvlryes#2020-04-0708:59mkvlrsorry for the unclear language#2020-04-0708:59mkvlrI guess we should start by trying to switch to shadow an measuring the performance impact, this has been on our list for a while#2020-04-0708:59thhellerand your main concern about using separate builds is that namespaces will be compiled once for each build?#2020-04-0709:00mkvlryes, our setup also is such that we compile the same main namespace for different targets, e.g. browser, web-worker and graaljs#2020-04-0709:01thhellerwell I always recommend making web workers part of your browser build via :modules#2020-04-0709:02thhellerbut you are hosting the entire self-hosted env in a worker right?#2020-04-0709:02thhellereg. https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L78-L96#2020-04-0709:03thhellerthat way the worker and main can share code and the user only downloads cljs.core etc once#2020-04-1107:54mkvlroh, I missed that and didn’t know about that. That should cut things down quite a bit for us, thank you!#2020-04-1107:56mkvlr:init-fn is shadow-specific, right?#2020-04-1108:04thhelleryes#2020-04-1108:05thheller{:init-fn foo.bar/init} is basically sugar for {:entries [foo.bar] :append-js "foo.bar.init();"} but :append-js per module is also shadow-cljs specific#2020-04-1108:08mkvlrhehe, sounds very useful for us though#2020-04-1108:10mkvlrdid you ever try to get it upstream?#2020-04-1108:11mkvlrI do think it’s nice to have a config that’s compatible with vanilla clojurescript#2020-04-1108:11thhellerI gave up on getting any of my ideas upstream a long time ago#2020-04-1108:12thhellerbut the entire :modules integration in shadow-cljs is so completely different that it will be non-trivial to adopt this for core#2020-04-1108:13mkvlralright, no more excuses for us to move to shadow then#2020-04-1108:14thhellerI wondered why you are using :simple compiled CLJS for the "normal" pages that aren't even using CLJS?#2020-04-1108:15thhellerwouldn't it be better for your users to have one :advanced build for regular page stuff#2020-04-1108:15thhellerthat can load self-hosted CLJS separately like I assume you do for other languages?#2020-04-1108:15mkvlrwe’re also using self-hosted in the browser as an internal feature#2020-04-1108:15mkvlrfor debugging mainly#2020-04-1108:16mkvlrbut that should eventually go away#2020-04-1108:16thhellerhmm ok. always scares me to see 10mb+ of JS when that could be <500kb 😛#2020-04-1108:16thhellerok can always optimize that later I guess#2020-04-1108:17mkvlrwe tried a few times to get advanced going#2020-04-1108:17mkvlrI always say it’s still smaller than a news page’s ad 😼#2020-04-1108:18mkvlrwould it be possible to have an advanced build and load self-hosted into the same target?#2020-04-1108:18thhellerhehe#2020-04-1108:18thhelleras long as the advanced and self-hosted builds only interact via "remote" RPC basically. so each serializes to EDN or whatever and the other loads it#2020-04-1108:18thhellerthey cannot otherwise interact directly#2020-04-1108:19mkvlrand you lose any sharing of the base…#2020-04-1108:19thhellereasy if you load the self-hosted env in a worker or so since that has to talk that way anyways#2020-04-1108:19mkvlryes#2020-04-1108:20thhellerwell each will have its own base yes but the :advanced one will be much much smaller#2020-04-1108:20thhellerand the self-hosted load on demand so no impact on overall page performance that might not use it#2020-04-1108:21mkvlryes, we already do that on demand#2020-04-0709:04thhelleralso multiple builds in shadow-cljs works a bit differently than elsewhere due do the caching#2020-04-0709:05thhellerso they'll be a lot faster after the first compile than elsewhere#2020-04-0709:23mkvlryes, we have the self-hosted compiler in a worker#2020-04-0709:24mkvlrthis sounds like we should really give this a try before asking for more features#2020-04-0709:25thhellerhow come the link you gave me about the graal stuff loads the :simple compiled version of cljs?#2020-04-0709:25thhellerdoesn't seem to need any self-hosted things? seems like a large chunk of JS for a page that doesn't use much?#2020-04-0709:28thhellerbut your entire setup seems rather "custom" and the defaults in shadow-cljs might not be a good fit for a setup like that#2020-04-0709:30thhellerI get worried anytime I see 10mb+ JS downloads for any site :P#2020-04-0709:30Chris McCormick> graaljs support has some up in the past and that would be interesting @thheller i am very curious about what this would mean in the context of shadow-cljs#2020-04-0709:31thhellergraaljs meaning the actual graaljs script engine#2020-04-0709:31thhellerNOT the usual graalvm native-image stuff people are excited about#2020-04-0709:31thhellerthat will never work for shadow-cljs#2020-04-0709:31Chris McCormickah ok#2020-04-0709:32thhellerthis stuff https://nextjournal.com/kommen/clojure-berlin-prosemirror-transforms-with-graalvm-and-clojure#2020-04-0709:33thhellergraalvm native-image cannot be supported since the CLJS compiler needs to be able to load code dynamically for macros and stuff. native-image cannot do that.#2020-04-0709:34thhellerthe graaljs stuff you can use in any JVM so isn't coupled to graalvm in any way#2020-04-0709:36Chris McCormickvery interesting#2020-04-0709:36thhellergraaljs is just an interesting replacement to nashorn basically#2020-04-0709:37thhellerand since nashorn is going away I need to find a replacement for shadow-cljs anyways (since that uses nashorn)#2020-04-0709:39Chris McCormicki'm quite ignorant about the graalvm space so forgive me if this is a stupid question, but is it conceptually possible to build a Clojure based graalvm native image which embeds the graaljs execution environment inside it as they have done in the example you linked, so you would end up with a native binary which runs cljs?
#2020-04-0709:39Chris McCormicka friend of mine @retrogradeorbit is shipping really neat stuff with Clojure + GraalVM and I'm in awe of it (bootleg, spire)#2020-04-0709:40thhellerdon't know why you would do that 😛#2020-04-0709:41thhellergraalvm native image is neat because it starts fast#2020-04-0709:41thhellerbut that comes at the code of not being dynamic anymore and clojure is cool because it is dynamic#2020-04-0709:41thhellerso ... tradeoffs 😛#2020-04-0709:42Chris McCormickyes tradeoffs#2020-04-0709:42Chris McCormicki guess there are situations where shipping a single binary to the end user is advantageous#2020-04-0709:42Chris McCormickif the end user doesn't know or care about nodejs#2020-04-0709:42Chris McCormicki know there is nexe too#2020-04-0709:45thhellerI still see graalvm native-image in the same way as an :advanced compiled CLJS build. highly optimized for one particular thing and not extensible at all 😛#2020-04-0709:46thhellerso it is absolutely useful for certain stuff, not so much for other things 🙂#2020-04-0710:53David Pham@thheller How would you do you cli —config-merge with a edn files? (Having a $(cat config.edn) I guess?)#2020-04-0711:07thhellerI recommend using the CLJ api whenever things go past a simple command line. https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2020-04-0711:08thhellerI never had a use to pass in a full edn file#2020-04-0711:12David PhamHmmm... how do you modify the argument of your build then? #2020-04-0711:17thhellerdon't know which one I'd need to modify#2020-04-0712:46darwinad Clojurist Together, I would cast a selfish vote for Dirac support: https://github.com/thheller/shadow-cljs/issues/636#2020-04-0713:13thheller@darwin you can likely already do all of that. assuming that you are able to use websockets, no tcp or other remote method available yet#2020-04-0713:14thhelleronly the custom analyzer stuff likely needs some work#2020-04-0713:55darwinyep, I’ll have to dive into it#2020-04-0714:55isakI'm getting this error when loading the page (latest version):
Exception in thread "async-dispatch-17" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: clojure.
lang.PersistentVector
        at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
        at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
        at clojure.core.async.impl.protocols$eval246$fn__247$G__235__252.invoke(protocols.clj:21)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:979)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
        at clojure.core.async$ioc_alts_BANG_$fn__3086.invoke(async.clj:385)
        at clojure.core.async$do_alts$fn__3018$fn__3021.invoke(async.clj:254)
        at clojure.core.async.impl.channels.ManyToManyChannel$fn__670.invoke(channels.clj:265)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
#2020-04-0714:56isakIt gets printed on every load#2020-04-0714:59thhellerweird indeed. maybe a conflicting core.async version?#2020-04-0715:00isakOh, let me try to update it#2020-04-0715:02thhellershould be [org.clojure/core.async "1.0.567"] if you are on .94#2020-04-0715:02thheller[org.clojure/core.async "1.1.587"] with the next release#2020-04-0715:26isakyou are right, that was it, thanks @thheller 👍:skin-tone-2:#2020-04-0716:00pmooserI have a shadow-cljs question - I am using shadow-cljs with the self-hosted cljs repl, and I notice that because the CLOSURE_BASE_PATH is defined as a relative path, I get loading errors for source maps and things, depending on what URL I happen to be accessing via the embedded dev http server. Does this sound like a crazy configuration error on my part?#2020-04-0716:06thhellershadow-cljs does not provide a self-hosted cljs repl#2020-04-0716:06pmooserI don't know quite how to explain - the bootstrap repl?#2020-04-0716:06thhellerCLOSURE_BASE_PATH you control via :asset-path#2020-04-0716:06pmooserOk, I will see if I can re-read the docs to look for :asset-path.#2020-04-0716:06pmooserThanks.#2020-04-0716:11thheller@pmooser you are using the :bootstrap support build target right?#2020-04-0716:13pmooser@thheller Yes ... I think I have it all fixed, using the :asset-path as you suggested.#2020-04-0716:13pmooserAnd yes I am using the :bootstrap target ...#2020-04-0717:03FlavaDavehaving an issue with a new project. Build keeps on failing.
Davids-MBP:~ Dave$ cd projects
Davids-MBP:projects Dave$ cd hone-master/
Davids-MBP:hone-master Dave$ shadow-cljs watch app
shadow-cljs - config: /Users/Dave/Projects/hone-master/shadow-cljs.edn  cli version: 2.8.83  node: v13.12.0
shadow-cljs - starting via "clojure"
running: npm install --save 
#2020-04-0717:04FlavaDavenpm install react does nothing#2020-04-0717:07lilactownit sounds like you don’t have a package.json#2020-04-0717:07lilactownrun npm init in your project and then npm install shadow-cljs react react-dom#2020-04-0717:55FlavaDaveok i tried that and then ran shadow-cljs watch app again and got a different error
NPM dependency "react" has installed version "^16.13.1"
"16.9.0" was required by jar:file:/Users/Dave/.m2/repository/reagent/reagent/0.9.1/reagent-0.9.1.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.13.1"
"16.9.0" was required by jar:file:/Users/Dave/.m2/repository/reagent/reagent/0.9.1/reagent-0.9.1.jar!/deps.cljs
[2020-04-07 12:51:04.188 - WARNING] :shadow.cljs.devtools.server.nrepl04/middleware-fail - {:sym refactor-nrepl.middleware/wrap-refactor}
FileNotFoundException Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
the print out was very long but that seems to be the meat and potatoes
#2020-04-0719:07thheller@dgonsalves22 looks like you have configured to use the refactor-nrepl middleware but did not add it do the classpath#2020-04-0719:07thhellerso either add that or remove the middleware#2020-04-0719:32isakIs it possible to disable :`browser-inject` for a build? I have a web-worker module in a seperate build, and this worked until I upgraded today. Now it chokes because the generated script references window:
(js/window.addEventListener "beforeunload"
    (fn []
      (when-let [s @socket-ref]
        (.close s))))
#2020-04-0719:33thhellerin a separate build? I presume you mean module?#2020-04-0719:34isakNo, it is a separate entry under :builds#2020-04-0719:35isakso there is no module from that build that will run in the normal browser environment#2020-04-0719:35thhellerso its a build for only a worker?#2020-04-0719:35isakyea#2020-04-0719:35thhellerthe recommended setup is using :modules. see https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2020-04-0719:35thhellerhmm but yeah the logic may be buggy if the only module is a worker#2020-04-0719:36thhelleryou can set :devtools {:browser-inject false} I guess#2020-04-0719:36isakCool, that worked 🙂#2020-04-0719:37thhelleropen an issue if you don't mind#2020-04-0719:37thhellerthat shouldn't be necessary#2020-04-0719:37isakOk#2020-04-0720:12isakIs inspect intended to be used with a value that can change over time? Does this require tapping it continuously, or should once be enough?#2020-04-0720:13isakLooks like it requires tap after changes#2020-04-0720:16isakI'm trying this:
(tap> #'re-frame.db/app-db)
with this Datafiable protocol extension:
(ns foo.utilities.debug
  (:require [clojure.core.protocols :as p]
            [reagent.ratom]
            [shadow.remote.runtime.cljs.browser]))

(extend-type reagent.ratom/RAtom
  p/Datafiable
  (datafy [x]
    @x))
#2020-04-0720:20isakHmm I think I'm mistaken, looks like the deref is happening more than once (I added a print)#2020-04-0720:20thhellerhmm dunno about reagent atom. I only use regular atoms#2020-04-0720:21thhellerdatafy is called when the object is added and "described"#2020-04-0720:22isakOk sweet, just saw that it updates when I navigate back and forth 🙂#2020-04-0720:22isakWhen I click back on the stack of items, then drill down into it again#2020-04-0720:22thhellereasy trick is (tap> {:foo re-frame.db/app-db})#2020-04-0720:23thhellerthat way you can be sure you can trigger the datafy whenever you want#2020-04-0720:23isakright ok#2020-04-0720:24thhellerbut the point of datafy is to get data, so not something that changes over time 😉#2020-04-0720:41FlavaDavei removed the middleware and now I get
{:type java.lang.IllegalArgumentException
   :message "Cannot open <nil> as a Reader."
   :at [$fn__11520 invokeStatic "io.clj" 288]}
#2020-04-0720:42thhelleryou get that where?#2020-04-0720:44FlavaDavewhen I run shadow-cljs watch app i mean there is a lot more I just wanted to avoid putting the whole thing in here because it would be very long#2020-04-0720:44thhellerwell without context that error is not very useful#2020-04-0720:51thhellerany more info? I don't mind long posts? 😛#2020-04-0720:57FlavaDaveI got it to work. ended up being something totally different#2020-04-0721:29FlavaDaveAlso, thanks for the help @thheller and @lilactown#2020-04-0806:36AronHi. Can I use :compiler-options :output-to to specify a relative path for the production build script with :target :browser ?#2020-04-0806:42AronI realize I can just move the file with a separate shell command but it would be much neater to be able to specify the file name#2020-04-0806:43Aroninstead of having to use the namespace (which means atm I get main.js, but I guess that will change too)#2020-04-0807:56Chris McCormick@ashnur can you use :release {:output-dir "build/js"}? I only learned of this option recently myself.#2020-04-0808:30thhelleryeah you can just configure a different output-dir for release builds, see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-04-0808:59Aron@chris358 @thheller does :output-dir change the outputted file's NAME?#2020-04-0808:59Aronif so, it's quite terribly named#2020-04-0809:00Aronno, actually, I get an error that the path is not a directory#2020-04-0809:00thhellerno. you control that name via :modules {:main ...}#2020-04-0809:01thheller:main becomes main.js#2020-04-0809:01AronI don't follow#2020-04-0809:01thheller:output-dir specifies which directory the files are written to#2020-04-0809:02Aronright, but I am asking how to have a specific filename for the production build#2020-04-0809:03Aron'path' for me means 'dir' + 'filename', maybe terminology discrepancy#2020-04-0809:03thhellerwhy does it have to be different for your production build?#2020-04-0809:03Aronbecause that is my goal for today#2020-04-0809:04Aronat the moment 🙂#2020-04-0809:05thhellerweird goal ...#2020-04-0809:05thhellerthe way this works in shadow-cljs is that you specify an :output-dir#2020-04-0809:05Aronwhy so judgmental? :D#2020-04-0809:05thhellerall files are written into that directory#2020-04-0809:05Aronso I can't change from shadowcljs this#2020-04-0809:05thhellerit should be exclusively for files compiled by shadow-cljs#2020-04-0809:06thhellereach module creates one file, named by the module name#2020-04-0809:06thhellerthat is the assumption#2020-04-0809:06Aronthanks, i will just use another process externally to move the files to their appropriate place with their appropriate name then#2020-04-0809:06thhellerit is hardcoded#2020-04-0809:06thhelleryou cannot change it#2020-04-0809:06AronI thought I can use shadowcljs for build stuff#2020-04-0809:07thhellernot sure what you mean by appropriate#2020-04-0809:08Aronintended#2020-04-0809:08Aronfinal#2020-04-0809:08Aronuseful#2020-04-0809:08thhellerif you want main-production.js or whatever it is advised to use a different directory for ALL files#2020-04-0809:08thhellerso /js/compiled/main.js or /js/dev/main.js or whatever#2020-04-0809:08Aronsure, that's not a problem, but I still can't change the filename, just because other files are there too#2020-04-0809:09thhellerI really do not understand your problem?#2020-04-0809:09Aronas it stand, I still need something else externally to find the file and rename it, so I need additional tooling#2020-04-0809:09thhelleryou can change the name by changing the module name?#2020-04-0809:09thheller:modules {:main ...} becomes main.js. :modules {:foo ...} becomes foo.js#2020-04-0809:09Aronbut that's the module name, not the filename#2020-04-0809:09thhellerTHAT IS THE FILENAME!#2020-04-0809:09Aronsorry, I don't want to frustrate you : (#2020-04-0809:10Aronclearly I misunderstand something, it's not my intent to cause trouble#2020-04-0809:11thhellerI explained as best I can. It is a hardcoded assumption that cannot be changed.#2020-04-0809:12AronThis is what I took that 'hardcoded, can't be changed -> filename must be the same as the namespace'#2020-04-0809:12AronIs this not correct?#2020-04-0809:14Aronand it's not#2020-04-0809:17Aron@thheller you explained well, but I misunderstood, {:output-dir "../dist" :modules {:new-filename {:init-fn app.core/main}}} creates ../dist/new-filename.js I am sorry for being thick headed at first#2020-04-0809:18Aronnow my only worry is that shadowcljs might overwrite something, but "luckily" production build assets are also in git so at least it's visible if it happens 🙂#2020-04-0809:20thhelleras I said it is recommended that shadow-cljs owns that directory completely#2020-04-0809:20thhellerso use :output-dir "../dist/js" or so#2020-04-0809:21Aronbut I can't do that#2020-04-0809:21Aronit would mean that I have to rewrite gazzillionn legacy stuff in a huge django project that's over 8 years old that uses dist to publish everything#2020-04-0900:04Chris McCormickashnur I have ClojureScript (shadow-cljs) working along side Django successfully. I managed to get it working through judicious use of the static folders sytem of Django where multiple folders are seen by the browser as a single folder. Ping me if you need more details or my config.#2020-04-0900:20Chris McCormickBasically while you are dev'ing on local one version of your .js file is used from the dev folder as it has static-files precedence, whilst on live the committed version is used instead.#2020-04-0903:12AronI just woke up, it's 4:10 AM : ) Just to explain why I didn't ask immediately. This sounds very useful, I can manually configure both the dev and the prod files and what is committed is going to get published (by hand), but something that requires less attention and is less error-prone would be nicer#2020-04-0923:55Chris McCormick@ashnur my setup is as follows: the cljs project is in a folder called ui at the top level. its shadow-cljs.edn specifies :output-dir "static/dev/admin-ui" (note the "dev" folder). I have :release {:output-dir "static/admin-ui"} (note the lack of "dev". Then in my Django settings:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_DEV = os.path.join(BASE_DIR, "ui", "static", "dev")
STATICFILES_DIRS = []
if os.path.isdir(STATIC_DEV):
    STATICFILES_DIRS += [STATIC_DEV]
STATICFILES_DIRS += [os.path.join(BASE_DIR, "ui", "static")]
What this does is cause /static/ to resolve files in ui/static/dev and also in ui/static and the "dev" variant only exists on my local while running npx shadow-cljs watch app. It never appears on the live site. Note that ui/static/dev and ui/static appear to be overlayed, so if you request /js/main.js it will first look relative to the dev folder, and then look relative to the other non-dev folder.
#2020-04-1002:45Aronthis is almost funny, twice in a row is a pattern : ) Thanks for the config, I shall try it right away#2020-04-1002:51AronIt's a bit more complicated because I am trying devcards, so those need a place too, but I don't want to build them for productions, and tests that I do want to build for production.#2020-04-1003:19AronOk, so the trick really is in the static resolution order in django, using /dev/ when there is one instead of always using the prod version which might exist during dev time too#2020-04-0809:21thheller"everything" but not subdirectories?#2020-04-0809:22AronI am trying to sneak in something on the back door, if I have to work on this 2 weeks just to get the paths right (you can see how slow I am, I am not exxargerating), it will not work : )#2020-04-0809:22thhellerok#2020-04-0809:22Aronno, I mean, there are already paths pointing to this filename I am writing#2020-04-0809:22Aronof course it would get published in a subdirectory too, you are entirely correct in everything you said 🙂#2020-04-0809:23thhelleryeah as soon as you said legacy stuff I understood 😛#2020-04-0809:23Aronthanks, next time I will lead with that then : )#2020-04-0809:24Aronin like 8 years since I've been trying to use clojure(script) for work, this is the first time I think I will succeed, it's thrilling#2020-04-0812:05yendaI'm switching a cljs react-native project from lein/clj/clj-rn to shadow-cljs. I got the dev and build working but I'm struggling with the tests. Previously the react-native libs were mocked by importing dependencies in a namespace. That namespace would be at different source path, one for the project code with requires, and one for the test with mocks of the functions that are called in tests. Now with shadow-cljs since the imports are made directly in the require I'm not sure how to proceed to mock these imports#2020-04-0812:06thhellernot sure I understand the setup, will need to see some code I'm afraid 😛#2020-04-0812:10yendasure do you want the old setup or the new one?\#2020-04-0812:11yendathis is the old project.cljs https://github.com/status-im/status-react/blob/develop/project.clj with mocked dependencies https://github.com/status-im/status-react/blob/develop/test/cljs/status_im/react_native/js_dependencies.cljs and test runner https://github.com/status-im/status-react/blob/develop/test/cljs/status_im/test/runner.cljs#2020-04-0812:12thhellerso the tests are running completely without any react-native involvement?#2020-04-0812:13yendayes they are just meant to test the logic and react-native effects are mocked#2020-04-0812:14yendamost of the time they don't even happen because most tests are testing the map of effects outputed by events without applying them (so no effects occur)#2020-04-0812:14thhellerso how does the code look now?#2020-04-0812:14thhellerdoes this ns still exist? https://github.com/status-im/status-react/blob/develop/test/cljs/status_im/react_native/js_dependencies.cljs#2020-04-0812:15thhelleror do the sources access the react-native deps directly?#2020-04-0812:15yendayeah they access the deps directly from require#2020-04-0812:16yendathis ns was the mock, in any case I couldn't use the same method with shadow since you can't define different src-path for different builds, which was how it worked#2020-04-0812:16thhellerthats not entirely true#2020-04-0812:16thhellershadow-cljs allows aliasing namespaces#2020-04-0812:16yendahttps://github.com/status-im/status-react/blob/develop/react-native/src/mobile/status_im/react_native/js_dependencies.cljs#2020-04-0812:17yendathat is the original namespace#2020-04-0812:17thhellerso you can use the mocked ns and call it (ns status-im.react-native.js-dependencies-mock)#2020-04-0812:18thhellerthen in your build config use :build-options {:ns-aliases {status-im.react-native.js-dependencies status-im.react-native.js-dependencies-mock}}#2020-04-0812:18thhellerthat would make every namespace that references the js-dependencies use the mock instead#2020-04-0812:19thhellerif each ns has the requires directly you can use the :resolve option to mock things https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2020-04-0812:19thhelleror use :js-options {:js-provide :require} (assuming its a :browser) build and provide your own require fn that returns the mocks#2020-04-0812:21thhellerso something like <script>window.require = function(name) { if (name == "foo") { return {} } else ... }; </script>#2020-04-0812:21thhellercan of course write that in CLJS also#2020-04-0812:22thhellerplenty of ways to mess with this 😛#2020-04-0812:25yendaideally I'd like to keep the requires directly in the ns declaration "shadow style", and keep the tests as vanilla cljs as possible so I'll look at js-options and js-resolve#2020-04-0812:26thhellerresolve will be rather verbose and since you are likely going to override all of them it might be better to just create a custom require fn#2020-04-0812:27thhellerits typically meant for single rewrites like react -> preact or so#2020-04-0817:23felipethomeHi! I’m having an issue when using schema-generators along with shadow-cljs. If I use clojurescript version 1.10.520 with shadow <= 2.8.83 everything works. If I bump clojurescript to version 1.10.597, or keep the version 1.10.520 but bump shadow-cljs to 2.8.84 I start to get the error Couldn't satisfy such-that predicate after 10 tries when trying to generate a schema. I’m asking for help here because if I use clojurescript version 1.10.597 and the cljs.build.api everything works fine. Do you have any clue about what may be happening? I thought it could a dependecy issue, but I compared both dependency trees (printed with lein deps :tree) and the tree using version 2.8.83 and 2.8.84 are identical (with exclusions loom pathom and core.async). Maybe I’m missing something when checking the dependencies. I have a sample project reproducing the issue at: https://github.com/felipethome/sg-issue#2020-04-0817:24thhellermake sure you get these versions
[com.google.javascript/closure-compiler-unshaded "v20191027"]

   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
   [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
#2020-04-0817:25thhellerlooks like you don't have those#2020-04-0817:27felipethomeStill the same problem here#2020-04-0817:29thhellersorry don't have time to look at that further#2020-04-0817:29thhellertry without lein#2020-04-0817:33felipethomeUnfortunately I can’t stop using lein at this moment. Thank you! I will try to investigate more#2020-04-0817:51PrometheusIs it possible to specify different configs before build for
shadow-cljs watch app
And
shadow-cljs release app
I different config-variables for each environment. On the serverside I use yogthos/config with lein. And I simply specify which profile to use.
#2020-04-0817:52thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-04-0817:53PrometheusSo you do it directly in shadow-cljs.edn?#2020-04-0817:54PrometheusThat’s a little bit to awesome for my taste Mr @thheller 🙏 You sir are a legend, and so is shadow-cljs#2020-04-0817:55PrometheusHow do I access the config variables inside my cljs files?#2020-04-0817:56thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2020-04-0817:57PrometheusBoom 💣#2020-04-0817:57Prometheusthanks#2020-04-0819:45Aroni have not been this happy for months#2020-04-0819:45Aroneverything just works#2020-04-0905:56Mikko HarjuAny ideas what I might be doing wrong? When I connect to Shadow-CLJS repl with Fireplace.vim and evaluate a form, the hot reload starts to fail with The required namespace "cljs.user" is not available. Evaluating more code with Fireplace still works...#2020-04-0905:57Mikko HarjuThis has just started happening, I'm not sure if this relates to updates in shadow-cljs or fireplace...#2020-04-0907:42thheller@mikko this has been reported before but I haven't been able to reproduce https://github.com/thheller/shadow-cljs/issues/667#2020-04-0912:33Mikko HarjuA-ha! 😄 this explains it. I've previously removed the preload-clause from my fireplace, but I just pulled a new version of Fireplace from GH, effectively removing that change from my repo. I knew this was something that has to do with Fireplace being updated. Thanks for this, I'll have a few tricks up my sleeve in how to get this working.#2020-04-1019:04Brad KurtzI'm having this issue as well, so I stepped through recent releases of shadow-cljs and it seems that 2.8.91 is the most recent release where this problem does NOT occur, seemingly indicating that it was something introduced by 2.8.92+#2020-04-1019:48Brad Kurtzman I'm dumb, I thought it went away but it didn't, I don't know what's going on, and sorry to keep spamming the channel, but I'd like to be able to use shadow-cljs and this would keep me from doing so since it interrupts the eval from vim workflow I'm so used to#2020-04-1020:52Brad KurtzOK so one more update lol, I was originally starting everything up with shadow-cljs watch app and that’s when I would get the issue, so I instead tried starting shadow as a clj repl shadow-cljs clj-repl, then doing (shadow/watch :app), and then when I connect Fireplace and run CljEval (shadow/repl :app), it seems to be working fine now?#2020-04-1021:13Brad KurtzNope… Not working again… Well I give up at this point.#2020-04-0912:02mkarpYes, The required namespace "cljs.user" is not available. comes and goes away sporadically#2020-04-0912:04thhellerI have never seen it so don't know what triggers it#2020-04-0913:32AronI am doing something wrong with material-ui makeStyles, it's throwing some error (length can't be read from undefined), maybe something related to jss. The thing is that I want to use hooks so I am not using reagent but helix (which is the successor of hx), less popular and I am at the very edge of my understanding. Since this is in devcards, it might be that it's not even supposed to work?#2020-04-0914:21Aronactually, I just forgot that I should pass js data to js functions instead of cljs facepalm#2020-04-0916:11p-himikCan advanced compilation remove the when body in
(goog-define X "")

(when (seq X) ...)
?
#2020-04-0917:52thheller@p-himik not sure, probably no#2020-04-0917:52thheller(when-not (identical? X "") ..) might have better chances#2020-04-1009:06martinklepschI’m seeing some weird differences between plain node and Shadow’s npm module thing. At first I thought it is an issue with Firebase but it looks like the issue might be related to Shadow’s module processing?
$ node

> const admin = require('firebase-admin');
undefined
> admin.initializeApp();
FirebaseApp { ... }
> const functions = require('firebase-functions')
undefined
> functions.config()
{}
> functions.config().constructor
[Function: Object]
> functions.config().constructor == Object
true
$ npx shadow-cljs cljs-repl :functions

shadow-cljs - config: /Users/martinklepsch/code/06-commercial/icebreaker/shadow-cljs.edn  cli version: 2.8.37  node: v10.16.3
shadow-cljs - connected to server
> (.-constructor (.config fb-functions))
#js {:some :js-obj}
> (object? (.config fb-functions))
false
#2020-04-1009:06martinklepschI’m seeing some weird differences between plain node and Shadow’s npm module thing. At first I thought it is an issue with Firebase but it looks like the issue might be related to Shadow’s module processing?
$ node

> const admin = require('firebase-admin');
undefined
> admin.initializeApp();
FirebaseApp { ... }
> const functions = require('firebase-functions')
undefined
> functions.config()
{}
> functions.config().constructor
[Function: Object]
> functions.config().constructor == Object
true
$ npx shadow-cljs cljs-repl :functions

shadow-cljs - config: /Users/martinklepsch/code/06-commercial/icebreaker/shadow-cljs.edn  cli version: 2.8.37  node: v10.16.3
shadow-cljs - connected to server
> (.-constructor (.config fb-functions))
#js {:some :js-obj}
> (object? (.config fb-functions))
false
#2020-04-1009:09martinklepsch
> (.config fb-functions)
== JS EXCEPTION ==============================
ENCODING FAILED, check host console
==============================================
#2020-04-1009:43thhellernot entirely sure I see the issue?#2020-04-1009:43thhellerdo you mean the failing object? check?#2020-04-1009:43thhellerbecause that is not what == Object does?#2020-04-1009:44thhellerand literally everything is true for == Object so I don't quite see the point of that check?#2020-04-1010:10martinklepschYes I mean the failing object check + the fact that the data that should be returned by .config() is instead returned if you access the constructor. There are some clear differences between these two repl sessions that don’t make sense, no? #2020-04-1010:35thhellerdon't use object? basically#2020-04-1010:36thhellerit only returns true for anything {}#2020-04-1010:36thhellerbut not anything with a prototype which this is likely returning#2020-04-1010:37thhellerwhats the actual issue though?#2020-04-1010:37thhellerthat printing fails can have a variety of reasons#2020-04-1010:38thhellercheck the browser console. might be a circular reference, might include a js/Symbol, etc#2020-04-1010:38thhellertry (js/console.dir (.config functions)) or so#2020-04-1011:53martinklepschthe actual issue is that it can’t be converted using clj->js or cljs-bean#2020-04-1011:53martinklepsch(js/console.dir (.config functions)) logs the config data to the console#2020-04-1011:54martinklepschjs/console.log does too actually#2020-04-1011:56martinklepschThis is a basic question I guess: how do I create a thing “with a prototype” that would allow me to reproduce this behavior outside of firebase’s config stuff?#2020-04-1013:09thheller"this behavior" of not working?#2020-04-1013:09thhellerI still don't know what you actual issue is? you want the config data as a CLJS map?#2020-04-1013:12thhelleryou can try (shadow.json/to-clj (.config functions))#2020-04-1116:18martinklepschI tried the shadow.json thing. I could require the namespace but running to-clj doesn’t exist somehow#2020-04-1116:23thhellerhmm https://github.com/thheller/shadow-cljs/blob/fb10d231b7a0ec673dde70a37e5a1425fd1e126b/src/main/shadow/json.cljs#L4#2020-04-1014:13jjttjjIs there an obvious reason bootstrapping cljs would work perfectly in dev mode but when I do a release I get Cannot read property 'findInternedVar' of null when using eval-str Here is my http://shadow.cl-cljs.edn
{:deps true
 :builds
 {:app
  {:target     :browser
   :output-dir "resources/public/js"
   :asset-path "/js"
   :compiler-options {:optimizations :simple}
   :modules    {:main {:entries [jt.jt16]}}
   :devtools   {:repl-init-ns jt.jt16}}
  :bootstrap-support
  {:target     :bootstrap
   :output-dir "resources/public/bootstrap"
   :exclude    #{cljs.js}
   :entries    [javelin.core diy.core diy.hoplon.tpl #_ui]
   :macros     []}}}
#2020-04-1014:15thhellersomewhere x.findInternedVar() is called where x is nil#2020-04-1014:15thhellerso find out where that is. stacktrace should show that. dunno why though.#2020-04-1014:16jjttjjAlso getting a bunch of
main.js:3742 Uncaught ReferenceError: goog is not defined
    at eval (/bootstrap/js/3bcbd8d8.cljs.core$macros.js:1)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:461)
    at Object.shadow.cljs.bootstrap.browser.script_eval (main.js:10070)
    at Object.shadow.cljs.bootstrap.browser.execute_load_BANG_ (main.js:10073)
    at main.js:10083
    at goog.async.run.processWorkQueue (main.js:3749)
type errors
#2020-04-1014:44jjttjjok hmmm it seems like goog isn't defined when bootstrap/init tries to load the first bootstrap file and this is breaking all my eval-str calls#2020-04-1016:06thhellerah rioght I remember now#2020-04-1016:06thhelleryou need to set :compiler-options {:output-wrapper false} in your :app config#2020-04-1016:22jjttjjThat did it, thanks so much!#2020-04-1018:18Brad KurtzHello, I have a question about setting up shadow-cljs to work with vim-fireplace#2020-04-1018:19Brad KurtzI have it seemingly working, where I can eval stuff with piggieback in vim, but as soon as I save the file I'm in, I get a build failure saying >The required namespace "cljs.user" is not available.#2020-04-1018:28Brad KurtzI see now somebody else asked this yesterday#2020-04-1106:48solfNewbie question: let's say I'm using only shadow-cljs and reagent, how do I hook up TailwindCSS to automaticaly process my css files (and trigger live reload etc)? Do I still need to use something like webpacker/browserify?#2020-04-1107:39mkvlrwe just commited the processed tailwind css to our repo and use vanilla css in our app, can recommend#2020-04-1107:40mkvlrshadow doesn’t have support built-in https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2020-04-1107:40mkvlr> shadow-cljs currently provides no support for directly compiling CSS but the usual tools will work and should be run separately. Just make sure the output is generated into the correct places.#2020-04-1107:41mkvlrbut I’d recommend trying without an extra css compilation step at least in dev#2020-04-1108:01thhellerI just have postcss setup separately and shadow-cljs will hot-reload it whenever it changes but knows nothing else about CSS#2020-04-1111:15solfOkay thanks!#2020-04-1111:16solfI'll do it the simpler way with separate processing#2020-04-1300:59dhalehttps://youtu.be/_CTTbC6owS0 At about two minutes into the video, helped me do this. #2020-04-1115:12sylvainI'm using a third party npm library in my project (BabylonJS) and the compilation breaks if I try to update it to the latest version. The offending typescript code does this: public dispose(disposeAll = true): void { super.dispose(disposeAll); if (this._depthRenderer && disposeAll) { delete this._depthRenderer.getDepthMap().getScene()?._depthRenderer[this._depthRendererId]; this._depthRenderer.dispose(); this._depthRenderer = null; } } and the error I get is: "Invalid delete operand. Only properties can be deleted." If I understand correctly the issue is the usage of the "?." operator together with "delete" and it can be fixed by using an if statement instead. However I'd rather avoid patching the library. Do I have other options here like maybe a compiler flag to pass to shadow-cljs ?#2020-04-1115:13thhellershadow-cljs does not support typescript so you are looking at the wrong code#2020-04-1115:14thhellerlook at the code that is actually getting included#2020-04-1115:14thhellernot the typescript sources. npm likely contains the transpiled code.#2020-04-1115:14sylvainDepthReducer.prototype.dispose = function (disposeAll) { if (disposeAll === void 0) { disposeAll = true; } var _a; _super.prototype.dispose.call(this, disposeAll); if (this._depthRenderer && disposeAll) { if(this._depthRenderer.getDepthMap().getScene()) delete this._depthRenderer.getDepthMap().getScene()._depthRenderer[this._depthRendererId]; this._depthRenderer.dispose(); this._depthRenderer = null; } };#2020-04-1115:14sylvainthis is the corresponding JS code#2020-04-1115:15thhellereither thats an invalid use of delete or a bug in the closure compiler#2020-04-1115:15thhellernot much I can do in shadow-cljs#2020-04-1115:16thhellerlooks fine to me, dunno why it complains#2020-04-1115:16thhellerwouldn't be the first time the closure-compiler found an actual bug in a library though#2020-04-1115:16thhellerso this might actually be invalid and just nobody ever runs into that actual code#2020-04-1115:17sylvainyes, very possible indeed. I'll try to convince the library authors to patch it then.#2020-04-1115:17sylvainThanks#2020-04-1115:18sylvainCan the version of the closure compiler used by shadow-cljs be changed ?#2020-04-1115:28sylvainSorry I realize the JS code above is not the offending one. It's the code I get after manually patching it. The offending code is:#2020-04-1115:28sylvainDepthReducer.prototype.dispose = function (disposeAll) { if (disposeAll === void 0) { disposeAll = true; } var _a; _super.prototype.dispose.call(this, disposeAll); if (this._depthRenderer && disposeAll) { delete ((_a = this._depthRenderer.getDepthMap().getScene()) === null || _a === void 0 ? void 0 : _a._depthRenderer[this._depthRendererId]); this._depthRenderer.dispose(); this._depthRenderer = null; } };#2020-04-1116:22thhellerright yeah that looks invalid#2020-04-1117:09Felipe MarquesI'm playing with the lifecycle-hooks. And putting in the shadow-cljs.edn the following hook: {:devtools {:after-load my-devtools/reload}. But the hook is not called (`reloading code but no :after-load hooks are configured!`). I imagine that because I'm not requiring my namespace (`my-devtools`) anywhere in my code it is not running the function. Because, when I add a require into my main-file it runs the hook. Is this the expected behavior? I would think that shadow-cljs would require que namespace specified in the devtools.#2020-04-1117:11thhellerit is expected that the namespaces are actually requireed by you#2020-04-1117:11thhellerotherwise you should use :devtools {:preloads [your.ns.with-hooks]}#2020-04-1117:12thhellerand in there do (defn ^:dev/after-load the-hook [] ...)#2020-04-1117:12Felipe Marqueshummm, got it#2020-04-1117:12Felipe Marquesthanks!#2020-04-1117:13thhellernot sure what you mean by requiring it runs the hook#2020-04-1117:13thhellerbecause that only happens if you actuall call the hook yourself#2020-04-1117:14Felipe MarquesOh, sorry, I wasn't clear. When I add (:require [my-devtools]) at some file that is compiled and loaded by shadow and then trigger the reload by editing some file, the hook runs.#2020-04-1117:20thhellerI guess it could add the namespaces to the build automatically but typically people have the hooks directly in the main ns#2020-04-1117:24Felipe Marqueshumm, the hook I'm injecting is hooks that I use in my personal development flow. I'm injecting it dynamically by loading the config-map, editting it and then giving it to shadow to watch it. The other developers in the project don't use these same hooks as I do. That is why I don't put these hooks in the main ns.#2020-04-1117:25Felipe MarquesUsing the preloads worked well for me (just tried it), don't know if it is necessary to add the namespaces to the build automatically. Maybe put in the documentation that the namespace must be required somewhere#2020-04-1117:25thhelleryou can do shadow-cljs watch app --config-merge "{:devtools {:preloads [hooks.that.only.i-want]}"#2020-04-1117:26Felipe Marquesyes, that is basically what I'm doing, but I'm doing it inside a clojure file#2020-04-1117:27Felipe MarquesI start the server and the watch command through clojure using the shadow.cljs.devtools.api .#2020-04-1117:27Felipe MarquesThis is the function that I use.
(defn watch-with-profile
  [build-id profile]
  (println "Running " build-id " with profile " profile)
  (-> (shadow.config/get-build! build-id)
      (assoc :profile profile)
      set-devtools-hooks
      shadow.api/watch))
#2020-04-1117:28thhelleryou can also do the config merge there#2020-04-1117:28thheller(shadow.api/watch :the-build {:config-merge [{:devtools {:preloads '[the.extra]}}]})#2020-04-1117:28thhellerbut your way works too#2020-04-1117:31Felipe Marquesoh, didn't know that shadow.api/watch had this option, cool!#2020-04-1117:32Felipe MarquesThanks for the help! 😄#2020-04-1122:55alexHey all, I'm trying to run tests in my shadow-cljs project via the CLI. I've created a build called :cljs-tests with the following config:
{:target :node-test
            :js-options {:node-modules-dir "../"}
            :output-to "out/node-tests.js"
            :autorun true
            :main my-app-name.events-test/start}
From the documentation, it's my understanding that I can specify a main as the entry point to running the tests. For now, I just have that hardcoded to a my-app-name.events-test/start , which just invokes cljs.test/run-tests:
(defn start []
  (cljs.test/run-tests))
In CLI, I'm running npx shadow-cljs compile cljs-tests . The process outputs "Compiling..." for a while, then spits out this error:
aborted par-compile, [:shadow.build.classpath/resource "my_app_name/events_test.cljs"] still waiting for #{my-app-name.events-test}
{:aborted [:shadow.build.classpath/resource "my_app_name/events_test.cljs"], :pending #{my-app-name.events-test}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "my_app_name/events_test.cljs"] still waiting for #{my-app-name.events-test}
	shadow.build.compiler/par-compile-one (compiler.clj:854)
	shadow.build.compiler/par-compile-one (compiler.clj:819)
	shadow.build.compiler/par-compile-cljs-sources/fn--12733/iter--12755--12759/fn--12760/fn--12761/fn--12762 (compiler.clj:937)
	clojure.core/apply (core.clj:665)
	clojure.core/with-bindings* (core.clj:1973)
	clojure.core/with-bindings* (core.clj:1973)
	clojure.core/apply (core.clj:669)
	clojure.core/bound-fn*/fn--5734 (core.clj:2003)
	java.util.concurrent.FutureTask.run (FutureTask.java:264)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
	java.lang.Thread.run (Thread.java:834)
Do you know what I might be missing?
#2020-04-1122:56thhellerif you are just calling run-tests then you don't need :main at all because its what it does by default?#2020-04-1122:57alexAh okay, that's good to know. I am getting some feedback when I run w/o the main option. Thanks#2020-04-1122:57thheller:main applies to :node-script only#2020-04-1122:58thhellerfor :node-test you'd use :runner-ns if a custom runner is needed#2020-04-1122:58thheller:main just confuses the compiler I guess#2020-04-1122:58thhellershould filter that out so feel free to open a ticket about that#2020-04-1122:59thhelleractually nevermind ... :main should work fine#2020-04-1122:59thhellerdunno why it doesn't#2020-04-1122:59alexAwesome thanks for the additional detail. The documentation might be a little out of date re: :main for node-test target. I can send a PR if that's alright?#2020-04-1122:59alexOh I see, hmm#2020-04-1123:17alexI'm getting an error that window is not defined, which makes sense in a node runtime. Wondering if I should try to mock window or use the :browser-test target. I'm not performing any UI tests, just business rule logic in CLJS, but cljs/shadow-cljs seem to be pulling in all of my NPM dependencies, many of which reference window#2020-04-1123:31thhellershadow-cljs doesn't pull in anything using window if you use :node-test#2020-04-1123:32thhellermust be your code doing that#2020-04-1123:32thheller(or your dependencies)
#2020-04-1123:32thhelleruse browser-test or karma if you need browser stuff#2020-04-1200:35alexthank you. karma seems to be working well#2020-04-1200:36alexim wondering if i can start a shadow-cljs watcher + karma runner in a single terminal. the example in the documentation runs compiles, then runs karma. i can run them from 2 terminals no prob#2020-04-1207:18thhellershadow-cljs does not run karma for you no#2020-04-1123:29alex#2020-04-1212:06Felipe MarquesYou can use the :ns-regexp to get only the tests and which will probably not depend on the window object. https://shadow-cljs.github.io/docs/UsersGuide.html#_testing#2020-04-1503:51alexThanks Felipe! I'll give that a try#2020-04-1306:29Saikyunis it possible to always have functions available in the cljs-repl? e.g. if I'd want (:require [cljs.repl :refer [doc]]) regardless of which ns I'm in#2020-04-1308:00thhelleryou can just call (cljs.repl/doc foo) from anywhere. having (doc foo) available does not work without you requiring it#2020-04-1314:29Saikyunokay, thanks. 🙂#2020-04-2011:04gravWill fully qualified ns'es always work without requiering them in Cljs? This is not the case in Clj, right?#2020-04-2011:14thhellerno. I was assuming that at some point in time (require 'cljs.repl) was done somewhere so that the ns is loaded#2020-04-2011:15thhellerit won't work if it was not#2020-04-1306:46Jakub Holý (HolyJak)Hello! Why does this code from https://clojurescript.org/reference/google-closure-library#import-a-class fail in shadow REPL?
(shadow/repl :main)
;=> [:selected :main]
(import 'goog.Uri)
;------ REPL Error while processing ---------------------------------------------
;(import 'goog.Uri)
;...
;ExceptionInfo: ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form)
;	shadow.build.compiler/post-analyze (compiler.clj:95)
? OK, the error says I cannot use import, but why not / why does the page above (which, of course, is not about Shadow) talks about REPL? Is that a limitation of shadow REPL compared to vanilla cljs? (I can use the classes, just not import them)
#2020-04-1307:07David PhamAnyone managed to have pprint activated automatically in the repl as well?#2020-04-1307:18Saikyunfor just pprint, in shadow-cljs.edn:
{:devtools {:repl-pprint true}}
doc: https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_3
#2020-04-1320:06David PhamYeah... I tried but it doesn’t work with Cider.#2020-04-1308:01thheller@holyjak I just haven't implemented import since (require 'goog.Uri) does the same#2020-04-1309:41Jakub Holý (HolyJak)Thanks! I have misunderstood > :import for Closure classes (which are also namespaces, like goog.Uri) and enums as "use import for classes". Now I understand.#2020-04-1309:43thhelleryou can open a ticket so I don't forget it again. I personally just never use import so I keep forgetting to implement it properly#2020-04-1313:49Jakub Holý (HolyJak)BTW thanks for all your hard work and the amazing tool you have created!#2020-04-1420:24David PhamI wondered if anyone had this issue: I am using tfjs-backend-wasm and it requires a wasm file. When I developping, shadow-cljs does not transfer the *.wasm file from the node_module directory. Anyone knows how to circumvent this behavior? Maybe I am doing something wrong.#2020-04-1420:52thhellershadow-cljs has no support for wasm at all. so totally expected that it doesn't copy wasm files.#2020-04-1422:21David PhamThen do you think it would make sense to support the node modules that contains WASM files?#2020-04-1507:48thhelleronce there is a settled standard for wasm maybe. right now each toolchain produces their own variant of JS glue code and includes it differently#2020-04-1507:48thhellerif they ever standardize it I will of course include support for it#2020-04-1507:49thhelleruntil then it would be too much work for me to keep up with all the different ways people handle this#2020-04-1508:25David PhamThanks!#2020-04-1422:09SpacemanHi, I'm running a shadow-cljs app, and getting the following error in my browser: WebSocket connection to '<ws://localhost:9631/ws/worker/app/d220add9-aa54-43e3-be71-b121ec13636f/e2fa1a2b-01cf-44e7-9bf0-c5db8cb75503/browser>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED And the shadow-cljs has stopped reloading, and I don't know what's causing this. How do I even start to debug this, if there aren't any other errors in the console? (edited)  Well there's also this error: shadow-cljs: websocket error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …} bubbles: false cancelBubble: false cancelable: false composed: false currentTarget: WebSocket {url: "<ws://localhost:9631/ws/worker/app/d220add9-aa54-43>…636f/e2fa1a2b-01cf-44e7-9bf0-c5db8cb75503/browser", readyState: 3, bufferedAmount: 0, onopen: ƒ, onerror: ƒ, …} defaultPrevented: false eventPhase: 0 isTrusted: true path: [] returnValue: true srcElement: WebSocket {url: "<ws://localhost:9631/ws/worker/app/d220add9-aa54-43>…636f/e2fa1a2b-01cf-44e7-9bf0-c5db8cb75503/browser", readyState: 3, bufferedAmount: 0, onopen: ƒ, onerror: ƒ, …} target: WebSocket {url: "<ws://localhost:9631/ws/worker/app/d220add9-aa54-43>…636f/e2fa1a2b-01cf-44e7-9bf0-c5db8cb75503/browser", readyState: 3, bufferedAmount: 0, onopen: ƒ, onerror: ƒ, …} timeStamp: 147976.1250000156 type: "error" proto__: Event#2020-04-1507:54thhellernet::ERR_CONNECTION_REFUSED means the browser failed to connect to localhost:9631#2020-04-1507:55thhellerthat is not the standard port. so that means there was something else listening on 9630?#2020-04-1507:55thhellercould also be your firewall blocking access or your OS having other issues causing it to fail#2020-04-1508:24David PhamOr maybe two shadow-CLJS processes?#2020-04-1508:25thhelleryeah could just be 2 different shadow-cljs processes interfering with each other#2020-04-1422:09lilactown@pshar10 is your watch running?#2020-04-1422:14Spacemanyes the watch is running.#2020-04-1422:22David PhamDo you have a copy of your build file?#2020-04-1423:11Pavel KlavíkHi, when I build my project in watch mode, everything works fine. But when I build it in release, the compilation works and I get the following error on the start:
shared.js:180 shadow-cljs - failed to load 7
LB @ shared.js:180
shadow$provide.<computed> @ main.js:18
LB @ shared.js:180
$APP.Ho @ shared.js:180
(anonymous) @ main.js:3198
(anonymous) @ main.js:4036
shared.js:180 shadow-cljs - failed to load 11
LB @ shared.js:180
$APP.Ho @ shared.js:180
(anonymous) @ main.js:3198
(anonymous) @ main.js:4036
shared.js:180 Uncaught TypeError: $jscomp.initSymbol is not a function
    at Object.shadow$provide.<computed> (main.js:9)
    at LB (shared.js:180)
    at Object.shadow$provide.<computed> (main.js:18)
    at LB (shared.js:180)
    at Object.$APP.Ho (shared.js:180)
    at main.js:3198
    at main.js:4036
Any idea what could be causing this??
#2020-04-1423:16Pavel KlavíkWe have added some npm dependencies, so this could be causing this?#2020-04-1423:25Pavel KlavíkProblem persists when I upgraded to Shadow-cljs 2.8.95.#2020-04-1500:17mauricio.szaboIs there any problem with the latest version? I just upgraded, and I'm not being able to watch a project, it fails with:
failed to parse websocket message {:type :repl/init, :repl-state {:shadow.cljs.repl/repl-state true, :current-ns ....
#2020-04-1500:42Pavel KlavíkThe piece of code where this is failing looks like this in the minified version:
Wh = function(a, b) {
        var c = oaa[a];
        if (void 0 !== c)
            return c;
        try {
            Th.push(a);
            var d = Uh[a]
              , e = shadow$provide[a];
            if (void 0 === d) {
                if (void 0 === e)
                    throw "Module not provided: " + a;
                d = {
                    exports: {}
                };
                Uh[a] = d
            }
            if (e) {
                delete shadow$provide[a];
                try {
                    e.call(d, $APP.Vh, Wh, d, d.exports)
                } catch (k) {
                    throw console.warn("shadow-cljs - failed to load", a),
                    k;
                }
                if (b) {
                    var f = b.globals;
                    if (f)
                        for (c = 0; c < f.length; c++)
                            window[f[c]] = d.exports
                }
            }
        } finally {
            Th.pop()
        }
        return d.exports
    }
#2020-04-1505:14David PhamCan you try to output to ES6? I think I had a similar issue and that resolved it.#2020-04-1507:44thhellertry :compiler-options {:output-wrapper false} too. looks like it has an issue with scoping somewhere?#2020-04-1510:38Pavel KlavíkCool, switching to ES6 worked. For some reason, I was using es3 before.#2020-04-1500:56awb99question: is there a plan to allow (require [ns]) to be available ?#2020-04-1500:57awb99So that namespaces can be required outside the ns declaration#2020-04-1500:59awb99I am trying to define different configs, so say :with-a :with-b :with-c or a combination thereof#2020-04-1500:59awb99the different profiles will have different include sets#2020-04-1501:00awb99I am currently ns-alias to get it done.#2020-04-1501:00awb99But this turns out to be quite difficult as the project gets bigger#2020-04-1502:10dpsuttonRequire doesn’t exist at runtime in cljs#2020-04-1502:17dpsuttonSo the code couldn’t work in prod. Or is this for node?#2020-04-1503:46awb99for browser#2020-04-1503:46awb99I am talking build time.#2020-04-1505:15David PhamYou can use deps.edn to have different profiles, or google closure variables and dispatch on these #2020-04-1507:45thheller@hoertlehner require must always be completely static so even if it was allowed outside the ns you still can't do anything that you can't do with ns anways#2020-04-1507:46thhelleryou can't make anything conditional regardless#2020-04-1507:47AronIf I ever disliked anything, it was the idea of conditional dependencies in javascript. Abuse of the abstraction : (#2020-04-1507:48Aronnever needed it but some people at previous jobs hated me for this opinion and tried to convince me why it should happen#2020-04-1507:50thhellerit is very useful to do sometimes ... just can't do it easily in an async context. thats really what makes everything difficult.#2020-04-1507:56AronThere is nothing wrong with dynamic conditional require/import if it uses different syntax/semantics as the static/sync version : )#2020-04-1509:52brunexHi, question related with clojurescript macros: Given a list of `(def data [:foo :bar :baz])`, I want to dynamically generate:
(def foo (some-fn foo))
(def bar (some-fn bar))
(def baz (some-fn baz))
for some reason I'm not able to resolve the symbol data in a clojurescript macro 😕
#2020-04-1510:00brunexin clojure, I got something like this doing the job:
(def data ["foo" "bar" "baz"])

(defmacro test-macro
  [data]
  `(do
     
#2020-04-1510:01brunexthe main issue is the resolve part#2020-04-1510:01brunexI guess 😕#2020-04-1510:33David PhamHow do you guys manage headless (end to end testing)? I would interested to have a solution where I could define a sequence of some re-frame events and that snapshot the results? Does it exists?#2020-04-1510:39mkvlrwe do it with https://github.com/puppeteer/puppeteer#2020-04-1510:39mkvlrand have a function to check that the re-frame event queue is empty#2020-04-1510:40mkvlr
(defn ^:export ready
  "Returns true the tick after no events are left to process in the re-frame queue"
  []
  (let [state (.-fsm-state (:event-queue re-frame/default-frame))
        dr @deferred-ready]
    (cond
      (and (= state :idle) (not dr))
      (do
        (if (exists? js/requestIdleCallback)
          (js/requestIdleCallback   #(reset! deferred-ready true))
          (js/requestAnimationFrame #(reset! deferred-ready true)))
        false)
      (and (= state :idle) dr)
      true
      :else
      (reset! deferred-ready false))))
#2020-04-1510:41mkvlrthis is for our re-frame fork https://github.com/nextjournal/freerange#2020-04-1510:42mkvlrthis should work in regular re-frame:#2020-04-1510:43mkvlr
(defn ^:export ready
  "Returns true the tick after no events are left to process in the re-frame queue"
  []
  (let [state (.-fsm-state re-frame.router/event-queue)
        dr @deferred-ready]
    (cond
      (and (= state :idle) (not dr))
      (do
        (if (exists? js/requestIdleCallback)
          (js/requestIdleCallback   #(reset! deferred-ready true))
          (js/requestAnimationFrame #(reset! deferred-ready true)))
        false)
      (and (= state :idle) dr)
      true
      :else
      (reset! deferred-ready false))))
#2020-04-1510:50David PhamThanks!!#2020-04-1510:51David PhamSo once you events are done you export it to png and compare the images?#2020-04-1511:35thheller@brunex it is very uncommon do write macros that depend on values of other vars. usually they should be self-contained and take all they need as an argument#2020-04-1511:35brunexgot it#2020-04-1516:34PrometheusAnybody here use reitit in conjunction with shadow-cljs having issues with hot reloading? I’m struggling a bit#2020-04-1517:26AronI am a bit confused about the whole repl nrepl prepl socket repl situation... I realize it would be a bit much to ask for a complete picture, so can please someone just give me some hints on what are already fully working options for neovim/shadow-cljs? I have never done "repl driven development" but I like the sound of "auto-complete" 🙂#2020-04-1517:38Spacemanshadow-cljs doesn't seem to hot-reload in iPhone simulator safari localhost#2020-04-1517:38Spacemanwhat to do about it?#2020-04-1517:41Spacemanit's working now#2020-04-1519:16thheller@peder.august whats the problem?#2020-04-1519:16PrometheusI’m pretty sure it’s not a shadow-cljs problem#2020-04-1519:34thhellersee https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html "Holding Code references in State"#2020-04-1519:34thhellerreitit example often have this#2020-04-1519:37PrometheusHmm thank you i’ll look into it 🙂#2020-04-1519:38thhelleryou can try :devtools {:reload-strategy :full} in your build config#2020-04-1519:38thhellerits slower but a bit more forgiving on architecture issues#2020-04-1519:38PrometheusThank you#2020-04-1519:52PrometheusI got it to work 🙂#2020-04-1519:52PrometheusHad to refactor my hooks#2020-04-1519:17thheller@ashnur I don't know neovim or which kind of REPLs it supports. most editors use nREPL.#2020-04-1519:19AronThanks, I am just checking out vim-iced. Sadly, cider comes with so many complications that I am way too anxious to try it 🙂#2020-04-1600:03knubie@ashnur I use vim-iced with shadow-cljs and it works quite well#2020-04-1600:12AronThanks, seems like the way to go : )#2020-04-1519:35Ivan FedorovHaving issues importing a js module dom-utils.js from a js module js-main.js which is required by a root.cljs . js-main.js is loaded just fine, but dom-utils.js isn’t.
;root.cljs
(ns website.main
  (:require ["./js-main" :as main]))

(defn init []
  (main/onDomReady))

; js-main.js
import {func1} from "./dom-utils.js"
export const onDomReady = () => func1("bar")

; dom-utils.js
export const func1 = (x) => foo(x)
All js files are laying in the same dir/package as main.cljs. In shadow cljs target is
:dev
{:target :browser
 :modules {:main {:init-fn website.main/init}}
 :output-dir "resources/public/website"
 :asset-path "/website"
 :compiler-options {:output-feature-set :es8}}
___________ Issue Browser says TypeError: Cannot read property 'func1' of null --------- I see dom-utils.js file in sources tab, by the path /website/cljs-runtime/website/dom-utils.js So perhaps I misconfigured output path or import.
#2020-04-1519:36thhellerand whats the issue?#2020-04-1519:37Ivan Fedorovupdated the post#2020-04-1519:40thhellerdunno about all the fat arrows. not exactly sure how the closure compiler handles those#2020-04-1519:40thhellertry export const function func1(x) ... or so?#2020-04-1519:44Ivan Fedorovyes, this works#2020-04-1519:46Ivan FedorovThanks again! 🍺❤️sheepy#2020-04-1519:48Ivan FedorovI can post this somewhere if that would be of any use#2020-04-1519:51thhellerfrankly I forgot the exact semantics of => so I don't know if it should be considered a bug or not#2020-04-1520:00Ivan FedorovHmm, I wasn’t fully honest. I also had
:compiler-options 
{:output-feature-set :es8}
#2020-04-1520:05Ivan FedorovI disabled this :output-feature-set :es8 part. Arrows work now. If I re-enable that it doesn’t matter arrows or not, nothing from dom-utils.js will be visible in js-main.js#2020-04-1520:09thhelleryeah probably best to stay a bit conservative with JS features#2020-04-1520:10thhellernot everything is fully supported all the time#2020-04-1520:10thhellergetting it all to play nice with CLJS already requires several hacks 😛#2020-04-1520:41Aronuse babel to convert js first to ES5 then I am sure everything will work. 🙂#2020-04-1520:59thhellerit is more likely that causes more issues actually#2020-04-1521:03AronIs this because of some of Polyfills?#2020-04-1521:03Aronor babel's version of es5 is buggy?#2020-04-1521:17thhellerthe style of code it generates is different than what the closure compiler does#2020-04-1521:17thhellerso it might contain duplicated polyfills and stuff#2020-04-1521:30AronMaybe I am biased as a long term babel user, and honestly, I don't even like it or the whole situation, even so, it sounds like someone would purposefully write js instead of cljs (or maybe a colleague) and then they would use babel to make it more compliant, but then they would have to forget about what closure does and configure babel in an incorrect way. Plausible, of course, but if someone is in that specific situation, I think it's unfair to assume that they will make mistakes : )#2020-04-1521:30AronThe way I use babel is to allow specific features, not in a blanket, solve everything at once way.#2020-04-1521:34thhellerthe point is that closure is able to rewrite most JS features when needed and the code is guaranteed to work with the further optimizations closure does. the babel code is not.#2020-04-1521:55AronThat is your point which I didn't debate. I just added a corollary. But let me stop here since I don't intend to argue minor thing, I respect both of our times more : )#2020-04-1610:18juhoteperiAny ideas what could cause parse errors with Node modules? In this case I'm having problems with Openlayers 6. I also had to remove .shadow-cljs/builds to even get Shadow-cljs to use the new sources.#2020-04-1610:18juhoteperi
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/ol/Feature.js:107:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 Resource: node_modules/ol/layer/BaseVector.js:106:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #3 -  -----------------------------------------------------------
 Resource: node_modules/ol/layer/Layer.js:131:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #4 -  -----------------------------------------------------------
 Resource: node_modules/ol/renderer/Layer.js:52:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #5 -  -----------------------------------------------------------
 Resource: node_modules/ol/renderer/canvas/Layer.js:57:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #6 -  -----------------------------------------------------------
 Resource: node_modules/ol/renderer/webgl/Layer.js:87:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #7 -  -----------------------------------------------------------
 Resource: node_modules/ol/source/Vector.js:89:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
------ WARNING #8 -  -----------------------------------------------------------
 Resource: node_modules/ol/source/Vector.js:216:20
 Parse error. name not recognized due to syntax error.
--------------------------------------------------------------------------------
#2020-04-1610:20juhoteperihttps://unpkg.com/browse/ol@6.3.1/Feature.js line 107 _this.geometryChangeKey_ = null;#2020-04-1611:35thhellerI think it doesn't like those typehints#2020-04-1611:35thheller@type {?import("./events.js").EventsKey}#2020-04-1611:37thhelleryeah that error is from the jsdoc parser#2020-04-1611:41thhellerthere was a way to turn this off but can't find it#2020-04-1611:58juhoteperiWhat is parsing the files? Closure?#2020-04-1611:58thhelleryes#2020-04-1612:05thhellerhmm weird there doesn't seem to be any option to turn jsdoc parsing off#2020-04-1612:05thhellerbut there are just warnings so it should still work?#2020-04-1612:25juhoteperiYeah, I'm having some problems with OL but could be unrelated to these warnings.#2020-04-1612:36thhellerhttps://github.com/google/closure-compiler/issues/1736#issuecomment-400107740#2020-04-1612:36thhellerthey are aware at least ...#2020-04-1612:36thhellerguess its a typescript thing#2020-04-1615:07pmooserI'm doing something slightly weird, but I'm wondering if anyone can help me resolve an inference issue. The short version is, I just enabled :infer-externs , and I am getting a warning from anything in my code that implements reagent.ratom.IReactiveAtom, which is just a methodless tag interface. The error looks like: Cannot infer target type in expression (. (. Example -prototype) -reagent$ratom$IReactiveAtom$)#2020-04-1615:07pmooserThe deftype in this example is just:#2020-04-1615:07pmooser
(deftype Example []
  reagent.ratom.IReactiveAtom)
#2020-04-1615:09pmooserMaybe this is a problem with a failure to require reagent.ratom correctly?#2020-04-1615:09pmooserTrying to read up on this now ...#2020-04-1615:44thheller@pmooser try (:require [reagent.ratom :as ratom]) and (deftype Example [] ratom/IReactiveAtom)#2020-04-1615:53pmooser@thheller I tried that with the same result. For now I've just turned off the inference feature, since it seems to work fine without it.#2020-04-1618:03kennyHas anyone seen this with shadow-clj 2.8.95? It appears to be a misalignment between the assertion and the message keys.#2020-04-1619:07thheller@kenny oops, should be fixed in 2.8.96#2020-04-1619:12kennyYep, thanks!#2020-04-1621:23SeledrexHello, I am trying to configure https://github.com/borkdude/clj-kondo to work with my shadow-cljs project. To configure it, I need to get the classpath. Other build tools have commands like lein classpath or clojure -Spath but I could not find something similar for shadow-cljs. Any tips on getting the classpath for a shadow-cljs project?#2020-04-1621:30dpsuttoncheck shadow-cljs --help#2020-04-1621:30dpsuttonshould be shadow-cljs classpath#2020-04-1717:04SeledrexOh thanks! That should have been obvious 😅#2020-04-1705:18Mark BaileyHello! anyone have any experience with shadow-cljs and tailwindcss?#2020-04-1705:19Mark BaileyI am having trouble getting tailwindcss to load and be usable#2020-04-1705:21sofraHi all, anyone had any luck getting shadow-cljs, deps.edn and cider working nicely together? Things work perfectly just using shadow-cljs and cider but when I try to use deps.edn as well the cider-jack-in-cljs stops working. I select cider-jack-in-cljs -> clojure-cli and then my build and I get the following error. error in process filter: The shadow-cljs ClojureScript REPL is not available. Please check for details#2020-04-1706:06sofrarelated https://github.com/clojure-emacs/cider/issues/2812#2020-04-1707:08thheller@sofra that is not an error from shadow-cljs and I can't help with the cider parts sorry#2020-04-1707:08sofra@thheller yep understood, I will take it over to #cider#2020-04-1707:08thhellershould be easy to do though. just add shadow-cljs to deps.edn and then start as normal#2020-04-1707:09sofraall the shadow-cljs stuff is working fine#2020-04-1707:09thheller@mbbailey96 whats the issue? you just load the tailwind css file? shadow-cljs doesn't need to know anything about that?#2020-04-1707:09sofrajust the cider integration that breaks#2020-04-1707:10thhelleryeah dunno about cider. I use Cursive.#2020-04-1707:10sofrano problem#2020-04-1707:10David PhamI usually use cider-connect-cljs #2020-04-1707:11David PhamI launch a watch process #2020-04-1707:11David Phambefore#2020-04-1709:21Mikko HarjuQuestion about https://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html I'm getting Cannot infer target type in expression (. c__41761__auto__ -ratomGeneration) when using r/with-let -form in reagent (in a react native project). The article would suggest that I should be use to tag it using ^clj but this does not help. Is this a known issue? I can always revert back to (let [] (fn [] ...)) and it works.#2020-04-1709:22thhellerthe problem is in the code the macro generates. so you cannot typehint it properly without modifying the lib#2020-04-1709:23thhellerbut wasn't that fixed? I thought it was fixed in newer reagent versions?#2020-04-1709:24juhoteperiIn what case does this happen? I'm running Reagent test suite with Shadow-cljs and extern inference so it should be okay.#2020-04-1709:24juhoteperiBut this probably requires version 0.9.1#2020-04-1709:24Mikko HarjuOK, maybe I need to update my libs then#2020-04-1709:25Mikko HarjuYeah, this project is at 0.8.1, I'll update it. Thanks for your fast replies!#2020-04-1709:25thhellerhttps://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L48 that has a ^clj tag so should work#2020-04-1709:26juhoteperiYeah, and that change was released in 0.9#2020-04-1709:27Mikko HarjuUpdated reagent to 0.9.1 and it works. Thanks!#2020-04-1709:26thhellerah ok#2020-04-1714:24Mark Bailey@thheller I am getting a js-invalid-requires message on watch, specifically pointing out a require located in the index.js file of tailwindcss. Docs recommended an NPM install of tailwind so that's what I did. When I view the app in browser, it give me "failed to load" errors again citing the 'require not defined'. I tried changing :js-options :js-provider to :require but that only fixed some of the issues. It's the closest I've gotten to a working build#2020-04-1714:25dhale@mbbailey96 I like the shadow-cljs + tailwindcss workflow described in this YouTube video: https://www.youtube.com/watch?v=_CTTbC6owS0#2020-04-1714:27Mark Bailey@iradavidhale, so do I! That's where I got the idea for tailwind from, but if you look at his git repo, he has the pulled tw css file already, not the node_modules. Errors like the ones I described above are only happening when I import the tailwind node module. Also, @thheller, I forgot to mention. I get the same failed to load in browser for
react
and
react-dom
#2020-04-1714:28thheller@mbbailey96 I don't know what you are trying to do. tailwind is a css file and doesn't have JS?#2020-04-1714:28thhelleryou include it in your HTML. your CLJS build doesn't know anything about it?#2020-04-1714:29thhellermeaning you do NOT require it in your CLJS sources?#2020-04-1714:30Mark BaileyAs far as I understand when reading through the install docs on the official tw website, it calls for an install through npm or yarn, then adding @tailwind base (and others) to your site.css file.#2020-04-1714:32thhellerfor the tailwind tools yes#2020-04-1714:32thhellerthat creates a .css file for you#2020-04-1714:33Mark BaileyAh, then I gravely misunderstood the task at hand. Sorry to bother you @thheller#2020-04-1714:33thhelleryou load that in your html via <link rel="stylesheet" href="/css/whatever.css">#2020-04-1714:33thhelleror you just skip the custom build stuff and just use <link href="" rel="stylesheet">#2020-04-1714:34thhellerhttps://tailwindcss.com/docs/installation/#using-tailwind-via-cdn#2020-04-1714:34Mark BaileyYep! Just read further into the site, and found that little gem.#2020-04-1714:34Mark BaileyMy apologies, didn't mean to ask stupid questions#2020-04-1716:55jjttjjIs there anything that would prevent shadow from loading a cljs namespace in a resources/ path? I have resources as a source path in my deps.edn and :deps true in shadow-cljs.edn but when I try to require public.code.myns which is located in resources/public/code/myns.cljs I'm getting "The required namespace "public.code.myns" is not available"#2020-04-1719:41thheller@jjttjj well is it (ns public.code.myns)?#2020-04-1719:41jjttjjyes#2020-04-1719:43thhelleroh right. resources/public is filtered by default because it is were people usually output there code to#2020-04-1719:43thhellerdunno why you'd put actual code there?#2020-04-1719:45jjttjjYeah, kinda a weird situation where I have static code files I wanted to eval with a bootstrapped compiler, there are probably better ways to do it but I was doing it this way as a shortcut for now#2020-04-1719:46jjttjj(and I was trying to get them to auto-reload)#2020-04-1720:47Ivan FedorovBeen getting lots of those recently https://gist.github.com/spacegangster/c3ffcb526598c40cb03bfd37a120c436 Internal compiler error#2020-04-1720:48thhellerinternal compiler error from the closure compiler#2020-04-1720:48thhellernot shadow-cljs#2020-04-1720:51Ivan Fedorovcould be ES6 forms again?#2020-04-1720:52thhellerwhy are you writing so much JS? 😛#2020-04-1720:54Ivan Fedorovthe opposite – porting some legacy))#2020-04-1720:55thhellerI haven't worked in direct JS support in a while so I imagine that it has several issues#2020-04-1720:55thhellerclosure is fairly strict in the kind of code it accepts#2020-04-1721:01Ivan FedorovYes. This time adding terminating semicolons helped.#2020-04-1721:38Ivan FedorovNope, premature celebration, still digging the sources.#2020-04-1721:38Ivan FedorovBut yeah, that’s something about Closure, not Shadow#2020-04-1721:54emil0r@thheller Is it possible to programatically configure shadow-cljs.edn when it is loaded by shadow-cljs?#2020-04-1722:05emil0rI would like to be able to set :devtools-url based on my current ip#2020-04-1808:23David PhamDid you try the config merge flag?#2020-04-1809:33emil0rI can make that work#2020-04-1809:33emil0rThanks#2020-04-1810:39Eamonn SullivanHi all, I have a small experimental Clojure library (https://github.com/eamonnsullivan/github-search) that I'd like to turn into a mono-repo that produces both a jar and an npm package (shadow-cljs), with some common code (.cljc). Is this possible? Has anyone tried this and can point me to an example I can study?#2020-04-1810:56thhellerby npm package you mean code meant to be consumed from JS?#2020-04-1811:30Eamonn SullivanCode consumed by JS, installable via npm or yarn. #2020-04-1810:56thhelleror just used as a regular CLJS lib?#2020-04-1811:06Andrea RussoHello everyone#2020-04-1811:08Andrea RussoI have a re-frame project where I need to have some react components written in React JSX.#2020-04-1811:09Andrea RussoI’m trying to build my project following the shadow-cljs guide about importing and cosuming javascript modules and everything compiles correctly, but when I’m using my js component in my cljs code, i get the following error:#2020-04-1811:09Andrea RussoTypeError: Cannot read property ‘createElement’ of undefined#2020-04-1811:09Andrea Russothe babel generated code for the component is this:#2020-04-1811:10Andrea Russoimport React from ‘react’; function myComponent() { return /#/React.createElement(“h1”, null, “JSX!“); } export { myComponent };#2020-04-1811:10Andrea Russoand the generated code looks like this:#2020-04-1811:10Andrea Russovar module$node_modules$react$index = shadow.js.require(“module$node_modules$react$index”, {}); function myComponent$$module$myComponent() { return module$node_modules$react$index.default.createElement(“h1", null, “JSX!“); }#2020-04-1811:11Andrea Russoit seems that that extra default property in the return statement leads to the error#2020-04-1811:12Andrea Russomodule$node_modules$react$index in the browser js runtime exists and has a createElement attribute#2020-04-1811:13Andrea RussoI’m using shadow-cljs version 2.8.97#2020-04-1811:14Andrea RussoI’m really stuck#2020-04-1811:30thhellerimport React from ‘react’; this is the issue, should be import * as React from "react";#2020-04-1811:31thhellerotherwise it accesses the .default property which react doesn't have#2020-04-1814:51Andrea Russooh sorry#2020-04-1814:51Andrea Russothank you very much for the hint#2020-04-1815:02thhellerwell technically your way is correct but commonjs<->esm interop is weird at the moment#2020-04-1815:13Andrea Russoit works perfectly with your suggested change#2020-04-1815:14Andrea Russothank you#2020-04-1815:14Andrea Russoand thank you very much also for shadow-cljs#2020-04-1815:14Andrea Russoe fantastic tool!#2020-04-1815:14Andrea Russoa fantastic tool!#2020-04-1815:43mauricio.szaboBy the way, recently I was having trouble using shadow-cljs with an electron project. I was getting an error: failed to parse websocket message... when whatching my project and running electron. I was just abouit to open an issue right now, and it's already fixed! Thanks a lot 😄#2020-04-1815:43thhellerhmm?#2020-04-1818:34mauricio.szaboFor some reason, since the version, version 2.8.90 I was having some problems with different targets like electron, with a message
failed to parse websocket message {:type :repl/init, :repl-state {...lots of things here...
#2020-04-1820:36thhellerfixed in 2.8.98. some REPL files weren't actually written to disk unless they were used in the regular build#2020-04-1823:29Donal Mac An RiHello all, wondering if anyone here has had any success working with shadow-cljs in WSL2 on windows? I'm getting this error any time I try to start either the browser or node-repl:
[:browser-repl] Build completed. (130 files, 0 compiled, 0 warnings, 2.55s)
null=> Execution error (AssertionError) at shadow.cljs.repl/read-one (repl.clj:535).
Assert failed: (symbol? read-ns)
#2020-04-1902:40Chris McCormickI have an issue where css reloading stops happening after a few successful reloads. What is the best way for me to dig in an help diagnose this?#2020-04-1903:22Chris McCormickHm it seems to resume after a while. Is there a debounce on the file change time?#2020-04-1907:17thheller@donal.macanri upgrade to 2.8.98, I accidentally broke the REPL in 2.8.95#2020-04-1907:18thheller@chris358 there is a 500ms wait time but shouldn't take longer than that?#2020-04-1907:23Chris McCormick@thheller thanks i will run some tests and also loosen up my CSS editing trigger finger 🔫#2020-04-1913:25Donal Mac An Rithat worked - thank you!#2020-04-1919:14knubie@thheller Are you planning to do a write up of some sort about shadow-experiments? I remember reading some comments you made about it across various forums. I’ve been super interested in it since I learned about it.#2020-04-1919:46thhellerwrote a bit in the readme and in the doc folder https://github.com/thheller/shadow-experiments#2020-04-1919:46thhellerbut not all of it is current#2020-04-1919:46thhellerI'll write more when I figure stuff out probably#2020-04-1919:47thhellerthinking about a lot of issues still#2020-04-1919:50thhelleroh and I'm dogfooding it all in the shadow-cljs UI so can take a look there if you like#2020-04-1921:45knubieWould also love to hear about the issues you’re thinking about too 😁#2020-04-1921:48thhellervarious stuff ... async scheduling, subtree priority (eg. delaying updates to parts that aren't visible), animations, etc#2020-04-1921:49thhellerdon't have too many brain cycles to spend on this currently so not much progress#2020-04-2001:45knubieAre you still optimistic about the worker stuff?#2020-04-2002:43wilkerluciohello, I've a project that I'm getting a lot of debug logs like
19:40:50.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
19:40:51.646 [main] INFO  io.undertow - starting server: Undertow - 2.0.30.Final
19:40:51.655 [main] INFO  org.xnio - XNIO version 3.8.0.Final
19:40:51.664 [main] INFO  org.xnio.nio - XNIO NIO Implementation Version 3.8.0.Final
19:40:51.728 [main] INFO  org.jboss.threads - JBoss Threads version 3.1.0.Final
19:40:51.737 [XNIO-1 I/O-2] DEBUG org.xnio.nio - Started channel thread 'XNIO-1 I/O-2', selector 
#2020-04-2002:43wilkerluciois there a way for me to debug why I'm getting the verbose, and how to tune it down?#2020-04-2005:16steveb8nQ: I like the “hacking libraries” capability. Should this also work for hacking npm dep sources?#2020-04-2006:36thheller@wilkerlucio if you are running the embedded version logging is subject to your logging config. so you configure it and can just disable it if you want.#2020-04-2006:37thheller@steveb8n not really no#2020-04-2006:40steveb8nGood to know. Thanks. I can still do the local clone/patch with my npm deps. that’s working well.#2020-04-2006:37wilkerlucio@thheller do you have an example of that config?#2020-04-2006:37thhellerI don't. You do.#2020-04-2006:37thhellerWhat do you use for logging in your app?#2020-04-2006:38thhellerlogback.xml, log4j.properties, etc?#2020-04-2006:38wilkerlucionothing, I'm guessing some dependency is doing it#2020-04-2006:39thhellercheck via shadow-cljs clj-repl ( "logback.xml") or so#2020-04-2006:39thhellersomething must be configuring the logging somewhere#2020-04-2006:41thhellerI'm a bit rusty when it comes to jvm logging setups#2020-04-2006:43wilkerlucioit seems to happen on my deps projects, on lein ones it seems normal#2020-04-2006:43wilkerlucionot just on shadow really, I see the same issue in other projects with just deeps#2020-04-2006:43wilkerluciogonna dig down#2020-04-2006:44thhellercheck your dependencies for a logging lib#2020-04-2006:44thhellerlog4j, logback etc#2020-04-2006:44thhellersome libs have direct deps on them when they shouldn't#2020-04-2006:45thhellerneed to find which lib is doing the actual logging to disable it 😛#2020-04-2006:59thheller@wilkerlucio log4j.properties in one classpath root with
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{HH:mm:ss,SSS}] %m%n
#2020-04-2006:59thhellershould make it shutup .. but only if your logger is log4j#2020-04-2006:59thhellerI don't have a config for logback#2020-04-2008:23Andrea RussoI have an hybrid project, where I use some JSX files. I’m able to convert them with babel in standard JS and consume them from ClojureScript in a re-frame app.#2020-04-2008:24Andrea Russomy problem arises when I try to import a local Js file in another JS file#2020-04-2008:26Andrea Russofor example:#2020-04-2008:26Andrea Russoimport { ProTip } from ‘./ProTip’;#2020-04-2008:27Andrea Russothe closure compiler says that it can’t understand import from directories#2020-04-2008:28thhellerplease post actual code with actual messages. makes it much harder to follow if you shorten things.#2020-04-2008:30Andrea Russoyes sorry I’m trying to replicate the problem, now I have other errors that happens before the one I described#2020-04-2008:31thhellerI don't really recommend including too many .js files. the system isn't really tuned for that and has a lot of issues I haven't had time to work on.#2020-04-2008:56Mark BaileyHey everyone! Setting up a new template for projects and shadow keeps alerting me "Stale Client". Not sure why it keeps doing so, even on a page refresh#2020-04-2008:57thhellermeans you are loading outdated .js code#2020-04-2008:57thhellercommon cause is changing the output directory or names but not adjusting your html accordingly#2020-04-2008:58Mark Baileychecking over my html, everything seems to be in place#2020-04-2008:59Mark Baileyoutput dir is set correctly as well it seems#2020-04-2008:59thhellerif you are using a different http server it might be caching related#2020-04-2009:00thhellercould also be that you have 2 separate shadow-cljs instances running competing with each other#2020-04-2009:01Mark Baileywhat if they are running on different ports?
#2020-04-2009:01Mark Baileyi have two dev instances running on different tmux boxes but on separate ports#2020-04-2009:01thhellerI mean in the same project#2020-04-2009:01thhelleryou can have as many different projects as you like#2020-04-2009:01thhellerjust don't run shadow-cljs twice in the same project#2020-04-2009:02Mark Baileyokay, that makes sense but that doesn't seem to be whats going on. mind if i throw you a github link?#2020-04-2009:02thhellersure#2020-04-2009:04Mark Baileycommitting now, one sec. sorry for the delay#2020-04-2009:05Mark Baileyin the meantime, @thheller you did an absolutely stellar job with shadow, my guy. CLJS has been an incredible journey and shadow has drastically improved my ux!#2020-04-2009:09Mark Bailey@thheller https://github.com/cerbervs/cljs-template#2020-04-2009:10thhellerlooks fine. a bit dated maybe but fine.#2020-04-2009:11Mark Baileydid a clean and im running npm install again. i'll go through the whole set up and if it works#2020-04-2009:11thheller{init-fn app.core/init} is incorrect though#2020-04-2009:12Mark Baileyokay! that was my initial guess as to why it wasn't giving me a non-stale build#2020-04-2009:12thheller
{:source-paths ["src"]

 :dependencies [[nrepl "0.7.0"]
                [cider/cider-nrepl "0.25.0-alpha1"]
                [proto-repl "0.3.1"]
                [binaryage/devtools "1.0.0"]
                [reagent "0.10.0"]
                [re-frame "0.12.0"]
                [day8.re-frame/re-frame-10x "0.6.2"]
                [bidi "2.1.6"]
                [kibu/pushy "0.3.8"]]
 :nrepl {:port 3334}

 :dev-http {8080 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

   :modules
   {:main
    {:init-fn app.core/init
     :preloads [day8.re-frame-10x.preload]}}

   :dev
   {:compiler-options
    {:closure-defines {re-frame.trace/trace-enabled? true
                       day8.re-frame.tracing/trace-enabled? true}}}}}}
#2020-04-2009:13thhellershadow-cljs watch app should complain about the bad {init-fn ...}?#2020-04-2009:13thhellerso yeah it would be stale after that since it never finishes the compile#2020-04-2009:14Mark Baileyno complaint, and says build completed#2020-04-2009:20thhellerfixed in master 😉#2020-04-2009:22Mark Baileyi'm sorry i don't understand, i've never had someone else edit my code with git#2020-04-2009:25thhellerno I mean I fixed it in shadow-cljs. with the next release {init-fn ...} will fail properly and show an error#2020-04-2009:26Mark Baileyoh!#2020-04-2009:26Mark Baileywow. my level of tiredness is showing#2020-04-2010:28Mark Bailey@thheller I've gone through every setting I can think of to no avail. It's still giving me a stale client warning#2020-04-2010:59Mark BaileyI am going through Jacek Schae's tutorial on re-frame, this is basically his template, just with updated deps. everything is fine running his template, but as soon as i update deps, things get wonky with the stale client warning#2020-04-2011:12thheller@mbbailey96 verify that you are actually loading what you are think you are loading#2020-04-2011:13thhelleryou get a stale client warning when the .js you are loading was not produced by the running watch#2020-04-2011:14thhellerthere aren't that many places that can cause this#2020-04-2011:18Mark Baileymain.js is supplied by watch afaik, which is being compiled. it is stored in my js/ folder, which is definitely linked in my index.html.#2020-04-2011:19Mark BaileyI haven't been getting any build errors, main is compiled and in the right directory, i just don't know what I am missing#2020-04-2011:28Mark Baileywhen I try to run (js/alert) it's giving me an error "No such namespace: js". Can't interact with the site at all through repl. Might this be a cause or a help determining what is going wrong?#2020-04-2011:36thhellerthat means you are in a CLJ REPL not a CLJS REPL#2020-04-2011:37thhellerbut not that doesn't mean anything#2020-04-2011:37thhellerlets go step by step#2020-04-2011:37thhellershut down shadow-cljs#2020-04-2011:37thhelleropen the webpage? do you get something? if yes something else is running somewhere#2020-04-2011:37thhellerdelete public/js#2020-04-2011:37thhelleropen the webpage? does it 404 properly?#2020-04-2011:38thhelleryou are looking all over the place if all you need to check if file you think you are loading are the actual files you are looking at#2020-04-2011:45Mark Bailey@thheller i was still getting connection from elsewhere.#2020-04-2011:45Mark Baileythank you for all the help!!#2020-04-2013:15Andrea RussoI can’t believe that yesterday this import (and others) worked:#2020-04-2013:15Andrea Russo(ns dias-web.common-ui (:require [re-frame.core :as re-frame] [dias-web.subs :as subs] [“@material-ui/core/styles/MuiThemeProvider” :default ThemeProvider] [“@material-ui/core/styles” :refer [createMuiTheme withStyles]] [“@material-ui/core/colors” :as mui-colors] [“@material-ui/core/CssBaseline” :default CssBaseline] [“@material-ui/core/Typography” :default Typography] ; [“@material-ui/core/Avatar” :default mui-avatar] ; [“@material-ui/icons/Android” :default AndroidIcon] [“@material-ui/core/AppBar” :default AppBar] [“@material-ui/core/Toolbar” :default ToolBar] [“@material-ui/core/IconButton” :default IconButton] [“@material-ui/icons/Menu” :default MenuIcon] [“@material-ui/core/Button” :default Button]))#2020-04-2013:15Andrea Russoand today everything compiles but at runtime it says:#2020-04-2013:15Andrea RussoFailed to load dias_web/common_ui.cljs Module not provided: module$node_modules$$material_ui$core$styles$index#2020-04-2013:16Andrea RussoIt’s very strange, everything the same as yesterday#2020-04-2013:57AronI would like to ask for some orientation (I am already reading the docs but I have some questions that are more basic than what the docs assumes). Basically, I am not even sure if it's possible, or rather I assume it's possible but I am not sure if I should do what I want to do : ) I would like to have specs added next to my devcards build that would complain during development if I mess up some argument to functions (or let bindings in components) or the output of some functions. Is there some guide regarding this that I could read to get up to speed?#2020-04-2014:00thheller@andrea.russo looks fine as far as I can tell. "Failed to load" sort of creates a chain reaction. One thing fails to load and then a whole bunch of others that depend on that also fail so you gotta fine the actual failing thing#2020-04-2014:02thheller@ashnur clarify "specs added"? shadow-cljs only compiles stuff for you. you are responsible for adding stuff to the build and requiring it. I typically recommend adding specs to extra namespaces. so for (ns app.foo) you also have (ns app.foo-spec) and then load that ns via :preloads or some other means#2020-04-2014:04Aronadding the files and writing in the namespace and the tests is what is the most clear thing in this process#2020-04-2014:05Aronthe preloads stuff, I have no idea why it is preload, compared to what, I am guessing there is a lot of history here where these names and approaches are coming from. I only know javascript, if I want something like this, I have to bundle in with the rest of the app#2020-04-2014:07thheller:preloads is badly named yes but it is what it is. It is for namespaces that should only be added to the build in development.#2020-04-2014:08Aronsorry, I didn't mean to criticize, I just don't understand 😐#2020-04-2014:08thhellerthey are added "before" the other code so they are sometimes loaded before the other code#2020-04-2014:08thhellerbut they can depend on other code in which they that code will be loaded before them#2020-04-2014:08Aronok, so it is similar as the namespace that I write in my file?#2020-04-2014:09thhellerit IS just a regular namespace yes#2020-04-2014:09thhelleryou just don't require them from any other namespaces#2020-04-2014:09Aronthanks!#2020-04-2014:30AronI hate when I am stupid, I added the file, wrote in the namespaces, specified the file/namespace in the vector of preloads for the build that I am running, if I change the file I can see shadowcljs picking the change up and rebuilding, but a simple (prn 'foo) has no output#2020-04-2014:31Aronthe relationship between namespaces/filenames is as obscure as ever for me#2020-04-2014:31Aronso I use the same for both, hopefully that should work#2020-04-2014:35thheller@ashnur you are not stupid. you are learning, it is ok to make mistakes. it is ok to ask questions ... that is how we learn.#2020-04-2014:35thhellernamespace and filename are really the same thing. there are just a few basic rules for namespaces and which filename they should have#2020-04-2014:35thheller(ns foo.bar) should be foo/bar.cljs#2020-04-2014:36thheller(ns foo.with-a-dash) should be foo/with_a_dash.cljs#2020-04-2014:36thhellerthe names go onto the classpath, meaning you pick one of your source-paths and put them there#2020-04-2014:36thhellerthats it really#2020-04-2014:36thhellerand yes the name of the namespace MUST match the filename#2020-04-2014:36thhellerotherwise it won't be found#2020-04-2014:37thhellerprn not showing up I don't know. if you do everything correctly it should.#2020-04-2016:42Aronit works, for some reason I forgot to put the :preloads under :devtools facepalm#2020-04-2016:18lilactownhey thheller, I am getting a bunch of $jscomp errors when using dependencies that ship es6+ code, unless I bump :output-feature-set to match the level required not to compile them#2020-04-2016:20lilactowna not-completely-minimal-example is this project: https://github.com/geraldodev/react-form-hook-test when i boot this up, I see a couple errors about $jscomp.makeIterator changing the :output-feature-set to :es6 makes these go away. then I try and type something in a field, which throws an error about $jscomp with the stacktrace pointing at an async function. bumping the :output-feature-set to :es8 makes this go away.#2020-04-2016:20Andrea Russo@thheller I’ve found that if I delete the .shadow-cljs/ and rebuild everything works. As soon as I stop the build and the start another without deleting the .shadow-cljs directory, I have the module loading problem#2020-04-2016:21lilactowni'll open a github issue#2020-04-2016:21Andrea RussoI can share with you the repo I’m working on, if you are interested seeing this behaviour#2020-04-2016:32Andrea Russoby deleting everytime the .shadow-cljs I’m able to work, which means I’m stuck again with another problem, maybe this one is something related to the closure compiler, which does not accept directory paths in javascript files when importing other files:#2020-04-2016:32Andrea Russo
losure compilation failed with 1 errors
--- App.js:6
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
#2020-04-2016:33Andrea RussoThese are imports from the App.js file:#2020-04-2016:33Andrea Russoimport * as React from ‘react’; import Container from ‘@material-ui/core/Container’; import Typography from ‘@material-ui/core/Typography’; import Box from ‘@material-ui/core/Box’; import Link from ‘@material-ui/core/Link’; import * as ProTip from ‘./ProTip’;#2020-04-2016:33Andrea Russoand the problem is importing a local file called ProTip.js#2020-04-2016:33Andrea Russowhich is in the same directory of App.js#2020-04-2016:38Andrea Russooh sorry, and this is my shadow-cljs.edn#2020-04-2016:38Andrea Russo{:lein true :nrepl {:port 8777} :builds {:app {:target :browser :output-dir “resources/public/js/compiled” :asset-path “/js/compiled” :modules {:app {:init-fn dias-web.core/init :preloads [devtools.preload day8.re-frame-10x.preload]}} :dev {:compiler-options {:closure-defines {re-frame.trace.trace-enabled? true day8.re-frame.tracing.trace-enabled? true}}} :devtools {:http-root “resources/public” :http-port 8280 }}}}#2020-04-2016:45Andrea Russooh now I read that you are discouraging having more than a bunch of js files in a shadow-cljs project#2020-04-2016:45Andrea Russosorry#2020-04-2016:47Andrea Russoany suggestion on how to coordinate me, using cljs, and my other cooworkers, using js? Maybe a magic live changing local node module in node_modules?#2020-04-2018:24Ivan FedorovSeeing those sometimes now after a version upgrade I think.
[:dev] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/spacegangster/clj/lightpad/client/src/flow/views/tasks/microtasks.cljs:6:1
--------------------------------------------------------------------------------
   3 |             [space-ui.style.constants :as sc]
   4 |             [space-ui.style.constants :as sc]))
   5 |
   6 | (def ^:const dim-item-side-px (sc/px sc/dim-step))
-------^------------------------------------------------------------------------
Error in phase :compilation
Can't redefine a constant at line 6 flow/views/tasks/microtasks.cljs
--------------------------------------------------------------------------------
   7 | (def ^:const dim-fs ".9rem")
   8 |
   9 | (def rules1
  10 |   [:.microtasks
Version output
=== Version                                                                        
jar:            2.8.97            
cli:            2.8.97               
deps:           1.3.2                   
config-version: 2.8.97  
Previously was on: ^2.8.91
#2020-04-2018:24Ivan FedorovWill add an issue on demand#2020-04-2020:01thheller@ognivo just don't use ^:const. it doesn't do what you think it does. do not use it. there is no point. also why is [space-ui.style.constants :as sc] imported twice? line 3/4?#2020-04-2119:09Ivan Fedorovok, thanks! I think I saw it somewhere in Mike Fikes twits#2020-04-2020:02thheller@andrea.russo I can't help much with this. I need something reproducible to figure out what is happening. deleting the cache shouldn't be necessary so that sounds like a bug.#2020-04-2020:43thhellerI always thought bash was bad but the syntax of powershell is ridiculous .. who comes up with this shit ...#2020-04-2020:45isakyea they messed up pretty bad#2020-04-2022:05Andrea Russo@thheller I can give you access to the repo if you want to reproduce the behaviour. I’m really sorry, I’m in a hurry with a project at work and I don’t have time to contribute with a minimal project that exposes this behaviour.#2020-04-2022:07Aroni thought powershell syntax was intuitive 😄#2020-04-2100:57haywoodI’m not finding a build hook that’s working for me, looking for some advice. I need to run some code that generates a new routes file (details not really important) based on files in a directory. This should really run before shadow does anything, but there’s not really a hook for that. I’m trying to repurpose my function to run on the :configure step, and the :compile-prepare step, but that’s not working so swell#2020-04-2101:57justin@thheller thanks for the project 🙂. Was running into issues getting react and some npm react components to play nice together, and noticed some funky javascript output with fighweel. switched to shadow-cljs and it fixed my issue.#2020-04-2103:29haywood++ shadow is the gold standard @justtaft#2020-04-2106:31thheller@haywood if you want something to run before shadow-cljs does anything then run it separately 😛#2020-04-2108:14yendaI'm writing an override of require for node-test target how can I make sure it's added at the top of the js file#2020-04-2108:15thhelleroverride how?#2020-04-2108:16thhellerI'm assuming for all the custom mods we talked about last time?#2020-04-2108:18yendayes#2020-04-2108:17thhelleryou can't really override actual node require#2020-04-2108:17yenda
(function(){
    var Module = require('module');
    var originalRequire = Module.prototype.require;

    Module.prototype.require = function(){
        // if react-native module return mock
        return originalRequire.apply(this, arguments);
    };
#2020-04-2108:18thhellerright. I would keep this totally separate probably.#2020-04-2108:19thhellerand when you run node you run node --require=./your-require-override.js the-output.js#2020-04-2108:21thhelleryou can make it part of the build also but I prefer to keep hacks in a place I can easily experiment with 😛#2020-04-2108:23yendabut if I want to write it in cljs then I need to have a separate build config for it?#2020-04-2108:26thhellerwrite what in CLJS? the override mechanism?#2020-04-2108:27yendayeah I was thinking of giving it a shot since I already have all the mocks in cljs#2020-04-2108:28thhellerhmm the issue is that its not easy to ensure that its actually loaded before require is first used#2020-04-2108:29thhellerso I wouldn't recommend trying that#2020-04-2108:29thhellerit is easier in development because you can abuse :preloads but there is no :preloads-that-also-apply-in-release#2020-04-2109:03yendabefore I go further it seems like my first issue with the react-native modules in node is that they are using import
SyntaxError: Cannot use import statement outside a module
#2020-04-2109:11yendait looks like the issue is that I get a require when it should be an import shadow.js.shim.module$react_native_languages = require("react-native-languages");#2020-04-2109:24thhelleryes. most react-native modules cannot be loaded in node. they are packaged with the assumption of going through metro first.#2020-04-2109:25thhellerI thought that is why you are mocking them?#2020-04-2109:40yendayes that is not a useful path to explore indeed, even if I manage to get them to run in node they will most likely yield odd results or errors#2020-04-2110:12Aronso, i removed my question because I found in the docs the environment variable part but actually it's not what I need, or at least only part of it. I still don't know how I can read the value of anything I pass to shadow-cljs inside my app. I am happy to use --config-merge or anything else, but that's just setting the value, what is the keyword to search for to find how to read what I set there?#2020-04-2110:32yenda@thheller looks like the solution with a separate js file works, on every error I mock the lib that fails and move to the next error. Since I already have the mocks in cljs and I find it more pleasant to write what would be the right approach? So far I have a frankenstein 😄 I put my mock cljs file in the path that is compiled by :test and I wrote an override.js that imports it, probably the worst possible way by copy pasting most of the shadow init code https://gist.github.com/yenda/eae7a492f2a7ea94cb4124ff5ef46f4a#2020-04-2110:32yenda(it does work though)#2020-04-2110:43thheller@ashnur https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2020-04-2110:43thhellerbut in general I advise everyone against using environment variables in CLJS builds. just pass that data into your code at runtime instead#2020-04-2110:53Aron@thheller what do you mean pass code at runtime#2020-04-2110:54thhellerpass the data#2020-04-2110:54thhellerassuming you are following the recommendations of having a init fn that is called when your code is loaded#2020-04-2110:55thheller<script>your.app.init("with-the-data-you-need");</script>#2020-04-2110:55thheller(defn init [the-data] ...)#2020-04-2110:55thhellercan pass the data in as a regular JSON object#2020-04-2110:55thhelleror edn encoded string#2020-04-2110:55thhelleror transit#2020-04-2110:55thhellerwhatever you want really#2020-04-2110:56Aronhow is going to help me to have different values for different builds#2020-04-2110:57AronThe problem I am trying to solve is that there are a number of servers I need to connect to depending on the environment#2020-04-2110:57Arondjango runs on one port for me, another for others and definitely different port in production#2020-04-2110:58thhellerthen you adjust whatever generates <script>your.app.init("with-the-data-you-need");</script>#2020-04-2110:58Aronmy devenv is devcards, thats' one port but when my boss checks my work, he will use the development build which is served by django in development mode which of course has it's own dev config#2020-04-2110:58Aronso I need something that generates that, thanks#2020-04-2110:58Aronwe just use static files at the moment#2020-04-2110:58thhellerthats fine#2020-04-2110:58thhellerjust have different html files ...#2020-04-2110:59thhellerindex.html index-dev.html index-boss.html etc#2020-04-2110:59Aron... that just exports the problem from shadow-cljs into django, I don't want to learn python 🙂#2020-04-2110:59thhellerif that pattern doesn't fit then use the env+closure-defines#2020-04-2110:59Aronthe thing is, no one wants to use cljs just me, if I have to commit code that changes everyone's codebase, there will be comments#2020-04-2111:00thhellerI don't have a clue what you are doing so you are going to have to do something that works for you#2020-04-2111:29AronI just realized something, I am not doing anything special, I created this project with create-cljs-app. There are no js files with init functions. I am trying to find how to pass data to my apps still, but so far only the closure-defines is the only thing that is somewhat similar, and even that I haven't yet been able to figure out how it actually expected to work. 🙂#2020-04-2112:17AronI think this create-cljs-app thing uses clojurescript to do this init calling thing since I have something like a main function exported and called with render, and the main function is configured in :init-fn. So if I understand your previous suggestions correctly, I should just write my configuration inside my core.cljs and cards.cljs files that call the render functions#2020-04-2113:34thhellerif the build config contains :init-fn some.ns/init then yes that calls init without args. you can will put the config into the html via <script>_CONFIG = "whatever";</script> and access it in into via (js/console.log js/MY_CONFIG)#2020-04-2113:36Aronthis also makes sense now, in hindsight.#2020-04-2111:00Aron🙂 thanks for the help, I will figure out something#2020-04-2111:39yendaI'm getting a maximal call stack size exceeded when running my tests
SHADOW import error /home/yenda/status-react/target/test/cljs-runtime/shadow.module.main.append.js
/home/yenda/status-react/node_modules/source-map/lib/util.js:343
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
                                            ^

RangeError: Maximum call stack size exceeded
    at compareByGeneratedPositionsDeflated (/home/yenda/status-react/node_modules/source-map/lib/util.js:343:45)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:88:11)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
#2020-04-2111:40yendacould it be because I have most of the SHADOW_IMPORT statements twice with my require override?#2020-04-2112:02martinklepsch
(let [react-dom-server (js/require "react-dom/server")]
      (.renderToStaticMarkup react-dom-server src))))
I’m just wondering, is this kind of approach something that Shadow’s npm module system supports?
#2020-04-2113:29thhellerI don't understand the question? shadow-cljs does not bundle js/require calls in browser builds. if this runs in an environment that has an actual js/require then it would work but shadow-cljs has no hand in that?#2020-04-2113:36martinklepschThis is for a node build. I guess I’m wondering if in node builds the ns require is needed for the npm module to be included in release builds? I hope that question makes more sense, sorry 🙂#2020-04-2113:39thhellerin node builds shadow-cljs doesn't include anything into the build#2020-04-2113:40thhellerit literally just writes require("a-thing") if you (:require ["a-thing" :as x])#2020-04-2113:41martinklepschgot it, thanks!#2020-04-2113:41thhellerbut yes ... if you want shadow-cljs to bundle things then it must be in the ns form. it does not pick up js/require calls in the code#2020-04-2113:41thhellerit could pick up js/require calls but that might give people ideas of using it dynamically and so on which won't work#2020-04-2113:41martinklepschuhm. what’s the difference between “bundle” and “include anything into the build”?#2020-04-2113:42thhellerin node builds in general it will create a regular .js file that still has require calls in the code#2020-04-2113:42thhellernode will take care of those and provide the dependencies at runtime#2020-04-2113:42thhellerin the browser we obviously can't do that so shadow-cljs does not generate require calls#2020-04-2113:43thhellerand instead bundles all the required code into the output directly so it can be loaded at runtime#2020-04-2113:43thhellerso a browser build would contain react and so on while a node build will not (by default)#2020-04-2113:46martinklepschOk, I think that makes sense. Bundling isn’t really a (necessary) thing in node.#2020-04-2113:46martinklepschthanks#2020-04-2113:46thhelleryou can still enable it if needed but it is off by default since node can just provide it#2020-04-2113:24AronI don't know what's with me and with clojre(script) tooling, but this continuous struggle of reading thousands of words with no results is really upsetting. I've given up for 8 years because of this, and I really feel like shadowcljs works, but to not be able to do something as simple as to set a build dependent variable for hours, despite getting help from the creator himself, is just upsetting^2. In js I know I have a bundler, browserify or webpack, I select the env plugin, use bash env variables in the terminal, then I can read them either through some module or on global/window. Not nice, but the whole process took less than 30 minutes the first time I had to do it. I've been trying to do this for 4 HOURS continously. I've read everything twice, I don't know what I missed but at this point I wish I could just quite and go fishing instead.#2020-04-2113:27dpsutton
{...
 :builds
 {:app
  {:target :browser
   ...
   :modules {:app {:entries []}}
   ;; to enable in development only
   :dev {:closure-defines { true}}
   ;; to enable always
   :closure-defines { true}
   ;; you may also enable it for release as well
   :release {:closure-defines { true}}
   }}
#2020-04-2113:29Aronas I described it above, the problem for me here is that this is INPUT, and I would rather read the variable, not just write it#2020-04-2113:29thheller
(ns )

(goog-define VERBOSE false)
#2020-04-2113:30thhellerthink of that like (def VERBOSE false)#2020-04-2113:30Arontrying to (prn VERBOSE) I only got the value that I defined inline in the file, the config didn't overwrite it#2020-04-2113:30thhellerso you use it like any other def#2020-04-2113:30thhellerwell how did you set it?#2020-04-2113:30Aronthe way you see it in the file at the root of this thread#2020-04-2113:31thhellerwhich one? those are multiple different examples rolled into one?#2020-04-2113:32thhellerdo you use project.clj or deps.edn instead of just shadow-cljs.edn? in that case you might have the wrong clojurescript/closure-library versions in which case closure-defines don't work properly#2020-04-2113:33Aronoh, i am so stupid#2020-04-2113:33AronI now understand the docs with the https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2020-04-2113:33Aronof course it didn't work#2020-04-2113:34AronI tried to do two things at once. thanks again @thheller and @U11BV7MTK#2020-04-2113:57yendaIs there a known cause for these sort of maximal call stack size exceeded errors?
Testing status-im.test.chat.models.message
SHADOW import error /home/yenda/status-react/target/test/cljs-runtime/shadow.module.main.append.js

/home/yenda/status-react/node_modules/source-map/lib/util.js:373
function strcmp(aStr1, aStr2) {
               ^
RangeError: Maximum call stack size exceeded
    at strcmp (/home/yenda/status-react/node_modules/source-map/lib/util.js:373:16)
    at compareByGeneratedPositionsDeflated (/home/yenda/status-react/node_modules/source-map/lib/util.js:354:9)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:88:11)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
    at doQuickSort (/home/yenda/status-react/node_modules/source-map/lib/quick-sort.js:99:5)
#2020-04-2113:58yendaI run the tests with yarn shadow-cljs compile mocks && yarn shadow-cljs compile test && node --require ./test-resources/override.js target/test/test.js override.js is here https://github.com/status-im/status-react/pull/10217/commits/80e7685cc772b8e0aa08f6c9325aeed7266902d5#diff-31223e9c64942d5ed5214807141c977e#2020-04-2113:59thhellerno clue#2020-04-2114:01yendathis particular test didn't yield any error with the doo+lein stack. I also noticed that there was another test that was failing with the same kind of error, but in that case it was just a test that wasn't run with doo and was wrong, but instead of a proper assertion fail it was throwing this callstack error#2020-04-2114:02thhellersource-map also modifies require I think so you might just get in its way?#2020-04-2114:02thhellertry running against a release build. that won't include the source-map package (unless you do manually)#2020-04-2114:03yendainteresting start with a warning in release build:
Resource: mocks/js_dependencies.cljs:47:1
 constant ReactNative assigned a value more than once.
Original definition at externs.shadow.js:2
#2020-04-2114:05yendabut yeah looks like it is related to sourcemap require because I see
Testing status-im.test.chat.models.message
ERROR in (add-received-message-test) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: lV.a is not a function]
DEBUG [status-im.native-module.core:259] - [native-module] is24Hour
#2020-04-2114:05yendaso probably some function call that wasn't mocked#2020-04-2114:07thhelleryou can turn off source maps then it won't include that package#2020-04-2114:07thhellerjust makes debugging a bit annoying 😛#2020-04-2114:09yendawell it's tests anyway#2020-04-2114:09yendaeasier to debug
ERROR in (add-received-message-test) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: status_im.chat.models.message.add_message.cljs$core$IFn$_invoke$arity$2 is not a function]
than random max call stack exceeded 😄
#2020-04-2114:09thhellershadow-cljs release tests --debug also helps#2020-04-2114:12yendawhat does it do? I just get an extra warning about tufte#2020-04-2114:15yendait looks like it's because of the with-redefs in the test#2020-04-2114:16yendahttps://github.com/status-im/status-react/blob/80e7685cc772b8e0aa08f6c9325aeed7266902d5/test/cljs/status_im/test/chat/models/message.cljs#L15#2020-04-2114:17thhellerif you need with-redefs when you should set :compiler-options {:static-fns false}#2020-04-2114:18yendathanks! totally worked#2020-04-2117:36Andrea RussoDid someone have success in importing react bootstrap in a shadow-cljs project?#2020-04-2117:41haywoodshould just be able to npm install it and start using it right?#2020-04-2117:41haywoodreagent’s react interop is great, I’m using the EUI library just fine.#2020-04-2117:42Andrea Russonpm installed react-bootstrap and I’m not able to do a simple (:require [“react-boostrap/Button” :default Button])#2020-04-2117:43haywood:as Button?#2020-04-2117:43Andrea Russoit seems that the react-bootsrap npm module is written in TypeScript#2020-04-2117:44Andrea Russofull of .ts files#2020-04-2117:44Andrea Russo@haywood yes, tried that too#2020-04-2117:44haywoodnot to be overly pedantic, but I refer to this chart a lot https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-04-2117:48haywoodI think the ts files are just the source files, if you look in the package.json it’ll point to the package’s main directory#2020-04-2117:48haywood(in the node_modules folder)#2020-04-2117:51Andrea RussoI’ve found the js files, in node_modules/react-bootstrap/esm#2020-04-2117:52Andrea Russobut requiring [“react-boostrap/esm/Button” :as Button] doesn’t work#2020-04-2117:53Andrea RussoSearch in: /Users/arusso/Development/clojurescript/dias-web/node_modules You probably need to run: npm install react-boostrap/esm/Button#2020-04-2117:56Andrea Russomaybe I can force the resolver by telling something like this?#2020-04-2117:56Andrea Russo:js-options {:resolve {“react-bootstrap” {:target :npm :require “react-bootstrap/esm”}}}#2020-04-2117:57Andrea Russodoesn’t work 😩#2020-04-2118:01AronI wouldn't want to use esm modules yet if I could avoid it. Is that package published using exclusively those?#2020-04-2118:02Andrea RussoI don’t know#2020-04-2118:02Andrea RussoI nee to check that#2020-04-2118:03Aronin any case, the link above to the UserGuide explains how to load npm packages, the npm error saying that you have to iunstall react-bootstrap/esm/Button sounds wrong#2020-04-2118:04Aronhave you tried just ["react-bootstrap/Button" :as Button]?#2020-04-2118:05Aronhttps://react-bootstrap.github.io/getting-started/introduction/#importing that's how the docs says it should work#2020-04-2118:10Andrea Russoyes I tried it also#2020-04-2118:11Aronand what was the error?#2020-04-2118:11Andrea Russoalways the same:#2020-04-2118:11Andrea RussoSearch in: /Users/arusso/Development/clojurescript/dias-web/node_modules You probably need to run: npm install react-boostrap/Button#2020-04-2118:12haywoodI’m gonna try it locally, have me curious#2020-04-2118:12Andrea Russothanks#2020-04-2118:12Andrea RussoI’m using this template project:#2020-04-2118:13Andrea Russohttps://github.com/day8/re-frame-template#2020-04-2118:13Andrea Russo
lein new re-frame <project-name> 
#2020-04-2118:13Andrea Russojust do a npm install react-bootstrap#2020-04-2118:14haywoodeh I’m just installing into my project#2020-04-2118:15Andrea Russo:+1:#2020-04-2118:14haywoodthis package is pretty weird though looking at the node_modules directory#2020-04-2118:14Andrea Russoyes#2020-04-2118:19haywoodyea just not working and I’m not sure why#2020-04-2118:20haywoodthe package.json points to main: cjs/index.js, and if you go to that file it’s exporting everything#2020-04-2118:21haywoodah#2020-04-2118:21haywood["react-bootstrap" :refer (Button)]#2020-04-2119:28haywoodcc @U01237PKU1Y#2020-04-2209:08Andrea RussoDid it work for you? I’m trying it but without success#2020-04-2209:11Andrea RussoIt works! Wonderful, I was sure I tried also that! Thank you very much @haywood#2020-04-2118:21haywoodyou can do [Button] too#2020-04-2119:17haywoodI need to run a process that reads files from one of my apps directories, this process creates and writes a new clojurescript file to disk, which Shadow knob should I be using? It should run during startup and on changes.#2020-04-2119:49klausharboI’m quite new to Clojurescript but have quite a bit of experience with Clojure. I’m interested in interacting with Excel using @microsoft/office-js``. I use the shadow-cljs re-frame example for experiments and modified the namespace declaration in views.clj`` to be
(ns demo.views
  (:require [demo.routes :as routes]
            [demo.subs :as subs]
            [re-frame.core :as re-frame]
            ["@microsoft/office-js" :as office]))


and get the error

[:app] Compiling ...
[:app] Build failure:
module without entry or suffix: @microsoft/office-js
…
ExceptionInfo: module without entry or suffix: @microsoft/office-js
	Clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)
	shadow.build.npm/find-package-require (npm.clj:207)
	shadow.build.npm/find-package-require (npm.clj:165)
	shadow.build.npm/find-file (npm.clj:387)
	shadow.build.npm/find-file (npm.clj:358)
	shadow.build.npm/find-resource* (npm.clj:618)
	shadow.build.npm/find-resource* (npm.clj:610)
Any hints to where I might start looking for the problem?
#2020-04-2119:53haywoodthat package looks a bit weird https://www.npmjs.com/package/@microsoft/office-js#using-the-npm-package#2020-04-2119:53haywoodit’s sorta saying you can copy the file in the dist directory to your static server, or you need to compile it yourself?#2020-04-2119:54haywoodeasiest thing to do for now would be to `
<script src="/assets/office-js/office.js"></script>
#2020-04-2119:54haywoodwhere you copy it to resources/public/js]#2020-04-2119:55haywoodand just refer to the global variable that file creates via js/office#2020-04-2119:59thhelleryeah microsoft things are very unfriendly towards packaging#2020-04-2120:00thhellerprobably best to follow their instructions#2020-04-2120:04klausharboI’ll try that - thanks#2020-04-2121:38haywoodok @thheller thanks for the tough love. I think I got what I needed by hooking into the :configure stage on startup, and then just running my own fs-watch that runs independently, so it’ll run even if shadow fails. Thanks#2020-04-2204:36Aronwhat kind of pretty printer is everyone using?#2020-04-2208:47mhuebertrandom comment to say how happy I am with shadow’s caching/invalidation approach. I had forgotten how often I used to encounter bugs related to partially compiled code, macros not recompiling properly, waiting to recompile everything after ‘clean’, etc, which had faded in my memory (until working again on some old code).#2020-04-2208:48yendaanyone tried using shadow in nixos? does it need a nixpkg like leiningen or is it just usable as a dep in the package.json of your project?#2020-04-2209:00thheller@yenda it needs java and node/npm#2020-04-2209:00thhellerleiningen is needed if you use project.clj, otherwise it works without#2020-04-2209:23yendadoes it fetch clojure jar itself when you install it with npm?#2020-04-2209:24thhellerit loads the shadow-cljs-jar npm dependency which contains an uberjar to download maven dependencies yes#2020-04-2209:41witekHello. I have a macro, which I would like to output different code, when in release build. How do I detect the release vs. development build in my macro code?#2020-04-2209:45thheller@witek you can check the :shadow.build/mode key in the macro &env, like this
(core/defmacro defonce
  "defs name to have the root value of init iff the named var has no root value,
  else init is unevaluated"
  [x init]
  (if (= :release (:shadow.build/mode &env))
    ;; release builds will never overwrite a defonce, skip DCE-unfriendly verbose code
    `(def ~x ~init)
    `(when-not (exists? ~x)
       (def ~x ~init))))
#2020-04-2211:49orestisHaving some trouble loading JS files on my classpath, as per https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js -
The required JS dependency "/js/react-fitted-image/index" is not available, it was required by "nosco/views/ideabox_copy_select_template.cljs".

Dependency Trace:
	nosco/views/main.cljs
	nosco/views/ideabox_copy_select_template.cljs
#2020-04-2211:50orestisHowever, from the same repl: (io/resource "js/react-fitted-image/index.js") returns a correct file.#2020-04-2211:52orestisNeither ["/js/react-fitted-image/index.js" :as FittedImage] nor ["/js/react-fitted-image/index" :as FittedImage] work.#2020-04-2211:56thheller@orestis it is possible that parsing errors in .js files aren't reported to the proper place. look at the server output, maybe there is something about a parse error#2020-04-2211:57orestisNothing there -> I also tried with a trivial file (literally just function foo(){ alert("hi"); }) and I get the same error.#2020-04-2211:59thhellerhmm it might be the filename? the typical - vs _ as in cljs files? not actually sure.#2020-04-2212:00thhellertry "/js/react_fitted_image/index.js" as the name?#2020-04-2212:00orestisBackground -> I want to use a stupid little react library and run into a flavor of the stupid babel regenerator runtime stuff. So I decided to just copy the thing in, it’s 100 lines of JS.#2020-04-2212:00thhellerdoes it contain JSX?#2020-04-2212:00orestis["/js/foo.js" :as foo] has the same issue, I thought of the dash vs underdash.#2020-04-2212:01orestisoh yeah, it should contain JSX, good call. But the foo.js file is just a function.#2020-04-2212:02thhellerhmm are you sure your classpath is setup correctly? I mean do you get the proper resource when using shadow-cljs clj-repl? no other tool, no nrepl, etc?#2020-04-2212:03orestis
$ shadow-cljs clj-repl
shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
> (require '[ :as io])
nil
> (io/resource "js/foo.js")
#object[.URL 0x240a2e93 "file:/Users/orestis/dev/nosco/gamma/dev-resources/js/foo.js"]
shadow.user=>
#2020-04-2212:03orestis
> (slurp (io/resource "js/foo.js"))
"var x = 1;\n"
#2020-04-2212:03thhellerdon't put these things into resources ...#2020-04-2212:03thhellerresources get filtered out#2020-04-2212:03orestisOh? I thought the classpath didn’t make any distinction?#2020-04-2212:04thhellerunfortunately shadow-cljs has to#2020-04-2212:04thhellerthere are waaaaaaaaaaaaaay to many libraries out there that contains compiled .js code as well as their sources#2020-04-2212:05thhellereven uncompiled sources .. so there might be a cljs/core.cljs file in a .jar that is not clojurescript#2020-04-2212:05orestisAre you literally looking for filenames that contain resources ? 😄#2020-04-2212:05orestisLet me just try for that foo.js thing for my curiosity#2020-04-2212:06thhellerhttps://github.com/thheller/shadow-cljs/blob/6ce4c6eb8c0d36e840cf1ee78519c8c93616b88d/src/main/shadow/build/classpath.clj#L921-L946#2020-04-2212:07thhellerI've been meaning to remove the classpath indexing shadow-cljs does#2020-04-2212:07thhellerbut it is so convenient to have sometimes that I don't really want to 😛#2020-04-2212:11Spacemanfor some reason my shadow repl isn't allowing me to require anything, although I can still require things in the project files.#2020-04-2212:11Spacemanshadow.user> (require '[tw-cljs.core :refer [tw]]) Execution error (FileNotFoundException) at shadow.user/eval76747 (form-init5445768818949264817.clj:465). Could not locate tw_cljs/core__init.class, tw_cljs/core.clj or tw_cljs/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.#2020-04-2212:11SpacemanWhy might this be?#2020-04-2212:11thhellerthat is not a CLJS REPL. that is a CLJ REPL. you can switch to the CLJS REPL by calling (shadow/repl :the-build-id)
#2020-04-2212:15orestisOK, moving the simple foo file outside to some non-resources folder seems to work. Good to know in the future.#2020-04-2212:16orestisBTW where is the guide at? I could make a quick doc PR for this#2020-04-2212:16thhelleryeah I should probably lift that restriction somewhat. doesn't really matter if you classpath is clean#2020-04-2212:16thhellershould probably just warn about bad .jar files that contain compiled code in bad places#2020-04-2214:06Spacemanhow do I run cljs tests in cider?#2020-04-2214:06SpacemanC-c C-t n doesn't work. I get clojure only operation requested in clojurescript buffer#2020-04-2214:08dpsuttonask in #cider for CIDER related things. but the automatic test runner is clj only#2020-04-2214:08Spacemanyeah wrong channel sorry#2020-04-2214:09Spacemanthere must be a way to hack cider though? I'm sure the way exists#2020-04-2215:16Spacemanwhenever I run (js/alert "foo") in the shadow repl, it breaks the repl. The repl stops working#2020-04-2215:17SpacemanWhy is this and why can't I see the output of the (js/alert "foo") in the repl?#2020-04-2215:21haywoodbtw @thheller that thing I’m working on is recreating next.js’s filesystem routing api, but natively for clojurescript, which has advantages since the source code for a page is data itself so it’s easy to extract a page routes map to configure the router (if you need). I have a basic thing working in our app now, will work on adding more features (what’s missing from next.js)#2020-04-2215:22haywoodsomething you’re aware of https://github.com/thheller/next-cljs/blob/master/src/main/shadow/next_js.clj#L27#2020-04-2215:22haywood@pshar10 if you’re in the browser repl that operation blocks everything until the alert is closed#2020-04-2215:23haywoodsame with (js/confirm "confirm or deny?")#2020-04-2215:26Spacemanso say I'm running tests and I want to compare the behavior of a component. e.g. (is (= #(js/alert "something") (:on-click (nth (my-component) 1)))How would I do that?#2020-04-2215:27Spacemanactually (is (= (js/alert "something") ((:on-click (nth (my-component) 1))))#2020-04-2215:28haywoodyou should instead assert that the passed on-click handler is called#2020-04-2215:28haywoodsince that’s essentially what you’re trying to assert, and not that js/alert works#2020-04-2215:28haywoodyou could test the resulting handler in isolation afterwards#2020-04-2215:30Spacemanwould you give an example of what you mean by asserting that the passed on-click handler is called?#2020-04-2215:31haywoodare you using any additional libraries for end to end testing#2020-04-2215:31Spacemanno, are there any good ones?#2020-04-2215:32haywoodit seems like you’re trying to simulate user actions, and make assertions about the outcomes based on the new elements displayed#2020-04-2215:32SpacemanI'm trying to do test driven development, and trying to test the front-end. I'm not sure if test driven development is useful for doing that.#2020-04-2215:34haywoodTDD is a little hard for client side code, but something like https://github.com/bhauman/devcards#2020-04-2215:34haywoodis a good translation to the workflow#2020-04-2215:34SpacemanI'm using #workspaces which is similar#2020-04-2215:34haywoodfor integration style tests against the browser I’ve used enzyme#2020-04-2215:34haywoodhttps://github.com/enzymejs/enzyme#2020-04-2215:35Spacemanhave you used it? does this make development faster?#2020-04-2215:36haywoodI have used it, the fact I don’t use it now probably says something#2020-04-2215:37haywoodmy workflow is get my editor connected to the browser repl, and then just start writing code#2020-04-2215:37haywoodlike tinkering on the workbench#2020-04-2215:37Spacemanso no test driven development? I thought it helps writing code faster?#2020-04-2215:37haywoodyou’re essentially testing your code as you go in the repl#2020-04-2215:37haywoodyea I dunno never worked for me#2020-04-2215:38haywoodwow I hadn’t heard about workspaces thanks for this!#2020-04-2216:29knubieRunning into this error on Cordova: WebSocket network error: WebSocket connection failed because it violates HTTP Strict Transport Security. I’m looking into it now, but just posting it here to see if anyone has run into this issue before? It’s preventing the hot reloading.#2020-04-2216:41thhellerjust relax your CSP? it is configured in your index.html by default and rather strict. just remove it for development?#2020-04-2218:37knubieYeah that was my first thought, but I don’t have any CSP set in the index.html#2020-04-2218:39knubieI’m thinking it might have to do with cordova-plugin-ionic-webview#2020-04-2219:27thhellerthis is about as far as I have ever used cordova and it had a CSP meta in the default html https://github.com/thheller/cordova-cljs#2020-04-2219:27thhellerdon't know more but the error you posted points towards CSP settings#2020-04-2216:59olleromoI'm trying out shadow-cljs for the first time with a new project based on Luminus. When I try to jack-in-cljs I get "Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11). missing instance". Is this an easy fix?#2020-04-2217:01thhellerdo you have shadow-cljs running?#2020-04-2217:02thhellerI do not support the way luminus has integrated shadow-cljs via lein-shadow. so you are going to have to ask the authors how this is meant to work.#2020-04-2217:02thhellerif you have it running then you might just not be connected to it properly#2020-04-2217:02thhellerbut instead conencted to the luminus server nrepl#2020-04-2217:03olleromoAh - ok. I'll look into that. Thanks 😊#2020-04-2217:40SpacemanHow can I add a js file in my shadow build process? It's a postcss.config.js file in my root directory and I want to build my shadow app with the postcss#2020-04-2217:43thhelleryou run postcss separately#2020-04-2217:44thhellerneither lein nor shadow-cljs need to know where your .css files come from. they just need to be somewhere.#2020-04-2217:49thhellerI use this for my tailwind stuff https://github.com/postcss/postcss#npm-run--cli#2020-04-2217:50DiegoHello, I've got a js file that I want to import into my app. The file starts like this:
var CodeMirror = require('codemirror/lib/codemirror')
require('codemirror/mode/javascript/javascript')
require('codemirror/addon/hint/javascript-hint')
require('codemirror/addon/hint/show-hint')
require('codemirror/addon/selection/mark-selection')
require('codemirror/addon/comment/comment')



console.log("cm",CodeMirror)
The problem is that CodeMirror is undefined. How can I import it?
#2020-04-2217:51thhellerwhats the point of that js file? why not do it directly on CLJS?#2020-04-2217:53DiegoI took it from another repo, I don't want to rewrite all the files#2020-04-2217:56thhellercan't say why it is nil, works fine for me.#2020-04-2217:57DiegoMy calling code looks a bit like this:#2020-04-2217:58thhellerI'm assuming that you mean this console.log("cm",CodeMirror) logs CodeMirror as being undefined?#2020-04-2217:58Diegoyes, and also the code that follows throws an error because of that#2020-04-2217:58Diego
(ns algoradio.core
  (:require
   [algoradio.state :refer [app-state]]
   [cljs.user :refer [spy]]
   [algoradio.archive :as archive]
   [reagent.core :as reagent]
   [algoradio.freesound :as freesound]
   [algoradio.player :as player]
   ["/hydra_editor/dist/index" :as h]))
;; more code
(comment (h/init (clj->js {:editorContainerId "editor-container"})))
#2020-04-2217:59DiegoI just found a quick and painless solution, that was building a bundle with parcel, but I wonder I am doing something wrong#2020-04-2217:59thhellerdon't know what you mean by building with parcel#2020-04-2218:00thhellerdoesn't seem like a good idea to me#2020-04-2218:00Diegothere's a bundle builder for js called parcel (kind of like webpack)#2020-04-2218:00thhellerI know parcel#2020-04-2218:00thhellerI don't know what you are using it for#2020-04-2218:00thhellerit is sort of like using parcel AND webpack in the same project#2020-04-2218:01thhellerthat doesn't seem like a thing you'd do?#2020-04-2218:03Diegoyeah, it's not good#2020-04-2218:30DiegoCould you please try this @thheller
const CodeMirror = require('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)

export default {}
#2020-04-2218:31DiegoI found that adding the export default caused the failure on my side#2020-04-2218:35Diegoin fact any use of export seems to provoke it#2020-04-2218:54SpacemanHow do I use reframe in the repl? In my project files subscribe and dispatch works, but in the connected shadow-cljs repl, the dispatches and the subscribes are all returning nil#2020-04-2218:55Spacemanalso the subscribe isn't working in my test file#2020-04-2219:24thheller@diego.vid.eco do not mix require with export. either use require with exports.foo or import and export foo. don't use commons and ESM in one file.#2020-04-2219:28DiegoThis doesn't work for me either
import CodeMirror from 'codemirror/lib/codemirror'
//const CodeMirror = require ('codemirror/lib/codemirror')
console.log("cm2", CodeMirror)
#2020-04-2219:28Diegoshould it?#2020-04-2219:29thhellerimport * as CodeMirror from ...#2020-04-2221:24Diegocool, thanks#2020-04-2221:25DiegoBTW I am really enjoying working with shadow. Awesome work!#2020-04-2219:29thhelleryou are likely better off with require#2020-04-2219:46SpacemanHow do I use reframe in the repl? In my project files subscribe and dispatch works, but in the connected shadow-cljs repl, the dispatches and the subscribes are all returning nil also the subscribe isn't working in my test file. Anybody?#2020-04-2310:33friczeshare your code on Github, or somewhere similar and post on #clojurescript#2020-04-2310:33friczeit should just work, so you probably have some problem with your code#2020-04-2219:48thheller@pshar10 please don't spam the same question repeatedly. I don't use re-frame and don't know.#2020-04-2308:53yendaI'm trying to js/require a json but I can't figure out which path the js/require is starting at, how can I find out?#2020-04-2308:56yendamhm maybe it doesn't make sense looks like I got the path right as it works for images, for instance (js/require "../resources/images/ui/welcome.jpg") works but (js/require "../resources/images/ui/fleets.json") doesn't#2020-04-2309:06SpacemanI'm unable to load the kaocha repl using (use 'kaocha.repl) in my shadow-cljs repl. I have added it in the dependencies like so:
:dependencies [[lambdaisland/kaocha "1.0-612"]]
But upon doing (use 'kaocha.repl), I get:
Error in phase :compilation
Only [lib.ns :only (names)] and optionally `:rename {from to}` specs supported in :use / :use-macros; offending spec: [kaocha.repl] at line 1 cljs/user.cljs
Why is this?
#2020-04-2310:22thhellerkaocha is not supported currently#2020-04-2310:23thhelleralso the (use 'kaocha.repl) are instructions for CLJ not CLJS#2020-04-2310:24Spaceman@thheller what's a good way to automate tests with shadow and maybe cider?#2020-04-2310:24thhellerno clue. I don't use tests in CLJS.#2020-04-2312:04SpacemanWhy not? Have you ever tried?#2020-04-2315:15thhellerjust not into testing that much. mostly do stuff with the REPL and then sometimes write a test to automate#2020-04-2311:27emil0r@thheller I’ve got a css generated from outside the directory of where I’m working using SASS. The generation works fine, but shadow-cljs does not reload. When I manually edit the generated CSS file shadow-cljs reloads. Any idea on how to solve this?#2020-04-2311:28thhelleryou mean if you edit the generated file it reloads but it doesn't reload when it is generated?#2020-04-2311:28emil0rYes#2020-04-2311:28thhellerweird, no idea#2020-04-2311:28thhellerwhat do you use to generate?#2020-04-2311:29emil0rgulp#2020-04-2311:29thhellercheck if the file last-modified timestamp is changed when that generates a new file?#2020-04-2311:30emil0rsure#2020-04-2311:31emil0rIt updates, but to two hours back in time#2020-04-2311:33thhellerhmm might be that shadow-cljs uses the wrong check?#2020-04-2311:33thhellerusually it should just check (not= last-mod prev-mod)#2020-04-2311:34thhellernot (> last-mod prev-mod)#2020-04-2311:36emil0rHmm.. seems like gulp sets the last-modified timestamp to UTC+0#2020-04-2311:37emil0rI’m currently at UTC+2#2020-04-2311:37emil0rOh well#2020-04-2311:39thhellerit should be enough if it changes, which direction it changes shouldn't matter#2020-04-2311:42thhellerhmm yeah dunno. might be something internal from the filewatcher that it doesn't like things going back in time?#2020-04-2311:42thhellershadow-cljs doesn't care#2020-04-2311:42thhellerjust teach gulp to set the correct date 😉#2020-04-2311:42emil0rIs there a trigger based on changed files?#2020-04-2311:43emil0rIe, a notify from a java api#2020-04-2311:43thhellerwhich OS do you use?#2020-04-2311:43emil0rIf so, could be that one that doesn’t report a changed file since it’s backwards in time. Ie, a previous version?#2020-04-2311:43emil0rMacOS#2020-04-2311:43emil0rhmm… shouldn’t matter though#2020-04-2311:44thhellerit does#2020-04-2311:45thhellermacos uses the hawk library to watch fs changes#2020-04-2311:45thhellerlinux/win do not#2020-04-2311:45thhellerdunno about hawk#2020-04-2311:45emil0rCoolies#2020-04-2311:52emil0r#2020-04-2311:52emil0rThat did the trick#2020-04-2311:52emil0rSo weird though#2020-04-2315:44NiclasI have a RN app with minimal shadow-cljs config and it compiles as I expect. Auto load is not working however and I’m not sure where to look, does anybody have any ideas?
# shadow-cljs.edn
{
 ...
 :builds {:dev {:target     :react-native
                :init-fn    env.main/main
                :output-dir "target/dev"
                :devtools   {:autoload true
                            :after-load my.core/print-debug-stmt}
 ...
}
#2020-04-2315:47NiclasRunning shadow-cljs v2.8.99 with npx shadow-cljs watch :dev#2020-04-2315:55thhelleris this my.core/print-debug-stmt maybe not included in the regular build?#2020-04-2315:56thhellermay need to add :preloads [my.core] into :devtools so the ns is actually compiled?#2020-04-2316:53Niclas@thheller It’s included in the regular build, it’s actually the fn that registers the root app component but I just changed names for it here 😄#2020-04-2316:53NiclasTried adding the ns to :preloads with no change#2020-04-2316:53thhellerdid you keep a reload mechanism like this one? https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L59#2020-04-2316:54thhellerreact-native is not capable of hot-reloading the root components once registered#2020-04-2316:54thhellerso the registerComponent call can only be done once#2020-04-2316:54NiclasThanks, I’ll try that out#2020-04-2317:09Niclas@thheller Unfortunately, no success#2020-04-2317:10NiclasI even tried putting (println "ABC") in the top level of my.core that’s printed only the first time the app is loaded but not after edits and recompiles#2020-04-2317:10thhellerany build warnings?#2020-04-2317:11NiclasNone to speak of#2020-04-2317:11NiclasI get this occasionalyl in the terminal, maybe it’s connected?#2020-04-2317:11Niclas
Exception in thread "async-dispatch-9" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: clojure.lang.PersistentArrayMap
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
	at clojure.core.async.impl.protocols$eval256$fn__257$G__245__262.invoke(protocols.clj:21)
...
#2020-04-2317:12NiclasWhere I’ve run npx shadow-cljs watch :dev#2020-04-2317:12thhellerah. tahts not normal#2020-04-2317:12NiclasGood! 😄#2020-04-2317:12thhellerlooks like you might have a bad core.async version?#2020-04-2317:12NiclasI’ll check it out#2020-04-2317:13Niclas[org.clojure/core.async "0.3.442"]#2020-04-2317:13thhelleryeah thats really bad#2020-04-2317:13thheller[org.clojure/core.async "1.1.587"]#2020-04-2317:13thhelleror none at all if you are just using shadow-cljs.edn#2020-04-2317:14NiclasAwesome, I’ll see if it works when I remove the dep#2020-04-2317:19NiclasNo luck there either I’m afraid#2020-04-2317:19NiclasThe crashes seem to have stopped though!#2020-04-2317:19NiclasThese are my deps
:dependencies [[binaryage/devtools "1.0.0"]
                [com.andrewmcveigh/cljs-time "0.5.2"]
                [com.cognitect/transit-cljs "0.8.256"]
                [com.rpl/specter "0.13.1"]
                [cljsjs/libphonenumber "8.10.18-0"]
                [orchestra "2017.07.04-1"]
                [expound "0.5.0"]
                [org.clojure/test.check "0.9.0" :scope "test"]
                [pjstadig/humane-test-output "0.8.1" :scope "test"]
                [re-frame "0.11.0-rc3"]
                [reagent "0.9.0-rc4" :exclusions [cljsjs/react-dom
                                                  cljsjs/react
                                                  cljsjs/react-dom-server
                                                  cljsjs/create-react-class]]
                [day8.re-frame/test "0.1.5" :scope "test"]]
#2020-04-2317:19NiclasDo you think there might be some other collission in deps?#2020-04-2317:20Niclas@thheller#2020-04-2317:20thhellerexpound is also really old#2020-04-2317:22NiclasUpdated it to latest 0.8.4 without results 😞#2020-04-2317:24thhellerdunno. what does the device log have to say? likely that it just fails to connect to the shadow-cljs server? happens if it can't find the correct IP to use?#2020-04-2317:24NiclasThat could be it, it does do the first load at least#2020-04-2317:24NiclasAnd I can see that index.js updates as expected#2020-04-2317:25NiclasAre there any shadow-cljs specific logs I could look at?#2020-04-2317:26thhellerdid you turn off the built-in react-native reloading?#2020-04-2317:27NiclasYes#2020-04-2317:30thhellerwhat do you mean by "index.js updates as expected"?#2020-04-2317:33NiclasI add a line (println "something-new") and can see that "something-new" appears in index.js 😄#2020-04-2317:34thhelleryeah .. compilation works#2020-04-2317:34thhellerthat doesn't mean that the device was able to connect to shadow-cljs#2020-04-2317:34thhellerlook at the device log#2020-04-2317:34NiclasAh, I’ll have a look#2020-04-2317:40NiclasNot getting any device logs when recompiling, do you want me to look for anything special in the logs that are printed on startup? I can’t find anything interesting but maybe I’m missing something#2020-04-2317:40thhellerit should log something like shadow-cljs - websocket connected#2020-04-2317:40thhelleror some kind of connect error#2020-04-2317:41NiclasAh! I can’t find that 😄#2020-04-2317:41NiclasNo matches for shadow#2020-04-2317:41thhellernot when compiling, when the app is first loaded#2020-04-2317:41NiclasNot printed anywhere#2020-04-2317:42NiclasOn iOS#2020-04-2317:43thhellerwere the dependencies you listed from project.clj or shadow-cljs.edn?#2020-04-2317:43NiclasFrom shadow-cljs.edn#2020-04-2317:43thhellertry shadow-cljs watch dev --verbose#2020-04-2317:44thhellerif should log the IP it is trying to connect to#2020-04-2317:44thhellermaybe thats just incorrect or taking a long time to time out#2020-04-2317:45NiclasIt does log Using IP: 192.168.1.208#2020-04-2317:46thhellerand is that the correct one?#2020-04-2317:46NiclasThat is my IP on the local network, is that what’s correct?#2020-04-2317:46thhellerI mean can you open http://192.168.1.208:9630 on your device browser?#2020-04-2317:47thhellerif your phone is on that same network yes#2020-04-2317:47NiclasI’m running on simulator atm#2020-04-2317:47NiclasThis is what I see#2020-04-2317:48thhelleryeah thats fine#2020-04-2317:48thhellerthen I really don't know#2020-04-2317:48thhellerthe first thing this should be doing is connect to the shadow-cljs websocket#2020-04-2317:48thhellerwithout that connection it won't know what it should reload etc#2020-04-2317:48NiclasSimulator can reach it too#2020-04-2317:49thhellerI don't do react-native myself so you'll have to figure this out on your own#2020-04-2317:49NiclasBummer, but thanks for the help!#2020-04-2317:49NiclasThis project has been running on for almost 4 years now so there’s likely a bunch of old dependencies and setup that might get in the way#2020-04-2317:50NiclasWas really stoked though to switch from figwheel to shadow though 😄#2020-04-2316:13Patrick TruongHello everyone, I’m new to shadow-cljs and ClojureScript. I was curious if there is a command that audits your dependencies for new available releases, and if there’s a command to update dependencies as well? Thanks for all the help!#2020-04-2316:13thhellerthere is not (yet) a command for that no if you are using shadow-cljs.edn only. lein or deps.edn have options for that.#2020-04-2316:19Dereknpx npm-check -u for npm deps#2020-04-2316:19Derekhttps://github.com/Olical/depot for clj(s) deps#2020-04-2316:19Derekif you’re using deps.edn#2020-04-2316:19Dereklein-ancient if lein#2020-04-2316:51Patrick TruongQuestion for anybody who uses cljs-devtools (https://github.com/binaryage/cljs-devtools) I just added it to my basic reagent/re-frame project deps.edn
{:paths ["src"]
 :deps  {thheller/shadow-cljs {:mvn/version "2.8.94"}
         binaryage/devtools   {:mvn/version "1.0.0"}
         reagent              {:mvn/version "0.10.0"}
         re-frame             {:mvn/version "0.12.0"}}}
shadow-cljs.edn
{:deps   true
 :builds {:app {:target     :browser
                :output-dir "public/out"
                :modules    {:app {:entries []
                                   :init-fn 
                :devtools   {:http-root "public"
                             :http-port 8020}}}}
and now I’m getting a bunch of console warnings along with my page no longer rendering
failed to load shadow.module.app.append.js TypeError: alpha_journal.app.render is not a function
    at Object.alpha_journal$app$main [as main] (:8020/js/cljs-runtime/alpha_journal.app.js:15)
    at eval (:8020/js/cljs-runtime/shadow.module.app.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:836)
    at Object.env.evalLoad (app.js:2224)
    at app.js:2414
DevTools failed to parse SourceMap: 
...
I was following the cljs-devtools example (https://github.com/binaryage/cljs-devtools/tree/master/examples/shadow) for shadow-cljs and it seems like I didn’t need to explicitly set a :preloads or anything. Thanks for any help 🙂
#2020-04-2316:52thhellercheck the first error? alpha_journal.app.render is not a function this is likely the result of something else failing before it#2020-04-2316:56Patrick Truong@thheller :face_palm: thanks, accidentally slurped my render function into another function. That fixed my rendering issue, but now I’m still getting the sourcemap parsing failures:
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
...
I didn’t explicitly require any DevTools package in my main file. Is that a possible problem? app.cljs
(ns 
  (:require
   [reagent.core :as r]
   [reagent.dom :as dom]))
#2020-04-2316:57thhellerno you shouldn't have a direct require for it anywhere. thats already taken care of just by including it in your dependencies#2020-04-2316:57thhelleris the path correct? I mean what do you get when you open http://localhost:8020/js/cljs-runtime/goog.debug.error.js.map manually?#2020-04-2316:59Patrick TruongI get a blank page and console output as:
Failed to load resource: the server responded with a status of 404 (Not Found)
app.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
app.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
DevTools failed to parse SourceMap: 
DevTools failed to parse SourceMap: 
#2020-04-2317:03thhellerso its not the correct path?#2020-04-2317:03thhellerwhere is your output?#2020-04-2317:06Patrick TruongSorry I’m a bit lost on the path situation. I’m seeing my page render on http://localhost:8020/, but if I follow the sourcemap warning link (ex. http://localhost:8020/js/cljs-runtime/goog.async.workqueue.js.map) I get a blank page and in the console, I get that output that I wrote above#2020-04-2317:07thhellerwhat is your :output-dir? what is your :asset-path? what is the path you are loading your JS from in your HTML?#2020-04-2317:09Patrick TruongHmm don’t believe I have those explicitly set. This is my shadow-cljs.edn
{:deps   true
 :builds {:app {:target     :browser
                :output-dir "public/out"
                :modules    {:app {:entries []
                                   :init-fn 
                :devtools   {:http-root "public"
                             :http-port 8020}}}}
and my index page is loading from <script _src_="out/app.js" _type_="text/javascript"></script> which I believe is correct
#2020-04-2317:09thhellerso you need to add :asset-path "/out" (right after :output-dir) since that defaults to /js#2020-04-2317:10thhelleryou can skip :entries [] since :init-fn already implies that#2020-04-2317:13Patrick TruongAwesome, so if I understand correctly, when I have a custom :output-dir I should remember to set my :asset-path (otherwise it uses the default path which is wrong) That seemed to clear up most of my sourcemap warnings. I just have a preload and postload warning?#2020-04-2317:14thhellerdon't know what those are? are you working on a browser extension? those errors come from a browser extension?#2020-04-2317:16Patrick TruongGot it. Turned out Adblocker causes those warnings. If anyone else runs into the same thing, I just removed my adblocker extension.#2020-04-2317:17Patrick Truong@thheller thanks for all the help! Much appreciated 🙂 I was curious though if you could elaborate a bit on what :entries does. Some of the config keys have been confusing me since I’ve been following a lot of tutorials and examples but a lot of them have very different config layouts in their shadow-cljs.edn. Thanks!#2020-04-2317:19thhellerentries is the namespaces that should be included in the module (your build basically)#2020-04-2317:19thheller:init-fn basically is sugar for :entries [] and calling the main fn on load#2020-04-2317:20thhelleryou can keep it but it is redundant#2020-04-2317:20Patrick TruongAwesome, thanks for the clarification. Helps a lot#2020-04-2317:49Andrea Russois there a way to import a cljs library from a github repo instead of a maven repo? I need to patch the https://github.com/ckirkendall/kioo library#2020-04-2317:52lilactownif you use deps.edn, it’s fairly easy#2020-04-2317:52lilactownrequires moving your dependencies from shadow-cljs.edn to a deps.edn#2020-04-2317:52lilactownalternatively, you can copy + paste the kioo source files into your project#2020-04-2317:52lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2020-04-2317:53thheller@lilactown deps.edn won't work. the lib has no deps.edn.#2020-04-2317:55lilactownyou’re right, I didn’t think of that. if they’re forking it anyway, it’s easy to add one#2020-04-2319:25thhellertrue#2020-04-2320:43Andrea RussoI use lein project.clj and shadow-cljs.edn#2020-04-2408:28rbergerHaving a weird problem with the latest aws-amplify npm library (3.0.8). They seem to have done a major re-org of it and the latest version causes the following error when shadow-cljs trys to build a simple program that uses aws-amplify and aws-amplify-react:
[:app] Build failure:
The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js".
#2020-04-2408:29rbergerIf I roll back to the pre 3.x.x version I don’t have that error.#2020-04-2408:30thhellerwhat build :target is this?#2020-04-2408:31rberger:browser#2020-04-2408:31thhellerwhy is that include a package that looks like it is meant for node?#2020-04-2408:32thheller@aws-sdk/node-http-handler?#2020-04-2408:32rbergerI don’t know.#2020-04-2408:32rbergerIt does look like http2 is a node thing not an npm package#2020-04-2408:33thhellerupgrade shadow-cljs. that now includes a dependency trace to see who ended up including that package#2020-04-2408:33thhelleryes http2 is a node built-in package#2020-04-2408:34rbergerGo to 2.8.99? I’m running 2.8.96#2020-04-2408:34thheller.100#2020-04-2408:35thhellerthe trace I added in .99#2020-04-2408:36rbergerTrying#2020-04-2408:37rberger
The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js".

Dependency Trace:
	omnyway/mock_checkout_page/core.cljs
	node_modules/@aws-amplify/core/lib/index.js
	node_modules/@aws-amplify/core/lib/Credentials.js
	node_modules/@aws-sdk/credential-provider-cognito-identity/dist/cjs/index.js
	node_modules/@aws-sdk/credential-provider-cognito-identity/dist/cjs/fromCognitoIdentity.js
	node_modules/@aws-sdk/client-cognito-identity/dist/cjs/index.js
	node_modules/@aws-sdk/client-cognito-identity/dist/cjs/CognitoIdentityClient.js
	node_modules/@aws-sdk/client-cognito-identity/dist/cjs/runtimeConfig.js
	node_modules/@aws-sdk/node-http-handler/build/index.js
	node_modules/@aws-sdk/node-http-handler/build/node-http2-handler.js
#2020-04-2408:38thhellerhmm yeah looks deeply nested#2020-04-2408:38rbergerIts probably like a handler for accessing AWS APIs#2020-04-2408:39rbergerThe “modularized” their sdk in version 3.#2020-04-2408:39thhellerdunno why its including node though. maybe the package now needs custom build steps?#2020-04-2408:39thhellerI don't know much about any of this AWS stuff but this looks like it would be node server-side stuff#2020-04-2408:40rbergerThis is supposed to be a client library#2020-04-2408:43rbergerOk, well I asked on their github discussion about it. I’ll see if anyone gives me any clues. But googling for this error finds nothing so I suspect there is some interaction with shadow-cljs and their new implementation. I don’t know how many folks are using the latest amplify-sdk and shadow-cljs.#2020-04-2408:44thhellerwhich package do you actually require in your code?#2020-04-2408:45rbergerThis is what I have in my requre:
["@aws-amplify/core" :default Amplify :as amp]
   ["aws-amplify-react" :refer (withAuthenticator)]
   ["/aws-exports.js" :default aws-exports]
#2020-04-2408:50thhellerno time to look into this further right now. you can try :js-options {:resolve {"http2" false}} in your build config#2020-04-2408:50thhellerthat will make the http2 require just return an empty package#2020-04-2408:50thhellerbut it looks to me like all of this shouldn't be loaded at all#2020-04-2408:51rbergerAppreciate your help! We’ll see if I can get anyone at AWS to give some insight#2020-04-2408:58rbergerLooks like :js-options {:resolve {"http2" false}}`` Did the trick!#2020-04-2409:00rbergerThanks again! I sometimes wonder if you are a AI! 😆#2020-04-2411:18yendaanyone here using a linter along with a shadow-cljs project such as zprint or cljfmt? how did you set it up (native image? calling it manually or scripted?)#2020-04-2416:19dntnSo I have a project that builds using shadow-cljs and one of the dependencies I include is a react component from NPM that includes its own assets that is itself bundled with (using rollup.js). For example, that package has some code like:
const img = require('my-image.jpg')
// then, later
<image src={img} />
But when build my shadow-cljs project, in the browser, I get:
 Failed to load app.views.js Module not provided: ./my-image.png
if I include the package with (:require '[my-npm-package]) Some thoughts from a colleague who has looked into this a bit more: > I have a shadow-cljs question for anyone who has worked with it. It seems to do some translation of commonJS's `require` with npm modules, but how do I get it to do the same with relative imports internal to those modules? > That is, it correctly figures out how to load npm modules so that e.g. `(:require '[react])` is equivalent to `require("react")` in plain old javascript. However, I'm working with a module that internally does a `require('./logo.png')`. > Now, `logo.png` is present in the distributed npm package (it sits right next to the js file in question inside `node_modules`) but shadow-cljs cannot figure out how to load it! > ... > I think the issue might just be that shadow-cljs is not intended to be a full asset bundler like webpack. > Other projects are using webpack which is loading (and inlining) the image as a data URI; however your shadow-cljs is not. Let me know if anything isn't clear and I appreciate any insights! 🙂
#2020-04-2416:45thhellershadow-cljs has no support for including images that way#2020-04-2416:49dntnThanks for the confirmation.#2020-04-2417:28dntn@U05224H0W can you speak to whether this is something that shadow-cljs could support in the future (i.e., is within what you consider the scope of shadow-cljs or should it be considered as an external extension as alluded in the CONTRIBUTING doc on github) and, if so, the level of effort it might take? For example, would it be reasonable for me to submit an issue for this on github? Could it possibly be realistic for a new contributor to implement this kind of functionality? I've read https://github.com/thheller/shadow-cljs/blob/master/CONTRIBUTING.md but want to make sure I don't clutter the issues unnecessarily.#2020-04-2417:36thhellershadow-cljs probably will never support this directly. you could do this as a secondary plugin or build hook if you wanted. you don't really need to do anything in shadow-cljs to support this. half of it you can probably do with just a macro#2020-04-2417:37thhellerbut enough people keep asking that I may reconsider my position on this#2020-04-2416:56jplazaHow to know and change the CLJS version used in the project?#2020-04-2417:18thhellerdon't. I recommend sticking with the version shadow-cljs depends on.#2020-04-2417:59p-himikWill the new CLJS release of 1.10.741 (namely, the JavaScript Bundler Support) affect anything w.r.t. shadow-cljs? If so, what can we expect?#2020-04-2419:50thheller@p-himik no change or impact whatsoever. shadow-cljs already does way more than that so doesn't need any of the newly added stuff.#2020-04-2507:43Michaël SalihiNot even for React Native with the new bundle target ?#2020-04-2507:45thhellernope#2020-04-2507:46thhellerall the stuff the :bundle enables (and more) has already been supported for years by shadow-cljs#2020-04-2507:47thhellerI even think :bundle is a bad idea for the reasons I listed here https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html#2020-04-2507:52Michaël SalihiOK I will re-read your post about this, thx. I thought it had changed and that it was no longer relevant.#2020-04-2507:53thhellernothing changed no. it is fine to use webpack if you want and I'll document how you can do that with shadow-cljs#2020-04-2507:54thhellerbut I still don't recommend it and it won't become the default#2020-04-2506:54thheller@rberger your http2 problem also popped up in a stackoverflow question. it appears this is a bug in shadow-cljs. the aws package is using browser overrides in a way I thought weren't allowed but I guess they are. will look into fixing that soon.#2020-04-2507:02thhellerhttps://github.com/thheller/shadow-cljs/issues/689#2020-04-2512:07SpacemanI have a problem with shadow-cljs:
repl/invoke error SyntaxError: Unexpected token '.'
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (browser.cljs:184)
    at eval (browser.cljs:187)
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (env.cljs:117)
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (browser.cljs:187)
    at shadow$cljs$devtools$client$browser$handle_message (browser.cljs:240)
    at eval (env.cljs:196)
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (env.cljs:184)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (env.cljs:197)
    at WebSocket.eval (browser.cljs:340)
shadow$cljs$devtools$client$browser$repl_error	@	browser.cljs:173
shadow$cljs$devtools$client$env$repl_call	@	env.cljs:138
shadow$cljs$devtools$client$browser$repl_invoke	@	browser.cljs:187
shadow$cljs$devtools$client$browser$handle_message	@	browser.cljs:240
eval	@	env.cljs:196
shadow$cljs$devtools$client$env$process_next_BANG_	@	env.cljs:184
shadow$cljs$devtools$client$env$process_ws_msg	@	env.cljs:197
eval	@	browser.cljs:340
This error sometimes occurs when I attempt to load a function in cider, and I find it hard to reach the underlying problem.
#2020-04-2512:08thhellerwell what did you eval?#2020-04-2512:08SpacemanProbably not helpful:
(deftest cart-show-on-click-test
  (db-refresh)
  (user/click-cart-btn)
  (is @sub/cart-shown?)
  )
#2020-04-2512:09thhelleryou can check the browser network tab#2020-04-2512:09thhellerthe websocket connection#2020-04-2512:09thhellerthat will contain the message with the code that was eventually eval'd#2020-04-2512:09thhellerwould help to have that. seems like it may have generated some bad code?#2020-04-2512:12SpacemanWhere is the message and code in the network tab?#2020-04-2512:14thhellernetwork tab, filter WS, should be one. then click "messages", there should be multiple#2020-04-2512:15thheller#2020-04-2512:16thhellerthere should be a :type :repl/invoke message
#2020-04-2512:17thhellerwhite background is messages coming from the server so would be one of those#2020-04-2512:19SpacemanI see the error message. How do I find the code generated when the function is evaluated?#2020-04-2512:19thhellerthe message containing :repl/invoke will also have a :js key#2020-04-2512:19thhellerthats the code#2020-04-2512:22SpacemanThanks. I know the underlying problem now.#2020-04-2512:23thhellerand what would that be? 😛#2020-04-2512:25SpacemanI had showed you a truncated version of the deftest. The original deftest uses an undefined function. It would be better if shadow can make undefined-kind errors explicit.#2020-04-2512:27thhellerI don't know how you got it to generate invalid code#2020-04-2512:28thhellerusing undefined things should generate warnings and fail with a different kind of error as well#2020-04-2512:29SpacemanNote that the function was defined before and the deftest was fine then.#2020-04-2512:30thhellerI don't have enough information so if you want to share the actual code and the actual generated bad code I can take a look#2020-04-2512:44SpacemanThat map contains a msg key whose value says:
Use of undeclared Var dom/img-id
How about the msg key's value were shown in the console directly?
#2020-04-2512:45thhellerit should be. your editor might just not be showing it. mine does.#2020-04-2512:46thheller
cljs.user=> (+ 1 foo)
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:6
 Use of undeclared Var cljs.user/foo
--------------------------------------------------------------------------------
##NaN
#2020-04-2512:47SpacemanOh, I didn't know that the message shows in the repl. How about it were shown in the browser console too?#2020-04-2512:50SpacemanBy the way, I have required the dom namespace but using dom/img-id gives that dom is not defined.#2020-04-2512:52thhellerplease be more precise in the reporting of stuff you did#2020-04-2512:52thheller"I have required dom" does not mean anything to me#2020-04-2512:53SpacemanSorry, I meant I have this
(:require [vendo.workspaces.dom :as dom])
But
dom/img-id
in this namespace gives:
dom is undefined
#2020-04-2512:56thhellerbecause if you do this at the REPL (:require [vendo.workspaces.dom :as dom]) you are literally doing a keyword lookup of the vector#2020-04-2512:56thhellerthis is not how you do a require in the REPL#2020-04-2512:57thhellerthat require form is only valid inside of ns#2020-04-2512:57thhellerotherwise at the REPL you do (require '[vendo.workspaces.dom :as dom])#2020-04-2512:57SpacemanThis is in a file#2020-04-2512:58thhellerI really want to help you but you are making this incredibly difficult#2020-04-2512:58thhellerevery time you ask something and post a small snippet of code and I never get the full picture#2020-04-2512:58thhellerit is in a file where?#2020-04-2512:58thhellerin the ns?#2020-04-2512:58thhellerdid you eval that ns?#2020-04-2512:58thheller...#2020-04-2512:59SpacemanYes it's in the namespace. Yes, I eval'd the namespaces#2020-04-2513:01SpacemanNow I get REPL command timed out#2020-04-2513:01thhellerand in your REPL you are in that namespace? not cljs.user?#2020-04-2513:02SpacemanI'm in cljs.user#2020-04-2513:03SpacemanAnd the keybinding for switching the repl to the current buffer's namespace isn't working anymore.#2020-04-2513:07thhellermaybe restart the REPL ... it could have gotten confused by too many errors#2020-04-2513:07SpacemanYes, after restarting, I could change the repl's namespace to the namespace where I'm using dom, but the error persists#2020-04-2513:08SpacemanNow suddenly it doesn't 🙂#2020-04-2513:08thhellerdid you require or eval the ns before trying to switch to it?#2020-04-2513:09SpacemanI meant, now the error is gone. Problem solved.#2020-04-2513:09SpacemanThanks for your help#2020-04-2512:30thhellerotherwise you are on your own#2020-04-2513:25dazldhey @thheller - do you have a WIP branch somewhere with yesterday's CLJS release? wondering if it fixes a couple of inference warnings we've been seeing#2020-04-2513:25dazldjust wondering, not a biggie 😉#2020-04-2513:25thhellerhmm?#2020-04-2513:26thhellerI released 2.8.102 with the new CLJS version if that is what you are asking?#2020-04-2513:26dazldoh, awesome, thank you for quick work!#2020-04-2513:26dazldwill take it for a spin#2020-04-2513:30thhellercurious about the inference warnings you are seeing though?#2020-04-2513:36dazldit was on the protocols - one moment#2020-04-2513:36dazldhttps://github.com/dazld/cljs-protocol-inference-warning#2020-04-2513:36dazldapparently this was fixed on this release, going to try it out#2020-04-2513:37thhellerhmm did you have this issue in shadow-cljs? I fixed that years ago for this case?#2020-04-2513:38thhelleror at least I thought I did#2020-04-2513:41dazldthink it's just in the advanced builds#2020-04-2513:42dazldthere was something funky and stateful going on too#2020-04-2513:42dazldthe warning would pop up on first build, but on subsequent builds it wouldn't appear - not a shadow thing this, afaict#2020-04-2514:00dazldsadly not.#2020-04-2514:01dazldI've updated the repro case 😞#2020-04-2518:38Spacemanhas anyone used jest with clojurescript? How did you install it? After I install it using npm install jest and add "test":"jest" in package.json, I expect keywords like "expect" to work:
(.toBeInTheDocument (expect (.getByText screen "Some Component")))
But I get that expect is undefined. js/expect gives undefined as well. How to get jest to work with clojurescript?
#2020-04-2519:01Patrick TruongRandom shadow-cljs background question: what does ana stand for? That is the folder that stores all the Clojure dependencies. Thanks for entertaining my curiosity 🙂#2020-04-2519:02lilactownanalyzer would be my guess#2020-04-2519:40thhelleryeah thats the analyzer cache#2020-04-2519:41thheller@pshar10 jest is not compatible. it expects to process and rewrite the JS files directly but doesn't understand the CLJS output format#2020-04-2519:50Spaceman@thheller how about this library? Its src is in typescript though. Do you think this can be used?#2020-04-2519:55SpacemanI tried it but it didn't work though. Is it because it's .ts and not .js?#2020-04-2519:57thheller"this library"?#2020-04-2520:02SpacemanSorry, the link: https://github.com/agilgur5/jest-without-globals#2020-04-2520:07thhellerthats fake ... it just moves the globals to a secondary namespace#2020-04-2520:07thhellerso the globals are here https://github.com/agilgur5/jest-without-globals/blob/master/src/index.ts#2020-04-2520:07thhellerit doesn't change how jest functions. its not gonna work with CLJS#2020-04-2523:48Spacemanhow to separate production and development environment variables in shadow-cljs?#2020-04-2523:49SpacemanSomething that works similarly to having an :uberjar map and a :dev map in the project.clj for clojure, and then specifying the source paths for each?#2020-04-2601:15wilkerluciohello, I'm trying to add electron-updater to an app, but when the app starts I see this error shadow.js.shim.module$electron_updater.AppUpdater.checkForUpdatesAndNotify is not a function#2020-04-2601:15wilkerluciois shadow addimg some shim around electron_updater?#2020-04-2606:59thhellershadow.js.shim.module$electron_updater = require("electron-updater"); is basically what it does#2020-04-2606:59thhellerso the function just doesn't exist on AppUpdater. maybe you need to instantiate it?#2020-04-2601:27sergey.shvetsNot sure, but have you tried to hint that this is ^js like in this part of the doc: https://shadow-cljs.github.io/docs/UsersGuide.html#externs? If you do that it shouldn't rename that function during compilation.#2020-04-2603:47DiegoIs there a way to require data from a .edn file?#2020-04-2607:00thhellersee https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2020-04-2603:47Diegokind of when in webpack one can import a .json file?#2020-04-2603:56radiousHi! I need some help, I'm new to shadow-cljs and unfamiliar with the larger JS/node ecosystem. I'm trying to import a npm package using shadow-cljs (the package is called ipfs) and use it in a browser app (:target is :browser). However, the compilation fails on the "crypto" package. ("The required JS dependency "crypto" is not available, it was required by "node_modules/nanoid/index.cjs".). From what I understand, crypto is something provided by node.js and not normally available in browsers. Does it mean that I need to use some kind of packer (like browserify or webpack) or can I somehow configure shadow-cljs to help me with that?#2020-04-2607:01thhellerinstall shadow-cljs in the project itself. that will bring in a few polyfills for packages like those#2020-04-2607:01thhellerbut it also just might be that the package you are trying to use isn't compatible with the browser at all#2020-05-0105:42radiousThanks! I do have shadow-cljs installed locally both. I tried both with --save and --save-dev (dunno if there's a difference). I didn't manage to get it working though. I'll stick to the CDN version and if I ever get deeper into this project, I might check what does webpack do differently. Regardless of that, thanks for shadow-cljs!#2020-04-2604:19radiousOh, I can override it via :resolve in in :js-options. Is this how it's commonly done? Do I need to manually craft them for every node module?#2020-04-2604:54radiousOr should I just stop the fight and use a packed version of the library from CDN?#2020-04-2605:35Spacemanis there a react-native framework or template for shadow like re-natal is for Figwheel?#2020-04-2606:42Ahmed Hassan
;; shadow-cljs.edn in project
{:deps {:aliases [:cljs]}}

;; ~/.shadow-cljs/config.edn
{:deps-aliases [:cider]}
What's difference between using :deps and :deps-aliases ?
#2020-04-2607:02thheller@ahmed1hsn the difference is that :deps-aliases allies to all projects and thus uses a different name#2020-04-2607:05thheller@pshar10 I only made a couple examples for RN, otherwise you just use shadow-cljs. nothing more specific for RN really. https://github.com/thheller/reagent-expo https://github.com/thheller/reagent-react-native#2020-04-2608:27SpacemanSometimes when loading a function, I get the following error in the repl:
no source by provide: myapp.workspaces.dom
{:provide myapp.workspaces.dom}
ExceptionInfo: no source by provide: myapp.workspaces.dom
	shadow.build.data/get-source-id-by-provide (data.clj:184)
	shadow.build.data/get-source-id-by-provide (data.clj:181)
	shadow.build.data/get-source-by-provide (data.clj:187)
	shadow.build.data/get-source-by-provide (data.clj:186)
	shadow.cljs.repl/repl-compile/fn--37359/fn--37360 (repl.clj:453)
	shadow.cljs.repl/repl-compile/fn--37359 (repl.clj:429)
	shadow.cljs.repl/repl-compile (repl.clj:427)
	shadow.cljs.repl/repl-compile (repl.clj:424)
	shadow.cljs.repl/process-read-result (repl.clj:515)
	shadow.cljs.repl/process-read-result (repl.clj:491)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:859)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:813)
	shadow.cljs.devtools.server.worker.impl/eval38290/fn--38291 (impl.clj:894)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823/fn--37831 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--37822 (util.clj:257)
	java.lang.Thread.run (Thread.java:748)
And the only way out is to quit the repl and start it again. Why would this be?
#2020-04-2608:30thheller@pshar10 "Sometimes when loading a function" no clue what you mean by that#2020-04-2608:36SpacemanI mean evaluating a function in cider or the repl directly gives this error.#2020-04-2608:37SpacemanI don't know what causes it though.#2020-04-2608:37SpacemanThe error gives no context#2020-04-2608:39thhelleryeah I'll improve that error#2020-04-2608:48thheller@pshar10 which shadow-cljs do you use? your stacktrace doesn't line up with my code at all? seems like its a rather old version?#2020-04-2610:03Spacemanit's 2.8.102#2020-04-2610:04thhellerplease open shadow-cljs clj-repl and try ( "shadow/cljs/repl.clj") and post the result#2020-04-2610:04thhellerit is very strange that your line numbers do not line up with the actual code#2020-04-2610:15SpacemanThis way it actually shows a different version:
( "shadow/cljs/repl.clj")
#object[.URL 0xfee791d "jar:file:/private/var/root/.m2/repository/thheller/shadow-cljs/2.8.93/shadow-cljs-2.8.93.jar!/shadow/cljs/repl.clj"]
#2020-04-2610:15SpacemanWhy would this be?#2020-04-2610:16thhellerI guess you are using leiningen or deps.edn?#2020-04-2610:16Spacemanyes#2020-04-2610:16thhellerthen you have the old version in there#2020-04-2610:16thhellerthe npm version is only for the command line stuff#2020-04-2610:17Spacemangotcha thanks#2020-04-2613:08Chris McCormickis there a way to cause shadow-cljs's debug mode console to show a value? i am trying to debug on a platform without console access.#2020-04-2613:26thheller@chris358 "debug mode console"? you mean inspect?#2020-04-2623:24Chris McCormicki mean the text which shows up at the bottom of the window when you have e.g. an undefined symbol in your code at compile time. i wanted to mis-use this to quickly display some value at runtime instead of doing js/alert but i should probably just install proper tooling instead. or just a pre tag facepalm sorry it was late.#2020-04-2623:45Chris McCormickyes, inspect is what i need. WOW.#2020-04-2613:56pezI can't evaluate things in Calva's :node-library , atm. The nrepl load-file op works, but not eval. It never returns. This happened w/o me upgrading shadow-cljs, which was still on 2.8.77. Using .102 makes no difference. The only thing I think has changed is my node version, which is now v12.13.0. Could that be the issue?#2020-04-2613:58thhellerI don't know? works fine for me. any logs of the shadow-cljs server side maybe?#2020-04-2613:59thhellerI also released .103 earlier which should log REPL errors more visibly#2020-04-2614:12pezIt seems that if I restart the extension host (within where my library runs) and then connect the repl again, things start to work. I can live with that, but a bit strange that it started happening. Will use .103, and see if it says something more about the condition.#2020-04-2614:13pezNo matching version found for #2020-04-2614:29thhelleroh sry. forgot to push the npm package. should be available now.#2020-04-2614:33thheller@pshar10 you might also want to upgrade to 2.8.103. at least the errors should log more info now. hopefully that makes figuring out what is happening easier for me. Its just a raw data dump so I don't expect anyone to make sense of it, just report it.#2020-04-2614:41bru@thheller FYI as of 2.8.102 something broke my (admittedly very unconventional) environment: I was loading a WebAssembly module, and I now see that the (automatically generated) js loader file does a require("fs"), making shadow-cljs complain with The required JS dependency "fs" is not available I reverted to 2.8.101 and everything started working again 🙂#2020-04-2614:42thhellercare to share which package that is?#2020-04-2614:42thhellerI didn't really change any of the polyfill behavior? so as long as you have shadow-cljs in the project it should find fs just fine?#2020-04-2614:45bruthat’s what I thought. I looked at the commits in .102 and couldn’t find the reason for it starting to complain at that point. Btw I can’t share that package as it’s proprietary, but I can try to create a minimal project that replicates the error. What’s the easiest way to setup a shadow-cljs project these days? (My codebase is 2 years old 🙂 )#2020-04-2614:45thhellernpx create-cljs-project foo#2020-04-2614:45brucool, that’ll be a useful exercise#2020-04-2614:46thhellerI only really need the package.json. if its just a blank require("fs") in the source file then only package.json can modify what that would do#2020-04-2614:46bruah that’s pretty basic, I don’t think there’s anything specific in there, let me check#2020-04-2614:47thhelleralongside your own build config of course#2020-04-2614:52bru@thheller I’m preparing a gist with package.json & shadow-cljs.edn, bear with me#2020-04-2615:01bru@thheller https://gist.github.com/bru/04bc81d623fd0de6854f2a3af5f9681b#2020-04-2615:13thheller@bru I didn't mean your package.json, I meant the package.json of the package that contains the require("fs")#2020-04-2615:14thhelleroh wait it isn't a package at all?#2020-04-2615:14bru@thheller ups, gotcha. It doesn’t have one at the moment, it’s a legacy C++ app that’s being converted to a wasm module#2020-04-2615:14thhellerhmm weird, dunno how this is affected then?#2020-04-2615:15brueh, no idea. let me try to create that minimal shadow-cljs project, it will definitely be easier to debug a simpler setup#2020-04-2615:16thhellerjust to check. you do have shadow-cljs IN THE PROJECT and not globally?#2020-04-2615:17thhellerhmm actually nevermind#2020-04-2615:17bruit’s in the project, yes#2020-04-2615:17thhellerlet me test something#2020-04-2615:17brusure, I’m carrying on with my refresher on how to setup a project in shadow 🙂#2020-04-2615:53Lucy WangMy project depends on a js lib, say "foo", and I have cloned that repo locally. Is it possible to tell shadow-cljs to auto reload it when I modify the source of foo?#2020-04-2615:54Lucy WangI have tried "yarn link" but shadow-cljs seems not compatible with it#2020-04-2615:54Lucy Wang
{:tag :shadow.build.npm/missing-entries, :entries ["dist/index.js"], :package-dir #object[.File 0x69de6ee "/src/project-mine/node_modules/foo"]}
ExceptionInfo: package in /src/project-my/node_modules/foo specified entries but they were all missing
#2020-04-2615:54thheller@wxitb2017 shadow-cljs no longer auto-reloads changes in node_modules if individual files are modified but it should recompiled if the package.json of that package is modified#2020-04-2615:55thhellerso you can touch node_modules/foo/package.json#2020-04-2615:55thhellerwell does the /src/project-my/node_modules/foo/dist/index.js exist?#2020-04-2615:55Lucy Wangit exists if I install it normally, but not when I use yarn link#2020-04-2615:55thhellerif you just clone a package and not build it the files may just be missing#2020-04-2615:56Lucy Wangahhh#2020-04-2615:56thhellermost packages will have a build step they do before publishing#2020-04-2615:56Lucy Wangtotally makes sense#2020-04-2615:58Lucy Wangjust tried, it works. Thx a ton @thheller!#2020-04-2617:06Lucy WangAnyone experienced shadow-cljs interferencing with input methods? I have a form input field in my react application, and as long as I add some println functions in my on-change function, after typing a char the input method would be automatically switched back from Chinese to system default (English)#2020-04-2617:07Lucy WangAnd 1. if I disconnect the browser from the repl - the problem magically disappears 2. reproducible on both chrome/ff/safari 3. only println would cause this problem, OTOH js/console.log is fine#2020-04-2617:12Lucy Wangreworded ☝️#2020-04-2617:54Lucy Wangnvm - turned out to be a bug os my system config#2020-04-2620:12bru@thheller here’s the minimal project I promised -> https://github.com/bru/minimal-wasm-shadow-cljs#2020-04-2623:25Chris McCormickthanks for sharing this!#2020-04-2700:26papachanwow ! interesting !#2020-04-2620:13thhellerthx#2020-04-2620:38thhellerthe glue code this generates is still horrible 😛#2020-04-2620:39thhellerbut doesn't have anything to do with this particular problem. I just messed up a boolean statement 😛#2020-04-2620:42bruI know, it wasn’t meant to be pretty, just straight to the point 😄#2020-04-2620:42bruor, actually, demonstrate all the steps I need to take in the mothership project 😊#2020-04-2620:43thhellerI'm surprised this actually runs to be honest 🙂#2020-04-2620:43thhellershould be fine again in 2.8.104#2020-04-2620:44bruI was too. It is very brittle though, I really don’t like having to keep babel in the picture for example#2020-04-2620:45thhellercan you just add all the generated files to the repo?#2020-04-2620:45thhellerI don't have any of the wasm related tools#2020-04-2620:47bru@thheller those are already in place. You don’t really need to care about the last part of the setup (that’s just if you want to modify the C source).#2020-04-2620:47bruuhm hang on, maybe I gitignored them#2020-04-2620:47bruone sec#2020-04-2620:47thhelleryeah the .wasm file is missing at least#2020-04-2620:50bru@thheller added now, in /resources/wasm. I’m also writing a build script to simplify the setup#2020-04-2620:54thhellerdon't bother 😛#2020-04-2620:55thhellerhmm why the babel stuff though?#2020-04-2620:58brutoo late, pushed 😉 babel was the easiest way I found to massage the js files to please the google closure compiler. Honestly for this minimal project it’s overkill, but as said I wanted to replicate the setup of the original one#2020-04-2620:58bru🤔 actually I’ll try to use this to come up with a plan to eradicate babel#2020-04-2620:59thhellerI just did 😛#2020-04-2621:00bruawesome, your package-lock.json will be far slimmer now!#2020-04-2621:01thhellerif you add me to the repo I can push the branch I made#2020-04-2621:01thhellerthe only problem I found is the ESM CommonJS interop. the generated libadd.js is commonjs but you glue.js was ESM#2020-04-2621:02thhellerso the import WasmAdder ... was the problem#2020-04-2621:02bruindeed#2020-04-2621:02thhellerI switched it to
const WasmAdder = require('./libadd.js');

let add, malloc, free;

const wait = new Promise(done => {
  WasmAdder().then(Module => {
    malloc = Module._malloc;
    free = Module._free;
    add = Module.cwrap('add2', 'number', ['number', 'number']);
    done();
  });
});

exports.add2wasm = function add2wasm(x, y) {
  return wait.then(() => { return add(x, y); });
}
and then you can just compile it with only shadow-cljs
#2020-04-2621:03bruyup, that makes perfectly sense. the original project is a bit more complex as it includes JS from different styles / sources.#2020-04-2621:04thhelleryeah thats an issue. should be either all ESM or all CommonJS. the mix isn't supported well right now#2020-04-2621:04brueheh I noticed#2020-04-2621:05brubtw, I invited you to the repo. If you want to push that branch, it’d be greatly appreciated#2020-04-2621:06thhellerjust did#2020-04-2621:07bruanyway, I hope this can help somehow push the wasm story for cljs. I know t’s brittle and sketchy at the moment, but it works and I’m mixing cljs, js and wasm in a single project (not saying it’s a good idea, but can be done 🙂 ).#2020-04-2621:07thhellerwell now I did 😛#2020-04-2621:14bruthank you so much for your help! I can confirm 2.8.104 works on both the small and the big projects#2020-04-2711:20joshkhi'm on the latest version of shadow-cljs (2.8.104) and just recently started getting a compilation error in my CI for a project that really hasn't changed:
shadow-cljs - dependencies updated
[2020-04-27 12:10:51.037 - WARNING] :shadow.build.classpath/bad-jar-contents - {:jar-file "/Users/myuser/.m2/repository/cljs-bean/cljs-bean/1.5.0/cljs-bean-1.5.0.jar", :bad-prefix "cljs_bean/from/", :bad-count 1}
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.104 running at 
shadow-cljs - nREPL server started on port 9999
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "cljs-bean.from.cljs.core" is not available, it was required by "cljs_bean/core.cljs".
after clearing my project's .shadow-cljs dir, i started getting the same error locally. when i unzip the cljs-bean-1.5.0.jar in my m2 folder, i can see the namespace is there:
system:cljs myuser$ pwd
/Users/myuser/.m2/repository/cljs-bean/cljs-bean/1.5.0/unzipped/cljs_bean/from/cljs
system:cljs myuser$ ls
core.cljs
any thoughts are much appreciated!
#2020-04-2711:21thhellerhaha oops. I added a protection against jars containing compiled and uncompiled cljs sources by looking for /cljs/core.cljs#2020-04-2711:21thhellerdidn't expect anyone to have that as a legit namespace#2020-04-2711:21joshkh😄#2020-04-2711:22joshkhis there a compilation flag that i can use to ignore the check?#2020-04-2711:28thheller@joshkh should be fine in 2.8.105#2020-04-2711:31joshkhthat did the trick! thanks @thheller for the super quick turnaround.#2020-04-2716:17davewoupgrading from 2.8.88 to 2.8.106 to try out the build caching change... and I get this:
shadow-cljs server
shadow-cljs - config: /home/dave/projects/owsy/gondola-client/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).
ES3

Full report at:
/tmp/clojure-6373547123142623863.edn
#2020-04-2716:29thheller@davewo looks like a dependency conflict. need to bump your CLJS version as well if you have it decalred in deps.edn#2020-04-2716:31davewoah, lovely that fixed it, thanks!#2020-04-2716:31yendaare modules https://shadow-cljs.github.io/docs/UsersGuide.html#_modules working with react-native?#2020-04-2717:02thheller@yenda I did some groundwork to get that working yes but I don't know any of the react parts to actually get it to lazy load#2020-04-2717:03thhellerrequires some weird messing with config files I've never seen 😛#2020-04-2717:04thhellersee https://reactnative.dev/docs/ram-bundles-inline-requires#2020-04-2717:05yendafor us it was working with js/require#2020-04-2717:06thhellerfor the build part you would set :chunks {:foo {:entries [some.ns]}} in addition to the usual stuff#2020-04-2717:06thhellerthat would create a foo.js in the output-dir#2020-04-2717:06thhellerand you just load it via (js/require "./foo.js") in your code#2020-04-2717:07yendachunks?#2020-04-2717:07thhellereh sorry :chunks {:foo some.ns/foo}#2020-04-2717:07thhellerso if you do (js/require "./foo.js") in your code you get some.ns/foo#2020-04-2717:08thhellersorry I don't quite remember all the details for this#2020-04-2717:09thhellerbeen a while since I did that and I never quite figured out the react-native parts so that it would actually lazy-load that code#2020-04-2717:09thhellerand not just inline it directly like it does for normal requires#2020-04-2717:10thheller:chunks is the new name the closure stuff uses, moving away from :modules so I just called in chunks to start#2020-04-2717:10thhellerbut its not the regular :modules from a browser build. works slightly differently so that react-native can do its thing properly#2020-04-2717:10yendaafaik inline requires are lazy-loaded#2020-04-2717:10yendaso you don't have to do anything#2020-04-2717:11thhellerlast time I tied I added a (js/console.log "I'm loaded!") the the ns that was supposed to be loaded when I click a button#2020-04-2717:11thhellerbut it was always loaded directly on startup#2020-04-2717:11yendathe key is to make sure the clojurescript code doesn't call the inline require at startup, ie in a def for instance that wouldn't work#2020-04-2717:11thhellerbut its been a while so no clue#2020-04-2717:11yendabut a memoized defn would do#2020-04-2717:12thhellerthe chunking stuff should works for the basics, can easily expand it to allow more complicated configs#2020-04-2717:13thhellerbut even the basics didn't work when I tried so I gave up#2020-04-2717:13thhellerthe files looked like they were supposed to just metro loaded everything eagerly#2020-04-2717:13yendayeah we only need super basic stuff: translation files and some big js files that don't need to be loaded at startup#2020-04-2717:14yendaI'll double check but I'm pretty sure it's just about wrapping the js/require in a defn so that it's only required when needed and not when app starts#2020-04-2717:31thhellerit might only work for release builds but in theory I set it up in a way that might also work for watch, probably not though. never could get it to lazy-load in any scenario#2020-04-2717:33yendamight be the case yeah, though it's fine if it doesn't lazy load for watch#2020-04-2717:42yendaok for watch target you are right it does load when app starts#2020-04-2717:46yenda@thheller though that might not help very much https://github.com/thheller/reagent-react-native/blob/master/react-native/metro.config.js#L13 😄#2020-04-2717:47yenda(quoting the shadow example but it's the same in our app)#2020-04-2717:48thhelleryeah I don't do react-native myself. I never went beyond a couple hello worlds so no clue what any of it means 😛#2020-04-2717:49thhellergave up here https://reactnative.dev/docs/ram-bundles-inline-requires#configure-preloading-and-inline-requires 😛#2020-04-2717:50yendayou can completely ignore everything about ram bundle it's useless#2020-04-2717:51yendait's for android only, and they made a new js engine called Hermes which AOT compiles the code. it's much better to use Hermes than ram bundles now#2020-04-2717:52thhellerah ok. I don't follow RN much so no clue whats happening#2020-04-2717:57yendastill loading early but it might just be dev, will have to wait a bit to test in release as I haven't fixed the android release build yet and ios is useless when it comes to logs#2020-04-2717:59thhellerlet me know how it works out. curious to see if it does 🙂#2020-04-2718:00yendaactually I changed the metro config in the wrong project#2020-04-2718:00yendaso it still need to be tested out 😄#2020-04-2719:44SpacemanHi, I constantly get this mongodb driver message in my shadow-repl, and I want to turn it off:#2020-04-2719:44Spaceman
2020-04-27 15:43:14,333 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=20.2 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.4 ms, state=CONNECTED}] 
2020-04-27 15:43:14,333 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=20.2 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}] 
2020-04-27 15:43:14,932 [XNIO-1 I/O-13] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1 
2020-04-27 15:43:22,145 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of  
2020-04-27 15:43:22,145 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016580, "i": 2}}, "signature": {"hash": {"$binary": {"base64": "w/czHSxejSRK/C/k02tdLQnaRxk=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25260 to database admin on connection [connectionId{localValue:100, serverValue:103115}] to server  
2020-04-27 15:43:22,161 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25260 completed successfully in 16.51 ms on connection [connectionId{localValue:100, serverValue:103115}] to server  
2020-04-27 15:43:22,162 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}] 
2020-04-27 15:43:24,338 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of  
2020-04-27 15:43:24,338 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Checking status of  
2020-04-27 15:43:24,339 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016595, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "rOVQeuBwIEgQnmmAJs4ylRWzPtA=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25261 to database admin on connection [connectionId{localValue:101, serverValue:107380}] to server  
2020-04-27 15:43:24,339 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Sending command '{"ismaster": 1, "$db": "admin", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1588016595, "i": 1}}, "signature": {"hash": {"$binary": {"base64": "rOVQeuBwIEgQnmmAJs4ylRWzPtA=", "subType": "00"}}, "keyId": 6777715635859226627}}}' with request id 25262 to database admin on connection [connectionId{localValue:102, serverValue:132898}] to server  
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25261 completed successfully in 23.75 ms on connection [connectionId{localValue:101, serverValue:107380}] to server  
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.8 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.7 ms, state=CONNECTED}] 
2020-04-27 15:43:24,363 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 25262 completed successfully in 23.93 ms on connection [connectionId{localValue:102, serverValue:132898}] to server  
2020-04-27 15:43:24,364 [cluster-ClusterId{value='5ea55fa97eda171d0065e0f9', description='null'}- DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=22.8 ms, state=CONNECTED}, {address=, type=REPLICA_SET_SECONDARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=19.6 ms, state=CONNECTED}, {address=, type=REPLICA_SET_PRIMARY, TagSet{[Tag{name='nodeType', value='ELECTABLE'}, Tag{name='provider', value='AWS'}, Tag{name='region', value='US_EAST_1'}]}, roundTripTime=23.0 ms, state=CONNECTED}] 
#2020-04-2719:44SpacemanAny help?#2020-04-2719:45SpacemanAnother thing I don't understand is that the mongodb connection is in the back-end, so why would it show in the shadow repl?#2020-04-2719:57SpacemanI want to silence this logging information because it isn't helpful to me and detracts me from a good interactive experience in the repl. These messages appear periodically and move the position of the cursor and also the location of the prompt.#2020-04-2719:57dvingoI have a simple .cljc file with the contents:
(ns my-proj.data
  (:require #?(:clj [com.wsscode.pathom.connect :as pc]))
  #?(:clj ::pc/hi)
the shadow cljs build is failing with:
Invalid keyword: ::pc/hi.
Is there something obvious I'm missing here?
#2020-04-2720:04thheller@danvingo the code is not readable in CLJS since it doesn't have the alias to resolve ::pc/hi#2020-04-2720:05thhellerI know its weird but its a quick of auto-resolved keywords, happens in CLJ too#2020-04-2720:05dvingoah ok cool, just wanted to make sure I wasn't going insane (at least due to this)#2020-04-2720:06thheller@pshar10 I guess you are running shadow-cljs embedded in lein or something? no clue why you'd be getting mongodb messages, it is shadow-cljs doing that#2020-04-2720:07SpacemanSo I found this: https://github.com/michaelklishin/monger/issues/115#2020-04-2720:09thhelleryou if you run shadow-cljs as I recommend and not embedded in something else then you won't have this issue#2020-04-2720:09thhellerif you do something else you have to sort it out on your own#2020-04-2720:09thhellerI can give pointers maybe if you share you setup#2020-04-2720:10SpacemanYeah, I understand. Anyway, I added this in my project.clj, [org.slf4j/slf4j-nop "1.7.12"] which is the proposed solution, but it didn't work. My setup is basically the Luminus template.#2020-04-2720:10Spacemanhttps://luminusweb.com#2020-04-2720:11SpacemanTo replicate, you would make a Luminus app and then connect with a mongodb server in clj. The shadow-repl would still show the connection messages#2020-04-2720:11thhelleris there a logback.xml in the project?#2020-04-2720:12thhelleror maybe a log4j.xml?#2020-04-2720:13SpacemanYeah logback.xml is there. What about it?#2020-04-2720:13thhellerthats the file that controls the logging#2020-04-2720:13thhellerwhats in it?#2020-04-2720:13Spaceman<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="10 seconds"> <statusListener class="ch.qos.logback.core.status.NopStatusListener" /> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> <encoder> <charset>UTF-8</charset> <pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern> </encoder> </appender> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>log/vendo.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>log/vendo.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>100MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- keep 30 days of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <charset>UTF-8</charset> <pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern> </encoder> </appender> <logger name="org.apache.http" level="warn" /> <logger name="org.xnio.nio" level="warn" /> <logger name="io.netty" level="warn" /> <root level="DEBUG"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> </configuration>#2020-04-2720:14thhellersee this line <logger name="io.netty" level="warn" />#2020-04-2720:14thhellerjust add <logger name="org.mongodb" level="warn" /> after it#2020-04-2720:14thhelleror change <root level="DEBUG"> to <root level="INFO">#2020-04-2720:15thhellerthis has absolutely nothing to do with shadow-cljs though. this is luminus.#2020-04-2720:15thhellerbut it'll make the messages disappear#2020-04-2720:15thhellerlikely need to restart though#2020-04-2720:16SpacemanThanks that worked @thheller#2020-04-2720:16Spaceman💯#2020-04-2720:36SpacemanA little side-question. There's this cider-test.el file for clj test support within cider. It would be good if there were an analogous one for running shadow cljs tests too. Do you have any idea what modifications would be needed in this file for that to be possible?#2020-04-2720:36Spacemanhttps://github.com/clojure-emacs/cider/blob/052290d080f58edc814dd7aa00b014d639c62974/cider-test.el#2020-04-2720:38thhellerI know nothing about cider sorry#2020-04-2723:19Mario C.@pshar10
(:import org.slf4j.LoggerFactory
           ch.qos.logback.classic.Level))

(defonce server (atom nil))

(def mongo-logger (LoggerFactory/getLogger "org.mongodb.driver"))
(def jetty-logger (LoggerFactory/getLogger "org.eclipse.jetty"))

(defn log-level
  [level]
  (let [levels {:error Level/ERROR}
        l (get levels level Level/DEBUG)]
    (.setLevel mongo-logger l)
    (.setLevel jetty-logger l)))
This what I got for controlling log-level
#2020-04-2723:19Mario C.Then you just call it like this (log-level :error)#2020-04-2723:19Mario C.This will get rid of all those mumbo jumbo, hope that helps!#2020-04-2720:06dvingoany recommendation on how to use auto-resolved kewwords then?#2020-04-2720:06dvingoor should i just use 2 files (cljs clj)#2020-04-2720:06thhellerjust need to make sure the alias exists for cljs too#2020-04-2720:07dvingohmm ok#2020-04-2720:07thheller
(ns my-proj.data
  (:require #?(:clj [com.wsscode.pathom.connect :as pc]
               :cljs [clojure.string :as pc]))
#2020-04-2720:07thhellerdoesn't really matter what it resolves to if you are not going to use in it CLJS anyways#2020-04-2720:07dvingook got it. thanks#2020-04-2721:40SpacemanIs there a way to define a custom function in the shadow.repl namespace, because I want to automatically run shadow/watch for a couple of profiles?#2020-04-2721:52aisamuYou can invoke arbitrary functions from shadow's cli (and those can start the build with your requirements) https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2020-04-2804:44Spaceman@U1UQEM078 my cider automatically runs this command:
/usr/local/bin/npx shadow-cljs -d nrepl:0.6.0 -d refactor-nrepl:2.5.0-SNAPSHOT -d cider/cider-nrepl:0.23.0 server
Given this, where do I put the functions I need to run on the repl startup?
#2020-04-2814:18aisamuYou can configure the command cider uses to start the repl - https://docs.cider.mx/cider/cljs/shadow-cljs.html#_configuration Those vars go in a .dir-locals.el file:
((clojure-mode
  (cider-preferred-build-tool . "clojure-cli")
  (cider-clojure-cli-global-options . "-A:dev"))
#2020-04-2819:08SpacemanSo exactly I want this: 1. I start a shadow repl using M-x return ' and choose shadow 2. Then shadow.user> repl prompt is shown. 3. In this I always evaluate this: (do (shadow/watch :app) (shadow/watch :workspaces) (shadow/repl :workspaces)) 4. In order to run these functions automatically, what do I need to do exactly?#2020-04-2819:17aisamuThis might be a better question for #cider. I recall there being a custom command to start clojurescript REPLs...#2020-04-2722:04Spaceman@thheller is there a way to integrate shadow-cljs with kaocha-cljs yet?#2020-04-2722:04Spacemanhttps://github.com/lambdaisland/kaocha-cljs/issues/2#2020-04-2723:16SpacemanI'm trying to run the kaocha-cljs library, and I've installed it by adding kaocha and kaocha depencies in my project.clj#2020-04-2723:17SpacemanBut when I evaluate a kaocha test in the clj repl, I get the following error:
(run 'vendo.workspaces.cards_test) ;; cljs file


Caused by: clojure.lang.ExceptionInfo: No such namespace: @testing-library/react, could not locate _CIRCA_testing_library_SLASH_react.cljs, _CIRCA_testing_library_SLASH_react.cljc, or JavaScript source providing "@testing-library/react" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file /Users...
I installed this library through npm and it's in that cards_test namespace. How do I run kaocha tests then that include npm dependencies?
#2020-04-2802:40Lucy Wang@pshar10 I think kaocha and shadow-cljs doesn't work well together at the moment
#2020-04-2802:41Lucy Wanghttps://github.com/lambdaisland/kaocha-cljs/issues/2#2020-04-2802:50Lucy Wang@thheller do you think it's a good idea to add support of a "pre/post-css-update-hook"? I have some animation defined in css and each time the css is live updated, the page would go through the animation process which is time consuming.#2020-04-2802:52Lucy WangThe idea is to I want to call some custom code before handle-asset-watch , e.g. add a '.disable-animation' class to the html body to make sure the animation rules is not in effect, and remove this class after the css update.#2020-04-2802:55Lucy Wange.g. https://github.com/lucywang000/shadow-cljs/commit/a71e74d39a64c8034a5f7ee1889b302470f03e49#2020-04-2806:40thheller@pshar10 no kaocha-cljs does not work with shadow-cljs yet. talked with the author yesterday and there are plans to get this working but nothing as of yet.#2020-04-2806:40andrehi is this something known ?#2020-04-2806:40andrein edn i have
:http-port  3000
#2020-04-2806:42thheller@andre this is caused by a core.async dependency conflict when using deps.edn/project.clj#2020-04-2806:42thhellermake sure you don't use an ancient core.async version, should be [org.clojure/core.async "1.1.587"]#2020-04-2806:43andreyeah i have [org.clojure/core.async "0.7.559"] in project.clj, thanks#2020-04-2806:46andrebut I have only one terminal with the project on port 3000 why does it say 3000 and 3001 are in use ?#2020-04-2806:47andre"1.1.587" didn't help, same Exception#2020-04-2806:48thhellerbecause something is running on those ports 😛 can't tell you what#2020-04-2806:49thhellermake sure you don't have any other conflicts too. maybe you have some leftover AOT cache as well?#2020-04-2806:49andrethis Exception started to happen when these ports appears, but the interesting thing I can open these ports and I can see another shadow-cljs project but they are not running in any terminal#2020-04-2806:49thhellerevery time someone has reported an error like this it was related to some dependency conflict. not sure what else it would be#2020-04-2806:49thhellertry jps#2020-04-2806:49thhellerand maybe just kill those processes if you don't want them?#2020-04-2806:53thheller@wxitb2017 wouldn't it be more practical if you start with a <body class="load-anim"> or so and then remove that class yourself at some point? I didn't even know that replacing the css would restart animations? do you have an example of that so I can reproduce and test?#2020-04-2806:54Lucy Wang> then remove that class yourself at some point? That need to be manually and breaks the modify => wait for css reload => evaluate new design => .. loop#2020-04-2806:54Lucy Wang> I didn't even know that replacing the css would restart animations one sec#2020-04-2806:56andreyeah there are no processes, and i found it was a browser cache If i clean it ,i can see the same project on these ports, so for some reason it runs same project on different ports#2020-04-2806:59andreand i still work with my project on port 3000 even if it says last one is 3002, but i can live with that , not critical 🙂#2020-04-2807:08thhellerthere must be something blocking those ports#2020-04-2807:08thhellerwhich OS are you on?#2020-04-2807:13andremacos, btw it worked just fine, but at some point i was running several projects in parallel , one was on 3000 and another on 3001, probably after that this project started to show these ports and exceptions, btw it shows exception only if i open browser on port 3001 if i open it on 3000 there are no exceptions#2020-04-2807:15thhellertry lsof -i -nP | grep LISTEN#2020-04-2807:15thhellerthat should show which process is listening on that port. if I remember the command correctly 😛#2020-04-2807:16thhellerbut selecting different ports really shouldn't cause that core.async error#2020-04-2807:16thhelleryou can try shadow-cljs clj-repl and then ( "clojure/core/async.clj") to see which version you get#2020-04-2807:17thhellerand maybe ( "clojure/core/async__init.class") to see if there are some AOT files that would break this as well#2020-04-2807:18Lucy Wang#2020-04-2807:19andreyes for some reason this project starts 3 ports, if i start it i can see 3 java listeners (3000, 3001 ,3002) if i stop it there are no listeners#2020-04-2807:19Lucy Wang@andre the last resort is to pkill -f java to kill all java process#2020-04-2807:20Lucy Wang@thheller you can see the demo I recorded. After removing the link node and recreating it (by undo) the animation (transition actually) is performed again.#2020-04-2807:20andrethere are no java processes#2020-04-2807:20thhellerthen just configure a different port for shadow-cljs if 3000 is used 😛#2020-04-2807:21thheller@wxitb2017 I meant the CSS to make this happen 🙂#2020-04-2807:21Lucy Wang
* {
    margin: 0;
    padding: 0;
    text-align: center;
}
html {
    background: white;
    width: 100%;
    height: 100%;
}
body {
    height: 100px;
    background-color: red;
    position: absolute;
    transition: background-color 3s linear 50ms;
    width: 100%;
}
h3 {
    margin-top: 1em;
}
#2020-04-2807:21Lucy Wanghtml is deadly simple
{:type :dtd, :data ["html" nil nil]}
#2020-04-2807:22thhellerinteresting that this animates the background-color. wouldn't have expected that.#2020-04-2807:23Lucy Wangnot only bg, any animatable css attribute would do#2020-04-2807:24Lucy Wangactually by talking with you I got some inspiration. The transition rule shall be added to a special selector instead of on the base.#2020-04-2807:26thhellerI guess its because html bg white is first applied and then body with transition#2020-04-2807:26kirill.salykinGoodmorning, when I am trying to launch shadow-cljs using deps.edn alias I see this error:
shadow-cljs - starting via "clojure"

Unknown option: "-m"

Usage:
  shadow-cljs <action> <zero or more build ids>

Supported actions are:

     compile - ...
       watch - ...
       check - ...
     release - ...
   classpath - ...
   node-repl - ...
browser-repl - ...
   cljs-repl - ...
    clj-repl - ...
    clj-eval - ...
     clj-run - ...
         run - ...
        info - ...
         pom - ...
    npm-deps - ...
        test - ...
         aot - ...
        init - ...
        help - ...
      server - ...
       start - ...
        stop - ...
     restart - ...
shadow-cljs.edn
{:deps     {:aliases [:frontend]}
 :dev-http {8080 "public"}
 :builds   {:app {:target     :browser
                  :output-dir "public/js"
             ... }}}
#2020-04-2807:27thhellerlooks like you have a clojure on your classpath thats not from the official tools.deps dist?#2020-04-2807:27thhellertry clojure -m shadow.cljs.devtools.cli help manually#2020-04-2807:28thhelleror what did you run to begin with?#2020-04-2807:28thhellerdid you run shadow-cljs -m something?#2020-04-2807:28kirill.salykin> try `clojure -m shadow.cljs.devtools.cli help` manually this works but If I invoke via shadow-cljs - doesnt#2020-04-2807:29thhellershadow-cljs -m is not supposed to work. what are you actually calling?#2020-04-2807:29kirill.salykin
{  :frontend
  {:deps
   {org.clojure/clojure       {:mvn/version "1.10.1"}
    org.clojure/clojurescript {:mvn/version "1.10.742"}
    thheller/shadow-cljs      {:mvn/version "2.8.106"}
    reagent                   {:mvn/version "0.10.0"}
    re-frame                  {:mvn/version "0.12.0"}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}
#2020-04-2807:29kirill.salykinthis is from the deps.edn#2020-04-2807:29kirill.salykinaliast#2020-04-2807:29kirill.salykinI just invoke shadow-cljs compile app#2020-04-2807:29thhellerremove the :main-opts thats redundant#2020-04-2807:30thhelleronly need that if you want to run via clj -A:frontend compile app#2020-04-2807:30kirill.salykinyes#2020-04-2807:30kirill.salykinworked!#2020-04-2807:30kirill.salykinthanks#2020-04-2807:30kirill.salykinI think it is mentioned here: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2020-04-2807:32thhelleryes, if you intend to run with clj directly.#2020-04-2807:32thheller> Running with clj directly.#2020-04-2807:32thhellerI guess that could be clearer#2020-04-2807:33kirill.salykinright, but now same alias cant be used for both scenarios#2020-04-2807:36thhelleryou can just add another alias if you want to be able to run from clj#2020-04-2807:37kirill.salykinis it possible to specify that I want start cljs repl via clj? (using cider)#2020-04-2808:26thhellercider uses nrepl so not sure what you mean with regards to clj#2020-04-2808:27kirill.salykinignore me, I’ve found that it is CIDER decides how to start shadowcljs repl#2020-04-2807:46andre
:builds       {:dev            {:target           :browser
                                 :output-dir       "public/js"
                                 :asset-path       "/js"
                                 :devtools         {:autoload   true
                                                    :http-root  "public"
                                                    :http-port  3000}}
               :dev1            {:target           :browser
                                 :output-dir       "public/js"
                                 :asset-path       "/js"
                                 :devtools         {:autoload   true
                                                    :http-root  "public"
                                                    :http-port  3000}}
               :dev2            {:target           :browser
                                 :output-dir       "public/js"
                                 :asset-path       "/js"
                                 :devtools         {:autoload   true
                                                    :http-root  "public"
                                                    :http-port  3000}}
interesting if i have such config, and run shadow-cljs watch dev I'll see this
shadow-cljs - HTTP server available at 
[2020-04-28 09:43:53.975 - WARNING] TCP Port 3000 in use.
shadow-cljs - HTTP server available at 
[2020-04-28 09:43:54.004 - WARNING] TCP Port 3000 in use.
[2020-04-28 09:43:54.009 - WARNING] TCP Port 3001 in use.
shadow-cljs - HTTP server available at 
#2020-04-2807:47andreif i remove :dev1 and :dev2 i don't see warnings#2020-04-2807:48andreso for some reason shadow runs listeners for all builds when i run one#2020-04-2807:50yendathe http port isn't a listener per build#2020-04-2807:51yendashadow only needs to run one and then you can monitor all builds on the http endpoint#2020-04-2807:52yendamaybe there should be a check when reading config that it's not defined more than once#2020-04-2807:52yendaor maybe I'm wrong 😛#2020-04-2807:53andrehey dude, when shadow-cljs ? 😛#2020-04-2807:54yenda@thheller btw confirmed, inline requires are only lazy loaded in release, so it's normal that you see them loaded early in dev. I think :chunks should be added to the shadow docs, module just works.#2020-04-2807:55yenda@andre we are going to work with Jakub today to collects the maven deps used by shadow and put them in the nix pkgs#2020-04-2807:56yendabut it's a lot of bash you get just the deps then you have to look for the sources and signatures in the m2 directory, very rough 😄#2020-04-2807:57SpacemanI have this following idiom in my code:
(deftest my-test
   (run-test-sync
       (is (= 1 2)) ;; etc.
   )
And it seems like a good idea to create a macro which would replicate this like so:
(deftest-sync my-test
   (is (= 1 2))
)
And I have tried this:
(defmacro deftest-sync [name test]
  `(deftest ~name ~(run-test-sync ~test))
  )
But on doing in the shadow repl:
(macroexpand '(deftest-sync some-test (is (= 1 1))))
I simply get the result:
(deftest-sync some-test (is (= 1 1)))
But I seem to get the correct result in a clojure repl. Why would this be?
#2020-04-2808:27thheller@andre hehe yeah the dev-http stuff isn't per build and they always run. instead use https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http so you just do :dev-http {3000 "public"} once at the top level#2020-04-2808:28thhellerno :http-root stuff in :devtools needed#2020-04-2808:28thheller:autoload true is also the default so you can skip the entire :devtools entries#2020-04-2808:29thhelleralso don't name your builds :dev. each build already has dev/release notion built-in, shadow-cljs release dev is just weird 😛#2020-04-2808:29thheller@yenda wow, thats neat. surprised that it works but thanks for confirming 🙂#2020-04-2808:35andrebtw i have an idea but i don't know if I'll have time any soon, but it would be cool to embed re-frisk into shadow dashboard and utilize shadow's websockets#2020-04-2808:36andreor shadow dashboard could have something like plugins idk#2020-04-2808:37thhellerplugins are pretty much impossible due to :advanced but I'd be happy to add a route that just delegates to a re-frisk ring handler when called?#2020-04-2808:39thhellerthe server supports plugins though, just not the UI. so you could hook into the shadow-cljs lifecycle if needed#2020-04-2808:40thhellerits not documented since I'm still not sure how I feel about plugins 😛#2020-04-2810:05yenda@thheller is there a way to specify a local maven repo directory to shadow?#2020-04-2810:13thheller:maven {:local-repo "maven"} in shadow-cljs.edn top level. assuming you aren't using deps/project.clj or course#2020-04-2811:17yendahow does shadow-cljs decides to use the shadow-cljs aot compiled jar? any clue why maven is downloading the sha1 signature of the jar and not the aot jar?#2020-04-2811:18thhellerhmm? it defaults to using the AOT jar when using shadow-cljs.edn to manage dependencies#2020-04-2811:18thheller:aot false to turn that off#2020-04-2811:38yendais there a way to build without going through maven deps resolution again? i.e we already have classpath and deps downloaded, but don't want to rerun dependencies resolution because it will ask for tons of different version of each deps#2020-04-2811:39thhellerremove any deps that use version ranges? 😛#2020-04-2811:40yendaI mean when you run shadow-cljs classpath you get all the deps the project needs#2020-04-2811:40yendabut actually when building you need all the intermediate versions to calculate the classpath#2020-04-2811:41thhellerisn't that all taken care of if you have the maven repo cached?#2020-04-2811:41yendawe already have the classpath and final deps so is there a way to get straight to the building step#2020-04-2811:41thhellerI mean it shouldn't do anything remote once its filled and there are no snapshot deps or ranges?#2020-04-2811:42thhellera pre-calculated classpath is not currently supported otherwise#2020-04-2811:42thhellerdo lein/deps provide something like that?#2020-04-2811:44yendano but with lein deps when starting from an empty m2 repo we were basically taking all the downloads printed by the command to have a list of all the deps#2020-04-2811:44yendabut most of them aren't even needed for the actual build#2020-04-2811:44thhellernot sure what you are actually trying to do with this#2020-04-2811:45thhellerI mean how do you get the shadow-cljs classpath? compute that elsewhere?#2020-04-2811:45thhelleryou can literally run java -cp <that-classpath> clojure.main -m shadow.cljs.devtools.cli release app yourself if you want 😛#2020-04-2811:45yendayeah we generate nix derivation is a stateful env then we do offline builds with them#2020-04-2811:46thhellerdon't know enough about nix to know how that all works 😛#2020-04-2811:48yendabasically think of it as building offline#2020-04-2811:48yendaall you have is a disk so you need everything on that disk#2020-04-2811:49thhelleryes. if I run lein deps once to get everything and then disconnect my network and lein repl or whatever it works?#2020-04-2811:49thhellerdoesn't do anything remote?#2020-04-2811:57yendayes indeed but it would have downloaded a ton of useless intermediate deps#2020-04-2811:57yendaI think your command with java above works#2020-04-2812:00thhelleryeah basically all the tools do is construct the classpath and ensure the files are actually downloaded#2020-04-2812:00thhellerotherwise if you have the classpath you don't need anything else and can just run java#2020-04-2812:01thhellermaybe need to adjust some extra args if you have :jvm-opts or so configured since they won't be taken into account#2020-04-2812:01thhellerbuild wise it doesn't matter how things were started#2020-04-2812:05yendais shadow making a call to yarn/npm during the build process?#2020-04-2812:05yenda
running: npm install --save --save-exact 
#2020-04-2812:07thhelleronly if your package.json doesn't contain all the packages that were required by cljs deps via deps.cljs#2020-04-2812:08thhellerI guess I could add a flag so it always skips that?#2020-04-2812:09yendamight be related to
NPM dependency "react" has installed version "16.9.0"
"16.13.0" was required by jar:file:/home/yenda/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
` then
#2020-04-2812:10yendaseems like there is a mismatch between react version required by reagent and the one required by react-native#2020-04-2812:10thhellerthats just a warning#2020-04-2812:11yendayeah but then our node_modules won't contain 16.13.0 and reagent will require it in deps.cljs?#2020-04-2812:11thhellerthat doesn't matter#2020-04-2812:12thhellerhttps://github.com/thheller/shadow-cljs/blob/60e0966f1ec087eb6aba06b1fde9e93f9a10ab46/src/main/shadow/cljs/devtools/server/npm_deps.clj#L223#2020-04-2812:12thhellerthats the code triggering the npm install#2020-04-2812:12yendabut the npm error says it tried to install 16.13.0 running: npm install --save --save-exact #2020-04-2812:12thhellerand your package.json contains those dependencies?#2020-04-2812:13thhellerthats the only question you need to answer#2020-04-2812:13thhellerif it is in there it should skip trying to install it, regardless of the versions. that check is done at a different point and does NOT trigger another install#2020-04-2812:13yendamy package.json contains "react": "16.9.0", "react-dom": "^16.4.2",#2020-04-2812:14yendaand they are locked in yarn.lock#2020-04-2812:14thhellerand it is in dependencies?#2020-04-2812:14thhellerand the package.json is in the same dir as shadow-cljs.edn?#2020-04-2812:15thhellerthe check is dumb ... so it must be in package.json "dependencies" or "devDependencies"#2020-04-2812:15thhellerit does not understand any other complicated setup#2020-04-2812:16yendaok will check, we do have the package.json in a different dir, might not be properly symlinked at that point#2020-04-2812:18thhelleryou can open an issue to just disable that check entirely if you want. it is somewhat naive anyways.#2020-04-2812:19yendalooks good, it works now, that was because the package.json wasn't there#2020-04-2812:39yendagetting a weird error in CI with deftype that doesn't happen locally:
[2020-04-28T12:32:47.944Z] [:android] Compiling ...
[2020-04-28T12:33:34.658Z] ------ ERROR -------------------------------------------------------------------
[2020-04-28T12:33:34.658Z]  File: /build/status-react-source-jsbundle/src/status_im/utils/multihash.cljs:53:1
[2020-04-28T12:33:34.658Z] --------------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z]   50 | ;; - `hex-digest` is a string holding the hex-encoded algorithm output.
[2020-04-28T12:33:34.658Z]   51 | ;;
[2020-04-28T12:33:34.658Z]   52 | ;; Multihash values also support metadata.
[2020-04-28T12:33:34.658Z]   53 | (deftype Multihash [code hex-digest _meta]
[2020-04-28T12:33:34.658Z] -------^------------------------------------------------------------------------
[2020-04-28T12:33:34.658Z] Error in phase :compilation
[2020-04-28T12:33:34.658Z] Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
[2020-04-28T12:33:34.658Z] {:warning :infer-warning, :line 53, :column 1, :msg "Cannot infer target type in expression (. (. Multihash -prototype) --equiv)"}
[2020-04-28T12:33:34.658Z] ExceptionInfo: Cannot infer target type in expression (. (. Multihash -prototype) --equiv)
#2020-04-2812:40thhellerdo you use :warnings-as-errors or so?#2020-04-2812:40thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#warnigs-as-errors#2020-04-2812:40yendayep#2020-04-2812:40thhellernormally these wouldn't throw otherwise?#2020-04-2812:41yendabut I don't get the warning when building locally#2020-04-2812:45yendawell it's building now so yolo#2020-04-2813:41yendait's weird the error actually happens intermittently#2020-04-2814:12SpacemanI have an myapp.environment namespace like so in an environment.clj file.
(ns myapp.environment
  (:require  [myapp.config :refer [env]]))

(defmacro myapp-url [] (:myapp-url env))
Then I require this in an events.cljs file like
[myapp.environment :refer-macros [myapp-url]]
I get the error in shadow
The required namespace "myapp.environment" is not available, it was required by "myapp/events.cljs".
"myapp/environment.clj" was found on the classpath. Should this be a .cljs file?
when using it like so:
(http/get (str (myapp-url) "/somepath"))
How do I fix this?
#2020-04-2814:17thhellerread https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-04-2815:52SpacemanSay I have a macro in the clj file to be used in a cljs file
(defmacro defelem [name element]
  `(defcard ~name
     (ct.react/react-card
      (r/as-element
       [~element]
       )
      )
     )
  )
and the dependencies are ct.react and r. Should the dependencies be required in the clj or the cljs files? I tried both but neither worked.
#2020-04-2815:52SpacemanI get the error in shadow:
(defelem cart-card cart)
-------^------------------------------------------------------------------------
Use of undeclared Var vendo.workspaces.cards/react-card
--------------------------------------------------------------------------------
#2020-04-2816:10Felipe MarquesProbably in the CLJS#2020-04-2816:12Felipe MarquesYour macro is depending on specific alias like ct.react and r I believe this must be available at the file you are using it. Or you should require it in the macro. Or use the full namespace like reagent.core/as-element .#2020-04-2816:16thheller@pshar10 use fully qualified names in the macro and require as normal in the CLJS file. CLJ macros can't see the CLJS aliases so you need to do it manually. I mention this in the blog post.#2020-04-2816:58Pavel KlavíkHi, is there some project for generating static web using Shadow-cljs? I really love hot code reloading (including CSS), so I am thinking to building the static web as a trivial React app in dev and generating static web using hiccup for the production.#2020-04-2817:42Spaceman@thheller this is what I have now, but it doesn't work still: In myapp.workspaces.cards (clj)
(ns myapp.workspaces.cards)

(defmacro defelem [name element]
  `(nubank.workspaces.core/defcard ~name
     (nubank.workspaces.card-types.react/react-card
      (reagent.core/as-element
       [~element]
       )
      )
     )
  )
In myapp.events (cljs) where I use this defelem macro
(ns myapp.workspaces.cards
  (:require
   [nubank.workspaces.core]
   [nubank.workspaces.card-types.react]
   [reagent.core]
   [myapp.cart :refer [cart]]
   
   ))

(defelem cart-card cart)
But I get:
(defelem cart-card cart)
--------^-----------------------------------------------------------------------
Can't take value of macro myapp.workspaces.cards/defelem
Why would this be?
#2020-04-2817:48thhellerread the blog post again#2020-04-2817:48thhellerit literally is just three steps you need to do 😛#2020-04-2817:49thheller
(ns myapp.workspaces.cards
  (:require-macros [myapp.workspaces.cards :refer (defelem)])
  (:require
    [nubank.workspaces.core]
    [nubank.workspaces.card-types.react]
    [reagent.core]
    [myapp.cart :refer [cart]]
    ))
#2020-04-2817:49thhellerthe CLJS namespace that also has macros MUST require itself via :require-macros in its ns-form#2020-04-2817:50thhellerin your case since you are also using that macro in the very same namespace you also need the refer#2020-04-2820:16mkarpHey there! I’ve got a question: if shadow watch is running, and I have an app opened in a browser, how can I trigger reload from a command line?#2020-04-2820:18thhellerreload?#2020-04-2915:42mkarpYes, sorry for being ambiguous. So let’s say there are a bunch of functions marked with ^:dev/after-load, and I’d like to call all of them via command line. Similar to CSS file watcher — when CSS changes, reload the app in the browser#2020-04-2915:47thhellerhmm no there is nothing like that. you can always call those functions from the REPL though?#2020-04-2915:48thhellerwhat are you trying to do though? why is calling that from the command line important?#2020-04-2916:03mkarpWe’re generating some js files along with the shadow build and would like to load them in a hot reload fashion#2020-04-2916:04mkarpREPL always works, but I’d like to do it via a file watcher for better usability#2020-04-2916:05thhelleryou mean you generate js files that aren't part of the build and are loaded via separate <script> tag?#2020-04-2916:17mkarpYes, exactly#2020-04-2916:17mkarpWe don’t want to bundle them together with the application code (translations)#2020-04-2916:18thhellerwell the easiest way is to just trigger a cljs compile#2020-04-2916:18mkarpWe’ve came up with a hacky solution of touching an empty cljs file in src/dev directory#2020-04-2916:19thhellertouch path/to/your/sources/some/ns.cljs#2020-04-2916:19mkarpYes, that’s what we did 🙂#2020-04-2821:41eccentric JThere's an going issue with suitable which sits somewhere between cider, and shadow-cljs. https://github.com/clojure-emacs/cider/issues/2808 the author of suitable suggests it was working and is not now. Could someone familiar with the shadow-cljs internals take a quick look and see if anything sticks out? https://github.com/rksm/clj-suitable/blob/master/src/main/suitable/complete_for_nrepl.clj#L207#2020-04-2907:41thheller@jayzawrotny one guess would be that it tries to eval stuff even when no runtime (eg. browser) is connected to do the actual eval?#2020-04-2916:48eccentric JI don't think it's that as I'm getting the error when running a node process while connected to the REPL. Sounds like it's not obvious so the maintainer will likely need to find time to debug.#2020-04-3017:10eccentric J@thheller We've examined the stack-trace more carefully and found the issue is due to this function returning false. https://github.com/rksm/clj-suitable/blob/master/src/main/suitable/complete_for_nrepl.clj#L204-L205 Anything stick out there?#2020-04-2910:36kucerm2Hi, is possible that shadow-cljs exclude .scss.js* node module files from target build?#2020-04-2910:46thhellerwhy would it? I mean actual .js files should load without issue?#2020-04-2911:32kucerm2I'm trying fluent-ui and get this errors with this require#2020-04-2911:33kucerm2
(ns app.main
  (:require [reagent.core :as r]
            ["@fluentui/react" :refer [Button PrimaryButton Stack]]
            ["@uifabric/utilities/" :as fu]
            ["@uifabric/styling/" :as fs]))
#2020-04-2911:33thhellerright so thats an actual .scss require#2020-04-2911:33kucerm2in CalendarDay,js is this#2020-04-2911:34kucerm2
import * as stylesImport from './Calendar.scss';
#2020-04-2911:34thhelleryeah, usually libraries ship with those either removed completely or already converted to .js#2020-04-2911:34thhellerso the lib seems to presume that you are using webpack with a scss loader configured?#2020-04-2911:34thhellerthat won't work with shadow-cljs#2020-04-2911:36kucerm2Ah, that's unfortunate#2020-04-2911:36kucerm2😕#2020-04-2911:37thhelleryou can use webpack if you want but you'll have to set that up on your own#2020-04-2911:37thhellerits 2 line of config for shadow-cljs but no clue how to do the webpack parts 😛#2020-04-2911:37kucerm2for completeness the file contains#2020-04-2911:38kucerm2
/* tslint:disable */
import { loadStyles } from '@microsoft/load-themed-styles';
loadStyles([{ "rawString": ".root_d7ec3e0f{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-box-shadow:none;box-shadow:none;margin:0;padding:0}.root_d7ec3e0f *{overflow:visible}.root_d7ec3e0f *::-moz-focus-inner{border:0}.root_d7ec3e0f *{outline:transparent}.root_d7ec3e0f *{position:relative}.ms-Fabric--isFocusVisible .root_d7ec3e0f *:focus:after{content:'';position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;border:1px solid " }, { "theme": "neutralSecondary", ...
#2020-04-2911:38kucerm2Calendar.scss.js#2020-04-2911:38thhellerso it is compiled? you are confusing me here#2020-04-2911:39kucerm2yes#2020-04-2911:40kucerm2sorry I never use webpack and scss.js file see first time#2020-04-2911:43thhellerah ok, now I get it.#2020-04-2911:43thhellervar stylesImport = require("./Calendar.scss"); this is the issue#2020-04-2911:43thhellerit is in the office-ui-fabric-react npm package#2020-04-2911:43thhellerthe first warning you get#2020-04-2911:44thhellerseems like that is badly packaged?#2020-04-2911:46kucerm2this import is in @fluentui/react/lib/Calendar.js
export * from 'office-ui-fabric-react/lib/Calendar';
and office-ui-fabric-react package is in node_modules directory
#2020-04-2911:47thhelleryes exactly. that is the bad package not @fluentui/react#2020-04-2911:47kucerm2#2020-04-2911:47thhellerCalendarDay.js is the bad one, not sure if there are others#2020-04-2911:48thhelleryep there are others#2020-04-2911:48thhellerthe entire lib uses that. probably best to report that as a bug#2020-04-2911:49kucerm2No, CalendarDay.js is in right path#2020-04-2911:50kucerm2sry bad directory 🙂#2020-04-2911:50thhelleryou are in the wrong dir#2020-04-2911:50kucerm2#2020-04-2911:51thhellerhmm actually you are right#2020-04-2911:51thhellerthe files do actually exist#2020-04-2911:51thhellerso this should work#2020-04-2911:52thhellerah yeah I think I know what happens#2020-04-2911:52thhelleryeah thats a bug in shadow-cljs#2020-04-2911:55kucerm2It's possible to get workaround it?#2020-04-2911:56thhellerhttps://github.com/thheller/shadow-cljs/issues/696#2020-04-2911:57thhellerwill need to think about that for a bit#2020-04-2911:57thhellerno quick hack other than using webpack#2020-04-2912:01kucerm2Ok, thank you very much for your interest. I wait until you have an solution, you are shadow-walker 🙂#2020-04-2912:01thhellerfirst time I see a package using this method it would go away if the require in those files just used require("./Calendar.scss.js") but I guess they had to rely on that little bit of extra magic 😛#2020-04-2912:02thhellerI guess thats a quickfix if you want one#2020-04-2912:02kucerm2It's M$ product in TS 🙂#2020-04-2912:02thhellerfor all files in that lib just search&replace .scss") with .scss.js") 😛#2020-04-2912:04kucerm2no problem it's only 100+ files 🙂 It not terrible for my tests 😉#2020-04-2912:05thhellerone command in your editor 😉#2020-04-2912:05kucerm2yes!#2020-04-2912:05kucerm2I love it 😄#2020-04-2912:06thhellerI'll see if I can sort this out easily. the filtering I did for css is a bit naive anyways#2020-04-2912:07kucerm2I thought that *.scss is not a coincidence#2020-04-2912:09thhelleryeah first time I see the combination of actually keeping the .scss require and just expecting to pick up the .scss.js#2020-04-2912:10thhellernormall either the require is renamed or uses the full name or just removed#2020-04-2912:16kucerm2Program run without error, after rename, thank you 😉#2020-04-2912:16thhellersweet#2020-04-2914:07Joel SödermanHi! I’m using shadow-cljs and loving it. Thanks so much for doing this! I have a question: is there a convenient a way to run just one specific test from the command line?#2020-04-2914:07thhellernot yet. the testing has been neglected for a bit but I have some plans to make that a bit more convenient.#2020-04-2914:08thhelleryou can use a REPL though#2020-04-2914:08Lucy Wangsome time I have written some custom runner code for that#2020-04-2914:08Lucy Wangin a project with target :node-script#2020-04-2914:08thhellershadow-cljs node-repl (require 'your.test-ns) (your.test-ns/the-test-you-want)#2020-04-2914:09thhellerthats what I do ... from my editor REPL though not from the command line#2020-04-2914:09Lucy Wanghttps://github.com/scterm/scterm/blob/master/src/test/scterm/test/runner.cljs#L29-L31#2020-04-2914:09Lucy Wang@thheller the cmd you give won't run fixtures, would it?#2020-04-2914:14thhellernot actually sure. might need to go through cljs.test for that#2020-04-2914:19Joel SödermanThanks for your quick responses 🙂 I will play around with you suggestions!#2020-04-2918:35tetriscodesAnyone get prepl working with shadow-cljs? Or can point me in the right direction#2020-04-2918:55tetriscodesUsing vim conjure and setting :prepl {:app 5557}} and when conjure tries to connect, I get a Stream Closed: http://java.io.IOException#2020-04-2918:56OlicalI never managed to get prepl to work nicely with Conjure I'm afraid, it requires a few more patches to shadow-cljs (and every other prepl implementation tbh)#2020-04-2918:56OlicalYou'll probably have better luck with Conjure's new develop branch which uses nREPL and works with shadow-cljs REALLY well.#2020-04-2918:57OlicalYou get completion and go to def too 😄 same key bindings, no pre-compile step, :help based docs. It's a lot better.#2020-04-2919:00tetriscodesAwesome. So dev branch supports prepl and nrepl going forward?#2020-04-2919:02OlicalJust nREPL today, but prepl is on my roadmap. The prepl won't be as feature rich, but I hope to add some support for it.#2020-04-2919:02OlicalContinuing conversation in the #conjure channel since this is Conjure specific really.#2020-04-2919:02tetriscodesDoesn’t master support prepl?#2020-04-2919:03tetriscodesok#2020-04-2919:46yendais there a way to prevent objects like goog.i18n.NumberFormatSymbols_en to be advanced compiled?#2020-04-2920:00thheller@yenda you mean the object name itself or the object keys/vals?#2020-04-3006:37yendaThe object key/values#2020-04-3006:39yendaI require it in the require, then I want to update a key after js->clj but it's advanced compiled#2020-04-3010:12thhelleryou can use the simplified externs https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2020-04-3010:12thhellerand just list the property names, then it shouldn't rename those and allow swapping?#2020-04-3010:15thhellerI'm not actually sure how google handles localization. there is a bunch of stuff already built-in so there should be ways to get this done#2020-04-3010:16thhellerI haven't looked into it much#2020-04-3010:27yendaok thanks yeah it does we just have a special case where we want to format a currency number but without adding the symbol to the formatting#2020-04-2921:21Patrick TruongHello all, I’m working on setting up re-frame-10x with my project. However, it is not registering my app-db (I can inspect _frame.db.app_db.state and see my re-frame db) in my re-frame-10x tool. I know using shadow-cljs with this library required some extra configs so I followed the sample for conduit project as closely as I could: https://github.com/jacekschae/conduit-re-frame-10x-demo/blob/master/shadow-cljs.edn However, for their shadow-cljs.edn, this is their :modules setup:
:modules          {:main {:entries [devtools.preload
                                      day8.re-frame.trace.preload
                                      conduit.core]}}  
but my shadow-cljs.edn looks like this:
{:deps   true
 :builds {:app {:target     :browser

                :output-dir "public/out"

                :asset-path "/out"

                :modules    {:main {:init-fn alpha-journal.core/main}}

                :compiler-options {:closure-warnings {:global-this :off}
                                   :closure-defines {"goog.DEBUG" true
                                                     "re_frame.trace.trace_enabled_QMARK_" true
                                                     "_frame.tracing.trace_enabled_QMARK_" true}
                                   :optimizations :whitespace}

                :devtools   {:http-root "public"
                             :http-port 8020
                             :after-load alpha-journal.core/main
                             :preloads  [devtools.preload
                                         day8.re-frame-10x.preload]}}}}
How can I setup my preloads while using my :init-fn? Is this possible?
#2020-04-2921:22thhellerthat project is setup as a demo of re-frame-10x using a release build setup so don't use it as an example for a regular project#2020-04-2921:24thhelleryou config looks correct#2020-04-2921:24thhellernot sure what you mean by :init-fn? how is that related?#2020-04-2921:26Patrick Truong@thheller so currently I’m not getting any info in my dashboard for my app-db. My first thought is that I wasn’t using the
[devtools.preload
day8.re-frame.trace.preload]
because I omitted using :entries for :init-fn . I’m not sure if that is the reason for my dashboard not picking up on my app-db or something else
#2020-04-2921:27thhellersorry I don't quite understand what your issue is. :init-fn is effectively the same as you specifying :entries [alpha-journal.core] it makes no difference as far as re-frame-10x is concerned?#2020-04-2921:28thhellerand the preload ensures it is running before the init so I don't really know what you are asking about here?#2020-04-2921:28thheller(I also don't use re-frame-10x so probably better to ask someone that does)#2020-04-2921:33Patrick TruongTo clarify why I thought :init-fn might be problematic in my case, the example case has the vector:
:entries 
[devtools.preload
 day8.re-frame.trace.preload
 conduit.core]
but my case I only include my run function :init-fn: alpha-journal.core/main so I don’t explicitly call for any preloads except in the devtools (which is only when it hot reloads?). This could be completely unrelated to my problem, but it was the one that seemed most potentially problematic since I figure I wasn’t loading the preloads. My then question was how can I load preloads while using :init-fn rather than :entries. Back on your comment saying that the conduit app is a release example. Does that mean I don’t need the :compiler-options and :preloads in :devtools if I were to create a minimum working example? According to this doc, it seems like shadow-cljs doesn’t require any extra config? Is that true? https://github.com/day8/re-frame-10x/blob/master/docs/Advanced-Setup.md Thanks for all the help @thheller! I will ask the re-frame channel if this has nothing to do with my shadow-cljs settings
#2020-04-2921:34thhelleryour setup is correct#2020-04-2921:34thheller:preloads is a way to add entries for development only#2020-04-2921:34thhellerso in development your :entries are literally what you just posted#2020-04-2921:39thhelleroh wait I remember something#2020-04-2921:39thhellerI think this has something to do with using rf/dispatch in your :init-fn#2020-04-2921:39thhellerso your first dispatch is async and then 10x doesn't pick it up or so#2020-04-2921:40thhellerso if you do a dispath in your :init-fn try switching it to dispatch-sync instead\#2020-04-2921:40Patrick TruongHmm that’s strange since I already should be using that one:
(ns alpha-journal.core
  (:require
   [reagent.core :as r]
   [reagent.dom :as dom]
   [re-frame.core :as rf]
   [alpha-journal.events]
   [alpha-journal.views :refer [app]]))

(defn render
  []
  (dom/render [app]
              (js/document.getElementById "app")))

(defn main
  []
  (rf/dispatch-sync [:initialize])
  (render))
#2020-04-2921:40thhellerok then I have no clue sorry#2020-04-2921:40thhellermaybe try dispatch instead, maybe it was the reverse#2020-04-2921:42thhelleror maybe try
(defn main
  []
  (js/setTimeout
    (fn []
      (rf/dispatch-sync [:initialize])
      (render))
    100))
#2020-04-2921:42thhellerI vaguely remember something about timing issues but not really sure anymore. long time ago.#2020-04-2921:44Patrick TruongOkay so I found some things that might be related to shadow-cljs. So this were my steps to get it working: 1. I loaded my app (re-frame-10x shows nothing) 2. I made a change to a view file and saved 3. Hot reloaded 4. My app now shows the db in re-frame-10x#2020-04-2921:44Patrick TruongI’m going to try the setTimeout now as well#2020-04-2921:46Patrick TruongsetTimeout didn’t work. I’m just curious if the hot reloads are running something that my first load isn’t#2020-04-2921:47thhellermaybe increase the timeout? I don't have a clue how long 10x takes to initilaize
#2020-04-2921:47thhellertry 2000 just to rule out thats not the problem#2020-04-2921:48Patrick TruongYeah I tried with 10000 and it doesn’t work#2020-04-2921:49thhellerok then I have no clue. as someone that actually knows how this is supposed to work. 😛#2020-04-2921:49thhellerignore the default docs .. the only difference you have in shadow-cljs is that you don't specify a :main but instead have :modules with a :init-fn#2020-04-2921:50Patrick TruongHaha, @thheller thanks for the help and clarifying about the docs 🙂. I’ll see if I could figure something out and ask around as well#2020-04-2921:52thhellerdunno how current this is https://github.com/mhuebert/shadow-re-frame#2020-04-2921:56Patrick TruongI’ll check that out, thanks#2020-04-2922:08Patrick Truong@thheller earlier, I mentioned this briefly: > Back on your comment saying that the conduit app is a release example. Does that mean I don’t need the :compiler-options and :preloads in :devtools if I were to create a minimum working example? To clarify, are the :compiler-options settings only for releasing an app? ex. 
:compiler-options {:closure-warnings {:global-this :off}
                                   :closure-defines {"goog.DEBUG" true
                                                     "re_frame.trace.trace_enabled_QMARK_" true
                                                     "_frame.tracing.trace_enabled_QMARK_" true}
                                   :optimizations :whitespace}
Thanks for explaining this all to a beginner like me 🙇
#2020-04-2922:19sergey.shvetsHi! What is the best way to deal with the runtime config in shadow-cljs? E.g. I want to pass different firebase credentials depends on where I deploy. Thanks in advance!#2020-04-2922:24SpacemanSo I have a promise in a test like so:
(deftest login-test
  (day8.re-frame.test/run-test-async
   (testing "login test"
     (async done
            (go
              (let [_ (<p! (js/Promise. (see/landing!)))

                    ]
                (prn "done")
                )
              )
            (done)
            )
     )
   )
  )
And running this test just hangs. What do you think is causing this?  Oh yeah, I'm also getting this error on evaluating just the js/Promise part, but have no clue what it means:
TypeError: Promise resolver #<cmp> is not a function
TypeError: Promise resolver #<cmp> is not a function
    at new Promise (<anonymous>)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:2)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
#2020-04-2922:26sergey.shvetsYou need to call (done) function when your async code finished. Here is the good section if you use core.async https://github.com/wilkerlucio/wsscode-async#javascript-async-tests#2020-04-2922:27sergey.shvetsOr this doc has a better example: https://clojurescript.org/tools/testing#async-testing#2020-04-2922:28sergey.shvetsThe problem with your code is most likely that async macro accepts only two arguments and your (done) call is 3rd arg, but I can't check it right now.#2020-04-2922:29sergey.shvetsIf you move your (done) inside the (go) block it should work.#2020-04-2922:41Spaceman@U4EFBUCUE Now there's no error, but it just hangs at "testing my.namespace"#2020-04-2922:41Spaceman"done" isn't printed#2020-04-2922:43sergey.shvetsis your promise ever resolved?#2020-04-2922:43sergey.shvets
<p!
will wait for promise to be resolved or rejected before continuing
#2020-04-2922:44Spacemanhow would I know?#2020-04-2922:44sergey.shvetswhat is see/landing! doing?#2020-04-2922:44Spacemanevaluating that promise part gives me this though:
TypeError: Promise resolver #<cmp> is not a function
    at new Promise (<anonymous>)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:118)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:7:3)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
#2020-04-2922:46sergey.shvetsTry:
(-> (js/Promise. (see/landing!)
    (.then (fn [res] <some print>))
    (.catch (fn [err] <some other print>)))
#2020-04-2922:48sergey.shvetsOh, wait, I know what the problem is: (js/Promise. (fn [resolve reject] <your code that need to call either resolve or reject> )#2020-04-2922:48sergey.shvetsdisregard the message with threading macro above, it will show you the same error#2020-04-2922:50Spacemanbut see/landing is supposed to return nil#2020-04-2922:53Spaceman@U4EFBUCUE, I don't quite understand what you mean. Would you give a full example how I would run these two functions sequentially in the test: (f1) (f2) where f1 returns nil?#2020-04-2923:02sergey.shvetsis see/landing async? Based by name I assume so.#2020-04-2923:05sergey.shvetsIf it is async, then you need to somehow let your test know that it finished working. You can do this by either having this function return async.core channel and function will post a value on the channel. It will look like this:
(deftest test-async
   (async done
      (go
        (is (= (<! (see/landing!) nil))
        
        (done))))
#2020-04-2923:06sergey.shvetsAlternatively, you can pass callback to the see/landing and let it call it once it is done:
(deftest test-async
  (async done
     (let [callback #(done)]
        (see/landing! callback))
#2020-04-2923:08sergey.shvetsor with a promise:
(deftest test-async
  (async done
     (let [_ (<p! (js/Promise. (fn [resolve reject] (see/landing! resolve reject))) ]
        (done))
#2020-04-2923:08sergey.shvets(parens) might be off since I'm typing it directly in chat#2020-04-2923:09sergey.shvetsIn last two cases (see/landing!) must call the callback it gets passed as an argument#2020-04-2923:18SpacemanWhat about if I have something that follows this see/landing! function that I want to execute after see/landing?#2020-04-2923:19SpacemanThis didn't evaluate the second function as expected:
(deftest test-async
  (async done
         (go
           (<! (see/landing!))
           (<! (interact/click-login-btn))
               (done))))
#2020-04-2923:19Spacemani.e., interact/click-login-btn#2020-04-2923:26sergey.shvetsSo, <! is an operation that takes from channel. go block will wait until something is posted on the channel to resume code that follows. If you want a sequential operation execution you need to make sure that you post/read from the same channel. It is hard to explain in a message. I recommend reading this to get yourself more familiar with core.async: https://www.braveclojure.com/core-async/#2020-04-2923:27sergey.shvetsBut reading between the lines, it looks like you're trying to make a UI test that will wait for the landing page to load and then run something#2020-04-2923:28sergey.shvetsWhat do you use to load your landing page? Most likely it returns promise that you can chain your checks to.#2020-04-3008:44SpacemanI'm using the react-testing-library's render function to mount the component to the dom. After some familiarity with the async I have the following simple test:
(deftest test-async

  (let [result (waitFor (+ 1 2)) ]
    (async done
           (go
             (is (= 3 (<p! result)))
             (prn "done")
             (done)
             )
           )
    
    ))
waitFor is a react-testing-library function that returns a promise. But this gives me the following error:
ERROR in (test-async) (Error:NaN:NaN)
expected: (= 3 (<p! result))
  actual: #error {:message "Promise error", :data {:error :promise-error}, :cause #object[TypeError TypeError: Cannot read property 'current' of undefined]}
"done"
#2020-04-3015:32sergey.shvetsIt looks like the promise is rejected with an error. I'm not familiar with waitFor and what it does.#2020-04-3008:26Joel SödermanRegarding running just one test with shadow-cljs. Thanks @wxitb2017 and @thheller for the help yesterday! In the end I built upon with Lucy’s code and added the functionality to provide several substrings that the test is matched against. I put the code in a gist in case it’s of use to someone else: https://gist.github.com/johesoman/16d765d158e0018ed20f9aafc6d4501f#2020-04-3015:02knubie@UPYGWGFG8 I made a library awhile ago for running a single test in cljs (with fixtures). Maybe you’ll find it useful? https://github.com/knubie/cljs-run-test#2020-04-3017:40Joel SödermanVery cool! Thanks 🙂#2020-05-0414:51thhellerthe new shadow-cljs release 2.8.110 adds some options to the :node-test target output#2020-05-0414:51thhellerso you can run node out/tests.js --list to see tests it knows#2020-05-0414:52thhellerand run a single test via node out/tests.js --test=some.ns/foo#2020-05-0414:52thhelleror test a ns via node out/tests --test=some.ns#2020-05-0414:52thhelleror multiple via node out/tests.js --test=some.ns,other.ns#2020-05-0414:52thhellermore to come#2020-05-0414:57Joel SödermanAwesome! Thank you for being so responsive 🙂#2020-04-3011:24Chris McCormickwhat's a good way to diagnose an error that only occurs when --debug is not passed during app release?#2020-04-3011:53yendatried shadow-cljs check?#2020-04-3012:02thhellerlikely a externs issue yes#2020-04-3012:04yendabtw why does shadow-cljs check reports cljs.core.PersistentArrayMap expressions are not callable as a warning?#2020-04-3012:04yendaI do that all the time 😄#2020-04-3012:05thhellernot sure I know which warning you mean?#2020-04-3012:06thhellercheck in general reports many false positives and non-issues#2020-04-3012:06thhellerthat why its not documented anywhere 😛#2020-04-3012:06thhellerit can be useful to find issues but its definitely not user friendly#2020-04-3012:07thheller@chris358 --debug also turns on :pseudo-names which still renames everything but uses longer names that are less likely to clash with anything#2020-04-3012:07thhellerso if your app has issues without that it is likely that you maybe have something in the page that defines a global variable or so that then clashes with the CLJS code#2020-04-3012:08thhellerone common issue in the past for example is google analytics that creates that the closure compiler would also use unless you had externs telling it not to#2020-04-3012:09thhellerwith :output-wrapper defaulting to true nowadays thats less of an issue#2020-04-3012:09thhellerbut can still happen. js->clj is also known to cause issues so if you use that with a lot of JS data that can be another cause#2020-04-3012:11Chris McCormickinteresting, thanks for the pointers!#2020-04-3012:11Chris McCormickit started happening after i slurped in a few new libraries so a global name clash could indeed be the cause.#2020-04-3012:13pmooserI'm working on my application, using shadow-cljs, with the bootstrap cljs support ... And if I serve the index.html via my own server (instead of the embedded shadow-cljs dev http server), I see an error from (I think) the bootstrap cljs stuff trying to load resources over a websocket. But I can't exactly see what it is trying to do or request - is there any advice on how I should debug this? It's perplexing, but if these resources fail to load, my bootstrap cljs eval stuff stops working.#2020-04-3012:14thhellerbootstrap doesn't load anything over websocket#2020-04-3012:14thhellerjust look at the browser console. it should be making regular XHR requests to get the files.#2020-04-3012:15pmooserI am looking at the console. It isn't totally evident what is being done. Here, for example, is the error from the console:#2020-04-3012:15pmooser
Uncaught SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Transit$JSONUnmarshaller.reader.JSONUnmarshaller.unmarshal (reader.js:39)
    at Transit$Reader.reader.Reader.read (reader.js:59)
    at Object.cognitect$transit$read [as read] (transit.cljs:137)
    at Object.shadow$cljs$bootstrap$browser$transit_read [as transit_read] (browser.cljs:23)
    at .XhrIo.G__63340 (browser.cljs:33)
    at goog.net.XhrIo.goog.events.EventTarget.fireListeners (eventtarget.js:285)
    at Function.goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:383)
    at goog.net.XhrIo.goog.events.EventTarget.dispatchEvent (eventtarget.js:196)
    at .XhrIo.onReadyStateChangeHelper_ (xhrio.js:871)
#2020-04-3012:15pmooserNot exactly super clear.#2020-04-3012:15thhellerjust look at the request it made#2020-04-3012:15thhellerand click the url it requested to open in a new tab#2020-04-3012:16thhellerit expects a JSON response but likely your server returned HTML instead?#2020-04-3012:16pmooserAh, no, I think it's because I don't understand the ... I'm not sure the right term, I'm not sure how the paths are constructed.#2020-04-3012:16pmooserSo it's asking for the resource (I think): http://localhost:8098/bootstrap/index.transit.json#2020-04-3012:17pmooserAnd not (for example) js/bootstrap/ ...#2020-04-3012:17thhellerso you are on http://localhost:8098#2020-04-3012:17pmooserYes (I am on localhost 8098)#2020-04-3012:17thhelleryes the path it requests defaults to /bootstrap#2020-04-3012:17pmooserI don't understand why some requests are /js/... and these are /bootstrap#2020-04-3012:17pmooserAre there any knobs on my end that can control that?#2020-04-3012:17thhelleryou can configure the path in the boot/init call you do#2020-04-3012:18thhellerjust {:path "/wherever"} in the map you already pass in#2020-04-3012:19pmooserAh perfect, let me see if I can do it that way instead of by adding another route on the server ...#2020-04-3012:19thhelleryou can put it wherever you want#2020-04-3012:20thhellerthe default is just /bootstrap just config :path "/js/bootstrap" if thats the dir you are putting the files in currently#2020-04-3012:20pmooser@thheller Thank you so much. I don't know how many hours that would have taken me to figure out.#2020-04-3012:20pmooserThat works perfectly.#2020-04-3013:58metehanhi, when I run shadow-cljs in a particular project it gives "java heap memory.." error on windows. how can i increase the memory limit#2020-04-3014:06metehanthis one https://github.com/flexsurfer/rn-shadow-steroid#2020-04-3014:11thheller@m373h4n "java heap memory.." ?#2020-04-3014:17metehanlike this
Exception in thread "async-thread-macro-1" java.lang.OutOfMemoryError: Java heap space
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetPublicMethods(Unknown Source)
        at java.lang.Class.privateGetPublicMethods(Unknown Source)
        at java.lang.Class.getMethods(Unknown Source)
        at clojure.lang.Reflector.getMethods(Reflector.java:498)
        at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:436)
        at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invokeStatic(fs_watch_jvm.clj:17)
        at shadow.cljs.devtools.server.fs_watch_jvm$poll_changes.invoke(fs_watch_jvm.clj:16)
        at clojure.core$map$fn__5866.invoke(core.clj:2753)
        at clojure.lang.LazySeq.sval(LazySeq.java:42)
        at clojure.lang.LazySeq.seq(LazySeq.java:51)
        at clojure.lang.RT.seq(RT.java:535)
        at clojure.core$seq__5402.invokeStatic(core.clj:137)
        at clojure.core$apply.invokeStatic(core.clj:660)
        at clojure.core$mapcat.invokeStatic(core.clj:2783)
        at clojure.core$mapcat.doInvoke(core.clj:2783)
        at clojure.lang.RestFn.invoke(RestFn.java:423)
        at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invokeStatic(fs_watch_jvm.clj:46)
        at shadow.cljs.devtools.server.fs_watch_jvm$watch_loop.invoke(fs_watch_jvm.clj:33)
        at shadow.cljs.devtools.server.fs_watch_jvm$start$fn__7286.invoke(fs_watch_jvm.clj:77)
        at clojure.core.async$thread_call$fn__3186.invoke(async.clj:484)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
#2020-04-3014:18thhellerthats very odd. never seen that before.#2020-04-3014:18thhellerdo you have like a billion files on the classpath?#2020-04-3015:16metehani checked there are 39.604 files and 5528 folders ( i don't know what is classpath)#2020-04-3015:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_important_concepts#2020-04-3015:37metehanthank you#2020-04-3015:56ullrichDoes (js/require …) work with shadow to require local .js files or can I only require them in the namespace?#2020-04-3016:13thhellerdepends on the target you are using?#2020-04-3016:14thhellerbrowser builds only support require in ns. node you can just use js/require#2020-04-3016:16ullrichHow about react-native? 🙂#2020-04-3016:18thhellerthat should be fine, already works for images#2020-04-3016:23thheller@m373h4n how much ram does you machine have? you can tune the memory settings via :jvm-opts ["-Xmx2G"] (for max 2GB ram) in top level shadow-cljs.edn. need to configure via project.clj/deps.edn if you use those.#2020-04-3016:24thhellerbut it is odd that its running out of memory in places that aren't very memory intense#2020-04-3016:24thhellerjust make sure you don't have node_modules or so in your classpath#2020-04-3016:24metehani have 16gb ram#2020-04-3016:25thhellerthen it should be allowed to use 4GB with default memory rules#2020-04-3016:25thhellerthat is more than enough#2020-04-3016:25thhellerare you just generally out of ram maybe? too much other stuff using everything up?#2020-04-3016:25metehanso :jvm-opts ["-Xmx2G"] for 2gb right#2020-04-3016:25thhelleryou probably want to tune the memory DOWN then#2020-04-3016:25thhellerso try -Xmx1G#2020-04-3016:26metehanok#2020-04-3016:28metehanit worked 🙂#2020-04-3023:59Mr. Savyis there a quick command for reloading the s-cljs server after making changes to the shadow-cljs.edn file or do I just need to restart it?#2020-05-0100:21bedersfor most changes other than dependencies it seems to just magically work for me#2020-05-0100:24Mr. Savyoh snap you're right. It looks like I just needed to save changes and switch windows.#2020-05-0106:50thhellerbuild config changes should be automatically applied yes#2020-05-0106:50thhellerjust dependencies, source-paths and some others like nrepl require a restart#2020-05-0108:57andrehi, what would be the better way to solve this
[2020-05-01 10:47:31.625 - INFO] duplicate resource taoensso/timbre.cljs on classpath, using jar:file:/.m2/repository/com/taoensso/timbre/4.10.0/timbre-4.10.0.jar!/taoensso/timbre.cljs over jar:file:/.m2/repository/status-im/timbre/4.10.0-2-status/timbre-4.10.0-2-status.jar!/taoensso/timbre.clj
[2020-05-01 10:47:31.640 - INFO] duplicate resource taoensso/timbre/appenders/core.cljs on classpath, using jar:file:/.m2/repository/com/taoensso/timbre/4.10.0/timbre-4.10.0.jar!/taoensso/timbre/appenders/core.cljs over jar:file:/.m2/repository/status-im/timbre/4.10.0-2-status/timbre-4.10.0-2-status.jar!/taoensso/timbre/appenders/core.cljs
at least do not show this info, this duplication we only have in dev
#2020-05-0109:05thhellerwhy would it not show this info? seems kinda important?#2020-05-0109:06thhellerI mean if you intent is to override that file then its kinda important to know that is not happening?#2020-05-0109:07andreyeah its important I'm not arguing 🙂#2020-05-0109:08andreis there something like :exclusions ?#2020-05-0109:09thhellerwhat is the issue? I don't quite know what you are trying to solve here?#2020-05-0111:25conanHi, I run the following script in Cursive to start shadow-cljs:
(require
  '[shadow.cljs.devtools.api :as api]
  '[shadow.cljs.devtools.server :as server])
(server/start!)
(api/watch :app)
(api/repl :app)
We've recently made some build changes and bumped shadow's version, and I cannot get this to start any more. I get errors like Syntax error (NoSuchFieldError) compiling at (shadow\cljs\devtools\api.clj:1:1) ES3 and Assert failed: (symbol? read-ns) Any ideas on what I'm doing wrong?
#2020-05-0112:11Thijs CreemersIs there a prefered way to merge multiple shadow-cljs projects into one :browser UI? We plan to create UI components per service and merge them together to get a frontend app that communicates to their respective services?#2020-05-0113:33thheller@conan that is due to a version conflict. need to resolve your conflicts. most likely a mismatched clojurescript version and maybe closure-compiler/closure-library.#2020-05-0113:59conanah, ok i'll check that. thank you, have a great weekend!#2020-05-0113:34thheller@thijs.creemers if you are asking about combining multiple builds into one single UI then there is no support for that CLJS in general is not suited for that#2020-05-0113:35thhellerif you are talking about creating multiple libraries/components and using them to build one UI that is fine#2020-05-0113:41Thijs Creemers@thheller Thank you for the answer. So the way to go for is making a UI library/component per service and combine them in one frontend app.#2020-05-0113:44thhellerI guess? Don't know enough about what you are trying to do. Loading multiple different builds on the same page will give you nothing but trouble so you should only load one, that is the only advice I can give without more info#2020-05-0113:58Thijs CreemersYou are right, I did some experiments and foud that it is trouble indeed.#2020-05-0113:59Thijs CreemersI will give it a try with cljs libraries.#2020-05-0115:15mauricio.szaboEverytime I post an issue on Shadow-CLJS, I feel the strenght of this project: most of the time, the bug is not on shadow, but on some dependency that I hardcoded my project... great job! 🙂#2020-05-0115:16thhelleryeah I wish there were an easy way to sort out dependency issues 😞#2020-05-0115:17thhellerits the most common issue people have but I have no idea how to fix it given that shadow-cljs is not always in charge#2020-05-0115:18mauricio.szaboDo you think it's possible for shadow-cljs to just remove the conflicting dependencies it finds from :depencies vector?#2020-05-0115:18mauricio.szabo(and issue an warning, or something?)#2020-05-0115:18thhelleralready doing that for clojurescript/clojure#2020-05-0115:19thhellerdon't want to hardcode too much since newer versions rarely are an issue#2020-05-0119:05SpacemanIs there a cljs test runner that works on emacs and not in the browser that offers good navigation between tests and simplifies information about which tests passed and which failed?l#2020-05-0119:49isakAnyone see any compiler/caching related issues with this code? Inside a translation macro:
(when env/*compiler*
      (validate-consistency! @env/*compiler* i18n-call) ;; The new thing
      (swap! env/*compiler* update-in [::ana/namespaces current-ns ::i18n-calls] vec-conj i18n-call))
That function:
(defn validate-consistency! [compiler i18n-call]
  (let [other-i18n-calls (for [[_ ns-data] (::ana/namespaces compiler)
                               i18n-call (::i18n-calls ns-data)]
                           i18n-call)
        conflict (some
                   (fn [other-i18n-call]
                     (get-conflict i18n-call other-i18n-call))
                   other-i18n-calls)]
    (when conflict
      (throw
        (ex-info
          (str
            "Translation calls with the same arguments cannot have differing translations.\n"
            (pr-str (:msg i18n-call))
            "\nvs.\n"
            (pr-str (:msg conflict)))
          {:translation i18n-call
           :conflicting-translation conflict})))))
cc @thheller
#2020-05-0119:56thheller@isak I see a lot of issues yes 😛#2020-05-0119:56isak😬#2020-05-0119:56thhellerunless the namespace that uses that depends on every other namespace this is checking you'll run into a lot of timing issues#2020-05-0119:56thhellerparallel compile might still be compiling namespaces and so on#2020-05-0119:57isakOk, but will that affect anything other than which callsite receives the error? because that doesn't matter in this case#2020-05-0120:01thhellerI have no idea in which context you are using this or what ::i18n-calls represent so I cannot comment on that#2020-05-0120:01thhellerthrowing an error based on other namespace data seems like a problem to me and would probably be something I would do as a post-compile hook#2020-05-0120:02thhellerin general macros shouldn't do side effects like that IMHO#2020-05-0120:03isakThe i18n-calls are just the data captured from macro invocations like this: (tr [:api-token/confirm-delete "Are you sure you want to delete this API token?"])#2020-05-0120:04isakSo I would like to throw an error if there are two translation calls that have the same namespaced keyword, but different text. Can this be done in a post-compile hook?#2020-05-0120:05isakWould it actually stop compilation, or just print a message to the console or something?#2020-05-0120:05thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2020-05-0120:05thhellerhook into :compile-finish and throw the error if it finds one#2020-05-0120:06isakOk, I'll fix it, thanks#2020-05-0120:06thhellerthe build-state argument has a :compiler-env key#2020-05-0120:06thhellerthat is the value you'd otherwise get out of the @env/*compiler* atom, so it has the ::ana/namespaces#2020-05-0120:06isakok, right#2020-05-0120:15knubie@thheller I did some digging into my websocket/cordova issue today.#2020-05-0120:16knubieI’m using ionic wkwebview plugin which serves up the index.html from a server.#2020-05-0120:16knubieIn the plugin settings you can set a custom hostname.#2020-05-0120:16knubieIf I set a hostname like foo.bar, I get a websocket error like: WebSocket network error: WebSocket connection failed because it violates HTTP Strict Transport Security.#2020-05-0120:17knubieAnd the websocket url is …/browser#2020-05-0120:17knubieBut changing the hostname back to localhost works without issue.#2020-05-0120:18knubieNot sure if this is something shadow-cljs can/should fix or just something I need to fix through my own configuration.#2020-05-0120:18knubieJust thought I’d let you know what I found out.#2020-05-0120:18knubieThis is in iOS btw, so it might be specific to safari.#2020-05-0120:20thhellershadow-cljs default to using js/document.location.host when trying to figure out what it should connect to#2020-05-0120:20thhelleryou can use :devtools {:use-document-host false} to use localhost instead#2020-05-0120:20thhelleror you can use :devtools-url to override the url completely https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2020-05-0120:21knubieWow, there’s an option for everything haha#2020-05-0120:21knubiethat’s great, thanks#2020-05-0123:28Pavel KlavíkHi, I am having some problems with code reloading. I have multiple defs scattered in multiple namespaces, all contained in one def called config which is used in mount-root for rerendering. When I do changes in one of the namespaces included into config, Shadow-cljs logo appears but the value is not propagated into config. If I change the config itself, the value is finally propagated. How does this work?#2020-05-0123:30Pavel KlavíkIt seems it does not work when I do transitive change, i.e, config contains the symbol a in ns a, which contains the symbol b in ns b, then updating b does not change config.#2020-05-0123:32Pavel Klavíknot sure whether it makes any difference, but everything is placed in .cljc namespaces.#2020-05-0123:46Pavel KlavíkLooking at the console, only namespaces a and b are reloaded, not the one with config#2020-05-0123:50Pavel KlavíkAdding ^:dev/always to the config namespace fixes the problem, but not sure why it happens#2020-05-0200:39lilactownshadow-cljs only reloads the namespace and direct dependents by default#2020-05-0200:41lilactownif you’re doing something like:
(ns config
  (:require a))

(def values
  {:a a/value})
and a/value relies on something in namespace b, then editing b will not update the value you’ve saved a reference to in your config namespace
#2020-05-0200:41lilactownI believe this behavior is consistent with Clojure#2020-05-0200:42lilactownthe trick is to use a var (at least if while you’re developing):
(def values
  {:a #'a/value})
or, a function:
(defn values []
  {:a a/value})
#2020-05-0201:53Pavel Klavíkhmm, changing values into fn helped, but what is the difference? that the value is recomputed everytime values is called?#2020-05-0203:06Lucy Wang@pavel.klavik it depends how you use it. If you use it like def config {:a (a/values)} then it's only recomputed everytime the ns is reloaded, which is prob. exactly what you want.#2020-05-0207:45thheller@pavel.klavik holding values from other namespaces is not a good idea since it hinders hot-reloading. you can use :devtools {:reload-strategy :full} in your build config to always reload all dependent namespaces but that can get a lot slower#2020-05-0213:00Pavel KlavíkThx. In this particular case, probably both solutions are ok since the project is tiny. But it is good to understand how it works.#2020-05-0207:55andrehi, is there a way to listen to compiling errors in the app? i would like to indicate it somehow in the react native app, thanks#2020-05-0207:58thhelleryou can copy this file into your src path and modify it however you like https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/react_native.cljs#2020-05-0207:59thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/react_native.cljs#L156#2020-05-0207:59thhellerright now it just does nothing#2020-05-0208:00andrenice! thanks#2020-05-0208:06thhelleris there an easy way to show a warning or something that doesn't require knowing anything about other components on the page?#2020-05-0208:06thhellerthat ideally works in expo and react-native?#2020-05-0208:09andreim not sure about expo, but at least would be useful to have an option so shadow throws a warning, how figwheel does#2020-05-0208:09andrei don't have warning from figwheel now, but here is how warning looks in rn app#2020-05-0208:09andre#2020-05-0208:12thhellerI don't do react-native so someone actually knowing how it works can probably build something nice#2020-05-0208:12thhellerhappy about a PR doing it in a generic way#2020-05-0208:13andrewe just migrated to shadow so for sure we'll contribute#2020-05-0222:23SpacemanDo you have a react native template that you can share?#2020-05-0222:23SpacemanLike re-natal for Figwheel?#2020-05-0304:58andrehttps://github.com/flexsurfer/ClojureRNProject#2020-05-0214:41awb99I have question: shadow-cljs is getting transient npm dependencies and writes them to package.json. So far so good. But now I also use npm dependencies in the app I am building. And now I have a package.json that is somehow changed by transient dependencies, and partially by the npm dependencies of my app. Now this can get confusing.. as package.json does not allow comments inside. Is it possible to define npm dependencies for my app somewhere else, so that the package.json can become a pure build-artefact do shadow-cljs ?#2020-05-0214:46amalantonyWhile installing dependencies for a new shadow-cljs project, I get this error: shadow-cljs - dependency update failed - Could not transfer artifact thheller:shadow-cljs:jar:aot:2.8.109 from/to clojars (): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Any ideas on how I can resolve this?#2020-05-0214:49amalantonySeems like a Java related issue. But this does not come up in a Clojure Lein project that I have.#2020-05-0215:37thheller@amalantony what java version do you use? maybe its too old?#2020-05-0215:37amalantony@thheller I have OpenJDK 10.#2020-05-0215:38thhellerthe error is about missing SSL certs, so if you use an OS installed version you might need to update that#2020-05-0215:38thhelleryeah jdk10 isn't officially supported anymore. either use jdk11 for long-term-support or use the newest jdk14 and keep updating with every new version#2020-05-0215:39thhellerhttps://en.wikipedia.org/wiki/Java_version_history#2020-05-0215:39thhellerjava10 ended support on September 2018 for OpenJDK#2020-05-0215:42amalantony@thheller thank you, I’ll try with the latest version.#2020-05-0215:42thhellerit might be enough to update the ssl certs on your system but I don't know how to do that 😛#2020-05-0215:47amalantony@thheller Updating the JDK version seems to have done the trick! I suppose it’s easier than updating the ssl certs since it’s a simple brew install command on Mac 🙂.#2020-05-0216:53Pavel KlavíkHi, is it possible to run watch on multiple builds at the same time? My shadow-cljs.edn looks like this:
{:source-paths ["src"]
 :dependencies [...]
 :nrepl        {:port 9000}
 :builds       {:client  {:target           :browser
                          :output-dir       "resources/public/js/compiled"
                          :asset-path       "/js/compiled"
                          :modules          {:main   {:init-fn    orgpad.client.core/init}}
                          :devtools         {:after-load     orgpad.client.core/mount-root
                                             :watch-dir      "resources/public"
                                             :browser-inject :main
                                             :loader-mode    :script}}
                :landing {:target     :browser
                          :output-dir "landing/resources/js"
                          :asset-path "/js"
                          :modules    {:main {:init-fn orgpad.landing.dev/init}}
                          :devtools   {:http-root      "landing/resources"
                                       :http-port      3500
                                       :after-load     orgpad.landing.dev/mount-root
                                       :watch-dir      "landing/resources"
                                       :browser-inject :main}}}}
#2020-05-0216:53thhellershadow-cljs watch client landing#2020-05-0216:53Pavel KlavíkI see#2020-05-0216:53thhelleror shadow-cljs server and start the builds from the ui (URL printed on startup, usually http://localhost:9630)#2020-05-0216:54Pavel KlavíkCool, thx.#2020-05-0222:22SpacemanEverytime I reload the page, the whole test namespace seems to disappear from shadow, and if I evaluate anything with cider in the test namespace, I get the following:
TypeError: Cannot read property 'address_input_bar_suggestions_QMARK_' of undefined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:22)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (: Cannot read property 'p__GT_c' of undefined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:98)
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:7:3)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
ERROR in () (TypeError:NaN:NaN)
expected: (some? (<p! (js/Promise.resolve (dom/mount-landing!))))
  actual: #object[TypeError TypeError: Cannot read property 'p__GT_c' of undefined]
How do I fix this?
#2020-05-0222:28Spacemanin fact all of the namespaces within test seem to disappear.#2020-05-0222:29SpacemanI do have the test directory in my source-paths though#2020-05-0222:37thhellerjust having something on the classpath means nothing. the files need to be actually required by your build.#2020-05-0222:38thhelleror use the :browser-test target which has rules to include all namespaces matching a regexp#2020-05-0222:44Spacemanhow do I require the files in my build?#2020-05-0222:44Spacemanautomatically?#2020-05-0300:21Lucy WangThe find there is a very easy to reproduce bug when using start-build/stop-build: 1. in a "yarn shadow-cljs clj-repl", run "(shadow/watch-set-autobuild! :app false)", then followed by "(shadow/watch-set-autobuild! :app true)" 2. now the cljs repl won't work anymore
missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)                                                                       (1/8 results) [30/121]
{}
ExceptionInfo: missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)
#2020-05-0300:21Lucy Wangcould be fixed by commenting out two lines:
--- a/src/main/shadow/cljs/devtools/server/worker/impl.clj
+++ b/src/main/shadow/cljs/devtools/server/worker/impl.clj
@@ -772,8 +772,8 @@
     ;; compile immediately, autobuild is then checked later
     (-> worker-state
         (assoc :autobuild true)
-        (build-configure)
-        (build-compile)
+        #_(build-configure)
+        #_(build-compile)
         )))
#2020-05-0302:04MatDCould anyone share how they work with logging (for debugging) using shadowcljs on Node? js/console.log sucks to print clojure map I found reference to shadowcljs inspect, which seems nice, but I can't make it work any other suggestions?#2020-05-0302:56knubie@UV2730B5K You could try chrome + https://github.com/binaryage/cljs-devtools#2020-05-0303:58lilactownunfortunately connecting devtools to Node.js doesn't support custom formatters 😞#2020-05-0304:58Lucy Wangjust call cljs.core.str(foo) manually 🙂#2020-05-0305:15steveb8nPersonally, I connect a REPL and put (def foo foo) inside fns I want to debug. then just repl.#2020-05-0305:15steveb8nbasically the same flow as scope-capture on the jvm. I can’t figure out how to use it on node#2020-05-0305:16steveb8nalso this lib is great for digging into js objs https://github.com/applied-science/js-interop#2020-05-0305:16steveb8nalthough I’ve heard good things about cljs-bean as well#2020-05-0314:54knubie@U4YGF4NGM Are you sure? I could have sworn I’ve used it with node before.#2020-05-0316:45lilactownI might be wrong, but I remember running into that at some point#2020-05-0316:45lilactownwould be happy to be shown wrong 😄#2020-05-0413:23MatDThanks everyone#2020-05-0302:07MatD(to be more precise, shadowcljs inspect works in the repl, but not inside a test (deftest))#2020-05-0306:51thhellerinspect just works based off tap> so it should work everywhere that the shadow.remote runtime runs. if you use :node-test that won't work currently since it immediately exits after running the tests.#2020-05-0305:06SpacemanWhen I make any changes in my app, shadow seems to rebuild the app (the build message is shown in the repl), but I see the following:
scheduler.development.js:108 Uncaught TypeError: lastCallbackNode is not a function
    at flushFirstCallback (scheduler.development.js:108)
    at flushWork (scheduler.development.js:220)
    at MessagePort.globalValue.port1.onmessage (scheduler.development.js:612)
in the console, and when I refresh the page, the app still seems to be in the older state. How do I fix this?
#2020-05-0305:13Lucy Wanglooks like your own application's problem. What's the lib scheduler.js?#2020-05-0305:24sergey.shvetsHi! Is it possible that when I'm importing namespace like (ns (:require [imported.but.never.used])) shadow just removes this namespace? I have a macro in it that should run some code on first namespace load and it doesn't seem to be ever triggered.#2020-05-0306:49thheller@bear-z no shadow-cljs will never remove a require. relying on a macro side effect is a bad idea since the behavior will be different depending on many factors like parallel compilation and caching#2020-05-0317:16sergey.shvetsI think I don't understand how require works. If in the namespace impored.but.never.used I have a js/console.log at the top level, should it fire when I require it for the first time?#2020-05-0319:40thhellerrequire means that the runtime will ensure that the required namespace will be loaded before the namespace that required it#2020-05-0323:17sergey.shvetsAnd when namespace is loaded then any code that is not wrapped in function should be executed right away?#2020-05-0306:50thheller@wxitb2017 please report reproducible bugs to the shadow-cljs github. reports just get lost in slack.#2020-05-0315:17Lucy Wanghttps://github.com/thheller/shadow-cljs/issues/700 https://github.com/thheller/shadow-cljs/pull/701#2020-05-0310:26andrehi, I see this in logs after code is reloaded, but code reloaded just fine, I can see changes in the UI#2020-05-0310:26andreReactNative app#2020-05-0310:49thhellerlooks like an error from metro? did you disable every kind of reload provided by metro directly?#2020-05-0310:56andreyes rn reload is disabled#2020-05-0311:04thhellerI suspect metro might just be too eager in reading the file?#2020-05-0311:04thhellerI mean starting to read the while it is still being written?#2020-05-0311:05thhellerits a large file so might take a couple of ms to construct#2020-05-0311:12andremhm, yeah sounds reasonable, so its something related to metro not shadow, thanks, probably we shouldn't watch js changes because we don't use react native reload#2020-05-0311:12thhellerthe bundling failed message definitely isn't from shadow-cljs yes#2020-05-0311:37thheller@andre how do you like viz.js? I've been meaning to add a nice namespace dependency graph to the shadow-cljs UI but so far haven't found anything that is actually readable in larger projects. is viz.js useful or rather stay away?#2020-05-0312:18yenda@thheller he shared a screenshot of it in #re-frame#2020-05-0312:51thhellerI saw. thats why I asked. 😉#2020-05-0312:55andreI've never worked with such libs, so I looked a few, and kinda liked this one, because of simple API, lots of configurations if needed, dynamic nodes and edges, haven't had any issues with it, renders pretty fast and smooth, so for re-frisk it was a best fit , though I haven't tried other libraries, I'm totally fine with this one 🙂#2020-05-0314:06jjttjjI'm suddenly getting the error
The required namespace "" is not available, it was required by "cljs/util.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
For a bootstrap build. Is it possible to see where the cljs.util namespace is being brought in somehow?
#2020-05-0314:08thhellerbug in CLJS https://clojure.atlassian.net/browse/CLJS-3245#2020-05-0314:08jjttjjThanks!#2020-05-0314:09thhelleryou can create an dummy clojure/java/io.cljs in your source path with just (ns )#2020-05-0314:09jjttjjawesome thanks#2020-05-0314:12jjttjjAfter that I get
The required namespace ".File" is not available, it was required by "cljs/util.cljc".
#2020-05-0314:12jjttjj#2020-05-0316:47thhellerblame CLJS, not much I can do about that#2020-05-0316:55ak-coramhi, I'd like to bundle a node-script target including their dependencies into a single js-file (via :js-provider :shadow ). It's working, but I have to specify the entirety of the node standard library in :js-options :resolve to be already included, which doesn't seem to be the right way to go. Anything else I can do?#2020-05-0319:25thheller@ak407 I recommend just post-processing the file with something like https://github.com/zeit/ncc without any :resolve config#2020-05-0323:01Tim SmartHow do you access process.env in a Node script? (:-env js/process) is returning nil for me.#2020-05-0323:05dpsutton
ClojureScript 1.10.597
cljs.user=> (.-env js/process)
#object[Object [object Object]]
i think your interop is off. you want .- not :-
#2020-05-0323:05dpsutton:-env is a keyword so invoking that is looking up in js/process for an entry at that keyword#2020-05-0323:08dpsuttonand to be a bit more precise :-env is trying to look up something at that key, finding a non-associative object and returns nil.#2020-05-0323:09Tim SmartHaha yes, was just about to report back that it should be .-env, thanks.#2020-05-0323:11Tim SmartThis leads to my next question… Is it possible to have a development only file (ignored in SCM) like secrets.edn, and then have a release version that uses (.-env js/process)?#2020-05-0323:12Tim Smartsecrets.edn example: {:api-key "asdfasdf1234"} Then in release build {:api-key (.. js/process -env -API_KEY)}#2020-05-0323:15dpsuttonsure#2020-05-0323:16Tim SmartHow would you do it? Can you have a development only source path? In node I would usually use dotenv#2020-05-0323:16dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines are useful. At dev time you define a debug/development boolean and when that's set, read in dev-config.edn. otherwise use env or read prod-config.edn#2020-05-0400:06Tim SmartEnded up doing: (merge (read-string (shadow.resource/inline "dev.edn")) (process-env-map)) behind a DEV closure-define. Release just uses (process-env-map). This means the actual configuration mapping doesn’t change between dev and release, which should help with “Works on my machine” issues 😉#2020-05-0403:35skiggzI keep getting this warning (doesn't seem to break anything but is rather annoying). First line below is the warning, then my file directory, and my source paths
Invalid Filename, got cljs/foo/bar.cljs but expected foo/bar.cljs (or .cljc)

src
- cljc
- cljs
-- foo
--- bar.cljs (ns foo.bar)

:source-paths ["src/cljc" "src/cljs"]
Am I missing something? If not, is there a way to hide these particular warnings? They seem to just be warnings, hot reload works fine.
#2020-05-0403:59dpsuttonAre deps managed by lein, clj, or shadow?#2020-05-0404:00dpsuttonWondering if it’s supposed to be paths and not source-paths. And it’s defaulting to “src” which would explain the error #2020-05-0500:33skiggzI am managing via lein for deps/source paths, and shadow cljs for the shadow config#2020-05-0407:31AronI depend on a package that depends on a specific version of react.js (stable). I would like to use experimental version of react.js which is a different version. Can I use :resolve for this?#2020-05-0407:52thheller@ashnur just install whatever react version you want. no need to configure anything in shadow, it will just use whatever you have installed#2020-05-0407:57AronRight, so I have 2 dependencies that use 2 different versions of react, I have 3 different versions of react installed, how can I tell which dependency to resolve which react version?#2020-05-0408:02Aronthe problem for me is that helix expects react under the name react, and I would like to use a react version installed under a different name (alias), so that for other react libraries in the same build I could still provide react under a different name. in #helix I am told it's shadow-cljs's job, but I don't like to make tooling complicated. It's also a bit of an edge case, since it might be easier to just do a different build for different versions of react, I am not sure. Ideally I could share react component code without actually share React rendering contexts (so different apps using different react versions could use some share of application code)#2020-05-0408:07thhellershadow-cljs will always use node_modules/react#2020-05-0408:07thhellerit doesn't care about any other installed versions#2020-05-0408:08thhellerwhat you are describing is not supported since it won't work
#2020-05-0408:08thhelleryou can't just use two different react versions and expect them to work together#2020-05-0408:34Aron@thheller who said anything about using the react versions together?#2020-05-0408:34Aronsharing code is not using them together#2020-05-0408:34Aronit's not sharing runtime memory#2020-05-0408:35thhellerthen I don't understand your question. "Ideally I could share react component code" so you just have two different builds?#2020-05-0408:37thhellerwhats the problem though? usually react has been pretty decent with backwards compatibility so using a newer version with something that expects the old one just work?#2020-05-0409:17Aronhttps://claudiopro.github.io/react-fiber-vs-stack-demo/ would like to build this#2020-05-0409:18Aronbut not the way it was done originally, because that's pointless, I figured I do it from cljs, it's a good exercise project.#2020-05-0409:18Aronapparently, it's too good#2020-05-0409:18Aron: D#2020-05-0409:22thhellerah so you want two different builds with one build using one version#2020-05-0409:22thhellerand the other using a different version?#2020-05-0409:23thhellerthats easy via https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules#2020-05-0409:24thhellerjust make a build1/package.json with the deps for build1 and build2/package.json#2020-05-0409:24thhellerthen make the one build use :js-package-dirs ["build1"] etc#2020-05-0409:29Aronwell, originally I didn't want two builds, I figured I just alias and use it, but since I gave up for many reasons, some of which you pointed out now I would be fine with a single build to be honest, if it would work, I installed only the experimental react version and it's breaking, I am guessing it's because "experimental" but haven't had the time to actually debug this too. Maybe first I do it in javascript just to be sure it actually works before I start experimenting here too?#2020-05-0409:31thhellerno clue what issue you are actually trying to solve here. nothing in the build config will allow you two include two different react versions for one build UNLESS you actually require a differently named version directly in your code#2020-05-0409:32thhellerso (:require ["react-foobar" :as react]) or whatever will of course work but overriding :resolve for react will effect everything in the build#2020-05-0409:33Aronthanks, that's clear#2020-05-0410:44Chris McCormickif i have a :node-script target is there a way to ask shadow-cljs to run it in the background when i do npx shadow-cljs watch server?#2020-05-0411:00thheller@chris358 there is not no#2020-05-0414:47thheller@jjttjj just released shadow-cljs version 2.8.110 that includes the updated CLJS release 1.10.758 that should fix the self-host issue you ran into#2020-05-0414:49jjttjjAwesome, will upgrade today, thanks!#2020-05-0415:28jjttjjWhen I start a cljs repl with shadow.cljs.devtools.api/repl and I enter any input I'm getting
ExceptionInfo: missing cljs.user, repl not properly configured (must have analyzed cljs.user by now)
Does that look familar at all?
#2020-05-0415:30jjttjjSeems to come from here: https://github.com/thheller/shadow-cljs/blob/022e1edab5908271992cda0d42300b4226c492ce/src/main/shadow/cljs/repl.clj#L500#2020-05-0415:38jjttjjOk it seems things work when I remove the :repl-init-ns option from my :devtools map in shadow-cljs.edn#2020-05-0416:34thhellerah. will be fixed in the next release.#2020-05-0418:18lilactownwhat’s the best way to add externs for GA’s scripts?#2020-05-0418:22lilactownthe issue I’m running into is I have GA on the page, and call (apply js/ga args) apply checks to see if .-cljs$lang$applyTo exists on the f passed in, which gets munged to like f.d, which actually exists on the ga object 😕#2020-05-0419:03thhellerdon't use apply then? 😛#2020-05-0419:03thhellerthere are some externs for google analytics in a google repo somewhere#2020-05-0419:03thhelleryou can include those#2020-05-0419:16lilactownwould that work if the GA script is already minified?#2020-05-0419:17thhellerthat question is weird. the externs are for the script you are including in your page. wouldn't make sense for them to provide externs for you and then minifiy to use different names#2020-05-0419:17thhellerbut I repeat ... just don't use apply 😛#2020-05-0419:18lilactownyeah that’s what I’m going with#2020-05-0419:18thhellerthe "false" positive behavior of detecting properties that aren't actually from CLJS is a known problem#2020-05-0419:18thhelleraffects js->clj as well still#2020-05-0419:19thhellercan't really do much about those other than adding externs for the properties it clashes with#2020-05-0419:20thhelleronly reliable way is to treat foreign objects as actually foreign and not expect them to behave like CLJS#2020-05-0504:30nam.hyunwoocan I browser-repl without automatically opening a default browser?#2020-05-0504:52nam.hyunwoook, i've added this snippet to my user.ns to kill browse-open. 😶
(reset! *open-url-script* "/usr/bin/false")
#2020-05-0506:14niwinzHello, After upgrading from 2.8.93 to the latest one i start getting some warnings:#2020-05-0506:15niwinz
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
Resource: simplified-externs.js:2
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
[...]
------ WARNING #5 -  -----------------------------------------------------------
Resource: simplified-externs.js:6
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
[:main] Build completed. (1060 files, 1057 compiled, 0 warnings, 52.05s)
#2020-05-0506:16niwinzit compiles successfully but the warning are noisy.#2020-05-0506:19niwinzIf I remove the externs directory, the warning disapears.#2020-05-0508:33pmooserI have a couple shadow-cljs questions (again). 1. I'm seeing a CORS preflight error when I try to load my app via the shadow-cljs dev http server. I had an entry in :push-state/headers which I thought would take care of this, but I'm not quite sure what else to do or even how to debug exactly what is going on. 2. If I don't use the shadow-cljs dev http server, and just go directly to my app's server, everything is mostly OK except I see some weird messages in the console when it tries to reload cljs code, where I just see the line: "shadow-cljs: can't find fn" (I have the impression that this normally would have the fn name after it) ... #2020-05-0508:33pmooserIf anyone has suggestions for either of those, I'd be very grateful.#2020-05-0508:35thheller1) CORS headers must be set by the server answering the request so if you request data from another server THAT server must set the headers not the :dev-http server.#2020-05-0508:36thheller2) no clue. you just have to load static files, functionality should be identical. only thing I can think of is that some files fail to load? any loading errors in the browser console? maybe some bad caching logic in your server?#2020-05-0508:39pmooserOk, I will try to double-check that the server is doing the right cors things. It's a little baffling because I can't see an awful lot about it in the browser's record of the request. As far as number 2, no loading errors in the console at all, but I've seen this on a couple projects in the last weeks that I am working on that are similar, and I suspect it is particular to the bootstrap build. Since it's a code-reloading thing, and since I think it won't happen if I am going via the dev http server, it probably isn't that important for me to investigate if I can fix the CORS issue.#2020-05-0508:39pmooser@thheller Thank you for the response!#2020-05-0508:41thhellernothing in the hot-reload process uses either the dev-http or your server#2020-05-0508:41thhellerit always talks directly to the shadow-cljs main server regardless of how the files were served#2020-05-0508:42pmooserI'm just telling you the consistently reproduceable facts.#2020-05-0508:42pmooserIt may well be my configuration,#2020-05-0508:42pmooserbut I'm not doing anything that strange, to be honest.#2020-05-0508:42pmooser(other than doing the cljs-in-cljs eval stuff)#2020-05-0508:42thhellerI'd be happy to look at an actual reproducible case 😛#2020-05-0508:43pmooserYeah that's a reasonable request ... I can't share my actual project but I wonder if I can make a skeleton project with the same characteristics.#2020-05-0508:43thhellershadow-cljs: can't find fn means that the server-side compile found a hook function (eg. :dev/after-load or config) but didn't find it at runtime#2020-05-0508:43thhellerit is literally just trying to look it up by name#2020-05-0508:43pmooserYeah, I only have one of those functions defined.#2020-05-0508:43pmooserI wonder why on earth it thinks it can't find it ...#2020-05-0508:44thhellerit doesn't think it .. it can't find it#2020-05-0508:44pmooserIt may be that it's another path problem somehow (since I'm accessing it via a different URL I guess) ... but I don't see any loading errors at all ... ?#2020-05-0508:45thhellerI mean go into the browser console and type in the name of the function it is supposed to call#2020-05-0508:45thhellerits either there or it isn't#2020-05-0508:46pmooserI mean it's a function, if I just type foo.bar.fn-name#2020-05-0508:46pmooserin the js console#2020-05-0508:46thhellerthe munged name yes, so that would be foo.bar.fn_name#2020-05-0508:47pmooserBut the question also is, why is the fn-name blank in the log msg?#2020-05-0508:47pmooser(doesn't it try to log the fn symbol?)#2020-05-0508:47thhellerits kind easy to destroy the runtime state with self-hosted code if you are not careful#2020-05-0508:47pmooserYes, so sorry, I think the munged name is completely present in the js console if I type it.#2020-05-0508:48thhellerso maybe you are loading code you shouldn't be loading via self-host? like loading a different cljs.core instance?#2020-05-0508:48pmooserWhat code should I not be loading I wonder?#2020-05-0508:48thhellerdo you use the bootstrap helpers described here? https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2020-05-0508:49thhellerthose should ensure that it doesn't load files that are already loaded#2020-05-0508:49pmooserI will review ... one moment please.#2020-05-0508:50pmooserI am using init ... I don't think I am using load ...#2020-05-0508:51thhelleryou can also review the websocket messages via the browser console, see if the message actually contains an emtpy fn call (which shouldn't be possible in theory as it would be invalid transit)#2020-05-0508:51pmooserSorry, I was wrong.#2020-05-0508:51pmooserI am using both init and load, very similar to what is shown in that blog post.#2020-05-0508:52pmooserMy init callback doesn't do anything though.#2020-05-0508:52pmooserBut when I use eval, I use boot/load every time.#2020-05-0508:52pmooserYeah, I tried looking at the WS calls in the browser, but I didn't see an error,#2020-05-0508:52pmooserbut maybe I can look closer.#2020-05-0508:53thhellerits not an error. its a regular :build-complete message#2020-05-0508:53thhellerthat contains all the info about what it should be reloading and so on#2020-05-0508:53pmooserSo I am guessing the problem is related to this:#2020-05-0508:53pmooser
:before-load [{:fn-sym nil, :fn-str ""} {:fn-sym nil, :fn-str "", :async true}]
#2020-05-0508:56thhelleryes#2020-05-0508:57thhellerno clue how that happens though? especially since that is always done by the shadow-cljs main server and not related to the dev-http at all#2020-05-0508:57pmooserYes, I mean I'm sure you must be correct that it is something in my config I am doing wrong#2020-05-0508:58pmooserI am having a hard time even pprinting that stuff in emacs, it's too slow#2020-05-0508:58pmooserI just need to learn enough about shadow-cljs internals to be able to effectively debug it#2020-05-0508:58thhelleroh one idea. do you use shadow-cljs in any kind of embedded way?#2020-05-0508:58thhelleryou calling server/start! embedded in another CLJ process?#2020-05-0508:59thhellerthats the server constructing the info https://github.com/thheller/shadow-cljs/blob/daf95e9dde0245112fc4c844098a9a0e7fcf8f75/src/main/shadow/cljs/devtools/server/worker/impl.clj#L239-L281#2020-05-0509:00thhellerhonestly not sure how it would ever get a nil there#2020-05-0509:00pmooserNope, I don't think so, I mean I am launching shadow-cljs with clj , but I'm not manually managing it or starting servers or anything.#2020-05-0509:00thhellerwhich version do you use?#2020-05-0509:01pmooser
thheller/shadow-cljs {:mvn/version "2.8.83"}
#2020-05-0509:01thhellerand kind of :build-hooks or something else that may be touching the compiler state?#2020-05-0509:01pmooserNo build-hooks#2020-05-0509:02pmooserIf I wanted to set a breakpoint in that code you showed me, is there an easy way to do that?#2020-05-0509:02pmooserI'm not really sure how to run shadow-cljs under a debugger.#2020-05-0509:02thhellerdo you use intellij?#2020-05-0509:08pmooserNope. Just emacs.#2020-05-0509:08pmooserI could install IntelliJ I think.#2020-05-0509:08thhellerthen I can't tell you 😛#2020-05-0509:08pmooser(if that would be much easier)#2020-05-0509:09pmooserFor now I am trying to dig around in browser's debugger#2020-05-0509:09pmooserbut that probably won't be too illuminating#2020-05-0509:09thhellerthe problem is on the server if you get weird empty hooks like that#2020-05-0509:09thhellernothing the client does affects that in any way#2020-05-0509:11pmooserYeah, I suspected as much.#2020-05-0509:12pmooserWell, thank you very much for your help. I will see what I can do to dig a little more, and then I will try to ask some more useful questions.#2020-05-0509:22pmooserI'm guessing it's all some combination of different paths I'm using or something along those lines.#2020-05-0509:23pmooserMy colleagues use IntelliJ#2020-05-0509:23pmooserI might ask them to help out, if I don't install it myself.#2020-05-0509:23thhelleryou can run things via deps.edn with a debugger attached#2020-05-0509:26pmooserYeah, I imagine I just need to pass the right jvm args so it will listen on a debug port or whatever#2020-05-0509:27thhelleryep, intellij will do that for you. no clue about emacs debugging support.#2020-05-0509:28pmooserYeah, to be honest, me neither. I have used it before but not often.#2020-05-0509:30niwinz@thheller do you know what can be the cause of the
------ WARNING #5 -  -----------------------------------------------------------
Resource: simplified-externs.js:6
name ShadowJS is not defined in the externs.
--------------------------------------------------------------------------------
#2020-05-0509:31niwinzi start seeing this warning on update from 2.8.93 to the latest version of shadow-cljs (as a side note, if i remove externs/ directory the warning disapears).#2020-05-0509:31thhellernot sure. I haven't touched any of the externs related code so it might be the new closure-compiler version having changed something#2020-05-0509:32thhellerthe simplified-externs.js is generated by the externs/build.txt so yeah removing that removes the file#2020-05-0509:32thhellerbut it should generate the proper output#2020-05-0509:32niwinzyeah but 2.8.93 don't shows the warning with the same cljs version#2020-05-0509:33thhellerclosure-compiler version#2020-05-0509:33thhellerCLJS isn't related to any of this#2020-05-0509:33niwinzhmm but closure-compiler version is updated with cljs or with shadow-cljs?#2020-05-0509:33thhellerbut you can't use the current closure-compiler version with the old CLJS version#2020-05-0509:34thhellerif you do it correctly with shadow-cljs. if you use project.clj it depends. if you use deps.edn it should be picking the newest available version (which shadow-cljs depends on)#2020-05-0509:35niwinzi'm using deps.edn#2020-05-0509:35thhellerok then check which versions you are getting#2020-05-0509:36niwinzcom.google.javascript/closure-compiler-unshaded v20200406#2020-05-0509:37thhelleryeah thats the version shadow-cljs depends on#2020-05-0509:37niwinzyep#2020-05-0509:37thhelleryou can downgrade that to test if you want#2020-05-0509:37niwinzi go to investigate what is the cause, thanks!#2020-05-0509:37thhellerjust declare it directly as a dep#2020-05-0509:38thhellerv20191027 would be the version used in 2.8.93. it should still work.#2020-05-0509:40niwinzthanks, i will do it as workaround.#2020-05-0509:40thhellerwhats the problem though? just a couple warnings or does it actually affect anything?#2020-05-0509:40thhellerI mean I have an idea why it might be happening#2020-05-0509:41thhellerbut not sure why it suddenly became a problem when it has worked for the past year or so#2020-05-0509:42niwinzyeah, is just a warning, and i just wanted let you know about this, that it start happening suddenly#2020-05-0511:14thheller@niwinz did you try the older closure-compiler version? if so, does it make the warnings to away?#2020-05-0511:19niwinz@thheller yes, just tried right now, and no, latest version of shadow-cljs and com.google.javascript/closure-compiler-unshaded {:mvn/version "v20191027"}#2020-05-0511:19niwinzand the warning still appears :S#2020-05-0511:19thhellerstrange#2020-05-0511:20niwinz
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "95e0edf7faedd5e0edf7faedb8f1f0e3f0fbe3b8f8f4fcfb"}, :content ("[email protected]")}
#2020-05-0511:22thhellerlooks fine. youj can open a github issue if you want. don't have time to look into this further now. really shouldn't warn about internal things so I'd like to fix that.#2020-05-0511:24niwinzi'll open an issue, sure. I have an other one related to fingerprint-hash, modules and webworker (where web worker tries to import "shared.js" when the fingerprint-hash is activated and the shared.js is renamed to shared.<md5hash>.js file)#2020-05-0511:25niwinzbut the last one i need to recheck it with the latest version before report#2020-05-0513:33schauehoI just started using shadow-cljs and I keep running into an issue on re-compilation. I get the following error which I couldn't find any reference to with my search-engine-fu: ExecutionException: clojure.lang.ExceptionInfo: failed to publish!, offer! failed {:msg {:type :build-log, :build-id :test, :event {:type :flush-source, :resource-name "node_modules/@material-ui/icons/CalendarViewDayTwoTone.js", :timing :exit, :timing-id 1489, :depth 1, :stop 1588684288351, :duration 3, :shadow.build.log/level :info}}, :topic :shadow.cljs.model/build-log} #2020-05-0513:33schauehoThis doesn't come up after removing the output-dir contents on a first compile / watch.#2020-05-0515:39thheller@schaueho thats odd. its a backpressure thing where its trying to log faster than the log consumer can read it. never heard of anyone else running into this before#2020-05-0607:52schauehoMy machine is pretty powerful (Ryzen Threadripper), maybe that's part of the reason. I can log an issue, if you want me to.#2020-05-0607:55thhellerI fixed the issue in master yesterday (I think). should be good with the next release.#2020-05-0607:59schauehoGreat. Thanks!#2020-05-0515:39thhellerI guess I can turn this into a warning instead since its not really critical to drop that message#2020-05-0515:40thhellerguess it just gets overloaded by when trying to flush the thousands of files @materiel-ui has#2020-05-0519:03JaimeV@thheller any news about shado-arborist?#2020-05-0519:49thheller@jev I'm using it for the shadow-cljs UI but no news beyond that. still lots of stuff to figure out and not much time to work on it.#2020-05-0521:47fabraohello all, how do I use something like this in cljs var Connection = require('../lib/tedious').Connection; ?#2020-05-0521:49fabraoI tried with
(ns app.core
  (:require
   ["express" :as express]
   ["tedious" :as sql]))

(defn create-connection []
    (sql/Connection. {}))
but no Connection found
#2020-05-0521:53thhellerdon't know that library sorry. you can try running node and then require("tedious")#2020-05-0521:53thhellerI'm assuming you are running a node build because of the express? ie. now a :target :browser build?#2020-05-0521:54fabraoYes, I´m trying to use with node and with express#2020-05-0521:56thhellerand if you run the node thing do you get something that has a Connection object?#2020-05-0521:58fabraoerror when calling lifecycle function app.core/start! TypeError: Cannot read property 'Connection' of undefined#2020-05-0521:59thhellerdo the plain node please#2020-05-0522:00thhellerI want to first confirm that it actually works in node. that is the only test you have to do.#2020-05-0522:01fabraoho, you mean testing in javascript node?#2020-05-0522:04thhellerliterally just go into your project directory and run node in a terminal#2020-05-0522:05thhellerand then run require("tedious") or require("tedious").Connection#2020-05-0522:09fabrao
require("tedious")
{
  connect: [Function: connect],
  BulkLoad: [Getter],
  Connection: [Getter],
  Request: [Getter],
  ConnectionError: [Getter],
  RequestError: [Getter],
  TYPES: [Getter],
  ISOLATION_LEVEL: [Getter],
  TDS_VERSION: [Getter],
  library: { name: 'Tedious' }
}
> require("tedious").Connection
[Function: Connection]
#2020-05-0522:10thhellerok that looks fine#2020-05-0522:10thhellerwhats your build config?#2020-05-0522:10fabrao
{:source-paths
 ["src"]

 :dependencies
 []

 :builds
 {:app
  {:main app.core/main
   :target :node-script
   :output-to "app.js"
   :devtools
   {:after-load app.core/start!
    :before-load app.core/stop!}}}}
#2020-05-0522:10fabrao
{
  "devDependencies": {
    "shadow-cljs": "^2.8.110"
  },
  "dependencies": {
    "express": "^4.17.1",
    "tedious": "^8.3.0"
  }
}
#2020-05-0522:11thhellerthat looks fine too#2020-05-0522:11thhellertry shadow-cljs node-repl and then (require '["tedious" :as x]) and then (js/console.log x)#2020-05-0522:14fabrao
cljs.user=>

  Connection: [Getter],

  Request: [Getter],
  ConnectionError: [Getter],
  RequestError: [Getter],
  TYPES: [Getter],
  ISOLATION_LEVEL: [Getter],
  TDS_VERSION: [Getter],
  library: { name: 'Tedious' }
}
nil
#2020-05-0522:15fabraoI started it with npx shadow-cljs watch app#2020-05-0522:15fabraoand than node app.js#2020-05-0522:16thhellerthat all looks fine#2020-05-0522:16thhellerbut the error you posted suggests it happens on hot-reload?#2020-05-0522:16thhellerso it works fine on startup?#2020-05-0522:17fabraoI inserted it after run it up#2020-05-0522:17fabraoyes, after hot-reload#2020-05-0522:20fabraoI think it´s ok now after restarting it#2020-05-0522:20fabraothanks !!!#2020-05-0521:55JaimeV@thheller Thanks for the update. Is there anyway to help with arborist?#2020-05-0521:56thhellernot really. it is just one experiment after another currently. it works well enough but not something I would recommend building on.#2020-05-0522:33JaimeVOk. I understand. The concept is spot on and would like to see it flourish. I may shadow-cljs UI and do some experiments of my own. I may reach out if I have something to share.#2020-05-0602:04Gordon KingHi is anyone experienced with boot-shadow/shadow-cljs who could help. Am changing from boot cljs to shadow for compilation, and have it successfully working via the command line. I've installed boot-shadow v 2.8.107 and are running into an error when running boot shadow/release.
No matching method sha1Hex found taking 1 args for class org.apache.commons.codec.digest.DigestUtils
This would appear to be related to the hashing function added in shadow-cljs v2.8.102. Full error in attachment. Thank you.
#2020-05-0604:09Gordon KingHi ignore for now. I had a class path conflict with commons.codec#2020-05-0602:28wilkerluciohello, I just started trying to use the web worker feature of shadow, but seems like shadow is trying to install devtools (fulcro inspect) in the worker#2020-05-0602:28wilkerluciois that a way to make the preloads load only on the :main module?#2020-05-0602:31Pavel KlavíkHow are your modules set up? Do you have a shared module?#2020-05-0603:37wilkerlucioyeah:
{:target           :browser
 :output-dir       "resources/public/js"
 :asset-path       "/js"
 :compiler-options {:closure-defines {goog.LOCALE "en"}
                    :source-map      true}
 :devtools         {:preloads       [devtools.preload com.fulcrologic.fulcro.inspect.websocket-preload]
                    :http-root      "resources/public"
                    :http-port      8120
                    :browser-inject :main}
 :modules          {:shared {:entries []}
                    :main   {:init-fn    myapp.webapp.main/init
                             :depends-on #{:shared}}
                    :worker {:init-fn    myapp.webapp.worker/init
                             :depends-on #{:shared}
                             :web-worker true}}}
#2020-05-0606:56thheller@U066U8JQJ just move the :preloads into the :main module. they can be specified per module.#2020-05-0608:56wilkerlucionice :+1:#2020-05-0605:03wilkerluciohello, something driving me a bit nuts here, I started seeing this error in a project:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/wilkerlucio/.m2/repository/com/wsscode/pathom/2.3.0-alpha6/pathom-2.3.0-alpha6.jar!/com/wsscode/pathom/trace.cljc:289:9
--------------------------------------------------------------------------------
 286 |       (let [trace*       (or (::trace* env) (atom []))
 287 |             env'         (assoc env ::trace* trace*)
 288 |             parser-trace (trace-enter env' {::event ::trace-plugin})]
 289 |         (let-chan [res (parser env' tx)]
---------------^----------------------------------------------------------------
Encountered error when macroexpanding clojure.core.async/go.
ClassCastException: class clojure.lang.Keyword cannot be cast to class clojure.lang.IObj (clojure.lang.Keyword and clojure.lang.IObj are in unnamed module of loader 'app')
I have another project in which the same code compiles fine, I have tried to mimic all the same deps between projects (core.async, shadow, cljs, clj), removed .shadow-cljs every time between builds, but for some reason its just not working, any ideas what I may be missing here?
#2020-05-0605:07sergey.shvetsI had the same with async-helpers 1.0.5. I rolled it back to 1.0.4 and that disappeared. Probably some version conflict?#2020-05-0605:25wilkerlucioyou are right, and there was a core.async bump there, probably is it, gonna dig more on that#2020-05-0606:14wilkerlucio@U4EFBUCUE I found the bug on the library, was a mistaken change in a require from cljs.core.async to clojure.core.async in the com.wsscode.async-cljs.clj file, version 1.0.6 released with the fix#2020-05-0606:16sergey.shvetsThanks, I'll check it out!#2020-05-0610:03Andy HeywoodHi folks - is there a way of using multiple lein profiles with shadow? e.g. a different profile per target?#2020-05-0610:07Andy HeywoodMotivation: using https://github.com/weavejester/environ to manage some ‘static’ configuration rather than goog-define#2020-05-0610:07thhellerno that is not supported and not recommended either#2020-05-0610:07thhellerconsider https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge instead#2020-05-0610:08thhellerif you really want to you can just use lein directly though#2020-05-0610:08thhellerlein with-profiles +whatever run -m shadow.cljs.devtools.cli release app or so#2020-05-0610:08Andy Heywoodah of course, cool#2020-05-0610:09Andy HeywoodI am using config-merge, but it’s not amazing for secrets#2020-05-0610:09thhellersecrets?#2020-05-0610:11Andy Heywoodso this is in a node context - using config-merge for e.g. api keys builds them into the js file, so they kind of need to come from the environment. hence went to environ which I’m used to from clj#2020-05-0610:11Andy Heywoodunless I am totally missing something#2020-05-0610:11thhellerif you are in the node context then keep secrets OUT OF YOUR BUILD! 😛#2020-05-0610:11thhellerload them at runtime as actual environment variables 😛#2020-05-0610:11Andy Heywoodexactly#2020-05-0610:12Andy Heywoodusing environ for that, and was considering it for other things too, but I just won’t 😄#2020-05-0610:13Andy Heywoodwill keep it exclusively as local dev file vs prod env separation#2020-05-0610:14Andy Heywoodthanks @thheller - had a really enjoyable time so far with shadow-cljs, very much appreciate your work#2020-05-0610:20pmooserNo luck yet figuring out how to get shadow-cljs running under the CIDER debugger.#2020-05-0610:21thhellerhow do you debug any other clj program?#2020-05-0610:23pmooserHonestly, not too often. If I am debugging my own app it hasn't been a problem to get emacs working. But since I have been using clj since about 2008, I sort of got used to not using a debugger very often with clojure. Even though there was technically debugging support quite early, java debuggers used to get freaked out a lot by locals clearing and other stuff so it never worked very well for me. And emacs had no clojure debugging support for quite a long time.#2020-05-0610:24pmooserLike, just as an experiment, let me see if I can debug my own app ... it'll take at least a few mins.#2020-05-0610:27pmooserOk, for my own app it's trivial, I just need to launch it with the cider middleware with nrepl ... not 100% sure how to do that with shadow-cljs.#2020-05-0610:28pmooserIf I launch into an nrepl interactive session, I'm not totally sure how to replicate what shadow-cljs does when I tell it 'watch app bootstrap'#2020-05-0610:28thhellerjust ignore shadow-cljs#2020-05-0610:28pmooserI am able to tell it to (compile :app) or (compile :bootstrap) but my breakpoints never get hit#2020-05-0610:28pmooserSo I'm obviously doing something wrong.#2020-05-0610:28thhellerand start it from within the nrepl session itself#2020-05-0610:29thhellerah no clue what that debugger does#2020-05-0610:29thhellermaybe it just hooks into the current thread?#2020-05-0610:29thhellerwatch runs in its own thread#2020-05-0610:29thhellerhere is one thing you can try#2020-05-0610:29thhellerrun shadow-cljs as normal#2020-05-0610:30thhellerconnect to nrepl (without any kind of debugger or so)#2020-05-0610:30thhellerrun (in-ns 'shadow.cljs.devtools.server.worker.impl)#2020-05-0610:31pmooserOK, I can try that.#2020-05-0610:31thhellerand just eval a modified version of that fn#2020-05-0610:31thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/worker/impl.clj#L239-L281#2020-05-0610:31pmooserOk thanks.#2020-05-0610:32pmooserI will try that.#2020-05-0610:32thhelleryou can just add a (tap> build-state) somewhere#2020-05-0610:32pmooseryup#2020-05-0610:32thhellerand look at it in the shadow-cljs ui#2020-05-0610:32pmooserand lots of printlns#2020-05-0610:32pmoosergood idea#2020-05-0610:32pmooserlet me see 🙂#2020-05-0610:32thhellerpff println 😛#2020-05-0610:32thhellernote that you might need to restart the watch for those things to get picked up#2020-05-0610:33thhellersince the resource hooks are cached#2020-05-0610:33pmooserHow do I restart the watch?#2020-05-0610:33thhellerso start of with shadow-cljs server#2020-05-0610:33thhelleruse the UI#2020-05-0610:33thhelleror restart from the REPL#2020-05-0610:33thhellerjust don't start with shadow-cljs watch app because that will shutdown if you stop the watch#2020-05-0610:33pmooserI mean, if I launch it with "watch app bootstrap",#2020-05-0610:33pmooseris there a way to restart that from the repl?#2020-05-0610:34thhellerno#2020-05-0610:34pmooserOr do I have to do (watch :app :bootstrap) from the repl?#2020-05-0610:34thhelleryou have to start the server separately if you want to be able to restart the watch#2020-05-0610:34thhellershadow-cljs server and then separately shadow-cljs watch app is fine#2020-05-0610:34thhelleras that won't kill the server if you ctrl+c the watch#2020-05-0610:36thhellerone tap is really all you need. the inspect you will let you drill down into everything else.#2020-05-0610:36pmooserI've never used tap>#2020-05-0610:36thhellerwhen the server is running open http://localhost:9630#2020-05-0610:36thhellerclick inspect#2020-05-0610:36pmooserSo wait, when you say a shadow-cljs server and a separate shadow-cljs watch app, you mean 2 processes??#2020-05-0610:36thhelleryes#2020-05-0610:37pmooserI'm a little confused, as I'm sure you can already tell.#2020-05-0610:37thhellerconfused about what?#2020-05-0610:37pmooserHow does it work if I have 2 separate processes, since I want to see what is happening in the watching process?#2020-05-0610:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_important_concepts#2020-05-0610:37pmooser(I don't understand how the two separately-launched processes are related here)#2020-05-0610:37thhellerread "Server Mode"#2020-05-0610:38pmooserOk thanks, got it.#2020-05-0610:38pmooser(that makes sense)#2020-05-0610:41pmooserOk, trying all of this ... let's see what happens.#2020-05-0610:42pmooserOk clicking on REPL just results in "Loading ..."#2020-05-0610:43pmooserSo how am I supposed to add a tap? I need to connect via nrepl somehow?#2020-05-0610:44pmooserAnd I assume it is the server process I'm supposed to connect to?#2020-05-0610:45pmooserOK my emacs nrepl connection doesn't work AT ALL without the middleware, so let's see if I can connect easily via clj or something.#2020-05-0610:48pmooserThere we go, very easy with lein#2020-05-0610:52pmooserSo do you really mean (tap> build-state) or is it like (tap> build-configure) ?#2020-05-0610:53pmooserI don't really know tap ...#2020-05-0610:55pmooserAh sorry, I understand now.#2020-05-0610:56pmooserOk, now I have those tap results ...#2020-05-0610:57pmooserJust gotta dig around a bit and see if I can make sense of them.#2020-05-0610:59thhellerlook at the :compiler-env key
#2020-05-0610:59thhellerthen the :cljs.analyzer/namespaces#2020-05-0610:59thhellerthen the ns that is supposed to have hooks#2020-05-0611:00thhellerthen the :defs#2020-05-0611:00thhellerthen the name of that def#2020-05-0611:00thhellerit seems to be missing the :name for some reason#2020-05-0611:02pmooserok I will try to go in that order, it's kind of a lot 🙂#2020-05-0611:03thhelleruhm which shadow-cljs version are you on?#2020-05-0611:03thheller> Ok clicking on REPL just results in "Loading ..."#2020-05-0611:03thhellerthe new UI doesn't have a REPL option so are you maybe on an old one?#2020-05-0611:04pmooserv2.8.83#2020-05-0611:04pmooserOk so I am looking at my ns now ...#2020-05-0611:04pmooserLet's see if anything looks weird#2020-05-0611:04thhellerI think you might need to upgrade for the UI to make any sense#2020-05-0611:05thhellerthe old inspect wasn't very good#2020-05-0611:05thhellernew one isn't good either but much better than the old one 😉#2020-05-0611:05thheller2.8.110 or so#2020-05-0611:06thhelleryou really only need to look at one thing though#2020-05-0611:06pmooserOk I will update soon.#2020-05-0611:06thheller[:cljs.analyzer/namespaces your.ns :defs the-hook-fn] basically#2020-05-0611:06pmooserI am going through all the defs now#2020-05-0611:06pmooserand looking for a :name that is nil#2020-05-0611:06thhellerno need to go through all#2020-05-0611:06thhellerjust the actual name of the hook#2020-05-0611:06thhellernothing else is relevant#2020-05-0611:06pmooserI looked at the hook:#2020-05-0611:07pmooser(defn ^:export ^:dev/after-load init#2020-05-0611:07pmooserSo I looked for 'init'#2020-05-0611:07pmooserBut it looks OK.#2020-05-0611:08thhellerdoes if have a {:name your.ns/init}?#2020-05-0611:08pmooserYes.#2020-05-0611:09thhellerthen I don't know how it can possible be nil when being sent to the client#2020-05-0611:10pmooserYeah, me neither. I just sent out the output of my init entry in defs, via private message.#2020-05-0611:11pmooserBut in any case, you've certainly gone above and beyond to try to help me.#2020-05-0611:11pmooserSo thank you for your efforts.#2020-05-0611:11pmooserIf I can't figure out emacs I will eventually have IntelliJ so maybe I can bug you about how you would use that debugger, if I don't figure it out first.#2020-05-0611:12thhellerI haven't used the debugger in years either#2020-05-0611:12thhellerI'm just using tap> nowadays with inspect#2020-05-0611:30thheller@niwinz I think I found and fixed the ShadowJS warning issue. should be gone with next release.#2020-05-0611:30niwinznice, thank you, and thank for you awesome work with shadow-cljs#2020-05-0612:45pmooserIn case anyone was following my error earlier, it turns out upgrading to the newest shadow-cljs and cljs seems to have made the error go away.#2020-05-0613:14yendait seems like shadow-cljs make a much bigger bundle than what we had before with clj and figwheel, is there some fundamental differences? It is only a problem on a specific device where the bundle crashes the js engine 90% of the time#2020-05-0614:13thheller@yenda define "a much bigger bundle"? for release the build should be smaller, for development it will be much larger yes.#2020-05-0614:13yendayeah the problem is in dev#2020-05-0614:13thhellerwell technically the same but for development all files are combined into one, re-natal loads many small files dynamically#2020-05-0614:33thhellerFWIW it would be trivial to provide a secondary approach like re-natal/krell do that only load a tiny js "loader" file on startup and that then loads everything else dynamically#2020-05-0614:33thhellerI opted not to do that because of the async layer it introduces, ie. making "loading" async in dev but not in production#2020-05-0614:34thhelleralso takes a lot longer to load initially if done async in my tests#2020-05-0614:34thhellerbut yeah I imagine the file can become quite big in larger projects#2020-05-0618:53alex-ebertsHi Folks, I'm trying to use shadow-cljs to compile a reagent / re-frame app and shadow-cljs is telling me that required namespace react is not available. I've seen the note about using shadow-cljsjs and have added it to my shadow-cljs.edn dependencies map but that hasn't fixed the problem. What else do I need to do?#2020-05-0618:57dpsuttonis there a package.json file in the directory of the project?#2020-05-0618:57alex-ebertsah, no. That must be it <facepalm>. thx!#2020-05-0620:42wilkerluciohello, I'm trying to make workspaces with web workers, but when I try to configure I get this error:
[:workspaces] Build failure:
Module Entry "devtools.preload" was moved out of module ":main".
It was moved to ":shared" and used by #{:shared :main}.
#2020-05-0620:42wilkerlucioand this is the config I'm trying:
:workspaces      {:target           nubank.workspaces.shadow-cljs.target
                  :ns-regexp        "-(test|cards)$"
                  :output-dir       "resources/workspaces/js"
                  :asset-path       "/js"
                  :compiler-options {:source-map true}
                  :modules          {:shared {:entries []}
                                     :main   {:depends-on #{:shared}
                                              :preloads   [devtools.preload com.fulcrologic.fulcro.inspect.preload]}
                                     :worker {:init-fn    my-app/init
                                              :depends-on #{:shared}
                                              :web-worker true}}
                  :devtools         {:http-resource-root "."
                                     :http-root          "resources/workspaces"
                                     :http-port          8121
                                     :browser-inject :main}}
#2020-05-0620:43wilkerluciobut I'm confused about whats going on, the workspaces is using a target that I modified a bit to dont completly override :main :entries so I can set preloads there#2020-05-0620:43thhellerdon't put the devtools.preload into the :main module#2020-05-0620:43thhellerjust remove it, it is added automatically when on the classpath#2020-05-0620:43wilkerlucio@thheller I tried messing with the target, if I remove that i complains on the same for the inject-repl-client#2020-05-0620:44thhellerhmm?#2020-05-0620:44wilkerlucio
(defn resolve-cards-and-tests
  [{::build/keys [mode config] :as state}]
  (let [{:keys [ns-regexp] :or {ns-regexp "-(ws|test)$"}}
        config

        dynamically-resolved-namespaces
        (find-namespaces-by-regexp state ns-regexp)]

    (-> state
      ;; Add the mounter and all of the resolved cards/tests
      (assoc-in [::modules/config :main :entries] (-> []
                                                      (into (get config :preloads []))
                                                      (into dynamically-resolved-namespaces)
                                                      (conj 'nubank.workspaces.shadow-cljs.mount)))
      (cond->
        (and (= :dev mode) (:worker-info state))
        (update-in [::modules/config :main] browser/inject-repl-client state config)

        (= :dev mode)
        (-> (update-in [::modules/config :main] browser/inject-preloads state config)
          (update-in [::modules/config :main] browser/inject-devtools-console state config)))
      (modules/analyze))))
#2020-05-0620:44wilkerluciothe cond-> part seems to be problem#2020-05-0620:45wilkerlucioyeah, removing that the compilatin works, altough it still installing the devtools twice (once on main, once on worker when it starts)#2020-05-0620:45thhellerthats normal?#2020-05-0620:46thhellerit is its own context after all so it will initialize twice#2020-05-0620:46thhellerunless you are not planning on doing any logging in the worker?#2020-05-0620:47wilkerlucionah, you are right, confusion on my part, first time using web workers, so I guess its fine#2020-05-0620:48thhelleryeah all code in :shared will be loaded twice, that will include devtools.preload and whatever that does#2020-05-0620:48thhellerbtw if you upgrade you don't need the :browser-inject logic anymore#2020-05-0621:21haywoodI have a build hook that runs during the configuration step, when building a release it seems like the compile step happens in parallel, is that right?#2020-05-0621:22thhellerno, configure always happens once and compile only starts when that finishes#2020-05-0621:23thhelleror do you mean the compilation happens in parallel itself? that would be true for development too#2020-05-0621:23haywoodduring the release build my hook is called after [:app] Compiling ... is printed#2020-05-0621:24thhellerCompiling ... is from the build-start event, that happens before anything else?#2020-05-0621:25thhelleragain .. also true for dev?#2020-05-0621:25haywoodthe hook generates a new clojurescript file that some files in the project depend on, so during development the generated file is there before the compilation step, but in the release build the compile step fails because the generated file is not there yet#2020-05-0621:25thhellerwhats the issue? what are you doing in the hook?#2020-05-0621:25thhellerdidn't I warn you against doing that?#2020-05-0621:25haywoodno I don’t think I got guidance#2020-05-0621:25haywoodhaha#2020-05-0621:25haywoodsorry#2020-05-0621:26thhellerdon't use hooks to generate files that you intend to use in the compilation :P#2020-05-0621:26haywoodyou know, yea I can get around this#2020-05-0621:26haywoodso I am using the hook to kick off a filesystem watch#2020-05-0621:26haywoodin dev#2020-05-0621:26haywoodin prod I can just run it beforehand#2020-05-0621:26haywoodright thanks#2020-05-0621:27thhelleryou definitely should not be doing that 😛 (starting a watch in a hook)#2020-05-0621:27haywood
(when (= :dev (:shadow.build/mode build-state))
      (fs-watch/start {}
                      (file-seq (io/file pages-directory))
                      ["cljs" "cljc" "clj" "js"]
                      gen-routes-fn))
#2020-05-0621:27haywoodseems to work fine#2020-05-0621:27thhelleryeah .. don't do that#2020-05-0621:28haywoodso basically you’re prescribing just a separate step that is bundled in the dev calls#2020-05-0621:28haywoodmake dev boots up shadow and the watcher#2020-05-0621:29thhelleryou should run anything like that separately#2020-05-0621:29thhellerif you must start it with shadow-cljs use clj-run#2020-05-0621:30haywoodroger that!#2020-05-0621:30haywoodthanks, and hey#2020-05-0621:30haywoodyou are my hero I want you to know#2020-05-0621:45haywoodI do feel like it would be really powerful to have a hook that can be called before shadow does anything, because ultimately it would be nice to open source this thing and that would make the install way easier#2020-05-0621:51haywoodwow, could this be what :devtools are for lmao#2020-05-0621:51haywoodsorry, I’ll get there#2020-05-0621:59thhellerthe issue why I'm advising against running this as a hook is that it starts a thread#2020-05-0621:59thhellerand you are likely not shutting that down anywhere#2020-05-0621:59thhellerso you can get into situations where it will be watching 1,2,3,4,5,6,n times#2020-05-0622:00thhellersince configure is called whenever you edit the build config for example#2020-05-0622:00thhellerI have a plugin mechanism which would let you plug into the lifecycle properly#2020-05-0622:00thhellerbut it isn't publicly documented since I don't think its a good idea#2020-05-0622:25wilkerlucio@thheller I like to contribute to shadow docs, where does the source of it lives?#2020-05-0700:30jjttjj@U066U8JQJ looks like it's here https://github.com/shadow-cljs/shadow-cljs.github.io#2020-05-0700:51wilkerluciothanks!#2020-05-0708:27erwinrooijakkersHi all, in shadow-cljs .edn if I depend on Reagent I have to use npm install to install it’s dependencies, but they are mentioned in Reagent’s package.json. Same for npm packages that have dependencies in package.json, for some reason I have to add them manually. Is there a way to retrieve transitive dependencies automatically?#2020-05-0708:27bitkiller.42Hi, i've a problem on hot reloading application on android device. My app is based on rn-rf-shadow (shadow-cljs, expo, reagent) https://github.com/PEZ/rn-rf-shadow . The hot reload has worked before. I think it has stopped as expo client updated react native and introduced fast-refresh. Fast-refresh is disabled on device. When I change my screen class the .cljs files are loaded and the start method is called.
load JS kickmanager/domain/start/start_screen.cljs
load JS kickmanager/domain/main/main_frame.cljs
call 
This is the start function
(defn start
  {:dev/after-load true}
  []
  (expo/render-root (r/as-element [PaperProvider {:theme custom-theme}
                                   [main-frame-with-socket]])))
Hope someone can give me a hint on what to investigate. Thx and regards.
#2020-05-0710:39thhelleras far as shadow-cljs is concerned it did its job. why your client doesn't update I cannot say. after calling your start fn shadow-cljs is done and out of the picture#2020-05-0710:39thhellermaybe you have a component that decides to skip re-rendering somewhere#2020-05-0710:40thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-05-0710:48bitkiller.42Danke Thomas, I will re-check with clean projects and ivestigate further (Costs so much time on side-projects 🙂 ). I’ve already tried swapping reagent atoms on start … but no success so far.#2020-05-0808:38bitkiller.42Works now. The fix was introducing the “dummy prop that always changes”, topic “Hooking up React” from the guide thheller mentioned above.#2020-05-0708:31thheller@erwinrooijakkers the dependencies should be installed automatically when starting shadow-cljs? reagent doesn't have a package.json though so you just might be on a very old reagent version that doesn't declare its JS deps properly?#2020-05-0708:31erwinrooijakkersDoes not happen#2020-05-0708:31erwinrooijakkers😕#2020-05-0708:31thhellerwell which version of reagent do you use?#2020-05-0708:31erwinrooijakkers[reagent "1.0.0-alpha1"]#2020-05-0708:31erwinrooijakkersBut the version before that had same problem#2020-05-0708:32erwinrooijakkersIt’s this example project: https://github.com/transducer/zenroom-cljs-demo where I wanted to get Reagent + Zenroom (an npm package with a WASM file) to work#2020-05-0708:33thhellerthat project has the dependencies listed in package.json?#2020-05-0708:33erwinrooijakkersSo I need to do this manually:
npm install 
#2020-05-0708:33erwinrooijakkersYes zenroom as well#2020-05-0708:33thhellersorry I'm lost#2020-05-0708:34thhellerwhat is the problem?#2020-05-0708:34thhellerwhen dependencies are declared in package.json then shadow-cljs does nothing#2020-05-0708:34thhellerdid you just miss the npm install (without any packages) to install the dependencies listed in package.json?#2020-05-0708:43erwinrooijakkersMaybe…#2020-05-0708:43erwinrooijakkersI mean nmp install zenroom && npm install would work?#2020-05-0708:44erwinrooijakkersI want these transitive dependencies to be added#2020-05-0708:44erwinrooijakkersWithout me doing it manually#2020-05-0708:44thhellersorry I'm absolutely lost#2020-05-0708:45thhellerif you checkout that project and run npm install#2020-05-0708:45thhellerit will install all the packages listed in the package.json#2020-05-0708:45thhellerincluding all transitive dependencies#2020-05-0708:46thhellerI don't know why you are calling npm install zenroom since that will just install zenroom but not the rest#2020-05-0708:46thhellerbut zenroom is listed in package.json so it will already be installed when you run npm install#2020-05-0708:46erwinrooijakkersYes I mean when you don’t have a package.json yet#2020-05-0708:46erwinrooijakkersHow you start from scratch#2020-05-0708:47thhelleryou must have one#2020-05-0708:47thhellernpm init -y#2020-05-0708:47erwinrooijakkersWhen I run npm init -y && npm install zenroom i do not have the transitive dependencies#2020-05-0708:47thhellerok that is fine#2020-05-0708:47erwinrooijakkersThen shadow-cljs complains#2020-05-0708:47thhellercomplains how?#2020-05-0708:48erwinrooijakkersAnd I have to manually run npm install #2020-05-0708:48erwinrooijakkers(Dependencies of zenroom)#2020-05-0708:48erwinrooijakkersMaybe i just dont know how npm works#2020-05-0708:49thhellerif zenroom doesn't declare its dependencies properly then that has nothing to do with shadow-cljs?#2020-05-0708:50erwinrooijakkersThey are mentioned here: https://github.com/DECODEproject/Zenroom/blob/master/bindings/javascript/package.json#L49#2020-05-0708:50erwinrooijakkers#2020-05-0708:51thhellernever ever look at at github repo when trying to figure out what a package does#2020-05-0708:51thhellerthat is not the file that is being distributed with the package#2020-05-0708:51erwinrooijakkersOhh#2020-05-0708:51thhellerhttps://unpkg.com/zenroom@1.1.0/package.json#2020-05-0708:51thhellerthat is the actual file distributed with the package#2020-05-0708:51erwinrooijakkersOkay that’s wrong…#2020-05-0708:51erwinrooijakkersThat version of core-js doesn’t work#2020-05-0708:51erwinrooijakkersThat’s the problem then#2020-05-0708:52erwinrooijakkersThanks!#2020-05-0708:56erwinrooijakkersAnd in relation to Reagent, is there a way to automatically install it’s npm dependencies (`npm install /cdn-cgi/l/email-protection /cdn-cgi/l/email-protection create-react-class`)?#2020-05-0708:56thhellerthat happens on startup?#2020-05-0708:56erwinrooijakkersLet me check#2020-05-0708:57erwinrooijakkersI have Reagent added in shadow-cljs.edn#2020-05-0708:57erwinrooijakkersOk#2020-05-0708:57erwinrooijakkersThen i run shadow-cljs watch app#2020-05-0708:57erwinrooijakkersAnd indeed running: yarn add #2020-05-0708:57erwinrooijakkersAutomatically#2020-05-0708:58erwinrooijakkersOkay everything is cleared up#2020-05-0708:58erwinrooijakkersIt does indeed#2020-05-0708:58erwinrooijakkersThe problem was not Reagent or shadow-cljs#2020-05-0708:58erwinrooijakkersThe problem was misconfigured zenroom package#2020-05-0709:22erwinrooijakkersI added an issue on that package and they’ll look into it. I am happy that I understand now what went wrong and that shadow-cljs is doing everything as hoped.#2020-05-0711:46erwinrooijakkersAnd @U05224H0W thanks a lot for thinking a long. I really appreciate the work your putting in shadow-cljs, it works supersmoothly, and also your active replies on people their problems here, like pinpointing my issue within a minute to be in the external package’s config.#2020-05-0710:51Gordon KingHi has anyone has come across this error when doing a release.
The required namespace "shadow.js" is not available, it was required by "node_modules/react/index.js"
I don't have this anywhere in my code nor do I have any clue why react is requiring it. I can get the app to compile by installing the npm package shadow.js (whatever that is, plus a dependency rxjs) and it will compile successfully, but then when loading the compiled javascript I get the error
uncaught ReferenceError: shadow is not defined
Appreciate any hints or help.
#2020-05-0710:54thhellershadow.js is a helper namespace for npm JS interop. it comes with shadow-cljs. should be basically impossible that it doesn't exist?#2020-05-0710:55thhellerit is not an npm package, no clue how it even gets to that logic?#2020-05-0710:55thhellerdo you use any kind of weird non-standard setup that may dynamically modify the classpath? ie. running in embedded? or boot maybe?#2020-05-0711:06Gordon KingYes running via a boot task, sorry should have mentioned it works fine via the command line. That would be important to know. I've spent the evening trying to hunt down class path conflicts. Unfortunately prefer to keep it in boot as its a step in a complicated deployment rpm/generation process. Task based on https://github.com/jgdavey/boot-shadow-cljs/blob/master/src/com/joshuadavey/boot_shadow_cljs.clj#2020-05-0711:07thhellerdon't know much about boot sorry. don't know how it even gets to a working state but then missing files that are in the exact same .jar#2020-05-0711:07thhellerbut I'm currently rewriting a bunch of classpath logic so it might accidentally fix that issue as well#2020-05-0711:22Gordon KingSomeone had the same error doing something with Karma back in 2018...doesn't jog a memory just on the off chance? https://clojurians-log.clojureverse.org/shadow-cljs/2018-08-22#2020-05-0711:22thhellerthats not related#2020-05-0711:23thhelleruncaught ReferenceError: shadow is not defined is the effect of the file missing in the first place#2020-05-0711:23thhellernot sure how you ever get past the error of shadow.js missing but any attempt at hacking that together will make everything else fail#2020-05-0711:24thhellerthe problem is the classpath issue#2020-05-0711:26thhellerhttps://github.com/jgdavey/boot-shadow-cljs/blob/master/src/com/joshuadavey/boot_shadow_cljs.clj#L59#2020-05-0711:26thhellerthis is downright scary old. certainly hope that is not the version you end up using.#2020-05-0711:27thhellerthe entire boot thing is scary to be honest. I never understood how any of it works#2020-05-0711:29Gordon Kingheh no I'm on your latest...#2020-05-0711:41Gordon KingFixed it! Thanks for posting that above. it got me thinking that the install-dependencies hook might not be working or doing the right thing in the right order. I added shadow-cljs to the main boot dependencies and its working finally!#2020-05-0711:42Gordon KingIts more magic than rails is boot...#2020-05-0712:01kwrooijenHi, does shadow-cljs have any method of handling (private) git repos as dependencies? Or should I just opt for deps.edn? I couldn’t really find anything on this topic.#2020-05-0712:04Pavel KlavíkHi, I have the following code in my cljc file:
#?(:clj  (slurp (io/resource "my-web/test.txt"))
   :cljs (resource/inline "my-web/test.txt"))
Is there a way to replace it with a single macro so this is easier to use? Not sure how to distinguish between Shadow-cljs and Clojure running the macro?
#2020-05-0712:19thheller@kevin.van.rooijen not supported. need to use deps.edn for that.#2020-05-0712:19kwrooijenAll right, thanks! 🙂#2020-05-0712:20thheller@pavel.klavik resource/inline should work from clojure too although that would mean you'd have shadow-cljs as a runtime dependency so probably not recommended for CLJ#2020-05-0712:24Pavel KlavíkOk, I can test that, I don't really care about runtime dependency since this is a library for static web compilation: https://github.com/OrgPad-com/volcano.#2020-05-0712:29Pavel Klavíkseem to work great, thx#2020-05-0712:31Pavel Klavíkbtw. if I have an inline JS function defined in my html file:
<script>function f { ... }</script>
how can I call it from my Clojurescript call? I tried js/f, but I get that it is undefined.
#2020-05-0712:45thhellershould be fine. did you ensure that is defined before your own code tries to access it?#2020-05-0712:51Pavel KlavíkThe script is defined above, and I have :on-click defined on the button div at the bottom.#2020-05-0712:52Pavel Klavík
[:div.button-filled #?(:clj  {:onclick "f();"}
                       :cljs {:on-click #(js/f)})
     "Odeslat"]
#2020-05-0712:57thhelleryeah you can't do that from hiccup, that is rendered by react#2020-05-0712:58thhellerjust use :on-click js/f#2020-05-0712:58thhellernevermind that would be the same#2020-05-0712:58thhellerthe CLJ version is the problem I suppose?#2020-05-0712:59Pavel Klavíkno, cljs. clj works fine#2020-05-0713:00thhellerI can't tell if that code actually runs when it is declared#2020-05-0713:00thhelleryour script tag including the cljs code comes after this?#2020-05-0713:00thhellerotherwise js/f is just nil at the time it reaches that point#2020-05-0713:01Pavel Klavíkya, I am producing a single hiccup for the entire page, so it contains both the script and the button#2020-05-0713:03thhellerthat isn't what I asked#2020-05-0713:03thhellerwhat is the actual order in your HTML#2020-05-0713:03thheller<script>function f() ...<script> MUST come before <script src="js/foo.js"> (your compiled CLJS output)#2020-05-0713:04Pavel Klavíkya, it happens like that:#2020-05-0713:04thhelleror do you produce the script tag itself from hiccup also?#2020-05-0713:05Pavel Klavíkscript tag for f is produced by hiccup also right now#2020-05-0713:05thhelleryeah that doesn't work. that just emits it as text and never evals it#2020-05-0713:06thhellerneed to actually js/goog.global.eval it instead, can skip the script tag#2020-05-0713:06Pavel Klavíkya, makes sense, so what would be the solution? Is it possible to add some reflection call to on-click? Or should I split this and include the script before?#2020-05-0713:07thhellerwell why isn't this part of the CLJS build in the first place?#2020-05-0713:07thhellerI mean why is it added as a script tag?#2020-05-0713:08thhelleryou just need to eval it in some way before trying to access it#2020-05-0713:11Pavel Klavíkok, so if I have a bunch of script files whose list is defined in runtime, how can I eval them? Should I call js/goog.global.eval on them?#2020-05-0713:12Pavel Klavíkbasically, in development I need to somehow eval them, in building static web, I just need to inline them#2020-05-0713:20thhelleryes when loading them from JS just eval the code#2020-05-0713:22Pavel Klavíkso what should I call for that?#2020-05-0713:23thheller(js/goog.global.eval the-code)?#2020-05-0713:24thhellerjust make sure you don't do it on every reagent render, that would be pointless#2020-05-0713:27Pavel Klavíkso how should I approach this to have hot code reloading?#2020-05-0713:27Pavel KlavíkI should put it into mount-root fn?#2020-05-0713:29thhellerif the code you are loading that way is safe to reload you can do that yes#2020-05-0713:30thhelleror just put it into the page directly? I assume you generate the base page from CLJ anyways?#2020-05-0713:35Pavel Klavíkhmm, ya, combination of these might work#2020-05-0713:37Pavel Klavíkthings like static libraries (i.e., jQuery) can go into the page directly, and scripts you write and want to inline can be included using js/goog.global.eval. thx, will test this out#2020-05-0713:43thhellerI don't quite understand what you are doing or why this stuff isn't part of the regular build though#2020-05-0713:45Pavel Klavíkit is a static website generator, where development runs as SPA using Reagent and Shadow-cljs, so you get hot code reloading, and then you build static website files#2020-05-0713:46thhellerso there is no compiled CLJS code on the page once you are done?#2020-05-0713:47Pavel Klavíkya, nothing#2020-05-0713:48Pavel KlavíkI am trying to add some basic js support so you can have contact forms, etc., but nothing too big#2020-05-0713:51thhellerok I expected there to be some CLJS at runtime regardless. mostly because I wouldn't want to write any JS I guess 😛#2020-05-0713:52Pavel Klavíkya, I feel the same, but basically the goal is to just have a few lines of JS for needed stuff, nothing big, and we want to optimize the download time#2020-05-0713:52Pavel Klavíkbasically the idea is that I want the similar comfort as with Reagent and Shadow-cljs, but for developing static web#2020-05-0713:53thhellerwell the :advanced CLJS build is basically the same size of jquery so thats no argument 😛#2020-05-0713:56Pavel Klavíkya, I think I will probably get rid of jQuery as well, plain JS should be enough, but adding small amout of CLJS when you need to do more complicated stuff makes sense#2020-05-0714:10Pavel Klavíkok, it seems to work, thx#2020-05-0714:11Filipe Silvaheya all, I have a question if someone is around: is it possible to add configuration items to the default node-repl? In my specific case I'd like to add a :resolve in :js-options that would always be used in the node repl#2020-05-0714:12thhelleryou can merge that stuff in when starting the node-repl from CLJ#2020-05-0714:12thheller(shadow/node-repl {:config-merge [{:js-options {:resolve ...}}]})#2020-05-0714:15Filipe Silvaok#2020-05-0714:15Filipe Silvathere's no way to put it in shadow-cljs.edn then I take it?#2020-05-0714:16thhellerwell you can use :build-defaults or :target-defaults (not documented anywhere though)#2020-05-0714:16thhellersay you want ALL your builds to share the same resolve config#2020-05-0714:16thheller:build-defaults {:js-options {:resolve ...}}#2020-05-0714:17thheller:target-defaults {:node-script {:js-options ...}} would only apply to :node-script builds#2020-05-0714:17Filipe Silvais that something that should be documented? I can add it to the docs#2020-05-0714:18thhellerprobably 😛#2020-05-0714:18Filipe SilvaI guess the real question is not if it should be documented, is if you'd like to support it#2020-05-0714:18thhellernode-repl should probably be configurable elsewhere too though. feels like a bad idea to try to abuse the defaults for that 😛#2020-05-0714:18Filipe Silvaif it is part of the supported features, then it should be documented#2020-05-0714:19thhellerI added it since I thought it might be a good idea but never actually used it anywhere 😛#2020-05-0714:20Filipe SilvaI don't know how legitimate my case is really... we have a bunch of node and browser builds, and they share some code. In the shared code, there's an import to a JS library that only works in browser. We added a resolve to redirect that require to a local js file that contains a stub. I would like to be able to say "for all builds but the browser build, resolve this library to the stub". That seems to be something that build-defaults would do well.#2020-05-0714:21Filipe Silvaat some point we tried to do the opposite: require the stub, and resolve the stub to the real library in the browser app, but that didn't seem to work#2020-05-0714:21Filipe SilvaI didn't debug why though, maybe I was resolving it wrong or something#2020-05-0714:23thhellerwell the config merge is rather basic so there really no way to remove a :resolve once its there#2020-05-0714:23Andy HeywoodAm I right in thinking (it certainly seems to be the case) that if I already have a shadow-cljs server running in another process, shadow-cljs watch :test will not autorun tests?#2020-05-0714:23Andy Heywoodohhhh I’m an idiot sry, they’re run and the output is in the server terminal#2020-05-0714:24thhellerit does autorun the tests but the output goes to the server process currently#2020-05-0714:24thhellerI think there is an open issue about that somewhere 😛#2020-05-0714:24Andy Heywoodyeah not ideal, but easy enough to work around#2020-05-0714:24Andy Heywoodthanks#2020-05-0714:25Filipe Silvahttps://github.com/thheller/shadow-cljs/issues/487 is the issue#2020-05-0714:25Andy HeywoodI assume it makes no difference if I just lean on the test watcher as the server, instead of starting one explicitly#2020-05-0714:26thhellertesting will be different soon anyways I hope. working on something that should improve the situation a bit.#2020-05-0714:34Derekis it the kaocha integration?#2020-05-0714:36thhellerno. that is happening separately though.#2020-05-0714:36Derekcool 🙂#2020-05-0714:26Andy Heywoodnice#2020-05-0714:27Filipe Silvadoes the user guide have a repository where I could contribute that :build-defaults bit to?#2020-05-0714:27thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_contributing 😛#2020-05-0714:28Filipe Silvaurf durf #2020-05-0714:29Filipe Silvajust to be clear about the semantics#2020-05-0714:29Filipe Silvahttps://clojurians.slack.com/archives/C6N245JGG/p1588861409381600#2020-05-0714:29Filipe Silvaby this do you mean that config items cannot be removed, or cannot be overwritten?#2020-05-0714:30Filipe Silvae.g. if I set a resolve on build-defaults can I overwrite it on my app config?#2020-05-0714:35thhelleroverride yes, remove no.#2020-05-0714:37Filipe Silvaok#2020-05-0714:37Filipe Silvadoes it go in toplevel config, or inside :builds?#2020-05-0714:39thhellertop-level#2020-05-0714:39thhellermerge order is build-defaults -> target-defaults -> actual build config -> extra config merges#2020-05-0714:48KamuelaIs there a quickstart guide for Node.js server-side with shadow?#2020-05-0714:53thhellerjust create a :node-script build and go 🙂#2020-05-0714:57KamuelaI'm a few steps behind that.
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :builds
 {:backend
  {:target :node-script
   :modules
   {:main {:init-fn acme.backend.core}
    :output-to "main.js"}}}}
Here's what I'm trying
#2020-05-0716:10thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script#2020-05-0716:11thheller:modules does not apply to :node-script. just plain :main.#2020-05-0815:17KamuelaThank you! Got some play code up and running 🙂#2020-05-0714:56Filipe Silvahttps://github.com/shadow-cljs/shadow-cljs.github.io/pull/50 here's the docs pr for the defaults
#2020-05-0806:04SpacemanI'm getting shadow-cljs stale client - you're not using the latest compilation output for some reason. I deleted my target and my out files and rebuilt using (shadow/watch :app) but I still get this prompt. How do I fix this?#2020-05-0806:04SpacemanAlso, in the repl I get
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
#2020-05-0807:31thheller@pshar10 you fix that by loading the correct files. seems like you maybe cleared the wrong directory or wrong server or so.#2020-05-0811:43yenda@thheller found 1 reason to use ^:const , you can't use a def in a case#2020-05-0813:47aisamuhttps://blog.fikesfarm.com/posts/2015-06-15-clojurescript-case-constants.html#2020-05-0813:48thhellercheck a few lines below this 😛#2020-05-0811:43thheller?#2020-05-0811:45yenda(let [test 4] (case test constants/command-state-request-transaction true false))#2020-05-0811:45yendaevals to false#2020-05-0811:45yendaconstants/command-state-request-transaction is def to 4#2020-05-0811:47thhellerthats a bug in CLJS then#2020-05-0811:48yendahttps://blog.fikesfarm.com/posts/2015-06-15-clojurescript-case-constants.html#2020-05-0811:48thhellertry it in CLJ#2020-05-0811:48thheller
user=> (def ^:const y 1)
#'user/y
user=> (case 1 y true false)
false
user=> (case 'y y true false)
true
#2020-05-0811:50yendaso you mean that the fact that it works in cljs with a const is a bug?#2020-05-0811:52thhellerno clue. I never use ^:const for anything. Maybe this is intentional. Maybe it actually works in CLJ and I'm just doing something wrong. the clojure docs clearly state that the test contants are not evaluated#2020-05-0811:52thhellerhttp://clojuredocs.org/clojure.core/case#2020-05-0811:53thhellerso looking up the var and seeing it was a const would imply some evaluation#2020-05-0811:55thhellerIMHO that would be a bug but IMHO the entire :const impl in CLJS is a bug#2020-05-0812:44yendaI tried to put :source-map false :source-map-include-sources-content :false in compiler options for :dev build but I still see source maps files in the output dir, does it mean it didn't work? (I cleaned all dir before recompiling)#2020-05-0812:51yendamhm I see this is known https://github.com/thheller/shadow-cljs/issues/328#2020-05-0812:51yenda@thheller would it be possible to allow disabling source-maps in dev? main reason is that they are mostly useless in react-native and result in huge bundles#2020-05-0813:13thheller@yenda how do they result in huge bundles? they aren't inlined?#2020-05-0813:25yenda#2020-05-0813:26yendaif you want to have a look that's our index.js#2020-05-0813:26yendabtw do you think it would be possible for shadow to write index.js in a temp file and replace it only once it is done writing? to avoid the metro bundler bug#2020-05-0813:28thhellerhmm it seems I forgot that react-native actually inlines the source maps#2020-05-0813:28thhellercan't remember why though#2020-05-0813:28thhellerI can certainly allow to disable that#2020-05-0813:30thhellerah I think that was the only way to get the source maps to work at all when running the debug-in-chrome thingy#2020-05-0813:31yendaand how does the rewriting of the index.js works? would it be possible to do it in a temp file first ?#2020-05-0813:32thhellerI don't really like working around bugs in other tools but sure I can add that#2020-05-0813:35thhelleruhm doesn't :compiler-options {:source-map false} not already turn off the source maps?#2020-05-0813:42yendaI tried but I could still see .map files and the index.js looked like it was same size#2020-05-0813:47thhellerhmm yeah indeed#2020-05-0817:33SpacemanWhy doesn't macro expand work in the cljs repl?#2020-05-0817:33SpacemanI define a macro in a clj file myapp.macros#2020-05-0817:33Spacemanand then require it in myapp.macros cljs file#2020-05-0817:33Spacemanand then use the macro in a third file#2020-05-0817:35Spacemanwhen I macro expand in the clj repl, the macroexpansion works:
(macroexpand '(db-event :foo [foo bar] [:foo foo :bar bar]))

(do
 :foo
 (clojure.core/fn
  [db__49764__auto__ [foo bar]]
  (clojure.core/apply
   clojure.core/assoc
   db__49764__auto__
   [:foo foo :bar bar])))
But in the shadow repl, this gives:
(macroexpand '(db-event :foo [foo bar] (assoc db :foo foo :bar bar)))
=> (db-event :foo [foo bar] (assoc db :foo foo :bar bar))
#2020-05-0819:47thheller@pshar10 just a guess but maybe you didn't follow the instructions I sent you before again? https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-05-0918:03sergey.shvetsThat article is gold, btw! Helped me to put a macros in no time! Thank you!#2020-05-0819:47thhellerif you don't do all of those steps then macros will not work as you expect#2020-05-0819:48thhellerand you cannot define a macro from a REPL unfortunately currently#2020-05-0819:52Spacemanthat's the issue indeed.#2020-05-0819:56thhellermacros live completely in CLJ anyways so I usually just work on them via a CLJ REPL and macroexpand it there#2020-05-0819:57thhellermaybe you can get used to that workflow too if you try. works pretty well for me.#2020-05-0819:48thhellerwell you can if its a CLJ REPL but that doesn't get you around the other limitations#2020-05-0822:11thhellerwrote a new post https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html for people asking about how :bundle affects shadow-cljs#2020-05-0902:07metehanshadow cljs starts on port 8080 then says 8080 in use and starts at port 8081, i didn't change anything it was working normally
shadow-cljs - config: D:\Dev\spill\spill_cljs\shadow-cljs.edn  cli version: 2.8.51  node: v10.16.0
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at 
[2020-05-09 04:04:29.520 - WARNING] TCP Port 8080 in use.
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.51 running at 
shadow-cljs - nREPL server started on port 4023
#2020-05-0902:13metehanactually i don't have any problem i can see my app on both ports 🙂#2020-05-0907:44thheller@m373h4n likely something else running on 8080. might be another shadow-cljs instance?#2020-05-0909:32metehanactually it's same instance, when i stop this both 8080 and 8081 is becomes free again. when i start shadow-cljs starts on both ports by giving the output above#2020-05-0909:51thhellerah do you have conflicting configs? using the same :devtools {:http-port 8080} for two builds?#2020-05-0922:05ak-coramI get the following error when trying to use the self-hosted clojurescript (cljs.js) and targeting :browser #error {:message "Could not eval (+ 1 1)", :data {:tag :cljs/analysis-error}, :cause #error {:message nil, :data {:clojure.error/source nil, :clojure.error/line nil, :clojure.error/column nil, :clojure.error/phase :compilation}, :cause #error {:message "Cannot read property 'findInternedVar' of null", :data {:tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}}#2020-05-0922:05ak-coramany ideas what this means?#2020-05-0922:32ak-coramI'm using :simple optimizations btw#2020-05-0923:06mssjust upgraded to 2.9.0 and am now getting the following error:
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).
ES3

Full report at:
/var/folders/rc/lsvprbcs66q69q5ywxrg10xm0000gn/T/clojure-5971753772166324101.edn
the linked log provides the following:
#2020-05-0923:06mss
{:clojure.main/message
 "Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).\nES3\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 1,
  :clojure.error/source "api.clj",
  :clojure.error/path "shadow/cljs/devtools/api.clj",
  :clojure.error/class java.lang.NoSuchFieldError,
  :clojure.error/cause "ES3"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 1,
     :clojure.error/source "shadow/cljs/devtools/api.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7648]}
   {:type java.lang.NoSuchFieldError,
    :message "ES3",
    :at [cljs.closure__init load nil 133]}],
  :trace
  [[cljs.closure__init load nil 133]
   [cljs.closure__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 348]
   [clojure.lang.RT classForName "RT.java" 2211]
   [clojure.lang.RT classForName "RT.java" 2220]
   [clojure.lang.RT loadClassForName "RT.java" 2239]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.core$require doInvoke "core.clj" 6007]
   [clojure.lang.RestFn invoke "RestFn.java" 2088]
   [cljs.repl$loading__5569__auto____6381 invoke "repl.cljc" 9]
   [cljs.repl__init load nil 9]
   [cljs.repl__init <clinit> nil -1]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 348]
   [clojure.lang.RT classForName "RT.java" 2211]
   [clojure.lang.RT classForName "RT.java" 2220]
   [clojure.lang.RT loadClassForName "RT.java" 2239]
   [clojure.lang.RT load "RT.java" 449]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.core$require doInvoke "core.clj" 6007]
   [clojure.lang.RestFn invoke "RestFn.java" 3894]
   [shadow.cljs.devtools.api$eval1540$loading__6721__auto____1541
    invoke
    "api.clj"
    1]
   [shadow.cljs.devtools.api$eval1540 invokeStatic "api.clj" 1]
   [shadow.cljs.devtools.api$eval1540 invoke "api.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7166]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.core$require doInvoke "core.clj" 6007]
   [clojure.lang.RestFn invoke "RestFn.java" 1523]
   [shadow.cljs.devtools.cli$eval138$loading__6721__auto____139
    invoke
    "cli.clj"
    1]
   [shadow.cljs.devtools.cli$eval138 invokeStatic "cli.clj" 1]
   [shadow.cljs.devtools.cli$eval138 invoke "cli.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7177]
   [clojure.lang.Compiler eval "Compiler.java" 7166]
   [clojure.lang.Compiler load "Compiler.java" 7636]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6839 invoke "core.clj" 6126]
   [clojure.core$load invokeStatic "core.clj" 6125]
   [clojure.core$load doInvoke "core.clj" 6109]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5908]
   [clojure.core$load_one invoke "core.clj" 5903]
   [clojure.core$load_lib$fn__6780 invoke "core.clj" 5948]
   [clojure.core$load_lib invokeStatic "core.clj" 5947]
   [clojure.core$load_lib doInvoke "core.clj" 5928]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$load_libs invokeStatic "core.clj" 5985]
   [clojure.core$load_libs doInvoke "core.clj" 5969]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$require invokeStatic "core.clj" 6007]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "ES3",
  :phase :compile-syntax-check}}
#2020-05-0923:06mssif anyone has run into something similar or has any ideas what I might have misconfigured, please let me know. thanks in advance#2020-05-1003:42lilactownhmm I don't even see the commit for 2.9.0#2020-05-1006:26ElirazHey, I'm  trying to move from React to Reagent using `shadow-cljs` but for some reason I don't understand, I keep getting this message *shadow-cljs - Stale Client! You are not using the latest compilation output!*#2020-05-1006:26ElirazWhen I add break points on any piece of code it seems like it gets to it but does not really execute it. not even `(js/alert "lala")`#2020-05-1007:09Elirazany help would be appreciated#2020-05-1007:22thheller@mss that is a version conflict. you have the incorrect clojurescript version. 2.9.0 needs cljs 1.10.758,#2020-05-1007:24thheller@eliraz.kedmi157 that means that the code you are loading is not the code produced by the watch you have running. commonly that happens if you configure a different :output-dir or :modules without updating the references in your HTML to actually use those files.#2020-05-1008:01thhellerFWIW I pushed 2.9.0 yesterday which was bumped to 2.9 because of the classpath indexing changes. this should make startup a little faster and have less issues with bad jar contents (containing compiled CLJS output). I hope it doesn't have any other negative effects, so if something weird starts to happen in your apps let me know.#2020-05-1008:16thheller@yenda in 2.9.0 you can also turn of source maps for react native via :compiler-options {:source-map false}#2020-05-1009:45yendaNice thanks#2020-05-1010:06Eliraz@thheller Thank you, that make sense 😛#2020-05-1010:06Elirazis there a way to know what the js filename would be?#2020-05-1010:08ElirazI got it. it's the same filename as the cljs one#2020-05-1013:42thhellerthe module id is the name :modules {:main {...}} produces main.js in :output-dir#2020-05-1017:59armed@eliraz.kedmi157 I always get stale client error when forgot to turn of caching in chrome dev tools. #2020-05-1018:00ElirazThank you! the issue actually was that no js was loaded#2020-05-1018:00Elirazthe path in the HTML was wrong#2020-05-1018:00ElirazI wish there was a better error message to it#2020-05-1018:39Sam GHello! I am trying to add Quil to my project but when I try to compile it tells me that The required JS dependency "p5" is not available, it was required by "cljsjs/p5.cljs". I close the repl, npm install p5, it tells me that it adds + and I can see the folder in /node_modules/ , but when I lein dev it fires back up and eventually tells me that it is still missing p5. What else should I be doing to fix this?#2020-05-1018:40lilactownis your project based off of some sort of template?#2020-05-1019:09Sam GI started with lein new re-frame and added retit and now quil#2020-05-1019:33dpsuttonI see “required by cljsjs/p5 there which is problematic in shadow#2020-05-1019:33thheller@dpsutton no it isn't. that is already the stub file mapping the cljsjs package to p5#2020-05-1019:34thheller@skiracer1292 I don't know what lein dev does so I can't help much. make sure you are in the correct directory and so on. also make sure lein dev isn't resetting your node_modules or so#2020-05-1019:36thhellerI must say I'm getting a little tired of lein-shadow ...#2020-05-1019:36dpsutton(Sorry for misreading and derailing)#2020-05-1019:41Sam GI am still pretty new to clojure and was recommended the re-frame template to start but if you don't recommend using the lein-shadow plugin that comes packaged with it I will look into setting the project back up to just use shadow and see if I can avoid this all together.#2020-05-1019:45thheller@skiracer1292 just make sure you are actually in the correct directories ... lein-shadow sort of starts out without a package.json and if you run npm install p5 in a directory without a package.json then all bets are off where it actually installs things#2020-05-1019:47thhellermake sure there is a package.json in the dir of your project.clj#2020-05-1019:47thhellerif there isn't one you can just run npm init -y#2020-05-1019:49Sam GI am in the project base directory when I install and can see the folder created in ~/project/node_modules/, if I have a finder window watching the node_modules I see the p5 folder get culled out. I tried adding "p5": "1.0.0" to the existing package.json and also watch that get replaced when I lein dev, which is defined as ["with-profile" "dev" "do" ["shadow" "watch" "app"]] in alases and {:dependencies [[binaryage/devtools "1.0.0"]]  :source-paths ["dev"]} in profiles#2020-05-1019:53thhellerdunno why it does that. its not shadow-cljs doing that. I tried to convince the authors not to use lein-shadow but somehow this is supposed to be easier with it ...#2020-05-1023:00superstructorCould you please provide some concrete information behind this @thheller. Why ? What is the disadvantage ?#2020-05-1019:53thheller:face_vomiting:#2020-05-1019:53thhellerplease open a bug report with the re-frame template ...#2020-05-1019:55Sam Gwill do. it is easy to get it to pop up in a fresh re-frame template project#2020-05-1020:00thhellerbut yeah consider moving away from lein-shadow completely#2020-05-1023:02superstructorWhy ?#2020-05-1103:40mikethompsonIn an attempt to stop support issues hitting this channel, we have added to the docs: https://github.com/day8/re-frame-template#how-to-add-dependencies#2020-05-1107:19thhellerthat is precisely why. npm should be in charge of it and npm should be used as is. consider that there might be people coming from the JS ecosystem familiar with npm (or yarn) and then suddenly things don't work as expected#2020-05-1107:19thhellerpeople might just want to use npm as is ... maybe they want scripts, maybe they want other things in package.json#2020-05-1107:20thhelleryou just wiping it without considering this is bad practice#2020-05-1107:21thhelleralso I always point people towards my docs and even the error message tells people to run npm install whatever#2020-05-1107:21thhellerwhich then doesn't apply since you do things differently#2020-05-1107:22thhellerI completely disagree with doing everything in project.clj ... that counts for shadow-cljs.edn as well since you lose a bunch of features by doing that#2020-05-1107:22thhellereg. config auto-reload. shadow-cljs watches shadow-cljs.edn for build changes etc.#2020-05-1107:23thhellersuiddenly that is gone because use has to edit project.clj or the changes are gone#2020-05-1107:23thhellerpeople may also prefer to use yarn over npm ... but they can't#2020-05-1107:25thhellerone thing npm does better than anything in CLJ(S) is npm install some-package without having to know the version#2020-05-1107:25thhellerthat is also gone ...#2020-05-1107:26thhellerIMHO you are not fixing anything npm related by moving it and just make it look like it doesn't exist.#2020-05-1107:26thhellerthat is bad ..#2020-05-1108:25superstructorThanks for the feedback @thheller, but its still not clear why the recommendation you propose is better for common use cases for ClojureScript devs#2020-05-1108:26thhellerwriting a longer reply on the github issue right now ...#2020-05-1108:26superstructorOk will await that 🙂 Thanks.#2020-05-1020:03Sam Ghttps://github.com/day8/re-frame-template/issues/128#2020-05-1020:05thhellerFWIW I looked at the source and it seems like you are supposed to add :npm-deps {"p5" "1.0.0"} to your project.clj#2020-05-1020:12lilactownyeah I used lein-npm at my last gig and it was awful and confusing#2020-05-1020:15lilactown> It also manages your npm dependencies in the :npm-deps key, checking for any changes on every run.#2020-05-1020:23Sam Gwhere are you seeing these docs? I have looked around for lein-shadow docs and found nothing 😞 I just found https://gitlab.com/nikperic/lein-shadow/-/blob/master/examples/lein-shadow-example/project.clj and tried to mimic their :npm-deps key with :npm-deps  [[p5 "1.0.0"]] and it still culls out my p5 library. same with :npm-deps {"p5" "1.0.0"#2020-05-1020:24thhellerno clue why that example has figwheel and cljsbuild in it ...#2020-05-1020:24thhellerdoesn't look like a good example#2020-05-1020:31nsauce@thheller ever come across this issue?
errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/request-compose/compose.js", :js-requires [], :js-errors [{:line 140, :column 3, :message "primary expression expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: /Users/njam/Github/nsauce/cannabit-lp/node_modules/request-compose/compose.js
#2020-05-1020:32thhellerprobably not a JS file#2020-05-1020:32thhellermight be JSX#2020-05-1020:33nsaucecan confirm it is a js file#2020-05-1020:33thhellermaybe its a node-only package?#2020-05-1020:34nsauceinteresting, it’s not a direct dependency of my project#2020-05-1020:35thhelleryeah quick glance at the code it is pretty clear this isn't intended to run in the browser#2020-05-1020:35nsauceyeah not sure why it’s being included on the client app compile process,#2020-05-1020:36thhellersomething required it somewhere#2020-05-1020:36nsauceyeah, i’ll have to hunt it down#2020-05-1020:36nsaucethanks for the help!#2020-05-1020:47nsaucehm, turns out I had a cljs file that was completely empty in a dependency, removing this file and repackaging my dependency fixed the issue#2020-05-1020:47nsauce@thheller ^#2020-05-1020:47nsauceso there might an issue with the compiler and empty files#2020-05-1020:48nsaucerecently updated to 2.8.107#2020-05-1020:48nsauceanyway it’s working so thanks again!#2020-05-1020:48thhellerempty files will definitely not add random dependencies 😛#2020-05-1020:49nsaucetotally, but it might be an issue reading the file?#2020-05-1020:52nsaucehm, nope adding another empty file does not cause the issue to reappear#2020-05-1020:52nsauceso I guess this was a corrupted dependency#2020-05-1020:52nsauceI dunno, its working so im happy#2020-05-1023:51folconIs there any way to get shadow-cljs to watch changes in js files?#2020-05-1107:16thheller@folcon js files in node_modules no, on the classpath that should already work#2020-05-1112:36folconIt doesn’t appear to? I’ve been trying to do it for a while, the file loads, but to get edits I have to keep rebooting the repl, which is a bit of a pain =)… I’m using the js-options:
:js-options
                   {:resolve {"terrain" {:target :file
                                         :file "resources/public/js/terrain.js"}
#2020-05-1114:11thhellerwhy not use https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js instead? no :resolve config required for that#2020-05-1114:56folconReading =)…#2020-05-1115:22folconWell I keep getting failed to convert sources… Not sure if there’s something I need to do to get it working?#2020-05-1115:29folconI’m not sure that reloading work either? I verbatim copied the imported code across to get things working, but it’s still complaining about missing imports… I thought it might not be watching the folder but:
(shadow/watch :test)
=> :already-watching
#2020-05-1115:30thhellerwell I cannot guess what is happening without more info#2020-05-1115:30folconI can certainly import the code, but the old code…#2020-05-1115:30thhellerwhats the actual error?#2020-05-1115:31folconWell the biggest one is that the javascript code in the path doesn’t appear to reload? I’m not sure if I’m supposed to refresh it in some special way?#2020-05-1115:31thhellerI do not have enough information to answer that#2020-05-1115:32thhellerI have no clue what you actually have now#2020-05-1115:32thheller:resolve with :target :file is not supposed to reload and never will. mostly because it shouldn't be used in the first place#2020-05-1115:32folconsorry, I was following your instructions regarding using classpath-js =)…#2020-05-1115:33folconI’ve removed the :resolve in shadow-cljs config, and now have it under my src and am requiring it with:
["/rm/terrain" :as terrain]
["/rm/language" :as language]
#2020-05-1115:34folconThe import works, but making code changes in the js files doesn’t appear to do anything…#2020-05-1115:34thhellerfirst of all please use the full filename#2020-05-1115:34folconAs in the absolute path?#2020-05-1115:34thhellerok reloading depends on how the file is written#2020-05-1115:34thhelleras in with extension#2020-05-1115:34folconOr just using .js#2020-05-1115:35thhellerhow is the code written? does it use import/export?#2020-05-1115:35folconAh sure, I was just copying what’s in the userguide which doesn’t do that =)…#2020-05-1115:36folconIt didn’t originally, I’ve basically just exported every function and am resolving the imports….#2020-05-1115:36thhelleryeah it doesn't affect anything ... I'm just likely going to remove the "guess-the-extension" part soon#2020-05-1115:36thhellerI need to know how#2020-05-1115:36thhelleryou are making this harder here ... I'm guessing what you are doing#2020-05-1115:37thhellerjust give me more info and I can actually help#2020-05-1115:37thhellerthere are a billion different ways to do things#2020-05-1115:37thhellerI cannot guess them all#2020-05-1115:38folconOk would a gist help?#2020-05-1115:39thhellerabsolutely#2020-05-1115:40thhellera simple example might be enough. basically I do not know what you mean when you say "exported every function" since there are multiple ways of doing that#2020-05-1115:41thhelleris is ESM export function foo or is it commonjs exports.foo = function ...#2020-05-1115:41thhellerone it hot-reloadable while the other is not#2020-05-1115:46folconGive me a minute =)… I’m putting something together, I’ve been wanting to figure out a way to get more comfortable with cljs/js interop and I’m still super unfamiliar with this stuff#2020-05-1116:06folconHere: https://github.com/Folcon/terrain#2020-05-1116:06folconI’ve just got a minimal case#2020-05-1116:08folconI can add in the changes I made, but that might be counterproductive… The synopsis is that I just added export before functions that I wanted in language.js, eg:
export function makeRandomLanguage
export function makeWord
and basically all the functions in terrain.js.
#2020-05-1116:10folconHappy to do it if you’d find it helpful, it will just take me a sec to copy/paste…#2020-05-1116:15thhellerwell without exports you cannot access the functions from CLJS#2020-05-1116:18folconActually here: https://github.com/Folcon/terrain/compare/master...Folcon:js-code-reloading?expand=1#2020-05-1116:18folconThat’s the changes I made on a different branch#2020-05-1116:19folconso I can throw it away if there’s a better approach =)…#2020-05-1116:20thhellerwithout that it won't even load normally so you are going to need that regardless#2020-05-1116:20folconI’m testing it by: Adding a console.log in language.js:
export function makeRandomLanguage() {
    console.log("TEST");
    var lang = makeBasicLanguage();
    lang.noortho = false;
Then calling this in terrain-cljs.core-test:
(.makeWord language (.makeRandomLanguage language) "city")
#2020-05-1116:20thhellerI'm not actually sure anymore if this is even supposed to work#2020-05-1116:20folconAs in js hot code reload?#2020-05-1116:21thhellerhaven't worked on direct JS support in a rather long time#2020-05-1116:21thhellerimporting it should be fine but hot-reload I don't really know#2020-05-1116:21folconOk sure, so maybe not something you really want to support any more?#2020-05-1116:21thhellerI know it definitely won't work without export though#2020-05-1116:22folconThat’s been added, the branch https://github.com/Folcon/terrain/tree/js-code-reloading has all the changes with the exports…#2020-05-1116:22thhellerwell reloading JS is always tricky so it will always be more limited than reloading CLJS#2020-05-1116:22folconI can definitely load the js files, just not reload them =)…#2020-05-1116:23thhellerI can take a look later#2020-05-1116:23folconThanks =)…#2020-05-1116:24thhellercode in that branch looks correct and should in theory be hot-reloadable#2020-05-1116:41folcon😕 that’s not a good sign#2020-05-1122:35thhellertry 2.9.1, hot-reloading the JS should work fine again assuming they have proper import/export#2020-05-1218:05folconOh cool! Will give that a go in a bit!#2020-05-1113:41papachanI just included [goog.string :refer [format]] at my require namespaces, in dev it worked fine i can use (format) but it dont find the google lib when i compile a release bundle#2020-05-1114:06papachananyway i just replace it using (str % " " %) instead of format#2020-05-1114:12thheller@papachan goog.string.format is a separate namespace from goog.string so to use it properly you must require it separately#2020-05-1114:12thheller
[goog.string.format]
[goog.string :refer (format)]
#2020-05-1114:18papachanAh didnt know that ! thank you @thheller#2020-05-1117:07Logan Powell👋 hi everyone! it's been a while since I've been here. I missed you guys! I am updating a library I wrote in cljs a year or so ago. I updated to the latest version of Clojurescript and for some reason now I can't eval functions with docstrings or macros... does anyone have an idea what's going on?#2020-05-1117:08Logan Powelli'm using the latest shadow-cljs#2020-05-1117:08thhelleryou'll need to clarify what "I can't eval functions with docstrings or macros" means#2020-05-1117:08Logan PowellIt seems that I can eval functions if I remove the docstrings from them#2020-05-1117:08thhellergo back like 100 steps#2020-05-1117:08thhellerand start at the beginning#2020-05-1117:09thhellerwhat command did you run?#2020-05-1117:09thhellerwhen you say eval I assume REPL? which one?#2020-05-1117:09Logan PowellI'm using Cursive and I run send (form) to REPL#2020-05-1117:10Logan Powellin general, i'm getting some wierdness... I have been slamming my face against the keyboard for a day#2020-05-1117:11Logan PowellIt's been a while, but last time I updated the lib I could send forms to the REPL and they would seem to be read in correctly by printing the function name with a hash in front, like:
#'census.utils.core/update-map
#2020-05-1117:12Logan Powellbut now the REPL just prints nil#2020-05-1117:12Logan Powellwhen I include the docstring#2020-05-1117:13Logan PowellI'm like five minutes away from rewritting the thing in js#2020-05-1117:13Logan PowellI can't believe how much of a PITA the tooling is to pick up again (after a year off)#2020-05-1117:14Logan PowellI've tried Cursive, Calva, Chlorine, back to Cursive they all do the same thing#2020-05-1117:52mauricio.szaboI can look at this issue on Chlorine, but I'm not seeing this problem with any target I'm seeing... Did you try to update shadow-cljs? Or even core.async#2020-05-1117:14Logan PowellI don't know what I'm doing wrong#2020-05-1117:15thhellerI don't know what you are doing either so I cannot help unless you tell me more#2020-05-1117:15Logan Powellbtw, hi @thheller#2020-05-1117:15Logan Powelllong time, no talk#2020-05-1117:15Logan Powell😄#2020-05-1117:16Logan PowellI really don't know what else to tell you... I mean the same code worked last year#2020-05-1117:16thheller
$ shadow-cljs browser-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> (defn foo "docstring" [a] a)
#'cljs.user/foo
cljs.user=> (foo 1)
1
#2020-05-1117:17Logan Powelllet me try that#2020-05-1117:17Logan Powelljust simple#2020-05-1117:17thhellerworks fine for me .. and that is all the details I have gotten from you so far#2020-05-1117:18Logan Powell
λ shadow-cljs node-repl
shadow-cljs - config: C:\Users\logan\Projects\census\census-geojson\shadow-cljs.edn  cli version: 2.8.59  node: v10.16.2
shadow-cljs - connected to server
census.utils.core=> (defn foo "docstring" [a] a)
nil
census.utils.core=> (foo 1)
TypeError: Cannot read property 'call' of undefined
    at cljsEval (<eval>:1:31)
    at global.SHADOW_NODE_EVAL ([stdin]:90:10)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:24:1)
    at C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:49:13
    at Object.ret [as repl_call] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:104:11)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:47:1)
    at shadow$cljs$devtools$client$node$process_message (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\node.cljs:118:5)
    at C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:183:9
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:171:7)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (C:\Users\logan\Projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow\cljs\devtools\client\env.cljs:184:7)
census.utils.core=>
#2020-05-1117:21Logan Powelland without docstring...
> (defn foo [a] a)
#'census.utils.core/foo
> (foo 1)
1
census.utils.core=>
#2020-05-1117:21thhellerthat is odd. works fine for me with node-repl too.#2020-05-1117:21thhellerdo you use project.clj or deps.edn? or just plain shadow-cljs.edn?#2020-05-1117:21Logan Powellproject.clj, but I kinda rely on the pom.xml file with cursive#2020-05-1117:21Logan Powelljust plain shadow-cljs.edn#2020-05-1117:22thhellerwhat is it ... project.clj or shadow-cljs.edn?#2020-05-1117:22thhellerdo you have :lein true or something in shadow-cljs.edn?#2020-05-1117:22Logan Powellshadow-cljs.edn#2020-05-1117:22Logan Powellno to :lein true#2020-05-1117:22Logan Powellhere's my setup:
{:source-paths ["src"]
 :dependencies [[org.clojure/core.async "1.0.567"]
                [cljs-ajax "0.8.0"]
                [funcool/cuerdas "2.2.0"]
                [clojusc/defun "0.4.0"]
                [frankiesardo/linked "1.3.0"]
                ;[jamesmacaulay/cljs-promises "0.1.0"] ; FIXME: When batching cartography files: uncomment and `shadow-cljs pom`
                ;[cider/cider-nrepl "0.21.0"]
                [net.cgrand/xforms "0.19.2"]]
 :nrepl        {:port 3333}
 :builds       {:lib    {:target           :node-library
                         :output-dir       "public/census"
                         :output-to        "public/census/census.js"
                         :compiler-options {:optimizations :advanced}
                         :exports-var      census.core/census}
                :geo    {:target           :node-library
                         :output-dir       "public/geo"
                         :output-to        "public/geo/batch_convert.js"
                         :compiler-options {:optimizations :simple}
                         :exports-var      configs.geojson.core/batch_convert}}}
#2020-05-1117:24thhellerhmm only guess I have is that the core.async version does not match#2020-05-1117:24thhellertry [org.clojure/core.async "1.1.587"] but also upgrade shadow-cljs to 2.9.0#2020-05-1117:24Logan Powellk#2020-05-1117:24thhellerdunno why it would error out like that though#2020-05-1117:25thhellerbetter yet just remove the core.async dependency completely. shadow-cljs depends on core.async so it will always be available#2020-05-1117:25thhellerand that way you get the version it expects#2020-05-1117:25Logan Powellah, ok#2020-05-1118:00Logan PowellFuck yes dude!#2020-05-1118:00Logan Powellthat did it#2020-05-1118:00Logan Powell😛#2020-05-1118:01Logan Powellbtw, I did have to npm i -D ws#2020-05-1118:01Logan Powellwas getting an error that that was missing#2020-05-1118:01thhelleryou should have shadow-cljs installed in the project itself, that will take care of that also#2020-05-1118:01Logan Powellok, will do#2020-05-1118:02Logan PowellOMG you have no idea how angry I was getting 😄#2020-05-1118:02Logan Powell🙏#2020-05-1118:02Logan Powellthank you sir#2020-05-1118:02thhellerI'm curious to know what exactly happened since core.async issues usually fail in different ways 😛#2020-05-1118:03Logan Powellyou and me both#2020-05-1118:03Logan Powellwho knew#2020-05-1118:03Logan Powellyour intuition was right though#2020-05-1118:04Logan Powellman, I feel so much better... did you ever set up a way for us to donate to the project?#2020-05-1118:05thhellerhttps://github.com/thheller/shadow-cljs see the sponsors button 😉#2020-05-1118:06Logan Powell👍#2020-05-1203:02lilactownhave to say, I really love node-repl for experimenting. great job and thank you for that thheller!#2020-05-1207:40Shuai LinJust curious, what's the difference with node-repl and connect to shadow-cljs from emacs? To me it's all the same ...#2020-05-1203:33lilactownI'm trying to use a Closure JS file. currently, I see the file gets loaded in the page, but when I try and evaluate anything in the namespace it provides it can't find it#2020-05-1203:33lilactownit's using goog.module instead of goog.provides, if that makes a difference#2020-05-1203:34lilactownI originally had it nested lilactown.harmony and evaluating e.g. lilactown.harmony/ref would say "cannot find namespace lilactown"#2020-05-1203:34lilactownI changed it to a single symbol, harmony and that symbol is just undefined#2020-05-1204:24lilactowntried another thing: deleted goog.module and tried to just treat it as a commonjs module (since goog.module also uses exports.foo = ...) and importing it like ["../harmony.js" :as harmony]#2020-05-1204:24lilactowndoesn't work in node-repl, does work in browser-repl#2020-05-1206:18lepistaneHello i am looking into shadow-cljs and react native development I've used re-natal to develop hoby project before so i've got some background. i'd like to try shadow out because i've heard many, many good things about it before this point. I have few questions about this. Is there a official template for this? Basically something that allows me to create project structure for me similar how re-natal does? Also google search provided me with few examples of shadow being used with Expo which i'd like to avoid. Is there template or project that uses shadow-cljs but only vanila react native?#2020-05-1206:24lilactown@lepistane the user guide has a link to an example repo: https://shadow-cljs.github.io/docs/UsersGuide.html#_react_native#2020-05-1206:37lepistaneso basically there is no 'template generation' this is the template to use and adopt. Thanks for the quick reply!#2020-05-1208:14thhellerI don't use react-native myself so I hope someone else creates proper templates 😉#2020-05-1210:01lepistaneto be honest i've never made a template 😄 but nice idea this might be the way to do it 😄 i will have a look if i come up with it i will share it here. thanks for suggestion 😄#2020-05-1207:49thheller@lilactown importing via string only works for ESM modules, don't use commonjs exports.foo#2020-05-1207:50thhellergoog.module needs to call goog.module.declaryLegacyNamespace() to be usable (or whatever that was called)#2020-05-1207:52thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/goog_class.js#2020-05-1207:53thhellerhttps://github.com/thheller/shadow-cljs/blob/9f79c967a9cb3f07ce2a72baf1ecb24a2ca49e3a/src/dev/demo/browser.cljs#L22#2020-05-1207:54thhellerbut I'm not sure this works with regular CLJS, might require :foreign-libs config#2020-05-1209:40dimaHello!
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1).
ES3
Have this error after upgrading to 2.9.1 from 2.8.90 Clojurescript version is 1.10.597
#2020-05-1209:42dimaI’ve seen https://github.com/thheller/shadow-cljs/issues/693 and https://clojurians.slack.com/archives/C6N245JGG/p1589065614433100 but it didn’t help much#2020-05-1209:43thheller@trybeee need to upgrade clojurescript if you update shadow-cljs. should be 1.10.758#2020-05-1209:45dimaThanks, it works!#2020-05-1209:44thhelleror don't use deps.edn/project.clj to shadow-cljs can ensure you get the correct version 😛#2020-05-1209:49dimawe use shadow with clj-run so the shadow-clj version is set in deps#2020-05-1209:50thhellerthats what I mean. if you use deps.edn it is in charge of dependencies. there is nothing shadow-cljs can do to ensure you get the correct versions#2020-05-1209:50thhellerso you have to keep track of it yourself#2020-05-1210:58folconIs it possible for shadow to say that it expects a newer version of clojurescript?#2020-05-1210:59thhellernot in a clean way and I'd rather not put checks everywhere#2020-05-1211:49pmooserHow does hot CSS reloading work in shadow-cljs? Should it work even if I'm not using the dev http server?
#2020-05-1211:49thhelleryes, but that requires extra configuration to tell it where to watch#2020-05-1211:49thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading see :watch-dir#2020-05-1211:55pmooserOk, trying it ... thank you!#2020-05-1211:56pmooserThat seems to have worked!#2020-05-1214:02lilactownI tried three legacy namespace declaration and it still didn't seem to work#2020-05-1214:03lilactownLemme push a repo in a bit#2020-05-1214:10wcohen@loganpowell i’ve been working on https://github.com/Factual/geo/issues/69 Factual/geo to cljs the last few weeks — any comments you have about potential ways to integrate census-geojson would be appreciated! I made a (still very quiet!) #gis channel if you want to discuss there!#2020-05-1214:55lilactownokay, so re: Closure JS. after clearing my build cache, adding goog.module and declareLegacyNamespace, it does require successfully#2020-05-1214:55lilactownhowever, it's now failing on part of my code due to ReferenceError: $jscomp is not defined#2020-05-1214:56lilactownrepo: https://github.com/Lokeh/melody JS file: https://github.com/Lokeh/melody/blob/master/src/lilactown/harmony.js#2020-05-1214:56lilactownI'm running a node-repl and then loading this namespace: https://github.com/Lokeh/melody/blob/master/src/melody/core.cljs#2020-05-1214:56lilactownloading the namespace works!#2020-05-1214:57lilactownbut evaluating the forms in the comment at the bottom of the file, fails at the last one: (send ,,,)#2020-05-1214:59lilactownspecifically the line it seems to fail on (compiled) is:
Branch.prototype.flushNext = function() {
    var $jscomp$destructuring$var0 = $jscomp.makeIterator(this.unrealizedThunks);
#2020-05-1214:59thhellerhmm I guess its yet another scoping issue for $jscomp. thought I got them all but guess not#2020-05-1215:01thhellerhttps://github.com/Lokeh/melody/blob/master/src/lilactown/harmony.js#2020-05-1215:01thhelleris this file generated from .ts or did you write it by hand?#2020-05-1215:02thhellerI have yet to see an example of tsickle output so I'm curious?#2020-05-1215:02lilactownI generated it from tsickle#2020-05-1215:03lilactownI commented out
var module = module || { id: 'src/index.ts' };

goog.require('_.tslib');
#2020-05-1215:03lilactownand added goog.module.declareLegacyNamespace();#2020-05-1215:03lilactownbut those are the only modifications I've made#2020-05-1215:04thhellerwhats with all the if (false) {?#2020-05-1215:04lilactownheh not completely sure. those were TS interfaces#2020-05-1215:05lilactownbest guess is it tells GCC what e.g. @implements {IRef} means?#2020-05-1215:05thhellerI guess so#2020-05-1215:07thhelleris anyone here aware that using deps.edn or project.clj in simple projects like this that make no use of any other particular feature of those will make shadow-cljs start about 50% slower?#2020-05-1215:07thhellerI see almost everyone using either these days and actually just using shadow-cljs.edn seems to become rather rare?#2020-05-1215:08lilactownI was not aware of the slowness, but I am aware of the complexity. the reason I default to deps is that I often use local roots / git deps for experimenting#2020-05-1215:09thhellerwell you can get the faster version by depending on thheller/shadow-cljs$aot but I'd generally advise staying away from using that in deps/lein projects#2020-05-1215:09thhellertoo scary what happens with conflicts. shadow-cljs.edn can at least try to prevent some conflicts#2020-05-1215:10Andy HeywoodI did it (lein) without even thinking about it, coming from clj, but I think it helps the cursive integration? knowing this, I’ll try it without#2020-05-1215:10thhellerfor cursive integration just run shadow-cljs pom and load the generated pom.xml in cursive#2020-05-1215:11thhellerwell thats what I do ... project.clj is fine too. really its all fine just curious why nobody is using the fastest default 😛#2020-05-1215:12lilactownI expect for this specific project, I won't need any dependencies so i can just keep the deps.edn around for external usage but use shadow-cljs.edn for dependency resolution in-project#2020-05-1215:12lilactownthanks for the perf tip :+1:#2020-05-1215:12Filipe Silvaheya, kinda following up on https://clojurians.slack.com/archives/C6N245JGG/p1588861409381600#2020-05-1215:13Filipe SilvaI was trying to set a default resolve for everything so that using a certain lib wouldn't break the node-repl, then override it to self for the browser build (where it should work)#2020-05-1215:13Filipe Silvaso something like this#2020-05-1215:13Filipe Silva
;; Default all builds to resolving amplitude-js to the mock file. 
 ;; This way node-repl doesn't break when amplitude-js tries to use `window`.
 ;; 
 :build-defaults
 {:js-options {:resolve {"amplitude-js" {:target :file
                                         :file   "src/js/amplitude-mock.js"}}}}

 ;; On browser targets, resolve amplitude-js properly to the npm package instead.
 :target-defaults
 {:browser
  {:js-options {:resolve {"amplitude-js" {:target  :npm
                                          :require "amplitude-js"}}}}}
#2020-05-1215:14Filipe Silvaturns out resolving to self is a no-no 😞#2020-05-1215:14Filipe Silva
[:app] Build failure:
can't resolve to self
{:require "amplitude-js", :other "amplitude-js"}
ExceptionInfo: can't resolve to self
#2020-05-1215:15Filipe Silvathis looks like a perfectly reasonable error, so my question is whether there's some other way of doing this#2020-05-1215:15Filipe Silvamaybe resolving "src/js/amplitude-mock.js" to the npm target#2020-05-1215:19thhellerjust repeat the config to the builds that actually need it ... I mean how many can there possibly be? 😛#2020-05-1215:20Filipe Silvathat's the thing though, I can't set the amplitude-js -> src/js/amplitude-mock.js resolve on the node-repl config because that config doesn't exist#2020-05-1215:20Filipe Silvaor at least that's what I got from our last conversation#2020-05-1215:21thheller:node-repl is just a :node-script build so you can set it as a default for that?#2020-05-1215:21Filipe Silvasuppose I could, I never saw it as just a node-script#2020-05-1215:21Filipe Silvashould resolving the file to the node package also work though?#2020-05-1215:22thhellerI don't understand the question#2020-05-1215:24Filipe Silvaif I have a require such as (:require ["../../../amplitude-mock" :as amplitude], that refers to a js file in the source paths, should it be possible to use {:js-options {:resolve ... to resolve it to a npm package instead of the js file?#2020-05-1215:26thhellerno#2020-05-1215:27Filipe Silvagotcha#2020-05-1215:27Filipe Silvathank you#2020-05-1215:29thhellerat one point I'll write a proper post how you deal with this stuff cleanly. :resolve and hacks like it really should never ever be used. abstract it properly and you don't have to 😛#2020-05-1215:29thhellerkinda have to have it because JS is so messy but it should never leak over into CLJS projects 😛#2020-05-1215:33Filipe Silvaatm I'm trying to do a dynamic require in the js file instead#2020-05-1215:33Filipe Silvathat sounds nicer than the other options#2020-05-1215:33Filipe Silvastill not great, but confined to that single file#2020-05-1215:35thhellerI made a gist while ago but never really expanded on it https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2020-05-1215:37thhellersometimes messing with resolve/aliasing is the only way to do things but thats really rare#2020-05-1215:38Filipe Silvaso that approach is inverting the dep#2020-05-1215:38Filipe Silvamakes sense#2020-05-1215:58thheller@lilactown so your issue is related to polyfills. it works fine when importing the file as ES6 but it fails when loading the file as a goog.module. not sure why yet.#2020-05-1215:59lilactownyeah. it sounds like a similar issue that I ran into with helix#2020-05-1216:11thhellerI don't get why it works in the browser though 😛#2020-05-1216:12lilactownI haven’t tried it using goog.module + legacy namespace in the browser#2020-05-1216:13thhellerwell nevermind .. figured it out as I said it. might actually fix your issue too#2020-05-1216:13thheller:compiler-options {:output-feature-set :es6}#2020-05-1216:13lilactownlol#2020-05-1216:14thhellerotherwise it adds polyfills for the let [thunk, ...rest] destructure you do#2020-05-1216:14thhellerthat should still work though#2020-05-1216:15lilactownthat makes sense, but I would prefer to take advantage of closure’s polyfill-ability#2020-05-1216:15thhelleryeah polyfills are a constant nightmare#2020-05-1216:16thhellerreally the least fun part of the entire tool#2020-05-1216:20thhellerbonus effect: Error: Namespace "demo.js_class" already declared. can't hot-reload goog.module files ....#2020-05-1216:21thhelleryou should really just use ESM, that works sooo much better#2020-05-1216:21thhellergoog.module is dead anyways#2020-05-1216:21lilactownI thought it was goog.provide that was dead?#2020-05-1216:22lilactownthe problem with ESM is I don’t know if it’s as portable#2020-05-1216:22lilactownthis stuff is so complicated#2020-05-1216:23lilactownI want to support shadow-cljs and vanilla cljs. vanilla cljs users have had issues with ESM in the past#2020-05-1216:23lilactownmaybe I’m not configuring things right#2020-05-1216:24lilactownalso, the idea of having a mixed TS + CLJS project is interesting 😄#2020-05-1216:24thhellerno clue how it works in regular CLJS. no clue how that even handles polyfills.#2020-05-1216:30lilactownI suppose for building an app with TS + CLJS, it would be better to emit ESM and feed it into CLJS that way#2020-05-1216:30lilactownthe opportunity to DCE and other optimize was tantalizing but probably not a big deal for app code#2020-05-1216:31lilactownfor this use case, it’s a library so I need to support vanilla CLJS, support DCE, etc.#2020-05-1216:36thhellerwell if you get it to work with regular CLJS let me know#2020-05-1216:36thhellerotherwise I don't think I want to spend more time sorting this mess#2020-05-1216:37thhellerI have no clue why it injects the polyfills for ESM files but not goog.module. they go through the same code path.#2020-05-1216:38thhellerhahahaha ... no they don't#2020-05-1216:38thhellergod dammit ...#2020-05-1216:50thheller@lilactown ok the main issue with the polyfills is that they are never injected dynamically. so for the node-repl they aren't there from the beginning so they are never added#2020-05-1216:50lilactownah#2020-05-1216:50thhellerif you make a :node-script build that loads the ns from the beginning they would be there#2020-05-1216:52thhellerbut I rewrote your source file to ESM. goog.module polyfill would still be missing.#2020-05-1216:54lilactownfor just node.js, or browser as well?#2020-05-1216:57thhellerpolyfills are never loaded over the REPL#2020-05-1216:58thhellerI might switch to the strategy used by the closure compiler of just injecting all the polyfills all the time and letting :advanced remove them if not needed#2020-05-1216:58thhellertrying to keep them in sync is painful#2020-05-1217:09lilactownbut when talking about a user trying to use my lib in a project#2020-05-1217:09lilactownwill it work in :node-script , :browser and :react-native targets?#2020-05-1217:10thhellerif its ESM then that should work yes#2020-05-1217:10thhellerhttps://github.com/thheller/shadow-cljs/issues/709#2020-05-1217:11thhellerno clue how to deal with that yet#2020-05-1217:15lilactownhow does the closure lib get handled? special cased?#2020-05-1217:15thhellergoog-js but I don't think any of them require any polyfills so that never has been a problem#2020-05-1217:23thhellerhow dare they use that name ... https://www.npmjs.com/package/@npmcli/arborist 😛#2020-05-1217:26lilactownvery rude#2020-05-1217:41lilactownI’m surprised that the class doesn’t cause any polyfill problems too#2020-05-1217:48thhellerwell you can express that as vanilla ES3#2020-05-1217:59lilactownokay, I guess I need to figure out how to get vanilla CLJS to use ESM#2020-05-1218:00thhellertry to get it working with goog.module#2020-05-1218:00thhellerI'm curious what it does about polyfills 😛#2020-05-1218:29lilactowngotta go figure out how to start a vanilla cljs project 😂#2020-05-1219:53knubieJust ran into an issue where I restarted my build and am now getting the Stale client! message. Checked that index.html is requiring the right javascript file (no changes were made to index.html or shadow-cljs.edn and not sure how to continue troubleshooting. Any help would be greatly appreciated!#2020-05-1219:59knubieJust tried deleting the js files -> reloading the page (got error as expected) -> rebuilt using shadow -> refreshed and that seemed to work#2020-05-1219:59knubieso maybe it was browser caching#2020-05-1307:28caleb.macdonaldblackI’m using the re-frame template where shadow-cljs is integrated within lein’s project.clj. Anytime I run lein dev something is running npm install --save --save-exact which is deleting all my deps I added in package.json How can I install an npm dependency without it getting deleted?#2020-05-1307:29thhellerhttps://github.com/day8/re-frame-template/issues/128#2020-05-1307:29thhellerdont use lein-shadow is my recommendation#2020-05-1307:32caleb.macdonaldblack@thheller Ah thanks. I’ll use shadow-cljs.edn#2020-05-1310:49superstructorWe've just made changes to address these concerns here - https://github.com/day8/re-frame-template/issues/128#issuecomment-627903960 @thheller @caleb.macdonaldblack#2020-05-1312:07Chris McCormickhello, i have run into a weird situation. when i run my shadow-cljs compiled SPA on iOS 9 Safari, the first time the page loads it doesn't run the main.js . if i change the code it live-reloads it successfully. i narrowed the problem down to a single dependency, which if i eliminate it, this problem goes away. has anybody ever seen anything like this and have any suggestions?#2020-05-1312:53Chris McCormicki seem to have solved this with a very small wrapper called zxingwrap.js:
module.exports = {
  "lib": window["RTCPeerConnection"] ? require("@zxing/library") : null,
};
when i do this and then require ["zxingwrap" :as zx] i can then use zx/lib.InstanceName and it works great on both platforms. Very curious. Any ideas as to why this works I would love to hear them!
#2020-05-1312:08Chris McCormickthe dependency is @zxing/library - https://github.com/zxing-js/library#2020-05-1314:04thheller@chris358 impossible to tell without more info. you should get an error when you load the page. that error will tell you whats wrong. just look at the browser console?#2020-05-1402:57Chris McCormickunfortunately i cannot look at the browser console on this device. i tried catching window.onerror but got nothing.#2020-05-1406:26thhellercan't you use safari to debug remotely?#2020-05-1406:27Chris McCormicki do not have a mac osx computer#2020-05-1406:27Chris McCormickall i have is a safari 9 tablet and the greatest software development tooling known to humankind#2020-05-1406:28Chris McCormickit's ok, this workaround is fine for now and nobody else in the world has a safari 9 ipad#2020-05-1406:29thhellerhmm. yeah thats rather old. you can try :compiler-options {:imul-js-fix true} in your build config#2020-05-1406:29thhellerthere used to be a rather old iOS bug with Math.imul. thought nobody was using version that was affected by that anymore#2020-05-1406:30Chris McCormickthank you, will try this!#2020-05-1406:30thhellerdon't think 9 is affected either but might be#2020-05-1316:24Matt JacobusHi all. I’m having trouble getting devcards working with shadow-cljs and wondering what I’m doing wrong. I’m a novice, so apologies if this is obvious to others. I’ve added devcards and shadow-cljsjs to my deps.edn, but the build continues to complain failed to load devcards.system.js ReferenceError: React is not defined. Is there something obvious I’m missing? Thanks in advance!#2020-05-1316:25thheller@mjacobus for some reason devcards does not declare its dependency on React so in the namespace where you require devcards first require cljsjs.react#2020-05-1316:25thheller(:require [cljsjs.react] [devcards.core :as dc] ...) or so#2020-05-1316:26thhellerdon't need to add shadow-cljsjs manually btw. shadow-cljs already depends on it so it will be available regardless.#2020-05-1316:27Matt JacobusThanks! I’ve been wrestling with that for a while. Really appreciate the quick reply. Very nice of you.#2020-05-1316:27Matt JacobusIt looks like same situation with ReactDOM.#2020-05-1316:28thhelleryeah, I think thats cljsjs.react.dom#2020-05-1316:29Matt JacobusYes, thank again.#2020-05-1316:32grischounI get the following error when I start shadow-cljs. I get it for the two versions that I have tried: 2.8.58 and the latest one. Any hint? Syntax error (NoSuchFieldException) compiling . at (shadow/build/closure.clj:68:5). getRegisteredGroups#2020-05-1316:33thhellerdependency conflict#2020-05-1316:33thhellerwhen using project.clj/deps.edn you must ensure that you get the correct shadow-cljs + clojurescript + closure-compiler versions#2020-05-1317:00grischounThanks. I’ll check my versions then.#2020-05-1317:40grischoun@thheller Sorry but I have tried everything and I still get the error. I moved my code to the latest version of shadow and clojurescript: org.clojure/clojurescript {:mvn/version "1.10.758"} thheller/shadow-cljs {:mvn/version "2.9.2"}#2020-05-1317:41grischounI tried with removing ‘node_modules’ but I get the same error.#2020-05-1317:45thhellernode_modules is not involved in this#2020-05-1317:45thhellercheck clj -Stree (with the aliases you need)#2020-05-1317:46thhelleryou should be getting [com.google.javascript/closure-compiler-unshaded "v20200504"]?#2020-05-1317:50grischounHmm, right, I get com.google.javascript/closure-compiler-unshaded v20180805#2020-05-1317:53grischounThis might be the problem: com.fulcrologic/fulcro 3.2.3 cljsjs/react-dom 16.13.0-0 com.cognitect/transit-cljs 0.8.256 com.cognitect/transit-js 0.8.846 org.clojure/clojurescript 1.10.597 org.clojure/google-closure-library 0.0-20170809-b9c14c6b org.clojure/google-closure-library-third-party 0.0-20170809-b9c14c6b org.mozilla/rhino 1.7R5 com.google.javascript/closure-compiler-unshaded v20180805#2020-05-1317:54thhelleryou also shouldn't be getting that older CLJS version?#2020-05-1317:55thhellerare you sure you have the dependencies declared in the correct spot? with the correct profiles?#2020-05-1318:00grischounooops, really sorry, I used the wrong alias. I indeed have the right closure version: com.google.javascript/closure-compiler-unshaded v20200504#2020-05-1318:04grischounBut the same error is still there.#2020-05-1318:04thhellerwell do you have shadow-cljs configured to use those aliases?#2020-05-1318:05thhellerif yes then there shouldn't be a problem?#2020-05-1318:07grischounUnless I am missing something, I think so. My shadow-cljs.edn starts as follows: {:deps {:aliases [:dev]}#2020-05-1318:08grischounAnd in deps.edn I have: :dev {:extra-paths ["src/test" "src/dev" "src/workspaces"] :jvm-opts ["-XX:-OmitStackTraceInFastThrow"] :extra-deps {org.clojure/clojurescript {:mvn/version "1.10.758"} thheller/shadow-cljs {:mvn/version "2.9.2"} #2020-05-1318:08thhellerso clj -A:dev -Stree does give you all the correct versions?#2020-05-1318:10grischounyes#2020-05-1318:11grischounthheller/shadow-cljs 2.9.2 org.clojure/clojurescript 1.10.758#2020-05-1318:11grischouncom.google.javascript/closure-compiler-unshaded v20200504#2020-05-1318:12thhellerhmm then I don't really know? which clojure version do you have configured?#2020-05-1318:15grischoun1.10.1#2020-05-1318:21thhellerthat should be fine. The error you see is 100% caused by an incorrect version on the classpath. maybe some old AOT classes or something?#2020-05-1318:23grischounok, thanks anyway for your help. I’ll try to investigate more, especially with regard to the classpath then.#2020-05-1316:56lilactownhey I’m trying to fight the dragon that is storybook today#2020-05-1316:57lilactown
Cannot assign to read only property 'exports' of object '#<Object>'
    at Module.<anonymous> (main.1d63ab3fd8c0aad6bcda.bundle.js:5638)
    at Module../out/cljs_env.js (main.1d63ab3fd8c0aad6bcda.bundle.js:5639)
    at __webpack_require__ (runtime~main.1d63ab3fd8c0aad6bcda.bundle.js:849)
run into this when using :npm-module with webpack before?
#2020-05-1316:58lilactownlooks like it’s some babel config bs. ugh#2020-05-1317:07lilactownwas a matter of telling babel to emit commonjs modules I guess#2020-05-1317:11thheller:npm-module already emits commonjs, don't need babel?#2020-05-1318:28lilactownI was able to get an example shadow-cljs + storybook v5 project up and running here: https://github.com/Lokeh/storybook-cljs#2020-05-1318:30thhellerI could fix the export issues so that only exported things are visible in dev as well#2020-05-1318:30thhellerfeel free to open an issue for that if you feel thats useful#2020-05-1318:38lilactownhttps://github.com/thheller/shadow-cljs/issues/710#2020-05-1318:30folcon@thheller it might be worthwhile highlighting that shadow-cljs is sensitive to things like clojurescript / closure-compiler versions? Just looking at the github readme I don’t see anything obviously there that prompts me to dig in and work it out. I only really clocked it when you told me when I was having problems =)…#2020-05-1318:30thhellerdoing that right now. tired of explaining that almost daily 😛#2020-05-1318:34folconPerhaps a warning + link to a section in the user guide (if that exists) talking through it in more detail?#2020-05-1318:35folconSorry, it’s just most libs you just require and go, so it’s not something the average clojure dev knows to look for =)…#2020-05-1318:35thhellerwell nobody would have to if they'd just use shadow-cljs as intended. 😛#2020-05-1318:36thhellerbut everyone wants to stick with lein or deps.edn so you shadow-cljs can't fix those issues for you#2020-05-1318:59aisamuIs there a way to use git deps and/or private repos with shadow without deps.edn? IIRC that was the reason we switched to deps#2020-05-1319:57thhellerfor that you need deps.edn for now yes#2020-05-1318:32lilactownI think that would be useful, as I can imagine wanting to put things like fixtures inside of the story as well#2020-05-1318:33lilactownI ran into one other puzzling thing where occasionally webpack would throw an error about reloading goog.math.Long at runtime#2020-05-1318:33lilactownreloading seemed to fix it#2020-05-1318:34lilactownI believe it was due to starting the shadow-cljs compile process after storybook. I would guess this was causing a reload of all of cljs.core + google closure library#2020-05-1321:09thheller@lilactown just released 2.9.3. storybook should no longer see non-exported defs#2020-05-1321:10lilactownI’ll take it for a spin in a bit 🙂#2020-05-1321:10David PhamIs there any bug with core.async? I am using 2.9.2 and the latest core.async version, for nodejs and the server complain that take! is not defined.#2020-05-1321:11David Pham
/.shadow-cljs/builds/app/dev/out/cljs-runtime/cljs/core/async/impl/ioc_helpers.cljs:52
(defn take! [state blk ^not-native c]
^
TypeError: c.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 is not a function
#2020-05-1321:11David PhamFor the error message...#2020-05-1321:13thhellerare you calling take! somewhere with something that is not a channel?#2020-05-1321:14David PhamI use it on a sliding buffer?#2020-05-1321:15thhellera buffer is not a channel?#2020-05-1321:15David Phamahh oops#2020-05-1321:15David PhamI am idiot#2020-05-1321:15David Phamguess coding at 23:15 is not optimal 🙂#2020-05-1321:16David Pham@thheller thanks a lot, I would have kept looking for the solution for hours.#2020-05-1321:19David PhamHow did you know it would be that mistake by the way?#2020-05-1321:24thhellerwell the ^not-native hint makes the compiler use the "direct" call to the take! protocol impl instead of going through the dispatch method#2020-05-1321:24thhellerso the error clearly points at something not implementing that protocol#2020-05-1321:27David Phamthanks#2020-05-1321:28thheller^not-native is a compiler optimization. it gains a bit of performance but loses a better error message in the process 😉#2020-05-1321:33thhellernew thing I added in the new release
$ shadow-cljs server
shadow-cljs - config: /mnt/c/Users/thheller/code/tmp/error-test/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------

This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.

You are using shadow-cljs version: 2.9.3

The important dependencies are:

  org.clojure/clojure "1.10.1"
  org.clojure/clojurescript "1.10.758"
  com.google.javascript/closure-compiler-unshaded "v20200504"

Please verify that you are loading these versions.
You can find all required dependencies here:

  

Please refer to the Guide for more information:

  

-----------------------------------------------------

The error encountered was:

Syntax error compiling at (shadow/cljs/devtools/api.clj:1:1).
        at clojure.lang.Compiler.load(Compiler.java:7647)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463) ...
#2020-05-1321:34thhellerhopefully provides some help when using the wrong dependency versions via deps.edn or project.clj#2020-05-1321:34thhellerstill writing the guide part though#2020-05-1321:43David Phamso if we do not specify tthe dependencies, we should be fine?#2020-05-1321:43thhellermessage only appears when it fails to load the code#2020-05-1321:43thhellerwhich usually only happens with dependency conflicts#2020-05-1405:43plexusWe've put out the first early releases of Chui, a new cljs test runner for the browser. Works best with Shadow for now, and integrates nicely with shadow's reloading. If that sounds interesting please do give it a spin and report back in #lambdaisland or #kaocha https://github.com/lambdaisland/chui#2020-05-1411:05dominicmWas #?(:shadow/cljs) ever a thing / How can I do the equivalent of https://clojurescript.org/guides/javascript-modules in a portable (shadow & non-shadow) way?#2020-05-1411:08dominicmhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js okay, I see you're aware of this conflict. So how can I write code which works for both?#2020-05-1412:51dominicmOne approach that seems to work is using goog.module with the latest versions of ClojureScript.#2020-05-1414:12thheller@dominicm show me what you want to use in CLJS (thats actually working) and I'll make sure it works in shadow-cljs too#2020-05-1414:12thhellerbut I've never seen the guide you linked lead to something that actually works in practice? 😛#2020-05-1414:26dominicm@thheller https://github.com/Lokeh/helix/blob/fix-figwheel/src/helix/impl/classes.js this doesn't work in shadow#2020-05-1414:28thhellerwhat do you mean? shadow-cljs itself uses exactly that approach?#2020-05-1414:28thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/js.js#2020-05-1414:29thhellerisn't that what I told you to do?#2020-05-1414:30dominicmYou didn't tell me anything, but you might have told @lilactown. I took his word that it didn't work in shadow, confirming for myself now.#2020-05-1414:31dominicm(I decided to investigate getting this to work in figwheel for myself)#2020-05-1414:31thhelleryeah I meant @lilactown#2020-05-1414:31thhellergoog.provide should be fully supported for all cases#2020-05-1414:31thhellerESM might work differently but should also work. whatever works in standard CLJS should work in shadow-cljs#2020-05-1414:32thhellerwith the exception of :foreign-libs meaning actual foreign-libs though, so files that aren't processed just prepended#2020-05-1414:33thhellerwhat classpath-js is referring to is requiring files by their actual filename, even allowing relative-paths. that was rejected from CLJS and won't work there.#2020-05-1414:33dominicmRight you are, works perfectly. I'll wait for him to to tell me what particular scenario doesn't work I guess!#2020-05-1414:34dominicm@thheller while I'm here, do you still not support providing imports via API (i.e. not via shadow-cljs.edn)?#2020-05-1414:34thhellerhmm? what are imports via API?#2020-05-1414:35dominicmSorry, multi-tasking. *builds.#2020-05-1414:36dominicmBasically, using shadow-cljs without a shadow-cljs.edn file.#2020-05-1414:36dominicmAh, looks like shadow-cljs problem was something specific that's now been fixed: https://github.com/thheller/shadow-cljs/issues/638#2020-05-1414:38thheller@dominicm that has always worked? you lose a bunch of features but that has always worked? I can't remember context if we talked about that before?#2020-05-1414:45dominicm@thheller we did, you told me that using via api wouldn't be supported as I recall... There was something that errored if you used the api without shadow-cljs.edn file existing containing a particular parameter.#2020-05-1414:46thhelleryou can't use the official API fns that refer to a build by id and have that load from something other than shadow-cljs.edn. that is true and won't be supported ever.#2020-05-1414:47thhellerbut you can pass the entire build config instead to the underlying API fns. shadow-cljs does not need to know where it came from?#2020-05-1414:47thhellersorry really can't remember this discussion#2020-05-1414:48dominicmI'll have to revisit in order to remember. Me neither, it was a couple years ago.#2020-05-1414:48dominicmI'm guessing there was an api that only existed in build id form.#2020-05-1414:50dominicmI would guess that stop requires a build id maybe?#2020-05-1414:50thhellerhttps://github.com/thheller/shadow-cljs/blame/36682facddf068b786ee814ffb55ee1c80c56fd2/src/main/shadow/cljs/devtools/api.clj#L343#2020-05-1414:50thhellersays 3 years ago so it has been there a while 😛#2020-05-1414:50thhelleryou must always supply a :build-id as part of the config anyways#2020-05-1414:51thhellerso you can stop it by that id later regardless#2020-05-1414:52thhellerhttps://github.com/thheller/shadow-cljs/blame/36682facddf068b786ee814ffb55ee1c80c56fd2/src/main/shadow/cljs/devtools/api.clj#L192#2020-05-1414:52thhellerthats 2 years ago so maybe that wasn't there when we talked about that last?#2020-05-1414:52thhellerbasically the gist is that (shadow/release :some-id) will load the build config for :some-id from shadow-cljs.edn and call release* with it#2020-05-1414:53thhellerbut you can call release* yourself if you want too#2020-05-1414:54thhellerbut yeah its not something I recommend doing and if you want to do that as part of some tool moving configuration elsewhere I'll fight you 😛 https://github.com/day8/re-frame-template/issues/128#2020-05-1415:14dominicmThis is what I want to do, yeah. I already have a config.edn where I can distinguish between dev/prod. I can also read from env, AWS or wherever else in it. I wouldn't be as evil as lein-shadow though, I mostly just want to pass through the user's arguments into shadow. Maybe one or two small tweaks for disabling anything that doesn't make sense in that context (e.g. for figwheel I disable open-url as you don't want that to happen on (reset) & I already have a mechanism for linking to auto-testing if it's enabled.)#2020-05-1414:54thhellerbut if you want that as part of something your own projects build pipeline you can see this as fully supported#2020-05-1414:55dimaWhat has higher priority project’s deps.edn or user-config ~/.shadow-cljs/config.edn ? I’m trying to override dependency specified in project’s deps.edn with shadow user config, but it doesn’t have any effect#2020-05-1414:56thhellerhmm? you use deps.edn to configure deps and give shadow-cljs the list of aliases?#2020-05-1414:57thhellerif you want more complex things you use clj directly without going through shadow-cljs?#2020-05-1414:59dimaI’ve added
{:dependencies
 [[cider/cider-nrepl "0.25.0-SNAPSHOT"]]}
to .shadow-cljs/config.edn assuming it would override cider-nrepl dep from deps.edn , but it’s not
#2020-05-1414:59thhelleryeah no that doesn't work#2020-05-1415:00thhellerspecify it in ~/.clojure/deps.edn and enable that alias instead#2020-05-1415:00dimathanks, i’ll try#2020-05-1415:00thhellerhmm bit it might merge in the wrong order too so you probably want to get rid of that in the project deps.edn?#2020-05-1415:01dimaone option is to remove it from project deps.edn, but i’m exploring other options#2020-05-1415:01thhelleruser specific config really shouldn't be in the project deps.edn (eg. cider) IMHO#2020-05-1415:02dimaright, i also think it shouldn’t be there#2020-05-1415:12bedersHey there, looks like there might be a juicy new compilation target for shadow: https://deno.land/v1 😉#2020-05-1415:19dpsuttonwas just reading about that. doesn't seem useful? no npm support. its value add is native TSC which it calls "unsatisfyingly slow". eventually typechecking needs to happen in Rust but that "will be a massive undertaking and will not happen any time soon"#2020-05-1415:20dominicmThis is javascript land, you must jump on the latest! pssht.#2020-05-1415:20thhelleryeah its meant to fix the issues he talked about here https://www.youtube.com/watch?v=M3BM9TB-8yA#2020-05-1415:20thhellerseems useful but I don't see it replacing npm/node anytime soon#2020-05-1415:22thhellerthis using urls for deps thing is not sometimes I think will work in practice but we'll see#2020-05-1922:57rbergerOne of the worse “features” of Go#2020-05-1415:40bedersit provides enough justification so everything can be re-written to make things "better" 😉#2020-05-1415:44thhellerI don't know what the eval situtation is like for deno so don't know about hot-reload or REPL but creating output that is consumable by it is trivial#2020-05-1416:02lilactownhey thheller, re: ^:const - what did you mean by “doesn’t do what everyone thinks it does” ?#2020-05-1416:02lilactownare there any docs on what the behavior is in modern CLJS?#2020-05-1416:21lilactownI’m seeing this error still using latest shadow-cljs: https://github.com/thheller/shadow-cljs/issues/643#2020-05-1416:22lilactownhere’s a (not so minimal) repro: https://github.com/Lokeh/helix/tree/shadow-goog-provide#2020-05-1416:22thhellerplease don't refer to old tickets. that ticket is talking about react-native. you are not doing react-native are you?#2020-05-1416:22lilactownI’m not#2020-05-1416:23thhellerhttps://github.com/thheller/shadow-cljs/issues/709#2020-05-1416:23thhellerdo you load the code from the REPL or is it part of the regular build?#2020-05-1416:23lilactownthis is a part of a regular build#2020-05-1416:23thhellerI think that is the underlying problem though#2020-05-1416:23thhellertry with :compiler-options {:output-feature-set :es6}#2020-05-1416:24thhellerhttps://recoiljs.org/ looks like react-world found re-frame 😉#2020-05-1416:28lilactowngood luck to them 😛#2020-05-1416:28lilactownI can confirm that changing the output feature set to :es6 fixes it#2020-05-1416:35thhelleryeah the issue is polyfills. CLJS doesn't do any polyfill handling for :none builds. maybe I should do that too?#2020-05-1416:35thhellerkinda annoying to deal with this mess 😛#2020-05-1416:35lilactown😞 it is a mess#2020-05-1416:36lilactown> CLJS doesn’t do any polyfill handling for `:none` build#2020-05-1416:37lilactown> what would that mean for users of my lib? #2020-05-1416:37thhellernothing? I will figure out how to deal with this ... even if I just bail on polyfills for dev builds like CLJS does#2020-05-1416:39lilactowndoes “bailing” mean you always load them? or don’t transpile to ES5 for dev builds?
#2020-05-1416:39lilactownI’m a bit confused#2020-05-1416:39thhellerdon't transpile language features . I'm pretty sure CLJS doesn't, will verify when I have some time#2020-05-1416:40lilactownI see#2020-05-1416:41thhellerpolyfills have been a pain forever so I want to figure this out cleanly once and for all#2020-05-1416:41lilactownand right now, doing a release build w/ goog.provides I see no jscomp error. so the polyfills must be loaded in the correct order there#2020-05-1416:42thhelleryes#2020-05-1416:42lilactownI think I understand now#2020-05-1417:00dominicmWhich sources correctly load polyfills? Is there a workaround where we could force-load the polyfills earlier somehow (maybe via an npm or esm?)#2020-05-1417:06thhellerall release builds should handle them correctly (now)#2020-05-1417:07thhellerduring dev closure-js doesn't handle them correclty (so goog.provide/goog.module on the classpath)#2020-05-1417:07thhellereverything else should assuming they aren't initially added by the REPL#2020-05-1417:07thhellersince the REPL doesn't add them dynamically at the moment#2020-05-1420:55Wilson Velezwhen to choose note-test over browser-test targets? only when the thing to test is not related with a “DOM/Browser”? what if I want to test a re-frame handler?#2020-05-1421:39thhellerany suggestions regarding? https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-05-1421:39thhellertried to capture everything I could think of but not sure its actually helpful 😛#2020-05-1421:41thheller@wvelezva :browser-test is currently rather limited and doesn't work great for automated testing env. :node-test generally works better if you can live without the DOM/browser APIs#2020-05-1421:51Wilson Velezthanks @thheller, and karma is only suitable if I'm planning to use continuous integration, right?#2020-05-1421:58thhellerkinda yes#2020-05-1423:04vinnyataidehello folks, I hope all is well#2020-05-1423:04vinnyataideI have an issue in windows, just installed clojure and shadow-cljs#2020-05-1423:05vinnyataidethis is my package.json
{
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "shadow-cljs": "^2.9.3"
  }
}
and this is my deps.edn
{:paths   ["src/main" "resources"]
 :deps    {org.clojure/clojure    {:mvn/version "1.10.1"}
           com.fulcrologic/fulcro {:mvn/version "3.0.10"}}

 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.742"}
                               thheller/shadow-cljs        {:mvn/version "2.8.107"}
                               binaryage/devtools          {:mvn/version "0.9.10"}}}}}
this is my shadow-cljs.edn too
{:deps     {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn app.client/init
                                       :entries [app.client]}}
                   :devtools   {:after-load app.client/refresh
                                :preloads   [com.fulcrologic.fulcro.inspect.preload]}}}}
it's giving the message
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/cli__init.class, shadow/cljs/cli.clj or shadow/cljs/cli.cljc on classpath.
#2020-05-1423:06vinnyataideam I missing something?#2020-05-1423:06thhellerthheller/shadow-cljs {:mvn/version "2.8.107"} but "shadow-cljs": "^2.9.3"#2020-05-1423:06thhellerthese should match. either downgrade the package.json version or update deps.edn#2020-05-1423:09vinnyataideoh ok#2020-05-1423:09vinnyataidethanks#2020-05-1511:09kirill.salykinhi I am trying to run a node-repl using instructions from https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-node but when I am node app/app.js - i dont see any WebSocket connected message - the scripts just runs main
{:deps true
 :builds
 {:app
  {:target :node-script
   :main 
   :output-to "app/app.js"}}}
please advice how I fix it? thanks
#2020-05-1511:16thheller@kirill.salykin I don't think the :node-script target prints anything anymore. if you don't get any errors it should just work? just call shadow-cljs cljs-repl app to get the REPL?#2020-05-1511:17thhellerassuming shadow-cljs watch app is already running of course#2020-05-1511:17kirill.salykinlet me try#2020-05-1511:20kirill.salykinworks, thanks a lot!#2020-05-1511:28kirill.salykinsomething different: when I valuate (a/chan) (where a is clojure.async) i see this:
TypeError: Cannot read property 'call' of undefined
    at cljsEval (<eval>:1:30)
    at global.SHADOW_NODE_EVAL ([stdin]:105:10)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/kirill.salykin/.../.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
is this me doing something wrong?
#2020-05-1511:32thhellerI don't know. how did you get there? I mean what did you eval before that?#2020-05-1511:32thheller
$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> (require '[clojure.core.async :as a])
nil
cljs.user=> (a/chan)
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user=>
#2020-05-1511:32thhellerworks fine for me#2020-05-1511:36kirill.salykinworks for me as well now sorry for disturbing#2020-05-1511:33kirill.salykinthanks, I’ll with fresh repl#2020-05-1516:40folconIf you’re running lein it appears that you have to install shadow-cljs globally?
./node_modules/.bin/shadow-cljs build :lambda
shadow-cljs - config: /<project-path>/shadow-cljs.edn
shadow-cljs - running: lein run -m shadow.cljs.cli --npm build :lambda
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Can't find 'shadow.cljs.cli' as .class or .clj for lein run: please check the spelling.
Syntax error (FileNotFoundException) compiling at (/private/var/folders/xl/rkkw077j4xxf827wn82mcp_c0000gn/T/form-init598900596536044588.clj:1:124).
Could not locate shadow/cljs/cli__init.class, shadow/cljs/cli.clj or shadow/cljs/cli.cljc on classpath.
#2020-05-1516:41thhellerno. you just can't use the npm version 2.9.3 with other shadow-cljs versions#2020-05-1516:41thhellerI'll reverting that change though#2020-05-1516:41thhellerthis was supposed to FIX dependency issues not add more#2020-05-1516:50folconAh, sorry =)… I just saw there was an update, I’ve been using deps for the past few weeks, but needed to setup a lambda so just used lein as I’m more familiar with it.#2020-05-1516:53thhellerit doesn't matter at all whether you use deps.edn or project.clj#2020-05-1516:54thhellerthe issue is that the npm shadow-cljs package 2.9.3 is only compatible with shadow-cljs CLJ 2.9.3. so you need to put that version into project.clj or deps.edn#2020-05-1516:54thhellerbut I'm pushing 2.9.4 now mismatched versions don't break anymore#2020-05-1517:00folconRight, sorry I thought I’d double checked that, but I tweaked the update.#2020-05-1517:01thhellerjust update the npm install to 2.9.4 then everything should be fine again#2020-05-1517:01thhellerdoesn't hurt to update project.clj/deps.edn either though#2020-05-1517:02folconThe issue I was referring to was this line: running: lein run -m shadow.cljs.cli --npm build :lambda, I’ve not gotten around to installing shadow-cljs as global, so I was surprised that calling the npm installed one then triggered lein to run it as if it was global. Unless there’s some other stuff going on that I’m not aware of :)…#2020-05-1517:02folconThanks, I will do#2020-05-1517:02thhelleryou are not understanding the issue I'm trying to explain#2020-05-1517:03thhellerI added a NEW namespace in 2.9.3 shadow.cljs.cli which the above it trying to call#2020-05-1517:03thhellerthat did not exist in prior releases#2020-05-1517:03thhellerBUT you have an older shadow-cljs version specified in project.clj or deps.edn#2020-05-1517:03thhellerso it breaks#2020-05-1517:03thhellerso when you updated your global install and got 2.9.3 it started breaking#2020-05-1517:04thhellernaive me thought people don't upgrade the npm package unless they also update project.clj/deps.edn#2020-05-1517:05thhellerbut of course nobody seems to do that#2020-05-1517:06folconYep, just tried that and you’re completely correct =)… Sorry for causing you stress @thheller!#2020-05-1517:09thhellermy mistake really for calling the npm package the same name as the CLJ package. wish I could undo that but its too late for that.#2020-05-1517:10folconIt’s always tricky to work these things out ahead of time, fundamentally shadow-cljs is an excellent tool, and hopefully over time people internalise that this is how it works.#2020-05-1517:12lilactownI’ve had an idea in the back of my mind of a tool that would help with generating & validating shadow-cljs.edn config#2020-05-1517:13thhellerwhat would that do? the problem isn't in shadow-cljs.edn 😛#2020-05-1517:14lilactownah, sorry, I was reminded of it because it could also do some trivial validation of package.json + classpath#2020-05-1517:15thhellerwell that is what the change was supposed to do#2020-05-1517:30lilactownyeah, a 2nd tool might allow us to use the same tool for multiple shadow-cljs versions and avoid the above. then you can instruct users to use the shadow-check tool to detect common errors#2020-05-1517:31lilactownor something! just food for thought 😄#2020-05-1517:32thhellerwell the issue here is project.clj or deps.edn. I'm not going to attempt to parse those so there isn't really much that can be done 😛#2020-05-1517:32thhellerthe main issue is gone with 2.9.4 and all startup failures should now get enough info so people can figure out what to do#2020-05-1517:34thhellerI'm not going to do any further help for project.clj or deps.edn related issues beyond the added error messages or user guide#2020-05-1517:50haywoodI’m looking for any hack, no matter how awful, to work around the fact we can’t support dynamic imports, but this library I’m using uses them and I need to patch it. In my console I get Uncaught (in promise) Module not provided: ./assets/search.js I can’t tell if that’s something I can reroute via js-options (hasn’t worked thus far)#2020-05-1517:51thhellernope, not possible#2020-05-1518:10haywoodoh Thomas, ye have little faith#2020-05-1518:11haywood
(ns deli.utils.icon-hacks
  (:require ["@elastic/eui/lib/components/icon/assets/search" :as Search]
            [oops.core :refer [oset!]]))

(set! (.. js/window -EuiIconDict) #js {"search" Search})
#2020-05-1518:11haywoodmodify the file in node_modules
_defineProperty(_assertThisInitialized(_this), "loadIconComponent", function (iconType) {
      Promise.resolve().then(function () {
        console.log("got here: ", iconType)
        return window.EuiIconDict[iconType];
      }).then(function (_ref)
#2020-05-1518:11haywoodlmao#2020-05-1518:12haywood> no matter how awful#2020-05-1520:09Rob Hanlonhello—i’m currently building two CLJS npm-modules that are meant to be included in frontend webpack build to be consumed by a react app written in JS. i have them both building with shadow-cljs compile lib and they’re both npm linked into my frontend project. unfortunately, i get an error on load that makes a ton of sense: Uncaught Error: Namespace "goog.math.Long" already declared. because both packages are including the closure compiler and declaring that same module. is there a way to essentially declare the closure compiler as an extern so that it’s assumed that it will be available in the environment? or is there another solution to this i’m not thinking of? thanks 🙂#2020-05-1520:10Rob Hanlonif this is a more general question for #clojurescript i can take it there as well#2020-05-1520:10thheller@robhanlon you should not be including two separate builds this way in one webpack build#2020-05-1520:13Rob Hanlonalright! what’s the alternative? they’re currently completely separate shadow-cljs (and leiningen) projects—do i need to merge them?#2020-05-1520:22thhelleryou can turn them both into libraries and add a third that turns them both into one :npm-module build if you want#2020-05-1520:22thhellerbut you should always compile all CLJS sources you are going to use together. otherwise you'll end up including lots of duplicated code.#2020-05-1520:25Rob Hanlongreat. thank you so much for the help and the awesome project!#2020-05-1520:27thheller@haywood if you are going to rewrite the source code anyways you can just turn the dynamic import() into a require import or require#2020-05-1520:27thhellerbut yeah I'd strongly advise looking for another library 😛#2020-05-1612:39r0manHello, is the build report broken? Running npx shadow-cljs run shadow.cljs.build-report app report.html give me this error: No such var: shadow.cljs.devtools.cli/from-remote.#2020-05-1614:10thheller@r0man downgrade to 2.9.2 for now. I broke the remote interaction in 2.9.4. will fix soon but have something else I want to fix first.#2020-05-1614:12r0manAlright, thanks!#2020-05-1620:29Stuarthi, I'm a complete newcomer to clojurescript and I'm having some issues with shadow-cljs (most likely me being dumb) and getting it to play nicely with cursive and IntelliJ, can someone lend a hand?#2020-05-1620:30StuartI have read from the docs that I can create a pom.xml and import this into cursive, but I have no idea how to do this in IntelliJ#2020-05-1620:30StuartRight now, things like defn and println just aren't recognised by IntelliJ and cursive#2020-05-1620:35thheller@qmstuart make sure you have the maven plugin installed in IntelliJ. otherwise it won't properly support importing pom.xml#2020-05-1620:36darwinwhy do you need pom.xml? cursive supports deps.edn and that plays pretty well with shadow-cljs :deps true#2020-05-1620:36StuartTHen I must be doing something wrong then 😞#2020-05-1620:36thheller@darwin that requires tools.deps ... pom.xml is much simpler and works just as well#2020-05-1620:37thheller@qmstuart do you have the plugin active?#2020-05-1620:37StuartI do#2020-05-1620:37StuartIt says the Maven plugin is bundled#2020-05-1620:37thhelleryes, but is it active?#2020-05-1620:37Stuarton the plugins screen of settings, I have an option to disable, so I presume it must be currently enabled ?#2020-05-1620:38thhelleris the checkbox next to it checked or not?#2020-05-1620:38Stuartit is 🙂#2020-05-1620:38Stuart(when I say I'm a newbie, I mean I just tried to get shadow-cljs working for the first time about 8 hours ago)#2020-05-1620:38thhellerand you did file -> new -> project from existing sources?#2020-05-1620:40Stuartthat's what I was missing! I was looking for an import option somewhere!#2020-05-1620:40Stuartthank you!#2020-05-1620:40StuartI didnt understand I had to open it as a project file itself#2020-05-1620:40Stuartthank you so much#2020-05-1620:40thhelleryeah let it create a project from the generated pom.xml#2020-05-1621:52cobySay I have this setup for a full stack Clojure/Script project:
src/my-app # app code goes in here
test/my-app # tests go in here
deps.edn
shadow-cljs.edn
And my shadow config:
{:source-paths ["src" "test"]
 :deps true
 :builds {:app ...

          :test {:test-dir "resources/public/test"
                 :target :browser-test
                 :ns-regexp "-test$"
                 :devtools {:http-root "resources/public/test"
                            :http-port 3002}}}}
This works fine for running CLJ tests via clojure -A:dev -m kaocha.runner, but I've never gotten this setup to work with Shadow/CLJS. watch doesn't seem to detect that the test files are even there. I see in the Testing section of the Shadow docs that it's "common" to keep files in src/main and src/test, but is that a requirement?
#2020-05-1621:53thhellerif you use :deps true then you configure :paths in deps.edn only#2020-05-1621:53thheller:source-paths in shadow-cljs.edn has no effect at all. you should get a big warning for that on startup, unless your version is too old for that.#2020-05-1621:56cobyah ok, just upgraded, getting the warning now#2020-05-1622:01cobyok, so looks like I need to add shadow as a dep to my :dev profile...do the maven and npm versions stay in lockstep?#2020-05-1622:02cobylooks like they are both at 2.9.6 atm, but just wondering 🙂#2020-05-1622:03thhellerI do recommend that but I just learned my lesson again to try to keep them compatible so it shouldn't matter most of the time#2020-05-1622:03thhellerthe version in deps.edn is the one that counts, the npm package is only for command-line stuff which doesn't really do much#2020-05-1622:05cobygotcha#2020-05-1622:07cobyjust got it working, thanks!#2020-05-1709:58orestisI’m building a library that I want to be compatible with both stable and experimental React. So when testing I need to bounce back between the two versions. I can probably detect the presence of functions at runtime, or I could have two different namespaces (one for stable and one for experimental), letting the user decide which to use. #2020-05-1710:00orestisBut when I’m developing the library, is there a way to test things out without too much hassle? My current thinking is to put the testing/demo stuff in a different project and use the library as a local root dep. Then I’d fire up two shadow-cljs instances, each one with a different node_modules. #2020-05-1710:03thhellerno clue? seems like more of a npm question than a shadow-cljs question 😛#2020-05-1710:03thhellerI'd probably take your appraoch of 2 separate builds with two separate folders#2020-05-1710:45orestisI’ll play around. I assume shadow looks for node_modules next to shadow-cljs.edn?#2020-05-1711:07thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules#2020-05-1711:31orestisSuper! #2020-05-1711:32orestisBtw where is the source for this guide? Would be nice to submit PRs ( if welcome)#2020-05-1711:38folconWhen you’re performing a require in the namespace in shadow-cljs, you have to add it to the ns form right? Shadow doesn’t like you referring to a namespace alias you defined outside that?#2020-05-1711:41folconUsing code in editor sent to clojure repl:
(require '[clojure.data :as data])
(data/diff [1 2 3] [4 5 6])
=> nil
=> [[1 2 3] [4 5 6] nil]
Using code in editor sent to shadow repl:
#2020-05-1711:41folcon
(require '[clojure.data :as data])
------ REPL Error while processing ---------------------------------------------
(require '[clojure.data :as data])
no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
{:id [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "terrain_cljs/core_test.cljs"]
	shadow.build.data/get-source-by-id (data.clj:171)
	shadow.build.data/get-source-by-id (data.clj:168)
	shadow.build.compiler/remove-dead-js-deps/remove-fn--13854/fn--13855 (compiler.clj:1164)
	clojure.core/complement/fn--5669 (core.clj:1441)
	clojure.core/filter/fn--5893 (core.clj:2817)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
	clojure.core/chunk-next (core.clj:708)
	clojure.core.protocols/fn--8154 (protocols.clj:137)
	clojure.core.protocols/fn--8154 (protocols.clj:124)
	clojure.core.protocols/fn--8114/G--8109--8123 (protocols.clj:19)
	clojure.core.protocols/seq-reduce (protocols.clj:31)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887)
	shadow.build.compiler/remove-dead-js-deps/remove-fn--13854 (compiler.clj:1166)
	clojure.core/update (core.clj:6196)
	clojure.core/update (core.clj:6188)
	shadow.build.compiler/remove-dead-js-deps/fn--13859/fn--13860 (compiler.clj:1172)
	clojure.core/map/fn--5866 (core.clj:2753)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887)
	shadow.build.compiler/remove-dead-js-deps/fn--13859 (compiler.clj:1173)
	clojure.core/update (core.clj:6196)
	clojure.core/update (core.clj:6188)
	shadow.build.compiler/remove-dead-js-deps (compiler.clj:1170)
	shadow.build.compiler/remove-dead-js-deps (compiler.clj:1159)
	shadow.build.compiler/compile-all (compiler.clj:1422)
	shadow.build.compiler/compile-all (compiler.clj:1269)
	shadow.build.api/compile-sources (api.clj:258)
	shadow.build.api/compile-sources (api.clj:250)
	shadow.build.api/compile-sources (api.clj:262)
	shadow.build.api/compile-sources (api.clj:250)
	shadow.cljs.repl/repl-require (repl.clj:218)
	shadow.cljs.repl/repl-require (repl.clj:187)
	shadow.cljs.repl/process-read-result (repl.clj:522)
	shadow.cljs.repl/process-read-result (repl.clj:502)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:879)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:833)
	shadow.cljs.devtools.server.worker.impl/eval16051/fn--16052 (impl.clj:914)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580/fn--15588 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--15579/fn--15580 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--15579 (util.clj:257)
	java.lang.Thread.run (Thread.java:830)
(data/diff [1 2 3] [4 5 6])
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: :1:2
 No such namespace: data, could not locate data.cljs, data.cljc, or JavaScript source providing "data"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:2
 Use of undeclared Var data/diff
--------------------------------------------------------------------------------
ReferenceError: data is not defined
    at eval (eval at shadow$cljs$devtools$client$browser$global_eval (), <anonymous>:1:1)
    at eval (<anonymous>)
    at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] ()
    at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] ()
    at shadow$cljs$devtools$client$browser$handle_message ()
    at eval ()
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] ()
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] ()
#2020-05-1711:41folconManually pasting the form:
(require '[clojure.data :as data])
=> nil
1
=> 1
(data/diff [1 2 3] [4 5 6])
=> [[1 2 3] [4 5 6] nil]
#2020-05-1711:39thheller@orestis https://shadow-cljs.github.io/docs/UsersGuide.html#_contributing very welcome#2020-05-1711:40thheller@folcon you can't define a namespace alias outside the ns#2020-05-1711:41folconIn shadow? It works in the normal repl, just tested it…#2020-05-1711:41thhellerREPL is a special case#2020-05-1711:41thhellerit does not work in regular files#2020-05-1711:44folconAh, sure =)…#2020-05-1711:45folconSorry, just to be clear, In both cases I’m performing send form to repl in a file, not pasting straight into the repl?#2020-05-1711:46folconLet me check in a clj file (as opposed to user.clj), you’re almost certainly right however =)…#2020-05-1711:47folconNo, that seems to work as well? To be honest, I’m not really bothered, it’s an easy thing to just add the form to the file. I’m more surprised that this requires special handling, I would have thought this sort of functionality would have been part of the reader?#2020-05-1711:49thhellerCLJ is different ...#2020-05-1711:49folconThat’s fair =)…#2020-05-1711:49thhellerit is simply a limitation of the JS platform. we cannot do sync IO, which require would need.#2020-05-1711:50folconGood to know#2020-05-1721:57thhellerin case someone is interested in WASM related things https://www.reddit.com/r/Clojure/comments/gloazr/using_wasm_in_cljs/#2020-05-1806:01sofraI would like to write a library using shadow-cljs (with npm dependencies) and use it from another shadow-cljs app, I can work out how does the app consume the npm dependencies of the library? There was stuff in the docs about deps.cljs but I could not get that to work and I am not sure if that is what I need?#2020-05-1807:19superstructor@sofra A library can provide transitive npm deps to a dependent project by putting a deps.cljs on the classpath containing {:npm-deps {"name" "version"}} . Reagent has an example: https://github.com/reagent-project/reagent/blob/master/src/deps.cljs#2020-05-1811:40sofrathanks! So does the dependant project then need to also include its own package.json to provide the dependancy?#2020-05-1903:31superstructorNo. shadow-cljs will inject these into the dependent project's package.json via npm install --save --save-exact ...#2020-05-1809:20andrehi , where should I look if I want to add support for
:build-complete
:build-failure
:build-start
in
:devtools
#2020-05-1817:07dimaMaybe this comment could help https://github.com/thheller/shadow-cljs/pull/707#issuecomment-627004576#2020-05-1906:17andreyes this helps for sure, thanks#2020-05-1906:39andrehttps://github.com/thheller/shadow-cljs/pull/707#issuecomment-630614342#2020-05-1906:51andreok i found why#2020-05-1906:53andrehttps://github.com/thheller/shadow-cljs/pull/718#2020-05-1907:10dima@andre :warnings are nested in :sources which is a sequence of maps#2020-05-1809:55thheller@andre I don't understand the question?#2020-05-1816:23Andy HeywoodHey folks - 100% sure this has been answered somewhere, but I can’t find it. Is there an issue with spec generation in shadow specifically even after I’ve manually included org.clojure/test.check ?#2020-05-1816:23Andy Heywood(which seems to be the working solution for regular cljs)#2020-05-1816:24Andy Heywoodfound a slack log from a couple of years ago of @thheller discussing the weirdness of it not working#2020-05-1816:24Andy HeywoodI’m getting: Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required#2020-05-1816:34Wilson VelezI had the same error last week, the way I solved was requiring clojure.test.check.generators#2020-05-1816:38Andy Heywoodha. that’s embarrassing 😄#2020-05-1816:39Andy Heywoodthink I switched from one error message to a different one after including test.check and didn’t pay attention - thanks!#2020-05-1816:40Wilson Velezsure, no problem!#2020-05-1816:50Wilson VelezIs there a way of excluding a file when doing the release of the app? I have a cljs file that it’s used only during developtment with some objects and data that I want to exclude when making the final js#2020-05-1816:57Andy Heywoodwhat target? I can’t see anything included in my output for a node-library that’s not referenced by an extern#2020-05-1816:59Andy Heywoodi.e. any namespace that’s required by code that’s ultimately extern’d will end up in the output, but if it’s not referenced, it shouldn’t appear#2020-05-1817:02Wilson Velezis for the browser, I have a file with an initial json, used to initialize the state of my re-frame app, this is only for development, because in production the json is provided by the page that loads the clojurescript app#2020-05-1817:04Wilson Velezbut when I release my app the data structure I use in develop is in the final js file, so I want to exclude it#2020-05-1817:15Wilson Velezor maybe I should use this? https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2020-05-1817:34thheller@wvelezva would help to see some code. I don't quite understand your setup but build-hooks are likely not the solution.#2020-05-1819:15Wilson Velez@thheller this is an very close example of what i have https://github.com/wvelezva/exclude-example-data#2020-05-1819:17thhelleryou can use (def stock-data (delay {... instead of (def stock-data {...)#2020-05-1819:17Wilson VelezI think it doesn’t work, there are some files that I didn’t include#2020-05-1819:17thhellerand @data/stock-data in the init#2020-05-1819:18thhellerthat should allow :advanced to remove the data entirely#2020-05-1819:18thhellerbut I don't get why you have that data as part of your code#2020-05-1819:19thhellerwhy not go with what release does and pass it into dev in development too#2020-05-1819:21Wilson Velezthe data in dev is a subset of what a user get in production#2020-05-1819:22thhellerthat isn't really relevant#2020-05-1819:22thhelleryou can just pass in the data you have in the example-data now#2020-05-1819:23Wilson Velezsorry, I don’t understand 😕#2020-05-1819:26Wilson Velezyou mean pass in the data where? in the html?#2020-05-1819:35thhellerhowever you do it in release?#2020-05-1819:39Wilson Velezin release I do nothing, the js is used in an html that provide a js structure with all the data#2020-05-1819:39Wilson Velezso there is an “external” app that provides the input to initialize the js#2020-05-1819:41thhellerI'm sorry but I really don't quite understand your issue#2020-05-1819:42thhelleryou are already passing in a bunch of stuff via https://github.com/wvelezva/exclude-example-data/blob/master/resources/public/index.html#2020-05-1819:42thhellerwhy not just pass in the sample data from there too?#2020-05-1819:42thhellerwhy does that have to be part of the CLJS code when the release version doesn't do that?#2020-05-1819:44Wilson VelezI had it that way, I wanted to arrive here….#2020-05-1819:45Wilson Veleznow, I want to use the same structure in the tests, and I didn’t know how to feed my tests without replicating the data#2020-05-1819:45Wilson VelezI want to use the same src of data#2020-05-1819:48thhelleryou can put the data into a :preloads and and have that initilialize it#2020-05-1819:48thhellerreally there are many options ... if you try with the delay you maybe can just leave things as they are#2020-05-1819:49thhelleras :advanced should be able to remove the example data#2020-05-1819:50Wilson VelezI read that there is experimental support for loading js file with shadow, so I also thought about create a js which I can include in the index.html and in the test.cljs#2020-05-1819:50thhellerhmm?#2020-05-1820:01Wilson Velezhttps://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2020-05-1820:02Wilson VelezI’m talking about using this in my tests to load the same data that I can use in the index,html of my dev setup#2020-05-1820:04thhellerthats no different than what you have now, except that it loads JS files instead of CLJS#2020-05-1820:04thhellerbut also can't be conditional in any way#2020-05-1820:17Wilson VelezHow should I declare an object in the included js file in order to used in the cljs file?#2020-05-1820:18Wilson Velez
var testScores = [                                        
    { id: 1, score: 86, gradeLetter: "B" },               
    { id: 2, score: 93, gradeLetter: "A" },
    { id: 3, score: 78, gradeLetter: "C" }
];
I have this js array
#2020-05-1820:19thhellerexport let testScores = { ... };#2020-05-1820:19thheller(:require ["./the-file.js" :as x]) x/testScores#2020-05-1820:20Wilson Velezthanks#2020-05-1901:08amarHi. I'm trying to cache build dependencies for CI. Is there a way to specify another location for the local maven repo directory? Want to download and copy the entire .m2 directory into a container.#2020-05-1901:24lilactownshadow creates a local build cache in .shadow-cljs/builds#2020-05-1901:59amarthanks. i'll look into that#2020-05-1904:06David PhamAnyone managed to get pretty printing working in the repl?#2020-05-1908:14thheller@amar for maven deps you can set :maven {:local-repo "maven"} in either shadow-cljs.edn or ~/.shadow-cljs/config.edn#2020-05-1912:37amarThank-you 🙂#2020-05-1910:09Elirazhey, can you make `shadow-js` work with `lumo` and get rid of that `JVM` runtime?#2020-05-1910:17thhellerno#2020-05-1911:21fbielejeccan I mimic this JS inheritance in ClojureScript?
class AccessController extends EventEmitter {

  static async create (db, options) {}

  static get type () {
    throw new Error('\'static get type ()\' needs to be defined in the inheriting class')
  }

  get type () { return this.constructor.type }

  async canAppend (entry, identityProvider) {}
}

class OtherController extends AccessController {

  static get type () { return 'othertype' }

  async canAppend(entry, identityProvider) {
    return true
  }
}
#2020-05-1911:22fbielejecSeems like in JS parlance static is a property of the object itself and th prototype properties (methods) can be overridden by setting the -.prototype.#2020-05-1911:23fbielejecWhat I'm not sure is what the get is, also since AccessController extends EventEmitter what to do with the static properties of EventEmitter, do I just add them to the object literal?#2020-05-1911:25fbielejecFor the former I would do something the lines of:
(defn create-controller []
  (let [type "othertype"
        ac-obj #js {:create (fn [db options]
                              (js/Promise.resolve true))
                    :type type}]

    (set! (.-prototype ac-obj) (.-prototype AccessController))

    (set! (.. CustomAccessController -prototype -type)
          (fn [] type))

    (set! (.. CustomAccessController -prototype -canAppend)
          (fn [entry identity-provider]
            (js/Promise.resolve true)))

    ac-obj))
#2020-05-1914:00thhelleranswered on SO#2020-05-2006:58Chris McCormickcan somebody share the link, i would like to read this. thanks!#2020-05-2007:27thhellerhttps://stackoverflow.com/questions/61891349/implementing-static-properties-in-clojurescript#2020-05-1918:18folconWhen using shadow-cljs with aws lambda, anyone got experience with correctly loading in node_modules? I’ve just been getting ImportModuleError. I’ve specifically been trying to use the pg npm module if that helps =)…#2020-05-1919:23folconOk, nvm =)… Managed to get it working!#2020-05-1919:59haywoodI need to run a bit of my front end code, which includes some native JS react components on my clojure server. The code compiles fine, like I can run it as a stand-alone node script, do I need to figure out how to get it to run on something like GraalVM?#2020-05-1919:59haywoodcompiling that code for the browser target and trying to run it with Nashorn didn’t work too well#2020-05-1920:00haywoodmore or less looking to see if anyone else has done something similar#2020-05-1920:01haywoodperhaps there’s a shadow namespace I can import on the server, and have it load the compiled node-library and run it?#2020-05-1920:09thhellerthere is not. nashorn as well as graal.js are rather limited JS engines and they don't support anything async#2020-05-1920:17haywooddamn, fwiw it’s just a bit of reagent code (of which wraps a native react component [:> Thing]) I’m I’m returning the string dom representation#2020-05-1920:17haywoodso close, but so far#2020-05-1921:02Eric IhliI'm having a problem with cider-eval-* . I know there's a lot of tools between running that emacs command and shadow-cljs, so maybe this isn't the right place to ask. But I've tracked it down to the nrepl responding with :repl-type of clj in its response map which then gets sent to cider-set-repl-type. I haven't been able to track how :repl-type gets set in the response. Does it have anything to do with shadow-cljs? I'm running npx shadow-cljs server, version 2.8.107 and cider-nrepl 0.25.0-alpha1. After launching npx shadow-cljs server I'm connecting on the default port of 9000 and then running (shadow/repl :main). Everything else works fine. I'm just not able to evaluate stuff from a buffer. The buffer is connected. I've verified that looking at sesman. I put a debug-on-entry on cider-set-repl-type and I see it change from cljs-pending type to clj type on the first attempt at eval. And if I manually set the type back to cljs with (cider-set-repl-type 'cljs, then on the next eval it tries to set it back to clj.#2020-05-1921:06dpsuttonif you set it to cljs and then eval something that is 100% cljs specific like (js/alert "hi") does it still kick it back to `clj?#2020-05-1921:11Eric IhliWell... shit... I switched to a different project and after manually changing it, it doesn't kick back to clj. It was in a project I was in earlier. I have to run out in 5 minutes so I'll see if I can repro when I get back.#2020-05-2008:50ElirazI have a question regarding to clojure.spec, how is it integrated with shadow-cljs? can It have a different run command? like npm test ? how do you setup the files with it? is there an example ?#2020-05-2009:16Andy HeywoodThe question’s a bit confusing, that’s not really how spec works - but it exists for cljs in the same way as it does for clojure.#2020-05-2009:17Andy HeywoodI’ve been working with it over the last few days - just require cljs.spec.alpha and you’re good to go#2020-05-2009:17Andy HeywoodThis is a good general reference - https://clojure.org/guides/spec#2020-05-2009:19Elirazokay, but how do you decide whether you you' d like to run the spec files or not?#2020-05-2009:19ElirazI mean, spec goes to production code?#2020-05-2009:20Andy Heywoodyeah, absolutely#2020-05-2009:20ElirazI haven't find any example of how it is integrated with the code.#2020-05-2009:20Elirazwhat if I'd like to have it only for development?#2020-05-2009:20Elirazis it possible?#2020-05-2009:21Andy Heywoodit’s just a library to allow declarative specification of data structures - it’s used a lot in testing, but also for validation of incoming data (in my case)#2020-05-2009:21Andy Heywoodcheck out the guide I linked above#2020-05-2009:21Elirazthank you#2020-05-2015:36lilactown@U012XM1CH39 clojure.spec.alpha is a code library for adding assertions to your code. it gets included in your bundle by default#2020-05-2013:30papachanHello. Just a question regarding cider and shadow-cljs. Is there a way to automatically start my app and directly tell cider-connect-sibling-cljs to use my unique :app alias ? I have my dir-locals.el on this project with the basic settings:
((nil . ((cider-default-cljs-repl . shadow)
         (cider-shadow-cljs-default-options . "app"))))
#2020-05-2015:37lilactownit might be a good question for #cider . I’m not sure, and I know that thheller doesn’t use Emacs or CIDER#2020-05-2016:56papachan@U4YGF4NGM yeah i supposed it too. but maybe some dev using shadow-cljs have a tip for me.#2020-05-2015:35Andy HeywoodI’ve worked around this for now, but just to throw it out there - it looks like shadow (or cljs in general?) doesn’t support - characters in namespaces when referencing namespaced keywords (i.e. when using spec)#2020-05-2015:36Andy Heywoodtypically my-ns becomes my_ns.cljs , but otherwise is referenced everywhere as e.g. (my-ns/my-fn …)#2020-05-2015:37Andy Heywoodbut when namespacing keys, :my-ns/mykey doesn’t work, it has to be :my_ns/mykey#2020-05-2015:38Andy Heywoodoh sorry - huge omission on my part - this is only an issue when running the node-test target - it works fine in the REPL#2020-05-2015:39lilactown@andrew.heywood can you explain what “doesn’t work” means?#2020-05-2015:44Andy HeywoodI should have threaded this too, sry - it’s easy enough to work around, but if it’s a legit issue I can submit an actual report with proper repro etc. Just thought I’d see if it was an obvious known issue#2020-05-2015:39Andy Heywoodhaha sorry, of course#2020-05-2015:39Andy Heywoodbasically ‘spec not found’:#2020-05-2015:41Andy HeywoodI’m trying to upload shots here but something’s crapping out sry#2020-05-2015:42Andy Heywood/.shadow-cljs/builds/test/dev/out/cljs-runtime/cljs/spec/alpha.cljs:71 (throw (js/Error. (str "Unable to resolve spec: " k))))#2020-05-2015:44lilactowncan you paste the code that causes this error?#2020-05-2015:44lilactowncan you paste the code that causes this error?#2020-05-2015:46Andy Heywoodyeah, I’m trying to simplify it down because it’s all slightly sensitive in it’s current form#2020-05-2015:55Andy Heywoodok this is confusing me. when I recreate it with a trivial example it works fine, but it works because now I can reference the ns properly:
:lambda.my-spec/myspec
#2020-05-2015:56Andy Heywoodpreviously, that failed, and I could only reference my spec as :_spec/spec#2020-05-2015:57lilactowndid you have an improper ns form?#2020-05-2015:57Andy HeywoodI switched between the repl and the test runner, and had a server running the whole time, and probably renamed the namespace… maybe some wires got crossed and I hit an edge case#2020-05-2015:57Andy HeywoodI don’t think so?#2020-05-2015:58lilactownwere you using shorthand syntax like ::lambda?#2020-05-2015:58Andy Heywoodgoing back to the original code that I just fixed, and if it re-breaks, I’ll dm it to you#2020-05-2015:58Andy Heywoodno I wasn’t#2020-05-2015:58lilactownok#2020-05-2016:07Andy Heywoodnope, it’s all working fine now, back in the state that was previously broken. It definitely was broken, but I’m very sure that after renaming the ns, the REPL was only accepting :my_ns/keyword whereas the test runner expected :my-ns/keyword. I was simultaneously running:
shadow-cljs watch :test
shadow-cljs watch :repl
node dist/node/repl.js
#2020-05-2016:07Andy Heywoodidk. I’m glad it’s not a real issue though 😄#2020-05-2016:08lilactownah so you renamed the namespace. that’s valuable info. not sure what to do with it tho 😛#2020-05-2016:10Andy Heywoodyeah, I can’t remember why/when exactly, it was this morning, I’ve been on the REPL all day. But I remember messing with stuff this morning because I thought it was very weird that I had to reference my namespaced keyword with an underscore instead of a dash#2020-05-2016:11Andy Heywoodand I’ve been generating from specs all day using an underscore for a ns that has a dash in it. and when I went over to the tests, nothing worked.#2020-05-2016:37Andy HeywoodI’ve figured it out (I think)! When referencing a kw, you have to require the ns separately. So it was all red-herrings - what’s actually fixed the problem is requiring the spec’s namepsace in the consuming namespace#2020-05-2016:38Andy Heywoodi.e.
(s/gen :lambda.leads-spec/lead)
will only work if you also require
[lambda.leads-spec :as ls]
#2020-05-2016:40thhelleryes, you can't gen/reference specs that haven't been loaded yet#2020-05-2015:50scottloweHello. Should the build-option :print-fn :none with :target :browser result in my not seeing println messages in the browser console? I’ve tried setting this locally is dev mode and there doesn’t seem to be any effect. Somewhat ironically, I was only checking it disabled printing in dev mode so that I can be sure that I’ve got the correct setting to use in my release build. I’m now wondering if it is overridden in dev when the shadow-cljs websocket is in use. Anyway, I’d like to disable printing in prod / release builds… so does anybody know if this option should still work, because it’s not mentioned in the current documentation, but I can see it in the source code?#2020-05-2015:55lilactown@scottlowe I’m not sure, but you can test this pretty quickly by doing a release build#2020-05-2015:56lilactownif you’ve already got a dev watcher running, in another terminal run:
shadow-cljs release <build>
and do a hard refresh of the page you’re developing in
#2020-05-2016:16scottloweHeh. I should have done that initially, but we have a complicated setup (don’t ask!). Was being lazy. Have built in release mode now and it doesn’t seem to work.#2020-05-2016:16scottlowePerhaps this is why: https://github.com/thheller/shadow-cljs/blob/fda0dc02d8199d5475a3ab42a3d2fd247c237235/src/main/shadow/build.clj#L306-L308#2020-05-2016:41thhelleryeah print-fn can't be disabled because otherwise you always get an exception for anything that prints#2020-05-2016:42thhellerwell, you can just set (set-print-fn! (fn [x])) in your :init-fn#2020-05-2016:42thhellerbut something must be set or you get errors#2020-05-2016:54scottloweOkay. Thank you very much for the confirmation, Thomas.#2020-05-2015:59grumpletrouting#2020-05-2016:07tzzhis it possible to use :module-hash-name with a :node-script target ? I couldn’t get it to work but was just wondering if this is possible#2020-05-2016:34thhellerno. what would be the point? do you want to guess the name of the script you want to execute?#2020-05-2016:36tzzhlol no - it’s more of a versioning thing but I realised it’s a bit of a dumb idea I am using the commit hash instead#2020-05-2016:28ullrichIs there anything special I need to do to get clojure.spec.gen.alpha up and running in a CLJS project with shadow? I’ve followed https://clojure.org/guides/spec#_generators and added org.clojure/test.check to our dependencies, but when I invoke (gen/generate (s/gen int?)) in the repl I get something like a deref error. (`[clojure.spec.gen.alpha :as gen]` & [cljs.spec.alpha :as s])#2020-05-2016:30Andy Heywoodtop of my head, having just been through this, you need to require clojure.test.check.generators#2020-05-2016:30Andy Heywoodi.e. require it in that ns, even though you’re not referencing it directly#2020-05-2016:31ullrich!!! Thanks @andrew.heywood you just saved my day (actually my evening 😄 )
#2020-05-2016:31ullrichRequiring clojure.test.check.generators did the trick#2020-05-2016:32Andy Heywoodtook me a while to find that one. I’ve definitely sunk a couple of wasted hours into cljs/shadow/spec integration this week#2020-05-2016:32Andy Heywoodwell worth it overall though!#2020-05-2016:34ullrichYes, I added specs to a hughe part of my lib but what gives if it breakes my tests because of my hand build test data 😄 I’m so excited about this right now. Thanks again @andrew.heywood The future is bright 😎#2020-05-2016:29grumplet@thheller I’m seeing some strange behaviour with shadow-cljs :dev-http server redirection. I’m using reitit-frontend so I can switch hashtag routing on or off. Looking at localhost:8280/lung and localhost:8280/lung/centre - these URLs both work with internal reitit navigation, but on address bar navigation /lung works but not /lung/centre. Hashtag versions work from the address bar as expected. I’m concluding that the dev servers can only redirect single-level addresses when typed in back to index.html. So /lung gets redirected to /index.html, but /lung/centre doesn’t. It seems strange, because if there were no redirection happening at all, I would expect the /lung address to fail too. The /lung/centre address gives a 404 in the browser.#2020-05-2016:36thheller@grumplet the :dev-http servers NEVER redirect. that functionality does not exist. unless of course you use a custom handler that does that. the built-ins don't#2020-05-2016:37grumpletThat’s truly strange then. The docs do say they fall back to index.html when a resource is not found.#2020-05-2016:37grumpletSection 5.4.5 of he user guide#2020-05-2016:38thhelleryes, it will serve that content. it will not redirect.#2020-05-2016:39grumpletGot it. Yes that agrees with the behaviour. Thanks!#2020-05-2020:00ghufranI just started using shadow-cljs, and trying to get it set up with cursive. I also just started blogging, and wrote a https://ghufran.posthaven.com/setting-up-a-reagent-clojurescript-project-with-shadow-cljs-and-cursive trying to detail the steps - the documentation was super helpful, so thanks to everyone who contributed to that! Take a look at the post if you get a chance - if you're new to shadow-cljs like me, let me know if anything is unclear, or could be improved, if you're an experienced user, let me know if I'm just doing it wrong... 🙂#2020-05-2115:10Wilson Velezhi @ghufran, I followed this guide and it helps me a lot, you can see if you find something useful#2020-05-2020:02ghufranI actually came here to ask - everything seems to be compiling fine, and will show up correctly when I refresh, but the 'hot reloading' doesn't seem to be working - I thought it came 'automatically' with shadow-cljs watch :build_name ? I tried using a different browser and incognito mode in case I had a chrome extension that was interfering, but still not working so far. Any pointers on things I should check?#2020-05-2020:07thheller@ghufran for Cursive I recommend running shadow-cljs pom and importing the pom.xml as a project https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2020-05-2020:09thhellerif you want hot-reload you need to configure a function to call that does the actual re-rendering. see :dev/after-load https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2020-05-2020:09thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-05-2020:09ghufranI saw that, but wasn't sure if that was because cursive didn't handle deps then, or because there was some other advantage#2020-05-2020:10ghufranThanks!#2020-05-2020:10thheller> Go to and select node_modules > shadow-cljs-jar > bin > shadow-cljs.jar, then click "open"#2020-05-2020:10thhellerthis is definitely something you shouldn't be doing#2020-05-2020:11thhelleryou also might want to read https://github.com/thheller/shadow-cljs#quick-start#2020-05-2020:11thhellersaves you the couple first steps#2020-05-2020:18ghufranWow, totally missed that! - the current "beginner guide" link goes to a blog post, might be best to just make that link to this instead!#2020-05-2020:43knubieAre there any known issues with using with-redefs in shadow-cljs test builds?#2020-05-2020:44knubieI have a simple test like this, which raises an exception when the test is run: foo_test.foo is not a function#2020-05-2020:44knubieThe broader context is that I’m trying to use https://github.com/alexanderjamesking/spy to mock some functions.#2020-05-2021:29EddieHi all, I'm a long time Clojure dev, but first time venturing into Clojurescript. I am struggling to get a skeleton deps.edn + shadow-cljs project up and running. I hate to dump a bunch of file contents to the channel, but I honestly can't even figure out a thread to pull on. Here is my deps.edn
{:src     ["paths"]
 :deps    {org.clojure/clojurescript {:mvn/version "1.10.758"}
           reagent                   {:mvn/version "1.0.0-alpha2"}}
 :aliases {:shadow-cljs
           {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.8"}}
            :main-opts  ["-m" "shadow.cljs.devtools.cli"]}}}
and my shadow-cljs.edn
{:deps     true
 :dev-http {8080 "target/"}
 :builds   {:app {:target     :browser
                  :output-dir "target/"
                  :asset-path "."
                  :modules    {:main {:entries app.core}}
                  :devtools   {:after-load app.core/main}}}}
when I call clj -A:shadow-cljs compile app I get the following exception.
Execution error (IllegalArgumentException) at shadow.build.js-support/eval11018$loading (js_support.clj:1).
No matching field found: getRegisteredGroups for class com.google.javascript.jscomp.DiagnosticGroups
If anybody can spot what I am doing wrong, I would greatly appreciate it.
#2020-05-2021:48thheller@erp12 you are using mismatched versions, see https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-05-2021:49thhelleralso if you upgrade to shadow-cljs 2.9.8 you will get an error telling you that 😉#2020-05-2021:55EddieThanks @thheller! So if I am reading this correctly, if looks like: shadow-cljs 2.9.8 is compatible with clojurescript 1.10.758. Changing that allows me to load.#2020-05-2021:56EddieAlthough the build starts, I get a build failure no output for id: [:shadow.build.classpath/resource "goog/base.js"] Is that still a deps and/or versioning problem?#2020-05-2021:58thhellerwell your :entries should be [app.core]. dunno why the spec allows a lone symbol there.#2020-05-2021:59EddieAh forgot to mention that I noticed that and fixed it after getting the versions correct.#2020-05-2021:59EddieThe spec did not allow it 🙂#2020-05-2022:02thhellernot sure why you are getting that error. can you post the full trace?#2020-05-2100:44EddieI had to go offline for a bit and when I came back i couldn't reproduce the error. I'm up and running now. Thanks a million for your help!#2020-05-2022:03thhelleryou might want to read https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2020-05-2022:03thhellergoing through clj is fine but a lot slower 😛#2020-05-2022:05thhellermaybe try adding these exclusions to the clojurescript dep, but full trace would help.
:exclusions
    [com.google.javascript/closure-compiler-unshaded
     org.clojure/google-closure-library
     org.clojure/google-closure-library-third-party]
#2020-05-2022:34dvingoI thought I recall reading in the shadow user guide that you can inline files with some helper. I've been scanning to docs looking for it but can't find it. anyone know what I'm talking about?#2020-05-2022:35dpsuttoni always google it and find it on clojureverse#2020-05-2022:36dvingomaybe that's where i saw it#2020-05-2022:36dpsuttonhttps://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2020-05-2022:36dvingothanks, i appreciate it#2020-05-2106:04ghufranI am trying to get source maps working, but having trouble This is my shadow-cljs.edn file:
;; shadow-cljs configuration
{:source-paths ["src"]
 :dev-http {8081 "public"}
 :nrepl {:port 55555}
 :dependencies			[[reagent "1.0.0-alpha2"]]
 :builds {:app { :target		    :browser
                :output-dir	  "public/scripts/"
                :modules	    {:core
                                  {:init-fn com.ghufran.core/run }}
                :compiler-options {:source-map                          true
                                   :source-map-detail-level             :all
                                   :source-map-include-sources-content  true
                                   }}}}
and this is the error I’m getting in the browser console (chrome) on first loading the page:
DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0
and this is the error in the firefox console:
Source map error: Error: request failed with status 404
Resource URL: 
Source Map URL: com.ghufran.core.js.map
I’m actually getting around 30 such errors, one for each file in /cljs-runtime/ whose source map the browser can’t find It looks like the browser is expecting the source map to be in /js/cljs-runtime/ when it should be /scripts/cljs-runtime/ based on the shadow-cljs.edn file, if I’ve understood that correctly. I’ve confirmed that com.ghufran.core.js.map is in fact in /scripts/cljs-runtime/ Any idea what might be going on? Is there some other config I need to tweak?
#2020-05-2108:01thheller@ghufran you don't need to set any of the :compiler-options, you are just relying on the default :asset-path "/js" which is incorrect in your case.#2020-05-2108:01thheller
{:source-paths ["src"]
 :dev-http {8081 "public"}
 :nrepl {:port 55555}
 :dependencies [[reagent "1.0.0-alpha2"]]
 :builds {:app {:target :browser
                :output-dir "public/scripts"
                :asset-path "/scripts"
                :modules {:core {:init-fn com.ghufran.core/run}}
                }}}
#2020-05-2115:12ghufranPerfect, thanks!#2020-05-2115:24flyboarder@thheller is there a shortcut in shadow-cljs to automatically require some namespaces in all or some files when compiling?#2020-05-2115:25flyboardermy use case: I would like to have my framework namespaces always available without a require block in every file that has to duplicate the same block of code, currently I have some front end stuff and our ui library has ~30 namespaces#2020-05-2115:29flyboarder{:require {#{app.ui} [[hoplon.core :as h]]}} something like that in shadow-cljs.edn would be great as a build option#2020-05-2115:51lilactownthat would be pretty surprising and wouldn’t transfer to any other build tool 😕 dislike#2020-05-2115:58lilactownI’m struggling to use shadow inspect#2020-05-2115:58lilactownI’ve included the preload in my build:
:devtools {:preloads [day8.re-frame-10x.preload
                                      shadow.remote.runtime.cljs.browser
                                      devtools.preload]}
#2020-05-2115:58lilactownI’ve opened my app in one tab and the ui at localhost:9630 in the other#2020-05-2115:59lilactownin my editor, I’ve a CLJS REPL open:
shadow.user> (shadow/watch :app)
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (1202 files, 4 compiled, 7 warnings, 13.32s)
shadow.user> (shadow/repl :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user> (tap> 123)
true
however, I see no output in the inspect tab of the shadow UI
#2020-05-2117:56isakStrange, works for me. Do you see anything if you use the cljs.user prompt at the bottom to do the tap> ?#2020-05-2117:56lilactownI don’t see a cljs.user prompt either#2020-05-2117:57isakOh, do you see a runtime connected near the top?#2020-05-2117:57lilactownit’s simply blank underneath the dashboard/builds/runtimes/inspect header tabs#2020-05-2117:57isakfor example, I see this:#2020-05-2117:58isakHm, do you have browser window that is loading your clojurescript code?#2020-05-2117:58lilactownyep#2020-05-2117:58lilactownI have a jacked-in CIDER session that I can evaluate CLJS code in the browser#2020-05-2118:00isakHm, not sure then#2020-05-2118:00lilactownunder “Runtimes” I don’t see anything under “Available ClojureScript Runtimes”#2020-05-2118:00lilactown#2020-05-2118:02thheller@U4YGF4NGM check the networks websockets tab. there should be a dedicated websocket for the remote stuff#2020-05-2118:05thhellerif all else fails just try shadow-cljs browser-repl and then (require 'shadow.remote.runtime.cljs.browser)#2020-05-2116:00lilactownthere are no errors in either tab’s console#2020-05-2117:35isak@flyboarder yea I've thought about that too, I think something like that is a good idea for the ns macro. Best place would be in ClojureScript, but that will never happen, unfortunately#2020-05-2117:37isakIn your case, maybe a decent workaround would be to re-export things from another namespace? Wouldn't work for :refers, though#2020-05-2117:38flyboarder@isak what do you mean by re-exporting?#2020-05-2117:38flyboardercan I def a ns as a symbol? and then refer that symbol?#2020-05-2117:39lilactown@flyboarder you can have one namespace that require’s all 30 of your other namespaces, then re-exports them#2020-05-2117:39isakFor example, re-frame does this so you don't need to import so many namespaces: https://github.com/day8/re-frame/blob/master/src/re_frame/core.cljc#L576-L597#2020-05-2117:39isakJust re-frame.core for most things#2020-05-2117:40flyboarderah yes I do this already, but I need to be able to resolve namespaced keywords ::card/card#2020-05-2117:40isakSo you can point to a function, but I guess you need to copy the docstring and any other meta#2020-05-2117:41flyboarderwhere ::card is one of my ui libs#2020-05-2117:41isakAh right, guess it wont work#2020-05-2117:42flyboarderthats why I think an auto included list of requires would be a good fit here
(ns 
  (:require-shadow :exclude [some.unwanted.ns]))
  (:require [[the.usual :as whatever]])
#2020-05-2117:43isakyea they have a mechanism for this in Elixir, very useful#2020-05-2117:45flyboarderhm, I wonder if I can hack the ns macro and extend it with this#2020-05-2117:46lilactownyou’ll run into lots of problems with anything that uses static analysis#2020-05-2117:46lilactowne.g. Cursive, clj-kondo, cljfmt/cljstyle#2020-05-2117:47flyboarderoh for sure, but I also wouldnt expect this to work outside of shadow#2020-05-2117:48isakHere is convo about this from before, Thomas commented: https://clojurians-log.clojureverse.org/shadow-cljs/2019-10-21/1571698320.305600#2020-05-2123:22dvingohey yall. I have a macro that spits out some cljs code and I'd like to configure the output of the macro based on a var that, ideally, the user can pass in. Anyone have any ideas how to go about that? I guess in the worst case I could deal with the config at runtime in cljs instead#2020-05-2123:51darwinso letting user specify it as a macro argument is not convenient? you want something to configure this once externally?#2020-05-2200:24dvingoyea, it's for a library - a wrapper around emotion css-in-js. it would be a global config to determine if the library assigns the component name as part of the className for the generated component. you'd specify :full to get ns/symbol :short for symbol or nil to not apply it. I have it using metadata for each individual call so you can override at the single level, but I'm thinking you could have a release build disable all className assignment, but you'd keep it for dev to see your components in the elements tab in devtools#2020-05-2210:16darwinyou can have a macro which emits nothing and as a side effect sets some globals in clojure context, subsequent macro expansions can use this value - it is doable, but side-effecting macros are not a good practice#2020-05-2212:25dvingoah thank you! yea, I'm thinking the better user api is to set the config via closure-define and to execute the configuration logic at runtime instead of tryint to do it at macroexpansion time.#2020-05-2200:24frankitoxHi! I'm trying to set up shadow-cljs to use a REPL with iced-vim. I had to add https://liquidz.github.io/vim-iced/vim-iced.html#vim-iced-manual-shadow-cljs settings to my shadow-cljs.edn file and it worked. Then I thought about moving that settings to .nrepl.edn or ~/.nrepl/nrepl.edn. But it's not picking up the changes. I feel like I'm missing something here. I'm using :react-native as target.#2020-05-2200:33frankitoxFor now I'll leave the :nrepl part of the settings on shadow-cljs.edn and move the :dependencies to deps.edn . But if somebody thinks otherwise do let me know!#2020-05-2207:35thhellerI don't know what dependencies have to do with nrepl but .nrepl.edn should be picked up#2020-05-2207:35thhellerjust need to make sure you restart shadow-cljs after making changes#2020-05-2222:24frankitoxThanks 🙂#2020-05-2209:20kirill.salykinHi, with latest changes to clojurescript (https://clojurescript.org/guides/webpack) npm integration becomes better and better. thus there is a question - what is the difference in handling npm dependencies between shadow-cljs and clojurescript? is shadow-cljs mostly just a code reloader via websocket (and sane compiler settings)? why would I prefer shadow-cljs over clojurescript (and vice verse)? sorry if i am asking stupid things, just trying to understand how things are connected thanks!#2020-05-2212:44vcode reloading, build your files based on target (e.g browser, node etc), code splitting, npm integration, sane project configuration settings#2020-05-2213:46kirill.salykinthanks#2020-05-2209:56thheller@kirill.salykin https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2020-05-2506:05Chris McCormickgreat summary thanks for this. :+1:#2020-05-2209:57thhellercode-reloading is maybe 5% of what shadow-cljs does so you get a lot more than that 😛#2020-05-2213:46kirill.salykinthanks#2020-05-2216:30AronI did a release build and it's heavy. Although not too much, but out of curiosity, is there a way to look into these visually and see what is being included?#2020-05-2223:12steveb8nhttps://github.com/stevebuik/Stu#2020-05-2300:36Aronvery nice, thanks#2020-05-2300:43steveb8nno probs. it’s a little out of date but I just tested it on my app and it works. there’s no longer a release-snapshot fn in shadow. the build-report fn will generate the snapshot data#2020-05-2300:44steveb8nand you’ll need > 1 snapshot to see the toggles on the left hand side. just rename the “latest” one and re-gen (or copy “latest” with another name).#2020-05-2300:45steveb8nsorry about the extra steps. I haven’t looked at it in a while. but now I’m learning about my new apps bundle 🙂#2020-05-2216:34Derekhttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2020-05-2216:46AronI wish I could remember what I see#2020-05-2217:01vhow do i specify nrepl port for each target build. I tried looking at the docs but couldnt anything#2020-05-2217:11dpsuttoni think only one nprel port?#2020-05-2217:12dpsuttonits just a single nrepl port. but you connect and call (shadow/nrepl-select :app) and that's how you specify which build for each repl#2020-05-2217:12lilactownyeah, there should only be one nREPL port. you can connect multiple times and have multiple REPLs#2020-05-2217:12lilactownIIRC#2020-05-2217:54isakAny problems with using :^const for constants that will not change in a live-reload context, so that they can be used with case, like (case x my-const ...)?#2020-05-2219:34thheller@isak ^:const had issues in a couple releases. should be fixed in 2.9.8. also don't use ^:const 😛#2020-05-2219:39isak@thheller ok, cool. What is the problem with it? The benefit is the (case) thing#2020-05-2219:41thhellercase is exactly the problem. it works differently in clojure.#2020-05-2219:42isakAh, ok, sounds like a good reason to avoid, thanks#2020-05-2223:11Brandon OlivierI'm trying to introduce a shadow-cljs project at work. Is it possible to get the tree shaking provided by webpack when I use an npm lib? (it's a lib we own, specifically a component lib)#2020-05-2301:54Lucy WangI wonder why not use google closure compiler's more advanced optimization instead?#2020-05-2307:23David PhamIs it possible to create a nrepl connection into a production nodejs script?#2020-05-2314:50Lucy WangI think you have to checkout how to use self-hosted cljs (lumo) as a library#2020-05-2308:45thheller@neo2551 no#2020-05-2311:05andrerelease 0.2.1 version for https://github.com/flexsurfer/rn-shadow-steroid react navigation with hot reload is simpler now, and also supports build notifiers#2020-05-2311:05andrehttps://github.com/flexsurfer/rn-shadow-steroid/blob/master/screencast.gif#2020-05-2317:19SaikyunI'm trying to require some js-files, for some reason I get the error:
Requested module does not have an export "EventDispatcher".
--- js/lul/OrbitControls.js:10
and many like it. the js-file looks like this:
import {
	EventDispatcher,
	MOUSE,
	Quaternion,
	Spherical,
	TOUCH,
	Vector2,
	Vector3
} from "three";
when looking at your example: https://github.com/shadow-cljs/examples/blob/master/local-js/src/demo/foo.js it seems like you are doing the same thing. so can't really figure out what I'm doing wrong
#2020-05-2317:30thheller@saikyun since "three" is a JS dependency that doesn't go through closure you cannot use refers like that. closure is rather picky on that subject and I haven't found a way to "allow all". import * as THREE from "three" should do it.#2020-05-2317:31thhelleror import THREE from "three"#2020-05-2317:31thhellercommonjs<->esm interop is still rather meh#2020-05-2317:33Saikyuncool, that did the trick. cheers! 🙂#2020-05-2317:34SaikyunI understand, am I understanding it correctly if I say require/`module.exports` is commonjs? and that's what shadow-cljs prefers?#2020-05-2317:35thhellershadow-cljs prefers ESM but as soon as you are using npm modules you might be better off sticking with commonjs#2020-05-2317:36thhellerthe rules for that are a lot less strict and generally interop with other commonjs works a bit better#2020-05-2317:36thhellerthe goal is to eventually get to everything using ESM though ...#2020-05-2317:38Saikyunokay, good to know#2020-05-2317:39Saikyunhmm, it seems that certain things doesn't get picked up by the import * -part. but if I did the require(...)-way it works. :x#2020-05-2317:41thheller> commonjs<->esm interop is still rather meh#2020-05-2317:41thheller😛#2020-05-2317:41Saikyunhehe 😄 I don't mind, just putting it out there in case anyone else stumbles over the chat log 🙂#2020-05-2317:42Saikyuneither way, thanks as always. shadow-cljs is currently being used both on my game project and at work. very happy with it.#2020-05-2318:00Saikyunhmm -- for some reason, that broke down when running on expo. maybe I should go back to putting my js code in an npm module instead#2020-05-2318:01SaikyunI did that before, but yarn link was pretty painful sometimes ^^;#2020-05-2318:07Saikyunanyway, don't bother about it, I'll solve it some other way 🙂 sometimes I get the feeling that the three-libs aren't structured nicely either#2020-05-2416:37knubieIt would be great if tap> returned its argument so that you could put it in the middle of thread macros#2020-05-2416:40lilactowndoto is universally useful for things like that but yes I feel this pain too#2020-05-2416:40knubieOh, yeah hadn’t thought of using doto#2020-05-2417:20thhellerthere is a CLJ ticket about tap>, not something shadow-cljs can change#2020-05-2420:19Saikyunmore and more I've started adopting bastardized lets:
(let [a (f)
      b (f' a)
      _ (tap> b)
      c (f'' b)]
  c)
#2020-05-2420:20SaikyunI don't reach for them immediately, but I feel they solve problems like wanting to do something in the middle of a threading macro#2020-05-2420:23thhellerFWIW I started writing an "enhanced" version of tap that has 3 forms ?> ?-> ?->> that captures the source location as well#2020-05-2420:23thhellerhttps://github.com/thheller/shadow-cljs/blob/7024ff149b9e6ae0e91aa98f8f3c67a2a2a54542/src/main/shadow/debug.clj#L39-L61#2020-05-2420:23thhellerI have only used it in shadow-cljs for CLJ stuff so far though so it doesn't do any of the "do nothing in release builds" stuff yet#2020-05-2420:25thhellerplenty of namespaces in shadow-cljs itself have [shadow.debug :refer (?> ?-> ?->>)] in their requires#2020-05-2420:25thhellerthere is also a (shadow.debug/locals) which dumps all the locals at that location as a tap#2020-05-2420:26thhellernone of this is guaranteed to stay though, really just a basic layer to address some of the limits of tap>. no clue how this would look when done properly.#2020-05-2420:28thhellerdon't really like that all of them take a second arg though, since thats the only reason it has 3 variants .. had some plans for that but not sure it makes sense anymore#2020-05-2423:31nprbstQuestion: Why would I see this error The required namespace "enqus.views" is not available, it was required by "enqus/main.cljs" with a file tree like this:
src/cljs/enqus/main.cljs
src/cljs/enqus/views/views.cljs
Where views.cljs starts off with (ns enqus.views?
#2020-05-2423:32nprbstI'm new to CLJS and it seems like either nested namespaces are disallowed (which would be strange) or I'm doing something wrong (more likely).#2020-05-2423:33nprbstAlso, my shadow-cljs.edn includes :source-paths ["src/cljc" "src/cljs"]#2020-05-2423:44lilactown@nathan.probst your namespaces need to match your file system#2020-05-2423:45nprbstMeaning it should be enqus.views.views in that case?#2020-05-2502:08lilactownYes#2020-05-2505:22ghufran@thheller: I wrote a blog post about https://ghufran.posthaven.com/using-devcards-with-shadow-cljs. I ran into some strange behavior, where changing the order of the (:require ..) vectors in the ns declaration seemed to lead to errors - can you take a look when you get a chance and let me know of any errors / omissions? Thanks!#2020-05-2507:22thheller@ghufran you do not need this complex ns require
(ns 
  (:require
   [devcards.core :as dc])
  (:require-macros
   [devcards.core :refer [defcard]]))
#2020-05-2507:23thhellerthis is enough
(ns 
  (:require
    [devcards.core :as dc :refer [defcard]]))
#2020-05-2507:23thhelleryou also do not need [thheller/shadow-cljsjs "0.0.21"]. just need to install marked.#2020-05-2517:20ghufranInteresting - so is the functionality that used to be in shadow-cljsjs now incorporated into shadow-cljs?#2020-05-2517:24thhellershadow-cljsjs has always been a dependency of shadow-cljs and you never need to require it directly. you never did so I don't know what made you think you need the require. would be curious to know what made you think that?#2020-05-2517:33ghufranWhen I read the https://github.com/thheller/shadow-cljsjs, I assumed from the name that it was for use with shadow-cljs - probably because I found it from this https://github.com/bhauman/devcards/issues/156, where it seemed a shim file was needed, and that shadow-cljsjs was a ‘one-stop-shop’ for those shims 🙂. Maybe we could update the shadow-cljsjs repo to make clear it’s not required separately if you are using shadow-cljs?#2020-05-2517:38thhellerthanks, I added a note to the readme https://github.com/thheller/shadow-cljsjs#2020-05-2507:26thheller> (Note: you may need to hit CTRL-C in order to get back to the terminal after this error).#2020-05-2507:26thhelleryou can also just open another terminal do the install, no need to restart shadow-cljs. it should pick up the newly installed package.#2020-05-2510:53Saikyunre: ?> et. al. -- sounds interesting 🙂 I've played around a bit in this area with miracle.save, but I hadn't considered you could get line information. this is only possible in cljs, right? I haven't figured out a way to capture this in clojure#2020-05-2511:00David Pham@thheller Do you think colorizing code in the inspect window of shadow-cljs would be a big work?#2020-05-2511:00David Pham(syntax highlighting would be the correct word)#2020-05-2511:16thheller@saikyun this works for CLJ too. you can get the line/column from the form metadata#2020-05-2516:54Saikyunhuh, really? thanks for the info. this is great news.#2020-05-2511:16thheller@neo2551 colorzing what exactly?#2020-05-2511:17David PhamThe data structure litterals that are in the pretty print windows#2020-05-2511:17David Phamor even the inspector?#2020-05-2511:17David PhamIf you tap a map, it would be nice to have the string colorized, or the keywords in a different color.#2020-05-2511:18David PhamMaybe we are too spoiled with our IDEs so when I see the data structure on inspect, I wish to have the same visual clues#2020-05-2511:18David Phambut I am already quit thankful for inspect 🙂#2020-05-2511:18thhellernot sure what the point of that would be? but I'm also not sure what exactly you are referring too#2020-05-2511:19thhellerthe "view as pretty-print/edn" could be syntax highlighted yes#2020-05-2511:19thhellerthe browse view not really#2020-05-2511:19David Phamyes, I was referring to the view as pretty-print/edn#2020-05-2511:19thhellernot sure it needs to#2020-05-2511:20thhellerI barely ever use those so hasn't been a priority for me 😛#2020-05-2511:21David Phamhaha, I am just saying that it is nice since pretty printing does not work on Emacs#2020-05-2511:21David Phamwith shadow-cljs#2020-05-2511:21thhellerhmm?#2020-05-2511:21thhellerah the automagic nrepl stuff? just set :devtools {:repl-pprint true} if you want pprint#2020-05-2511:21David PhamCider never pretty prints my result when I connect to shadow-cljs#2020-05-2511:24David Phamoh okay nevermind#2020-05-2511:24David PhamI learned something today 🙂#2020-05-2511:25thhellerI had some ideas for colorizing the browse output a bit. I may do that at some point but its quite a lot of work so may take a while#2020-05-2511:25David Phamwhat about putting code mirror in it?#2020-05-2511:25David Pham🙂#2020-05-2511:25thhellerthats what I'd do for pretty-print/edn#2020-05-2511:25thhellerfor browse that is not an option. performance would be horrific#2020-05-2511:26David Phamwhat about just for pretty-print/edn?#2020-05-2511:26David PhamI don't use browser that much#2020-05-2511:28David PhamIt is cool for big inputs, but usually pretty-print#2020-05-2511:29David PhamIt is great because it allows to have some history of the print and Emacs is not providing that#2020-05-2514:20thheller@neo2551 https://github.com/thheller/shadow-cljs/commit/0f9d9a0d034cddc5dece731526f0b9cedd879554 I'll probably make a release later#2020-05-2514:20David PhamThanks!#2020-05-2514:46ho0manHi everyone, Is there a way in shadow-cljs to pass some values/configuration to the app based on the build target - for instance to set the address for my api requests localhost:3000 for :dev mode and for :release ? Thanks#2020-05-2514:58Andy Heywood--config-merge in general#2020-05-2514:59Andy HeywoodI don’t think there are any other options, other than of course different targets which weirdly I didn’t think about when I was doing this 😕#2020-05-2515:00Andy Heywoodbut if your target has a large proportion of varying data vs static data, maybe that’s a good option#2020-05-2515:03ho0manThanks a lot, Andy#2020-05-2517:03dvingoI came across an interesting situation where a js module is required correctly using :as for a browser build, but resolves to nil in an :npm-module build. Additionally, in an :npm-module build :default resolves the package correctly. I'm using this js library https://www.npmjs.com/package/@date-io/date-fns/v/1.3.13 I noticed that their package.json (within node_modules/@date-io/date-fns) has this :
{"name": "@date-io/date-fns",
  "version": "1.3.13",
  "description": "Abstraction over common javascript date management libraries",
  "main": "build/index.js",
  "module": "build/index.esm.js",
I'm not sure if that module entry is what's messing things up. at a plain node repl:
> require('@date-io/date-fns')
[Function: DateFnsUtils]
it doesn't come in as an object with default on it - which is the desired behavior and is what happens in the :browser build. this is confirmed in a shadow browser-repl also:
(require '["@date-io/date-fns" :as d1])
cljs.user=> d1
#object[DateFnsUtils]
anyway. I got things working by doing this:
(:require
;; for browser target
 ["@date-io/date-fns" :as date-fns]
;; for npm-module target
 ["@date-io/date-fns" :default date-fns2])

(def date-util-fn (or date-fns2 date-fns))
I'm not sure what is causing the difference, but posting here in case someone knows or has run into this.
#2020-05-2517:13dvingoI also see the following in the compiled file for the npm-module build: shadow.js.shim.module\$\$date_io\$date_fns.js
goog.provide("shadow.js.shim.module$$date_io$date_fns");
goog.provide("module$shadow_js_shim_module$$date_io$date_fns");
shadow.js.shim.module$$date_io$date_fns = require("@date-io/date-fns");
module$shadow_js_shim_module$$date_io$date_fns.default = shadow.js.shim.module$$date_io$date_fns;
#2020-05-2517:21thheller@danvingo it depends on the tool you use to fulfill the require("@date-io/date-fns");. it probably defaults to using the module entry whereas shadow-cljs and node default to using main#2020-05-2517:22thhellerits one of my favorite subjects ... commonjs<->esm interop ... its ugly ...#2020-05-2517:22thhellernothing shadow-cljs can do really since it doesn't process the require#2020-05-2517:23thhellerwhen it does (eg. :browser) I have some limited control which is why it defaults to main still since modules only really works if every package you use supports it#2020-05-2517:48dvingothanks for the feedback @thheller it's being processed as part of webpack so that would explain it#2020-05-2517:48dvingoi'm fine with the solution to just check which one is resolved#2020-05-2518:56mruzekwIs there a way to have :target :browser but be able to access NodeJS APIs like fs? My use case is the renderer process in an electron app#2020-05-2519:23mruzekwFound:
:js-options {:js-provider :require}
Will this still bundle things up? Do I need to bundle things up in an electron app? I'll research this, but if anyone knows, holler!
#2020-05-2519:34thhellerI don't know what the best practice for electron. :require will not bundle anything no.#2020-05-2519:36mruzekwOkay, good to know, thanks. My guess is it's still valuable for app updates#2020-05-2520:49mruzekw@thheller Would there be a way now or in the future to whitelist which imports to use with the runtime require vs. shadow-cljs? I feel like that would be the sweet spot for Electron#2020-05-2520:55thheller@mruzekw not sure what you mean?#2020-05-2520:55thhellerdo you have 2 builds or just one? been a while since I looked at electron stuff#2020-05-2521:00thhellerthere is :js-options {:keep-as-require #{"foo" "bar"}} which wouldn't bundle those if you mean that#2020-05-2521:03mruzekwYep!#2020-05-2521:03mruzekwSo if I just needed fs to be from the encompassing runtime, it would keep it as require#2020-05-2521:06thhelleryou can set :js-options {:keep-native-requires true}#2020-05-2521:06thhellerthat keeps all the node-builtins as require including fs#2020-05-2521:07mruzekwNice! That's all I would really need#2020-05-2521:07mruzekwI'll try that out now#2020-05-2521:09mruzekwWorks great! Thank you! Would be good to have that in the docs. I could help create an Electron section#2020-05-2521:10thhellerI haven't look at any electron stuff in a long long time so I don't feel qualified to write about it#2020-05-2521:10thhellerhttps://github.com/shadow-cljs/shadow-cljs.github.io happy about a PR though 😛#2020-05-2521:11mruzekwCool, I'll see what I can write up#2020-05-2605:29TuomasHey, I’m a relatively new clojurian. I got my own stuff working by adding
:compiler-options {:optimizations :simple}
but I also want to investigate further to learn more and mby help others. I have a fulcro app with shadow-cljs and I used Formidable’s Victory for a simple bar chart. I colored the bar fills with a function
(fn [data]
                                     (let [integer-value (.. data -datum -rpn)]
                                       (cond
                                         (> integer-value first-threshold)) "#c43a31"
                                         (> integer-value second-threshold) "#ffa500"
                                         :else "#00ff00")))
While I was developing the colouring worked, but after deploying a noticed it was all "#00ff00" . The bug seemed to appear randomly on my local environment, but eventually I noticed that it happens always after
shadow-cljs release main
And after changing code (and automatically compiling with simple) it started working. With simple optimizations I got it working after deploying too. Am I breaking some obvious rule, or is this something I should investigate more and try to fix?
#2020-05-2606:50thheller@koivistoinen.tuomas turn on :infer-externs :auto https://shadow-cljs.github.io/docs/UsersGuide.html#externs that will likely give you a warning about the (data -datum -rpn). so you ^js data whereever that is coming from and that should fix it.#2020-05-2607:39wilkerluciodoes :exclusions works on shadow? I'm trying to use a custom version of test.check that I built (on my group name), but because there is some dep trying to load the original test.check they are conflicting, I tried put :exclusions [org.clojure/test.check] in every dep a I have, but that didn't worked (I'm using :dependencies from shadow itself in this project), is there a way around it?#2020-05-2607:47thhellershould work? [some-dep "version" :exclusions [foo/bar]?#2020-05-2608:05thhelleroh wait. shadow-cljs itself has a dependency on test.check because of pathom#2020-05-2608:05thhellerso thats probably where it is coming from#2020-05-2608:05thhellerhttps://github.com/thheller/shadow-cljs/blob/1d6c44140d60a4fc15aace86138fa39e7dfd7f8a/project.clj#L63-L70#2020-05-2608:05thhellercan't remember the details. maybe thats not current anymore?#2020-05-2608:24wilkerluciohumm, pathom should not need that unless you are doing generative stuff with it#2020-05-2608:25wilkerluciomy case is a bit specific due to I need to use a custom version of test.check that I forked, and this project so far needs to use shadow, I could get shadow to use my version by releasing with a bigger version number, but now getting a lot of warnings due to duplication of namespaces on classpath#2020-05-2608:41thhellerthose should be gone with newer versions? it doesn't scan the classpath for cljs sources anymore?#2020-05-2608:48thheller@wilkerlucio just tested, pathom won't start without test.check on the classpath.#2020-05-2608:48wilkerluciook, I can check that, this shouldn't be required#2020-05-2608:48thhellerhttps://github.com/edn-query-language/eql/blob/master/src/edn_query_language/core.cljc#L4#2020-05-2608:49thhellerfails because of that#2020-05-2608:49wilkerluciook, updating it in a bit#2020-05-2608:50wilkerluciothanks for the precise pointing 🙂#2020-05-2609:11wilkerlucio@thheller eql 1.0.0 now has generative features on a different ns, pathom 2.3.0-alpha9 bumps EQL, that should fix it#2020-05-2609:15thhellerjust a thought but you could maybe move all the spec stuff into a separate ns. then people can add eqn-query-language.specs to :preloads if wanted. you can get rid of the goog-define that way. right now I doubt that most people are aware of the INCLUDE_SPECS define?#2020-05-2609:15thhellerits just dev-only stuff anyways#2020-05-2609:16wilkerluciomakes sense, I think I'll move on this direction next#2020-05-2609:17thhellerI also thought about making that a bit automatic in shadow-cljs. so you can set :include-specs true or so and it auto includes foo.bar-specs in development if foo.bar is part of the build#2020-05-2609:17thhellersince dev-only specs are hard to keep out of the main build otherwise currently#2020-05-2609:19wilkerluciothe main problem there I think is that its hard to know if a spec is intended for prod or not, because some are#2020-05-2609:20wilkerlucioin recent projects I've been using guardrails, with that I use the guardrails fn to define dev stuff, and spec directly for prod stuff, this way at least its a clean separation#2020-05-2609:20thhellerwell prod specs you'd just include normally#2020-05-2609:21wilkerlucioah, sorry, I think I understand now#2020-05-2609:21wilkerlucioabout a pattern to auto-require *-specs during dev#2020-05-2609:22thhelleryeah. like now pathom includes edn-query-language.core. with the flag shadow-cljs would detect edn-query-language.core-specs and also include that automatically in dev#2020-05-2609:23thhellergood thing about that way is that the specs can directly include the core ns and use it as a alias and easily do fdef for it#2020-05-2609:23thhellerif core would require core-specs that not easily possible because of the circular reference#2020-05-2609:24thhellerbut yeah guardrails is much more involved so that wouldn't work#2020-05-2609:24thhellerlast time I checked just including guardrails did leave some stuff after :advanced even if never used#2020-05-2609:25wilkerluciowas that a long time ago? I know tony made some changes to just inject validation code instead of rely on instrumentation, I wonder if that makes the difference on it#2020-05-2609:25thhellerI added https://github.com/day8/re-frame-debux#option-2-namespace-aliases-with-shadow-cljs as an alternative for things like that#2020-05-2609:26thhellerso you can actually ensure that nothing is left#2020-05-2609:26wilkerlucionice#2020-05-2609:26thhellerits been a while yes#2020-05-2609:26wilkerluciobut maybe that wouldn't work for guardrails, given I still need guardrails in prod to generate the standard fns#2020-05-2609:26thhelleryeah, your alias ns would do exactly that#2020-05-2609:27wilkerlucioah, ok, not a transparent stub thing, cool#2020-05-2609:27thhellerthe tracing stuff does that too. without the alias it adds the tracing code. with the alias it just does a regular defn#2020-05-2609:27wilkerluciowhat tracing stuff?#2020-05-2609:28thhellerre-frame example from above#2020-05-2609:28thhellerhttps://github.com/day8/re-frame-debux/blob/master/src/day8/re_frame/tracing_stubs.cljc#2020-05-2609:29thhellerthe issue why we need this is that even if you have a macro that does nothing#2020-05-2609:29thhelleryou cannot get rid of the ns requires the namespace providing the macros has#2020-05-2609:29thhellerhttps://github.com/day8/re-frame-debux/blob/master/src/day8/re_frame/tracing.cljc#L1-L11#2020-05-2609:29thhellerand those may do stuff that don't play well with :advanced#2020-05-2613:30djanushey, is there a way to tell shadow-cljs to not generate a huge index.js for debug builds, instead going for document.write('<script...>') like vanilla cljs tooling?#2020-05-2613:31djanuscase in point: I have a react-native app and RN insists on reloading the whole thing every time I change something, even though RN's fast refresh is turned on#2020-05-2615:35thheller@dj942 for :browser there is an option to emit multiple files. for react-native there is not.#2020-05-2615:35thhellerlast time I checked there were 2 options for turning of reload in RN. with both off it would only check the generated shadow-cljs output when loading the app but never while its running#2020-05-2615:37djanusI don't event mind longish reloads all that much, but I'd prefer not to lose app state every time a reload happens#2020-05-2615:37thhellersounds to me like you are letting react-native reload stuff#2020-05-2615:38thhellershadow-cljs reload would keep your state#2020-05-2615:38djanusyeah, that's correct
#2020-05-2615:38djanusI guess I need to read up metro bundler's documentation on how to disable reload#2020-05-2615:39thhellerI never configured anything in metro#2020-05-2615:39thhellerjust the debug menu thing in the app itself#2020-05-2615:39thhellerfast refresh and live-reload or whatever the other one is called#2020-05-2615:39thhellerthere are two options#2020-05-2615:43djanuslooks like there's only one in react-native 0.62, "disable fast refresh"#2020-05-2615:45thhellerno clue, last time I checked there were 2 options#2020-05-2615:45thhellercan't remember which version that was though#2020-05-2615:45djanusit works! although it doesn't trigger a rerender after reload#2020-05-2615:45djanusI guess there's a callback somewhere#2020-05-2615:45thhellerthat part is up to you, the demo repo I created has an example of how you can set that up#2020-05-2615:46djanusglorious#2020-05-2615:46djanushuge thanks#2020-05-2615:55Derek2.9.9 looks to have introduced a regression with regard to deps.cljs and a package.json file
IllegalArgumentException: No matching field found: exist for class .File
        clojure.lang.Reflector.getInstanceField (Reflector.java:397)
        clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
        shadow.cljs.devtools.server.npm-deps/install-deps (npm_deps.clj:160)
        shadow.cljs.devtools.server.npm-deps/install-deps (npm_deps.clj:131)
        shadow.cljs.devtools.server.npm-deps/main (npm_deps.clj:242)
        shadow.cljs.devtools.server.npm-deps/main (npm_deps.clj:228)
        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:141)
        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
        clojure.core/apply (core.clj:669)
        clojure.core/apply (core.clj:660)
        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:665)
        clojure.core/apply (core.clj:660)
        shadow.cljs.devtools.cli/-main (cli.clj:75)
        shadow.cljs.devtools.cli/-main (cli.clj:67)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:665)
        clojure.main/main-opt (main.clj:514)
        clojure.main/main-opt (main.clj:510)
        clojure.main/main (main.clj:664)
        clojure.main/main (main.clj:616)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.main.main (main.java:40)
#2020-05-2615:55DerekDropping back to 2.9.8 and it works#2020-05-2615:58thhellerwhoops.#2020-05-2615:59Derekexist vs exists?#2020-05-2616:03thhelleryeah, fixed in 2.9.10#2020-05-2616:03DerekThanks#2020-05-2619:12Pavel KlavíkHi, I am trying to build a small HTTP server in NodeJS. I am trying to use macchiato, but after requiring the dependency [macchiato.server :as http], I get the following error on startup:
SHADOW import error C:\Shared\orgpad\.shadow-cljs\builds\preview\dev\out\cljs-runtime\shadow.js.shim.module$xregexp.js
Error: Cannot find module 'xregexp'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at C:\Shared\orgpad\.shadow-cljs\builds\preview\dev\out\cljs-runtime\shadow.js.shim.module$xregexp.js:3:33
    at global.SHADOW_IMPORT (C:\Shared\orgpad\preview\preview.js:64:44)
    at C:\Shared\orgpad\preview\preview.js:2329:1
    at Object.<anonymous> (C:\Shared\orgpad\preview\preview.js:2342:3)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
#2020-05-2619:31thhellerthats the node message for a missing npm install xregexp?#2020-05-2620:41Pavel Klavíkcool, it works, thx#2020-05-2620:41Pavel Klavíkwhat is the approach for hot code reloading? stopping the server and starting it again?#2020-05-2621:04lilactownif you var-quote your routes, it will dynamically look up the function each invocation#2020-05-2621:04lilactownfrom their docs:
(def routes
  ["/" {""        {:get #'home}
        "message" {:post #'message}}])
#2020-05-2621:50thhellermeh vars in CLJS, maybe #(home %) might be better? assuming it just gets one arg 😉#2020-05-2622:40Pavel KlavíkIt seems to work sufficiently well for the small size of the server 🙂#2020-05-2620:46thhellerno clue. I've never used macchiato#2020-05-2622:13cjsauerIs is possible to run shadow-cljs watch on a build without injecting nREPL related things into the output? I’m using the :node-script target and have a coworker who doesn’t use a REPL (I know, I’ve tried to convince him), but would still like to have the auto-compile functionality of the watch whenever the file is changed.#2020-05-2622:14dpsutton> The nREPL server can be disabled by setting :nrepl false#2020-05-2622:15dpsuttonwait, what do you mean injecting nrepl?#2020-05-2622:18thheller@cjsauer there are no nrepl related things injected into the JS output, it just connects the websocket which handles hot-reload and also the REPL#2020-05-2622:19thhellerso its all the same websocket anyways, nothing to turn off#2020-05-2622:19cjsauerAh ok. That is what prevents the development node script from exiting yea? In a normal workflow, I’d run node my_script.js and then connect my REPL. In his case tho, he’d like to run the script manually upon every change, and have it exit normally.#2020-05-2622:20thhelleryou can set :devtools {:enabled false} in the build. then it won't connect and just exit#2020-05-2622:20cjsauerCool, that’s what I’m after 👍#2020-05-2622:23thhellergeneral question I guess: I'm thinking about allowing a shadow-cljs.local.edn or so which could override shadow-cljs.edn config stuff#2020-05-2622:24thhellerseems like quite often people have different preferences when working in teams, so that way each user could have their own local config#2020-05-2622:24thhellerI really dislike using env vars to stuff like that#2020-05-2622:25cjsauerI’m having exactly this conversation with my coworker at the moment (he just asked me how to read env vars in shadow-cljs.edn). A local config file would be great for things like this.#2020-05-2622:25thhellerlike you could keep devtools while your coworker can disable it 😛#2020-05-2622:25thhellershadow-cljs watch the-script --config-merge "{:devtools {:enabled false}}" also works though#2020-05-2622:26cjsauerOoh that’s nice, didn’t know that. I was considering having two builds: :script-calvin and :script-eric haha#2020-05-2622:26thhellerhehe that also works 😛#2020-05-2622:28cjsauerI appreciate your help and hard work @thheller. Thanks for the guidance.#2020-05-2704:30awb99I have a really weird issue with a npm dependency vega-embed. I have defined it in https://github.com/pink-gorilla/gorilla-ui and now https://github.com/pink-gorilla/shiny-clj uses gorilla-ui. In gorilla-ui I have defined deps.cljs When I compile cljs with shadow-cljs in shiny-clj it wants additional npm dependencies (buffer and process). This dependencies are not needed in gorilla-ui. And I think they are only needed when compiling for target :node and not for target :browser.#2020-05-2705:31awb99base) [/cdn-cgi/l/email-protection shiny-clj]$ lein shadow-compile [:web] Compiling ... The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js". Search in: /home/andreas/Documents/gorilla/shiny-clj/node_modules You probably need to run: npm install buffer#2020-05-2705:31awb99the even crazier thing is this:#2020-05-2705:31awb99cat node_modules/vega-loader/build/vega-loader.js | grep buffer#2020-05-2705:32awb99there is no buffer in this file#2020-05-2707:36Adam HelinsIs there a way for testing an advanced compiled build? shadow-cljs release $test-build fails#2020-05-2708:10thheller@adam678 fails how? you just run shadow-cljs release for the build and then run the tests normally?#2020-05-2708:10thheller@hoertlehner you need to have shadow-cljs installed in your project. both buffer and process are polyfills packages that shadow-cljs will provide ...#2020-05-2708:55awb99thanks @thheller#2020-05-2708:58awb99I have [thheller/shadow-cljs] [thheller/shadow-cljsjs "0.0.21"]#2020-05-2708:58awb99and compile cljs with#2020-05-2708:58awb99["with-profile" "+cljs" "run" "-m" "shadow.cljs.devtools.cli" "compile" ":web"]#2020-05-2708:59thhellerhmm? I mean the npm shadow-cljs package?#2020-05-2709:00thhellerjust npm install shadow-cljs in the project?#2020-05-2709:03awb99ahhh#2020-05-2709:07awb99super! this fixed it!#2020-05-2709:08awb99will the npm dependency bring th full compiler of shadow? or des it only bting this fixes?#2020-05-2709:08awb99I am a little lost on undestanding what is going on behind the scenes...#2020-05-2709:14thhellerthe npm package is mostly the for CLI stuff but also brings in some extra npm packages#2020-05-2709:15thhellerthe compiler is from the CLJ dependency you have in project.clj.#2020-05-2709:18thhellerthe npm stuff never does any actual compilation, just runs the java process#2020-05-2710:02awb99thanks for the explaination!!!#2020-05-2708:11Adam Helins@thheller I get:
--- cljs_test_display/core.cljs:411
illegal initialization of @define variable cljs_test_display.core.root_node_id
#2020-05-2708:25thhellerhmm is this :browser-test?#2020-05-2708:58thhellerhmm yeah I can reproduce that. cljs-test-display does a no-no for :advanced#2020-05-2708:58thhellerhttps://github.com/bhauman/cljs-test-display/blob/be674b314530ac9ed3c4a160d3d3f17eec72f304/src/cljs_test_display/core.cljs#L411#2020-05-2708:58thhellernot allowed to set! goog-define constants#2020-05-2709:01Adam HelinsYes, :browser-test indeed. So I was not doing anything wrong. I am surprised no one has noticed this before, testing advanced builds is pretty useful.#2020-05-2709:04thhelleryeah indeed#2020-05-2709:06thhelleryou can open an issue on the cljs-test-display repo. should be an easy fix. I can do that later too#2020-05-2709:09thhellerI have a custom test runner in my backlog too though. want something with a little more control over what it does on hot-reload so it doesn't always run all the tests#2020-05-2709:09thhellerdunno when I get to that though#2020-05-2709:30Adam HelinsIf it is an easy fix then I'll preferably someone else do it (well, you it seems 😄 ) since I have 0 knowledge about the codebase#2020-05-2805:20plexusWould you consider trying out chui? It works under advanced and should be a richer UI experience than cljs-test-display https://github.com/lambdaisland/chui#2020-05-2805:48dpsuttoni'm getting the following error trying to cider-jack-in to this project: > Error building classpath. Manifest type not detected when finding deps for metosin/pohjavirta in coordinate #:local{:root "/System/Volumes/Data/home/arne/github/pohjavirta"}#2020-05-2805:49dpsuttonah, this is in chui-remote's deps. need to clone and compile the java classes for that?#2020-05-2807:30plexushmmm right, you don't need chui-remote, and chui-remote no longer needs pohjavirta. Let me clean that up#2020-05-2807:33plexusthanks for trying it out!#2020-05-2807:33plexuscould you try a164d8ba32f48a632a3f285f41a52f93d7bd024d ? thanks!#2020-05-2807:34plexusissues/questions can go to #lambdaisland#2020-05-2809:31Adam HelinsThanks Arne, this is perfect! I've already caught a nasty bug (r/w big ints with DataViews without type hinting)#2020-05-2809:36plexusnice!#2020-05-2709:38thhellerok, I'll check it out later.#2020-05-2709:42Adam HelinsIf it turns out to be more involving, I can try to dive in the codebase and help, let me know. I opened an issue anyway https://github.com/bhauman/cljs-test-display/issues/7#2020-05-2709:44thhellerhttps://github.com/bhauman/cljs-test-display/issues/8#2020-05-2709:44Adam HelinsRight!#2020-05-2709:44thhelleroops#2020-05-2709:46Adam HelinsI'll close mine 😉#2020-05-2709:49thhellerhehe doh. almost hit close on mine 😛#2020-05-2709:49Adam Helins(by the way, thanks for shadow-cljs, I have been using more and more lately after a sabbatical from CLJS, and I keep being impressed with how drastically it simplifies the workflow 🚀)#2020-05-2713:37bhaumanman I never thought about folks testing under advanced 🙂#2020-05-2719:03Adam HelinsWell, you never know. I admit I became a bit paranoid regarding :advanced#2020-05-2713:49thhellerhehe yeah not many people do that with :browser-test I guess. first time this has come up. 🙂#2020-05-2713:54bhaumandevcards 0.2.7 realeased and should no longer depend on a global js/React#2020-05-2713:54bhaumanbut don’t use it in advanced mode 😉#2020-05-2714:17Pavel KlavíkHi, I am trying to get puppeteer running with Shadow-cljs, by adapting this: https://gist.github.com/apeckham/ec1725b22642d9344e294c701de18fb2#file-puppeteer-cljs, so I got this code:#2020-05-2714:17Pavel Klavík
(-> (puppeteer/launch)
        (.then (fn [browser]
                 (-> (.newPage browser)
                     (.then (fn [page]
                              (.goto page url #js{:waitUntil "networkidle2"})
                              (.screenshot page #js {:path "screenshot.png"})
                              (.close page)))))))
#2020-05-2714:17Pavel Klavíkand I am getting these error warnings:
(node:5068) ExperimentalWarning: The fs.promises API is experimental
(node:5068) UnhandledPromiseRejectionWarning: Error: Could not find browser revision 756035. Run "npm install" or "yarn install" to download a browser binary.
    at ChromeLauncher.launch (C:\Shared\orgpad\node_modules\puppeteer\lib\Launcher.js:59:23)
(node:5068) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5068) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#2020-05-2714:18Pavel KlavíkWhat is the Clojurescript idiomatic way of rewritting this:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('', {waitUntil: 'networkidle2'});
  await page.pdf({path: 'hn.pdf', format: 'A4'});

  await browser.close();
})();
#2020-05-2714:54lilactown@pavel.klavik have you address the errors that you pasted at all?#2020-05-2714:54lilactownit seems to be pretty clear in how to fix them#2020-05-2715:01Pavel Klavíkya, I noticed the error there, got it working#2020-05-2715:01Pavel Klavíkthought at first that I am using promises in wrong way.#2020-05-2715:02Pavel Klavíkbut I am still interested in idiomatic way of writing this in ClojureScript? core.async?#2020-05-2715:03lilactownno, similar to the way you wrote it#2020-05-2715:03lilactownbut you can flatten it#2020-05-2715:06Pavel KlavíkI got this in the end while loading the browser in a different thread:
(-> (.newPage @browser/browser)
        (.then (fn [page]
                 (log/info "Openning page" url "...")
                 (-> (.goto page url #js{:waitUntil "networkidle2"})
                     (.then #(.screenshot page #js {:path "screenshot.png"}))
                     (.then #(do (log/info "Screenshot of " id "with token" token "generated.")
                               (.close page)))))))
How would you do flattening?
#2020-05-2715:06lilactownpromise .then always returns another promise#2020-05-2715:06lilactownyou don’t need to nest inside of the function you pass to .then#2020-05-2715:08lilactown
(-> (puppeteer/launch)
    (.then (fn [browser]
             (.newPage browser)))
    (.then (fn [page]
             (.goto page url #js{:waitUntil "networkidle2"})
             page))
    (.then (fn [page]
             (.screenshot page #js {:path "screenshot.png"})
             page))
    (.then (fn [page]
             (.close page))))
#2020-05-2715:08Pavel KlavíkI see, that looks better.#2020-05-2715:08Pavel Klavíkthx#2020-05-2717:37Alex PorterHi, working on setting up shadow-cljs for our project, and I'm getting the following error when I attempt to generate the shadow build report. Everything else is working fine in terms of creating my release build. Any ideas? #2020-05-2717:41Alex PorterI'm not sure if this is affecting anything, but we have a shared project used between our different cljs apps in a monorepo, and so we're adding the source-path from here like ../shared/src/client and then getting a lot of these warnings as well
[2020-05-27 12:32:24.902 - INFO] filename violation for ns shcl.core.c.dropzone, got: client/shcl/core/c/dropzone.cljs expected: shcl/core/c/dropzone.cljs (or .cljc)
These didn't seem to affect anything with the release build though.
#2020-05-2718:31thhellerjust a guess but do you also have ../shared/src as a classpath/source-path?#2020-05-2718:38Alex PorterNo, just these
"src/server"
"src/client"
"src/shared"
"../shared/src/app"
"../shared/src/server"
"../shared/src/client"
"../shared/src/shared"
#2020-05-2718:39Alex PorterWe use the same ns convention / folder structure inside src/client and it doesn't have any issues with that.#2020-05-2718:49thhelleryeah but somehow client/shcl/core/c/dropzone.cljs exists on the classpath. try ( "client/shcl/core/c/dropzone.cljs") from a clojure REPL. shadow-cljs clj-repl or so#2020-05-2718:49thhellersee what the full path for that is#2020-05-2719:01Alex Porter
#object[.URL 0x5a069486 "jar:file:/Users/alex.porter/.m2/repository/fullcontact/redboat.shared/latest/redboat.shared-latest.jar!/client/shcl/core/c/dropzone.cljs"]
#2020-05-2719:02thhellerok so that jar seems to contain a file that is maybe shouldn't contain? 😛#2020-05-2719:04Alex Porterok, yeah, I'll get that figured out#2020-05-2719:04Alex PorterThinking this is maybe the cause of the build report issue as well?#2020-05-2719:13thhellerI doubt it. the error is deep in the closure compiler code so I'm not exactly sure what it means#2020-05-2719:14thhellerit has something to do with source maps which are required for the build report#2020-05-2719:15thhellerbut I never had that error before so I'm not exactly sure what the problem is#2020-05-2719:15Alex Porterok, no worries. Thanks for the help.#2020-05-2717:37Alex Porter
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:112)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:67)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:128)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
	shadow.cljs.devtools.cli/main (cli.clj:179)
	shadow.cljs.devtools.cli/main (cli.clj:134)
	clojure.core/apply (core.clj:669)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/-main (cli.clj:221)
	shadow.cljs.devtools.cli/-main (cli.clj:219)
	clojure.lang.Var.invoke (Var.java:399)
	user/eval152 (form-init209812503692384868.clj:1)
	user/eval152 (form-init209812503692384868.clj:1)
	clojure.lang.Compiler.eval (Compiler.java:7177)
	clojure.lang.Compiler.eval (Compiler.java:7167)
	clojure.lang.Compiler.load (Compiler.java:7636)
	clojure.lang.Compiler.loadFile (Compiler.java:7574)
	clojure.main/load-script (main.clj:475)
	clojure.main/init-opt (main.clj:477)
	clojure.main/init-opt (main.clj:477)
	clojure.main/initialize (main.clj:508)
	clojure.main/null-opt (main.clj:542)
	clojure.main/null-opt (main.clj:539)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
Caused by:
NullPointerException:
	com.google.debugging.sourcemap.SourceMapObjectParser.parse (SourceMapObjectParser.java:44)
	com.google.debugging.sourcemap.SourceMapConsumerV3.parse (SourceMapConsumerV3.java:68)
	com.google.javascript.jscomp.SourceMapInput.getSourceMap (SourceMapInput.java:58)
	com.google.javascript.jscomp.Compiler.addSourceMapSourceFiles (Compiler.java:2828)
	com.google.javascript.jscomp.Compiler.initBasedOnOptions (Compiler.java:553)
	com.google.javascript.jscomp.Compiler.initModules (Compiler.java:533)
	com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:729)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/compile-js-modules (closure.clj:1008)
	shadow.build.closure/compile-js-modules (closure.clj:997)
	shadow.build.closure/optimize/fn--3682 (closure.clj:1195)
	shadow.build.closure/optimize (closure.clj:1181)
	shadow.build.closure/optimize (closure.clj:1172)
	shadow.build.api/optimize (api.clj:267)
	shadow.build.api/optimize (api.clj:261)
	shadow.build/optimize (build.clj:419)
	shadow.build/optimize (build.clj:411)
	shadow.cljs.build-report/generate/body-fn--8571--auto----9378 (build_report.clj:219)
	shadow.cljs.build-report/generate (build_report.clj:195)
	shadow.cljs.build-report/generate (build_report.clj:190)
	shadow.cljs.build-report/-main (build_report.clj:261)
	shadow.cljs.build-report/-main (build_report.clj:260)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/do-clj-run/body-fn--8571--auto----9150 (cli.clj:110)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:109)
	shadow.cljs.devtools.cli/do-clj-run (cli.clj:67)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:128)
	shadow.cljs.devtools.cli/blocking-action (cli.clj:118)
	shadow.cljs.devtools.cli/main (cli.clj:179)
	shadow.cljs.devtools.cli/main (cli.clj:134)
	clojure.core/apply (core.clj:669)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/-main (cli.clj:221)
	shadow.cljs.devtools.cli/-main (cli.clj:219)
	clojure.lang.Var.invoke (Var.java:399)
	user/eval152 (form-init209812503692384868.clj:1)
	user/eval152 (form-init209812503692384868.clj:1)
	clojure.lang.Compiler.eval (Compiler.java:7177)
	clojure.lang.Compiler.eval (Compiler.java:7167)
	clojure.lang.Compiler.load (Compiler.java:7636)
	clojure.lang.Compiler.loadFile (Compiler.java:7574)
	clojure.main/load-script (main.clj:475)
	clojure.main/init-opt (main.clj:477)
	clojure.main/init-opt (main.clj:477)
	clojure.main/initialize (main.clj:508)
	clojure.main/null-opt (main.clj:542)
	clojure.main/null-opt (main.clj:539)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
#2020-05-2718:32thheller@ajporter2011 is this for a :browser build? build-report currently has issues with other targets?#2020-05-2718:36Alex PorterHere's my :shadow-cljs config in my project.clj
{:nrepl  {:port 8777}
                :builds {:app {:target     :browser
                               :output-dir "resources/public/js/compiled"
                               :asset-path "/js/compiled"
                               :modules    {:app {:init-fn  plcl.main/init
                                                  :preloads [devtools.preload
                                                             day8.re-frame-10x.preload]}}
                               :dev        {:compiler-options {:closure-defines
                                                               {goog.DEBUG                           true
                                                                re-frame.trace.trace-enabled?        true
                                                                day8.re-frame.tracing.trace-enabled? true}}}
                               :release    {:compiler-options
                                            {:infer-externs :auto
                                             :optimizations :advanced}
                                            :build-options
                                            {:ns-aliases
                                             {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
                               :devtools   {:http-root "resources/public"
                                            :http-port 9222}}}}
#2020-05-2718:48thhellerlooks fine. this only fails for the build report or does release also fail?#2020-05-2718:48Alex PorterOnly the build report#2020-05-2718:50thhellerhmm not sure#2020-05-2718:34Alex PorterIt is#2020-05-2719:23JohnsonHey all, wondering if someone has some advice. I want to pass an api key as a command line argument. I understand that you can use --config-merge to pass command line arguments to the shadow-cljs.edn file. My question is, how do I then use that argument in my application? Thanks in advance for your help#2020-05-2719:26thhellerwhat is your application? browser/node-script?#2020-05-2719:27JohnsonAt the moment it’s browser#2020-05-2719:27thhellerthen don't make it part of the build at all. this is runtime configuration. I really need to write the blog post about this ... 😛#2020-05-2719:27thhellerbasically set it via HTML#2020-05-2719:27thheller<script>_API_KEY = "foo";</script> or so#2020-05-2719:28thhellerthen load it in your code :init-fn via js/MY_API_KEY#2020-05-2719:28thhelleror add it into your <body data-api-key="foo"> and load it from there#2020-05-2719:28thhellerlots of options#2020-05-2719:29thhellermaking it part of the build would be my last choice but you can do it if you want#2020-05-2719:29thhellerlook at the docs for closure-defines and set that via --config-merge#2020-05-2719:33JohnsonAh okay, thanks for explaining the options 🙂 I was hoping to pass the api key to a docker container at runtime, using a secret in my CI pipeline, rather than having stored in the html file. Do you tend to inject it into the html file? echo >> … etc?#2020-05-2719:35thhelleranything that makes it to the client is NOT a secret#2020-05-2719:36thhellerI typically have a server that generates my HTML but if you just have a static file you can use a placeholder and replace that via some command line tool#2020-05-2719:36thhellersed or so#2020-05-2719:42JohnsonYeah, I get your point about it not being a secret when it gets to the client, I’ll have at node target as well and consider options. Thanks for your time and pointing me in the right direction 🙂 I listened to the podcast you were on with @jacek.schae, it’s an excellent tool you’ve built!#2020-05-2720:26thhellerthanks 🙂#2020-05-2721:32mruzekwIf I was using shadow-cljs for a fulcro project, and I'd like to use a local version of fulcro (to change and test some fulcro code), how would I do that? Thanks!#2020-05-2721:38thhellereasiest way is probably via deps.edn#2020-05-2721:43mruzekwOkay, yes, I'm only using :dependencies now#2020-05-2721:44mruzekwWould you do something like?
{:deps
 {time-lib {:local/root "/path/to/time-lib"}}}
#2020-05-2721:44mruzekw(with fulcro of course)#2020-05-2721:45mruzekwOr maybe with an alias?#2020-05-2721:57thhellermove all your dependencies to deps.edn and configure shadow-cljs to use it. see the user-guide#2020-05-2722:01mruzekwKk, thanks#2020-05-2804:36rbergerI’m trying to use the npm library video.js The JS docs for video.js (https://docs.videojs.com/tutorial-react.html) for use in react says:
import videojs from 'video.js'
and use it like this:
this.player = videojs(this.videoNode, this.props ...)
I do a require in my cljs file:
(:require
   ["video.js" :as vjs])
and I’ve tried
(:require
   ["video.js" :default videojs])
But in the first case vjs/videojs is undefined as is videojs in the second case. Am I doing something stupid, or is something amiss like having the . in the package name is screwing things up?
#2020-05-2805:21rbergerI just tried putting the actual js file video.js into my work directory and require it as ["./video.js" :as vjs] and ["./video.js" :default videojs] and its behaving the same so I don’t think it’s because of the period. Its something with video.js is setup? They use videojs both as the. top namespace and as the function that effectively instantiates the instance. I don’t know it that is particularly weird for JS or not… They mention it in their docs on videojs : > The `videojs()` function doubles as the main function for users to create a https://docs.videojs.com/Player.html instance as well as the main library namespace. - https://docs.videojs.com/module-videojs-videojs.html#2020-05-2805:39rbergerHmm, if I put <script src=""></script> in my index.html and remove the requires for video.js and refer to it as js/videojs it works….#2020-05-2806:45thheller@rberger it probably is (:require ["video.js" :as videojs]) and videojs directly, not the vjs/videojs alias you tried before.#2020-05-2806:58rberger@thheller That seems to have been it. Now I just. have to figure out how to actually use this thing. Its showing up in my dom as a video element but not playing my streams. But this isn’t a shadow-cljs problem! Thanks again!#2020-05-2807:00rbergerBy the way, this really tweaks my mental model of :require and :as I always had assumed the :as value was an arbitrary label/symbol…#2020-05-2807:02thhelleryeah its weird but string requires are the exception to the rule of :as being just an alias for alias/foo#2020-05-2808:55Diogo VasconcelosHi. I am getting the following error when I try to compile any shadow-cljs target from my project. It used to work, but now it errors and I am not sure what changed. Maybe you can help me out figuring out what is wrong:
shadow-cljs - starting via "clojure"
[:dev] Compiling ...
Execution error (AssertionError) at shadow.build.data/add-source (data.clj:214).
Assert failed: (rc/valid-resource? rc)

Full report at:
/tmp/clojure-1306074555799542362.edn
#2020-05-2808:57Diogo Vasconcelosfullreport: https://pastebin.com/UG0FVQrp#2020-05-2808:57Diogo Vasconcelosthanks in advance 🙂#2020-05-2808:58thhellerhmm not sure. which version is this? in deps.edn?#2020-05-2809:04Diogo Vasconcelosof shadow-cljs? 2.9.10#2020-05-2809:04Diogo Vasconcelos(I was on 2.8.83 and got the same error, updated, got a nicer error message 🙂 but still the same issue)#2020-05-2809:07thhelleryeah I'll definitely improve that error message. the assert is useless 😛#2020-05-2809:09thhellerI don't have any specific idea why this would fail.#2020-05-2809:09thhellertry running shadow-cljs clj-repl and then#2020-05-2809:09thheller
(in-ns 'shadow.build.data)
(defn add-source [state {:keys [resource-id resource-name] :as rc}]
  (when-not (rc/valid-resource? rc)
    (throw (ex-info "invalid resource" {:rc rc})))

  (-> state
      (update :sources assoc resource-id rc)
      (add-provides rc)
      (cond->
        resource-name
        (update :name->id assoc resource-name resource-id)
        )))
#2020-05-2809:10thhellerthen (shadow.cljs.devtools.api/compile :dev)#2020-05-2809:32Diogo Vasconcelos
shadow.build.data=> (shadow.cljs.devtools.api/compile :dev)
[:dev] Compiling ...
invalid resource
{:rc {:cache-key ["5b0a111dc988bc0136ede52338f0c7cd98f61a45"], :ns-info {:rename-macros nil, :renames {}, :meta {:file "repl.cljs", :line 1, :column 5, :end-line 1, :end-column 9}, :use-macros nil, :excludes #{}, :name repl, :imports nil, :requires {cljs-bean.core cljs-bean.core, cljs.pprint cljs.pprint, pprint cljs.pprint, promesa.core promesa.core, p promesa.core, cljs.core cljs.core, goog goog}, :seen #{:require}, :uses {->clj cljs-bean.core}, :require-macros {cljs.core cljs.core}, :cljc false, :flags {:require #{}}, :js-deps {}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}, :ns repl, :output-name "repl.js", :file #object[java.io.File 0x32a1aabf "/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :resource-id [:shadow.build.classpath/resource "repl.cljs"], :resource-name "repl.cljs", :type :cljs, :last-modified -3600000, :requires #{cljs-bean.core promesa.core cljs.core goog cljs.pprint}, :macro-requires #{cljs.core}, :url #object[java.net.URL 0x6b7f46f6 "file:/home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs"], :provides #{repl}, :deps [goog cljs.core cljs-bean.core cljs.pprint promesa.core]}}
ExceptionInfo: invalid resource
	shadow.build.data/add-source (NO_SOURCE_FILE:14)
	shadow.build.data/add-source (NO_SOURCE_FILE:12)
	shadow.build.data/maybe-add-source (data.clj:267)
	shadow.build.data/maybe-add-source (data.clj:259)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:550)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:510)
	shadow.build.resolve/resolve-require (resolve.clj:561)
	shadow.build.resolve/resolve-require (resolve.clj:557)
	shadow.build.resolve/resolve-entry (resolve.clj:571)
	shadow.build.resolve/resolve-entry (resolve.clj:570)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-entries (resolve.clj:582)
	shadow.build.resolve/resolve-entries (resolve.clj:573)
	shadow.build.modules/resolve-module/fn--14145 (modules.clj:265)
	shadow.build.modules/resolve-module (modules.clj:261)
	shadow.build.modules/resolve-module (modules.clj:251)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.build.modules/resolve-modules (modules.clj:271)
	shadow.build.modules/resolve-modules (modules.clj:270)
	shadow.build.modules/analyze (modules.clj:325)
	shadow.build.modules/analyze (modules.clj:316)
	shadow.build/resolve (build.clj:395)
	shadow.build/resolve (build.clj:389)
	shadow.build/compile (build.clj:403)
	shadow.build/compile (build.clj:397)
	shadow.cljs.devtools.api/compile* (api.clj:315)
	shadow.cljs.devtools.api/compile* (api.clj:311)
	shadow.cljs.devtools.api/compile!/body-fn--17311--auto----17398 (api.clj:324)
	shadow.cljs.devtools.api/compile! (api.clj:322)
	shadow.cljs.devtools.api/compile! (api.clj:319)
	shadow.cljs.devtools.api/compile (api.clj:331)
	shadow.cljs.devtools.api/compile (api.clj:326)
	shadow.cljs.devtools.api/compile (api.clj:328)
	shadow.cljs.devtools.api/compile (api.clj:326)
	shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
	shadow.build.data/eval38637 (NO_SOURCE_FILE:22)
	clojure.lang.Compiler.eval (Compiler.java:7177)
	clojure.lang.Compiler.eval (Compiler.java:7132)
	clojure.core/eval (core.clj:3214)
	clojure.core/eval (core.clj:3210)
	shadow.cljs.devtools.server.socket-repl/repl/fn--17818 (socket_repl.clj:63)
	clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
	clojure.main/repl/read-eval-print--9086 (main.clj:437)
	clojure.main/repl/fn--9095 (main.clj:458)
	clojure.main/repl (main.clj:458)
	clojure.main/repl (main.clj:368)
	shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:30)
	shadow.cljs.devtools.server.socket-repl/repl (socket_repl.clj:28)
	shadow.cljs.devtools.server/from-cli (server.clj:678)
	shadow.cljs.devtools.server/from-cli (server.clj:589)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23)
	shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20)
	shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129)
	shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:669)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:665)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)

-3600000 - failed: nat-int? in: [:last-modified] at: [:last-modified] spec: :shadow.build.resource/last-modified
:error
#2020-05-2809:33Diogo Vasconcelosthanks for looking into this so quickly btw 🙂#2020-05-2809:40thhellercan you check stat /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs or so?#2020-05-2809:41thhellerI have no idea how it gets a negative timestamp?#2020-05-2809:42Diogo Vasconcelosyeah, something is screwed with the modify date on that file:
File: /home/diogovasconcelos/git-projects/core-banking-repos/core-banking-platform/service/banking-errands/dev/repl.cljs
  Size: 596       	Blocks: 8          IO Block: 4096   regular file
Device: fd01h/64769d	Inode: 9570063     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/diogovasconcelos)   Gid: ( 1001/diogovasconcelos)
Access: 2020-05-28 10:43:16.172569415 +0200
Modify: 1970-01-01 00:00:00.000000000 +0100
Change: 2020-05-20 14:58:43.953551480 +0200
 Birth: 2020-02-21 10:50:27.964589751 +0100
#2020-05-2809:42thhellerModify: 1970-01-01 00:00:00.000000000 +0100?#2020-05-2809:42thhelleris this running in a container or so?#2020-05-2809:42thhellermaybe just try to touch the file to get an updated timestamp?#2020-05-2809:44Diogo Vasconcelosand I updated it and now the dates are correct. It still fails. I am going to check if other files got this problem and let you know#2020-05-2809:49Diogo Vasconcelosyeah. all the files had the dates screwed (and I think you are right, I did mess with docker and mounting this folder). It works now (I re-cloned the repo)#2020-05-2809:49Diogo Vasconcelosthanks a lot!!!#2020-05-2809:49Diogo Vasconcelossorry for the trouble#2020-05-2809:39thhellerthats weird. how does a file get a negative last-modified timestamp?#2020-05-2809:39thheller:last-modified -3600000#2020-05-2809:39thhellerI didn't even know that was possible 😛#2020-05-2811:35Ian FernandezHello guys, How can I use the "shadow.user" ns that emacs initiates using npx shadow-cljs but starting from cider?#2020-05-2811:37Ian FernandezI'm having some trouble using cider to start a repl and simply using: (ns user (:require [shadow.cljs.devtools.api :as shadow.api] [shadow.cljs.devtools.server :as shadow.server])) (defn -main {:shadow/requires-server true} [& _] (shadow.server/start!) (shadow.api/watch :my-project))#2020-05-2811:37Ian Fernandezwhen I use, (shadow.api/rep :my-project)#2020-05-2811:38Ian FernandezI don't have a repl on cider's repl, I have a repl on stdin on emacs#2020-05-2811:49thheller@d.ian.b if you get a stdin REPL you are not connecting to the shadow-cljs nrepl server#2020-05-2811:49Ian Fernandezyeah, there's a way to start to shadow-cljs nrepl from clj with cider?#2020-05-2811:50thhellerI don't know enough about cider to answer that#2020-05-2811:50thhellerbut if you connect to the nrepl provided by it you can just configure the shadow-cljs middleware#2020-05-2811:51thhellerthen the repl should also just work#2020-05-2811:51thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2020-05-2811:52Ian Fernandezthere's a way to use this on clj tools.deps?#2020-05-2811:52thhellercider defaults to using .nrepl.edn or so I think. ask in #cider about how to configure middleware#2020-05-2817:54Ian Fernandez=(#2020-05-2818:02thhellerI don't use cider so I have no clue how current the instructions here are https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2020-05-2818:02thhellerthats all I can link you to unfortunately#2020-05-2914:14Ian Fernandezthanks @thheller#2020-05-2811:53Ian Fernandezaw#2020-05-2811:53Ian Fernandezokay!#2020-05-2811:53Ian Fernandezthanks @thheller#2020-05-2814:35thhellerI should have known ... never change a running system ... :face_vomiting:#2020-05-2815:58kanweiI'm getting this on 2.9.10#2020-05-2815:58kanwei
[:ddplugin] Configuring build.
[:ddplugin] Compiling ...
[:ddplugin] Build failure:
no output for id: [:shadow.build.classpath/resource "goog/base.js"]
{:resource-id [:shadow.build.classpath/resource "goog/base.js"]}
ExceptionInfo: no output for id: [:shadow.build.classpath/resource "goog/base.js"]
	shadow.build.data/get-output! (data.clj:196)
	shadow.build.data/get-output! (data.clj:192)
	shadow.build/enhance-warnings (build.clj:26)
	shadow.build/enhance-warnings (build.clj:22)
	shadow.build/extract-build-info/fn--53837 (build.clj:97)
	clojure.core/map/fn--5866 (core.clj:2753)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887)
	shadow.build/extract-build-info (build.clj:99)
	shadow.build/extract-build-info (build.clj:69)
	shadow.build/update-build-info-after-compile (build.clj:107)
	shadow.build/update-build-info-after-compile (build.clj:105)
	shadow.build/compile (build.clj:407)
	shadow.build/compile (build.clj:397)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:327)
	shadow.cljs.devtools.server.worker.impl/eval55641/fn--55643 (impl.clj:779)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248/fn--55256 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--55247/fn--55248 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--55247 (util.clj:257)
	java.lang.Thread.run (Thread.java:830)
#2020-05-2815:58kanweionly happens when there's already a cached version#2020-05-2816:07thhellerhmm strange#2020-05-2816:08thhellerjust shadow-cljs watch ddplugin and fails immediately?#2020-05-2818:45fabraoHello all, for this message:
The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored.
can´t I use dependency anymore?
#2020-05-2818:49fabraosorry, I think I asked a dumb question#2020-05-2818:50thhellershadow-cljs knows that you are gonna use shadow-cljs. you don't need to declare it in shadow-cljs.edn.#2020-05-2903:39tekacshas anyone been able to use shadow and REBL together, at all?#2020-05-2903:40tekacsI'd love to use REBL against shadow's nREPL, which I'm accessing from Cursive#2020-05-2907:29thhellerno clue how to hook up REBL to nrepl#2020-05-2914:38kszabohttps://github.com/RickMoynihan/nrebl.middleware#2020-05-2914:02metehanwhen I release an app on server it has some bug Is there anyway to debug it.#2020-05-2915:07thheller@m373h4n see https://shadow-cljs.github.io/docs/UsersGuide.html#externs#2020-05-2916:58cjsauerWhile using the :node-script target, is it possible to have shadow inline all require(...) calls in order to produce a single, standalone output file? I have the following in my cljs file:
(:require ["@cucumber/gherkin" :as gherkin]
          ["@cucumber/messages" :refer [IdGenerator]]
          )
Which is leading to ...; var x=require("@cucumber/messages"); ... calls in the compiled output. Wondering if there is any way to “inline” those. I’ve tried setting {:js-provider :shadow} but then I run into:
The required JS dependency "stream" is not available, it was required by "node_modules/@cucumber/gherkin/dist/src/stream/GherkinStreams.js".
So I’m not sure that this provider is compatible with node…
#2020-05-2919:22thheller@cjsauer post-procress the output with https://github.com/vercel/ncc#2020-05-2919:33cjsauerAh that looks great. Thanks. #2020-05-2919:59LukasHi guys, I have a very basic beginner question: I try to get shadow-cljs working with deps.edn. In my deps.edn I defined the deps for shadow-cljs
:aliases
 {:cljs {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
                     thheller/shadow-cljs {:mvn/version "2.9.10"}
                     reagent {:mvn/version "1.0.0-alpha2"}}}
when I now start shadow-cljs I get an error Use of undeclared Var reagent.core/render-component . How can I import reagent into my project? ( and yes i have absolutly no idea what I"m doing :D )
#2020-05-2920:00LukasThe full error message
Use of undeclared Var reagent.core/render-component

   2 |   (:require [reagent.core :as reagent]))

   3 | 

   4 | (defn load-app []

   5 |   (reagent/render-component

   6 |    [:h1 "hallo"]

   7 |    (. js/document (getElementById "app"))))

   8 | 

   9 | (defn ^:export init
#2020-05-2920:01thhellerits just render not render-component#2020-05-2920:19Lukasthis didn't work out, shadow tells me explicit that reagent is missing here. Any other idea?🙄#2020-05-2920:23thhellerwhats the error?#2020-05-2920:30Lukas
(reagent/render

-^---------------------------------------------------------------------

Use of undeclared Var reagent.core/render
#2020-05-2920:30LukasI guess reagent is just missing#2020-05-2920:30thhellerno. shadow-cljs isn't telling you that reagent is missing#2020-05-2920:31thhellerit is telling you that var is missing. thats entirely difrerent error. reagent.core exists just fine#2020-05-2920:31Lukasah okay#2020-05-2920:31thhellermaybe render was moved? I have no clue. you are using an alpha2 version so make sure that actually has what you need#2020-05-2920:32Lukasokay that's good input#2020-05-2920:32thhellerquick guess is that render was moved to reagent.dom/render instead#2020-05-2920:32thhellerso no longer in reagent.core#2020-05-2920:33Lukasty for ur time really appreciate is#2020-05-2920:34Lukaskinda hard, as a beginner, to figure out what exactly is the problem 😏#2020-05-2920:37thhelleryeah it might be better to sticking with stable stuff .. alpha things should probably be avoided as a beginner 😛#2020-05-2920:06Lukasoh gosh#2020-05-2920:06Lukasty :rolling_on_the_floor_laughing: told ya i don't know what im doing. Thanks a lot#2020-05-3005:18sergey.shvetsHi, getting some very weird issue, when trying to run a "Getting Started" guide of Slate.js. It seems like something with closure compiler but I'm completely lost. Anyone saw this before?
index.js:404 Uncaught TypeError: Cannot read property 'prototype' of undefined
    at Object.$jscomp.generator.createGenerator (generator_engine] :879)
    at Object.levels (index.js:755)
    at Object.above (index.js:380)
    at Object.void (index.js:2233)
    at eval (index.js:2092)
    at HTMLUnknownElement.callCallback (react-dom.development.js:189)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:238)
    at invokeGuardedCallback (react-dom.development.js:293)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:307)
    at executeDispatch (react-dom.development.js:390)
I've been only able to find this issue thus far: https://github.com/google/closure-compiler/issues/2910 which might be or not be similar. The component renders but when I try to edit anything, the error above happens.
#2020-05-3006:16rbergerJust when I think my mental model of Javascript interop is in sync with reality, the javascript world sends me another cureveball. Especially after being spoiled by npm and shadow-cljs. I have a lame javascript “library that only comes as a javascript file that seems to be intended only to be consumed via a <script> tag, not imported. It’s not an NPM library. If I inject it via the script file it comes in as a nice js function:
WebRTCAdaptor:  λ[mediaConstraints audioConstraint stream]
                jsƒ WebRTCAdaptor(initialValues)
I can then instantiate the main object with a (new js/WebRTCAdapter jsparams) and all is well, until it is :advanced compiled and all the names get munged. I could go thru all the function and property calls and use cljs-oops to ensure they don’t get munged, but it seems like I should be able to figure out how to import /require the js file and shadow-cljs should take care of things (I hope that assumption is correct!) Then I find out I don’t know how to deal with the object that get’s imported/ required. It’s not coming in as a function or an object with a constructor. If I try to :require it like ["./antmedia/webrtc_adaptor.js" :as WebRTCAdaptor] I get the object but, its just an js object:
WebRTCAdaptor:  
{}
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
And I can’t do a new (new WebRTCAdaptor jsparams) Uncaught TypeError: module$visx$dashboard$antmedia$webrtc_adaptor is not a constructor or execute it as a function (WebRTCAdaptor jsparams) Uncaught TypeError: module$visx$dashboard$antmedia$webrtc_adaptor is not a function So I come back to the fount of knowledge to humbly ask for guidance. Is there a nice clean way to do this with shadow-cljs or should I just apply some cljs-oops elbow grease to the <script> imported js?
#2020-05-3007:38thheller@rberger first of all delete cljs-oops from your mind as an option. NEVER use it. turn on :infer-extern :auto and let the compiler tell you about things it needs externs for. you can just stick a regular CLJS syntax, no need for a library.#2020-05-3007:38thhellerwould help to see the code. the library seems to have an exported value, otherwise you'd get nothing. looks like that is already an instance of the class it provides.#2020-05-3007:39thhellerreally up to you if you want to bring the code into your build or leave it in a script#2020-05-3007:40thhellerexterns inference will probably well you which externs you need. if the JS does too much dynamic stuff it might not survive :advanced because of that. externs aren't enough to fix that, so it just might not be compatible.#2020-05-3007:42thheller@bear-z my guess would be that you are looking at this incorrectly. in general my first guess when something is undefined is that you didn't pass a value that was expected correctly.#2020-05-3017:21sergey.shvetsThank you for your time. I'll start with a minimal example to triple check myself. Can I share the code if it doesn't work?#2020-05-3018:05thhellersure#2020-05-3018:14sergey.shvetsThank you so much. I just completed the example and it has the same error. Here is the repo with the code: https://github.com/bearz/slate-cljs-minimal-example I'm trying to run an example from here: https://docs.slatejs.org/walkthroughs/01-installing-slate And here is the working javascript code: https://codesandbox.io/s/cranky-currying-vl7ik?file=/src/App.js Thank you again for looking into it. I'm lost and don't know where to dig next.#2020-05-3018:28thhellerhmm the problem seems to go away if you set :compiler-options {:output-feature-set :es6}#2020-05-3018:33sergey.shvetsThat helps!#2020-05-3018:33sergey.shvetsIs this affects anything else that I should be aware of?#2020-05-3018:35thhellerwell yeah the code doesn't run in browsers that don't support ES6 (dunno which feature slate uses exactly that causes the error otherwise)#2020-05-3018:35thhellerthe default is :es5 so the closure compiler will trying to transpile it down#2020-05-3018:35thhellerwhich seems to be causing the issue#2020-05-3018:35thhellerbut if you don't care about pre 2015 browsers then thats probably fine#2020-05-3018:36sergey.shvetsYes. Doesnt' really matter to me. Thank you so much! I wouldn't find this any time soon without your help#2020-05-3018:36sergey.shvetsSlate is in typescript since recently, probably they target es6 with their compile.#2020-05-3007:43thhellerdepending on when the library checks what you passed the resulting error might be deep in the code#2020-05-3007:43thhellerso first make sure that the arguments you are passing to slate are what they are supposed to be. meaning don't pass CLJS data if it expects JS objects, etc.#2020-05-3008:21rbergerI’m curious as to why it works if the webRTCAdapter code is brought in globally with the <script> tag but doesn’t work as an import. If you do have the time to glance at the code it is at https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/js/webrtc_adaptor.js#2020-05-3008:23thhellerthis has no exports so it can't possibly work#2020-05-3008:24rbergerAh, If I were to add something like export WebRTCAdaptor it would work?#2020-05-3008:25thhelleryou can just add export { WebRTCAdaptor } at the bottom yes#2020-05-3008:25thhellerthat gives you a :refer (WebRTCAdaptor) in CLJS#2020-05-3008:26rbergerCool, really appreciate your time#2020-05-3008:34thhellerquick warning though. the code is not exactly idiomatic JS and closure might have issues with this#2020-05-3008:35thhelleryou can also add exports.WebRTCAdaptor = WebRTCAdaptor; at the bottom instead of the exports#2020-05-3008:35thhellerthat turns the code into commonjs, meaning it doesn't go through :advanced and instead uses the same style as node_modules code#2020-05-3008:35thhellerso if you have :advanced issues that might be worth trying#2020-05-3011:45EmmanuelOgasup, does anybody know where's the right place to change :watch-ext ? I'm trying to make shadow reload my static html file changes but can't figure out where to put that config key. Ref: https://github.com/thheller/shadow-cljs/blob/7428c212b246f2ce179b2da39678f5d32931b772/src/main/shadow/cljs/devtools/server/worker.clj#L262-L264 I tried: https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading
{...
    {:builds
      {:app {...
             :devtools {:watch-exts #{"css" "html"}}}}}
... but not luck. Btw, this is not documented afaict.
#2020-05-3012:31thheller@emmanueloga that isn't supported. even if you make it watch the html it won't reload it.#2020-05-3020:29EmmanuelOgathat explains it 🙂#2020-05-3021:25Pavel KlavíkHi, I have a problem in advance compilation of NodeJS, probably due to missing extern. I am using Macchiato which has the following line:
(.createServer (node/require "http") http-handler)
When running in advance, I get this:
function mo(a,b,c){var d=null!=b&&(b.h&64||r===b.P)?J.b(dh,b):b,e=E.b(d,oj);b=E.b(d,Si);var f=E.b(d,Zh);if(x(Wk.a(f)))return null;try{var g=e.j?e.j():e.call(null);hf.c(c,sd,a);var k=g}catch(l){throw b=l,Error([["could not start [",C.a(a),"] due to"].join("")," ",C.a(b)].join(""));}c=k;d=null!=d&&(d.h&64||r===d.P)?J.b(dh,d):d;d=E.b(d,wm);gf(d,c);hf.H(ko,W,a,new v(null,1,[Si,b],null));return hf.H(jo,xf,new X(null,2,5,Y,[a,Zh],null),new mh(null,new v(null,1,[Wk,null],null),null))}
                                                                                                                                                                                                 ^

Error: could not start [#'orgpad.screenshot.core/server] due to TypeError: (intermediate value)(intermediate value)(intermediate value).rd is not a function
    at mo (C:\Shared\orgpad\screenshot\screenshot.js:443:204)
    at Function.so.l (C:\Shared\orgpad\screenshot\screenshot.js:449:21)
    at so (C:\Shared\orgpad\screenshot\screenshot.js:447:276)
    at Function.<anonymous> (C:\Shared\orgpad\screenshot\screenshot.js:556:154)
    at Function.J.b (C:\Shared\orgpad\screenshot\screenshot.js:169:112)
    at C:\Shared\orgpad\screenshot\screenshot.js:556:119
    at Object.<anonymous> (C:\Shared\orgpad\screenshot\screenshot.js:557:3)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
When switching to :simple compilation, everything works fine.
#2020-05-3021:27mauricio.szaboHi, I'm trying to compile a project (that was working on 2.8.109) with the current version 2.9.10. Something strange is happening: when I try to watch my node-library project, it's printing the following on terminal:
[:dev] Configuring build.
[:dev] Compiling ...
[:dev] Build completed. (213 files, 212 compiled, 0 warnings, 33.38s)
[:dev] Compiling ...
[:dev] Build completed. (213 files, 0 compiled, 0 warnings, 0.07s)
[:dev] Compiling ...
[:dev] Build completed. (213 files, 58 compiled, 0 warnings, 1.21s)
[:dev] Compiling ...
[:dev] Build completed. (213 files, 92 compiled, 0 warnings, 7.22s)
[:dev] Compiling ...
[:dev] Build failure:
The required namespace "shadow.umd-helper" is not available.
#2020-05-3021:27dpsuttonWhy are you using advanced compilation?#2020-05-3021:28dpsutton@pavel.klavik #2020-05-3021:29Pavel KlavíkNot sure, it was the default. The file is little bit smaller, might be faster. Not really that important in the end, since the server is really tiny.#2020-05-3021:30dpsuttonI’m surprised it’s the default. What build target are you using?#2020-05-3021:31dpsuttonWhat does you shadow-cljs.edn file look like?#2020-05-3021:32mauricio.szaboI believe all targets on shadow-cljs defaults to :advanced...#2020-05-3021:32Pavel KlavíkThe entire build config looks like this:
:screenshot {:target           :node-script
                             :main             orgpad.screenshot.core/main
                             :output-to        "screenshot/screenshot.js"
                             :devtools         {:autoload true}
                             :compiler-options {:optimizations :simple}}
#2020-05-3021:32dpsuttonDelete those compiler options. Shadow uses sensible defaults#2020-05-3021:33dpsuttonNode doesn’t I don’t believe#2020-05-3021:33dpsuttonNo benefit to advanced#2020-05-3021:33mauricio.szaboNode does 🙂
#2020-05-3021:33dpsuttonOh does it?#2020-05-3021:33Pavel Klavíkit was broken without them, so I added them to make it work for now#2020-05-3021:35thhellereverything defaults to :advanced#2020-05-3021:35thhellerit is broken because of machiato doing nonsense#2020-05-3021:36thheller(.createServer (node/require "http") http-handler) this I mean ...#2020-05-3113:25Pavel Klavíkhow should this be changed to make it work with Shadow-cljs?#2020-05-3114:38thhellerit works just fine. it just isn't recognized by externs inference#2020-05-3114:38thhellershould be (:require ["http" :as http]) in the ns and then (http/createServer ...) but that might have issue with regular cljs#2020-05-3120:24Pavel Klavíkso how could this be solved if one wants to be compatible with regular cljs?#2020-05-3120:33thhelleradd externs inference hints in the code#2020-05-3120:34thhelleror you create https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs for createServer in your project#2020-05-3120:34thhellerand maybe others .. whatever else fails#2020-05-3021:36thhellerbut yeah if you are fine with :simple then use it#2020-05-3021:37mauricio.szabo@thheller any tips on debugging The required namespace "shadow.umd-helper" is not available. happening?#2020-05-3021:37dpsuttoni apologize. i thought i remember reading that a few targets did not use advanced. the node ones in particular. i was wrong#2020-05-3021:38thhellernot really. can you narrow it down when it happens?#2020-05-3021:38thhellerlike editing a specific file or so? it is a generated namespace so not sure how it could be missing#2020-05-3021:38mauricio.szaboWhen I try to compile Chlorine source. Just compile, nothing fancy happening#2020-05-3021:39thhellerseems to work a couple of times and then doesn't#2020-05-3021:39mauricio.szaboLike, I just watch the file, it says 3 times that build is complete, but then tries to compile again#2020-05-3021:39thhellerso something must happen that is causing it to stop working#2020-05-3021:39thhelleryou mean it compiles 3 times on its own without you doing anything?#2020-05-3021:40mauricio.szaboYes, exactly.#2020-05-3021:40thhellerand you are sure that NOTHING is touching any files or so?#2020-05-3021:40thhellerwouldn't be the first time that some editor setup just does stuff. like running a linter, formatter or whatever#2020-05-3021:41thhelleryou can set :log {:level :debug} in shadow-cljs.edn that will give you a little more log output#2020-05-3021:46mauricio.szaboOkay, I just closed all editors, everything that can touch files, removed old compilation files, and added that option to shadow, the error still happens... Still says "Build completed" twice, then fails 😞#2020-05-3021:47mauricio.szaboWait... there's something strange indeed on my config#2020-05-3021:49mauricio.szaboNevermind - the output-dir was included on source-files.#2020-05-3021:49mauricio.szaboIf I remove it, it works#2020-05-3021:51mauricio.szaboThanks a lot! With :level :debug I saw:
[2020-05-30 18:44:37.353 - FINE] :shadow.cljs.devtools.server.reload-classpath/classpath-js-update - {:dir #object[java.io.File 0xbbe1be95 "/home/mauricio/.atom/packages/chlorine/lib"], :name "js/cljs-runtime/sci.impl.max_or_throw.js", :ext "js", :file #object[java.io.File 0xa45ec655 "/home/mauricio/.atom/packages/chlorine/lib/js/cljs-runtime/sci.impl.max_or_throw.js"], :event :mod}
And that gave me clues on what's wrong :+1:
#2020-05-3021:53thhellerhmm weird. those are supposed to be filtered. it shouldn't be watching cljs-runtime folders.#2020-05-3021:53thhellerbut yeah output dirs on the classpath is not a great idea#2020-05-3022:08thhellerfighting with nrepl again ... one day I'll make it my mission to kill nrepl. so extremely annoying to work with for CLJS ...#2020-05-3022:16mauricio.szaboDo shadow-cljs have a ClojureScript nREPL? Or it works the same as piggieback, for example?#2020-05-3022:16thhellerit has its own nrepl middleware. piggieback exists but isn't used. only there because other middleware expects it.#2020-05-3022:22mauricio.szaboIs there any documentation that tooling authors can follow? Or do you not recommend using it?#2020-05-3022:23thhellerno extra docs, you just use nrepl as normal#2020-05-3022:24thhellerI mean you can read piggieback docs or whatever#2020-05-3122:47gmercerHi, I just ran lein new re-frame demo +less +10x +re-frisk +calva +kondo +test +handler and everything from Calva worked great but in order to get "less watch/auto" behaviour I need to run lein less auto (BTW shadow-cljs correctly picks up the changes) is there an example of hooking in lein-less ? For a dodgy hack ... (defn hook {:shadow.build/stage :configure} [build-state & args] (future (shell/sh "lein" "less" "auto")) build-state)#2020-05-3123:43nprbstI'm relatively new to ClojureScript and I'm working on a demo project to pitch CLJS for our next project at work. I'd like to include Dynadoc (https://github.com/oakes/Dynadoc) in that project, and I've used shadow-cljs, not Lien or Boot. How would I use Dynadoc from shadow-cljs? Any advice would be much appreciated!#2020-06-0105:09didibusIf I use shadow-cljs, and I have lib A depend on NPM packageX version 1.2 and now say I have lib B depend on NPM packageX version 2.0 and now I have my app depend on both lib A and lib B? What happens? Assuming lib A and B are both ClojureScript libs?#2020-06-0107:44thheller@gmercer launching lein less in a hook is not a good idea. :configure is called whenever your build config changes while watch is running so you can end up with multiple watches. I recommend using some other tool to run multiple processes for you. eg. https://github.com/strongloop/node-foreman#2020-06-0107:46thheller@nathan.probst dynadoc is a leiningen plugin. not sure it can be used without lein. maybe try shadow-cljs run dynadoc.core with maybe some args?#2020-06-0107:47thheller@didibus you have to sort out that conflict and decide which version to install. ultimately the installed version wins. if none are installed shadow-cljs will install the newest one, assuming they are declared in deps.cljs :npm-deps (of those libraries)#2020-06-0108:14gmercer@thheller cheers, yes - a nasty hack, after investigating it looks I should use the less tool directly (rather than lein-less) and get it to run alongside/in conjuction with shadow watch app . Do you know of an example something like that? I guess the trickiness is making sure tools run at the correct part of the lifecycle#2020-06-0108:15thhelleragain the answer would be a separate tool to run multiple processes for you#2020-06-0108:16thhellerI have never used less in any shape so I can't make recommendations on which tools to use#2020-06-0108:17gmercerI mean any other node web pipeline tool that does a transformation to directories watched by shadow#2020-06-0108:17thhelleras far as shadow-cljs is concerned it is just files on disk that it reloads#2020-06-0108:17thhellerit doesn't care where those files come from#2020-06-0108:19gmercerI was looking for an example of running another node tool .. that places files in shadow-cljs 's area of concern#2020-06-0108:19thhellerI don't follow. you are asking how to run generic node tools?#2020-06-0108:20thhellerif you configure :dev-http {3000 "public"} which serves the public folder under port 3000#2020-06-0108:20thhellerso you generate you css into public/css/foo.css however you like#2020-06-0108:21thhellershadow-cljs will reload it automatically#2020-06-0108:22thhellerif you use a custom webserver you'll need to configure :watch-dir, see https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2020-06-0108:24gmercerIf I change my search from less to sass or scss .. I can see you have been through this discussion before ..#2020-06-0108:24thhelleryes, I have used sass before and have used and continue to use node-sass#2020-06-0108:25thhellernode-sass -w src/sass/main.scss public/css/main.css#2020-06-0108:26gmercerdo you have the example that shows node-sass "running in the background" or in conjunction with shadow ?#2020-06-0108:26thhellervia nf start#2020-06-0108:26thhellernf = node-foreman I linked above#2020-06-0108:27gmercerthanks#2020-06-0108:32thhellerFWIW I also used https://www.npmjs.com/package/npm-run-all in the past but imho nf is simpler and does enough for me#2020-06-0108:34thhellerI don't use it to run shadow-cljs though, still run that separately. I guess mostly out of habit#2020-06-0108:36gmercerI was trying to get a beginner started with the re-frame template (which uses lein to kick-off shadow-cljs) and trying to avoid the extra lein less auto step, if I can work it out I would create a PR to make it easier for other beginners.#2020-06-0108:38thhellerthat is a question for the template then, I have no control over that and my own grievances with the setup it creates#2020-06-0108:41gmercerI could take that the wrong way ... are you going to make a proper shadow-cljs only re-frame template :rolling_on_the_floor_laughing:#2020-06-0120:44rbergerI made a clj-new template for re-frame/shadow-cljs/deps.edn projects, might need its dependencies updated, but I’ve been using it https://github.com/omnyway-labs/re-frame-template#2020-06-0205:02superstructorThere is already an issue to improve the integration storey between shadow-cljs and re-frame-template @gmercer Please see https://github.com/day8/re-frame-template/issues/128#issuecomment-634414469 Busy working on some documentation related issues atm but will get to this at some point in the near future.#2020-06-0604:28gmercer@U0G75S29H sounds great - looking forward to it#2020-06-0108:43thhellerI don't use re-frame so I won't create a template for it. thats a community thing, there are already plenty of templates that just use shadow-cljs directly without the whole lein-shadow setup#2020-06-0108:44thhellerits fine to run through lein if you like that setup#2020-06-0108:44thhellera lot of people prefer deps.edn nowadays#2020-06-0108:45gmercerI was just familiar with that template and using lein was fine, they added the shadow-cljs feature and I thought I would check it out .. I might see if I can find a pure shadow-cljs template ... didn't even think of that 😉#2020-06-0108:47thhellerthe official re-frame-template is definitely the best maintained and has the most options though#2020-06-0108:52gmercereven though they just plonked shadow-cljs on as an option, it should really cope with the other chosen options#2020-06-0108:53gmercerPS I just read your clojure-verse discussion on shadow-cljs templating .. now I need to check out vue cli to see what you mean#2020-06-0109:01thhelleryeah the vue ui thing is great#2020-06-0109:02thhellerIf I had infinite amount of time I'd write something like that 😛#2020-06-0109:12Elirazhey, is there an easy way to update all the deps to their latest version?#2020-06-0109:14thhellerno#2020-06-0109:29Elirazso you have to check manually for each one?#2020-06-0109:30thhellerif you use project.clj or deps.edn then there are tools that handle that#2020-06-0109:31thhellerthere is also something that supports shadow-cljs.edn but I can't remember the name#2020-06-0109:45Elirazgot it.#2020-06-0113:07andrewboltachevHello! I'm using shadow-cljs for web project. I have macros, which in the meantime should read from . With shadow-cljs, how do I configure the resources path?#2020-06-0113:28aisamuCheck the :source-paths key (or src if you're using deps.edn) https://shadow-cljs.github.io/docs/UsersGuide.html#source-paths#2020-06-0113:30andrewboltachevYes thanks. Only it's not :resource-paths#2020-06-0113:31ElirazHey I have 2 build entries, how would I point a (second?) dev server to the other out dir?
:dev-http {8080 "target/"}
 :builds {:app {:output-dir "target/"
                :asset-path "."
                :target :browser
                :modules {:main {:init-fn }}
                :devtools {:after-load !
                           :preloads [devtools.preload]}}
          :devcards {:output-dir "devcards/"
            :asset-path "."
            :target :browser
            :modules {:main {:init-fn devcards.main/init}}
            :devtools {:after-load !
                       :preloads [devtools.preload]}}}
#2020-06-0113:34aisamu
:dev-http {8080 ["target/"]
           8081 ["devcards/"]}
#2020-06-0113:34ElirazThank you !#2020-06-0113:31andrewboltachev@aisamu that worked, thanks!#2020-06-0113:33Elirazshould they have the same output directory?#2020-06-0113:34Elirazohh nice#2020-06-0113:35aisamuYou don't need a vector if you don't have multiple folders to serve#2020-06-0113:35Elirazgot it#2020-06-0113:35Elirazthanks for the help#2020-06-0113:37andrewboltachev
✗ npx shadow-cljs browser-repl
<...>
cljs.user=> .1
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:1
 Use of undeclared Var cljs.user/
--------------------------------------------------------------------------------
0.1
cljs.user=> 
#2020-06-0113:37andrewboltachevHaving this error. Should this be a warning?#2020-06-0114:15thhelleryou mean you have this warning but it should be an error?#2020-06-0115:52ElirazHey, I'm struggling a bit with devcards, given the following:
(ns devcards.main
  (:require-macros
   [devcards.core :refer [defcard]])
  (:require [reagent.core :as r]
            [devcards.core :as dv]))

(def functional-compiler (r/create-compiler {:function-components true}))

(reagent.core/set-default-compiler! functional-compiler)

(defn hello-component []
  [:div "hello-world"])

(defcard hello
  (r/as-element [hello-component]))

(defn ^:export init [] (devcards.core/start-devcard-ui!))

(defn ^:export reload []
  (println "Refreshing Devcards!"))
#2020-06-0115:52ElirazI get main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefined#2020-06-0115:53Elirazthat means that devcards.core is undefined for some reason#2020-06-0115:54ElirazAm I missing something?#2020-06-0116:28thhellerI don't know. any other errors in the browser console?#2020-06-0116:39Eliraz
./cljs-runtime/shadow.module.main.append.js:4 An error occurred when calling (devcards.main/init)
eval @ ./cljs-runtime/shadow.module.main.append.js:4
goog.globalEval @ main.js:836
env.evalLoad @ main.js:2229
(anonymous) @ main.js:2411
main.js:2231 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:2231
(anonymous) @ main.js:2411
main.js:2232 TypeError: Cannot read property 'start_devcard_ui_BANG__STAR_' of undefined
    at Object.devcards$main$init [as init] (main.cljs:18)
    at eval (./cljs-runtime/shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:836)
    at Object.env.evalLoad (main.js:2229)
    at main.js:2411
#2020-06-0116:39Elirazthese are all the errors#2020-06-0116:40Elirazit looks like it cannot find the devcards/core object or something like it#2020-06-0116:42thhellerany warnings during compile?#2020-06-0116:43Elirazhmm#2020-06-0116:43Elirazyes!#2020-06-0116:43Eliraz
[:devcards] Build failure:The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".
#2020-06-0116:44Elirazmaybe it's due to my namespace? I named it devcards#2020-06-0116:47thhellernot unless there is a regular devcards.main in the package that you overwrote#2020-06-0116:48thhellerseems like the new version relies on some bundled marked dependency. shadow-cljs doesn't support foreign libs so that won't work#2020-06-0116:50thhelleryou can probably set :js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}}} to "correct" it#2020-06-0116:58Elirazoh#2020-06-0116:58Elirazin the edn file?#2020-06-0116:58thhellerin shadow-cljs.edn in your build config yes#2020-06-0116:59Elirazand I guess I'll need to install it via npm>#2020-06-0116:59Eliraz?#2020-06-0117:00thhelleryes#2020-06-0117:02Felipe MarquesHello, I'm trying to run some tests using Karma#2020-06-0117:02Felipe MarquesBut I keep getting shadow is not defined#2020-06-0117:03Felipe MarquesI followed the instructions here#2020-06-0117:03Felipe Marqueshttps://shadow-cljs.github.io/docs/UsersGuide.html#_the_build#2020-06-0117:05thhellersounds like you didn't. this happens if the code produced by shadow-cljs isn't actually included in the code loaded by karma#2020-06-0117:05thhellerso make sure all the filenames match exactly#2020-06-0117:05Felipe Marquesyes, I saw this thread here in the history, the path seems right#2020-06-0117:05thheller:output-to "target/ci.js" must match the
basePath: 'target',
        // The file itself
        files: ['ci.js'],
#2020-06-0117:06Felipe Marquesit worked now, I think it was because I didn't add --single-run#2020-06-0205:05superstructorHas anyone come across this kind of issue when trying to require an npm package ? The file is valid JS, but I guess it could be using some features that Google Closure doesn't support ?
Build failure:
Failed to inspect file
  ...\node_modules\prettier\index.js

it was required from
  ...\codemirror.cljs

Errors encountered while trying to parse file
  ...\node_modules\prettier\index.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}

RuntimeException: Exception parsing ".../node_modules/prettier/index.js"
        com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:155)
#2020-06-0205:31David PhamDid you install prettier?#2020-06-0205:32David PhamMaybe reinstall it? #2020-06-0205:32David PhamOr maybe it is not valid JavaScript.#2020-06-0207:19thheller@superstructor please always post the full errors. I can reproduce this and I get a closure compiler error. seems to be something in the file it doesn't like. not sure what.
IllegalArgumentException: Must call rewindTo before calling getSourcePosition for an earlier line (1298797 < 1300077)
	com.google.common.base.Preconditions.checkArgument (Preconditions.java:300)
	com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourcePosition (LineNumberScanner.java:46)
	com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourceRange (LineNumberScanner.java:58)
	com.google.javascript.jscomp.parsing.parser.Scanner.getTokenRange (Scanner.java:100)
#2020-06-0209:21thheller@superstructor https://github.com/google/closure-compiler/issues/3492#2020-06-0210:20superstructorThanks for following it up @thheller 👍 🙂 and apologies for cutting the error output short.#2020-06-0210:21thhellerno biggy. I know that those kind of errors mean internal closure compiler problems, just easier to guess which one with the full trace 🙂#2020-06-0210:22thhellerare you including this in a browser build? the prettier package is pretty node focused so I wouldn't have much faith in it working in the browser#2020-06-0211:33superstructorYeah I was trying it in a browser build but I ended up trying js-beautify for now which appears to work OK. Not a critical feature.#2020-06-0212:31Elirazhello, doe's anyone here has an experience with devcards? I've finally made devcards "work" but I get no components rendered on the screen, all I see is the `devcards` title and clojurescript logo.. how do I tell devcards to render those cards I have?#2020-06-0212:47thheller@eliraz.kedmi if you setup a reproducible example I can take a look and see if its a setup issue. otherwise no clue about devcards.#2020-06-0212:47Eliraz@thheller how can I do that?#2020-06-0212:48Elirazis there an online env for clojurescript?#2020-06-0212:48thhellercreate a github repo with instructions on how to produce the problem#2020-06-0212:48Elirazsure I'll do that#2020-06-0212:48ElirazThank you!#2020-06-0221:52Felipe MarquesI'm trying to add some custom reader tags to my cljs project. It works as expected by when recompilation is triggered by editing some file, I get the following error:
#copy :inclusion.home/inclusion-card-title
----------------^---------------------------------------------------------------
my_app/core.cljs [line 26, col 10] No reader function for tag copy.
Does any one have faced this problem.
#2020-06-0221:52Felipe MarquesI added the require to my main-ns to gurantee that the tag is registered#2020-06-0221:52Felipe MarquesI register the tag like this
(cljs.reader/register-tag-parser! 'copy (fn [kw] (copy kw)))
#2020-06-0221:54thhellershadow-cljs does not support custom reader tags in source files and never will, unless someone can give me a really convincing reason. so far noone has.#2020-06-0221:55thhellerthere is literally no reason to ever use it in source code. absolutely fine and useful for data.#2020-06-0221:55thhellerjust call (copy :inclusion.home/inclusion-card-title) directly instead of #copy :inclusion.home/inclusion-card-title.#2020-06-0221:58thhellercljs.reader is for reader tags in data parsed by cljs.reader is is not for source code.#2020-06-0221:59thhellereg. (cljs.reader/read-string "#copy :foo") is totally fine and you have total control over that#2020-06-0222:00Felipe Marqueshumm, I understand. It was a more stylistic choice than regarding any functionality. I'll use the function directly.#2020-06-0222:01thhellerFWIW custom reader tags in code are an absolute nightmare for tooling#2020-06-0222:02thhellersince its impossible to tell what you are doing in the read fn and it occurs during read time ...#2020-06-0222:02thhellermacros or regular functions already let you do everything you can possibly want to do, just in a more well defined manner#2020-06-0307:05Eliraz@thheller I created a repo with the project: https://github.com/eliraz-refael/pointmers#2020-06-0307:06Eliraznpm install && npx shadow-cljs watch :devcards#2020-06-0307:26thheller@eliraz.kedmi the mistake you have is :devcards true in your build config. that should be :compiler-options {:devcards true}#2020-06-0307:27thhellerand then
(defn hello-component []
  [:div "hello-world"])

(defcard hello
  (dv/reagent hello-component)
  {:inspect-data true
   :frame true
   :history true})
#2020-06-0307:27thhellerinstead of (dv/reagent hello)#2020-06-0307:27thhellerthen everything shows up as expected#2020-06-0307:45Elirazwow it works! thank you!#2020-06-0321:47thhellersmall teaser for an addition coming in the next release. might be useful for :preload authors (eg. re-frame-10x, fulcro-inspect)#2020-06-0401:04awb99I love this feature! But this will not work with production bundles I assume; as this would require shadow-cljs to ship a self-hosted compiler. Or will it? Similar to what SCI can do today?#2020-06-0406:50thhellerno you are correct. this only works while the watch is running. talks directly to the shadow-cljs process precisely so it doesn't need any of the self-hosted things.#2020-06-0420:52tony.kay@U0CSAHDV0, this is interesting for the tooling you’ve been playing with.#2020-06-0420:59thhellerit is released in 2.10.0 and should be available in all builds automatically as long as watch is running. I'll document this a bit more soon.#2020-06-0321:48thhelleror anyone wanting to eval cljs code in the browser console 😉#2020-06-0401:00awb99I somewhere read, that shadow-cljs can create statistics on the composition of the size of all the modules that are in a bundle. Can someone tell me how to do that? I am trying to better understand the size implicatios of the different dependencies in my bundle, so that I can possibly split parts of it in a more lazy fashion. Thanks!#2020-06-0402:45aisamuPerhaps this? https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2020-06-0403:06awb99Thanks @U1UQEM078#2020-06-0408:24Rob KnightI'm struggling to figure out how to exclude ghostwheel from my release builds with shadow-cljs. The documentation suggests that it's only included if compiler options are set for the :dev build, but I can see 100kb+ of stuff for ghostwheel and its dependencies in my release build report.#2020-06-0408:26thhellerI don't think ghostwheel has any kind of options to remove it completely. you can try https://github.com/fulcrologic/guardrails which ensures think can be eliminated a little better.#2020-06-0408:27thhellerbut I haven't checked in a while how much this actually leaves behind#2020-06-0408:27thhellerlikely still too much#2020-06-0408:29Rob KnightThanks! I'll try that.#2020-06-0408:29thhelleryou can try setting up something like this https://github.com/day8/re-frame-debux/issues/30#2020-06-0408:29thhellerie. create a stub ns that actually does nothing and also doesn't require any additional dependencies#2020-06-0408:30thhellerthat would ensure that everything is gone#2020-06-0408:30Rob KnightOh, right. There appears to be a Github repo with a stub ns for Ghostwheel, but no information about what you're supposed to do with it.#2020-06-0408:30Rob KnightI think I was confused by the documentation for turning off runtime checks in release builds vs. actually stubbing the library out (which is undocumented maybe?)#2020-06-0408:31thhellerah yeah thats the common approach. you basically just replace the ghostwheel dependency on the classpath with the stubs#2020-06-0408:31thhellerbut that requires changing the classpath for dev/release builds which I think is a bit icky#2020-06-0408:32thhellerbut yeah you can take the stub ns it has, name it ghostwheel.core-stubs or so#2020-06-0408:33thheller
{:builds
 {:app
  {:target :browser
   ...
   :release
   {:build-options
    {:ns-aliases
     {ghostwheel.core ghostwheel.core-stubs}}}}}
#2020-06-0408:34Rob KnightAha. I couldn't find a single example of anyone actually doing this on github.#2020-06-0408:35thhellerwell this method nobody has done for ghostwheel#2020-06-0408:36thhellerthe typical method just uses different dependencies and switching the alias/profile using deps.edn/lein#2020-06-0408:37thhelleraliasing the ns is only supported by shadow-cljs and I haven't documented it much so it isn't exactly widely used 😛#2020-06-0408:38Rob KnightAh, ok. There is a stub library but it has the same namespace as the real one, so presumably I'm meant to switch them. And to do that I need deps.edn and can't do it in shadow-cljs?#2020-06-0418:25gnlThe stubs approach with the same namespace in two different artifacts seemed to me like the best way to reliably eliminate all dependencies from the production build at the time. It was inspired by https://github.com/philoskim/debux. I do however agree with @thheller that it's not a particularly pretty solution, I believe we even had a brief conversation about it at the time. For the next Ghostwheel release I plan to do it with a special version of gnl/ghostwheel rather than a different artifact, so it can be overridden using :override-deps in deps.edn. Unless, that is, a better and equally reliable approach comes up in the meantime. Feel free to post in #ghostwheel if anything else comes up.#2020-06-0408:39thhellerexactly#2020-06-0408:40Rob KnightThat makes sense. Thanks!#2020-06-0409:02David PhamIn general, what can go into the :build-options key?#2020-06-0409:03David PhamI did not find anything in the docs#2020-06-0410:48thhellermost of them are for internal stuff you shouldn't worry about#2020-06-0410:48thhellerI'll try to document the few that you can actually use#2020-06-0411:23David PhamThanks a lot! I really liked ns-aliases#2020-06-0411:23David PhamIt saved my ass today for devcards 0.2.7#2020-06-0411:23David Pham:-9#2020-06-0411:32martinklepschIs there a way to build code in release mode while triggering new builds whenever a file changes?#2020-06-0411:38thheller@martinklepsch no. I'd recommend triggering the compile from the REPL.#2020-06-0411:40martinklepschOk, guess I’ll try to hook that up to a watcher than. For debugging advanced issues this is quite handy#2020-06-0411:40martinklepsch(I’m back to debugging our node source maps issues 😅)#2020-06-0411:41thhellershadow-cljs release app --pseudo-names while shadow-cljs server is running is what I typically do#2020-06-0411:41thheller:advanced builds typically take too long to compile so with a watch you can end up queing another rebuild while the current one is running#2020-06-0411:42thhellerleading to many useless compiles ... (at least in my experience)#2020-06-0411:42martinklepschyeah I realized that might be an issue#2020-06-0414:27vis there a way to restart the server after installing cljs dependences without killing the previous process?#2020-06-0414:27vis there a way to restart the server after installing cljs dependences without killing the previous process?#2020-06-0414:28vit works with npm dependences, but when i install cljs dependency, I always have to kill the process and restart it#2020-06-0414:58thhellerthere is not no.#2020-06-0414:48p4v4nHi, Not sure if this is the right place to ask. I am trying to use a npm library and the import statement is sort of failing. Library - https://github.com/ruilisi/react-chessground Relevant code bits: lein new re-frame test npm install --save react-chessground (:require ["react-chessground" :as rcg :default Chessground]) [:> Chessground {}] Chessground is undefined/nil and (.log js/console rcg) returns an empty object instead of a module. Tested that the library is working with this example from readme. https://github.com/ruilisi/react-chessground/tree/master/example#2020-06-0415:00thheller@p4v4n any errors during load?#2020-06-0415:07p4v4n@thheller There is one reference issue.
app.js:2231 An error occurred when loading benoni.components.chess_ground.js
env.evalLoad @ app.js:2231
app.js:2232 ReferenceError: $jscomp is not defined
    at Object.shadow$provide.module$node_modules$chessground$util (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$util.js:1)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$chessground$board (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$board.js:8)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$chessground$api (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$api.js:1)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$chessground$chessground (:8280/js/compiled/cljs-runtime/module$node_modules$chessground$chessground.js:1)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$react_chessground$chessground (:8280/js/compiled/cljs-runtime/module$node_modules$react_chessground$chessground.js:2)
    at shadow.js.jsRequire (js.js:66)
#2020-06-0415:08p4v4nOn component load
Uncaught Error: Assert failed: Invalid Hiccup form: [nil {}]
#2020-06-0415:11thhellerok nothing will work after that error#2020-06-0415:12thhellerwhich shadow-cljs version is that?#2020-06-0415:12thheller$jscomp issues should be fix in more recent versions?#2020-06-0415:13p4v4nshadow-cljs version is 2.9.3. The reference error is happening only when this particular library is loaded.#2020-06-0415:14thhellertry 2.9.10#2020-06-0415:28p4v4n@thheller Tested it with 2.9.10. Still facing the same issue. (upgraded version - lein deps - lein run)#2020-06-0415:31thhellerdon't have time to look at it closer now but you can maybe fix the issue by setting :compiler-options {:output-feature-set :es6}#2020-06-0415:31thheller$jscomp issues should be fixed but I don't know enough about your setup to comment further#2020-06-0415:31thhellerif you make a reproducible example I can take a look later#2020-06-0415:35p4v4nThanks a lot.Will try that.#2020-06-0415:49p4v4n@thheller After adding :compiler-options {:output-feature-set :es6} the reference error disappeared. Able to use the library now.Thanks.#2020-06-0416:05jaimeHi, I already have running shadow-cljs watch app in terminal, and I'm already connected to repl (under user namespace) using intellij cursive (see screenshot for the config). When I run (shadow/repl :app) I'm getting this message No such var: shadow/repl What am I missing here?#2020-06-0416:06thhelleruse the fully qualified namespace. (shadow.cljs.devtools.api/repl ...)#2020-06-0416:06thhellerotherwise it depends on which namespace you are in and only works in shadow.user by default.#2020-06-0416:11jaimeEven when I switch to that namespace, its not working (see screenshot). Here is my shadow-cljs.edn
{:deps {:aliases [:web]}

 :builds
 {:app {:target :browser
         :output-dir "resources/public/app"
         :asset-path "/"
         :modules {:app {:init-fn limeray.web.core/init}}
         :devtools {:http-port 9000
                    :http-root "resources/public/app"
                    :preloads [devtools.preload]}}}}
THis is the alias entry in deps.edn
:web {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.94"}
                              thheller/shadow-cljsjs {:mvn/version "0.0.21"}
                              tick {:mvn/version "0.4.17-alpha"}
                              org.clojure/clojurescript {:mvn/version "1.10.597"}
                              reagent {:mvn/version "0.9.1"}
                              metosin/reitit {:mvn/version "0.4.2"}
                              binaryage/devtools {:mvn/version "1.0.0"}
                              cljs-bean {:mvn/version "1.5.0"}
                              cljs-http {:mvn/version "0.1.46"}
                              devcards {:mvn/version "0.2.6"}}}
#2020-06-0416:12thhellerand how did you start things?#2020-06-0416:12thhellerjsut the watch?#2020-06-0416:13thhelleryou have use port file from nrepl file activated#2020-06-0416:13thhellerthat only works with more recent versions of cursive#2020-06-0416:14thhellerotherwise it uses .nrepl-port which shadow-cljs doesn't create#2020-06-0416:14thhellerlooks to me like you are just not connected to the correct nrepl server#2020-06-0416:15thhellermaybe configure :nrepl {:port 12345} and connect to that port directly#2020-06-0416:19jaimeoh ok. I was thinking shadow-cljs creates nrepl.port file? I created symbolic link to point to it
▶ readlink .nrepl-port
webapp/.shadow-cljs/nrepl.port
#2020-06-0416:20thhellerah ok#2020-06-0416:20jaimeok. My bad. I think I'm pointing to the wrong symbolic link.#2020-06-0416:21jaimeIt is one directory up 😅#2020-06-0416:22jaimethanks @thheller for your help, appreciate it#2020-06-0416:25jaimeI should put readme file on this project. I always get stuck like an hour before I figure out how to connect to repl 😆#2020-06-0416:28thhellercursive in EAP supports looking at the .shadow-cljs/nrepl.port file directly so that gets a bit easier 🙂#2020-06-0416:37jaimecool 🙂 looking forward to it#2020-06-0416:45andrewboltachevHello I'm trying to build shadow-cljs for complex debug purposes, having customized Google Closure Compiler. I've built Google Closure Compiler's v20200504 with mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-shaded.xml and referenced it from project.clj , replacing v20200504 with 1.0-SNAPSHOT . When running ./build-cli.sh I'm having this error:
Compiling 17 source files to /home/andrey/Work/se/shadow-cljs/target/classes
warning: [options] bootstrap class path not set in conjunction with -source 8
/home/andrey/Work/se/shadow-cljs/src/main/com/google/javascript/jscomp/ShadowAccess.java:62: error: cannot find symbol
    public static final DiagnosticType NON_GLOBAL_DEFINE_INIT_ERROR = ProcessDefines.NON_GLOBAL_DEFINE_INIT_ERROR;
                                                                                    ^
  symbol:   variable NON_GLOBAL_DEFINE_INIT_ERROR
  location: class ProcessDefines
Note: /home/andrey/Work/se/shadow-cljs/src/main/shadow/undertow/ShadowResourceHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
Compilation of Java sources(lein javac) failed.
#2020-06-0416:45andrewboltachevNote: I'm using java-11-openjdk-amd64#2020-06-0416:47thhellerthats a class from the closure-compiler so maybe a build issue?#2020-06-0416:48andrewboltachevah so is this shadow-cljs/src/main/com/google/javascript/jscomp/ShadowAccess.java actually taken from GCC?#2020-06-0416:49thhellerno. the ProcessDefines is from GCC#2020-06-0416:49andrewboltachevah. true#2020-06-0416:50thhellerthat class is in the shadow-cljs repo because it accesses a bunch of package-protected stuff shadow-cljs can't otherwise access#2020-06-0416:50thhellerdunno if they maybe removed that define?#2020-06-0416:51andrewboltachevI've actually compared (using vim as archive viewer, haha) two jars — and my SNAPSHOT one differs from the v20200504. Though I've built it off of v20200504 tag branch#2020-06-0416:52thhellerwell yeah this stuff isn't part of any public API so it breaks quite frequently#2020-06-0416:52andrewboltachevaha...#2020-06-0416:53thhellerfaster for me to just access this stuff directly to fix certain annoyances rather than going for a github issue and waiting 2 years 😛#2020-06-0416:54andrewboltachevor Google Groups? 🙂#2020-06-0416:54thhellergood to know there is a breaking change coming up though 😉#2020-06-0417:52andrewboltachevbtw you're right. I've messed the jars a little bit, needed to specify the exact one I need to compile#2020-06-0417:56andrewboltachevand yes here: https://github.com/google/closure-compiler/commit/7886d14c1e1d75b4c15378e1a56560060d9834d9#diff-40e9cfb8d2376d689d3f9fd7ce12365eL84#2020-06-0417:56andrewboltachevthey get rid of it#2020-06-0416:54thhellerwell google groups are pretty much dead#2020-06-0416:55thhellerwhat are you trying to do in closure exactly?#2020-06-0416:55andrewboltachevWell I want to know why I'm getting failed to convert sources#2020-06-0416:55thhellerI'd probably recommend trimming down the problem so you can reproduce it with closure only#2020-06-0416:56andrewboltachev
-> Shadow JS converting 1861 JS sources
failed to convert sources
#2020-06-0416:56thhellerotherwise you'll drastically reduce your chances of getting a PR through 😛#2020-06-0416:56thhellerthere should be more to that error?#2020-06-0416:56andrewboltachevthere's quite a few sources#2020-06-0416:56andrewboltachevwell yes#2020-06-0416:57andrewboltachevhttp://dpaste.com/2SRND1M#2020-06-0416:57thhellerhmm interesting. thats not very precise info. usually you get better errors than that 😛#2020-06-0416:58andrewboltachevwell it's simple com.google.common.base.Preconditions.checkNotNull#2020-06-0416:58andrewboltachevthis checks, and if sth is null it would throw the infamous one#2020-06-0416:58thhellerwell yeah that is clear#2020-06-0416:58thhellerbut usually closure will at least include some kind of source location that caused the issue#2020-06-0416:59andrewboltachevit's here https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/RemoveUnusedCode.java#L2624#2020-06-0417:05thhellerlooks like a weird place to fail? what are you including from npm? there shouldn't be goog.inherits calls in there?#2020-06-0417:05thhellerwell maybe it also applies to class and the comments just aren't updated. can't really tell 😛#2020-06-0417:12andrewboltachevokay 🙂 good to know!#2020-06-0417:13andrewboltachevwell, one "suite" of interest is https://deck.gl/#/#2020-06-0417:13andrewboltachevothers are React and related stuff, should be very common#2020-06-0417:40thhellerin case anyone has some time to test stuff I just released 2.10.0 which includes a pretty significant rewrite of everything REPL. ideally nothing changes from the user perspective but I might have missed stuff.#2020-06-0417:41thhellerit also enables Inspect and tap> for everything by default, no need to manually enable it anymore#2020-06-0417:42thhellerI'll probably post an update about Inspect this weekend or so#2020-06-0418:30andrewboltachevCan anyone suggest how to compile (`./build-all.sh` fails for me, is ./build-cli.sh enough?) and use the compiled/customized shadow-cljs (i.e. what to run instead of npx shadow-cljs compile myns )?#2020-06-0419:44thheller@andrewboltachev why are you messing with shadow-cljs when you want to debug a GCC issue in the first place?#2020-06-0419:45thhellerjust use deps.edn and declare the GCC version you want to use#2020-06-0420:32andrewboltachev@thheller well I just think it's the easiest way. 'cause shadow-cljs pushes that assets right through GCC#2020-06-0420:33thhellerbut what are you modifying in shadow-cljs itself? if you just want to change the dep you don't have to do that in shadow-cljs#2020-06-0420:34thhelleryou don't really need any of the build.sh scripts, they are mostly for CI and publishing. a regular lein install should be enough.
#2020-06-0420:34thhellerjust saying that you don't really need to touch shadow-cljs in any way if you are not making changes there.#2020-06-0420:36andrewboltachevah so, it's not dependency-through?#2020-06-0420:36thhellerhmm?#2020-06-0420:37thhellerGCC is a dependency of shadow-cljs yes but to change that dependency you don't need to change shadow-cljs?#2020-06-0420:37thhellerjust override it directly from lein or deps.edn#2020-06-0420:37andrewboltachevi.e. of my own project then?#2020-06-0420:37thhelleryes#2020-06-0420:39andrewboltachevah so that's no matter — the other ver. of GCC would be connected#2020-06-0420:39andrewboltachevlet's see#2020-06-0420:40thhellerwhat do you use? project.clj or deps.edn?#2020-06-0420:40andrewboltachevaha! I'm seeing my ouput#2020-06-0420:40andrewboltachev
CALL 2 [length: 30] [source_file: node_modules/turf-jsts/jsts.min.js]
#2020-06-0420:40thhellerwoho!#2020-06-0420:41andrewboltachevokay, that tells that the problem is coming from turf modules#2020-06-0420:41andrewboltachevturf — sort of geospatial calculations module#2020-06-0420:41thhellerthere is more info about the location a node came from#2020-06-0420:42andrewboltachevand btw that's min file#2020-06-0420:42andrewboltachevah so I should try to optimize it directly by GCC somehow probably#2020-06-0420:42thhellerit will be#2020-06-0420:43thhellerit is running through :simple optimizations .. doesn't matter if its minified before or not#2020-06-0420:44thhellerdon't get side-tracked. figure out the source location that is causing this in the actual source.#2020-06-0420:44thhellerif you do it might be easier to make a reproducible case and get this actually fixed in GCC#2020-06-0420:44andrewboltachevaha#2020-06-0420:44andrewboltachevyes, great thanks!#2020-06-0420:44andrewboltachevI guess I'll summarize here then when I'll gather all the details#2020-06-0420:45andrewboltachevalso comparing against different GCC versions maybe#2020-06-0420:46thhellerdon't try too many different GCC versions with shadow-cljs. its going to break pretty soon as you already saw 🙂#2020-06-0420:46thhellerits usually every other release that breaks somethings#2020-06-0420:48thhelleror just replace the turf-jsts lib if you can, thats probably the easier route#2020-06-0501:43Josh HorwitzHey everyone! Was wondering if anyone had a writeup/documentation about porting a lein cljs project with project.clj over to shadow-cljs?#2020-06-0501:45Chris McCormickno write-up but have done it a couple of times if you have any questions#2020-06-0502:38Josh HorwitzThanks! Just curious, what was your first step? which direction did you decide to go? Keep lein? remove? etcc.#2020-06-0502:45Chris McCormicki did this on https://github.com/infinitelives/px3d as one example. started by simply creating a shadow-cljs.edn and package.json as if i was starting from scratch.#2020-06-0502:46Chris McCormicki had done a few shadow-cljs projects by this time so that part was fairly straightforward#2020-06-0502:46Chris McCormickonce it was all up and running i could remove the project.clj though that isn't really neccessary#2020-06-0502:47Chris McCormicki also wrap everything in a Makefile generally so i just modified the one i already had working#2020-06-0502:48Josh Horwitzgreat, thank you so much!#2020-06-0502:48Chris McCormickhey no problem at all hope it goes well!#2020-06-0509:28David PhamDid anything happen to the shadow-cljs nrepl? I got some nullpointer exception whenever I am trying to make autocompletion with Cider#2020-06-0509:29David PhamIt works with 2.9.10 but not 2.10.1#2020-06-0509:31thhellerhttps://github.com/rksm/clj-suitable/issues/15#2020-06-0509:34thhellerstay with 2.9.10 if you want cider auto complete for now. not sure I can or want to restore the not-public API it used before.#2020-06-0510:12David PhamThanks. So clj-suitable can actually change their API and it would work?#2020-06-0510:33thhellerthat is what I'm trying to determine in the ticket. not actually sure what they need. I think the new API fn should cover everything.#2020-06-0510:34thhellerI'll see if I can restore the old stuff in some way but not sure I can. probably best to stay with 2.9.10 if you care about cider autocomplete#2020-06-0512:20David PhamThanks 🙂#2020-06-0514:41LucaHi I am trying to use this React component: https://github.com/christo-pr/dangerously-set-html-content , I am using Reagent. At the top I have:
(ns app.core
  (:require ["dangerously-set-html-content" :default InnerHTML]))
My component is:
(defn component []
  (let [html-str "blabla"]
      [:> InnerHTML {:html html-str}]))
I get this error in my JS console:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Thank you in advance for your time!
#2020-06-0514:41LucaHi I am trying to use this React component: https://github.com/christo-pr/dangerously-set-html-content , I am using Reagent. At the top I have:
(ns app.core
  (:require ["dangerously-set-html-content" :default InnerHTML]))
My component is:
(defn component []
  (let [html-str "blabla"]
      [:> InnerHTML {:html html-str}]))
I get this error in my JS console:
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Thank you in advance for your time!
#2020-06-0515:04LucaOk, I am pretty sure the InnerHTML reference is nil..#2020-06-0515:37alpoxI'm not sure what happens exactly but are there not a set of parantheses missing in the ns declaration?
(ns app.core
  :require ["dangerously-set-html-content" :default InnerHTML])
Should be:
(ns app.core
  (:require ["dangerously-set-html-content" :default InnerHTML]))
Not sure if it would work without the parantheses
#2020-06-0516:00LucaSorry I did not paste the code correctly! The parentheses are there!#2020-06-0516:50thheller@luca.cambiaghi try
(ns app.core
  (:require ["dangerously-set-html-content" :as InnerHTML]))
#2020-06-0516:52Luca@thheller awesome, that works! I feel stupid for not having tried it before! Thank you!!#2020-06-0517:03kennyEvery time I start shadow-cljs up, it sends a build error on this particular line:
50 |        #::table
----------------------^---------------------------------------------------------
No namespace: compute.ui.components.table found
The compute.ui.components.table is required in the namespace this error is in. Is there a known issue with namespace map syntax?
#2020-06-0517:04kennyIf I go make a small change to the table ns, the error goes away. It will then find another place where the namespace map syntax is used and fail on that. For example
139 |        #::calendar{:value     selected-date
-------------------------^------------------------------------------------------
No namespace: compute.ui.components.calendar found
#2020-06-0517:05thhellerthis is not an error from shadow-cljs. maybe from the reader?#2020-06-0517:06kennyTrying the latest version. Was on 2.9.8. Oh, yeah probably the reader.#2020-06-0517:09kenny2.10.2 fixes it. Weird.#2020-06-0517:09kennySome sort of bug in the reader in between those versions. A bit surprising.#2020-06-0517:10thhellerthere have been no tools.reader changes in those versions#2020-06-0517:10thhellercheck your classpath. maybe you have some conflicts?#2020-06-0517:18kennyOh, perhaps. Will check. Latest shadow-cljs will print this warning to the console on reload: couldn't find custom :build-notify#2020-06-0517:20thhellerwhoops#2020-06-0517:23thhellerwill be fixed soon. looking into something else before I make a new release#2020-06-0518:45fabraoHello all, I´ll deploy my first shadow-cljs project. I know that I´ll have to compile it with npx shadow-cljs realease app . But how do I pack the node_modules?#2020-06-0518:46fabraoMy node_modules has 270 Mb, do I have to copy it to my server?#2020-06-0518:46thhellerassuming you are talking about a :browser build you only need the files in the :output-dir#2020-06-0518:48fabraoyes, :browser . If I did something like <link rel="stylesheet" href="node_modules/suneditor/dist/css/suneditor.min.css"> , copy it to the css asset?#2020-06-0518:49fabraothere is cljs-runtime, do I have to copy it too?#2020-06-0518:50thhellerif you are referring to css files directly then you need to copy those#2020-06-0518:50thhellerthe cljs-runtime dir is from dev builds (ie. watch). it is not produced or required by release builds.#2020-06-0518:51fabraoso, only app.js?#2020-06-0518:52thhellerI don't know your :modules config. if you only have :modules {:app ...} then yes#2020-06-0518:56fabrao:modules {:app {:entries [app.core]}}#2020-06-0518:57fabraoso it will compress all the dependencies in one app.js ?#2020-06-0518:57thhelleryeah that produces a app.js in your :output-dir#2020-06-0518:57thhelleryes#2020-06-0518:57fabraoGood#2020-06-0518:57fabraothank you !#2020-06-0609:06David PhamHow can you achieve the same thing with node is script? That is compiling all dependencies into a single is file when you want to release the script?#2020-06-0609:07thhellerI recommend post-processing the file with https://github.com/vercel/ncc#2020-06-0609:07thhellershadow-cljs can also do that on its own but its less reliable and requires more configuration#2020-06-0616:20jjttjj@thheller you responded when this was brought up recently in another channel: andare (self host compatible core.async: https://github.com/mfikes/andare), doesn't work with shadow due to this function https://github.com/thheller/shadow/blob/master/src/main/shadow/util.clj#L29, specifically the :require on [cljs.core.async.impl.ioc-macros :as ioc] which isn't in andare. Was wondering now if you'd consider removing it or gutting it of the internal async stuff. I've removed it locally and have had no problems running my regular shadow workflows, for what that's worth. Andare's implementation is probably not ideal but seems like the best way to accomplish getting core.async on self-hosted cljs for now. You might have a better sense if anyone is using that go! macro though.#2020-06-0616:20jjttjj@thheller you responded when this was brought up recently in another channel: andare (self host compatible core.async: https://github.com/mfikes/andare), doesn't work with shadow due to this function https://github.com/thheller/shadow/blob/master/src/main/shadow/util.clj#L29, specifically the :require on [cljs.core.async.impl.ioc-macros :as ioc] which isn't in andare. Was wondering now if you'd consider removing it or gutting it of the internal async stuff. I've removed it locally and have had no problems running my regular shadow workflows, for what that's worth. Andare's implementation is probably not ideal but seems like the best way to accomplish getting core.async on self-hosted cljs for now. You might have a better sense if anyone is using that go! macro though.#2020-06-0617:41thhellerI can remove it ... created it a long time ago and there's even a ticket for it but doubtful anything will ever happen about it#2020-06-0617:42thhellernot that important anyways. core.async was a bad fit for want I wanted it for anyways 😛#2020-06-0617:42jjttjjAwesome, thanks!#2020-06-0617:48thhellergone in [thheller/shadow-client "1.3.3"]#2020-06-0617:48thhellerprobably will make a new shadow-cljs release a bit later too#2020-06-0617:54thhellerstill feels kinda dangerous to just replace a fairly integral dependency like core.async but I guess andare probably just leaves the clojure.core.async stuff alone and modifies only cljs.core.async#2020-06-0617:55jjttjjYes I believe there are no changes to the clojure part#2020-06-0617:55jjttjjIt's definitely a hack but it gets the job done for now#2020-06-0616:55andrewboltachev@thheller just FYI: this is one minimal snippet I was able to produce on which GCC (`v20200504`) would fail:
function aa() {
    var a = {}, b = null;
    a.a = 1,
    b.a = 2,
    Object.defineProperties(a, b);
}
Latest master of GCC produces the same error (just double-checked that)
#2020-06-0617:24thheller@andrewboltachev odd code. did you report it?#2020-06-0617:25andrewboltachev@thheller not yet actually. But this is my code. Actual one looks more like this: http://dpaste.com/1053C50#line-87#2020-06-0617:26andrewboltachevwhich comes from that "turf jsts" module (it's min version, which I've beautified)#2020-06-0617:26andrewboltachevthe selected line confuses the GCC#2020-06-0617:27andrewboltachevif replaced with sth = Object.defineProperties(Bi, Vi); it would pass#2020-06-0617:31andrewboltachevwhat it's doing is about that: this Bi object just got an update with Object.defineProperties by adding some Vi properties to it. But the object isn't used anymore so it wants to optimize that extra work (calling Object.defineProperties) away#2020-06-0617:31thhellerhmm yeah no clue. the code looks valid to me so must be a bug in closure#2020-06-0617:32thhellerdefineProperties has no return value I think. it just modifies the first argument in place#2020-06-0617:33thhellerso that should work fine#2020-06-0617:33andrewboltachevyes sure#2020-06-0617:33andrewboltachevbut having that Bi (or a in my case) won't be used anymore#2020-06-0617:33andrewboltachevwon't it want to optimize it away?#2020-06-0617:33thhellerjust include your shortened example and the original code in the report#2020-06-0617:33thhellerjust include your shortened example and the original code in the report#2020-06-0618:38andrewboltachevhere it is https://github.com/google/closure-compiler/issues/3612#2020-06-0620:42thhellerits usually a good idea to include a stacktrace of the actual crash. might want to add that.#2020-06-0617:34thhelleryou can reproduce the error with the web interface which helps#2020-06-0617:34thhellerhttps://closure-compiler.appspot.com/#2020-06-0617:34andrewboltachevaha#2020-06-0713:20Filipe Silvaheya#2020-06-0713:20Filipe SilvaI was taking a look at devcards 0.2.7 and it fails to build with Shadow-CLJS#2020-06-0713:20Filipe SilvaI opened an issue on their repo https://github.com/bhauman/devcards/issues/168#2020-06-0713:21Filipe Silvabut I'm sorta unsure if this is a configuration problem in my setup, maybe I should be providing that namespace somehow?#2020-06-0713:21Filipe Silvait seems to be defined in it's deps.cljs#2020-06-0713:21Filipe Silvahttps://github.com/bhauman/devcards/blob/master/src/deps.cljs
{:foreign-libs
 [{:file "devcards/js_libs/highlight.pack.js"
   :provides ["devcards-syntax-highlighter"]
   :global-exports {devcards-syntax-highlighter DevcardsSyntaxHighlighter}}
  {:file "devcards/js_libs/marked.min.js"
   :provides ["devcards-marked"]
   :global-exports {devcards-marked DevcardsMarked}}]
 :externs ["devcards/js_libs/highlight.ext.js"
           "devcards/js_libs/marked.ext.js"]
 :npm-deps {"create-react-class" "15.6.3"
            "react" "16.13.1"
            "react-dom" "16.13.1"}}
#2020-06-0713:21Filipe Silvathis is a fairly new release as well so maybe there was some misconfiguration there#2020-06-0713:22Filipe Silvawondering if someone has ran into it, or knows what should be done#2020-06-0713:24thheller@filipematossilva answered in the devcards issue#2020-06-0713:30Filipe Silvathank you @thheller, testing with that redirect#2020-06-0713:30Filipe Silvathank you @thheller, testing with that redirect#2020-06-0718:15David PhamI added a comment on how you could hack a solution for 0.2.7 using some undocumented options from shadow-cljs.#2020-06-0717:16alex-ebertsHi All, I’ve got a shadow-cljs project that builds and runs fine on my Mac but the dev-http server does not startup on an arch linux box. Has anyone seen this before and what do you recommend to tracking down the issue?#2020-06-0717:17alex-ebertsThings we’ve tried on the Linux box include: • Upgrading node to latest with pacman • Clearing node cache and reloading dependencies#2020-06-0718:36thhellernode is not involved in :dev-http#2020-06-0718:36thhellerwhat messages do you get on startup?#2020-06-0723:19jdkealyI can’t seem to get CSS reloading working. From everything I’ve read, there’s supposed to basically no configuration involved. I have reframe and 10x running, a sass compiler, absolute path to the CSS (include-css "/css/site.css") tried tinkering with :watch-dir "resources/public/" and :watch-dir "resources/public/css" / restarting shadow .etc. What else should I try ?#2020-06-0723:20mikethompson@jdkealy did you use re-frame-template?#2020-06-0723:20mikethompson@jdkealy did you use re-frame-template?#2020-06-0723:20jdkealyYes I did#2020-06-0723:21mikethompsonSo you have followed the instructions there?#2020-06-0723:21jdkealyAh, thanks I see now.#2020-06-0723:21mikethompsonnp#2020-06-0811:06martinklepschFinally got around to create a repro for broken source-mapping when targeting :node-libray (and to an extent :node-script): https://github.com/martinklepsch/shadow-src-map-issues Did anyone else encounter unexpected results with source maps and these targets?#2020-06-0811:06thheller@martinklepsch private repo? it get a 404#2020-06-0811:07martinklepsch@thheller oops, fixed!#2020-06-0811:08thhelleralso there is no package.json so I don't know which version you tried 😛#2020-06-0811:09martinklepschI tried latest but somehow
npm install --save-dev shadow-cljs
didn’t add a package.json, will fix
#2020-06-0811:09thhelleryeah need to package.json. install never creates it#2020-06-0811:10martinklepschdone#2020-06-0811:16thhellerbtw dunno if you tried but
$ node -r source-map-support/register -e 'var x = require("./functions/index"); x.throw()'
/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/index.js:253
556298533),Ve=new Tb(null,"more-marker","more-marker",-14717935);function qf(a){throw Error(["[",G.a(a),"] Fabricated example exception"].join(""));}var rf=["icebreaker","server","util_reduced","something_that_throws"],sf=aa;rf[0]in sf||"undefined"==typeof sf.execScript||sf.execScript("var "+rf[0]);for(var tf;rf.length&&(tf=rf.shift());)rf.length||void 0===qf?sf=sf[tf]&&sf[tf]!==Object.prototype[tf]?sf[tf]:sf[tf]={}:sf[tf]=qf;
                                                                                ^

Error: [api-endpoint-error] Fabricated example exception
    at qf (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/cljs/core.cljs:10747:20)
    at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/goog/base.js:169:3)
    at [eval]:1:46
    at Script.runInThisContext (vm.js:96:20)
    at Object.runInThisContext (vm.js:303:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at evalScript (internal/bootstrap/node.js:582:27)
    at startup (internal/bootstrap/node.js:267:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
#2020-06-0811:17thhellerI don't have babashka installed so can't run your other scripts 😛#2020-06-0811:17thhellerif that the same result you get though? it does indeed seem incorrect#2020-06-0811:20thhellerI guess this fails https://github.com/martinklepsch/shadow-src-map-issues/blob/master/view-source.clj#L1#2020-06-0811:20thhellerdoesn't matter though. source-map-support seems to show the issue just fine#2020-06-0811:32martinklepschSeeing the similar results with -r source-map-support/register#2020-06-0811:32martinklepschDo you want me to open an issue for this?#2020-06-0811:33thhellersure#2020-06-0813:34thheller@martinklepsch suppose this looks better 😉
Error: [api-endpoint-error] Fabricated example exception
    at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/icebreaker/server/util_reduced.cljs:4:30)
    at [eval]:1:46
#2020-06-0813:34martinklepschThat indeed looks better 🙂#2020-06-0813:47thheller@martinklepsch fixed in 2.10.5#2020-06-0821:19jjttjjThis is probably a horrible idea and I probably won't pursue it, but let's say I want to allow my self-hosted cljs app to be distributed as just html+js files with no server. I then wouldn't be able to make any ajax calls due to cross origin policy. I believe I could support this by replacing ajax calls with dynamically adding a script tag to the DOM linking to the a js file that puts the json in a variable. To do this with shadow, in theory, could I just add a postprocessing step to put index.transit.json and the bootstrap analysis files into js files, and then rewrite a selfhost load/`init` function based on the current shadow browser load mechanism? Or is there something obvious I'm missing#2020-06-0821:20thhelleryou mean let the user load everything from local disk?#2020-06-0821:21jjttjjyes#2020-06-0821:22thhellerno clue how that would work but I guess you could also create one gigantic .html file that just already contains everything#2020-06-0821:22thhellersame thing I do for the build-report html files#2020-06-0821:23jjttjjI believe I could append a <script src="x.js"> tag with the source being
var transit123 = ...
and kinda have a "fake ajax" layer that way, but yeah maybe I should try the big file first to see how that works
#2020-06-0821:24jjttjji'll check out the build-reports, thanks!#2020-06-0821:24thhellerdon't have to do that#2020-06-0821:25thhelleryou can create <script type="my-transit" data-key="some-name">... transit contents here ...</script> (or <template>) tags#2020-06-0821:26thhellerthen when its time to parse them just look it up by data-key or so and parse the text#2020-06-0821:26thhellerdon't have the browser eval it#2020-06-0821:26jjttjjI was thinking for performance reasons though to defer the loading until needed, but I might be overthinking that#2020-06-0821:27thhellerif its not script tags have a non-js type the parser just skips over them. that should be pretty fast and you are talking about local access so no network concerns.#2020-06-0821:27thhelleractually parsing the transit you can delay however long you like#2020-06-0821:27jjttjjoh cool, didn't know that#2020-06-0821:29thhellerjust gotta be careful whats in those transit strings. will get you into trouble if there is a {:foo "</script">"} transit encoded value in there since the HTML parser is just looking for </script> and doesn't to any kind of other parsing#2020-06-0821:30thhellermight need base64 encoding or so#2020-06-0821:30jjttjjthat's definitely good to know 🙂#2020-06-0821:30thhelleryou can try the other method too of course, just wrap the transit files JsonP style with a function call that registers them somewhere#2020-06-0821:31jjttjjyeah it does seem the big file might be a bit more straightforward for now#2020-06-0821:31thhellermight be scary to hand someone a 20mb .html file though 😉#2020-06-0821:33jjttjjyeah that was my initial thought haha#2020-06-0910:46thhellerhttps://clojureverse.org/t/status-update-inspect-cljs-eval/6074#2020-06-0912:46HarshanaHey all, I git cloned a re-frame project and am working on it. If I make any changes in the files and save them, hot reloading happens.But when I created a new file and saved it, it gets compiled but hot reloading doesnt happen. I am giving shadow-cljs watch app every time after saving to compile it. But the changes are getting rendered. What might be the issue here?#2020-06-0912:56thheller@hana.8500 I can't quite follow your problem description. creating a new file doesn't really do anything unless the file is required in your build. if it is it should be reloaded?#2020-06-0912:56thheller@hana.8500 I can't quite follow your problem description. creating a new file doesn't really do anything unless the file is required in your build. if it is it should be reloaded?#2020-06-0913:10HarshanaSorry, I'm quite new here. I created another cljs file in the same project that I cloned and when I save it, the changes do not get rendered unless I come out and give shadow-cljs watch app again. Whereas in the files that are already present in the project, if I make any changes and save them, they directly get rendered.#2020-06-0913:34thhellerI say again. just creating a new file doesn't do anything#2020-06-0913:35HarshanaI have linked it from the core file.#2020-06-0913:35thhellerdo :require the namespace in any ns?#2020-06-0913:36thhellerwhat does the browser console say? it logs every file it reloads?#2020-06-0913:36Harshanayeah I have done that and it gets rendered perfectly.#2020-06-0913:37thhellerdid you read https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html?#2020-06-0913:37thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2020-06-0913:38thhellerI don't know enough about your code. if you share it somewhere I can take a look what you might be missing#2020-06-0913:38thhellerthe browser console should be telling you all the relevant info though#2020-06-0914:17HarshanaThe browser console doesn't say much. Just shadow-cljs ready#2020-06-0914:18Aronwhat might be the reason for source map discrepancies? What I mean is that the reported file:linenr don't seem to be related to the problem at all, it's a simple (def ...) form not sure how could that throw, in fact I am fairly sure I know where the error is, when I send React some value it thinks is a function and tries to call it in a third party component. But, again, this def is not related to that component, it isn't even used there.#2020-06-0915:44thheller@ashnur I just fixed a source map issue in the recent release. whats the context for you though? which target? release or dev? etc?#2020-06-0918:39Arondev, I will check my version, probably update and try it. But I am very new to this whole thing so I am doing it a bit empirically, with less theory than I would wish for.#2020-06-0919:33thhellerdev isn't affected by the changes I made. also never had any reports of source maps being incorrect during dev though.#2020-06-0921:07AronThere are two ways sourcemaps can be incorrect. One is when the mapping points to the wrong place. The other when the mapping is correct but the original stacktrace is not relevant. I am not sure in this second case it's actually a source map issue what I am experiencing. I am not experiencing the first case, that's for sure.#2020-06-0921:48pcjHas anyone gotten shadow-cljs in a luminus app to work on dokku/heroku?#2020-06-0923:52fabraoWARNING: The thheller/shadow-cljs dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility. is this error message is about what?#2020-06-0923:53fabraoI can´t use :dependencies in shadow-cljs.end anymore?#2020-06-1000:03lilactownit says that the thheller/shadow-cljs dependency is being ignored#2020-06-1000:04lilactownnot all of them#2020-06-1000:04lilactownyou don’t need to specify the version of shadow-cljs in shadow-cljs.edn. you specify it package.json#2020-06-1000:05fabraothat´s what I did#2020-06-1000:06fabraothe error message gone, thank you, again#2020-06-1003:37entropyI'm looking into splitting my cljs code into modules, and using shadow.lazy to load the code dynamically on my SPA. In production I have static assets fronted by nginx and served by a CDN. After digging into it a little I can't figure out how a call to shadow.lazy/load translates into a web request, and I can't confirm whether or not it's still going to play well with my setup in production. Any pointers are greatly appreciated!#2020-06-1006:36tekacsI'm seeing $jscomp errors on 2.10.5, with :output-feature-set :es6 set. I'm able to work around it by setting :output-feature-set :es-next although that seems like a less-than-ideal workaround? The $jscomp errors appear to be linking back (through sourcemaps) to places where my NPM depdendencies are using async or other later-than-ES6 features in their original (not distributed) source -- a specific example of this from my dependencies is react-hook-form . On that hunch I switched to the :es-next feature set, but I assume this is some kind of issue with polyfills being used? I'll try to reduce this example down at some point, but hopefully the tracing back to the use of async is at least somewhat informative! Potentially relevant to https://github.com/thheller/shadow-cljs/issues/709 ?#2020-06-1006:57Schpaahow can I check the version of shadow-cljs I’m running???#2020-06-1006:58Schpaadoesnt response to -v, and the help screen shows nothing#2020-06-1007:33thheller@schpaencoder the version is printed on every startup?#2020-06-1007:33SchpaaI know it used to#2020-06-1007:34Schpaaprob. something with the container#2020-06-1007:34thhellerstill does. just doesn't print the CLI version anymore since thats less useful#2020-06-1007:35SchpaaI beg to differ#2020-06-1007:35thhellershadow-cljs info also has all the info#2020-06-1007:35Schpaathats it#2020-06-1007:36SchpaaI was looking for info, but thought about version#2020-06-1007:36Schpaamy bad#2020-06-1007:36thhellerrun shadow-cljs watch app or whatever and paste the output. I'd be very surprised if it didn't print the info on startup 😛#2020-06-1007:36Schpaait’s just that my brain looks for -version and never -info#2020-06-1007:37Schpaacase solved#2020-06-1007:39thheller@guaqueta shadow.lazy basically just figures out which module the namespace is in your are referencing and then loads that via :asset-path + <module-id>.js#2020-06-1007:41thhellerusing shadow.loader. you may set :module-loader-init false in your build config but then must call (shadow.loader/init "") before actually using the loader anywhere (eg. first thing in :init-fn)#2020-06-1007:41thhellerusing shadow.loader. you may set :module-loader-init false in your build config but then must call (shadow.loader/init "") before actually using the loader anywhere (eg. first thing in :init-fn)#2020-06-1017:07entropyThanks for the reply, I think this is exactly what I needed (also, thanks for shadow-cljs, it's been super helpful).#2020-06-1017:08thhellerforgot to mention that :asset-path also controls all of this#2020-06-1017:09thhellerso if you set that to a full URL at build time it will be used. eg :asset-path "" will end up loading your modules from there. so :modules {:main ...} would be #2020-06-1017:10entropyOh, neat. How would I configure :asset-path to have different values for dev vs prod builds?#2020-06-1017:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-06-1017:12thheller:release {:asset-path ""}#2020-06-1017:15entropyAlso, just for context: I was trying to catch the loader in action, so to speak. So in dev I added a middleware to my ring app to priint out all requests, and then I was hoping to see the request for the new module come through at the appropriate time (i.e. when I interact with my app in a way that should trigger the load). My app works as expected, so the new code clearly is getting loaded, but I just don't see the request that actually fetches the js file. I dug around a bit and saw that shadow.loader uses google module manager which in turn uses bulkloader which in turn uses Xhrio, so it should just come down to a web request for that asset. I'm probably just missing something obvious and now I've rambled for too long, but anyways that's where I was coming from.#2020-06-1017:16entropyoh and thanks for that link, I should have just read the docs before asking that.#2020-06-1017:21thhellerjust look at the browser console to see when the requests happen#2020-06-1017:22thhellerbut yes they are regular xhr requests fetching the sources. "when" depends entirely on how you use it.#2020-06-1017:29entropyIndeed, I do see the requests in the browser console happening when I expect them. I must have done something dumb in my logging middleware.#2020-06-1007:41thhellerif you must use a dynamic url that is#2020-06-1007:43thheller@tekacs for starters it would help to know which npm package is causing the issue. might give me something reproducible.#2020-06-1007:43thheller@tekacs for starters it would help to know which npm package is causing the issue. might give me something reproducible.#2020-06-1016:49tekacssorry if I wasn't clear -- it's the use of react-hook-form -- specifically when it uses any later-than-ES6 features like async functions.#2020-06-1011:07AronI am doing something wrong again. I ran into this issue: https://github.com/bhauman/devcards/issues/168 tried to add the config that fixes it, and I get IllegalArgumentException: Wrong number of args passed to keyword: :ns-aliases#2020-06-1011:08AronI tried to search for the docs for ns-aliases in both the shadow-cljs user guide, shadow-cljs github repo, and in clojurescript docs, I didn't see it anywhere.#2020-06-1011:10thhellerWrong number of args passed to keyword: :ns-aliases #2020-06-1011:10thhellerwhats your exact config?#2020-06-1011:13Aronthe ns-aliases I copied from that github issue.#2020-06-1011:13AronShould I share the full config file?#2020-06-1011:17Aronhttps://gist.github.com/ashnur/ac3c1950c052f98136d5ea8f4f74f42a#2020-06-1011:20AronI reverted to 0.2.6 devcards and that works fine still, so I am not stuck with this, to be honest, if devcards is this troubling, I think I should move to a different lib that has similar features, I think I saw a couple.#2020-06-1011:56thhellerworkspaces is nice#2020-06-1011:58thhellerthe devcards thing I about getting :bundle to work I think. there isn't really any clear guidance on how that is supposed to work with foreign-libs in regular CLJS yet. not sure how that will turn out.#2020-06-1012:04Aronworkspaces is the one I remember clearly as an alternative, yes. I am all for reducing configuration. When I have to use undocumented config options to make something work, that's exactly when I know my colleagues will complain.#2020-06-1012:05AronI think I saw it somewhere mentioned that you also don't want to encourage people using ns-aliases, I suspect that's the reason I couldn't find it. Or that I missed it, but it's there, which is always an option : )#2020-06-1012:27rickmoynihantrying to debug why I’m getting a “No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.” message from shadow-cljs. It works in my dev environment, but I’m trying to debug something in my test env, so my app is started up in test mode on a different port.#2020-06-1012:27rickmoynihanI’ve read this: https://shadow-cljs.github.io/docs/UsersGuide.html#missing-js-runtime#2020-06-1012:27rickmoynihanwhich makes sense… but not sure how to debug what is missing#2020-06-1012:28rickmoynihanI can see main.js is served in my test app, and it appears to be the same one that is built for dev app… as moving it causes it to 404#2020-06-1012:35rickmoynihanahh its ok I’ve fixed it#2020-06-1013:17bendlasI'm embedding shadow components with a modularized build as cross - origin. In the dev-setup (containerized hosts), the page tries to load its source-maps from the embedding host, instead of the origin. Probably because shadow loads its code via eval, in this mode. :devtools-url doesn't show any difference either, so I'm creating a route in the embedding service, as a workaround for development. Does shadow also want a ticket for this?#2020-06-1014:05thheller@bendlas I don't quite understand what you are asking. if the eval-loader is a problem you can use :devtools {:loader-mode :script} in your build config to go back to regular script tags or fetch#2020-06-1014:07bendlasthanks for the hint, I'll try that.#2020-06-1014:08jjttjjCan I get the main.js (or other entry js files) javascript source code from the shadow compiler state map after compiling? I can't seem to find where it would be#2020-06-1014:10thheller:devtools-url only really controls the websocket connection. it doesn't have anything to do with how the code is loaded into the page initially#2020-06-1014:11bendlasi figured ..#2020-06-1014:23fabraohello all, is there any project to work with deno? My hard disk is fulled with#2020-06-1014:23fabraonode_modules#2020-06-1014:24thhellerdelete them if you don't need them? 😛#2020-06-1014:24thhellerI mean switching to deno would just give you deno_modules or whatever the name for the directory it uses is#2020-06-1014:25fabraohahah, NOOOO, I want to center all the libs as with .m2#2020-06-1014:25thhellerah, right. forgot it uses a shared cache.#2020-06-1014:26fabraoyes !!!#2020-06-1014:26fabraoeach node_modules take 300 Mb of files#2020-06-1014:27fabraoand besides about the security way that it works#2020-06-1014:27fabraoworks -> deno#2020-06-1014:28thhellerwell security is rather useless given that you need to give all the permissions if you want websocket REPL and hot-reload to work#2020-06-1014:29thhellerdeno is interesting but I don't quite see the point for CLJS given how restrictive it is#2020-06-1014:30fabraomaybe I can use linked folder for a node_module shared#2020-06-1014:30fabraodo you know if any1 tried this?#2020-06-1014:31thhellerno clue. I barely use any node_modules myself anymore.#2020-06-1014:32fabraowell, how do you use with shadow-cljs?#2020-06-1014:32fabraoand package.json?#2020-06-1014:39Arondo you have many of these 300mb node_modules? I think I got to some GBs in all my repos together, but it's not terribly overwhelming, not even on a smallish laptop ssd#2020-06-1015:01fabrao@ashnur I have many projects that use node_modules, and I heard about deno.#2020-06-1015:01fabrao@ashnur I have many projects that use node_modules, and I heard about deno.#2020-06-1016:24Aronhave you heard about tink? https://github.com/npm/tink#2020-06-1021:41fabraoHello, have you tried?#2020-06-1106:50AronNo, because at the time I heard about it was at the very beginning. I didn't realize that the development seemingly stopped last year.#2020-06-1015:12bendlasSwitching to the script-loader actually made it worse, because now it attempts to load the scripts from the first party host as well, and also trips over my :asset-path "/" config XD So when embedding {:tag :script, :attrs {:src "<http://shadow.host/base.js>"}, :content ("</code> into a page from <code>embedding.host</code>\n• eval loader basically works, but can&apos;t find its source maps: <code>DevTools failed to load SourceMap: Could not load content for <http://embedding.host/cljs-runtime/goog.debug.error.js.map>: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE</code>\n• script loader tries to load code from the embedding host, but source maps presumably would work, if that was fixed (and maybe the asset-path issue): <code>GET <http://embedding.host//cljs-runtime/goog.debug.error.js> net::ERR_ABORTED 404 (Not Found)</code>\nI understand, that this may not be a supported use case, yet, so am working around it with adding proxy routes, but if you&apos;d want to support this for shadow, I&apos;d be happy to help with that as well, <span class=\"username\">@thheller</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:14:24.227500Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591802064.227500\" rel=\"nofollow\">15:06:24</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>or am I just missing a config setting? XD</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:28:46.228500Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591802926.228500\" rel=\"nofollow\">15:06:46</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>oh .. I think I might be able to do this with just <code>:proxy-url</code> ... brb, trying</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:36:57.228800Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803417.228800\" rel=\"nofollow\">15:06:57</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>you are missing the correct <code>:asset-path</code> basically <span class=\"emoji\">😛</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:10.229100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803430.229100\" rel=\"nofollow\">15:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>blame the name on CLJS. you can put the entire url in there</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:10.229100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803430.229100\" rel=\"nofollow\">15:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>blame the name on CLJS. you can put the entire url in there</p></p></span></div><div class=\"message thread-msg\" id=\"inst-2020-06-10T18:41:52.230000Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803712.230000\" rel=\"nofollow\">15:06:52</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>oh, I didn&apos;t know that, thanks!</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:37:57.229900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803477.229900\" rel=\"nofollow\">15:06:57</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>why are you serving the files from a different host though? its just static files, whyt not just serve them from the regular host?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:44:48.231400Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591803888.231400\" rel=\"nofollow\">15:06:48</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>to do with our current deployment structure and an in-progress refactoring, where we use shadow modules in a legacy application</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T18:50:40.234300Z\"><a class=\"message_profile-pic\" href=\"/team/U0FSKA94Z\" style=\"background-image: url(https://avatars.slack-edge.com/2017-08-16/226817332337_b0cc8f5304f170e6116c_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U0FSKA94Z\">bendlas</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591804240.234300\" rel=\"nofollow\">15:06:40</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>but OTOH, legacy has just the loader stubs, which don&apos;t change that often and there hardly a case for not including these advanced-compiled, even during development, so your idea is probably still the better one ... I&apos;ll go with that.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T20:54:53.238200Z\"><a class=\"message_profile-pic\" href=\"/team/U083D6HK9\" style=\"background-image: url(https://avatars.slack-edge.com/2019-07-17/697988944069_29e7fb533f304a8bc61a_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U083D6HK9\">kenny</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591811693.238200\" rel=\"nofollow\">17:06:53</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>Is there some documentation that enumerates all of the keywords and their definitions available in shadow-cljs.edn?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T21:13:13.239200Z\"><a class=\"message_profile-pic\" href=\"/team/U083D6HK9\" style=\"background-image: url(https://avatars.slack-edge.com/2019-07-17/697988944069_29e7fb533f304a8bc61a_48.jpg);\"></a><a class=\"message_username\" href=\"/team/U083D6HK9\">kenny</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591812793.239200\" rel=\"nofollow\">18:06:13</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>If an <code>index.html</code> exists in the shadow http server root paths and <code>:push-state/index</code> is set to <code>other-index.html</code>, shadow will still serve <code>index.html</code> by default, not <code>other-index.html</code>. Is this the desired behavior?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T22:35:33.239900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591817733.239900\" rel=\"nofollow\">19:06:33</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><span class=\"username\">@kenny</span> I guess that could be considered a bug. index.html always is picked first since it is picked way before the push-state handler is ever called.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T23:52:55.242100Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822375.242100\" rel=\"nofollow\">20:06:55</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>Not sure if this is already know/reported, but I&apos;m trying out shadow-cljs 2.10.5. I have a cljs browser repl open, when I eval an aliased ns I get Invalid keyword error:\n<pre class=\"highlight\"><code>; in ns form: (:require [com.fulcrologic.fulcro.application :as app])\n (-&gt; app1 ::app/runtime-atom)\n\n(-&gt; app1 ::app/runtime-atom)\ndummy.cljs [line 1, col 28] Invalid keyword: ::app/runtime-atom.</code></pre>\nTried using 2.9.8 and there is no issue there</p></p></span></div><div class=\"message\" id=\"inst-2020-06-10T23:59:40.242300Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822780.242300\" rel=\"nofollow\">20:06:40</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>this is from a cljs file</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:01:24.242700Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591822884.242700\" rel=\"nofollow\">21:06:24</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>which ns are you in? try <code>::foo</code> to see if its the one you expect?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:14:01.243200Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823641.243200\" rel=\"nofollow\">21:06:01</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><pre class=\"highlight\"><code>(println ::foo)\n (println (keys (app/fulcro-app)))\n (println ::app/hi)\n\n;; repl window:\n(println ::foo)\n:app.devcards-play/foo\n=&gt; nil\n(println (keys (app/fulcro-app)))\n(:com.fulcrologic.fulcro.application/id :com.fulcrologic.fulcro.application/state-atom :com.fulcrologic.fulcro.application/config :com.fulcrologic.fulcro.application/algorithms :com.fulcrologic.fulcro.application/runtime-atom)\n=&gt; nil\n(println ::app/hi)\ndummy.cljs [line 1, col 18] Invalid keyword: ::app/hi.</code></pre></p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:15:20.243400Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823720.243400\" rel=\"nofollow\">21:06:20</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>weird</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:15:58.243900Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823758.243900\" rel=\"nofollow\">21:06:58</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>can you try again with <code>shadow-cljs cljs-repl app</code> (or whatever your build id is)</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:16:08.244100Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823768.244100\" rel=\"nofollow\">21:06:08</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>I assume this is over nrepl?</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:16:15.244300Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823775.244300\" rel=\"nofollow\">21:06:15</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>yep</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:17:06.244600Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823826.244600\" rel=\"nofollow\">21:06:06</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>ah nvm. got it reproduced.</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:17:10.244800Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591823830.244800\" rel=\"nofollow\">21:06:10</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>ah kk</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:23:05.245000Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824185.245000\" rel=\"nofollow\">21:06:05</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>fixed in master</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:23:20.245200Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824200.245200\" rel=\"nofollow\">21:06:20</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>probably won&apos;t make a release today though</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:27:47.245600Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591824467.245600\" rel=\"nofollow\">21:06:47</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>awesome, thanks - no worries I am working around it</p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:48:07.246500Z\"><a class=\"message_profile-pic\" href=\"/team/U05224H0W\" style=\"background-image: url(https://secure.gravatar.com/avatar/76114b0ba3de5ac406bce99741dda6e1.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0021-48.png);\"></a><a class=\"message_username\" href=\"/team/U05224H0W\">thheller</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591825687.246500\" rel=\"nofollow\">21:06:07</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p><span class=\"username\">@danvingo</span> released <code>2.10.6</code> with the fix. too tired to work on the other thing anyways <span class=\"emoji\">😛</span></p></p></span></div><div class=\"message\" id=\"inst-2020-06-11T00:58:26.246700Z\"><a class=\"message_profile-pic\" href=\"/team/U051V5LLP\" style=\"background-image: url(https://secure.gravatar.com/avatar/26d9d40cf3244ebaa2cd324547a650cb.jpg?s=48&amp;d=https%3A%2F%2Fa.slack-edge.com%2Fdf10d%2Fimg%2Favatars%2Fava_0002-48.png);\"></a><a class=\"message_username\" href=\"/team/U051V5LLP\">dvingo</a><span class=\"message_timestamp\"><a href=\"/shadow-cljs/2020-06-10/1591826306.246700\" rel=\"nofollow\">21:06:26</a></span><span class=\"message_star\"></span><span class=\"message_content\"><p><p>lol thank ya</p></p></span></div></div></div></div></body></html>")}#2020-06-1119:25Rebecca Bruehlmanreposting from #reagent as I'm wondering if this is a shadow-cljs issue: I have the following bit of code to create a datepicker:
(ns ui.components.picker.core
  (:require ["@material-ui/pickers" :refer [TimePicker DatePicker MuiPickersUtilsProvider]]
            ["@date-io/moment" :as MomentUtils]
            [ui.utils.core :as utils]
            [reagent.core :as reagent]))

(def component-styles {})
(def component-props {:inputVariant "outlined" :fullWidth true})

(defn date-picker-real [props & children]
  (let [all-props (-> component-props (merge props))]
    (utils/->component DatePicker all-props
                       :styles component-styles
                       :children children)))

;; Call this datepicker from the UI; really it's just wrapping the actual DatePicker component with the MuiPickersUtilsProvider, which is necessary to get this all to work.
(defn date-picker [props & children]
  [:> MuiPickersUtilsProvider {:utils (reagent/as-element MomentUtils)} [date-picker-real props children]])
This works well if I compile to a browser target. But when I compile to npm module, I get error messages like the following:
VM53713 react_devtools_backend.js:6 Warning: Failed prop type: Invalid prop `utils` of type `object` supplied to `MuiPickersUtilsProvider`, expected `function`.
    [. . .]
Uncaught TypeError: Utils is not a constructor
    at eval (useUtils-cfb96ac9.js?2ccd:11)
    at mountMemo (react-dom.development.js?61bb:15442)
    at Object.useMemo (react-dom.development.js?61bb:15738)
    at useMemo (react.development.js?72d0:1521)
    at MuiPickersUtilsProvider (useUtils-cfb96ac9.js?2ccd:10)
    at renderWithHooks (react-dom.development.js?61bb:14803)
    at mountIndeterminateComponent (react-dom.development.js?61bb:17482)
    at beginWork (react-dom.development.js?61bb:18596)
    at HTMLUnknownElement.callCallback (react-dom.development.js?61bb:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?61bb:237)
Seems strange the behavior would change depending on compilation method, so wondering if I might be missing something?
#2020-06-1119:27lilactownthe module resolution might change depending on the config#2020-06-1119:27lilactowncan you log what MomentUtils is in the npm build?#2020-06-1119:37Rebecca Bruehlman@lilactown do you mean something like (js/console.log (reagent/as-element MomentUtils)) ?#2020-06-1119:37lilactownremove the as-element… what is MomentUtils? we need to know#2020-06-1119:41thheller@rbruehlman my guess would by the {:utils (reagent/as-element MomentUtils)} isn't correct and that it expects an actual class/function there. so maybe just {:utils MomentUtils}#2020-06-1119:41Rebecca Bruehlmanhere's the object (somewhat truncated... not quite sure how to better format)
Module {__esModule: true, Symbol(Symbol.toStringTag): "Module", default: ƒ}
default: ƒ MomentUtils(_a)
arguments: (...)
caller: (...)
length: 1
name: "MomentUtils"
prototype:
addDays: ƒ (date, count)
date: ƒ (value)
endOfDay: ƒ (date)
endOfMonth: ƒ (date)
format: ƒ (date, formatString)
formatNumber: ƒ (numberToFormat)
getCalendarHeaderText: ƒ (date)
getDatePickerHeaderText: ƒ (date)
getDateTimePickerHeaderText: ƒ (date)
getDayText: ƒ (date)
getDiff: ƒ (date, comparing)
getHourText: ƒ (date, ampm)
getHours: ƒ (date)
getMeridiemText: ƒ (ampm)
getMinuteText: ƒ (date)
getMinutes: ƒ (date)
getMonth: ƒ (date)
getMonthArray: ƒ (date)
getMonthText: ƒ (date)
getNextMonth: ƒ (date)
getPreviousMonth: ƒ (date)
getSecondText: ƒ (date)
getSeconds: ƒ (date)
getWeekArray: ƒ (date)
getWeekdays: ƒ ()
getYear: ƒ (date)
getYearRange: ƒ (start, end)
getYearText: ƒ (date)
isAfter: ƒ (date, value)
isAfterDay: ƒ (date, value)
isAfterYear: ƒ (date, value)
isBefore: ƒ (date, value)
isBeforeDay: ƒ (date, value)
isBeforeYear: ƒ (date, value)
isEqual: ƒ (value, comparing)
isNull: ƒ (date)
isSameDay: ƒ (date, comparing)
isSameHour: ƒ (date, comparing)
isSameMonth: ƒ (date, comparing)
isSameYear: ƒ (date, comparing)
isValid: ƒ (value)
mergeDateAndTime: ƒ (date, time)
parse: ƒ (value, format)
setHours: ƒ (date, count)
setMinutes: ƒ (date, count)
setMonth: ƒ (date, count)
setSeconds: ƒ (date, count)
setYear: ƒ (date, year)
startOfDay: ƒ (date)
startOfMonth: ƒ (date)
constructor: ƒ MomentUtils(_a)
__proto__: Object
__proto__: ƒ ()
property: ƒ (prop, desc)
apply: ƒ apply()
arguments: (...)
bind: ƒ bind()
call: ƒ call()
caller: (...)
constructor: ƒ Function()
length: 0
name: ""
toString: ƒ toString()
Symbol(Symbol.hasInstance): ƒ [Symbol.hasInstance]()
get arguments: ƒ ()
set arguments: ƒ ()
get caller: ƒ ()
set caller: ƒ ()
__proto__: Object
[[FunctionLocation]]: <unknown>
[[Scopes]]: Scopes[0]
[[FunctionLocation]]: index.esm.js?d37f:4
[[Scopes]]: Scopes[4]
Symbol(Symbol.toStringTag): "Module"
__esModule: true
__proto__: Object
#2020-06-1119:42Rebecca Bruehlman@thheller gave that a shot too, and no dice#2020-06-1119:44thhellermaybe you just don't have the correct object? whats the JS example you are basing this on?#2020-06-1119:44lilactownit looks like the npm-module build is resolving it as an ES module. note the "default" key in that object#2020-06-1119:45thheller@lilactown thats incorrect. note the __esModule. that is es module rewritten by babel to commonjs#2020-06-1119:46thhellerbut yeah maybe try ["@date-io/moment" :default MomentUtils]#2020-06-1119:46lilactown@rbruehlman says that it works in browser build, so I have to assume that it resolves to the correct function somehow in that context#2020-06-1119:47lilactownI’m also not convinced that creating an element out of it is correct, but just narrowing down on why you would see different behaviors between different build configs#2020-06-1119:47Rebecca BruehlmanRight, yeah, it resolves in the browser build. I'll try :default and see if it gets me anywhere. I didn't write the code in question, but a JS example would be something to the effect of:
import MomentUtils from '@date-io/moment';
import DateFnsUtils from '@date-io/date-fns';
import LuxonUtils from '@date-io/luxon';
import { MuiPickersUtilsProvider } from 'material-ui-pickers';
 
function App() {
  return (
    <MuiPickersUtilsProvider utils={DateFnsUtils}>
      <Root />
    </MuiPickersUtilsProvider>
  );
}
 
render(<App />, document.querySelector('#app'));
#2020-06-1119:48Rebecca Bruehlmanmy coworker, who wrote the code, said he fought with it for a long while and was only able to get it to work in the browser with (reagent/as-element MomentUtils) in lieu of just MomentUtils , so hence the choice of as-element
#2020-06-1119:50Rebecca Bruehlmanoh, hey, :default worked, with no need for as-element. Interesting quirk. Thanks for the help!#2020-06-1119:52lilactownyeah, as-element would be equivalent to <MomentUtils /> in JS#2020-06-1119:55thhelleryeah the above is using the default export too#2020-06-1120:51rschmuklerHey @thheller - re. your comment on my PR - would you be open to a PR that removes the semvar.js dep and instead uses a CLJ-based implementation?#2020-06-1120:52rschmuklerRelatedly, have you seen https://github.com/grimradical/clj-semver?#2020-06-1120:53thhellerabsolutely. as long as it parses node versions in the same way. no extra dependency.#2020-06-1120:54thhellerthat lib doesn't seem to handle version ranges no uses everywhere?#2020-06-1120:54rschmuklerYeah, I think you're right - just pulled up the shadow code to see what you were using it for now#2020-06-1120:55rschmuklerLooks like we would likely need a re-write#2020-06-1120:55rschmuklerStill, I might take a crack at porting it over since I'm playing with loom for my runtime and GraalVM + Loom looks like a long way out#2020-06-1120:55thhelleryou sure?#2020-06-1120:55thhellerI mean its just a nashorn replacement. doesn't have anything else to do with graal vm#2020-06-1120:56thhellerjust the regular JDK#2020-06-1120:56rschmuklerDefinitely not sure - a bit lacking in my knowledge of Graal nuance. My understanding was that Graal was a special cut of the JVM - I take it that it's not?#2020-06-1120:57thhellerthere is graalvm yes. completely separate and not related to the graaljs scriptengine#2020-06-1120:57rschmuklerAhhh#2020-06-1120:57thhellerwell related yes but not required#2020-06-1120:58thhellerI'm can't possibly force everyone to use graalvm 😛#2020-06-1120:58rschmuklerHaha, indeed, I was wondering how you were going to address it in non-nashorn releases#2020-06-1120:58thhellerits just a regular JVM dependency, no need to switch your entire jvm#2020-06-1120:59rschmuklerWonderful#2020-06-1120:59rschmuklerI will have to look at graaljs a bit more to understand where the boundaries are. Seeing as that there are other JS deps in shadow anyway, porting to graaljs probably makes more sense since it seems unlikely to get off of JS completely, right?#2020-06-1121:00thhellerI wouldn't call it "porting" exactly. Its just adding the extra dependency and switching the name here https://github.com/thheller/shadow-cljs/blob/db38f5968a8ecefcd10cd62412333028ee13959b/src/main/shadow/cljs/devtools/server/npm_deps.clj#L30#2020-06-1121:00thhellerno other changes required most likely#2020-06-1121:01thhellerbut yeah some JS support is still required for the babel stuff#2020-06-1121:01thhellerdon't really want to go back to node for that but could#2020-06-1121:01rschmuklerYes! I was saying that that seems like a better alternative than rewriting semver.js in cljc#2020-06-1121:02rschmukler(ie. porting semver.js to cljc)#2020-06-1121:04thhellerwell I'd still prefer a CLJ impl for that part. bit of a gigantic overhead to launch an entire JS vm for a bit of version parsing#2020-06-1121:04thhellerjust can't be bothered to figure out all the crazy node version strings out there 😛#2020-06-1121:05rschmuklerTotally#2020-06-1121:06rschmuklerI might take a poke at using graaljs since getting that into the project seems like a long-term goal anyway, and it could serve as an easier fix to porting#2020-06-1121:06rschmuklerIf that's something that you'd still be interested in#2020-06-1121:09thhellerthere is really not much to do .. its mostly about testing in a few different JDK versions and so on#2020-06-1121:14thhellerhttps://github.com/graalvm/graaljs/blob/master/docs/user/ScriptEngine.md#2020-06-1121:14rschmuklerPlaying with it now 🙂#2020-06-1121:16thhellerwhy are you trying to use loom with shadow-cljs though?#2020-06-1121:16rschmuklerHahaha, it's indeed a bit wonky#2020-06-1121:18rschmuklerThe long and short of it is that I have cider starting shadow and it seems to use shadow to manage both the clj JVM and the cljs process#2020-06-1121:19rschmukler(and I could be 100% wrong about what cider-jack-in-clj&cljs is actually doing, but as far as I can tell it's starting a JVM and then loading nREPL on the backend, and then starting shadow as java lib, and then starting a second nREPL on the JS side)#2020-06-1121:20thhellerno clue what cider does 😛#2020-06-1121:20rschmuklerThat makes two of us 😉#2020-06-1121:21dpsuttoncan i recommend using cider-jack-in-clj and cider-jack-in-cljs separately?#2020-06-1121:21dpsuttonthe one you are using does expect that the same jvm can juggle both sessions. not usually true with shadow#2020-06-1121:21dpsuttonbut if you check your *Messages* buffer it will say the one command being used to start a jvm#2020-06-1121:22rschmuklerEven if I did use it separately, wouldn't it use the same default java command? ie. won't they be the same JVM runtime version unless I explicitly configure two different runtime paths ?#2020-06-1121:22rschmukler(right now 15-loom is my "default" JDK)#2020-06-1121:24dpsuttonpresumably one will use lein/deps/boot and one will use shadow#2020-06-1121:24dpsuttonsame jvm runtime version and default java command but that seems neither here nor there#2020-06-1121:24rschmuklerBut shadow (the node package) invokes java on the $PATH right?#2020-06-1121:25rschmuklerI might be wrong, but then I would expect that it'd just be two separate processes both running loom anyway - which I think leaves me in the same pickle of needing a nathorn replacement in the JDK-15 based build#2020-06-1121:26thhellerare you using loom as your default JVM? that seems ... brave? 😛#2020-06-1121:26rschmuklerBorderline insane I'd say#2020-06-1121:26rschmuklerBut yeah, I can't resist playing with the concurrency constructs#2020-06-1121:27thhellerjust use JAVA_HOME=~/install/loom clj -m your.loom-stuff?#2020-06-1121:27rschmukleror nix right? 😉#2020-06-1121:27thhellernever used nix before but there are plenty of options to select a different JDK per project 😛#2020-06-1121:27rschmuklerBut none the less, it seems like shadow will need to overcome nathorn disappearing at some point, regardless of how crazy bleeding edge I am#2020-06-1121:28thhelleryes. everything is in place. like I said .. add the dependency and change "nashorn" to "JavaScript". that should be all there is to it.#2020-06-1121:29thhellerI just need to get around testing it a bit more .. which I'll do when jdk15 is actually out and nashorn actually removed.#2020-06-1121:29rschmuklerPlaying with it thus far - looks like there may be additional work to get it to register with the ScriptManager but not convinced that I'm doing it right yet#2020-06-1121:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/project.clj#L143-L144#2020-06-1121:30thhellerdid you add these ttwo?#2020-06-1121:30rschmuklerWell there's my problem 😛#2020-06-1121:31rschmuklerDidn't see the second dep - testing now#2020-06-1121:31thhellerdidn't I also read somewhere that nashorn will be available as regular dep?#2020-06-1121:32thhellerjust like the removed a bunch of stuff after jdk8 and turned it into libs instead? like jaxb?#2020-06-1121:32thhellerdidn't check up on it in a while#2020-06-1121:33thhellerdoesn't really matter ... if all else fails I'll just remove the semver.js ... its annoying anyways#2020-06-1121:33rschmuklerI admittedly have almost no context here. That being said, it seems like graal-js might be the better pick anyway?#2020-06-1121:33rschmuklerThat being said, I use loom, so you can tell that I favor cutting myself on the bleeding edge#2020-06-1121:33rschmuklerlol#2020-06-1121:33rschmukler(ie. comparing whether to introduce the nathorn lib vs the graal-js lib)#2020-06-1121:34thhelleryeah I don't want to get too hyped about loom just yet .. still probably a couple years out right?#2020-06-1121:34rschmuklerJDK 18 I think is what I remember reading#2020-06-1121:34thhellerso 2 years ...#2020-06-1121:35thheller+ another 10 till enough people have it to warrant actually using it in shadow-cljs 😛#2020-06-1121:35rschmuklerBut it's definitely hype worthy. https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ is a fantastic read on why a runtime based scheduler is preferable#2020-06-1121:36rschmuklerYeah I don't know if it'll ever matter in the context of shadow - and definitely a way out. But in terms of what it means for the JVM, quite exciting to see#2020-06-1121:36thhelleroh its absolutely game changing if it actually works 😛#2020-06-1121:36thhellerwe'll see how the performance and stuff works out#2020-06-1121:37rschmuklerI'm curious - why don't you think it would work? Haven't Go and BEAM (Erlang), and to some extent GHC, demonstrated that a run-time based scheduler solution can work?#2020-06-1121:38thhellerwell there is going to be a tradeoff somewhere. this can't be free. either overall performance, GC perf or whatever.#2020-06-1121:39thhellererlang also has a quite different memory/process model which makes this a whole lot easier#2020-06-1121:39rschmuklerIn some initial toy benchmarks I made 5000 HTTP requests simultaneously using both aleph (manifold based, nio) and hato (clj-http mimicing client wrapping JDK 11 http client). Loom was about 2x as fast#2020-06-1121:40rschmuklerI expect that that might have something to do with aleph's default thread pool as it didn't manage to "light up" the cores nearly as effectively as loom#2020-06-1121:40thhellerjust the fact that you don't have to think about thread pools anymore is soo nice 😛#2020-06-1121:40rschmuklerYeah, it's wonderful#2020-06-1121:40rschmuklerAlso, seriously, not leaking deferred / promises all over#2020-06-1121:41rschmukler(or go channels, whatever your concurrency primitive is)#2020-06-1121:41thhelleryeah no go macro anymore. just async/virtual-thread or whatever 🙂#2020-06-1121:41rschmuklersuddenly concurrency becomes caller controlled, not implementing function's responsibility#2020-06-1121:41rschmuklerexactly#2020-06-1121:41rschmuklerCannot wait#2020-06-1121:41rschmuklerlol#2020-06-1121:41rschmuklerI've had it in erlang and haskell, and it's 100% the thing I miss most#2020-06-1121:42rschmuklerAlso, I imagine something like aleph's let-flow which could disect a body of code and automatically parallelize paths#2020-06-1121:43rschmuklereg.
(parallelize
  (let [a (foo)
        b (bar)
        c (+ foo bar)]
   (println "Hello")
   c))
#2020-06-1121:43rschmuklerImagine something that disects the body to run (foo) (bar) and (println) in parallel, and then rejoins on c#2020-06-1121:47thhellerI'm happy with core.async if I can get rid of the go macro. just blocking ops everywhere. already using mostly async/thread in shadow-cljs and its sooo much better than go#2020-06-1121:49rschmuklerYep! Yeah, you still need channels / streams to coordinate execution within. ie. for the same reason I prefer (map f coll) to imperative manipulation, I want ways to operate over queues (eg. stream/map) - but to not have to consider whether something inside those transformations is "blocking" is 😍#2020-06-1121:49rschmuklerAnyway, sorry for nerding out haha. Got the engine working. How should I best test this? JDK 8, 11, 13 and 15-loom sound like an okay checklist?#2020-06-1121:50rschmukler(15-loom is for me, I'll admit it!)#2020-06-1121:51thhellerI mostly care about jdk8 tests#2020-06-1121:52thhellerif that works then all the newer ones should too#2020-06-1121:53thhellernot like the node world were everything breaks constantly 😛#2020-06-1121:55rschmuklerAwesome - I'll test it out on JDK 8 and make sure it works. Also going to add a couple tests (mostly just porting over your semver-intersects comments) just so there's something in case you ever wire up multi JDK CI tests#2020-06-1121:59thhellerI can add a system property or config entry so you can pick which js engine to use#2020-06-1121:59thhellerI'd rather delay switching away from nashorn. not fond of adding extra deps if I don't have to.#2020-06-1121:59thhelleralready have too many#2020-06-1122:00rschmuklerAh, okay. It does considerably cleanup the module to remove nashorn (eg. make-engine* and get-jvm-major-version can be removed)#2020-06-1122:00rschmuklerBut, I tested on open-jdk-8 and all is good either way... So if you don't want that cleanup in the PR let me know#2020-06-1122:02thhellernot interested it making it the default just yet. still want the option to be available though.#2020-06-1122:03thhelleralthough whats another 20mb of deps right? 😛#2020-06-1122:04rschmuklerI mean, shadow isn't exactly light anyway. You're interoping with NPM, etc#2020-06-1122:04rschmuklerMaybe it's just me personally, but I don't expect it to be a lightweight library#2020-06-1122:04rschmuklerlol#2020-06-1122:05thhellerI actually think its fairly light compared to some projects I've seen 😛#2020-06-1122:06rschmuklerNo comment there! I just meant given that it's close to an IDE in some respects, it gets some license in my mind#2020-06-1122:06thhellerstill ... would like it to be smaller 😛 and start faster ...#2020-06-1122:07rschmuklerSo, regarding the changes to the actual file then, if I'm not cleaning up detecting the major JVM version, etc. do you just want a one-liner string substitution + the deps changes + the tests?#2020-06-1122:09rschmuklerhttps://github.com/thheller/shadow-cljs/pull/731 If it's easier to collaborate there (through in the cleanup, but 100% happy to undo it)#2020-06-1122:09thhellerlet me think about this for a bit. too tired to decide now. its either removing all the version check stuff and just using graal or some system property/config entry to control which engine is used#2020-06-1122:09rschmuklerSounds good! I'll just wait for whatever you decide on the PR. Thanks again for all the help 🙂#2020-06-1207:31thheller@darwin you are the chrome extension expert: do you know if there is any way for a chrome devtools extension to talk directly to workers? I mean eval code in a running worker? I can only find things to eval in page?#2020-06-1207:31thheller@darwin you are the chrome extension expert: do you know if there is any way for a chrome devtools extension to talk directly to workers? I mean eval code in a running worker? I can only find things to eval in page?#2020-06-1213:14tony.kay@thheller I’m using latest shadow…it messed with my package.json…why?#2020-06-1213:14tony.kayas in: it did a thing that very likely broke my program#2020-06-1213:18dpsutton“It did a thing”#2020-06-1213:19tony.kay@dpsutton you really think “changed package.json” isn’t enough of a description?#2020-06-1213:20tony.kaygiven the delicate nature of the madness that is npm#2020-06-1213:20tony.kay?#2020-06-1213:21dpsuttonDid it add a dep? Reorder them? Put white space? Remove entries? Chop half the file? Rot 13 it? Just wondering what it did. #2020-06-1213:22tony.kayrunning: yarn add --exact @js-joda//cdn-cgi/l/email-protection#2020-06-1213:26tony.kayI spent some hours getting js-joda working right, and I don’t feel very good about my versions being messed with. I don’t know that this broke something, but it gives me a strong sinking feeling (I now have to go test things to see what might have broken), and is not what I want my build tools doing to me.#2020-06-1213:47tony.kayEsp at 6am before coffee 😜#2020-06-1213:50Andy Heywoodwhat’s the diff of your package.json?#2020-06-1213:51Andy Heywoodlike, it was in state (a), you ran a shadow-cljs cmd, now it’s in state (b) - what’s the difference between a and b, and what command did you run?#2020-06-1213:51DerekI’d assume a cljs dependency you’re using has a deps.cljs file#2020-06-1214:00thheller@tony.kay it will only install dependencies if they aren't already in your package.json but are declared in a deps.cljs in some library you use#2020-06-1214:00thhellerbut there seems to be a caching problem with npm deps I haven't yet figured out https://github.com/thheller/shadow-cljs/issues/727#2020-06-1214:02thhellerbut shadow-cljs will not modify your package.json if the deps are already in there ... you can also set :npm-deps {:install false} in the top level of shadow-cljs.edn. then it won't even do that.#2020-06-1214:07tony.kayah, ok. Good to know there’s a toggle. I figured you had thought it through…just a little jarring.#2020-06-1214:08thhellerwhat is exactly? I mean the JS dep seems to be required right? do you want to install it yourself and have your app break?#2020-06-1214:08tony.kayin this case js-joda is moving from non-scoped to scoped names#2020-06-1214:08tony.kayand the whole mess seems a bit fragile#2020-06-1214:09tony.kayso if someone declares the scoped one and I am using unscoped, it gets scary#2020-06-1214:09thhellersure I get that ... but I also don't see how shadow-cljs is at fault here? 😛#2020-06-1214:10tony.kaynow that I think of it, I upgrade shadow at the same time as some other libs…so it was certainly one of those libs that did it to me 😛#2020-06-1214:10tony.kayit’s early…I thought perhaps your new inspect tool wanted something in package.json or something#2020-06-1214:11thhellerdon't you have your package.json in git? I mean what exactly happened should be easy to tell no?#2020-06-1214:11tony.kaybut it was the first time I saw it auto-change packge.json as well#2020-06-1214:11thhellerinspect doesn't have any JS deps#2020-06-1214:11tony.kayit changed js-joda from unscoped to scoped and bumped the version#2020-06-1214:12thhellerIt certainly won't change. It may add.#2020-06-1214:12tony.kayoh wait…actually, I think you’re right…I think I ended up with both#2020-06-1214:12tony.kaywhich was even a bit more scary, since this is js-land#2020-06-1214:13thhellerwell that wouldn't be any different in JVM land either if you add a dep under a different name#2020-06-1214:13tony.kaywell, but in js-land I don’t trust that package authors keep things out of the global space…so then I’m not sure what I have#2020-06-1214:14tony.kaylike I said: not sure that anything broke, but just so very tired of the js ecosystem’s fragility#2020-06-1214:14thhellerwell its actually not that common that things end up in global somewhere but you may be passing non-scoped things to other things that expect the new scoped things#2020-06-1214:15thhellerso that would be a problem but the origin seems to be in some other dep you bumped as well as shadow 😛#2020-06-1214:15tony.kayyeah, like I said, it was just a combo of that (changed versions on mulitple things at once), and it being the first time I’d noticed shadow changing my package.json#2020-06-1214:16tony.kaywell, and it being 6am after getting woken up at 3am 😕#2020-06-1214:17thhelleryeah, but the behavior is safe IMHO. add the dep only if it is not already listed, otherwise leave it alone.#2020-06-1214:17thhellerbut yeah I'm not a fan of :npm-deps in deps.cljs at all ... but also have no better ideas 😛#2020-06-1214:17tony.kayCool. js-joda has add-ons (like locales) that seem to plug into the base, so changing from non-scoped to scoped seems like potential breakage.#2020-06-1214:17thhellermaybe just a build error would be safer#2020-06-1214:17tony.kayhaving both seems insane#2020-06-1214:18tony.kayand the whole js-joda thing seems in flux…like not everything is ported yet#2020-06-1214:18tony.kaybut yeah, in the past I’ve been perfectly happy with a build error like “react-dom” not found. Is it in your package.json? That’s what shadow used to do, right?#2020-06-1214:19thhellerthe :npm-deps behavior is reaaally old. it always worked like that. the only thing I added recently is the ability to turn it off.#2020-06-1214:20tony.kayit was added during that SoC thing, right? I think Antonio was involved as well?#2020-06-1214:21tony.kayI thought you had to turn it on…didn’t realize it had been on all this time. esp since I’ve seen any number of compiler errors about things missing from package.json over the years#2020-06-1214:21thhellerhttps://github.com/thheller/shadow-cljs/commit/83ee468855725667c9a6407d72fc8b23cb661327#2020-06-1214:21thheller3 years ago .. so really not that new 😛#2020-06-1214:21tony.kayLove it: “[WIP] :npm-deps, still not a fan”#2020-06-1214:21thhellerno this case of :npm-deps has nothing to do with the :npm-deps in CLJS#2020-06-1214:23thhellerits just about installing deps nothing more#2020-06-1214:23thhellerotherwise libs can't declare their npm dependencies anywhere#2020-06-1214:24thhellerits also how it works in CLJS normally nowadays. it just used to do a bit more.#2020-06-1214:25tony.kayah, for someone that helped you with the book and has been maintaining cljc libs for 5 years…you’d think I’d have caught up on this one 😄 So, the deps.cljs was your invention, and now adopted in regular Clojurescript? That was never clear to me. I just remember trying that early mess in stock cljs builds where it tried to do the backflips with npm.#2020-06-1214:26thhellernot my invention no#2020-06-1214:26tony.kaythat was so horrible that I just glazed over any time I see :npm-deps#2020-06-1214:26thhellerjust used to do more than one thing in regular CLJS. In shadow-cljs it only ever had one function.#2020-06-1214:27tony.kayI see…thanks for catching me up. I’ve been avoiding this topic ever since I tried to get that mess to work 4-5 yrs ago (before I discovered shadow). Been happy with the “manually manage package.json, and fix it when shadow tells me to”#2020-06-1214:31thhelleryeah I guess its not nice to sneakily install new dependencies like this#2020-06-1214:32tony.kayI’m not a huge fan of convenience that can bust my stuff 😄#2020-06-1214:32tony.kaybut opt-out is fine#2020-06-1214:57Wilson Velezcan I use the same code base for two targets? :browser and react-native? or they are two completely different worlds?#2020-06-1216:37David PhamCan webworkers connect to shadow CLJS dev server on 9630? So that we can tap> with them as well?#2020-06-1216:44thheller@neo2551 they should already do that yes.#2020-06-1216:45thheller@wvelezva thats fine yes. depends on how you want to organize the code I guess. I know some people prefer to keep it in one project and others prefer to split.#2020-06-1216:45David PhamCool! It makes it easier to use them haha. I wonxer if we could even hook re-frame-10x to them.#2020-06-1314:59mokrHi, I’m looking for a quick hint in case this sounds familiar: My reloading works in the sense that terminal states “Build completed. (415 files, 2 compiled, 0 warnings, 0.66s)“, HUD in browser informs that reload occurred, but nothing actually changed (what I did was adding a Reagent [:h1 “foo”] element to page). Browser console stated “shadow-cljs: reloading code but no :after-load hooks are configured!“, but in general there’s nothing I want to do after load. What am I missing here? 🤔 Background: I’m moving a somewhat large project to shadow-cljs. It’s a “re-frame project” based on a Luminus template from 2017, and it has been using lein-figwheel up until now. I just went for the transition and it was a lot smoother than I feared, and it even pointed out quite a few bug along the way. Any ideas?#2020-06-1315:19mokrCode is served by the Immutant based web server created by the mentioned Luminus template. I see that when I change the config in shadow-cljs.edn, my Reagent/Hiccup are propagated to browser.#2020-06-1315:30thheller@mokr you need to actually trigger the re-render yourself. thats what the hooks are for. see https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-06-1315:30thhellerI believe in figwheel its the :on-jsload option in your config#2020-06-1315:32mokrThanks, @thheller this is the kind of pointer I was looking for. Now I need to do some more reading.#2020-06-1315:33thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2020-06-1315:38mokrI’m actually in the process of reading the complete docs, and was reading that chapter just now. I think the main problem for me is that I have “outsourced” quite a bit of the setup/plumbing to Luminus. That has been serving me very well, but when I now sit down and want to do shadow-cljs from scratch I miss some details, I guess. Anyway, thanks again.#2020-06-1315:39thhellerfigwheel works the exact same. you tell it what it should call when its done loading and it does.#2020-06-1315:39thhellerjust look for :on-jsload in your config. you maybe never noticed it when your template generated it 😛#2020-06-1315:40mokrYeah, I see that now, as I noticed the :on-jsload in my config.#2020-06-1315:40mokrSpot on#2020-06-1315:40thhellerbut yeah seems like a good idea to understand your setup fully 🙂#2020-06-1315:42mokrI think that is always a benefit, but as a on-man-show I had to prioritise other tasks. I believe that was the right thing to do at the time, but it does bother me to not understand better why it works.#2020-06-1315:43mokrBTW: Is shadow-cljs working well in Docker? Issues with reload time for lein-figwheel in docker is actually what pushed my to finally start on the transition. Docker as a DEV environment, that it.#2020-06-1315:44thhellerno clue. never tried it. 😛#2020-06-1315:45mokrOk, I guess I will find out soon enough. It’s not a dealbreaker, at all, but it would be nice to be able to run dev in the same environment as production.#2020-06-1315:45thhellerI certainly hope you are not running shadow-cljs in production#2020-06-1315:46mokrNo! :)#2020-06-1315:49mokrIt would just feel nice to be able to fire up a working dev environment based on a docker-compose stack, and run the production code in a kind of pre-prod sense locally.#2020-06-1315:50thhellerI know that file-watching used to be a problem and that the default didn't work. so you had to use the polling watcher instead which is quite a bit slower.#2020-06-1315:51thhellerno clue if that is still current though. was like 2 years ago the last time someone asked#2020-06-1315:52mokrThat is exactly what I was spending my time on yesterday. Still an issue on MacOS as far as I can see.#2020-06-1315:53thheller:fs-watch {:watcher :polling} in shadow-cljs.edn will enable the polling watch#2020-06-1315:54thhellerhttps://github.com/thheller/shadow-cljs/issues/210#2020-06-1315:54mokrNice, thanks. But what kind of user experience should I expect from this? What’s the drawback?#2020-06-1315:54thhellerFeb 26, 2018 been a while 😛#2020-06-1315:54thhellerI have no clue. I never tried it. I barely ever use docker.#2020-06-1315:56mokrIn a sense I would say you are missing out on something quite useful, but I don’t know what you are doing apart from shadow-cljs 😀#2020-06-1315:56thhelleroh I looked into it a while ago and it is just annoying to me 😛#2020-06-1315:57thhellerit certainly does have its uses ... just don't see any for local development 😜#2020-06-1315:58mokrOh, for me it was quite the opposite. At least I did see something that would fit in my “toolbox” and solve real problems at work.#2020-06-1315:58thhelleryeah if you want to run a database or so sure#2020-06-1315:59thhellerlike you said .. emulating a server production env is great#2020-06-1315:59thhellerbut shadow-cljs is not part of that stack so I have no interest in putting it into docker 😛#2020-06-1316:00thhellertreat the output just like your production env. static files served by some webserver. thats great.#2020-06-1316:00thhellerdoesn't mean shadow-cljs also has to run in that env#2020-06-1316:02mokrThe local dev thing was driven mostly by frustration that “lein new luminus myproject +re-frame ….” stopped working locally on my Mac. For shadow-cljs dev the great thing would be that everything is wrapped up in something that works. No local setup apart from Docker.#2020-06-1316:03thhellersure if that works for you go ahead and do it. I know its not for me.#2020-06-1316:05mokrAs it looks right now, it won’t be my go to solution either. CPU usage and delays will not be as good as I would want. But, I think I will still try it out jut for fun. 😊#2020-06-1316:09mokrWhile we are at it; What about the Clojure side of things? I’m looking into deps.edn, but I haven’t decided what to do about handling dependencies, running the Clojure based backend in dev and generating the executable jar used in prod. Any tips?#2020-06-1316:39mokrAnd just to confirm; Adding ^:dev/after-load to the function called by figwheel’s :on-jsload solved my initial issue. Thanks for taking the time @thheller, I really appreciate it! 😊 I’m confident that I will be in a way better position when this transition is done. My previous experience with shadow-cljs + D3.js code in plain JS was really pleasant, so I can probably reduce the complexity of the codebase going forward (D3 code is currently cljs)#2020-06-1317:49thhellerCLJ stuff I still use lein. works well for me, does everything I need.#2020-06-1320:14Gleb PosobinI am building a chrome extension with shadow, and it for some reason adds one of the background scripts into the content_scripts entry in manifest.json, and I can't understand why. That script's ns appears in requires only in two other namespaces, neither of which are content scripts: one is the main background ns, the other is the options page for the extension, neither of them is require'd in any other namespace and they don't appear in the content_scripts list in manifset.json. mount/start for some reason picks up on the states defined in that background namespace and tries to start them when starting the content script. Is there a way to determine why it is being added?#2020-06-1320:22thhellerwell its your ns :require controlling all of this but no there is easy visualization or so for this#2020-06-1320:22thhellerbeen meaning to replace the old variant I had for this once but didn't get to it yet#2020-06-1320:27Gleb PosobinIt is also the fourth entry from the bottom of the content_scripts list. I assume the files there are in topological order there (?), and the ones after it are shadow.module.bg-shared.append.js, ampie.content_script.content.js (my content script ns) and shadow.module.content-script.append.js, that background script is referenced in neither of them.#2020-06-1320:29thhellerthis is all a bit too abstract for me to follow#2020-06-1320:32thhellernote that ALL dependencies count when determining where something ends up. so you content scripts might not require something from the background directly#2020-06-1320:32thhellerbut another ns the content script uses might?#2020-06-1320:33Gleb PosobinI'll double check, but the files that require that ns are themselves not included in content_scripts list.#2020-06-1320:37thhellerI honestly can't remember much about the chrome extension stuff#2020-06-1320:37Gleb PosobinI removed the reference to it from the ns that is compiled as :chrome/single-file and that entry disappeared from the content_scripts.#2020-06-1320:38Gleb PosobinSo all the dependencies of single-file targets are added to content_scripts?#2020-06-1320:39thhellersingle-file is standalone yes#2020-06-1320:40thhellerthis is all based on :modules and sharing as much code as possible#2020-06-1320:57Gleb PosobinWhat do you mean by sharing as much code as possible?#2020-06-1320:58Gleb PosobinSo the thing seems to be: ns in question is required in a background script and in a single-file script. If I remove the require from either one of those places, it disappears from content_scripts list, otherwise it is added there (unnecessarily, since it isn't required in any content scripts even indirectly). I created a new ns and required it in those two namespaces, the same behaviour repeated.#2020-06-1321:00Gleb PosobinSo shadow is trying to put the namespaces that appear as dependencies several times into the content_scripts list?#2020-06-1321:21thhellerI cannot help if you don't share details#2020-06-1321:21thhellerI need a reference of some kind. this is all too abstract.#2020-06-1321:23thhellerI also honestly can't remember much of the details of the chrome ext stuff#2020-06-1321:25Gleb PosobinOk, I'll try to make an example later.#2020-06-1401:55valeraukoi'm running shadow-cljs in electron and i can't figure out what would be a good contentsecuritypolicy header. anyone has a working example maybe? i don't use any non-local resources#2020-06-1402:39rbergerI am running my target browser app on Safari on iOS. shadow-cljs works fine with that in regular http defaults. But I have to run the page with SSL/HTTPS. because I’m testing out webRTC stuff which requires the page be served with SSL. I successfully get shadow-cljs to serve the page with ssl/https but the websocket errors out. I’ve tried: • Just adding :ssl {} • Adding:
:ssl {} 
 :http {:port 9630 :host "discovery.local"}
• Adding:
:ssl {} 
 :http {:port 9630  :ssl-port 19630 :host "discovery.local"}
In all cases the basic page works but the websocket doesn’t Here is the error from the debugger:
🠶 shadow-cljs: websocket error
Event
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
isTrusted: true
returnValue: true
srcElement: WebSocket
URL: ""
binaryType: "blob"
bufferedAmount: 0
extensions: ""
onclose: null
onerror: null
onmessage: null
onopen: null
protocol: ""
readyState: 3
url: ""
WebSocket Prototype
target: WebSocket
URL: ""
binaryType: "blob"
bufferedAmount: 0
extensions: ""
onclose: null
onerror: null
onmessage: null
onopen: null
protocol: ""
readyState: 3
url: ""
WebSocket Prototype
timeStamp: 1101
type: "error"
Event Prototype

[Error] WebSocket network error: The operation couldn't be completed. (OSStatus error -9807.)
🠶 shadow-cljs: WebSocket disconnected!
#2020-06-1408:32thheller@rberger best option is to enable ssl for shadow-cljs. otherwise you'll have mixed content. https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl#2020-06-1408:32thheller@rberger best option is to enable ssl for shadow-cljs. otherwise you'll have mixed content. https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl#2020-06-1503:48rbergerI did enable ssl as per the docs and it looks like everthing is using ssl, bu the websocket (<wss://discovery.local:9630/ws/worker/app/5010a5c1-8b82-4796-b5ba-1ed7b3358476/4ccf7ba7-f35c-4021-80a5-0f9b2cb292e7/browser>) is still failing. I suspect its something to do with how Apple/Safari does the remote debugger#2020-06-1408:39thheller@vale I'd suggest not using CSP in dev at all so you don't have to worry about it regarding shadow-cljs and then use a proper one for release?#2020-06-1408:39thheller@vale I'd suggest not using CSP in dev at all so you don't have to worry about it regarding shadow-cljs and then use a proper one for release?#2020-06-1422:16rbergerLooks like shadow-cljs 2.10.8 is on clojars but https://npmjs.com has only 2.10.7#2020-06-1422:24mauricio.szaboHi, I updated shadow-cljs yesterday, and I'm getting the message The shadow-cljs Websocket was disconnected more frequently. About two~three weeks ago (last time I upgraded) I could leave the watch process and my node process running while putting my computer to sleep and then keep working on my CLJS, but currently it seems that this is not working anymore...#2020-06-1422:44bedersJust stopped by to say that I love the latest Inspector changes. So easy to sprinkle in a few tap> s to see what is going on. Well done!#2020-06-1500:42mauricio.szaboBy the way: nice job on node target! The console is being redirected to the REPL! Great job @thheller!#2020-06-1509:05thheller@rberger oops. fixed.#2020-06-1509:06thheller@mauricio.szabo which version? I added the reconnect logic in 2.10.7.#2020-06-1513:17mauricio.szabo@thheller Wow, I missed by 0.0.1 😄. It was 2.10.6 (just saw that 2.10.7 is indeed reconnecting). Thanks 😄#2020-06-1517:28frankitoxHi, had anyone struggled with an error like the following while working with the react-native target in Android? > WebSocket connect failed:Expected HTTP 101 response but was '200 OK' I don't have a clue about how to debug such a thing. I'm trying different things like updating shadow to the latest version, destroying/creating a new ADV. I don't get any significant log errors from react-native log-android.#2020-06-1517:31jimberlageWhat step is this at? I think this is a metro bundler issue - it initiates the websocket connection.#2020-06-1517:33jimberlageCould also be a REPL, since that would also initiate the WS connection. The first step when hitting something like is for the server sending websocket messages to give a 101 Switching Protocols message, so whatever process accepts that connection is where to look. I don't think checking on-device logs will get you what you want#2020-06-1517:36frankitoxHuh. It happens once the application starts, after loading it with react-native run-android. Well, the error message also says It was trying to connect to: . I checked with --verbose when running shadow and I see the line Using IP: 192.168.0.62.#2020-06-1517:37jimberlageIs there another process on your machine running on 9630? I'd check to see what process has that port, just to double-check that it looks like something related to react native and not another microservice or some other piece of software#2020-06-1517:38jimberlageA webserver running on that port might return 200 OK for the initial HTTP request used to start a websocket connection#2020-06-1517:46frankitoxThe shadow-cljs web server it's running on that port#2020-06-1517:49frankitoxAlthough I don't know if the device should do the websocket connection with shadow or the Metro thing#2020-06-1517:50jimberlageProbably both - flipper opens a websocket connection to metro to make its displays work, and shadow would open a websocket connection to run the REPL#2020-06-1517:50jimberlageI guess that points to a shadow issue - what version are you using?#2020-06-1517:52jimberlage> flipper opens a websocket connection to metro React native really has a way of making you write some bizzare things. Flipper is react-native-specific devtools software, developed and maintained by facebook#2020-06-1517:54jimberlageAnd metro is a process that watches for changes to JS files in your project, bundles them into one big JS file and transforms the AST to properly reference images and other react native things, and swaps out the JS file used by the react native project on your simulator.#2020-06-1518:02jimberlageI'd try a curl/postman request to GET http://localhost:9630, so that you can see what it responds with#2020-06-1518:02jimberlageBased on the process here: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#Client_handshake_request#2020-06-1518:09frankitoxThank you for all the info, it's very helpful! I'm using latest shadow-cljs (2.10.8). From what you say it looks more likely a problem with shadow. Doing #2020-06-1518:16thheller@franquito no clue why you'd be getting a 200. maybe a proxy of some kind in the middle?#2020-06-1518:18thhellerdoes the UI work at http://192.168.0.62:9630? from your machine and/or the android browser? it also connects to the same websocket location as react-native should? so if that works properly we can rule out shadow-cljs.#2020-06-1518:22frankitoxThe UI works from the machine and the device too. > it also connects to the same websocket location as react-native should? How can I check that?#2020-06-1518:27thhellerbrowser devtools checking if the WS is connected?#2020-06-1518:28thhelleror just the console should log something if it failed#2020-06-1518:29frankitoxOh, yes. The console shows that initial websocket error connection and then logs WebSocket disconnected!#2020-06-1518:29thhellerin the UI?#2020-06-1518:29frankitoxI just disabled debugging and got a different error Error: addEventListener and attachEvent are unavailable.#2020-06-1518:30thhellerplease stay with the browser for now#2020-06-1518:30thhellerdoes the UI work? is it fully functional?#2020-06-1518:31frankitoxThe shadow-cljs UI in http://192.168.0.62:9630/ is working properly. You can even do a force compile.#2020-06-1518:31thhellergood so the websocket isn't the issue its your device connecting#2020-06-1518:31thhellerdo you have more context for the addEventListener error?#2020-06-1518:32thhellernever seen that before#2020-06-1518:33thhellerdon't really know what flipper is either though
#2020-06-1518:34frankitoxYes, sure, these are logs from react-native log-android#2020-06-1518:34frankitox
[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.onJSBundleLoadedFromServer()

[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.recreateReactContextInBackground()
                           │ ReactInstanceManager.runCreateReactContextOnNewThread()
                           └ ReactInstanceManager.tearDownReactContext()

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() start
                           └ CatalystInstanceImpl.destroyV1() start

[15:32:23] I | ReactNative ▶︎ [GESTURE HANDLER] Tearing down gesture handler registered for root view com.facebook.react.ReactRootView{379a637 V.E...... ......ID 0,0-1440,2392}

[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.createReactContext()
                           └ Initializing React Xplat Bridge.

[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge before initializeBridge

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() end

[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge after initializeBridge

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.runJSBundle()
                           │ ReactInstanceManager.setupReactContext()
                           │ CatalystInstanceImpl.initialize()
                           └ ReactInstanceManager.attachRootViewToInstance()

[15:32:24] D | ReactNative ▶︎ ReactInstanceManager.createReactContextInBackground()
                           └ ReactInstanceManager.attachRootViewToInstance()

[15:32:25] E | ReactNativeJS ▶︎ Error: addEventListener and attachEvent are unavailable.

[15:32:25] I | ReactNativeJS ▶︎ Running "NewApp" with {"rootTag":61}

[15:32:25] E | ReactNativeJS ▶︎ Invariant Violation: "NewPibe" has not been registered. This can happen if:
                             │ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                             └ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

[15:32:25] I | ReactNativeJS ▶︎ #4 ready!
#2020-06-1518:35thheller
Invariant Violation: "NewPibe" has not been registered. This can happen if:
                             │ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                             └ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
#2020-06-1518:35thheller[15:32:25] I | ReactNativeJS ▶︎ #4 ready!#2020-06-1518:35thhellerits connected just fine?#2020-06-1518:49frankitoxI can recompile from the UI. Yes, it's strange to get that message about component registration. I will try with a git bisect on my repository. Thanks for all the help! 🙏#2020-06-1518:37thhellerError: addEventListener and attachEvent are unavailable. no clue about this one but the other one above looks like you are maybe calling registerComponent with the wrong name or not at all?#2020-06-1519:56frankitoxThe problem was a bug on a new version of re-frame, It was already reported https://github.com/day8/re-frame/issues/604.#2020-06-1614:13plexus
[:main] Build failure:
babel failed?
{:file "/home/arne/clj-projects/xterm-sci/node_modules/local-echo/lib/HistoryController.js"}
ExceptionInfo: babel failed?
is there an easy way to see the output from babel?
#2020-06-1614:21thhellerthe server process should be logging more?#2020-06-1614:24thhellerhmm or maybe not. this isn't supposed to fail. maybe try restarting.#2020-06-1615:01plexusno, restart didn't help...#2020-06-1615:03plexusooooh I know what it is... starting shadow from cider which is started from emacs which doesn't have node on its PATH. In the shell I use nvm but emacs doesn't see that.#2020-06-1615:04plexusfigured it out by looking at the nrepl-server buffer#2020-06-1615:10plexusbut... turns out I actually need some changes that aren't released to npm yet. Is there any way to consume npm/js libs off github directly?#2020-06-1615:12thhellernpm allows that yes. can't remember the exact syntax though some like "the-dep":"github:foo/bar" in your package.json dependencies#2020-06-1615:13thhellernpm also takes local dirs. plenty of stuff you can do.#2020-06-1615:15plexusthanks for the pointers, I'll check that out#2020-06-1615:15plexus(no pun intended :P)#2020-06-1621:05thhellerteaser time 😉
(ns demo.esm.a
  (:require
    ["" :refer (copy)]))
#2020-06-1621:22thheller
(ns demo.esm.a
  (:require ["" :as x]))
#2020-06-1621:22thhellerwho needs npm anyways 😉#2020-06-1621:23lilactownw00t!#2020-06-1621:23lilactownis shadow going to emit native ESM?#2020-06-1621:24thhellerin release yes, in development not really. 😛#2020-06-1621:26lilactowntoday I was thinking about how CLJS could be used similar to the latest fashion of JS dev tooling that compile .js/.ts files on demand by a dev server, in combination with native ESM (so you don’t need to bundle)#2020-06-1621:27lilactownit would be terrible for DCE (maybe) but interesting in dev mode#2020-06-1621:27thhellernot interested in that at all. I think its a stupid concept thats easily fixed by better caching ...#2020-06-1621:28lilactownyeah, I think it only really makes sense if you’re actually shipping ESM to prod w/o bundling#2020-06-1621:28thhellerJS world is so obsessed with startup time ... which is something we'll never win in anyways so I don't care 😛#2020-06-1621:29cjsauerWhen running shadow-cljs release I’m seeing the following warnings:
npm package "util" expected version "
I did a bit of searching and found this github issue: https://github.com/thheller/shadow-cljs/issues/547 with the quote: > It is quite intentional that it does not follow standard node resolve rules since I will never allow having multiple versions of the same dependency in one build (which happens regularly in webpack builds with nested node_modules dirs). I understand the rationale, but I’m not clear on how I would go about resolving conflicts like the one above, which seem like they’d be rather common. I could use :js-package-dirs to force the search path to include the newer version of uuid for example, but then the warnings would just swap to another conflict saying that uuid was too new.
#2020-06-1621:29lilactownwell if we were willing to chop up cljs.core more… maybe we could get there 😛#2020-06-1621:31lilactownif records + tuples make it past TC39 in a reasonable state, there might be an opportunity to move our bespoke data structures to a lib and use native immutable data in core#2020-06-1621:31thheller@cjsauer if the versions are incompatible then you are out of luck. I will not support having 2 versions of the same dep loaded.#2020-06-1621:38cjsauerGotcha. I believe I can get around this using :js-package-dirs option in this specific circumstance.#2020-06-1621:39thhellerno you really can't 😛#2020-06-1622:15cjsauerYea you’re right, :js-package-dirs is not what I need. In my specific circumstance i have a big monolith project. I can split the monolith in a way that would avoid these conflicts altogether. #2020-06-1621:31thhellerrecords and tuples to absolutely nothing for the data structures we use?#2020-06-1621:32thhellerI'll never give up :advanced so I don't really care about turning cljs.core into a shareable ESM "library"#2020-06-1621:33lilactownlike I said, if they made it out of TC39 in a reasonable state 😛 records are almost enough like maps, and tuples almost enough like vectors, that it makes me want to use them as replacements#2020-06-1621:37thhellerthey aren't even remotely close to comparable#2020-06-1621:37thhellerrecords compare to defrecord maybe but not to maps#2020-06-1621:38thhellertuples for small vectors maybe, not with many members#2020-06-1621:40lilactownhm, what’s the correlation you’re making to defrecord? and why would tuples be more akin to small vectors?#2020-06-1621:40lilactownFWIW I’m talking about https://github.com/tc39/proposal-record-tuple#2020-06-1621:43lilactownthe proposal is pretty different from any of the immutable data that CLJS has anyway, and they seem dismissive of ideas that would make them more general purpose#2020-06-1621:44thhellergranted I know nothing about how they are planning to implement it#2020-06-1621:44thhellerbut I doubt very much they are going with the HAMT route clojure uses#2020-06-1621:44thhellerso records just look like syntax sugar over object/arrays#2020-06-1621:44thhellerjust like tuples#2020-06-1621:44thhellerlike any other language with those concepts#2020-06-1621:46thhellerso records aren't anything like generic maps#2020-06-1621:46lilactownyeah I imagine it will vary by the implementation#2020-06-1621:47thheller> Non-string keys are coerced to strings.#2020-06-1621:47thhellerso absolutely not even remotely close to clojure maps ...#2020-06-1621:47lilactownyeah 😭#2020-06-1621:47lilactownthe big design goal seems to be to enforce the semantic #{a: 1, b: 2} === #{a: 1, b: 2}#2020-06-1621:49thhellerstill probably can't use them as keys in Map in Set though#2020-06-1621:49lilactownwhich, there are many ways of doing that. the solution they’ve chosen is to restrict what can be used as keys and values very tightly to make it easy at the VM level to do that#2020-06-1621:49lilactownI think you can use them as keys in Map and Set , but you can’t do the reverse!#2020-06-1621:51thhelleryeah its really one of the least interesting TC39 proposals .. and most of them are already boring. nothing to get excited about at all.#2020-06-1621:53isakI heard there was a multi-threading thing - was that rejected?#2020-06-1621:55lilactownWeakRefs is the only other one that I would find myself using probably immediately: https://github.com/tc39/proposal-weakrefs#2020-06-1621:56lilactownand that’s only because I’m working on a side project that basically involves writing my own ref counter atm 😝#2020-06-1621:56dpsuttonwhat prompted your need for a ref counter?#2020-06-1621:59lilactowni’m writing my own reactive dataflow lib similar in API to reagent’s ratom/reaction API#2020-06-1621:59lilactownjust for fun#2020-06-1622:00lilactownyou have to keep a reference to any upstream or downstream dependencies in each node to know when to fire, and when to clean up#2020-06-1622:03lilactownweakrefs would basically be an addon to that where I could add a finalizer which detects if a watched node falls out of scope and gets GCd, then I can use that to cleanup any connected nodes that aren’t being listened to anymore#2020-06-1622:55sova-soars-the-soraHi, how can I get shadow-cljs to install clojurescript dependencies? I added them to the :dependencies vector in the shadow-cljs.edn file, but it reports unavailable...#2020-06-1622:57thheller"reports unavailable" - what does that mean?#2020-06-1622:58sova-soars-the-soranevermind, I just restarted it and it updated the dependencies#2020-06-1622:58thhellerah yes, changing :dependencies or :source-paths requires restarting#2020-06-1622:58sova-soars-the-soraright on 😃#2020-06-1623:04sova-soars-the-sora@thheller Works great.#2020-06-1705:13rbergerWe’re requiring a js file like so: ["/graphql/subscriptions" :as subscriptions] It has an assignment like:
export const onCreateBag = 
  subscription OnCreateBag {
...
Works fine in dev, but on release (:advanced) the onCreateBag gets munged to $onCreateBag$: and we can’t really use it as a key. This only became a problem from shadow-cljs 2.9.6 onward. (Same code works in 2.9.6 but not on any version after that including 2.10.9) Is there an easy way to tell shadow not to munge that? The only other thing unusual is the graphql/subscripitions.js is being required from a Clj dependency of another library as a git dependency in deps.edn
#2020-06-1705:14rbergerOn a side note, is there an easy way to run a release build locally without setting up a whole webserver environment?#2020-06-1706:30thheller@rberger what kind of JS is that? am I missing something or is this processed in any way? this isn't valid JS subscription OnCreateBag {?#2020-06-1706:32thhellerwhy do you have pseudo-names activated? or is that just to show that it is getting renamed?#2020-06-1706:33thhellerI'm surprised that it wasn't getting renamed previously. It should always been renamed but if it wasn't that was a bug.#2020-06-1706:33thhellerin which context are you relying on the name? if you are passing the whole ns as an object to something than that is something you shouldn't be doing in the first place#2020-06-1707:39rbergerI just put a snippet for the js. But this evening we re-evaluated what we were doing and realized we didn’t need this in JS and switched it all to clojurescript and EDN. So our problem is solved by removing those JS files and replacing with cljs. The use case was a bit funky. The JS files were being generated by CI from some authoritative schema in one project / repo and we needed to get them on the classpath of other projects/repos. I had built the image with --debug on so it was generating psuedo-names to help us figure out where the problem was originally. The one other JS file that we did need to have (`aws-exports.js`) is importing fine. The main weird thing was it all worked in 2.9.6 and earlier. If you want me to gather any other info, let me know.#2020-06-1707:42thheller@rberger well it should have always worked like it does now. the renaming is intentional. you can add externs to stop the renaming. not quite sure why it wasn't renamed before#2020-06-1707:45rbergerYeah, I was wondering if externs would have been the correct answer if we were to continue with that path.#2020-06-1707:45rbergerIs there an easy way to test release / :advanced compile in the local environment?#2020-06-1707:46thhellerI don't know what your setup is. I run shadow-cljs release whatever locally constantly.#2020-06-1707:46rbergerRight that builds the release, but if I wanted to run it without some other setup?#2020-06-1707:47rbergerIE run it like things run in dev but obviously not with all the interactivity#2020-06-1707:47thhellerI cannot possibly answer that. I design my dev builds to be as close to release as possible so I can just switch between them locally without issue.#2020-06-1707:48thhellerbut I have no clue what your code does so that might not be as easy for you#2020-06-1707:48rbergerI guess I’m asking is there a way to use the shadow-cljs http server to run the release build#2020-06-1707:49thhellerif you just need a static server sure. just run shadow-cljs server seperately and keep it running.#2020-06-1707:49rbergerOk, I’ll play around with that. Thanks#2020-06-1713:14thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2020-06-1713:15thhellerhttps://www.reddit.com/r/Clojure/comments/haqw43/shadowcljs_generating_es_modules_browser_deno/#2020-06-1713:16thhellerhttps://twitter.com/thheller/status/1273243150572826625#2020-06-1720:51rbergerYou mentioned that snowpack was one of the triggers for this. Is there some usable relationship between cljs/shadow-cljs and snowpack for doing cljs development?#2020-06-1713:46Chris McCormick
[shadow.esm :refer (dynamic-import)]
:exploding_head:
#2020-06-1713:47thhellerdon't look at the implementation 😉#2020-06-1714:31sova-soars-the-soraedit: nevermind :D#2020-06-1714:47jaimeHi! I'm using cljs.test and playing with helix and integrating with some npm react library components. 1. How do you run tests in intellij cursive repl when using shadow-cljs? 2. What does it mean by "node REPL"? Is it enough to run tests that needs browser functionality, like simulating click events (I'm not talking about webdriver or opening real browser here. In JS land, there js-dom https://github.com/jsdom/jsdom)? I'm looking into this guides now, but still struggling to digest the content. https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test https://clojureverse.org/t/any-tricks-in-writing-clojure-script-tests/1016/2 PS: I've tried the :browser-test option before, I'm just exploring other option to see which one works well for me.#2020-06-1714:52sova-soars-the-sora@jaime.sangcap Good luck. I'm not sure about incorporating testing into shadow-cljs but i would recommend getting them to run from the command line.. incorporating them into intellij later will be simple (in theory)#2020-06-1716:50haywoodif my project uses deps: true, and my deps file includes a library via :local/root "../lib-name", does shadow handle the installing of that libraries package.json file? I’m trying to figure out how to package and deploy that library for consumption, and unsure if I need to npm install and bundle it. Sorry if the question is super basic#2020-06-1716:59thheller@haywood it does not look at the package.json no. the library can include a deps.cljs with {:npm-deps {"foo" "version"}} in one of its :paths. those will be installed.#2020-06-1816:16Felipe MarquesI was reading about the deps.cljs. How is it added to the JAR? there is any extra step to do it or just using depstar would do it?#2020-06-1816:20thhellerno clue what depstar does. it should just put the file in it automatically, just like any other source file.#2020-06-1816:26Felipe Marquesoh, so it should be inside a folder like src for example?#2020-06-1819:59thhelleryes#2020-06-1921:12Felipe Marquesthanks#2020-06-1717:00haywoodah#2020-06-1717:00haywoodgenius, thanks!#2020-06-1718:02fabrao@thheller
(ns demo.esm.a
  (:require ["" :as x]))
How is that? And about dependencies?
#2020-06-1718:05fabraoshadow-cljs will take care about download it?#2020-06-1718:06thhellerno, your browser does#2020-06-1718:13lilactownhuge 1⃣ on supporting native ESM via CLJS. really glad you’re willing to take on the work to provide us with that, thheller lisphug#2020-06-1718:14thhellerwell not sure if I will take on the compiler rewrite to emit esm directly 😛#2020-06-1718:15thhellerbut this works well enough that it was worth publishing#2020-06-1718:15lilactownof course, but there are measures in between that and not supporting it, like you have already done 😄#2020-06-1718:32Eric Ihli
:modules {:shared
                           {:entries []}
                           :main
                           {:init-fn app.client/init
                            :depends-on #{:shared}}
                           :worker
                           {:init-fn app.worker/init
                            :depends-on #{:shared}
                            :web-worker :true}}
                 :devtools {:after-load app.client/refresh
                            :browser-inject :main
                            :preloads [com.fulcrologic.fulcro.inspect.preload]}}
I'm trying to test out web workers. I'm getting an error with the above because the preload expects to have access to document. Is there a way to preload at the module-level rather than the build-level? I also tried splitting the web worker module into a completely separate build, but that resulted in an error about goog.debug.Error (for example) already being declared. Perhaps the answer is still multiple builds, but there's something else I need to do to limit the output of the web-worker build? Or wrap the preload in something that checks its environment?
#2020-06-1718:40thheller@ericihli just move the :preloads to the :main module. they can be specified per module#2020-06-1721:22thhelleryou can use it to handle npm dependencies instead of shadow#2020-06-1721:22thhellerI mostly like it because it pushes ESM#2020-06-1721:24thhellerand I like what they are doing over what webpack is doing#2020-06-1804:44fabraoHello all, I´m thinking about how to deal with shadow-cljs and server with pedestal serving the index.html ? Is shadow detect server and let it serve index or do I have to use index just for shadow and other index for app? Do you have any reference to using both in the same project?#2020-06-1807:24thheller@fabrao shadow-cljs doesn't care how you serve your index.html. Just use your server like you would in production. Just load the .js files via your pedestal server directly. They are just static files.#2020-06-1812:56fabrao@thheller but how does it works with refresh and repl?#2020-06-1813:06TrevorHi is it possible to turn off hot reloading? Thought I read it could be turned off at the namespace level#2020-06-1813:10TrevorAh found it#2020-06-1813:36p-himikJust ran a build report and noticed something peculiar:
| jar | re_frame/loggers.cljc                                                                 |   -717.0 B  |  -0.17 % |      2.9 KB |      2.2 KB |
Negative size, heh.
#2020-06-1814:14David PhamWhy are ESM useful?#2020-06-1814:15thheller@fabrao hot-reload and REPL are done over the websocket. it is handled separately and your server doesn't need to do anything#2020-06-1814:53thheller@p-himik yeah I saw that before. I'm just using source-maps and sometimes they aren't entirely accurate or I'm maybe counting backwards or something#2020-06-1815:06thheller@neo2551 if you cannot answer that its not useful to you basically. It is useful if you want to integrate with other tools, eg. interfacing with a codebase written in typescript or whatever.#2020-06-1815:06thhellerit doesn't offer anything new and isn't useful if you don't care about interfacing with other code basically#2020-06-1815:07David PhamIt would allow me to expose my libraries to Ts/JS users?#2020-06-1815:07thhelleryes.#2020-06-1815:08David PhamGood, now I know my CLJS code will not be thrown away if anyone refactor my apps with JS xD#2020-06-1815:09David PhamI have to admit that I am missing your blogpost. I always learned something knew when I read them :).#2020-06-1815:10thhelleryeah I didn't make it very clear that this is mostly about intergrating into the greater JS ecosystem#2020-06-1815:11thhellerlike using JS tools, using your code from JS, etc#2020-06-1817:08knubieAfter upgrading to the latest version of shadow-cljs and building a release build, I’m getting this error in the js console:
breadcrumbs.ts:117 shadow-cljs - failed to load 367
(anonymous) @ bundle.min.js:2
13:03:33.676 js.js:75 Uncaught TypeError: $jscomp.initSymbol is not a function
    at Object.shadow$provide.<computed> (index.js:178)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at index.js:2
    at append.js:2
I remember reading about something related to $jscomp in one of the releases, so I figured this might be a known (familiar?) issue. Last version of shadow-cljs I built against was 2.8.90
#2020-06-1819:59thheller@steedman87 which version is this?#2020-06-1820:00knubie@thheller that was 2.10.12. I can open an issue with more details if you want.#2020-06-1820:01thhellera reproducible example would help 😛#2020-06-1820:05knubieI’ll see what I can do. I also had trouble getting source maps working right in Sentry, although they seemed fine in the browser. In Sentry the stack trace seemed to consist of unrelated files / line numbers. Earlier versions of shadow mostly worked, but the line numbers were somewhat off.#2020-06-1820:06thhellercan't do much without reproducible examples 😛#2020-06-1820:10naomarikHey! I tried compiling my project a week ago and ran into the foreign-libs issue. Here https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html this is mentioned I'm happy to provide an interim solution to make the transition easier if someone has a good idea how to do so. Wondering if there any other examples or more docs explaining this transition? I have a few JS libs I'm including in my compiled JS and I'm not using NPM for anything. Would love to give shadow-cljs a try!#2020-06-1820:11thheller@naomarik define "JS libs"? You are using CLJSJS?#2020-06-1820:11naomarikNo just straight up JS files in resources/js#2020-06-1820:12naomarikwell, resources/foreign-libs/*.js 🙂#2020-06-1820:25thhellerwhat kind of files? I mean how did you include them previously and how did you access them?#2020-06-1820:33naomarik@thheller Just normal foreign libs stuff, for example:
{:file "resources/foreign-libs/hammer.min.js"
                 :provides ["hammerjs"]}
then requiring it [hammerjs] in a file and (js/Hammer. (.getElementById js/document "selected-photo") nil)
#2020-06-1820:35thhellercan you paste the file somewhere? does it have the isual commonjs/amd wrapper?#2020-06-1820:35thhellerie. does if have logic for module.exports or so?#2020-06-1820:35naomariknot sure. you want the source cljs file or the hammer js file? hammerjs for example just here: https://github.com/hammerjs/hammer.js#2020-06-1820:37thhellerwell the easiest way is npm install --save hammerjs and (:require ["hammerjs" :as hammer]) and using (hammer. (.getElementById ....))#2020-06-1820:37naomarikya know about that way 🙂#2020-06-1820:38thhellerbut you can also do (:require ["/foreign-libs/hammer.min.js" :as hammer]) and use hammer not js/Hammer#2020-06-1820:38naomarikwould this be compiled in the JS file?#2020-06-1820:39naomarikor would it need to always be explicitly available to fetch#2020-06-1820:39thhellerI don't understand the question. it will load the file from your classpath (so the resources folder) and include it in your build#2020-06-1820:39naomarikoh cool#2020-06-1820:39naomarikthat's exactly what i wanted to hear, will try this now#2020-06-1821:03naomarik@thheller how would I include something like this? https://github.com/blueimp/JavaScript-Canvas-to-Blob I've saved it
npm install --save blueimp-canvas-to-blob
and importing ["toBlob" :as to-blob] but getting The required JS dependency "toBlob" is not available, it was required by "common/file_upload.cljs". calling it with either (.toBlob canvas ... or (to-blob/toBlob canvas ...)
#2020-06-1821:05thhellerblueimp-canvas-to-blob is the package name#2020-06-1821:05thheller(:require ["blueimp-canvas-to-blob" :as to-blob])#2020-06-1821:07naomarikahh thanks so much -- my JS packaging/NPM knowledge still from the days of Yore#2020-06-1822:09naomarik@thheller Got everything working, thanks so much! Just last thing -- has anyone complained about cider completion errors in the repl?#2020-06-1822:09thhelleryes, its broken.#2020-06-1822:09naomarikokay cool#2020-06-1822:13naomarikI feel this is way faster than what I was using before -- lein figwheel 0.5.19#2020-06-1822:41dpsutton@thheller is the change that broke CIDER's completion an accidental change you are going to restore or one that CIDER needs to adjust to the new way in shadow?#2020-06-1822:41thhellerhttps://github.com/rksm/clj-suitable/issues/15#2020-06-1822:42dpsuttonoh. i keep suitable off all the time.#2020-06-1822:42dpsuttoni wonder if autocompletion works with that completion engine off#2020-06-1822:42thhellerthen you might be fine? not actually sure#2020-06-1822:43dpsuttonme either. @naomarik can you check if completions work with (setq cider-enhanced-cljs-completion-p nil)#2020-06-1822:43thhelleronly reports I had were because of suitable.#2020-06-1822:43dpsuttonthanks. i'll see if i can look into this.#2020-06-1822:58naomarik@dpsutton That worked, thanks for that.#2020-06-1822:58dpsuttoni think the suitable stuff is cool in a few situations and breaks more often than not unfortunately. and cljs tooling is crazy hard#2020-06-1823:02naomarikthe only thing I cannot get working now is CSS reloading
:devtools {:watch-dir "resources/public/css"
               :watch-path "/static"}
this is in my build but doesn't seem to do anything when css is changed, no headsup display notification either
#2020-06-1823:03thhellerhow do you access the css in your html?#2020-06-1823:03naomariknginx#2020-06-1823:03thhellerno. under which path?#2020-06-1823:03naomarik1. ah http://localhost/static/css/site/app.css 2. #2020-06-1823:04naomariki've tried all kinds of variations on the watch-path too#2020-06-1823:04naomarikand watch-dir#2020-06-1823:04thhellerok then :watch-dir "resources/public" :watch-path "/static"#2020-06-1823:04thhellerassuming resources/public/css/site/app.css exists and is the file served when you load #2020-06-1823:05naomarikyup it's bbeing served#2020-06-1823:05naomarikokay that worked hehe#2020-06-1823:05naomarikyou've been super helpful, thanks so much @thheller#2020-06-1823:06naomarikbeen changing my build tools all day going from a hobbled combo of lein and boot to deps.edn and now shadow-cljs#2020-06-1823:59Spacemanhow to find the line number of the re-frame code that throws the error:
[Error] Error: ["unrecognized request format: " nil]
	(anonymous function) (re_frame.router.js:6)
	(anonymous function) (re_frame.router.js:359)
	(anonymous function) (re_frame.router.js:425:110)
	(anonymous function) (re_frame.router.js:552)
	(anonymous function) (re_frame.router.js:291)
	(anonymous function) (re_frame.router.js:383)
	(anonymous function) (re_frame.router.js:425:110)
	G__67540 (re_frame.router.js:336)
	(anonymous function) (goog.async.nexttick.js:98)
#2020-06-1900:07cjpotusseHello! I am trying to use the react-bootstrap-table2 ’Export CSV’ functionality and struggling with the dependencies syntax - specifically, how to require ToolkitProvider, CSVExport, and ExportCSVButton. Any tips? import ToolkitProvider, { CSVExport } from 'react-bootstrap-table2-toolkit'; const { ExportCSVButton } = CSVExport;#2020-06-1907:21thhellersee the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-06-1912:47cjpotusseThank you. Doing the following gets me access to ToolkitProvider and CSVExport but I’m not sure how to get ExportCSVButton out of CSVExport. ["react-bootstrap-table2-toolkit" _:refer_ (CSVExport) _:default_ ToolkitProvider]#2020-06-1912:48thheller(.-ExportCSVButton CSVExport)#2020-06-1912:48cjpotusseThank you!#2020-06-1900:55currentoorI'm trying to work on a react native app on an android device via USB but having a lot of trouble. I've disabled fast refresh and don't see an option for live reload or hot code reload in the debug menu. I'm on the latest shadow-cljs release (2.10.12) The app is able to load and make requests to my laptop. But whenever I update some code the app crashes instead of refreshing. If I try connecting to the app's repl I get this (using intelliJ)
Connecting to remote nREPL server...
Clojure 1.10.1
(shadow/repl :pos-bare)
To quit, type: :cljs/quit
=> [:selected :pos-bare]
1
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
In the build section I see the connected runtimes keep getting droped and new ones are created. The logs are also consistent
#17 ready!
#18 ready!
#19 ready!
#21 ready!
Any idea what would cause the connected runtimes to keep getting dropped like that? Also this same code works on my friend's laptop so seems like something specific to my setup.
#2020-06-1902:47currentoorjust verified, repl connecting to an emulator works fine it's just the device that's broken#2020-06-1903:12currentooralso verified i can make requests from the device to the server, but for some reason the runtimes still get dropped
(js/setInterval #(async/go
                   (let [response (async/<! (http/get ""))]
                     (log/spy :warn response)))
  1000)
#2020-06-1903:25currentoorI also followed the instructions here, with the --verbose option i see the ip address is correct and in react-native log-android I don's see anything informative about why the runtime is getting dropped. Just the following
[20:23:16] I | ReactNativeJS ▶︎ #8 ready!
[20:23:39] I | ReactNativeJS ▶︎ #9 ready!
[20:24:05] I | ReactNativeJS ▶︎ #10 ready!
[20:24:28] I | ReactNativeJS ▶︎ #11 ready!
[20:24:52] I | ReactNativeJS ▶︎ #12 ready!
https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native
#2020-06-1907:22thheller@currentoor that looks odd but the timing appears to be the ping/pong timeout#2020-06-1919:46currentoori wounder if perhaps i have a defective device#2020-06-1919:47currentoori tried connecting a websocket from device to my laptop and it kept dropping and re-establishing the connection#2020-06-1919:48currentoorthat said, why does shadow establish a new runtime every time instead of re-connecting the old one?#2020-06-1907:22thhellerif the runtime doesn't respond to pings for about ~20sec it will be kicked by the relay#2020-06-1907:23thhellerthe relay is sending a ping every 5sec when idle and the runtime is supposed to respond#2020-06-1907:23thhellernot sure why it wouldn't?#2020-06-1907:23thhellerbut I also never tested this on an actual device before#2020-06-1907:25thhelleryou can try setting :log {:level :debug} in shadow-cljs.edn but that will likely just confirm that it is indeed kicking because of ping timeout#2020-06-1907:25thhellernot why the client isn't responding#2020-06-1910:20Caseyo/ 'lo there I'm writing a custom target for a resource constrained environment and am trying to figure out the proper compiler options to enable dead code elimination, but disable renaming and whitespace removal. So the code remains readable, but dead code is removed.#2020-06-1910:44CaseyI want this in devel mode. the problem is a basic hello world script is 1.5MB.#2020-06-1910:45CaseyI suspect if I could get a hold of the underlying CompilerOptions object, I could call setRemoveDeadCode(true) on it when using optimizations :none#2020-06-1911:34thheller@ramblurr this isn't going to work for development code#2020-06-1911:35thheller:optmizations :none literally means "do not call the closure compiler at all"#2020-06-1911:36thhellerwhat are you doing exactly? I mean for which environment is this?#2020-06-1911:42CaseyAh 😕 I didn't know that.#2020-06-1911:43CaseyI'm writing a target for the game http://screeps.com#2020-06-1911:44CaseyThe code players right is ES6, but not in a DOM nor a node-like environment. I started with the graaljs target, and customized it. However there is a 2MB code limit on player code, and just cljs+goog is 1.5MB.#2020-06-1911:45CaseyHm, maybe i can filter out the unneeded goog modules in the flush step.#2020-06-1911:53thhellerhmm does it support ESM?#2020-06-1911:53thhellerdo you have a JS example?#2020-06-1911:54thhellerah looks like commonjs. why not :node-library?#2020-06-1911:55CaseyNo ESM support unfortunately. It supports a limited require that has no support for folders.#2020-06-1911:55thhellerthis might not be node but that doesn't really matter#2020-06-1911:56thhelleruse :node-library and shadow-cljs release while shadow-cljs server is running#2020-06-1911:56thhellerthat will make everything small enough so size isn't an issue#2020-06-1911:56thhelleror maybe :npm-module works too#2020-06-1911:57thhellercompile might work for that one but you'll be approaching the size limits pretty fast#2020-06-1911:57CaseyYea, I got it working at first with :node-library (or was it node script? don't remember), in dev and release modes. But in this game you'll need to react on the fly to things happening in the world, and it is very useful to see the un-minified code. You'll often react to some event in game by patching the deployed code, then later bringing those changes back into your codebase.#2020-06-1911:58Casey:release / advanced optimizations makes that all but impossible.#2020-06-1911:58thhellerhmm does it support websockets? might be fun to get in there and use the REPL to tune stuff 😛#2020-06-1911:59thhelleryou could try :simple with :pretty-print#2020-06-1911:59thhellerbut that'll also be close to the max size#2020-06-1911:59Caseythe official game doesn't, but, since its open source, i'm working on a patch to the server to allow WS. That would be useful for testing outside the main official server.#2020-06-1912:00Caseygetting a repl is one of my goals, it would be tons of fun (even if not on the main server)#2020-06-1912:03thheller:simple with just cljs.core is about 1mb. not sure how much code the game code ends up being but that might be fine?#2020-06-1912:05thheller:target :esm would be by far the best option for this .. shame they don't support it 😛#2020-06-1912:22CaseyOooh, yea cljs.core is the heavy item here, not the extra goog libraries#2020-06-1912:27erikwhat is the proper way of creating a DevTools page when developing a Chrome extension?#2020-06-1912:32thheller@eallik maybe https://clojureverse.org/t/generating-es-modules-browser-deno/6116?#2020-06-1912:37erikdevtools_page in the manifest needs to point to an .html page, so I generate an ESM module and then manually include it in that .html page?#2020-06-1912:38thhelleryeah. you can also just use a :browser build though#2020-06-1912:39erikgreat, will try out both#2020-06-1912:42mkarp@thheller Just tried the shadow’s Inspect feature — works great! Thank you :star-struck:#2020-06-1912:56Casey@thheller do you know of any writeups regarding how the cljs repl works?#2020-06-1912:57kwrooijenHello, how do I include dependencies for specific builds? e.g. I want to add re-frisk to my :dev build, but not in my :prod build?#2020-06-1913:39pithyless@thheller not sure how to debug this, but I think there may be some kind of race-condition bug. With the newest  `malli.registry/type` code (that checks for a setting via closure-defines), once in a while (but only after a shadow-server restart) I see the `{:type "default"}` exception (i.e. a missing closure-defines option), but it Just Works™ if I "force compile" the build once in the shadow UI.#2020-06-1913:40pithyless^ Testing with shadow 2.10.10#2020-06-1914:21thhellerwhat is a {:type "default"} exception?#2020-06-1915:03pithylesshttps://github.com/metosin/malli/blob/master/src/malli/registry.cljc#L30#2020-06-1915:04pithylesswhich is dependent on this: https://github.com/metosin/malli/blob/master/src/malli/registry.cljc#L4#2020-06-1915:05pithylessso, it looks like (goog-define type "default") is returning "default" - malli will throw an exception; then I "force compile", type is no longer "default" but "custom" and malli continues without errors#2020-06-1915:06pithylesswhere I'm setting in shadow-cljs.edn: :closure-defines {malli.registry/type "custom"}#2020-06-1915:08thhellerhmm no clue.#2020-06-1915:08thhellerthere is some kind of bug that I haven't figured out when switching between compile->watch#2020-06-1915:09thhellermaybe thats also present in watch->watch. I have no clue what is happening but it results in a compile error. so unlikely to be related to your problem#2020-06-1915:10pithylessok, it's not a showstopper 🙂 If I figure out how to reproduce it I'll post an issue. Cheers!#2020-06-1915:11pithylessfor now I've only seen it when starting server -> first watch; (if that helps narrow it down)#2020-06-1915:13thhellerwould be good to have something reproducible 🙂#2020-06-1913:39David PhamHello, I have some trouble with the shadow-cljs modules: I have a google closure error saying 1. Do you know what this would be?#2020-06-1913:43David Phamoh I think I got it, there is an error in cljs.spec.alpha when calling gen...#2020-06-1914:21thheller@kevin.van.rooijen classpath doesn't matter just always include it. and then add re-frisk via :preloads.#2020-06-1914:21kwrooijenThe JS doesn't get included if I don't :require it manually?#2020-06-1914:22thhellercorrect#2020-06-1914:22kwrooijenMakes sense, thanks!#2020-06-1914:22thheller@ramblurr only https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2020-06-1915:17Casey> The goog: prefix currently only works for ES6 file. require("goog:cljs.core") does not work. There's no way to call cljs from js then when ESM isn't available?#2020-06-1915:18thheller:npm-module or :node-library#2020-06-1915:23Caseyre the repl docs: that is a nice high level explanation. To implement a repl for screeps, I'd need to be able to implement #3 Transfer Out and #6 Transfer Back using something besides web sockets... vanilla http requests#2020-06-1915:29thhellerIt is unlikely that you need to implement that since there already is an impl for websockets#2020-06-1915:29thhellerbut I don't know enough about the screeps runtime and what it can do#2020-06-1915:37CaseyThere are no websockets. from inside the game i can read/write json to a memory location, from outside the game I can read/write to that memory location using an HTTP GET/POST.#2020-06-1915:37CaseyI'll dive into the impl and check it out.#2020-06-1915:38thhellerhttps://github.com/thheller/shadow-cljs/blob/db55036fb6988fb3146fb91a9554da25932209c6/src/main/shadow/cljs/devtools/client/node.cljs#2020-06-1915:38thhellerthats the node client impl#2020-06-1915:39thhellerhttps://github.com/thheller/shadow-cljs/blob/db55036fb6988fb3146fb91a9554da25932209c6/src/main/shadow/cljs/devtools/client/browser.cljs#2020-06-1915:39thhellerbrowser has a bunch more stuff but the core impl is the same#2020-06-1915:42thhellerhttps://github.com/thheller/shadow-cljs/blob/master/doc/remote.md this might also be relevant#2020-06-1915:42thhellerthats how it all works together#2020-06-2008:01rbergerI have a local file JS import: ["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]] Its working fine. The file is being imported and all the functionality is there. The issue is that, In dev mode, if I make changes to that JS file, shadow-cljs doesn’t seem to notice and doesn’t do a rebuild. Is that expected behavior? Or am I doing something wrong? I also tried putting it in a parallel directory as per https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js (and modified the :require statement to match) and it again worked correctly if I restarted shadnow-cljs watch but shadow-cljs still did not rebuild when I changed something in the js file.#2020-06-2008:02rbergerIts doing this with shadow-cljs 2.10.9 and 2.10.12#2020-06-2009:36David PhamWhere is the tap> feature documented? #2020-06-2012:16papachanhttps://github.com/clojure/clojure/blob/master/changes.md#23-tap#2020-06-2009:39David PhamHow can you use the inspect feature of shadow-CLJS with regular Clojure?#2020-06-2009:40David PhamGot it in my notes haha#2020-06-2009:40David Pham
(require '[shadow.cljs.devtools.server :as server])
(server/start!)
(tap> :hello)
#2020-06-2023:08currentoorI'm developing an app in chrome but over LAN on a mobile device, using the setting in shadow-cljs.edn
:log      {:level :debug}
my runtime keeps disconnecting from shadow and I see this log
[2020-06-20 15:59:27.446 - FINE] :shadow.remote.relay.local/client-disconnect - {:client-id 52, :client-info {:since #inst "2020-06-20T22:59:07.397-00:00", :proc-id "d6e4f00e-4f36-442d-a752-0894a052b5f0", :connection-info {:remote true, :websocket true}, :user-agent "Chrome 537.36 [Linux armv8l]", :type :runtime, :lang :cljs, :build-id :back-office, :host :browser, :dom true}}
but looking at the remote chrome devtools network tab i see a sente websocket connection to my server remains robust but but the shadow connection keeps dieing, any ideas why?
#2020-06-2023:13currentoorthe message frames for the shadow WS connection always look like this, before dying
["^ ","~:op","~:welcome","~:client-id",47]
["^ ","~:op","~:hello","~:client-info",["^ ","~:host","~:browser","~:user-agent","Chrome 537.36 [Linux armv8l]","~:dom",true,"~:type","~:runtime","~:lang","~:cljs","~:build-id","~:back-office","~:proc-id","d6e4f00e-4f36-442d-a752-0894a052b5f0"]]
["^ ","~:op","~:request-notify","~:notify-op","~:shadow.cljs.devtools.client.env/worker-notify","~:query",["~:eq","~:shadow.cljs.model/worker-for","~:back-office"]]
["^ ","~:op","~:request-supported-ops","~:from",3]
["^ ","~:op","~:supported-ops","~:ops",["~#set",["~:ping","~:shadow.cljs.devtools.client.env/worker-notify","~:tap-unsubscribe","~:obj-forget","~:cljs-asset-update","~:cljs-build-start","~:runtime-print-unsub","~:obj-describe","~:cljs-build-complete","~:cljs-eval","~:tap-subscribe","~:request-tap-history","~:obj-request","~:cljs-build-failure","~:obj-forget-all","~:js-eval","~:shadow.cljs.devtools.client.shared/runtime-print-disconnect","~:runtime-print-sub","~:cljs-runtime-init","~:cljs-build-configure","~:access-denied"]],"~:to",3]    539    
["^ ","~:op","~:tap-subscribe","~:summary",true,"~:history",true,"~:from",3]
["^ ","~:op","~:tap-subscribed","~:history",[],"~:to",3]
#2020-06-2023:16currentoorreading the shadow source and these messages, it looks like the server sends a :ping and the client is supposed to respond with a :pong https://github.com/thheller/shadow-cljs/blob/5a32abb215c81c26268967ed4439303bb348e5d0/src/main/shadow/cljs/ui/worker/relay_ws.cljs#L90 but in these messages the client is never sending the :pong, nor do I see any error messages in the logs#2020-06-2023:20currentooris there anyway to get more insight into why this might be happening?#2020-06-2023:28currentoorin the messages for sente, I see sente just sends a ping to the server every 20 seconds, would that design be more robust? rather than having the client wait for the server to tell it to ping/pong, just have the client ping on some regular interval#2020-06-2023:29currentoornot having my usual shadow-cljs repl is really hindering progress#2020-06-2023:34thheller@currentoor the server sends the ping every 5sec, not sure why it wouldn't. too tired to look into this now. would help if you have something reproducible.#2020-06-2023:39donyormAnyone have any wisdom/advice for deploying shadow-cljs apps to heroku? Or suggestions for an alternative to heroku that works well with clojurescript (currently just have a frontend so no worry about setting up a backend yet)#2020-06-2023:39dpsuttonif no backend i've found netlify to be extremely easy
#2020-06-2023:40dpsuttonhttps://github.com/dpsutton/asg-ignite-presentation has an example app, a presentation going through the app, and a link to the app running on netlify#2020-06-2023:43donyormThanks that's helpful.!#2020-06-2108:28thheller@currentoor forgot to ask which version you use? the ping behavior was definitely buggy in earler 2.10.x versions. make sure you are on 2.10.12#2020-06-2118:47currentoor@thheller I'm on 2.10.12#2020-06-2119:44thhellercan you open the UI and see if that sends ping/pong? or does that also not work?#2020-06-2121:05currentoori was able to open the UI, however i came into my office, which is a different network, and now it's working very robustly#2020-06-2121:06currentoorthanks for considering though#2020-06-2121:09currentoorstrange that this only happens • on android device (android emulator and iOS device worked fine) • connected over lan • at my home network (office works) • for the shadow WS (my app's WS using sente works) #2020-06-2121:09currentoorvery mysterious but im just glad it's working now#2020-06-2108:29thheller@rberger what does the browser console say? does it not actually rebuild anything? do you maybe have the file in a resources folder?#2020-06-2203:43rbergerStill having this issue that changes in the JS file does not trigger shadow in watch mode to rebuild. The Browser Console, the shell terminal running shadow-cljs -A:dev watch app, nor the webpage itself show any indication that a rebuild happens. The JS file is not in resources (other than the compiled output). I wasn’t quite sure what was meant in the guide (https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js) by: > The files must not be physically located in the same directory. The lookup for the file appears on the classpath instead. This is unlike node which expects relative requires to always resolve to physical files. So I tried all the permutations I could think of and none of them would trigger shadow-cljs watch to rebuild. Updating any CLJS file did as normal. Here is what I tried: 1. With the JS file in the same source tree (but not directory) as the cljs file requiring the JS file: deps.edn :path ["src"]
(ns visx.dashboard.antmedia
  (:require
   ["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
  (:require
   ["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
with the file layout:
├── package.json
├── shadow-cljs.edn
└── src
    └── visx
        └── dashboard
            └── antmedia.cljs
            |__ antmedia
                |__ webrtc_adapter.js
2. Or when the JS file is a different directory tree under src:
(ns visx.dashboard.antmedia
  (:require
   ["/js/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
    └── visx
        └── dashboard
            └── antmedia.cljs
            |__ antmedia


    └── js
        └── dashboard
            └── antmedia
                |__ webrtc-adapter.js
3. Or when the JS is in a different tree but matching class path with updated :path: deps.edn: :path ["src/js" "src/cljs"]
(ns visx.dashboard.antmedia
  (:require
   ["/visx/dashboard/antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
or
(ns visx.dashboard.antmedia
  (:require
   ["./antmedia/webrtc_adaptor.js" :refer [WebRTCAdaptor]]))
├── package.json
├── shadow-cljs.edn
└── src
    [__ cljs
        └── visx
            └── dashboard
                └── antmedia.cljs
                |__ antmedia
    └── js
        |__ visx
            └── dashboard
                └── antmedia
                    |__ webrtc-adapter.js
#2020-06-2208:12thhellerplease stop shadow-cljs completely#2020-06-2208:13thhellerthen run shadow-cljs watch <your-build> --verbose#2020-06-2208:13thhellerafter the initial compile has finished run touch src/whever/the/file/is.js#2020-06-2208:13thhellerand post the full log#2020-06-2208:14thhellerit doesn't really matter where the file is. just put it into the same directory you are including it from. all this classpath juggling isn't useful or required#2020-06-2110:31ziltiI tried using shadow-cljs on a fresh Windows install today. I "installed clojure" using their new powershell script, and npm and GraalVM using Chocolatey (JAVA_HOME is set, and java is on the path; running clj works as expected). I did an npm install in my project and ran clj once so all dependencies are present. Then I tried to run npx shadow-cljs, but only get the error that the system can't find the path. What could that be?#2020-06-2111:17David PhamFind the path of what?#2020-06-2111:30ziltiYea no idea. That is all powershell tells me. "The system couldn't find the specified path".#2020-06-2112:42David PhamI am sorry, I don't have a lot of experience with powershell. What could you try is to execute shadow-cljs directly by specifying the full path directly in powershell. I would recommend trying bash though 🙂#2020-06-2111:34Ozdid you install npx? also maybe whitespace in the path?#2020-06-2111:36ziltiyes, and just calling npx on its own shows the normal help text with the possible flags of npx#2020-06-2111:36ziltiNo whitespace in the path#2020-06-2112:09Oznpx shadow-cljs watch app suddenly doesn't recompile or reload my code when I save my soruces. I'm not sure what have changed. it might have been cosmic radiation. On the other hand, changes to shadow-cljs.edn are being watched correctly. Any idea how to debug this?#2020-06-2112:42erikwhat is the relationship between the nREPL and the different JS contents of a chrome extension such as bg script and content scripts?#2020-06-2114:44ziltiOkay so npx shadow-cljs works fine outside of the project directory.#2020-06-2115:10Lucy Wang@thheller With latest 2.10.12 I find a bug: each time I eval the ns form for a file, the functions defined in that ns is lost, calling them in the REPL results in errors like
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var my.ns/f1
#2020-06-2117:31thheller@wxitb2017 (ns my.ns) always just declares that ns. you need to (require 'my.ns) (in-ns 'my.ns) if you want to load and switch? that has always been that way though.#2020-06-2117:31thheller@wxitb2017 (ns my.ns) always just declares that ns. you need to (require 'my.ns) (in-ns 'my.ns) if you want to load and switch? that has always been that way though.#2020-06-2201:04Lucy Wang@thheller nope, for a better example, take this ns as an example
// project/lib.js
(ns project.lib)

(defn f1 [])
So this ns has a f1 var. But if I eval the ns form again, and try to catch f1 , it would throw the error I pasted above.
#2020-06-2208:16thhellerthis is not a better example. please use shadow-cljs node-repl or browser-repl and post everyh single step you do to get to the error#2020-06-2213:22Lucy Wang@thheller sorry if I didn't make it clear. I'm not using node-repl or browser-repl, but connecting to shadow-cljs from emacs+cider. and project/lib.js is a file I open in emacs.
// project/lib.js
(ns project.lib)
(defn f1 [])

(comment
  (f1)
)
1. I open the project, and cider-jack-in 2. I can call (f1) in the comment form, which returns nil 3. I put the emacs cursor in the end of the ns form, and cider-eval that form (e.g. I often do that to add new imports to current ns) 4. now if i try to call (f1) again, it throws that error
#2020-06-2214:55thhellerI do not know emacs and this doesn't tell me anything about what you are actually doing#2020-06-2215:12Lucy WangI see. Just replace emacs with "cursive/vim". Open a cljs file in cursive/vim, and eval the ns form of that file. Then all the vars for that ns is gone.#2020-06-2217:35thhellerplease report it as a reprocucible example with ONLY shadow-cljs node-repl or shadow-cljs browser-repl. no editor or other configuration. otherwise I will not investigate this further.#2020-06-2300:53Lucy Wang@thheller Here it is with node-repl (TBH, they are essentially the same as my earlier examples):
$ yarn shadow-cljs node-repl 
cljs.user=> (ns foo.bar)
nil
foo.bar=> (defn f1 [] (println "foo.bar/f1 called!"))
#'foo.bar/f1
foo.bar=> (f1)
foo.bar/f1 called!
nil
foo.bar=> (ns foo.bar)
nil
foo.bar=> (f1)
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var foo.bar/f1
--------------------------------------------------------------------------------
foo.bar=> (require 'foo.bar)
nil
foo.bar=> (f1)
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var foo.bar/f1
--------------------------------------------------------------------------------
#2020-06-2301:08Lucy Wangversion info: mac os 10.15 shadow-cljs version: 22:10:44 js | shadow-cljs - server version: 2.10.12 running#2020-06-2307:12thheller@wxitb2017 please report as a github issue. slack will get lost.#2020-06-2313:03Lucy Wang@thheller here it is! https://github.com/thheller/shadow-cljs/issues/741#2020-06-2117:33thheller@zilti please post the full error. very hard to piece together what you are actually doing or what is missing.#2020-06-2117:35zilti@thheller that is the full error. (Or rather was, I deleted the node_modules folder now, and ran npx shadow-cljs again, and it installed and ran. I suspect it is a problem that I had shadow-cljs in my package.json file?)#2020-06-2117:36thhellerhmm ok#2020-06-2120:14Spacemanhow do I run pure js code from cljs? I have a js code snippet that needs to be run on a dom event. What's a simple way to do this?#2020-06-2120:18Spacemanthe js code is in the public resources directory file#2020-06-2120:34SpacemanThis is the code in the google-maps.js file:
(function(exports) {
                 "use strict";

                 console.log("loading map");
                 function initMap() {
                     exports.map = new google.maps.Map(document.getElementById("map"), {
                         center: {
                             lat: -34.397,
                             lng: 150.644
                         },
                         zoom: 8
                     });
                 }

                 exports.initMap = initMap;
             })((this.window = this.window || {}));
#2020-06-2120:35SpacemanI'm using shadow so can I import this file and run it? How exactly? @thheller?#2020-06-2120:44thheller@pshar10 whats the point? why not rewrite it in CLJS?#2020-06-2120:45Spacemanthis is not a special case.#2020-06-2120:45SpacemanI have this in google_maps.js:
export function initMap() {
                     exports.map = new google.maps.Map(document.getElementById("map"), {
                         center: {
                             lat: -34.397,
                             lng: 150.644
                         },
                         zoom: 8
                     });
                 }
#2020-06-2120:46Spacemanand I imported like this:
["./google_maps.js" :refer (initMap)]
#2020-06-2120:46thhellerthats not valid JS#2020-06-2120:46Spacemanbut it doesn't work#2020-06-2120:46Spacemanwhy is it not valid?#2020-06-2120:46thhellerexports.map =#2020-06-2120:46thhellerchange that to return#2020-06-2120:49Spacemanstill gives initMap is not a function. Is it imported correctly?#2020-06-2120:50SpacemanWhat is the default directory? the watch directory in shadow edn?#2020-06-2120:50Spacemanor a combination of the watch directory and the asset path>#2020-06-2120:51thhellernone of those questions are relevant for what you are doing#2020-06-2120:51thhellerthe import is correct yes#2020-06-2120:52thhellerassuming that the path is correct and it actually compiles correctly#2020-06-2120:52thhellerdo you get compile errors or does it just fail at runtime?#2020-06-2120:52SpacemanCompilation failed!
The required JS dependency "./google_maps.js" is not available, it was required by 
#2020-06-2120:53thhellerthen read https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js and put the file in the correct place#2020-06-2121:01SpacemanAdding :source-paths ["resources/public/js"] in shadow config didn't work#2020-06-2121:02SpacemanThe required JS dependency "./google_maps.js" is not available, it was required by#2020-06-2121:02Spacemanthe file is in resources/public/js#2020-06-2121:03thhellerthat is not the correc solution#2020-06-2121:03thhellermove the file into the same folder as the file you are including it from#2020-06-2121:12Spacemanbeing loaded like so:
(def load-map (with-meta identity
                {:component-did-mount
                 initMap}))

[load-map [:div {:id "map"}]]
gives: initMap is not a function
#2020-06-2121:14Spaceman(index):1 Uncaught (in promise) Vc {message: "initMap is not a function", name: "InvalidValueError", stack: "Error↵ at new Vc (https://maps.googleapis.com/m} Promise.then (async) ij @ js?key=AIzaSyD1r7IEvY&callback=initMap&libraries=&v=weekly:136 google.maps.Load @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:14 (anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:227 (anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap&libraries=&v=weekly:227 This error is after the console.log print console.log("init map"), the first line of initMap#2020-06-2121:18Pavel KlavíkHi, I have rebuild my client with 2.10.12 version and I am getting the following errors on the start:#2020-06-2121:18Pavel KlavíkI did some changes in my rf code but it does not seem to be related to this in any way.#2020-06-2121:21thhellerI assume there are more errors? all of the errors in that screenshot are likely to something else before that (might be reported after)#2020-06-2203:12Pavel KlavíkOk, so the error was silly. During refactoring, I moved one namespace and forgot to change its path so it was not matching the new location. Refactoring features in Cursive are not perfect. Couldn't this be checked by Shadow-cljs and some error be displayed?#2020-06-2121:22Spaceman@thheller initMap is not a function#2020-06-2121:23Spacemanbut the console.log in initMap prints#2020-06-2121:23thheller@pshar10 last warning ... if you continue to be this impatient I will start to ignore youi#2020-06-2121:23thhellerI have stuff to do I cannot spend every second trying to help you with your issue#2020-06-2121:23thhellerI do not know what is going on in your problem but the issue is that the google maps stuff expects to call an initMap function#2020-06-2121:24thhellerwhich does not exist since it is not on the global namespace#2020-06-2121:25thhellerso was under the impression that YOU want to call this function but it looks like google will call that function for you#2020-06-2121:25thhellerso the entire setup you are trying is incorrect#2020-06-2121:26thhellerI do not know anything about the google maps API so I cannot tell how the correct version would look#2020-06-2201:15mauricio.szaboHi, is this a problem with Shadow or with ClojureScript? When I try to compile a file with:
(when something
  (nil 10))
It should point to the second line, right? But it is pointing to the first one...
#2020-06-2201:15mauricio.szaboThis is an example of the error that gets displayed:
------ ERROR -------------------------------------------------------------------
 File: /home/mauricio/.atom/packages/chlorine/repl-tooling/src/repl_tooling/repl_client/shadow_ws.cljs:195:1
--------------------------------------------------------------------------------
 192 | 
 193 | 
 194 | 
 195 | (when-not true
-------^------------------------------------------------------------------------
Error in phase :compilation
Can't call nil at line 196 repl_tooling/repl_client/shadow_ws.cljs
--------------------------------------------------------------------------------
 196 |   (nil 10))
 197 | 
 198 | ; (lol/bar 10)
 199 | ; (-> msg :build-status :report println)
--------------------------------------------------------------------------------
#2020-06-2201:17mauricio.szaboThis points to the right line, for example:
(when something
  ::wrong-ns/keyword)
#2020-06-2201:48mauricio.szabo(Well, I also found lots of interesting behaviors with compilation errors, so maybe it's not really a problem after all 😄. After all, compilation errors are quite rare anyway 😄)#2020-06-2205:08pwalshExcuse the cross-posting but I just added this to #clojurescript but I am currently using Shadow and part of my problem may be able to be solved in Shadow. Any help appreciated https://clojurians.slack.com/archives/C03S1L9DN/p1592802205168100#2020-06-2205:29p-himikMy tl;dr for the above: Is there a way to output function my_function(...) {...} for CLJS functions marked with ^:export (or somehow marked in any other way)? Specifically this kind of construct is needed. var my_function = ... and _function = ... will not work.#2020-06-2207:00CaseyIs there a trick to getting core async go blocks to execute to work when using the :node-test target?#2020-06-2208:20thheller@pwalsh you can specify a name for :export
(defn foobar
  {:export "someName"}
  []
  (js/console.log "called me!"))
#2020-06-2211:09pwalshthanks @U05224H0W - unfortunately it does not work. It looks like it does expose someName in the global scope, but, it still compiles foobar to function c() {} (i.e; the function definition, which apps script needs, is not the original name of the function).#2020-06-2211:58thhellerso you are saying that var onOpen = function() { ... }; would be invalid in apps-script?#2020-06-2212:04thhellerhttps://developers.google.com/apps-script/guides/v8-runtime#improved_function_detection I guess thats the issue then. looks like it tries to analyze the code instead of just calling it?#2020-06-2417:07pwalsh> so you are saying that `var onOpen = function() { ... };` would be invalid in apps-script? Yes, exactly#2020-06-2417:10pwalshbtw I solved this not even with externs. I just compile my clojurescript, and also push a javascript file to app script which exposes the public interface for app script and calls the functions from the compiled clojurescript.#2020-06-2417:12pwalsh(for anyone who every does this in future, use https://github.com/google/clasp so you can work with your code using a normal workflow and push to apps script like "deploying" your code - it is very useful)#2020-06-2417:13thhelleryou could use (js* "function onOpen() { your.ns.actual_on_open() };") but don't tell anyone I said that#2020-06-2916:06pwalshnice, thanks @U05224H0W#2020-06-2208:21thhellerso judging from the apps script example just (defn on-open {:export "onOpen"} [] ...)?#2020-06-2208:22thhellerdon't know much about the context this is running in so this may not work though#2020-06-2209:27thheller@ramblurr there is nothing special regarding :node-test and async go blocks. they work exactly as they do in all other targets#2020-06-2210:40smogstatehi i want to split our project. i read about modules, but as i understand its still same project.#2020-06-2210:40smogstatesame code base#2020-06-2210:41thheller:modules has nothing to do with how you organize your project. it only splits the output into several files but still requires compiling everything together.#2020-06-2210:43smogstateso module can be arbitrary js?#2020-06-2210:43thhellerno#2020-06-2210:43thheller"modules" unfortunately is a bad name with very different meaning in many different contexts#2020-06-2210:44thhellerso this will be much quicker if you explain what you want to do#2020-06-2210:44smogstatei wnat to split my project in multiple projects each has own CI/CD#2020-06-2210:45smogstatethen assemble them in SPA with dynamicly loaded modules#2020-06-2210:46thhellerok. one has nothing to do with the other.#2020-06-2210:46thheller:modules is about the produced output. so thats what you do to get "dynamically loaded modules" from#2020-06-2210:46thhellerthe input however does not matter for this. so whether this is coming from multiple libraries or not doesn't matter#2020-06-2210:47thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2020-06-2210:47smogstatei read this article 🙂#2020-06-2210:48smogstatei checked source on github you got those lazy loaded components in same project#2020-06-2210:48thhelleryes but it literally doesn't matter where those components come from#2020-06-2210:48thhellercould be from a library somewhere#2020-06-2210:49thhellerif you are asking how to use multiple independent projects and their produced .js files together on one page then that is not supported#2020-06-2210:50rickmoynihanI’ve just tried putting {:deps-aliases [:cider]} in my .shadow-cljs/config.edn file and I now get the error nREPL middleware: shadow.cljs.devtools.cli has no namespace error Command failed with exit code 2. when running shadow-cljs watch myapp, any idea how to resolve this?#2020-06-2211:05rickmoynihanweird copying the alias into :dependencies style works#2020-06-2210:51smogstateso if i have react components compiled into js i cant use them in one page#2020-06-2210:51thhellerwhat I think you want is moving some code into a library that you use as a dependency in your main project#2020-06-2210:52smogstateso basicaly i got view components which are used in core project which provides routing between those components#2020-06-2210:53thhelleryes, put the components into libraries of their own#2020-06-2210:53thhellerbut your main project still compiles everything together#2020-06-2210:54smogstateas a node.js libs?#2020-06-2210:54thhellersorry. I don't have time for this right now.#2020-06-2210:54thhellerno#2020-06-2210:54smogstatetnx anyway#2020-06-2210:54smogstate🙂#2020-06-2210:54smogstateand tnanks for shadow-cljs#2020-06-2212:24CaseyAre there any docs/guides for connecting emacs/cider to a :node-test target? I can't figure out how to connect to the right repl. It's erroring with no js runtime available.#2020-06-2212:25thhellernode-test isn't supposed to have a REPL#2020-06-2212:26thhellerjust use shadow-cljs node-repl if you want a generic node repl#2020-06-2212:46CaseyWhen I follow the instructions from the guide (https://shadow-cljs.github.io/docs/UsersGuide.html#_launch_the_clojurescript_repl) after the repl connects, I've given a cljs.user> prompt, but typing anything in it prints No available JS runtime. I selected my app using the :node-script target#2020-06-2212:47CaseyThe shadowjs web ui (http://localhost:9630/runtimes) only shows a single clj runtime, no cljs runtimes#2020-06-2212:50CaseyHm ok strange. Rather than choosing my app build target, I just chose node-repl and then I get a functioning cljs.user> repl.#2020-06-2212:54thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2020-06-2221:06rschmuklerHey all! Is there any way to resolve a javascript require via a symbol at compile time? I've got a library that's an NPM dependency and I'm writing a macro that generates code for it. How can I consume that macro in a different namespace? ie. unlike "normal" shadow requires, I can't use the fully qualified namespace since that'd be a string. Furthermore, the macro is meant to be used inside a function body, so something like (do (require "foo" :as foo) (defn something [] (foo/bar))) won't work#2020-06-2221:10rschmuklerNever mind, looks like js/module$node_modules$str#2020-06-2222:35lilactown@rschmukler are you trying to dynamically require a module?#2020-06-2222:36lilactownFWIW require is only available at dev time; it won’t work when you do a release build even if it’s static AFAIK#2020-06-2222:40rschmuklerIt's at compile time. I managed to get it working by looking at what resolve resolves the symbol to when you do (:require ["library" :as foo]) - turns out it's a string concat of node_modules + other stuff#2020-06-2222:40rschmuklerThanks though 🙂#2020-06-2321:16bennyis it a known limitation to using kebab casing for init-fn?#2020-06-2321:59thheller@benny not sure what you mean#2020-06-2322:00bennyi had init-fn: my-project.core/init inside my build def and it failed saying it couldn’t find the namespace, but when i renamed everything to just myproject it worked just fine#2020-06-2322:00bennyit appeared to be because of the dash but maybe something else i’m doing wrong#2020-06-2322:02dpsuttonwas the folder on disk named with an underscore rather than a hyphen?#2020-06-2322:02naomarik@benny did your filename have an underscore?#2020-06-2322:05thhelleryeah the folder needs to be called my_project but the ns can use my-project#2020-06-2323:02bennyahhh. thanks all!#2020-06-2403:21isakit isn't possible to use shadow-cljs inspect from a clojure (not clojurescript) project, is it?#2020-06-2404:40isakwow it works#2020-06-2404:47David PhamYep :) you need to start the server only.#2020-06-2404:48David PhamIt is really useful as it replace somehow the REBL haha#2020-06-2408:15CaseyIs expound compatible with shadow-cljs' :node-test target?#2020-06-2408:21CaseyOh I see, I'm running into this > As of https://github.com/clojure/clojurescript/commit/5f0fabc65ae7ba201b32cc513a1e5931a80a2bf7#diff-c62a39b0b4b1d81ebd2ed6b5d265e8cf, ClojureScript instrumentation errors only contain data and leave formatting/printing errors to the edge of the system e.g. the REPL.#2020-06-2408:28CaseyHere's an impl of test/report that uses expounds printer#2020-06-2408:33CaseyNow, is it possible to load that in the node-test target without overriding shadow.test.node/main#2020-06-2408:41thhelleryou can put it into any of your test namespaces#2020-06-2408:42thhelleror include it from one or all of them#2020-06-2408:42thhellerremove
(nodejs/enable-util-print!)
(enable-console-print!)
though
#2020-06-2408:42thhellerthe code just needs to run before the tests run#2020-06-2408:44Caseythat works well thanks#2020-06-2408:48CaseyUpdated the snippet#2020-06-2408:51thhelleractually that doesn't work#2020-06-2408:51thheller(ts/instrument) is a side-effecting macro which needs to be called AFTER everything has been compiled#2020-06-2408:52thhellerbut you are calling it at a point BEFORE everything is compiled, or maybe partially compiled thus not instrumenting everything#2020-06-2409:06Caseyits working for me atm, so must be the luck of compile order? What would be the proper way to fix it? Could I put it at the end of every test file that needs instrumentation ?#2020-06-2409:28thhellerI'd go with a custom runner ns#2020-06-2409:29thhellerjust copy this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#2020-06-2409:29thhellerand add the expound stuff and then the (st/instrument) call in main#2020-06-2409:30thhellerthat ensures that everything is instrumented before tests run#2020-06-2410:41dazld@thheller the new cljs_eval function is really nice! how do you do the lookup between a var in the form and which function to call / value etc?#2020-06-2410:42thheller@dazld I don't understand the question? what lookup?#2020-06-2410:43thhellerah ... I'm just compiling on the server as all the REPLs do. this has basically no logic on the client at all.#2020-06-2410:44dazldthought so - i understood vars were elided at compile time#2020-06-2410:44dazldso was wondering how that worked#2020-06-2410:44dazldelided maybe wrong word#2020-06-2410:44thhelleryeah this isn't self-hosted. all the compiler stuff happens in the watch worker process on the server.#2020-06-2412:18ghaskinsHey all, does anyone know if theres a way to utilize clojure.datafy in a manner that is compatible with optimized output?#2020-06-2412:19ghaskinsBy this, i mean the symbol renaming problem#2020-06-2412:19thhellernot sure what you mean? it works just fine in optimized output?#2020-06-2412:20ghaskinsno, i mean it works in dev output but is getting munged in optimized output#2020-06-2412:20ghaskinsi wasnt sure if there was a way to annotate/utilize such that the generated code gets enough of a hint to allow datafy to do its thing#2020-06-2412:20thhellerI don't know what you mean by that. can you provide an example?#2020-06-2412:21ghaskinssure#2020-06-2412:21thhellerdatafy is just as minified as all the rest so its not a problem?#2020-06-2412:21thhellergranted you still need to follow externs inference stuff and maybe typehint a bit#2020-06-2412:21ghaskinsyou and I spoke about this area before, but it was before I knew about datafy, so I was revisiting to see if that could help#2020-06-2412:22ghaskinsin short, im working with grpc-web#2020-06-2412:22ghaskinshttps://github.com/grpc/grpc-web#3-write-your-js-client#2020-06-2412:22thhellerand you datafy objects from grpc?#2020-06-2412:22ghaskinsand im doing things like this#2020-06-2412:22ghaskins
(defmacro invoke-unary
  [client method req auth]
  `(p/create
     (fn [resolve# reject#]
       (let [result# (~method ~client
                      ~req
                      (cljs.core/clj->js {"authorization" ~auth})
                      (fn [err# resp#]
                        (if err#
                          (reject# err#)
                          (resolve# (datafy (.getMessage ^js resp#))))))]
         (.on result# "status" (fn [status#]
                                 (let [s# (datafy ^js status#)]
                                   (when-not (zero? (:code s#))
                                     (reject# s#)))))))))
#2020-06-2412:23ghaskinswhich works in dev, for instance, i see things like#2020-06-2412:23ghaskins
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {"code" 16, "details" "invalid auth token", "metadata" #js {:cache-control "private, no-cache", :connection "keep-alive", :content-length "0", :content-type "application/grpc-web-text+proto", :date "Wed, 24 Jun 2020 12:09:43 GMT", :grpc-message "invalid auth token", :grpc-status "16", :server "istio-envoy", :x-envoy-upstream-service-time "1"}}
#2020-06-2412:23ghaskinsbut in optimized, I just get#2020-06-2412:23ghaskins
TypeError: Z.og is undefined
#2020-06-2412:23thhellerwhy is this a macro? 😛#2020-06-2412:24thhellerturn on https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs. it'll tell you about the things that fail#2020-06-2415:53mauricio.szabo@thheller can I ask why it's not the default? Everytime I start a new project, I add infer-externs because I find it extremely useful 🙂#2020-06-2416:19thhelleryeah it maybe should be at this point 😛#2020-06-2412:24ghaskinsbecause I need to capture the dot-form interop#2020-06-2412:25ghaskinsi couldnt figure out how to do that without a macro#2020-06-2412:25thhellerin this case it likely is the .on being renamed#2020-06-2412:25ghaskinscool, i will check that#2020-06-2412:26thhellerand maybe the method stuff? how do you use invoke-unary?#2020-06-2412:26thheller^js result# might be enough#2020-06-2412:27ghaskinsits called like this#2020-06-2412:27ghaskins
(defn get-providers [auth]
  (let [req (pb/ProvidersGetRequest.)]
    (.setHeader req (utils/make-header))
    (invoke-unary (connect) .getProviders req auth)))
#2020-06-2412:27ghaskins(the grpc-web lib is terrible#2020-06-2412:27ghaskinsits super awkward to interface with#2020-06-2412:28thhelleryeah ok that s the other problem then#2020-06-2412:28ghaskinsill try the result$ suggestion, too#2020-06-2412:28thheller.getProviders also needs a hint#2020-06-2412:28thhellerbut ^js .getProviders might not work#2020-06-2412:30thhellerbut datafy isn't the problem here its usual JS interop thats the problem#2020-06-2412:30ghaskinsunderstood#2020-06-2412:30ghaskinsi didnt mean to suggest otherwise#2020-06-2412:30thhelleruse shadow-cljs release app --pseudo-names. that will give a better idea of what Z.og is#2020-06-2412:31ghaskinsi just wasnt sure if there was some magic "oh yeah, do this to make datafy work"#2020-06-2412:31ghaskins(which, i think is what we are working through now)#2020-06-2412:32ghaskinsnot sure this is overkill/correct, but going to try this now#2020-06-2412:32ghaskins
diff --git a/src/cljs/mcp_admin_ui/grpc/macros.clj b/src/cljs/mcp_admin_ui/grpc/macros.clj
index 344cc97..0f6d050 100644
--- a/src/cljs/mcp_admin_ui/grpc/macros.clj
+++ b/src/cljs/mcp_admin_ui/grpc/macros.clj
@@ -6,14 +6,14 @@
   [client method req auth]
   `(p/create
      (fn [resolve# reject#]
-       (let [result# (~method ~client
-                      ~req
-                      (cljs.core/clj->js {"authorization" ~auth})
-                      (fn [err# resp#]
-                        (if err#
-                          (reject# err#)
-                          (resolve# (datafy (.getMessage resp#))))))]
-         (.on result# "status" (fn [status#]
-                                 (let [s# (datafy status#)]
-                                   (when-not (zero? (:code s#))
-                                     (reject# s#)))))))))
+       (let [result# (^js ~method ^js ~client
+                       ~req
+                       (cljs.core/clj->js {"authorization" ~auth})
+                       (fn [err# resp#]
+                         (if err#
+                           (reject# err#)
+                           (resolve# (datafy (.getMessage ^js resp#))))))]
+         (.on ^js result# "status" (fn [status#]
+                                     (let [s# (datafy ^js status#)]
+                                       (when-not (zero? (:code s#))
+                                         (reject# s#)))))))))
#2020-06-2412:32thheller^js ~method that won't do anything#2020-06-2412:32ghaskinshave to do it at the callsite?#2020-06-2412:33thhellerno you can do it in the macro but ~method becomes (unquote method) so you have ^js (unquote method) which is not the place you need it in#2020-06-2412:34thheller~(vary-meta method assoc :tag 'js) might work#2020-06-2412:34thhellertry the --pseudo-names first to actually figure out where the issue is#2020-06-2412:34ghaskinsyou are a ninja...i wouldnt have thought to try that, heh#2020-06-2412:34thhellerno point in hinting blindly#2020-06-2412:35ghaskinsok#2020-06-2412:40ghaskinsi ran lein shadow release app --pseudo-names but nothing is jumping out at me to see if it did anything#2020-06-2412:40ghaskinsis that the wrong incantation?#2020-06-2412:41ghaskinsor could that be the hint that I captured all the annotations i needed?#2020-06-2412:49thhellerI don't know if lein shadow supports that arg#2020-06-2412:50thhellerTypeError: Z.og is undefined this should be different. if its not then the arg was passed properly#2020-06-2412:50ghaskinsits the same, so let me try the direct method#2020-06-2412:50ghaskinsalso, do you have a similar flow as "watch app" but for a release build?#2020-06-2412:51ghaskinsits painful for me to iterate on release through docker ->k8s#2020-06-2412:51ghaskinsi need the dev-http proxy to test locally, is the problem#2020-06-2412:52ghaskinsmaybe i just need an alternate config#2020-06-2413:02ghaskinsok, i added a parallel config, for now#2020-06-2413:02ghaskins
:shadow-cljs {:nrepl {:port 8777}
                :dev-http {8280 {:root "resources/public"
                                 :proxy-url ""}}
                :builds {:app {:target :browser
                               :compiler-options {:infer-externs :auto}
                               :output-dir "resources/public/admin/js/compiled"
                               :asset-path "/admin/js/compiled"
                               :modules {:app {:init-fn mcp-admin-ui.core/init}}}
                         :rel {:target :browser
                               :compiler-options {:infer-externs :auto
                                                  :optimizations :advanced}
                               :output-dir "resources/public/admin/js/compiled"
                               :asset-path "/admin/js/compiled"
                               :modules {:app {:init-fn mcp-admin-ui.core/init}}}}}
#2020-06-2413:03ghaskinshowever, watch rel still results in a bunch of independent js, so I think im not quite doing what i expected#2020-06-2413:06thhellershadow-cljs server and leaving that running. then shadow-cljs release app is quicker. no clue about your docker setup or lein shadow though. I do not recommend lein shadow because it makes all of this harder.#2020-06-2413:06ghaskinsawesome, ill try that#2020-06-2413:07thhellerwatch does not run optimizations at all ever so setting it does nothing. :rel is identical to :app basically as the default is :optimizations :advanced anyways#2020-06-2413:13ghaskinsshadow-cljs server was the magic I needed#2020-06-2413:14ghaskinsnow i can iterate quick, let me add that --psuedo-names option and see what I get#2020-06-2413:16ghaskins
Uncaught TypeError: Cannot read property '$datafy$' of undefined
    at Array.<anonymous> (app.js:33921)
    at zb (app.js:2042)
    at Ma.<anonymous> (app.js:2041)
    at xa (app.js:2026)
    at ra (app.js:2026)
    at vb (app.js:2034)
    at Ma.O (app.js:2062)
    at Ma.K (app.js:2062)
#2020-06-2413:17ghaskinsand actually, i see this in this build mode#2020-06-2413:17ghaskins
File: /Users/ghaskins/sandbox/git/mcp-admin-ui/src/cljs/mcp_admin_ui/grpc/account_service.cljs:14:5
--------------------------------------------------------------------------------
  11 | (defn get-providers [auth]
  12 |   (let [req (pb/ProvidersGetRequest.)]
  13 |     (.setHeader req (utils/make-header))
  14 |     (invoke-unary (connect) .getProviders req auth)))
-----------^--------------------------------------------------------------------
 Use of undeclared Var clojure.datafy/datafy
#2020-06-2413:17ghaskinsprobably related#2020-06-2413:18ghaskinsso, im borking up the requires on datafy, somehow#2020-06-2413:24ghaskinshmm, im not getting something#2020-06-2413:31ghaskinsi tried using a fully qualified (clojure.datafy/datafy) form, but its still unhappy with me calling that in optimized mode#2020-06-2413:31ghaskinsworks fine in debug mode#2020-06-2413:32ghaskinsim not quite sure what would cause that#2020-06-2413:39ghaskinsoh, maybe this is simply that the value is nil#2020-06-2413:47ghaskinshmm, nope#2020-06-2414:20ghaskinsim out of ideas...i added a js/console.log just prior and the object seems to be valid#2020-06-2414:21ghaskinsheres the log output#2020-06-2414:21ghaskins
status: {code: 16, details: "invalid auth token", metadata: {…}}
app.js:33922 Uncaught TypeError: Cannot read property '$datafy$' of undefined
    at Array.<anonymous> (app.js:33922)
    at zb (app.js:2042)
    at Ma.<anonymous> (app.js:2041)
    at xa (app.js:2026)
    at ra (app.js:2026)
    at vb (app.js:2034)
    at Ma.O (app.js:2062)
    at Ma.K (app.js:2062)
#2020-06-2414:21ghaskinsfor
(.on ^js result# "status" (fn [status#]
                                     (js/console.log "status:" status#)
                                     (let [s# (datafy status#)]
                                       (when-not (zero? (:code s#))
                                         (reject# s#)))))
#2020-06-2414:46ghaskinsok, i figured it out (sorta)#2020-06-2414:47ghaskinsit has something to do with clojure.datafy/datafy...even though that exists in both clj and cljs, i think its somehow not recognized in the macro expansion when in release build#2020-06-2414:48ghaskinsi switched to cljs.core/js->clj and this of course has no ambiguity#2020-06-2414:48ghaskinsthat works#2020-06-2414:51thhellerthats a weird error. do you call .datafy somewhere? using datafy otherwise does not create a datafy property since its a protocol?#2020-06-2416:07ghaskinsno, its super weird#2020-06-2416:08ghaskinsim speculating but it seems like its confused over the dual definition#2020-06-2416:10ghaskinsin summary, both ["datafy" "js-cljs"] throw erros about the var not existing within the macro ns (even though i had referred it in the macro ns)....making datafy fully qualified explicitly as clojure.datafy/datafy still results in a undefined var, and cljs.core/js->clj works#2020-06-2416:11ghaskinsbut only for release builds...dev builds work in all forms#2020-06-2416:12ghaskinsthis is the only one that works in release#2020-06-2416:12ghaskins
(.on ^js result# "status" (fn [status#]
                                     (let [s# (cljs.core/js->clj status# :keywordize-keys true)]
                                       (when-not (zero? (:code s#))
                                         (reject# s#)))))
#2020-06-2416:13ghaskinsits entirely possible I have some subtle expansion error in my macro that ive yet to uncover#2020-06-2416:32ghaskinsjust to confirm, I also dropped the :refer approach and did (:require [clojure.datafy :as d]) and (d/datafy)#2020-06-2416:33thhellerI still think you are looking at the wrong code#2020-06-2416:33dpsuttoncould this be a clojure.datafy vs cljs.datafy problem?#2020-06-2416:33ghaskinsbut it still shows up as undefined clojure.datafy/datafy at compile time#2020-06-2416:33ghaskins@dpsutton quite possibly#2020-06-2416:33ghaskinslet me try that#2020-06-2416:33thhellerno, its clojure.datafy#2020-06-2416:33thhellerthere is no cljs.datafy#2020-06-2416:33ghaskinsah, ok#2020-06-2416:34ghaskinsi had hope for a second there#2020-06-2416:34ghaskinsheh#2020-06-2416:34thhelleryou should still try to identify what $datafy$ actually is#2020-06-2416:34thhelleryou are quite possibly will tweaking the wrong bit of code#2020-06-2416:34ghaskinsany advice on how to do that?#2020-06-2416:35thhelleror did you confirm that its 100% what you are working on now?#2020-06-2416:35thhellerI usually just look at the compiled pseud-names output#2020-06-2416:35thhellerjust look for .$datafy$ and figure out what that is 😛#2020-06-2416:35ghaskinsgot it
#2020-06-2416:35ghaskinslooking now#2020-06-2416:36thhelleror in chrome "pause on uncaught exception" and debug from there#2020-06-2416:36thhellershadow-cljs release app --debug gives you pseudo-names + source maps which makes that easier#2020-06-2416:37ghaskinsawesome, ill try both of those too#2020-06-2416:44ghaskinsI dont really have the full context/knowledge to know whats right, but if I had to guess, the issue is simply that the gensym'd symbol isnt datafy-able ?#2020-06-2416:46thhellerhmm that is indeed the code you are working on#2020-06-2416:46ghaskinsactually, it looks like two gensymed symbols were munged?#2020-06-2416:46thhellerbut it should not be renamed that way. makes no sense.#2020-06-2416:46thhellerdo you have manually specified clojure and datafy as externs?#2020-06-2416:46ghaskinsnot to my knowledge#2020-06-2416:46thhellerhmm no they are renamed so its not externs#2020-06-2416:47thhellerbut they should be flattened. not sure why it doesn't flatten them#2020-06-2416:47thhelleroh wait .. how did you setup your macro? do you actually require clojure.datafy in CLJS code?#2020-06-2416:47ghaskinsnope...i can try that#2020-06-2416:48thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-06-2416:48ghaskinsi was actually reading that this morning, heh#2020-06-2416:48ghaskinsi'll re-review#2020-06-2416:48ghaskinsi actually had trouble with one of your suggestions#2020-06-2416:49ghaskins(the dual clj/cljs ns didnt work for me#2020-06-2416:49ghaskinsmaybe that is another hint#2020-06-2416:49thhellersounds like it#2020-06-2416:49ghaskinsi was only able to get it to work with a single .clj + :require-macros in the consumer, but only in dev mode#2020-06-2416:50ghaskinsadding a dual .cljs would not compile for me#2020-06-2416:51thhellerthen you are definitely doing something incorrectly there#2020-06-2416:52ghaskinsok, progress#2020-06-2416:53ghaskinsadding the :require to the consumer got rid of both the :undeclared-var warning at compilation, and the $datafy$ TypeError at runtime#2020-06-2416:53ghaskinsty for that#2020-06-2416:53ghaskinsultimately it looks like datafy is limited in :advanced mode, now#2020-06-2416:53ghaskinsi get#2020-06-2416:53ghaskins
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: [object Object]
#2020-06-2416:54ghaskinsinstead of the decoded fields#2020-06-2416:54ghaskinsmaybe that is par for course#2020-06-2416:54ghaskinsi guess the only weird thing left is that datafy and js->clj both return a map in dev, but only js->clj returns one in :advanced#2020-06-2416:55ghaskinsexpected?#2020-06-2416:55ghaskins(the operative part of the log is the [object Object]#2020-06-2416:56thhellerwait ... you had an undeclared-var warning the entire time?#2020-06-2416:56ghaskinsyeah, i mentioned that though#2020-06-2416:56ghaskinsheh, sorry#2020-06-2416:57thhellerhmm yeah I missed that ...#2020-06-2416:57ghaskinshttps://clojurians.slack.com/archives/C6N245JGG/p1593004631361300#2020-06-2416:58thhellerI don't know what fetch-providers is but I assure you datafy works just fine in :advanced#2020-06-2416:58ghaskinsThis is what that log should have looked like if it worked#2020-06-2416:58ghaskins
core.cljs:159 ERROR [mcp-admin-ui.events:20] - fetch-providers failed: {:code 16, :details "invalid auth token", :metadata {:date "Wed, 24 Jun 2020 16:58:04 GMT", :server "istio-envoy", :grpc-status "16", :x-envoy-upstream-service-time "2", :cache-control "private, no-cache", :content-length "0", :grpc-message "invalid auth token", :content-type "application/grpc-web-text+proto", :connection "keep-alive"}}
#2020-06-2416:58thhellerit is 100% your code being the problem. not datafy.#2020-06-2416:58ghaskinsoh, im sure its me#2020-06-2416:58ghaskinsi just dont understand whats wrong#2020-06-2417:03thhellerI don't know either. Don't have enough code to make sense of any of this.#2020-06-2417:03ghaskinsill see if I can put a test-case together#2020-06-2420:56Adrian SmithHas any one ever got https://chakra-ui.com/getting-started working under shadow-cljs? I can get it working with React but with shadow no dice :S#2020-06-2421:59Adrian SmithI was missing empty maps as the attributes for the components#2020-06-2501:23neilyioI'm getting a INTERNAL COMPILER ERROR trying to use https://github.com/oliver-moran/jimp in a new ClojureScript project. I've installed it with npm install --save jimp , and using :require ["jimp" :as jimp] . Not sure what to do, my Google searches have been dead ends.#2020-06-2501:27dpsuttonHave you looked in the shadow users guide for the different ways to interact with node libraries?#2020-06-2501:28dpsuttonThere are examples of all the ways to import npm libs. Perhaps you could identify which jimp is and make sure you are requiring it correctly#2020-06-2501:55neilyioYes, jimp asks for var Jimp *=* require('jimp'); and my import seems correct according to the user guide:
(:require ["jimp" :as jimp])
#2020-06-2501:24neilyio#2020-06-2501:24neilyioFull, painful output:#2020-06-2501:26neilyio#2020-06-2501:37lilactownI would check out what node_modules/jimp/browser/lib/jimp.js looks like#2020-06-2501:37lilactownit might be in a weird format and/or require some sort of processing before being usable by shadow-cljs#2020-06-2501:40neilyioI'll check it out, thank you for the pointer. It's a little frustrating to have this error from a "npm install" when it seems like a perfectly good CLJSJS package for jimp is available... but my understanding is that there's no way for me to use CLJSJS jimp in shadow-cljs, correct?#2020-06-2501:40lilactownthat’s correct, yeah. CLJSJS packages do not work with shadow-cljs#2020-06-2501:41dpsuttonHave you seen the import style and checked what form it should be in the users guide?#2020-06-2501:42lilactownyou could try using the version that is on CLJSJS. It’s 0.2.27#2020-06-2501:42lilactown@dpsutton the import style would probably not effect this, since it’s failing to even process the file#2020-06-2501:42lilactownit’s not breaking on usage#2020-06-2501:47neilyioYikes, node_modules/jimp/browser/lib/jimp.js is big. I really don't know what I'm looking for here. Here's the file if you're curious.#2020-06-2501:47neilyio#2020-06-2501:49lilactownyeah, it’s failing at the exports["default"] = void 0 for some reason#2020-06-2501:50lilactownhave you tried restarting shadow-cljs yet?#2020-06-2501:50neilyioYes, a couple times. Also updated it.#2020-06-2501:50lilactownkk#2020-06-2501:50lilactownyou could also try and require something other than the browser build#2020-06-2501:51lilactowne.g. ["jimp/es/index.js" :as jimp]#2020-06-2501:51lilactownI’m just spit balling, I am not really sure why it fails to process that file#2020-06-2501:51neilyioGood thinking. I'll try that and then the CLJSJS build if nothing works.#2020-06-2501:52neilyioThe only thing that came up in my searching was that "It's a Google Closure Compiler bug".#2020-06-2501:55lilactownhmm it looks similar to https://github.com/google/closure-compiler/issues/1714#2020-06-2501:59neilyio["jimp/es/index.js" :as jimp] worked! It compiles now.#2020-06-2501:59neilyioHow did you know to do that?#2020-06-2502:04neilyioAlso, do you think there's any point in raising this issue in the google/closure-compiler repo? Should I post the file there?#2020-06-2502:09lilactownreading the docs and source of jimp helped a bit#2020-06-2502:10lilactownthe README talks about the different builds and their tradeoffs. the browser build is something specific to webpack#2020-06-2502:10lilactownat least, AFAICT#2020-06-2502:10lilactowneither way, I had hope that the ES module was built in a way that was more amenable to GCC’s parser#2020-06-2502:31neilyioThanks for all your help with this, saved me hours.#2020-06-2504:35sova-soars-the-sora@neil.hansen.31 is it not the coolest thing when somebody saves you mountains of effort?! gotta give thanks. gratefulness the blessing#2020-06-2507:09bbssI am trying to use shadow-cljs as a library. I want to grab some cljs with npm dependencies from a jar or files. I found out I can do that with get-classpath-entries and index-classpath from shadow.build.classpath . Furthermore I am using shadow.build.api to configure the build with the various api/with-* and seem to successfully compile-sources. But I don't see the output appear in the :output-dir I wonder what I'm missing for that to work.#2020-06-2507:11thhelleryou need to "flush" it but each :target option has its own way of doing that#2020-06-2507:12bbssokay, thanks. Searching for flush examples :)#2020-06-2507:12thhellerwhat are you trying to do exactly? none of those things are documented in any way and not really part of any public API I recommend using 😛#2020-06-2507:14bbssOn a high level, I am trying to make "plugins" that provide a nice way to use cljs and JavaScript libraries from Clojure by providing convenient api's to them and a base cljs app that relays usage of that api from clojure.#2020-06-2507:15bbssAnd right now I want to grab the base-app for each plug-in and compile it with shadow-cljs.#2020-06-2507:15thhellerI don't understand 😛#2020-06-2507:16bbssfor example if you'd want to use http://deck.gl#2020-06-2507:16bbssawesome webgl dataviz stuff#2020-06-2507:17bbssI'm wrapping that JS and allowing it to be used from Clojure#2020-06-2507:18bbssby running a web server with a base-app that understands calls you made to the clojure wraper#2020-06-2507:18bbssand the idea is to have multiple different JS libraries available like that#2020-06-2507:18thhellerI still don't understand 😛#2020-06-2507:18thhellerwhat is a "base-app"?#2020-06-2507:18bbssbase app is some clojurescript that bridges the calls you made to the clojure wrapper to the actual JS#2020-06-2507:19thhellerhow do you call the actual JS?#2020-06-2507:19thhellerI mean how do you intend to call CLJS from CLJ?#2020-06-2507:19bbssrun a webserver that passes websockets messages to the running base-app#2020-06-2507:20thhellerand the user is supposed to open a browser?#2020-06-2507:20bbsswell, the library I'm making does that, but yes#2020-06-2507:20thhellerok, so its a regular :browser build and you just dynamically add a few :entries for your plugins?#2020-06-2507:20bbssYes#2020-06-2507:21thhellerso why the low level API use?#2020-06-2507:21bbssHmm, I tried the higher level api, which is devtools.server I think? But that didn't pick up my resources well.#2020-06-2507:22thheller(shadow.cljs.devtools.api/compile* {:build-id :foo :target :browser :modules {:main {:entries [foo.bar-plugin] :init-fn {})#2020-06-2507:23thheller(shadow.cljs.devtools.server/start!) needs to be running before that though#2020-06-2507:23bbssthen it would pick up :foo from a shadow-cljs.edn in project root right?#2020-06-2507:23thhellerno, this is entirely custom config#2020-06-2507:24thhelleryou can call (api/get-build-config :foo) and then update-in or whatever and pass that to compile*#2020-06-2507:24bbsswhere would it get the resources from?#2020-06-2507:24thhellerclasspath#2020-06-2507:25bbssOkay, I'll give that api another go to see where I get. Thank you!#2020-06-2507:25thhellerbut I really don't have a clue what you are doing still 😛#2020-06-2507:25bbssI'm providing a nice way to use some JS libraries from CLJ basically#2020-06-2507:26thhellerI don't understand what that means ... why would you ever use a JS library from CLJ?#2020-06-2507:26bbssbecause you want to visualize some data you have in clj#2020-06-2507:26thhellerthe http://deck.gl is webgl visualization. how do you use that from CLJ?#2020-06-2507:28thhellerI guess the part I don't get is why you are trying to compile on the consumer side? that gets soooo complicated soo quickly#2020-06-2507:28thhellerdealing with arbitrary npm install conflicts and so on#2020-06-2507:28bbsshttp://deck.gl uses layers, I generated macros that wrap them and visualize them#2020-06-2507:29bbssSure it's another layer of indirection#2020-06-2507:30bbssI'm using first bootstrap, and now sci to compile functions in clj. It's complicated, but seems to work fairly well so far.#2020-06-2507:30thhellerI guess I'm confused by the whole plugin thing which CLJS is completely terrible at#2020-06-2507:31thhellerwhich is probably why you are compiling on the consumer side in the first place?#2020-06-2507:32thhellerlet me make a different suggestion maybe#2020-06-2507:32bbsssure#2020-06-2507:32thhellerit sounds like you are writing the plugin anyways?#2020-06-2507:32thhellerand you interact with that plugin over websocket provided by the base app#2020-06-2507:32bbssYes#2020-06-2507:33thhellerwhy not compile the "base-app" and provide that as part of the library (the compiled variant)#2020-06-2507:33thhellerthen on the consumer side you just need a webserver and serve static JS? no need to shadow-cljs to run at all?#2020-06-2507:34thhellerif you want you can use :modules to split everything#2020-06-2507:35bbssyes, that's what I'm doing now, but I am combining multiple bundles which seems problematic#2020-06-2507:35thhellerI never said compiled multiple bundles#2020-06-2507:35thhellerthat is a definite no-no.#2020-06-2507:35thhellerI mean the base-app distribution contains compiled code for all plugins ...#2020-06-2507:36thhelleryes I know that is less extensible#2020-06-2507:36thhellerbut plugins isn't something CLJS does well in any kind of way unfortunately#2020-06-2507:37thhellerand giving up on all :optimizations is also terrible#2020-06-2507:37bbssYeah I am aware of no optimizations and it being hacky#2020-06-2507:38bbssI dynamically resolve symbols from from the window, and the main blocker now is that react hooks don't seem to work if I include two plugins that use react.#2020-06-2507:38bbssmy assumption is because there are multiple reacts required (eventhough same version)#2020-06-2507:39bbssthat's why I was hoping that compiling it consumer side would solve those issues#2020-06-2507:42thhelleryes combining multiple builds on the same page is a recipe for disaster#2020-06-2507:43bbsssidenote: I think it's interesting you wrote your own "cljs bootstrap" recently. I'm fairly happy with sci, but it is kind of restrictive, needing to include symbols, explicitly allowing certain usage of DOM stuff, and erroring when functions get called with variadic arguments.#2020-06-2507:44thhellerI did no such thing 😛#2020-06-2507:44thhellerwell I guess kind of but it only looks like that#2020-06-2507:44bbssyou mentioned something along those lines and maybe expanding upon it later, looking forward to reading more 🙂#2020-06-2507:44thhellersci works without a running shadow-cljs watch. my stuff doesn't 🙂#2020-06-2507:46bbssI'm mostly writing this as an extension of a clojure programmers toolkit in mind, not necessarily web-app proof.#2020-06-2507:46bbssSo running shadow-cljs in the background and not doing advanced compilation is not an issue.#2020-06-2507:47thhellerwell but what happens if they already use shadow-cljs? two instances is not a great idea and its not designed to work that way.#2020-06-2507:48borkdude@bbss > erroring when functions get called with variadic arguments that should not happen. btw, you can access most DOM stuff with {:classes {:allow :all 'js goog/global}} maybe#2020-06-2507:48borkdudeplease post a bug report about the variadic stuff#2020-06-2507:49bbssThanks @borkdude will give that a try. It was able to side-step the issue for now by declaring [.. & args] for the calls to not error.#2020-06-2507:50borkdude@bbss Do you mean that sci errors on function calls that would also error on the JVM, but not in CLJS?#2020-06-2507:50borkdudelike: (apply inc [1 2 3])#2020-06-2507:51bbssYes, I looked into the codebase for a while to try and fix it but didn't really figure it out at the time.#2020-06-2507:51borkdudeI don't see how one would like to turn that off honestly 😉#2020-06-2507:52borkdudefeel free to discuss any other sci issues in #babashka (sorry for the off topic-ness here)#2020-06-2507:52bbssOkay, bringing it there.#2020-06-2507:57bbss@thheller two instances wouldn't be good, agreed. Having all this plugin stuff play nicely with shadow-cljs is something I want to consider.#2020-06-2507:58thhellerwell I think you could create 2 new targets#2020-06-2507:58thhellerone for the main app#2020-06-2507:58thhellerand one for the plugins#2020-06-2507:58thhellerbut I don't even know how you'd deal with things using different versions#2020-06-2507:58thhellerand how you handle plugins sharing dependencies and so on#2020-06-2507:58thhellerso compiling on the consumer side may be your best option#2020-06-2508:00bbssalright, giving that a go. Thanks!#2020-06-2510:58superstructor@thheller I just raised an issue for a possible race condition in shadow.cljs.bootstrap.browser/init for bootstrapped environments. Please ping me here or on GitHub if you need any further info or help as we have quite comprehensive tests. Thanks 🙂#2020-06-2512:41thheller@superstructor please setup a reproducible example if you want me to look into this#2020-06-2512:54superstructorOk will look into this tomorrow 👍#2020-06-2515:28kennyI'm getting an error in a production shadow-cljs build. It occurs only some of the time but I don't think that actually has to do with the issue. The error message is "ReferenceError: Highcharts is not defined". In Chrome I can click the line number in the error message to take be to the minimized JS. Chrome also has a handy formatter that will pretty print the minimized code (this feature is extremely cool btw. It even goes back and updates the line numbers in the error to point to the pretty printed code!) The line number it takes me to has this code:
d: Highcharts.SVGRenderer.prototype.symbols.arc(g, m, this.center[2] / 2, 0, {
Typing Highcharts in the browser console also leads to a "ReferenceError: Highcharts is not defined". It would appear Highcharts is expecting the Highcharts object to be globally defined but it is likely not due to the advanced build. Any idea what the correct solution to this would be?
#2020-06-2515:31kennyI could add a top-level (set! (.-Highcharts js/window) highcharts) which may fix the issue but that doesn't seem like the right solution.#2020-06-2515:33kennyHighcharts is used in our app by including "highcharts": "8.1.2" in package.json and in a :require like this ["highcharts" :as highcharts].#2020-06-2515:43kennyI believe this is the exact error! https://github.com/highcharts/highcharts/issues/13710#2020-06-2516:03kennyYep that was it. For those interested or who may hit this as well.. Rolling back to 8.1.0 appears to fix it 🙂#2020-06-2517:40tony.kayI’m trying to use an npm module that requires css. My understanding was that shadow just ignores css requires (according to this blog post https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html), but I’m getting this error:
Failed to inspect file
  /Users/tonykay/fulcrologic/ucv/node_modules/react-calendar/dist/Calendar.css
which is coming from this statement in the react-date-picker library require("react-calendar/dist/Calendar.css");
#2020-06-2519:47thhellerI changed the default to throw instead of ignore. set :js-options {:ignore-asset-requires true} to get the old behavior back#2020-06-2519:48thhellerguess I forgot to document that somewhere#2020-06-2520:54tony.kayah, that explains it#2020-06-2521:28thhellerfun thing is that previously it just always ignored .css requires#2020-06-2521:29thhellerbut there are actual packages that have require("./some.css") that actually is supposed to load a some.css.js file ... fun times ...#2020-06-2521:43tony.kayoh jesus#2020-06-2517:40tony.kayusing 2.10.12 of shadow-cljs#2020-06-2518:05tony.kayrolling back to 2.8.100 (as a random choice) works#2020-06-2518:14tony.kayperhaps “works” is too strong a word. It doesn’t complain, but I guess it also ends up importing nothing. I think this lib just isn’t usable…nvm.#2020-06-2519:16lreadHello @thheller! As part of my checklist to test out rewrite-cljc before release, I’m verifying against various projects. One of these projects uses Shadow CLJS. It taught me that rewrite-cljc does not currently compile under Shadow CLJS. Rewrite-cljc has an internal cljs version of potemkin import-vars which, by its nature, looks at analyzer data. I dug in and noticed that Shadow CLJS analyzer data is a wee bit different than ClojureScript analyzer data. The part that interests me is that Shadow CLJS includes macros only under :macros and ClojureScript includes them under both :defs and :macros. I don’t know if this is an intentional choice by Shadow CLJS, and I expect I can adapt, but thought I should letcha know. Here’s a repro of what I found: https://github.com/lread/repro-shadow-cljs-analyzer-macro-diff#2020-06-2519:19lreadAnd… I am by no means an expert here, so I may very well be doing something incorrectly or inappropriately!#2020-06-2519:50thheller@lee IMHO its a bug that CLJS includes macros from CLJS files. they can never be used and shouldn't exist in that ns as functions. leads to weird and strange behavior.#2020-06-2519:51thhelleror maybe I'm misunderstanding something? basically shadow-cljs ignored defmacro in CLJS files. that is all.#2020-06-2519:55lreadThanks for the reply @thheller! Ya, I really don’t know what is correct. My cljs import-vars only currently updates :defs and does not touch :macros and import-vars on macros works. I’ll experiment.#2020-06-2519:58thhellerwell your import-vars should likely ignore the macro defs since they are unusable anyways#2020-06-2519:58thhellerno use in importing them to another ns, still useless there 😛#2020-06-2519:59lreadah… interesting… thanks for the tip!#2020-06-2520:09neilyioI've been wondering... with a "hot-reload" setup like shadow-cljs, is there any reason why I would ever want to "evaluate" my ClojureScript code through CIDER in Emacs? As in using cider-eval-defun-at-point after changing some code? My understanding is that shadow-cljs is just watching for changes to the saved file, and evaluating code in the CIDER REPL isn't so useful.#2020-06-2919:40magraHi, in Cider I find the
cider-eval
which default bindings
C-x C-e
very userful. I have complex fulcro components, which are react-components. With cider eval I can evaluate any part of bigger structures. Like in
(let [a (my-fun (+ c b))]
  do-stuff)
I can put the cursor between the two closing parens of b)) and check whether (+ a b) is what I think it is. Or behind be to check just whether a is what I think it is. If c or b is not defined because they are arguments of the function I can have a comment in the file which binds values for debugging like so:
(comment
  (def a 4)
)
This is invaluable for me when chasing bugs. Of course I often just insert (str a) into the ui to do a sort of println debugging, too, but the ui often stops rendering when react gets bad data.
#2020-06-2520:11thhelleryeah I use the CLJS much less than CLJ because of hot-reload#2020-06-2520:12neilyioI'm sure the answer will seem obvious... but as a newcomer I don't have a great conceptual model of how the whole system works. I don't really get the relationships between the ClojureScript that is getting compiled, evaluation in CIDER nREPL, shadow-cljs server, shadow-cljs watch app, etc.#2020-06-2520:12neilyio@thheller could you elaborate on that? I don't understand.#2020-06-2520:12thhellerread the user guide?#2020-06-2520:13neilyioSorry, I meant your last statement.#2020-06-2520:13neilyioI realize that I have some studying to do to build my mental model.#2020-06-2520:13thhellerin CLJ I use the REPL for basically everything all the time#2020-06-2520:13thhellerin CLJS I barely ever use it#2020-06-2520:14neilyioGot it, glad to hear I'm not missing something then.#2020-06-2520:14neilyioThanks for the tip, and for shadow-cljs. I wouldn't have made it this far in ClojureScript without it.#2020-06-2521:22sova-soars-the-soraHi, i'm trying to make a .js build for production.#2020-06-2521:23sova-soars-the-soraBut I get some funky errors on calls...#2020-06-2521:23sova-soars-the-sorawhen on the server online#2020-06-2521:25sova-soars-the-sora
MBP:rolo-client janell$ npx shadow-cljs release frontend --debug
------------------------------------------------------------------------------
shadow-cljs - config: /Users/ja/nos.lv/rolo/rolo-client/shadow-cljs.edn
[:frontend] Compiling ...
Warning: Nashorn engine is planned to be removed from a future JDK release
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
------------------------------------
#2020-06-2521:28thhellerthats not an error thats a warning. you can ignore that one#2020-06-2521:29sova-soars-the-soraokay cool#2020-06-2521:30sova-soars-the-sorain the clientside when i run it i get some red... pardon the redness#2020-06-2521:30sova-soars-the-sorakinda hard to diagnose but i'm on it ^.^#2020-06-2521:31thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2020-06-2521:32thhellermake sure thats on :auto#2020-06-2521:32sova-soars-the-soralearning in progress pls wait#2020-06-2521:38sova-soars-the-sorano dice yet but i'll keep learning about the options#2020-06-2521:38sova-soars-the-soragonna try with optimizations simple#2020-06-2521:40sova-soars-the-sora😄 😄 😄 😄 😄 😄 😄#2020-06-2521:40sova-soars-the-sorawe are live ladies and gentlemen#2020-06-2522:44lread@thheller thanks again for your help on the analyzer differences. I dug a little more. My problem arose from the fact that Shadow CLJS and ClojureScript return different data for resolve. Details are here if you are curious: https://github.com/lread/repro-shadow-cljs-analyzer-macro-diff#resolve-macro-differences#2020-06-2606:35CaseyI have a customized shadow.build.targets target namespace I'm using, currently it just sits in my codebase along with my app. Is there a way I can pull it out of the source tree, but still have it found on the classpath when shadow runs?#2020-06-2607:09thheller@ramblurr just turn it into a library and use it as a regular dependency#2020-06-2607:20Caseygood idea, thanks.#2020-06-2609:38pmooserI'm trying to use react-markdown in reagent via shadow-cljs, but I get this error when I require it:
[:app] Build failure:
The required JS dependency "path" is not available, it was required by "node_modules/vfile/core.js".
#2020-06-2609:39pmooserWhat's typically done to fix something like that?#2020-06-2609:40pmooserI guess path is a node.js thing ...#2020-06-2609:42pmooserI can always go for a different approach WRT markdown.#2020-06-2609:46pmooserI found a path-browserify polyfill, but I got a different error, which lead me to this :#2020-06-2609:46pmooserhttps://github.com/thheller/shadow-cljs/issues/519#2020-06-2609:48pmooserI'm launching via deps ...#2020-06-2609:50pmooserOk, I think I've worked it out.#2020-06-2609:55pmooserIt looks like npm installing path-browserify and process is enough to resolve those issues.#2020-06-2610:16thheller@pmooser npm install -D shadow-cljs in your project#2020-06-2610:17thhellerthat will bring in those deps ...#2020-06-2610:24pmooser@thheller Thank you ...#2020-06-2615:25kennyI'm trying to output source maps for https://sentry.io/. Setting these keys in the :compiler-options will output a source map file.
:source-map                         true
:source-map-include-sources-content true
:source-map-detail-level            :all
After adding those keys, however, if I visit my production built app, I receive this warning in the console: "DevTools failed to load SourceMap: Could not parse content for http://localhost:3002/js/main.js.map: Unexpected token < in JSON at position 0". It's clearly trying to load sources maps and getting HTML back, thus the error. My question is if there is a way to output source maps and not have the console attempt to load the source maps. I'm guessing when those above keys are set, the outputted JS has some sort of indicator to tell the browser to attempt to load source maps. In a production build without the above keys set, I do not get the warning message printed in the console.
#2020-06-2615:43kennyYes - shadow is including
//# sourceMappingURL=main.js.map
As the last line in the outputted JS. Is there a way to output source maps without this line included in the final JS?
#2020-06-2615:48kennyI suppose I can do this sed -i '/sourceMappingURL/d' out/public/js/main.js . Seems like there should be a way to tell shadow to output source maps without the line in the released JS file though.#2020-06-2617:10erikwhen developing a chrome extension (one with a bg script, content script as well as devtools panel), in what context does the REPL execute and how to access any of bg, content script or devtools panel?#2020-06-2617:42thheller@eallik since they are 3 different contexts you have 3 different runtimes that you can REPL into#2020-06-2617:42thhellerunfortunately no editor has good support for switching between them#2020-06-2617:42thhellergranted that the API for this in shadow isn't much better#2020-06-2621:29donyormSo I'm trying to run tests with a test build target (using :browser-test as the target), but when I run shadow-cljs watch test no http server is started. Is my config messed up?
{:target :browser-test
   :test-dir "public/js/test"
   :devtools  {:http-port          8021
               :http-root          "public/js/test"
               :http-handler shadow.http.push-state/handle
               }}
#2020-06-2709:48erik@thheller so is it possible at all? at least to switch the default connect-to context? and in any case, which context does the shadow nREPL connect to by default? bg or content?#2020-06-2709:59thhellerwhatever connects first 😛#2020-06-2714:36erikso it’s currently not deterministic even?#2020-06-2715:51thhellerhonestly I can't remember too much about chrome extensions#2020-06-2717:41thheller@kenny there is :compiler-options {:source-map-comment false} but I'm not sure its supported for all targets.#2020-06-2915:04kennyThanks! Afaict, this isn't documented. Would be great to have it under https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options.#2020-06-2915:15kennyFor those following along, I can confirm this does work as expected for the :browser target.#2020-06-2717:41thheller@donyorm looks fine but http servers aren't really related to any build. consider using the newer :dev-http. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2020-06-2717:51chuckleheadHello all - I'm trying to use the React UI components from the most recent version of the AWS Amplify framework in a CLJS project. I'm currently running into an issue that I think is related to the CLJS compilation, but I'm new to all of this and definitely out of my depth at this point. If I try to import the AmplifyAuthenticator component using ["@aws-amplify/ui-react" :refer (AmplifyAuthenticator)], I see the following in the shadow-cljs server console during the first build (which does go on to complete successfully):
[2020-06-27 12:53:18.268 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-b93ab635.js", :requires [{:line 1615, :column 73}]}
If I try to render an AmplifyAuthenticator component in my application I see the following in the console:
Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
If it helps: I think the new Amplify framework wraps Web Components and my suspicion is that I'm either doing something wrong in the way that I'm importing or compiling that's causing a polyfill to go missing, or doing something wrong in the way that I'm creating or passing children to the new version of the component. There are examples online using a prior version of the framework with CLJS and I was able to put together a minimal reproduction where the legacy Authenticator component from aws-amplify-react renders and swapping it for AmplifyAuthenticator from @aws-amplify/ui-react fails. https://github.com/casselc/amplify-reproducer https://github.com/casselc/amplify-reproducer/compare/works-legacy-aws-amplify-react Would appreciate any pointers in the right direction, thanks!
#2020-06-2718:20thheller@chuck.cassel guess it requires ES6 classes. set :compiler-options {:output-feature-set :es6}#2020-06-2720:19chuckleheadThanks, I'd played around with that in my actual app before I got around to putting together the example but I still had some errors and concluded I didn't know what I was doing 😕. I just tried it again with the example in the repo and with :es6 it still doesn't render, but does give this error instead:
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
    at eval (index-b93ab635.js:1334)
    at Generator.next (<anonymous>)
    at b (app.js:34)
bumping up to :es8 for generators gives:
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
    at initializeComponent (index-b93ab635.js:1334)
Is this something where I need an extern? I've tried messing around with the various :infer-externs options without success.
#2020-06-2722:02thhellermaybe try :es7 or :es8?#2020-06-2722:03thhellerthis does not seem externs related#2020-06-2722:03thhellerany other errors before that one?#2020-06-2722:41chucklehead:es7 gives the same as :es6, :es8 and :es-next both give
index-b93ab635.js:1606 Module not provided: ./amplify-authenticator.cjs.entry.js
index-b93ab635.js:1334 Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined
    at initializeComponent (index-b93ab635.js:1334)
no other errors in the browser, and only the js-invalid-requires message in the shadow-cljs server output.
#2020-06-2722:44chuckleheadIf I wanted to test bringing it in via CDN, what would the :js-options {:resolve {"@aws-amplify/ui-react" { ... }} need to look like to pull in individual components? Not sure I understand what's going on well enough to translate the react globals example in the user guide.#2020-06-2800:09Nolanim thinking i must have botched a dependency version or something somewhere along the line, but just upgraded to {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7d0e151c19120a501e11170e3d4f534c4d534c4e"}, :content ("[email protected]")} with:
{:deps   {:aliases [:cljs]}
 :builds {:browser {:target :browser ,,,}}}
and i cant seem to figure out why this is happening:
$ shadow-cljs watch browser
...
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
...
Caused by:
NoSuchFieldError ES3
is this looking familiar to anyone? i imagine i need to update piggieback or something like that, but i havent been able to crack it...
#2020-06-2800:47Nolanit seems pinning the com.google.javascript/closure-compiler-unshaded version to the same version in the shadow-cljs/deps.edn file eliminates that issue, but fails the build with:
[:browser] Build failure:
RuntimeException: No such resource: js/es6/util/createtemplatetagfirstarg.js
#2020-06-2800:54Nolanhuh—removing the org.clojure/clojurescript entry in the deps.edn (i.e. not setting the clojurescript version explicitly) fixed the rest of the issues. apologies for the noise. will leave in case others stumble#2020-06-2807:55thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-06-2813:58sova-soars-the-soraIs there a rule of thumb for what vars to earmark as ^:export ?#2020-06-2814:02dpsuttonmy understanding is that you only need to mark vars which you need to call from outside cljs and therefore need a stable and predictable name#2020-06-2814:03dpsuttonso not a rule of thumb. you either have a requirement to mark it as export to be able to know its name or your don't have that requirement#2020-06-2814:03sova-soars-the-soraOhh interesting. Cuz some of my variables are getting munged and "cannot call ab of undefined" and such when I used :advanced So ^:export probably won't help there#2020-06-2814:04sova-soars-the-soraI figured it would preserve var names but yeah why would that be a problem if it had them all saved in a table or w/e#2020-06-2814:04dpsuttondoes it work under no optimizations but fails under advanced?#2020-06-2814:04sova-soars-the-sorayes.#2020-06-2814:05dpsuttonah. i think the recommendation is to use :pseudo-names true in your compiler options for your build#2020-06-2814:05dpsutton> You can use shadow-cljs release app --debug to enable both temporarily without touching your config. This is very useful when running into problem with release builds#2020-06-2814:14sova-soars-the-soraHmmm. I still get cannot call undefined.. pardon the Red#2020-06-2814:14sova-soars-the-sora#2020-06-2814:15thheller@sova use shadow-cljs release app --debug#2020-06-2814:15thhellerthats source maps + pseudo-names#2020-06-2814:16thhellermuch easier to identify where the actual issue is#2020-06-2814:16thheller:export you only need for things you are calling by name from the HTML or so. not required for anything else and never fixes any other naming issues.#2020-06-2814:17sova-soars-the-soraAh, if I want to call a function() from the javascript / html side I use :^export#2020-06-2814:17sova-soars-the-soraokay I will try with release app --debug and see#2020-06-2814:18sova-soars-the-sorayeah it works with no optimizations, awesome-O, but creates a 2.1 mB file so ... would be nice to shave that down a tad.#2020-06-2814:22dpsuttonshadow-cljs release app --debug uses advanced optimizations. it sets :pretty-print and :pseudo-names to true to help you diagnose problems like these#2020-06-2814:22dpsutton> :pretty-print and :pseudo-names default to false. You can use shadow-cljs release app --debug to enable both temporarily without touching your config. This is very useful when running into problem with release builds#2020-06-2814:23dpsuttonhttps://clojurescript.org/reference/compiler-options#pseudo-names#2020-06-2814:32sova-soars-the-soraawesome.. thanks guys... mmm it seems like it comes down to my hydrate code. I wonder if I could post it in code-review#2020-06-2909:26Chris McCormickis there a guide for self-hosting settings when using shadow-cljs? (per https://clojurescript.org/guides/self-hosting)#2020-06-2910:07Lucy WangAFAIK shadow-cljs requires JVM so it's not possible to run on self-hosted cljs#2020-06-2911:19thheller@chris358 there is only this https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2020-06-2912:13Chris McCormickperfect. thank you.#2020-06-2912:33Chris McCormickOn the blog post linked above it says: > Usually shadow-cljs does not require lein but it is required in this case since I’m using lein to build the shadow-cljs project. However i don't see lein being invoked.#2020-06-2912:34thhellerthis only applies if you clone shadow-cljs which you should not do
#2020-06-2912:35thhellerlook at a standalone example. the example I made in the main shadow-cljs repo is not maintained and likely doesn't work anymore#2020-06-2915:57kennyI continue to intermittently get an error like this when starting shadow-cljs:
------ ERROR -------------------------------------------------------------------
 File: /home/kenny/compute/monorepo/projects/ui/src/compute/ui/analytics/cloud_acct/view.cljs:44:12
--------------------------------------------------------------------------------
  41 | (defn CloudAccountsTable
  42 |   [{:keys [:integration/type]}]
  43 |   [table/Table
  44 |    #::table{:table-class "is-fullwidth"
------------------^-------------------------------------------------------------
No namespace: compute.ui.components.table found

--------------------------------------------------------------------------------
The compute.ui.components.table namespace is required in the view file references in the above error. The error seems to magically disappear and reappear with no clear way to reproduce it. Previously Thomas thought this was due to a dependency conflict with the reader. Looking at the output from clj -Stree, I can see org.clojure/tools.reader 1.3.2 is coming directly from thheller/shadow-cljs 2.10.13. Has anyone else been hitting this? Workarounds? I have not been able to come up with something that will consistently fix the issue.
#2020-06-2915:59kennyIt occurs with anything that uses the namespaced map reader (e.g., #::table )The only solution I can think of is to not use that anymore. I would think shadow would be compatible with it though.#2020-06-2915:59thhellerThis error isn't from shadow-cljs. so no clue what would cause it.#2020-06-2916:01kennyIt started happening several weeks ago when updating to the latest shadow version. Perhaps it's some sort of issue with cljs?#2020-06-2916:01kennyIt feels like some sort of race condition due to the intermittency.#2020-06-2916:01thhellerI don't know. never seen it myself.#2020-06-2916:02thhellerif the namespace has a proper require for the alias table then race condition shouldn't really happen since that ensures the ns is compiled before#2020-06-2916:02kennyIt's quite consistent. 3 other devs on my team have been hitting it. Another "workaround" is to have shadow reload the "problem" namespace (in this case compute.ui.components.table) by creating a trivial change and saving.#2020-06-2916:02thhellerI don't know. maybe look at the tools reader source or whereever that error is from#2020-06-2916:03kennyThere's no stacktrace.#2020-06-2916:03thhelleryeah thats weird too#2020-06-2916:04kennyThere's a bit more code in the error message but literally nothing else.#2020-06-2916:04thhellerhmm its not even in tools reader#2020-06-2916:05kennyIt's almost like these are false errors :man-shrugging::skin-tone-2:#2020-06-2916:05thhellerah the error is from clojure#2020-06-2916:06thhellerstill doesn't explain it though#2020-06-2916:06kennyWere you looking for where "No namespace: %s found" occurs?#2020-06-2916:06thhelleryeah#2020-06-2916:07thhellerapparantly on the-ns but shadow-cljs also never uses that#2020-06-2916:08thhelleryeah no clue. don't have time to dig deeper now.#2020-06-2916:08thhellerwould help a lot if you reproduce this somewhere#2020-06-2916:08thhellerare you maybe using the embedded variant and use tools.namespace in CLJ?#2020-06-2916:08thhelleror is this running standalone?#2020-06-2916:08kennyHmm. I've tried for weeks to get a reliable repro. Every time I try, the error magically goes away.#2020-06-2916:09kenny> are you maybe using the embedded variant and use `tools.namespace` in CLJ? Afaik, no use of tools.namespace. > or is this running standalone? We start shadow with npx.#2020-06-2916:09kenny
npx shadow-cljs watch app devcards
#2020-06-2916:10kennySometimes deleting .shadow-cljs helps.#2020-06-2916:12kennyfwiw, compute.ui.components.table is a .cljs file not .cljc and no .clj counterpart.#2020-06-2922:26lilactowncould there be something in the compute.ui.components.table namespace preventing it from being parsed?#2020-06-2922:27lilactownI remember running into this at work as well, I can't remember how we fixed it#2020-06-2923:08kennyI don't think so. Changing the keywords from the reader map syntax to regular keywords fixes the issue. The intermittency is also strange.#2020-06-3000:17kenny@U05224H0W Would you like me to open an issue for this?#2020-06-3006:28thhellersure#2020-06-3015:29kennyhttps://github.com/thheller/shadow-cljs/issues/748#2020-06-2923:02fabraohello all, how do you use font-end shadow-cljs and back-end in the same port in dev mode? I mean, start shadow-cljs and something like ring to provide shadow-cljs reload?#2020-06-2923:07thhelleryou make your backend server serve the static files shadow-cljs generates#2020-06-2923:23fabraocan I use something like hiccup to generate the html5?#2020-06-2923:23thhellersure#2020-06-2923:25fabraoHow shadow-cljs communicate with browser to do hot-reload?#2020-06-2923:25thhellerwebsocket to the shadow-cljs watch process#2020-06-2923:26fabraoso, when html5 "render" like app.js is that time both communicate?#2020-06-2923:28thhellersorry too tired for this. shadow-cljs produces JS files. it doesn't matter what you use to serve them and your server doesn't need to do anything to "enable" shadow-cljs. just serve static files.#2020-06-2923:29fabraosorry about asking this dumb question, because I came from lein figwheel that does all the stuffs for us#2020-06-2923:30lilactown@fabrao there are a number of shadow-cljs templates out there - it might be worth looking at how they work and deconstructing them#2020-06-2923:32fabraook, last project I used helix and graphql in separated projects because I didn´t know how to join both#2020-06-2923:33fabraonow I´m trying to join both in the same project, thank you#2020-06-3001:03frankitoxHi! I'm using shadow-cljs hooks (`:flush`) to trigger a little Linux command to show a notification in case a warning happens. I'd like to do the same thing each time an error appears, but none of the hooks seem to help#2020-06-3008:08magraat thheller: I just startet using tap on the ring-request. Thank you!!!!! Very nice!!#2020-06-3010:08pmooserDoes anyone know what the right way to require something like CodeMirror is? When I'm using random JS packages, I'm often a bit confused by the require/import statement.#2020-06-3010:09thheller(:require ["codemirror" :as cm])#2020-06-3010:09pmooserIf I do something like (:require ["CodeMirror" :as cm]) then cm itself seems to be a function?#2020-06-3010:09thhelleryep, the constructor to be precise. so you (cm. #js {:opts ...})#2020-06-3010:10pmooserSo when I see an example like, CodeMirror.fromTextArea() ... how do I reach that?#2020-06-3010:10thhellercm/fromTextArea#2020-06-3010:10pmooserHuh, wow, really? I'm so confused!#2020-06-3010:11thhellerwell (.fromTextArea cm ...) is also ok#2020-06-3010:11thhellerusually :as just sets up an alias but in case of JS requires it may also be used as an object#2020-06-3010:13pmooserOk, thank you ! Not being much of a JS guy, I've never quite understood exactly how those JS namespaces/etc get mapped into cljs.#2020-06-3010:14thhellerexactly as in CLJ basically the only difference is that CLJ doesn't allow :as foo using foo directly where each def would be a property of that foo#2020-06-3010:15thhellersince JS doesn't have real namespaces we can cheat ... 😛 and JS frequently does#2020-06-3010:15pmooserBut like periodically I see things that don't exist in CLJ, like :default (I think?) ...#2020-06-3010:20thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-06-3010:21pmooserThank you ...#2020-06-3010:21thhellerbecause CLJ or Java have no such concept. thats strictly about being able to use JS features as intended#2020-06-3010:22pmooserOk, that table is extremely useful.#2020-06-3010:23pmooser(as a translation guide)#2020-06-3010:26pmooserI see an example where someone is using cljsjs, and they require the clojure mode for CodeMirror like:
cljsjs.codemirror.mode.clojure
#2020-06-3010:27pmooserI don't quite understand how to do that, or translate it, to shadow-cljs using the npm directly.#2020-06-3010:27pmooserMaybe if I understood a little more about the layout of an npm compared to the github repo for CodeMirror.#2020-06-3010:35pmooserMaybe something like this: ["CodeMirror/mode/clojure/clojure.js"]#2020-06-3010:35pmooserYeah, I think that did it allright.#2020-06-3010:45gmercerHi, I was trying to println debug my routes and the output seems to be swallowed by shadow - is there a way around this ?#2020-06-3010:47gmercer(def dev-handler (-> #'routes wrap-reload push-state/handle)) - this is the dev-handler generated from the re-frame template - I got a prn to work upon the load of the handler namespace#2020-06-3010:56thhellerI recommend running any kind of server-related code separately. leave shadow-cljs out of it. you won't have shadow-cljs in production either so don't tie it to your development server either.#2020-06-3010:58gmercerCool - I was wondering if there was a logger type interface to spit out something in the short term ?#2020-06-3010:59gmercerotherwise I should just include a logger (timbre etc.) to get it to land in a file#2020-06-3011:00thhelleras I said .. keep it separate then you can do whatever you want#2020-06-3011:01thhellereverything else you are on your own#2020-06-3011:02gmercerNo worries - thanks#2020-07-0100:35lgesslerhi, i'm working with a cljc file project.cljc and shadow's complaining that a clojure-only keyword doesn't exist even though it's only referenced inside a #?(:clj ...) reader conditional. the offending code:
(ns glam.models.project
  (:require #?(:clj [glam.neo4j.project :as prj])
            #?(:clj [glam.neo4j.core :refer [one rename-id]])
            #?(:clj [com.wsscode.pathom.connect :as pc])))

#?(:clj
   (pc/defresolver all-projects [{:keys [neo4j current-user]} _]
     {::pc/output [:project/id]}
     (prj/get-document-ids neo4j)))
the error:
X Compilation failed.
------ ERROR -------------------------------------------------------------------
 File: [...]/glam/models/project.cljc:8:18
--------------------------------------------------------------------------------
   5 | 
   6 | #?(:clj
   7 |    (pc/defresolver all-projects [{:keys [neo4j current-user]} _]
   8 |      {::pc/output [:project/id]}
------------------------^-------------------------------------------------------
glam/models/project.cljc [line 8, col 18] Invalid keyword: ::pc/output.

--------------------------------------------------------------------------------
   9 |      (prj/get-document-ids neo4j)))
  10 | 
  11 | #?(:clj
  12 |    (pc/defresolver get-project [{:keys [neo4j]} {:project/keys [id]}]
--------------------------------------------------------------------------------
#2020-07-0100:35lgesslerI think I must be missing something basic here... any suggestions?#2020-07-0100:40lgesslerif I expand the keyword and write :com.wsscode.pathom.connect/output the error of course goes away, but it'd be nice to avoid that#2020-07-0106:58erikis there any up-to-date schema against which to validate my shadow-cljs.edn?#2020-07-0107:12thheller@lgessler the pc alias needs to exist in CLJS as well. otherwise the code isn't readable. consider it a quirk in clojure and tools.reader since both have this issue. not something shadow-cljs can do anything about.#2020-07-0115:14lgesslergot it, thank you!#2020-07-0107:15thheller@eallik no. there are some specs for :builds but no overall schema#2020-07-0107:15erikseems that it silently ignores bad input...#2020-07-0107:34thhelleryeah it won't complain about bad keys#2020-07-0110:58Wilson Velezin shadow-cljs.edn what’s the difference between
:dev-http {8000 "resources/public"}
and
:devtools         {:http-root    "resources/public"
                   :http-port    8000}
?
#2020-07-0110:59thhellerthe second converts to :dev-http. use :dev-http. the :devtools http stuff is deprecated#2020-07-0110:59Wilson Velezthanks!#2020-07-0114:46bjrntHi, just started learning CLJS and I'm interested in trying this out: https://blog.fikesfarm.com/posts/2015-06-15-see-js-in-cljs-repl.html . I've tried setting :repl-verbose true in devtools in my shadow-cljs config file, but that didn't seem to do anything. Does anyone know if this is possible in combination with shadow-cljs?#2020-07-0115:04Wilson VelezI think it shouldn’t be in the devtools , probably in the first level of the edn, but I haven’t test it before
:repl-options {:repl-verbose     true}
#2020-07-0115:12bjrntGave it a try, but didn't seem to work#2020-07-0116:58thhellerthis is not supported by shadow-cljs#2020-07-0118:38bjrntGood to know, thanks!#2020-07-0119:10Jakub Holý (HolyJak)Hi! Is there a way to reset the Inspect tab of the shadow server so that I can easily see new values that have been tap-ed to it? Thanks!#2020-07-0119:11royalaid@thheller Hey quick question, is it easy for shadow to warn when an underscore is included as an actual clojure namespace symbol?#2020-07-0119:12royalaide.g. file name test_fixes.cljs and then a namespace name test_fixes#2020-07-0119:12royalaidwhen it should be test-fixes#2020-07-0119:13royalaidbecause I just started work at a new place and their project compiled fine under CLJS in a build script but shadow timed out with "par-timeouts"#2020-07-0119:13royalaidfixing the underscore was the solution#2020-07-0119:29thheller@holyjak not yet. planning to add it though.#2020-07-0119:30thheller@royalaid not even aware that was an issue. it should be warning already if the filename doesn't match the expected ns name but maybe it doesn't#2020-07-0119:35royalaidYeah I am not sure if it is a weird corner case or we hit a fluke but that definitely was the issue#2020-07-0119:37thhellerprobably should open an issue otherwise I'll forget 😉#2020-07-0119:57royalaidhttps://github.com/thheller/shadow-cljs/issues/749#2020-07-0119:58royalaidLet me know if that is enough to go on#2020-07-0205:23JAtkinsHow possible is it to dynamically load cljs modules? Use case is I'm trying to make a plugin system for an electron app. I'd like to have everything run under advanced compilation and be able to pull in optional deps, hopefully without dragging multiple copies of the cljs std library in. Does the EMCA support (-ish) in shadow have any bearing on this? If not this channel is most likely to have the answer anyway 🙂 AFAICT this is pretty easily possible if I don't care about importing cljs core multiple times. I can just use ^:export on the important functions and then use emca import.#2020-07-0206:06Chris McCormickcould you make a small js file that wraps require at runtime?#2020-07-0206:06Chris McCormickoh wait, sorry, cljs modules not js modules.#2020-07-0207:16thheller@jatkin plugins systems are impossible if you use :advanced. :advanced is whole-program optimization so it removes everything that isn't used. as soon as one of your plugins would use something that was removed previously everything breaks.#2020-07-0207:55thhellermultiple cljs.core is also not a great idea since they won't be compatible with each other. so can't pass a {:foo "bar"} map from one plugin to main or other plugin and expect that to work#2020-07-0208:38pmooserI'm trying to use react-color, but importing it from one of my namespaces gives me an error, which seems to be from:
failed to load module$node_modules$react_color$lib$components$common$index
#2020-07-0208:38pmooserAny idea what that may indicate about what I'm doing wrong?#2020-07-0208:41pmooserOk, that comes from this error (I think):
Uncaught TypeError: Cannot redefine property: Alpha
#2020-07-0208:41pmooserAnd maybe that's from this code?
Object.defineProperty(exports, 'Alpha', {
  enumerable: true,
  get: function get() {
    return _interopRequireDefault(_Alpha).default;
  }
});
#2020-07-0208:41pmooserBut I'm a bit mystified by it nonetheless ...#2020-07-0208:44pmooserAhh ... maybe this is just in the bootstrap build or something?#2020-07-0208:46pmooserI'm not sure if there's a way to exclude just this one react npm from the bootstrap build, or why it's a problem ...#2020-07-0208:47thhellerwhat is a bootstrap build?#2020-07-0208:48thhelleryou mean actual self-hosted :target :bootstrap?#2020-07-0208:48pmooserYes, that is what I mean. Sorry.#2020-07-0208:49pmooserI mean this specifically blows up only in that build - I have a normal app build and then the self-hosted one.#2020-07-0208:49pmooserIf I exclude the whole NS that imports this, the error doesn't occur.#2020-07-0208:49thhellerno clue. if you setup a reproducible example I can take a look otherwise you are on your own.#2020-07-0208:50thhellertoo much self-hosted weirdness I don't want to get into#2020-07-0208:50thhellercan't redefine sounds like it is already loaded but it is trying to load over itself#2020-07-0208:51thhellerwhich shouldn't happen if you properly bootstrap/init and all of that but I don't know#2020-07-0208:52pmooserSure, I understand it's mysterious and not a priority for you. Just thought something might sound obvious!#2020-07-0208:52pmooserThe whole mechanics of the self-hosted build are more or less a mystery for me anyway.#2020-07-0209:07thhelleranything self-hosted is just as much a mystery to me 😉#2020-07-0209:09pmooserHeh ! I hope eventually I understand a little more ...#2020-07-0209:10defaI’m having an issue that my entry-point (init-fn) is missing in production builds. shadow-cljs compile app works fine, but shadow-cljs release app seems not to export my init funciton.#2020-07-0209:11thhellerits not supposed to be exported if you use :init-fn in your build config#2020-07-0209:11thhellerotherwise you control whats exported via ^:export#2020-07-0209:13defaI use
:modules    {:main {:entries [someapp.core]}}
and
(defn ^:export init [] ...
#2020-07-0209:13defathe init function is in someapp.core#2020-07-0209:15thhellerok that should create the somapp.core.init in JS?#2020-07-0209:19defabut not as a function. There is something like :
var shadow$provide = {};
(function(){
    ...
    Aa("someapp.core.init",function(){var a=new U(null,1,5,W,[zD],null);
    ...
}).call(this);
#2020-07-0209:20defaI can see no difference to https://github.com/shadow-cljs/examples/tree/master/re-frame but obviously I’m missing something.#2020-07-0209:20thhelleryeah that is supposed to create someapp.core.init with function(){var a...#2020-07-0209:21thhellerwhat is your actual problem though?#2020-07-0209:21thhellerhow are you using the function? or why don't use use :init-fn instead? or when do you actually use it?#2020-07-0209:23defaIn index.hml : <body><script>someapp.core.init();</script></body>#2020-07-0209:23defaI also tried :init-fn like in the docs but doesn’t work either.#2020-07-0209:24thhellerwell where is the script loaded?#2020-07-0209:24thhellergotta load the main.js for it to exist somewhere?#2020-07-0209:25defa
<html lang="en">
  <head>
    <meta charset='utf-8'>
    <!-- ... -->
    <script src="/js/compiled/main.js"></script>
  </head>
  <body>
    <div id="app"></div>
    <script>someapp.core.init();</script>
  </body>
</html>
#2020-07-0209:25thhellerand thats not a 404 or so? that is actually loading fine without any errors?#2020-07-0209:26thhellerI mean what does the browser console say?#2020-07-0209:28defaCan't find variable: someapp … but now I see that there is an error way before and that might cause the that the init-method will not be defined, right?#2020-07-0209:29defaI’m having a router in my app (reitit) and that seems to have an issue with compiler optimisations in production as it seems?#2020-07-0209:29defa=> Error: No protocol method Router.match-by-name defined for type null: #2020-07-0209:31defa=> https://metosin.github.io/reitit/basics/name_based_routing.html#2020-07-0209:31thhelleryes any error during load will cause the export to never be created#2020-07-0209:32thhellerwell something is nil. gotta find out what 😉#2020-07-0209:33thhellershadow-cljs release app --debug will make that a bit easier#2020-07-0209:35defaThanks, Thomas, I will start the search…#2020-07-0209:46defaChrome clojure devtools helped to find the error quickly. It was a debug statement (println "*** " (reitit.frontend.easy/href ::somethin)) on toplevel … bummer.#2020-07-0214:51strsndI seem to be hanging in an endless loop in watch where shadow-cljs is recompiling some files constantly. Anyone seen that before?#2020-07-0217:13thhelleris something maybe touching your source files or so? so shadow-cljs writes something, something else watches the output and touches something which then triggers shadow-cljs to compile again?#2020-07-0217:45strsndI checked with inotifywatch (using linux here) that there are no modifications to my src tree. I am investigating a bit later today what is going on there.#2020-07-0218:01strsndOh, can it have to do with me renaming my resources/ directory to resources-dev/ and I didn't notice since then? Looks like in shadow/build/classpath.clj it gets filtered.#2020-07-0218:03strsndIf I delete the contents of cljs-runtime, while it is looping, it regenerates and stops. Maybe the pattern doesn't match correctly here.#2020-07-0218:07strsndYeah, that was the change that leads to this behavior.#2020-07-0219:25bennyi’m stuck somehow, i’ve added cljs-ajax as a dependency and no matter what i do, i cannot get the repl to recognize the library:
(require '[ajax.core :refer [GET]])
=> nil
(GET "")
=> #object[ReferenceError ReferenceError: Can't find variable: ajax]
#2020-07-0219:25bennyi’ve added other dependencies like sente and everything works just fine#2020-07-0220:01thhellernot enough info to comment. need more context. what :target? anything in the console? etc?#2020-07-0220:03bennyhere’s my build:
:dev
                {:target     :react-native
                 :init-fn    client.core/init
                 :output-dir "app"
                 :compiler-options {:closure-defines
                                    {"re_frame.trace.trace_enabled_QMARK_" true}}
                 :devtools   {:after-load steroid.rn.core/reload
                              :build-notify steroid.rn.core/build-notify
                              :preloads [re-frisk-remote.preload]}}
#2020-07-0220:04bennyre: console, initially i tried running a shadow server and connecting via nrepl in cursive but tried dropping to a cljs-repl and ran the above in a non-user namespace#2020-07-0220:08bennyjust tried clearing everything, rebuilding, and got the same thing#2020-07-0220:58thhellerinclude it in one of you files first#2020-07-0220:59thhellerthen try the REPL. I think there is an open issue about this.#2020-07-0220:59thhellerhttps://github.com/thheller/shadow-cljs/issues/574#2020-07-0221:00thhellerI don't use react-native myself and my setup for it keeps breaking ... so kinda frustrating to work on it 😛#2020-07-0221:28bennyi suspected that would help too but it doesn’t unfortunately 😞#2020-07-0221:36thhellerwell any errors during load?#2020-07-0221:37thhellerhttps://github.com/JulianBirch/cljs-ajax/issues/218#2020-07-0221:38thhellerseems like a known problem?#2020-07-0222:09bennyno errors are surfaced at least. by the sounds of it, people have had luck with cljs-http in rn#2020-07-0306:42neuralHi, i have a question about the required fields in ns declaration. Is a string not required for a npm package now ?? I mean:
(ns foo (:require ["react" :as react]))
is now
(ns foo (:require [react :as react])) ??
Because i'am getting this error in my repl (emacs/cider): &lt;&lt; could not find string alias for "react" from foo &gt;&gt; and when i change to the no string version it works fine. But how now i require something like ["@material-ui/core" :as mui] ??? i cant have a no string version because of the the @ operator! I asking here in shadow-cljs channel because i think it start to happens after i upgraded shadow-cljs from npm to the last version 2.10.13.
#2020-07-0307:21thheller@neural.works.com strings are always preferred for JS dependencies#2020-07-0307:21thhellernot sure why you are getting that error. do you have more context for what you are doing?#2020-07-0307:21thhellerand the full error?#2020-07-0310:39borkdudeWhat benefit has using shadow-cljs over figwheel main?#2020-07-0311:59Chris McCormickin my experience of both, shadow-cljs feels more tightly integrated with the existing node ecosystem. you npm install shadow-cljs into your project and use a package.json rather than having the project.clj manage dependencies. importing node modules into frontend code seems smoother than it was under lein + figwheel. i am a big fan of figwheel, but i have not used figwheel for a few months and things might have changed. shadow-cljs.edn is far more concise for the most common use-cases than project.clj.#2020-07-0312:00borkdudeI'm talking about figwheel main, so the deps.edn based thing#2020-07-0312:02Chris McCormickoh sorry#2020-07-0312:02Chris McCormicki don't have experience with it#2020-07-0310:39borkdudeIt's ok to give a biased answer, I'm also going to ask in #figwheel-main#2020-07-0311:42Paulo CasarettoHey everyone! Getting started with shadow-cljs and experimenting with Preact. Couple of questions: 1. import "preact/debug"; would normally activate the debugging tools . Using it as such did in fact add the debugging tools to window as the developer extensions expected but it seems it something is off because it could not hook into the rendering process.
(ns 
  (:require ["preact/debug"]
            ["preact" :as preact]))
2. Preact offers a React compatibility layer. Do you think it would be possible to "trick" shadow.markup.react into working with Preact?
#2020-07-0313:45thheller@pcasaretto dont use shadow.markup.react but yes you can trick everything into using preact by just rewriting the react requires https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm#2020-07-0313:46thhelleryou probably want to move the preact/debug to :preloads ["preact/debug"] so its only included in dev builds#2020-07-0313:49thheller@borkdude I've never used figwheel in any real project so I won't even start to make comparisons. The things I focussed on with shadow-cljs is easier configs with better defaults. better support for :modules / code-splitting and useful things for release builds like [build-reports](https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report)#2020-07-0313:50thhellerif you like building your own setup from scratch then shadow-cljs is not for you#2020-07-0313:51thhellerif you instead just want a tool that works with minimal config and lets you get on with your project it might be 😉#2020-07-0313:51thhellernpm integration is also a bit smoother since you don't have to worry about webpack or anything on that front#2020-07-0313:52borkdudemy team lead isn't fond of npm in general so having to install npm to run the build may put him off#2020-07-0313:55thhellerwell if you intend to use npm packages via :bundle then you'll install that regardless#2020-07-0313:55thhellerif you just want CLJSJS then definitely do not use shadow-cljs since it doesn't even support those packages#2020-07-0313:55thhelleryou don't need to install npm to "run the build" though#2020-07-0313:56borkdudeyeah we use a lot of CLJSJS still#2020-07-0313:56borkdudeoh that was my impression, that you have to run npm install shadow-cljs ?#2020-07-0313:56thhellerit is recommended yes but not required#2020-07-0313:56thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2020-07-0313:57borkdudeso shadow-cljs doesn't support working with packages from CLJSJS? - how is that?#2020-07-0401:43rbergerShadow-cljs not working with CLSJS is a feature, not a bug. You don’t need CSJS anymore since you can so easily work directly with native npm libraries. No need to create brittle CLJSJS versions of all the libraries you want. Life is so much better this way. You can use just about any npm library you might need.#2020-07-0313:57thhellerCLJSJS is not supported at all yes https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2020-07-0313:58thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2020-07-0313:58borkdudeok, maybe figwheel main is the only viable option for us then right now#2020-07-0313:59thhellerif you don't intend to use npm packages then yes#2020-07-0313:59thhellerif you use npm packages then you need to get off CLJSJS anyways#2020-07-0314:00borkduderight, we're not there yet. thanks a lot#2020-07-0317:01neural@thheller Hi Thomas, when changing ns i am get this problem only when using strings in JS dependencies.
cljs.user=> (ns site.core)
[2020-07-03 13:59:18.978 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(ns site.core)", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (ns site.core), :source "(ns site.core)", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:519)
        shadow.cljs.repl/process-read-result (repl.clj:493)
        shadow.cljs.repl/process-input (repl.clj:673)
        shadow.cljs.repl/process-input (repl.clj:657)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
        java.lang.Thread.run (Thread.java:748)
Caused by:
ExceptionInfo could not find string alias for "react" from site.core {:require-from-id site.core, :require "react"}
        shadow.build.data/get-string-alias (data.clj:139)
        shadow.build.data/get-string-alias (data.clj:135)
        shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
        clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
        clojure.core/fn--8437 (core.clj:6845)
        clojure.core/fn--8437 (core.clj:6830)
        clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
        clojure.core/reduce-kv (core.clj:6856)
        clojure.core/reduce-kv (core.clj:6847)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
        shadow.cljs.repl/repl-ns (repl.clj:340)
------ REPL Error while processing ---------------------------------------------
(ns site.core)
could not find string alias for "react" from site.core
{:require-from-id site.core, :require "react"}
ExceptionInfo: could not find string alias for "react" from site.core
        shadow.build.data/get-string-alias (data.clj:139)
        shadow.build.data/get-string-alias (data.clj:135)
        shadow.build.ns-form/rewrite-js-deps/fn--9175 (ns_form.clj:639)
        clojure.lang.PersistentArrayMap.kvreduce (PersistentArrayMap.java:377)
        clojure.core/fn--8437 (core.clj:6845)
        clojure.core/fn--8437 (core.clj:6830)
        clojure.core.protocols/fn--8167/G--8162--8176 (protocols.clj:175)
        clojure.core/reduce-kv (core.clj:6856)
        clojure.core/reduce-kv (core.clj:6847)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:636)
        shadow.build.ns-form/rewrite-js-deps (ns_form.clj:628)
        shadow.cljs.repl/repl-ns (repl.clj:340)
        shadow.cljs.repl/repl-ns (repl.clj:328)
        shadow.cljs.repl/process-read-result (repl.clj:513)
        shadow.cljs.repl/process-read-result (repl.clj:493)
        shadow.cljs.repl/process-input (repl.clj:673)
        shadow.cljs.repl/process-input (repl.clj:657)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--14381 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045/fn--14053 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14044/fn--14045 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14044 (util.clj:257)
        java.lang.Thread.run (Thread.java:748)
It compiles fine, the problem is in repl
#2020-07-0317:32thheller@neural.works.com please open a github issue otherwise this will get lost#2020-07-0317:35neuralok#2020-07-0414:43Jakub Holý (HolyJak)@thheller thank you for shadow and good error messages! (Namely that :sources is ignored when :deps is truthy)! ❤️#2020-07-0603:01Tom H.Hi folks, is there a reason why shadow-cljs might include its remote runtime code in a release build?#2020-07-0603:02Tom H.I'm using shadow-cljs release app --verbose and seeing libs like Cache read: shadow/remote/runtime/cljs/env.cljs in the output#2020-07-0604:01Tom H.Nvm! Found the culprit in a require of shadow.remote.runtime.cljs.browser in one of our devtools that was also being included#2020-07-0607:57kirill.salykinGoodmorning, I am compiling cljs in a docker - everything seems fine, but when I run the compiled scripts - there is an error that package not found
dev_1         | internal/modules/cjs/loader.js:1032
dev_1         |   throw err;
dev_1         |   ^
dev_1         |
dev_1         | Error: Cannot find module '/app/app/app.js'
dev_1         |     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
dev_1         |     at Function.Module._load (internal/modules/cjs/loader.js:898:27)
dev_1         |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
dev_1         |     at internal/main/run_main_module.js:17:47 {
dev_1         |   code: 'MODULE_NOT_FOUND',
dev_1         |   requireStack: []
dev_1         | }
Maybe you have any ideas what goes wrong? thanks! UPD: found the issue - related to docker setup
#2020-07-0614:49wilkerluciohello, question, I'm trying to run some code on. Shadow Node REPL, but when I try to invoke any macros it says #object[TypeError TypeError: Cannot read property 'call' of undefined], is there any special thing that needs to be done to call macros on node repl?#2020-07-0614:51wilkerluciotried both :require and :require-macros, but same result#2020-07-0614:52wilkerlucio(:require [com.wsscode.async.async-cljs :as wasync :refer [go go-promise <!p]])#2020-07-0614:53wilkerluciousing latest shadow cljs#2020-07-0615:01wilkerlucioin version 2.10.6 it works fine, I'm going to bisect the between version to find when it stopped#2020-07-0615:04wilkerluciosorry, realised the problem was I was putting a clojurescript version in the deps, moving it to provided to shadow doesn't see it (I still want for the editor to see) fixed the issue#2020-07-0615:45kanweimorning - I'm getting this error when building#2020-07-0615:45kanwei
[:ddregister] Configuring build.
[:ddregister] Compiling ...
[2020-07-06 11:38:17.464 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
AssertionError Assert failed: (.exists file)
	shadow.build.cache/read-cache (cache.clj:33)
	shadow.build.cache/read-cache (cache.clj:33)
	shadow.build.closure/convert-sources-simple/fn--52392/fn--52394 (closure.clj:2097)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.build.closure/convert-sources-simple/fn--52392 (closure.clj:2089)
	shadow.build.closure/convert-sources-simple (closure.clj:2087)
	shadow.build.closure/convert-sources-simple (closure.clj:2009)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1164)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1157)
	shadow.build.compiler/compile-all (compiler.clj:1409)
#2020-07-0615:52kanweialright deleting cljs-runtime seems to have fixed it#2020-07-0617:48wilkerlucioanother thing, I'm noticing on the node repl, if shadow finds a warning, the file stops loading, is there a way to launch the node repl so it ignores warnings and just keeps running things?#2020-07-0617:48wilkerlucioI'm starting the node repl with shadow/node-repl from the server REPL#2020-07-0619:39bennyi’m targeting react-native and have images in a directory called images under the root of my project. my output-dir for the target is app but can’t figure out how to reference the images if my app is running from the app#2020-07-0620:27thheller@benny https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L9-L13#2020-07-0620:41bennysweet thanks @thheller#2020-07-0620:42bennyrn will just handle linking it when i’m building for release?#2020-07-0701:06steveb8nQ: anyone know how to build shadow-based devcards for a prod release? I’m trying to make it work here https://github.com/stevebuik/fork-malli-ideas#2020-07-0707:50thheller@steveb8n you are only setting :devcards true for dev. move that "up". also don't set :optimizations :none is never has any effect anywhere is already the forced default for dev#2020-07-0707:51steveb8nah ok. I’ll try that immediately. thanks!#2020-07-0708:00thheller@benny I'd expect so. I've never done an actual released RN app#2020-07-0708:56steveb8n@thheller that worked (but you already knew that 🙂. much appreciated#2020-07-0709:39romdoqHow can I debug hot reloading? For some reason, this week it's stopped working for me. 😞 The rebuild is triggered, I see the Shadow spinner in the browser, but the page doesn't get updated. 😕 I have an :npm-module which is used by a larger webpack'ed application. AFAIK the only thing that's changed since last week is that I updated a bunch of packages on my machine (Debian Testing), mostly libraries. I tried downgrading Chromium, to no avail.#2020-07-0710:50thheller@mel.collins what does the console say? is you after-load hook getting called? if so you must debug your app not shadow-cljs#2020-07-0710:57romdoqHmm, doesn't look like after-load is being called, no 😕#2020-07-0710:59romdoqI did a long-overdue upgrade of shadow-cljs not long ago, and if I revert to the previous version (2.8.something) it works again, so maybe I missed an important change? (though I'm not sure why it would've taken a week to manifest)#2020-07-0711:01thhellermaybe the usual version conflict? make sure you have no conflicts if you use project.clj/deps.edn#2020-07-0711:07romdoqI do use deps.edn, but the shadow-cljs version does match between that and package.json.#2020-07-0711:08romdoqcore.async was at a very different version to shadow's deps, but updating it didn't fix the issue#2020-07-0711:13thhellerbad core.async versions are known to cause issues#2020-07-0711:13thhellerand so are all the other possible conflicts#2020-07-0711:13romdoqHmm, downgrading clojurescript from .773 to .597 (as in shadow-cljs/deps.edn) causes errors with cider/piggyback.clj. Am I looking at the right file there?#2020-07-0711:13thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-07-0711:14romdoqAh, clojars. I had a feeling there was somewhere else that I found the dep versions previously#2020-07-0711:39romdoqHm. I had to add closure-compiled-unshaded, but I now have all four of the "important" dependencies specified at the same versions in my deps as on clojars, but still no dice 😕#2020-07-0712:28romdoqBah. I just tried using shadow-cljs.edn for dependencies (without shadow's own deps) and hot reloading still doesn't work 😞#2020-07-0712:29thhellerwhat is exactly IS happening though? I mean you said something happens?#2020-07-0712:29thhellerwhat does shadow-cljs watch app give you?#2020-07-0712:29thhellerwhat does the browser console say? any warnings/errors?#2020-07-0712:33romdoqThe only thing from Shadow in the browser console is: "shadow-cljs: #3 ready!" The things my before-load and after-load should both print to the console don't appear.#2020-07-0712:33thhellerthat just means that the connect happens#2020-07-0712:34thhellerwhat happens if you make a change?#2020-07-0712:34thhellerin the watch and in the browser console?#2020-07-0712:37romdoqin the watch I get the usual:
[:npm] Compiling ...
[:npm] Build completed. (321 files, 2 compiled, 0 warnings, 0.44s)
In the browser, I get nothing from shadow. Just webpack doing its normal:
[HMR] bundle rebuilding
...
Ignored an update to declined module ../path/to/my/yarn/linked/cljs/module.js
#2020-07-0712:37romdoqI do get the Shadow spinny thing in the corner of the browser though#2020-07-0712:41romdoqFWW, on startup, the watch warns about: Nashorn engine, a too-new react version, and an illegal reflective access by mranderson048; but none of those are new#2020-07-0712:42thhellerwait you have webpack HMR active?#2020-07-0712:43thhellerand this is a :npm-module build?#2020-07-0712:54romdoqyes#2020-07-0712:55romdoqwebpack's reloading is declined in the module which imports the cljs module, which has worked previously#2020-07-0712:58thhellersorry can't help you with this. too many unknowns. if you make a reproducible example I can take a look but running webpack HMR together with watch seems like a recipe for disaster#2020-07-0713:01romdoqYeah, thanks for the help anyway. 🙂 The setup has worked well so far, but it looks like some change in Shadow (since 2.8.55!) broke it. I'll go back and try to find the version/change where it stopped working, and debug from there.#2020-07-0713:02romdoqNot how I intended to spend my last workday before holiday, but these things happen 😄#2020-07-0714:31romdoq@thheller Looks like the cause was this part in build/targets/npm_module.clj:
(cond->
        ...
        (and (= :dev mode) (:worker-info state))
        (update config :devtools merge {:autoload false ;; doesn't work yet, use built-in for now
                                        :use-document-host false}))
Before this was changed (in 2.8.56), autoload was mis-spelled, so didn't actually get disabled: https://github.com/thheller/shadow-cljs/commit/c75fa3376efdbc8405e5f978db1db5f748861c55 However, when autoload is not false'd here, hot reloading works in my environment, so I'm not sure what the comment is referring to as not working?
#2020-07-0714:57thhellerjust set :devtools {:autoload true} then?#2020-07-0714:59romdoqThat code in npm-module seems to override whatever is specified in shadow-cljs.edn#2020-07-0715:01romdoqHowever, if I patch npm_module.clj renaming :autoload to :autoload* in the aforementioned code, hot reloading works without any setting in the edn file.#2020-07-0809:05thheller@mel.collins I removed the forced override in master. will probably make a release later.#2020-07-0809:51cflemingI’ve got my build into a state where whenever I restart it, I get a message: server pid exists but server appears to be dead, proceeding without server, and then my build hangs when compiling. Is there an easy way to just reset everything and force a clean build?#2020-07-0809:56thheller@cfleming unlikely that fixes anything but you can delete .shadow-cljs/builds. does it actually hang completely? does it max out cpu?#2020-07-0809:57thhellerI've had weird reports of "hangs" when using incompatible core.async versions? did you maybe change versions?#2020-07-0809:58cflemingNo, I’m not using core.async (well, some of the machinery via promesa, but not directly)#2020-07-0809:58thhellercheck for dependency conflicts in case you are using project.clj/deps.edn#2020-07-0809:59cflemingOk, I’ll do that. I’m using a project.clj but perhaps I should just switch to a pom.#2020-07-0809:59thhelleror maybe a macro going wild 😛#2020-07-0809:59thhellerdoesn't really matter what you use if its not shadow-cljs.edn#2020-07-0809:59cflemingDeleting that didn’t seem to help.#2020-07-0810:00cflemingWhere does it find the pid? Can I delete that?#2020-07-0810:00thhellersince only shadow-cljs.edn can somewhat ensure you get the correct deps#2020-07-0810:00thhellerpid doesn't matter. it is just telling you that the server probably did shut down cleanly#2020-07-0810:00thheller.shadow-cljs/server.pid but that doesn't mean anything#2020-07-0810:00cflemingSo I should implement direct shadow importing, is what you’re saying 😛#2020-07-0810:01cflemingOk, I’ll look - I don’t think I’ve changed anything along those lines.#2020-07-0810:01thhellerhehe. its fine to use the others. just need to ensure you get the correct deps manually and dependency issues are the most common problem people run into#2020-07-0810:01thhellersince we must get the correct mix of dependencies or things break 😞#2020-07-0810:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-07-0810:02thhellerusually they fail on start, sometimes they fail in weirder ways 😞#2020-07-0810:02thhelleralso shadow-cljs compile app --verbose might help#2020-07-0810:02thhellersee where it gets stuck
#2020-07-0810:05cfleming
~/d/c/lambda (licence-panel)> shadow-cljs compile local --verbose
shadow-cljs - server pid exists but server appears to be dead, proceeding without server.
shadow-cljs - config: /Users/colin/dev/cursive-site/lambda/shadow-cljs.edn  cli version: 2.8.77  node: v12.1.0
[:local] Compiling ...
-> build target: :node-script stage: :configure
<- build target: :node-script stage: :configure (5 ms)
-> Resolving Module: :main
<- Resolving Module: :main (43 ms)
-> build target: :node-script stage: :compile-prepare
<- build target: :node-script stage: :compile-prepare (0 ms)
-> Closure JS Cache read: 63 JS files
<- Closure JS Cache read: 63 JS files (87 ms)
-> Cache read: cljs/core.cljs
<- Cache read: cljs/core.cljs (73 ms)
-> Cache read: clojure/string.cljs
-> Cache read: cljs/tools/reader/impl/inspect.cljs
-> Cache read: applied_science/js_interop/impl.cljs
<- Cache read: cljs/tools/reader/impl/inspect.cljs (34 ms)
<- Cache read: applied_science/js_interop/impl.cljs (178 ms)
<- Cache read: clojure/string.cljs (178 ms)
-> Cache read: cljs/tools/reader/impl/utils.cljs
-> Cache read: applied_science/js_interop.cljs
<- Cache read: cljs/tools/reader/impl/utils.cljs (6 ms)
-> Cache read: cljs/nodejs.cljs
<- Cache read: applied_science/js_interop.cljs (9 ms)
-> Cache read: lambda/credentials.cljs
<- Cache read: cljs/nodejs.cljs (5 ms)
-> Cache read: promesa/protocols.cljc
-> Cache read: cljs/tools/reader/reader_types.cljs
<- Cache read: lambda/credentials.cljs (6 ms)
-> Cache read: promesa/util.cljc
<- Cache read: promesa/protocols.cljc (7 ms)
<- Cache read: cljs/tools/reader/reader_types.cljs (8 ms)
<- Cache read: promesa/util.cljc (6 ms)
-> Cache read: cljs/tools/reader/impl/errors.cljs
-> Cache read: promesa/exec.cljc
<- Cache read: promesa/exec.cljc (6 ms)
-> Cache read: cljs_bean/from/cljs/core.cljs
<- Cache read: cljs/tools/reader/impl/errors.cljs (8 ms)
-> Cache read: promesa/impl.cljc
-> Cache read: cljs/tools/reader/impl/commons.cljs
<- Cache read: cljs_bean/from/cljs/core.cljs (6 ms)
-> Cache read: cljs_bean/core.cljs
<- Cache read: promesa/impl.cljc (6 ms)
-> Cache read: lambda/licence.cljs
<- Cache read: cljs/tools/reader/impl/commons.cljs (6 ms)
-> Cache read: clojure/set.cljs
-> Cache read: promesa/core.cljc
<- Cache read: cljs_bean/core.cljs (7 ms)
-> Cache read: lambda/dynamo/util.cljs
<- Cache read: lambda/licence.cljs (6 ms)
-> Cache read: clojure/walk.cljs
-> Cache read: cljs/tools/reader.cljs
<- Cache read: clojure/set.cljs (6 ms)
<- Cache read: lambda/dynamo/util.cljs (7 ms)
<- Cache read: promesa/core.cljc (459 ms)
-> Cache read: lambda/util.cljs
<- Cache read: cljs/tools/reader.cljs (466 ms)
<- Cache read: clojure/walk.cljs (467 ms)
<- Cache read: lambda/util.cljs (7 ms)
-> Cache read: cljs/tools/reader/edn.cljs
-> Cache read: lambda/dynamo/expr.cljs
-> Cache read: lambda/dynamo/response.cljs
-> Cache read: lambda/pricing.cljs
<- Cache read: cljs/tools/reader/edn.cljs (10 ms)
<- Cache read: lambda/dynamo/expr.cljs (9 ms)
-> Cache read: cljs_time/internal/core.cljs
<- Cache read: lambda/pricing.cljs (8 ms)
<- Cache read: lambda/dynamo/response.cljs (10 ms)
-> Cache read: cljs/reader.cljs
-> Cache read: lambda/dynamo/request.cljs
<- Cache read: cljs_time/internal/core.cljs (7 ms)
-> Cache read: cljs_time/core.cljs
<- Cache read: cljs_time/core.cljs (15 ms)
<- Cache read: lambda/dynamo/request.cljs (21 ms)
<- Cache read: cljs/reader.cljs (23 ms)
-> Cache read: lambda/kms.cljs
-> Cache read: lambda/email.cljs
-> Cache read: lambda/dynamo.cljs
-> Cache read: cljs_time/format.cljs
<- Cache read: lambda/kms.cljs (7 ms)
-> Cache read: clojure/edn.cljs
<- Cache read: lambda/email.cljs (10 ms)
<- Cache read: lambda/dynamo.cljs (10 ms)
-> Cache read: hiccups/runtime.cljs
-> Cache read: lambda/buy.cljs
<- Cache read: clojure/edn.cljs (10 ms)
<- Cache read: hiccups/runtime.cljs (8 ms)
<- Cache read: cljs_time/format.cljs (15 ms)
-> Cache read: lambda/webhook.cljs
-> Cache read: lambda/renew.cljs
-> Cache read: lambda/quote_email.cljs
<- Cache read: lambda/buy.cljs (11 ms)
-> Cache read: lambda/tables.cljs
-> Compile CLJS: lambda/email_content.cljs
-> Cache read: cljs_time/coerce.cljs
<- Cache read: lambda/tables.cljs (13 ms)
<- Cache read: lambda/renew.cljs (183 ms)
<- Cache read: cljs_time/coerce.cljs (181 ms)
<- Cache read: lambda/webhook.cljs (185 ms)
<- Cache read: lambda/quote_email.cljs (184 ms)
-> Cache read: lambda/quote.cljs
<- Cache read: lambda/quote.cljs (13 ms)
#2020-07-0810:06cflemingquote.cljs hasn’t changed, I’d suspect email_content.cljs the most, but that seems to have compiled ok.#2020-07-0810:27thheller-> Compile CLJS: lambda/email_content.cljs means it started doing something#2020-07-0810:27thheller<- means it finished#2020-07-0810:27thhellerso that never seems to finish. does it abort after 30sec timeout?#2020-07-0810:28thhellerthere is a guard on the thread pool. in case it makes no progress for 30sec it should abort#2020-07-0810:29thhellerquote was just loaded from cache and finished so thats not the issue#2020-07-0811:07cflemingNo, no timeout after 30 seconds, and it Activity Monitor is still showing the Java process using CPU.#2020-07-0811:07cflemingAt least I know where to look now, thanks!#2020-07-0811:22cflemingYeah, I have some problem with a macro there - I should be able to track that down, thanks!#2020-07-0815:17pmooserIf someone is using shadow-cljs + deps, what's the normal way to package something as a library?#2020-07-0815:17pmooserI see the docs regarding leiningen ...#2020-07-0815:19pmooserTrying to use something like depstar results in a jar that's 34mb. Heh.#2020-07-0815:20dpsuttonwhat's in the jar?#2020-07-0815:20pmooserEverything you can imagine of every kind of dependency. It's just an uberjar. So it has compiled clj .class files etc.#2020-07-0815:21pmooserI assume there must be common ways people do this stuff, but this deployment piece of the deps ecosystem sucks a little bit.#2020-07-0815:22pmooserMaybe I'm answering the wrong question - I have the impression that the cljs library should just literally contain the .cljs files (or .cljc) as well as its dependency info.#2020-07-0815:25slimslenderslacksYa, like if you're packaging your cljs/cljc files for other shadow-cljs projects to use. I've been using pack.pack-alpha for that#2020-07-0815:25slimslenderslacks
;; jar creation from juxt
  :pack {:extra-deps {pack/pack.alpha {:git/url ""
                                       :sha "d9023b24c3d589ba6ebc66c5a25c0826ed28ead5"}}
         :main-opts ["-m" "mach.pack.alpha.skinny" "--no-libs" "--project-path" "api-cljs.jar"]}
#2020-07-0815:26slimslenderslacks(but this is not an uberjar)#2020-07-0815:28slimslenderslacksand possibly you can share your .cljs/cljc files via :git/url and not use a jar at all.#2020-07-0815:30pmooser@slimslenderslacks Thank you - I just happened to run across a cljs library packaged just like that. Awesome!#2020-07-0815:36slimslenderslacksYa, it's quite nice when you first realize that you might not need a jar at all - strange feeling#2020-07-0815:38pmooserYeah that is blowing my mind a little bit. I still can't quite wrap my head around it.#2020-07-0815:38pmooserWhat exactly does --no-libs do?#2020-07-0815:42slimslenderslacksI think it's kind of "don't make an uber jar"#2020-07-0815:45pmooserI wonder what I'm doing wrong. Pack worked perfectly fine (I think) but when I run shadow-cljs and depend on these things directly (whereas before I was using them as local artifacts) I get a bunch of provide conflicts.#2020-07-0816:55pmooserSo I think the problem was, pack was including my old js build products. However, when I clean those up and make a new minimal jar, shadow-cljs can't find the classes in it, or says effectively "required namespace x.y.z is not available".#2020-07-0816:56pmooserSo something about how I'm packaging it with pack is wrong for shadow-cljs.#2020-07-0817:02thheller@pmooser I don't know anything about pack or anything deps.edn packaging related for that matter. I just use lein since it is by far the easiest and straightforward.#2020-07-0817:03thhelleryou .jar file should only contain the relevant sources. you can check via jar -tvf your.jar whats in it.#2020-07-0817:03pmooserYes, I understand, I don't use lein anymore, but what I'm a little more interested in is, how would you debug the issue of shadow-cljs saying something isn't available? I can unpack the jar and look in it ... what does shadow-cljs expect to see, for just a normal cljs library? What directory layout?#2020-07-0817:04pmooserYeah, my namespace hierarchy is basically foo.bar.baz/file.cljs and if unpack the jar, I see directories foo/bar/baz/file.cljs ...#2020-07-0817:04pmooserI'm just not sure if there's something else or another level of structure that shadow-cljs expects to see, or what.#2020-07-0817:05thhellerplease give concrete examples ... the filename must match the ns ... that is it. like any other clojure(script) lib or tool. nothing special regarding shadow-cljs.#2020-07-0817:05thhellerfoo.bar.baz/file.cljs is not valid so please don't add confusing examples.#2020-07-0817:06pmooserHold on, let me find "real" names and replace proprietary components.#2020-07-0817:06pmooserThe error is like:#2020-07-0817:06pmooser
The required namespace "jett.hyperbase.client" is not available, it was required by "jett/hypercell/actions.cljs".
#2020-07-0817:06pmooserAnd if I unpack the jar of the library, it looks like:#2020-07-0817:06thhellerso there should be a jett/hyberbase/clients.cljs in the jar#2020-07-0817:07thhellerplease use jar -tvf. I don't care about the unpacked result.#2020-07-0817:07pmooser(yes, it's there)#2020-07-0817:07thhellernothing ever unpacks the .jar during compilation#2020-07-0817:07pmooser
0 Wed Jul 08 18:49:46 CEST 2020 jett/hyperbase/
     0 Wed Jul 08 18:49:46 CEST 2020 jett/
 11489 Fri Jun 26 00:13:24 CEST 2020 jett/hyperbase/core.clj
   484 Mon May 04 11:56:40 CEST 2020 jett/hyperbase/transit.clj
   378 Mon May 18 19:47:00 CEST 2020 dev.clj
  5419 Fri Jun 05 11:57:08 CEST 2020 jett/hyperbase/order_util.cljc
  6375 Tue Jun 02 09:44:34 CEST 2020 jett/hyperbase/id_util.cljc
     0 Wed Jul 08 18:49:46 CEST 2020 jett/gavel/
  1612 Fri May 08 13:05:20 CEST 2020 jett/gavel/core.cljs
  5526 Thu Jun 11 13:06:34 CEST 2020 jett/gavel/message_center.cljs
 10888 Mon Jun 08 19:26:02 CEST 2020 jett/hyperbase/sample_application.cljs
   549 Mon Apr 20 10:26:56 CEST 2020 jett/hyperbase/diff.cljs
   403 Mon Jun 08 19:25:30 CEST 2020 jett/hyperbase/util.cljs
 21608 Mon Jul 06 15:47:08 CEST 2020 jett/hyperbase/itom.cljs
 16470 Fri Jun 26 14:36:42 CEST 2020 jett/hyperbase/client.cljs
   979 Wed Jun 17 12:20:18 CEST 2020 jett/hyperbase/ui.cljs
  5338 Tue Jun 09 13:00:06 CEST 2020 jett/hyperbase/core.cljs
   576 Wed May 13 12:14:12 CEST 2020 jett/hyperbase/user.cljs
     0 Wed Jul 08 18:49:46 CEST 2020 web/
   240 Tue Apr 07 17:34:08 CEST 2020 web/index.html
     0 Wed Jul 08 18:49:46 CEST 2020 web/css/
  7313 Mon May 18 12:06:08 CEST 2020 web/css/site.css
#2020-07-0817:08thhellerok the dev.clj and web/ files probably shouldn't be in there but otherwise the file seems to be present?#2020-07-0817:08pmooserYes, I knew the web and dev things aren't useful but I couldn't figure out how they would be harmful.#2020-07-0817:08thhellerand that jar is part of your dependencies?#2020-07-0817:08thhellerI mean it needs to be on the classpath to be found?#2020-07-0817:11pmooserYes, the jar is in my deps.edn.#2020-07-0817:11thhellerand you restarted shadow after adding it?#2020-07-0817:13pmooserYes, several times.#2020-07-0817:13pmooserI can depend on this stuff if I use local coordinates or git coordinates (in deps)#2020-07-0817:14pmooserIt's just something about I'm packaging the library that must be messed up.#2020-07-0817:14pmooserIn any case, it sounds like from your point of view, it looks correctly structured, so I'm not sure we should take more of your time trying to figure it out.#2020-07-0817:17thhellertry shadow-cljs clj-repl and ( "jett/hyperbase/client.cljs")#2020-07-0817:17thhellerif thats not nil maybe the file is corrupted in some way?#2020-07-0817:18pmooserOk, let me try.#2020-07-0817:18thhellertry (slurp *1) and see if there are some funky chars in the beginning.#2020-07-0817:19pmooserIt returns nil. So presumably it doesn't find it.#2020-07-0817:21thhelleryeah but thats not shadow-cljs trying to find it. thats the JVM. so something is wrong with either your dependency on being on the classpath or the .jar itself#2020-07-0817:22pmooserOk, I'm sure it's the jar. I'll take a look. Thank you for your help!#2020-07-0817:27thhellerif jar -tvf works that the jar seems to be valid#2020-07-0817:45pmooserI don't see any manifest information in the jar, but I'm not sure what exactly is supposed to be there.#2020-07-0817:46pmooserI'm not doing anything especially weird with pack, but maybe there's another argument I'm supposed to use. And to be clear, I don't care about pack. I just am trying to figure out the right way to package a cljs library using deps. We used to do this with lein trivially all the time and deploy to an internal maven server. I just can't quite figure out how to build an artifact with deps that works along with shadow-cljs.#2020-07-0817:46pmooser(or probably anything else)#2020-07-0817:47thhellerall I can say is ... just use lein. even if its just to bundle stuff. I cannot help you with anything deps.edn related since I have not used anything.#2020-07-0817:47thhellershadow-cljs requires absolutely nothing special from the bundling and is not involved in it in any way#2020-07-0817:48pmooserSure, maybe I will go that route. Thank you again.#2020-07-0817:48thhellerwhatever you are doing is also wrong with any other tool. it has nothing to do with shadow-cljs.#2020-07-0818:03pmooserFor packaging a library, there aren't even supposed to be any build products from shadow-cljs or anything in it right?#2020-07-0818:04lilactownlibraries just have cljs files in it, no compiled artifacts#2020-07-0818:05lilactownfor my libs, I do use lein just for that. I would reach out to whatever deps.edn script you’re using if you want help with releasing a CLJS lib#2020-07-0818:05pmooserOk, thanks.#2020-07-0818:13slimslenderslackshey @pmooser, did you deploy that jar to clojars or something? Or are you depending on it using something like {:local/root "/path/to/your.jar"}? Your setup sounds the same as mine so I'm also really wondering what's going wrong 🙂#2020-07-0818:19slimslenderslackscertainly not a bad idea to switch to lein, but in my experience, what you're trying to do does work. There was no pom.xml in the unpacked jar. So it doesn't have any transitive dependencies?#2020-07-0905:01pmooserSorry it took me a bit to respond to this. So I got it working with lein - I'm deploying to an internal maven repository - and I don't quite understand why pack.alpha doesn't have any manifest information.#2020-07-0905:02pmooserSo that seems to be the fundamental problem - the code is all included, but nothing about about to find the code or map it to source directories, etc.#2020-07-0905:02pmooserTo be honest, I'm not very expert at maven or any build tools - I mostly haven't had to be, using leiningen for a decade - so I'm not quite sure what pack is doing. I'd like to figure it out, though, and if I do, I will certainly keep you updated.#2020-07-0921:56slimslenderslacks@pmooser Ya, I looked a bit more at my configuration, and the pom.xml really is a key component of how this works - I should've mentioned this to you when we first started this thread. This link is useful: https://github.com/juxt/pack.alpha#uploading-to-clojars-or-maven Part of the process involves keeping a pom.xml up to date (including updating the version in the pom.xml).#2020-07-0919:07SchpaaDoes something like day8/lein-git-inject exist for shadow-cljs (such that I don’t have to use lein-shadow)?#2020-07-0919:15thhellerno. but you can use lein without lein-shadow ... or deps.edn#2020-07-0919:16thhellerif you are asking about injecting a "version" into the build you can use https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2020-07-0919:17SchpaaGlossed over that one, thanks #2020-07-0921:46AleedIf I need to use aliases, running shadow-cljs server isn’t an option right? I see it mentioned in docs, just checking in case there’s possible workarounds.#2020-07-0922:00thheller@alidcastano I don't undersatnd the question? what aliases?#2020-07-0922:08Aleed@thheller tools.deps aliases from this bit of the docs, I infer I can’t do shadow-cljs server -A:foo and have the builds I start up inherit those options > Aliases are only applied when a new instance/server is started. They do not apply when connecting to a running server using the `shadow-cljs` command.#2020-07-0922:10thhelleryou can use aliases like that#2020-07-0922:10thhelleryou however can not use an alias per build.#2020-07-0922:11thhellershadow-cljs server -A:foo is fine#2020-07-1008:01jerger_at_ddaHi, is there a recommend way to reduce size of generated *.js? My first clojure-script project (https://github.com/DomainDrivenArchitecture/dda-masto-embed) generates 2,3M minimized js - I think that's quite large ... how should I start my quest for shrink the resulting size??#2020-07-1008:03thheller@jerger_at_dda don't use {:optimizations :simple}. that is pretty much the reason its so large.#2020-07-1008:09jerger_at_ddaI assume closure compilers ADVANCED_OPTIMIZATIONS will map to {:optimizations :advanced} ?#2020-07-1008:09thhellerthat is the default yes, just remove the setting entirely#2020-07-1008:10thhellerdon't need :release {:compiler-options {:optimizations :simple}}}#2020-07-1008:10jerger_at_dda:+1:#2020-07-1008:10thhellerthen use https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report to figure out the rest. I know that cljs-time is a pretty significant chunk too (because of its deps, not so much cljs-time itself)#2020-07-1008:11thhellerdepending on what you use from it you might be better off with the code from the closure library. its about 5% the size of cljs-time.#2020-07-1008:18jerger_at_ddaoptimization cut the size down to 1,5M Will investigate further with build-report ... thanx for your help 🙂#2020-07-1008:32jerger_at_ddaIs there a way to get a kind of dependency tree reported ?#2020-07-1008:32Kurt SysHow to compile a node script where I can pass command line arguments?
:builds
 {:converter {:target :node-script
              :output-to "converter.js"
              :main  converter/run
              }
        }
I'd like to be able to do something like node converter.js group user (which would only convert groups and users)?
#2020-07-1008:37thheller@kurt.sys (defn run [group user] ...) already gets the arguments#2020-07-1008:38Kurt Sysoh, really, cool...#2020-07-1008:38Kurt Systhx.#2020-07-1008:38thheller@jerger_at_dda no tree/graph currently no#2020-07-1008:39Kurt Sys(@thheller but they are not names args, right?)#2020-07-1008:39Kurt Syskjkj:w#2020-07-1008:39thhellernot sure what you mean?#2020-07-1008:39jerger_at_dda@kurt.sys that's sth we solved in https://github.com/yogthos/mastodon-bot (see package.json, shadow-cljs.edn, core.cljs). You can install with sudo npm install mastodon-bot -g and run with mastodon-bot -h#2020-07-1008:39jerger_at_ddaif example is good enough#2020-07-1008:40thhelleryou can use something like https://github.com/clojure/tools.cli to parse the args#2020-07-1008:40thhelleror any of the many npm packages for that#2020-07-1008:41thhellerthey are just passed in as strings normally#2020-07-1008:41Kurt Sysright, check... nice.#2020-07-1213:43Yehonathan SharvitHello there, is there a way with shadow-cljs to compile a cljs lib into a js bundle for the browser?#2020-07-1213:43Yehonathan Sharvitcc: @dam#2020-07-1215:34thheller@viebel whats the difference to compiling a cljs app?#2020-07-1215:34Yehonathan SharvitI am not sure. Maybe the fact that there is no entry point#2020-07-1215:36thhelleryou need to be more precise and describe what exactly "js bundle" means for you. there is always an entry point, even a lib will have at least one ns you'd use#2020-07-1215:37Yehonathan SharvitA ns could be set as entry point. No need for a specific function?#2020-07-1215:38Yehonathan SharvitBy “js bundle” I mean that if I load this file in the browser, all the function of my lib are defined and callable#2020-07-1215:38thhellerdefined and callable by what?#2020-07-1215:39thhellerthe usual ^:export will make everything defined and callable. you can have as many of those in your lib as you want.#2020-07-1215:39thhellerI guess I'm confused by the "lib" aspect. not sure what that means to you.#2020-07-1215:56Yehonathan SharvitThe use case is for libs that are not self host compatible, to make them usable in a Klipse snippet#2020-07-1215:56Yehonathan SharvitI don’t need advanced compilation#2020-07-1215:57Yehonathan SharvitI don’t want to force lib author to add ^:export to all the lib functions#2020-07-1216:02thhellerso you are talking about CLJS libs being used by self-hosted CLJS? that would be a no then.#2020-07-1216:05thhellerI mean there is https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html and you could in theory just compile all libs you want to be available together#2020-07-1216:05thhellerbut other than that there is no support for any other self-hosted stuff and you kinda need to write that yourself#2020-07-1315:43lilactown@viebel for your use case, it sounds like you would be loading a compiled CLJS bundle AND a self-hosted app which would not work out great#2020-07-1400:37Yehonathan Sharvitwhat kind of issues could it cause @lilactown ?#2020-07-1402:36lilactownyou would be loading cljs.core twice#2020-07-1406:52robert-stuttafordin upgrading from "2.8.83" to "2.10.14", our use of headless-chrome has started breaking: Uncaught ReferenceError: $jscomp is not defined - however, i see https://github.com/thheller/shadow-cljs/commit/04e636404e976761fb1eac675db55e5d12518246 as well. going to do a fresh node_modules. anything else we should try? update: clean node_modules didn't help.#2020-07-1408:18thheller@robert-stuttaford which build :target? if you are using headless-chrome and only need to target that you can set :compiler-options {:output-feature-set :es8} which gets rid of most polyfills (which $jscomp is for)#2020-07-1408:20robert-stuttafordthank you, giving that a go#2020-07-1408:29robert-stuttafordthat works, thank you!#2020-07-1413:04Karol WójcikIs it possible to create a wrapper library which consumes a npm library using shadow-cljs? I would like to make sure taht other build tools like figwheel-main could understand the generated source-code#2020-07-1413:05thhellerdon't need to do that at all. consumers just need to use the new :bundle to get the npm package access. the code stays the same.#2020-07-1413:07Karol WójcikThanks @thheller. Those are great news!#2020-07-1413:54firstclassfuncMorning, Not sure if this was covered but any chance on adding git-deps t shadow-cljs.edn dependency resolution?#2020-07-1415:59thheller@gary001 at some point yes. until then just use deps.edn.#2020-07-1419:22adamHi guys. The live reload become painfully slow when I add: ["@material-ui/icons" :refer (ArrowForward)] The console says it’s processing 6557 files instead of 1013 once I add that import line. The solution seems to be described here but not sure how to do that in CLJS: https://github.com/mui-org/material-ui/issues/12422#issue-347896444#2020-07-1419:24thheller@somedude314 definitely only import the icons you are actually using. all of them is madness.#2020-07-1419:25thheller["@material-ui/icons/ArrowForward" :default ArrowForward]#2020-07-1419:28adamAh thank you so much, that worked. I was trying ["@material-ui/icons/ArrowForward" :as ArrowForward :default defaultExport] and it was giving me an error.#2020-07-1517:40RabieHi, I've been googling for a while without finding an answer. I'm using shadow-cljs with calva and I use the jack-in REPL to connect to localhost:8280. For a strange reason I keep having the messae Stale Client! You are not using the latest compilation output Is there a quick way of cleaning up everythin so shadow-cljs can recomplile everything from scratch? Thank you?#2020-07-1517:42thheller@rnait1977 there is not much to clean up. make sure you are loading the correct compilation output. maybe you changed your :output-dir and didn't adjust the paths you used to include the .js files?#2020-07-1517:42thhellershadow-cljs does recompile everything from scratch but it can't do anything if you are not loading the files it created.#2020-07-1517:43thhellermaybe you change a :modules {:foo ..} name but don't load the new foo.js file?#2020-07-1517:43RabieNo actually I just created a new file undo-interceptor.cljs#2020-07-1517:44RabieMay be it's clava/vs code related#2020-07-1517:44thhellerno it isn't. it really is that simple. check if you are loading the correct file from your HTML. it is nothing else.#2020-07-1517:45thhellerwell it might be cache if you are not using the default shadow-cljs dev-http server?#2020-07-1517:45thhelleryou might have 2 shadow-cljs instances running for the same project?#2020-07-1517:53pezI think it is the browser caching the old client. Refresh w/o caches usually clears things up for me.#2020-07-1517:54thhellerthe :dev-http servers handle caching correctly so that doesn't happen but any other server may not do that#2020-07-1517:55RabieYou were right Thomas. It's not realted to Calva nor shadow-cljs. Actually I made a mistake in naming the namespace which provoked a build error and the error message doesn't show up clearly in vs code. Thanks for your help guys 🙂#2020-07-1518:49pezThen it is a bit related to Calva in that the error could be better surfaced. #2020-07-1521:14Drew VerleeI run cider-jack-in with configuration to choose shadow cljs and i successfully launch a browser. Which then immediately tells me my state is stale. in the browser client i see websocket connected! websocket disconnected! I would expect either the state to not be state (which i assume means the shadow server isn't able to read the compiled js and reload) or i would expect an error.#2020-07-1521:15Drew Verleenow if i refresh on the 3rd time the stale error goes away. But cider isn't connected to the repl.#2020-07-1521:26Drew Verleeif i run shadow-cljs watch app where app is the name of my app (original i know) then i get an exception aboud piggieback which i can't fathom.
➜  Cabotage git:(labtest-results-should-get-its-own-page) ✗ yarn watch
yarn run v1.22.4
$ shadow-cljs watch app;
shadow-cljs - config: /home/drewv/work/breezeehr/master-at-arms/Cabotage/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Downloading: binaryage/devtools/1.0.2/devtools-1.0.2.pom from 
Downloading: binaryage/devtools/1.0.2/devtools-1.0.2.jar from 
[2020-07-15 16:22:48.972 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
	clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
	clojure.lang.Compiler.macroexpand (Compiler.java:7075)
	clojure.lang.Compiler.eval (Compiler.java:7161)
	clojure.lang.Compiler.load (Compiler.java:7636)
	clojure.lang.RT.loadResourceScript (RT.java:381)
	clojure.lang.RT.loadResourceScript (RT.java:372)
	clojure.lang.RT.load (RT.java:459)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
Caused by:
NoSuchFieldError ES3
	cljs.closure__init.load (:133)
	cljs.closure__init.<clinit> (:-1)
	java.lang.Class.forName0 (Class.java:-2)
	java.lang.Class.forName (Class.java:348)
	clojure.lang.RT.classForName (RT.java:2211)
	clojure.lang.RT.classForName (RT.java:2220)
	clojure.lang.RT.loadClassForName (RT.java:2239)
	clojure.lang.RT.load (RT.java:449)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.10.14 running at 
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[2020-07-15 16:23:17.405 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
	java.lang.Class.forName0 (Class.java:-2)
	java.lang.Class.forName (Class.java:348)
	clojure.lang.RT.classForName (RT.java:2211)
	clojure.lang.RT.classForName (RT.java:2220)
	clojure.lang.RT.loadClassForName (RT.java:2239)
	clojure.lang.RT.load (RT.java:449)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
#2020-07-1521:37Drew Verleethis happens after i bumped shadow cljs it seems. i can post the specific update if there is interest.#2020-07-1522:16dpsuttoni'd recommend doing everything in the command line until you are sure everything works#2020-07-1522:16dpsuttononly use CIDER on a known working project. then if there's an issue its definitely in CIDER#2020-07-1522:25Drew Verleei suspect it's an issue in cider. i can't properly run cider-jack-in and connect to my the nrepl server that shadow sets up. I guess ill rollback.#2020-07-1522:08Drew VerleeThis seems to appear even though i have no dependencies configured. What could that mean?
=============================================================================
WARNING: The configured :dependencies in shadow-cljs.edn were ignored!
         When using :deps they must be configured in deps.edn
==============================================================================
#2020-07-1608:46thhellerthe check is literally (seq (:dependencies config)) so you definitely have something in :dependencies configured?#2020-07-1613:54Drew VerleeI do. it's in my root shadow-cljs config ./shadow-cljs/config.edn#2020-07-1616:12thhellerah right#2020-07-1601:33neilyioI'm using the shadow-cljs node-repl, and getting lots of crashes using core.async. I'm finding the entire REPL (both with cider-jack-in-cljs and shadow-cljs server) crashes anytime I make an error inside of a go block. This is frustrating, because I have to restart the entire shadow-cljs server every time. Is anyone else experiencing this?#2020-07-1601:33neilyioHere's an example of an error.#2020-07-1601:33neilyio
(defn <!
^
Error: <! used not in (go ...) block
    at Object.cljs$core$async$_LT__BANG_ [as _LT__BANG_] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:92:1)
    at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/app/main.cljs:47:11
    at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:4736:15
    at /Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:4736:29
    at Object.sval (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:3438:7)
    at Object.cljs$core$ISeqable$_seq$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:3429:1)
    at Object.cljs$core$seq [as seq] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:1234:7)
    at Function.cljs$core$IFn$_invoke$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:9953:1)
    at Function.cljs$core$IFn$_invoke$arity$1 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:9966:1)
    at switch__30781__auto__ (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/app/main.cljs:45:3)
#2020-07-1601:34neilyioAfter this, if I simply try and evaluate (+ 2 2) at the REPL, I get another error (below), and I'm forced to shut down the entire server.#2020-07-1601:34neilyio
ERROR: Unhandled REPL handler exception processing message {:nrepl.middleware.print/buffer-size 4096, :ns app.main, :file *cider-repl Desktop/loserCLI:localhost:65433(clj)*, :nrepl.middleware.print/quota 1048576, :nrepl.middleware.print/print cider.nrepl.pprint/pprint, :op eval, :column 11, :line 35, :id 34, :code (+ 2 2), :nrepl.middleware.print/stream? 1, :nrepl.middleware.print/options {:right-margin 80}, :session 9e5bd5b2-32da-428c-b4ef-3ec6637ed31a}
java.lang.AssertionError: Assert failed: (some? worker)
	at shadow.cljs.devtools.server.repl_impl$do_repl.invokeStatic(repl_impl.clj:19)
	at shadow.cljs.devtools.server.repl_impl$do_repl.invoke(repl_impl.clj:19)
	at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invokeStatic(nrepl_impl.clj:143)
	at shadow.cljs.devtools.server.nrepl_impl$do_cljs_eval.invoke(nrepl_impl.clj:131)
	at shadow.cljs.devtools.server.nrepl_impl$handle.invokeStatic(nrepl_impl.clj:216)
	at shadow.cljs.devtools.server.nrepl_impl$handle.invoke(nrepl_impl.clj:210)
	at shadow.cljs.devtools.server.nrepl$middleware$fn__7184.invoke(nrepl.clj:40)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at cider.nrepl$wrap_out$fn__7479.invoke(nrepl.clj:312)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at cider.nrepl.middleware.inspect$eval_reply.invokeStatic(inspect.clj:64)
	at cider.nrepl.middleware.inspect$eval_reply.invoke(inspect.clj:62)
	at cider.nrepl.middleware.inspect$handle_inspect.invokeStatic(inspect.clj:95)
	at cider.nrepl.middleware.inspect$handle_inspect.invoke(inspect.clj:93)
	at clojure.lang.Var.invoke(Var.java:388)
	at cider.nrepl$wrap_inspect$fn__7455.invoke(nrepl.clj:215)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at nrepl.middleware.caught$wrap_caught$fn__6589.invoke(caught.clj:97)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at nrepl.middleware.print$wrap_print$fn__6325.invoke(print.clj:234)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at cider.nrepl$wrap_slurp$fn__7387.invoke(nrepl.clj:110)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at cider.nrepl$wrap_undef$fn__7551.invoke(nrepl.clj:471)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at cider.nrepl.middleware.track_state$handle_tracker.invokeStatic(track_state.clj:240)
	at cider.nrepl.middleware.track_state$handle_tracker.invoke(track_state.clj:238)
	at clojure.lang.Var.invoke(Var.java:388)
	at cider.nrepl$wrap_tracker$fn__7543.invoke(nrepl.clj:460)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at nrepl.middleware.session$session$fn__6931.invoke(session.clj:297)
	at nrepl.middleware$wrap_conj_descriptor$fn__6114.invoke(middleware.clj:16)
	at shadow.cljs.devtools.server.nrepl$start$fn__7215.invoke(nrepl.clj:138)
	at nrepl.server$handle_STAR_.invokeStatic(server.clj:19)
	at nrepl.server$handle_STAR_.invoke(server.clj:16)
	at nrepl.server$handle$fn__7009.invoke(server.clj:36)
	at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
#2020-07-1601:36neilyio(By the way, the above <! is indeed in a go block in my code, so I'm not sure why the first error is even happening... but I can't really debug it if it shuts down my REPL every time.)#2020-07-1608:48thheller@neil.hansen.31 I can fix the second issue but the first is kinda a node problem. it just exits on uncaught exceptions and I cannot catch it in the REPL since its async.#2020-07-1609:12neilyioThanks @thheller, I'd be glad if this could be helpful. If the first issue can be solved by just catching the errors, I can be more careful. Is there a best practice for error handling in core.async + NodeJS +shadow-cljs?#2020-07-1609:16thhellerhttps://nodejs.org/api/process.html#process_event_uncaughtexception#2020-07-1609:16thhellerI'm hesitant to install a handler by default here#2020-07-1609:17thheller> . It is not safe to resume normal operation after 'uncaughtException'.#2020-07-1609:37neilyioHmm, it does sound dangerous to use that directly. Thank you for the resource! I understand that the application probably needs to be restarted on an event like this. Is there a way to restart the NodeJS process that might be faster that entirely resetting shadow-cljs server?#2020-07-1609:38thhelleryou don't need to restart server.#2020-07-1609:39thhellerI added a fix in master so the nrepl session is reset properly#2020-07-1609:40neilyioAmazing, thanks. I'll try it out first thing in the morning.#2020-07-1617:06thheller@neil.hansen.31 also added automatic restart for node-repl if the node process crashes. state will be gone though. test 2.10.15#2020-07-1618:22neilyio@thheller I can't believe you fixed this so quickly. It's already so much better.#2020-07-1618:26neilyioI'm finding that the REPL works right away after my <! used not in (go...) block error. I get a message that says The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone, followed by shadow-cljs - #11 ready!, which is great. Evaluation works right away. (+ 2 2) yields the expected result, and cider-eval-last-sexp is also working in the buffer.#2020-07-1618:29neilyioHowever, once in the "new runtime" post-error, I'm getting errors when I try and evaluate def and defn expressions. I'm in a namespace called app.main, evaluating either kind of statement returns #object[ReferenceError ReferenceError: app is not defined]. This happens both with cider-eval-last-sexp in the buffer and with def and defn statements used in the REPL.#2020-07-1618:46neilyioI just did a doom upgrade a moment to update all my Emacs packages, and I see that some REPL behaviour has changed. Now with the exact same steps (1. eval buffer 2. eval go block with <! problem), I'm no longer getting any error message at all in the REPL. No stack trace is printed; the only output is The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.#2020-07-1618:48neilyioI have no idea what package update might have caused this, but let me know if you have any ideas of how to get the error message/stack trace back. I was confused on how to debug <! used not in (go...) block even when I could see the whole stack trace... Now I'm totally helpless 😛#2020-07-1619:28neilyio^^^ and the messages are back after a few restarts. I don't know what's going on. #object[ReferenceError ReferenceError: app is not defined] is still problem.#2020-07-1619:30thheller@neil.hansen.31 like the message is telling you ... your state is gone. so the namespace you previously defined is gone with it.#2020-07-1619:36neilyioYou're absolutely right... I need to remember that it's being reset to a "empty" NodeJS environment. Thanks so much for your help. There's such a wild amount of complexity to wrap my head around in Clojure environments, I keep missing things that seem obvious.#2020-07-1619:39neilyioI'm trying to write down all the little "conceptual" roadblocks that I run into. I'd love to send it your way at some point, hopefully to help make shadow-cljs more "self-documenting" to give clues to beginners like myself. I think having a good mental model of everything that's going on would help someone like me get more out of your User Guide.#2020-07-1621:34awb99I have upgraded my shadow-cljs dependency (and a few other dependencies. And now watch goes into endless compile loops. Strangely I also get "Warning: Nashorn engine is planned to be removed from a future JDK release". >Any ideas?#2020-07-1623:37awb99What happens is that the initial compile works; and when a change is detected that compile works also , but now it re-compiles this change over and over.#2020-07-1700:50adamHow can I run shadow watch app on my local IP instead of localhost? I want to test my app on mobile#2020-07-1706:52thheller@hoertlehner people have reported that this happens when the output files are on the classpath? did you upgrade the JDK version? that would explain the nashorn warning?#2020-07-1707:21awb99I did not update jvm. Nashorn warning now comes when shadow checks npm dependencies.#2020-07-1707:21awb99Output goes to target/we app/public.#2020-07-1712:58awb99@thheller Might this constant recompile issue happen also due to the bundle being in a resource path?#2020-07-1714:24thhellerI don't have a clue whats causing this. otherwise I'd fix it.#2020-07-1714:25thhellerit might be your editor#2020-07-1714:25thhelleror some other watcher touching files#2020-07-1714:25thhellercan't do much without a reproducible example#2020-07-1706:52thheller@somedude314 it should be available on your local IP automatically?#2020-07-1713:14adamAh you are right, thanks. I didn’t think that was the case because the console says “localhost”#2020-07-1714:42Drew VerleeWhen i run shadow-cljs watch app s i get a warning about shadow cljs devtools not being able to locate refactor nrepl:
[2020-07-17 09:22:55.580 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym refactor-nrepl.middleware/wrap-refactor}
FileNotFoundException Could not locate refactor_nrepl/middleware__init.class, refactor_nrepl/middleware.clj or refactor_nrepl/middleware.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
	clojure.lang.RT.load (RT.java:462)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
	clojure.core/load-lib/fn--6780 (core.clj:5948)
	clojure.core/load-lib (core.clj:5947)
	clojure.core/load-lib (core.clj:5928)
	clojure.core/apply (core.clj:667)
	clojure.core/load-libs (core.clj:5985)
I'm not sure what to do. Should i be including refactor nrepl middlware? I can make a minimal project if that would help debug this. Many thanks on any hints.
#2020-07-1714:43thhelleryou have configured that middleware somewhere. shadow-cljs does not use it. well maybe cider-nrepl or whatever configures it? I don't really know.#2020-07-1714:44thhellermight be in your global config again?#2020-07-1714:45thhellerall the default nrepl locations apply, not sure what they are exactly. I think .nrepl.edn in your project and somewhere else#2020-07-1714:47Drew Verlee➜ Cabotage git:(master) ✗ cat ~/.nrepl/nrepl.edn {:middleware [refactor-nrepl.middleware/wrap-refactor]} Many thanks. This is likely it. i had no idea this existed. I must say, its sometimes overwhelming all the places dependencies can be set.#2020-07-1714:50thhellerhmm yeah I couldn't decide whether I should adopt nrepl defaults or not#2020-07-1714:52Karol WójcikIs it possible for shadow-cljs to generate full externs file like that tool does? https://jmmk.github.io/javascript-externs-generator/#2020-07-1714:53thhellerno. why would it? that tool should never be used by anyone.#2020-07-1714:57Karol WójcikI would like to generate externs for react-jss to provide cljsjs.react-jss package as a backward compatibility for people who will not use the new :target :bundle option. Seems that the generator I've linked is unable to produce externs for https://github.com/FieryCod/cljs-react-jss/blob/master/resources/cljsjs/react-jss.js. Thought that maybe shadow-cljs is able to do it.#2020-07-1714:58thhellerso you are using react-jss in your library?#2020-07-1714:58Karol WójcikYep#2020-07-1714:58thhellerok then add extern inference hints in YOUR library#2020-07-1714:59thhellerthen react-jss doesn't need any externs at all#2020-07-1714:59thhellerunless users of your library also use react-jss directly and don't use your stuff your library already uses.#2020-07-1715:00Karol WójcikI would rather allow the users to consume react-jss directly#2020-07-1715:01thhelleryou can also write the more "modern" CLJSJS style. you are writing the bad old style.#2020-07-1715:01Karol WójcikOk guide me master.#2020-07-1715:01Karol WójcikWhat the "modern" means?#2020-07-1715:03thhellerno clue how it works exactly but you can configure :foreign-libs to "provide" react-jss#2020-07-1715:04thhellerso (:require ["react-jss" :as x]) works regardless of using CLJSJS or shadow-cljs or bundle#2020-07-1715:04thhellerlike this I guess https://github.com/cljsjs/packages/blob/master/react/build.boot#L43-L57#2020-07-1716:34Karol Wójcik@thheller I think that this line allows the same: https://github.com/FieryCod/cljs-react-jss/blob/master/build.boot#L32#2020-07-1716:36thhellerthe issue II meant is this https://github.com/FieryCod/cljs-react-jss/blob/master/src/main/css_cljs/core.cljs#L6#2020-07-1716:36thhellerand using the global via js/ https://github.com/FieryCod/cljs-react-jss/blob/master/src/main/css_cljs/core.cljs#L19#2020-07-1716:37thhellerso it seems you already have this setup correctly https://github.com/FieryCod/cljs-react-jss/blob/master/build.boot#L30#2020-07-1716:37thhellerso just use the react-jss require and alias instead of the global js/ alias#2020-07-1716:41thhellerlike reagent https://github.com/reagent-project/reagent/blob/master/src/reagent/dom.cljs#L2 it doesn't use any js/ globals anymore because the compiler does that automatically when using cljsjs#2020-07-1716:44Karol WójcikOk got it! You're right I can simply use ["react-jss" :as react-jss] and compatibility will be preserved.#2020-07-1716:45Karol WójcikIt seems that I do not have to provide cljsjs.react-jss namespace as well. Am I right?#2020-07-1719:18thhelleryes, thats not required#2020-07-1722:43Karol WójcikThank you @thheller! You are awesome!#2020-07-1720:16Drew VerleeI assume this warning means ill need to supply a type hint:
17 |                   (let [x @loadable]
  18 |                     (when-some [modules (.-modules loadable)]
-----------------------------------------------^--------------------------------
Cannot infer target type in expression (. loadable -modules)
Will there be more then that?
#2020-07-1720:18thhellerI don't understand the question?#2020-07-1720:21Drew VerleeShadow is giving me a warning that it cannot infer the target type. My assumption is that i have to tell it the type, is that correct?#2020-07-1720:22thhelleryes, that is an externs inference warning#2020-07-1720:22thhellerif you don't wan't them you can turn the warnings off#2020-07-1720:22thhellerI just turned them on by default recently#2020-07-1720:22thheller:compiler-options {:infer-externs true} turns them off#2020-07-1720:23Drew Verleemakes sense. ill think about if i want i need to do more later#2020-07-1720:23thhellerit might compile fine without hints#2020-07-1720:26Drew Verleehttps://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options It says it should be true by default or i'm i reading that wrong#2020-07-1720:27thhellerdidn't update that#2020-07-1720:28thhellerits now :infer-externs :auto by default#2020-07-1720:28thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2020-07-1720:29Drew Verleeawesome. as always thanks for the help @thheller#2020-07-1723:18Felipe MarquesI'm trying to write a build-hook that adds some preloads. The build-hook runs on the :configure stage and adds the preload like this:
(update-in build-state [:devtools :preloads] conj 'my.preload.namespace)
Is it possible to do this?
#2020-07-1801:10Felipe MarquesSolved it by changing the implementation of the build-hook. Instead I added my namespace directly to the :shadow.build.modules/config#2020-07-1822:50roklenarcicI am trying to use npm package svg-cards which is basically a big bag of PNGs and SVGs, but my shadow-cljs build isn’t serving them (I get 404). Is there some kind of way to make this work (other than manually copying from npm package to resources folder)?#2020-07-1906:20David PhamCan you show us the code that you use? (Maybe clean the .shadow-cljs folder).#2020-07-1907:42thheller@roklenarcic shadow-cljs has no support for serving "assets" from node_modules. it just deals with JS.#2020-07-1907:43Chris McCormicki have symlinked stuff from node_modules/... into public before which worked fine. if you have a build step it has to take this into account.#2020-07-1915:55magraHi, at the moment, to build production, I have to kill my dev environment and stop the shadow-cljs server to prevent cached dev dependencies (guardrails) to leak into production. Is there a way to tell shadow-cljs to not use the running server?#2020-07-1916:03Drew VerleeI believe you could output your build/release artifacts to another file so they didn't clash.#2020-07-1919:59thheller@magra they don't leak into production unless you builds includes them?#2020-07-2008:32magramaybe I misused the word leaked, I apologize. I think I followed the instructions in the guardrails readme. They work fine if I stop the dev server everytime I want to build release. They throw if I forget to stop the dev server. Since @U05224H0W ansered in another thread a few days ago that maybe someone had inadvertantly a second shadow-cljs server running I thought there maybe is a way to have a second server running on purpose or maybe start shadow-cljs release in a way that it does not reuse the running dev server. If I read the guardrails docs correctly they suggest to always stop the dev server before release and provide a throw if I forgot to stop the dev server.#2020-07-2008:33thhelleryou are doing something that is absolutely NEVER required but not describing enough WHY you think you have to do it#2020-07-2008:34thhellerplease first describe what your actual problem is#2020-07-2008:34magraI work on a fulcro project. It works fine and I have emacs and shadow-cljs running 8 hours at a time. When I want to release a main.js to a server I have to kill the shadow-cljs dev server.#2020-07-2008:35thhellerwhy?#2020-07-2008:35thhellerwhat commands are you running?#2020-07-2008:37magraI start dev like: [nREPL] Starting server via /usr/local/bin/npx shadow-cljs -d nrepl:0.8.0-alpha3 -d cider/piggieback:0.5.0 -d refactor-nrepl:2.5.0 -d cider/cider-nrepl:0.25.3-SNAPSHOT server -A:dev I start release: npx shadow-cljs release -A:ui prod#2020-07-2008:39thhellerok now you provided some essential info. you are using deps.edn aliases to switch dependencies. that cannot be done with a running server and does require a restart.#2020-07-2008:39thhellernow explain WHY you are doing that? like what is the difference in the profiles?#2020-07-2008:40thhellerin general it is irrelevant what is on the classpath when building CLJS projects. the code only uses what is actually used, just the presence on the classpath does nothing.#2020-07-2008:40magraok. The jvm options in the profiles are different since dev includes the fulcro backend.#2020-07-2008:41thhelleryou don't need the jvm properties when building CLJS. you should configure via the build config as the guardrails doc show#2020-07-2008:41thhellerthe JVM properties are for CLJ#2020-07-2008:41magra"-Dguardrails.enabled=true"]#2020-07-2008:42thheller
...
     :app  {:target            :browser
            :dev               {:compiler-options
                                {:external-config {:guardrails {:throw? false}}
                                 :closure-defines {goog.DEBUG true}}}
...
#2020-07-2008:42thhelleryou don't need the -Dguardrails...#2020-07-2008:42magraI need -Dguardrails for the backend.#2020-07-2008:42thhellerthen use a different profile for the backend and CLJS?#2020-07-2008:46thhellernpx shadow-cljs --force-spawn release -A:ui prod also works but I'd strongly recommend building a setup that doesn't require switching deps.edn aliases#2020-07-2008:46thhellerthis never uses the running server and always starts a new process#2020-07-2008:51magraThank you! That is what the question was about. But I still want to follow your guidance about the seperate profiles. What do you mean by different profiles since you seem not to mean different deps.edn aliases. At the moment I use cider to connect both clj and cljs on the conection that I start as shown above. Are you talking about starting a seperate jvm for server and UI and have two seperate connections from emacs without sibling connections?#2020-07-2009:08thhellerI do mean deps.edn aliases. just too used to lein which calls them profiles.#2020-07-2009:09thhellerI do mean that you create a :backend alias and maybe a :backend-prod or so and then one alias for :cljs which just configures the guardrails via build config without jvm property#2020-07-2009:12magraAhh thank you!!!! I could not figure out the middle between the extremes. Thank your for your time and your patience!#2020-07-2009:14thhellercould also add a :enable-guardrails-clj alias that just sets the jvm property. so you can do clj -A:backend and clj -A:backend:enable-guardrails-clj#2020-07-2009:30magraI think my using cider-jack-in-clj&clj instead of two separate jackins prevented me from doing that. My dev environment used shadow-cljs for UI and Backend at the same time and I am going to change that. Thank you again and thank you for shadow-cljs!#2020-07-2016:32magraFor the archive: separate cider-jack-in-clj and cider-jack-in-cljs is completely possible works fine with above suggestions.#2020-07-1920:00thhellerthe guardrails readme shows how to enable it for dev?#2020-07-1920:33mruzekwI’m working on a node script in IntelliJ/Cursive and I notice all the JS symbols are coming up “cannot be resolved”. Is there a way to fix this?#2020-07-1920:34thhellerno#2020-07-1920:40mruzekwOkay, thanks#2020-07-1920:42thhellerwell you can fix it by disabling that warning 😛#2020-07-1920:42thhellerI think there is an open Cursive issue about this#2020-07-1920:42cflemingYes, there is, I’m planning to do what I can about this soon-ish.#2020-07-1922:08mruzekwDoes shadow-cljs process JS with async/await functions? I’m trying to use a module that exports one and not having much luck
shadow-electron-starter/node_modules/electron-serve/index.js:12
const getPath = async path_ => {
                      ^^^^^
SyntaxError: Unexpected identifier
#2020-07-2004:48tjbhey everyone i just starting using shadow-cljs and ive got into this state where it keeps recompiling without any changes happening
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.17s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.21s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.22s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.24s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.28s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.19s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.19s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.27s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.18s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.21s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.18s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.17s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.16s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.20s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.26s)
[:app] Compiling ...
[:app] Build completed. (266 files, 2 compiled, 0 warnings, 0.23s)
[:app] Compiling ...
#2020-07-2004:48tjbhas anyone else experienced this?#2020-07-2006:26Chris McCormickmaybe you are compiling into the watched folders
#2020-07-2006:26Chris McCormickwhat does your shadow-cljs.edn look like?#2020-07-2018:28tjbi can share with you tonight!#2020-07-2008:00thheller@tjb yes this happens if you have the :output-dir on the classpath. you can try 2.10.16 which should fix this.#2020-07-2012:34nick@tjb were you able to fix this bu upgrading shadow-cljs to 2.10.16 in project.clj? Looks like it fixed it for me. Let me guess, do you use Linux? Debian perhaps? AFAIK, this infinite build completed/compiling issue could not be reproduced on OSX#2020-07-2018:28tjbhey all! i am using Pop_OS! so yes linux. i will try tonight to upgrade to 2.10.16!#2020-07-2018:29nickor just generate a new luminus template. New version has been released very recently#2020-07-2018:30nickhttps://github.com/luminus-framework/luminus-template/pull/496#issuecomment-661040188#2020-07-2021:54tjbworks on upgrade 📣 thanks everyone!#2020-07-2009:19AronI need a bit of clarification on the docs here https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test Does the part "gathering up namespaces that contain tests" include files that are in my app directory, or do I have to create these namespaces as new directories next to my app directory?#2020-07-2009:23AronI am getting the feeling that I am trying too many things at once again and that's why I am not getting anything : D#2020-07-2010:16thheller@ashnur I don't know what you mean by "app directory". shadow-cljs is only concerned with the classpath. https://shadow-cljs.github.io/docs/UsersGuide.html#_important_concepts#2020-07-2010:17thhellerregarding tests they are collected from your :source-paths#2020-07-2010:17thhelleryou can put tests wherever you want. in the same directory as your regular source files is fine.#2020-07-2010:35djanushello! are there any other places shadow-cljs pulls dependencies from, apart from shadow-cljs.edn? can't find it in the docs#2020-07-2010:35djanusshadow-cljs --cli-info says that I have [com.taoensso/sente "1.11.0"] as a direct dependency, but I'm not declaring it as such#2020-07-2010:36djanusditto for many others#2020-07-2010:50djanusok, I answered my own question by copying the deps to an empty Leiningen project and running lein deps :tree#2020-07-2010:50djanusit was not actually a direct dependency, even though shadow-cljs reports it as such#2020-07-2010:51djanusit probably has to do with conflict resolution#2020-07-2010:52djanusbut I think it would be good for shadow-cljs to be able to answer the question "why does my output include dependency X?"#2020-07-2011:11magranpx shadow-cljs run shadow.cljs.build-report your-build shadow-report.html might be what you are looking for. @dj942#2020-07-2011:17djanusooh, that's handy to know! although, strangely enough, the output of that one doesn't seem to mention that dependency at all (presumably because it's only pulled into the output file because I have it in [:devtools :preloads])#2020-07-2011:36thheller@dj942 build reports use release mode so :preloads aren't included#2020-07-2101:00cobyI'm getting the following error when pulling in a new dependency, @fullcalendar/interaction:
Failed to inspect file
  /home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.css

it was required from
  /home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.js

Errors encountered while trying to parse file
  /home/tamayo/projects/rtc/node_modules/@fullcalendar/common/main.css
  {:line 4, :column 1, :message "primary expression expected"}
So that common/main.js file is a transitive dependency and is trying to pull in CSS with import './main.css'. I read up on "JavaScript Dialects" and it looks like I would need to use a Babel plugin or somesuch to transform the CSS-in-JS, and then use Shadow to compile the transformed files. But does that basically mean I can't get this to work for a transitive dependency like common/main.js without forking my dependency, to tell it where to find the transformed files?
#2020-07-2101:23rbergerIs it best to run shadow-cljs commands so it executes the version local to the app repo? I just realize my globally installed shadow-cljs was ancient compared to the one in package.json in my repos. And I had been running watch and release with the global one. Haven’t had any issues, but I’m wondering if it would be better to just remove the global one and always do npx shadow-cljs or yarn shadow-cljs?#2020-07-2101:35cobyIt's probably a good idea if it's a collaborative project, that way everyone is using the same version of shadow-cljs. It's a much bigger deal in JS Land, where APIs change every 20 minutes or so 😉#2020-07-2107:15thheller@ctamayo libraries like that pretty much expect to be bundled by webpack so you won't have much luck bundling with anything else. I'd recommend looking for a different lib.#2020-07-2115:26cobyI found this issue, looks like the author is making an earnest effort to support other build tools. The solution is a bit hacky but I'm wondering if shadow-cljs looks at the main module declared in package.json, rather than module? If so I think his proposed solution would apply to my case as well.#2020-07-2115:26cobyhttps://github.com/fullcalendar/fullcalendar/issues/5393#issuecomment-658404645#2020-07-2115:30thhellershadow-cljs looks at main by default#2020-07-2115:32thhellerhttps://unpkg.com/browse/@fullcalendar/common@5.1.0/package.json also has no module at all so it doesn't seem to apply to that package#2020-07-2115:33thhellerFWIW you can set :js-options {:ignore-asset-requires true} in your build config#2020-07-2115:33thhellerthat will make it compile but you will be missing the CSS#2020-07-2115:36cobyahhh#2020-07-2115:36cobythat's more what I was looking for, rock on!#2020-07-2107:16thheller@rberger shadow-cljs will automatically use the version installed in the project, even if using the global shadow-cljs install. you should always have a version installed in your project. the global install is optional though.#2020-07-2108:44rbergerCool, that is what I hoped (the local one would be used) but wanted to make sure. Glad to hear I don’t have to delete the global on to ensure that the local one in package.json is used.#2020-07-2108:47thhellerwell there might be a problem if you use a really old global install#2020-07-2108:47thhellerit needs to be somewhat close in versions#2020-07-2108:48thhellerotherwise the global install might not pick up features from the newer local one#2020-07-2114:22Alex PorterWe're following https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html for code splitting but running into issues with deploying new versions of our app and the loading of a new view's js loads the wrong version. Any recommendations?#2020-07-2114:46thheller@ajporter2011 either https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output or using https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge to set a unique :output-dir for release builds#2020-07-2114:48Alex PorterThanks @thheller#2020-07-2120:00genekim@thheller Thank you so much for shadow-cljs! I was able to make a quick change to a project that I haven’t touched in 6 months, confirm it works in a REPL, push out a change to Heroku, and have it running in production in about 30 minutes. Usually, it would be hours trying to get builds running again, and I’d be randomly changing versions of everything (cljs, clojure, random libraries), doing “lein clean”, heck, why not upgrade IntelliJ/Cursive, too, because nothing else seems to be fixing my build/run issues, etc. Days afterwards, encouraged by how easy everything is, I’ve made a nearly ten other changes — it makes front-end programming so incredibly fun, as opposed to full of dread and regret. 🙂#2020-07-2120:02genekim(Something really strange: it has been so long since I’ve done a build, the npm executable wasn’t even in my path anymore…. Huh! Whatever! 🙂#2020-07-2209:43steveb8nQ: I’m trying to get a react-vega sample working but I’m failing. Does anyone have a really simple example of this in shadow?#2020-07-2211:22thheller@steveb8n whats the problem?#2020-07-2211:24steveb8nI don't know. I get an empty div. Hence the question. I'm pretty sure I'm doing the reagent interop wrong#2020-07-2211:25steveb8nSample code coming....#2020-07-2211:26steveb8n
(:require ["react-vega" :refer [VegaLite Vega]]
          [reagent.core :as r])
(let [spec (clj->js {:width    400
                     :height   200
                     :mark     "bar"
                     :encoding {:x {:field "a"
                                    :type  "ordinal"}
                                :y {:field "b"
                                    :type  "quantitive"}}
                     :data     {:name "table"}})
      data (clj->js {"table" [{"a" "A" "b" 28}
                              {"a" "B" "b" 20}]})]
  [:> VegaLite {:spec spec
                :data data}])
#2020-07-2211:27steveb8npackage.json…#2020-07-2211:27steveb8n
"react-vega": "7.4.0",
"vega-embed": "6.10.0",
"vega": "5.13.0",
"vega-lite": "4.13.1"
#2020-07-2211:27steveb8nmaybe this question is better in the reagent/re-frame channel?#2020-07-2211:29thhellerlooks fine to me#2020-07-2211:29steveb8nbut I thought I’d ask here first. don’t waste time on it unless you’ve done it before. I’m hoping I’ll find someone who has done this already#2020-07-2211:30steveb8nor tomorrow (getting late here) I’ll wake up and find the problem. it’s always easier in the morning#2020-07-2211:30thhellerhttps://github.com/vega/react-vega/tree/master/packages/react-vega#mainjs-1#2020-07-2211:30thhellerhas "data": [{ "name": "table" }] but you have :data {:name "table"}#2020-07-2211:31thhellermaybe it must be in an array?#2020-07-2211:31thhellernvm .. the vegalite also has the obj only#2020-07-2211:31thhellerany errors during load maybe?#2020-07-2211:33steveb8nboom! fixed!#2020-07-2211:34steveb8nit wasn’t the data. it was a typo in the word “quantitative”#2020-07-2211:34steveb8nwhich was in the console errors when I dialled up the verbosity#2020-07-2211:34steveb8nthank you for the redirection!#2020-07-2211:35steveb8nnow I can sleep properly 🙂#2020-07-2212:14brunexdid an update of shadow-cljs to the latest and started to have this error when compiling:
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
#2020-07-2212:15brunexI am using the experiment feature of requiring js files, and had this import on that files:
import * as THREE from 'three';
#2020-07-2212:16brunexany suggestions of how I go about this import now?#2020-07-2212:28thheller@brunex need more context. what build :target is this in? which version did you upgrade to? did you make sure to upgrade all dependencies properly in case you are using project.clj or deps.edn?#2020-07-2213:55brunex
-        "shadow-cljs": "^2.8.106"
+        "shadow-cljs": "^2.10.17"
#2020-07-2213:56brunex
:target :browser
:release {:compiler-options  {:optimizations :advanced
                                 :output-feature-set :es8
                                 :source-map true
                                 :pseudo-names true
                                 :cross-chunk-method-motion false}}
#2020-07-2213:58brunexI'm using shadow-cljs.edn for :dependencies#2020-07-2214:00brunexand thanks for the help btw#2020-07-2214:15thheller@brunex looks fine and works fine for me too. you should definitely remove :pseudo-names true though. thats for debugging and will make your build huge.#2020-07-2214:16brunexI'm debugging#2020-07-2214:16brunexthat's why#2020-07-2214:16brunexbut can't get it to compile#2020-07-2214:16thhellerdo you use deps.edn or project.clj?#2020-07-2214:17brunex
Closure compilation failed with 1 errors
--- client/components/simulation/trackball.js:1
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
#2020-07-2214:17brunexI use shadow-cljs.edn#2020-07-2214:17brunexand I do cider-jack-in#2020-07-2214:17brunexwhat you mean by deps.edn or project.clj?#2020-07-2214:18thheller:lein or :deps in shadow-cljs.edn as some true-ish value#2020-07-2214:18thhellerusing those to manage dependencies and not just shadow-cljs.edn#2020-07-2214:19thhellerand the JS file you are working only has import and export and no other goog.* stuff?#2020-07-2214:19brunexyep#2020-07-2214:19brunexI'm using shadow-cljs.edn and no :lein or :deps keys#2020-07-2214:20brunex
:dependencies
 [
  [cljs-drag-n-drop "0.1.0"]
  [cljs-http "0.1.46"]
  [com.stuartsierra/component "0.3.2"]
  [venantius/accountant "0.2.3"]
  [com.cemerick/url "0.1.1"]
  [com.taoensso/timbre "4.8.0"]
  [bidi "2.1.6"]
#2020-07-2214:20brunexetc..#2020-07-2214:20brunexthat is how I do dependecies ...#2020-07-2214:21thhellermaybe try deleting the .shadow-cljs/builds dir. could be that the cache is confused about something.#2020-07-2214:21brunexregarding the JS file yes is only a
import * as THREE from 'three';
#2020-07-2214:21brunexokay let me try#2020-07-2214:21thhellerand there isn't any other goog.* stuff in the file?#2020-07-2214:22brunexnop#2020-07-2214:23brunexsame error after deleting .shadow-cljs#2020-07-2214:24brunexit is working perfectly with version 2.8.106#2020-07-2214:24thhellerit is working fine for me on 2.10.17 too#2020-07-2214:25brunexhmmm weird#2020-07-2214:25brunexlet me stop all REPLs clean everything and try again#2020-07-2214:25thhellerI found one cache issue related to classpath-js but thats entirely different from your problem#2020-07-2214:30brunexsame 😞#2020-07-2214:30brunex
import * as THREE from 'three';



let TrackballControls = function ( object, domElement ) {
    ....

};

TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
TrackballControls.prototype.constructor = THREE.TrackballControls;

export { TrackballControls };
#2020-07-2214:30brunexthis is how my JS file looks like#2020-07-2214:32brunexthe idea is to use it as something like this on the cljs side (:require ["./trackball.js" :as tb]) (tb/TrackballControls. camera element)#2020-07-2214:33thhellerall seems fine to me. is this open source code?#2020-07-2214:33brunexno is a internal project 😕#2020-07-2214:36thhellersorry, not a clue what might be going on there#2020-07-2214:36brunexthanks anyway, will revert to the old version for now#2020-07-2217:24MatDHi! I'm really trying hard to use an existing macro in my CLJS code, but I get a Error in phase :compilation error. The macro I'm trying to use : https://github.com/escherize/tracks It's written in CLJC so it should work in clojurescript right ? I added the dependency to my shadow-cljs.edn
:dependencies [[tracks "1.0.6"]]
And in the file I'm trying to use it
(ns dummy
  (:require [tracks.core :refer-macros (deftrack)]))
(deftrack calculate-price-for-order
  {:a {:c price}
   :b {:d quantity}}
  (* price quantity))
I also read the post from @thheller (https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html) but I'm not sure if this applies to macros from libraries. Following the post, I tried to define a tracks.core namespace in a CLJS file and refer itself, but it doesn't change the error. Any ideas ?
#2020-07-2219:38thheller@mathieu.durand it helps if you post the actual error you are getting and not just parts of it. I do not know that library but it looks to me like it might be clojure only#2020-07-2220:26MatD@thheller thats the thing, there is no more to the error. I only get Error in phase :compilation and if I wait 15 sec, I get this
Exception in thread "async-dispatch-7" java.net.SocketException: Socket closed
        at java.base/java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
        at java.base/java.net.SocketOutputStream.write(SocketOutputStream.java:150)
        at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
        at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
        at nrepl.transport$bencode$fn__5881.invoke(transport.clj:109)
        at nrepl.transport.FnTransport.send(transport.clj:28)
        at nrepl.middleware.print$send_nonstreamed.invokeStatic(print.clj:159)
...
and the shadow-cljs process dies...
#2020-07-2220:27MatDHow can you tell if it's clojure only or clojurescript compatible ?#2020-07-2220:27thhellerthere is no such thing as ONLY Error in phase :compilation#2020-07-2220:27thhellerthere must be more info to it?#2020-07-2220:27thhellereven if its just a location?#2020-07-2220:28thhellerhttps://github.com/escherize/tracks/blob/master/src/tracks/core.cljc#L65#2020-07-2220:28MatDI'm using Calva to start the process... maybe it's hiding the error. Let me try to start it manually#2020-07-2220:28thhelleralter-meta! doesn't do anything useful in CLJS#2020-07-2220:31MatDI will PM you the screenshot where I get the error and nothing else#2020-07-2320:43bennytrying to use :closure-defines like https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines but nothing seems to change, is there something I’m doing wrong?
; shadow-cljs.ed
...
:builds {:dev
          {:target :react-native
           :closure-defines {client.home/foo "bar"}

; client/home.cljs
(def foo "Hayea!")

...
[rn/text {:style ui/header-style} foo]
...
#2020-07-2320:45thheller@benny you need to use (goog-define foo "default"). a regular def does nothing with regards to closure-defines.#2020-07-2320:45bennyahh thank you!#2020-07-2323:08colinkahnThis is perhaps a weird question, but is there a way to output javascript in shadow-cljs that doesn’t target either the browser or node? Specifically I’m looking to target https://github.com/dop251/goja#2020-07-2407:08thheller@colinkahn that is what :target is for. there could be a :target :goja. from the looks of it the output of :node-script release builds might just work?#2020-07-2815:36colinkahn@U05224H0W thanks, I used the custom target example and got it working. Thanks again for an awesome tool!#2020-07-2407:08thhellersee https://github.com/titonbarua/shadow-cljs-gjs-target for a similar thing#2020-07-2411:11gleisonsilvaHello, guys! Yesterday I've updated to 2.10.17. Then my setup with Vim Fireplace has stopped working. I can't no more connect to repl... has anyone experience that? Can help me?#2020-07-2411:16OlicalI've also lost completion support recently, so have other users of Conjure, we're seeing NPEs (will attach as snippet after this)#2020-07-2411:17Olical#2020-07-2411:18thhellerclj-suitable is broken currently. https://github.com/rksm/clj-suitable/issues/15#2020-07-2411:18OlicalAH!#2020-07-2411:18OlicalThanks!#2020-07-2411:18thhellerapparantly its just disabled in cider now?#2020-07-2411:19OlicalLike, no cljs completion until it's fixed?#2020-07-2411:19OlicalBecause Conjure handles it okay, I don't need to disable it. It's just failing in the background and saying there's no completions.#2020-07-2411:19thhellercompletion still works I think. just the regular kind. so no completion for "live" JS objects#2020-07-2411:20OlicalAh! So I can turn off that advanced flag#2020-07-2411:20thhellerI don't really know how any of it works since I don't use it#2020-07-2411:21OlicalNo problem, I think it's enhanced-cljs-completion?, pretty sure I can just switch that off for now and it'll continue to work. Thank you so much for the insight.#2020-07-2421:53neilyioI'd love a tip or two on reading the below stacktrace. I evaluated a function in the CIDER REPL, and got #object[Error Error: No protocol method ReadPort.take! defined for type null: ] . Then, I did a (tap> *e) in the REPL so that I could take a look at the :stack key on the object using the (amazing) shadow-cljs Inspect tool.#2020-07-2421:53neilyioHere's what I see:
Error: No protocol method ReadPort.take! defined for type null: 
    at Object.cljs$core$missing_protocol [as missing_protocol] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core.cljs:318:3)
    at cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_37176 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async/impl/protocols.cljs:13:1)
    at Object.cljs$core$async$impl$protocols$take_BANG_ [as take_BANG_] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async/impl/protocols.cljs:13:1)
    at Function.cljs$core$IFn$_invoke$arity$3 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
    at Function.cljs$core$IFn$_invoke$arity$2 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
    at cljs$core$async$take_BANG_ (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/cljs/core/async.cljs:99:1)
    at cljsEval (<eval>:1:36)
    at global.SHADOW_NODE_EVAL ([stdin]:105:10)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:11:1)
    at Object.shadow$cljs$devtools$client$shared$IHostSpecific$do_invoke$arity$2 (/Users/neil/Desktop/loserCLI/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:100:5)
#2020-07-2421:54neilyioI don't see any of the names of my own .cljs files on any of these lines, so I'm not sure where to start looking for the error. To be clear, I'm happy to debug the actual error on my own, I'd just love a tip for getting started.#2020-07-2421:54thheller(<! something) where something is nil#2020-07-2421:56neilyioHaha that certainly saves me some debugging time, thank you! I'll remember that particular error-cause relationship now, but do you think it would be useful for me to know how to parse this stack trace?#2020-07-2421:57thhellerNo protocol method ReadPort.take! defined for type null <! is calling that protocol. the trace is basically just going from the helper fn through the entire implementation ending up at the protocol#2020-07-2421:58thhellerit starts with something you called from the REPL#2020-07-2421:58thheller<! is also called take! basically#2020-07-2421:59neilyioI guess what's throwing me off is that I don't see any of my own source files in the stack trace. I realize that it's probably hidden by all the compilation that's happening, but I was wondering if I should be configuring something to make them more clear.#2020-07-2421:59thhellergo block are rewritten pretty heavily so the stack traces often don't quite make sense#2020-07-2422:00neilyioI see, so this unclear stack trace might be an issue I'll keep running into with core.async and go blocks. That helps me understand better, thank you once again.#2020-07-2422:00thhellerdid you not trigger this from the REPL?#2020-07-2422:00neilyioI did, yes.#2020-07-2422:00thhellerstacktrace looks like you did so there really is no "file" reference to show#2020-07-2422:01neilyioOoooooh#2020-07-2422:01neilyioOf course. One of those things that doesn't make sense until you publicly embarrass yourself with it. Is there a smarter way of evaluating my code that would help me see that "file" reference?#2020-07-2422:02thhellerwhat file reference do you want to see? the error was in the code you just eval'd? you know where that came from?#2020-07-2422:03neilyioI just evaluated my main function, which calls a few other functions, and I just wasn't really sure where to start looking for the error.#2020-07-2422:03neilyioBut it sounds like the trick is just to evaluate smaller blocks of code at a time.#2020-07-2422:04thhellerI always just load the entire file and then sometimes code from (comment ...) blocks#2020-07-2422:04neilyioIdeally, I would have liked to see the line in my app.main cljs file that contained the <! or the go block that I messed up on.#2020-07-2422:04neilyioThat's a good tip. Thanks for working with me through these rough spots.#2020-07-2422:07thhellerthe shadow-cljs codebase is littered with these kinds of comments. usually I clean them up after a while but sometimes they just hang arround#2020-07-2422:07thhellereg. https://github.com/thheller/shadow-cljs/blob/83b7d5ac07bd3e9f776290453e2373e993f5dd55/src/main/shadow/cljs/repl.clj#L653#2020-07-2422:08thhellerso in Cursive I just open that file and "Load file in REPL" and then place my cursor in that form and "Send form to REPL"#2020-07-2422:08thhellerpretty common workflow. others have made videos about that.#2020-07-2422:10thhellerI agree that things could be smarter in that each form sent to the REPL could contain a source location and Cursive does this in some way to Clojure#2020-07-2422:11thhellerbut thats mostly on the editors not sending the information and the REPLs not respecting or consuming it at all#2020-07-2422:12neilyioGlad to hear I'm not entirely going crazy!#2020-07-2620:36aaelonyCan someone point me to a working shadow-cljs example that runs out of the box? I have tried several (e.g. https://github.com/shadow-cljs/examples/tree/master/re-frame) that all seem to have various errors.#2020-07-2620:36aaelonye.g.
[:app] Build failure:
The required namespace "react" is not available, it was required by "mranderson047/reagent/v0v8v0_alpha2/reagent/core.cljs".
#2020-07-2620:42aaelonyI see, I think I might only need
npm install react react-dom create-react-class react-flip-move react-highlight.js
first. But it might be nice if the examples "just worked", although I understand that might be more difficult.
#2020-07-2620:51dpsuttonHave to install dependencies no matter what#2020-07-2622:59aaelonywell, then list the deps in the readme, or have the install process fetch them ;)#2020-07-2621:22thheller@aaelony those examples are rather outdated. there are a couple more recent ones out there though. I recommend starting with the quick start so you understand whats going on https://github.com/thheller/shadow-cljs/blob/master/README.md#2020-07-2707:46Karol WójcikTrying to test react components using "@testing-library/react". After compiling and running with karma I'm receiving following errors: Question: How to test React components in cljs?#2020-07-2707:54Chris McCormickis there a way to suppress building the manifest.edn completely?#2020-07-2708:24thheller@karol.wojcik I don't know anything about testing react components but the above error you can fix by setting :compiler-options {:output-feature-set :es7} or maybe :es6 or :es8. depends on what the lib uses and what karma supports#2020-07-2710:15Karol WójcikUsing the latest shadow-cljs. Anyway applying :es8 fixed the issue 🙂 Thanks!#2020-07-2708:24thhelleris this with the latest shadow-cljs? I though I fixed all the $jscomp issues. if not maybe try upgrading.#2020-07-2708:26thheller@chris358 no but I can add an option for that. open an issue if you want, otherwise I'll forget 😉#2020-07-2708:28Chris McCormickit is really not important. i can just add the file to .gitignore.#2020-07-2708:28thhelleryour entire :output-dir should be gitignored 😛#2020-07-2708:29Chris McCormickit is created during release as well#2020-07-2708:29Chris McCormickmy release artifact is checked in on a branch as i use git push to deploy.#2020-07-2708:33thhelleryikes. doesn't that make your entire git repo disturbingly large after a while?#2020-07-2708:33thhellerwell I guess github does it for github pages too so can't be that bad 😛#2020-07-2708:37Chris McCormickmy git repos are not excessively large. git's diffs are very efficient and builds are not that frequent. sometimes i build into an entirely separate repository (e.g. project is the source and project/build is a separate repo containing the artifact). yes, it's the same strategy as github pages and some other static page providers.#2020-07-2708:38thhellerhmm don't git diffs fail completely for :advanced builds? didn't try in a while but it was bad?#2020-07-2708:40Chris McCormickyes git diffs of checked in artifacts would be very ugly. i don't do this.#2020-07-2712:21schauehoI'm running into a dependency issue and could use a hand to figure out what's going on. Here's the error on compiling: The required JS dependency "path" is not available, it was required by "node_modules/node-gyp-build/index.js".#2020-07-2712:22schauehoI did an npm install --save path already and the path library is available in node_modules. Any help appreciated.#2020-07-2712:27thheller@schaueho looks like you are trying to use a package that isn't supported in the browser. might be node only. as for the path package you need to have shadow-cljs installed in your project. that provides the required polyfills.#2020-07-2712:34thhellerthe node-gyp stuff is for building native packages so very likely it won't work in the browser#2020-07-2712:39Pavel KlavíkHi, I am getting the following error when trying to print my Re-frame app-db using Shadow-cljs REPL: #2020-07-2712:39Pavel Klavík
Exception in thread "XNIO-1 I/O-1" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x70
 at [Source: 
#2020-07-2712:39Pavel KlavíkAny idea what could be causing this? The app works in the browser fine.#2020-07-2712:40schauehoYeah, I'm trying to use sodium-plus, which in turn tries to use sodium-native, which is using the browser NaCL stuff.#2020-07-2712:40thheller@pavel.klavik not a clue but try (tap> app-state) and the UI 🙂#2020-07-2713:06Pavel KlavíkOk, so the data gets printed in UI fine. How do you control it to explore the map?#2020-07-2713:10thhellerjust click things#2020-07-2713:22Pavel Klavíkya, makes sense, it got broken somehow because Shadow got stuck, working now#2020-07-2713:22Pavel KlavíkI have this#2020-07-2713:22Pavel Klavík#2020-07-2713:22Pavel Klavíkand when clicking on dashboard, I just get#2020-07-2713:23Pavel Klavíkso the problem is probably somewhere there#2020-07-2713:24thhellerinteresting. would be curious to see what you have in there causing this 😛#2020-07-2713:25thhelleryou can click the "EDN" button on the bottom. maybe that works? or pprint?#2020-07-2713:26thhellerbut the UI also uses transit so makes sense it also fails#2020-07-2713:50Pavel Klavíkit shows#2020-07-2713:52thhellerhmm also probably crashes#2020-07-2713:52thhellerany visible exceptions? browser console, process output?#2020-07-2713:53Pavel Klavíknot anything, I can check what data are send from the server#2020-07-2713:54thhellerI have nothing in the UI to handle failures since I had nothing that caused a failure before 😛#2020-07-2713:54thhellerwould be rather interesting what this is#2020-07-2713:55thhellermaybe a string with some weird unicode or so that isn't escaped properly and confuses the JSON parser#2020-07-2713:57Pavel Klavíkshould be, there are no strange characters in names, etc., so not sure#2020-07-2713:57Pavel Klavíkany idea how to do debugging of this?#2020-07-2713:57thhellerthis is a browser app right?#2020-07-2713:57Pavel Klavíkya#2020-07-2713:59thhellertry (tap> (pr-str app-state)) in the REPL#2020-07-2714:00thhellerno clue how to trim it down#2020-07-2714:00thhellercan't really think of anything that would make this fail#2020-07-2714:01Pavel Klavík#2020-07-2714:01Pavel Klavíkand I am getting the same error from Shadow-cljs#2020-07-2714:01thhelleryeah ok then there is something in the output that can't transfered via transit#2020-07-2714:03thhellerall google searches suggest its a bad utf-8 string, just gotta find it 😛#2020-07-2714:04thhellermaybe try trimming it down as much as possible and just use (js/console.log (pr-str (:dashboard app-state))) or so#2020-07-2714:05Pavel Klavíkmakes sense, will try this out#2020-07-2714:06Pavel KlavíkI could probably erase everything since it happens in my testing data, but I am curious what is going on#2020-07-2714:06thhellerme too 🙂#2020-07-2714:10Pavel Klavíkalso I was trying to tap another state where dashboard was not loaded (and which fails as well)#2020-07-2714:10Pavel Klavíkand while exploring, I am getting stuck on clicking some top keys and getting this error in console: WARNING] :shadow.remote.relay.local/client-sent-invalid-msg - {:client-id 52, :msg {:op :obj-request, :to nil, :oid nil, :request-op :nav, :idx 2, :call-id 21}}#2020-07-2714:11Pavel Klavíkit happens when clicking on :dashboard#2020-07-2714:47Pavel KlavíkOk, so it seems to be breaking on something which looks like this:
[:strong {} "And maybe not this. And maybe not this. "
                         [:span {} " And maybe not this. " [:strong 
{} "And maybe not this. And maybe not this.  "]]]
#2020-07-2714:48Pavel Klavíksuper weird, nothing seems strange there#2020-07-2714:55Pavel Klavíkno idea what is going on, I will probably just reset my development data and hopefully I won't see this error again, super weird#2020-07-2818:55Mikael AnderssonI've seen issues where editors under some circumstances get an invalid byte sequence in the source code, which then also is invisible in the editor. It's not super common, but if the issue persists, try running code/data through cat -v, od -t x1c , hexdump, or whatever gets you byte values without any character set conversion. Cat -v might be multibyte aware on some platforms, so the other alternatives are safer if you are unsure.#2020-07-2712:40schauehoAnd you're right, I'm running directly into the next issue.#2020-07-2712:41thhellerhttps://github.com/paragonie/sodium-plus/blob/HEAD/docs/getting-started.md#sodium-plus-in-the-browser#2020-07-2813:11schauehoJust FYI, following this recipe and assigning sodium-plus to the window object allowed me to use it then. Thanks again for the nudge in the right direction!#2020-07-2712:41thhellerlooks like you can't use it directly from npm#2020-07-2712:42thhelleryou can also set :js-options {:resolve {"sodium-native" false}} that will make it ignore that package#2020-07-2712:42thhellerno clue if thats enough though. may break in other ways.#2020-07-2712:43schauehowill try that, thanks a ton for the input!#2020-07-2717:14ShaneLesterI was reading somewhere that turning aot-cache to false might fix an issue I'm having when I'm targeting a node module as my output. On the https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options it says that aot-cache is "unsupported or non-applicable"-- does this mean that it is false by default? or is it always true?#2020-07-2717:15thhellerwhat issue do you have? aot-cache is not a thing in shadow-cljs. it has a different caching mechanism.#2020-07-2717:19ShaneLesterAhh ok. Was a bit of a longshot. Essentially, I'm using a material-ui datepicker which requires moment and some moment utils, and I'm using cljsjs/moment to get some of that to work. It works fine locally / deployed in our normal process, but when we try to export our project as a node module with shadow, it can no longer find the default MomentUtils it needs from dateio/moment. I was googling and got spit out to https://figwheel.org/docs/npm.html "Problems with cached compiled assets" section, and obviously this is a different product but what it was describing in that section seemed pretty familiar to what I was running into. I think I may have been mistaken / misunderstood what that aot cache actually does though#2020-07-2717:20thhellerthis goes a lot quicker if you provide more details about the actual problem. not what you searched to fix it.#2020-07-2717:20thheller> it can no longer find the default MomentUtils it needs from dateio/moment.#2020-07-2717:20thhellerwhat does that mean?#2020-07-2717:21thhellercljsjs/moment is also a problem in itself so that may be your issue. shadow-cljs does not support CLJSJS.#2020-07-2717:21ShaneLesterI'll refine what my actual issue is and come back, just wanted to provide context to why i asked the question. Part of my current problem is I haven't exactly identied the problem yet#2020-07-2717:21thhelleryou should just use the npm packages directly instead#2020-07-2717:21ShaneLesterah ok. I will try to get rid of that overall#2020-07-2717:22ShaneLesterthanks for the response, and sorry for the lack of good details#2020-07-2717:31thhellerjust (:require ["moment" :as mom]) and then (mom/whatever ...) should be fine. dont use cljsjs.moment and js/moment#2020-07-2720:13neilyioFollowing the instructions https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_3 for setting the :devtools key on my build, but it doesn't seem to be taking effect when I restart the server. I'm expecting the REPL to start in the namespace app.main, according to my shadow-cljs.edn config below, but it still starts in cljs.user. repl-pprint doesn't seem to be having any effect either.
{:source-paths
 ["src"]

 :dependencies
 [[fullcontact/full.async "1.1.0"]]

 :builds
 {:main
  {:target :node-script
   :main app.main/main
   :output-to "public/main.js"
   :devtools {:repl-init-ns app.main
              :repl-pprint true}}}}
#2020-07-2801:07lsenjovI'm kinda stumped on an issue. I need to use requirejs on this platform (no getting around it unfortunately), and shadow appears to be having conflicts. Specifically, loading modules with the usual ["namespace" :as something] appears to replace whatever requirejs is loading Any hints/things to look into would be appreciated#2020-07-2804:12lsenjovTurns out it was just the library I was bringing in (nprogress) which seems to load itself globally for some reason. I don't need it. Other libraries are loading fine#2020-07-2812:20timrichardtI am trying to use js code within a shadow-cljs project. shadow-cljs.edn :
{:source-paths
 ["src/cljs"
  "src/js"]
...
From src/cljs/.../core.cljs , I want to render a react component exported from a js file
(ns core
  (:require ["react" :as react]
            ["react-dom" :as react-dom]

            ["/Component.js" :default Example]))


(.log js/console Example)

(defn init! []
  (react-dom/render (Example) (js/document.querySelector "#root")))

(defn reload! []
  (init!))
src/js/Component.js :
import React from "react";

export default function Example() {
  return React.createElement(
    "div",
...
#2020-07-2812:22thhellerfirst of all forget about src/cljs and src/js. just put the .js file in the same directory as your CLJS file#2020-07-2812:23thhellerjust makes this needlessly complex and js files should be namespaced as well#2020-07-2812:23thhellerbut whats the issue? 😛#2020-07-2812:24timrichardtOk, i babel them now to the cljs folder, the issue is
TypeError: Cannot read property 'createElement' of undefined
#2020-07-2812:24timrichardtReact is not loaded properly somehow.#2020-07-2812:25thhellerah ok you are using babel. then a separate source paths makes sense#2020-07-2812:25thhellershould be import * as React from "react"#2020-07-2812:25thhellercommonjs <-> ESM interop is weird#2020-07-2812:26timrichardtvoila, it works.#2020-07-2812:26timrichardtThanks.#2020-07-2812:26timrichardtYes, I have seen that you translate it to commonJS imports.#2020-07-2812:27timrichardtBut have no idea how those really work.#2020-07-2812:27thhellerits sort of undefined since regular ESM (eg. actual browsers) do not support it at all#2020-07-2812:27timrichardtoh, ok. didnt know that#2020-07-2812:28thhellersome tools like webpack or babel just tried to hide it and now we have to deal with the consequences of everything being shit for a while 😛#2020-07-2812:28thhellerprobably going to take a couple years till more ESM is available#2020-07-2812:30timrichardtThanks. 🤗#2020-07-2820:54sova-soars-the-sorapretty print true and what's the other one for figuring out what's up with advanced optimizations fuzzing up?#2020-07-2820:55sova-soars-the-soraaha, pseudo-names... or --debug... wish me luck#2020-07-2820:56thhellerfirst step should be turning on externs inference in case it isn't https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2020-07-2820:56thheller(its on by default in recent versions)#2020-07-2820:58sova-soars-the-soracheck. got that. ... well here look#2020-07-2820:59sova-soars-the-sora#2020-07-2820:59sova-soars-the-sorai'm getting this from a text input#2020-07-2821:01sova-soars-the-sorawill do more investigating...#2020-07-2821:22thhellerthat doesn't look like --pseudo-names or --debug?#2020-07-2821:45Jp SoaresAbout the new :target :esm.. Shouldn't it include the shadow.cljs.devtools.client.env.js in the dev compiled outputted esm module? As it uses shadow.cljs.devtools.client.env.module_loaded. I'm always getting the error
Uncaught TypeError: Cannot read property 'module_loaded' of undefined
    at shared.js:91
#2020-07-2821:47thhellerit should be included?#2020-07-2821:48Jp SoaresIt doesn't get included in my shared.js file. It's fixed when I include the lines
import "./cljs-runtime/shadow.cljs.devtools.client.env.js";                                                               
SHADOW_ENV.setLoaded("shadow.cljs.devtools.client.env.js");
#2020-07-2821:49thhelleryou are using watch I presume?#2020-07-2821:50Jp SoaresNot right now.. I'm just compiling.#2020-07-2821:50Jp SoaresBut it happened while I was watching, I guess..#2020-07-2821:50thhellercould be that its broken for compile#2020-07-2821:50Jp Soareslet me see in watch#2020-07-2821:53Jp SoaresYep.. it works on watch#2020-07-2821:55sova-soars-the-sorauhh, invoking --debug in console but not getting --debug results... will try with flag#2020-07-2821:55Jp SoaresHey Thomas.. as you are here reading my messages 🙄 I commented in one of your answers here https://clojureverse.org/t/generating-es-modules-browser-deno/6116/10?u=jponline#2020-07-2821:56thheller@sova could be that the error is deep in some already minified npm package? that wouldn't be affected by --debug or --pseudo-names?
#2020-07-2821:59thheller@jpsoares106 I don't really understand what you are asking. you want to publish some web components written in CLJS as a npm library to be consumed by JS users?#2020-07-2822:08Jp SoaresYes, exactly, this is one thing..#2020-07-2821:59sova-soars-the-sorao.o i suppose, i'm not using a lot of crazy things... i didn't go out of my way to minify anything#2020-07-2822:00thhellerwell the screenshot you posted is not from a --debug output build#2020-07-2822:00sova-soars-the-sora
(rum/defc user-chat-input < rum/reactive []
 #?(:cljs (let [csrf-token  (.getAttribute (. js/document (getElementById "aft")) "data-aft")
            input-atom (rum/react user-msg-input-atom)]
  [:div.userinputwrap
   [:div.userinputrapp 
   [:form#in {:on-submit (fn [e] (.preventDefault e)
   	                             (.log js/console "send message via sente net event")
   	                             (chsk-send! [:clientsent/chat-msg {:input input-atom :location (js/decodeURI (. (. js/window -location) -pathname))}])
   	                             (reset! user-msg-input-atom "")
   	                             )}
    [:input {:placeholder "submit chat here, be kind"
    									:auto-focus true
    								 :value (rum/react user-msg-input-atom)
             :on-change (fn [e] (do (println (-> e .-target .-value))
  											                       (reset! user-msg-input-atom (-> e .-target .-value))))}]]
   [:script {:src (str "main.js?v" 6)}]]]))

  #?(:clj 
   [:div.userinputwrap
   [:div.userinputrapp 
   [:form#in
    [:input {:placeholder "submit chat here, be kind" :autofocus true}]]
   [:script {:src (str "main.js?v" 6)}]]]))
at a glance can you catch anything egregious ?
#2020-07-2822:01sova-soars-the-soraoh i wonder why the --debug build is not showing up q.q#2020-07-2822:04thhellerwhat the heck is this [:script {:src (str "main.js?v" 6)}]?#2020-07-2822:04sova-soars-the-sorajust happens to be where the script is included 😂#2020-07-2822:05thhellerhow does that work? the script is already loaded at that point?#2020-07-2822:05sova-soars-the-sorayeah, but you're it ought not be loaded until all components are loaded?#2020-07-2822:05sova-soars-the-sorasaying *#2020-07-2822:06thhellerI don't have a clue what you are doing but loading a script like that looks like an error to me#2020-07-2822:06thhellerthis is definitely not how you load things ever on the client side#2020-07-2822:06sova-soars-the-soraoh, thanks, i was not aware of that#2020-07-2822:06sova-soars-the-sorahow ought i do that?#2020-07-2822:07thhellerI do not have a clue what you are doing so I cannot possibly answer that#2020-07-2822:07thhellerit looks like you have some server-side code that adds the script tag?#2020-07-2822:07thhellerso when the client loads that html it will load the scripts#2020-07-2822:07thhellerbut then it reaches the point in the code and tries to include the scripts again#2020-07-2822:07thhellerbut they are already loaded? so just don't load them again?#2020-07-2822:07sova-soars-the-soraoh#2020-07-2822:08sova-soars-the-soradoh#2020-07-2822:08sova-soars-the-sorajust don't include the script again on the clientside#2020-07-2822:08thhellerunless you are doing some code-splitting and actually want to lazy load code#2020-07-2822:09sova-soars-the-soranot the case 😄#2020-07-2822:09thhellerok then just remove the [:script ...] for the cljs path#2020-07-2822:09sova-soars-the-soralegitas.#2020-07-2822:09sova-soars-the-soracljs is still a blurry new landscape to me... thank you for your help#2020-07-2822:09sova-soars-the-soraand unfailing patience#2020-07-2822:23sova-soars-the-soraHmm... I am using --debug but still getting these minified errors.#2020-07-2822:23sova-soars-the-soraI am probably missing something obvious...#2020-07-2822:28thhelleryou are doing shadow-cljs release app --debug?#2020-07-2822:30sova-soars-the-sorayes#2020-07-2822:32thhellerand whatever file that is producing you are loading on the page? not some old file sitting in a different dir or so?#2020-07-2822:32sova-soars-the-soralet me double check that part#2020-07-2822:34sova-soars-the-sorayes#2020-07-2822:35sova-soars-the-soraseems like output?#2020-07-2822:35thhellerok that looks like its deep on react-dom code (which is already minified so its not affected by --debug)#2020-07-2822:36sova-soars-the-soraAh okay#2020-07-2822:38thhellerits also in hydrate which I have never used so no clue what you are doing#2020-07-2822:38sova-soars-the-soraNot sure what to make of it. Do you spot anything wild in these lines
(let [in-data    (cljs.reader/read-string (.getAttribute (. js/document (getElementById "pcp")) "data-mggs"))
						in-answers (cljs.reader/read-string (.getAttribute (. js/document (getElementById "pcp")) "data-inanswers"))
      page-type  (.getAttribute (. js/document (getElementById "pcp")) "page-type")]
      (println page-type in-data in-answers)


      (reset! indata in-data) ;set storange atoms
      (reset! inansw in-answers)
      
  (if (= "question" page-type) (do (rum/hydrate (question-page @indata @inansw) (.getElementById js/document "rhqp"))
  																																	(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))))

  (if (= "room" page-type)     (do (rum/hydrate (chat-page in-data) (.getElementById js/document "rhcp"))
  																																	(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))
  																																	(scroll-to-bottom)))

  (if (= "allqp" page-type)    (do (rum/hydrate (all-question-page @indata)        
                                                (.getElementById js/document "rhaq"))																																	))

  (if (= "setts" page-type) 
   (let [in-dn (.getAttribute (. js/document (getElementById "ecce")) "data-displayname")]
      (reset! displayname in-dn)
      (.log js/console in-dn)
      (rum/hydrate (rolo-settings @displayname)
      (.getElementById js/document "rhsp"))
      ;(rum/hydrate (user-chat-input) (.getElementById js/document "uci"))
      )))
#2020-07-2822:39sova-soars-the-soraa snippet from client.cljs that has the rum/hydrate methods#2020-07-2822:39thhellersorry not a clue. as I said I have never used hydrate.#2020-07-2822:40sova-soars-the-sorano problem. it's just a way to get the clientside to nimbly saddle onto the pre-rendered server html#2020-07-2822:40sova-soars-the-sorait just sucks because the un-optimized version is 2.4MB and it ought be maybe 750k#2020-07-2822:41thhellerI know what hydrate is ... I just have never used it so I cannot help you figure out what it needs#2020-07-2822:42thhellerit might be trying to look up functions by name or so which doesn't work with :advanced since they are all renamed#2020-07-2822:52sova-soars-the-sorait's 6.9MB when not a release build#2020-07-2822:52sova-soars-the-sora😮#2020-07-2822:53thhelleryeah dev builds are huge#2020-07-2822:54sova-soars-the-sorahmm so some things are getting renamed...#2020-07-2910:59sova-soars-the-soraWell i'm stumped. I have a super simple component, optimizations make it not work. will try to slim it down to the bare essentials.#2020-07-2911:25thhellerhappy to take a look if you make a reproducible example#2020-07-2912:23sova-soars-the-sorathank you my man, guess what. rum doesn't know what to do with :on-submit .... instead, example code for rum uses
#?(:cljs 
 (defn- textarea-keydown [callback]
  (fn [e]
    (if (and (== (.-keyCode e) 13) ;; enter
             (not (.-shiftKey e))) ;; no shift
      (do
        (callback (.. e -target -value))
        (set! (.. e -target -value) "")
        (.preventDefault e))))))
to submit on a :textarea which it would appear solves my problem i think...
#2020-07-2912:24sova-soars-the-soragood news: clojurescript is the greatest again.#2020-07-2914:08sova-soars-the-sora543 kB 😃#2020-07-2916:10grounded_sageNot sure if it is how I am running shadow or the cljs side. But I am getting undeclared var on macro’s when I run shadow-cljs watch app. But if I paint up a repl and connect to browser environment the macros seems to work fine. #2020-07-2916:20thhellerhard to tell without seeing code 😛#2020-07-2916:20thhellerI wrote this regarding macros https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-07-2919:24Eric IhliDon't see much in the docs about source maps other than the config option that defaults to true during development. I'm getting an exception and it's reporting line 600+ in a 200-line file. Curious if this means I have something mis-configured or it I'm not understanding when source-maps come into play. My assumption was that when an exception occurred, I could click on the link in the dev console and it would take me to the clojurescript file, not the compiled javascript file. That's not the case. Instead, when I click on the line in the exception, bitstamp.js:631, it opens a new tab in Firefox and I get an alert that the line can't be found. I try typing in a line that I know exists and it still can't be found. In fact, the tab opens to view-source: but it's an empty page. No code lines. Nothing. Not sure what the expected behavior is because I've never known my environment to work any other way. But this feels wrong. It's a fairly barebones project.
{:dev-http {8008 ["classpath:public"]}
 :nrepl {:port 9999
         :middleware []}
 :deps true
 :builds
 {:main {:target :browser
         :output-dir "resources/public/js/main"
         :asset-path "js/main"
         :modules {:main {:entries [com.owoga.bitstamp]
                          :init-fn com.owoga.bitstamp/init}}
         :devtools {:repl-init-ns cljs.user
                    :console-support false
                    :after-load com.owoga.bitstamp/refresh
                    :repl-pprint true}}}}
#2020-07-2919:26Eric IhliThe file does exist and it does look like it has source map annotations.
➜  my-project tail resources/public/js/main/cljs-runtime/com.owoga.bitstamp.js
com.owoga.bitstamp.refresh = (function com$owoga$bitstamp$refresh(){
taoensso.timbre._log_BANG_.cljs$core$IFn$_invoke$arity$10(taoensso.timbre._STAR_config_STAR_,new cljs.core.Keyword(null,"info","info",-317069002),"com.owoga.bitstamp",null,330,new cljs.core.Keyword(null,"p","p",151049309),new cljs.core.Keyword(null,"auto","auto",-566279492),(new cljs.core.Delay((function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["Re-rendering root."], null);
}),null)),null,1062859293);

return reagent.dom.render.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [com.owoga.bitstamp.order_book], null),document.getElementById("order-book"));
});
goog.exportSymbol('com.owoga.bitstamp.refresh', com.owoga.bitstamp.refresh);

//# sourceMappingURL=com.owoga.bitstamp.js.map
#2020-07-2920:16thhellermaybe try setting :devtools {:loader-mode :script}#2020-07-2920:17thhelleror maybe just :asset-path "/js/main". relative paths are problematic sometimes if you use any kind of push-state routing or so#2020-07-3013:50Eric IhliJust confirmed it is loader-mode :script that fixes it. Tried each individually and together. Get success with just loader-mode script.#2020-07-3013:50Eric IhliThanks!#2020-07-2923:45dehlihello! is it possible to have shadow watch a release build? when building with traditional clj, you could do:
(require '[cljs.build.api :as b])
(b/watch "src"	
         {:main 'handlers.core	
          :output-dir "out/"	
          :output-to "build/js/main.js"	
          :optimizations :simple	
          :target :nodejs})
#2020-07-2923:58dpsuttonThat is running optimizations simple. Seems to defeat the purpose? It’s not really a release build at that point.#2020-07-3001:31dehliWith it being a nodejs app I don’t really need to have advanced optimization since bundle size isn’t a big deal (unless there’s some other benefit I’m unaware of).#2020-07-3007:47orestisI have a potentially weird request: can I just run an analysis over my .cljs code that will do macroexpansion but nothing else? We’re yet again trying to do translation extraction based on macros. We don’t care to generate JS code at all, just go over all of our source code (with no cache), macroexpand, then look at at some dynamic var that contains all our translation strings.#2020-07-3008:14thheller@dehli there is no watch for release builds. you can run shadow-cljs server and then shadow-cljs release app whenever you want to rebuild. it'll be quick, just need to trigger it manually. or just use an external watcher to trigger that command. I recommend doing it manually since release optimizations can take a long time you usually end up compiling "prematurely" and then having another compile queue up.#2020-07-3008:18thhellerdon't quite see a reason why you want watch with :simple though? whats wrong with just watch?#2020-07-3011:38dehlithanks! the artifact produced with watch seems to require some dependencies (such as websocket). My idea of using watch with a simple build is that I could have that running and as I make changes I could very quickly deploy the updated code to AWS.#2020-07-3008:49kaukoHi all! I'm trying to add https://github.com/gregnb/mui-datatables#install to our project. I'm already successfully using material-ui components, but this one I can't get to work. I'm requiring the component with ["mui-datatables" :default MUIDataTable] (the readme has import MUIDataTable from "mui-datatables";), and my component looks like:
The issue is resolved, removed the code to not fill the whole channel
#2020-07-3008:49kaukoHi all! I'm trying to add https://github.com/gregnb/mui-datatables#install to our project. I'm already successfully using material-ui components, but this one I can't get to work. I'm requiring the component with ["mui-datatables" :default MUIDataTable] (the readme has import MUIDataTable from "mui-datatables";), and my component looks like:
The issue is resolved, removed the code to not fill the whole channel
#2020-07-3008:50kaukoI'm seeing a bunch of errors in my console, not sure which one is the most relevant one#2020-07-3008:50kauko"Invalid Hiccup form: [nil]"#2020-07-3008:51kauko> Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.#2020-07-3008:52kauko☝️ This one looks important, but I don't really know what to do with this 😄#2020-07-3008:52Karol WójcikCheck if MuiDataTable contains a value#2020-07-3008:53kaukoyou mean just (println MUIDataTable)?#2020-07-3008:53Karol WójcikYep#2020-07-3008:58kaukoI think I may have figured it out. I think mui-datatables requires material ui v4, and we only have v3#2020-07-3008:58kaukothat tip helped though, thanks a lot 🙂#2020-07-3011:32kaukoIt works after updating material ui to v4. Thanks again for the nudge into the right direction Karol!#2020-07-3018:35Karol Wójcik;D#2020-07-3012:36dehliHi, I think I’ve found a performance bug with shadow and was wondering if anyone has seen something like it before. Calling (map js/JSON.parse (string/split-lines x)) takes approximately 10 seconds to run with an 7mb file on my local machine however running the equivalent with Javascript (using js/eval) is less than a second. The reason I think this is a shadow bug and not Cljs is that we’ve recently started to have our functions that do this timeout and it’s lining up with when we switched to shadow. I think it’s specifically the split-lines command that is taking much longer. I am using the latest version of shadow. My next step is going to make a minimal reproducible examples showcasing the differences between shadow, clj, and raw nodejs. Edit: Looks like it’s not unique to Shadow. I’m seeing the same performance differences w/ a regular Clojure repl. I guess it’s a coincidence that the bugs started showing up around the same time. Sorry about that!#2020-07-3016:45ddellacostaHi folks, apologies if this is common knowledge but I’m trying to start a cider repl via cider-jack-in-cljs (per https://shadow-cljs.github.io/docs/UsersGuide.html#cider). I’m never given the option to choose a build, instead apparently it tries to create one, and this fails since I’ve already got a shadow-cljs server running. I’ll note that I’ve also got a .dir-locals.el set up per the cider instructions but this seems to be getting ignored. On the other hand it seems like I can connect to the shadow-cljs server just fine by using cider-connect-cljs instead. It’s obviously not a problem since I’ve got it working, but it’s very much not what is in the reference either for shadow-cljs or cider. I will also note that I’m using lein for dependencies instead of the default--could this be causing this? Anyways, just curious, not a big deal since it seems like I’m up in running now.#2020-07-3016:54thhellermaybe better to ask in #cider. I don't use emacs so I don't know anything about this.#2020-07-3107:22timrichardthttps://github.com/thheller/shadow-cljs/issues/127 @thheller I am really interested in th is feature. It would make the life for my coworker much easier. I would like to work on it, if you don't mind? Could you point me to the right starting point? 🙂#2020-07-3108:12thheller@timrichardt how so? this really isn't that relevant anymore? it only affects ES6 files in node_modules? why does that affect you?#2020-07-3108:18timrichardtThere are people working on jsx Files. I babel them and then bundle with shadow. Errors inside the babel-output are not source mapped to the original jsx Files. Do you have any idea how to tell the browser the mapping from jsx->js?#2020-07-3108:18thhellerhow do you include them in the project?#2020-07-3108:19timrichardtThey live in a separate folder /src/js along with the .js.map -Files.#2020-07-3108:19thhellerok so you are including via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js ?#2020-07-3108:20timrichardtYep.-#2020-07-3108:20thhellerand the files do have the sourceMappingURL comment?#2020-07-3108:20timrichardtThey do.#2020-07-3108:20thhellerthen source maps should already be working#2020-07-3108:20timrichardtMh, ok.#2020-07-3108:21thhellerI can take a look if you make a reproducible example. I haven't tested this in a long time so maybe its broken.#2020-07-3108:21thhellerbut it isn't what #127 is about so it would be a separate issue#2020-07-3108:22timrichardtI'll do a minimal example.#2020-07-3108:25thhellerI basically only need a .jsx file and its converted form + map#2020-07-3108:36timrichardthttps://github.com/timrichardt/jsx-cljs-template#2020-07-3108:36timrichardtI have included the js and map#2020-07-3109:05thheller@timrichardt I think the problem is that the map file needs to contain the sourcesContent. closure will not find the file otherwise.#2020-07-3109:06thhellerah nvm its already in there#2020-07-3109:07thhelleris it possible to make babel inline the source map into the file?#2020-07-3109:07timrichardtI also saw this warning now.
------ WARNING #1 -  -----------------------------------------------------------
 Resource:
 Failed to resolve sourcemap at Component.js.map: Component.js.map
#2020-07-3109:07timrichardtBabel has this option, let me try.#2020-07-3109:12timrichardtInlining in principle works, but Chrome and Firefox seem to not recognize the source map comment.#2020-07-3109:12timrichardt#2020-07-3109:23thhellerI'll check it out later. can you add the inline option to the repo?#2020-07-3109:26timrichardtOK, i'll do. Thanks anyway.#2020-07-3112:15ghaskins@thheller Do you know if there is a way to use both :handler and :proxy-url with the :dev-http feature? After a quick look at the code, I think the answer is "no" but I wanted to check in case I missed something#2020-07-3112:16ghaskinsultimately what I am after is the ability to define what should be wildcarded to my SPA and what should be forwarded to the proxy#2020-07-3112:17ghaskinsThe follow-up question is: if there is not, would you be interested in a patch that does?#2020-07-3112:31thheller@ghaskins "define what should be wildcarded to my SPA" what does that mean? we are talking about :dev-http, what does the SPA have to do with that?#2020-07-3112:33ghaskinswhat I mean is: i have a backend with different endpoints...lets just say there is an identity provider on /oauth, an api backend on /graphql, and an admin ui at /admin....and /admin is a shadow-cljs compiled SPA#2020-07-3112:33thhellerif you have a backend anyway why not use that directly? I mean why do you need the proxy?#2020-07-3112:33ghaskinswhat id like is to define something like a push handler that says /admin/* should be index.html, anything else should be forwarded#2020-07-3112:34ghaskinsits just during development of the SPA#2020-07-3112:34thhellerwhy do you need the proxy? does it proxy to some remote production server?#2020-07-3112:34thhelleror is your backend running locally anyways?#2020-07-3112:34ghaskinsright, though its a sandbox deployment, but same difference#2020-07-3112:35ghaskinsno, its not local#2020-07-3112:35ghaskinsits running in k8s in aws, except for my ui#2020-07-3112:35ghaskinsthe dev-proxy works great, except for the inability to specify what is a route handled in the spa#2020-07-3112:36thhelleryou are confusing me with your wording#2020-07-3112:36ghaskinssorry#2020-07-3112:36thheller"route handled in the SPA" to me means something handled by the client that never even reaches the server#2020-07-3112:36ghaskinswe have a kubernetes architecture with a bunch of microservices...one type of microservice is a shadow-cljs compiled ui that has an SPA in it#2020-07-3112:37ghaskinsduring develoment, its nice to work on the UI code locally where I want any of the paths that would normally hit the UI backend to be served by dev-proxy, and all others to forward on#2020-07-3112:38ghaskinsthe SPA has kee-frame/reitit routes, so things like /admin/foo/bar are actually served from /admin/app.js#2020-07-3112:38ghaskinsbut everything else needs to forward to the server#2020-07-3112:39thhellerah you are using push state routes and don't want to forward those to the proxy?#2020-07-3112:39thhellerlike the server always give you the same html regardless of what path you ask for?#2020-07-3112:39ghaskinsi think that is correct, though I am unsure of the terminology#2020-07-3112:40ghaskinsright, or really once the /admin/[index.html, app.js] are running, it knows that foo/bar is a route inside the browser#2020-07-3112:41ghaskinswhich works great#2020-07-3112:41ghaskinsbut the problem is if someone tries to navigate to /admin/foo/bar externally, the proxy forwards that to the backend#2020-07-3112:42ghaskinsi.e. it only works if you come in through the front index.html#2020-07-3112:42thhelleryes but you handle that in production too right?#2020-07-3112:43ghaskinsso what I was thinking is something like a push-handler that can be configued in conjunction with :proxy-url, and the push-handler can decide if it should be handled locally or forwarded#2020-07-3112:43ghaskinsyes, prod is fine#2020-07-3112:43ghaskinsonce its in the k8s backend, the routing all works#2020-07-3112:43ghaskinsthis is just when the :dev-proxy is in front during dev#2020-07-3112:46ghaskinsso the first question is: do you already allow this and I missed it? and if you don't, would you be willing to consider a patch for the feature?#2020-07-3112:47ghaskinslooking at the :dev-proxy code, I suspect we can put an undertow handler in front of the LoadBalancingProxyClient in a fairly straight forward way#2020-07-3112:48ghaskinssorry, :dev-http code, i meant#2020-07-3112:51ghaskinswhat im thinking is something that would basically allow this and :proxy-url to both be configured, details TBD#2020-07-3112:51thhellerhmm I'm undecided. usually I recommend running your own server if you need more complicated setups#2020-07-3112:52ghaskinsthats an acceptable response, though I think what i need/suggest is not too far off from what you already offer#2020-07-3112:52thhellerlike how would you want to configure this?#2020-07-3112:53thhellerone person may say that you want to exclude certain paths, another may want to include certain paths#2020-07-3112:53ghaskinsim thinking it would look something like
{...
 :dev-http
 {8000
  {:root "public"
   :handler 
   :proxy-url ""}}}
#2020-07-3112:54thhelleryes but that doesn't work since the proxy always answers#2020-07-3112:54ghaskins> one person may say that you want to exclude certain paths, another may want to include certain paths Yeah, so to that point, the protocol for the :handler would need to allow it to express whether to serve locally or move on to the proxy#2020-07-3112:54ghaskinsim thinking its either a path to a local file (e.g. "index.html" or nil, in which case the proxy is queried#2020-07-3112:55thhellerthe issue is that at the point where the handler is called the http request is in blocking mode and you can't proxy anymore#2020-07-3112:56ghaskinsits been a while since I wrote an undertow backend, but I think one thing that may work is if we add an undertow handler in front of the reverse-proxy#2020-07-3112:56ghaskinssince undertow already has handler chaining, IIRC#2020-07-3112:56thhelleryes you can add a handler to decide which other handler to take next#2020-07-3112:56ghaskinsright#2020-07-3112:56ghaskinsthats what i was thinking was the integration point#2020-07-3112:56thhellerbut how would you configure that?#2020-07-3112:57ghaskinsim thinking its the same :handler spec as above, and if it returns a path, we serve that, and if it doesnt, we move to the next handler#2020-07-3112:58ghaskinsso in my example, I could map "/admin/*" to "index.html", and everything else is nil#2020-07-3112:58ghaskinsor I could code it for the opposite, e.g. "/oauth/* -> nil#2020-07-3112:58thhellerjust trying to figure out how to express this in config without getting too complex#2020-07-3112:58ghaskinswhatever the use case is#2020-07-3112:59thhellersome kind of :proxy-skip #2020-07-3112:59ghaskinsright#2020-07-3112:59thhellerpointing to a (defn should-this-proxy [req] true|false)#2020-07-3113:00thhelleror :proxy-skip [#"^/something" #"^/else"]#2020-07-3113:01ghaskinsright..if we can assume that the non-proxy behavior of shadow.http.push-state/handle is what we want, then the new config really just needs to be a predicate#2020-07-3113:01ghaskinsthats why I was thinking I wouldnt propose a new configuration knob, just allow the :handler to decide#2020-07-3113:02ghaskinsbut id be happy with the above, too#2020-07-3113:02thhellerthe handler can't decide because of how undertow works#2020-07-3113:02ghaskinsah, ok#2020-07-3113:03thhelleras soon as it enters "ring" mode (which the handler is) I switch it to "blocking" mode#2020-07-3113:03thhellerbut proxy only works when its in the async mode#2020-07-3113:03ghaskinslet me check how I did this in protojure#2020-07-3113:03thhellerand as far as I know there is no way to go back to async mode#2020-07-3113:04thhellergranted that worrying about this at all for a dev server is overkill#2020-07-3113:04thhellerbut I still want to do it correctly#2020-07-3113:04ghaskinsi understand completely#2020-07-3113:07ghaskinsso, details TBD, obviously, but this is what I was thinking#2020-07-3113:07ghaskinsas per https://undertow.io/undertow-docs/undertow-docs-2.1.0/index.html#handlers#2020-07-3113:08ghaskinsspecifically "a handler can pick the next handler to invoke based on the current request."#2020-07-3113:08thhelleryes I understand that#2020-07-3113:08ghaskinsin protojure, im currently only installing one handler, just like shadow#2020-07-3113:08ghaskinshttps://github.com/protojure/lib/blob/master/src/protojure/pedestal/core.clj#L300#2020-07-3113:09ghaskinsbut im wondering if I hook it at the Undertow/builder level, if we can get both the :handler and :proxy-url components working together#2020-07-3113:09ghaskinsi get what you are saying about blocking vs async mode#2020-07-3113:09ghaskinsmight have to play around with that#2020-07-3113:10thhelleryeah the way this is built is quite strange but it made sense to me at the time I built it#2020-07-3113:10ghaskinsi also understand that completely, heh#2020-07-3113:12thhellerbasically before the :handler is called it is passing through https://undertow.io/undertow-docs/undertow-docs-2.1.0/index.html#blocking-handler#2020-07-3113:12ghaskinsok, let me understand how you did that part#2020-07-3113:13thhellerbut this breaks when its in blocking mode https://undertow.io/undertow-docs/undertow-docs-2.1.0/index.html#reverse-proxy#2020-07-3113:13ghaskinsi also forget the nuances of the undertow api...i remember there are things that you do that implicitly set the mode#2020-07-3113:13thhellerI think I have an idea how to add what you want without getting too complicated#2020-07-3113:13ghaskinsoh? that would be awesome#2020-07-3113:15thhellerI sort of created a DSL for describing the handler setup#2020-07-3113:15thhellerlooks something like
[:shadow.cljs.devtools.server.dev-http/file-recorder
 {:on-request
  #object[shadow.cljs.devtools.server.dev_http$start_build_server$file_request_fn__19970 0x6fce3691 "shadow.cljs.dev
#2020-07-3113:16ghaskinsah, that probably explains the [::undertow/xx] stuff I saw#2020-07-3113:16ghaskinsi didnt dig into that, but I was curious#2020-07-3113:17thhelleryeah constructing the handlers by hand was quite annoying otherwise#2020-07-3113:18thhellerit probably overkill but it solves the issues I wanted to solve 😛#2020-07-3113:19ghaskinsi get it#2020-07-3113:19ghaskinsvery clever#2020-07-3113:21ghaskinsits not quite clear to me what I need to do to express this in the DSL though...guidance appreciated#2020-07-3113:22thhelleryou can't express it in the DSL#2020-07-3113:22ghaskinsah, sorry...misunderstood#2020-07-3113:22thhellerproblem is that the "next" logic of the proxy handler requires this returning null#2020-07-3113:22thhellerhttps://github.com/undertow-io/undertow/blob/cc993bcad219f449f452ac3a36021398d3cc48f1/core/src/main/java/io/undertow/server/handlers/proxy/ProxyHandler.java#L177#2020-07-3113:23thhellerbut it never does#2020-07-3113:23thhellerhttps://github.com/undertow-io/undertow/blob/8d911b58acfc74caa3dc0f00b216dd78d4b8f76c/core/src/main/java/io/undertow/server/handlers/proxy/LoadBalancingProxyClient.java#L254#2020-07-3113:23thhellerbut I guess I can subclass that proxy client and have that return null whenever the clojure fn returns false#2020-07-3113:23ghaskinsthat sounds reasonable#2020-07-3113:24thhelleror just leave all that alone and add a regular handler instead#2020-07-3113:24thhellerprobably simpler .. especially since subclassing in clojure is annoying#2020-07-3113:24ghaskinsyeah...#2020-07-3113:26ghaskinsthe handlers are a simple reify, so probably easier than a full gen-class#2020-07-3113:32ghaskinsthough the 'next' concept seems to be only in the deprecated constructors#2020-07-3113:33ghaskinsmaybe they've changed the way the chaining works#2020-07-3113:36Audriusplease help me debug my build configuration:
:builds       {:app {:target     :npm-module
                      :output-dir "node_modules/shadow-cljs"}}}
gives me such error:
[:app] Configuring build.
[:app] Build failure:
Invalid configuration
-- Spec failed --------------------

  {:target :npm-module,
   :output-dir "node_modules/shadow-cljs",
   :build-id :app}

should contain key: :entries

| key      | spec            |
|==========+=================|
| :entries | (coll-of        |
|          |  simple-symbol? |
|          |  :distinct      |
|          |  true           |
|          |  :min-count     |
|          |  1              |
|          |  :kind          |
|          |  vector?)       |

-- Relevant specs -------

:shadow.build.targets.npm-module/target:
  (clojure.spec.alpha/keys
   :req-un
   [:shadow.build.targets.shared/output-dir
    :shadow.build.targets.npm-module/entries]
   :opt-un
   [:shadow.build.targets.npm-module/runtime
    :shadow.build.targets.shared/devtools])
:shadow.build.config/build+target:
  (clojure.spec.alpha/and
   :shadow.build.config/build
   (clojure.spec.alpha/multi-spec
    shadow.build.config/target-spec
    :target))

-------------------------
Detected 1 error
#2020-07-3113:38Audriusaltho
{:frontend
                 {:target :browser
                  :modules {:main {:init-fn }}
                  }}
does not contain :entries but does not throw the same error.
#2020-07-3113:41thheller:target :browser has different config that :target :npm-module#2020-07-3113:42thhellerfor :target :npm-module you need to specify :entries [at-least-one.of-your.namespaces]#2020-07-3113:42thhellerbasically you need to configure which namespaces you want to have available from JS#2020-07-3113:44Audrius@thheller how do I choose which ns to add?#2020-07-3113:46thhellerwhichever you want to have available from JS?#2020-07-3113:46thhellerwhy are you using :npm-module in the first place?#2020-07-3113:47Audriusthis is from react native app#2020-07-3113:48thhellerreact-native should be using :target :react-native and not :npm-module#2020-07-3113:58ghaskinsI think I get the gist of your DSL now#2020-07-3114:24ghaskins@thheller im struggling to see where you serve the local-files in front of the proxy from#2020-07-3114:25ghaskinsoh, i think i see it now#2020-07-3114:28thhellersee :shadow.undertow/file in the DSL example from above#2020-07-3114:29ghaskinsyep, i see it now#2020-07-3114:29ghaskinsty#2020-07-3114:29thhellerit checks if the file exists and calls the next handler if it does not#2020-07-3114:47thheller@ghaskins https://github.com/thheller/shadow-cljs/commit/0e1d8f86921c69745b68c8e127dc78af19167f05#2020-07-3114:47thhellerwill make a release in a bit, just want to look at something else first#2020-07-3114:50ghaskinsthere are some cases where it may be easier to whitelist or blacklist what should be proxied, so I wonder if a predicate-fn is more flexible#2020-07-3114:52ghaskinsfor example, I have two UIs, one at /foo and another at the default / page, so the exclude works well for the former but not the latter...but a simple predicate-fn would work for both#2020-07-3114:54ghaskinsso what im thinking is, maybe :proxy-pushstate-predicate returns true means invoke the :handler, false means invoke the proxy#2020-07-3114:55ghaskinsthoughts?#2020-07-3114:56ghaskinsand there could be a default pushstate-predicate that handles exclude/include options, if we wanted#2020-07-3115:27Saikyunis it possible to get the absolute path of a file (alternatively relative path + project directory)? in vanilla cljs cljs.analyzer/*cljs-file* does the trick, but with shadow-cljs I only seem to get the part of the path after the source directory#2020-07-3115:28Saikyune.g. "hello_world/other.cljs" rather than "/Users/.../src/hello_world/other.cljs"#2020-07-3117:39thheller@saikyun what for? and what would it report for files from libraries in .jar files?#2020-07-3119:50adamrenklintI’m trying to use the :target :bootstrap feature in Shadow and am running into trouble with macros. The :entries vector of my bootstrap build contains instaparse.core, and the build fails with:
The required namespace "instaparse.macros" is not available, it was required by "instaparse/core$macros.cljc".
"instaparse/macros.clj" was found on the classpath. Maybe this library only supports CLJ?
Tried patching the problem by copying https://github.com/Engelberg/instaparse/blob/master/src/instaparse/macros.clj into my src folder, but named macros.cljc (thanks for the ability to quickly add custom implementations of arbitrary namespaces, btw). This solved that particular problem, but another similar error pops up:
The required namespace "" is not available, it was required by "cljs/repl$macros.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
I feel like I must be holding this tool wrong, as the same code and namespaces can be used to generate an analyzer cache with my own old solution, which generated a node script with Boot and simply executed it. Any tips where I should look next?
#2020-07-3119:54thheller@adamrenklint the most likely explanation is that the library just doesn't support self-hosted use. especially if it imports namespaces like http://clojure.java.io#2020-07-3119:58adamrenklintThat’s the weird thing, I have created this analyzer cache before, and it definitely included Instaparse, but it was all done with Boot and is horribly slow to develop with, so I want to use Shadow instead.#2020-07-3119:59adamrenklintBut maybe you can explain the first error. Why is importing macros implemented using CLJ instead of CLJC throwing an error? The namespace is obviously there, the error message even states it.#2020-07-3120:06thhellerI can't explain it sorry. It has been several years since I looked at and implemented this stuff and I cannot remember the fine details#2020-07-3120:16thhellerthere is a secondary pass that does the macro compilation#2020-07-3120:16thhellermaybe you just need to exclude some#2020-07-3120:21thhellerI honestly cannot remember any of this 😞 self-hosted confuses me when it comes to macros#2020-07-3122:09thheller@ghaskins 2.10.19 lets you specify :proxy-predicate some.ns/some-fn. should be (defn some-fn [ex config] true|false) where ex is the undertow HttpServerExchange (eg. (.getRequestURI ex) to get request path) and config is the :dev-http config map#2020-07-3122:09thhellershould return true if the request should go to the proxy and false if the handler should be taken instead#2020-07-3122:11thheller@timrichardt I looked over the source map issue but I can't figure out how to make it work#2020-07-3122:15ghaskinsTy @thheller#2020-07-3123:06Björn EbbinghausDoes anyone have a clue why I am getting DOMException: Failed to construct 'WebSocket': The URL 'ws://:8237/chsk?... Exceptions in my console, when I install a service worker? Everything works fine as far as I can see. Live reloading is working..#2020-07-3123:13thhellerno clue. looks like you are trying to connection to ws without a host?#2020-08-0108:41Björn EbbinghausThis only happens when a service worker is installed. I am playing around with them for the first time.#2020-08-0220:33thhelleris the websocket in the service worker the one trying to create the connection? maybe you are using document.location or something which isn't present in service workers?#2020-08-0105:24steveb8nQ: I’m running a shadow-cljs browser app inside Salesforce. Using one type of integration it loads/works great. Using another I get “shadow-cljs - failed to load 34” in the console. I can see from the generated js that this is loading the npm pdfjs module. Unfortunately that is where the trail ends for me. I can’t work out why it won’t load even when I use the debugger in the fn that calls shadow.provide for that dep - it never seems to invoke that fn#2020-08-0105:25steveb8neven stranger is that in the first type of integration, it never calls that provide fn either but the app works ok#2020-08-0105:25steveb8nis there a way of looking deeper into these kinds of load errors?#2020-08-0105:26steveb8nFYI: the integration that works is a Lightning Component and the one that fails is a Lightning Web Component. That doesn’t mean anything to cljs devs but I mention it for completeness#2020-08-0105:36steveb8nHmm: I was able to catch an error in the browser debugger “”Cannot assign to read only property ‘URL’ of object ‘[object Object]’“”#2020-08-0105:36steveb8nI suspect the Salesforce browser security is suppressing something needed by shadow when loading the pdfjs dep#2020-08-0106:50steveb8nI’ve found the culprit https://github.com/mozilla/pdf.js/blob/15087c35d164a4152b21adde908b4d7619897bb3/src/shared/compatibility.js#L264#2020-08-0106:50steveb8nbut I can’t figure out how to stop it from calling this code…#2020-08-0108:26thhellerdoesn't look like you can stop it. at least I see no flags or anything to do so.#2020-08-0109:23steveb8nYeah, I think you are right. Seems like some webpack trickery. I have way around it I can try. Thx#2020-08-0105:47timrichardt@thheller Thx! Anyway, I'll let you know, when I figured something out.#2020-08-0109:00Saikyun@thheller re: absolute cljs source path -- I'm transforming source code at the bottom of my namespace (so it runs whenever the namespace is loaded). it's only used for source I'm working on myself. an alternative way of getting the source code would be fine as well 🙂#2020-08-0109:04thhellerso you just want to slurp the file?#2020-08-0109:04Saikyunyup#2020-08-0109:05thhellerslurp with (io/resource the-file) should do it#2020-08-0109:12Saikyunwhere the-file is a relative path?#2020-08-0109:19Saikyunthat seemed to do it, thanks!#2020-08-0112:41adamrenklintQ: is the compiler option :dump-core (https://cljs.github.io/api/compiler-options/dump-core) not supported in Shadow CLJS? It’s not listed in https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options as either supported or not, and it seems the option is not forwarded to the compiler. Is this intentional? Can I affect this through my build settings somehow?#2020-08-0112:50adamrenklintFound the answer in https://clojurians-log.clojureverse.org/shadow-cljs/2019-07-07, that this compiler flag is not supported, and we’re supposed to use :target :bootstrap, which doesn’t seem to work (https://clojurians.slack.com/archives/C6N245JGG/p1596225051349100).#2020-08-0113:19thheller:target :bootstrap works just fine. just some namespaces seem to cause problems. you don't have to precompile them though either. :dump-core wouldn't do that either.#2020-08-0113:20thhelleryou can just use :entries [cljs.core] which would be equiv to :dump-core#2020-08-0216:51genekim@thheller PS: browser test runner in shadow-cljs is amazing. I’m eventually going to have to figure out how to port over old karma tests, but wow, got browser tests running in less than 10 minutes. Thank you!!! (I never got browser tests running prior to switching to shadow-cljs!)#2020-08-0303:29CrispinHi. Does anyone know of a good leining starting project template that combines lein + jvm web server + shadow-cls client build? (hopefully without too much extra baggage, would like websocket support (so not jetty), but would like client side to not have any deps (like no reagent for example))?#2020-08-0307:03robert-stuttafordyou'll learn a tremendous amount of permanently useful and valuable stuff by piecing this together yourself 🙂#2020-08-0307:04robert-stuttafordto answer your question directly, i'm not aware of one that does these things specifically. you might try for sente + shadow-cljs ?#2020-08-1317:01sergey.shvetsCheck https://luminusweb.com/. But I woud advice to setup a separate build for shadow-cljs instead of managing deps in leiningen.#2020-08-0303:32Crispinoh, I also use cider, so something that supports cider-jack-in-clj&cljs would be great!#2020-08-0307:02robert-stuttafordis there a way to force a config reload + rebuild from inside the clj/cljs repls provided by shadow?#2020-08-0308:05steveb8nare you using a watch? if so, you can touch the shadow-cljs.edn and it will rebuild everything#2020-08-0308:06steveb8notherwise shadow.cljs.devtools.api/compile! should do it
#2020-08-0308:20thhellerbuild config reloads should be automatic already#2020-08-0308:20thhellerotherwise there is a shadow.cljs.devtools.api/watch-compile! and shadow.cljs.devtools.api/watch-compile-all! to force building a running watch. which however won't reload any config since that should be automatic?#2020-08-0309:08Saikyun@thheller wrt: slurping source -- I've tried the solution you suggested: > slurp with `(io/resource the-file)` should it seems though that sometimes when this code is run during initial compilation (e.g. when running shadow-cljs watch app), it can't find the file.#2020-08-0309:11thhellerwhat are you slurping?#2020-08-0309:12Saikyun(slurp (io/resource ana/*cljs-file*))#2020-08-0309:13thhelleryes but which file?#2020-08-0309:15thhellerI mean it won't work in the REPL since that has no file#2020-08-0309:15Saikyunnah, not in the repl#2020-08-0309:15Saikyunhttps://pastebin.com/37LBw1kN#2020-08-0309:15thhellerbut other than that all files should exist#2020-08-0309:15Saikyun
(defmacro run-tests!
          []
          (read-string (str "(do " (rewrite/rewrite-without-non-comment-blocks-cljs (slurp (io/resource ana/*cljs-file*))) ")"))))
#2020-08-0309:17Saikyunhm, now that I think about it, I might have a clue.#2020-08-0309:18thhellerlooks like you should revise your macro setup. :refer-macros is sooo outdated https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-08-0309:19Saikyunokay, thanks for the link#2020-08-0309:19thhellerotherwise looks file#2020-08-0309:19thhellerwell its missing some quoting which the macro is supposed to do#2020-08-0309:19SaikyunI found that the error originated from the same run-tests! that is run in clj-mode. so it had nothing with cljs-file to do#2020-08-0309:22Saikyunor to put it in a different way, I needed to use (io/resource *file*) in the clj macro 🙂 rather than just *file*#2020-08-0309:23Saikyunwrt quoting, it's on purpose, in order to put the forms from read-string into the place the macro is run#2020-08-0309:24Saikyuniiuc I can't run read-string if I quote it, right?#2020-08-0309:29thheller
`(do ~(read-string ...))
#2020-08-0309:30thhellerwell that doesn't change much I guess#2020-08-0309:42Saikyunah, right#2020-08-0309:42Saikyunwhy not 🙂#2020-08-0309:45Saikyunhm, strangely enough it didn't work if I did (do ~(read-string ...))`#2020-08-0309:46Saikyunoh now I remember#2020-08-0309:46Saikyunit's because read-string only reads one form#2020-08-0309:46Saikyunwhile the code can contain multiple forms#2020-08-0309:46Saikyunso that's why I did the str solution#2020-08-0313:10Saikyunthanks again for the link about macros. didn't know you could refer to macros like that 🙂#2020-08-0315:58ghaskins@thheller the proxy-predicate feature works nicely, ty#2020-08-0407:26robert-stuttafordcurious @thheller -- if somehow a module ended up having exactly the same code in it between two builds, will the resultant js cache between builds as well? or does shadow/cljs/gclosure do something to prevent it from being the same bytes/etag/whatever#2020-08-0407:31thheller@robert-stuttaford it is somewhat unlikely for modules to be compatible between builds. it can happen but I wouldn't rely on it.#2020-08-0407:32robert-stuttafordthought as much; just thought i'd confirm it with you#2020-08-0407:32robert-stuttafordwell done on modules, by the way. it's fantastic#2020-08-0407:33thhellergiven hot macros work with (gensym) and foo# they may be using different names in each build, which then may get different names in :advanced and so on#2020-08-0407:33thheller:modules is why all this exists in the first place 😉#2020-08-0407:33robert-stuttaford😁#2020-08-0408:13EmmanuelOgasup! is there any guidance around using node 12 vs 14?#2020-08-0408:14EmmanuelOgashadow docs just say "(v6.0.0+, most recent version preferred)"#2020-08-0408:16thhellerany issues with either? it pretty much shouldn't matter at all?#2020-08-0408:19EmmanuelOgawell.... hahah yeah there are issues on my system, but who knows may be completely unrelated. I installed nodejs with scoop on windows then copy the shadow-cljs.edn file from the front page of shadow site, then npm install sahdow, etc... I just get a single error "? ? is not ISeqable", so kind of those impenetrable messages that don't really tell you much. So I began wondering if the node version mattered. Anyway, I removed the scoop node and I'm trying the official installer see if it makes any difference#2020-08-0408:19EmmanuelOgaI suspect is more of a problem of how my system is configured more than any shadow issue, but yeah I was wondering if 12 v 14 made any difference#2020-08-0408:20thhellernode does not make a difference regarding shadow-cljs#2020-08-0408:20thhellerit may make a difference for the code you are running on it#2020-08-0408:21thhellerits not that impenetrable error message wise#2020-08-0408:22EmmanuelOgathis is what I saw:#2020-08-0408:22EmmanuelOga#2020-08-0408:22EmmanuelOgaalso found it suspicious that shadow had those "..." instead of actual help#2020-08-0408:22thhellerI guess I never tried to handle a typo?#2020-08-0408:24EmmanuelOgathe command line help typo is not the actual problem I think#2020-08-0408:24EmmanuelOgahere's a better example:#2020-08-0408:24EmmanuelOga#2020-08-0408:26thhellerthats odd indeed. I'd guess that there are maybe some invalid "hidden" chars in the config?#2020-08-0408:27EmmanuelOgahmmm yeah, let me try delete the file and try copy-paste again from the front page#2020-08-0408:27thhellerthere was a command to easily show such things but I can't remember what it was#2020-08-0408:28thhellerif you send me the actual file I can check it out#2020-08-0408:28thhellerand maybe improve the error message in the process#2020-08-0408:29EmmanuelOganoooo just deleted it, yeah that was the problem, I think the file had the wrong encoding. So nothing to do with the nodejs scoop installed#2020-08-0408:29EmmanuelOgamaybe I can replicate that file... let me try#2020-08-0408:30EmmanuelOgaTF I think my emacs is loosing it#2020-08-0408:30EmmanuelOga#2020-08-0408:30EmmanuelOgahaha#2020-08-0408:31EmmanuelOgaok cool, there's something wrong with my emacs. I could replicate the file.#2020-08-0408:31thhellerplease send to <mailto:/cdn-cgi/l/email-protection|/cdn-cgi/l/email-protection>#2020-08-0408:33EmmanuelOgasent!#2020-08-0408:35thheller
$ cat shadow-cljs.edn
��{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:main {:init-fn app.main/main!}}}}}
#2020-08-0408:36thhellerthx. can reproduce the error, will try to improve it 😛#2020-08-0408:37EmmanuelOgathx! was really jarring, although it was my mistake, I'm sure it can help other ppl too#2020-08-0408:51Audriushow you run re-frisk on react native? 🤔#2020-08-0408:55EmmanuelOgaI know nothing on the subject but it seems like the readme has some info: https://github.com/flexsurfer/re-frisk#react-native-electron-or-web-applications#2020-08-0410:40thheller@stebokas I think you better ask those questions in #react-native.#2020-08-0412:18Mikko HarjuI'm experiencing some weird issues with classpath override.. We basically have overridden a library with our own patches in src that shadow-cljs has previously used instead of the sources from the library. Now I'm getting:
[2020-08-04 14:47:11.441 - INFO] duplicate resource graphql_builder/generators/shared.cljc on classpath, using file:/Users/harri/.gitlibs/libs/floatingpointio/graphql-builder/7e8311225d5595e4456b8fd6338b127a80b7aab6/src/graphql_builder/generators/shared.cljc over file:/Users/harri/Development/hesburger/core-client/src/graphql_builder/generators/shared.cljc
for each of the overridden files, and they are not patched. This is only affecting 1 machine out of 4 working ones.
#2020-08-0412:18Mikko HarjuI'm experiencing some weird issues with classpath override.. We basically have overridden a library with our own patches in src that shadow-cljs has previously used instead of the sources from the library. Now I'm getting:
[2020-08-04 14:47:11.441 - INFO] duplicate resource graphql_builder/generators/shared.cljc on classpath, using file:/Users/harri/.gitlibs/libs/floatingpointio/graphql-builder/7e8311225d5595e4456b8fd6338b127a80b7aab6/src/graphql_builder/generators/shared.cljc over file:/Users/harri/Development/hesburger/core-client/src/graphql_builder/generators/shared.cljc
for each of the overridden files, and they are not patched. This is only affecting 1 machine out of 4 working ones.
#2020-08-0412:26Mikko HarjuWe are not getting this INFO notice in our other dev machines.#2020-08-0412:39Mikko Harjuclj -Spath returns a proper classpath, but it is in a different order#2020-08-0412:45Mikko Harjumy machine for instance, has src:test:.... and in the failing machine, they are somewhere in the middle#2020-08-0412:51thhellermaybe different tools.deps versions?#2020-08-0412:59Mikko HarjuNope. 1.3.2 in all machines...#2020-08-0412:59Mikko HarjuI removed .cpcache and other suspects as well, but still it produces them in a different order.#2020-08-0413:00Mikko HarjuI am so baffled by this. What can it be 😄#2020-08-0413:03Mikko HarjuOh... clojure got an update when I upgraded it from homebrew...#2020-08-0413:04Mikko Harjudepends in openjdk14 and all that... maybe this is the root cause?#2020-08-0413:09Mikko HarjuNope. Still works on my machine 😞#2020-08-0413:12Mikko HarjuNow the classpath is "messed up" similarly on my machine as well but it does not produce that error on conflict#2020-08-0413:34thhellerno clue. if you use deps.edn then that is solely responsible for constructing the classpath and nothing shadow-cljs does affects that#2020-08-0413:39Mikko HarjuThis is just one of those days...#2020-08-0413:48Mikko HarjuI just removed the updates we had made, and put them to a new branch in our fork and refer to that new SHA in deps.edn. Now it works, but if we want to use that feature again this will have to be revisited...#2020-08-0412:40kommenis there a way to dissoc build options via the :`config-merge` option? use case: for the release build, we have set up ns-aliases. but for a specific release build, I want to remove one of those ns-aliases#2020-08-0412:50thheller@kommen there is not currently#2020-08-0413:02kommenok, thanks#2020-08-0413:02kommenwill look for another solution then#2020-08-1307:19kommenfwiw: I’m now using a build hook for the :configure stage to bend the configuration of the release build to my will. the hooks really provide a lot of flexibility @thheller, very nice!#2020-08-0419:46awb99I just upgraded shadow-cljs from nashorn-js to graal-js and now I am getting problems in the compiled bundles. Compilation works, but vega npm dependencies cannot load when used in in transient project. this is the package that was making problems with polyfills (buffer / process) before. Is there any change in regards to this with the graal versions?#2020-08-0419:46awb99shadow-cljs - failed to load 131 main.js:10793:82 shadow-cljs - failed to load 133 main.js:10793:82#2020-08-0419:46awb99ypeError: $jscomp.arrayFromIterable is not a functionhttp://localhost:9000/r/main.js     shadow$provide[131]/< http://localhost:9000/r/main.js:5067     shadow$provide[131]/< http://localhost:9000/r/main.js:4742     131 http://localhost:9000/r/main.js:4742     jsRequire http://localhost:9000/r/main.js:10793     shadow$provide[133]/< http://localhost:9000/r/main.js:5313     133 http://localhost:9000/r/main.js:5313     jsRequire http://localhost:9000/r/main.js:10793     require http://localhost:9000/r/main.js:10793     <anonymous> http://localhost:9000/r/main.js:18601     <anonymous> http://localhost:9000/r/main.js:19942#2020-08-0419:50awb99It works in my project where I use shadow dev server#2020-08-0419:50awb99but when I use jetty it does not work#2020-08-0419:50awb99I have two projects: gorilla-ui#2020-08-0419:51awb99which uses vega modules and shadow dev server#2020-08-0419:51awb99and notebook-ui which uses gorilla-ui#2020-08-0419:51awb99and uses jetty.#2020-08-0419:51thhellerlooks like a polyfill issue. not sure why you are suspecting graal-js#2020-08-0419:52thhellerjetty also isn't relevant#2020-08-0419:52awb99I juess the issue is elated to either transient dependencies that use vega, OR jetty vs shadow dev server#2020-08-0419:52awb99I had it working.#2020-08-0419:52awb99and I only updated to new shadow version.#2020-08-0419:52thhellerok .. start with that next time 😛#2020-08-0419:53awb99what is the best pproach?#2020-08-0419:53thhellerthis is :target :browser?#2020-08-0419:53awb99add buffer and process to deps.cljs ?#2020-08-0419:53awb99yes#2020-08-0419:53awb99target browser#2020-08-0419:53thhelleras long as you have shadow-cljs installed IN THE PROJECT#2020-08-0419:53thhelleryou do not need to worry about process or buffer at all#2020-08-0419:54thhelleryou can fix this easily by bumping :compiler-options {:output-feature-set :es6} or whatever language level is appropriate#2020-08-0419:54thheller:es8 is good if you have bunch of async/await code in libs#2020-08-0419:56awb99testing...#2020-08-0419:56awb99many thanks!#2020-08-0419:56awb99Your new version works like charm BTW!#2020-08-0419:56awb99It feels 5x faster#2020-08-0419:57awb99I LOVE it!#2020-08-0419:59awb99Thank you so much for your work!#2020-08-0420:00awb99I honestly have no idea how you do it!#2020-08-0420:00awb99New versions all the time#2020-08-0420:00awb99plus new features#2020-08-0420:00awb99I have only one explaination you must be an alien!#2020-08-0420:00awb99hahaha#2020-08-0420:03awb99compiler optionsdoes not fix it.#2020-08-0420:04awb99I guess I have to remove all buffer and process dependencies in all parent projects...#2020-08-0420:04awb99This will take a while...#2020-08-0420:11awb99shadow-cljs - watching build :webly [:webly] Configuring build. [:webly] Compiling ... [:webly] Build failure: The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js". Dependency Trace: demo/app.cljs pinkgorilla/ui/default_renderer.cljs pinkgorilla/ui/data/vega.cljs node_modules/vega-embed/build/vega-embed.js node_modules/vega/build/vega-node.js node_modules/vega-dataflow/build/vega-dataflow.js node_modules/vega-loader/build/vega-loader.js Searched for npm packages in: /home/andreas/Documents/gorilla/gorilla-ui/node_modules See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install#2020-08-0420:11awb99Now I have compile errors#2020-08-0420:11awb99before I had runtime error#2020-08-0420:17awb99{:lein {:profile "+demo"}, :dev-http {9000 {:handler https://demo.app/handler}}, :http {:port 9001, :host "localhost"}, :nrepl {:port 9002}, :builds {:webly {:target :browser, :output-dir "target/webly/public", :asset-path "/r", :modules {:main {:entries [https://demo.app]}}, :compiler-options {:optimizations :simple :output-feature-set :es8 }}, :ci {:target :karma, :output-to "target/ci.js", :ns-regexp "-test$"}}}#2020-08-0420:18awb99I have removed .shadow-cljs , node-modules and target#2020-08-0420:18awb99to be sure that I am starting from a clean slate#2020-08-0420:24awb99so only :output-feature set without package.json including shadow-cljs does NOT work.#2020-08-0420:29thhellernever said that it should#2020-08-0420:29thhellerinstalling shadow-cljs in the project ensures that all node polyfills are available so it should always be done#2020-08-0420:30thhellernew version should even be warning when its not#2020-08-0420:31awb99so what is the difference with output-feature set ?#2020-08-0420:31awb99Perhaps this feedback is helpful to you:#2020-08-0420:31awb99I struggled in understanding shadow-cljsjs and shadow-cljs#2020-08-0420:32awb99with some learning I remember why I need cljsjs#2020-08-0420:32awb99But when I update dependencies#2020-08-0420:32awb99whn I update shadow-cljs dependency version,#2020-08-0420:32awb99it is VERY easy to forget that I have to update shadow-cljs not only in project.clj but also in package.json.#2020-08-0420:32awb99I think this is a potential problem#2020-08-0420:32awb99because it is not easy to see it.#2020-08-0420:37thhellerwell its your choice to use project.clj not mine#2020-08-0420:38thhellerits also not super critical to keep the versions in sync. the package.json version can stay older usually, just need to have it at all.#2020-08-0420:39thheller:output-feature-set controls which JS features are transpiled away#2020-08-0420:40awb99the other problem is,#2020-08-0420:40thhellerthe higher version you set the more modern browser is required to run it#2020-08-0420:40thhellerwhereas "modern" is something like 3 years old ...#2020-08-0420:41awb99when I update deps.cljs to "shadow-cljs" "^2.10.19"#2020-08-0420:41awb99then in projects that depend on this project#2020-08-0420:41awb99they will not update the package.jsn to the new version#2020-08-0420:41thhellerdeps.cljs has nothing to do with this and shadow-cljs should *NEVER* be in there#2020-08-0420:42awb99why not?#2020-08-0420:42thhellerI actually mean never. I may make it a hard error if it finds it in there.#2020-08-0420:42thhellerthats like saying clojure depends on leiningen#2020-08-0420:42awb99otherwise transitive dependencies do not flow throygh#2020-08-0420:43awb99it is a little different for my usecase#2020-08-0420:43thhellerno it isn't#2020-08-0420:43awb99I need to make it easy for notebook users to add their cljs / npm deps to the notebook#2020-08-0420:43thhellershadow-cljs is not a transitive dependency#2020-08-0420:45thhellerI'm not joking here. I will add a check that deps.cljs does not contain shadow-cljs if I find that becoming a thing.#2020-08-0420:48awb99ok#2020-08-0420:49awb99I would like to manage the npm deps only via deps.cljs#2020-08-0420:49awb99The whole thing of maven + npm#2020-08-0420:49awb99is already complicated enough.#2020-08-0420:50thhelleryes I understand that but deps.cljs is not the place to do this for shadow-cljs#2020-08-0420:50awb99And in deps.edn I can add comments (a HUGE plus)#2020-08-0420:50thhellerjust run npm install shadow-cljs when the notebook CLJ launches or whatever#2020-08-0420:50thheller(if not already in package.json)#2020-08-0420:53awb99thanks for making this clear!#2020-08-0420:53awb99https://github.com/pink-gorilla/gorilla-ui/commit/54f63feed681d1c0ab295eed6edbe825f45dfccc#2020-08-0420:54awb99your order has been obeyed 🙂#2020-08-0421:24bennyTrying to test my project and I’m getting the following, any suggestions where to look?
❯ shadow-cljs compile test
shadow-cljs - config: /Users/benny/projects/client/shadow-cljs.edn
shadow-cljs - connected to server
[:test] Compiling ...
========= Running Tests =======================
SHADOW import error /Users/benny/projects/client/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$$react_navigation$native.js
/Users/benny/projects/client/node_modules/react-native/index.js:13
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1047:16)
    at Module._compile (internal/modules/cjs/loader.js:1097:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/benny/projects/client/node_modules/@react-navigation/native/lib/commonjs/useBackButton.tsx:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
===============================================
[:test] Build completed. (164 files, 163 compiled, 0 warnings, 7.45s)
#2020-08-0421:26thhelleryou cannot import regular react-native packages without running through metro#2020-08-0421:27thhelleronly the :target :react-native works for react-native#2020-08-0421:27thhellerno clue what to do testing with react-native#2020-08-0421:28bennyouch#2020-08-0421:28bennyok, so just to clarify, there’s no known way to test react native with shadow?#2020-08-0422:11thhellerI don't know any. I'm sure there are but I don't use react-native so I have no clue how testing works there#2020-08-0422:12thhellerwhatever works with other tools will also work with shadow-cljs#2020-08-0422:12bennyi’ll check over in #cljsrn thanks @thheller#2020-08-0422:20bennyis there a way to break out the tested code so to ignore the rn-specific code during test execution?#2020-08-0422:21bennyone way would be to use a different source root for tests, but afaik you can only set the source root at the project root which breaks that theory#2020-08-0422:21thhellerdon't know what you mean#2020-08-0422:22bennyif i just want to test re-frame code for example, is there a way i could make my test target compile and test just that code?#2020-08-0422:22thhellerthat depends on your code#2020-08-0422:23thhellerif its all in namespaces that don't otherwise use react-native stuff then sure#2020-08-0422:23bennyhow would i configure shadow to look only at those namespaces though?#2020-08-0422:24bennythis isn’t legal:
:test
          {:target    :node-test
           :source-paths ["src/client/re-frame" "test"]
           :output-to "out/node-tests.js"
           :autorun   true}
#2020-08-0422:25thhellersource-paths are not relevant for what you are trying to do#2020-08-0422:25thhellershadow-cljs ONLY includes files that are directly referenced somewhere#2020-08-0422:25thhellerit doesn't matter if files are other files on the classpath#2020-08-0422:25thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2020-08-0422:27bennythen when i run shadow-cljs compile test why does it try to compile the react native specific code if i’m not referencing it in my test sources?#2020-08-0422:28thhellertest defaults to including namespaces that end in -test#2020-08-0422:28thhellerso if any of those (or those they require) require react-native stuff it will end up including it#2020-08-0422:42bennythat’s pretty great, something somewhere is pulling in native code, but i will figure out what, it’s great to know it’ll only get pulled in if it’s referenced!#2020-08-0506:38rbergerI’m trying to import IconContext for react-icons I’ve been able to import the actual icons ok, but I need to import IconContext for changing the Icon’s attributes. I’ve tried:
["react-icons" :default IconContext]
["react-icons" :refer (IconContext)]
["react-icons" :as IconContext] # I know that one shouldn't work but tried anyway
And I always get:
[:app] Build failure:
package in /Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-iconsspecified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["lib"], :package-dir #object[java.io.File 0x627fddf1 "/Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-icons"]}
ExceptionInfo: package in /Users/rberger/omnyway/visx/visx-shopper-app/node_modules/react-iconsspecified entries but they were all missing
Any idea what I’m doing wrong? The Original react-icons doc for the import is at: https://github.com/react-icons/react-icons#configuration
#2020-08-0508:37thheller@rberger hmm try "react-icons/lib/cjs/index.js" for now. the package seems to be bundled rather strangely#2020-08-0508:40awb99Hi @thheller I observed the following behavior: deps.cljs file in src/ works (= dependencies are added to package.json). deps.cljs in src/pinkgorilla -> does not work (dependencies not added to package.json). I am not sure if this is intentionally or not.#2020-08-0508:41thhellerdeps.cljs must always be in the "root" of the classpath. it does not work anywhere else.#2020-08-0508:41awb99I think a warning might make sense here.#2020-08-0508:42awb99Mot ides now collapse multiple folders into one line.#2020-08-0508:42awb99And there is not really any way to tell if the resource has been placed correctly or not.#2020-08-0508:43awb99I dont care anymore for my project, as I have he location correct.#2020-08-0508:43awb99But I think this is a potential to other people that is pretty much impossible to see.#2020-08-0508:44awb99And I guess it just needs a regex to detect.#2020-08-0508:44awb99A you must be scanning all resources anyhow in some way.#2020-08-0508:44awb99Just my feedback as a user...#2020-08-0508:44awb99🙂#2020-08-0508:46thhellernot interested. pinkgorilla.deps would be a completely ok namespace and checking every possible deps.cljs file whether its an actual ns or not is not practical.#2020-08-0510:59superstructor@thheller NPM deps that are already in package.json get filtered out by https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/npm_deps.clj#L222 Or in other words, if all the deps that shadow-cljs is responsible for are already in package.json shadow-cljs does not run any npm install command at all ? Does that mean that the intended behaviour is that its a user's responsibility to run npm install prior to shadow-cljs manually or via another build tool ?#2020-08-0511:56thheller@superstructor the intention is that users manage their own packages yes. shadow-cljs is not a package manager.#2020-08-0512:03superstructorok thanks @thheller 👍#2020-08-0513:03dimaHello, how to make js/URL to be resolved to custom class (like URL from react-native-url-polyfill) ? Or in general, how to change global var like js/window or js/document ?#2020-08-0513:06dimaI’m trying to use this in config
:js-options {:resolve {"react-native-url-polyfill" {:target :global
                                                                       :global "URL"}}}
#2020-08-0513:07dimaBut it doesn’t seem to work#2020-08-0519:44thhellernothing can affect what js/URL resolves to. it literally means use the global URL object, whatever that may be.#2020-08-0519:44thhellerjust don't use js/URL if you want to change it?#2020-08-0521:43dimaThere is other code relying on URL to be globally available and I cannot change that code, but would like to provide my own URL implementation#2020-08-0522:41thhellerah. you can do (js/goog.exportSymbol "URL" whatever-it-should-be) in a namespace that is loaded before the one using it#2020-08-0607:32dimathanks, that seems what it needs!#2020-08-0602:18royalaidHey @thheller running into some weirdness with when trying to import a javascript file that itself has an import and CLJS is throwing back at me saying that Requested module does not have an export "initSchema".#2020-08-0602:18royalaidThe code in question in src/models/index.js#2020-08-0602:18royalaidimport { initSchema } from '@aws-amplify/datastore';#2020-08-0602:18royalaidand then in another file#2020-08-0602:18royalaid["/models/index" :refer [Post]]#2020-08-0602:20royalaidand yet strangely#2020-08-0602:21royalaid
(ns ex
  (:require ["@aws-amplify/datastore" :refer [DataStore initSchema] :as foo]
            #_["/models/index" :refer [Post]]
            [cljs.core.async.interop :refer [<p!]]))
works just fine and initSchema is a fn if I log it
#2020-08-0602:38royalaidFinal point is that if I swap to import * as foo from '@aws-amplify/datastore'; everything works and I can use foo but unfortunately this is generated code and would rather not have to update the require after each time I re-generate the file#2020-08-0604:08Mikko HarjuIs it a known issue that when evaling stuff with nRepl, I've started to get
[2020-08-06 07:06:52.100 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 21}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
pretty frequently, and the only solution that I've found is to shut down shadow-cljs and start it again. I haven't figured out the actual circumstances this happens but I'll try to see if I see some similarities. I'm using Vim/Fireplace if that is something that might have to do with this.
#2020-08-0607:42robert-stuttaford@thheller how do i interpret the size difference between what the build report says, and the filesize on disk? for example, a common module, the report says "JS: 1.92 MB", but on disk, the same module is '9912095' bytes, or 10mb. is it perhaps that the report is about :release and my on-disk code is the non-:release version? edit: on reflection, this is a silly question, of course it's about the :release version 😅#2020-08-0608:19thheller@royalaid npm packages are imported in a separate step and converted to commonjs. closure does some strict checking for ESM files but since everything is CJS it only supports imports * as .... a bit annoying but pure ESM doesn't work unless everything is ESM and npm packages rarely are.#2020-08-0608:19thheller@robert-stuttaford yeah, its always release#2020-08-0608:20thheller@mikko which version do you use? I thought I fixed that issue a couple versions ago?#2020-08-0609:32Mikko Harju
shadow-cljs - server version: 2.10.19 running at 
#2020-08-0609:33Mikko HarjuI think this relates to running code in a completely new NS, or then something else has failed in prior reload and then evaluating new code causes this. But these are just pure guesses.#2020-08-0609:35thhellervery strange. would help a lot if you can narrow it down a create some reproducible steps to trigger it.#2020-08-0609:40Mikko HarjuDefinitely. Will try!#2020-08-0705:10Mikko HarjuI think this has to do with clara.rules somehow. I'm not sure why, but it seems that whenever I get into a state where it fails to satisfy our constraints we get to an error state where I evaluate a form, and then it prints that error. We've had had issues with clara.rules previously too on CLJS that it might do something funky, might be related to compilation failing or something..#2020-08-0705:12Mikko HarjuFor instance, now I just hit a situation where it failed to succeed with a perfectly valid set of facts and rules, that error appeared, restarted the compilation and now it works with no changes 🙂#2020-08-0708:19thhellerstrange. no clue how that may be happening. thought I fixed all the cases but I guess not?#2020-08-0708:37Mikko HarjuWhat was the relevant part you changed? If I could spot something… (or not)?#2020-08-0709:03thhellerwhat do you mean? the commit that should have fixed this was https://github.com/thheller/shadow-cljs/commit/80d56a807af3b7a921f10b858e38ff20f4de9bfe#2020-08-0709:04thhellerbut there were a couple other commits since then that may potentially affect this#2020-08-0709:42Mikko HarjuCan it be that the connection tries to declare cljs.user again and that itself causes an exception causing the cljs,user to not be available anymore?#2020-08-0709:42Mikko HarjuFor example, (ns cljs.user (:require some.namespace.that.fails))#2020-08-0709:44thhellerdo you have an actual cljs.user? the error message suggests you don't?#2020-08-0709:44Mikko HarjuHey, that's it? If I just put (throw (js/Error. "Lets fail")) to a NS and then load it => I get that error!#2020-08-0709:45thhellera JS runtime error cannot possibly cause a CLJS compiler error?#2020-08-0709:45Mikko HarjuFirst.
[2020-08-07 12:45:14.376 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(load-file \"filippos/core/models/data_types.cljs\")", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (load-file "filippos/core/models/data_types.cljs"), :source "(load-file \"filippos/core/models/data_types.cljs\")", :tag :shadow.cljs.repl/process-ex}
#2020-08-0709:45Mikko Harju(that data_types ns has the throw)#2020-08-0709:45Mikko HarjuThen next eval form:
[2020-08-07 12:45:47.721 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 8, :from 40}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
#2020-08-0709:46Mikko HarjuAnd I load it with Require! in fireplace after I planted that throw#2020-08-0709:47thhelleris there more to the first error? it should be printing a stacktrace?#2020-08-0709:47Mikko HarjuYeah#2020-08-0709:48Mikko Harju#2020-08-0709:48thhellerthats not the first#2020-08-0709:48thheller> [2020-08-07 12:45:14.376 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex #2020-08-0709:48thhellerthat one#2020-08-0709:48Mikko HarjuWhoops#2020-08-0709:48Mikko Harju#2020-08-0709:49thhellerthats all? there should be more?#2020-08-0709:49Mikko HarjuYes#2020-08-0709:49thhellersee thats the issue#2020-08-0709:49Mikko HarjuYeah, and that is on the classpath.#2020-08-0709:51thhelleryes but load-file expects a file-path so src/main/filippos/core/models/data_types.cljs or an absolute path#2020-08-0709:52thhelleror do you just have the file in the project root?#2020-08-0709:52thhellerI mean this error should clearly not cause everything else to fail but it is a legit error caused by sending invalid data#2020-08-0709:54Mikko Harjuwait, I'll add repro steps#2020-08-0710:00Mikko HarjuArgh. I thought I had it but now it's resisting me and is working 😄#2020-08-0710:01Mikko HarjuI'll try.#2020-08-0710:04Mikko Harju1. compile 2. introduce error in code & save 3. wait for compilation 3. refresh browser 4. eval anything in that NS => fails subsequently, even after fixing the error and refreshing#2020-08-0710:05thhellersorry that isn't precise enough. like I said a JS (throw ...) cannot possibly cause an error on the compiler side#2020-08-0710:06thhellerunless you mean "error in code" as an compilation error#2020-08-0710:06Mikko HarjuOK – so basically it boils down to having unhandled exceptions lurking around in the core and that causes failures?#2020-08-0710:06thhellerit is completely expected that you CANNOT eval anything in an NS that fails to load#2020-08-0710:06thhellerthat will NEVER work#2020-08-0710:07thhellerbut the issue I'm interested in here is the "no output by id"#2020-08-0710:07thhellerwhich is a compile side error#2020-08-0710:07thhellerno ...#2020-08-0710:07thhellerbut you need to separate the two worlds when diagnosing this#2020-08-0710:08thhelleron the server-side CLJS compilation running in CLJ#2020-08-0710:08thhellerone is JS side#2020-08-0710:09thheller"no output by id" cannot possibly the caused by a JS side runtime exception#2020-08-0710:10thhellerit may cause the JS side to fail but not the reverse#2020-08-0710:10thhellerso we need to track down what you did to trigger that error, not the other errors that may cause.#2020-08-0710:10Mikko HarjuUnderstood.#2020-08-0614:15OdyWith the minimal setup as described here: https://github.com/minimal-xyz/minimal-shadow-cljs-browser. Is it supposed to deploy, ie. copy assets like index.html when it detects changes?#2020-08-0614:55thhellerno.#2020-08-0615:09OdyCool, what magic incantation makes it do so? May be this https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2020-08-0615:17thhellerthere is no support for doing anything with html at all
#2020-08-0615:18OdyThanks. I am new to cljs, at the stage of examining the tools around it. I assumed it will reload when it sees a change in asset files, like figwheel is doing.#2020-08-0615:22thhellercss reloading yes that is supported but assumes that you put it into the correct place yourself#2020-08-0615:23thhellerhtml reloading no since typically you just rely on hot reload and never actually want to reload your full page#2020-08-0615:23OdyThere is also no reloading of jar files right? If say i add a new lib to deps#2020-08-0616:57thhellermodifying the CLJS dependencies requires a restart currently yes. npm packages don't#2020-08-0711:16jysandyFrom the docs: > Sometimes you will see examples of import Foo from “something” when the code is actually CommonJS code. Just ran into this case recently. However, it looks like if I try to require ... :as after I incorrectly use require ... :default, the require ... :as fails and doesn’t do anything. I had to restart the shadow-cljs watch process and reconnect to get it to work. Is this worth documenting as a gotcha? Spent quite a lot of time debugging, because I thought the CommonJS import was failing as well.#2020-08-0711:59thheller@jysandy hmm yeah thats an issue. the problem is that the first :default will create the DayPicker binding. :as is only taken if there is no other binding by that name since its normally reserved as a namespace alias. not really something I can easily fix. Just use :as first and you won't run into this issue#2020-08-0716:18bennytrying to spin up shadow in cider for the first time in a while and getting the following, any ideas? > Exception in thread “main” java.lang.RuntimeException: Unable to resolve symbol: requiring-resolve in this context, compiling:(shadow/cljs/devtools/cli.clj:70:16)#2020-08-0716:19bennyah looks like since i’m using lein for deps it’s ignoring the dynamic deps#2020-08-0716:21dpsuttonwhat's your clojure version? that function was added in 1.10 and is in clojure.core#2020-08-0716:26thheller@benny just add org.clojure/clojure to your deps in lein, looks like you are getting an older version#2020-08-0716:49bennysweet that’s much better than switching back, thanks @dpsutton @thheller#2020-08-0814:27metasoarousDoes anyone know why I'd be getting the following from a shadow-cljs release build?
shadow-cljs - failed to load
I'm pulling my hair out here trying to figure out what's going on.
#2020-08-0814:28metasoarousPossibly related, all of my minified builds are giving me errors like
app.js:1994 Uncaught TypeError: $jscomp.inherits is not a function
    at app.js:1994
    at app.js:1645
    at Object.shadow$provide.<computed> (app.js:1645)
    at vs (app.js:2831)
    at app.js:2211
    at Object.shadow$provide.<computed> (app.js:2211)
    at vs (app.js:2831)
    at app.js:3230
    at app.js:3271
#2020-08-0814:29metasoarousTrying to cut a new release of https://github.com/metasoarous/oz, and shit is just not working. I didn't really even change very much since the last working release and when things starting going haywire.#2020-08-0814:30metasoarousLast working release was 1.6.0-alpha15#2020-08-0814:34metasoarousThere's a Makefile in there with build and release tasks which document how I've been doing this.#2020-08-0814:36metasoarousThe Uncaught TypeError is the real issue, as it's preventing the app from loading and doing The Thing. But it seems to be related to some weird shadow shenanigans that I've been unable to sort out.#2020-08-0814:36metasoarousFor a while the error that was coming up was a little different:
TypeError: $jscomp.asyncExecutePromiseGeneratorProgram is not a function
at La.q.runAsync (app.js:492)
at $jscomp.generator.Engine_.program_ (app.js:2153)
at $jscomp.generator.Engine_.nextStep_ (app.js:20)
at $jscomp.generator.Engine_.next_ (app.js:16)
at $jscomp.generator.Generator_.next (app.js:21)
at app.js:2125
at new Promise (<anonymous>)
at N (app.js:2124)
at Pc (app.js:2148)
at $jscomp.generator.Engine_.program_ (app.js:2146)
at $jscomp.generator.Engine_.nextStep_ (app.js:20)
at $jscomp.generator.Engine_.next_ (app.js:16)
at $jscomp.generator.Generator_.next (app.js:21)
at t (app.js:2124)
#2020-08-0814:37metasoarousTried updating shadow, and now it's the other (seemingly related) error#2020-08-0815:07thheller@metasoarous this is a problem with polyfills. I thought I fixed all those. guess I didn't. an easy fix is adding :compiler-options {:output-feature-set :es8} to your build config.#2020-08-0815:07thheller@metasoarous this is a problem with polyfills. I thought I fixed all those. guess I didn't. an easy fix is adding :compiler-options {:output-feature-set :es8} to your build config.#2020-08-0816:23metasoarousHey @U05224H0W! Thanks for the quick response! I've verified that it's working with the :es8 featureset. Strangely though, when I then comment out that line and recompile it works again! Also, I may be crazy or have missed something, but I had it working yesterday again and then it just stopped. Is there any reason it would be misbehaving intermittently like this? Also very strange that it just magically started breaking with me not having changed very much.#2020-08-0816:25thhellerdid you upgrade the shadow-cljs version? I did a bunch of changes in this area in the past few releases trying to fix this. It manifests in so many different ways so I guess I missed some.#2020-08-0816:39metasoarousI didn't when the issue first popped up. Later I updated to try and fix it.#2020-08-0816:40metasoarousThat's when it went from TypeError: $jscomp.asyncExecutePromiseGeneratorProgram is not a function to TypeError: $jscomp.inherits is not a function.#2020-08-0816:40metasoarousBut the first of those errors seemingly popped up out of nowhere#2020-08-0817:02metasoarousOne more potentially pertinent detail; While, as I said, I don't remember changing anything about my Shadow setup, I did run some devcards with shadow-cljs watch which I hadn't done in a while. And with the weirdness of turning on/off :es8 targeting fixing things, I wonder if this could have something to do with information Shadow is caching that isn't getting cleared out?#2020-08-0815:07thhellerI'll see if I can reproduce this locally and try to figure out whats happening#2020-08-0815:07thhellerI'll see if I can reproduce this locally and try to figure out whats happening#2020-08-0816:24metasoarousAmazing; Thanks so much!#2020-08-0815:11awcotHi, I'm having some trouble getting set up using shadow-cljs: npx create-cljs-project my-project All OK. cd my-project npx shadow-cljs
Could not find shadow-cljs.edn config file.
To create one run:
  shadow-cljs init
OK... It's definitely in there though. Looks like it can't find it? Using node v12.18.3. The only thing I can run is npx shadow-cljs help 😅 . Also tried installing globally, no different... Thx
#2020-08-0815:15thheller@alexandercotton1996 oops I messed up the last release. just pushed 2.10.21 which fixes this. run npm install in the project dir to fix it#2020-08-0815:15thheller@alexandercotton1996 oops I messed up the last release. just pushed 2.10.21 which fixes this. run npm install in the project dir to fix it#2020-08-0815:17awcotNice! That works, many thanks#2020-08-0817:27bennyany idea why i would randomly start getting
no dispatch macro for s
for the shadow reader like so
:closure-defines  {client.config/api-base-url #shadow/env "API_URL"}
#2020-08-0817:50bennylooks like a bug with a newer version#2020-08-0817:50bennyi’ll submit a bug#2020-08-0821:03thheller@benny I think the problem is that API_URL might not be set? you can try #shadow/env ["API_URL" "default-value"]?#2020-08-0821:18bennythat’s true, but in 2.10.18 it doesn’t care. that profile isn’t being used, so i wouldn’t even expect it to be evaluated#2020-08-0821:20thhellercan't stop the reader from not trying to use it. for some reason the CLJS tools.reader doesn't allow reader conditionals that return nil/false. looks like a bug in tools.reader.#2020-08-0917:58kiranshilaHey everone. Is there a way to create a custom target configuration? I am trying to get shadow to work with building for Espruino, a JS runtime for microcontrollers. The esprit project accomplishes this by just using cljs.main, but I would like to use shadow for the better integration of external js. I can't quite figure out how to make shadow just accomplish clj -m cljs.main -c myproject.core#2020-08-0917:59kiranshilaAs in, I don't want to wrap in any extra stuff like the repl or hot reloading#2020-08-0918:38thheller@me1310 yes, :target is extensible and meant to enable things like this. Its just not documented very well so writing it may be not so straightforward. do you have an example project for this? would be curious to know what the runtime is capable of. I saw Mike tweeting about about it but haven't looked into it myself yet.#2020-08-0918:40kiranshilaYeah, I'm working on a simple project here. I'm using make to orchestrate some of the flashing as well#2020-08-0918:40kiranshilahttps://github.com/kiranshila/HackerHUD/#2020-08-0918:41kiranshilaAFAIK no one has tried to like make a project like this yet, Mike's examples were all fooling around in the repl#2020-08-0918:41kiranshilaBut I fixed some bugs for him to make it such that "projects" like this just work#2020-08-0918:42kiranshilaIn fact, I have CIDER working, and can live code on the device, which is frankly incredible#2020-08-0918:42thhellerare there some docs for the runtime itself? is it node?#2020-08-0918:42kiranshilaIts like its own thing https://www.espruino.com/#2020-08-0918:43kiranshilaAnd its not a perfect implementation of the runtime, I had to muck around with cider's wrap fn as it's implementation of try/catch isn't quite correct#2020-08-0919:08kiranshila@thheller Do you have an example bare-minimum target I can follow?#2020-08-0919:09kiranshilaOoh also Espruino provides an npm module that actually does a lot of the heavy lifting, including hot code reloading#2020-08-0919:09thhellerwell the easiest and closest is probably the node-script#2020-08-0919:09thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/node_script.clj#2020-08-0919:10kiranshilaNice, I'll take a look#2020-08-0919:11kiranshilaAnd so, is this something I need a fork to do? Or is there a mechanism to point to a custom target clj file#2020-08-0919:11thhellersomeone made a :target not too long ago. maybe that helps too https://github.com/titonbarua/shadow-cljs-gjs-target#2020-08-0919:11thhellerno you just create a namespace with a process fn, then :target that.namespace just works#2020-08-0919:12kiranshilaoh sweet, thats easy#2020-08-0919:13thhellerbasically that fn is called repeatedly with :shadow.build/stage changing and you doing stuff depending on the stage#2020-08-0919:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#compile-stages#2020-08-0919:14thhellersome of the hooks docs apply too. its pretty similar in structure https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2020-08-0919:15thhellerjust that hooks do work after the :target impl. otherwise its the same.#2020-08-0919:15kiranshilaCool, makes sense#2020-08-0919:15thhelleryou can try the UI and (tap> build-state) to explore what it looks like#2020-08-1008:32royalaid@thheller I have a bit of weird one for you, any idea why when loaded via shadow.resource causes Invalid UTF-8 start byte 0x97 ? Stack Overflow is points to my files not being UTF-8 but I have tried to confirm that they are as best as I can.#2020-08-1009:23thhelleris the file you are loading as a resource proper utf-8? it often is some kind of utf16 or so#2020-08-1009:24thhellershadow-cljs does not perform any kind of conversion so it is likely that your file contains the invalid byte#2020-08-1009:24thhellerthey are often invisible in editors so easy to miss#2020-08-1022:03Jack ArringtonI just want to say, shadow-cljs is awesome! I just set up hot reloading in like 5 minutes. Normally when spinning up a new JS project with Webpack, I plan on wasting an hour or two at least to get everything configured. Great job on the usability front 🍻#2020-08-1106:49nivekuilI somehow got shadow-cljs into a state where running shadow-cljs release raises a NPE. My CIDER repl hot reloading is also broken. known bug?#2020-08-1106:49nivekuilI somehow got shadow-cljs into a state where running shadow-cljs release raises a NPE. My CIDER repl hot reloading is also broken. known bug?#2020-08-1118:30nivekuilI don't think I have anything fancy going on. I think CIDER just runs the default command, shadow-cljs server. I think this may have been a race condition from hot reload + release at the same time, but anyway it went away after a restart#2020-08-1108:26steveb8nQ: I’ve reached the stage where using tap> and the inspector would be really helpful. I’m using 2.8.94. Should it be working in the browser app? I can’t see any runtimes even though I have a nodejs server running. and when I (tap> []) from the cljs repl, nothing happens#2020-08-1108:27steveb8nI seem to remember it’s been disabled but I just want to ask#2020-08-1109:00thheller@steveb8n that version is too old for inspect. it is enabled by default in newer versions.#2020-08-1109:01steveb8nok great. I can update and try it. Thanks. looking forward to using it#2020-08-1109:01steveb8nbtw: I agree with @mail985 shadow rocks!#2020-08-1109:30steveb8ninspect working now. thx!#2020-08-1111:51Jack ArringtonFollowing examples to make a testing namespace and shadow is telling me node-test is an invalid target:
Target "node-test" for build :test was not found. The built-in targets are:
  - :browser
  - :browser-test
  - :node-script
  - :node-library
  - :npm-module
  - :karma
  - :bootstrap
Should I just be using node-script?
#2020-08-1111:52thheller:target :node-test? should exist unless you are on an ancient version#2020-08-1112:16Jack ArringtonI just installed a few minutes ago#2020-08-1112:24Jack ArringtonLooking like I am running v 2.10.21#2020-08-1112:29Jack ArringtonI think it's a problem with my namespace directories actually - error seems to be coming from https://github.com/thheller/shadow-cljs/blob/bfdda1d472198a8f352468eafc2a1080e855b747/src/main/shadow/cljs/devtools/errors.clj#L82. Looks like it's just an outdated error message 🙂.#2020-08-1112:55bendlasI'm trying to run shadow watch for :node-script on a different (docker) host, than node app.js. :devtools-url "" yields remote-error Error: Unexpected server response: 200. What's the best way to do this?#2020-08-1113:38thheller@mail985 looks like you might be using :target node-test. note that it must be a keyword, otherwise it'll look for (ns node-test) which indeed does not exist.#2020-08-1113:38thheller@mail985 looks like you might be using :target node-test. note that it must be a keyword, otherwise it'll look for (ns node-test) which indeed does not exist.#2020-08-1113:40thheller@bendlas assuming that calling actually results in the shadow-cljs UI that should be fine? did you verify that the http connect actually works?#2020-08-1123:17bendlas@U05224H0W it turns out, it does that, when a stale app.js tries to connect during shadow's boot up (docker volume, for sharing build results). removing app.js (and waiting for it to be re-generated) before connecting node, fixed it. thanks!#2020-08-1115:27pcjIs it currently possible to add a dependency while shadow watch is running? If not, are there any barriers for that feature to be added? I can take a look at it 🙂#2020-08-1115:46thhellernot possible currently and not trivial to add given that it must be supported via shadow-cljs.edn, project.clj and deps.edn. I may add a shadow-cljs.edn solution some day but it is low priority. restarting occasionally is not that bad.#2020-08-1116:02pcjThanks for the quick response! Yeah, doing some research over the past week it doesn't look trivial 😞#2020-08-1116:03thhelleryeah manipulating the classloader at runtime is full of footguns. its easy for just .cljs files but macros and other resources is where it gets tricky#2020-08-1120:30mauricio.szaboHi, there's a thing with Shadow-CLJS that I really don't understand, that's almost reproducible all time. On my project: https://github.com/mauricioszabo/repl-tooling, if I try to watch :integration target, most of the time I get the following error:
File: /home/mauricio/.atom/packages/chlorine/repl-tooling/test/repl_tooling/repl_client/textual_representation_test.cljs:18:3
--------------------------------------------------------------------------------
  15 |       render/txt-for-result))
  16 | 
  17 | (cards/deftest evaluate-to-text
  18 |   (async-with-clj-repl "text repr"
---------^----------------------------------------------------------------------
Encountered error when macroexpanding cljs.core/aset.
StackOverflowError: 
        cljs.analyzer/compiler-options (analyzer.cljc:168)
        cljs.analyzer/checked-arrays (analyzer.cljc:178)
        cljs.analyzer/checked-arrays (analyzer.cljc:174)
        cljs.core/aset (core.cljc:1043)
        cljs.core/aset (core.cljc:1041)
        clojure.core/apply (core.clj:669)
      ....big stacktrace
#2020-08-1120:31mauricio.szaboI just need to open this file and save it once, then it compiles fine.#2020-08-1120:33thhellerthe file looks rather macro heavy and no clue what they do. might expand to a bazillion forms for all I know 😛#2020-08-1121:09mauricio.szaboRight you are, but not that heavier than other test files that don't cause trouble 😄#2020-08-1121:09mauricio.szaboThat's what's been on my mind for a while 😄#2020-08-1121:33neuralHello all! need some help on :optimizations. I am working on an app using shadow/reagent/expo/react-native and the app works fine upon shadow-cljs release with :optimizations :simple but with :optimizations :advanced it looses some symbols names from google closure optimizations.
(defn root []
  (let [this (r/current-component)
        open-drawer  #(this.refs.drawer.openDrawer)]
     ....
The reference for this.refs.drawer.openDrawer is lost on advanced optimization. Some thoughts on how to circunvent this??
#2020-08-1202:28royalaidThis is a pretty common problem and there are a lot of options. https://github.com/appliedsciencestudio/js-interop is my favorite, https://github.com/mfikes/cljs-bean/ is another option people seem to like. Going a bit more extreme there is https://github.com/binaryage/cljs-oops which was built specifically to address this problem. Finally you can drop down into https://clojureverse.org/t/cljs-hidden-google-closure-library-gems/2321/2#2020-08-1202:29royalaidThe point is that "dot access" breaks because the variable names change on advanced optimization and your CLJS code doesn't#2020-08-1208:50thheller
(defn root []
  (let [^js this (r/current-component)
        open-drawer  #(.. this -refs -drawer -openDrawer)]
#2020-08-1208:51thhellerthis should be all you need. don't need a library or anything. if you have externs inference turned on you should be getting a warning https://shadow-cljs.github.io/docs/UsersGuide.html#externs#2020-08-1209:02thheller@U0S3YK6HK using those libraries to fix externs issues is pretty much an anti-pattern these days and should not be used for that#2020-08-1215:43royalaidTIL, thanks!#2020-08-1219:44neural@U05224H0W tks! that works! TIL !!#2020-08-1209:53robert-stuttafordhowdy @thheller! i see this issue is closed: https://github.com/thheller/shadow-cljs/issues/716 did this get fixed and i just need a newer version?#2020-08-1210:00thhellerI think so but nobody has ever confirmed so no clue actually. I don't use emacs/cider myself and don't have a clue how to test this 😛#2020-08-1210:01robert-stuttafordok, pretty sure it isn't working, but i'll test with the very latest version to be sure 🙂#2020-08-1210:12CaseyI am attempting to use the cljs library https://github.com/lifecheq/re-auth0 which wraps the https://github.com/auth0/auth0.js/ library. re-auth0 uses the old cljsjs method of including deps. I followed the instructions https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#migrating-cljsjs by creating a shim. However when shadowcljs runs it complains The required JS dependency "process" is not available, it was required by "node_modules/auth0-js/dist/auth0.min.js" According to https://github.com/thheller/shadow-cljs/issues/519#issuecomment-508386654 this should be remediated by ensuring shadow-cljs is an app dependency... but it already is in my project (generated with luminus), or so I thought? The line in :dependencies in project.clj is [thheller/shadow-cljs "2.10.17" :scope "provided"]#2020-08-1210:13thheller@ramblurr you need to have the npm shadow-cljs installed in your project. so npm install shadow-cljs. that brings in the required process polyfill.#2020-08-1210:14CaseyOh the npm module !#2020-08-1210:20Caseythanks @thheller that does it, I added a comment to the linked issue mentioning the distinction#2020-08-1213:08mkarpJust switched a pretty old node bundle to shadow-cljs and everything works like a charm. Love having a reliable REPL. Thanks @thheller!#2020-08-1220:27rickheereHi everyone, I hope someone can point me in the right direction. I downloaded the react native expo reagent repo. Them I test it on my phone the app loads as expected but in about 5 to 10 seconds I get this error.#2020-08-1220:27rickheere
Running application "main" with appParams: {"initialProps":{"exp":{"lastErrors":[{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":2},{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":3},{"isFatal":false,"errorMessage":"console.error: \"shadow-cljs - remote-error\", [object Object]","exceptionId":3}],"initialUri":"","manifest":{"env":{},"id":"@anonymous/reagent-expo-f0486819-2cb9-4ab2-ae63-272afd37af81","privacy":"public","assetBundlePatterns":["**/*"],"primaryColor":"#023C69","bundleUrl":"","slug":"reagent-expo","name":"hello-world","icon":"./assets/icon.png","xde":true,"loadedFromCache":false,"splash":{"resizeMode":"contain","backgroundColor":"#ffffff","image":"./assets/splash.png","imageUrl":""},"orientation":"portrait","entryPoint":"./app/index.js","iconUrl":"","isVerified":true,"version":"1.0.0","developer":{"tool":"expo-cli","projectRoot":"/home/rick/Repositories/dca3"},"mainModuleName":"app/index","debuggerHost":"192.168.2.36:19001","logUrl":"","packagerOpts":{"https":false,"dev":true,"lanType":"ip","hostType":"lan","minify":false,"urlRandomness":"84-n8h"},"sdkVersion":"35.0.0","platforms":["ios","android","web"],"hostUri":"192.168.2.36:19000","ios":{"supportsTablet":true},"updates":{"fallbackToCacheTimeout":0}},"shell":false}},"rootTag":81}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
#2020-08-1220:27rickheeresome more info#2020-08-1220:35thheller@rickheere I suspect that its picking the wrong IP to connect to. try running shadow-cljs clj-repl and then (shadow/get-server-addr)#2020-08-1220:35rickheereIf I connect the devtools I also get the message a bit more info Failed to connect to localhost/127.0.0.1:9630#2020-08-1220:36rickheere
shadow.user=> (shadow/get-server-addr)
"172.19.0.1"
#2020-08-1220:36thhellerhmm yeah thats the wrong one I guess#2020-08-1220:38thhelleryou can try :local-ip "192.168.2.36" in the build config or shadow-cljs watch app -config-merge '{:local-ip "192.168.2.36"}'#2020-08-1220:48Adam HelinsLive reloading works but the lifecycle hooks (:after-load, :before-load) are not being called, it even logs explicitly that there is no :after-load hook. I've tried both via metadata and in :devtools. Could there be a sane reason?#2020-08-1220:50thhellerits :dev/after-load in the code? the namespace needs to be actually included in the build too? maybe via :preloads if its not part of your usual code?#2020-08-1220:50rickheereI can confirm that adding :local-ip "192.168.2.36" worked for me.#2020-08-1220:52thheller@rickheere can you share (shadow/find-local-addrs) from the CLJ repl?#2020-08-1220:53thhellermaybe I can adjust the filtering so it finds the correct one on its own#2020-08-1220:57rickheere
shadow.user=> (shadow/find-local-addrs)
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: f in this context
([#object[java.net.NetworkInterface 0x7d151d89 "name:br-c8e7b746556e (br-c8e7b746556e)"] #object[java.net.Inet4Address 0x789f27e5 "/172.19.0.1"]] [#object[java.net.NetworkInterface 0x1dea0730 "name:wlp2s0 (wlp2s0)"] #object[java.net.Inet4Address 0x7dfe23c2 "/192.168.2.36"]])
#2020-08-1220:57rickheereIs this what you are looking for?#2020-08-1220:59thhelleryes, thx. had hoped for a more recognizable pattern or so. doesn't look like something I can easily filter.#2020-08-1221:00rickheereTo bad, thank you for the help.#2020-08-1307:23flowthingI think I’m having the same issue as @adam678. I have src/cljs/user.cljs, and in shadow-cljs.edn, I have :preloads [cljs.user ,,,]. Using :after-load pointing to cljs.user/start in shadow-cljs.edn doesn’t work, nor does setting ^:dev/after-load meta on the var.#2020-08-1307:24flowthingIf I put the after-load function into a namespace that’s not in preloads, it works.#2020-08-1307:24thhellerah. you can't have hooks in cljs.* files. they are filtered.#2020-08-1307:24thhelleruse a regular namespace. cljs.user is special and should not be used for this.#2020-08-1307:24flowthingAha! Good to know, thanks.#2020-08-1307:58Adam Helins@thheller Thanks! A small indication in the docs might be useful since it seems to happen at least once in a while#2020-08-1313:25David PhamI am sorry if this is documented somewhere: how can use files from npm packages that are located in different folders than the usual ones. I am trying to use this library, https://github.com/projectstorm/react-diagrams but the es6 files are not ont the default dist folder but dist/es6 folders. Anyone got the issue before?#2020-08-1313:28thheller@neo2551 that library does not look usable but you can access any file you want via (:require ["the-npm-package/path/to/whatever.js" :as x]) which would be node_modules/the-npm-package/path/to/whatever.js#2020-08-1313:29thhellerjust needs to be a real JS file so not typescript, flow, JSX or whatever other dialects there may be#2020-08-1313:32David PhamThanks a lot! My issue is the cross dependency call the correct path so I would need to rewrite the source code... how do you know it is not usable? Thanks a lot for your answer!#2020-08-1313:33thhellerwell for one https://unpkg.com/react-diagrams gives you an error which is never good#2020-08-1313:39thhellerok nevermind I guess. checked the wrong package 😛#2020-08-1313:40thhellerwhy do you want the ES6 files in the first place?#2020-08-1516:01David PhamBecause I get an error whenever I import the package in typescript otherwise.#2020-08-1518:42thhellerwhat does that mean? the output shadow-cljs produces will be almost identical#2020-08-1315:39mishaa bit of e newbie question: I am getting compilation error with no details, and ns is 1kloc
shadow-cljs - starting via "clojure"
------ ERROR -------------------------------------------------------------------
 File: /<...redacted...>/foo.cljc
Error in phase :compilation

-------------------------------------------------------------------------------- 
what can I do to narrow it down?
#2020-08-1316:05misha
clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.758\"}}}" --main cljs.main --compile bug.core
Caused by: clojure.lang.ExceptionInfo: failed compiling constant: 1/4; clojure.lang.Ratio is not a valid ClojureScript constant. {:constant 1/4, :type clojure.lang.Ratio, :clojure.error/phase :compilation}
weirdly enough, if literal is just ratio 1/4 shadow shows (other) ns errors and warning, but if it is vector with ratio [1/4] - error is blank, as in previous message
#2020-08-1316:51thheller@misha I think I fixed that error message recently. which shadow-cljs version do you have? try 2.10.21#2020-08-1316:52misha
thheller/shadow-cljs             {:mvn/version "2.8.40"}
#2020-08-1316:52thhelleryeah that definitely doesn't have the fix. think its fixed in 2.10.18 or so#2020-08-1316:53mishado you want me to check it out now? (I'd rather not opieop)#2020-08-1316:55thhellercheck it out? if you want to narrow down the issue use the newer version 😉#2020-08-1316:56mishaI already did. But if you'd like a confirmation newer version would narrow it down too – I'll try it out now opieop#2020-08-1317:02mishayep, that prints ratio error, sweet. thank you#2020-08-1317:48neilyioIn Chrome DevTools, my "Sources" panel and all Console errors are pointing to files in , most commonly the core.cljs file there. Is this normal, or is there a further layer of "source-mapping" I could be enabling to actually get errors to reference my own source files?#2020-08-1317:51thhellerhmm?#2020-08-1317:56neilyioYes, curious! Are there any screenshots or anything I can post to clarify?#2020-08-1318:31thhellerI don't know what you mean by "own source file"? you mean like on disk?#2020-08-1318:41neilyioI think that's what I mean. My Sources panel in Chrome DevTools is showing this core.cljs file.#2020-08-1318:43neilyioAll my runtime errors in the Chrome Console also point to this core.cljs file, which makes it very difficult for me to track them down in my own source code (e.g. src/app/core.cljs).#2020-08-1318:44neilyioI feel like I'm doing something fundamentally wrong, and I've been trying to grind through guessing where errors come from for a couple months.#2020-08-1318:48neilyioThis is definitely coming from a place of inexperience with Chrome DevTools. Upon digging through the explosion of error messages in DevTools, I guess I'm able to pick out a file name that looks familiar (only because I happened to have named it views.cljs, which I recognize). I've highlighted that one in the image below.#2020-08-1318:49neilyioAnd upon clicking on that one, it does indeed take me to the correct source file in the Chrome DevTools. I guess I've just been finding this to be a very harrowing user experience, especially when there are multiple runtime errors and I have to scan through lots of stack trace noise to find where I made the error.#2020-08-1318:50neilyioApologies if this became off-topic, I posted this here because I thought I was doing something wrong with my shadow-cljs configuration. But perhaps I just need some debugging tips, and I can ask elsewhere.#2020-08-1318:57thhellerit has nothing to do with shadow-cljs as far as I can tell. its chrome just stripping the "folders" from the filename so you just see a bunch of core.cljs instead of cljs/core.cljs or so#2020-08-1318:57thhellernot much to do other than learning to recognize the errors#2020-08-1318:58neilyioThanks! Sorry to pollute the thread with this, I appreciate your response.#2020-08-1318:58thhellerlike the error you see is @foo when foo is nil#2020-08-1318:59thhellerand you identified the correct place of the error in views.cljs#2020-08-1318:59thhellermaybe there is an option in chrome to show more of the filename? not sure#2020-08-1405:50AronIf I want to compile some tests for puppeteer or similar, to be ran both with watch and a single test with return 0 if tests pass, which build target is the best? After 2 days of trying everything and nothing working out, I am inclined to believe that I should either use jvm (i.e. etaoin) or none of the -test builds, but node-script. Is this correct?#2020-08-1407:10thheller@ashnur node-test should be fine#2020-08-1407:37Aronthanks, I will try that again then : )#2020-08-1407:39AronOne thing I am really confused about is that it seems the process exists before the go blocks finish running.#2020-08-1407:40thhellerwell you need to use the async test helper. otherwise the tests finish without waiting for async stuff and exit the process.#2020-08-1407:42AronOk, that sounds reasonable but I am looking here https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test and I am not really sure what would be the 'helper' that you refer to. The whole page doesn't have this word on it : )#2020-08-1407:43thhellerbecause its not shadow-cljs related. it is cljs.test/async#2020-08-1407:43thhellerhttps://clojurescript.org/tools/testing#async-testing#2020-08-1407:44Aronsorry, this is embarrassing. thanks again#2020-08-1411:15Samuel McHughHello, I'm trying to get a test build working with devcards test. My working devcards build has a option
:build-options {:ns-aliases {devcards-marked cljsjs.marked, devcards-syntax-highlighter cljsjs.highlight}}
specified. The problem is that this :build-options key is not available when setting up a :test build. So any files in devcards which match the -test$ regex will try to compile with this test build, but they will also end up including devcard.core leading to the marked issue.
#2020-08-1411:23thheller@smchugh230395 I'm not sure what you mean by :build-options key is not available ...#2020-08-1411:27Samuel McHugh
{:test
  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true
   :main      optional}}}
This is the list of config options according to the docs. It does not list :build-options as a valid config option. I thought maybe it is valid, but unlisted in the docs, so I tried including it in the test config options. This did not solve the issue though as opposed to my :mycards build which works fine.
#2020-08-1411:27thheller:build-options can be used in any build, the docs just don't mention it. just like :compiler-options and :js-options.#2020-08-1411:34Samuel McHughThat was indeed my suspicion. When I ran previously I was still getting the same issues with regards to "devcards-marked" but now it's compiling. I must have made an error when compiling. Sorry about that. Thanks for the help.#2020-08-1420:59jeff tangHello, I'm currently building a cljs electron app. I'm finding some difficulty accessing node.js APIs from renderer application namespaces. For instance, I can access fs fine from main, but not from the application code. I can access npm modules fine from the application as well, such as @material-ui/icons. Most of my code is based off of https://github.com/ahonn/shadow-electron-starter, and I have enabled nodeIntegration.#2020-08-1421:25jeff tangInterestingly, when I add (:require ["electron" :as elec :refer [ipcRenderer]]) to the top of a renderer file, and print elec, it is an empty js object.#2020-08-1421:36jeff tangVerified: from the electron console, module$node_modules$electron$index returns an empty object#2020-08-1421:45jeff tangWhoo. I'm able to (js/require "fs") . I need to understand the difference between :require and js/require ...#2020-08-1421:49jeff tangAppears that js/require is commonJS require('') whereas :require is fancy ES6 import * from "" https://clojureverse.org/t/guide-on-how-to-use-import-npm-modules-packages-in-clojurescript/2298#2020-08-1421:00jeff tangI wonder if this has something to do with :target :browser for the renderer code. Perhaps shadow-cljs doesn't expect this code to also have node.js access in the case of electron?#2020-08-1421:04Pavel Klavík@thheller So the strange error with incorrect UTF-8 start byte started occuring to me again: #2020-08-1421:04Pavel Klavík
Exception in thread "XNIO-1 I/O-3" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8
 at [Source: 
#2020-08-1421:04Pavel KlavíkSo I was digging little bit through my data and I found that the problem is with using non-ascii characters in strings. Evaluating the following form in REPL will throw the error:
"Křápová"
Was something changed recently in using transit in Shadow-cljs? My version is 10.18.
#2020-08-1422:40thheller@pavel.klavik works fine for me
s$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> "Křápová"
"Křápová"
cljs.user=>
#2020-08-1422:42thheller@tangj1122 :browser by default will try to bundle all js requires which isn't what you want in case of electron. so you can either set :js-options {:js-provider :require} or :js-options {:keep-as-require #{"fs" ...}}#2020-08-1422:43thheller:require will make everything go through require (so via nodeIntegration). :keep-as-require lets you select whichever packages but defaults to bundling all others#2020-08-1422:54Pavel Klavíkso it works with node-repl#2020-08-1422:55Pavel Klavíkand I tested everything from scretch and I get the same error with this output in REPL:
Connecting to remote nREPL server...
Clojure 1.10.1
"Křápová"
=> "Křápová"
(shadow/repl :client)
To quit, type: :cljs/quit
=> [:selected :client]
"Křápová"
#2020-08-1422:56thhellerdon't know what to tell you. works fine in node-repl and browser-repl for me.#2020-08-1422:56thhellermaybe your browser encoding is messed up?#2020-08-1422:58thhelleralso works fine over nrepl
(shadow/repl :browser)
To quit, type: :cljs/quit
=> [:selected :browser]
"Křápová"
=> "Křápová"
#2020-08-1423:01Pavel Klavíkno idea, but it is broken in both firefox and chrome#2020-08-1423:02Pavel Klavíkmaybe something in my shadow-cljs.edn?
{:source-paths ["src"]
 :dependencies [[reagent "0.10.0"]
                [reagent-utils "0.3.3"]
                [re-frame "0.12.0"]
                [com.cognitect/transit-cljs "0.8.264"]
                [day8.re-frame/http-fx "v0.2.0"]
                [hickory "0.7.1"]
                [binaryage/devtools "0.9.10"]
                [bidi "2.1.6"]
                [com.taoensso/sente "1.15.0"]
                [venantius/accountant "0.2.5"]
                [com.cemerick/url "0.1.2-SNAPSHOT"]
                [com.taoensso/timbre "4.10.0"]
                [cljc.java-time "0.1.8"]
                [bouncer "1.0.1"]
                [orgpad/volcano "0.1.2"]
                [macchiato/core "0.2.17"]
                [macchiato/env "0.0.6"]
                [mount "0.1.16"]]
 :nrepl        {:port 9000}
 :builds       {:client     {:target           :browser
                             :output-dir       "resources/public/js/compiled"
                             :asset-path       "/js/compiled"
                             :modules          {:shared {:entries []}
                                                :main   {:init-fn    orgpad.client.core/init
                                                         :depends-on #{:shared}}
                                                :layout {:entries    [orgpad.client.layout.webworker.core]
                                                         :depends-on #{:shared}
                                                         :web-worker true}}
                             :compiler-options {:infer-externs      :auto
                                                :output-feature-set :es6}
                             :devtools         {:after-load     orgpad.client.core/mount-root
                                                :before-load    orgpad.client.core/stop-web-workers
                                                :watch-dir      "resources/public"
                                                :browser-inject :main
                                                :loader-mode    :script}}
                :landing    {:target     :browser
                             :output-dir "landing/resources/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn orgpad.landing.dev/init}}
                             :devtools   {:http-root      "landing/resources"
                                          :http-port      3500
                                          :after-load     orgpad.landing.dev/mount-root
                                          :watch-dir      "landing/resources"
                                          :browser-inject :main}}
                :emails     {:target     :browser
                             :output-dir "emails/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn orgpad.server.email.dev/init}}
                             :devtools   {:http-root      "emails"
                                          :http-port      3600
                                          :after-load     orgpad.server.email.dev/mount-root
                                          :watch-dir      "emails"
                                          :browser-inject :main}}
                :screenshot {:target           :node-script
                             :main             orgpad.screenshot.core/main
                             :output-to        "screenshot/screenshot.js"
                             :devtools         {:autoload true}
                             :compiler-options {:optimizations :simple}}}}
#2020-08-1423:02Pavel Klavíkit fails in client project#2020-08-1423:04thhellerlooks fine#2020-08-1423:05thhellercan't think of anything that would affect this in shadow-cljs. maybe a bad charset encoding in your editor/terminal? should be utf-8#2020-08-1423:05Pavel KlavíkI am using Cursive nREPL#2020-08-1423:06Pavel Klavíkhow can I access REPL from terminal?#2020-08-1423:06thhellertry <meta charset="utf-8"> if its not in your HTML. wouldn't be the first time this fixed something.#2020-08-1423:06thhellershadow-cljs cljs-repl client or just shadow-cljs node-repl or browser-repl#2020-08-1423:07Pavel Klavíkit works fine from cljs-repl from terminal#2020-08-1423:08thhellermaybe weird encoding in cursive then? I don't have a clue, the nrepl I tested was also in cursive.#2020-08-1423:08Pavel KlavíkI have this in my HTML:
<meta charset='utf-8'>
#2020-08-1423:08Pavel KlavíkI will try to update Cursive to see whether it won't fix it#2020-08-1517:26kennyI’m using chromex with shadow-cljs. When I connect to the REPL using (shadow/nrepl-select :extension) , I appear to be connected to the browser environment within the extension. Anyone familiar with chromex to know how to get the REPL connected to the browser environment for the content-script (i.e., the actual loaded browser page)?#2020-08-1517:30kennyIt sounds like it is possible to do from https://github.com/thheller/shadow-cljs/issues/279#issuecomment-549115864.#2020-08-1517:45kennyGiven this output,
(shadow/repl-runtimes :extension)
=>
[{:since #inst"2020-08-15T17:10:59.182-00:00",
  :proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
  :connection-info {:remote true, :websocket true},
  :client-id 47,
  :user-agent "Chrome 537.36 [MacIntel]",
  :type :runtime,
  :lang :cljs,
  :build-id :extension,
  :host :browser,
  :dom true}
 {:since #inst"2020-08-15T17:11:01.035-00:00",
  :proc-id "7453f221-866f-4e45-ae1a-49c489d30616",
  :connection-info {:remote true, :websocket true},
  :client-id 48,
  :user-agent "Chrome 537.36 [MacIntel]",
  :type :runtime,
  :lang :cljs,
  :build-id :extension,
  :host :browser,
  :dom true}]
is the runtime-id the same as the client-id?
#2020-08-1517:51kennyI see this fn shadow/repl-runtime-select. Calling it with the client-id of 48 (seen above) and then running (shadow/nrepl-select :extension) does not result in the REPL calls getting eval’ed in the client-script environment.#2020-08-1518:04kennyPerhaps there’s a way to pass in a function for how to select the default runtime id?#2020-08-1518:30kennyThis seems like it’d work. Must be missing something.
(shadow/repl-runtime-select :extension 88)
=> true
(:default-runtime-id @(:state-ref (shadow/get-worker :extension)))
=> 87
#2020-08-1518:41thheller@kenny this isn't currently supported. I broke it in the 2.10 REPL updates. https://github.com/thheller/shadow-cljs/issues/776#2020-08-1518:43kennyAh, okay. Perhaps easiest to go back to 2.9.10 then?#2020-08-1518:45thhellerhonestly not sure how reliable it previously was. not aware of anyone ever actually using it.#2020-08-1518:46kennyAh. Perhaps folks using chromex don’t also use shadow-cljs.#2020-08-1518:47thhellerdoesn't have anything to do with chromex. the problem also exists when I work on the shadow-cljs UI which uses a webworker and so always has two runtimes and its kinda annoying to switch.#2020-08-1518:49kennyChromex also necessitates 2 runtimes. Without support for runtime switching, you can only interact with 1 runtime. It seems incredibly painful to work without a repl!#2020-08-1518:50kennyThus the conclusion previously drawn. If you’re also in the same situation, how do you switch between the different runtimes?#2020-08-1518:52thhellerI don't currently. I only use the REPL via Inspect when looking at some data stuff. Otherwise just relying on hot-reload.#2020-08-1518:55kennyLife without access to a repl seems dark 🙂#2020-08-1518:57thhellerI barely ever use the REPL in CLJS for some reason. I use it for everything in CLJ but somehow hot-reload works better for me in CLJS#2020-08-1518:58kennyI do that often when working on our prod app at work. I’m currently messing with an old cljs code base and just wanted to explore what stuff did, immediately reaching for the repl.#2020-08-1518:59kennyAnyway, 2.9.10 with (shadow/nrepl-select :extension {:runtime-id "<id>"}) does work. One thing that is frustrating with explicitly specifying the runtime id is if you refresh your browser, the id changes.#2020-08-1523:08cfleming@thheller I’m looking at @pavel.klavik’s problem with UTF in Cursive. Am I correct in thinking that that exception is when the Shadow server is reading a transit response, presumably the response from the CLJS client?#2020-08-1523:10cflemingI’m not super familiar with how Shadow works, so I’m not sure where transit would be being used. My mental model of how this eval would be passed is:
Cursive nREPL client -> Shadow nREPL server -> CLJS client
But I thought that second step was usually passed as a string rather than transit/JSON.
#2020-08-1523:11cfleming@pavel.klavik Do you have your IntelliJ configured to use UTF-8 under Settings-&gt;Editor-&gt;General-&gt;Console?#2020-08-1523:22Pavel KlavíkI have this there:#2020-08-1523:22Pavel KlavíkChanging to UTF-8 does not seem to help.#2020-08-1523:28cflemingIt looks like your system encoding is not set to UTF-8, which might cause this problem. I’m trying to figure out how to set that, one sec…#2020-08-1523:31cflemingOk, if you go to Help | Edit Custom VM Options and add -Dfile.encoding=UTF-8 there, then restart IntelliJ, does that help?#2020-08-1523:31cflemingIn the same config pane you posted above, you should then see: System Default: UTF-8#2020-08-1523:31cfleming@pavel.klavik ^^#2020-08-1523:36Pavel KlavíkIt shows now UTF-8 as System Default, but the error stays the same#2020-08-1523:41cflemingHmm, I’m running out of ideas then, I’m afraid.#2020-08-1523:41cflemingI have to go now, but I’ll think about it and look into it more next week.#2020-08-1523:43Pavel KlavíkSure, thx a lot 🙂.#2020-08-1523:13cflemingAlso, when you eval this do you see anything in your Network pane of developer tools?#2020-08-1523:27Pavel KlavíkYou mean in Chrome? Not sure how to display anything there from Shadow-cljs#2020-08-1609:38thheller@pavel.klavik yeah you should check what the message looks like it is sending. its transit but that is somewhat readable. in the chrome devtools network tab select the websocket connection going to ....#2020-08-1609:39thhellerthat has a "Messages" tab. the message with the error is likely with a green background (sent to server) and starts with ["^ ", "~:op", "~:obj-result", ...#2020-08-1615:37Pavel KlavíkI send there two strings, one "test" which works fine, the other "čau" which fails and I get the following:#2020-08-1615:37Pavel Klavík#2020-08-1615:38Pavel Klavík#2020-08-1615:39Pavel KlavíkThe difference I see for the second case is that it also sends this at the end:#2020-08-1615:40Pavel Klavík@U05224H0W ^^ see the data#2020-08-1616:08thhellerhmm ok there is definitely something broken coming. if you look at the :cljs-eval message the code is definitely garbled#2020-08-1616:10thhellerweird how it turns into the proper thing a bit later. so I suppose there is some encoding going on somewhere#2020-08-1616:12thhellercan the check the cljs-compile-result message what the :js code looks like? it is cut off in the screenshot#2020-08-1616:15thhelleralso check sending the same thing from the terminal. wonder if it shows up garbled as well.#2020-08-1616:48Pavel Klavík#2020-08-1616:50Pavel KlavíkThis is what I get when running "čau" in shadow-cljs cljs-repl:#2020-08-1616:51Pavel Klavík#2020-08-1616:51Pavel Klavík#2020-08-1616:51Pavel Klavík#2020-08-1618:06Pavel Klavík@U05224H0W ^^ (not sure whether you saw my reply)#2020-08-1618:54thhellerI do. just no clue whats going on on your machine. I just get the regular "čau" as expected. no garbled text or weird encodings.#2020-08-1618:55thhellerI'm also on windows so its not that#2020-08-1618:55thhellerI have no idea what is happening but it seems to start with receiving bad input from the REPL#2020-08-1619:23Pavel KlavíkAlso it was not happening till recently. Not sure how long because I haven't tested it for some time. Maybe somehow related to updating Windows or updating of Cursive, not sure. But I haven't update Windows on my laptop and it was broken and it didn't fix with both updating Windows and IntelliJ with Cursive.#2020-08-1619:24Pavel KlavíkMaybe @U0567Q30W will have some idea how to debug Cursive?#2020-08-1619:47thhellerdoesn't seem to be related to Cursive since the cljs-repl input is also bad. bad in a different way but still incorrect.#2020-08-1620:40Pavel Klavíkthat might be related to something I noticed in general that Unicode characters are displayed broken in REPL, even on my server REPL#2020-08-1620:41Pavel Klavíkbut not sure whether it also influences input there#2020-08-1620:47thhellerI don't have any ideas what might be causing this#2020-08-1620:47thhellerhow do you start shadow-cljs?#2020-08-1620:49thhellerdoes npx create-cljs-project foo cd foo npx shadow-cljs node-repl work?#2020-08-1720:07Pavel Klavík@U05224H0W I am running it using shadow-cljs watch client . This works when I send "čau" from Cursive.#2020-08-1720:08thhellerby "This works" you mean the empty project works but yours doesn't?#2020-08-1720:09Pavel KlavíkNo, node-repl work for both. It just runs Clojure? Or how can I switch to Clojurescript?#2020-08-1720:10Pavel KlavíkI also tested another very simple project I made using Shadow-cljs and it is failing the same, so it is not something we changed in our project recently.#2020-08-1720:10thhellerI'm confused. what are you asking me here?#2020-08-1720:10thheller> It just runs Clojure? #2020-08-1720:10thheller?#2020-08-1720:11Pavel KlavíkWhen I run node-repl, what does it connect to? As I understand it, (shadow/repl :client) switches to ClojureScript REPL for the particular client.#2020-08-1720:11Pavel Klavík#2020-08-1720:11thheller(shadow/repl :client) switches to the REPL of the :client build. whatever JS runtime is connected to that#2020-08-1720:12thhellerI'm entirely confused what you are doing here now#2020-08-1720:13thhellerI cannot help you if you only give me half the information about what you are doing.#2020-08-1720:13thhellerwhat is the above screenshot from?#2020-08-1720:14Pavel KlavíkSorry, I will try to explain better. I tested running shadow-cljs node-repl on my project. I connect to the REPL from Cursive and it works as above.#2020-08-1720:14thhellerno it does not!#2020-08-1720:14thhelleryou seem to misunderstand how all this works#2020-08-1720:15Pavel Klavíkok, so how does it work?#2020-08-1720:15thhellerabove you send (shadow/repl :client). it will attempt to switch to the REPL of the client build#2020-08-1720:15thhellerit is telling you that build is not running and does NOT switch#2020-08-1720:15thhellertherefore you are just still in CLJ and that works fine#2020-08-1720:15Pavel Klavíkya, still makes sense#2020-08-1720:16thhellerso you want to switch to the node-repl inside cursive
#2020-08-1720:16thhelleryou do that by running (shadow/node-repl) or (shadow/repl :node-repl) in case you already have done shadow-cljs node-repl#2020-08-1720:17thhellerdo not just ignore error messages please ... they are there for a reason.#2020-08-1720:18Pavel Klavíkya, I get that, just was not sure what node-repl means or how I should switch to it#2020-08-1720:18Pavel Klavíkit fails the same:#2020-08-1720:19thhellerok, so same problem.#2020-08-1720:19thhellernow please do the same in the empty project I asked you to create#2020-08-1720:19thhellerI want to establish if this has something to do with your project setup or not#2020-08-1720:19Pavel Klavíksure, working on it#2020-08-1720:20Pavel Klavíkstill the same problem#2020-08-1720:21thhellerok sorry. then I have absolutely no clue what the problem is.#2020-08-1720:22Pavel Klavíkit is a puzzle, no idea what is going on#2020-08-1720:23thhelleryou can maybe try going back version by version until it works but I suspect it starts failing when I switched the transport to use transit instead of EDN#2020-08-1720:23Pavel Klavíkin the worst case, I can avoid using non-ASCII characters in my development data so I can run them in REPL without any problems#2020-08-1720:23Pavel Klavíkwhich version is it?#2020-08-1720:24thhellerbut I don't have any issues with any unicode data at all#2020-08-1720:24Pavel Klavíkthat is one thing I did, I was using npm install -g shadow-cljs to run the binary directly, and I had a quite old binary for some time#2020-08-1720:24thhellerno clue. probably 2.10.0#2020-08-1720:24Pavel Klavíkand recently, I updated it on both devices with npm update -g shadow-cljs#2020-08-1720:25thhellerI do hope that you have shadow-cljs installed in the project directly. the global install really doesn't matter all that much then and doesn't have anything to do with this anyways.#2020-08-1720:27Pavel KlavíkI have shadow-cljs as dependency in both project.clj and package.json, but I noticed that there was outdated version of Shadow-cljs displayed on the start when running shadow-cljs watch client, so I tried to update it in this way#2020-08-1720:28thhellerwell yes the versions should be somewhat close to each other. if you want to avoid guessing remove the global install completely#2020-08-1720:28thhelleralthough you have to run npx shadow-cljs instead of shadow-cljs then so kinda annoying 😛#2020-08-1720:28Pavel KlavíkI am getting this output:
C:\Shared\orgpad>shadow-cljs watch client
------------------------------------------------------------------------------
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
NPM dependency "react" has installed version "^16.13.1"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.13.1"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.10.14 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build completed. (934 files, 79 compiled, 0 warnings, 29.43s)
while having this in project.clj
[thheller/shadow-cljs "2.10.18"]
#2020-08-1720:30thhellerthat can't be#2020-08-1720:30thheller> shadow-cljs - server version: 2.10.14 #2020-08-1720:30thhellerwhats your shadow-cljs.edn?#2020-08-1720:31thhellerI assume you have :lein true or so in there?#2020-08-1720:31thhellersomething is very weird ... this extra garbage --------------- line shouldn't be there anymore. I fixed that.#2020-08-1720:32Pavel Klavíkno, I didn't use that, I have ClojureScript dependencies written twice, once in project.clj for Cursive, and once for Shadow-cljs#2020-08-1720:32thhellerit looks like you do not have :lein true in your shadow-cljs.edn?#2020-08-1720:32Pavel Klavík
{:source-paths ["src"]
 :dependencies [[reagent "0.10.0"]
                [reagent-utils "0.3.3"]
                [re-frame "0.12.0"]
                [com.cognitect/transit-cljs "0.8.264"]
                [day8.re-frame/http-fx "v0.2.0"]
                [hickory "0.7.1"]
                [binaryage/devtools "0.9.10"]
                [bidi "2.1.6"]
                [com.taoensso/sente "1.15.0"]
                [venantius/accountant "0.2.5"]
                [com.cemerick/url "0.1.2-SNAPSHOT"]
                [com.taoensso/timbre "4.10.0"]
                [cljc.java-time "0.1.8"]
                [bouncer "1.0.1"]
                [orgpad/volcano "0.1.2"]
                [macchiato/core "0.2.17"]
                [macchiato/env "0.0.6"]
                [mount "0.1.16"]]
 :nrepl        {:port 9000}
 :builds       {:client     {:target           :browser
                             :output-dir       "resources/public/js/compiled"
                             :asset-path       "/js/compiled"
                             :modules          {:shared {:entries []}
                                                :main   {:init-fn    orgpad.client.core/init
                                                         :depends-on #{:shared}}
                                                :layout {:entries    [orgpad.client.layout.webworker.core]
                                                         :depends-on #{:shared}
                                                         :web-worker true}}
                             :compiler-options {:infer-externs      :auto
                                                :output-feature-set :es6}
                             :devtools         {:after-load     orgpad.client.core/mount-root
                                                :before-load    orgpad.client.core/stop-web-workers
                                                :watch-dir      "resources/public"
                                                :browser-inject :main
                                                :loader-mode    :script}}
                :landing    {:target     :browser
                             :output-dir "landing/resources/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn orgpad.landing.dev/init}}
                             :devtools   {:http-root      "landing/resources"
                                          :http-port      3500
                                          :after-load     orgpad.landing.dev/mount-root
                                          :watch-dir      "landing/resources"
                                          :browser-inject :main}}
                :emails     {:target     :browser
                             :output-dir "emails/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn orgpad.server.email.dev/init}}
                             :devtools   {:http-root      "emails"
                                          :http-port      3600
                                          :after-load     orgpad.server.email.dev/mount-root
                                          :watch-dir      "emails"
                                          :browser-inject :main}}
                :screenshot {:target           :node-script
                             :main             orgpad.screenshot.core/main
                             :output-to        "screenshot/screenshot.js"
                             :devtools         {:autoload true}
                             :compiler-options {:optimizations :simple}}}}
#2020-08-1720:32thhellerah ok. then it doesn't matter what you put in project.clj at all as far as shadow-cljs is concerned#2020-08-1720:33thhellerthen the version you have in package.json matters#2020-08-1720:33Pavel KlavíkI see, so I could remove it? And how is the version in package.json used?#2020-08-1720:33thhelleror just add :version "2.10.21" to your shadow-cljs.edn#2020-08-1720:33thhellerI don't understand that question#2020-08-1720:34Pavel KlavíkSuppose that I want to update to 10.21. I go and change it in package.json.#2020-08-1720:34Pavel KlavíkHow does it propagates? Do I need to update global shadow-cljs as well?#2020-08-1720:35thhelleryou basically never edit package.json by hand#2020-08-1720:36thhellerif you do you need to run npm install afterwards#2020-08-1720:36thhelleryou can declare the version you want in shadow-cljs.edn as mentioned above if that helps#2020-08-1720:37thhellernpm install shadow-cljs also updates it#2020-08-1720:37thhellerbut if you edit you manually need to run npm install afterwards#2020-08-1720:37Pavel Klavíkok, that is what I was always doing#2020-08-1720:38thhellerit makes sense to keep the global install somewhat on the same level but if you want to be totally sure use npx shadow-cljs instead#2020-08-1720:43Pavel KlavíkSo I updated both to 10.21:
C:\Shared\orgpad>shadow-cljs watch client
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
NPM dependency "react" has installed version "^16.13.1"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.13.1"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.10.21 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build completed. (934 files, 0 compiled, 0 warnings, 99.62s)
I get the same problem while testing both shadow-cljs watch client and npx shadow-cljs watch client .
#2020-08-1720:44Pavel KlavíkWould it be possible to add an option to use EDN instead of Transit?#2020-08-1720:45thhellerno#2020-08-1720:47thhellerI don't have a clue why this isn't working on your machine#2020-08-1720:48thhellerdo you mess with java options in any way? like overriding the default encodings or something?#2020-08-1720:48Pavel KlavíkProbably somehow related to Windows-1250 encoding, maybe the problem got surfaced by switching from edn to transit#2020-08-1720:49Pavel Klavíkno, nothing like that#2020-08-1720:49thhellerwhere is that setting? I want to see what I have#2020-08-1720:50Pavel Klavíkwhat do you mean? what are java options?#2020-08-1720:51thhellerenvironment variables JAVA_OPTIONS or so#2020-08-1720:52thhellerhmm I have window-1252 in cursive as well#2020-08-1720:53thhellerwhat do you get in the CLJ REPL for (System/getProperty "file.encoding")?#2020-08-1720:53Pavel KlavíkI don't think there is anything in my JVM_OPTS or anything like that set up, I just installed JVM and didn't set anything up#2020-08-1720:54Pavel Klavík
Connecting to remote nREPL server...
Clojure 1.10.1
(System/getProperty "file.encoding")
=> "Cp1250"
#2020-08-1720:54thhellerhmm yeah me neither. just guessing here ...#2020-08-1720:54thhellerhmm weird. that says UTF8 for me#2020-08-1720:54thhellerdon't know why#2020-08-1720:55thhelleroh hehe. I do actually have JVM_OPTS=-Dfile.encoding=UTF8 as a global environment variable#2020-08-1720:56thhellernot sure if I set that at some point or if some installer added it?#2020-08-1720:57thhellermaybe that does something. try adding :jvm-opts ["-Dfile.encoding=UTF8"] to your shadow-cljs.edn?#2020-08-1720:57thhellerand probably wipe the .shadow-cljs/builds dir. no clue how the cache reacts to changing the file encoding 😛#2020-08-1720:59Pavel Klavíkok, it works 🙂#2020-08-1721:02thhellerseriously?#2020-08-1721:02thhellerhmm now I have to figure out where this JVM_OPTS is coming from. I can't remember ever setting this.#2020-08-1721:04Pavel KlavíkYa, good guessing 🙂.#2020-08-1721:07thhellerman that was a weird one#2020-08-1721:07Pavel KlavíkThx a lot for figuring this out. @U0567Q30W the solution is to set file.encoding to UTF8 in JVM_OPTS, see the above#2020-08-1721:08thhellerespecially since there is no file-writing involved in this 😛#2020-08-1722:10cflemingYeah, that’s a bit of a bad name - that’s actually the system encoding. Pavel and I tried setting that for IntelliJ (which IMO is probably a good idea) but it seems like it should be set for shadow too.#2020-08-1722:10cflemingWhich makes sense.#2020-08-1722:32thhellerah. didn't know its the global encoding.#2020-08-1609:52thhellermaybe I could add a debug flag on the server side that dumps the messages it receives into a file or so#2020-08-1609:56thhellerthis is where it fails so maybe you can try to redefine this function in the REPL#2020-08-1609:56thhellerhttps://github.com/thheller/shadow-cljs/blob/e2196c2d14ea206b40a1f2078dc851a940ffae72/src/main/shadow/cljs/devtools/server/web/api.clj#L158#2020-08-1609:58thhellerso you could change (map transit-read) to
(map (fn [x] (try (transit-read x) (catch Exception e (log/warn-ex e ::ws-read-fail {:x x})))))
#2020-08-1615:40Pavel Klavík@U05224H0W How can I change this? From REPL?#2020-08-1616:11thhellerdoubt that will show us anything we don't already have so don't bother#2020-08-1609:58thhellermaybe I'll do that as a default#2020-08-1609:59thhellerget at least some kind of clue whats wrong#2020-08-1700:08jmckitrickQuick question about cljs-shadow in a project from luminus. To work with CIDER, we have to move the cljs-shadow part out of the project file, correct?#2020-08-1700:17dpsuttonIs it still using that plugin? If so, it’s advisable to move it out. It’s an extra layer of tooling for no real benefit. It makes diagnosing problems harder. #2020-08-1700:19jmckitrickI’m back to my project after a couple of months delay, and trying to get CIDER to connect to both clj and cljs. I have a project where this is working, but when starting from scratch with a more recent luminus template, it’s failing. I feel like I solved this before, but failed to write it down.#2020-08-1700:21jmckitrickOk, it’s working again. Now I have to figure out why….#2020-08-1700:24jmckitrickBefore I try to extract the shadow config from the project file again#2020-08-1701:05souenzzoCan I use any tool like https://www.npmjs.com/package/source-map-explorer in shadow-cljs bundles?#2020-08-1704:44steveb8nI built https://github.com/stevebuik/stu to do exactly this. I tried it recently and it still works with latest shadow#2020-08-1704:44steveb8nit’s got a couple of bugs, the most important being that it needs 2 releases for the bar chart to appear#2020-08-1704:44steveb8nI can fix them if you want to use it regularly#2020-08-1704:45steveb8nor I can help you fix them#2020-08-1708:42thhelleryou can use source-map-explorer yes. or just the regular build reports https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report#2020-08-1712:18souenzzoATM we can't use SME https://github.com/danvk/source-map-explorer/issues/190#2020-08-1712:28souenzzoReport is awesome!#2020-08-1712:49souenzzohttps://souenzzo.com.br/eql-realworld-example-app/conduit-report.html?#2020-08-1701:48steveb8nQ: when I update from v2.8.101 to v2.10.21 I am blocked by a compilation error from prosemirror. I am not an expert at npm so I could use some help. I’ll start a thread with the details….#2020-08-1701:49steveb8nThe required JS dependency "!!../../css-loader/index.js!./prosemirror.css" is not available, it was required by "node_modules/@aeaton/react-prosemirror/dist/index.js". Dependency Trace: nextdoc/devcards.cljs nextdoc/text_editor.cljs nextdoc/common/text_editor/editor.cljs node_modules/@aeaton/react-prosemirror/dist/index.js#2020-08-1701:50steveb8nI’ve checked and the prosemirror.css is present in the node_modules dir#2020-08-1701:51steveb8nI’m pretty sure it’s this require that is breaking…#2020-08-1701:51steveb8nhttps://github.com/hubgit/react-prosemirror/blob/a6f910565dbf6366745b7f3c2ad832bbe001b8b8/react-prosemirror/src/Editor.js#L4#2020-08-1701:52steveb8nfor now, I’ll workaround by staying on the older version of shadow. I guess that shadow or cljs is doing more checking so it’s desirable to upgrade?#2020-08-1708:44thheller:js-options {:ignore-asset-requires true} will ignore the css require which it previously did by default or warnings#2020-08-1800:21steveb8nthanks. I tried this but it made no difference. is it possible that promemirrors use of css-loader is not handled by the ignore? I ran the build using the Cursive debugger with a breakpoint here https://github.com/thheller/shadow-cljs/blob/f82cffe1b8904e412ed8402b9f90b9d104599601/src/main/shadow/build/npm.clj#L709#2020-08-1800:22steveb8nthe .css import never hits that line. I used a conditional breakpoint to verify other file types and .js files do go through there. Would the react-prosemirror import go through another mechanism?#2020-08-1800:23steveb8n@thheller I can stay on the older version for now so not blocked.#2020-08-1808:13thhellerhonestly I'd just recommend staying away from packages that have some weird hardcoded webpack references. who knows what other issues it will have. can't really support all of that weirdness.#2020-08-1809:53steveb8nok. it’s a shame because react-prosemirror removes a lot of custom code/complexity. I’ll look for an alternative. worst case, I’ll have to stay with v2.8. not ideal but it’ll work#2020-08-1809:54steveb8nI might try patching that wrapper and removing the css-loader. that will work too. I’d rather have the latest shadow if possible#2020-08-1809:55thhellerI'd just open an issue on the react-prosemirror package. it is often just an oversight if things like that remain in code.#2020-08-1809:55steveb8nthat’s a good idea. thx#2020-08-1809:56steveb8nthere are other wrappers out there too. I can try them instead#2020-08-1712:04flowthingHmm.. it seems to me that shadow.cljs.devtools.server/reload! is broken. shadow.cljs.devtools.server.runtime/instance-ref got changed into an atom here: https://github.com/thheller/shadow-cljs/commit/36e63a7801a2bafe0140fe9e49dbada9233335f8#diff-6f236ccd9b9e2a1e666f13927b75d522L3-R3 but shadow.cljs.devtools.server/reload! tries to call vreset! on it here: https://github.com/thheller/shadow-cljs/blob/6252e3b0843b21cfda49fe77bd0e51ad7b32782f/src/main/shadow/cljs/devtools/server.clj#L526. I guess reload! should call reset! instead.#2020-08-1712:06thheller@flowthing I forgot that fn even exists. why do you want to call it?#2020-08-1712:07flowthingI was updating dependencies in one of my work projects and this turned up. I’m not the original author, so I’m not sure why the call to reload! is there. The callsite is in a user/reset type function.#2020-08-1712:08flowthingIt probably isn’t necessary to call reload! at all there, though… need to dive into it a bit.#2020-08-1713:02thheller@flowthing you can just call (server/stop!) (server/start!) instead I guess#2020-08-1714:01sbHi, I got a really strange bug.. “Invalid Filename, got app/something/events.cljs but expected app/something/events.cljs (or .cljc)” .. did you get similar error message..? I played with that around few hours.. I need to delete the file and recreate. So strange.. on OSX.#2020-08-1714:02sb(Im not sure that is shadowcljs related, ..I don’t know)#2020-08-1714:03flowthing@thheller Yep. In this case, I don’t think I even need to do that, though.#2020-08-1714:12thheller@sb make sure you have the actually correct filename. this should only appear if the filename has a typo or something? easy to miss typos if the listed names look mostly similar.#2020-08-1714:13sbI needed delete the file and recreate with same content. Nothing changed. Really strange.. Yes I checked everything x20.. because I thought here is typo but not.. I don’t know what was that.#2020-08-1714:14thhellerdid if have a - in the name?#2020-08-1714:14sbno#2020-08-1714:14sbNothing extra, that was reframe events file.#2020-08-1714:15sb(Just I thought that is maybe happened with others too.)#2020-08-1714:16thhellerno clue. nobody mentioned this before. only when the filename was actually incorrect.#2020-08-1714:24sbok#2020-08-1715:20Filipe Silvaheya @thheller 👋#2020-08-1715:21Filipe SilvaI was running into a problem similar to https://github.com/thheller/shadow-cljs/issues/733 so I tried to create the missing repro#2020-08-1715:21Filipe SilvaI'm not sure if the problem I can repro is exactly the same#2020-08-1715:21Filipe Silvabut I opened https://github.com/thheller/shadow-cljs/issues/777 with a repro#2020-08-1715:22Filipe Silvait looks like in some cases $jscomp isn't there#2020-08-1715:22Filipe Silva(as in, at all, the reference was never declared)#2020-08-1715:24thhellerwith all of these the easy fix is just preventing the polyfilling completely if you know the engine supports it. just set :compiler-options {:output-feature-set :es8}#2020-08-1715:24thhellerI'll take a look when I have some time#2020-08-1715:24Filipe Silvathanks for taking the time#2020-08-1715:25Filipe Silvathe weird part about this one is that the exact same code runs fine in :browser-test but not in :karma#2020-08-1715:25thhellermight just be that karma doesn't declare the global properly. not sure.#2020-08-1715:26thhellerhandling of all of this is kinda hacky but I don't know how to clean it up properly#2020-08-1715:27Filipe SilvaI can confirm that adding :compiler-options {:output-feature-set :es8} to the karma target sorts it out#2020-08-1715:29Filipe Silvawill add that to the issue#2020-08-1722:33superstructorRe that $jscomp in karma error we have just started using :output-feature-set :es6 about a week ago to workaround this issue and no problems so far. I think es5 is pretty much obsolete anyway as the only browsers that would matter for are Internet Explorer series (not MS Edge). So it should probably be asked, does anyone actually need es5 level polyfills by default ? @thheller @filipematossilva#2020-08-1722:34thhellerIE11 is still quite common as a requirement#2020-08-1722:35thhellerbut I could probably bump the :karma default#2020-08-1722:36thhellerhonestly I'd just rather fix $jscomp not working properly. will figure out why its missing when I have time#2020-08-1803:01Josh Horwitzhey all, anyone know what this is ?
Can't find 'shadow.cljs.devtools.cli' as .class or .clj for lein run: please check the spelling.
Syntax error (FileNotFoundException) compiling at (/private/var/folders/z3/xn3w5qfj4cz854tgqrbgl9xc0000gn/T/form-init10942131942141271474.clj:1:126).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
#2020-08-1806:56timrichardtGuten Morgen.#2020-08-1806:56timrichardtI am running into a problem with advanced optimization. I have a project with js and cljs code https://github.com/timrichardt/jsx-cljs-template
> npx shadow-cljs release app
shadow-cljs - config: /Users/tim/jsx-cljs-template/shadow-cljs.edn
[:app] Compiling ...
Closure compilation failed with 3 errors
--- Component.js:2
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
.... [2 more errors of this type]
#2020-08-1806:59timrichardtThis is what the import statements of Component.js look like.
//
import * as React from "react";
import StateProvider from "./StateProvider";
import { useStateValue } from "./StateProvider";
import defaultState from "./defaultState";
import Example2 from "./Component2";
#2020-08-1808:05thheller@joshua.d.horwitz looks like you don't have the thheller/shadow-cljs dependency declared in project.clj?#2020-08-1808:18nitaaihi. i am having troubles with source maps. devtools in chrome are trying to get them from wrong path, i.e. relative to the current url. it should already be fixed here (https://github.com/thheller/shadow-cljs/issues/747). i am using version 2.10.21. anyone else having this issue?#2020-08-1808:20darwinI confirm that the bug was fixed, you must be seeing something else.#2020-08-1808:20thheller@matuskmit1 when asking if anyone else is seeing something it is helpful describing what you are actually seeing 😛#2020-08-1808:26nitaaiwhen i am on /app/borrow/models/1aabaeb8-c1a5-5c8e-858a-aa0bddf469dd, devtools try to get the source maps from /app/borrow/models/js/cljs-runtime/better_cond.core.js.map, instead from /app/borrow/js/cljs-runtime/better_cond.core.js.map. notice the /models/ part. my config file is here: https://github.com/leihs/leihs-borrow/blob/mk/feat/booking-calendar/shadow-cljs.edn#2020-08-1808:28thhellerlooks like :asset-path "js" is incorrect then? should be :asset-path "/app/borrow/js"?#2020-08-1808:31nitaaino, then i get /app/borrow/models/app/borrow/js/cljs-runtime/better_cond.core.js.map. besides that everything else works just fine based on my config…#2020-08-1808:33nitaaiwait, let me restart everything and try again.#2020-08-1808:35thhellernote the leading slash ... without that it will not work#2020-08-1808:38nitaaiyes, that’s the point. now it seems to work 😄#2020-08-1808:39nitaaithanks!#2020-08-1808:40nitaaiwhy everything else was working with an incomplete path is another question though, but already happy#2020-08-1808:41thhellerthe path pretty much is only relevant for source maps and if you use :module-loader (which you are not)#2020-08-1808:43nitaaioh ok 👍#2020-08-1816:02tony.kay@thheller seems like #env stopped working somewhere after .12#2020-08-1816:02tony.kayhttps://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2020-08-1816:03tony.kayno #shadow/env either:
===== ERROR =================
Failed to read config file: /Users/tonykay/fulcrologic/ucv/shadow-cljs.edn
[line 86, col 141] No dispatch macro for e.
when it reaches #env or #shadow/env
#2020-08-1816:03tony.kayseems like a problem with the npm command…I can run .21 via the .12 npm command#2020-08-1817:44thheller@tony.kay it was caused by a bug in tools.reader. its already fixed in master just didn't cut a new release yet since I want to finish something else. https://clojure.atlassian.net/projects/TRDR/issues/TRDR-62#2020-08-1817:44thhellerproblem is with env vars that aren't set#2020-08-1817:45thhelleryou can do #shadow/env ["FOO" "defaultVal"] so #shadow/env ["FOO" ""] would be the same behavior as before I think#2020-08-1821:56dasluHi all! I am enjoying shadow-cljs these days, but now started running into a problem: It seems that the compilation result of shadow-cljs compile app is different from that of shadow-cljs watch app. By looking into their behaviour, it seems to me that the compile result is somehow reverting to some old version, possibly cached somewhere. Does anybody know of a possible common reason for that? (Here is my project: https://github.com/scicloj/gorilla-notes/blob/2821701/shadow-cljs.edn) 🙏#2020-08-1822:00daslu(Removing the .shadow-cljs cache subdirectory does not fix that.)#2020-08-1822:14daslu🌴 Interesting. Removing all the compiled code did fix that. 🌴#2020-08-1823:13dpsuttonNot sure if it’s part of your problem but I would remove those compiler options setting the compilation optimizations #2020-08-1904:26dasluThanks @dpsutton!#2020-08-1904:46daslu(doesn't seem to help 😊 🙏 )#2020-08-1905:42dasluIt looks like browser caching was at least part of the problem, since on different browsers I got different behaviors. Now I cannot reproduce it, and everything seems to be fine. 🤔#2020-08-1908:28thheller@daslu :resouce-paths in not a thing in shadow-cljs.edn and wouldn't apply anyways since you have :lein true and all classpath management is done by project.clj. setting :optimizations in :dev only does absolutely nothing since :dev ALWAYS forces :none and that cannot be modified. you can also leave :devtools always in since it will be ignored in release builds.#2020-08-1908:28thhelleryou should really consider bundling you CSS properly. putting a bunch of paths into :dev-http like that is not going to end well 😛#2020-08-1908:29thhellerFWIW watch and compile differ in that watch injects a bunch of extra REPL/hot-reloaded extra code, otherwise they should be the same#2020-08-1908:32daslu@thheller thank you so much for this kind and detailed mentoring. This is really enlightening and helps so much. ❤️#2020-08-1908:33thhellerah and also only use :dev-http since it will conflict with :devtools {:http-port ..} otherwise#2020-08-1908:34thheller
{:lein true
 :dev-http {8080 ["resources/public/"
                  "target"
                  "classpath:resources"
                  "classpath:resources/public"
                  "node_modules"
                  "node_modules/leaflet/dist"
                  "node_modules/mathjax/es5"
                  "node_modules/ag-grid-community"]}
 :builds {:app {:output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :target :browser
                :modules {:main {:init-fn gorilla-notes.main/main!}}
                :devtools {:after-load gorilla-notes.main/reload!}}}}
#2020-08-1908:35thhellerthat is the leftover config if all the invalid stuff is removed 😉#2020-08-1908:41daslu🙏#2020-08-1914:36p-himikThe :bootstrap target seems to be undocumented, and the anchor https://shadow-cljs.github.io/docs/UsersGuide.html#target-bootstrap (used by the very first mention of :bootstrap in the user's guide) is not attached to anything. Is it an intentional omission?#2020-08-1914:39Sam Ritchiehey all! @mhuebert, question for you if you have a moment...#2020-08-1914:51mhueberthi @sritchie09! it does look like encore may be the issue here — in the source https://github.com/ptaoussanis/encore/tree/master/src/taoensso I see cljx files... is there another version somewhere ported to use cljc?#2020-08-1914:52Sam Ritchie@mhuebert I don't think he has one, but of course I could fork it, or exclude. I will say that I went into the jar when debugging and deleted the cljx file, leaving only the generated cljs and clj files#2020-08-1914:52Sam Ritchieand this same behavior still occurred#2020-08-1914:52Sam RitchieI can definitely try swapping that dependency and seeing if we have any luck, I'm only pulling it in transitively to do logging#2020-08-1914:53mhuebertit probably is not selfhost compatible #2020-08-1914:53mhuebertis it necessary? #2020-08-1914:55Sam RitchieI can exclude it with a little work by replacing the logging calls in sicmutils#2020-08-1914:55mhuebertsubtle tricks are often needed for selfhost compatible macros, see https://github.com/cgrand/macrovich#2020-08-1914:55Sam Ritchieyes, I expect I'm going to have to do this too for sicmutils#2020-08-1914:56Sam Ritchiewhich is totally fine! I've been aiming at Maria for a few weeks, and I'm so close...#2020-08-1914:56mhuebertor you can try adding the encore clj namespace to the :exclude vector#2020-08-1914:56mhuebertif you don’t need the macro available in the editor #2020-08-1914:56Sam Ritchielet me try again, but compilation does fail, I believe#2020-08-1914:57mhuebertis your code using encore directly or is it a transitive dep?#2020-08-1914:57p-himikIf encore is indeed not compatible with bootstrapped CLJS, maybe it's worth creating an issue in its repo.#2020-08-1914:59Sam Ritchieokay, that triggers The required namespace "taoensso.encore" is not available, it was required by "taoensso/timbre.cljs".#2020-08-1914:59Sam Ritchie`#2020-08-1914:59Sam Ritchieagree that this merits an issue in their repo#2020-08-1914:59Sam Ritchiebtw I think we're chatting friday, with Jack and Dave, if you're free#2020-08-1914:40Sam RitchieI'm trying to get Maria working with https://github.com/littleredcomputer/sicmutils, so we can do physics, calculus etc in Maria#2020-08-1914:40Sam RitchieI'm hitting an issue that I've nailed down to something strange in the bootstrap build#2020-08-1914:40Sam Ritchiehence @p-himik’s Q#2020-08-1914:41Sam Ritchiebasically, if I use this entry in shadow-cljs.edn, as the project currently uses:
:bootstrap
  {:target :bootstrap
   :output-dir "public/js/compiled/bootstrap"
   :module-hash-names true
   :entries [maria.user]
   :exclude [cljs.js]}
#2020-08-1914:42Sam Ritchiethen live evaluation in Maria works great! but the build breaks with this error:
[:bootstrap] Build failure:
The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
 + /live.html
#2020-08-1914:42Sam Ritchieif I change the entries line to this:
:modules {:main {:entries [maria.user]}}
#2020-08-1914:42Sam Ritchiethen the build can successfully complete...#2020-08-1914:43Sam Ritchie#2020-08-1914:44Sam Ritchiebut I see this when I try to evaluate anything#2020-08-1914:45Sam Ritchiethis reproduces on the sritchie/last_attempt branch here: https://github.com/sritchie/maria/tree/sritchie/last_attempt#2020-08-1914:45Sam Ritchiedoes anyone with knowledge of :bootstrap have any thoughts about what's going on, and why this bare :entries form is both required, but seems to get in the way of cljs compilation?#2020-08-1914:46Sam Ritchiein the shadow-bootstrap-example I see the same thing: https://github.com/mhuebert/shadow-bootstrap-example/blob/master/shadow-cljs.edn#L10#2020-08-1915:06thheller@sritchie09 :target :bootstrap does not support :modules so using it breaks stuff. :module-hash-names also has no effect. you just specify :entries and it will compile those to be available in self-hosted#2020-08-1915:06thhelleryou run into a namespace that requires java and that breaks compilation#2020-08-1915:07thhelleryou can maybe just exclude it so :exclude [cljs.js taoensso.encore]#2020-08-1915:09thhellerits often the case that libraries contain macros that aren't self host compatible#2020-08-1915:11thhellerall bootstrap relating things are severly lacking in documentation. mostly because I don't know how half the stuff works either and nobody else bothered to write anything.#2020-08-1915:19Sam Ritchie@thheller I'm taking a pass at swapping out the logging library -#2020-08-1915:20Sam Ritchieit's not that important, and might bebest#2020-08-1915:20Sam Ritchieexcluding failed on me, unfortunately#2020-08-1915:20thhellerfailed how?#2020-08-1915:22Sam Ritchieoh, sorry, annoying lack of info#2020-08-1915:22Sam Ritchietimbre requires it,#2020-08-1915:23Sam Ritchiethe logging library I was using, so excluding it caused a "encore not found" error#2020-08-1915:23thhellertaoensso.encore definitely does not support self-hosted CLJS#2020-08-1915:23thhelleryou are using it in self-hosted?#2020-08-1915:24Sam RitchieI've got a physics library converted to cljs, and I'm trying to make it available in the Maria environment#2020-08-1915:24Sam Ritchiewhich runs in self-hosted mode#2020-08-1915:25thhellerah#2020-08-1915:25Sam Ritchiethis MIGHT be the only issue... but probably there will be some macro problems inside the library#2020-08-1915:25Sam Ritchienot a big deal to convert to another logging library, of course#2020-08-1915:26thhellerwell the self-hosted variant is only needed if you actually compile something client side that uses it#2020-08-1915:26thhellerlike if you are trying to eval (encore/something foo)#2020-08-1915:27Sam Ritchiestrangely, all I was trying to do was require sicmutils.env, which depends on namespaces that depend on timbre#2020-08-1915:27Sam Ritchieokay, interesting, maybe this is deeper than we think#2020-08-1915:27Sam Ritchie
[:bootstrap] Build failure:
The required namespace "" is not available, it was required by "taoensso/encore$macros.cljc".
"clojure/java/io.clj" was found on the classpath. Maybe this library only supports CLJ?
 + /live.html
#2020-08-1915:27Sam Ritchiethis problem occurred on build#2020-08-1915:28Sam Ritchienot on any eval -#2020-08-1915:28Sam Ritchiesending the exclude error#2020-08-1915:29thhellerthe above is expected. that namespace cannot be compiled for self-hosted.#2020-08-1915:30Sam Ritchiewait a second, I may have misunderstood a suggestion -#2020-08-1915:30mhuebertadding taoensso.encore to :exclude - next to cljs.js - was tried already?#2020-08-1915:30Sam RitchieI was excluding from the actual jar... I"m trying to add that ns to exclude now.#2020-08-1915:31Sam Ritchiesorry about that! yes, I had excluded the transitive encore dep in `deps.edn#2020-08-1915:31thhelleryeah I meant :exclude in the build config#2020-08-1915:31Sam Ritchiethis is promising, I see The required namespace "io.aviso.exception" is not available, it was required by "taoensso/timbre$macros.cljc".#2020-08-1915:32thhellersame thing.#2020-08-1915:32Sam Ritchieyup, chasing it down#2020-08-1915:32thhellerprobably just exclude taoensso.timbre#2020-08-1915:33Sam Ritchiewe may a winner...#2020-08-1915:35Sam Ritchieokay, boom, I think we have more errors, but that may get me past that one#2020-08-1915:40Sam Ritchieokay, amazing, I think we're in business!!!#2020-08-1915:40Sam Ritchiequestion for you both...#2020-08-1915:40Sam Ritchielet's say I do have a macro that I want to use in Maria#2020-08-1915:41Sam Ritchie
#?(:clj
   (defmacro bootstrap-repl!
     "Bootstraps a repl or Clojure namespace by requiring all public vars from
     sicmutils.env. From (This will only work at a repl in Clojurescript.)"
     []
     `(require '~['sicmutils.env
                  :refer
                  (into [] (keys (ns-publics 'sicmutils.env)))])))
#2020-08-1915:41Sam Ritchiethis is probably a case where I need to use macrovich?#2020-08-1915:44Sam Ritchieor perhaps just specifically refer this macro vs [sicmutils.env :as e :include-macros true]#2020-08-1915:55Sam RitchieYES! you're both geniuses, scholars, athletes, whatever you want to be#2020-08-1915:55Sam Ritchie#2020-08-1915:56Sam RitchieThe lagrangian for a pendulum, it's alive#2020-08-1915:56thhelleryou definitely want to stay away from macros doing anything with require#2020-08-1915:56thhellerthats black magic that doesn't work at all in CLJS#2020-08-1915:57thhelleryou can however just modify the compiler-env directly if you want 😉#2020-08-1915:57thhellerthats probably easier#2020-08-1915:59Sam Ritchieyup, I just inserted a monster require block#2020-08-1916:00Sam Ritchiethe only thing remaining is that the repl can't see any macros from env#2020-08-1916:00Sam Ritchie
#?(:clj
   (defmacro with-literal-functions
     [& args]
     `(f/with-literal-functions 
#2020-08-1916:01Sam Ritchie@thheller it does look like I can access other macros here...#2020-08-1916:01Sam Ritchieobh, obviously, gotta strip the :clj: #2020-08-1916:02thhellerself-host macros is where my understanding of all of this ends. its weird and scary 😛#2020-08-1916:04Sam RitchieI wade into the unknown#2020-08-1916:12Sam Ritchie#2020-08-1916:12Sam Ritchieholy mackerel...#2020-08-1916:12Sam Ritchiemacros work too. thank you all!!!#2020-08-1916:16Sam Ritchiefor anyone curious, what this means is that we can now run all code and exercises from "Structure and Interpretation of Classical Mechanics" live in a browser, via Maria https://www.amazon.com/Structure-Interpretation-Classical-Mechanics-Sussman/dp/0262194554#2020-08-1916:17Sam RitchieSussman wrote another book called Functional Differential Geometry, that implements all of the math of general relativity... all of that works too. The reason for this port is that I want to add the ability to take those equations above, and live-generate an animation, right when you evaluate the code... and have it update when you change things#2020-08-1916:17Sam Ritchie2020-07-01 21.20.35.gif#2020-08-1916:18Sam Ritchiehttps://i.imgur.com/e4ajq5r.gif#2020-08-1916:18Sam Ritchieyou can write down a "lagrangian" that describes this system, but it's a bit frustrating to not get to see it work. so now with cljs we'll be able to!#2020-08-1916:19thhellerlooks like black magic to me. math and physics are even scarier than self-host macros 😛#2020-08-1916:19Sam Ritchiehaha, I hear you and agree#2020-08-1916:20Sam Ritchiethat's the problem I'm trying to solve, making it less like black magic and more like a strange game engine (powering the Universe Game that we're all playing)#2020-08-1916:21Sam Ritchieanimation, math, code next to each other. pin function inputs to sliders, and watch everything change in sync, Bret Victor style... http://worrydream.com/#!/Tangle#2020-08-1916:21Sam Ritchieokay, thanks again, all#2020-08-1918:05mhuebert@sritchie09 fantastic that you got this working!#2020-08-1921:58daslu@sritchie09 that is wonderful!#2020-08-2000:04Jack ArringtonI've noticed in my shadow-cljs project that when there is an error I don't get any useful line number -- just a bunch of references to browser.cljs. Is this a shadow-cljs limitation or a Clojurescript one, and is there something I can do about it?#2020-08-2000:06Jack ArringtonI keep hearing that CLJS has very well-engineered source maps, but it's pretty frustrating to get a basic arity error or something of that nature and have zero idea where it's coming from. I'm hacking on a small project with Clojure right now, but if it grows searching around blindly until I figure out what section of the code an error came from definitely isn't going to be maintainable#2020-08-2000:06Jack ArringtonOh and this is running in watch-mode, if that has anything to do with it#2020-08-2007:52thheller@mail985 you need to be a bit more specific. I have no clue what your problem is. make screenshot or something that shows what you are talking about.#2020-08-2012:48nivekuilI can't seem to get css reloading working. I have a hiccup-generated page loading a css file at "/css/view.css", which on the fs is at resources/public/css/view.css. I'm not using :dev-http so I have {:target :browser ... :devtools {:watch-dir "public" ...} in shadow-cljs.edn. does that look right? maybe I'm missing something in deps.edn? shadow command is server
#2020-08-2012:54thheller@kevin842 shjould be :watch-dir "resources/public"#2020-08-2012:58nivekuilhm.. I swear I had already tried that but I just tried it again and it worked. thanks :P#2020-08-2012:59nivekuilmaybe I was thrown off by the loading spinner that pops up on the HUD when shadow-cljs.edn is edited, but didn't restart the server#2020-08-2013:51bendlasI have a problem with (:require ["docx4js"]) with :target :react-native, it works, but with :target :browser it throws
[:app] Build failure:
The required JS dependency "/node_modules/docx4js/lib" is not available, it was required by "shadow.js.shim.module$node_modules$docx4js$lib$props.js".

Dependency Trace:
        r8/contree/styled_system.cljs
        node_modules/docx4js/lib/index.js
        node_modules/docx4js/lib/openxml/docx/document.js
        node_modules/docx4js/lib/openxml/document.js
        node_modules/docx4js/lib/document.js
        shadow.js.shim.module.js
Apparently it trips over requiring node_modules/docx4js/lib/$props.js
#2020-08-2014:02thhellerah. of course there are npm files that have $ in their name ... why wouldn't there be 😛#2020-08-2014:04thhellerdue to https://clojure.atlassian.net/browse/CLJS-3235 that is now a special char. guess I'll have to disable that functionality for node_modules ...#2020-08-2014:06bendlas😅 can I quickfix this somehow, short of webpacking that lib?#2020-08-2014:08thhellerno clue if you are even on a version with that feature yet. don't have time to look into the issue right now but it'd be my guess that its $#2020-08-2014:08thhellerin which case you can only "fix" it by renaming the file and requires thereof#2020-08-2014:08bendlasok, thanks!#2020-08-2016:02lilactownI have a .cljc file which uses a namespaced keyword in a :clj branch. When trying to evaluate that in a CLJS REPL, it barfs:
(cljs.core/load-file "/Users/lilactown/Code/amperity/app/service/web/web-ui/src/amperity/web/mx_segment/core.cljs")
------ ERROR -------------------------------------------------------------------
 File: /Users/lilactown/Code/amperity/app/service/segment/segment-core/src/clj/amperity/mx_segment/folder.cljc:52:20
--------------------------------------------------------------------------------
  49 |    (do
  50 |      (pc/defresolver list-resolver
  51 |        [{:keys [tree] :as env} _input]
  52 |        {::pc/output [{::all config-keys}]}
--------------------------^-----------------------------------------------------
amperity/mx_segment/folder.cljc [line 52, col 20] Invalid keyword: ::pc/output.

--------------------------------------------------------------------------------
  53 |        (d/chain
  54 |          (list tree)
  55 |          (fn [seg-list]
  56 |            {::all seg-list})))
--------------------------------------------------------------------------------
#2020-08-2016:03lilactownthe namespace only exists in the :clj branch as well, so if the reader is trying to interpret it it makes sense why it would barf. I would just expect it skip it since it’s in a reader conditional#2020-08-2016:03lilactownfull offending code:
#?(:clj
   (do
     (pc/defresolver list-resolver
       [{:keys [tree] :as env} _input]
       {::pc/output [{::all config-keys}]}
       (d/chain
         (list tree)
         (fn [seg-list]
           {::all seg-list})))


     (pc/defresolver get-resolver
       [{:keys [tree] :as env} {:keys [::id] :as input}]
       {::pc/input #{::id}
        ::pc/output [{::node config-keys}]}
       (d/chain
         (get tree id)
         (fn [node]
           {::node node})))))
#2020-08-2016:05thheller@lilactown either branch of the code must still be readable and as such must have that alias. not anything shadow-cljs can do anything about.#2020-08-2016:06thhelleryou can fake whatever alias you want but it must exist regardless#2020-08-2016:06thhellerwould need to be fixed in clojure and tools.reader if you want to take that on 😉#2020-08-2016:07lilactownalright 😄 thanks#2020-08-2016:09lilactownit’s pathom, so it is cljc. I’d rather not include all of pathom in my bundle if not necessary tho#2020-08-2016:09lilactowndo you think pathom would get :knife: if I require it but never refer it?#2020-08-2016:10thhellerlike I said .. only the alias needs to exist. doesn't matter what it points to (:require [clojure.string :as pc])#2020-08-2016:10lilactown(I can check this myself just thought I would ask if you know off hand)#2020-08-2016:10lilactownyeah that’s true!#2020-08-2016:15bendlasRegarding aliases, may I direct your attention to https://clojure.atlassian.net/browse/CLJ-2030 and https://clojure.atlassian.net/browse/CLJ-2123#2020-08-2016:15lilactownanother question: I recently updated to 2.10.21. I’m now receiving an error on release:
--- amperity/web/stitch/report_v2/viz.js:1
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
#2020-08-2016:16lilactownthis file is an es module - I remember rewriting it from a goog module to es syntax#2020-08-2016:16lilactowndid the ES module require-by-path get removed?#2020-08-2016:17lilactownor is there some way that I need to signal that it is in fact an es module, and not a goog module? (other than use import and export, which it does)#2020-08-2016:20thhellerI haven't looked into this yet but there have been other reports#2020-08-2016:20bendlasNot sure if that will answer your question, but I'm adding node modules in a separate source folder and make them available as package.json dependencies: "local-package": "file:./local-package-src"#2020-08-2016:20thhellernot nothing should have changed in that regard. but it bumped closure which tends to change stuff ...#2020-08-2016:22thheller@bendlas I think this particular aliasing problem warrants a new issue. given that the code is immediately discarded anyways it shouldn't attempt to resolve it.#2020-08-2016:25bendlasYou mean about the missing ::alias/ns behind a read-cond? Yeah, that would be good to get fixed in the reader ...#2020-08-2016:28thhellerI never tried but symbols may have the same problem. but yes on read-cond branches that aren't active a missing alias shouldn't break the code.#2020-08-2016:28thheller
`alias/foo
#2020-08-2016:29thhelleris also resolved by the reader. probably breaks too.#2020-08-2016:30bendlasUnfortunately, clojure.tools.reader/*alias-map* seems to be the only facility for that. I guess that could be hacked, by implementing ILookup, but there would be many open questions then, about how to proceed after read-cond has been resolved ...#2020-08-2016:31thhellerwould really need to be fixed in clojure first imho#2020-08-2016:31thhellerno point in adding stuff to tools.reader that clojure doesn't support#2020-08-2016:32bendlastrue. clojure doesn't have :read-cond :preserve, does it?#2020-08-2016:33thhellerno clue. whats that?#2020-08-2016:33bendlasoh, it does: https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/read#2020-08-2016:33bendlasthat's for retaining read-cond branches#2020-08-2016:33thhellerah. and there goes all hope for getting this "fixed" I guess 😛#2020-08-2016:34bendlasso then, boxing ::alias/kw would be part of the deal ..#2020-08-2016:24lilactownis there a known good version I can downgrade to w.r.t. es module issue, that’s better than going back to what I was on (2.8.61 😅 )#2020-08-2016:24thhellersince I don't know what the issue is I cannot possibly answer that#2020-08-2016:26lilactownk#2020-08-2016:56lilactownI’ve narrowed it down to being introduced in 2.9.7#2020-08-2017:00lilactownostensibly https://github.com/thheller/shadow-cljs/commit/22b078a77444cc99ba22a87277f82286f0f90437#2020-08-2017:04thhellerthanks. I'll see if I can figure it out.#2020-08-2017:43thheller@bendlas your issue should be fixed in 2.10.22.#2020-08-2019:35bendlasYay \o/#2020-08-2109:54bendlasSeems lile that lib does more freaky stuff, that we're tripping over: • require("f" + "s") at https://github.com/lalalic/docx4js/blob/84ae60e0395e3cef066055d11392732b65c76d90/lib/document.js#L206
[:app] Compiling ...
[2020-08-21 11:47:11.520 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/docx4js/lib/document.js", :requires [{:line 206, :column 14}]}
#2020-08-2109:58bendlasThen there is
[:app] Build failure:
The required JS dependency "entities/maps/entities.json" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js".

Dependency Trace:
        r8/contree/styled_system.cljs
        node_modules/docx4js/lib/index.js
        node_modules/docx4js/lib/openxml/docx/document.js
        node_modules/docx4js/lib/openxml/document.js
        node_modules/docx4js/lib/document.js
        node_modules/docx4js/lib/$props.js
        node_modules/cheerio/index.js
        node_modules/cheerio/lib/cheerio.js
        node_modules/cheerio/lib/parse.js
        node_modules/htmlparser2/lib/index.js
        node_modules/htmlparser2/lib/Parser.js
        node_modules/htmlparser2/lib/Tokenizer.js
, where it refers to node_modules/entities/lib/maps/entities.json. Not sure, if that's related to the other error, somehow ..
#2020-08-2110:00thhellerthats probably a version conflict. like expecting an older/newer version of entities#2020-08-2110:02bendlasstrange .. again, in :target :react-native it works ...#2020-08-2110:02thhelleryeah dynamic requires like the faked require("fs") are just to hide them from packagers. pretty stupid but I guess thats common in the JS world#2020-08-2110:02bendlasthought so ..#2020-08-2110:02thheller:target :react-native does no bundling whatsoever by shadow-cljs. its all done by react-native metro#2020-08-2110:02thhellerand they are happy to include 2 versions of the same library. so you just get entities twice#2020-08-2110:03bendlasI mean, I'm happy to browserify/webpack this stuff, just wanting to let you know ...#2020-08-2110:03thhellershadow-cljs does not do that and will never do that.#2020-08-2110:04bendlasoh right, it's there 3 times
entities
htmlparser2/node_modules/entities
cheerio/node_modules/entities
#2020-08-2110:04thhellerfun times .. then you get 3 versions of it in react-native. totally doesn't bloat your final bundle at all 😉#2020-08-2110:05bendlas... as opposed to maven's randomly changing your version. it's really pest vs cholera 😞#2020-08-2110:06thhelleryou can set :js-options {:resolve {"entities/maps/entities.json" {:target :npm :require "entities/lib/maps/entities.json"}}} I think. never actually tried using it to override direct references but it should work#2020-08-2110:07bendlaswhat should be the key to the inner map?#2020-08-2110:07thhellerin your build config that is#2020-08-2110:07bendlasoh, i see#2020-08-2110:07bendlasthanks, I'll try!#2020-08-2110:08thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2020-08-2110:10bendlasHa! Neat! That actually worked. 🙂#2020-08-2110:10bendlasHad to also do it for 2 other files, but that's really good to know#2020-08-2110:11bendlasthe dynamic require is just a warning, and I'm not hitting the require("fs") path in the browser anyway#2020-08-2110:12bendlasGood times. Thanks!#2020-08-2110:21thhelleryeah thats why requires like that are just a warning and not an error 😛#2020-08-2017:47royalaid@thheller at my new job we are doing a lot of serverless stuff so I end up having to jump into cloudwatch and copy and pasting edn a bunch. I am wondering if there is a way I can leverage tap> from within the AWS lambdas and point it at a kind of IRC Bouncer/inbox style thing and then pick the tap>ed values up on my local machine using shadow inspect#2020-08-2017:49thhellerin theory yes. the code isn't written in practice though 😉#2020-08-2017:50thhellerhmm don't the lambdas die after they have done their work?#2020-08-2017:51thhellertap> never actually transfers the full value so that would be a problem#2020-08-2017:52thhelleryou could automate the EDN copying. if you get it to your shadow-cljs instance you can just tap> it from CLJ#2020-08-2018:34royalaidThe lambda's do die after#2020-08-2018:34royalaidI was under the impression that it actually sent a message#2020-08-2018:34royalaidBut I guess the bouncer thing could handle that#2020-08-2018:34royalaidhmmmm#2020-08-2018:34royalaidGonna have to poke around with tap I guess#2020-08-2020:15jeff tangAfter I moved to an Electron app, I began getting this async-dispatch-N error when I shadow-cljs watch renderer . It happens non-deterministically, and usually mentions @material-ui/icons . The build is `
:renderer {:target :browser
                     :output-dir "resources/public/js/compiled"
                     :asset-path "js/compiled"

                     :modules {:renderer {:init-fn athens.core/init}}

                     :compiler-options {:closure-warnings {:global-this :off}
                                        :closure-defines {re-frame.trace.trace-enabled? true}}

                     :devtools {:preloads [devtools.preload
                                           day8.re-frame.trace.preload]}}
#2020-08-2020:17thheller@tangj1122 only guess I have is that you maybe have a bad core.async version#2020-08-2020:17thhellermake sure it matches the version shadow-cljs needs#2020-08-2020:17thhellercheck other possibly dependency conflicts while you are at it 😛#2020-08-2020:20thhellerbut could be a simple overload. @material-ui/icons adds thousands of files to your build. I fixed something to that extent in some version. can't remember which.#2020-08-2020:26jeff tanghmm cljs.core.async is not a dependency in this project#2020-08-2020:27thhellercheck lein deps :tree for conflicts#2020-08-2020:27thhelleror maybe just try upgrading. could just be the overload issue I fixed not too long ago#2020-08-2020:31jeff tangok, trying to upgrade from 2.8.110 to 2.10.22#2020-08-2020:31jeff tang(no conflicts in deps tree)#2020-08-2020:42jeff tangI don't seem to be getting the error anymore, after running it 5 times. The probability is in my favor. Thanks @thheller ❤️#2020-08-2111:29Aronwhat is a proper handling of multiple watch processes? I keep having to cancel and relaunch them because I get confused by what is being shown.#2020-08-2111:31thhelleruse the UI#2020-08-2111:35AronI am unable to find the blogpost or doc segment or github issue where you described how to use it. Please remind me where it is#2020-08-2111:36thhellershadow-cljs server and then its printed on startup shadow-cljs - server version: 2.8.110 running at #2020-08-2111:37thhellerso usually http://localhost:9630#2020-08-2111:37Aronso far I was with you, I did open it, but I don't know where from here 🙂#2020-08-2111:38thhelleryou click builds and "start watch" for whatever builds you want running#2020-08-2111:38thhellerI assuming here that you are on a somewhat recent version where the UI actually works#2020-08-2111:39thhellerwhen you click the name of a build it'll take you to the build output of that build and won't distract you with output of the others#2020-08-2111:40AronThe second thing I am trying to watch is tests with puppeteer that I build with :target :node-test#2020-08-2111:40AronAnd I am trying to use it in headful mode#2020-08-2111:41AronLaunching it from the UI I don't know where the output it or why the puppeteer windows don't appear#2020-08-2111:41thhellerwell for one you should never use :autorun true#2020-08-2111:42thhellerrun it manually ... then you never have to guess where your output is#2020-08-2111:42Aronwell, why is there then? 🙂#2020-08-2111:42thhelleras for puppeteer ... no clue. never used it.#2020-08-2111:42thhellerbecause people asked for it and I foolishly said yes#2020-08-2111:43Aronok, but some convenient way to automatically start the browser again when I close it would be really nice since otherwise I will have to repeat this hundreds of times every day#2020-08-2111:44thhellerI don't know what you mean#2020-08-2111:46Aronthese are automated tests. The browser loads up and does a bunch of things like a manual tester would, then stays open so I can work with it. But when I need to test if my work is good, I close the browser and autorun relaunches it immediatelly. But with your suggestion, I would have to have a separate terminal where I would have it in bash history and every time I close the browser I would hunt this terminal down and press up arrow and enter 🙂#2020-08-2111:48AronIf there is a better flow to write these tests, I am very open to learning it. This is how I am used to do it, but not something I like.#2020-08-2111:54thhellerI don't really see how the question is related to shadow-cljs. I do not use puppeteer and have no clue how to use it. if your concern is not using :autorun true you can easily use other tools to achieve the same without being coupled to shadow-cljs. eg. https://github.com/kimmobrunfeldt/chokidar-cli just have that watch the :output-to file of the build and do stuff when it changes?#2020-08-2112:02thhellerI want to build a proper "test runner" at some point but its a whole lot of work and not very high priority for me.#2020-08-2112:08AronIt might be unrelated if it doesn't support it already, you are absolutely correct. I will try to look for other solutions#2020-08-2112:52AronAnother reason I used npm scripts to start the watch process was that I could use the same build both for testing and development, with --config-merge. Now it seems I have to create separated builds or use environment variables. Neither option is better than config-merge.#2020-08-2112:55thhellerI feel like you are kinda expecting miracles here. I can only make suggestions. Given how little information I have about what you are actually doing they may fit or not. It is up to you to decide what you want to do and how you want to do it.#2020-08-2113:03AronSorry if that's how it comes through. I am actually glad I have a place to ask questions and I get some answers. No expectations whatsoever. My understanding was that you are against using environment variables and suggest instead config-merge with goog-define. This option seems not to be available if I follow your most recent suggestion. I do not expect you to have an answer (I don't know how to convey this without explicitly stating it...), but if you do have some suggestion on how to use the UI + use a single :target :node-test build compile watched + then launch the tests with different modes, one for command line testing through npm test, another for development, maybe with chokidar or similar ... but without using environment variables, then I would like to know. Normally I wouldn't ask such detailed questions, I am used to using lots of environment variables in node and even in the browser, I am not even sure what's the reasoning against them.#2020-08-2113:07thhellerFirst you should maybe explain what you are using environment variables for#2020-08-2113:07thhellersince environment variables in node builds can just be actual environment variables. I don't see why they need to become part of the build config?#2020-08-2113:08thhellerlike if you want to access them at runtime just use js/process.env.WHATEVER_ENV_YOU_WANT#2020-08-2113:08thhellerI also don't understand how you are using --config-merge to use one build for testing and development.#2020-08-2113:14Aron"shadow-cljs watch test --config-merge \"{:closure-defines {tests.core/TEST_MODE \"tdd\" tests.core/SITE_URL \\\"$LOCAL_NAMESERVER\\\"}}\" "#2020-08-2113:16AronI didn't think about just using process from node. I was too hung up on finding out what already is there.#2020-08-2113:18thhellerif you are running node definitely just use js/process.env. :closure-defines is definitely worse than doing that and pretty much only used by people in browser builds since that can't otherwise access your environment variables#2020-08-2113:19Aronthanks, I will do that#2020-08-2114:06dehliHello! I have a question about shadow’s watch command. Is it possible to have the artifact built not have a dependency on ws?#2020-08-2114:08dehliI’d like to have watch running and then be able to quickly upload the artifact to AWS as I make code changes without having to do a full build every time#2020-08-2114:10Wilson Velezhi, I’m starting to play with nubank/workspaces and I set a build called cards as explained here: https://github.com/nubank/workspaces#with-shadow-cljs
{:source-paths ["src"]
 :nrepl        {:port 3333}
 :dependencies [[binaryage/devtools "1.0.2"]
                [reagent "1.0.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom]]
                [nubank/workspaces "1.0.15"]]
 :dev-http     {8080 ["target/" "assets/"]}
 :builds       {:app   {:output-dir "target/"
                        :asset-path "."
                        :target     :browser
                        :modules    {:main {:init-fn app.main/main!}}}
                :cards {:target     nubank.workspaces.shadow-cljs.target
                        :ns-regexp  "-(test|cards)$"
                        :output-dir "target/workspaces"
                        :asset-path "workspaces"
                        :preloads   []}}}     
#2020-08-2114:11Wilson Velezbut when I “watch” the build I’m getting this error http://localhost:9630/build/cards X Compilation failed.
TBD, classpath indexing is gone.
{}
ExceptionInfo: TBD, classpath indexing is gone.
	shadow.build.classpath/get-all-resources (classpath.clj:1225)
	shadow.build.classpath/get-all-resources (classpath.clj:1223)
	nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:10)
	nubank.workspaces.shadow-cljs.target/find-namespaces-by-regexp (target.clj:9)
	nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:36)
	nubank.workspaces.shadow-cljs.target/resolve-cards-and-tests (target.clj:30)
	nubank.workspaces.shadow-cljs.target/process (target.clj:61)
	nubank.workspaces.shadow-cljs.target/process (target.clj:53)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--13688 (build.clj:162)
	shadow.build/process-stage (build.clj:159)
	shadow.build/process-stage (build.clj:151)
	shadow.build/resolve (build.clj:407)
	shadow.build/resolve (build.clj:403)
	shadow.build/compile (build.clj:441)
	shadow.build/compile (build.clj:434)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:345)
	shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:440)
	shadow.cljs.devtools.server.worker.impl/fn--15030 (impl.clj:429)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808/fn--14816 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--14807/fn--14808 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--14807 (util.clj:257)
	java.lang.Thread.run (Thread.java:745)
#2020-08-2114:15thheller@wvelezva see https://github.com/nubank/workspaces/issues/42. I thought that was fixed. maybe need a different version?#2020-08-2114:16thhellerhmm no still open. so I guess not fixed.#2020-08-2114:16mkarpJust tried using :karma target for the first time — it works like a charm :+1: Thank you for it!#2020-08-2114:18Wilson VelezI’m working with the lastest verstions of shadow and workspaces#2020-08-2114:19Wilson Velezshould I ask in workspaces channel?#2020-08-2114:26thhelleryou can just use the :target :browser-test. don't need to use the workspaces target#2020-08-2114:29thheller
{:target     :browser-test
 :ns-regexp  "-(test|cards)$"
 :output-dir "target/workspaces"
 :asset-path "workspaces"
 :runner-ns  nubank.workspaces.shadow-cljs.mount
 :devtools
 {:before-load nubank.workspaces.core/before-load
  :after-load  nubank.workspaces.core/after-load}}
#2020-08-2114:29thhellermight be enough? don't think the custom target does anything else#2020-08-2114:32Wilson Velezok, thanks @thheller I will give it a try#2020-08-2206:06smnplkHi, I am using shadow-cljs via leiningen. Everything works perfectly, except when I do lein uberjar I get the following error#2020-08-2206:07smnplkCan't find 'shadow.cljs.devtools.cli' as .class or .clj for lein run: please check the spelling. Syntax error (FileNotFoundException) compiling at (/tmp/form-init11854498876761345265.clj:1:74). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.#2020-08-2206:10smnplk
:cljs {:source-paths ["src/cljs"]
                    :dependencies [
                                   [org.clojure/clojurescript "1.10.773" :scope "provided"]
                                   [com.google.javascript/closure-compiler-unshaded "v20200719"]
                                   [org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
                                   [thheller/shadow-cljs "2.10.22"]
                                   [reagent "0.8.1"]
                                   [re-frame "0.10.7"]
                                   [kibu/pushy "0.3.8"]
                                   [fork "2.0.0"]
                                   [vlad "3.3.2"]
                                   [day8.re-frame/http-fx "v0.2.0"]]}
             :uberjar
             {:resource-paths ["resources" "resources/sql"]
              :source-paths ^:replace ["src/clj" "src/cljc"]
              :prep-tasks ["compile"
                           ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
              :hooks []
              :omit-source true
              :aot :all}})
here are the profiles entries in my project.clj. If I run lein run -m shadow.cljs.devtools.cli release app manually in a console, everything works fine.
#2020-08-2206:34smnplki think i know what's wrong, i need to activate the cljs profile, using with-profile...tried this :prep-tasks ["compile" ["with-profile" "+cljs" "run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]`#2020-08-2206:42smnplki get some weird StackOwerfow exception..:(#2020-08-2206:56smnplkSolved: I just had to :prep-tasks ["compile" ["with-profile" "cljs" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]]#2020-08-2214:07bbssThe app I've been working on for a while is getting a bit big (19MB...) I decided to try out the release so closure compiler can do its thing. Brought it down to 11MB, still not great. Running gzip on that brings it down to 1.6MB, which I find acceptable for the interactive app that it is.#2020-08-2214:08bbssWas expecting to run into a lot of trouble with advanced compilation but after a few minor issues it actually seems to go well. The only thing I'm not sure about is some es6 files that I ran through babel, closure doesn't like em:
Closure compilation failed with 4 errors
--- kr/models/ronde-tempel-compiled.js:6
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
..
#2020-08-2214:22bbssand without --debug for release that goes down even further to 1.2mB! nice 🙂#2020-08-2214:40thheller@bbss yeah there seems to be an issue with handling .js files. still haven't figured out what the problem is though.#2020-08-2215:30bbssalright, well if there's anything I can do to test let me know. Other .js files seem to load okay, but the ones I ran manually through babel don't, they work in watch build though.#2020-08-2215:32bbssThese files that don't load are https://github.com/react-spring/gltfjsx output of this. After which I run it through babel. They turn a webGL file into a react class.#2020-08-2215:37Sam Ritchie@thheller Q for you about packaging a cljs dependency for shadow-cljs compatibility if you have a second - I previously had packaged "fraction.js" in cljsjs, using your advice, and that is working great#2020-08-2215:38Sam Ritchiebut the npm package has a bigfraction.js living inside of it too, that I'd love to package up as a different dependency#2020-08-2215:39Sam RitchieWhen I built the fraction.js package you had noted I needed a :global-export entry that matched the NPM package, which I did and again that works great: https://github.com/cljsjs/packages/blob/master/fraction/build.boot#L35#2020-08-2215:40Sam Ritchiebut what to do for an NPM dependency that packages up TWO files, with two identical namespaces? Do I make them... both export "fraction.js", and then this is on the user to only include one of cljsjs/fraction` vs cljsjs/bigfraction?#2020-08-2215:40Sam Ritchiethat would work, but I wanted to check before I contribute to someone else's dependency issues down the road. Thanks anyone who has insight here!#2020-08-2216:13thheller@sritchie09 your question is confusing. I'm assuming there is a fraction.js npm package and a bigfraction.js? thats all shadow-cljs needs to know. it doesn't even look at :foreign-libs for anything#2020-08-2216:13thhellerso you are probably asking what to do for builds NOT using shadow-cljs?#2020-08-2216:14Sam RitchieThere’s not a bigfraction.js #2020-08-2216:14Sam Ritchie@thheller I think he just packages that file inside fraction.js#2020-08-2216:15Sam Ritchiehttps://github.com/infusion/Fraction.js/blob/ac2a406f0da4d06157cfb02d04c24d269575c386/tests/fraction.test.js#L3#2020-08-2216:15Sam Ritchieand then tests it like this#2020-08-2216:15Sam Ritchiemaybe it's a work in progress, and the answer is to publish it separately using cljsjs and alias it as bigfraction?#2020-08-2216:17thhellerah so in shadow-cljs that would be (:require ["fraction.js/bigfraction.js" :as bf])#2020-08-2216:18thhellerno clue how you want to bundle that for cljsjs if its the same package?#2020-08-2216:19Sam Ritchieoh, nice, amazing#2020-08-2216:19Sam Ritchie@thheller I suspect I can do this trick:#2020-08-2216:19Sam Ritchiehttps://github.com/cljsjs/packages/blob/master/fraction/resources/package.json#L32#2020-08-2216:21Sam Ritchiebut bundle bigfraction.js instead, and then do this in build.boot:
(deps-cljs :provides ["fraction.js/bigfraction.js", "cljsjs.bigfraction"]
              :requires []
              :global-exports '{fraction.js/bigfraction.js Fraction
                                cljsjs.bigfraction Fraction})
#2020-08-2216:21Sam Ritchieif that works, with the funky provides, then that should be shadow-cljs compatible, yeah?#2020-08-2216:22Sam RitchieI would go all shadow-cljs, but I haven't converted our build yet#2020-08-2216:22Sam Ritchieand it would be nice if non-shadow folks could use my library as a dependency#2020-08-2216:24thhellerthis doesn't sound like a good idea to me#2020-08-2216:25thhellerbut I guess its fine if its just a single file with no other dependencies#2020-08-2216:25Sam Ritchieyes, that's right#2020-08-2216:29Sam Ritchieastonishingly it works#2020-08-2216:29thhellerbut what happens if a user uses both in one project?#2020-08-2216:30thhelleror does that not happen?#2020-08-2216:30thhellerI mean if it does you definitely need to use a different global name#2020-08-2216:31Sam RitchieFor sure - I think my aliases cover this #2020-08-2216:31Sam Ritchieoh I see you mean in the bundle phase #2020-08-2216:31thhellerif both use the Fraction global it will conflict on that#2020-08-2216:32Sam RitchieYes good call, I’ll rename the bigfraction to BigFraction when I run the bundler #2020-08-2216:36Sam RitchieThanks @thheller !#2020-08-2217:26jaimeHi, I'm using d3.js (third party js lib from npm) I'm using its line function but I'm getting error curve is not a function in line 23 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 However, I can see that it is defined in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 (just few lines above its usage) Is this related to shadow-cljs? Here is snippet of how I use the line function
line (-> d3
         (.line)
         (.curve (.curveNatural d3))
         (.defined #(not (js/isNaN (.-value %))))
         (.x #(x (.-date %)))
         (.y #(y (.-value %))))

_ (-> svg
       (.append "path")
       (.datum data)
       (.attr "fill" "none")
       (.attr "stroke" "green")
       (.attr "stroke-width" 1.5)
       (.attr "d" line))
EDIT: Looking at the file generated by shadow for d3.js. The error is in line 349 in the attached snippet
#2020-08-2217:26jaimeHi, I'm using d3.js (third party js lib from npm) I'm using its line function but I'm getting error curve is not a function in line 23 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 However, I can see that it is defined in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L23 (just few lines above its usage) Is this related to shadow-cljs? Here is snippet of how I use the line function
line (-> d3
         (.line)
         (.curve (.curveNatural d3))
         (.defined #(not (js/isNaN (.-value %))))
         (.x #(x (.-date %)))
         (.y #(y (.-value %))))

_ (-> svg
       (.append "path")
       (.datum data)
       (.attr "fill" "none")
       (.attr "stroke" "green")
       (.attr "stroke-width" 1.5)
       (.attr "d" line))
EDIT: Looking at the file generated by shadow for d3.js. The error is in line 349 in the attached snippet
#2020-08-2217:38jaime#2020-08-2217:58thheller@jaime.sangcap you are looking at something completely irrelevant 😛#2020-08-2217:58thhellercurve = curveLinear, means its just a rename for some reason and the actual function is coming from import curveLinear from "./curve/linear.js";#2020-08-2217:59thhellerso I'm guessing you just need to adjust your ns :require?#2020-08-2218:00thhelleror I don't follow your problem ... d3 went through a whole lot of changes in the various versions#2020-08-2218:00thhellerso without seeing an actual full example I can only assume that you are using it wrong#2020-08-2218:27jaimeFair point 🙂 I might be doing it wrong. I will try to create a repo to reproduce the issue#2020-08-2219:09jaime@thheller The error changed a bit when I try to reproduce it in this repo https://github.com/jaimesangcap/repro-cljs-d3
app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
    at SVGPathElement.line (d3-shape.js:349)
    at SVGPathElement.eval (d3-selection.js:399)
    at Selection.each (d3-selection.js:366)
    at Selection.attr (d3-selection.js:423)
    at Object.repro_cljs_d3$core$init [as init] (core.cljs:77)
    at eval (shadow.module.app.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:836)
    at Object.env.evalLoad (app.js:2224)
    at app.js:2404
Probably I'm missing some configuration?
#2020-08-2219:11thhellerand you are porting this from which JS example/docs?#2020-08-2219:11thhellerI mean what makes you think that there should be a curve fn?#2020-08-2219:12thhellerI mean d3 got split up into a lot of smaller packages quite a while ago. are you sure that fn isn't supposed to be in one of those instead of the generic d3?#2020-08-2219:20thheller
curveBasis: (...)
curveBasisClosed: (...)
curveBasisOpen: (...)
curveBundle: (...)
curveCardinal: (...)
curveCardinalClosed: (...)
curveCardinalOpen: (...)
curveCatmullRom: (...)
curveCatmullRomClosed: (...)
curveCatmullRomOpen: (...)
curveLinear: (...)
curveLinearClosed: (...)
curveMonotoneX: (...)
curveMonotoneY: (...)
curveNatural: (...)
curveStep: (...)
curveStepAfter: (...)
curveStepBefore: (...)
#2020-08-2219:20thhellerthere are a bunch of curve fns? maybe it just was renamed?#2020-08-2219:35jaimeI saw the curve example in the readme https://github.com/d3/d3-shape#curves When using the generic d3 lib and use the line, I can draw a line chart, but the connection between the line/path are sharp. So I tried applying the curve function, but I'm getting the error above. Using the d3-shape gives the same error. I probably need to spend some time reading the docs and code#2020-08-2219:37thhellerok but that is the d3-shape package not d3?#2020-08-2219:38thheller(:require ["d3-shape" :as d3s]) (d3s/line) seems to have a .curve?#2020-08-2219:40thhellerI really don't have a clue whats going on in this code so I cannot do much#2020-08-2219:41thhellerits impossible for me to tell if you are calling this correctly#2020-08-2220:13jaimeRequiring the d3-shape as mentioned above throws error as well when calling the (.curve)
line (-> (d3s/line)
               (.curve (.curveNatural d3))
               (.defined #(not (js/isNaN (.-value %))))
               (.x #(x (.-date %)))
               (.y #(y (.-value %))))
app.js:2226 failed to load shadow.module.app.append.js TypeError: curve is not a function
    at SVGPathElement.line (d3-shape.js:349)
    at SVGPathElement.eval (d3-selection.js:399)
    at Selection.each (d3-selection.js:366)
    at Selection.attr (d3-selection.js:423)
    at Object.repro_cljs_d3$core$init [as init] (core.cljs:76)
    at eval (shadow.module.app.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:836)
    at Object.env.evalLoad (app.js:2224)
    at app.js:2427
If I understand the d3-shape code in line 10 https://github.com/d3/d3-shape/blob/master/src/line.js#L10, it creates a var curve=curveLinear , which will be called later in the closure line 23, but it seems like by the time the closure get invoked, it throws an error that var curve declared in line 10 is not a function.
#2020-08-2220:15jaimeThanks a lot for your help btw, I need some help and crack it tomorrow 🙂#2020-08-2220:16thhellerit isn't failing on the .curve#2020-08-2220:17thhellerthat works just fine#2020-08-2220:17thhellerit is failing on this line (.attr "d" line)#2020-08-2220:18jaimeYes, when it invokes the function line(data) {} which is a closure of d3s/line#2020-08-2220:19jaimeCould it be possible that the var curve has been hoisted?#2020-08-2220:25jaimeI added breakpoint here https://github.com/d3/d3-shape/blob/master/src/line.js#L23 and the value of var curve is Natural which is this file https://github.com/d3/d3-shape/blob/master/src/curve/natural.js#2020-08-2220:44thhellerits completely possible that the closure compiler rewrites this in a weird way#2020-08-2220:44thhellerbut I cannot tell what is happening in this code or if its correct#2020-08-2220:52jaimeI made a dumb interop mistake. I was invoking the function instead of property access 😅 What I'm doing (just dot) (.curve (.curveMonotoneX d3)) Correct way (dot hyphen) (.curve (.-curveMonotoneX d3))#2020-08-2220:55thhellerbtw you shouldn't be using d3 like that. it is a namespace alias so d3/curveMonotoneX would be correct and also looks better 😉#2020-08-2220:56jaimegreat tip! learned the hard way. 😆 Thanks a lot for your time#2020-08-2313:15thheller@bbss I fixed the JS import thing in 2.11.0. it is however a breaking change in that only import Thing from "npm" is now supported. The previous import * as Thing from "npm" is now the error case. I hope its the last time I have to adjust this.#2020-08-2405:49bbssOkay, checking! 🙂#2020-08-2406:33superstructorThanks for the fix @thheller That release builds re-frame fine. Just to confirm does this change the table in the docs at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages ?#2020-08-2407:01thheller@superstructor it changes the table for import inside .js files on the classpath. CLJS remains the same.#2020-08-2407:02thhellerI updated https://shadow-cljs.github.io/docs/UsersGuide.html#_language_support but I guess I'll make a note there too#2020-08-2409:04superstructorThanks for the clarification 👍 @thheller#2020-08-2410:50rickmoynihanWhat is the easiest way to require and instrument spec namespaces/functions in development mode?#2020-08-2410:51rickmoynihanset the spec ns as a preload?#2020-08-2410:52rickmoynihanthen call (s/instrument) at the bottom of that ns/top-level?#2020-08-2410:54thhellerthe trouble with instrument is that it is a macro and only instruments things that have been compiled by the type it is called#2020-08-2410:55thhellerso if you put it in a preload that ns also needs to require all namespaced its supposed to instrument#2020-08-2410:55thhellerbut that works yes#2020-08-2410:56rickmoynihanI think I can do that here… It does mean the specs won’t be in my app at all; but I’m keeping the namespaces separate right now, so they need to be included at the root.#2020-08-2410:56thhellerif you are on a recent version you can get fancy and do
(def ^:dev/after-load instrument-everything []
  (js/cljs-eval "(cljs.spec.alpha/instrument)"))
#2020-08-2410:56thhellersince the eval happens after all compilation finishes it will see everything#2020-08-2410:57thhelleror maybe
(def ^:dev/after-load-async instrument-everything [done]
  (-> (js/cljs-eval "(cljs.spec.alpha/instrument)")
      (.then done)))
#2020-08-2410:59thhellerI also added :build-options {:auto-require-suffixes #{"-spec"}} that will automatically add foo.bar-spec to the build if foo.bar is required#2020-08-2410:59thhellerbut that doesn't solve the instrument issue needing to be called "late"#2020-08-2411:15rickmoynihanThanks… I seem to be getting an error: “Use of undeclared Var cljs.spec.alpha/instrument”. I have (:require [cljs.spec.alpha :as s :include-macros true]) in my ns definition#2020-08-2411:16rickmoynihancurrently calling (s/instrument) at the top level#2020-08-2411:17thhelleroh that might be in another namespace#2020-08-2411:18thhellerI think it might be cljs.spec.test.alpha. not actually sure.#2020-08-2411:19thhelleryou can also do (js/cljs-eval "(require 'cljs.spec.test.alpha) (cljs.spec.test.alpha/instrument)") of course#2020-08-2411:20rickmoynihanyeah you’re right — I thought it was wrong; but had seen something online listing it that way#2020-08-2411:20rickmoynihanwhy cljs-eval it?#2020-08-2411:22thhellereval what? the instrument or the require?#2020-08-2411:23rickmoynihanwhy cljs-eval both like you have, rather than via preload?#2020-08-2411:24rickmoynihan(If I only want them in dev mode)#2020-08-2411:24thhelleryou can do the preload that is fine. if you setup your requires correctly that will work just fine#2020-08-2411:25thhellerBUT instrument is a macro so you need to realize what that means#2020-08-2411:25thhellerit will only do stuff it knows about at the time it is compiled. so it is easy to miss stuff if you don't list something or so.#2020-08-2411:25thhellerby using cljs-eval it is ensured that the macro is expanded at a time where all other compilation has finished#2020-08-2411:26thhelleryou are guaranteed to get the "latest" version#2020-08-2411:26thhellerI do think that the :preloads variant is better and probably more reliable but it is more work and easy to mess up#2020-08-2411:27rickmoynihanYeah ok, that’s more or less what I was thinking… Essentially you’re saying the fdef’s all need to be explicitly required for them to be found, from the top of this ns, so any fdef’s required from the app’s top level would be missed.#2020-08-2411:30thhellerthe fdefs need to be compiled before instrument is called yes, where from exactly doesn't really matter as long as its before#2020-08-2411:31rickmoynihan👍#2020-08-2411:31thheller<preload-ns> -> -> main.app-spec is fine but for example won't invalidate <preload-ns> when main.app-spec is changed and as such won't affect instrument#2020-08-2411:31thhellerunless you add :dev/always to the preload ns to always recompile#2020-08-2411:31thhellerI should really write this down somewhere. feel like I explained this before somewhere#2020-08-2411:32thhellerthere are a whole lot of gotchas to watch out for but it can work fine#2020-08-2411:34rickmoynihanwhat about where my.app.specs -> ?#2020-08-2411:35thhellerhmm? obvioulsy need to have my.app.specs required somewhere. if you do that in the preload that is fine, or the :auto-require-suffixes I mentioned#2020-08-2411:37rickmoynihanyeah was thinking essentially it would just be required via the :preloads#2020-08-2411:37thhelleryes thats fine#2020-08-2411:37rickmoynihanwould I need any :dev/always or similar flags?#2020-08-2411:39thhellerif you have a instrument call in that namespace yes. otherwise while editing the code it will become "unstrumented". eg. watch compiles https://my.app and loads it so your fdef instrument is replaced#2020-08-2411:39rickmoynihanahh gotcha#2020-08-2411:39rickmoynihanmakes sense#2020-08-2411:44rickmoynihanhmm I might well switch to using :auto-require-suffixes stuff after all… will see 🤔#2020-08-2411:56thhellerthat doesn't solve the instrument problem though 😉#2020-08-2413:23rickmoynihanyeah but including with ^:dev/after-load-async does right?#2020-08-2413:24thhellerit should in theory yes. never actually tried it 😛 frankly the instrument macro scares me 😛#2020-08-2416:21TuomasI’m recreating react material ui docs in workbooks to prove my colleagues it’s not impossibly hard. I got pretty far in one go, but ended up shutting down my computer before finishing. After I got back I was faced with a weird situation where on initial load the cards are empty but after live reload they work. The problem seems to be with my importing. I’m trying to recreate
import {
  MuiPickersUtilsProvider,
  KeyboardTimePicker,
  KeyboardDatePicker,
} from '@material-ui/pickers';
with
(ns app.mui-component (:require ["@material-ui/pickers" :refer [MuiPickersUtilsProvider KeyboardTimePicker KeyboardDatePicker]]))
having npm installed
"@material-ui/pickers": "^3.2.10",
but end up with
shadow-cljs - failed to load module$node_modules$$material_ui$pickers$dist$material_ui_pickers
  shadow.js.jsRequire @ js.js:74
  shadow.js.require @ js.js:113
  eval @ app.mui_components.js:10
  goog.globalEval @ main.js:577
  env.evalLoad @ main.js:1670
  (anonymous) @ main.js:2650
main.js:1672 An error occurred when loading app.mui_components.js
  env.evalLoad @ main.js:1672
  (anonymous) @ main.js:2650
main.js:1673 undefined
  env.evalLoad @ main.js:1673
  (anonymous) @ main.js:2650
Any tips on what to check/try/read?
#2020-08-2416:21TuomasI’m not even sure if it’s shadow related or something completely different#2020-08-2416:23thhellerare there more errors? there should be. its just telling you what failed to load, the why you didn't paste?#2020-08-2416:23Tuomas#2020-08-2416:27thhellerlooks like you have to fix a bunch of other stuff?#2020-08-2416:30thhellerI cannot tell what the actual error is either. my guess would be that maybe it expects a different react version?#2020-08-2416:42Tuomas“buch of other stuff” you mean errors? If I comment out the
@material-ui/pickers
import and defs/cards/componests that end up relying on something undefined, I get no errors. When I remove the comments it’s like the whole namespace doesn’t load
#2020-08-2416:42thheller
react-dom.development.js:89 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See  for details.
* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: 
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.
Please update the following components: ReactGridLayout, ResponsiveReactGridLayout
#2020-08-2416:43thhellerwhat are these? no clue if thats related to @material-ui/pickers or something else?#2020-08-2416:51TuomasI get that warning with and without pickers. I thought it was a Fulcro thing but I’ll try to make sure#2020-08-2417:14TuomasI’m sorry to let you know that it is working again, but I don’t know why. I’ll try to break it again for a while but will then move on. Thanks the replys!#2020-08-2416:23bbss@thheller I'm still having trouble compiling the file:
[:main] Build failure:
Closure compilation failed with 2 errors
--- kr/models/ronde-tempel-compiled.js:7
Requested module does not have an export "createElement".
--- kr/models/ronde-tempel-compiled.js:7
Requested module does not have an export "useRef".
#2020-08-2416:24bbssWith
import { useRef, createElement } from 'react'
#2020-08-2416:24thhellermaybe import React, { useRef, createElement } from "react" works?#2020-08-2416:25bbssnop, also tried#2020-08-2416:25thhellerotherwise only import React from "react" and React.useRef might work#2020-08-2416:25bbssalso tried that.. React is undefined#2020-08-2416:25bbss
shadow-cljs - server version: 2.10.13 running at 
#2020-08-2416:25bbssis that correct?#2020-08-2416:25thhellerno?#2020-08-2416:25bbssI did install 2.11.0#2020-08-2416:26thhellershould be 2.11.0. remember to update in project.clj or deps.edn if you use either#2020-08-2416:26bbssOkay#2020-08-2416:26bbssChecking again..
#2020-08-2416:27bbssDoh.. I thought might have been wrong version!#2020-08-2416:33bbssNow watch build works again, but having minification issues I think, for release
cannot read property 'geometry' of undefined
;;probably for
createElement("mesh", {
    material: materials.red,

      receiveShadow: true,
      castShadow: true,
      geometry: nodes.temple_railing_top.geometry,
    name: "temple_railing_top",
    position: [0.82, 2.23, -2.03],
    rotation: [Math.PI, 0, Math.PI],
    scale: [2.61, 2.61, 2.61]
  })
#2020-08-2416:33bbssIs there a way to exclude files from minification?#2020-08-2416:34bendlassay, I have two custom node libraries, depending on conflicting versions of d3. By default, shadow would try to resolve a single d3 version. :js-options :resolve doesn't help here either, because it just lets me choose the d3 version to resolve, correct? How to best deal with this? Should I use rollup to package the two libraries?#2020-08-2416:35thheller@bbss if you use require and module.exports instead of import/export the file is treated as commonjs and as such does not go through :advanced#2020-08-2416:35thhellerJS code otherwise doesn't have externs inference so you could just add externs manually as well#2020-08-2416:37thheller@bendlas shadow-cljs will not let you include 2 different versions of d3 no matter what so you have to use something different to get that yes#2020-08-2416:39thhellerhttps://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html maybe the :js-provider :external#2020-08-2416:50bbssawesome! working with release! thanks once again :)#2020-08-2421:30grounded_sageHow do I run the browser tests once they are generated? I am having difficulties figuring this out from the documentation#2020-08-2421:33lilactownthe :browser-test build is meant to be opened in a browser. it should generate an html file as part of its output that you can open#2020-08-2421:33grounded_sageHow do you open it?#2020-08-2421:35lilactownpoint chrome to where the file is being served by shadow-cljs web server#2020-08-2421:36lilactownhere’s an example of our config for it:
:test {:target :browser-test
                 :test-dir "resources/public/test"
                 :ns-regexp "-test$"
                 :compiler-options {:language-in :es6
                                    :output-feature-set :es6}
                 :devtools {:http-port 8021
                            :http-root "resources/public/test"}}
#2020-08-2421:36lilactownso I would go to http://localhost:8021/#2020-08-2421:36lilactownwhile the test watch is running#2020-08-2421:42grounded_sagehmm. I get a bunch of errors when I do shadow-cljs watch test#2020-08-2421:46grounded_sageOkay smaller library trying this out works. But I don’t see the results of the tests. Where are they printed?#2020-08-2421:47lilactownin the browser#2020-08-2421:48grounded_sageI have this in the console. env.cljs:187 error when calling lifecycle function shadow.test.browser/start Error: Assert failed: cljs-test-display: Element with id "test-root" does not exist.#2020-08-2421:49lilactowntry adding that html element to the index.html in test-dir#2020-08-2421:49lilactown<div id="test-root" />#2020-08-2421:51grounded_sageOkay that worked#2020-08-2421:51grounded_sageSeems that this needs to be generated with the file.#2020-08-2421:59thheller:browser-test should generate the index.html if it doesn't exist#2020-08-2421:59thhellerif you re-use a folder and it does exist it may not do the right thing#2020-08-2422:01grounded_sageYea I just tried on another project and it generated things properly. :man-shrugging:#2020-08-2422:02grounded_sageI’ve literally been going down a rabbit hole trying to figure out why the test runner wasn’t working with Kaocha. Tracing problems in the code but it was actually the runner. shadow-cljs to the rescue again 🙇#2020-08-2422:09bendlasI just ran into a problem, where I'm not sure if it's about shadow or the closure compiler: A node module, accessing process, hence triggering shadow's automatic require('process'), got moved by the closure compiler into a common base module, where it then failed to require process. But only in production mode.#2020-08-2422:09bendlasSolution was to explicitly move the node module into the common sub module#2020-08-2422:16thhellerclosure doesn't move JS requires. in fact it doesn't even see them?#2020-08-2422:43bendlasyes, the js require had been rewritten to a shadow require at that point, but the module wasn't found. I suspect that, since the require('process') is added by shadow, it might have added the shadow$provide for process too late, because it didn't know about the require being cross-module moved, or something. If it's not obvious to you from the description, I can try to condense a test case ....#2020-08-2423:21bennycross-posting this to see if there’s a way to do this with cljs#2020-08-2423:49Pavel KlavíkHi, is this guide still up-to-date: https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html? If I want to split a large component in my Re-frame app into a separate module, I will add events, subscriptions and views namespaces into this module and load view by lazy-load as in the example? How do I load subscriptions and events namespaces? Should I add them to the main view namespace?#2020-08-2507:47thheller@pavel.klavik yes that is current. you can either add the namespaces you want to load in a module via the build config :entries#2020-08-2514:24Pavel KlavíkSo I got almost everything running with the following code:
[:> react/Suspense {:fallback (r/reactify-component [loading/loading :loading/administration])}
                 [:> (lazy/component (slazy/loadable orgpad.client.views.administration.core/administration))]]
But I am getting the following error:
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
    in Suspense (created by root-component)
    in div (created by root-component)
    in div (created by root-component)
    in root-component (created by orgpad.client.views.root.root)
    in orgpad.client.views.root.root
What am I doing wrong?
#2020-08-2515:04thhellerI don't know? what is (lazy/component (slazy/loadable orgpad.client.views.administration.core/administration))? returning?#2020-08-2515:05thheller{:fallback (r/reactify-component [loading/loading :loading/administration])} should likely be {:fallback (r/as-element [loading/loading :loading/administration])}?#2020-08-2515:05Pavel KlavíkSorry, I have rewritten it like this:
(ns orgpad.client.views.widgets.lazy
  (:require ["react" :as react]
            [reagent.core :as r]
            [shadow.lazy :as slazy]
            [orgpad.client.views.loading :as loading]))

(defn- component
  "React Lazy component which waits till the code is loaded and then replaces it with the component itself."
  [loadable]
  (react/lazy
    (fn []
      (-> (slazy/load loadable)
          (.then (fn [root-el]
                   #js {:default (r/reactify-component (fn [props] [@loadable props]))}))))))

(defn lazy
  "Renders a component whose source code may have to be first loaded. While the source code is loaded, renders the
  loading screen for the given state. The single parameter is a map having the following keys:

  :lazy/loadable - Call (slazy/loadable ).
  :lazy/state - The loading state while the component's source code is loaded."
  [{:lazy/keys [loadable state]}]
  [:> react/Suspense {:fallback (r/reactify-component [loading/loading state])}
   [:> (component loadable)]])
#2020-08-2515:06Pavel Klavíkorgpad.client.views.administration.core/administration is just a reagent component#2020-08-2515:07Pavel Klavíkok, changing to as-element fixed the problem#2020-08-2515:08Pavel Klavíkthx, react interop is something I am never using very frequently, so it is quite tricky to get it right#2020-08-2507:48thhelleror by adding them to the :require of a namespace you added to the :entries#2020-08-2509:35rickmoynihanI think in order to get spec errors to pretty print properly in cljs with expound you need to eval (require '[expound.alpha :as expound]) (set! clojure.spec.alpha/*explain-out* expound.alpha/printer) in the clojure vm that compiles macros… Is there a way to wire shadow-cljs up to do that?#2020-08-2509:39rickmoynihanlike maybe putting it in a user.clj at the root of the shadow jvms classpath?#2020-08-2509:51thheller@rickmoynihan instrument errors will not be affected by that?#2020-08-2509:52thhellershadow-cljs already does this for spec errors it prints itself. so if you write (let [x]) or so the resulting spec error is printed by expound#2020-08-2509:53rickmoynihanits instrument errors I want#2020-08-2509:54thhellerthen you need to eval the above in CLJS not CLJ#2020-08-2509:54rickmoynihanI am#2020-08-2509:54thhellerbut I don't even know if instrument uses that printer?#2020-08-2509:55thhellerI haven't used instrument myself, too scared of the code modifications it does 😛#2020-08-2509:56rickmoynihanHmm… I might have misdiagnosed this then#2020-08-2509:56rickmoynihanI wonder if it’s because my spec error is occuring inside a core.async go block#2020-08-2510:05rickmoynihanactually I think this might be something else 👀#2020-08-2511:51psdpSorry, stupid question. Trying to import a npm module but failed. What can I do about it?
Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.umd.min.js:355
Duplicate let / const / class / function declaration in the same scope is not allowed.
#2020-08-2513:03shivekkhuranaHeya! Has somebody here faced some issues with importing CJS modules after upgrading to shadow version 2.11? This version was releases 2 days ago (https://github.com/thheller/shadow-cljs/commit/28169be104149e496b31bad443be7ecb6d16cd4a) and is tagged as [BREAKING].#2020-08-2513:04shivekkhuranaThis lead to build failure for my app using BlueprintJS#2020-08-2513:04shivekkhurana📄 Short error:
[:app] Build failure:
Failed to inspect file
  /Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js

it was required from
  /Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/index.js

Errors encountered while trying to parse file
  /Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}
#2020-08-2513:05shivekkhurana📑 Full Error#2020-08-2513:06shivekkhurana
RuntimeException: Exception parsing "/Users/shivekkhurana/WIP/tmp/blueprint-cljs/node_modules/@blueprintjs/icons/lib/cjs/generated/iconContents.js"
	com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:155)
	com.google.javascript.jscomp.JsAst.parse (JsAst.java:152)
	com.google.javascript.jscomp.JsAst.getAstRoot (JsAst.java:55)
	shadow.build.closure.JsInspector.getFileInfo (JsInspector.java:176)
	shadow.build.closure.JsInspector.getFileInfoMap (JsInspector.java:190)
	shadow.build.npm/get-file-info*/fn--10535 (npm.clj:549)
	shadow.build.npm/get-file-info* (npm.clj:548)
	shadow.build.npm/get-file-info* (npm.clj:490)
	shadow.build.npm/get-file-info (npm.clj:611)
	shadow.build.npm/get-file-info (npm.clj:608)
	shadow.build.npm/find-resource (npm.clj:709)
	shadow.build.npm/find-resource (npm.clj:661)
	shadow.build.resolve/find-npm-resource (resolve.clj:123)
	shadow.build.resolve/find-npm-resource (resolve.clj:94)
	shadow.build.resolve/fn--12489 (resolve.clj:257)
	shadow.build.resolve/fn--12489 (resolve.clj:226)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:81)
	shadow.build.resolve/find-resource-for-string (resolve.clj:70)
	shadow.build.resolve/resolve-string-require (resolve.clj:375)
	shadow.build.resolve/resolve-string-require (resolve.clj:358)
	shadow.build.resolve/resolve-require (resolve.clj:591)
	shadow.build.resolve/resolve-require (resolve.clj:584)
	shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:50)
	shadow.build.resolve/resolve-deps (resolve.clj:34)
	shadow.build.resolve/resolve-string-require (resolve.clj:400)
	shadow.build.resolve/resolve-string-require (resolve.clj:358)
	shadow.build.resolve/resolve-require (resolve.clj:591)
	shadow.build.resolve/resolve-require (resolve.clj:584)
	shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:50)
	shadow.build.resolve/resolve-deps (resolve.clj:34)
	shadow.build.resolve/resolve-string-require (resolve.clj:400)
	shadow.build.resolve/resolve-string-require (resolve.clj:358)
	shadow.build.resolve/resolve-require (resolve.clj:591)
	shadow.build.resolve/resolve-require (resolve.clj:584)
	shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:50)
	shadow.build.resolve/resolve-deps (resolve.clj:34)
	shadow.build.resolve/resolve-string-require (resolve.clj:400)
	shadow.build.resolve/resolve-string-require (resolve.clj:358)
	shadow.build.resolve/resolve-require (resolve.clj:591)
	shadow.build.resolve/resolve-require (resolve.clj:584)
	shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:50)
	shadow.build.resolve/resolve-deps (resolve.clj:34)
	shadow.build.resolve/resolve-string-require (resolve.clj:400)
	shadow.build.resolve/resolve-string-require (resolve.clj:358)
	shadow.build.resolve/resolve-require (resolve.clj:591)
	shadow.build.resolve/resolve-require (resolve.clj:584)
	shadow.build.resolve/resolve-deps/fn--12441 (resolve.clj:52)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
	shadow.cljs.util/reduce-> (util.clj:47)
	shadow.cljs.util/reduce-> (util.clj:46)
	shadow.build.resolve/resolve-deps (resolve.clj:50)
	shadow.build.resolve/resolve-deps (resolve.clj:34)
	shadow.build.resolve/resolve-string-require (resolve.clj:400)
Caused by:
StackOverflowError:
	com.google.javascript.jscomp.parsing.IRFactory.handleJsDoc (IRFactory.java:678)
	com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:829)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpressionHelper (IRFactory.java:1840)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1816)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:3275)
#2020-08-2513:07shivekkhuranaFile in question: https://unpkg.com/browse/@blueprintjs/icons@3.20.1/lib/cjs/generated/iconContents.js#2020-08-2514:39yendaWhy do I get an infer warning on this?
(.on nodejs/process "SIGTERM" (fn []))
#2020-08-2514:39yenda
Cannot infer target type in expression (. nodejs/process on "SIGTERM" (fn []))
#2020-08-2515:02thhellerwhy wouldn't you? what is nodejs/process?#2020-08-2515:11yenda[cljs.nodejs :as nodejs]#2020-08-2515:11yendaI fixed the warning by doing ^js (.on nodejs/process "SIGTERM" (fn []))#2020-08-2515:13thhellerjust use (js/process.on ...) and banish cljs.nodejs from your codebase 😛#2020-08-2515:08thheller@shivekkhurana look at the file on your disk? it might be corrupted somehow? I vaguely remember someone having this problem before?#2020-08-2515:45shivekkhuranaI'm messaging on the github issue for better visibility. Thanks for the quick response !#2020-08-2515:51thhellerah just saw the full stacktrace#2020-08-2515:52thhellerlooks like a problem in the closure compiler. dunno what that is about but I vaguely remember seeing problems with this file before. unfortunately its lost in slack history#2020-08-2515:12thheller@psdp unfortunately I can't remember if this was fixable. it was reported before but I think there was nothing to do except using the CDN distro of jspdf#2020-08-2522:48neilyioAnybody have https://storybook.js.org/ working with shadow-cljs? I'm trying to follow @thheller's post https://clojureverse.org/t/using-storybook-with-cljs/1495, but it's from a couple years ago and the https://github.com/shadow-cljs/examples/tree/master/cljs-storybook doesn't work anymore.#2020-08-2522:49thhelleryeah pretty sure it doesn't work anymore#2020-08-2522:51neilyioI'm trying to follow https://github.com/jacekschae/shadow-cljs-examples/blob/master/cljs-storybook/shadow-cljs.edn which seems based on your post, but I'm getting "No available JS runtime" in my CIDER REPL with a similar config:
:storybook
  {:target     :npm-module
   :output-dir "out"
   :entries [app.storybook]
   :devtools {:enabled false}}}
#2020-08-2522:52thhellerthat means the JS hasn't been loaded#2020-08-2522:52thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2020-08-2522:52thhellerbut yeah I wouldn't have much hope of this working#2020-08-2522:53neilyioI appreciate the tip, that'll save me some time. Do you have any tips for getting dev-cards working with shadow-cljs?#2020-08-2522:54neilyioAlso, sorry I didn't find the user guide entry. I did a CMD-f search for :npm-module, which I've never used before. That keyword doesn't appear in the user guide section you just linked, maybe that's why I missed it. Thought I'd give you a heads up!#2020-08-2522:55thhellerI don't understand what you just said#2020-08-2522:55thhellerwhich guide?#2020-08-2522:57thhelleryou mean the repl troubleshoot section doesn't specifically mention :npm-module? thats because there are a bazillion gazillion ways to use :npm-module and I can't possibly list all the "solutions"#2020-08-2522:57thhellereg. storybook js processes and bundles the :npm-module output and I have no clue what it does to it#2020-08-2522:57thhellerand therefore no clue if the REPL can even possibly work#2020-08-2522:58thhellerbut the gist of it is that the JS needs to be loaded SOMEWHERE. which is why you should probably read the whole thing and not skip over it#2020-08-2523:00neilyioThat is what I meant. I was just saying that my CMD-f search for :npm-module in the Shadow-CLJS User Guide didn't lead me to the REPL Troubleshooting section, which is why I asked here. I thought you might appreciate knowing why a reader may have missed it.#2020-08-2523:01neilyioThanks once again for getting back to me so quickly! I'll read through and try one more time on Storybook, and then I'll try for dev-cards next.#2020-08-2523:03lilactownI created an example ~3 months ago: https://github.com/lilactown/storybook-cljs#2020-08-2523:56neilyio@lilactown I think I've made it to the end of your example. I've successfully got "hi" printing out in the browser console.#2020-08-2523:57neilyioI wanted to let you know that I think there's a typo in the Configuring Storybook section's code example:
module.exports = {
  stories: ["../stories/**/*.stories.js", "../out/**/*_story.js"],
  addons: ["@storybook/addon-actions", "@storybook/addon-links"],
};
#2020-08-2523:59lilactownwhat’s the typo?#2020-08-2523:59neilyioThe example is adding "../out/**/*_story.js", but your CLJS namespace is stories.core, which for me is resulting in a stories.core.js file in my out folder.#2020-08-2600:00neilyioInstead of "../out/**/*_story.js" , I've added "../out/**/stories.*.js" to the module.exports list in main.js and it seems to be working.#2020-08-2600:01lilactownhmm I don’t think we actually need stories.core to be included in the storybook build#2020-08-2600:02lilactownI suppose you can organize how you want#2020-08-2600:02neilyioOh, really? I thought that would be the only way to do it. Where are the *_story.js files coming from?#2020-08-2600:03lilactownthe part I left out is creating a corp.design.button-story namespace#2020-08-2600:03lilactownhttps://github.com/lilactown/storybook-cljs/tree/master/src/corp/design#2020-08-2600:04neilyioOoooh I see now. I couldn't think of why else there might be *_story.js files, so I assumed it was a typo.#2020-08-2600:05lilactownyeah. what I’m doing is a bit weird. basically, I enumerate each story namespace in two places: • stories.core so that shadow-cljs knows to build it • in the storybook config using the glob pattern, so that the built file gets picked up by storybook’s CLI#2020-08-2600:06neilyioEither way, you've gotten me much farther than I thought I would get with this!#2020-08-2600:06lilactownI suppose another way you could do it is to configure storybook to just statically include stories.core.js#2020-08-2600:06neilyioHow did you find out the .babelrc was necessary? I would never have thought of that.#2020-08-2600:08lilactownyears of experience working with JS bundlers 😂#2020-08-2600:09lilactownI can’t remember now why it was necessary tbh#2020-08-2600:15neilyioAlso, how are you getting away without using the storiesOf API?#2020-08-2600:15neilyioOh wait, I see, it seems like you're basically using the new CSF style.#2020-08-2600:18neilyioWhere they depend on default exports etc. I'm actually trying to avoid that, it seems to rely on having one file per React component. Reagent components are so small that I tend to have multiple per file. I'm thinking the older storiesOf API will be more accommodating to that, let me know if you have another idea!#2020-08-2523:17neilyio@lilactown That's an amazing resource, thank you! Very well written. I'll let you know if I get it working.#2020-08-2523:19thhellerkinda funny that you say "integrating the latest storybook (v5)" when apparently v6 came out since. wonder what they broke this time 😉#2020-08-2523:53lilactownlmao. right? we can’t keep up#2020-08-2602:36souenzzoHey I'm trying to load react-vega and I'm getting this issue
[:zubi] Build failure:
The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js".

Dependency Trace:
	zubi/dev.cljs
	zubi/client.cljs
	node_modules/react-vega/lib/index.js
	node_modules/react-vega/lib/Vega.js
	node_modules/react-vega/lib/utils/updateMultipleDatasetsInView.js
	node_modules/react-vega/lib/utils/updateSingleDatasetInView.js
	node_modules/vega-embed/build/vega-embed.js
	node_modules/vega/build/vega-node.js
	node_modules/vega-dataflow/build/vega-dataflow.js
	node_modules/vega-loader/build/vega-loader.js

Searched for npm packages in:
	/home/souenzzo/src/zubi/node_modules

See: 
I think that somehow vega-loader thinks that it's running on nodejs (maybe ssr) and tryies to import a buffer.
#2020-08-2602:38souenzzoI'm on thheller/shadow-cljs {:mvn/version "2.11.0"} Using "deps" both JVM8 and JVM14 do the same error.#2020-08-2608:34thhelleryou need to npm install shadow-cljs in your project ...#2020-08-2608:34thhellerwhich you should be getting a big fat warning about#2020-08-2614:06souenzzonpm install --save-dev shadow-cljs and it do the hot-reoload even before I checkout logs/output Tnks for shadow-cljs ❤️#2020-08-2603:24royalaid@thheller would it be possible to a way to clear shadow-inspect?#2020-08-2603:24royalaidSpecifically remove any logged taps that are on the page#2020-08-2603:25royalaidwould be easier to read than (tap> "==================") 😂#2020-08-2608:38thheller@royalaid please open an issue so I don't forgot to add it this time. working on the UI but need to solve something else first 😉#2020-08-2617:45royalaidhttps://github.com/thheller/shadow-cljs/issues/782, thanks as always!#2020-08-2612:47mkarpHey there! With the following build config:
:app {:target :browser
      :js-options {:resolve {"foo" {:target :npm :require "foo"}}}}
Eval-ing the following code on the REPL:
(require '["foo" :as foo])
(js/console.log foo)
I get the following:
{__esModule: true, default: ƒ}
So to make an instance of foo, I have to call (foo/default.) Is there a way to specify within the build config that default should be “unwrapped” automatically, so that I can call (foo.)? What I’m trying to solve (and perhaps there’s a better way): There’s a dependency foo which exports a constructor function directly via a UMD. Within tests I need to substitute foo with a mock, so I’m using a separate npm package foo-mock which is an ESM and the constructor is under the default export property. The config in the end might look something like this:
:app {:target :browser
      :js-options {:resolve {"foo" {:target :npm :require "foo"}}}}

:test {:target :browser-test
       :js-options {:resolve {"foo" {:target :npm :require "foo-mock"}}}}
Thanks in advance!
#2020-08-2613:13thheller@me1676 why is the mock different from the actual? seems like a strange way to mock?#2020-08-2613:14thhelleryou can try :resolve {"foo" {:target :npm :require "foo-mock$default"}} if you are on a recent version but I'm not sure that'll work#2020-08-2613:14mkarpYes, that’s an unfortunate decision by the author of foo-mock. I’ll try your suggestion#2020-08-2613:19mkarpshadow-cljs 2.10.21 fails:
Build failure:
:resolve override for "foo" to "foo$default" which does not exist
{:tag :shadow.build.resolve/invalid-override, :require-from #object[java.io.File 0x4aa9328a ".../test.cljs"], :require "foo", :other "foo$default"}
#2020-08-2613:20thhellerhmm yeah didn't expect that to work really 😛#2020-08-2613:20mkarp😃#2020-08-2613:22thhellerwhat are the packages?#2020-08-2613:22mkarpIt’s https://www.npmjs.com/package/pusher-js and https://www.npmjs.com/package/pusher-js-mock#2020-08-2613:28thhellerto answer your other question you can use (:require ["foo" :default foo]) and direclty use (foo.) or (:require ["foo$default" :as foo]) (new "standard" variant likely coming in next CLJS release)#2020-08-2613:29thhellerthe only other suggestion I can make is publishing your own npm package that uses pusher-js-mock but exports the default you want#2020-08-2613:30thhellermodule.exports.default = require("pusher-js-mock").Whatever;#2020-08-2613:31thhellernode_modules/pusher-js-mock-default/index.js or so#2020-08-2613:31thhellerthen the :require redirect should be fine#2020-08-2613:37mkarpThank you @thheller, these are good suggestions!#2020-08-2620:56neilyioHow should I use a CommonJS/ES6 namespace in a ClojureScript macro? I'm following @thheller's https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html, which suggests that defmacro within a .`clj` file should use a fully-qualified namespace. But going by the shadow-cljs User Guide's https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages, I don't see how to use a fully-qualified namespace with CommonJS/ES6 imports, because they are referred to with strings as in (:require ["module-name"]).#2020-08-2709:19mkarpHey there! Would it be possible to somehow run :browser-test and :node-test targets within the same shadow watch process? If I do this at the moment, shadow looks up for namespaces with "-test$" regexp and node-specific tests land in the browser-test target. So the options would be either to run separate shadow processes with different classpaths, or to have more precise namespace naming convention for the regexps (like "$browser([\w-\.]+)test$" and "$node([\w-\.]+)test$")?#2020-08-2709:47thheller@me1676 if you structure your namespaces just right that might be enough too? your.app.frontend.foo-test vs your.app.backend.foo-test or your.app.whatever.foo-test?#2020-08-2709:48thhellerhappy to add more filtering options if needed too. you also have the option to specify namespaces directly instead of just a regexp#2020-08-2709:48thhellerjust :namespaces [foo.bar-test ...] and :exclude #{foo.dummy-test} also exists#2020-08-2709:51mkarpAhh that’s nice, didn’t know about :namespaces and :exclude 🙂#2020-08-2709:51thhellerif :namespaces is used :ns-regexp has no effect though#2020-08-2709:52mkarpDo you think it would be possible to add something like :filepath-regexp to filter based on the file paths?#2020-08-2709:55thhellersure but what would that do?#2020-08-2709:55thhellerI mean it doesn't make sense in how I organize my tests so I first need to understand how you organize your tests to make a useful impl 😛#2020-08-2713:22mkarpAlright, I’ll try explain. Source directories: src/browser — Namespaces pitch.app., pitch.components., pitch.integrations., pitch.something-else. src/node — Namespaces pitch.node., pitch.something-else. Test directories: test/browser — Namespaces pitch.app.-test, pitch.components.-test, pitch.integrations.-test, pitch.something-else.-test test/node — Namespaces pitch.node.-test, pitch.something-else.-test Unfortunately just by looking at the namespace it’s not possible to understand to if it belongs to browser or node bundle, that’s why ns-regexp can’t work in our case. However, if we can apply a regexp to the filepath of a cljs file, then it becomes easy#2020-08-2715:44thhellerlein shadow watch app devcards should work and only give you one JVM#2020-08-2715:46Elsothat's actually quite awesome to know (does it matter in that case that watch-dirs overlap?)#2020-08-2715:46thhellerno#2020-08-2715:46ElsoThe problem was rather more stupid than I'm comfortable admitting - I had a terminal window burrowed somewhere that still had a watch job only on app running#2020-08-2715:47Elsobut your hint made me look for it so thank you very much 🙂#2020-08-2717:20Sam Ritchie@thheller, do you have any advice on how to enable data_readers.cljc for a self hosted build? here is the shadow-cljs.edn: https://github.com/sritchie/maria/blob/sritchie/last_attempt/editor/shadow-cljs.edn#2020-08-2717:22Sam RitchieI found a reference on the site about the compiler option to enable this (and your footgun warning 🙂 ), but it seems to not work when I add :compiler-options {:data-readers true} to the bootstrap build#2020-08-2717:22Sam Ritchie"not work" means, grabbing the error...#2020-08-2717:24Sam Ritchie#2020-08-2717:25Sam Ritchiethis does indeed work at a repl with data_readers.cljc loaded, and I can see that it did make it into the jar#2020-08-2719:01thheller@sritchie09 for self-hosted that you are compiling you need to handle data-readers in the compiler yourself. nothing shadow-cljs can do to help that.#2020-08-2719:02thhellerat least I don't think so. no clue really.#2020-08-2719:13Sam Ritchiehere be dragons!#2020-08-2719:14Sam Ritchiethanks for the note, @thheller, I'll see if I can figure out how to get it working down the road#2020-08-2720:58Sam Ritchie
(set!
 cljs.tagged-literals/*cljs-data-readers*
 (merge cljs.tagged-literals/*cljs-data-readers*
        {'sicm/complex sicmutils.complex/parse-complex
         'sicm/bigint sicmutils.util/parse-bigint
         'sicm/ratio sicmutils.ratio/parse-ratio}))
#2020-08-2720:59Sam Ritchieas a hack, @thheller this does it, if I type this in on the page itself!#2020-08-2719:14Sam Ritchieand write down my lessons from the mines#2020-08-2719:58neilyioSorry to double-post, but I think I asked this after-hours last night and missed everyone. I'm rather stuck on it, so fingers crossed there's an easy answer:#2020-08-2719:58neilyioHow should I use a CommonJS/ES6 namespace in a ClojureScript macro? I'm following @thheller's https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html, which suggests that `defmacro` within a .`clj` file should use a fully-qualified namespace.  But going by the shadow-cljs User Guide's https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages, I don't see how to use a fully-qualified namespace with CommonJS/ES6 imports, because they are referred to with strings as in `(:require ["module-name"])`.#2020-08-2720:00thheller@neil.hansen.31 I recommend that you don't access npm packages directly but instead create a helper fn that does so and call that from the macro#2020-08-2720:01neilyioThanks @thheller, I'll try that right now.#2020-08-2720:08neilyioThat totally worked, I should have thought of that. Thanks!#2020-08-2722:24thheller@me1676 in 2.11.1 you can specify :test-paths ["test/node"] in the test build configs which will only make it use namespaces matching ns-regexp from those paths. they need to be classpath roots and already on the classpath though. maybe that works.#2020-08-2807:10mkarpAwesome, thanks! I’ll check it out#2020-08-2817:17grounded_sageI’ve started getting this error on a project I had shadow working on. Not sure what changed.
hadow-cljs - starting via "clojure"
[2020-08-28 19:15:35.245 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
	clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
	clojure.lang.Compiler.macroexpand (Compiler.java:7075)
	clojure.lang.Compiler.eval (Compiler.java:7161)
	clojure.lang.Compiler.load (Compiler.java:7636)
	clojure.lang.RT.loadResourceScript (RT.java:381)
	clojure.lang.RT.loadResourceScript (RT.java:372)
	clojure.lang.RT.load (RT.java:459)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
Caused by:
NoSuchFieldError ES3
	cljs.closure__init.load (:133)
	cljs.closure__init.<clinit> (:-1)
	java.lang.Class.forName0 (Class.java:-2)
	java.lang.Class.forName (Class.java:427)
	clojure.lang.RT.classForName (RT.java:2211)
	clojure.lang.RT.classForName (RT.java:2220)
	clojure.lang.RT.loadClassForName (RT.java:2239)
	clojure.lang.RT.load (RT.java:449)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.10.21 running at 
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[2020-08-28 19:15:45.805 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
	java.lang.Class.forName0 (Class.java:-2)
	java.lang.Class.forName (Class.java:427)
	clojure.lang.RT.classForName (RT.java:2211)
	clojure.lang.RT.classForName (RT.java:2220)
	clojure.lang.RT.loadClassForName (RT.java:2239)
	clojure.lang.RT.load (RT.java:449)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
#2020-08-2817:26grounded_sageActually seems like I bumped up against this before. It’s when I use :deps {:aliases [:cljs]} instead of :dependencies which I was avoiding for duplication reasons#2020-08-2820:02thhellerits just a version conflict you need to resolve. see https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-08-2817:49devnHello friends. I am completely stumped. I have a typescript npm pkg that I’m building that includes a set of components. One of these components is named DatePicker. Under the covers it uses https://github.com/Hacker0x01/react-datepicker. On the clojurescript side, I do a (:require ["@foo/bar" :as bar]) and then do [:> bar/DatePicker …] The error I get is: Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Looking at the react-datepicker issues, I came across: https://github.com/Hacker0x01/react-datepicker/issues/1333 but changing my tsx code to point at ReactDatePicker.default doesn’t seem to do the trick either.#2020-08-2817:50devnWhat I have verified is that I can indeed use react-datepicker directly, but not when it’s nested in a component from another package.#2020-08-2817:50devnI don’t know if this is a shadow-cljs question or not, but I am quite confused and any help would be appreciated.#2020-08-2817:53devnon the TS side, the component file looks roughly like:
import * as React from 'react';
import ReactDatePicker from 'react-datepicker';

export interface DatePickerProps {
  ...
}

export const DatePicker = (props: DatePickerProps) => {
 ...
  return (
    <div>
      <ReactDatePicker
        ...
      />
    </div>
  );
};
#2020-08-2818:07msshey there, two quick questions: 1. I’ve got a :node-script target with :compiler-options {:hashbang false} yet a shebang still seems to be getting inserted at the beginning of my compiled file. any idea what might be causing that? I’m on 2.11.1 2. is there a way to inline generated source maps as opposed to keeping them in separate files? #2020-08-2820:03thheller@devn see https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2020-08-2820:04thheller@mss :hashbang false is directly in the build config, not inside :compiler-options#2020-08-2820:05thheller:compiler-options {:source-map-inline true}#2020-08-2820:12devn@thheller anything to add there? The trouble seems to be with the ReactDatePicker, not my component that wraps it.#2020-08-2820:12devnand I expose a number of components from the lib, via a :require :as#2020-08-2820:14thhellerI don't know what you are doing#2020-08-2820:15thheller> Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.#2020-08-2820:15thhelleris telling you that when using [:> Thing ...] Thing was undefined. so you said bar/DatePicker which probably meant bar/DatePicker is undefined#2020-08-2820:15thhellerthats all I can tell you without seeing more code#2020-08-2820:20devnbar/DatePicker is there, but I get the error about a nested component within that component named ReactDatePicker#2020-08-2820:21devnbut it works fine on the plain typescript side#2020-08-2908:04p-himikPlease create a minimal reproducible example. Otherwise it's unproductive guesswork.#2020-08-3002:15devnwill do#2020-08-2917:01jmckitrickWhy would I get WARNING] can't find node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.transform.js, please install npm install --save-dev shadow-cljs. even after I’ve run the npm install command?#2020-08-2917:02thhellerlooks like either have an ancient global install or ancient project install of shadow-cljs#2020-08-2917:02thhellerthat file hasn't existed for quite a while#2020-08-2917:03jmckitrickThat’s very possible. How to clean up?#2020-08-2917:03jmckitrickglobal de-install and stick to project-only install?#2020-08-2917:04thhellerproject-only install means you must always run through npx shadow-cljs ...#2020-08-2917:04thhellerif you are ok with that you don't need the global install at all#2020-08-2917:06thhellerthe global install will use the project install if its a compatible version#2020-08-2917:06thhellerwhich it usually is ... just not if they are too far apart#2020-08-2917:08jmckitrickWhat’s the cleanest way to remove the binary at /usr/local/bin/shadow-cljs so I don’t have a conflict?#2020-08-2917:08jmckitricknpm uninstall -g shadow-cljs seems like it works but the binary is still there#2020-08-2917:09jmckitrickAnd I don’t want to just delete it, that’s sloppy#2020-08-2917:09thhellercheck out where it is actually from#2020-08-2917:10thhellerwhich shadow-cljs or so#2020-08-2917:10thhellermaybe you installed it via yarn?#2020-08-2917:10jmckitrickah, ok. Let’s see…#2020-08-2917:13jmckitrickIt’s acting like it removed it, but the binary is still there… 🤔#2020-08-2917:14thhellerjust look at the file#2020-08-2917:15thhelleris it a symlink? is it a bash script calling some other path?#2020-08-2917:15thhellermust be from somewhere#2020-08-2917:16jmckitrickAh, ok. You’re right, it’s a symlink to a yarn install. But I just removed that, I thought…#2020-08-2917:16jmckitrickI didn’t see a ‘global’ flag on yarn remove…. I’ll look again#2020-08-2917:17thhelleryarn global remove#2020-08-2917:17jmckitrickAh, it’s a prefix….#2020-08-2917:17jmckitrickBingo!#2020-08-2917:18jmckitrickI’m almost there… I’m extracting the luminus shadow config into a standalone config….#2020-08-2917:19jmckitrickIt’s complaining about `com/cognitect/transit.js:649:8  variable module is undeclared`#2020-08-2917:19jmckitrickIs that a dev dependency I need?#2020-08-2917:20thhellerthats just a warning. you can ignore that.#2020-08-2917:21jmckitrickHmm.. my hot reloading has disappeared….#2020-08-2917:22jmckitrickI’m running in CIDER, and it worked when it was all in one project.clj… let me stash my changes and confirm that…#2020-08-2917:22thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-08-2917:25jmckitrickAll fixed. A fresh start of emacs and cider did the trick….#2020-08-2917:29jmckitrickSo what issues will I have if my src files are separated by extension?#2020-08-2917:29jmckitrickThe manual says ‘harder to use’#2020-08-2920:23thhelleryour choice. if you like doing it then do it. I'm assuming you are talking about src/clj and src/cljs?#2020-08-2920:43jmckitrickCorrect#2020-08-2920:44jmckitrickThe last piece I’m working on today is how to get ‘env/dev/cljs’ in the source path for dev, and ‘env/prod/cljs’ for prod given that :source-paths are global and there can be only one.#2020-08-2920:44thhellermust use lein or deps.edn if you need that#2020-08-2920:44thhellernot supported by shadow-cljs.edn#2020-08-3009:22Umar Darazhi friends, I don't know if it is a right channel to post this question or not. Please forgive me if it is not. I m unable to start cider-jack-in-clojurescript for my shadowcljs project in spaceemacs but cider-jack-in works fine. Please help me know what i m missing to make it work! Here are the logs that I m getting. Thanks
A session with the same parameters exists (clojure-projects/reviews:localhost:56442).  You can connect a sibling instead.  Proceed? (y or n) y
[nREPL] Starting server via /usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
[nREPL] server started on 57396
[nREPL] Establishing direct connection to localhost:57396 ...
[nREPL] Direct connection to localhost:57396 established
error in process filter: user-error: The shadow-cljs ClojureScript REPL is not available.  Please check  for details
error in process filter: The shadow-cljs ClojureScript REPL is not available.  Please check  for details
#2020-08-3009:40thheller@umardaraz4747 probably better to ask in #cider. This doesn't look like it is starting shadow-cljs.#2020-08-3009:42Umar Darazsure @thheller and thank you so much for shadow cljs 🙏#2020-08-3112:49timrichardt
import * as React from "react";
suddenly results in this error:
Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import React from 'goog:module$node_modules$react$index';?
#2020-08-3112:50timrichardtafter upgrading to shadow-2.11.1#2020-08-3112:52timrichardtDid something fundamentally change? :)#2020-08-3113:26timrichardtYep, I just have to read the release notes 🙂#2020-09-0108:01timrichardtAfter 2.11.0 the default imports inside .js are kinda weird now? If i
import Card from "@material-ui/core/Card";
I now only can use it via
<Card.default> ... </Card.default>
The
import { foo } from "bar"
imports work as expected.
#2020-09-0108:30thheller@timrichardt unfortunately that is the only way I can make it work. closure is kinda strict about commonjs <-> ESM interop and as far as Closure is concerned it only sees the npm packages as commonjs#2020-09-0108:32thhellerdid you not have issues with JS code in release prior to 2.11.0?#2020-09-0108:32timrichardtI did, but this works now, as you intended.#2020-09-0108:35timrichardtThx. 🙂#2020-09-0109:00thhellerI wonder whats going to happen with webpack5. they've been talking about breaking changes in this area for years#2020-09-0109:02thhellerhttps://github.com/webpack/webpack/issues/11406 looks like its going to happen soon. hope it'll improve the situation a bit#2020-09-0113:48dazldtap> is super handy! is there any way to be able to send stuff from a server side process to the inspect tab via the same helper..?#2020-09-0114:37Lucy Wangnot sure if possible, but for a pretty good general REBL-like solution, checkout https://github.com/djblue/portal#2020-09-0210:50pithyless@dazld I do just that, by starting a second shadow-cljs instance on the server-side. If you're running some kind of component system, you can hook up as just another start/stop component 🙂#2020-09-0210:52pithyless
(:require [shadow.cljs.devtools.server :as shadow-server])

(defn start-shadow-inspect []
  (println "Starting shadow-server...")
  (shadow-server/start!))
^ It will find an open port and print on what port it started.
#2020-09-0115:25thheller@dazld tap> for CLJ currently only works in the process where shadow-cljs is running. remote otherwise only works for CLJS.#2020-09-0118:25scottloweI'm getting a security notification for the NPM lib Elliptic which needs to be bumped from 6.5.1 to 6.5.3. The dependency is only local but it's being included by shadow-cljs as a dependency of node-libs-browser. https://github.com/advisories/GHSA-vh7m-p724-62c2#2020-09-0118:25scottloweI was simply going to wait until shadow-cljs gets updated, but I've just noticed that node-libs-browser is deprecated and unlikely to be updated. Should I simply patch my yarn.lock file with a new elliptic version, or are there any plans for shadow-cljs that will sidestep this issue in the near future?#2020-09-0118:26scottloweelliptic module in shadow-cljs dependency tree#2020-09-0118:28thhellerI don't know what is going to happen with node-libs-browser once webpack v5 is out#2020-09-0118:29thhelleryou can just bump the dependency in your project if you are worried but it isn't really relevant and this will only ever be used in browser builds#2020-09-0118:29thhellerwhich are probably safe. don't see how one could ever exploit this.#2020-09-0118:30scottloweOkay, thanks @thheller That's what I was thinking. It's only used in dev, obviously. Thanks! 🙇#2020-09-0118:30thhellerno its used in production BUT node-libs-browser are polyfills for npm built-in packages#2020-09-0118:31scottloweAch. Right. Thanks for the correction.#2020-09-0118:31thhellerso you have to use a npm package that uses any of these. I'm assuming its require("crypto") and then use this in a browser (as :node-script etc will not use node-libs-browser)#2020-09-0118:32thhellerI can bump the node-libs-browser dep. maybe thats enough.#2020-09-0118:42scottloweI see what you mean. The version restrictions on crypto-browserify are relaxed for the minor version; so the child dependencies can be updated, even if there isn't a new release of node-libs-browser.#2020-09-0118:43scottloweOh. That works for me locally too with yarn upgrade. I now have {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "caafa6a6a3babea3a98afce4ffe4f9"}, :content ("[email protected]")}. The joys of semantic versioning (seriously). The version restrictions were loose enough in shadow-cljs deps that I received the updated child packages. Well that's solved my problem 😊#2020-09-0312:54jntnHey! Anyone knows if it possible to hook into and change the configuration before any builds starts? I know of the :build-hooks but they are just for a particular build. I want to be able to add new builds dynamically. :relaxed:#2020-09-0313:04thheller@jntn what do you mean by "add new builds dynamically"?#2020-09-0313:10jntnWell, I want to create node-script builds for at lot of files without having to add them all to the shadow-cljs.edn. I am looking into using Vercel (formerly zeit now) to deploy a clojurescript project. And Vercel has a folder (/api) where every file becomes a lambda function. I basically want to be able to put a *.cljs file into a folder and magically shadow-cljs produces a js file in, say /api. I could of course add them all to the shadow-cljs manually, but there could potentially be very many. Sorry of this does not make any sense 😅#2020-09-0313:11thhelleryou can just go through the API functions directly#2020-09-0313:12thheller(shadow.cljs.devtools.api/release* {:build-id :app :target :node-script :main 'foo.bar/main :output-to "somewhere/script.js"} {})#2020-09-0313:13thhellerthats like calling shadow-cljs release app but instead of loading the build config from shadow-cljs.edn you just pass it in directly#2020-09-0313:13thhellerthe map is what you'd usually have in shadow-cljs.edn :builds but also requires the :build-id to be present#2020-09-0313:14thhellersounds a bit crazy to me to build one file per handler though but I can't remember if it let you load other files as well#2020-09-0313:15jntnThanks a lot! That seems like a great way to do it.#2020-09-0313:15thhellercoupled with https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run you can do pretty much anything you want#2020-09-0313:16jntnIt could indeed be a bad idea, I am just experimenting 😋 I really like Vercel and shadow-cljs and really want them to work together#2020-09-0313:18thhellerI did some experiments some time ago as well as others#2020-09-0313:18thhellerI just can't remember any of it 😛#2020-09-0313:20dpsutton@jntn this sounds like a great article if you have any interest in writing#2020-09-0313:24jntn@dpsutton If I get something working, why not! 🙂#2020-09-0313:25jntnI have actually created a custom builder for Now that works well, but it is a bit outdated and uses old deprecated apis. https://github.com/jntn/now-shadow-cljs#2020-09-0313:25jntnSo I am looking for new possibilities#2020-09-0315:50alexstokes(reposting from #clojurescript as i just found this channel for shadow-cljs specifically)#2020-09-0315:50alexstokeshi all, I’m trying to use a js lib w/ shadow-cljs and getting an error from the closure compiler about an unsupported feature `bigint`  — my dependency uses `bn.js`#2020-09-0315:50alexstokesdoes anyone know how to fix this or where I can read more? i’m wondering if there is a flag i can set somewhere or if it truly is just unsupported in cljs right now…#2020-09-0315:54lilactowndoes --debug preserve line numbers by chance? 😬#2020-09-0315:55lilactown@alexstokes need more info. how are you installing the JS library?#2020-09-0315:57lilactownI guess pretty-print def would not preserve line numbers#2020-09-0316:07lilactownpseudo-names also seems to change the line numbers quite a bit 😞#2020-09-0316:17alexstokesjust npm install @chainsafe/discv5#2020-09-0316:18lilactownand what’s the full error?#2020-09-0316:18alexstokesfollowing this: https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps#2020-09-0316:19alexstokes
cljs.user=> (require '["@chainsafe/discv5" :as discv5])
[2020-09-03 08:18:14.954 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(require '[\"@chainsafe/discv5\" :as discv5])", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (require (quote ["@chainsafe/discv5" :as discv5])), :source "(require '[\"@chainsafe/discv5\" :as discv5])", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:520)
        shadow.cljs.repl/process-read-result (repl.clj:494)
        shadow.cljs.repl/process-input (repl.clj:674)
        shadow.cljs.repl/process-input (repl.clj:658)
        shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--15149 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813/fn--14821 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14812/fn--14813 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14812 (util.clj:257)
        java.lang.Thread.run (Thread.java:834)
Caused by:
ExceptionInfo closure errors {:tag :shadow.build.closure/errors, :errors [{:resource-name nil, :source-name nil, :line -1, :column -1, :msg "Attempted to run pass \"markUntranspilableFeaturesAsRemoved\" on input with features it does not support. Running pass anyway.\nUnsupported features: [bigint]"}]}
        shadow.build.closure/throw-errors! (closure.clj:1164)
        shadow.build.closure/throw-errors! (closure.clj:1158)
        shadow.build.closure/convert-sources-simple* (closure.clj:1902)
        shadow.build.closure/convert-sources-simple* (closure.clj:1759)
        shadow.build.closure/convert-sources-simple (closure.clj:2057)
        shadow.build.closure/convert-sources-simple (closure.clj:2009)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1172)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1165)
        shadow.build.compiler/compile-all (compiler.clj:1417)
        shadow.build.compiler/compile-all (compiler.clj:1284)
        shadow.build.api/compile-sources (api.clj:259)
        shadow.build.api/compile-sources (api.clj:251)
------ REPL Error while processing ---------------------------------------------
(require '["@chainsafe/discv5" :as discv5])
Closure compilation failed with 1 errors
--- null:-1
Attempted to run pass "markUntranspilableFeaturesAsRemoved" on input with features it does not support. Running pass anyway.
Unsupported features: [bigint]
#2020-09-0316:25lilactownthis looks relevant: https://github.com/google/closure-compiler/issues/3167#2020-09-0316:26lilactownyou can try setting your language-in / language-out to ECMASCRIPT_2019. I’m not sure if that will resolve the compiler error or not#2020-09-0316:33alexstokesyeah as far as i know that lib is not using the native type so i’m not sure why the closure compiler will fail#2020-09-0316:34lilactownthe lib you posted relies on https://github.com/no2chem/bigint-buffer#2020-09-0316:34lilactownwhich does seem to use the proposed native BigInt#2020-09-0316:43thheller@alexstokes yeah the closure compiler cannot transpile bigints away, so the only option is turning off ALL transpilation
#2020-09-0316:44thheller:compiler-options {:output-feature-set :es-next} I believe it the setting. let me check.#2020-09-0316:44thhelleror :compiler-options {:language-out :no-transpile}#2020-09-0316:57thheller@lilactown what do you mean by "preserve line numbers"? --debug adds source maps so you can get the original line from that?#2020-09-0316:58lilactownI had an issue in production that I’m trying to reverse engineer the line numbers/symbols#2020-09-0316:59lilactownthe sourcemaps aren’t showing up in the stack trace unfortunately#2020-09-0316:59thhellerin a --debug build?#2020-09-0316:59lilactownno, in the production build. I haven’t figured out how to reproduce the error either#2020-09-0317:00thhellerrelease builds don't have source maps by default? did you enable them?#2020-09-0317:00lilactownyeah they’re enabled#2020-09-0317:00thheller--debug is source map + pseudo names#2020-09-0317:00thhellerhmm then everything should be source mapped? unless your error is somewhere deep in react-dom or so.#2020-09-0317:01thhellerthat uses the minified react-dom.production.min.js which doens't have source maps#2020-09-0317:02lilactownit starts in React but bubbles up to cljs.core#2020-09-0317:03lilactownI think we figured it out (it was really bizarre) but in general I would like to have the source maps show in up in exceptions#2020-09-0317:03lilactownit could be that we’re catching them and console.loging them?#2020-09-0317:10thheller> catching them#2020-09-0317:10thhellerwhos them?#2020-09-0317:11thhellerah the exceptions#2020-09-0317:11thhellerdepends on how you log them#2020-09-0317:11thhellerif you (js/console.log ex) chrome source maps them. if you (js/console.log (.-stack ex)) it does not I believe#2020-09-0317:12alexstokes@thheller neither of those :compiler-options changed anything, but thanks for your help#2020-09-0317:17thhelleris this lib meant to run in the browser?#2020-09-0317:18alexstokesit is running here#2020-09-0317:18alexstokeshttps://enr-viewer.com/#2020-09-0317:18alexstokesperhaps there is an issue w/ typescript?#2020-09-0317:18alexstokesi tried this as well and getting the same error still#2020-09-0317:18alexstokes
:compiler-options {:language-in :es-next
                    :output-feature-set :es-next}
#2020-09-0317:18thheller:language-out not in#2020-09-0317:19thhellerin already defaults to :es-next and changes nothing#2020-09-0317:19alexstokesdocs say :output-feature-set replaces :language-out#2020-09-0317:19thhelleryes don't use both#2020-09-0317:19thhellerthats why I suggested them separately ... try :compiler-options {:language-out :no-transpile}#2020-09-0317:20thhellerONLY, without :output-feature-set#2020-09-0317:20thheller:output-feature-set is the newer option but I don't think it has a "do nothing" option#2020-09-0317:20alexstokesi tried both separately, will double check again#2020-09-0317:22alexstokescan’t get past the error w/ any of the above options#2020-09-0317:24thhellerI believe the release that came out a few days ago had some changes in that area#2020-09-0317:24thhellerdunno how the support looks though. may still not work.#2020-09-0317:24thhellerv20200830 maybe try that#2020-09-0317:26thhellerif all else fails use webpack ala https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external 😉#2020-09-0317:29alexstokesv20200830 is referring to a shadow-cljs release?#2020-09-0317:31thhellerno the closure compiler [com.google.javascript/closure-compiler-unshaded "v20200830"]#2020-09-0317:32thhellercurrently is at [com.google.javascript/closure-compiler-unshaded "v20200719"] (if you are on 2.11.x)#2020-09-0318:35alexstokesah thanks, i’ll try some of these options#2020-09-0320:44Pete ParkerI’m under the impression that returning a modified build-state in a build hook will affect the build, but it does not appear to. I have tried updating both :output-dir and :closure-defines in the :configure stage and the build appears to use their original values. (When I log the build config in subsequent stages it is updated, but the build does not reflect the update.) Am I misunderstanding how to modify build-state via hooks?#2020-09-0320:45thhellerI don't know. what did you modify?#2020-09-0320:46thhellerlike (assoc build-state :output-dir whatever) won't do anything#2020-09-0320:47Pete Parker
(update-in build-state [:shadow.build/config :closure-defines] merge {some/other "config"})
#2020-09-0320:48thhellerfor example if you want to override the :output-dir of a :browser build you need to override this value https://github.com/thheller/shadow-cljs/blob/9178e39a84108b1c0b9b26368b161a9501f4b39f/src/main/shadow/build/targets/browser.clj#L317#2020-09-0320:48thhellerbuild-hooks run after the specific :target implementation and the :target implementation will already have taken everything out of :shadow.build/config and not look at it again#2020-09-0320:49thhellerso closure defines would be in (update-in build-state [:compiler-options :closure-defines] merge {})#2020-09-0320:50Pete ParkerAh, that is likely my error…#2020-09-0320:51thhelleryeah you can look at the config and get stuff for your hook from it if needed but the target usually won't use it anymore after the :configure stage#2020-09-0320:52Pete ParkerThere isn’t any pre-configure stage, is there?#2020-09-0320:53thhellerno#2020-09-0320:54Pete ParkerOkie dokie, I’ll modify those values in their final locations. 👍#2020-09-0407:45gravWhen I want to hack on my node app, I first start up Shadow in watch mode. Then I need to wait a bit until Shadow is done compiling, before starting the node process. Can I automate this in some way?#2020-09-0407:48Chris McCormick@grav you can try something like this:
srv=build/server.js
# run the server under node
( rm -f ${srv}; while [ 1 ]; do if [ -f ${srv} ]; then node ${srv}; else sleep 1; fi; done ) &
# watch-and-compile the server
( npx shadow-cljs watch server ) &
here the node script artifact being built is build/server.js
#2020-09-0407:49gravAh, good idea. So simply remove the build artifact and then wait for it to show up!#2020-09-0407:49Chris McCormickat the end of the script i have a wait and run everything as background tasks. at the start of the script i have this:
trap killgroup SIGINT

killgroup(){
  echo killing...
  kill 0
}
which kills everything launched in the script when ctrl-C is run
#2020-09-0407:49Chris McCormickprobably i should document this somewhere#2020-09-0407:50gravGreat hack! Thanks a bunch @chris358 🙂#2020-09-0407:51thhelleror use shadow-cljs node-repl and go from there 😉#2020-09-0408:05grav@thheller So you mean use Clojure instead of Bash? Sounds tempting :-) I haven't used the shadow api much, apart from (shadow/watch :my-app). But that doesn't seem to work in a node-repl? Am I mis-reading https://shadow-cljs.github.io/docs/UsersGuide.html#node-repl?#2020-09-0408:11thhellerI do not know what you read from that#2020-09-0408:12thhelleryou just get a blank CLJS REPL that isn't tied to your :my-app build but can still just (require '[ :as x]) and (x/main "foo" "bar") or so (emulating a regular :node-script build for example)#2020-09-0408:13thhellernode-repl just manages the node process so you don't have to use hacks to wait for files to appear or so#2020-09-0408:13thhellerjust gives you the regular clojure-like REPL experience#2020-09-0411:14hoppyprobably doing something horribly wrong, but this seemed like it used to work.#2020-09-0411:15hoppynow getting TypeError: ia.format is not a function in release, but works in repl. Obviously getting minified away. Any good way to avoid?#2020-09-0411:53thheller@hoppy you were probably relying on some of your :preloads loading goog.string.format#2020-09-0411:53thhellerjust add it to your :require in the ns#2020-09-0411:53thhellerformat is actually it its own "namespace". looks a bit weird but works#2020-09-0412:10hoppyok, this works. I'm not sure I understand why, or whether I need to.#2020-09-0412:10hoppybut thanks#2020-09-0412:17thheller...#2020-09-0412:17thhellerdont remove the first one#2020-09-0412:18thheller
(ns my-app.core
  (:require [goog.string :as gstring]
            [goog.string.format]))
#2020-09-0412:18thhellerI know its weird .. blame the closure library#2020-09-0412:18thhelleryou need to because goog.string and goog.string.format format are basically 2 namespaces#2020-09-0412:18thhellerbut for some reason goog.string.format is not actually a namespace, only a function#2020-09-0412:19thhellerbut it is in its own file so it needs to be required properly#2020-09-0412:20hoppyneato 😜#2020-09-0412:21hoppyyou are probably right though, I dug that code out of a different working project, so it was probably osmosis of some sort.#2020-09-0412:21hoppythanks again for the help#2020-09-0412:21thhelleryeah it works by accident if goog.string.format was required anywhere else but its not something you should rely on so the :require fixes that#2020-09-0415:24Jakub Holý (HolyJak)Hello! When I make a simple change to my app, it takes Shadow 3-7 seconds to recompile the change, after which the app re-renders. Is that duration normal? Or do I use too many libraries or is the changed UI namespace too large? What can I do to speed it up, so that I can change the code (add a new dom element, change button label, ...) and see the change "at once"? Thank you!!!#2020-09-0415:46wilkerlucioIME keeping files small makes a good difference for compilation times, so it potentially has less things to compile#2020-09-0415:47wilkerlucio3-7 seconds seems a very high time for me, in the biggest project I worked on (30k+ LOC), we were still getting compilations in 500ms avg (except when touching some of the big files, there it could go up to 3 seconds, but rarely more than that)#2020-09-0416:46Jakub Holý (HolyJak)Thanks! Perhaps something is wrong with my setup, I will clean up everything and upgrade shadow to latest.#2020-09-0416:37thheller@holyjak that seems excessive and shouldn't be that slow. complex macros can significantly impact recompile speeds. maybe try running with shadow-cljs watch app --verbose or use the UI to see where it spends its time#2020-09-0417:54Jakub Holý (HolyJak)Here is the verbose log:
[:main] Compiling ...
<- Resolving Module: :main (171 ms)
<- Compile CLJS: minbedrift/ui.cljc (118 ms)
<- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1460 ms)
<- Cache write: minbedrift/ui.cljc (852 ms)
<- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (1370 ms)
<- build target: :browser stage: :compile-finish (312 ms)
<- Flushing unoptimized modules (2066 ms)
<- build target: :browser stage: :flush (2465 ms)
[:main] Build completed. (1076 files, 2 compiled, 0 warnings, 6.64s)
I think I saw much better compile times on this app before summer so something in the environment must have changed...
#2020-09-0419:39thhellerwell thats defienitely slow. what does minbedrift/ui/kostnadsdeling/ui.cljc do? macro heavy stuff? maybe including huge edn data?#2020-09-0419:40thhellerCache write: minbedrift/ui.cljc (852 ms) is also quite slow#2020-09-0419:40thhellerhow big are these files?#2020-09-0518:31Jakub Holý (HolyJak)No. no big EDN. kostnadsdeling/ui has 593 lines, 31KB, and 13 direct macro calls, namely Fulcro's defsc . minbedrift/ui has 3KB and 75 lines (and includes the kostnadsdeling.ui namespace and others).#2020-09-0518:35Jakub Holý (HolyJak)After really upgrading to 2.11.1 I get
<- Cache write: minbedrift/ui.cljc (709 ms)
<- Compile CLJS: minbedrift/ui/kostnadsdeling/ui.cljc (1339 ms)
<- Cache write: minbedrift/ui/kostnadsdeling/ui.cljc (552 ms)
after a trivial code change
#2020-09-0618:52thhellersource file size doesn't necessarily mean much if there is a macro in it expanding to something huge#2020-09-0618:52thhellercheck the generated .js file for the size#2020-09-0618:56thhellerit might also just be something in your system intefering with file writing#2020-09-0618:56thhelleranti virus or that kind of stuff is often the cause#2020-09-0618:56thhellerscanning all newly written files making everything slow#2020-09-0618:57thhellerI'm not on macos but on windows the windows defender thing is causing such issues and performance goes up significantly if the project dir is just ignored#2020-09-0716:09Jakub Holý (HolyJak)Thanks, I will try that!#2020-09-0417:49Jakub Holý (HolyJak)I guess my shadow issues are related to the following problem logged in the browser console, which I have not seen before (on a project I haven't used for a 2-3 months): > failed to parse websocket message {:type :repl/init, :repl-state {:shadow.cljs.repl/repl-state true, :current-ns cljs.user, :repl-sources [...], :repl-actions []}} #error {:message "Invalid reader tag: :type. Reader tags must be symbols.", :data {:type :reader-exception, :ex-kind :reader-error}} Any idea what could be wrong / where to look? I have just upgraded to shadow 2.11.1, deleted node_modules and .shadow-cljs, and installed/started from scratch.#2020-09-0419:19thheller@holyjak uhm that doesn't look like 2.11.1? do you use project.clj or deps.edn and didn't upgrade there?#2020-09-0419:47Jakub Holý (HolyJak)thank you! What about package.json? Does the version been manually synced between this and deps?#2020-09-0419:52thhellerif you use deps.edn then you need to update deps.edn#2020-09-0419:53thhellerthe npm version in package.json should be somewhat close since things may break if they are too far apart#2020-09-0505:19bennyany suggestions how to fix shadow getting the wrong IP? (`shadow.cljs.devtools.client.env.server_host`)#2020-09-0508:39thheller@benny wrong IP in which context? react-native?#2020-09-0514:58danielstocktonI'm trying to compile a build for aws lambda, which renders a react app server side. Keep getting the error "Runtime.ImportModuleError: Error: Cannot find module 'react'", in logs, which doesn't appear in the frontend build. Anyone know what i'm missing?#2020-09-0514:58danielstocktonIt's a reagent/re-frame app#2020-09-0516:14thheller@danielstockton looks like you are not copying the node_modules for the lambda. node-script and node-library builds by default do not bundle their dependencies and will delegate to node to provide them. you can post process the output with something like https://github.com/vercel/ncc to make them fully self-contained if you want.#2020-09-0516:14danielstocktonYeah, im not. I guess i need to copy it into the zip before updating function code#2020-09-0516:15danielstocktonncc might be useful, thanks#2020-09-0602:15kiranshilaHow do I get around Cannot infer target type in expression errors? The code compiles are first go, but it breaks hot-reloading. I'm trying to use web bluetooth.#2020-09-0602:33kiranshilaI tried going the route of adding a node module that wraps web bluetooth, but I get compiler errors
[:app] Build failure:
Failed to inspect file
  <project>/node_modules/keypress/index.js

it was required from
  <project>/node_modules/node-web-bluetooth/src/InteractiveTermList.js

Errors encountered while trying to parse file
  <project>/node_modules/keypress/index.js
  {:line 374, :column 30, :message "Octal integer literals are not supported in strict mode."}
  {:line 375, :column 30, :message "Octal integer literals are not supported in strict mode."}
#2020-09-0607:21Jakub Holý (HolyJak)Based on the previous discussion, I guess that recompilation times of 2.3 - 3.8s during watch are also very high, correct? I have just tested running npx shadow-cljs watch :main --verbose in https://github.com/fulcrologic/fulcro-rad-demo/, forcing a recompilation by changing a string at line 57 of src/shared/com/example/ui/sales_report.cljc Detailed verbose output in the thread.#2020-09-0607:22Jakub Holý (HolyJak)First recompile, 3.8s:
[:main] Compiling ...
-> Resolving Module: :main
<- Resolving Module: :main (83 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: com/example/ui/sales_report.cljc
-> Compile CLJS: com/example/ui/dashboard.cljc
-> Compile CLJS: com/example/ui.cljc
<- Compile CLJS: com/example/ui/dashboard.cljc (136 ms)
-> Cache write: com/example/ui/dashboard.cljc
<- Compile CLJS: com/example/ui/sales_report.cljc (518 ms)
-> Cache write: com/example/ui/sales_report.cljc
<- Compile CLJS: com/example/ui.cljc (457 ms)
-> Cache write: com/example/ui.cljc
<- Cache write: com/example/ui/dashboard.cljc (616 ms)
<- Cache write: com/example/ui/sales_report.cljc (753 ms)
<- Cache write: com/example/ui.cljc (1201 ms)
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (20 ms)
-> build target: :browser stage: :flush
-> Flush: com/example/ui.cljc
-> Flush: com/example/ui/dashboard.cljc
-> Flush: com/example/ui/sales_report.cljc
<- Flush: com/example/ui/dashboard.cljc (4 ms)
<- Flush: com/example/ui.cljc (11 ms)
<- Flush: com/example/ui/sales_report.cljc (17 ms)
-> Flushing unoptimized modules
-> Flush: shadow/module/main/append.js
<- Flush: shadow/module/main/append.js (2 ms)
<- Flushing unoptimized modules (1425 ms)
<- build target: :browser stage: :flush (1583 ms)
[:main] Build completed. (1014 files, 3 compiled, 0 warnings, 3.87s)
Second recompile, 2.3s:
[:main] Compiling ...
-> Resolving Module: :main
<- Resolving Module: :main (70 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: com/example/ui/sales_report.cljc
-> Compile CLJS: com/example/ui/dashboard.cljc
-> Compile CLJS: com/example/ui.cljc
<- Compile CLJS: com/example/ui/dashboard.cljc (53 ms)
-> Cache write: com/example/ui/dashboard.cljc
<- Compile CLJS: com/example/ui/sales_report.cljc (436 ms)
-> Cache write: com/example/ui/sales_report.cljc
<- Compile CLJS: com/example/ui.cljc (323 ms)
-> Cache write: com/example/ui.cljc
<- Cache write: com/example/ui/dashboard.cljc (593 ms)
<- Cache write: com/example/ui/sales_report.cljc (618 ms)
<- Cache write: com/example/ui.cljc (675 ms)
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (15 ms)
-> build target: :browser stage: :flush
-> Flushing unoptimized modules
-> Flush: com/example/ui/sales_report.cljc
-> Flush: com/example/ui/dashboard.cljc
<- Flush: com/example/ui/sales_report.cljc (10 ms)
-> Flush: com/example/ui.cljc
<- Flush: com/example/ui/dashboard.cljc (14 ms)
<- Flush: com/example/ui.cljc (7 ms)
-> Flush: shadow/module/main/append.js
<- Flush: shadow/module/main/append.js (0 ms)
<- Flushing unoptimized modules (756 ms)
<- build target: :browser stage: :flush (778 ms)
[:main] Build completed. (1014 files, 3 compiled, 0 warnings, 2.32s)
#2020-09-0607:23Jakub Holý (HolyJak)Is it simply because Fulcro is too macro-heavy and there is no way around it? Thank you for any hints!!!#2020-09-0607:42thheller
[:main] Build completed. (1014 files, 1013 compiled, 0 warnings, 48.54s)
[:main] Compiling ...
-> Resolving Module: :main
<- Resolving Module: :main (44 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: com/example/ui/sales_report.cljc
-> Compile CLJS: com/example/ui/dashboard.cljc
-> Compile CLJS: com/example/ui.cljc
<- Compile CLJS: com/example/ui/dashboard.cljc (20 ms)
-> Cache write: com/example/ui/dashboard.cljc
<- Compile CLJS: com/example/ui/sales_report.cljc (82 ms)
-> Cache write: com/example/ui/sales_report.cljc
<- Compile CLJS: com/example/ui.cljc (78 ms)
-> Cache write: com/example/ui.cljc
<- Cache write: com/example/ui/dashboard.cljc (174 ms)
<- Cache write: com/example/ui/sales_report.cljc (173 ms)
<- Cache write: com/example/ui.cljc (216 ms)
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (8 ms)
-> build target: :browser stage: :flush
-> Flushing unoptimized modules
-> Flush: com/example/ui/sales_report.cljc
-> Flush: com/example/ui.cljc
-> Flush: shadow/module/main/append.js
<- Flush: shadow/module/main/append.js (5 ms)
<- Flush: com/example/ui.cljc (22 ms)
<- Flush: com/example/ui/dashboard.cljc (28 ms)
<- Flush: com/example/ui/sales_report.cljc (38 ms)
<- Flushing unoptimized modules (133 ms)
<- build target: :browser stage: :flush (150 ms)
[:main] Build completed. (1014 files, 3 compiled, 0 warnings, 0.68s)
#2020-09-0607:43thheller[:main] Build completed. (1014 files, 3 compiled, 0 warnings, 0.56s)#2020-09-0607:44thhelleraverages out around that area on my machine which is very fast so I don't know if its just a hardware difference or maybe something else going on#2020-09-0607:44thhellerwhat kind of system are you on?#2020-09-0607:45thhellermaybe your harddisk is almost full or something?#2020-09-0614:56Jakub Holý (HolyJak)Osx. Perhaps the disk, I will check. Thank you very much!#2020-09-0711:48Jakub Holý (HolyJak)Thank you very much for trying this out on your machine! I have an early 2015 MacBook Pro with 16GB RAM (14GB used) and an SSD disk, which was a high-performance machine at that time but perhaps is too aged now. The OS complained about the disk being used but increasing the free space from 5 to 10GB did not change the performance. I guess I just need a new mchine...#2020-09-0713:12thhellerI'm afraid its not the computer. I have pretty much the same machine. 2,5ghz i7 macback pro mid 2015. 16gb ram, ssd. recompile time is a bit slower but not much. about 0.69s#2020-09-0713:16thhellermaybe your disk is just getting slow which can happen in SSDs over long time#2020-09-0713:16thhelleror more likely its something running on your machine interfering with stuff#2020-09-0713:18thheller
-> Resolving Module: :main
<- Resolving Module: :main (24 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: com/example/ui/sales_report.cljc
-> Compile CLJS: com/example/ui/dashboard.cljc
<- Compile CLJS: com/example/ui/dashboard.cljc (11 ms)
-> Cache write: com/example/ui/dashboard.cljc
-> Compile CLJS: com/example/ui.cljc
<- Compile CLJS: com/example/ui/sales_report.cljc (62 ms)
-> Cache write: com/example/ui/sales_report.cljc
<- Compile CLJS: com/example/ui.cljc (66 ms)
-> Cache write: com/example/ui.cljc
<- Cache write: com/example/ui/dashboard.cljc (141 ms)
<- Cache write: com/example/ui/sales_report.cljc (134 ms)
<- Cache write: com/example/ui.cljc (158 ms)
-> build target: :browser stage: :compile-finish
<- build target: :browser stage: :compile-finish (9 ms)
-> build target: :browser stage: :flush
-> Flushing unoptimized modules
-> Flush: com/example/ui/sales_report.cljc
-> Flush: shadow/module/main/append.js
<- Flush: com/example/ui.cljc (1 ms)
<- Flush: com/example/ui/sales_report.cljc (1 ms)
<- Flushing unoptimized modules (177 ms)
<- build target: :browser stage: :flush (189 ms)
[:main] Build completed. (1012 files, 3 compiled, 0 warnings, 0.63s)
#2020-09-0713:18thhellerthats from my macbook, barely any difference#2020-09-0716:08Jakub Holý (HolyJak)Thank you! I will do further experiments.#2020-09-0607:39thheller@me1310 https://shadow-cljs.github.io/docs/UsersGuide.html#externs likely just need one ^js hint in the correct location? or just turn it off if you don't care about release. :compiler-options {:infer-externs false}#2020-09-0616:51kiranshilaRight, of course. Thanks so much!#2020-09-0618:32kiranshilaWhat does it mean if it still can't infer the target type, even with the type hint?#2020-09-0618:33kiranshilaI have the following in a go-loop, but I still get an error
(<p! (.writeValue ^js sock chunk))
#2020-09-0618:33kiranshila
Cannot infer target type in expression (. inst_48442 (writeValue inst_48443))
#2020-09-0618:34kiranshilathat sock value is the result of de-refing an atom#2020-09-0618:50thhellerah you are in core.async go. that appears to be loosing typehints#2020-09-0618:50kiranshilaOh interesting#2020-09-0618:50thhellerif you have the sock outside the go then annotate it there#2020-09-0618:57kiranshilaPerfect. Thank you!#2020-09-0619:48adamrenklintIs it possible to trigger the :after-load fn of a :target :browser build from the :flush hook of a :target :bootstrap build?#2020-09-0620:21tekacsMight anyone know why a macro that pulls in a symbol would cause “Use of undeclared Var” errors? i.e. a macro like
(ns a-ns
  (:require [some.namespace :as sn]))

(defmacro something []
  (sn/some-function "do a thing"))
… when used in another namespace seems to sporadically give me:
(ns another-ns)

(something) ;=> Use of undeclared Var some.namespace/some-function
Which is resolved by doing (:require [some.namespace]) at the use site of the macro… but this hasn’t usually been necessary and the issue goes away from time to time. This seems like it might be new behavior (I’m using 2.10.22), but that could be due to mutations in my own codebase. Would really welcome any thoughts on this, I’ve tried debugging and poking around a bunch to no reliable discovery of the pattern causing the issue so far 🙂
#2020-09-0620:27thheller@tekacs follow https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html#2020-09-0620:28tekacsah I think this is because I’m doing CLJC self-require - i.e. (ns app.util #?(:cljs (:require-macros [app.util]))#2020-09-0620:28tekacsoh hm no, I’m following the separate ns pattern here#2020-09-0620:28thhellerCLJC makes this 10x more complicated but it is fine if you do it correctly#2020-09-0620:29tekacsI’ll pick through and check I’m doing every step right#2020-09-0620:29tekacsthanks!#2020-09-0620:29thhellerthe example code you posted is incomplete so I cannot say where maybe you went wrong#2020-09-0620:29tekacs:+1:#2020-09-0620:31tekacsokay, I think that helped rebase/realign my understanding and I believe I’ve resolved it now — thanks so much for the prompt! 🙂#2020-09-0709:12AronWhat is the easiest way to take the output of the report and create a pie chart or something visual? So far I only tried to see if I can copy paste from the terminal or from html.#2020-09-0710:09thhellernot all of the data is exported in pure data form. you can check the .shadow-cljs/release-snapshots/<build-id>/latest/bundle-info.edn file, maybe it contains what you need?#2020-09-0710:17thhellerthe HTML file also has the data in EDN format so you could get it from there#2020-09-0710:51Aronthat's going to be perfect, thanks#2020-09-0716:45robert-stuttafordany js pros able to guide me on how to do this with cljs only, perhaps? (from the code inside the first example on https://react-select.com/advanced):
const SortableMultiValue = SortableElement(props => {
  const onMouseDown = e => {
    e.preventDefault();
    e.stopPropagation();
  };
  const innerProps = { onMouseDown };
  return <components.MultiValue {...props} innerProps={innerProps} />;
});
<SortableSelect
      components={{
        MultiValue: SortableMultiValue,
      }}
    />
one of the downfalls of working on cljs so long is i've long since forgotten all the javascript arcana!
#2020-09-0716:54thhellerisn't JSX fun? 😛 you are using reagent I presume?#2020-09-0717:02thheller
(def SortableMultiValue
  (SortableElement
    (fn [props]
      (let [mouse-down
            (fn [e]
              ...)]
        
        (react/createElement
          components/MultiValue
          (js/Object.assign
            #js {:innerProps
                 #js {:mouseDown mouse-down}}
            props))))))

[:> SortableSelect {:components #js { :MultiValue SortableMultiValue}}]
#2020-09-0717:02Aron@robert-stuttaford what have you tried so far? This does not appear to be exceedingly difficult to translate, it's a function getting a lambda and returning a dynamically created element with an injected eventhandler. (I would probably ask the person who wrote the original code to either document why this convolution or to rewrite it though)#2020-09-0717:02Aronwhy the object assign?#2020-09-0717:03thhellerI'm assuming those are React props which shouldn't be mutated (or even might be frozen)#2020-09-0717:03Aronoh, that's the merge because they are spreading the original props, got it#2020-09-0717:04Aronthis kind of state management is very fragile 😞#2020-09-0717:08robert-stuttaford@ashnur i have noooo experience translating any js using const - that's after my time. been cljsing since 2012 😅 it's super occasional that i need something like this. thank you @thheller! using rum actually, but yeah, this gets me there!#2020-09-0717:09thhellerjust replace const with var, if that makes it more readable 😉#2020-09-0717:10robert-stuttafordit would have been rad for the react-select folks to support multi-select as a first class feature, but this is the only method they offer. don't care to learn the whole thing's internals, just need the feature in. complexity budget reserved for the domain!#2020-09-0717:11thhelleryeah the react world likes to go crazy with HoCs 😛#2020-09-0720:53alpoxIt seems that they lessen again since Hooks came into play. Now there are just tons of those ^^#2020-09-0717:11robert-stuttafordyeah, i mean the whole es 2015 and onwards flavour of js. the last major js i wrote was raw gclosure in 2011/2012 😂#2020-09-0717:12robert-stuttafordi appreciate the quick response and help, @thheller, thank you sir o7#2020-09-0717:12robert-stuttafordold news to you, but shadow is fucking rad 👏#2020-09-0717:20Aronreact-select is the issue here, i gathered several hundreds of downvotes speaking my mind in its issue pages#2020-09-0717:21Aronand I can just agree with @thheller 🙂#2020-09-0717:57robert-stuttafordit may not do it well, but man, it's such an upgrade to anything we were doing before#2020-09-0718:03thhellerbut does it really justify adding 90kb to a release build? for a select thingy? feels like a little overkill#2020-09-0718:04thhellerbut I guess as far as react components are concerned thats still pretty reasonable 😛#2020-09-0722:08neilyioI'm not sure that my namespace dev.preload is being loaded from the :devtools {:preloads [dev.preload]} slot in my shadow-cljs.edn. I have (js/console.log "We are preloading.") right at the top of my dev.preload namespace and nothing is being printed in the browser. What should I try next?#2020-09-0722:14neilyioI can confirm that the following, from my main application namespace, does indeed print "We are preloading" when the app loads, so I know that dev.preload is the correct namespace.
(ns app.core
  (:require [dev.preload]))
#2020-09-0722:16neilyioI thought that having :devtools {:preloads [dev.preload]} in my build config would have the same effect, please let me know if there's an extra step or if there's something that I missed. If it helps, my :source-paths is just ["src"], and the file is src/dev/preload.cljs.#2020-09-0723:00thheller@neil.hansen.31 you need to be more specific WHERE you put the preloads. it is supposed to be in your build config. can't tell where you have it if you just paste a part, the part looks correct though.#2020-09-0723:04neilyioHey @thheller, thanks for the reply. I can confirm it's in the the build config, as in
:builds
  {:app
    {:target :npm-module
     ...
     :devtools {:preloads [dev.preload]}}}
#2020-09-0723:04thhellerthat is the correct position#2020-09-0723:04thhellerah ..#2020-09-0723:04neilyioSorry just made an edit above#2020-09-0723:04thheller:npm-module does not support preloads#2020-09-0723:05thhelleryou are kinda responsible to loading it yourself since there is no clearly defined way which namespace is loaded first#2020-09-0723:05thhellerie. the JS loading the code controls that#2020-09-0723:06neilyioGot it, thanks for clarifying. I really dug through the shadow-cljs user guide on this one, but sorry if I missed a mention of this anywhere.#2020-09-0723:07thhellerwell technically preloads is supported .. but they are only compiled and not loaded#2020-09-0723:07neilyioIs that true for all the npm/node targets?#2020-09-0723:08thhellerwhat are you doing? :npm-module is sort of deprecated and kinda dead#2020-09-0723:08thhellernope only :npm-module#2020-09-0723:10neilyioI'm (still) working on a CLJS + StorybookJS integration. I'm using the npm-module target, and having the Storybook process load all the compiled .js files that are prefixed with my stories namespace.#2020-09-0723:11neilyioStorybook asks for a glob path to the .js files that have your "stories" in them, so this was my solution. It feels kind of hacky (and is slow), but it's working right now. I'd love a tip if you have a suggestion!#2020-09-0723:11thhellerhmm yeah no clue about storybook. either way its going to be hacky 😛#2020-09-0723:13neilyioWhat's the best alternative to :npm-module?#2020-09-0723:13thhellerin case of storybook none#2020-09-0723:13thhellersince that really wants multiple files#2020-09-0723:16neilyioI think I can also just point it to a single file. Would :node-script be worth trying?#2020-09-0723:16thhellerunlikely since you are not running in node#2020-09-0723:19thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116 :esm is the more modern :npm-module but its probably not an option for storybook#2020-09-0723:20thhellermostly because storybook probably won't accept the already provided react version#2020-09-0723:59neilyioThe :esm target is coming pretty close... But I'm getting these two warnings:
Warning: unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.
#2020-09-0723:59neilyio
Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
    in Transition (created by CSSTransition)
    in CSSTransition (created by app.sidebar.modal_left)
    in app.sidebar.modal_left (created by stories.core.sidebar_modal)
    in stories.core.sidebar_modal (created by reagent3)
    in reagent3 (created by storyFn)
    in div (created by storyFn)
    in storyFn
    in ErrorBoundary
#2020-09-0800:01neilyioThis seems to be what you were talking about. I really have no idea where to go from here... but I'd love to figure it out as I'm very close with this Storybook/ClojureScript library.#2020-09-0809:43rickmoynihanIs it better to have a separate shadow-cljs build for devcards, or a single build for the app with devcards as a module?#2020-09-0809:49thheller@rickmoynihan always separate build. :modules are not meant for this.#2020-09-0809:51rickmoynihan@thheller: Yeah, I’m reviewing a PR from a colleague — I was expecting a separate build. Why is it better to do a separate build rather than as modules though? Will it result in devcards being compiled into the prod app?#2020-09-0809:52thhellerbasically yes#2020-09-0810:01rickmoynihanSo what do modules actually do? Our setup essentially looks like this:
:main {:entries [app.main]
                :init-fn mut.main/pre-init}
:cards {:entries [app.dev.cards]
            :depends-on #{:main}}
From a human perspective, obviously they essentially give us separate exposed entry points into the app i.e. init fns.
#2020-09-0810:02rickmoynihanThe userguide says: > When using multiple Modules the code is split so that the maximum amount of code is moved to the outer edges of the graph. But I’m not quite sure what that means, and how it would differ from two builds.#2020-09-0810:03thhellerit means exactly that. don't know how to describe it differently 😞#2020-09-0810:03thhellerbasically the cards module will contain all the code of the cards in theory#2020-09-0810:03thhellerBUT a regular user will never load the cards#2020-09-0810:03rickmoynihanyes#2020-09-0810:04thhellerand that means that any code that is kept alive that couldn't be moved will make the :main module larger than it needs to be#2020-09-0810:05rickmoynihanahh ok so a codepath from :cards might mean it can’t dead code eliminate something it otherwise would be able to#2020-09-0810:05thhellerif you are very careful you can do it ... but its just not worth doing over a secondary build#2020-09-0810:05thhelleryes, it negatively impacts DCE in almost all cases#2020-09-0810:06rickmoynihanyeah — seems like it mixes concerns to me… i.e each build already has a dev and prod env; and here we’re kinda saying devcards is a prod dependency, and relying on dead-code elimination / module-shuffling to figure it out#2020-09-0810:07rickmoynihanwhere as we could just tell it; and guarantee it’ll never make it in; and make the intent clearer.#2020-09-0810:09thhelleryep#2020-09-0814:17rickmoynihanCan you associate tools-deps aliases with a specific build?#2020-09-0815:39thhellerno#2020-09-0818:51roklenarcicI want to theme some Semantic UI, which afaik involves compiling less files. What’s the easiest way to introduce that into a shadow-cljs project?#2020-09-0917:03fabraoHello all, I have this ->
import { Filter, FilterSettingsModel, GridComponent, IFilter, Inject } from '@syncfusion/ej2-react-grids'
with
export default class App extends React.Component<{}, {}>{
public Filter : IFilter = {
    type: 'CheckBox'
  }
  public render() {
      return <GridComponent dataSource={data} filterSettings={this.FilterOptions}
            allowFiltering={true} height={273}>
          <ColumnsDirective>
              <ColumnDirective field='OrderID' width='100' textAlign="Right"/>
              <ColumnDirective field='CustomerID' filter={this.Filter} width='100'/>
              <ColumnDirective field='EmployeeID' width='100' textAlign="Right"/>
              <ColumnDirective field='Freight' width='100' format="C2" textAlign="Right"/>
              <ColumnDirective field='ShipCountry' width='100'/>
          </ColumnsDirective>
          <Inject services={[Filter]} />
      </GridComponent>
  }
}
 How do I use `services={[Filter]}` with CLJS? IFilter interface what?
#2020-09-0917:04thhellerhmm is that typescript or what is that?#2020-09-0917:05fabraotype#2020-09-0917:07lilactown@fabrao I answered your question in #helix . it’s best not to cross post many channels#2020-09-0917:08thhellerits just #js [#js {:type "CheckBox"}] I presume, not actually a clue if typescripts adds anything#2020-09-0917:08fabraomany sory#2020-09-0917:08lilactownassuming that IFilter is a TypeScript interface, they have no runtime#2020-09-0917:09thhelleryes but the import { Filter } confuses me? what is that?#2020-09-0917:09thhellerI'd assume that the public Filter = { type: "CheckBox" } is just regular property syntax?#2020-09-0917:10thhellerI still know next to nothing about typescript though 😛#2020-09-0917:10thheller@lilactown btw didn't you write something to generate ES class or did you want to do that?#2020-09-0917:10lilactownahhh I was thrown off by the indentation, I thought that was a part of the type of App#2020-09-0917:11thhellerI finally broke down and wrote one myself 😛#2020-09-0917:11lilactownoh yeah? lol#2020-09-0917:11lilactownthis is what I’m using in helix: https://github.com/lilactown/helix/blob/master/src/helix/impl/classes.js#2020-09-0917:12lilactownit is not great#2020-09-0917:12thheller
(defclass Something
  (extends SomethingElse)
  (field foo 1)
  (field bar)
  
  (constructor [this x]
    (super "foo")
    (set! bar (+ foo x)))
  
  Object
  (someMethod [this foo])
  
  SomeProtocol
  (foo [this bar]))
#2020-09-0917:13thheller(Something. 1)#2020-09-0917:14thhellergenerates an actual some.ns.Something = class some$ns$Something { constructor(x) { ... }}#2020-09-0917:14lilactownnice. I like it#2020-09-0917:14lilactownI had high hopes to create a patch for CLJS to actually emit class but then life happened. I think someone created a library that does it by extending/altering the compiler at a distance#2020-09-0917:15thhelleryeah requires hacking into the compiler quite a bit#2020-09-0917:16thhellerhttps://github.com/thheller/shadow-cljs/commit/106dcda807c048fbe56adaf00f35b7f196113b39#2020-09-0917:16thhellerseems to work ok but probably missing a bunch of weird edge cases 😛#2020-09-0917:17thhellerI thought you wrote something like this but I guess I misremembered then?#2020-09-0917:17lilactownnah it was someone else#2020-09-0917:18thhellerhappy that it works at all for now#2020-09-0917:20lilactownrelease it as a standalone lib and so I can delete my gross hack in helix 😄#2020-09-0917:21thhellerwhen I feel semi confident that its correct I'll likely do that#2020-09-0917:21thhelleruntil then it'll stay in shadow-cljs#2020-09-0917:24thhellerhttps://github.com/thheller/shadow-experiments/blob/66de56ea3855cb12dcdde077bd41a0e2f970addf/src/main/shadow/experiments/grove/ui/vlist.cljs#2020-09-0917:25lilactownvery nice#2020-09-0917:26lilactownstarting to get sick of React’s shit. might give grove a try sometime this year 😂#2020-09-0917:26thhellergot really tired of doing this shit since there was no other way to do stuff in the "constructor"#2020-09-0917:26thhellerhttps://github.com/thheller/shadow-experiments/blob/02765f345fe4c4e63dac078f10d6ce8a4b2b478e/src/main/shadow/experiments/grove/ui/vlist.cljs#L247-L261#2020-09-0917:27thhellerstay away from grove for now .. I have a few breaking changes coming up 😉#2020-09-0917:28lilactownI’m not dropping React anytime soon… or ever. I think I really just want something else to do#2020-09-0917:28lilactowngrove looks cool.#2020-09-0917:28thhellerhttps://github.com/thheller/shadow-experiments/blob/02765f345fe4c4e63dac078f10d6ce8a4b2b478e/src/main/shadow/experiments/grove/components.cljs#L489-L510#2020-09-0917:29thhellerpicard-facepalm#2020-09-0917:31lilactownlol#2020-09-0917:31lilactownthe positional args for types/records will never not drive me crazy#2020-09-0917:37thhellertypically don't write much of this kind of mutable code but sometimes you just have to 😛#2020-09-0917:44lilactownyeah there’s a lot of this in a lib i’ve been working on: https://github.com/lilactown/serenity/blob/clj/src/serenity/core.clj#L191#2020-09-1014:21Alexis Vincenthi all, does :target :npm-module support repl?#2020-09-1014:55thhellerdepends#2020-09-1014:55thhellerwhat are you doing with it?#2020-09-1018:30mauricio.szaboHi, is there a way to make Shadow stop printing shadow-cljs - #34 ready! - like messages on development? The reason I need is because I'm compiling for a target that if I try to print on console, it raises an error 😱#2020-09-1018:53thheller@mauricio.szabo there is no way to do that currently but I can add an option. please open an issue. until then you can (set! shadow.cljs.devtools.client.browser/devtools-msg (fn [])) in a preload or so#2020-09-1018:54thhellerdifferent ns in case its not the browser. hmm although browser might be the only where this would actually work#2020-09-1104:32Mr. Savyhas anyone dealt with a stale client? I'm not sure why it decided to start doing this. I've tried restarting everything.#2020-09-1105:04bbss@ajsnow2012 usually this means the browser has an old version#2020-09-1105:05bbssare you sure the cache of your browser is disabled?#2020-09-1105:05bbssi.e. devtools > network tab > disabled cache ticked (don't worry, it will only be disabled while, devtools are open)#2020-09-1218:45Mr. SavyI will try this, thanks!#2020-09-1107:39Misha BohdanHello! I'm new to cljs and trying to start a clean project from re-frame-template. I'm constantly getting the same error while jack-in: websocket.cljs:12 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED . How can I solve it? REPL is not working too in VS Code, but for Clojure (not a script one) it's working fine. Tried both Chromium and Firefox.#2020-09-1108:23thheller@ajsnow2012 did you maybe change your :output-dir or :modules {:main ...} to :modules {:app ...} or so? anything that affects where the output goes basically but did not update your HTML to load that code and instead still load the old stuff?#2020-09-1204:25Mr. SavyI will check this tomorrow and update the channel if I it still happens and/or I fix or whateves#2020-09-1108:24Norman EcksteinAnyone using shadow-cljs with Cursive on Windows?#2020-09-1108:24thheller@bohdan.mikhail looks like shadow-cljs isn't running? or running on a different port but not having compiled yet?#2020-09-1108:24thheller@info902 I am 😉#2020-09-1108:26Norman EcksteinOk then there is hope for me. I couldn’t get it working yesterday. But that are some of my first steps in ClojureScript anyway , before only Clojure #2020-09-1108:26Misha Bohdan@thheller VSCode says that all should works fine, according to logs
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.0 running at 
shadow-cljs - nREPL server started on port 8777
#2020-09-1108:26Norman EcksteinI tried to get @jacek.schae project working in Cursive #2020-09-1108:28Misha BohdanCan it be caused by running under WSL?#2020-09-1108:29Norman EcksteinI use WSL2 but since today I do all coding directly in Windows #2020-09-1108:29pmooserAnyone have any insight about what the correct value for :asset-path is for a :bootstrap build is? If I try to do advanced compilation, I get errors about goog not found from the bootstrap stuff in particular.#2020-09-1108:29thheller@bohdan.mikhail if you run under WSL2 then you must use the IP of that virtual machine to connect since it is not running under localhost anymore#2020-09-1108:30thheller(or forward the port from windows)#2020-09-1108:30Norman EcksteinSorry mixed up with your discussion 😆#2020-09-1108:31pmooser(maybe :advanced doesn't work with bootstrap, who knows?)
#2020-09-1108:31thheller@pmooser :bootstrap does not have that setting at all. :advanced is not compatible with bootstrap, must use :simple#2020-09-1108:31pmooserOk, thanks. I will give it a try. Does that mean both of my builds have to be :simple ? (ie both the app and bootstrap builds)#2020-09-1108:32thhelleryes#2020-09-1108:32pmooserThat appears not to work at all for me, but thanks for the info.#2020-09-1108:34thheller@info902 whats your issue then? most of the time I run my stuff directly under windows, sometimes under WSL1. WSL2 is kinda annoying because of the IP but easy enough if you just use a hostname for that machine vs an IP#2020-09-1108:37Norman EcksteinWell I opened the ReFrame Pro project in IntelliJ and as its a Shadow-cljs project / no Leiningen .... I couldn’t get the repl connected to the started project . I tried all kind of things to get the Cursive repl working. Calva worked fine#2020-09-1108:38Misha Bohdan@thheller it's a little bit confusing, because the web page opens like it's at the localhost but a ws connection should be port-forwarded. Don't they work in the same manner?#2020-09-1109:17thhellerhmm how do you access the webpage?#2020-09-1219:33Misha BohdanI found that the VS Code or maybe Windows itself performing port forwarding on opening link step (clicking to it in the editor) because typing in the browser is not working without explicit forwarding#2020-09-1108:38Norman EcksteinMust be a beginner problem 😐#2020-09-1108:39pmooser@thheller Is the fact that :advanced doesn't work with :bootstrap a shadow-cljs limitation, or a fundamental self-hosted cljs limitation?#2020-09-1108:45thhellerfundamental, it cannot work ever anywhere.#2020-09-1108:46thheller@info902 well what DID you try? do you have a hardcoded :nrepl {:port 9000} or so in your shadow-cljs.edn?#2020-09-1108:50thhelleralso see https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2020-09-1108:54pmooser@thheller Ok, I'm trying to use :simple for both my :app and :bootstrap targets ... and when I try to load the page, I get some shadow-cljs logs that say "failed to load 8" "failed to load 16" and "failed to load 23" each of those is a jsRequire call of some sort ... can you provide any hints about debugging what might be causing this?#2020-09-1109:00Norman EcksteinYeap / :nrepl {:port 333} and npm run dev starts up#2020-09-1109:02Norman EcksteinDamn, I just deleted the whole .idea project and recreated it new. This time directly with the pom.xml #2020-09-1109:02Norman EcksteinLooks better now with Cursive#2020-09-1112:45mauricio.szaboHi, I'm having some trouble with some node.js requires, when I require then using :js-provider :shadow (requiring then on the ns form). For example, jsdom have the following code somewhere:
exports.Canvas = null;
let canvasInstalled = false;
try {
  require.resolve("canvas");
  canvasInstalled = true;
} catch (e) {
  // canvas is not installed
}
if (canvasInstalled) {
  const Canvas = require("canvas");
  if (typeof Canvas.createCanvas === "function") {
    // In browserify, the require will succeed but return an empty object
    exports.Canvas = Canvas;
  }
}
#2020-09-1112:45mauricio.szaboThis makes shadow-cljs expects to have canvas installed. Is there a workaround, or should I use the default :js-provider and use something else to bundle my js file?#2020-09-1112:53thhellerthis pattern isn't supported (ie. require.resolve)#2020-09-1112:54thhelleryou can set :js-options {:resolve {"canvas" false}} so it won't bundle it#2020-09-1112:55thhellerthat might kind of work but is rather horrid thing to do#2020-09-1114:56Alexis Vincent@thheller Hi there, I’m trying to get either npm-module or :esm to pop me a repl in the browser. Cljs being imported from javascript in nextjs. Want a way to use cljs libs from nextjs applications.#2020-09-1114:57Alexis VincentBut neither is connecting back to the shadow watcher#2020-09-1114:58Alexis VincentDo they support repl in the browser?#2020-09-1115:04thhellerdon't use :esm when embedding into other targets. thats needs a lot more work before that becomes practical.#2020-09-1115:05Alexis VincentWould you suggest using :browser?#2020-09-1115:05thheller:npm-module should work fine *BUT* you need to ensure the REPL ns is loaded from JS#2020-09-1115:05Alexis Vincentright, which ns is this?#2020-09-1115:05thhellerso wherever you do (require "./cljs/whatever.your.ns")#2020-09-1115:05thhellerthe ns is shadow.cljs.devtools.client.browser#2020-09-1115:06thhelleryou can if if (process.env.NODE_ENV === "development") { require ... } in the JS#2020-09-1115:06thhellerdon't know what your JS looks like#2020-09-1115:06Alexis Vincentcool. So in dev, load shadow.cljs.devtools.client.browser#2020-09-1115:06Alexis Vincentperfect#2020-09-1115:06Alexis Vincentgot you#2020-09-1115:07Alexis VincentWould be interesting to have a discussion about esm sometime. I have a large interest in getting seamless TS and cljs interop. But don’t always control the bundling experience#2020-09-1115:09Alexis VincentWhat are the options for shipping cljs core in an npm package, and then having cljs compile in place (same directory), but with a require on cljs? Not sure if I made sense here.#2020-09-1115:09Alexis VincentThanks for the help!#2020-09-1115:11thhellercljs.core as npm package to be included in other CLJS builds is pretty much a no go#2020-09-1115:11thhelleror rather not something I'm interested in working on or supporting#2020-09-1115:11thhellerjust goes completely against what :advanced is supposed to do#2020-09-1219:26Mr. Savyjust as an update, I tried restart and it fixed everything before I had a chance to try those two other suggestions. I think maybe I had a second instance still running that I never actually closed maybe? I'm not sure. Either way thanks!#2020-09-1220:20worlds-endlessI'm trying to use Shadow.cljs on an Apache server WITHOUT url fragments (the index.html in every directory is identical for now). However, my js map seems to have issues because it looks up my resources relative to each file. Can anyone tell me how it shoudl be set up in this scenario?#2020-09-1220:26thhelleruse an absolute :asset-path "/js" not a relative :asset-path "js"#2020-09-1220:30worlds-endlessAh -- the :asset-path : perfect. Thanks!#2020-09-1220:59worlds-endlessRelated problem: I created /portfolio/index.html and now it works if I browse to localhost/portfolio/ ; however, I need it to work without the slash at localhost/porfolio . Suggestions?#2020-09-1308:58thhellerthats an apache question I cannot answer. not related to CLJS/JS.#2020-09-1323:24tony.kayCan someone remind me how to configure compiler to use an alternate file for a required cljs file. E.g. My code says require a but I want the compiler to really pull in b.cljs.#2020-09-1323:25tony.kayis it just the same as what you’d do for a NPM file?
{:browser
   {:js-options
     {:resolve {a {:require b}}}}}
#2020-09-1400:00tony.kayI can’t seem to get it to work#2020-09-1400:00tony.kayfor cljs namespaces, that is#2020-09-1407:19thheller@tony.kay for CLJS its :build-options {:ns-aliases {a b}}. eg. https://github.com/day8/re-frame-debux#option-2-namespace-aliases-with-shadow-cljs#2020-09-1410:45jpmonettashi everybody! is there a way to specify general :exclusions in shadow-cljs.edn like there is in lein?#2020-09-1412:00thheller@jpmonettas exactly like in lein, :dependencies [[some-dep "version" :exclusions [foo]]#2020-09-1412:09jpmonettasyeah but is there a general :exclusions, like this one https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L89-L92#2020-09-1412:13thhellerthat is not supported. what are you trying to exclude? I mean its rather uncommon to get an unwanted dep from multiple sources?#2020-09-1412:45jpmonettasI'm working on a project where a bunch of our libraries depend on mount. For one of the projects that uses all those, I want to work with a fork of mount I made, so I want to exclude all mount dependencies everywhere since I want to provide the one to use. Does it make sense?#2020-09-1412:47jpmonettasI'm in the process of migrating this project to shadow-cljs, and the current project is using that lein functionality#2020-09-1413:17pithyless@jpmonettas are you using deps.edn? Because you can create an alias with :override-deps to point to your fork; and then pull in the deps via alias in shadow.#2020-09-1413:17robert-stuttafordhelp 🙂 how do i express this: import Select, { components } from 'react-select'; in this:
(ns yep
  (:require ["react-select" :default react-select]
            ["react-select/async" :default react-select-async]))
I also need to import Option from "react-select" somehow
#2020-09-1413:22jpmonettas@pithyless I don't think :override-deps works since they are different artifacts, not different versions, I'm including district0x/mount and want to exclude mount since the both contains the same namespaces#2020-09-1413:26pithylessThis would work if you reference the git repo:
{mount {:git/url "" :sha ...}}
(But you would need to add a deps.edn to your forked repo)
#2020-09-1413:27pithylessI wonder if you can specify an alternative mvn root... {:mvn/version "..." :mvn/artifact ...}#2020-09-1413:35pithylessLooks like the groupId/artifactId stuff is hardcoded for :mvn; but that forked git repo would work.#2020-09-1414:07jpmonettasyeah not sure what to do, I think I'll just add exclusions per dependency, but is kind of error prone, if I miss one then I'll have some hard to track bugs#2020-09-1414:08jpmonettasthanks for your ideas !!#2020-09-1414:12Mark GerardHiya, I am getting this error when I try to run my tests:
Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
nil
========= Running Tests =======================
internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module 'xmlhttprequest'
#2020-09-1414:12Mark GerardAny pointers on how to fix this?#2020-09-1414:23thhellernpm install xmlhttprequest? Guess you are using :node-test and a library that does a require("xmlhttprequest") somewhere?#2020-09-1414:25Mark GerardI am using shadow-cljs compile test. I added a dependency to use cljs-ajax#2020-09-1414:29thhellerhttps://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs#L35#2020-09-1414:30thhellerso yeah npm install xmlhttprequest should fix it#2020-09-1414:38Mark Gerardthanks#2020-09-1416:42thheller@robert-stuttaford see the translation table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages (:require ["react-select" :as react-select :default Select :refer (Option)]) or so#2020-09-1508:39borkdudeWhen I have a local npm dep and make changes to it, can I get reloading for that, or do I have to npm install + restart my build process every time?#2020-09-1509:15thheller@borkdude shadow-cljs no longer watches individual files in node_modules (there were just tooooo many). you can touch node_modules/that-package/package.json though to trigger a recompile#2020-09-1509:16borkdudethanks!#2020-09-1509:17thhelleror in case you are writing the whole thing yourself anyways just go with direct includes via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2020-09-1509:17borkdudewill this JS also be optimized when building with release?#2020-09-1509:17thhelleryep#2020-09-1509:17borkdude👍 :)#2020-09-1509:18thhellereven going through :advanced unlike node_modules which is only :simple#2020-09-1509:19borkdudeFirst project using shadow (inherited from @plexus) https://babashka.org/xterm-sci/#2020-09-1509:21thhellerhmm why xterm?#2020-09-1509:21borkdudedunno :)#2020-09-1509:21borkdudeit was plexus's idea, I thought I'd take a stab at it, since he was using implementation details of sci, I forced myself into making those things public#2020-09-1509:22borkdudeotherwise, it could have just been a text area probably#2020-09-1509:22thhellernah I mean that we can probably do better than a text-only interface these days 🙂#2020-09-1509:23thhellerI'm sad if that is the best we can do#2020-09-1509:23thhellerwell the shadow-cljs UI is at least my attempt to do better ... not yet sure if it actually is 😉#2020-09-1509:24borkdudesure#2020-09-1509:25thhellermaybe a codemirror input (or any editor) and outputting some kind of DOM is better than xterm#2020-09-1509:25borkdudethat wasn't the point of this exercise from my angle, I'm sure there are lots of nice things you can do visually#2020-09-1509:25borkdudeyes, I already have that here: https://borkdude.github.io/sci.web/ (this is an older version of sci, I should update it)#2020-09-1509:30thhellerI played with xterm too in the UI a while ago. it is definitely a decent way to get a functional terminal-ish interface going quickly#2020-09-1509:30borkdude@thheller I used local-echo but it had issues with quoting. Made an issue + fix for it#2020-09-1509:31thhellerthere is also a linefeed issue. (dotimes [x 1000] (prn x)) (might be because I'm on windows?)#2020-09-1509:32thheller
81
  982
     983
        984
           985
              986
                 987
                    988
                       989
                          990
                             991
                                992
                                   993
                                      994
                                         995
                                            996
                                               997
                                                  998
                                                     999
nil
user=> ^C
user=> 
#2020-09-1509:32thhellerI vaguely remember having that problem too before#2020-09-1509:33borkdudethanks, I'll make an issue about it#2020-09-1510:13Michaël Salihi@borkdude @thheller > (might be because I'm on windows?) FYI same behaviour on Linux.#2020-09-1510:13borkdudeyeah, I know what the issue is actually. I'm only replacing the last \n with \r\n (which the terminal needs), not the intermediate ones#2020-09-1510:14borkdudeI think I should support *print-fn* in sci instead of only *out* which works better for CLJS#2020-09-1510:14borkdudeIn this REPL I'm flushing everything first to a buffer and print it at the end which is kind of sub-optimal#2020-09-1510:14borkdudeThe issue is registered#2020-09-1510:20Eugenhi, I'm trying to figure out why a simple access works in development mode and not with release.
(re-frame/reg-event-db
 ::check-web3
 (fn-traced [db [_ js-window]]
            (let [web3-enabled (exists? (.-ethereum js-window))]
              (js/console.log (str "Browser is web3? " web3-enabled " " (.-ethereum js-window) " " js-window))
              (assoc db :web3-enabled? web3-enabled))))
I'm trying to check for window.ethereum which is a proxy object added by http://MetaMask.io extension .
#2020-09-1510:20Eugenthe code woeks with lein watch but fails to work when I do lein release and load the app via static server#2020-09-1510:21borkdudemaybe an advanced compilation problem which renames that property access#2020-09-1510:23borkdude@eugen.stan I think your best bet with property access in CLJS in general may be goog.object/get#2020-09-1510:24Eugenthanks @borkdude. I am a bit surprised because the use case seems simple. I just started a build with disabled optimisations#2020-09-1510:24borkdudeanother good library for this is https://github.com/applied-science/js-interop#2020-09-1510:37Eugenyes, it is an optimisation issue. Thanks @borkdude. I'll reread the docs.#2020-09-1510:47EugenAdding the ^js type hint fixes the issue with advanced compilation (fn-traced [db [_ ^js js-window]] . Thanks again.#2020-09-1510:50henrikFor some reason, I had to add com.google.guava/guava {:mvn/version "23.0"} manually to my deps today, because of:
[2020-09-15 12:49:30.646 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError com/google/common/collect/Streams
	com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
	com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)
	com.google.javascript.jscomp.Compiler.findModulesFromInput (Compiler.java:1914)
	com.google.javascript.jscomp.Compiler.findModulesFromEntryPoints (Compiler.java:1870)
	com.google.javascript.jscomp.Compiler.parseInputs (Compiler.java:1679)
	com.google.javascript.jscomp.Compiler.parseForCompilationInternal (Compiler.java:954)
	com.google.javascript.jscomp.Compiler.lambda$parseForCompilation$4 (Compiler.java:937)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:129)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:843)
	com.google.javascript.jscomp.Compiler.parseForCompilation (Compiler.java:935)
	com.google.javascript.jscomp.Compiler.compile (Compiler.java:693)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
Caused by:
ClassNotFoundException com.google.common.collect.Streams
	jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
	jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
	java.lang.ClassLoader.loadClass (ClassLoader.java:522)
	com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60)
	com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163)
#2020-09-1511:19thheller@henrik typical dependency conflict. you may want to investigate where this conflict is from, otherwise the other code depending on the other version may have issues.#2020-09-1511:50henrikGotcha @thheller. Only mention of Guava seems to be from dev-local, maybe that’s the culprit.
com.datomic/dev-local 0.9.195
  com.google.errorprone/error_prone_annotations 2.3.4
  com.datomic/client-api 0.8.54
  com.cognitect/anomalies 0.1.12
  com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
#2020-09-1511:52thhelleryeah datomic is a common cause#2020-09-1511:54henrikWhy can’t we just be friends#2020-09-1511:55thhellerthats fine#2020-09-1511:55thhellerlooks like you are on an older shadow-cljs version?#2020-09-1511:55henrik2.11.4#2020-09-1511:56thhellerah right. the check is still running but you can ignore it. you may want to consider keeping your CLJ deps out of your CLJS alias#2020-09-1511:58henrikDidn’t know that goods practice. I’m on a pretty cljc-heavy codebase, might be a bit finicky?#2020-09-1511:58thhellerdon't know. I keep my stuff usually completely separate. CLJS managed by shadow-cljs.edn only and CLJ by project.clj#2020-09-1511:59thhellerdepends on how you project is organized I guess#2020-09-1511:59henrikYeah, it’s just laziness talking. It sounds like a good thing to do.#2020-09-1511:59thhellerif I were to use deps.edn only I'd have a :frontend alias and a :backend alias#2020-09-1512:00thhellerjust to avoid conflicts like these .. you won't be using REBL or dev-local in your CLJS builds anyways#2020-09-1514:17borkdude@thheller printing issue should be fixed: (run! prn (range 500)) https://babashka.org/xterm-sci/#2020-09-1608:46sbIs that possible compile shadow-cljs project into one single file "js-build" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"] which command or flag could help me? (that code from project.clj file)#2020-09-1608:48thheller@sb the question is unclear. you are doing a release build which sounds like what you asked? what is the problem?#2020-09-1608:49sbI would like to inject into one go project as frontend and for this would be great a single js file (because I need to compile into file, as fs attachment, different like in clojure)#2020-09-1608:50sbmaybe I forget the :advanced flag..#2020-09-1608:50thhellerI do not understand what you are asking here#2020-09-1608:50thhellerrelease produces an optimized build#2020-09-1608:50thhellerwhich is a single file#2020-09-1608:50thhellerunless you declared multiples :modules#2020-09-1608:50sbhmm interesting#2020-09-1608:50sbok I check again, thanks!#2020-09-1608:50thheller(assuming this is a :target :browser) build#2020-09-1608:51sbSorry for this question! I check again#2020-09-1608:54thhellerif the cljs-runtime dir confuses you that is from watch or compile builds and is not needed in release builds. you can optionally just clean out the :output-dir before running the release#2020-09-1608:55sbthanks, yes that was the problem 🙄#2020-09-1609:04thhelleryou can also just use a different output-dir for release via :release {:output-dir "somewhere/else"} see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-09-1609:39ikitommihi. We have a mixed project of cljs & ts. What needs to be considered on writing reusable react-components with ts? I guess the style-requires on ts need to be handled somehow, getting module errors on those requires with shadow-cljs.#2020-09-1609:40ikitommicurrently using sass on both sides, but I guess plain css requires (on js/ts -side) don't work either?#2020-09-1609:41thhellershadow-cljs has no support for compiling/handling CSS#2020-09-1609:43thhelleryou can either compile the TS to regular ES6 code and include it directly via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2020-09-1609:43thhellerthat way the TS can see all the CLJS code and CLJS all the TS#2020-09-1609:44thhellerany other method will result in either the TS code not seeing CLJS or relying on globals to wire everything together#2020-09-1611:08ikitommithanks. got the ts & sass converted into js & css, but still have the css-requires in the react-components. Is there a easy way to strip those away on the js-side? e.g. the components look like this:
const Logo_1 = require("./Logo");
require("../styles/overlay.css");
const { Header, Content, Sider, Footer } = antd_1.Layout;
exports.Overlay = (props) => {
    return (React.createElement(antd_1.Layout, null, ...
#2020-09-1611:09ikitommior is there a way for shadow-cljs not to fail on css requires? (as I can import them in my sass)#2020-09-1611:12ikitommimy bad, actually a typo. sorry for the extra noice.#2020-09-1611:19thhelleryou can let shadow-cljs ignore them via :js-options {:ignore-asset-requires true} but it is better to just avoid them to begin with#2020-09-1609:40thhellerwhat are style-requires? CSS I presume?#2020-09-1612:02rickmoynihanA colleague wired up devcards and shadow-cljs; however I appear to be having some problems with the dependencies… In particlar shadow-cljs reports shadow-cljs - failed to load module$node_modules$highlight_DOT_js$lib$core#2020-09-1612:02rickmoynihanThen some exceptions related to that#2020-09-1612:03rickmoynihan#2020-09-1612:07rickmoynihanI think it’s because devcards vendors dependencies on highlight.js and marked#2020-09-1612:12rickmoynihanThis commit seems relevant: https://github.com/bhauman/devcards/commit/4f02973c75586ad3f9559c044cb98585764e5199#2020-09-1612:41thheller@rickmoynihan which shadow-cljs version and which :target?#2020-09-1612:41rickmoynihan@thheller cli version: 2.8.26 node: v13.7.0 with :target :browser#2020-09-1612:43thhelleryou can either upgrade or set :compiler-options {:output-feature-set :es6} in your build config#2020-09-1612:45rickmoynihanok I’ll try upgrading to 2.11.4#2020-09-1612:46rickmoynihanhmm actually the cli version was different to the one in my deps.edn / package.json#2020-09-1612:50rickmoynihanok did yarn global add shadow-cljs and bumped to 2.11.4 and it seems to have fixed the issue#2020-09-1715:53adamrenklintI’ve got a :target :bootstrap build and it works great to get all the sources, but if any code captured in the bootstrap is changed and then after-load function is called in the host build and I run boot/init again, I get stale code in the bootstrap build. Seems if the index has been built once, it never tries to fetch any code again. Feels a bit at odds with the fantastic reload mechanics of Shadow, and is not particularly helpful while developing. I tried a workaround where I would simply reset the index-ref and force all sources to be fetched again, but the ran into issues with goog namespaces “already being provided”. Feels like I’m maybe holding the tool wrong? Has anyone else found a nice reloadable workflow when working with the bootstrap target?#2020-09-1715:57JAtkinsIs there anything I'm missing here? Trying to convert this js example
import {AgGridColumn, AgGridReact} from 'ag-grid-react';
import 'ag-grid-community/dist/styles/ag-grid.css';
import 'ag-grid-community/dist/styles/ag-theme-alpine.css';
to a cljs import.
["ag-grid-react" :as agr :refer [AgGridReact]]
;;TODO: can't figure out how to bring in styles:
["ag-grid-community/dist/styles/ag-grid.css"]
["ag-grid-community/dist/styles/ag-theme-alpine.css"]
The compiler error looks like this:
errors in file: /home/jarrett/.../NewSite/node_modules/ag-grid-community/dist/styles/ag-grid.css
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es8", :goog-module nil, :js-warnings [], :resource-name "node_modules/ag-grid-community/dist/styles/ag-grid.css", :js-requires [], :js-errors [{:line 6, :column 72, :message "Semi-colon expected"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: /home/jarrett/.../NewSite/node_modules/ag-grid-community/dist/styles/ag-grid.css
#2020-09-1716:10thheller@jatkin CSS is not supported and cannot be imported that way via CLJS :require#2020-09-1716:11JAtkinsGacha, just importing it via <link ... for now.#2020-09-2112:17kimimHow to import use <link? Thanks.#2020-09-2118:38JAtkinsJust via html tags#2020-09-1718:58nodenameHi folks, can I create an npm package with shadow-cljs that I can then import in a typescript project?#2020-09-1719:05thhelleryou can via :npm-module#2020-09-1721:26Alex J HendersonHi, We're noticing that since shadow-cljs 2.10.0 the autocomplete/intellisense is broken, when using VS Code & Calva, is this a known issue? (curiously it does work for a few seconds after jack-in but breaks when the build is compiled)#2020-09-1721:27thhellerhttps://github.com/rksm/clj-suitable/issues/15#2020-09-1723:08pezPlease note that this issue also affects cljs completions in Calva if the JSCompletion setting is enabled. Disable this in VS Code for shadow projects until a resolution is found. #2020-09-1804:22bennyany places to look when running with a release build, I get undefined is not an object (evaluating 'Z4.$l') but it works just fine when running dev builds?#2020-09-1804:31p-himikIssues with externs. Likely whatever Z4 was before, it shouldn't have been renamed. Or you have something different happening in the release build so that Z4 is a genuine variable that has a value of undefined.#2020-09-1807:00thheller@benny turn on externs inference if it isn't on (wasn't the default as of very recently) https://shadow-cljs.github.io/docs/UsersGuide.html#externs#2020-09-1807:00thhellerlooks like an externs renaming issue#2020-09-1810:14Karol WójcikIs it possible to not start nrepl server when using shadow.cljs.devtools.server/start?#2020-09-1810:47sogaiuin shadow-cljs.edn: > The nREPL server can be disabled by setting :nrepl false. #2020-09-1810:47sogaiumay be that works?#2020-09-1810:47sogaiusee: https://shadow-cljs.github.io/docs/UsersGuide.html#nREPL#2020-09-1814:46yendaIs there some gotchas when hot-reloading a namespace that uses macros? Trying to use clara-rules defrule macro and every time I save the namespace shadow complains about undeclared vars, which are functions defined in the namespace and originally compiled fine#2020-09-1814:46yendaadditionally when moving these functions to another namespace it also works fine#2020-09-1814:47thhellernot enough information to comment#2020-09-1814:48yenda
(ns notifications.notifications
  (:require [clara.rules :as clara])
  (:require-macros [clara.macros :refer [defrule defsession]]))

(defsession session 'notifications.notifications
  :fact-type-fn :type)

(defn testz [user-id]
  {[:user/id user-id] [:user/id]})

(defrule follow
  "A rule which isd fired on every follow"
  [:context [env] (= ?env env)]
  [:follow [{followed-id :followed/id user-id :user/id}]
   (= ?followed-id followed-id)
   (= ?user-id user-id)]

  =>
  (testz ?user-id))

(defn handle-event [env event]
  (-> session
      (clara/insert (merge env {:type :context})
                    event)
      (clara/fire-rules)))
#2020-09-1814:49thhellerI don't know much about clara-rules so no clue what that code does#2020-09-1814:50thhellerI know that is uses a clojure side atom and does not play well with caching#2020-09-1814:50thhellerso could be likely that it also doesn't play well with incremental compilation at all#2020-09-1814:51yendayeah it looks like it's something like that because rules that are deleted keep throwing undeclared-var compilation errors#2020-09-1814:51yendaso disabling caching could help?#2020-09-1814:51thhellerif you want to completely obliterate recompile performance 😉#2020-09-1814:52thhellerno clue to be honest. maybe there is something you can call to "reset" its state#2020-09-1814:52thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2020-09-1814:53thhellercache is off by default for clara already#2020-09-1815:04frozarHi, I'm wondering how to manage subproject through shadow-cljs. My situation is the following: I want to create a main project on a private repository and this project should use an "embedded" subproject which is public and should remain public. Both on them will use shadow-cljs.edn as build configuration file. Is there a convenient way to embed a subproject with shadow-cljs?#2020-09-1815:06thhelleryou can use deps.edn or project.clj to do this#2020-09-1815:06thhellershadow-cljs.edn itself does not support this#2020-09-1815:06thhellerwell you can just add :sources-paths ["src/main" "../that-subproject/src/main"] if its just about source paths#2020-09-1815:07yendainteresting even after completely disable the cache the initial compilation works then I get undeclared variables 😕#2020-09-1815:08thheller@yenda diid you restart the shadow-cljs process? as I said the library keeps some CLJ side state that isn't part of any shadow-cljs cache or so you could reset#2020-09-1815:10yendayes I restarted it#2020-09-1815:11thhellersorry don't know enough about the lib to even guess#2020-09-1815:13yendalooks like there is a clear-ns-productions! function#2020-09-1815:16yendaso I should use it in
:before-load  
#2020-09-1815:17thhelleryou might also need ^:dev/always on the ns https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2020-09-1815:18thhellerfor macros that access the analyzer state directly#2020-09-1815:18thhellercan't remember if that was necessary or not#2020-09-1815:41yendaok works#2020-09-1815:41yenda(clara/clear-ns-productions!) needs to be put in the ns#2020-09-1815:41yendanothing else required#2020-09-1815:08frozarOK, thank you @thheller, always reactive, always amazing ! Yes, I can manage this with the classpath, but I don't want to duplicate the dependencies of the subproject in the main project. I'll try the deps.edn approach, thank again#2020-09-1816:00frozarAs I use many npm package, it's finally easier to keep using shadow-cljs ^^#2020-09-1815:31StephenHi, I am just getting into clj/cljs dev. Is there a way to only use the shadow-cljs commandline tool for managing all deps (clj and cljs)? Or are deps.edn and/or lein always needed for the backend(clj) side?#2020-09-1815:34StephenAll this clj (deps.edn), lein, and shadow-cljs configs confuse me#2020-09-1815:37frozar@slack1781 as far as I know, shadow-cljs is dedicated to clojurescript project, or javascript aspect of a project.#2020-09-1815:44wombawombaSo I have a shadow-cljs project, and I want to disable CORS (i.e. inject permissive CORS headers) for the shadow-cljs watch command. How can I make this happen?#2020-09-1815:50wombawombaFWIW I thought the :push-state/headers key as described in the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http) seems promising for this, but adding it doesn’t seem to have any effect#2020-09-1815:51wombawombaMaybe I’m putting it in the wrong place?#2020-09-1816:04wombawombaNevermind, I figured it out 🙂#2020-09-1816:49Diegohow can I set environment vars for development vs prod. I am reading this section of the docs (https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env), but I am used to starting shadow with Cider, so I am not even sure how I set the env vars there.#2020-09-1816:50DiegoI just want to point the api endpoint to somewhere else, so it's something quite trivial#2020-09-1816:55dpsutton
{...
 :builds
 {:app
  {:target :browser
   ...
   :modules {:app {:entries []}}
   ;; to enable in development only
   :dev {:closure-defines { true}}
   ;; to enable always
   :closure-defines { true}
   ;; you may also enable it for release as well
   :release {:closure-defines { true}}
   }}
you could use :dev and :release to use hardcoded versions. or start shadow from the command line and then cider-connect-cljs to the already running instance with easily set env vars
#2020-09-1816:56Diegothanks @dpsutton#2020-09-1816:57dpsuttonyou could also call (setenv VARIABLE VALUE). make a function that does this and then calls cider-jack-in-cljs and you might be good if you really wan to stay in emacs#2020-09-1918:34DiegoAwesome, thanks#2020-09-1816:58dpsuttonfor work i use
(cider-connect-cljs (list :host "localhost"
                          :port 7888
                          :cljs-repl-type 'figwheel-connected
                          'project-dir "~/projects/aclaimant/acl"))
in a function. you could adjust that as needed with a call to set-env
#2020-09-1818:32zhuxun2Has anyone seen npx shadow-cljs watch :main running forever? Like so:
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.49s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.39s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.35s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.33s)
[:main] Compiling ...
[:main] Build completed. (286 files, 2 compiled, 0 warnings, 0.34s)
... (forever) ...
#2020-09-1818:33zhuxun2I did not touch any code during this time..#2020-09-1818:33zhuxun2What triggers a re-compilation in watch mode?#2020-09-1818:37zhuxun2And if I delete the compiled folder, and restart the watch, the problem resolves ... weird#2020-09-1818:38thheller@zhuxun2 this can happen if your :output-dir is also on any of the :source-paths#2020-09-1818:41zhuxun2@thheller But isn't that usually the case? for example, I usually use "resources/public/js" as the output directory, but "resources" is usually one of the source-paths#2020-09-1818:44thhelleryes, but that is filtered. the filter is very basic so it may not properly filter all the stuff#2020-09-1818:44thhellerI thought I fixed most cases but maybe I didn't. not saying that this is the cause of your problem. just a guess.#2020-09-1818:44thhellerif you have non-standard paths then it is more likely#2020-09-1818:45zhuxun2Yes I do, I used a separate resources folder called "resources_dev" for the development compiles#2020-09-1818:45zhuxun2Is there any workaround in that case?#2020-09-1818:46thhellercall it dev-resources 😛#2020-09-1818:46thhellerpaths ending in resources are filtered#2020-09-1818:47thhellerwhich version is this? I though I fixed this in general but maybe I didn't#2020-09-1818:47zhuxun2LOL, okay. I am using 2.9.10#2020-09-1818:48zhuxun2Oh actually 2.8.58#2020-09-1818:48thhellerhmm yeah maybe try upgrading. or just renaming that should definitely work#2020-09-1818:50zhuxun2Okay I'll try. Why not make the filter an explicit setting?#2020-09-1818:51thhellerit shouldn't be required at all anymore but that was definitely after 2.8.58#2020-09-1818:52zhuxun2I see, yeah maybe I was just using an out-dated version .. thanks!#2020-09-1915:52MacrozHello, is there a way to get shadow-cljs to serve http resources from under multiple directories / or copy stuff around? I mean a case where you don't want to mess the resources -directory with compiled / generated stuff but want to put it under target . What is the best setup for this? With Leiningen I can define cljsbuild output to go under target and then have two resource-paths , one under source resources and one from under target . Have I missed something in the manual? As far as I can see :http-root is singular.#2020-09-1917:08thheller@macroz https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2020-09-2015:17kiranshilaDo any of the @types/* node modules help with extern business in shadow?#2020-09-2015:35thhellerno#2020-09-2015:38kiranshila👍#2020-09-2020:32theeternalpulseI've gotten devcards setup with my shadow app but trying to figure out how to run one command to run my app and the devcards on different ports. I'm guessing because they use the same output folder I'd have to change that, but the port seems to be set for both configurations (my main app and devcards)#2020-09-2023:42theeternalpulseThink I figured it out, just had to make a devcards.html, and output my devcards build to another dir, then just run them both with watch.#2020-09-2102:50Lucy Wanganother option is to can add your devcards ns to the :preload section, e.g. https://github.com/lucywang000/sctools/blob/mvp1/shadow-cljs.edn#L164#2020-09-2105:43theeternalpulseinteresting, I saw another option `
:dev {:compiler-options {:devcards true}}
in the docs, I'll try adding that as well
#2020-09-2105:44theeternalpulsethanks for the better path, double compile seemed bloated#2020-09-2118:45theeternalpulseHad to dive deeper, interesting way to handle rendering either devcards or the main app.#2020-09-2214:51Lucy Wangthe compiler option is not necessary if you add the app.devcards ns to the preloads, because preloads are not included in release builds iirc#2020-09-2021:18Pavel KlavíkHi, I am recently getting errors while working with Shadow-cljs in nREPL. It often happens that after code reloading, the repl gets broken and I am getting error messages from it. Restarting shadow-cljs helps. For instance, just now I am getting this:
@re-frame.db/app-db
=> #object[ReferenceError ReferenceError: re_frame is not defined]
#2020-09-2021:33Pavel KlavíkI am frequently getting Timeout while waiting for result.#2020-09-2021:34Pavel KlavíkAnd shadow-cljs outputs this for instance:
[2020-09-20 23:33:38.961 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(require '[orgpad.common.util.url :as url])", :ns cljs.user, :repl true}, :include-init true, :call-id 6, :from 52}}
AssertionError Assert failed: (symbol? repl-ns)
        shadow.build.resolve/resolve-repl (resolve.clj:639)
        shadow.build.resolve/resolve-repl (resolve.clj:639)
        shadow.cljs.repl/repl-require (repl.clj:207)
        shadow.cljs.repl/repl-require (repl.clj:187)
        shadow.cljs.repl/process-read-result (repl.clj:514)
        shadow.cljs.repl/process-read-result (repl.clj:494)
        shadow.cljs.repl/process-input (repl.clj:680)
        shadow.cljs.repl/process-input (repl.clj:658)
        shadow.cljs.devtools.server.worker.impl/fn--15155 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--15155 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14818/fn--14819/fn--14827 (util.clj:285)
#2020-09-2021:34Pavel Klavíkas response for running (require '[orgpad.common.util.url :as url])#2020-09-2107:18Adam HelinsDoes shadow-cljs have trouble with index.js files? NPM package A (`querystring`) emulates a node module, its entry point is index.js. It is required by NPM package B in my dependencies (`require("querystring")` ). Compilation fails because the compiler cannot find dependency querystring . I, on the other hand, can require it by mentioning (:require ["querystring/index"]) . Indeed, I can fix this by altering altering package B to specify require("querystring/index") but it is a brittle solution at best. What would be a better fix?#2020-09-2108:15thheller@adam678 the correct fix is npm install shadow-cljs in your project. which you should be getting a warning on startup about.#2020-09-2108:16thhellerquerystring is one of those node polyfill packages which will be installed if you npm install shadow-cljs#2020-09-2109:12Adam Helins@thheller Thanks, indeed it works. However, I don't think there was any warning besides a suggestion to run npm install querystring which didn't do the trick anyway#2020-09-2109:20thhellermaybe you are on an older version that didn't warn about this?#2020-09-2116:33Pavel Klavík@thheller I was digging into the first error with reframe.db/app-db and now I have to use (require 're-frame.db) to make it work. What did make this change?#2020-09-2116:35thheller@pavel.klavik I don't understand what you mean. I don't have enough context about what you are doing#2020-09-2116:36thhellermakes things a million times easier if you just paste a shadow-cljs cljs-repl app session or so#2020-09-2116:37thhellertoo many other things may be going when when using nREPL so I need waaaaaaaaaaay more information to provide any kind of help#2020-09-2116:40Pavel KlavíkI just checked and no idea how to reproduce it, everything works just fine now#2020-09-2116:41Pavel Klavíkrecently I am getting more errors of the type posted above, not sure what is causing it, but it is somehow related to code reloading#2020-09-2116:42Pavel Klavíkif I get more insight into what could be causing the errors, I will let you know#2020-09-2117:32bennywhat’s the best way to set up a multi-project repo like so:
project
|-- api
|   |-- src\clj
|
|-- client 1
|   |-- src\cljs
|
|-- client 2
    |-- src\cljs
#2020-09-2118:55Pavel KlavíkI don't see much value in different directories for clj, cljs and cljc files.#2020-09-2118:57Pavel KlavíkI personally have a single src directory with multiple subdirectories which copy my project structure: src/project/client (cljs files) src/project/server (mostly clj files) src/project/common (cljc files) src/project/css (clj files for Garden) and a few others#2020-09-2118:59bennybut i ultimately have 3 deployable units, does it still make sense to do it this way though#2020-09-2119:20Pavel Klavíksure, you have three deployable units, but they might share some code (at least we share a lot of code in between)#2020-09-2119:21Pavel Klavíkso I would recommend having everything in a single repo (at least till it is possible), and separating everything in build time (you specify the root namespaces and only their dependencies will be included in your build)#2020-09-2119:45bennyI currently have one shadow project already (react native) and i’ll have another one (react web) so my biggest problem is the vast difference in dependencies they have and how to manage that#2020-09-2119:47Pavel KlavíkAs with everything, I would choose the simplest way unless you have a good reason not to. I think we currently have single list of Shadow-cljs dependencies and the right dependencies get picked up during compilation, but maybe some other way is prefered here.#2020-09-2119:55bennyah, true, i recall @thheller explaining that — how only what your used references are compiled#2020-09-2119:56bennyi’ll give er a go, thanks @pavel.klavik that gives me the confidence to trudge forward#2020-09-2119:57thhellerwhy do you set it up this way? wouldn't just :client1 :client2 builds be enough?#2020-09-2120:10bennyi’m using cursive so loading up the project via lein is ideal and afaik i can’t specify different lein targets with different shadow builds#2020-09-2120:11bennythis is ultimately what i’m trying to figure out — what the ideal is all things considered, especially since i’m using lein + shadow#2020-09-2120:11bennyright now i have this in the root of my shadow project :lein {:profile "+client"}#2020-09-2120:11bennynow i’m introducing another client#2020-09-2120:18thhellerif you are using lein anyways then just do whatever you do in lein#2020-09-2120:18thhelleryou don't have to use the shadow-cljs command#2020-09-2120:18thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2020-09-2120:19thhellerlein with-profiles +client2 run -m shadow.cljs.devtools.cli watch build-id#2020-09-2120:19thhellerbut you didn't answer why its not just two different builds
#2020-09-2120:19thhellerwhy does it have to be lein profiles?#2020-09-2120:19bennybecause of the different dependencies they have#2020-09-2120:19thhellerwhy is that a problem?#2020-09-2120:20bennybut to @pavel.klavik’s point, separating the deps won’t matter much since they’re just pulled in based on usage#2020-09-2120:20thhellerexactly. the builds only include what they actually used/required. you can have thousands of extra depenendencies and that won't matter at all#2020-09-2120:20bennyso ultimately that’s where i guess we landed — i’ll just use the superset of deps in lein and different builds in shadow#2020-09-2120:21bennysweet, even more confident, thanks guys#2020-09-2118:50wilkerluciohello, is there a way to increase the timeout of waiting for a REPL command response?#2020-09-2118:51thhellernot currently. open an issue please so I don't forget.#2020-09-2121:22wilkerluciohttps://github.com/thheller/shadow-cljs/issues/787#2020-09-2202:55bennywhat’s the recommended way to include vendor css with shadow?#2020-09-2203:19thhellerwhatever you prefer using to handle css. shadow-cljs provides nothing css related.#2020-09-2203:26bennybut with it being a build tool, is there a recommended approach to pulling in those files to the scope of the build?#2020-09-2203:28bennyeven something like tailwind would require a build tool to move it from node_modules to public or am i thinking about this all wrong?#2020-09-2203:33thhellerthere are far too many options that cover this. I have a rather basic bash script that does the copying or in even older projects I just copied things once myself and never touched it again#2020-09-2203:33thhelleryou can also use something like ant, gulp, make, ....#2020-09-2211:21hlolliIf you use emotion, it would get bundled with the js assets. 0 configuration there.#2020-09-2203:19thhellerI use node-sass for older sass projects and postcss for tailwind projects#2020-09-2205:22steveb8nQ: when building nodejs tests, I generally use the shadow auto-run feature. When (is (= foo bar)) fails, and foo is a (nested) map, the expected vs actual are quite difficult to read in the output. Is there a better technique (some kind of pprint or diff) for this?#2020-09-2207:06steveb8nWhat I do today is pprint both values and eyeball them. I’m about to try adding a diff printing lib to this but was wondering if anyone else has any other tricks?#2020-09-2210:35EugenThat would be great, I've also noticed test runs are hard to follow. I've added a junit xml export - but tha is not for console.#2020-09-2210:37Eugenbtw, do you have an example on how to use node fs api in a test? I'm trying to load some test resource files and I'm failing. The reports above are for browser tests with karma#2020-09-2210:47steveb8n1. [“fs” :as fs]#2020-09-2210:48steveb8n2.
(when-not (fs/existsSync out-dir)
  (fs/mkdirSync out-dir))
#2020-09-2210:48steveb8n3. (fs/readFileSync “test-resources/images/hobbit-house-original.jpg”)#2020-09-2210:48steveb8nhopefully that gets you moving 🙂#2020-09-2210:49steveb8nre: test output diffs. there are quite a few options these days. all of them good…#2020-09-2210:50Eugenthanks, it worked ( I had something similar but it failed to work before)#2020-09-2210:50steveb8n1. rebl 2. reveal 3. shadown inspect #2020-09-2210:50steveb8nbut none of them provide a nice diff out of the box#2020-09-2210:50steveb8nglad it worked for you#2020-09-2210:55Eugencomming from a java background, regarding test vizualization in cljs, the setup I have now is very simplistic and not very usefull. I've started with clojure/clojurescript recently.#2020-09-2210:55EugenI know it's not diff related, but is this usefull: https://github.com/usrz/javascript-karma-verbose-reporter ?#2020-09-2212:38thheller@U0510KXTU diff is actually kinda hard to do properly. I want to eventually add it to inspect but that will likely take a while.#2020-09-2222:49steveb8nthanks everyone. I’ll try and use https://github.com/lambdaisland/deep-diff2 for now. that should do the job#2020-09-2402:31steveb8nI’ve started using deep diff and the diff fn works well but it’s pretty-print fn does not display well in auto-run output. just providing the info for anyone that sees this#2020-09-2215:09grounded_sagehow does one troubleshoot the ChromeHeadless browser not launching when running karma start --single-run for the tests?#2020-09-2215:26kennyshadow-cljs 2.11.4 seems to continuously crash my Chrome tabs. I don't have a minimal repro yet but perhaps this is a known issue already. We have two http servers running. One is for our main application and it runs on port 3000 (is is configured at [:builds :app :devtools :http-port]). The other is for our devcards setup. It's running on port 3001 and is configured via [:dev-http 3001]. The 3001 server has two :roots ["resources-devcards/public" "resources/public"] and has the push-state/index set to "devcards.html". To repro the problem, I start shadow-cljs up fresh. I navigate to http://localhost:3001/devcards.html and make a change to my css file. shadow-cljs will reload the css. In the console, I see "shadow-cljs: load CSS /css/main.css" printed exactly one time for each css change. This is the expected behavior. Now I open a second tab with my main app at http://localhost:3000/. I now make a single CSS change and see the "load CSS" message printed 3 times in the main app's console. If I make another change, I get the the load CSS message printed 6 times in the main app console. The next single change results in 12 load CSS. The whole time, the devtools console at 3001 is also printing out exponentially more load CSS messages. I also notice that even when I'm not making any changes to the CSS, the head element is continuously flashing in the Elements tab. This indicates that the head element is changing frequently. This pattern will continue until both tabs crash completely. The Chrome message is "Error code: SIGILL". This issue is quite disruptive to our workflow. I'm on Ubuntu 20.04 but we have other devs on Mac that have been experiencing this as well. Chrome 85.0.4183.102. This has popped up fairly recently so rolling back to an earlier version may be a good solution for the time being.#2020-09-2215:29kennyThe devcards.html file relies on two css files:
<link rel="stylesheet" type="text/css" media="screen,projection" href="/css/main.css">
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/css/devcards.css">
And the main :app index.html file (which is also on the classpath of the devcards app) relies on just one file:
<link rel="stylesheet" type="text/css" media="screen,projection" href="/css/main.css">
#2020-09-2218:01thheller@kenny I cannot reproduce this. it is working completely fine and as expected for me#2020-09-2218:02kennyI have not tried to create minimal repro but it is definitely happening continuously and is a new behavior.#2020-09-2218:03kennyTo be completely clear, as long as only one build is open (3000 or 3001), it will always work as expected.#2020-09-2218:06kennyCLJS reloads do not appear to be affected. Seems to be CSS related only.#2020-09-2218:09kennyProblem is present in 2.10.22 and not in 2.9.10. Have not tested anything in-between.#2020-09-2218:10kennyIn 2.9.10, I get 2 "load CSS" message printed in each tab for each CSS file change I make. It does not get exponentially larger though.#2020-09-2218:25kennyOkay, I have gone through many versions now 🙂 From my findings, it appears the issue was introduced in v2.10.22. 2.10.0 - no issue, 2 load css msgs on change 2.10.6 - no issue, 2 load css msgs on change 2.10.16 - no issue, 2 load css msgs on change 2.10.21 - no issue, 2 load css msgs on change 2.10.22 - 2^(number of css changes) load css msgs printed on change 2.11.4 - same as 2.10.22#2020-09-2219:28thhellerhmm that is indeed the version where the logic for this changed#2020-09-2219:28thhellerhttps://github.com/thheller/shadow-cljs/pull/770#2020-09-2219:28thhellerbut not a clue how it would get to that behavior#2020-09-2221:55kennyNo idea either. Behavior is very odd. Would you like me to file an issue for this?#2020-09-2222:08kennyWould be interesting to try a patched version of shadow-cljs that reverts that change to see if that was really it.#2020-09-2222:17kennyStared at it for a few mins and couldn't think of any reason why. Don't know if relevant but cloneNode will copy inline listeners.#2020-09-2222:21thhellerhmm that might be relevant but then this should always be a problem?#2020-09-2222:22kennyPresumably. Perhaps most people don't set inline listeners on their links.#2020-09-2222:23kennyStill don't have an explanation for why the copying of inline listeners would exhibit this behavior. I suspect it would require deeper knowledge than just this function.#2020-09-2222:25kennyPrimarily wrt the problem only occurring when more than 1 tab is open.#2020-09-2222:42thhellerdo you have other stuff going on in the page? maybe browser extensions?#2020-09-2222:43kennyDefinitely have some extensions. Can in an incognito browser.#2020-09-2222:44kennySame issue in an incognito browser.#2020-09-2222:47kennyAnother thing to note is if I have two tabs both pointed to localhost:3000, I do not have the issue. It only occurs when I have 1 tab of localhost:3000 and 1 tab of localhost:3001#2020-09-2222:49kennySame thing for two tabs with localhost:3001.#2020-09-2222:49kennyThe moment I open a tab on a different port than the one I started on, every CSS change from that point forward will have the issue.#2020-09-2315:30kennyfyi, created an issue here that includes all of the Slack info: https://github.com/thheller/shadow-cljs/issues/789#2020-09-2218:36kennySome very odd behavior when I watch the head element in the Elements tab in Chrome. After making a CSS change, I observe 2^(number of css changes) <link> elements added. It will then slowly start removing some number of those. This is with 2.10.22.#2020-09-2218:38Pavel KlavíkHi, trying to import DayjsUtils from @date-io/dayjs and it does not want to work. Here is the link to its code: https://github.com/dmtrKovalenko/date-io/blob/master/packages/dayjs/src/dayjs-utils.ts#L62 and here is my code:
(:require ["@date-io/dayjs" :default DayjsUtils]
            ["@material-ui/pickers" :refer (DatePicker MuiPickersUtilsProvider)]
            [orgpad.client.util.date :as date])
I have also tested other versions of including this, the value of DayjsUtils in REPL is nil. I was following https://material-ui-pickers.dev/getting-started/usage
#2020-09-2218:47neilyioWhat error are you getting?#2020-09-2219:05Pavel KlavíkDayjsUtils is nil#2020-09-2219:05Pavel Klavíkthe rest of code looks like this:
[:> MuiPickersUtilsProvider {:utils DayjsUtils}
   [:> DatePicker {:value     (date/parse "2020-06-18" true)
                   :on-change #(js/console.log %)}]]
#2020-09-2219:06Pavel Klavík
react_devtools_backend.js:2273 Warning: Failed prop type: The prop `utils` is marked as required in `MuiPickersUtilsProvider`, but its value is `undefined`.
    in MuiPickersUtilsProvider (created by orgpad.client.views.widgets.date_picker.date_picker)
    in orgpad.client.views.widgets.date_picker.date_picker (created by orgpad.client.views.widgets.grid.item)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.item)
    in orgpad.client.views.widgets.grid.item (created by orgpad.client.views.widgets.grid.grid)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.grid)
    in orgpad.client.views.widgets.grid.grid (created by orgpad.client.views.widgets.paper.paper)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.paper.paper)
    in orgpad.client.views.widgets.paper.paper (created by orgpad.client.views.administration.users.user_filter)
    in orgpad.client.views.administration.users.user_filter (created by orgpad.client.views.widgets.grid.item)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.item)
    in orgpad.client.views.widgets.grid.item (created by orgpad.client.views.widgets.grid.grid)
    in div (created by ForwardRef)
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by orgpad.client.views.widgets.grid.grid)
    in orgpad.client.views.widgets.grid.grid (created by orgpad.client.views.administration.users.users)
    in orgpad.client.views.administration.users.users (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
    in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
    in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
    in div (created by function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
})
    in function orgpad$client$views$administration$core$administration(){
return reagent.core.create_class(new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),orgpad.client.views.administration.core.load_administration_data,new cljs.core.Keyword(null,"display-name","display-name",694513143),orgpad.client.views.administration.core.administration,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),orgpad.client.views.administration.core.render_administration], null));
} (created by orgpad.client.views.administration.core.administration)
    in orgpad.client.views.administration.core.administration (created by reagent4)
    in reagent4 (created by orgpad.client.views.widgets.lazy.lazy)
    in Suspense (created by orgpad.client.views.widgets.lazy.lazy)
    in orgpad.client.views.widgets.lazy.lazy (created by root-component)
    in div (created by root-component)
    in div (created by root-component)
    in root-component (created by orgpad.client.views.root.root)
    in orgpad.client.views.root.root
overrideMethod @ react_devtools_backend.js:2273
printWarning @ checkPropTypes.js:21
checkPropTypes @ checkPropTypes.js:83
validatePropTypes @ react.development.js:1715
createElementWithValidation @ react.development.js:1814
reagent$impl$template$make_element @ template.cljs:422
reagent$impl$template$native_element @ template.cljs:334
reagent$impl$template$vec_to_elem @ template.cljs:366
reagent$impl$template$as_element @ template.cljs:385
reagent$impl$component$wrap_render @ component.cljs:114
reagent$impl$component$do_render @ component.cljs:141
(anonymous) @ component.cljs:164
reagent$ratom$in_context @ ratom.cljs:42
reagent$ratom$deref_capture @ ratom.cljs:55
reagent$ratom$run_in_reaction @ ratom.cljs:537
reagent$impl$component$render @ component.cljs:164
finishClassComponent @ react-dom.development.js:17161
updateClassComponent @ react-dom.development.js:17111
beginWork @ react-dom.development.js:18621
beginWork$1 @ react-dom.development.js:23180
performUnitOfWork @ react-dom.development.js:22155
workLoopSync @ react-dom.development.js:22131
performSyncWorkOnRoot @ react-dom.development.js:21757
(anonymous) @ react-dom.development.js:11090
exports.unstable_runWithPriority @ scheduler.development.js:654
runWithPriority$1 @ react-dom.development.js:11040
flushSyncCallbackQueueImpl @ react-dom.development.js:11085
flushWork @ scheduler.development.js:598
channel.port1.onmessage @ scheduler.development.js:165
material-ui-pickers.js:48 Uncaught TypeError: Utils is not a constructor
    at eval (material-ui-pickers.js:48)
    at mountMemo (react-dom.development.js:15443)
    at Object.useMemo (react-dom.development.js:15739)
    at Object.exports.useMemo (react.development.js:1522)
    at MuiPickersUtilsProvider (material-ui-pickers.js:47)
    at renderWithHooks (react-dom.development.js:14804)
    at beginWork (react-dom.development.js:17483)
    at HTMLUnknownElement.callCallback (react-dom.development.js:189)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:238)
    at invokeGuardedCallback (react-dom.development.js:293)
#2020-09-2219:09Pavel KlavíkOk, so requiring it like this fixed the problem:
(ns orgpad.client.views.widgets.date-picker
  (:require ["@date-io/dayjs" :as dayjs]
            ["@material-ui/pickers" :refer (DatePicker MuiPickersUtilsProvider)]
            [orgpad.client.util.date :as date]))

(defn date-picker
  []
  [:> MuiPickersUtilsProvider {:utils dayjs}
   [:> DatePicker {:value     (date/parse "2020-06-18" true)
                   :on-change #(js/console.log %)}]])
Fuck this shit, I don't think I will ever understand enough JS to know how this stuff works.
#2020-09-2219:09neilyioI just tried it out and got this same thing, it imports as nil.#2020-09-2219:10neilyioGlad you sorted it out! I know it's confusing, I've been studying ClojureScript/shadow-cljs for three months and I'm just barely starting to get productive.#2020-09-2219:19Pavel KlavíkClojure(Script) itself is great, I am rarely strugling with anything, mostly I can just concentrate on my business problems, but including JS libraries is sometimes tricky and much more annoying. The hardest part is that you will get example code in JS which you have to translate into CLJS and it is often try and guess for me, plus dealing with mutability is annoying 🙂#2020-09-2219:20Pavel KlavíkBut the language is superb compared to anything else, due to REPL, hot code reloading, simplicity, data orientation, ... I would never change it for anything.#2020-09-2218:38neilyioI'm trying to get the https://www.11ty.dev static site generator to work with shadow-cljs. I expect Eleventy to read my shadow-cljs .js output files and produce HTML files. Eleventy does its thing with a command line utility, so I've got a build hook setup with shadow-cljs to call node node_modules/.bin/eleventy on the :flush event. Eleventy needs a module.exports = my_render_func in the JS module that it reads, so I'm using the :esm target in my shadow-cljs.edn. As Eleventy expects CommonJS, I'm using the NodeJS esm library to make my shadow-cljs output compatible. This means that in my :flush build hook, I'm calling (sh "node" "-r" "esm" "node_modules/.bin/eleventy"). So far, this is working perfectly with shadow-cljs compile site. Eleventy produces all the expected HTML files. The problem comes when I run shadow-cljs watch site. Shadow-cljs gets stuck at the "compiling..." stage and never finishes. Do you have any suggestions for a workaround? Eleventy seems to be a good fit so far for shadow-cljs, and I feel like I'm really close to a smooth workflow. I'd love to write up a blog post to help others with shadow-cljs + Eleventy, but this part has me stumped.#2020-09-2218:39neilyio@thheller I hope you can give me some guidance! Here's my build config, as well as the :flush hook.#2020-09-2218:39neilyio
:builds
 {:site
  {:target :esm
   :output-dir ".shadow-cljs-cache"
   :build-hooks
   [(build.hooks/eleventy)]
   :modules {:index.11ty {:exports
                          {default pages.index/default}}}}}}
#2020-09-2218:40neilyio
(defn eleventy
  {:shadow.build/stage :flush}
  [build-state & args]
  (let [output (sh "node" "-r" "esm" "node_modules/.bin/eleventy")]
    (when-not (empty? (:err output))
      (println (:err output)))
    (println (:out output)))
  build-state)
#2020-09-2219:30thheller@neil.hansen.31 not a clue. looks fine but I don't have a clue what eleventy even is or does. does it not have a watch command itself that you can run separately and skip the hook altogether?#2020-09-2220:00neilyio@thheller thanks for the response. I know it's tough to answer questions like this about an external tool... Eleventy does have its own watch command, but there's a few details that prevent it from working well with shadow-cljs compile.#2020-09-2220:03neilyioRight now my build is producing index.11ty.js, which exports.default a function that calls reagent's render-to-static-markup and returns an HTML string. Eleventy is basically running index.11ty.js, taking the HTML string, and creating the resulting HTML file (with some templating that it takes care of).#2020-09-2220:06neilyioI diff'd two versions of index.11ty.js, one created by shadow-cljs compile and one created by shadow-cljs watch. I noticed that there's a bunch of extra shadow.* namespaces that are imported in the version created by shadow-cljs watch, I figure some of these for hot-reloading functionality in the browser and providing the ability to connect to a REPL. I suspect that when Eleventy evaluates index.11ty.js, it's getting stuck somewhere on this REPL/hot-reload code.#2020-09-2220:07thhellerif you don't need hot-reload or REPL you can set :devtools {:enabled false} in your build config#2020-09-2220:08thhellerwhy are you not using :node-library though?#2020-09-2220:08thheller:esm seems like a weird choice if you actually want commonjs?#2020-09-2220:08thhellerthis never directly runs in the browser right?#2020-09-2220:15neilyioI tried :node-library a while, but I got the same error as in https://github.com/thheller/shadow-cljs/issues/304.
No protocol method ISwap.-swap! defined for type cljs.core...
#2020-09-2220:17neilyioAnd I don't seem to be able to do a module.exports = my_render_func with the :npm-module target, which is mentioned later in that issue.#2020-09-2415:06thhelleryou could just create a foo.js yourself that just has module.exports = require("./path-to-npm-module-output/your.ns").the_export;#2020-09-2415:06thhellerwith (defn ^:export the-export [foo bar] ...) in that ns#2020-09-2415:08thhellerbut I still don't have a clue what you are doing ... so good luck with boot 😉#2020-09-2220:20thhellerhow are you running into the issue you linked? do you have two builds loading in the script?#2020-09-2221:18neilyioWanted to address this question of yours. I'm running into this issue when I use Eleventy's --watch command, as you suggested in your first response. With this alternative workflow, I set Eleventy up to call shadow-cljs compile site every time it reloads.#2020-09-2221:19neilyioIt actually works the first time, as soon as I start Eleventy, but as soon as I make a change to a file, the reload errors with No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object].#2020-09-2221:20neilyio#2020-09-2220:20thhellerI assume its just running node to do stuff and generate HTML?#2020-09-2220:21thhellerI don't know enough about eleventy so I can't really help and linked issues that you guess might be related but also might not be doesn't let me help you#2020-09-2220:22thhellerthe issue that is immediately suspicious to me is the build hook#2020-09-2220:26neilyioWhich part?#2020-09-2220:31neilyioAlso, if this can be helpful at all, here's a GIF of what I'm seeing in the REPL on shadow-cljs watch. It's hanging on Compiling ..., and after I ctrl-c to exit, I'm getting a successful message Eleventy saying Copied 9 files / Wrote 1 file in 0.94 seconds, followed by shadow-cljs - #3 ready!. The HTML generation does in fact work perfectly after I ctrl-c to get out of the Compiling... message.#2020-09-2220:32neilyio#2020-09-2220:38neilyioUpdate: I can confirm that adding {:devtools {:enabled false}} as you suggested fixes the hanging problem. It no longer gets stuck on Compiling.... I feel even closer to the solution now, but Hot Reload really seems important to the workflow. Fingers crossed you have an idea for me!#2020-09-2222:18thhellerI still don't have the slightest clue about what you are actually trying to do here sorry#2020-09-2222:19thhellermy assumption would be that you'd just have a regular generate HTML page and include the JS afterwards#2020-09-2222:19thhellerincluding the JS to build the thing in the first place is something entirely different and I've never done that using react (ie. SSR)#2020-09-2318:47daemianmacki'm trying to switch "REPL focus" in shadow CLJS -- i've launched the CLJS REPL pointing at a build and then used the dashboard to start watching a second build. is there a way from within the CLJS REPL to evaluate statements against that second build? what i've been doing up until now is killing the REPL entirely, and relaunching it pointing it at that other build.#2020-09-2319:28thhellerthat would only be an option if whatever client you are using supports it#2020-09-2319:28thheller(I don't know any that do)#2020-09-2320:08daemianmackok, good to know at least i'm not missing something in the docs.#2020-09-2407:26thheller@daemianmack you can just run shadow-cljs watch build1 build2 build3 and then shadow-cljs cljs-repl build1 and so on (or nrepl) to talk to a specific REPL for a given build#2020-09-2407:27thhelleryou can have as many REPLs as you want but most editors don't do session management very well#2020-09-2409:33andrehi, when upgrading from 2.9.2 to the latest version, there is an error on Android, but works fine on ios , react native project#2020-09-2409:34andre#2020-09-2409:44andreand it seems work fine with hermes engine disabled#2020-09-2409:49andreso something has been changed after 2.9.2 and it won't work in hermes engine#2020-09-2409:51thhellerhmm no clue. would help to know what that statement was 😛#2020-09-2410:01yenda@thheller there is an instant crash with shadow-cljs on react-native when using the hermes engine "Property Long doesn't exist" related to goog.math.long.js . I bisected through shadow-cljs versions and it looks like 2.9.4 is clean, 2.9.5 is not on npm, and 2.9.6 has the bug#2020-09-2410:02yendawe are not using goog.math.long anywhere directly, but it looks like transit does indirectly#2020-09-2410:04yendasince it works fine in release I wonder if that could be related to this commit https://github.com/thheller/shadow-cljs/commit/c5ce449c5749c9a7dd7ed0f9d58ec5f78b826e03#2020-09-2410:05yendaor maybe even just the goog module hot-reload https://github.com/thheller/shadow-cljs/commit/659e6eb72f7ed0f2acaf57e5d4502bf24884646c#2020-09-2410:08thhellerI don't have a clue. goog.math.Long is used by cljs.core. sounds like a bug in hermes to me though?#2020-09-2410:09thhellerI assume you tested with 2.11.4 too?#2020-09-2410:09yendaIt can't be a bug in hermes because there is no bug in shadow-cljs 2.9.4, and no bug in release#2020-09-2410:10yendayes I tried 2.11.4 as well#2020-09-2410:10yendaany version above 2.9.4 has the bug#2020-09-2410:11yenda(2.9.5 is not on npm for some reason though)#2020-09-2410:11thhellerjust set :version "2.9.5" in shadow-cljs.edn (assuming you use neither project.clj nor deps.edn)#2020-09-2410:12thhelleris there more to the "Property Long doesn't exist" error though? I can't do much without knowing what the actual code is that crashes#2020-09-2410:12thhellerand how#2020-09-2410:13thhellerI mean just run a shadow-cljs compile build and load it#2020-09-2410:13thhellerif it crashes the code should be easy to find#2020-09-2410:13yendano compilation is fine as I said release works with any version#2020-09-2410:13thhellerit might be a bug in hermes because of eval#2020-09-2410:13thhellerrelease builds don't eval#2020-09-2410:14yendaand the crash doesn't give much info#2020-09-2410:14yenda#2020-09-2410:14yendain the phone logs it's even less#2020-09-2410:14thhellerrun shadow-cljs compile build#2020-09-2410:15thhellerthen the app/index.js is self-contained and won't connect to the REPL#2020-09-2410:15thhelleryou can edit that file#2020-09-2410:15thhellerit will have a bunch of evalLoad calls#2020-09-2410:15thheller
env.evalLoad = function(name, code) {
        goog.globalEval(code);
    };
#2020-09-2410:16thhellershould be in the code somewhere in the beginning#2020-09-2410:16yenda
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ee978b808a8fae8a8b9d859a819e"}, :content ("[email protected]")}
#2020-09-2410:16thhellermaybe try adding console.log("loading", name, code) or so#2020-09-2410:16thhellerjust to find the code that actually fails#2020-09-2410:17yendawhen I run the code generated by shadow-cljs compile build I have no error#2020-09-2410:17thhellerthen do the same with a running watch#2020-09-2410:18thhellerjust don't make any other changes or your mod will be overwritten#2020-09-2410:18thhelleralso make sure to test with 2.11.4 please#2020-09-2410:18thhellerno point in testing with 2.9.6#2020-09-2410:19yendashadow-cljs - server version: 2.11.4 running at http://localhost:3449#2020-09-2410:22yendathe last statement I see in the log is loading goog.math.long.js goog.loadModule(function(exports) and then the whole module code#2020-09-2410:24yenda@thheller If you want more details:
#2020-09-2410:26thhellerhmm#2020-09-2410:26thhellerthat file isn't rewritten at all?#2020-09-2410:26thhellerah hmm I guess the problem might be the :output-feature-set#2020-09-2410:28thhellerthat prevents it from rewriting the class Long and that maybe confuses Hermes?#2020-09-2410:28thhellerhmm although that should also fail in compile builds#2020-09-2410:31yendathere is a SHADOW_ENV.evalLoad in the file
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n  \x22use strict\x22;\n  goog.module(\x22goog.math.Long\x22);\n  goog.module.declareLegacyNamespace();\n  const asserts \x3d goog.require(\x22goog.asserts\x22);\n  const reflect \x3d goog.require(\x22goog.reflect\x22);\n  class Long {\n    constructor(low, high) {\n      this.low_ \x3d low | 0;\n      this.high_ \x3d high | 0;\n    }\n    toInt() {\n      return this.low_;\n    }\n    toNumber() {\n      return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n    }\n    isSafeInteger() {\n      var top11Bits \x3d this.high_ \x3e\x3e 21;\n      return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n    }\n    toString(opt_radix) {\n      var radix \x3d opt_radix || 10;\n      if (radix \x3c 2 || 36 \x3c radix) {\n        throw new Error(\x22radix out of range: \x22 + radix);\n      }\n      if (this.isSafeInteger()) {\n        var asNumber \x3d this.toNumber();\n        return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n      }\n      var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n      var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n      var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n      var remDiv \x3d this.div(radixToPower);\n      var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n      var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n      if (digits.length \x3c safeDigits) {\n        digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n      }\n      val \x3d remDiv.toNumber();\n      return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n    }\n    getHighBits() {\n      return this.high_;\n    }\n    getLowBits() {\n      return this.low_;\n    }\n    getLowBitsUnsigned() {\n      return this.low_ \x3e\x3e\x3e 0;\n    }\n    getNumBitsAbs() {\n      if (this.isNegative()) {\n        if (this.equals(Long.getMinValue())) {\n          return 64;\n        } else {\n          return this.negate().getNumBitsAbs();\n        }\n      } else {\n        var val \x3d this.high_ !\x3d 0 ? this.high_ : this.low_;\n        for (var bit \x3d 31; bit \x3e 0; bit--) {\n          if ((val \x26 1 \x3c\x3c bit) !\x3d 0) {\n            break;\n          }\n   ...
#2020-09-2410:31thhelleryeah all that looks exactly like it should#2020-09-2410:32thhellernot a clue why it works in compile but not watch?#2020-09-2410:32thhellerI mean watch loads more (and connects websocket) but all of that comes after goog.math.Long#2020-09-2410:40yendawith 2.9.4 https://gist.github.com/yenda/5f157d93164b856303574d547c33f632#2020-09-2410:40yenda(it loads the rest afterward)#2020-09-2410:45yenda@thheller if you look at the module it looks like they are not the same, not sure if that matters but for instance /** @const */ var reflect in 2.9.4 vs const reflect in 2.11.4#2020-09-2410:50yendaso maybe you were write and it has something to do with feature set?#2020-09-2410:51thhelleryes, if you set :output-feature-set :es5 that should change the rewriting#2020-09-2410:52thhellerbut again .. that sounds like a bug in hermes to me then#2020-09-2410:53yendaI'm not very familiar with these feature set so what changed between 2.9.4 and now?#2020-09-2410:55yendaHermes is compiling js into bytecode#2020-09-2410:58yenda
{:target :react-native
           :init-fn app.core/init
           :output-dir "app"
           :dev {:devtools {
                            :autoload true
                            :reload-strategy :full
                            :after-load app.core/reload
                            :compiler-options {:source-map false
                                               :output-feature-set :es5}}
                 :local-ip #shadow/env "SHADOW_HOST"}
           :release {:compiler-options {:output-feature-set :es6
                                        :warnings-as-errors true
                                        :infer-externs :auto
                                        :optimizations :advanced
                                        :js-options {:js-provider :closure}}}}
#2020-09-2410:59yendaI still have the error with this config#2020-09-2411:02yendaand the modules still have the const reflect syntax in index.js
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n  \x22use strict\x22;\n  goog.module(\x22goog.math.Long\x22);\n  goog.module.declareLegacyNamespace();\n  const asserts \x3d goog.require(\x22goog.asserts\x22);\n  const reflect \x3d goog.require(\x22goog.reflect\x22);\n  class Long {\n    constructor(low, high) {\n      this.low_ \x3d low | 0;\n      this.high_ \x3d high | 0;\n    }\n    toInt() {\n      return this.low_;\n    }\n    toNumber() {\n      return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n    }\n    isSafeInteger() {\n      var top11Bits \x3d this.high_ \x3e\x3e 21;\n      return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n    }\n    toString(opt_radix) {\n      var radix \x3d opt_radix || 10;\n      if (radix \x3c 2 || 36 \x3c radix) {\n        throw new Error(\x22radix out of range: \x22 + radix);\n      }\n      if (this.isSafeInteger()) {\n        var asNumber \x3d this.toNumber();\n        return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n      }\n      var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n      var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n      var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n      var remDiv \x3d this.div(radixToPower);\n      var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n      var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n      if (digits.length \x3c safeDigits) {\n        digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n      }\n      val \x3d remDiv.toNumber();\n      return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n    }\n    getHighBits() {\n      return this.high_;\n    }\n    getLowBits() {\n      return this.low_;\n    }\n    getLowBitsUnsigned() {\n   
#2020-09-2411:06yenda2.9.4:
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n  \x22use strict\x22;\n  goog.module(\x22goog.math.Long\x22);\n  goog.module.declareLegacyNamespace();\n  /** @const */ var asserts \x3d goog.require(\x22goog.asserts\x22);\n  /** @const */ var reflect \x3d goog.require(\x22goog.reflect\x22);\n  /** @final @constructor */ var Long \x3d function(low, high) {\n    /** @private @const @type {number} */ this.low_ \x3d low | 0;\n    /** @private @const @type {number} */ this.high_ \x3d high | 0;\n  };\n  /**\n   * @return {number}\n   */\n  Long.prototype.toInt \x3d function() {\n    return this.low_;\n  };\n  /**\n   * @return {number}\n   */\n  Long.prototype.toNumber \x3d function() {\n    return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n  };\n  /**\n   * @return {boolean}\n   */\n  Long.prototype.isSafeInteger \x3d function() {\n    var top11Bits \x3d this.high_ \x3e\x3e 21;\n    return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n  };\n  /**\n   * @param {number\x3d} opt_radix\n   * @return {string}\n   * @override\n   */\n  Long.prototype.toString \x3d function(opt_radix) {\n    var radix \x3d opt_radix || 10;\n    if (radix \x3c 2 || 36 \x3c radix) {\n      throw new Error(\x22radix out of range: \x22 + radix);\n    }\n    if (this.isSafeInteger()) {\n      var asNumber \x3d this.toNumber();\n      return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n    }\n    var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n    var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n    var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n    var remDiv \x3d this.div(radixToPower);\n    var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n    var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n    if (digits.length \x3c safeDigits) {\n      digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n    }\n    val \x3d remDiv.toNumber();\n    return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n  };\n  /**\n   * @return {number}\n   */\n  Long.prototype.getHighBits \x3d function() {\n    return this.high_;\n  };\n  /**\n   * @return {number}\n   */\n  Long.prototype.getLowBits \x3d function() {\n    return this.low_;\n  };\n  /**\n 
#2020-09-2411:08yenda@thheller ok looks like it works when I put compiler options at the top level of my build#2020-09-2411:09yendaso this line doesn't look into :dev and set es6 as default? https://github.com/thheller/shadow-cljs/commit/ad8ea9d4aefc5d1c0ab371613a9c96c17da3d447#diff-022dc5a1b7d0a256b0203406d97d8eb8R147#2020-09-2411:14yenda@thheller so the fix for now is to have :compiler-options {:output-feature-set :es5} at the top level of your build config map when you want to use hermes on react-native target#2020-09-2411:15grounded_sageAnyone have experience with doing the :target :karma and it not launching the headless chrome when running npx karma start --single-run?#2020-09-2411:19victorbHello everyone! Seems when I sometimes reload my browser window, vim-fireplace is loosing the connection with the page and cannot re-establish it. Trying to send commands after this happens show the following error:
[2020-09-24 13:16:06.847 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 1, :from 24}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/fn--15169/fn--15172 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
My config currently looks like this, basically the minimal one I could get my hands on.
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[reagent "1.0.0-alpha2"]]

 :dev-http {8081 "public"}
 
 :nrepl {:port 8082}

 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn app/init}}}}}
I come from using figwheel and figwheel-main for a long time, first time using shadow-cljs for a project, so probably I'm doing something wrong here. Using neovim, vim-fireplace. Running shadow-cljs by running npx shadow-cljs watch frontend , connecting my repl by doing :Connect 8082 and then :Piggieback :frontend . Everything works except until I reload the page, then starting to get that error above and the only thing I can do to make it work is restarting shadow-cljs watch again, then it starts working.
#2020-09-2411:22thheller@victorbjelkholm429 which version is this? this should have been fixed a while ago.#2020-09-2411:23victorb@thheller 2.11.4, think the project was bootstrapped from create-cljs-project so got the version from there#2020-09-2411:24victorbhm, could be the vim-fireplace version maybe? I'll check those out too#2020-09-2411:24thhellerweird. anything in particular you are doing with the REPL?#2020-09-2411:25victorbno, just calling println's and alike, nothing extreme#2020-09-2411:25thhellernot sure why you reloading the page affects anything on the compiler side#2020-09-2411:26victorb@thheller was behind a few commits in vim-fireplace. Upgraded and now not getting the error again... But will keep trying to reproduce, but seems fixed now. Well, thanks for the rubberducking @thheller 🙂#2020-09-2411:41andreso this line doesn't look into :dev and set es6 as default? https://github.com/thheller/shadow-cljs/commit/ad8ea9d4aefc5d1c0ab371613a9c96c17da3d447#diff-022dc5a1b7d0a256b0203406d97d8eb8R147#2020-09-2411:43thheller@andre why would it? its not supposed to? it is supposed to be identical in dev/release?#2020-09-2411:44thhellerI say again ... this very much sounds like a bug in hermes to me if it works in other engines#2020-09-2411:44thhellergiven that chrome, firefox, etc have no issues with this whatsoever#2020-09-2411:45thhellerand again .. I suspect eval to be the cause here. release builds will not eval and instead load the code directly.#2020-09-2411:45thhellerI do not have any necessary setup to test hermes so can't say much more#2020-09-2411:47thhellerthe code shadow-cljs produces looks exactly like it should, :es5 should not be a required setting but if it makes hermes happy then fine just set it#2020-09-2411:47thhelleryou can set :dev {:compiler-options {:output-feature-set :es5}} if you only want it in dev#2020-09-2412:00yendait doesn't work if you set it in dev @thheller, I had to set it in the top level of the build map#2020-09-2412:59yendaIs there a way to write jsx file alongside cljs and import the components in cljs files? It works with js but I don't understand the stack enough to figure out how to make sure the jsx stuff gets transpiled#2020-09-2413:18simongrayNot having any luck attempting to use oz via shadow-cljs. At first I just tried going by the instructions in the Oz github readme, but kept running into an error with a missing file. Shadow-cljs was looking for a .js file, but in the folder only .min.js, .node.js and .module.js were available. Then I found this template project and the exact same error occurs: https://github.com/ivanminutillo/reagent-shadow-oz-example
[:app] Build failure:
override to file that doesn't exist
{:tag :shadow.build.npm/invalid-override, :require-from #object[java.io.File 0x4d68156d "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-dataflow/build/vega-dataflow.js"], :require "vega-loader", :file #object[java.io.File 0x41ebcb92 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.node.js"], :override "./build/vega-loader.js", :override-file #object[java.io.File 0x5d156b61 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.js"]}
ExceptionInfo: override to file that doesn't exist
	shadow.build.npm/find-resource (npm.clj:735)
	shadow.build.npm/find-resource (npm.clj:661)
	shadow.build.resolve/find-npm-resource (resolve.clj:123)
	shadow.build.resolve/find-npm-resource (resolve.clj:94)
#2020-09-2419:40JAtkinswow, this is the first time I've seen that message in my builds and you already asked about it 🙂. Quite a coincidence#2020-09-2419:41JAtkinsI would almost say that there is some new version of vega, and since package.json usually imports "^version", we both got upgraded at the same time#2020-09-2413:20simongraySo now I’m wondering what to do? The packages are installed, but shadow-cljs is looking for e.g. vega-loader.js when only files like vega-loader.min.js is available in that folder.#2020-09-2415:46thheller@simongray not a clue. the package is linking to a file that it does not itself contain. likely just a bad config entry on their part. you can fix it by editing https://github.com/vega/vega/blob/master/packages/vega-loader/package.json#L41 to link to the correct file#2020-09-2415:50simongrayThanks Thomas. I'll attempt that. It just seems odd that a setup that presumably worked at one time using those same versions now doesn't to seem any longer.#2020-09-2415:52thhellerI'm guessing that the bundling was just changed in recent versions#2020-09-2415:53thhellercurrent seems to be 4.3.3 but 4.3.2 still had the non-min file https://unpkg.com/browse/vega-loader@4.3.2/build/vega-loader.js#2020-09-2415:53thhellerso blame them ...#2020-09-2416:44simongrayThanks a lot. That got me on the right track. I managed to get it to compile by adding these two explicit dependencies to the package.json
"vega-loader": "4.3.2",
"vega-canvas": "1.2.4"
apparently, version 1.2.5 of the vega-canvas package suffered from the same issue.
#2020-09-2416:46simongray@U01BL8MKU7K Jeg fandt ud af hvad problemet var med lidt hjælp fra Thomas.#2020-09-2506:16Sofie JensenHurra!#2020-09-2609:39victorbThe docs for :module-hash-names explains I should probably use the generated manifest.edn with it, but can't seem to find any ways of not having to manually (or write a script for it) replace the path in my index.html to the fingerprinted bundle. Is there no option for this?#2020-09-2610:01victorbEnded up adding some sed and jet commands to my deploy file to workaround in the meantime. But would be happy to hear if this is build-in somewhere!#2020-09-2610:41thhellerI wrote a proof-of-concept a while ago that can do this#2020-09-2610:41thheller
:build-hooks
   [(shadow.html/copy-file
      "out/demo-browser/index.src.html"
      "out/demo-browser/public/index.html")]
#2020-09-2610:42thhellerin your build config#2020-09-2610:42thhellerexpects to find a <script src="/js/main.js"> if you build config has :asset-path "/js" :modules {:main ...}#2020-09-2610:43thhellerand will replace that with the hashed name#2020-09-2610:43thhelleror you could replace the bash file you have and write it entirely in clojure#2020-09-2610:44thhellerand use clj-run to trigger the function#2020-09-2610:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2020-09-2610:44victorboooh, the build-hooks stuff is just what I was looking for! Thanks!#2020-09-2610:45victorbif I had the time I'd send you a PR to add the build-hooks example to right after where it says "it gets a little bit more complicated to include them in your HTML" in the docs#2020-09-2610:46victorbotherwise, cheers for shadow-cljs! Minimal hassle so far 🙏#2020-09-2617:34yendaIs there a workaround for transit-cljs compilation warning besides turning warning as error to false in release builds?#2020-09-2617:58thheller@yenda :warnings-as-errors {:ignore #{transit.*}} I believe?#2020-09-2618:04yendathanks, actually I realize it's not coming from transit-cljs but from this snippet in our code base
(deftype DefaultHandler []
  Object
  (tag [this v] "unknown")
  (rep [this v] (pr-str v)))
#2020-09-2618:04yenda
Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)
{:warning :infer-warning, :line 8, :column 1, :msg "Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)"}
ExceptionInfo: Cannot infer target type in expression (. (. DefaultHandler -prototype) -rep)
#2020-09-2618:08thhellerhmm yeah I don't know why that warns but had that in my own code#2020-09-2618:09thhellerdidn't have time to look into it but (set! *warn-on-infer* false) is a quickfix until then 😉#2020-09-2618:10yendaactually not sure if it's better or not but I got rid of it by typehinting#2020-09-2618:10yenda
(deftype ^js DefaultHandler []
  Object
  (tag [this v] "unknown")
  (rep [this v] (try
                  (str v)
                  (catch :default e
                    (when goog.DEBUG
                      (log/warn "Transit was unable to encode a value."))
                    "UNENCODED VALUE"))))
#2020-09-2704:20mischovHas anybody had a problem getting shadow-cljs to compile when your deps.edn includes a com.datomic/dev-local dep? Compilation hangs for me when I include it but works fine if I remove it.#2020-09-2704:22mischovWondering if it has anything to do with the games Cognitect make you play getting authorization to pull the dep.#2020-09-2707:11thheller@mischov I believe it causes a conflict on guava or something. check for dependency conflicts. its not the authorization (assuming you have that setup correctly)#2020-09-2714:33souenzzo@mischov I have a app that use #shadow-cljs and #datomic ions/cloud I end up to manually manage the guava version. (explicit set it in deps.edn)#2020-09-2715:33mischovThanks!#2020-09-2717:33mischovThat was indeed that problem. Thanks again! There is a forum post about it here, too: https://forum.datomic.com/t/incompatibility-between-versions-of-guava-in-dev-local-and-clojurescript-compiler/1550#2020-09-2808:46g7sI don't know if this has been asked before but I am trying to require a json file in a react native project. Is it possible to do with shadow? If yes can someone please outline the process? thanks!#2020-09-2808:48g7sRight now I have a "src/js/my/namespace/foo.json" file and I am including the "src/js" in my :source-paths I do not succeed when it comes to actually requiring the file#2020-09-2808:50g7sOne other thing I tried is to include a :js-options with :resolve to my json file to no avail#2020-09-2808:59thheller@g7s you can only require json files via js/require to let metro fill it in#2020-09-2808:59thheller(def data (js/require "../assets/foo.json"))#2020-09-2808:59thhellerpath is relative to the created :output-dir#2020-09-2809:00g7sah I actually never tried that.. Thanks @thheller#2020-09-2811:14shivekkhuranaWhat's the status of code splitting with Reagent applications? I've found this 2 year old blog post by Thomas (https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html). It splits code but reactifies Reagent component before rendering. It it possible to lazy load Reagent components?#2020-09-2811:15thhellerthats what the post describes?#2020-09-2811:17shivekkhuranaIn your post, the Reagent components are Reactified: https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs#L27 This means that Ratoms and Reframe cannot be used, since ratoms don't work with reactified components.#2020-09-2812:00thhellerthats not correct#2020-09-2812:01thhellerthe wrapper loading the component is reactified. not the actual component#2020-09-2812:01thhellerthe actual component can do whatever#2020-09-2904:57shivekkhuranaThank you Thomas! I was able to get lazy loading work with shadow/lazy#2020-09-2812:06shivekkhuranaOh, okay. I had a gap in my understanding.#2020-09-2812:06shivekkhuranaWill try it out.#2020-09-2818:13Akiz17Hi, i ve been using shadow-cljs with lein to this day. Today i removed :lein true and moved all clojurescript deps into shadow-cljs.edn. When I run shadow-cljs watch app it fails with the required namespace devtools.preload is not available. But binaryage/devtools 1.0.2. Is one of my dependencies in shadow-cljs. edn. What is the problem? Should i go back to combination of lein and shadow-cljs even if it is discouraged fy shadow-cljs website?#2020-09-2818:31thheller@jakub.zika-extern should be working fine. you sure you declared it correctly? no misplaced [] or so?#2020-09-2818:45Akiz17No, but i am glad to hear that cljs dependencies should work 1:1 with lein. I moved everything back to lain but i will investigate further later for sure. Is there some debugging on shadow-cljs side like "show me installed dependencies" etc?#2020-09-2819:12thhellershadow-cljs info shows a bit#2020-09-2820:18Ian FernandezI didn't found a way to run with node-tests to activate :auto-run true only on watch, there's a way to to this on shadow-cljs cli like shadow-cljs watch :my-test something-here ?#2020-09-2820:18thhellershadow-cljs watch my-test --config-merge "{:autorun true}"#2020-09-2820:19Ian Fernandezthanks @thheller 🙂#2020-09-2820:19Ian Fernandez=))#2020-09-2903:45JeremyHi everyone. May I please get some advice on how to debug an AssertionError Assert failed: (rc/valid-resource-id? src-id) shadow.cljs.devtools.server.worker.impl/eval17300/fn--17303/fn--17306 (impl.clj:808) error? :shadow.cljs.devtools.server.util/handle-ex reports {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "common/lists.cljc"]... and :sources seems to include a nil which I presume is causing the problem. Unfortunately I can't quite work out what's causing the nil.#2020-09-2903:45Jeremy(The error happens when I try to evaluate anything once connected to the browser cljs repl)#2020-09-2906:56thheller@clojure475 what are you trying to eval? and please do not shorten errors. I need the full stacktrace to make sense of it#2020-09-2910:05JeremyThanks for reply Thomas. It seems to happen when I try to eval anything, even a plain keyword.#2020-09-2910:05JeremyThe setup is a bit complicated (`shadow-cljs.edn` pointing at deps.edn aliases etc) but has been working brilliantly until I made too many changes without testing stepwise.#2020-09-2910:05JeremyOutput
:a
[2020-09-29 20:04:36.176 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "common/lists.cljc"] [:shadow.build.classpath/resource "common/allocations.cljc"] [:shadow.build.classpath/resource "test/tools.cljc"] [:shadow.build.classpath/resource "test/examples.cljc"] [:shadow.build.classpath/resource "test/common/allocations.cljc"] [:shadow.build.classpath/resource "test/common/api.cljc"] [:shadow.build.classpath/resource "test/common/appointments.cljc"] [:shadow.build.classpath/resource "test/common/dates.cljc"] [:shadow.build.classpath/resource "test/common/fsm.cljc"] [:shadow.build.classpath/resource "test/common/lists.cljc"] [:shadow.build.classpath/resource "test/common/message.cljc"] nil [:shadow.build.classpath/resource "test/common/core.cljc"] [:shadow.build.npm/resource "node_modules/react/cjs/react.production.min.js"] [:shadow.build.classpath/resource "test/client/events/requests.cljs"] [:shadow.build.classpath/resource "test/client/core.cljs"] [:shadow.build.npm/resource "node_modules/scheduler/cjs/scheduler.production.min.js"] [:shadow.build.npm/resource "node_modules/react-dom/cjs/react-dom.production.min.js"] [:shadow.build.npm/resource "node_modules/scheduler/cjs/scheduler-tracing.production.min.js"] [:shadow.build.npm/resource "node_modules/react-is/cjs/react-is.production.min.js"] [:shadow.build.npm/resource "node_modules/prop-types/factoryWithThrowingShims.js"] [:shadow.build.classpath/resource "cljs/user.cljs"]], :call-id 5, :from 57}}
ExceptionInfo no output for id: [:shadow.build.classpath/resource "test/examples.cljc"] {:resource-id [:shadow.build.classpath/resource "test/examples.cljc"]}
	shadow.build.data/get-output! (data.clj:197)
	shadow.build.data/get-output! (data.clj:193)
	shadow.cljs.devtools.server.worker.impl/eval17300/fn--17303/fn--17306 (impl.clj:813)
	clojure.core/map/fn--5866 (core.clj:2753)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
Timeout while waiting for result.
#2020-09-2910:06thhellerwhich version in deps.edn?#2020-09-2910:07Jeremy2.11.2, running from clj not the command line#2020-09-2910:08thhellertry 2.11.4 just in case#2020-09-2910:09thhellerthere was a bug related to this a while ago but no clue why you are still seeing it#2020-09-2910:12thhellerwhat REPL is this? assuming nrepl?#2020-09-2910:13Jeremyyep nrepl and yep thank you the version bump (as well as restarting repl, which I do fairly frequently) seems to have resolved the problem!:+1:#2020-09-2910:19Jeremybrilliant#2020-09-2907:44pmooserIn my project, I'm doing a normal + bootstrap build, and when I first launch shadow-cljs, I get a bunch of warnings about a provide conflict between the normal and bootstrap builds, like this:
[2020-09-29 09:40:52.675 - WARNING] provide conflict for #{goog.structs.Set} provided by web/js/bootstrap/js/goog.structs.set.js and {"/goog/structs/set.js" #{goog.structs.Set}}
#2020-09-2907:44pmooserDoes this represent an error on my part, that can be avoided?#2020-09-2907:46thhellerdon't have the output of a build on the classpath 😛#2020-09-2907:46thhelleralthough I thought I had fixed the filtering that should take care of this#2020-09-2907:46thhellerguess it doesn't account for bootstrap builds#2020-09-2907:47pmooserSo that's inferred or generated based on what, exactly? outdir-dir ? or asset-path ? I see no explicit classpath in my shadow-cljs.edn.#2020-09-2907:48pmooserWhat I am doing seems to follow more or less the tutorials that exist.#2020-09-2907:48pmooserSo I don't find that advice of "don't do that" very easy to follow, unfortunately.#2020-09-2907:52thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_important_concepts#2020-09-2907:52thhellerby classpath I'm referring to your :source-paths and the :output-dir being on said source path#2020-09-2907:54pmooserMy :source-paths have my output dir on them - but if I remove it from source-paths and restart shadow-cljs, I get the same error.#2020-09-2907:54pmooserLet's see ...#2020-09-2907:57pmooserOk, perfect.#2020-09-2907:57pmooserSo I ended up having that same issue in a project I was importing, which maybe seems to have been the source of the error.#2020-09-2907:57pmooserThanks for that - I'm not sure why my output dir was in the source paths to begin with.#2020-09-2907:58pmooserProbably an artifact of something dumb I was doing long ago!#2020-09-2907:58thhellerwell it is supposed to be filtered and ignored but it looks like it just doesn't filter bootstrap builds#2020-09-2907:59thhellersince the filtering is based on the cljs-runtime dir which bootstrap doesn't have#2020-09-2908:01pmooserOk, well, thank you for the insight in any case. I prefer having no warnings coming from the build if I can!#2020-09-2910:26ullrichIntro and context: We are reusing some code between our web app and our react-native app and for that we need to do some runtime checks. Unfortunately we also need to convince the compiler to play along. For web it’s easy to stub out dependencies by using :js-options :resolve with :target :global. So here comes the question: If we want to use :target :global on react-native what is the best way to populate global? In our web app we can execute JS before the app runs, but on mobile I didn’t find a way to do so.#2020-09-2910:27thheller@ullrich.schaefer do you have an example of what you are stubbing out this way?#2020-09-2910:28thhellerI made this example a while ago https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2020-09-2910:28thhellerit isn't fully explained but I hope the idea is somewhat understandable#2020-09-2910:28thhellerpoint is that you don't do any "replacements" of the requires this way#2020-09-2910:40ullrichA good example is Quill-js which is used in the main app to edit text. The mobile app is not concerned with editing text, but is including some namespaces that eventually end up importing quill. Also our main app is still build without shadow in production so we’re restricted in how we can import namespaces. There we use :global-exports in deps.edn. We use shadow for dev though so we can just do :js-options {:resolve {"quill" {:target :global :global "quill"}}} . Quill is just one of many examples and it would be great not to have to restructure all code around those dependencies, but find a solution at build tool level.#2020-09-2910:58thhellerI don't get it. where does quill come from?#2020-09-2911:00thhelleryou might want to look into :js-provider :external if thats coming from webpack or so? only desribed here currently https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
#2020-09-2911:03thhelleras far as I understand for the react-native issue though you can probably just set :js-options {:resolve {"quill" false}}#2020-09-2911:03thhellerthat will make it just ignore that dependency entirely? not sure if you need the actual global?#2020-09-2911:05thhellerI'm assuming that the code using the result isn't called at all?#2020-09-2911:06thhellerotherwise (:require ["quill" :as q]) the q will be false#2020-09-2911:09ullrichYes, that’s actually what we’re looking for. We’ll try that and I’ll report back to you. Sorry, but our setup is a bit complicated and grew a bit over the years 😄 Our dependencies on web are loaded using an outdated approach called doublebundle, described https://presumably.de/double-bundle-integrating-npm-dependencis-into-clojurescript-projects.html. Certainly something we need to transition away from at some point. A lot of good things happened to the CLJS ecosystem over the last years. Shadow being one of them 🙏 thanks3 🙇#2020-09-2912:01ullrich@thheller Turned out it didn’t work because we’re not using shadow-style/double-quote imports (we have another app that is build using cljs with :target :bundle#2020-09-2911:10thhellerlook into the :external stuff maybe#2020-09-2911:12ullrichin which context? Do you have a link where I can learn more?#2020-09-2911:12thhellersee the link a few lines up#2020-09-2911:13thhellerfor the web parts I mean#2020-09-2911:10thhellerthats basically a half-automated double-bundle#2020-09-2911:35danielstocktonHaving some problems with my project after installing some npm dependencies Uncaught TypeError: Cannot read property 'hydrate' of undefined#2020-09-2911:36danielstockton
(ns pwa.core
  (:require [react-dom :as react-dom]
            [reagent.core :as r]))
#2020-09-2911:36danielstocktonWhy would react-dom be undefined here?#2020-09-2911:36danielstocktonIs the reagent dependency somehow conflicting with the react/react-dom in package.json?#2020-09-2911:39thheller@danielstockton there is no use of hydrate in the code you pasted so no clue how you are using it?#2020-09-2911:40danielstocktonSorry, just using it like this
(ns ^:figwheel-hooks pwa.core
  (:require [pwa.shared :as shared]
            [react-dom :as react-dom]
            [reagent.core :as r]))

(defn mount [el]
  (react-dom/hydrate (r/as-element [shared/root]) el))
#2020-09-2911:40thhellerlooks fine#2020-09-2911:40thhellercheck if your node_modules/react-dom is empty for some reason#2020-09-2911:40thhellersometimes that can happen with npm#2020-09-2911:41danielstocktonYeah, these problems started after i installed html-react-parser for the server side part, which meant i also had to install react and react-dom with npm. Have tried clearing node_modules completely and reinstalling multiple times, npm installing the same version as reagent (16.13.0)#2020-09-2911:42danielstockton
ls node_modules/react-dom/
build-info.json  index.js  package.json  README.md          server.js       test-utils.js  unstable-fizz.browser.js  unstable-fizz.node.js
cjs              LICENSE   profiling.js  server.browser.js  server.node.js  umd            unstable-fizz.js          unstable-native-dependencies.js
#2020-09-2911:42danielstocktonreact-dom folder not empty#2020-09-2911:43thhellerif you haven't restarted shadow-cljs after running npm install or so maybe try doing that#2020-09-2921:26Logan PowellI've been banging my head against Calva and VSCode with shadow all day and I'm spent... anyone know why when I eval a namespace nothing seems to get loaded?#2020-09-2921:29Logan Powellhere's my shadow-cljs.edn:
{:source-paths ["src"]
 :dependencies [[cljs-ajax "0.8.0"]
                [org.clojure/core.async "1.3.610"] ; ignored by shadow-cljs (embedded)
                [funcool/cuerdas "2.2.0"]
                [clojusc/defun "0.4.0"]
                [frankiesardo/linked "1.3.0"]
                [jamesmacaulay/cljs-promises "0.1.0"] ; FIXME: When batching cartography files: uncomment and `shadow-cljs pom`
                ;;[cider/cider-nrepl "0.23.0"] ; for Calva + Shadow-cljs 
                [net.cgrand/xforms "0.19.2"]]
 :nrepl        {:port 3333}
 :builds       {:lib {:target           :node-library
                      :output-dir       "public/census"
                      :output-to        "public/census/census.js"
                      :compiler-options {:optimizations :advanced
                                         :source-map-include-sources-content false}
                      :exports-var      census.core/census}
                :geo {:target           :node-library
                      :output-dir       "public/geo"
                      :output-to        "public/geo/batch_convert.js"
                      :compiler-options {:optimizations :simple}
                      :exports-var      configs.geojson.core/batch_convert}}}
#2020-09-2921:29Logan Powell... here's what I'm trying to load:
(ns configs.geojson.core
  (:require
   [cljs.core.async           :refer [>! <! chan promise-chan close! take! put! pipeline-async]
    :refer-macros [go go-loop]]
   [cuerdas.core              :refer [join]
    :as s]
   [clojure.set               :refer [map-invert]]
   [defun.core                :refer-macros [defun]]
   [cljs-promises.async       :refer [value-port]] ;; Fixme: Need this dependecy -< move configs to separate project
   [census.utils.core         :refer [map-target error err-type]]
   [configs.utils.core        :refer [read-edn FileSaver]]
   [configs.geojson.filepaths2018 :refer [paths]]
   [clojure.reader :refer [read-string]]
   ["fs" :as fs]
   ["shpjs" :as shpjs]
   ["mkdirp" :as mkdirp]))

(def geoKeyMap (read-edn "./src/configs/geojson/index.edn"))
#2020-09-2921:30Logan Powelland here's what's eval'd:
clj::shadow.user=> 
; Creating cljs repl session...
; Connecting cljs repl: shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Connected session: cljs, repl: node-repl
; TIPS: You can choose which REPL to use (clj or cljs):
;    *Calva: Toggle REPL connection*
;    (There is a button in the status bar for this)
cljs::cljs.user=> 
; Evaluating file: core.cljs
; ------ WARNING - :redef --------------------------------------------------------
;  Resource: <eval>:16:1
 resolve already refers to: cljs.core/resolve being replaced by: cljs-promises.core/resolve
--------------------------------------------------------------------------------

nil
cljs::configs.geojson.core=> 
#object[TypeError TypeError: Cannot read property 'core' of undefined]
cljs::configs.geojson.core=> 
#2020-09-2921:31Logan PowellI've tried using a remote session and a straight "jack-in" workflow both using a build id as well as just a node-repl I get the same no matter#2020-09-2922:06thheller@loganpowell the problem might be the warning#2020-09-2922:06thhellerI can't see what the REPL is actually doing (like what was eval'd) so I can't tell#2020-09-2922:06thhellermight be that the warning skips loading the code#2020-09-2922:08Logan Powelllet me try without defun#2020-09-2922:09thhellerdefun? the warning is from cljs-promises? no clue what defun is?#2020-09-2922:09Logan Powellsorry, that's what I meant#2020-09-2922:55steveb8nQ: has anyone ever done aws interop to implement x-ray tracing for the entire SDK as documented here https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-awssdkclients.html ? I can’t figure out the incantation for Shadow style interop#2020-09-2922:57thhellerwhat incantation?#2020-09-2922:57thhellercan't tell from the page since either example is missing code to understand what any of it means#2020-09-2923:05steveb8nI agree. That’s part of my problem. I’m experimenting with it now, looking at the generated js to try and match it up. I’ll report back if/when I get it working#2020-09-2923:05steveb8n(sorry, by “incantation”, I meant “interop form”. that’s me being too clever)#2020-09-2923:09thhelleryes but which form do you mean?#2020-09-2923:09thhellervar AWS = AWSXRay.captureAWS(require('aws-sdk')); that example doesn't explain where AWSXRay is coming from#2020-09-2923:10thhellervar ddb = AWSXRay.captureAWSClient(new AWS.DynamoDB()); that doesn't explain where AWS is coming from#2020-09-2923:10thhellerso I can't tell how this is supposed to be used#2020-09-2923:11thhellerunless its supposed to be used together
var AWSXRay = require('aws-xray-sdk');
    var AWS = AWSXRay.captureAWS(require('aws-sdk'));
    var ddb = AWSXRay.captureAWSClient(new AWS.DynamoDB());
#2020-09-2923:11thhellerin which case the documentation is just plain weird#2020-09-2923:11thhellerbut which part do you have an issue with?#2020-09-2923:13thheller
(ns foo.bar
  (:require
    ["aws-xray-sdk" :as aws-xray]
    ["aws-sdk" :as aws-sdk]))

(def aws (aws-xray/captureAWS aws-sdk))
(def ddb (aws-xray/captureAWSClient (aws.DynamoDB.)))
#2020-09-2923:13thhellermaybe that helps. no clue what any of it does but that would be the translation#2020-09-2923:28Logan Powellyep, resolve already refers to: cljs.core/resolve being replaced by: cljs-promises.core/resolve is the issue, when I remove that, smooth sailing. Is there a way to alias a function within a dependency like this?#2020-09-2923:31steveb8nthanks @thheller I figured it out. the confusing part was around calling the “new” which is not very lispy. And yes, the AWS doc is not clear at all#2020-09-2923:35steveb8nthe solution is…. use these 2 requires
["aws-sdk" :as aws-sdk-clean]                   ; clean means without x-ray
          ["aws-xray-sdk" :as aws-xray-sdk]
          
then use this form to wrap the sdk with xray
(let [capture-full-sdk (j/get aws-xray-sdk :captureAWS)]
  (capture-full-sdk aws-sdk-clean))
then you can use this let form to construct a service client where aws-sdk is the wrapped sdk
[s3-client (j/get aws-sdk :S3)
      s3 (new s3-client)]
#2020-09-2923:35steveb8nwas not obvious but this works#2020-09-3008:16thheller@loganpowell (:refer-clojure :exclude (resolve)) in the ns would fix it too#2020-09-3011:56Logan PowellThank you sir. I actually did just this by just copying the library that conflicted and appending that code within the conflicting namespace.#2020-09-3011:58Logan PowellFunny thing is - I know it's been a while (about six months) - that I recall I used to get the same conflict warning, but I would still be able to run my code...#2020-09-3012:06martinklepschI have a bit of code that stores a JS object in an atom and I have to add ^js hints whenever I want to interop with that object. Would there by another way that doesn’t require adding ^js everywhere?
(defonce ^:private remote-config
  (atom nil))

(defn init! []
  (reset! remote-config (firebase/remoteConfig))
  (set! (.-settings ^js @remote-config)
        #js {:minimumFetchIntervalMillis config/remote-config-fetch-interval})
  (p/do!
    (.ensureInitialized ^js @remote-config)
    (.fetchAndActivate ^js @remote-config)))
#2020-09-3012:19thheller@martinklepsch why are you putting it in an atom if you are going to mutate it anyways?#2020-09-3012:20martinklepschBecause I can’t construct it at namespace loading time #2020-09-3012:20thhelleryou can reduce the number of ^js with a (let [^js cfg @remote-config] ...) and just operating on cfg but other than that I don't know of a way to typehint deref#2020-09-3012:20martinklepsch(If that makes any sense) #2020-09-3012:21thheller(def thing nil) (set! thing "something") should be fine?#2020-09-3012:27martinklepschAh, didnt realize set! could also be used on „vars“ kind of assumed it had to have an interop form as first arg #2020-09-3013:11kimimHello, I'm using react-data-grid to show some data. But since version 7.0.0.canary.17 this lib uses some ES2020 feature, as it says: react-data-grid is published as ES2020 modules, you'll probably want to transpile those down to scripts for the browsers you target using Babel and browserslist. How can I enable this for cljs? Thanks.#2020-09-3015:11thheller@kimi.im automatically done for you#2020-09-3022:32kimimBut there are some weird problem if I switch the version. Or maybe that’s react-data-grid’s bug. I put the example in github here: https://github.com/kimim/cljs-react-data-grid #2020-09-3023:14thhellerplease provide at least some kind of error description. I don't know what I'm supposed to be looking for and don't have time to run through the entire repo#2020-10-0102:02kimimhttp://ubuntu.chinaeast2.cloudapp.chinacloudapi.cn:3030/#2020-10-0102:03kimimIt is expected to display the table, but it did not show any thing now if I use the canary.22 version of the lib.#2020-10-0102:05kimimThe expected result: https://adazzle.github.io/react-data-grid/canary/?path=/story/demos--common-features#2020-10-0108:03thhelleras far as I can tell it is the div with height: 100%. if I set that to 200px or so it displays the table just fine?#2020-10-0108:30kimimThank you @thheller, I think that is the bug in react-data-grid itself, as it is under some big changes in recent versions. Anyway shadow-cljs is a great tool, which ease a lot of pain to use clojurescript.#2020-09-3015:51localshredHi friends, I'm struggling to find a way to invoke a node script during compilation (after files have changed) for live reload of generated css. My app has garden styles written in each of my reagent components that I'm then building with a node target which writes out the index.html and app.css files in my public directory. I'd like to invoke that :static node target (which becomes resources/bin/static.js) during the normal :browser target live reload compilation. All of the generator code for producing the index and css files live in a namespace separate from my primary application, as I don't want that code ending up in the released app. I've tried every configuration trick I can find in the user manual: + :dev/before-load or :dev/after-load doesn't appear to work as the gen namespace isn't required by app (is my guess). + Adding a separate module (the generator ns) that depends on app ns. This nearly worked, but was invoking things in a cljs context which meant I didn't have access to write files to the system. + :build-hooks after :flush stage Currently my shadow file looks like this:
{:deps {:aliases [:cljs]}
 :builds
 {:browser
  {:target     :browser
   :modules    {:app {:entries []}}
   :output-dir "resources/public/js/my/app"
   :asset-path "/js/my/app"
   :devtools   {:before-load my.gen/generate!
                :after-load  
                :http-root   "resources/public"
                :http-port   43234}}

  :static
  {:target           :node-script
   :main             my.gen/generate!
   :output-to        "resources/bin/static.js"
   :compiler-options {:reader-features #{:node}}}}}
Anyone have any ideas?
#2020-09-3015:54thhellernot supported. you could do it in a :flush hook of the :static builds. I'm assuming that also loads all the code the browser build is loading#2020-09-3015:55localshredyes it does, it requires the component ns' to get the styles for compilation#2020-09-3015:56localshrednow that I write that here, I'm thinking I could write a shim fn in the browser code that does the compilation and just dynamically injects a style tag into the head or something, then have that code stripped out of the release build#2020-09-3015:58localshredthanks @thheller for the response, and of course for the wonderful tool that shadow is#2020-09-3022:03mrchanceHi, I have some weird behavior with shadow cljs and an npm library... I (:refer ["d3-hierarchy" :as d3])and call (.tree d3) which worked before, but now it says tree is not a function, and on inspection the d3 object is just an empty map. I cleaned, restarted the build, even re-installed all npm dependencies, but it didn't change it. Any idea how that might've happened?#2020-09-3022:20mrchanceOccasionally the build also claims that [nil] is not a valid hiccup form for a component in the same namespace, which by this point is literally just
(defn foo []
  [:div "wtf"])
#2020-10-0109:29thhellerdid you maybe install a different version of the package? sometimes stuff is moved to different packages. I vaguely remember someone else reporting and issue but it was something based on the package. can't remember the details though.#2020-10-0114:49mrchanceI did have the "full" d3 package installed before, but I don't see that either in the package.json or the lockfile anymore, and everything else I deleted and reinstalled as far as I can tell#2020-10-0113:41J CrickI'm having some trouble using cljsjs/react-select in a reagent project (I'm pretty new to CLJS). The problem is, I get this: The required namespace "cljsjs.react-select" is not available, output from shadow-cljs. The dependencies in my shadow-cljs.edn file look like this:
:dependencies [[binaryage/devtools "1.0.0"]
                [nrepl "0.7.0"]
                [stylefy "2.2.1"]
                [reagent "0.10.0"]
                [cljsjs/react-select "2.4.4-0" :exclusions [cljsjs/react]]]
My require statement inside the reagent component looks like this:
(:require
    [cljsjs.react-select]
    [stylefy.core :as stylefy
     :refer           [use-style]]))
Does anyone have an idea of what I might be doing wrong---or an example of code working with cljs/react-select that I might be able to consult?
#2020-10-0115:05isak@alibris.lumos For shadow-cljs you shouldn't be using cljsjs , check out this part of the docs: https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2020-10-0115:06isakOr use that workaround in the docs, I guess#2020-10-0115:23J Crick@U08JKUHA9 Thanks for pointing that out! I'll read up on that...#2020-10-0209:32Karol WójcikIs it possible to include dependency only on nodejs? Something like (:require-node)?#2020-10-0210:07thhelleronly via https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2020-10-0210:59AronI am a bit confused with the missing runtime error. I have a node-test build that I ran with node, but that doesn't yield a runtime, or at least not one I could yet connect to.#2020-10-0211:30jcfHello all! I'm working on a little prototype web app built on top of AWS Amplify, and I've hit an interesting problem when applying advanced optimisations. Amplify generates code for you that defines the attributes of models that can be found in your GraphQL backend. In my case the generated models/index.js file contains this:
// @ts-check
import { initSchema } from '@aws-amplify/datastore';
import { schema } from './schema';



const { Product, ListedProduct, List } = initSchema(schema);

export {
  Product,
  ListedProduct,
  List
};
The schema file is a JavaScript file with lots of data…
export const schema = {
    "models": {
        "Product": {
In development I can require these models from Clojurescript with (:require ["../models/index" :as model]) , and things like model/Product work just fine. In production, with advanced compilation, the value of model/Product is undefined. In fact, all three of the models I'm playing with are undefined.
(js/console.log "Models:" #js {:List          model/List
                                 :ListedProduct model/ListedProduct
                                 :Product       model/Product})
That logs this in Firefox:
Models: 
{…}

List: undefined

ListedProduct: undefined

Product: undefined

<prototype>: Object { … }
grocer.cljs:272:48
#2020-10-0211:31jcfI'm fairly sure this is some dead code elimination/var renaming taking place during advance compilation.#2020-10-0211:34jcfI initially expected some property was being renamed, which is why Amplify wouldn't initialise the DataStore it provides, but given these vars resolve to nothing…#2020-10-0212:30thhelleryeah closure will rename this code. you can either create externs or access the names by string#2020-10-0212:31thhellersomething like https://github.com/applied-science/js-interop j/get-in or so#2020-10-0212:32thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2020-10-0212:32thhelleris quick too though#2020-10-0212:32thhellercould maybe even generate that automatically somehow#2020-10-0212:32jcfWouldn't model/Product get renamed consistently though?#2020-10-0212:33jcfI'm using js-interop in places, and I looked at adding simple externs.#2020-10-0212:33thhellerno because the JS file uses "Product" (as in a String)#2020-10-0212:34jcfSo I can't do something like this:
(ns foo
  (:require ["../models" :as models]))

(.subscribe DataStore models/Product)
#2020-10-0212:35thhellerhttps://developers.google.com/closure/compiler/docs/api-tutorial3#propnames#2020-10-0212:35jcfI'd need to do (.subscribe DataStore (j/get-in models :Product))?#2020-10-0212:35thhellerwith the simple externs you can do models/Product#2020-10-0212:36jcfIn externs/<build>.txt I need to add something like this?
# Fix Amplify's models being undefined :)
models/Product
#2020-10-0212:37thhellerjust Product#2020-10-0212:37jcfAwesome. I'll echo ... into a file and mint a release build now. :+1:#2020-10-0212:39jcf@U05224H0W I love you! That did it. 💥#2020-10-0212:39jcfThank you so much!#2020-10-0212:29thheller@ashnur node-test does not support a REPL. just use node-repl instead.#2020-10-0214:21Aronthere is no such target as node-repl#2020-10-0214:21AronI am even more confused now 🙂#2020-10-0214:24dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#node-repl#2020-10-0214:25Aronthanks, I found this, but I am not yet sure how to use it for the purpose I need the repl#2020-10-0214:26dpsuttonthat will start a repl, right? then you can develop and require your code as desired#2020-10-0214:27Aroni wish it were as simple#2020-10-0214:28AronI need to somehow connect it to my editor, right? because "no one actually types in the repl, who would do that" I saw this on twitter. And copy pasting lots of stuff is difficult anyway#2020-10-0214:29dpsuttonyeah most likely. CIDER can do this. what's your editor?#2020-10-0214:29Aronneovim/conjure#2020-10-0214:30dpsuttoni think if you put the nrepl options in the shadow config it will start up with that stuff and you should be able to connect as normal#2020-10-0214:30AronI usually have to do a ConjureConnect to the nrepl port and then ConjureShadowSelect to select the build/namespace I am connecting to. But this second part doesn't work#2020-10-0214:31AronIf I write ConjureShadowSelect it tells me that the watch for the build is not running. Which is not true, it's running, but it's a node-test build.#2020-10-0214:32AronSo, just to be clear, I don't think either tool is wrong in any way, I just don't know what I don't know that would connect it.#2020-10-0214:39thheller@ashnur I don't have a clue about the conjure parts. shadow-cljs node-repl will launch it as will (shadow.cljs.devtools.api/node-repl) (from CLJ)#2020-10-0214:39thhellerif ConjureShadowSelect asks for a build id that would be :node-repl (but it needs to be started elsewhere first#2020-10-0214:41AronBut what port?#2020-10-0214:41thhellerthe usual nrepl port#2020-10-0214:42thhellermaybe there is an option in conjure to start the node-repl directly. I don't know.#2020-10-0214:44Aronthe usual is already used by the actual build of the application running#2020-10-0214:46Aronok, I started the node repl, and tried to connect to 3334 port which seem to work, but if I try to evaluate the buffer, it just throws errors#2020-10-0214:46thhelleryou need to do the select thingy#2020-10-0214:47thhellerotherwise you are just in a clojure REPL#2020-10-0214:48Aronright, sorry, I did do that. I selected :node-repl as you said. The evaluation certainly works, I think I have a new problem now, not related to either conjure or shadow. Thanks#2020-10-0215:09OlicalYou may also want to use node-repl, not :node-repl when selecting#2020-10-0216:21scottloweI'm using an js-joda via an npm module and my target is :browser. Unfortunately the js-joda code contains calls to the ES2016 feature .includes function (on Array) instead of indexOf which fails in IE11. I've tried all sorts of shadow-cljs config combinations wtihout any luck, e.g. :js-options {:babel-preset-config {:targets {:ie 11}} or :compiler-options {:rewrite-polyfills true} which I believe only writes polyfills for ES6+ anyway.#2020-10-0216:21scottloweHas anybody managed to configure shadow-cljs such that an ES2016 feature is re-written or polyfilled for ES5 compatibility?#2020-10-0216:22thhellerthe output is supposed to be es5 assuming you didn't override :output-feature-set#2020-10-0216:23thhellerbut maybe it doesn't detect the .includes properly#2020-10-0216:23dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options (for reference)#2020-10-0216:23thhellerthere is :compiler-options {:force-library-injection #{"polyfill-name"}}#2020-10-0216:23thhellerdon't know the includes name though#2020-10-0216:25thhelleror just add the polyfill via external lib like https://polyfill.io/v3/#2020-10-0216:25scottloweThanks, both of you. I believe I've tried the correct :output-feature-set and other config options already, but I'll double check. Just to confirm, I don't need the babel-preset-config at all?#2020-10-0216:26scottloweI will probably fallback to adding the polyfill manually, I was just convinced that shadow-cljs would take care of it and found that idea attractive. Anyway, let me go away and check my config again. Perhaps some of the config options I've got in there are interfering with each other. Thanks#2020-10-0216:32scottloweHmm... no, I can't get it to work. Perhaps the includes call isn't being detected properly, as you say. For completeness, the offending lines in the third-party code are chained calls, so perhaps that makes it harder to detect https://github.com/js-joda/js-joda/blob/a1a635a7e4e506dfa7a9eedcc932571bdba9c1b2/packages/locale/src/format/cldr/CldrDateTimeTextProvider.js#L226#2020-10-0216:32scottloweAnyway, I will simply include the polyfills via that :force-library-injection config key for now. Thanks!#2020-10-0216:49scottloweThat worked 🙂 I also uncovered a call to Object.values. The final shadow-cljs config was :compiler-options {:force-library-injection ["es6/array/includes" "es6/object/values"]}#2020-10-0309:53Karol WójcikI got some issue while trying to setup https for development. For context I have isomorphic application which I'm porting to shadow. Browser bundle & statics are served from https://example.com and it works perfectly fine, but shadow websocket is unable to connect due to mixed content.
websocket.cljs:12 Mixed Content: The page at '' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ''. This request has been blocked; this endpoint must be available over WSS.
Any ideas how to overcome it?
#2020-10-0310:09victorbTry :devtools {:use-document-protocol true}#2020-10-0311:01Karol WójcikFixed it by including ssl in shadow!#2020-10-0312:36kimimHello, If I configured two modules, how can I watch both modules? Thanks.
{:app
    {:target :browser
     :output-dir "target/cljsbuild/public/js"
     :asset-path "/js"
     :modules {:app {:entries []}
               :login {:entries [vorstellung.login]}}}
#2020-10-0313:54lispers-anonymousGood morning. https://shadow-cljs.org/ seems to be having some troubles. Firefox is showing me this error.
Warning: Potential Security Risk Ahead

Firefox detected an issue and did not continue to . The website is either misconfigured or your computer clock is set to the wrong time.

It's likely the website's certificate is expired, which prevents Firefox from connecting securely. If you visit this site, attackers could try to steal information like your passwords, emails, or credit card details.
#2020-10-0314:05thheller@jiyinyiyong the SSL cert seems to have expired#2020-10-0318:27Karol WójcikAny ideas what causes it? It seems that adding the :modules {} broke the build.
base ❯ clj -A:dev:shadow-cljs release browser
[:browser] Compiling ...
npm package "react-transition-group" expected version "
#2020-10-0318:43Karol Wójcik@thheller I don't know whether it's common, but I experience about 400kb increase in bundle size when using multiple modules.#2020-10-0318:50thhellerthats not normal and not something I have ever seen#2020-10-0318:50thhellerthe above I also don't know#2020-10-0318:50thhellerwhich version is this?#2020-10-0318:51thhellerthe errors suggests its something wrong with your :modules setup and their :depends-on config#2020-10-0319:41Karol Wójcik@thheller Here is how :modules look like for increased build.#2020-10-0319:41Karol WójcikUsed version is: 2.11.4
{:browser-core                 {:entries    [core.browser]
                                                             :init-fn    core.browser/main}

                              ;; :view-checkout-payment-stage  {:entries    [view.checkout.payment-stage]
                              ;;                                :depends-on #{:browser-core}},
                              :view-ui-cms-tooltip          {:entries    [view.ui.cms-tooltip]
                                                             :depends-on #{:browser-core}}
                              ;; :view-checkout-delivery-stage {:entries    [view.checkout.delivery-stage]
                              ;;                                :depends-on #{:browser-core}}
                              :view-rich-content            {:entries    [view.rich-content]
                                                             :depends-on #{:browser-core}}
                              :view-debug-page              {:entries    [view.debug-page]
                                                             :depends-on #{:browser-core}}
                              :view-ui-hero                 {:entries    [view.ui.hero]
                                                             :depends-on #{:browser-core}}
                              :view-product-lists           {:entries    [view.product-lists]
                                                             :depends-on #{:browser-core}}
                              :view-about-pages             {:entries    [view.about-pages]
                                                             :depends-on #{:browser-core :view-reservation :view-vouchers}}
                              :view-sis                     {:entries    [view.sis]
                                                             :depends-on #{:browser-core :view-action-pages}}
                              :view-lps-pages               {:entries    [view.lps-pages]
                                                             :depends-on #{:browser-core}}
                              :view-help-forum              {:entries    [view.help-forum]
                                                             :depends-on #{:browser-core}}
                              :view-membership-gifts        {:entries    [view.membership.gifts]
                                                             :depends-on #{:browser-core :view-membership-common}}
                              :view-wines-factory           {:entries    [view.wines-factory]
                                                             :depends-on #{:browser-core}}
                              :view-newsletter              {:entries    [view.newsletter]
                                                             :depends-on #{:browser-core}}
                              :view-recipe                  {:entries    [view.recipe]
                                                             :depends-on #{:browser-core}}
                              :view-settings                {:entries    [view.settings]
                                                             :depends-on #{:browser-core :view-checkout-payment}}
                              :view-notification            {:entries    [view.notification]
                                                             :depends-on #{:browser-core}}
                              :view-cards                   {:entries    [view.cards]
                                                             :depends-on #{:browser-core}}
                              :view-action-pages            {:entries    [view.action-pages]
                                                             :depends-on #{:browser-core}}
                              :view-promo-pages             {:entries    [view.promo-pages]
                                                             :depends-on #{:browser-core}}
                              :view-office-page             {:entries    [view.office-page]
                                                             :depends-on #{:browser-core}}
                              :view-lp-affilation-page      {:entries    [view.lp.affilation-page]
                                                             :depends-on #{:browser-core}}
                              :view-new-brand-shop          {:entries    [view.new-brand-shop]
                                                             :depends-on #{:browser-core}}
                              :view-membership-common       {:entries    [view.membership.common]
                                                             :depends-on #{:browser-core}}
                              :view-reservation             {:entries    [view.reservation]
                                                             :depends-on #{:browser-core :view-vouchers}}
                              :view-membership-rebate       {:entries    [view.membership.rebate]
                                                             :depends-on #{:browser-core :view-product-lists :view-membership-common}}
                              :view-rodo                    {:entries    [view.rodo]
                                                             :depends-on #{:browser-core}}
                              :view-brand-shops             {:entries    [view.brand-shops]
                                                             :depends-on #{:browser-core}}
                              :view-brandbank               {:entries    [view.brandbank]
                                                             :depends-on #{:browser-core}}
                              :view-membership-banner       {:entries    [view.membership.banner]
                                                             :depends-on #{:browser-core :view-membership-common}}
                              :view-lp-membership           {:entries    [view.lp.membership]
                                                             :depends-on #{:browser-core :view-ui-hero :view-lps-pages :view-membership-common :view-membership-banner}}
                              :view-checkout                {:entries    [view.checkout]
                                                             :depends-on #{:browser-core :view-product-lists :view-settings}}
                              :view-importer                {:entries    [view.importer]
                                                             :depends-on #{:browser-core}}
                              :view-survey                  {:entries    [view.survey]
                                                             :depends-on #{:browser-core}}
                              ;; :view-lp-fruits-and-vegs      {:entries    [view.lp.fruits-and-vegs]
                              ;;                                :depends-on #{:browser-core}}
                              :view-cart                    {:entries    [view.cart]
                                                             :depends-on #{:browser-core :view-product-lists}}
                              :view-page-logged-in          {:entries    [view.page.logged-in]
                                                             :depends-on #{:browser-core}}
                              :view-checkout-payment        {:entries    [view.checkout.payment]
                                                             :depends-on #{:browser-core}}
                              :view-login                   {:entries    [view.login]
                                                             :depends-on #{:browser-core}}
                              ;; :view-checkout-products-stage {:entries    [view.checkout.products-stage]
                              ;;                                :depends-on #{:browser-core}}
                              :view-mailing                 {:entries    [view.mailing]
                                                             :depends-on #{:browser-core}}
                              :view-ui-video-player         {:entries    [view.ui.video-player]
                                                             :depends-on #{:browser-core}}
                              :view-cart-promotions         {:entries    [view.cart-promotions]
                                                             :depends-on #{:browser-core :view-vouchers}}
                              :view-shopping-lists          {:entries    [view.shopping-lists]
                                                             :depends-on #{:browser-core :view-product-lists}}
                              :view-products-product-page   {:entries    [view.products.product-page]
                                                             :depends-on #{:browser-core}}
                              :view-contest                 {:entries    [view.contest]
                                                             :depends-on #{:browser-core}}
                              :view-lp-ready-meals-page     {:entries    [view.lp.ready-meals-page]
                                                             :depends-on #{:browser-core :view-ui-hero :view-product-lists :view-lps-pages :view-settings :view-reservation :view-checkout :view-checkout-payment}}
                              :view-email-preview           {:entries    [view.email-preview]
                                                             :depends-on #{:browser-core}}
                              :view-lp-business-page        {:entries    [view.lp.business-page]
                                                             :depends-on #{:browser-core :view-ui-hero :view-rodo}}
                              :view-vouchers                {:entries    [view.vouchers]
                                                             :depends-on #{:browser-core}}}
#2020-10-0319:45Karol WójcikAnd that configuration was used which ended up with error: #2020-10-0319:45Karol Wójcik
{:browser-core                 {:entries    [core.browser]
                                                             :init-fn    core.browser/main}
                              :shared {:depends-on #{:browser-core}}

                              ;; :view-checkout-payment-stage  {:entries    [view.checkout.payment-stage]
                              ;;                                :depends-on #{:browser-core}},
                              :view-ui-cms-tooltip          {:entries    [view.ui.cms-tooltip]
                                                             :depends-on #{:shared}
                                                             }
                              ;; :view-checkout-delivery-stage {:entries    [view.checkout.delivery-stage]
                              ;;                                :depends-on #{:shared}}
                              :view-rich-content            {:entries    [view.rich-content]
                                                             :depends-on #{:shared}}
                              :view-debug-page              {:entries    [view.debug-page]
                                                             :depends-on #{:shared}}
                              :view-ui-hero                 {:entries    [view.ui.hero]
                                                             :depends-on #{:shared}}
                              :view-product-lists           {:entries    [view.product-lists]
                                                             :depends-on #{:shared}}
                              :view-about-pages             {:entries    [view.about-pages]
                                                             :depends-on #{:shared :view-reservation :view-vouchers}}
                              :view-sis                     {:entries    [view.sis]
                                                             :depends-on #{:shared :view-action-pages}}
                              :view-lps-pages               {:entries    [view.lps-pages]
                                                             :depends-on #{:shared}}
                              :view-help-forum              {:entries    [view.help-forum]
                                                             :depends-on #{:shared}}
                              :view-membership-gifts        {:entries    [view.membership.gifts]
                                                             :depends-on #{:shared :view-membership-common}}
                              :view-wines-factory           {:entries    [view.wines-factory]
                                                             :depends-on #{:shared}}
                              :view-newsletter              {:entries    [view.newsletter]
                                                             :depends-on #{:shared}}
                              :view-recipe                  {:entries    [view.recipe]
                                                             :depends-on #{:shared}}
                              :view-settings                {:entries    [view.settings]
                                                             :depends-on #{:shared :view-checkout-payment}}
                              :view-notification            {:entries    [view.notification]
                                                             :depends-on #{:shared}}
                              :view-cards                   {:entries    [view.cards]
                                                             :depends-on #{:shared}}
                              :view-action-pages            {:entries    [view.action-pages]
                                                             :depends-on #{:shared}}
                              :view-promo-pages             {:entries    [view.promo-pages]
                                                             :depends-on #{:shared}}
                              :view-office-page             {:entries    [view.office-page]
                                                             :depends-on #{:shared}}
                              :view-lp-affilation-page      {:entries    [view.lp.affilation-page]
                                                             :depends-on #{:shared}}
                              :view-new-brand-shop          {:entries    [view.new-brand-shop]
                                                             :depends-on #{:shared}}
                              :view-membership-common       {:entries    [view.membership.common]
                                                             :depends-on #{:shared}}
                              :view-reservation             {:entries    [view.reservation]
                                                             :depends-on #{:shared :view-vouchers}}
                              :view-membership-rebate       {:entries    [view.membership.rebate]
                                                             :depends-on #{:shared :view-product-lists :view-membership-common}}
                              :view-rodo                    {:entries    [view.rodo]
                                                             :depends-on #{:shared}}
                              :view-brand-shops             {:entries    [view.brand-shops]
                                                             :depends-on #{:shared}}
                              :view-brandbank               {:entries    [view.brandbank]
                                                             :depends-on #{:shared}}
                              :view-membership-banner       {:entries    [view.membership.banner]
                                                             :depends-on #{:shared :view-membership-common}}
                              :view-lp-membership           {:entries    [view.lp.membership]
                                                             :depends-on #{:shared :view-ui-hero :view-lps-pages :view-membership-common :view-membership-banner}}
                              :view-checkout                {:entries    [view.checkout]
                                                             :depends-on #{:shared :view-product-lists :view-settings}}
                              :view-importer                {:entries    [view.importer]
                                                             :depends-on #{:shared}}
                              :view-survey                  {:entries    [view.survey]
                                                             :depends-on #{:shared}}
                              ;; :view-lp-fruits-and-vegs      {:entries    [view.lp.fruits-and-vegs]
                              ;;                                :depends-on #{:shared}}
                              :view-cart                    {:entries    [view.cart]
                                                             :depends-on #{:shared :view-product-lists}}
                              :view-page-logged-in          {:entries    [view.page.logged-in]
                                                             :depends-on #{:shared}}
                              :view-checkout-payment        {:entries    [view.checkout.payment]
                                                             :depends-on #{:shared}}
                              :view-login                   {:entries    [view.login]
                                                             :depends-on #{:shared}}
                              ;; :view-checkout-products-stage {:entries    [view.checkout.products-stage]
                              ;;                                :depends-on #{:browser-core}}
                              :view-mailing                 {:entries    [view.mailing]
                                                             :depends-on #{:browser-core}}
                              :view-ui-video-player         {:entries    [view.ui.video-player]
                                                             :depends-on #{:browser-core}}
                              :view-cart-promotions         {:entries    [view.cart-promotions]
                                                             :depends-on #{:browser-core :view-vouchers}}
                              :view-shopping-lists          {:entries    [view.shopping-lists]
                                                             :depends-on #{:browser-core :view-product-lists}}
                              :view-products-product-page   {:entries    [view.products.product-page]
                                                             :depends-on #{:browser-core}}
                              :view-contest                 {:entries    [view.contest]
                                                             :depends-on #{:browser-core}}
                              :view-lp-ready-meals-page     {:entries    [view.lp.ready-meals-page]
                                                             :depends-on #{:browser-core :view-ui-hero :view-product-lists :view-lps-pages :view-settings :view-reservation :view-checkout :view-checkout-payment}}
                              :view-email-preview           {:entries    [view.email-preview]
                                                             :depends-on #{:browser-core}}
                              :view-lp-business-page        {:entries    [view.lp.business-page]
                                                             :depends-on #{:browser-core :view-ui-hero :view-rodo}}
                              :view-vouchers                {:entries    [view.vouchers]
                                                             :depends-on #{:browser-core}}}
#2020-10-0319:59thhelleryikes. splits like that are completely pointless#2020-10-0320:00thhellerwell not completely but very unlikely to be optimal#2020-10-0320:01thhellerdon't you get a bazillion really small files and then a couple really large ones?#2020-10-0320:16thhellertotally possible that something in the system breaks with this many modules. never seen this many before 😛#2020-10-0320:45Karol WójcikWell actually this is what I get.#2020-10-0321:20Karol WójcikActually even if I split to two modules I can see about 200kb increase in build size.#2020-10-0321:23Karol WójcikWhat is $APP?#2020-10-0322:08thhellerthe only global variable so modules can access shared code#2020-10-0322:09thhellerwhat does the build report look like? where are the 200kb coming from?#2020-10-0318:38jplaza👋 I’m getting a
Cannot infer target type in expression (. (. BigJSHandler -prototype) -rep)
For this deftype
(deftype BigJSHandler []
  Object
  (tag [this v] "bigjs")
  (rep [this ^js/Big v] (.toFixed v))
  (stringRep [this v] nil))
#2020-10-0318:39jplazaI think extern inference is not working as expected, maybe I have to provide an externs file?#2020-10-0318:52thheller@jplaza yeah I don't know what that is about. I thing (deftype ^js BigJSHandler ...) fixes it. otherwise you can also set (set! *warn-on-infer* false) before and true after to silence it for now#2020-10-0318:57jplazaThanks @thheller ! ^js worked perfectly. Also this externs worked too
var Object = function() {};
Object.prototype.tag = function() {};
Object.prototype.rep = function() {};
Object.prototype.stringRep = function() {};
#2020-10-0319:08thhelleryeah but you don't actually want externs for this#2020-10-0319:08thhellerit is fine if it gets renamed#2020-10-0319:09thhellerbut it is fine. it is just some kind of regression. don't yet know why the warning is back.#2020-10-0400:06Mr. SavyI downloaded the fulcro template to play around with, but I'm getting an net::ERR_CONNECTION_REFUSED whenever I start the server. Has anyone encountered this error before with shadow-cljs? I ask here because the terminal spat out an error that pointed to some shadow-cljs code.#2020-10-0400:09Mr. SavyThe namespace is shadow.cljs.devtools.client.websocket line 12. Still looking into it though. It seems like anything could cause this which is worrisome.#2020-10-0400:59Mr. Savylooking at some of the issues in the github, something with websocket I guess.#2020-10-0404:35Mr. Savyredownloading the template caused it to go away. I have no idea why.#2020-10-0410:38victorbIs there any way I can inline the compiled output into the HTML file? Something like HtmlWebpackInlineSourcePlugin but for shadow-cljs#2020-10-0410:51victorbanother question, is there a target for generalized JS environment? The context I'm trying to run in is not a browser environment (no access to browser APIs) nor nodejs (so can't use dirname and other nodejs specific things). The environment is a sandboxed browser environment with ES6, with removed browser APIs#2020-10-0411:21victorbmore questions, slightly related. There is bunch of extra (undocumented) targets in https://github.com/thheller/shadow-cljs/tree/b05b8f41afd45564ef7b9831a07201d09a5c4a07/src/main/shadow/build/targets, can I use them from the shadow-cljs npm module somehow? I'm not able to figure out how...#2020-10-0413:26thheller@victorbjelkholm429 there is nothing to do the inline the output into html. you could just to it in an extra step after compilation thought. need more information before I can comment on the target thing. Maybe :target :esm does what you need in release mode or any of the node stuff. just don't expect watch or compile to work. release output might work.#2020-10-0413:30victorbInteresting, I'll take a look at the :esm target, thanks! For now, watch/compile for that is not super important, can work around that for now.#2020-10-0413:33victorbfor the record, here is where I'm trying to get it to run: https://www.figma.com/plugin-docs/how-plugins-run/ Basically has two different contexts. One "UI" that has access to all the browser APIs but cannot load JS sources via script tags, everything has to be inlined. The other one "code" (basically background) that has no access to browser APIs but custom ones like the figma one. Currently I got the UI one working fine by having shadow-cljs output a npm-module that I'm including in a "vanilla JS" file, then webpack packs it + index.html into a single file with the JS embedded. Having harder time getting the "code" context to work, as output from shadow-cljs (cljs-compiler maybe?) is either assuming it's in a browser OR nodejs context while in "code" context, neither global, process nor window is available#2020-10-0413:35thheller:target :browser may work too, but again just in release#2020-10-0413:35thhellerin compile or watch it will definitely try to access all of those#2020-10-0413:35victorbHm, I'll give release a try, didn't try it before with the :browser target. Thanks for the guidance!#2020-10-0509:02victorbManaged to get it to work by using a combination of compile for the "Figma UI target" and release for the "Figma background target", and using the :browser target for both. Thanks for the help!#2020-10-0509:03thhellerthe :ui-dev build you do not need#2020-10-0509:04thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-10-0509:05thhelleror I guess the :ui build is old since its still :npm-module?#2020-10-0509:05victorb@U05224H0W I do 🙂 I have two different environments, one where I simulate the Figma environment in the browser#2020-10-0509:05victorbhas to be a npm module as after shadow-cljs I pass it to webpack to inline UI into the index.html (needed for Figma...)#2020-10-0509:06victorbit's a bit tricky and messy, but it works at least. Basically I shim the APIs that Figma provide in the plugin context, if FIGMA is false. So I can develop most of it in browser, and then only test integration in figma itself#2020-10-0509:12thhellerwell there could be a :target :figma-plugin or so that takes care of some of the messiness#2020-10-0509:12thhellerbut I don't have time to look into that currently#2020-10-0509:23victorb@U05224H0W don't worry about it, thanks for the guiding so far. I think it's a pretty small intersection of people who write clojure and writes Figma plugins 😄 I might open source the wrapper I'm using, to help others, and if that sees any interest, I could think about contributing a :figma-plugin target#2020-10-0413:27thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2020-10-0421:44xfyreIs there a way to make React Native hot reload feature work? Somehow Metro bundler reloads the whole bundle after recompilation#2020-10-0422:02thhellerdisable it completely and let shadow-cljs handle the reload#2020-10-0422:26xfyre@U05224H0W thanks for the pointer! It works much better (the currently active screen doesn’t refresh though)#2020-10-0422:35thhelleryou must set up the re-rendering properly#2020-10-0422:35thhellerso if nothing refreshes you likely have done something that breaks that or not done it at all#2020-10-0422:35thhelleryou can use the helper I added for this https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L36#2020-10-0422:37xfyregot it, thank you!#2020-10-0502:23xfyreso now I have
(defn dev-render-root {:dev/after-load true} []
  (shadow/render-root "DcnetApp" (r/as-element [app-root]))
  )
it’s called after I update the code, as expected
[Sun Oct 04 2020 19:17:50.501]  LOG      load JS dcnet_app/screens/home.cljs
[Sun Oct 04 2020 19:17:50.507]  LOG      load JS dcnet_app/appnav.cljs
[Sun Oct 04 2020 19:17:50.508]  LOG      call dcnet-app.ios.core/dev-render-root
but the screen doesn’t get updated. anything else I might be missing?
#2020-10-0503:02xfyreI think something’s off with the bundler. I tried two other methods (directly calling .forceUpdate and updating ratom within the root component). It does trigger re-rendering, but still displays old version of the code. I’ll let you know if I figure it out.#2020-10-0508:57thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-10-0508:57thhellercheck the "things to avoid" and "hooking up react"#2020-10-0516:48xfyreI think I finally made it work, thanks a lot for your help!#2020-10-0422:02thhellerotherwise no clue#2020-10-0422:11GalagoraHi. I have a CommonJS module in src/add.js (`module.exports = add`) and this CLJS code in src/habit/core.cljs:
(ns habit.core
  (:require [moment]
            ["/add" :as add]
            ))

(println (add 1 2))
(defn main []
  (println "hi"))
With this shadow-cljs.edn:
{:source-paths
 ["src/"]

 :dependencies
 []

 :builds
 {:m
  {:target :node-script
   :main habit.core/main
   :output-to "out/core.js"
   }}}
I then run sc cljs-repl m and node out/core.js which outputs "3" and "hi". However, in the repl, I get this error when trying to access add : #object[ReferenceError ReferenceError: module$add is not defined] . I can access moment fine. What am I doing wrong?
#2020-10-0422:22thheller@lightningstrikeiv which version?#2020-10-0422:23Galagora2.11.4#2020-10-0422:27GalagoraShould I try an earlier one?#2020-10-0422:31Galagora@U05224H0W#2020-10-0422:33thhellerno. just ruling out that you are on old versions 😛#2020-10-0422:34thhellermight just be a bug in the node-repl. don't really know. not something alot of people do#2020-10-0500:10GalagoraOK, so FWIW, I put the same minimal reproducible example up https://github.com/galagora/clonode. I couldn't get Figwheel to work either. I guess I'll just have to use something with better Node.js support, https://www.tweag.io/blog/2019-05-09-inline-js/ 😉#2020-10-0501:16devnClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named I keep getting these on shadow-cljs watch#2020-10-0501:16devnit stems from some business in shadow around cljs_hacks#2020-10-0501:19devn
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
        clojure.core/namespace (core.clj:1597)
        clojure.core/namespace (core.clj:1597)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:155)
        shadow.build.cljs-hacks/shadow-resolve-var (cljs_hacks.cljc:147)
        cljs.analyzer/resolve-existing-var (analyzer.cljc:1276)
        cljs.analyzer/resolve-existing-var (analyzer.cljc:1271)
        cljs.compiler/fn--9175 (cljs_hacks.cljc:740)
        cljs.compiler/fn--9175 (cljs_hacks.cljc:717)
#2020-10-0501:19devnIt doesn’t happen every time.#2020-10-0507:15rbergerAnyone familiar with being able to use https://shoelace.style/getting-started/installation in a shadow-cljs project? I can’t seem to just simply require components even though its shipped as an npm package. Do I need to do some webpack thing first? (their installation docs seem to imply that). Or is there some special path I need to use?#2020-10-0507:19rbergerI have tried (:require ["@shoelace-style/shoelace" :refer [SlButton]]) and (:requre ["@shoelace-style/shoelace" :as sl]) and I end up with nil for SlButton or sl/SlButton#2020-10-0509:00thheller@devn do you maybe use shadow-cljs embedded in some CLJ app in combination with some kind of classloader magic or tools.namespace?#2020-10-0519:25devnI don’t think that’s my situation, but either way, do you have any suggestions for catching what’s actually happening here?#2020-10-0520:11thhellernot a clue#2020-10-0522:21thhellerit is extremely unlikely that this is actually a shadow-cljs problem#2020-10-0522:21thhellerthis is deep inside the clojure core code#2020-10-0522:21thhellerso it is much more likely something goin on in your JVM that shouldn't be#2020-10-0522:22thhellerhow are you running things?#2020-10-0522:24thhellerif you are connected over nREPL it might be the nREPL doing stuff#2020-10-0523:51devn@U05224H0W it’s not always inside the clojure core code. I wish I could get a smaller way to reproduce, but: The project has 3 primary source directories: “shared” (cljc code) “src” (clojure code) “ui-src” (clojurescript code) There is a project.clj which specifies all 3 of these source paths in its source-paths key. This project.clj requires the latest version of clojurescript. In addition, there is a package.json and a shadow-cljs.edn. The shadow-cljs.edn has 3 builds in it, all of which are specified with :entries [the.ns]#2020-10-0523:52devnThe shadow watch is run with npx — shadowcljs 2.11.4 is specified in the package.json#2020-10-0600:19devnUgh. I am very embarrassed.#2020-10-0600:19devnI accidentally IBM’s J9 OpenJDK, not the HotSpot version of AdoptOpenJDK#2020-10-0509:01thheller@rberger read https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages about the default exports. I don't know for this case but it might be (:requre ["@shoelace-style/shoelace" :default SLButton])#2020-10-0519:17rberger@U05224H0W I was able to get it to import with:
(:require ["@shoelace-style/shoelace/dist/custom-elements/index.js" :refer [defineCustomElements setAssetPath SlButton]])
It ends up with an html custom element (web component) now I still have to figure out how to access the element after doing:
(.define js/customElements "sl-button" SlButton)
SlButton is defined as a class, but sl-button is not defined. I probably just need to learn more how web components work with reagent.
#2020-10-0520:10thhellerah if its web components you just do [:sl-button ...] like any other regular dom element#2020-10-0520:11thhellerthats why the :refer and stuff may not actually exist because you don't need it if it already self-registers#2020-10-0520:17rbergerOh, I didn’t try with the : Now that I try that, it does inject <sl-button>… into the DOM now, but I’m getting a
Uncaught ReferenceError: regeneratorRuntime is not defined
index.js:2654 Uncaught ReferenceError: regeneratorRuntime is not defined
    at initializeComponent (index.js:2654)
    at _connectedCallback (index.js:2944)
    at HTMLElement.connectedCallback (index.js:3049)
    at commitPlacement (react-dom.development.js:8835)
    at commitAllHostEffects (react-dom.development.js:18656)
    at HTMLUnknownElement.callCallback (react-dom.development.js:150)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:200)
    at invokeGuardedCallback (react-dom.development.js:257)
    at commitRoot (react-dom.development.js:18914)
    at eval (react-dom.development.js:20419)
But at least that is something I can track down now hopefully. Thanks again for your help! Oh, I didn’t try with the
#2020-10-0520:23thhellerthat likely means you are including transpiled code from babel#2020-10-0520:25thhellerI think a require for regenerator-runtime might be enough#2020-10-0522:23thheller(:require ["regenerator-runtime"]) should do it in case you didn't try .. you said "refer" which would be incorrect#2020-10-0522:23thheller(maybe npm install regenerator-runtime first of course)#2020-10-0522:23thhellerbut the script tag is fine too I guess#2020-10-0522:25rbergerYep, (:require ["regenerator-runtime"])`` works great. Preferred to <script> tag Thanks again!#2020-10-0509:01thhellerbut from the package name I gather its about CSS which shadow-cljs does not handle. so it might be webpack only?#2020-10-0509:04victorbIs there any built-in way of combining watch and release? Basically just want a way of running release every time the files change. watch will call compile on file change, as I understand it, so if there is a way of getting it to run release instead?#2020-10-0514:09localshrednot native to shadow in particular, but if you use watchman-make you can do anything you want after files are changed e.g. watchman-make -p './src/***/**.cljs' -t release https://facebook.github.io/watchman/docs/watchman-make.html#2020-10-0514:10localshred(where release would be a target in your Makefile to run shadow-cljs release {target} )#2020-10-0516:11victorbThanks @U5RFD1733, I opted for the inotifywait route as I already had that installed and didn't need to download anything new 🙂#2020-10-0516:30localshredoh for sure, there's a billion watchers out there. yay unix :)#2020-10-0509:05thhellerno#2020-10-0614:50jhacksIs there a config setting in shadow-cljs for preventing hot reloading of code when there is a compilation error? I was watching this figwheel presentation https://youtu.be/j-kj2qwJa_E?t=1164 (linked to time in video) where Bruce Hauman shows figwheel not loading the code after a compilation error. I didn’t see anything in the shadow-cljs guide that directly mentions this (although I could have missed it), but at the end of this article: https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html Thomas writes: > Note that an exception during the load of a namespace process may break hot-reload entirely. Avoid running code as much as possible and instead use the `^:dev/after-load` hooks when needed. Maybe that’s the intended way to deal with compilation errors in shadow-cljs?#2020-10-0615:08victorbThere is an *:ignore-warnings`*` option in shadow-cljs that defaults to false. shadow-cljs should already avoid compiling when there is warnings, but you can set :ignore-warnings to true to compile anyways (which might lead to breakage). I know you mentioned compilation errors, but I do think Bruce talks about compilation warnings, not errors#2020-10-0615:18jhacksAhh, thanks @UEJ5FMR6K! Also, you’re absolutely right, in the video Bruce talks about warnings, not errors. Sorry for the mixup.#2020-10-0618:41souenzzoThere is some shadow-cljs tools that acts like warn-on-reflection ? I mean, to be "super safe" about to access .-props#2020-10-0619:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs should be all you need#2020-10-0619:16thhellerno such thing as "reflection" in JS#2020-10-0709:54jahsonHi! Is there any documentation / articles about usage of :js-options {:babel-preset-config { ... }}? I'm trying to enable polyfills for IE11.#2020-10-0710:03thhellerthis only affects npm packages that are actually transpiled by babel. which is only a very small percentage. so much so that this option is mostly useless.#2020-10-0710:04thhellerwhat kind of polyfills is it not detecting already? this is usually controlled by setting :compiler-options {:output-feature-set :es5} (which is the default)#2020-10-0710:04thhelleryou can try :es3#2020-10-0710:33jahsonOh, I see. Looks like I should be using :compiler-options, instead of :babel-preset-config, because my project probably don't have such npm packages. Thanks for your answer, I'll try it.#2020-10-0710:39thhelleralso note that watch/compile builds may not work in IE11 regardless of polyfill status#2020-10-0710:39thhellerbest to test that with release only#2020-10-0711:31jahsonGot it, thanks!#2020-10-0716:52jcfHello, everyone! I'm having a go at spinning up a Lambda function with Clojurescript via Shadow CLJS, and I'm running into a strange error that returns three results via Google. 🙂
$ yarn run shadow-cljs compile lambda --verbose
shadow-cljs - config: /home/jcf/code/example/shadow-cljs.edn
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
[:lambda] Compiling ...
-> build target: :node-library stage: :configure
<- build target: :node-library stage: :configure (3 ms)
-> Resolving Module: :main
With both release and compile I get this error after the output above:
The required namespace "example.lambda" is not available, it was required by "shadow/umd_helper.cljs".
I've found a GitHub issue related to generating single files, with a recommendation to use ncc to package everything into a single file, which I can do as soon as I have something compiling. My build looks like this:
{:builds
 {:lambda
  {:deps             {:aliases [:lambda]}
   :output-to        "amplify/backend/function/example/src/index.js"
   :target           :node-library
   :exports          {:handler example.lambda/handler}
   :devtools         {:enabled false}
   :compiler-options {:infer-externs :auto
                      :source-map    true}}}}
I've triple checked the namespace and path to my namespace and it's very correct (I've copied and pasted the name back and forth to be doubly sure).
#2020-10-0716:52jcfHello, everyone! I'm having a go at spinning up a Lambda function with Clojurescript via Shadow CLJS, and I'm running into a strange error that returns three results via Google. 🙂
$ yarn run shadow-cljs compile lambda --verbose
shadow-cljs - config: /home/jcf/code/example/shadow-cljs.edn
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
[:lambda] Compiling ...
-> build target: :node-library stage: :configure
<- build target: :node-library stage: :configure (3 ms)
-> Resolving Module: :main
With both release and compile I get this error after the output above:
The required namespace "example.lambda" is not available, it was required by "shadow/umd_helper.cljs".
I've found a GitHub issue related to generating single files, with a recommendation to use ncc to package everything into a single file, which I can do as soon as I have something compiling. My build looks like this:
{:builds
 {:lambda
  {:deps             {:aliases [:lambda]}
   :output-to        "amplify/backend/function/example/src/index.js"
   :target           :node-library
   :exports          {:handler example.lambda/handler}
   :devtools         {:enabled false}
   :compiler-options {:infer-externs :auto
                      :source-map    true}}}}
I've triple checked the namespace and path to my namespace and it's very correct (I've copied and pasted the name back and forth to be doubly sure).
#2020-10-0716:53jcfIn my deps.edn I have an alias that sets :paths ["src"]#2020-10-0716:53jcfIf anyone has a working example of generating a :node-library that I can package up with ncc I'd be extremely grateful.#2020-10-0716:53jcfDefinitely scratching my head on this one. 🤔#2020-10-0717:01jcfhttps://github.com/thheller/shadow-cljs/issues/418#2020-10-0717:01jcfhttps://github.com/vercel/ncc#2020-10-0717:02jcfRelevant links above, with two archived Slack convos coming right up…#2020-10-0717:02jcfhttps://clojurians-log.clojureverse.org/shadow-cljs/2018-06-26#2020-10-0717:02jcfhttps://clojurians-log.clojureverse.org/clojurescript/2020-09-04#2020-10-0717:16jcfI think tomorrow I might create a little repo to see if I can reproduce outside of my codebase. If so, I can open a decent issue on GitHub.#2020-10-0718:00Mandimby RaveloarinjakaHello, for my information, why do you build a "node-library" and not a "node-script" or "esm" (https://clojureverse.org/t/generating-es-modules-browser-deno/6116)? Moreover, shadow-cljs will generate one js file: why do you need ncc for?#2020-10-0719:14jcf@U805L34UX see this GitHub issue and its conclusion: https://github.com/thheller/shadow-cljs/issues/290#issuecomment-539087352#2020-10-0720:34Mandimby Raveloarinjakaindeed I just did a small test. The target "node-lib" needs the node_modules to be bundled with the js; The target "esm" bundles everything in one js natively. However, the version of node on lambda is node 12 that does not support esm without the flag "--experimental-modules" (http://2ality.com/2019/04/nodejs-esm-impl.html#using-es-modules-on-nodejs)#2020-10-0720:12thheller@jcf the file is supposed to be /home/jcf/code/example/src/example/lambda.cljs. make sure it actually exists. the :deps inside :builds is incorrect. it is supposed to be at the top level#2020-10-0720:12thheller@jcf the file is supposed to be /home/jcf/code/example/src/example/lambda.cljs. make sure it actually exists. the :deps inside :builds is incorrect. it is supposed to be at the top level#2020-10-0721:42jcfI wasn’t sure if :deps could be nested. I want to use different dependencies for different builds, and went for :aliases#2020-10-0721:46thhellerthis is not supported and also usually quite useless. see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2020-10-0721:54jcfIs that post related to isolating dependencies declared using tools.deps’ :deps or is it to do with source paths (e.g. src/cljs)? I was trying to include a different set of third-party dependencies (my Lambda doesn’t need Rum) and have all my Clojure-like source collocated.#2020-10-0721:58jcfI’ll have a proper read in the morning to make sure I’m understanding it. Thanks, thheller! You’re work as always is appreciated. 🙇#2020-10-0807:45thhellerit doesn't matter if you have rum on the classpath or not for other code#2020-10-0807:45thhellerif it isn't explicitely required in any of your code it won't be used#2020-10-0807:46thhellerso the lambda isn't affected at all whether its on the classpath or not#2020-10-0720:12thhellercan't see your :paths though#2020-10-0720:12thhellerassuming :paths ["src"] in deps.edn is set correctly#2020-10-0721:44jcfI think I’ve done all of the above, but will double check after a good night’s rest. Thanks, thheller. 🙇#2020-10-0723:59kennytiltonIs there an issue with shadow and macros, perhaps in the context of .cljc? I define…
(defmacro deftags [& tags]
  `(do 
…in one NS, require it in another,
(ns mxweb.tag
  (:require
    [mxweb.gen :as gen]))

(gen/deftags a abbr acronym ...etc..)
…then a check reports
------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: mxweb/tag.cljc:5:2
 Use of undeclared Var mxweb.gen/deftags
A conventional CLJS build using the lein meis scripts works OK. Thx!
#2020-10-0807:03Karol WójcikDid you include require-macros :refer [deftags] in cljc file?#2020-10-0807:44thheller@U0PUGPSFR https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html most likely your are missing the :require-macros in the mxweb.gen ns for itself#2020-10-0808:54kennytilton@UJ1339K2B I started with :require-macros in the using mxweb.tag NS and was seeing the same error. Thx to @U05224H0W’s blog post I see the linkage is a bit hairier than I realized and will give it another go. btw, I had everything in .cljcs, and will start by moving macros into a .clj just to reduce the unknowns.#2020-10-0810:26Karol WójcikYou should have put it in mxweb.gen#2020-10-0815:07kennytiltonYeah, that was the shocker I picked up from @U05224H0W’s blog. I did all this years ago using the mies scripts. That worked OK, but I am curious about Shadow. One puzzle is that I do not have the macros in a .clj, which I do remember as a requirement! I guess the .cljc gives me the .clj compile for the macros? Anyway, I plan to KISS and move the macros into a .clj, then set things up as you have described. Thx!#2020-10-0815:20thheller.cljc as far as CLJS macros are concerned are just two files in one. one for CLJ one for CLJS. the macro rules are exactly the same but IMHO it is much easier to follow those rules with two actual files instead of one#2020-10-0815:41kennytiltonYeah, I am splitting them up now. This will be a challenge for any tooling, tho: deftag generates a macro. 🙂 Results shortly…#2020-10-0816:52kennytiltonWorks like a charm. Thx @UJ1339K2B and @U05224H0W!#2020-10-0804:08ianchowHi, not sure if this is a shadow-cljs specific question but... I'm trying to use a js library https://github.com/tambien/Piano but am getting the error message
TypeError: Class constructor _o cannot be invoked without 'new'

(ns myapp.core
  (:require ["@tonejs/piano" :refer (Piano)]))
(Piano.)
I had set :compiler-options :output-feature-set to :es6 with no luck. Any help appreciated. Thanks.
#2020-10-0807:03Karol WójcikWhich shadow-cljs version?#2020-10-0807:28ianchow2.11.4 Other npm packages seem to work fine.#2020-10-0808:11thheller@ianchow hard to say without full stacktrace. looks like it is something internal in the lib. not something you are actually calling from CLJS.#2020-10-0809:02ianchowAh.. ok. Looks like I have to do more digging. Thanks.#2020-10-0811:09Karol WójcikHow can I include refactor-nrepl in shadow-cljs?#2020-10-0811:28thhellersame as everywhere else I presume#2020-10-0811:31Karol Wójcik😄 Ok got it working!#2020-10-0811:32Karol WójcikLast question though. What should I do to access that function? shadow.loader.load_many#2020-10-0811:32Karol WójcikI'm getting: Uncaught TypeError: shadow.loader.load_many is not a function#2020-10-0811:33Karol WójcikModule loader has been added to build: :module-loader true#2020-10-0811:46Karol WójcikAhh ok. It should load-multiple.#2020-10-0816:22jacklombardHello I am trying to connect my chrome extension to the REPL. I can’t connect to that run time and this is the error I get in the websockets tab ["^ ","~:op","~:access-denied"] . Any help would be appreciated.#2020-10-0816:23jacklombardI am using binaryage/chromex and I have connected to the nrepl server and then I’ve done the (shadow/repl :extension) step where extension is the name of the build.#2020-10-0816:45jacklombardNevermind I was able to resolve this#2020-10-0819:12jahsonTried :es3, still no luck. IE throws exception about Object.assign.#2020-10-0819:17thheller@jahson you could include the polyfill externally via https://polyfill.io/v3/#2020-10-0819:18thhelleror :compiler-options {:force-library-injection ["es6/object/assign"]}#2020-10-0819:18jahsonYeah, but https://polyfill.io is not an option for me 🙂 Probably I will go with direct require / injection.#2020-10-0819:20Karol Wójcik@jahson you know that you can download full polyfill bundle?#2020-10-0819:25jahson@thheller Thank you for your help anyway.#2020-10-0819:25jahson@karol.wojcik Yeah, I've done polyfills many times in JS, just never did with ClojureScript.#2020-10-0819:28jahsonJust wanted to make it more elegant 😉#2020-10-0908:50Karol WójcikHow this feature is called where you can tell shadow-cljs to resolve ns XYZ instead of ABC. I cannot find it 😞#2020-10-0909:28thheller@karol.wojcik :build-options {:ns-aliases {from to}}#2020-10-1008:47Andrei StanHello, guys! I just started learning clojure/clojurescript and i am trying to use re-com (https://github.com/day8/re-com) in my app built with shadow-cljs. When compiling, i receive an error :
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.110 running at 
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /home/nas/proiecte/homebank-ofx/src/main/netdava/homebank/app/hello.cljs
no source by provide: recom.core
{:provide recom.core}
ExceptionInfo: no source by provide: recom.core
        shadow.build.data/get-source-id-by-provide (data.clj:186)
        shadow.build.data/get-source-id-by-provide (data.clj:183)
        shadow.build.data/get-source-by-provide (data.clj:189)
        shadow.build.data/get-source-by-provide (data.clj:188)
        shadow.build.compiler/fn--11892 (compiler.clj:340)
        shadow.build.compiler/fn--11892 (compiler.clj:322)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.build.compiler/do-compile-cljs-resource/fn--11967/fn--11976 (compiler.clj:623)
        shadow.build.compiler/do-compile-cljs-resource/fn--11967 (compiler.clj:618)
        shadow.build.compiler/do-compile-cljs-resource (compiler.clj:562)
        shadow.build.compiler/do-compile-cljs-resource (compiler.clj:520)
        shadow.build.compiler/maybe-compile-cljs/fn--12065 (compiler.clj:897)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:896)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:872)
        shadow.build.compiler/par-compile-one (compiler.clj:1005)
        shadow.build.compiler/par-compile-one (compiler.clj:960)
        shadow.build.compiler/par-compile-cljs-sources/fn--12101/iter--12123--12127/fn--12128/fn--12129/fn--12130 (compiler.clj:1078)
        clojure.core/apply (core.clj:665)
        clojure.core/with-bindings* (core.clj:1973)
        clojure.core/with-bindings* (core.clj:1973)
        clojure.core/apply (core.clj:669)
        clojure.core/bound-fn*/fn--5749 (core.clj:2003)
        java.util.concurrent.FutureTask.run (FutureTask.java:264)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
        java.lang.Thread.run (Thread.java:834)
Here is my shadow-cljs.edn:
{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn netdava.homebank.app.core/main}}
        :output-dir "public/js"
        :target :browser}
  :csv2json {:target :node-library
             :output-to "csv2json.js"
             :output-dir "out/csv2json-lib"
             :exports-fn netdava.homebank.csv/generate-exports}
  :parse-demo {:target :node-script
               :main netdava.homebank.csv-demo/main
               :output-to "out/parse-demo.js"}
  :dir-converter {:target :node-script
               :main netdava.homebank.dir-converter/main
               :output-to "out/dir-converter.js"}
  :test {:ns-regexp "-nodetest$"
         :output-to "out/test.js"
         :target :node-test
         :compiler-options {:infer-externs :auto}}
  :ci {:target :karma
       :output-to "out/ci.js"
       :ns-regexp "-test$"}}
 :dependencies [[bux "0.3.0"]
                [devcards "0.2.6"]
                [re-com "2.9.0"]
                [reagent "0.8.1"]]
 :dev-http {3000 "public"}
 :nrepl {:port 3333}
 :source-paths ["src/main" "src/csv2json" "src/test"]}
thanks in advance.
#2020-10-1009:22thheller@andrei.stan the ns is re-com.core not recom.core?#2020-10-1009:23thhelleralso .. upgrade. you are on an old version.#2020-10-1012:46Andrei Stanhi, what exactly should i upgrade?#2020-10-1012:51thhellershadow-cljs#2020-10-1105:58Andrei Stani have upgraded, build is ok, it still doesn't work. the build is ok, but i receive errors in browser console:#2020-10-1105:59Andrei Stan
component.cljs:127 Error rendering component (in netdava.homebank.app.hello.converter >  >  >  > re_com.buttons.button)
reagent$impl$component$do_render	@	component.cljs:127
eval	@	component.cljs:143
reagent$ratom$in_context	@	ratom.cljs:37
reagent$ratom$deref_capture	@	ratom.cljs:43
reagent$ratom$run_in_reaction	@	ratom.cljs:504
netdava.homebank.app.hello.convert_btn_render	@	component.cljs:143
finishClassComponent	@	react-dom.development.js:14742
updateClassComponent	@	react-dom.development.js:14697
beginWork	@	react-dom.development.js:15645
performUnitOfWork	@	react-dom.development.js:19313
workLoop	@	react-dom.development.js:19353
callCallback	@	react-dom.development.js:150
invokeGuardedCallbackImpl	@	react-dom.development.js:200
invokeGuardedCallback	@	react-dom.development.js:257
replayUnitOfWork	@	react-dom.development.js:18579
renderRoot	@	react-dom.development.js:19469
performWorkOnRoot	@	react-dom.development.js:20343
performWork	@	react-dom.development.js:20255
requestWork	@	react-dom.development.js:20229
scheduleWork	@	react-dom.development.js:19912
updateContainerAtExpirationTime	@	react-dom.development.js:20573
updateContainer	@	react-dom.development.js:20658
ReactRoot.render	@	react-dom.development.js:20954
eval	@	react-dom.development.js:21091
unbatchedUpdates	@	react-dom.development.js:20460
legacyRenderSubtreeIntoContainer	@	react-dom.development.js:21087
render	@	react-dom.development.js:21156
reagent$dom$render_comp	@	dom.cljs:21
eval	@	dom.cljs:44
eval	@	dom.cljs:39
eval	@	core.cljs:74
netdava$homebank$app$core$render	@	core.cljs:20
netdava$homebank$app$core$main	@	core.cljs:25
eval	@	shadow.module.main.append.js:4
goog.globalEval	@	main.js:577
env.evalLoad	@	main.js:1670
(anonymous)	@	main.js:1941
#2020-10-1106:01Andrei Stan
main.js:1673 TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at eval (validate.cljs:87)
    at validate_arg (validate.cljs:87)
    at eval (core.cljs:4736)
    at eval (core.cljs:4736)
    at Object.eval [as sval] (core.cljs:3439)
    at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3496)
    at Object.cljs$core$seq [as seq] (core.cljs:1234)
    at Object.cljs$core$every_QMARK_ [as every_QMARK_] (core.cljs:4239)
    at Object.re_com$validate$validate_fns_pass_QMARK_ [as validate_fns_pass_QMARK_] (validate.cljs:102)
    at Function.eval [as cljs$core$IFn$_invoke$arity$variadic] (validate.cljs:117)
#2020-10-1108:59thhellerlooks like you have something undefined that shouldn't be [thing {:foo "bar"}] where thing is undefined or so#2020-10-1100:11mikethompson@andrei.stan I'm not sure if you fixed your problem or not, but you can always use re-frame-template to obtain a working re-com app#2020-10-1106:01Andrei Stanthanks for your input, i will repeat the whole process if i can't fix it#2020-10-1107:15jarredlhumphreyHello fellow clojurians... I've been working on an electron + re-frame + shadow-cljs app for the past few weeks and I've been running into an issue trying include an npm package called electron-store. If I understand the error logs correctly, it seems shadow-cljs doesn't like the javascript spread syntax that the electron-store library uses in a few places. Any idea why this is the case? All of my packages are fully up to date (at least as I'm aware) and I'm running on Node.js v14.13.0. Any thoughts around root cause would be much appreciated and let me know if there's more information I can provide to help clarify. Thanks! JS Error:
SHADOW import error <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js
App threw an error during load
<DIR>/node_modules/electron-store/index.js:13
			...options
			^^^
SyntaxError: Unexpected token ...
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:528:28)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js:3:40
    at global.SHADOW_IMPORT (<DIR>/resources/main.js:64:44) 
shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "1.1.1"]
                [cider/cider-nrepl "0.21.0"]]

 :dev-http {8080 "resources/public/"}

 :builds {:main {:target :node-script
                 :output-to "resources/main.js"
                 :main app.main.core/main}

          :renderer {:target :browser
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:init-fn app.renderer.core/start!}}}}}
package.json
{
  "name": "placeholder",
  "version": "1.0.0",
  "description": "placeholder",
  "main": "resources/main.js",
  "scripts": {
    "dev": "./node_modules/.bin/shadow-cljs watch main renderer",
    "build": "./node_modules/.bin/shadow-cljs compile main renderer",
    "clean": "rm -rf resources/public/js/* && rm -rf target"
  },
  "keywords": [
    "shadow-cljs",
    "reagent",
    "electron"
  ],
  "author": "placeholder",
  "devDependencies": {
    "electron": "^10.1.3",
    "shadow-cljs": "^2.11.5"
  },
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "create-react-class": "^15.6.3",
    "electron-store": "^6.0.1",
    "normalize.css": "^8.0.1",
    "react": "^16.13.0",
    "react-dom": "^16.13.0"
  }
}
#2020-10-1108:44thheller@jarredlhumphrey this is an internal electron/node error. it has trouble loading that file. not shadow-cljs.#2020-10-1108:45thhellerjust run node and then require("electron-store"). that should give you the same error.#2020-10-1119:19jarredlhumphrey@thheller hmm when I do this from Node I don't receive any errors. Similarly, when I try to run an example vm.runInThisContext call from Node with a spread operator (as thats the command in shadow-cljs thats choking) I dont have any issues. So it seems to be just from the context of shadow-cljs that its barfing. I'm going to dig into electron a bit and see if it does anything special to node or the vm that might effect this, but otherwise still a little stumped. Anyhow, thanks for your help here I really appreciate it.#2020-10-1119:22thhellerno clue. shadow.js.shim.module$electron_store.js is literally only doing require("electron-store") and the failure is in that file. shadow-cljs has not processed that file in any way and it is just up to electron fulfilling that require.#2020-10-1119:34jarredlhumphreyOk thanks for the clarification. Appreciate it!#2020-10-1108:47thhellermaybe some electron/node setting configures which language version it accepts or so?#2020-10-1110:03teodorluHey! I'm having trouble using Datascript under Shadow-CLJS and advanced compilation. Before I write up a minimal example, has anyone else had this problem? I'm using Shadow-CLJS 2.11.5 and Datascript 1.0.1.#2020-10-1110:11thhelleryou need to include the externs for some reason. no clue why.#2020-10-1110:12thhellerhttps://github.com/tonsky/datascript/wiki/Tips-&amp;-tricks#externs-and-shadow-cljs#2020-10-1110:15teodorluAh, that's a bit random. Thanks!#2020-10-1110:23teodorluThat fixed it. Thanks a lot, @thheller 🙏#2020-10-1215:15currentoorHas anyone used apollo client with shadow-cljs? Or does lack of webpack prevent that from working. #2020-10-1215:23thhellerdoes it explicitely depend on webpack?#2020-10-1215:40ziltiAre there really libs that actually do? I've seen some libs that claim to require webpack (by mentioning it as part of their install) but none of these actually did. Actually depending on it sounds like terrible design...#2020-10-1216:01thhellersome are rather webpack specific yes but not that common in popular libs#2020-10-1217:51flyboarderAnyone using dynamic loading (shadow.loader) with or without shadow.lazy?#2020-10-1217:53thhellerI do#2020-10-1217:54flyboarderI have a module with an init-fn that fn loads a module dynamically, but im having issues calling things from the loaded module#2020-10-1217:56flyboarder
:module-loader true
:modules {:base   {:entries [app.debug app.auth]}
          :common {:entries [app.index]
                   :depends-on #{:base}}
          :app {:init-fn app.main/init!
                :depends-on #{:common}}
          :cloud {:entries [app.main.cloud]
                  :depends-on #{:app}}}
#2020-10-1217:57thhellerI'm assuming this doesn't actually say :cloud {:entities?#2020-10-1217:58flyboarderthat could very well be a typo#2020-10-1217:58flyboarderI was tired lastngiht#2020-10-1217:59flyboarderI had that module as an init-fn as well as a test#2020-10-1218:00flyboarderwhen using it as an init-fn it loaded - but I got a whole bunch of errors that things were already declared#2020-10-1218:02flyboarder
;; app/main.cljs
(defn init! []
  (loader/with-module :cloud
    (fn []
      (let [cloud (resolve 'app.main.cloud/dashboard)]
        (cloud)))))
#2020-10-1218:03flyboarderfailed to load clojure.set.js Error: Namespace "clojure.set" already declared.#2020-10-1218:08thhellerhmm don't use with-module?#2020-10-1218:08thheller(-> (loader/load :cloud) (.then (fn [] ...))#2020-10-1218:09thhellerI can't remember what with-module is for#2020-10-1218:09thhelleralso just use shadow.lazy. much better API and doesn't involve dealing with resolve issues#2020-10-1218:09flyboarderIdeally I want to use shadow.lazy but It couldnt find the modules#2020-10-1218:10thhellerwhat does that mean?#2020-10-1218:10flyboarderwhen I give it the symbol the compiler throws an error about not finding the app.main.cloud module#2020-10-1218:10flyboarderto the loadable#2020-10-1218:12flyboarder
(def components
  (lazy/loadable {:cloud app.main.cloud/dashboard)})

(defn init! []
  (-> (lazy/load components)
      (.then
        (fn [{:keys [cloud]}]
            (cloud)))))
#2020-10-1218:13thhellerwell if you actually had the typo from earlier that may have been the cause?#2020-10-1218:13thhellerI mean if the ns isn't actually included in the build?#2020-10-1218:17flyboarderSo the block above does work, but I still get the same console errors#2020-10-1218:18flyboarderill check the manifest again#2020-10-1218:20thhelleralso note that if you are loading the module directly on init it would be better to have your HTML load it immediately instead#2020-10-1218:20thhellerbut otherwise this looks fine#2020-10-1218:20flyboarderbase.js:2226 failed to load goog.dom.inputtype.js Error: Namespace "goog.dom.InputType" already declared.#2020-10-1218:22flyboarderis the depends-on correct? should the dynamic modules “depend” on the main loader module, or the other way around?#2020-10-1218:22flyboarderthis seems to be thrown by the dynamic module#2020-10-1218:24thhellertry triggering the load via some kind of async delay#2020-10-1218:24thheller(js/setTimeout (fn [] _here_ ) 0) or so#2020-10-1218:24thhellermaybe its a race condition#2020-10-1218:31flyboarderok so i reduced the number of them by removing the module from the index file#2020-10-1218:32thhellerdon't know what that means#2020-10-1218:33flyboarder
{:type :dtd, :data ["html" nil nil]}
#2020-10-1218:33flyboarderthats the index file#2020-10-1218:33flyboarderI had the cloud.js in there#2020-10-1218:34thhellerah yeah if you do that you definitely need the timeout#2020-10-1218:34thhellerotherwise it triggers the load twice#2020-10-1218:35flyboarderso im still getting some of them#2020-10-1218:35thhellerI don't like that you have ./client as the path. much more predictable if you use absolute paths with the proper absolute :asset-path as well#2020-10-1218:35flyboarderyeah thats an issue with the kubernetes ingress#2020-10-1218:35thhellerbut besides that I don't have enough information to help#2020-10-1218:36thhellerit all looks fine from here#2020-10-1218:44flyboarderok good to know im at least kinda understanding this 😅#2020-10-1218:54flyboarderdoing it with the lazy block as above seems to be working now, could very well have been a typo causing the issue with it last night#2020-10-1301:40MatDHi. Is there a way for the test results to output the complete path of a failing test file? For example, suppose I have the following structure src + main ++ module1 +++ file.cljs + test ++ module1 +++ file_test.cljs when I have a failure, I get
FAIL in (my-test) (module1/file_test.cljs:31:13)
The problem is that I cannot click on the file path in the terminal and open the file directly, since it's missing the "src/test/" at the beginning
#2020-10-1308:40thhellernot built-in no#2020-10-1312:59jcfHello again folks! Hope you're having a great day wherever you are. 🙂 I've pushed things as far as I can without a working cljs REPL so have carved out sometime to get a Emacs/Cider-based nREPL connection working with shadow-cljs. The blocker right now is Cider trying to require cider.piggieback, which I've read shadow-cljs doesn't use at all. I'm using cider-jack-in-cljs with both :deps and :nrepl in my shadow-cljs.edn:
{:deps  {:aliases [:client]}
 :nrepl {:port 8777}
 ,,,}
I've tried adding Cider deps to my deps.edn even though Cider injects its deps/middleware for me:
/usr/bin/clojure -A:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
I haven't tried adding my client alias to my global CLI opts because I don't want browser-based dependencies being loaded in a server REPL but if that's the problem I can probably juggle things around. I've also read in a GitHub issue that use of :dependencies is recommended over use of :deps but that's on an old issue and I can't find any mention of such a recommendation in the shadow-cljs user guide. I keep reading that it's a simple as running cider-jack-in-cljs so I'm feeling a little dumb I guess. :shrug:
#2020-10-1313:00jcfMy .dir-locals.el contains this:
((nil
  (cider-clojure-cli-global-options . "-A:dev:test")
  (cider-default-cljs-repl . shadow-select)
  (cider-known-endpoints . (("localhost" "8777")))
  (cider-shadow-default-options . ":REDACTED")
  (cider-preferred-build-tool . clojure-cli)))
#2020-10-1313:01jcf
{:clojure.main/message
 "Execution error at nrepl.cmdline/require-and-resolve (cmdline.clj:195).\nNo namespace: cider.piggieback found\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.Exception,
  :clojure.error/line 195,
  :clojure.error/cause "No namespace: cider.piggieback found",
  :clojure.error/symbol nrepl.cmdline/require-and-resolve,
  :clojure.error/source "cmdline.clj",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.Exception,
    :message "No namespace: cider.piggieback found",
    :at [clojure.core$the_ns invokeStatic "core.clj" 4162]}],
  :trace
  [[clojure.core$the_ns invokeStatic "core.clj" 4162]
   [clojure.core$ns_resolve invokeStatic "core.clj" 4369]
   [clojure.core$ns_resolve invokeStatic "core.clj" 4359]
   [clojure.core$ns_resolve invoke "core.clj" 4359]
   [nrepl.cmdline$require_and_resolve invokeStatic "cmdline.clj" 195]
   [nrepl.cmdline$require_and_resolve invoke "cmdline.clj" 185]
   [nrepl.cmdline$fn__3236 invokeStatic "cmdline.clj" 199]
   [nrepl.cmdline$fn__3236 invoke "cmdline.clj" 199]
   [clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
   [clojure.core$map$fn__5862$fn__5863 invoke "core.clj" 2742]
   [clojure.lang.PersistentVector reduce "PersistentVector.java" 343]
   [clojure.core$transduce invokeStatic "core.clj" 6883]
   [clojure.core$into invokeStatic "core.clj" 6899]
   [clojure.core$into invoke "core.clj" 6887]
   [nrepl.cmdline$__GT_mw_list invokeStatic "cmdline.clj" 226]
   [nrepl.cmdline$__GT_mw_list invoke "cmdline.clj" 224]
   [nrepl.cmdline$build_handler invokeStatic "cmdline.clj" 235]
   [nrepl.cmdline$build_handler invoke "cmdline.clj" 228]
   [nrepl.cmdline$options__GT_handler invokeStatic "cmdline.clj" 304]
   [nrepl.cmdline$options__GT_handler invoke "cmdline.clj" 295]
   [nrepl.cmdline$server_opts invokeStatic "cmdline.clj" 352]
   [nrepl.cmdline$server_opts invoke "cmdline.clj" 340]
   [nrepl.cmdline$dispatch_commands invokeStatic "cmdline.clj" 443]
   [nrepl.cmdline$dispatch_commands invoke "cmdline.clj" 436]
   [nrepl.cmdline$_main invokeStatic "cmdline.clj" 459]
   [nrepl.cmdline$_main doInvoke "cmdline.clj" 454]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 665]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "No namespace: cider.piggieback found"}}
Stacktrace hidden in a file by Clojure. 👆
#2020-10-1313:01jcfI wish Clojure would write to stdout/stderr so I could redirect output myself. 🙂#2020-10-1313:01thhellerAll I can point you to is https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2020-10-1313:01thhellerI don't use emacs/cider so I don't have a clue how it works#2020-10-1313:02thhellermight be simpler to just connect to the REPL instead of jacking in#2020-10-1313:03thhellerie. just run shadow-cljs server or so and then connect remotely to 8777 (however you do that I don't know though)#2020-10-1313:04thhellerthe clojure call above doesn't seem to be using shadow-cljs#2020-10-1313:07jcfThanks for the pointers, @thheller. I tried connecting to the nREPL server running inside my shadow-cljs watch process but I get errors about middleware being missing. I've added the middleware to my deps.edn and get the same errors.#2020-10-1313:07jcf
;; Connected to nREPL server - 
;; CIDER 0.26.1 (Nesebar), nREPL 0.7.0
;; Clojure 1.10.1, Java 14.0.2
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :REDACTED))
;;
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
To quit, type: :cljs/quit
;; => [:selected :REDACTED]WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 2.5.0 and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user> 
cljs.user> 
#2020-10-1313:08thhellerseems fine? just adjust the versions in deps.edn?#2020-10-1313:08jcfUno momento. I'll get the error from that. 🙂#2020-10-1313:11jcfI've added these deps to my :client alias:
cider/cider-nrepl             {:mvn/version "0.25.4"}
    refactor-nrepl/refactor-nrepl {:mvn/version "2.5.0"}
And now Cider tells me this:
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
#2020-10-1313:11jcfI've checked my ~/.config/clojure/deps.edn and made sure there's no ~/.clojure/deps.edn. Where this snapshot version of Cider is coming from, I'm unsure.#2020-10-1313:12jcfAnd why the explicit artefacts in my deps.edn are ignored…#2020-10-1313:12jcf
:aliases
 :client
  :extra-deps
   applied-science/js-interop    {:mvn/version "0.2.7"}
    cider/cider-nrepl             {:mvn/version "0.25.4"}
#2020-10-1313:12jcfSlack ditched a curly brace there. It's definitely in my deps.edn file. 😄#2020-10-1313:12thhellermight be a better question for #cider#2020-10-1313:13jcfHmm. Cider doesn't manage my dependencies when I connect a REPL but I guess they might have some vendored snapshot or some dependency resolution thing they're doing somewhere.#2020-10-1313:14thhellerI would expect it to respect deps.edn but I don't have a clue#2020-10-1313:15thhellereither way it is saying it requires 0.25.3 and you have 0.25.4 so that might be the problem too#2020-10-1313:19thhellermaybe try clojure -A:client -Stree or whatever the command was to list the tree. maybe that explains wheres its coming from#2020-10-1313:22jcfI've asked the question over here too: https://clojurians.slack.com/archives/C0617A8PQ/p1602595230188700 Hopefully some of the lovely people over there are using my dream combo of Cider and shadow-cljs! 🙂#2020-10-1313:24thheller@jcf I just noticed from the command above it had /usr/bin/clojure -A:dev:test#2020-10-1313:25thhellerso that doesn't use the :client alias you setup?#2020-10-1313:25jcfThat's correct. In my shadow-cljs.edn file I have :deps {:aliases [:client]} … Do I need the initial invocation of Clojure to include :client too?#2020-10-1313:26jcfThat might get a little tricky as I don't always want to load up all my browser-based deps when I jack in. Maybe I can add those options to just the cljs opts.#2020-10-1313:26thhellerI cannot answer cider/emacs questions sorry. From the command above it did not invoke shadow-cljs at all so whatever is in shadow-cljs.edn also has no effect.#2020-10-1313:28jcfProgress! 💥
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
DEPRECATED: Libs must be qualified, change compliment => compliment/compliment 
DEPRECATED: Libs must be qualified, change nrepl => nrepl/nrepl 
DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl 
WARNING: When invoking clojure.main, use -M
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
nREPL server started on port 33897 on host localhost.localdomain - 
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by dynapath.defaults$eval29666$fn__29667 to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of dynapath.defaults$eval29666$fn__29667
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
;; Connected to nREPL server - 
;; CIDER 0.26.1 (Nesebar), nREPL 0.8.0
;; Clojure 1.10.1, Java 14.0.2
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;  Startup: /usr/bin/clojure -A:client:dev:test -Sdeps '{:deps {me.raynes/fs {:mvn/version "1.4.6"} compliment {:mvn/version "0.3.6"} com.cemerick/pomegranate {:mvn/version "0.4.0"} org.tcrawley/dynapath {:mvn/version "0.2.5"} nrepl {:mvn/version "0.8.0"} cider/piggieback {:mvn/version "0.5.1"} refactor-nrepl {:mvn/version "2.5.0"} cider/cider-nrepl {:mvn/version "0.25.3"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
;;
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :grocer))
;;
;; => :missing-nrepl-middlewareuser> 
user> 
#2020-10-1313:29jcfI've added :client to my CLI opts.#2020-10-1313:33thhellerok now you are missing the shadow-cljs nrepl middleware#2020-10-1313:33thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2020-10-1313:33thhellerdunno how you add that#2020-10-1313:35jcfThere's a cider-jack-in-cljs-nrepl-middlewares var that takes a list of strings from the looks of it.#2020-10-1313:35jcf
cider-jack-in-cljs-nrepl-middlewares is a variable defined in
cider.el.

Value
("cider.piggieback/wrap-cljs-repl")

Set

Documentation
List of Clojure variable names.
#2020-10-1313:36jcfI'm not sure if I need wrap-cljs-repl with shadow-cljs, right? I thought I read that shadow provides its own middleware.#2020-10-1313:37thhelleryou can keep it but you don't need it yes#2020-10-1313:37jcfCool. Jacking in now. :crossed_fingers:#2020-10-1313:42jcfI think this exception is shadow-cljs letting me know that I'm not building anything?
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
missing instance
#2020-10-1313:43jcfNot sure why an exception is thrown as that doesn't seem like an exceptional circumstance but maybe it's the way Cider's firing up the REPL internally.#2020-10-1313:43thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2020-10-1313:44thhelleryou are running in embedded mode so shadow-cljs isn't even started yet#2020-10-1313:44thhelleryou need to start it#2020-10-1313:45thhellerit is an exception because the jack in likely wants to switch you to the shadow-cljs REPL which obviously can't work when shadow-cljs isn't even running#2020-10-1313:46thhellerI recommend connecting remotely ... doing all of this yourself is a lot of effort for basically no gain#2020-10-1313:49jcfOkay, I'll stick with connecting Cider to shadow-cljs and forget about jacking in.#2020-10-1313:52jcfI'll be starting from here:
WARNING: CIDER 0.26.1 requires cider-nrepl 0.25.3, but you're currently using cider-nrepl 0.23.0-SNAPSHOT. The version mismatch might break some functionality! (More information)
To quit, type: :cljs/quit
;; => [:selected :grocer]No available JS runtime.
See > 
🙂
#2020-10-1313:53thhellerlooks like you got it. just open the browser with your code loaded. (assuming this is a browser build of course)#2020-10-1313:54jcfThat's awesome! I can connect to the browser and eval stuff like (js/alert "Hi, there!").#2020-10-1313:54jcfCompletion blows up quite spectacularly. 😄#2020-10-1313:54thhellerthats likely https://github.com/rksm/clj-suitable/issues/15#2020-10-1313:55jcfYeah, I've stumbled across that issue today.#2020-10-1313:55thhelleryou can turn that off to just get regular completion#2020-10-1313:57jcf@thheller do you know how I turn that off to get regular completion?#2020-10-1313:57jcfI can eval code but completion and eldoc are broken.#2020-10-1313:58jcfEldoc gives you the function signature in the bottom of the editor window, which is super handy.#2020-10-1313:59jcfFound something here: https://github.com/clojure-emacs/cider/issues/2808#issuecomment-620382450#2020-10-1418:41Misha BohdanHello! Did anyone try to use shadow-cljs from devcontainers? I found that it works much better than WSL but hot reloading is not working for some reason. Any ideas why could it be?#2020-10-1418:53ziltiI haven't, but just in case you didn't know: shadow-cljs, npm, and clojure run perfectly fine directly on Windows. No need for either WSL or any kind of container#2020-10-1419:23thhellerI honestly don't even know what devcontainers are 😛#2020-10-1419:24thhellerbut by having container in the name I'm assuming its virtualized which might mean that file watching doesn't work#2020-10-1419:24thhellermaybe :fs-watch {:polling true} in shadow-cljs.edn makes it work#2020-10-1419:31Misha Bohdan
{:nrepl {:port 8777}
 :source-paths ["src/cljs"]
 :fs-watch {:polling true}
 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules  {:app {:init-fn mui.core/init}}
                :autobuild true
                :devtools {:http-root "resources/public"
                           :http-port 8280
                           :autobuild true
                           :preloads [devtools.preload]}}}
 :devtools {:after-load mui.core/start}}
Is it correct?
#2020-10-1419:34thhelleryes#2020-10-1419:44Misha Bohdan@U05224H0W Can I see somehow this config? https://github.com/thheller/shadow-cljs/blob/b05b8f41afd45564ef7b9831a07201d09a5c4a07/src/main/shadow/cljs/devtools/server/fs_watch_hawk.clj#L43#2020-10-1420:14thhellerwhat do you mean see? this is the :fs-watch map?#2020-10-1420:16thhellerbut the hawk watcher is only used on macOS#2020-10-1420:17thhelleroh hmm right that might mean that :polling true doesn't actually do anything since it is a hawk only option 😛#2020-10-1420:22Misha BohdanI found the solution https://github.com/wkf/hawk/issues/10#issuecomment-173656507 and tried it with Hawk. For now I'll try to force Hawk in the container#2020-10-1420:31Misha BohdanYes, it's working! @U05224H0W, could I create a pull request?#2020-10-1420:37thhellerfor?#2020-10-1420:39Misha Bohdanfor forcing the use of Hawk in config#2020-10-1420:43Misha BohdanI've made a change into the shadow.cljs.devtools.server.fs-watch file
-        (if (and (str/includes? os-name "Mac") (not (false? (:hawk config))))
+        (if (not (false? (:hawk config)))
and config
:fs-watch {:watcher :polling
           :hawk true}
After these changes, hot reloading finally started to work!
#2020-10-1420:44Misha BohdanBy default hawk is false so there is shouldn't be a problem#2020-10-1420:54thhellerdefinitely not doing that#2020-10-1420:54thhellerbut I'm ok with testing :hawk true#2020-10-1421:26Misha BohdanThank you so much for your help! Should I create an issue instead? It still needs to be supported in the codebase since devcontainer is a Docker container and OS in it is Linux and it will fail (str/includes? os-name "Mac") precondition.#2020-10-1421:40thhellercreate an issue. I'll think about it.#2020-10-1419:26Misha BohdanIt's just a docker container with needed runtime and vscode service.#2020-10-1500:27macrobartfastafter creating a project with
lein new re-frame demorf +cider
and then
lein deps
and
npm install
and then running in emacs
cider-jack-in-cljs
I got a user> prompt, but attempting to eval the :require statement in core.cljs with
cider-eval-defun-at-point
generated
Unhandled java.io.FileNotFoundException
   Could not locate reagent/dom__init.class, reagent/dom.clj or
   reagent/dom.cljc on classpath.
which I assume will apply to every dependency. How should I start troubleshooting this?
#2020-10-1500:33macrobartfastI just realized I probably posted this to the wrong channel… it’s a re-frame template… got mixed up.#2020-10-1501:10macrobartfastI got an answer in #clojurescript 😀#2020-10-1618:10sova-soars-the-soraHey all, I keep getting this funky warning:
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
#2020-10-1618:11sova-soars-the-soraAnd in the console, for the minified release version there is:
winjpc.js:145 TypeError: Cannot read property 'call' of undefined
    at pa (winjpc.js:262)
#2020-10-1618:12sova-soars-the-soraI have ajax and rum as dependencies, the watch build works locally, but when I upload a release to my box it is no worky...#2020-10-1618:27sova-soars-the-sorais it problematic that my namespace is a single word with no dots?#2020-10-1618:29sova-soars-the-soraDOH renamed the build didn't change the console line to compile w/ new name xD#2020-10-1618:35sova-soars-the-soramaybe#2020-10-1618:40sova-soars-the-sorano dice ;/#2020-10-1618:46sova-soars-the-soraso the non-minified code says "move data fetching to componentDidUpdate" ... it's a warning#2020-10-1618:46sova-soars-the-soraand then when I make a release build... it just doesn't work#2020-10-1618:52sova-soars-the-soraYeah, not really sure... maybe you guys get these errrors sometimes?#2020-10-1619:09Karol WójcikThat’s probably lack of externs#2020-10-1619:17sova-soars-the-soraOh#2020-10-1619:17sova-soars-the-soraThank you. Will look into it now.#2020-10-1619:23sova-soars-the-soraI added :infer-externs :all to the shadowncljs edn ... no difference yet... hrm#2020-10-1619:48sova-soars-the-soraoh it needs :compiler-options {:infer-externs :auto} let's se if that does the trick...#2020-10-1618:52sova-soars-the-sora#2020-10-1621:20macrobartfastcan someone point me in the direction of a current tutorial on how to use npm react components in a shadow-cljs/reagent project?#2020-10-1621:20macrobartfastI found a couple on the googles but I am worried they may not be current.#2020-10-1621:23macrobartfastI want to use https://codesandbox.io/s/react-piano-basic-demo-forked-q5xyj in a lein new reagent myapp +shadow-cljs generated project… I’m not sure I can do this in ClojureScript, actually.#2020-10-1621:49sova-soars-the-sorai think rumnext can make rum components out of javascript, not 100% sure#2020-10-1621:54macrobartfastI found this… https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2020-10-1621:54macrobartfastbut I’m truly floundering.#2020-10-1621:57dpsuttonhttps://github.com/dpsutton/asg-ignite-presentation is a repo with links to a presentation, a demo app built and deployed onto netlify, and the repo of the app. it uses npm deps and shadow-cljs#2020-10-1621:58macrobartfastsweet!#2020-10-1621:58sova-soars-the-soradpsutton with the clutch fix =]#2020-10-1621:58macrobartfastalways.#2020-10-1623:05sova-soars-the-sorawhen it doubt.. baby steps and comment out#2020-10-1623:11sova-soars-the-soraWhen I add these lines, everything breaks
[:input.insit { :type "text"
		        :value rc
				:auto-focus :true
                :on-change (fn [e] 	(reset! email-input (.. e -target -value)))}]
#2020-10-1623:11sova-soars-the-sorasanity check#2020-10-1623:24sova-soars-the-sorai think :value is not necessary... hrm#2020-10-1623:25sova-soars-the-sora🎵 "minutes change like seasons, i'm just talking to myself.."#2020-10-1623:26sova-soars-the-soraWOW. that was the offending line xD#2020-10-1623:26sova-soars-the-sorathanks for stickin' it out with me boiz#2020-10-1623:26sova-soars-the-sorai know you're here in spirit 😄#2020-10-1705:53hyooHi all, I got an error like
[2020-10-17 01:50:37.230 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-1f3b9bdc.js", :requires [{:line 1630, :column 33}]}
#2020-10-1705:56hyooIt looks like it is caused by
return Promise.resolve().then(function () {
    return _interopNamespace(require(`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {...}, consoleError);
#2020-10-1705:56hyooIs there a way to get around this in shadow-cljs?#2020-10-1708:57thheller@hjfirst no, this is not supported.#2020-10-1711:33hyooThanks for clarifying.#2020-10-1711:41kwrooijenHas anyone tried Cordova with Android platform? I followed this repo https://github.com/thheller/cordova-cljs but I get the Shadow-cljs - reconnecting message. it's noted in the repo that this was only tested on the windows platform, but maybe someone has an idea? (I also removed the Content-Security-Policy part)#2020-10-1712:31thhellerdoes it say why the connection failed?#2020-10-1713:35kwrooijenSorry was afk for a bit. I got the debugger working and had the error ERR_CLEARTEXT_NOT_PERMITTED . I then added a rule in my config.xml to fix this. Now I have an ERR_CONNECTION_REFUSED error. Checking now if I need to add any extra rules or something.#2020-10-1713:35kwrooijenIf I can get this to work I'll create a PR to update the README for that repo#2020-10-1713:51kwrooijenAll right, figured it out. Apparently Android needs to look at 10.0.2.2 . So the solution is to add this to your shadow-cljs.edn devtools config: :devtools-url ""#2020-10-1713:59kwrooijenPR to add this info to cordova-cljs repo, so other people don't have to bump their heads against the wall: https://github.com/thheller/cordova-cljs/pull/2#2020-10-1717:39Jack ArringtonIf I want to use a single, local JS file (not from npm) from CLJS, how do I do that? There is :foreign-libs, but it sounds like that is not compatible with shadow-cljs.#2020-10-1717:45thheller@mail985 see https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2020-10-1717:46Jack ArringtonPerfect, thanks @thheller!#2020-10-1721:49joshkhshould npx shadow-cljs server produce a .nrepl-port file?#2020-10-1722:10thhellerno#2020-10-1722:10thhellerit produces .shadow-cljs/nrepl.port#2020-10-1722:28joshkhgot it, thanks @thheller. i'm just working on an easy Cursive setup, and the "Use port from nREPL file" isn't working. i probably botched something on my end.#2020-10-1722:43thhellershould be working fine assuming you have a current cursive version#2020-10-1722:43thhellerolder versions only looked for .nrepl-port#2020-10-1722:43thhellernewer versions definitely support .shadow-cljs/nrepl.port#2020-10-1723:02joshkhyup, that did the trick 🙂#2020-10-1723:07joshkhand one last non-pressing thing (i'm sure i'll find it in the docs after asking)
(ns app
  (:require ["left-pad" :as left-pad]))

; Cursive loading the app.cljs ns in the repl:
Loading src/main/app.cljs... 
Syntax error macroexpanding clojure.core/ns at (src/main/app.cljs:1:1).
((:require ["left-pad" :as left-pad])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
#2020-10-1723:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2020-10-1723:16joshkhah, shadow/repl wasn't running. as always, thanks for your help#2020-10-1914:13kommenis there any way to make :infer-warnings show up in the shadow-cljs hud? they show up in the stdout, but we’d like to see them in the hud as well#2020-10-1914:13kommenand maybe even also make :warnings-as-errors also treat :infer-warning as an error#2020-10-1914:16wombawombaIs there a way to get the browser to reconnect after the shadow-cljs connection has been close?#2020-10-1914:26thheller@wombawomba it should be trying to reconnect on its own?#2020-10-1914:27wombawombaIt doesn’t though… I need to refresh#2020-10-1914:27wombawombaFWIW this happens whenever my laptop goes to sleep#2020-10-1914:28thheller@kommen they should show up in the HUD just as any other warning? as does :warnings-as-errors?#2020-10-1914:28wombawombaI don’t think I’m on the newest shadow-cljs version though.. perhaps this has been fixed in newer releases?#2020-10-1914:28thhelleryes. that was changed not too long ago.#2020-10-1914:29wombawombawhen this happens there’s a red box saying “Connection closed!” where the usual messages go#2020-10-1914:29wombawombaalright, I’ll try the newest version and see if that fixes it 🙂 thanks#2020-10-1914:41kommen@thheller true that. upgrading from shadow-cljs 2.8.91 to the latest version indeed makes them show up in the hud 🙈#2020-10-1923:16Alexis Vincent@thheller what is the status on :esm?#2020-10-1923:26Alexis VincentI’m looking to spend some time getting NextJS working with shadow-cljs. Looking through your next-cljs project and approach seems straightforward for automation. But for now I’d like to build things out manually to get a feel for how viable this is. Output needs to work in both node and browser. Have tried :esm and :npm-module but get duplicate require issues. Which target is best to try work through? Is this something you would be ok lending some support if I were to build out a proper integration?#2020-10-2000:05kennytiltonI am getting a harmless error
Parse error. illegal use of unknown JSDoc tag "pd"; ignoring it
doing a release build, when it gets to this line in a library I am using: https://github.com/ptaoussanis/tufte/blob/master/src/taoensso/tufte.cljc#L315 There is a comment with a code snippet ending @pd. ANy way to quiesce that? Not a big deal at all.
#2020-10-2008:05thheller@kenny there is an option but I can't remember the name. I'll try to look it up later.#2020-10-2008:06thheller@mail024 what are "duplicate require issues"? for now :npm-module should sort of work. :esm is sort of finished except for a "do not bundle X packages" setting I guess#2020-10-2010:13victorb@thheller I keep trying to shoehorn shadow-cljs into lots of different contexts, and thinking about it, it would be helpful if you could provide new :target 's as plugins/extensions to shadow-cljs, to keep the core smaller and not having to implement everything in shadow-cljs. Something you thought about?#2020-10-2010:13thhellerthis is the basic design#2020-10-2010:14thheller:target accepts a symbol. so :target your.lib/my-target would call that function#2020-10-2010:14victorbooooh, didn't know that! That's cool, will take a look at that#2020-10-2010:15thhellerall the default targets are implemented this way https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2020-10-2010:15victorbguessing it just has to be available on the classpath and it'll pick it up from there?#2020-10-2010:15thhellerand a keyword for :target just expands to shadow.build.targets.<name-of-kw>/process#2020-10-2010:16victorbcool cool, thanks 👍#2020-10-2010:16thhelleryes its just a regular function you implement that inspects some keys to know what it is supposed to do#2020-10-2010:16thhellerI recommend looking at simple targets like node-script https://github.com/thheller/shadow-cljs/blob/80b00a6bd61537c3a4dbcaece1f7555234cc2d87/src/main/shadow/build/targets/node_script.clj#L66#2020-10-2010:17thheller:browser is by far the most complicated so can be hard to understand what is happening#2020-10-2010:18thhellerthe API isn't documented at all though but happy to walk you through it#2020-10-2010:18thhellerbasically it gets the entire build state and just does whatever it needs to#2020-10-2010:22thhellerthis is one of the custom targets someone else wrote as a lib https://github.com/titonbarua/shadow-cljs-gjs-target#2020-10-2010:44Alexis Vincent@thheller duplicate require was a bad way to name it. I meant Namespace "xxx" already declared . Happens for both esm and npm-module. I think i remember similar things happening a little while back when I tried to import cljs code from shadow in webpack.
Error: Namespace "cljs.core" already declared.
    at Object.goog.provide (webpack-internal:///./dist/cljs/cljs-runtime/cljs_env.js:102:13)
    at eval (webpack-internal:///./dist/cljs/cljs-runtime/cljs.core.js:4:6)
    at Module../dist/cljs/cljs-runtime/cljs.core.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:199:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./dist/cljs/index.js:41:85)
    at Module../dist/cljs/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2298:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./pages/index.js:2:77)
    at Module../pages/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2310:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
#2020-10-2010:44Alexis VincentSuper cool about the target thing mentioned above!#2020-10-2010:46thhellerweird. are you including multiple builds this way?#2020-10-2010:48Alexis VincentA single one. I can get you a repro project if thats useful.#2020-10-2010:49Alexis Vincent
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[reagent "0.8.1"]]

 :builds
 {:site {:target :npm-module
         :output-dir "site/src/cljs"
         :build-hooks [(shadow.next-js/create-pages)]
         :entries []}
  :esm {:target :esm
        :output-dir "dist/cljs"
        :build-hooks [(shadow.next-js/create-pages)]
        :modules {:index {:exports {page_index }}}}}}
#2020-10-2010:50Alexis VincentLet me push a repro project#2020-10-2010:53Alexis Vincenthttps://github.com/alexisvincent/shadow-cljs-next-repro#2020-10-2010:54Alexis Vincentrepro is for esm#2020-10-2010:54Alexis Vincentnpm run dev shadow-cljs watch esm#2020-10-2010:55Alexis Vincentactually. Sorry, should remove the build hook for esm. Will fix#2020-10-2010:58Alexis VincentAlso to note, on latest shadow last night I ran into an issue where I changed the shadow-cljs output-dir for either the npm-module or esm and even after restarting shadow watch, it was still outputting to the old dir. Deleting .shadow-cljs fixed it. Possible i had a shadow server running somewhere in emacs while this happened but i dont think i did#2020-10-2011:01Alexis Vincentscratch that, I think i did have a shadow-cljs server running#2020-10-2011:09Alexis Vincentok. I’ve pushed a clean repro case for issues with next-js (although i think this is webpack reproducible as well) and esm. Super simple import. From fresh next and shadow cache. Terminal history is as follows: #2020-10-2011:09Alexis Vincent
> 
#2020-10-2011:20thhelleruhm yeah watch won't work#2020-10-2011:20thhellertry compile#2020-10-2011:21Alexis VincentHave now added an npm-module case. Which works! I must have had bad caches yesterday? What doesn’t work however is interplay between hmr from webpack and shadow. I expect here that I could leave hmr up to shadow by using compile. But then i still want to have a shadow server for repl and hmr, how do I do this? Im assuming some combination of compile and server?#2020-10-2011:25Alexis Vincentesm compile works, but fails for other reasons I dont think are related to shadow. Thanks! Having a way for shadow to do hmr but bypassing the flush step to avoid next attemping to hmr cljs code would be great. Do you know how i might achieve this?#2020-10-2011:41thhellersorry don't have time for this today
#2020-10-2011:41thhelleryou cannot have both webpack hmr and shadow#2020-10-2011:41thhellerit is either or#2020-10-2011:41thhellerif you want REPL and stuff you need to use the shadow reloading only#2020-10-2012:30Alexis VincentOk, thanks for the input. I’ll get some time to look closer into this tomorrow. Goal is to get reliable interplay between shadow and nextcljs#2020-10-2012:33thhellerI believe I said it is not a good match for CLJS and it still isn't and never will be great#2020-10-2012:33thhellertoo many presumed JS-isms that don't translate well#2020-10-2012:50victorbyeah, I got the same impression last time I looked at next.js, doesn't seem to fit with clojurescript development really. Question for people who used next.js more though, what exactly are you missing in cljs devlopment that next.js gives you? Might be something better in the ecosystem to give you the same or greater benefits#2020-10-2019:14mauricio.szaboHi, @thheller, I just found a really strange issue 😄. On Chlorine, I evaluate all shadow-cljs commands by treating the result - so they all go inside a let. So, if I do something like this:
(let [res (ns some.namespace (:require ["js-dependency" :as dependency]))] res)
And then try do define a function: (defn a-fn [] (.useThis dependency) It breaks with:
AssertionError Assert failed: (symbol? module)
        shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
        shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
        shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:109)
        shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:104)
#2020-10-2019:16mauricio.szaboIf I don't wrap the ns form in a let, it works fine. It's not a big deal, really - Shadow's hot-reload makes evaluating ns forms unnecessary, but I thought I would explain the issue anyway 😄#2020-10-2019:24thheller@mauricio.szabo ns is a special form which you cannot put into a let in CLJS#2020-10-2019:25thhellerthat alone should already fail. dunno how you get to the second error#2020-10-2019:26mauricio.szaboYes, the simple fact that it works sometimes is something that amazes me 😄. For example, load-file simply do not work if you wrap on let#2020-10-2019:27mauricio.szaboThe result of the first command is nil, so it does run... to some extend#2020-10-2019:32thhellerall special forms can't possibly work#2020-10-2019:33thhellerhttps://github.com/thheller/shadow-cljs/blob/b6d1f4c0b6063dee40df182f2abee4a644cd332c/src/main/shadow/cljs/repl.clj#L401-L425#2020-10-2109:35SchpaaI am experimenting with build-hooks in shadow-cljs and I wondered why this fragment wont kick in when building a release:
(defn simple-user-test {:shadow.build/stages #{:configure :flush :compile-prepare}} [state args]
  (println "HELLO:")
  (println (with-out-str (pprint args)))
  (println (:shadow.build/stage state)))
  state) 
but if I pass in a keyword, like :flush (instead of the set) it works fine…?
#2020-10-2109:35SchpaaI am experimenting with build-hooks in shadow-cljs and I wondered why this fragment wont kick in when building a release:
(defn simple-user-test {:shadow.build/stages #{:configure :flush :compile-prepare}} [state args]
  (println "HELLO:")
  (println (with-out-str (pprint args)))
  (println (:shadow.build/stage state)))
  state) 
but if I pass in a keyword, like :flush (instead of the set) it works fine…?
#2020-10-2109:37simongrayI’m not really qualified to answer this, but in your example code snippet you seem to be missing the ^ marking the map as metadata?#2020-10-2109:40Schpaainteresting, well it works fine without the set#2020-10-2109:41Schpaaand https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks does not involve any ^#2020-10-2109:42simongraymy bad, apparently the defn macro allows for attaching metadata using a plain map. I didn’t realise that 🙂#2020-10-2109:44Schpaayup, cheers#2020-10-2109:35SchpaaThis is what the docs say:
The hook is a just a normal Clojure function with some additional metadata. The {:shadow.build/stage :flush} metadata informs the compiler to call this hook for :flush only. You may instead configure {:shadow.build/stages #{:configure :flush}} if the hook should be called after multiple stages. At least one configured stage is required since the hook otherwise would never do anything.
#2020-10-2109:41thheller@schpaencoder when using a set it is stages not stage#2020-10-2109:42Schpaaah!! dang#2020-10-2109:42thhellereasy to miss 😛#2020-10-2109:43Schpaayeah!#2020-10-2116:40neilyioIs there a way to get the shadow-cljs classpath from the command line? This is mentioned in https://github.com/thheller/shadow-cljs/issues/558, I'm just wondering what the best solution is to use clj-kondo, https://github.com/borkdude/clj-kondo#project-setup.#2020-10-2116:43dpsuttonshadow-cljs classpath. described in shadow-cljs --help#2020-10-2116:44neilyioYep just saw that... Thanks for the reply!#2020-10-2121:42jmckitrick@thheller (or anyone else who might know) not long ago, you suggested I ignore that ‘builds’ page that pops up after a successful build.#2020-10-2121:43jmckitrickDoes that page have or will it have a useful purpose? Or is it just a relic or diagnostic tool?#2020-10-2121:52thheller@jmckitrick not a clue what you mean. what is "‘builds’ page that pops up after a successful build"?#2020-10-2121:54jmckitrickI assume it’s shadow-cljs, but I could be wrong. a question pops up after CIDER starts the CLJS REPL and says Visit '' in a browser? (y or n)#2020-10-2121:54jmckitrickSome told me ‘just say no and ignore this’#2020-10-2121:54thhellerthat is a cider question. it isn't coming from shadow-cljs. not a clue what controls it.#2020-10-2121:58jmckitrickok, sorry…#2020-10-2122:00thhellerthe page it wants to open is the shadow-cljs UI#2020-10-2122:00thhellerif you don't care about it you don't need to use it#2020-10-2122:01thhellerbut the prompt is not from shadow-cljs#2020-10-2122:03dpsutton(setq cider-offer-to-open-cljs-app-in-browser nil)#2020-10-2122:06thheller@dpsutton if that supposed to open the actual user app? then it is opening the wrong URL maybe?#2020-10-2122:06thheller9630 is always the shadow-cljs UI, never anything the user builds#2020-10-2122:07dpsuttoncorrect. i believe its usally spot on. when the port is 3000 it offers that port. been a bit but i wouldn't be surprised if this is maybe when deps are managed by lein or deps perhaps#2020-10-2122:08dpsuttoni have 3000 listed as my port but that's occupied so shadow bumped up to 3001. i was correctly offered to see 3001#2020-10-2122:09dpsuttonsearches the nrepl server output for (search-forward-regexp ":[0-9]+" nil 'noerror)#2020-10-2122:11dpsuttonparsing this output
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.37 running at 
is it deterministic that the HTTP server output is before the shadow server output?
#2020-10-2122:12thhellernot a clue actually 😛#2020-10-2122:13thhellerbut the line is different so maybe just ignore the server line?#2020-10-2122:13dpsuttonyeah i should open an issue. maybe look around for all of the different versions to watch out for#2020-10-2204:37ianchowHi, would appreciate if anyone could try to use this npm module @tonejs/piano https://www.npmjs.com/package/@tonejs/piano using shadow-cljs to see if the error is just on my end. Trying to instantiate a Piano object using (Piano.) results in TypeError: Class constructor _o cannot be invoked without 'new' and I can't figure out how to debug it.#2020-10-2211:37AJ JaroWhen I execute a build for shadow-cljs, there are still some :infer-warnings that get displayed. The default for this type of warning is false and there is no change in behavior when I add the additional compiler-option to set that warning type to false. Why are there some :infer-warning types that still display during the build even though the option is turned off by default or explicitly?
------ WARNING #22 - :infer-warning --------------------------------------------
 File: /ui/components/team.cljs:78:77
--------------------------------------------------------------------------------
  75 |            [:input {:placeholder "Username"
  76 |                     :value       username
  78 |                     :on-change   #(rf/dispatch-sync [::changeusername (.-target.value %)])}]
-----------------------------------------------------------------------------------^
 Cannot infer target type in expression (. p1__110681# -target.value)
#2020-10-2212:43thheller@ajarosinski use (.. % -target -value) and the warning should go away?#2020-10-2212:43thheller@ajarosinski use (.. % -target -value) and the warning should go away?#2020-10-2212:58AJ JaroThanks. I couldn’t get this interop to work but I got something similar to get the build behavior to change.#2020-10-2212:59AJ JaroThanks!#2020-10-2212:43thhellersurprised .-target.value even works at all#2020-10-2218:58JAtkinsAny idea how the wrong version of an npm dep would end up used by shadow? I just upgraded sweetalert2 from v9 to v10 in package.json, and I verified that project/node_modules/sweetalert2 contains the published code for v10. I cleared everything from the :output-dir and :asset-path. However, after a shadow restart and compile, I see the code for sweetalert2 v9 in the :output-dir again...#2020-10-2218:58JAtkinsOh, and I did check, ~/node_modules doesn't have any cached version of sweetalert#2020-10-2219:08thhellertry deleting .shadow-cljs/builds. thats the cache maybe something is confused#2020-10-2312:21AJ Jaro@thheller I’ve found this particular flow a challenge when upgrading dependencies as well. It seems like this is required whenever a dependency is changed. Do you know of a better way to ensure the shadow-cljs build is updated when upgrading dependencies other than deleting builds?#2020-10-2313:08thhellerI haven't deleted builds in years so I don't have a clue what you are doing that makes this necessary#2020-10-2313:09thhellerif you have a reproducible case please open an issue#2020-10-2313:09thhellerwhich shadow-cljs version is this?#2020-10-2901:18AJ Jaro@thheller This is in 2.11.4. I’ll try to make a reproducible case so we can investigate further#2020-10-2219:28JAtkinsah, missed that one#2020-10-2219:42JAtkins@thheller many thanks, that worked.#2020-10-2223:39Александр СтояновHello! How can i run backend in re-frame template?#2020-10-2223:41thhellerbetter ask in #re-frame. shadow-cljs only handles CLJS stuff.#2020-10-2309:59victorbTrying to setup some very basic tests via shadow-cljs, but getting Uncaught ReferenceError: tests is not defined on the runner page. My target:
{:target :browser-test
   :test-dir "resources/public/js/test"
   :devtools {:http-port 8021
              :http-root "resources/public/js/test"}}
My test file (in components/searchbar-test.cljs)
(ns components.searchbar-test
  (:require [cljs.test :refer (deftest is)]))

(deftest a-failing-test
  (is (= 1 2)))
Test file is right next to the implementation file, and it's correctly added to the classpath AFAIK (`:source-paths ["src/main"]` defined in shadow-cljs config) Running the tests with npx shadow-cljs watch test
#2020-10-2310:15thhellermy guess is that you have custom index.html in resources/public/js/test that calls tests.something in a script?#2020-10-2310:15thhellerits not shadow-cljs doing this#2020-10-2310:18victorbHm, not as far as I know, all I did was the target+test file above. Seems something went wrong while I was first setting it up, removing resources/public/js/test and restarting the watcher for the tests solved the problem. Thanks once again#2020-10-2313:29frankitoxAlright, someone here trying the WSL2 + react-native combo? Or at least only WSL2?#2020-10-2313:29frankitoxAlright, someone here trying the WSL2 + react-native combo? Or at least only WSL2?#2020-10-2313:29frankitoxI can't shadow-cljs to connect to my device (getting websocket connection error through port 9630). I've been following this https://gist.github.com/bergmannjg/461958db03c6ae41a66d264ae6504ade which tells you to forward port 8081 from Windows to WSL (for the Metro server), so I tried to do the same for port 9630 without luck. Is there any other port I should forward? Is there any way to use other protocol instead of websockets? Although there's the possibility this is a WSL2 bug, I found a related message in https://clojurians-log.clojureverse.org/shadow-cljs/2020-01-27.#2020-10-2313:44thhellerI don't have a clue about the react-native bits but if you have shadow-cljs running in WSL2 then the port it is using must be reachable by your mobile#2020-10-2313:44thhellerits only port 9630 (or 9631++ if those are used)#2020-10-2313:46thhellerusually a good first step is just opening the browser on the mobile and trying to access the website on 9630#2020-10-2313:46thhelleronce you have that going and working getting it to work in your app should be straightforward#2020-10-2314:45frankitoxThank you!! The suggestion to open the browser on mobile really helped me. The problem was that the shadow-cljs server and the phone live in different subnets.#2020-10-2314:45frankitoxThe subnet for Win + WSL2 is 172.17.134.96/28 , Win using 172.17.134.97 and WSL2 using 172.17.134.106. The subnet for Win + phone is 192.168.0.0/24, Win using 192.168.0.193 and the phone 192.168.0.133. So to solve it I had to: 1. Forward 192.168.0.193:9630 -> 172.17.134.106:9630 (Powershell's command netsh interface portproxy add v4tov4 listenport=9630 listenaddress=192.168.0.193 connectport=9630 connectaddress=172.17.134.106). 2. Run shadow-cljs with --config-merge '{:local-ip "192.168.0.193"}' .#2020-10-2408:37nivekuilhow is wasm support nowadays? I think I will try to get https://github.com/antelle/argon2-browser working. I installed it from npm and tried requiring it in cljs, but it looks like something can't even read the wasm magic header: {:line 1, :column 0, :message "Character '\0' (U+0000) is not a valid identifier start char"}#2020-10-2408:40thheller@kevin842 bundling wasm is not supported. you can still use wasm, just not bundle it#2020-10-2408:41nivekuilyeah, but I figured I would try to get it working like in https://github.com/thheller/wasm-pack-cljs#2020-10-2408:41nivekuilor is it still too far away to bother?#2020-10-2408:42thhellerit all depends on the generated JS that comes with the .wasm file#2020-10-2408:42thhellersome works fine out of the box. some will never work.#2020-10-2408:47nivekuilwell, reading the generated JS doesn't seem that bad, being only ￱~￱600 lines prettified, but I wish there were better error messages to even see what's going on#2020-10-2408:54thhellerhttps://unpkg.com/browse/argon2-browser@1.15.2/lib/argon2.js if thats it all the import stuff needs to go#2020-10-2408:54thhelleras well as the require stuff#2020-10-2408:54thhellerthe rest looks straightforward#2020-10-2408:56thhellerah nevermind that wasn't the generated file#2020-10-2408:57thhellerhmm yeah the generated file looks much worse#2020-10-2409:00nivekuilhow so? some of the code in there is for node.js, so maybe that's why.. but I am having trouble even figuring out what to look for, is there a resource?#2020-10-2409:01thhellerI didn't write anything beyond the example repo I made#2020-10-2409:01thhellernot aware of anyone else doing stuff with wasm#2020-10-2409:02thhellerwhat doesn't work is any kind of JS that expects the bundler to provide the .wasm file#2020-10-2409:03thhellerif there is a variant that uses fetch or xhr to load the .wasm file then this variant should be used#2020-10-2409:03thhellerand you just copy the .wasm file somewhere and provide the path (assuming thats possible)#2020-10-2409:03thhellerunfortunately the emscripten generated code is quite terrible and contains a lot of useless loading code#2020-10-2409:04thhellerall this dynamic figuring out which runtime it is in needs to be removed#2020-10-2409:07nivekuilthat's unfortunate.. you think the rust wasm toolchain is friendlier than emscripten?#2020-10-2409:07thhellerlast time I checked it generated better JS yes#2020-10-2409:08thhellerits been a while since I looked at it though and it was completely different the time I checked before that#2020-10-2409:11thhellerdon't think the "standard" for this is any further along too#2020-10-2409:11thhellerso no clue. I only follow casually#2020-10-2409:22nivekuilthis one seems to work out of the box: https://github.com/Daninet/hash-wasm#2020-10-2409:23nivekuilI wonder what the difference is. anyway thanks for the help :)#2020-10-2416:23wombawombaSo I’m trying to upgrade shadow-cljs from 2.8 to 2.11.5, and I’m having some problems. Specifically, my build compiles without errors, but my ‘core’ ns doesn’t get loaded when I open my app in a browser. Instead, I see the following error in the browser:
react_devtools_backend.js:2450 Failed to load foo/core.cljs SyntaxError: Unexpected identifier
    at eval (<anonymous>)
    at Object.goog.globalEval (base.js:577)
    at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:23)
    at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:35)
    at eval (browser.cljs:56)
    at eval (env.cljs:232)
    at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:204)
    at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:240)
    at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:48)
    at eval (browser.cljs:92)
Any idea what might be causing this, or how I can fix it?
#2020-10-2416:28wombawombaOkay I figured it out. I had a function marked as ^:export, and it started working as soon as I removed that keyword. Has ^:export been deprecated, or could there be something else going on?#2020-10-2416:30wombawomba…I assume that ^:export is intended to work, considering that it’s mentioned in the documentation: https://shadow-cljs.github.io/docs/UsersGuide.html#_working_with_optimizations#2020-10-2416:44thheller:export has not been changed. it works just like before.#2020-10-2513:56wombawombaAlright, good to know.#2020-10-2513:56wombawombaAny idea why it would break my code?#2020-10-2513:58thhellernot a clue#2020-10-2514:12wombawombaokay 🙂#2020-10-2419:36afhammadI can't get shadow-cljs to bundle an npm library with a node-script target. I've installed the lib via npm, its in my packages.json, also added a deps.cljs:
{:npm-deps {"xmlhttprequest" "1.8.0"}}
it's required like this:
["xmlhttprequest" :refer [XMLHttpRequest]]
no complaints on compilation but get
Error: Cannot find module 'xmlhttprequest'
at runtime. What am i missing?
#2020-10-2420:03thheller@afhammad node builds don't bundle their dependencies by default since node can just load them from node_modules directly. so either just include the node_modules whereever you are running it or post process the file with something like https://github.com/vercel/ncc#2020-10-2420:04afhammadgot it, thanks#2020-10-2421:29nivekuilis is possible to target specific node￱_￱modules dependencies to be compiled with :advanced? like:js-provider :closure but for specific modules, not the whole app#2020-10-2507:37thheller@kevin842 no. the chances of that working are also extremely slim.#2020-10-2507:53joshkhi have a :node-library build, and i'm attaching a JS runtime by running node out/index.js . whenever an error is thrown in the REPL, say for example from node's http package, the NodeJS process quits and i have to go through the process of restarting/re-attaching everything. is there a way to avoid this?#2020-10-2507:54thhellerhttps://nodejs.org/api/process.html#process_event_uncaughtexception#2020-10-2507:54thheller> Warning: Using 'uncaughtException' correctly#2020-10-2507:54thhelleris why it is not done by default#2020-10-2507:56joshkh> Attempting to resume normally after an uncaught exception can be similar to pulling out the power cord when upgrading a computer. Nine out of ten times, nothing happens. But the tenth time, the system becomes corrupted. i like this simile. thanks for pointing me to the docs.#2020-10-2508:12thhellerbtw if you just want a node-repl you can just use shadow-cljs node-repl. that manages the node process for you.#2020-10-2514:26wombawombaSo I’m trying to include a JS react library in my CLJS project. Unfortunately the JS library includes a bunch of statements that import CSS files, which causes shadow-cljs to complain:
[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
[;...]/foo.css

it was required from
[...]/foo.js

Errors encountered while trying to parse file
[...]/foo.css
  {:line 20, :column 1, :message "primary expression expected"}
Is there a way to get around this?
#2020-10-2514:27thhellermost likely the library expects to be bundled by webpack#2020-10-2514:27thhellerif you can live without the css you can set :js-options {:ignore-asset-requires true} in your build config#2020-10-2514:27wombawombaAlright, I’ll try that as a first step 🙂 Thanks!#2020-10-2515:05wombawomba@thheller so the code compiles fine when I set :ignore-asset-requires. Unfortunately, it still won’t load in a browser, because the JS code contains statements like require('foo.css').use();. Maybe there’s some other way to get this working?#2020-10-2515:09wombawombaLike, perhaps I should be building the JS lib separately somehow instead?#2020-10-2515:14wombawomba…on second thought, I think I’ll just give up for now and run the whole thing from JS in an iframe instead. The library I’m trying to use is just too messy for me to be able to figure out how to call from CLJS.#2020-10-2515:16wombawombaI’d still be curious to hear if there’s a recommended workflow for building pesky JS libs separately though :)#2020-10-2515:20wombawombaAlright, I found this which goes over what my options are: https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2020-10-2515:20thhellerI don't know what kind of library you are using here. never heard of anything doing require('foo.css').use(); before#2020-10-2515:21thhellerthats even uncommon for webpack#2020-10-2515:21wombawombaIt’s here: https://github.com/eclipse-theia/theia/blob/e7a01601db463efeab77f4580ed2f1a7682e08d7/packages/core/src/browser/frontend-application-module.ts#L18#2020-10-2515:24thhellerthat looks like a standalone project and not a library you include?#2020-10-2515:26wombawombaYeah pretty much. There’s some discussion on how to use it as a library here though: https://github.com/eclipse-theia/theia/issues/1045#2020-10-2515:27wombawombaSo I wanted to give that a shot before moving on to other options#2020-10-2610:36wombawombaFor JS libraries (e.g. https://github.com/Microsoft/monaco-editor) that offer multiple approaches to modules (AMD, ESM + Webpack, ESM + Parcel, …), which one should I go with if I’m using shadow-cljs?#2020-10-2610:38thhellerIIRC the last time I tried to use that package myself it tried to do a bunch of dynamic import which shadow-cljs doesn't support#2020-10-2610:38thhellerbut that has been at least a year so no idea what the current state is#2020-10-2610:39thhellerlooks like it still does that crap when it even requires custom webpack config/plugin to use https://github.com/microsoft/monaco-editor/blob/master/docs/integrate-esm.md#2020-10-2610:40thhelleryou can just use the AMD version and manually embed it in the page and not in the actual CLJS build#2020-10-2610:40thhelleror use webpack#2020-10-2610:41wombawombaPhew, that was quick 🙂#2020-10-2610:42wombawombaAnyway great advice, thanks… any reason to pick AMD over webpack or vice versa?#2020-10-2610:44wombawombaActually I think I’ll just bite thee bullet and set up webpack as described in https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2020-10-2610:44thhellerdid you try it without?#2020-10-2610:44thhellerI mean it might work? I don't have a clue#2020-10-2610:45thhellerif you just want an editor in a html page try codemirror. that one works and is used by many people.#2020-10-2610:47thhellerfrom the looks of the ESM docs it seems like it might work#2020-10-2610:47wombawombaI did try codemirror already actually, but I like the look of monaco so I want to see if I can get that one working instead#2020-10-2610:48wombawombaI didn’t try it with shadow-cljs yet, but okay. I’ll see if I can get ESM to work with shadow-cljs and fall back to whichever of ASM and webpack I can get working first 😉#2020-10-2610:49thhellergetting the worker stuff to work will be the tricky part#2020-10-2610:49thhellerbut other than that it seems fine#2020-10-2610:50wombawombaAlright.. out of curiousity, why would the worker stuff be tricky? Because of something the workers do?#2020-10-2610:52thhellerok nevermind it is not going to work. I did a quick test and it is importing css. so webpack it is#2020-10-2610:53thhellerworker stuff just needs to be configured, so it just doesn't work out of the box#2020-10-2610:53wombawombaOkay then 🙂#2020-10-2610:54thhellerAMD also works. then you don't even have to setup webpack.#2020-10-2610:55wombawombaBTW, you wouldn’t happen to have a recommended way of running webpack --watch and shadow-cljs watch? Curious if there’s a way to have both without running two terminal windows#2020-10-2611:01thhellerplenty of ways to do that#2020-10-2611:02thhellerI have used https://github.com/strongloop/node-foreman, https://github.com/mysticatea/npm-run-all and a few others in the past#2020-10-2611:02thhellernowadays I prefer separate terminals for stuff#2020-10-2611:05wombawombaGot it#2020-10-2611:08wombawombaSo I got AMD working, but I decided to see if I could go with https://www.npmjs.com/package/@monaco-editor/react instead to save myself from having to write a bunch of glue code. However, when I try to load that, shadow-cljs gives me the following error: browser.cljs:38 Failed to load my-project/monaco.cljs TypeError: Cannot redefine property: DiffEditor. Do you think there’s a way around this, or should I give up? 🙂#2020-10-2611:08wombawomba(sorry for all these questions BTW, I’m new to the JS ecosystem and it’s absolutely bewildering to me)#2020-10-2611:08thhellerits bewildering for everyone 😉#2020-10-2611:09thhellerdon't know what that error is. don't know what you are doing in your code#2020-10-2611:10wombawombaI’m doing (ns my-project.monaco (:require ["@monaco-editor/react" :refer [Editor]])) and then nothing else#2020-10-2611:10thhellerdon't know what the react package is doing either#2020-10-2611:11thhellerit likely just wraps the ESM package no?#2020-10-2611:11wombawombait seems to use AMD: https://www.npmjs.com/package/@monaco-editor/react#config#2020-10-2611:13wombawombaPerhaps there’s some sort of conflict happening with some other JS lib I’ve previously run? I’ll see if I can reproduce from a clean slate#2020-10-2611:14thhellerit likely isn't worth using the react wrapper#2020-10-2611:14thhellerjust write the 5 lines to do that yourself and save the headache of making that lib work#2020-10-2611:15wombawombaOkay 🙂#2020-10-2619:43Michael Whow can I troubleshoot shadow giving me a stale output error? I see my build running in the web console, with warnings. But when I connect to my app shdow-cljs gives me a stale output error, though the app runs. I cleared my js, and the .shadow-cljs folder and restarted my watch but it still says stale output even though it was forced to recompile everything from complete scratch.#2020-10-2620:28thhellerjust make sure you are loading the correct file#2020-10-2620:28thhellercould be loading an old one from a different path or so#2020-10-2620:28thhellerfrequently happens if you change you :modules config or :output-dir#2020-10-2620:29thhelleror can happen if you have 2 shadow-cljs instances running for your project competing with each other#2020-10-2620:29thhellermake sure there is only one running#2020-10-2713:44amorokhhi all, is there a way to tell shadow-cljs to just download deps?#2020-10-2713:45thhellershadow-cljs classpath will do that#2020-10-2713:45amorokhok, thanks @thheller#2020-10-2715:50thomasHi, I just started my first Shadow project... yeah... and straight after adding my first NPM module I am getting this error: Illegal variable reference before declaration: a any idea what I can do to get rid of this?#2020-10-2717:17tjbHey everyone! Perhaps a dumb question but what is the preferred route to running a full stack (clj + cljs) clojure project? I currently have three directories: client, backend, common which refer to cljs, clj and ‘cljc’ respectively. My client uses shadow-cljs and after doing some reading I noticed that there are two ways to run shadow.  1. Via npm 2. Via lein I’m confused on what is preferred here. I assume with running the client project via npm I would still get access to the repl right?  I also noticed that in lein generated projects the top level directory has a project.clj file and both the client and backend run off of lein. Ive noticed the same thing with luminus too and I am confused what is the preferred route.  It seems like running shadow via npm and the backend clj project via lein would be right but what i mentioned above makes me hesitant that it is the "right way"#2020-10-2717:17tjblet me know if i should be asking this in #beginners !#2020-10-2718:06thhellerI run my backend via lein and all frontend related stuff via shadow-cljs/npm#2020-10-2718:07thhellerthat works well for me#2020-10-2718:07thhellerothers prefer to run everything via lein#2020-10-2718:07thhellerup to personal preference I guess#2020-10-2718:13thhellerI also have only one src/main that houses all .clj/s/c files but namespaced accordingly#2020-10-2718:14thhellerso src/main/acme/project/frontend.cljs etc#2020-10-2718:18tjbword thanks a ton @thheller! my structure is
src/project_name/{client,backend,common}
ok cool im going to go your route since i like it as well. just need to make Calva play nice with it!
#2020-10-2718:22thhellerbtw I never let my editor launch my REPLs#2020-10-2718:22thhellerI only connect to them remotely#2020-10-2718:23thhellerdunno how calva handles things by default#2020-10-2719:00tjbinteresting! i am still fairly new to clojure so i only know of calva or cursive#2020-10-2719:00tjbdo you have other recs?#2020-10-2719:50thhellerI only use cursive#2020-10-2718:06thheller@thomas hard to say without more info. what npm package is causing this?#2020-10-2719:26thomasThe precise error I'm getting is this:#2020-10-2719:26thomas
Closure compilation failed with 1 errors
--- node_modules/ibmcloud-appid-js/dist/appid.umd.min.js:44
Illegal variable reference before declaration: a
#2020-10-2719:55thhellernot a clue. this is an error from the closure compiler. either it is actually invalid code in the library or something the compiler didn't understand properly.#2020-10-2719:55thhellerthe code does look somewhat odd so hard to say#2020-10-2719:57thheller
jsrsasign: a = a,
#2020-10-2719:57thhellerlooks weird#2020-10-2808:42thomasthat is weird indeed. not surprising the Closure compiler is complaining about that.#2020-10-2808:43thomasis there a way to make sure the Closure compiler ignores this code?#2020-10-2808:50thhellerI don't think so#2020-10-2809:16thomasdang#2020-10-2816:40thomasI think I can workaround this for the moment by getting this from the CDN.#2020-10-2815:55mishagreetings! is there a way to access js var foo from js module(?) which does not export it? specifically https://github.com/paulrosen/abcjs/blob/master/src/write/abc_glyphs.js#L21
(:require ["abcjs/src/write/abc_glyphs"]); :refer [glyphs]]
exposes only 1 top-level var:
module.exports = Glyphs;
https://github.com/paulrosen/abcjs/blob/master/src/write/abc_glyphs.js#L234
#2020-10-2815:57mishaI tried every combination from table in https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages with no success#2020-10-2815:58thhellerwhich var do you want to access? in general you cannot access var unless it is part of some exported object#2020-10-2815:59misha1st link:
var glyphs =
#2020-10-2816:00thhellernope can't get that#2020-10-2816:00mishathank you#2020-10-2816:41thomasFor some reason when I change my code the the code in the browser doesn't update.... 🤔#2020-10-2816:42thomasI can see the reload image, but the DOM doesn't change. I only have a inti function.#2020-10-2817:56thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2020-10-2817:56thhellerlike missing a ^:dev/after-load tagged function to do the actual re-render#2020-10-2818:34thomasthat did the trick, thank you @thheller. I didn't see that in any of the examples though I looked at. I must have missed something.#2020-10-2818:49thhellermaybe they have the old style :after-load in the build config https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2020-10-2819:02Michael W@thheller What version did hot-reload change? I have a problem with watching telling me the code is stale even if it compiles from scratch. I have a :devtools :after-load function, and nothing is tagged with ^:dev/after-load in my code. I recently upgraded to the newest shadow-cljs.#2020-10-2819:15thhellerit didn't change. both versions work.#2020-10-2819:35Michael W@thheller I had tried to downgrade and still have the same problem with stale output. Thanks anyways. Any pointers on troubleshooting shadow-cljs processes to find my issue? Still new to clojure and not sure how to find my issue. It seemed to start happening when I upgraded several libs but I have gone back to my last working commit and still shadow tells me I have stale output, even when I completely clear all caches, and see it compile everything from scratch. I also rebooted my laptop just in case there was a process running headless or detached.#2020-10-2820:23thheller@michael819 there isn't much to it. I assure you that you not loading the correct output if you get stale output warnings.#2020-10-2820:23thhellermake sure all your paths are exactly like you expect them#2020-10-2820:24thhellerI mean just delete the output files you think you are working with and reload the page#2020-10-2820:24thhellerif that doesn't give you 404s then you need to track down the files you are actually loading#2020-10-2823:38flyboarder@thheller is there a way to update closure library to a newer version?#2020-10-2823:39thhellerI guess you can kinda make your own release?#2020-10-2823:40thhellershadow-cljs is just using the CLJS-released version which has no new release#2020-10-2823:41flyboarderyeah looks to be a year out of date so far#2020-10-2823:42thhelleryeah its not updated very frequently#2020-10-2900:10thhellerif you need a specific updated file you can just copy it onto your classpath#2020-10-2900:10thhellerdoesn't need to come from the closure lib#2020-10-2910:04David PhamI am using shadow-cljs inspector on localhost:9630, I have been noticing that a few tap> were not caught in the inspector is it normal?#2020-10-2910:06thhellerit should show all taps assuming the UI is actually open and connected. it will miss all if not connected/open#2020-10-2910:08thhellerwell if you tap faster than it can accept it then there is some backpressure that will drop taps#2020-10-2910:08thhellerbuts thats only if you tap like thousands per second#2020-10-2911:59David Phamokay thanks!#2020-10-2913:47amorokhis there a way to make shadow-cljs compile <build-id> produce the same output as a compile during shadow-cljs watch <build-id> does? (wrt to the CLOSURE_DEFINES )#2020-10-2916:10thheller@amorokh watch and compile do set the same closure defines? in as far as that makes sense anyway, watch sets a couple more for REPL related stuff?#2020-10-2916:10thhelleras far as your settings from the build config they are the same?#2020-10-2919:03amorokh@thheller I would like to produce an output that has those exact REPL stuff in CLOSURE_DEFINES , I am serving my SPA from a docker container and would like to serve a client that has shadow-cljs “enabled” (i.e. connects to a REPL)#2020-10-2919:14thhellerI don't get it. for the REPL to work you need a running watch? why do you want compile?#2020-10-2919:18amorokhI might very well be be misunderstanding things here, please let me know if I do#2020-10-2919:20amorokhwhat I want to accomplish is to build a docker image with my server that serves my client (SPA) and when I load the client in my browser I want it to connect to my shadown-cljs watch <build-id> process that I’m running locally#2020-10-2919:20thhellerwould help if you describe what you want/expect.#2020-10-2919:20amorokh🙂#2020-10-2919:21thhellerwhy not just load the output directly? even if just mounted into the docker process?#2020-10-2919:22amorokhso I’m actually running the docker container in a VM somewhere else#2020-10-2919:24thhellerwell whatever you want to do. you need to load the output shadow-cljs has created. however you get it there is up to you.#2020-10-2919:24amorokhthe environment that where the container is running is rather restrictive#2020-10-2919:24amorokhyeah sure, but what I want is to be able to create the same output as the shadow-cljs watch creates#2020-10-2919:25amorokhbut maybe I can execute watch in the Dockerfile?#2020-10-2919:25thhelleryeah that is not possible. you need the output created by the running watch. it won't accept any other output.#2020-10-2919:26thhellerI don't know enough about your setup to make suggestions sorry#2020-10-2919:27thhelleryou can just have shadow-cljs run locally and serve the generated JS#2020-10-2919:27thhellerand in the docker image HTML load <script src=":<port>/js/main.js"> or so#2020-10-2919:28thhellerbut other than that I don't know#2020-10-2919:28thhellermaybe https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support also works?#2020-10-2919:29thhellersorry that one https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy#2020-10-2919:30amorokhok thanks a lot, I will read that#2020-10-2919:30amorokhI might also reconsider how I build my docker image when in debug mode#2020-10-2919:31amorokhthanks again for your swift replies, you’re doing great work with shadow-cljs#2020-10-2921:35amorokhsorry to bother you again but I’m still having some issues, I thought that the [:http :host] settings in shadow-cljs.edn would instruct the client what shadow-cljs HTTP server to connect to to but it seems that it only instruct the HTTP server what ip/dns to listen to, am I missing something?#2020-10-2921:36amorokhto me it seems that shadow-cljs in the client is always trying to connect to the server it was hosted from#2020-10-2922:45thhelleryes that is the default. :devtools-url controls where it connects to if its not the host#2020-10-2922:46thhellerto a lesser extent :devtools {:use-document-host false} if just localhost is ok#2020-10-3005:58amorokhah ok, many thanks again#2020-10-3013:01Jakub Holý (HolyJak)Any tips for troubleshooting when shadow-cljs (2.11.1) gets stuck? I run
$ node_modules/.bin/shadow-cljs watch :main
shadow-cljs - config: /Users/holyjak/Work/customersupport-app/shadow-cljs.edn
shadow-cljs - starting via "clojure"
DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl (/Users/holyjak/.clojure/deps.edn)
DEPRECATED: Libs must be qualified, change mount => mount/mount (deps.edn)
DEPRECATED: Libs must be qualified, change hiccup => hiccup/hiccup (deps.edn)

# now it printed nothing more for minutes...
server has the same issue.
#2020-10-3013:03thhellerfirst guess would be that you have a user.clj that does stuff on load?#2020-10-3013:03thhellerbesides that not a clue#2020-10-3013:03thhellermaybe you need to fix you deps.edn issues#2020-10-3013:05thhellermaybe try running just clj with whatever aliases you might need#2020-10-3013:05thhellerand then (require '[shadow.cljs.devtools.server :as srv]) and (srv/start!)#2020-10-3013:19Jakub Holý (HolyJak)Thank you! Running clj and starting it manually from there worked just fine! 🎉#2020-10-3014:02Sam RitchieHey all... I THINK this is a simple process but just wanted to check in to be sure. I'm moving toward release for https://github.com/littleredcomputer/sicmutils, and want to add a shadow-cljs.edn before I do this#2020-10-3014:03Sam RitchieAm I right in thinking that... maybe this actually has nothing to do with library release, and more / all with developer experience?#2020-10-3014:05thhellerI don't understand the question#2020-10-3014:06thhellera library does not need a shadow-cljs.edn at all and in fact would have no effect whatsoever#2020-10-3014:09Sam Ritchiethat's the reassurance I was looking for! just trying to find my feet#2020-10-3014:10Sam RitchieI hacked up a test profile months ago with lein-doo https://github.com/littleredcomputer/sicmutils/blob/master/project.clj#L71 and I suspect that the testing experience would be way better with shadow-cljs... also I'm finally at a phase where I can start developing UI components off of this work, so it's time to switch. just wanted to make sure I wasn't missing any pieces wrt library#2020-10-3014:11thhellerjust to understand what you are talking about here. you want to bundle everything up as a regular library that people will add to their :dependencies and require in their ns?#2020-10-3014:12thhellerCLJS libs are not compiled at all when doing that. you just include the source files.#2020-10-3014:12Sam Ritchieyes, I didn't know if, for example, there were some other path these days for dependencies, like direct git deps, that needed a shadow-cljs.edn for clojurescript#2020-10-3014:13thhellerthey don't#2020-10-3014:13thhellerthe only place where someone needs a shadow-cljs.edn is in their project. that is the only relevant one. all others have no effect.#2020-10-3014:14Sam Ritchie:+1: thank you!#2020-10-3014:15Sam Ritchieprobably what I should do if I want to enable git deps is move this build to tools.edn
#2020-10-3014:15Sam Ritchiewhich is unrelated to shadow, as you say#2020-10-3014:17thhelleryes, deps.edn is its own thing.#2020-10-3015:46borkdudeI'm getting a warning I don't understand:
------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /Users/borkdude/.gitlibs/libs/borkdude/sci/971614de14a6fd00e6991d1afd6c0ce9fbda104c/src/sci/impl/fns.cljc:51:32
--------------------------------------------------------------------------------
  48 |                           (throw-arity fn-name macro? args))
  49 |                         ret)))
  50 |                   ctx #?(:clj (.assoc ctx :bindings bindings)
  51 |                          :cljs (-assoc ctx :bindings bindings))
--------------------------------------^-----------------------------------------
 Use of undeclared Var sci.impl.fns/clojure
#2020-10-3016:19thhellerodd indeed. looks like the reported location is incorrect#2020-10-3016:21thhellerthis can happen if you have any fully-qualified names in CLJC code that ends up in a CLJS branch#2020-10-3016:21thhellereg. clojure.lang.ExceptionInfo or anything clojure.lang.* really#2020-10-3016:22thhelleryou can maybe look at the generated code looking for clojure. maybe that provides a better clue#2020-10-3016:23thhellerI see a few references that would confuse CLJS. eg ^clojure.lang.Associative ctx so thats most likely it#2020-10-3016:23thheller(.get ^java.util.Map ctx :bindings)#2020-10-3016:24thheller@borkdude ^#2020-10-3016:26borkdudeaha, thanks!#2020-10-3023:53fabraoHello all, is that possible to use shadow-cljs to compile to typescript?#2020-10-3108:48thheller@fabrao no, that would not would make sense since typescript compiles to JS anyways and CLJS is untyped so there would be no difference to JS#2020-11-0123:10afhammadHas anyone come across this error? I get it when running shadow-cljs watch main on a clone of https://github.com/fulcrologic/fulcro-rad-demo
Execution error (IllegalArgumentException) at shadow.build.cljs-bridge/eval14597$loading (cljs_bridge.clj:1).\nNo matching field found: getRegisteredGroups for class com.google.javascript.jscomp.DiagnosticGroups\n"
#2020-11-0123:32afhammad@U05224H0W Thanks for the pointer and link, just had a read. The versions seem to match up with the dependencies listed on the shadow-cljs clojars page.#2020-11-0123:51thhellerthis is a dependency conflict so you need to resolve it. don't know what else to tell you.#2020-11-0123:15thhellerdependency conflict using the wrong clojurescript/closure-compiler version combo#2020-11-0123:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2020-11-0123:28hlolliIt seems to me that the authors of react-date-picker are blindly expecting users to be using css loader. I notice that shadow (rightfully), isn't very happy about that
Failed to inspect file
  /home/hlolli/Documents/visitor/node_modules/react-calendar/dist/Calendar.css

it was required from
  /home/hlolli/Documents/visitor/node_modules/react-date-picker/dist/entry.js
Would override be the good solution here? (solved)
#2020-11-0123:28hlolliIt seems to me that the authors of react-date-picker are blindly expecting users to be using css loader. I notice that shadow (rightfully), isn't very happy about that
Failed to inspect file
  /home/hlolli/Documents/visitor/node_modules/react-calendar/dist/Calendar.css

it was required from
  /home/hlolli/Documents/visitor/node_modules/react-date-picker/dist/entry.js
Would override be the good solution here? (solved)
#2020-11-0123:30hlolliThe line is here https://github.com/wojtekmaj/react-date-picker/blob/master/src/entry.js#L1 But it seems they offer a workaround https://github.com/wojtekmaj/react-date-picker/blob/master/src/entry.nostyle.js so probably solvable without any hacking.#2020-11-0123:33hlolliok ["react-date-picker/dist/entry.nostyle.js" :default DatePicker] solves it, so it's solved#2020-11-0123:48thheller:js-options {:ignore-asset-requires true} will just ignore them. that may or may not work depending on the lib.#2020-11-0212:25bendlasDoes anybody here use cljs.spec.test.alpha/instrument? I just ran into an error, where a var only became instrumented, after deleting .cpcache. Just a restart and regular clean didn't help ...#2020-11-0212:31bendlasadding the ns calling instrument to :cache-blockers should fix it though, right?#2020-11-0212:40thhellerinstrument is a rather difficult beast since it is a macro#2020-11-0212:41thhellerit isn't so much about the ns calling instrument, it is more about ensuring that that ns is compiled after all the namespaces you want to be instrumented#2020-11-0212:41thhellerso the ns calling it should directly require all the namespaces#2020-11-0212:42thhellerso I doubt that .cpcache or any cache really had anything to do with it#2020-11-0212:42thhellerrather you were maybe instrumenting a var that just happened to still be compiling when instrument was already running due to parallel compile#2020-11-0212:42bendlasyou mean "directly" as in "transitively"? because that's what we already did.#2020-11-0212:44bendlasI'm using the no-argument version of instrument, that would instrument all specced vars. After adding the transitively dependent namespace, that also calls instrument, to :cache-blockers, it seems fine ..#2020-11-0212:44thhelleryes if you require transitively then the ns calling the instrument might not recompile#2020-11-0212:44thhellerif you require directly it will#2020-11-0212:45bendlasoof#2020-11-0212:45thhellerso blocking the cache or (ns ^:dev/always this.calls.instrument) works too#2020-11-0212:46thhellersince it is a macro is must be recompiled to reflect the changes done in other namespaces#2020-11-0212:46bendlasok, that's good. because fn-specs are already used pervasively throughout the project, and will be used even more in the future ..#2020-11-0212:46bendlasthanks!#2020-11-0217:55AudriusHello! I wonder how do you debug (with stepping debuger) CLJS code when compiling with shadow? I use Cursive IDE so it would be also nice to find out how that works with debugging.#2020-11-0221:03thheller@stebokas it doesn't work. you can use the chrome built-in debugger a little bit but thats about it.#2020-11-0308:32nivekuilusing a npm package with "main": "dist/index.umd.js" throws some error like Cannot read property 'createGenerator' of undefined , but it works if I use the esm instead. is that expected? can't find any mention of the difference in the user guide#2020-11-0308:34nivekuilalso I think that error only happened in dev, not release#2020-11-0308:52nivekuilthis package also has a "module": "dist/index.esm.js" in package.json which shadow-cljs seemed to ignore, preferring the umd#2020-11-0309:34thheller@kevin842 it is intentional that it defaults to using main. compatibility is much better since not all packages provide module and mixing has been a nightmare in the past. it can work but it largely depends on the packages you use. can't say much about the createGenerator error without more information. you can make it use module via setting :js-options {:entry-keys ["module" "browser" "main"]} in the build config, the reverse is the default.#2020-11-0311:07nivekuilah, nice. didn't see :entry-keys mentioned anywhere. I don't know what createGenerator is doing, but I guess you've seen different behavior with umd/esm? JS packaging seems like a real nightmare#2020-11-0312:57thhelleryes, js packaging is weird and getting weirder every day almost#2020-11-0318:27colinkahnIf i’m using :shadow {:main-opts ["-m" "shadow.cljs.devtools.cli"]} in my deps.edn to watch a build, should I get a REPL after navigating to my app? I remember getting this but haven’t seen it in awhile, and have been having issues connecting my editor and figured this was a good place to start.#2020-11-0318:31thhellerthis never gave you a REPL no#2020-11-0318:33colinkahnOK, I was following the Fireplace instructions via the Guide and when I try doing :CljEval (shadow/repl :my-app) it says shadow isn’t defined#2020-11-0318:34thhellerwell the actual namespace is (shadow.cljs.devtools.api/repl :my-app)#2020-11-0318:34thhellerso wherever you are evaling likely just doesn't have that ns aliased#2020-11-0318:34thhellerit is aliased by default if you are in shadow.user but maybe you are just in user#2020-11-0318:35colinkahnUnfortunately using the full namespace actually creates a REPL prompt as the output, but doesn’t connect my editor 😅#2020-11-0318:35thhellersounds like you are maybe connecting to the wrong nrepl server?#2020-11-0318:35thhelleror you need to load the shadow-cljs nrepl middleware in the one you are connected to#2020-11-0318:36colinkahni’m using :nrepl {:port 51468} in my shadow-cljs.edn, so it should be the right one, since I explicitly connect to that port.#2020-11-0318:36colinkahnWhat’s the nrepl middleware? cider/cider-nrepl?#2020-11-0318:37thhellerif you are connecting to the actual shadow-cljs nrepl server you don't need to worry about it. that will definitely have the middleware configured.#2020-11-0318:38colinkahnAny other suggestions for debugging this? Asking another colleague seems like what we used to use for connecting via emacs isn’t working either#2020-11-0318:39thhellerI can't help with any cider/emacs related bits#2020-11-0318:44colinkahnThe error they’re getting is :missing-nrepl-middleware, so that is something outside shadow?#2020-11-0318:44thhellerthat means you are definitely NOT connected to the nrepl server shadow-cljs provides#2020-11-0318:45thhellerso yeah. either configure the nrepl middleware or connect to the shadow-cljs server#2020-11-0318:54colinkahnconfirmed that I can connect using clj -Sdeps '{:deps {nrepl {:mvn/version "0.8.3"}}}' -m nrepl.cmdline --connect --host localhost --port 33333 , upgrade via (shadow/repl :my-app), so yeah, it seems like an nrepl connection issue. Thanks for taking a look, I’ll try to debug from here.#2020-11-0400:22fabraoHello all, I´m sorry about my dumb question, but is there any way to see the source of clojurescript in browser source?#2020-11-0408:57Elsohttps://github.com/binaryage/dirac#2020-11-0400:22fabraousing shadow-cljs?#2020-11-0402:09fabraoor how to use shadow-cljs with external http server?#2020-11-0402:09fabraoor how to use shadow-cljs with external http server?#2020-11-0409:00ElsoI don't really understand the question. You want an arbitrary server to serve the JS that is compiled by shadow? It should be enough to include the JS in some page then and serve that while running the shadow watch-job. That is not different than using shadow with a Ring webserver and I guess you'll find some tutorials on how to set that combination up.#2020-11-0409:33fabraoHello, I thougth that would be a problem with showing .cljs source in browser#2020-11-0409:33fabraoI´ve read that .cljs source in browser is a shadow-cljs limitation#2020-11-0416:24ElsoEh yeah I think my answer was actually nonsense too - https://stackoverflow.com/questions/60543802/get-sourcemapped-source-place-in-browser#2020-11-0408:57Elso2020-11-04 09:21:57,377 [XNIO-1 I/O-1] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1 How do I turn this off on the shadow-cljs server log? my SLF4J config has an entry <logger name="org.xnio.nio" level="warn" /> but it doesn't seem like shadow reads that.#2020-11-0409:28thheller@d.eltzner012 the logger org.xnio.nio doesn't affect io.undertow so you need to add that too. its your logging setup so you need to configure it.#2020-11-0416:37Elsowoops sorry, I'm blind. actually was not "my logging setup" in that someone else set it up and I didn't find the time to deal with it yet. sorry to bother with that#2020-11-0409:30thheller@fabrao I do not understand the questions. you can use any webserver you want. just serve the generated .js files like any other static file.#2020-11-0410:03fabrao@thheller Sorry, I thougth that custom server would be a problem about not showing `.cljs` source in browser. Now I know that is a shadow-cljs limitation#2020-11-0410:04thhellerI do not know what you mean by "showing .cljs source in browser"#2020-11-0410:05fabraosource map, that you can see the clojurescript source in browser#2020-11-0410:05thhellerthat works completely fine with shadow-cljs#2020-11-0410:05fabrao🤔#2020-11-0410:05thhellerthe only thing you have to watch out for is setting the correct :asset-path in your build config#2020-11-0410:06fabrao
:output-dir "resources/public/js"
                :asset-path "/js"
#2020-11-0410:06thhellerassuming you load your JS via <script src="/js/main.js"> that is correct yes#2020-11-0410:07fabraoyes <script src="/js/main.js" type="text/javascript"></script>#2020-11-0410:08thhellerok looks fine#2020-11-0410:08thhellerdo you get warnings/errors when loading the page about missing source maps? otherwise it should just work (assuming you are talking about watch or compile builds)#2020-11-0410:09thhellerrelease does not have source maps enabled by default#2020-11-0410:09fabraothheller/shadow-cljs {:mvn/version "2.11.2"}#2020-11-0410:09thhellersource maps have worked forever so shadow-cljs version doesn't matter much. this is fine.#2020-11-0410:10fabraois there any pre-version for this/#2020-11-0410:10fabrao?#2020-11-0410:10thhellerwould help if you described what you expect to work and doesn't work as expected#2020-11-0410:11fabraoif I got any error, it shows up into .cljs not in .js#2020-11-0410:11thhellerassuming that error actually occured in CLJS that should work fine#2020-11-0410:11fabraoit only show by .js#2020-11-0410:12fabraoIf I go to sources from browser, do I have to see the .cljs over there?#2020-11-0410:12thhellerbut you said something about external webserver? did you make sure that server does serve source maps correctly?#2020-11-0410:12thhelleryes CLJS sources should be listed#2020-11-0410:13thheller/js/cljs-runtime/cljs/core.cljs for example#2020-11-0410:13fabraoit´s pedestal from lacinia graphql, and I included the part about serving other stuffs#2020-11-0410:13thhellerwell just open the webpage in chrome or whatever with the devtools open#2020-11-0410:13thhellerit should complain if it fails to load source maps#2020-11-0410:14fabrao#2020-11-0410:14thhelleryou can also just try loading (or whatever port you are on) to see if its served correctly#2020-11-0410:14thhelleryeah looks like source maps are missing#2020-11-0410:15fabraoyes, in that url took a map to download#2020-11-0410:16thhellerit should be served with application/json mime type#2020-11-0410:16thhellermaybe you need to configure that in your webserver#2020-11-0410:17fabraoI tried with other samples, and it happens the same problem#2020-11-0410:18thhellerbut the browser should be giving you a warning about this too#2020-11-0410:19fabrao#2020-11-0410:21fabraoI tried in Edge and it works 🤔🤔#2020-11-0410:21fabrao#2020-11-0410:21thhelleryeah no clue. looks fine.#2020-11-0410:21fabraoin Chrome it´s not working#2020-11-0410:22fabraoWTF?#2020-11-0410:22fabraolol, I got 2 days trying to figure it out#2020-11-0410:22thhellermaybe you have a bad service worker running or so? some bad cache?#2020-11-0410:22thhelleror maybe some browser extension messing with things?#2020-11-0410:23fabraoI can bet it would be McAfee AV#2020-11-0410:24fabraoman, that´s insane#2020-11-0410:26fabraoFirefox is ok too, the only problem is that with McAfee WebAdvisor#2020-11-0410:44thhellerno clue. never used that.#2020-11-0410:51fabraothank you for your time !!!#2020-11-0418:07Rico MeinlIs there any way to disable the hot reloading for target :chrome-extension? I tried :devtools {:autoload false} and it didnt work#2020-11-0419:34thhellermight be a bug if that doesn't disable it. why do you want to disable it?#2020-11-0419:38thhelleryeah looks like its hardcoded to be enabled https://github.com/thheller/shadow-cljs/blob/ad8ea9d4aefc5d1c0ab371613a9c96c17da3d447/src/main/shadow/build/targets/chrome_extension.clj#L84#2020-11-0419:40Rico MeinlCause it messes up the reloading of my chrome extension. If I use compile after every code change it works, but the watch inserts multiple instances of the content script#2020-11-0419:40Rico MeinlCould you make it a variable? #2020-11-0419:45thhellersure#2020-11-0419:46thhellerwhy does it insert multiple instances? its your code doing that no?#2020-11-0419:48Rico MeinlYeah it is. I'm trying to set it up in a way that I don't have to reload the web page for every code change. If it works with the auto load to false I'm happy to share the setup. It would make the chrome extension development 10x faster #2020-11-0419:50thhellershould be fixed in 2.11.7#2020-11-0509:47Rico MeinlThanks a million. Seems to work now#2020-11-0507:50b4is there anybody know how to find a clue of this error? #2020-11-0507:50b41. npx create-cljs-project test-project 2. yarn add react react-dom 3. add reagent 1.0.0 into shadow-cljs.edn 4. shadow-cljs server error: [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}] [:failed-to-compare "16.13.0" "16.13.0" #error { :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null" :via [{:type java.lang.NullPointerException   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}] :trace [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14944 invoke "npm_deps.clj" 46]  [clojure.lang.Delay deref "Delay.java" 42]  [clojure.core$deref invokeStatic "core.clj" 2320]  [clojure.core$deref invoke "core.clj" 2306]  [shadow.cljs.devtools.server.npm_deps$fn__14943$fn__14946 invoke "npm_deps.clj" 52]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]  [shadow.cljs.devtools.server.npm_deps$main$fn__15031 invoke "npm_deps.clj" 223]  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]  [clojure.lang.LazySeq sval "LazySeq.java" 42]  [clojure.lang.LazySeq seq "LazySeq.java" 51]  [clojure.lang.RT seq "RT.java" 535]  [clojure.core$seq__5402 invokeStatic "core.clj" 137]  [clojure.core$seq__5402 invoke "core.clj" 137]  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.core$apply invokeStatic "core.clj" 669]  [clojure.core$apply invoke "core.clj" 660]  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.core$apply invokeStatic "core.clj" 665]  [clojure.main$main_opt invokeStatic "main.clj" 514]  [clojure.main$main_opt invoke "main.clj" 510]  [clojure.main$main invokeStatic "main.clj" 664]  [clojure.main$main doInvoke "main.clj" 616]  [clojure.lang.RestFn applyTo "RestFn.java" 137]  [clojure.lang.Var applyTo "Var.java" 705]  [clojure.main main "main.java" 40]]}]#2020-11-0507:55b4and i used shadow-cljs and i install & remove so many program even kernel .. after that it is not working anymore. im trying to find a reason. but dont have a clue.#2020-11-0509:00thheller@b4 which java -version do you use? and which shadow-cljs version?#2020-11-0509:01b4java version is openjdk 15.0.1 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)#2020-11-0509:02b4shadow-cljs 2.11.7#2020-11-0509:02thhellerdo you use project.clj or deps.edn? or just shadow-cljs.edn?#2020-11-0509:03b4only deps.edn#2020-11-0509:03thhellerand you have that shadow-cljs version in deps.edn?#2020-11-0509:04b4no.#2020-11-0509:09b4i found adding cljs-ajax into shadow-cljs.edn's dependencies is working but reagent and re-frame is not.#2020-11-0509:10thhellerno means you don't use deps.edn right?#2020-11-0509:11b4ok. i have test two project. 1st is with deps.edn 2nd is make a project "npx create-cljs-project test-project" that is don't use deps.edn.#2020-11-0509:12b4both has same error.#2020-11-0509:12thhellerI'm asking because jdk15 removed nashorn. so if you are not actually on the version you listed above that would cause the error.#2020-11-0509:12thhellerie. if you are on an older version. which version is listed when you start shadow-cljs?#2020-11-0509:15b4i can't find anything when i exec shadow-cljs server. could u tell me how can i check?#2020-11-0509:16thhellerit is listed when you start it#2020-11-0509:16thhellershadow-cljs server then it will print shadow-cljs - server version: <version> running at on startup#2020-11-0509:17b4shadow-cljs - HTTP server available at http://localhost:9999 shadow-cljs - server version: 2.9.10 running at http://localhost:9630 shadow-cljs - nREPL server started on port 9100#2020-11-0509:17thhellersee that is an old version#2020-11-0509:18thhellerdo you maybe have an older shadow-cljs global install?#2020-11-0509:18thhellertry npx shadow-cljs server or npm install -g shadow-cljs#2020-11-0509:23b4it is working.!!! thanks very much.#2020-11-0509:25b4and thanks for ur shadow-cljs!#2020-11-0513:08austinbirchDoes anybody know if there is a way to evaluate forms from the REPL in the context of a web-worker module? I have my main application loading my web-worker module (setup with :web-worker true in shadow-cljs), but the web-worker keeps some state in an atom that I don’t think I can access from the REPL currently?#2020-11-0513:33victorb#2020-11-0513:34victorbAlternatively, write your web-worker in a way that you can either run it embedded in the page or as a proper web worker, so in development you run it in the same scope as the web app itself, and you can use the repl normally. When you wanna release/deploy, make the embedded web worker into a proper one where you use postMessage to communicate#2020-11-0513:46thhellerweb workers can open websockets just fine which is the only things the shadow-cljs REPL needs#2020-11-0614:04austinbirch@UEJ5FMR6K yeah, that’s the other alternative. I have avoided that so far just because the postMessage boundary between the worker and the main thread keeps me honest (ha!), and gives a good indication of the general performance characteristics for the release build. I do something similar though when working on the worker from the REPL - I sometimes just load the namespace into the main thread, work on it in pieces in a REPL-driven way, then once I’m done saving the file updates the code in the worker context.#2020-11-0513:44thheller@austinbirch you can REPL in the webworker just fine but no editor currently allows you selecting the runtime to eval in#2020-11-0513:44thhellerone way you can is using the UI. just tap> something in the worker and it will show up in the web UI inspect#2020-11-0513:44thhellerthat has an eval window#2020-11-0513:45austinbirchAh, right - that makes sense.#2020-11-0513:48austinbirchThe actual problem I was having was that I’ve fallen into a more REPL-driven workflow, and that stopped working for the web worker. Not really a big deal though - I can just lean on the hot reloading and tap> / js/console.log or whatever. Thanks for the help.#2020-11-0513:49thhelleryou can do the REPL workflow in web workers just fine#2020-11-0513:49thhellerBUT when you open a website with code using a worker you'll have two completely separate runtimes#2020-11-0513:49austinbirchNot redefining functions etc from Cursive though? Ends up defining the functions in the ‘main thread’ rather than the web worker context?#2020-11-0513:49thhellerone is the regular webpage and one is the worker. they don't share anything#2020-11-0513:49austinbirchYeah, that’s it.#2020-11-0513:50thhellerso when you eval stuff you need to "select" which runtime you actually want to work in#2020-11-0513:50thhellerand that is unfortunately not supported by any editor at the moment so it is kind of clunky to do#2020-11-0513:50austinbirchThat’s fine, I’d rather keep the REPL working for the regular webpage and just use reloading + tap> for the worker context. It’s not that bad of a tradeoff, still a nice workflow.#2020-11-0513:53austinbirchIf editors added support for selecting the runtime then I’d probably use that, but it’s not a huge problem.#2020-11-0513:56sbWhat is the best practice to use circleci with shadow-cljs? is there any example of config (shadow-cljs project > config.yml)? Thanks!#2020-11-0514:04thhellerto do what exactly? you can just run the normal commands#2020-11-0514:06sbI would like to learn from others how they create the .yml file etc (avoid fails, faster learning curve etc). Nothing extra#2020-11-0514:09thhellerI also have it setup for shadow-cljs itself#2020-11-0514:09thhellerhttps://github.com/thheller/shadow-cljs/blob/master/.circleci/config.yml#2020-11-0514:09thhelleralthough that first uses lein to do stuff since I can't use shadow-cljs only after I have built it so it should be an unconventional setup#2020-11-0514:04victorb@sb example config for a project I'm working on: https://github.com/instantwebsite/dashboard/blob/master/.circleci/config.yml (fairly trivial stuff though)#2020-11-0514:05sbthank you very much ! that is really cool example!!#2020-11-0514:06victorbif you want the compiled output, just add another npx shadow-cljs compile step + archive_artifacts#2020-11-0514:27austinbirch> Just `tap>` something in the worker and it will show up in the web UI inspect > that has an eval window @thheller I’ve just used the Inspect UI for the first time… wow! This is so great! Thanks so much for your work on this, it’s really really helpful. Today has been a good developer tooling day for me; I’ve been trying out https://github.com/jpmonettas/flow-storm-debugger and it’s pretty smart, and now I’ve got Inspect to use as well.#2020-11-0516:49bennyafter shadow’s dev server reloads my app, the dom appears to be reset to this:
<html><head></head><body><input type="text" name="history_state1" id="history_state1" style="display:none"></body></html>
why isn’t it at a very minimum using the static html page i have for the react container?
#2020-11-0517:25thhellerthis is not shadow-cljs doing that#2020-11-0517:25thhellersomething in your code (or libraries) is responsible for that#2020-11-0517:26thhellerlooks like you might be initializing goog.History multiple times. that does that IIRC.#2020-11-0518:36bennythank you so much! that was it#2020-11-0612:52mauricio.szaboHello there! Is there a way to get how a specific dependency is being pulled on shadow-cljs? Specifically, something like lein deps :tree or similar#2020-11-0612:53thhellerthere is a rough version in shadow-cljs info#2020-11-0613:00mauricio.szaboAh, ok, thanks. Turns out Pathom was being pulled by shadow-cljs itself 🙂.#2020-11-0613:03thhellerindeed#2020-11-0618:41Clément RonzonHi guys, I am developping a SPA using re-frame and I have a question about shadow-cljs + karma + coverage. In my edn file I have a :karma-test under :build which is like this:
:karma-test   {:target    :karma
              :ns-regexp "-test$"
              :output-to "target/karma-test.js"}
What I understand is that Shadow is going to compile all my cljs files, from src/ and test/ into that target/karma-test.js file. I'd like to report test coverage using karma's coverage plugin but for that, I need to have the sources and the test in separate files, right? If I add this to my karma config file, it runs into a loop:
preprocessors: {
            'target/karma-test.js': ['coverage']
        },
Was anyone successful at running coverage report? (FYI I'm quite new at using clojure/clojurescript/shadow-cljs)
#2020-11-0618:44Clément RonzonHere is the output of the "loop" I mentioned:
<--- Last few GCs --->

[743:0x2e177e0]    27020 ms: Scavenge 1365.5 (1423.5) -> 1364.7 (1424.0) MB, 2.0 / 0.0 ms  (average mu = 0.300, current mu = 0.273) allocation failure 
[743:0x2e177e0]    28513 ms: Mark-sweep 1365.6 (1424.0) -> 1362.4 (1423.5) MB, 1490.8 / 0.0 ms  (average mu = 0.392, current mu = 0.459) allocation failure scavenge might not succeed
[743:0x2e177e0]    28518 ms: Scavenge 1363.3 (1423.5) -> 1362.5 (1424.0) MB, 2.6 / 0.0 ms  (average mu = 0.392, current mu = 0.459) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x1246665bf1d]
    1: StubFrame [pc: 0x1246661b535]
Security context: 0x0e367139e6c1 <JSObject>
    2: builder(aka builder) [0x3a525ca3dcf1] [/app/node_modules/@babel/types/lib/builders/builder.js:~16] [pc=0x12466a63ad1](this=0x287b09c026f1 <undefined>,/* anonymous */=0x3841126a8a69 <String[14]: ObjectProperty>)
    3: arguments adaptor frame: 3->1
    4: valueToNode(aka valueToNode) [0x358fe6fb6809] [/app/node_modul...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x8fb090 node::Abort() [node]
 2: 0x8fb0dc  [node]
 3: 0xb031be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb033f4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xef7452  [node]
 6: 0xef7558 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
 7: 0xf03632 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0xf03f64 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0xf06bd1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xed0054 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
11: 0x117012e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x1246665bf1d 
Aborted (core dumped)
#2020-11-0619:46thhellersorry, don't know anything about karma/coverage stuff/#2020-11-0620:32Clément RonzonThe only thing that is missing so coverage can run is to have the sources separated from the tests. Right now they are regrouped in the same file kamra-test.js. I would really appreciate if you could help me figuring out how to separate them please?#2020-11-0620:39thhellerI do not understand what you mean by separate#2020-11-0620:42thhellerI have not used karma coverage so I don't have the slightest clue how it works or what it expects#2020-11-0620:42thhellerif you point me to some documentation I can take a look#2020-11-0620:44Clément RonzonSure, this is the doc: https://github.com/karma-runner/karma-coverage#basic In particular:
preprocessors: {
      // source files, that you wanna generate coverage for
      // do not include tests or libraries
      // (these files will be instrumented by Istanbul)
      'src/**/*.js': ['coverage']
    },
We want the source files to be separate from the test files.
#2020-11-0620:46thhelleryou can try using a :npm-module build but I have my doubts that changes much#2020-11-0620:46thhellerbut that has each ns is its own file#2020-11-0620:47Clément RonzonOk thx, I will try!#2020-11-1622:45Clément RonzonHi @thheller, I've spent a good amount of days trying and searching for alternatives, in vain. How feasible would it be to have the :browser-test target generating 2 js files? - one with only the namespaces from the sources - one with the tests and all the rest Having this, it would be extremely easy to run test coverage.#2020-11-1710:17thhellersorry I don't understand what that would accomplish#2020-11-1716:28Clément RonzonNo worries, let me explain: The code that needs to be analysed, in terms of coverage, has to be in a separate file from the rest of the code (tests, libraries etc.) so we can specify it in Karma's configuration (`preprocessors: 'path/to/code/to/analyse/*.js': ['coverage']`) (see https://karma-runner.github.io/0.8/config/coverage.html). This way Karma's coverage "knows" what js files are to analyse v.s. what js files are testing that code. Currently, the :karma target dumps all the js code into a single file which makes it impossible to run the coverage module with any accuracy.#2020-11-1716:31thhellerI don't understand the last argument#2020-11-1716:32thhellerhow does it get more accurate with multiple files? I presume it uses source map to map the code which will point back to the original sources?#2020-11-1716:32thhellerwhy does it matter that there multiple and not one file?#2020-11-1716:32thhellerplease point me to technical docs explaining why if there are any?#2020-11-1716:33thhellerI simply do not know enough about karma to make any technical decisions but what you are asking does not make sense to me in a build sense. I told you before to use :npm-module if you want one file per namespace. that is the best I can offer?#2020-11-1716:34thhelleryou can create a reproducible example repo with something that doesn't work so I can take a look#2020-11-1716:34thhellerbut so far I don't have enough information to make more suggestsions#2020-11-1716:35Clément Ronzonhttps://karma-runner.github.io/0.8/config/coverage.html#2020-11-1716:35Clément RonzonIn the section "Preprocessor"#2020-11-1716:35Clément RonzonThere is a BAD example#2020-11-1716:35Clément Ronzon> In this example also JASMINE and JASMINE_ADAPTER get included but they shouldn't as these file are only for the test setup used and not for your program.#2020-11-1716:36Clément Ronzon> If you include these files there can occur side effects like the following, > - a part of the code coverage report will be output in the installation directory of Karma. > - the code coverage rate is reduced unfairly.#2020-11-1716:38Clément RonzonI understand you must have bigger fish to fry and I'd love to be able to propose a PR.#2020-11-1716:38Clément RonzonI cloned your repo locally but I hadn't enough time to put myself in the code in order to understand where to tweak it.#2020-11-1716:39Clément RonzonPlease, if you could point me into the right direction I would appreciate it!#2020-11-1716:39thhellerthe only thing I can say is that I need a reproducible repo to actually see what is happening before making any decicions#2020-11-1716:39thhellerthe JASMINE line makes so sense to me since that is not something shadow-cljs uses or includes#2020-11-1716:40Clément RonzonI took it as an example, it's valid with any non-functional/production code#2020-11-1716:40thhellerI can't point you in any direction since I still don't have the slightest clue which problem you are actually trying to solve#2020-11-1716:41Clément RonzonOK. Let me create a repo to illustrate the issue#2020-11-1716:41Clément RonzonI'll get back to you in a few days#2020-11-0620:06ro6@thheller I want to improve the ability to switch between repls when working on a browser extension and contribute the improvements back if I get anywhere. Can you give me a push in the right direction? For a first step, I was hoping to set things up so I can iterate on shadow while exercising it interactively from my main project. Guessing :cli or :create-cli builds are my best bet?#2020-11-0620:09thhellernot sure what you mean by :cli or :create-cli?#2020-11-0620:10thhellerand what do you mean by the "ability to switch between repls"?#2020-11-0620:13thhellertechnically the setup expects the editor to do the switching but none is really doing it currently. still need to do a proper writeup of how to do it I guess.#2020-11-0620:56ro6Those are builds in the shadow-cljs repo, I assume they output the npm installable command line tool? Guessing there's also a way to load up and interact with the library code directly?#2020-11-0620:59ro6I've written some code over shadow/repl-runtime-selectto help me switch between repl environments, but the selection is brittle (it depends on the order they start in to know which one I'm picking) and as the runtimes come and go (eg page reload) it doesn't seem like the connection gets maintained consistently, though I could be wrong.#2020-11-0621:00thheller:cli is the code for the shadow-cljs command yes. I do not understand what you mean by "way to load up and interact with the library code directly?"#2020-11-0621:01thhellerwhich library code?#2020-11-0621:01thhellerthe repl-runtime-select is never going to be pretty either way since hacking this together over nrepl is always going to be limited by nrepl#2020-11-0621:02thhellerjust to clarify: what you call "repl environments" I call "runtimes". will make it easier in communication if you use that word please 🙂#2020-11-0621:03thhellerand yes the editor is supposed to pick the runtime it wants to eval in#2020-11-0621:03thhelleror I guess repl client, not limited to "editor"#2020-11-0621:03thhellerif you open the shadow-cljs UI it will list all connected runtimes under http://localhost:9630/runtimes#2020-11-0621:04thhellerthe "vision" is that any client also lists those and you just click whichever one you want to talk do#2020-11-0621:05thhellerthe repl-runtime-select thing is pretty much dead and gone. it doesn't do anything at all anymore these days.#2020-11-0621:05thhelleras you say it was very brittle anyways#2020-11-0621:26thhellerdo you have a plan for how to make it more reliable? I mean I'd do it myself but I can't come up with a cleaner way to do things that don't require changing how the editor handles/presents the REPL interface#2020-11-0700:23ro6No clear plan, just a sense of what I'd like the experience to be. It feels so close, but maybe there's deeper limitations I'm unaware of. Do you tend to hack on shadow standalone, or in active use for developing something else? By "library code", I mean having shadow's build/repl services running and being able to hack on them without restarting the whole command line process to integrate changes.#2020-11-0709:39thheller@robert.mather.rmm I work on shadow-cljs standalone. most of the time using the :browser, :script or :library builds. sometimes just a browser-repl or node-repl. started like https://github.com/thheller/shadow-cljs/blob/master/CONTRIBUTING.md#starting-a-repl#2020-11-0709:41thhellerthere is also a bunch of code in src/repl that may look like tests but arent. each deftest is just an isolated snippet of code I can run via keypress so experiment with specific things#2020-11-0709:42thhellerif you have suggestions for the REPL stuff I'm happy to work through them with you#2020-11-0709:42thhellerit is all a tad more complicated than I prefer right now since I rewrote the REPL from the ground up for shadow.remote https://github.com/thheller/shadow-cljs/blob/master/doc/remote.md#2020-11-0709:43thhellercombining shadow.remote with nrepl has been challenging since it is meant to replace it entirely#2020-11-0709:44thhellerbut I wrote that stuff mostly for the UI. maybe I'll work on the REPL interface there for a bit today#2020-11-0709:45thhellerjust to show how its meant to work#2020-11-0819:14xfyreDoes anyone know what this might mean (React Native)?
(shadow/repl :dev-android)
To quit, type: :cljs/quit
=> [:selected :dev-android]
(def one 1)
=> #object[TypeError TypeError: undefined is not an object (evaluating 'cljs.user.one = (1)')]
I’m pretty certain it was working before, so I don’t quite understand what went wrong and why
#2020-11-0819:59thhellerjust a hunch but looks like cljs.user is undefined. do you get the same error for (ns cljs.user) or so?#2020-11-0820:39xfyreoh, interesting. if I execute (ns cljs.user) before anything else - it starts working#2020-11-0820:40thhellerwhich version is this? there was one 2.10 version that had this problem IIRC#2020-11-0820:40thhellercan't remember which though#2020-11-0820:41xfyre"shadow-cljs": "^2.11.4"#2020-11-0820:42xfyreit’s no big deal, but I was puzzled#2020-11-0820:45xfyre@thheller btw - regarding hot reload questions I had a couple of weeks earlier. I figured out why recompilation messes up React Native hot reload. That’s because the entry point file target/index.js gets rewritten every time - so at first Metro reacts correctly and tries to do a fast refresh, but then, when entry point file gets updated - it just reloads the whole thing. Although I finally got it to work as you suggested, I’m wondering whether it would be possible to prevent the entry point from getting recompiled every time.#2020-11-0820:50thhelleryou should disable any hot-reloading from the metro side#2020-11-0820:50xfyreyes, that’s what I did#2020-11-0820:50thhellerit is not needed and will only get in the way#2020-11-0820:51xfyrebut I’m curious why the entry point file gets recompiled every time#2020-11-0820:51thhellerso you always have the latest code on disk#2020-11-0820:51thhellerI could disable that but then you'd get old versions if you reloaded the RN app#2020-11-0820:53xfyreyou mean this is configurable?#2020-11-0820:53thhellerno it isn't. but it could be.#2020-11-0820:53thhellerbut first I need a convincing reason why it should be 😉#2020-11-0820:54thhellerI mean I can't see a scenarion where metro fast refresh and shadow hot-reload won't conflict with each other and mess each other up#2020-11-0820:55xfyreit might make sense to allow choosing one or the other (I don’t have a strong opinion about this - since I never got fast refresh to work, I don’t know how convenient it is compared to shadow hot reload)#2020-11-0820:57zhuxun2It seems that the extern inference doesn't work well with the go blocks:
(defn f
  []
  (.-foo (clj->js {"foo" 42})))
;; WARNING: :infer-warning

(defn f
  []
  (.-foo ^js (clj->js {"foo" 42})))
;; no warning

(defn f
  []
  (clojure.core.async/go (.-foo ^js (clj->js {"foo" 42}))))
;; WARNING again :infer-warning
#2020-11-0820:57thhelleryeah thats a known issue. go rewrites too much stuff and loses typehints#2020-11-0820:58zhuxun2Is there a way to hide that particular warning?#2020-11-0820:59thhellerI don't know. depends on the actual code. I mean if you actually use clj->js and then access a property that doesn't make sense at all?#2020-11-0821:00thhelleryou should always have as little code as possible in go blocks so ideally you never get to code that has to do this#2020-11-0821:04zhuxun2What I'm actually trying to do is to wrap http://goog.net.XhrIo.send into a channel so that I don't have to do callbacks#2020-11-0821:04thhellerdon't know if there is an open core.async issue about this#2020-11-0821:05thhellerthats fine but you can construct all of it outside a go#2020-11-0821:06zhuxun2but using this channel requires the user code to be in a go-block, right? That's where I have other code that needs type-hinting#2020-11-0821:07thhellerno it doesnt#2020-11-0821:07thhellerI mean waiting on the channel result does yes but not constructing the xhr itself#2020-11-0821:09zhuxun2I think this is what I mean:
(go
  (let [url (.getParameterValue parsed-href "url")]
      (<! (fetch-ch url))
      ;; other stuff
  ))
#2020-11-0821:09zhuxun2yes, fetch-ch itself wont report any warnings#2020-11-0821:09zhuxun2but (.getParameterValue parsed-href "url") will#2020-11-0821:10thhelleryou can make a helper function for that to avoid the . access#2020-11-0821:10thheller(let [url (get-parameter-value parsed-href "url")] ...)#2020-11-0821:10thhellerI know its annoying but so far no one has dared working on the core.async code#2020-11-0821:11thhellerits not something I can work arround in shadow-cljs#2020-11-0821:12thhellerif you don't care about inference you get (set! *warn-on-infer* false) in that file#2020-11-0821:12zhuxun2I see. Yeah I guess that's one workaround#2020-11-0904:14zhuxun2Is there a way to suppress a particular :redef warning?
#2020-11-0904:19zhuxun2OK, Seems like (:refer-clojure :exclude [map]) is more appropriate https://stackoverflow.com/questions/51511643/disable-compiler-warnings-for-a-specific-file-in-clojurescript#2020-11-0916:34mccraigmccraigdo modules work ok with react-native ?#2020-11-0916:57thheller@mccraigmccraig you can declare :chunks {:foo your.components.foo/some-var :bar your.components.bar/some-var} in your :react-native build config#2020-11-0916:57thhellerthat will create a foo.js and bar.js in the :output-dir#2020-11-0916:57thhellerthat you can load at runtime#2020-11-0916:57thhelleruses :modules under the hood#2020-11-0916:58thhellerjust (js/require "./foo.js") somewhere and the result of that should be some-var#2020-11-0917:00mccraigmccraigexcellent - i can have my cake and eat it 😃... is there an idiomatic rn project somewhere that demos config with shadow-cljs for chunks, live-reload etc ?#2020-11-0917:01thhellernot aware of anything public using :chunks. I could never quite get it to work with react-native to actually lazy load it#2020-11-0917:01thhellerdunno if this is still current but it required tuning on the JS side#2020-11-0917:01thhellerhttps://reactnative.dev/docs/ram-bundles-inline-requires#2020-11-0917:02thhellerbut others have reported that it sort of got faster with :chunks#2020-11-0917:02thhellerbut the RAM bundle stuff I never got working and I don't use react-native so I have never built an actual app that uses this#2020-11-0917:05mccraigmccraigok, sounds like i need to build a simple poc with some :chunks#2020-11-0917:10thhellerlooks like status is using chunks. maybe talk to them https://github.com/status-im/status-react/blob/develop/shadow-cljs.edn#L54-L55#2020-11-0917:12mccraigmccraigdyu know anyone who works @ status ?#2020-11-0917:15thhellerhttps://github.com/status-im/status-react/graphs/contributors#2020-11-0917:15mccraigmccraigwell, it looks like status is using a very compatible set of tech to us, so i'll just try out their build 🙂#2020-11-0917:15thhellerpretty sure they are in slack. IIRC I talked to @yenda about :chunks#2020-11-0917:16mccraigmccraigcool - thanks @thheller!#2020-11-1009:19wombawombaI'm trying to import an ES module (https://github.com/otakustay/react-diff-view — via :require [react-diff-view :refer [parse Diff Hunk]]) that shows up as empty (i.e. (js/console.log react-diff-view parse Diff Hunk) gives me {__esModule: true} undefined undefined undefined). Any idea what's causing this or what could be done about it?#2020-11-1009:43wombawombaAlright, I was able to figure this out by importing the library in a REPL. Apparently there was an error due to a mismatch in React versions.#2020-11-1009:48wombawombaFWIW the note at the end of https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages about using a REPL was very helpful. I had originally skipped over it because it's in the default exports section and I wasn't using those — might be a good idea to put it in a more prominent place?#2020-11-1010:12raymcdermottis it possible, (using the support for git in NPM) to rely on a git repo SHA rather than a published package?#2020-11-1010:12raymcdermott[ I can’t find it in the book ]#2020-11-1010:45romdoqAre Shadow-cljs builds intended to be deterministic? I read that the Google Closure Compiler itself is deterministic, but my builds always seem to include large-%age changes to files which haven't changed from release to release (eg cljs.core.js). Looking at the first example in a diff, the differences can be something so trivial as: var p=$CLJS.zh;this.ri=p instead of this.ri=$CLJS.zh 😕 So I'm wondering where the extra entropy in my builds is coming from!#2020-11-1011:04thheller@raymcdermott whatever npm installs will be used and I think you can use something like github:foo/bar#commit instead of a version number. whether that works entirely depends on the npm package though. most of them require a build step so using them from source-only usually doesn't work.#2020-11-1011:06thheller@mel.collins builds are not really deterministic and really can't be if you factor in DCE. any change you make may lead to something in cljs.core staying alive or being removed. :advanced output must be used as one contained unit and cannot be mixed with output from other builds.#2020-11-1011:32romdoq@thheller My intent isn't to split builds in this case - the compiled JS gets committed to git (primarily to enable using the git repo as a dependency elsewhere), and it bothers me that every release has so many changes to the compiled source. Even running shadow-cljs release npm twice in a row produces different output each time, so it's definitely not (only) a DCE thing. It would be nice to have IMO, but if reproducible builds isn't a design goal for shadow-cljs then I can stop concerning myself with it!#2020-11-1012:16thhellerwell here it comes to definitions. reproducible of course that is a goal. 100% binary identical is not. half of the "blame" here also goes to the closure compiler so not much to do about that. the CLJS compiler and macros also use gensym quite frequently so thats also not deterministic.#2020-11-1015:34romdoqFair enough, thanks for the info#2020-11-1020:57oliverHi everyone! I'm currently working through Dmitry Sotnikov's book on Luminus: His approach is to distinguish builds (production, development) by varying the source-paths in order to load code selectively. For ClojureScript he accomplishes this by integrating shadow-cljs with Leiningen. Since I'm using boot (and the shadow-cljs guide seems to discourage integration with lein/boot/cli anyway) I'd like to achieve the same thing using shadow-cljs separately. The guide, however, states “the source path is only specified once in the entire configuration.” So I guess there's no way to include different versions of namespaces for different builds using standalone shadow-cljs. If I want, say, three different flavors of my app with different environment settings, where would I start?#2020-11-1021:02thhelleryou can only do so by using lein or deps.edn. shadow-cljs.edn does not and will not support it.#2020-11-1021:02thhellerI personally don't like that approach and have never used it myself#2020-11-1021:11oliverMany thanks for the quick reply! Given what I've been able to piece together on the Internet I'm not even all that surprised (or disappointed ). Seems this is more opinionated than I thought… Is there any other native way to distinguish between more environments than just :dev and :release? (I know how to set variables for these with :closure-defines, but wouldn't know how to define a third one)#2020-11-1021:12thhellerfirst you need to differentiate between BUILD configuration and RUNTIME configuration. you are most likely talking about runtime configuration which IMHO should not be in the build config at all.#2020-11-1021:12thhellerthat is my approach and that is how shadow-cljs is set up basically#2020-11-1021:13thhellerso I never had a need to define anything other than :dev or :release and as such is not supported#2020-11-1021:13thhelleryou can always use --config-merge to override stuff if you want though which sort of gets you whatever you might need with regards to :closure-defines etc#2020-11-1021:29oliverAlright, I have read that chapter in the guide… in any case: I'm much clearer now as to what's in the cards. (Actually I've never used a build tool prior to my Clojure days, so I'm still trying to figure out the best way of doing things… so far shadow-cljs is the one one I understand best…) Many thanks for your swift help on this occasion (and previous ones)…#2020-11-1021:30thhellerdon't get sucked into too many configuration details. most of the time simple configs are enough for even complex projects.#2020-11-1021:34oliverThanks I'll try to keep that in mind!#2020-11-1022:04darwinAny way to ignore The required JS dependency "<npm-package>" is not available, it was required by ..., I’m porting pretty large js codebase and they seem to be not having using the code in <npm-package> ...#2020-11-1022:06darwinbtw. <npm-package> is a transitive dependency somewhere, I tried to add it by hand, but that leads to another issue with incompatible react versions required by different packages#2020-11-1022:23darwinah, nevermind, it looks like yarn did the right job and installed all npm packages from transitive dependencies, not sure why npm didn’t do that#2020-11-1022:26dpsuttonit kinda sounds like the dependency set is unsatisfiable if trying by hand gives incompatible react versions. i wonder if npm is doing the right thing and yarn is doing a thing that is wrong but relied upon?#2020-11-1022:51darwinnow, I have a different problem, shadow-cljs complains The required JS dependency "use-cannon" is not available but I’m sure it is in node_modules/use-cannon, and package.json there properly points to compiled index.js file#2020-11-1023:03darwinuhmm, I’m not familiar with npm stuff, turned out the package.json contains only module key and has no main key[1]. I renamed module to main and shadow-cljs started working as expected. Quickly googled this[2] Maybe shadow-cljs should warn and fallback to module? [1] https://github.com/pmndrs/use-cannon/blob/cf8a7482ed9eb8dfc2f39a58bec5b8027caee542/package.json#L16 [2] https://stackoverflow.com/questions/42708484/what-is-the-module-package-json-field-for#2020-11-1310:50thhellerbtw I missed this. you can set :js-options {:entry-keys ["module" "browser" "main"]} to make it use module by default. it isn't in the list by default since mixing commonjs and ESM is PITA. in the next release it'll use module last just in case neither browser or main are set.#2020-11-1100:35darwinwell, I have another problem which seems to be over top of my head 🙂 1. npm package use-cannon uses react’s lazy to lazy-load another file relatively from the same package[1] 2. when my app tells react to render component tree, it eventually starts lazy loading that code 3. it ends up calling shadow.js.jsRequire where it fails to resolve module Module not provided using relative name “./Provider-480a0e71.js”, at that point shadow.js.nativeRequires is empty, shadow$provide is empty, shadow.js.files contains 67 items, but does not match the name, there are some use_cannon related items, but not the provider[2] [1] https://github.com/pmndrs/use-cannon/blob/cf8a7482ed9eb8dfc2f39a58bec5b8027caee542/src/index.tsx#L28 [2] https://gist.github.com/darwin/788f7799398b3fd92d77c685d2ae51ea#2020-11-1100:39darwinhttps://box.binaryage.com/shadow-shot-use-cannon.png#2020-11-1109:27thheller@darwin dynamic import is not supported by the closure compiler currently and won't be for the forseeable future. only option is to use a JS packaging tool that does (eg. webpack) via :js-provider :external https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2020-11-1113:42AJ JaroMore recently in Chrome I’m receiving a ton of console messages locally like this. How can I help prevent these issues? > DevTools failed to load SourceMap: Could not load content for http://localhost:3000/js/compiled/cljs-runtime/module$node_modules$date_fns$_lib$addLeadingZeros$index.js.map: Load canceled due to load timeout#2020-11-1113:43darwincan you open that url in a separate tab? does it load properly?#2020-11-1113:51AJ JaroThe view loads properly, but it’s support for sourcemap data in Chrome does not, no.#2020-11-1113:51darwinI’m speaking about this url: #2020-11-1113:52darwinit must load, btw., the default timeout in devtools is 30s#2020-11-1113:44thhellerI'm guessing that you might have too many files in your build?#2020-11-1113:52AJ Jarotoo many files in the build? Is there a limit? Is there a way to improve the web server?#2020-11-1113:54thhellerwhich server do you use?#2020-11-1113:54thhellerI've seen builds with 6000+ files and things start getting weird at that point. technically there is no limit on the shadow-cljs side but browsers starts to struggle (as you are seeing now)#2020-11-1113:56darwinmakes sense, looking at the devtools code, there is also maxConcurrentLoads set to 500, so if you have for example 600 files to be loaded, last 100 will be queued up and wait, but timeout will start counting at the time of submission to the queue#2020-11-1113:56darwinthe timeout is 30s (by default)#2020-11-1113:59darwinhttps://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/sdk/PageResourceLoader.js#L28-L38#2020-11-1114:01darwin#2020-11-1117:56AJ Jaro@U05224H0W I’m using lein ring server#2020-11-1118:09thhellersorry can't say anything regarding that. it should be fast enough but no clue. somewhere your timeouts come from. it isn't from shadow-cljs since the files you are loading are just static files from disk. it is either your browser or the server. might be some browser addon or just too many files. the number of files used in a build is logged after each build in the "Build completed" message. would be useful into to know.#2020-11-1118:10thhellerI never had an issue like this but its also just source map files so they don't have any influence on the functionality of the site itself#2020-11-1113:45thhelleror maybe the webserver you are using is getting overloaded? shouldn't happen with the servers provided by shadow-cljs but I've seen this happen with other "simple" servers#2020-11-1118:12jmckitrickQuestion: I just started on a clj/cljs project where the devs use cursive. I got the backend up and running with cider. The front end is shadow-based, but since they use cursive, they don't need a cljs repl.#2020-11-1118:12jmckitrickWhat does the deps.edn or shadow-cljs.edn need so I can jack in with CIDER?#2020-11-1118:13thhellerwhat does cursive have to do with not needing a REPL? 😛#2020-11-1118:13jmckitrickGood point, lol. But they use static analysis and hot reloading.#2020-11-1118:13jmckitrickCIDER is what I'm used to, including jump-to-def etc with CLJS#2020-11-1118:13thhellercan't answer the cider question sorry. don't have a clue.#2020-11-1118:13jmckitrickHmm. ok.#2020-11-1212:31bendyHey all - I'm in the process of code splitting our single file js into multiple modules. Using the loader works on the home page, as loader/load "module" fetches /js/module.js, however if I load any other page (say /foo/bar) loader/load "module" tries to fetch /foo/js/module.js. How can I ensure that the asset path remains consistent regardless of the url?#2020-11-1212:32thhellerset the correct :asset-path "/js" in your build config. looks like you have :asset-path "js"?#2020-11-1212:42bendy:man-facepalming:#2020-11-1212:42bendydoh, you are correct, thanks!#2020-11-1214:16jkentCan I tell shadow to watch certain npm dependencies? I’ve used yarn link to create a symlink between my cljs project and a js library but shadow is not picking up the new changes to the js library when it recompiles#2020-11-1214:17thhellershadow no longer watches any npm dependencies since that was causing issues on some projects#2020-11-1214:17thhelleryou can touch the package.json of the package to trigger a recompile though#2020-11-1214:18thhellerso if you do that after building the js lib it should work out#2020-11-1214:27jkent@thheller thanks! thats works and it much better than restarting shadow 🙂#2020-11-1216:56darwin@thheller just a follow up, thanks for your insigths, I was able to work around the dynamic import issue by forking the repo and turning it into static import[1], luckily that was the only instance of dynamic import in my npm deps. By looking around I noticed PR[2] in closure compiler, so I guess a support for dynamic imports is imminent upstream [1] https://github.com/darwin/use-cannon/commit/81fb03fda4aaf31b60085ece9118cb02183fce74 [2] https://github.com/google/closure-compiler/pull/3706#2020-11-1217:00thhellernah not really. it'll most likely just be ignored. https://github.com/google/closure-compiler/issues/3707#2020-11-1217:01thhellerI also think it should NOT be supported. it is sort of annoying if libraries do this because they enforce code splitting on you in places where it might not actually make sense for your app.#2020-11-1217:02thhellersure there needs to be a way to do conditional code loading somehow but this is just one of the latest hacks in this area ...#2020-11-1217:03darwinI’d like to open an issue with use-cannon and persuade them not to use dynamic imports so I could eventually return to their official version.#2020-11-1217:04darwinNot sure if I have good arguments though, I’m not familiar with this new JS stuff.#2020-11-1217:12thhellerwell I don't really know why they are doing this so I can't say either#2020-11-1217:12thhellerfrom the looks of it they do it to only conditionally load the Provider stuff when in a context with window#2020-11-1217:12thhellerso presumably the code can also be loaded in a worker where they don't want that code#2020-11-1217:14thhellerbut I don't get why there is import { ProviderProps } from './Provider' and then import('./Provider')#2020-11-1217:14thhellerso I don't really understand what this code is even supposed to do from the bundler perspective#2020-11-1217:16darwinI was also wondering about that repeated ./Provider import, once static, second time dynamic, also that was causing warnings about cyclic dependencies when I was trying to compile the dist files of the package on my machine, because provider imports index again. Anyways, thanks for your points, I will ask them in an issue.#2020-11-1217:16thhellerI'd expect webpack do duplicate content but no clue why anyone would want that#2020-11-1217:17thhellerwould be interesting to see what webpack actually does#2020-11-1217:22thhellerhmm looks like the ProviderProps is just a type so probably a misplaced import that should be in the import type further up#2020-11-1217:22thhellermaybe the typescript compiler removes that import later so it never gets to webpack#2020-11-1217:26darwinfyi, if you wanted to follow this up, please subscribe this issue: https://github.com/pmndrs/use-cannon/issues/132#2020-11-1312:09thhellerdid anyone upgrade to big sur yet? I'd be curious if this issue still exist in the final release. https://github.com/thheller/shadow-cljs/issues/767#2020-11-1314:28rkiouakapologies if theres an easy reachable answer to this (I wasn’t able to find it) — is there a way to reference an environment variable in the dev-http block of shadow-cljs.edn?#2020-11-1314:29thhellertodo what exactly?#2020-11-1314:29rkiouake.g. i want to be able to do something like:
{:nrepl    {:port 8777},
 :dev-http {8280 {:root             "resources/public",
                  :proxy-predicate  foo.bar/proxy-predicate,
                  :push-state/index "baz/index.html",
                  :proxy-url        (or (System/getenv "FOO_BAR_URL") "")}},
...
}
 
#2020-11-1314:29thheller#shadow/env ["FOO_BAR_URL" ""] second value is default if env var is not set#2020-11-1314:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2020-11-1314:30rkiouakah, thank you… i did see that form in your docs, but i thought it had to occur in this block :closure-defines {https://your.app/URL #shadow/env "APP_URL"}`#2020-11-1314:30rkiouakfoolish of me not to try, thanks for the help and love the tool!#2020-11-1314:31thhelleryeah works everywhere. not specific to :closure-defines#2020-11-1317:14jmckitrickSo if I have cider connected to a shadow project and the repl is warning me `No available JS runtime.` yet jump-to-definition is working, what functionality will I be missing?#2020-11-1317:25thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2020-11-1317:29thhellermany cider operations don't actually require eval so they'll work. everything that does eval will need a runtime.#2020-11-1319:29jmckitrickAh, ok. Turns out I figured out the issue. Gotta load the right page 🙂#2020-11-1320:31cap10morganHow can I use a local closure-compatible JS lib? Specifying :libs ["../path/to/lib"] and then requiring it as a namespace doesn't seem to work.#2020-11-1320:32thhellerjust needs to be on the classpath normally#2020-11-1320:32thhellerno extra option required afterwards#2020-11-1320:36cap10morganWith (:require ["sjcl/hmac" :as hmac]) I'm getting:
Execution error (AssertionError) at shadow.build.data/add-string-lookup (data.clj:119).
Assert failed: (symbol? sym)
#2020-11-1320:37thhellerhmm? whats the full stacktrace?#2020-11-1320:37cap10morganand src/sjcl/hmac.js exists#2020-11-1320:37thhellerthis is a file with goog.provide?#2020-11-1320:37cap10morganyes#2020-11-1320:38thhellerthen it should be (:require [sjcl.hmac :as hmac])#2020-11-1320:38cap10morganah ok#2020-11-1320:39cap10morgandoes the FS path need to match the goog.provide value?#2020-11-1320:39cap10morgani.e. goog.provide("foo.bar.baz") need to be in src/foo/bar/baz.js or similar?#2020-11-1320:40thhellerideally yes but it doesn't have to#2020-11-1320:41cap10morgangot it, thanks!#2020-11-1322:21Ronny LiHi everyone, I just stumbled on shadow.markup (https://github.com/thheller/shadow/wiki/shadow.markup) and thought it looked interesting but it hasn't been updated in 2 years. Is anyone here using it in production and would like to share their experience?#2020-11-1409:25thheller@ronny463 I use it in production in some old stuff but I'd consider it dead. you are welcome to fork it but I likely won't be updating it anymore. that being said it works just fine and doesn't really require updates. it works well but the main problem I have with it is having to come up with a name for every single element. that gets kind of tedious after a while.#2020-11-1413:50Ronny LiThanks for your input and for all the great work you do! A few follow-on questions: 1. Is naming every element in shadow.markup more tedious than creating new classes in CSS? I would imagine it can't be worse 2. If you're not using shadow.markup anymore does that mean you've settled on an alternative like garden?#2020-11-1414:49thhellerI'm mostly using tailwind these days. never used garden. the naming issue also is pretty much the same as in other systems like BEM yes. it is comparable in that way and I'd prefer shadow.markup over those systems#2020-11-1414:50thhellertailwind isn't perfect either though. kinda tough to find the "best" system#2020-11-1415:37Ronny LiAh great! Tailwind was actually my alternative 🙂 shadow.markup looks great and honestly close to Tailwind in terms of usefulness but I'll probably go with Tailwind since the project is still active#2020-11-1615:43dehliHi, I have a question about the :node-test target. Should releases using :node-test be minified the same way as :node-script? There’s a bug I’m getting when I run my tests if the code is generated using release . This is the issue for some more context (https://github.com/henryw374/cljs.java-time/issues/8)#2020-11-1615:48thhellerdo you have the build configs you used?#2020-11-1615:59thheller@dehli you can set :compiler-options {:externs ["cljsjs/js-joda/common/js-joda-dup.ext.js"]} in your build config to include the externs it seems to require. not sure why node-script works but node-test does not.#2020-11-1616:02dehliGreat! sorry i didn’t see your earlier message but this was the build config I used https://gist.github.com/dehli/09599a4ed0040f7a03fea22ef02c4c89#file-shadow-cljs-edn I’ll make some more changes to the gist to try and isolate the issue but since it’s just for tests I’m fine doing compile instead of release . Thanks!#2020-11-1616:04dehliAlso thanks for following up on the issue! That helps a lot!#2020-11-1616:04thhellercompile doesn't go through :advanced so it will never have any externs related issues.#2020-11-1618:34Chris JoslynI have an issue where a symbol->symbol map is compiled to a PersistentArrayMap where each keyword appears to be mapped to itself. So when I start with
{:a :b :foo :bar}
the compiler produces
new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);
Seems like a bug, but I am new to shadow. Version used is 2.11.7.
#2020-11-1618:59dpsuttonWhat are you expecting to see? Your bug report seems to include a lot of extra stuff#2020-11-1619:02Chris JoslynMight be better to describe it this way: a get passing this map and one of the keys produces null. One moment. I can clarify with some specific examples.#2020-11-1619:04dpsuttonyeah just a simple code example would work#2020-11-1619:06Chris JoslynSource:
(ns shadow-compile-map.core)

(def ^:private example-map
  {:a :b
   :foo :bar})

(defn demo [k]
  (get example-map k))
Main output:
import "./cljs_env.js";
goog.provide('shadow_compile_map.core');
shadow_compile_map.core.example_map = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"a","a",-2123407586),new cljs.core.Keyword(null,"b","b",1482224470),new cljs.core.Keyword(null,"foo","foo",1268894036),new cljs.core.Keyword(null,"bar","bar",-1386246584)], null);
shadow_compile_map.core.demo = (function shadow_compile_map$core$demo(k){
return cljs.core.get.cljs$core$IFn$_invoke$arity$2(shadow_compile_map.core.example_map,k);
});
I happened to be testing the output in browser, so I have this index.html:
<script type="module">
  import { demo } from "./compiled/demo.js";
  const result = demo("foo");
  console.assert("bar" === result, "The result is %s", result);
</script>
#2020-11-1619:06Chris JoslynInstead of “bar” I get null .#2020-11-1619:06dpsuttonyou're calling demo on the string "foo" which is not in your map#2020-11-1619:12dpsutton(= :foo "foo") will be false#2020-11-1619:14Chris JoslynCopy. I had some bad assumptions about interop re: a different part of the app where this came up. It’s not you. It’s me. Thank you.#2020-11-1618:50Clément RonzonHi guys, I read that one can define a custom :ns-runner for the :browser-test target (https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test). I tried to make my own but it didn't work:
Uncaught TypeError: Cannot read property 'init' of undefined
    at (index):2
My custom runner is a copy of shadow.test.browser and I located it in my test directory. Please can someone help me making this work?
#2020-11-1619:41Clément RonzonI think I got it. The file test-dir "index.html" already existed and contained the call to the previous init (`shadow.test.browser`). I deleted it and recompiled. This is now ok. Too bad this file is not cleaned up on a config change.#2020-11-1703:09zhuxun2Requiring Chroma.js [1] results in a failure to eval the code, with an error that just says "undefined" [1] https://github.com/gka/chroma.js/#2020-11-1703:13zhuxun2Minimal code:
(ns app.chroma
  (:require
   ["chroma-js" :as cm]))
After compilation, refresh the browser and the console gives two errors as shown in the attached picture:
main.js:1672 An error occurred when loading app.chroma.js
  env.evalLoad @ main.js:1672
  (anonymous) @ main.js:1886
main.js:1673 undefined
  env.evalLoad @ main.js:1673
  (anonymous) @ main.js:1886
#2020-11-1710:18thheller@zhuxun2 sorry that is not enough information for me to tell whats going on. how is cm actually used?#2020-11-1804:41mruzekwWhat is the recommended way to split code based on platform for a React Native application? I know there’s custom reader conditionals for .cljc files. Are there any ways to consider? Thanks#2020-11-1811:01thhellerwhat does "split code based on platform" mean? if its just small snippets of code then reader conditionals make sense#2020-11-1811:01thhellerit its actual full namespaces then it might be better to use separate entry namespaces#2020-11-1811:01thhellerI don't use react-native so I don't know what people usually use#2020-11-1814:03rkiouakIs there a way to use shadow-cljs to output a cljs .jar? My colleagues and I were just discussing how to declare, for example, a minimum js dependency version in a cljs generated jar, and it seems like https://clojure.atlassian.net/browse/CLJS-1973 is how we’d plug into our existing build, but I note your comment on this ticket, and am not clear if there is an alternative method for declaring js deps in clojurescript output?#2020-11-1815:14thheller@mrkiouak shadow-cljs does not support creating/publishing .jar files. I use lein to do that. JS deps you declare via :npm-deps in deps.cljs, eg. https://github.com/reagent-project/reagent/blob/master/src/deps.cljs#2020-11-1815:16rkiouakis that compatible with non cljsjs bundled npm libs now? My understanding was that used to require a cljsjs publish#2020-11-1815:26rkiouakah… in testing it i see that it does work without a cljsjs published jar#2020-11-1815:26rkiouakthanks#2020-11-1815:46orestisI’m using the build report functionality and it’s super helpful. I’ve shuffled some modules around and I’m seeing a lot of stuff I did not expect into the “base” module. That is, stuff that are perhaps in a required namespace but not actually used in the entry file. Is there I way I can figure out why they are included and perhaps drop hints to shadow-cljs to move them to another module?#2020-11-1816:14thheller@orestis the logic is always to move dependencies as far "outside" as possible#2020-11-1816:15thhellerif its moved up into base it is likely that you have 2 modules that are separate but depend on c#2020-11-1816:15thhellersince it can't be in a AND b it is moved into the base#2020-11-1816:16thhelleryou requires are the only way to control where stuff goes#2020-11-1816:16thhelleror if you absolutely want one namespace in a specific module you just declare it in the module :entries vector#2020-11-1816:16thhellerthen it will error out if it gets moved out and tell you why#2020-11-1816:27orestisAh, so it’s namespace-level @thheller, right? Not function level like DCE? That makes sense. I will then probably need to split some large namespaces.#2020-11-1816:28thhellerthe config is namespace level#2020-11-1816:28thhellerthe final split is function level#2020-11-1816:29thhellerin the report you'll often find a namespace split into multiple modules#2020-11-1816:30thhellerbut yeah smaller namespaces make for better splits#2020-11-1816:47orestisHm, I expected namespaces into multiple modules but in my case it’s not happening effectively. I’ll dig around more to see what I can do to affect stuff. #2020-11-1816:48orestisJS dependencies might also affect this right? I guess they can’t be split as effectively. #2020-11-1816:50thhelleryeah they'll stay in the module they are required in. never moved further.#2020-11-1822:41Jag GunawardanaHas anyone had any luck using MathJax with shadow-cljs. I’ve done what I normally do (npm install mathjax; and then (:require [“mathjax” :as mj]) …. ) Just keep getting an empty {} when I look at what is in the namespace.#2020-11-1900:44mruzekwIs there a way to alias a namespace per build? So two builds would use the same namespace in the code, but when built are replaced with aliased namespaces#2020-11-1908:50thheller@mruzekw you can set :build-options {:ns-aliases {my.app.foo my.app.bar}}. that will make it use .bar whenever .foo is required in the build#2020-11-1923:41mruzekwNice! Thank you!#2020-11-1909:02thheller@jag I can't tell what is going on but the package doesn't seem to be bundle-able. looks like you are supposed to directly include it via a script tag#2020-11-1909:05thhellerI mean it even has tons of custom instructions for webpack. doesn't even work out of the box there. https://docs.mathjax.org/en/latest/web/webpack.html#2020-11-1909:06thhellerthe mathjax package seems to be targetted for node only#2020-11-1910:07Jag GunawardanaThanks @thheller. Sorry if this was obvious. My JS knowledge needs a bit of a turbo boost.#2020-11-1910:09thhellernot at all obvious. quite the opposite actually.#2020-11-1911:07ingesolHi! I’m having issues making Leaflet work in the build I’m trying to convert. The issue is that some plugin of Leaflet refers to the global L variable that is traditionally exposed by leaflet. The NPM version of leaflet does not expose the global. In another lein project I fixed this by running webpack, with the following tweak:
new webpack.ProvidePlugin({
      // Leaflet markercluster plugin requires global L object.
      L: 'leaflet'
    }),
Is there some way of solving this naturally in shadow-cljs? Seems like I could change my :js-provider, but that would kind of remove the point of moving to shadow-cljs. Maybe create my own cheat where I make a new module that requires leaflet and exposes the global?
#2020-11-1911:54thheller@ingesol :js-options {:resolve {"leaflet" {:exports-globals ["L"]}}} in the build config might do the trick. or just (js/goog.exportSymbol "L" L) with (:require ["leaflet" :as L]) somewhere before the plugin is loaded#2020-11-1911:55ingesol@thheller Thanks! Will try#2020-11-1913:02ingesolworked nicely with that export-globals thing. Tried to find it in the docs, seems undocumented for now?#2020-11-1913:04thhellermight be yeah. very rare thats actually needed.#2020-11-1914:48defaHaving react-native as a target, when I'm connected to "on device repl" (`(shadow/repl :app)`), I'm having a string encoding issue. when using println in the REPL all non ASCII chars are ? any idea on how to fix that?#2020-11-1916:02thheller@defa shadow-cljs uses unicode everywhere so this should be fine. did you try shadow-cljs cljs-repl app directly and check if it happens there too? if so it is your connection to the other REPL#2020-11-1916:49misha@thheller hi, might be useful for you and others: https://akovantsev.github.io/corpus/shadow-cljs this is aggregated slack log on a single page, rather than spread across hundreds of 1-day=1-page files at https://clojurians-log.clojureverse.org/shadow-cljs/#2020-11-1918:24wisemanI must be doing something wrong. I have a simple app build:
{:app
  {:target :node-script
   :output-to "out/server.js"
   :main com.disney.rant-lsp/main
   :compiler-options {:infer-externs true}}
  :test
  {:target :node-test
   :output-to "out/node-tests.js"
   :compiler-options {:infer-externs false}
   ;;:ns-regexp "-spec$"
   :autorun true}}
I do npx shadow-cljs compile app. The app runs fine, until I package it (it’s a VS Code extension). The packaging doesn’t include the .shadow-cljs directory. This used to work, but recently I started getting this:
Error: ENOENT: no such file or directory, open '/Users/wisej041/.vscode/extensions/wdi.rant-1.0.2/server/.shadow-cljs/builds/app/dev/out/cljs-runtime/goog.debug.error.js'
#2020-11-1918:26wisemanI didn’t think I had to include .shadow-cljs; is that correct?#2020-11-1918:39thheller@wiseman you need to run shadow-cljs release app if you want to publish something. compile and watch are development builds only meant to run on the machine they were compiled on#2020-11-1918:41thheller@misha yikes that file is gigantic. doesn't seem very practical to me. where did you get the data?#2020-11-1918:42wisemanthanks, @thheller!#2020-11-1919:25mishaIt is practical, but for staying open in a tab, not for getting open willy-nilly every few minutes :) Data is from scraped second url, clojureverse one#2020-11-1919:26mishaTry doubleclicking words, you’ll see what I mean #2020-11-1920:47isakThe other one is not practical, because it is not 100% indexed by google. I had to download all the files and write a script to find stuff. So for me this one is much better, even if it is a little big.#2020-11-2009:31AronHi, I am running into TypeError: $jscomp.inherits is not a function when I am using a third party dependency (helix), one particular macro from it does it. I already tried to update and restart everything, I also added :output-feature-set :es8 to compiler options and I really wish I could do something that's not just guesswork but actual diagnostic and work. Any ideas?#2020-11-2009:33thhellerwhich shadow-cljs version? this should be fixed for several versions now#2020-11-2009:36AronI never know how to easily read version information. I am used to just add --version after cli commands and they print their version#2020-11-2009:37thhellerit is printed clearly on each startup#2020-11-2009:37thhellershadow-cljs - server version: <version> running at #2020-11-2009:38thhellershadow-cljs info also works but only in limited ways if you use deps.edn or project.clj#2020-11-2009:39Aroni just do a shadow-cljs restart every time i need to start it, so it clear the usually stuck lock file from previous start#2020-11-2009:39Aronit doesn't print anything other than shadow-cljs - config: path/shadow-cljs.edn shadow-cljs - server starting .......................... ready!#2020-11-2009:40thhellerah you are running in the background#2020-11-2009:40thhellerthen its in the .shadow-cljs/server.stderr.log or .shadow-cljs/server.stdout.log#2020-11-2009:40Aronyou told me to do it this way because i was having trouble managing 3 different terminal outputs. It's much better I admit#2020-11-2009:41Aronshadow-cljs - server version: 2.11.7#2020-11-2009:41AronI am not sure this is shadow-cljs issue.#2020-11-2009:42thhellerwell there were several $jscomp related issues that I fixed recently but they should definitely be fixed in 2.11.7#2020-11-2009:43thhellerwould help to have a reproducible example#2020-11-2009:43thhellerwhat is the actual build config you used?#2020-11-2009:44Aronhttps://gist.github.com/ashnur/a46a10fcc1fb153d46339376f4e055fc#2020-11-2009:45Aronnot the tests, the app#2020-11-2009:46thhellerlooks fine except the :output-feature-set :es8 is only in the :release config. I'm assuming the problem you mentioned appears in watch/compile?#2020-11-2009:47thhellerbtw this is old and not needed anymore shadow.remote.runtime.cljs.browser in :preloads. you can just remove it.#2020-11-2009:47Aronok, thanks#2020-11-2009:47AronI will update. And the problem appears in the browser after I compiled and loaded it.#2020-11-2009:48AronDidn't really wanted to do this, but I need class components because of react. I would avoid using them if I knew how, but ..#2020-11-2009:50AronI see what you mean by the config only in the release. That would explain it, I will try in a minute, thanks#2020-11-2009:51thhelleralso in the :release the :modules and :output-dir are exactly the same as outside so you can remove it#2020-11-2009:56Aron😌#2020-11-2009:56Aronthanks again#2020-11-2010:16rickmoynihanI’m assuming it’s known that running shadow-cljs with the latest clojure cli tools appears to print a warning about invoking the clojure cli tools in a (recently) deprecated way: > WARNING: When invoking clojure.main, use -M#2020-11-2010:16thhellerhmm? news to me 🙂#2020-11-2010:17rickmoynihan
$ clojure -Sdescribe
{:version "1.10.1.716"
 :config-files ["/usr/local/Cellar/clojure/1.10.1.716/deps.edn" "/Users/rick/.clojure/deps.edn" ]
 :config-user "/Users/rick/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/usr/local/Cellar/clojure/1.10.1.716"
 :config-dir "/Users/rick/.clojure"
 :cache-dir "/Users/rick/.clojure/.cpcache"
 :force false
 :repro false
 :main-aliases ""
 :repl-aliases ""}
#2020-11-2010:19rickmoynihanok I think the change is basically you now need to invoke clojure.main with clojure -M -m clojure.main#2020-11-2010:19rickmoynihansee here: https://insideclojure.org/2020/09/04/clj-exec/#2020-11-2010:19thhellerwell does that work with older versions? if not then I'm not changing that for a while#2020-11-2010:20rickmoynihanprobably not#2020-11-2010:20thhellerthe command it runs is clojure -m shadow.cljs.devtools.cli --npm ...#2020-11-2010:21rickmoynihansorry yeah you’ll need clojure -M -m shadow.cljs.devtools.cli ...#2020-11-2010:21thhellerI haven't followed tools deps recently so dunno what changed#2020-11-2010:21rickmoynihanA lot#2020-11-2010:23rickmoynihanThe main thing is the new :exec-fn and :exec-args stuff; which is pretty awesome actually… It could be interesting thinking about what it might mean for shadow-cljs… Though I imagine it’s a lot easier to just carry on with shadow-cljs.edn as it is 🙂#2020-11-2010:23rickmoynihaneither way though it may open up some new options for you#2020-11-2010:23thhelleryeah I'm not going to enforce using deps.edn on anyone. I don't use it on a single project of mine either.#2020-11-2010:24thhellerits nice to see its moving forward but its still nowhere near lein for me#2020-11-2010:25thhelleror shadow-cljs for CLJS of course 😉#2020-11-2010:25rickmoynihanI certainly know what you mean… it’ll be interesting to see what happens with tools.build#2020-11-2010:27rickmoynihanbut the :exec-fn stuff at least now provides a way to integrate tooling to build a library and deploy it#2020-11-2010:27rickmoynihanit’s not yet as easy as it should be… but it would be pretty straightforward to make it as easy as lein to do this bit.#2020-11-2010:27thhellersure. if that some day is less than a 5 lines project.clj + lein deploy clojars I might support it 😉#2020-11-2010:32rickmoynihannot less than yet… but it could at least now be made more or less equivalent. I currently have it down to about 30 lines of deps.edn with maybe 4 lines of bash: https://github.com/RickMoynihan/pom-update/blob/37d7bdb0eceb69af0f4796f4b9e7334db3f364a2/deps.edn#L13-L39#2020-11-2010:32thhelleryikes 😛#2020-11-2010:34rickmoynihanIKR… if these libs were integrated together (I’ve done it already in a proprietary project which has slightly more bespoke needs - it could be done as easily as with lein)#2020-11-2010:34rickmoynihangive or take a few LOCs#2020-11-2010:37thhelleryeah its interesting to see work in this area but so far everything looks kinda clunky#2020-11-2010:38rickmoynihanIt’s definitely clunky — but :exec-fn makes things much better and feels like it could well be a decent foundation for new tooling#2020-11-2010:28thhellerbut good thing is I don't have to do anything. everyone can already use it if they want#2020-11-2010:28thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2020-11-2010:29thhellerstill relevant and also still accurate describing why it won't use :exec-fn anytime soon#2020-11-2010:42rickmoynihanYeah I definitely agree with your stance in that article… but I think :exec-fn is still relevant for shadow-cljs. i.e. if the shadow-cljs api defines entry point tooling functions to just be a single map of data, then they can work with :exec-fn, so users have more options for integration.#2020-11-2010:43rickmoynihanSo shadow won’t need to mandate tools.deps and :exec-fn; but it could still be an option for users. Providing perhaps a few reasonable constraints are maintained#2020-11-2010:44rickmoynihanAnyway, as always thank you for your time 🙇 Shall I create a GH issue about the warning for you, just so there’s a record of it?#2020-11-2010:46thhelleryes please#2020-11-2010:57rickmoynihanhttps://github.com/thheller/shadow-cljs/issues/802#2020-11-2012:02defaRegarding character encoding in the repl. I'm connections via repl to a react-native app running on device:
lein repl :connect 9876                                        
Connecting to nREPL at 127.0.0.1:9876
REPL-y 0.4.4, nREPL 0.7.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 1.8.0_265-bre_2020_10_20_12_24-b00
...
shadow.user=> (println "Smørrebrød")
Smørrebrød
nil
shadow.user=> (shadow/repl :app)
To quit, type: :cljs/quit
[:selected :app]
cljs.user=> (println "Smørrebrød")
Sm??rrebr??d
nil
In the "Java REPL" encoding is okay, in the "JS REPL" it is broken... any ideas on how to fix that?
#2020-11-2012:05defaFor me it looks like the JavaScript environment on device uses a different character encoding.#2020-11-2012:12thhellerthat might be. I don't have a clue about react-native sorry#2020-11-2012:13defaIt's a little strange that the JVM "runs" on US-ASCII
lein repl :connect 9876
shadow.user=> (System/getProperty "file.encoding")
"US-ASCII"
despite the fact that -Dfile.encoding=UTF-8 is in the arguments of the java process of lein?
#2020-11-2012:13thhellerah#2020-11-2012:14thhellersomeone had this issue before. I cannot remember the details#2020-11-2012:14defaSo I suspect I should have the same char encoding in the Java world than in the JavaScript world running on device.#2020-11-2012:14thhellerhow is shadow-cljs launched?#2020-11-2012:16defa
shadow-cljs watch app
#2020-11-2012:16thhellerI have a JVM_OPTS environment variable with -Dfile.encoding=UTF8#2020-11-2012:16thhellerand you have :lein true or something in shadow-cljs.edn?#2020-11-2012:16defano#2020-11-2012:17defaI'm using tools.deps#2020-11-2012:17thhellerthen why did you mention is in the arguments of the java process of lein`? `?#2020-11-2012:17defai only start the repl with lein#2020-11-2012:17thhellerright but the shadow-cljs server process needs to have the same encoding#2020-11-2012:17thhellerotherwise that won't work#2020-11-2012:17thhellerso you can set :jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn#2020-11-2012:18defaSame issue/problem with the repl when running in IntelliJ with Cursive#2020-11-2012:18defaI'll try....#2020-11-2012:19defaOf course the US-ASCII is not from the lein-JVM but from the shadow-JVM... stupid me!#2020-11-2012:24defaOkay, thanks, cool. Setting :jvm-opts ["-Dfile.encoding=UTF8"] in shadow-cljs.edn fixed the problem.#2020-11-2012:25defaWhy is it US-ASCII bei default? When I launch clj I get:
% clj 
Clojure 1.10.1
user=> (System/getProperty "file.encoding")
"UTF-8"
#2020-11-2012:27defaAlthough UTF8 works, I guess it should be UTF-8.#2020-11-2013:46Eugenhow can I depend on a local built jar (path to jar) ? I'm working to patch https://github.com/titonbarua/shadow-cljs-gjs-target/pull/2 to allow for Gnome Extension to be built. I need to make [[titonbarua/shadow-cljs-gjs-target "0.1.0"] -> [[ shadow-cljs-gjs-target "0.2.0-gnome-extension-patch"]] I can build the patch locally#2020-11-2013:50thheller@eugen.stan you can run lein install to install it locally#2020-11-2013:51thhelleror in the examples :source-paths you can just direclty include the code via "../../src" and no :dependencies#2020-11-2013:53Eugenthanks, I will try both#2020-11-2013:56Eugenincluding source-paths in shadow-clj.edn of example/gnome-extension.. project does not work (it will not pull the dependencies of that one)#2020-11-2013:56EugenI can use lein install#2020-11-2013:58thhellerhttps://github.com/titonbarua/shadow-cljs-gjs-target/blob/master/project.clj#L6 but it doesn't have dependencies?#2020-11-2023:37Eugen(after nap) Thanks, I was using the wrong path. I can compile and work on the integration now. Made some progress but not quite there yet. It's doable though and we will be able to build GTK apps for gnome shell (Gnome extensions) in ClojureScript#2020-11-2100:23Eugenmy main issue right now is to disable minification for some function: init, enable and disable. gnome shell calls those function to do the work. But the current setup minifies those names.#2020-11-2101:13BuidlerI'm getting
[2020-11-20 20:08:05.240 - INFO] duplicate resource com/fulcrologic/fulcro/mutations.cljc on classpath, using jar:file:/home/buidler/.m2/repository/com/fulcrologic/fulcro/3.4.3/fulcro-3.4.3.jar!/com/fulcrologic/fulcro/mutations.cljc over file:/home/buidler/project/src/app/com/fulcrologic/fulcro/mutations.cljc
But I don't understand why. I want to use my file, not the version in the jar file. Looking at these instructions https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries
#2020-11-2101:43BuidlerI think I got it. Looks like I have to restart shadow-cljs whenever there's a modification.
#2020-11-2110:32thhellerwhich version is this? it should be using the file not in the jar always but that kinda depends on which version you use?#2020-11-2112:19Buidlerthheller/shadow-cljs {:mvn/version "2.8.107"}#2020-11-2112:33thhelleryeah thats rather old. dunno how it was handled back then. try 2.11.7#2020-11-2112:34thhelleralso when you use tools.deps it kinda depends which version you are using there#2020-11-2112:34thhellerthere was a version that didn't sort :paths first#2020-11-2113:15BuidlerShould I be concerned much about a shadow-cljs upgrade breaking my application in some way?#2020-11-2114:56thhellersince the upgrade also involves upgrading CLJS and the closure-compiler that can always happen#2020-11-2114:56thhellerdon't know what you are doing so can't rule it out#2020-11-2114:56thhellerbut most of the time the upgrade is smooth and without issues#2020-11-2101:14Buidler:paths ["src/app" "resources" "src/test"]#2020-11-2101:34EugenI made a Gnome Extension with ClojureScript that does nothing useful !!! thanks @thheller for support 🙂#2020-11-2101:35EugenI need to clean up the code and then submit a proper PR and document it#2020-11-2106:53srihariHey there 👋 I’m building an app that requires an in-browser-evaluator, and so, I’m using the shadow-cljs-bootstrap functionality. I’ve mostly followed the https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html. I’m having trouble creating a release of my app with the bootstrap target. I get a “goog is not defined” error. Works in dev mode. Not sure what I’m missing.#2020-11-2106:53srihariHere’s my project.clj: https://github.com/nilenso/in-browser-evaluator/blob/master/project.clj#2020-11-2106:55srihariI’ve tried setting compile options to :optimizations :simple . That doesn’t work either.#2020-11-2107:00srihariIf I compile app and bootstrap-support separately in dev mode, it works. i.e shadow-cljs compile app bootstrap-support .#2020-11-2110:33thhellerthe app build must use :compiler-options {:optimizations :simple}#2020-11-2110:33thhellerfor release to work#2020-11-2112:48srihariYeah, I tried that as well. I also mentioned that above. Same error, “goog not defined”.#2020-11-2112:49thhellerwell goog is not defined is what you get when it is :advanced and not :simple#2020-11-2112:50thhellerso might have been in the wrong place or had a typo or so#2020-11-2112:52srihariHrm, double checking.#2020-11-2112:56srihariYeah, same error. Not sure what I’m missing: https://github.com/nilenso/in-browser-evaluator/blob/master/project.clj#L30-L45#2020-11-2112:57thhellerassuming you are loading /js/compiled/app.js in your HTML? I mean where exactly do you get that error?#2020-11-2112:58thhelleroh wait .. I know sorry#2020-11-2112:58srihari#2020-11-2112:58thhelleryou also need :output-wrapper false in the compiler options#2020-11-2112:58srihariIn app or bootstrap-support?#2020-11-2112:58thhellerapp#2020-11-2113:01srihari💯#2020-11-2113:01srihariJust read up about the output-wrapper in the user guide as well.#2020-11-2113:02srihariThanks @thheller ❤️#2020-11-2113:02srihariAnd thank you for making shadow-cljs 🙇#2020-11-2113:03srihariMight be worth adding this as a note in the blog post, or in the user-guide, perhaps.#2020-11-2113:03thhelleryeah just added it to the blog post 🙂#2020-11-2113:03srihari👌 that was quick#2020-11-2113:04srihari@thheller while I have you here, another question: I would like the compiler state to be refreshed every time I run eval. Is there a way to do this?#2020-11-2113:05srihariRight now, I’m hacking this by using a different namespace for every eval 😛#2020-11-2113:06srihariBut that hack is coming apart now, so I’d rather fix it the right way.#2020-11-2113:06srihariSeems like I might have to run boot/init to refresh every time?#2020-11-2113:07srihariBut I remember trying that, and not succeeding.#2020-11-2114:54thhellerI don't know what you mean by "compiler state to be refreshed"?#2020-11-2114:55thhellerI mean you can reset the compiler state but that doesn't reset the runtime state so that wouldn't do much#2020-11-2204:47srihariI’m looking for something similar to a repl refresh, I guess. Where the functions/vars not currently in the file aren’t in the registry? I want every “eval-str” to be without the context of the previous eval. So if a function foo was defined with the previous eval, calling (foo) with a new eval shouldn’t work.#2020-11-2209:39thhellerwell as I said you can reset the compiler state#2020-11-2209:40thhellerbut you cannot reset the JS runtime state so you can create (defn foo [] ...) will create cljs.user.foo = function() ... . resetting the compiler state will remove the definition from the analyzer#2020-11-2209:40thheller(foo) will then result in a warning but it eval'd will call the old cljs.user.foo#2020-11-2209:41thhellerwell technically you can also reset cljs.user I guess#2020-11-2210:29lambdamHello everyone, I have a project where I want to have many different CLJS entry points. Instead of having one big webapp, I have a lot of small webapps. If I understand well the docs, the :modules functionality is meant for on big webapp that would be splitted into various chunks. Is it possible instead to have many entry points that would share a common set of namespaces? Thanks.#2020-11-2210:49robert-stuttafordhow do you want code to be shared? do you want all the code in each app's js, or do you want there to be a common js file with all the common bits, and then smaller app js files for each app? you can do big-app-with-lazy-modules and lots-of-apps-that-share-code with :modules; the difference is in how you decide to load code via script tags (one for a big app, or different ones on different pages for lots of apps) / loading GClosure modules on demand (in your big app)#2020-11-2210:47robert-stuttafordis there a way to add a deps.edn dependency and have shadow-cljs load it without having to restart the compiler?#2020-11-2211:11thheller@robert-stuttaford no#2020-11-2211:13thheller@dam :modules allows you to split the code so you only load whatever is needed. if you instead want everything in one file and just use whatever from it you can use (defn ^:export foo []) and then call <script>your.ns.foo();</script> from the HTML#2020-11-2211:13thhellerie. each exported function can be your entry point#2020-11-2212:09lambdamThanks for your answers. I found a workaround that worked for my need. I have it working for dev and prod with the hashed names (for cache buster).
;; shadow-cljs.edn

{:deps true
 :builds {:app {:target :browser
                :output-dir "resources/public/cljs"
                :asset-path "/cljs"
                :release {:output-dir "resources/public/cljs"
                          :module-hash-names 12
                          :build-options {:manifest-name "assets.edn"}}
                :modules {:shared-deps {:entries [myapp.front.shared-deps]}
                          :entry-point-a {:init-fn myapp.front.entry-point-a/main!
                                          :depends-on #{:shared-deps}}
                          :entry-point-b {:init-fn myapp.front.entry-point-b/main!
                                          :depends-on #{:shared-deps}}
                          :entry-point-c {:init-fn myapp.front.entry-point-c/main!
                                          :depends-on #{:shared-deps}}
                          }}}}

;; myapp/front/shared_deps.cljs

(ns myapp.front.shared-deps)

(defn foo [])

;; myapp/lib/compile_time_util.clj

(ns myapp.lib.compile-time-util
  (:require [clojure.edn :as edn]
            [ :as io]))

(defmacro inject-cljs-resource [resource-id]
  (let [env (System/getenv "MYAPP_ENV")
        cljs-dir "public/cljs"
        asset-path "/cljs"]
    (if (contains? #{"prod" "testing"} env)
      (->> (str cljs-dir "/assets.edn")
           io/resource
           slurp
           edn/read-string
           (some (fn [entry]
                   (when (= (:name entry) resource-id)
                     entry)))
           :output-name
           (str asset-path "/"))
      (str asset-path "/" (name resource-id) ".js"))))

;; myapp/server/views/mypage.clj

(defn render-page [req]
  (layouts/render-layout
    (assoc req
           ::vutil/extra-js-deps [(ct-util/inject-cljs-resource :shared-deps)
                                  (ct-util/inject-cljs-resource :entry-point-a)])
    [:div
     [:h1 "Title"]
     ...]))
#2020-11-2220:46Rin AHi, I have a bit of a noob question, sorry... I'm building a webapp, and I'm using shadow-cljs. I'm trying to use google firebase, so I tried npm i --save firebase, and it updates my package.json fine. The firebase docs say to require it in a normal js app using import firebase from "firebase/app"; so as per https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I've imported it using ["firebase/app" :default firebase]. But if I try to use that import with (firebase/initializeApp #js{ ... }) I get the following error: `No such namespace: firebase, could not locate firebase.cljs, firebase.cljc, or JavaScript source providing "firebase"` If I try to require it instead by using ["firebase/app" :as firebase] then if I try to use it with (firebase/initializeApp #js{ ... }) I get the following error instead: #object[TypeError TypeError: module$node_modules$firebase$app$dist$index_esm.initializeApp is not a function] If I look at node_modules/firebase/app/dist/index.esm.js it looked like it was just loading from @firebase. So I try ["@firebase/app" :as firebase] and I get #object[TypeError TypeError: module$node_modules$$firebase$app$dist$index_esm.initializeApp is not a function]. But if I look at node_modules/@firebase/app/dist/index.esm.js it seems like the function would be there. For the heck of it, and to see if I'm understanding how to do this properly, I try installing underscore and importing it as ["underscore" :as underscore] and that totally works. I can go into the REPL and run > (.entries js/Object underscore) and I'll get something that makes sense. But if I try > (.entries js/Object firebase) then I get something a little hard for me to explain:
The result object failed to print. It is available via *1 if you want to interact with it.
The exception was:
RangeError: Maximum call stack size exceeded
:shadow.cljs/print-error!
I think I've probably just made a silly error somewhere, but I don't seem quite capable of figuring it out - does anyone know what I've done wrong in installing and requiring firebase? Also I think this is a shadow-cljs thing but let me know if I'm wrong and this is totally the wrong place to ask...
#2020-11-2221:58thheller@ryielle :as sets up a namespace alias so you can do firebase/doX. :default does not setup up an alias but instead acts like :refer. so you can do (.initializeApp firebase) with :default firebase#2020-11-2223:21Rin AAmazing, thank you so much for this!#2020-11-2311:00grumpletSorry if there’s an obvious answer to this, but I’m seeking reassurance that it’s straight forward to configure generation of ES5 code for older browsers using Shadow. I’m pulling in reframe/reagent and a yet to be decided chart library from npm modules.#2020-11-2311:01thhelleres5 output is the default but the answer somewhat depends on "how old is the browser"?#2020-11-2311:02thhellerie8 will likely require manual tuning which can be done of course 😉#2020-11-2311:02grumpletI may need to add poilyfills, but IE10 would be sufficient. IE9 would hit even the stuck in the mud hospital IT departments#2020-11-2311:03thhellerclojurescript itself will be fine with even ie6. largely depends on the libs you are going to use. some may work some may not#2020-11-2311:04thhellerthere is basic polyfilling in shadow-cljs which is usually good enough but it really depends on the libs you use#2020-11-2311:21grumpletGreat, many thanks. I suppose the unknown for me is whether I will need to postprocess anything outside of the shadow build.#2020-11-2311:22grumpletI’ll suck it and see for a bit.#2020-11-2311:27thhellerunfortunately its impossible to give a concrete answer to this. the various degrees of javascript on npm make this too much of an unknown. not all features can be polyfilled or transpiled so if you end up using those you'll not get far. if you only use conservative libraries with "older" JS then everything will likely just work.#2020-11-2311:41grumpletUseful advice - thank you. So, in case you know off the top of your head - I’m using react-bootstrap and recharts at the moment. React-bootstrap is harder to replace, but I could swap recharts with any reasonable chart lib.#2020-11-2311:42grumpletThose are the only major npm dependencies.#2020-11-2312:40thhellersorry, haven't used either of those. bootstrap is widely used so it should be fine.#2020-11-2313:43recholsknauberHello! Newbie here--what is best practice for organizing/running .clj code in a Shadow app? Does anyone run "shadow-cljs clj-run" programmatically? My specific case involves generating initial HTML files from clj Hiccup, then affecting the resulting DOMs with Reagent.#2020-11-2314:30amorokhHow should I handle css files from npm packages, is there anything in shadow-cljs that causes them to be “copied” to my target dir structure as well as the required js-files? I am quite new to this js-world so apologies if there is an obvious solution (like “don’t use shadow for that”)#2020-11-2315:05thheller@ryanknauber shadow-cljs focuses only on CLJS. for CLJ related things I recommend using lein.#2020-11-2315:05thheller@amorokh shadow-cljs does not handle CSS. you can use something like postcss to handle css#2020-11-2318:07tony.kayI’m trying to use proxy support to deal with some SSL/CORs debugging locally. I’ve used nginx for this in the past, and when I downgrade to 2.8.110 it does seem to work fine. With the latest 2.11.7 everything connects, it downloads the correct js, but then shadow always shows the red error bar saying I’m running stale js. The configuration is: In shadow-cljs, I’m using
:devtools         {:devtools-url "" 
and I’m using an nginx proxy configured as shown here https://www.nginx.com/blog/websocket-nginx/
#2020-11-2318:08tony.kayThe SSL stuff all works perfectly fine (my app functions properly), and the shadow websocket does connect#2020-11-2318:11thhellerhmm just a guess but does the nginx maybe not pass query parameters to the websocket properly?#2020-11-2318:11tony.kaythat is diff between 2.8 and 2.11?#2020-11-2318:11thhellerthe opened url should have ?server-token=<uuid>#2020-11-2318:11tony.kayI’ll look at logs#2020-11-2318:12thhellerwell there were other changes but that is one of the ones that'll lead to the stale error#2020-11-2318:12tony.kayok, thanks#2020-11-2318:14thhellerhttps://github.com/thheller/shadow-cljs/blob/e2196c2d14ea206b40a1f2078dc851a940ffae72/src/main/shadow/cljs/devtools/server/web/api.clj#L112#2020-11-2318:15thhellerthats the fn handling this. maybe redefine it at the REPL and add some debug tap>#2020-11-2318:23tony.kayYeah, that was it @thheller. Thanks. I thought I had the rewrite correct. I had:
location /shadow-cljs/ {
        rewrite ^/shadow-cljs/(.*) /$1 break;
        proxy_pass ;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "Upgrade";
        proxy_set_header   Host $host;
    }
in nginx, and it turns out putting the $1 on the proxy_pass was wrong…changing it to this fixed it:
location /shadow-cljs/ {
        rewrite ^/shadow-cljs/(.*) /$1 break;
        proxy_pass ;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "Upgrade";
        proxy_set_header   Host $host;
    }
#2020-11-2410:59grounded_sageIs there a way to run a browser test in shadow with advanced compilation off? Trying to debug something that the moment which works in repl but hangs in the test runner. #2020-11-2415:32thheller@grounded_sage shadow-cljs compile? or just :compiler-options {:optimizations :simple}?#2020-11-2517:27grounded_sageI’ll circle back to this. Hit another serious problem which has taken priority. #2020-11-2507:47mkvlrgood morning, we are using :repl {:runtime-select :latest} in our project and like it. Now I’ve added an iframe that also runs a cljs target that’s built with shadow. Is there a way to opt out of shadow considering this iframe for the repl? I’d like shadow to use the latest main window for the repl…#2020-11-2507:53mkvlrboth of these use the same build but a different module.#2020-11-2508:02mkvlrtrying to switch this manually with shadow.cljs.devtools.api I noticed that my repl-runtimes are missing the :runtime-id key that’s needed for me to switch this or am I misunderstanding the api?
(repl-runtimes :website)
;; => [{:since #inst "2020-11-25T07:44:05.319-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 45, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true} {:since #inst "2020-11-25T07:44:07.842-00:00", :proc-id "68613cad-86ad-44ea-a950-32dac30914ec", :connection-info {:remote true, :websocket true}, :client-id 46, :user-agent "Chrome 537.36 [MacIntel]", :type :runtime, :lang :cljs, :build-id :website, :host :browser, :dom true}]
#2020-11-2508:25thheller@mkvlr switching that way is currently not supported. https://github.com/thheller/shadow-cljs/issues/776#2020-11-2508:26thhellerI'll see about fixing that. not many people use it so I forgot 🙂#2020-11-2508:26mkvlrcool, thanks a lot!#2020-11-2508:31mkvlrdo you think adding a flag to not consider a certain frame from becoming the active repl might also make sense?#2020-11-2508:32mkvlrnot likely that a lot of people run into this problem though…#2020-11-2508:32thhellerthe problem is that there is no easy way to identify something#2020-11-2508:33thhellerand iframe looks just like any other normal document#2020-11-2508:33mkvlrsure, maybe a js global to opt out?#2020-11-2508:33thhellerit does identify workers but even with multiple workers it can't identify between them#2020-11-2508:34thhellersure that would work. must be something coming out of the document loading the JS#2020-11-2508:34mkvlrthat would work for our case#2020-11-2509:19thheller@mkvlr in 2.11.8 you can set <script>var SHADOW_CONFIG = { repl: false };</script> in the HTML (before the actual script) to opt-out of the REPL for that page#2020-11-2509:20thhellerthe actual manual REPL select logic I'll need to think about for a bit#2020-11-2509:24mkvlr@thheller wow, thanks so much!#2020-11-2510:22Carlohey, I'm new to clojurescript, could you guide me in the process of adding the cytoscape-cola library to a project using shadowjs?#2020-11-2510:23CarloHere's what I know: I can't use cljsjs because shadow-clj doesn't support that, so I think I have to install the library via npm install cytoscape-cola#2020-11-2510:27CarloThen I added (:require ["cytoscape-cola" :as cyto])#2020-11-2510:50CarloI seem to have solved my problem now, thanks 🙂#2020-11-2606:47steveb8nQ: I’m struggling with an npm dep failing in nodejs CI tests. The error is opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1#2020-11-2606:47steveb8nthe lib is https://github.com/uuidjs/uuid#2020-11-2606:47steveb8nfrom that error I can see that it’s using the wrong dist i.e. the browser variant#2020-11-2606:49steveb8nbut I can’t work out how to get it to use the node variant instead. I’ve tried nearly everything in the docs about npm deps e.g. “module” entrypoints etc but no luck#2020-11-2606:49steveb8nanyone dealt with this before?#2020-11-2606:52steveb8nthe require is…#2020-11-2606:52steveb8n
(:require ["uuid" :as uuid-js])
#2020-11-2606:53steveb8n
{:target           :node-test
             :compiler-options {:optimizations :none}
             :js-options       {:entry-keys ["module" "main"]} ; using esm modules (for uuid npm dep) see 
             :output-to        "cljs-out/test/node-tests.js"
             :ns-regexp        "-test$"
             ; autorun does not return an exit code suitable for CI. CI tests are runs from node cli instead
             :autorun          false}
#2020-11-2608:53thheller@U0510KXTU opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1 is not an error. that is a filename. what is the actual error?#2020-11-2608:54steveb8n+ node cljs-out/test/node-tests.js SHADOW import error /opt/atlassian/pipelines/agent/build/.shadow-cljs/builds/test-ci/dev/out/cljs-runtime/shadow.js.shim.module$uuid.js /opt/atlassian/pipelines/agent/build/node_modules/uuid/dist/esm-browser/index.js:1 export { default as v1 } from './v1.js'; ^^^^^^ SyntaxError: Unexpected token 'export' at wrapSafe (internal/modules/cjs/loader.js:1043:16) at Module._compile (internal/modules/cjs/loader.js:1091:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10) at Module.load (internal/modules/cjs/loader.js:976:32) at Function.Module._load (internal/modules/cjs/loader.js:884:14) at Module.require (internal/modules/cjs/loader.js:1016:19) at require (internal/modules/cjs/helpers.js:69:18) at /opt/atlassian/pipelines/agent/build/.shadow-cljs/builds/test-ci/dev/out/cljs-runtime/shadow.js.shim.module$uuid.js:3:30 at global.SHADOW_IMPORT (/opt/atlassian/pipelines/agent/build/cljs-out/test/node-tests.js:64:44) at /opt/atlassian/pipelines/agent/build/cljs-out/test/node-tests.js:1839:1#2020-11-2608:56thhellerwhy is your node setup using the module entry? it should be using main?#2020-11-2608:56steveb8n@U05224H0W my naive reading of this is that the shim is running the browser impl when it’s in a nodejs build. Am I wrong about this?#2020-11-2608:56thhellerthe :js-options have no effect here#2020-11-2608:56steveb8ngood. I suspected as much#2020-11-2608:56thhellerthe "shim" is literally only doing require("uuid"). nothing else.#2020-11-2608:57thhellerso when it is taking the browser entry that is something in your node setup#2020-11-2608:57thhellerrun node manually and then require("uuid")#2020-11-2608:57steveb8nok….#2020-11-2608:58thhellerjust as a test to see if that reproduces the error#2020-11-2608:58steveb8nWelcome to Node.js v12.12.0. Type “.help” for more information. > require(“uuid”) { v1: [Getter], v3: [Getter], v4: [Getter], v5: [Getter], NIL: [Getter], version: [Getter], validate: [Getter], stringify: [Getter], parse: [Getter] } >#2020-11-2608:58steveb8ncan’t tell which impl was selected#2020-11-2608:58thhellerok and that is the same node as above?#2020-11-2608:58steveb8ngood question….#2020-11-2608:58thhelleryou can do require.resolve("uuid") to see#2020-11-2608:59steveb8nI do have a different result on my machine vs CI#2020-11-2608:59steveb8n> require.resolve(“uuid”) ‘/Users/steve/Documents/dev-personal/nextdoc-cloud/components-portable/node_modules/uuid/dist/index.js’ >#2020-11-2608:59thhellerthats what you should get#2020-11-2609:00thhelleryou might have configured some node environment variable or so to prefer esm#2020-11-2609:00steveb8nchecking node version differences…#2020-11-2609:00thhellerI honestly don't know what the state of esm support in node is#2020-11-2609:00thhellerit used to require a --esm flag or so#2020-11-2609:02steveb8nit’ll take me a bit of time (docker) to check node versions. would that be a likely cause?#2020-11-2609:04thhellerI don't know honestly. none of the js-options will do anything since node is responsible for picking the JS dependency. which you can see from the stacktrace.#2020-11-2609:04thhellerso it might be something from the environment or your package.json#2020-11-2609:05steveb8nyeah ok. I will look into the package-lock as well. thanks for taking a first pass at this#2020-11-2609:05thhellerAs of Node.js 12.17.0, the --experimental-modules flag is no longer necessary to use ECMAScript modules (ESM).#2020-11-2609:05steveb8nI’ll touch base if I find out some clues that point at shadow instead of node/npm#2020-11-2609:06thhellerif node and require("uuid") works then :node-test output fill work too#2020-11-2609:06steveb8nmy local machine is v12.12.0. CI (where it fails) is v13.2.0#2020-11-2609:06steveb8nI’ll start by matching these up#2020-11-2609:06thhellernode -e "require('uuid')"#2020-11-2609:07thhellerseems kinda weird that it picks the module entry but then doesn't understand modules 😛#2020-11-2609:08steveb8nyeah. the world of npm is weird in many ways but so much gold in libs out there too#2020-11-2609:08steveb8nI’ve gotta go have dinner. I’ll report back conclusions#2020-11-2609:08steveb8nthanks 🙂#2020-11-2609:40steveb8nok. it was the node version. works fine in v12 and fails in v13#2020-11-2609:41steveb8nI’ll stick with v12 since that’s what’s supported by AWS lambda#2020-11-2609:41steveb8nthanks again 🙏#2020-11-2612:53mrchanceHey! Is there a recommended way to hack on two libraries at once, similar to lein checkouts? I didn't really find anything besides some recommendations to just softlink part of the source tree.#2020-11-2613:02mrchanceAh, I found something in the slack archive:
@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integration
Thanks, will try that first
#2020-11-2613:02mrchanceAh, I found something in the slack archive:
@lilactown just add the :source-paths and keep it in :dependencies. or you use the lein integration
Thanks, will try that first
#2020-11-2614:13scknkkrerAny guide to combine Clojure and Clojurescript projects, with Shadow ?#2020-11-2614:22mrchanceIf you're using the re-frame template, there's a parameter to include a compojure server for fullstack development, that might offer a start!#2020-11-2614:22scknkkrerI don’t have a project, yet. Are there any good template for this ?#2020-11-2614:22scknkkrerBeside, re-frame.#2020-11-2614:23mrchanceI like re-frame, it uses shadow cljs and has the Clojure setup built in, but there are probably others as well#2020-11-2614:24scknkkrerI need more purified template, I think.#2020-11-2614:25scknkkrerI need a simple job to do.#2020-11-2614:25mrchanceHm, then I'd just use the re-frame template for an example how the integration works (It's pretty straightforward), and then go with the reagent template: https://github.com/reagent-project/reagent-template#2020-11-2715:08cjsauerI’m having an issue getting shadow to ingest .js files. The use the import/export syntax as required, but they make use of a class with static fields, which for some reason is giving me a syntax error of “expecting a (“ after the field name. Is it possible that I need to tweak the closure compiler's input language setting? Commenting out all static fields allows compilation to succeed...#2020-11-2715:08cjsauerI did try setting the :language-in compiler option to no avail. #2020-11-2715:09thhelleraren't static fields just a proposal for now?#2020-11-2715:09thhellertweaking input language is not a thing since it is already at the highest level by default#2020-11-2715:10thhellerI don't have a clue whether they are supported or not. if you get a compiler error maybe not.#2020-11-2715:11thhellerif its not in any officially released JS versions then chances are good that its not supported. they often don't implement experimental features.#2020-11-2715:14thhellerhttps://github.com/google/closure-compiler/issues/3477#2020-11-2715:18cjsauerOh I didn’t even realize that! Thank you. #2020-11-2715:19cjsauerI wonder, could I transpile this with Babel prior to feeding closure maybe?#2020-11-2715:46thhellerdunno. I'd just go for class Foo {} and Foo.field = 1; or whatever#2020-11-2715:54cjsauerI didn’t write this code unfortunately. It’s generated. I’ll see if I can transform it prior to closure somehow. Thanks for the help. #2020-11-2715:33jmckitrickFor this error: ‘Cannot infer target type in expression’ is that Closure, shadow, or something else generating that message?#2020-11-2715:33jmckitrickHow can it be fixed?#2020-11-2715:34thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2020-11-2715:36jmckitrickThanks, I’ll try that.#2020-11-2718:45bendlasHello, I just ran into some weirdness while porting a project from figwheel-main to shadow-cljs. Both only discovered because serving dev-http from classpath: :dev-http {9000 "classpath:www"}:#2020-11-2718:46bendlas• shadow finds public/index.html from a dependency, instead of in resources/public/index.html. I suspect this is because of the hardcoded special-casing of folders named *resources, because it behaves correctly, when public/index.html is in different :paths directory#2020-11-2718:46bendlas• when serving from classpath, the fallback to index.html necessary for client-routing, doesn't work as described in https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http.#2020-11-2718:46bendlasI now realize that probably both could be worked around by serving from multiple file roots. Shall I create tickets?#2020-11-2718:59macI am having a pot of trouble shimming https://github.com/cljsjs/packages/tree/master/rrule so I can use https://github.com/reup-distribution/cljs-rrule. I have created a a shim like the below in src/cljs/cljsjs:
(ns cljsjs.rrule
  (:require ["rrule" :as rrule]))

(js/goog.exportSymbol "RRule" rrule)
#2020-11-2719:00macBut when I call cljs-rrule.core/rrule I get #object[TypeError TypeError: Cannot read property 'call' of undefined]#2020-11-2719:10thheller@bendlas this likely has nothing to do with shadow-cljs but instead the ordering of the classpath by deps.edn#2020-11-2719:11thhellershadow-cljs doesn't filter any folders when it comes to :dev-http. it just uses the classpath as constructed by clojure#2020-11-2719:11thhellerI don't know if that has been fixed but it didn't put :paths first for a while so the ordering was more or less random#2020-11-2719:11thhellerwell not random but different from shadow-cljs.edn and project.clj#2020-11-2719:12thheller@mac sorry I don't know that package. check what rrule actually is in the REPL or so.#2020-11-2720:50mac@thheller (type r/rrule) => nil#2020-11-2721:46mac@thhellerI figured it out 🙂 I think the structure of the js package might have changed since the cljs lib was made.#2020-11-2723:02Lyderic DutillieuxHey guys, I'm thinking of reducing my modules footprint. I was wondering if it would be possible to get cljs.core and other core libs from a CDN ? I'm aware that I would lose tree-shaking capabilities, but since core libs are really stable, clojurescript is getting more and more popular and my project grows, using a CDN and client cache may be a good fit. Have anyone tried to setup this ?#2020-11-2723:30lilactownI don't think anyone has tried this. you not only lose tree shaking, but also the advanced optimizations that the Closure compiler does for you such as variable renaming#2020-11-2911:03RollACasterHi, is there any common practice to include the hashes from https://shadow-cljs.github.io/docs/UsersGuide.html#NameHashing into the index.html file? The User Guide states: > The https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifest can help with that. How is the Output Manifest commonly used to do this task?#2020-11-2911:46thhellerif you just have a static html file you can use this https://github.com/thheller/shadow-cljs/blob/16727382e683bb9449a07068158e01f9f16827ea/shadow-cljs.edn#L146-L149#2020-11-2911:47thhellercopies the index.src.html and modifies the <script src="/js/main.js"> (or whatever your modules and paths are)#2020-11-2911:54RollACasterah perfect, thanks!#2020-11-3009:02defaIs there a way in shadow-cljs to pass arguments to clojure? Like clj -Sdeps '{:mvn/local-repo "foo"}' . Reason being that I want to use a different local maven repo when building in a CI pipeline (gitlab).#2020-11-3009:40thheller@defa no there is not but you can just as well just use clj directly. doesn't matter from shadow-cljs perspective. just use clj -m shadow.cljs.devtools.cli release app or so. that would be identical to shadow-cljs release app#2020-11-3009:42defa@thheller Thanks, man. Your're right... quite obvious :face_with_rolling_eyes:#2020-11-3013:47David Pham@thheller Hello, thanks a gain for your work in shadow-cljs. I am using the browser-test target, and I love it. I have a small observation though, and I don't know if it is my browser are small bug: when a test fails, and the output of the test is fairly big, I wish we could pretty print the results or expand horizontally the results. For now we can only scrool horizontally, and I believe the arrow on the left of the restuls is made for expanding the result. What do you think?#2020-11-3017:20thheller@neo2551 the test UI is from this library, not related to shadow-cljs. https://github.com/bhauman/cljs-test-display#2020-11-3017:21David PhamThanks!#2020-12-0113:41Alexis VincentDoes anyone know how to make cider stop asking if I want to open localhost:9630 in the browser when i jack in a shadow-cljs project?#2020-12-0114:10nivekuil@mail024: (cider-offer-to-open-cljs-app-in-browser . nil)#2020-12-0114:32Alexis Vincentamazing! Thank you!#2020-12-0117:18dpsuttonoften caused by using relative paths for those assets rather than absolute. i'm guessing these requests are to http://example.com/subcategory/styles.css or something similar?#2020-12-0121:23fsdHello community, I had a quick question, I have react shadow cljs application, when I yarn build and open index.html (in public) , everything works except the images and icons. Any tips for that?#2020-12-0210:25David Phamdid you check the console for veryfing the paths of the assets?#2020-12-0211:00Karol WójcikIs it possible to turn off installations of devtools in worker environment?#2020-12-0211:19anonimitorafHey guys, how do you deploy your release builds? Specifically this part of https://github.com/shadow-cljs/quickstart-browser#2020-12-0211:22Karol WójcikDepends. You can put the output of release build on s3, behind nginx. It depends what you need.#2020-12-0211:27anonimitorafAh, I guess I'm after the simplest way of doing so. I was looking at Heroku specifically as one of the easiest (it seems)#2020-12-0211:48anonimitorafAfter reading a bit, it seems like I'll have to set up nginx/apache/some web server in Heroku#2020-12-0213:34Michaël SalihiYou can also go for eg. with Netlify which it's appropriate to static website. https://medium.com/ampersandas-clojure-thing/how-to-publish-clojurescript-application-to-netlify-for-free-c7d148afaa64#2020-12-0213:45anonimitorafOh damn, thanks. I'll try it out#2020-12-0217:55Alexis Vincent@UR37CBF8D Highly recommend Vercel#2020-12-0217:55Alexis Vincentcan get it online as simply as “vercel .”#2020-12-0222:39anonimitorafUpdate: Netlify was so damn easy to use @UJWLUPW13 But I'll check Vercel out too!#2020-12-0215:58martinklepschis there a way to restart the process backing the node repl? I sometimes seem to get into a broken state where prints inside async evaluations are not captured properly#2020-12-0220:54thheller@martinklepsch from the clj-repl (shadow/stop-worker :node-repl)#2020-12-0312:19martinklepschthanks! I now noticed that when requiring some of my namespaces in the node repl I get lots of infer-warnings and - if I remember correctly - this previously impacted async evaluations at the REPL#2020-12-0312:24martinklepschI only get those warnings when requiring the namespace inside shadow-cljs node-repl — when evaluating via Conjure/Vim they are not shown#2020-12-0312:22martinklepschis there a way to type hint the return value of a function at the place where the function is defined? I have some functions that return JS objects and hinting those in every place I use them is a little tedious/noisy.#2020-12-0312:25martinklepschAlso I’m noticing that the warnings only occur when requiring the namespace in a node-repl. The actual builds using those files don’t log any warnings#2020-12-0312:49thheller@martinklepsch I think (defn foo ^ReturnType [a b] ...)#2020-12-0312:50thhellerdon't know about infer warnings, need more info#2020-12-0312:57martinklepschInterestingly a large chunk also seems to be undeclared-var warnings from something like this:
(:require #?(:node
               ["@sentry/node" :as sentry]
               :browser
               ["@sentry/browser" :as sentry])
(.configureScope sentry (fn [^sentry.Scope scope] ....
#2020-12-0312:57thheller^sentry.Scope has no meaning in shadow-cljs whatsoever. just make your life easier and use ^js#2020-12-0312:58thhelleryou might not get be inference warnings because shadow-cljs processes the JS for browser builds, so it collects more externs infos#2020-12-0312:58thhellerthat is not done for node builds since they load stuff directly via node#2020-12-0313:01martinklepschI do get the inference warnings when starting the node repl via shadow node-repl , just not when evaluating through my editor (so probably not shadow’s fault)#2020-12-0313:02martinklepschthat said the example above was more about the undeclared-var warning and less about inference#2020-12-0313:02thhellermaybe your editor just doens't show it? I don't know. need more info.#2020-12-0313:02thhellerundeclared var what? you only pasted a chunk of code#2020-12-0313:02thhellerwhat is undeclared there?#2020-12-0313:02martinklepschUse of undeclared Var icebreaker.util.sentry/sentry#2020-12-0313:02thhellerthats the ^sentry.Scope probably. should be either ^js or sentry/Scope given that its an alias not a var#2020-12-0313:04martinklepschI also get it on lines that don’t have the sentry.Scope hint and it persists after removing the sentry.Scope hints#2020-12-0313:05thhellerI don't know. I can't guess without seeing the code.#2020-12-0313:06thhellerone thing though. if you have :as something you should probably always be treating that as a proper namespace alias#2020-12-0313:06thhellerwhile (.configureScope sentry ...) is valid (sentry/configureScope ...)would be better#2020-12-0313:13martinklepschoh I see, maybe I’ll just try that#2020-12-0313:16martinklepschhm, that still gives me
No such namespace: sentry, could not locate sentry.cljs, sentry.cljc, or JavaScript source providing "sentry"
#2020-12-0313:18martinklepschhere’s the full source for this namespace: https://gist.github.com/martinklepsch/0a146f46dfc7a304eaec0f348e5a5d36#2020-12-0314:04thheller@martinklepsch now I see. you don't have a :cljs default branch for sentry. node-repl doesn't use any custom reader conditionals so it only uses :cljs which is missing.#2020-12-0314:06martinklepschoh, true, I do mostly start my node-repl like this (shadow/node-repl {:config-merge [{:compiler-options {:reader-features #{:node}}}]}) but you’re right that when I tried to reduce the repro I skipped that#2020-12-0314:26thhelleryou can set :target-defaults {:node-script {:compiler-options {:reader-features ...}}}. that should apply to node-repl#2020-12-0406:42bennyi tend to end up with errors like this in my release builds for our react native project. does this have to do with the :infer-externs flag?
E/unknown:ReactNative: MyAppImpl caught native exception
    com.facebook.react.common.JavascriptException: TypeError: u(BY).Il is not a function. (In 'u(BY).Il(q.a(n))', 'u(BY).Il' is undefined), stack:
#2020-12-0408:58thheller@benny yes, thats a typical externs error#2020-12-0420:30bennyis the solution for it to just change :infer-externs to false!?#2020-12-0421:55thhellerthe solution is add ^js typehints where required. :infer-externs false just turns of the warnings. see https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2020-12-0409:36defaWith :target :react-native where would I put files to load on demand via (js/require "data.json")? Is there some assets/resource path to configure?#2020-12-0412:06thhellerin shadow-cljs no, in react-native I don't know. just js/require the file with a relative path to the output file#2020-12-0412:36rkiouakI imagine with react native it would be similar to how fonts are bundled -- so i think something in both ios and android folders#2020-12-0503:03wilkerluciois there way to tell shadow to output exports using export ... format instead of Object.defineProperty(module.exports, ...)?#2020-12-0503:03wilkerluciousing :npm-module target#2020-12-0509:19thhellervia https://clojureverse.org/t/generating-es-modules-browser-deno/6116 only#2020-12-0509:35bennycan I use shadow-cljs to create an "uberjar" like node bundle? I want to compile something on one platform and transfer a single file or small archive to the target platform and have node it without any dependency issues#2020-12-0509:43bennynote to self: first try to read documentation: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script#2020-12-0509:47thhellerthat doesn't bundle the dependency by default#2020-12-0509:47thhelleryou can use something like https://github.com/vercel/ncc to make it fully self contained#2020-12-0509:47thhelleror even https://github.com/nexe/nexe#2020-12-0510:37bennyweird, I used the release target and my single cljs dependency was bundled#2020-12-0510:37bennyoh sorry: node is on the target platform, but that's it. I don't need a single file executable, a single file script is enough for my usecase (arm7l system)#2020-12-0511:11thhelleryes if you only use CLJS and the built-in node packages that'll be fine as is#2020-12-0511:11thhellerbut if you add any npm dependencies it'll either require the node_modules folder wherever you are running or post-processing a release build with ncc#2020-12-0510:07theeternalpulseI'm trying to integrate flow-storm-debugger in my development workflow with shadow. It requires that you first call the flow-storm-debugger.main/-main and then connect using flow-storm-api/connect. I originally added a preload of a .cljs file but it needs to run the debugger in a clj context. Is there a way to execute that debugger.main namespace as part of my build?#2020-12-0510:09theeternalpulseI'm not using this workflow, would I need to switch? https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2020-12-0510:27thhellersorry I don't have a clue what flow-storm is#2020-12-0510:52theeternalpulseIt's a debugger that I can connect to, but it requires a startup beforehand in clojure, and connecting to it when the app loads#2020-12-0510:52theeternalpulseBasically I want to run it beforehand, but I'm clojure, and then connect using a preload#2020-12-0511:07thhellerthen run the clj part however the instructions tell you#2020-12-0511:08thhellerseems to be a separate application so you need to run it separately 😛#2020-12-0516:56theeternalpulseright, I want it integrated into the build, so trying with the clj-run option#2020-12-0517:00theeternalpulseThat seemed to do it#2020-12-0520:28theeternalpulseI was hoping there was a way to have preloads run clj files to execute so I could just do cider jack in from cider#2020-12-0516:21wontheone1Hello! I just started using shadow-cljs (I used leiningen only)#2020-12-0516:22wontheone1
{:source-paths ["src" "test"]
 :dependencies [[com.taoensso/timbre "4.10.0"]
                [macchiato/core "0.2.16"]]
 :builds {:app {:devtools {:repl-init-ns backend.core
                           :repl-pprint true}
                :main   backend.core/server
                :target :node-script
                :source-map true
                :exports {:server backend.core/server}
                :output-dir "target"
                :output-to "target/main.js"
                :compiler-options {:optimizations :simple}}}
 :nrepl {:init-ns backend.core}}
^ My edn file looks like this but where do I put development dependencies. Can’t see example from the official doc. I want to include [binaryage/devtools "1.0.2"]
#2020-12-0516:25wontheone1
:profiles {:dev     {:source-paths ["dev"]
                       :repl-options {:init-ns user}
                       :dependencies [[midje "1.9.9"]
                                      [ring/ring-mock "0.4.0"]]
                       :aliases      {"test-ancient" "midje"
                                      "upgrade-deps" ["ancient" "upgrade" ":all" ":check-clojure"]}
                       :bikeshed     {:max-line-length 120
                                      :docstrings      false}}
^ Would using dev profile work? (This is from my leiningen project.clj )
#2020-12-0516:36thhellerjust include it always. doesn't matter.#2020-12-0519:25wontheone1@thheller Thank you. Just to clarify, do you mean I include it in :dependencies (top level)?#2020-12-0520:54thheller@wontheone1 yes. it won't have any negative impacts.#2020-12-0520:57wontheone1Aha thank you. I guess some dead code elimination 🙂 makes sense#2020-12-0523:34thhellerthat doesn't apply. just adding a dependency does not automatically include it in a build. you actually need to require the namespaces it provides.#2020-12-0606:30wontheone1Aha make sense! thank you!#2020-12-0606:51esp1I'm attempting to use the newly refactored @aws-amplify/ui-react npm packages, but I'm getting the following compilation warning:
[2020-12-05 22:23:46.005 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-1f3b9bdc.js", :requires [{:line 1628, :column 73}]}
The referenced code looks like it's doing some weird webpack magic to require files:
return Promise.resolve().then(function () { return _interopNamespace(require(
    /* webpackInclude: /\.entry\.js$/ */
    /* webpackExclude: /\.system\.entry\.js$/ */
    /* webpackMode: "lazy" */
    `./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {
        {
            cmpModules.set(bundleId, importedModule);
        }
        return importedModule[exportName];
    }, consoleError);
I'm not exactly sure what's going on, but it seems like the @aws-amplify/ui-components package may be requiring webpack to function? Anyway the end result in the UI is that when I try to use the Amplify UI components I get errors like these in the console:
Module not provided: ./amplify-authenticator.cjs.entry.js
Module not provided: ./amplify-nav_2.cjs.entry.js
These *.entry.js files exist in the node_modules/@aws-amplify/ui-components/dist/cjs/ directory but it looks like because of the aforementioned error they are not properly getting loaded. Does anyone know of any workaround to get this working?
#2020-12-0607:14esp1I should mention I'm using shadow-cljs 2.11.8 and I'm including the amplify and react dependencies in package.json#2020-12-0609:58thhelleryeah those references look like it expects webpack#2020-12-0609:58thhellerthis is not something shadow-cljs understands or can support#2020-12-0616:22esp1Ok thanks @U05224H0W that's kinda what i figured. I'm going to see if I can preprocess the bits that use amplify using webpack and then include into the cljs code..#2020-12-0619:45thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider :external. that way you can let webpack process all the npm dependencies together#2020-12-0619:45thhellerand let shadow-cljs handle the CLJS parts#2020-12-0721:59esp1this worked great, thanks @U05224H0W!#2020-12-0804:58rbergerWhat version were you having this issue with? We’re using @aws-amplify/ui-react": "0.2.24 with no problem using the defaults for the :browser target. Havent tried the latest version which seems to be https://github.com/aws-amplify/amplify-js/releases/tag/%40aws-amplify%2Fui-react%400.2.31
#2020-12-0820:29esp1@U07GPFFAS I'm using 0.2.31. Good to know that this wasn't an issue for previous versions.#2020-12-0821:48rbergerI’ll try the latest version when I get a chance. Seems like such a change shouldn’t happen for any change in minor numbers of the semantic version#2020-12-0707:41defclassHello, I’m very new in shadow-cljs. I encounter a problem recently that I’m getting a ton of errors like these after invoke watch command. The compilation still works, but that’s making the console unusable.
[:failed-to-compare "^7.8.7" "7.12.5" #error {
 :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
 :via
 [{:type java.lang.NullPointerException
   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
 :trace
 [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]
  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]
  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]
  [shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17482 invoke "npm_deps.clj" 46]
  [clojure.lang.Delay deref "Delay.java" 42]
  [clojure.core$deref invokeStatic "core.clj" 2320]
  [clojure.core$deref invoke "core.clj" 2306]
  [shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17484 invoke "npm_deps.clj" 52]
  [shadow.build.targets.browser$check_npm_versions$fn__18133$fn__18134 invoke "browser.clj" 826]
  [clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]
  [clojure.core.protocols$fn__8138 invokeStatic "protocols.clj" 75]
  [clojure.core.protocols$fn__8138 invoke "protocols.clj" 75]
  [clojure.core.protocols$fn__8088$G__8083__8101 invoke "protocols.clj" 13]
  [clojure.core$reduce invokeStatic "core.clj" 6828]
  [clojure.core$reduce invoke "core.clj" 6810]
  [shadow.build.targets.browser$check_npm_versions$fn__18133 invoke "browser.clj" 818]
  [shadow.build.targets.browser$check_npm_versions invokeStatic "browser.clj" 817]
  [shadow.build.targets.browser$check_npm_versions invoke "browser.clj" 799]
  [shadow.build.targets.browser$process invokeStatic "browser.clj" 854]
  [shadow.build.targets.browser$process invoke "browser.clj" 838]
  [clojure.lang.Var invoke "Var.java" 384]
  [shadow.build$process_stage$fn__14212 invoke "build.clj" 148]
  [shadow.build$process_stage invokeStatic "build.clj" 145]
  [shadow.build$process_stage invoke "build.clj" 137]
  [shadow.build$compile invokeStatic "build.clj" 408]
  [shadow.build$compile invoke "build.clj" 397]
  [shadow.cljs.devtools.api$release_STAR_ invokeStatic "api.clj" 353]
  [shadow.cljs.devtools.api$release_STAR_ invoke "api.clj" 340]
  [shadow.cljs.devtools.cli$do_build_command invokeStatic "cli.clj" 29]
  [shadow.cljs.devtools.cli$do_build_command invoke "cli.clj" 26]
  [shadow.cljs.devtools.cli$do_build_commands invokeStatic "cli.clj" 51]
  [shadow.cljs.devtools.cli$do_build_commands invoke "cli.clj" 40]
  [shadow.cljs.devtools.cli$main$body_fn__17101__auto____17691 invoke "cli.clj" 168]
  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 167]
  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$apply invoke "core.clj" 660]
  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]
  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.core$apply invokeStatic "core.clj" 665]
  [clojure.main$main_opt invokeStatic "main.clj" 514]
  [clojure.main$main_opt invoke "main.clj" 510]
  [clojure.main$main invokeStatic "main.clj" 664]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}]
I google for hours and no result, I’m curious is there a way for me to debug the process of compilation. Thanks very much.
#2020-12-0707:45defclass@U354VUKQA It may be a bit verbose. I use deps.edn with shadow-cljs. the deps.edn:
{:paths ["src/main"]
 :deps
 {org.clojure/clojure         {:mvn/version "1.10.1"}
  rum/rum                     {:mvn/version "0.12.3"}
  ;; rum                         {:local/root "/home/tienson/codes/source/clj/rum"}
  ;; persistent-sorted-set       {:mvn/version "0.1.2"}
  ;; FIXME: doesn't work on my archlinux laptop (tienson)
  ;; The required namespace "datascript.core" is not available, it was required by "frontend/db.cljs".
  datascript/datascript       {:git/url "",
                               :sha "7c2822565d9a114c7d8604c335af89de4640e2e5"}
  ;; datascript                  {:mvn/version "1.0.1"}
  datascript-transit/datascript-transit
                              {:mvn/version "0.3.0"
                               :exclusions [datascript]}
  funcool/promesa             {:mvn/version "4.0.2"}
  medley/medley               {:mvn/version "1.2.0"}
  metosin/reitit-frontend     {:mvn/version "0.3.10"}
  cljs-bean/cljs-bean         {:mvn/version "1.5.0"}
  prismatic/dommy             {:mvn/version "1.1.0"}
  org.clojure/core.match      {:mvn/version "1.0.0"}
  com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
  cljs-drag-n-drop/cljs-drag-n-drop
                              {:mvn/version "0.1.0"}
  borkdude/sci                {:mvn/version "0.1.1-alpha.6"}
  hickory/hickory             {:mvn/version "0.7.1"}
  hiccups/hiccups             {:mvn/version "0.3.0"}
  tongue/tongue               {:mvn/version "0.2.9"}
  org.clojure/core.async      {:mvn/version "1.3.610"}
  thheller/shadow-cljs        {:mvn/version "2.8.81"}
  expound/expound             {:mvn/version "0.8.6"}
  lambdaisland/glogi          {:mvn/version "1.0.74"}}

 :aliases {:cljs {:extra-paths ["src/dev-cljs/"]
                  :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.597"}
                                thheller/shadow-cljs        {:mvn/version "2.8.81"}
                                binaryage/devtools          {:mvn/version "0.9.10"}
                                org.clojure/tools.namespace {:mvn/version "0.2.11"}
                                cider/cider-nrepl           {:mvn/version "0.23.0-SNAPSHOT"}}
                  :main-opts ["-m" "shadow.cljs.devtools.cli"]}
           :test
           {:extra-paths ["src/test/"]
            :extra-deps  {org.clojure/clojurescript {:mvn/version "1.10.520"}
                          org.clojure/test.check {:mvn/version "RELEASE"}}
            :main-opts   ["-m" "shadow.cljs.devtools.cli"]}
           :runner
           {:extra-deps
            {com.cognitect/test-runner
             {:git/url "",
              :sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
            :main-opts ["-m" "cognitect.test-runner" "-d" "test"]}}}
and the shadow-cljs.
{:deps     true
 :nrepl        {:port 8701}

 :builds
 {:app
  {:target :browser
   :module-loader true
   :modules {:main {:init-fn frontend.core/init}
             :code-editor
             {:entries [frontend.extensions.code]
              :depends-on #{:main}}}

   :output-dir "./static/js"
   :asset-path "/static/js"
   :release {:asset-path ""}
   :compiler-options {:infer-externs :auto
                      :output-feature-set :es6
                      :externs ["datascript/externs.js"
                                "externs.js"]}
   :closure-defines {goog.debug.LOGGING_ENABLED true
                     frontend.config/GITHUB_APP_NAME #shadow/env "GITHUB_APP2_NAME"}

   :devtools
   ;; before live-reloading any code call this function
   {:before-load frontend.core/stop
    ;; after live-reloading finishes call this function
    :after-load frontend.core/start
    :preloads     [devtools.preload]}}

  :test
  {:target :node-test
   :output-to "static/tests.js"}

  :publishing
  {:target :browser
   :module-loader true
   :modules {:main {:init-fn frontend.publishing/init}
             :code-editor
             {:entries [frontend.extensions.code]
              :depends-on #{:main}}}

   :output-dir "./static/js/publishing"
   :asset-path "/static/js"

   :closure-defines {frontend.config/PUBLISHING true
                     goog.debug.LOGGING_ENABLED true}

   :compiler-options {:infer-externs :auto
                      :output-feature-set :es6
                      :externs ["datascript/externs.js"
                                "externs.js"]}
   :devtools
   ;; before live-reloading any code call this function
   {:before-load frontend.core/stop
    ;; after live-reloading finishes call this function
    :after-load frontend.core/start
    :preloads     [devtools.preload]}}}}
#2020-12-0707:47wontheone1do you have :target key in the edn?#2020-12-0707:49defclassSorry, yes,I have a :target key . app target is :browser#2020-12-0707:51wontheone1hmm#2020-12-0707:51wontheone1did you run compile or watch to build dev version and opened a browser to provide runtime?#2020-12-0707:52wontheone1When do you get those error messages#2020-12-0707:54defclassyep, I guess it might be caused by some of my environment changed yesterday. The config works well for a long time.#2020-12-0707:57wontheone1sorry I have no idea#2020-12-0707:57wontheone1Also when do you see these msgs? what command did you run?#2020-12-0707:58wontheone1or did you run the build with node ?#2020-12-0708:01defclassclojure -M:cljs watch app , I use this command. Thank you all the same, Your help may lead me to find a solution : )#2020-12-0708:05defclassI saw these messages about 1 or 2 days ago.#2020-12-0708:05wontheone1I just advise you to go through git diff what broke it#2020-12-0708:06wontheone1going through change by change, pin point what change broke it 🙂#2020-12-0708:08defclassThanks for your advice. I reset the codebase, but did not work. I guess something broken out the codebase.#2020-12-0709:00defclassI found it was a problem with jdk. It works when I downgrade jdk from 15 to 1.8. Thanks for your help @U354VUKQA: )#2020-12-0709:01wontheone1Aha no problem#2020-12-0709:01wontheone1I think JDK 8 is the most stable version with Clojure 🙂#2020-12-0709:01wontheone1Good that you found out!#2020-12-0709:03defclassI recall that I executed brew upgrade unconsciously yesterday 😭#2020-12-0709:04wontheone1😄 brew fucked up my python environments few times as well#2020-12-0707:42wontheone1what does your shadow-cljs.edn look like?#2020-12-0709:13thheller@michael.wong upgrade shadow-cljs. then jdk15 is just fine. I use it myself.#2020-12-0709:13thhellerthis jdk8 recommendation needs to die.#2020-12-0709:14thhellerthheller/shadow-cljs {:mvn/version "2.8.81"} is ancient history by now#2020-12-0709:15thhelleras is org.clojure/clojurescript {:mvn/version "1.10.520"}#2020-12-0709:17defclassOK, thanks for advice, We will update the version at some future time. At present I need to ensure that our legacy code runs normally.#2020-12-0709:24mkvlrdo I remember correctly that ReferenceError: $jscomp is not defined in a release build points towards an issue with polyfills?#2020-12-0709:28thhelleryes, $jscomp is polyfills. thought I fixed all the issues though?#2020-12-0709:31mkvlrstill running it one, but only in production, not doing a local release#2020-12-0709:31mkvlrwe’re on 2.11.5 in this project, let me try upgrading first#2020-12-0709:32thhellerbumping to the appropriate :output-feature-set is always the best option#2020-12-0709:51mkvlrhmm, still occurring with :output-feature-set :es8#2020-12-0710:21mkvlrnevermind, caching is hard…#2020-12-1011:29martinklepschWould it be possible to write a Closure-compatible JS namespace that merely requires (and exports) a different set of NPM dependencies? I’d like to do this to provide different (API compatible) packages based on node/browser.#2020-12-1011:30martinklepschI know that shadow can help with it’s :node reader conditional but the issue with that is that that forces the namespace to be .cljc and our code isn’t necessarily valid Clojure (it uses js/ etc)#2020-12-1011:38thhelleras long as you don't load that namespace in CLJ thats not a problem?#2020-12-1011:39thhellerI don't understand your question though. why would it need to be closure js?#2020-12-1011:46martinklepschWe use linters and other tools that cause trouble in this situation. Maybe we could configure them to only look at things from a CLJS perspective but it also just feels a little… unintended to me to to have a bunch of Clojure namespaces#2020-12-1011:47martinklepschAnd Closure JS because my understanding is that that’s the only thing I can load as if it’s a ClojureScript namespace in my ClojureScript code?#2020-12-1011:48thhellerI'm not entirely sure what you are asking here#2020-12-1011:48thhellerwhat problem are you trying to solve exactly?#2020-12-1011:49thhellerI have seen plenty of projects that use CLJC for everything but only actually working on one platform so its not uncommon#2020-12-1011:52thhellerI also wrote this a while ago. while incomplete it may give you an idea how to solve "platform specific" code without relying in compiler hacks#2020-12-1011:52thhellerhttps://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2020-12-1011:55martinklepschYeah, for sure. And it’s working. I’m just trying to understand if there might be a different way that would remove the reader conditionals and move the conditional loading into an external file. Maybe I could also just have a designated namespace that re-exports the relevant requires. I guess the effect would be the same as having a Closure namespace.#2020-12-1011:56martinklepschThat said I like the idea of the Closure namespace it would mean we’re closer to “stock” Clojurescript#2020-12-1011:57martinklepschJust to be clear I’m not trying to solve a pressing problem here I guess. It’s more about exploring alternative approaches to learn#2020-12-1012:31thhellerI do not understand which problem you are trying to solve. what does conditional loading mean to you? practical example?#2020-12-1012:33thhellerisn't control via the build config enough? https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2020-12-1014:41martinklepschoh that js-options thing actually looks like it might just do what I’m looking for#2020-12-1011:39Ernesto GarciaHello. We have an existing AngularJS app bundled with Browserify. We have created a re-frame cljs view for to embed in the existing app. Using shadow-cljs, we are able to build into an :npm-module target, and bundle everything together, but we don't have the convenient auto-reload and REPL from shadow-cljs. I would therefore like to target :browser. It can be set up so that shadow-cljs bundles separately from Browserify. How would I achieve bundling all together?#2020-12-1011:40thheller@ernesto.garcia you can use :external an let that file be processed by browserify as usual https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider#2020-12-1011:41thhellerhttps://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2020-12-1011:42Ernesto GarciaI'll look into that. Is there also a way for shadow-cljs to bundle the JS files, and not use Browserify at all?#2020-12-1011:43thhellerdon't know. haven't looked at angular in a really long time#2020-12-1011:43thhellerlikely has some browserify plugin to process stuff right?#2020-12-1011:43Ernesto GarciaI think we are not doing any interesting processing, just bundling#2020-12-1011:44Ernesto GarciaShadow-cljs is able to deal with JS code directly when put in :source-paths?#2020-12-1011:44thhellerwhen its is standards-compliant JS yes#2020-12-1011:45thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2020-12-1011:45Ernesto GarciaOk, I will look into your responses. Thanks a lot for your support!#2020-12-1120:28fsdHi Everyone, I am a JavaScript dev (new to clojure), I am working with yarn package react-google-recaptcha. I am currently facing an issue to get back a token after verifying the recaptcha. If I do it in Javascript the onChange(value) function returns the token
function onChange(value) {
  console.log("Captcha value:", value);
}
 
ReactDOM.render(
  <ReCAPTCHA
    sitekey="Your client site key"
    onChange={onChange}
  />,
  document.body
);
But I try this in ClojureScript and I am getting nothing in the console
(defn onChange [value] 
       (println value)
)

($ ReCAPTCHA 
    { :sitekey "Your client site key" 
      :onChange #(onChange) })
(note $ is helix lib)
it tell me that wrong number of args (0) passed to onChange Can someone please tell where am I wrong?
#2020-12-1120:34dpsuttononChange expects an argument .`onChange={onChange}` means call the function onChange with the event. #(onchange) means is a shorthand for (fn [event] (onchange)) where you are not sending the event through. just do :onChange onChange which is exactly what the js version is doing#2020-12-1120:44fsdOh I see, (fn [event] (onchange)) anonymous function?#2020-12-1120:45dpsuttonthat's what #(onchange) expands to in essence. and its calling a 1 arity function with no args. which is what your error is#2020-12-1120:40dpsutton@singhamritpal49 also i think this is just a clojurescript question and so belongs in #clojurescript in the future#2020-12-1120:46fsdGot it sorry for the mistake.#2020-12-1120:47dpsuttonno worries. its really to make sure the greatest number of people who could help actually see your question#2020-12-1120:49fsd👍#2020-12-1205:58wilkerluciohello, I bumped shadow in a project and now I'm getting this: Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import d3 from 'goog:module$node_modules$d3$dist$d3_node';? Any idea why? The line it points out have this: import * as d3 from "d3";#2020-12-1214:51thheller@wilkerlucio should be import d3 from "d3", unfortunately the closure folks made that change in a strict way. cant' cheat anymore#2020-12-1214:53wilkerluciothanks, that fixes it 🙏#2020-12-1215:04p-himikWhen I compile a small piece of code with
:target           :browser
                         :compiler-options {:output-feature-set :es6}
                         :js-options       {:babel-preset-config {:modules "commonjs"
                                                                  :targets "chrome > 70"}}
there's always this small JS block in the result (after formatting it):
if ("undefined" !== typeof Symbol) {
        var c = Symbol;
        "object" != typeof c || !c || c instanceof Array || c instanceof Object || Object.prototype.toString.call(c)
    }
It doesn't seem to have any effect and I couldn't find where it comes from. Do you have any idea?
#2020-12-1216:57thhellersomething in cljs.core. look for js/Symbol dunno why its not removed either.#2020-12-1310:23p-himikNope, nothing there as well. Just 5 instances of js/Symbol usage and none of them seems to be the culprit.#2020-12-1319:13thhellerthought it was this one but maybe not https://github.com/clojure/clojurescript/blob/154b19a40e33fb9285bd5c16bc96ec0ab88c4261/src/main/cljs/cljs/core.cljs#L338-L341#2020-12-1221:21GGfpcSo I've recently migrated to shadow-cljs in order to use NPM packages with reagent. I've managed to port over all my previous dependencies from cljsjs, but when I try to use this project: https://github.com/weknowinc/react-bubble-chart-d3 I get an error like this
Assert failed: Component must not be nil
I'm importing as such
(ns goodstats.stats
  (:require [reagent.ratom :as ratom]
            [reagent.core :as reagent]
            [ajax.core :as ajax]
            [clojure.edn :as edn]
            ["@weknow/react-bubble-chart-d3" :refer (BubbleChart)]
            ["recharts" :as recharts]))



(def BubbleChart (reagent/adapt-react-class BubbleChart))
In the README they say that one needs to import React as the component does not import it, but I assumed Reagent already imported react (since I'm using other react components). Does anyone know what I'm doing wrong?
#2020-12-1222:33anonimitorafIs that :refer (BubbleChart) on purpose? Instead of :refer [BubbleChart]?#2020-12-1222:34GGfpcI got it from here#2020-12-1222:34GGfpcOn the shadow-cljs start page#2020-12-1222:36anonimitorafAh. I just had a look at the npm page and it looks like BubbleChart is the default import So, try :default BubbleChart#2020-12-1222:38GGfpcI tried both suggestions and unfortunately the error persists#2020-12-1222:39anonimitorafmaybe try :as BubbleChart as well?#2020-12-1222:39anonimitorafI remember having to do :as Blah when I thought I needed :default Blah#2020-12-1222:39GGfpcThat was the first thing I've tried to no avail 🙂#2020-12-1222:40anonimitorafI'd be interested to know how people go about debugging issues like this#2020-12-1222:41anonimitorafone other thing to check is, maybe the import is fine but the issue is caused by something else. After importing it, can you do a (print BubbleChart)? Just to check if it really is nil#2020-12-1222:49GGfpcHmm, it seems that it returns a function. The console log points to this#2020-12-1222:55GGfpcBut in the REPL it's nil#2020-12-1413:44GGfpcInterestingly, this library also does not work for me https://github.com/kauffecup/react-bubble-chart Could the problem be related to d3?#2020-12-1222:33GGfpcAlso, in another dependency I have the following issue:
The required JS dependency "core-js/es6/math" is not available, it was required by "node_modules/recharts/lib/polyfill.js".

Dependency Trace:
        goodstats/index.cljs
        goodstats/stats.cljs
        node_modules/recharts/lib/index.js
        node_modules/recharts/lib/polyfill.js
index.cljs imports all others so I'm able to fix the missing dependency on all but index.cljs by adding the following to index.cljs
(:require ["core-js/es6/math"])
Resulting in this. And now I don't know how to proceed.
The required JS dependency "core-js/es6/math" is not available, it was required by "goodstats/index.cljs".

Dependency Trace:
        goodstats/index.cljs
#2020-12-1413:44GGfpcInterestingly, this library also does not work for me https://github.com/kauffecup/react-bubble-chart Could the problem be related to d3?#2020-12-1309:38thheller@ggfpc12495 this is likely caused by a version conflict. make sure the dependency version listed in node_modules/recharts/package.json matches the actual node_modules/core-js/package.json version#2020-12-1309:38thhellerdon't know the lib but maybe ["@weknow/react-bubble-chart-d3" :refer (BubbleChart)] should be ["@weknow/react-bubble-chart-d3" :as BubbleChart]#2020-12-1312:06GGfpcThanks @thheller you were right about the conflict. As for the second tip, I had tried that to no avail 😕#2020-12-1319:08thheller@ggfpc12495 might also be ["@weknow/react-bubble-chart-d3" :default BubbleChart] see the translation table at https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2020-12-1319:19GGfpcI'm not sure if it's related to the import If you read this thread you can see some suggestions that I've tried https://clojurians.slack.com/archives/C6N245JGG/p1607808078432400#2020-12-1320:39BuidlerI'm getting this error in my ci:
WARNING: When invoking clojure.main, use -M
$ npx karma start --single-run
13 12 2020 20:36:56.964:WARN [filelist]: Pattern "/builds/buidler/prj/target/ci.js" does not match any file.
13 12 2020 20:36:56.975:INFO [karma-server]: Karma v5.2.3 server started at 
13 12 2020 20:36:56.976:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
13 12 2020 20:36:56.983:INFO [launcher]: Starting browser ChromeHeadless
13 12 2020 20:36:58.523:INFO [Chrome Headless 87.0.4280.66 (Linux x86_64)]: Connected on socket tCMp7MAbveBvUWK6AAAA with id 26441006
Chrome Headless 87.0.4280.66 (Linux x86_64) ERROR
  ReferenceError: shadow is not defined
      at eval (eval at <anonymous> (/builds/buidler/prj/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:1)
      at ContextKarma.start (/builds/buidler/prj/node_modules/karma-cljs-test/adapter.js:6:7)
      at ContextKarma.loaded ()
      at 
Cleaning up file based variables
ERROR: Job failed: exit code 1
It just randomly started happening without any related changes. Now if I go back to the last passing build and try to rebuild it, that fails too.
#2020-12-1322:18BuidlerMaybe it's the OOM killer. Looks like this issue has come up before https://clojurians-log.clojureverse.org/shadow-cljs/2019-01-05#2020-12-1409:17thheller13 12 2020 20:36:56.964:WARN [filelist]: Pattern "/builds/buidler/prj/target/ci.js" does not match any file.#2020-12-1409:17thhelleryeah looks like the file isn't created properly, likely OOM#2020-12-1408:55David PhamHello, I wonder if anyone managed to make the cljs repl work with https://vlaaad.github.io/reveal/ ? I like inspect but I would like to explore ways to stay in Emacs with the tap> function. I tried to add it as middleware, but taps are not communicated to the JVM (I think this is basic cljs vs clj repl). Anyone has an idea how we can solve this "easily"? Maybe create a server listening to the same websocket as shadow-cljs and forwarding this to reveal?#2020-12-1409:08thhellerI don't think reveal supports CLJS at this point but I don't really know#2020-12-1409:25David PhamThey have a nrepl middleware, but then it does not work once you entered the cljs repl.#2020-12-1410:14wilkerlucio@neo2551 I never tried, but in the docs it says to use the socket REPL for CLJS, look for remote-prepl at https://vlaaad.github.io/reveal#2020-12-1410:16David PhamI am think I am locked with shadow-cljs though 🙂#2020-12-1410:16David PhamMaybe I can create another process than the watch but with a remote-prelp#2020-12-1410:17David Phamwill try.#2020-12-1410:18David PhamBy the way, shadow-cljs inspect is really good, the most stable "rebl" like experience I found with cljs#2020-12-1418:46zhuxun2Is there a way to access rc/incline from JavaScript? https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2020-12-1418:47zhuxun2I would like to load a txt file (a glsl shader file) as a string, but in a javascript file. I couldn't find a way to do it using the closure compiler so I figured maybe I could rely on Shadow-CLJS?#2020-12-1420:39thheller@zhuxun2 no. this is a macro so it is only available in CLJS#2020-12-1508:10Chris McCormickIs there a way to get rc/inline to get a binary blob?#2020-12-1509:27thheller@chris358 no, but you can copy to macro to do so. it is a simple macro. just need to base64 encode it or so#2020-12-1615:09Pavel KlavíkHi, it happens to me quite frequently (several times every day) that while doing changes in the code, Shadow-cljs REPL stops working correctly and I have to restart Shadow to make it working again.#2020-12-1615:09Pavel KlavíkFor instance, I get the following in Cursive nREPL:
(clojure.string/join ["ab" "cd"])
Timeout while waiting for result.
#2020-12-1615:10Pavel KlavíkAnd shadow-cljs outputs this into console:
[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
#2020-12-1615:10Pavel KlavíkAny idea what could be causing this or how I could debug where is the problem?#2020-12-1615:12Pavel KlavíkAlso, all previous requires are lost when this happens. So for instance, I run the following code before:
(require '[orgpad.client.db.get :as db-get])
=> nil
I can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:2
 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name)
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var db-get/latest-editor
--------------------------------------------------------------------------------
#2020-12-1615:30rgmI have a client who wants to re-add limited IE11 support to an app. One technical problem is that we’re leaning on Vega for charting. Vega has switched over to a lot of spread / gather and arrow function syntax and relies on Symbols extensively. Am I understanding the shadow-cljs docs right that any npm dependencies it processes into the app bundle get ES5'd? Wondering if this is a reasonable enough way to get it to at least compile for loading into IE11. (I’m presuming there are still going to be runtime breakages that I can at least catch as exceptions and use to swap in a degraded UI).#2020-12-1616:08thheller@pavel.klavik which version? this should have been fixed a couple versions ago#2020-12-1616:09thheller@rgm the default is ES5 output so that should already work#2020-12-1616:10rgmIs this some kind of personal sorcery, or just what GCC does?#2020-12-1616:11thhellermostly GCC yes#2020-12-1616:11rgmEither way this beats heading into webpack/babel and foreign libs 🙏#2020-12-1616:12thhellerwell can't know for sure. sometimes some patterns aren't properly detected/polyfilled by GCC and need manual tuning#2020-12-1616:13thhellerbut most modern language features can be compiled down#2020-12-1616:19Pavel Klavík@thheller It seems that I am already running the latest version:
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/pavel/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.8 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
But I updated anyway using npm install -g shadow-cljs where I got
+ 
#2020-12-1616:21thhellerserver version: 2.11.8 looks fine yeah#2020-12-1616:21thhellerI'm not sure what could be causing this. I was not able to reproduce it again after the last fix#2020-12-1616:21thhellerwould help to know what else is going on over the nrepl connection and at what point it starts failing#2020-12-1616:23Pavel KlavíkI am not able to find a reproducible way yet. It occurs several times per day to be quite annoying but not enough frequently to be easily reproducible. Is there some debugging I could run when it occurs?#2020-12-1616:24thhellerI wrote a nrepl helper that logs all the messages back and forth, would help to have a dump from that#2020-12-1616:24thhellerclj -m shadow.nrepl-debug 3000 3001#2020-12-1616:25thhellertunnels from port 3000 to port 3001#2020-12-1616:25thhellerso clj -m shadow.nrepl-debug 9001 9000 would work if you then connect your editor to 9001 instead of 9000#2020-12-1616:29Pavel KlavíkOk, I got that running\#2020-12-1616:29Pavel Klavíkwhat would you want to get when it fails? the console output, or the debug message is stored somewhere else?#2020-12-1616:33thhellerit logs somewhere in target/nrepl-debug or so#2020-12-1616:33thhellerthe file would help#2020-12-1616:33Pavel KlavíkOk, I actually got it failing right now, with
Connecting to remote nREPL server...
Clojure 1.10.1
(shadow/repl :client)
To quit, type: :cljs/quit
=> [:selected :client]
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.
(+ 1 2)
Timeout while waiting for result.
#2020-12-1616:34Pavel Klavík#2020-12-1616:56thhellerthanks. I'll take a look#2020-12-1618:10thheller@pavel.klavik can't tell anything from the logs. this is a browser env right? is the browser maybe on a breakpoint in the debugger? break on uncaught exception or something? or js/alert? dunno why else it wouldn't respond to a simple eval#2020-12-1618:15Pavel Klavíknothing like that, I was not using any debugger#2020-12-1618:15Pavel Klavíkthe app was running fine#2020-12-1618:17thhellerguess I'll add some more logging to help figure this out#2020-12-1618:18thhelleroh one idea. do you have an actual cljs/user.cljs file on the classpath?#2020-12-1618:19Pavel KlavíkThere are clj/user.clj files generated by Luminus template, but certainly nothing like that. All my ns start with orgpad#2020-12-1706:25kimimHello. I am using material UI, when use project.clj from luminus template, everything works fine. But I switch to shdow-cljs cli, some component style is not working well. This branch is using lein: https://github.com/kimim/vorstellung and this branch uses shadow-cljs https://github.com/kimim/vorstellung/tree/shadow . When click Date Picker or DataGrid, the menu works wrongly.#2020-12-1710:01Shako FarhadHey guys. I have setup a shadow-cljs project with deps.edn. When I run the
clj -A:shadow-cljs-dev watch app
command I get a server up and running and things are great. But after I quit it with "ctrl + z" the server lingers forever. I can go to localhost:8700 and still see my app running there. If I restart the watch app then it will says that my build is stale and was not produced by the current watcher. Only workaround is to change the port. Anyone know how to fix this? Reboot doesn't help either. So something is cached somewhere? My deps.edn alias:
:shadow-cljs-dev
  {:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
                re-frame/re-frame {:mvn/version "1.1.2"}
                binaryage/devtools {:mvn/version "1.0.2"}
                re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305 
                                                                     re-frame/re-frame]}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}
I have manually killed all the processes, rebooted the pc etc. But when I go to localhost:8700, the app is still being served there. And in the corner it says "shadow-cljs reconnecting...". If I try to start a new watch on that same port it will say that it is stale.
#2020-12-1710:06kimimType “fg” will get it back#2020-12-1713:05Shako Farhadjust type fg in the terminal? THis waht I tried:
:/mnt/c/bec-core$ fg
-bash: fg: current: no such job
:/mnt/c/bec-core$ npx shadow-cljs fg
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"

Invalid action "fg"
#2020-12-1713:13thhellerfg only works after you ctrl+z a process. it is not a shadow-cljs command, its a linux thing#2020-12-1710:01thheller@kimi.im what do you mean by "shadow-cljs cli"? you should still start the server parts using lein?#2020-12-1710:02kimimno matter server is started by Leon or clj, the result is the same. I’ve compared with both.#2020-12-1710:03kimimI guess there is some thing I did wrong with shadow-cljs. The lein integrated way works fine.#2020-12-1710:03thhellerdo you get a 404 on some css or so?#2020-12-1710:04kimimcss is correctly loaded.#2020-12-1809:28kimimI think there are many problems. Firstly, material UI implement js loaded css, some element will overwrite the global css. Secondly, I do not know why use lein shadow there is no problem, but use shadow-cljs, there are problems. Anyway, I plan not use Material UI now.#2020-12-1810:16thhellerI can't do much without a reproducible repo. too many unknown for me. if you set one up I'll take a look and maybe fix it.#2020-12-1811:58kimimHello @thheller, I put two projects in github: https://github.com/kimim/shadow-mui Could you help to have a look? Thanks.#2020-12-1812:16thhellerhttps://github.com/kimim/shadow-mui/tree/master/shadow-cljs there is no shadow-cljs.edn?#2020-12-1812:18kimimsorry, it was ignored in .gitignore. Now I add it back.#2020-12-1812:22kimimand also package.json is ignored. I add it back also.#2020-12-1812:27thheller
$ clj -M:run
Syntax error (FileNotFoundException) compiling at (vorstellung/middleware.clj:1:1).
Could not locate vorstellung/env__init.class, vorstellung/env.clj or vorstellung/env.cljc on classpath.

Full report at:
/tmp/clojure-14799446093176938932.edn
#2020-12-1812:27thhellerin the shadow-cljs folder#2020-12-1812:27kimimsorry, please pull again, one config file is missing.#2020-12-1812:36thhellerone mistake I see is the deps.edn using :resource-paths. that is not a thing in deps.edn#2020-12-1812:38kimimThanks. If removed, there is the same problem. I’m just trying every possible solutions..#2020-12-1812:40thhellerother than that the only problem I see is that there is a justify-content: center; css rule on one element which causes everything to center#2020-12-1812:40thhellerdon't know why its there but thats the cause#2020-12-1812:40thhelleron .MuiButtonBase-root#2020-12-1812:41thhellerso far it looks like everything is working as intended?#2020-12-1812:42kimimIf use the shadow-cljs branch, when you click the red menu item, the menu will be in disorder#2020-12-1812:42thhellerthat is what I mean ...#2020-12-1812:43thheller"disorder" isn't quite right. it is "centered"#2020-12-1812:43kimimYes, centered and shrinked a little#2020-12-1812:44kimimThree button over the table “load, send and export” is also turn to white. It is blue in lein-shadow branch.#2020-12-1812:46kimimIf comment the table in src/cljs/vortellung/app/table.cljs: #_[people] everything turns OK#2020-12-1812:46kimimor this part:#2020-12-1812:47kimim
clojure
#_[:> m/TableContainer {:style {:height "80vh", :width "auto"}}
     [:> dg/DataGrid {:rows rows :columns cols :checkboxSelection true :autoPageSize true
                      :exportAllData true}]]```
#2020-12-1812:47thhellerthe lein run doesn't work at all for me#2020-12-1812:48thheller I get some swagger stuff#2020-12-1812:48thhellerah nevermind. I guess because the js is missing#2020-12-1812:50kimimIn lein-shadow branch, if lein run not work, you can use clj -M:run also. and use lein shadow watch home app#2020-12-1812:51thhellerwhy are home and app two builds?#2020-12-1812:52kimimhome build contains some authentification stuffs. But I removed in these two sample.#2020-12-1812:55thhellerI'm sorry but I really can't tell what is going on in this template at all#2020-12-1812:56thhellerwaaaaaaaaaaaaaaay to much other stuff I can't look at#2020-12-1812:56thhellerthe CLJS parts look fine but the CLJ server parts I can't figure out#2020-12-1812:59kimimBut If CLJ server is running with clj -M:run it should be same as shadow-cljs branch..#2020-12-1813:01kimimSo far as I know, the only different is the way to run shadow-cljs, with lein shadow or with shadow-cljs .#2020-12-1813:09kimimI try to reproduce the issue after remove the backend and some unrelated codes.#2020-12-2303:27kimimHello @thheller, I simplify the code in the same repo, could you help to have a look? Thanks: https://github.com/kimim/shadow-mui#2020-12-2310:03thhellercan you get rid of all the server-side code and just use :dev-http static webserver? the server parts are the confusing bits for me#2020-12-2311:25kimimI don’t how to create client only SPA. Thank you for your reminds. I will try :dev-http#2020-12-2311:26thhelleryou just take out everything that talks to the server#2020-12-2311:51kimimServer parts are removed now.#2020-12-2312:59thhellerso I upgraded the shadow-cljs version in lein-shadow to 2.11.10 so both variants use the same version#2020-12-2312:59thhellerand they look exactly the same then#2020-12-2313:02thhelleryou can add :js-options {:entry-keys ["browser" "main"]} to your build config which appears to make it work#2020-12-2313:03thhellerwhy I can't quite tell. looks like something in material-ui behaves differently when using "module" as well#2020-12-2313:04kimimThank you. I just realized that these two branches use different version of shadow-cljs, sorry for this.#2020-12-2313:07kimim:js-options {:entry-keys ["browser" "main"]} solve this issue. That’s great!#2020-12-2313:10thhelleryou should maybe consider removing this and just requiring all the esm code directly#2020-12-2313:11thhellerotherwise you end up with a weird mix of commonjs and esm#2020-12-2313:11thhellermaterial ui is one of those packages that contains 15 different variants on the code in one package#2020-12-2313:11thhellerbasically you just add an esm path to all requires#2020-12-2313:12thhellerso isntead of ["@material-ui/icons/Build" :default Build] you use ["@material-ui/icons/esm/Build" :default Build]#2020-12-2313:13kimimOK, I will try this solution. Thanks very much.#2020-12-2313:33kimimthis way is not working: `["@material-ui/icons/Build" :default Build]` to `["@material-ui/icons/esm/Build" :default Build]`#2020-12-2313:39thhellersorry no time to look into this today. guess the old way is fine then.#2020-12-2313:40kimimYes. :js-options {:entry-keys ["browser" "main"]} this way is fine now. Thank you for your time. It helps a lot.#2020-12-1710:02thheller@shakof91 ctrl+z sends the process to the background and keeps it running, ctrl+c stops it.#2020-12-1710:10Shako FarhadIt has the same behaviour. The page is stuck at "shadow-cljs - reconnecting ..." instead of showing a blank page after I run "ctrl + c". This is what I see in the console. In addition a lot of sourcemap warning spam comes too.
shadow.cljs.devtools.client.websocket.js:sourcemap:4 WebSocket connection to '' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
shadow$cljs$devtools$client$websocket$start @ shadow.cljs.devtools.client.websocket.js:sourcemap:4
eval @ shadow.cljs.devtools.client.shared.js:sourcemap:467
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shadow.cljs.devtools.client.shared.js:sourcemap:929
eval @ shadow.cljs.devtools.client.browser.js:sourcemap:952
goog.globalEval @ app.js:577
env.evalLoad @ app.js:1670
(anonymous) @ app.js:1945
shadow.cljs.devtools.client.shared.js:sourcemap:651 shadow-cljs - remote-error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
This wouldn't be a problem if I could run the watch command again and just be able to continue developement from the same port again, but I instead get this message: "Shadow-cljs - stale output! Your loaded js was not produced by the running shadow-cjs instance. Is the watch running?" Even if I try to delete the .shadow-cljs folder, the .cpcache folder and remove the app.js files, it will still say this as long as I use the same port.
#2020-12-1710:42thhellerI don't understand your issue. what do you expect?#2020-12-1710:42thhellerthe server started by lein is serving the content. shadow-cljs just produces the javascript and it needs to be running for that JS to connect back#2020-12-1710:42thhellerdon't start 2 shadow-cljs instances for the project or you will get a mess#2020-12-1710:44Shako FarhadMy expectation is that I can stop the watch and restart it later. So maybe I am not understanding how to start and stop it. I thought it was just to stop it with ctrl + c and run it again with "clj -A:shadow-cljs-dev watch app" again.#2020-12-1710:46Shako FarhadI am also expecting that the websocket will stop when I run ctrl + c so that the browser doesnt show my app anymore. I have disabled caching in the browser as well so I would expect that the app wouldn't linger when I go to localhost:8700 after I have stopped it. :x#2020-12-1710:47thhellerwhat commands do you run exactly? I mean to me it sounds like you just have 2 instances running#2020-12-1710:48thhellerfirst check there is actually only one instance running. you can check how many instances via jps or so#2020-12-1710:48Shako Farhad
{
  "name": "bec-core",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "watch-app": "clj -A:shadow-cljs-dev watch app",
    "release-app": "clj -A:shadow-cljs-prod release app",
    "cljs-repl": "clj -A:shadow-cljs-dev cljs-repl app"
  },
  "dependencies": {
    "react": "16.13.0",
    "react-dom": "16.13.0"
  }
}
That is my package.json and I run
npm run watch-app
It builds etc just fine and then I press "ctrl + c"
#2020-12-1710:49thhellerand what do you get?#2020-12-1710:49thhellerthere should be a "server shutdown" message#2020-12-1710:50Shako Farhad
shako$ npm run watch-app

> 
#2020-12-1710:50thhellerthats just the worker not the server#2020-12-1710:50thhellertry jps to see if there is a running java process#2020-12-1710:51Shako Farhad
shako$ jps
7582 Jps
shako$ jps -l
7600 jdk.jcmd/sun.tools.jps.Jps
I haven't used jps before. I am not exactly sure what to expect. :x
#2020-12-1710:53Shako FarhadI ran the jps command in the windows terminal instead of the WSL2 ubuntu terminal:
C:>jps
12576 RemoteMavenServer36
18528 Jps
17028 RemoteMavenServer36
3204 RemoteMavenServer36
5796 RemoteMavenServer36
6472 RemoteMavenServer36
12908 RemoteMavenServer36
14380 RemoteMavenServer36
12592 RemoteMavenServer36
16336
3408 RemoteMavenServer36
8592 RemoteMavenServer36
11316 RemoteMavenServer36
10552 RemoteMavenServer36
3672 RemoteMavenServer36
13212 RemoteMavenServer36
#2020-12-1710:54Shako FarhadTHis is the culprit huh? 😄#2020-12-1710:54Shako Farhad
C:>jps -l
12576 org.jetbrains.idea.maven.server.RemoteMavenServer36
17028 org.jetbrains.idea.maven.server.RemoteMavenServer36
3204 org.jetbrains.idea.maven.server.RemoteMavenServer36
5796 org.jetbrains.idea.maven.server.RemoteMavenServer36
6472 org.jetbrains.idea.maven.server.RemoteMavenServer36
12908 org.jetbrains.idea.maven.server.RemoteMavenServer36
14380 org.jetbrains.idea.maven.server.RemoteMavenServer36
12592 org.jetbrains.idea.maven.server.RemoteMavenServer36
16336
3408 org.jetbrains.idea.maven.server.RemoteMavenServer36
8592 org.jetbrains.idea.maven.server.RemoteMavenServer36
11316 org.jetbrains.idea.maven.server.RemoteMavenServer36
22100 jdk.jcmd/sun.tools.jps.Jps
10552 org.jetbrains.idea.maven.server.RemoteMavenServer36
3672 org.jetbrains.idea.maven.server.RemoteMavenServer36
13212 org.jetbrains.idea.maven.server.RemoteMavenServer36
#2020-12-1710:55Shako FarhadLooks like intellij processes, right?#2020-12-1711:02thhellermight be the 16336?#2020-12-1711:02thhellercheck with regular ps or so#2020-12-1711:03thhelleryou are using npm and clj and either of those may be causing the server to linger. I can't say. I can only help with actual running shadow-cljs commands#2020-12-1711:04thhellerany reason you are not using the shadow-cljs command?#2020-12-1711:09Shako FarhadWe are trying to use deps.edn for the dependancy management and the recommended way was to use the clj -A:alias watch app command to run shadow-cljs through the shadow-cljs.devtools.cli.#2020-12-1711:10thhellerno that isn't recommended anywhere#2020-12-1711:10thhelleryou can still use deps.edn to manage dependencies. that is totally fine.#2020-12-1711:11Shako Farhadhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn
Running with clj directly.

{:paths [...]
 :deps {...}
 :aliases
 {:shadow-cljs
  {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
clj -A:shadow-cljs watch app
Is what I followed in the documentation. Perhaps I am just too noob to know how to properly setup and run with deps.edn :s
#2020-12-1711:13thhellerthat is meant as an example that you CAN run with clj directly. doesn't mean you should.#2020-12-1711:14thhellerit is completely fine to do this. I just can't help you with debugging issues then 😛#2020-12-1711:14thhelleryou should run the regular shadow-cljs watch app and so on#2020-12-1711:14thhellerI guess I should clarify that in the docs#2020-12-1711:14Shako FarhadHow can I setup dev dependancies and prod dependancies when using deps.edn and shadow-cljs installed globally? 😮#2020-12-1711:16thhelleryou don't have to in CLJS#2020-12-1711:16thhellerjust keep everything on the classpath all the time#2020-12-1712:47Shako FarhadI am sorry I am really noob at this. What exactly do you mean? Just ignore deps.edn and let shadow-cljs handle the deps? This is how I have set it up: deps.edn
{:paths ["src" "resources" "target"]

 :deps
 {org.clojure/clojure {:mvn/version "1.10.1"}}

 :aliases
 {:cljs
  {:extra-deps {thheller/shadow-cljs {:mvn/version "RELEASE"}
                re-frame/re-frame {:mvn/version "1.1.2"}
                binaryage/devtools {:mvn/version "1.0.2"}
                re-frisk/re-frisk {:mvn/version "1.3.5" :exclusions [com.google.code.findbugs/jsr305
                                                                     re-frame/re-frame]}}}}}
shadow-cljs.edn
{:deps {:aliases [:cljs]}

 :builds
 {:app
  {:target :browser
   :output-dir "resources/public/js"
   :modules {:app {:entries [bec-core.cljs.core]}}

   :js-options {:js-package-dirs ["node_modules"]}

   :compiler-options {:infer-externs :auto}

   :dev {:closure-defines {goog.DEBUG true}}
   :devtools
   {:before-load bec-core.cljs.core/stop
    :after-load bec-core.cljs.core/start
    :http-root    "resources/public"
    :http-port    8711
    :preloads     [devtools.preload
                   re-frisk.preload]}}}}
Running it like this:
$ npx shadow-cljs watch app
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.8 running at 
shadow-cljs - nREPL server started on port 60273
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (270 files, 59 compiled, 0 warnings, 24.61s)
^C
$ Worker shutdown.
npx shadow-cljs stop app
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - server not running
I don't know how to exlude refrisk and dev-tools dependancies from the release version of the app. Also even when I run shadow-cljs through npx it still has the same issue. I can't stop the server with ctrl + c. The browser still shows the old app running and a new watch on the same port won't update anymore. It will just ocmplain about a stale build.. 😕
#2020-12-1713:11thhelleryou don't need to exclude dev stuff from release. shadow-cljs only includes what you actually require in your code in the build#2020-12-1713:11thhellerso it absolutely does not matter if devtools and refrisk are on the classpath for release builds#2020-12-1713:11Shako FarhadAh I understand! Wow that is smart! 😄#2020-12-1713:12thhelleryou also don't need these
:js-options {:js-package-dirs ["node_modules"]}

   :compiler-options {:infer-externs :auto}

   :dev {:closure-defines {goog.DEBUG true}}
#2020-12-1713:12thhellerthose are already the defaults#2020-12-1713:12thhellerI don't have a clue why you can't stop the server via ctrl+c. which OS is this?#2020-12-1713:13thhellerwhich clojure version?#2020-12-1713:14Shako FarhadI am running on windows 10 in WSL2 ubuntu terminal.
$ clj --help
Version: 1.10.1.561
#2020-12-1713:15thhellerso if you just run shadow-cljs server and ctrl+c that the process still lingers?#2020-12-1713:21Shako Farhad
$ npx shadow-cljs server
shadow-cljs - config: /mnt/c/Users/shako/OneDrive/Documents/GitLab/bec/bec-core/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.8 running at 
shadow-cljs - nREPL server started on port 50490
^C
THe page at http://localhost:9630 dissappears when I reload it. So it works as expected when I ctrl + c. But http://localhost:8712 is still there. "Shadow-cljs - reconnecting..." And when I start the server the message just becomes "Shadow-cljs stale build etc."
#2020-12-1713:22Shako FarhadWindows terminal result:
C:\bec-core>jps -l
10088 jdk.jcmd/sun.tools.jps.Jps
1980
Ubuntu terminal result:
bec-core$ jps -l
9068 jdk.jcmd/sun.tools.jps.Jps
#2020-12-1713:23thhellerif you start it in wsl2 then only that matters. the windows side doesn't matter at all.#2020-12-1713:23thhellercan't mix them#2020-12-1713:24Shako FarhadAlright. All commands are run in WSL2. I don't have clojure installed on windows 10, only in WSL2.#2020-12-1713:24thhellerget your system into a state where serves nothing#2020-12-1713:24Shako FarhadYes, I am trying the best I can. I even rebooted the machine and it still is there :s#2020-12-1713:25thhellerok that is definitely not shadow-cljs then#2020-12-1713:25thhellermaybe you have some other server running there or some cache stuff I don't know#2020-12-1713:26Shako FarhadMy app starts a service worker to register the app. Is it perhaps that which is causing it to not let go?#2020-12-1713:30Shako FarhadYep. Now it behaves as expected! I removed this piece of the code:
(try
    (-> (. js/navigator.serviceWorker (register "/service-worker.js"))
      (.then (fn [] (js/console.log "service worker registered"))))

    (catch js/Object err (js/console.error "Failed to register service worker" err)))
And now the browser is properly letting go. So it is probably a chrome issue. I wonder how to fix it...
#2020-12-1713:32thhellerah you used a service worker ... yeah you shouldn't cache the output of a watch build ever. just disable that in the worker.#2020-12-1713:35Shako FarhadIs it possible to output the release version to a different directory than the watch build output? I could then set the service worker to cache the release version only? Or perhaps the right way to do this is to register the service worker in release mode only, using the goog.DEBUG to toggle the registering of the service worker... Not sure what is best to do 😮#2020-12-1713:46Shako FarhadOne solution for now is to just clear the service-worker cache: inspect -> application -> clear storage#2020-12-1713:54thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2020-12-1713:54thheller:release {:output-dir "somewhere/else"}#2020-12-1713:55Shako FarhadAh! THat is wonderful! Thank you! I understand now. I am sorry for taking so much of your time. I appreciate your help!#2020-12-1714:29Michaël SalihiHello @thheller Since your proposition was not seleted, I wonder to know how to do without the convenient Shadow-CLJS's :default on vanilla CLJS. https://clojure.atlassian.net/browse/CLJS-2376#2020-12-1714:30Michaël SalihiHasn't that changed since the issue?#2020-12-1714:30thheller(:require ["foo$default" :as x]) will be the default solution but I don't think it is released yet#2020-12-1714:31thhellervs (:require ["foo" :default x]). you can also always do (:require ["foo" :as x]) and then x/default#2020-12-1714:40Michaël SalihiI just test with Krell and this don't works with this RN lib https://github.com/kmorales13/react-native-alarm-clock I'll try with RN Shadow-CJLS and see if it comes from the lib which may be specific.#2020-12-1715:31Michaël Salihi@thheller So I just tried with Shadow-CLJS and your "reagent-react-native" repo.
(ns 
  (:require
    [shadow.react-native :refer (render-root)]
    ["react-native" :as rn]
    ["react" :as react]
    [reagent.core :as r]
    ["react-native-alarm-clock" :default AlarmClock]))

(defn create []
  (let [date (.toISOString (js/Date.))]
    (.createAlarm AlarmClock date "Alarm test")))
#2020-12-1715:32Michaël SalihiAnd I have this error#2020-12-1715:33Michaël SalihiThis lib seems specific right? https://github.com/kmorales13/react-native-alarm-clock/blob/master/src/index.tsx#2020-12-1715:50Michaël SalihiA little idea @thheller please?#2020-12-1715:59thhellerI don't have a clue. it might be ["react-native-alarm-clock" :as AlarmClock]?#2020-12-1715:59thhellerdefault exports are tricky sometimes because it also depends on how the library is bundled. looking at the code does not always match what the actual published package uses.#2020-12-1716:04Michaël SalihiOK, I can see the published package provides 3 versions#2020-12-1716:05Michaël SalihiHow does CLJS do in this case?#2020-12-1716:06Michaël SalihiCommonJS take predecence?#2020-12-1716:08Michaël Salihi@thheller I think I have a lead. The CommonJS and module version export this var _default#2020-12-1716:09Michaël Salihi
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _reactNative = require("react-native");

const {
  AlarmClock
} = _reactNative.NativeModules;
var _default = AlarmClock;
exports.default = _default;
//# sourceMappingURL=index.js.map
#2020-12-1714:34Michaël SalihiOh OK, I thought this issue was merged https://github.com/clojure/clojurescript/commit/f5f9b79f6f446cef768e190971cf67fc78bf5b93 Thanks for your help!#2020-12-1715:57thhelleryes it is in master. just not in any official release I think.#2020-12-1716:18valeraukoHey @thheller could you please explain how shadow-cljs compiles dependencies? Users declare dependencies, you fetch them using aether... and then? How do the .cljc bits make it into the JS source code?#2020-12-1716:19valeraukoI've been trying to read the source of shadow-cljs but couldn't find where this magic happens
#2020-12-1716:45thhellernot sure I understand the question#2020-12-1716:45thheller.cljc files are just source code somewhere on the classpath#2020-12-1716:45thhellerso if you require the foo.bar somewhere in your code#2020-12-1716:45thhellerit'll look for foo/bar.cljs or foo/bar.cljc#2020-12-1716:46thhellerthen it compiles those. code is in shadow.build.compiler#2020-12-1716:47valeraukoBut how do you acquire the cljc out of the jars? Do the jars contain the raw cljc files?#2020-12-1716:47thhelleryes#2020-12-1716:49thhellerthe files are loaded via ( "foo/bar.cljc")#2020-12-1716:49thhellerdoesn't matter if its a regular file or in a jar. jvm classloader handles that.#2020-12-1716:49valeraukoSo basically you have maven (aether) fetch the jars (and unpack them?) then collect all the cljc/cljs files and give them to the compiler?#2020-12-1716:49valeraukoThe CLJS compiler can walk into jars?#2020-12-1716:50thhellerit doesn't have to. the jvm classloader does.#2020-12-1716:50thhellerjars are never unpacked (on disk, happens all in memory only)#2020-12-1716:53valeraukoOhh I see, jvm magic! Does the CLJS compiler look for cljs/cljc files on its own or do you have to feed it the files "manually"?#2020-12-1717:06thhellershadow-cljs will load and read them#2020-12-1717:21valeraukoAwesome, I understand! Thanks a lot!#2020-12-1720:35tomc@thheller looks like http://shadow-cljs.org/ might be down? Not loading for me.#2020-12-1804:01JonI think it's during migrating.#2020-12-1804:01Jonthe old content can be found at https://github.com/shadow-cljs/shadow-cljs.org/blob/master/markdown/introduction.md#2020-12-1723:07cobyis there a way to get browser tests to pretty-print failures, so that they're not all on one line like this? I'm guessing I would need a custom :ns-runner but beyond that it's hazy...#2020-12-1723:11dpsuttoni think that's the output from @bhauman’s excellent cljs-test-display#2020-12-1723:27cobyChecking that out, thanks for the tip!#2020-12-1808:18Eugenhi, http://shadow-cljs.org/ is down for me#2020-12-1808:19Eugennow it directs to github#2020-12-1808:38EugenI've just ran npx create-cljs-project web-syntax-highligh and got
web-syntax-highlight
├── node_modules
|-- REDACTED
├── package.json
├── package-lock.json
├── shadow-cljs.edn
└── src
    ├── main
    └── test
It is a bit surprising - no files are present? Is this expected?
#2020-12-1808:48Eugenalso shadow-cljs is almost empty
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]
 :dependencies
 []
 :builds
 {}} 
#2020-12-1809:10EugenI checked my previous project and I was using https://github.com/filipesilva/create-cljs-app which provides a more opinionated experience for new apps - which is what I need#2020-12-1812:55Jakub Holý (HolyJak)Hello! In JS, with Webpack, I can do
import "some_node_module/some.css"
Is something similar possible with Shadow? I could cp node_modules/some_node_module/some.css public every time before I deploy but ☝️ is even less effort.
#2020-12-1812:56thhellerno, CSS is not supported#2020-12-1813:59Eugen@holyjak I've also hit shado-cljs webpack integration just now. Trying to make a clojurescript app with monaco-editor (VSCode in browser). Can you share some hints/ strategies on how to approach it? All monaco examples seem to be with webpack or directly in browser#2020-12-1815:33Jakub Holý (HolyJak)Sorry, I do not integrate with web pack#2020-12-1817:01flowthing@U011NGC5FFY https://www.reddit.com/r/Clojure/comments/9p4xh0/has_anyone_successfully_used_microsofts/#2020-12-1818:08Eugenthank you, that confirmed my worries 🙂#2020-12-1818:19EugenI found this out and going to try it https://github.com/suren-atoyan/monaco-react#2020-12-1818:19Eugenlooks promissing#2020-12-1818:19flowthingI'd be interested in hearing whether it works for you.#2020-12-1818:19Eugensure I will update you#2020-12-1818:56Eugenit works, I can see the editor and type into it
(ns app.monaco
  (:require [reagent.core :as r]
            ["@monaco-editor/react" :as Editor]))

(defn editor []
  [:<>
   [:p "Hello, hledger-web-demo is running!"]
   [:p "Here's an example of using a component with state:"]
   [(r/adapt-react-class Editor/default) {:height "90vh" :languge "javascript"}]])
#2020-12-1819:03flowthingNice, thanks for letting me know!#2020-12-1819:06flowthing(Just a small side note: you can also do [:> Editor/default ,,,] instead of r/adapt-react-class.)#2020-12-1819:09Eugenthanks, I'll have to read throught the re-agent docs 🙂#2020-12-1814:01EugenI can't even import the JS because of :
(ns app.monaco
  (:require [reagent.core :as r]
            ["react-monaco-editor" :default monaco]))

----
Failed to inspect file
  /home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css

it was required from
  /home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js

Errors encountered while trying to parse file
  /home/ieugen/proiecte/hledger-grammars/examples/hledger-web-demo/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css
  {:line 8, :column 1, :message "primary expression expected"}
#2020-12-1814:14Eugen@thheller Monaco seems to distribute module with esm that imports CSS so requireing it in shadow, fails. Do you have any suggestions on how to approach this sittuation? https://microsoft.github.io/monaco-editor/#2020-12-1815:10flowthingMy understanding is that if I use an NPM module that uses e.g. Object.assign and I want shadow-cljs handle polyfills for me such that the resulting JS bundle works with IE11, I just need to add :js-options {:babel-preset-config {:targets {:ie 11}}} into my shadow-cljs.edn. That doesn't appear to work, though: I still get Object doesn't support property or method 'assign'. Should that work, or should I take another approach? FWIW:
λ du -hs .shadow-cljs/babel-worker/babel-worker.js
2.8M    .shadow-cljs/babel-worker/babel-worker.js
#2020-12-1815:43JAtkinsHas anyone seen the $jscomp error? I'm seeing this on the console of my release build occasionally.
shadow-cljs - failed to load 973
jLb @ main.js:14558
CZ @ main.js:14559
(anonymous) @ main.js:15924
(anonymous) @ main.js:18690
main.js:6386 Uncaught ReferenceError: $jscomp is not defined
    at main.js:6386
    at main.js:6028
    at Object.shadow$provide.<computed> (main.js:6028)
    at jLb (main.js:14558)
    at main.js:6630
    at Object.shadow$provide.<computed> (main.js:6630)
    at jLb (main.js:14558)
    at Object.shadow$provide.<computed> (main.js:6770)
    at jLb (main.js:14558)
    at Object.shadow$provide.<computed> (main.js:6771)
This is reproducible with the same code. However, I cannot find what in the code is inducing this behavior.
#2020-12-1815:54thheller@jatkin $jscomp is for polyfills. which version do you use? I thought I had fixed those issues. if you can afford it the best option is setting :compiler-options {:output-feature-set :es6} or higher if you can (:es7, :es8, ...)#2020-12-1815:57JAtkinsI'm using 2.11.8#2020-12-1815:54thheller@flowthing not all sources are processed with babel so that might not apply. you can set :compiler-options {:force-library-injection #{"es6/object/assign"}}#2020-12-1815:54thhellernot 100% sure on the name but I think thats it#2020-12-1816:05flowthing@thheller Thank you! I'll give it a shot and let you know. How do I figure out what to put in :force-library-injection if I need polyfills for other things?#2020-12-1816:05thhellerpathnames from here https://github.com/google/closure-compiler/tree/master/src/com/google/javascript/jscomp/js#2020-12-1816:05flowthingGreat, thanks!#2020-12-1816:24ghaskins@thheller we've been using your :proxy-predicate feature to great success, thanks again for that. A related problem we are running into is Secure cookie handling when using the dev-proxy against a TLS backend. I think what we need to do is simply strip the "Secure" flag in the cookies as they pass through when the backend is https, which I think is essentially the opposite of https://undertow.io/javadoc/2.0.x/io/undertow/server/handlers/SecureCookieHandler.html#2020-12-1816:25ghaskinsi was trying to see where I might propose such a feature: it looks like it might fit somewhere in here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/undertow.clj#L304#2020-12-1816:25ghaskinsbut guidance appreciated#2020-12-1816:58flowthing@thheller It works, many thanks! This really saves me a lot of trouble. Sadly, the Closure compiler doesn't provide a polyfill for Symbol.for, so I need to figure out a way to add one myself.#2020-12-1819:02crsadvanced compilation question. Is there an annotation that preserves a name rather than just exporting an alias? E.g.
shadow$umd$export = {MyName:MyName}
instead of
shadow$umd$export = {MyName:kA}
I want the meaningful name to be available for debugging when logging this object in the console
#2020-12-1819:14thheller@chris.smothers externs control that. if you add MyName to externs it won't be renamed. https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2020-12-1819:32crsI’m trying this and it’s still getting renamed. Is there a special syntax for CLJS namespaces? ns/var or ns$var ?#2020-12-1821:51thhellerno just MyNane one line#2020-12-1819:17thheller@ghaskins not a clue. seems like that would need to be something the proxy handler from undertow has to do? not sure we can control that#2020-12-1819:22lilactownhey thheller. I have a lib that has certain feature flags you can turn on locally for certain runtime and compile time behavior, like:
(defnc my-component []
  {:helix/features {:fast-refresh true}} ;; turn on compile-time processing for react-refresh
  )
I'm trying to figure out an easy way for consumers to enable this globally w/o wrapping the defnc macro. wdyt?
#2020-12-1821:52thhelleryou can use the same stuff as cljs-devtools I guess but closure defines would work too#2020-12-1821:52thhellerhttps://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.clj#L8-L12#2020-12-1819:23lilactownI thought about :closure-defines but I don't think that would work here, since I don't think I can get at those during compile-time to know whether I should do the processing#2020-12-1819:36ghaskins@thheller i reverse engineered Undertow's SecureCookieHeader to come up with this prototype
commit 4a9ea2d9e07c6f87364ef9f613b31751e935be8f (HEAD -> strip-secure-2.10-backport, refs/patches/strip-secure-2.10-backport/dev-http-strip-secure-cookies)
Author: Greg Haskins <
#2020-12-1819:36ghaskinsits hooking the right place, now im just sorting out the details#2020-12-1819:37ghaskins(ProxyHandler was where I looked first, but it doesnt seem to be extensible at that layer...but Undertow in general is)#2020-12-1819:41ghaskinsanyway, assuming you are conducive to such a feature, you can guide me on how best to integrate it for merge consideration after I prove out the if/how#2020-12-1821:44thheller@ghaskins can't you just configure SSL for shadow-cljs? that seems to be the easiest option?#2020-12-1822:03ghaskins@thheller on the dev-proxy? is that an option#2020-12-1822:03ghaskins?#2020-12-1822:04ghaskinsi know sometimes dealing with the self-signed certs is a pain, too, but I havent tried to do that#2020-12-1822:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_ssl#2020-12-1822:14thhellercerts can be a bit annoying yeah#2020-12-1822:41JBI'm getting cannot instantiate non-constructor when I run shadow-cljs check buildName despite trying simple externs ConstructorThing and manual externs
/**
 * @constructor
 */
constructorThing = function() {};
#2020-12-1822:42JBI'm also prepending ^js/ to the name#2020-12-1822:53thhellercheck is not reliable. thats why it is not documented. it will always give you a lot of false positives#2020-12-1823:28JBAh thanks for clarifying! I saw in the the “simplified externs” section of the docs and assumed it was #2020-12-1822:48ghaskins@thheller ty for the doc link, I didnt know that was an option. Still, it may be worth considering some version of what I am proposing as it reduces dev friction to not have to deal with SSL unless necessary. We have found that this patch solves our problem
commit 836ec3dfe35bc3342f76e5ed0373163e8f8b47c5 (HEAD -> strip-secure-2.10-backport)
Author: Greg Haskins <
#2020-12-1822:49ghaskinsif you are open to considering some form of it, id be happy to work a PR to your satisfaction#2020-12-1822:54thhellerlooks fine to me just rather hard to test#2020-12-1823:44wilkerluciois there a way to set a custom REPL timeout for (shadow/browser-repl)?#2020-12-1900:32wilkerlucio
(shadow/browser-repl {:devtools {:repl-timeout 3000000}})
#2020-12-1823:59ghaskins> looks fine to me just rather hard to test Its a good point. I can probably at least split the header-handling into a defn so I can add a test for it. I will do so#2020-12-1823:59ghaskinsty#2020-12-1908:53Pavel KlavíkHi, I have just encountered the following surprising thing. When I want to encode a fixes large set (say of strings) into the code, using #{...} generates a twice as large code than (set #js [...]) which generates the set at the start. Why is that?#2020-12-1909:51thhellerare you sure its still twice as large after :advanced? that usually takes care of that?#2020-12-1919:46Pavel KlavíkI was comparing the output size given by
shadow-cljs run shadow.cljs.build-report app report.html
#2020-12-1920:56thhellerhmm odd. I don't actually know what kind of code this generates. might be worth opening an issue in CLJS for if its really bad.#2020-12-2014:56Pavel KlavíkLooking into generated code, this is how (set #js [...]) looks:
var oRa = $APP.Cj("aaa aarp abarth abb abbott abbvie ... [a lot more] ... yoga yokohama you youtube yt yun za zappos zara zero zip zm zone zuerich zw".split(" "));
Which looks like a clever Google Closure optimization. And this is how #{...} looks:
var oRa = new $APP.yj(null,new $APP.m(null,1504,["studio", null, "etisalat", null, "mortgage", null, "xn--gecrj9c", null, "technology", null, "nl", null, "lilly", null, "wolterskluwer", null, "schmidt", null, "hisamitsu", null, "total", null, "blue", null, "aw", null, "zw", null, "properties", null, "amex", null, "linde", null, "arpa", null, "ieee", null, ... [a lot more] ... , "fairwinds", null, "lk", null, "itau", null],null),null);
Not sure why set constructor has alternating strings with nulls.
#2020-12-2015:07Pavel KlavíkThe latter corresponds to this in unoptimized build:
orgpad.common.util.tld.all_tlds = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1504, ["studio",null,"etisalat",null,"mortgage",null,"xn--gecrj9c",null,"technology",null,"nl",null,"lilly",null,"wolterskluwer",null,"schmidt",null,"hisamitsu",null,"total",null,"blue",null,"aw",null,"zw",null,"properties",null,"amex",null,"linde",null,"arpa",null,"ieee",null, ... [a lot more] ...,"fairwinds",null,"lk",null,"itau",null], null), null);
No idea why inner PersistentArrayMap is created. The former corresponds to this:
orgpad.common.util.tld.all_tlds = cljs.core.set(["aaa","aarp","abarth","abb","abbott","abbvie", ... [a lot more] ...,"yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"]);
#2020-12-2015:25Pavel KlavíkPosted to ask.clojure, so I will see whether this will lead to something#2020-12-2114:45AJ JaroHas anyone experienced extremely high CPU load using shadow-cljs? I have seen upwards for 900% and it seems to be resolved after killing my command: npx shadow-cljs watch …#2020-12-2115:09thhellerwell it'll use all available CPU while compiling but otherwise should be mostly idle#2020-12-2115:10thhellerthere was a while where it used much more CPU than it should have but that was a long time ago. can't remember which version though.#2020-12-2120:21AJ JaroI’m on version 2.11.4. If it’s “watching” then it could potentially be compiling a fair amount as I switch branches I guess @thheller#2020-12-2120:51thhellerif a lot of files change then of course that'll trigger a compile#2020-12-2201:16AJ Jaroyep, that makes sense it’ll recompile, but from my experience that high CPU usage can sometimes continue for quite a while even after the build is completed.#2020-12-2202:52royalaidHey @thheller I have been playing around with https://github.com/jpmonettas/flow-storm and when I tried to wire it up from node.js output I ran up against an issue with how to include the ws npm package.#2020-12-2202:53royalaidBecause flow-storm leverages sente I figured I would look there#2020-12-2202:53royalaidand https://github.com/ptaoussanis/sente/blob/master/src/taoensso/sente.cljc#L1062-L1064 seems to be the root of the issue, if I :require "ws" it isn't in a spot where sente expects#2020-12-2202:54royalaidwhat is the recommended way to solve this?#2020-12-2202:55royalaidShould I monkey patch the goog/global obj (this what I am planning right now), should I issue some kind of PR to sente, or does Shadow have some cool workaround in the config I can setup?#2020-12-2202:55royalaidMaybe something else?#2020-12-2210:17thheller@royalaid from what I can tell it expects the node websocket package, not ws? it certainly tries to hide that require as much as possible 😛#2020-12-2216:57royalaid@thheller I think it is so that it works around some react native stuff, and ws is the npm websocket package complicating this all the more 😂#2020-12-2216:58thhellerI do understand why they do this hack. I do not understand why you are talking about the ws package. there is an actual websocket package they expect. at no point do I see any reference to ws?#2020-12-2221:54royalaidYa know, upon reflection I think you might be on to something. I may have been conflating the two this whole time.#2020-12-2223:06thhellershadow-cljs actually uses the ws package for node so you'll need both but as far as sente is concerned that expects websocket#2020-12-2309:06kimimHello, How can I conditionally use different :source-paths for dev and release? thanks.#2020-12-2310:01thheller@kimi.im with shadow-cljs.edn you can't. I consider this an anti-pattern that should be avoided so its not supported out of the box. you can do it when using deps.edn or project.clj if you really need to#2020-12-2310:04kimimthen I should use two different files in the same source path for dev and prod? Is that ok?#2020-12-2310:11thhellerwhat are you trying to do? what do you mean by "two different files"?#2020-12-2310:12thhellerthis is usually an anti-pattern in shadow-cljs because it does things differently then other tools. so the problem that this pattern is trying to fixed is already fixed. see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2020-12-2310:41Pavel KlavíkHi, the REPL problem we discussed occured to me right now and I noticed the following output in browser console:#2020-12-2311:22thhellersorry I talk to too many people. which problem? 😛#2020-12-2311:23thhellerthat looks like a regular repl load sequence so I don't see the issue?#2020-12-2313:05Pavel Klavíkthe bug where requires are lost, occurs sometimes#2020-12-2313:07Pavel Klavík[reposting the original report] Hi, it happens to me quite frequently (several times every day) that while doing changes in the code, Shadow-cljs REPL stops working correctly and I have to restart Shadow to make it working again. [4:09 PM] For instance, I get the following in Cursive nREPL:
(clojure.string/join ["ab" "cd"])
Timeout while waiting for result.
[4:10 PM] And shadow-cljs outputs this into console:
[2020-12-16 16:07:58.625 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 71}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/fn--15184/fn--15187 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
[4:10 PM] Any idea what could be causing this or how I could debug where is the problem? [4:12 PM] Also, all previous requires are lost when this happens. So for instance, I run the following code before:
(require '[orgpad.client.db.get :as db-get])
=> nil
I can use functions from db-get perfectly fine. After this, I can't call them and I get this error in REPL:
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:2
 No such namespace: db-get, could not locate db_get.cljs, db_get.cljc, or JavaScript source providing "db-get" (Please check that namespaces with dashes use underscores in the ClojureScript file name)
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var db-get/latest-editor
--------------------------------------------------------------------------------
#2020-12-2313:08thhellerplease open a github issue if you want to get any kind of progress on this. there is far too much going on in slack for me to keep track of it all.#2020-12-2313:08Pavel Klavíkok, I will do that 🙂#2020-12-2313:08thhellerI do remember this now but still don't have a clue what is going on and also still can't reproduce it#2020-12-2313:09thhellerseems similar to this maybe https://github.com/thheller/shadow-cljs/issues/788#2020-12-2313:11Pavel KlavíkSeems to be related, I will put it there#2020-12-2315:46GGfpcThis might be a super dumb question but I'm not familiar with frontend. I'm using reagent with shadow-cljs, when I do shadow-cljs release should I be able to serve the app just from my browser by opening index.html or will I always need a webserver?#2020-12-2315:50dpsuttonyou'll need a webserver. in that index.html will be a reference to your js bundle that the browser will attempt to fetch. without a webserver that fetch will fail#2020-12-2315:50dpsuttonamong likely other things like css and images#2020-12-2315:51thhellerthats not entirely true. you can load it directly from the filesystem but you are going to be limited in what you are allowed to do since browsers restrict some stuff if loaded from disk#2020-12-2315:52thhellerits best to use a server#2020-12-2315:53GGfpcok so basically I can't host it on github pages or S3?#2020-12-2315:53thhelleryep#2020-12-2315:55dpsuttoni thought github pages and s3 both can do this. that yep meant those things will work? also, netlify makes this amazingly easy#2020-12-2315:55thhellerhaha didn't see the "can't". just read "can". sorry. yes of course those are fine.#2020-12-2315:55thhelleranything that speaks http and knows how to serve files is fine.#2020-12-2320:45nivekuilhello, I'm trying to use https://github.com/kunukn/react-collapse imported like #?(:cljs ["@kunukn/react-collapse" :default Collapse]) but when it's rendered this happens:
ERROR [com.fulcrologic.fulcro.react.error-boundaries:31] - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
first time I've run into an error like this, not sure if there's something special about importing this module into shadow-cljs?
#2020-12-2320:46nivekuilversion is shadow-cljs 2.11.10#2020-12-2320:49thhellerlikely means that Collapse is nil. might be :as Collapse or :refer (Collapse)#2020-12-2320:49nivekuiloh, it was :as Collapse#2020-12-2320:50nivekuilI only tried :refer; didn't even know you could import a whole class like a ns#2020-12-2320:51nivekuilis there some rule for when that needs to be done? I see export default Collapse in the library, so I thought it'd be a default export#2020-12-2320:51nivekuilthanks a lot though :)#2020-12-2320:59David PhamYeah, what is the rule? I usually have to make trial and errors haha#2020-12-2321:00thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2020-12-2405:16David PhamThanks! #2020-12-2521:26Chris O’DonnellAnyone have an idea why I'm getting this warning?
Warning :infer-warning in rocks/mygiftlist/http_remote.cljs at 106:8

Cannot infer target type in expression (. inst_93897 (setResponseType inst_93951))

 103 |      (fn transmit! [{:keys [active-requests]}
 104 |                     {::txn/keys [ast result-handler update-handler]
 105 |                      :as        send-node}]
 106 |        (go (let [edn              (eql/ast->query ast)
 107 |                  ok-handler       (fn [result]
 108 |                                     (try
 109 |                                       (result-handler result)
 110 |                                       (catch :default e
Full source is at https://github.com/codonnell/mygiftlist-blog/blob/dokku-deploy/src/cljs/rocks/mygiftlist/http_remote.cljs The error message seems to reference https://github.com/codonnell/mygiftlist-blog/blob/dokku-deploy/src/cljs/rocks/mygiftlist/http_remote.cljs#L150, which is already hinted.
#2020-12-2614:28GGfpcHello! Is there anyway I can set up an environment variable that is replaced at build time? For instance, I want my source code to have an IP address pointing to localhost, but when I release a build I want it to be replaced with my server's address#2020-12-2614:32oconnI use closure-defines for this kind of configuration. https://clojurescript.org/reference/compiler-options#closure-defines & goog-define https://cljs.github.io/api/cljs.core/goog-define where the second argument would be your default localhost address#2020-12-2614:33Chris O’Donnell☝️ Same. There's a section on how to use them in the user guide, too: https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines.#2020-12-2615:07GGfpcthat's perfect, thanks!#2020-12-2615:32David PhamI use deps.edn and aliases with a namespace containing a map with all the variables.#2020-12-2615:38oconnHi, I’m looking to use shadow-cljs to self-host a cljs project in a web worker. I feel like I’m close and probably configuring my build wrong… In my shadow-cljs.edn config I have my cljs worker build configured like this;
{:builds {:cljs-worker {:target :browser
                        :output-dir "resources/public/js"
                        :asset-path "/js"
                        :compiler-options {:optimizations :simple}
                        :modules {:cljs-worker-base {:entries [shadow.cljs.bootstrap.env]}
                                  :cljs-worker {:init-fn workers.cljs.core/init!
                                                :depends-on #{:cljs-worker-base}
                                                :web-worker true}}}
In workers.cljs.core i’ve got;
(ns workers.cljs.core
  (:require [cljs.env :as env]
            [cljs.js :as cljs]
            [shadow.cljs.bootstrap.browser :as boot]))

(defn- process-response
  [{:keys [error value] :as result}]

  (when (some? error)
    (js/console.log "ERROR")
    (js/console.error error))

  (when (some? value)
    (js/console.log "VALUE")
    (js/console.log value))

  result)

(defonce compile-state-ref (env/default-compiler-env))

(defn evaluate [code]
  (cljs/eval-str
   compile-state-ref
   code
   nil
   {:eval cljs/js-eval
    :load (partial boot/load compile-state-ref)}
   process-response))

(defn init! []
  (boot/init compile-state-ref {:path "/js"} #(evaluate "(+ 1 1)")))
which was inspired by https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html - Configured this way results in the following error; failed to download boostrap file:/js/index.transit.json It seems this file is only generated when setting the target to bootstrap? Changing my config to more closely match the blog post generates index.transit.json but does not build modules.
:cljs-worker
  {:target :bootstrap
   :output-dir "resources/public/js"
   :asset-path "/js"
   :compiler-options {:optimizations :simple}
   :modules {:cljs-worker-base {:entries [shadow.cljs.bootstrap.env]}
             :cljs-worker {:entries [cljs.js]
                           :exclude #{cljs.js}
                           :macros []
                           :init-fn workers.cljs.core/init!
                           :depends-on #{:cljs-worker-base}
                           :web-worker true}}}
Is there a configuration that will allow me to build a worker supporting self-hosted cljs?
#2020-12-2617:18thheller@oconn failed to download boostrap file:/js/index.transit.json looks like you are trying to do this directly from the filesystem? that won't work, you need a http server. you can use :dev-http#2020-12-2617:18thheller:modules does nothing in :bootstrap#2020-12-2617:18thhelleryou need the browser build and the bootstrap build. separate.#2020-12-2619:21oconn@thheller - Looks like index.transit.json is loaded directly in shadow.cljs.bootstrap.browser/init. I’m running a dev server using;
:devtools {:http-root "resources/public"
           :http-port 9000
           :preloads [shadow.remote.runtime.cljs.browser]} 
I changed my bootstrap build to
:cljs-worker
  {:target :bootstrap
   :output-dir "resources/public/js/workers/cljs"
   :compiler-options {:optimizations :simple}
   :entries [cljs.js workers.cljs.core]
   :exclude #{cljs.js}
   :macros []}
and that is compiling everything under the output-dir but I’m not sure what js file I’m supposed to load into my web worker? Taking a looking at the bootstrap-support build in shadow-cljs ’s shadow-cljs.edn config, it outputs to out/demo-selfhost/public/bootstrap. The index file in that dir loads <script src="/worker/js/base.js"></script> - Is there supposed to be a base.js file in the output?
#2020-12-2619:59deplectI am running into something interesting, I have to access the :cause field of an cljs.core/ExceptionInfo and noticed it's being mangled by an release build. Now figuring out how to protect against the mangling.#2020-12-2620:20deplecthttps://github.com/clojure/core.async/blob/472340f947789513775d2dde5a478ea1ab03d333/src/main/clojure/cljs/core/async/interop.cljs#L13#2020-12-2620:21deplectThe cause I want to read out is build here in this async.interop. Advanced compilation mangles the class name, and the cause field, making it inaccessible for ex-cause.#2020-12-2620:26thheller@oconn no. your :modules control that in your case will be cljs-worker.js in the :output-dir#2021-12-2715:51oconn@thheller Thanks for pointing me in the right direction! I was loading my web worker using a relative path. Also didn’t know I needed two separate builds for self-hosted cljs. Thanks again!#2020-12-2620:26thhelleryou load that in the html and then bootstrap init#2020-12-2620:27thhelleragain failed to download boostrap file:/js/index.transit.json this error suggests that you just loaded the index.html directly from the filesystem in the browser instead of #2020-12-2620:30thheller@deplect in general if something gets mangled that you don't want mangled you need externs. see https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs just add cause one line to preserve it#2020-12-2620:31deplect@thheller amazing, was just writing my own extern, but this is magic. Thank you#2021-12-2703:16NerosHey people, hope Christmas went well.  I am trying to get React QR Scanner to work in shadow-cljs and am having problems getting it working. I converted the following react code:
[12:02 AM] import React, { Component } from 'react'
import QrReader from 'react-qr-scanner'

class Example extends Component {
  constructor(props){
    super(props)
    this.state = {
      delay: 500,
      result: 'No result',
    }

    this.handleScan = this.handleScan.bind(this)
  }
  handleScan(result){
    if(result){
      this.setState({ result })
    }
  }
  handleError(err){
    console.error(err)
  }
  render(){
    const previewStyle = {
      height: 240,
      width: 320,
    }

    return(
      <div>
        <QrReader
          delay={this.state.delay}
          style={previewStyle}
          onError={this.handleError}
          onScan={this.handleScan}
          />
        <p>{this.state.result}</p>
      </div>
    )
  }
}
[12:04 AM] I converted it from class to functional in react then converted it to cljs: (defn example   []   (let [state (r/atom {})         preview-style {:height "240" :width "320"}]     [:<>      (fn []        [:div         [:> QrReader {:name "qr-reader"                       :delay (:qr-reader @state)                       :style preview-style                       :on-error (fn [e]                                   (prn "You have an Error Bitch!"))                       :on-scan (fn [e]                                  (swap! state assoc :qr-reader                                         (-> e .-target .-value)))}]])])) I had made a few variations of the above and keep running into issues, any suggestions would be most welcome. Thankyou.
#2021-12-2703:39Christopher GenoveseI'm having a repl problem I've never had before immediately after the first hot reload, when running a shadow-cljs server and connecting to it via a repl. The repl loses track of all namespaces and eventually hangs. Specifically:#2021-12-2703:39Christopher Genovesecljs.user> (require '[app.ui :as ui] '[app.client :as client] '[com.fulcrologic.fulcro.application :as app]) nil cljs.user> (app/current-state client/app) {...stuff here looks good...} ;; ...examine a few more gits of data cljs.user> (app/current-state client/app) {...stuff here still looks good...} ;; Then after the first hot reload in shadow-cljs following a minor change in a file cljs.user> (app/current-state client/app) ------ WARNING - :undeclared-ns ------------------------------------------------ Resource: <eval>:1:2 No such namespace: app, could not locate app.cljs, app.cljc, or JavaScript source providing "app" -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:2 Use of undeclared Var app/current-state -------------------------------------------------------------------------------- ------ WARNING - :undeclared-ns ------------------------------------------------ Resource: <eval>:1:20 No such namespace: client, could not locate client.cljs, client.cljc, or JavaScript source providing "client" -------------------------------------------------------------------------------- ------ WARNING - :undeclared-var ----------------------------------------------- Resource: <eval>:1:20 Use of undeclared Var client/app -------------------------------------------------------------------------------- ;; After this simple arithmetic expressions work for a bit, but eventually -- and ;; immediately after requiring anything, the repl times out and then hangs. ;; For instance, re-doing the above require gives this error [2020-12-26 22:35:10.636 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(require\n '[com.kymetis.rav.app.ui :as ui]\n '[com.kymetis.rav.app.client :as client]\n '[com.fulcrologic.fulcro.application :as app])", :ns cljs.user, :repl true}, :include-init false, :call-id 9, :from 5}} AssertionError Assert failed: (symbol? repl-ns) shadow.build.resolve/resolve-repl (resolve.clj:639) shadow.build.resolve/resolve-repl (resolve.clj:639) shadow.cljs.repl/repl-require (repl.clj:211) shadow.cljs.repl/repl-require (repl.clj:187) shadow.cljs.repl/process-read-result (repl.clj:518) shadow.cljs.repl/process-read-result (repl.clj:498) shadow.cljs.repl/process-input (repl.clj:682) shadow.cljs.repl/process-input (repl.clj:660) shadow.cljs.devtools.server.worker.impl/eval17014/fn--17017 (impl.clj:755) clojure.lang.MultiFn.invoke (MultiFn.java:234) shadow.cljs.devtools.server.util/server-thread/fn--16643/fn--16644/fn--16652 (util.clj:285) shadow.cljs.devtools.server.util/server-thread/fn--16643/fn--16644 (util.clj:284) ;; A timeout message is given and then no more response#2021-12-2703:42Christopher Genovese
I ran shadow-cljs server and then connected with a cljs-repl.  Using the latest version of shadow-cljs and using the following config: {:deps     {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn app.client/init
                                       :entries [com.kymetis.rav.app.client]}}
                   :devtools   {:after-load app.client/refresh
                                :preloads   [com.fulcrologic.fulcro.inspect.preload
                                             com.fulcrologic.fulcro.inspect.dom-picker-preload]}}}
 :nrepl {:port 8777}

 :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}
#2021-12-2703:43Christopher GenoveseWhen first connecting the browser, it says the JS is stale; a reload fixes it. This is baffling me, and any help would be much appreciated. Thanks.#2021-12-2708:07thheller@genovese sounds like https://github.com/thheller/shadow-cljs/issues/788. unfortunately I haven't been able to reproduce this#2021-12-2714:49Christopher GenoveseThanks, @U05224H0W. You're right, that is an exact match. (Sorry I missed that.) I'll try to document things as clearly as possible on github and produce a minimal example. Any general pointers on where I should look in the shadow-cljs code to track this? This is killing repl-driven development for my project, so I'm motivated. Thanks again#2021-12-2715:38thhellerthe issue is that somehow it gets the repl into a corrupted state where something that should never be nil is nil#2021-12-2715:39thhellerhttps://github.com/thheller/shadow-cljs/blob/b6d1f4c0b6063dee40df182f2abee4a644cd332c/src/main/shadow/cljs/repl.clj#L211#2021-12-2715:39thhellerbut I somehow can't get into that state. granted I don't use the cljs REPL all that much because of hot-reload#2021-12-2715:40thhellersteps to reproduce would help a lot. I'll then happily track it down 🙂#2021-12-2716:57Christopher GenoveseThanks! I'll put my details on github shortly.#2021-12-2717:37Christopher GenoveseP.S. @U05224H0W As a shortcut, I tried to redefine shadow.cljs.repl/repl-require to log new-ns-info from within shadow's clj repl before starting the watch, but that didn't work. If you think it worthwhile and let me know the best way to build a branch for debugging, I can help get some info as well since it's happening here.#2021-12-2717:39thhellerneed to redef this too if you redef the fn#2021-12-2717:39thhellerhttps://github.com/thheller/shadow-cljs/blob/b6d1f4c0b6063dee40df182f2abee4a644cd332c/src/main/shadow/cljs/repl.clj#L401#2021-12-2717:39thhellerthen it should work fine#2021-12-2720:45Christopher GenoveseOutstanding, thanks#2021-12-2716:08victorbcan I somehow get shadow-cljs to output the server-token (in order to connect to api/remote-relay myself manually) to stdout when running shadow-cljs server ?#2021-12-2716:12victorbthe file .shadow-cljs/server.token has the token I need#2021-12-2716:40thhelleryeah the file is meant for exactly that 🙂#2021-12-2716:42thhellercurious what you intend to build? I still need to document all of this better 😛#2021-12-2716:45victorbeh, just mucking around, wanted to control the build process directly from browser app, via nested babashka (so browser -> ws -> babashka -> babashka -> shadowcljs), got better access with nrepl in the end, after discovering the files from .shadow-cljs/#2021-12-2717:51Mr. SavyI'm having trouble with my repl. If I start it up it starts in the shadow.user namespace. However, after typing in the (shadow/repl :main) command to switch to a cljs repl, my namespace becomes nil and loading/switiching to other namespaces doesn't seem to work; they also return nil. does anyone recognize what I might be doing wrong? I haven't had this problem before, and I don't recall making any changes that may have caused this.#2021-12-2720:05thheller@ajsnow2012 what returns nil? You a switching with shadow/repl that turns the CLJ REPL into CLJS so you should start out at cljs.ujser?#2021-12-2720:20Mr. Savy*ns* return nil when I make the switch. Although, it does seem to think i'm in cljs.user . so here's what i'm seeing directly :#2021-12-2800:05thheller*ns* is not a thing in CLJS. you can see the ns in the bottom right corner#2021-12-2800:05thhelleror a quick trick is ::foo or so#2021-12-2800:15Mr. SavyI saw the bottom right, but I thought *ns* worked in both versions. I must be losing my mind. Sorry for the trouble and thank you!#2021-12-2800:51thhellerit works in macros but not in the REPL#2021-12-2813:57Björn EbbinghausIs there a way to print a dependency graph with shadow-cljs? I see namespaces in the build report and I don’t now where they are coming from.#2021-12-2813:59thhelleryou mean where it is required? no thats currently displayed#2021-12-2814:03Björn EbbinghausThere are dependencies in the build report I didn’t expect there. cljs.pprint is in the report, but I don’t use it in my project. Also pathom which is only used in my .clj files. I am asking myself if maybe fulcro (or another dependency) is pulling them in.#2021-12-2814:10thhellerfulcro had a require for that some time ago#2021-12-2814:11thhellerdon't know if newer versions still do#2021-12-2814:13thhellerthe info is all available just need to put it into the report somehow 😛#2021-12-2820:39brunexhi, found this https://clojureverse.org/t/using-storybook-with-cljs/1495#2021-12-2820:40brunexbut cant find the example source code mentioned there#2021-12-2820:40brunexany help? thanks#2021-12-2823:06thhellerthat post is severly outdated and won't work with the current storybook at all#2021-12-2823:07thhellerstorybook completely changed everything basically#2021-12-2910:55victorbThe following is in the docs: > If you want to switch to a CLJS REPL this may require additional setup in the tool you used to start the server in. Since `lein` will default to using nREPL it will require configuring additional nREPL `:middleware`. When using `clj` you are good to go since it doesn’t use nREPL. I'm trying to manually connect to the shadowcljs nrepl and run (shadow/repl :build-id) to create a cljs repl, but I'm not getting it to work. I guess it's supposed to change the ns for me, but getting nothing. Works when running via lein repl :connect , changes the ns properly and drops my into a cljs repl, but no dice when manually connecting via sockets. Any ideas what I'm missing?#2021-12-2911:14thheller@victorbjelkholm429 you are connecting to what? the shadow-cljs nrepl server? the lein one?#2021-12-2911:14thhellerand what are you connecting with? if you are coding this manually you need to properly manage the nrepl session stuff#2021-12-2912:14victorb@thheller yeah, connecting directly to the nrepl started by shadow-cljs. Using the lein nrepl client just as a test client, main usage is supposed to be via a Java Socket manually in Clojure code. Yeah, already using session + id, bencode and the whole rabble. Any information around what the command shadow/repl expects my nrepl session to do? I'm assuming it'll return me a ns that I should switch to, while retaining the same session, or something like that but haven't quite figured it out yet#2021-12-2912:17thhellerI can't remember either. I think clients usually clone and then shadow/repl switches the current session to CLJS. don't know if thats supposed to return something.#2021-12-2912:18thhellerCLJS over nrepl is horrible#2021-12-2912:23victorbhah, it's a bit messy at times I guess, but unsure if there is any alternatives?#2021-12-2912:23victorbI'll continue digging, thanks!#2021-12-2912:24thhellerdon't know what you intend to do exactly#2021-12-2912:25victorbwant to run cljs code in the browser from a clojure process programmatically, and since shadow-cljs runs as a sub-process to the clojure process, I'm using nrepl to communicate. That's the summary I guess#2021-12-2912:26thhellershadow.remote stuff is the easiest (if you can do websocket and transit) in my opinion but I'm quite biased 😉#2021-12-2912:27victorbah, very cool, didn't know about shadow.remote! Seems to be an alternative, will take a closer look#2021-12-2912:27thhellersocket repl is easy too if you don't care much about the output#2021-12-2912:27thhelleryou already looked at the shadow.remote stuff. its the websocket endpoint you tried a couple days ago.#2021-12-2912:28thhellerhttps://github.com/thheller/shadow-cljs/blob/master/doc/remote.md its a bit out of date but the idea is the same#2021-12-2912:28victorbyeah, didn't look to much at it the other day as I found I could get a nREPL connection up and running 😄 But, back to it we go.#2021-12-2912:30thhellerbasically all you need to send is the {:op :hello} and then get the client id of the CLJS runtime you want to eval in#2021-12-2912:30thhellerif you know it
{:op :cljs-eval
 :to client-id
 :input {:code "(+ 1 2)"
         :ns 'cljs.user
         :repl true}}
#2021-12-2912:30thhellerthis gets you eval#2021-12-2912:31thheller:repl true is optional. if you don't care about *1 *2 and so on you can leave it out#2021-12-2912:32victorbawesome, thanks!#2021-12-2912:32thhellerif you want to emulate "RPC" you can send :call-id 123 with the request and the server will reply with that id in the message#2021-12-2915:43mauricio.szabo@victorbjelkholm429 if you want to take a look, I wrote a client to connect to shadow.remote - I use it on Chlorine / Clover plug-ins: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/repl_client/shadow_ws.cljs#2021-12-2915:47mauricio.szaboIt's a ClojureScript package, so you can even import on your CLJS code and run right away! It does a lot more than just connecting to Shadow, but you can ignore most parts if you want (I believe that CLJS's dead code removal will handle it). Please, ping me if you think it helps, because I'm also researching on a web-based evaluator 🙂#2021-12-2915:49victorb@mauricio.szabo thanks a lot! In the end I went the nREPL way, so I can interact with the shadowcljs nrepl the same way I interact with clojure and babashka nrepls, less code 🙂 Figured out the issues I was seeing was my fault, I was creating a new session in the wrong place, instead of reusing an existing one, got everything to work as expected now#2021-12-3013:29Alexis Vincent@thheller If I’m compiling :node-library is there any way to do dynamic module loading? I’m working on a hybrid client / server ssr tool for cljs akin to next js. I have library code that I want to require client modules and for this to work on both the client and the server. The main issue I can forsee is if I try to have multiple entry points on the server. Any comments? For more context: • The tool is called clam. • I have a node cli with a clam dev command that spawns a clj process, which then starts a shadow server and call watch* with 2 generated build configs. • I generate 2 builds, a client and a server. :target :browser and target :node-library , currently these both import client react trees, with the server one adding http handlers and ssr. • I want to augment this to support dynamic module loading on the client and control the loading experience. The issue I can see is that since its no longer a single require tree, I dont know how that will play with node-library#2021-12-3014:05thheller:node-library cannot do this and isn't meant to no.#2021-12-3014:06thhelleryou can try :target :esm maybe that fits your needs#2021-12-3014:06thhellerbut I don't quite see how server side stuff relates to client side stuff in any way?#2021-12-3014:07thhellerI mean the client never downloads server side code?#2021-12-3014:12Alexis VincentThanks Thomas. Does :esm support repl and hot reloading? It’s more loading and executing client code on the server, but if the client code has dynamic module loading then It seems this is no longer possible#2021-12-3014:13Alexis VincentI don’t mind doing some custom build stuff to get this working, since I completely control the build step#2021-12-3016:42thheller@mail024 it entirely depends on how you do the dynamic module loading stuff. its code in your control so you can just write one implementation for the browser and one for node.#2021-12-3016:42thhelleresm does support REPL and hot-reload yes but you really should use two separate builds and not try to make one build do two things#2021-12-3017:10Alexis VincentI definitely have 2 builds. I guess what I’m asking is if its possible to do dynamic module loading, inline require in node using cljs#2021-12-3017:34thhellerthat entirely depends on how YOU do dynamic module loading in the first place#2021-12-3017:34thhelleras far as shadow-cljs is concerned it is putting .js files on disk#2021-12-3017:35thhellerhow you load them is your concern. one option is to use shadow.loader which only works in :browser builds. you do not have to use that though. you can completely roll your own that works in both browser and node#2021-12-3017:47Alexis Vincentright! thanks for the clarification, I guess I assumed the .js files outputted assumed a browser environment. Or that the files outputted with other builds don’t work without entries, etc.#2021-12-3017:47Alexis VincentWhats the status on esm builds? Theres no mention in the docs#2021-12-3019:13thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-12-3019:13thhellerwaiting on some stuff in the closure compiler before further work on this#2021-12-3019:14thhellershouldn't change much on the configuration side though#2021-12-3108:50StefanHi there! I’ve picked up a side project and started using awesome ShadowCLJS again. I’m trying to figure out something but I’m having a hard time. I’m hoping someone here can give some advice. I’m building a :browser target for use in an iOS / Android web view. On iOS I have it working. On Android there’s the issue however that Android has 10.0.2.2 as IP address of the host running the development environment, not localhost. So what I’m observing is that the initial load of my compiles JS bundle is working (because I load it from 10.0.2.2, but then ShadowCLJS tries to connect to localhost. I’ve tried setting :devtools-url` to , but then the websockets upgrade doesn’t work (“error during websocket handshake: unexpected response code: 200”). I have the feeling that it should be possible somehow, but how…? Thanks for any help / pointers!#2021-12-3109:32StefanWhile ruminating this over breakfast, I realized that I already knew the solution, just didn’t think of it at the right time. Like the manual says, :devtools-url should point to the primary server. So it should have been . After changing that it worked. 🎉#2021-12-3113:43Alexis Vincent@thheller Thanks, useful to see. I’ll play around with :esm and see what I can get going.#2021-12-3113:43Alexis VincentWhat is supported by :browser but not by :esm ?#2021-12-3113:45Alexis VincentWhat are the 2 PR’s going to allow for? Will they enable mograting away from goog.provide ?#2021-12-3114:15thhellerthe output will look like :esm currently but a little cleaner I guess. goog.provide is never part of an optimized build so I'm not sure what you mean. CLJS will continue to use that for a while.#2021-12-3114:50ghaskins@thheller is there a way to access the lein project name/version programmatically from within the app?#2021-12-3114:50ghaskinsfor instance, in jvm clojure, I can do (System/getProperty "attribute-service.version")`#2021-12-3114:50ghaskinsis there a parallel in cljs you are aware of?#2021-12-3115:18thhellera macro I guess#2021-12-3115:29Alexis VincentIs there any reason I should use browser over esm for browser target?#2021-12-3117:08thhelleresm is experimental and unfinished. browser is stable and used by many.#2021-12-3117:08thhelleryou don't gain much by using esm imho#2021-01-0121:30Dan MaltbieI'm working with a package that has an alternate way to install for its "nightly" build. I've cloned the package repo to my local drive and built the package (actually it builds multiple packages but in my example I'm only using one.) The local repo serves up the package via a http interface using a simple Python server. I can then install the package using npm install with the dependency in my project package.json file of  `"@ndn/packet": "http://localhost:8000/packet.tgz"`. The package installs properly but fails when I run shadow-cljs to compile. I have tested using this package with webpack and node.js so I am confident that the Javascript stuff is working properly. Is there something I need to do with shadow-cljs to get this to work? The compile fails with the following error: (parallels) (27)# shadow-cljs compile app shadow-cljs - config: /media/psf/DataPartition/lastmile/ttncore/shadow-cljs.edn [:app] Compiling ... npm package "@ndn/packet" expected version "@ndn/ [:app] Build completed. (225 files, 6 compiled, 0 warnings, 11.57s) npm ls reports the following: (parallels) (28)# npm ls | more {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f581819b969a8790b5c5dbc5dbc4"}, :content ("[email protected]")} ├─┬ @babel/ │ └── ├─┬ @ndn/ │ ├─┬ @ndn/ And here's a snippet from my package.json file: "dependencies": { "@babel/runtime": "^7.12.5", "@ndn/packet": "",#2021-01-0123:47thheller@dmaltbie [:app] Build completed. (225 files, 6 compiled, 0 warnings, 11.57s) the build succeeded? the "expected version" thing is just a warning?#2021-01-0200:39Dan MaltbieIt appears so. And the code seems to work. Should I ignore these warnings? I don't get them when I compile with webpack or node.#2021-01-0201:05thhelleryou seem to have a deps.cljs which you don't really need?#2021-01-0201:12Dan MaltbieI'm not seeing that. Where would that be specified (which file)?#2021-01-0201:22Dan MaltbieI can't find a file in the project named deps.cljs. my shadow-cljs.edn file contains two cljsjs packages. could that cause a problem? :dependencies [ [cljsjs/hash "1.1.3-0"] [cljsjs/msgpack-lite "0.1.26-0"] [reagent "1.0.0-alpha2"] [reagent-utils "0.3.3"] ]#2021-01-0201:23thhelleryou don't need to include those cljsjs deps since shadow-cljs will not use them anyways#2021-01-0201:23thhellerdon't know what they would provide#2021-01-0201:25thhelleryou can set :npm-deps {:install false}. then it won't warn or attempt to install npm dependencies from deps.cljs. something in your dependencies or you project has a deps.cljs file which declares a :npm-deps dependency on "@ndn/packet" with version "@ndn/#2021-01-0201:39Dan MaltbieThe package.json file for @ndn/packet (in the node_modules directory) has a dependency for the tlv.tgz file. But there isn't a deps.cljs file. And I thought I needed to have the package version specified in the shadow-cljs.edn file for packages I use. Are you saying that I should just install with npm instead of cljsjs?#2021-01-0201:44Dan MaltbieWhere does the :npm-deps statement go?#2021-01-0201:54Dan MaltbieOk. I see in the User Guide section 5.2.2 that it says to use npm to manage the JS packages and not cljsjs. got it. But I still can't find where to put the :npm-deps statement. Do I put it in my main.cljs file or create a deps.cljs file?#2021-01-0210:37thhellerinto shadow-cljs.edn at the top level#2021-01-0210:39thhelleryou must have a deps.cljs files somewhere. its the only file that causes those warnings. it might be in one of the cljsjs dependencies though so if the warning goes away after removing them its probably one of those#2021-01-0319:48Dan MaltbieI expect this is my bonehead problem, but I can't get the :npm-deps option to work. I've tried several ways with no success. I even tried it in a deps.cljs file in the src directory. Can you please look at my shadow-cljs.edn file and tell me what I'm doing wrong? You'll see I've tried it in various places in the .edn file just to see if I misplaced it. No luck. Also, I've searched for the deps.cljs file but I'm not finding one. (used find starting from root and grep to search the source tree). Thanks.#2021-01-0320:36thhellerat the top level the one is just fine. are you maybe on an old version that doesn't have this flag?#2021-01-0323:01Dan MaltbieHere's what I've got:
(parallels) (157)# shadow-cljs info
shadow-cljs - config: /media/psf/DataPartition/lastmile/ttncore/shadow-cljs.edn
=== Version
jar:            2.11.11
cli:            2.11.11
deps:           1.3.2
config-version: 2.11.11

=== Java
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
#2021-01-0323:17Dan MaltbieAlso in my package.json I have (is this necessary?):
"devDependencies": {
        "onchange": "^7.1.0",
        "shadow-cljs": "^2.11.11",
        "tailwindcss": "^1.9.6"
    },
#2021-01-0400:12thhellerlooks fine to me. I don't know what is up with your setup but again you can ignore the warning. it has no impact on the build whatsoever.#2021-01-0402:39Dan MaltbieOk. Thanks for your help.#2021-01-0423:07Dan MaltbieJust curious, is there is a way to examine the option settings for a given runtime of the compiler?#2021-01-0510:35thhellernot sure I understand the question? which "runtime" are you talking about abnd which settings?#2021-01-0813:51thhellerhey, I just released version 2.11.12 which should get rid of the warning you asked about. it doesn't compare versions using http: etc anymore#2021-01-0813:51thhellerin addition there is a :js-options {:check-versions false} to turn the check off completely (true by default)#2021-01-1818:27Dan MaltbieThat worked for me!! Thanks. I really appreciate being able to weed out the extraneous warnings so that I can see any others with less clutter. Big Thumbs Up!#2021-01-0200:18Pavel KlavíkHi, I am trying to hunt down a strange bug. I have a multifunction defined in multiple files. When I start watch process, the function is not called correctly. When I modify the source file, for instance by adding a log there, Shadow logo shows in the bottom left corner and everything works fine, even after removing the added line. When I restart shadow-cljs, the problem repeats, and it also happens within release build. If I keep the log there and restart watch, the line is not printed to console.#2021-01-0200:23Pavel KlavíkAlso reloading the app in the browser causes the same problem, again only fixed after reloading the file. If I write console.log as the top level form, it is called in the beginning. But not inside the multifn. I am running 2.11.11.#2021-01-0200:45Pavel KlavíkOk, sorry, I have found it, I had the same method overridden by another file 🙂.#2021-01-0216:30Vincent Cantinhi, are there any example of build hooks? what people do with this feature? https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2021-01-0301:37frankitoxI use it to show a little OS notification if I get a warning (usually I keep shadow's term hidden).#2021-01-0309:55Vincent CantinUsing Shadow-cljs, is there a way to run a hook inside the context of the reloaded cljc source files? From my test on the hooks, it seems that the source code is only loaded once.#2021-01-0309:57Vincent CantinThis is my use case: https://clojurians.slack.com/archives/C07UQ678E/p1609647836133300#2021-01-0310:19thhellerscanning for generic things like that is difficult but build hooks receive the entire build state and can inspect it however they need#2021-01-0310:20Vincent CantinI took a look at the build-state and made the mistake of printing its content 😛#2021-01-0310:20thhellerthe best option I have found so far however is using a dedicated css macro or so that collects these things during compilation. much easier to extract but slightly more verbose in the code
(def button-style (css :border :p-2 :shadow :lg/p-4))
or so
#2021-01-0310:21thheller(tap> build-state) and look at it in the inspect UI#2021-01-0310:21Vincent Cantinoh, good idea (for the tap>)#2021-01-0310:21thheller:sources has all the sources#2021-01-0310:22thheller:output has all the outputs of those sources (in :flush) stage, otherwise might still be empty
#2021-01-0310:22Vincent CantinI made a macro which adds the css in the metadata attached to the clojure var already. I am looking at how to read it from the hook.#2021-01-0310:28thhelleryou can take a look at this macro I wrote https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2021-01-0310:28thhellerit stores state in the analyzer data for the namespace#2021-01-0310:29thhelleryou could read that out later in the build hook via [:compiler-env :cljs.analyzer/namespaces your.ns :your.thing/key] or so#2021-01-0310:33Vincent CantinThx, I am taking a look now.#2021-01-0312:09Vincent Cantin@U05224H0W this worked !
(tap> (get-in build-state
                [:compiler-env
                 :cljs.analyzer/namespaces
                 '
                 :defs
                 'my-fn
                 :css]))
Big thank you !
#2021-01-0312:47thhellerwhen you add custom keys to the analyzer data make sure they are namespaced#2021-01-0312:47thhellerotherwise you might at some point clash with implementation details#2021-01-0412:06Alexis Vincent@thheller shadow-cljs isn’t hot reloading files that aren’t found in src path. I have a deps.edn file with :paths ["src", "resources", ".x/resources"] and :deps true in shadow. File watching, recompile and hot-reload work if I have the file in src but not if the file is instead in resources or .x/resources . How do I fix that? I’m starting the server and watch process in clojure using shadow.cljs.devtools.server/start! and shadow.cljs.devtools.api/watch* .#2021-01-0412:45thhellerresources are filtered out since they not supposed to contain source files. this is currently not configurable since a lot of people put the output files into the resources folder and that causes issues for shadow-cljs if it thinks those are sources again#2021-01-0412:51Alexis VincentThanks. I found the same issue with ".clam/src" What alternative paths are allowed#2021-01-0412:53thhellerhttps://github.com/thheller/shadow-cljs/blob/c28859a8034bdeec3bd5c40846872c22fbcdd0f4/src/main/shadow/build/classpath.clj#L1055-L1083#2021-01-0412:53thheller.clam/src should be fine unless the dir is hidden#2021-01-0412:53Alexis VincentThanks. Ill try again. Might have been conflating issues#2021-01-0413:00Alexis VincentExcellent! Working! Is there a way to force hot-reloading further up the tree for specific namespaces? i.e. not just requiring namespaces#2021-01-0413:14thhellerhmm?#2021-01-0413:14thheller:dev/always in the ns forces a recompile every time but what do you mean by "further up the tree"?#2021-01-0413:46Alexis Vincentso I have a case where x -requires-> y -requires-> z . When z changes I need to compute data with clojure and inject it into x . Currently the way I’m doing it is, y defs a var that evals a macro (which computes the data). Then x has a :dev/after-load hook which renders component defined in z, computed in macro in y . However, the require of yin x is stale when :dev/after-load is called (I assume because of hot reloading doesnt traverse up the tree like figwheel), so I need to do some stuff where I defer using var via wrapped function. I realise this is probably super confusing. But I was asking whether when z changes, which triggers y to be reevaluated, I could make x do the same, because I ’m assuming this would fix my issue? It’s not super important since I got things working by creating a function that returns the function I want (in x), its just a bit unclear why this is needed.#2021-01-0413:54Alexis VincentAdding :dev/always fixes it!#2021-01-0420:10mssI’m running shadow/watch to compile + hot reload a bundle w/ a browser target and want a hook to run a shell script after the initial build. what’s the idiomatic way to do that in shadow?#2021-01-0420:18thheller:build-hooks https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2021-01-0420:30msshad seen this, but it looks like a build hook on a watch will be invoked on each rebuild if I’m reading that correctly. there’s no hook for just the first completed build at the moment, correct?#2021-01-0420:31mssby the way, thanks for everything you do with shadow. absolutely lovely piece of technology#2021-01-0420:31thhelleryou can (assoc build-state ::work-done true) and then check (::work-done build-state) if you did what you intended to do#2021-01-0420:32thhellerwell opposite order but build-state will stay arround in watch so you can store stuff in it between each cycle#2021-01-0420:32thhellermake sure to use namespaced keys though to now clash with anything internal#2021-01-0420:34mssperfect. thanks for the pointers#2021-01-0500:1813talesHey there. I’m a relative newbie just getting to grips with Clojurescript and shadow-cljs, and have a quick workflow/REPL question: I’m running/hot-reloading my application with shadow-cljs watch, and connecting to the REPL with Cider. When I add a new dependency to shadow-cljs.edn, do I need to stop and restart the watch command in order to be able to use it, or is there something I can do via the REPL to install it and make it available right away?#2021-01-0500:3313talesOkay, found the answer to my own question: it looks like adding/changing dependencies does always require restarting the server, if I’m understanding the docs correctly. > Once the server is running however you only have to restart it whenever your :dependencies change and everything else can be done via the REPL. https://shadow-cljs.github.io/docs/UsersGuide.html#_server_mode#2021-01-0500:4313talesWould still appreciate some clarity on this, actually: If I’m developing with shadow-cljs watch, what should I do when I add a dependency? Trying to restart the server by running shadow-cljs restart in another terminal seemed to break the connection with the browser and REPL.#2021-01-0510:40thhellerjust ctrl+c the watch and start it again#2021-01-0513:25Alexis VincentYes for clojure dep, no for npm dep#2021-01-0522:5913tales@thheller Thanks. Still new to the ecosystem, and wanted to make sure there wasn’t some galaxy-brain clojure-wizard I-never-leave-my-REPL way of updating the dependencies that I was missing 😅#2021-01-0501:56dpsuttonJust kill the process and restart the watch#2021-01-0504:40Gustavo AguiarHi all, I'm learning Clojure(Script) and for that I'm doing a little project. In this little project I setup a JNI with Rust, which made me use lein so that I can correctly compile the Java file I had in my project. I'm also the kind of person who likes to write to learn, and I'm writing about the project setup. But to truly write something good I have to understand why I had to use lein (I honestly don't know, a friend simply said it would work if I did, and it worked). Is there any resource where I can understand if shadow-cljs can compile .java files, and if not, why it can't?#2021-01-0505:22saitouenaAs far as I know, shadow-cljs cannot compile .java files because compiling .java files is not the purpose of shadow-cljs. I think reading the official documentation would help you. lein: https://github.com/technomancy/leiningen > Leiningen is for automating Clojure projects without setting your hair on fire. lein is a kind of build tool for clojure(script). shadow-cljs: https://shadow-cljs.github.io/docs/UsersGuide.html#_introduction the purpose of shadow-cljs is compiling cljs code into javascrpt codes with ease.#2021-01-0510:37thhellershadow-cljs is for compiling clojurescript and at most some .js files. it does not deal with any .java or JVM related things#2021-01-0510:37thhellerI personally use lein for JVM related clj/java things#2021-01-0512:09Gustavo AguiarThanks for the explanation 😊 #2021-01-0512:22zendevil.ethI’m running a shadow watch#2021-01-0512:22zendevil.ethbut am getting the following error:#2021-01-0512:22zendevil.ethThe required namespace “appname.core” is not available.#2021-01-0512:23zendevil.etheven though the app name exists in the src/appname/core.cljs folder#2021-01-0512:23zendevil.ethwith the ns as appname.core#2021-01-0512:24zendevil.ethhere’s my shadow-cljs.edn file#2021-01-0512:24zendevil.eth{:paths [“src”] :dependencies [[reagent “0.10.0"] [re-frame “0.12.0”] [re-frame-steroid “0.1.1"] [rn-shadow-steroid “0.2.1”] [re-frisk-remote “1.3.3"]] :builds {:dev {:target :react-native :init-fn appname.core/init :output-dir “app” :compiler-options {:closure-defines {“re_frame.trace.trace_enabled_QMARK_” true}} :devtools {:after-load steroid.rn.core/reload :build-notify steroid.rn.core/build-notify :preloads [re-frisk-remote.preload]}}}}#2021-01-0512:33thheller@ps does appname maybe contain a -? Then the folder would need to be app_name#2021-01-0512:34zendevil.ethit doesn’t contain a hyphen#2021-01-0512:36zendevil.eththe folder and the namespace have the same name and contain only the alphabet characters#2021-01-0512:37thhellerah now I see it. it is :source-paths not :paths#2021-01-0512:40zendevil.eththanks @thheller#2021-01-0512:48zendevil.ethfor some reason following these steps to compile to react native target isn’t working: https://morioh.com/p/ac368dc1fceb#2021-01-0512:50zendevil.ethwhen I empty the index.js to just
import './app/index.js';
I get the error that it’s not registered
#2021-01-0512:54zendevil.ethactually I’m getting the error:#2021-01-0512:54zendevil.ethelement type is invalid: expected a string#2021-01-0512:54zendevil.ethbut got object#2021-01-0512:54zendevil.ethyou likely forgot to export the component from the file it is defined in#2021-01-0513:00zendevil.ethis registerComponent required in ./index.js or does it come with the register-reload-comp?#2021-01-0513:00thhellersorry don't know what register-reload-comp is#2021-01-0513:01thhellerthe index.js is just supposed to load the CLJS output, it shouldn't do anything else. at least in the examples I set up.#2021-01-0513:02zendevil.eththat’s exactly what I do#2021-01-0513:02zendevil.ethimport ‘./app/index.js’;#2021-01-0513:02zendevil.ethbut that doesn’t register the app#2021-01-0513:02thhellerelement type is invalid: expected a string usually means that some component you are using was nil#2021-01-0513:03thhellerits your job to register the app#2021-01-0513:04thhelleryes but the error you are getting doesn't necessarily have anything to do with the root component#2021-01-0513:04thheller[:> something {:foo "bar"}] when something is nil you'll get this error#2021-01-0513:06zendevil.ethI’m not getting the expected string error when ./index.js just contains the import#2021-01-0513:10thhellerdo you use expo?#2021-01-0513:11zendevil.ethno i don’t#2021-01-0513:13Michaël SalihiWhat's your init defn (code snippet)?#2021-01-0513:15zendevil.eth(defn init [] (rn/register-reload-comp {:name “Something”} root-comp))#2021-01-0513:15zendevil.ethalso tried (defn init [] (AppRegistry {:name “Something”} root-comp))#2021-01-0513:15zendevil.ethby doing [“react-native” :refer [AppRegistry SafeAreaView]]#2021-01-0513:27zendevil.ethI meant, also tried this (defn init [] (. AppRegistry registerComponent {:name “Something”} root-comp))#2021-01-0513:28zendevil.ethcompiles successfully but Appname isn’t registered#2021-01-0513:28thhellerthis is CLJS {:name “Something”} maybe you want #js {:name “Something”}#2021-01-0513:29zendevil.ethstill registration problem 😞#2021-01-0513:32Michaël SalihiTry like this:
(defn init []
  (rn/register-reload-comp "Something" root-comp))
#2021-01-0513:33zendevil.ethsame problem#2021-01-0513:34zendevil.ethnot registered#2021-01-0513:38zendevil.ethwhy does it say that registerComponent wasn’t called when it was called?#2021-01-0513:39thhellerhard to say without all the code#2021-01-0513:41zendevil.eth
(ns appname.core
  (:require [steroid.rn.core :as rn]
            ["react-native" :refer (View AppRegistry SafeAreaView)]))

(defn root-comp []
  [:> View "view"]
  #_[rn/view
    [rn/text "Hello CLojure! from CLJS"]])

(defn init []
  (. AppRegistry registerComponent #js {:name "Something"} root-comp))
#2021-01-0513:41zendevil.ethand ./index.js is
import './app/index.js';
#2021-01-0513:43zendevil.ethshadow-cljs.edn is
{:source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "0.12.0"]
                [re-frame-steroid "0.1.1"]
                [rn-shadow-steroid "0.2.1"]
                [re-frisk-remote "1.3.3"]]

 :builds       {:dev
                {:target     :react-native
                 :init-fn    appname.core/init
                 :output-dir "app"
                 :compiler-options {:closure-defines
                                    {"re_frame.trace.trace_enabled_qmark_" true}}
                 :devtools   {:after-load steroid.rn.core/reload
                              :build-notify steroid.rn.core/build-notify
                              :preloads [re-frisk-remote.preload]}}}}
#2021-01-0513:47thhellerdont call register component like that#2021-01-0513:48zendevil.ethhow to call it instead?#2021-01-0513:52thhellerlike the example does#2021-01-0513:56zendevil.ethyou mean this repo? https://github.com/thheller/reagent-react-native#2021-01-0513:56zendevil.ethI couldn’t search for registerComponent call in this repo#2021-01-0513:57thhellerthis call is doing that https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L36#2021-01-0514:07zendevil.ethI now have my code as the example but I’m still getting the not registered error:#2021-01-0514:07zendevil.eth(ns appname.core (:require [steroid.rn.core :as rn] [shadow.react-native :refer (render-root)] [reagent.core :as r] [“react-native” :refer (Text SafeAreaView View AppRegistry SafeAreaView)])) (defn root-comp [] [:> SafeAreaView [:> View [:> Text “Some Text”]]]) (defn init [] (render-root “Root” (r/as-element [root-comp])))#2021-01-0514:08thhelleris Root the name of your app? it needs to match whatever you have in app.json or so#2021-01-0514:08zendevil.ethOkay now it works!#2021-01-0514:08thhellerI don't really do react-native myself so I'm just guessing with all of this 😛#2021-01-0514:09zendevil.ethDo you work with reagent web?#2021-01-0514:12thhellerno. not using react at all anymore.#2021-01-0514:15zendevil.ethwhat do you use instead>#2021-01-0514:16thhellerhttps://github.com/thheller/shadow-experiments#2021-01-0514:17thhellernot something anybody else should use yet but I like experimenting with new stuff 🙂#2021-01-0514:08zendevil.ethThanks so much!#2021-01-0514:18flowthingDon't know if this more of a ClojureScript or a shadow-cljs issue, but I guess I'll try my luck here first: I'm working on integrating Playwright (https://playwright.dev) into one of my projects. I have a macro like this:
(defmacro test-page
  [browser-types page-sym & body]
  `(cljs.test/async done#
     (cljs.core.async/go
       (doseq [browser-type# ~browser-types]
         (let [browser# (cljs.core.async.interop/<p! (.launch browser-type#))
               page# (cljs.core.async.interop/<p! (.newPage browser#))
               ~page-sym page#]
           
And I call it like this:
(deftest smoke
  (test-page [chromium] page
    (<p! (.goto page ""))
    (is (= "Nope" (<p! (.innerText page ".navbar__title"))))))
It works well, but I get a lot of inference warnings like this:
10 |   (test-page [chromium] page
---------^----------------------------------------------------------------------
 Cannot infer target type in expression (. inst_47307 (newPage))
I'm not sure how to fix those warnings. Any ideas?
#2021-01-0514:21Jakub Holý (HolyJak)Hello folks! What is the best practice for using JS libraries for the browser distributed via CDN? Simply add <script ...> to the html and use it via js/exportedThing ? Thank you!#2021-01-0514:21thhellercore.async loses ^js typehint information unfortunately so its kinda hard to typehint that stuff properly#2021-01-0514:22thheller@flowthing you can turn off the warnings via :compiler-options {:infer-externs true} (not :auto). that way you only get warnings if you (set! *warn-on-infer* true) in the ns#2021-01-0514:23thheller@holyjak yes thats fine. this also works https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global#2021-01-0514:23flowthing@thheller Thanks! Will give that a try. Works great! 🙇:skin-tone-2:#2021-01-0515:16mkvlrhas anyone tried to let closure handle modules generated by typescript?#2021-01-0515:28Alexis VincentYeah. Worked fine from my memory#2021-01-0515:30mkvlr@mail024 did you use https://github.com/angular/tsickle?#2021-01-0515:31Alexis VincentNo, no experience with that. but thats probably the way to go to get optimisations. I just compiled to js and used shadow’s js integration#2021-01-0515:32Alexis Vincentcertainly wasnt an optimised experience. Was just for convinience pasting ts/js code into a file and using from cljs#2021-01-0515:32mkvlrah oh, so using it like a normal node module#2021-01-0515:34Alexis Vincentexactly. I used the option on the ts compiler to keep directory structure. Then added the output to the classpath.#2021-01-0515:35Alexis VincentSo i had the ts files sitting alongside the cljs files.#2021-01-0515:36Alexis Vincentand a ./x.js in cljs land worked because the directory structure was persisted#2021-01-0516:21thhellerif the code is ESM you will get full advanced optimizations when included via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-01-0516:22thhelleronly trouble is externs inference doesn't work for the JS code so if that code uses a lot of npm code you might need manual externs#2021-01-0516:24Alexis Vincent@thheller You might find the conversation I just had with @dnolen on #clojurescript interesting.#2021-01-0516:26thhellerI've been thinking about writing a cljs compiler that outputs only modern ESM code directly for a while now#2021-01-0516:26thhellerbut a whole lot of effort for little gain currently#2021-01-0520:10lilactownI went down the route of tsickle for a lib awhile back but IIRC the goog.module output it produces wasn't amenable for use with CLJS#2021-01-0520:10lilactownI had to hand-modify the files after compilation to use the old module system#2021-01-0600:42thheller@lilactown shadow-cljs should be fine with goog.module#2021-01-0600:44lilactownI think it was the "vanilla" CLJS compiler that I ran into issues#2021-01-0600:44lilactownand I didn't want my lib to be shadow-cljs only 😄#2021-01-0600:45lilactownwhich, I never finished it anyway. If I pick it back up I'll probably rewrite the TS code in CLJS. I thought it was a neat experiment to see if I could get easy interop between TS and CLJS#2021-01-0603:05steveb8nthis is interesting. I wonder if it has any good use-cases in the shadow world? https://evanw.github.io/source-map-visualization/#2021-01-0603:06steveb8nI struggle a bit with source maps when using closure and ncc together. probably unrelated to the value of this tool but mentioning it in case others have similar challenges#2021-01-0609:30thhellerwould be useful but I still get "invalid source map" for some maps although they work fine in the browser#2021-01-0609:30thhellerpreviously used https://sokra.github.io/source-map-visualization/#2021-01-0609:30thhellersame issue and had issues with bigger source maps#2021-01-0609:41steveb8nshame but good to know 🙂#2021-01-0616:36Pavel KlavíkHi, what is the easiest way to look for all occurances of all keywords with certain ns in my CLJS code, and to use this list for constructing CSS using Garden? I would like to get hot code reloading for it, so when I modify CLJS code, Garden should recompile as well.#2021-01-0617:35isakI would try using this tool to search your clojure code with spec: https://github.com/borkdude/grasp#2021-01-0617:49isakOh, and for the file-watching part, you'd just create a script using a file-watching library (like juxt/dirwatch), and then set up your file watching, then call shadow.cljs.devtools.api/watch programatically. Then, instead of running the watch task:
yarn shadow-cljs run dev/watch
Where src/dev.clj has a watch function that does this
#2021-01-0617:51isakOh and your watch function needs this metadata:
(defn watch
  {:shadow/requires-server true}
  ...
#2021-01-0620:51Pavel KlavíkThanks for the link to grasp, haven't seen this before.#2021-01-0620:52Pavel KlavíkThis sounds like a possible solution to set everything up on my own, but I am not convinced it is the easiest one. I could imagine using Shadow-cljs hooks which would call this code search on all modified files and dump stuff somewhere where it can be picked by Garden file watcher.#2021-01-0622:10isakThis is why I don't do it that way: https://clojurians-log.clojureverse.org/shadow-cljs/2019-10-08/1570556850.403100#2021-01-0622:40Pavel Klavíkthanks for sharing this, it gives quite a lot of insight#2021-01-0700:23isakSometimes I get compilation issues while switching branches, I'm guessing because git may create a reference to a file before it creates the file that is being referred to. Not a huge deal since a page-reload makes it go away, but when watching, how about checking if git is doing an operation before doing the compile? I think this can be done by checking the existence of .git/index.lock. Not sure if it is worth it, just putting it out there. Actually for the implementation, since shadow-cljs is already watching for file system changes to .cljs files, how about .git/index.lock as well?#2021-01-0702:09zendevil.ethI’m getting ajax.edn is not available#2021-01-0702:09zendevil.etheven though I have cljs-ajax/cljs-ajax in deps.edn#2021-01-0702:10zendevil.ethHow to fix this error?#2021-01-0702:16zendevil.ethall my imports in deps.edn aren’t working#2021-01-0702:21saitouenaare you using :deps true option? https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2021-01-0702:21saitouenacan you share your shadow-cljs.edn and deps.edn ?#2021-01-0702:23zendevil.ethwhen I use the deps true option I get this error#2021-01-0702:23zendevil.ethhttp://java.io#2021-01-0702:24zendevil.ethwhen loading the repl#2021-01-0702:25dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2021-01-0702:26dpsuttonin particular > You must add the thheller/shadow-cljs artifact to your deps.edn manually. #2021-01-0702:29zendevil.ethI added the artifact, but now I get a different error:#2021-01-0702:29zendevil.ethCaused by: java.lang.RuntimeException: Unable to resolve var: comp/source-map-data-gen-col in this context#2021-01-0702:32zendevil.ethHere’s my shadow-cljs.edn#2021-01-0702:33zendevil.eth{:deps true :source-paths [“src”] :dependencies [[reagent “0.10.0"] [re-frame “0.12.0”] [re-frame-steroid “0.1.1"] [rn-shadow-steroid “0.2.1”] [re-frisk-remote “1.3.3"]] :builds {:dev {:target :react-native :init-fn humboi.core/init :output-dir “app” :compiler-options {:closure-defines {“re_frame.trace.trace_enabled_QMARK_” true}} :devtools {:after-load steroid.rn.core/reload :build-notify steroid.rn.core/build-notify :preloads [re-frisk-remote.preload]}}}}#2021-01-0702:33zendevil.ethHere’s my deps.edn#2021-01-0702:33zendevil.eth{:deps {org.clojure/clojure {:mvn/version “1.10.0”} org.clojure/clojurescript {:mvn/version “1.10.339"} reagent {:mvn/version “0.10.0”} re-frame {:mvn/version “0.12.0"} re-frame-steroid {:mvn/version “0.1.1”} rn-shadow-steroid {:mvn/version “0.2.1"} cljs-ajax/cljs-ajax {:mvn/version “0.8.1”} day8.re-frame/http-fx {:mvn/version “0.2.2"} thheller/shadow-cljs {:mvn/version “2.11.11”}} :paths [“src”]}#2021-01-0702:35dpsuttontry with cljs version "1.10.597" which is the one shadow uses#2021-01-0702:44zendevil.eththat gives the following:#2021-01-0702:44zendevil.eth============================================================================= WARNING: The configured :dependencies in shadow-cljs.edn were ignored! When using :deps they must be configured in deps.edn ============================================================================== ============================================================================== WARNING: The configured :source-paths in shadow-cljs.edn were ignored! When using :deps they must be configured in deps.edn ============================================================================== NPM dependency “react” has installed version “16.13.1" “16.13.0” was required by jar:file:/private/var/root/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs [2021-01-07 08:13:51.446 - WARNING] :shadow.cljs.devtools.server/nrepl-ex Note: The following stack trace applies to the reader or compiler, your code was not executed. CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source “cider/piggieback.clj”, :symbol if-ns} clojure.lang.Compiler.macroexpand1 (Compiler.java:7018) clojure.lang.Compiler.macroexpand (Compiler.java:7074) clojure.lang.Compiler.eval (Compiler.java:7160) clojure.lang.Compiler.load (Compiler.java:7635) clojure.lang.RT.loadResourceScript (RT.java:381) clojure.lang.RT.loadResourceScript (RT.java:372) clojure.lang.RT.load (RT.java:463) clojure.lang.RT.load (RT.java:428) clojure.core/load/fn--6824 (core.clj:6126) clojure.core/load (core.clj:6125) clojure.core/load (core.clj:6109) clojure.core/load-one (core.clj:5908) Caused by: NoSuchFieldError ES3 cljs.closure__init.load (:133) cljs.closure__init.<clinit> (:-1) java.lang.Class.forName0 (Class.java:-2) java.lang.Class.forName (Class.java:348) clojure.lang.RT.classForName (RT.java:2207) clojure.lang.RT.classForName (RT.java:2216) clojure.lang.RT.loadClassForName (RT.java:2235) clojure.lang.RT.load (RT.java:453) clojure.lang.RT.load (RT.java:428) clojure.core/load/fn--6824 (core.clj:6126) clojure.core/load (core.clj:6125) clojure.core/load (core.clj:6109) shadow-cljs - server version: 2.11.11 running at http://localhost:9630#2021-01-0703:11saitouenahttps://github.com/thheller/shadow-cljs/issues/460#2021-01-0703:13saitouenahttps://github.com/thheller/shadow-cljs/issues/460#issuecomment-472047147#2021-01-0703:15saitouenahttps://clojars.org/thheller/shadow-cljs @ps Specifying org.clojure/clojurescript 1.10.773 might help#2021-01-0703:16dpsuttonoh sorry. i recommended that cljs version as i found it in shadow's deps.edn#2021-01-0703:17saitouenashadow-cljs version specifies clojurescript version so I think you need to keep it the same#2021-01-0703:18zendevil.ethit works now#2021-01-0703:18saitouenaOh I overlooked dpsutton's recommendation 🙇#2021-01-0703:19zendevil.eth1.10.773 made it work#2021-01-0703:20saitouenaIn addition, you can omit :dependencies entry as the warning said.#2021-01-0711:15zendevil.ethI’m getting an error when importing and using AsyncStorage#2021-01-0711:15zendevil.eth“error is ” #object[TypeError TypeError: undefined is not an object (evaluating ‘shadow.js.shim.module$$react_native_async_storage$async_storage.AsyncStorage.setItem’)]#2021-01-0711:16zendevil.ethusing
(reg-event-fx
 :_id-persist
 (fn [coeffects [_ id]]
   
   (go
     (try
       (<p! (. AsyncStorage setItem "_id" id))
       (catch js/Error e (prn "error is " e))))
   {}
   ))
#2021-01-0711:16zendevil.ethimporting#2021-01-0711:16zendevil.eth
["@react-native-async-storage/async-storage" :refer (AsyncStorage)]
#2021-01-0711:17zendevil.ethwhy is AsyncStorage undefined?#2021-01-0711:26thheller@ps it might be :as AsyncStorage not :refer, or even :default AsyncStorage. see the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-01-0712:01zendevil.ethimport { AsyncStorage } from “react-native”;#2021-01-0712:02zendevil.ethfrom https://pusher.com/tutorials/persisting-data-react-native#2021-01-0712:02zendevil.ethwhich translates to what i have#2021-01-0712:04zendevil.ethactually import AsyncStorage from ‘@react-native-async-storage/async-storage’;#2021-01-0712:19zendevil.eththanks#2021-01-0717:28Alexis Vincent@thheller I’m running a watch process, running a build hook which finds functions with specific metadata and outputs a file because of it. When I add a new cljs file, I want that to be included in the watch/analyse/compile process. Is there a way to tell shadow to start watching this new file as well? If not, is there a way extend shadow user side to do this?#2021-01-0717:32Alexis VincentAlso, is there a way to tell shadow to safely bail, in a build hook? Or should I just throw an exception?#2021-01-0717:49Alexis Vincentto my first question: I want to watch all files against a specific path, and have them considered by the analyzer#2021-01-0719:34thheller@mail024 none of the default :target implementations support this. what exactly do those files do? usually only files that are actually required by something will be included.#2021-01-0719:38Alexis VincentIt’s really only in development that I want this. I’m doing something similar to what you do here https://github.com/thheller/next-cljs/blob/master/src/main/shadow/next_js.clj#L12. I got around this by watching the files myself and generating a “dev.cljs” file that contains requires for the files. This is good enough. But knowing how to include all files rather then just those reachable via entries would be useful for simplification of the implementation. Not vital given the workaround#2021-01-0803:13ghaskinsIs there a prescribed way for dealing with css embedded in an npm module, ala:
import '@trendmicro/react-sidenav/dist/react-sidenav.css';
#2021-01-0803:13ghaskinshttps://github.com/trendmicro-frontend/react-sidenav#2021-01-0803:14ghaskinsI tried doing something like this
(ns react-sidenav
  (:require [reagent.core :as r]
            ["@trendmicro/react-sidenav" :refer (Toggle Nav NavItem NavIcon NavText) :as lib]
            ["@trendmicro/react-sidenav/dist/react-sidenav.css"]))
#2021-01-0803:14ghaskinsbut it doesnt like the .css, of course#2021-01-0810:27tughIs it possible to target firefox extension with shadow? I see that there is :chrome-extension target and I’m wondering if the output also works in firefox since they both follow WebExtension standards.#2021-01-0810:27thheller@ghaskins css is not supported at this time. you can use webpack if you really need it or just anything else that can process css#2021-01-0810:27thheller@tugh yeah I think they work in firefox too but not sure#2021-01-0810:30tughThanks, will try and let everyone know.#2021-01-0811:44tughYes. :chrome-extension target also works for firefox 🔥 #2021-01-0811:44tughYes. :chrome-extension target also works for firefox 🔥 #2021-01-0812:43AudriusHello, is this related to Shadow-cljs? I see such html element for the first time. What is this?#2021-01-0813:44thheller@stebokas no it is not. this is shadow dom. usually associated with web components https://developer.mozilla.org/en-US/docs/Web/Web_Components#2021-01-0814:51Vincent Cantin@thheller I have my CSS generated from the metadata found in my source code, it works. Now I have another problem (minor but annoying), the CSS is reloaded in the front end right after the hooks ^:dev/before-load and ^:dev/after-load are called, leading to a flash of unstyle page because the updated source code is using CSS classes which are defined in the CSS file which is not yet loaded in the front end. What can I try to do to get things in this order instead? 1. ^:dev/before-load called 2. Source code and CSS reloaded in the front end 3. ^:dev/after-load called#2021-01-0815:08markbastianI just updated to the latest shadow-cljs and did a clean restart of everything. I can create an nrepl connection to the server just fine, but now when I execute (shadow.cljs.devtools.api/nrepl-select :dev) I get the error:
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28).
watch for build not running
I can see a shadow-cljs - server starting ....................................................................... ready! message in my console and everything else seems right. Any ideas as to what could be going wrong?
#2021-01-0815:11thheller@markbastian as the error is telling you the watch needs to be running. start only starts the server not the watch. you can either start the watch via the web UI at http://localhost:9630 or shadow-cljs watch <build-id>#2021-01-0815:12thheller@vincent.cantin :dev/before-load-async has control over when the next step happens#2021-01-0815:20Vincent CantinFor this to work, the front end would need to know that the CSS is going to be reloaded, so that it will wait for it (in a finite time). I am not sure if it is possible. Alternatively, I was thinking that there could be a way to alter the build-state in the compilation hook where the CSS is generated to mark the generated file as “updated” and hope that it would be sent to the front end in the same batch as the source code. Is this possible?#2021-01-0815:22Vincent CantinSide note: my compilation hook only regenerates the CSS when it is needed, it does not happen on each source code change.#2021-01-0815:36thhellersorry I do not know what you are doing to give a proper answer#2021-01-0815:47Vincent CantinInside a compile hook at the phase :compile-finish , I collect every meta on every Clojure var from any namespace compiled. Based on those informations, I generate some CSS content which I write into an output file, e.g. public/style/girouette.css, using spit. The file is not re-generated if its content is going to be the same. During a shadow-cljs watch :front-end, when the front end developer changes his source and save it on the hard disk, Shadow-CLJS detects a change and recompile the source code. My compilation hook is triggered and a CSS file’s content may be updated. In the browser, the source code is reloaded, front end hooks are called, and then afterward the new CSS (when it’s been regenerated) is reloaded in the browser. My problem is that the CSS is reloaded separately from the source code, I am looking for a way to make Shadow-CLJS update the CSS file in the browser at the same time the source code is updated.#2021-01-0815:49thhellerthat is not supported. css watching is entirely separate currently#2021-01-0815:49Vincent CantinAh ok. Thanks for the answer.#2021-01-0908:52lokirrationalishi! is there a best practice on how to write tests for functions used in a react native environment? i tried targeting :node-test and :karma but — i guess one could have expected that — they throw syntax errors because i include react native modules written in / with flow for the type checks done in that module. as a disclaimer, i’m still in the early phases of clojure(script) development and also react native, so i guess i took on quite a challenge combining both from the start. 🙂 i’d say my ideal scenario would be to test all my pure functions within the clojurescript side of things and i also think that’s the way to go. i’m not really after testing my ui modules / interactions. however, even with a minimal example for a test namespace that doesn’t include any of the namespaces using react native stuff i still get that syntax error, so i’m kinda out of ideas right now. maybe my only choice is to run my tests at runtime in the repl…?#2021-01-0911:05thheller@moledur best ask in #cljsrn I don't do react-native development myself and don't have a clue about testing 😛#2021-01-0911:09lokirrationalisokay thanks 🙂#2021-01-0913:40aratareHi there. I'm having some problems with importing JS file inside CLJS file. Specifically, when using the normal (:require ["blah" :refer [blah]]) I'm getting this error TypeError: $jscomp.inherits is not a function. I'm currently using [org.clojure/clojurescript "1.10.773"] and [thheller/shadow-cljs "2.11.11"]. Has anyone seen anything like this and can point me to the right direction? Thanks.#2021-01-1119:29JAtkinsI have the same issue actually. Last time it was removed by bumping compiler support from default to :es5 then bumping again to :es6. But now, even on :es6 it has appeared 😐. IIRC this is an issue with polyfills#2021-01-0913:49aratareUpdate: Setting the compiler feature set to es6 makes it work. I guess es5 is not an option.#2021-01-0915:46thheller@rextruong unfortunately I haven't been able to reproduce this issue. es5 is the default and should be an option but breaks on some code. I don't know why, would help if you can make a reproducible repo#2021-01-0918:27aratareI'll make an issue soon 🙂#2021-01-0918:11Carlogood morning! I'm trying to use the expound library to pretty-print spec failures. Here's how expound is supposed to work in cljs:
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.773"} expound {:mvn/version "0.8.7"}}}' -M -m cljs.main -re node

ClojureScript 1.10.773
cljs.user=> (require '[clojure.spec.test.alpha :as stest])
nil
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[expound.alpha :as expound])
nil
cljs.user=> (defn add1 [x] (+ 1 x))
#'cljs.user/add1
cljs.user=> (s/fdef add1 :args number?)
cljs.user/add1
cljs.user=> (stest/instrument `add1)
[cljs.user/add1]
cljs.user=> (set! s/*explain-out* expound/printer)
#object[expound$alpha$printer]
cljs.user=> (add1 nil)
Execution error - invalid arguments to cljs.user/add1 at (<cljs repl>:1).
<filename missing>:<line number missing>
-- Spec failed --------------------
Function arguments
  (nil)
should satisfy
  number?
-------------------------
Detected 1 error
However, when I do this in a repl controlled by shadow (both in CIDER and in the command line) I get instead some raw error object:
#error {:message "Call to #'cljs.user/add1 did not conform to spec.", :data {:cljs.spec.alpha/problems [{:path [], :pred cljs.core/number?, :val (nil), :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha30168], :cljs.spec.alpha/value (nil), :cljs.spec.alpha/fn cljs.user/add1, :cljs.spec.alpha/args (nil), :cljs.spec.alpha/failure :instrument}}
Is there a way to control how a failing spec is printed out in shadow-cljs?
#2021-01-0919:32dvingoI have run into an odd issue trying to require a library (@emotion/styled) from npm, where the library works fine on its own, but fails to be required after adding an unrelated npm dependency (@storybook/react). I created a reproduction here: https://github.com/dvingo/shadow-cljs-requires-bug Based on the output from the shadow-cljs build screen ("Babel transform:" statements) I suspect that there is some babel transformation happening to @emotion/styled via a transitive dependency of @storybook/react, but I haven't been able to figure out what it is. I played around with js-options for @emotion/styled to try and force a certain file to be used, but nothing has worked.#2021-01-0920:25thheller@meditans please create a github issue, it'll get lost here. @danvingo you too please#2021-01-0921:13Carlo@thheller done at https://github.com/thheller/shadow-cljs/issues/825#2021-01-0921:16thhellerthx#2021-01-0921:58royalaid@thheller hey I am trying to work on a better Kaocha hook to start a shadow build if it isn't already running. Currently the hook, running in clj, is using
(shadow-api/release (:shadow/build testable))
but this kinda crappy side effect of always starting a new shadow server even if one is running. Is there an easy way to mimic what the shadow-cljs npm package does when starting a build by connecting to a running server or starting a new one?
#2021-01-0922:00royalaidI guess I could always just shell out to start the build but I would prefer use a proper shadow api if possible#2021-01-0923:07GHvWI'm getting a build error caused by an npm dependency issue
[:app] Build failure:
Failed to inspect file
  /mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js

it was required from
  /mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/geometry/projection.js

Errors encountered while trying to parse file
  /mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js
  {:line 5, :column 231, :message "'}' expected"}
Does this look familiar to anyone? I'm new to both clojurescript and shadow-cljs and so I thought I'd ask if this might be caused by something a newbie like me would do that is obvious to veteran users. if it's of any use, characters 220-240 of the pe.js file looks like this "t(((e,t)=>{import("./" , so it looks like it doesn't like something somewhere right at the { and import . Anyone have any ideas what I might be doing wrong? I should mention the npm package is a beta package, its possible there's something wrong, I just doubt its them.
#2021-01-0923:25Mr. Savyhas anyone ever run into an erroneous no output for id error while using the repl?#2021-01-1000:56thheller@ajsnow2012 should be fixed in latest version#2021-01-1002:12Mr. Savyok, thank you sir!#2021-01-1000:56thheller@ghvanw283 the closure compiler does not support dynamic import() so shadow-cljs doesn't either#2021-01-1000:58thheller@royalaid there is no CLJ funtion to connect to a remote server. that is all done from the npm bits. I guess you could do the same thing that does but there is nothing built-in for that from CLJ#2021-01-1001:23GHvWGot it. Thank you so much for the reply @thheller#2021-01-1002:24stuartrexkingI’m getting a compile error I don’t understand. 1. In a CLJC file, in a # block I require a couple of clj namespaces, using :as to name them. 2. In that same CLJC file, in a #?(:clj form, I use those names to destructure keys on a map param. I get this:#2021-01-1002:25stuartrexkingDoes shadow parse :clj forms?#2021-01-1002:29stuartrexkingMy guess is it’s this https://clojurians-log.clojureverse.org/shadow-cljs/2020-07-01#2021-01-1002:39stuartrexkingYeah that was it. CLJC for everything or nothing.#2021-01-1006:58zendevil.ethhow to run tests in shadow-cljs?#2021-01-1006:58zendevil.ethI have the following shadow-cljs.edn#2021-01-1006:58zendevil.eththat contains a test build#2021-01-1006:58zendevil.eth
{:deps true
 :source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "0.12.0"]
                [re-frame-steroid "0.1.1"]
                [rn-shadow-steroid "0.2.1"]
                [re-frisk-remote "1.3.3"]
                [cljs-ajax/cljs-ajax "0.8.1"]
                [day8.re-frame/http-fx "0.2.2"]]

 :builds
 {:test {:target :browser-test
         :test-dir "test/humboi"
         :runner-ns humboi.core
         :devtools  {:http-port          8021
                     :http-root          "test/humboi"}
         }
  :dev
  {:target     :react-native
   :init-fn    humboi.core/init
   :output-dir "app"
   :compiler-options {:closure-defines
                      {"re_frame.trace.trace_enabled_QMARK_" true}}
   :devtools   {:after-load steroid.rn.core/reload
                :build-notify steroid.rn.core/build-notify
                :preloads [re-frisk-remote.preload]}}}}
#2021-01-1006:58zendevil.ethbut running (shadow/watch :test) doesn’t run the tests#2021-01-1006:59zendevil.ethmy tests are in the test/humboi directory#2021-01-1006:59zendevil.ethand the core.cljs contains#2021-01-1006:59zendevil.eth(cljs.test/run-tests)#2021-01-1007:06zendevil.ethI’m getting the following error:#2021-01-1007:06zendevil.ethErrors encountered while trying to parse file /Users/prikshetsharma/Desktop/Humboi/node_modules/react-native/index.js {:line 13, :column 7, :message “cannot use keyword ‘typeof’ here.“}#2021-01-1007:07dmrdI am in search of examples using shadow cljs with replumb. Is anyone familiar with any example code? Came across this thread in this channel previously, which describes that bootstrap shadow target is probably necessary. For context, I’m debugging a replumb repl I have setup that doesn’t seem to have any symbols defined in the cljs/user namespace. Basic types like 1 and 'this-is-a-keyword work fine, but defs & any function call fails#2021-01-1007:11dmrdI have a feeling it is related to the default init-fn! for replumb not working out-of-the-box with shadow: https://github.com/arichiardi/replumb/blob/dde2228f2e364c3bafdf6585bb1bc1c27a3e336c/src/cljs/replumb/browser.cljs#L4#2021-01-1007:12zendevil.eththis is my core_test.cljs#2021-01-1007:13zendevil.eth
(ns humboi.core-test
  (:require [humboi.core :as sut]
            ["@testing-library/react-native" :refer [render fireEvent]]
            [humboi.auth.core :refer [google-sign-in-comp]]
            [cljs.test :as t :include-macros true]))

(defn mount! [component]
  (render (r/as-element component)
          #js {:container (testing-container)}))

(deftest google-login-test
  (is (mount! [google-sign-in-comp])))

(defn start [] (cljs.test/run-tests))

(defn stop [done]
  ;; stopping the tests 
  (done))

(defn ^:export init []
  (start))
#2021-01-1011:22thheller@ps ask in #cljsrn. I do not know anything about react-native testing but I do know that you cannot run them via :browser-test or :node-test#2021-01-1011:23thheller@ritt93 use https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html instead of replumb#2021-01-1017:39ribeloI will try to explain a rather complicated problem in my "English" ;) I am trying to use macro with alter-var-root to redefine how defn and defn-.
(ns patch.tufte
  (:require
   [taoensso.tufte :as tufte :refer [p]]
   [taoensso.encore :as enc]
   #?(:clj
      [cljs.core]))
  #?(:cljs (:require-macros [patch.tufte])) <- Here's the problem!
  )

...
...

#?(:clj
   (alter-var-root #'cljs.core/defn (constantly #'defnp)))

#?(:clj
   (alter-var-root #'cljs.core/defn- (constantly #'defnp-)))
If the specified line is not commented out when launching shadow, it looks like cljs.core is compiling with my new defn. However, if I uncomment the line after compiling the project for the first time, everything works. Can it be solved somehow?
#2021-01-1018:34thhellerside-effects like that are not supported and will break just about everything shadow-cljs knows about compiling#2021-01-1018:37ribeloStill, shadow-cljs it's awesome 🙂#2021-01-1018:38ribeloThanks as always for your work and quick reply.#2021-01-1019:14ribelo@thheller is there any way to force recompilation of the ENTIRE project?#2021-01-1019:15ribeloafter compile time after using force-compile in the dashboard it seems to me that this only compiles the latest changes#2021-01-1020:28thheller@huxley you can delete the cache in .shadow-cljs/builds/<build-id>#2021-01-1020:28thhellerotherwise it'll always use the cache#2021-01-1020:29thhellerneed to restart the watch after that though since that still everything in memory#2021-01-1107:55mkvlrseeing a $jscomp polyfill error again. Wondering if there’s anything I should keep for a reproduction before I nuke .shadow-cljs/ to make the error go away?#2021-01-1107:55mkvlrconcretely it’s $jscomp.asyncExecutePromiseGeneratorFunction is not a function#2021-01-1111:17thhellerhmm yeah I don't know how that happens#2021-01-1111:17thhellersomehow somewhere the polyfill information is lost#2021-01-1111:49thhellerdoes is not go away if you restart the watch?#2021-01-1115:53mkvlrsorry for the late reply, doesn’t go away if I force compile or restart the watch#2021-01-1108:19mkvlrI have the feeling this happens on our project every time we change the package.json#2021-01-1120:31localshredI've been having $jscomp issues as well, I removed .shadow-cljs/ and $jscomp is back in the release build, thanks for the tip @mkvlr#2021-01-1319:02janezjHi, I am porting an old app created at the end of 2015. It was my first app in clojurescript, and since then in production. So from lighttable, leiningen, closure library I would like to migrate to calva, shadow-cljs, newer closure library. So far I am able to compile the code, and clj-kondo revealed some very fishy spots. But application works in simple mode. So now I would like to eliminate compilation warnings I am including google maps in my html page (<script src="https://maps.googleapis.com/maps/api/js?key=AIza.....&amp;libraries=drawing"></script>
34 | (when bslayer
  35 |   (google.maps.event/addListener
----------^---------------------------------------------------------------------
 No such namespace: google.maps.event, could not locate google/maps/event.cljs, google/maps/event.cljc, or JavaScript source providing "google.maps.event"
my build:
{:frontend
  {:target :browser
   :compiler-options {:externs ["google_maps_api_v3_19.js"]}
; google_maps_api_v3_19.js is in the same dir as shadow-cljs.edn
#2021-01-1319:12thheller@jj974 use js/google.maps.events.addListener#2021-01-1319:13thhellerif you use google.maps.event/addListener it expects that to be a CLJS namespace#2021-01-1319:32janezjThanks, I was looking (reading about) npm stuff. this is much better.#2021-01-1320:40grav:node-test ❤️#2021-01-1320:50gravIn Cursive, I'm happily using a Remote Repl with Shadow. I normally run npx shadow-cljs watch app from the terminal, however. Any good hints on how to integrate this part of the workflow better into Intellij?#2021-01-1402:06aratareYou can have a run configuration to run npm run. It's what I'm using at the moment.#2021-01-1320:54thhellerCursive does have a built-in terminal? 😛#2021-01-1322:07gravOh yeah! That's actually working pretty well!#2021-01-1322:05Felipe MarquesHi guys! I'm connected to a CLJS Repl (running on the browser), with Shadow 2.11.13 and CLJS 1.10.773 and I keep getting this error when trying to eval my dev namesapce:
Execution error (ReferenceError) at (<cljs repl>:1).
dev is not defined
This also happens when I run part of it, like this:
(defn sumation [a b]
  (+ a b))
This appear to be a problem specially when I run a def or defn
#2021-01-1322:11gravI've successfully created a node-library with Shadow, but my intention is to use the "module" in a Chrome extension (which doesn't consume modules). Should I just use Webpack on the side, or is there more sense in just using :target :browser, marking my api fns with ^:export?#2021-01-1322:56thhellerwhat is a "module" in a chrome extension?#2021-01-1322:57thhellerthere is a dedicated :chrome-extension target#2021-01-1323:08gravOh - didn't see that in the docs - thanks 🙂#2021-01-1323:50thhellerits not in the docs yet. kinda unfinished but works ok#2021-01-1323:51thhellerhttps://github.com/thheller/shadow-cljs/issues/279#2021-01-1402:25jkentAfter adding :repl-init-ns option to my shadow-cljs.edn, I’ve been encountering the following error after leaving my browser repl idle:
[2021-01-05 13:26:03.677 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(test-client)", :ns client, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns client, :form (test-client), :source "(test-client)", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:524)
        shadow.cljs.repl/process-read-result (repl.clj:498)
        shadow.cljs.repl/process-input (repl.clj:682)
        shadow.cljs.repl/process-input (repl.clj:660)
        shadow.cljs.devtools.server.worker.impl/fn--15170 (impl.clj:755)
        shadow.cljs.devtools.server.worker.impl/fn--15170 (impl.clj:745)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14833/fn--14834/fn--14842 (util.clj:285)
        shadow.cljs.devtools.server.util/server-thread/fn--14833/fn--14834 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14833 (util.clj:257)
        java.lang.Thread.run (Thread.java:834)
Caused by:
ExceptionInfo no source by provide: client {:provide client}
        shadow.build.data/get-source-id-by-provide (data.clj:187)
        shadow.build.data/get-source-id-by-provide (data.clj:184)
        shadow.build.data/get-source-by-provide (data.clj:190)
        shadow.build.data/get-source-by-provide (data.clj:189)
        shadow.cljs.repl/repl-compile/fn--14400/fn--14401 (repl.clj:460)
my client.cljs file looks as follows:
(ns client
  (:require [cljs.repl :refer [doc find-doc source apropos pst dir]]
            [re-frame.core :as rf]
            [re-frame.db :as rfdb]))

(defn test-client []
  {:status "alive"})

(defn db []
  @rfdb/app-db)
what does “no source by provide: xxx {:provide xxx}” mean? is there a way to to recover from this besides restarting my shadow-clj watch and my repl?
#2021-01-1410:55thhellerwhich version do you use? I fixed a bug related to this in the last version#2021-01-1414:06jkent@thheller I’m using the latest shadow-cljs version 2.11.13#2021-01-1415:36thhellerI suppose client is not part of your usual build? try adding :preloads [client] :repl-init-ns client#2021-01-1415:37jkentthats correct. client.cljs is mostly used a scratch file for development#2021-01-1415:38jkentI’ll try adding :preloads [client] to my shadow-cljs.edn file#2021-01-1415:40jkentI’m giving this a go:
:devtools         {:repl-init-ns client
                   :http-root    "resources/public"
                   :http-port    8280
                   :proxy-url    ""
                   :preloads     [client
                                  sphere.cstools
                                  devtools.preload
                                  day8.re-frame-10x.preload]}}}}
#2021-01-1415:41thhellerthat should be fine#2021-01-1408:42gravCan I get Shadow to reload and re-run tests (`:target :node-test`) when a non-clojure file changes (in this case an edn file with expected results)?#2021-01-1410:43Karol Wójcik@thheller I'm sorry for notifying you directly, but I think that you're the only who can answer this question. In the project I'm working on we're using following strategy to resolve lazy modules:
(defn- lazy-resolve
  [symbol-k]
  (let [symbol' (symbol symbol-k)
        module' (-> (str symbol')
                    (s/replace #"/.*" "")
                    (s/split #"\.")
                    ((partial s/join "-"))
                    keyword)]
    `(conj [] ~module' (cond-> (fn [] (resolve (quote ~symbol')))
                         config.core/DEV?
                         (with-meta {:sym (quote ~symbol')})))))
.... From this we get [module-name, symbol] like ["core-reservation", "core.reservation/some-symbol"] . Then we combine that data with shadow.loader . Of course it works well. The only issue I have is how greatly this pattern increase the build size. Those invocations are spread across whole application adding like 200kb for main bundle. The question is whether it can be somehow optimized? If you could share some insights with me I would be more than grateful.
#2021-01-1410:53thheller@karol.wojcik look at a build report to see where the size is coming from https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2021-01-1410:54thhellerin general you should avoid resolve. there is also https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2021-01-1410:55Karol Wójcik@thheller I'm using code splitting and lazy modules. I'm trying to say that requiring lazy different modules to main bundle results in those long strings of resolves. I would like to make it smaller.
#2021-01-1410:58Karol Wójcik@thheller Ok got it. Will use loadable and the issue is resolved. 🙂 Thank you so much!#2021-01-1411:00thhelleras I said ... look at the build report so you can figure out WHY you get the 200kb#2021-01-1411:00thhellermy hunch would be that you are importing cljs.analyzer somewhere maybe#2021-01-1412:55Karol Wójcik@thheller i got a lot of lazy calls, and a lot of lazy modules. Anyway thanks for hint with cljs.analyzer. Will check this out#2021-01-1412:56thhellerthat doesn't tell me anything. I do not know what a lazy call or lazy module is in your terms#2021-01-1412:56thhellerI know what it is in the case of shadow.lazy but if you build your own I do not know what that does#2021-01-1415:13Karol WójcikI mean that I'm having 30-40 modules (you told me once that I should group those modules together (will do it as well)) in :modules section in shadow-cljs.edn configuration which I use quite extensively in main module. The strategy of requiring the module is combination of shadow.loader + resolve. Resolve is the function which adds that 200kb to main bundle. Checked whether cljs.analyzer is imported somewhere, but it's not 🙂#2021-01-1415:13Karol WójcikThank you very much for the respnse. Will use Loadable to get rid of resolve 🙂#2021-01-1415:35thhellerresolve adds a bunch of boilerplate "noise" yes. didn't expect it to get to 200kb though.#2021-01-1414:46Felipe MarquesI boiled down to two problems. • Referencing deprecated functions (and multi-method)
(defn ^:deprecated my-fn [a b] (+ a b))
• A namespace defining a value two times
(def a 1)
(def a 2)
@thheller Was there any change to Shadow from version 2.8.93 to verison 2.11.13 regarding this? I didn't find any in the notes of each release, but I may have not notice.
#2021-01-1415:07grounded_sageHow do I control what browser the browser-repl connects to?#2021-01-1415:09mkvlr@grounded_sage by default it’s the first one that connects, but you can change it to be the last with :repl {:runtime-select :latest} in shadow-cljs.edn#2021-01-1415:37thhellerthere is also now (shadow/repl :app {:runtime-id 123})#2021-01-1416:39grounded_sageIs this documented somewhere and how you use it?#2021-01-1416:57thhellerwhat do you mean? thats all there is to it?#2021-01-1417:39grounded_sageSorry I am just unsure how :runtime-id works. Where is it generated? I don’t see anything that says runtime id when I run shadow-cljs watch app etc. I haven’t been that deep in shadow-cljs lately or doing any complex configurations.#2021-01-1417:48thhellerah sorry. it is visible in the ui http://localhost:9630/runtimes#2021-01-1417:48thhelleror listed in most runtimes on connect#2021-01-1417:48thhellerbrowser.cljs:20 shadow-cljs: #13 ready! or so#2021-01-1417:48thheller13 would be the runtime-id#2021-01-1418:24grounded_sage🙏#2021-01-1415:39thheller@marques.goncalves.fel your question is unclear. need more information about what you are doing. how do you "eval" the dev ns? (require 'dev) in the REPL? load-file from the editor? (ns dev)? if you just use (dev/whatever) without doing those first you'll get the dev is not defined error?#2021-01-1415:47Felipe MarquesI eval the file using cider-eval-buffer. The file in question is the dev.cljs which contains the dev namespace.#2021-01-1415:59thhellerand what is in that file?#2021-01-1416:30Felipe MarquesLot of stuff! Hahahaha. But I found out that it didn't load when it referred another namespace that contained a deprecated function like this: (defn ^:deprecated ab [a b] (+ a b) Or when the namespace itself defined a value two times, like this:
(def company-id (random-uuid))
; Some other code
(def company-id #uuid "0acf9013-7c42-49fc-ae4b-221639bf9a34")
#2021-01-1416:39thhellerah so whenever there is a warning#2021-01-1418:27Felipe MarquesYes, I think so.#2021-01-1418:38thhellerright yeah I changed it that warnings in compiled code prevent the code from being loaded#2021-01-1418:38thhellerstill need to add an option to turn that off#2021-01-1418:41Felipe MarquesGot it! Cool! Thanks for the information. Do you think that this is an issue that a new comer to the repo would be able to do? Maybe I can try to add this option.#2021-01-1418:49thhellerfixed in 2.11.14 via :devtools {:ignore-warnings true} in your build config#2021-01-1418:50Felipe Marquescool! Thanks!#2021-01-1416:38grounded_sageThanks @mkvlr that is exactly what I needed.#2021-01-1522:40Greg RynkowskiHi, thank you @thheller for building this amazing tool. I’ve been trying to create a demo showing an integration of it into a hypothetical existing Serveless NodeJS project. I managed to call CLJS from JS (using :npm-module) target, but I can’t call local JS files from CLJS files. I receive ReferenceError: shadow$provide is not defined at the place I try to https://github.com/rynkowsg/serverless-demo/blob/master/calc-nodejs-shadowcljs/src/main/calc.cljs#L5. The URL to the repo is here: https://github.com/rynkowsg/serverless-demo/tree/master/calc-nodejs-shadowcljs Any help, hint very much appreciated.#2021-01-1710:34thhellerplease open a github issue. I'll take a look soon.#2021-01-1916:09Greg RynkowskiI have created the issue here: https://github.com/thheller/shadow-cljs/issues/832#2021-01-1602:57masasHi everyone.#2021-01-1707:06zendevil.ethhas anyone used react native testing library with shadow-cljs?#2021-01-1707:06zendevil.ethHow did you integrate the tests?#2021-01-1714:49janezjI would like to import js-notications, the exact syntax is not in shadow-cljs doc
import ToastManager from 'js-notifications';
const toastManager = new ToastManager();
(:require ["js-notifications" :refer (ToastManager)] ) (.ToastManager. {}) -> module$node_modules$js_notifications$dist$ToastManager.ToastManager is not a constructor
#2021-01-1715:23thhellerthe exact syntax is in the docs, see the translation table https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-01-1716:29janezjThe exact pattern is not in the docs. I tried them all, but after lunch I might found the solution, it looks promising - no errors (It is not logical to me at all)
import ToastManager from 'js-notifications';
-> 
["js-notifications" :default ToastManager]
#2021-01-1716:41nivekuil#2021-01-1716:41nivekuilI see that one as the first row in the table#2021-01-1716:52janezjthis "default" is confusing to me. When npm exports some objects, is there one default? or defaultExport is just a name and :default just picks an object from map of all exported objects?#2021-01-1716:59thhellerimport defaultExport from "module-name"; it is right there in the first example 😛#2021-01-1717:00thhellerthe name is up to you. you choose it. defaultExport is the name#2021-01-1717:00thhellercan be anything#2021-01-1717:01thhellerdefault exports are "new" in ESM and are somewhat special#2021-01-1717:01thhellertechnically you can also :as x and x/default but thats kinda lame#2021-01-1718:22zendevil.ethI’m getting the following error when running shadow watch#2021-01-1718:23zendevil.ethInvalid configuration -- Spec failed --------------------  {:target ...,   :output-dir ...,   :entries [],       ^^   :build-id ...} should satisfy  (<= 1 (count %) Integer/MAX_VALUE) -- Relevant specs ------- :shadow.build.targets.npm-module/entries:  (clojure.spec.alpha/coll-of   clojure.core/simple-symbol?   :distinct   true   :min-count   1   :kind   clojure.core/vector?) :shadow.build.targets.npm-module/target:  (clojure.spec.alpha/keys   :req-un   [:shadow.build.targets.shared/output-dir   :shadow.build.targets.npm-module/entries]   :opt-un   [:shadow.build.targets.npm-module/runtime   :shadow.build.targets.shared/devtools]) :shadow.build.config/build+target:  (clojure.spec.alpha/and   :shadow.build.config/build   (clojure.spec.alpha/multi-spec   shadow.build.config/target-spec   :target)) ------------------------- Detected 1 error#2021-01-1718:23zendevil.eth{:deps true :source-paths [“src”] :dependencies [[reagent “0.10.0"] [re-frame “0.12.0”] [re-frame-steroid “0.1.1"] [rn-shadow-steroid “0.2.1”] [re-frisk-remote “1.3.3"] [cljs-ajax/cljs-ajax “0.8.1”] [day8.re-frame/http-fx “0.2.2"]] :builds {:test {:target :npm-module :output-dir “test-out” :entries []} :dev {:target :react-native :init-fn humboi.core/init :output-dir “app” :compiler-options {:closure-defines {“re_frame.trace.trace_enabled_QMARK_” true}} :devtools {:after-load steroid.rn.core/reload :build-notify steroid.rn.core/build-notify :preloads [re-frisk-remote.preload]}}}}#2021-01-1718:23zendevil.ethi’m running the command shadow-cljs watch test#2021-01-1718:41thhellerthe error tells you that :entries [] is not valid and requires at least one namespace#2021-01-1718:45zendevil.ethI put in a namespace myapp.core-test but it says that the namespace wasn’t found#2021-01-1718:45zendevil.ethnot available#2021-01-1718:47zendevil.ethI expect that the namespace would be available#2021-01-1718:47zendevil.ethsince the namespace is defined in one of the files in the source-paths#2021-01-1718:48zendevil.eththe source path is “test”#2021-01-1718:57zendevil.ethand the file with this namespace is found in the path ./test/myapp#2021-01-1719:29thheller:deps true. do you have "test" added in :paths in deps.edn?#2021-01-1720:02zendevil.ethI’ve added test in :source-paths in deps.edn#2021-01-1720:30janezjWhat about clj->js? I was quite naive, that the npm import has magic powers and will also convert clojure stuctures to js. But I found that this is not the case and clj->js is still a must, It would be great id clj-kondo would be able to recognize cases like that. I spent at least an hour before I find out that my options are silently ignored without conversion. (def tm (ToastManager. (clj->js {:container log-container, :seconds 300})))#2021-01-1720:31borkdude@jj974 this is impossible to know for clj-kondo I think, which JS libs accept data CLJS structures and which do not (even if most of them don't)#2021-01-1720:34thheller@ps :source-paths is not a thing in deps.edn. it is :paths or :extra-paths#2021-01-1721:53janezj@U04V15CAJ clj-kondo is great. I cleaned up my old project. Learned a few things, misplaced doc strings, way too many times.#2021-01-1721:54borkdude:)#2021-01-1815:56mynomotoOn a sample project I used :target :npm-module without :entries because that was not mandatory at the time. This is used to compile test files to be ran by jest. What should I put on :entries to have the same behavior as before? That is related to @ps question as he is using the project as a reference to run tests using jest.#2021-01-1815:57mynomotoI mean something more practical than enumerate every test namespace 😅 as this is clearly an option.#2021-01-1815:58mynomotoLink for reference: https://github.com/mynomoto/reagent-expo/blob/jest-test/shadow-cljs.edn#L18#2021-01-1816:30davidwwhen using watch, is it possible to get shadow to watch extra files other than a cljc/cljs files? I'm working on some tests for firebase firestore security rules (using {:target node-test :autorun true ...}) and I'd like to have the tests automatically re-run when I update the firebase.rules file.#2021-01-1816:37thheller@davidw no not currently but you could just not use :autorun true and instead run the tests triggered by another watch util#2021-01-1816:38thhellereg use https://github.com/paulmillr/chokidar#cli and have it watch the test output file and firebase.rules#2021-01-1816:39davidwok, thanks, I'll do something like that.#2021-01-1816:42thheller@mynomoto open a github issue please so I don't forget. I can add that functionality back I guess.#2021-01-1818:49mynomotohttps://github.com/thheller/shadow-cljs/issues/831#2021-01-1818:49mynomotoThank you!#2021-01-1818:04jpmonettashi everybody! I'm getting a error when compiling a app that uses "http://kepler.gl" npm lib. I'm getting [2021-01-18 15:02:00.526 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/kepler_DOT_gl/dist/localization/index.js", :requires [{:line 44, :column 192}]}. What looks wrong is that path "node_modules/kepler_DOT_gl/..." when it should be "node_modules/kepler.gl/..." any ideas of what can be causing this?#2021-01-1818:23thhellerthats just the resource naming. the actual file is in and the name has nothing to do with the problem#2021-01-1818:23thhellerits likely the lib does some kind of dynamic require require(somethingNotAString) or so#2021-01-1818:34jpmonettasoh you are right#2021-01-1818:35jpmonettasit is doing require("./".concat(key))["default"]#2021-01-1818:36thhelleryeah thats not supported#2021-01-1818:36jpmonettasoh ok, any workarounds? or this library can't be used in a shadow-cljs project?#2021-01-1818:37thhellerunlikely that will be supported by any bundler#2021-01-1818:38thhellermaybe the lib requires a webpack plugin or so and requires webpack in turn#2021-01-1818:38thhellercan't say. don't know the lib.#2021-01-1818:39jpmonettasyeah probably, thanks a lot @thheller#2021-01-1900:53pinkfrogI am using this dependency: [cljsjs/react-input-autosize “2.2.1-1”]#2021-01-1900:53pinkfrogand when run npx shadow-cljs compile app, it errs: The required namespace “cljsjs.react-input-autosize” is not available, it was required by “understanding_re_frame/hiccup.cljs”#2021-01-1900:54pinkfrogHowever, I do see a ~/.m2/repository/cljsjs/react-input-autosize/2.2.1-1/react-input-autosize-2.2.1-1.jar file#2021-01-1900:55pinkfrogwhat’s the further steps should I verify to see what’s going wrong?#2021-01-1900:56dpsutton> shadow-cljs does not support CLJSJS at all to avoid conflicts in your code https://shadow-cljs.github.io/docs/UsersGuide.html#_why_not_use_cljsjs#2021-01-1913:19pinkfrogThanks for that info.#2021-01-1913:28SchpaaDoes shadow support this? http://clojurescriptmadeeasy.com/blog/refactoring-with-deprecation.html#2021-01-1913:30thheller@schpaencoder in the latest version you can set :devtools {:ignore-warnings true} so this doesn't blow stuff up#2021-01-1913:30thhelleror you can just turn off the warning completely#2021-01-1913:31thheller:compiler-options {:warnings {:fn-deprecated false}} should work fine yes#2021-01-1913:31Schpaahttps://github.com/clojure/clojurescript/commit/3ea593825f60c228f6a384be52bcf2fc4e417567#2021-01-1913:31Schpaathere is this ^#2021-01-1913:31Schpaa(def ^:dynamic cljs-warn-fn-deprecated true)#2021-01-1913:32SchpaaIf I can do this with a simple binding, I would rather…#2021-01-1913:34thhellerpretty sure that code doesn't exist anymore#2021-01-1913:38Schpaaoh well, I guess I just have to slow down a little then#2021-01-1913:39thhellerwhats the problem?#2021-01-1913:40SchpaaThe problem is I don’t want to turn off warnings, but shadow complains about deprecations#2021-01-1913:41thhellerthen turn off that warning if you dont want to see that warning#2021-01-1913:42SchpaaOh, sorry, Didn’t see the {:fn-deprecated false}#2021-01-1913:42thhellerunless you still want to see it but not prevent hot reload and stuff. for that you can set :devtools {:ignore-warnings true}#2021-01-1913:42SchpaaYes of course!#2021-01-1913:42Schpaaperfect!!#2021-01-1914:30Margohello, everybody! I am relatively not new to clojureScript, but I am new to shadow-cljs, in particular how to configure testing properly. i have a 100% shadow-cljs project and I am struggling with the :node-test and :browser-test setups as they do not give me the desired output. Can maybe somebody give me an example of a project with shadow-cljs with properly configured testing? thank you in advance#2021-01-1916:18pinkfrogIsn’t shadow supposed to automatically download the dependency? When I add https://github.com/day8/re-frame-10x as the project dependency, it errs: The required JS dependency “react-highlight.js” is not available, it was required by “day8/re_frame_10x/view/components.cljs”.#2021-01-1916:18thheller@marharyta.obraztsova what is the "desired output"?#2021-01-1918:17MargoSo, I am currently configuring :browser-test and the way I understand it (correct me if I am wrong) that this is the best way to set up testing for atoms and re-agent components#2021-01-1918:18MargoInitially I was not able to see the UI in the browser#2021-01-1918:18Margo#2021-01-1918:19Margoas you can see now, I do, yet the panel on top shows 0 tests, o assertions#2021-01-1918:20Margo#2021-01-1918:20Margothere it is#2021-01-1918:25thhellerhmm not a clue about that. that display is from https://github.com/bhauman/cljs-test-display#2021-01-1918:25Margoyes, it is#2021-01-1918:26Margoaccording to the shadow-cljs docs I should not need it in the first place#2021-01-1918:26Margobecause they have it intergrated#2021-01-1918:26MargoBut I seem to need#2021-01-1918:26thhellerneed what?#2021-01-1918:27Margo... I seem to need it in my code to display the tests in the viasual way in the browser anyways#2021-01-1918:27thhellerI'm confused. this is something you set up yourself?#2021-01-1918:28Margoyes, I did set it up myself#2021-01-1918:28Margotest.cljs
(ns mytherapy.test
  (:require [cljs.test :refer (deftest is use-fixtures)]
            [shadow.dom :as dom]
            [shadow.test :as st]
            [cljs-test-display.core :as ctd]
            ["react-testing-library" :as rtl]
            [cljs-time.core :as time]
            [mytherapy.state-utils :refer [state-app make-note]]
            ))


;; 
 
(use-fixtures :each
  {:after rtl/cleanup})

(def test-state {:notes []
                 :records []
                 :data []
                 :currentNote {}})

(deftest a-failing-test
  (is (= 2 2)))

(deftest a-failing-test-6
  (is (= 9 2)))

(deftest test-make-note
  (is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
                                      :note_title "hello"
                                      :note_type "note"
                                      :timestamp_created "20210119T164619"
                                      :timestamp_edited "20210119T164619"})))

(defn start []
  (st/run-all-tests (ctd/init! "test-root"))
  (a-failing-test)
  (a-failing-test-6)
  (test-make-note))

(defn stop[done]
  ; tests can be async. You must call done so that the runner knows you actually finished
  (done))

(defn ^:export init[]
  (dom/append [:div#test-root])
  (start))
#2021-01-1918:28thhellerwhy did you do that?#2021-01-1918:28Margobecause otherwise I see blank page#2021-01-1918:29Margoif the test file looks like this:#2021-01-1918:29thhellerthe test file should just contain deftest and so on#2021-01-1918:30Margo
(ns mytherapy.test
  (:require [cljs.test :refer (deftest is use-fixtures)]
            [shadow.dom :as dom]
            [shadow.test :as st]
            [cljs-test-display.core :as ctd]
            ["react-testing-library" :as rtl]
            [cljs-time.core :as time]
            [mytherapy.state-utils :refer [state-app make-note]]
            ))


;; 
 
(use-fixtures :each
  {:after rtl/cleanup})

(def test-state {:notes []
                 :records []
                 :data []
                 :currentNote {}})

(deftest a-failing-test
  (is (= 2 2)))

(deftest a-failing-test-6
  (is (= 9 2)))

(deftest test-make-note
  (is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
                                      :note_title "hello"
                                      :note_type "note"
                                      :timestamp_created "20210119T164619"
                                      :timestamp_edited "20210119T164619"})))

(defn start []
  (a-failing-test)
  (a-failing-test-6)
  (test-make-note))

(defn stop[done]
  ; tests can be async. You must call done so that the runner knows you actually finished
  (done))

(defn ^:export init[]
  (start))
#2021-01-1918:30thhellernothing related to runner stuff. that is completely optional. I guess the docs should make that clearer.#2021-01-1918:30Margothen i see blank page#2021-01-1918:30thhellerremove start/stop/init completely#2021-01-1918:30MargoIt says I should do that in the docs#2021-01-1918:30thhellerand do NOT specify a :runner-ns in your build config#2021-01-1918:31Margohttps://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test#2021-01-1918:31Margohmm, I can try it#2021-01-1918:31thhelleryeah I'll clear that up. :runner-ns (optional)#2021-01-1918:31thhellerthis is definitely not clear enough 😛#2021-01-1918:33Margoafter deleting :runner-ns I see nothing#2021-01-1918:34thhellerok now you likely need to delete the index.html you created#2021-01-1918:35thhellershadow-cljs will generate a new one (when you start the watch)#2021-01-1918:37MargoSame here#2021-01-1918:39thheller
{...
 :builds
 {:test
  {:target :browser-test
   :test-dir "test-out"
   :ns-regexp "-test$"
   :devtools {:http-port 8021
              :http-root "test-out"}}}}
#2021-01-1918:39thhellertry this. just in case there are files or whatever in the old :test-dir interfering with stuff#2021-01-1918:40thhellernote that the test ns likely needs to be changed as the regexp above is for files ending in -test so mytherapy.test wouldn't match that#2021-01-1918:42Margoperfect!#2021-01-1918:42MargoThanks a lot @U05224H0W!#2021-01-1916:19thheller@i did you restart after adding the dependency?#2021-01-1916:23pinkfrogYes. Now I manually add the dependency.#2021-01-2005:26zendevil.ethI’m getting an error when importing and using a module#2021-01-2005:26zendevil.ethHere’s how it’s imported:#2021-01-2005:26zendevil.eth[“@react-native-community/cameraroll” :default CameraRoll]#2021-01-2005:26zendevil.ethHere’s how it’s used:#2021-01-2005:26zendevil.eth(. CameraRoll save (.-uri (<p! (. @!camera recordAsync))))#2021-01-2005:26zendevil.ethHere’s the error:#2021-01-2005:27zendevil.ethundefined is not an object (evaluating ‘shadow.js.shim.module$ $react_native-community$cameraroll.default.save’)#2021-01-2005:27zendevil.ethHow to fix this error?#2021-01-2010:19thheller@ps same problem as always. it might not be :default it might be :as or :refer. [“@react-native-community/cameraroll” :as CameraRoll] or [“@react-native-community/cameraroll” :refer (CameraRoll)]#2021-01-2011:29Karol WójcikIs it possible to modify: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/api.clj#L114?#2021-01-2011:33thhellermodify what? https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache ?#2021-01-2011:36Karol Wójcikcache-blockers#2021-01-2011:37Karol WójcikOk got it!#2021-01-2011:37Karol WójcikThank you @thheller#2021-01-2013:57pinkfrogThere is like 5 seconds delay between i save the cljs file and shadow recompiling it.#2021-01-2013:57pinkfrogHow to make it shorter?#2021-01-2013:59thhellerdo you use macos big sur?#2021-01-2014:22pinkfrogyes#2021-01-2014:26thhelleryeah I heard reports that its a lot slower there since they removed some stuff basically all CLJ(S) projects used#2021-01-2014:26thhellerie. they broke hawk#2021-01-2015:16valsenHi everyone, I’m setting up a fullstack project with deps.edn and shadow-cljs.edn, and I have a “clj” and a “cljs” folder in src. I want shadow-cljs.edn to manage the cljs dependencies, but they are not being recognized at all. If I set :deps true I can successfully manage them from deps.edn instead, but I would prefer not having to do that. Any ideas what I might be doing wrong?#2021-01-2015:32valsenOh and here’s shadow-cljs.edn:
{:source-paths ["src/cljs"]
 :dependencies
        [[re-frame "1.1.2"]
         [reagent "0.9.1"]]
 :builds
        {:app {:target     :browser
               :output-dir "resources/public/js"
               :asset-path "/js"
               :modules    {:main {:init-fn wallet.core/init}}
               :devtools   {:http-root "resources/public"
                            :http-port 4200}}}
 :nrepl {:port 9000}}
and deps.edn:
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        metosin/reitit {:mvn/version "0.5.10"}
        http-kit/http-kit {:mvn/version "2.5.0"}}

 :paths ["src/clj" "resources"]

 :aliases {:run {:main-opts ["-m" "wallet.core"]}}}
#2021-01-2017:12thhellerlooks fine. what is the problem?#2021-01-2019:51valsen@thheller My namespaces in src/cljs are not being recognized, and neither are the required dependencies, as you can see in this screenshot#2021-01-2019:53thhellerwell thats a Cursive issue. not anything to do with shadow-cljs#2021-01-2019:53valsen#2021-01-2019:53valsenah ok, i see#2021-01-2019:54thhellerCursive doesn't support shadow-cljs.edn so it doesnt "see" the source-paths and dependencies#2021-01-2019:54thhelleronly option really is to put everything into deps.edn#2021-01-2019:55valsenok, will do that then. Thanks for the explanation!:)#2021-01-2020:04valsenIf anyone else looks at this thread and notices that I forgot to add :as reagent and :as re-frame in the requirements, that was just when I quickly prepared the code to demonstrate. The problem persists with correct requirements and is due to Cursive, like thheller explained:)#2021-01-2017:53Jp SoaresIs there a way to use the compiler option {:warnings-as-errors true} with cljs.js/eval-str? It looks like the available options of [cjs.js/eval-str](https://cljs.github.io/api/cljs.js/eval-str) are limited.
(defn evaluate [s callback]
  (cljs.js/eval-str
    compile-eval-state
    s
    nil
    {:eval cljs.js/js-eval
     :load (partial shadow.bootstrap/load (analyzer/empty-state))
     :warnings-as-errors true
     :context :expr}
    (fn [result] (do (js/console.log result)
                     (callback result)))))
I also tried to pass compiler-options as an argument of analyzer/empty-state but I had no success.
#2021-01-2018:03thhellerno, that is a shadow-cljs feature not part of regular cljs#2021-01-2018:04Jp Soareshum.. ok, but I also tried the :warning-handlers and it also didn't work.#2021-01-2018:05thhellersorry can't help with self-host questions much. can't expect shadow-cljs features to work there since that is using all the regular cljs compiler stuff without any of the shadow-cljs additions/tweaks#2021-01-2018:06Jp SoaresThanks.. maybe the #clojurescript would be a better channel for this question?#2021-01-2018:07thhellerprobably#2021-01-2019:35fsdHi There, I have shadow.cljs application, when I run yarn build , it gives generates build file main.js. After linking the css and main.js to index.html it gives error on some of the assets file for ex png images. The css file background-image: url("/icons/square.png") these gives 404. Any help would be appreciated!#2021-01-2019:52thhellerI guess you are looking at the file without an http server? just opening the index.html?#2021-01-2020:00fsdCorrect, index.html#2021-01-2020:02fsdafter linking up all the file, everything loads main.js css file except background-image: url (“”)#2021-01-2020:04thhellerwell by using a path like /icons/square.png it'll look at an absolute path for your file#2021-01-2020:05thhellerso if you open /home/user/project/foo/index.html it'll look for /icons/square.png#2021-01-2020:05thhellerwhich is not where you have the files very likely 😛#2021-01-2020:05thhelleryou can either use icons/square.png so the path is relative to the current file#2021-01-2020:05thhelleror use an http server which you'll likely use/need anyways#2021-01-2020:37fsdI tried using this on both opening index.html and local server and did not work#2021-01-2020:51thhellerwell if you show me your config and setup I can tell you whats wrong#2021-01-2020:51thhellerwithout that I'm guessing which helps no one#2021-01-2100:41Mr. Savyhello! I am trying to release a shadow-cljs app through heroku. does anyone know of any guides that can help me get through this process? I haven't ever done this before.#2021-01-2106:07David PhamYou mean that you advanced compiled an app, and now you want to publish it?#2021-01-2106:09David Phamhttps://blog.heroku.com/deploying-react-with-zero-configuration#2021-01-2113:16thhellershould be straightforward but I've never used it either#2021-01-2117:58Mr. Savyyeah I've run the release command on my application so now I want to go through the process of publishing it. i will take a look at that link, thank you!#2021-01-2118:01Karol WójcikQuestion: Is it possible to run two release builds in parallel?#2021-01-2118:32thhellersure, just not with the default commands#2021-01-2213:23Karol WójcikGot it!#2021-01-2118:33thhellertypically you won't gain much doing it. compiltation is already parallel and should use most cores most of the time#2021-01-2215:12janezj
(defn parse-dtime
([parser stime]
   (let
    [d (js/Date. 0 0 0 0 0 0 0)
     n (.strictParse parser stime d  
--------------^-----------------------------------------------------------------
Cannot infer target type in expression (. parser strictParse stime d)
How to tell compiler, that parser is instance of goog.i18n.DateTimeParse. DateTimeParse.strictParse is from goog library and is renamed during advanced compilation.
#2021-01-2215:39isakTry to switch [parser stime] to [^js parser stime]. Does that work?#2021-01-2215:54thhellerif its safe to rename you can do [^goog parser stime]. ^js is fine too but prevents the renaming#2021-01-2218:04janezjThanks, code is compiled without errors and it is working properly. But I don't understand a shadow-cljs and compiler's magic powers ^js => strictParse is not renamed, and there is a code strictParse = function(a, b, c) # how compiler knows that strictParse must be exposed, what happens when there are more classes with strictParse? how compiler ^goog.i18n.DateTimeParse, ^goog => in both cases, result is the same, method is renamed and it works properly. I just don't get it how ^goog provides enough information#2021-01-2218:11thheller^goog just tells externs inference that it does NOT need to collect externs for this and as such the closure compiler is free to rename it#2021-01-2218:12thheller^js creates externs for strictParse and as such closure will not rename it#2021-01-2218:12thhellercompletely fine to just use ^js since the code size difference will be so tiny it won't matter#2021-01-2218:24janezjI know about the size, I just want to understand my code. the renaming must happen on two places in my code and in the google library. So compiler will rename all strictParse (marked as renamable) globally, not case by case, so ^goog means all "attachments - properties, methods" of this object. This is undocumented feature?#2021-01-2218:33thhellerno you misunderstand how :advanced optimizations and externs work#2021-01-2218:33thhellerthe CLJS compiler generates identical code with ^js or ^goog. it does not affect the generated JS at all.#2021-01-2218:34thhellerexterns then control whether the closure compiler is allowed to rename something or not. the CLJS compiler is out of the picture at that time.#2021-01-2218:34thhellerso as far as the closure compiler is concerned there is no such thing as the closure library or CLJS code. it just sees a bunch of JS code#2021-01-2218:34thhellerand the renaming it does is documented, just not sure where#2021-01-2222:25janezjSo for every cljs file shadow-cljs generates a .js file, but the file is not affected by annotations, where are all externs written?#2021-01-2222:27thheller.shadow-cljs/builds/<build-id>/release/shadow.externs.js or so#2021-01-2219:00gzmaskhello! pretty new to cljs: for browser target I tried to eval a quoted code list into Clojurescript runtime. while cljs.js/eval works with simple things like [1 2 3, anything that needs core NS stuff will tell me they are undefine with warning: i.e
(cjs/eval
 (cjs/empty-state)
 (parse-string "(cljs.core/println \"ehhlo bootstrapped\")")
 {:eval cjs/js-eval
  :source-map true
  :context :expr}
 (fn [r] r))
but if I choose browser target, start the browser, connect to cljs-repl, and change to bootstrap target midflight, it works . If I choose bootstrap target, browser fails to connect to my cljs-repl; Can I just use browser or bootstrap target instead of the mid-flight switch hack to make it work?
#2021-01-2219:55thhellerif you want to do self-hosted stuff you need to do the setup described here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2021-01-2219:56thhellerdon't know what kind of hackery you are trying but browser+bootstrap are supposed to be 2 separate builds. it does not work otherwise.#2021-01-2220:04gzmaskah, I see, they are meant to be separated and call in certain orders. That’s probably why my hack kinda work. Thanks!#2021-01-2222:27gzmaskis source map path hardcoded? I set my output-dir to be out and I am getting
DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0
which suggests it’s looking at js instead
#2021-01-2222:28thhellerthat is controlled by :asset-path#2021-01-2300:19JasonI want to try out a js library whose install instructions want me to do something like
<NewLibProvider>
    <App />
</NewLibProvider>
What is the best / most idiomatic way to do that in a shadow app?
#2021-01-2300:44thhellerdepends on which react wrapper you prefer. reagent is probably easiest?#2021-01-2301:20Jasonan expertly weighted nudge in the right direction. thanks#2021-01-2316:37BuidlerI'm getting this error when initially firing up:
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (rewrite_clj/custom_zipper/core.clj:59:1). #:clojure.error{:phase :compile-syntax-check, :line 59, :column 1, :source "rewrite_clj/custom_zipper/core.clj"}
I haven't fired up my project in a little while. It worked just fine last time I looked at it like a month ago but now the above occurs. Edit: looks like upgrading to latest shadow fixed it.
#2021-01-2317:48thhellerthis is not part of any code shadow-cljs uses. maybe cider-nrepl?#2021-01-2409:13NerosI am trying to get a QR code scanner to work in my project, I have tried several different ways but I am still getting problems. The most basic QR code example in react I have found is the following: I am trying to get a QR code scanner to work in my project, I have tried several different ways but I am still getting problems. The most basic QR code example in react I have found is the following:
import React from 'react';
import BarcodeScannerComponent from "react-webcam-barcode-scanner";

function App() {

  const [ data, setData ] = React.useState('Not Found');

  return (
    <>
      <BarcodeScannerComponent
        width={500}
        height={500}
        onUpdate={(err, result) => {
          if (result) setData(result.text)
          else setData('Not Found')
        }}
      />
      <p>{data}</p>
    </>
  )
}

export default App;
Any suggestions would be most grateful, thanks.
#2021-01-2410:23thhellerand what CLJS did you try?#2021-01-2410:40Nerosshadow-cljs#2021-01-2410:42thhellerno the code#2021-01-2410:45thheller> I have tried several different ways#2021-01-2423:31Mr. Savyare there any tutorials anywhere online for building and deploying a shadow app as a jar? I tried just compiling it to js but I can't figure out how to get that working on a server. @neo2551 that article you linked was interesting but I couldn't figure out how to get it working with my use case.#2021-01-2503:49lsenjovYou mean constantly running it as a server? Or running it on a server to output compiled js?#2021-01-2504:14Mr. Savyi'm not sure i understand the question, but I think the second one? I'm just trying to figure out how to run my release code on a server basically, and I think i'm going to need to use depstar to do it maybe.#2021-01-2504:30aratareSo I assume you have a java server for the backend and shadow-cljs for the frontend?#2021-01-2504:30aratarein that case you can just uberjar both of them and have the server serve the frontend#2021-01-2505:23Mr. Savyserver is heroku, I think they have java buildscripts. i've been having trouble getting an uberjar set up correctly when i have tried!#2021-01-2505:43aratareI'd recommend trying to build it manually first before setting up heroku. Wrestling with building an uberjar and heroku at the same time sounds like a bad time.#2021-01-2505:44aratareat least doing so would help you pinpoint where you're having trouble with bundling an uberjar#2021-01-2600:08Mr. Savyyou're absolutely right! that's what i've been trying to do, unfortunately without much success. although, having thought about it some, I think building it isn't the issue. I can run the build after a release, but it crashes when i try to move it over to the server. so i think I need to get it onto the server in a form it recognizes, I'm going to try node and see if that gives any headway.#2021-01-2509:14thheller@ajsnow2012 there is no such thing as deploying a "shadow app as a jar". the output shadow-cljs produces is javascript which no presumption about which server you are going to use. shadow-cljs itself is never part of the server and shouldn't be. its job is just building the output and staying out of your production environment completely.#2021-01-2509:15thhellerso anything that is capable of serving static files is fine. I don't know heroku but I'd assume there is something to do that#2021-01-2509:16thhellerI personally just build stuff locally and then copy the output to a static webserver#2021-01-2509:17thhellerof course if you need anything server-side you can do that as well but shadow-cljs doesn't handle those parts. I use lein for that.#2021-01-2510:46Ian Fernandezsome of my coworkers got a delay on compiling since from saturday#2021-01-2510:47Ian Fernandezand now when he tries to open the application, it never loads, only in incognito mode#2021-01-2510:47Ian Fernandezanyone here had some issue like this?#2021-01-2510:47Ian FernandezI don't understand why he is having this issue#2021-01-2510:47thhellersounds like a cache issue? maybe a service worker?#2021-01-2510:49Ian Fernandezhe deleted npm_modules/, .shadow-cljs/#2021-01-2510:49Ian Fernandezand installed it again#2021-01-2510:49Ian Fernandezbut it not worked#2021-01-2510:50Ian Fernandezany thoughts on debugging this?#2021-01-2510:51Ian Fernandezin "normal mode" he is having a 304#2021-01-2510:51Ian Fernandezand in "incognito mode" he is having 200#2021-01-2510:51thhellersounds like a cache issue? maybe a service worker?#2021-01-2510:51Ian Fernandezhe does not have a cache in the browser#2021-01-2510:52Ian Fernandezi don't know how to debug a "service worker" sorry#2021-01-2510:52Ian Fernandez😞#2021-01-2510:52thhellerfirst confirm that non is active#2021-01-2510:52Ian Fernandezwhere?#2021-01-2510:52thhellerin chrome devtools under Application#2021-01-2510:53Ian Fernandez#2021-01-2510:53thheller304 is something the server sends so make sure you are using the correct server. it is not something the client can produce without a service worker.#2021-01-2510:53thhellermight be browser extension also#2021-01-2510:55thheller304 is fine but it does point to a cache issue#2021-01-2510:55thhellerso maybe there is some old bad html cached somehow#2021-01-2510:55thhellerI don't know what your actual issue is so I can't help much#2021-01-2510:55thheller> it never loads#2021-01-2510:55thhelleris there an error in the console?#2021-01-2510:55thhellersomething must happen#2021-01-2510:57Ian Fernandezno, only loads eternally#2021-01-2510:57Ian Fernandez😞#2021-01-2510:57Ian Fernandezstrange that is happening for him and for another coworker but not with me#2021-01-2510:58thhelleragain. did you verify you are connecting to the correct server?#2021-01-2510:58thhellershut down shadow-cljs completely and open the page again#2021-01-2510:58Ian Fernandezyeah,#2021-01-2510:59Ian Fernandezincognito goes well#2021-01-2510:59thhellerwhat server is this?#2021-01-2511:00thhellerwhich shadow-cljs version is this?#2021-01-2511:01Ian Fernandezhe cleared the browser and the cache and everything and it went well#2021-01-2511:01Ian Fernandez😞#2021-01-2511:01Ian Fernandez2.11.14 => shadow-cljs#2021-01-2511:02Ian Fernandezsorry to mess it but thanks anyway @thheller#2021-01-2511:02Ian Fernandez🙂#2021-01-2512:10simongrayHaving trouble configuring a custom dev-http host. I have been using localhost:7000 so far to access my live-reloading page. I thought I might be able to better separate my different web projects (and their differing SSL requirements) by changing the default dev-http host, so I modified my shadow-cljs.edn to read:
#2021-01-2512:10simongray
:dev-http {7000 {:root "classpath:public"
                  :host "stucco"}}
rather than
#2021-01-2512:10simongray
:dev-http {7000 "classpath:public"}
#2021-01-2512:11simongraybut nothing is available at stucco:7000 . Am I misunderstanding something here? Do I need to configure something else for this to work?#2021-01-2512:28thhellerI'm guessing your dns doesn't resolve stucco to localhost#2021-01-2512:28thhellernothing to do with shadow-cljs, it can't configure your dns#2021-01-2512:29thheller:host only does something if your machine has multiple ips so it knows which to pick but since it picks all by default that usually doesn't do anything#2021-01-2512:29thhelleron macos I believe you can add stucco 127.0.0.1 so /etc/hosts#2021-01-2512:29thhellerthen it should be find with :dev-http {7000 "classpath:public"}#2021-01-2512:29thhelleror I'm misunderstanding your problem if you already have that#2021-01-2512:31thhellerhttp://foo.lvh.me:7000/ is typically useful too#2021-01-2512:31thhellerthat domain just points all subdomains to localhost by default#2021-01-2513:01simongray@thheller Thank you. That is probably it.#2021-01-2600:10Mr. Savyyeah that's what I thought at first but after struggling for a few days I started reaching I guess. knowing it's just supposed to be js, I'm going to try targeting node next and see if that works, thank you for your input!#2021-01-2600:51kimimHello, I get this error, when use shadow-cljs in WSL ubuntu on Windows, can anyone help? thanks. shadow-cljs - config: /home/kimim/workspace/vorstellung/shadow-cljs.edn shadow-cljs - updating dependencies shadow-cljs - dependencies updated Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593). Assert failed: (sequential? root-contents)#2021-01-2601:01thheller@kimi.im my guess is that you don't have a :source-paths vector? maybe a set or map?#2021-01-2601:02thheller@ajsnow2012 you don't have to look at node either. unless you need some type of server of course. look literally for "static website"#2021-01-2601:03kimimIt is set correctly :source-paths ["src/cljs"] The same setting, works in Linux or windows environment. But WSL failed..#2021-01-2601:04thhellerI use WSL too and never had an issue#2021-01-2601:04thhellerwhat is the rest of the stacktrace?#2021-01-2601:05kimimHello @thheller, the full error looks like this: {:clojure.main/message "Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593).\nAssert failed: (sequential? root-contents)\n", :clojure.main/triage {:clojure.error/class java.lang.AssertionError, :clojure.error/line 593, :clojure.error/cause "Assert failed: (sequential? root-contents)", :clojure.error/symbol shadow.build.classpath/process-root-contents, :clojure.error/source "classpath.clj", :clojure.error/phase :execution}, :clojure.main/trace {:via [{:type java.lang.AssertionError, :message "Assert failed: (sequential? root-contents)", :at [shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593]}], :trace [[shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593] [shadow.build.classpath$process_root_contents invoke "classpath.clj" 593] [shadow.build.classpath$find_jar_resources invokeStatic "classpath.clj" 670] [shadow.build.classpath$find_jar_resources invoke "classpath.clj" 638] [shadow.build.classpath$find_resources invokeStatic "classpath.clj" 767] [shadow.build.classpath$find_resources invoke "classpath.clj" 758] [shadow.build.classpath$index_path_STAR_ invokeStatic "classpath.clj" 997] [shadow.build.classpath$index_path_STAR_ invoke "classpath.clj" 994] [clojure.lang.PersistentVector reduce "PersistentVector.java" 343] [clojure.core$reduce invokeStatic "core.clj" 6827] [clojure.core$reduce invoke "core.clj" 6810] [shadow.build.classpath$index_classpath$fn__10836$fn__10837 invoke "classpath.clj" 1130] [clojure.lang.Atom swap "Atom.java" 37] [clojure.core$swap_BANG_ invokeStatic "core.clj" 2352] [clojure.core$swap_BANG_ invoke "core.clj" 2345] [shadow.build.classpath$index_classpath$fn__10836 invoke "classpath.clj" 1130] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1129] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1126] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.cljs.devtools.server.common$fn__15586 invokeStatic "common.clj" 92] [shadow.cljs.devtools.server.common$fn__15586 invoke "common.clj" 90] [clojure.lang.AFn applyToHelper "AFn.java" 154] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.runtime.services$start_one invokeStatic "services.clj" 98] [shadow.runtime.services$start_one invoke "services.clj" 87] [shadow.runtime.services$start_many$fn__9395 invoke "services.clj" 127] [shadow.runtime.services$start_many invokeStatic "services.clj" 126] [shadow.runtime.services$start_many invoke "services.clj" 105] [shadow.runtime.services$start_all invokeStatic "services.clj" 144] [shadow.runtime.services$start_all invoke "services.clj" 139] [shadow.cljs.devtools.server$start_system invokeStatic "server.clj" 340] [shadow.cljs.devtools.server$start_system invoke "server.clj" 202] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 483] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 388] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$from_cli invokeStatic "server.clj" 615] [shadow.cljs.devtools.server$from_cli invoke "server.clj" 591] [clojure.lang.AFn applyToHelper "AFn.java" 160] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$lazy_invoke invokeStatic "cli_actual.clj" 23] [shadow.cljs.devtools.cli_actual$lazy_invoke doInvoke "cli_actual.clj" 20] [clojure.lang.RestFn invoke "RestFn.java" 460] [shadow.cljs.devtools.cli_actual$blocking_action invokeStatic "cli_actual.clj" 129] [shadow.cljs.devtools.cli_actual$blocking_action invoke "cli_actual.clj" 116] [shadow.cljs.devtools.cli_actual$main invokeStatic "cli_actual.clj" 177] [shadow.cljs.devtools.cli_actual$main doInvoke "cli_actual.clj" 132] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.core$apply invokeStatic "core.clj" 669] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$_main invokeStatic "cli_actual.clj" 219] [shadow.cljs.devtools.cli_actual$_main doInvoke "cli_actual.clj" 217] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 75] [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 67] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.main$main_opt invokeStatic "main.clj" 514] [clojure.main$main_opt invoke "main.clj" 510] [clojure.main$main invokeStatic "main.clj" 664] [clojure.main$main doInvoke "main.clj" 616] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.main main "main.java" 40]], :cause "Assert failed: (sequential? root-contents)"}}#2021-01-2601:06thhellerwhich java version?#2021-01-2601:08thhelleryeah its a bad .jar file on the classpath causing this#2021-01-2601:08thhellersomething that pretends to be a .jar but isn't#2021-01-2601:08thhellermost likely from your java dist#2021-01-2601:09kimimopenjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06) OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)#2021-01-2601:10thhelleryou can set :log {:level :debug} in your shadow-cljs.edn. that should then log which one causes the trouble#2021-01-2601:15kimimThanks. It says one deps jar is empty: [2021-01-26 09:14:44.403 - FINE] :shadow.build.classpath/bad-jar - {:file #object[http://java.io.File 0x7b8bf5c0 "/home/kimim/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar"]} ZipException zip file is empty#2021-01-2601:16thhellerjust delete it#2021-01-2601:16thhellerredownload probably fixes it#2021-01-2601:16kimimIt works now. Thanks.#2021-01-2608:40zimabluehey, I'm getting an issue using node when I try to require a cljs file which itself requires a string path javascript file, but I don't really get a stack trace, just "failed to import" and then "SHADOW ERROR" and the path#2021-01-2608:40zimabluesorry SHADOW import error#2021-01-2608:48zimablueI made progress, that file is in my output watch artifact, I manually modified it to log the error, which told me the problem was another missing module: Module not provided: shadow.js.shim.module$chai, however this module is in the root node_modules#2021-01-2609:11thheller@zimablue I don't understand what you mean by however this module is in the root node_modules. what is your build config and how are you running it?#2021-01-2610:16zimabluehi Mr Heller, the overall purpose is to try and test datascript which I am consuming through javascript, so in my actual project I use datascript though javascript which works fine but can't debug it, I was trying to jam part of my javascript project in as a datascript-repl dependency so I could use clojure debugging and understand the Clojure project, To that end I am connecting calva to a node-library build, the repl works and I can import datascript modules. I then just dumped my javascript node_modules and output lib into a subdirectory of the datascript project. It works to some extent but fails to resolve when one javascript file imports another, my build looks like this:#2021-01-2610:17zimabluebuilds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}#2021-01-2610:17zimablueand the error I get after I manually overwrite my output artifact to print the error is:#2021-01-2610:17zimablue(in node)#2021-01-2610:17zimablueshadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai#2021-01-2610:18zimablueChai being a javascript dependency of the javascript file which I am importing#2021-01-2610:18zimabluesorry, please don't waste any time on this since I am very new so it's certainly a failure of my understanding#2021-01-2610:18zimabluebut if you can immediately guess the problem that would be cool also#2021-01-2610:29thhelleryeah sorry I can't help much. it seems like you are trying to do something weird but I don't understand what#2021-01-2610:29thhellercljs-runtime/marc.js suggests you have a (ns marc) which I don't see in your config so no clue#2021-01-2610:33thheller:js-package-dirs ["vscodelib", "node_modules"] this is also suspect. why are you doing this?#2021-01-2610:34thhellerno clue how chai plays into all of this. datascript doesn't use it.#2021-01-2610:43thheller"dumped my javascript node_modules and output lib into a subdirectory" this will definitely not work and is not supposed to#2021-01-2611:30zimabluewhat is the recommended alternative approach for consuming js code? it has to be formatted as npm packages?#2021-01-2611:31thhellerit sounds to me like you want the opposite route? consume the CLJS code in a JS build? if your code is mostly JS?#2021-01-2611:32zimablueI'm doing that successfully, the reason for this reversal is for development, so that I can debug a clojurescript library using clojurescript repl/tooling#2021-01-2611:32thhellerdebug "where"?#2021-01-2611:32thhellerI mean where is the final JS running?#2021-01-2611:33thheller:node-library isn't really meant to be re-bundled. it is meant to be used in node directly. (as the name implies 🙂)#2021-01-2611:33zimabluethe final js is intended to run as you said, consuming the clojurescript, this is just intended to run in my repl/run tests so I can poke around the clojurescript dependencies#2021-01-2611:33zimablue(this alternative setup)#2021-01-2611:34zimabluesince it's hard to use javascript tools to understand what clojurescript libraries are doing with your datastructures I tried to set up a version of the reverse setup to enable me to use cljs tooling#2021-01-2611:34thhellerok. what kind of JS code do you have? plain standard ES6+ code or some kind of other dialect? JSX? etc?#2021-01-2611:35zimablueit's typescript which has been compiled to es5 modules#2021-01-2611:35zimablueI think#2021-01-2611:35thhellerok, did you follow https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-01-2611:35zimablueI'm certain that's what happens, but not sure that my description is useful#2021-01-2611:35thhellerbetter to compile to es8 or so but es5 isok#2021-01-2611:36zimabluethanks, I have looked at this document but not read every line, I will reread this section#2021-01-2611:36zimabluethank you for your help#2021-01-2611:38thhelleryou may also try :npm-module which will might work better for your use-case#2021-01-2611:38zimablueah yes I read this section, then by trial and error made it work by requiring in my cljs like this: (ns marc (:require ["/vscodelib/test/databasespec.js" :as foo])) That call works, but when databasespec.js has a further dependency (require("chai")), that's when I get the error I pasted#2021-01-2611:38zimablueI will try npm-module#2021-01-2611:38zimablueI started to read the shadow-cljs source code but it seems fairly complex#2021-01-2611:38thhellerso you have :source-paths ["src"] and src/vscodelib? the :js-package-dirs is misleading here and probably causing issue#2021-01-2611:39zimablueyes I have both of those, I think that was what worked (or at least gave me a new error message) by trial and error#2021-01-2611:39thhellerideally the code you use this way uses ESM syntax so not require("chai") but import Foo from "chai"#2021-01-2611:40zimablue(ns marc (:require ["/vscodelib/test/databasespec.js" :as foo]))#2021-01-2611:40thhellerwhat is your :source-paths?#2021-01-2611:40zimabluesorry wrong paste#2021-01-2611:41thhellervscodelib makes me suspicious. is this running as a vscode plugin of some kind?#2021-01-2611:41zimablue{ :verbose true :log {:level :debug} :source-paths [ "src" ] :dependencies [[persistent-sorted-set "0.1.2"]] :builds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}}}#2021-01-2611:41thhellerok so the above would look for src/vscodelib/test/databasespec.js#2021-01-2611:41zimablueyes which is where it is#2021-01-2611:41zimabluethat part I believe works, it's the next dependency resolution, js=>js#2021-01-2611:42thhellerso that JS file has a require("chai")?#2021-01-2611:42zimablueyes#2021-01-2611:42zimabluewhich I think is the result of a typescript compilation with target "es5"#2021-01-2611:43thhellerwell it should not have require at all. it should have import#2021-01-2611:43thhellerbut require should also work#2021-01-2611:44thhellerhow are you running any of this?#2021-01-2611:44zimablueI start shadow-cljs server, shadow-cljs watch node, npm=>import "./lib" and then finally through calva connect to the running repl#2021-01-2611:45zimabluesorry if that's a pedantic description as you can tell I'm new to this ecosystem#2021-01-2611:45thhellernpm=>import "./lib" what does that mean?#2021-01-2611:45zimabluesorry#2021-01-2611:45zimablue• "node => import lib"#2021-01-2611:45zimabluei start node in a terminal then import the output artifact#2021-01-2611:45zimabluewhich provides the runtime (?)#2021-01-2611:46thhellerplease post what exactly you are doing. you are forcing me to guess which helps noone.#2021-01-2611:46zimablueas in (calva) <=> (shadow-cljs watch) <=> (node with loaded code)#2021-01-2611:46zimablueI was trying to be precise#2021-01-2611:46thhelleryou are literally running node and then import lib? that is invalid?#2021-01-2611:46zimablueno I run node and then "require("lib")#2021-01-2611:46zimabluesorry I got the verbs confused#2021-01-2611:47thhellerplease be more precise#2021-01-2611:47thhellerrequire("lib") this would be looking for node_modules/lib? which no output is going to#2021-01-2611:47thhellerI need to understand what you are doing to provide any kind of help#2021-01-2611:47zimabluelib is where the node watch process outputs the javascript artifact#2021-01-2611:48zimabluethis line in my shadow-cljs.edn: :output-to "./lib"#2021-01-2611:48zimablueI believe configures that#2021-01-2611:48thhelleryes. but require("lib") will NOT look for that output at least not with the default node configuration#2021-01-2611:48zimablueit's require ("./lib")#2021-01-2611:48zimabluesorry#2021-01-2611:48thhellerok thanks#2021-01-2611:49thhellerok first of all why are you doing this at all?#2021-01-2611:49thhellerwhy not just shadow-cljs node-repl or that via Calva?#2021-01-2611:50thhellerbut ok, lets try to make this work#2021-01-2611:50zimablueI think I tried that and it didn't work, so I tried to run the individual commands#2021-01-2611:50thhelleryou open node. you run require("./lib"). what happens next?#2021-01-2611:50zimablueto at least vaguely understand what what happening#2021-01-2611:50zimabluethen I go to calva and do "connect to running repl", some magic happens and I can communicate with that process#2021-01-2611:51thhellerno. what happens in the node process#2021-01-2611:51thhellernot interested in calva at this time#2021-01-2611:51zimablueI get this output#2021-01-2611:51zimablue> require("./lib") { dunno: [Getter] } > shadow-cljs - #6 ready!#2021-01-2611:51thhellerok that appears to work fine then#2021-01-2611:52thhellernow please run shadow-cljs cljs-repl node#2021-01-2611:52thhellerno calva#2021-01-2611:52thhellerthen eval something like :foo just to verify the connection works#2021-01-2611:53zimabluethe shadow-cljs cljs-repl node gives "shadow-cljs: command not found"#2021-01-2611:54thhellerok if you don't have the global install run npx shadow-cljs cljs-repl node instead#2021-01-2611:54zimablueyes sorry I see I was using npx for the others#2021-01-2611:54zimablueit connects and runs simple commands#2021-01-2611:54thhellerok and what command did you run to "break" things?#2021-01-2611:55zimablue(require 'marc)#2021-01-2611:55thhellerok and that still breaks things now? trying to take calva out of the equation here#2021-01-2611:55zimablueyes#2021-01-2611:55thhellerwith what error? the above Module not provided I assume?#2021-01-2611:57zimabluesame problem: shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js now before I had gotten more information about the error by modifying the output "lib" artifact and adding a line which logs the error#2021-01-2611:57thhellerremove :exports {:dunno datascript.js/keywordize}} from your build config and instead use :exports {:dunno marc/foo}}#2021-01-2611:57zimablueand if I repeat that I get#2021-01-2611:58zimablueshadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js#2021-01-2611:58zimabluereferring to the js=> js import#2021-01-2611:58zimablueok#2021-01-2611:58thhellerneed to have an actual def in that ns though. you can use any you already have or just add (def foo 3)#2021-01-2611:59thhellerpoint is getting that ns into the initial build so we can get to the error "earlier", ie. trigger it on build or on load, not the REPL#2021-01-2612:00thhelleralso remove :js-options completely#2021-01-2612:01zimabluebefore i removed js-options, you are right this moved the error from the repl stage to the node require("./lib") stage#2021-01-2612:01zimabluesame error#2021-01-2612:01zimabluetrying without js-options#2021-01-2612:02thhellerok, I'm guessing you are running into a variant of this https://github.com/thheller/shadow-cljs/issues/832#2021-01-2612:02thhellerso, try node then global.shadow$provide = {}; then require("./lib")#2021-01-2612:02zimabluesame result without js-options#2021-01-2612:03thhelleralso I don't understand why you are not getting that error#2021-01-2612:03thhellercan you share this file src/vscodelib/test/databasespec.js?#2021-01-2612:04zimabluewithout js-options and with the suggested node argument I get the same error#2021-01-2612:06zimabluehere:#2021-01-2612:08thhellerok var datascript_1 = require("datascript"); this is a problem and probably causing all the rest#2021-01-2612:08thhellerthat will include the npm datascript package. not the one compiled by shadow-cljs you are doing all this for#2021-01-2612:09roelofany shadow-expert who can help me with this How to solve this one :
cljs꞉cljs.user꞉>  @state/orders
nil
; No available JS runtime.
clj꞉cljs.user꞉>  @state
shadow-cljs.edn
{:source-paths ["src"]

 :dependencies [[binaryage/devtools "0.9.10"]
                [proto-repl "0.3.1"]
                [reagent "0.8.0"]]

 :nrepl        {:port 3333}

 :builds
 {:app {:target :browser
        :output-dir "public/js"
        :asset-path "/js"

        :modules
        {:main
         {:entries [giggin.core]}}

        :devtools
        {:after-load  giggin.core/main
         :http-root   "public"
         :http-port   3000}}}}
#2021-01-2612:10thheller@roelof open in the browser. see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2021-01-2612:10roelofthat one is open#2021-01-2612:10thhellerwhat does the browser console say?#2021-01-2612:12zimablue@thheller, I see - I think this problem might be separate, since the chai importation is direct in this file not through datascript. What should that import look like and do you have any idea how I nudge typescript to compile it so that it requires correctly?#2021-01-2612:16thhellerwell there isn't really any way to do this#2021-01-2612:16thhellersince the datascript npm package is bundled differently and not by shadow-cljs#2021-01-2612:17thhelleryeah I really don't think the way you are trying this is going to work#2021-01-2612:19zimablueI see, thanks for all your help I learned something hopefully#2021-01-2612:19zimablueis a better approach to try and bundle the javascript into an npm package shape, whatever that is#2021-01-2612:20zimabluesince shadow-cljs knows how to consume that?#2021-01-2612:25thhellerno that won't do anything#2021-01-2612:26thhellerthe issue is getting JS->CLJS->JS->JS working#2021-01-2612:30zimabluethat's not strictly necessary, I'm only trying to test some isolated pieces, I don't need to go datascript=>js=>datascript, I just commented those parts. I also rearranged to check and all the inter-project direct imports work, it's just anything that assumes it's going to see a node_modules and does like that unqualified import like var ramda = require("ramda")#2021-01-2612:31zimablueso if I can just go datascript => js => (assumed node_modules import) I will have enough to do the poking that I was hoping for#2021-01-2612:31zimabluethanks so much, do you have any simple menial task I could do as compensation for your help?#2021-01-2612:31zimablue(help so far)#2021-01-2612:14zendevil.ethI get a warning in my react-native app: the shadow-cljs websocket was disconnected.#2021-01-2612:14zendevil.ethDo you know what’s the cause?#2021-01-2612:15thhellerno. did it ever connect successfully?#2021-01-2615:39zendevil.ethi don’t know what the websocket is#2021-01-2716:51zendevil.ethit seems like it’s connected successfully since the app correctly loads.#2021-01-2717:22thhellerno that doesn't mean anything. the websocket is injected by shadow-cljs to provide the hot-reload and REPL. it does not effect the app loading part.#2021-01-2717:22thhellerbut it may fail to connect if it picked the wrong IP or so#2021-01-2717:22thhellerbut without more info I cannot help you#2021-01-2805:58zendevil.ethI’m not exactly sure what info to provide#2021-01-2612:14roelofI see two messages
Warning: The tag <orders> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

CLJS DevTools: some custom formatters were not rendered.
#2021-01-2612:15roelofI see the posted message on repl of VS Code#2021-01-2612:20roelofI want to show the contents of this :
(ns giggin.state
  (:require [reagent.core :as r]))

(def orders (r/atom {}))
#2021-01-2612:25thheller@roelof this ; No available JS runtime. means that the browser has not connected back to shadow-cljs. that is the only issue you need to solve. the code does not matter. I cannot solve this for you without more info. the build config you provided will have generated a public/js/main.js. I assume you have a public/index.html file with a <script src="/js/main.js">?#2021-01-2612:26roelofyes#2021-01-2612:27roelofand I tried also (js/alert "test") and then I saw a popup so it seems there is a js runtime#2021-01-2612:27thhellerand you don't get a shadow-cljs ready message in the browser console?#2021-01-2612:27thhellerwait now there is a runtime?#2021-01-2612:27roelofif I do the alert there seems to be a runtime#2021-01-2612:28thhellerand what do you get via giggin.state/order?#2021-01-2612:28roelofyes, I see this message : `shadow-cljs: #7 ready!` #2021-01-2612:28thhellerok. that is your runtime#2021-01-2612:28thhellerdid you try the REPL stuff before opening the page?#2021-01-2612:29roelofthen it seems to work#2021-01-2612:29roelof`cljs꞉cljs.user꞉> giggin.state/orders #<Atom: {}>`#2021-01-2612:29roelofyep, then everything works then#2021-01-2612:30roelofthanks#2021-01-2614:19crankyadminHi, this may be a question for graal js but thought I'd give it a go. Has anyone managed to get shadow-cljs to output js that can be loaded via graal context?#2021-01-2614:19crankyadminCurrently I'm playing with :target :esm which has got me further than I have been...#2021-01-2614:30thhellerthere is an undocument :target :graaljs which sort of works for most stuff#2021-01-2614:31crankyadminCheers, I'll give that a blast and have a look at the source.#2021-01-2614:32thhellerjust :entries [whatever.ns] :output-to "foo/bar.js"#2021-01-2614:32thhellerit has no support for running graaljs context or so. that you have to do yourself.#2021-01-2614:33thhellerno REPL or hot-reload either since the default context doesn't support it. I can show some code to sort of get it but its pretty specific to how you create and use the graal context#2021-01-2614:36crankyadminIf you have some example code it would be great. I'm currently going off nothing so anything is helpful.#2021-01-2614:43thhellerwell what do you intend to do with graal?#2021-01-2614:48crankyadminUsing it for ssr a reagent app.#2021-01-2614:50crankyadminI started using shadow a couple of years back because of the great npm support but now have to get that app ssr'ing, graal because of the performance uplift.#2021-01-2614:50thhellerhttps://nextjournal.com/kommen/react-server-side-rendering-with-graalvm-for-clojure#2021-01-2614:50thhellerperformance is generally a lot worse than node#2021-01-2614:50thhellerstartup time is horrible#2021-01-2614:51thhellerand no support for async whatsoever is rather limiting#2021-01-2614:53thhellerthey have since moved to shadow-cljs and I implemented the :target :graaljs for them as well as some custom code so they get some hot-reload#2021-01-2614:57crankyadminLooks like it would be wise to go back to ol' fashioned jvm#2021-01-2619:22GGfpcHow can I start a repl that I can tap into with (shadow/repl) but without reloading the server on every change?#2021-01-2619:23GGfpcI want to write some code in the repl but don't want to lose state on every change#2021-01-2717:12Malik Kennedydef's get re-evaluated and overwritten, running shadow-cljs watch , if I have state that I don't want to get re-initialized and re at the def form, there's defonce .#2021-01-2619:24GGfpcI tried the browser repl but I can't connect via Cursive because it returns this error
(shadow/repl :app)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28).
watch for build not running
#2021-01-2619:28Robert Mitchell“watch for build not running”. Have you tried (shadow/watch :app) first?#2021-01-2619:30thheller> ... but don't want to lose state on every change#2021-01-2619:31thhellerthat is your code losing the state. you can fix that. you can also run (shadow/watch :app {:autobuild false}) so it doesn't automatically recompile if thats what you are asking#2021-01-2619:32thhelleralso just (shadow/node-repl) is usually good enough if you just want a repl#2021-01-2707:00tomrbowdenhas anyone managed to get Klipse working on Shadow-CLJS? I’m having one heck of a time trying to get it to build.
[:app] Build failure:
The required namespace "cljsjs.codemirror.addon.edit.matchbrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".
I have already added codemirror via npm install codemirror, so I’m stuck…
#2021-01-2709:16thheller@tom.bowden https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2021-01-2710:26tomrbowdenThanks for your reply @thheller. I’ve added the file src/main/cljsjs/codemirror.cljs file to my project, with this code inside:
(ns cljsjs.codemirror
  (:require ["codemirror" :as cm]))

(js/goog.exportSymbol "CodeMirror" cm)
However, I still get the build failure:
The required namespace "cljsjs.codemirror.addon.edit.matchbrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".
I must be doing something silly — I just can’t work out what it is…
#2021-01-2710:27thhellerwell you added cljsjs.codemirror not cljsjs.codemirror.addon.edit.matchbrackets#2021-01-2710:28thhellerthats a different ns and different require#2021-01-2710:28thhelleryou can look at how that cljsjs package is created to find out what require that would be#2021-01-2710:28thhellermay just be "codemirror/addon/edit/matchbrackets" but I'm not sure#2021-01-2711:18tomrbowdenSorry about this, but I am still confused. I have also added the file src/main/cljsjs/codemirror/addon/edit/matchbrackets.cljs file to my project:
(ns cljsjs.codemirror.addon.edit.matchbrackets
  (:require ["codemirror.addon.edit.matchbrackets" :as cmaem]))

(js/goog.exportSymbol "CodeMirrorAddonEditMatchbrackets" cmaem)
Now I get the build error:
[:app] Build failure:
The required JS dependency "codemirror.addon.edit.matchbrackets" is not available, it was required by "cljsjs/codemirror/addon/edit/matchbrackets.cljs".

Dependency Trace:
	clojsandbox/app/core.cljs
	klipse/run/plugin/plugin.cljs
	klipse/plugin.cljs
	klipse/klipse_editors.cljs
	klipse/ui/editors/common.cljs
	klipse/ui/editors/editor.cljs
	cljsjs/codemirror/addon/edit/matchbrackets.cljs
#2021-01-2711:28thhellerplease check what I said in my last message 😛#2021-01-2711:28thhellerthe require string does not always match the cljsjs name exaclty#2021-01-2711:28thhellerso at the very least it requires / instead of .. you can find the correct path by going into node_modules/codemirror and finding the correct folder or matching .js file for the above#2021-01-2711:29thhellerso either node_modules/codemirror/addon/edit/matchbrackets.js or node_modules/codemirror/addon/edit/matchbrackets as a folder#2021-01-2711:53tomrbowdenDoh! Silly mistake. I think I need to get some rest, thanks for your patience @thheller #2021-01-2712:06witekHello. I have included the npm module qrious into my package.json. How do I require it in my namespace and call the constructor new QRious()? -> https://www.cssscript.com/pure-javascript-qr-code-generator-qrious/ I have tried ["qrious" :as qrious] but js/QRious is not defined. qrious seams to be a function, but calling it throws Cannot read property 'bind' of undefined .#2021-01-2712:56thheller@witek in general you NEVER use js/ for anything that you imported via require in the ns. you use the :as name directly#2021-01-2712:57thhellerso probably just (qrious. ...)#2021-01-2713:13witek(qrious. ...) throws Uncaught Error: Invalid option: __reactInternalInstance$uiqex7uo9w at Nevis.extend.exists._set (qrious.js:1924). When using qrious in Vanilla JS, I have to call the QRious() constructor, which is defined globally when including the qrious.js via <script>. Don't I have to mention this QRious constructor somehow? Perhaps you have a hint for me after having a look at qrious.js: https://github.com/neocotic/qrious/blob/master/dist/qrious.js#2021-01-2714:19Michaël SalihiHi @witek, did you tried to use qrious in vanilla JS with require like const qrious = require('qrious')? It works? The doc does not mention this method.#2021-01-2714:58Michaël SalihiIf yes so as mentionned thheller, require the lib in your CLJS namespace like that:
(ns your-namepace
  (:require ["qrious" :as qrious]))
Then you could interop: (def qr (qrious. #js {:element (.getElementById js/document "qr"), :value "Custom value"})) > Don't I have to mention this QRious constructor somehow? Note the dot after QRious, this is a sugar syntax for construct new Object...equivalent to (def qr (new qrious #js {:element (.getElementById js/document "qr"), :value "Custom value"})) Refresh your page and it should works.
#2021-01-2716:17thheller@witek without a full code snippet for what you are doing we cannot help much. the constructor appears to be called properly, just with an option it didn't expect, since it seems to get to this part https://github.com/neocotic/qrious/blob/master/dist/qrious.js#L1923#2021-01-2719:11bennytrying to use rechart, but it’s failing to build with the following error. any ideas? > Closure compilation failed with 2 errors > --- node_modules/d3-array/dist/d3-array.js:271 > This code cannot be converted from ES6. extending native class: Map > --- node_modules/d3-array/dist/d3-array.js:291 > This code cannot be converted from ES6. extending native class: Set#2021-01-2719:27thheller@benny you need to up your :compiler-options {:output-feature-set :es6} if there is code that can't be transpiled#2021-01-2720:23bennythat did it! thanks @thheller#2021-01-2721:41jaimeHi all, how to do the hot-reload trick in react-native, similar to below example with react-dom...
(defn ^:dev/after-load start []
  (reagent/render [ui {:x (js/Date.now)}] dom-root)) 
Here is the entry point for react-native, it accepts a function that returns react component
(react-native/AppRegistry.registerComponent "myApp" #(reagent/reactify-component root))
EDIT: I've tried below which I've found thru googling but does not work. Though I don't really understand the theory behind to be honest 😅
(def root-version (atom 0))
(defn reloadable-root []
  @root-version
  (r/reactify-component root))

(defn start []
  (rn/AppRegistry.registerComponent "myApp" reloadable-root))

(defn ^:dev/after-load after-load []
  (js/console.log "after load...")
  (swap! root-version inc)
  (start))
#2021-01-2722:09thheller@jaime.sangcap you can use the helper I created https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L36#2021-01-2722:09thhelleror copy what that does if you want to roll your own#2021-01-2722:09thhellerI can tell that for you the issue is that your are deref'ing the @root-version outside of a scope where reagent looks for it#2021-01-2722:23jaime@thheller Awesome! ❤️ Thanks for the link. I will try that trick. Btw, IIRC you also use cursive and intellij? How do you manage to switch between repl? One thing I noticed is that for running (shadow.cljs.devtools.api/watch-compile-all!), you need to be in the CLJ repl. But for evaluating cljs, you need to be in the CLJS repl. How do you manage to compile/reload while making changes?#2021-01-2722:57thhellerI never use (shadow.cljs.devtools.api/watch-compile-all!) so I rarely have a reason to be in a CLJS repl when working on CLJS#2021-01-2807:14jaimeI'd be interested to know about your workflow when working with web apps. Would you mind sharing? 😄 Do you just enable the autobuild when watching file changes?#2021-01-2809:17thhelleryes, just the regular shadow-cljs watch app. or rather nowadays just shadow-cljs server and start the watch from the UI#2021-01-2809:17thhellerheavily using tap> with Inspect but actually very little REPL for CLJS#2021-01-2810:16jaimeThanks for sharing. Will try experiment with that workflow#2021-01-2820:59jaimeLooks like this is the tap> workflow you've mentioned? https://clojureverse.org/t/introducing-shadow-cljs-inspect/5012 Not sure what is the difference with tap> and sending forms to repl. But somehow I'm excited to acquire new super powers!! :star-struck:#2021-01-2821:05thhellertap sends it to the UI. the UI isn't otherwise integrated into the REPL for now.#2021-01-2821:05thhellerjust open the ui at http://localhost:9630/inspect-latest and tap something in the REPL#2021-01-2821:06thheller(assuming you use a somewhat recent version)#2021-01-2821:33jaimeWhen I select view as edn , it shows as the var#2021-01-2821:36jaimeI already changed my keymap from send to repl to (tap> ~selected) repl command 😉#2021-01-2722:58thhellerwhen I do some CLJ stuff I just open a second connection#2021-01-2806:43stuartrexkingI’m trying to use https://www.npmjs.com/package/@aws-sdk/client-cognito-identity-provider from a :browser target. When I require what I need like this
(ns main
  (:require
   ["@aws-sdk/client-cognito-identity-provider" :refer [CognitoIdentityProviderClient]]))
I get an error returned
#object[TypeError TypeError: $jscomp.inherits is not a function]
#2021-01-2806:44stuartrexkingThe ES6+ import example from that NPM page looks like this
import { CognitoIdentityProviderClient, AddCustomAttributesCommand } from "@aws-sdk/client-cognito-identity-provider";
#2021-01-2808:23stuartrexkingUpgrading shadow to the latest seemed to resolve the issue. Weird as a colleague on an older version didn’t experience it. #2021-01-2809:09thheller@stuartrexking that is a known issue that I have not been able to reproduce and track down unfortunately#2021-01-2809:40stuartrexkingFun. Thanks though. #2021-01-2810:41socksygoing a bit crazy with a new project and tools.deps integration. Certain I had this working before. I have a deps.edn like:
{:paths ["src"]
 :deps {}
 :aliases 
 {:dev
  {:extra-deps {thheller/shadow-cljs {:mvn/version "2.9.2"}}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}
and a shadow-cljs.edn like:
{:deps true
 :builds {:app
          {:target :node-script
           :output-to "target/main.js"
           :output-dir "target"
           :exports {:handler platform.core/handler}}}}
but when I run clj -M:dev watch app, I get
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
watch (No such file or directory)
What am I missing?
#2021-01-2810:45socksyoh fuck it was wrongly nested braces in the deps.edn. The closing brace on extra-deps line meant that :main-opts was added as an alias and so ignored. Thanks for the help 😅#2021-01-2817:44wilkerluciohello, I'm having an issue to use the shadow ns in a project here, it says the namespace isn't defined, but others like shadow.cljs.devtools.server.nrepl are there, any ideas what could be wrong?#2021-01-2817:45wilkerlucio
(shadow/nrepl-select :app)
Syntax error compiling at (REPL:1:1).
No such namespace: shadow
#2021-01-2817:48dpsuttonwhat did you require :as shadow?#2021-01-2817:48wilkerlucionothing, I never had to, in every other project when I connect to shadow it's already there#2021-01-2817:50wilkerlucioI found I can fix by running the full name (shadow.cljs.devtools.api/nrepl-select :app), but found strange why only in this project I cant use just shadow/nrepl-select :thinking_face:#2021-01-2817:52dpsuttonmust have some tooling that requires it? I think CIDER might do this to start up. not sure if you're reusing a repl from that or something?#2021-01-2817:55wilkerluciono, my setup is usually close to raw, simple deps with shadow, then I connect via nrepl to it#2021-01-2817:55wilkerluciono plugins related to repl#2021-01-2817:57wilkerlucioits funny, I have a snippet to start shadow, which spits (shadow/nrepl-select $NAME$), I've been using this snippet for many years now, in many different projects (with various different setup configurations), that's why this situation puzzles me#2021-01-2818:21thhellercheck which ns you are in. should be shadow.user, that has the shadow alias.#2021-01-2818:21thhellerbut yeah to be safe use the full name#2021-01-2821:24wilkerluciogood point, I in this case it starts in a different ns 👍#2021-01-2818:29clyfe> npm install bulma Can I make shadow serve css out of that node_module during dev watch & whatnot?#2021-01-2818:31thhellerno, css is not supported#2021-01-2818:31thhellerI mean sure you can make it serve static files just fine but it won't process css in any way#2021-01-2818:32clyfeI guess symlink in public is the way for now.#2021-01-2818:32thhellerI just copy stuff personally#2021-01-2818:40Adam HelinsShadow sometimes starts throwing when evaling cljs, forcing me to restart it. It happens after a while, somewhat randomly. I don't have any cljs/user.cljs file since I know that Shadow treats it specially. I guess this must be because something is missing in my config:
[2021-01-28 19:37:26.204 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 3, :from 10}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
        shadow.build.data/get-output! (data.clj:197)
        shadow.build.data/get-output! (data.clj:193)
        shadow.cljs.devtools.server.worker.impl/eval17184/fn--17187/fn--17190 (impl.clj:813)
        clojure.core/map/fn--5866 (core.clj:2753)
        clojure.lang.LazySeq.sval (LazySeq.java:42)
        clojure.lang.LazySeq.seq (LazySeq.java:51)
        clojure.lang.RT.seq (RT.java:535)
        clojure.core/seq--5402 (core.clj:137)
        clojure.core.protocols/seq-reduce (protocols.clj:24)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8146 (protocols.clj:75)
        clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
#2021-01-2819:07thheller@adam678 which version is this? I fixed this not too long ago#2021-01-2819:09Adam HelinsI upgraded some time ago to 2.11.4 but it didn't go away#2021-01-2819:09Adam HelinsI'll upgrade again then#2021-01-2819:10thhellerI think I fixed it in 2.11.10#2021-01-2819:10thhellerjust try 2.11.15#2021-01-2820:02clyfe
Failed to inspect file
  /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standalone-tokens.css

it was required from
  /home/clyfe/dev/riviera/node_modules/monaco-editor/esm/vs/editor/standalone/browser/standaloneEditor.js
#2021-01-2820:02clyfeIs there webpack integration? Seems I have to use this style-loader thing: https://webpack.js.org/loaders/style-loader/#2021-01-2820:15thhellerlike I said earlier. css is not supported.#2021-01-2820:26clyferoger & apologies - I was under the impression that I'm asking different things (ie. assets bundling vs this error)#2021-01-2821:11thhellerFWIW you can use webpack with shadow-cljs to handle this#2021-01-2821:11thhelleras described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-01-2821:12thhellerI think monaco still requires adding a webpack plugin though. not sure.#2021-01-2821:27Mark McQuillenHello, I would be grateful for some help deploying an app to Heroku. I built a shadow-cljs app using: https://github.com/filipesilva/create-cljs-app Worked fine locally. But then I tried deploying it to Heroku and I got this error: "Executable 'java' not found on system path." I even tried deploying the default app provided from both my computer and Cloud9 IDE and I got the same error. Any thoughts on how to get this work? Thanks!
remote: -----> Build
remote:    Running build (yarn)
remote:    yarn run v1.22.10
remote:    $ yarn clean && shadow-cljs release app
remote:    $ rimraf public/js
remote: shadow-cljs - config: /tmp/build_8c64e158/shadow-cljs.edn
remote: ===== ERROR =================
remote: Executable 'java' not found on system path.
remote: =============================
remote: error Command failed with exit code 1.
remote:    info Visit  for documentation about this command.
remote: 
remote: -----> Build failed
#2021-01-2821:28thhellersorry don't know anything about heroku but java will be required to build things
#2021-01-2821:29thhellerdunno why you have to build on heroku though. you could just build locally and deploy the static files#2021-01-2821:58Mark McQuillenWould you be willing to tell me how I can do that? I tried deleting all the clojurescript files/folders but then it broke.#2021-01-2909:45thhellerin your build config you have an :output-dir. lets assume that is public so everything in the public folder you put on heroku on a static site. you don't tell it about shadow-cljs or npm or java or any of that. you purely put STATIC files on heroku. I assume there is a way to do that but I don't know how.#2021-01-2914:07Mark McQuillenThanks I appreciate the pointers. And thanks for shadow-cljs. It's been cool using it!#2021-01-2821:31Mark McQuillenRight, I built locally. I think what you're saying is that I don't have to deploy the whole repo. Is that right?#2021-01-2822:52Mark McQuillenCan someone please recommend a service to deploy a shadow-cljs app? I tried Heroku and it didn't work. Can you tell me one that does?#2021-01-2822:59stuartrexking@markdmcq That repo you linked to outputs a static single page app. Any static hosting site should be able to host it once you have built it.#2021-01-2823:00Mark McQuillenI do build it. But then I get that java missing error. I think there's a problem with Heroku.#2021-01-2823:00stuartrexkingYou need java and npm to build that site though. You would normally do that on your machine before deploying (copying) the output files (html, js, css) to a static site somewhere.#2021-01-2823:01Mark McQuillenYes, it gives me a public folder with javascript and css. I haven't found a way to run it though.#2021-01-2823:04stuartrexkingOnce you have the static files you just need to put them somewhere that can serve them, like a webserver or CDN or a static site hosting. They won’t be run like I think you are suggesting.#2021-01-2901:54Adam HelinsIs there a more elegant way to force REcompiling all files while watching? Rather than purging the compilation cache and restarting? (Need to do some side effects via macro, hence recompiling files even if they didn't change)#2021-01-2908:19NazralI am trying to follow https://developers.google.com/web/fundamentals/primers/service-workers and service workers seem to require two .js files, is there a way for shadow-cljs to automatically build both these files while watching?#2021-01-2909:40thheller@adam678 you can use :cache-blockers or :dev/always (see docs) in combination with (shadow.cljs.devtools.api/watch-compile-all!) from the REPL#2021-01-2909:48Adam HelinsAnother simple solution I eventually found is having a macro which takes a path and recursively touches all files from there, hence triggering recompilation.#2021-01-2909:51thhellermacros are a terrible way to do this kind of stuff#2021-01-2913:13Adam HelinsYeah, I am experimenting with some esoteric stuff which compile CSS to files without needing a server (some CLJC magic). Not sure if it's really worth it, but it does the job actually...#2021-01-2909:41thhellerbut in general you should avoid side effects in macros as much as possible#2021-01-2909:41thhellermaybe :build-hooks let you do what you need in a cleaner way#2021-01-2909:42thheller@archibald.pontier_clo you can either use :modules or two separate builds and shadow-cljs watch build-a build-b#2021-01-2909:43thhellerbut in general CLJS isn't a great fit for building service workers, separate tools like https://developers.google.com/web/tools/workbox get it done much smaller and simlper#2021-01-2909:44NazralThank you#2021-01-2921:19Dan MaltbieI having been working on a Clojurescript project for some time now but this is my first serious project. I've been keeping little snippets of code for unit testing within the source files and using repl to test. I thought I would take this as an opportunity to use the shadow-cljs test capabilities (I've been using lein test for the Java version of my code for several months without issue). I got a basic framework running with a simple dummy test file which works. But when I add some of the libraries I'm using I get an error that a dependent library file is missing. I have no issues when I compile my app using these libraries but when I compile my test code it fails. I'm using shadow-cljs 2.11.14. Here's the error: `The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js". Dependency Trace: ttncore/some_test.cljs node_modules/@ndn/repo/lib/mod_node.js node_modules/@ndn/repo-api/lib/mod_node.js node_modules/@ndn/repo-api/lib/bulk-insert-initiator_node.js node_modules/@ndn/repo-api/lib/data-store_node.js node_modules/@ndn/packet/lib/mod_node.js node_modules/@ndn/packet/lib/security/signed-interest-policy_node.js node_modules/@ndn/packet/lib/interest_node.js node_modules/@ndn/packet/lib/security/helper_node.js node_modules/crypto-browserify/index.js node_modules/create-hash/browser.js node_modules/cipher-base/index.js node_modules/stream-browserify/index.js Searched for npm packages in: /media/psf/DataPartition/lastmile/ttncore/node_modules Here are the modules I have installed: (parallels) parallels (98)# npm list /cdn-cgi/l/email-protection /media/psf/DataPartition/lastmile/ttncore ├─┬ @babel//cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ @ndn//cdn-cgi/l/email-protection │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ @ndn//cdn-cgi/l/email-protection │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection deduped │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── @types//cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection deduped │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection deduped │ ├── @ndn//cdn-cgi/l/email-protection deduped │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ ├─┬ @ndn//cdn-cgi/l/email-protection │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── @ndn//cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection deduped │ ├── @ndn//cdn-cgi/l/email-protection deduped │ ├── @types//cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ └─┬ /cdn-cgi/l/email-protection │ │ └─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection.0.2 deduped │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ └─┬ /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection deduped ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection deduped │ │ └── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├── @blakeembrey//cdn-cgi/l/email-protection │ ├── @blakeembrey//cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── UNMET OPTIONAL DEPENDENCY /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ └─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ ├─┬ /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ └─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ └─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection deduped │ └─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection deduped ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── safe-buf/cdn-cgi/l/email-protection deduped │ │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ └── /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ └─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection └─┬ /cdn-cgi/l/email-protection ├─┬ @fullhuman//cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ └─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├─┬ /cdn-cgi/l/email-protection │ │ ├─┬ /cdn-cgi/l/email-protection │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ ├── /cdn-cgi/l/email-protection deduped │ │ │ └─┬ /cdn-cgi/l/email-protection │ │ │ └── /cdn-cgi/l/email-protection deduped │ │ ├── /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection deduped ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection30001171 │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection deduped ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ └─┬ /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection │ └─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ └─┬ /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├─┬ /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ ├── /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ ├── /cdn-cgi/l/email-protection │ └── /cdn-cgi/l/email-protection ├─┬ /cdn-cgi/l/email-protection │ ├── /cdn-cgi/l/email-protection deduped │ ├─┬ /cdn-cgi/l/email-protection │ │ └── /cdn-cgi/l/email-protection deduped │ └── /cdn-cgi/l/email-protection ├── /cdn-cgi/l/email-protection ├─#2021-01-2921:26thheller@dmaltbie the above error is caused by not having shadow-cljs installed in the project. hmm or not. seems to be in the list#2021-01-2921:48Dan MaltbieI don't have a choice for this library; it's one of a kind and provides key features. I've had problems with this library before, including at least two you have already helped me fix. It does some weird things in implementation but works for the most part. The method it uses to support common browser and node code is particularly problematic. When I've talked to the developer about this he says webpack works fine for him. Sigh. Is it possible for you to upgrade to the 3.x version of readable-stream and stream-browserify? Not sure if this would fix the problem but their release notes talk about changes that break with the older version and having something to do with supporting more recent browser JS engines.#2021-01-2922:03thhellerwell you could just use webpack as well#2021-01-2922:04thhellerhttps://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-01-2922:04thhellerthe node-libs-browser packages are pretty much all deprecated and shouldn't be used#2021-01-2922:22Dan MaltbieI'd rather not switch to webpack. I like shadow-cljs better. 😁 But isn't shadow-cljs using the node-libs-browser package? Or am I reading the dependency graph wrong?#2021-01-2922:39thhellerit is yeah#2021-01-2922:40thhelleryou can try installing the newer version manually#2021-01-2922:40thhellerjust add it directly to your package.json, that might work. I don't have a clue. I don't use packages that use these 😛#2021-01-3000:32Dan MaltbieWell, I don't know what it means but your suggestion to add the package worked !??!%!$! Is it just me or is Javascript packaging one of Dante's nine circles of hell?#2021-01-3000:45Dan MaltbieAs always thanks for your quick and informative response. It's truly one of the reasons I use your software!#2021-01-2921:27thhellerI would personally recommend staying away from packages that use node specific packages in a browser build#2021-01-2921:45Carlowhat's the recommended way to upgrade to a new version of shadow-cljs ? Is this documented anywhere?#2021-01-2922:02thhellereither manually edit package.json to pick the version you want and running npm install after. or npm install directly#2021-01-2922:03thhellerassuming you don't use project.clj or deps.edn#2021-01-3013:09Alexis Vincent@thheller Hi there! I’m generating a :node-library with :js-provider :shadow. And getting a bunch of The required JS dependency "stream" is not available and similar for node core libs. Whats the best way to get around this?#2021-01-3013:10Alexis VincentI want to compile in all deps but obviously not the core ones.#2021-01-3013:12thheller@mail024 set :js-options {:keep-native-requires true} in your build config#2021-01-3013:12Alexis VincentSweet! Thanks 😄#2021-01-3013:14Alexis VincentAwesome, that works!#2021-01-3020:20Adam HelinsIs there a way to disable css reloading?#2021-01-3020:23Adam HelinsOr more commonly, disable watching a folder served by the dev server?#2021-01-3020:48thhellerthere is currently no way to turn that off if you use the built-in :dev-http#2021-01-3109:02Adam HelinsAll right, I guess it must be a very unusual request anyways#2021-01-3112:24bendyHello all - I have some edn files on my classpath. What is the best way to read the data structures for a browser application with shadow-cljs?#2021-01-3112:37bendyask a question an you find the answer 😂
(-> "path/to/edn" shadow.resource/inline clojure.reader/read-string)
#2021-02-0114:45HenryIIRC, http://shadow-cljs.org used to have a homepage. It is now linked back to the GitHub repo instead, is it intentional? Also, is the latest docs still the User Guide Version 1.0 dated Jan 10, 2018? Thanks!#2021-02-0114:49thhellerI never bother to update the date on the docs. doesn't mean anything anyways. it is still current. The homepage I'll restore when I have time, not high prio right now#2021-02-0115:00HenryExcellent to know. The GitHub repo is indeed very resourceful and full of helpful information already. Many thanks for creating and maintaining such a fantastic and important tool.#2021-02-0117:38Ray StubbsHi all, I'm having some difficulty with dynamic module loading. The error returned by the loader doesn't give much info, but pasting the generated js into the console gives me the following. Anybody know how to fix this?#2021-02-0117:39Ray Stubbs@U08JKUHA9#2021-02-0118:10thhellercould be related to how you are loading the files. pasting code into the console is not something you should be doing#2021-02-0118:13Ray StubbsNot a familiar issue then huh? Yeah the pasting was a last attempt to get some useful error info (maybe it's misleading though?), the actual error returned by the loader just says... 1.#2021-02-0118:14thhellerit could be polyfill problems. try deleting .shadow-cljs/builds/<build-id>/dev and rebuild#2021-02-0118:14thhellerbut diagnosing things by loading it in the console is making things harder not easier#2021-02-0118:15thhellerthe loader you can easily skip by just making a HTML file and putting script tags after each other for all the files it is supposed to load#2021-02-0118:15thhellerin the correct order of course#2021-02-0118:15thhellerbut no need to use the loader#2021-02-0118:25Ray StubbsIt's only happening in a prod environment unfortunately, so deleting the build files probably won't help... though it may be worth looking into whether those are cleared on the server before each build. Copying into a script tag is probably worth trying too, but putting the code into the original html file won't work, since it's not a dev environment. Anyway, thanks for the help, I'll continue to play around with it.#2021-02-0122:03Ray StubbsThanks for the help @thheller, your suggestion of clearing the .shadow-cljs let me repro the issue locally, turned out to be a bug in an outdated version of shadow-cljs.#2021-02-0117:45hadilsHi. I loaded a react native npm package and its peer dependencies into my project. They are present in my package.json file and my require is correct, but
[:> ls/LoginScreen]
returns
[:> nil]
I am wondering if using Expo SDK 40 and react 17.0.0 might be causing this problem. Any thoughts?
#2021-02-0118:08thheller@hadilsabbagh18 what is ls? what is your require? read the section about :default, maybe thats it https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-02-0118:15hadils@thheller Sorry
(require '["react-native-login-screen" :as le])
#2021-02-0118:16thhellerI don't know the package but it might be :default LoginScreen#2021-02-0118:19hadilsOk let me try that.#2021-02-0118:22hadilsThat works! Thanks a lot @thheller!!!#2021-02-0209:26thheller@rameezkhan.sa saw your question on twitter. did you sort it out?#2021-02-0209:29RameezNope not yet. :)#2021-02-0209:29RameezLet me get some more details...#2021-02-0209:31RameezI'm behind a corporate HTTP proxy currently, if I specify proxy details as follows in my projects local shadow-cljs.edn it works fine:#2021-02-0209:31thhellerI assume by proxy you meant the :proxy in shadow-cljs.edn for dependency resoltiuon?#2021-02-0209:31Rameez
{:source-paths
 ["src"]

 :proxy {:host "127.0.0.1" :port 3128}
 :nrepl {:port 9000}

 :dependencies
 [[cider/cider-nrepl "0.25.8"]
  [reagent "1.0.0"]
  [re-frame "1.1.2"]]

 :builds {:app {:target     :browser
                :output-dir "public/js"
                :modules    {:main {:entries []}}
                :devtools   {:http-root "public"
                             :http-port 3000}}

          :prod {:target     :browser
                 :output-dir "public/js"
                 :modules    {:main {:entries []}}
                 :release    {:compiler-options {:optimizations :simple}}}}}
#2021-02-0209:32thhelleryeah that should be :maven {:proxy ...}#2021-02-0209:32RameezCorrect.#2021-02-0209:32Rameezah!#2021-02-0209:32Rameezcool!#2021-02-0209:32thhellerthat'll then work in the other config too#2021-02-0209:32Rameeznice! 🙂#2021-02-0209:32RameezThanks for the help!#2021-02-0209:32thhellerbtw the :prod build is an anti-pattern in shadow-cljs#2021-02-0209:33thhellerjust put the :release bit into the :app config#2021-02-0209:33thhelleroptimizations are only applied to release builds so it does not affect the watch or compile builds#2021-02-0209:34RameezAh got you! Thanks for the spot.#2021-02-0209:34RameezLearnt something new 🙂#2021-02-0209:35thhelleryeah common mistake people make that have used other tools before (or read other docs) 🙂#2021-02-0209:41RameezWould you then just do shadow-cljs release app ?#2021-02-0209:41thhelleryes#2021-02-0209:41RameezCool#2021-02-0209:47RameezThe proxy still doesn't seem to work globally set.#2021-02-0209:47RameezThis is what I have set:#2021-02-0209:47Rameez
{:mvn {:proxy {:host "127.0.0.1" :port 3128}}}
#2021-02-0209:47Rameezfile-path is: /home/rameezk/.shadow-cljs/config.edn#2021-02-0209:47thheller:maven not :mvn#2021-02-0209:47RameezThat look right?#2021-02-0209:48Rameezah cool#2021-02-0209:48RameezApologies, that works 🙂#2021-02-0216:10Aronplease give me a hint with regards to missing source maps e.g. DevTools failed to load SourceMap: Could not parse content for : Unexpected token < in JSON at position 0 the < part is because the static server returns the index.html, but the file is missing too. I am not even sure if the file should or shouldn't exist and I don't need the source maps right now at all, but I suspect I am doing something wrong again and that's why I have these warnings#2021-02-0216:15thhellermy guess is you have :asset-path "/" but the files aren't actually located there. it should match the path you use to serve the JS. so maybe /js or so#2021-02-0216:17Aronthat was it, thank you#2021-02-0216:18Aronfunny thing is, i did check the files by name before and i saw some source map files, but not exactly the one i was checking and i concluded it must be something else, not just a path issue#2021-02-0216:42hadilsHi. I am having problems with hot reload. I ran shadow-cljs watch app --verbose and found that it was using a different IP address than expo. How can I get them to be the same?#2021-02-0216:53thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native#2021-02-0217:01hadilsThank you @thheller!#2021-02-0217:10thhellerI still need a better place to configure this somehow 😛#2021-02-0223:13jaimeHi, I'm trying to run cljs-test in repl in my react-native project. But I'm getting this error when the app loads in the emulator EDIT: error has changed
[Wed Feb 03 2021 03:48:56.126]  WARN     The shadow-cljs Websocket was disconnected.
[Wed Feb 03 2021 03:48:56.127]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /10.212.134.22 (port 9630) from /10.0.2.16 (port 36722) after 10000ms"}
Now when I send forms to repl, I got this error
No available JS runtime.
See 
#2021-02-0313:52dimaI’m adding `{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "%IP-ADDRESS%"}}` to `(shadow/watch options)` to set correct IP address#2021-02-0315:43thhellerwhat the heck does this do? is this some kind of trick I don't know about? what is %IP-ADDRESS%? or do you just set the actual IP there?#2021-02-0320:56jaimeHi @U051091NM, how can I get the IP address? Is it the IP of the emulator? I don't know how to get the IP#2021-02-0409:03dima%IP-ADDRESS% is a placeholder for your machine real ip#2021-02-0409:05dima{:closure-defines {"shadow.cljs.devtools.client.env.server_host" "192.168.1.111"} for instance#2021-02-0409:05dima@thheller server_host is used here https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/cljs/devtools/client/env.cljs#L84 if not set, it uses “localhost” which doesn’t work in iOS simulator (it needs ip address to connect)#2021-02-0409:10dima@UNL0HK5ME It needs to be IP address of your host machine (where shadow-cljs is running), on mac you can get it with ipconfig getifaddr en0 where en0 is your network interface#2021-02-0409:49thheller@U051091NM well for react-native there is :local-ip "1.2.3.4" in your build config or via config merge. going through closure-defines is kinda backwards. just thought there was some magic %IP-ADDRESS% placeholder or something that metro will replace but I guess not.#2021-02-0411:08dimaThanks @thheller Nice to know there is local-ip option. At the time i was adding hack with server-port override, it wasn’t there i think.#2021-02-0411:11thhellerthat has always been there, just not documented. I don't do react-native myself so the entire section of the code and docs is lacking a lot of clarity 😞#2021-02-0516:41jaime@U051091NM thanks! I will try that one. The whole time I'm thinking shadow and emulator are running in localhost. I want to dig more into the architecture, do you have recommended resources that I can read?#2021-02-0517:34jaimeThanks! it works now by specifying the LAN IP. If I understand correctly now, my laptop running the shadow-cljs and emulator will be two device connected to the LAN. When shadow-cljs runs in localhost, the websocket client running in the emulator tries to connect to localhost which is then the emulator not my laptop? Where the solution to put the specific IP will make the websocket client point to my laptop LAN IP which is where the websocket server is running right?#2021-02-0517:38dimaYes, client running in the emulator needs IP to connect to server which is running on your laptop#2021-02-0517:45thhellertechnically it doesn't use localhost by default for react-native. it uses the IP it gets from your system. specifically this part of the code#2021-02-0517:45thhellerhttps://github.com/thheller/shadow-cljs/blob/23dcd7724681f9ba7c64530735385b06549266f6/src/main/shadow/cljs/devtools/api.clj#L588-L623#2021-02-0517:46thhellerbut if your machine has multiple IPs it sometimes picks the incorrect one. still need to tune that mechanism a little I guess.#2021-02-0517:47thhellerbut yes, your emulator has a different IP and connects over the "network" not localhost#2021-02-0518:11jaimeThanks @thheller @U051091NM for these pointers. I learned something new again#2021-02-0223:16jaime#2021-02-0300:44thheller@jaime.sangcap see the link above. seems to be picking the wrong IP too#2021-02-0320:55jaimeWhen I run react-native log-android in different terminal, it logs almost the same thing as the bundler (in again another terminal where I run react-native start) . No log about IP address. Am I missing something? How to I know what is the IP of the emulator?#2021-02-0321:22thhelleryou don't need to know the IP of the emulator. you need to know the IP of the machine shadow-cljs is running on.#2021-02-0321:23thhellerand that IP needs to be reachable by the emulator. dunno how to find that info either. I don't do react-native dev#2021-02-0321:44jaimeOh ok got it. Thank you for the info.#2021-02-0316:13alexdavishey I’m getting
[2021-02-03 16:09:28.301 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@aws-amplify/ui-components/dist/cjs/index-e94df828.js", :requires [{:line 1632, :column 73}]}
Trying to use https://www.npmjs.com/package/@aws-amplify/ui-react lib and requiring it like
(:require ["@aws-amplify/ui-react" :refer [AmplifyAuthenticator AmplifySignOut]]...
I think the problem is here but not entirely sure what I can do about it
return Promise.resolve().then(function () {
    return _interopNamespace(require(`./${bundleId}.entry.js${ ''}`)); }).then(importedModule => {...}, consoleError);
Any ideas?
#2021-02-0316:40thhellerno luck. that pattern is not supported. it is webpack specific. if you must use that lib you can follow option 2 https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-02-0316:45alexdavisMakes sense, thanks a lot! Maybe it’s not that easy but if you linked to that article or even put the error you get into the article so it comes up when someone Google’s it that might save you some time answering silly questions like this#2021-02-0316:46alexdavisBut it’s been a while since I switched to shadow and this is the first speedbump I’ve ran into which is a vast improvement on other tools so thanks in general!#2021-02-0316:47thhelleryeah it is rare but some libs expect you to use webpack and really aren't happy with anything else#2021-02-0321:35Adam HelinsIs there somewhere a rough description of how the watch algorithm decides what to recompile and what to read from the cache? At first I thought that it was systematically recompiling any child namespace (makes sense). But it isn't always true around the entry namespace of a module from what I see with --verbose and it puzzles me.#2021-02-0321:54thhellerthe namespace you changed and all namespaces that directly require it by default#2021-02-0321:54thhelleralso all namespaces with warnings since they are never cached#2021-02-0321:55thhellerand all namespaces marked with :dev/always and all namespaces blocked for caching by :cache-blockers#2021-02-0321:59Adam HelinsSo the entry namespace of my main and only module should always recompile? Because all I see is:
-> Flush: meloview/comp/root.cljs
<- Flush: meloview/comp/root.cljs (5 ms)
No Compile CLJS or Cache write for that namespace
#2021-02-0322:00Adam HelinsOh, when you say "directly", do you imply that in A requires B which requires C, A might not recompile when C changes but B always will?#2021-02-0322:10thhelleryes. the logic is that if you change C (eg. remove a def, add a def, change defn signature, etc) then B should be recompiled because it may now have warnings/errors but A cannot#2021-02-0322:18Adam HelinsGreat, that explains it all. I was under the false assumption the whole tree would recompile. Many thanks!#2021-02-0322:28thhellerno, that gets rather slow in larger projects and isn't usually required.#2021-02-0322:12witekHallo. I am looking for an idea how to get a string which is generated in the browser into a specific file in my project directory. My usecase: My code is pure cljs, not cljc. I have a kind of model driven application. So inside the browser I can collect information about it's internals and generate documentation metadata. I want this documentation data into a file, as soon as compilation completes and a callback hook in the browser is called. Since shadow-cljs which runs on the filesystem already communicates with the browser, I thougt there might by a way to do the trick. Any suggestions?#2021-02-0322:15thhellerI don't understand. you need some kind of server you POST the data to or so#2021-02-0322:16witekHaving something like (shadow-cljs.browser-tools/write-file "target/info.txt" "file content here") would be optimal.#2021-02-0322:16thhellershadow-cljs does not handle server code for you. you'll have to write that.#2021-02-0322:17witekNo, I need this thing to only work during development. When a shadow-cljs hook is called in the browser. I would like to be able to call some magic function from shadow-cljs which sends the data back to the shadow-cljs server which writes it to a file.#2021-02-0322:18thhellerI repeat. no shadow-cljs does not handle such a case for you. you do have to write it yourself.#2021-02-0322:18thhelleryou may use a custom http handler from the :dev-http server#2021-02-0322:18witekHow does a test reporting tool do this? When the tests run in the browser, how do the results get to a file on the server? Or don't they?#2021-02-0322:19thhellerthey don't. at least in shadow-cljs :browser-test#2021-02-0322:19witek@thheller thank you anyway!#2021-02-0322:19thheller@witek it may not be obvious but what you are asking is about 5 lines of code with a custom :handler. so I do not see the point in shadow-cljs providing such a thing.#2021-02-0322:20witekI have no server in my project. It's pure JavaScript for Google Firebase.#2021-02-0322:21thhellerbut you have shadow-cljs running and use :dev-http? https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2021-02-0322:22witekYou are right, thank you! I tinkered with macros for a half day. :man-facepalming:#2021-02-0322:26thheller@witek set :dev-http {3000 {:root "public" :handler my.handler/handle}} and
(ns my.handler
  (:require [shadow.http.push-state :as push-state]
            [ :as io]))

(defn handle [{:keys [uri] :as req}]
  (if (not= uri "/save-me")
    (push-state/handle req)
    (do (spit (io/file "somewhere" "foo.txt") (slurp (:body req)))
        {:status 201
         :body ""})))
#2021-02-0322:26thhellerthen from the browser side just send a post request to /save-me#2021-02-0322:26thhelleror something like that. didn't test the above but should be ok.#2021-02-0322:34Elis PopescuHi! Is there a way to add in my shadow-cljs.edn a "build step" to execute an external command every time I run the build? For example to run postcss input.css -o out/out.css`` . Ideally with a watch function, so it runs that command only when the input.css changes?#2021-02-0322:34thheller@elisescu see :build-hooks in the docs. fair warning though this is almost always a bad idea since it will slow down you CLJS recompile cycle#2021-02-0322:37Elis PopescuGot it. Any suggestion of how to do something like that better? Or I should leave it completely out of the shadowcljs build process? And thanks a lot for the very quick reply.#2021-02-0322:39thhellerI just run things like that separately. sometimes with something like https://www.npmjs.com/package/foreman or alternatives#2021-02-0322:40Elis Popescu:thumbsup:#2021-02-0322:51johannjohannhowdy all--i recently have been playing around with using shadow cljs to emit ecmascript modules (esm) for denojs--i'm not sure if this is a newish thing, but since deno defines a global window object, a particular line of code in the shadow.dom package is causing an error#2021-02-0322:53johannjohanni.e. the code defining shadow.dom/transition-supported? which looks like
shadow.dom.transition_supported_QMARK_ = (((typeof window !== 'undefined'))?goog.style.transition.isSupported():null);
so i am wondering if theres a way to prescribe to shadowcljs to not include some of these helper packages? help much appreciated!
#2021-02-0323:05thhelleryou probably forgot to configure :runtime in the build config. that defaults to browser. for :deno you'll need :runtime :custom since I have not implemented hot-reload for it at all.#2021-02-0323:06thhelleras mentioned here https://clojureverse.org/t/generating-es-modules-browser-deno/6116 only compile and release kinda work for now.#2021-02-0323:09johannjohannhuzzah! thank you friend 🙂#2021-02-0415:28hadilsOk. I am using React Native and Expo with an iOS simulator. I got the IP addresses to line up and disabled fast refresh on the simulator. When I refresh my code the simulator displays the new set up immediately, then reloads the previous state. What am I doing wrong?#2021-02-0415:29thhellerprobably still have the expo reload active#2021-02-0415:29hadilsIt says disabled on the simulator pop-up...#2021-02-0415:30thhellersorry I don't use react-native or expo and it has been a couple years since I tested this. there used to be a separate expo reload. no clue if that still exists. I cannot help you track this down but if you see two reloads then this is the most likely cause.#2021-02-0415:31hadilsOk, thanks for the lead!#2021-02-0416:44rschmuklerHey all! I recently just updated my shadow version on a project (from 2.8 to 2.11) and am now seeing a "Failed to inspect file <path>.css" - it's coming from a JS file that is built and imports a CSS file via require. I would expect this issue https://github.com/thheller/shadow-cljs/issues/598 to have solved this, but maybe I'm missing something. I also kinda remember an ignore-resources option existing once, but I'm not sure if I'm misremembering#2021-02-0416:44rschmuklerAny tips on how to best resolve this?#2021-02-0416:45rschmukler(Also, interestingly, the same application compiles fine under 2.8)#2021-02-0416:46thheller@rschmukler the default changed from ignoring asset css requires to failing them so they don't go unnoticed. you can set :js-options {:ignore-asset-requires true} to get the old behaviour#2021-02-0416:46rschmuklerWonderful, thank you for the help! Is this potentially worth documenting in the user-guide? I will add a comment to that issue as well#2021-02-0417:24isakHaving a problem with inspect - my taps are not showing up in the Inspect stream. I have devtools.preload in the :preloads. Has something changed?#2021-02-0417:52thhellerdevtools.preload? that is not from shadow-cljs or related to inspect#2021-02-0418:42isakAh, that is the console.log formatter, never mind. But yea sounds like I should be seeing taps, but I'm not seeing any.#2021-02-0418:46thhellercheck the browser console if its connected properly#2021-02-0418:52thhellerdon't know what you are doing so really can't help much. try shadow-cljs browser-repl or shadow-cljs node-repl and see if those show up#2021-02-0515:34isakI'm running tap> in my code that runs in the browser, then trying to inspect those values in #2021-02-0515:35isakI'm sure the tap>s are getting executed because I have console logging on the same code path#2021-02-0515:36isakAnd yea, it does say stuff like shadow-cljs: #21 ready! in the console also.#2021-02-0515:37isakI just tried executing tap via browser-repl, and those values do show up#2021-02-0515:39thhellerdo you maybe tap> too early? like on page load?#2021-02-0516:09isakhmm yea it is pretty quick, I'll try delaying it#2021-02-0516:09thhellerthe tap> is only setup after the ready message so if you log before that it won't make it to the UI#2021-02-0516:10isakyea, that was it#2021-02-0516:11isakCan my program listen for the ready message?#2021-02-0516:14thhellerno, not currently#2021-02-0516:17isakWould you accept a PR to have the shadow tap listener queue messages until the page is ready, then flush?#2021-02-0516:19thhellerif you do it in a clean way. the way this is currently set up this isn't easily possible.#2021-02-0516:19isakOk, I may give this a shot. Thanks for the help!#2021-02-0417:53thhellerdoesn't require any config actually, it is on by default with watch builds#2021-02-0418:17Adam HelinsI am watching my source files using Hawk. Ordinarily, when I hit save, I get 1 :modify event as expected. However, when running Shadow in watch mode, saving a single file results suddenly in all that io:
:hawk :create #object[java.io.File 0x18f77246 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913]
:hawk :modify #object[java.io.File 0x52954b80 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913]
:hawk :delete #object[java.io.File 0x58038f69 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/4913]
:hawk :delete #object[java.io.File 0x7f50d4a /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc]
:hawk :create #object[java.io.File 0x43e0fe21 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc~]
:hawk :create #object[java.io.File 0x393148d /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc]
:hawk :modify #object[java.io.File 0x3fffaee3 /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc]
:hawk :delete #object[java.io.File 0x4b70ec0a /home/adam/projects/clj/helins/medium/src/dev/helins/medium/dev.cljc~]
Is that normal?
#2021-02-0418:21thhellershadow is just watching. it never modifies your source files ever, it only reads. the events happening are done by you#2021-02-0418:22thhellerlikely your editor#2021-02-0418:24Adam HelinsHmmm, weird, I get that behavior only when Shadow is running (same editor and all...)#2021-02-0418:24Adam HelinsBut yeah, I was surprised at the idea it might modify anything in the source#2021-02-0419:22dpsuttoni'm attempting to startup up a :deps true style project with CIDER. I'm getting the dreaded "missing instance". I remember reading in the users guide (although i can no longer find it) that if i made sure ensure that shadow's middleware was included all would be good. I'm attempting:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/piggieback {:mvn/version "0.5.2"} cider/cider-nrepl {:mvn/version "0.25.8"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[\"cider.nrepl/cider-middleware\",\"shadow.cljs.devtools.server.nrepl/middleware\",\"cider.piggieback/wrap-cljs-repl\"]"]}}}' -M:test:cider/nrepl
and then
(do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
after startup and i'm still getting the missing intance message. Is there something i'm skipping over?
#2021-02-0420:58thhellerhopefully that makes it clearer in the future https://github.com/thheller/shadow-cljs/commit/c7c831e19851ff4ef1fa4967abb60b469fc76b98#2021-02-0420:59dpsuttonlovely#2021-02-0419:23dpsuttonpiggieback is not necessary but cider still sticks it in when doing clojurescript#2021-02-0419:28dpsuttonah i'm sorry. I've found (and documented before) that i need to call (shadow.cljs.devtools.server/start!)#2021-02-0420:29thheller@dpsutton yeah missing instance always means that shadow-cljs has not been started in the JVM you are connected to. which won't happen if you just start an nrepl server like the command above.#2021-02-0420:34dpsuttonthe strange thing is i had npx shadow-cljs server which includes :nrepl {:port 8701}. My understanding is that it would have been the server#2021-02-0420:42thhelleryes, that is the server but you don't seem to be connected to it#2021-02-0420:42thhellerthe above commands starts its own nrepl server in a new JVM which cider then probably connects to#2021-02-0420:43thhellerif you want to do it absolutely correctly and the way it is intended then DO NOT configure a fixed :nrepl port and instead look up the port in .shadow-cljs/nrepl.port#2021-02-0420:43thhelleror rather teach cider how to do that 😛#2021-02-0420:44thhellerstill no clue how cider works or does#2021-02-0420:51dpsuttonhaha. i know more about it than only 2 or 3 people and i'm still working it out 🙂 Trying to figure out how to setup for local dev#2021-02-0420:56LukasHello, I use emacs/cider and have a clojurescript project build with shadow cljs. I connected to the nrepl server, but I'm not able to send s-expressions to the repl with C-c C-e like I normally do. Can someone here me with this?#2021-02-0420:57dpsuttonwanna chat in #cider for the time being? Most likely an issue with setup and not actually shadow#2021-02-0420:58LukasOkay, I already raised the question in #cider 🙂#2021-02-0420:58Lukasshould I delete this thread?#2021-02-0420:59dpsuttonnah. its a single comment and if anyone has a similar issue maybe they'll be directed to #cider#2021-02-0423:08Nolanhi there—think im running into a user error here when trying to override config from the repl. ive been trying to walk this path:
(shadow/compile
 :build1
 {:config-merge
  {:closure-defines '{ true}}})
and i must be getting something slightly off because it gives the error that the structures can't be merged. the exception makes it look like the structure is a seq of map entries rather than a map potentially? sincere apologies if ive missed something in the manual that addresses this use-case
#2021-02-0423:10Nolani actually think the solution im aiming for will eliminate the need to do this, but in general this seemed like something someone might want to do#2021-02-0500:10Nolanah, impeccable what a few minute break and a glass of water will do. this works as expected:
(shadow/compile
 :build1
 {:config-merge
  [{:closure-defines '{ true}}]})
which makes sense in hindsight. apologies for the noise!
#2021-02-0515:34isakI'm running tap> in my code that runs in the browser, then trying to inspect those values in #2021-02-0504:36Stevy BHi all ! Beginner here. I am trying to compile my app with
shadow-cljs watch dev-ui
But I am getting this error :
shadow-cljs - config: .../shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.4 running at 
shadow-cljs - nREPL server started on port 54872
shadow-cljs - watching build :dev-ui
[:dev-ui] Configuring build.
[:dev-ui] Compiling ...
[:dev-ui] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
I have installed react with
npm install react react-dom create-react-class 
but the issue is still there. Let me know if I am doing everything right ? Thanks for the help.
#2021-02-0509:41thhellerdid you install it in the correct directory? there should be a <project>/node_modules/react directory. if you don't have a package.json in your project dir it might install somewhere else.#2021-02-0509:45Stevy BI didnt install npm in the right folder that was the issue#2021-02-0509:45Stevy Bnow all good thanks !#2021-02-0508:22Peter Muysmoment-mini#2021-02-0508:23Peter MuysHello, I have a problem when doint a release with shadow-cljs, I get the following error: [:app] Compiling ... [2021-02-05 09:20:43.012 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} Closure compilation failed with 1 errors --- externs.shadow.js:13 Parse error. 'identifier' expected#2021-02-0508:24Peter MuysThe js-invalid-requires also comes up when watching (shadow-cljs watch app), but everything seems to work fine#2021-02-0509:44thheller@peter085 don't know that package. it might try to do a dynamic import() which is not supported#2021-02-0510:56Peter MuysWhen looking at the moment.min.js file ate columnn 4095 i see a function with 'return"string"==typeof e?W[e]||W[e.toLowerCase()]:void 0'#2021-02-0510:57Peter MuysWhen i look at externs.shadow.js:13 i see ShadowJS.prototype.;#2021-02-0510:59Peter Muysthe package moment-mini is a dependency of (I think) mermaid npm module.#2021-02-0511:00thhellerhmm odd. seems like shadow-cljs collected some kind of empty externs property. no clue how.#2021-02-0511:01Peter MuysThe description of moment-mini: This package exposes https://github.com/moment/moment/blob/develop/min/moment.min.js as an npm module so you can import/require the minified version of moment into your projects without the bloat of the locales. This package will follow the https://github.com/moment/moment/releases.#2021-02-0511:02Peter MuysHow could I solve this problem? It stops me from deploying my app.#2021-02-0514:54thheller@peter085 I don't know. I tried the moment-mini and mermaid packages and they compile fine. something must confuse the externs generator but I don't know how or what.#2021-02-0514:57Peter MuysOk, thanks for looking. BTW I otherwise love shadow-cljs (never had a problem like this before)#2021-02-0514:59thhellerit is a very odd issue. can you check if the line ShadowJS.prototype.; is actually ShadowJS.prototype.; and not maybe some unicode char or so behind inbetween the .;?#2021-02-0515:00thhellerits not supposed to generate empty externs and I don't know how it would#2021-02-0515:37Peter Muys@thheller This is a copy with lines before and after, it doesn't show any other chars. / @const {ShadowJS} */ var location; / @const {ShadowJS} */ var module$node_modules$codemirror$lib$codemirror; ShadowJS.prototype.; ShadowJS.prototype.$; ShadowJS.prototype.$$typeof;#2021-02-0515:38thhellerhmm yeah would be interested to find out how it gets to generate an empty externs entry#2021-02-0515:40Peter MuysDo you need any other info, like package.json or something else?#2021-02-0515:40thhellertrying to think of a good way to debug this#2021-02-0515:44thheller@peter085 can you create an empty CLJ ns like (ns debug) and put this in it
(defn find-it
  {:shadow.build/stage :flush}
  [{:keys [output] :as build-state}]
  
  (->> output
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))
  
  build-state)
#2021-02-0515:44thhellerthen in your build-config set :build-hooks [(debug/find-it)]#2021-02-0515:44thhellerthat should then at least tell us which of the files is causing the empty externs#2021-02-0515:44Peter Muysok,let my try#2021-02-0515:44thhelleroh wait it doesn't get to flush, use this instead
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (->> (vals output)
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))

  build-state)
#2021-02-0515:46thhelleryou can define it entirely in the REPL too#2021-02-0515:46thhellerdoesn't need to be in a file just shadow-cljs clj-repl is fine#2021-02-0515:49thhelleroh wait. its missing a (vals)#2021-02-0515:49thheller(vals output)#2021-02-0515:49thhellerforgot its a map 😉#2021-02-0515:50Peter MuysI got the following: shadow-cljs - starting via "clojure" WARNING: When invoking clojure.main, use -M enabling instrumentation [:app] Compiling ... [2021-02-05 16:48:35.711 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} () Closure compilation failed with 1 errors --- externs.shadow.js:13 Parse error. 'identifier' expected The only difference is the () in de output, 'enabling instrumentations' is something from my code#2021-02-0515:51Peter Muysoeps, missed some messages#2021-02-0515:51thhellerupdated the code snippet#2021-02-0515:52thhelleryeah the () would be the empty sequence from the prn if it didn't find what it was looking for#2021-02-0515:53Peter MuysSame output with vals#2021-02-0515:55thhellermaybe try
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (doseq [{:keys [resource-id properties]} (vals output)
          prop properties
          :when (< (count prop) 2)]
    (prn [:prop resource-id prop]))

  build-state)
#2021-02-0515:56thhellerthat should at least log something. maybe too much though#2021-02-0515:57Peter Muysgot#2021-02-0515:58thhellercan ignore anything thats not empty, just need to find the one that "looks" empty#2021-02-0515:59Peter Muys
[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-force/dist/d3-force.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "R"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "C"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "P"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "U"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-voronoi/dist/d3-voronoi.js"] "N"]
[:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-shape/dist/d3-shape.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/shapes.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "q"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/perl/perl.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/coordinate-system.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/lib/codemirror.js"] "y"]
#2021-02-0515:59thhelleryeah those are all fine#2021-02-0515:59Peter Muys
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-polygon.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-contour/dist/d3-contour.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-path/dist/d3-path.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/d3-geo/dist/d3-geo.js"] "o"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/graph.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/rgb.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-ellipse.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/normalize.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-rect.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/hsla.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-dispatch/dist/d3-dispatch.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "$"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "o"]
[:prop [:shadow.build.npm/resource "node_modules/mermaid/dist/mermaid.core.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/create-edge-paths.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/grayscale.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-drag/dist/d3-drag.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/rgba.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Q"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "q"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "p"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "M"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "S"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "Z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "H"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "V"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "U"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "X"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "u"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "W"]
[:prop [:shadow.build.npm/resource "node_modules/d3-time-format/dist/d3-time-format.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/util.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-interpolate/dist/d3-interpolate.js"] "c"]
#2021-02-0515:59thhellerdon't need those#2021-02-0515:59Peter Muys
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "n"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-brush/dist/d3-brush.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/barycenter.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "k"]
[:prop [:shadow.build.npm/resource "node_modules/d3-zoom/dist/d3-zoom.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/index.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/elm/elm.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/graphlib/lib/json.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre-d3/lib/intersect/intersect-line.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/greedy-fas.js"] "v"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/channels/reusable.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/position/index.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "e"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/layout.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "d"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "w"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "L"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "M"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/moment-mini/moment.min.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hsl.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/codemirror/mode/haskell/haskell.js"] "f"]
[:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-quadtree/dist/d3-quadtree.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-selection/dist/d3-selection.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/color/hex.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/dagre/lib/order/resolve-conflicts.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/methods/invert.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "z"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "x"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "t"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "i"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "y"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "A"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "m"]
[:prop [:shadow.build.npm/resource "node_modules/d3-hierarchy/dist/d3-hierarchy.js"] "c"]
[:prop [:shadow.build.npm/resource "node_modules/d3-chord/dist/d3-chord.js"] "_"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/khroma/dist/utils/channel.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "s"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "a"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "b"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "r"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "g"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "l"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "h"]
[:prop [:shadow.build.npm/resource "node_modules/d3-color/dist/d3-color.js"] "c"]
#2021-02-0516:00Peter Muysnothing empty#2021-02-0516:00thhelleryeah those are all fine#2021-02-0516:05thhellermaybe
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [build-state]

  (prn (shadow.build.closure/extern-props-from-cljs build-state))

  build-state)
#2021-02-0516:06thhellerif that contains "" then it is somehow coming from CLJS not JS#2021-02-0516:20Peter Muys
[2021-02-05 17:19:55.794 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]}
#{"" "_run" "NaN" "flush-after-render" "getMode" "unbounded-unshift" "_peek-at" "_update-watching" "fromCharCode" "onChange" "_queued-run" "add-after-render" "flush-render" "_set-opts" "_peek" "isScrolling" "floorEntry" "autoLoadMode" "ceilingEntry" "createElement" "Fragment" "PersistentVector" "copyState" "POSITIVE_INFINITY" "findModeByName" "Children.toArray" "queue-render" "schedule" "startState" "_set-state" "hasNext" "findDOMNode" "flush-queues" "_handle-change" "getLength" "PersistentArrayMap" "Doc" "render" "_try-capture" "flush-before-flush" "cljsIsDirty" "unmountComponentAtNode" "NEGATIVE_INFINITY" "Component" "add-before-flush" "run-queues" "core" "equiv"}
Closure compilation failed with 1 errors
--- externs.shadow.js:13
Parse error. 'identifier' expected
#2021-02-0516:20Peter MuysYEP#2021-02-0516:20thhellerah ok, let me get the function to find it#2021-02-0516:22thheller
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [{:keys [ns file] :as src}
          :let [{:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])] 
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))
  
  build-state)
#2021-02-0516:22thhellerthis should do it#2021-02-0516:24thhelleroh oops delete something#2021-02-0516:24Peter Muyssomething wrong in find-it
[2021-02-05 17:23:40.074 - WARNING] :shadow.build/hook-config-ex - {:hook-idx 0, :hook-sym debug/find-it, :build-id :app}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error macroexpanding doseq at (debug.clj:15:13). #:clojure.error{:phase :macro-syntax-check, :line 15, :column 13, :source "debug.clj", :symbol doseq}
#2021-02-0516:25thheller
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))

  build-state)
#2021-02-0516:25dpsuttonshould state and build-state be the same var?#2021-02-0516:26thhelleroh indeed#2021-02-0516:26thheller
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))

  state)
#2021-02-0516:28Peter MuysGot [:found glas-editor.plugin-paste #{""}]#2021-02-0516:28Peter MuysLooks like my code#2021-02-0516:31thhellerwould be curious to see what that does and how ends up adding an empty property#2021-02-0516:31Peter MuysThis is the function
(defn plugin-paste []
			{}
			{:on-cm-init (fn [editor config state]
											 (cm/on-paste editor (fn [editor event]
																							 (on-paste-event editor event))))})
#2021-02-0516:32thhellerits the entire ns, not the function#2021-02-0516:32thhellernone of the would generate any externs#2021-02-0516:32Peter Muys
if i change it to 
(defn plugin-paste []
			{})
#2021-02-0516:33Peter Muysi still get the error#2021-02-0516:33thhellerthis is the ns glas-editor.plugin-paste#2021-02-0516:33thhellerwhatever else is in that file matters
#2021-02-0516:36Peter Muys
I removed the require for the  plugin name space, now i get
[:app] Compiling ... [2021-02-05 17:35:32.949 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/moment-mini/moment.min.js", :requires [{:line 1, :column 4095}]} ------ WARNING #1 - ----------------------------------------------------------- Resource: node_modules/codemirror/lib/codemirror.js:2 constant module$node_modules$codemirror$lib$codemirror assigned a value more than once. Original definition at externs.shadow.js:11 --------------------------------------------------------------------------------
#2021-02-0516:38Peter Muys
externs.shadow.js:
/** @const {ShadowJS} */ var location;
/** @const {ShadowJS} */ var module$node_modules$codemirror$lib$codemirror;   <-- ln 11
ShadowJS.prototype.$;
ShadowJS.prototype.$$typeof;
#2021-02-0516:38thhellerthats just a warning, you can ignore that#2021-02-0516:39thhellerdunno how that happens either but for now it doesn't matter#2021-02-0516:40Peter MuysIt did generate a main.js#2021-02-0516:41Peter MuysOk, I will try removing code bit by bit in glas-editor and let you know what i found. Ok for you?#2021-02-0516:41thhellersure#2021-02-0516:56Peter Muys
Found the following code that generates the error:

(ns glas-editor.plugin-paste  
  (:require 
  ...
  \["turndown" :as td\]  
 \["turndown-plugin-gfm" :as tdgfm\]  
 ))
 
 (def td-service (td/. (bean/->js {"headingStyle" "atx"  
 "codeBlockStyle" "fenced"})))

td/. is the cause.
#2021-02-0517:04thhellerhow does that even work? thats not a valid JS function name?#2021-02-0517:23thheller@peter085 is that supposed to be (td. ...) without the /?#2021-02-0517:25Peter Muysindeed#2021-02-0517:26Peter MuysDoesn't explain the moment-mini error, but does explain the externs problem i think#2021-02-0517:33thhellerthis is not an error. it is a warning.#2021-02-0517:34thhellerjust search for require in the code. anything that is not just a plain require call with a string argument is "invalid"#2021-02-0520:44jaimeHi, I'm trying to run-tests using @testing-library/react-native npm module. But I'm getting this error
undefined is not an object (evaluating 'shadow.js.shim.module$$testing_library$react_native.render')
Here is my test file (I think I'm importing it correct, see the js example https://callstack.github.io/react-native-testing-library/docs/getting-started/#example)
(ns limeray.component-test
  (:require [clojure.test :refer [deftest run-tests run-all-tests]]
            ["@testing-library/react-native" :refer [render]]
            [reagent.core :as r]
            [limeray.component :as ui]))

(def jaime (render (r/as-element [ui/button {:title "My Title"}])))

(deftest render-button-with-title
  (as-> (render (r/as-element [ui/button {:title "My Title"}])) $view
    (.getByText $view "My Title")))

(run-tests)
Is this something related to externs?
#2021-02-0521:00thhellerno. there just doesn't seem to be a render function. looks correct otherwise but I don't know the setup. is this running in node or how does it work?#2021-02-0521:05jaime:thinking_face: I'm running shadow-cljs watch app , then using cursive I connected to the repl, then switched to cljs by calling (shadow.cljs.devtools.api/repl :app) The connected client is an android emulator. What I'm doing is to send the run-tests in repl.#2021-02-0521:07thhelleryeah that doesn't work. you cannot add requires dynamically in a react-native env. so if you regular app doesn't have this require then adding it via the REPL won't work#2021-02-0521:11thhellerbut I really don't know anything about how react-native testing works or what kind of setup it requires#2021-02-0521:13jaimeOh ok. Maybe I can try testing it in node-repl and see if it will work. Looking at the library, it is just a wrapper for react-test-renderer which I think deals only with js objects (vdom)#2021-02-0521:14thhellerthat won't work if your code requires react-native anywhere. since that package needs to be built by metro#2021-02-0521:17jaimeI see. looks like I have to do some research how testing works in react-native. Thanks a lot for clarifying. Btw, out of curiosity, you cannot add requires dynamically in a react-native env. In the context of browser env, what does it mean by requiring dynamically? Maybe this will help me understand why its not possible in react-native#2021-02-0521:18jaimeOr I would say, what is happening when doing require dynamically.#2021-02-0521:19thhellerdynamically as in anything done in the REPL and not at build-time#2021-02-0521:20thhellershadow-cljs just generates some JS for your build but does not provide any JS dependencies#2021-02-0521:20thhellermetro will then process that generated JS and actually fill in those dependencies such as react-native itself#2021-02-0521:21thhellerthis output you then load and all requires that were provided are available#2021-02-0521:21thhellerhowever if you now connect the REPL metro is out of the equation and as such cannot provide JS dependencies anymore#2021-02-0521:27jaimeDoes that mean if I require lets say the @testing-library/react-native in my production code. Metro will be able to provide it as deps? EDIT: I've just tried it, looks like lib is now being loaded#2021-02-0521:37thhelleryes, if you get it into the build somehow it'll be available#2021-02-0521:41jaimeCool. I think I can do this a temp fix for now. Thanks a lot. appreciate your help and explaining in detail 😄#2021-02-0605:51Peter Muys@thheller Thank you for your help yesterday!#2021-02-0610:53Karol WójcikHow to set polyfills for ResizeObserver in shadow-cljs? Or maybe in general how do you include polyfills?#2021-02-0610:57thhellernot sure there are any for ResizeObserver in closure. you can always use https://polyfill.io/v3/ separately#2021-02-0614:41Adam HelinsLooking at the doc I don't think so, but is it possible to add metadata to a namespace to prevent caching? :cache-blockers works but it's not very user-friendly when it comes to libraries#2021-02-0614:59thhellerwhy would you want that? there is ^:dev/always#2021-02-0618:55Adam Helins@thheller Once again I was in a bit of an odd situation... I am messing a lot with doing side effects at compilation these days. Being able to force compilation from metadata might be a useful feature given how Shadow-CLJS is widely used. You wouldn't have to add defaults in :cache-blockers but then it's true that side-effecting on compilation is definitely not a widespread habit#2021-02-0619:22thhellerits also a bad idea. if you share what you are working on I can maybe make some suggestions.#2021-02-0619:45Adam HelinsIt's a somewhat novel CSS compiler that does many things. Essentially, this bit is about Garden rules declared in CLJC files being recompiled from Clojure (JVM) everytime a file is saved, which also triggers CLJS recompilation and does some syncing between those 2 environments. It works really well actually but there are a few problems that are tough to solve in order to provide a seamless experience. Slowly getting there 🙂 I'll let you know when I release an alpha version#2021-02-0619:46Adam HelinsBut those problems are very specific and definitely not the kind of day to day work a Clojurist does, that's why I have been asking weird questions around a few channels lately :p#2021-02-0620:07West@adam678 Yo, I’m really interested in this CSS compiler. What are some other things it can do?#2021-02-0620:23Adam Helins@c.westrom It leverages Garden but provides a whole dev experience as well as aggressive optimizations for production. In dev mode, it is about providing structure, documentation, and efficient live reloading. All names such as CSS classes are defined in an Clojure idiomatic way as Vars. Easy to consume, can hold docstrings, and even more importantly, this prevents any name collision. Any sets of CSS rules you write can be documented as well and when you hit save, are written to files in a two level directory tree mimicking your code (namespace > sym). Everything is always clear in code and you can always see the exact CSS it produces. Only rules that change are recompiled and live reloaded which doesn't put a burden on your dev environment. (The "recompile everything" at save is horrible for any real-world project). In release mode, it provides dead code elimination of CSS by detecting CSS names that survived advanced compilation and analyzing your rules. Then it will actually optimize everything and rewrite your classes! This is extra nice because you don't have to worry about efficiency. When I write rules for a class, everything is flat. I merge maps, don't care at all about CSS inheritance or whatever. It looks like common Clojure. It's the compiler's job to then detect common rules amongst classes, split and merge them as needed, create atomic rules and all those CSS buzzwords. That's it in a gist 🙂#2021-02-0620:29Adam HelinsAnd there is actually plenty more, it can lint your rules at dev time (eg. warn you if there is a typo in a property), warn you if your code uses CSS names which do not show up in your rules, and so one...#2021-02-0620:30WestSee the reason I asked is I’m working on something myself. I’m trying to use a java-based css parser to convert a CSS file and create garden syntax from it. The experience of trying to integrate npm, shadow-cljs, and all these crazy build steps just to use tailwind, has been pretty crusty.#2021-02-0620:34Adam HelinsA parser that supports all CSS is probably not that easy. The end goal is to not need frameworks like Tailwind or Tachyons. Anyway, as soon as you need something they don't provide, you are on your own... I don't believe they are that good of a solution#2021-02-0620:40WestTrue. Tailwind was nice to start though. I really enjoyed putting a class in my HTML and immediately seeing a change. Even better that I can take a reagent component and all my styles stay with it. I would love to implement something like this using hiccup syntax, maybe leverage https://github.com/Jarzka/stylefy. How would you recommend handling CSS using nothing but hiccups?#2021-02-0620:40thhellerI wrote https://github.com/thheller/shadow/wiki/shadow.markup a long time ago. sounds somewhat similar.#2021-02-0620:52Adam HelinsWhat I dislike about those solutions is that they are dynamic for things that should be static. It's another way of putting strain on JS. Everything is "blazing fast" in isolation but put together... That's why the web is slow 😛#2021-02-0620:52Adam HelinsI have exactly 0 runtime cost here and it's highly optimized... which I like!#2021-02-0621:00thhellerit isn't dynamic.#2021-02-0621:01thhellerbut the thing I never bothered to write but all of this supports is extracting the css in a separate compile phase#2021-02-0621:02thhelleranyways .. I'm not using it anymore either so wouldn't recommend anyone else to do it either.#2021-02-0621:42West@adam678 I wanna build static sites using ClojureScript, mostly because I could imagine templating would be easier using functions. I wanna have a multilingual site, also have dark mode/light mode as an option. Either way, can’t wait to see you release this.#2021-02-0714:44Luis SantosHi everyone, Whats the recommended way to use static assets installed via npm? Let's say that I want to install bootstrap or tailwindcss using CSS and I want the assets to be available int he public folder and later in the dist folder. What are the best practices?#2021-02-0714:44Luis SantosThanks#2021-02-0715:31thhellerI just use tailwind with postcss as described in the tailwind docs#2021-02-0715:54aratareHi there. I'm combing through the doc and there doesn't seem to be any way to tell shadow-clj which lein profile to use dynamically instead of having it hardcoded inside shadow-cljs.edn? The reason for this is I have multiple lein profiles, each of which corresponding to different environment like dev, test, prod, etc. and I'd like shadow-clj to be able to do the same. Would appreciate any insight. Thanks in advance 🙂#2021-02-0716:46thhellershadow-cljs does not support this and it usually isn't required for CLJS. at least I haven't heard a convincing argument for it yet 😉#2021-02-0716:46thhelleryou can just use lein if you really must#2021-02-0716:46thhellerinstead of shadow-cljs release app you do lein with-profiles +whatever run -m shadow.cljs.devtools.cli release app#2021-02-0718:00aratareThanks a lot 🙂 I'm not sure if it's technically hard to do but having separate lein config inside each build would be nice for something like this I imagine.#2021-02-0720:54thhellerthe way things currently work this is not possible and I have no interest in changing it. if you must do this you can just use lein as described.#2021-02-0720:20cobyI'm having an adventure failing to understand how to connect my editor (Neovim/Conjure) to a REPL for a :target :node-script build. So first I'm doing shadow-cljs start && shadow-cljs clj-repl app and then running (shadow/watch :app) and (shadow/repl :app) from there, per https://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage. The prompt then changes to cljs.user=> and when I evaluate forms directly from there it complains "No application has connected..." which is to be expected I think since I haven't actually started a Node process. So far so good I guess. However, at this point when I do :ConjureConnect 7001 from my editor and try to evaluate forms, it is connecting to a plain Clojure REPL and doesn't consider JS forms e.g. (js/console.log ...) valid. I think this is because the (shadow/... :app) forms only transform that one client connection into a CLJS REPL; the nREPL server itself is still in Clojure "mode"...but how do I get the server itself to compile CLJS forms?#2021-02-0720:49thheller@ctamayo first of all are you sure shadow-cljs node-repl isn't enough for your use case? second if you connect to the nrepl that connection starts out in CLJ mode. so you switch it via (shadow/repl :app)#2021-02-0720:49thhellerthe server is always in CLJ mode and that cannot be changed. you just switch your connection when needed.#2021-02-0720:58cobyWhen I do shadow-cljs node-repl it starts up the server on 7001 but when I do :ConjureConnect 7001 it complains:
[2021-02-07 12:53:39.022 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns }
FileNotFoundException Could not locate media_server/app__init.class, media_server/app.clj or media_server/app.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
My main file is src/media_server/app.cljs and when I change it to .clj it complains that the ns form does not conform to spec because I'm trying to require the "fs" node module.
#2021-02-0721:00thhellersorry I can't answer conjure questions. I have never used it and have no idea what it does.#2021-02-0721:02cobyIt's a REPL client for Neovim, no worries :thumbsup::skin-tone-3:#2021-02-0721:03thhellerI know what it is. I just don't know what it does on connect and stuff#2021-02-0721:01thhellerlooks like its trying to change the CLJ connection to that ns. that will not work, it needs to be switched to CLJS first#2021-02-0721:02thhellerthink of shadow-cljs as a CLJ server only. it then takes commands to build CLJS. you cannot eval CLJS without giving those commands first#2021-02-0721:04thhellerfor the node-repl you can just run shadow-cljs server .. connect to nrepl and then run (shadow/node-repl)#2021-02-0721:04cobyYeah, I immediately remembered I hadn't done that, sorry. Here's what happens when I do though.
$ shadow-cljs node-repl
shadow-cljs - config: /home/tamayo/projects/media-player/server/shadow-cljs.edn
shadow-cljs - server version: 2.9.6 running at 
shadow-cljs - nREPL server started on port 7001
cljs.user=> (shadow/watch :app) ;; <----------- TRYING TO SWITCH MODES HERE ----------<<<<<
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: :1:2
 No such namespace: shadow, could not locate shadow.cljs, shadow.cljc, or JavaScript source providing "shadow"
--------------------------------------------------------------------------------
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: :1:2
 Use of undeclared Var shadow/watch
--------------------------------------------------------------------------------
TypeError: shadow.watch is not a function
    at cljsEval (<eval>:1:16)
    at global.SHADOW_NODE_EVAL ([stdin]:105:10)
    at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:24:1)
    at ret (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:49:13)
    at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:120:11)
    at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:47:1)
    at shadow$cljs$devtools$client$node$process_message (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/node.cljs:106:5)
    at /home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:242:9
    at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:194:7)
    at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/home/tamayo/projects/media-player/server/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow/cljs/devtools/client/env.cljs:248:7)
cljs.user=>
#2021-02-0721:04thhelleror shadow-cljs server ... connect nrepl then (shadow/watch :app) and (shadow/repl :app)#2021-02-0721:05thhellerif you run shadow-cljs node-repl in the command line that will drop you directly into CLJS mode as indicated by cljs.user=> prompt#2021-02-0721:05thhellerbut ONLY that command. not the nrepl server#2021-02-0721:05cobyonly that command meaning only that connection/client?#2021-02-0721:06thhellerlisten. kill all processes. run shadow-cljs server.#2021-02-0721:06thhellerthat starts a blank server that just does nothing except wait for further commands#2021-02-0721:06thhellerTHEN connect nrepl or run other commands in a separate terminal#2021-02-0721:07thhelleryou can use the shadow-cljs commands or you can run all those directly over nrepl#2021-02-0721:07thhellerjust don't confuse the two and their purpose#2021-02-0721:11thhellersorry for making this more confusing by bringing up node-repl. that is just a simplified node repl that is already ready to go with its own node process but not coupled to any build#2021-02-0721:11thhellervs :node-script where you have to manage the node process yourself#2021-02-0721:16coby> not coupled to any build I see, that is the piece I was missing. I understand the piece about server vs the various REPL commands...I tried various ways but still can't get my editor REPL to play nice with CLJS. So I need to just figure out what the issue is on the Conjure side. Sorry if it seemed like I wasn't listening, I was just trying to validate my understanding.#2021-02-0721:17thhellerso you get an error if you run shadow-cljs server and then connect conjure? without doing anything else?#2021-02-0721:18thhellerthat shouldn't happen but if it does its on the conjure side of things#2021-02-0721:18thhellerunless you maybe configure :nrepl {:init-ns ...} in your shadow-cljs.edn config?#2021-02-0721:19cobyAh, I did do that, now I understand why it wouldn't like that...#2021-02-0721:20cobyand yes, it errors at that point w/o anything else#2021-02-0721:20thhellerright yeah. that would switch the CLJ nrepl to that ns but since its a CLJS ns that doesn't work#2021-02-0721:21thhelleryou switch the default ns for you build via :devtools {:repl-init-ns foo.bar} in your build config instead#2021-02-0721:21cobygotcha, that makes sense#2021-02-0723:00genekimI’m using shadow-cljs on an M1 MacBook Pro for a couple of week. (PS: it’s amazing. IntelliJ/Cursive, shadow-cljs watch, kaocha watch, Fulcro RAD app running in browser. Laptop stays cool, totally silent, and runs for hours with only 20-30% battery consumed. So different than my Intel MBP, which would last for no more than 45m!) But I have noticed something strange, and don’t know how to best document this strange behavior. When using an ARM JVM (either IntelliJ JBR or Azul JVM), it seems to take much longer to detect file changes. This affects the shadow-cljs builds, and kaocha watch tests. When a save a file, it may take between 3 seconds and maybe even up to 10+ seconds for the file change to trigger a compile or test run. Has anyone else run into this problem? Is there a simple test case or scenario I can use to isolate what is causing the delay? (I haven’t tried using an x86 JVM yet. I’m sufficiently afraid I’ll permanently break my dev setup by doing that… Unwarranted I’m sure, but… 🙂#2021-02-0723:09thheller@genekim I assume this is on Big Sur so try the latest version. I removed the old hawk file watching lib which seemed to cause trouble on Big Sur#2021-02-0723:09thheller2.11.17#2021-02-0723:09genekimIncredible, @thheller. Thank you!! Always blown away by shadow-cljs , and how it makes the build system just fade into the background, in the best possible way! 🎉🎉🎉 So wonderful!#2021-02-0723:10thhellerdon't know anything about how it affects M1 though. only had reports from older hardware but all related to big sur so maybe the same on M1#2021-02-0723:11genekimWill try this right now!#2021-02-0723:12thhelleryou can also set :fs-watch {:hawk false} in shadow-cljs.edn top level on older versions, basically the same effect#2021-02-0723:22genekimConfirmed that file watcher issue seems to have disappeared. Thanks, @thheller!!#2021-02-0805:31Sean PoulterThomas. Your docs are amazing. Thank you! It has helped me make sense of ClojureScript macros. 🙂#2021-02-0805:36Sean PoulterIs it possible to write a macro that uses an npm package as a dependency? I’ve run into Gotcha #1: Namespace Aliases and Dependencies from https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html. My goal was to write a quick utility for faking timers in tests with @sinonjs/fake-timers but it seems like that’s not possible with deps from npm. :/ my.util.clj
(ns test.fixtures)

(defmacro with-fake-timers
  [symbol & body]
  `(let [~symbol (fake-timers/install)]
    (try 
my.util.cljs
(ns test.fixtures
  (:require
   ["@sinonjs/fake-timers" :as fake-timers])
  (:require-macros
   [test.fixtures :refer [with-fake-timers]]))
my.util-test.cljs
(ns test.fixtures-test
  (:require
    [cljs.test :refer [deftest testing is]]
    [test.fixtures :refer [with-fake-timers]]))

(deftest macro-test
  (is (= '_ (macroexpand-1 '(with-fake-timers clock (prn "Hello, world"))))))

(deftest with-fake-timers-test
  (testing "Given a symbol to bind to and a body to execute, "
           "it should replace the global timer APIs and execute the body"
    (let [previous-value js/window.setTimeout]
      (with-fake-timers clock
        (let [actual (= js/window.setTimeout previous-value)
              expected false]
          (is (= actual expected)))))))
#2021-02-0805:51Sean PoulterCould this be related to it being a :karma build target? The macro expands as expected but uses the missing ns alias, then throws: > Chrome Headless 88.0.4324.150 (Mac OS 10.14.6) test.fixtures-test with-fake-timers-test FAILED > FAIL in (with-fake-timers-test) (ReferenceError:NaN:NaN) > failed with ReferenceError: fake_timers is not defined > message: Uncaught exception, not in assertion. > #2021-02-0805:52Sean PoulterI’m guessing I should stop fighting and give up on the macro. 😕#2021-02-0806:56johnjelinekhihi, I'm trying to use shadow-cljs where I need to consume some javascript generated by the typescript compiler. I've tried different ways to transpile and I just don't seem to be getting it right. If I transpile in ES2015+, shadow-cljs complains about references to import * as cdktf from 'cdktf';. If I transpile to CommonJS, it complains as well:
; Execution error (ReferenceError) at (<cljs repl>:1).
module$docker$index is not defined
#2021-02-0806:57johnjelinek
> tree ./.gen/providers-out/
./.gen/providers-out/
└── docker
    ├── config.d.ts
    ├── config.js
    ├── container.d.ts
    ├── container.js
    ├── data-docker-network.d.ts
    ├── data-docker-network.js
    ├── data-docker-registry-image.d.ts
    ├── data-docker-registry-image.js
    ├── docker-provider.d.ts
    ├── docker-provider.js
    ├── image.d.ts
    ├── image.js
    ├── index.d.ts
    ├── index.js
    ├── network.d.ts
    ├── network.js
    ├── secret.d.ts
    ├── secret.js
    ├── service.d.ts
    ├── service.js
    ├── volume.d.ts
    └── volume.js

1 directory, 22 files
#2021-02-0806:59johnjelinekall the exports are within index.js and the modules it refers to call out to cdktf (expected from node_modules)#2021-02-0806:59johnjelinekany help would be much appreciated 🙂#2021-02-0807:05johnjelinekfor CommonJS:
> (require '["/docker"])
FileNotFoundException: ~/hello-world/.gen/providers-out/docker (Is a directory)

> (require '["/docker/index" :as docker])
nil

> docker

Execution error (ReferenceError) at (<cljs repl>:1).
module$docker$index is not defined
nil
#2021-02-0807:14johnjelinekfor ES2015:
ExceptionInfo closure errors {:tag :shadow.build.closure/errors, :errors [{:resource-name "docker/config.js", :source-name "docker/config.js", :line 3, :column 0, :msg "Namespace imports (goog:some.Namespace) cannot use import * as. Did you mean to import cdktf from 'goog:shadow.js.shim.module$cdktf';?"}]
#2021-02-0807:19johnjelinekand here's how the module looks like in the node REPL after transpiling to CommonJS:
> var docker = require('./.gen/providers-out/docker')
undefined
> docker
{
  Config: [Getter],
  ContainerNetworkData: [Getter],
  Container: [Getter],
  Image: [Getter],
  Network: [Getter],
  Secret: [Getter],
  Service: [Getter],
  Volume: [Getter],
  DataDockerNetworkIpamConfig: [Getter],
  DataDockerNetwork: [Getter],
  DataDockerRegistryImage: [Getter],
  DockerProvider: [Getter]
}
#2021-02-0809:24thhellerwith which shadow-cljs version did you try? I fixed a bug related to this very recently. try 2.11.17#2021-02-0813:26johnjelinek
"shadow-cljs": "^2.11.17",
#2021-02-0818:52johnjelinek@U05224H0W: looks like the same version ☝️#2021-02-0818:58thhelleron problem is that for all npm dependencies the closure compiler will see them as commonjs#2021-02-0818:58thhellerthus import * as cdktf from 'cdktf'; is invalid and would need to be import cdktf from 'cdktf';. which the warning is telling you basically#2021-02-0819:18johnjelinek@U05224H0W: ok, so that's something I'd need to manually change after the transpiler completes if I want to target ES2015? But if it's CommonJS as the target and I'm getting module$docker$index is not define -- what should I do in that case?#2021-02-0819:22johnjelinekregarding ES2015 output and your suggestion about manual change, magic!
> docker
#js {:Config #object[Config$$module$docker$config], :Container #object[Container$$module$docker$container], :ContainerNetworkData #object[ContainerNetworkData$$module$docker$container], :DataDockerNetwork #object[DataDockerNetwork$$module$docker$data_docker_network], :DataDockerNetworkIpamConfig #object[DataDockerNetworkIpamConfig$$module$docker$data_docker_network], :DataDockerRegistryImage #object[DataDockerRegistryImage$$module$docker$data_docker_registry_image], :DockerProvider #object[DockerProvider$$module$docker$docker_provider], :Image #object[Image$$module$docker$image], :Network #object[Network$$module$docker$network], :Secret #object[Secret$$module$docker$secret], :Service #object[Service$$module$docker$service], :Volume #object[Volume$$module$docker$volume]}

> Container
#object[Container$$module$docker$container]
#2021-02-0819:22thhellerI don't know. can you try with a browser-repl or an actual build?#2021-02-0819:23johnjelinekI didn't make any changes to the references or to the shadow-cljs.edn after transpiling to ES2015 and changing the import statement for every single generated .js file#2021-02-0819:24johnjelineknote, my current ns where it's working with ES2015 now:
(ns demo.script
  (:require ["constructs" :refer (Construct)]
            ["cdktf" :refer (App TerraformStack)]
            ["/docker/index" :as docker :refer (Container)]))
#2021-02-0819:25johnjelinekwhat should I look for in a browser-repl for this?#2021-02-0819:26johnjelinekhere's my shadow-cljs.edn:
{:source-paths ["src/main" ".gen/providers-out"]
 :builds {:app {:target :node-script
                :output-to "target/script.js"
                :main demo.script/main}}}
#2021-02-0819:26thhellerbrowser-repl for the cases where you get module$docker$index is not defined now#2021-02-0819:27thhellerif things even run in the browser. seems to be a node target so that may not be an option.#2021-02-0819:35johnjelinekya, it's definitely a node target#2021-02-0819:39johnjelinekI'll go with the ES2015 module output for now, thanks! I'm not sure how I would've troubleshooted this without you.#2021-02-0809:23thheller@sean.poulter the easiest path is just creating a function in CLJS that delegates to the npm dep (defn install-timer [] (fake-timers/install)) and call that from the macro instead.#2021-02-0812:38Sean PoulterThanks for keeping it simple. 🙂#2021-02-0814:01Sean PoulterThat works perfectly. 🙏#2021-02-0814:02Sean PoulterDo you have a preference for Patreon or PayPal?#2021-02-0814:08thhellerall fine 🙂#2021-02-0814:04Adam HelinsWouldn't it be useful to also take into account file deletions when it comes to live reloading? (Eg. UI reflects that a CSS file has been deleted (browser will reload non-existing file))#2021-02-0814:06thhellerhow would it reload a non-existing file? doesn't make much sense to me#2021-02-0814:25Adam HelinsDo what it does for modifications (ie. modify the r query argument -> browser tries to reload file and fails)#2021-02-0814:46thhelleryes but why would you willingly force a 404?#2021-02-0815:06Adam HelinsFor instance in the context of live reloading CSS, it's a bit confusing that nothing changes when a CSS file gets deleted (because the browser knows nothing about that)#2021-02-0815:08thhelleryeah still no clue what you are doing but so far I'm not interested in adding that#2021-02-0815:13Adam HelinsHaha, all right, it's just I would expect that deleting any live-reloaded asset that is still being used by my code would induce a change to help me notice it, but all right#2021-02-0816:50thhelleryeah I can only imagine getting into weird situations. the only sensible things to do would be deleting the link tag used to import the style as thats the only way to remove the css#2021-02-0816:51thhellerbut then when you add it again the HTML doesn'lt have the link anymore so it won't be loaded#2021-02-0816:51thhellerin general you should only have one css file anyways. at least thats what I have always done. take the many files and generate one that is loaded in the html#2021-02-0912:12dazldhey there - I'm trying to understand what's happening with *print-fn* such that if I print something from a function in the browser, I'll see that output in my repl. I can see that *print-fn* appears to be bound to the same thing (?) in both the client and the repl, but the behaviour diverges.#2021-02-0912:13dazldrepl-print-fn it seems.. although I guess that's just the var#2021-02-0912:13dazldI couldn't see anything in the docs about repl output too#2021-02-0912:14dazldif I (prn :foo) from a connected repl, I see the output in the repl and the browser console, but if I do the same thing from a function (eg reagent component), then i only see it in the console.#2021-02-0913:38thhelleractually this is more or less a problem with nrepl and the nrepl clients#2021-02-0913:38thhellerif you use the plain shadow-cljs cljs-repl app then those prints should be captured#2021-02-0913:38thhellerit is just an artifact of most nrepl clients not accepting output that is not tied to a specific evaluation#2021-02-0913:39thhellershadow-cljs does capture the prints, it just has nowhere to send them in case of nrepl#2021-02-0916:05dazldthanks @U05224H0W#2021-02-0916:05dazldand yep, i'm using an nrepl#2021-02-0916:07dazldsome kind of plumbing for a connected build would be pretty neat, getting prints back from the client#2021-02-0913:26thhellershadow-cljs does not capture arbitrary prints outside the nREPL evaluation. pretty sure no CLJS REPL does#2021-02-0913:36roman01laHello 👋 Is it expected that release build won't write into location specified in {:release {:output-to "..."}}?#2021-02-0913:39thhellerdepends. which :target are you talking about? :output-to for example is not an option for :browser#2021-02-0913:39roman01la:target :browser#2021-02-0913:39thhellerthat should be :output-dir then#2021-02-0913:50roman01laah, so there's no way to specify output-dir per module?#2021-02-0913:51thhellerno, it is by design that all :modules should live in the same directory. otherwise complicates things with loader and source maps and so on#2021-02-0913:53roman01lagot it :thumbsup: what about compiler namespaces, are they written into :output-dir as well when running release?#2021-02-0913:54thhellerno, in case you mean the cljs-runtime dir you otherwise get with watch or compile output#2021-02-0913:56roman01laperfect! thanks 🙏#2021-02-0914:06roman01labtw, are there any docs on how shadow bundles NPM deps? is it using own bundler? does it split npm deps together with cljs splits?#2021-02-0914:07thhelleryes, yes, yes#2021-02-0914:08thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html has some background info on how things work#2021-02-0914:09thhellersome other posts also talk about it#2021-02-0914:12roman01lathanks! I have some more questions if you don't mind: what about DCE? does it exist, is it on par or better than webpack? what happens with NPM deps when compiling with advanced optimizations?#2021-02-0914:13thhellerfor npm dependencies it does not exist no, they only go through :simple#2021-02-0914:15thhellerI might add it at some point but currently everything is pretty webpack specific so even other JS bundlers struggle with it#2021-02-0914:20roman01laI see. So how's JS deps are included into cljs splits then? Does shadow splits NPM deps into modules based on requrie's from cljs code and then prepends JS splits to CLJS ones?#2021-02-0914:20thhellerbasically yes#2021-02-0914:20thhellerbut its file based not module based, so even if they are in the same package they might end up in different modules depends on how you use them#2021-02-0914:23thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2021-02-0914:25roman01lacool! thanks :thumbsup:#2021-02-0915:12johnjelinekdoes anyone know of a reference architecture/starter kit for clojurescript that has typescript interop? Would this be interesting to anyone?#2021-02-0920:28roman01laI got to code splitting and hitting an issue now: goog is not defined#2021-02-0920:28roman01lathe setup is simple: there's module A and module B that depends on A, when A is loading the exception is thrown#2021-02-0920:29roman01lashould mention it happens in release build with advanced optimizations#2021-02-0920:30roman01lathe line where it fails is goog=goog||{} which I guess comes from goog's base.js#2021-02-0920:33thhellerhmm? advanced shouldn't contain this?#2021-02-0920:35roman01lahmm, good point, might be something coming from a library, let me see, thanks#2021-02-0920:40roman01lahere's code block around that line compiled with :pseudo-names true
$APP.$JSCompiler_stubMap$$ = [];
    goog = goog || {};
    $goog$global$$ = this || self;
    $goog$NONCE_PATTERN_$$ = /^[\w+/_-]+[=]{0,2}$/;
    $goog$cspNonce_$$ = null;
    $goog$UID_PROPERTY_$$ = "closure_uid_" + (1E9 * Math.random() >>> 0);
    $goog$uidCounter_$$ = 0;
    $APP.$goog$now$$ = Date.now || function() {
        return +new Date
    }
    ;
    $goog$evalWorksForGlobals_$$ = null;
    $APP.$goog$inherits$$($goog$debug$Error$$, Error);
#2021-02-0920:40roman01lais that something that shouldn't be there after advanced?#2021-02-0920:42thhellernot a clue where this is from. it shouldn't be there.#2021-02-0920:43thhellerwhich versions do you use? make sure it all matches properly. using mismatched closure compiler, CLJS or shadow-cljs versions causes all sorts of weird issues#2021-02-0920:44roman01lashadow 2.10.21 cljs 1.10.773#2021-02-0920:46thhellerin a regular build it should be something like var da=da||{} or pseudo-named var $goog$$ = $goog$$ || {}#2021-02-0920:46roman01lahuh, actually I'm building using shadow from NPM of one version and requiring shadow's loader, which is coming from shadow of another version declared in deps.edn, should fix that as well#2021-02-0920:47thhelleryeah those should be somewhat close but only the deps.edn version is really relevant#2021-02-0920:47thhellernpm stuff only affects the shadow-cljs command line tools, nothing from the compilation#2021-02-1002:06bringeHello. I'm trying to require js in the same project, compiled from typescript, following this guide: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js, but I can't seem to get it to work. I have a state.ts file that's compiled to out/state.js - I added out to the shadow-cljs source-paths, since I read that js requires are read from the classpath, then I tried to require it in the ns form like (:require ["out/state" :as state] ... but it just appears to be an empty object :thinking_face:. This js file has exports and is used elsewhere in typescript files in the project.#2021-02-1002:08bringeIt does build though via shadow and I don't get any errors - if I rename state in the path to something like statee that doesn't exist I see this error printed: JS reload failed Error: Cannot find module 'out/statee' so it appears that it at least sees the module state since I don't get an error with that.#2021-02-1002:15bringeOk now seeing the error: Cannot find module 'out/state' so maybe it's not found. Hoping/guessing I'm just missing some small detail about this process.#2021-02-1005:13johnjelinek
> node ./main.js
file:///home/john/cdktfclj/main.js:5
var SHADOW_IMPORT_PATH = __dirname + '/.shadow-cljs/builds/cdktf/dev/out/cljs-runtime';
                         ^

ReferenceError: __dirname is not defined
    at file:///home/john/cdktfclj/main.js:5:26
    at file:///home/john/cdktfclj/main.js:1789:3
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
I'm getting this error with the code that comes out of shadow-cljs compile app
#2021-02-1005:16johnjelineklooks to be related to "type": "module", inside my package.json#2021-02-1005:36johnjelinekhmm ... it looks kinda like shadow-cljs is maybe outputting AMD instead of CommonJS -- is this configurable?#2021-02-1008:59thhellerAMD/CommonJS is pretty much the same so that doesn't matter#2021-02-1008:59thhellerand no this is not configurable. there is an experimental :target :esm but you shouldn't use this when building for node currently#2021-02-1015:06johnjelinekI didn't think CommonJS did an IIFE like AMD did#2021-02-1015:11thhellerit doesn't have to but it makes no difference. it is not the cause of your issue and would not affect anything. __dirname not being present is purely an effect of node loading the file as a ESM module#2021-02-1015:16johnjelinekyou're right -- the __dirname problem went away when I removed the --experimental flag to node#2021-02-1015:16johnjelinek"type": "module" is the same as --experimental#2021-02-1015:19thhellerwhy do you have that in the first place?#2021-02-1016:23johnjelinekbecause I need to interop with typescript and when I generate it as CommonJS instead of ES2015 then I get the error at the top of the other thread: module$docker$index is not defined#2021-02-1016:59thhellerif you make a reproducible example I can take a look but so far I'm just guessing#2021-02-1020:43johnjelineksure, I can do that#2021-02-1008:57thheller@brandon.ringe I tried to explain this in the guide but I will try again. the PATH you require MUST be on the classpath and MUST be an actual path. ["out/state" ...] will look for node_modules/out since it doesn't start with / or ./. so instead use ["/state.js" :as state]. the classpath will then be searched in order and if you have out on the classpath it'll eventually find <project>/out/state.js#2021-02-1018:38bringeThanks for explaining more. I've managed to get to a new error with that. I have out on the classpath (have verified with shadow-cljs classpath), and state.js exists in out, along with other js files and directories containing js files. When I try to require the file with ["/state.js" :as state] I get the following error:
[:calva-lib] Build failure:
FileNotFoundException: /home/brandon/development/calva/out/doc-mirror (Is a directory)
        java.io.FileInputStream.open0 (FileInputStream.java:-2)
        java.io.FileInputStream.open (FileInputStream.java:195)
        java.io.FileInputStream.<init> (FileInputStream.java:138)
        shadow.build.data/sha1-file (data.clj:341)
        ...
#2021-02-1018:39bringeIt's true that doc-mirror is a directory, but I don't see how that is relevant / why it matters :thinking_face:#2021-02-1018:46bringeThat directory does contain an index.js file (along with others), but it's the first one to contain one, alphabetically. Not sure if that has anything to do with the error.#2021-02-1022:21thhellerthen use /doc-mirror/index.js. it doesn't do any of the npm nonsense of guessing which file you mean. just refer to the file by name.#2021-02-1022:40bringeSorry if I wasn't clear. I don't want to import that file. I want to import /state.js which is in the out directory. out is on the classpath, the file is in out and I import it at "/state.js" :as state . So I'm referring to it by name and starting with / so it doesn't check node_modules. When I try to do that, I get that error about that unrelated directory.#2021-02-1022:42bringeI can make an issue with a repro case if you think that would help.#2021-02-1100:46bringeI'm still digging into it a bit: https://github.com/thheller/shadow-cljs/issues/841#2021-02-1012:02aratareHi there @thheller. Sorry for pinging you directly but I feel this is something only you can fix. So I'm working on a fulcro project with Elastic UI and stumbled across this error Uncaught (in promise) Module not provided: ./assets/plus.js when trying to use a React component from the UI library. But this component works perfectly find in a normal JS library, in fact I was testing around with CodePen and there's nothing wrong with it. So I suspect it has something to do with shadow-cljs. I've created a GH issue with more details here: https://github.com/thheller/shadow-cljs/issues/840. Thanks in advance 🙂#2021-02-1012:40thhelleranswered on github#2021-02-1013:19Alexis Vincent@thheller Are the goog.provide lines generated by shadow or by cljs compiler?#2021-02-1013:29Alexis VincentAnd is there a reason that it’s important that throw new Error('Namespace "' + name + '" already declared.'); be thrown from within goog.provide declaration? I’m trying to get webpack to happily hot reload cljs generated with :npm-module#2021-02-1014:53thheller@mail024 why do you want to let webpack do that instead of shadow-cljs?#2021-02-1014:54Alexis VincentI’m experimenting with cljs/nextjs interop#2021-02-1014:54Alexis VincentSo I want the repl connection, but to leave everything else up to the rest of the toolchain.#2021-02-1014:55Alexis Vincentmodule loading; optimisation; HMR; etc#2021-02-1014:56thhellerbeen a while since I looked at webpack HMR but it used to have issues with reloading cljs code#2021-02-1014:56thhellerthe exception you can get rid of by deplacing goog.provide with goog.constructNamespace_ as done here https://github.com/thheller/shadow-cljs/blob/f28003cbb062fd27685048e8b4793eb05ca8f829/src/main/shadow/cljs/devtools/client/env.cljs#L145#2021-02-1014:57thhellerif you are experimenting with interop stuff you should really use :target :esm instead#2021-02-1014:57Alexis Vincentthanks! I actually just made a patch goog that does just that. Yours is simpler though#2021-02-1014:57thheller:npm-module has all sorts of little quirks that'll really get in your way#2021-02-1014:57Alexis Vincentok thanks. I’ll check that out#2021-02-1014:59Alexis VincentBeen running through the clojurescript codebase to try get a better idea of how everything works. My experience with cljs thus far has largely been via shadow-cljs so I’m not that familiar with standard cljs emmission.#2021-02-1015:04thhellerhttps://clojureverse.org/t/clojurescript-compiler-internals-with-mike-fikes/7141 might help#2021-02-1015:19Alexis VincentThanks!#2021-02-1015:24thhellerI guess you saw https://github.com/thheller/next-cljs ?#2021-02-1015:25Alexis Vincentyeah, I worked through that a few months back. Ultimately I decided to write something native clojurescript. But I’m experimenting again with interop. Want to try see if I can get a clean interop story with native js tooling#2021-02-1015:27Alexis VincentDo you know if the emmitter is the only place that cares about google closure? Does it feed in higher up?#2021-02-1015:28thhellerwhat do you mean by "cares about google closure"?#2021-02-1015:30Alexis VincentIf I were to swap out the cljs emmitter and replace it with something that doesn’t output in a google closure friendly way, how much would I need to change up in the analyser say#2021-02-1015:31thhellerabout everything#2021-02-1015:31Alexis Vincentgot you#2021-02-1015:32thhellerI have been thinking about writing a cljs compiler variant that emits pure modern ESM code with no traces of closure#2021-02-1015:32thhellerbecause I think this really cannot be retrofitted into the current compiler#2021-02-1015:32thhellerbut yeah its a massive amount of work#2021-02-1015:33Alexis VincentWould love to talk to you about this. It’s something I want to see and would be prepared to support. financially or otherwise#2021-02-1015:33thhellerit might be possible but I'm already working around too many issues with shadow-cljs that this is not an avenue I wanted to pursue#2021-02-1015:34thhellerits mostly a time issue for me. the final "gain" is questionable since things like the REPL and hot-reload will get much harder#2021-02-1015:35thhellerthe only downside of the current way really is that JS tools don't like it but otherwise its pretty nice#2021-02-1015:35thhellerI mean you can always do the hacks that :target :esm or :npm-module do and that works ok enough for a bit#2021-02-1015:35thhellerbut to do it cleanly things need to be really different#2021-02-1015:36Alexis VincentI think the downside of JS not liking it actually is everything for me#2021-02-1015:36Alexis VincentI’ll DM you#2021-02-1015:36thhelleryeah getting smoother JS interop would be useful for a lot of tools#2021-02-1109:29roman01laIs it expected that shadow won't infer an extern and won't produce a warning? I'm seeing a renamed JS property slipped into release build#2021-02-1110:00thheller@roman01la you need to be a bit more specific. it entirely depends on the code whether externs are generated or not.#2021-02-1110:02roman01laI see, here's more context code
(defn get-x []
  ^js/LibraryX @lib-x)

(let [x (get-x)]
  (.methodA x)
  (.methodB x))
manual externs
LibraryX.prototype.methodA = function() {}
#2021-02-1110:03roman01lafor the above setup methodB gets renamed in release build and there's no compiler warning emitted#2021-02-1110:04thheller
(defn get-x ^js []
  @lib-x)
#2021-02-1110:04roman01lanow when I remove manual externs and hint those values with ^js inference seems to work fine in release#2021-02-1110:05thhellerbut you should be getting warnings in this case. or automatic externs inference#2021-02-1110:05roman01launfortunately I didn't get any#2021-02-1110:05zendevil.ethI’m running a watch like so:
shadow-cljs watch app
But in the browser app, I’m getting two errors:
Connection closed
and
Stale client
How to fix this error? There are warnings but no errors in the shadow command line
#2021-02-1110:05roman01lawhy does ^js work but more specific ^js/Lib doesn't?#2021-02-1110:06zendevil.ethNow I’m only getting Connection closed#2021-02-1110:06thheller@roman01la both are the same as far as shadow-cljs is concerned. I'm just not sure that the typehint directly on the defer properly propagates to the function return value.#2021-02-1110:07thheller@ps that means the JS that is being loaded was not produced by the watch you started. that can either happen if you have 2 shadow-cljs isntances running in the same project. or you changed the paths somewhere but still access the "old" JS#2021-02-1110:07zendevil.ethhow to close all shadow-cljs instances?#2021-02-1110:08zendevil.ethi might have been running two#2021-02-1110:08zendevil.ethI’ve tried shadow-cljs stop#2021-02-1110:09roman01la> both are the same as far as shadow-cljs is concerned. I'm just not sure that the typehint directly on the defer properly propagates to the function return value. interesting, so there two things going on 1. shadow doesn't emit a warning 2. switching to ^js solves the problem, externs inferred correctly#2021-02-1110:10thhellerodd#2021-02-1110:13thheller@ps stop will only stop the latest one. if you somehow started another you need to kill it manually. you can use the java tools to find the process. just jps or jcmd#2021-02-1111:44roman01la@thheller I can verify that adding return type hint solves the above problem, however it doesn't exist in plain cljs#2021-02-1112:44thhellerwhat does? shadow-cljs doesn't do anything special in that regard?#2021-02-1112:45roman01laI mean that in plain cljs property renaming doesn't happen, but in shadow it does happen, even though shadow doesn't emit infer warning#2021-02-1112:47thhelleryou need to be more precise. I do not have enough information to know what you are referring to. for example the renaming may not happen in regular CLJS because you have some CLJSJS externs that happen to handle it, they are often over-generated so it might even be from a different package or so.#2021-02-1112:48thhellerI'm happy to take a look at reproducible sample code any time (and fix it if there are actual issues)#2021-02-1112:49roman01lagood point about third party externs, I'll put a minimal repro once I manage to reduce the scope of the problem#2021-02-1112:49thhellerin general shadow-cljs does more externs inference, not less so I'd be very surprised if thats the cause#2021-02-1112:49roman01layeah that's why it seemed weird to me#2021-02-1112:50roman01laanother interesting case I just hit is that during dev shadow emits an inferring warning, but release build doesn't emit the warning and generated JS looks correct#2021-02-1112:51roman01lathis is not a problem, since adding a hint to silence the compiler in dev is fine, but still interesting inconsistency#2021-02-1112:52thhellercan't say anything without reproducible examples#2021-02-1114:11zendevil.ethI’m trying to run the shadow repl on cursive#2021-02-1114:12zendevil.eththis is my repl configuration#2021-02-1114:13zendevil.ethBut I’m getting this error:
EOF while trying to sync input stream.
#2021-02-1114:13zendevil.ethwhen clicking run#2021-02-1114:13thhellercan you see the warning on the bottom? pretty sure you need to add "localhost" to the Host field#2021-02-1114:14thhellerand also select nREPL above, then also select "use port from nrepl file"#2021-02-1114:15thhellerlike this#2021-02-1114:22zendevil.eth@thheller it’s stuck on: Connecting to remote nREPL server...#2021-02-1114:23zendevil.eth#2021-02-1114:24thhelleris shadow-cljs running? did you actually configure that port? is it actually running on localhost?#2021-02-1114:24thhellerplease use the above setting. you really should not be hardcoding the port ever.#2021-02-1114:25zendevil.eththis is the beginning of the shadow output:
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.8.93 running at 
shadow-cljs - nREPL server started on port 7002
shadow-cljs - watching build
#2021-02-1114:25thhellerseems fine then. maybe your firewall is blocking the port?#2021-02-1114:26zendevil.ethhow to fix that?#2021-02-1114:26thhellersorry I cannot help you with macOS questions and note the "maybe". I don't have a clue if that is the cause#2021-02-1114:26zendevil.ethalso I still see shadow-cljs connection closed#2021-02-1114:27zendevil.ethThis is the output from jcmd#2021-02-1114:27zendevil.eth
51168 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init5834689007742471668.clj
53409 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init6184901872508431686.clj
52882 clojure.main -m leiningen.core.main run -m shadow.cljs.devtools.cli --npm watch app
52885 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init2867749071698962093.clj
51910 
53993 sun.tools.jcmd.JCmd
#2021-02-1114:27thhellerok that is one shadow-cljs process. the others are lein processes. not sure if you mean to have those.#2021-02-1114:28zendevil.ethi mean to have one lein process that’s running my app’s server#2021-02-1114:29thhellerok. but you did not start shadow-cljs in those processes? meaning there is no lein-shadow in your project.clj?#2021-02-1114:30zendevil.ethI’m not sure: #2021-02-1114:30zendevil.eth
(defproject vendo "0.1.0"

  :description "Main Page. Vendomarch."
  :url ""

  :dependencies [[ch.qos.logback/logback-classic "1.2.3"]
                 [cheshire "5.10.0"]
                 [cljs-ajax "0.8.0"]
                 [clojure.java-time "0.3.2"]
                 [com.cognitect/transit-clj "1.0.324"]
                 [com.fasterxml.jackson.core/jackson-core "2.11.0"]
                 [com.fasterxml.jackson.core/jackson-databind "2.11.0"]
                 [com.google.javascript/closure-compiler-unshaded "v20200504" :scope "provided"]
                 [cprop "0.1.17"]
                 [day8.re-frame/http-fx "0.1.6"]
                 [expound "0.8.4"]
                 [funcool/struct "1.4.0"]
                 [luminus-aleph "0.1.6"]
                 [luminus-transit "0.1.2"]
                 [luminus/ring-ttl-session "0.3.3"]
                 [markdown-clj "1.10.4"]
                 [metosin/jsonista "0.2.6"]
                 [metosin/muuntaja "0.6.7"]
                 [metosin/reitit "0.5.2"]
                 [metosin/ring-http-response "0.9.1"]
                 [mount "0.1.16"]
                 [nrepl "0.7.0"]
                 [org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.764" :scope "provided"]
                 [org.clojure/core.async "1.1.582"]
                 [org.clojure/google-closure-library "0.0-20191016-6ae1f72f" :scope "provided"]
                 [org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f" :scope "provided"]
                 [org.clojure/tools.cli "1.0.194"]
                 [org.clojure/tools.logging "1.1.0"]
                 [org.webjars.npm/bulma "0.8.2"]
                 [org.webjars.npm/material-icons "0.3.1"]
                 [org.webjars/webjars-locator "0.40"]
                 [re-frame "0.12.0"]
                 [reagent "1.0.0-alpha2"]
                 [ring-webjars "0.2.0"]
                 [ring/ring-core "1.8.1"]
                 [ring/ring-defaults "0.3.2"]
                 [selmer "1.12.27"]
                 [thheller/shadow-cljs "2.8.93" :scope "provided"]

                 ;; non-default dependencies
                 [com.novemberain/monger "3.1.0"]
                 [clj-http "3.10.1"]
                 [org.mongodb/mongo-java-driver "3.12.1"]
                 [com.cemerick/url "0.1.1"]
                 [com.draines/postal "2.0.3"]
                 [digest "1.4.9"]


                 ;; cljs
                 [rgm/tailwind-cljs "0.1.0"]
                 [cljs-bean "1.5.0"]

                 [clojurewerkz/elephant "1.0.0-beta18"]
                 ]

  :min-lein-version "2.0.0"
  
  :source-paths ["src/clj" "src/cljs" "src/cljc"]
  :test-paths ["test/clj" "test/cljs"]
  :resource-paths ["resources" "target/cljsbuild"]
  :target-path "target/%s/"
  :main ^:skip-aot vendo.core

  :plugins [[lein-shadow "0.2.0"]] 
  :clean-targets ^{:protect false}
  [:target-path "target/cljsbuild"]
  :shadow-cljs
  {:nrepl {:port 7002}
   :builds
   {:app
    {:target :browser
     :output-dir "target/cljsbuild/public/js"
     :asset-path "/js"
     :modules {:app {:entries []}}
     :devtools
     {:watch-dir "resources/public" :preloads [re-frisk.preload]}
     :dev
     {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
    :test
    {:target :browser-test;;:node-test
     :test-dir  "resources/public/js/test"
     :autorun true
     :ns-regexp ".*"

     :devtools  {:http-port          8021
                 :http-root          "resources/public/js/test"}

     }
    :node-test
    {
     :target :node-test
     :output-to "target/test/test.js"
     }

    :ci
    {
     :target :karma
     :output-to "target/ci.js"
     :ns-regexp ".*"
     }
    
    }}

  :npm-deps [[shadow-cljs "2.8.93"]
             [create-react-class "15.6.3"]
             [react "16.13.0"]
             [react-dom "16.13.0"]]
  :npm-dev-deps [[xmlhttprequest "1.8.0"]]

  :profiles
  {:uberjar {:omit-source true
             :prep-tasks ["compile" ["shadow" "release" "app"]]
             :aot :all
             :uberjar-name "vendo.jar"
             :source-paths ["env/prod/clj"  "env/prod/cljs" ]
             :resource-paths ["env/prod/resources"]}

   :dev           [:project/dev :profiles/dev]
   :test          [:project/dev :project/test :profiles/test]

   :project/dev  {:jvm-opts ["-Dconf=dev-config.edn" ]
                  :dependencies [[binaryage/devtools "1.0.0"]
                                 [cider/piggieback "0.5.0"]
                                 [pjstadig/humane-test-output "0.10.0"]
                                 [prone "2020-01-17"]
                                 [re-frisk "1.3.2"]
                                 [ring/ring-devel "1.8.1"]
                                 [ring/ring-mock "0.4.0"]]
                  :plugins      [[com.jakemccrary/lein-test-refresh "0.24.1"]
                                 [jonase/eastwood "0.3.5"]] 
                  :source-paths ["env/dev/clj"  "env/dev/cljs" "test/cljs" ]
                  :resource-paths ["env/dev/resources"]
                  :repl-options {:init-ns user
                                 :timeout 120000}
                  :injections [(require 'pjstadig.humane-test-output)
                               (pjstadig.humane-test-output/activate!)]}
   :project/test {:jvm-opts ["-Dconf=test-config.edn" ]
                  :resource-paths ["env/test/resources"] 
                  }
   :profiles/dev {}
   :profiles/test {}})
#2021-02-1114:31thhellerok, sorry cannot help you with lein-shadow related issues#2021-02-1114:32zendevil.ethwhat if I remove the lein-shadow plugin?#2021-02-1114:32thhelleryes, you should do that#2021-02-1114:34thhellerbasically what you want is EITHER running everything directly via lein OR running the server parts with lein and the CLJS parts with shadow-cljs#2021-02-1114:34thhellerNOT both. it appears to me that you currently try to do both and them interfering with each other#2021-02-1114:34thhellerI do recommend running things separately always#2021-02-1114:35thhellerso in one process you run lein repl or whatever the command there is and in another process you run shadow-cljs watch app#2021-02-1114:35thheller(I have also never used luminus so I'm not sure how all that works)#2021-02-1301:07bringeDoes anyone here happen to know how to make the typescript compiler not complain about imports like import { some_thing } from 'goog:some.ns' ? I've done some searching but haven't found a solution.#2021-02-1314:56Carlocan :dev {:compiler-options {:invalid-arithmetic false}} in shadow-cljs.edn silence a warning coming from a dependency?#2021-02-1316:16thhellerno, but yes 😉#2021-02-1316:17thheller:dev {:compiler-options {:warnings {:invalid-arithmetic false}}} can#2021-02-1317:11Carlothanks, you're the best 🙌#2021-02-1320:40mauricio.szabo@thheller Hi there. It seems that recent versions of Shadow-CLJS do not work with OpenJ9 JVM. Do you know if it's a ClojureScript issue, or a Shadow-CLJS one? It does compile, but when I try to run the JS output it gives an error of ReferenceError: ...... is not defined. This ...... can be almost anything, but most of the time is key, $coll, $seq or something like this. I'm not really asking to solve it, but maybe you can have some insight on where the problem is :thinking_face:#2021-02-1320:42thhellersounds like https://github.com/thheller/shadow-cljs/issues/804. not a clue what is happening or even how.#2021-02-1320:43thhellerthere is no code in shadow-cljs or CLJS I'm aware of that prepends a $ to a symbol#2021-02-1320:43thhellerappend yes, prepend no#2021-02-1320:44mauricio.szaboWell, I remember a bug I had on a Clojure code with OpenJ9 that it resolved java methods to different implementations (for example, where both have the signature (int, int) or (long, long), or something). Maybe that's related? I remember that the method was resolved using reflection...#2021-02-1320:45mauricio.szaboSeems like an interesting thing to investigate 😄#2021-02-1320:45thhelleryeah not a clue where to even start#2021-02-1320:46mauricio.szaboYeah, it was related to reflection: https://clojure.atlassian.net/browse/CLJ-2400#2021-02-1321:08thhellerif you have a reliable way to reproduce the problem I'd be happy to check it out#2021-02-1321:08thhellerbut the "random" nature makes this difficult#2021-02-1321:13dpsuttoni think alex might have made a ticket about this. method resolution is basically random and there might be problems with Clojure before any cljs gets involved on j9#2021-02-1322:17Carlogeneral question: how do you run automatically your tests from cider+shadow-cljs? I see by googling that in the past we didn't have an automated process, but I wonder if that changed#2021-02-1322:19CarloI added:
:test {:target    :node-test
                       :output-to "out/node-tests.js"
                       :autorun   true}
to the configuration but nothing ever happens, and I don't know how to activate them
#2021-02-1409:15thhellercan't comment on cider stuff but :autorun will run tests after compilation. very probable that cider just isn't displaying the output, nrepl is weird in that way.#2021-02-1409:36CarloThanks, and so what's yours set-up for running them?#2021-02-1409:39thhellereither from the REPL or manually. I don't use :autorun#2021-02-1411:02Carloso, by manually you mean something like
shadow-cljs compile test && node out/node-tests.js
how do you run them from the repl? Since then I discovered that I can open a repl which targets :test that does what I want, but it seems I can only have one repl open in cider (?)
#2021-02-1411:04thhelleryes, by manually I mean I run node the-tests.js whenever I want to run the tests. I'll still have the watch running usually to see compile errors and stuff#2021-02-1411:04thhellerfrom the repl just (cljs.test/run-tests 'the.ns-test) or so#2021-02-1411:05thhellerusually just a simple node-repl#2021-02-1411:06thhellerI don't test much so you should probably ask someone that actually has a test workflow#2021-02-1411:06Carlothanks @thheller 🙌#2021-02-1411:16OzHello, I notice that in my app, re-compilation is very fast, but the reload (where the little wheel spins) takes a good 7 seconds, probably because I did something silly. Any idea what may cause the slowdown?#2021-02-1411:17thhellerimpossible to say without more info. you can run shadow-cljs watch app --verbose to get a little more info about what is going on#2021-02-1411:18thhelleryour code might be doing something that takes a long time when it is getting loaded#2021-02-1411:20OzThank you! I will try the verbose mode and playing with the mount-root function#2021-02-1411:24OzStrange, the delay disappeared as soon as I restarted the watch#2021-02-1511:56RollACasterHi, I am trying to import http://kepler.gl, unfortunately the library is mixing esm & commonjs imports which results in an error when I try to import them. https://github.com/keplergl/kepler.gl/blob/master/src/localization/index.js#L30 I tried to manually specify the requirements with:
{
  ...
   :js-options
   {:resolve {"./fi" {:target :file
                      :require  "node_modules/kepler.gl/dist/localization/fi.js"}}
             ...}
}
Which resulted in another error: $jscomp.inherits is not a function Is there some way to import this library?
#2021-02-1512:17thheller@thsojka you might need to use webpack. the lib seems to do stuff that shadow-cljs does not support#2021-02-1512:18thhellerthe inherits you can get rid of by setting :compiler-options {:output-feature-set :es6}#2021-02-1512:20RollACasterthanks 👍 I’ll try that#2021-02-1513:14zendevil.ethsomething that’s working in regular react native isn’t working in cljsrn run with shadowcljs, making me think that there must be something up with shadow that’s causing it. React Native:
<LottieView
      source={require('../components/img/animations/cat-loading.json')}
      style={{marginRight: 100, marginLeft: 50}}
      autoPlay
      loop
    />
In this case I’m seeing the LottieView animation. Cljs React Native:
[:> LottieView {:source (js/require "../resources/images/loading2.json")
                      :autoPlay true
                      :loop true
                      :style {:height 200
                              :marginright 200
                              :marginleft 50}}]
In this case I’m not seeing the LottieView animation. What might be causing this error?
#2021-02-1513:42zendevil.ethIn the github of lottie files it’s imported like so:
import LottieView from 'lottie-react-native';
#2021-02-1513:43zendevil.ethwhich, according to the shadow user guide translates to: [“lottie-react-native” :default LottieView]#2021-02-1513:44zendevil.ethBut this gives an error. using :as instead of default doesn’t give an error (but the animation doesn’t show either). Why am I getting an error when using :default when I’m using the direct translation from shadow cljs user guide?#2021-02-1513:48zendevil.ethhttps://github.com/lottie-react-native/lottie-react-native#2021-02-1514:13thheller@ps I don't have a clue. I do not use react-native. this looks correct to me except maybe for the path used in the js/require call. that looks wrong. might also be the :style map. not exaclty sure how reagent converts that, if at all.#2021-02-1601:25Chris McCormickis there a way to run a script like you would with lumo? e.g. similar to npx shadow-cljs run ... except for .cljs files. so it would compile and then execute the script with node.#2021-02-1608:29thhellerno, that would be terrible experience. rather slow startup due to having the JVM startup. just build it with :node-script and once its built you don't need shadow-cljs or the compiler at all anymore#2021-02-1612:41Michaël Salihi@chris358 The same way we can do with vanilla CLJS? clj -M -m cljs.main -t node -o main.js -i example.cljs#2021-02-1702:04Chris McCormickwill test out both of these, thanks. @thheller what i am looking for is something that can replace an existing workflow from javascript. i often have a small piece of js in my makefile to just do one thing (like transform markdown into HTML on the server) and i would like to be able to use cljs instead. it would be good if i could just create and run a .cljs file in a node context, rather than having to add a clause to shadow-cljs.edn and run multiple steps. i guess i'm really looking for something like lumo - a cljs interpereter that is pre-compiled into js on node.#2021-02-1709:25thheller@chris358 sounds like babashka might be a good fit? or even just clj? CLJS is only great for this is you have it precompiled and don't need the JVM anymore. Or just lumo. shadow-cljs will always require the JVM to compile so thats not the best fit if you want to compile on-demand#2021-02-1713:17huxleyI have a weird error that I don't know what it is#2021-02-1713:19huxleyI'm pretty sure it worked before, but I can't find a Shadow version where it actually works#2021-02-1713:20huxleyproblem only affects meander#2021-02-1713:20huxleyhttps://github.com/ribelo/shadow-meander-test#2021-02-1713:34thheller@r.krzywaznia my guess is that the meander macro emits some "bad" JS code referencing jvm stuff. usually something like java.lang.Exception or so#2021-02-1713:34thhelleroftentimes you never really run into these exception so the code appears to work. doesn't make it any more valid though.#2021-02-1713:39huxleyI will pass the information to the meander creator#2021-02-1713:41huxleythx#2021-02-1713:47thhelleryeah as expected the compiled code contains
} catch (e48925) {
                    if (e48925 instanceof java.lang.Exception) {
                      var e__47256__auto__ = e48925;
#2021-02-1713:47thhellershould it ever end up in that catch the code will break#2021-02-1723:47bringeHello. Been looking around for clues to this issue I'm having and it looks similar to this issue, but not sure it's the same. I'm trying to require js files compiled from typescript. I can require them with js/require , but trying to require them from the ns form doesn't work. The shadow compilation works, but with a require like ["/config.js" :as config] and then eval config I get
; Execution error (ReferenceError) at (
#2021-02-1723:48bringeThis is with shadow version 12.11.18#2021-02-1723:48thhellerdon't do this. I thought we went over this in the ticket 🙂#2021-02-1723:49thhellerjust use js/require instead#2021-02-1800:06thhellerwhen you require it from the ns :require it will become part of the shadow-cljs build#2021-02-1800:06thhellerwhen you js/require it then it will just resolve at runtime and not be part of the build#2021-02-1800:06bringeYes, that works. Whereas before I wasn't trying to make shadow bundle things, I later wanted to see if I could get shadow bundling everything as you mentioned in that ticket. I've been reading stuff you said there multiple times and understanding more and more 😄. > Just stick with :node-library. :esm will not give you any "new" features if it requires post-processing anyways. So until vscode can load ESM directly without further bundling :esm should not be used. I'm sticking to :node-library but was thinking I could still bundle things with shadow if I could make typescript ignore the goog:.. imports, as you mentioned, and then stop using webpack. But I see you mentioned potential issues with that, so I probably will stop this approach now.#2021-02-1800:08thhelleryeah I'd recommend sticking with js/require until you get the amount of JS code down significantly#2021-02-1800:08bringeThat makes sense#2021-02-1800:08thhellerits fine for smaller bits of JS code or JS code that is fully advanced compatible#2021-02-1800:09thhellerbut for the vast chunk of the vscode based code you probably won't have externs anyways#2021-02-1800:09bringeI see#2021-02-1800:10thhellerI mean you can still go with this route and try it#2021-02-1800:10thhellerbut not many people do so there may be many issues with this that may require tinkering with shadow-cljs#2021-02-1800:10thhellerit works ok-ish in the browser but node seems to have some problems#2021-02-1800:12bringeYeah, I'd rather go the path of least resistance in this case#2021-02-1804:23Kira McLeanHas anyone built a custom shadow-cljs build target before? Is this actually possible? I spotted this in the shadow-cljs docs: > The build target is an extensible feature of `shadow-cljs` but am still looking for details about how it might be done :thinking_face: .. wondering if there are any examples out there#2021-02-1804:25Kira McLeanI would like to make a build target that combines devcards and karma (basically combine the current built-in :browser and :karma build targets), so I can use devcards as a test harness for UI-based cljs tests#2021-02-1807:03thheller@kiraemclean I guess as example you could look at the default provided targets, they all use the same mechanism a custom target would use. https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2021-02-1814:15Kira McLeanthis is very helpful, thank you for the reply! I didn’t know the :karma target could take a runner-ns option, I think that would do it! I was looking at using a custom runner-ns for the existing browser-target then some karma hackery to get it to run in CI, but I think doing it the other way around (starting with the existing karma target and adding a custom runner) would be simpler.#2021-02-1814:15Kira McLeanI was wading through the custom targets but didn’t figure out how to build a custom one that could hook in to the existing build chain.#2021-02-1815:08thhellerthey all function based on the same principle. when shadow-cljs finds :target :karma in the build config it'll "expand" :karma to shadow.build.targets.karma/process and call that function for every "stage" of the compilation. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#L114#2021-02-1815:09thhellerso if you were to create a :target :kira you'd create that shadow.build.targets.kira/process function and do whatever you want to do#2021-02-1815:09thhellerit it also valid to have :target kira.target which would call (kira.target/process build-state) or :target kira.target/do-stuff which would call (kira.target/do-stuff build-state)#2021-02-1815:10thhellerso a keyword is just the shorter version of a symbol or qualified symbol#2021-02-1815:11thhellerthe function is call repeatedly and is supposed to look at the :shadow.build/stage etc keys to figure out what to do#2021-02-1815:11thhellerexplaining beyond that will get very technical and it would be best to look at what the current targets do to understand#2021-02-1815:12thhellerhappy to help if you have specific questions but that should be the rough overview#2021-02-1819:29Kira McLeanThis is very helpful! Thank you so much for the explanation. I suspect I can acheive what I’m after without needing a whole custom build target, but I see now how it’s done.. really really appreciate your guidance, thanks. And also shadow-cljs! It’s very cool.#2021-02-1819:32thhelleryeah, I do think that a custom :runner-ns will probably be enough. the important bits there is just the exported init function#2021-02-1819:33thhellerI vaguely remember someone doing something with devcards and shadow-cljs before but I can't find it#2021-02-1819:34thhellerhow you'd hook up devcards to the karma stuff I have absolutely no clue though 🙂#2021-02-1819:35Kira McLeannice.. if I ever get it running I’ll make sure to write it down somewhere 🙂 but yeah all the pieces are here — test harness, karma-compatible test js file, etc. but they don’t work together yet.#2021-02-1819:36Kira McLeanhah.. yeah I’m on the fence about using devcards as a ui actually.. most front-end browser tests work by appending and removing the component to be tested from the dom. with the dev-card ui I’d have to somehow click around to make sure the right one is showing for the right tests.#2021-02-1819:37Kira McLeananyway.. I’m optimistic about this 🙂 probably will pause to work on something else for a bit to give my brain a rest.. but I really would love to get it up and running! soon.#2021-02-1819:38Kira McLeanthanks again for the pointers.#2021-02-1807:04thhellerit is however not exactly documented or easy to do since they can get rather involved in low level stuff (eg. :browser https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj)#2021-02-1807:06thheller:karma is much simpler and I think already allows what you are looking for via the :runner-ns option https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#2021-02-1807:07thhellerdefaults to this one https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/karma.cljs and I guess you could just create one that uses devcards instead#2021-02-1807:16bbssI'm trying to put my web-app into an app. I think http://capacitorjs.com looks pretty good so giving that a try. I've built and ran my app successfully, however firebase auth works a bit differently when running in apps (webview). I'm using the capacitor-firebase-auth plugin, but running into an error I haven't been able to solve yet and I think it's related to esModules stuff. The error I'm getting is: ️ TypeError: undefined is not an object (evaluating 'new q.auth.GoogleAuthProvider') Originating here: https://github.com/baumblatt/capacitor-firebase-auth/blob/master/src/facades.ts#L28 I've tried to shadow-cljs release with
:release {:compiler-options {:variable-renaming :off
                             :property-renaming :off
                             :pretty-print      true
                             :source-map        true
                             :infer-externs :auto
                             :output-feature-set :es6
                             :optimizations :simple}}
But to no avail.
#2021-02-1807:17bbssMight it be there is a conflicting issue with typescript somehow? There is this comment in the readme:
1 import firebase from 'firebase/app';
         ~~~~~~~~
    8601 export = firebase;
         ~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
If you see the message above, please use `esModuleInterop=true` in your `tsconfig.json` file.
#2021-02-1807:17thheller@bbss and how does the CLJS code looking doing this?#2021-02-1807:18bbss
(ns kr.ui.firebase
  (:require ["firebase/auth"]
            ["firebase/analytics"]
            ["firebase/app" :default firebase]
            ["capacitor-firebase-auth" :refer [cfaSignIn]]
            ["firebaseui" :as fbui]))
...

(.subscribe (cfaSignIn "") (fn [u] (js/console.log u :signed-in))) ;;offending line in my code
#2021-02-1807:19bbssthe library file on github does a require like this: import * as firebase from 'firebase/app';#2021-02-1807:19thhellerso (cfaSignIn "") this fails?#2021-02-1807:20bbssyes#2021-02-1807:20thhellerdid you verify that the firebase version you use matches EXACLTY the version capacitor-firebase-auth expects?#2021-02-1807:21bbssI did not, let me check.#2021-02-1807:21thhellerfirebase is notorious for changing its API constantly#2021-02-1807:21thhellerso I expect that you just use an incompatible version#2021-02-1807:21bbsscould be! checking.#2021-02-1807:23thhellerfor example in the lib there is import * as firebase from 'firebase/app'; but you have ["firebase/app" :default firebase]#2021-02-1807:23thhellerthose are not the same thing and only one version is correct 😛#2021-02-1807:24bbssUgh, they're not the same?#2021-02-1807:24bbssYeah it's a major version mismatch, the plugin has peerdep 7.x.x and I use 8.x.x#2021-02-1807:25bbssdowngrading..#2021-02-1807:26bbsshttps://github.com/baumblatt/capacitor-firebase-auth/issues/128 looks relevant..#2021-02-1807:33bbssgreat! updating to that alpha version mentioned in the issue seems to fix it!#2021-02-1807:33bbssThanks for the insight @thheller#2021-02-1818:59lambduhhhDoes anybody know of an alternative to codox to auto generate documentation for a private cljs project? Codox looks great but seems like shadow w deps isn't officially supported.#2021-02-1819:00lambduhhh(hope I'm posting in the correct place, if anyone knows a better channel to post in just lmk 🙂 )#2021-02-1819:30thhelleryou can just create a lein project.clj and use codox that way. as far as I know codox doesn't actually compile the code, just needs to be able to read it.#2021-02-1819:31thhellerbut it has been a while since I used and and only for CLJ at that#2021-02-2001:10mauricio.szaboHi there! Is there any way to make shadow don't try to resolve a Javascript require? The problem I'm facing is that for some libraries that do run on the browser and are expected to be bundled by webapack, they sometimes wrap the require into a try...`catch` and then shadow tries to resolve it and fails#2021-02-2008:45thheller@mauricio.szabo :js-options {:resolve {"that-package" false}}#2021-02-2018:24mauricio.szaboOh, great! Thanks again, it worked!#2021-02-2100:07Adrian SmithI have a shadow-cljs project using a node-script build, I'm using shadow-cljs node-repl then connecting and trying evaluate my file that has npm imports like ["robotjs" as robo] when I try and evaluate the file I'm getting clojure.core.spec complaining about that, where am I going wrong?#2021-02-2100:14Adrian Smithah looks like I had to do (shadow/node-repl) whilst inside the repl#2021-02-2109:13thhellerindeed, REPLs first always start out in CLJ when you connect over nREPL#2021-02-2111:59Adam Kalisz@theller I don't know, if this came up earlier. For some time, I was unable to load the development version of our ClojureScript project on localhost in Chromium. It worked in Firefox, but was rather slow. I didn't know at all, what caused it. So I tried to gather some data about it. I cleared the cache of Chromium (deleted ~/.cache/chromium) and this helped a few times but the problem always returned. I have resorted to deleting of the build directory of shadow-cljs. The result was that the development version of our project loaded immediately in Chromium and Firefox as well. I don't have any further data, just wanted to let you know.#2021-02-2113:17RemyHello, I’m trying to setup custom response headers in order to do a cross-origin request during development. I’ve been reading [the user guide](https://shadow-cljs.github.io/docs/UsersGuide.html) and [a stackoverflow question](https://stackoverflow.com/questions/65907176/how-to-properly-setup-shadow-cljs-for-hot-reload) but it seems the headers only apply to the shadow-cljs “dashboard” server (eg. 9630), not the app itself. I tried the following so far: - wrapping shadow.http.push-state/handle and calling the wrapper in :dev-http. Same result when overriding :push-state/headers - setting :devtools :http-handler, again pointing at my wrapper I just wanted to ask here before going through the source, maybe there’s something i misunderstood entirely from the docs. I’m starting the server up through emacs cljs-jack-in with
npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.9 server
;; dev/custom_handler.clj
(ns custom-handler
  (:require [shadow.http.push-state :refer [handle]]))


(defn handle-wrapper
  [req]
  (handle (assoc-in req
                    [:http-config :push-state/headers]
                    {"conten-type" "text/html; charset=utf-8"
                     "access-control-allow-origin" "*"})))
;; shadow-cljs.edn
;; shadow-cljs 2.11.7
;; clojurescript 1.10.773
{:deps {:aliases [:dev :shadow :cljc]}
 :nrepl {:port 8777
         :middleware [refactor-nrepl.middleware/wrap-refactor]}

 :dev-http {8281 {
                  :root "resources/public"
                  :push-state/headers {"access-control-allow-origin" "*"}
                  }
            }
 :builds {:app {:target :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules {:app {:init-fn remyrd.rock-n-call-frontend.core/init}}
                :devtools {:http-root "resources/public"
                           :http-port 8280
                           :http-handler custom-handler/handle-wrapper
                           :preloads [devtools.preload]
                           }}}}
#2021-02-2113:20thhellerbasically as soon as you want to do something like this you should be using your own http server instead#2021-02-2113:21thhellerwhat is serving your HTML that makes this necessary in the first place?#2021-02-2113:22thhellerthe handler isn't supposed to modify the request coming in. instead it should modify the response#2021-02-2113:23thheller
(defn handle-wrapper
  [req]
  (-> req
      (handle)
      (update :headers merge
        {"access-control-allow-origin" "*"})))
#2021-02-2113:28thhelleralso why do you have a dev-http and then another in devtools?#2021-02-2113:31RemyJust to showcase the two possibilities i tried#2021-02-2113:30RemyRight, silly me it should’ve gone in the response. I agree I should be using my own http server, for now i’m just doodling and I needed this data from an external api.#2021-02-2113:30thhellermaybe you want to proxy instead?#2021-02-2113:33Remyprobably… i see there’s a section about it that i can read :)#2021-02-2113:43RemyWell i’m trying to figure out what is the best way to serve cross-origin content on a static webpage, probably I’m forcing this approach but I wanted to avoid spinning up a server#2021-02-2113:50thhellersounds like you are maybe trying to solve this in the wrong way? the API server handling the requests is the server that needs to set those CORS headers#2021-02-2113:50thhellernot the shadow-cljs server serving the .js files#2021-02-2113:54Remyoh i see, yes the origin in allow origin makes more sense now, thanks#2021-02-2113:45RemyBtw, thanks for the quick answers and the tool#2021-02-2218:17rschmuklerHas anyone here ever seen shadow unable to use a specific library because the underlying library cannot be converted from ES6 in the closure compiler?#2021-02-2218:17rschmuklerSpecifically, I am trying to use https://www.npmjs.com/package/mapbox-gl which is published as an ES6 bundle#2021-02-2218:19thhellerif it cannot be converted you can turn of the conversion via :compiler-options {:output-feature-set :es6} or :es7 :es8. depending on what makes sense#2021-02-2218:20rschmuklerThank you @thheller#2021-02-2218:20rschmuklerIt does look like it can't be, without more advanced transpilation config anyway (it depends on webworkers)#2021-02-2218:25thhellerunless you need really old browser support :es6 is a reasonable setting. I might even make it default soon (since Closure will do that as well)#2021-02-2218:27rschmuklerYep, that fixed it! Apologies for not consulting the user guide before bothering you#2021-02-2218:27rschmuklerThanks for the help 🙏#2021-02-2218:55orestisI wonder if people are seeing slow file change response times from shadow-cljs on M1 macs? This is probably related to the hawk and the underlying file watch service thing, but I thought I'd ask here first if there's a known issue?#2021-02-2219:05thheller@orestis update. I removed hawk entirely and the default JVM watcher seems to be faster.#2021-02-2220:14orestisIndeed it’s much faster. Thanks! I’m using the Azul 11 jdk on ARM btw. #2021-02-2219:11orestisI'll try, thanks#2021-02-2219:13Adam Kalisz@thheller Ok, it seems the problem I have written about yesterday (but messed up the handle) "For some time, I was unable to load the development version of our ClojureScript project on localhost in Chromium. It worked in Firefox, but was rather slow. I didn't know at all, what caused it. So I tried to gather some data about it. I cleared the cache of Chromium (deleted ~/.cache/chromium) and this helped a few times but the problem always returned. I have resorted to deleting of the build directory of shadow-cljs. The result was that the development version of our project loaded immediately in Chromium and Firefox as well. I don't have any further data, just wanted to let you know." It seems, the problem stems from shadow-cljs watch since the problem doesn't happen when a release is built. I tried this with 2.11.11 and 2.11.18 and there was no change. I am on Debian Testing, none of my colleagues with Windows are experiencing this but for me, I am basically unable to work efficiently - there are no development tools for ClojureScript in Firefox. Chromium seems to be hit by this bug somewhat harder. What further debugging steps do you propose?#2021-02-2219:16thhellersorry I cannot provide any tips without more info about your project#2021-02-2219:16thhellerwhen it compiles and you get the "build completed" message. what numbers do you see?#2021-02-2219:16thheller[:browser] Build completed. (143 files, 137 compiled, 0 warnings, 8.33s)#2021-02-2219:17thhellerwhich version do you use? which java version?#2021-02-2219:23Adam KaliszWhen run with shadow-cljs watch I see:#2021-02-2219:25Adam Kalisz[:client] Build completed. (1106 files, 9 compiled, 0 warnings, 1.48s) The release version looks like this: [:client] Build completed. (1041 files, 895 compiled, 0 warnings, 113.01s) The Java version is: java --version openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment (build 11.0.10+9-post-Debian-1) OpenJDK 64-Bit Server VM (build 11.0.10+9-post-Debian-1, mixed mode, sharing)#2021-02-2219:27Adam KaliszI tested with shadow-cljs 2.11.18 and 2.11.11 as well. No visible change in behaviour between those.#2021-02-2219:30thhellerlooks fine. do you use :init-fn in your build config?#2021-02-2219:31thhellerif so try changing :init-fn some.ns/foo to just :entries [some.ns]. that will cause the same code to be included but not called on startup#2021-02-2219:31thhelleris it still slow when loading the page? or is the call actually making everything slow? if so that is your code and shadow-cljs can do nothing about that.#2021-02-2219:33Adam Kalisz
:client     {:target           :browser
                            :output-dir       "resources/public/js/compiled"
                            :asset-path       "/js/compiled"
                            :module-loader    true
                            :modules          {:shared {:entries []}
                                               :main   {:init-fn    orgpad.client.core/init
                                                        :depends-on #{:shared}}
                                               :admin  {:entries    [orgpad.client.views.administration.core]
                                                        :depends-on #{:main}}
                                               :layout {:entries    [orgpad.client.layout.webworker.core]
                                                        :depends-on #{:shared}
                                                        :web-worker true}}
                            :compiler-options {:infer-externs      :auto
                                               :output-feature-set :es6}
                            :devtools         {:after-load     orgpad.client.core/mount-root
                                               :before-load    orgpad.client.core/stop-web-workers
                                               :watch-dir      "resources/public"
                                               :browser-inject :main
                                               :loader-mode    :script}}
The init looks like this:
(defn init
  "Init function of the client."
  []
  (rf/dispatch-sync [:init/starting-app])
  (window-events!)
  (accountant/configure-navigation!
    {:nav-handler       #(rf/dispatch [:app/changed-route %])
     :path-exists?      #(routes/client-routes (:handler (b/match-route routes/routes %)))
     :reload-same-path? true})
  (webfonts/load!)
  (mount-root))
I will try your proposed change
#2021-02-2219:38Adam KaliszI have done the change:
:main   {:entries    [orgpad.client.core] ;:init-fn    orgpad.client.core/init
         :depends-on #{:shared}}
(restarted shadow-cljs watch) and it still hangs and shows "shadow-cljs - Reconnecting ..." in the browser, also the Console output looks pretty much the same as it looked before on such hang
#2021-02-2219:39thhellerdo you have browser extensions installed in chrome?#2021-02-2219:39thheller> Console output looks pretty much the same#2021-02-2219:39thhellerwhat does it say?#2021-02-2219:41Adam KaliszInstalling CLJS DevTools 0.9.10 and enabling features :formatters :hints :async util.cljs:136 CLJS DevTools: some custom formatters were not rendered. devtools$util$check_custom_formatters_active_BANG_ @ util.cljs:136 browser.cljs:20 shadow-cljs: #6 ready! react-dom.development.js:24995 Download the React DevTools for a better development experience: core.cljs:11 csrf-token parsed: 9YQlw8taXECNrtRSbR8y1jjZ3awFctrGTALtx5YpLoTZxxhb0O9xIY1ZGxoTbWFGBF0D5VjbpxwKh6lW#2021-02-2219:41Adam KaliszI don't have any notable extensions just Chromium PDF Viewer and CryptoTokenExtension#2021-02-2219:43Adam KaliszThe Chromium is: Version 88.0.4324.146 (Developer Build) built on Debian bullseye/sid, running on Debian bullseye/sid (64-bit)#2021-02-2219:43thhellerthat suggests there is still code running on startup core.cljs:11#2021-02-2219:44thhellerwhy the the shadow-cljs websocket reconnecting? what do you see in the network tab regarding that?#2021-02-2219:44Adam KaliszI don't know. I will try again with all browser cache cleared#2021-02-2219:50fsdNeed help starting shadow cljs Application yarn start crashes and cant get pass this#2021-02-2219:52thhellerweird. try deleting the .shadow-cljs directory in the project. not a clue why it can't read a file it obviously found?#2021-02-2220:01fsddidn’t work after doing that :(#2021-02-2220:05thhellerI don't know. look at the file in your editor and make sure it is readable and so on#2021-02-2219:56Adam KaliszI cannot get rid of the csrf-token parsed line - it seems to concern this code: (def csrf-token "Value of CSRF token parsed from the metadata of HTML." (-> "csrf-token" js/document.getElementsByName (aget 0) (.getAttribute "content"))) (js/console.log "csrf-token parsed: " csrf-token) this is the line 11#2021-02-2219:58thhelleryou don't have to get rid of it. all code running on startup (without :init-fn) however directly contributes to load time#2021-02-2219:58thhellerso you have to dig yourself on why it is slow#2021-02-2219:58thhellergot into the profile, hit record+reload and figure out what is going on 😛#2021-02-2219:59Adam KaliszThe problem is, the load never finishes at all in Chromium...#2021-02-2220:00thhellerthat is fine. the profiler should stop after a few seconds.#2021-02-2220:01Adam KaliszSometimes, after a lot of deleting caches etc. it loads but after a few page changes in our SPA the problems is back again#2021-02-2220:01thhellerI have absolutely no clue what you are doing so I cannot comment#2021-02-2220:02Adam KaliszSure. Me neither thank you for your time and effort#2021-02-2222:48eccentric JIs there a quick way to tel the dev-http config to serve files from a virtual /static/ path or should I write a custom handler?#2021-02-2312:03thhellerwhat is a virtual /static/ path? You mean you don't have an actual /static/ directory on disk? that case would require a custom handler.#2021-02-2317:24eccentric JCorrect, a non /static/ path on disk.#2021-02-2317:24eccentric JThat makes sense, though I ended up just creating an actual static subdir which also solved the problem 😛#2021-02-2319:29eccentric JAlso: Thanks 🙂#2021-02-2301:28steveb8nQ: I’ve switched to an M1 mac/Big Sur and I’m seeing a delay in shadow compiles when using the :watch. Has anyone else seen this?#2021-02-2301:29steveb8nI use Cursive and “Save All” to initiate. I’m pretty sure Cursive is saving the file because when I try the same thing in a node/browsersync project, the rebuild is instant#2021-02-2301:30steveb8nI’ve switched to :watch verbose but don’t see anything there.#2021-02-2301:30steveb8nAny suggestions on how I can diagnose where the delay comes from?#2021-02-2305:48eccentric JDid the watch verbose include a timestamp?#2021-02-2307:06steveb8nI just checked: no timestamp#2021-02-2308:16thheller@U0510KXTU update. I removed hawk and that makes everything faster again.#2021-02-2308:18steveb8nok. I’ll try that soon. I have a dependency that breaks in latest shadow so I’ll have to refactor that first#2021-02-2308:18steveb8nthanks for the heads up#2021-02-2308:56thhellerhow does it break?#2021-02-2309:56steveb8nNo break. Just a delay between save and start of compile. In cursive I can see the dirty file indicator disappear so that's why I suspect the watcher#2021-02-2309:57steveb8nIt's not a blocker, just interrupts flow a bit#2021-02-2309:57steveb8nSeems only fair that I upgrade before asking more of your time#2021-02-2309:58steveb8nI'll report back again once I'm on latest#2021-02-2310:29thheller> I have a dependency that breaks in latest shadow#2021-02-2310:29thhellerthat break I meant. the delay I know and fixed.#2021-02-2311:21steveb8nAh ok. We discussed it a while back. It's https://github.com/hubgit/react-prosemirror which can be replaced by a more current wrapper. It's in my backlog#2021-02-2311:22steveb8nI'm on latest shadow for all other cljs projects so I need to do this anyway#2021-02-2311:23steveb8nHmm, that makes me realise I can verify the fix on other projects. I'll test this in the morning and will report back#2021-02-2311:24steveb8nUseful chat 😀#2021-02-2406:08steveb8nok, I can confirm the delay goes away with 2.11.18. it was still there with 2.11.8. thanks for the fix#2021-03-0512:43donavanInteresting, I’ve been running :fs-watch {:hawk false} on an M1 Mac for 2 months now and came here to say the exact same thing. It’s faster without hawk on my setup. I should have mentioned it sooner!#2021-02-2309:01MatiasHey, I have a bit of a weird bug that appeared when I switched from figwheel-sidecar (0.5.20) + cljsbuild (1.1.8) over to shadow-cljs (2.11.18). My application is running on Electron (5.0.2, can't update) and re-frame (0.10.9). The app uses a touch screen and no other peripherals, and the users need to input text, so a homebrew on-screen keyboard is used. Everything worked fine with figwheel, but when I switched to shadow, with no other dependencies being updated or changed, text inputs broke. When the user types into a field with the on-screen keyboard, the caret stays stuck to the start of the input. Naturally I have access to a keyboard when developing, which works just fine for text input: the caret moves as I input characters into the text field. After I've input some text with a keyboard, and switch to using the on-screen keyboard, the caret also continues to behave normally. Only when I input into an untouched field, with the on-screen keyboard, does the caret get stuck. The text field content is managed from re-frame db, and the on-screen keyboard "inputs" append the pressed key to the selected field's state in the db. I've tried to dispatch the same events a physical keyboard would send (`input`, keyup and keydown). I've tried to use .setSelectionRange to manually correct the caret to the right place, but it gets overwritten, so right now the ugly workaround I have is to set the caret position on a short timeout. This leads to the caret visibly jumping as you type, but the characters mostly go where they need to go. I want to stress that this all worked completely normally with figwheel, and only upgrading to shadow broke it. Are there any guesses to what might have broken it? Different optimizations, transpiling to a different version? I might have to switch back to figwheel if I can't solve this, because the current hack to type correctly is very unreliable and fragile.#2021-02-2309:06MatiasI can't give the project sources over, but here's the project.clj for the frontend. Shadow config included because of lein-shadow
(defproject xxx "3.3.1"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [org.clojure/clojurescript "1.10.764"]
                 [org.clojure/spec.alpha "0.2.187"]
                 [medley "1.3.0"]
                 [re-frame "0.10.9"]
                 [garden "1.3.10"]
                 [day8.re-frame/http-fx "v0.2.0"]
                 [com.taoensso/tempura "1.2.1"]
                 [com.andrewmcveigh/cljs-time "0.5.2"]
                 [thheller/shadow-cljs "2.11.18"]]

  :plugins [[lein-garden "0.3.0"]]

  :min-lein-version "2.5.3"

  :source-paths ["src/clj" "src/cljs" "src/cljc"]

  :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"]

  :garden {:builds [{:id           "screen"
                     :source-paths ["src/clj" "src/cljc"]
                     :stylesheet   xxx.css/screen
                     :compiler     {:output-to     "resources/public/css/garden.css"
                                    :pretty-print? true}}]}

  :profiles {:dev  {:dependencies [[binaryage/devtools "1.0.2"]
                                   [day8.re-frame/re-frame-10x "0.3.7-react16"]
                                   [day8.re-frame/tracing "0.6.0"]]
                    :plugins      [[lein-kibit "0.1.8"]
                                   [lein-shadow "0.3.1"]]}
             :prod {:dependencies [[day8.re-frame/tracing-stubs "0.6.0"]]}}

  :npm-deps [[create-react-class "15.6.3"]
             [react "16.8.6"]
             [react-dom "16.8.6"]
             [react-flip-move "^3.0.4"]
             [react-highlight.js "^1.0.7"]]

  :npm-dev-deps [[shadow-cljs "^2.11.18"]]

  :shadow-cljs {:lein   true
                :builds {:app {:target           :browser
                               :modules          {:app {:entries [xxx.core]}}
                               :output-dir       "resources/public/js/compiled"
                               :asset-path       "/js/compiled"
                               :dev              {:closure-defines {"re_frame.trace.trace_enabled_QMARK_"        true
                                                                    "day8.re_frame.tracing.trace_enabled_QMARK_" true}}
                               :devtools         {:preloads   [devtools.preload
                                                               day8.re-frame-10x.preload]
                                                  :watch-dir "resources/public"}
                               :compiler-options {:optimizations :simple}}}})
#2021-02-2309:15thhellerFor one you are not using the correct CLJS version. That should be 1.10.773 for 2.11.18.#2021-02-2309:15thhellerwhat CLJS version did the figwheel variant use?#2021-02-2309:17thhellerthe cause of this problem will be somewhere in your code but I cannot say where. I vaguely remember some things breaking because of a CLJS update sometime ago but can't remember details#2021-02-2309:20MatiasCLJS version was not changed, so it was the same when I used figwheel. I will update CLJS and report back!#2021-02-2311:12MatiasBumping CLJS version to 1.10.773 did not change behaviour. I'm not ruling out a problem in re-frame/reagent/react that manifested by changing build tools, but I'm at loss so I will ask on #re-frame#2021-02-2311:58thhelleryeah I don't have a clue what could be causing this#2021-02-2311:58thhelleris this with release only or also with development builds?#2021-02-2311:59MatiasI've narrowed it down just now to re-frame not firing off the input events until after the virtual keyboard has been closed the first time for each field or physical keyboard input is given. Not sure why this surfaced now, but that's the issue#2021-02-2312:01MatiasSo I will continue the discussion on re-frame channel if I get stuck again 👍#2021-02-2314:31Jakub Holý (HolyJak)Hello! Is it possible to require a ns only if goog.DEBUG is true? In Clojure I would use requiring-resolve but that is not available in cljs. (I have a library under my :dev alias dependencies that I use during development but do not want to include in production code.) Thank you!#2021-02-2315:14thheller@holyjak :preloads [that.ns] in your :modules or :devtools#2021-02-2315:22Jakub Holý (HolyJak)Thank you! I have now added my.ns as a pre-load and in my code I use
(when goog.DEBUG (my.ns/my-fn))
But will this not complain about unknown symbol my.ns when I run release?
#2021-02-2315:25thhelleryeah you can't do that#2021-02-2315:58Jakub Holý (HolyJak)Ok. So what is a solution when I need to call to the dev-only code from my prod code (but only while running in dev)? Perhaps in the preload I could store the fn in some *dyn-var* that lives in code that is save to share between both and call (when *dyn-var* (*dyn-var*)) in my prod code?#2021-02-2316:03Jakub Holý (HolyJak)I guess I could simply define js/myThing in my dev code and use that from my prod code...#2021-02-2316:05thhellerI cannot answer that without more information. I do not know what you are calling this way and what the code actually does. You cannot dynamically require anything so you'll have to find a different solution.#2021-02-2316:33Jakub Holý (HolyJak)I figured it out. Instead of calling (holyjak.fulcro-troubleshooting/troubleshooting-render-middleware) in my prod code I will call (js/holyjak.fulcro_troubleshooting.troubleshooting_render_middleware) As long as I only do this in dev, it will work.#2021-02-2316:34thhellercan't you just create a ns that you add to preload and that adds the middleware in question? or does it have to be in your app ns?#2021-02-2317:38Jakub Holý (HolyJak)The problem is that it cannot "add the middleware". The prod code has to ask for the middleware. There is, in prod code, something like:
(setup-app {:middleware <some middleware...>})
And my dev-time code is a library so I cannot assume anything about the user's code other than that it has a use for a middleware (as defined by the framework).
#2021-02-2318:58Raymond KoHas anyone seen this kind of error before? A case if works on my local machine, but stopped working on CircleCI. The build user is root so I am not sure why it would fail a file system operation.
nil
IOException: Operation not permitted
	java.io.UnixFileSystem.canonicalize0 (UnixFileSystem.java:-2)
	java.io.UnixFileSystem.canonicalize (UnixFileSystem.java:178)
	java.io.File.getCanonicalPath (File.java:620)
	java.io.File.getCanonicalFile (File.java:645)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:566)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:438)
	shadow.build.node/flush-optimized/fn--18657 (node.clj:224)
	shadow.build.node/flush-optimized (node.clj:212)
	shadow.build.node/flush-optimized (node.clj:209)
	shadow.build.targets.node-library/flush (node_library.clj:194)
	shadow.build.targets.node-library/flush (node_library.clj:189)
	shadow.build.targets.node-library/process (node_library.clj:213)
	shadow.build.targets.node-library/process (node_library.clj:196)
#2021-02-2319:04thhellerodd. is that permanent or just temporary? maybe some disk stuff going on?#2021-02-2319:14Raymond KoInside a :builds target, I had :output-dir "./" :output-to "./handler.js This stopped working for some reason. I changed it to :output-dir "output" :output-to "output/handler.js` and it worked! Removing the trailing / does not make a difference. Must be CircleCI or my updated Docker build image...#2021-02-2319:09Jakub Holý (HolyJak)What could this mean? I have done this for ages and never seen this error - "missing instance" - before:
Connecting to remote nREPL server...
Clojure 1.10.1
(shadow/repl :main)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
missing instance
(I am running npx shadow-cljs watch main ) Restarting Shadow fixed it so it is not a problem anymore but still, it was weird...
#2021-02-2412:39pezIs there a way to configure the compilation progress output to include the files being compiled? So I have things like this in the log
[:dev] Build completed. (451 files, 3 compiled, 0 warnings, 5.12s)
And would like to have the file paths of the 3 compiled files.
#2021-02-2412:41thhellerthe UI might be a better option for that? as far as the CLI is concerned there is only --verbose which is likely too verbose?#2021-02-2412:50pezLooks like I can grep a bit on the verbose output and get what I want.#2021-02-2412:51thhellerwhat do you want? if you actually want to do something with the "data" a build hook might help? https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2021-02-2412:57pezA build hook might do it too. I have the output from the CLI in a terminal pane in VS Code. When I save a file or unstash something and such I like to see when the compilation is done, and also which files have been recompiled. It’s more “for my information” than anything else.#2021-02-2413:21pezTried with this hook now, but don’t see anything in the CLI output.
(defn print-compilation-info [build-state & args]
  {:shadow.build/stages #{:compile-finish :flush}}
  (prn [:build-state build-state
        :args args])
  build-state)
#2021-02-2413:22pezThis in the build conf:
:build-hooks [(env.hooks/print-compilation-info 1 2 3)]
#2021-02-2413:26thhellerehm yeah printing the build-state is not a good idea. it will be several hunderd megabytes 😛#2021-02-2413:26thhelleruse tap> and look at it in the UI#2021-02-2413:26thhelleralso the metadata is misplaced#2021-02-2413:26thhellerbefore the args vector, not after.#2021-02-2413:28pezThat inspector. ❤️#2021-02-2413:29pezWith the metadata map at the right place things started to work of course.#2021-02-2413:31pezWe have just (yesterday) switched to shadow at work for our react native app. I am going to have so much use for the inspector I now realize. Totally wonderful.#2021-02-2413:51pezNot sure I can hook myself to the output I want. Using verbose output it looks like I would want the -> Cache write: foo.cljs rows in addition to the non-verbose output. But i don’t find the info I need in the build-state. You think it is there in any of the stages, @thheller?#2021-02-2414:07thheller@pez well you could replace the logger but I think it is enough if you just get the data you need and print what you want#2021-02-2414:07thhellerfor example
(defn pez-print
  {:shadow.build/state :flush}
  [{:keys [build-sources] :as build-state}]
  
  (let [compiled (get-in build-state [:shadow.build/build-info :compiled])]
    (doseq [src-id build-sources
            :when (contains? compiled src-id)
            :let [rc (get-in build-state [:sources src-id])]]
      (prn [:compiled (:resource-name rc)])))

  build-state)
#2021-02-2414:11pez:shadow-build/build-info :compiled! Thanks. I’m tempted to name the hook like that. 😃#2021-02-2414:12thhelleryeah I need to document the build-state data at some point. kind of a lot of stuff in there 🙂#2021-02-2414:15thhellerrc will also contain all the other info. :file will have the .File instance if you need the full path. :resource-name is just the name on the classpath#2021-02-2414:18thheller(not all sources fill have :file though so make sure you are only accessing it if it exist. won't exist for classpath .jar resources for example)#2021-02-2414:48pezI’ll run with this for now. Many thanks for the help!
(defn print-compiled-files
  {:shadow.build/stages #{:flush}}
  [{:keys [build-sources] :as build-state}]
  (let [compiled
        (get-in build-state
                [:shadow.build/build-info
                 :compiled])
        output
        (->> rc
             :resource-name
             (for [src-id build-sources
                   :when (contains? compiled src-id)
                   :let [rc (get-in build-state
                                    [:sources src-id])]])
             (sort)
             (into [:compiled]))]
    (binding [clojure.pprint/*print-right-margin* 20]
      (clojure.pprint/pprint output)))
  build-state)
#2021-02-2416:15jimmyPosted in #cider and got no bites. Figured I’d repost here: Anyone else have any issues with cider-doc in a shadow-cljs? It is working fine in my clojure repl and in a different project that uses weasel. It isn’t even working for built-in clojure functions.  Toggled messages and just see a (“done” “no-eldoc”). Any ideas?#2021-02-2416:16thhellershadow-cljs doesn't handle eldoc. the cider-nrepl middleware does. did you install that?#2021-02-2416:18jimmyYep, got cider nrepl. Works for all the other projects I’m working on. But for some reason not working in my shadow-cljs project. (Posted in cider first because I know it isn’t shadow-cljs’s fault)#2021-02-2416:21thhellerif you have the cider-nrepl listed as a proper dependency and a new enough shadow-cljs version it should work#2021-02-2416:22thhellerbut I don't use emacs or cider so I cannot help much with debugging#2021-02-2416:24jimmyNo worries. Like I said, not it isn’t shadow’s fault. Just want to see if anyone has run into it. I’m doing a jack-in. (Pasted the wrong one here see comment in thread for correct one) Using shadow version 2.11.17#2021-02-2416:25jimmyMaybe it is a lack of piggieback?#2021-02-2416:26jimmyWait that was the wrong one sorry#2021-02-2416:26jimmy
;;  Startup: /Users/jimmy/.npm-packages/bin/npx shadow-cljs -d nrepl:0.8.2 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.4 server                                                                                                     
43 ;;                                                                                                                                                                                                                                          
44 ;; ClojureScript REPL type: shadow                                                                                                                                                                                                          
45 ;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :frontend) (shadow/nrepl-select :frontend))        
#2021-02-2416:28thhellerlooks fine#2021-02-2416:28dpsuttonand you've connected to the runtime? something like (js/alert "hi") will work? (making sure you're not still in a clojure repl or have connected to the js engine)#2021-02-2416:34jimmyYep, I can eval perfectly fine#2021-02-2416:36dpsuttonm-x nrepl-toggle-message-logging and then try again. you can inspect the nrepl messages to see if there are any clues there#2021-02-2416:37jimmy
(-->
  id         "51"
  op         "eldoc"
  session    "50e453a5-e9b4-4b65-8572-923074485504"
  time-stamp "2021-02-24 11:35:14.713680000"
  ns         #("[my-namespace]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
  sym        "helix/defnc"
)
(<--
  id         "51"
  session    "50e453a5-e9b4-4b65-8572-923074485504"
  time-stamp "2021-02-24 11:35:14.717698000"
  status     ("done" "no-eldoc")
#2021-02-2416:38jimmyDoesn’t matter what symbol. That is what I always get.#2021-02-2416:41dpsuttonm-x cider-describe-session and choose either of the two connections listed (if you only have the one connection at the moment. one is tooling, one is regular interaction). It should open up a buffer with Supported ops: and list what the connection can do. you can see if eldoc and info are supported. also, eldoc is something that happens on hover i think. I think you want to find an op of "info"#2021-02-2416:41dpsutton
(-->
  id         "23"
  op         "info"
  session    "dcdd12ab-8b2e-4411-8096-66c5e103943c"
  time-stamp "2021-02-24 10:40:49.108554000"
  ns         #("metabase.sync.sync-metadata.tables-test" 0 39 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
  sym        "testing"
)
(<--
  id           "23"
  session      "dcdd12ab-8b2e-4411-8096-66c5e103943c"
  time-stamp   "2021-02-24 10:40:49.113750000"
  added        "1.1"
  arglists-str "[string & body]"
  column       1
  doc          "Adds a new string to the list of testing contexts.  May be n..."
  file         "jar:file:/Users/dan/.m2/repository/org/clojure/clojure/1.10...."
  line         597
  macro        "true"
  name         "testing"
  ns           "clojure.test"
  resource     "clojure/test.clj"
  see-also     ("clojure.test/is" "clojure.test/deftest")
  status       ("done")
)
#2021-02-2417:26jimmyYeah, info does the same sort of thing.
(-->
  id         "66"
  op         "info"
  session    "50e453a5-e9b4-4b65-8572-923074485504"
  time-stamp "2021-02-24 12:24:05.124286000"
  ns         #("[my-ns]" 0 40 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
  sym        "helix/defnc"
)
(<--
  id         "66"
  session    "50e453a5-e9b4-4b65-8572-923074485504"
  time-stamp "2021-02-24 12:24:05.127422000"
  status     ("done" "no-info")
)
I do have two sessions. One shows me a big long list including eldoc and info. But the session listed above “50e453a5-e9b4-4b65-8572-923074485504” literally doesn’t open up anything when I do a cider-describe-nrepl-session
#2021-02-2417:31dpsuttonhmm. i can look into this tonight to see if i can reproduce. don't have time until then. sorry about this issue though#2021-02-2417:37jimmyI think I figured out a commonality. Most of them that aren’t working are macros. There are non-macros that are working. (At first I thought none were working, I just kept accidentally trying macros)#2021-02-2615:02fsdHello Good Morning, I needed a little help, how do I make shadow-cljs react application support old browser such as Internet Explorer (IE)#2021-02-2615:43thhellerthat entirely depends on what is causing it not to work. maybe you need to add some polyfills. maybe :compiler-options {:output-feature-set :es3} in your build config works.#2021-02-2615:44thhelleris it breaking in some npm library? does it break in your code? there is unfortunately no easy answer to this if the above is not enough.#2021-02-2616:07fsd@thheller this is what I get
#2021-02-2616:12thhellerdoes the release build work? watch doesn't need to work and has no priority to work.#2021-02-2616:21fsdI only used yarn start I am new to shadow cljs How do I run that command?#2021-02-2616:25thhellerwhat does yarn start do? what template did you use? normally just shadow-cljs release <your-build-id>#2021-02-2616:35fsdyarn postcss && shadow-cljs watch app#2021-02-2616:36thhellerso shadow-cljs release app#2021-02-2616:41fsdYes#2021-02-2709:12WestSo I’m trying to get a CIDER repl working with shadow-cljs. The way I launch it is by indirectly, through another script in package.json, doing shadow-cljs watch main renderer. I can seem to do cider-connect-cljs just fine, but I can’t evaluate any functions or send anything to the repl. Maybe this is a better question for #emacs?#2021-02-2709:13thhellerwhat happens if you do? I can't really answer emacs/cider questions but maybe I can give a hint depending on what happens#2021-02-2709:17WestSo shadow starts a server just fine. Then I can see live changes when I edit the source. I can’t seem to be able to send anything to the repl though. I found about this thing called piggieback so I added it as a dependency, but is that really the problem?#2021-02-2709:45WestWARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information) I wonder if this has anything to do with the problem. I even checked out the URL where it says “(https://docs.cider.mx/cider/troubleshooting.html#cider-complains-of-the-cider-nrepl-version)” but it didn’t really help.#2021-02-2709:51thhellerwell did you add cider-nrepl to your dependencies?#2021-02-2709:51WestNevermind. Turns out I had the incorrect cider version.#2021-02-2709:51WestI had cider/nrepl not cider/cider-nrepl.#2021-02-2709:51thhellerah#2021-02-2714:26p-himikI'm using ANTLR4 4.9.1 that AFAICT generates ES6 classes with static members which seem to upset shadow-cljs:
220 | 
 221 | export default class ABCMusicLexer extends antlr4.Lexer {
 222 | 
 223 |     static grammarFileName = "ABCMusic.g4";
---------------------------------^----------------------------------------------
'(' expected
--------------------------------------------------------------------------------
To add more details - I just call ANTLR4's code to generate some JS files that I include in my CLJS files and then I call shadow-cljs to build it all. Is there any way to compile such classes?
#2021-02-2714:29thhellerit doesn't upset shadow-cljs. that is the closure-compiler complaining.#2021-02-2714:30thhellerprobably just doesn't support static class properties yet#2021-02-2714:31p-himikI assume it means that I have to either use Babel or something like that or downgrade ANTLR4 to the point when it wasn't emitting such code, right?#2021-02-2714:40p-himikFWIW /cdn-cgi/l/email-protection works fine since it emits ES5 code, so I'll settle on it.#2021-02-2716:56thhellerhttps://github.com/google/closure-compiler/issues/3477#2021-02-2716:56thheller> FYI, static class fields are currently in stage 3 of the TC39 process, so they aren't officially part of the language yet.#2021-02-2717:14p-himikRight, thanks!#2021-02-2808:57johnjelinek
(def my-stack #(let [stack %
                     _ (DockerProvider. stack "default")
                     image (Image. stack "nginxImage" {})
                     container (Container. stack "nginxContainer" {} #_{:ports [{:internal 80
                                                                                 :external 8000}]})]
                 (set! (.-name image) "nginx:latest")
                 (set! (.-keepLocally image) false)
                 (set! (.-image container) (.-latest image))
                 (set! (.-name container) "tutorial")
                 #_(set! (.-ports container) {"internal" 80
                                            "external" 8000})))
I should be able to set opts for these js interop objects like this:
(Container. stack "nginxContainer" {:port [{:internal 80 :external 8000}])
but this isn't working and so I'm having to use (set! -- any idea why that's not working?
#2021-02-2808:57johnjelinekI don't seem to be getting any errors, but the values just aren't getting set during runtime#2021-02-2808:59johnjelinekside-note: the actual ports example fails either way (with or without set!) -- the error there is that it can't seem to map over [{,,,}]#2021-02-2809:27thhellerfirst of all. why is this a def with an anonymous function? makes its terribly hard to read.#2021-02-2809:28thheller(Container. stack "nginxContainer" {:port [{:internal 80 :external 8000}]) I assume Container is some JS Object and you are passing a CLJS map as an argument which it very likely won't understand#2021-02-2809:28thhelleruse (Container. stack "nginxContainer" (clj->js {:port [{:internal 80 :external 8000}]))#2021-02-2809:29thhellerthe last commented out set! has the same issue. trying to pass a CLJS map to any JS object will either fail directly or fail silently since they all expect plain JS objects#2021-02-2809:30thhelleryou can also construct JS objects directly via #js {:foo "bar"}#2021-02-2815:23johnjelinek@U05224H0W: thanks! clj-js worked! #js {,,, did not#2021-02-2815:34johnjelinekah, if I'm doing #js, I gotta apply it more liberally:
(Container. stack "nginxContainer" #js {:image (.-latest image)
                                              :name "tutorial"
                                              :ports #js [#js {:internal 80
                                                               :external 8000}]})
#2021-02-2815:36johnjelinek😆 this should address your first-of-all:
(defn my-stack [app name]
  (let [stack (TerraformStack. app name)
        image (Image. stack "nginxImage" #js {:name "nginx:latest"
                                              :keepLocally false})]
    (DockerProvider. stack "default")
    (Container. stack "nginxContainer" (clj->js {:image (.-latest image)
                                                 :name "tutorial"
                                                 :ports [{:internal 80
                                                          :external 8000}]}))))
#2021-02-2815:37johnjelinekthank you again for your help!#2021-02-2815:43thhelleryeah #js doesn't apply to nested values so clj->js is better for more complex structures where you don't care about performance#2021-02-2814:46nmkipHi, I'm trying to make a simple chrome extension but I'm having some problems with the initial setup of the project. When I watch the :extension build and then open the url that I'm matching in my shadow-cljs.edn I'm getting the following error multiple times:
browser.cljs:406 WebSocket connection to '' failed: Unknown reason
shadow$cljs$devtools$client$browser$ws_connect_impl @ browser.cljs:406
shadow$cljs$devtools$client$browser$ws_connect @ browser.cljs:388
browser.cljs:20 🠶 shadow-cljs: websocket error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
browser.cljs:20 🠶 shadow-cljs: WebSocket disconnected!
It keeps trying to reconnect and always fails. I'm using binaryage/chromex shadow example as my template with some changes: • Removed deps.edn • Removed all dependencies • Changed the :content-script :matches to a specific url instead of <all_urls> More info in thread 🧵
#2021-02-2814:47nmkipThis is how my shadow-cljs.edn file looks like:
{:source-paths ["src/background"
                "src/popup"
                "src/content-script"]

#_#_ :dependencies [[binaryage/chromex "RELEASE"]
                [binaryage/devtools "RELEASE"]]
 
 :builds {:extension

          {:target           :chrome-extension
           :extension-dir    "resources/unpacked"
           :manifest-file    "resources/unpacked/manifest.edn"
           :compiler-options {; 
                              :closure-output-charset "US-ASCII"
                              ; we need to fully inline source maps to avoid devtools security restrictions of loading .map
                              ; files via chrome-extension://<extension-id>/out/cljs-runtime/goog.debug.error.js.map urls
                              :source-map-inline      true}
           :outputs          {:background     {:output-type :chrome/background
                                               :entries     [chromex-sample.background]}
                              :content-script {:output-type    :chrome/content-script
                                               :chrome/options {:matches [""]
                                                                :run-at  "document_end"}
                                               :entries        [chromex-sample.content-script]}
                              :popup          {:output-type :chrome/shared
                                               :entries     [chromex-sample.popup]}}}}}
#2021-02-2814:47nmkipThis is how my manifest.edn file looks like:
{:name             "Test chrome extension"
 :version          "1.0"
 :description      "Test chrome extension"
 :manifest-version 2

 :permissions      ["http://*/*"
                    "https://*/*"]

 :browser-action   {:default-title "Show the popup"
                    :default-icon  "images/icon48.png"
                    :default-popup "popup.html"}

 :content-security-policy
                   ["default-src 'self';"
                    ;; FIXME: unsafe-eval should be injected for dev, user shouldn't have to write this
                    "script-src 'self' 'unsafe-eval' ;"
                    "connect-src * data: blob: filesystem:;"
                    "style-src 'self' data: chrome-extension-resource: 'unsafe-inline';"
                    "img-src 'self' data: chrome-extension-resource:;"
                    ;; FIXME: localhost only? don't want to allow any origin though
                    "frame-src 'self' :* data: chrome-extension-resource:;"
                    "font-src 'self' data: chrome-extension-resource:;"
                    "media-src * data: blob: filesystem:;"]}
#2021-02-2815:41thheller> failed: Unknown reason #2021-02-2815:41thhellerthere must be a reaon. dunno how you find out what 😛#2021-02-2815:42nmkipThere's probably a reason xD#2021-02-2815:43nmkipand it's probably my fault 😛#2021-02-2815:44thhellerconfig looks ok. does it work if you change the :matches?#2021-02-2815:45nmkipI believe the :matches is working as I'm only getting shadow error messages in this site: https://classroom.google.com/u/0/ta/not-reviewed/all#2021-02-2815:47nmkip#2021-02-2815:52nmkipIt works if I use :matches [""]#2021-02-2815:54nmkipshadow-cljs connects to the websocket and if I eval a println in the content_script.cljs I can see it in the console#2021-02-2815:54thhellerwell yeah it must be allowed to connect to the shadow-cljs server for the REPL and hot-reload stuff#2021-02-2815:54thheller(for development builds, ie. watch and compile)#2021-02-2815:55thhellerrelease can and should be stricter#2021-02-2815:55nmkipand how do I allow it?#2021-02-2815:56thhellerits an array so just add multiple things#2021-02-2815:56nmkipwhat array are you talking about?#2021-02-2815:56thheller:matches ["" ":*/*"] probably#2021-02-2815:59nmkipUsing this shadow-cljs connects to the websocket in localhost, but I get the websocket error in google classroom#2021-02-2816:00nmkipThis is the localhost console:#2021-02-2816:00nmkipThis is google classroom console:#2021-02-2816:01nmkipAnd this is the shadow-cljs.edn file:
{:source-paths ["src/background"
                "src/popup"
                "src/content-script"]

 #_#_:dependencies [[binaryage/chromex "RELEASE"]
                    [binaryage/devtools "RELEASE"]]

 :builds {:extension

          {:target           :chrome-extension
           :extension-dir    "resources/unpacked"
           :manifest-file    "resources/unpacked/manifest.edn"
           :compiler-options {:closure-output-charset "US-ASCII"
                              :source-map-inline      true}
           :outputs          {:background     {:output-type :chrome/background
                                               :entries     [chromex-sample.background]}
                              :content-script {:output-type    :chrome/content-script
                                               :chrome/options {:matches ["" ""]
                                                                :run-at  "document_end"}
                                               :entries        [chromex-sample.content-script]}
                              :popup          {:output-type :chrome/shared
                                               :entries     [chromex-sample.popup]}}}}}
#2021-02-2816:02thhellertry ":*/*" instead of ""#2021-02-2816:03thhellernot a clue really. been a while since I looked at any of this. maybe chrome got stricter security restrictions these days#2021-02-2816:03thhellerdo you still have some csp rules in your HTML maybe?#2021-02-2816:05nmkipI'm using brave browser I don't know if that's a problem#2021-02-2816:05thhellermight be. not a clue, never used it.#2021-02-2816:06nmkipAs far as I know brave uses the same extensions as chrome.#2021-02-2816:06nmkipI will download chrome and try there.#2021-02-2816:08thhellermore likely that something in your config doesn't quite match#2021-02-2816:09thhellerwhat about your html?#2021-02-2816:09thhelleris there any?#2021-02-2816:09nmkipthe only html is the popup, just a hello world 😛#2021-02-2816:09thhellerok, does that have some csp rules?#2021-02-2816:09thheller<meta name="Content-Security-Policy" ...>#2021-02-2816:10nmkipnope#2021-02-2816:10thhellerthen I'm out of ideas#2021-02-2816:11nmkipokay, no problem! Thanks a lot 🙂 I'll try a bit more and if I fail I'll just use javascript and suffer 😛#2021-02-2816:12thhellerwell the websocket is only used for hot-reload and REPL. if you don't care about those then you can just set :devtools {:enabled false} and it won't try to connect#2021-02-2816:13nmkipgood to know , maybe Ill do that#2021-02-2817:38nmkip@U05224H0W I've noticed that I'm having this problem with https sites#2021-02-2817:56thhellerhmm yeah that might be a reason. might need to setup ssl for shadow-cljs so is all ssl#2021-02-2815:57nmkipI tried that#2021-02-2818:42naomarikHas anyone got react-native project going using WSL2? I'm wondering how/where the port from the app (below 50594 and 50612) is being determined so I can forward it properly to my WSL2 instance:
[Sun Feb 28 2021 22:39:55.649]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /172.25.210.33 (port 9630) from /192.168.0.166 (port 50594) after 10000ms"}
[Sun Feb 28 2021 22:40:10.782]  WARN     The shadow-cljs Websocket was disconnected.
[Sun Feb 28 2021 22:40:10.792]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "failed to connect to /172.25.210.33 (port 9630) from /192.168.0.166 (port 50612) after 10000ms"}
[Sun Feb 28 2021 22:40:10.852]  LOG      giving up trying to connect
#2021-02-2818:45thhellerthat is the port of the react-native app client. you don't need to do anything for that port as it will be random always#2021-02-2818:45thhelleryou just need to be able to connect from the app to shadow-cljs. looks like that is trying to use the wrong IP#2021-02-2818:46naomarikyeah it's using the IP internally from WSL2... I have adb tcpip running from windows then within WSL2 adb connect to connect to the device#2021-02-2818:46thhellershadow-cljs watch app --config-merge '{:local-ip "1.2.3.4"}' lets you set a specific one#2021-02-2818:48naomarikthat worked 😉#2021-02-2818:49naomarikI can't just add the local-ip key within my shadow-cljs.edn ?#2021-02-2818:49naomarikI tried that first and didn't seem to do anything#2021-02-2818:49thhellercurrently needs to go into the build config#2021-02-2818:49thhellerstill need create a better way to control all this#2021-02-2818:50naomarikcool that works too#2021-03-0114:24thhellersometimes you really have to wonder what the closure-compiler is doing to the code when this is the "best" pseudo-name it can come up with for a local variable is
$G__37663_G__37667_G__37671_G__37675_G__37682_G__37686_G__37691_anchor_37656_old_coll_37645_old_items_37652$
$G__37664_G__37668_G__37672_G__37676_G__37683_G__37687_G__37692_idx_37657_new_len_37651$$ 
#2021-03-0114:39raspasovIt might be processing it through 7 dimensions 😝 (based on the number of G’s)#2021-03-0114:26thhellerI mean I know how it comes up with those but it is still kinda spooky to see sometimes#2021-03-0118:50Alexis Vincent@thheller Is there an application level fix I can apply to get around -> https://github.com/thheller/shadow-cljs/issues/846#issuecomment-788183542#2021-03-0118:52thhelleryou can put a cljs/closure.clj with just (ns cljs.closure) on your classpath#2021-03-0118:53thhellerthen you can update the closure-compiler version which has the fix#2021-03-0118:53thheller(in theory, haven't tried)#2021-03-0118:53thhellermaybe this branch of CLJS also works https://github.com/clojure/clojurescript/tree/bump-closure#2021-03-0118:53Alexis VincentBeing thrown when Closure hits @stitches/react , required by https://github.com/pmndrs/leva , I’ve tried setting
{:js-options {:resolve {"@stitches/react" {:target :npm
                                             :require "@stitches/react/dist/stitches.react.esm.mjs"}}}})
but that doesnt seem to actually change the file being resolved as can be seen
#error {
 :cause closure errors
 :data {:tag :shadow.build.closure/errors, :errors [{:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 1218, :msg Class names defined inside a function cannot be reassigned.} {:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 1229, :msg Class names defined inside a function cannot be reassigned.} {:resource-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :source-name node_modules/@stitches/react/dist/stitches.react.cjs.cjs, :line 2, :column 4095, :msg Class names defined inside a function cannot be reassigned.}]}
#2021-03-0118:53thhellerDavid is working on this currently#2021-03-0118:54Alexis VincentThanks. Will see what I can get right#2021-03-0119:00fsdIs it possible to view shadow cljs React App on a Mobile Device that is connected to same network?#2021-03-0119:01thhellersure. just open it in the browser. just need to know the IP of your machine.#2021-03-0119:05fsdPerfect thanks man :) #2021-03-0119:06Alexis VincentUsing bump-closure I hit
Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).
com.google.javascript.jscomp.AnonymousFunctionNamingPolicy
Do you see a quick fix? Or should I wait. Seems like David is pretty active on the branch
#2021-03-0119:06thhellerneed to update shadow-cljs too 🙂#2021-03-0119:07thhelleroh nevermind. I haven't released the version with the fix yet.#2021-03-0119:07thhellerhang on I can do that now#2021-03-0119:09Alexis Vincent🎉 🙏#2021-03-0119:14thheller@mail024 2.11.19 should fix that#2021-03-0119:14Alexis VincentShweeeet. Will give it a go#2021-03-0119:20Alexis Vincent
The required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".
might be another removal
#2021-03-0119:20Alexis VincentAgainst bump-closure#2021-03-0119:22thhellerdon't bump the closure library for now#2021-03-0119:22thhellerclosure-compiler is enough#2021-03-0119:23Alexis VincentAh, I’m just using David’s branch. Dont really know what you mean by the cljs/closure.clj thing.#2021-03-0119:24Alexis VincentDo i just add an exclude and drop the dep down#2021-03-0119:24Alexis Vincent
org.clojure/google-closure-library {:mvn/version "0.0-20201211-3e6c510d"}
#2021-03-0119:25thhelleryou put the file on the classpath. meaning you take one of your source-paths and put the file there#2021-03-0119:25thhellersrc/main/cljs/closure.clj or so#2021-03-0119:25thhellerthen you can stick with older CLJS version or rather the current 1.10.773#2021-03-0119:25Alexis VincentNo i get that. But im not sure what to put inside. When i found the file in the clojurescript repo it looked very long#2021-03-0119:25Alexis Vincentmaybe i found the wrong one#2021-03-0119:25thhelleras I said ... just (ns cljs.closure) nothing else#2021-03-0119:25thhellershadow-cljs does not use that file at all, so it can be empty#2021-03-0119:26Alexis VincentOh right.#2021-03-0119:26Alexis Vincentcool#2021-03-0119:26thhellerit is nrepl piggieback loading that file so if you don't need that then you don't need to worry about that at all either#2021-03-0119:26Alexis Vincentthanks. Will give that a go#2021-03-0119:26thhellerbut since nrepl is started by default its best to just replace the file temporarily#2021-03-0119:28thhelleroh and it might matter which tools.deps version you use too. since older versions didn't put source-paths first this trick might not work there#2021-03-0119:28thhellercurrent version should though#2021-03-0119:28thhellerbasically by putting it one the :paths (or :source-paths if just shadow-cljs.edn) you are "overwriting" the file in the clojurescript released jar#2021-03-0119:29Alexis VincentYeah. With you on that! Just thought i needed to overwrite the file with something useful.#2021-03-0119:29Alexis VincentThanks!#2021-03-0119:30Alexis VincentWhoop whoop!!! It compiled without errors on the new closure compiler!#2021-03-0119:31Alexis VincentThanks @thheller. Appreciate it!#2021-03-0210:13tomrbowdenI’m experimenting with self-hosted cljs in the browser, bootstrapped with shadow-cljs. I’m evaluating cljs typed into a textarea, eval’ed with the on-change event (debounced by a few hundred milliseconds). It works fine mostly, however, I’ve noticed that when typing in forms/expressions that yield infinite lazy sequences, the browser seizes up and stops responding. For example, typing (range) causes this behavior. Are there any good strategies for dealing with this?#2021-03-0210:14thhellerdon't eval infinite sequences? 😛#2021-03-0210:14thhellerI'm guessing you call pr-str or so on the result?#2021-03-0210:29tomrbowdenI use cljs/eval-str and show the result in a div#2021-03-0210:31tomrbowdenThe problem I have is that I can’t prevent users of the web-app from evaluating infinite series that they’ve input into the textarea…#2021-03-0210:33tomrbowdenIs there a way to force-kill the infinite evaluation? (like hitting Ctrl-C when hitting an infinite loop in a command-line REPL?)#2021-03-0210:33thhellerwell HOW do you display it in a div? I assume pr-str? THAT is were your infinite sequence is realized#2021-03-0210:34thhellerso that is the problem you need to solve#2021-03-0210:34thhellereg. you can set *print-length* to limit the amount of items printed#2021-03-0210:34thhellernot exactly sure how you do that in self-hosted but something to look into#2021-03-0210:37tomrbowdenNo, I simply do this:
(defonce evaluated-output (r/atom nil))

(defn compile-it [code]
  (let [options  {:eval cljs/js-eval
                  :load (partial boot/load c-state)}
        callback (fn [result]
                   (reset! evaluated-output (:value result)))]
    (cljs/eval-str c-state code "[demo-bootstrap-cljs]" options callback)))
and then I render it:
[:pre>code "Output: " [:strong (str @evaluated-output)]]
#2021-03-0210:37thheller(str @evaluated-output)#2021-03-0210:37tomrbowdenYes, I see what you’re saying now#2021-03-0210:37thhellershould be using pr-str in either case but str is the same in this case#2021-03-0210:38thheller(binding [*print-length* 5] (pr-str @evaluated-output)) might be enough#2021-03-0210:38tomrbowdenI’m not clear what the difference it, but I will put pr-str then#2021-03-0210:38thhellerpr-str produces EDN output#2021-03-0210:38thhellerstr calls toString (which will not always be EDN)#2021-03-0210:40tomrbowdenThat works perfectly! You’re awesome, @U05224H0W Thanks so much!!!#2021-03-0211:26yuhanIs there any way to get shadow-cljs to watch and hot-reload changes to index.html?#2021-03-0211:28thhellerno#2021-03-0211:39yuhanThanks! Some note of this in the documentation would be great - it's not so clear what "monitor your source files and recompile them automatically" encompasses exactly#2021-03-0300:21JasonIs it possible to specify a path to shadow-cljs.edn in the command line?#2021-03-0300:23lsenjovWorkaround if not:
npx shadow-cljs --config-data "$(cat /path/to/shadow-cljs.edn)"
#2021-03-0300:27JasonI'm trying to sort out multiproject monorepo deps, so i am trying to start via chained namespaces and`clj`like :
clj -M:defaults:dev:ui -A:shadow-cljs watch app 
but I need to say which subproject's app build i mean and have all the paths work out.
#2021-03-0300:28Jasonso I can't do it with npx#2021-03-0301:37JasonOr can one add extra :source-paths per build?#2021-03-0308:05thheller@jasonhlogic this is not possible. either put a separate shadow-cljs.edn into each project or use one at the root#2021-03-0308:06thhelleralso separating depedencies per build is not something you need to do per build#2021-03-0308:06thhellereach build only uses whatever the build actually requires in the namespaces. you can have thousands of extra dependencies on the classpath, they won't matter as they won't be used.#2021-03-0322:47denik@thheller I’m exploring a system where frontend code is generated by the backend and would need to be compiled on the fly. All dependencies of that code would already exist on the frontend. One example is sending a react component as hiccup with handlers that call into frontend code. The backend sends:
'[:input {:type          "text"
          :default-value "foo"
          :on-change     (fn [e]
                           (frontend-ns.state/assoc-in id (.. e -target -value)))}]
which on the frontend should result in a CLJS hiccup vector where the function is a js function compiled from the CLJS counterpart.
#2021-03-0407:33dpsuttonwe're working on adding an :npm-module output into a webpacked js frontend at work. One footgun is that forgetting to mark things with ^:export has no consequence during dev time but is obviously catastrophic at release time. Is it possible to have the dev build munge names so that we can kinda feel this pain under dev settings and not just in CI or (gasp) released?#2021-03-0408:14thheller@dpsutton no, the closure compiler does the munging and that is not used in dev builds#2021-03-0408:14thhelleryou might want to use :target :esm. there the exports are configured in the build config so no ^:export there#2021-03-0408:16dpsuttonyeah that builds up a big build config so probably better to just go with ^:export#2021-03-0408:17dpsuttonalso, is there a way to get around enumerating every namespace in the :entries vector? Basically everything will be compiled either directly or transitively so would be nice to just get all namespaces for free.#2021-03-0408:18dpsuttoni was a cljs dev for 3 or so years and i'm excited that i'll finally be able to use shadow in a work product. its all been lein-figwheel because the projects were set up when that was the only game in town and wasn't worth changing over#2021-03-0408:18thheller@denik that is not possible if you want to use :advanced optimizations (which you should for browser builds). with one small adjustments you can just interpret the EDN though: turn functions into actual data. for [example](https://github.com/thheller/shadow-cljs/blob/f0a2ae8e9cfdbadc19641bd89327b3fb496733d3/src/main/shadow/cljs/ui/components/inspect.cljs#L107) in the stuff I'm building you'd say :on-click {:e :some.ns/foo! :with "some" :other "args" :maybe true} (just data). yes that limits you to only using events that already exist but that might be enough for you#2021-03-0417:25denikmakes sense. thanks @thheller!#2021-03-0408:19thheller@dpsutton I recently changed the logic back so that an emptry :entries [] is allowed again#2021-03-0408:19thhellerthat'll just give you all found namespaces#2021-03-0408:19dpsuttonoh nice. i saw a spec error that indicated it needed at least one simple simple. maybe we need a newer version#2021-03-0408:47ribelo@denik I did something very similar for fun. I had a re-frame on the front. Using sente I both passed hiccup data that was written to the db, and instead of sending functions, I sent re-frame event keys. If you wanted to send functions though, you could use sci#2021-03-0417:26denikinteresting idea to use sci! I’ll ponder it#2021-03-0409:39ribeloreagent interprets hiccup in runtime, so you can fetch data from the db and simply render it when received.#2021-03-0414:07mkvlr@thheller you recomment letting shadow bring in the ClojureScript dep, correct? Asking because I want to give https://github.com/clojure/clojurescript/commit/715cdc07dbb1d595af91ea12affb6faf0b615d4b a try#2021-03-0414:13mkvlrdo you expect issues when requiring a cljs version explicitly?#2021-03-0414:22mkvlrseeing this now:
Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).
com.google.javascript.jscomp.AnonymousFunctionNamingPolicy
#2021-03-0414:38mkvlroh, I see that’s fixed by bumping shadow and getting https://github.com/thheller/shadow-cljs/commit/d0451aba279689bc74ae5340e83b2466e4bdb237#2021-03-0416:20thhellerit might work if you use master yes. I still haven't checked all the closure-library/compiler related changes and verified they work#2021-03-0416:20thhellerthat AnonymousFunctionNamingPolicy issue is fixed but there might be others I'm not yet aware of since the closure-lib has undergone some rather big changes too#2021-03-0416:24thhellerI'll likely test the CLJS master myself later or tomorrow if you want to wait 😉#2021-03-0421:43thhellertested CLJS master with the latest closure-compiler and library and everything appears to work fine#2021-03-0501:53Cam Saulsorry if this is a dumb question, but I searched all over the place and couldn't find an answer to it. I have a small namespace I'm exporting as an :npm-module and using in JavaScript code... when I try to run our existing Jest unit tests for the JavaScript code, the JS file that's loading the the CLJS file is failing with
● Test suite failed to run

    Namespace "goog.math.Long" already declared.

      at Object.<anonymous>.goog.module (frontend/src/cljs/cljs_env.js:124:13)
      at frontend/src/cljs/goog.math.long.js:14:8
      at Object.<anonymous>.goog.loadModule (frontend/src/cljs/cljs_env.js:322:27)
      at Object.<anonymous> (frontend/src/cljs/goog.math.long.js:12:6)
      at Object.<anonymous> (frontend/src/cljs/cljs.core.js:4:1)
      at Object.<anonymous> (frontend/src/cljs/metabase.types.js:4:1)
      at Object.<anonymous> (frontend/src/metabase/lib/types.js:13:29)
Any idea what I might be doing wrong? I'm importing the CLJS code into the JS code like
import { isa, TYPE } from "cljs/metabase.types";
This works fine everywhere except for when I go to run the Jest unit tests
#2021-03-0507:20thheller@camsaul do you maybe have two different builds you are loading this way? or is there only one :npm-module build?#2021-03-0507:21thhellerthat error you get when trying to load 2 separate CLJS builds into the same "global" context. they'll clash and interfere with each other so that really shouldn't be done#2021-03-0507:32thhellercould also just be Jest loading things in a strange way. not exactly sure how jest works.#2021-03-0507:33thhellerit likely works in release builds since they don't share anything global#2021-03-0510:40mkvlr@thheller we got everything working after a shadow upgrade and another unrelated fix, thanks for having fixed things before we even asked for them!#2021-03-0512:35sbHello, I would like to create a clojure/script lib. I can solve the cljs part with shadow-cljs. My question is, of course I can push to Clojars libs, .. if I would like to push with .cljc files (cljs part with shadow-cljs), how do I need to setup the leiningen? or that isn’t possible (use from cljs part if somebody add my lib, or better add a separated cljs-lib)? (sorry for noob question in this topic, maybe somebody did similar, good one example, github repo) Thanks in advance! #justbeforeIstart#2021-03-0512:50raspasovhttps://github.com/clojars/clojars-web/wiki/Pushing#2021-03-0512:52raspasovAlso look at clj-new for a library template (just used it the other day, I also don’t publish libs too often) https://github.com/seancorfield/clj-new#2021-03-0512:55sbmy question is, if I add shadow-cljs to cljs part.. for the lib, is that will work problem less if .. somebody will add.. who didn’t use shadow-cljs just cljs? Just I didn’t see good simple example#2021-03-0512:56sbeg https://github.com/day8/re-frame-debux, but not so good example.. I would like to create an api lib, which will work from clj and cljs (but in cljs rs256 signing works just with npm libs)#2021-03-0512:57sbgoogle crypt.. don’t have rs256 signing#2021-03-0512:58sbmaybe a bad question, I just try out#2021-03-0513:38thhellershadow-cljs is not relevant when publishing libraries#2021-03-0513:38thhellerall you need is something that puts the .cljs files into a .jar#2021-03-0513:38thhellerthey don't need to be compiled or anything#2021-03-0513:39thhellerI use lein and just have the files as usual on the :source-paths#2021-03-0513:40sbOk, thanks the info!#2021-03-0521:30kommenafter bumping ClojureScript to https://github.com/clojure/clojurescript/commit/69b66374d857a176c5a9cd8cc0cbb7506876640d we’re running into compile errors seemingly related to shadow:
IllegalArgumentException: No matching method setOriginalPath found taking 1 args for class com.google.javascript.jscomp.SourceFile$Preloaded
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/convert-sources-simple*/iter--86592--86596/fn--86597/fn--86598 (closure.clj:1855)
	shadow.build.closure/convert-sources-simple*/iter--86592--86596/fn--86597 (closure.clj:1830)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5402 (core.clj:137)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8146 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/reduce (core.clj:6828)
	clojure.core/into (core.clj:6895)
	clojure.core/into (core.clj:6887)
	shadow.build.closure/convert-sources-simple* (closure.clj:1859)
	shadow.build.closure/convert-sources-simple* (closure.clj:1826)
	shadow.build.closure/convert-sources-simple (closure.clj:2117)
	shadow.build.closure/convert-sources-simple (closure.clj:2069)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1169)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1162)
	shadow.build.compiler/compile-all (compiler.clj:1414)
#2021-03-0521:31kommendidn’t have that with ClojureScript at https://github.com/clojure/clojurescript/commit/715cdc07dbb1d595af91ea12affb6faf0b615d4b#2021-03-0521:34thhellerits the closure-compiler changing stuff again#2021-03-0521:34thhellercan't fix that until there is an official CLJS release that works with newer closure-compiler versions#2021-03-0521:35thhellerjust downgrade closure-compiler to v20210202#2021-03-0521:41thhelleractually I might be able to fix it. the alternative way of working with SourceFile is rather old so it might be ok. will see tommorrow#2021-03-0619:21mkvlrit’s fixed with https://github.com/thheller/shadow-cljs/commit/f5d8fec986afba3432019fe8d6eb7ef9ccf946aa, thank you!#2021-03-0612:50Phil JacksonHey. Is there a trick for getting typehints to things in a go block?#2021-03-0612:51Phil Jackson#2021-03-0612:52Phil JacksonIf I put the right hint (I think) where it should go (I think), it doesn't fix things for me.#2021-03-0612:57thhellerunfortunately core.async loses typehints#2021-03-0612:57Phil JacksonOh no.#2021-03-0612:58Phil JacksonOk. Back to promises. Thanks for the swift reply.#2021-03-0613:03Phil JacksonActually, I can just wrap the culprits...#2021-03-0619:01alexHi there - any tips for introspecting app state via the REPL when you have 2 browser clients connected? For example, I have a user via regular Chrome window + a second user via incognito Chrome window. The browser runtime for the REPL seems to default to whichever browser client connects first, which makes sense... but I'm curious if it's possible to look at both?#2021-03-0619:07thheller@alex.na you can switch the REPL by specifying the :runtime-id. so (shadow/repl :app {:runtime-id 123})#2021-03-0623:19alexAwesome -- thanks a lot thomas!#2021-03-0619:07thhellerthe runtime id is printed on connect in the console. or you can find in the UI http://localhost:9630/runtimes. inspect and tap> might also be useful#2021-03-0812:30Iheatu WoguI’m trying to run
:test-ci {:target  :node-test
                          :output-to "out/node-test/js"
                          :autorun "true"
                          :js-options {:resolve {"devcards-marked" {:target :npm :require "marked"}
                                                 "devcards-syntax-highlighter" {:target :npm :require "highlight.js"}}}}}
but I get
[:test-ci] Compiling ...
The required namespace "devcards-marked" is not available, it was required by "devcards/util/markdown.cljs".
I’m quite unsure what I might have done wrong
#2021-03-0814:51Dan MaltbieI have two packages, one is the app and the other is a library on which it depends. This library is actually a dual CLJ/CLJS library. For development ease with Clojure using leiningen, I can set a soft link to the library package directory from the app package directory (in the checkouts subdirectory of the app package directory). Is there a way to do something like this for development purposes with shadow-cljs where the app is a CLJS program? Or other ways to simplify development with local package dependencies?#2021-03-0820:48thhellerwell the easy answer is "just use lein" if you have that setup anyways#2021-03-0820:48thhellershadow-cljs.edn itself doesn't support checkouts or so. you could just add :source-paths to the proper places#2021-03-0821:11Dan MaltbieSorry for confusion, I use lein for JVM code and Shadow-cljs for JS. I'll check out :source-paths and see if that can work for me. thanks!!#2021-03-0821:13thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2021-03-0821:13thhellerjust let lein manage the classpath I meant. CLJS related things will still be handled by shadow-cljs#2021-03-0918:07Dan MaltbieIt's like peeling the layers of an onion... Thanks for the pointer. Looks like something that should help.#2021-03-0918:09Dan Maltbieshadow-cljs is awesome!#2021-03-0819:26flowthingThe simplest way that I know of to get a JVM ClojureScript REPL that I can connect my editor to (basically, just a REPL without a prompt) is to start a Clojure socket REPL (e.g. via the system property) and do something like this:
((requiring-resolve 'cljs.repl/repl)
  ((requiring-resolve 'cljs.repl.browser/repl-env))
  :need-prompt (constantly false)
  :prompt (constantly ""))
But what if I have shadow-cljs in the mix? Does shadow-cljs expose a repl-env that I can pass to cljs.repl/repl? The most straightforward method I know of is to start a Clojure socket REPL and call (shadow.api/repl :id), but there doesn't seem to be a way to disable the prompt. Also, promoting a Clojure REPL to a ClojureScript REPL is rather problematic as far as editor integrations go, because it's difficult for the editor to know whether it's in Clojure or ClojureScript mode. I'd rather have a whole separate socket connection for the ClojureScript REPL, but I haven't found a way to do that with shadow-cljs.
#2021-03-0819:29thheller@flowthing there is no cljs.repl/repl equivalent in shadow-cljs but I could add the :prompt config options. why do you not want a prompt? what editor did you use? most editors use nrepl and not many people use the socket repl at all#2021-03-0819:33flowthingI use Sublime Text, I'm working on my own thing. I don't really want to use nREPL because: a) I don't actually need any of the features it offers b) I'd like to avoid the dependency if I can (and with Clojure, it's relatively easy to upgrade a Socket REPL to implement editor integration) c) it has the same problem regarding switching REPL modes#2021-03-0819:33thhellerc) is fairly straightforward to handle over nrepl though#2021-03-0819:33thhelleri can understand a+b. not a fan of nrepl myself.#2021-03-0819:34thhelleryou could use prepl but that is somewhat ugly as well#2021-03-0819:34flowthingprepl only has structured output, not structured input.#2021-03-0819:34thheller:prepl {12345 :build-id} will start a prepl on port 12345 for the build-id#2021-03-0819:35thhellerthe input is identical to socket repl and prepl? just clojure forms?#2021-03-0819:35flowthingYep.#2021-03-0819:36flowthingOr, well. This is a rather involved topic. 😛 Anyway, a :prompt option would be great, but I'm not yet sure whether I'd actually end up using it. What I'd really like is a way to run a ClojureScript REPL in a way that's agnostic to build tooling.#2021-03-0819:37thhellergiven how vastly different the CLJS REPL is from CLJ thats difficult#2021-03-0819:37thhellerand the REPL impl in shadow-cljs is also very very different and supports many features that the default REPLs don't#2021-03-0819:38thhellerthe shadow.remote stuff I built might be of interest for you but thats heavily under documented and not final yet#2021-03-0819:38flowthingIndeed. I do realize it might be a pipe dream, but I think I'm still going to give it a go.#2021-03-0819:39thhellerI tried fixing all the REPL issues I could think of with shadow.remote and one day I'll document and publish it#2021-03-0819:39thhellerbut so far its only used internally for everything shadow-cljs and the REPLs do#2021-03-0819:41flowthingSounds interesting. I'd like my thing to work with just out-of-the-box ClojureScript, though.#2021-03-0819:42flowthingIf I start a Clojure socket REPL and send this:
((requiring-resolve 'cljs.repl/repl)
             ((requiring-resolve 'cljs.repl.browser/repl-env))
             :need-prompt (constantly false)
             :prompt (constantly ""))
In a shadow-cljs project, I get this:
Execution error (IllegalArgumentException) at shadow.build.cljs-hacks/eval24027$fn (cljs_hacks.cljc:981).
#2021-03-0819:44thhelleras I said .. cljs.repl/repl will never work with shadow-cljs#2021-03-0819:45flowthingWell, you said there's no equivalent. 🙂 But okay, that's good to know.#2021-03-0819:46flowthingI'll see where I end up with this thing, but I can make an issue about the :prompt thing if it comes to that. In any case, thanks for the help!#2021-03-0819:46thhelleryeah the REPL implementations are so drastically different that I can't provide a compatible repl-env stuff#2021-03-0819:46thhellerwhat is the issue with :prompt?#2021-03-0819:46flowthingAll right, that's very good to know.#2021-03-0819:46thhellerI mean why is the prompt a problem?#2021-03-0819:46flowthingI just meant an option to disable the prompt when calling (shadow/api :app).#2021-03-0819:47thhelleryes, but why?#2021-03-0819:47flowthingWhen I send forms to be evaluated from my editor, I don't want the prompt to show up in the evaluation results.#2021-03-0819:57thheller2.11.22 has (shadow/repl :id {:prompt false})#2021-03-0819:57flowthingWow, thank you! 🙇:skin-tone-2:#2021-03-0820:08flowthingJust to demonstrate what I meant: https://tutkain.flowthing.me/before.png https://tutkain.flowthing.me/after.png The first line with => is the "prompt" (really, the namespace indicator) my client prints (disregard the namespace there, it's WIP), the second line is the prompt shadow-cljs printed. The point is just that I'd like to be sure that what I'm getting from the server is just EDN and I can control when foo=> gets printed and how.#2021-03-0820:09flowthing(Well, in this case it's not just EDN because it can also be whatever stdout gets, but anyway.)#2021-03-0820:09flowthingI'll stop taking up more of your time -- thanks again!#2021-03-0821:25azHi all, I’m a little confused on how to best setup a new re-frame project with shadow. I used the re-frame template lein new re-frame <app-name> I see other projects set up differently and I’m wondering what is the consensus on setting this up, if any? Lastly, any reading material you could point out regarding deployment best practices.#2021-03-0903:15mikethompson@limix The re-frame-template uses Leiningen with Lein Shadow. Some regard Leiningen as "the old way". But it still works pretty well for us. If you just want to have a play around with ClojureScript, Shadow-cljs and re-frame, the template is probably more than good enough - because the build tooling doesn't matter too much. But if you are starting a new, serious project which will grow over time, then you may want to choose to not use Leiningen - the Shadow-clj docs will give you the alternative structure.#2021-03-0904:26azThank you @U051MTYAB really appreciate the feedback #2021-03-0904:12nonrecursivehey y’all, has anyone run into an issue with watch taking > 5s to detect a change? I’m not sure what I changed, if anything, but now there’s a significant delay between when I save a file and when shadow-cljs compiles#2021-03-0904:13nonrecursivecompiling itself is still fast at ~0.35s#2021-03-0904:28nonrecursivelooks like this happens when i switch from openjdk 11.0.2 to 11.0.10#2021-03-0907:56thheller@nonrecursive are you on macos big sur? if so upgrade shadow-cljs to a recent version, that should have fixed it. not aware of any other issues.#2021-03-0913:39nonrecursive@thheller i am - thanks!#2021-03-1014:22roman01la@thheller Is there an API to trigger heads up display so that a warning from a build hook running in flush stage could be visible in a browser?#2021-03-1015:44thheller@roman01la no API but you can just put a warning into the build-state#2021-03-1015:45roman01laoh that's nice!#2021-03-1015:45thheller:shadow.build/build-info is the key of the data that the clients will get#2021-03-1015:45thhellerit has a nested :sources and those have :warnings#2021-03-1017:11Clément RonzonHi gals and guys, I'm having an issue with a NPM dependency I am using: react-color (https://www.npmjs.com/package/react-color) I get a couple of errors and warnings when running karma on the produced code (`:karma-coverage`):
# karma start
10 03 2021 16:57:08.655:INFO [preprocessor.coverage]: coverage not included in reporters dots,progress
10 03 2021 16:57:08.881:WARN [karma]: No captured browser, open 
10 03 2021 16:57:08.973:INFO [karma-server]: Karma v5.2.3 server started at 
10 03 2021 16:57:08.973:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
10 03 2021 16:57:08.976:INFO [launcher]: Starting browser ChromeHeadless
10 03 2021 16:57:10.131:INFO [Chrome Headless 88.0.4324.182 (Linux x86_64)]: Connected on socket pvu_uV4i-0kufk6WAAAA with id 85631944
10 03 2021 16:57:10.581:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$UnfoldMoreHorizontalIcon.js?80c4489cd485acfeed1e160ad69825303e4ee8e4
10 03 2021 16:57:10.595:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$CheckIcon.js?3b1f8ad831751a7b84b35493627cc64278e2c8c7
10 03 2021 16:57:10.765:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$UnfoldMoreHorizontalIcon.js?80c4489cd485acfeed1e160ad69825303e4ee8e4
10 03 2021 16:57:10.800:WARN [web-server]: 404: /base/target/cljs-runtime/module$node_modules$icons$material$CheckIcon.js?3b1f8ad831751a7b84b35493627cc64278e2c8c7
Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$ChromeFields'
Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$ChromeFields'

Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$Chrome'
Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$components$chrome$Chrome'

Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$index'
Chrome Headless 88.0.4324.182 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_color$lib$index'

Chrome Headless 88.0.4324.182 (Linux x86_64) ERROR
  Uncaught Module not provided: module$node_modules$$icons$material$UnfoldMoreHorizontalIcon
  at target/cljs-runtime/shadow.js.js:37:9
Chrome Headless 88.0.4324.182 (Linux x86_64) ERROR
  Uncaught Module not provided: module$node_modules$$icons$material$UnfoldMoreHorizontalIcon
  at target/cljs-runtime/shadow.js.js:37:9
I read some passed discussions on this channel, about adding :js-options {:ignore-asset-requires true}, others about adding :compiler-options {:output-feature-set :es8} but none solved my issue.
#2021-03-1017:17thhellerwhy do you get 404s? do the files exist on disk?#2021-03-1017:22Clément RonzonThere are those: module$node_modules$$icons$material$UnfoldMoreHorizontalIcon.js module$node_modules$$icons$material$CheckIcon.js ...with that double $ which doesn't match the ones indicated in the 404 warnings.#2021-03-1017:24thhellerthe extra $$ are the replacements for the /@ in actual source path (which aren't valid in JS identifiers)#2021-03-1017:25thhellersomething in karma must be replacing $$ in $ for some reason?#2021-03-1017:34Clément RonzonYeah, that must be it. I'm using a custom :karma-coverage target. With :karma it works just fine.#2021-03-1017:48Clément RonzonThank you @thheller#2021-03-1018:42pmooserI'm trying to upgrade from shadow-cljs 2.10.6 to 2.11.22, and I see a number of warnings about not being able to infer the type of things. I've gone though and manually hinted most them as ^js , but I'm getting warnings that I don't know how to hint everytime I use a deftype that implements reagent.ratom.IReactiveAtom.
387 | 
388 | (deftype Foo [^:mutable amdoc ^:mutable clj-value ^:mutable snapshot meta validator ^:mutable watches ^:mutable callback]
        -------^------------------------------------------------------------------------
        Cannot infer target type in expression (. (. Foo -prototype) -reagent$ratom$IReactiveAtom$)
        --------------------------------------------------------------------------------
 389 |   IAtom
 390 |   reagent.ratom.IReactiveAtom
 391 | 
 392 |   FooClassification
Any insight as to why this is happening now, and more importantly, how to resolve it?
#2021-03-1018:48pmooserAs to "why now" I understand that at some point some defaults regarding inference changed, but I have no idea how to hint that deftype to make it leave me alone.#2021-03-1021:40thhellerreagent.ratom.IReactiveAtom should be reagent.ratom/IReactiveAtom I think#2021-03-1021:41thhelleryou silence externs inference in that file by setting (set! *warn-on-infer* false)#2021-03-1021:41thhelleror reverting the old behavior by setting :compiler-options {:infer-extern true}#2021-03-1108:37pmooserThank you @thheller! I in fact turned the warnings off, but I will see if fixing my reference resolves the error ... thanks again ! 🙂#2021-03-1108:38pmooserChanging it to / instead of . didn't change anything ...#2021-03-1108:38pmooserBut I can just leave the warnings disabled, worst-case.#2021-03-1108:44thhellerI think this particular warning will be fixed with the next CLJS release anyways. It originates from deep inside the compiler that shadow-cljs cannot easily modify.#2021-03-1108:53pmooserThank you for your assistance in any case!#2021-03-1019:20Stuartis their a clj template for creating a shadow-cljs project targetting the browser? Just to give all the basics to get started, so I can get up and running with hot-reload, dev and test src paths, reloading css, a public folder for the html/css etc ? I'm trying to go through the docs but its so complicated and feels pretty impenetrable without an example to follow along with that I can see works and I can change and mess with.
#2021-03-1022:07thhellerdid you go through https://github.com/thheller/shadow-cljs#quick-start?#2021-03-1022:08thhellerit only handles basic project setup though. if you want more specific templates you need to select one for the libs you want to use#2021-03-1023:11StuartIts the paths and naming thats confusing me. From the quick start you called the project acme-app, but then the namespace is How did we end up with a frontend between acme and app ? The dots become slashes in the expected directory structure? Then in the edn you have
:builds
{:frontend
 ...
What happened to acme and app here? There just seems to be an awful lot of magic happening here based on strings and names that I'm not understanding. I think I just need to create a few examples using the npx create-cljs-project with different names and see what gets created. Thanks!
#2021-03-1023:20thhellerthe project is called acme-app. that is literally only the directory name the files are in. it has nothing to do with what the project does. The name I picked because naming is hard but I tried to explain why I did#2021-03-1023:22thhellerin many other CLJS examples you'll see a bunch of foo.core namespaces. I personally don't like .core names so I used something else. its just a name, use what makes sense for you.#2021-03-1023:32StuartSo I've created a project called learn-reframe in a learn-reframe folder.
.
├── learn-reframe.iml
├── node_modules
├── package.json
├── package-lock.json
├── pom.xml
├── shadow-cljs.edn
└── src
    └─ main
    └─ test
For now I don't care about names so a random prefix will do, exfn So I create
src\main\exfn\app.cljs
With namespace
(ns )
So I my edn should look like this:
{...
 :builds
 {:???
  {:target :browser
   :modules {:main {:init-fn }}}}}
I'm not sure what my :??? would be :exfn or :app?
#2021-03-1023:33StuartJust :app I think?#2021-03-1023:33thhelleralso just a name. up to you. :app is fine#2021-03-1023:34thhellerthat is the build-id used later in the shadow-cljs watch app etc commands#2021-03-1023:37Stuartok, think i get it now! Thank you for your help. I really appreciate it!#2021-03-1020:21dpsuttonif i'm using :npm-module and bundling that into a webpack frontend, is it possible to get a cljs repl connected to the webpacked build? Does shadow emit all of the necessary bridge stuff during a watch such that this is a reasonable thing to expect?#2021-03-1021:43thheller@dpsutton yes but you need to manually require the shadow.cljs.devtools.client.browser ns from the JS side of things. so if (process.env.NODE_ENV === "development") { require("wherever/shadow.cljs.devtools.client.browser.js") }#2021-03-1021:44dpsuttonheh, and can't put that behind a flag in a cljs file and sneak it in that way?#2021-03-1021:44thhellerbut the REPL has some limits in what it can do since webpack post-processes the code normally but not the code loaded over the REPL#2021-03-1021:45thhelleryou can try 😉#2021-03-1021:46dpsuttonoh, where should that live? process.env.NODE_ENV? I'm quite the beginner with webpack stuff. presumably that's in the webpack config? i'm surprised to see a require that uses that#2021-03-1021:46thhellerwell its a pattern that is commonly setup in webpack#2021-03-1021:46thhellerits that not already configured then that wouldn't work either#2021-03-1021:47thhellerwell it might actually be included by default nowadays. not actually sure.#2021-03-1021:48dpsuttoni see. i'll give that a shot. thanks so much @thheller#2021-03-1021:50thhellerFWIW (when (identical? js/process.env.NODE_ENV "development") (js/require "./shadow.cljs.devtools.client.browser.js")) should work#2021-03-1021:50thhellerthe trouble is that shadow-cljs doesn't have a clearly defined entry namespace for :npm-module. so it cannot inject that for you before loading that ns#2021-03-1110:06zendevil.ethI get these two errors periodically in my react-native app:
[Thu Mar 11 2021 15:25:10.620]  WARN     The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:25:10.640]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
[Thu Mar 11 2021 15:26:37.705]  WARN     The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:26:37.706]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
[Thu Mar 11 2021 15:28:01.413]  WARN     The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:28:01.419]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Network is unreachable"}
[Thu Mar 11 2021 15:29:27.332]  WARN     The shadow-cljs Websocket was disconnected.
[Thu Mar 11 2021 15:29:27.333]  ERROR    shadow-cljs - remote-error {"isTrusted": false, "message": "The operation couldn't be completed. Operation timed out"}
everything is running smoothly but I get the warning and error periodically.
#2021-03-1110:08thhellerlooks like the app is losing the websocket connection to the shadow-cljs instance. maybe the device going to sleep or so?#2021-03-1110:49zendevil.ethi’m running this on the simulator currently, and it has never gone to sleep#2021-03-1110:52thhellerno clue. must be something in the emulator/app. does this ever happen when you actually using the "device" or does it just happen if its sits "idle" for 90sec?#2021-03-1110:53zendevil.ethit also happens when using a real device#2021-03-1110:54zendevil.ethit doesn’t need to be idle. It happens even when the app is being used#2021-03-1111:02thhellerI don't know. what happens if you open a browser on the device/emulator and open the UI? http://the-ip:9630? is that getting disconnected as well?#2021-03-1111:06zendevil.eth@thheller how do I find the-ip?#2021-03-1112:23thhellerthe ip of your computer#2021-03-1112:50zendevil.eththat gives “safari cannot open the page because it could not connect to the server”#2021-03-1112:50zendevil.ethI googled “my ip”#2021-03-1112:51thhellerthat likely led you to a site telling you your public IP which is not the IP you have on your local network#2021-03-1112:51thhellerwhat OS are you on?#2021-03-1112:54zendevil.ethmacOS#2021-03-1112:55thhellerhttps://osxdaily.com/2010/11/21/find-ip-address-mac/#2021-03-1112:55thhellerancient article I guess but I think the info is still there somewhere#2021-03-1112:58zendevil.ethi see the following:#2021-03-1112:58zendevil.eth#2021-03-1113:00thhelleryes that is the shadow-cljs UI#2021-03-1113:01thhellerwhen its websocket disconnects you should get a big fat red box on the top#2021-03-1113:01zendevil.ethi just saw the error and the warning in the app. Then opened safari. No difference#2021-03-1113:01thhellerkeep the browser open#2021-03-1113:02thhellerdo nothing. just wait. if you get no red box for 5min or whatever then that socket is not disconnecting#2021-03-1113:02thhellerso the cause of you problem must be somewhere related to your app/react-native#2021-03-1113:03thhellerif it also disconnects I still don't have a clue but at least we can rule out that the app is the cause#2021-03-1113:06zendevil.ethokay, no red box for five minutes#2021-03-1113:08thhellerand the UI still works? you are on a kind of old version and I can't remember if that version already had the big red box#2021-03-1113:09zendevil.ethSo I changed to this:
(defn init []
  (dispatch [:register-db])
  (render-root "Humboi" (as-element [view];;[root-comp]
                                    )))
Basically removed the root-comp with a rn view
#2021-03-1113:09zendevil.ethAnd I do see the warning and the error#2021-03-1113:09thhellerok so it is definitely connected#2021-03-1113:10thhelleryeah sorry can't help further. I don't use react-native and don't have a clue how its networking works or how you'd go about debugging it#2021-03-1113:10thhellerseems to be app related if the browser works fine#2021-03-1113:22zendevil.ethcould it be because of the three warnings that I’m getting? I don’t know how to get rid of them:
------ WARNING #1 - :fn-arity --------------------------------------------------
 Resource: re_frisk/trace.cljs:27:11
 Wrong number of args (1) passed to reagent.impl.component/do-render
--------------------------------------------------------------------------------

------ WARNING #2 - :fn-arity --------------------------------------------------
 Resource: re_frisk/trace.cljs:31:54
 Wrong number of args (1) passed to reagent.impl.component/do-render
--------------------------------------------------------------------------------

------ WARNING #3 - :undeclared-var --------------------------------------------
 Resource: re_frisk_remote/core.cljs:120:15
 Use of undeclared Var reagent.impl.component/static-fns
--------------------------------------------------------------------------------
#2021-03-1115:16thhellerdon't know what this does so don't have a clue if this affects anything. looks unlikely but I can't be sure.#2021-03-1114:43Volodymyr HuzarHello! I want to get at least some kind of coverage for our cljs code. The generated by :target -> :karma js bundle is too big to be handled by karma-coverage plugin (JavaScript heap out of memory is thrown). The idea I had in my mind to split tests and source code into different modules and check coverage only on source part. But to be honest I have no idea on how to implement that. So my questions are: 1. Is it possible to use :modules for :build -> :target -> :karma ? I have tried and it seems they are ignored 2. Can we use namespace regex for :modules -> :entries ? I have tried :entries [".*-tests"] but it doesn’t work#2021-03-1115:13thheller@vguzar sorry I went over this with someone else not too long ago but I cannot remember any details. I have never used karma-coverage and I don't know what it needs to work. :modules is not supported by :target :karma. the target however is very little code so you can maybe figure out what you need and modify it to fit your needs. see https://github.com/thheller/shadow-cljs/blob/d810a0f5e1b1c78f15e0365ce7a05cba16f0ca70/src/main/shadow/build/targets/karma.clj#2021-03-1115:33Nolanhey @thheller! we're working on using one of the libraries we build with shadow from React Native. the library depends both directly and transitively on node's crypto module. i'm not super familiar with RN and its tooling, but it seems to be a well-recognized limitation that the crypto module needs to be browserified to some degree in order to be used, so all the proposed solutions trickle down into the build process. does this seem like something we could solve by tweaking shadow configuration? we've tried using :target :react-native and a few ways of redirecting :resolve, but the transitive dependency seems to retain require('crypto') somewhere or another. most recently weve been looking into ways of combining :js-provider :require with whatever polyfills crypto in :target :browser. let me know your thoughts and how you might approach this, it would be pretty awesome to get this working#2021-03-1115:34Volodymyr Huzar@thheller thanks for the answer. probably there is no sense to spend too much time on karma coverage if it doesn’t work out of the box as it gives coverage for js output code instead of source code. I am considering using https://github.com/lambdaisland/kaocha-cljs instead of karma which looks like supports coverage out of the box but lets see. I’ll come back to this later in case kaocha will not help here#2021-03-1115:37thheller@nolan use :target :react-native and follow whatever react-native instructions are for using the crypto module. there should be some? this needs to be resolved in the react-native configuration side of things. something in metro probably. no clue how.#2021-03-1115:42Nolanyeah, i thought the process for using crypto from metro would have a lot more documentation, but everything i've been able to find seems somewhat poorly supported. i was hoping to shield consumers of the library from a change to their build process, but it seems that might not be the best route.#2021-03-1115:48Nolanreally appreciate the help. i was definitely going to sink a number of hours into twiddling target/provider configuration, so youve saved me that at the very least#2021-03-1115:49thhellerwell it might work with some configuration but it might get verbose#2021-03-1115:50thhellerthere is :js-options {:keep-as-require #{"react-native"}} for example#2021-03-1115:50thhellerso you can set :js-provider :shadow and it'll bundle every JS require except for those mentioned in :keep-as-require.#2021-03-1115:51thhellerso if you mention ALL but crypto that might work. fairly undesirable but it might work#2021-03-1115:52thhelleroh nvm ... :js-provider :require is hardcoded for :react-native#2021-03-1115:55Nolanhuh, very interesting. i will spend some time with this. at this point im primarily curious/ready to learn more about how this all works in shadow . i highly admire how easy it has been to grok how the config comes together#2021-03-1115:57thhellerwell this line is currently what would prohibit testing this with :js-provider :shadow and :keep-as-require https://github.com/thheller/shadow-cljs/blob/ea54e4b943c762645178303778aef094387f1a85/src/main/shadow/build/targets/react_native.clj#L131#2021-03-1115:58thhelleryou can take this file, put it on your classpath in the proper location and change that#2021-03-1115:58thhellermaybe that works#2021-03-1116:01Nolanindeed, indeed. ill try it! a local shadow repo is something ive wanted to need for a long time. thanks a ton! 🙏#2021-03-1116:05Nolani found this metro solution (https://github.com/brix/crypto-js/pull/259#issuecomment-588201011), which is the best way ive been able to find to do it generally (assuming it works). but im still going to see if im able to produce an artifact that doesnt need it directly from shadow, since i think that would be a pretty neat capability#2021-03-1116:28thhellerdon't need a full shadow-cljs repo. just literally copy that one file into your classpath and use it 🙂#2021-03-1115:38thheller:target :browser is not meant for react-native and don't waste your time trying to adjust it.#2021-03-1117:12naomarikWhat JDK do you guys recommend for M1 mac? I've tried openjdk 16, tons of reflection errors. Zulu openjdk8 for macos/ARM and it works but the watch function seems to pick up changes extremely slowly. The only thing that's fast for watch is adoptjdk8 but it's x64 and launches very slow.#2021-03-1117:17naomarikBy pick up changes slow, I mean editing cljs files and saving takes a few seconds before anything happens... compiles fast though.#2021-03-1117:19thhellerI use openjdk 15. watch being slow is caused by big sur. upgrading shadow-cljs should fix it#2021-03-1117:19naomarikcool will try upgrading it now then!#2021-03-1117:20thheller:fs-watch {:hawk false} in shadow-cljs.edn should also work#2021-03-1117:22naomarikThanks @thheller, lightning fast now.#2021-03-1117:22naomarikUpgraded to latest version works fast now.#2021-03-1119:08pmooserI'm trying to debug a case that has cropped up in my project, where a release build with optimizations :simple breaks due to loading errors, but optimizations :advanced works fine. I get things like:#2021-03-1119:08pmooser#2021-03-1119:09pmooserAny clue on how you would debug this? I'm completely mystified by it.#2021-03-1119:15thhellernot a clue. look at the code location I guess.#2021-03-1119:16pmooserWhat does it mean to do a release build with simple optimizations? It's still minified I suppose.#2021-03-1119:17thhelleryou can set :js-options {:minimize-require false} in your build config. that'll at least make it more obvious which files fail#2021-03-1119:17pmooserOk, thank you - that will be helpful I am sure.#2021-03-1119:17thhellershadow-cljs release app --debug might also help#2021-03-1119:18pmooserOk, thanks for that as well. I will keep banging my head against this ...#2021-03-1119:18pmooser(This didn't used to happen)#2021-03-1119:23pmooserOk, interesting. It is a js library I use called Automerge that is failing to load for some reason.#2021-03-1119:23pmooserI also see this:#2021-03-1119:23pmooser
Resource: node_modules/automerge/src/automerge.js:2
 constant module$node_modules$automerge$src$automerge assigned a value more than once.
Original definition at externs.shadow.js:20
#2021-03-1119:23pmooserDoes that mean that the inferred externs don't match somehow?#2021-03-1119:29thhellerhmm odd. not sure.#2021-03-1119:32pmooserOk, well, thanks for the insight. I am going to go have dinner, and I will try to pick this up tomorrow after getting some more sleep. Have a nice night!#2021-03-1120:32hadilsI am trying to convert the JS statement:
import AsyncStorage from '@react-native-async-storage/async-storage';
into shadow-cljs:
(ns com.yardwerk.mobile-ui.async-storage
  (:require
    [cognitect.transit :as t]
    [com.fulcrologic.fulcro-native.alpha.components :as c :refer [react-factory]]
    ["@react-native-async-storage/async-storage" :default AsyncStorage]))
and I am getting the following error:
undefined is not an object (evaluating 'shadow.js.shim.module$$react_native_async_storage$async_storage.default')
I am scratching my head. I checked everything -- the package.json, reloaded node_modules, etc. Anybody run into this problem?
#2021-03-1120:39thhellertry ["@react-native-async-storage/async-storage" :as AsyncStorage]. your translation is otherwise correct but sometimes packages don't actually have a default export and are bundled as commonjs#2021-03-1120:40thhellerI assume you reloaded your RN app after making that change as "new" JS dependencies cannot be loaded via hot-reload#2021-03-1120:42hadilsYes, I did. Now the call to setItem fails:
undefined is not an object (evaluating 'shadow.js.shim.module$$react_native_async_storage$async_storage.setItem')
#2021-03-1120:42hadilsI shut everything down and restarted...#2021-03-1120:43thhellerjust try (js/console.log AsyncStorage) or so to find out what it actually is#2021-03-1120:43hadilsOk.#2021-03-1120:44hadilsIt's underfined.#2021-03-1120:45thhellerdid you install it properly? maybe it needs an extra install step besides npm install#2021-03-1120:45thhellersome react-native packages seem to require that#2021-03-1120:45thhellerI don't use react-native so I don't have a clue#2021-03-1120:51hadilsOk. Thanks.#2021-03-1121:29hadils@thheller A friend helped me solve the problem. You need to import it into a part of the working app. I was writing a library so it didn't know about it from the root of the app...#2021-03-1220:37isakIs there a good way to develop shadow-cljs locally and use in other projects? Like lein install, except if you want to use it the recommended way (npm)?#2021-03-1220:41thhellerI just lein install#2021-03-1220:41thhellerthe recommended way still just uses the installed version in .m2 so that has nothing to do with it#2021-03-1220:42thhellerwhat do you intend to do? another way is just putting the shadow-cljs src/main into the source paths of your project#2021-03-1304:03isakSounds good if lein install works. Just checking if I can solve one of the problems with inspect that I noticed earlier (where taps don't work if you do them too quickly on a page load)#2021-03-1308:32thhellerif you intend on working on it while working on a project I'd definitely recommend just adding the source path to the project#2021-03-1308:32thhellerI do this frequently. all projects in ~/code so just :source-paths ["src/main" "../shadow-cljs/src/main"]. while keeping the normal shadow-cljs dependency to get all other transitive dependencies and stuff#2021-03-1308:33thhellerworks fine with project.clj or deps.edn as well#2021-03-1322:40isakI'll give that a shot, thanks!#2021-03-1221:22JasonI'm playing with monorepo multiproject multibuild settings and I'm getting a fresh error. I'm not sure where I went wrong with deps.edn alias:
:dev-cljs
  {:extra-deps {thheller/shadow-cljs          {:mvn/version "2.11.22"}
   ...
   :main-opts  ["-m" "shadow.cljs.devtools.cli" "watch" "ui"]}
and shadow-cljs.ednbuild:
{:ui {:target :browser
       :output-dir "projects/ui/public/js"
       :asset-path "projects/ui/js"
       :module-hash-names false
       :modules {:ui {:init-fn ui.main/init!
                      :preloads [devtools.preload
                                 day8.re-frame-10x.preload]}}
       :dev {:compiler-options {:infer-externs :auto
                                :closure-defines
                                {re-frame.trace.trace-enabled? true
                                 day8.re-frame.tracing.trace-enabled? true}}}
       :devtools {:repl-pprint true
                  :preloads [shadow.remote.runtime.cljs.browser]
                  :http-root "projects/ui/public"
                  :http-port 8280}}}
When i load the app in the browser, I get "is the watch for this app running?". I only changed paths to move the location of shadow-cljs.edn up a couple of directories. Any help appreciated.
#2021-03-1221:46thheller@jasonhlogic first of all your :asset-path looks incorrect. likely that should just be /js?#2021-03-1221:46thhellerthe error you get is when the files you are loading were not produced by the running shadow-cljs instance#2021-03-1221:47thhellerso likely if you changed some paths or so you have some older files still somewhere that are not used instead of the new output#2021-03-1221:49thhelleror you jsut haven't started the watch? don't know which command you run#2021-03-1221:56JasonI changed the :assset-pathto "/js", but I still get the same error. My command is:
clojure -M:defaults:ui:dev-cljs
where defaultsis a set of override-deps to version-lock libraries shared across projects and ui is:
{:extra-deps {ui/ui {:local/root "projects/ui"}}}
which adds the project-level deps.edn
#2021-03-1221:56thhellernot a clue how that works but it doesn't matter for shadow-cljs#2021-03-1221:57thhelleryou are opening http://localhost:8280 I presume?#2021-03-1221:57thhellerthat serves the files from <project>/projects/ui/public#2021-03-1221:57JasonConfirmed.#2021-03-1221:58JasonAlso correct.#2021-03-1221:58thhellerand you are including <script src="/js/ui.js"> in the HTML#2021-03-1221:58thhellerdo you maybe have two instances of shadow-cljs running?#2021-03-1221:59JasonYes, this app ran before I changed the paths#2021-03-1222:00thhellersimple test. shutdown shadow-cljs and open the http://localhost:8280#2021-03-1222:00thhellerif you still get a reply then find out from where#2021-03-1222:00JasonOnly one instance running, and these resuts are confirmed by another developer#2021-03-1222:00thhellercould be a service worker if you have one#2021-03-1222:01JasonI shut down the instance and the browser says it can't connect#2021-03-1222:02thhellerok#2021-03-1222:03thhellerthen I'm out of ideas. there really isn't much that goes into this. shadow-cljs places the files in the :output-dir and the :http-root serves them#2021-03-1222:03thhellerbut especially if you move some files or change directory names or so#2021-03-1222:04thhellerit is easy to miss one place and is still using an old file from some other directory#2021-03-1222:04Jasonyes, let me go clean those out.#2021-03-1222:06thhelleryou can also remove :preloads [shadow.remote.runtime.cljs.browser]. that has been the default for a while now.#2021-03-1222:06thhellerbut that doesn't affect anything regarding this#2021-03-1222:07Jasonhappy to clean out old opts 🙂#2021-03-1222:15Jasoni found it. i changed the build name to 'ui' but did not update the name of the js file the index page loads. Thank you very much for your responses. I'm sorry to have taken your time with my config error.#2021-03-1222:15thhellerthe build name doesn't affect this. the :modules key does.#2021-03-1222:18Jasonduly noted and thanks again#2021-03-1316:44wombawombais there a recommended way of running other background processes (asset processors, static site builders etc) together with shadow-cljs watch?#2021-03-1318:04wombawombaFWIW I found https://www.npmjs.com/package/concurrently which seems works really nicely for my use-case#2021-03-1316:46thhellerI have used https://www.npmjs.com/package/foreman https://www.npmjs.com/package/npm-run-all in the past#2021-03-1316:46thhellernowadays I just run things separately#2021-03-1316:47wombawombaalright, thanks!#2021-03-1317:25stopaHey team, is there a recommended article / resource, that goes into the “most idiomatic setup” for css with shadow? Would love any pointers!#2021-03-1318:14stopaHey team, I am playing around with optimizing my shadow-cljs bundle. I ran
npx shadow-cljs run shadow.cljs.build-report app report.html 
One thing I noticed, is that currently the clojurescript runtime is taking 400kb. That seems surprising — I thought it would be doing some kind of tree-shaking. (To test, I deleted all code in core.cljs, and left the imports) Here’s my shadow config in project.clj:
{:nrepl {:port 7002}
   :builds
   {:app
    {:target :browser
     :output-dir "target/cljsbuild/public/js"
     :asset-path "/js"
     :modules {:app {:entries []}}
     :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
     :devtools {:preloads [day8.re-frame-10x.preload]
                :watch-dir "resources/public"}}
    :test
    {:target :node-test
     :output-to "target/test/test.js"
     :autorun true}}}
I may be missing something trivial. (perhaps I need to manually set a certain kind of :optimizations? Any pointers / resources for debugging further would be appreciated!
#2021-03-1318:17thhelleryou are including cljs.analzyer and cljs.pprint somewhere#2021-03-1318:17thhellerthose are very heavy hitters that can't be DCE'd#2021-03-1318:18thhellerso you should get rid of those at least (which will also further shrink cljs.core in the process)#2021-03-1318:31stopaAh, thanks for the pointer @thheller! Will look deeper.#2021-03-1318:38stopaOkay, looks like the two biggers culprits: I have a /dev/…/app.cljs file, which imports
[cljs.spec.alpha :as s]
    [expound.alpha :as expound]
    [devtools.core :as devtools]))
And my core.cljs file imported [reitit.coercion.spec :as reitit-spec], which seem to also be a culprit. My guess right now is that I am incorrectly using /dev/ vs /prod/, and then will learn more about what reitit-spec is about.
#2021-03-1318:45thhellerdevtools.core you should remove unless you are calling it somewhere directly?#2021-03-1318:45thhellerdev stuff in general you want to move into a :preloads ns#2021-03-1319:00stopaRight now, the way it is set up, I have a custom file in /env/dev/cljs/[app-name]/app.cljs , which does the following:
(ns ^:dev/once 
  (:require
    [virtual-library.core :as core]
    [cljs.spec.alpha :as s]
    [expound.alpha :as expound]
    [devtools.core :as devtools]))

(extend-protocol IPrintWithWriter
  js/Symbol
  (-pr-writer [sym writer _]
    (-write writer (str "\"" (.toString sym) "\""))))

(set! s/*explain-out* expound/printer)

(enable-console-print!)

(devtools/install!)

(core/init!)
Looking at project.clj, looks like this gets replaced by a /prod/ in uberjar:
{:uberjar {:omit-source true
             :prep-tasks ["compile" ["shadow" "release" "app"]]

             :aot :all
             :uberjar-name "virtual-library.jar"
             :source-paths ["env/prod/clj"  "env/prod/cljs" ]
             :resource-paths ["env/prod/resources"]}
I think the way I set up shadow, the reporting script is assuming env/dev/*. Will look deeper into this, and :preloads. From a quick test, looks like this is indeed what is happening,
#2021-03-1319:03thhellerthis is a terrible pattern I would strongly recommend changing#2021-03-1319:04thhellerin your build config set :modules {:app {:init-fn ! :preloads [virtual-library.dev]}}#2021-03-1319:04thhellerand move all the stuff you have in app to the .dev ns#2021-03-1319:04thhellerno need to switch the classpath and all that mess#2021-03-1319:04thheller
(enable-console-print!)

(devtools/install!)

(core/init!)
#2021-03-1319:04thhellerdelete these 3 too. not needed at all.#2021-03-1319:05stopa…Amaazing! Thank you @thheller!#2021-03-1319:06stopaAlso, with reitit-spec removed, and the dev/app stuff, now we’re muuch better: (will update with your advice and keep playing with the optimization)#2021-03-1319:23stopaOkay, current shadow setup:
{:nrepl {:port 7002}
   :builds
   {:app
    {:target :browser
     :output-dir "target/cljsbuild/public/js"
     :asset-path "/js"
     :modules {:app {:init-fn virtual-library.core/init! :preloads [virtual-library.dev]}}
     :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
     :devtools {:preloads [day8.re-frame-10x.preload]
                :watch-dir "resources/public"}}
    :test
    {:target :node-test
     :output-to "target/test/test.js"
     :autorun true}}}
first thought, will try moving day8.re-frame-10x.preload into virtual-library.dev . Let me know if there’s more cleanup I could do : } — thanks team
#2021-03-1321:04thhellerfine to just move :preloads together. either in :modules or :devtools is fine#2021-03-1419:24dvingoI have a use case where I want to ^:export some variables for JS consumption - the build in shadow is :npm-module. To clean things up I wanted to do export a cljs var within a macro, but I'm struggling to find a way to do so - attaching the metadata to the resulting cljs var doesn't get shadow to include the var in the module.exports. I can goog.exportSymbol manually in the macro code, but I do I also need the JS var in the module.exports object. Is this a known limitation or is there a way to get this working?#2021-03-1420:01thheller@danvingo what did you do in the macro? shadow collects the data from the analyzer meta data so if you did it correct it should just work#2021-03-1420:02thhellerhttps://github.com/thheller/shadow-cljs/blob/62700720fc82e048442a4abc0a5b99d845d6545b/src/main/shadow/build/closure.clj#L798-L814#2021-03-1421:33dvingothe background context is I'm trying to create some react storybook stories - which in the newer versions are just functions that are exported. Here's the code:
(defmacro make-story2 [nm body]
  `(defn ^:export ~nm []
     (reagent.core/as-element ~body)))
I've also tried:
(defmacro make-story2 [nm body]
  `(do
     (defn ~nm []
       (reagent.core/as-element ~body))
     (alter-meta! (var ~nm) assoc :export true)))
#2021-03-1421:41dvingoahhhh I found the magic incantation 🙂
(defmacro make-story2 [nm body]
  `(defn ~nm
     {:export true} []
     (reagent.core/as-element ~body)))
#2021-03-1421:43dvingohmm, so this works for defn, but not for def I guess I can refactor to use defn#2021-03-1421:53thheller^:export ~nm [] isn't valud#2021-03-1421:54thheller~(vary-meta nm assoc :export true) would do it#2021-03-1421:54thheller
(defmacro make-story2 [nm body]
  `(defn ~(vary-meta nm assoc :export true) []
     (reagent.core/as-element ~body)))
#2021-03-1421:58dvingoI figured the reader macro wouldn't work - ahh very cool!#2021-03-1421:58dvingothanks for the help#2021-03-1510:26Karol WójcikHow can I check which dependency includes cljs.test and cljs.pprint? I can see in shadow-report both of those included, whereas I don't have explicit require for them in the application.#2021-03-1510:52thhellercurrently there is no easy answer to this API wise#2021-03-1510:53thhelleryou can technically reconstruct it from the build data but no readymade function currently#2021-03-1511:01Karol WójcikHmm.. I think the fastest way would be to stub cljs.pprint with some ns which includes throw of an error and check stacktrace. Will check it out#2021-03-1515:36jacekschaeIf you wondering how to setup devcards with shadow-cljs here is an example: https://github.com/jacekschae/shadow-cljs-devcards also created a PR to add to the examples#2021-03-1522:01wombawombaSo I have some code that compiles fine in shadow-cljs, but gives me the following error when I try to load it in the browser:
SyntaxError: Invalid or unexpected token
   at eval (<anonymous>)
   at Object.goog.globalEval ()
   at Object.env.evalLoad ()
   at 
The error doesn't really tell me where the problem lies, and the compiled js file being loaded is >4000 lines. How can I figure out what's causing the error?
#2021-03-1522:02wombawombaLike, is there a way to eval the statements in the file one by one?#2021-03-1522:02thhellerthe only way I have seen this error before is when two shadow-cljs instances are running at the same time and writing to the same files#2021-03-1522:02thhellermessing each other up#2021-03-1522:03thhellercould also be one instance but two builds using the same :output-dir#2021-03-1522:03wombawombaI did do that yesterday#2021-03-1522:03thhelleryou can set :devtools {:loader-mode :script} in the build config#2021-03-1522:05wombawombahow do I clean this up? should deleting the output directory suffice?#2021-03-1522:05thhellerfirst identify that there is only one instance running#2021-03-1522:05wombawombayeah there are zero instances right now :)#2021-03-1522:06thhellerand you only have one build writing to the output-dir? and no other processes modifying that output in any way?#2021-03-1522:06wombawombayeah#2021-03-1522:06wombawombabut like I said, I had two earlier#2021-03-1522:07thhellerrestarting will recreate all the files properly but if you want you can clean out the output-dir as well#2021-03-1522:07wombawombaalright#2021-03-1522:07thhellerunlikely to change anything#2021-03-1522:07wombawombaI did restart a few times afterwards, so maybe something else is going on here#2021-03-1522:08thhellerthe :loader-mode will load things as one script at a time, instead of all at once#2021-03-1522:08thhellerbut normally the eval loader should also tell you which file failed at least#2021-03-1522:08wombawombayeah it does tell me, but it's not helpful because that file is huge#2021-03-1522:09wombawombayeah no, still fails#2021-03-1522:09wombawombaI'll try the loader-mode thing next#2021-03-1522:09thhellerwhich server is serving :8281?#2021-03-1522:10wombawombashadow-cljs#2021-03-1522:12wombawombaalright, :loader-mode :script gave me a much nicer error, albeit in a different file...#2021-03-1522:13wombawombaI'll try to solve that one and see if I can get to the other thing that was failing 🙂#2021-03-1522:13thheller:script will not abort loading if one file fails. so it likely just creates a cascade of other errors#2021-03-1522:13wombawombaoh wait, duh#2021-03-1522:13wombawombayeah, the original error is there — I just missed it#2021-03-1522:14wombawombait's telling me which line is failing now though#2021-03-1522:14wombawombait's a bad regex#2021-03-1522:14wombawombathanks for the help!#2021-03-1522:14thhellerinteresting. good to know.#2021-03-1522:25wombawombaBTW, is there a way to get something like lein checkouts with shadow-cljs?#2021-03-1522:26wombawombaright now my workflow when working on cljs/cljc libraries with my cljs project is basically 1. make a change to a library 2. quit shadow-cljs 3. reinstall the library to my local maven repo 4. start shadow-cljs again 5. find something I want to change, go back to 1#2021-03-1522:27wombawomba...which seems pretty far from optimal 🙂#2021-03-1522:31thhellerwell the obvious answer is use lein checkouts 😉 or deps.edn via :local/root#2021-03-1522:32thhelleror just adding the :source-paths might work too (thats what I usually do)#2021-03-1522:38wombawombahuh 🙂 I didn't realize I could use lein and shadow-cljs together#2021-03-1522:39wombawombavery cool#2021-03-1604:01yqrashawnHi all, Is it possible to export macros to js context with the :esm target like this?
(ns core
  (:require [cljs.spec.alpha :as s :include-macros true]))

(def exports #js
  {:and s/and})
#2021-03-1607:55thheller@namy.19 no. macros run at compile-time. you cannot use them dynamically at runtime unless you go full self-hosted. even then you couldn't use them from JS though.#2021-03-1608:03yqrashawnis it possible to use annotation to skip the check? @thheller#2021-03-1608:04thhellerwhich check? s/or is a macro. you cannot call it dynamically from a function. what you are trying is simply not possible without eval#2021-03-1608:05yqrashawnbut this works#2021-03-1608:06yqrashawnthe s/and and s/def are both macros#2021-03-1608:07thhellerit does not work. not in the sense of actually using spec correctly.#2021-03-1608:11yqrashawnok so it’s not possible..#2021-03-1608:12thhellermacros are function that take CLJS syntax forms and return new CLJS syntax forms that the compiler will then compile. fundamentally you cannot call them from javascript without eval#2021-03-1608:13thhellerand even with eval you'd be constructing the CLJS forms from JS and then compile them. not just call them as functions.#2021-03-1608:13yqrashawnok so if I want to use spec in js, i have to implement one in js#2021-03-1608:17thhellerkind of yeah#2021-03-1608:26yqrashawnreally thanks for your super fast reply#2021-03-1610:10wombawomba@namy.19 you might find https://github.com/metosin/malli or https://github.com/plumatic/schema useful for these kinds of things#2021-03-1610:46wombawombaAny recommendations on how to handle environment-specific configuration? (e.g. hostnames that need to be different for dev vs different prod envs)#2021-03-1610:49thhellerif you are talking about a browser build I recommend putting it into the HTML when this is dynamically generated HTML from a server#2021-03-1610:50thhellerotherwise the typical answer is :closure-defines#2021-03-1611:11wombawombaGood idea, thanks#2021-03-1612:50Alexis Vincent@thheller You once shared a neat code snippet to sidestep the closure “namespace has already been declared” thing. Can’t find it or remember where it was from. Are you able to reshare?#2021-03-1613:52thheller@mail024 https://github.com/thheller/shadow-cljs/blob/f28003cbb062fd27685048e8b4793eb05ca8f829/src/main/shadow/cljs/devtools/client/env.cljs#L145#2021-03-1614:56Alexis VincentThanks!#2021-03-1623:20underplankHi all. I was wondering if there was a way to make the cljs-runtime directory concatenate to a single file when we release? Using a Vercel and having the 1000 odd files on upload for every deploy kills thier hobby limit.#2021-03-1623:23wilkerluciothe release build does that#2021-03-1623:26underplankhmm... so it does... I wonder where all those other files came from? thanks for you help!#2021-03-1708:29thhellerwatch or compile produce the cljs-runtime dir. release does not and does not need it. it also doesn't clear it though. you can just rm -rf the-output-dir && shadow-cljs release app or so yourself#2021-03-1708:37Robert SchulteI have some trouble regarding source maps in combination with client-side routing in my development build: • When I access my SPA via localhost:<dev-http-port>, everything works as expected. • When I enter via localhost:<dev-http-port>/some/path/within/spa, the browser console is flooded with warnings regarding unresolvable source maps. In Chrome these warnings look like this:
DevTools failed to load SourceMap: Could not parse content for :<dev-http-port>/some/path/within/<:asset-path>/cljs-runtime/<cljs-ns>.js.map: Unexpected token < in JSON at position 0
I have looked into the generated code and reviewed the source maps v3 specification; shadow-cljs writes relative sourceMappingUrl (and sourceURL). According to the spec the browser should resolve sourceMappingURL relative to the "page's origin" for evaled code. As it stands, the only chance I have to make this work is to pass a custom :dev-http :handler that strips /some/path/within from the URL before handing it to the default :handler, correct? Would it make sense to provide an option to have shadow-cljs create absolute URLs for sourceMappingUrl and sourceURL? This would probably only make sense with a single port :dev-http ...
#2021-03-1709:32thheller@rlschulte21 use an absolute :asset-path. so "/js" instead of "js" or whereever you have your files#2021-03-1709:44Robert SchulteThank you so much @U05224H0W! Prepending :asset-path with / has lead to the creation of absolute // # sourceURL and everything works as expected now. Thank you for debugging my configuration without me even sharing it.. Thank you for your quick response and your great work on shadow-cljs:raised_hands:#2021-03-1709:33thhellerno it doesn't make sense to configure this in :dev-http. :asset-path is the config option that controls this.#2021-03-1717:03laurentHi all! I'm trying to set up a cljs project but when I try to add chakra-ui I get a compile error. I tried to figure it out for about an hour but I did not get very far as I'm a newbie. I would appreciate it if a good soul would send me in the right direction. Thanks! (i added @emotion/react but that did not help)
FileNotFoundException: .shadow-cljs/builds/app/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long)
	java.io.FileOutputStream.open0 (FileOutputStream.java:-2)
	java.io.FileOutputStream.open (FileOutputStream.java:298)
	java.io.FileOutputStream.<init> (FileOutputStream.java:237)
	java.io.FileOutputStream.<init> (FileOutputStream.java:187)
	shadow.build.cache/write-file (cache.clj:24)
	shadow.build.cache/write-file (cache.clj:24)
	shadow.build.closure/convert-sources-simple/fn--12171/fn--12173 (closure.clj:2139)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6827)
	clojure.core/reduce (core.clj:6810)
    ....
#2021-03-1720:45thheller@laurent wow that is indeed a long filename. what OS are you on?#2021-03-1804:36laurentHi! I’m using Ubuntu 20.10#2021-03-1809:25thhellerhmm doh#2021-03-1809:26thhellerseems like the maximum filename length is 255 bytes for ext4#2021-03-1809:26thhellerwhich this ridiculous packages manages to use up#2021-03-1809:26thhellerunfortunately I don't have an easy fix for you. this is the first time I see such a long name#2021-03-1812:37laurentThanks @U05224H0W! I search replaced the file name with a shorter name across the project and it works.#2021-03-1803:27emccueBest I can tell shadow is able to send dev builds in a single bundle to the browser#2021-03-1803:27emccueis there any part of the techno wizardry that went in to that which can be used with a deps.edn project?#2021-03-1803:28emccueright now I am working on a project that is using figwheel.main to launch the dev environment, but compared to shadow it is taking forever on refreshes just due to the number of files#2021-03-1803:29emccueand I can't seem to find an option anywhere that would concat those#2021-03-1809:04thheller@emccue figwheel or cljs.main do not support this feature no. you can just use shadow-cljs with deps.edn if you want.#2021-03-1810:24pezHello. I’m writing a library containing just two macros. It’s supposed to work in both CLJS and CLJ (I am having troubles making it work, but that’s a separate issue). It’s a tools/deps project and I have added a shadow-cljs.edn file to it with a :test build that runs my (failing) tests. Now I want to connect my REPL to it. I get No JS runtime if I try to eveluate anything towards the :test build. Is there a way I could make that work? Guessing not, so next question is how do I create a build that I can connect to and use for REPL-ing? I could make a small webapp, I guess, but it still seems a bit heavier than what I really need. Anyone know of a library project out there I could have a look at?#2021-03-1810:32thheller@pez use shadow-cljs node-repl or shadow-cljs browser-repl#2021-03-1810:33thheller:test builds (assuming that is actually :browser-test or :node-test) do not support REPLs#2021-03-1810:40pezIt’s a :node-test. I’m trying to make it using CLJC, so same tests for Clojure as for ClojureScript. They run, but all fail utterly. I want to be able to load the test file and the tested file in the repl. Tried node-repl which also gave me No JS runtime, but I am testing it via Calva, which I haven’t done in a while, so that might be broken. Will try from the prompt now and see what that gives me.#2021-03-1810:43thhellerI guess you are launching the REPL wrong#2021-03-1810:43thhellerlaunching node-repl and then connecting to the test build instead of the node-repl?#2021-03-1810:44thhellerdon't have a clue of calva has a specific option for node-repl#2021-03-1810:44thhellernode-repl will ALWAYS have a JS runtime so if you get the no JS runtime error you likely are not actually using that#2021-03-1810:53pezYes, Calva has a specific option. But it runs shadow-cljs using npx so my mistake was that I didn’t hava package.json with shadow dev deps. Now it works. I can load my files and my library (that let> macro stuff you helped me with over at ClojureVerse) also works. That’s great. But the tests are not passing in the :test build. I’ll see if I can figure that out.#2021-03-1810:53pezCalva also has a browser-repl option, btw.#2021-03-1810:54thhellergood to know#2021-03-1811:00pezSo running the tests taps what I expect them to tap in the shadow-cljs inspector. But the tests add a tap of their own that are then inspected. Works for CLJ, but for CLJS the atom is not updated. The tests all look like this:
(testing "Taps the binding box"
  (let [tapped (atom nil)
        save-tap (fn [v] (reset! tapped v))]
    (add-tap save-tap)
    (is (= [:foo :bar]
           (sut/let> [foo :foo
                      bar :bar]
                     [foo bar])))
    (is (= '[[foo :foo]
             [bar :bar]]
           @tapped))
    (remove-tap save-tap)))
Failing like this:
FAIL in (let>) (pez/taplet_test.cljc:20:11)
Taps the binding box
expected: (= (quote [[foo :foo] [bar :bar]]) (clojure.core/deref tapped))
  actual: (not (= [[foo :foo] [bar :bar]] nil))
#2021-03-1811:58thheller@pez in CLJS the tap is done via setTimeout so it is async#2021-03-1811:59thhelleryou can bind your own tap-fn so it stays sync https://github.com/clojure/clojurescript/blob/715cdc07dbb1d595af91ea12affb6faf0b615d4b/src/main/cljs/cljs/core.cljs#L79-L86#2021-03-1812:30pezThanks. I know this is not the CLJS support, but anyway, does this look sane enough to your eyes?
(defn sync-fn [f] (f))
(def ^:dynamic *dummy* nil)

(deftest let>
  (testing "Evaluates as `let`"
    (is (= [:foo :bar] (sut/let> [foo :foo
                                  bar :bar]
                                 [foo bar]))))

  (testing "Taps the binding box"
    (let [tapped (atom nil)
          save-tap (fn [v] (reset! tapped v))]
      (add-tap save-tap)
      (is (= [:foo :bar]
             (binding [#?(:clj *dummy*
                          :cljs *exec-tap-fn*) sync-fn]
               (sut/let> [foo :foo
                          bar :bar]
                         [foo bar]))))
      (is (= '[[foo :foo]
               [bar :bar]]
             @tapped))
      (remove-tap save-tap)))
 ...
It works, but ¯\(ツ)/¯
#2021-03-1813:18thhellerwell I'd probably swap the binding to just use do for CLJ but this is fine too#2021-03-1813:22thhelleryou can also do #?(:cljs (set! *exec-tap-fn* (fn [f] (f))) somewhere in that file#2021-03-1813:22thhellernot exactly clean but saves having to mess with binding and stuff 😛#2021-03-1814:16pezAh, makes sense. Thanks!#2021-03-1814:34SchpaaWhat is going on here? Getting this error/warning when starting an app of mine.
error when calling lifecycle function app.core/reload! #error {:message "Unexpected compile spec type", :data {:given nil, :type nil}}
eval @ env.cljs:198
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:196
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
G__73437 @ env.cljs:204
eval @ env.cljs:233
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:204
eval @ env.cljs:240
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:49
eval @ browser.cljs:93
eval @ shared.cljs:32
shadow$remote$runtime$shared$process @ shared.cljc:164
eval @ shared.cljs:284
shadow$cljs$devtools$client$shared$remote_msg @ shared.cljs:16
eval @ websocket.cljs:16
#2021-03-1814:36SchpaaAlso getting this when dispatching any events (in re-frame), probably nothing to do with shadow, but hey…#2021-03-1815:22thhelleryeah not shadow. something you do in the reload! method throws an exception. no clue what.#2021-03-1913:37superstructorIf I want to rewrite cljs sources during compilation is there a way to use build hooks to get the result of reading the forms and manipulate the forms prior to macro expansion ? The only way I have figured out so far is hooking into compile-prepare and replacing every cljs file in build state with one at a different tmp path that has been modified. Thoughts ?#2021-03-1913:56thhellerwhat kind of "rewrite" are you thinking about?#2021-03-1913:56thhellercurrently there is no way to hook into the compiler at that level#2021-03-1914:44pfeodrippeHi there o/ Is there any way that I could create standalone js files for each of the entries (or modules)? Or should I create a new build for each (could I watch them all at the same time, I guess it's doable from my part if this is the only way o/)? In the example below, it outputs a shared.js file, it's fine, but standalone would be good for now (I'm trying to use Cypress).
{:builds :....
 {:target :browser
  :output-dir "out/testtt"
  :compiler-options {:infer-externs :auto}
  :modules {:shared {:entries [cypress.core]}
            :cypress.blablabla.edit-test
            {:entries [cypress.blablabla.edit-test]
             :depends-on #{:shared}}

            :cypress.blablabla.add-test
            {:entries [cypress.blablabla.add-test]
             :depends-on #{:shared}}}}}
And thanks for this very awesome piece of software, Thomas o/
#2021-03-1914:56mauricio.szabo@pfeodrippe IFAIK, when you compile the release version, each module will be a single JS file#2021-03-1914:57thhellerI don't understand the question? the whole point of modules is creating multiple files? if you only want one file only use one module?#2021-03-1915:01pfeodrippeOh sorry, I want to create a standalone file for each cypress.blablabla... namespace, right now it creates a thin js file for each, it gives me SHADOW_ENV is not defined error. The only way to do this is through a build (maybe any other dynamic way)?#2021-03-1915:02thhellerI'm missing some basic information I guess. you are supposed to load the shared.js first before loading the other module#2021-03-1915:02thheller(that is where SHADOW_ENV comes from)#2021-03-1915:03thhellerwhy does it have to be a standalone file?#2021-03-1915:03thhellerI have never used cypress so I don't have a clue how it works#2021-03-1915:03thhellerbut to answer your question: no, there is no way to make modules standalone using shadow-cljs#2021-03-1915:04thhelleryou could do it yourself by just concatenating shared.js + the module file#2021-03-1915:04thhellerbut I don't get why you'd need to do that#2021-03-1915:08pfeodrippeOh, thanks. Yes, to load shared.js before appears to be the best approach, I just wanted to check if there was another way. Thanks, @thheller and @mauricio.szabo o/#2021-03-1915:09thhellerwell technically the :target abstraction in shadow-cljs would allow for a :target :cypress and then just take the minimum amount of config to emit the output that fits best for cypress#2021-03-1915:10thhellerbut that is going to be a bit of work since none of the underlying code is documented 😉#2021-03-1915:11pfeodrippeOh very nice! Well, I can check how karma (or some simpler one) works, thanks again o/#2021-03-2111:06jamesmintramHey all - I think this is a shadow question: I have integrated slate using shadow's automatic npm imports. I see this error:
Uncaught TypeError: a is undefined
createGenerator shared.js:27
levels index.js:757
levels: function* levels(editor) {
.....
    yield* levels;
  },
Does anyone know if there some shadow setting I have missed? Or something else obvious?
#2021-03-2111:12thhellerwell the "obvious" answer most likely is that you are looking at the wrong piece of code#2021-03-2111:12thhellermore likely that you are passing an incorrect argument to a function somewhere#2021-03-2111:12thhellerlike where/how are you calling slate?#2021-03-2111:16jamesmintramIn this particular case, the error occurs when I click the slate widget. This is how I have create the slate component:
(defn text-editor* []
  (r/as-element
    (let [editor (slate-react/withReact (slate/createEditor))
          [value setValue!] (react/useState  [{:type "paragraph"
                                             :children [{ :text "A line of text in a paragraph." }]
                                             }])]
      [:> slate-react/Slate {:editor editor
                             :value value
                             :onChange setValue!}
       [:> slate-react/Editable]])))
#2021-03-2111:20jamesmintramI cannot see a call to createGenerator and I notice that the fn above createGenerator in the callstack itself a generator (`yield return..`) - I am guessing google closure does something to insert the call to createGenerator#2021-03-2111:22jamesmintram(which led me to wonder if there were any compiler settings I could tweak via the shadow config)#2021-03-2111:23thhellerand you did verify that editor is actually what you expect? I mean log it or so. I don't have a clue what any of this does but the code looks very suspicious#2021-03-2111:24jamesmintramI will check!#2021-03-2111:31jamesmintramYep - it's what I expect#2021-03-2112:00superstructor@thheller Would you consider providing a new build hook that gives access to change/replace forms ? i.e. after the reader step but prior to compilation, ideally before macro expansion ? Is it even a feasible idea or difficult to provide ?#2021-03-2113:13thheller@jamesmintram I cannot say without an reproducible example. much of the code you posted looks very suspicious though. for example in the react/useState you are using a CLJS datastructure that you then hand to the slate-react/Slate via :value. so unless slate-react is some kind of CLJS wrapper for slate that will likely not work. also the (slate/createEditor) would recreate the editor on every render.#2021-03-2114:43jamesmintramThanks. I think I have found something interesting (maybe not!) but inside the function that fails, I see
arguments: undefined
arguments: Arguments(2) [{…}, {…}, callee: ƒ, Symbol(Symbol.iterator): ƒ]
inside of chrome's Scope Local display. Clearly something weird there. Should I be asking about this in the more general clojurescript or could this be some weird compilation/module bundling thing caused by shadow?
#2021-03-2114:45jamesmintram(I've updated the code to use r/with-let and clj->js on the maps provided. Strangely, the observed behaviour did not change (I originally though there was some magic happening doing the clj->js conversion behind the scenes)#2021-03-2114:50thhellerI can almost guarantee that you are looking at the wrong place#2021-03-2114:50thhellerthis is almost certainly not a bug in clojurescript or shadow-cljs#2021-03-2114:51thhellerit is far more likely that something in your code is either passing some incorrect data or calling a wrong function or so#2021-03-2114:51thhellerI cannot possibly help you with that without seeing more code#2021-03-2114:51thhellerdigging into the tools before you debug your own code is not useful#2021-03-2114:52thhellermake sure that all the data you are passing around is exactly what you are supposed to pass around#2021-03-2114:53thhellerof course this could be a problem in shadow-cljs or cljs but 99% of the time it isn't#2021-03-2114:53jamesmintram> I can almost guarantee that you are looking at the wrong place > > > Ok. Thanks. I'll pull it into a minimal example. (it will probably start working then 😂 )#2021-03-2114:53thhellerso stop looking at library implementation code and investigate your own code first#2021-03-2114:53thhellerthis also all appears to be using react hooks so make sure you are actually using a modern reagent version with functional components#2021-03-2113:15thheller@superstructor what is the use case? it would be fairly easy to provide such a hook but depending on what it wants to do might be rather tricky to integrate. eg. caching might be affected.#2021-03-2113:16superstructorThe use case is for debugging/tracing tooling without having to insert macros throughout the source code, so to do the transformation instead in dev builds.#2021-03-2113:17superstructorLike, for example adding fn-traced (re-frame-debux) macro to trace all the values of all the forms in all functions throughout an entire codebase; or on specific namespaces with a metadata tag.#2021-03-2113:17superstructorUnfortunately would need to modify ns form to add :requires as well, so I imagine that would make it more difficult to integrate ?#2021-03-2113:22thhelleryes, as soon as it affects more than just the form you are processing things get tricky#2021-03-2113:22thhellerI spent quite a bit of time thinking about an integrated tracing solution in shadow-cljs myself and the UI and tap> integration is basically the first step in that direction#2021-03-2113:23thhellersince being able to store the traces and looking at them remotely is probably the hardest part#2021-03-2113:24thhellerbut nothing practical regarding the tracing is implemented yet#2021-03-2113:26superstructorwhat are the main missing pieces ? instrumenting an entire codebase without manually adding tap ?#2021-03-2113:29thhellerwell I don't know. I don't really mind adding an extra require and calling something as long as that something doesn't get in the way in release builds and just seamlessly disappears#2021-03-2113:30thhellerso once that exists there could be an extra convenience thing that allows you to skip that extra require and uses metadata or so to control what is traced#2021-03-2113:31thhellertracing the entire codebase will IMHO give you way too much data you don't really care about. it is more about tracing app semantics (eg. event A -> B -> C) than tracing (+ x 5)#2021-03-2113:31thhellerat least for me#2021-03-2113:32superstructoryes, agreed. Our main use case is tracing re-frame event handler functions, and probably only namespaces tagged by the developer by metadata. But also wouldn't want to design a re-frame only solution for shadow-cljs, obviously.#2021-03-2113:35thhelleryeah dunno how that would look#2021-03-2113:35superstructorIdeally, we'd like to be able to • look at the namespace metadata for a ^:re-frame/trace • If it is there, then look for all reg-event-* forms in that ns • Replace all the fn or defn forms in those forms with fn-traced or defn-traced from re-frame-debux • Or, if macroexpansion has already run just do the equivalent of the re-frame-debux macroexpansion inline, but we would still need to refer to some helper fns / global state to store the tracing via requires. #2021-03-2113:37superstructorIn :compile-prepare I see a bunch of files in the build-state . Can one just replace those files in their entirety with a different file (i.e. read the file, modify it, write it out to a tmp location) then return the new tmp files in the build state ? or is that a really bad idea ?#2021-03-2113:39thhellerwell kind of a bad idea yeah#2021-03-2113:39thhellerin :compile-prepare all dependencies are already resolved. so you cannot add a new require or so for example.#2021-03-2113:42thhellerbut I honestly don't see a problem with the current re-frame tracing stuff apart from how the macros work. you could rewrite those fairly simply so they don't rely on switching classpath dependencies or shadow-cljs :ns-aliases#2021-03-2113:47thhellerbut yeah I don't have an answer for you if your goal is to get rid of some extra require/forms and only control it via metadata instead#2021-03-2113:48thhellershadow-cljs will actually get in your way if you try to do that more than cljs.main would#2021-03-2113:49thhellersome of the stuff shadow-cljs does favors more repeatable/predictable builds so sacrifices some more dynamic aspects of the compilation that would technically be possible#2021-03-2113:53superstructorall good 👍:skin-tone-2:Thanks for all the info. I will think some more about it.#2021-03-2115:09zendevil.ethNot sure if this is a shadow-cljs issue or a react-native issue, but I’ve found that when I make a change in my app and save it, and after the shadow-cljs compiler compiles the code, instead of getting a refresh (live reload is on), I’m seeing the whole js bundle reloading each time. Is there a way to prevent the whole bundle reloading each time?#2021-03-2115:10thhellerthat is likely the default built-in react-native reloading mechanism. you should turn that off. no clue how. used to be an option in the react-native menu thingy on the device.#2021-03-2115:11zendevil.ethBut when I “Disable Fast Refresh” in the React Native Debug Menu, the refresh also stops so the app isn’t updated#2021-03-2115:12thhellershadow-cljs provides it own hot-reloading and you need to turn off all built-in reloading from react-native as they will otherwise interfere#2021-03-2115:13thhellerI cannot help you debug hot-reload issues other than point at the example that has it built-in and working https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L33-L39#2021-03-2115:14thhellerthe core essential part of the render-root call. if you do not use that you are on your own and I cannot help.#2021-03-2115:16zendevil.ethIn fact, I am using render-root and also added {:dev/after-load true} but the refresh doesn’t happen#2021-03-2115:17thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2021-03-2115:18thhellercheck "things to avoid" ... you might be doing one of those#2021-03-2115:37zendevil.eth@thheller I have goog.object/get in a reframe handler. Does that come under “missing :ns require”?#2021-03-2115:39zendevil.ethAnd of course I have js/#2021-03-2115:39zendevil.ethOther than that, I’m not using defonce at all#2021-03-2115:39zendevil.ethand am using the init-fn#2021-03-2115:40zendevil.eth
{:deps true
  :builds
 {:test
  {:target    :npm-module
   :output-dir "test-out"
   :entries [humboi.core-test]}
  :dev
  {:target     :react-native
   :init-fn    humboi.core/init
   :output-dir "app"
   :compiler-options {:closure-defines
                      {"re_frame.trace.trace_enabled_QMARK_" true}}
   }}}
#2021-03-2115:40zendevil.eth
(defn
  init
  {:dev/after-load true}
  []
  (dispatch [:register-db])
  (render-root "Humboi" (as-element [root-comp])))
#2021-03-2115:40thhellerthis is impossible to debug without seeing more code. I don't have a clue what the :register-db thing does or the root-comp#2021-03-2115:41thhellerone common issue is storing functions in your app database for example#2021-03-2115:41thhellerthose are not hot-reloaded and will you will end up calling "old" code instead of the new#2021-03-2115:41zendevil.eth
(defn
  init
  {:dev/after-load true}
  []
  (render-root "Humboi" (as-element [view])))
Change to this ^^, but still no hot-reloading
#2021-03-2115:42zendevil.ethI’m not storing any functions in the app database#2021-03-2115:43thheller> this is impossible to debug without seeing more code#2021-03-2115:44thhelleradd a (js/console.log "foo") to the init fn to check if its actually getting called#2021-03-2115:44thhellerif so it is all up to your code#2021-03-2115:45zendevil.ethno it’s not being called#2021-03-2115:45thhelleris the websocket connected?#2021-03-2115:46zendevil.ethhow does one tell?#2021-03-2115:46thhellerlog should say so#2021-03-2115:46thhelleror open the UI http://localhost:9630/runtimes should be listed there#2021-03-2115:47zendevil.ethnew metro logs have stopped ever since I turned off live reload in the emulator#2021-03-2115:48zendevil.ethYes there’s one “21 minutes ago”#2021-03-2115:48thhellerthere must be at least 2? the first #1 is the CLJ runtime#2021-03-2115:49zendevil.eth#2021-03-2115:49thhelleryes, that is missing the react-native runtime. so the websocket is not connected.#2021-03-2115:50zendevil.ethhow do I connect the websocket?#2021-03-2115:50thhellerI assume you have the watch running so it should connect automatically#2021-03-2115:51thhellerif not look for the error message in the log#2021-03-2115:51zendevil.eththere’s no error message in the shadow log#2021-03-2115:51thhellernot talking about the shadow log#2021-03-2115:51thhellerreact-native log#2021-03-2115:52zendevil.eththe last log is the following:
giving up trying to connect
#2021-03-2115:52thhellerdidn't we already talk about the IP stuff before? it might be picking an incorrect IP address so you need to tell it the correct one#2021-03-2115:52thhellereither by setting :local-ip "1.2.3.4" in your build config or shadow-cljs watch app --config-merge '{:local-ip ...}'#2021-03-2115:59zendevil.ethI removed some :devtools from shadow config and it works now. Thanks for your time @thheller 🙂 The periodic websocket disconnects are gone as well.#2021-03-2116:57noorvirI’m a newbie so apologies if this is naive: how do you release a reagent app built with shadow-cljs release app ? I create an app template using create-reagent-template. I’m using shadow-cljs with the lein flag set to true. The dev setup works using shadow-cljs watch app but I noticed there’s no index.html file generated. Similarly, when I build the release version, there’s not index.html . I’m failing to understand what is the entry point of the reagent app. I’m trying to deploy to Firebase Hosting but predictably it complains with a 404. Here’s my shadow-cljs.edn :
{:lein         true
 :builds       {:app {:target     :browser
                      :output-dir "public/js"
                      :asset-path "/js"
                      :modules    {:app {:entries [noorvir.com.core]}}
                      :devtools   {:after-load noorvir.com.core/mount-root}}}
 :dev-http     {3000 {:root    "public"
                      :handler noorvir.com.handler/app}}}
Thanks in advance!
#2021-03-2116:58thheller@noorvir.aulakh creating the index.html is your job. shadow-cljs does not handle html generation.#2021-03-2117:00noorvirI tried that too. This is the index.html file I have in the public folder right not:
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <link href="/css/styles.css" rel="stylesheet" type="text/css">
</head>
<body class="body-container">
<div id="app"></div>
<script src="js/app.js" type="text/javascript"></script>
</body>
</html>
Am I supposed to call an init method somewhere?
#2021-03-2117:00thhellerwith your build config yes#2021-03-2117:01thhelleryou can swap :entries [.core] to :init-fn .core/init#2021-03-2117:35noorvirOk this worked! It took way longer because the function was called init! which I didn’t notice.#2021-03-2117:01thhellerthen the code will call that fn on load#2021-03-2117:02thhellerhow do you handle this in dev? this is not specific to release? what did your :handler do?#2021-03-2117:07noorvirOk trying this out now. This is the handler that was generated by the template:
(def app
  (reitit-ring/ring-handler
    (reitit-ring/router
      [["/" {:get {:handler index-handler}}]
       ["/items"
        ["" {:get {:handler index-handler}}]
        ["/:item-id" {:get {:handler    index-handler
                            :parameters {:path {:item-id int?}}}}]]
       ["/about" {:get {:handler index-handler}}]
       ["/cards" {:get {:handler cards-handler}}]])
    (reitit-ring/routes
      (reitit-ring/create-resource-handler {:path "/" :root "/public"})
      (reitit-ring/create-default-handler))
    {:middleware middleware}))
#2021-03-2117:08thhellerso in dev you have a server but in production you don't? I'm confused#2021-03-2117:38noorvirI was for serving files for local dev I assumed. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http It did seem a little odd to me that there should be two different entry points.#2021-03-2118:54thhelleryeah if you don't do anything server-side then just a regular index.html and :dev-http {3000 "public"} is enough#2021-03-2117:35noorvirOk this worked! It took way longer because the function was called init! which I didn’t notice.#2021-03-2117:38noorvirThanks a lot for the help! 🙌 🙏#2021-03-2120:19ribeloI thought there was a page/app somewhere that allowed to see what js output#2021-03-2120:19ribelounfortunately I can't find#2021-03-2120:20ribeloand unfortunately I didn't save#2021-03-2120:22ribelook, found it#2021-03-2212:04grounded_sageDoes shadow offer any conveniences for benchmarking and possibly across JS VM’s by any chance?#2021-03-2215:16thhellerno#2021-03-2215:25grounded_sageTime for an adventure then I guess haha#2021-03-2215:35thhelleryeah too many factors to make a generic setup#2021-03-2215:36thhellerI did some benchmarks recently using the js-framework-benchmark https://github.com/thheller/js-framework-shadow-grove#2021-03-2215:37thhellerbut thats a rather specific benchmark#2021-03-2215:38thhellersome older benchmarks I used the npm benchmark package https://github.com/thheller/shadow-experiments/blob/master/src/test/shadow/experiments/grove/bench_db.cljs#2021-03-2215:38thhellerworks ok but not great#2021-03-2217:55grounded_sageYea there is a cascade of dependencies and system requirement 😅#2021-03-2219:25grounded_sageDo you know if this is the right way to go for testing libraries @U05224H0W? Or am I going down the wrong path here? https://clojurescript.org/community/running-tests#2021-03-2219:26thhellerI don't understand the question#2021-03-2219:26thhellertesting what?#2021-03-2219:28grounded_sageI’m trying to figure out the best way to benchmark Datahike across different JS VM’s. I also guess this would not work with IndexedDB and only work for in-memory so I would need to actually have the headless browsers. So perhaps I am going down the wrong path.#2021-03-2219:32thhellerwhat are different JS VMs for you? you mean just different browsers or actually different lower level JS VMs without being hooked up to a browser, so jsc directly instead of safari?#2021-03-2219:33thhellerI mean if you intend this to run in the browser then I'd be testing the browsers?#2021-03-2219:44grounded_sageWe do intend to offer node support etc. Despite the value prop in our opinion not being that high compared to using it on JVM. So I was investigating the most general testing and then going to work to more specific. From my basic tests at the REPL the in-memory is pretty similar to IndexedDB so I was thinking that this would give us the best view into our performance. We could then more accurately identify where the performance problems are.#2021-03-2219:46grounded_sageArguably some people might want to do some IOT stuff using Datahike from JS.#2021-03-2219:46grounded_sageOr even Cljs#2021-03-2215:59pinkfrogIs there any equivalent for deps.edn https://github.com/shadow-cljs/lein-template ?#2021-03-2216:03thhellerdon't know#2021-03-2216:03pinkfrogCurrently I manually touch a shadow-cljs.edn and add stuff according to the user manual. Dunno if it is the normal flow to go.#2021-03-2216:04thhellerI use the create-cljs-project described here https://github.com/thheller/shadow-cljs#quick-start#2021-03-2216:05thhellerbut that just sets up the minimum folder structure and config file, not a complete template if you are looking for that#2021-03-2302:51zendevil.ethI’m trying to load the following in my shadow repl:
(ns humboi.events
  (:require
   [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] 
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [ajax.edn :as edn]
   [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax]
   [day8.re-frame.http-fx]
   [cljs.core.async :refer [go]]
   ))
However, I’m getting this error:
1. Unhandled java.io.FileNotFoundException
   Could not locate day8/re_frame/http_fx__init.class, day8/re_frame/http_fx.clj
   or day8/re_frame/http_fx.cljc on classpath. Please check that namespaces with
   dashes use underscores in the Clojure file name.
why is the repl looking for java files? Why am I on a clojure repl? In the same repl, when I do (shadow/watch :dev) it works and the watch is running smoothly too.
#2021-03-2305:10TuomasI think it's because the shadow process is a clojure process. In there you can start "watching" a build but if you want to connect to do it, you need to it via (shadow/repl :the-build) Are these of any help to you? https://shadow-cljs.github.io/docs/UsersGuide.html#build-repl https://shadow-cljs.github.io/docs/UsersGuide.html#_clojure_repl https://shadow-cljs.github.io/docs/UsersGuide.html#_nrepl_usage https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration#2021-03-2312:07zendevil.eth@UH9091BLY when I select the shadow option in cider, and try to run (shadow/watch :dev), I get No available cljs runtime#2021-03-2312:15zendevil.ethI’m using react-native and yes the react-native app is open#2021-03-2312:22zendevil.ethhow to get the runtime when the build target is react native?#2021-03-2312:24zendevil.ethnevermind I had to turn on debugging#2021-03-2315:00dpsuttoni'm running shadow-cljs run shadow.cljs.build-report app report.html and getting an error:
Caused by:
NoSuchFileException: .shadow-cljs/release-snapshots/app/latest/goog.debug.error.js.map
I've tried created the build both after a compile and a release but get the same error. Project is :npm-module. Anyone ever see anything like this?
#2021-03-2315:12dpsutton#2021-03-2315:26thheller@dpsutton build reports are only supported for :browser builds. doesn't make sense for :npm-module builds since they are "incomplete"#2021-03-2315:26dpsuttonmakes sense. thanks @thheller#2021-03-2409:44bbssI'm trying to use the material-ui/ which also uses @emotion/styled and @emotion/react and running into some issues with the :require/:refer:
core.js:1662 TypeError: module.keyframes is not a function
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple (TouchRipple.js:58)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$ButtonBase (ButtonBase.js:37)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$index (index.js:34)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$AccordionSummary$AccordionSummary (AccordionSummary.js:31)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$AccordionSummary$index (index.js:27)
    at shadow.js.jsRequire (js.js:66)
I'm using shadow-cljs 2.11.20 Which seems to be the :refer of https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/index.js#L20
#2021-03-2409:55thhellerin general when using @next packages you are on your own. they are unreleased preview alpha packages that very likely contain some breaking changes that might not match "current" documentation or so#2021-03-2409:55thhellerit is also often much more likely to run into version conflicts#2021-03-2409:55thhellerdon't know why you linked the above but this is the call that seems to fail https://github.com/mui-org/material-ui/blob/next/packages/material-ui/src/ButtonBase/TouchRipple.js#L14#2021-03-2409:56thhellerso maybe you don't ahve the correct version of this package @material-ui/styled-engine#2021-03-2410:15bbssAlright, that makes sense. Thanks for having a look as always, seeing if I can find that magical npm packages combo.. 🙂#2021-03-2415:33pinkfrogI wonder what makes running shadow-cljs significantly faster when :deps true is not enabled. Isn’t shadowcljs itself a jvm library that ultimately leverages java regardless :deps is enabled or not?#2021-03-2415:46thheller@i running or starting? running should not be much of a difference#2021-03-2415:46thhellerstartup speed is faster because shadow-cljs.edn uses the aot artifact by default#2021-03-2415:46thhelleryou can switch the thheller/shadow-cljs dependecy to thheller/shadow-cljs$aot in deps.edn I think#2021-03-2416:16pinkfrogso in theory, if I switch to the $aot version, there should not be a different#2021-03-2416:16pinkfrogright?#2021-03-2416:27thhellerdepends on what you are doing. startup speed should be similar then yes#2021-03-2423:02Ian Fernandezthere's a way to invoke lein's with-profile with shadow-cljs, like when I use aliases with -A using deps.edn?#2021-03-2508:34thheller@d.ian.b no, just use lein directly if you need that. lein with-profiles +foo run -m shadow.cljs.devtools.cli release app or whatever would be similar to shadow-cljs release app#2021-03-2519:18Ian Fernandezthanks#2021-03-2613:50Volodymyr HuzarWe have :ssl in our configuration which enabling https for all builds. Is it possible to run :devtools for one of the build on http? To add more context: I am trying to run tests using https://github.com/lambdaisland/kaocha-cljs2 and having https there adding a lot of overhead to setup all the tools to have proper certificates provided everywhere. Also Chrome complains with registering custom ServiceWorkers when self signed certificates are used which seems to be configurable but again adds another overhead.#2021-03-2617:02thheller@vguzar in 2.11.26 I added an option to allow that. :dev-http {3000 {:root "public" :ssl false}}#2021-03-2618:38Volodymyr Huzar@U05224H0W seems it will not fix a problem I have. A :dev-http is a global configuration, isn’t? What I need to run one of the builds (test one) on http, but I want application build still to be run using https. Is it possible to solve somehow, maybe disable ssl using :devtools configuration?#2021-03-2618:40thhellerthe http servers are ALWAYS global, the :devtools :http-root and :http-port are old configuration and were replaced by :dev-http#2021-03-2618:40thhellerso if you previously had :devtools {:http-port 3000 :http-root "public"} that should instead be :dev-http {3000 "public"} or the the example above with the disabled :ssl#2021-03-2618:41Volodymyr Huzaroh, good to know that, doesn’t it complicates the things? how to serve different roots for different builds now?#2021-03-2618:42thhellerno, it makes things much simpler. it was my mistake allowing the devtools http config in a config for the build. that was never how it worked and the dev-http matches more closely how it actually works#2021-03-2618:43thhellerif you need multiple servers you just use multiple ports#2021-03-2618:43thheller:dev-http {3000 {:root "public" :ssl false} 3001 "something-else"}#2021-03-2618:43Volodymyr Huzaroh, got it#2021-03-2618:44Volodymyr Huzarby the way the latest release I see here https://github.com/thheller/shadow-cljs/releases is 2.11.13#2021-03-2618:44thhellerhttps://clojars.org/thheller/shadow-cljs#2021-03-2618:50Volodymyr Huzarthanks a lot! everything, works as expected now#2021-03-2617:14haywoodapologies… but has anyone run into this? I’m dusting off a project that hasn’t been touched in like a year
[:failed-to-compare "^16.13.1" "16.9.0" #error {
 :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
 :via
 [{:type java.lang.NullPointerException
   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
 :trace
 [[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]
  [shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]
  [shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]
  [shadow.cljs.devtools.server.npm_deps$fn__17458$fn__17459 invoke "npm_deps.clj" 46]
  [clojure.lang.Delay deref "Delay.java" 42]
  [clojure.core$deref invokeStatic "core.clj" 2320]
  [clojure.core$deref invoke "core.clj" 2306]
  [shadow.cljs.devtools.server.npm_deps$fn__17458$fn__17461 invoke "npm_deps.clj" 52]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]
  [shadow.cljs.devtools.server.npm_deps$main$fn__17546 invoke "npm_deps.clj" 223]
  [clojure.core$complement$fn__5669 invoke "core.clj" 1441]
  [clojure.core$filter$fn__5893 invoke "core.clj" 2821]
  [clojure.lang.LazySeq sval "LazySeq.java" 42]
  [clojure.lang.LazySeq seq "LazySeq.java" 51]
  [clojure.lang.RT seq "RT.java" 535]
  [clojure.core$seq__5402 invokeStatic "core.clj" 137]
  [clojure.core$seq__5402 invoke "core.clj" 137]
  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]
  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]
  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]
  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$apply invoke "core.clj" 660]
  [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]
  [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.core$apply invokeStatic "core.clj" 665]
  [clojure.main$main_opt invokeStatic "main.clj" 514]
  [clojure.main$main_opt invoke "main.clj" 510]
  [clojure.main$main invokeStatic "main.clj" 664]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}]
#2021-03-2617:14haywoodversions:
=== Version
jar:            2.11.25
cli:            2.11.25
deps:           1.3.2
config-version: 2.11.25
#2021-03-2617:16thheller@haywood looks like you upgraded to java JDK 15+ in the meantime? that removed the Nashorn JS engine previously used. need to upgrade shadow-cljs.#2021-03-2617:17thhellerthe above versions would have the fix but you might be using deps.edn or project.clj to manage your dependencies so you'd need to upgrade shadow-cljs there#2021-03-2617:18haywoodoof why do I have shadow in my deps.edn AND package.json#2021-03-2617:20haywoodwell, that fixed it, was only upgrading the version in the package.json…#2021-03-2617:32Azzuritewhenever I get some kind of runtime error during reload while developing, there's a small error dialog fixed at the bottom of the page. This does not disappear until I completely reload the page. Is that a bug or supposed to be like that?#2021-03-2617:33thhellerdefine runtime error?#2021-03-2617:33Azzurite#2021-03-2617:34AzzuriteI fix that, and the page reloads again and everything is fine, except that the error stays at the bottom#2021-03-2617:35thhellerok that looks like you are running code directly on load? (eg. directly calling (render)) in your file? you should not be doing that.#2021-03-2617:35Azzuritewell yeah, when I load the page the js should execute, should it not?#2021-03-2617:36thhellerno, you should be using the lifecycle hooks provided for that https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2021-03-2617:36thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2021-03-2617:38Azzuriteoh thanks so basically use one namespace on the production site that immediately executes and another with the lifecycle hooks while developing?#2021-03-2617:38thhellerno, use :init-fn in your module to call the code you want to run on startup#2021-03-2617:38Azzuritehm#2021-03-2617:38Azzuriteok well I'll read some more#2021-03-2617:38thhelleras the blogpost explains#2021-03-2617:39thhellerthe pattern of swapping out namespaces in production is bad and absolutely advised against#2021-03-2617:41Azzuriteyeah I only read the user guide and maybe I didn't understand that perfectly#2021-03-2617:42Azzuriteit seemed more like "you can do that if you want" not "you need to do that actually"#2021-03-2617:42thhellerwell the issue with running code directly on load is that it interrupts that reload cycle#2021-03-2617:42thhellershadow-cljs cannot know WHAT failed during load, it only knows that something failed and abort#2021-03-2617:42thhellerleaving your code in an undefined state#2021-03-2617:43Azzuritemakes a lot of sense, just didn't get that by myself 😄#2021-03-2617:43Azzuritethanks#2021-03-2617:43thhellerthats why the error dialog doesn't go away#2021-03-2617:43Azzuriteso much shit to learn when you're teaching yourself#2021-03-2617:44Azzurite😄#2021-03-2617:44Azzuritereally appreciate the help & quick reply ❤️#2021-03-2617:45thhelleryeah thats why shadow-cljs tries to keep everything as minimal as possible. unfortunately some older blogposts, tutorials, templates use more complex setups making things more complicated than they need to be. IMHO, YMMV 😛#2021-03-2618:00Azzuriteyeah I'm not an inexperienced dev, only in clj/cljs... I so so love getting everything as simple as possible, which is basically what I've been doing so far. And shadow-cljs is a really nice piece of software in the simplicity area#2021-03-2706:16raspasov@UCULU82G3 “as simple as possible” sounds like you’re on the good path 🙂#2021-03-2712:07Azzurite@U050KSS8M yeah over-engineering is very rampant where I'm from, took a bit to get to this path not easy when you're doing it alone and "only" trying to scour the interwebs for the "right things to do" - so much knowledge in people's heads but not written down I feel 😄#2021-03-2716:50raspasov@UCULU82G3 “over-engineering” - what language/framework?#2021-03-2719:40Azzurite@U050KSS8M I more meant geographically/where I've been working/studying so far, Germany but language is Java/C#/JS mostly#2021-03-2720:18raspasov👍 understood :)#2021-03-2622:31andersmurphyDoes anyone know of a good example of using a service worker with shadow-cljs?#2021-03-2622:33andersmurphy(in terms of shadow-cljs.edn set up)#2021-03-2708:37thheller{:target :browser :modules {:sw {:init-fn my.sw/init :web-worker true}}} should be ok#2021-03-2709:26thhellerFWIW I think its better to use a dedicated tool for this like https://developers.google.com/web/tools/workbox#2021-03-2709:45andersmurphy🙏#2021-03-2704:30lispers-anonymousI'm having issues using the vega-embed library from npm with shadow-cljs that I would like some help with. I will put all the details of my problem in a thread so it doesn't get too noisy.#2021-03-2704:31lispers-anonymousIn my package.json I have the following dependencies declared
"dependencies": {
    ...
    "vega": "5.20.0",
    "vega-embed": "6.17.0",
    "vega-lite": "5.0.0"
	...
}
When the application starts up, these warnings show up in the browser console as soon as the application loads.
shadow-cljs - failed to load module$node_modules$d3_array$dist$d3_array js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_format$build$vega_format js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_loader$build$vega_loader js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_dataflow$build$vega_dataflow js.js:74:16
shadow-cljs - failed to load module$node_modules$vega$build$vega_node js.js:74:16
shadow-cljs - failed to load module$node_modules$vega_embed$build$vega_embed
In my cljs code, I'm attempting to use the vega library like this.
(ns components.charts.vega-chart
  (:require
    ;; ...
    ["vega-embed" :as vega-embed]))
	
;; later in the namespace
(vega-embed/embed node spec options)
The value of vega-embed is an empty javascript object. The problem seems to be occuring before I even get to exectue this code. If I evaluate any of my cljs code that makes use of vega-embed I get a bunch of errors that all trace back to the vega code not being loaded (nils, not a function, etc) Would anyone be able to help me get to the bottom of this?
#2021-03-2704:40lispers-anonymousDamn. Everytime I sit down and write up a big question for slack I find a solution right after. Adding :output-feature-set :es6 to my shadow-cljs :compiler-options map fixed this for me. I got the idea from this post https://stackoverflow.com/questions/64461818/require-aws-amplify-v-3-amplify-and-auth-classes-in-clojurescript-reagent-shadow#2021-03-2816:37Jack ArringtonMaybe a dumb question, but is there an equivalent to the :autorun option for a build with a :browser-test target? I find it pretty useful to be able to run the test with one command, like the :node-test ones#2021-03-2817:19thhellerthey run automatically when you open the browser-test output in a browser. for automated stuff use :karma#2021-03-2911:12valerauko@thheller have you made any progress with :target :esm and watch ? is there anything I could help with in that direction?#2021-03-2911:36thhellerwatch works fine but I assume you mean hot-reload? that is runtime dependent and not implemented for deno#2021-03-2911:38thhellerbasically what is need is an equivalent to this https://github.com/thheller/shadow-cljs/blob/f7a360d52dfae654ff17d7a5335943beabaf163c/src/main/shadow/cljs/devtools/client/node.cljs#2021-03-2911:38thhellerjust using deno not node specific stuff#2021-03-2911:45thhellerif you want to work on that you can do so by setting :target :custom :devools {:client-ns the.ns-you-work-on}} in your build config#2021-03-2911:47thhellerits not documented much but happy to answer questions. it is fairly low level code but pretty straightforward.#2021-03-2912:06simongrayHaving some troubles with using clojure.data.csv in a macro. Been following the approach in this guide: https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html I have a load.clj :
(ns load
  (:require [clojure.data.csv :as csv]
            [ :as io]))

(defmacro timeline
  []
  (with-open [reader (io/reader (io/resource "timeline.csv"))]
    (doall (csv/read-csv reader :separator \;))))
and a load.cljs :
(ns load
  (:require-macros [load]))
but when I try to require and then use it from my user.cljs , e.g.,
(ns user
  (:require [load :as load]))

(def timeline-data
  (load/timeline))
I get an error which seems to be related to the amount of lines in the csv file (433)
#2021-03-2912:07simongrayHowever, if I wrap replace the use of the macro with (macroexpand '(load/timeline)) then it works. I’m sure I’m just doing some n00b macro error here.#2021-03-2912:07thhellerbe mindful of what that macro is returning. right now it is returning a sequence ala ([1 2 3] [3 4 5])#2021-03-2912:08thhellerso it will be executed as such when compiling, ending up as an actual function call. swap the doall with a vec and it should be ok#2021-03-2912:09simongrayahhhh. I knew it was something silly like that. Thanks! And thank you for the guide too.#2021-03-3014:14pmooserIn Brave, I see a warning now regarding SharedArrayBuffer and it looks like it originates from something like shadow$provide.module$node_modules$scheduler$cjs$scheduler_development.#2021-03-3014:14pmooserIs this a known issue that an update will address? Or not yet?#2021-03-3014:19pmooser(it's just a deprecation warning from the browser)#2021-03-3015:17thheller@pmooser that is a library you are using, or rather that react is using. I have no control over that and shadow-cljs is not involved in that.#2021-03-3015:18thhelleryou can check the repo if there is an issue about it. there probably is.#2021-03-3016:06pmooserOk, sorry about that. I didn't realize!#2021-03-3016:41wombawombais there a way to get custom formatters and/or a CLJS REPL in Chrome devtools when using shadow-cljs?#2021-03-3020:36Jack ArringtonMaybe not exactly what you want, but if you want to make your Chrome devtools more CLJS friendly you might check out Dirac: https://github.com/binaryage/dirac#2021-03-3020:39Jack ArringtonI haven't personally used it (honestly, I've just been too lazy to set it up), but I've heard a lot of praise for it in the community#2021-03-3021:00wombawombaDoes Dirac work with shadow-cljs?#2021-03-3021:09Jack ArringtonIt should work with any Clojurescript code running in a browser. Shadow-cljs is just a build system.#2021-03-3109:04wombawomba@U05224H0W can you confirm this?#2021-03-3109:06thhellerno. dirac does not work. or it didn't use to work, it has been a while since I looked.#2021-03-3109:09wombawombaokay thanks 🙂#2021-03-3016:49thhellercustom formatters you can just use cljs-devtools. a REPL no.#2021-03-3021:00wombawombaalright, thanks#2021-03-3021:42dpsuttoni'm seeing some strange compiler output
(defn js-i18n [format-string-string & args]
  (js* "ttag/t`~{}`" format-string-string)
  (apply ttag/t (-> format-string-string chomp-format-string into-array) args))
i'm playing around with emitting a tagged format literal in js for our i18n. And strangely, this is emitting
(metabase.shared.util.i18n.js_i18n.cljs$core$IFn$_invoke$arity$variadic = (function (format_string_string,args){
ttag/t`format_string_string`;

return cljs.core.apply.cljs$core$IFn$_invoke$arity$3(shadow.js.shim.module$ttag.t,cljs.core.into_array.cljs$core$IFn$_invoke$arity$1(metabase.shared.util.i18n.chomp_format_string(format_string_string)),args);
}));
which is including the name of the var, not its contents: ttag/t'format_string_string' (had to use apostrophes instead of backticks here). however, evaluating (js* "1 + ~{}" x) at a repl where x is (def x 3) correctly yeilds 4. So it seems to resolve at runtime in a repl but under advanced compilation uses the local name
#2021-03-3021:47thhellerI don't understand. that is producing exactly the code it is supposed to?#2021-03-3021:49thhellerthis (js* "1 + ~{}" x) ends up as 1 + x in the code so of course that is valid?#2021-03-3021:49thhellerunless I'm missing something?#2021-03-3021:49dpsuttonoh i see. i was thinking it would end up as 1 + 3 instead of 1 + x with that being a valid local#2021-03-3021:49dpsuttonand now i realized i had thought myself into a silly place 🙂#2021-03-3021:50thhelleryeah the string literals are difficult to emulate#2021-03-3021:50dpsuttoni'm fighting against an i18n library that has a plugin to enumerate all strings for translation that looks for tagged template literals. and i'm working on how i can get some cljs code to play nice with that#2021-03-3021:51thhellermacro is the only way I'm afraid#2021-03-3021:54dpsuttonthat would use the js* special form? or does that strike you as the wrong approach?#2021-03-3021:54thhellerit would need to use that since the compiler otherwise isn't currently able to emit those#2021-03-3021:55dpsuttonawesome. thanks for your help and sorry for the wall of text for a really dumb question 🙂#2021-03-3021:55thhellerI mean support could be added via magic but that is a rather advanced task 😛#2021-03-3021:58dpsuttonyeah. and since they are callable as functions its not a big hindrance. just a bummer that their plugin to find them looks over the ast for tagged literals in particular#2021-03-3022:23thheller@dpsutton https://github.com/thheller/shadow-cljs/commit/e043d5be60877bd1d367080a9a41fc9d12364b91 😉#2021-03-3022:25thhellerneed to finish up some more testing with new CLJS version and then that'll be in the next release#2021-03-3022:25dpsuttonthat's close but if its possible to put a tag on front that would be nice#2021-03-3022:26thheller(js/ttag.t (js-template "foo"))?#2021-03-3022:28dpsuttoni don't think so. that would call
t(`foo`)
//distinct from
t`foo
`
#2021-03-3022:28thhellerit is?#2021-03-3022:28thhellerdon't think so?#2021-03-3022:29thhellerI've never actually used them anywhere so I might be totally wrong 😛#2021-03-3022:30dpsuttonhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
myTag`That ${ person } is a ${ age }.`;
is equivalent to
myTag(["That ", " is a "], person, age)
#2021-03-3022:30thhelleroh right doh#2021-03-3022:32dpsuttonyeah its confusing at first but then just totally makes sense mechanically. it's just chopped up#2021-03-3022:33thhellerhmm wonder if that should be (js-template foo "bar") or (js-tagged-template foo "bar")#2021-03-3022:34thhelleras in a separate form or just handled by being smart and checking the first argument 😛#2021-03-3022:45thhellerhttps://github.com/thheller/shadow-cljs/commit/109ea8858b5180522895b1d32c17e47d8cfff90e#2021-03-3022:46thhellerdunno if this is actually useful but it has been bugging me that this wasn't supported for a while 😛#2021-03-3022:49thhellerprobably full of bugs still, pretty sure the escape logic is too naive but who knows 😉#2021-03-3022:51dpsuttonyeah that looks closer. feels weird to emit without munging. i think you could define your own functions in cljs so it should probably be munged#2021-03-3022:52thhellerwhat do you mean? it is munging?#2021-03-3022:52thheller(js-template (function-that-is-called-with-template-arg) "foo") is
function_that_is_called_with_template_arg()`foo
`
#2021-03-3022:53thhellerwhich is valid as far as I know?#2021-03-3022:53thhellertried it in the console and seemed to work 😉#2021-03-3022:54thhellerit isn't taking the literal symbol and just dumps it there. it is actually analyzing that symbol#2021-03-3022:54thhellerso (js-template js/ttag.t "foo") would be
ttag.t`foo
`
#2021-03-3022:55thhellerI mean for your stuff you likely still need a macro either way if you just want to emit that as a side effect so the parser can find it?#2021-03-3022:56thheller(js-template alias/foo "foo") would be
whatever.alias.was.foo`foo
`
#2021-03-3023:02dpsuttonactually that does all it needs to. if it emits the correct thing its golden
#2021-03-3023:02dpsuttonit needs to parse the compiled output to compile a list of strings needing translations#2021-03-3023:04thhelleryeah but depends on what it is looking for I guess. dunno if it understands the aliasing shadow-cljs does for modules and stuff#2021-03-3023:05dpsuttonyeah i was looking at that. i think that would be another problem to solve but it felt more approachable. was wondering what your shim was and how wrapped over the underlying lib it was#2021-03-3023:06thhelleryou appear to be using :npm-module so if you have (:require ["ttag" :refer (t)]) and (js-template t "foo") what would give you
shadow.js.shim.module$ttag = require("ttag");
shadow.js.shim.module$ttag.t`foo
`
#2021-03-3023:06thhellerdunno how smart your parser is at detecing that 😉#2021-03-3023:08thhellerthe shim is just a placeholder variable basically for the require result#2021-03-3023:08thhellerit won't be that after advanced#2021-03-3023:15thhellerhmm what language level is this even?#2021-03-3023:16dpsuttonyeah i don't think it picked that up. i had to (js* "ttag/t~{}) to get it to work#2021-03-3023:16dpsuttonyeah i was hoping i could throw an export on it and have it stable#2021-03-3023:16dpsuttonand under advanced compilation it was still super readable so dunno#2021-03-3023:16dpsuttonwhat language level? es6, etc?#2021-03-3023:17thhelleryeah which spec level#2021-03-3023:18thhellerah yeah :es6 seems to be ok#2021-03-3023:18thhellerclosure was rewriting it with :es5#2021-03-3023:21dpsuttonoh annoying#2021-03-3023:23thhellerthinking about it a macro may actually be enough with a bit of js*, doesn't need to do all I'm doing now#2021-03-3023:24thhellerI'll see about it tomorrow when I can actually think, way too late now 🙂#2021-03-3023:30dpsuttonwell thanks for being the sounding board#2021-03-3116:36thhellerI pushed 2.12.0 (minor bump because of new cljs version) which also has the (js-template ...) if you want to try that#2021-04-0215:45dpsuttoni'm on 2.12.0: shadow-cljs - server version: 2.12.0 running at , and (js-template ttag/t "hello") is giving me an error about an undeclared var js-template#2021-04-0215:47thhelleroh you need to require it. I made it available as a library#2021-04-0215:47dpsutton(special-symbol? js-template) is returning false which surprises me#2021-04-0215:47dpsuttonahh#2021-04-0215:47thheller(:require [shadow.cljs.modern :refer (js-template)])#2021-04-0215:52dpsuttongetting an error with (js-template ttag/t "hello") and similarly with just a base test: (js-template "hello"): cannot read property call of undefined#2021-04-0215:53dpsuttonnevermind, must have been some funky repl state. re-evaled the ns with the require and it is now working#2021-04-0216:52thhellerI expect there to be bugs with this. I didn't test is very much and the implementation is definitely kinda rushed in a late night sleepy state 🙂#2021-04-0216:53thhelleronce this has been tested a little more we can maybe make a patch for CLJS out of it#2021-04-0216:56dpsuttonone thing to think about, is that tagged template literals, and template literals in general, make the most sense when they can have the interpolated values. i tried a simple (js-template "hello ${\"there\"}") and it emitted t'hello \$"there"' which was almost workable. not sure how to handle this. off the cuff might be (js-template "hello " x) might emit t'hello ${x}'but i doubt that might be worth the trouble and sounds like a super uphill battle going into cljs#2021-04-0216:58thhellerwell the whole point was making this act like str but emit a template string#2021-04-0216:59thheller(js-template "hello " x) will emit exactly
`hello ${x}` 
#2021-04-0216:59dpsuttonah sorry i thought i tried that and it didn't do what i wanted#2021-04-0217:00thheller(js-template "hello ${\"there\"}") is therefore pointless and will be escaped 😛#2021-04-0217:00dpsuttontotally#2021-04-0217:01thheller(js-template "hello " (any-cljs "expr")) is totally valid, if it was using ${} then you'd run into all sorts of annoying quoting issues#2021-04-0217:01dpsuttona difficult part for this particular implementation is that the translation library expects "your {x} works perfectly" and will expect the translated phrase to be "your {placeholder} works perfectly" and i can't recreate that in this guise#2021-04-0217:02dpsutton(js-template "your " x " works pefectly") would emit the "works pefectly" as part of the substitution rather than the base phrase#2021-04-0217:02dpsuttonagain, certainly a quirk in this implementation but kinda the point of the templates i think#2021-04-0217:02thhellerdid you check what the code actually emits?#2021-04-0217:03dpsuttonno i haven't. let me go check#2021-04-0217:03thhellerit may just be the CLJS compiler emitting the usual extra () which I can't do anything about unfortunately#2021-04-0217:04thhellerI mean that should emit
`your ${x} works perfectly` 
#2021-04-0217:04thhellerbut might be
`your ${(x)} works perfectly` 
#2021-04-0217:05thhelleror whatever x resolves to in this case. could also by some.other.ns.x#2021-04-0217:05dpsutton
(let [x "soundcard"]
  (js-template "your " x " works pefectly"))
#2021-04-0217:05dpsutton
var x_46339 = "soundcard";
(metabase.shared.util.i18n.js_template.cljs$core$IFn$_invoke$arity$3 ? metabase.shared.util.i18n.js_template.cljs$core$IFn$_invoke$arity$3("your ",x_46339," works pefectly") : metabase.shared.util.i18n.js_template.call(null,"your ",x_46339," works pefectly"));
#2021-04-0217:06thhellerthat is definitely not the correct output. this is not using the special form at all#2021-04-0217:06dpsuttonah, i removed the import. apologies#2021-04-0217:06dpsuttonand got confused because my repl still had it 🙂#2021-04-0217:07dpsutton
var x_48110 = "soundcard";
`your ${x_48110} works pefectly`;
#2021-04-0217:07dpsuttonwell i'll be damned#2021-04-0217:07dpsuttonwell excellent job in your late night haze#2021-04-0217:08thhellerthats more like it 😉#2021-04-0217:09dpsuttonand the plan would be to move that into cljs proper as a special form with those methods for analyzing and emitting?#2021-04-0217:09dpsuttonre-added my sponsorship now that i'm finally using shadow at a work project#2021-04-0217:13thhellerwell it definitely needs more discussion and testing before this can be submitted to CLJS proper#2021-04-0217:14thhellerstill not sure if the special form is actually needed for this. a macro might do the trick just fine with js*#2021-04-0217:14thhellerthis just felt cleaner#2021-03-3023:31dpsuttonand its amazing how responsive you are. truly#2021-03-3108:38superstructorlein new re-frame my-app template had a major new release today. It now creates a pure shadow-cljs build using shadow-cljs.edn and package.json as the source of configuration. Appreciate any testing, feedback, issues or PRs from the shadow-cljs community to improve it further. https://github.com/day8/re-frame-template#2021-03-3108:39thhellernice! one thing you might want to consider is using npm-run-all and cross-env like this setup does https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/package.json#L2-L10#2021-03-3108:40thhellercross-env to make things work in windows, since it doesn't support the FOO=thing env vars otherwise#2021-03-3108:40thhellernpm-run-all contains the run-p and run-s utils to run things in parallel or sequentially#2021-03-3108:40thheller(might be useful if you ever intend to add something like that)#2021-03-3108:42thhellerhttps://github.com/mysticatea/npm-run-all/blob/HEAD/docs/run-p.md#2021-03-3108:45thhelleralso please consider updating the use of the :devtools :http-root and :http-port. they have been deprecated for years and :dev-http should be used instead https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2021-03-3108:46superstructorthanks for the link re npm-run-all / cross-env, that will be very helpful.#2021-03-3108:46superstructorI'll fix the :devtools usage now.#2021-03-3109:05thheller:dev-http {8280 {:root "resources/public" :handler foo.bar}} would be the handler variant#2021-03-3109:11superstructorThanks, but have removed the handler support as we decided to focus purely on the best possible client side experience (being a 're-frame' template) and leave the backend impl to other projects.#2021-03-3109:12superstructorI have released v2.0.1 that fixes the deprecated use of devtools, uses dev-http.#2021-03-3109:13thhellerthanks#2021-03-3109:14thhellerdoes the top-level :build-hooks actually work? I can't remember 😛#2021-03-3109:15thheller:build-defaults {:build-hooks ...} should but otherwise no right?#2021-03-3109:15superstructoroh ops; maybe I messed up the template#2021-03-3109:23superstructorThanks for spotting that @thheller. v2.0.2 is releasing on ci now, will be live in 10 minutes. Tested w/ build-defaults and the version is set correctly.#2021-03-3113:34Gleb PosobinHow do I keep my package.json updated? I updated my cljs dependencies, how do I prune and update the JS packages they were depending on?#2021-03-3115:26richiardiandreaMy favorite way is yarn upgrade-interactive --exact#2021-03-3113:45thhellermanually checking it I guess? shadow-cljs provides no tools to do so#2021-03-3114:10wombawombaHow can I get a 'nice' stand-alone terminal REPL going with shadow-cljs? Ideally something like https://github.com/bhauman/rebel-readline#2021-03-3114:16thhelleryou only get a basic REPL for the terminal. most people use REPL provided by their editor so terminal REPL hasn't had much work#2021-03-3114:17thhellernot aware of anyone working on one either#2021-03-3117:23wombawombaAlright. How would I go about making one?#2021-03-3117:24wombawombaI'm thinking it shouldn't be that much work to add at least basic readline support/autocompletion to the existing one#2021-03-3117:26thhelleryou could build one on top of nrepl, maybe using cider-nrepl. then you basically get all the features that has out of the box and you just write the readline code#2021-03-3117:28wombawombaalright#2021-03-3117:29wombawombais the basic shadow-cljs repl talking to an nrepl server, or is it hosting one?#2021-03-3117:30thhellerno the basic repl is using a plain streaming socket repl. thats why it has basically no extra features#2021-03-3117:32thhellerif you have a shadow-cljs server or shadow-cljs watch running you can find the nrepl port via the .shadow-cljs/nrepl.port file#2021-03-3117:33wombawombaalright#2021-03-3117:33thhellernrepl is a fairly simple protocol so should be easy to do#2021-03-3117:33wombawombaright yeah#2021-03-3117:33wombawombawould it be possible to instead hook into the existing shadow-cljs command? so I wouldn't have to keep track of two services#2021-03-3117:34wombawombai.e. could I extend it with my own command that runs my REPL and also manages a shadow-cljs server?#2021-03-3117:34thhellerthat would be something your tool would do#2021-03-3117:35thhellerI mean since that needs to control the input stream to hook up the readline stuff#2021-03-3117:35thhellerif you run the shadow-cljs command separately or from whatever process you launch is your choice#2021-03-3117:35wombawombaalright#2021-04-0106:10Stuart CampbellHello, I’m fiddling around trying to use mapbox-gl in a cljs project and having some trouble – not sure if this is really a shadow-cljs thing or not. But I noticed the following: • I have mapbox-gl ^2.2.0 as a dependency in package.json • I have a :main build that targets :browser with an entrypoint like (ns mapbox-test.main :require [mapbox-gl]) • compilation (`npx shadow-cljs build main`) fails like this:
Closure compilation failed with 2 errors
--- node_modules/mapbox-gl/dist/mapbox-gl.js:33
This code cannot be converted from ES6. class expression that cannot be extracted
--- node_modules/mapbox-gl/dist/mapbox-gl.js:37
This code cannot be converted from ES6. class expression that cannot be extracted
• if I instead do npx shadow-cljs browser-repl then (require 'mapbox-gl), I see no errors. I guess I’m confused about (among other things) what the difference is between these two ways of requiring something.
#2021-04-0108:31thheller@stuart611 set :compiler-options {:output-feature-set :es6} or higher (`:es7, :es8, :es2019, :es2020`) in your build config. browser-repl defaults to :es-next-in (the most modern stuff)#2021-04-0108:31thhellerthe default is :es5 and you are using code that cannot be converted lower#2021-04-0108:32thhellerbasically the option controls in how old a browser you need to support#2021-04-0108:32thheller:es8 is a good default nowadays unless you need to support IE11#2021-04-0116:00Stuart CampbellSuperb, thank you for the fix & explanation 🙂#2021-04-0213:13Vincent CantinHi, during the compilation on our project, the compiler hangs, seemingly on a deadlock situation. We suspect that it may be related to a namespace dependency cycle. Is it plausible or not?#2021-04-0214:06thhellerunlikely. dependency cycles are detected in the resolve stage before it gets to compilation#2021-04-0214:07thhellermost common problem is a macro expanding endlessly#2021-04-0214:09thhellerthe compiler should self-terminate if it makes no progress for 60seconds#2021-04-0214:10Vincent CantinThat's what happen, it terminates after some time and namespaces say which other ones they were waiting for.#2021-04-0214:11thhellerthe check what that namespace does#2021-04-0321:51Vincent Cantin@U05224H0W I found the problem which caused Shadow-CLJS to hang, and that might interest you:
(ns foo.core
  (:require [bar_baz :as baz])) ;; typo, "_" instead of "-"
#2021-04-0321:52Vincent CantinMaybe a "_" in a namespace should trigger a warning.#2021-04-0408:02thhellerah. please open an issue about that so I don't forget.#2021-04-0214:51lispers-anonymousI keep getting these messages printed into my repl, and can't find much about it searching online
10:47:01.189 [XNIO-1 I/O-1] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1
The are printed every couple of seconds. Seemingly when ping/pong messages are exchanged over the websocket between shadow and my site in a browser session. Is there any way to hide these? They started showing up recently and I'm unsure what I did to trigger these to appear.
#2021-04-0214:51thhellerlooks like you are running shadow-cljs in embedded mode? ie. embedded in your CLJ process started from the REPL or so?#2021-04-0214:53lispers-anonymousMaybe so? I started my repl with cider-jack-in-cljs. Maybe I will have different results if I start shadow in a terminal and connect to that through cider#2021-04-0214:55thhellerif you start it in embedded mode shadow-cljs inherits your jvm logging setup. so you'd configure that logging via your log4j.properties logback.xml or whatever logging you are using#2021-04-0214:55thhellerif you start it separately those logs should not appear#2021-04-0214:58lispers-anonymousI started my repl with shadow-cljs watch app and connected manually with cider. I still see the messages, both in my terminal and my connected cider repl. We do have a logback.xml in this project. I will try to exclude these logs somehow. Do you happen to know what the logger name would be for these messages?#2021-04-0214:59lispers-anonymousTrying this <logger name="io.undertow.websockets.core.request" level="WARN" /> first#2021-04-0215:02thhellerI can never remember how to configure this stuff either but logback.xml is the place to do it 🙂#2021-04-0215:03thhelleryou can use name="io.undertow" since you likely don't care about any of the messages it outputs. not just that ns.#2021-04-0215:04lispers-anonymousI will play around with it. I am not the logback guy at my work. Someone will know how to do it though.#2021-04-0215:04lispers-anonymousThank you for your help. I really appreciate how responsive you are in this channel.#2021-04-0215:06thhellerhappy to help#2021-04-0215:26lispers-anonymousI have figured it out. My logback.xml lives in config/logback.xml . I believe one of my dependencies also had some logback stuff defined in it, and that is what my repl was picking up. I added "config" to my :source-paths in shadow-cljs.edn and added this line to my logback.xml file
<logger name="io.undertow" level="OFF" />
Without modifying my source paths my logback wasn't picked up. Now that it is, my repl is cleared up.
#2021-04-0215:26lispers-anonymousI have figured it out. My logback.xml lives in config/logback.xml . I believe one of my dependencies also had some logback stuff defined in it, and that is what my repl was picking up. I added "config" to my :source-paths in shadow-cljs.edn and added this line to my logback.xml file
<logger name="io.undertow" level="OFF" />
Without modifying my source paths my logback wasn't picked up. Now that it is, my repl is cleared up.
#2021-04-0317:07MaxWow, just started playing around with the inspector and it’s great! Two small things it choked on: it can’t seem to inspect into reagent’s ratoms the same way it inspects normal atoms, and it doesn’t seem to be able to inspect items inside of LazySeqs. The latter can be easily worked around by just running (into [] $o) though, so not a huge deal. Awesome tool!#2021-04-0319:08thheller@max.r.rothman yeah the support for lazy seqs is incomplete. you can extend support for reagent atoms by extending the datafy protocol#2021-04-0319:10thhellersomething like this
(extend-protocol p/Datafiable
  reagent.ratom/RAtom
  (datafy [r]
    (with-meta [(deref r)] (meta r))))
#2021-04-0319:11thhellerwith p being (:require [clojure.core.protocols :as p])#2021-04-0319:11thhellercan do it from a REPL or a ns you load via :preloads#2021-04-0321:25SchpaaWhy is this not legal in shadow-cljs.edn?
:git-inject    {:version-pattern #"^v\/(.*)$"
                 :ignore-dirty?   false}
#2021-04-0321:27Schpaashadow says this is an Unsupported escape character: \/.#2021-04-0322:05Azzuritedoesn't seem like it has anything to do with shadow-cljs, you just can't (read: don't have to) escape a /? you probably meant to do \\ to escape a \ so you match \/ in the final regex (or you just want to remove the \ so you match a single /, if that's what you want)#2021-04-0322:11Azzuritealso seems like this is not a standard shadow-cljs feature but rather coming from https://github.com/day8/shadow-git-inject so it might be that you get better answers there#2021-04-0407:59thhellerbecause EDN does not support regexp#2021-04-0408:01thhellerdon't know why they have it as an example but default clj/cljs EDN readers do not support regular expressions#2021-04-0408:01thhellerI guess I could maybe change it to use the regular CLJ parsers but as of now it is treated as EDN#2021-04-0410:05SchpaaGot it, thanks!#2021-04-0410:09thhellerjust use a string, it'll be converted. just requires a bit more escaping the \\#2021-04-0422:22mikethompson@UBKAXK5QB That bug (and the documentation) in shadow-git-inject has been fixed. We have also moved re-frame-template to use this update. Thanks for report.#2021-04-0415:30Vincent Cantin@thheller It seems that the Git tags are missing from the recent releases in the Git repository.#2021-04-0416:39thheller@vincent.cantin do you use them for anything? jiyinyiyong used to handle those but he isn't active in CLJS anymore so he stopped doing them. I never used them for anything so I didn't take over doing them#2021-04-0501:40Vincent CantinI don't use them for anything special, other than visualizing in source tree which commit is which release. It's only useful for people looking at the source code.#2021-04-0416:40thhellerI guess I could make a script for this if they are of some use for you#2021-04-0419:35ribelosomething has changed regarding the use of js/require ?#2021-04-0419:35ribeloopened an old electron project and got this error#2021-04-0419:36ribelo
ReferenceError: require is not defined
#2021-04-0419:36ribelo
(defonce electron (js/require "electron"))
#2021-04-0419:40thhellerelectron has changed that yes#2021-04-0504:07Vincent CantinIs the usage of ^:const (e.g. in (def ^:const my-var 3000)) still justified when using shadow-cljs?#2021-04-0507:42thheller^:const is probably the most misunderstood feature in CLJ(S) so I would avoid it. but you can use it if you must.#2021-04-0515:06Stewart FoxallHi total newbie here. Just trying out shadow-cljs, but can’t seem to get past the intial step, am getting a binding error. [2021-04-05 15:44:22.985 - WARNING] :shadow.cljs.devtools.server/socket-repl-ex BindException Can’t assign requested address (Bind failed) https://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) https://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) https://java.net.ServerSocket.bind (ServerSocket.java:375) https://java.net.ServerSocket.<init> (ServerSocket.java:237) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system/fn--17877 (server.clj:233) shadow.cljs.devtools.server/start-system (server.clj:232) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) BindException: Can’t assign requested address (Bind failed) https://java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2) https://java.net.AbstractPlainSocketImpl.bind (AbstractPlainSocketImpl.java:387) https://java.net.ServerSocket.bind (ServerSocket.java:375) https://java.net.ServerSocket.<init> (ServerSocket.java:237) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:123) shadow.cljs.devtools.server.socket-repl/start (socket_repl.clj:115) shadow.cljs.devtools.server/start-system (server.clj:248) shadow.cljs.devtools.server/start-system (server.clj:202) shadow.cljs.devtools.server/start! (server.clj:483) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/start! (server.clj:388) shadow.cljs.devtools.server/start! (server.clj:385) shadow.cljs.devtools.server/from-cli (server.clj:615) shadow.cljs.devtools.server/from-cli (server.clj:591) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:23) shadow.cljs.devtools.cli-actual/lazy-invoke (cli_actual.clj:20) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:129) shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177) shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132) clojure.core/apply (core.clj:669) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219) shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.core/apply (core.clj:660) shadow.cljs.devtools.cli/-main (cli.clj:75) shadow.cljs.devtools.cli/-main (cli.clj:67) clojure.lang.Var.applyTo (Var.java:705) clojure.core/apply (core.clj:665) clojure.main/main-opt (main.clj:514) clojure.main/main-opt (main.clj:510) clojure.main/main (main.clj:664) clojure.main/main (main.clj:616) clojure.lang.Var.applyTo (Var.java:705) clojure.main.main (main.java:40)#2021-04-0515:07thhellerwhat binding error?#2021-04-0515:07Stewart FoxallSorry first time using slack and it sent the message before I had finished typing#2021-04-0515:08Stewart FoxallI was using another example, but then switched to using this: https://github.com/shadow-cljs/quickstart-browser I am running on macos 11 if that is relevant#2021-04-0515:09thhellerdid you block it in your firewall? It needs to open a server socket so you can talk to it via the REPL etc#2021-04-0515:11Stewart FoxallNot as far as I am aware, I have nothing running, checked and can’t see that 8630 port is being used#2021-04-0515:11thhellerdid you configure anything related to ports in shadow-cljs.edn? or is this with the default setup?#2021-04-0515:12thhelleronly thing I can think of is your firewall blocking it#2021-04-0515:13Stewart FoxallI did on another example was learning on, but not for quick start. Just followed the commands as is. The file contents is:
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :dev-http
 {8020 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"

   :modules
   {:main ; becomes public/js/main.js
    {:init-fn starter.browser/init}}}}}
#2021-04-0515:14thhellerthat looks fine#2021-04-0515:15Stewart FoxallMy firewall is off#2021-04-0515:15thhelleryou can try adding :socket-repl false so it skips trying to start that#2021-04-0515:15Stewart Foxallsure#2021-04-0515:15thhellerbut likely it'll then just fail on the next network port it tries to use#2021-04-0515:15Stewart Foxalland thank you for helping#2021-04-0515:17Stewart FoxallTo be clear, you mean like this:
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 []

 :socket-repl false

 :dev-http
 {8020 "public"}

 :builds
 {:app
  {:target :browser
   :output-dir "public/js"
   :asset-path "/js"
#2021-04-0515:17thhelleryes#2021-04-0515:18Stewart FoxallErrors out again#2021-04-0515:18thhellerit tries to bind to 0.0.0.0 by default which should be localhost. I do not know why it would fail. nobody else has reported this before.#2021-04-0515:19thhelleror rather 127.0.0.1 for the socket-repl. maybe you only have ipv6 configured? no ipv4 at all?#2021-04-0515:20thhelleror rather it tries to bind localhost. is that maybe not configured for some reason?#2021-04-0515:20Stewart FoxallJust taking a look now#2021-04-0515:23thhellertry ping localhost in the terminal#2021-04-0515:25Stewart FoxallLooks like something to do with my ISP#2021-04-0515:26thhellerthat is odd. localhost shouldn't leave you machine at all.#2021-04-0515:26thhellerI don't actually know where this is configured in macos anymore. maybe still /etc/hosts?#2021-04-0515:27Stewart Foxall#2021-04-0515:27Stewart FoxallThis may be the culprit#2021-04-0515:30thhellermy macbook has
$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
#2021-04-0515:30Stewart FoxallYes just noticed 127.0.1 was not there, added in and refreshed working now. Thank you!!!!#2021-04-0515:30thhellerstrange 🙂#2021-04-0515:31Stewart FoxallVery, must have been cleared some point in the past, thanks again…#2021-04-0516:23MaxIs there a way to do dev-only dependencies with shadow-cljs, or do you have to integrate with deps or lein?#2021-04-0516:39Azzuritewouldn't dev-only dependencies be npm install <package> --save-dev?#2021-04-0516:51MaxNot if it’s a maven/deps package#2021-04-0517:08thheller@max.r.rothman the distinction is not necessary. the builds decide what is included and as such having extra but unused dependencies on the classpath do not matter#2021-04-0517:09thhellerjust include everything all the time. shadow-cljs.edn itself does not have the concept of dev-dependencies.#2021-04-0517:10MaxDoes that happen at all optimization levels? And how then do I configure a build to not include that code (or to only include that code in one build)?#2021-04-0517:11thhelleryou ns :require forms control what the build will actually use for all optimization levels#2021-04-0517:12thhellerthe build reports will tell you in detail what your build included https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2021-04-0517:12MaxNice! 🪄#2021-04-0517:13MaxSounds like there’s not a way to make certain namespaces or dependencies unavailable in certain builds though? I’d have to figure out some way of scraping the build report if I wanted to check that constraint automatically?#2021-04-0517:16thhelleryou could also verify with a build hook. in general you want to include dev-only code via :preloads. they are not included in the release builds#2021-04-0517:16thhellermost cljs libs already provide instructions to do so, if that applies#2021-04-0518:41cbchello, i'm new and i'm using shadow-cljs with cursive, and i can't get command completion to work for a js (actually typescript) library that i installed with npm...should there be a way to make this work?#2021-04-0518:45cbci created the project using the pom.xml as detailed here: https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2021-04-0520:23thhellerno, this is currently not support by Cursive#2021-04-0520:38wilkerlucioyou must use a deps.edn or a project.clj to setup things for Clojure in Cursive#2021-04-0520:52Azzurite@U01T8T8BL9F with Cursive it's best to use deps.edn or leiningen project.clj for defining dependencies instead of shadow-cljs.edn#2021-04-0520:53Azzuritesee https://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration#2021-04-0522:10cbcok, thanks everyone, i will give it a try...for now i'm just living with all the unresolved symbols#2021-04-0607:12thhellerpom.xml works fine, you do NOT need to use deps.edn or project.clj for Cursive. Regardless of what you use though Cursive does not support JS dependencies as of now#2021-04-0716:22rkiouakin my experience, there is definitely no need to manage dependencies in deps or project.clj, just want to echo thhellers comment (I find that managing npm deps in shadow-cljs.edn is FAR less maintenance work than dealing with deps.edn or project.clj finagling I end up doing when working with npm deps in those)#2021-04-0521:46JasonDoes anyone have any experience building a project with Bazel? Apparently the best angle is to use the Closure rules but does that mean I should npm install shadow-cljs or clojurescript itself?#2021-04-0606:48thhellerI have never used bazel but I know someone did. Just forgot who or how#2021-04-0608:59pezI can’t specify nrepl port via user config, right?#2021-04-0609:02thhelleryou should never ever specify a fixed port for nrepl#2021-04-0609:02thhellerlet it use a random port and read it from .shadow-cljs/nrepl.port in the project#2021-04-0609:02thhellerif by user config you mean ~/.shadow-cljs/config.edn then no since that would start to conflict as soon as you run more than one shadow-cljs instance at the same time#2021-04-0609:07pezThe issue arose because the only Cursive wielding user in our project wanted to add a fixed port. But you are a Cursive user too, aren’t you, @thheller?#2021-04-0609:08thhellerI am and Cursive is perfectly capable of using that file. Absolutely no use for a fixed port in Cursive#2021-04-0609:08pezAwesome.#2021-04-0609:09thheller#2021-04-0613:02Azzuritedidn't even need the "specify custom file" there, but yeah 😄#2021-04-0615:00thhellerIn my project I do because I also use lein and don't want it to get confused. Otherwise the other option also works yes.#2021-04-0609:10pezThanks!#2021-04-0611:09wombawomba~I'm running ~ Actually, scratch that. I restarted everything and now it works 🙂#2021-04-0614:42bartukahello, I am using bide (https://github.com/funcool/bide) to routing and this library makes a call to goog.isDefAndNotNull function. However, I got an error like this:
Execution error (TypeError) at (<cljs repl>:1).
goog.isDefAndNotNull is not a function
there is any additional config I need to setup to make this work on shadow-cljs side?
#2021-04-0614:59thheller@iagwanderson that function was removed in the newer closure-library. bide will need to change that.#2021-04-0615:34bartukathanks @thheller!#2021-04-0616:11bartukafor those interested, this is the commit from closure-library https://github.com/google/closure-library/commit/9325ce1bbebcfe8c7aa54f8342959c73a1762a77#2021-04-0616:16thhelleryeah they removed basically all the * functions over the past few years. we were stuck with a quite old closure-library version for a while due to those incompatibilities even in cljs.core. the new CLJS release (announcement still upcoming) fixed those but a lot of libraries still need adjustments for the newer version as well#2021-04-0615:04thhelleror downgrade shadow-cljs to 2.11.26. 2.12.0 was the released with the new closure-library version#2021-04-0615:07iGELHello. I'm trying to migrate some builds from lein-figwheel to shadow-cljs and fail at it :face_palm: Shadow-cljs doesn't find my namespace: The required namespace "data-request.core" is not available. I've slimed down my src/cljs/data_request/core.cljs to this:
(ns data-request.core)

(defn ^:export initialize [x]
  (prn x))
And my shadow-cljs.edn looks like this:
{:source-paths ["src/cljs/data_request"]
 :dependencies []
 :builds {:data-request {:target :browser
                         :modules {:main {:entries [data-request.core]}}
                         :output-dir "../output/dev/"
                         :asset-path "/cljs/output/dev/data-request_target"}}}
But still:
# yarn shadow-cljs watch data-request

yarn run v1.22.10
$ /webapp/cljs/admin/node_modules/.bin/shadow-cljs watch data-request
shadow-cljs - config: /webapp/cljs/admin/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - server version: 2.12.1 running at 
shadow-cljs - nREPL server started on port 7890
shadow-cljs - watching build :data-request
[:data-request] Configuring build.
[:data-request] Compiling ...
[:data-request] Build failure:
The required namespace "data-request.core" is not available.
#2021-04-0615:08dpsuttonthe ns data-request.core would be expected to be at <classpath-root>/data_request/core.cljs. Since your classpath root is src/cljs/data_request, it will be looking for src/cljs/data_request/data_request/core.cljs and not finding it#2021-04-0615:10iGELDoh 😉 I was pretty sure I tried that. Thanks 🙂#2021-04-0615:12thhellerThe :asset-path also looks incorrect. that should be the path under which you access the files over HTTP, that likely isn't :port/cljs/output/dev/data-request_target/main.js?#2021-04-0615:16iGELWith figwheel, we were serving this through Rails and a middleware there was hooking things up. Is that still a good approach for shadow-cljs?#2021-04-0615:21thhellerif it makes sense for you yes. they are still just plain static javascript files, no difference on that front#2021-04-0615:22thhellerthe code just needs to be able to connect back to the http://localhost:3450 server. dunno why you reconfigured that from the default 9630. the is only the webserver used for the UI and websockets. It does nothing regarding your other code.#2021-04-0615:23thhelleralso you want to avoid using a fixed :nrepl {:port ...} if you can. most editors nowadays support reading that port rom the generated .shadow-cljs/nrepl.port file instead#2021-04-0615:43emierHello! Trying to config the test runner, but running into some problems regarding namespace when trying to compile. Here’s the configs: project.clj
:test
{:dependencies [[binaryage/devtools "1.0.2"]]
 :source-paths ["env/test" "test/src"]}
shadow-clj.edn
:lein {:profile "+dev,+test"}
…
:builds
{:dev {...}
:test 
  {:target     :node-test
   :output-to    "test/target/testable.js"
   :ns-regexp    "myapp\\..*"
   :autorun    true}}
And here’s the problem:
$ npx shadow-cljs watch test
…
[:test] Compiling ...
[:test] Build failure:
Resource does not have expected namespace
{:tag :shadow.build.resolve/unexpected-ns, :resource "src/myapp/runner.cljs", :expected-ns src.myapp.runner, :actual-ns myapp.runner}
Any ideas why it doesn’t accept the namespaces? It hasn’t been a problem with our previous test runner. A potentially relevant side note is that Cursive also complains in these files that the namespace is missing a src. (for example in (ns myapp.test.db ...) ) but it seems to me this shouldn’t be needed.
#2021-04-0615:56thheller@emil.eriksson41 what are the :source-paths you have configured in project.clj? you do not need a "runner" for the tests, that is generated for you by the :node-test target.#2021-04-0707:20emierSource paths are ["env/test" "test/src"] - some environment configuration variables, and then all the test files. File hierarchy is e.g. test/src/myapp/test/db.cljs You’re right, the runner file remained from old solution. After removing it, same problem remains but for other files (e.g :expected-ns src.myapp.test.api.transform, :actual-ns myapp.test.api.transform)#2021-04-0707:50thhellerit looks like you have "test" on the classpath, which is the default when using lein via :test-paths ["test"]. You need to override that so the classpath doesn't contain duplicated entries.#2021-04-0707:51thhellerbut which shadow-cljs version is this with? either you are using a very old shadow-cljs version or something else is going on?#2021-04-0708:46emierUsing 2.11.18 right now. Looks like we didn’t have a :test-paths set in project.clj at all, so I tried setting it to ["test/src"] which seems to have solved the namespace issue! Now I get another error instead but it seems related to our own code.#2021-04-0616:23Rob KnightIt seems that the most recent Closure Compiler has removed the stripTypePrefixes compiler option 😞#2021-04-0616:24thhellerthey did indeed. it was always the absolute nuclear option anyways though 🙂#2021-04-0616:24Rob KnightYeah, now I need to figure out exactly what is adding 94kb of cljs.analyzer to my release build#2021-04-0616:26thhellerhttps://github.com/thheller/shadow-cljs/issues/865 😉#2021-04-0616:26thhellerthere used to be a function for that but it broke a while back. really need to bring that back#2021-04-0616:27Rob KnightAh, but that would take all of the fun out of it 😄#2021-04-0616:39Rob KnightIs that kind of information available anywhere, even if it's hard to get at? I don't mind hacking around#2021-04-0616:43thhellernot in an easily accessible way no. really low level would be in the build-state from a build hook#2021-04-0616:45thhellerfrom the CLJ REPL (eg. shadow-cljs clj-repl) you can call (def build-state (shadow/compile! :the-build))#2021-04-0616:45thhelleryou use (tap> build-state) and look at entire state in the shadow-cljs UI#2021-04-0616:45thhellerdo not try to print it from the REPL, it is way too large and will take forever 😉#2021-04-0616:46thhellerthere is a :compiler-env key and that has :cljs.analyzer/namespaces#2021-04-0616:46thhellerif you really want to dig in that is the place to do it 😛#2021-04-0617:07Rob KnightIs there a way of getting this information for a release build? My problem is that there is various spec-related stuff that I want in my dev builds, but not in my release builds.#2021-04-0619:22thhellerthere is a release! but just noticed that has a bad return value#2021-04-0619:22thhellerbut (shadow/release* (shadow/get-build-config :the-build) {}) should be ok#2021-04-0619:48Rob KnightThanks#2021-04-0616:47Rob KnightThanks 🙂#2021-04-0616:52awb99I have https://www.npmjs.com/package/@ricokahler/oauth2-popup-flow in deps.cljs in a library. oauth2-popup-flow has a few dev dependencies like typescript that are needed to compile it. It seems dev dependencies are somehow lost. So I had to add all transient dev dependencies of oauth2-popup-flow to my deps.cljs. Is this intended behavior?#2021-04-0616:54thhellernpm packages generally contain the already compiled code and dev dependencies are used for THEIR development#2021-04-0616:55thhellerthey will generally not be used when you use the library so you adding those dependencies to deps.cljs seems like something you should absolutely not do. shadow-cljs will also never compile typescript for you so they'll like remain unused.#2021-04-0616:55thhellerso yes, that is intended#2021-04-0617:13awb99Thanks @thheller#2021-04-0617:14awb99I have seen a lot of npm libraries that build themselves on npm-install. I dont quite understand why it works in the library, but not via deps.cljs. I will have to investigate more.#2021-04-0619:17thhellerI have not seen a single npm library do that? well maybe those with native dependencies but certainly not typescript#2021-04-0619:17thhellerthe library you asked about also seems to contain the compiled JS code as expected? https://unpkg.com/@ricokahler/oauth2-popup-flow@2.0.0-alpha.1/index.js#2021-04-0619:17thhellerhttps://unpkg.com/browse/@ricokahler/oauth2-popup-flow@2.0.0-alpha.1/#2021-04-0619:18thhellerit also doesn't contain any of the actual .ts code so it couldn't even compile itself?#2021-04-0619:18thhellernever ever look at the git repo when looking at npm libraries. those never reflect how the library is actually distributed.#2021-04-0620:53awb99thanks a lot!#2021-04-0617:48Neil AshtonHey all! I’m having some issues with shadow-cljs’s build of a web worker. Within that web worker, I’m getting ReferenceError: window is not defined errors; it looks like it’s happening when this line runs, https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/js.js#L82, as a result of my “shared” module calling SHADOW_ENV.evalLoad("cljsjs.jquery.js", …) because of another library’s jQuery dependency (namely castra.core’s). Has anyone else solved this problem in a project?#2021-04-0617:49Neil AshtonAlso, FWIW, I notice that when I explicitly define window at the top of the web worker’s compiled JS by adding var window = goog.global;, that problem goes away – but then I start to get a document is not defined error that seems to ultimately be caused by shadow.dom.js.#2021-04-0619:19thhellerwhen building a web-worker it is your code (or depdencies of that) that must not load references using window#2021-04-0619:19thhelleryou also must configure the :module you are using as a web-worker via :web-worker true?#2021-04-0619:20thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2021-04-0619:51thhellerFWIW the goal should be to get the jquery out of the code loaded by the worker. you might do so by introducing an extra module somewhere in your graph.#2021-04-0620:14Neil AshtonYes, looks like that did it. Instead of having all modules depend directly on :shared, I inserted another module between :shared and those modules with jQuery dependencies. No more window-related errors. Thank you!#2021-04-0705:16Stuart CampbellHello, I just tried adding an NPM package called https://gildas-lormeau.github.io/zip.js/ to my project, and compilation failed with this error about a missing Babel plugin:
SyntaxError: […]/node_modules/@zip.js/zip.js/lib/core/codecs/codec-pool-worker.js: Support for the experimental syntax 'importMeta' isn't currently enabled (82:72):

  80 | 	let messageTask;
  81 | 	if (!workerData.interface) {
> 82 | 		workerData.worker = new Worker(new URL(workerData.scripts[0], import.meta.url));
     | 		                                                                     ^
  83 | 		workerData.worker.addEventListener(MESSAGE_EVENT_TYPE, onMessage, false);
  84 | 		workerData.interface = {
  85 | 			append(data) {

Add @babel/plugin-syntax-import-meta () to the 'plugins' section of your Babel config to enable parsing.
I found https://github.com/thheller/shadow-cljs/issues/190 but I wasn’t sure how to proceed. One comment in there suggested that .babelrc could somehow be used, but I’m not sure if that’s applicable here.
#2021-04-0707:43thhellerthis is not currently supported but the library seems to contain a prepackaed version without the worker via (:require ["@zip.js/zip.js/dist/zip-no-worker.min.js" :as zip]) maybe that works for you#2021-04-0715:59Stuart CampbellOK cool, that might work – I’ll give it a shot. Thanks!#2021-04-0705:27David PhamAre there any consequences from the new npm require syntax for Shadow-cljs? Should we prefer the official statements now?#2021-04-0707:09Karol WójcikWhat are the official statements?#2021-04-0707:39thhellerthe $ syntax has been in shadow-cljs for a long time too. it is a useful addition so use it when it make sense for you.#2021-04-0712:13thheller@UJ1339K2B https://clojurescript.org/news/news#_library_property_namespaces#2021-04-0713:08Karol WójcikAhh. That's that new one! 😄 Thanks @U05224H0W 🙂#2021-04-0712:40pmooserI'm trying to set up a new project using shadow-cljs version "2.12.1". • compile works fine • watch throws piggieback-related exceptions • Both work completely fine if I revert to version "2.11.23" (happens to be the version I use on another project).#2021-04-0712:41pmooserI can provide the specific exceptions if it would help.#2021-04-0712:50thheller@pmooser most likely you are using project.clj or deps.edn and have not bumped the CLJS version after bumping shadow-cljs#2021-04-0712:50thheller2.12.0 requires CLJS 1.10.844, which is why it did the 2.11 -> 2.12 bump#2021-04-0712:52pmooserSorry about that. I thought I used that version, but you must be correct.#2021-04-0712:52pmooserThank you.#2021-04-0712:53pmooserYes, that fixes it.#2021-04-0715:56iGELHey. I'm still on my lein-figwheel -> shadow-cljs adventure 😉 Right now I'm trying to replace the cljsjs/clipboard code with the npm package. I've added the same version (1.6.1) with yarn, and required ["clipboard" :as clipboard]instead of cljsjs.clipboard. But how do I update this line?
(new js/Clipboard (rdom/dom-node button))
#2021-04-0716:02thheller@igel your are getting rid of the js/GlobalThingy references and just use it like any regular CLJS namespace#2021-04-0716:02thhelleror in this case it is special since you are using it as a regular var#2021-04-0716:02thhellerso just (new clipboard (rdom/dom-node button)). just using the :as clipboard directly#2021-04-0716:05iGELThanks, the last suggestion was what I needed. 👍#2021-04-0718:41pmooserAny idea what the error IllegalStateException: Externs must contain builtin for env BROWSER: whatwg_console.js is caused by? I'm trying to migrate everything to the newest cljs and shadow-cljs.#2021-04-0718:44thhellersome classpath issue probably. maybe you excluded a dependency too much?
#2021-04-0718:44thhellerthey should be part of the closure-compiler#2021-04-0718:45pmooserHmmm. I'll keep digging, thanks.#2021-04-0718:47thhelleror maybe a good old guava conflict 😛#2021-04-0718:48pmooserYeah, I'm not sure. It doesn't happen with my old compiled artifact, but I happen to be trying pull in a local project (which I am also updating) via :local/root. So it's interesting that if I just use the old thing it's fine.#2021-04-0718:48pmooserI've updated that project's deps (of course) ... but the code is all identical.#2021-04-0718:49thhellercould be an issue in in shadow-cljs, cljs, closure-compiler. hard to say without more info.#2021-04-0718:50pmooserYeah. I'm going to stop for the day soon. I'll see if I can gather some more useful information in the morning.#2021-04-0718:52thhelleroh, this should be in the closure-compiler-externs artifact I think. maybe you just excluded that by accident#2021-04-0718:53thhelleror maybe you have a externs.zip on the classpath? 😛#2021-04-0718:54thhellershadow-cljs clj-repl ( "externs.zip") should give a clue#2021-04-0718:56pmooserThat yields:
"jar:file:/Users/taronish/.m2/repository/com/google/javascript/closure-compiler-externs/v20180805/closure-compiler-externs-v20180805.jar!/externs.zip"
#2021-04-0718:57pmooserI imagine those are old ...#2021-04-0718:57thhellerthat looks too old yes, I get
#object[java.net.URL 0x1a418fc7 "jar:file:/C:/Users/thheller/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20210302/closure-compiler-unshaded-v20210302.jar!/externs.zip"]
#2021-04-0718:57pmooserI'm wondering why pulling in the local project that way makes it use ancient externs, assuming that is what is happening.#2021-04-0718:58thhellerhmm so I guess that might be the reason. they seem to have combined it into the closure-compiler-unshaded and the separate closure-compiler-externs don't exist anymore?#2021-04-0718:59pmooserI'm not personally sure where this comes from ... is there any way to "tell it" to use a newer one?#2021-04-0719:00thhellerclj -Stree should tell you what is adding it#2021-04-0719:01pmooserHmm I wonder if I can just exclude that from wherever it is coming from?#2021-04-0719:02thhelleryou can, just :exclusions#2021-04-0719:05pmooserThat did it. Thank you very much.#2021-04-0719:05thhellergood to know that might be an issue. did the lib have a direct dependency on the externs?#2021-04-0719:06pmooserNo - not that I can see anyway.#2021-04-0719:07pmooserIt is coming in because that project is pulling in: org.clojure/clojurescript 1.10.597#2021-04-0719:08thhellerthats like ancient history, 2.12 should definitely be used with 1.10.844#2021-04-0719:08pmooserYes, it makes sense. I will talk to the library author and get him to update.#2021-04-0719:09pmooserI'm wondering if this has been responsible for some other weirdness I've seen related to this library.#2021-04-0719:09pmooserThanks for helping me debug it - I would never have traced it back to externs like that.#2021-04-0719:15yiorgoswhat is the preferred way to do repl driven dev with shadow-cljs alongside tools.deps? I’ve got the backend using tools.deps and I would like to implement the front end with re-frame, but if I connect with vim/fireplace to the nrepl that shadow starts I can’t eval the backend related code because it cant find the libraries in the class path. Should I use tools.deps for both shadow-frontend/backend tasks?#2021-04-0719:15yiorgosthanks!#2021-04-0719:16thhellercan fireplace open a second connection to your backend?#2021-04-0719:16yiorgosI’m not quite sure about that tbh#2021-04-0719:17thhellerme neither but that would be the optimal solution#2021-04-0719:17thhellerotherwise you could run shadow-cljs as part of your backend process, using the embedded mode https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2021-04-0719:17yiorgosis cider capable of doing that?#2021-04-0719:17thhellercider can do multiple connections I think yeah#2021-04-0719:18yiorgos👍#2021-04-0720:49dottedmagIs it expected that throwing an exception in Node.js REPL causes the runtime to exit? E.g.:
% shadow-cljs node-repl
shadow-cljs - config: /Users/dottedmag/w/hz/shadow-cljs.edn
shadow-cljs - server version: 2.12.1 running at 
shadow-cljs - nREPL server started on port 52529
cljs.user=> shadow-cljs - #4 ready!


(throw "x")


^C
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
cljs.user=> Failed to read: clojure.lang.ExceptionInfo: Input/output error {:type :reader-exception, :line 2, :column 1, :file "dummy.cljs"}
#2021-04-0720:50dottedmagAlso the message about disappeared runtime does not appear until ^C#2021-04-0807:41thheller@dottedmag strange indeed. (throw (ex-info "foo" {})) works as expected. must have something to do with throwing a string. I'll investigate#2021-04-0808:48thhellerfixed in 2.12.2#2021-04-0808:51dottedmag@thheller Not on NPM yet?#2021-04-0809:07thhelleroops, fixed#2021-04-0809:15dottedmagThanks, works.#2021-04-0819:22wilkerlucioone thing that I noticed on shadow cljs build-report: when I use a dependency from git (using deps.edn), it ends up grouped as if it was code from the project itself (instead of separate dependency)#2021-04-0819:23wilkerlucioshould I open an issue for it?#2021-04-0819:30thhelleryes please#2021-04-0819:30thhellerits because it treats everything that is not in a .jar as a project file#2021-04-0819:30thhellerwhich of course is sort of incorrect 😛#2021-04-0819:53wilkerluciohttps://github.com/thheller/shadow-cljs/issues/867#2021-04-0905:04dmrdIs there a way to filter down tests somehow / only run for a particular file? This issue suggests no: https://github.com/thheller/shadow-cljs/issues/322 Currently simply running them all using a test target:
:test
           {:target    :node-test
            :output-to "out/node-tests.js"
            :ns-regexp "-test$"
            :autorun   true}
#2021-04-0906:33thheller@ritt93 for :autorun true no. otherwise yes. see node out/node-tests.js --help#2021-04-0907:20flowthingClojureScript compilation fails for me with shadow-cljs 2.12.2 and ClojureScript 1.10.844. I get a bunch of errors like this:
Multiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "re_frame/interop.cljs"] still waiting for #{reagent.core}
{:aborted [:shadow.build.classpath/resource "re_frame/interop.cljs"], :pending #{reagent.core}}
Oddly, 2.12.1 works.
#2021-04-0908:01thheller@flowthing is this in a :browser build?#2021-04-0908:01thhellerI did change something regarding this in 2.12.2 but I haven't been able to reproduce#2021-04-0908:02ingesolHi! I’m latest shadow and tools.deps, trying to pass a config map through CLI. my alias looks like this
{:some-alias  
{:extra-deps  {
 thheller/shadow-cljs  {:mvn/version "2.11.23"}}
:main-opts   ["-m" "shadow.cljs.devtools.cli"
                                         "--config-merge" {:some "thing"}]}}
Running this alias gives me this error:
Error while parsing option "--config-merge {:some": java.lang.RuntimeException: EOF while reading
I did try to change the format of the map to be wrapped in a string, put it inside the string containing --config-merge, and wrapping it with both single and double quotes. Ideas?
#2021-04-0911:07ingesolSeems to be caused by the provided config containing spaces. If I just pass an empty map {}, it seems to work.#2021-04-0911:09ingesolAs doing this
["-m" "shadow.cljs.devtools.cli"
                                      "server"
                                      "--config-merge" []]
seems to be valid syntax and gives this message
--config-merge expects an EDN map argument
{:v []}
#2021-04-0911:13thhellerthis is a deps.edn issue. it doesn't properly escape strings and as such the argument doesn't arrive correctly in the shadow-cljs code#2021-04-0911:13ingesolah, thanks, was beginning to suspect that#2021-04-0911:14ingesolis it possible to point to an edn file for config-merge?#2021-04-0911:15thhellernot currently but you can open an issue and I'll add it#2021-04-0911:15ingesolgreat#2021-04-0908:08flowthing@thheller :node-test, actually.#2021-04-0908:10thhelleroh. then I know.#2021-04-0910:20tvirolaiHi, I'm being bitten by a strange issue when trying to compile Reagent code to React components using Shadow-CLJS. I don't know whether this has to do with Reagent, build configuration or something else. The problem is that when I'm compiling Reagent to React components, the components fail to render on the React side if they use Material UI components, with the error: Uncaught Error: Minified React error #321; visit for the full message or use the non-minified dev environment for full errors and additional helpful warnings. Could this be caused by the fact that Material UI components use React Hooks, which are disallowed in React class components? While debugging this, I set up a minimal test project to investigate the issue: https://github.com/tvirolai/mui-cljs-test. Here, Component1 renders while Component2 (with a Material UI icon) fails with the error. Any idea how to get around the issue? I asked around in the #clojurescript channel a couple of weeks ago, but couldn't find a workaround...#2021-04-0911:25thheller@tvirolai yes, this is related to hooks. ask in #reagent, this is not a shadow-cljs issue#2021-04-0911:26thheller@flowthing should be fixed in 2.12.3#2021-04-0911:30thhelleranyone want to leave a reply here: https://ask.clojure.org/index.php/10403/pros-and-cons-figwheel-vs-shadowcljs#2021-04-0913:03henryw374I'd be interested in seeing an open discussion between the leading lights of the cljs community 😉 on the various approaches to builds, future for cljs etc. there seem to be no end of podcasts these days but apparently never in a debate kind of format#2021-04-0913:11thhellerI try to always document the "why?" when I choose to follow a different path or slightly different setup in shadow-cljs#2021-04-0913:12thhellerthere are a couple posts in my blog https://code.thheller.com/ and some on clojureverse or just directly in the user guide#2021-04-0913:14henryw374I see that.... I really appreciate your efforts and am often sharing links to stuff you've written 👍#2021-04-0911:30thhellerI'm too biased to answer 😉#2021-04-0911:41flowthing@thheller Many thanks, will give it a try next week!#2021-04-0912:41raspasov@thheller I don’t use shadow-cljs currently but I would love you to answer 🙂 Always appreciate your input.#2021-04-0912:43thhellermisread sorry. I feel like I shouldn't answer because I have never used figwheel so I'm not qualified to compare it#2021-04-0912:44thhellerjust listing the shadow-cljs features doesn't really answer that question 🙂#2021-04-0912:47raspasovFair enough 🙂 I’ve been juggling whether I should try shadow-cljs; not having to deal with JS bundlers (webpack etc) is very compelling; However, for my current project in React Native specifically (and I mentioned that in the thread), you still need to use Metro, even if you use shadow-cljs (I am pretty sure that’s the case); so for that setup specifically, it doesn’t feel like it makes a ton of sense for me right now;#2021-04-0912:50thhellerI always say to never change a running setup, so what you have now is working properly for you and does what you expect it to do keep it#2021-04-0912:50thhelleryou'll still use metro regardless yes#2021-04-0912:51thhellerI also don't do react-native development so I can't even speak to what figwheel might be doing differntly#2021-04-0912:51thhellerI know that the loading mechanism is different but at runtime things are probably quite equal#2021-04-0912:52raspasovOne problem I did run into, but I’m not sure if shadow-cljs can help with this (and I don’t presume you know, because you don’t do much RN), is integrating a library like reanimated-v2#2021-04-0912:53raspasovThey do something unusual, in which they use React hooks that add ‘worklet’ in this style: https://docs.swmansion.com/react-native-reanimated/docs/worklets#2021-04-0912:55raspasovAfter that, at compile time (I believe), they look for those worklets and do some fancy stuff with them to make the animation run better.#2021-04-0912:55thhellerhmm yeah no clue sorry#2021-04-0912:56raspasovThey achieve that via some babel plugins; the problem is, that if you have those worklets writte in CLJS#2021-04-0912:56raspasov… the babel plugin can’t understand them;#2021-04-0912:56raspasovSince they are not written in JSX (I believe)#2021-04-0912:56thhellerwell you can always just write them in JS if needed I guess#2021-04-0912:56raspasovYes, that’s what I did 🙂#2021-04-0912:56raspasovJust have a local npm package…#2021-04-0912:57raspasovWhich I include… and pass data from CLJS; works well enough.#2021-04-0912:57raspasovBut for the sake of purity, I would like it to work from CLJS! 😄lightsaber#2021-04-0912:57raspasovBut otherwise, it works.#2021-04-0912:57thhelleryeah that won't work (with shadow-cljs either)#2021-04-0912:59raspasovThat’s what I thought… thanks!#2021-04-0912:53aratareas someone who briefly used figwheel/main and is now using shadow-cljs, I can say that setting up SCLJS takes much much much less time than figwheel/main#2021-04-0912:54aratareI was struggling to get figwheel-main up for an entire day and all it took was 15 mins with SCLJS#2021-04-0912:56aratarealso one more thing I like about SCLJS is the doc itself. Figwheel/main doc was kind of a mess when I was using it, and it contributed to why it was taking so long to set things up.#2021-04-0912:58raspasov@rextruong yea the shadow-cljs docs are really top notch#2021-04-0913:42p-himikSeems like :target :npm-module is broken in at least 2.12.3:
IllegalArgumentException: No matching field found: stripTypePrefixes for class com.google.javascript.jscomp.CompilerOptions
#2021-04-0913:47p-himikSeems like it's this commit: https://github.com/google/closure-compiler/commit/79ced4fdc09a82d77f61683e33f1e48630d8279d#2021-04-0913:49thhellerstripping was removed yes. what is the full stacktrace?#2021-04-0913:50thhellerI mean unless you are setting this in your build config it shouldn't be used anyways?#2021-04-0913:51thhellerah right ... npm-module calls it#2021-04-0913:53thhellerplease open an issue or it'll get lost, can't fix it now#2021-04-0914:27p-himikDone, https://github.com/thheller/shadow-cljs/issues/868#2021-04-0918:47Michaël SalihiHi! I tried to implement Inertia.js client side with Shadow-CLJS and Reagent. The documentation give this snippet who contains this following dynamic require
import { App } from '@inertiajs/inertia-react'
import React from 'react'
import { render } from 'react-dom'

const el = document.getElementById('app')

render(
  <App
    initialPage={JSON.parse(el.dataset.page)}
    resolveComponent={name => require(`./Pages/${name}`).default}
  />,
  el
) 
Is this possible with ClojureScript/Shadow-CLJS in the browser? With goog/require or something like that?
#2021-04-0918:47Michaël SalihiSource: https://inertiajs.com/client-side-setup#initialize-app#2021-04-0918:54Michaël SalihiFor now, I'm stuck with the expected error Uncaught ReferenceError: require is not defined
(ns myreagent.core
  (:require
   ["@inertiajs/inertia-react" :refer [App]]
   [reagent.dom :as d]))


(def el (.getElementById js/document "app"))

(defn home-page []
  [:> App {:initial-page (.parse js/JSON (.. el -dataset -page))
           :resolve-component (fn [name] (.-default (js/require (str "./Pages/" name))))}])

(defn mount-root []
  (d/render [home-page] el))

(defn ^:export init! []
  (mount-root))
#2021-04-0919:27thheller@admin055 dynamic require like that is not supported, but you can probably replace it with either just a normal reference or something using shadow.loader#2021-04-0919:30Michaël SalihiOK, thx for the confirmation.#2021-04-0919:33Michaël SalihiI don't about shadow.loader, I'll check, thank you. When you say normal reference, you mean like that?
(defn Home [{:keys [name]}]
  [:h1 (str "Hello " name "!")])

(defn home-page []
  [:> App {:initial-page (.parse js/JSON (.. el -dataset -page))
           :resolve-component (fn [name] (r/reactify-component Home))}])
#2021-04-0919:35thhelleryes#2021-04-0919:36thhellerI don't know what intertia.js is so I don't know what it expects, but that would be what I'd guess#2021-04-0919:37Michaël SalihiOK, in my case this is not suitable because it takes away the principle of Inertia.js.#2021-04-0919:37thhellerif this is about code splitting then follow https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2021-04-0919:44martinklepschI’m getting these strange errors in a fresh project recently:
107 |   (let [an (rum/react *active-notes)]
 108 |     [:div
 109 |      [:div [:code (pr-str an)]]
---------------------------------^----------------------------------------------
Use of undeclared Var starter.browser/an
--------------------------------------------------------------------------------
also saw this with another thing where a function argument was regarded as undeclared
#2021-04-0919:45martinklepschshadow version 2.11.23#2021-04-0919:51Michaël Salihi@thheller Inertia.js seems interesting project that I'll tried to write an back and adapter for Clojure. From the website: "Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers." The dynamic require is use to load the front component base on backend routing. Inertia read the component from the data-page attribute object.#2021-04-0919:53thhellerbut why does it have to be a dynamic require?#2021-04-0919:53thhellerI mean you can use code-splitting but you can also case (case name "foo" ComponentA "bar" ComponentB ...)#2021-04-0919:55thheller@martinklepsch since this is with rum I'm guessing that would be related to https://github.com/tonsky/rum/issues/233#2021-04-0920:01Michaël Salihi@thheller Yes the case works great but this implies adding the components by hand as the project progresses in this condition + require namespaces, etc.#2021-04-0920:02thhellerwell yes but at some point you could write a :target :intertia that automates all of that and emits the code optimal for intertia#2021-04-0920:03thhelleryou shouldn't except a generic :browser (or whatever you are using) build to match what intertia wants#2021-04-0920:03thhellerI'm too drained to look into what intertia is so I really don't have a clue what it does or wants#2021-04-0920:06Michaël SalihiYeah I understand, your help has already been precious. 😉#2021-04-0920:06Michaël SalihiThx Thomas.#2021-04-1010:38wombawombaI ran into a wierd situation where I was using one Node libray that was working well with shadow-cljs (https://github.com/react-syntax-highlighter/react-syntax-highlighter), and then added another library that works well with shadow-cljs (https://github.com/otakustay/react-diff-view – has no dependencies), and this caused shadow-cljs to be unable to import the former library. Oddly enough, removing the latter dependency (via yarn remove) does not seem to help. I've also tried restarting shadow-cljs and removing all build files. The import that fails is [react-syntax-highlighter :refer [Prism]], the error is, the line that fails in the generated code is Object.defineProperty(exports,"Prism",{enumerable:!0,get:function(){return _prism.default}}), and the error (that happens in the browser – everything compiles without error) is:
TypeError: Cannot read property 'default' of undefined
    at Object.get [as Prism] (<url-for-cljs-runtime-dir>/module$node_modules$react_syntax_highlighter$dist$cjs$index.js:2:442)
Any idea what could be going on here? How can I debug this further?
#2021-04-1010:44wombawomba...actually, one strange thing that I just found is that cljs-runtime/module$node_modules$react_syntax_highlighter$dist$cjs$prism.js.map contains var _prism = _interopRequireDefault(require(\"./styles/prism/prism\")); , but there's no corresponding var _prism line in cljs-runtime/module$node_modules$react_syntax_highlighter$dist$cjs$prism.js#2021-04-1010:46wombawombaFWIW here's prism.js:
shadow$provide.module$node_modules$react_syntax_highlighter$dist$cjs$prism=function(global,require,module,exports){var _interopRequireDefault=require("module$node_modules$$babel$runtime$helpers$interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0});exports.default=void 0;global=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$highlight"));module=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$styles$prism$prism"));
var _refractor=_interopRequireDefault(require("module$node_modules$refractor$index"));require=_interopRequireDefault(require("module$node_modules$react_syntax_highlighter$dist$cjs$languages$prism$supported_languages"));global=(0,global.default)(_refractor.default,module.default);global.supportedLanguages=require.default;exports.default=global}
#2021-04-1010:46wombawombaand here's prism.js.map:
{
"version":3,
"file":"module$node_modules$react_syntax_highlighter$dist$cjs$prism.js",
"lineCount":2,
"mappings":"AAAAA,cAAA,CAAe,2DAAf,CAAgF,QAAQ,CAACC,MAAD,CAAQC,OAAR,CAAgBC,MAAhB,CAAuBC,OAAvB,CAAgC,CAGxH,IAAIC,uBAAyBH,OAAA,CAAQ,kEAAR,CAE7BI,OAAA,CAAOC,cAAP,CAAsBH,OAAtB,CAA+B,YAA/B,CAA6C,CAC3CI,MAAO,CAAA,CADoC,CAA7C,CAGAJ,QAAA,CAAQK,OAAR,CAAkB,IAAK,EAEnBC,OAAAA,CAAaL,sBAAA,CAAuBH,OAAA,CAAQ,iEAAR,CAAvB,CAEbS,OAAAA,CAASN,sBAAA,CAAuBH,OAAA,CAAQ,0EAAR,CAAvB,CAEb;IAAIU,WAAaP,sBAAA,CAAuBH,OAAA,CAAQ,qCAAR,CAAvB,CAEbW,QAAAA,CAAsBR,sBAAA,CAAuBH,OAAA,CAAQ,2FAAR,CAAvB,CAEtBY,OAAAA,CAAc,CAAC,CAAA,CAAGJ,MAAH,CAAcD,OAAf,EAAwBG,UAAxB,CAAmCH,OAAnC,CAA4CE,MAA5C,CAAmDF,OAAnD,CAClBK,OAAA,CAAYC,kBAAZ,CAAiCF,OAAjC,CAAqDJ,OAErDL,QAAA,CAAQK,OAAR,CADeK,MApByG;",
"sources":["node_modules/react-syntax-highlighter/dist/cjs/prism.js"],
"sourcesContent":["shadow$provide[\"module$node_modules$react_syntax_highlighter$dist$cjs$prism\"] = function(global,require,module,exports) {\n\"use strict\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\");\n\nObject.defineProperty(exports, \"__esModule\", {\n  value: true\n});\nexports.default = void 0;\n\nvar _highlight = _interopRequireDefault(require(\"./highlight\"));\n\nvar _prism = _interopRequireDefault(require(\"./styles/prism/prism\"));\n\nvar _refractor = _interopRequireDefault(require(\"refractor\"));\n\nvar _supportedLanguages = _interopRequireDefault(require(\"./languages/prism/supported-languages\"));\n\nvar highlighter = (0, _highlight.default)(_refractor.default, _prism.default);\nhighlighter.supportedLanguages = _supportedLanguages.default;\nvar _default = highlighter;\nexports.default = _default;\n};"],
"names":["shadow$provide","global","require","module","exports","_interopRequireDefault","Object","defineProperty","value","default","_highlight","_prism","_refractor","_supportedLanguages","highlighter","supportedLanguages"]
}
#2021-04-1010:56wombawomba...it looks to me like shadow-cljs is leaving out a few lines of prism.js. Could this be a bug, or is there something I should be doing to make sure that these lines get included?#2021-04-1011:13wombawombajust saw that there's another error that happens prior to this:
TypeError: $jscomp.inherits is not a function
#2021-04-1011:15wombawombaI followed the instructions at https://stackoverflow.com/questions/64169633/clojurescript-typeerror-jscomp-inherits-is-not-a-function, and now it works!#2021-04-1011:16wombawombaThanks thheller for making a great tool btw :)#2021-04-1016:44thhellerwhen stuff works one way but then breaks when you add another package that is almost always caused by a version conflict on a common dependency#2021-04-1016:45thhellerlib A requiring v1 and lib B requiring v2 of some dependency and that often causes trouble#2021-04-1013:40Michaël SalihiHi @thheller In my case could ESM dynamic-import be useful? https://github.com/thheller/shadow-cljs/blob/3e559b8f9ea80cc1ad1c51772fe4aa8c099a1159/src/main/shadow/esm.cljs#L15#2021-04-1013:41Michaël SalihiI am trying.#2021-04-1016:14Joseph RollinsI'm trying to manage building functions for firebase alongside my clientside app. I'm currently using 2 builds to achieve this with the functions being built into the expected functions/index.js file. Unfortunately this requires duplicating my dependencies since firebase expects a functions/package.json file listing all deps and I also have to include those deps in the root package.json for shadow. Is there any way around this duplication. I don't see any support in shadow for specifying a different package.json for a particular build. Maybe there is another solution I'm missing?#2021-04-1016:41thheller@rollins.joseph in your functions build you can configure :js-options {:js-packages-dirs ["functions/node_nodules"]} then it'll take the packages installed there instead of the default <project>/node_modules#2021-04-1016:43thheller@admin055 I still don't know enough about inertia. I repeat that you should follow the code-splitting guide I posted yesterday. That will give you everything you need I think. It would be the same for esm basically, the dynamic import doesn't do anything magic for you.#2021-04-1016:44Joseph Rollins@thheller thanks, i'll give that a try#2021-04-1115:09wcalderipehey folks 👋 I'm having issues with cider-connect-cljs on a shadow-cljs project. I'm not sure this is the right channel to post my question, but I'm in the hope that someone else here would have faced the same issue before and will point me in the right direction or just say the right channel :) I noticed that when I connect Emacs to a running nrepl using cider-connect-cljs, my REPL doesn't work the same way as it does when I use cider-jack-in-cljs for instance. To be honest, I don't know if cider-connect-cljs and cider-jack-in-cljs have different user experiences but I assume they don't. I have recorded a video to try to explain the problem a bit better. What you can see is: - Run shadow-cljs watch to have the app and a REPL running - Use cider-connect-cljs to connect Emacs on the running REPL - Try to set the current namespace using cider-repl-set-ns - Try to eval a fn using cider-eval-last-sexp The project you see on the video is here https://github.com/wcalderipe/cljs-playground (there's nothing special). Versions: macOS Big Sur 11.2.2 Emacs 27.1 Cider latest commit on master (I'm using straight.el)#2021-04-1115:10wcalderipeI've just noticed the video is on extremely low quality. Sorry in advance 😅#2021-04-1115:11thhelleryeah I can't tell what is going on#2021-04-1115:12thhellerbut I don't use emacs anyways so I don't have a clue what any of those commands are supposed to do#2021-04-1115:12thhellerif the cider-repl-set-ns executes (in-ns 'whatever) then that will not work unless the NS is already compiled and loaded#2021-04-1115:13thhellerif that is not the case you need a (require 'whatever) first#2021-04-1115:13thhellerbut I'd assume the error would show up somewhere telling you that#2021-04-1115:17wcalderipe@U05224H0W I believe it does execute (in-ns 'foo) under the hood. btw, in-ns works if I just type it on the REPL#2021-04-1115:20thhellerin general #cider likely is a better place to ask this#2021-04-1115:21wcalderipethanks. will do 🙂#2021-04-1115:27wcalderipeI'll leave the message here in the hope someone using Emacs save me. Moreover, I'll drop my second screen record with higher quality.#2021-04-1115:59dpsuttonjust to fill in, CIDER is aware it starts with a clj repl and is waiting on (shadow/nrepl-select <the-build>). But since cider-nrepl is not on the classpath it never realizes that the clj repl has been switched to cljs and is stuck in a pending state (or what it thinks is a pending state)#2021-04-1118:11sh54Not sure what dependency that is causing an issue here but… I am getting an issue with goog.isBoolean not being defined. This is right now only happening in my karma build. And only in the cljs-oops library: https://github.com/binaryage/cljs-oops It is getting called by the oops function (in js terms) Object.oops$core$validate_object_access_dynamically I took a look at the generated output javascript file and I see that stuff like goog.isObject gets assigned and even goog.isDateLike which I don’t think I am directly touching in this project. But there is no similar assign to goog.isBoolean in the output file so it looks like it got pruned. My karma build parameters are: {:target :karma :output-to "target/test-ci.js" :compiler-options {:devcards true :infer-externs true :output-feature-set :es-next :warnings {:redef-in-file false :infer-warning false} :pretty-print true :pseudo-names true}}
#2021-04-1118:15thheller@slack1003 those predicate functions were removed from the closure-library, see the CLJS release announcement https://clojurescript.org/news/2021-04-06-release Noteworthy & Breaking Changes#2021-04-1118:35sh54oops got updated#2021-04-1118:36sh54so fixed by moving to 0.7.1#2021-04-1118:36sh54thanks#2021-04-1118:49sh54Is there a way to use something like the leiningen test selectors with the karma build?#2021-04-1118:49sh54All I really want to do is exclude running certain tests that were tagged with the relevant metadata. I have a bunch of webgpu tests which only run in Chrome Canary (and similar) which bail in regular headless chrome. There are work arounds like just checking if various js globals are defined. But I would prefer to just tag relevant namespaces and tests with some metadata and let the test runner figure it out. Since I am also targeting regular clojure too I tend to just run the tests via clojure when I am developing#2021-04-1118:50thhellerthat is not yet supported no. I have some changes regarding testing planned but didn't get around to them yet. might be a while too.#2021-04-1118:53sh54alright. Do you have some guidance on adding a new target? I just need a hint or two. Is it possible to supply a new target without replacing shadow-cljs with a fork?#2021-04-1118:57sh54great job on the whole system though! It is really nice to work with. This really is the only real sticking point I have come up against which I see I can get around with that regex or snooping for javascript globals#2021-04-1119:00thhelleryes you can write targets without changing shadow-cljs. in fact all targets are implemented that way. https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2021-04-1119:00thhellereg. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/karma.clj#2021-04-1119:01thhelleryou can also specify :target your.own-target#2021-04-1119:01thhellerthat ns would then need to declare a (defn process [build-state] build-state)#2021-04-1119:01thhellernone of that is documented in particular though, so will require some digging#2021-04-1119:02sh54and it’ll find it in my project as long as the process bit is there?#2021-04-1119:02thhellercan be in your project or a library yes, as long as that ns is on the classpath#2021-04-1119:03thhellerits just a regular CLJ namespace and the process function is called repeatedly for each step#2021-04-1119:03thheller:browser is by far the most complicated target but karma pretty straightforward#2021-04-1119:07sh54k thanks for the help there! I’ll take a look. may also just take the shortcut 🙂#2021-04-1119:09thhellerfwiw the node-test target already has some configuration options#2021-04-1119:09thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/test/node.cljs#2021-04-1119:09thhelleror rather runtime options configuring which tests to run#2021-04-1200:04ValentínI'm asking this question here, because my app built is controlled by shadow-cljs#2021-04-1201:08Azzuriteby this logic, you can ask any question you want... your question really has nothing to do with shadow-cljs, shadow-cljs just creates some javascript files for you, what you do with those js files is completely your problem you should ask this in a general or beginner channel or somewhere that has to do with heroku#2021-04-1201:13ValentínI took your recommendation#2021-04-1211:24Azzurite❤️ 👍#2021-04-1215:09grounded_sageHas anyone got a repl workflow working with developing chrome extensions?#2021-04-1215:14thhellerdepends on which "target" you are talking about? there are many different runtimes when it comes to extensions, background scripts, page injects, page actions etc#2021-04-1219:30grounded_sageYea I am still wrapping my head around it all. I’ll poke around a bit more and report back when I can more clearly express what I am looking for. I was basically wondering if there was any off the shelf demo repo’s that hooked up a repl for the extension runtimes where it works etc#2021-04-1215:16pinkfrogWhich is more standard, put :dev-tools section under build-id, or put :dev-tools under :dev (which itself is under build-id) ?#2021-04-1215:18thhellerdon't need to put devtools in dev, that is implicit and will not apply to release builds anyways#2021-04-1215:19pinkfrogBut putting dev-tools under dev seems to make it more structured.#2021-04-1215:20thhelleryou can put it there if you want, just don't need to#2021-04-1215:20thhellerI think its better directly in the build but YMMV#2021-04-1217:33denik
[:app] Build failure:
The required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".
#2021-04-1217:33denikanyone know how to fix this?#2021-04-1217:38thhellernot use shadow.xhr? 😛 goog.result was removed from closure-library with no replacement. where do you get this?#2021-04-1217:43denik@thheller initial build
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.oracle.truffle.js.scriptengine.GraalJSEngineFactory could not be instantiated
Warning: Nashorn engine is planned to be removed from a future JDK release
NPM dependency "@js-joda/core" has installed version "1.12.0"
"3.2.0" was required by jar:file:/Users/den/.m2/repository/cljs/java-time/cljs.java-time/0.1.18/cljs.java-time-0.1.18.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.18 running at 
shadow-cljs - nREPL server started on port 8877
shadow-cljs - watching build :app
[:app] Configuring build.
-> build target: :browser stage: :configure
<- build target: :browser stage: :configure (4 ms)
[:app] Compiling ...
-> Resolving Module: :main
[:app] Build failure:
The required namespace "goog.result" is not available, it was required by "shadow/xhr.cljs".
#2021-04-1217:44denikand not using shadow/xhr.cljs as far as I know (maybe libraries do)#2021-04-1217:44thhellerlooks like you are trying to use an older shadow-cljs version with the new cljs release?#2021-04-1217:44thhellerneed to bump shadow-cljs if you want to use cljs 1.10.844, which will also fix this problem#2021-04-1217:48denikI think I’m on the newest version
✨  Done in 0.35s.
➜  z1 git:(simple) ✗ yarn global add shadow-cljs
yarn global v1.22.5
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "
#2021-04-1217:48denikthat said, looks like shadow-cljs does not print its version at the beginning of the build process#2021-04-1217:48thhellershadow-cljs - server version: 2.11.18 you are not#2021-04-1217:49thhellerprobably using deps.edn or project.clj and didn't update there?#2021-04-1217:49thhellerthe yarn/npm install is just the command line, not the actual tool#2021-04-1217:51denikah yes, had an alias that overwrote it. vielen dank!#2021-04-1218:41jeff tangGetting the error
The required JS dependency "@material-ui/core/SnackBar" is not available, it was required by "athens/views.cljs".
when building on Linux but not Mac
#2021-04-1218:43jeff tangAlso not having a problem importing other core components like
["@material-ui/core/ExpansionPanel" :as ExpansionPanel]
    ["@material-ui/core/ExpansionPanelDetails" :as ExpansionPanelDetails]
    ["@material-ui/core/ExpansionPanelSummary" :as ExpansionPanelSummary]
    ["@material-ui/core/Slider" :as Slider]
    ["@material-ui/core/Switch" :as Switch]
#2021-04-1219:01jeff tanghmm, I think i figured it out. was importing SnackBar instead of Snackbar. interesting that this works on Mac but not Linux though!#2021-04-1219:33thhellerinteresting, probably just case insensitive filesystem#2021-04-1220:41Michael RispoliIs it possible to have the out directory be the same as the directory the cljs files is in? So instead of a dist directory just compile a js file right next to the cljs file and keep the directory structure as is?#2021-04-1221:22Michael RispoliMy end goal here is to introduce clojurescript to an existing node codebase gradually by compiling similar to how rescript (formerly reasonml) recommends right alongside each file. I was thinking it might help with adoption / testing if we were able to gradually compile certain features in clojurescript etc#2021-04-1220:48chrisnCan shadow-cljs's repl integration work if the index.html is dynamically generated server-side? I have a deps.edn-based project that I am playing with and we typically generate our home page server-side. I can get everything to work correctly aside from any cljs-repl functionality.#2021-04-1220:49chrisnTrying this out with emacs/cider if that changes the answer.#2021-04-1220:51chrisnHot-reloading is working.#2021-04-1220:58chrisnnm. Misread instructions. Everything works perfectly 🙂.#2021-04-1223:35awb99hi thomas! Is it somehow possible to add a ring undertow websocket handler to the shadow-cljs dev server? We use sente for websockets in our app, and we tested sente with undertow, and this works. but somehow I seem not to be able to get it to work on the shadow http dev server.#2021-04-1306:49thhellerI do recommend using your own server if you do this. :dev-http is meant as a STATIC webserver and using a custom handler is not recommended#2021-04-1306:50thhellerthat being said it does support websockets just fine, just probably not the ring variant or sente#2021-04-1313:10awb99sente works with undertow.#2021-04-1313:10awb99I tested it#2021-04-1313:11awb99https://github.com/pink-gorilla/webly/tree/sente#2021-04-1313:11awb99but it seems the websockets of undertow ring handler are different than the ones used in shadow cljs#2021-04-1304:52dvingois there a way to apply preloads only to some modules and not all. I am trying to create a web-worker, but the preloads assume the main thread js environment is present and are resulting in an exception when the worker starts.#2021-04-1306:50thheller@danvingo you can set :preloads per module yes. just {:modules {:main {:init-fn :preloads [foo.bar]}}}#2021-04-1312:19dvingoThanks! That worked, but these are dev-time only preloads, is there a way to include them only during dev and not a release? I tried nesting them under :dev but they aren't being included now:
{:modules {:main { :dev 
;; moving to here:
{:preloads [...]} }
          :worker{}}
:devtools          {:after-load         app.client.client-entry/refresh
                                          :http-port          8044
                                          :http-resource-root "public"
                                          :http-root          "resources/public"
;; moving from here
                                          :preloads           [com.fulcrologic.fulcro.inspect.preload
                                                               app.client.development-preload
                                                               com.fulcrologic.fulcro.inspect.dom-picker-preload]}}
#2021-04-1313:14thheller:preloads are ALWAYS developmen only and do not apply to release builds#2021-04-1313:15thhellerso just put it into modules like I said#2021-04-1313:41dvingoperfect, thank you!#2021-04-1312:14grounded_sageI have been digging through old Clojurians messages and issues on Github related to connecting a repl to different runtime environments we need to deal with when doing Chrome extensions. Still unclear to me if this is possible... let alone how to do it. It seemed that @wilkerlucio mentioned that he had it working on background and devtool but not content-script. Though I have not been able to get any working. Wondering what the current state of this is and whether it is worth investing any more time in trying to get it working. Seems that there is a lot of nrepl and sourcemap related issues..#2021-04-1313:03pinkfrogUsing shadowcljs$aot version, constantly seeing this error:
[:mobile] Build completed. (203 files, 91 compiled, 0 warnings, 13.29s)
Exception in thread "async-dispatch-2" java.lang.IllegalArgumentException: No implementation of method: :close! of protocol: #'clojure.core.async.impl.protocols/Channel found for class: nil
        at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
        at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:575)
        at clojure.core.async.impl.protocols$eval1077$fn__1078$G__1066__1083.invoke(protocols.clj:21)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:979)
        at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:975)
        at clojure.core.async$ioc_alts_BANG_$fn__3907.invoke(async.clj:384)
        at clojure.core.async$do_alts$fn__3839$fn__3842.invoke(async.clj:253)
        at clojure.core.async.impl.channels.ManyToManyChannel$fn__1491.invoke(channels.clj:265)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
#2021-04-1313:16thheller@i that means you are also using a conflicting too old core.async version as a dependency#2021-04-1313:17thhellerwith all AOT code you basically need to have the version that the AOT code used, otherwise you'll get errors such as that#2021-04-1412:09pinkfrogI wonder why that makes a difference. With or without aot, I thought using an old library will both fail, not aot alone.#2021-04-1412:16thhellerjust an artifact of how clojure AOT code works, doesn't mean the non AOT code will work. it might fail at a different point in the code and not directly on load#2021-04-1412:16thhellermight also just work but either way you should ensure to use a compatible version#2021-04-1313:19thheller@grounded_sage I cannot help without seeing your config or what you are actually doing. chrome extensions are rather difficult since they do have all sorts of restrictions but the repl and hot-reload do work. I cannot tell you more since I don't know what you have tried. this is still pretty much the only "documentation" that exists https://github.com/thheller/shadow-cljs/issues/279#2021-04-1313:23grounded_sageHere is the shadow-cljs.edn and the manifest.edn @thheller. Currently I get a tonne of few websocket errors that are thrown in the console and a bunch of sourcemap errors. https://github.com/homebaseio/datalog-console/blob/extension/shadow-cljs.edn https://github.com/homebaseio/datalog-console/blob/extension/shells/chrome/manifest.edn#2021-04-1313:24grounded_sageHave mostly been aligning with the file structure and set up done for fulcro-inspect so that it is easier to reference across the two and see differences.#2021-04-1313:25thhellerthen you are likely just blocking yourself with your CSP rules?#2021-04-1313:25thhellerhttps://github.com/homebaseio/datalog-console/blob/extension/shells/chrome/manifest.edn#L21#2021-04-1313:26thhellerI can never remember the exact rules for CSP but it needs to be able to connect to localhost:9630 (the shadow-cljs instance server)#2021-04-1313:26grounded_sageah sorry on my local that is set to 9630. Must have been a recent change I did not push.#2021-04-1313:27thhellerI mean if you get warnings/errors already then they are the hint to fix it as well#2021-04-1313:28thhelleryou can paste some and I can maybe tell you what they mean#2021-04-1313:42grounded_sageOkay. Seems that changing the CSP url to be the same as devtools-url removes the ws errors that are thrown. But this makes it different to what is happening in fulcro-inspect. Which has 9632 in the devtools-url and then 9630 in the CSP rules.#2021-04-1313:43grounded_sageI get this when I open up the chrome console inside of the chrome-panel. Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.#2021-04-1313:45grounded_sageIn both background (when clicking the url of extension inspect views) and the chrome panel I get a lot of source map loading errors DevTools failed to load source map: Could not load content for : HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME#2021-04-1313:45thhellerwell is it actually running on 9630 or 9632? it is logged on startup#2021-04-1313:48grounded_sageI now have it running on 9630. I'm not sure why it is different on fulcro-inspect. https://github.com/fulcrologic/fulcro-inspect/blob/3f1e2509c45712c15b7f3a2c64f878e412485286/shadow-cljs.edn#L15 https://github.com/fulcrologic/fulcro-inspect/blob/3f1e2509c4/shells/chrome/manifest.edn#L24#2021-04-1313:48thhellerwell if you have multiple shadow-cljs instances running locally and 9630 is taken it'll use 9631 then 9632 and so on#2021-04-1313:49thhellerdon't use :devtools-url at all if you want to avoid that headache#2021-04-1313:49thhellerah wait no you have to#2021-04-1313:49thhellerbut yeah use your port ...#2021-04-1313:56thhellerfor source maps try :source-map-inline true in :compiler-options#2021-04-1314:24grounded_sage:source-map-inline true worked for chrome-extension target but doesn't seem to be working for chrome target https://github.com/homebaseio/datalog-console/blob/extension/shadow-cljs.edn#L21. Though perhaps I have something else configured wrong here? I also seem to be able to connect to the background runtime with the repl when I set my devtools-url to 9630. When the devtools-url is set to 9632 I get WebSocket connection to '' failed: followed by shadow-cljs - remote-error several times before it gives up trying to connect.#2021-04-1314:25thhellerI do not understand why you are trying to connect to 9632. shadow-cljs ONLY starts ONE port. there is no such extra magic port with regards to chrome-extension#2021-04-1314:26thhellerso stick with 9630 if that is the port you are starting shadow-cljs with#2021-04-1314:26grounded_sageI was just following the configuration from fulcro-inspect#2021-04-1314:26thhellerbut it clearly doesn't apply to your setup. it can only connect to a port that actually exists, so don't configure one that doesn't#2021-04-1314:27thhelleras for the REPL connection. open http://localhost:9630/runtimes#2021-04-1314:27thhellerthat will list all the connected runtimes with their respective ids#2021-04-1314:28thhelleryou can switch to a specific one but the default rule is to connect to the first one that connects#2021-04-1314:28grounded_sageokay. We are doing similar things. Plan to also build an electron app so most of what was done there I thought would apply.#2021-04-1315:29grounded_sageThanks for pointing out the url for open runtimes. Was a big help. I am able to connect to them with the repl now. Only thing left is source-maps not loading in the panel. But I think this is a path related issue on my end.#2021-04-1315:45thhellerinline should fix it but might be a bug in the :chrome-extension target not supporting it properly or something#2021-04-1317:15grounded_sageyes it fixed it for this one actually. It was the :browser target for the panel UI that is still throwing the source map error.#2021-04-1315:45thhellerdon't know, can't check right now#2021-04-1316:17lispers-anonymousI have a question about an issue I've run into with the :output-feature-set :es5 setting with shadow-cljs. When my compiled javascript is loaded I get an error that says
Uncaught TypeError: $jscomp.arrayFromIterable is not a function
    memoizedFn memoize.js:60
    setEnabled history.js:503
    <anonymous> events.cljs:458
    re_frame$fx$do_fx_after fx.cljc:59
    ... blah blah ...
    <anonymous> babel-polyfill.min.js:1
    m babel-polyfill.min.js:1
    b babel-polyfill.min.js:1
Using the browser console, I can see that the $jscomp object is defined, but the function arrayFromIterable is not defined on it. Other functions are. I was able to fix this by defining the function in a :prepend statement for my module.
:prepend "$jscomp.arrayFromIterable = function(a) {return a instanceof Array ? a : $jscomp.arrayFromIterator($jscomp.makeIterator(a));};"
It fixed my problem. My javascript loads but it feels dirty. Is there another way to solve this?
#2021-04-1316:18thhellerthere is some issue with $jscomp I havent been able to track down yet#2021-04-1316:19thhellernormally it just goes away after wiping the cache and recompiling. just try deleting .shadow/builds/<build-id>#2021-04-1316:19lispers-anonymousI attempted that, but it did not fix my issue#2021-04-1316:19thhellerand then restarting the watch or release#2021-04-1316:19thhellerhmm odd#2021-04-1316:19lispers-anonymousIt goes away when I target :es6 but I can't do that because of internet explorer 😞#2021-04-1316:19thhellerI mean if you can make a reproducible minimal repro that would help a lot#2021-04-1316:20thhellerIE is dead 😉#2021-04-1316:20lispers-anonymousNot for my enterprise customers unfortunately lol#2021-04-1316:22lispers-anonymousI will see if I can make a reproduceable small build. That might take me a while to do. I'm working on migrating a really large cljs application to shadow so there are a lot of moving parts. In the mean time, maybe that little hack will help someone.#2021-04-1316:51emierIn testing, what’s a good way to run some js code from a file (`myPreloads.js` ), which mocks some things before running the main test function? Basically, achieving the same thing as copy-pasting the code from myPreloads.js to the beginning of the test/target/testable.js file (which obviously isn’t a good idea).#2021-04-1319:45lispers-anonymousI was able to accomplish this by writing my own preloads and using those in the test build.#2021-04-1319:48lispers-anonymousIf running clojure code won't work for you, you should be able to require the js file in the namespace declaration of your preload file.#2021-04-1914:22emierThanks for the reply @dannyfreeman, that seems to do what I want it to! However, now I get a problem with the modules that are required from the preloaded js file. So right now I have my preload namespace:
(ns preloads
  (:require ["./myPreloads.js"]))
and the js file I want to run, which requires its own modules myPreloads.js
...
require("module-alias/register");
...
I get the following error when trying to run the tests:
SHADOW import error /app/.shadow-cljs/builds/test/dev/out/cljs-runtime/myPreloads.js

/app/test/target/testable.js:67
    throw e;
    ^
Module not provided: shadow.js.shim.module$module_alias$register
Looking at the generated testfile testable.js, this is where it does the import.
SHADOW_IMPORT("shadow.js.shim.module$module_alias$register.js");
Can’t really figure out how to require these modules so that shadow can find them. Am I missing something here?
#2021-04-1914:24lispers-anonymousThat I am unsure about. I did run into some issues around testing code meant for a browser for a node-test target that seems similar. To fix those issues I had to set this option in my :test profile in shadow-cljs.edn file
:js-options {:entry-keys ["module" "browser" "main"]}
#2021-04-1914:25lispers-anonymousI'm really unsure what the implications of doing that are, but combining that with stubbing out the global window object got my tests to run in node.#2021-04-1914:45lispers-anonymousAlso, if the contents of myPreloads.js are pretty simple, you could try re-writing them in clojurescript directly in your preloads cljs file. Perhaps shadow-cljs doesn't understand the code in your js file.#2021-04-1914:48emierOkay, from the docs it seems like :js-options determines which build variant to use for the npm package, e.g. CommonJS or ESM. Unfortunately, adding it doesn’t do anything for me. Unfortunately, myPreloads.js is quite extensive so I’m trying to avoid rewriting it in cljs.#2021-04-1914:53emier@thheller any ideas on how to fix this error related to shadow-cljs being unable to import npm modules that are required from a local js-file which in turn was required in a preload namespace? More info in my first reply of this thread#2021-04-1914:55emierNot sure if it makes a difference, but the modules it can’t find seems to be devDependencies#2021-04-1915:02thhellerhow are you running the tests? it is :node-test I presume?#2021-04-2006:40emieryes, using :node-test#2021-04-2006:45thhellerif your preloads only setup node related things and don't interact with CLJS in any way you can just use node -r ./preloads.js your-test-output.js#2021-04-2006:45thhellerthere are ways to get it into the build of course but this would be the fastest and easiest#2021-04-2006:54emierokay, it seems it could work, is there a way to make :autorun run this as well though?#2021-04-2007:12thhellerno there is not but I don't recommend using that anyways#2021-04-2007:13thhelleryou are much better off using something like https://www.npmjs.com/package/chokidar-cli to watch the test output file and have that rerun the tests when needed#2021-04-2007:13thhellerthat also gives you full control over how tests run and so on#2021-04-2007:16emierThanks for the tip, I’ll look into it! Just curious, what’s the reason behind the nested requires not working when using preloads?#2021-04-2007:20thhellerit should work but what the code does actually matters and I don't have enough information to say#2021-04-2007:20thhellerif you have some reproducible code I could probably tell you
#2021-04-2007:21thhellerbut without its kinda hard to say#2021-04-1318:40thheller@dannyfreeman you can do it a little cleaner by setting :compiler-options {:force-library-injection ["es6/util/arrayfromiterator"]}. the problem is that the polyfill detection logic somewhere makes a mistake and that part gets lost but you can always just tell it which polyfills to include#2021-04-1318:42thhellerthey are all listed here https://github.com/google/closure-compiler/tree/master/src/com/google/javascript/jscomp/js#2021-04-1318:43thhellerso the above would just include https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterator.js which you did via the :prepend#2021-04-1318:43thhellerwell or rather https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/es6/util/arrayfromiterable.js#2021-04-1318:51lispers-anonymousI just tried to use :force-library-injection ["es6/util/arrayfromiterable"] in my compiler-options and that did not work. arrayfromiterator also didn't change anything but that function is available already.#2021-04-1318:58lispers-anonymousIs it possible that arrayfromiterable needs to be included here: https://github.com/thheller/shadow-cljs/blob/9a4144b65141ecdacc28fefed53fe968035363e5/src/main/shadow/build/closure.clj#L2522#2021-04-1319:00thhelleroh right. force-library-injection only triggers for release builds#2021-04-1319:00thhellerI guess that could be adjusted too yeah#2021-04-1319:00lispers-anonymousI will try this on a release build real quick#2021-04-1319:04lispers-anonymousYeah that :force-library-injection key works for my release build, but not a development build.#2021-04-1319:23thhellerhttps://github.com/thheller/shadow-cljs/issues/870#2021-04-1319:27lispers-anonymousThank you 🙂 is there anyway I could help out with that?#2021-04-1319:40thhellertoo late 🙂 should be fixed in 2.12.5. also just added the interable by default so should be ok even without config.#2021-04-1319:43lispers-anonymousAwesome. I'll be on the lookout for that release. Thank you very much for the help.#2021-04-1320:44valsenHi, noob question here. What is a common way to set and access env variables, for example to use different firebase configs for dev/prod? I’ve tried using js/process.env but get a ReferenceError: process is not defined. Is there some trick to getting this to work in shadow or cljs in general?#2021-04-1320:46thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines + https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2021-04-1414:19valsenI’ve configured my env variables and added them to my shadow-cljs.edn as described in those links, but how can I now reference/use them in my cljs code? For example, if I have :closure-defines {app.core/APIKEY #env "APIKEY"} , I don’t understand how to reach it from within the app.core namespace#2021-04-1414:28valsenIf I try something like {:api-key #shadow/env "APIKEY"} I get a compile error No reader function for tag shadow/env . And simply referring to it by its name, APIKEY , I get an undeclared var error#2021-04-1415:06thhelleryou (goog-define APIKEY "default value") in app.core and then use it like any other clojure def#2021-04-1415:17valsenOk, thanks:) It does however feel a little strange having to use system environment variables for setting config values for the frontend. Isn’t it more common do that in runtime instead of when compiling?#2021-04-1416:13thhelleryes, but a browser environment will hardly have access to your system environment#2021-04-1416:13thhellerso either way it is something that will become part of your build at compile time#2021-04-1416:14thhellerI do recommend keeping some kind of configuration in your HTML directly, so that it becomes actual "environment" configuration and is not hardcoded at build time#2021-04-1407:46flowthingDoes shadow-cljs have an API for getting the ClojureScript compiler environment? I'm asking because I'm considering implementing basic ClojureScript auto-completion support from scratch and I believe I need to get a hold of the compiler environment for that.#2021-04-1407:46flowthingI found this comment: https://github.com/thheller/shadow-cljs/issues/76#issuecomment-318763762 But that snippet doesn't seem to return the compiler env anymore (unless I messed something up).#2021-04-1407:49thheller(shadow.cljs.devtools.api/compiler-env :the-build)#2021-04-1407:49flowthingHow did I not find that... facepalm thanks!#2021-04-1407:49thhellerwatch needs to be running for that to work#2021-04-1407:50flowthingSure.#2021-04-1408:28flowthingAnother (maybe too vague) question: I'd like to start a nested REPL using clojure.main/repl that leverages shadow-cljs to evaluate ClojureScript. I'm wondering whether there's any prior art on this sort of thing I ought to be looking at? I tried quickly hacking something together and came up with this:
;; *out-fn* is bound to a function that prints to the socket output stream
(let [out-fn tutkain.repl.runtime.repl/*out-fn*]
  (clojure.main/repl
    :read clojure.core.server/repl-read ;; add :repl/quit support
    :need-prompt (constantly false) ;; don't want prompt
    :prompt (constantly "") ;; don't want prompt
    ;; eval is code -> value -- cljs-eval is string -> string, so need to pr-str the input form
    :eval #((requiring-resolve 'shadow.cljs.devtools.api/cljs-eval) :app (pr-str %) {})
    :print (fn [{:keys [results out err ns]}]
             (when (seq out) (out-fn {:tag :out :val out}))
             (when (seq err) (out-fn {:tag :err :val err}))
             (run! #(out-fn {:tag :ret :val % :ns ns}) results))))
This seems to work as far as very basic use goes. Does this seem like a reasonable approach? I know that's not enough to have special things like in-ns work -- need to look into that some more.
#2021-04-1408:31thheller(shadow.cljs.devtools.api/repl :the-build {:prompt false})#2021-04-1408:34thhellerif you want more control over what the REPL does you could use what it internally uses#2021-04-1408:34thhellerhttps://github.com/thheller/shadow-cljs/blob/af40121e41ece2aac1fbb9072ebc5d71baa2579b/src/main/shadow/cljs/devtools/server/repl_impl.clj#L320-L363#2021-04-1408:34thhellerbut would be better to make an issue for it with a proper description so I can add an actual API fn for it#2021-04-1408:34flowthingYeah, that's what I was looking for. Thanks! I'll dive into it and make an issue if something turns up.#2021-04-1408:34thhellerdigging into internals too much is not recommended because I might break it at any point 😛#2021-04-1408:35flowthingSure. 🙂#2021-04-1412:34flowthingOne more: if I do this:
(when file
    (let [{:keys [results err]} ((requiring-resolve 'shadow.cljs.devtools.api/cljs-eval)
                                 :app
                                 (format "(cljs.core/load-file \"%s\" %s)" file code) {})]
      (when err
        (out-fn (response-for message {:tag :err :val err}))
        (run! #(out-fn (response-for message {:tag :ret :val %})) results))))
And the code is a ClojureScript namespace that uses an auto-qualified keyword like ::db/reset, I get this error:
repl-input.cljs [line 23, col 38] Invalid keyword: ::db/reset.
The namespace has a require like this: [app.client.db :as db]. Are auto-qualified keywords not supported? This might also be more of a general ClojureScript question, but if I've understood correctly, shadow-cljs implements its own load-file kind of thing.
#2021-04-1412:35thhellerit is much easier for me to answer stuff if you show the actual REPL code#2021-04-1412:36thhellershadow-cljs node-repl or browser-repl and then the actual command#2021-04-1412:36thhellerI don't know if you are escaping the strings properly etc#2021-04-1412:36thhellerthe aliases should work just fine, assuming they actually exist#2021-04-1412:36flowthingOh, string escaping is a good point. Gotta double-check that.#2021-04-1412:37flowthingThey do exist, the code itself works. But yeah, I'll come back with a better repro if it's something else than string escapes.#2021-04-1412:37thhellerload-file also only take one argument?#2021-04-1412:39flowthingOh, that's right. I must've gotten it mixed up... good catch, thanks. :thumbsup::skin-tone-2:#2021-04-1417:22orestisIs there a way to generate the "build report" html file when doing a proper release? Right now it seems that it takes as much time to do the release as it takes to generate the report. Would be nice to cut our CI times in half.#2021-04-1417:25thhellernot currently no. it could in theory but currently it is separate since it changes a bunch of stuff in the config to make things easier. needs to be able to access source maps and stuff#2021-04-1417:25thheller(which are not enabled by default for release for example)#2021-04-1417:30orestisMakes sense. I've enabled source maps in release mode now (I'm trying to integrate Sentry), but I guess it's not that simple.#2021-04-1417:32thhellershould be simple but no clue 🙂#2021-04-1420:49Alys BrooksI've tried enabling the babel integration to compile my output for IE11, but it doesn't seem to be working. Here's my shadow-cljs.edn:
{:builds {:main 
          {:js-options {:babel-preset-config {:ie 11}}
...}}
...}
#2021-04-1420:51Alys BrooksI tried enabling a verbose build log, and babel doesn't seem to be anywhere.#2021-04-1420:53thhellerbabel is not applied to all JS sources, the more reliable option is :compiler-options {:output-feature-set :es3}#2021-04-1420:53thhellerwhat exactly doesn't work in IE11? I mean typically es5 should be fine for that?#2021-04-1421:02Alys BrooksI think the issue is that IE11 doesn't support String.includes . The code is for a client and not open source, so I'd have to see if the error is in the application code or one of the libraries we're using.#2021-04-1421:06thhelleryou can try setting :compiler-options {:force-library-injection #{"es6/string/includes"}} in your build config#2021-04-1421:06thhellerthat will inject the polyfill if needed#2021-04-1422:31Alys BrooksI fixed one of the issues upstream with glögi, but now URLSearchParams is causing a problem.#2021-04-1506:52thhellerdid you try a release build? unless you are on version 2.12.5 the :force-library-injection only works for release builds#2021-04-1518:54Alys BrooksOh, that works now, thanks! I'm not sure there's a Google Closure polyfill for URLSearchParams, though.#2021-04-1519:03thhelleryou can always use https://polyfill.io/v3/ to get whatever standard polyfills you need for IE#2021-04-1519:34Alys BrooksThat looks like a good resource! I have seen references to babel, but it seems like it might lag behind in terms of polyfill support.#2021-04-1519:34thhellerbabel doesn't lag behind. babel isn't used.#2021-04-1519:35thhellerit has one specific purpose in shadow-cljs but that is not polyfilling. in fact we don't want it to polyfill at all and I'll likely remove that aspect of it completely#2021-04-1519:38Alys BrooksOh, gotcha#2021-04-1519:42Alys BrooksI think I'm going to use goog.uri instead of https://polyfill.io. (Probably why Google Closure doesn't have a polyfill for URLSearchParams)#2021-04-1519:44Alys BrooksWould you be interested in a PR adding documentation around :force-library-injection? It seems like it's a fallback/last resort, but the documentation could definitely note that.#2021-04-1519:45thhellerunder normal circumstances it is never required to set it#2021-04-1519:46thhellerjust under some weird circumstances that I have not been able to reproduce it needs to be manually added#2021-04-1519:46thhellersure it would be worth documenting but I'd rather identify why its not detected properly 😉#2021-04-1519:52Alys BrooksMakes sense. I can try to reproduce with a minimal sample project, if that would help.#2021-04-1520:06thhellerit would#2021-04-1620:02Alys BrooksYou might not be surprised to hear that I'm not having a lot of luck reproducing in a simpler sample project. I thought maybe something about Glögi was confusing it or perhaps Glögi plus separate modules, but both of those are working fine. I'll keep trying today.#2021-04-1620:08thhelleryeah it has proven difficult to reproduce 😛#2021-04-1421:53Alys BrooksI'm not having any luck with that either. 😕 . I'm putting it in :builds . It also looks like the issue is coming from one of the libraries I'm using. I don't think that should make a difference, as it's also ClojureScript that would need to be compiled, though?#2021-04-1422:20Alys BrooksThe build log does say it's generating polyfills#2021-04-1505:48Vincent CantinI am compiling 2 independent CLJS projects A and B with shadow-cljs, and load them both into the same browser webpage as compiled JS scripts. I am trying to make A read a CLJS hashmap produced by B. The transmission of the data is made via JS property js/window.b-data. This part is working. Now, when A runs (get b-data :foobar) it returns nil. The keyword is not found because :foobar in A is different than :foobar in B.
;; We are in A's runtime.

(def b-foobar (first (keys js/window.b-data)))

(keyword-identical? :foobar b-foobar) ;; false
(identical? (.-fqn k) (.-fqn :ui/alert)) ;; true
(keyword? b-foobar) ;; false
The problem of (get b-data :foobar) is that b-foobar fails keyword?.
(core/defmacro keyword? [x]
  (bool-expr `(instance? Keyword ~x)))
Maybe Keyword is a different in A and in B ? Would there be a way with Shadow-CLJS to make b-data pass the predicate keyword? ?
#2021-04-1506:04Vincent CantinI found the definition of Keyword inside cljs/core.js :
cljs.core.Keyword = (function (ns,name,fqn,_hash){
this.ns = ns;
this.name = name;
this.fqn = fqn;
this._hash = _hash;
this.cljs$lang$protocol_mask$partition0$ = 2153775105;
this.cljs$lang$protocol_mask$partition1$ = 4096;
})
Since both compiled CLJS runtime are using a different function (the same implementation but different "instance"), it makes sense that the instance? fails.
#2021-04-1506:11Vincent CantinI guess that there is no way for shadow-cljs to help, here.#2021-04-1506:49thhelleryeah what you are trying to do is not possible#2021-04-1506:50thhellerand I strongly recommend against doing it at all, two separate builds means two separate cljs.core and whatever other dependencies they might be sharing#2021-04-1506:50thhellerlots more for the user to download#2021-04-1506:50thhellerif you need to share data you are doing to need to use transit/edn#2021-04-1506:51thhellerbut ideally don't have separate builds in the first place#2021-04-1507:39Vincent CantinMy use case is Cypress tests (`A`) with my webapp (`B`) via https://github.com/viesti/cypress-clojurescript-preprocessor#2021-04-1507:40Vincent CantinI try to read the values in re-frame.db/app-db#2021-04-1507:41thhellerthen I'd recommend just having the test build include your regular app?#2021-04-1507:42thhelleror create an exported function in your main app that you can call to get the DB as transit or so#2021-04-1507:43thhellerincluding two separate development builds at the same time is guaranteed to cause issues as well#2021-04-1507:44thhellertwo release builds can work but even they might cause problems with each other#2021-04-1507:54Vincent CantinI succeeded using a hack, but it is very brittle
(defn rewrite [x]
  (walk/prewalk
    (fn [x]
      (case (pr-str (type x))
        "cljs.core/Symbol" (symbol (.-ns ^js x) (.-name ^js x))
        "cljs.core/Keyword" (keyword (.-ns ^js x) (.-name ^js x))
        x))
    x))
#2021-04-1507:57thhelleryou are basically asking for trouble, nothing will work as expected. don't do this. I can't do more than warn you 😉#2021-04-1509:18Vincent CantinI tried your approach and exported a function which spits the db as edn in a string. It works very well. Thank you !#2021-04-1509:29Karol Wójcik1. How can I provide "react" and react-dom using :provider :external and using webpack.ProvidePlugin? This is what I've tried:
const path = require('path');
const webpack = require('webpack');

module.exports = {
    entry: './public/js/index.js',
    mode: 'development',
    output: {
        path: __dirname + '/public/js',
        filename: "libs.js"
    },
    devServer: {
        stats: 'errors-only',
        contentBase: path.resolve(__dirname, '/public/js'),
        publicPath: '/'
    },
    plugins: [
        new webpack.ProvidePlugin({
            react: 'react',
            ReactDOM: 'react-dom',
        })
    ],
    module: {
        rules: [
        ]
    }
};
Still getting:
app.js:1563 Error: Dependency: react-dom not provided by external JS. Do you maybe need a recompile?
    at shadow$bridge (index.js:14)
    at eval (shadow.js.shim.module$react_dom.js? [sm]:3)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:497)
    at Object.env.evalLoad (app.js:1560)
    at app.js:1699
env.evalLoad @ app.js:1563
(anonymous) @ app.js:1699
11:27:52.383 
2. Btw: Specifying global require like (:require ["react"]) does not work. It has to be (:require ["react" :as react]). Why?
#2021-04-1509:58Karol WójcikActually 2. is more suprising for me.#2021-04-1510:13thhellerdon't know why you are messing with provideplugin?#2021-04-1510:14thhellerjust compile the file with webpack without any plugins or special config#2021-04-1510:14thhellerthe external index js does not require that, only if you add additional custom js you may need it for that?#2021-04-1510:19Karol WójcikStopped messing with providePlugin. I've used something like this instead:
(ns web.globals
  (:require
   ["react" :as react]
   ["react-dom" :as react-dom]))
Still I don't understand why it needs this :as 😕
#2021-04-1510:20Karol WójcikI need webpack config. I want to tree-shake antd-design.#2021-04-1510:51Karol Wójcik@thheller Could you please elaborate what you mean by custom js?#2021-04-1510:58Karol WójcikOk. I think I found a bug in shadow$bridge. Without :as the dependency is not registered. Shouldn't (:require ["react"]) generate require('react')? in external-provider file? This is with :as:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!

var ALL = {};
ALL["@ant-design/icons"] = require("@ant-design/icons");
ALL["antd/lib/divider"] = require("antd/lib/divider");
ALL["antd/lib/input/Search"] = require("antd/lib/input/Search");
ALL["antd/lib/layout/Sider"] = require("antd/lib/layout/Sider");
ALL["antd/lib/layout/layout"] = require("antd/lib/layout/layout");
ALL["react"] = require("react");
ALL["react-dom"] = require("react-dom");
global.shadow$bridge = function shadow$bridge(name) {
  var ret = ALL[name];

  if (ret === undefined) {
     throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
  }

  return ret;
};

shadow$bridge.ALL = ALL;
This is without :as:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!

var ALL = {};
ALL["@ant-design/icons"] = require("@ant-design/icons");
ALL["antd/lib/divider"] = require("antd/lib/divider");
ALL["antd/lib/input/Search"] = require("antd/lib/input/Search");
ALL["antd/lib/layout/Sider"] = require("antd/lib/layout/Sider");
ALL["antd/lib/layout/layout"] = require("antd/lib/layout/layout");

global.shadow$bridge = function shadow$bridge(name) {
  var ret = ALL[name];

  if (ret === undefined) {
     throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
  }

  return ret;
};

shadow$bridge.ALL = ALL;
#2021-04-1511:03thhellerfirst of all regarding the :as. without it is is basically unusable so I don't understand why that is even a question?#2021-04-1511:04thhellerwhat is the overall goal for this?#2021-04-1511:04thheller> I want to tree-shake antd-design#2021-04-1511:04thhellerwhat does that mean for you? I mean you already have separate requires which basically is tree shaking already?#2021-04-1511:05thhellerI'm unsure why the external index doesn't include requires without :as and that could be considered a bug but I'd still like to understand why you don't want the :as? I mean you do intend to use react right?#2021-04-1511:06thhellerby custom JS I mean JS code you write that you want to compile with webpack and include alongside the external index#2021-04-1511:17Karol Wójcik@thheller Ok let me explain myself a little bit. I don't know whether I will ever use "react" in the code like react/createElement or so. "react" and "react-dom" are only required so that I can use reagent, therefore requiring "react" :as react is now something I don't need. (it's just triggers clj-kondo warning) Regarding ant-design yes you're right. Now it's treeshaked since I'm directly specifying the path to component, but I would rather use ant plugin for webpack and simply refer the components I want. Another story is including css which I also plan to do with webpack. At some point I want to require less in shadow-cljs like so: (:require ["./core.less"]). Don't know whether it will work with shadow-cljs. https://ant.design/docs/react/use-with-create-react-app#2021-04-1512:53thhellerok so. reagent.dom will be including react-dom so if you don't plan on using it in your code then don't#2021-04-1512:53Karol WójcikAhhh.. I think I got you!#2021-04-1512:53thhellertree shaking in webpack is based on the import statements but since the shadow-cljs external index generates require that won't work#2021-04-1512:54thhellerI did start to implement with supporting :refer to emit import instead but that'll have a few compatibility issues so I used require for now#2021-04-1512:55thheller(:require ["./core.less"]) will not work since classspath relative imports will always be processed by shadow-cljs directly and only supports JS#2021-04-1512:56Karol WójcikOk I will somehow live with using full path for importing ant components. Is it possible to somehow bypass shadow-cljs so that "./core.less" will not be processed by shadow-cljs?#2021-04-1512:59thhellerin ns :require no#2021-04-1513:01Karol WójcikOh. But still I can use js/require am I right? 🙂#2021-04-1513:02Karol WójcikProbably import is special statement and cannot be used like js/require 😄#2021-04-1513:03thhelleradding either import or js/require is not valid#2021-04-1513:03thhellersince ONLY the external index file will be processed by webpack#2021-04-1513:03thhellernot the CLJS parts#2021-04-1513:04thhellerI could add an extra mechanism to tell webpack to also include other stuff#2021-04-1513:04thhellerbut it will not be part of ns :require#2021-04-1513:04thhellercould be ns metadata or so#2021-04-1513:05thhellerwould be much easier to talk about this if you setup a demo repo of what you'd like to have#2021-04-1513:05thhellerdoesn't need to be functional but something code wise we can talk about. its all a bit abstract in a slack thread#2021-04-1513:06Karol WójcikSure. I will provide a demo.#2021-04-1513:06Karol Wójcik🙂#2021-04-1513:06Karol WójcikThank you @thheller#2021-04-1608:24Karol Wójcik@thheller Here is a demo of what I'm trying to achieve: https://github.com/FieryCod/ant-design-in-shadow-cljs Basically I want to import less, and scss files into .cljs so that webpack could handle compilation of both.#2021-04-1608:59thhellercan you explain why this exists? https://github.com/FieryCod/ant-design-in-shadow-cljs/blob/master/src/web/globals.cljs#2021-04-1611:09Karol WójcikYep. It's needed by reagent. Alternatively I can put those line in app.cljs.#2021-04-1611:16thhellerit is NOT needed by reagent#2021-04-1611:16thhellerwhat gives you that idea?#2021-04-1611:18thhellerreagent already declares its own dependency on react. https://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L4#2021-04-1611:18thhellerI'd like to understand why you are repeating it?#2021-04-1611:19Karol WójcikOk. Just please remove those lines. You will see that shadow does not include react.#2021-04-1611:20Karol WójcikWe're going through the stuff I already described above.#2021-04-1611:31thhellerok so a couple notes#2021-04-1611:32thhellerthis will never work and there is no way to make it work https://github.com/FieryCod/ant-design-in-shadow-cljs/blob/master/src/web/app.cljs#L9#2021-04-1611:33thhellerbut you only seem to want to include it for the side effects right? it is never actually used anywhere#2021-04-1611:33thhellerthe problem is that webpack is not aware of the classpath#2021-04-1611:33thhellerso the path you include that way needs to be relative from the output file, not the source file#2021-04-1611:35thhellerand the point of this repo is that you want to replace ["antd/lib/divider" :default AntDivider] with just ["antd" :refer (Divider)] or whatever that would be?#2021-04-1611:36thhelleror is it to get less support?#2021-04-1611:37Karol WójcikI want to 1. Replace ["antd/lib/divider" :default AntDivider] with ["antd" :refer (Divider)] 2. Include less, scss via webpack.#2021-04-1611:37Karol WójcikI want both 😄#2021-04-1611:37thhellerand antd doesn't require any additional setup to support this? thought it required a plugin to do that?#2021-04-1611:37Karol WójcikThere is https://www.npmjs.com/package/babel-plugin-import#2021-04-1611:38thhelleryes but it isn't setup anywhere. I'm trying to figure out what is actually needed from the shadow-cljs side#2021-04-1611:40Karol WójcikThere are two things. 1. Generate imports not require (you said that it requires some work therefore I'll probably wait for it) 2. Allow to require assets in external provider. #2021-04-1611:41Karol WójcikI will add babel-loader and babel-plugin-import to project in couple of hours.#2021-04-1611:41thhelleras for requiring assets#2021-04-1611:42thhelleryou are now using webpack to process public/js/index.js. you could write a manual public/js/index-with-styles.js or whatever that just does require("./index.js"); require("./ant.less") etc#2021-04-1611:42Karol WójcikI'm wondering whether it's possible to create a .js file which I import in shadow-cljs that would point to assets.#2021-04-1611:43Karol Wójcik😄#2021-04-1611:43thhellerso not sure that is really something shadow-cljs needs to do#2021-04-1611:44thhellergenerating imports is a problem for one simple reason. the convention is that commonjs packages such as react must be imported as import React from "react" which in JS terms is a singular default export#2021-04-1611:44thhellerbut all CLJS code uses [react :as react] so :as**#2021-04-1611:44thhellerwhich would be import * as react from "react"#2021-04-1611:45thhelleremitting an ESM import is difficult for that reason#2021-04-1611:45Karol WójcikAhhh.. Got it#2021-04-1611:45thhellerthe code actually already exists to generate ESM https://github.com/thheller/shadow-cljs/blob/989590bb373e56b1d0ccf3a4029e2d3ec294ffe3/src/main/shadow/build/targets/external_index.clj#L68-L84#2021-04-1611:46thhellerthe problem is that pretty much all CLJS libs break because of their now "incorrect" requires#2021-04-1611:47thhellerfor the code you control you could easily just switch the references#2021-04-1611:47thhellerbut that is not so easy for library code such as reagent#2021-04-1611:47thhellerso the only reason it uses require in the first place is compatibility#2021-04-1611:48thhellerI don't really have a solution for this but the problem will be present until all JS libraries uniformly written in ESM#2021-04-1611:53thhellerand everything will likely change again once packages such as antd adopt https://webpack.js.org/guides/package-exports/#2021-04-1611:54thhellerthat react via reagent alone doesn't work is a bug#2021-04-1611:59Karol WójcikI've forgotten how much js world is a mess by working with cljs for 2 years.#2021-04-1611:59Karol WójcikTotally understandable why you're resisting to adopt asset require in shadow-cljs.#2021-04-1612:02thhellerwell the external code already has partial support for (ns {:external/assets ["./foo.less"]} (:require ...))#2021-04-1612:03thhellerit is useful to be able to express such things in code, just doing it via require is bad IMHO#2021-04-1612:03thhellerbut JS doesn't have namespaces or metadata so they have a harder time to get something like this 😛#2021-04-1612:22Karol Wójcik:external/assets are great! Love it#2021-04-1513:37pinkfrog@thheller reading your post: https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html. What will be reloaded when a cljs file changes. Will the ns containing the init-fn be reloaded, of the ns just containing the modified code.#2021-04-1513:46thhellerthe ns you changed + all those that have a direct require for that one#2021-04-1513:59pinkfrogso are you saying the ns has in-direct require to the changed ns won’t be re-required ?#2021-04-1514:00pinkfrogSeems not documented: https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2021-04-1514:08pinkfrogI see: shadow-cljs will only automatically recompile the direct dependents since in theory dependencies further up cannot be directly affected by those interface changes.#2021-04-1516:57thheller> On the backend the shadow-cljs watch app process will compile a namespace when it is changed and also recompile the direct dependents of that namespace (ie. namespaces that :require it). This is done to ensure that changes to the namespace structure are reflected properly and code isn’t using old references.#2021-04-1516:58thhelleryou can change the reload strategy to reload all files or set :dev/always metadata if you want to force recompile a namespace on every change#2021-04-1513:46thhellerinit-fn ns only if that has a direct require, otherwise no#2021-04-1519:47thosmosI’m getting some errors when watching my project after updating the version to 2.12.5. Not sure how to troubleshoot this:
[2021-04-15 12:37:05.387 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). 
...
[2021-04-15 12:44:11.955 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
#2021-04-1519:48thheller@thosmos version conflict. not using the updated 1.10.844 CLJS with 2.12.+ won't work#2021-04-1519:48thosmosOK thanks will upgrade to that#2021-04-1520:13thosmosThat worked#2021-04-1610:19happyb3atHow to debug this error? I create a brand new project but get IllegalArgumentException: no conversion to symbol Clojure lein new re-frame duck Retrieving re-frame/lein-template/2.1.2/lein-template-2.1.2.pom from clojars Retrieving re-frame/lein-template/2.1.2/lein-template-2.1.2.jar from clojars Generating re-frame project. ➜ Clojure cd duck  ➜ duck shadow-cljs run shadow-cljs - config: /home/hovgaard/Clojure/duck/shadow-cljs.edn shadow-cljs - updating dependencies Retrieving thheller/shadow-cljs/2.12.5/shadow-cljs-2.12.5-aot.jar from https://repo.clojars.org/ shadow-cljs - dependencies updated running: npm install --save --save-exact /cdn-cgi/l/email-protection /cdn-cgi/l/email-protection added 101 packages, and audited 102 packages in 2s 3 packages are looking for funding  run npm fund for details found 0 vulnerabilities IllegalArgumentException: no conversion to symbol        clojure.core/symbol (core.clj:596)        clojure.core/symbol (core.clj:589)        shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:70)        shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:65)        shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:126)        shadow.cljs.devtools.cli-actual/blocking-action (cli_actual.clj:116)        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:177)        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)        clojure.core/apply (core.clj:669)        clojure.core/apply (core.clj:660)        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)        clojure.lang.Var.applyTo (Var.java:705)        clojure.core/apply (core.clj:665)        clojure.core/apply (core.clj:660)        shadow.cljs.devtools.cli/-main (cli.clj:75)        shadow.cljs.devtools.cli/-main (cli.clj:67)        clojure.lang.Var.applyTo (Var.java:705)        clojure.core/apply (core.clj:665)        clojure.main/main-opt (main.clj:514)        clojure.main/main-opt (main.clj:510)        clojure.main/main (main.clj:664)        clojure.main/main (main.clj:616)        clojure.lang.Var.applyTo (Var.java:705)        clojure.main.main (main.java:40) duck clojure --version Clojure CLI version 1.10.3.822 duck java --version openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment 18.9 (build 11.0.10+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)#2021-04-1611:14thheller@alan.hovgaard why do you call shadow-cljs run? that expects more arguments? did you mean shadow-cljs server, shadow-cljs watch app or so?#2021-04-1618:07happyb3atWow yeah.. shadow-cljs watch app ...all works fine... RTFM... thx thheller 🙂#2021-04-1615:21SchpaaGetting this when trying to include some modules of codemirror
Closure compilation failed with 1 errors
--- node_modules/lezer-tree/dist/tree.cjs:385
ES6 transpilation of 'declaration with multiple destructuring children not in statement block' is not yet implemented.
#2021-04-1616:09mkvlrgo lezer!#2021-04-1615:21Schpaais there a trick I could do to avoid this?#2021-04-1615:29thhellerset :compiler-options {:output-feature-set :es6}#2021-04-1615:29Schpaanice, that works, and thanks!#2021-04-1618:18yedihey folks, i'm using shadow-cljs to create a Github Action that uses cljs (targeting nodejs). I'm getting what looks like extern related errors when the built JS is run by Github. I do see some inference warnings in the shadow-cljs build output here's the error I see when the github action is run: "f.git.zc is not a function" here's the code that's failing (println (<p! (.. octokit -git (updateRef update-args)))) - octokit is pulled from a github npm library. so this def seems externs related but I'm wondering how i'd resolve this in a nodejs context? do I really need to add externs for each function i want to use from github's library? interestingly, i have another line prior to the above which seems to run successfully without any extern issues: ref-resp (js->clj (<p! (.. octokit -git (getRef ref-args)))) any idea what might be happening here?#2021-04-1618:20thhellerthe problem is that core.async loses typehints so even if you type hint the externs inference doesn't work correctly#2021-04-1618:20thhellerbut yeah this is an externs issue#2021-04-1618:22thhelleryou can fix it by moving as much interop code out of the go block as possible#2021-04-1618:22yediso if i wrap those lines in a function defined outside of the go block, i should be good?#2021-04-1618:23thhellerdepends on what octokit is but in theory yes#2021-04-1618:25yedii'll try it and see what happens#2021-04-1618:37yediso that looks like it's workign thanks @thheller#2021-04-1618:38yedijust out of curiosity do you recommend folks use a lib like cljs-oops in order to not worry about externs?#2021-04-1618:38thhellerI wouldn't recommend using it#2021-04-1618:39thhellernormally externs inference is a much better way to go, it just suffers a little in core.async#2021-04-1618:47yediok i actually had one last question (though this might be more on the github actions end) - if i don't commit the node_modules/ directory along with the JS script that shadow-cljs outputs, then I get this error when the script is run on github: Error: Cannot find module '@actions/core' while committing node_modules/ alongside the script seems to work, i always thought doing a release with shadow-cljs would automatically use the closure compiler to inject the relevant JS from those node modules into the outputted script. i feel like there might be a piece of this i'm not following#2021-04-1618:48thhellerby default :node-script (which I assume you are using?) does not bundle the dependencies since node will provide them via node_modules#2021-04-1618:49thhelleryou can post-process the file with https://github.com/vercel/ncc which would make it standalone#2021-04-1618:50yediah k, i saw that recommended elsewhere, was wondering if its still the same with shadow. cool ty#2021-04-1710:44Janis PeisenieksHello folks! I’m pretty new to shadow-cljs, but I’m curious - is there a way to add a preamble to the generated js file? https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options, but I’m curious if I’m missing something. My use case is that I’d like to add a link to a file with the licenses of the OpenSource libraries I’ve used#2021-04-1710:49thheller@janis each module can have a :prepend "some-string"#2021-04-1710:49thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_modules#2021-04-1710:51Janis Peisenieksfacepalm Thank you @thheller#2021-04-1713:44conanHello I've been struggling with some type inference:
(let [^js data (.data author-post)
      postRef (.-post data)]
  )
gives me Cannot infer target type in expression (. inst_51072 -post) but if I do this
(defn get-data
  [^js o]
  (.data o))

(let [data (get-data author-post)
      postRef (.-post data)]
  )
it works. any ideas why? there's something i'm not understanding, and any advice would extremely appreciated!
#2021-04-1713:54conanusing
(aget data "post")
works too, but i'm cargo-culting the belief that this is bad
#2021-04-1714:25lispers-anonymousIs the let inside a go block?#2021-04-1714:31conanyes, this is all inside a go block#2021-04-1714:33lispers-anonymousType hints in clojurescript can get lost in go blocks. The best thing to do is extract things out into functions like you have here. I believe it is an issue with the go block macro#2021-04-1714:33lispers-anonymousI will try to find a source of this for you#2021-04-1714:34lispers-anonymousHere is one: https://increasinglyfunctional.com/2021/01/28/clojurescript-type-hinting-core-async-gotcha.html#2021-04-1821:33conanoh! well that is surprising. thanks for the sleuthing!#2021-04-1716:12zalkyHi all, investigating migrating to shadow-cljs for our builds and in the processes of piecing together our previous workflows. Specifically, we we had one project that depended on another. Previously we would use webpack to produce a js bundle, and then include it as a :foreign-lib, telling the cljs-compiler what namespace it :provides. We could then put this bundle in in the dependency jar, and then have access to those same foreign libs in the dependent project. The shadow browser target operates on the node_modules folder. Is there some recommended approach to coordinating these kinds of transitive js dependencies with shadow?#2021-04-1716:43thheller@zalky if you want to continue using webpack I'd suggest using :js-provider :external as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-04-1716:49zalkyThanks @thheller for the link! Giving it a read now. I don't suppose it makes any sense to package node_modules itself into the jar file, and have shadow access it from the depedent's classpath?#2021-04-1717:13zalkyOk, just to see if I've understood the implications of your blog post in the context of a dependent project, I could try something along the lines of: 1. Configure the dependency project with :js-provider :external 2. Generate libs.js via webpack 3. Package libs.js in the dependency jar 4. Configure the dependent project with :js-provider :external 5. Include the libs.js along with the depedent's main.js Have I got the right idea?#2021-04-1717:20thhellerno, that sounds wrong#2021-04-1717:20thhellerfirst of all: why webpack? do you include other non CLJS stuff or is it purely for bundling npm dependencies for use by CLJS?#2021-04-1717:58zalky@thheller, purely for bundling npm dependencies. Doesn’t have to be webpack, but before shadow it was the simplest approach to managing the npm dependencies between our two projects. Our dependant project didn't really have to worry about any npm workflows. It could just rely on the bundle to have the correct version of everything. Definitely open to other workflows that shadow may enable. #2021-04-1718:00thhellerwell just letting shadow-cljs handle the npm dependencies will be straightforward (well depending on which packages you use). letting webpack do that will require much more configuration#2021-04-1718:44zalkyThat would be ideal but would that require introducing a package.json into the dependant project and ensure all the transitive npm dependencies are installed in the dependant project?#2021-04-1719:04zalkyA bit more context if it helps: we have a full-stack clojure application with backend, frontend and sass that is all bundled as a framework and deployed in different domain specific contexts. These domain specific applications extend the core one. The core app is really easy to bring into a new project as a dependency, the biggest pain point was the npm modules that the core app requires. Bundling these with webpack, and then including the bundle in the jar meant that anyone working the domain specific applications would not have to worry about npm workflows. You do have to declare your foreign libs :provides in the dependent project, but this seemed easier than having package.json track transitive dependencies and then having to manually sync npm installs.#2021-04-1716:44thhelleryou'd still need to replace your :foreign-libs setup probably though. shadow-cljs does not support those as they are in general not required and problematic when mixing with npm dependencies#2021-04-1819:57pezI have two libraries, A and B, depending on different versions of library C. Can I configure my way around this?#2021-04-1820:23pezI could. :exclusions. I have a bit of a special case, but the right :exclusions did it.#2021-04-1909:13Volodymyr HuzarI have a problem with starting shadow-cljs server on my Jenkins Alpine Linux machine using shadow-cljs start After long time I’m getting
shadow-cljs - server starting "a lot of dots and" `Cannot contact jenkins_cluster: hudson.remoting.RequestAbortedException: java.nio.channels.ClosedChannelException` error.
It could be some policy of our Jenkins which doesn’t allow that but I cannot find any information which I can pass to our DevOps to investigate that. Is the some way to get more details what is going on under the hood of this command? Or maybe there is a way to enable some logs (`-v` and --debug shows nothing)?
#2021-04-1910:43Volodymyr HuzarThe same is going one when I try to run shadow-cljs start on Docker image https://github.com/theasp/docker-clojurescript-nodejs locally. You can reproduce it from your project directory using
docker run --rm -v ${PWD}:/home/my-project -w="/home/my-project" theasp/clojurescript-nodejs:latest npx shadow-cljs start
#2021-04-1914:14thhellerwhy are you using start in a CI environment?#2021-04-1914:50Volodymyr Huzar@thheller I would like to use https://github.com/lambdaisland/kaocha-cljs2 to run tests and I need somehow to serve the compiled tests with shadow-cljs, so I have decided to use shadow-cljs server for that. I am not sure if it is the best choice. I would appreciate a better advice on that if you have#2021-04-1914:52thhellerhmm I don't know anything about kaocha or how it runs tests unfortunately#2021-04-1914:52thhelleryou could maybe run the tests via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2021-04-1915:03Volodymyr HuzarActually what I need is to serve the complied directory with lambdaisland.chui.remote to be preloaded. And shadow-cljs server looks ideal. I could try to look for another way to achieve the same. But do you have any idea why it doesn’t work on Docker? Is it expected or can I log the issue in GitHub for that?#2021-04-1915:07thhellerI don't have a clue why it wouldn't work. maybe the logfiles created in the .shadow-cljs/ dir provide some clues? I'm not capable of debugging docker issues. if server works fine I'd assume start to work as well since the only thing it does is detach to process into the background.#2021-04-1915:22Volodymyr Huzarlet me actually check if shadow-cljs server works inside Docker. I haven’t checked it separately#2021-04-1916:25Volodymyr Huzar@thheller when I am using shadow-cljs server with local docker I get a project specific error (out of scope for my question). But it seems shadow-cljs start hanging when errors occur, is it possible?#2021-04-1916:28thhellerhow does it fail? could certainly affect start yes#2021-04-1916:41Volodymyr Huzarshadow-cljs server failed (actually process just ends) during fetching lein private dependencies because of luck of permissions. During shadow-cljs start it just shows dots#2021-04-1916:45thhelleryeah with start all logging goes into the log files in .shadow-cljs/server.stdout.log or server.stderr.log#2021-04-2112:07Volodymyr Huzar@thheller thanks for you advices, they helped me to find root cause of the problem. I will create an issue in GitHub for use case that start is hanging when error occurs during start up if you don’t mind. My root issue on Jenkins was that jks ssl certificate which we use for local environment was not committed and I still not sure is it a good idea to commit it. Is it possible somehow to force shadow-cljs to ignore ssl certificate if it is not found instead of throwing exception?#2021-04-2112:09thhellerif the cert is not found ssl won't work? or do you not need that to work?#2021-04-2112:10Volodymyr HuzarI don’t need that to work. I need SSL for local server but not when I run tests#2021-04-2112:12thhellerhmm yeah I guess there should be an option to disable that but for CI you could just write a simple script that just deletes the :ssl config from shadow-cljs.edn before actually starting it#2021-04-2112:13Volodymyr HuzarOption will be better, but I try to write something in meanwhile#2021-04-2112:16thheller
(require '[ :as io])
(require '[clojure.edn :as edn])
(let [file (io/file "shadow-cljs.edn")]
  (-> (slurp file)
      (edn/read-string)
      (dissoc :ssl)
      (as-> config
        (spit file (pr-str config)))))
#2021-04-2112:16thhellerif you have clojure installed on the CI system you can just put that into a script file and run it with that#2021-04-2112:16thhelleror use something like babashka#2021-04-2112:21Volodymyr Huzarthanks a lot. I’ll try#2021-04-2112:30thhellerfeel free to open issues about this. can't get to it now but maybe later#2021-04-1910:41ingesolWhile setting up :js-provider :external, I have found that it only works with ["react" as react] style requires. Meaning that both the string-style and the alias is required in order for the corresponding js require to be generated. Is this a known issue/by design? This could be very tricky for others to figure out. The string syntax is fine, when documented, but the required alias is more of a pitfall.#2021-04-1914:16thheller@ingesol that is a bug yes#2021-04-1914:20ingesol@thheller Ok, I’ll retest to verify the pattern and post a bug#2021-04-1915:53witekHi. I am building with :target :node-library and I would like to use the fetch api. But (js/fetch ...) fails with fetch is not definded and requiring ["node-fetch"] fails with symbol module$shadow_js_shim_module$node_fetch already provided by [:shadow.build.js-support/require "node.fetch"], conflict with [:shadow.build.js-support/require "node-fetch"]. Any suggestions how to access the fetch function? Thank you.#2021-04-1916:08thhellerlooks like you have a node.fetch and a node-fetch? they clash, stick to one I guess?#2021-04-1916:42witekWhat do you mean by "you have"? In my own namespaces I don't use any of these. But I would like to and I can not fugure out how to require it.#2021-04-1916:44thhelleryou said "requiring node-fetch failed". try node.fetch#2021-04-1916:44thhellerwhich shadow-cljs version do you use? I thought these kinds of clashes were fixed?#2021-04-1916:50witekI am on the latest version. Requiring [node.fetch :as nf] errors in the compiler with he required namespace "node.fetch" is not available. Requiring ["node.fetch" :as nf] passes the compiler, but errors at runtime when loading with Error: Cannot find module 'node.fetch'. 😞#2021-04-1916:52thhellerI'm confused then. something else appears to be using it?#2021-04-1916:52thhellerso even if you fix your end it still won't run since that uses it?#2021-04-1916:53witekEverything runs fine. Until I require anything of it.#2021-04-1916:54thhellerI'm entirely confused. WHERE does the "node.fetch" come from? if you ONLY have "node-fetch" that should be totally fine but having that as well as "node.fetch" will not work#2021-04-1916:55thhelleras the error tells you SOMETHING required "node.fetch"#2021-04-1916:55witekI have some dependencies. Like firebase-admin and firebase-functions. Perhaps it comes from there.#2021-04-1916:55thhellernot if you are using :node-library, then shadow-cljs will not process any npm dependencies at all. some CLJS code must be requiring that#2021-04-1916:58witekOk, I will check. Or narrow down my scope. Thank you very much for your time!#2021-04-1917:00thhelleralso verify which shadow-cljs version you are using. I thought I fixed this particular issue.#2021-04-1917:01thhellerthe problem is that node-fetch AND node.fetch both munge into the module$shadow_js_shim_module$node_fetch pseudo-namespace and they need to be unique#2021-04-1917:02thhelleralthough I don't understand how you get that name to be honest. that should be shadow.js.shim.module$node_fetch. might be something weird in your setup, can't say#2021-04-1917:34witekFor the record. What I forgot to mention 😞 is that my compiled code is not executed directly - instead the Firebase Cloud Functions Emulator loads it. I added "node-fetch" to my package.json and now requireing "node-fetch" works.#2021-04-2008:56andrehi, does anyone know how to enable js/performance for :target :node-test ?#2021-04-2008:57thhellerno such thing in node. it is a module there. see https://nodejs.org/api/perf_hooks.html#2021-04-2008:58andrehow can i use this module ?#2021-04-2008:59thhelleras you use any other module (:require ["perf_hooks" :refer (performance)]) or so#2021-04-2008:59andreoh ok thanks#2021-04-2009:00thhelleror require that somewhere else and make it a global so js/performance works#2021-04-2009:00thhellerI think the API is the same#2021-04-2009:02andremany thanks!#2021-04-2015:37ghaskinsHi all, does anyone have experience with the “@date-io/date-fns” npm package?#2021-04-2015:37ghaskinsim struggling with the import, trying everything I know but they are all returning nil#2021-04-2015:38ghaskinse.g.
(require '["@date-io/date-fns" :as DateFnsUtils])
=> nil
DateFnsUtils
=> nil
#2021-04-2015:39ghaskinsIm not always clear when various options are eligible to try, but I can typically get it to work by following https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-04-2015:39ghaskinsbut this one is stubborn#2021-04-2015:42thhellerI don't know that library. might help to try node and the var x = require("@date-io/date-fns") x just to see what that would be#2021-04-2015:42thhellermight just be an error during load or something? did you check the console?#2021-04-2015:43ghaskinslet me try that#2021-04-2015:46ghaskinsnothing on the console, node returns#2021-04-2015:46ghaskins
> var x = require("@date-io/date-fns")
undefined
> x
[Function: DateFnsUtils]
#2021-04-2015:52ghaskinsim basically trying to follow this: https://material-ui-pickers.dev/getting-started/installation#2021-04-2015:53thheller
> (require '["@date-io/date-fns" :as DateFnsUtils])
nil
cljs.user=> DateFnsUtils
#object[Function]
cljs.user=>
#2021-04-2015:53thhellerseems to work fine for me?#2021-04-2015:53ghaskinsunfortunately all 4 options are part of the same @date-io package so I suffer the same fate with all#2021-04-2015:53ghaskinsinteresting#2021-04-2015:53ghaskinsi wonder why its not working here#2021-04-2015:53ghaskinswhat version of @date-io did you use?#2021-04-2015:54ghaskinsim using “@date-io/date-fns” “1.3.13"#2021-04-2015:54ghaskins(the material/picker said it was dependent on v1.x so maybe they updated in v2#2021-04-2015:55thhellerit installed these for me
"@date-io/date-fns": "^2.10.8",
    "date-fns": "^2.21.1",
#2021-04-2015:56ghaskinsok, ill see if I can level set with v2#2021-04-2016:00Arondate-fns v2 > v1#2021-04-2016:00ghaskinsyes, the dep I am using explictly states to use @1.x#2021-04-2016:00Aronevery function should be independently requirable#2021-04-2016:00ghaskinsbut, thanks#2021-04-2016:01ghaskinsit might just be too old#2021-04-2016:03AronI see, I am not sure why it wouldn't work, but I remember having some issues similar to yours. Sadly I don't remember how I resolved it, I might've just looked for a different dependency at the time. Imho there should be no reason why the old one wouldn't work.#2021-04-2016:03ghaskinsI know, its confounding#2021-04-2016:03ghaskinsill keep plugging#2021-04-2110:28Shako FarhadAnyone here using shadow-cljs in an ubuntu 20.04 environment under WSL2 on WIndows 10? After upgrading from WSL1 to WSL2, shadow-cljs doesn't recognize diffs in my files so it doesn't recompile. Basically hot reloading doesn't work. Force compile from the server doesn't generate new files either. Anyone know what to do to fix this?#2021-04-2110:33thhellerstick with wsl1. thats a known problem on the wsl2 side, nothing shadow-cljs can do about that#2021-04-2110:35thhellerhttps://github.com/microsoft/WSL/issues/4739#2021-04-2110:38thhellerwsl1 actually is better anyways if you work on the files from the windows side anyways. network also becomes quite annoying since the wsl2 container gets its own IP and stuff. IMHO WSL1 is still better and I use that still.#2021-04-2110:43Shako FarhadI had to upgrade to WSL2 because nginx didn't work properly in WSL1. And unfortunatly I need this to work since we want dev and prod environments to be as similar as possible. I will try to move my projects to the linux filesystem and see if that maybe helps.#2021-04-2110:45thhellerpretty sure that doesn't help but let me know if it does#2021-04-2110:52AronI use shadow-cljs in wsl2 ubuntu#2021-04-2110:53AronAt least I thought that's what I am doing.#2021-04-2110:54AronBut yeah, I do everything from inside the wsl, even the editor runs from there (using X, kitty, nvim or alternatively vscode with their very good wsl support)#2021-04-2111:21Shako Farhad@thheller I fixed the issue. Changes to the file now does trigger recompile. 1. I git cloned all my repositories to /home/user/src in the linux filesystem. 2. I mapped the linux filesystem network folder to a normal drive foler. Follow this short guide: https://support.microsoft.com/en-us/windows/map-a-network-drive-in-windows-10-29ce55d1-34e3-a7e2-4801-131475f9557d 3. Then I opened my repository folder with Intellij (also works with VS Code). 4. Make changes in intellij to the file -> shadow-cljs compiles and nginx serves the new file. Probably works without nginx too.#2021-04-2111:23Shako FarhadBTW. The compilation time seems to be faster too now. But this is just a feeling I have now, no hard data behidn that statement. 😛#2021-04-2112:02thhellerthanks for the info#2021-04-2112:07Shako Farhad@thheller I notice that shadow-cljs fails to connect to the websocket when the server is serving the files over 127.0.0.1 instead of localhost. Is it possible to perhaps have the reconnection logic try both? I know it is possible to specify the host in the config file, so it is a minor issue. I just think it might lead to a bit of confusion for some?#2021-04-2112:08thhellerthats not something that is fixable I think. I mean if you connect to 127.0.0.1 that would need to map to the container ip#2021-04-2112:08thhellerdunno how that is handled for localhost, maybe thats another adapter or has some forwarding logic#2021-04-2112:08thhellerby default the browser websocket connect logic will use the host you used to open the page#2021-04-2112:11Aronif you do nginx, you have to forward the ports imho#2021-04-2112:11Aronand the reason it works with localhost I think is some OS level magic related to WSL#2021-04-2112:12Arontell me if I am wrong 🙂#2021-04-2112:13Shako FarhadAh really?
server {
    listen 127.0.0.1:80;
    include /home/dev/src/locations.conf;
}
THis is what I have in my nginx config.
#2021-04-2112:13thhellerbut do you have something extra on the windows side?#2021-04-2112:14thhellerlast time I checked it didn't automagically forward ports but it has been a while#2021-04-2112:14thhellerotherwise the 9630 port should also just work#2021-04-2112:16AronI checked and I have nothing about the 9630 anywhere and it works#2021-04-2112:16Shako FarhadNothing special on the windows side. The locations is just:
location /client/ {
    alias /home/dev/src/client/resources/public/;
}
So going to 127.0.0.1/client/ will load up everything. Shadow-cljs is stuck reconnecting and then stops trying. Changing it to localhost makes shadow-cljs connect right away and everythign works. :x
#2021-04-2112:16Aronthe ws server and webui#2021-04-2112:17Aronbut obviously not with 127.0.0.1#2021-04-2112:18thhellerneat, guess I should test that again. dealing with network ports was very annoying last time I tried#2021-04-2112:19Shako FarhadYeah
:http {:port 9630
       :host "127.0.0.1"}
this does not help. Looks like the server is not started at http://127.0.0.1:9630/, at least my browser shows nothing when trying to open that page. So even when specifying the host, the reconnection fails.
#2021-04-2112:19Aron#2021-04-2112:20Arondo you absolutely need the 127.0.0.1?#2021-04-2112:20Shako Farhad
NAME            STATE           VERSION
* Ubuntu-20.04    Running         2
#2021-04-2112:20Shako FarhadHehe I don't think so. I will check things on my side.#2021-04-2112:26Aronhave you tried searching for shadow-cljs in the WSL github issues?#2021-04-2112:26Shako FarhadNo, I haven't 😮#2021-04-2112:28Aronbecause this had some TIL for me https://github.com/microsoft/WSL/issues/4851#2021-04-2112:29Arona quote, because sometimes I am surprised that a vague memory turns out to be resonant > Tag needs-investigation in the sense this needs a ruling on whether the current (circa 19640) behavior of the magic WSL localhost tunnel is by-design (by fiat), or should route ipv4 `127.0.0.1` to ipv6 `::1` automatically like it does on Linux.#2021-04-2112:30thhellershadow-cljs defaults to binding to whatever address is returned by localhost#2021-04-2112:32thhelleroh wait no, it defaults to 0.0.0.0#2021-04-2112:32thhellerbut you can control this via the :http :host#2021-04-2112:33AronI haven't changed anything like this. I set a dev-http and an nrepl port#2021-04-2117:04lilactownI upgraded to 2.12.5 and get the following when running a watch:
[2021-04-21 10:03:22.948 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (clojure/tools/reader/edn.clj:75:9). #:clojure.error{:phase :compile-syntax-check, :line 75, :column 9, :source "clojure/tools/reader/edn.clj"}
	clojure.lang.Compiler.analyze (Compiler.java:6808)
	clojure.lang.Compiler.analyze (Compiler.java:6745)
	clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3820)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7109)
	clojure.lang.Compiler.analyze (Compiler.java:6789)
	clojure.lang.Compiler.analyze (Compiler.java:6745)
	clojure.lang.Compiler$IfExpr$Parser.parse (Compiler.java:2837)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7107)
	clojure.lang.Compiler.analyze (Compiler.java:6789)
	clojure.lang.Compiler.analyze (Compiler.java:6745)
	clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6120)
	clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6436)
Caused by:
RuntimeException No such var: err/throw-no-dispatch
	clojure.lang.Util.runtimeException (Util.java:221)
	clojure.lang.Compiler.resolveIn (Compiler.java:7388)
	clojure.lang.Compiler.resolve (Compiler.java:7358)
	clojure.lang.Compiler.analyzeSymbol (Compiler.java:7319)
	clojure.lang.Compiler.analyze (Compiler.java:6768)
	clojure.lang.Compiler.analyze (Compiler.java:6745)
#2021-04-2117:06thhellerwrong tools.reader version#2021-04-2117:06lilactownlein deps :tree shows that shadow-cljs depends on org.clojure/tools.reader "1.1.3.1"#2021-04-2117:06lilactownand AFAICT that's the only version present#2021-04-2117:08lilactownlooking at the source on github, throw-no-dispatch exists#2021-04-2117:10lilactownif nothing else shows up on the deps tree depending on it, how do I know what's pulling in the wrong tools.reader version?#2021-04-2117:11thhellerdo you use profiles? did you active those that would be activated when starting shadow-cljs?#2021-04-2117:12thhellertry lein repl (with profiles if needed) and ( "clojure/tools/reader/edn.clj")#2021-04-2117:13lilactownI don't use any profiles#2021-04-2117:14lilactown
user=> ( "clojure/tools/reader/edn.clj")
#object[java.net.URL 0x440076b6 "jar:file:/Users/lilactown/.m2/repository/org/clojure/tools.reader/1.1.3.1/tools.reader-1.1.3.1.jar!/clojure/tools/reader/edn.clj"]
#2021-04-2117:15thhellerthats the wrong version? https://clojars.org/thheller/shadow-cljs#2021-04-2117:15thhellerorg.clojure/tools.reader 1.3.3#2021-04-2117:16thhellerwhere did you get the impression that shadow-cljs uses 1.1.3.1?#2021-04-2117:18lilactownlein deps :tree shows the following output:
[thheller/shadow-cljs "2.12.5" :exclusions [[fipp] [edn-query-language/eql] [com.wsscode/pathom]]]
   [cider/piggieback "0.5.0" :exclusions [[org.clojure/clojure] [org.clojure/clojurescript] [nrepl]]]
     [javax.xml.bind/jaxb-api "2.3.1"]
       [javax.activation/javax.activation-api "1.2.0"]
   [com.bhauman/cljs-test-display "0.1.1"]
   [com.google.javascript/closure-compiler-unshaded "v20210302"]
   [expound "0.8.5"]
   [hiccup "1.0.5"]
   [org.clojure/clojure "1.10.1"]
     [org.clojure/core.specs.alpha "0.2.44"]
     [org.clojure/spec.alpha "0.2.176"]
   [org.clojure/clojurescript "1.10.844" :exclusions [[com.google.javascript/closure-compiler-unshaded] [org.clojure/google-closure-library] [org.clojure/google-closure-library-third-party]]]
   [org.clojure/core.async "0.3.465"]
     [org.clojure/tools.analyzer.jvm "0.7.2"]
       [org.clojure/core.memoize "0.5.9"]
       [org.clojure/tools.analyzer "0.6.9"]
       [org.ow2.asm/asm-all "4.2"]
   [org.clojure/data.json "1.0.0"]
   [org.clojure/google-closure-library-third-party "0.0-20201211-3e6c510d"]
   [org.clojure/google-closure-library "0.0-20201211-3e6c510d"]
   [org.clojure/tools.cli "1.0.194"]
   [org.clojure/tools.reader "1.1.3.1"]
#2021-04-2117:18lilactownI would expect tools.reader to appear elsewhere in the tree as well if something else depended on it?#2021-04-2117:19thhellerodd#2021-04-2117:19thhellerdo you have it in managed-dependencies or so?#2021-04-2117:20thhellercore.async is also the very wrong version?#2021-04-2117:20lilactown😐 yes#2021-04-2117:21lilactownI'm in a monorepo that uses lein-monolith, and both tools.reader and core.async are in managed-dependencies in the root project.clj facepalm#2021-04-2117:21lilactownI didn't even know about managed-dependencies#2021-04-2117:22lilactownthanks for the help#2021-04-2118:31papachanI am trying to compile a serverless project with shadows-cljs which it was working until i add mongodb library from node. it seems the compilation process skip some dependency requiered by mongodb import. Someone have fall down into this before?#2021-04-2118:32thhellernot enough info to comment. what is the actual problem?#2021-04-2118:36papachanWhen i bundle the serverless app, look like mongodb library require some extra dependency to be inmported correctly i added theses manually to the package.json but when i run the project the bundle js dont found thoses#2021-04-2118:37papachani have this when i compile:
:js-options {
:js-provider :shadow
:keep-native-requires true
}
#2021-04-2118:37thhellerit would help if you tell me the actual error ...#2021-04-2118:38thhellermongodb might have native code dependencies#2021-04-2118:38thheller:js-provider :shadow is NOT recommend for node builds#2021-04-2118:39thhellergenerally https://github.com/vercel/ncc is safer, maybe that works for you#2021-04-2118:42papachan@thheller i just had to create again the stacktrace: 'Module not provided: mongodb-extjson'#2021-04-2118:45thhellerok, that might be dynamically required (which shadow-cljs doens't detect or bundle) or it might be a native dependency#2021-04-2118:57papachanprobably i can build the js bundle and look where it required or call it#2021-04-2122:03papachan@thheller is there any other idea, maybe downgrade mongodb?#2021-04-2122:06papachaninstead of :shadow maybe :external ?#2021-04-2122:07thhelleruse the default :js-provider :require and use ncc I linked#2021-04-2122:08thhellerexternal only applies for browser builds not node stuff#2021-04-2122:30papachanOK i am trying with ncc but should i provide a js file with the specific requires?#2021-04-2123:09papachanOK i get the index file#2021-04-2123:09papachanBut how i can use it with require? i add it to my bundle dir?#2021-04-2123:22papachanseems to work#2021-04-2123:55nivekuilcan shadow hot-reload css files that are @imported from the top-level css file, which is the only one explicitly included in the html?#2021-04-2206:21thhellerno, it can't see those#2021-04-2203:29mbertheauWhat's the correct workflow when adding a dependency to shadow-cljs.edn? When I run just shadow-cljs , it updates package.json and yarn.lock by calling yarn, and then it tells me "specify which action to run". I get what I want because package.json and yarn.lock are updated, but I think I may have not used the intended workflow. :target is :react-native if that's relevant#2021-04-2203:31mbertheauAlso, I call shadow-cljs with npx, and I don't install npm packages globally, in particular yarn isn't installed globally. Consequently when shadow-cljs calls yarn, it complains IOException: Cannot run program "yarn" (in directory "."): error=2, No such file or directory. I work around that by calling shadow-cljs through yarn through npx: npx yarn shadow-cljs. Is that the intended way? Update: I guess the correct answer to this is don't mix npm/npx and yarn like this. Use npm and package-lock.json and npx, or use yarn by installing it globally and use yarn.lock.#2021-04-2206:23thhelleryeah don't mix. shadow-cljs wants to infer which tool you are using look looking for the lock files. so if there is a yarn.lock it'll attempt to use yarn.#2021-04-2205:20Vincent CantinUsing shadow-cljs v2.12.5, I run into a very weird bug where functions in a long namespace (5 namespace segments) are resolved at runtime to nil . Did it happen to anyone before?#2021-04-2206:24thhellernot enough information to comment. it is rather unlikely that the number of namespace segments is the cause here. much more likely to be related to something else.#2021-04-2206:58Vincent CantinI will try to reproduce on a smaller project after work. I am using shorter namespaces (4 namespace segments) as a workaround.#2021-04-2207:11thhellerFWIW pretty much all my projects have 5 or more segments. even the shadow-cljs UI has 5 https://github.com/thheller/shadow-cljs/blob/bbbac5ede9b0cefb48224050a06c673203431685/src/main/shadow/cljs/ui/components/inspect.cljs#L1#2021-04-2207:11thhellernever had an issue#2021-04-2212:52Vincent CantinOk. I guess the bug appears as a side effect of something else. I will still investigate.#2021-04-2311:31Vincent Cantin@thheller I could reproduce 2 of the bugs we encountered with the latest version of shadow-cljs https://github.com/thheller/shadow-cljs/issues/874#2021-04-2206:34mbertheauWhen I add reagent as a cljs dependency to shadow-cljs.edn and run shadow-cljs, it calls npm to add react and react-dom as deps to package.json. What's the mechanism here that triggers this? Looking at the reagent source code, there's deps in package.json to react and react-dom, but there's also prop-types and cljs-oss/module-deps there, which shadow-cljs doesn't add to package.json. What happens here?#2021-04-2207:08thhellerreagent declares its npm dependencies via deps.cljs https://github.com/reagent-project/reagent/blob/master/src/deps.cljs#2021-04-2207:08thhellershadow-cljs will attempt to install those unless they are already in package.json#2021-04-2207:13thhelleryou can set :npm-deps {:install false} in your shadow-cljs.edn to disable to automatic install#2021-04-2213:18oliverCan closure defines be used within macros? I want to configure a build against various configuration files by specifying their path as a closure-define. I want a macro read the specified file at compile time and bind its contents to a var. Here's the macro I use:
(defmacro def-from-file [var path-to-file f]
  `(def ~var
     (~f ~(read-string (slurp path-to-file)))))  
I've been unable to call the macro with file being the value bound to a closure define. With the shadow-cljs guide stating that closure defines “are essentially compile time constants” I thought there must be a way to eval them inside macros… is that actually possible? If not, are there other ways to do what I'm looking for here?
#2021-04-2213:35thhelleryou can look at the compiler environment to get the value#2021-04-2218:24oliverMany thanks… that library look great, but for now I'll keep it simple and just access cljs.env/*compiler*directly. Thanks for pointing me at it!#2021-04-2218:35thhellerthats what I meant. just wanted to show an example of a library doing that.#2021-04-2213:35thhellersomething like this https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.clj#L8-L12#2021-04-2214:39haywoodHey friends, wanted to ask if I’m thinking about this correctly: I have a clojure codebase and I want to add a couple `.cljc` namespaces to it and create a jar that only includes those namespaces using a separate profile for consumption as a library in a clojurescript project. Is that necessary or should I just create a single jar for the whole thing?#2021-04-2214:40thhellerimho just create a jar with everything#2021-04-2214:40haywood:thumbsup::skin-tone-2:, does it need to be an uberjar? I don’t know how dependencies all resolve#2021-04-2214:41thhellerno uberjar, just your sources#2021-04-2214:43thhellermight make sense to make a separate library that both use, your clj code won't be used by cljs project I assume#2021-04-2214:51ghaskinsI have this snippet
(defn copy-to-clipboard [val]
  (let [c (.-clipboard js/navigator)]
    (-> (.writeText c val)
        (.then (fn [] (debug "copied to clipboard")))
        (.catch (fn [e] (error "clipboard error:" e))))))
#2021-04-2214:51ghaskinswhich works fine in dev build, and fails in release build#2021-04-2214:51ghaskinsi suspect I need to properly require the navigator stuff, but im not quite sure of the mechanics#2021-04-2214:51ghaskinsany suggestions?#2021-04-2214:52ghaskinsrelease build throws
Uncaught TypeError: navigator.clipboard is undefined
#2021-04-2214:53ghaskinsor maybe I need a ^js hint?#2021-04-2214:55ghaskinsin reference to: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard#2021-04-2215:00thheller^js hint you only need if things are getting renamed but it doesn't seem to be renamed#2021-04-2215:00ghaskinsyeah, its like js/navigator isnt available in release build#2021-04-2215:01thhellerit should be. hard to say without seeing code.#2021-04-2215:06ghaskinshmm, generated code looks ok, I think#2021-04-2215:06ghaskins
function eNa(a){return navigator.clipboard.writeText(a).then(...
#2021-04-2215:08thhelleryes but in which context does it execute#2021-04-2215:09thhellerpretty sure you are only allowed to access that after asking permissions first? did you do that?#2021-04-2215:16ghaskinsyeah, that is a distinct possibility…i havent got that far yet, but i would have expected an exception over permissions, not a seemingly symbol undefined error#2021-04-2215:16ghaskinsill keep plugging#2021-04-2215:17thhellerjust for sanity try logging js/navigator and see what that is. maybe it is redeclared somewhere locally or so#2021-04-2215:17ghaskinsgood idea, ill try that#2021-04-2215:31ghaskinsThe navigator object is there, but it doesnt have the clipboard property, giving legs to your theory on permissions#2021-04-2215:31ghaskinsill follow that rabbit hole, ty#2021-04-2215:49ghaskinsah, i think I figured it out, completely uninteresting#2021-04-2215:49ghaskinsits only supported from secure-contexts with https, heh#2021-04-2215:49ghaskinsforest for the trees#2021-04-2215:49ghaskinsty for the help, though#2021-04-2217:17aptHey folks. I’m trying to connect to socket repl in a shadow project. My project is based on this template, I didn’t change too much stuff: https://github.com/day8/re-frame-template I’m doing the following: 1. lein watch 2. In Emacs, I use inf-clojure-connect with localhost and the port in .shadow-cljs/socket-repl.port. The repl opens fine. 3. Then, when I try to eval any require, I get errors such as:
Could not locate timeline/test_utils__init.class, timeline/test_utils.clj or timeline/test_utils.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
I’ve tried to have a look at shadow’s manual but I’m not too familiar with cljs and front-end. Am I missing something?
#2021-04-2217:19dpsuttonwhen that repl opens up, type (help). I think there's a small banner indicating this. You get a clojure repl and you can start your repl with (shadow/repl :your-build)
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=> 
#2021-04-2217:21thhelleror (shadow/browser-repl) or (shadow/node-repl) if you don't have a build configured yet and just want a REPL#2021-04-2217:34aptOoops, I missed (help) . Thanks 🙇#2021-04-2217:38aptA more general issue: There’s one test that passes in the repl, but it fails with karma . What would be a good approach of debugging that? :thinking_face: I guess I can bisect and run karma, just wondering if there’s a more efficient way#2021-04-2218:20aptWell, yeah, already found the issue (bisecting)#2021-04-2311:31Vincent Cantin@thheller I could reproduce 2 of the bugs we encountered with the latest version of shadow-cljs https://github.com/thheller/shadow-cljs/issues/874#2021-04-2303:20mbertheauIn https://github.com/thheller/reagent-react-native how do the two package.json and react-native/package.json relate? Which dependencies go where?#2021-04-2306:56thheller@mbertheau in that repo I specifically wanted to have all code generated and used by the react-native tooling in its own directory. so everything react-native related you do in the react-native directory. that includes installing react-native dependencies. CLJS tooling related things you'd put into the main package.json directly#2021-04-2306:57thhelleryou don't have to do that separation, could just as well combine it all but for me this is cleaner and maybe easier to show what parts of CLJS related and what is metro/react-native. should also in theory make it easier to support multiple react-native versions or just upgrading since all you need to change the :output-dir in the build config#2021-04-2308:10zimabluesorry I have a really basic question - in a clojurescriptdevelopment workflow where one in-development project depends on another in-development project, both clojurescript, how does one use a direct folder link to avoid having to republish everything through git all the time? I saw in the user guide it mentions source-paths, but setting this to "../my-other-prj/src" didn't seem to do anything#2021-04-2308:12thhellerdid you restart shadow-cljs after changing that?#2021-04-2308:22zimabluethink I saw the problem, I see a warning in the shadow-cljs server process that it's being ignored because of deps.edn#2021-04-2308:23zimabluesorry, I feel like your project must be subject to an incredible number of subtle third party bugs, and users trying to use clj/cljs/js/java who aren't great with any or all of their respective sets of build tools#2021-04-2308:23zimablueor maybe it's just me#2021-04-2308:27thhellernah its a common mistake. thats why I added the warning 😉#2021-04-2308:36zimablueif you get chance, that section of the docs could note it too#2021-04-2308:36zimabluemake it easy for my chimp section of the developer community#2021-04-2314:47niwinzhello folks! After upgrading to 2.12.5 I start randomly getting the following error (image), Is usually happens after a modify -> hot-reload -> browser refresh -> error. But on next reload it not happens.#2021-04-2314:49niwinzThe error is raised on loading a module, bacause of a error on loading other module, reading the browserfeaure.js , looks like the const googUserAgent = goog.require('goog.userAgent'); returns nil :S#2021-04-2314:51niwinzI don't know if is shadow-cljs related or clojurescript related#2021-04-2314:52niwinzonly reproducible on development builds#2021-04-2314:57thhellermake sure oyu have all the proper versions. 2.12.x will only work with CLJS 1.10.844+ and the matching closure-compiler/library versions#2021-04-2315:02niwinzI'm not using deps.edn, I use the shadow-cljs dependencies without specifying the clojurescript version...#2021-04-2315:10thhellerhmm should be ok then. hard to say without seeing actual code#2021-04-2315:12niwinzThe code is open-source, the bad part, is a pretty big project (https://github.com/penpot/penpot) I probably need to isolate it in a small project or similar#2021-04-2315:13thhellerhttps://github.com/penpot/penpot/blob/develop/frontend/shadow-cljs.edn#L1 ?#2021-04-2315:13niwinzi'm on a branch#2021-04-2315:14thhellerlooks ok in deps.edn anyways#2021-04-2315:14niwinzhttps://github.com/penpot/penpot/blob/niwinz/fonts-management/frontend/shadow-cljs.edn#2021-04-2315:14thhelleris this easily reproducible? I mean can I just run this locally or does it need special setup?#2021-04-2315:15niwinzhmm let me check#2021-04-2315:15niwinzif you run it locally, you will probably need to add the dev-http serve for serve that files#2021-04-2315:16niwinzlet me prepare this and i give you instructions#2021-04-2315:26niwinz😞 unfortunatelly I'm unable to reporduce the issue on the login page (the unique page you can view without all the environment) If I found a way to "more" deterministically reproduce it" I'll ping you, but for now it happens randomly, that makes it pretty hard to find the cause#2021-04-2315:32thhelleryeah the goog.events.browserfeature stuff is used pretty commonly (eg. in all my projects) and never had an issue with it#2021-04-2315:32thhellerso dunno what it might be#2021-04-2315:35niwinzI have tried to serve the files through the shadow-cljs server (using proxy pass to it instead of serving the directory with nginx) and now I unable to reproduce it :S#2021-04-2315:37niwinzon the end looks something unrelated to shadow-cljs, sorry for inconvenience, but I did not expeted that... specially when it start happens after upgrade :S#2021-04-2315:41thhelleryeah dunno. with custom servers you have to check cache issues but they usually manifest differently so no clue#2021-04-2314:58iGELHello! I was wondering, whether it's possible to exclude dependencies from npm packages? It's described here for webpack for the package i'm using: https://github.com/seiyria/bootstrap-slider/tree/v9.10.0#how-do-i-exclude-the-optional-jquery-dependency-from-my-build#2021-04-2315:00thheller:js-options {:resolve {"jquery" false}}#2021-04-2315:03iGELthank you!#2021-04-2323:04ribeloHave I broken something? Unfortunately I can't find any information either on https://shadow-cljs.github.io/docs/UsersGuide.html or on google#2021-04-2402:13dvingocan you post your shadow-cljs.edn config for this build? you likely have to set :output-dir and asset-path to different values than they are now. For example:
:builds 
{:my-build {:output-dir  "dev/public/js" :asset-path "/js" :modules {...}
  :devtools   {:http-port          8021
                                  :http-resource-root "public"
                                  :http-root          "dev/public/"}}
#2021-04-2407:32thheller@huxley you cannot open the html file directly from disk. it needs to be served via http (eg. via :dev-http)#2021-04-2407:33ribelothx#2021-04-2421:10yiorgoswhat opts do I need to pass in this line? :main-opts ["-m" "shadow.cljs.devtools.cli" ] I fount that line here https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2021-04-2421:10yiorgoscan I hardcode the watch app in the deps.edn?#2021-04-2421:10thhellersure, just add "watch" "app"#2021-04-2421:10yiorgossomething like :main-opts ["-m" "shadow.cljs.devtools.cli" "watch app"]#2021-04-2421:11yiorgosah, let me try#2021-04-2423:02Janne SauvalaHello 👋:skin-tone-2: If I have understood correctly shadow-cljs produces some JS code that will open a websocket server (in the client) and adds that to the rest of the JS code generated from CLJS. That websocket server will then accept new code updates (like user’s REPL evals) from the shadow-cljs process (that does the compilation of the CLJS code to JS). Would it be possible to open manually the websocket server inside the library I have created (I guess I can just require shadow-cljs NPM package and use that?) and make it accept JS code coming from the shadow-cljs build process?#2021-04-2423:02Janne SauvalaI’m interested trying out to keep the REPL-feeling when I have done a release build. The release build will strip away this websocket-server since it is made to be used only for dev time.#2021-04-2501:52lilactownthe release build won't allow you to interact with any of the built code, even with a REPL, because it's all been minified#2021-04-2507:42thhellerwell most importantly shadow-cljs is written in Clojure not ClojureScript. so you cannot embed it into a JS process.#2021-04-2507:42thhellerbut also that part of shadow-cljs is not written as a library and cannot be used like that. it is meant as a standalonee process to do what shadow-cljs does not some other user-related things#2021-04-2509:10Janne SauvalaThanks for the answers. I’ll go back to the hammock to think about this 🙂#2021-04-2519:27dvingoDoes running a build-report always operate against a release build? I would assume so, but I'm debugging a release build having namespaces I do not expect to be there so I'm asking. Related to this, if I have dev build watches running will that impact the build-report? (should I stop any builds before running the release or perform any cleaning by removing output directories?)#2021-04-2519:36thhellerbuild report runs separately and always in release mode. watch does not affect it#2021-04-2519:39dvingoperfect, thanks#2021-04-2615:10fsdHello There, I have a quick question, I am new in clojure How do I use png file in cljs? I have a shadow cljs application for example "./icons/marker.png I’ve tried using this but it’s not loading#2021-04-2615:14AzzuriteThis has nothing to do with shadow-cljs, try #beginners or #clojurescript But generally, you need to start a webserver and serve that file on the webserver you started shadow-cljs has https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, but you don't want to use that for your final app...#2021-04-2615:13thhellerhow are you embedding it? this is not a CLJS question really, more HTML specific. if you use ./ in the path it'll be relative to the page you are on. you need to make sure the path is correct.#2021-04-2618:18sova-soars-the-soraHi, how can I name the file something other than main.js?#2021-04-2618:19Aronthis caught me too, the key in the map decides#2021-04-2618:20sova-soars-the-soraAha#2021-04-2618:21sova-soars-the-sorathank you @ashnur#2021-04-2620:31Michaël SalihiHi there. Is it possible to invalidate the node_modules cache without restarting npx shadow-cljs watch app ? Any option?#2021-04-2620:32thhellerinvalidate why? I mean what do you expect that to achieve?#2021-04-2620:35Michaël SalihiI put some console.log on npm package for debugging.#2021-04-2620:35thhelleryou can touch node_modules/that-package/package.json to trigger a recompile#2021-04-2620:36Michaël SalihiI don't have any output, so I supposed that's because Shadow cache.#2021-04-2620:36Michaël SalihiOh perfect, thx!#2021-04-2620:37thhelleryeah I removed individual file watching for node_modules files because some projects used like 5000 files from there and that was causing some performance issues#2021-04-2620:37thhellerbut it still watches package.json files in cause you npm install stuff or so#2021-04-2620:37thhellertouching the package.json will invalidate the entire package#2021-04-2620:40Michaël SalihiYeah I understand, very good reason performance wise. Thanks Thomas.#2021-04-2620:46pezIs there a reason I should defonce my app-db in a re-frame project from a hot-reload perspective?#2021-04-2620:49thhelleryes, without it the hot-reload will just replace it with a new atom when you modify the file#2021-04-2620:50thhellerdefonce is needed if you want to keep your state#2021-04-2620:51pezThe state seems to be kept in the re-frame.db/app-db ratom. I notice no difference when I use def on my app-db. hot reload seems to work the same.#2021-04-2620:52thhellerthen I don't understand your question. when using re-frame you don't have your own app-db?#2021-04-2620:57pezI am asking because I am going to present ClojureScript app development on a meetup Wednesday. And I had sort of planned to mention defonce as a protector of the app-db, but when I tested it I noticed that that part of the demo doesn’t seem to hold. Looking in re-frame.db then, it’s app-db is also just (def app-db (ratom {})) . I just want to understand a bit better how it really works. Even if I realize I should stay away from the subject during the demo. 😃#2021-04-2620:58thhellerwell you don't modify the re-frame.db namespace so it is never reloaded and never has this issue#2021-04-2620:58pezAh. Thanks!#2021-04-2620:58thhellerif you have this is your main namespaces that is constantly getting reloaded you will lose your state every time without defonce 😉#2021-04-2621:00pezYeah, I can totally get it to happen with a local atom and such. Which added to my confusion.#2021-04-2703:29zhuxun2Where is the best place to set NODE_ENV? Do I just put a line of (set! js/NODE_ENV (if goog.DEBUG "development" "production") in my entry point? Is there a way to say this in the shadow-cljs.edn?#2021-04-2706:57thhellerits an env variable so you NEVER set it in your code#2021-04-2705:35andrehi, can we make this work somehow with shadow https://www.npmjs.com/package/babel-plugin-assign-directive ?#2021-04-2705:36Aronseems like there is a NOTE saying no 🙂#2021-04-2705:37andreyes , thats why im here 🙂#2021-04-2705:37Aronwhy the link is 404 from the package site?#2021-04-2705:38Aroncan't even read the source#2021-04-2705:38andreidk its outdated, its possible to add directive with a macro , im more interesting in how we can use babel plugin for generated js code with shadow#2021-04-2705:39andreor probably it could be not a bubel plugin, i mean we need access to js code to be able to change it in runtime#2021-04-2705:42AronI am not sure I fully understand. If I generate my js code with shadow-cljs, why would I take the output of that and try using another approach to modify it? Why not just modify at the beginning#2021-04-2705:43AronI know lots of tooling on how to modify js code from js, but that is in js land entirely#2021-04-2705:44andrewe need to get this user.i_use_worklet*=*function(){var _f*=*function _f(){*return* console.log("Hey I'm running on the UI thread");};_f._closure*=*{console*:*console};_f.asString*=*"function(){const{console}=this._closure;{return console.log(\"Hey I'm running on the UI thread\");}}";global.__reanimatedWorkletInit(_f);*return* _f;}(); from this user.i_use_worklet*=*function(){"worklet";*return* console.log("Hey I'm running on the UI thread");};#2021-04-2706:22andrehm actually, probably we need this only in the release build#2021-04-2706:53AronI know I would write something custom with this https://www.npmjs.com/package/falafelhttps://www.npmjs.com/package/falafel 😄#2021-04-2706:57thheller@andre I don't know how this works at all but maybe you want to write the worklet code directly in JS and just use it from CLJS? or do you really need to write those in CLJS?#2021-04-2706:58andreso my idea is to run re-frame event handlers in a separate thread, so yeah it should be cljs code#2021-04-2707:00andrebut for my idea i don't need it in develop, only in production for performance reasons#2021-04-2707:00thhellerthe main issue is that :advanced will likely remove the "worklet;" thing#2021-04-2707:01andreyeah, i also thought about this#2021-04-2707:01thhellerit'll also agressively inline functions and so on so the code is never what you wrote after :advanced#2021-04-2707:01andreyeah thats true#2021-04-2707:01thhelleralso I don't have a clue how worklets actually work but I'd assume it would require a lot of serialization#2021-04-2707:02thhellerif it all runs in a separate thread and you can't share memory in JS#2021-04-2707:02thhellerso running re-frame event handlers seems like an absolute no go for me? too much overhead serializing the app-db back and forth?#2021-04-2707:05thheller> When you pass arguments, they will be copied to the UI JS context.#2021-04-2707:05andreseems like that 😞#2021-04-2707:08thhellerhttps://www.npmjs.com/package/babel-plugin-assign-directive the github repo for this doesn't exist anymore so I think this never actually worked? can't see how this would work with any other CLJS tool either as :advanced or even :simple would be the major hurdle here#2021-04-2707:08thhellerso the only way I see this working is with actual JS functions just called from CLJS but not passing through CLJS tooling, just metro#2021-04-2707:13andreyeah, thanks#2021-04-2707:23thhellera custom worklet-fn special form could be created to create the code you need but yeah its applications are very limited and I don't expect this to ever work for functions using CLJS datastructures anywhere. basic JS types maybe work though.#2021-04-2710:08borkdude#2021-04-2710:09borkdudehow should those warnings be fixed for shadow?#2021-04-2710:11borkdudeNote that the code does work, also under advanced#2021-04-2710:26borkdude#2021-04-2711:36thheller@borkdude first of all this has nothing to do with shadow-cljs, you'd get those warning for regular CLJS as well if you were to enable them. so the only difference is that shadow-cljs defaults to having them enabled automatically vs. manually. You can either use (set! *warn-on-infer* false) somewhere above those forms if you know they are safe and can be renamed (which they likely can)#2021-04-2711:38borkdude@thheller Adding an extra local type hint solved the warnings. I don't understand why because that type hint was already on the return tag of the function. But thanks. It was reported by a shadow-cljs users, I have never seen this warning before.#2021-04-2711:38thhellerunsure why the return type hint is missing though. that should be ok#2021-04-2711:39borkdudeI will check out warn-on-infer, it sounds useful#2021-04-2711:43thhelleryeah if you set that to true you should get the warnings with the regular cljs compiler too#2021-04-2711:43thhellerbasically shadow-cljs just sets that to true by default for local files (ie. files not in .jar)#2021-04-2711:45thhellerI do remember some weird issue with return type hints but not sure. I think in some places it was a little inconsistent and (defn ^Return foo [] ...) worked but (defn foo ^Return [] ...) didn't#2021-04-2711:46thhelleror the other way. you really don't see them used all that often :P#2021-04-2714:58iGELHello. I have another question, probably quite stupid again, but I'm banging my head against this for a few hours. I'm trying to adapt this example: https://github.com/reactchartjs/react-chartjs-2/blob/master/example/src/charts/Line.js
(ns my-app.views
  (:require ["react-chartjs-2" :refer [Line]]))

(defn chart []
  [:> Line
      {:data {:labels ["1" "2" "3" "4" "5" "6"]
              :datasets [{:label "# of Votes"
                          :data [12 19 3 5 2 3]
                          :fill false
                          :backgroundColor "rgb(255, 99, 132)"
                          :borderColor "rgba(255, 99, 132, 0.2)"}]}
       :options {:scales {:yAxes [{:ticks {:beginAtZero true}}]}}}])
But I get this error:
error when calling lifecycle function my-app.core/mount-root Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `my-app.views.chart`.
Line seems to be undefined and I don't know why. Both "chart.js": "^3.1.1" and "react-chartjs-2": "^3.0.2" are in my package.json. I'm quite sure it was working yesterday, but don't know what I've changed
#2021-04-2714:59AronSo what is Line?#2021-04-2715:00Aronoh, i can't read, sorry, you said it's undefined#2021-04-2715:00iGELIt should be a react component, provided by react-chartjs-2#2021-04-2715:00iGELhehe#2021-04-2715:01Aroncan you check how that component exports? sometimes people do weird things#2021-04-2715:01Aronalthough if it was working and you didn't update anything then it's probably not that#2021-04-2715:14iGELI've added nouislider-react to the project, but I just removed it and it's still not working. What should I look for in the exports? I'm not too familiar with JS modules and exports, but I found this in node_modules/react-chartjs-2/dist/index.js:
var Line = React.forwardRef(function (props, ref) {
  return React__default.createElement(ChartComponent, Object.assign({}, props, {
    type: 'line',
    ref: ref,
    options: props.options || {}
  }));
});
#2021-04-2715:20Aronthere should be either export or module exports#2021-04-2715:20Aronbut I don't think that's the issue if it was working, more likely a typo or similar issue#2021-04-2715:29iGELI guess it was a caching issue. I deleted everything and restored it from git and restarted shadow-cljs. Now it's working. Thank you anyway!#2021-04-2715:29iGELI thought I tried that before, but this time I removed not just the node modules, but everything#2021-04-2715:35Aronglad it's working 🙂#2021-04-2805:02mbertheauIs there a quicker way to get a react-native app to try to reconnect to the shadow-cljs server after it lost that connection (for example wifi reconnect) than re-starting the app with react-native run-android ?#2021-04-2806:28henryw374hi. is there a way to depend on a cljs library which depends on npm libs, but tell shadow to not include the npm source in the build? or to put it another way, put :exclusions on npm-deps ? I see the bit about cdn and resolve-global here: https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global which would be handy if I could do the exclusions#2021-04-2806:35thheller@henryw374 :js-options {:resolve {"npm-dep" false}} will "ignore" the dependency but fail if you actually attempt to use it in the code#2021-04-2806:37thheller:npm-deps {:install false} in the shadow-cljs.edn root will not attempt to install npm-deps from deps.cljs at all, there are no specific exclusions otherwise#2021-04-2807:42henryw374Awesome! thanks @thheller#2021-04-2817:36AronI have a weird error that does this https://imgur.com/a/AuzL5iy and I am not sure how I could go about finding out where it is coming from.
#2021-04-2817:36AronIt's in development#2021-04-2817:50thheller@ashnur looks like trying to print a self-referential structure of some kind. an atom that contains itself or so#2021-04-2817:52Aroncan I assume it has to be a prn? I don't use anything else that prints in my own code#2021-04-2817:53thhellercould also be a str call, but more likely prn or pr-str yes#2021-04-2817:54AronI have much much more str than prn 🙂 Thanks, I should be able to find it#2021-04-2819:43AronProbably not prn, because I have them all commented out. It's particularly bad because I can't consistently reproduce it, it always appears when I least expect it. I am writing here because when it happens, the first sign is that shadow-cljs notification appears saying "reconnecting".#2021-04-2819:45thhellerI don't have the slightest clue what you are actually doing so I can't really comment. only you know how your data is structured and where it is sent. might not be your code, might be some library you use that tries to send data as EDN#2021-04-2819:46Aronfair, I didn't expect miracles, only if you or others saw something similar then I might've been lucky : )#2021-04-2819:47AronI am betting on some react issue#2021-04-2819:48thheller(def x (atom {:x nil})) -> (swap! x assoc :x x) ->
The result object failed to print. It is available via *1 if you want to interact with it.
The exception was:
RangeError: Maximum call stack size exceeded
:repl/print-error!
#2021-04-2819:49thhellerfairly simple to replicate the issue from the REPL, just gotta find it. might just be a missing deref somewhere#2021-04-2819:50AronI don't have any atoms :-S#2021-04-2820:10thhellerdoesn't have to be an atom, just an example. ANY structure that can reference itself will have this issue#2021-04-2820:11thheller
(def x #js {:x nil})
#'cljs.user/x
cljs.user=> x
#js {:x nil}
cljs.user=> (set! (.-x x) x)
The result object failed to print. It is available via *1 if you want to interact with it.
The exception was:
RangeError: Maximum call stack size exceeded
:repl/print-error!
#2021-04-2820:52AronThanks for the elaboration on that, I am familiar with the js version of this (e.g. when json fails for circular references), with this knowledge I will be able to find it for sure.#2021-04-2909:18Fredrik AnderssonI am trying to understand how I could use nrepl in a node-script target. Any pointers to help/tutorial?#2021-04-2909:22thhellerdepends on what you mean by "nrepl in a node-script". do you mean starting your own nrepl server or using the shadow-cljs nrepl server to talk to the node-script?#2021-04-2909:28Fredrik Anderssonusing the shadow-cljs server#2021-04-2909:29Fredrik Anderssonatleast that's what I thought to do. I'm still quite new to clojure/cljs#2021-04-2909:29thhellerthen you use it like any other REPL?#2021-04-2909:30Fredrik Anderssoni want to attach it to cursive#2021-04-2909:30thhellerthen you connect to the shadow-cljs server (using the .shadow-cljs/nrepl.port file)#2021-04-2909:30thhellerand then (shadow/repl :the-build-id) to switch that connection to CLJS#2021-04-2909:31Fredrik Anderssonah ok#2021-04-2909:32Fredrik Anderssonhm it seems i have another problem in cursive too#2021-04-2909:32Fredrik Andersson#2021-04-2909:32Fredrik Anderssonmaybe i need to figure that out first#2021-04-2909:33thhellerjust select the proper module#2021-04-2909:33thhelleryou also want to remote connect, not run a local repl#2021-04-2909:34Fredrik Anderssonok#2021-04-2909:35Fredrik Anderssoni dont understand where i would chose the proper module#2021-04-2909:36Fredrik Andersson#2021-04-2909:41thhelleryou don't need that. use the "Use port from nrepl file"#2021-04-2909:41thheller#2021-04-2909:42Fredrik Anderssonfor some reason, when i do that i cant chose project#2021-04-2909:42Fredrik Anderssonis there a step i missed_#2021-04-2909:42Fredrik Andersson?#2021-04-2909:44thhellerI don't know? how did you create the project in cursive?#2021-04-2909:44Fredrik Anderssoni created it with npx i believe#2021-04-2909:45Fredrik Anderssonand just opened it in cursive#2021-04-2909:45thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2021-04-2909:45Fredrik Anderssonahh#2021-04-2909:46Fredrik Anderssonthanks!#2021-04-2914:51Fredrik Anderssonokay, now I finally found time to test this @thheller and it works. however when i try to switch workspace in i get "No avvailable JS runtime"#2021-04-2914:51Fredrik Anderssonso I guess i'm missing something?#2021-04-2914:54thhelleryeah, you need to run your node-script output#2021-04-2914:54Fredrik Anderssonok so ill do that manually_#2021-04-2914:54Fredrik Andersson?#2021-04-2914:54thhellerdon't know what you are building but probably yes 😉#2021-04-2914:55thhellerif you just want a node repl use (shadow/node-repl) instead#2021-04-2914:55thheller(from the initially connected Cursive REPL)#2021-04-2914:56Fredrik Anderssoni would like to have the same concept that we have in the browser where i can reload code but keeping state#2021-04-2914:56Fredrik Anderssonis that possible?#2021-04-2915:01thhellersure, but only via node-script and running the thing manually#2021-04-2915:01thhellernode-repl doesn't do hot-reload#2021-04-2915:02Fredrik Anderssoni have setup node-script and it's building#2021-04-2915:02Fredrik Anderssonbut it doesnt run the code#2021-04-2915:02thhellerwhat do you mean by that? you are supposed to run it?#2021-04-2915:03thheller:node-script gives you the file in :output-to#2021-04-2915:03Fredrik Anderssonyes#2021-04-2915:03thhelleryou then run node whatever.js#2021-04-2915:03thhellerwhat this process does is completely under your control depending on what you do in main?#2021-04-2915:03thhellerwhat are you trying to build?#2021-04-2915:04Fredrik Anderssona service that is monitoring crypto exchanges#2021-04-2915:04Fredrik Anderssonbasically a script#2021-04-2915:04thhellerok something that is long running?#2021-04-2915:05thhelleror just a script that runs once for a second or whatever and then exits?#2021-04-2915:05Fredrik Anderssonyes#2021-04-2915:05Fredrik Anderssonlong running#2021-04-2915:05thhellerok fine. then when you run that you can REPL into it#2021-04-2915:05thhellerit should log a message on startup "shadow-cljs ready" or so#2021-04-2915:05Fredrik Anderssonyep that works#2021-04-2915:05Fredrik Anderssonand hot reload?#2021-04-2915:05Fredrik Anderssonjust rebuilding?#2021-04-2915:06Fredrik Anderssonwhile keeping the process alive#2021-04-2915:06thhellersame way as the browser targets https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload#2021-04-2915:06thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2021-04-2915:06thhellerno difference, same setup (just see the main fn as the init fn described in the post above)#2021-04-2915:06Fredrik Anderssonokay thanks!#2021-04-2915:06Fredrik Anderssonill read through it#2021-04-2915:17Fredrik Anderssonthanks for your patience, it works like i want it to now#2021-04-2919:57grounded_sageI keep getting Stale Output! on this Chrome Extension I am working on. Even when I clear all the js , out, manifest.json, .shadow-cljs, node_modules etc#2021-04-2919:57grounded_sageI'm wondering if there is some weird Chrome caching bug happening here.#2021-04-2919:58grounded_sageHard restart of the computer seems to fix it when this happens.#2021-04-2919:58grounded_sageHas happened to me several times over the course of a few days now.#2021-04-2919:59thhellerif you restart the build for any reason you need to reload the extension in chrome#2021-04-2920:14grounded_sagehmm I am pretty sure I do this. Like hitting refresh everywhere.#2021-04-2920:15thhellerin <chrome://extensions/> hit the reload thingy#2021-04-2920:15grounded_sageI even removed the unpacked extension and loaded it again. Maybe I'm missing something. Will go slower next time and write down all the steps I take to see if I do something silly.#2021-04-3018:38mssgetting a hard-to-parse error on shadow 2.12.5 when trying to compile an app with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dba9bebab8aff6abbfbd9beef5e9f5eb"}, :content ("[email protected]")} as a dependency:
[2021-04-30 13:37:26.247 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoClassDefFoundError Could not initialize class cljs.repl__init
	java.lang.Class.forName0 (Class.java:-2)
	java.lang.Class.forName (Class.java:468)
	clojure.lang.RT.classForName (RT.java:2211)
	clojure.lang.RT.classForName (RT.java:2220)
	clojure.lang.RT.loadClassForName (RT.java:2239)
	clojure.lang.RT.load (RT.java:449)
	clojure.lang.RT.load (RT.java:424)
	clojure.core/load/fn--6839 (core.clj:6126)
	clojure.core/load (core.clj:6125)
	clojure.core/load (core.clj:6109)
	clojure.core/load-one (core.clj:5908)
	clojure.core/load-one (core.clj:5903)
#2021-04-3018:38mssthere are also a number of warnings around using string continuations generated by compiling that dep:
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/pdfjs-dist/build/pdf.js:9211:32
 String continuations are not recommended. See 
--------------------------------------------------------------------------------
------ WARNING #2 -  -----------------------------------------------------------
 Resource: node_modules/pdfjs-dist/build/pdf.js:9225:34
 String continuations are not recommended. See 
--------------------------------------------------------------------------------
------ WARNING #3 -  -----------------------------------------------------------
 Resource: node_modules/pdfjs-dist/build/pdf.js:9327:34
 String continuations are not recommended. See 
--------------------------------------------------------------------------------
------ WARNING #4 -  -----------------------------------------------------------
 Resource: node_modules/pdfjs-dist/build/pdf.js:9344:36
 String continuations are not recommended. See 
--------------------------------------------------------------------------------
#2021-04-3018:39mssany idea what I might be doing wrong?#2021-04-3019:42thheller@mss I'm guessing you are using project.clj or deps.edn to manage dependencies and don't have the proper shadow-cljs+cljs versions. 2.12.x requires cljs 1.10.844#2021-04-3020:36msswas exactly the issue. really appreciate the help + all the work you’ve done on shadow – amazing piece of software#2021-05-0117:31Janne SauvalaHi, I’m trying get the CLJS bootstrap repl to work via shadow.cljs.bootstrap.node. I was checking the post here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html for some tips. When I try to eval something I get
[:result {:error #error {:message "Could not eval [test]", :data {:tag :cljs/analysis-error}, :cause #error {:message nil, :data {:clojure.error/source nil, :clojure.error/line 1, :clojure.error/column 1, :clojure.error/phase :compilation}, :cause #error {:message "Cannot read property 'findInternedVar' of null at line 1 ", :data {:file nil, :line 1, :column 1, :tag :cljs/analysis-error}, :cause #object[TypeError TypeError: Cannot read property 'findInternedVar' of null]}}}}]
Can you see if there is something wrong with my configs or code:
#2021-05-0117:31Janne Sauvalacode:
require these:
[cljs.js :as cljs]
[cljs.env :as env]
[shadow.cljs.bootstrap.node :as shadow.bootstrap]
...
(defn print-result [{:keys [error value] :as result}]
  (prn [:result result]))

(def code "(+ 1 2)")

(defonce compile-state-ref (env/default-compiler-env))

(defn compile-it []
  (cljs/eval-str
   compile-state-ref
   code
   "[test]"
   {:eval cljs/js-eval
    :load (partial shadow.bootstrap/load compile-state-ref)}
   print-result))

(shadow.bootstrap/init compile-state-ref
                       {:path "out/extension/bootstrap"}
                       compile-it)

(compile-it)
#2021-05-0117:32Janne SauvalaAnd shadow-cljs.edn build section:
:builds
{:dev {:target :node-library
       :output-to "out/extension/extension.js"
       :output-dir "out/extension"
       :exports-var prode.extension/exports
       :devtools {:repl-pprint true}
       :compiler-options {:source-map-detail-level :all
                          :output-wrapper false
                          :optimizations :simple}}

 :bootstrap {:target :bootstrap
             :output-dir "out/extension/bootstrap"
             :entries [cljs.js]
             :macros []
             :exclude #{cljs.js}
             :compiler-options {:warnings {:infer false}
                                :optimizations :simple}}}
#2021-05-0118:39thhellerYou can't do this (compile-it) until the above init has completed#2021-05-0118:39thhellerso you are just calling it too early#2021-05-0118:39thhellerinit will already call it when its done#2021-05-0118:47Janne SauvalaI moved calling that function inside a comment block and evaluated it from there. This gives me the same error message. If shadow.bootstrap/init is going to run the compile-it, where should I see the result (it’s not printed to the REPL)?#2021-05-0118:55Janne SauvalaI changed the call-back function to a new function that would print something, and now I see some errors in the node-env’s (it is actually a vscode debug instance) logs something
[2021-05-01 21:53:18.838] [renderer11] [error] transit-load failed: Error: transit-load failed
    at new cljs$core$ExceptionInfo (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11455:1)
    at Function.cljs$core$IFn$_invoke$arity$3 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
    at Function.cljs$core$IFn$_invoke$arity$2 (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/cljs/core.cljs:11484:1)
    at ReadFileContext.callback (/Users/janne/Dev/clojure/prode/out/extension/cljs-runtime/shadow/cljs/bootstrap/node.cljs:38:9)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:265:13)
    at FSReqCallback.callbackTrampoline (internal/async_hooks.js:120:14)
#2021-05-0119:08Janne SauvalaIt seems that one is coming from shadow (https://github.com/thheller/shadow-cljs/blob/6b662c0e05fb560216984746818d658fea8b2963/src/main/shadow/cljs/bootstrap/node.cljs#L38)#2021-05-0119:48thhellerwell you removed a couple things from the config#2021-05-0119:49thhellerso I'm guessing your server isn't setup correctly#2021-05-0119:49thhellerby default it expects to load stuff from /bootstrap#2021-05-0119:50thhellerbut seems like you are loading it in node?#2021-05-0119:50thhelleroh right I missed that#2021-05-0119:50thhellerI'm guessing your paths aren't quite right?#2021-05-0120:05Janne SauvalaI won’t rule that option out 😄 I have been trying with different paths but I haven’t been able to find a working setup. The dev-build output the build stuff to out/extension and the output is inside that one out/extension/bootstrap. Did you mean that bootstrap should go actually on the same level as the out folder (project root)?#2021-05-0120:07thheller:path "out/extension/bootstrap"#2021-05-0120:08thhellerhow do you run the stuff anyways? from "extension" I gather its not regular node?#2021-05-0120:09Janne SauvalaThis is something I have been experimenting. To create a VSCode extension that would execute cljs via the bootstrap repl. So the output js is loaded to vscode as an extension#2021-05-0120:09thhellerhmm yeah no clue if the bootstrap.node will work there#2021-05-0120:10Janne Sauvalait could work like a normal node env but it might have some differences. Maybe I try to get this working in normal node first. Then I can check if everything is okay on vscode side#2021-05-0120:11thhellermaybe try not setting :path at all? it defaults to this https://github.com/thheller/shadow-cljs/blob/015926609e1c070de57efa71646c46f92f08d7d9/src/main/shadow/cljs/bootstrap/node.cljs#L13#2021-05-0120:11thhellermaybe you need a similar path/resolve call#2021-05-0120:12Janne SauvalaYea, I could try that#2021-05-0120:14Janne SauvalaThat worked! I removed the :path and it is working 🙂#2021-05-0120:17Janne SauvalaSo many thanks for the help 🙂#2021-05-0119:42hadilsHi. I have an Expo app that I just ejected to bare workflow, so now it's plain React Native. I am wondering what is the best way to create an App.js in my directory. Can I automate it with shadow-cljs?#2021-05-0119:49hadilsNVM, I figured it out. I need to point shadow-cljs.edn to the. App/ build dir.#2021-05-0119:51thhellersorry I don't have a clue what an ejected app looks like#2021-05-0206:47sh54I am getting an issue that when some required in javascript file changes, the final product shadow-cljs produces does not change.#2021-05-0206:47sh54I have some fork of some javascript project that I am working on then “compiling” and copying over relevant js files into my clojure project. shadow-cljs is certainly noticing that this happens and starts compiling and hot reload triggers. However the actual change in functionality does not get picked up. If I reload the page there is still no change. But if I go to the shadow-cljs dashboard and press stop then watch then the change appears.#2021-05-0206:48sh54Not sure if this is a general issue or something very specific here. What I am actually changing is a c++ file that gets compiled to js via emscripten. For this project the wasm binary is just base64 encoded and dumped into the js file. So when I am changing something the only change in the js file is that some def var wasmBinaryFile="data:application/octet-stream;base64,ABCD"; is getting altered. Just for context.#2021-05-0207:31thheller@slack1003 hard to say without knowing how you actually include those files. why not load the actual .wasm file over the ajax or so? inlining it via base64 will make it needlessly large?#2021-05-0207:34sh54I agree that it should be compiled to its own file and loaded. I am just on a fork. It is something I have thought of changing. There is a certain simplicity in just having a single js file include though#2021-05-0207:34sh54I am requiring it in via (:require #?(:cljs ["imgui-js" :as imgui]))#2021-05-0207:36thhellerso its in node_modules/imgui-js? node_modules files are not hot-reloaded. to invalidate the cache it has you can touch node_modules/imgui-js/package.json which will then trigger a recompile#2021-05-0207:38sh54so I have kept it out of the node_modules right now. in my own build it just copies it into a directory on the class path. then in my shadow-cljs config I do :js-options {:resolve {"imgui-js" {:target :file, :file "src/cljc/imgui/imgui.js"}}}#2021-05-0207:39thhellerdo NOT use :resolve if you have stuff on the classpath anyways#2021-05-0207:39sh54not sure if that is best practice by any means but seems easiest for development#2021-05-0207:39sh54k#2021-05-0207:39thhellerjust use (:require ["/imgui/imgui.js" :as imgui]) https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-05-0207:39sh54i’ll get that changed then#2021-05-0207:39sh54thanks, i’ll see if that helps.#2021-05-0207:44sh54ahh, I remember there was a particular reason for why i did that! There is a separate js file I include that I have done that style: #?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]) . And it tries to do require('imgui-js') to get in that same file. Since it looked like I needed that resolve bit to make imgui_demo.js happy i just used that in my cljc file too.#2021-05-0207:44sh54can I leave the :resolve in the shadow cljs settings to keep the other include happy and move to use (:require ["/imgui/imgui.js" :as imgui]) in my cljc file then?#2021-05-0207:45thhellersorry I don't have a clue what you are doing and would need to see some actual code#2021-05-0207:45thhellerotherwise there are far too many unknowns for me but it looks like you are trying to hack this together in the wrong way#2021-05-0207:46thhellerusing :resolve for packages you already control is almost guaranteed to be wrong#2021-05-0207:48sh54maybe… main issue is I don’t have “full” control. Just on a fork to add some functionality. and if I don’t have to change some of the build fundamentals in that project then I would like to leave them be and deal with things on the clojure side.#2021-05-0207:49sh54sorry if my explanation here is lacking. I can get back with a better summary of how things are wired together#2021-05-0207:50thhellerwasm in general requires rather specific "glue" code that currently isn't very bundler friendly#2021-05-0207:50sh54It all works fine outside of the hot reload.#2021-05-0207:50thhelleryeah, I'm gonna need to see some code to comment on that#2021-05-0207:51sh54Yeah I have done my own wasm tests a while back and I remember having quite a few issues with the glue code then.#2021-05-0208:23sh54k incoming essay: 🙂#2021-05-0208:23sh54So I include https://github.com/flyover/imgui-js as a git submodule.#2021-05-0208:24sh54I have a little build tooling that just runs its make file and copies the relevant compiled js files over somewhere into my class path.#2021-05-0208:24sh54Here I guess I may be going wrong and that I should register it as a node module. Not sure how to do that but I’m sure I can figure it out if thats the way to go.#2021-05-0208:24sh54Anyway, the project compiles down to two important files. imgui.js really is the thing that does everything. imgui_demo.js is several thousand lines of js that is recommended to include when developing since it both serves as documentation and a settings tweaker. Again all not really my code, though I can always change things up if necessary in the fork.#2021-05-0208:24sh54It seems like it is the interplay between those two files that causes some issues with shadow-cljs. The top of imgui_demo.js has one of those standard check all sorts of places to figure out how to require imgui.js.#2021-05-0208:24sh54
// imgui_demo.js top
    (function (global, factory) {
        typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('imgui-js')) :
        typeof define === 'function' && define.amd ? define(['exports', 'imgui-js'], factory) :
        (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ImGui_Demo = {}, global.ImGui));
    }(this, (function (exports, ImGui) { 'use strict';
    ... );
#2021-05-0208:24sh54The important thing being the require('imgui-js') it seems?#2021-05-0208:24sh54Right now I really only include them in my wrapper files.#2021-05-0208:24sh54What works with the requires is when I do the following:#2021-05-0208:25sh54
(:require
      #?(:cljs ["imgui-js" :as imgui])
      ;;#?(:cljs ["/imgui/imgui.js" :as imgui]) ;; this does not work!
      #?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]))
#2021-05-0208:25sh54Then everything builds fine. But alterations to the js file do not get picked up and require a stop and watch. But hardly the end of the world.#2021-05-0208:25sh54and in my shadow-cljs config include:#2021-05-0208:25sh54
:js-options {:resolve {"imgui-js" {:target :file :file "src/cljc/imgui/imgui.js"}}}
#2021-05-0208:25sh54Now I have tried with the following instead:#2021-05-0208:25sh54
(:require
      #?(:cljs ["/imgui/imgui.js" :as imgui])
      #?(:cljs ["/imgui/imgui_demo.js" :as imgui-demo]))
#2021-05-0208:25sh54Right now this results in imgui.js somehow being included twice! The imgui_demo.js file seems to get its own copy.#2021-05-0208:25sh54I can see this by looking at my shared.js which shadow-cljs is compiling.#2021-05-0208:25sh54In this setup it has the lines:#2021-05-0208:25sh54
SHADOW_ENV.evalLoad("module$imgui$imgui.js", true , ......
    SHADOW_ENV.evalLoad("module$src$cljc$imgui$imgui.js", true , ......
#2021-05-0208:25sh54so two copies of imgui.js which compiles fine but crashes at runtime.#2021-05-0208:25sh54I guess I could try to keep them in my node_modules instead? Maybe it will give better results. Though it feels like it should be possible to handle them being files in the class path too.#2021-05-0208:33thhellerfirst of all forget about :resolve. as I said that this is NOT relevant here#2021-05-0208:34thhellerWHY did you add it in the first place? WHY do you think require('imgui-js') is a problem?#2021-05-0208:35thhelleragain this is would be much much much much much easier if you just put the code into some repo so I can look at it together#2021-05-0208:45sh54Without the :resolve bit then shadow cljs is not able to build anything: X Compilation failed.
The required JS dependency "imgui-js" is not available, it was required by "imgui/imgui_demo.js".
#2021-05-0208:46sh54How I have things required in is the only way that the project is building, and not throwing at runtime, and not double including imgui.js#2021-05-0208:47sh54I can try to reproduce in a simpler repo.#2021-05-0208:47thhellerWHERE is imgui-js from? it is not the file you generate from the wasm right? did you modify that file in any way?#2021-05-0208:48sh54as stated before the require('imgui-js') part is in the helper files like imgui_demo.js that are also a part of that project#2021-05-0208:48thhellerI asked where the file is from, not where it was included from#2021-05-0208:48thhellersrc/cljc/imgui/imgui.js WHERE is this from? is this also wasm generated code?#2021-05-0208:49sh54got you#2021-05-0208:49sh54that is just copied from the build output of the project. Copied unmodified like all the rest of the build artifacts I am relying on#2021-05-0208:50thhellerok, so you have two files in a directory?#2021-05-0208:50sh54yup#2021-05-0208:51thhellerok, my first suggestion would be to just modify the generated demo.js to replace require('imgui-js') with require('./imgui.js') instead#2021-05-0208:51thhellersince you are generating that file anyways that should be trivial to add#2021-05-0208:51sh54yeah I can try that#2021-05-0208:52thhellerthe goal of this is to make everything self-contained so it doesn't rely on build config and the code expressing its intent correctly#2021-05-0208:53thhellerright now require('imgui-js') is interpreted as "require the imgui-js npm library" but it is not an npm library. avoid resolve to fix this, much better to fix it in the source directly#2021-05-0208:53sh54totally. I guess you have to deal with all sorts of different js files doing some funky things when it comes to dependencies sometimes 😕#2021-05-0208:54thhellerthe problem really is :resolve to :file. I should probably remove that altogether since it is basically never the correct way to do anything#2021-05-0208:56sh54good to know#2021-05-0209:04sh54hey, so your suggesting on changing the require to ./imgui.js works nicely. I eliminated my use of :js-options :resolve too. just going to alter my tooling to alter the files then I can check if hot reload works#2021-05-0209:04sh54thanks a bunch for your help and time#2021-05-0209:05sh54I was going in with the idea of not altering the build artifacts and fudging things on the clojure side#2021-05-0209:05thhellerhot-reload was likely broken because of the :resolve#2021-05-0209:05thhellercan you send me the generated demo.js file? I'd be interested to see how that looks in full#2021-05-0209:06sh54but it looks like the way to go is to provide files with the right refs#2021-05-0209:06sh54sure#2021-05-0209:07sh54the two files where imgui_demo.js has been patched#2021-05-0209:10thhellerhot-reload is probably going to be a problem. the code doesn't really allow it. but recompile and browser reload should be ok without :resolve#2021-05-0209:11thhellerthe caching problem should be gone though#2021-05-0209:12sh54yeah as long as the browser reload is all good then that is plenty good enough! I figured hot reload would be a problem given the important stuff happens in the wasm#2021-05-0209:13thhellerwould be a little easier to accomplish without the wasm inlined into the source#2021-05-0209:33sh54yeah the recompile is now working! thanks again for the help#2021-05-0220:02Sam Ritchiehey all.. I am having the toughest time converting to shadow-cljs from lein, for my CIDER repl workflow. I run cider-jack-in-cljs, select shadow-cljs then shadow as the repl type,#2021-05-0220:02Sam Ritchieand everything boots, but then when I try to eval a form, I see
No available JS runtime.
See 
#2021-05-0220:03Sam Ritchiemy goal is to get a node repl running#2021-05-0220:03Sam Ritchieso… MAYBE I am supposed to run the generated file and it will get a repl going? except this is my test target, so it probably will not…#2021-05-0220:06Sam RitchieI must be missing something obvious here, for getting up a workflow that uses node to evaluate forms without needing a browser. sorry for the fumbling question… I’ve been at CLJS a long time and build stuff can still be mystifying#2021-05-0220:21Sam Ritchienode-repl is saving me… before it was failing with an error I can’t find, but I may be in business!! apologies for the flailing, I think I’m good 🙂#2021-05-0307:46mbertheau@thheller I was thinking a bit more about the approach in https://github.com/thheller/reagent-react-native with react-native/metro separated into a subdirectory. You specifically said "CLJS tooling related things" go in the top-level package.json. Is it accurate that that conflicts a bit with the default behaviour {:npm-deps {:install true}} which installs non-tooling JS deps in the top-level package.json / node_modules, instead of the one in react-native/, where metro in the end looks for it? One might end up with different versions of the same package in the two node_modules directories.#2021-05-0308:12thhellerthat is correct yes. I'll likely remove the automatic :npm-deps install completely at some point and make it a proper manual command instead#2021-05-0308:13thhellerbut the duplicate install won't be used under normal circumstances so it doesn't matter too much for now#2021-05-0308:14thhelleralso you don't have to do this separation. it just made sense to me. I also don't actually use react-native for anything so I might be totally wrong#2021-05-0311:12mbertheauI like the separation very much, I was delighted when I found that example! There's so many files in a react-native project, all on the top level, that just come straight from the react native template. I like a cleaner workspace. Thanks! Then I'll set {:npm-deps {:install false}} and go with that one right away. I briefly tried debugging though and it didn't find the CLJS source. I suspect that that has to do with the fact that the CLJS source files are outside of the metro / react native root, but I didn't have time yet to look into that.#2021-05-0311:25thhellerwho didn't find cljs sources? metro shouldn't care, it should only see the sources generated in that dir https://github.com/thheller/reagent-react-native/blob/master/shadow-cljs.edn#L14#2021-05-0311:54mbertheauI mean the original CLJS for source-mapping during debugging#2021-05-0311:54mbertheauBut as I said, I just stumbled over this and haven't had a moment to confirm or disprove that shallow hypothesis#2021-05-0311:57thhellerdoes react-native finally support source maps? been a while since I checked#2021-05-0311:57thhellersource maps otherwise are self contained and contain all sources#2021-05-0313:49FabimMy app is surprisingly large in release mode. I used shadow-cljs release app on my reagent/reframe app. the js folder that is created is 25MB. do I need to manually delete the cljs-runtime folder?#2021-05-0314:22mbertheau@merklefabian try deleting the output folder before doing release app. Most of the big stuff in there is only needed for the development build.#2021-05-0314:23thhellerthe cljs-runtime folder is not used by release builds yes#2021-05-0315:08FabimThanks for your quick answer. Whats the reason it is not deleted automatically?#2021-05-0315:12thhellershadow-cljs doesn't delete stuff as sort of a rule 😛#2021-05-0317:24biscuitpantsis it still possible to 'hack' on shadow-cljs by adding the lib to the classpath? i've added it to src/ and i get conflicts on compile so i assume it is being added to the cp. unfortunately i don't see changes i've made to the codebase, or see any hot reloads when i change cljs files#2021-05-0317:29thheller@biscuitpants I'm not sure I understand the question. what did you add to src? replacing shadow-cljs internal namespace should be fine yes?#2021-05-0317:29thhellerif you are using shadow-cljs.edn only (no deps.edn, project.clj) you might need to add :aot false to the top level#2021-05-0317:35biscuitpantsyeah i've got src/shadow/cljs/ui/components/inspect.cljs and just added a simple prn to ui-tap-panel and it doesn't seem to be overwriting the default inpsect.cljs#2021-05-0317:35biscuitpantsi'm using shadow-cljs.edn with deps.edn and :deps true#2021-05-0317:36thhelleryou can't hack the cljs parts that way#2021-05-0317:37thhellerthose are precompiled and only the finished JS files is used#2021-05-0317:37biscuitpantsahhh#2021-05-0317:37biscuitpantswell that explains it 😄#2021-05-0317:40biscuitpantsthanks for the help 🙂#2021-05-0317:41thhelleryou can compile the UI code locally and replace it for your app if you want#2021-05-0317:41biscuitpantsyeah that is what i'm going to do#2021-05-0317:41biscuitpantsfwiw i'm trying to add js/Object support to inspect#2021-05-0317:41thhellerthat is already supported?#2021-05-0317:42biscuitpantshmm i'll double check my versions, but doing tap> on a pure JS object just printed js/Object#2021-05-0317:42thhellerfor that you don't need to change the UI code at all btw#2021-05-0317:42thhellersince that part is handled by the code that is injected into your app#2021-05-0317:43biscuitpantsah. i'll dig more through the code then. definitely missed something#2021-05-0317:43thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/remote/runtime/obj_support.cljc#2021-05-0317:44biscuitpantsthank you#2021-05-0317:44thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/remote/runtime/cljs/js_builtins.cljs#2021-05-0317:44thhellerthat would be the support for generic JS objects#2021-05-0317:45thhelleryou can extend the Datafiable protocol onto any objects in your codebase and it'll just work in the UI#2021-05-0317:46biscuitpantsahhh that is much easier! i did not know that. thank you#2021-05-0317:46biscuitpantsreally nice way to do that#2021-05-0317:50thhellerthere are some more examples here https://github.com/thheller/shadow-experiments/blob/master/src/main/shadow/experiments/grove/dev_support.cljs#2021-05-0317:50thhellercan be handy to be able to look into "foreign" objects via the UI#2021-05-0317:51biscuitpantsahh that's awesome. very useful for custom objects#2021-05-0317:52biscuitpantsreally useful for react/other components#2021-05-0317:56Ryan JerueHello @thheller looking at this guy https://github.com/thheller/shadow-cljs/issues/434#issuecomment-461206429 It looks like that this means that
:js-options
{:source-map false}
would prevent source maps from things inside of node_modules from being outputted?
#2021-05-0317:58thhellerno, there is no separate setting for node_modules source maps#2021-05-0318:17Ryan Jeruehttps://imgur.com/a/StHAnXP … the only difference with these is that the smaller one has
:js-options
{:source-map false}
set. https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/build/api.clj#L125`default-js-options`https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/build/api.clj#L125
#2021-05-0318:21thhellerhmm kinda accidental that this works then I guess#2021-05-0323:08zhuxun2Is there an easy way to "re-export" a variable from a js libary using the same name? For example, instead of having to say:
(ns xxx
   (:require ["my-lib/my-thing-1" :default my-thing-1*]))

(def my-thing-1 my-thing-1*)
for every my-thing-n, is there a way similar to (:require ["my-lib/my-thing-1" :default my-thing-1* :reexport), so that I can use xxx/my-thing-1 in another ns in the same project?
#2021-05-0404:47zimablueHi, what is the recommended way if any to build something intended for a (node + typescript) consumption? I think the issue is that you need to do :keep-native-requires for node to work, but :keep-native requires leaves as you'd imagine, the requirement as "require" whereas typescript seems to hate that, throwing this error: WARNING in ../node_modules/datahike/datahike.js 112:12-19 vs-sprot-mm: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted#2021-05-0407:03thheller@zhuxun2 no, that is not supported and probably never will be#2021-05-0407:05thheller@zimablue don't know what that error is about, would need to see some code. don't know what :keep-native-requires has to do with anything? when you are using node anyways you absolutely should not be using :js-provider :shadow?#2021-05-0407:06zimablueI did not know that I should not be using that js-provider, sorry. In fact that is the one thign I never tried varying#2021-05-0407:06zimabluewhat should I be using?#2021-05-0407:07zimablueI pulled the first configuration that I tried from this thread: https://github.com/thheller/shadow-cljs/issues/290#2021-05-0407:07thhellerwell, I need to know more about what you are building to answer#2021-05-0407:08zimabluetrying to compile datascript (cljs library) so that it works through an application that uses typescript to target a node runtime#2021-05-0407:08zimabluein fact it's datahike, which is a fork#2021-05-0407:08thhellerso you use :target :node-library?#2021-05-0407:09zimablueyes, although I've tried others in my scattershot attempts#2021-05-0407:10thhellerwell, it sounds like :node-library would do what you need. if you describe what the problem with that was I can maybe help further#2021-05-0407:11thhellercompletely basic config, no :js-options config whatsoever#2021-05-0407:12zimablueI will strip out all the config and then come back#2021-05-0407:12zimablueyou recommend to use "release" right, not compile#2021-05-0407:12zimabluedoes infer-externs matter? it is on auto currently#2021-05-0407:13thhelleryou must use release if you intend to release the actual library to be used in projects. compile or watch will only work on the machine it was compiled on in the directory it was compiled in#2021-05-0407:14thhellermatter for what? it only affects the warnings you'll see for your code. nothing else#2021-05-0407:14zimabluefor working when consumed as a module by typescript I guess#2021-05-0407:14zimablueI'll leave as-if and follow your advice#2021-05-0407:14zimablueI think I will have already tried that combination, but it will at least give us the relevant error#2021-05-0407:15thhelleryou don't need to set it at all, auto is the default nowadays (unless you are on a really old version)#2021-05-0407:15zimablueI will set it just to let it know I'm serious#2021-05-0407:16thhellerit does not affect the code that is generated in any way so I'm unsure what you think it does#2021-05-0407:33zimabluesorry, it was a stupid joke#2021-05-0407:37thhellerjust wanted to be clear that it doesn't affect the generated code 😛 it really only controls whether you see the warnings or not#2021-05-0407:57zimabluewith the settings that you suggested, the runtime error is this: $environ$core$fs$$.$existsSync$ is not a function. When I look at the code, it's trying to do existsSync on ".lein-env". I'm actually trying to run it in a vscode extension and now wondering whether vscode blocks raw node calls so I'm checking on that also#2021-05-0408:00thhellerthat looks like you are maybe doing (def fs node-fs) with (:require ["fs" :as node-fs]) or something like that?#2021-05-0408:01thhelleroh no ... worse the library is doing that https://github.com/weavejester/environ/blob/master/environ/src/environ/core.cljc#L11#2021-05-0408:02thhellerfor that you'll need to add manual externs I guess#2021-05-0408:02thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2021-05-0408:03thhelleror just get rid of that entire library. it doesn't seem to be doing all that much 😛#2021-05-0408:04Aronthis is such an evergreen advice. I love libraries, because of this :)#2021-05-0408:06thhelleryes, maybe but unfortunately very many libraries are designed for CLJ and then someone just adds support for CLJS later as an afterthought#2021-05-0408:07thhellerthat doesn't always work out well#2021-05-0408:09AronI remember the first time I realized how far cljs and clj are from each other. I almost broke down crying. 🙂#2021-05-0408:10Aronalthough, in this situation it seems to me there might be other assumptions going on that could be breaking https://imgur.com/a/rZzPfWl#2021-05-0408:12zimablueyes, :require "fs" as fs is happening, both seemingly in that dependency and also in the library main#2021-05-0408:12zimabluethe problem is when this all gets pushed through a typescript=>node-electron thing though, it all works fine in shadow-cls node-repl#2021-05-0408:13thheller@zimablue the problem is the library uses js/require so externs inference is "hindered" a little. that is why you are seeing the existsSync (and likely the others) getting renamed
#2021-05-0408:13zimablueso it's expected that it works in node-repl but not when compiled and pushed through typescript?#2021-05-0408:13thhellerif that were (:require ["fs" :as fs]) externs inference would be much smarter and generate the proper externs#2021-05-0408:14zimablueah, so it might just be the dependencies having that requirement that's the problem, not the project "main"?#2021-05-0408:14thhellerplease take a second to understand what externs are#2021-05-0408:14Aronjs requires explicit exports, which is not kept without all this being in place#2021-05-0408:14zimabluebut "manual externs" should work?#2021-05-0408:14thhellerthey ONLY prevent the renaming of stuff. when you run node-repl NOTHING is getting renamed since it does not run through :advanced compilation#2021-05-0408:14zimablueI have taken a second before, it's taken me longer than that definitely xD from memory "variables which should not be renamed"#2021-05-0408:14thhellerwhen you run release things will get named and minified#2021-05-0408:14zimablueah, I see#2021-05-0408:14thhellerso with externs you prevent those renames#2021-05-0408:15thhellerexterns-inference is meant to do this automatically for you but it can only do so when the code is written appropriately. which this library is not. so you need to help it along manually#2021-05-0408:15Aronappropriate is es6 import/export?#2021-05-0408:22thhellerFWIW if you use the proper (:require ["fs" :as fs]) then shadow-cljs will automatically add externs for whereever fs/* is used. with (js/require ...) this is not done. basically since you are never supposed to use that ...#2021-05-0408:27Aronthanks for getting back on this, sorry for causing confusion :/#2021-05-0408:28AronI can see why js/require is not helpful#2021-05-0408:30thhellerwell often it is used as a "hack" to get a dynamic require sort of behavior. like that library does. from a build tool perspective this pattern is horrible but I understand why it is done.#2021-05-0408:30thhellera simple ^js hint would also fix problems with this but the lib doesn't have it#2021-05-0408:16Aronor some cljs convention#2021-05-0408:16thhellerthere is no such thing as es6 import/export in CLJS, but lets please stay on topic here#2021-05-0408:16thheller@zimablue what you need is a externs/your-build-id.txt and just one line for existsSync (and maybe more lines for other stuff getting renamed)#2021-05-0408:17thhellerthat will make it work fine in release and typescript#2021-05-0408:18thhellernormally this should be fixed directly in the code but since it is a library you can't easily do that. unless you are ok with forking it#2021-05-0408:31pez@zimablue have a look at the Clover extension and see how things are done there. iirc it uses shadow-cljs as the central part of the toolchain. I can also recommend using the #vscode channel for getting some pointers and help from others fighting a similar battle. 😃#2021-05-0408:36thhellerI'd honestly just replace that library. Unless you actually want your electron app to be configurable via a .lein-env file?#2021-05-0408:52zimablueIt's not my personal project to pull libraries out of, I'll follow the explanation you gave, applied to this project and see where I get to#2021-05-0408:53zimablue@pez, thanks for that advice I will take a look#2021-05-0414:32Adam Kalisz@thheller it has been more than a month. I couldn't load my dev-environment in Chromium on Debian Linux and had to resort to working in Firefox without some of the useful tools. The loading of the project was so slow, it basically was just hanging. The issue seems to have been with :devtools {:loader-mode :script} which was there for some (maybe already obsolete) issue. Switching to {:loader-mode :eval} seems to fix the problem. Everything is snappy again#2021-05-0414:34Adam KaliszI don't know any details, my colleague found it to fix some of his performance issues and it helped me even more.#2021-05-0414:52Prabu RajanHi, How do I import a react library component in a shadow-cljs / re-frame app? Below isn’t working
//JS version
import { Button } from "@chakra-ui/react";
import { ChakraProvider } from "@chakra-ui/react";

class App extends Component {
  render() {
    return (
      <ChakraProvider>
        <Button
                px="3"
                py="2"
                bg="green.200"
                rounded="md"
                _hover={{ bg: "green.300" }}>
            Click me
        </Button>
        <h1>Hello World</h1>
      </ChakraProvider>
    );
  }
}

//cljs version

(ns todo.views
  (:require
   [re-frame.core :as re-frame]
   [todo.events :as events]
   ["@chakra-ui/react" :refer (ChakraProvider)]
   ["@chakra-ui/react" :refer (Button)]
   [todo.subs :as subs]))

(defn button-panel []
  [:div {:id "button-panel"}
   [:> Button {:px 10 :py 5 :bg "green.200" :on-click
     #(re-frame/dispatch [::events/update-counter 1])} "+"]
   [:> Button {:px 10 :py 5 :bg "green.200" :on-click
     #(re-frame/dispatch [::events/update-counter -1])} "-"]])

(defn main-panel []
  (let [counter (re-frame/subscribe [::subs/counter])]
    [:> ChakraProvider
     [:div
     [:h1 @counter]
     (button-panel)]]))
#2021-05-0415:03Prabu RajanI was able to fix it like this
(ns todo.views
  (:require
   [re-frame.core :as re-frame]
   [todo.events :as events]
   ["@chakra-ui/react" :as cui]
   [todo.subs :as subs]))

(defn button-panel []
  [:div {:id "button-panel"}
   [:> cui/Button {:mr 1 :bg "green.200" :on-click
     #(re-frame/dispatch [::events/update-counter 1])} "+"]
   [:> cui/Button {:bg "green.200" :on-click
     #(re-frame/dispatch [::events/update-counter -1])} "-"]])
#2021-05-0416:07thheller["@chakra-ui/react" :refer (ChakraProvider Button)] would be ok too#2021-05-0417:14Prabu RajanCool, works too, not sure what was missing earlier#2021-05-0417:22thhellerthere seems to be a bug. you had the "@chakra-ui/react" require twice and the second one replaced the first one instead of adding to it#2021-05-0417:56Prabu RajanYes, thats right. Thanks for pointing it out. You mean its a bug with shadow-cljs or the code above?#2021-05-0417:56thhellerbug in shadow#2021-05-0418:01Prabu RajanThanks, raised this issue - https://github.com/thheller/shadow-cljs/issues/879#2021-05-0418:01mssanyone had any luck getting react-pdf or generally pdfjs working nicely with shadow? feel like I’m mashing a square peg into a round hole, mostly because I’m not super familiar with pdfjs#2021-05-0418:15zalkyHi all: when using :js-provider :external , is it required to have a node_modules installed before compiling with shadow? I'm getting an error without it:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
I'm getting my js bundle via another source (not npm), and wondering if there's still some way to make it work with shadow.
#2021-05-0418:30thhellerwell the problem there is that reagent.core does (:require [react ...]) as in a symbol#2021-05-0418:31thhellerthe only way to know that this symbol is referring to an actual npm library it needs to be in node_modules#2021-05-0418:31thhellerif that was (:require ["react" ...]) that check is not necessary since we know that strings are reserved for JS libs#2021-05-0418:32thhellercurrently there is no way to tell it manually that certain symbols should be treated as a npm lib, well besides installing the actual npm lib#2021-05-0418:33thhellerI tried advocating for enforcing strings for JS requires but that feedback was ignored so we have this problem unfortunately#2021-05-0418:39zalkyGotcha, the string require does make a lot of sense, it's basically js interop, no sense hiding it. I guess just assuming every missing dependency is externally provided is not feasible?#2021-05-0418:42zalkyI suppose not since you still have to check the cljs ones.#2021-05-0418:46zalkyIt wouldn't make sense to turn it into a warning, would it? "This is missing, better be provided externally" something along those lines?#2021-05-0418:52thhellerI won't just make every symbol valid assuming its a npm dependency. there could be typos and stuff#2021-05-0418:53thhellerI'd be open to adding a config option to treat certain symbols as npm requires without requiring their presence#2021-05-0418:54thhellermaybe I could also just use the :npm-deps from deps.cljs for that#2021-05-0420:44lispers-anonymousDoes shadow-cljs have a tool built in for printing out a graph of namespace requires? I am trying to figure out why cljs.pprint is being included in my production bundle, which I learned using the shadow-cljs.build-report tool.#2021-05-0420:48dpsuttoni don't remember where i heard/read it, but i have a memory that if you use the equivalent of format it will drag pprint in#2021-05-0420:53lispers-anonymousI don't believe we are using any functions called format . Do you know what namespace that lives in?#2021-05-0420:54dpsuttonit had been a while. i looked it up and its cljs.pprint/cl-format so probably not the insight i remembered it to have been 🙂#2021-05-0420:56lispers-anonymousYeah definitely not using that lol, I appreciate the thought though. I feel like exhausted all my options for finding the culprit#2021-05-0420:56nivekuilexpound, maybe from guardrails? if you use fulcro at all it'll get pulled in#2021-05-0420:57lispers-anonymousExpound may be it actually. looking#2021-05-0420:59lispers-anonymousYeah that's it. I'm not using fulcro or guardrails, but we do have one usage of expound. This must be it. Thank you!#2021-05-0421:14thheller@dannyfreeman that graph does not currently exist no. requires a bit of manual digging currently to find it. do you use fulcro?#2021-05-0421:15thhellerah nvm thread. yeah expound is one source#2021-05-0421:17lispers-anonymousYeah that was the only culprit thankfully. I can happily code split on the namespace where I use expound and get cljs.pprint out of my main bundle.#2021-05-0508:33roman01lais it possible to run advanced build in watch mode? trying it now and the output doesn’t seem to be optimized (not using :debug flag)#2021-05-0508:34thhellerno, not possible. due to the sometimes excessive build times of :advanced that simply isn't practical. much better to click one button or run one command when you are actually sure you want to build#2021-05-0509:16Aronshould I use a linter? and which one?#2021-05-0509:21thhellerno clue, your choice. I've never used one for long, too much noise regarding macros in the ones I tested#2021-05-0509:34Aronthat's why I am asking here, seems like an unsurmountable hurdle#2021-05-0509:52thhellerI think the most popular one currently is #clj-kondo#2021-05-0509:54Aronyeah, ale for vim has autoconfigure for it, also for joker, I tried both because it would help me as a beginner, i think, but it's probably not going to happen today. difficult to configure all the macros and i am not even sure what to do when it's not a macro#2021-05-0514:06lispers-anonymousI've not had too many issues with clj-kondo. Dealing with macros is pretty easy. In my re-frame project, the only macro I have a special lint rule for is this
{:lint-as {reagent.core/with-let clojure.core/let}}
Which lives in project-root/.clj-kondo/config.edn Everything had been working great with it.
#2021-05-0514:08lispers-anonymousIf you have custom macros that don't match any known macro linters I think you can tell the linter to ignore them, or perhaps tell it to :lint-as the comment macro#2021-05-0510:10grumpletShould we expect the grand total of the build report optimised column from something like shadow-cljs run shadow.cljs.build-report app report.html to be about the same size as the target app.js I wonder? It’s falling short for me and so I’m trying to understand what I’m missing.#2021-05-0510:11thhellerwithin a certain percentage yes, it isn't 100% accurate but close enough#2021-05-0510:13grumpletThanks @thheller. I’ll make a gist to show you what I mean - I’m quite a long way short.#2021-05-0510:17grumplethttps://gist.github.com/gmp26/86648a78b754cdaf577feaad550b38ac#2021-05-0510:20thhellerbuild config would help. don't know what you are doing to the build 😛#2021-05-0510:20thhellerhtml report is also more helpful since it groups stuff#2021-05-0510:20thhellerjar | cljs/core.cljs | 750.5 KB#2021-05-0510:21thhellerlooks like you are maybe using :simple? or pseudo-names?#2021-05-0510:21thhellershouldn't be that large otherwise#2021-05-0510:22grumpletSorry - my mistake - I had dine a calva jack-in so was looking at a development app.js. Makes more sense after another build.#2021-05-0510:34grumplet… and you were right - I did have optimisations simple.#2021-05-0518:55Jakob DurstbergerHey, I am using shadow-cljs to run cljs on aws lambda. I want to use the npm package jsonwebtoken. The problem is when I build my lambda for prod the node_modules are not included in the output folder so just uploading the index.js file leads to a runtime error that jsonwebtoken could not be found. I copied node_modules manually and zipped it all up which worked but is tedious. Is this expected? I feel like I am doing something wrong and shadow-cljs would take care of that for me. shadow-cljs.edn:
{:source-paths
 ["src"]

 :dependencies []

 :builds
 {:wallet-lambda {:target :node-library
                  :output-to "./dist/wallet_lambda/index.js"
                  :exports {:handler com.ye-olde-shoppe.wallet.main/handler}
                  :compiler-options {:infer-externs :auto}}}}
package.json
{
  "name": "yos-backend",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "shadow-cljs": "2.12.5"
  },
  "dependencies": {
    "jsonwebtoken": "^8.5.1"
  },
  "scripts": {
    "build-wallet": "shadow-cljs release :wallet-lambda",
    "assemble-wallet": "npm run build-wallet && cd dist/wallet_lambda && zip ../wallet_lambda.zip *"
  }
}
#2021-05-0519:15thhelleryou can post process the :output-to file with something like https://github.com/vercel/ncc#2021-05-0519:15thhellerbut honestly it is better to just copy the node_modules you need#2021-05-0519:22Jakob Durstbergerok, thanks. I’ll probably add a copy node_modules step to my build script#2021-05-0519:31Jakob Durstbergerjust to clarify, you mean to copy the whole node_modules folder right?#2021-05-0519:37thhellerno#2021-05-0519:38thhellercreate a folder with a package.json including the pacakges you need#2021-05-0519:38thhellerrun npm install --production#2021-05-0519:38thhellercopy the resulting node_modules#2021-05-0519:39thhellerI think the AWS has a section for best practices regarding this#2021-05-0519:39thhellerjust check their docs#2021-05-0519:43Jakob Durstbergerah, thank you 🙂#2021-05-0900:30rbergerHere’s a https://gist.github.com/rberger/6d4c5db1ecb5ae452e1b5412a14c7e6d that showed how I just recently did something similar. Was targeting /cdn-cgi/l/email-protection which had a max image size of 50MB, so besides yarn install --production I also used https://github.com/ModClean/modclean to get the zipped image with node_modules to less than 30MB.#2021-05-0907:06thheller@U07GPFFAS you can safe some time by combining
npx shadow-cljs release :lambda-viewer
	npx shadow-cljs release :lambda-origin
into just
npx shadow-cljs release lambda-viewer lambda-origin
#2021-05-0907:06thhellersafes the second startup#2021-05-0908:00rbergernice to know! Thanks#2021-05-0915:23Jakob DurstbergerThat is very similar to what my script ended up looking like 🙂#2021-05-0518:57jaimeHi everyone, I'm using shadow-cljs v2.12.5 for a react-native app The react-native console is showing error
ERROR  shadow-cljs - remote-error {"isTrusted": false, "message": "CLEARTEXT communication to 10.212.134.68 not permitted by network security policy"}
 WARN  shadow-cljs: giving up trying to connect to  
I think the problem here is that the IP above is not my local IP (192.168.0.184). When I search for 10.212.134.68 in my project, I found a matching text in target/index.js file Here is the first 5 lines of code
var $CLJS = global;
var shadow$start = new Date().getTime();
var shadow$provide = global.shadow$provide = {};
var goog = global.goog = {};
global.CLOSURE_DEFINES = {"shadow.cljs.devtools.client.env.repl_pprint":false,"shadow.cljs.devtools.client.env.reload_strategy":"optimized","shadow.cljs.devtools.client.env.devtools_url":"","shadow.cljs.devtools.client.env.autoload":true,"shadow.cljs.devtools.client.env.proc_id":"b2dc811d-cc6d-467e-81bf-e8f4eae2709a","shadow.cljs.devtools.client.env.use_document_protocol":false,"goog.ENABLE_DEBUG_LOADER":false,"shadow.cljs.devtools.client.env.server_port":9630,"shadow.cljs.devtools.client.env.server_token":"d98f5299-1231-4718-8262-3736140c13f2","shadow.cljs.devtools.client.env.use_document_host":true,"shadow.cljs.devtools.client.env.module_format":"goog","goog.LOCALE":"en","shadow.cljs.devtools.client.env.build_id":"app","shadow.cljs.devtools.client.env.ignore_warnings":false,"goog.DEBUG":true,"cljs.core._STAR_target_STAR_":"react-native","shadow.cljs.devtools.client.env.log":true,"shadow.cljs.devtools.client.env.ssl":false,"shadow.cljs.devtools.client.env.enabled":true,"shadow.cljs.devtools.client.env.server_host":"10.212.134.68","shadow.cljs.devtools.client.env.worker_client_id":2,"goog.TRANSPILE":"never"};
When I change the hardcoded IP in target/index.js file, the websocket connection is working and I'm getting a message
LOG  dev init time 839
 LOG  Running "Limeray" with {"rootTag":201}
 LOG  date is  null
 LOG  #6 ready!
My question is, is there a way to configure shadow-cljs to use specific IP for websocket? In my case Previously when I encountered this issue, I was able to configure like below. But now, it does not seem to work
{:deps true
 ;; local network IP in order for websocket to send repl command over-the-network
 :http {:host "192.168.0.184"}
 :builds
 {:app {:target :react-native
        :init-fn limeray.mobile.main/init
        :output-dir "target"
        :js-options {:js-package-dirs ["node_modules"]}}}}
#2021-05-0519:13thheller@jaime.sangcap in ~/.shadow-cljs/config.edn you can configure :local-ip "192.168.0.184" (or in your shadow-cljs.edn local config as well)#2021-05-0520:41jaimeAwesome! Thanks a lot, it works. Shame on me, it is stated in the docs https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native 😅#2021-05-0606:16FHEHi everyone. Painfully noobish CLJS-er here. Just wondering why when I created a project folder with the npx command near the beginning of the shadow-cljs user guide....there is no main.html file I can find.#2021-05-0606:27thheller@factorhengineering if you continue reading the README it is telling you to create it?#2021-05-0606:39FHE@thheller I haven't read the whole thing yet, but I would have thought it would be a basic thing any project would need, so it would be created at the beginning.#2021-05-0606:43thhellerthe npx create-cljs-project only generates the very bare bone project skeleton. I don't know what you are going to build. might be a node script, might be a react-native app, might be browser-based app. not all of them require html files.#2021-05-0606:43FHEI did just search for main.html, and index.html (I think that's what I meant in the first place), but I don't really see a step of creating one. ...and again, isn't it needed for CLJS?#2021-05-0606:44thhelleryou can use a more specific templates like the re-frame template if you like. that generates a HTML file#2021-05-0606:45FHEA react-native app wouldn't need one? Wow. OK, it does not work the way I thought it would. I thought react native just ported a standard JS-enabled webpage to mobile.#2021-05-0606:45thhellerno it does not. that would be something cordova and others do.#2021-05-0606:46FHEMy dream of making an app that works on web and mobile is looking ever more distant. lol A widening gulf of learning between me and it. Haha#2021-05-0606:47thhellerwell there is react-native-web that turns a react-native ab into a webapp but thats about all I can tell you about it. never used it myself.#2021-05-0606:49FHEInput mobile app, output webapp?? That's backwards from what I'd heard so far. OK, I wasn't going to worry about mobile just yet...focus on web...but based on that maybe I should jump right in. 😕#2021-05-0606:49FHEWill have to decide tomorrow. Too tired now. Thanks for your help. 🙂#2021-05-0606:53BenjaminHello, I am curious if it is possible to get a shadow-cljs repl connected to a browser userscript.#2021-05-0606:55thhellerdefine "browser userscript"?#2021-05-0607:01Benjaminlike a GreaseMonkey script. (Or in my case, VionlentMonkey).#2021-05-0607:02thhellerI don't know to be honest. if they can open websocket connections and eval then in theory sure you could do it#2021-05-0607:02Rob KnightFirebase recently released a beta of their JS SDK which is designed to support tree-shaking and thus reduce bundle size. However, it doesn't seem to work! Replicating their JS code, I've translated import {getAuth} from "firebase/auth" as ["firebase/auth" :refer [getAuth]], which should import only that function. Instead it seems that everything is being imported, as it was in the previous (non-tree-shakeable) version. Is there anything else I ought to be doing here, or is this a case of Closure compiler not being able to use the same strategy as Rollup/Webpack would?#2021-05-0607:03thhelleryes, that kind of "tree shaking" currently refers to something only js tools do, not the closure compiler#2021-05-0607:04Rob KnightOk, thanks!#2021-05-0607:02thhellerbut I don't know enough about how they work at all to be sure#2021-05-0607:04BenjaminThey are pretty simple in that they more or less just inject a javascript file into a given webpage as if that webpage loaded it. Like a content script in a browser extension, except without the security restrictions. (IE. Eval works).#2021-05-0607:08thhellerso in theory you can just make a normal :browser build#2021-05-0607:08thhellerand then manually inject a <script src=":port/script.js"> into the page from the script#2021-05-0607:09thhellermight need to tweaks some stuff like :asset-path and :devtools-url though#2021-05-0607:09thhellernever tried it but might work#2021-05-0607:12BenjaminOkay, thanks! I'll look into it more and see if I can figure it out.#2021-05-0607:35Jakob DurstbergerDoes anyone know what is wrong with the following snippet?
(ns main
  (:require ["@aws-sdk/client-dynamodb" :refer [DynamoDBClient ListTablesCommand]]))

(DynamoDBClient. #js {:region "eu-west-2"})
The error I am getting is: shadow.js.shim.module$$aws_sdk$client_dynamodb.DynamoDBClient is not a constructor I translated this from https://www.npmjs.com/package/@aws-sdk/client-dynamodb
import { DynamoDBClient, BatchExecuteStatementCommand } from "@aws-sdk/client-dynamodb";

const client = new DynamoDBClient({ region: "REGION" });
#2021-05-0607:38thhellerlooks fine#2021-05-0607:38thhellertry adding an :as to the :require and logging that to see what it is#2021-05-0607:39thhelleralso check that there are no other errors during load#2021-05-0607:39thhelleraws has in the past written code that only worked with webpack, might be the case here too#2021-05-0607:40thhellercan't help further though, gotta go#2021-05-0607:40Jakob Durstberger> also check that there are no other errors during load I didn’t restart the REPL after adding new dependency facepalm Thank you#2021-05-0609:05Mikko HarjuHi! What would be the best way to access goog-defines (or any other setting if this is not feasible, defined in shadow-cljs.edn) in macro context to prevent generating code if a flag is set?#2021-05-0609:25Mikko HarjuAnswering myself: (get-in @env/*compiler* [:options :closure-defines])#2021-05-0612:48FHEGiven that the project structure created by running `
npx create-cljs-project my-project
does not include any index.html` (or a folder for CSS, as far as I can tell), how should I add it? I mean where? Somewhere in the project folder? If so, then do I need to add any pointer to where it is anywhere? And would I need to manually have it point it at wherever my main output JS file is for a given build (test vs develop vs release)?
#2021-05-0616:16thheller@factorhengineering the readme covers this https://github.com/thheller/shadow-cljs#quick-start css files you just put somewhere in the public folder and use link it from the HTML.#2021-05-0618:08FHE@thheller Thank you! I had been combing through the larger https://shadow-cljs.github.io/docs/UsersGuide.html but couldn't find it there. So I guess none of the automagic goodness really touches the .html file(s?) or .css file(s), and where things get put doesn't really matter other than making sure the normal linking in the index.html file (to the .css and to the .js file, where the name of the .js file would be whatever the compilation output is) is correct? Fair enough. 👍#2021-05-0618:27thhellercss is not related to js in any way. they both just get included in the html and do their stuff#2021-05-0618:28thhellershadow-cljs doesn't handle generating/compiling css in any way but it does offer some basic hot reloading if you modify the file#2021-05-0619:02FHE...but the location of the .css files don't matter because shadow-cljs knows where they are based on the reference in the index.html file? OK, great. I'm probably just make a css folder under src for projects where I use CSS.#2021-05-0619:04thhellerseems like you misunderstand how this works#2021-05-0619:04thhellerI said "public" not src#2021-05-0619:04thhellerthe public folder is the folder served by the web server, so all files in that (including subdirectories) are reachable via http#2021-05-0619:05thhellerso you create public/css/foo.css and link it in your html via <link rel="stylesheet" href="/css/foo.css">#2021-05-0619:06thhellerif you intend to build css using other tools that is fine, but shadow-cljs only cares about the final file in the public folder#2021-05-0619:06thhellerhow it got there is not relevant as far as shadow is concerned#2021-05-0619:07thhellerbut all of this is basic html/css stuff, it has absolutely nothing specific to do with shadow-cljs#2021-05-0619:15thhellerthe path you use is also completely up to you, as long as it is in the public folder it doesn't matter#2021-05-0619:15thhellerthat isn't even shadow-cljs caring about it at all, its the browser needing to load it over http and only seeing what is in the public folder#2021-05-0619:15thhelleror whatever other webserver you intend to use#2021-05-0619:17FHEI do understand those basics. I was just wondering where those basic files go (after getting over my initial shock that they weren't auto-generated for the project), and yes I thought maybe those basic files got acted on in some way by the tools.#2021-05-0619:18thhellerwell for hot-reloading it basically just watches css files in the public folder and reloads them on change, but that is the only thing shadow-cljs does regarding css files#2021-05-0619:21FHEI can't even find a public folder. I guess I need to make one myself under src?#2021-05-0619:24thhelleragain .. the readme covers this ...#2021-05-0619:24dpsuttonhttps://github.com/dpsutton/asg-ignite-presentation here's a presentation i did that has a walkthrough and a sample app with shadow if you think that might help#2021-05-0619:25FranklinHello... would it be possible to use shadow-clj with a backend server that runs on the JVM? I have looked through the documentation at https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http but cant find a good answer to this#2021-05-0619:26thhellersure, just run it separately. shadow-cljs doesn't care which server you use and the server doesn't need to do anything special. just serve the files from disk#2021-05-0619:31Franklinthanks#2021-05-0619:41Franklin@thheller if I'm serving the compiled JS files from my own server.. do you think hot reloading will still work?#2021-05-0619:42FranklinI don't think so, but I'd like to hear what you think#2021-05-0619:44thhellerit just works. hot-reload is not dependent on the server that served the files. that is handled by the websocket connection the compiled code opens, which will talk to the shadow-cljs watch server directly#2021-05-0619:45thhelleras far as your webserver is concerned there are just some static .js files on disk somewhere that you expose via http#2021-05-0619:46Franklinalright, thanks again#2021-05-0619:25thhellerthe public folder is not under src, it is in your project root#2021-05-0619:33FHEThere's no public folder right now, so I guess I have to create it there. So in the root? OK. Scrubbing through the longer guide (Users Guide), I see lots of references to things being output to /public/js/ or /public/css/, but no reference to what the parent folder of public is, or of any files needing to be put there manually. I do see the part about setting the watchdir to public (which I guess I'm supposed to assume is my-project/public?) in order to have CSS reloading. ...but then there's a part about testing that mentions /resources/public/js/test/, which looks like a public folder not in the root. Actually the example given in the early 1.4.3 "Convensions Used" section mentions resources/public/js/ as well. Sorry just trying to wrap my head around this.#2021-05-0619:35thhellerall paths mentioned are always relative to the project root, the folder your shadow-cljs.edn is in#2021-05-0619:35thhelleryou incorrectly added a leading /, you may use that but that would make it an absolute path outside your project folder#2021-05-0619:36FHEJust trying to indicate folder. I guess that's obvious. I can drop those first and last slashes.#2021-05-0619:37thhellerthe leading slash is very important when talking about this stuff, so it does matter whether it is there or not#2021-05-0619:37FHEDid not think it would be an absolute path without a drive or net location at the beginning, though. Maybe it's a Linux thing? It assumes /a/b/c means ~/a/b/c ?#2021-05-0619:37thhelleran absolute path is an absolute path in your filesystem root#2021-05-0619:38FHEI mean (whateverdrive)/home/a/b/c#2021-05-0619:38thhellerso /public/js would be c:\public\js on windows or just /public/js in linux#2021-05-0619:38thhellerand no /a/b/c does NOT mean ~/a/b/c#2021-05-0619:38FHEOK, so not even home. Root of the whole drive. Got it.#2021-05-0619:41FHEIn @dpsutton's presentation I see reference to folder public, which I now get is my-project/public. So I should ignore the other kind of example from the User Guide, with resources/public?#2021-05-0619:43thhellerthats just another folder, your config decides which folders you use. those names are YOUR choice, name it whatever makes sense for you. I use public everywhere. other people prefer resources/public. others use dist, target, web or whatever else may fit#2021-05-0619:46FHEOK. I'll stick with that. So at any point does that get duplicated? I have hit upon the concept of shadow-cljs having multiple targets. I would guess the index.html file in public gets used for a web release (and test?) but there is some kind of other output for, say, mobile or desktop(/server)?#2021-05-0619:48thhellerthat all depends on what you are building. as I said before if you build a react-native app or a node-script those will not have html files at all#2021-05-0619:50FHEOK maybe what I'm talking about only makes sense for dev vs release vs test. 1 of those uses the 'real' original index.html, and the others use some kind of auto-duplicated one? I only suggest that because I think I saw something like that in the guide. If there is only ever the one file, well I'm happy to be wrong because that would be simpler.#2021-05-0619:51thhellerno, shadow-cljs will never duplicate any html for you#2021-05-0619:52thhellerand again .. that entirely depends on what you are building. I pretty much always have a CLJ server generating my HTML for me, so I never have a static index.html on disk anywhere#2021-05-0619:52thhellerand my dev html I have is identical to the release html in all cases#2021-05-0619:53FHEOh right...hiccup? Yes, another thing I need to learn how to set up.#2021-05-0619:54thhellerwell I also have a really old rails app generating some HTML, doesn't really matter where the html is coming from#2021-05-0619:54FHEIt does sound like there are multiple copies of index.html, though. If not auto-generated, then at least put in place manually for the different web targets if there are more than one.#2021-05-0619:55thhellerif what you are building requires multiple html files then you'll have multiple html files yes#2021-05-0620:10FHE• I meant multiple copies, just based on the following from the User Guide: • "Remember that the test directory will have the index.html, and a js folder." and • "https://shadow-cljs.github.io/docs/UsersGuide.html#_generated_output_in_code_test_dir_code`:test-dir` The output includes two primary artifacts in your test-dir folder: index.html - If and only if there was not already an index.html file present. By default the generated file loads the tests and runs init in the :runner-ns. You may edit or add a custom version that will not be overwritten. #2021-05-0620:11FHE...but I'm happy to ignore that possibility for now. I'm a long way off from doing specific test builds I would think.#2021-05-0620:28FHEThank you for your help. As painful as it might have been for you to realize a person out there doesn't know this already by the way, I'm really glad our conversation meandered into Linux folder reference convention. I've done some things in Linux before and am still surprised that /x/y/z could ever be considered an absolute path when it doesn't mention a drive (and when it differs so little from x/y/z), like C:/x/y/z .#2021-05-0620:30FHEMaybe I'm a strange case, but I would suggest actually adding that to https://shadow-cljs.github.io/docs/UsersGuide.html#_conventions_used . (i.e. "References to folders in this book (as in many types of code (html/css/js/...) are usually relative and of the form folder-x or folder-x/subfolder-y which indicates the parent of the top folder referred to (folder-x in both cases above) is the root project folder.")#2021-05-0620:32FHEEven more helpful would be throwing in some early info on index.html, i.e. right under the npx command in https://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code`npm`the text could be expanded to "This will create all the necessary basic files and you can skip the following commands. Note that index.html is not considered a basic file, and for projects which would need one (web projects), it will need to created manually. A popular practice is to also create a 'public' folder in the project root folder and create the index.html there. Any css files would also need to be created manually (or by some other method outside the scope of this book), and could be put in a new folder public/css ."#2021-05-0620:33thhellerI think you have the wrong expectations here#2021-05-0620:33thhellerthere are far better guides/tutorials and even video courses to teach you specific things. like building a web focused thing#2021-05-0620:34thhellershadow-cljs is just a generic build tool that can do many things. I cannot possibly cover all of them, I simply do not have the time to do so#2021-05-0620:35thhellerhttps://github.com/day8/re-frame-template for example gets you a fully running web thing out of the box#2021-05-0620:35thhellercreate-cljs-project by intention is minimal and does NOT provide and target specific things#2021-05-0620:35thhellerthere are simply too many options, I cannot cover them all#2021-05-0620:35FHELike I said, I fully admit I don't have the same background knowledge of many or even most other readers of that guide, but I'd like to think it was not completely crazy of me to assume that 'all the necessary basic files' for a CLJS project would include index.html and maybe even a single .css file. 😉#2021-05-0620:36FHEI mean I know that was wrong now, but... Haha.#2021-05-0620:38thhellerthere is also https://github.com/filipesilva/create-cljs-app which maybe better suited for your needs, that also generates much more web centric stuff (including html and css 😉)#2021-05-0620:40FHEYour first link scares me a bit, what with needing leiningen (I thought I heard using shadow-cljs would mean not needing to also use leiningen) and node.js (I thought...still think actually...node.js was for server-side/desktop, but maybe it's there because it generates front-end and back-end.#2021-05-0620:41thhelleryou already used node.js when you executed npx create-cljs-project#2021-05-0620:41thhellernpx is part of npm which comes with node#2021-05-0620:43thhelleryou don't need to use leiningen, but some people prefer to do so. so some templates use it, many also use deps.edn. those are all valid options, as I said ... impossible for me to cover them all#2021-05-0620:52FHESame with re-frame, actually. I was trying to minimize the number of new things I need to learn at once (WSL2 + Linux CLI + Doom Emacs (vi) + CLJS + <some build tool, which I chose to be shadow-cljs based on recommendations based on it being able to handle a lot>), but I accept your challenge of adding re-frame to that soon. 😎 I'll lean toward deps.edn over leiningen, though, just since it seems simple (just an actual file).#2021-05-0620:52FHEI'll dive into your second link even sooner, though. Thanks again.#2021-05-0700:01sergey.shvetsHi, I'm having a little problem that annoys me and I'm pretty sure I'm doing something wrong. Every time I restart shadow-cljs server I have to remove .shadow-cljs/builds folder manually or otherwise I have a console full of errors on the screenshot below. It sometimes burps on optimized builds also, but if I clean the build folder everything is fine. Is it necessary to clean the build folder before each start? I don't remember doing this for my last project.#2021-05-0704:31Aronhow do you restart shadow-cljs#2021-05-0705:18sergey.shvetsI run it with VS Code Terminal/Calva npx shadow-cljs watch app and then kill it with Ctrl-c once I'm done working.#2021-05-0705:24Aronand then try running it again with watch?#2021-05-0705:25AronI always do shadow-cljs restart when I want to start, because with wsl I often can't cleanly exit. I run this manually, but an npm script should work. Then I start the web interface to shadow-cljs on 9630 and press watch there.#2021-05-0707:03thheller@bear-z you shouldn't need to remove the cache folder ever so whatever is happening could be considered a bug. but I cannot tell what you are doing so without a reproducible example I can't say much. might be some bad config. might be 2 instances of shadow-cljs running for the project and interfering with each other. might be bad macros, really can't say.#2021-05-0715:13sergey.shvetsThanks. I'm using one alpha library that wraps react. How do I debug bad macros? I'm suspicious it may cause it. I want to get to the bottom of it, so it won't blow up in my face one day.#2021-05-0715:14sergey.shvetsI would appreciate any pointers on what to look on.#2021-05-0715:15thhellernot a clue, would need to see actual code and actual build configs#2021-05-0716:19sergey.shvetsI'll try to come up with a minimal reproducible example and share it once I pinpoint what's causing it. Thank you for your prompt responses and for confirming that it's indeed a problem. And for shadow-cljs in general 🙂#2021-05-0711:02codeasoneI'm finally moving over the shadow-cljs and have started shadow-cljs watch :app in the terminal, which has run through successfully to Build completed. but I'm having troubling jacking into cljs via cider with the option shadow for repl-type and :app for the cljs build selection:
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app))
;;
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
shadow-cljs has not been started yet!
In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it.
If you have a shadow-cljs server or watch running then you are not connected to that process.
would welcome some advice on how to proceed. This is with CIDER 1.1.0 (package: 20210422.802) (Plovdiv)
#2021-05-0711:12codeasoneIf I cider-connect-sibling-cljs to localhost:9123 followed by shadow-select and :app build then I just see:
:missing-nrepl-middlewareuser>
Confused
#2021-05-0711:16codeasoneWith the incantation below to resolve the missing NREPL middleware warning:
(eval . (progn
         (make-variable-buffer-local 'cider-jack-in-nrepl-middlewares)
         (add-to-list 'cider-jack-in-nrepl-middlewares "shadow.cljs.devtools.server.nrepl/middleware")))
in my .dir-locals I just land on the same issue:
;; ClojureScript REPL type: shadow-select
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/nrepl-select :app))
;;
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
shadow-cljs has not been started yet!
In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it.
If you have a shadow-cljs server or watch running then you are not connected to that process.
#2021-05-0711:30codeasonecider-connect-cljs to `localhost:9123` followed by `shadow-select` and `:app` however does gives me a REPL, I can (js/alert ...) etc, but working on a cljs file and jumping to REPL still gives cider--no-repls-user-error: No cljs REPLs in current session "Farillio/app:localhost:9123" and #?(:cljs ...) code in cljc files is still grayed out (no syntax highlighting) 😢#2021-05-0711:32codeasoneWas really hoping I could just run the shadow-cljs watch... in a terminal, add
(cider-default-cljs-repl . shadow)
     (cider-shadow-default-options . "app")
to my dir-locals.el and then just cider-jack-in-clj&cljs - should/could it be that simple?
#2021-05-0712:01thheller@codeasone I don't use emacs so the help I can provide is rather limited. to me it looks like you didn't add the cider-nrepl middleware to your dependencies. when you run shadow-cljs watch separately cider cannot inject it automatically so you need to add it manually. don't know how jack-in stuff works these days, but connecting remotely is totally fine and even what I'd recommend doing#2021-05-0713:05codeasoneThanks for your input @thheller - the cider-nrepl dependencies are auto-injected by cider - I'm making some progress with:
(cider-default-cljs-repl . custom)
     (cider-custom-cljs-repl-init-form . "(do (user/cljs-repl))")
     (eval . (progn
               (make-variable-buffer-local 'cider-jack-in-nrepl-middlewares)
               (add-to-list 'cider-jack-in-nrepl-middlewares "shadow.cljs.devtools.server.nrepl/middleware")))
and:
;; 
(defn cljs-repl
  ([]
   (cljs-repl :app))
  ([build-id]
   (server/start!)
   (shadow/watch build-id)
in user.clj I'm seeing the following on cider-jack-in-clj&cljs and I can force (re)compiles with
#2021-05-0713:06codeasonebut it's not recompiling on source changes and visiting the app I see:#2021-05-0713:08codeasoneHo-hum... looks like I'm going to have to dig into the cider code and gain greater familiarity with shadow-cljs to debug#2021-05-0713:11thheller@codeasone the stale output warning could mean that you now have two instances of shadow-cljs running. that is what I meant by connecting vs. jack-in.#2021-05-0713:12thhelleryou are now starting the server in embedded mode in the JVM. you are not connecting to the shadow-cljs watch you started separately#2021-05-0713:13thheller> the cider-nrepl dependencies are auto-injected by cider#2021-05-0713:13thhelleras I said .. that is only done when you jack in .. that is NOT done if you connect remotely#2021-05-0713:19codeasoneI think I've found a working solution with none of the hacks above#2021-05-0713:20thhellerno clue how current this is either https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2021-05-0713:20codeasonecider-jack-in-clj with clojure-cli to run the backend, then separately cider-jack-in-cljs (no piggy-backing) with shadow-cljs#2021-05-0713:21thhellerI'd suggest connecting but jack-in is fine too#2021-05-0713:23codeasonewatcher is running fine, and the two REPLs are associated with the correct clj|cljs buffers for jump-to-repl purposes - removed all hacks in dir-locals.el and user.clj 🎉#2021-05-0713:23codeasonethanks for your patience and consideration @thheller#2021-05-0714:55Franklinhello, getting some errors while using shadow-cljs that I can't figure out. please have a look#2021-05-0714:55Franklin
component.cljs:127 Error rendering component (in app.hello.hello)
reagent$impl$component$do_render @ component.cljs:127
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
renderRoot @ react-dom.development.js:19436
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 2 more frames
component.cljs:127 Error rendering component (in app.hello.hello)
reagent$impl$component$do_render @ component.cljs:127
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 6 more frames
core.cljs:56 Uncaught Error: Assert failed: Component must not be nil
c
    at Object.reagent$core$adapt_react_class [as adapt_react_class] (core.cljs:56)
    at $hello$hello [as reagentRender] (hello.cljs:15)
    at eval (component.cljs:86)
    at Object.reagent$impl$component$wrap_render [as wrap_render] (component.cljs:91)
    at Object.reagent$impl$component$do_render [as do_render] (component.cljs:121)
    at eval (component.cljs:271)
    at Object.reagent$ratom$in_context [as in_context] (ratom.cljs:44)
    at Object.reagent$ratom$deref_capture [as deref_capture] (ratom.cljs:57)
    at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (ratom.cljs:539)
    at cmp.reagent$impl$component$wrap_funs_$_render [as render] (component.cljs:271)
reagent$core$adapt_react_class @ core.cljs:56
app$hello$hello @ hello.cljs:15
eval @ component.cljs:86
reagent$impl$component$wrap_render @ component.cljs:91
reagent$impl$component$do_render @ component.cljs:121
eval @ component.cljs:271
reagent$ratom$in_context @ ratom.cljs:44
reagent$ratom$deref_capture @ ratom.cljs:57
reagent$ratom$run_in_reaction @ ratom.cljs:539
reagent$impl$component$wrap_funs_$_render @ component.cljs:271
finishClassComponent @ react-dom.development.js:14742
updateClassComponent @ react-dom.development.js:14697
beginWork @ react-dom.development.js:15645
performUnitOfWork @ react-dom.development.js:19313
workLoop @ react-dom.development.js:19353
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
replayUnitOfWork @ react-dom.development.js:18579
renderRoot @ react-dom.development.js:19469
performWorkOnRoot @ react-dom.development.js:20343
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 10 more frames
react-dom.development.js:17118 The above error occurred in the <app.hello.hello> component:
    in app.hello.hello

Consider adding an error boundary to your tree to customize error handling behavior.
Visit  to learn more about error boundaries.
logCapturedError @ react-dom.development.js:17118
logError @ react-dom.development.js:17154
expirationTime.callback @ react-dom.development.js:18066
commitUpdateEffects @ react-dom.development.js:16434
commitUpdateQueue @ react-dom.development.js:16464
commitAllLifeCycles @ react-dom.development.js:17384
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
commitRoot @ react-dom.development.js:18949
eval @ react-dom.development.js:20419
exports.unstable_runWithPriority @ scheduler.development.js:256
completeRoot @ react-dom.development.js:20418
performWorkOnRoot @ react-dom.development.js:20347
performWork @ react-dom.development.js:20255
requestWork @ react-dom.development.js:20229
scheduleWork @ react-dom.development.js:19912
updateContainerAtExpirationTime @ react-dom.development.js:20573
updateContainer @ react-dom.development.js:20658
ReactRoot.render @ react-dom.development.js:20954
eval @ react-dom.development.js:21091
unbatchedUpdates @ react-dom.development.js:20460
legacyRenderSubtreeIntoContainer @ react-dom.development.js:21087
render @ react-dom.development.js:21156
reagent$dom$render_comp @ dom.cljs:19
eval @ dom.cljs:48
eval @ dom.cljs:38
app$core$render @ core.cljs:9
app$core$main @ core.cljs:14
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
Show 3 more frames
shadow.module.main.append.js:4 An error occurred when calling (app.core/main)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:577
env.evalLoad @ main.js:1670
(anonymous) @ main.js:1840
main.js:1672 An error occurred when loading shadow.module.main.append.js
env.evalLoad @ main.js:1672
(anonymous) @ main.js:1840
main.js:1673 Error: Assert failed: Component must not be nil
c
    at Object.reagent$core$adapt_react_class [as adapt_react_class] (core.cljs:56)
    at $hello$hello [as reagentRender] (hello.cljs:15)
    at eval (component.cljs:86)
    at Object.reagent$impl$component$wrap_render [as wrap_render] (component.cljs:91)
    at Object.reagent$impl$component$do_render [as do_render] (component.cljs:121)
    at eval (component.cljs:271)
    at Object.reagent$ratom$in_context [as in_context] (ratom.cljs:44)
    at Object.reagent$ratom$deref_capture [as deref_capture] (ratom.cljs:57)
    at Object.reagent$ratom$run_in_reaction [as run_in_reaction] (ratom.cljs:539)
    at cmp.reagent$impl$component$wrap_funs_$_render [as render] (component.cljs:271)
#2021-05-0714:56dpsutton> Error: Assert failed: Component must not be nil #2021-05-0714:57dpsutton> An error occurred when calling (app.core/main) #2021-05-0714:57dpsuttonthese stand out to me#2021-05-0714:57Franklinhere's the all the code https://github.com/FrankApiyo/shadow-cljs-test#2021-05-0714:57Franklinnot certain were I have a nil component#2021-05-0715:11thheller
(ns app.hello
  (:require [reagent.core :as r]
            ["react-data-grid" :refer [ReactDataGrid]]))
#2021-05-0715:11thhellerthis is probably incorrect#2021-05-0715:11Franklinyep! noticed that the issue is here
[(r/adapt-react-class  ReactDataGrid)
   {:columns [{:key 0 :name "test"}] :rows [{:id 1 :title "two"}]} ""]
#2021-05-0715:11thhellertry
(ns app.hello
  (:require [reagent.core :as r]
            ["react-data-grid" :default ReactDataGrid]))
#2021-05-0715:12thhellersee the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-05-0715:12thhellerthe JS example has import ReactDataGrid from 'react-data-grid'; so the :default should be correct#2021-05-0715:14thhellerand you don't need the adapt-react-class#2021-05-0715:14Franklinwow, yea, that worked!#2021-05-0715:14thhellerJust [:> ReactDataGrid {...}] should be ok#2021-05-0715:15Franklinthank you so much#2021-05-0715:08codeasoneThis open cider issues reflects a lot of the pain I've been feeling today trying to get a shadow-cljs workflow arranged with a large clj|cljc|cljs project https://github.com/clojure-emacs/cider/issues/2946#2021-05-0715:09codeasoneI'm having to (still) do a bit of a dance with sesman-link-with-project and separate cider jack-ins for tool.deps backend and shadow front-end to get something work-able#2021-05-0715:34iGELI suspect that shadow-cljs should handle updates to the package.json & yarn.lock fine, right? For me it usually ends in a loop trying to compile over and over again, until I kill it, with this error:
[:admin] Compiling ...
[:admin] Build failure:
package in /webapp/cljs/admin/node_modules/nouislider specified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["distribute/nouislider.js"], :package-dir #object[java.io.File 0x669ecd61 "/webapp/cljs/admin/node_modules/nouislider"]}
ExceptionInfo: package in /webapp/cljs/admin/node_modules/nouislider specified entries but they were all missing
	shadow.build.npm/find-package-main (npm.clj:186)
	shadow.build.npm/find-package-main (npm.clj:159)
	shadow.build.npm/find-package-require* (npm.clj:200)
	shadow.build.npm/find-package-require* (npm.clj:194)
I guess I've updated nouislider here. I also started to delete the .shadow-cljs dir to make sure everything is fresh
#2021-05-0715:34iGELI run it inside of Docker, this might be an issue?#2021-05-0715:39thhellerthe error message is telling you that the package.json refered a file that does not exist#2021-05-0715:39thhellerso it has something like "main":"./foo.js" or so but foo.js does not exist in the package (in your case distribute/nouislider.js)#2021-05-0715:40thhellerdon't know enough about what you are doing to comment further#2021-05-0715:49iGELYeah, I imagine it's hard to debug from there. The files are there (in a volume), restarting shadow-cljs fixes it. I blame Docker for now#2021-05-0721:02dvingoI'm using shadow-cljs 2.12.5 on macOS 10.15.6 (Catalina) when running a watch process for a browser target I'm seeing builds go into an infinite loop: [:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.46s) [:app] Compiling ... [:app] Build completed. (1341 files, 270 compiled, 0 warnings, 15.65s) [:app] Compiling ... [:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.27s) [:app] Compiling ... [:app] Build completed. (1341 files, 270 compiled, 0 warnings, 16.69s) [:app] Compiling ... as soon as the compilation is complete it starts again, and the shadow jvm process spikes the CPU:#2021-05-0721:03dvingoHas anyone else experienced this behavior? I could maybe try upgrading the OS version#2021-05-0721:03dpsuttoni think i've seen this happen if the compiled output is on the classpath?#2021-05-0721:03dpsuttonaka the output appears as input which triggers output which triggers ...#2021-05-0721:04dvingohmm, thanks for the suggestion. I'll look into that. It's odd though because there's a team of people working on this so I would have thought they'd see it also.#2021-05-0808:05thhellerhmm odd since it is always compiling the same amount of files. maybe some external tool (eg. your editor) touching all the files all the time?#2021-05-0808:06thhellerbut yeah most commonly this was caused by having :output-dir into something that is also a :source-paths entry#2021-05-0811:42dvingoThanks for the tip - I'll take a look again next week#2021-05-0809:33martinklepschWith the node-library target, is there a way to include all dependencies from node_modules in the target JS file? (asking because that would be useful in the context of cloud function setups like AWS Lambda)#2021-05-0809:54thhelleryou can post-process the :output-to with https://github.com/vercel/ncc or just include the proper node_modules for aws#2021-05-0809:55thhellerI wonder why everyone keeps asking this? Is this not the normal thing you'd do with AWS? https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#2021-05-0809:56thhellerI've never done anything with AWS so I really don't know what the best practices for this are but it seems straightforward?#2021-05-0810:25martinklepschYeah, you’re right, I think just packaging with node_modules also works perfectly fine#2021-05-0811:13martinklepschActually ncc does seem nice. One problem I’m seeing with it is that the source maps probably wouldn’t be accurate anymore(?) did anyone run into that?#2021-05-0813:36thhellerfwiw shadow-cljs also has some basic support for this directly. it does however have some issues so not all packages work. https://github.com/thheller/shadow-cljs/issues/290#issuecomment-459818765#2021-05-0813:36thhellerdon't know about source maps and ncc#2021-05-0813:43thhellerin general I'd likely recommend creating a dedicated folder that you'll send to AWS#2021-05-0813:44thhellercreate a package.json in that folder and run npm install --production#2021-05-0813:44thhellerthat'll not install devDependencies and the resulting node_modules should be much smaller#2021-05-0813:44thhellerthe just :output-dir "that-folder/lib.js" and just zip and deploy that-folder#2021-05-0812:00martinklepschWhats the performance impact of having lots of builds? If the cache is shared between them it shouldn’t be too bad right? (Is it?)#2021-05-0813:33thhellercache is not shared between builds#2021-05-0818:30martinklepschSo I guess that means initial build times grow with number of builds. What do you think would the impact be if you had, say 20 builds, for incremental builds? I realize this is a bit outside of the usual but just curious what your potential concerns would be with such setup#2021-05-0821:57thhellerI don't have a clue what you are building so impossible to comment#2021-05-0821:58thhellershadow-cljs is very flexible so if the default targets don't do what you need it would be relatively easy to add one that fits better#2021-05-0822:18martinklepschI guess what I’m asking is how shadow will perform with one build vs. 20 identical ones with different target files. #2021-05-0822:21thhellerhow am I supposed to answer that when I don't have a clue what you are building? shadow-cljs doesn't care, you can have a thousand builds, it does not matter to shadow. your computer will probable scream and blow up since memory and cpu consumption will go through the roof though#2021-05-0822:21thhellerI do not know what you are doing. do you intend to build all the builds in parallel? sequentially? watch all? just release all?#2021-05-0822:22thhellerwhat is the point of having 20 identical builds with different target files? why is it not one build and you copy the output file 20 times?#2021-05-0822:22thhelleryou are only giving me very vague information so I really cannot give you any reasonable answer 😛#2021-05-0822:45martinklepschOk fair enough 😄 Maybe I’ll try to write up more specific information tomorrow 🙂#2021-05-0812:13Karol Wójcik@martinklepsch For AWS lambda the best possible approach is to pack dependencies and ship them as a layer#2021-05-0812:19martinklepschAh, that’s interesting! Can you explain a bit more how this would manifest? Like if I have a lot of node_modules I’d put those in a layer and then the deploy payload would get smaller I guess? Does it have any impact on performance? Right now with ncc + advanced + zip I get pretty tiny lambdas (25kb) and the deployment story of a single JS file just seems more straightforward.#2021-05-0812:20martinklepschSo I’m thinking layers yes, but probably only once your individual lambdas get too big?#2021-05-0812:26martinklepsch@UJ1339K2B what do you use for deployment and resource automation? I just played around with https://arc.codes/ a bit and I’m really liking how little assumptions it makes around build tools and what not#2021-05-0812:43Karol WójcikLayers are super useful when you have a lot of dependencies since you pack your dependencies once. For this I strongly recommend trying yarn. I started using it 2 years ago and now I now that I will never go back npm. Regarding performance it should not vary much where dependencies are stored. I'm already doing the same for babashka runtime and I'm happy with the results. If your lambdas are 25kb it's probably not worth trying layers though. For deployment and resource automation I'm using AWS SAM. I have already used Serverless Framework and I find AWS SAM the simplest and the best solution. I have never tried Architect , but for me it's just a sugar around AWS SAM and cloudformation. For me having all resources of the stack in template.yml is super simple. https://github.com/FieryCod/holy-lambda/blob/master/examples/bb/native/sqs.example/template.yml Btw I'm planning to add support for Node.js in holy-lambda, so if you would like to help me out it would be lovely.#2021-05-0822:05martinklepschwow, this looks very cool @UJ1339K2B, I’ve just been thinking that babashka tasks seems like the perfect foundation for this type of thing
#2021-05-0822:38martinklepschUnfortunately he cljdoc build is broken btw, if you run the following in your repo you can see an issue with cljdoc.edn
curl -fsSL  | bash -s doc/cljdoc.edn
#2021-05-0822:39martinklepschThis can also be used as a CI step and will fail if there is an issue#2021-05-0822:43martinklepschhttps://github.com/FieryCod/holy-lambda/pull/39#2021-05-0823:46martinklepsch> so if you would like to help me out it would be lovely. I’ve played with shadow-cljs quite a bit this weekend to see how it worked with different packaging strategies/deployment tools (like Architect) — if that sounds interesting maybe we can have a chat?#2021-05-0909:14Karol WójcikLet's have a chat then 🙂#2021-05-0812:30martinklepschDid some exploration of using https://arc.codes to deploy CLJS to AWS Lambda today: https://github.com/martinklepsch/shadow-cloud-fns/tree/master/trying-arc — it all works pretty well. The only thing I’m still a little unsure about is the ncc source maps situation https://clojurians.slack.com/archives/C6N245JGG/p1620472416489100#2021-05-0816:47pezI’m trying to set up a React Native project using Fulcro 3. I get a strange exception when I run shadow-cljs watch :app. About piggieback. My deps.edn looks like so:
{:paths   ["src/main"]
 :deps    {org.clojure/clojure    {:mvn/version "1.10.1"}
           com.fulcrologic/fulcro {:mvn/version "3.4.21"}}

 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.742"}
                               thheller/shadow-cljs        {:mvn/version "2.12.5"}
                               binaryage/devtools          {:mvn/version "0.9.10"}}}}}
shadow-cljs.edn:
{:deps {:aliases [:dev]}
 :builds
 {:app
  {:target :react-native
   :init-fn 
   :output-dir "app"
   :devtools {:autoload true
              :preloads [shadow.expo.keep-awake]}}}}
The exception:
~/Projects/rn-fulcro-shadow(main|✚3…) % npx shadow-cljs watch :app
shadow-cljs - config: /Users/pez/Projects/rn-fulcro-shadow/shadow-cljs.edn
shadow-cljs - starting via "clojure"
WARNING: When invoking clojure.main, use -M
[2021-05-08 18:43:55.123 - WARNING] TCP Port 9630 in use.
[2021-05-08 18:43:55.363 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding if-ns at (cider/piggieback.clj:22:1). #:clojure.error{:phase :macroexpansion, :line 22, :column 1, :source "cider/piggieback.clj", :symbol if-ns}
        clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
        clojure.lang.Compiler.macroexpand (Compiler.java:7075)
        clojure.lang.Compiler.eval (Compiler.java:7161)
        clojure.lang.Compiler.load (Compiler.java:7636)
        clojure.lang.RT.loadResourceScript (RT.java:381)
        clojure.lang.RT.loadResourceScript (RT.java:372)
        clojure.lang.RT.load (RT.java:459)
        clojure.lang.RT.load (RT.java:424)
        clojure.core/load/fn--6839 (core.clj:6126)
        clojure.core/load (core.clj:6125)
        clojure.core/load (core.clj:6109)
        clojure.core/load-one (core.clj:5908)
Caused by:
ExceptionInInitializerError 
        java.lang.Class.forName0 (Class.java:-2)
        java.lang.Class.forName (Class.java:468)
        clojure.lang.RT.classForName (RT.java:2211)
        clojure.lang.RT.classForName (RT.java:2220)
        clojure.lang.RT.loadClassForName (RT.java:2239)
        clojure.lang.RT.load (RT.java:449)
        clojure.lang.RT.load (RT.java:424)
        clojure.core/load/fn--6839 (core.clj:6126)
        clojure.core/load (core.clj:6125)
        clojure.core/load (core.clj:6109)
        clojure.core/load-one (core.clj:5908)
        clojure.core/load-one (core.clj:5903)
Caused by:
ClassNotFoundException com.google.javascript.jscomp.AnonymousFunctionNamingPolicy
        jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:606)
        jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:168)
        java.lang.ClassLoader.loadClass (ClassLoader.java:522)
        java.lang.Class.forName0 (Class.java:-2)
        java.lang.Class.forName (Class.java:468)
        clojure.lang.RT.classForName (RT.java:2211)
        clojure.lang.RT.classForNameNonLoading (RT.java:2224)
        cljs.closure/loading--5569--auto----3990 (closure.clj:9)
        cljs.closure__init.load (:9)
        cljs.closure__init.<clinit> (:-1)
        java.lang.Class.forName0 (Class.java:-2)
        java.lang.Class.forName (Class.java:468)
#2021-05-0816:56p-himikTo add to thheller's answer, according to documentation, you simply don't need to specify any version of ClojureScript - shadow-cljs already depends on the needed one. That is, unless you need a very specific version of ClojureScript. https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2021-05-0817:45pezThanks! I'll send a PR on the fulcro book about it. #2021-05-0816:50thheller@pez wrong CLJS version. 2.12.x requires 1.10.844#2021-05-0817:58pezThanks. Will try it out when I'm back at the keyboard. But, I thought no piggieback was involved?#2021-05-0818:38thhellershadow-cljs does not use it but it is added for compatibility with stuff that expects it (eg. cider-nrepl)#2021-05-0822:10codeasoneI've prepared a minimal repo and README capturing the difficulties I encountered getting a shadow-cljs plus tools.deps project working well with cider after transitioning over from years of clojure-cli plus figwheel-main https://github.com/codeasone/starter-cider-tools-deps-shadow - it was certainly more painful than I'd like it to have been.#2021-05-0822:13thhellerthat seems to be much more complicated than it needs to be#2021-05-0822:15codeasoneyeah, I would have been delighted if I could just run watch in a terminal, and establish a sibling cljs REPL connection, but I can't make that work#2021-05-0822:16codeasoneswitching between and eval-ing forms in clj cljc and cljs code and having it target the correct REPL is essential for my workflow#2021-05-0822:16thhellerwhy not? I mean cider does have a remote connect open, but everything you described seemed to be based on jack-in?#2021-05-0822:22codeasoneI made a typo in one of the heading https://github.com/codeasone/starter-cider-tools-deps-shadow#jacking-in-to-clj-repl-and-adding-a-sibling-jack-in-for-shadow-cljs I actually tried establishing a M-x cider-connect-sibling-cljs which would have been ideal, but as I say didn't work out due to the way REPL sessions are managed.#2021-05-0822:24thhellerI do not have a clue what the commands are called in emacs. the way I work is I run my backend manually outside my editor, typically just lein repl. then I start shadow-cljs server separately.#2021-05-0822:25thhellerthen I connect to the .nrepl-port for my CLJ REPL and .shadow-cljs/nrepl.port for the CLJS REPLs#2021-05-0822:25thhellertwo separate processes, completely separate connections, nothing shared#2021-05-0822:25thhellerI would expect emacs to be capable of doing the same but I don't have a clue#2021-05-0822:26thhelleryou can instead run shadow-cljs in embedded mode so it runs in your backend process#2021-05-0822:26thhelleryou sort of flipped it and run your backend process in the shadow-cljs process. not something I recommend but you can do it.#2021-05-0822:31codeasoneA moment of inspiration struck me, I just wanted something that worked and fit my muscle memory of how to bring up my full-stack, I honestly don't know the intent behind shadow.user ns, and whether my usage is misuse, but I defer to your advice of course.#2021-05-0822:31thheller
1. Unhandled clojure.lang.ExceptionInfo
   shadow-cljs has not been started yet!  In embedded mode you need to call
   (shadow.cljs.devtools.server/start!) to start it.  If you have a shadow-cljs
   server or watch running then you are not connected to that process.
#2021-05-0822:32thhellerdid you ever try that? I mean running the shadow-cljs server in embedded mode in your backend process?#2021-05-0822:32thhellerI assume that is how you ran figwheel previously?#2021-05-0822:33thheller> Picking up on shadow-cljs has not been started yet! I try running shadow-cljs watch app in a separate terminal (which worked fine):#2021-05-0822:34thhellerrunning shadow-cljs watch will start a new JVM process, instead you are supposed to run (shadow.cljs.devtools.server/start!) in whatever JVM you were connected to when you got that error#2021-05-0822:35thheller> But I just started it!#2021-05-0822:36thhellerexactly the point, you started it separately but still talk to the old JVM#2021-05-0822:37codeasoneRe: figwheel I just invoke vanilla cider-jack-in-clj&cljs and it just works, clj REPL spins up - I (start)the backend server and figwheel is piggybacked in to the same cider session, all orchestrated by Emacs#2021-05-0822:37thhellerwhat is (start)? I'm guessing thats a user.clj function you have in your codebase that starts figwheel in embedded mode#2021-05-0822:37codeasonewanted to get to same single-step bring up under Emacs, that's the point of the repo#2021-05-0822:38codeasone(start) is just something to bring up the backend - just an example of something you might type into the REPL to start the HTTP server for instance#2021-05-0822:39codeasoneas per the demo-rig code, which I tried to keep as minimal as possible, but reflect the various moving parts I need to content with day-to-day in my production code.#2021-05-0822:39thhellerbut this is not minimal at all#2021-05-0822:40codeasoneokay, I wanted some clj some cljccode and some cljs code so I could ensure I could eval forms and the appropriate REPL would be targetted#2021-05-0822:41codeasoneI'm also learning to use shadow-cljs and understand it's capabilities in the process#2021-05-0822:41thhellersure I get that#2021-05-0822:43thhellerto me it sounds like all your were missing is instead of calling just (start) you also call (shadow.cljs.devtools.server/start!)#2021-05-0822:43thhelleror have the (start) do that for you wherever that was coming from. I assume you did something like that with figwheel#2021-05-0822:43codeasoneI'll try that out soon, thanks#2021-05-0822:44thhellerpoint is when you run cider jack-in that starts a JVM for you with a nrepl server. if you then run shadow-cljs watch separately you'll get a second JVM instance with its own nrepl server.#2021-05-0822:45codeasoneGoing to hit the sack now though, thanks for the feedback#2021-05-0822:45thhellerhow you deal with that in emacs I don't know. if emacs doesn't support two separate remote connections then you likely want to run shadow in embedded mode https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2021-05-0822:16thhellerbut you can also just run in embedded mode but you sort of flipped it to embed everything in shadow-cljs instead#2021-05-0822:16codeasoneI end up with two "sessions" in cider and the way they are managed is not smart enough#2021-05-0822:18thhelleradding a custom shadow.user ns is definitely not the way to go here#2021-05-0822:18codeasonethe only thing that works - and it works well - is to have cider-jack-in-clj&cljs control everything - it's also really simple to bring everything up with one key binding#2021-05-0909:59vinurshello, how can i use this remote in render file with electron
import {remote} from "electron";
when i import it ,it outputs
An error occurred when loading app.renderer.core.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2005
renderer.js:1563 TypeError: exports.existsSync is not a function
    at Object.shadow$provide.module$node_modules$electron$index (index.js:9)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at eval (js/cljs-runtime/app.renderer.core.js:3)
    at eval (<anonymous>)
    at Object.goog.globalEval (renderer.js:497)
    at Object.env.evalLoad (renderer.js:1560)
    at renderer.js:2005
env.evalLoad @ renderer.js:1563
(anonymous) @ renderer.js:2005
js/cljs-runtime/shadow.module.renderer.append.js:4 An error occurred when calling (app.renderer.core/start!)
eval @ js/cljs-runtime/shadow.module.renderer.append.js:4
goog.globalEval @ renderer.js:497
env.evalLoad @ renderer.js:1560
(anonymous) @ renderer.js:2006
renderer.js:1562 An error occurred when loading shadow.module.renderer.append.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2006
renderer.js:1563 TypeError: app.renderer.core.start_BANG_ is not a function
    at eval (js/cljs-runtime/shadow.module.renderer.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (renderer.js:497)
    at Object.env.evalLoad (renderer.js:1560)
    at renderer.js:2006
#2021-05-0910:34thhellernot enough code to comment. you are calling existsSync on something but I can't guess the code doing that.#2021-05-0910:50vinurs
const fs = require('fs');
const path = require('path');

const pathFile = path.join(__dirname, 'path.txt');

function getElectronPath () {
  if (fs.existsSync(pathFile)) {
    const executablePath = fs.readFileSync(pathFile, 'utf-8');
    if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
      return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath);
    }
    return path.join(__dirname, 'dist', executablePath);
  } else {
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
  }
}

module.exports = getElectronPath();
i found it in node_modules/electron/index.js
#2021-05-0910:51vinursusing "electron": "^12.0.6",#2021-05-0910:54thhellerI'm guessing you are not supposed to use that in the renderer?#2021-05-0910:55thhellerI don't use electron so I really cannot help much#2021-05-0910:55vinursyes, i just want to use dialog in electron.remote#2021-05-0910:18anonimitorafHi guys, I'm getting this error
The required JS dependency "entities/maps/entities.json" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js".

Dependency Trace:
	tung_frontend/devcards/core.cljs
	tung_frontend/devcards/text_chat.cljs
	node_modules/stream-chat-react/dist/index.js
	node_modules/react-markdown/with-html.js
	node_modules/react-markdown/lib/with-html.js
	node_modules/react-markdown/lib/plugins/html-parser.js
	node_modules/html-to-react/index.js
	node_modules/html-to-react/lib/parser.js
	node_modules/htmlparser2/lib/index.js
	node_modules/htmlparser2/lib/Parser.js
	node_modules/htmlparser2/lib/Tokenizer.js

Searched for npm packages in:
	/home/anonimito/work/pegleg/clojure/eviota-frontend/node_modules

See: 
I found this old shadow-cljs thread that contains this exact error message https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-20/1598004360.046400 but it doesn't seem to work for me. Relevant config:
:devcards {:asset-path "js/devcards"
                                    :modules {:main {:init-fn tung-frontend.devcards.core/main}}
                                    :compiler-options {:devcards true}
                                    :output-dir "resources/public/js/devcards"
                                    ;; :devtools {:httop-root "resources/public" :http-port 8281}
                                    :target :browser
                                    :build-options {:ns-aliases {devcards-marked
                                                                 tung-frontend.devcards.cljsjs.marked
                                                                 devcards-syntax-highlighter
                                                                 tung-frontend.devcards.cljsjs.highlight}}
                                    ;; See 
                                    :js-options {:resolve {"entities/maps/entities.json"
                                                           {:target :npm
                                                            :require "entities/lib/maps/entities.json"}}}}
I'm using thheller/shadow-cljs "2.11.4"
#2021-05-0910:25anonimitorafWeird, installing htmlparser2 manually seems to solve it. 😕#2021-05-0910:33thhellervery likely a dependency conflict#2021-05-0910:47anonimitorafRight, I see 2 versions of it (via yarn why)
=> Found "
#2021-05-0911:07Ivan Fedorovanyone had any issues with watching changes in Linux on Windows environment? I have a client, who has launched shadow-cljs watch app , then he changes a view file, but shadow doesn’t recompile. Perhaps may be some WSL issue. If shadow-cljs build is re-launched – then it updates the view. ---- UPD: My client found this https://stackoverflow.com/questions/66055215/emacs-cider-with-shadow-cljs-browser-settings-on-windows-wsl2-hot-code-reload/66061927#66061927, so suspicion moves strongly towards WSL conf. ---- UPD2: Fixed with SO instructions#2021-05-0911:10thhelleryes, common wsl2 problem#2021-05-0913:09naomarikI've done all my wsl2 development from within the linux FS and had no problems with any watchers.#2021-05-0913:24Aronsame here, vim and vscode, latter has own support for editing wsl projects, works very well#2021-05-0913:35thhellerthe problem happens when you edit the files from windows via the mounted fs. if you edit files from within the wsl distro that is fine#2021-05-1005:01metehanI have a project which runs perfectly when I use watch app but when I release with release app it gives some failed to loaderrors. How can I solve such problem.#2021-05-1005:02metehanthe error can be seen here -> https://uygulama.spill.web.tr/nightly#2021-05-1007:13thhellerwhich shadow-cljs version is this with? I fixed a couple issues regarding $jscomp not too long ago#2021-05-1007:14thhellerotherwise the easiest way to fix this increasing the :compiler-options {:output-feature-set :es6} or even higher :es7, :es8#2021-05-1007:14thhellerdepending on how many really old browsers you need to support#2021-05-1007:18thhellerin the older versions it was sometimes enough to delete the .shadow-cljs/builds cache#2021-05-1023:53metehanI had "shadow-cljs": "^2.8.51" looks like I am far behind the current version. I don't need to support any old browser so I will just start to use latest version thank you#2021-05-1100:00metehanusing latest version and deleting builds solved my problem#2021-05-1016:06Endre Bakken StovnerSorry if this is an inappropriate channel but I am wondering how I can debug an import error. I am using luminus with the +shadow-cljs setting. I've added d3-dag to my :npm-deps in project.clj. I've also tried installing d3-dag manually from the command line. However, when I try to require it like this:
(require '["d3-dag" :as d3])
I get the error:
[:app] Compiling ...
[:app] Build failure:
IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError
	clojure.lang.Reflector.getInstanceField (Reflector.java:397)
	clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
	shadow.build.closure/js-error-xf/fn--45167 (closure.clj:536)
	clojure.core/map/fn--5862/fn--5863 (core.clj:2742)
	clojure.core.protocols/iter-reduce (protocols.clj:49)
	clojure.core.protocols/fn--8140 (protocols.clj:75)
	clojure.core.protocols/fn--8140 (protocols.clj:75)
	clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
	clojure.core/transduce (core.clj:6884)
	clojure.core/into (core.clj:6899)
	clojure.core/into (core.clj:6887)
	shadow.build.closure/throw-errors! (closure.clj:1093)
	shadow.build.closure/throw-errors! (closure.clj:1088)
	shadow.build.closure/convert-sources-simple* (closure.clj:1843)
	shadow.build.closure/convert-sources-simple* (closure.clj:1703)
	shadow.build.closure/convert-sources-simple (closure.clj:1989)
	shadow.build.closure/convert-sources-simple (closure.clj:1941)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1082)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1075)
	shadow.build.compiler/compile-all (compiler.clj:1333)
	shadow.build.compiler/compile-all (compiler.clj:1194)
	shadow.build.api/compile-sources (api.clj:256)
	shadow.build.api/compile-sources (api.clj:248)
	shadow.build/compile (build.clj:398)
	shadow.build/compile (build.clj:389)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:314)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:300)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:936)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:899)
	shadow.cljs.devtools.server.util/server-thread/fn--48207/fn--48208/fn--48216 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--48207/fn--48208 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--48207 (util.clj:257)
	java.lang.Thread.run (Thread.java:831)
Any hints on how to start debugging this would be appreciated. The error is specific to the d3-dag package, since requiring ["react" :as r] works.
#2021-05-1016:08thheller@endrebak85 that is cased by a dependency conflict on the closure-compiler version. see https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2021-05-1016:10Endre Bakken StovnerThank you. I was experiencing some other weirdness too (dunno if they are due to shadow-cljs though). Will fix it and see if they disappear. Do you think these error messages might have the same cause? https://clojurians.slack.com/archives/C053AK3F9/p1620220881170500#2021-05-1016:29thheller@endrebak85 that happens when you use a too old shadow-cljs version with jdk15+, need to upgrade shadow-cljs#2021-05-1016:31thhellercant' remember which version added jdk15 compatibility, but at least 2.11.x is likely required. current is 2.12.6#2021-05-1101:57FHESuper-basic question: In https://github.com/shadow-cljs/quickstart-browser , are the commands npx shadow-cljs server and npx shadow-cljs watch app both supposed to tie up the CLI window (I'm running this in WSL2) and require opening a new one for subsequent commands?#2021-05-1102:01FHEThey seem like ongoing processes, so it makes sense to me. I just would like to make sure nothing's going wrong.#2021-05-1102:08Drew VerleeYour right, they both start a process.#2021-05-1102:26FHERunning google-chrome does as well? I've opened my 4th window now...#2021-05-1102:28FHESorry. Trying to learn a lot at once. To me it's strange to see a CLI echo responses to a command, then just...stop responding (without returning to a prompt). I've seen something similar with REPLs, but at least there you get some kind of prompt.#2021-05-1102:36FHEBy the way, running the server command above responds that it starts an HTTP server at , another server at , and an nREPL server "on port 35301". I can navigate to the first two servers in my WSL2 browser (and even in a Windows browser), but I don't know what to make of the third. Actually, since it was telling me a REPL was being started I was kind of waiting for a REPL prompt to show up (but no).#2021-05-1103:03FHEHow do I access this nREPL?#2021-05-1107:06thhellernREPL is the protocol used by most editors/tools. It is not directly used by humans. don't know what editor your are using but it most likely supports nREPL#2021-05-1112:29FHEAha. Thanks. So if I figure out how to use CIDER, that is probably what it will hook into?#2021-05-1103:36FHESeparate question: Is npx shadow-cljs watch app process in https://github.com/shadow-cljs/quickstart-browser supposed to cover index.html (and CSS files, I should ask) for live updating? ...or is there a way to get it to? The browser is not reacting to changes to it. I can hit F5, but I thought that was not supposed to be required with hot reloading.#2021-05-1107:06thhellercss is hot-reloaded. HTML is not.#2021-05-1112:30FHEFair enough. 👍#2021-05-1105:27FHE3rd question: How do you use cljs to set the text of the h1 in index.html? I've tried 20 different ways based on examples from a cljs cheatsheet and 3 or 4 other sources. Here are just some examples that have failed: 1.`(js/document.getElementsByTagName('h1')[0].innerHTML = 'Live reloaded')` 2.`(. js/document.getElementsByTagName('h1')[0].innerHTML = 'Live reloaded')` 3. (-> js/document (.getElementsByTagName "h1" 0) (.-innerHTML) (set! "Live reloaded")) 4. (set! (.-innerHTML .getElementsByTagName "h1" "0" js/document) "Live reloaded") 5.`(def heading1 (.getElementsByTagName "h1" 0 js/document)) (set! (.-innerHTML "Live reloaded"))` 6. (def heading1 ([0] "h1" .getElementsByTagName js/document)) ;(set! (.-innerHTML "Live reloaded")) ...and I do realize state should be dealt with differently, like by using atoms and/or learning reagent, but for now I just want to try to get some kind of live reloading working. Thanks.#2021-05-1107:08thhellerThis is basic interop question. I suggest reading some code. There are a couple ways to do this but taking the JS and moving the parens is not the way 😉 One variant
(let [el (-> (js/document.getElementsByTagName "h1")
             (aget 0))]
  (set! (.-innerHTML el) "yo"))
#2021-05-1112:36FHEBig 'Aha.'. The (aget 0) part is a particular surprise. All of my attempts were pretty close to others' supposedly working code, by the way. Their code examples were mostly (or all?) for getElementById, though, which means they did not show how to handle an index number.#2021-05-1113:04FHEKind of surprised the above doesn't work rearranged as a one-liner (avoiding using 'let'): (set! (.-innerHTML (-> (js/document.getElementsByTagName "h1") (aget 0)) "Equivalent one-liner wihout 'let'?")) Not sure how half of the example working code I found out there was one-liners (again, at least for things referenced by Id---I wonder if not having to deal with that '0' makes the difference).#2021-05-1113:20thheller(set! (.-innerHTML (-> (js/document.getElementsByTagName "h1") (aget 0))) "Equivalent one-liner wihout 'let'?")#2021-05-1113:20thhellergotta be careful with the placement of the parens .. the let for me makes the code easier to read, that is why I use it#2021-05-1113:45FHESigh...basic paren mistake. Whoops. Thanks! ...and yes, I'm sure I'll want to not use hard-to-read one-liners going forward. For this instance I just wanted to see a working one-liner side-by-side with all my failed lines to compare and contrast. 😉#2021-05-1113:48thhellerwell as I said there are many ways to write this. so the most important step is learning what every part does.
(-> (js/document.getElementsByTagName "h1") (aget 0) (set! -innerHTML "Equivalent one-liner wihout 'let'!"))
also works
#2021-05-1113:54FHEGood to know. So many combinations. Hopefully it will sink it soon for me why the ones that work work and why the other examples from around the web did not (other than the aget(0) piece never being there).#2021-05-1113:56FHEAppreciate your feedback very much. I'm sure I'll have another softball question (that I couldn't answer even after scouring the web) in about 12 hours when I can get back to this. Ha!#2021-05-1113:58thhellerjs/document.getElementsByTagName returns an array, aget gets the nth element of that array#2021-05-1113:58thhellerjs/document.getElementById only returns a singular element, not an array#2021-05-1105:32FHE4th question: If I add example 5. above to my starter.cljs file (again, this is using the shadow-cljs quickstart project), I get errors. That's fine. It's bad code. No problem. ...but then if I comment that line of code out, then after a hot reload I still get the same error. How can that be?? This behaviour was hard to suss out, and made me have to re-try lots of code for trying to set that h1 text (after finding out that old, commented-out code, and not replacement lines of code I was trying to test, could be to blame for errors).#2021-05-1111:02AronI am getting a variable module is undeclared warning from Resource: com/cognitect/transit.js:649:8 when I do release and I am not sure why, any pointer would be appreciated to what this is about.#2021-05-1111:54thhelleryou can ignore that one. you can create externs for module to get rid of it but it is safe to ignore#2021-05-1112:03Aronthanks#2021-05-1112:42FHEFurther to my Q4 above, should I just assume that if my code causes an error (or at least the kind of error that shows up on an all-red banner), then after fixing/removing the offending code I need to force a reload of the webpage? That seems odd.#2021-05-1112:49FHE(Errors on white with red border (e.g. "Compilation failed!", caused by my code line 4. above) reliably go away when code is reverted. Errors on white with yellow banner (e.g. "WARNING in start/browser.cljs", caused by my code line 6. above) also reliably go away when code is reverted. Errors on red banner (e.g. "shadow-cljs - [reload failed] Failed to load starter/browser.cljs: [...]", caused by my code line 5. above) persist even after removing the lines of code that caused them!)#2021-05-1113:18thheller@factorhengineering as the error says. it failed to load the file. that has nothing to do with the compilation. it can compile but still fail to load if the code is invalid. that will go away when you fix the code.#2021-05-1113:19thhellerI don't know what code you are trying to load but all the examples you had were invalid and would cause an error during load#2021-05-1113:28AronEmpirical programming at its best. I remember FHE asking shadow-cljs questions in #beginners and thinking to myself that I should definitely not mention this channel yet. : ) Maybe I am too mean, but what I see is a lot of wasted effort by rushing ahead and by this, making things more difficult, even for people who would like to help.#2021-05-1113:31thhellerdefinitely shows that we need a lot more documentation for all of this 🙂#2021-05-1113:37FHEor a #shadow-cljs-beginners kiddie pool. 😉#2021-05-1113:39thhellerits fine to ask here. I'll answer when I have time.#2021-05-1114:47AronI think the current documentation is extremely good, but it's written in a style that makes it difficult to consume#2021-05-1114:48Aroni've been actually planning to propose an alternative presentation for it, or a kind of rewrite#2021-05-1115:24henryw374hello. if I have a watch build running, with a cljs repl connected, is there a way to temporarily prevent live-reloading in the browser, but keep the repl connected? with figwheel you have a stop function you can call to achieve this - I'm looking for the shadow equivalent. thanks#2021-05-1115:33thheller@henryw374 from the clojure REPL (shadow/watch-set-autobuild! :the-build-id true|false)#2021-05-1115:34thhellerno clue if anyone ever actually used that or if it works but I added it a long time ago 🙂#2021-05-1115:41henryw374thanks again @thheller. it's working well 😉 I use that when I'm defining a bunch of temp vars with https://github.com/vvvvalvalval/scope-capture and don't want reload to lose the state#2021-05-1118:19FranklinI have figwheel code splitting configs that look like this
:modules
              {:organization
               {:entries #{app.components.organization.init}
                :output-to "target/cljsbuild/public/js/out/organization.js"}
               :home
               {:entries #{app.components.home.init}
                :output-to "target/cljsbuild/public/js/out/home.js"}
               :user-management
               {:entries #{app.components.organization.users.init}
                :output-to "target/cljsbuild/public/js/out/user-management.js"}
               :settings
               {:entries #{app.components.organization.settings.init}
                :output-to "target/cljsbuild/public/js/out/settings.js"}}
#2021-05-1118:19Franklinso, for each module a single .js file is generated#2021-05-1118:22FranklinI get this error when I don't add :depends-on
ExceptionInfo: two modules without deps, please specify which one is the default
#2021-05-1118:54Franklinseems https://github.com/thheller/code-splitting-clojurescript/blob/c9e1e9340c45969f3fc5b515fb9d095f28595c24/src/main/demo/app.cljs uses a front end router and I wonder if I can set up code splitting without a frontend router#2021-05-1119:06Franklinactually, I think I might have figured this out... the documentation helped#2021-05-1119:06thhellerregular CLJS has an implicit base module that all of them depend on. shadow-cljs does not but you can add it and have them all manually depend on it#2021-05-1119:06thhellerjust :shared {:entries []} and then all the other :depends-on #{:shared}#2021-05-1119:07thhellerthey are all written to the output-dir, no need for :output-to per module#2021-05-1119:10Franklinthanks#2021-05-1119:30john-shafferThanks for the advice @thheller. In this case I'm not even using the feature, and I may be better off forking the library so I can stick with the default feature set The issue is that Material UI is (gradually) dropping IE 11 compat and starting to use newer ECMAScript features, so those options will probably be needed in the future. Hopefully they are less bleeding edge by then#2021-05-1119:37thhelleryeah all that stuff is extremely messy#2021-05-1120:25thhellerhttps://clojureverse.org/t/new-build-reports-with-dependency-traces/7653#2021-05-1120:25thhellerso nobody ever has to ask again why cljs.pprint was in their build 😉#2021-05-1416:52lispers-anonymousThank you so much for doing this#2021-05-1203:37mbertheauCan I run build-report at the same time a dev build watch is running, or should I stop the dev build watch first?#2021-05-1207:33thhellerthe docs mention that, you can run them while watch is running#2021-05-1207:51mbertheauIndeed! Sorry I missed that. Thanks!#2021-05-1203:58mbertheauAnd another question: is it expected that the function names in stack traces are less helpful than they maybe could be?#2021-05-1207:33thhellerdunno, I'm guessing they are all anonymous functions?#2021-05-1207:20Robert PofukHi! I was trying to set
:module-loader    :no-inject
Based on code https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/browser.clj should be ok:
;; true to inject the loader data (which changes the signature)
              ;; any other true-ish value still generates the module-loader.edn data files
              ;; but does not inject (ie. change the signature)
              (true? module-loader)
              (inject-loader-setup-release config)
But spec for module loader forces bolean (s/def ::module-loader boolean?) What is missing in my setup to avoid inclusion of module loader in js?
#2021-05-1207:32thheller@robert.pofuk thats a boolean only, so just :module-loader false? what are you trying to achieve? that comment refers to old code that doesn't exist anymore#2021-05-1207:43Robert PofukI have multiple we applications, all of them are build with shadow-cljs, clojurescript, react material ui. I would like to share some code between them. Because I would like to avoid re-building all of them every time shared peace of code changes i wanted to modularize them. App 1:
MODULES:
:main {:entries [:react, :material-ui]}
:feature-1 {:entries [alpha/feature-1]}
App 2:
MODULES:
:main {:entries [:react, :material-ui]}
:feature-2 {:entries [alpha/feature-2]}
App 3:
MODULES:
:main {:entries [:react, :material-ui]}
:feature-3 {:entries [alpha/feature-3]}
Then I would be able to load javascript produced from :feature-1 and :feature-2 modules into APP3 . All of them are compiled using :simple optimization and are forcing for all shared deps to be in main module. My assumption here was that I will be able to override loadig of modules and put in :feature-1 and :feature-2 modules inside
var shadow$modules = {"uris":{"main":[],
                      "feature-1":[""]},
                      "feature-2":[""]},
                      "infos":{"main":null,"feature-3":["main"]}};
#2021-05-1207:47thhellerthat is not possible, separate :advanced builds are not compatible with each other#2021-05-1207:47Robert PofukAll of them are compiled using :simple optimization#2021-05-1207:48thhellereven then that is questionable, :simple is also gigantic#2021-05-1207:53thhelleryou can set :module-loader-init false in your build config#2021-05-1207:54thhellerand then initialize the loader via shadow.loader/init yourself. you can change the shadow$modules however you want before that#2021-05-1207:54thhellerbut I strongly advise against doing this. it will have unintended consequences.#2021-05-1207:55Robert PofukI know it is big 4x in my example. But sharing modules between apps would be amazing. I could have multiple teams in parallel developing without having 1 project as bottleneck. Also I could use this feature as feature toggle, rewrite module from scratch and so on... And javascript it self makes it easy to load code on demand and then it would be cool to utilize this in clojurescript. I only did small comparison and 2 different apps create same output of same code in module.#2021-05-1207:58thhellerbut if you care about performance at all then :simple is a dealbreaker#2021-05-1207:59thhelleryou can't possibly regain that loss from sharing code#2021-05-1208:02thhellerthe trouble is that even with :simple some code is rewritten in incompatible ways#2021-05-1208:02thhellerif you just want to move out the JS dependencies and share those you can do so by using :js-provider :external#2021-05-1208:02thhellerbut sharing :modules will end up in trouble at some point#2021-05-1208:04Robert PofukThank you for help! I will try to figure out if it is worth the risk and load the modules on my own or find a way how to compile things together.#2021-05-1209:12FranklinI have a macro that looks like this
(defmacro reg-event-assoc-in [name seq-of-kw]
  `(re-frame/reg-event-db
    ~name
    (fn [db# [_ value#]]
      (assoc-in db# ~seq-of-kw value#))))
#2021-05-1209:12Franklinand I call it as follows:#2021-05-1209:13Franklin
(utils-events/reg-event-assoc-in ::accounts-dropdown-selected-option
                                [:accounts-dropdown :the-selected-option])
#2021-05-1209:13Franklinshadow-cljs keeps throwing this error:
4 | (utils-events/reg-event-assoc-in ::enable-new-project-modal?
-------^------------------------------------------------------------------------
Syntax error macroexpanding cljs.core/fn.
Call to cljs.core/fn did not conform to spec.
-- Spec failed --------------------

  ((clojure.core/apply
    clojure.core/vector
    (clojure.core/seq
     (clojure.core/concat
      (clojure.core/list 'quagga.utils.events/db__31345__auto__)
      (clojure.core/list
       (clojure.core/apply
        clojure.core/vector
        (clojure.core/seq
         (clojure.core/concat
          (clojure.core/list 'quagga.utils.events/_)
          (clojure.core/list
           'quagga.utils.events/value__31346__auto__)))))))) ...)
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

should satisfy

  vector?

or value

  ((clojure.core/apply ... ...) ...)
    ^^^^^^^^^^^^^^^^^^

should satisfy

  vector?

-- Relevant specs -------

:shadow.cljs.devtools.cljs-specs/param-list:
  (clojure.spec.alpha/and
   clojure.core/vector?
   (clojure.spec.alpha/cat
    :params
    (clojure.spec.alpha/* :shadow.cljs.devtools.cljs-specs/binding-form)
    :var-params
    (clojure.spec.alpha/?
     (clojure.spec.alpha/cat
      :ampersand
      #{'&}
      :var-form
      :shadow.cljs.devtools.cljs-specs/binding-form))))
:shadow.cljs.devtools.cljs-specs/params+body:
  (clojure.spec.alpha/cat
   :params
   :shadow.cljs.devtools.cljs-specs/param-list
   :body
   (clojure.spec.alpha/alt
    :prepost+body
    (clojure.spec.alpha/cat
     :prepost
     clojure.core/map?
     :body
     (clojure.spec.alpha/+ clojure.core/any?))
    :body
    (clojure.spec.alpha/* clojure.core/any?)))
#2021-05-1209:13Franklinany pointers on how to fix this?#2021-05-1209:14Franklincan I silence the spec checks?#2021-05-1209:46thhellerthe _ is the problem, use ignored# or so instead#2021-05-1209:47thhelleralso this doesn't need to be a macro at all, just use a function#2021-05-1209:48thheller
(defn reg-event-assoc-in [name seq-of-kw]
  (re-frame/reg-event-db name
    (fn [db [_ value]]
      (assoc-in db seq-of-kw value))))
#2021-05-1209:48thhelleryou can't silence the spec checks since they are telling you that your code is incorrect and won't compile#2021-05-1210:19Franklinthank you#2021-05-1211:48AronI have a beginner question this time. I suspect the answer might not be shadow-cljs related, but I am not sure yet. Basically, I have two different problems related to testing, and I would like to solve them both at once. I am using a :node-test target to compile puppeteer tests that I run manually. The problem is that sometimes I only want to run a single test, but the only way to easily configure this so far was through the :ns-regexp config. Is there a conventional solution to this problem? I can imagine writing an ad-hoc solution that takes CLI arguments and calls the tests or not based on that, but I am always wary of reinventing the wheel. And the second problem is that similarly through CLI arguments, I would like to feed different data to the same tests. Anyone here has some suggestions for some tooling, any kind of tooling, that would make both these problems easier to solve? Or should I just give in and code it up myself?#2021-05-1211:50thheller:node-test already takes CLI arguments#2021-05-1211:50Aronalready I start to feel stupid#2021-05-1211:50Aronsmh#2021-05-1211:50thhellertry --help, or --test=a.single.ns or --test=a.single.ns/test-name#2021-05-1211:51thhellerI think I didn't document those when I added them#2021-05-1211:52Aronyou don't mean config-merge I am sure#2021-05-1211:52thhellerno, when running the test node the-test-file.js --help#2021-05-1211:52thhellernot a build option at all, just a runtime thing#2021-05-1211:53Arontrying#2021-05-1211:53thhellerthe second part with passing custom data is not supported since tests themselves don't take arguments#2021-05-1211:54Aronif I can do any cli based logic, then i can load the necessary data from disk#2021-05-1211:54Aroncompile the tests with different fixtures/mock data#2021-05-1211:55thhellerwhat you do in your tests is up to you#2021-05-1211:55AronI wish, but my colleagues have a say too : )#2021-05-1211:57thhellerTEST_DATA=foo.txt node the-test-file.js --test=that.one/test-thing#2021-05-1211:58thhellerand in your test (fs/readFileSync js/process.env.TEST_DATA) or whatever#2021-05-1211:58Aronthank you, immensely helpful as ever#2021-05-1304:53zimablueah ignore me I found a link in this chat somewhere#2021-05-1304:53zimabluehttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2021-05-1308:46Endre Bakken StovnerWhen using the {:js-options {:js-provider :require}} the luminus landing page tells me that the javascript has not compiled and I get these errors in the developer console:
app.js:1672 An error occurred when loading shadow.js.shim.module$react.js
env.evalLoad @ app.js:1672
app.js:1673 ReferenceError: require is not defined
    at eval (:3000/js/cljs-runtime/shadow.js.shim.module$react.js:3)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:577)
    at Object.env.evalLoad (app.js:1670)
    at app.js:1773
env.evalLoad @ app.js:1673
app.js:1672 An error occurred when loading shadow.js.shim.module$react_dom.js
env.evalLoad @ app.js:1672
app.js:1673 ReferenceError: require is not defined
    at eval (:3000/js/cljs-runtime/shadow.js.shim.module$react_dom.js:3)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:577)
    at Object.env.evalLoad (app.js:1670)
    at app.js:1811
env.evalLoad @ app.js:1673
util.cljs:187 Installing CLJS DevTools 1.0.3 and enabling features :formatters :hints :async
app.js:1672 An error occurred when loading everclear.app.js
env.evalLoad @ app.js:1672
app.js:1673 TypeError: Cannot read property 'prototype' of undefined
    at Object.reagent$impl$component$create_class [as create_class] (component.cljs:323)
    at Object.reagent$impl$component$fn_to_class [as fn_to_class] (component.cljs:373)
    at Object.reagent$impl$component$as_class [as as_class] (component.cljs:379)
    at reagent$impl$template$reag_element (template.cljs:159)
    at Object.reagent$impl$template$vec_to_elem [as vec_to_elem] (template.cljs:284)
    at Object.reagent$impl$template$as_element [as as_element] (template.cljs:288)
    at Object.eval [as reagent$impl$protocols$Compiler$as_element$arity$2] (template.cljs:305)
    at Object.reagent$impl$protocols$as_element [as as_element] (protocols.cljs:5)
    at f (dom.cljs:47)
    at Object.reagent$dom$render_comp [as render_comp] (dom.cljs:19)
env.evalLoad @ app.js:1673
This happens even though lein shadow watch app builds and compiles just fine. Any hints for how to debug it?
#2021-05-1308:56mbertheau@UT770EY2K Why do you use :js-provider :require? This is option isn't intended for code that should run in the browser.#2021-05-1308:57Endre Bakken StovnerAh, I want to use some npm libraries that do not compile with the regular settings.#2021-05-1308:58mbertheauIt seems like :js-provider :require isn't the right solution for that. What error do you get with the regular settings?#2021-05-1309:00Endre Bakken Stovner
[:app] Compiling ...
[:app] Build failure:
Closure compilation failed with 2 errors
--- node_modules/d3-array/dist/d3-array.js:280
This code cannot be converted from ES6. extending native class: Map
--- node_modules/d3-array/dist/d3-array.js:300
This code cannot be converted from ES6. extending native class: Set
#2021-05-1309:00Endre Bakken StovnerWith :require it compiles (but does not work in the browser)#2021-05-1309:02Endre Bakken StovnerI am a complete JS-n00b, but I tried to follow the guide https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages.#2021-05-1309:05mbertheauWell, the JS ecosystem is a mess 🙂 JS is constantly extended with new language features, and the Google Closure compiler doesn't understand all of them. The library d3-array apparently uses features that the Google Closure compiler doesn't understand. What I would try is to load d3-array separately in the browser and use :js-options {:resolve {"d3-array" {:target :global }}} https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global. You'll probably have to process d3-array for the browser as well. Usually people use Babel for that.#2021-05-1309:06mbertheauSee also https://github.com/d3/d3-array/issues/87#2021-05-1309:07mbertheauYou might alternatively get away with an older version of d3-array#2021-05-1309:09mbertheauNotably d3-array also appears here as an example for a JS module that tends to need special treatment for the browser: https://github.com/babel/babel-loader#some-files-in-my-node_modules-are-not-transpiled-for-ie-11#2021-05-1309:10Endre Bakken StovnerHmmm, d3-array is a dependency of some other library, so trying to choose a specific library version manually sounds like it might easily lead to problems. Thanks for the pointers. I will try to understand them now :)#2021-05-1309:12mbertheauMaybe :js-provider :shadow works. It could be the default already, I'm not sure, but that's something you could try easily.#2021-05-1309:13mbertheauhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-provider#2021-05-1309:54thheller@UT770EY2K set :compiler-options {:output-feature-set :es6} not :js-provider#2021-05-1309:55thhellerif you set :js-provider :require shadow-cljs will NOT process any JS dependencies and instead expect a separate tool to do that. this is not what you want#2021-05-1309:56thhellerthe default :output-feature-set is :es5 but as the error is telling you the d3 code cannot be converted "down". so by setting a "higher" feature set that problem goes away#2021-05-1309:57thheller:js-provider :shadow is the default for :browser builds, do not change it unless you know what you are doing.#2021-05-1309:58thhellerdo not use :resolve either, that is not relevant here.#2021-05-1310:04mbertheauInteresting. So Google Closure is apparently quite good in supporting newer JS features. https://shadow-cljs.github.io/docs/UsersGuide.html#_output_language_options#2021-05-1310:05thhelleryes, not super bleeding edge but quite good. usually when there is a standard there is support.#2021-05-1310:06thhellerI might bump the default to :es6. really doesn't make sense to have :es5 still.#2021-05-1310:12mbertheauIf you want support for IE11 you need to set that back to :es5 then, right?#2021-05-1310:14thhelleryes#2021-05-1310:18thhellerI just bumped the default. really should have done that a year ago 😛#2021-05-1310:38mbertheau@thheller https://cljs.github.io/api/compiler-options/language-out doesn't mention :ecmascript6 . Is that correct?#2021-05-1310:39thhelleryeah .. doesn't matter. closure keeps changing the names of those. in shadow thats just an alias for ecmascript-2015, same option#2021-05-1311:28Endre Bakken StovnerThanks for all the help 🙂 It seems to be working fine now.#2021-05-1313:50zimablueThis is a question where I seem to have found a workaround, so please ignore if busy. shadow-cljs release node wasn't working, even though shadow-cljs compile node was. Following advice in the troubleshooting guide, I compared versions of the major dependent libraries across working and non-working projects and noticed that the com.google.javascript/closure-compiler version was different, someone had pinned it in the deps.edn with a note about "enable for node", I also noted that there is a specified shadow-cljs version in the deps.edn it eventually worked only when I both installed the specified version of shadow-cljs (through npm, how I'd originally installed), and unpinned the versions of com.google.javascript/closure-compiler and org.clojure/google-closure-library which had both been pinned under a note. The things I remain confused about: do aliases like: :aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.10.21"} enforce shadow-cljs version? From my troubleshooting, I guess not if you install via npm, therefore I should be installing via lein? Does anyone have an idea why these libraries have to be pinned, and shadow-cljs has to be an older version? the errors I got with the newer version were like this: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError and The result of a goog.define call must be assigned as an isolated statement. one for pinned and one for unpinned closure compiler versions#2021-05-1314:49thhellerif you use deps.edn and have a true-ish :deps key in shadow-cljs.edn then ONLY deps.edn controls the version for shadow-cljs you get#2021-05-1314:49thhellerthe one in package.json then only controls the version of the shadow-cljs command line tools#2021-05-1314:31FranklinI have set up shadow-cljs to compile my cljs to a specific folder from where I'm serving them with a different HTTP server. Everything seems to work ok... code compiles on save and hot reloads on the browser 😃. However, I do not get a browser repl after the code is compiled when I run shadow-cljs watch app#2021-05-1314:31FranklinI have commented out ;; :dev-http {3000 "public"} in my shadow-cljs.edn file because my server is running on the same port#2021-05-1314:32FranklinI wonder what I might be missing?#2021-05-1314:34Franklinerror messages also sometimes, on the browser console don't seem to pinpoint exactly where the error is.#2021-05-1314:50thhellershadow-cljs cljs-repl app will give you the REPL#2021-05-1314:51thhelleror use your editor to connect#2021-05-1315:58Franklinthanks, that worked#2021-05-1316:08haywoodusing shadow.loader/load but the XHR request it makes has this undefined segment in the url <correct shadow-cljs.edn asset path> and I’m not sure why#2021-05-1316:09haywoodhave to look into this = goog.module.ModuleManager.getInstance();#2021-05-1316:09thhellermight be calling it too early? before it is initialized?#2021-05-1316:12thhellerdon't know why you posted the mm line? if that didn't exist you'd never get an URL from anything, it would error out differently#2021-05-1316:12thhellerif you called shadow.loader/init without an argument that might be the undefined?#2021-05-1316:13thhellerneeds to get one argument for the prefix it is supposed to use, just an empty string for no prefix#2021-05-1316:13haywoodoh I was looking into what this was doing .execOnLoad(id, cb)#2021-05-1316:14haywoodI think it’s a user error that I need to sort out because I’m only getting the issue when I load the async route (in my app) directly#2021-05-1316:14haywoodbut if I go to another route first that isn’t a separate module, and then go to async route it loads correctly#2021-05-1316:15thhellerwhat do you want execOnLoad for? doubt anyone ever used that#2021-05-1316:15thhellerI don't even know what its supposed to do 😛#2021-05-1316:16haywoodoh… lol uhh I thought I was following the code for shadow.loader/load
shadow.loader.load = function(id, cb) {
  shadow.loader.ensureInitWasCalled();
  id = shadow.loader.string_id(id);
  if (cb) {
    shadow.loader.mm.execOnLoad(id, cb);
  }
  return shadow.loader.mm.load(id);
};
#2021-05-1316:16haywoodhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#L115#2021-05-1316:17haywoodhttps://shadow-cljs.github.io/docs/UsersGuide.html#_loading_code_dynamically#2021-05-1316:23thhellerbut why not just use load?#2021-05-1316:24thhellerif you intent to call something when the code is loaded use :init-fn in the module config#2021-05-1316:31haywoodhmm, interesting question. I’m trying to work the async module loading into my app’s router which is represented as data in state, so like, when the ‘on-navigate’ event fires I load the new page’s module and call it’s render function. I’m sure it could be improved like how you suggested, I’m trying to get a poc working#2021-05-1316:32thhellermaybe you want something like shadow.lazy or the example from here https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2021-05-1316:33haywoodahh that is probably exactly it#2021-05-1316:33thhellerthe lazy-component util is using shadow.lazy https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs#2021-05-1316:34haywood
["blog"
    {:name :,
     :weight 5,
     :view #'deli-pages-blog/render,
     :label "blog",
     :controllers
     [{:identity
       (clojure.core/juxt :parameters :path-params :query-params),
       :start #(rf/dispatch [:fetch-blog])}]}]
the only reason it’s all bundled together is for importing the namespace and passing it to that :view keyword, so if I can just lazy reference that, bingo
#2021-05-1316:34haywoodthanks @thheller!!#2021-05-1319:13StuartAny idea what I'm doing here. My shadow-cljs.edn
:source-paths ["src/main" "src/test"]

:builds {
   :test {:target :karma
          :output-to  "target/ci.js"}}
$ npx shadow-cljs compile test
shadow-cljs - config: /home/stuart/Source/cljs/cljs-asm/shadow-cljs.edn
shadow-cljs - connected to server
[:test] Compiling ...
[:test] Build completed. (62 files, 1 compiled, 0 warnings, 0.45s)
This puts a file ci.js in a folder named target I have a karma.conf.js
module.exports = function (config) {
    config.set({
        browsers: ['ChromeHeadless'],
        // The directory where the output file lives
        basePath: 'target',
        // The file itself
        files: ['ci.js'],
        frameworks: ['cljs-test'],
        plugins: ['karma-cljs-test', 'karma-chrome-launcher'],
        colors: true,
        logLevel: config.LOG_INFO,
        client: {
            args: ["shadow.test.karma.init"],
            singleRun: true
        }
    })
};
When I run karma start --single-run I see this:
13 05 2021 20:11:24.219:INFO [karma-server]: Karma v6.3.2 server started at 
13 05 2021 20:11:24.222:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
13 05 2021 20:11:24.230:INFO [launcher]: Starting browser ChromeHeadless
13 05 2021 20:11:24.539:INFO [Chrome Headless 90.0.4430.212 (Linux x86_64)]: Connected on socket 63Mi3R7buKBGnu2WAAAB with id 43705700
Chrome Headless 90.0.4430.212 (Linux x86_64): Executed 0 of 0 SUCCESS (0.003 secs / 0 secs)
TOTAL: 0 SUCCESS
My tests are namespaced like this
(ns exfn.parser-test
  (:require [cljs.test :refer-macros [deftest is testing run-tests]]))
anyone any ideas why its not finding my tests?
#2021-05-1319:14StuartI'm running karma from the root folder of my app, in teh same folder as karma-conf.js#2021-05-1319:26thhellerhard to say. you omitted several important details. like which version is this? where is the actual test file?#2021-05-1319:28Stuartsorry, the test files are in "src/test" folder off the root of my project.#2021-05-1319:29StuartKarma version is 6.3.2#2021-05-1319:29thhellershadow-cljs version? do you use project.clj or deps.edn?#2021-05-1319:29Stuartyes#2021-05-1319:30StuartI'm using shadow-cljs via commands like
npx shadow-cljs watch app
npx shadow-cljs release app
etc
#2021-05-1319:30Stuarthow do I make it show me the version ?#2021-05-1319:31Stuart
shadow-cljs - config: /home/stuart/Source/cljs/cljs-asm/shadow-cljs.edn
=== Version
jar:            2.11.22
cli:            2.11.22
deps:           1.3.2
config-version: 2.11.22
#2021-05-1319:32thhellerdo you use project.clj or deps.edn? is there a :lein or :deps key in your shadow-cljs.edn?#2021-05-1319:32StuartI only have a shadow-cljs.edn#2021-05-1319:32StuartMy whole shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
 ["src/main"
  "src/test"]

 :dependencies
 [[binaryage/devtools "0.9.10"]
  [reagent "1.0.0"]
  [re-frame "1.2.0"]
  [day8.re-frame/re-frame-10x "1.0.1"]
  [org.clojars.ertucetin/re-frame-flow "0.1.1"]
  [bidi "2.1.6"]
  [com.rpl/specter "1.1.3"]]

 :nrepl    {:port 3333}
 :dev-http {8080 "public"}
 :builds   {:app {:target     :browser
                  :output-dir "public/js"
                  :modules    {:main {:init-fn }}
                  :dev        {:compiler-options {:closure-defines {re-frame.trace/trace-enabled?        true
                                                                    day8.re-frame.tracing/trace-enabled? true}}}
                  :devtools   {:http-root "public"
                               :http-port 3000
                               :preloads  [day8.re-frame-10x.preload
                                           re-frame-flow.preload]}

                  :compiler-options {:closure-defines {re-frame.trace.trace-enabled? true}
                                     :silence-optimizations-warning true

                                    ;; in production so you can do an :advanced compile.
                                     :optimizations :simple}

                  :release    {:build-options {:ns-aliases {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}

            :release {:target     :browser
                      :output-dir "release/js"
                      :modules    {:main {:init-fn }}
                      :compiler-options {:silence-optimizations-warning true
                                         :optimizations :advanced}}
            
            :test {:target :karma
                   :ns-regexp "-test$"
                   :output-to  "target/ci.js"}}}
#2021-05-1319:34thhellerlooks fine. don't really need the :release build but thats not relevant to the test#2021-05-1319:34thhellerI assume you have actual deftest in your test file? with actual is assertions?#2021-05-1319:36Stuartyeah, so i have a bunch of tests over 2 files. The tests are
src/test/interpreter-tests.cljs
src/test/parser-tests.cljs
A test looks like
(deftest is-register-tests?
  (is (true? (is-register? ":x")))
  (is (false? (is-register? "5")))
  (is (false? (is-register? "foo")))
  (is (false? (is-register? "b_010101"))))
#2021-05-1319:36thhellerdon't know where you get :silence-optimizations-warning from but that config option does not exist#2021-05-1319:36thhellerthose are not valid filesnames#2021-05-1319:37thheller(ns exfn.parser-test ... needs to be in src/test/exfn/parser_test.cljs#2021-05-1319:37Stuartah okay! I didn't know that, let me move them and try#2021-05-1319:37thhelleryou configured :ns-regexp "-test$" which does not match parser-tests#2021-05-1319:37StuartI thought that was parsing on the namespace, its parsing on the file?#2021-05-1319:38thhellerit is looking for the namespace, but that is derived from the filename#2021-05-1319:49Stuartok, cool. I'll move those files and try again.Thanks for your time and help!#2021-05-1320:05macrobartfastI am adding a server to my shadow project to handle endpoints and Crux. I would normally add Ring and Compojure to do that. Do I add these deps to shadow-cljs.edn or somewhere else? Are some of them already included… if so where are they pulled in? Thanks!#2021-05-1320:07macrobartfastI created my app with create-cljs-app so that’s the structure.#2021-05-1320:08thhellerI'd recommend using whatever you prefer for writing CLJ apps#2021-05-1320:08thhellerI use lein for all my CLJ needs so I'll have a project.clj for that with the proper dependencies. so I'll have a shadow-cljs.edn for everything CLJS related and a project.clj for CLJ stuff#2021-05-1320:11Stuart@thheller thank you! It works now and runs my tests. Fantastic 🙂#2021-05-1320:11thhellerhttps://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-05-1320:11thhellerjust pushed me to finish posting this 😉 might help a little in understanding why those names/paths matter#2021-05-1320:13StuartNice, I have been confused about all the paths in clojure(script)#2021-05-1321:01macrobartfastin terms of adding a project.clj to a shadow project (next to a shadow-cljs.edn), I have (from lein new app server
(defproject server "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.1"]]
  :main ^:skip-aot server.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})
how much of this is relevant pr meeds to be changed? (thanks for the hand holding).
#2021-05-1321:03thhellerI really can't guide you through building a CLJ server sorry#2021-05-1321:04thhellermaybe follow some tutorial first and then integrate the files into actual project later#2021-05-1321:12macrobartfastI totally understand! And thanks for all the help… you’ve got me going in the right direction.#2021-05-1405:03caleb.macdonaldblackMy coworker and I are experiencing this bug: https://github.com/thheller/shadow-cljs/issues/877#2021-05-1405:03caleb.macdonaldblackWe’ve tried deleting .shadow-cljs, target and compiled js. We’ve upgraded to shadow-cljs 2.13.0 as well#2021-05-1405:04caleb.macdonaldblackWe’ve tried running a new shell as well#2021-05-1405:05caleb.macdonaldblackAny ideas. Thheller expains some incompatibility with version of CLJS and shadow. We’re not specifying CLJS in our deps as afaik, shadow-cljs pull them in with the correct version.#2021-05-1405:19caleb.macdonaldblackI had to update any deps using goog.isBoolean.#2021-05-1407:04pedrorgirardiI started getting this error
Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:581).
jdk.vm.ci.services.Services
after upgrading from version 2.12.5 to 2.13.0. I start the watch process with npx shadow-cljs watch :main. Is there something that I need to change in shadow-cljs.edn or the way that I'm starting Shadow CLJS in watch mode?
#2021-05-1407:07thhellerno clue, never seen that error before. did you by any chance change your JVM installation at the same time?#2021-05-1407:07thhellerunlikely to be anything in shadow-cljs, more likely something else in your setup#2021-05-1407:11pedrorgirardiDidn't change my JVM. I'm using openjdk version "15.0.1" 2020-10-20 on macOS.#2021-05-1407:12pedrorgirardiBut I also tried with openjdk version "11.0.10" 2021-01-19 without luck.#2021-05-1407:12pedrorgirardiIt's loooong file, but this might help#2021-05-1407:13pedrorgirardi
{:clojure.main/message
 "Execution error (ClassNotFoundException) at jdk.internal.loader.BuiltinClassLoader/loadClass (BuiltinClassLoader.java:606).\njdk.vm.ci.services.Services\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.ClassNotFoundException,
  :clojure.error/line 606,
  :clojure.error/cause "jdk.vm.ci.services.Services",
  :clojure.error/symbol
  jdk.internal.loader.BuiltinClassLoader/loadClass,
  :clojure.error/source "BuiltinClassLoader.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.util.ServiceConfigurationError,
    :message
    "org.graalvm.polyglot.impl.AbstractPolyglotImpl: Provider com.oracle.truffle.polyglot.PolyglotImpl could not be instantiated",
    :at [java.util.ServiceLoader fail "ServiceLoader.java" 584]}
   {:type java.lang.NoClassDefFoundError,
    :message "jdk/vm/ci/services/Services",
    :at [org.graalvm.libgraal.LibGraal <clinit> "LibGraal.java" 46]}
   {:type java.lang.ClassNotFoundException,
    :message "jdk.vm.ci.services.Services",
    :at
    [jdk.internal.loader.BuiltinClassLoader
     loadClass
     "BuiltinClassLoader.java"
     606]}],
  :trace
  [[jdk.internal.loader.BuiltinClassLoader
    loadClass
    "BuiltinClassLoader.java"
    606]
   [jdk.internal.loader.ClassLoaders$AppClassLoader
    loadClass
    "ClassLoaders.java"
    168]
   [java.lang.ClassLoader loadClass "ClassLoader.java" 522]
   [org.graalvm.libgraal.LibGraal <clinit> "LibGraal.java" 46]
   [org.graalvm.compiler.truffle.runtime.hotspot.libgraal.LibGraalTruffleRuntimeAccess
    getPriority
    "LibGraalTruffleRuntimeAccess.java"
    44]
   [com.oracle.truffle.api.Truffle
    selectTruffleRuntimeAccess
    "Truffle.java"
    89]
   [com.oracle.truffle.api.Truffle access$000 "Truffle.java" 57]
   [com.oracle.truffle.api.Truffle$1 run "Truffle.java" 122]
   [com.oracle.truffle.api.Truffle$1 run "Truffle.java" 107]
   [java.security.AccessController
    doPrivileged
    "AccessController.java"
    312]
   [com.oracle.truffle.api.Truffle initRuntime "Truffle.java" 107]
   [com.oracle.truffle.api.Truffle <clinit> "Truffle.java" 62]
   [com.oracle.truffle.api.impl.Accessor getTVMCI "Accessor.java" 1092]
   [com.oracle.truffle.api.impl.Accessor
    access$000
    "Accessor.java"
    117]
   [com.oracle.truffle.api.impl.Accessor$Constants
    <clinit>
    "Accessor.java"
    974]
   [com.oracle.truffle.api.impl.Accessor
    nodeSupport
    "Accessor.java"
    1025]
   [com.oracle.truffle.api.LanguageAccessor
    <clinit>
    "LanguageAccessor.java"
    79]
   [com.oracle.truffle.api.TruffleLogger$LoggerCache
    <clinit>
    "TruffleLogger.java"
    957]
   [com.oracle.truffle.api.TruffleLogger
    getLogger
    "TruffleLogger.java"
    154]
   [com.oracle.truffle.api.TruffleLogger
    getLogger
    "TruffleLogger.java"
    138]
   [com.oracle.truffle.polyglot.PolyglotContextImpl
    <clinit>
    "PolyglotContextImpl.java"
    101]
   [com.oracle.truffle.polyglot.HostException
    <init>
    "HostException.java"
    58]
   [com.oracle.truffle.polyglot.PolyglotImpl
    <clinit>
    "PolyglotImpl.java"
    92]
   [jdk.internal.reflect.NativeConstructorAccessorImpl
    newInstance0
    "NativeConstructorAccessorImpl.java"
    -2]
   [jdk.internal.reflect.NativeConstructorAccessorImpl
    newInstance
    "NativeConstructorAccessorImpl.java"
    64]
   [jdk.internal.reflect.DelegatingConstructorAccessorImpl
    newInstance
    "DelegatingConstructorAccessorImpl.java"
    45]
   [java.lang.reflect.Constructor
    newInstanceWithCaller
    "Constructor.java"
    500]
   [java.lang.reflect.Constructor newInstance "Constructor.java" 481]
   [java.util.ServiceLoader$ProviderImpl
    newInstance
    "ServiceLoader.java"
    782]
   [java.util.ServiceLoader$ProviderImpl get "ServiceLoader.java" 724]
   [java.util.ServiceLoader$3 next "ServiceLoader.java" 1396]
   [org.graalvm.polyglot.Engine$1
    searchServiceLoader
    "Engine.java"
    747]
   [org.graalvm.polyglot.Engine$1 run "Engine.java" 733]
   [org.graalvm.polyglot.Engine$1 run "Engine.java" 707]
   [java.security.AccessController
    doPrivileged
    "AccessController.java"
    312]
   [org.graalvm.polyglot.Engine initEngineImpl "Engine.java" 707]
   [org.graalvm.polyglot.Engine access$000 "Engine.java" 106]
   [org.graalvm.polyglot.Engine$ImplHolder <clinit> "Engine.java" 115]
   [org.graalvm.polyglot.Engine getImpl "Engine.java" 304]
   [org.graalvm.polyglot.HostAccess$Builder
    targetTypeMapping
    "HostAccess.java"
    913]
   [com.oracle.truffle.js.scriptengine.GraalJSScriptEngine
    createNashornHostAccess
    "GraalJSScriptEngine.java"
    104]
   [com.oracle.truffle.js.scriptengine.GraalJSScriptEngine
    <clinit>
    "GraalJSScriptEngine.java"
    99]
   [com.oracle.truffle.js.scriptengine.GraalJSEngineFactory
    getScriptEngine
    "GraalJSEngineFactory.java"
    180]
   [com.oracle.truffle.js.scriptengine.GraalJSEngineFactory
    getScriptEngine
    "GraalJSEngineFactory.java"
    57]
   [javax.script.ScriptEngineManager
    getEngineByName
    "ScriptEngineManager.java"
    241]
   [shadow.cljs.devtools.server.npm_deps$make_engine
    invokeStatic
    "npm_deps.clj"
    16]
   [shadow.cljs.devtools.server.npm_deps$make_engine
    invoke
    "npm_deps.clj"
    11]
   [shadow.cljs.devtools.server.npm_deps$fn__17754$fn__17755
    invoke
    "npm_deps.clj"
    28]
   [clojure.lang.Delay deref "Delay.java" 42]
   [clojure.core$deref invokeStatic "core.clj" 2324]
   [clojure.core$deref invoke "core.clj" 2310]
   [shadow.cljs.devtools.server.npm_deps$fn__17754$fn__17757
    invoke
    "npm_deps.clj"
    34]
   [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_
    invokeStatic
    "npm_deps.clj"
    201]
   [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_
    invoke
    "npm_deps.clj"
    195]
   [shadow.cljs.devtools.server.npm_deps$main$fn__17849
    invoke
    "npm_deps.clj"
    221]
   [clojure.core$complement$fn__5686 invoke "core.clj" 1443]
   [clojure.core$filter$fn__5911 invoke "core.clj" 2825]
   [clojure.lang.LazySeq sval "LazySeq.java" 42]
   [clojure.lang.LazySeq seq "LazySeq.java" 51]
   [clojure.lang.RT seq "RT.java" 535]
   [clojure.core$seq__5419 invokeStatic "core.clj" 139]
   [clojure.core$seq__5419 invoke "core.clj" 139]
   [shadow.cljs.devtools.server.npm_deps$main
    invokeStatic
    "npm_deps.clj"
    223]
   [shadow.cljs.devtools.server.npm_deps$main
    invoke
    "npm_deps.clj"
    210]
   [shadow.cljs.devtools.cli_actual$main
    invokeStatic
    "cli_actual.clj"
    141]
   [shadow.cljs.devtools.cli_actual$main doInvoke "cli_actual.clj" 132]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 671]
   [clojure.core$apply invoke "core.clj" 662]
   [shadow.cljs.devtools.cli_actual$_main
    invokeStatic
    "cli_actual.clj"
    219]
   [shadow.cljs.devtools.cli_actual$_main
    doInvoke
    "cli_actual.clj"
    217]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.core$apply invoke "core.clj" 662]
   [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 75]
   [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 67]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.core$apply invokeStatic "core.clj" 667]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "jdk.vm.ci.services.Services"}}
#2021-05-1407:13pedrorgirardiIt was generated by the Clojure CLI.#2021-05-1407:17thhelleryeah dunno. the graal-js engine has been in use for a while now (definitely long before 2.12.5) so I don't know why you'd be getting that error now#2021-05-1407:17thhelleralways helps to sort out your dependency conflicts if you use project.clj or deps.edn#2021-05-1407:19thhellermight just be a classpath issue with a missing dependency or so
#2021-05-1407:19pedrorgirardiI'm on 2.12.5, so let me try to upgrade to 2.12.6 and then 2.12.7 just to see when it happens.#2021-05-1407:20thhellernothing regarding any of this has changed#2021-05-1407:21pedrorgirardiI just tried upgrading to 2.12.6 and I get the same error. I'm wondering what my be wrong with my setup.#2021-05-1407:23thhellersomething JVM/classpath related, can't say more without more information about your overall setup#2021-05-1407:23pedrorgirardiSorry for the long output, but this is what I get with -Stree#2021-05-1407:24thhellerthats not interesting really#2021-05-1407:24pedrorgirardi
org.clojure/data.json 2.2.3
org.clojure/clojure 1.10.3
  . org.clojure/spec.alpha 0.2.194
  . org.clojure/core.specs.alpha 0.2.56
org.clojure/tools.logging 1.1.0
expound/expound 0.8.9
compojure/compojure 1.6.2
  . org.clojure/tools.macro 0.1.5
  . clout/clout 2.2.1
    . instaparse/instaparse 1.4.8
  . medley/medley 1.3.0
  X ring/ring-core 1.8.1 :use-top
  X ring/ring-codec 1.1.2 :superseded
    X commons-codec/commons-codec 1.11 :parent-omitted
org.slf4j/jcl-over-slf4j 1.7.30
  X org.slf4j/slf4j-api 1.7.30 :use-top
com.google.cloud/google-cloud-logging-logback 0.119.0-alpha
  X ch.qos.logback/logback-classic 1.2.3 :use-top
  . ch.qos.logback/logback-core 1.2.3
  . com.google.cloud/google-cloud-logging 2.0.1
  . com.google.guava/failureaccess 1.0.1
  . com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
  . com.google.code.findbugs/jsr305 3.0.2
  . org.checkerframework/checker-compat-qual 2.5.5
  . com.google.errorprone/error_prone_annotations 2.4.0
  . com.google.j2objc/j2objc-annotations 1.3
  . io.grpc/grpc-api 1.34.0
  . io.grpc/grpc-context 1.34.0
  . org.codehaus.mojo/animal-sniffer-annotations 1.19
  . io.grpc/grpc-stub 1.34.0
  . io.grpc/grpc-protobuf 1.34.0
  . io.grpc/grpc-protobuf-lite 1.34.0
  . javax.annotation/javax.annotation-api 1.3.2
  . com.google.auto.value/auto-value-annotations 1.7.4
  . com.google.protobuf/protobuf-java 3.14.0
  . com.google.protobuf/protobuf-java-util 3.14.0
  . com.google.code.gson/gson 2.8.6
  . com.google.api.grpc/proto-google-common-protos 2.0.1
  . com.google.api.grpc/proto-google-cloud-logging-v2 0.85.1
  . com.google.api/gax 1.60.1
  . io.opencensus/opencensus-api 0.24.0
  . com.google.api/gax-grpc 1.60.1
  . io.grpc/grpc-auth 1.34.0
  . com.google.auth/google-auth-library-credentials 0.22.0
  . io.grpc/grpc-netty-shaded 1.34.0
  . io.grpc/grpc-alts 1.34.0
  . io.grpc/grpc-grpclb 1.34.0
  X org.apache.commons/commons-lang3 3.5 :superseded
  . org.conscrypt/conscrypt-openjdk-uber 2.5.1
  . org.threeten/threetenbp 1.5.0
  . com.google.cloud/google-cloud-core-grpc 1.94.0
  . com.google.http-client/google-http-client-jackson2 1.38.0
  . com.fasterxml.jackson.core/jackson-core 2.12.0
  . com.google.http-client/google-http-client 1.38.0
  . org.apache.httpcomponents/httpclient 4.5.13
  . commons-logging/commons-logging 1.2
  X commons-codec/commons-codec 1.11 :superseded
  X org.apache.httpcomponents/httpcore 4.4.13 :superseded
  . io.opencensus/opencensus-contrib-http-util 0.24.0
  . io.grpc/grpc-core 1.34.0
  . com.google.android/annotations 4.1.1.4
  . io.perfmark/perfmark-api 0.19.0
  . com.google.api.grpc/proto-google-iam-v1 1.0.3
  X org.slf4j/slf4j-api 1.7.30 :use-top
  . com.google.api/api-common 1.10.1
  . com.google.cloud/google-cloud-core 1.94.0
  . com.google.auth/google-auth-library-oauth2-http 0.22.0
  X com.google.guava/guava 30.0-android :use-top
org.apache.logging.log4j/log4j-to-slf4j 2.14.1
  X org.slf4j/slf4j-api 1.7.25 :use-top
  . org.apache.logging.log4j/log4j-api 2.14.1
com.cognitect/anomalies 0.1.12
ring-cors/ring-cors 0.1.13
ring/ring-defaults 0.3.2
  X ring/ring-core 1.6.3 :use-top
  . ring/ring-ssl 0.3.0
    X ring/ring-core 1.6.0 :use-top
  . ring/ring-headers 0.3.0
    X ring/ring-core 1.6.0 :use-top
  . ring/ring-anti-forgery 1.3.0
    . crypto-random/crypto-random 1.2.0
    . crypto-equality/crypto-equality 1.0.0
    X hiccup/hiccup 1.0.5 :use-top
  . javax.servlet/javax.servlet-api 3.1.0
com.cognitect/transit-cljs 0.8.269
  . com.cognitect/transit-js 0.8.874
thheller/shadow-cljs 2.12.6
  X org.clojure/data.json 2.2.1 :use-top
  X org.clojure/tools.cli 1.0.194 :superseded
  . org.clojure/tools.reader 1.3.5
  . nrepl/nrepl 0.8.3
  . cider/piggieback 0.5.2
  X com.cognitect/transit-clj 1.0.324 :use-top
  X com.cognitect/transit-cljs 0.8.264 :use-top
  . org.clojure/core.async 1.3.610
    . org.clojure/tools.analyzer.jvm 1.1.0
      . org.clojure/tools.analyzer 1.0.0
      . org.clojure/core.memoize 1.0.236
        . org.clojure/core.cache 1.0.207
          . org.clojure/data.priority-map 1.0.0
      X org.ow2.asm/asm 5.2 :superseded
      X org.clojure/tools.reader 1.3.2 :older-version
  X org.clojure/clojurescript 1.10.844 :use-top
  . com.google.javascript/closure-compiler-unshaded v20210302
  . org.clojure/google-closure-library 0.0-20201211-3e6c510d
    . org.clojure/google-closure-library-third-party 0.0-20201211-3e6c510d
  . org.clojure/google-closure-library-third-party 0.0-20201211-3e6c510d
  . thheller/shadow-util 0.7.0
    X hiccup/hiccup 1.0.5 :use-top
  . thheller/shadow-client 1.3.3
    X org.clojure/core.async 0.3.443 :older-version
    X hiccup/hiccup 1.0.5 :use-top
  . thheller/shadow-undertow 0.1.0
    . org.clojure/core.async 1.3.610
    . io.undertow/undertow-core 2.2.4.Final
      . org.jboss.logging/jboss-logging 3.4.1.Final
      . org.jboss.xnio/xnio-api 3.8.0.Final
        . org.wildfly.common/wildfly-common 1.5.2.Final
        . org.wildfly.client/wildfly-client-config 1.0.1.Final
          X org.jboss.logging/jboss-logging 3.3.1.Final :older-version
          X org.wildfly.common/wildfly-common 1.2.0.Final :older-version
      . org.jboss.xnio/xnio-nio 3.8.0.Final
        . org.jboss.xnio/xnio-api 3.8.0.Final
          X org.jboss.threads/jboss-threads 2.3.3.Final :older-version
      . org.jboss.threads/jboss-threads 3.1.0.Final
        . org.jboss.logging/jboss-logging 3.4.1.Final
  X hiccup/hiccup 1.0.5 :use-top
  X ring/ring-core 1.9.2 :use-top
  . org.graalvm.js/js 21.0.0.2
    . org.graalvm.regex/regex 21.0.0.2
      . org.graalvm.truffle/truffle-api 21.0.0.2
    . org.graalvm.truffle/truffle-api 21.0.0.2
      . org.graalvm.sdk/graal-sdk 21.0.0.2
    . org.graalvm.sdk/graal-sdk 21.0.0.2
    . com.ibm.icu/icu4j 67.1
  . org.graalvm.js/js-scriptengine 21.0.0.2
    . org.graalvm.sdk/graal-sdk 21.0.0.2
  X expound/expound 0.8.5 :use-top
  X fipp/fipp 0.6.23 :use-top
  . com.bhauman/cljs-test-display 0.1.1
  . com.wsscode/pathom 2.2.31
    . com.wsscode/spec-inspec 1.0.0-alpha2
    . spec-coerce/spec-coerce 1.0.0-alpha6
      . com.wsscode/spec-inspec 1.0.0-alpha2
    . edn-query-language/eql 0.0.9
      X org.clojure/test.check 0.10.0-alpha3 :older-version
      X org.clojure/spec.alpha 0.2.176 :older-version
      X org.clojure/core.specs.alpha 0.2.44 :older-version
    X org.clojure/core.async 0.4.474 :older-version
    X org.clojure/test.check 0.10.0-alpha3 :older-version
  . org.clojure/test.check 1.1.0
  . thheller/shadow-cljsjs 0.0.21
org.clojure/clojurescript 1.10.844
  X org.clojure/data.json 0.2.6 :use-top
  X org.clojure/tools.reader 1.3.3 :older-version
  X com.cognitect/transit-clj 0.8.309 :use-top
com.stuartsierra/component 1.0.0
  . com.stuartsierra/dependency 1.0.0
fipp/fipp 0.6.23
  . org.clojure/core.rrb-vector 0.1.1
aero/aero 1.1.6
org.slf4j/jul-to-slf4j 1.7.30
  X org.slf4j/slf4j-api 1.7.30 :use-top
cljs-ajax/cljs-ajax 0.8.3
  . cheshire/cheshire 5.10.0
    X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
    . com.fasterxml.jackson.dataformat/jackson-dataformat-smile 2.10.2
      X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
    . com.fasterxml.jackson.dataformat/jackson-dataformat-cbor 2.10.2
      X com.fasterxml.jackson.core/jackson-core 2.10.2 :older-version
    . tigris/tigris 0.1.2
  X com.cognitect/transit-clj 1.0.324 :use-top
  X com.cognitect/transit-cljs 0.8.264 :use-top
  . org.apache.httpcomponents/httpasyncclient 4.1.4
    X org.apache.httpcomponents/httpcore 4.4.10 :older-version
    . org.apache.httpcomponents/httpcore-nio 4.4.10
      X org.apache.httpcomponents/httpcore 4.4.10 :older-version
    X org.apache.httpcomponents/httpclient 4.5.6 :older-version
    . commons-logging/commons-logging 1.2
  . org.apache.httpcomponents/httpcore 4.4.14 :newer-version
com.brunobonacci/mulog 0.6.5
  . amalloy/ring-buffer 1.3.1
zprint/zprint 1.1.2
  . rewrite-cljs/rewrite-cljs 0.4.5
    X org.clojure/tools.reader 1.3.2 :older-version
  X borkdude/edamame 0.0.11-alpha.28 :superseded
    X org.clojure/tools.reader 1.3.4 :older-version
  X borkdude/sci 0.2.1-alpha.1 :superseded
    X borkdude/sci.impl.reflector 0.0.1 :parent-omitted
    X borkdude/edamame 0.0.11-alpha.27 :parent-omitted
  . rewrite-clj/rewrite-clj 0.6.1
    X org.clojure/tools.reader 1.2.2 :older-version
hiccup/hiccup 1.0.5
org.apache.commons/commons-text 1.9
  . org.apache.commons/commons-lang3 3.11 :newer-version
com.google.guava/guava 30.0-jre
  . com.google.guava/failureaccess 1.0.1
  . com.google.guava/listenablefuture 9999.0-empty-to-avoid-conflict-with-guava
  . com.google.code.findbugs/jsr305 3.0.2
  . org.checkerframework/checker-qual 3.5.0
  X com.google.errorprone/error_prone_annotations 2.3.4 :older-version
  . com.google.j2objc/j2objc-annotations 1.3
datalevin/datalevin 0.4.31
  . org.clojure/tools.cli 1.0.206 :newer-version
  . borkdude/sci 0.2.4 :newer-version
    . borkdude/sci.impl.reflector 0.0.1
    . borkdude/edamame 0.0.11-alpha.29 :newer-version
      X org.clojure/tools.reader 1.3.4 :older-version
  X com.cognitect/transit-clj 1.0.324 :use-top
  . nrepl/bencode 1.1.0
  . com.taoensso/nippy 3.1.1
    X org.clojure/tools.reader 1.3.4 :older-version
    . com.taoensso/encore 3.9.2
      X org.clojure/tools.reader 1.3.3 :older-version
      . com.taoensso/truss 1.6.0
    . org.iq80.snappy/snappy 0.4
    . org.tukaani/xz 1.8
    . org.lz4/lz4-java 1.7.1
  . persistent-sorted-set/persistent-sorted-set 0.1.2
  . org.graalvm.nativeimage/svm 21.0.0.2
    . org.graalvm.nativeimage/svm-hosted-native-linux-amd64 21.0.0.2
    . org.graalvm.nativeimage/svm-hosted-native-darwin-amd64 21.0.0.2
    . org.graalvm.nativeimage/svm-hosted-native-windows-amd64 21.0.0.2
    . org.graalvm.sdk/graal-sdk 21.0.0.2
    . org.graalvm.nativeimage/objectfile 21.0.0.2
      . org.graalvm.compiler/compiler 21.0.0.2
    . org.graalvm.nativeimage/pointsto 21.0.0.2
      . org.graalvm.compiler/compiler 21.0.0.2
    . org.graalvm.truffle/truffle-nfi 21.0.0.2
      . org.graalvm.truffle/truffle-api 21.0.0.2
      . org.graalvm.truffle/truffle-nfi-native-linux-amd64 21.0.0.2
      . org.graalvm.truffle/truffle-nfi-native-linux-aarch64 21.0.0.2
      . org.graalvm.truffle/truffle-nfi-native-darwin-amd64 21.0.0.2
    . org.graalvm.compiler/compiler 21.0.0.2
      . org.graalvm.sdk/graal-sdk 21.0.0.2
      . org.graalvm.truffle/truffle-api 21.0.0.2
  . org.lmdbjava/lmdbjava 0.8.1
    . com.github.jnr/jnr-constants 0.9.15
    . com.github.jnr/jnr-ffi 2.1.15
      . com.github.jnr/jffi 1.2.23
      . com.github.jnr/jffi$native 1.2.23
      . org.ow2.asm/asm 7.1 :newer-version
      . org.ow2.asm/asm-commons 7.1
        . org.ow2.asm/asm 7.1
        . org.ow2.asm/asm-tree 7.1
        . org.ow2.asm/asm-analysis 7.1
      . org.ow2.asm/asm-analysis 7.1
        . org.ow2.asm/asm-tree 7.1
      . org.ow2.asm/asm-tree 7.1
        . org.ow2.asm/asm 7.1
      . org.ow2.asm/asm-util 7.1
        . org.ow2.asm/asm 7.1
        . org.ow2.asm/asm-tree 7.1
        . org.ow2.asm/asm-analysis 7.1
      . com.github.jnr/jnr-a64asm 1.0.0
      . com.github.jnr/jnr-x86asm 1.0.2
#2021-05-1407:24pedrorgirardi
binaryage/devtools 1.0.3
re-frame/re-frame 1.2.0
  . reagent/reagent 1.0.0
    X cljsjs/react 17.0.1-0 :excluded
    X cljsjs/react-dom 17.0.1-0 :excluded
    X cljsjs/react-dom-server 17.0.1-0 :excluded
  . net.cgrand/macrovich 0.2.1
  X org.clojure/tools.logging 1.1.0 :use-top
com.cognitect/transit-clj 1.0.324
  . com.cognitect/transit-java 1.0.343
    X com.fasterxml.jackson.core/jackson-core 2.8.7 :older-version
    . org.msgpack/msgpack 0.6.12
      . com.googlecode.json-simple/json-simple 1.1.1
      . org.javassist/javassist 3.18.1-GA
    X commons-codec/commons-codec 1.10 :older-version
    . javax.xml.bind/jaxb-api 2.3.0
nano-id/nano-id 1.0.0
lambdaisland/glogi 1.0.106
org.slf4j/slf4j-api 1.7.30
metosin/reitit-frontend 0.5.13
  . metosin/reitit-core 0.5.13
    . meta-merge/meta-merge 1.0.0
ch.qos.logback/logback-classic 1.2.3
  . ch.qos.logback/logback-core 1.2.3
  X org.slf4j/slf4j-api 1.7.25 :use-top
ring/ring-mock 0.4.0
  X cheshire/cheshire 5.8.1 :older-version
  X ring/ring-codec 1.1.1 :older-version
org.slf4j/log4j-over-slf4j 1.7.30
  X org.slf4j/slf4j-api 1.7.30 :use-top
ring/ring-core 1.9.3
  . ring/ring-codec 1.1.3 :newer-version
    . commons-codec/commons-codec 1.15 :newer-version
  . commons-io/commons-io 2.6
  . commons-fileupload/commons-fileupload 1.4
    X commons-io/commons-io 2.2 :older-version
  . crypto-random/crypto-random 1.2.0
    X commons-codec/commons-codec 1.6 :older-version
  . crypto-equality/crypto-equality 1.0.0
world.convex/convex /Users/pedro/Developer/convex-dev/convex-web/convex.jar
  . org.apache.commons/commons-lang3 3.11
http-kit/http-kit 2.5.3
#2021-05-1407:25thhellerthe relevant graal js deps are there. try 2.12.4, I suspect that to be broken too#2021-05-1407:25thhellermaybe even delete .cpcache and 2.12.5 might be broken after too#2021-05-1407:26pedrorgirardiLet me try#2021-05-1407:27borkdude@pedrorgirardi I suspect your error message has to do with deps in datalevin, it seems it pulls in GraalVM SVM: https://github.com/juji-io/datalevin/blob/4e699c5a45cc0013420b70afdf5dcb48199c25e1/project.clj#L35#2021-05-1407:27pedrorgirardiTrue @borkdude!#2021-05-1407:28borkdudeI think datalevin should not be doing that, unless you build for graalvm#2021-05-1407:28borkdudebut perhaps he has reasons to do it, not sure#2021-05-1407:29pedrorgirardiYeah, that's a good point. Let me see if I can simply ignore it because I'm embedding Datelevin in my app.#2021-05-1407:30pedrorgirardiAnd @thheller, 2.12.4 works fine too.#2021-05-1407:30thhellerodd#2021-05-1407:31thhellerah in 2.12.6 I updated the graal-js dependency. so I guess thats the cause then#2021-05-1407:32borkdudeI think he only needs those deps when he compiles a native image: https://github.com/juji-io/datalevin/blob/ab421c34b9abee61ef574a57fb1c75f9033fbba2/native/src/java/datalevin/ni/Lib.java so I think it's worth pointing that out to him and try to get him to move the dep to a profile#2021-05-1407:32borkdudeoh you also have a graal-related dependency, hmm, that explains it probably#2021-05-1407:33thhellerjust the graal-js scriptengine, not graalvm related#2021-05-1407:33thhellerjdk15 removed nashorn and graal-js was the replacement#2021-05-1407:33borkdudebut that is built on graalvm?#2021-05-1407:34thheller@pedrorgirardi you can try manually adding [org.graalvm.js/js "21.1.0"] and [org.graalvm.js/js-scriptengine "21.1.0"]. maybe those fix it too (newer versions than shadow-cljs currently uses)#2021-05-1407:34pedrorgirardiHm, I tried tried:
datalevin/datalevin {:mvn/version "0.4.31"
                       :exclusions [org.graalvm.nativeimage/svm]}
but Daletinv complains about a ClassNotFound.
#2021-05-1407:34thhellerno, not built on graalvm (as in the actual JVM)#2021-05-1407:35pedrorgirardiWill add the dependencies @thheller.#2021-05-1407:35borkdudefwiw datalevin uses 21.0.0.2#2021-05-1407:35pedrorgirardiYes @borkdude you right, that's what I have in my classpath#2021-05-1407:35pedrorgirardiorg.graalvm.nativeimage/svm 21.0.0.2#2021-05-1407:36borkdude@huahaiy Please read this discussion when you are awake :) - there might be a way to exclude the graalvm specific deps in datalevin as a JVM lib#2021-05-1417:53HuahaiThis is needed because I am using a GraalVM method to detect if we are running in GraalVM, which would use GraalVM specific binding for LMDB. Is there another reliable way to detect this?#2021-05-1417:55borkdudeYou can detect this using a System property#2021-05-1417:55Huahaiwhich one?#2021-05-1417:56Huahai
`Boolean.getBoolean("com.oracle.graalvm.isaot")`?
#2021-05-1417:56borkdude
bb -e '(clojure.pprint/pprint (into {} (System/getProperties)))'
{"babashka.version" "0.4.1-SNAPSHOT",
 "org.graalvm.nativeimage.kind" "executable",
 "path.separator" ":",
 "user.dir" "/Users/borkdude/dre/DocSearch/app",
 "java.vm.specification.vendor" "Oracle Corporation",
 "java.vendor.url" "",
 "java.specification.name" "Java Platform API Specification",
 "line.separator" "\n",
 "java.vm.version" "GraalVM 21.0.0 Java 11",
 "java.vendor" "Oracle Corporation",
 "java.specification.vendor" "Oracle Corporation",
 "java.vm.specification.version" "11",
 "java.io.tmpdir" "/var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/",
 "java.class.path" "",
 "java.vm.vendor" "Oracle Corporation",
 "org.graalvm.nativeimage.imagecode" "runtime",
 "java.vm.name" "Substrate VM",
 "java.version" "11.0.10",
 "os.arch" "amd64",
 "user.home" "/Users/borkdude",
 "java.specification.version" "11",
 "java.ext.dirs" "",
 "sun.jnu.encoding" "UTF-8",
 "sun.arch.data.model" "64",
 "java.class.version" "55.0",
 "file.encoding" "UTF-8",
 "os.name" "Mac OS X",
 "os.version" "10.14.6",
 "jdk.lang.Process.launchMechanism" "FORK",
 "file.separator" "/",
 "java.vm.specification.name" "Java Virtual Machine Specification",
 "java.endorsed.dirs" "",
 "java.library.path" "",
 "user.name" "borkdude"}
#2021-05-1417:56borkdudelet's see...#2021-05-1417:56borkdudeI think you can use "org.graalvm.nativeimage.kind" "executable"#2021-05-1417:56borkdudeor perhaps "org.graalvm.nativeimage.imagecode" "runtime"#2021-05-1417:57borkdudeI usually use one of both#2021-05-1417:57Huahaiok, let me try that, thanks!#2021-05-1418:27borkdude@huahaiy You can also make a top-level variable that captures one of your own environment variables during graalvm compilation#2021-05-1418:27borkdudeand then use that accordingly#2021-05-1603:35Huahai@pedrorgirardi GraalVM dependencies are removed from Datalevin 0.4.34 JVM library#2021-05-1603:36pedrorgirardiThat’s great! Will upgrade to the latest version. Thank you @huahaiy .#2021-05-1603:37pedrorgirardiAnd thank you once again for your help @borkdude . Really appreciated!#2021-05-1603:38HuahaiPlease let me know if it works#2021-05-1603:40pedrorgirardiWill do.#2021-05-1603:47pedrorgirardiYep, it worked beautifully :)#2021-05-1407:37thhellerthis is one of those situations where I recommend keeping your CLJS setup separate from your CLJ setup. way too annoying to deal with dependency conflicts such as this#2021-05-1407:37pedrorgirardiTests are passing with org.graalvm.js/js {:mvn/version "21.1.0"}, will try to upgrade Shadow CLJS now.#2021-05-1407:38borkdude@thheller I think this shouldn't have happened in the first place, probably both dependencies should be opt-in#2021-05-1407:38thhellerif 21.1.0 fails just downgrade to 20.1.0 which is what 2.12.5 and before used#2021-05-1407:38pedrorgirardiOk#2021-05-1407:41thhellermaybe move datalevin to a CLJ specific alias that isn't used when running CLJS#2021-05-1407:42pedrorgirardiThat's a good idea!#2021-05-1407:42pedrorgirardiBut this fixed it#2021-05-1407:42pedrorgirardi
org.graalvm.js/js {:mvn/version "20.1.0"}
  org.graalvm.js/js-scriptengine {:mvn/version "20.1.0"}
#2021-05-1407:43pedrorgirardiI think I will try to move server only dependencies to its own alias 😐#2021-05-1407:43pedrorgirardiThank you very much @thheller and @borkdude!#2021-05-1410:26Arondaily fun: I am doing something wrong and hot reload results in an infinite loop eating up all my memory#2021-05-1410:31AronHolding Code references in State I am generating the UI, kinda a must to hold it in the state at some point.#2021-05-1411:04thhellerthat likely is an invalid reference. holding on to some state does not cause an infinite loop#2021-05-1411:06Aronit is an invalid reference according to some stack trace snippets, but I don't really understand what it says, and I am sure it's me doing the incorrect thing not some bug in the tools I use Uncaught TypeError: Cannot read property 'cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3' of null#2021-05-1411:07Aronthis is just one of the weird errors#2021-05-1411:07thhellerthat error is a core.async put on nil#2021-05-1411:07Aronhmm#2021-05-1411:08thheller(>! nil something)#2021-05-1411:08Aronyes, thank you, I understand what you mean and it fits very well, I can easily imagine that react runs some piece of code that references to the old queue before the hot reload#2021-05-1412:03Aron> shadow-cljs is rather strict about namespace references dunno, without the linter I wouldn't know half my imports are missing : D#2021-05-1412:46AronI thought putting defonce on the channel will solve this issue with the null, but no#2021-05-1412:47thhellerdon't know what you are refering to#2021-05-1412:48Aronput on nil. I thought that because the page is reloading out of order, some react registered thing on the callstack sees the channel I am putting on as nil, because it was removed from under it. So I defined the channel with defonce not def.#2021-05-1412:49Aronbut really, the bigger issue is that somehow the interaction between shadow-cljs hot reload and my react code results in a memory leak and kills my browser process#2021-05-1412:50Aronit started when I pust unsub and close into the return functions of my react useEffect hooks, before that I only got the usual memory leak message from react that i am trying to do something with unmounted state, and I thought I am fixing something, but actually managed to make it worse#2021-05-1412:51Aronhttps://i.imgur.com/vT6qiNq.png#2021-05-1412:52thhellerone bug I can see is the (swap! timeouts conj @timeouts ...). remove the @timeouts#2021-05-1412:53Aron🙂#2021-05-1412:53Aronthank you#2021-05-1412:54thhellerand I think the use-layout-effect is wrong, looks like it is missing a wrapping (fn [] ...)#2021-05-1412:56thhelleralso you are always recur'ing, so there is never a check whether it should stop or not#2021-05-1412:59Aronwhat would such a check look like#2021-05-1412:59thheller(when-some [msg (<! notification-chan] ... (recur))#2021-05-1413:02Aronmy understanding was that inside go-loop, <! is blocking, if I close the channel, it should not call recur#2021-05-1413:02thhellerclearTimeouts is also using map lazy seq,so it never actually clears anything#2021-05-1413:02thhellerthat is incorrect. when you take from a channel and that is closed it returns nil#2021-05-1413:02Aronyeah, as you see, I was editing the code before I sent the screenshot#2021-05-1413:03AronI see, thanks for the correction#2021-05-1419:01bartukaI am following a dynamic export (https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_exports) to emit code to be used as node libraries and one of my forms is a defmacro. I currently get an error when I compile the code as Can't take the value of macro ...path-to-var what do I need to do here?#2021-05-1419:02bartukaI already have (:require-macros [my.core.ns :refer [macro-var]) in top level#2021-05-1419:38bartukaI made the code available online https://github.com/wandersoncferreira/respondent/blob/c420359ca838c510d0183be3452c293d137cd9b2/src/respondent/core.cljc#L127 this is the macro I want to export#2021-05-1419:45or@iagwanderson: I believe you need a (:require-macros [respondent.core]) in a respondent/core.cljs file, it requires the macros from its own namespace. I haven't done it in a .cljc file, but I guess you can just add it to the top there as well for :cljs.#2021-05-1419:50bartukaI tried to add
#?(:cljs (:require-macros [cljs.core.async.macros :refer [go go-loop]]
                            [respondent.core :refer [behavior]]))
to the top and didnt work
#2021-05-1420:01thheller@iagwanderson https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html missing the self-require as oliver said#2021-05-1420:05bartukaI will read the post first.. interesting bit already: > > I strongly recommend writing your macros in 2 separate files until you feel comfortable with that. I still do it for 100% of my macros.#2021-05-1420:06thhelleryeah, cljc makes things a lot more complicated#2021-05-1420:56bartukaThanks for help @oliver and @thheller... getting closer to the answer here.. I do not have the error while compiling, but when I run the node.js script using the library it gives me undefined for the macro https://github.com/wandersoncferreira/respondent/blob/main/src/respondent/behavior.cljs#2021-05-1421:03bartukamight be Gotcha #3 now 😃 will change it here...#2021-05-1422:00bartuka@thheller I might have found the issue. I believe the first implementation was already good. However, if I try to refer to my macro anywhere other than in the first position of a form I get the same error Can't take value of macro.. .. I tried two things 1) calling my macro inside #js {:behavior (behavior)} export map and it worked! and 2) added (println (identity behavior)) to the code and got the same error Can't take value of macro.... maybe I cannot export macros ?#2021-05-1422:26bartukayeah, makes sense#2021-05-1421:58Jacob EmckenI need my ClojureScript SPA to know of URL that differs from when I develop (run locally) and when the app gets deployed into production. I've been scrolling through the documentation... but nothing stands out to me as useful. I assume this is a quite common need, so I've come to conclusion that I just don't have the right terminology to find it. Can anyone give pointers?#2021-05-1422:21Jacob EmckenI did stumble over shadow-env but it seemed overly complicated so I assumed there was a simpler (better?) way.#2021-05-1422:37Jacob Emckenmaybe let a single value point to a file path that gets read/included... then the file path points to an edn file?#2021-05-1422:38Jacob Emckenhmmm :thinking_face: but it should all happen on build time.#2021-05-1422:39Jacob EmckenLet's see if anyone else pitches in with ideas 😄#2021-05-1506:47thhelleryour question really is a little vague. there are about hundreds of ways to do this, it really depends on your app and how you want to do it. :closure-defines would be the build-config driven variant. see also https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2021-05-1506:49thhelleryou can also get stuff from the HTML directly, or load if via fetch on startup. really far to many options to mention them all.#2021-05-1507:09yalu👋 I have this problem working with npm library called js-waku https://stackoverflow.com/questions/66309813/the-required-js-dependency-readable-stream-writable-js-is-not-available-it-wa#2021-05-1507:11yaluI tried forcing version 2.0.2 of readable-stream as suggested in SO solution but get another error after that transpilation of BigInt is not supported#2021-05-1507:12yaluThank you for any help unraveling this mystery#2021-05-1507:14thhellertry :compiler-options {:output-feature-set :es2018} in your build config. maybe :es2019 or :es2020. not sure which language level bigints were#2021-05-1507:52yaluCool thank you that make sense I will give it a go#2021-05-1508:00yaluSeems it was in :es2020 but still no dice 😞 I get failed to convert sources on a whole bunch of libraries#2021-05-1508:00thhellerI cannot guess the errors you get sorry#2021-05-1508:01thheller:ex-next-in is the highest level possible, maybe that works#2021-05-1508:03yaluooohh that might js-waku is written in typeScript with compiler option esnext#2021-05-1508:03thhellerthat isn't relevant, js config options don't apply to closure compiler options#2021-05-1508:05yalustill that did not work same failed to convert sources error
npx shadow-cljs watch frontend
shadow-cljs - config: /Users/yalu/Projects/nemonymous/shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.13.0 running at 
shadow-cljs - nREPL server started on port 50869
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/object-assign/index.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.production.min.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.development.js"] [:shadow.build.npm/resource "node_modules/react/index.js"] .............................................
#2021-05-1508:05thhellerdon't shorten errors ... you cut out the reason why it failed#2021-05-1508:14yaluIt was too big to fit.. so attaching file of log#2021-05-1508:15thheller
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SHEQ): node_modules/bcrypto/lib/native/bn.js:3605:6
  if ((y & 1n) === 0n)
  Parent(IF): node_modules/bcrypto/lib/native/bn.js:3605:2
  if ((y & 1n) === 0n)
#2021-05-1508:15thhellerthis is a closure-compiler error, it appears that it doesn't support the code#2021-05-1508:16thhelleryou can try using webpack with this method https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-05-1508:17yaluThank you for the prompt response and incredible patience 🙏 I will give webpack a go#2021-05-1508:18thhellerare you sure this code is supposed to be supported in the browser? I see a bunch of node specific stuff so it looks like a node thing to me?#2021-05-1508:23yaluI am pretty sure it is supposed to be supported in the browser https://www.npmjs.com/package/js-waku#2021-05-1508:27thhellerhmm yeah seems rather cutting edge#2021-05-1508:29yaluyeah.. freshly released.. hardly battle tested.. I'm also communicating with the dev.. so let's see I'm going to try everything I can#2021-05-1606:14Franklinhello, I'm trying to run tests with karma and I get this error:
user:shadow-quagga$ yarn karma start --single-run
yarn run v1.21.1
$ /home/user/work/node_modules/.bin/karma start --single-run
16 05 2021 09:13:28.366:INFO [karma-server]: Karma v6.3.2 server started at 
16 05 2021 09:13:28.367:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
16 05 2021 09:13:28.371:INFO [launcher]: Starting browser ChromeHeadless
16 05 2021 09:13:28.623:INFO [Chrome Headless 90.0.4430.212 (Linux x86_64)]: Connected on socket BOp0uUsEZlSbo7HdAAAB with id 30514711
Chrome Headless 90.0.4430.212 (Linux x86_64) ERROR
  ReferenceError: test is not defined
      at eval (eval at <anonymous> (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:15)
      at ContextKarma.start (/home/user/work/zebra/shadow-quagga/node_modules/karma-cljs-test/adapter.js:6:7)
      at ContextKarma.loaded ()
      at 
#2021-05-1606:15Franklinnot sure what I'm missing... I have a test build that looks like this
:ci {:target :karma
       :output-to "out/ci.js"
       :ns-regexp "-test$"}
#2021-05-1606:15Franklinmy karma.conf.js looks like this
// See 
module.exports = function(config) {
    config.set({
        frameworks: ['cljs-test'],
        plugins: ['karma-cljs-test', 'karma-chrome-launcher', 'karma-junit-reporter'],

        basePath: 'out',

        // If you need to include custom JavaScript files, put them here.
        files: [
            // We serve all the JS files via Karma's webserver so that you can
            // use :optimizations :none. Only test_suite.js is included because
            // CLJS does its own module loading.
            'ci.js'
        ],
        colors: true,
        logLevel: config.LOG_INFO,
        client: {
            args: ['quagga.runner-test.run'],
            singleRun: true
        },

        // If you don't like the progress reporter, you could try 'dots'
        reporters: ['progress', 'junit'],

        // If you want to use other browsers, you need to install the launchers
        // for them! E.g. npm install --save-dev karma-firefofx-launcher
        browsers: ['ChromeHeadless'],

        reportSlowerThan: 500, // ms

        // We disable autoWatch, because it executes tests while the code is
        // still comiling. We use :notify-command to trigger them instead.
        autoWatch: false,

        // Configuration for JUnit output. We care only about the output directory.
        // This directory is relative to basePath, so the XML files will be 
        // in `target/out/reports`.
        // <>
        junitReporter: {
            outputDir: 'reports'
        }
    });
}
#2021-05-1606:16Franklinin the quagga.runner-test namespace I have a run function that looks like this
(defn ^:export run [karma]
  (karma/run-tests
   karma
   'quagga.events-test))
#2021-05-1606:17Franklinan in the quagga.events-test namespace
(ns quagga.events-test
  (:require [cljs.test :refer-macros [deftest is testing run-tests]]))

(deftest first-test
  (testing "hello world test"
    (is (= 1 1))))
#2021-05-1606:22Franklinactually, I found my issue#2021-05-1606:22Franklinseems a _ was expected where I placed a -#2021-05-1607:29thhelleryeah this in JS quagga.runner-test.run means quagga.runner MINUS test.run#2021-05-1608:24MargoHello, people! Trying to figure out how to configure cljfmt with shadow-cljs.edn . Any tips?#2021-05-1608:43thhelleryou can run it via shadow-cljs run cljfmt.main#2021-05-1708:06zimablueHi, I'm using shadow-cljs version 2.12.7 with config like this :node {:target :node-library :compiler-options {:infer-externs :auto} :devtools {:repl-timeout 100000}#2021-05-1708:06zimablueand getting timeout errors still, the timeout seems to be ignored#2021-05-1708:07thhellerwhat timeouts are you talking about?#2021-05-1708:09thheller:repl-timeout only controls how long shadow will wait for an result of a repl evaluation#2021-05-1708:11zimablueah, It's a timeout when I'm in node-repl and I run an import statement#2021-05-1708:11zimablueit's intermittent#2021-05-1708:11zimabluesorry by import I mean require#2021-05-1708:12thhellerI'm totally in the dark here. I don't have a clue what you are talking about. Please be more specific.#2021-05-1708:13zimablueI'm sorry#2021-05-1708:13zimablueI run the command "shadow-cljs node-repl node"#2021-05-1708:13zimabluethen I am in a repl, which works fine#2021-05-1708:13thhellerok, first mistake. node-repl is standalone, it is NOT controlled by any build config#2021-05-1708:13zimabluebut some statements cause a timeout, which then stops the repl from working any more#2021-05-1708:13zimablueah#2021-05-1708:14zimablueso how can I create a node repl using shadow-cljs which I can configure the timeouts for?#2021-05-1708:15thhellerfirst explain why configuring a timeout is necessary. 30sec default is plenty and should NEVER be encountered in a node repl. Unless you compile a millions lines of CLJS via the require or so#2021-05-1708:18zimablueI don't know why it's necessary, sorry. I just know that it's timing out. I can try to work that out#2021-05-1708:18zimabluejust by binary searching the imports to work out which one is heaviest? but it's slightly tough to debug because it only happens 50% of the time#2021-05-1708:18thhellerI'm asking WHAT you are doing? Why do you think increasing the timeout is necessary?#2021-05-1708:19thhellerI have seen no code or anything so I'm guessing ...#2021-05-1708:20zimablueI'm hacking on datahike, a clojurescript library, and encountering timeout errors. Because it's intermittent and something to do with compiling, working out the precise origin seemed like it would be tough so my first instinct was just to increase the timeout#2021-05-1708:22thhellernote that getting a timeout does NOT stop the action from actually running#2021-05-1708:23thhellerit'll just cause the REPL to no longer wait and give you another prompt#2021-05-1708:24thhellerbut yeah you are not providing enough information to offer any kind of suggestion#2021-05-1708:24thhellera REPL for your actual build you get via shadow-cljs cljs-repl node (assuming :node is the build id)#2021-05-1708:25thhellerthat will then also respect your timeout settings, just need to manage the node process yourself then#2021-05-1708:29zimabluethank you, sorry for the poor information, I think that you have helped me#2021-05-1721:36mauricio.szaboHi, @thheller. Once, you told me of a parameter that allows me to debug the compilation process of Shadow-CLJS. What's the parameter? The reason is that my hot-reload is taking a looong time, and I want to be able to se what's happening.#2021-05-1807:29thhellerhot-reload or compilation? you can get more details for the compilation parts via shadow-cljs watch app --verbose#2021-05-1807:29thhellerhot-reload itself doesn't have options#2021-05-1813:38mauricio.szaboAll right, I'll try --verbose and see if it helps#2021-05-1723:17mauricio.szaboAlso, is there a way to not remove deftest and friends in compilation process? I know I can use another target, but I'm doing some weird things and I want to control how to run specific tests so I'm using a target :node-script 😄#2021-05-1723:24mauricio.szabo(Nevermind the last question: I can use :load-tests true on :compiler-options)#2021-05-1803:42Aronthere is a --test= argument for the compiled tests#2021-05-1803:42Aronif the target is node-test#2021-05-1807:24Franklinhello, is there any need to have test dependencies in any way separated from the other (runtime) dependencies. Will shadow-cljs automatically remove unused dependencies when I run shadow-cljs release app?#2021-05-1807:30thheller@franklineapiyo your builds only include whatever you :require in your namespaces. having extra :dependencies does not matter when they are not required in your build directly. generate a build report to see what ended up in your build and why https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2021-05-1807:32Franklinthanks#2021-05-1814:01MargoHello, channel! I am trying to generate a js with a hash for my project, but it seems I have no idea how to dynamically include a hashed js file into an html. How do I make sure that my index.html file includes the latest module with a hash if I use
:module-hash-names
?
#2021-05-1814:43MargoI am trying to get a selmer workaround#2021-05-1817:26thhelleryou can use the manifest to generate the HTML you need https://shadow-cljs.github.io/docs/UsersGuide.html#BrowserManifest#2021-05-1817:26thhelleror you can use this hook https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L150-L152#2021-05-1817:27thhellerit'll copy the src html and rewrite the script src with the hashed names#2021-05-1915:34MargoI have tried that approach but it looks like unfortunately it doesnt work#2021-05-1915:34MargoUnless I am missing something#2021-05-1915:36thhellerno way for me to tell without seeing what you did 😛 I know that the implementation works since I use it#2021-05-1915:37thhellerbasically you need to have a source html file that has <script src="/js/base.js"></script> tag already#2021-05-1915:37thhellerall the copy does is replace the src path, and only if the source path matches you configured :asset-path + the module name#2021-05-1915:38Margoright ... Ill try to double check! Thanks for coming back to me so quickly!#2021-05-1915:46Margolooks like I have the setup correctly, but it still doesnt do the desired thing ...#2021-05-1915:47thhellerwhat is your :asset-path? what is your script src? and what is your :build-hooks config?#2021-05-1915:48thhellernot that many things affect this so should be easy to find#2021-05-1915:48MargoI have src/index.html file that contains <script _src_="js/compiled/main.js" _type_="text/javascript"></script> tag. I have shadow-cljs.edn that has
:frontend
    {:target :browser
     :output-dir "public/js/compiled"
     :asset-path "/js/compiled"
    ;;  :compiler-options {
    ;;                     ;; add env vars
    ;;  }


     :build-hooks [(shadow-env.core/hook)
                   (shadow.html/copy-file
                    "public/src/index.html"
                    "public/index.html")]


     :module-hash-names true
    ;; ;;  :fingerprint true
    ;;  :build-options {:manifest-name "manifest.json"}
     :modules {:main
               {:init-fn mytherapy.core/init!}}
    ;;  :compiler-options {:externs ["public/js/plugins/"]}
     }
#2021-05-1915:48thhellerwell there you have it 😛#2021-05-1915:48thhelleryou have :asset-path "/js/compiled" but use script src="js/compiled/main.js"#2021-05-1915:48thhellerthat needs to match, so switch either#2021-05-1915:50Margolike (not (= "/js/compiled" "js/compiled)) type of match?#2021-05-1915:51thhelleryes, exact match. not only for the purpose of this hook, they should always match#2021-05-1915:54MargoI dont know, if I switch to <script _src_="/js/compiled/main.js" _type_="text/javascript"></script> and :output-dir "public/js/compiled" and :asset-path "/js/compiled" they do not seem to affect the behaviour#2021-05-1915:56thhellerhttps://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-05-1915:57thhellerhopefully the second part about output paths and http makes that a bit clearer#2021-05-1915:57Margothanks! Ill read into it!#2021-05-1915:57thhellervery likely you want :asset-path "/js/compiled" and script src="/js/compiled/main.js"#2021-05-1915:59Margothat is literally what I have#2021-05-1915:59Margo#2021-05-1916:00Margook, actually, needed to clear cache#2021-05-1916:00Margonow it works#2021-05-1916:00MargoWith the paths being identical!#2021-05-1916:00MargoThanks a lot! Very useful tip!#2021-05-1817:47rwstauneri'm trying to fix an issue in a dep two levels down with an externs file. i can get the extern to work if i put the file in my repo and add it to :externs but i'm trying to add it to the dep (via deps.cljs in that jar) so that other projects can get it for free... but it isn't getting picked up that way. anyone know if this does or doesn't work? versions to use? pointers on debugging?#2021-05-1817:49rwstauneri'd love to have shadow-cljs print out what it's passing to the compiler... if that's even how it works 🙂#2021-05-1817:50rwstauneror does anyone know if {:externs ["file.js"]} is enough... or does it need foreign-libs to work? (from a jarred deps.cljs)#2021-05-1818:53rwstaunerthe shadow build produces a jar manifest that has the externs file contents (in "~:resources"), but the "~:externs" is just [] ... there aren't any other files in it though... it looks like it's treating it as a js module#2021-05-1819:07rwstaunerconfirmed, if i rename that file to .txt it no longer shows up in the manifest even though it's supposed to be in :externs#2021-05-1819:44thheller@clj149 shadow-cljs does not support externs via deps.cljs#2021-05-1819:45thhellerand regular CLJS doesn't support the simplified .txt externs#2021-05-1819:45rwstaunerok, thanks#2021-05-1819:45rwstaunerso any externs required must be in the project being built#2021-05-1819:46thhelleryeah, libraries nowadays should really use ^js hints when needed. that works in everything and is easier to maintain.#2021-05-1819:47rwstauneryeah, i've confirmed that that helps, but was trying to hack around external libraries if there was any magic way to do it#2021-05-1819:47rwstaunerthanks#2021-05-1908:49zachHello! When using shadow-cljs, would passing --config-merge on compile be a good place to give environment variables? e.g: building for production doing a --config-merge '{:closure-define { secretkey "s1234"}#2021-05-1908:50thhelleryes, that is what it was made for#2021-05-1908:50thhelleralthough you shouldn't put "secrets" into your build ever, in JS nothing is "secret"#2021-05-1908:51thhellerbut in general yes, config merge or #shadow/env work for this#2021-05-1908:55zachAwesome, thank you!#2021-05-2107:29Aronfor 2 minutes today I was panicking that my shadow-cljs setup broke, but then i realized that the webserver i hosted the build was running from a different docker instance than the shadow-cljs server (same directory mounted in two different instances)#2021-05-2108:20Franklinhello, I keep getting the folloiwing error while trying to use https://www.npmjs.com/package/@yaireo/tagify js library,
views.cljs:328 Uncaught TypeError: module$node_modules$$yaireo$tagify$dist$tagify_min.default is not a constructor
    at cmp.eval (views.cljs:328)
    at cmp.reagent$impl$component$custom_wrapper_$_componentDidMount [as componentDidMount] (component.cljs:207)
    at commitLifeCycles (react-dom.development.js:20664)
    at commitLayoutEffects (react-dom.development.js:23427)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3946)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:3995)
    at invokeGuardedCallback (react-dom.development.js:4057)
    at commitRootImpl (react-dom.development.js:23152)
    at exports.unstable_runWithPriority (scheduler.development.js:469)
    at runWithPriority$1 (react-dom.development.js:11277)
#2021-05-2108:20Franklinthe require looks like this ["@yaireo/tagify" :as Tagify]#2021-05-2108:21Franklinwhich corresponds to import Tagify from '@yaireo/tagify'#2021-05-2108:22Franklinand the line where the error is thrown looks like this: (Tagify. html-input-element)#2021-05-2108:23Franklinit's not clear to me why I'm getting this error because it's previously worked ok (but I might be mistaken; 🤷 )#2021-05-2108:27thheller["@yaireo/tagify" :as Tagify] does NOT correspond to import Tagify from '@yaireo/tagify'#2021-05-2108:27thhellersee the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-05-2108:28thhellerbut it looks like you have ["@yaireo/tagify" :default Tagify]?#2021-05-2108:28thhellermaybe need to actually try :as. see the section about default exports in the link above#2021-05-2309:16Franklinok... so, after messing around for a while and trying different things; this works for me ["@yaireo/tagify/dist/react.tagify" :default Tagify]#2021-05-2309:16Franklinseems there was a better way of using tagify with React that I didn't know about#2021-05-2111:03murtaza52I am using moment js library in my shadow-cljs project. I have tried including both the cljsjs lib and the npm package. The advanced compilation breaks the moment js usage, any leads on how I can make it work ?#2021-05-2111:05thhellerbreaks how?#2021-05-2111:12murtaza52this is the error I see in the browser console, the page never loads -
Uncaught TypeError: Cra.initializeApp is not a function
    Jra 
    <anonymous> 
    onload 
#2021-05-2111:12murtaza52There is no error and the app works fine with shadow-cljs watch app#2021-05-2111:12thhellerthat doesn't look moment related? where do you call initializeApp or what on?#2021-05-2111:14thhellertry shadow-cljs release app --debug#2021-05-2111:14thhellermaybe that provides a better clue what fails#2021-05-2111:14murtaza52thanks lets me try that#2021-05-2120:53Tomas BrejlaHi. I'm currently not using any "UI component framework" in my cljs app which utilizes shadow. And my compilation times are awesome so far (sub second times for tiny changes : 0.25 - 0.5s). I tried introducing material-ui library to my project. This specific library might be an overkill, really - I just knew that a friend of mine was using it on his project, so I wanted to try it. It's likely I'll not end up using it in the end. Importing the library to my project was easy. But suddenly, even a tiny change in some label inside my namespace resulted in 5-6s compile time instead of sub-1s. No matter how tiny the change was. Would splitting my namespaces into more modules (such as :shared shown in user manual) help here? Or is there any other way of improving the compilation performance?#2021-05-2120:54thhellerhmm how did you add it? should only make the compile slower once, after that cache should take care of it#2021-05-2120:56thheller(no, :modules won't do anything regarding performance)#2021-05-2121:02Tomas BrejlaInteresting. I have already stashed my changes in the past, so I'll try to do it again from scratch on current (fast) version. But I guess I just npm-installed the library, created a new namespace which :require-d and aliased the library and then used (r/adapt-react-class to make react class adapters.#2021-05-2121:05thhellerthat should be fine#2021-05-2121:06Tomas BrejlaI've done the same and it's super fast now facepalm 😄#2021-05-2121:06thhellersometimes helps to restart shadow-cljs if you've just done a npm install. that modifies a lot of files and sometimes shadow-cljs gets out of sync with that#2021-05-2121:07Tomas Brejlais there any "temporary" folder eg. with some caches for shadow-cljs which one might try deleting when really desperate? 🙂#2021-05-2121:08thheller.shadow-cljs/builds but that usually does nothing. restart is enough.#2021-05-2121:08Tomas BrejlaOk, perfect. Thanks#2021-05-2121:16Tomas Brejla@thheller oh, I see the problem now. When I'm only importing ["@material-ui/core" :as mc], it's fine, but once I also add ["@material-ui/icons" :as mi] , the slowness starts.#2021-05-2121:17Tomas Brejlaand I'm not surprised 😱
➜  myproject git:(master) ✗ find node_modules/@material-ui/icons -type f | wc -l
16674
➜  myproject git:(master) ✗ du -sh node_modules/@material-ui/icons          
201M	node_modules/@material-ui/icons
#2021-05-2121:18thhelleroh you shouldn't be doing that anyways. that will add several megabytes to you build and you are likely not using those thousands of icons#2021-05-2121:18thhellerjust import what you need directly#2021-05-2121:20thhellersame for material-ui too basically. those will bloat your build so much#2021-05-2121:21thhellerjust (:require ["@material-ui/icons/ZoomIn" :default ZoomIn]) instead of (:require ["@material-ui/icons" :refer (ZoomIn)])#2021-05-2121:22thhellerbut yeah adding a couple thousand files to your build might make it slower 😉#2021-05-2121:25Tomas BrejlaIndeed 😄. I made a typical textbook mistake. Made too many changes at once. Therefore it didn't occur to me that it was the actual naive import of icons' namespaces which introduced this slowness. I simply thought that it was the library size and complexity which made the compilation slow. Thanks for your help.#2021-05-2211:50knubieIf I’m using shadow.loader do I still need to use cljs.loader/set-loaded! in my modules?#2021-05-2214:11thheller@steedman87 no.#2021-05-2214:12knubie@thheller Should I be using (loaded? "module-name") to avoid loading modules more than once?#2021-05-2214:14thhellerdepends on what you are doing. I'd suggest using shadow.lazy for everything. much simpler interface. either directly or with a wrapper as described here https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2021-05-2214:15knubieOh, i wasn’t aware of shadow.lazy, I’ll take a look at the article. Thanks for the pointer.#2021-05-2214:19knubieIs shadow.lazy documented somewhere? I don’t see it mentioned on the Users Guide#2021-05-2214:23thhellerhttps://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2021-05-2214:39tlonisthi, I’m having a little trouble using shadow-cljs with cursive in intellij. It looks like this. Somehow all the macros innate in clojure is colored gray and doesn’t support autocomplete. Has anybody experienced something similar to this?#2021-05-2214:40tlonistI made a reagent project with lein new reagent-frontend myproject.#2021-05-2214:41tlonistand have been following this instruction. https://ghufran.posthaven.com/setting-up-a-reagent-clojurescript-project-with-shadow-cljs-and-cursive#2021-05-2214:42thhellerdid you create the pom.xml and use that to create the project?#2021-05-2214:43thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2021-05-2214:43tlonistactually, I did lein new reagent-frontend first, then created pom.xml afterwards#2021-05-2214:44tlonistshould the order matter?#2021-05-2214:55thhellerI don't know what lein new reagent-frontend generates#2021-05-2214:56thhellerthe order doesn't matter, as long as the relevant files are correct#2021-05-2214:56thhellercursive not recognizing stuff is a sign that dependencies aren't properly configured#2021-05-2214:57thhellerso either you didn't use shadow-cljs pom to generate it or created the project via project.clj (from lein) but didn't configure the shadow-cljs dependency there#2021-05-2214:58tlonistthanks, anyhow it works now. I erased the whole project, and started out with shadow-cljs init and shadow-cljs pom, then copy&pasted everything back from the reagent template.#2021-05-2220:27grounded_sageLong shot. But any idea how one would do this manual loading of the monaco-editor into a chrome extension? https://github.com/suren-atoyan/monaco-loader#config#2021-05-2220:37Dan MaltbieJust read the "Paths, Paths, Paths" article on the "From the Shadows" blog. Really useful!! Question: is :dev-http {3000 "public"} the same as :builds {:app {:devtools {:http-root "public" :http-port 3000}}} ?#2021-05-2220:37thheller@grounded_sage I'd guess you set the paths and you are good to go?#2021-05-2220:52grounded_sageyea it looks straight forward but I think I'm missing something with the paths#2021-05-2220:54grounded_sageto be honest I think the editor folder is not being loaded into the extension and I'm not sure why#2021-05-2220:55thhellerdid you copy it properly? shadow-cljs won't copy dynamically loaded stuff like that#2021-05-2220:55grounded_sageOnly seeing js files that I have called out to in the html. But the rest isn't there :thinking_face:#2021-05-2220:56grounded_sageI got this script in my package.json cp -R node_modules/monaco-editor/** shells/chrome/lib/monaco-editor 😅#2021-05-2220:57thhellersorry can't help you much. the devtools should give you errors and stuff if it fails to load things#2021-05-2220:57thhelleror maybe the monaco loader does#2021-05-2221:01grounded_sageYea I'll keep scratching around and see if I can get it working. Tried :web_accessible_resources ["lib/*"] but that doesn't seem to do anything for me#2021-05-2220:38thheller@dmaltbie yes, the second desugars into the :dev-http. the http stuff in :devtools has been deprecated for a couple years now, not going to remove it but it is the old style#2021-05-2220:39Dan MaltbieYes, I have both in my .edn file. I'll remove the devtools stuff. Works fine with both, though.#2021-05-2308:01WestAlright guys, so here’s an issue I was having. I can write this JS and have it run in node no problem.
import unified from 'unified';
import parse from 'uniorg-parse';
import uniorg2rehype from 'uniorg-rehype';
import extractKeywords from 'uniorg-extract-keywords';
import html from 'rehype-stringify';
import { toVFile } from 'to-vfile';

unified()
    .use(parse)
    .use(extractKeywords)
    .use(uniorg2rehype)
    .use(html)
    .process(toVFile.readSync('src/posts/example.org'), function(err, file) {
        console.log(file);
    })
Now I’m trying to use the same libraries in clojurescript, and it doesn’t work at all.
(ns app.parser
  (:require ["unified" :as unified]
            ["uniorg-parse" :as parse]
            ["uniorg-extract-keywords" :as extract-keywords]
            ["uniorg-rehype" :as uniorg2rehype]
            ["rehype-stringify" :as html]
            ["fs" :as fs]
            ["to-vfile" :refer (toVFile)]
            [cljs-node-io.core :as io]))

(->
  (unified)
  (.use parse)
  (.use extract-keywords)
  (.use uniorg2rehype)
  (.use html)
  (.process (.readSync toVFile "src/posts/example.org")
            (fn [err file]
              (js/console.log file))))
When I run it I get errors like this:
app.parser => (->
(unified)
(.use parse)
(.use extract-keywords)
(.use uniorg2rehype)
(.use html)
(.process (.readSync toVFile "src/posts/example.org")
(fn [err file]
  (js/console.log file))))

Execution error (TypeError) at (<cljs repl>:1).
Cannot read property 'readSync' of undefined
:repl/exception!

app.parser => (->
(unified)
(.use parse)
(.use extract-keywords)
(.use uniorg2rehype)
(.use html)
(.process (toVFile "src/posts/example.org")
(fn [err file]
  (js/console.log file))))

Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$to_vfile.toVFile is not a function
:repl/exception!
Mind you, I looked at the source of to-vfile. It does in fact export the function toVFile. What could be going on here?
#2021-05-2308:04thhellerdon't know. what setup is this?#2021-05-2308:04thhellernode-script build? node-repl?#2021-05-2308:06WestI’m using node-repl with cider.#2021-05-2308:06thhellerand what do you get for (require '["to-vfile" :as x]) and x?
#2021-05-2308:07WestLet me check#2021-05-2308:07thhellerand (.. x (-toVFile) (readSync "src/posts/example.org"))#2021-05-2308:09West
app.parser> (require '["to-vfile" :as x])
nil
app.parser> x
#js {}
#2021-05-2308:09West
app.parser> (.. x (-toVFile) (readSync "src/posts/example.org"))

Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$to_vfile._toVFile is not a function
:repl/exception!
#2021-05-2308:09thhellerand what do you get for (js/require "to-vfile")?#2021-05-2308:10West
app.parser> (js/require "to-vfile")

Execution error (Error) at (<cljs repl>:1).
Must use import to load ES Module: /Users/main/Code/web/mysite/node_modules/to-vfile/index.js
require() of ES modules is not supported.
require() of /Users/main/Code/web/mysite/node_modules/to-vfile/index.js from /Users/main/Code/web/mysite/[stdin] is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/main/Code/web/mysite/node_modules/to-vfile/package.json.

:repl/exception!
#2021-05-2308:11WestIt’s so odd, because toVFile is so clearly a function.#2021-05-2308:11thhellerwell the error you just posted is probably your issue#2021-05-2308:12WestDoes this mean I need to fix the package myself?#2021-05-2308:12thhellerthe package probably is not your problem#2021-05-2308:12thhellerdo you have type: module in YOUR package.json?#2021-05-2308:12WestNo I don’t.#2021-05-2308:13thhellerhmm I'm unsure what the current state of things is in node#2021-05-2308:13thhellershadow-cljs uses require to load npm stuff, can't remember if there was something you are supposed to set to enable that#2021-05-2308:15West> Install > This package is https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c: Node 12+ is needed to use it and it must be imported instead of required. From the https://github.com/vfile/to-vfile page for to-vfile.#2021-05-2308:15thheller(also likely depends on which node version you use since this stuff changed a lot)#2021-05-2308:17WestI guess this is a problem. If it cannot be brought in using require then I need to either do a workaround or help fix shadow to add support for this.#2021-05-2308:17thhelleryeah it is a topic I have been putting off .. basically just waiting for the node world to sort this stuff out#2021-05-2308:17thhellerthey have been going back and forth for years on how to do this, guess they finally settled#2021-05-2308:19thhellernot sure if there is an easy fix, need to read up on how node actually handles this now#2021-05-2308:20WestI see. How would you recommend a novice start to chip away at understanding a large codebase? I’d like to see this implemented, so it would be well worth my time to attempt to fix it.#2021-05-2308:23thhellerwell it'll be something along :target :esm https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-05-2308:23thhellersince this really only works when everything is ESM, including the code shadow-cljs generates#2021-05-2308:23thhellerit might even work today, just may require some additional options#2021-05-2308:25thheller:target :esm currently defaults to trying to bundle all dependencies, but there is :js-options {:keep-as-import #{"fs" "to-vfile" ...}} for stuff it shouldn't bundle#2021-05-2308:25thhelleralthough bundling may actually be fine too, not sure what kind of code this is#2021-05-2308:27thhellerthis will really involve a lot of rewriting in the node interop code, maybe even a new seperate implementation so we don't lose the old commonjs stuff#2021-05-2308:30thhellerwonder why you don't get the same ESM error for (require '["to-vfile" :as x]), that just does a js/require under the hood#2021-05-2308:41WestI imagine error handling can be pretty messy.#2021-05-2318:07Jakub Holý (HolyJak)Hello! How to troubleshoot
207 |     (def ui-player (comp/factory Player {:keyfn :player/id}))
-----------^--------------------------------------------------------------------
 ui-player at line 207 is being replaced
? What is it being replaced by, where? (I have couple more def ui-player in this file but all precede this one and all are inside (comment ...) 🙏 Thank you!!!
#2021-05-2318:19nenadalmSometimes when I have weird errors, stopping everything and removing compiler cache (https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache) helps. Other times I am just removing or commenting out code piece by piece until it starts working.#2021-05-2319:24Jakub Holý (HolyJak)Thanks! Restarting helped.#2021-05-2319:41WestWhat’s the best way to include a node script in a shadow project? Where might I put it in my project? I thought of using a lib folder just for parser.js. All I want really is to call the functions in the script from cljs, that way I can also debug the script somewhat interactively.
.
├── LICENSE
├── README.md
├── deps.edn
├── package.json
├── postcss.config.js
├── shadow-cljs.edn
├── src
│   ├── app
│   │   ├── components.cljs
│   │   ├── core.cljs
│   │   ├── data.cljs
│   │   ├── index.clj
│   │   └── parser.js
│   ├── config
│   │   └── site-data.edn
│   ├── css
│   │   ├── 404.css
│   │   ├── main.css
│   │   └── tailwind.css
│   ├── lib
│   └── posts
│       ├── 
│       ├── 
│       ├── 
│       ├── blog-posts.edn
│       └── 
├── tailwind.config.js
├── yarn-error.log
└── yarn.lock
#2021-05-2319:56thheller@c.westrom see https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-05-2411:54roman01laDoes shadow infer externs for JS libraries required from a file system? Seems like methods got renamed, but there’s no warnings about failed externs inference#2021-05-2411:58thhellerthere is no inference for JS files, since that is only part of the CLJS compiler which they don't go through#2021-05-2411:59roman01lamakes sense, is there anything shadow/closure can do to warn about renamed symbols in JS files?#2021-05-2412:04thhellershadow-cljs check the-build but that is very noisy#2021-05-2415:25hoppyhello. Does the possibility exist to create a working setup whereby node would be running on something like say a raspi-zero that can run node, connected to a regular development system that can reasonably run JVM/Shadow/node, and be able to create a repl experience, or is that folly?#2021-05-2415:32thhellerthat is trivial if you use something like sshfs or so. something that makes the files from your PC available over on the pi#2021-05-2415:33thhellermanual copy works too though#2021-05-2415:34thhellerlets say :node-script you have :output-to "out/script.js" and :output-dir "out". you somehow make the out directory available on the pi and run it there via node script.js or so#2021-05-2415:34thhellerthen the only extra option you'll need is :devtools {:devtools-url ""} in your build config#2021-05-2415:34thhellerthats it#2021-05-2415:35hoppyok, let me see how far I get with that.#2021-05-2416:32hoppyseems like this is pretty close to working. Had to stuff a 'ws' on the target device. So I'm running 'watch app' on the dev box, and running app with node on the target. It clearly gets a code reload whenever the watch decides to recompile.#2021-05-2416:33hoppyI'm connected via calva, I guess to the watch on the dev box.#2021-05-2416:33hoppyall of the 'evals' seem to be happening on the dev box though - is this expected?#2021-05-2416:33hoppygets rather opaque who I'm talking to...#2021-05-2416:36thhellereval happens whereever the process runs, so your pi#2021-05-2416:37thhellercalva just talks to your dev box and the shadow-cljs process handles the messaging between the processes#2021-05-2416:38thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting maybe that helps a little#2021-05-2416:38hoppyI tried to validate that with a fs.writeFileSync, and I don't seem to see that behavior#2021-05-2416:38thhellerhow did you start the REPL though? if you juse use node-repl that will run on the dev box#2021-05-2416:38thhellerneed to select the REPL for the build you created#2021-05-2416:39hoppy(I'm writing off in the non-shared filesystem)#2021-05-2416:39hoppyhmm#2021-05-2416:40hoppyyes that seems the be the issue - much better#2021-05-2416:41hoppythat is really nice - thank you!#2021-05-2416:56hoppyabout the only thing I would note is that on the target, there is an implied js dependency on 'ws', which isn't there. Actually I lied, it isn't an rpi, it's a custom board which doesn't have npm, but does have node.#2021-05-2416:57thhellerbest way to handle this is having a package.json in your out directory#2021-05-2416:57thhellerand having dependencies installed there#2021-05-2417:53hoppyat least until you have a native module. But anyway, thanks for the pointers, this works fantastic.#2021-05-2612:40maxt@thheller First, I find shadow-cljs to be an amazing piece of software, thank you! I like to turn autobuild off, but then I would like it to recompile if I reload the browser. Is there a simple way to achive that?#2021-05-2612:54maxtI imagine some kind of before-load function on the java side that can call compile!#2021-05-2613:24thheller@maxt you can toggle the autobuild from a CLJ REPL via (shadow/watch-set-autobuild! :the-build false) and then trigger a compile via (shadow/watch-compile! :the-build).#2021-05-2613:24thhellera compile trigger when you reload the browser does not exist#2021-05-2613:33Christopher StoneHello @thheller, I've just created a pull request to add a shim file to the shadow-cljsjs library, whould you be so kind as to review the changes and accept. This is my first shim file created and any pointers would be appriciated, Thanks#2021-05-2613:35thhellerwhy did you create it? I can't find the keycloak-js package here https://github.com/cljsjs/packages#2021-05-2613:37thhelleralso which library is using the cljsjs.keycloak-js?#2021-05-2613:40Christopher StoneI want to expose the Keycloak global variable after installing keyclaok-js (using yarn add keycloak-js), as our code is not able to access it using js/Keycloak#2021-05-2613:41thhellerwhy do you want to access it via js/Keycloak? if this is just for your code and not a public library then put the shim file onto your classpath. no need for it to be in shadow-cljsjs#2021-05-2613:42thhellerjust (:require ["keycloak-js" :as keycloak-js] in your code and use keycloak-js instead of js/Keycloak?#2021-05-2613:42thhellerno need for this cljsjs indirection if its your code anyways and not some official cljsjs package you are trying to replace#2021-05-2613:43Christopher StoneOK thanks for the prompt reply, I will let you know if there are any further issues 🙂#2021-05-2616:00lispers-anonymousI use keycloak with shadow-cljs regularly. Pulling it in through NPM and using it with (:require ["keycloak-js" :as keycloak-js]) works great for me. If you have any specific questions about it I'd be glad to answer them.#2021-05-2613:56maxt@thheller to create a compile-on-reload trigger, could I write a cljs :before-load function that somehow signals the shadow server to recompile?#2021-05-2613:57thhellerno, before-load is triggered after a compile completes. not when the browser reloads.#2021-05-2613:58thhellerif you have a custom server, that could trigger the recompile when the request comes in#2021-05-2613:58maxtok, make sense.#2021-05-2613:58maxtah, right.#2021-05-2613:58maxtYes that would solve it, thanks!#2021-05-2702:56valeraukoa node-script generated output needs a node_modules folder too?#2021-05-2702:57valeraukoi have some dependencies in package.json and after shadow-cljs release the generated file errors saying the dependencies are missing#2021-05-2702:59valerauko(dependencies are missing = Error: Cannot find module)#2021-05-2703:28caleb.macdonaldblackIn Cursive, I connect to the remote repl for shadow-cljs. Then I have to type (shadow/repl :app). Can I set this up to run that command by default when I connect to the remote repl?#2021-05-2707:11thheller@vale yes, node-script does not bundle dependencies by default. you can post-process the file with something like https://github.com/vercel/ncc to make it standalone. or just include the node_modules whereever you are publishing (recommended)#2021-05-2711:16valeraukoi went with ncc because i couldn't figure out how to make my node_modules "minimal"#2021-05-2707:11thheller@caleb.macdonaldblack I don't think so. problem is that cursive needs to create the second nrepl session for CLJS, can't start out the REPL that way.#2021-05-2707:12caleb.macdonaldblackAh ok. No worries. #2021-05-2709:25simongrayI can’t seem to get shadow-cljs 2.14.0 working in my deps.edn setup. I do have the required dependencies at the correct versions (Clojure, ClojureScript, closure-compiler-unshaded), but somehow I end up getting this error every time I try to run shadow-cljs watch app :
11:22 $ shadow-cljs watch app
------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See 

------------------------------------------------------------------------------
shadow-cljs - config: /Users/rqf595/Code/louis-hjelmslev/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------

This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.

You are using shadow-cljs version: 2.14.0

The important dependencies are:

  org.clojure/clojure "1.10.3"
  org.clojure/clojurescript "1.10.866"
  com.google.javascript/closure-compiler-unshaded "v20210505"

Please verify that you are loading these versions.
You can find all required dependencies here:

  

Please refer to the Guide for more information:

  

-----------------------------------------------------

The error encountered was:

Syntax error macroexpanding at (closure.clj:78:5).
        at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1742)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705)
        at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
        at clojure.lang.Compiler.eval(Compiler.java:7186)
        at clojure.lang.Compiler.load(Compiler.java:7640)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6856.invoke(core.clj:6115)
        at clojure.core$load.invokeStatic(core.clj:6114)
        at clojure.core$load.doInvoke(core.clj:6098)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5897)
        at clojure.core$load_one.invoke(core.clj:5892)
        at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
        at clojure.core$load_lib.invokeStatic(core.clj:5936)
        at clojure.core$load_lib.doInvoke(core.clj:5917)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$load_libs.invokeStatic(core.clj:5974)
        at clojure.core$load_libs.doInvoke(core.clj:5958)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$require.invokeStatic(core.clj:5996)
        at clojure.core$require.doInvoke(core.clj:5996)
        at clojure.lang.RestFn.invoke(RestFn.java:551)
        at shadow.build.js_support$eval11454$loading__6737__auto____11455.invoke(js_support.clj:1)
        at shadow.build.js_support$eval11454.invokeStatic(js_support.clj:1)
        at shadow.build.js_support$eval11454.invoke(js_support.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7181)
        at clojure.lang.Compiler.eval(Compiler.java:7170)
...
...
...
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
        at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:257)
...
...
...
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
        at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1735)
        ... 211 more
#2021-05-2709:26thheller@simongray thats a dependency conflict on guava#2021-05-2709:28simongrayI see. How do you know that, though?#2021-05-2709:28thhellercom.google.common.collect.* is a guava package#2021-05-2709:29simongrayaha#2021-05-2709:31simongrayThank you. Hm, still kinda puzzled why this is now seemingly an issue.#2021-05-2709:31thhellerdo you have your server-side CLJ stuff in the default deps.edn :deps? might make sense to move them to a :server alias or so#2021-05-2709:32simongrayyes#2021-05-2709:32thhellerso that they aren't loaded when running CLJS, kinda helps avoiding such conflicts#2021-05-2709:32simongrayMakes sense!#2021-05-2709:32thheller(also why I typically recommend keeping your CLJ and CLJS setups apart)#2021-05-2709:33thhellerbut keeping it all in deps.edn with aliases is totally fine#2021-05-2709:33simongrayI guess I’ll make a split into a :backend and :frontend aliases and then keep CLJC libs in the root#2021-05-2709:34simongrayYeah, I like the utility of a single file#2021-05-2709:50simongrayOk, so moving the deps into aliases worked! 😄#2021-05-2709:50simongrayThank you, once again#2021-05-2711:37simongrayBTW @thheller the link in this message
WARNING: shadow-cljs not installed in project.
   See 
doesn’t seem to lead anywhere (the #project-install part specifically).
#2021-05-2711:37simongrayJust FYI#2021-05-2711:40thhelleroh right. I guess I forgot to write that section 😉#2021-05-2711:46simongrayHaha#2021-05-2711:47simongrayIt seems to work fine anyway, so why the warning?#2021-05-2711:50thhellerinstalling npm shadow-cljs ensures that some runtime dependencies are also installed. ie. ws for node builds or node-libs-browser for browser polyfills. can work without but may fail.#2021-05-2711:59simongrayI see.#2021-05-2712:02thhelleroh and of course it also ensures that you are not dependent on some global shadow-cljs install, which may drift in versions and so on.#2021-05-2712:19leonoelIn a macro, I need to check if a symbol resolves to an undefined var. Calling (cljs.analyzer/resolve-var env sym nil false) triggers an error : > Wrong number of args (2) passed to: shadow.build.cljs-hacks/shadow-resolve-var Is this a known bug, is there a workaround or a better way ?#2021-05-2713:01thheller@leonoel just call it with 2 args?#2021-05-2713:03leonoelarity 2 works but then how to reliably check that the var is undefined ?#2021-05-2713:06thhellerhmm I must have missed the change where the extra arity was introduced. that only used to have 2 or 3#2021-05-2713:15leonoelshould I open an issue ?#2021-05-2713:18thhelleralready fixed in master#2021-05-2713:19thhellerjust trying to find a place where the 4th arity is actually used anywhere 😛#2021-05-2713:20thhellerah, its only used once internally. I guess you are the first trying to use it in what way 😛#2021-05-2713:23leonoelawesome, thanks !#2021-05-2713:26thhellerjust released 2.14.1 with that fix#2021-05-2715:05Volodymyr HuzarHello! is there a way to support modules when :target :karma is used? Now I am getting “Uncaught Error: shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.”#2021-05-2715:08thhellernot sure karma allows that#2021-05-2715:13Volodymyr HuzarFrom what I saw we need to append shadow.loader.init(""); somehow to the output, but have no idea how to do that properly#2021-05-2715:14thhellerthat is true in theory but not enough#2021-05-2715:14thhellersince no modules are configured it'll then just fail wherever you are calling load#2021-05-2715:15thhellerhow do you use the loader? typically that code should not be part of tests?#2021-05-2715:15thhellerI mean the code should just be loaded directly in the test?#2021-05-2715:18Volodymyr Huzaranother component is loaded in component I’m testing, so I’m not calling it directly but it is called on certain test scenarios#2021-05-2715:19Volodymyr Huzaractually I have tried it with :browser-test and only adding `
:module-loader true
was enough, without specifying modules. Also I’m requiring the namespace which should be loaded in tests directly, so maybe it is a reason why they are not failing
#2021-05-2715:23thhellersomething must be calling something from shadow.loader. otherwise you wouldn't get that error.#2021-05-2715:27thhellerin :browser-test you can set :module-loader since it is built on the :browser target. :karma is not so that won't work there#2021-05-2715:27thhellerbut :browser-test still won't be able to actually use the shadow.loader api in any way#2021-05-2717:55Volodymyr Huzar@thheller shadow.lazy/loadable is used in the function I’m testing that’s why error happens inside :karma while working fine inside :browser-test I’ll open an issue in GitHub and will try to find some workaround in meanwhile. I think it would be nice to have some recipe to run tests when shadow.lazy is used inside#2021-05-2717:57thhellerif you provide a repro I can give you tips. without knowing what you are doing I really can't give other tips.#2021-05-2717:59Volodymyr Huzarsure, I’ll try to prepare some demo tomorrow#2021-05-2809:53Volodymyr Huzar@thheller I haven’t prepared an example yet, but it seems I have found workaround for my issue by adding js file with next content
(function () {
  goog.global.shadow$modules = {infos: {test: null}, uris: {test: []}}
  shadow.loader.init("");
})();
to karma.conf.js -> files
#2021-05-2809:55thhellerstill don't know why you need that but looks fine#2021-05-2810:58Volodymyr Huzar@thheller https://github.com/Valdermeyder/karma-modules-support/tree/master I have created a small but enough to reproduce example#2021-05-2811:03thhellerwell yeah but that is missing the entire context? I mean why do you call the loadable in the test in the first place? is that rendering actual UI code or what are you doing?#2021-05-2811:14Volodymyr HuzarI am not calling it in the first place. It is called by the function which is tested. I understand you concern that in this example it looks like a first call but in my real case it is one of the things which happen. In general the context is when user have certain permissions call this method from another module. It was split by modules to load this additional code only for users which have this certain permission. I’ll not argue that it is the best solution which can be implemented but it is already done and I’m not in charge to change it right now.#2021-05-2811:15Volodymyr HuzarAnyway I think the problem of running karma tests when modules and lazy load are used is not related to the context. As you can see it fails even in very simple example.#2021-05-2811:27thheller
(ns my.app-spec
  (:require
    [cljs.test :as ct :refer [deftest is]]
    [shadow.loader :as sl]
    [ :as app]
    [my.core]))

(ct/use-fixtures :once
  (fn [test]
    (sl/init "")
    (test)))
may also work
#2021-05-2811:30thhellerI'm really unsure how to treat loader related things in tests. since it can't actually load a module the test using it becomes kind of pointless#2021-05-2811:39Volodymyr HuzarThe example above will work only once, the next test suite will fail at least from what I saw in the code.#2021-05-2811:41Volodymyr Huzaryeah, it is probably hard to achieve fully but when your require lazy loadable namespace in the test (e.g. my.core), lazy loader works fine, so I think here is only a matter of not failing :karma target when modules are used#2021-05-2811:44Volodymyr HuzarI am not big fun of mocks but probably with-redefs can be used somehow to stub parts of the lazy loaded namespaces in case we don’t want to require them explicitly#2021-05-2812:24Volodymyr Huzar@thheller are you okay to open issue in GitHub for that case?#2021-05-2813:19thhellersure#2021-05-2815:11Volodymyr Huzarhttps://github.com/thheller/shadow-cljs/issues/889#2021-05-2715:49wcalderipehey 👋 does this error ring a bell on someone?
❯ node_modules/.bin/shadow-cljs watch webapp
shadow-cljs - config: /Users/wcalderipe/dev/foo-project/shadow-cljs.edn
shadow-cljs - updating dependencies
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (sharedRuntime.cpp:531), pid=17169, tid=5635
#  Error: ShouldNotReachHere()
#
# JRE version: OpenJDK Runtime Environment (16.0+14) (build 16+14)
# Java VM: OpenJDK 64-Bit Server VM (16+14, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/wcalderipe/dev/foo-project/hs_err_pid17169.log
#
# If you would like to submit a bug report, please visit:
#   
#
===== ERROR =================
ENOENT: no such file or directory, open '/Users/wcalderipe/dev/foo-project/.shadow-cljs/classpath.edn'
=============================
os macOS 11.4 (20F71) shadow-cljs: 2.11.11 java
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment (build 16+14)
OpenJDK 64-Bit Server VM (build 16+14, mixed mode)
#2021-05-2715:51thhellerodd. no clue.#2021-05-2715:56thhellerdo you also get that error with lein or deps.edn? it happens during dependency downloading? so even before shadow-cljs even starts?#2021-05-2715:59wcalderipeyeah, I also get that just by running clj on the terminal. definitely not related to shadow-cljs#2021-05-2715:59wcalderipethanks!#2021-05-2716:24SchpaaWhat is the correct way of including firebase into a cljs project?#2021-05-2716:25thhellernpm install it and require it in your ns#2021-05-2716:25SchpaaAnd how would the require look like? (:require [“firebase”]) ?#2021-05-2716:26thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#js-deps#2021-05-2716:26SchpaaI am really confused about the js/ prefix and why using it#2021-05-2716:26thhelleryou don't use js/ for this#2021-05-2716:27thhellerjs/ is for accessing global variables#2021-05-2716:27thhellermaybe this helps https://github.com/jacekschae/shadow-firebase#2021-05-2716:27Schpaamy project cannot see the firebase imported, like your examples, and I don’t know how to fix this#2021-05-2716:28Schpaa@thheller Yes, I think I follow it#2021-05-2716:28thhellerdon't know how you imported it or how you accessed it, so can't say#2021-05-2716:28Schpaaits in a package.json#2021-05-2716:29Schpaathats the only place where it is ref.#2021-05-2716:29thhellerthat doesn't do anything without requiring it in your code#2021-05-2716:29Schpaa
(:require [cljs-bean.core :refer [->clj ->js bean]]
            ;["firebase/app"]
            ;["firebase"]
            ;["firebase" :as firebase]
            ;["@firebase/app" :refer (firebase)]
#2021-05-2716:30Schpaasome of my attempts#2021-05-2716:30thhellerhttps://github.com/jacekschae/shadow-firebase/blob/master/src/app/fb/init.cljs#2021-05-2716:31SchpaaI’ll try#2021-05-2716:32thhellerusually helps if you have JS examples, those translate 1:1 regarding the requires#2021-05-2716:37SchpaaI think there is something else, not the requires#2021-05-2716:37Schpaasomething with my config#2021-05-2716:38Schpaabut I have no grasp of it because there are so many loose ends right now#2021-05-2716:38thhellerthis requires no extra config at all#2021-05-2716:39Schpaaunless I’ve done something stupid in my shadow-cljs.edn#2021-05-2716:39thhellerhard to say without seeing it or the code 😉#2021-05-2716:39Schpaa
{:deps       {:aliases [:dev]}
 :dev-http   {8000 "classpath:public"}
 :nrepl      {:port       7002
              :middleware []}

 :builds     {:test     {:target    :browser-test
                         :test-dir  "resources/public/js/test"
                         :ns-regexp "event2-test$"
                         ;:runner-ns tests.client-test-main
                         :devtools  {:http-port          8021
                                     :http-root          "resources/public/js/test"}}

              :app { :git-inject {:version-pattern "^v/(.*)$"
                                  :ignore-dirty?   true}
                    :target            :browser
                    :build-hooks       [(shadow-git-inject.core/hook)]
                    :compiler-options  {:closure-defines {app.system.config/version :shadow-git-inject/version}}
                    :output-dir        "resources/app/js"
                    :asset-path        "/js"
                    :module-hash-names 4
                    :modules           {:main {:init-fn app.core/init!}}
                    :dev               {:dependencies     [#_[day8.re-frame/tracing-stubs "0.5.1"]]
                                        :compiler-options {#_#_:output-feature-set :es6
                                                           :closure-defines {app.system.config/version :shadow-git-inject/version
                                                                             app.system.config/build-time :shadow-git-inject/build-iso-date-time
                                                                             "re_frame.trace.trace_enabled_QMARK_" true}}}

                    :release           {:output-dir       "resources/dist/js"

                                        :compiler-options {#_#_:output-feature-set :es6
                                                           :closure-defines {app.system.config/version :shadow-git-inject/version
                                                                             app.system.config/build-time :shadow-git-inject/build-iso-date-time}
                                                           :optimizations   :simple
                                                           :infer-externs   :auto}}

                    :devtools          {;:preloads   [day8.re-frame-10x.preload]
                                        :after-load app.core/reload!
                                        :http-port  8050
                                        :http-root  "resources/app"
                                        :watch-dir  "resources/app"}}}}
#2021-05-2716:40SchpaaI use the :app branch#2021-05-2716:40SchpaaDo I do anything crazy here?#2021-05-2716:41thhellersome unnecessary config but looks ok#2021-05-2716:41Schpaa
{:paths   ["src/cljs"]
 :deps    {org.clojure/clojure         {:mvn/version "1.10.3"}
           org.clojure/clojurescript {:mvn/version "1.10.866"}
           org.clojure/core.async      {:mvn/version "1.3.610"}
           thheller/shadow-cljs        {:mvn/version "2.14.1"}
           com.taoensso/timbre         {:mvn/version "5.1.0"}
           #_#_com.schpaa/schpaa           {:mvn/version "0.2.0-SNAPSHOT"}
           expound                     {:mvn/version "0.8.9"}
           reagent                     {:mvn/version "1.0.0"}
           re-frame                    {:mvn/version "1.1.2"}
           kee-frame                   {:mvn/version "1.1.2"}
           cljs-bean                   {:mvn/version "1.6.0"}
           fork                        {:mvn/version "2.4.0"}
           vlad                        {:mvn/version "3.3.2"}
           com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
           thedavidmeister/cljs-i18n   {:mvn/version "0.4.0"}
           arco                        {:mvn/version "0.3.4"}
           fipp                        {:mvn/version "0.6.23"}
           mvxcvi/puget                {:mvn/version "1.3.1"}
           markdown-to-hiccup          {:mvn/version "0.6.2"}
           markdown-clj                {:mvn/version "1.10.5"}
           medley                      {:mvn/version "1.3.0"}
           nrepl                       {:mvn/version "0.8.3"}
           day8/shadow-git-inject      {:mvn/version "0.0.4"}

           ;for codemirror
           #_#_applied-science/js-interop {:mvn/version "0.2.5"}}


 :aliases {:carve
           {:extra-deps {borkdude/carve {:git/url ""
                                         :sha     "$LATEST_CARVE_SHA"}}
            :main-opts  ["-m" "carve.main"]}

           :dev
           {:extra-paths ["src/dev"]
            :extra-deps  {;nubank/workspaces      {:mvn/version "1.0.15"}
                          ;day8.re-frame/re-frame-10x {:mvn/version "1.0.2"}
                          ;org.clojure/clojurescript  {:mvn/version "1.10.773"}

                          binaryage/devtools         {:mvn/version "1.0.2"}}}}}
#2021-05-2716:41SchpaaI’ve eliminated all codemirror related stuff#2021-05-2716:42Schpaa
{
  "dependencies": {
    "create-react-class": "^15.7.0",
    "firebase": "^8.6.2",
    "firebase-auth": "^0.1.2",
    "highlight.js": "10.7.1",
    "image-conversion": "^2.1.1",
    "marked": "^0.7.0",
    "process": "^0.11.10",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-firebaseui": "^5.0.2",
    "react-highlight.js": "1.0.7",
    "react-virtualized": "^9.22.2"
  },
  "devDependencies": {
    "highlight.js": "9.18.1",
    "react-highlight.js": "1.0.7"
  }
}
#2021-05-2716:42thhellerall looks fine, except the missing npm install shadow-cljs maybe#2021-05-2716:42Schpaahmm#2021-05-2716:43Schpaawhere would that go?#2021-05-2716:43Schpaaif there is something special#2021-05-2716:43SchpaaI just invoke it from the cli#2021-05-2716:44thhellerin the project, you just npm install shadow-cljs. so you don't rely on some global install#2021-05-2716:44Schpaaoh ok#2021-05-2716:44Schpaayes#2021-05-2716:44thhellerbut that likely has nothing to do with whatever your issue is#2021-05-2716:44thhellerjust recommended and "safer" 😉#2021-05-2716:46SchpaaThere is also the error in the console I cannot really fathom#2021-05-2716:46Schpaa
main.js:1552 TypeError: module$node_modules$firebase$app$dist$index_esm.initializeApp is not a function
    at $system$database$core$init_BANG_ [as init_BANG_] (core.cljs:71)
    at $core$init_BANG_ [as init_BANG_] (core.cljs:33)
    at eval (shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:486)
    at Object.env.evalLoad (main.js:1549)
    at main.js:2040
#2021-05-2716:47thhellerdepending on which firebase version you use it might require a different import. they seem to change it every other version#2021-05-2716:47Schpaaerroring while init’ing the fb connection#2021-05-2716:47Schpaado they?#2021-05-2716:47thhellerso instead of ["firebase/app" :as firebase] try ["firebase/app$default" :as firebase]#2021-05-2716:47Schpaainteresting#2021-05-2716:48thhelleragain .. help if you have JS examples#2021-05-2716:48Schpaathere are no js I’ve made#2021-05-2716:48thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages there is a translation table#2021-05-2716:48thhellerbut I assume you are looking at JS docs for this stuff which have examples#2021-05-2716:49Schpaathe js stuff is rel. easy, just have to establish a stable firebase-var access#2021-05-2716:50Schpaawhich is really tripping me up here#2021-05-2716:50SchpaaI am also using a react-firebaseui comp#2021-05-2716:50thhellerso look at ONE JS example that explains this stuff and then translate it using the table I linked#2021-05-2716:51thhellerthere is really no point in guessing here. this stuff should be documented somewhere in the docs#2021-05-2716:52thhellerfor example https://www.npmjs.com/package/react-firebaseui#2021-05-2716:52thheller
import firebase from 'firebase';
#2021-05-2716:52thhellerthat would be ["firebase" :default firebase] OR the new official variant ["firebase$default" :as firebase]#2021-05-2716:54thhellerbut yeah for firebase it is extremely important to check the versions you use, they change a lot of stuff constantly#2021-05-2716:55thhellerso stuff that used to work for older versions may be incorrect today#2021-05-2716:58Schpaathank you#2021-05-2717:50Schpaano dice at all#2021-05-2717:50SchpaaMaximum call stack size exceeded when trying to peek at firebase#2021-05-2717:51thhellerno idea what you mean by that#2021-05-2717:52Schpaa
env.evalLoad @ main.js:1551
(anonymous) @ main.js:1930
main.js:1552 RangeError: Maximum call stack size exceeded
    at Object.eval [as cljs$core$ILookup$_lookup$arity$2] (core.cljs:6851)
    at Function.eval [as cljs$core$IFn$_invoke$arity$2] (core.cljs:1959)
    at Object.cljs$core$print_meta_QMARK_ [as print_meta_QMARK_] (core.cljs:10236)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10246)
    at cljs$core$pr_writer (core.cljs:10339)
    at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (core.cljs:10191)
    at Object.eval [as cljs$core$IPrintWithWriter$_pr_writer$arity$3] (core.cljs:692)
    at Object.cljs$core$_pr_writer [as _pr_writer] (core.cljs:778)
    at Object.cljs$core$pr_writer_impl [as pr_writer_impl] (core.cljs:10257)
    at cljs$core$pr_writer (core.cljs:10339)
#2021-05-2717:52Schpaathat meta_QMARK#2021-05-2717:52thhellerok, that means you can't print it. likely because is has self-referential circular references#2021-05-2717:52Schpaaoh#2021-05-2717:53thhellerbut if you don't print it thats not a problem 😛#2021-05-2717:53SchpaaSo i cannot do
(-> firebase .-app)
#2021-05-2717:53Schpaaor (.-app firebase)#2021-05-2717:54thhellersure you can. you just can't print it, so you can't do it in the REPL if thats what you mean#2021-05-2717:54thheller(js/console.log (-> firebase .-app)) should be ok, or tap> and the Inspect UI (probably rather limited, so use console)#2021-05-2717:55Schpaanothing shows up in the console#2021-05-2717:55Schpaaoh yes#2021-05-2717:55Schpaaƒ app(name){name=name||“[DEFAULT]“;if(!(0,_util.contains)(apps, name))throw ERROR_FACTORY.create(“no-app”,{appName:name});return apps[name]}#2021-05-2717:56SchpaaSo it seems I can invoke initializeApp via this firebase thing#2021-05-2717:58thhellersure, the JS examples seem to do that. don't see the anywhere but the initializeApp I believe is the first thing you are supposed to call#2021-05-2717:59Schpaayes#2021-05-2717:59Schpaaand thats passing fine#2021-05-2718:00SchpaaI do an init at
(defn ^:export init! []
#2021-05-2718:00Schpaaand put the result in an atom#2021-05-2718:01Schpaa
(defn init! []
  (log/info "widd/init!")
  (reset! app (if (zero? (count (.-apps firebase)))
                (-> firebase
                    (.initializeApp (->js appinfo-vakt)))
                (.-app firebase)))
  (when goog.DEBUG
    (-> firebase
        .database
        (.useEmulator "localhost" 10008))
    (-> firebase
        .firestore
        (.useEmulator "localhost" 10009))))
#2021-05-2718:01thhellerthat doesn't seem to have a result. or at least the JS stuff never handles it#2021-05-2718:11knubieIs it possible to access closure-defines, or something simlar, in a clojure macro? I have a side effecting macro, and I’d like to somehow disable the side effecting part in certain builds like in CI.#2021-05-2718:14thhellersure, see https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.clj#L8-L12 for an example#2021-05-2718:15thhellerclosure defines are also somewhere in @cljs.env/*compiler*, I think just [:options :closure-defines] but not sure#2021-05-2718:16knubieawesome, thanks!#2021-05-2718:26Schpaahow did you infer that “firebase$default” was needed in the require#2021-05-2718:27Schpaarequire(‘firebase’).default as it is in js#2021-05-2718:27Schpaais this a translation that is only applicable to shadow-cljs?#2021-05-2718:28SchpaaI cannot find anything in the docs related to adding a $default to the name required#2021-05-2718:29SchpaaPerhaps I’m formulating this somewhat obtuse#2021-05-2718:29SchpaaI just dont know where to look and I feel I have no threads to follow#2021-05-2719:15thheller@schpaencoder if you look at the translation table https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages you'll see the use of :default, more here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports. that is a shadow-cljs only thing that was rejected from CLJS, instead it added the $default thing in the recent release. see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces#2021-05-2719:16Schpaaoh, never seen that before#2021-05-2719:16thhellerso the $ really is just sugar for accessing properties directly, ["firebase" :as firebase] and firebase/default is also valid.#2021-05-2719:17thhellerwhich would equate to the require(‘firebase’).default variant, as does "firebase$default"#2021-05-2721:09Filipe Silva@thheller I have a bit of a weird question for you: when I have a shadow-cljs server running for a web app, and the browser has the web app open, if the app is unresponsive I will get a message about shadow-cljs reconnecting. How do you display that message?#2021-05-2721:10Filipe SilvaI ask because I just saw that message pop up while the web app was blocked on a synchronous 30s transit deserialization call, which surprised me because nothing else should be able to run.#2021-05-2722:10mauricio.szaboHi @thheller. I just started an app that I need to use deps.edn. I just tried to add nextjournal.clojure-mode and shadow-cljs on dependencies, configured a simple browser app, but I'm seeing the following error on console:
cljs$core$ExceptionInfo {message: "failed to encode relay msg", data: {…}, cause: null, name: "Error", description: undefined, …}
eval @ shared.cljs:229
eval @ shared.cljs:229
shadow$remote$runtime$api$relay_msg @ api.cljc:4
...
#2021-05-2722:14mauricio.szaboI downgraded to 2.12.7, the error is gone and the browser can connect to the running instance#2021-05-2806:52thheller@mauricio.szabo no clue. it uses transit? maybe a transit version conflict or so?#2021-05-2806:53thheller@filipematossilva yeah that sounds impossible? its just a regular callback when the websocket disconnects? nothing what would defy the rules of single-threaded browser world? 😛 https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/websocket.cljs#L22-L24 https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L268-L270#2021-05-2810:45roman01lais there a way to configure shadow to load scripts via script tag in dev? as it is done in “pure” cljs repl#2021-05-2810:45thheller:devtools {:loader-mode :script} for the initial page load. for the REPL itself no, that always uses eval.#2021-05-2810:46roman01lagot it#2021-05-2811:02David PhamDoes anyone has a good tailwind library in Clojure to recommend? (Usable on both clj and cljs) #2021-05-2811:04thhellerwhat do you need a library for? I just have [:div {:class "px-4 py-2 md:px-6"}] etc?#2021-05-2813:13David PhamOki doki :) make sense, I wondered if anyone had something like styled components to compose them :)#2021-05-2813:40wilkerlucio@neo2551 this is a nice setup example for tailwind and shadow: https://github.com/jacekschae/shadow-cljs-tailwindcss#2021-05-2813:42David PhamThanks :)#2021-05-2815:15defaIs there an easy way for git describe based version information derived at build time to be available as variable at runtime? I was thinking about using :closure-defines and #shadow/env together with a shell script… and was wondering if there is a more straight forward way? I’d like to have a git based version string to show in the app. The environment react-native. Android build.gradle and iOS Info.plist integration would be the icing on the cake but not mandatory 😉#2021-05-2815:29knubie@U5FKQSSS1 You could maybe write a macro for that.#2021-05-2815:30knubiethe macro would run git describe from clojure at build time and you could include that information in the expanded code#2021-05-2817:25thhellerhttps://github.com/day8/shadow-git-inject#2021-05-2815:52kommenis there any difference between shadow-cljs and clojurescript regarding handling externs-inference for stuff required from npm modules?#2021-05-2815:56kommentrying to reproduce an issue we’re experiencing since upgrading to shadow-cljs 2.14.0, where a bunch of new :infer-warnings popped up for code with js interop with npm modules. 2.13.0 can still correctly infer them and compile without those warnings#2021-05-2816:46kommenhaving this in package.json
"prosemirror-transform": "^1.2.8", "prosemirror-state": "1.3.3"
this
(ns foo
  (:require ["prosemirror-state"]))

(defn apply-tr [tr]
  (.getMeta tr nil))
compiles without a warning with 2.13.0, but produces this warning with 2.14.0
2 |   (:require ["prosemirror-state"]))
   3 | 
   4 | (defn apply-tr [tr]
   5 |   (.getMeta tr nil))
---------^----------------------------------------------------------------------
 Cannot infer target type in expression (. tr getMeta nil)
#2021-05-2817:27thheller@kommen 2.14 upgraded to CLJS release .866, not sure if there were any changes in CLJS regarding this. on the shadow-cljs side I didn't change anything regarding this (not intentionally at least)#2021-05-2817:28thhellerah no I did have to make one change. the code that gathers potential extern names from JS code had to remove one branch since the closure compiler folks changed something and removed an API I was using#2021-05-2817:28thhellerthat may affect that I guess. couldn't find any problem in my code but that doesn't do a whole lot of JS interop#2021-05-2817:34kommenok, thanks for investigating! for our codebase this results in over 200 new warnings and breakage of the advanced build around them.#2021-05-2817:34thhellerwow, did not expect that#2021-05-2817:35thhellerlet me see if I can revert that change or find the "replacement" API in gcc#2021-05-2817:38thhellertechnically it is closer to regular CLJS inference now, so maybe hints would an an alternative solution. the property extraction from npm JS code has always been sort of black magic voodoo 😛#2021-05-2817:46kommentype hints works for us, just was surprised to run into this. thus my initial question on the difference between cljs and shadow-cljs regarding this#2021-05-2817:50thhelleryeah, shadow-cljs will process all npm code and in the process collect some properties. CLJS never looks at JS code so never collects those.#2021-05-2819:02thheller@kommen should be back to normal in 2.14.2#2021-05-2819:34kommenyep, looks good. CI with integration tests is green and the warnings are gone. will test more on monday. thank you so much!#2021-05-3113:11kommen@U05224H0W fyi, we have it in production now it looks good so far#2021-05-2819:50thhellerI'm beginning to hate the closure compiler ... for some reason on windows it started rewriting the filenames I give it from some/thing.cljs to some\\thing.cljs. which wouldn't matter except that it breaks source maps and the build report. super fun time trying to figure out why and when that changed ... :face_vomiting:#2021-05-2917:11rbergerIs it a closure compiler problem or a Windows problem? Windows’ original sin was using backslash instead of slash for file separators IMHO.#2021-05-2900:21vermaSo the CSS auto reload is not working for me because I dynamically load the CSS (based on tenant configuration), the setup is similar in development also, and I read in the documentation that any absolute references CSS resources should auto load. I was wondering if there's a way for me to explicitly instruct shadow to watch certain CSS files at certain paths?#2021-05-2900:32vermaOk, I coded the path in instead of keeping it dynamic, but still I don't see any reloads happening hmm. Double checking things.#2021-05-2900:42vermaAs far as I can tell config looks ok 😞#2021-05-2907:48thhellerand what does the config look like? 😛#2021-05-2915:37verma🙂 thanks for your response https://gist.github.com/verma/7fd227fb6dda8092fbdf9e4a5c45b5cf#2021-05-2916:53thhellernote that in shadow-cljs you don't need separate dev/release builds. one build for both cases is enough.
#2021-05-2916:54thhellerotherwise looks fine. assuming your CSS files actually reside in resources/public somewhere and that your link tags in the HTML use absolute paths#2021-05-2916:57vermaThey do 😞 but I will make sure, for sure I am doing something wrong somewhere. Thanks for your help. The debug/release build are just left-over from figwheel days 🙂#2021-05-2917:00thhellerpaths need to match, thats about it. so resources/public/whatever/foo.css would be /whatever/foo.css in the HTML#2021-05-2917:01thhellerassuming of course you use the server on :3449#2021-05-2917:01thhellerthis looks somewhat suspicious :devtools-url "". don't know why you are doing that#2021-05-2917:02thhellersuggests that you are using another server inbetween that maybe mucks with the paths#2021-05-2917:03thhellerin which case you might to tweak the :watch-path "/foo" option (prefix)#2021-05-2917:09vermayes, there is an nginx proxy sitting in the middle which proxies requests to shadow-cljs and the backend ... that's a good point, I will check what its re-writing this path to. I will also check directly against :3449 .. thanks for the suggestions!#2021-05-2917:57vermaI see that nginx is not doing anything funky with re-writing URLs, but let me check how it works with direct connection to :3449#2021-05-2918:05vermaOk, it seems to be running through :3449 🎉 .. I am looking into what's up with going through proxy.#2021-05-2918:41vermaI am not sure what I did but it all seems to be working now. The only change I made was that I exposed port 3449 on to the host from my docker container. But its all working now even with dynamically loaded CSS! Phew! This has been bugging me for a while but its working well now! :thumbsup: thanks for all your help and the amazing shadow-cljs!#2021-05-2919:18vermaOk, here's an observation: I start my dev env and I go to dev.local and the CSS reloading doesn't work. Then I go to dev.local:3449 and although I cannot reach my backend the frontend loads and then if I make a change to my css, it reloads correctly. Then finally, if I go back to dev.local again, the css loading works (with or without /css/style.css).#2021-05-2919:25vermaOk, so I am consistently able to reproduce this, I am not including /css/style.css in my html but shadow-cljs seems to be picking up my dynamic include. I can work around this as long as I visit :3449 first.#2021-05-2916:07SchpaaShouldn’t pretty-print be the default (or at least persistent) when selected in the inspect latest tab?#2021-05-2916:08SchpaaOr can this be configured somewhere?#2021-05-2916:08SchpaaContext is the Tap History facilities in the browser#2021-05-2916:51thhellerin ~/.shadow-cljs/config.edn :js-options {:preferred-display-type :pprint}#2021-05-2918:09Schpaa🙏#2021-05-3001:43nivekuilhttps://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options mentions :infer-externs defaults to true, but I think it should say :auto now instead?#2021-05-3019:59Ketan SrivastavHello all. I am wondering if shadow-cljs supports chrome extension development using Manifest 3? I am halfway through my development and now having to migrate to version 3 from 2. In manifest 3, instead of a background script, you need to have a service worker. currently, i am rewriting manifest.json with a version of the JSON i wrote, which overwrites the automatically generate options with hardcoded ones( where i change the background file to a background service, etc.), after each compilation. The arrangement works in the sense that the extension loads and functions properly but i have lost the ability to connect to the browser REPL for repl driven development. I know shadow-cljs supports connecting to an active service worker, so even if it doesn't yet support manifest 3 it should definitely be possible and i would be willing to make the change. In that case, can anyone give me a few pointers as to which part of the shado-cljs code i should be looking to modify?#2021-05-3116:54thheller@ketan.srivastav shadow-cljs has no notion of manifest versions, you just put whatever into the manifest. no clue how that works nowdays.#2021-05-3118:54martinklepschI’m trying to require node-xlsx but somehow I’m not having luck with this:
import xlsx from 'node-xlsx';
translated to this (https://shadow-cljs.github.io/docs/UsersGuide.html#npm)
["node-xlsx" :default xlsx]
With this approach xlsx is nil. With other approaches it returns an empty object but nothing that contains the build method mentioned in https://www.npmjs.com/package/node-xlsx
#2021-05-3119:09nivekuiltry :as instead of :default (as per 2nd paragraph in https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports)#2021-05-3119:20martinklepschStill getting (.-build xlsx) => nil#2021-05-3120:02thhellermaybe try (js/require "node-xlsx"), there seem to some newer ESM only node packages that only work with import. those are not yet supported.#2021-05-3120:03thhellerbut there is a // Or var xlsx = require('node-xlsx').default; example so should be fine?#2021-05-3120:57martinklepschI tried plain js/require but got an empty ja map there too. I’ll give this another try tomorrow #2021-06-0123:55rbergerI just went thru something similar with https://github.com/daily-co/daily-js It had two “libraries” under {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "9df3f2f9f8b0f0f2f9e8f1f8eeddf9fcf4f1e4b0fef2"}, :content ("[email protected]")} I first tried out doing the explicit file import as part of the require:
(:require
  ["@daily-co/daily-js/dist/daily-iframe-esm.js" :default DailyIframe])
to see which one worked and then moved it into shadow-cljs:
:js-options
           {:resolve {"@daily-co/daily-js" {:target :npm
                                            :require "@daily-co/daily-js/dist/daily-iframe-esm.js"}}}
as per https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm
#2021-06-0123:57rbergerI’d be curious why the world is like this but at least got it to work!#2021-06-0200:19rbergerThat being said, now that I did a quick try with xlsx, you are having a different problem. xlsx is being set from (:require ["node-xlsx" :as xlsx]) so the basic import is working#2021-06-0200:27rbergerActually for me it works fine:
(:require ["node-xlsx" :as xlsx])
(js/console.log "XLSX: " (.-build xlsx))
Produces the following in the console:
XLSX:  λ[]
       jsƒ (worksheets,options)
Using :default instead of :as works the same for me.
#2021-06-0200:33rbergerSo “works on my computer!” 🙂#2021-06-0212:17martinklepschSo for me it actually turned out the problem existed between the chair and the keyboard. I thought I installed a different library than what I had actually installed, thus the require didn’t work. Interestingly it didn’t hard-fail either#2021-06-0221:50rberger👍#2021-06-0110:35snurppaAnyway to disable/ignore unreachable code warnings when releasing? Seems it is not coming from cljs.analyzer/*cljs-warnings* as for example :warnings-as-errors true has no effect on it 🙂#2021-06-0111:07thhellernot sure, maybe :compiler-options {:closure-warnings {:unreachable-code :off}}?#2021-06-0113:18snurppathanks, indeed it seems so.. however when I try it, I get the following when releasing:
[:front] Compiling ...
{:type :shadow.build.closure/invalid-closure-warning, :key :check-useless-code, :level :off, :shadow.build.log/level :warn}
and the warning is still printed :thinking_face: build release config is:
:release {:compiler-options
          {:warnings-as-errors true
           :closure-warnings   {:check-useless-code :off}}}
At least the ClojureScript docs says that :check-useless-code should be available. Hmm..
#2021-06-0113:23snurppathis is with :lein true and [thheller/shadow-cljs "2.14.1"] & [org.clojure/clojurescript "1.10.866"] , i will check the sources tomorrow unless you don’t have any idea from the top of your head, thx :thumbsup:#2021-06-0116:13thhellerthe docs may be out of date. the closure compiler changes the names of those things constantly.#2021-06-0116:14thhellermight just be :useless-code or :uselessCode#2021-06-0117:30snurppathank you, I found how you used (DiagnosticGroups/getRegisteredGroups) and found from there that it is nowadays "uselessCode" -> :useless-code#2021-06-0111:08thhellerthe warning is from the closure compiler, not the cljs compiler#2021-06-0117:25haywood👋:skin-tone-2: anyone have experience evaluating clojurescript code in the browser within a shadow-cljs project? https://yogthos.net/posts/2015-11-12-ClojureScript-Eval.html I’m following this example but it looks like (empty-state) is missing cljs.core because when I eval (+ 1 1) I get
WARNING: Use of undeclared Var cljs.user/+ at line 1 
but when I clone the repo used in the example (which uses figwheel) it’s working, so just wondering if there is some compiler setting I might need
#2021-06-0117:43haywoodupdate, I’m reading here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html#2021-06-0122:22haywoodstealing from here https://github.com/mhuebert/shadow-bootstrap-example#2021-06-0210:197e27I’m trying to use the :dev-http with :ssl. The build is succesfull, and shadow-cljs logs “HTTP server available at https://localhost:3000”. I get curl: (35) error:14004410:SSL routines:CONNECT_CR_SRVR_HELLO:sslv3 alert handshake failure. My shadow-cljs.edn file looks like this:
{:dependencies [[reagent "1.0.0"]
                [re-frame "1.2.0"]]
 :source-paths ["src"]
 :nrepl {:port 4444}
 :ssl {}
 :dev-http {3000 "public"}
 :builds
 {:app {:target :browser
        :output-dir "public"
        :asset-path "/"
        :modules {:app {:init-fn hello.core/init}}}}}
Am I missing something?
#2021-06-0211:107e27Never mind. The problem was me using bad keytoolinvocation, I should just RTFM I guess - sorry:)#2021-06-0218:38alexdavisI am trying to use some JSX components in a cljs project. I'm following the shadow user guide and have babel processing my .tsx files and outputting .js files. This works totally fine, unless I try and import a file that requies another js file. So this works without issue:
'gen/Button.js'
...
import React from 'react';

export const Button = ({
  primary = false,
  label,
  ...props
}) => {
  const mode = primary ? "text-primary" : "dark:text-white";
  return /*#__PURE__*/React.createElement("button", _extends({
    className: "font-extralight " + mode
  }, props), label);
};
But this fails
import React from 'react';
import { Button } from './Button.js';
export const Header = ({
  onCreateAccount
}) => /*#__PURE__*/React.createElement("header", null, /*#__PURE__*/React.createElement("div", {
  className: "wrapper"
}, /*#__PURE__*/React.createElement(Button, {
  primary: true,
  size: "small",
  onClick: onCreateAccount,
  label: "Sign up"
})));
with the error
Header.js:8 Uncaught ReferenceError: Button$$module$gen$Button is not defined
This is all the cljs needed to cause the error
(:require ["../gen/Header.js" :refer (Header)])
It all works from a JS project FWIW
#2021-06-0218:38alexdavisThe shadow guide seems to suggest that this should be fine though so not sure whats going wrong#2021-06-0218:40thhellerlooks fine. any other errors before that one? that one might just be a symptom not the cause?#2021-06-0219:00thhelleroh and I'm assuming this is a browser target?#2021-06-0219:58alexdavisYes browser target, no other errors. I’ll put together a minimal reproducible example tomorrow, was just wondering if I was doing something silly…#2021-06-0222:44alexdavisOk this is bare minimum to reproduce https://github.com/armincerf/clojurescript-serverless-framework/blob/build-failure-requiring-js-file/src/todo_mvc/core.cljs Javascript components are here https://github.com/armincerf/clojurescript-serverless-framework/tree/build-failure-requiring-js-file/src/components js files generated by babel --plugins @babel/plugin-transform-react-jsx src/components --out-dir src/gen --watch are here https://github.com/armincerf/clojurescript-serverless-framework/tree/build-failure-requiring-js-file/src/gen#2021-06-0222:45alexdavisThere's definitely still a possiblity this is just me not understanding something fully, but I'm pretty sure this should work#2021-06-0302:36Ronny LiHi everyone, does shadow-cljs handle URL rewriting to support deep-linking into a single-page app? We are hosted on firebase and to perform rewrites we just need to do the following (Note that we actually have two pages. Hopefully that's not an obstacle):
"rewrites": [
      {
        "source": "/",
        "destination": "/index.html"
      }, {
        "source": "**",
        "destination": "/trade.html"
      }
    ]
So http://www.mysite.com/foo/bar rewrites to /trade.html on firebase but not in localhost. Any suggestions for how to fix this would be greatly appreciated!
#2021-06-0306:52thhellerjust use a the local firebase development http server. IIRC it has one? don't need to use the shadow-cljs http server for this.#2021-06-0309:56Ronny LiThanks for the the reply Thomas. My understanding is that the https://firebase.google.com/docs/hosting/test-preview-deploy#test-locally doesn't support hot reloading? Step 4 of https://firebase.google.com/docs/hosting/test-preview-deploy#test-locally says "To update the local URL with changes, refresh your browser."#2021-06-0309:58Ronny Libut you're totally right that I'm able to test deep-linking when I use firebase emulators:start as opposed to
shadow-cljs watch app
#2021-06-0310:00thhellerthose two are completely separate and the HTTP server you use has nothing to do with hot-reloading. that is separate.#2021-06-0311:08Ronny Lioooh gotcha so I'm supposed to run both at the same time. Thank you!#2021-06-0311:08thhelleryes#2021-06-0309:49romdoqIs there a way to bundle eg. binary images along with an :npm-module build? Such that I can get a URL to use in eg. an [:img {:src image-url}]? I'm thinking of something like the Webpack(?) bundler(?) that lets one import { default as myImageUrl } from './my-image.png'; in Javascript.#2021-06-0310:01thhellerno#2021-06-0310:34romdoqokay, that's what I thought thanks 🙂#2021-06-0311:42ikitommiis there a shadow + StoryBook example around there? the link in Clojureverse seems dead: https://github.com/shadow-cljs/examples/tree/master/cljs-storybook#2021-06-0311:53alexdavishttps://github.com/lilactown/storybook-cljs this is reasonably recent#2021-06-0312:09ikitommithanks!#2021-06-0313:40thhellerthere could be a :target :storybook that outputs everything exactly in the format storybook wants but so far not too many people use storybook it seems#2021-06-0318:20ikitommimight see more adoption if the integration would be that trivial?#2021-06-0318:23ikitommithe example doesn’t work anymore:
TypeError: Cannot read property 'CLOSURE_UNCOMPILED_DEFINES' of undefined
#2021-06-0318:26thhellerhmm yeah storybook changes a lot. kinda switches how everythingthing works every version. haven't looked at it recently.#2021-06-0517:03rbergerI for one would love a :target :storybook. Personally I think it would be a game changer in terms of making Clojurescript more popular.#2021-06-0517:05rbergerAlso @UAZRR3MRN wrote something up on his recent experience with it https://shaolang.github.io/posts/2021-02-14-storybook.js-with-shadow-cljs/#2021-06-0517:06thhellerpersonally I'd much rather have some CLJS based. storybook doesn't look that special to me?#2021-06-0517:07rbergerIt's an ecosystem that would be nice to be part of. And there is no CLJS equivalent that I have found. Wish there were!#2021-06-0517:18thhellerlooks fine for me from the config side. not sure what else :target :storybook could make easier?#2021-06-0517:18thhellerFWIW :target :npm-module also supports :ns-regexp "stories$" so you don't have to list all :entries manually#2021-06-0517:19thheller
{:target      :npm-module
 :ns-regexp   "stories$"
 :output-dir  "public/js/stories"}
#2021-06-0517:22rbergerWell you suggested :target :storybook 😁 Sounded good to me. I have seen a few stabs at getting a minimal usage, I haven't had a chance to really dive into it yet. But my interest is to use it as a way to document our internal UI Components and evolve to a design system. Ideally with the ability to leverage other things going on in the Storybook world (which may or may not really be possible if there are a lot of assumptions about having JS code be the main underlying "glue"#2021-06-0517:26thhelleryeah but the blogpost you linked looks pretty optimal to me. not sure what else a :target :storybook could do. there could be one if it was more complicated but it doesn't seem to be. I don't use storybook so no clue where the problems are#2021-06-0517:27rbergerYes, will need to dive into it. Wish I had more time to explore meta tools for CLJS UI building. Maybe someday#2021-06-0317:37myguidingstarwhy is the file argument to load-file must be in classpath? https://github.com/thheller/shadow-cljs/blob/e6c7d36dc4a870c0b64286e0b590e69c06c63d43/src/main/shadow/cljs/repl.clj#L296#2021-06-0317:39myguidingstarwhat does it take to remove that constraint? I suppose it's connected to other part of the code base?#2021-06-0317:40thhellerbecause thats generally what you want for a "build tool", repeatable builds are the focus. so accessing stuff outside the classpath is generally not allowed#2021-06-0317:40thhellerwhy do you care? I mean what files are you trying to load that aren't on the classpath?#2021-06-0317:42myguidingstarI asked because I'm using lispy-mode in emacs (an alternate to paredit) which load some "middleware" which is just a cljs file packaged with lispy-mode itself#2021-06-0317:43myguidingstarcurrently lispy-mode can't work with shadow because it use cider to load the said cljs file when starting up lispy#2021-06-0317:43myguidingstarand I see repl-load-file* thow exception that the file is not in class path#2021-06-0317:43thhellerhmm yeah thats a problem#2021-06-0317:45myguidingstarso what does it take to fix? I suppose it may break the api or make some errors become uncaught?#2021-06-0317:45thhellerreplacing this throw with an impl that supports files outside the classpath https://github.com/thheller/shadow-cljs/blob/e6c7d36dc4a870c0b64286e0b590e69c06c63d43/src/main/shadow/cljs/repl.clj#L294#2021-06-0317:46thhellerbasically the same as the impl below that, just without all the classpath references#2021-06-0317:47thhellerwill be kinda hard without understanding how all of it works internally 😛#2021-06-0410:06myguidingstarthis is hard indeed with all the internals 😄#2021-06-0412:29thhellerI went with a slightly different strategy so that it doesn't matter whether the file is on the classpath at all, no difference in code executed#2021-06-0412:30thhellerI wanna look into something else first but I'll try to make a release later today#2021-06-0414:11thhellertry 2.14.3#2021-06-0414:11myguidingstargreat. Many thanks#2021-06-0317:47thhellerfeel free to open an issue about this. can't get to it right now but maybe over the weekend#2021-06-0317:48myguidingstaryes, I will. I'm trying to make a PR anyway...#2021-06-0317:49myguidingstarthank you very much#2021-06-0406:15DiegoI am trying to create a library that is going to be included in a script tag in another shadow-cljs project. The problem I am facing is that it seems that a shadow$provide global variable is created for each build, and because of this, the second variable overwrites the first one producing a Module not provided. I've tried the :browser and the :node-library targets and both of them seem to have the same problem. What is the best way to get around this?#2021-06-0406:27thheller@diego.vid.eco it is not a good idea to use 2 separate CLJS builds on the same page. both will end up including cljs.core and all other dependencies leading to a lot of bloat. they also won't be compatible with each other and can't exchange CLJS datastructures. ideally make the library part of the compilation of the second one, like any other CLJS libs.#2021-06-0406:45DiegoI see. And it makes sense. I originally wanted to develop a couple of plug-n-play libraries for an art project, where also others could plug in their own developments. So that's why I didn't intend to have them "installed" by default on the hosting webpage. Seems like I may have to reconsider some things, but might not be much of a problem.#2021-06-0406:52thhelleryeah unfortunately there is no way to really do this properly in CLJS. even if I isolated shadow$provide more that doesn't fix all the other problems you'd have.#2021-06-0406:53thhellerJS has the same issues if you have 2 libs using immutable-js or so. things can talk to each other fine with just JS objects but everything else breaks.#2021-06-0408:14danielnealis it possible to have multiple shadow-cljs builds with different dependencies. i.e. I want to produce a js npm package (that doesn't depend on react, helix etc) and a cljs live-reloading demo of the package (that does depend on react, helix etc), but preferably from the same overall project#2021-06-0408:16thhellernpm library as-in it will be consumed by JS projects?#2021-06-0408:17thhellerin general your dependencies decide nothing about the build. the build config controls how or what is included, not the dependencies you have listed in your project#2021-06-0408:17thhellerwhat is a live-reloading demo? for people checking out the repo and running it locally you mean?#2021-06-0408:18danielnealyep, the npm library will be consumed by js projects#2021-06-0408:19danielnealthe live-reloading demo is exactly for the cljs devs so that we can check out the lib and make modifications to it and see it in action#2021-06-0408:19thhellernot including react is fine but helix is a CLJS lib so you need to include that no?#2021-06-0408:20thhellerto build the library you can use :target :node-library or :target :npm-module, those by default don't bundle JS dependencies, only compiled CLJS code#2021-06-0408:21danielnealah ok#2021-06-0408:21danielnealI'll have a go 🙂#2021-06-0408:21thhellerhttps://github.com/thheller/npm-module-demo#2021-06-0408:22thhellermade that a long time ago. config is unchanged though. just need to bump a few versions#2021-06-0408:23thhellerbasically you add the dependencies of the package in the packages/demo/package.json#2021-06-0408:23thhellerand publish the packages/demo dir using npm publish#2021-06-0408:24danielnealthe :entries key is a list of clojurescript namespaces to include in the npm package?#2021-06-0408:29thhelleryes#2021-06-0408:29danielnealgreat, thanks#2021-06-0408:40Franklincan shadow-cljs also watch and hot-reload css?#2021-06-0408:42thhellerwatch as in observe when the file changes yes#2021-06-0408:42thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2021-06-0408:42Franklinyes, so I'm hoping that when I change them... the styling on the browser also changes#2021-06-0408:42Franklincool, thanks#2021-06-0413:32myguidingstarhow do I use latest shadow-cljs from github?#2021-06-0414:54thhellerunfortunately not that simple. can't use deps.edn because there is some stuff that needs to be built (eg. java sources).#2021-06-0501:50awb99I have a weird bug with shadow-cljs: when I add the dependency to tools.deps.alpha, add-libs3 branch, the watch comand crashes.#2021-06-0501:51awb99this is the dependency: org.clojure/tools.deps.alpha {:git/url "https://github.com/clojure/tools.deps.alpha.git" :sha "241cd24c35ba770aea4773ea161d45276e5d3a73"#2021-06-0501:51awb99And this the error:#2021-06-0501:52awb99[2021-06-05 01:46:51.392 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}} NoSuchMethodError 'java.util.stream.Collector com.google.common.collect.ImmutableList.toImmutableList()' com.google.javascript.jscomp.deps.DependencyInfo$Require.asSymbolList (DependencyInfo.java:60) com.google.javascript.jscomp.deps.DependencyInfo$Base.getRequiredSymbols (DependencyInfo.java:163) com.google.javascript.jscomp.Compiler.findModulesFromInput (Compiler.java:1954) com.google.javascript.jscomp.Compiler.findModulesFromEntryPoints (Compiler.java:1910) com.google.javascript.jscomp.Compiler.parseInputs (Compiler.java:1723) com.google.javascript.jscomp.Compiler.parseForCompilationInternal (Compiler.java:933) com.google.javascript.jscomp.Compiler.lambda$parseForCompilation$4 (Compiler.java:916) com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127) com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:816) com.google.javascript.jscomp.Compiler.parseForCompilation (Compiler.java:914) com.google.javascript.jscomp.Compiler.compile (Compiler.java:667) jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (:-2)#2021-06-0501:52awb99my setup is completely the same.#2021-06-0501:52awb99just adding the dependency is enough#2021-06-0506:32thhellerdependency conflict on guava#2021-06-0517:20awb99how can there be dependency conflicts with deps.alpha ? deps.alpha always takes the newest version?#2021-06-0517:21awb99any idea how to resolve it?#2021-06-0517:22thhellerthe newest version may be the one breaking stuff#2021-06-0517:23thhelleryou'll need the version the closure compiler expects#2021-06-0517:24thhellerno clue why you are putting tools.deps.alpha on the classpath for CLJS compilation though, probably best to keep it in a server-only alias#2021-06-0502:48SxPWhat's the proper way to use printf formatting in Clojurescript? I see posts on the web suggesting using goog.string.format but there are other posts discussing dead code elimination issues with that library. I have a minimal test app with
(ns stopwatch (:require [goog.string :as gs]))
(println (gs/format "Hello %s" "world"))
that works with shadow-cljs when building without optimizations. But if I use :simple or :advanced, I get a runtime failure because goog.string is missing format.
#2021-06-0506:33thheller@sameer864 add an extra [goog.string.format] to your :require then it'll work. it lives in its own file/namespace so just importing goog.string is not enough#2021-06-0506:48thheller(for dev builds likely some other devtool requires it, so it works accidentally. for release builds that devtool is unused and so the require is missing)#2021-06-0507:05SxP@thheller, thanks. That worked. Is this an issue specific to goog.string/format or will I run into this with other APIs when I create release builds? I though the build system would automatically include all the transitive dependencies of the functions I refer to.#2021-06-0507:07thhellernot the functions you refer to. the namespaces you require. goog.string.format just happens to be this special case that it is a separate namespace, not part of goog.string.#2021-06-0507:08thhellerits a weird case, that is rather uncommon#2021-06-0516:45sbSomebody solved this npm package w/shadow-cljs? https://www.npmjs.com/package/react-dates, I require as
["react-dates/initialize" :as init]
["react-dates" :as rd :refer [DateRangePicker SingleDatePicker DayPickerRangeController]]
#2021-06-0516:46sbI tried with `
(def DateRangePickerX
  (r/adapt-react-class DateRangePicker))
or [:> DateRangePicker.. but not really work..
#2021-06-0516:46sbany idea what.. I did in wrong way?#2021-06-0516:49sbClear example: https://github.com/majapw/react-dates-demo/blob/master/src/App.js#2021-06-0517:02thheller@sb and what is the error?#2021-06-0517:03sbsimply no error..#2021-06-0517:03sbnothing happens.. when I click on the fields..#2021-06-0517:03thhellerprobably because you are missing the css?#2021-06-0517:04thhellerat least looks like that?#2021-06-0517:04sbwithout css.. I didn’t add, I just check the functionality#2021-06-0517:04sbyes, without css#2021-06-0517:04thhellerdon't know what it does but it might happen outside the visual area because of the missing css#2021-06-0517:04sbok, I’m going to add it, thanks!#2021-06-0517:07sbI don’t think…
body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}
#2021-06-0517:07sbthat is the css#2021-06-0517:08thhellerhttps://unpkg.com/browse/react-dates@21.8.0/lib/css/_datepicker.css#2021-06-0517:08thhellerthat is the css?#2021-06-0517:18sbSorry, true!#2021-06-0517:36sbI need to setup a demo project for this.. because without this I can’t debug.. 😕#2021-06-0517:38thhellerprobably a better question for #reagent the shadow-cljs parts seem to work fine#2021-06-0616:29kiranshilaQuick question - what is the "correct" way to package up a library with node dependencies? I've tried adding the list of them to deps.cljs in src, but including the dependency from clojars in a shadow project elsewhere didn't seem to install them.#2021-06-0616:31thhellerhow did you package it? I mean is the deps.cljs file actually included with the jar? what is the clojars lib?#2021-06-0616:33kiranshilaOoo it doesn't look like it is in the jar#2021-06-0616:33kiranshilahttps://clojars.org/com.kiranshila/cybermonday#2021-06-0616:33thhellerdeps.cljs with {:npm-deps {"foo" "version"}} is the correct way#2021-06-0616:33kiranshilaAnd does it go in the root of the project or next to the source, I wasn't quite sure#2021-06-0616:34thhellerinto the root of one of your source paths#2021-06-0616:34thhellerso src/deps.cljs in your case#2021-06-0616:35kiranshilaAh I see, I think I put it too deep the first time I tried#2021-06-0616:40kiranshilaSuccess! Thank you @thheller!#2021-06-0617:39sbCould somebody help to test this repo? https://github.com/damesek/example-error I created from this, and still not work on my computer, but there is a screenshot too that is works. From here: https://stackoverflow.com/questions/58852849/clojurescript-date-timepicker-with-cljsjs-react-day-picker. I got this react.development.js:316 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.#2021-06-0617:41sbI think, that is a same issue at all packages.. as I feel. I can’t find out, maybe very trivial.. 😕#2021-06-0617:41thhellerread and understand the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-06-0617:41thhellerthen compare the JS code from the example docs with the CLJS code you have#2021-06-0617:41thhellerand you'll find the problem#2021-06-0617:42sbthanks!!#2021-06-0617:45thhellernote that looking at "old" example may not be correct today#2021-06-0617:46thhellerJS packages often change how they bundle stuff so the way you require them may change as well#2021-06-0618:06sbOk, … now works all. :man-facepalming:picard-facepalm thanks the help!#2021-06-0714:46Sam Ritchiehey all, gut-check question here… I have a library I’d like to depend on that is currently managed with bower: https://gitgud.io/unconed/mathbox If I want to publish a clojurescript library that depends on this package… is the best option to re-publish this as an NPM dependency? I am getting my head around all of this, and it seems that bower is deprecated#2021-06-0714:47Sam RitchieI guess the alternative that comes to mind is cljsjs, or including the js files directly (seems very un-pro)#2021-06-0716:23thhellerfor shadow-cljs you'd need to publish to npm since cljsjs is not supported. should be very simple since bower is very similar to npm as far as packages are concerned#2021-06-0716:25thhellerin fact shadow-cljs can also use bower packages just fine, just needs a little extra configuration in :js-package-dirs#2021-06-0716:49Sam Ritchieinteresting!#2021-06-0716:49Sam Ritchieis there any docs page that lays out what to do? otherwise I will go down the NPM road#2021-06-0716:50thhellerwell since you mentioned publishing a library that depends on mathbox I strongly recommend publishing to npm#2021-06-0716:50thhellerotherwise everyone using that package would need to manually install bower and that package#2021-06-0716:50thhellerwith npm it just works automatically if you list it in deps.cljs#2021-06-0716:50Sam Ritchiegot it, that is clearly best#2021-06-0716:51thhellerotherwise if you just want to try it https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules#2021-06-0716:51thheller:js-packages-dirs ["node_modules" "bower_modules"] IIRC bower used that dir?#2021-06-0716:52thhellerbut to publish the thing to npm you likely only need to change the name in package.json and npm publish#2021-06-0716:53Sam Ritchiethank you @thheller#2021-06-0716:53Sam Ritchie!#2021-06-0716:55thhellerdunno if its a good idea to use a 5 year old JS package with version 0.0.5 though. It is not clojure after all 😛#2021-06-0717:07Sam Ritchie@thheller in most cases I would agree.. BUT!#2021-06-0717:08Sam Ritchiein this case, this library still seems to be the most world-class thing out there for mathematical visualization in the browser... it powers http://www.math3d.org/animate_camera as an example#2021-06-0717:09Sam Ritchie@unconed has this insane level of work in this project, but stalled because he'd developed something wonderful but "javascript as a language didn't seem to fit for the declarative XML-ish structures he'd based the library on" 😉 https://acko.net/blog/mathbox2/#2021-06-0717:09Sam Ritchieso I'm going to rehab this thing and get him interested again. Anyway, TMI for the main thread, but cool stuff!#2021-06-0718:09Sam Ritchie@thheller one Q for you related to cljsjs. I've published mathbox as https://www.npmjs.com/package/@sicmutils/mathbox2. I want to provide a :global-exports entry that will make this package compatible with shadow-cljs. but the boot task in cljsjs needs a map of sym=>sym for its :global-exports value. what should the value be here?
:global-exports '{"@sicmutils/mathbox2" MathBox
                  cljsjs.mathbox2 MathBox}
#2021-06-0718:10Sam RitchieI can always republish it without the @ symbol... but I don't want to stomp the global mathbox2 name, for when the original author pushes this out#2021-06-0718:13thhellerI don't understand your question. shadow-cljs does NOT support foreign-libs, so whatever you add there will not be read by shadow-cljs at all?#2021-06-0718:13thhellerdoes (:require ["@sicmutils/mathbox2" :as x]) not work?#2021-06-0718:16Sam Ritchieah, I think I have this figured out. I wanted to make sure that the foreign-libs entry I added would let users write code that was compatible with foreign-libs and also with shadow-cljs, and cljsjs was rejecting my foreign-libs entry#2021-06-0718:18Sam Ritchieyour line should absolutely work with shadow-cljs (duh), and I think I figured out how to get past my problem in cljsjs...#2021-06-0718:20thhelleryeah you can just setup foreign-libs to that the above require works with regular CLJS. can't remember how though.#2021-06-0912:53ghaskinsHello all: im struggling to figure out how/when shadow-cljs may or may not automatically invoke npm install#2021-06-0912:54ghaskinsi have two projects and I cant spy a difference in their config, yet one will implicitly install npm deps and the other doesnt#2021-06-0912:54ghaskinsin the one that works, I observe this last line in the output#2021-06-0912:54ghaskins
$ lein dev
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
shadow-cljs - config: /Users/ghaskins/sandbox/git/mcp-login-ui/shadow-cljs.edn
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch app
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
running: npm install --no-save 
#2021-06-0912:55ghaskinsI do not get that in the project that doesnt work…in that project, manually running npm install fixes it#2021-06-0912:59ghaskinsim just looking for what triggers that difference in behavior#2021-06-0913:58dpsuttonas far as I know shadow never does this. There's a lein plugin that you are likely using here that does this. To me that plugin is a mistake, making everything more complicated#2021-06-0914:04ghaskinsThat’s what I was wondering (and I agree) but I don’t seem to have a plug-in in either#2021-06-0914:04ghaskinsI’ll keep digging#2021-06-0914:10dpsuttonin the project.clj file you should see a shadow config, and also a lein-shadow (i think this is the name) plugin. This plugin allows you to keep the config in project.clj, the aim being that everything in a single file is beneficial. It installs npm deps, copies the shadow part to the standard shadow-cljs.edn location and then runs shadow for you. I see zero benefit and only downsides#2021-06-0914:13ghaskinsunderstood…i am not using lein-shadow in either project, afaict#2021-06-0914:14ghaskinsi do use lein, but I have a distinct shadow-cljs.edn (with lein=true) and package.json for each#2021-06-0914:15dpsuttonah, sorry i went down the wrong path then#2021-06-0914:15ghaskinsi cant discern what is different, but one project auto- npm-installs for me#2021-06-0914:33thheller@ghaskins installing npm dependencies is handled by libraries containing a deps.cljs file with :npm-deps listed#2021-06-0914:34thhellerotherwise you can disable it in shadow-cljs.edn but thats about it. maybe the other project has older dependencies that didn't yet have deps.cljs?#2021-06-0914:35thheller@dpsutton shadow does install npm deps by default (for now, might make it optional at some point)#2021-06-0914:35dpsuttonoh is that recent? or have i just totally missed it#2021-06-0914:35thhellerno, that has been there for a very long time#2021-06-0914:36dpsuttonhuh. i could have sworn when i watch an project in the past it would fail until i killed it and npm installed the deps.#2021-06-0914:36dpsuttonoh well. sorry for the noise#2021-06-0914:37thhellerwell it can only install npm deps if they are listed in deps.cljs. many libs didn't do that for a while but nowadays most do#2021-06-0914:39zackteoHello, how do I do import 'leaflet/dist/leaflet.css'; from https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I understand it should be (:require ["leaflet/dist/leaflet.css"]) ? But think I'm doing something wrong#2021-06-0914:39thheller@zackteo css is not supported, so you need to handle it separately. might be enough to just copy the node_modules/leaflet/dist/leaflet.css to your public folder and include it#2021-06-0914:40zackteoRight, how might I want to handle it actually?#2021-06-0914:41thhellerreally depends on what kind of css setup you have. if you don't have one then the manual copy is probably good enough. if you have something like postcss setup just use that.#2021-06-0914:44zackteohmm okay will try#2021-06-0914:44zackteothanks!#2021-06-0915:29ghaskins> installing npm dependencies is handled by libraries containing a `deps.cljs` file with `:npm-deps` listed @thheller thats what I figured…what I cant reconcile atm is that both projects include the same cljs lib with a deps.edn, and then locally declare additional npm deps (such as react) in their local packages.json#2021-06-0915:29ghaskinsbut for reasons I am still unsure about, one project implicitly runs npm install and the other does not#2021-06-0915:29ghaskinsim sure i have some difference I am not yet seeing#2021-06-0915:29ghaskinsill keep digging#2021-06-0915:30ghaskinsi just wasnt sure if there was something to look for, like “oh, check :foo-bar in shadow-cljs.edn”#2021-06-0915:32thheller@ghaskins shadow never runs an inital npm install for stuff listed in your package.json. that you have to do yourself#2021-06-0915:32thhellershadow will only install npm deps that aren't already listed in package.json, so if you have those in them but did not run npm install then they won't be installed#2021-06-0915:33ghaskinsah, that might be the hint I needed#2021-06-0915:33ghaskinsi think I know what is wrong, now#2021-06-0915:33ghaskinsty#2021-06-0915:33ghaskinsill report back#2021-06-0915:33thhellerbasically the deps.cljs install is just a way to get missing things into your package.json#2021-06-0915:33ghaskinsyeah…the project that isnt working had previously been run with the defaults that creates packages-lock#2021-06-0915:34thhellerbut yeah one npm install you'll need at least#2021-06-0915:34ghaskinsso the one that isnt working has a complete packages.json#2021-06-0915:34ghaskinswhere “isnt working” is probably functionally correct#2021-06-0915:35ghaskinsi.e. the project that runs npm install has inadvertent novelty in the dep#2021-06-0915:35thhelleryeah unlike maven deps just listing the deps is not enough, need to actually run npm to install them#2021-06-0915:36ghaskinsty, this is very helpful#2021-06-1005:37tlonistHow do I update new dependencies in shadow-cljs?#2021-06-1005:42tlonistI added a new dependency in shadow-cljs.edn, (by the way I’m using intellij + cursive) and re-ran shadow-cljs watch app. But my cljs file still cannot find required libraries in the namespace.#2021-06-1005:43tlonistI’ve done pom.xml-> download sources as well.#2021-06-1005:43AronI just restart shadow-cljs#2021-06-1005:44tlonistshouldn’t
shadow-cljs watch app 
do?
#2021-06-1006:20thhellerif its already running no, you need to restart it fully. shadow-cljs stop should shut it down completely#2021-06-1006:29thhelleralso depends on how you have configured shadow-cljs.edn. if you have a :deps key in there then dependencies need to be added in deps.edn. if there is a :lein then it would be project.clj.#2021-06-1006:36tlonistThanks! I ran
shadow-cljs pom
and re-imported the project in ide, which worked out.
#2021-06-1006:38thhellerah, thought you meant shadow-cljs didn't find dependencies. yeah shadow-cljs pom to make the dependencies visible for Cursive#2021-06-1009:18Michaël SalihiHi! I'm interested in how to manage the versions of the JS bundle. I have read the part of the documentation https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output and knowing that my html is generated by hiccup, I am thinking of using the solution from the manifest.edn file. Are there some leads? How do you do with Shadow-cljs when an index.html file is used to call the script?#2021-06-1010:34thheller@admin055 if you just have a static html file you can use this hook https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L147-L149#2021-06-1010:35thhellerthat'll take the source and rewrite the html script tags eg. https://github.com/thheller/shadow-cljs/blob/master/out/demo-browser/index.src.html#L10-L11#2021-06-1010:36thhellerbut if you have hiccup you don't need to hook#2021-06-1010:36thhellerjust read the manifest.edn and generate the script tag from that?#2021-06-1010:37thhellerslurp -> edn/read-string and transform it however you need. its just clojure data.#2021-06-1010:42Michaël Salihi> slurp -> edn/read-string and transform it however you need. its just clojure data. Perfect, that's what I'm putting together. Thank you for confirming that I am going in the right direction.#2021-06-1010:44Michaël SalihiI was not aware of this hook, it's wonderful! Thank you#2021-06-1010:50Michaël Salihi@thheller Shadow-cljs is full of hidden gems ... I never regret when I ask questions! 🙂#2021-06-1013:39Michaël SalihiAnother question. If I doesn't the built-in Shadow server and want to watch/reload the CSS file locate in resources/public/css/app.css, what path do I put in {:devtools {:watch-dir "???"}} option?#2021-06-1013:39Michaël SalihiThe path must be in the classpath too?#2021-06-1013:40Michaël SalihiI tried multiple solution but no success.#2021-06-1013:40thhellerresources/public assuming the file is accessed via /css/app.css in your html#2021-06-1013:41Michaël SalihiYes, this is the case.#2021-06-1013:41Michaël SalihiStrange, I already try with this path but no success.#2021-06-1013:41thhelleryou need to restart the watch for this to take effect#2021-06-1013:42Michaël SalihiOh ok, I try to restart#2021-06-1013:45Michaël SalihiAfter restarting, I touch resources/public/css/app.css but not rebuild happened#2021-06-1013:45thhellerwhat rebuild do you expect? css is not built by shadow?#2021-06-1013:47Michaël SalihiYes I know I am using postcss for this. I meant reload#2021-06-1013:48Michaël SalihiCSS reload#2021-06-1013:48thhellerI don't know. what is the EXACT html link tag you use to include it?#2021-06-1013:48thhellerand I'm assuming resources/public/css/app.css is the OUTPUT file produced by postcss, not the input?#2021-06-1013:48Michaël SalihiYes the output file.#2021-06-1013:48Michaël Salihi<link href="/css/app.css" rel="stylesheet" type="text/css">#2021-06-1013:49thhellerand your webserver doesn't cache the file or so? I mean what do you see in the browser console? shadow-cljs should be telling you what it is doing#2021-06-1013:50Michaël SalihiI just got it. My public folder does not contain an index.html file as this is handled by hiccup. I thind watch-dir works only with html file, right?#2021-06-1013:50thhellerno, doesn't care#2021-06-1013:50Michaël SalihiOK, good to know#2021-06-1013:52Michaël Salihi> and your webserver doesn't cache the file or so? I mean what do you see in the browser console? shadow-cljs should be telling you what it is doing I'll do some tests and I'll tell you
#2021-06-1013:52thhellerthere really isn't much to this. :watch-dir will cause shadow to watch that directory and notify about file updates. the client will look for CSS matches by path and reload if found#2021-06-1013:53thhelleragain ... look at the console. if you see a load CSS message from shadow-cljs but css didn't update then your server likely caches stuff and didn't return the "new" version#2021-06-1013:53thhellerif no load CSS shows up then it didn't match the paths properly#2021-06-1013:55Michaël SalihiLoad CSS shows up and CSS reload now, perfect!#2021-06-1013:57Michaël SalihiI think my various tests without restarting shadow-cljs watch misled me. A big thank you again!#2021-06-1014:00Michaël SalihiMore I works with Shadow-CLJS and more I'm impressed by the nice piece of librarie that it is! 😉#2021-06-1015:15knubieI’ve got a function in my app (defn my-fn [x] (do-stuff-with-x)) that gets sent the method toString by some library code. How can I guarantee that toString returns the same value for every build? (I think toString is returning different values because advanced compilation is renaming the function).#2021-06-1015:18thhellerI don't understand. "gets sent the method toString by some library code.". what does that mean?#2021-06-1015:19thhelleryou mean you are calling toString on a function?#2021-06-1016:23knubie@thheller yes sorry#2021-06-1016:23knubiesometimes in OOP calling a method is also called “sending a message”#2021-06-1016:24knubieso it looks like myFn.toString()#2021-06-1016:24knubieFor some context, the pouchdb library does this to create a unique replication ID#2021-06-1016:24knubieit takes the stringified function, plus some other options to create the unique ID#2021-06-1016:25knubieand if the ID change, it will sync everything (which I’m trying to avoid)#2021-06-1016:26thhellerwhy does it take a stringified function? that sounds like total nonsense?#2021-06-1016:27thhellerbut there is no way to guarantee that the function will always stay the same with :advanced, at least as far as I'm aware#2021-06-1016:28thhellerwhy can you not choose which string to use? why a stringified function? I don't get it. have some docs?#2021-06-1016:31knubieSure, the documentation on the replication protocol is here: https://docs.couchdb.org/en/3.1.1/replication/protocol.html#generate-replication-id#2021-06-1016:31knubieand here is the pouchdb implementation https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-generate-replication-id/src/index.js#L15#2021-06-1016:31knubieI believe the idea is that you would want to re-start replication from scratch if any of the parameters for the replication changes#2021-06-1016:34knubiewhat if I import the function from a javascript module?#2021-06-1016:35thhellerand where is that function used? everything going through :advanced or even :simple is never guaranteed to stay identical#2021-06-1016:37knubieUsed here: https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-replication/src/replicate.js#L48#2021-06-1016:37knubieI could fork the library (I already maintain a fork of this lib so it wouldn’t be a huge deal)#2021-06-1016:38thhellerhmm yeah no clue, I don't see a way to keep this totally stable#2021-06-1016:39thhellerI mean any kind of minifier should have this issue? it might end up sort of stable but there is no guarantee#2021-06-1016:40knubieYeah seems like that would be the case#2021-06-1016:40knubieI’ll search around the issues and stuff to see if anyone else has the same problem#2021-06-1016:40knubiethanks for taking a look with me#2021-06-1016:41thhellerI mean you can go totally crazy with hacks but that seems kinda scary#2021-06-1016:43thheller(defn ^:export my-fn [x] ...) and as .filter you use (js/Function. "function filterMe(x) { return _fn(x); }") 😛#2021-06-1016:44thhelleror was it (js/Function. "x" "return _fn(x);"), can't remember precisely#2021-06-1016:44thhellerkinda absurd to construct a function that way, but that would stay equal 😉#2021-06-1016:44knubiehmm#2021-06-1016:45knubieI’ll play around with it, but thank you for suggestions!#2021-06-1019:58Michaël SalihiMe again :) I just finished the Reagent front end integration of this demo app https://inertia.prestance-design.com/js and I'm going to tackle the optimization. For that I use the useful Shadow-cljs report and it seems to me that overall it looks to be well optimized? https://inertia.prestance-design.com/js/report.html Someone in the know could give me an opinion? Is there something to do in particular at the level of the CLJS bundle?#2021-06-1020:08Michaël SalihiOr the final size seems reasonable.#2021-06-1020:32thhellerlooks reasonable. below 150kb gzip is good#2021-06-1020:32Michaël SalihiPerfect, thanks for taking the time 👍#2021-06-1109:32Franklinhey @thheller I'm having some trouble with using the repl
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "3253425b4b5d7253425b4b5d1f665a5b5c59625356"}, :content ("[email protected]")}
#2021-06-1109:33Franklinmy app build looks as follows:
{:app {:asset-path "/js/quagga"
        :modules {:shared
                  {:entries []}
                  :organization
                  {:entries [quagga.components.organization.init]
                   :depends-on #{:shared}}
                  :home
                  {:entries [quagga.components.home.init]
                   :depends-on #{:shared}}
                  ...}
        :output-dir "resources/public/js/quagga/"
        :target :browser
        :devtools {:devtools-url ""}}
#2021-06-1109:34Franklinsince I'm using a custom HTTP server, I added the :devtools option#2021-06-1109:34FranklinI'm not sure if I followed the user guide instructions correctly#2021-06-1109:37FranklinI've also tried {:devtools-url ""}#2021-06-1109:40FranklinDo I have to build a handler on my server for /shadow-cljs path that proxies requests to http://localhost:9630?#2021-06-1110:22thhelleris your server running on the same machine as shadow-cljs?#2021-06-1110:22thhellerthen you likely don't need to set :devtools-url at all#2021-06-1110:23thhellerotherwise you need assuming shadow-cljs is reachable on that location. you can test by just opening it in the browser, you should get the UI#2021-06-1110:44Franklinyes, on the same machine#2021-06-1110:45thhellerthen you just need to open the generated JS in the browser, no :devtools-url#2021-06-1110:45thhellercheck the browser console if it connects properly#2021-06-1111:47Franklinin the available runtimes tab#2021-06-1111:47Franklinshould I find a cljs runtime#2021-06-1111:52thhelleronce it is connected yes. check your browser console where you are loading your app.#2021-06-1111:59Franklinstill getting the same error
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bfdecfd6c6d0ffdecfd6c6d092ebd7d6d1d4efdedb"}, :content ("[email protected]")}
#2021-06-1112:00thhellerand what about the browser console?#2021-06-1112:01thhellerI don't know what you are doing but what you just pasted is just telling me that no runtime has connected back to shadow-cljs. so you either didn't open the compiled code in the browser OR it failed to connect#2021-06-1112:01thhellerI tried explaining how everything works in https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2021-06-1112:01thhellerI cannot do better here#2021-06-1112:02thhellerif you just care about quickly getting a REPL that is NOT related to your "app" you can just use shadow-cljs browser-repl instead. that'll open a browser on its own.#2021-06-1112:03Franklinthe browser console seems silent... nothing is logged#2021-06-1112:04thhellerthere MUST be something logged. either "shadow ready" message OR some kind of error or timeout#2021-06-1112:04thhellerI'm assuming here of course you are running a shadow-cljs watch app already#2021-06-1112:07Franklinno, I wasn't running that...#2021-06-1112:11Franklinok... that's what I was missing#2021-06-1112:11Franklinthanks#2021-06-1215:38Ertugrul CetinHi all, I'm having a problem with @react-three/drei library. When I require it ["@react-three/drei" :refer [Sky Environment]], I get this error:
Closure compilation failed with 2 errors
--- node_modules/three-stdlib/index.cjs.js:2
Illegal variable reference before declaration: i
--- node_modules/three-stdlib/index.cjs.js:2
Illegal variable reference before declaration: t
I've tried a couple of :js-options options did not work out:
{:js-provider :shadow
 :keep-native-requires true
 :output-feature-set :es6
 :closure-output-charset "ascii"}
Here is my package.json:
"@pmndrs/branding": "^0.0.8",
"@react-three/cannon": "2.1.2",
"@react-three/drei": "6.0.2",
"@react-three/fiber": "7.0.1",
"@react-three/postprocessing": "2.0.4",
"@types/three": "0.129.1",
"lodash-es": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"three": "0.129.0",
Any suggestions?
#2021-06-1216:06thhellernot much you can do config-wise. according to the closure-compiler there seems to be some invalid code. I guess you can use webpack as described in this post https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-06-1216:07thhellerwhich version of shadow is this? if not the latest maybe an upgrade might help#2021-06-1216:08thhellersometimes code is actually invalid and webpack just happens to make it work due to its processing#2021-06-1221:30Ertugrul Cetin@thheller "shadow-cljs": "2.12.5"#2021-06-1302:21rbergerCodox seems to be barfing on the :default in :require that shadow-cljs enables. Does anyone know a way to tell codox to allow it? The error is:
Caused by: clojure.lang.ExceptionInfo: Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: ["react-bootstrap-table2-editor" :default cellEditFactory] at line 1 file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs {:file #object[java.net.URL 0x1835b24b "file:/Users/rberger/omnyway/neo/lib/re-view/src/review/table.cljs"], :line 1, :column 1, :tag :cljs/analysis-error}
Or is my only painful alternative is to replace the very nice :default with :as and an alias?
#2021-06-1306:28thheller@rberger you can use the new official alternative ["react-bootstrap-table2-editor$default" :as cellEditFactory], see https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces#2021-06-1320:48rbergerIf I use the new official alternative, do I use the alias in the code just like it was the previous :default? I.e (cellEditFactory (clj->js {:mode "click"})) (without the /default)#2021-06-1320:52thhelleryes, thats what the $default does#2021-06-1320:53thhellerFWIW don't do this (cellEditFactory (clj->js {:mode "click"})). for really simple JS objects like that just use #js eg. (cellEditFactory #js {:mode "click"})#2021-06-1308:57juhoteperiI'm getting bunch of infer-warnings on shadow-cljs with Reagent (the project itself, not when using as library). Seems to be related to deftype and extending a protocol without any methods. Though IAtom doesn't cause these problems, any ideas?
(defprotocol IReactiveAtom)

(deftype IRatom [bar]
  IAtom
  IReactiveAtom
  )
------ WARNING #1 - :infer-warning ---------------------------------------------
 File: /home/juho/tmp/your-project/src/your_project/core.cljs:30:1
--------------------------------------------------------------------------------
  27 |
  28 | (defprotocol IReactiveAtom)
  29 |
  30 | (deftype Ratom [bar]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. IRatom -prototype) -your-project$core$IReactiveAtom$)
--------------------------------------------------------------------------------
  31 |   IAtom
  32 |   IReactiveAtom
  33 |   )
  34 |
--------------------------------------------------------------------------------
#2021-06-1308:59thhellermost likely a problem in CLJS directly? or does it not happen there?#2021-06-1309:00thhellerwould help if you try with cljs.main and (set! *warn-on-infer* true)#2021-06-1309:00juhoteperiNo, but I guess I need to check if I'm running warn-on-infer there.#2021-06-1309:00thhellerif that doesn't warn I can fix it. if not its happening somewhere in the CLJS parts of inference#2021-06-1309:06juhoteperiStrange, I get different warnings with cljs.main:
Compiling /home/juho/Source/reagent/src/reagent/ratom.cljs to target/bundle-adv/resources/public/js/out/reagent/ratom.js
WARNING: Cannot infer target type in expression (. c push derefed) at line 76 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. G__6105 push p2__6103#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. G__6105 push p3__6104#) at line 98 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. v -destroy) at line 328 /home/juho/Source/reagent/src/reagent/ratom.cljs
WARNING: Cannot infer target type in expression (. a push f) at line 495 /home/juho/Source/reagent/src/reagent/ratom.cljs
And shadow-cljs:
------ WARNING #1 - :infer-warning ---------------------------------------------
 File: /home/juho/Source/reagent/src/reagent/ratom.cljs:129:1
--------------------------------------------------------------------------------
 126 |
 127 | (defprotocol IReactiveAtom)
 128 |
 129 | (deftype RAtom [^:mutable state meta validator ^:mutable watches]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. RAtom -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
 130 |   ; IAtom
 131 |   IReactiveAtom
 132 |
 133 |   IEquiv
--------------------------------------------------------------------------------

------ WARNING #2 - :infer-warning ---------------------------------------------
 File: /home/juho/Source/reagent/src/reagent/ratom.cljs:208:1
--------------------------------------------------------------------------------
 205 |                 (set! (.-reaction obj) r))
 206 |               v))))
 207 |
 208 | (deftype Track [f args ^:mutable reaction]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. Track -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
 209 |   IReactiveAtom
 210 |
 211 |   IDeref
 212 |   (-deref [this]
--------------------------------------------------------------------------------

------ WARNING #3 - :infer-warning ---------------------------------------------
 File: /home/juho/Source/reagent/src/reagent/ratom.cljs:250:1
--------------------------------------------------------------------------------
 247 |
 248 | ;;; cursor
 249 |
 250 | (deftype RCursor [ratom path ^:mutable reaction
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. RCursor -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
 251 |                   ^:mutable state ^:mutable watches]
 252 |   IAtom
 253 |   IReactiveAtom
 254 |
--------------------------------------------------------------------------------

------ WARNING #4 - :infer-warning ---------------------------------------------
 File: /home/juho/Source/reagent/src/reagent/ratom.cljs:358:1
--------------------------------------------------------------------------------
 355 | ;; - state
 356 | ;; - watches
 357 | ;; - watching
 358 | (deftype Reaction [f ^:mutable state ^:mutable ^boolean dirty? ^boolean nocache?
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. Reaction -prototype) -reagent$ratom$IReactiveAtom$)
--------------------------------------------------------------------------------
 359 |                    ^:mutable watching ^:mutable watches ^:mutable auto-run
 360 |                    ^:mutable caught]
 361 |   IAtom
 362 |   IReactiveAtom
--------------------------------------------------------------------------------
#2021-06-1309:08thhellerthat is odd. thx for testing, I'll look into it#2021-06-1309:16juhoteperiMinimal project https://github.com/Deraen/shadow-cljs-infern-warning, npm run release shows the warning, build.sh doesn't#2021-06-1309:48thhellerfixed in https://github.com/thheller/shadow-cljs/commit/721f71dce7ca55bf9b3c5d80b38709e68270ef4a, released in 2.14.5#2021-06-1315:51eoliphanthello, i’ve a quick question. I’m trying to create a devcards macro that basically just wraps components with my react lib’s theme provider, and realized it presents a bit of a catch 22 as i need the symbol for the react component in the actual clj implementation. i know the general approach is to make sure you use fully qualified symbols (clojure.core/xxx). But since the ["mylib" :default/refer …] syntax is cljs/shadow specific, just wondering what (if any) equivalent there is.#2021-06-1315:54thhellercreate a helper function that does what you need. (defn foo-helper [a b] (that-npm-alias/do-stuff a b)). maybe even helps reducing the amount of code the macro generates.#2021-06-1315:57thhelleryou can also use cljs.analyzer/resolve-var to get the actual alias if helper function is not an option#2021-06-1315:59eoliphanta helper on the clj side? I tried something like that w/o creating the macro, for something like (defcard xxx (wrap-theme comp)) but I think the arg capture confuses things.#2021-06-1315:59eoliphantah#2021-06-1315:59eoliphantok, yeah will give resolve-var a try#2021-06-1315:59thhellerhelper on the cljs side#2021-06-1315:59eoliphantyeah, that’s what I did. no joy 😉#2021-06-1316:00thhellerwhat did you try? should be straightforward macro-wise? even just a function?#2021-06-1316:03eoliphantfor the helper i tried a couple things someting like:
(defn theme
   [x]
   [:> ThemeProvider 
     x])
as well as another variant that returned an fn
#2021-06-1316:03eoliphantbut i hadn’t gotten far on the macro, as I realized i wasn’t sure how to fully qualify ThemeProvider#2021-06-1316:04thheller(:name (cljs.analyzer/resolve-var &env the-sym))#2021-06-1316:04eoliphantfiring up my repl now 🙂#2021-06-1316:04thhellerbut that doesn't look like it should be a macro#2021-06-1316:05thheller(remember that you can't write macros in a CLJS repl)#2021-06-1316:05eoliphantyeah i didn’t think so, but for whatever reason it doesn’t seem to work. will try checking the macro expansion#2021-06-1316:06eoliphantah yeah i know, just meant to start playing with the analyzer#2021-06-1316:30agilecreativityHi, I keep getting shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running message when trying from Emacs cider-jackin-cljs#2021-06-1316:31agilecreativityWhat option do I miss? My .dir-locals.el looks like
((nil . ((cider-preferred-build-tool . shadow-cljs)
         (cider-default-cljs-repl . shadow)
         (cider-shadow-default-options . "app")
         (cider-shadow-watched-builds . ("app")))))
#2021-06-1316:31agilecreativityI am trying out the example project here https://github.com/shadow-cljs/quickstart-browser#2021-06-1316:32thhellereither you are loading the wrong javascript (often happens when people rename :modules or change :output-dir)#2021-06-1316:32thhelleror you might have 2 instances of shadow-cljs running competing with each other and conflicting#2021-06-1316:33agilecreativityThanks let me check#2021-06-1316:33thhellernote that jack-in from emacs starts a new fresh instance, so if you have shadow-cljs watch already running separately that would be your conflict#2021-06-1316:36agilecreativityI am sure I don’t have anything running as I list all of my open program and then kill off all node process just to make sure and I am still getting the error.#2021-06-1316:36agilecreativityAnd I kill off my Emacs instance as well just to be on the clean state for testing.#2021-06-1316:39agilecreativityI am trying the npx shadow-cljs watch app then cider-connect options to confirm#2021-06-1316:47thhellershadow-cljs is a java process. so killing the node process may not end up killing the java process#2021-06-1316:55agilecreativityI managed to fix it by reload the page. And the things seems to be connect properly now. Thanks again for your help.#2021-06-1411:24AronI need some general advice, if someone has it. I have found this https://github.com/thheller/reagent-react-native and trying to adapt it to a windows-wsl setup. I am not sure which part should be inside of WSL, has anyone done something similar that's available publicly? 🙂 I know I am asking for much, but from the answers it seems I might be better of just ditching windows for any project using react native with shadow-cljs.#2021-06-1411:45thhellerwhy would ditching windows be a factor? I mean I use windows so I know that all the commands work fine there. don't have a clue about react-native and wsl though#2021-06-1411:47thhellergiven that I made the reagent-react-native demo on windows I assume it works fine still 😉 IIRC I didn't use wsl though#2021-06-1411:59Aronwait, so everything inside windows? i have not yet tried that, using git with ssh was difficult last time#2021-06-1412:02Aronanyway, this is exactly the kind of information I needed, thanks#2021-06-1412:16thhellerI mean I use WSL1 still so I have all the files on my windows drive and access them using windows tools#2021-06-1412:16thhellerjust some command line stuff I run through WSL sometimes. shadow-cljs I mostly run directly in windows. RN too because of the emulator stuff#2021-06-1414:21Aronmakes total sense, I am just starting with react native (again, once I tried it several years ago), everything is new, I don't even know which bit goes where#2021-06-1416:09biscuitpantsis it possible to disable certain warnings being outputted to the console during dev builds? something like :ignore in :warnings-as-errors, but to disable output instead?#2021-06-1416:12thhelleryou are supposed to fix warnings not ignore them 😛#2021-06-1416:12biscuitpantshaha totally agree with you. its coming from an interned (no longer maintained) library, which is my reasoning#2021-06-1416:12biscuitpantsbut that's a totally fair stance#2021-06-1419:07ribeloI'm having some bizarre problem importing and using the npm package, which I haven't encountered before.
["date-fns-tz" :rename {format dtftz.format}]
...
(dtftz.format (js/Date.) "Europe/Berlin")
;;=>
module$node_modules$date_fns_tz$index is not defined
#2021-06-1419:09thhellerthis would be a lot more helpful if it was an actual reproducible snippet#2021-06-1419:09thhellerwhich shadow-cljs version? which :target?#2021-06-1419:11ribelothheller/shadow-cljs {:mvn/version "2.11.23"} :target :browser#2021-06-1419:16ribeloI upgraded the shadow-cljs version to the latest 2.14.5, but it doesn't change anything#2021-06-1419:19thhellerthen it should be easy to make a reproducible repo. can't say much else.#2021-06-1419:22thhellerFWIW you call looks wrong to begin with?#2021-06-1419:22thhellerconst output = format(zonedDate, pattern, { timeZone: 'Europe/Berlin' })#2021-06-1419:22thhellerthats not what you have?#2021-06-1419:23ribelosure, I will check one more thing and do repo right away#2021-06-1419:35ribeloon a clean project it works#2021-06-1419:35ribelowhich means I need to see what I have broken and where#2021-06-1419:37thhellersometimes just restarting shadow-cljs might help#2021-06-1419:37thhellerif you run npm install while shadow is running it sometimes gets confused#2021-06-1419:37thhellerdunno if you did that but restart is always a good check 😛#2021-06-1419:40ribeloI tried, also deleted the .shadow-cljs folder#2021-06-1419:41ribelobut what else I have noticed, which may give some guidance, in this particular project also importing via ["date-fns/format" :as format] also causes the same type of error#2021-06-1419:42ribelonot just import, but the later use of#2021-06-1419:44ribelothe fact that it is an electron should be rather irrelevant, shouldn't it?#2021-06-1419:46thhellernot really. that is very relevant. it is not a regular browser anymore#2021-06-1419:46ribeloargh#2021-06-1420:07ribelothis is not an electron issue either, because again on a relatively clean project it works#2021-06-1420:08thhellerI mean did you try this in actual code anywhere? maybe the REPL is not the best place to verify it#2021-06-1420:08thhellerdon't know any particulars about electron but I know they changed some security related things#2021-06-1420:08thhellermaybe they sandboxed some more. really don't know#2021-06-1420:09ribeloI'm trying something like (js-keys dtf-tz)to see if it even exists and what it has inside#2021-06-1420:10ribelonever mind, thanks for your time, if I figure it out, I'll share#2021-06-1420:11thhellerthat is checking the wrong thing if dtf-tz is undefined what module$node_modules$date_fns_tz$index is not defined basically means#2021-06-1420:11ribeloI don't really know what I'm checking, but I know that if it works, it spits out a list of functions, and on a clean project it works#2021-06-1420:11thhellerin the browser you can easily verify it it the console since it will even autocomplete once you start typing module$...#2021-06-1420:12ribelo
(js-keys dtf-tz);; => #js ["format" "getTimezoneOffset" "toDate" "utcToZonedTime" "zonedTimeToUtc"]
#2021-06-1420:12thhellerworks in the browser or works in electron?#2021-06-1420:13ribeloI created a clean repo and added electron#2021-06-1420:13ribeloand works as above#2021-06-1420:14ribeloit doesn't work in one particular project and I'm curious why and what I've messed up, especially as it has >1y and maybe I've misconfigured something somewhere#2021-06-1420:14thhellercould be a dependency version conflict in some npm package#2021-06-1420:16thhellerdid you restart shadow-cljs after updating it? and updated it in the correct place? I did fix a bug somewhat related to this not too long ago. definitely after 2.11.23#2021-06-1420:16thhelleror did you test with the 2.11.23 in the empty project?#2021-06-1420:17ribelono, 2.14.5#2021-06-1420:39ribeloI found it.#2021-06-1506:47thheller@huxley and what was it?#2021-06-1506:48ribeloI was working in a new file that was not yet required anywhere 😜#2021-06-1506:49ribeloand date-fns-tz has not been used anywhere else#2021-06-1506:50ribelothe main cause of problems usually sits in front of the monitor#2021-06-1506:53thhellerhmm well normally that shouldn't be a problem but I guess there is an issue with electron and eval then#2021-06-1506:54thheller(assuming you just load-file or require the file it should be fine)#2021-06-1507:53ribeloas I did a require in another ns which is used in the application and is compiled, then suddenly everything started to work everywhere and in every ns#2021-06-1508:04thhellerdo you have any custom :js-options or so in your build config? anything electron related?#2021-06-1508:04thhellernormally this should just work (and did in your and my tests)#2021-06-1513:12WestIs it possible to call a node script from cljs? If so, how do I configure my shadow-cljs.edn so that I can call it?#2021-06-1513:12thhellerwhat do you mean by "call a node script from cljs"?#2021-06-1513:13WestNevermind, I finally figured out the classpath business.
(ns app.data
  (:require [clojure.edn :as edn]
            [shadow.resource]
            ["/org_processor" :as org]
            ))
#2021-06-1513:14Westdeps.edn:
{:paths ["src" "scripts/js"]
...}
#2021-06-1513:14WestBut now I get a weird error.
[:app] Compiling ...
[:app] Build failure:
Closure compilation failed with 1 errors
--- org_processor.js:3
Parse error. '}' expected
#2021-06-1513:14thhellerah you mean using a JS file in your build. by "call a node script" I assuming you mean run node some-script.js or so 😛#2021-06-1513:15thhellerwhats weird about that error? seems to be invalid js?#2021-06-1513:15Westyeah, I want to use a node script as it interacts with my local filesystem, and shadow.resource just doesn’t suit my needs.#2021-06-1513:16WestThe error is weird because it’s output from a compiled cljs file.#2021-06-1513:16WestIt should be valid#2021-06-1513:16thhelleryou are not making much sense to me here#2021-06-1513:16thhellerits output from a compiled cljs file? what does that mean?#2021-06-1513:17thhellerplease describe what you are trying to do, if possible with actual example#2021-06-1513:17WestI’m trying to use a library that turns org-mode documents into html.#2021-06-1513:19WestHere’s my script.
(ns scripts.org-processor
  (:require ["unified" :as unified]
            ["rehype-stringify" :as html]
            ["uniorg-parse" :as uniorg]
            ["uniorg-rehype" :as rehype]
            ["uniorg-extract-keywords" :refer (extractKeywords)]
            [cljs-node-io.core :as io :refer [slurp spit file-seq]]
            ))

(def processor
  (->
   (unified)
   (.use uniorg)
   (.use extractKeywords)
   (.use rehype)
   (.use html)))

#_(def org-string "
#+title: Lorem Ipsum
#+subtitle: stuff test
#+date: 2021-04-15
#+tags: test
#+author: Christian Westrom
#+id: test-1

* Here's some stuff
  * Here's more stuff
  - more stuff")

(defn process-org
  [org]
  (.processSync processor org))

(defn org->html
  [org-string]
  (.-contents (process-org org-string)))

(defn org->data
  [org-string]
  (js->clj (.-data (process-org org-string))
  :keywordize-keys true))

(defn blog-post
  [org-string]
  {:content (org->html org-string)
   :data (org->data org-string)})

(defn ^:export all-posts
  [path]
  (js/console.log (map #(blog-post (slurp %)) (rest (file-seq path)))))
#2021-06-1513:19WestNow the function all-posts just outputs to the console for now, but I want to call it from my reagent site.#2021-06-1513:20thhellerok then requiring the file is that what you want here#2021-06-1513:20thhellerI'd recommend to have that script output files to a certain location#2021-06-1513:20thhellerand either loading those files dynamically via ajax at runtime#2021-06-1513:21thhelleror including then via shadow.resource#2021-06-1513:21thhellerI do NOT recommend trying to run that script as part of the compilation. that'll just end up with unnecessary avoidable problems all over the place#2021-06-1513:21WestLooks like I need ajax then lol Because there’s no equivalent to file-seq in shadow-resource.#2021-06-1513:22thhellerwell with a macro you could trivially write that yourself#2021-06-1513:22Westhow?#2021-06-1513:23thhellerI wouldn't recommend doing that though so you'll have to figure that out yourself 😉#2021-06-1513:23thhellerI mean you have the script to generate the stuff right there#2021-06-1513:23thhellerso you could have that generate a single EDN or JSON file and just shadow.resource that#2021-06-1513:24thhellerbut I would really recommend loading them dynamically#2021-06-1513:24thhellerunless you enjoy recompiling your entire code every time you make a change in the org mode files#2021-06-1513:25WestOk cool, any good libraries for doing ajax in clojurescript?#2021-06-1513:25thhellerif you don't care about really old browser then just use js/fetch#2021-06-1513:25West👍#2021-06-1513:25WestThanks a bunch!#2021-06-1609:33Franklinis it possible to do something like the following in shadow-cljs?
import './App.css';
#2021-06-1609:34thhellerno#2021-06-1609:35Franklinmmmh... I wonder if there are any constraints/reasons why?#2021-06-1609:37thhellerwell the constraint is that shadow-cljs knows how to build JS and CLJS files. adding support for CSS files would be a non-trivial amount of work.#2021-06-1609:37thhellerthe reason I haven't done it is because I don't think it is useful#2021-06-1609:38thhellerI usually have a secondary build system for my CSS anyways and I can just put the import there. I think its silly to use JS constructs for that.#2021-06-1609:39thhellerfor example you can use the setup described here#2021-06-1609:39thhellerhttps://github.com/jacekschae/shadow-cljs-tailwindcss#2021-06-1609:39thhellerand then either put your css in this file directly https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/src/css/tailwind.css or have that import the other files#2021-06-1609:40thhellerI know that it would be more convenient if shadow-cljs handled all that automatically but I currently don't have the time/energy to work on that#2021-06-1609:41Franklinalright#2021-06-1610:56Jakub Holý (HolyJak)Hello! I struggle with REPL-driven development with shadow. The problem is that when I define some troubleshooting / dev vars (such as (defn f [& args] (def *debug args) (...)) ), they tend to disappear. I suppose that is because I do most of my coding inside a (comment ...) and when IntelliJ saves the file after any changes, Shadow reloads the code. I thought that vars would survive that (as they do in clj) but it seems they do not, at least sometimes. Any tips? 🙏#2021-06-1611:09thhellerwell yeah hot-reload and REPL are sort of at odds with each other#2021-06-1611:09thhellerhot-reload is not additive so it'll remove definitions that you only defined in the REPL#2021-06-1611:10thhellerso one option is to disable the hot-reload and just use the REPL like you would in CLJ#2021-06-1611:10thhelleror you keep the hot-reload but accept that stuff sometimes gets undefined#2021-06-1611:10thhellertechnically it is all still there on the JS side, just the compiler doesn't know about it anymore#2021-06-1611:16thhellerthings aren't additive with hot-reload since I want warnings to show up ASAP. say I changed (defn foo []) to (defn bar []). I want to see warnings for all places still using foo ASAP. In Clojure I often only notice such things when I restart my process a couple hours/days later since foo will still be around and valid until then.#2021-06-1612:31raspasovNot sure if that’s relevant for you/shadow, but figwheel will actually refuse to load namespaces with warnings and namespaces that depend on them. That feels like a good default to me.#2021-06-1612:32thhellersame in shadow#2021-06-1612:32raspasovCool 👍#2021-06-1611:19thhellerI guess I could compromise somehow and track which def was defined from a REPL and keep those instead of resetting the entire ns#2021-06-1612:12Jakub Holý (HolyJak)Thanks a lot! Is there a quick way to switch hot-reload on/off?#2021-06-1612:13Jakub Holý (HolyJak)(I agree that being non-additive to show such warnings ASAP is in general the better choice. I just need to find out an effective way of doing experiments/troubleshooting in the REPL - which may be telling intellij not to save files automatically.)#2021-06-1612:24thhellerfrom the CLJ REPL you can call (shadow/watch-set-autobuild! :app false)#2021-06-1613:10ProctorHello.. I am relatively new to ShadowCLJS and using Clojure_Script_… and was wondering if you all might be able to point me in the general direction on JS libraries that use Node dependencies#2021-06-1613:12Proctorthere might be two issues going on: 1st - we are trying to use the Redlock library, and when we do as part of the require:
~   9             ["ioredis" :as Redis]
~  10             ["redlock" :as Redlock]
#2021-06-1613:12ProctorI get the following compilation error:
[:employee_record] Compiling ...
The required JS dependency "async_hooks" is not available, it was required by "node_modules/bluebird/js/release/util.js".

Dependency Trace:
        shadow/umd_helper.cljs
        user_auth_profile/employee_record/update.cljs
        user_auth_profile/system_config.cljs
        node_modules/redlock/redlock.js
        node_modules/bluebird/js/release/bluebird.js
        node_modules/bluebird/js/release/promise.js
        node_modules/bluebird/js/release/util.js

Searched for npm packages in:
        /Users/sproctor/guaranteed-rate/user-auth-profile/node_modules

See: 
#2021-06-1613:13ProctorThe part that is confusing is that async_hooks is part of NodeJS#2021-06-1613:14thhellerwhich :target is your build? when building for the browser the native node packages are not available#2021-06-1613:14Proctora :node-library#2021-06-1613:14Proctorwe are deploying to AWS Lambda#2021-06-1613:14thhellerdid you set :js-provider :shadow in your build config?#2021-06-1613:14Proctoryes#2021-06-1613:15Proctorhere is the build target:
:employee_record {:target :node-library
   43                             :exports {:update user-auth-profile.employee-record.update/-main}
   44                             :source-map false
   45                             :output-dir "target/employee-record"
   46                             :output-to "target/employee-record/lambda.js"
   47                             :compiler-options {:infer-externs :auto
   48                                                :externs ["externs/httpurr.js"]}
   49                             :js-options {:js-provider :shadow
   50                                          :keep-native-requires true}
~  51                             :release {:compiler-options {:optimizations :simple}}}
#2021-06-1613:15thhellerso you can either not do that at all or add :keep-as-require #{"async_hooks"}#2021-06-1613:17thhellernote that I do NOT recommend using :js-provider :shadow for node builds#2021-06-1613:17thhellerbetter to keep the default and post-process with https://github.com/vercel/ncc or so if you really need things to be standalone#2021-06-1613:20ProctorIs there some detail in the UserGuide that outlines this? Wondering if I have missed it, or mis-understood this#2021-06-1613:21thheller:js-provider :shadow is built and optimized for browser builds. that is works for node was due to some experimental changes and I decided this wasn't worth doing so didn't continue working on it.#2021-06-1613:22thhellerso you likely found out about it in the github issue about this in the first place? the docs don't mention it#2021-06-1613:22ProctorI have been trying to ramp up on ShadowCLJS as new projects at work are starting to use it over Figwheel for our AWS Lambda deployments#2021-06-1721:44rbergerI have a little playground example for getting cljs working with lambda. I think it still works https://github.com/omnyway-labs/lambda-play#2021-06-1721:49rbergerThis also looks interesting. Not (yet) supporting cljs but it makes it easy to use Java, GraalVM or Babashka for lambdas https://github.com/FieryCod/holy-lambda The biggest issue I found with using cljs in lambdas (or probably any standalone node style program) is you are trapped in single thread / Promise / Async hell that you don't really experience in a browser / reagent / re-frame app#2021-06-1613:22ProctorI saw some, but might have mis-understood what that issue was referring to#2021-06-1613:24thhellerI think its best to NOT post-process the files at all and just "deploy" your .js file together with the needed node_modules#2021-06-1613:24thhellerbut I don't use AWS lambda so I don't know the details of how deploys actually work#2021-06-1613:25ProctorI did see this item yesterday: https://github.com/thheller/shadow-cljs/issues/290#2021-06-1613:25Proctorgot lost in the other references around MongoDB, and some other side threads on it… 😉#2021-06-1613:26ProctorThank you for your help!!!#2021-06-1613:26Proctorneed to take this back to the larger team and understand how we want to proceed#2021-06-1613:26Proctorthanks again#2021-06-1618:38kiranshilaIs the story for having a library play nice with figwheel is to just provide the CLJSJS fallbacks? If so, how do I provide the equivalent :require calls?#2021-06-1620:17thhellerfor people using figwheel with :target :bundle :require is exactly identical and no CLJSJS is needed#2021-06-1620:18thhellerfor CLJSJS you need to setup that CLJSJS package and setup the proper :foreign-libs to emulate the :require#2021-06-1620:18thhellerin the code nothing changes#2021-06-1618:38kiranshilaAs much as I'd like to slap a "won't fix/use shadow" tag on the issue haha#2021-06-1619:52Jonathan@neo2551 did you ever figure out shadow-cljs with kamera?#2021-06-1619:53David PhamNot really. What I did figure out though was to use Clojure dev tools protocols used in kamera to navigate to the page and make the screenshot and then use these screenshot with kamera.#2021-06-1619:54David PhamSince I am using re-frame, I also had a list of events that cdp could use to go to the desired state.#2021-06-1619:58JonathanThanks 🙂 I'm in a similar situation#2021-06-1619:58Jonathan> use Clojure dev tools protocols used in kamera to navigate to the page Any chance you could elaborate on this?#2021-06-1620:30JonathanKamera library looks fairly hackable, gonna try forking it. Will post more if it works.#2021-06-1707:20Ertugrul Cetin@thheller regarding problem Illegal variable reference before declaration: i we talked about a few days ago. Someone suggested me to use different module type https://github.com/pmndrs/three-stdlib/issues/69#issuecomment-862871876 and I applied but getting another king of errors and does not work. Do you have anything to add here?#2021-06-1707:23thheller@ertucetin yes, don't do the resolve config. When you want to default to using esm code then use :js-options {:entry-keys ["module" "browser" "main"]}#2021-06-1712:46bbssso I tried the entry-keys as my comment there suggests, but that gave me other problems for some other packages. That resolve config actually fixed all issues for me. I was wondering if entry-keys is a bit too general, might not you want to use esm for some but not for other libraries, probably misunderstanding how it works..#2021-06-1712:49thhellerwell it all depends on what kind of packages you use. if you are mostly using commonjs packages then the above wouldn't help much. if you have some kind of bad mix things get complicated.#2021-06-1712:50thhellerin any case you should NEVER be using :target :file for npm packages#2021-06-1712:50bbssoh yeah, definitely on a mix of bad things! I'm happy I can keep it going with the more recent versions of these libaries.#2021-06-1712:50bbssoh, I'm not sure where I got that from..#2021-06-1712:51thhellerso
{"three-stdlib" {:target :npm :require "three-stdlib/index.js"}
 "@react-three/drei" {:target :npm :require "@react-three/drei/index.js"}
 "@react-three/fiber" {:target :npm :require "@react-three/fiber/dist/react-three-fiber.esm.js"}
 "@react-three/cannon" {:target :npm :require "@react-three/cannon/dist/index.js"}}
#2021-06-1712:52bbssI'll try that out.#2021-06-1713:09thhellerstill haven't had time to look at this at all so I don't know why its necessary in the first place. really shouldn't be. maybe I can take a look tomorrow#2021-06-2107:10Ertugrul Cetin@thheller @U09MR0T5Y thank you guys so much for the help! I found out how to make it work, I just used :js-options {:entry-keys ["module" "browser" "main"]} and added ["regenerator-runtime"] as a dep and everything works now https://github.com/ertugrulcetin/racing-game-cljs#2021-06-2107:21bbssThanks for letting me know. I still think it’s a bug on their side. But I don’t have time to dig into it more myself so good to know this worked for you, will probably try it myself at some point. React three fiber and the other libraries are so cool!#2021-06-1707:24thhellercan't look into this more now, gotta go#2021-06-1707:24Ertugrul Cetinyeah no problem, thanks!#2021-06-1711:17dawdlerIs there any obvious reason why two simple (sh "cp" "-r" "from" "to") statements are not executed (it appears) when using shadow-cljs clj-run my.ns/build-fn? Other functions used in build-fn work as expected.#2021-06-1712:48bbss@ertucetin the error you have now seems related to three-mesh-bvh which I don't use, perhaps you could also add a resolve config for that library.#2021-06-1712:48thheller@dawdler I susppose checking the return value :out and :err would tell you?#2021-06-1712:52dawdler@thheller bah, thanks. worked in repl, which is why I was confused.#2021-06-1718:27sova-soars-the-soraHi I want to use [cljsjs/date-fns "2.20.2-1"] in shadow-cljs... how can I include this dependency ?#2021-06-1718:27sova-soars-the-sorawell my end-goal need is a lib i can use to make a calendar app. if that helps / short circuits this need#2021-06-1718:32sova-soars-the-soraIf a library exists in NPM such as "date-fns" do I still need to include it in the :dependencies [[]] key in shadow-cljs.edn?#2021-06-1718:36sova-soars-the-soranpm install date-fns did the trick i think.#2021-06-2012:33Aronthis react native thing is difficult to set up#2021-06-2015:04WestOk, so I’m trying to wrap my head around how aliases and builds work within shadow-cljs. When I run the command shadow-cljs watch [buildname] I spin up a repl and everything, but it also seems to load the dependencies I specify. It seems like it’s no different that if I ran shadow-cljs -A:test:dev watch test.
{...
 :aliases {:dev  {:extra-deps {thheller/shadow-cljs          {:mvn/version "2.14.5"}
                               refactor-nrepl/refactor-nrepl {:mvn/version "2.5.1"}}}
           :test {:extra-paths ["test"]}}}
I have two aliases. In shadow-cljs.edn I’m referring to two aliases. Does this mean I have the option of using these aliases before running shadow? Or does it load all aliases regardless? I usually spin up a node-repl as opposed to loading a build.
{:deps {:aliases [:dev :test]}...

 :builds {:script ...
          :test   ...}}
My expectation was that within each build I could have it point to an alias in deps.edn but there’s no documentation to suggest that’s possible, neither have I found any examples on github.
#2021-06-2015:16thhellerthat is a deps.edn question. not really a shadow-cljs question.#2021-06-2015:16thhellerI mean you can just use deps.edn directly if you want#2021-06-2015:17thhelleror configure those aliases. the alias are always loaded yes, it is not supported to specify aliases per build#2021-06-2015:18thhellerbut if you can clj -A:test -M -m shadow.cljs.devtools.cli compile test or whatever if you must have an alias per build
#2021-06-2015:18thhellerbut .. having extra unused dependencies on your classpath does NOT affect your build in any way#2021-06-2015:18thhellerso just always load all of them#2021-06-2015:18WestOk, I thought they would affect build size.#2021-06-2015:19thhellerthey don't. only namespaces you actually :require are compiled. so having test on the classpath always doesn't matter since you never require your tests in your regular buidl anyways#2021-06-2015:19WestOk, good to know.#2021-06-2015:19thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2021-06-2015:21thhellerso really all this deps.edn alias tinkering isn't required for shadow. you can do it if you really want to but you don't have to#2021-06-2015:25WestYou really do have some good build tools.#2021-06-2023:59Drew VerleeThe reloading process (e.g ^:dev/after-load) seems to happen such that my browser defaults (e.g css grid overlay div selected) always get reset. I would like them not to get reset. I'm trying to understand why they are. Currently my mental model is that the page is refreshing. Edit. It's not refreshing, i meant re-rendering, which yes, i'm telling it to do. I dont think i can get that gird selection to stay.#2021-06-2104:21awb99NPM dependency "@icon/fontisto-emoji" has installed version "3.0.4-alpha.0" "^3.0.4-alpha.0" was required by jar:file:/home/andreas/.m2/repository/org/pinkgorilla/webly/0.3.8/webly-0.3.8.jar!/deps.cljs#2021-06-2104:22awb99For this npm dependency shadow watch brings me this warning, which it should not. I guess it is the strange version format?#2021-06-2106:57thheller@drewverlee the :dev/after-load is just a function that shadow-cljs calls. what it does is up to you, so I guess you'll have to figure out what resets them since that is your code doing it?#2021-06-2106:57thhellerthe page is not refreshing. https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2021-06-2106:59thheller@hoertlehner yeah the version compare code is fairly limited. I'll very likely remove it completely at some point. maybe turn it into a separate helper function.#2021-06-2208:21Aronanyone actively uses react native with shadow cljs?#2021-06-2214:47souenzzoi developed an #fulcro app targeting react native since before #shadow-cljs support react-native (~2019). I used npm-module target and things work pretty well Even things like hot reload works in some how Now I already ported most of the things to react-native target and etc I'm just sharing that things in cljs/shadow are pretty stable and you can trust them 🙂 I still think that in 2019 I had the better/fastest code-reload/dev-experience available in react-native world. And the setup to share code between native and web is WAY simpler than anything with webpack#2021-06-2214:59Aronyeah, react in 2017 was faster than /cdn-cgi/l/email-protection is now#2021-06-2208:38Aronnever mind, it just started working on its own. dark magic#2021-06-2208:47Arontook me more than a week from first cloning the react-native repo with shadow config 😄#2021-06-2209:12thhellerdid you not follow https://github.com/thheller/reagent-react-native?#2021-06-2209:57Aronit's difficult to follow something which starts from assumptions that I am ignorant about 🙂#2021-06-2210:04AronThat was the repo I was specifically mentioning. I tried to do those steps, and it took me over a week to get to the place where everything connects. For two days the build was working but for some reason the websocket had issues. That was the last thing, and that was the only thing that fixed itself. It requires an emulator or usb, which i haven't tested. took me a bunch of days just to be able to run the emulator, I had to disable wsl2 which contained all my working environment. Then, wherever should I get react-native binary in my PATH? I ended up using npx, so that's a diversion already, I have zero idea what you had set up. Then, for some reason, it requires create-react-class, I had to install that manually, there was no way around it. It's not part of your repo anywhere 🙂 To be clear, I am still 100% amazed that it works and it's all as promised and I am very grateful for everything.#2021-06-2215:37jamescroftHi there. I’m using :module-hash-names true and when I do a release build I get the fingerprinted file. However, if I then remove the .shadow-cljs folder and do another release build I get a file which has a different fingerprint even though there have been no code or dependency changes. It appears that the munged variable names are different. Q: is this expected? I assumed that the build process would produce identical output given identical input, but maybe that’s not the case?#2021-06-2216:53thhellerno, builds are not 100% deterministic. by deleting .shadow-cljs you are basically destroying the reproducible part 😉#2021-06-2218:17jamescroft@thheller ok, thanks for confirming. Our builds are done on CI and we are not sharing the ‘.shadow-cljs’ between build machines. We were confused as to why our fingerprints change with every build even if there are no cljs code changes.#2021-06-2218:24v3gaCan someone tell me what I'm missing here? I've added clojurescript/shadow-cljs to my project and when I go to my default index page I do get indication that it's picking up on shadow-cljs in the lower left corner. However as far as detecting any functions I write in core.cljs or even my cljs repl it's a no go. Not sure what else I'm missing or where I goof'd https://github.com/v3gal0g/chrysalis-xd#2021-06-2218:40thheller@decim "However as far as detecting any functions" what does that mean? what are you doing exactly?#2021-06-2218:52v3ga@thheller say I even try (js/alert “foo”) it doesn’t pick up on it. It looks like it should be reading my app.js file but it doesn’t appear so. I’m not quite sure, after tinkering for a few hours.#2021-06-2218:53thhellerI need more information#2021-06-2218:53thhellerWHERE do you type that?#2021-06-2218:53thhellerwhat commands did you run?#2021-06-2218:56thheller> It looks like it should be reading my app.js file but it doesn’t appear so#2021-06-2218:56thhellerwhat do you mean by "It"? shadow-cljs generates the resource/public/js/app.js yes. it does not generate any HTML, so loading that file is up to you?#2021-06-2219:00WestSo I tried following the instructions for using karma to test my code. Unfortunately my code is a node script and karma is a browser test suite, not designed for node. All I really want is some XML output so I can see the results in circleci. I don’t even know how to get more detailed tests, is there a verbose option? All I get is this when I run my test.
========= Running Tests =======================

Testing uniorg-util.cli-test

Testing uniorg-util.core-test

Ran 8 tests containing 31 assertions.
0 failures, 0 errors.
===============================================
#2021-06-2219:17thhellerso I assume you found :node-test?#2021-06-2219:17thheller> All I really want is some XML output so I can see the results in circlec#2021-06-2219:18thhellernot sure what you mean by that#2021-06-2219:18thhellershadow has no built-in "xml output" for tests if thats what you are asking#2021-06-2219:22WestI see, so I would need to configure another test runner that supports junit style xml results?#2021-06-2219:24thhelleryeah you can configure custom runners with :node-test. in case those exist 😛#2021-06-2220:17WestSo I managed to find https://github.com/lambdaisland/kaocha-junit-xml. I’m currently trying to see if I can get https://github.com/lambdaisland/kaocha-cljs2 working.#2021-06-2219:33v3gaGenerally people throw an index.html in resources/public/ as I did. Don’t worry about it I’ll figure it out, I’m sure it’s a beginners error. If not I’m familiar with figwheel. #2021-06-2219:39thheller@decim and WHERE did you type (js/alert "foo")? there is a difference here to figwheel. you need either a connection from your editor or shadow-cljs cljs-repl app in addition to shadow-cljs watch app first#2021-06-2219:40thhellerso REPL is a separate process from the watch#2021-06-2219:45v3gaBoth using shadow-cljs repl and from emacs evaluating it in (core.cljs) with ‘npx shadow-cljs watch app’ running. Also I apologize if I came off as rude. I’m not slighting your project by any means. The issue is on my end. #2021-06-2219:46thheller@decim I'm trying to help you but I don't have a clue what you are doing so I'm asking what you are doing. you are only giving me small pieces of information that don't really tell me what you are doing.#2021-06-2220:01gravHey! Whenever I make a change in my cljs.user, and Shadow-cljs hot-reloads it, and I then try executing something in the repl, I get the following exception:
------ REPL Error while processing ---------------------------------------------
foo
no source by provide: cljs.user
{:provide cljs.user}
ExceptionInfo: no source by provide: cljs.user
	shadow.build.data/get-source-id-by-provide (data.clj:186)
.....
Only seems to be the case for cljs.user
#2021-06-2220:06thheller@grav which version are you on? that should have been fixed for a while now?#2021-06-2220:08grav@thheller Latest: 2.14.5#2021-06-2220:08gravHere's more info:
[2021-06-22 22:07:23.472 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "foo", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form foo, :source "foo", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:501)
        shadow.cljs.repl/process-read-result (repl.clj:475)
        shadow.cljs.repl/process-input (repl.clj:659)
        shadow.cljs.repl/process-input (repl.clj:637)
#2021-06-2220:10gravI'm using :deps {:aliases [:cljs]}, and then I have :paths ["src" "dev"] in my deps.edn, and cljs.user is in dev/cljs/user.cljs#2021-06-2220:11thhellerwould help if you can setup a reproducible repo#2021-06-2220:11gravAlright - I'll see if I can do that :thumbsup: Is there a work-around for now, can I eg avoid having shadow hot-reload cljs.user#2021-06-2220:13thhelleryou can have (ns cljs.user {:dev/once true} ...) meta to only load it once. not sure that fixes anything#2021-06-2220:16gravDoesn't seem to unfortunately.#2021-06-2220:23gravTried to use :repl-init-ns with another namespace - same problem with that namespace. Anyway, I'll create a repro.#2021-06-2220:46grav@thheller There you go: https://github.com/grav/shadow-cljs-user-issue 🙂 Will also create an issue#2021-06-2220:50gravCreated issue here: https://github.com/thheller/shadow-cljs/issues/905 Thanks for looking into it 🙂#2021-06-2221:19v3gaHa I got it! In shadow-cljs.edn…. :modules {:app … changed that to main and pulled main.js in index.html and now we have lift off. #2021-06-2309:10Michaël SalihiHi, I never had the case so far. How to import a js module outside "node_modules" via its relative path like
import { Ziggy } from './ziggy.js';
#2021-06-2309:11Michaël SalihiI'll tried :require ["./ziggy.js" :refer [Ziggy]]#2021-06-2309:12Michaël SalihiI'm asking here and not on #clojurescript because I think Shadow-cljs offers more possibilities for imports, right?#2021-06-2309:25Michaël SalihiThat all right, it works. I also found the :js-options :resolve who seems perfect to avoid complected relative paths. 👍#2021-06-2310:03thheller@admin055 do not use :resolve. if you have the file on the classpath (which you should) just use either the relative path or the full path (:require ["/some/file.js"]) following classpath rules#2021-06-2312:04Michaël SalihiOK thanks for the advice and confirmation. Another question, I tried to import/require this lib ziggy-js but without success: https://github.com/tighten/ziggy/blob/main/src/js/index.js#L3#2021-06-2312:06Michaël SalihiI have already tried what I usually do, i.e.
["ziggy-js" :refer [route]]

or

["ziggy-js" :default route]
#2021-06-2312:07Michaël SalihiBut it doesn't works. Any clue?#2021-06-2312:17thhellermight be ["ziggy-js" :as route]#2021-06-2312:17thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2021-06-2312:35Michaël SalihiYep it works. 👍 The part with the REPL workflow to debug the imports is very interesting and useful. Thx#2021-06-2315:02martinklepschI’m trying to get Cypress working with some shadow-cljs builds but keep getting this error:
Cannot use import statement outside a module
Tried release and watch builds, both unsuccessful
#2021-06-2317:36thhellerdon't know what cypress is. where do you get this error? shadow doesn't generate import statements anywhere. unless you are using :target :esm?#2021-06-2315:57erwinrooijakkersIs it possible to import raw .jsx files? When I import as such:
["./surveyjs/widgets/RatingWidget.jsx" :refer [RatingWidget]]
I get: > cannot identify as cljs resource
#2021-06-2316:04erwinrooijakkersah i think it needs to be preprocessed (https://shadow-cljs.github.io/docs/UsersGuide.html)#2021-06-2318:28erwinrooijakkersThat worked :thumbsup:#2021-06-2318:28erwinrooijakkersnpx babel *.jsx --out-dir gen#2021-06-2318:50Robert PofukHi! I have javascript hosted on different URL from application it self and it works ok for main module. When I have multiple modules then they are loaded from relative path to index.html. This problem I notices on mobile when packaging using cordova, main.js comes from https://example.com/main.js but then my module is loaded from http://127.0.0.1/module.js. Can I somehow adjust URLS for modules?#2021-06-2318:57thheller:asset-path controls that#2021-06-2408:31erwinrooijakkersI have a JSX component that returns a React component:
import React from "react";
import Select from "react-select";
import Survey from "survey-react";

const CustomSearchWidget = ({ choices, onChange }) => {
...
  return (
    <Select
      ...
    />
  );
};

export const SearchWidget = {
  ...
  render: (question) => {
    return (
      <CustomSearchWidget
        ...
      />
    );
  },
};
When I compile this using babel with npx babel *.jsx --out-dir gen and import this compiled file in a clojurescript file like so:
["./surveyjs/widgets/gen/SearchWidget.js" :refer [SearchWidget]]
and use the SearchWidget in the application I get this error:
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
If I return <div/> instead of <Select/> this error does not occur
#2021-06-2409:05erwinrooijakkersFull code:
import React from "react";
import Select from "react-select";
import Survey from "survey-react";

const CustomSearchWidget = ({ choices, onChange }) => {
  const handleChange = (option) => {
    onChange(option.value);
  };

  const options = choices.map((choice) => {
    return { label: choice, value: choice };
  });

  return (
    <Select
      className="basic-single"
      classNamePrefix="select"
      isClearable={true}
      isSearchable={true}
      name="color"
      options={options}
      onChange={handleChange}
    />
  );
};

export const SearchWidget = {
  name: "search dropdown",
  title: "Dropdown with search",
  isFit: function (question) {
    return question.getType() === "searchdropdown";
  },
  activatedByChanged: function (activatedBy) {
    Survey.JsonObject.metaData.addClass("searchdropdown", [], null, "text");
    Survey.JsonObject.metaData.addProperties("searchdropdown", [
      { name: "choices", default: ["Click Me"] },
    ]);
  },
  render: (question) => {
    return (
      <CustomSearchWidget
        choices={question.choices}
        placeholder={question.title}
        onChange={(val) => (question.value = val)}
      />
    );
  },
};
#2021-06-2409:18erwinrooijakkers(And it goes wrong when importing like so):
(ns nl.mediquest.questionnaire-frontend.component.survey
  (:require
   ["./surveyjs/widgets/gen/SearchWidget.js" :refer [SearchWidget]]
   [survey-react :refer [Survey StylesManager CustomWidgetCollection]]))

(.. CustomWidgetCollection -Instance (addCustomWidget SearchWidget "customtype"))
#2021-06-2409:18erwinrooijakkerspackage.json
{
  "devDependencies": {
    "@babel/cli": "^7.14.5",
    "@babel/core": "^7.14.6",
    "@babel/plugin-transform-react-jsx": "^7.14.5",
    "shadow-cljs": "2.10.12"
  },
  "dependencies": {
    "@fortawesome/fontawesome-pro": "^5.13.0",
    "@fullhuman/postcss-purgecss": "^2.0.5",
    "autoprefixer": "9.8.0",
    "global": "^4.4.0",
    "postcss-cli": "7.1.1",
    "postcss-import": "^12.0.1",
    "react": "^16.13.0",
    "react-dom": "16.13.0",
    "react-select": "^4.3.1",
    "recharts": "1.8.5",
    "survey-react": "^1.8.4",
    "tailwindcss": "1.4.6"
  },
  "scripts": {
    "build-css": "node_modules/postcss-cli/bin/postcss resources/public/css/tailwind.css -o resources/public/style.css"
  }
#2021-06-2409:30erwinrooijakkersit is something with the Select component, because when I turn it into <div/> the webpage renders and there are no errors#2021-06-2408:31erwinrooijakkersIs there a workaround for this?#2021-06-2408:45thheller@erwinrooijakkers you ... out a bunch of code so I cannot see what this SearchWidget actually is. from what you left in it is not a correct react component and that is what the error is telling you?#2021-06-2408:45thhellermaybe you just forgot a export const SearchWidget = class extends React.Component {?#2021-06-2409:05erwinrooijakkersThank you. I added the full code in the reply#2021-06-2409:08erwinrooijakkersexport const SearchWidget = class extends React.Component { gives babel compilation error:
Unexpected token (28:6)

  26 |
  27 | export const SearchWidget =  class extends React.Component {
> 28 |   name: "search dropdown",
     |       ^
#2021-06-2409:09erwinrooijakkerswith npx babel *.jsx --out-dir gen#2021-06-2409:16erwinrooijakkersthese are functional components I understand from the party that helped made them, so cannot add a class extends React.Component, although they say in the end it’s the same#2021-06-2409:37thhelleras the error is telling you an object is not a valid react component#2021-06-2409:37thhellerso whatever it is it is invalid. it has nothing to do with shadow-cljs, it is purely a react error#2021-06-2409:38thhellermaybe its meant to be a React.createClass({ name: ...})#2021-06-2409:46erwinrooijakkersI fixed it by changing:
import Select from "react-select";
to
const Select = require('react-select');
#2021-06-2409:49erwinrooijakkersvia https://github.com/facebook/react/issues/13445#issuecomment-595470399#2021-06-2409:46erwinrooijakkersthe same code did work in javascript for some reason#2021-06-2409:46erwinrooijakkersin the create-react-app#2021-06-2409:46erwinrooijakkersanyway#2021-06-2409:46erwinrooijakkersthanks for the help!#2021-06-2410:58Alex J HendersonI'm using shadow-cljs, with the helix library. I'm noticing that a tagged js literal such as #js [] when placed anywhere within the form of a call to react/useState, breaks the hooks state preservation on hot reload. For example test-state is preserved if I make a code change with this component:
(defnc test-component []
  (let [[test-state set-test-state] (react/useState (do [] 1))]
    ($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
but if I tag the array inside the do form with a #JS like the following, the state of test-state is not preserved if I make a code change:
(defnc test-component []
  (let [[test-state set-test-state] (react/useState (do #js [] 1))]
    ($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
maybe this is not a shadow-cljs issue, but any help would be much appreciated, thanks!
#2021-06-2411:43thhellerwhy is there a do in the first place?#2021-06-2412:45Alex J Hendersonsimply to demonstrate that it's some sort of reader issue. The empty array never even reaches react/useState only the '1' does.#2021-06-2412:48thhellermaybe helix does some stuff in a macro. I don't really know how hot-reload works with hooks. I would assume useState is always lost, just like local state is normally lost. given that component type changes it should go through a full unmount/mount cycle#2021-06-2412:50Alex J Hendersonthe weird thing is it seems to be related to the tagged literal. If I write
(defnc test-component []
  (let [a #js []
        [test-state set-test-state] (react/useState (do a 1))]
    ($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
it works fine
#2021-06-2412:52Alex J HendersonAnd this works fine also
(defnc test-component []
  (let [[test-state set-test-state] (react/useState (do (array) 1))]
    ($ "button" {:on-click #(set-test-state inc)} (str "test1: " test-state))))
that's what makes me think it's either clojurescript or shadow
#2021-06-2412:52thhellerreally need to ask in the #helix channel. I don't have a clue what defnc does internally#2021-06-2412:52Alex J Hendersonok thanks very much 🙂#2021-06-2412:54thhellerjust a glance at the macro code makes me pretty certain that it is the macro#2021-06-2412:54thhellerhttps://github.com/lilactown/helix/blob/master/src/helix/core.clj#L170#2021-06-2412:54thhellernot shadow or cljs#2021-06-2412:55Alex J Hendersonah brilliant, that's very helpful, I guess it's analysing the code for calls to react hooks and something about the tagged literal is tripping it up, cheers#2021-06-2411:43thhellerbut yeah not a shadow-cljs issue. that is either helix or react, don't know#2021-06-2411:44Aronhelik 😄#2021-06-2619:35theeternalpulseTrying to follow the fulcro developer guide from scratch.  have all the basic deps and shadow config, startup script and html setup but when I run `npx shadow-cljs server` I get the following error
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
I copied the configs so not sure what's missing. my deps.edn
{:paths   ["src/main" "resources"]
 :deps    {org.clojure/clojure    {:mvn/version "1.10.1"}
           com.fulcrologic/fulcro {:mvn/version "3.5.0-RC3"}
           #_[ com.fulcrologic/fulcro {:mvn/version "3.4.22"}]}

 :aliases {:dev {:extra-paths ["src/dev"]

                 :extra-deps  {org.clojure/clojurescript {:mvn/version "1.10.866"}
                               thheller/shadow-cljs      {:mvn/version "2.14.5"}
                               binaryage/devtools        {:mvn/version "1.0.3"}}}}}
my shadow-cljs.edn
{:deps     {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds   {:main {:target     :browser
                   :output-dir "resources/public/js/main"
                   :asset-path "/js/main"
                   :modules    {:main {:init-fn mindjoin.client/init
                                       :entries [mindjoin.client]}}
                   :devtools   {:after-load mindjoin.client/refresh
                                :preloads   [com.fulcrologic.fulcro.inspect.preload]}}}}
#2021-06-2619:55theeternalpulseI saw an issue where this might come up because a version mismatch, but both this and in package.json are using shadow-cljs 2.14.5#2021-06-2620:00theeternalpulsethe unspecified aliases looks suspicious, when I clear my .m2 repository and try to run the server again, i get tha alias error before it grabs the deps, and shadow is not a part of it. Is it not connecting the deps.edn with the shadow config?#2021-06-2620:01theeternalpulse
[fulcroapp] npx shadow-cljs -v server                                                                                                    master  ✭
shadow-cljs - config: /home/deepe/projects/clojure/fulcroapp/shadow-cljs.edn
shadow-cljs - starting via "clojure"
WARNING: Specified aliases are undeclared: [:-A]
Downloading: org/clojure/clojure/1.10.1/clojure-1.10.1.pom from 
....(oteher deps)
#2021-06-2620:32thheller@theeternalpulse can you try 2.14.4 of the npm package? the version in deps.edn can stay#2021-06-2620:37theeternalpulsejust did that, still no dice. I was able to get it working by doing clj -A:dev to get it to put those jars in the classpath and then re-run it. Seems like something is not passing in the deps.edn alias : dev#2021-06-2620:40thheller@theeternalpulse I tried with the exact examples you pasted. just copied them into the files and it works fine#2021-06-2620:41thhellerwhich clj -version do you use? maybe thats too old?#2021-06-2620:42theeternalpulsemaybe, it doesn't have the -version option, I thought of upgrading that,#2021-06-2620:43theeternalpulselet me do that and try again#2021-06-2620:47thheller$ clj -version Clojure CLI version 1.10.3.855#2021-06-2620:47theeternalpulseI'm on ubuntu and this is what I get
[fulcroapp] clj -version                                                                                                              
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-version (No such file or directory)
#2021-06-2620:48thhellerclj --version?#2021-06-2620:48thhellerclj -Sdescribe?#2021-06-2620:48theeternalpulsehmm, let me try removing completely#2021-06-2620:49theeternalpulseseems there's a different one than I installed with apt#2021-06-2620:49thhellerguess its some old version if it doesn't have -version#2021-06-2620:49theeternalpulseI think I may have installed it differently#2021-06-2620:49theeternalpulseusing -Sdescribe gives me version "1.10.1.478" but that might just be from my deps?#2021-06-2620:51thhellerno clue. I don't use deps.edn much. maybe try upgrading#2021-06-2620:58theeternalpulsethat did it, thanks for the second pair of eyes, I've been using plain old shadow-cljs for so long I didn't think that maybe clj tools were out of date#2021-06-2620:58theeternalpulseI was just following the tutorial, I find the integration of deps a bit confusing so I'll unwind that later#2021-06-2708:09xcenoHey thanks for figuring that out guys, that was my error as well!#2021-06-2710:07javiIn the `:bootstrap` target, is there any way to add extra data-readers for custom tagged literals?#2021-06-2807:55thhellercan you explain what you mean? I don't really understand the question?#2021-06-2807:56thhellerI mean what is specific about :bootstrap? you are controlling the compiler in the host-build, so you'd set them?#2021-06-2810:47javisorry, just saw this, i had notifications off. followed your advice in the clojurescript thread and it worked. #2021-06-2718:37Pavel KlavíkHi, we have recently encountered the following problem on multiple computers while modifying source files and saving them:
[:client] Build failure:
ExecutionException: java.io.FileNotFoundException: C:\Shared\orgpad\resources\public\js\compiled\cljs-runtime\orgpad.client.effects.core.js.map (The requested operation cannot be performed on a file with a user-mapped section open)
        java.util.concurrent.FutureTask.report (:-1)
        java.util.concurrent.FutureTask.get (:-1)
        clojure.core/deref-future (core.clj:2304)
        clojure.core/deref (core.clj:2324)
        clojure.core/deref (core.clj:2310)
        clojure.core/run!/fn--8813 (core.clj:7717)
        clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
        clojure.core/reduce (core.clj:6829)
        clojure.core/run! (core.clj:7712)
        clojure.core/run! (core.clj:7712)
        shadow.build.async/wait-for-pending-tasks!/fn--10176 (async.clj:25)
        clojure.lang.Atom.swap (Atom.java:37)
        clojure.core/swap! (core.clj:2356)
        clojure.core/swap! (core.clj:2349)
        shadow.build.async/wait-for-pending-tasks! (async.clj:23)
        shadow.build.async/wait-for-pending-tasks! (async.clj:19)
        shadow.build/flush (build.clj:476)
        shadow.build/flush (build.clj:467)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:531)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:486)
        shadow.cljs.devtools.server.util/server-thread/fn--14066/fn--14067/fn--14075 (util.clj:284)
        shadow.cljs.devtools.server.util/server-thread/fn--14066/fn--14067 (util.clj:283)
        shadow.cljs.devtools.server.util/server-thread/fn--14066 (util.clj:256)
        java.lang.Thread.run (:-1)
Caused by:
FileNotFoundException: C:\Shared\orgpad\resources\public\js\compiled\cljs-runtime\orgpad.client.effects.core.js.map (The requested operation cannot be performed on a file with a user-mapped section open)
        java.io.FileOutputStream.open0 (:-2)
        java.io.FileOutputStream.open (:-1)
        java.io.FileOutputStream.<init> (:-1)
         (io.clj:230)
         (io.clj:230)
         (io.clj:69)
         (io.clj:166)
         (io.clj:166)
         (io.clj:69)
         (io.clj:119)
         (io.clj:104)
        clojure.core/apply (core.clj:669)
        clojure.core/spit (core.clj:6956)
        clojure.core/spit (core.clj:6956)
        shadow.build.output/generate-source-map-regular (output.clj:208)
        shadow.build.output/generate-source-map-regular (output.clj:173)
        shadow.build.output/generate-source-map (output.clj:222)
        shadow.build.output/generate-source-map (output.clj:212)
        shadow.build.output/flush-source/fn--10254 (output.clj:249)
        shadow.build.output/flush-source (output.clj:245)
        shadow.build.output/flush-source (output.clj:224)
        shadow.build.output/flush-sources/fn--10274 (output.clj:257)
        shadow.build.async/queue-task/fn--10171 (async.clj:15)
        clojure.core/apply (core.clj:667)
        clojure.core/with-bindings* (core.clj:1977)
        clojure.core/with-bindings* (core.clj:1977)
        clojure.core/apply (core.clj:671)
        clojure.core/bound-fn*/fn--5767 (core.clj:2007)
        java.util.concurrent.FutureTask.run (:-1)
        java.util.concurrent.ThreadPoolExecutor.runWorker (:-1)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (:-1)
        java.lang.Thread.run (:-1)
This can be fixed by kiling the process running on port 7000 which is nREPL for our development server. Is this something caused by Shadow-cljs or source maps handled by Chrome? I am running :loader-mode :eval in the Shadow-cljs config.
#2021-06-2719:08Pavel KlavíkOk, so basically killing our development server and restarting it again will fix the issue, since it is not serving these files anymore and the tab in Chrome closes.#2021-06-2719:31thheller> The requested operation cannot be performed on a file with a user-mapped section open #2021-06-2719:32thhellerdon't know what that means. shadow-cljs is trying to write the source maps but can't because of that#2021-06-2719:32thhellerwhat causes it I don't know. is this some network shared folder or so maybe? might be another process working on that directory or disk?#2021-06-2719:34thhellermaybe you have two shadow-cljs instances running and both trying to write source maps at the same time?#2021-06-2720:09Pavel KlavíkNo network folder.#2021-06-2720:09Pavel KlavíkNo two instances.#2021-06-2722:35Pavel KlavíkI will try to debug this further when it happens again, for instance to see whether turning Chrome will fix it. It is rather strange.#2021-06-2801:48russellIs there a good way to start the shadow-cljs server with configuration specified programmatically? i.e. with a function which returns data of the same shape as shadow-cljs.edn, without such a file being consulted? Context is that I want to manipulate the relative filesystem paths (the node_modules and the outputs) to interoperate with a build process, while keeping the "normal" paths for use from the repl. So various other things such as middlewares or alternative paths to load the config from, would also help me out. thanks!#2021-06-2804:41awb99stupid question: shadow-cljs has many graal dependencies. why is this so?#2021-06-2805:55thheller@russell I don't understand what you are trying to do. everything is built around shadow-cljs.edn so many things expect it. things will still function without it but you'll lose features. do you have an example config you'd like to generate compared to a normal one?#2021-06-2805:56thheller@hoertlehner jdk15 removed the nashorn js engine. the graal-js engine is used instead now.#2021-06-2805:58thheller@pavel.klavik chrome never touches your filesystem directly. it'll load the file over http so it is more likely to be that server. pretty much impossible to be chrome. if its anything it is an OS level issue. so either multiple processes trying to write to the filesystem, or that FS otherwise locking or so. or maybe two separate builds writing to the same :output-dir (at the same time again)?#2021-06-2917:34Pavel KlavíkMakes sense. We are serving the resource directory (containing compiled output from Shadow-cljs) using the standard ring.middleware.resource via ring.middleware.defaults. Can this be blocking the file resource?#2021-06-2918:58thhellerit might. not sure. does the issue appear when that server is not running?#2021-07-0121:04Pavel KlavíkNot sure, haven't happened since the last time. I will do further debugging when I discover it again. Thanks for tips.#2021-06-2806:27awb99thanks @thheller this is for node deployments? or for what is it used?#2021-06-2806:35thhellernot for node no. one tiny script uses it to compare npm versions since I couldn't find an implementation in java/clojure#2021-06-2806:36thhellerI'll very likely completely remove that at some point though. just can't be bothered to implement it myself.#2021-06-2906:21awb99crazy that there are no semver tools for clojure. To bring a huge tail of graal dependencies just to check semver is indeed crazy. But on the other hand I do like the log entries about npm versions.#2021-06-2907:00thhellerwell "huge tail of graal" is a bit extreme? I do not consider this "huge"?
[org.graalvm.js/js-scriptengine "21.1.0"]
 [org.graalvm.js/js "21.1.0"]
   [com.ibm.icu/icu4j "68.2"]
   [org.graalvm.regex/regex "21.1.0"]
   [org.graalvm.sdk/graal-sdk "21.1.0"]
   [org.graalvm.truffle/truffle-api "21.1.0"]
#2021-06-2907:01thhellerbut I had other plans with the JS engine initially#2021-06-2907:01thhellerbut I'll probably stick with node, so ultimately the graal stuff might be going away. just didn't have time to work on it yet#2021-06-3005:12awb99this dependencies bring a lot of other dependencies. but it is not oly that, it is also the fact that graal stuff is not very stable in terms of the library ecosystems, so when clojure world has coflicts, then it is related to the graal libraries.#2021-06-3005:18thhellerI always suggest keeping CLJS dependencies separate from CLJ for that reason. I never had a single problem with dependencies that way. If you choose to combine them it is your problem dealing with the conflicts 😛#2021-06-3005:23awb99yes, but I am delivering shadow as part of my project, because my users need to be able to compile stuff on the fly.#2021-06-3005:25thhellerI said this many times before. shadow-cljs is NOT designed to be embedded in other systems and should NOT be used as such. it is designed as a standalone tool, so embedded concerns don't have a high priority right now#2021-06-3005:29thhellerbut I'm not much a fan of the graal stuff either, just had to do it quickly to stay compatible with jdk15+ without loosing features#2021-06-3005:29thhellerbut I'm ok with loosing this particular feature at some point. or rebuilding it on top of node#2021-06-3005:59awb99I switched to deps.edn away from lein for thst reason. now with deps.edn it works pretty stable.#2021-06-2806:37thhellerhttps://github.com/thheller/shadow-cljs/blob/ea54e4b943c762645178303778aef094387f1a85/src/main/shadow/cljs/devtools/server/npm_deps.clj#L19#2021-06-2814:04Gleb PosobinIs there a way to make the "compilation failed" notice not take up the whole screen? I am working on an extension and when I make a mistake in the content script, every tab shows this notice and it blocks off all the contents on the pages.#2021-06-2815:35murtaza52hi, is there a verbose option when starting a build with shadow-cljs ?#2021-06-2815:37lispers-anonymousthere is a --verbose flag mentioned in the documentation#2021-06-2818:45thhellerThe web UI is verbose by default, otherwise shadow-cljs watch app --verbose#2021-06-3007:10murtaza52thanks guys#2021-06-2917:34Pavel KlavíkMakes sense. We are serving the resource directory (containing compiled output from Shadow-cljs) using the standard ring.middleware.resource via ring.middleware.defaults. Can this be blocking the file resource?#2021-06-2903:47Adam KaliszWith the new ClojureScript 1.10.866 and shadow-cljs 2.14.5 combined with reagent-utils 0.3.4 I have a problem, where my release builds don't set cookies with correct options such as Expires, Secure or SameSite. Any ideas @thheller how to debug this further? https://github.com/reagent-project/reagent-utils/issues/19#2021-06-2904:24Adam KaliszIt looks like we will get there. reagent-utils depends on API changes present in the latest GCL in respect to setting SameSite on cookies and I had a mixup of dependencies - basically my release builds were using a different (older) GCL than the testing it seems.#2021-06-2905:01Adam KaliszOk, so the GCL that shadow-cljs depends on is too old and the newer one from May 2021 doesn't seem to work.#2021-06-2906:53thhellerI'd probably just use the GCL code directly without the reagent-utils#2021-06-2906:53thhellerlooks like something in the GCL code changed. it is now a separate namespace apparently#2021-06-2906:54thhellerhttps://github.com/google/closure-library/blob/master/closure/goog/net/cookies_deprecated.js#2021-06-2906:54thhellergoog.net.cookies is what reagent-utils uses but it is now goog.net.Cookies I guess?#2021-06-2906:55thhellerbut as far as I know SameSite must be set by the server?#2021-06-2913:42Adam KaliszIt makes usually more sense to set it in a server response but I don't think it is a requirement.#2021-06-2906:55thhellerit really doesn't matter if you set it on the client? or does it? not sure#2021-06-2907:02thhellerhttps://github.com/google/closure-library/blob/master/closure/goog/net/cookies.js#L167-L229 I'd just port this to clojure and be done with it 😛#2021-06-2912:24Adam KaliszYes, perhaps this is the easiest way out. One less dependency also#2021-06-2920:48rgmI’m trying to make a little Reagent app that sits in a Wordpress site. The site has already loaded react in its <head> so I don’t want shadow to prepend it to my release JS. If possible, it’d be great if shadow just assumes it’s there. Can anyone point me to the instructions for doing this? I’m having some trouble finding them. (Also, I’m using Reagent 1.1.0 which I believe removed the react dependency).#2021-06-3004:29sova-soars-the-sorai suspect that is not gonna work unfortunately... but i could be wrong#2021-06-3004:31sova-soars-the-sorathe V8 closure compiler ought to do very furious dead-code elimination, so a release build ought to be fairly minimal. will the compilation step in shadow-cljs work without knowing what [the heck] react is? 自信ない (not confident about that)#2021-06-3004:31sova-soars-the-sorai'm a newb tho so 😅#2021-07-0214:28rgmYeah, but the google closure compiler isn’t going to do dead-code elimination on a foreign lib, unless something’s changed recently. My recollection is that shadow just adds the minified react JS as a prefix to the whole bundle, because what else can it do with code that’s not closure-compatible. I did figure it out though: if I leave React out of the package.json, and provide stub cljs namespaces to link the cljs symbols to the names React hangs off of the global js/React, it seems all’s well and I get a shadow bundle leaning on the React that Wordpress has already provided on js/window. See https://gist.github.com/rgm/9ebc632a19074dea1a69955336fd3c8c#2021-07-0214:28rgm(or more specifically https://gist.github.com/rgm/9ebc632a19074dea1a69955336fd3c8c#file-react-cljs-L6-L13 for the stubs)#2021-07-0219:44thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-global#2021-07-0220:52rgmoh, well that’s a lot simpler. Thanks!#2021-07-0214:28rgmYeah, but the google closure compiler isn’t going to do dead-code elimination on a foreign lib, unless something’s changed recently. My recollection is that shadow just adds the minified react JS as a prefix to the whole bundle, because what else can it do with code that’s not closure-compatible. I did figure it out though: if I leave React out of the package.json, and provide stub cljs namespaces to link the cljs symbols to the names React hangs off of the global js/React, it seems all’s well and I get a shadow bundle leaning on the React that Wordpress has already provided on js/window. See https://gist.github.com/rgm/9ebc632a19074dea1a69955336fd3c8c#2021-06-3005:05awb99I found an artice on modules with react. Are there any other explainations available? I would like to use something similar, but I dont want to go to react level, but stay on reagent. Is there a way how to interact with the shadow module loader? Can I trigger module load myself and get a callback when it is loaded? Also, I am not totally sure how to move enough code to the modules. I guess that I have to make sure that there are not too many entry calls to each module, as otherwise I dont know when to load it? does this work only with ui functions or all functions? I guess I have to make sure that each module does only have calls of its own functions, a otherwise all namespaces would be grouped together into the main module? what happens with common utility functions? they all would always go to main module.#2021-06-3005:07awb99A second related question is, if I can post-process the bundle-size report of shadow someway? To me the logicall grouping many times does not represent to what I consider a common cost factor. So I would like to consolidate multiple such namspaces to one line.#2021-06-3005:09awb99And a last question: I have many goog namespaces on internationalization and date/time and calendars. Can I find out how they end up in my bundel? I cannot exactly tell how big they are, but inspecting the bundel visually, this is a lot of static data.#2021-06-3005:20thheller@hoertlehner you kinda have to go to the react level for the loader stuff. https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2021-06-3005:20thhellerthere is only like 2 lines react specific code so I don't see a problem with that#2021-06-3005:21thhellerthe bundle report is not customizable no. it is meant to show overall size and easily identifiable "outliers" size-wise (eg. cljs.pprint)#2021-06-3005:22thhellerbut all the data it collects is available so if you want to dig into it feel free to write your own output format and visualizations#2021-06-3005:22thhellerif you are on a new enough shadow-cljs version you can just mouse over the namespaces to see what required them#2021-06-3005:23thhellerlike in this report https://code.thheller.com/demos/build-report/ui-report.html#2021-06-3005:26awb99thanks @thheller I just looked at the new report - I LOVE IT!!!!!!!!!!!!!!!!!! AMAZING! so useful!! thaaaankkkks#2021-06-3016:43zendevil.ethI started the shadow repl with cider-jack-in and also started the watch with (shadow/watch :app), however, I’m getting this in the browser: Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running?#2021-06-3016:43zendevil.ethAlthough when I save something, the js does get compiled, according to the message in the shadow repl#2021-06-3019:33thheller@ps this is commonly caused by either having 2 instances of shadow-cljs for the same project running. or just changing paths but not updating them in the HTML and thus loading old files.#2021-06-3020:09zendevil.eth@thheller It occurs even after restarting my machine and rerunning the shadow REPL, and I have also changed no paths.#2021-06-3021:01zendevil.ethIt solved itself automatically#2021-06-3020:43Mitul Shahhi has anyone here set up tailwind JIT for their repo? i’m having some trouble i have this weird bug which is best explained through this video: https://www.loom.com/share/31e47c4cd28f487d8340dc99b952a62b If I open port 8080, the updated styles don’t seem to apply on hot reload If I open port 8081, the styles work fine and then if I go back to 8080, it also works fine. worth noting, we have a local firebase http server running on 8080 hence why we have 2 ports#2021-06-3021:56sova-soars-the-soraHmmm... very curious#2021-07-0103:01sova-soars-the-soraI think we need more info about your build environment... shadowcljs is hosting a server on 8080 presumably... what is hosting the server on 8081? You mention Firebase is also hosting something on 8080...#2021-07-0103:02Mitul Shah8081 is just shadowcljs without firebase connection#2021-07-0103:26Aronseeing the config would help a lot#2021-07-0106:28thheller@U023KKYKZNE I can't see your build config anywhere but if you are NOT using :dev-http then you need to configure :devtools {:watch-dir "foo/bar"}#2021-07-0106:30thhellerthe built-in :dev-http logs all requests and automatically figures out which css files to watch. so when it knows about the paths once (by visiting 8080) it'll then also work for 8081. :watch-dir should fix it so it works without visiting 8080 first#2021-07-0106:30thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2021-07-0620:25Mitul Shahno luck with this sadly 😞 but thank u#2021-07-0620:27Mitul Shahnot 100% sure what my build config is but i assume this – nothing there#2021-07-0620:50thhelleryour build config is the config you have in shadow-cljs.edn :builds#2021-07-0620:57Mitul Shah#2021-07-0620:58Mitul Shahi added the watch-dir even tired targeting actual file but nothing#2021-07-0621:05thhellerbecause your :watch-dir likely needs to be "resources/public"#2021-07-0621:06Mitul Shahlooks like it works!!!! thank you so much why didn’t /css work?#2021-07-0621:08thhellersee https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-07-1323:05sova-soars-the-soraOh, so if the :`watch-dir` is set to resources/public/css the browser location localhost:8080/css/hax.css will actually ask for public/css/css/hax.css is that right?#2021-07-1405:20thhelleryes, should be resources/public. always the "root" + the full path used in the browser#2021-07-0119:20kennytiltonTrying to build the plain version https://github.com/thheller/reagent-react-native I get
While resolving: 
I love node so much. Any suggestions? I was not crazy about using the -force option. Thx!
#2021-07-0119:26thhellerhow did you get that? what did you run?#2021-07-0119:31kennytiltonI cloned the repo ^^^...ugh, forgot to rename AwesomeProject. n.m!#2021-07-0119:33thhellerthere is no AwesomeProject in that repo?#2021-07-0119:49kennytiltonWell, I started by just cloning the repo and issuing the first instruction and got: $ npm install && cd react-native && npm install npm WARN deprecated /cdn-cgi/l/email-protection: The added 93 packages, and audited 94 packages in 4s 3 packages are looking for funding run npm fund for details found 0 vulnerabilities npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: /cdn-cgi/l/email-protection npm ERR! Found: /cdn-cgi/l/email-protection npm ERR! node_modules/react npm ERR! /cdn-cgi/l/email-protection"16.12.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer /cdn-cgi/l/email-protection"16.9.0" from /cdn-cgi/l/email-protection npm ERR! node_modules/react-native npm ERR! /cdn-cgi/l/email-protection"0.61.5" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See /Users/kennethtilton/paho.mqtt.javascript/.npm/eresolve-report.txt for a full report. npm ERR! A complete log of this run can be found in: npm ERR! /Users/kennethtilton/paho.mqtt.javascript/.npm/logs/2021-07-01T1945_29_923Z-debug.log Then I saw a note about how the the directory react-native got created and thought that was sth I should have done. So forget that. What about this npm madness? Can I just hack a json somewhere? I googled the error but quickly got depressed. 🙂#2021-07-0119:50thhellerhmm let me check. never seen that error before.#2021-07-0119:51kennytiltonThx! Gotta run, will check back in a couple. I am on Mac M1, fwiw#2021-07-0119:51thhellerhmm I get that error as well. not a clue, never seen it before#2021-07-0119:53thhellernpm install --legacy-peer-deps seems to do it. I guess something in npm change in how they handle dependency conflicts#2021-07-0119:53thhellerbut the react-native folder in that repo is ancient at this point. so probably best to recreate it#2021-07-0122:21kennytiltonThx for the quick response. That legacy hack did the trick, but now the run-android flops on no emulator and I cannot get emulator to run an emulator. run-ios does not work either. I'll try your other versions....#2021-07-0206:42thhellerseriously try an upgrade first. this is javascript after all. 2 years is like ancient history. do not bother trying to rescue that old version.#2021-07-0207:56kennytiltonUgh, forgot to report that I did recreate react-native. I also have a recent Android Studio and have worked thru pure JS tutorials with emulators successfully, and also got an emulator up OK using https://github.com/PEZ/rn-rf-shadow, FWIW. But I am looking for a bare CLJS+RN "hello world" so I can apply my Matrix reactive library to come up with a new CLJS+RN framework. I thought your "plain" example sounded the "barest", but I can start from sth heftier. Mind you, the Android Studio emulator CLI cannot bring up an emulator either. The emulator CLI says "cannot find emulator executable". I get a kick out of that. 🙂 I'll soldier on. Thx again for the quick and great support. I am saving that "legacy" incantation!#2021-07-0913:10emak@U0PUGPSFR if it can help I re-created the react-native folder, it is now on master https://github.com/thheller/reagent-react-native About your emulator issue. What does which emulator returns?
🠶 which emulator
/home/emak/Android/Sdk/emulator/emulator

🠶 emulator -list-avds           
Pixel_2_API_29

;; Try to open the emulator before running `react-native run-android`
🠶 emulator -avd Pixel_2_API_29 &
#2021-07-0913:48kennytiltonThx! 🙏
$ which emulator
/Users/kennethtilton/Library/Android/sdk/emulator/emulator
~/inonit/cantavi/songpark-platform/mqtt [dev] $ emulator -v
emulator: Android emulator version 30.3.5.0 (build_id 7036990) (CL:N/A)
emulator: ERROR: No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'
I think the problem may be on my end: emulators Android and IOS worked OK originally, but somewhere along the line I broke Android, leaving aside CLJS altogether. For now I am plowing ahead on iOS, making good headway with the https://github.com/PEZ/rn-rf-shadow project. Might have MatrixRN "hello world" by Monday. Thx for pitching in!
#2021-07-0120:46hadilsHi! I am trying to use shadow-cljs in a docker container as part of a Buddy CI pipeline. I don’t know how to build the classpath from my deps.edn file under the dev alias. It works as expected on my local machine (Intellij idea) but it complains about a missing dependency when I try to run it in a Docker container. Any suggestions?#2021-07-0206:41thheller@hadilsabbagh18 can you provide more details? I cannot tell what you actual problem is#2021-07-0206:48thheller> I don’t know how to build the classpath from my deps.edn file under the dev alias#2021-07-0206:48thhellerclj -A:dev?#2021-07-0210:53Alex J HendersonI'm trying to keep a npx shadow-cljs server process running so I can more quickly start and stop watching builds as I switch between git branches in my project. But when I switch branches npx shadow-cljs watch app no longer detects the running server process. Is there a file somewhere or something that I need to keep around which watch app looks for to detect the server?#2021-07-0219:43thhellerdoes switching the branches wipe the .shadow-cljs dir? the detection is based on a file in that dir? otherwise it should be detected fine?#2021-07-0211:58Mikko HarjuJust discovered the possibility to have Javascript files alongside CLJS – a very nifty thing to say the least. I'm now intrigued is it possible to trigger "re-compilation" (re-evaluation?) of JS files if I should change the definitions within the JS files, or do I always have to restart node-repl?#2021-07-0215:06Björn EbbinghausI have a problem with compiling the new material-ui v5 beta, and I have no idea how to tackle this. shadow-cljs fails to load a file. Reason:
TypeError: _system.keyframes is not a function
 at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple (TouchRipple.js:64)
The related JS Code looks like this:
// file -- @material-ui/core/node/ButtonBase/TouchRipple.js
var _system = require("@material-ui/system");
const pulsateKeyframe = (0, _system.keyframes)`... stuff ...`

// file -- @material-ui/styled-engine/index.d.ts
export { ThemeContext, keyframes, css } from '@emotion/react';

// file -- @material-ui/system/index.js
Object.defineProperty(exports, "keyframes", {
  enumerable: true,
  get: function () {
    return _styledEngine.keyframes;
  }
});
I deleted old js output and the .shadow-cljs folder beforehand. (That usually fixes stuff like this. 🙂) Disclaimer: I have no idea of JS or TS modules or shadow-cljs works. Sorry, if I am at the wrong place to ask.
#2021-07-0215:07Björn Ebbinghaus
// file -- package.json
// Relevant dependencies:
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^5.0.0-beta.0",
#2021-07-0219:44thhellerthis is caused by a dependency conflict#2021-07-0219:45thhellercan't remember which one exactly but somewhere there is a dependency conflict on some lib#2021-07-0302:24lucian303i'm seeing:
app.js:1552 TypeError: module.keyframes is not a function
    at Object.shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple 
with various material ui versions including beta.0 (see my post). i wonder if it's a similar issue. i get it just upgrading shadow/cljs but can't seem to resolve it
#2021-07-0315:37Björn Ebbinghaus@U053KNT7C Seems like it is. @U05224H0W Do you have a tip on how to debug this?#2021-07-0318:08lucian303i'm not sure what is happening exactly. i've tried various combinations of dependencies, cljs, shadow, closure compiler, etc. but haven't been able to get any results. i will try a few other versions to see if it makes a difference. it could be an mui issue as originally i was just trying to add in a dependency for the x-grid component that led to similar errors, but then saw that deps have to be updated#2021-07-0320:08Björn Ebbinghaus@U09MR0T5Y The Slack Archive hints to you having this problem back in March. Were you able to find a solution?#2021-07-0402:38bbssOof, had to look it up to refresh my memory but I'm afraid I didn't get very far in finding the right package versions.. I'm still on v4.#2021-07-0422:22lucian303fwiw, i got arttuka/reagent-material-ui "5.0.0-alpha.29-0" working with cljs 1.10.773 and shadow 2.11.24. Beyond that shadow version, it stopped working (not sure why). would be nice to be able to upgrade and add other packages, but i too am running out of ideas of how to debug such issues#2021-07-0505:05thhellerwouldp help if you setup a reproducible repo. I really don't have enough to go on here.#2021-07-0616:56lucian303i'll try to set one up#2021-07-0802:34lucian303ok, here it is @U05224H0W... https://github.com/unifiedcompliance/cljs-test this is the whole front end (which will be open source soon anyway). i stripped out the backend except a minimal pedestal server to serve / and other unnecessary stuff, left the working front end, did the initial commit, upgraded shadow and cljs (and pinned the tools.reader to a version so it could compile at all) and now it's a sea of errors compared to the initial commit. in the past, i also tried to pin versions of
com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library
                               org.clojure/google-closure-library-third-party 
tried upgrading reagent/mui/other deps at the same time in virtually all combos i could think of, etc. but i cannot get rid of these errors and cannot get the front end working again
#2021-07-0805:45thhellersorry but I don't look at projects using lein-shadow. and there is way too much stuff I can't comb through. there should be no docker or anything of that sort to reproduce either.#2021-07-0805:56thhellerFWIW this is not a thing you do in shadow :mylo-app-production. it is the same build as :mylo-app and you can just use that. :preloads don't apply to release to in effect the config is identical.#2021-07-0812:39Björn Ebbinghaus@U05224H0W I created a reproduction repo as well. https://github.com/MrEbbinghaus/mui5-shadow-cljs-issue-repro Steps in the README.#2021-07-0817:09thhellersorry I can't figure this one out either. FWIW I'd probably stay away from beta packages like that one#2021-07-0817:09thhellerit just might be the dependency conflict I mentioned#2021-07-0817:09thhellernpm package "hoist-non-react-statics" expected version "/cdn-cgi/l/email-protection^16.7.0" but "17.0.2" is installed. npm package "prop-types" expected version "/cdn-cgi/l/email-protection^16.8.1" but "17.0.2" is installed.#2021-07-0817:09thhellerthat is the warnings shadow gives you for that#2021-07-0817:10thhellerand yarn also gives you plenty of warnings on install#2021-07-0817:10thhellermaybe try using webpack instead as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-07-0817:11thhellerIt might be relying on something specific webpack does that shadow does not#2021-07-0822:12lucian303i'll create a shadow only version that's more stripped down. you won't need the dockerfile, i don't know why i even left it in there. it might take me awhile though#2021-07-0906:18thheller@U053KNT7C the repro Björn Ebbinghaus created works fine to reproduce the problem. don't need another one.#2021-07-2702:39lucian303@U05224H0W i've updated my project to use shadow-cljs.edn directly and i've been able to narrow down where the error starts to occur. when i upgrade the shadow-cljs version from 2.12.7 -> 2.13.0 or above, I get a bunch of errors and it seems unable to load and run the app or its components. i've also noticed the same thing with @U4VT24ZM3's demo app above. when i change the shadow version to 2.12.7, there is no more error in the console. when i go to 2.13.0, there's an error. i'm not sure if this helps narrow down the issue or not. it's possible the issue is with cljs or some other component that shadow depends on that also changes at that version. here's the diff for the demo repo that makes it work:
diff --git a/deps.edn b/deps.edn
index b072947..71a16bf 100644
--- a/deps.edn
+++ b/deps.edn
@@ -5,6 +5,5 @@
  :aliases {;; See  for Emacs support
            :dev {:extra-paths ["src/test" "src/dev" "src/workspaces"]
                  :jvm-opts ["-XX:-OmitStackTraceInFastThrow"]
-                 :extra-deps {org.clojure/clojurescript {:mvn/version "1.10.866"}
-                              thheller/shadow-cljs {:mvn/version "2.14.6"}
+                 :extra-deps {                              thheller/shadow-cljs {:mvn/version "2.12.7"}
                               binaryage/devtools {:mvn/version "1.0.3"}}}}}
diff --git a/package.json b/package.json
index 9351cae..4aab757 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,6 @@
         "react-dom": "^17.0.2"
     },
     "devDependencies": {
-        "shadow-cljs": "^2.14.6"
+        "shadow-cljs": "2.12.7"
     }
 }
 
#2021-07-2703:26thhellerhmm interesting. the only change in 2.13 was setting default :output-feature-set :es6. not sure why this would break anything but you can easily set the previous default by setting :compiler-options {:output-feature-set :es5} in your build config#2021-07-2708:20Björn EbbinghausCan confirm ES5 working fine. Not a single warning/error.#2021-07-2711:09Björn Ebbinghaus@U05224H0W So. The problem isn't a deps issue after all?#2021-07-2716:36thhellernot a clue. when I tested this the keyframes thing existed but yet it failed complaining that it didn't exist. couldn't figure it out.#2021-07-2910:56Björn Ebbinghaus@U05224H0W @U053KNT7C @U01ENMKTW0J had the same problem and solved it: https://github.com/MrEbbinghaus/mui5-shadow-cljs-issue-repro/issues/1 7 days ago and I didn't get a notification. 😅 Adding :js-options {:entry-keys ["module" "browser" "main"]} to the shadow-cljs config resolves this.#2021-07-3015:27Björn Ebbinghaus@U05224H0W Setting :js-options {:entry-keys ["module" "browser" "main"]} leads to other functions not found.
; my-lib/card.cljc
(def content (log/spy :info (interop/react-factory #?(:cljs CardContent :clj nil)))) 

; my-app/some-ns.cljs requireing [my-lib/card :as card]
(log/spy :info CardContent)
(log/spy :info (interop/react-factory CardContent))
(log/spy :info card/content)
Prints this:
(interop/react-factory CardContent) => fn [props & children]
CardContent => {$$typeof: Symbol(react.forward_ref), propTypes: {…}, render: ƒ}
(interop/react-factory CardContent) => fn [props & children]
card/content => undefined
Any idea, how to circumvent this?
#2021-07-3015:29thhellerwell if you use module it'll require following what the modules actually export#2021-07-3015:29thhellerso commonjs didn't have the concept of default exports but ES modules do#2021-07-3015:30thhellerso likely your require changed from :as Thing to :default Thing. depends on what the libraries do, see the translation table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-07-3015:31thhelleresm <-> commonjs interop can be a little annoying#2021-07-3100:08lucian303the :js-options solution above does seem to work for the most part and i was able to upgrade shadow, mui, and react, but i've ran into other issues w/ a couple of the packages, @material-ui/data-grid and @material-ui/x-grid. they are basically the same library, w/ x grid having extra features. on the older version (4.0.0-alpha.21) which works w/ the old 2.12.7 shadow and older mui, i get this after the build completes, but the rest of the app works:
app.js:1551 An error occurred when loading neo.common.components.data_grid.js
env.evalLoad @ app.js:1551
(anonymous) @ app.js:2507
app.js:1552 TypeError: (0 , p.makeStyles) is not a function
    at Object.shadow$provide.module$node_modules$$material_ui$x_grid$dist$index_esm (index-esm.js:2424)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at eval (neo.common.components.data_grid.js:2)
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:486)
    at Object.env.evalLoad (app.js:1549)
    at app.js:2507
but on versions i think above 4.0.0-alpha.23 or so, i get exceptions during the build itself, either of the below two. i also get this w/ the old shadow version 2.12.7.
[:mylo-app] Build failure:
babel failed?
{:file "/Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js"}
ExceptionInfo: babel failed?
	shadow.build.babel/convert-source/fn--11641 (babel.clj:164)
	shadow.build.babel/convert-source (babel.clj:156)
	shadow.build.babel/convert-source (babel.clj:152)
	shadow.build.resolve/make-babel-source-fn/fn--11715 (resolve.clj:202)
	shadow.build.data/get-source-code (data.clj:319)
	shadow.build.data/get-source-code (data.clj:306)
	shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313/fn--11314 (closure.clj:1809)
	shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313 (closure.clj:1808)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.RT.seq (RT.java:535)
	clojure.core/seq--5419 (core.clj:139)
	clojure.core.protocols/seq-reduce (protocols.clj:24)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
	clojure.core/reduce (core.clj:6830)
	clojure.core/into (core.clj:6897)
	clojure.core/into (core.clj:6889)
	shadow.build.closure/convert-sources-simple* (closure.clj:1837)
	shadow.build.closure/convert-sources-simple* (closure.clj:1804)
	shadow.build.closure/convert-sources-simple (closure.clj:2098)
	shadow.build.closure/convert-sources-simple (closure.clj:2050)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
	shadow.build.compiler/compile-all (compiler.clj:1440)
	shadow.build.compiler/compile-all (compiler.clj:1307)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:442)
	shadow.build/compile (build.clj:432)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:439)
	shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:428)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068/fn--14076 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--14067 (util.clj:256)
	java.lang.Thread.run (Thread.java:834)
or (this was huge so i snipped out the middle which seems to be a bunch of dumped js):
Browserslist: caniuse-lite is outdated. Please run next command `npm update`
/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:7429
!0,Ei.Xa="cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers117711",Ei.Gb=function(b){return Rb(b,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers117711")};return new Ei(a,je)}function Gi(a){try{var b=a[0];return b.a?b.a(a):b.call(null,a)}catch(c){if(c instanceof Object)throw b=c,a[6].rb(null),b;throw c;}}function Hi(a,b){b=zi(b,Fi(function(c){a[2]=c;a[1]=4;return Gi(a)}));return H(b)?(a[2]=Cb(b),a[1]=4,mh):null}
                                                                                                                                                                                                                                                                                                                    ^

Error: /Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js: Unknown property: L
    at matchProperty (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:15854:8)
    at handleLoneUnicodePropertyNameOrValue (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32136:19)
    at getUnicodePropertyEscapeSet (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32145:9)
    at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32276:5)
    at /Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32323:12
    at Array.map (<anonymous>)
    at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32322:26)
    at /Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32323:12
    at Array.map (<anonymous>)
    at processTerm (/Users/lucian303/Desktop/neo/.shadow-cljs/babel-worker/babel-worker.js:32322:26) {
  code: 'BABEL_TRANSFORM_ERROR'
}
[2021-07-30 16:51:35.396 - WARNING] :shadow.build.babel/babel-transform-ex - {:code "import{LicenseInfo as e,useLicenseVerifier as t}from\"@material-ui/x-license\";export{LicenseInfo}from\"@material-ui/x-license\";import*as r from\"react\";import n from\"react\";import{capitalize as l,ownerDocument as o,useEventCallback as a,createSvgIcon as i,unstable_useId as s,useForkRef as c,ownerWindow as u,debounce as d}from\"@material-ui/core/utils\";import p from\"clsx\";import m from\"@material-ui/core/InputBase\";import*as f from\"@material-ui/core/styles\";import{useTheme as g,lighten as b,darken as h}from\"@mater	

RuntimeException EOF while reading
	clojure.lang.Util.runtimeException (Util.java:221)
	clojure.lang.LispReader.read (LispReader.java:268)
	clojure.lang.LispReader.read (LispReader.java:216)
	clojure.lang.LispReader.read (LispReader.java:210)
	clojure.core/read (core.clj:3754)
	clojure.core/read (core.clj:3729)
	clojure.core/read (core.clj:3729)
	clojure.core/read (core.clj:3729)
	shadow.build.babel/babel-transform! (babel.clj:107)
	shadow.build.babel/babel-transform! (babel.clj:93)
	shadow.build.babel/babel-loop (babel.clj:126)
	shadow.build.babel/babel-loop (babel.clj:123)
[:mylo-app] Build failure:
babel failed?
{:file "/Users/lucian303/Desktop/neo/node_modules/@material-ui/x-grid/dist/index-esm.js"}
ExceptionInfo: babel failed?
	shadow.build.babel/convert-source/fn--11641 (babel.clj:164)
	shadow.build.babel/convert-source (babel.clj:156)
	shadow.build.babel/convert-source (babel.clj:152)
	shadow.build.resolve/make-babel-source-fn/fn--11715 (resolve.clj:202)
	shadow.build.data/get-source-code (data.clj:319)
	shadow.build.data/get-source-code (data.clj:306)
	shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313/fn--11314 (closure.clj:1809)
	shadow.build.closure/convert-sources-simple*/iter--11308--11312/fn--11313 (closure.clj:1808)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
	clojure.core/chunk-next (core.clj:710)
	clojure.core.protocols/fn--8176 (protocols.clj:137)
	clojure.core.protocols/fn--8176 (protocols.clj:124)
	clojure.core.protocols/fn--8136/G--8131--8145 (protocols.clj:19)
	clojure.core.protocols/seq-reduce (protocols.clj:31)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
	clojure.core/reduce (core.clj:6830)
	clojure.core/into (core.clj:6897)
	clojure.core/into (core.clj:6889)
	shadow.build.closure/convert-sources-simple* (closure.clj:1837)
	shadow.build.closure/convert-sources-simple* (closure.clj:1804)
	shadow.build.closure/convert-sources-simple (closure.clj:2098)
	shadow.build.closure/convert-sources-simple (closure.clj:2050)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
	shadow.build.compiler/compile-all (compiler.clj:1440)
	shadow.build.compiler/compile-all (compiler.clj:1307)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:442)
	shadow.build/compile (build.clj:432)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:439)
	shadow.cljs.devtools.server.worker.impl/fn--14290 (impl.clj:428)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068/fn--14076 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--14067/fn--14068 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--14067 (util.clj:256)
	java.lang.Thread.run (Thread.java:834)
also, i've seen this from that package once or twice when it did compile:
--- node_modules/@material-ui/data-grid/dist/index-cjs.js:17
Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.
which led me to try adding: :compiler-options {:output-feature-set :es2018}}}} to the options which led to the original error even on the older 2.12.7 version.
#2022-06-1513:31Stijn Albert@U053KNT7C did you manage to fix this? I have the exact same problem with MUI data-grid#2022-06-1604:59lucian303no, i ended up using @inovua/reactdatagrid-community instead of x-grid @U02LLEJMREG#2021-07-0216:23Drew VerleeHow would i create a release build from clojure, rather then the command line? I'm looking for the docs and don't see an example of this, though im guessing its possible from a namespace such as shadow.cljs.<something> Edit found it: https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2021-07-0302:20lucian303i'm trying to upgrade (cljs 1.10.773 -> 866, shadow 2.11.24 -> 2.14.5) my re-frame / material-ui project to the latest shadow and cljs, but when i build the app, i see a ton of errors like the below. could it be a build or dependency issue? compilation has no issues and it works with the previous cljs/shadow versions. i've tried adding managed dependencies and different combinations of package versions, npm packages, etc. the npm deps are there but they don't seem to load and i'm not sure how to get it working
An error occurred when loading reagent_material_ui.styles.js
and warnings like
shadow-cljs - failed to load module$node_modules$$material_ui$core$node$ButtonBase$TouchRipple
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$material_ui$core$node$ButtonBase$ButtonBase @ ButtonBase.js:35
shadow.js.jsRequire @ js.js:66
#2021-07-0306:51thheller@lucian303 try setting :js-options {:entry-keys ["browser" "main"]} in your build config#2021-07-0307:49lucian303unfortunately, i still get the same errors even w/ that setting in the config @thheller#2021-07-0308:29pezIf I have something like :lein {:profile "+dev"} in my config, does that impact the release build? I’m guessing it does?#2021-07-0310:26pezOr, can I have :lein in the :dev map of the build? I’ve tried it and there are no complaints, but I don’t know if it is picked up.#2021-07-0318:20thheller@pez shadow doesn't support classpath profiles. you can configure one for lein and that always applies
#2021-07-0318:21thhellerdon't really need to do it for anything. you can just run through lein directly if you really want more profiles#2021-07-0321:18pezNot sure I follow. I’m trying to get the Luminus template to allow me to start the server and the client such that Calva can connect both REPLs. If I have :lein {:profile "+dev"} in the config, Leiningen starts like so:
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Which satisfies Calva’s needs, and works in development. But I am unsure how/if it impacts a release build of the client app.
#2021-07-0406:38thheller@pez it does not. the classpath does not decide what ends up in the build. only your :require does. what isn't required isn't included. see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2021-07-0406:53pezThat's awesome. And a great article explaining it! Thanks!#2021-07-0414:58hadilsHi! I have a problem. I had a shdaow-cljs app that was working, but now the watch function is broken. I am troubleshooting the problem and I found that the websocket connection to localhost:9630 is getting back "access denied" in proper transit format. The result is that the website is showing stale information. Restarting the app and reloading the webpage has no effect. I checked the dependencies and I think they are correct. Any suggestions for how to resolve this? Thanks!#2021-07-0414:59thhellerI really gotta expand that error message ...#2021-07-0415:00thhellercommon problem #1: changing :output-dir OR :modules but not updating your HTML to actually load those files and thus loading the old files#2021-07-0415:00thheller#2: having two instances of shadow-cljs running in the same project and both running watch competing with each other#2021-07-0415:01thheller#3: less common but when using :devtools-url not properly proxying requests?#2021-07-0415:03thhelleror what also might happen if you have 2 projects both using shadow-cljs, they'll start on port 9630 and then port 9631. there might be cases where the watch from project a isn't actually running but the files still try to connect although 9630 now belong to another project. doens't seemt to be your case though since you said watch is running#2021-07-0415:03hadilsI am not using devtools-url. Let me check #1.#2021-07-0415:06hadilsI don't have two proejcts with shadow-cljs.#2021-07-0415:06hadilsWait...#2021-07-0415:06thhelleralso try http://localhost:9630/api/project-info#2021-07-0415:06thhellermake sure the server is actually what you think it is#2021-07-0415:34hadilsI rebooted. No other shadow-cljs processes running. The link above checks out as my project. I don't know why I'm getting access denied from the websocket reply.#2021-07-0415:35thhellerdid you verify you are loading the correct files? delete them to be sure#2021-07-0415:35hadilsHmmm, let me check#2021-07-0415:36thhellercould also be some sort of cache? maybe you have a service worker installed that caches too aggressively?#2021-07-0415:36hadilsAh. Let me check...#2021-07-0415:43hadilsThe service-worker was the problem! Thanks, @thheller!#2021-07-0416:31hadilsA naive point of view: it doesn't seem like hot code reloading works properly with service-workers. I am sure that I don't have it configured properly...#2021-07-0416:40hadilsI take that back. I had installed my pwa which was causing the problem.#2021-07-0420:00hadilsHi again. Can web workers have a different output-dir than the other modules? I would like to use the modules feature to generate my service worker...#2021-07-0420:06thhellera service worker should really be a separate build#2021-07-0420:06thhellermakes absolutely no sense to combine it#2021-07-0420:07thhellerIMHO I wouldn't even write a service worker in CLJS. probably just use something like https://developers.google.com/web/tools/workbox to generate it#2021-07-0420:30hadilsOk. Thanks @thheller!#2021-07-0421:41hadilsBTW, @thheller, This is an excellent library you have developed. I am really impressed.#2021-07-0516:10Adam Kalisz@thheller After an upgrade to shadow-cljs 2.11.26 to 2.14.5 the loading of our administration module broke with this message message: "Error loading admin: Consecutive load failures", stack: "CustomError: Error loading admin: Consecutive load…2e67cadcbe6a0cbc0cd49287b5202a7cdedc.js:421:1090)" Any ideas?#2021-07-0516:11Adam KaliszIn dev, everything is fine. Also release on my local laptop works fine. As soon as I deploy to staging, the administration module loading is broken.#2021-07-0516:16thhellerdon't know. what is the full error? looks like it is missing some info WHY it fails loading?#2021-07-0516:17thhellerI also don't recognize that error. it isn't from shadow?#2021-07-0516:52Adam KaliszI don't really have a clue why it happens, I only know, I updated shadow-cljs as described to use newer ClojureScript 1.10.866 and that's it. The module is loaded using something like:
[lazy/lazy #:lazy{:loadable (slazy/loadable <someprojectname>.client.views.administration.core/administration)
                  :state    :loading/administration}]
Here is the lazy implementation:
(ns <someprojectname>.client.views.widgets.lazy
  (:require ["react" :as react]
            [reagent.core :as r]
            [shadow.lazy :as slazy]
            [<someprojectname>.client.views.loading :as loading]))

(defn- component
  "React Lazy component which waits till the code is loaded and then replaces it with the component itself."
  [loadable]
  (react/lazy
    (fn []
      (-> (slazy/load loadable)
          (.then (fn [root-el]
                   #js {:default (r/reactify-component (fn [props] [@loadable props]))}))))))

(defn lazy
  "Renders a component whose source code may have to be first loaded. While the source code is loaded, renders the
  loading screen for the given state. The single parameter is a map having the following keys:

  :lazy/loadable - Call (slazy/loadable ).
  :lazy/state - The loading state while the component's source code is loaded."
  [{:lazy/keys [loadable state]}]
  [:> react/Suspense {:fallback (r/as-element (if state
                                                [loading/loading {:loading/state state}]
                                                [:div]))}
   [:> (component loadable)]])
The error isn't very specific unfortunately - or at least I don't see any useful details.
#2021-07-0516:55thhellerwhats in the network tab of the devtools? do the files 404 or something?#2021-07-0517:04Adam KaliszNo 404 I can see...#2021-07-0517:05thhellerdoes it execute code on load? maybe it throws an error during loading#2021-07-0517:05thhelleryou can sort of easily test this by just loading the required files manually in your html#2021-07-0517:05thhellerwithout the loader. just some script tags, in the correct order so shared/admin or whatever else there is#2021-07-0517:07thhellernot sure why its loading everything twice though? why is it loading "layout" twice or even 3 times?#2021-07-0517:10Adam KaliszI really don't know, I haven't written this part of the code... I only stumbled over it, because it broke. :-)#2021-07-0517:28Pavel KlavíkWe are running the same webworker in layout twice, so that is likely the reason.#2021-07-0517:30Pavel KlavíkAdministration is loaded twice because we have two lazy components which depend on it, inserted into different views.#2021-07-0517:48Adam KaliszOk, after removing one of the lazy loads, I get one fewer error messages...#2021-07-0517:07Adam KaliszAh, ok, I will try that. This is something that gets executed early on - but don't even see the temporary console.log.
(rf/reg-event-fx
  :administration/load-data
  [clean/effects]
  (fn [effects [_ refresh]]
    (let [{:administration/keys [init mode]} (db-get/administration effects)]
      (js/console.log "LOG LOG Loading administration data.")
      (if (or init refresh)
        (db-update/administration (case mode
                                    :administration/index (metrics/switch-to-metrics effects)
                                    :administration/metrics (metrics/switch-to-metrics effects)
                                    :administration/charts (charts/switch-to-charts effects)
                                    :administration/users (users/switch-to-users effects)
                                    :administration/usergroups (usergroups/switch-to-usergroups effects)
                                    :administration/devices (devices/switch-to-devices effects)
                                    :administration/orgpages (orgpages/switch-to-orgpages effects)
                                    :administration/campaigns (campaigns/switch-to-campaigns effects)
                                    (metrics/switch-to-metrics effects))
                                  dissoc :administration/init)
        effects))))
#2021-07-0517:19Adam KaliszIf I don't modularize the code, everything works without issue.#2021-07-0517:22thhelleryou should modularize the code though 😉#2021-07-0517:23Adam KaliszYes, that would be nice...#2021-07-0517:23thhellerI mean there aren't that many things that can go wrong, so finding it shouldn't be that hard#2021-07-0517:24Adam KaliszWell, it kind of is for me, because it just is a pile of stuff I see for the first time. With basically a three line change in dependencies.#2021-07-0517:25thhellerwell you didn't just upgrade shadow-cljs. you upgraded the clojurescript, closure-compiler and closure-library version as well#2021-07-0517:26thhellerand the closure stuff has had a few known breaking changes#2021-07-0517:26thhellerso totally possible that something broke that worked before. not a clue without finding your actual error#2021-07-0517:26Adam KaliszYes 🙂 Btw. have rewritten the cookies as you recommended - but while testing my changes, I traced the broken administration back to this change.#2021-07-0517:27Adam Kalisz(So before any of the other changes.)#2021-07-0517:28Adam KaliszWhat really strikes me is it doesn't happen when I do a release build locally#2021-07-0517:56Pavel Klavík@thheller the entire code just follows https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html, does that still work for you in the latest shadow-cljs version?#2021-07-0517:57thhelleryes, no changes#2021-07-0518:06Pavel KlavíkI don't really understand why release build locally works while it is broken when we deploy to staging. So it looks like it would be related to script file not being served correctly, but we get 200 on it with no errors.#2021-07-0520:26thhellerguess you'll have to find out whats different in staging. maybe some sort of caching? did you verify that the hashes actually match and it doesn't end up using files from an old build or something?#2021-07-0518:27Adam KaliszOk, if I include layout and admin into the app.html template, the administration loads. This obviously kind of breaks the point of modularization, but it shows the problem is most likely in the lazy loading part somewhere.#2021-07-0518:29thhellerdo not do anything other than directly loading the JS files in your html#2021-07-0518:30thhellerno loader, no lazy. just load the files. that'll most likely already reveal the problem.#2021-07-0518:33Pavel Klavíkafter adding it directly without lazy loading, everything works fine, except no modularization#2021-07-0518:33Pavel Klavíkthere are no errors in the console#2021-07-0518:37Adam KaliszSo what I did is, I left the lazy loader in the code just as it always was. I just added the admin.js into the app.html so it is basically loaded before the part where <someprojectname>.client.views.administration.core/administration is called. As Pavel wrote, this doesn't produce any errors and it works.#2021-07-0519:04Applehi i'm first time shadow user. i'm trying to convert from figwheel to shadow and run into this issue: pretty sure i have reagent/reagent in my deps.edn file. where to look for clues? [:app] Compiling ... -> Resolving Module: :main [:app] Build failure: The required namespace "react" is not available, it was required by "reagent/core.cljs".#2021-07-0519:06Applei'm not using npm/npx. shadow is started from a user clj like: (defn shadow-cljs [& args] (server/start!) (shadow/watch :app {:verbose true}))#2021-07-0519:14Applehttps://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies says add reagent to shadow-cljs.edn. Instead i'm using an alias within deps.edn. Does it matter?#2021-07-0519:16Adam KaliszPerhaps require React e.g. (ns ... (:require ["react" :as react]))#2021-07-0519:19Adam KaliszAnd perhaps [reagent.core :as r] Also in your package.json add the dependency:
"dependencies": {
...
  "react": "^16.14.0",
<and optionally other dependencies with appropriate versions>
  "react-dom": "^16.14.0",
  "react-easy-crop": "^2.1.2",
  "react-motion": "^0.5.2",
  "react-transition-group": "^4.4.1",
...
},
#2021-07-0519:20Adam KaliszAnd install the packages with npm/ npx.#2021-07-0519:21Applei was using figwheel and didnt have to deal with any package.json is shadow different in this aspect?#2021-07-0519:23Adam KaliszIt looks for package.json for dependencies and other stuff more akin to how a JavaScript project would work.#2021-07-0519:24Apple{:deps {...}} :paths ["src" "resources" "target"] :aliases {:dev-deps {:extra-deps {;;nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.26.0"} reagent/reagent {:mvn/version "1.1.0"} cljs-ajax/cljs-ajax {:mvn/version "0.8.3"} cljsjs/react-bootstrap {:mvn/version "1.3.0-0"} thheller/shadow-cljs {:mvn/version "2.14.6"} ring/ring-devel {:mvn/version "1.9.3"}}} :dev {:main-opts ["-m" "user"] :extra-paths ["dev"]} :build {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]} :prod {:main-opts ["-m" "web.core"]}}}#2021-07-0519:24Adam KaliszAt least that is how I understand it. It is nothing too complex, just a json file, that describes your project.#2021-07-0519:24Appleclj -M:dev-deps:dev#2021-07-0519:25Applei replace figwheel deps with shadow deps in :extra-deps#2021-07-0519:25Appleand was hoping it'd just work#2021-07-0519:25Appleso npm/npx is a hard dependencies with shadow-cljs?#2021-07-0519:27Applehttps://shadow-cljs.github.io/docs/UsersGuide.html#_library this is the way i use#2021-07-0519:29Adam KaliszI don't use deps.edn so can't really help you with that. Perhaps somebody else will step in...#2021-07-0520:24thheller@UP82LQR9N yes, with shadow-cljs you need to use npm to handle npm dependencies. it does not support CLJSJS (which you probably relied on with figwheel)#2021-07-0520:24thhellerso you need to have node/npm installed#2021-07-0520:26Applegot it. thank you!#2021-07-0520:29Appleby reading https://shadow-cljs.github.io/docs/UsersGuide.html#_installation i had an impression that npm/npx was not mandatory.#2021-07-0520:34thhelleryou do not have to use the shadow-cljs npm package. that is correct. but you'll still need npm for the actual npm packages such as react#2021-07-0802:29AppleI reduce my deps.edn to minimal w/o figwheel, and it still compiles. So cljs compiler should be able to handle all dependencies. shadow-cljs calls cljs.main to compile as well, right? If that's true then shadow should be able to compile as well, right? {:aliases {:dev-deps {:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.866"} reagent/reagent {:mvn/version "1.1.0"} cljs-ajax/cljs-ajax {:mvn/version "0.8.3"} cljsjs/react-bootstrap {:mvn/version "1.3.0-0"}}}}} clj -M:dev-deps --main cljs.main -O advanced -c web.core#2021-07-0805:49thheller@UP82LQR9N no. shadow does not use or support cljs.main. and if you your question is still about npm dependencies then the answer is still no. shadow-cljs does NOT support CLJSJS dependencies and you MUST install npm dependencies. I suggest reading https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps if you want to learn more#2021-07-0813:24Apple@thheller Excuse my English. What I was trying to say was that my *.cljs files can be compiled manually by invoking cljs compiler w/o figwheel(cljsjs or not), so that means the functions in cljs compiler(clojurescript-1.10.866.jar) alone did the job. I presume shadow-cljs uses and is built upon the same cljs compiler(clojurescript-1.xx.xxxxx.jar) to compile .cljs files so I don't understand why shadow-cljs cannot compile the same set of .cljs files.#2021-07-0813:25AppleI'm curious in how it works the underlying connection between shadow-cljs and cljs compiler.#2021-07-0813:49Applecljs compiler perhaps uses google closure library to solve dependencies? shadow-cljs does not uses cljs compiler or closure library for dependencies but npm instead?#2021-07-0814:26thhelleryes, shadow-cljs uses the regular cljs compiler. react however is not a CLJS library. it is a JS library. the default cljs implementation will resolve those using a mechanism called foreign-libs which are provided by CLJSJS packages. shadow-cljs does not support those and instead provides JS deps directly from npm.#2021-07-0814:54AppleI'm almost there with you.... you say "shadow-cljs uses the regular cljs compiler", while what regular cljs compiler can compile fails in shadow-cljs. Does that somehow mean shadow-cljs is not leveraging what's already available in regular cljs compiler?#2021-07-0814:56thhellerplease re-read what I wrote and maybe read the docs ... I can only repeat myself over and over again.#2021-07-0814:57thhellershadow-cljs uses the latest cljs compiler and it is quite intentional that it does NOT support CLJSJS.#2021-07-0814:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2021-07-0814:57thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2021-07-0814:58thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2021-07-0814:58thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2021-07-0815:00thhellerif you do not want to use npm at all then you probably shouldn't use shadow-cljs#2021-07-0815:08AppleThank you very much! I'll read them all to better understand how js dependency works.#2021-07-0816:25AppleI sense that ":foreign-libs support" is probably it. I'm good now.#2021-07-0521:09Adam Kalisz@thheller shouldn't root-el be used in the function here: https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs ?#2021-07-0521:09Adam KaliszI don't understand the comments there#2021-07-0521:13thhellerif you want hot-reload to work you can't use root-el? I mean I can't describe it any clearer than I did in that comment?#2021-07-0521:25Adam KaliszOk, thank you for the clarification. We will probably end up injecting the script tag into head to load the administration. We just can't figure out, why exactly the lazy load doesn't work just when we run the build for staging.#2021-07-0521:27Adam KaliszThe order how Chrome loads stuff if I do a release build locally and in staging is different. It seems, in staging the JavaScript is loaded later than in the local build. I don't know why.#2021-07-0607:06thhellerimpossible to say without seeing the code and config. pretty much the only problems I ever had with module loading is with cache issues. eg. when you have an old shared.js but try to load newer admin.js or so but the hashes prevent that from happening usually. could be something like a service worker going crazy too though#2021-07-0620:13Pavel KlavíkWe don't have any service worker at the moment.#2021-07-0620:14Pavel KlavíkAnd files have Git commit SHA appended, so there should be no collisions.#2021-07-0620:15Pavel Klavík
{:lein     true
 :jvm-opts ["-Dfile.encoding=UTF8" "-Xmx2G"]
 :nrepl    {:port 9000}
 :ssl      {:keystore "keystore.jks"
            :password "..."}
 :builds   {:client     {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :module-loader    true
                         :modules          {:shared {:entries []}
                                            :main   {:init-fn    orgpad.client.core/init
                                                     :depends-on #{:shared}}
                                            :admin  {:entries    [orgpad.client.views.administration.core]
                                                     :depends-on #{:main}}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:shared}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs      :auto
                                            :output-feature-set :es6}
                         :devtools         {:after-load     orgpad.client.core/mount-root
                                            :before-load    orgpad.client.core/stop-web-workers
                                            :watch-dir      "resources/public"
                                            :browser-inject :main
                                            :loader-mode    :eval}}
            :landing    {:target     :browser
                         :output-dir "landing/resources/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.landing.dev/init}}
                         :devtools   {:http-root      "landing/resources"
                                      :http-port      3500
                                      :after-load     orgpad.landing.dev/mount-root
                                      :watch-dir      "landing/resources"
                                      :browser-inject :main}}
            :emails     {:target     :browser
                         :output-dir "emails/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.server.email.dev/init}}
                         :devtools   {:http-root      "emails"
                                      :http-port      3600
                                      :after-load     orgpad.server.email.dev/mount-root
                                      :watch-dir      "emails"
                                      :browser-inject :main}}
            :screenshot {:target           :node-script
                         :main             orgpad.screenshot.core/main
                         :output-to        "screenshot/screenshot.js"
                         :devtools         {:autoload true}
                         :compiler-options {:optimizations :simple}}}}
#2021-07-0620:48thhellerhmm you are not using :module-hash-names so how do you get the proper filenames into the loader?#2021-07-0621:15Pavel Klavíkrelease build is done by this:
(defn release []
  (let [version (System/getenv "GIT_SHA")]
    (when-not (= (shadow/release :client {:config-merge [{:release-version version}]}) :done)
      (throw (RuntimeException. "Shadow-cljs compilation failed.")))))
#2021-07-0621:17thhellerah#2021-07-0621:17thhellerFWIW there is a shadow/release! that'll throw if compile fails#2021-07-0621:17thhelleris admin something the regular user will actually use? or is it actual admin-only stuff?#2021-07-0621:18thhellerreally not super important but admin specific stuff that regular users won't use is probably better off in a separate build#2021-07-0621:18Pavel Klavíkthe latter#2021-07-0621:19thhellerbut config wise it looks fine. don't know what could be going wrong with it#2021-07-0621:20thhellerwhen do you actually trigger lazy loads? directly on first load?#2021-07-0621:20Pavel Klavíkbtw. is there a way to run newer version of Shadow with previous Clojurescript and Closure library?#2021-07-0621:21Pavel Klavíkwhen you enter administration, the lazy component is displayed and does the loading using the code Adam posted yesterday#2021-07-0621:22thhellerdue to breaking changes all over the place you really can't mix versions too well#2021-07-0621:22thhelleryou can try but no guarantees#2021-07-0709:13Michaël SalihiHi, I meet a case when hot-reload children Reagent component stop working after refactoring some code. With this following setup, it's working (`after-load` hooks on mount-root) : https://github.com/prestancedesign/pingcrm-clojure/blob/ssr/src/cljs/pingcrm/app.cljs#L11-L26#2021-07-0709:15Michaël SalihiBut it doesn't works when I use this helper function createInertiaApp:
(defn ^:dev/after-load start []
   (createInertiaApp
    #js {:resolve (fn [name] (let [^js comp (r/reactify-component (get pages name))]
                                (when-not (= name "Auth/Login")
                                  (set! (.-layout comp) (fn [page] (r/as-element [layout page]))))
                                comp))
         :setup (j/fn [^:js {:keys [el App props]}]
                  (d/render (r/as-element [:f> App props]) el))}))

(defn init! []
  (start))
#2021-07-0709:16Michaël SalihiHere the source of the createInertiaApp: https://github.com/inertiajs/inertia/blob/master/packages/inertia-react/src/createInertiaApp.js#L4#2021-07-0709:17Michaël SalihiDoes this have to do with async? Or another clue?#2021-07-0712:39Michaël Salihi@U05224H0W Should I use after-load-async in this case or nothing related?#2021-07-0715:25thhellerno, that won't do anything different. I suspect that createInertiaApp is setup so it only works once? no clue sorry.#2021-07-0812:04Michaël SalihiIn fact, I have found a solution to my problem. Hot reloading stop working when I move required components to another namespace to share them between two main files : 1. app.cljs for the SPA part 2. ssr.cljs for the SSR part#2021-07-0812:06Michaël SalihiTo fix it, I added var quotes '# to theses components. Here the commit: https://github.com/prestancedesign/pingcrm-clojure/commit/175aee8fca26a281e7bc82680b5ac5e1e70fb997#2021-07-0812:08Michaël SalihiI regulary use var quote for Clojure (Reitit/Compojure handlers, etc), but It's the first time I must use it for ClojureScript. Is this common?#2021-07-0814:44thhellerI'd avoid using var. it dumps a bunch of useless metadata and code into your code. so makes release bigger than it needs to be#2021-07-0816:03Michaël SalihiThank you for this very useful clarification, I had not assumed that ... I did well to ask the question.#2021-07-0816:25Michaël SalihiFor the moment, I don't see another solution than use var to get the hot reload working unfortunately. 😞#2021-07-0711:06OzHey, is there a way to get auto-completion working for npm modules in cider? It works for js, but not for e.g
(ns my.namespace
(:require
   ["@material-ui/core" :as mui])
(mui/P|<- *cursor is here*  )
#2021-07-0711:51Tomas BrejlaAlso interested whether this is possible somehow. 🤞#2021-07-0910:06Tomas BrejlaFYI here's one answer from #cider channel. https://clojurians.slack.com/archives/C0617A8PQ/p1625772420264100?thread_ts=1625743117.262500&amp;cid=C0617A8PQ#2021-07-0910:07Tomas Brejlanot sure if clj-suitable is a way to go (and whether it works correctly with shadow), but worth investigating#2021-07-0712:37Michaël Salihi@ozfraier You should ask in #cider channel.#2021-07-0712:49Tomas BrejlaOn the other hand... if such feature is possible, there might be some support needed on shadow-cljs side. My expectation is that cider has no knowledge about the existence of npm modules, while shadow does.#2021-07-0716:27sheluchinI want to make sure I understand this correctly... if I have :deps true or :deps {:aliases [:dev]} in my shadow-cljs.edn file, then I should not have a :dependencies key anywhere in the same file, correct? All my deps are managed by deps.edn as a result of those settings -- that's my understanding.#2021-07-0716:31thhelleryes#2021-07-0718:54ShaneLesterAnyone have an idea why I might be getting this error only on npm-module target builds? Browser target works perfectly fine
internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/events/events.js"]
{:dep [:shadow.build.classpath/resource "goog/events/events.js"]}
ExceptionInfo: internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/events/events.js"]
I am using shadow 2.14.6. Am I missing something super obvious? I've tried adding goog events manually a few places but no dice so far
#2021-07-0720:22ShaneLesterFor anyone finding this in the future, node-library target works and was not hard to switch to from npm-module target. do an exports-var pointed at your highest-level function and call it as the function itself when you require it as it is shown https://shadow-cljs.github.io/docs/UsersGuide.html#_single_static_default_export#2021-07-0718:58thhellersee https://github.com/thheller/shadow-cljs/issues/908#2021-07-0718:58ShaneLesterAh. ok. thank you.#2021-07-0804:03awb99When I use "watch" I get no warnings. But with release, I get the following warning. I guess it should be reorted to cognitect:#2021-07-0804:03awb99------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared --------------------------------------------------------------------------------#2021-07-0804:04awb99Or does tis have something with my app ?#2021-07-0804:50awb99I have a advanced build issue:#2021-07-0804:50awb99(defn render-math [dom-node data-js] (let [mathjax (.-MathJax js/window) ;options (clj->js options) options (.getMetricsFor mathjax dom-node true)] (-> (.tex2svgPromise mathjax data-js options) ; (.then (fn [math-node] (.appendChild dom-node math-node) #_(add-math-css)))))) (defn ^{:category :ui} math "displays mathematical formulas" [{:keys [data options]}] [render-js {:f render-math :data data}])#2021-07-0804:51awb99.getMetricsFor gets removed, but it is used in "math" function (which is in bundel).#2021-07-0804:51awb99I guess the passing of functions in a map is the culprit?#2021-07-0805:43thhellerdo you not get an externs inference warning? or are you on an old version that didn't have that enabled by default yet?#2021-07-0817:49awb99I am not getting an externs inference warning. In adanced compilation the js module functions disappear. I will investigate more when this happens.#2021-07-0817:55thhellerplease describe how you determined that it "disappeared". Closure doesn't just delete code.#2021-07-0805:44thhellerdon't know what you mean by "gets removed". you mean "gets renamed"?#2021-07-0805:44thhellerthe transit warning you can ignore#2021-07-0814:42haywoodI have a dependency .jar that uses shadow-cljs for it’s dependency management, does that project need to also include a deps.edn with mirrored dependencies so the parent project fetches them?#2021-07-0814:43haywoodor mirror them in the project.clj, I’m not sure how nested dependency management works#2021-07-0814:45thhellerI don't understand the question. what do you mean by nested dependency management?#2021-07-0818:06zendevil.ethI’m trying to run jest with shadow cljs, and this is my test config:
{:target  :browser-test
                :test-dir "target/test/"
                :autorun tr
which basically compiles to target/test/js/test.js, but when I run jest on test.js, it produces the following:
FAIL  target/test/js/test.js
  ● Test suite failed to run

    browser bootstrap used in incorrect target

      1449 |
      1450 |   if (!doc) {
    > 1451 |     throw new Error("browser bootstrap used in incorrect target");
           |           ^
      1452 |   }
      1453 |
      1454 |   var scriptBase = goog.global.window.location.origin;

      at Object.call (target/test/js/test.js:1451:11)
      at Object.<anonymous> (target/test/js/test.js:1582:3)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.43 s
How to fix this? This is the singular test file that’s being compiled:
(ns humboi.sum-test)

(defn sum [a b] (+ a b))

(test "adds 1 + 2 to equal 3"
      (fn []
        (.toBe (expect (sum 1 2)) 3)))
#2021-07-0818:06thhellerjest is not a browser so :browser-test won't work#2021-07-0818:09zendevil.ethso what would be the correct target type?#2021-07-0818:09thhellerprobably none. I have never used jest so I have not written any code to support it#2021-07-0818:09thhellerothers might have experimented but I don't know#2021-07-0818:35zendevil.ethI have npm installed @testing-library/react, but I’m still getting the following: https://gist.github.com/zendevil/0f88020fa4c757f1fc3b664425c51a6d I have tried deleting node_modules#2021-07-0818:41thhellerwell if you delete it then it can't be found?#2021-07-0818:41thhellerthat is a node error. node cannot find that module. did you install it in the correct directory?#2021-07-0818:46zendevil.ethwhat I meant was that I tried deleting node_modules and running npm install#2021-07-0818:47zendevil.ethI ran npm install --save-dev @testing-library/react in the root of the project#2021-07-0818:49zendevil.ethOn browser-test target, a similar error:
[:test] Compiling ...
[:test] Build failure:
The required JS dependency "@testing-library/react" is not available, it was required by "humboi/core_test.cljs".

Dependency Trace:
	humboi/core_test.cljs

Searched for npm packages in:
	/Users/prikshetsharma/Desktop/humboi/node_modules

See: 
#2021-07-0818:50thhellerwell does it exist? there should be a /Users/prikshetsharma/Desktop/humboi/node_modules/@testing-library/react directory?#2021-07-0818:51zendevil.ethit doesn’t exist (even after npm install) but does in the devDependencies in package.json#2021-07-0818:51thhellerand you are in /Users/prikshetsharma/Desktop/humboi?#2021-07-0818:51thhellerand it is in this /Users/prikshetsharma/Desktop/humboi/package.json?#2021-07-0818:52zendevil.ethyes#2021-07-0818:52thhellerdo you have npm in production mode? ie. not installing devDepenencies?#2021-07-0818:56zendevil.ethremoving from devDependencies and installing with --save works#2021-07-0818:56zendevil.ethwithout manually removing from devDependencies, --save has no effect#2021-07-0818:57zendevil.ethbtw in a luminus app, lein test runs only the clj tests. Is there a way to run only the cljs tests?#2021-07-0818:58thhellerdon't know. I have never used luminus#2021-07-0819:00zendevil.ethin any project that has both clj and cljs tests, how does one run only the cljs tests?#2021-07-0819:00thhellershadow-cljs compile test && node the-file-generated-by-node-test-build.js#2021-07-0819:05zendevil.ethand what if the target is browser-test?#2021-07-0819:07thhelleryou open the browser?#2021-07-0819:09zendevil.eththe port specified in :devtools {:http-port isn’t connecting when opened in the browser#2021-07-0819:11zendevil.ethdoes that mean that I have to spin another server on that port?#2021-07-0819:12thhelleris shadow-cljs running?#2021-07-0819:13thhellerno, you don't need to start a separate server. assuming the config is correct it should be running.#2021-07-0819:13thhellernpx shadow-cljs server or a running watch is needed. otherwise it won't be running#2021-07-0819:14zendevil.ethyeah the test watch is already running#2021-07-0819:14thhellerso what is your config?#2021-07-0819:14zendevil.eth
{:nrepl {:port 7002}
 :builds
        {:app
               {:target     :browser
                :output-dir "target/cljsbuild/public/js"
                :asset-path "/js"
                :modules    {:app {:entries []}}
                :devtools   {:watch-dir "resources/public"
                             :preloads  [re-frisk.preload]}
                :dev        {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
                :release    {}}
         :test {:target  :browser-test
                :test-dir "target/test/"
                :autorun true
                :devtools {:http-port 8081
                           :http-root "target/test/"}}}
 :lein  true}
#2021-07-0819:15zendevil.ethboth watches are running#2021-07-0819:15zendevil.ethand test is compiling without warnings#2021-07-0819:15thhellerlooks fine but FWIW you should be using :dev-http https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2021-07-0819:15thheller:autorun is not an option for :browser-test#2021-07-0819:16thhellerhttp://localhost:8081 should be working#2021-07-0819:20zendevil.eth8081 isn’t working#2021-07-0819:20zendevil.ethcan’t be reached#2021-07-0819:20thhellerso what does it say when you start shadow? how do you start it in the first place?#2021-07-0819:21zendevil.ethI start it with cider#2021-07-0819:21zendevil.ethIt does give this error:
Execution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:30).
Assert failed: (keyword? repl-env)
#2021-07-0819:21zendevil.ethin the very beginning#2021-07-0819:22thhellercan't help you with that sorry. I don't use or know cider#2021-07-0823:21wilkerluciohello, I'm trying to include a recent version of BlueprintJS (https://blueprintjs.com/docs) in a project, but seems like Shadow can't load the files there#2021-07-0823:22wilkerluciomy first guess is because the code has Typescript in it#2021-07-0823:22wilkerluciobut it also has a dist compiled version like "@blueprintjs/core/dist/core.bundle.js", I tried to load that but no luck#2021-07-0823:23wilkerluciois there a way to load this kindle of bundles with Shadow?#2021-07-0823:24wilkerluciowhen I try to load ["@blueprintjs/core" :as bp-core], it doesn't give any error, but the bp-core comes blank#2021-07-0823:24wilkerluciosame when trying to require the bundled#2021-07-0823:31wilkerlucioI tried reverting to a blueprint version I now worked before, but that seems broken now too, gonna try to find in which version of shadow it broke#2021-07-0823:36wilkerluciothat's strange, I reverted the version of shadow and blueprint to ones I know that work in another project, but I'm still getting the same errors#2021-07-0823:54wilkerlucionevermind, the issue is completly something else, I'm loadingf require.js to load monaco and that was conflicting under window.require facepalm#2021-07-0900:11wilkerlucioI'm trying to integrate Monaco editor (https://microsoft.github.io/monaco-editor), but loading it is a pain... just from shadow it doesn't load at all, and this AMD approach is conflicting with the shadow loader stuff#2021-07-0900:12wilkerluciowould love to hear if anyone has a way around this#2021-07-0900:18lsenjovWe’ve dealt with something similar to this, our solution was making sure require came after loading the main.js (I think, it’s been a little while)#2021-07-0900:18lsenjovSince require.js overwrites the window.require when it loads#2021-07-0900:21lsenjovAlthough all our usage of the thing needing require was done through the using interop, rather than importing it in shadow#2021-07-0900:47wilkerluciothanks, I ended up doing the same, and loading requirejs itself via react hooks inside the component#2021-07-0900:47wilkerluciolooks terrible, but works#2021-07-0906:16thhellerhaven't looked at monaco in a while. they used to have their completely custom loading mechanism that didn't follow any conventions and didn't even work with webpack or so#2021-07-0906:16thhellerdon't know if thats still the case today or if they provide some kind of esm build maybe#2021-07-0904:03awb99I have a lazy loading question: I noticed that together with lazy loading of code I should b lazy loading of css. I know shadow does not deal with css. But it would be great to listen to module load events. So as soon as a module starts loading, I would like to load the associated css. Is this possible?#2021-07-0906:14thheller@hoertlehner not with the built-in loader but you can easily wrap that to add your own css loading#2021-07-0919:55awb99thanks @thheller your fast answers are incredibly helpful for me in using shadow-cljs. I really dont know how you find the time to provide such great support! thanks!#2021-07-0914:23Justin ChandlerHey everyone! I'm trying to get the Puppeteer library to work with ClojureScript/ShadowCLJS and I'm getting this error when requiring it: Closure compilation failed with 1 errors --- node_modules/puppeteer/lib/cjs/puppeteer/common/AriaQueryHandler.js:33 Cannot convert ECMASCRIPT_2018 feature "RegExp named groups" to targeted output language Is there a way to configure the goog compiler to swap out the targeted output language to a later ecmascript and use the feature anyway through the shadow.edn or something or is there more to this kind of compatibility problem?#2021-07-0916:01thheller@chandler.justin.s :compiler-options {:output-feature-set :es-next} in your build config#2021-07-0916:02thhellernot sure why you are getting this error though? are you trying to compile for the browser? puppeteer only works for node?#2021-07-0916:06Justin Chandler@thheller Ahhh you're right, I did forget to change my target to Node! Hahaha I would've spent all day on that. Thank you, I appreciate it!#2021-07-0916:48haywoodwhen compiling a project that has uses a :bootstrap build I’m getting a lot of Uncaught ReferenceError: goog is not defined when the compiler is loaded in the application, I don’t get it during development and I’m not sure why… :thinking_face:#2021-07-0916:51haywoodMy two builds:
{:app      {:target            :browser
             :output-dir        "target/cljsbuild/public/js"
             :asset-path        "/js"
             :module-hash-names true
             :modules           {:app {:entries []}}
             :compiler-options  {:warnings {:infer false}}
             :build-hooks
             [(scripts.gen-routes/watch)]
             :devtools
             {:watch-dir "resources/public"
              :preloads  [re-frisk-remote.preload
                          shadow.remote.runtime.cljs.browser]}
             :dev
             {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
             :js-options
             {:resolve {"dom-helpers/class/addClass"    {:target  :npm
                                                         :require "dom-helpers/addClass"}
                        "dom-helpers/class/removeClass" {:target  :npm
                                                         :require "dom-helpers/removeClass"}}}}
  :bootstrap {:target :bootstrap
              :output-dir "target/cljsbuild/public/js/bootstrap"
              :asset-path "/js/bootstrap"
              ;; These are the namespaces we expose to the bootstrapped compiler
              :entries [cljs.js
                        dlstats.telemetry.common
                        dlstats.telemetry.schema]
              :compiler-options
              {:warnings {:infer false}}

              ;; many macro namespaces can't be evaluated in ClojureScript -
              ;; so we exclude them here to avoid runtime errors. Note that
              ;; it's ok to include code that consumes Clojure (jvm) macros,
              ;; but only selfhost-compatible macros can be evaluated "live".
              :exclude #{cljs.js}}
#2021-07-0916:52haywoodcompiling with shadow-cljs release app bootstrap#2021-07-0918:04thhelleryou must compile with :optimizations :simple in your app build :compiler-options#2021-07-0918:05thhellerthe default :advanced does not work with self-hosted#2021-07-1001:04lilactownis there a way for me to find how a namespace is being included in my bundle?#2021-07-1005:23rbergerDoes shadow-cljs have a way to check for unused dependencies in package.json for a clojurescript project like npm/yarn https://github.com/depcheck/depcheck does for JS projects? Or is there some combination of tooling that could accomplish that?#2021-07-1006:17thheller@lilactown the new build reports show it on mouseover. see https://code.thheller.com/demos/build-report/ui-report.html#2021-07-1006:18thheller@rberger not built in but I guess you can do npx shadow-cljs compile app --config-merge '{:js-options {:js-provider :external :external-index "foo.js"}}' and then let the regular depcheck run over that foo.js file#2021-07-1006:19thhellerthat file will require all npm deps you'd otherwise include in a format depcheck should understand#2021-07-1007:48rbergerCool. I was also able to review the build report and manually figure it out#2021-07-1016:02lilactownanother q: what's the way to tell shadow-cljs pull in the profiling version of React when doing a release build? https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977#2021-07-1016:04thheller:js-options {:resolve {"react-dom" {:target :npm :require "react-dom/profiling"}}}, optionally wrapped in :release {:js-options ...} when it should only apply to release builds?#2021-07-1016:05thhelleror the same via --config-merge#2021-07-1016:06lilactownthe --config-merge would allow me to do this via CLI#2021-07-1016:06lilactownthanks!#2021-07-1016:07lilactowncould I elide the :release {,,,} wrapping if I'm doing shadow-cljs release --config-merge ",,,"?#2021-07-1016:08thhellerof course. whatever you merge will only apply to the build you are doing at that time.#2021-07-1016:20lilactownthat worked 🙂 appreciate it!#2021-07-1109:53Jo Øivind GjernesI can't seem to get my cytoscape.js import to work. Ending up with this:
Uncaught TypeError: module$node_modules$cytoscape$dist$cytoscape_esm.cytoscape is not a function
    at Object.topology$graph$cytoscape_clj [as cytoscape_clj] (graph.cljs:36)
#2021-07-1110:08thheller@jodleif no clue what cytoscape is but I'm guessing you used it wrong. check the translation table and section about default exports here: https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2021-07-1114:17Jo Øivind Gjernes0. (https://cytoscape.org/ visualization library) 1. I've verified that the function it is complaining about exists in the js source shadow-cljs is pointing to 2. I've also verified other npm packages work :man-shrugging: (i.e. calling imported function, getting something back in repl) 3. What's the next step in debugging this? The import seems to work but i'm obviously missing something...#2021-07-1114:20thhellerdid you read the docs? II'm almost 100% sure that your :require is just wrong#2021-07-1114:20thhellerpretty sure thats the only thing you need to debug#2021-07-1114:27Jo Øivind GjernesI've read docs and some blog posts you have written#2021-07-1114:29thhellerdid you try the REPL example here https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2021-07-1114:29thheller?#2021-07-1114:31thhellerI really can't help you without seeing code. I can only guess what you are doing. From the error message I'm guessing you used :refer (cytoscape) when either :as cytoscape or :default cytoscape would be correct.#2021-07-1115:00Jo Øivind Gjernes#2021-07-1115:01thhellerso (:require ["/js/cytoscape.esm.min" :default cytoscape])#2021-07-1115:02thheller(cytoscape (clj->js {}))#2021-07-1115:02thhellerwhy /js/cytoscape.esm.min? why not use the npm package? or is that not an npm package?#2021-07-1115:03Jo Øivind GjernesJust hammer debugging. :default seems promising, I've tried that as well- but maybe repl had dirty state Now:
(cytoscape (clj->js {}))
#object[eo$$module$js$cytoscape_esm_min [object Object]]
#2021-07-1115:03Jo Øivind GjernesThanks a lot 👍#2021-07-1113:23AronI see that the https://github.com/thheller/reagent-react-native was updated, but the readme is a bit confusing, would it be all right if I suggest further changes in a PR? E.g. why use both yarn and npm? then how to go twice into the same directory? cd react-native appears twice.#2021-07-1113:26thhellerthe rn commands you run in the react-native dir so you need to cd into it#2021-07-1113:27thhellerhappy about a PR to adds more docs if that makes it clearer#2021-07-1116:16Aronso, i tried it and it works, i just feel that what i learned is too empirical, don't understand why it works the way it works. not the shadow-cljs part, that's transparent at least, but now I am guessing the yarn install is there so that --legacy-peer-deps is avoided for npm, and I rather use the web interface, but otherwise the watch keeps the terminal, so I see why it's mentioned twice#2021-07-1116:17Aroni also have to run adb devices first for the react native run command to work, this something that start to look like religious rituals : )#2021-07-1116:24thhellercan't comment on any react-native parts and would recommend following their docs#2021-07-1116:24thhellerI got it running once when I setup that example. I have not launched it since and probably won't for a while 😛#2021-07-1116:30Arondo you publish to mobile some other way or not very much?#2021-07-1119:06thhellerjust regular web stuff#2021-07-1204:02agilecreativityHi I am trying to build simple node-js library and keep getting the following error when trying to use it in non-dev mode:
Cannot find module 'uuid'\\nRequire stack

my `shadow-cljs.edn` is something like:
{:deps {:aliases [:cljs]} :builds {:handler {:target :node-library :output-to "handler.js" :exports-var example-demo.core/exports :compiler-options {:infer-externs :auto}} :test {:target :node-test :output-to "test.js"} :autotest {:target :node-test :output-to "test.js" And this only happen when I am trying this via
clojure -M:cljs:shadow release handler

My cljs file look like:
(ns example-demo.core (:require ["uuid" :as uuid])) (println "sample uuid: " (uuid/v4)) ;; this work properly when running in in the dev mode via REPL and check the eval the code via editor (defn sample [] ;; ... some code that return js/Promise ) (def exports #js {:sample sample}) I am trying to read through the documentation still I am not sure if someone know if something that I may have missed? Thanks
#2021-07-1209:53Karol Wójcik@agilecreativity 😄 I'm seeing what you're trying to do here 😄#2021-07-1213:07agilecreativityHi @UJ1339K2B yeah you got me, still waiting for holy-lambda to support nodejs 😄#2021-07-1213:09Karol WójcikNodejs support will happen in the end of the year most probably. But why not native runtime? It’s significantly faster#2021-07-1213:13agilecreativityAt work, we are heavy user of nodejs at the moment from historical reason. Since we use many library that may not work properly with Graalvm natively so that may be some issue to adopt it.#2021-07-1213:15Karol WójcikOh I see. That’s sad ;( #2021-07-1213:16agilecreativityI really love the workflow from Clojure though compare to the ClojureScript one.#2021-07-1213:17Karol WójcikWhich libraries hold you in Nodejs if I could ask? Cause maybe it’s possible to interop with those via GraalVM Polyglot API#2021-07-1213:18agilecreativityLike we are using things that talks to Redis for example, I have not yet checked if Carmine is compatible with GraalVM for example.#2021-07-1213:22agilecreativityOr things like honey-sql, etc#2021-07-1213:22agilecreativitybut just checked it seems Carmine is compatible with GraalVM https://github.com/BrunoBonacci/graalvm-clojure/tree/master/carmine#2021-07-1213:38Karol WójcikOh but you're mentioning now the stuff on Clojure side. I mean that in GraalVM native-image you do interop with node.js#2021-07-1213:38Karol Wójcikhoneq-sql should work just fine I think#2021-07-1206:11thheller@agilecreativity node builds by defaults do NOT bundle their dependencies. so whereever you run it you'll need the proper node_modules as well#2021-07-1213:08agilecreativityThanks @thheller will give that a try.#2021-07-1206:12thhellerif you want something self-contained you can post-process the release file with https://github.com/vercel/ncc#2021-07-1207:01David PhamHello :) In the newest version of shadow-cljs, i think it gets confused to which node_modules folder to use dependencies. I am using deps.edn to refer to an local deps, which also contains a node_modules folder and shadow-cljs extract the js deps from the dependencies node_modules folder, which cause the build to fail as it can’t get js files outside the project. Is it a problem on my side?#2021-07-1207:01David PhamThe problem is resolved when I remove/rename the node_modules folder.#2021-07-1207:01David PhamIn the dependency lib.#2021-07-1207:01thhelleronly the node_modules of your project are considered. it does not look at node_modules of libraries, unless you specifically configured that via :js-packages-dirs#2021-07-1207:03David PhamNope, I did not such things 😕#2021-07-1207:03thhellerso what you mean by "it gets confused"?#2021-07-1207:05David PhamI got the following mistakes
Build failure:
Failed to inspect file
  /home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js

it was required from
  /home/david/Documents/transparency/frontend/src/cljs/transparency/reporting/user_input.cljs

files outside the project are not allowed: /home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js
{:file #object[java.io.File 0x6910e23c "/home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js"]}
ExceptionInfo: files outside the project are not allowed: /home/david/Documents/transparency/frontend/node_modules/@date-io/date-fns/build/index.js
#2021-07-1207:05David PhamWhile my main project is at /home/david/Documents/whatever/#2021-07-1207:07David PhamDoes it make sense?#2021-07-1207:08thhellerand how did you require it?#2021-07-1207:09David Phamin the deps.edn file, under the :deps key#2021-07-1207:09David Phamtransparency/transparency {:local/root "lib/transparency"}#2021-07-1207:09David Pham(with a simlink)#2021-07-1207:09thhellerdeps.edn does not manage or affect JS depdencies in any way. so whatever you do there does NOT affect this#2021-07-1207:09thhellerI'm asking how you required it in your code, in your cljs ns :require?#2021-07-1207:10David Pham(:require ["@date-io/date-fns" :as date-fns-utils])#2021-07-1207:10David Phamthis?#2021-07-1207:10thhellerdo you have any other config that might affect this? :js-options :resolve or so?#2021-07-1207:10David PhamI use deps.cljs under the root of the source?#2021-07-1207:10thhellerin shadow-cljs.edn#2021-07-1207:11David Phamof the main project?#2021-07-1207:11thhelleryes#2021-07-1207:11thhelleris the node_modules (or anything in it) symlinked?#2021-07-1207:11David Phamnope, nothing#2021-07-1207:11David Phamit is a plain npm i --save#2021-07-1207:12David PhamAs I said, if I remove the node_modules from the dep library, it works.#2021-07-1207:12thheller/home/david/Documents/transparency/frontend this is your project folder?#2021-07-1207:12David Phamthis is the lib folder#2021-07-1207:13David Pham/home/david/Documents/whatever would be the project folder#2021-07-1207:13thhelleroh, hang on. I think I know what might be happening#2021-07-1207:28thheller@neo2551 try shadow-cljs 2.15.1, should be ok again#2021-07-1207:34David PhamThanks a lot! Sorry for disturbing#2021-07-1207:38thhellerthanks for the report 🙂#2021-07-1214:28Simonhow do i use "https" node.js standard library to make a request to an external API? If there is another library better suited for ClojureScript what would that be?#2021-07-1214:29Simon
(defn book_consultation [req, res]
  ;/book_consultation
  (let [query (.. req -query)
        email (.-email query)]
    (.on
     (.get
      https
      ""
      (fn [resp]
        (let [data ""]
          (.on
           resp
           "end"
           (fn [] (.send res (.. (.parse js/JSON data) -results))))))
      "error"
      (fn [err] (.log js/console (str "Error: " (.-message err))))))))
#2021-07-1214:29SimonThis is the code i have, but it can't infer the target type:
--------------------------------------------------------------------------------
  12 |       ""
  13 |       (fn [resp]
  14 |         (let [data ""]
  15 |           (.on
-----------------^--------------------------------------------------------------
 Cannot infer target type in expression (. resp on "end" (fn [] (.send res (.. (.parse js/JSON data) -results))))
--------------------------------------------------------------------------------
  16 |            resp
  17 |            "end"
  18 |            (fn [] (.send res (.. (.parse js/JSON data) -results))))))
  19 |       "error"
--------------------------------------------------------------------------------
#2021-07-1214:31Simoncould i use the cljs.core.async.macros :refer [go] macro? Or would that not work on node.js?#2021-07-1214:38Justin ChandlerI'm not the best resource to be asking, so someone can correct me if I'm wrong, but 1. if it says cannot infer target type when using a . function, I'm pretty sure it means you're missing a ^js in front of the variable in question, in your case it'd be fn [^js resp] and ^js res wherever it's declared and 2. you should be able to use macros in both browser and node.js just fine#2021-07-1214:48SimonYes this is also what i want to use, since i already use it on the client side. Although i run into this error:
>  /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:177
>      return new XMLHttpRequest();
>      ^
>  ReferenceError: XMLHttpRequest is not defined
>      at goog.net.DefaultXmlHttpFactory.createInstance (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:177:5)
>      at Object.goog.net.XmlHttp (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xmlhttp.js:37:36)
>      at goog.net.XhrIo.createXhr (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xhrio.js:682:42)
>      at goog.net.XhrIo.send (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/goog/net/xhrio.js:530:20)
>      at Object.cljs_http$core$xhr [as xhr] (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/core.cljs:107:5)
>      at cljs_http$core$request (/Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/core.cljs:150:5)
>      at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:125:7
>      at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:207:7
>      at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:223:7
>      at /Users/simonchristensen/Documents/Developer/movenation/calculator/.shadow-cljs/builds/firebase-functions/dev/out/cljs-runtime/cljs_http/client.cljs:104:7
With this code:
(defn book_consultation [req, res]
  ;/book_consultation
  (let [query (.. req -query)
        email (.-email query)]
    (go (let [response (<! (http/get ""
                                     {:with-credentials? false}))
              name (get-in response [:body :results :name :first])])
        (.send res (str "name is: " name)))))
#2021-07-1214:50SimonIt returns a XMLHttpRequest. Which makes sense, but does someone know how to call it correctly?#2021-07-1214:54Simonyeah it's in node.js#2021-07-1215:13SimonIt works! Thank you!
(ns functions.index
  (:require ["firebase-functions" :as fun]
            ["https" :default https]
            [cljs.core.async :refer [<!]] [cljs-http.client :as http]
            [cljs.nodejs :as nodejs]
            ["xhr2" :as xhr2])
  (:require-macros [cljs.core.async.macros :refer [go]]))

(set! js/XMLHttpRequest xhr2)

(defn book_consultation [req, res]
  ;/book_consultation
  (let [query (.. req -query)
        email (.-email query)]
    (go (let [response (<! (http/get ""
                                     {:with-credentials? false}))
              name (get-in response [:body :results 0 :name :first])]
          (.send res (str "name is: " name))))))
#2021-07-1215:15Simonyeah I just thought it would be more clear if i declare all the imports in require. I am aware i could write (set! js/XMLHttpRequest (nodejs/require "xhr2"))#2021-07-1215:17Simonyeah but then i would be able to write (set! js/XMLHttpRequest xhr2)#2021-07-1214:43Justin ChandlerAlso as a side note, I really have to compliment the response time of @thheller and @borkdude, the speed and amount of support you both give is amazing, as are your projects! I've been using babashka and shadowCLJS for a while now and I never knew both of you were so accessible hahaha In any case, thank you for your hard work, it's appreciated!#2021-07-1216:12sova-soars-the-sora😄 the clojure community rocks. bowie#2021-07-1219:43zendevil.ethI’m running the tests like so: shadow-cljs release test and this is my config file:
{:nrepl {:port 7002}
 :builds
 {:app
  {:target     :browser
   :output-dir "target/cljsbuild/public/js"
   :asset-path "/js"
   :modules    {:app {:entries []}}
   :devtools   {:watch-dir "resources/public"
                :preloads  [re-frisk.preload]}
   :dev        {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
   :release    {}}
  :test {:target   :node-test
         :test-dir "target/node-tests.js"
         :autorun  true
         }}
 :lein  true}
And I’m getting this error: https://gist.github.com/zendevil/6f29c2ac64d8be067e5e5f525b2f059e How can I fix this?
#2021-07-1220:02thheller@ps I'm guessing target/node-tests.js is an actual file? when it should be a directory?#2021-07-1220:06zendevil.eththis is a snippet from the user guide:
{...
 :builds
 {:test
  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true}}}
#2021-07-1220:06thhelleroh right node-test#2021-07-1220:06thhellerso yeah. do you see the difference? you are missing :output-to#2021-07-1220:06thheller:test-dir is from :browser-test only#2021-07-1313:21Pepijn de VosHow do I use bootstrap-icons npm package with shadow-cljs? Basically the css file somehow needs to end up in the public folder I guess...#2021-07-1317:20thhelleryeah shadow-cljs doesn't handle css. either copy the file manually or setup some css tools like postcss to handle that for you#2021-07-1407:53Pepijn de VosTurns out there is a react package that I could easily tie into reagent. Just inserts raw SVG rather than an icon font. Works like a charm.#2021-07-1407:56jajuInteresting - which one is this?#2021-07-1407:57Pepijn de VosPff something like bootstrap-icons-react#2021-07-1503:05awb99I have a stupid question on the lazy loader: it works AMAZING with ui functions. But I also have normal utility functions that need to be lazy loaded. And most of this functions are synchronous. So for this functions I cannot return a different ui while they are loading. I tried many options, but it seems I cannot block util an async call is finished. Any ideas?#2021-07-1504:44Aronthe point of async is that you don't block : )#2021-07-1505:19thheller@hoertlehner its impossible to block so you won't find a solution to that other than going async#2021-07-1522:14awb99thanks @U05224H0W#2021-07-1507:43Afonso TsukamotoHi! I started developing a clojurescript app that needs to target nodejs using shadow-cljs. One of the dependencies I have is macchiato for the web-server which uses lein-npm to manage npm dependencies. Is there a way to get shadow-cljs to manage these dependencies? Currently, to make it work, I copied the dependencies to the package.json but this is mostly an hard to maintain hack#2021-07-1509:04Chris McCormickHi all, I was wondering if it's possible to get source-maps in watch mode for a :target :node-script? I want to see the expressjs tracebacks in terms of my cljs code. I tried putting this in my shadow-cljs.edn
:compiler-options {:source-map true
                                      :source-map-inline true}
But the only way I can get source maps is if I do release mode with --debug. Any help is much appreciated! 🙏
#2021-07-1516:22thheller@chris358 source maps are enabled by default for watch in :node-script? do you have shadow-cljs installed in the project? you need the source-map-support package, either intalled directly or indirectly via shadow-cljs#2021-07-1600:05Chris McCormickAh ok, yes, I am successfully getting source-mapped tracebacks into cljs code now with no changes. I am not sure what made me think it wasn't working. facepalm sorry for the noise!#2021-07-1516:23thhellerthere is nothing else you need to activate since it should be enabled by default#2021-07-1516:24thheller@afonsotsukamoto macchiato would need to provide a deps.cljs file listing the :npm-deps. not sure if it does. the leinigen files won't do anything#2021-07-1613:34kennytiltonThis is weird. Trying out Helix examples https://github.com/aiba/helix-react-native-nav back on an older MBPro I get this (indirectly from make shadow: $ clj -m shadow.cljs.devtools.cli watch dev Error building classpath. Could not find artifact com.datomic:dev-local:jar:0.9.203 in central (https://repo1.maven.org/maven2/) I an guessing shadow does not use Datomic. But…who is looking for that dev-local jar? Wish I knew mvn. (I’ll start researching that,) Now once upon a recent time I had installed some Datomic tools, so I am guessing one of them is trying to reach that dev-local.jar, but I do not recall what that could be or how to track it down and get rid of it. Not doing Datomic these days.#2021-07-1615:04thheller@hiskennyness not a clue. shadow-cljs definitely doesn't use anything from datomic. maybe you put something in ~/.clojure/deps.edn or so?#2021-07-1615:07kennytiltonThx, @thheller, that was it. I never use that file so it was out of mind. ISTR the Datomic install directions suggesting that and like a dummy I went ahead and created a global dependency on a test jar. :face_palm:#2021-07-1715:59AppleI use a user.clj to start shadow-cljs and clj repl is right there. One can jump from cjl repl into cljs repl. Is there a way to start perhaps a separate cljs repl? Or what's the best way to allow emacs to connect to both clj and cljs repl?#2021-07-1721:21AppleHuh silly me. It's just cider-connect-cljs.#2021-07-1810:43kennytiltonLooking in shadow-cljs.edn here https://github.com/PEZ/rn-rf-shadow we see the comment: "; In a real app consider using deps.edn instead." Is there something we should know, @pez? Some deficit in shadow-cljs? Performance, build quality, app size? Thx! 🙏#2021-07-1810:55pezIirc, that comment originates from @U05224H0W#2021-07-1811:11pezI don't think it is either of those reasons, though. Rather functionality. deps.edn is a purpose built dependency management tool. Shadow can take care of some of that for you, but I think it is a non-goal to make that pay full featured. #2021-07-1811:16pezIt's easy enough to just move it out to deps.edn if you outgrow what shadow offers.#2021-07-1813:55thhellerthat comment definitely did not come from me 😛#2021-07-1813:59thhellerif you ever need git dependencies or the :local/root stuff then it makes sense to use deps.edn#2021-07-1814:00thhellerotherwise they are pretty similar. you definitely don't gain any performance, build quality or app size advantages from using deps.edn. none of the is affected by which tool you use to build the classpath#2021-07-1815:24pezNote to self: I should remove that file. #2021-07-1815:56kennytilton:rolling_on_the_floor_laughing: I definitely checked if that comment was from you or @U05224H0W!#2021-07-1816:25Drew Verleegreetings, i'm asking this question the problem with the library might be understood best through the differences between shadow and figwheel. the expression (shadow.cljs.devtools.api/compile :docs {:verbose true) with the shadow build :modules {:main {:entries [doc] and that entrie/ns being
(ns docs
  (:require [ :as app]
            ;; must require dynadoc.core so dynadoc's frontend can be built
            dynadoc.core
            [rum.core :as rum])
  (:require-macros [dynadoc.example :refer [defexample]]))
Return's the error The required namespace "cljsjs.rangy-core" is not available, it was required by "paren_soup/core.cljs". If i look at the namespace paren_soup/core.cljs it does require it right here https://github.com/oakes/paren-soup/blob/15f55ebb40ee30f75ca960d381ddebd094a76f3d/src/paren_soup/core.cljs#L6 but i'm unsure why it would "not available". Any advice on how to troubleshoot this would be appreciated. Things to i have noticed: • the author's minimal example of how to use the overall functionality used figwheel here: https://github.com/oakes/dynadoc-examples/tree/master/basic-deps-cljs uses fighwheel with compiler optimizations set to :simple, which i have also enabled. • if i remove the require on the dynadoc.core library in the cljs ns (e.g https://github.com/oakes/dynadoc-examples/blob/b23ef1003365d238847d1f1ea3f6d73149ae0bac/basic-deps-cljs/src/basic_deps_cljs/docs.cljs#L4) then it will compile, but the examples don't properly eval (e.g (defexample conj (conj [] 1)) doest show the expression result [1]. So i assume the comment on the code for the dyadoc.core require is still relevent. "must require dynadoc.core so dynadocs frontend can be built". My intuition is that maybe shadow is pruning out cljsjs.rangy-core because it's never directly used? but overall, I'm really unsure where to look.
#2021-07-1817:17thhellershort version: shadow-cljs does not support CLJSJS packages so it won't work with anything using those#2021-07-1817:18thhellerbut usually its pretty easy fix https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2021-07-1817:18thhellerlonger version https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html#2021-07-1817:18thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-going-forward.html#2021-07-1817:18thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html#2021-07-1819:05Drew Verlee👍#2021-07-1819:21zendevil.ethI’m seeing a dependency shadow watch says wasn’t installed:
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required JS dependency "querystring" is not available, it was required by "node_modules/url/url.js".
even after installing with npm
#2021-07-1823:49Drew Verlee@U01F1TM2FD5 i'm not sure, but this looks very similar to my problem in essence. It's possible the issue is because shadow-cljs does not support CLJSJS packages so it won't work with anything using those. but usually its  pretty easy fix https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs You can read about it here: https://code.thheller.com/blog/shadow-cljs/2017/09/15/js-dependencies-the-problem.html I'm not sure that's the heart of the issue but worth checking#2021-07-1905:40thheller@U0DJ4T5U1 this is a npm package, not a CLJSJS package#2021-07-1905:41thheller@U01F1TM2FD5 you need to have shadow-cljs installed in the project, so npm install shadow-cljs#2021-07-1905:43thhellerthat'll install the node-libs-browser polyfills package which polyfills node built-in packages for the browser#2021-07-1911:34borkdudeDoes shadow perhaps add support for js/NodeList as seqable by default?
(seq (.getElementsByClassName js/document "terminal"))
It seems to just work in a project compiled with shadow, so I wondered about this.
#2021-07-1912:20jkxyzIt seems like NodeList had an iterator property added in 2016 which is the same as NodeList#values - so it satisfies cljs.core/js-iterable?#2021-07-1913:02borkduderight#2021-07-1916:37thhelleryeah thats it. shadow doesn't add anything special to anything on the JS side#2021-07-1911:41borkdudeHmm, no it seems to work with newer vanilla CLJS as well#2021-07-1916:25Drew VerleeI'm trying to follow these instructions here: https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs Would this shimmed file reside in my project or in the project that was using cljsjs? e.g myapp --- pulls in deps from ---> a_lib which has the (:require .... [cljssjs...]) and deps.edn with :deps cljsjs.... my first thought was that it would need to be the lib which uses it, but the docs imply shadow-cljsjs is fixing it at the application level.#2021-07-1916:37thheller@drewverlee anywhere on the classpath. doesn't matter really, just put it in your project#2021-07-1916:42Drew VerleeThanks! So ns/deps farther up the tree win? I feel like I should know this.#2021-07-1916:43thhellerthe classpath wins#2021-07-1916:43thhellerno such thing as a tree there#2021-07-1916:43thhellerhttps://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-07-2009:35kwrooijenHello (not sure if this is the proper place to post this so apologies if that's not the case). I added a NPM package and I'm getting the following Closure Compiler error:
Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.es.min.js:10636
Duplicate let / const / class / function declaration in the same scope is not allowed.
I assume this is an issue with the library code itself (as the error states). I'm just wondering if there's a "quick and dirty" fix to solve this, or if my only option is to fork and fix the dependency? The dependency: https://github.com/MrRio/jsPDF
#2021-07-2014:39thhellerno easy fix unfortunately. well besides using another "dist" they ship. maybe the commonjs version doesn't have that issue? assuming of course that they ship multiple versions#2021-07-2015:35sheluchinI'm getting this error after connecting my editor to my REPL:
e iced repl :main --force-shadow-cljs --with-cljs -A:dev
OK: CLJS option is enabled.
OK: shadow-cljs project is detected
OK: For shadow-cljs project, start watching instead of starting REPL.
shadow-cljs - config: /project/shadow-cljs.edn  cli version: 2.8.64  node: v12.18.0
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.11.23 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :main
[:main] Configuring build.
[:main] Compiling ...
GUARDRAILS IS ENABLED. RUNTIME PERFORMANCE WILL BE AFFECTED.
Mode: :runtime  Async? false  Throw? false
Guardrails was enabled because the CLJS Compiler config enabled it
[:main] Build completed. (287 files, 0 compiled, 0 warnings, 9.00s)
[2021-07-20 11:27:28.995 - WARNING] :shadow.cljs.devtools.server.nrepl-impl/init-ns-ex - {:init-ns sheluchin.user}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Unexpected error macroexpanding defrecord at (rewrite_clj/node/comment.clj:6:1). #:clojure.error{:phase :macroexpansion, :line 6, :column 1, :source "rewrite_clj/node/comment.clj", :symbol defrecord}
    clojure.lang.Compiler.macroexpand1 (Compiler.java:7019)
    clojure.lang.Compiler.macroexpand (Compiler.java:7075)
    clojure.lang.Compiler.eval (Compiler.java:7161)
    clojure.lang.Compiler.load (Compiler.java:7636)
    clojure.lang.RT.loadResourceScript (RT.java:381)
    clojure.lang.RT.loadResourceScript (RT.java:372)
    clojure.lang.RT.load (RT.java:459)
    clojure.lang.RT.load (RT.java:424)
    clojure.core/load/fn--6839 (core.clj:6126)
    clojure.core/load (core.clj:6125)
    clojure.core/load (core.clj:6109)
    clojure.core/load-one (core.clj:5908)
Caused by:
NullPointerException 
    clojure.lang.Compiler.maybeResolveIn (Compiler.java:7424)
    clojure.core/ns-resolve (core.clj:4370)
    clojure.core/ns-resolve (core.clj:4359)
    clojure.core/resolve (core.clj:4372)
    clojure.core/resolve (core.clj:4372)
    clojure.core/map/fn--5866 (core.clj:2753)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.RT.seq (RT.java:535)
    clojure.core/seq--5402 (core.clj:137)
    clojure.core/reduce1 (core.clj:930)
    clojure.core/set (core.clj:4113)
There is some suggestion that the issue is coming up because I'm including CLJ function calls in CLJS and shadow doesn't know what to do with it: https://clojurians.slack.com/archives/C68M60S4F/p1626790359069100?thread_ts=1625841427.419200&amp;cid=C68M60S4F Any suggestions for a fix? I can't seem to get around this one.
#2021-07-2015:43thhellershadow-cljs is nowhere on that stacktrace. no clue what your REPL is doing#2021-07-2015:46thhellerits not part of shadow-cljs compilation. that completed. so your REPL is trying to do something but I can't tell what#2021-07-2019:48agI'm having hard time connecting to cljs REPL, I do this:
(require '[shadow.cljs.devtools.server :as server])
(require '[shadow.cljs.devtools.api :as shadow])
(server/start!)
(shadow/watch :app)
(shadow/nrepl-select :app)
and everything but the last step works fine. The last step fails with :missing-nrepl-middleware. Where should I dig?
#2021-07-2020:03thhellerthe nrepl server you connected do is missing the middleware#2021-07-2020:03thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2021-07-2020:14agOh, that's what I missed. Thank you Thomas!#2021-07-2111:07Timofey SitnikovHello Clojurians. I run my development environment in a VirtualBox on my Mac with 8GB of RAM. Because of amazing thing like clojure_lsp, I am out of memory. I am developing using Fulcro Library, and it seems to require tons of dependencies. Are there some ideas of how I can reduce shadow-cljs memory usage? Is one JVM better than others? Is there a way to run in a mode that reduces the memory usage.#2021-07-2114:43awb99I am trying to use "vega-loader-arrow" "0.0.10" in my deps.cljs. And when I inclued it in a cljs file I get the following error in the browser: TypeError: Cannot read property 'ByteBuffer' of undefined at Object.shadow$provide.module$node_modules$apache_arrow$util$buffer (buffer.js:23) at shadow.js.jsRequire (js.js:66) at Object.shadow$provide.module$node_modules$apache_arrow$io$adapters (adapters.js:20) at shadow.js.jsRequire (js.js:66) at Object.shadow$provide.module$node_modules$apache_arrow$Arrow_dom (Arrow.dom.js:21) at shadow.js.jsRequire (js.js:66) at eval (vega-loader-arrow.js:3) at Object.shadow$provide.module$node_modules$vega_loader_arrow$build$vega_loader_arrow (vega-loader-arrow.js:2) at Object.shadow.js.jsRequire (js.js:66) at Object.shadow.js.require (js.js:113)#2021-07-2114:43awb99does this error mean thst this npm package module type is not supported?#2021-07-2114:48awb99the error comes from "flatbuffers" npm dependency#2021-07-2114:48awb99which is transient#2021-07-2116:25thheller@timofey.sitnikov you can always limit the amount of memory shadow-cljs uses. assuming you use only shadow-cljs.edn you can set :jvm-opts ["-Xmx600m"] to limit to 600mb. that is usually plenty unless you run like 5 watch in parallel#2021-07-2116:27thheller@hoertlehner it means that it Cannot read property 'ByteBuffer' of undefined. why that is so I do not know, don't know what it is trying to access that on. as always can't say much more without a reproducible repo#2021-07-2209:28Timofey Sitnikov@thheller OK, I am trying it. Also I am trying Open J9 JVM, it does seem to trade speed for size, but that may be better than having to live on disk for memory.#2021-07-2209:30Timofey SitnikovAhh, with lower memory I get this:
[2021-07-22 05:26:30.681 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
OutOfMemoryError Java heap space
        java.util.Arrays.copyOfRange (Arrays.java:4061)
        java.lang.StringUTF16.newString (StringUTF16.java:1025)
        java.lang.StringBuilder.toString (StringBuilder.java:449)
        clojure.core/str (core.clj:555)
        clojure.core/str/fn--5483 (core.clj:559)
        clojure.core/str (core.clj:557)
        clojure.core/str (core.clj:546)
        shadow.build.targets.browser/flush-unoptimized-module-eval (browser.clj:540)
        shadow.build.targets.browser/flush-unoptimized-module-eval (browser.clj:501)
        shadow.build.targets.browser/flush-unoptimized-module (browser.clj:669)
        shadow.build.targets.browser/flush-unoptimized-module (browser.clj:664)
        shadow.build.targets.browser/flush-unoptimized/fn--40713/fn--40715 (browser.clj:691)
738m seems to work OK.
#2021-07-2216:23thheller@timofey.sitnikov interesting. how big is your build? I have done tests with as little as 300m working fine for test builds#2021-07-2410:42Timofey Sitnikov@thheller, how do I know how big is the build? Is that the size of the output js file? I think it is 22 MB#2021-07-2412:37thhellergenerate a build report https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2021-07-2412:38thhellerwatch size generally is fairly large. although 22mb is quite a lot even for watch#2021-07-2318:10Pavel KlavíkHi, I am trying to get Shadow-cljs running on a computer I haven't used for a while. I have updated npm dependencies using npm install, even run npm install -g shadow-cljs, after running shadow-cljs watch client, I get the following error:
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch client
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.14.6 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build failure:
The required namespace "goog" is not available, it was required by "devtools/preload.cljs".
#2021-07-2318:12thhellerweird. I'm guessing version conflict. you are using lein so check that you get the correct clojurescript, closure-compiler, closure-library versions#2021-07-2318:13thhellerthe npm updates basically do nothing when using lein, so check project.clj instead#2021-07-2318:13Pavel KlavíkThis is in project.clj:
[thheller/shadow-cljs "2.14.6"]
                 [org.clojure/clojurescript "1.10.866"
                  :exclusions [com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library
                               org.clojure/google-closure-library-third-party]]
#2021-07-2318:15thhellerrun shadow-cljs clj-repl then ( "goog/base.js")#2021-07-2318:16Pavel Klavík
shadow.user=> ( "goog/base.js")
#object[java.net.URL 0x5787e5d4 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/org/clojure/google-closure-library/0.0-20201211-3e6c510d/google-closure-library-0.0-20201211-3e6c510d.jar!/goog/base.js"]
#2021-07-2318:17thhellerlooks fine#2021-07-2318:23Pavel Klavíktried to update to the latest version and the problem remains:
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.15.2 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build failure:
The required namespace "goog" is not available, it was required by "devtools/preload.cljs".
#2021-07-2318:23thhelleryeah not a clue. try the above but with slurp, see if its empty or something#2021-07-2318:24thhellerthat file provides goog and it appears to be there? maybe try wiping .shadow-cljs although that self wipes on versions updates so unlikely to help#2021-07-2318:26Pavel Klavíkthe content slurps just fine#2021-07-2318:27thhellertry setting :log {:level :debug} in shadow-cljs.edn. maybe that logs something useful#2021-07-2318:28thhellernever seen this problem before. can't really think of anything that could cause this.#2021-07-2318:28thhellerjust in case check ( "cljs/core.cljs") and ( "com/google/javascript/jscomp/Compiler.class")#2021-07-2318:29thhellerjust to verify they are all the correct expected versions#2021-07-2318:30Pavel Klavík
shadow.user=> ( "cljs/core.cljs")
#object[java.net.URL 0x391d2130 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/org/clojure/clojurescript/1.10.879/clojurescript-1.10.879.jar!/cljs/core.cljs"]
shadow.user=>  ( "com/google/javascript/jscomp/Compiler.class")
#object[java.net.URL 0x390c8c58 "jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20210505/closure-compiler-unshaded-v20210505.jar!/com/google/javascript/jscomp/Compiler.class"]
#2021-07-2318:30thhellerlooks fine#2021-07-2318:30Pavel Klavík
C:\Shared\orgpad>shadow-cljs watch client
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch client
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
[2021-07-23 20:29:33.876 - FINE] :shadow.cljs.devtools.server/clj-check - {:cli-pid "4900"}
[2021-07-23 20:29:34.274 - FINE] :shadow.cljs.devtools.server.nrepl/config - {:port 9000}
[2021-07-23 20:29:34.597 - FINE] :shadow.remote.relay.local/client-hello - {:client-id 1, :client-info {:connection-info {}, :since #inst "2021-07-23T18:29:34.588-00:00", :type :runtime, :lang :clj, :desc "JVM Clojure Runtime"}}
shadow-cljs - HTTP server available at 
[2021-07-23 20:29:34.617 - FINE] :shadow.cljs.devtools.server.dev-http/http-serve - {:handler-state {:mime-mappings #object[io.undertow.util.MimeMappings 0x2d7166ee "
#2021-07-2318:31thhellerhmm yeah nothing#2021-07-2318:31thhellertry creating an empty project npx create-cljs-project dummy cd dummy npx shadow-cljs browser-repl#2021-07-2318:34Pavel Klavíkit seems to work:
shadow-cljs - config: C:\Shared\dummy\shadow-cljs.edn
shadow-cljs - updating dependencies
Retrieving org/clojure/core.async/1.3.618/core.async-1.3.618.jar from 
Retrieving org/clojure/tools.reader/1.3.6/tools.reader-1.3.6.jar from 
Retrieving commons-io/commons-io/2.10.0/commons-io-2.10.0.jar from 
Retrieving expound/expound/0.8.9/expound-0.8.9.jar from 
Retrieving ring/ring-codec/1.1.3/ring-codec-1.1.3.jar from 
Retrieving crypto-random/crypto-random/1.2.1/crypto-random-1.2.1.jar from 
Retrieving thheller/shadow-cljs/2.15.2/shadow-cljs-2.15.2-aot.jar from 
Retrieving ring/ring-core/1.9.4/ring-core-1.9.4.jar from 
shadow-cljs - dependencies updated
shadow-cljs - server version: 2.15.2 running at 
shadow-cljs - nREPL server started on port 62056
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build completed. (119 files, 118 compiled, 0 warnings, 11.46s)
cljs.user=>
#2021-07-2318:35thhellerand in your lein project? npx shadow-cljs browser-repl I mean?#2021-07-2318:37Pavel Klavíkalso fails:
[:browser-repl] Configuring build.
[:browser-repl] Compiling ...
[:browser-repl] Build failure:
The required namespace "goog" is not available, it was required by "devtools/preload.cljs".

[2021-07-23 20:37:08.192 - FINE] :shadow.remote.relay.local/client-hello - {:client-id 3, :client-info {:connection-info {}, :since #inst "2021-07-23T18:37:08.191-00:00", :type :repl-session, :build-id :browser-repl, :proc-id "de1528ef-bc61-4bb8-869d-c0e23ee42dff"}}
cljs.user=>
#2021-07-2318:38thhellerok that narrows it down somewhat I guess? I don't know to what though 😛#2021-07-2318:38Pavel Klavíkthis is how shadow-cljs.edn looks:
{:lein     true
 :jvm-opts ["-Dfile.encoding=UTF8" "-Xmx2G"]
 :nrepl    {:port 9000}
 :ssl      {:keystore "keystore.jks"
            :password "openpassword"}
 :log      {:level :debug}
 :builds   {:client     {:target           :browser
                         :output-dir       "resources/public/js/compiled"
                         :asset-path       "/js/compiled"
                         :module-loader    true
                         :modules          {:shared {:entries []}
                                            :main   {:init-fn    orgpad.client.core/init
                                                     :depends-on #{:shared}}
                                            :admin  {:entries    [orgpad.client.views.administration.core]
                                                     :depends-on #{:main}}
                                            :layout {:entries    [orgpad.client.layout.webworker.core]
                                                     :depends-on #{:shared}
                                                     :web-worker true}}
                         :compiler-options {:infer-externs      :auto
                                            :output-feature-set :es6}
                         :devtools         {:after-load     orgpad.client.core/mount-root
                                            :before-load    orgpad.client.core/stop-web-workers
                                            :watch-dir      "resources/public"
                                            :browser-inject :main
                                            :loader-mode    :eval}}
            :landing    {:target     :browser
                         :output-dir "landing/resources/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.landing.dev/init}}
                         :devtools   {:http-root      "landing/resources"
                                      :http-port      3500
                                      :after-load     orgpad.landing.dev/mount-root
                                      :watch-dir      "landing/resources"
                                      :browser-inject :main}}
            :emails     {:target     :browser
                         :output-dir "emails/js"
                         :asset-path "/js"
                         :modules    {:main {:init-fn orgpad.server.email.dev/init}}
                         :devtools   {:http-root      "emails"
                                      :http-port      3600
                                      :after-load     orgpad.server.email.dev/mount-root
                                      :watch-dir      "emails"
                                      :browser-inject :main}}
            :screenshot {:target           :node-script
                         :main             orgpad.screenshot.core/main
                         :output-to        "screenshot/screenshot.js"
                         :devtools         {:autoload true}
                         :compiler-options {:optimizations :simple}}}}
#2021-07-2318:38thhellermaybe try commenting out the devtools dependency#2021-07-2318:39thhellerbuild configs don't matter when browser-repl also fails#2021-07-2318:39Pavel Klavíkthis is project.clj:
(defproject orgpad "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [org.clojure/tools.cli "1.0.206"]
                 [com.taoensso/sente "1.16.2"]
                 [com.taoensso/timbre "5.1.2"]
                 [bidi "2.1.6"]
                 ; Use epoll on Linux for a lot more efficient polling of incomming packets
                 ; 
                 ; 
                 ; 
                 [io.netty/netty-transport-native-epoll "4.1.25.Final" :classifier "linux-x86_64"]
                 [aleph "0.4.6"]
                 [mount "0.1.16"]
                 [nrepl "0.8.3"]
                 [cprop "0.1.16"]
                 [cheshire "5.10.0"]
                 [clojure.java-time "0.3.2"]
                 [dnsjava/dnsjava "3.3.1"]
                 [org.postgresql/postgresql "42.2.12.jre7"]
                 [luminus-migrations "0.6.7"]
                 [conman "0.8.4"]
                 [expound "0.8.4"]
                 [yogthos/config "1.1.7"]
                 [selmer "1.12.22"]
                 [ring/ring-anti-forgery "1.3.0"]
                 [ring/ring-defaults "0.3.2"]
                 [ring/ring-devel "1.8.0"]
                 [ring/ring-codec "1.1.2"]
                 [ring/ring-json "0.5.0"]
                 [metosin/ring-http-response "0.9.1"]
                 [buddy/buddy-hashers "1.4.0"]
                 [co.deps/ring-etag-middleware "0.2.1"]
                 [bk/ring-gzip "0.3.0"]
                 [com.cognitect/transit-clj "1.0.324"]
                 [ring-basic-authentication "1.0.5"]
                 [ring-oauth2 "0.1.4"]
                 [clj-http "3.11.0"]
                 [hiccup "2.0.0-alpha2"]
                 [com.draines/postal "2.0.4"]
                 [cljc.java-time "0.1.8"]
                 [com.amazonaws/aws-java-sdk-s3 "1.11.1034"]
                 [byte-streams "0.2.5-alpha2"]
                 [camel-snake-kebab "0.4.1"]
                 [bouncer "1.0.1"]
                 [garden "1.3.10"]
                 [orgpad/volcano "0.1.2"]
                 [tea-time "1.0.1"]
                 [com.twelvemonkeys.imageio/imageio-jpeg "3.6.2"]
                 [com.twelvemonkeys.imageio/imageio-tiff "3.6.2"]
                 [com.twelvemonkeys.imageio/imageio-batik "3.6.2"]
                 [net.coobird/thumbnailator "0.4.13"]
                 [org.apache.xmlgraphics/batik-transcoder "1.14"]

                 [thheller/shadow-cljs "2.15.2"]
                 [org.clojure/clojurescript "1.10.879"
                  :exclusions [com.google.javascript/closure-compiler-unshaded
                               org.clojure/google-closure-library
                               org.clojure/google-closure-library-third-party]]
                 [reagent "0.10.0"]
                 [re-frame "0.12.0"]
                 [day8.re-frame/http-fx "v0.2.0"]
                 [hickory "0.7.1"]
                 [venantius/accountant "0.2.5"]
                 [pathetic "0.5.1"]

                 ; Node.js dependencies, should duplicate dependencies from shadow-cljs.edn for Cursive.
                 [macchiato/core "0.2.17"]
                 [macchiato/env "0.0.6"]]

  :plugins [[lein-garden "0.3.0"]
            [lein-ns-dep-graph "0.2.0-SNAPSHOT"]]

  :main orgpad.server.core

  :min-lein-version "2.5.3"

  :source-paths ["src"]

  :clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
                                    "test/js"]

  :resource-paths ["resources"]

  :garden {:builds [{:id           "orgpad"
                     :source-paths ["src"]
                     :stylesheet   orgpad.css.core/orgpad
                     :compiler     {:output-to     "resources/public/css/orgpad.css"
                                    :pretty-print? false}}
                    {:id           "landing"
                     :source-paths ["src"]
                     :stylesheet   orgpad.landing.css.core/landing
                     :compiler     {:output-to     "landing/resources/l/css/landing.css"
                                    :pretty-print? false}}]}

  :profiles
  {:dev     {:jvm-opts       ["-Dconf=dev-config.edn" "-Xmx2G"]
             :dependencies   [[binaryage/devtools "0.9.10"]]
             :plugins        [[lein-doo "0.1.8"]]
             :source-paths   ["env/dev/clj"]
             :resource-paths ["env/dev/resources" "landing/target"]}
   :uberjar {:source-paths   ["env/prod/clj"]
             :omit-source    true
             :main           orgpad.server.core
             :aot            [orgpad.server.core]
             :uberjar-name   "orgpad.jar"
             :prep-tasks     ["clean"
                              ["garden" "once"]
                              ["run" "-m" "shadow.cljs.devtools.cli" "release" "screenshot"]
                              ["run" "-m" "orgpad.landing.build/build!"]
                              ["run" "-m" "orgpad.server.email.build/build!"]
                              ["run" "-m" "orgpad.build/release"]
                              "compile"]
             :resource-paths ["env/prod/resources"]}})
#2021-07-2318:40thhellercomment out [binaryage/devtools "0.9.10"]. don't know why it fails on goog since everything depends on it#2021-07-2318:41thhelleras always I strongly recommend keeping your CLJ and CLJS dependencies separate. either in shadow-cljs.edn or different lein profiles. your setup of everything always is pretty much the worst case for dependency issues#2021-07-2318:43Pavel Klavíkthe error is now different:
[:client] Build failure:
The required namespace "goog" is not available, it was required by "shadow/cljs/devtools/client/console.cljs".
#2021-07-2318:43Pavel KlavíkI can try to put dependencies back into shadow-cljs to see whether it will fix the problem#2021-07-2318:43thhellerno, it is still the same error. it just fails on the first file it tries to compile, which is the :preloads. that one is added by watch, the other is added automatically when devtools are on the classpath#2021-07-2318:45thhellerI don't really have a clue what could cause this. maybe check your lein version? although I don't really know why that would affect anything#2021-07-2318:45thhellerjust trying to limit factors#2021-07-2318:49Pavel Klavíkso after moving dependencies back to shadow-cljs, everything seems to work:
C:\Shared\orgpad>shadow-cljs watch client
shadow-cljs - config: C:\Shared\orgpad\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
NPM dependency "react" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
NPM dependency "react-dom" has installed version "^16.14.0"
"16.13.0" was required by jar:file:/C:/Users/Pavel%20Klavik/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
[2021-07-23 20:48:16.503 - WARNING] TCP Port 9630 in use.
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.15.2 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
Browserslist: caniuse-lite is outdated. Please run next command `npm update`

[:client] Build completed. (1134 files, 1128 compiled, 0 warnings, 57.48s)
#2021-07-2318:51Pavel Klavíkbtw. I don't probably need to have this in my lein dev profile, since it is only used to run our server?
:dependencies   [[binaryage/devtools "0.9.10"]]
#2021-07-2318:53thhellerthe dev profile is used by default unless you are on the jar/uberjar tasks, so it does apply when running shadow-cljs as well#2021-07-2318:53thhellerinteresting that it works without lein#2021-07-2318:54thhellerI don't know what [lein-ns-dep-graph "0.2.0-SNAPSHOT"] is? maybe that does something weird?#2021-07-2319:03Pavel Klavíkthat is just something which produces graphs between namespaces using graph-viz#2021-07-2319:03Pavel KlavíkNot really useful anymore since the project is huge. Maybe I will write output to OrgPad in the future instead.#2021-07-2319:10Pavel KlavíkBtw. concerning the problem where our server was locking js files so they cannot be recompiled Shadow-cljs. I have decided to not serve them by ring-resource middleware, but instead running Shadow-cljs HTTP server and redirecting requests starting with /js/ from our server to Shadow-cljs. It seems to fix the issue.#2021-07-2319:16thhellerhmm good to know#2021-07-2319:17Pavel KlavíkIn the end, it seems cleaner to let Shadow-cljs handle everything concerning these files.#2021-07-2319:18thhellerI never had an issue letting other servers serve my JS. although I never use ring-resource so that might be a factor 😛#2021-07-2320:22Pavel KlavíkHow do you do this? Maybe it would simpler than our solution with redirecting to Shadow-cljs HTTP server.#2021-07-2406:21thhellerSome older projects have nginx in front serving all static files. Others just use JVM Undertow (similar to shadow-undertow but older)#2021-07-2319:20Pavel Klavíkit seems to just use java.io.resource under the hood, so unclear what changed: we didn't do any changes in the code recently, or upgrading any dependencies#2021-07-2319:20Pavel Klavíkmaybe something related to update in Windows since these problems occur randomly on different computers (on my laptop sometimes, on my desktop almost never, much more frequently on another two computers)#2021-07-2319:21thhellermy primary PC is windows so I would have run into this at some point I'd assume#2021-07-2407:16sbHello, if I would like to add for tailwind css a custom parameter, how can I do? `
[:span {:className (str "absolute top-0 right-0 block h-3 w-3 transform -translate-y-1/2 translate-x-1/2 rounded-full ring-2 ring-white" color)}]
Ofc I can a case around of span, but is here easier/nicer solution? (sorry if that is beginner question)
#2021-07-2407:57thhellerI don't understand the question? Assuming color is just a regular string it should be detected as a tailwind class#2021-07-2411:54sbYes, that is regular and don’t detect.. eg color: “bg-teal-400”#2021-07-2411:54sbTherefore I asked this…#2021-07-2411:55sbOk, in this need to work in this way as I thought.#2021-07-2412:02thhelleryou need the whole string as described in the official docs https://tailwindcss.com/docs/optimizing-for-production#writing-purgeable-html#2021-07-2412:06sbYes, I solved in this way. So that is once way! Thanks the link!!#2021-07-2418:39alexdavisI’m trying to use a js component, compiled from a local .jsx file to .js as specified https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects, the only difference being I am using the react-native target. I get the following error when requiring my generated js file:
Uncaught Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault
Is this functionality just not supported in react native or do I need to do something different?
#2021-07-2418:43thhellershould be supported but had issues some versions ago. which version do you use? also did you attempt to load the file over the REPL or was it part of the initial load?#2021-07-2418:51thhellercannot load new npm dependencies over the REPL, need to be loaded by the app (rn metro) first#2021-07-2418:51thhellernamespaces starting with shadow.js.shim.module are the npm requires that are added#2021-07-2418:54alexdavisPart of the initial load, using shadow 2.15.1#2021-07-2418:54alexdavisIt does occur to me though that I’m going from jsx to js to cljs to js again#2021-07-2418:55alexdavismaybe there is a better way?#2021-07-2418:55thhellerdon't know what you mean by that. don't know anything about what you are doing in general so only wild guesses here.#2021-07-2418:57alexdavisI saw this when googling
thheller18:01:52
but you are using react-native anyways so you should figure out a way to let react-native compile the js files and not shadow-cljs
so thought maybe there was a way to skip the babel step
#2021-07-2418:57alexdavisbut maybe I misunderstood#2021-07-2418:57alexdavisI’ll try and make a minimal reproducible example#2021-07-2419:00thhellerthe essence of "Module not provided" errors is that shadow-cljs generates a shadow$provide object entry to each npm dependency. under normal circumstances that is populated before the depdencny is actually accessed#2021-07-2419:01thhellerbut if its not provided it was accessed before that#2021-07-2419:01thhellerwhich in react-native can happen if you do not reload the entire app and just load stuff over the REPL#2021-07-2419:01thhellersince in react-native metro needs to provide those deps and shadow-cljs can't#2021-07-2419:02thhellerand it can only provide them on the initial app load#2021-07-2419:02thhelleryou can access JS dependencies directly using js/require but not via ns#2021-07-2419:03thhellerwell technically you can also load them via the ns but then you'd need to make a node_modules package for those, which might be fine. don't know what kind of files you are trying to load#2021-07-2419:04thhellerie. assuming you have :output-dir "app" you can (js/require "../js/some.jsx") to access the js file directly. again same limitations though, only on initial load#2021-07-2419:05alexdavisI have a standard react app which imports the generated js files via ns like ["../gen/TaskList.js" :refer (TaskList)] , I’ve tried to replicate the same setup in my react native project but actually the generated file is different, even with exactly the same babel command and source file#2021-07-2419:06alexdavisI’m fine with it being on inital load, I’m just trying to import some react components which are written in jsx#2021-07-2419:07thhellerwhy not generate them into a node_modules package and load via ["your-package/TaskList" :refer (TaskList)]"?#2021-07-2419:07alexdavisSure I’ll try that#2021-07-2419:08alexdavisBut the shadow guide does suggest the other approach (generate into src/gen and import that in ns )#2021-07-2419:08thhellermight even be possible to just ust jsx directly without the manual conversion, given thats its react-native#2021-07-2419:09thhellerreact-native is sort of a special case because you have to deal with metro#2021-07-2419:09alexdavisYeah thats what I was thinking earlier, ok I’ll try that first, so make a package containing the jsx files and import it like any other npm module#2021-07-2419:13alexdavisthis is what babel generates btw, just incase there is a bug somewhere
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.TaskList = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _this = this,
    _jsxFileName = "/src/stories/TaskList.tsx";
var TaskList = function TaskList() {
    return _react.default.createElement(_reactNative.View, {
        __self: _this,
        __source: {
            fileName: _jsxFileName,
            lineNumber: 6,
            columnNumber: 5
        }
    }, _react.default.createElement(_reactNative.Text, {
        __self: _this,
        __source: {
            fileName: _jsxFileName,
            lineNumber: 12,
            columnNumber: 7
        }
    }, "Hello, world!"));
};
exports.TaskList = TaskList;
#2021-07-2419:14alexdavisI definitely have @babel/runtime/helpers/interopRequireDefault in node_modules#2021-07-2419:27alexdavisOk I got it to work using (def TaskList (.-TaskList (js/require "../src/gen/TaskList.js"))) with the babel approach, still going to try the npm package way but that at least confirms theres nothing wrong with shadow#2021-07-2419:28alexdavisThanks for the help, I’m slowly learning how this stuff works…#2021-07-2419:29thhellerthat can likely direclty load the jsx too#2021-07-2419:31alexdavisYep it can, nice#2021-07-2419:31alexdavisWould that work in a standard react project?#2021-07-2419:32alexdavisOr does it only work because of the metro bundler#2021-07-2419:32alexdavisI guess the latter, because browsers can’t understand the jsx#2021-07-2419:34thhelleryeah, metro. basically you are using two separate bundlers#2021-07-2419:36alexdavisYeah, its got its downsides for sure but I guess not having another babel process is nice, probably will give nicer errors than doing the jsx -> js conversion pre cljs too#2021-07-2607:50zendevil.ethI’m trying to use this library: https://kiarash-z.github.io/react-modern-calendar-datepicker/docs/getting-started#2021-07-2607:50zendevil.ethand I have [react-modern-calendar-datepicker *:as* DatePicker] in require#2021-07-2607:51zendevil.eth(using reagent) and tried using like [:> DatePicker] and [DatePicker] but getting error:#2021-07-2607:51zendevil.ethreact-dom.development.js:68 Warning: Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.#2021-07-2607:53zendevil.ethand template.cljs:277 Uncaught Error: Assert failed: Invalid Hiccup form: [#js {:Calendar #object[F], :default #object[global], :utils #object[T]}] (in humboi.core.raise_page) respectively#2021-07-2607:53zendevil.ethHow to use DatePicker?#2021-07-2608:49alexdavisUse this table to work out what your require should look like https://shadow-cljs.github.io/docs/UsersGuide.html#js-deps#2021-07-2609:23zendevil.ethThank you. This worked with :default#2021-07-2609:24zendevil.ethHowever, when I use this import 'react-modern-calendar-datepicker/lib/DatePicker.css'; like ["react-modern-calendar-datepicker/lib/DatePicker.css"] I get:
Failed to inspect file
  /Users/prikshetsharma/Desktop/humboi/node_modules/react-modern-calendar-datepicker/lib/DatePicker.css

it was required from
  /Users/prikshetsharma/Desktop/humboi/src/cljs/humboi/core.cljs

Errors encountered while trying to parse file
  /Users/prikshetsharma/Desktop/humboi/node_modules/react-modern-calendar-datepicker/lib/DatePicker.css
  {:line 1, :column 1, :message "primary expression expected"}
#2021-07-2609:26jajuI don’t think you can import/require a css file.#2021-07-2609:43thhellercss is not supported#2021-07-2614:10romdoqIs the :node-library target suitable for code that will be executed in the browser, rather than by node? Are there particular circumstances or edge cases to be aware of?#2021-07-2615:05thhellerit is meant for node so watch and compile won't run in the browser. release only when processed by webpack or so#2021-07-2703:16souenzzoHello I started a library that allow you to run npm install without need a node runtime or npm installed. It's a pure-clojure implementation of an interpreter" of package-lock.json that downloads packages from npm registry and untar it into node_modules. Easy as run (npm/install {:path "."}), or with new -T, clj -T:npm install :path '"."' For me, the advantage of this project is allow me to create advanced compiled cljs without need a nodejs runtime inside my docker image. I would like to know from other cljs developers if this is an interesting lib before continue to work on this project. https://github.com/souenzzo/tools.npm#2021-07-2703:29thheller@souenzzo you should probably make that work based on either package.json or some other kind of config (eg. deps.edn). how would you get a package-lock.json without having npm or node installed in the first place? 😛#2021-07-2711:32souenzzoWell, the idea is that you will have a commited package-lock.json In your local/dev machine you will still use node/npm/etc it's just to simplify the deploy pipeline#2021-07-2703:33thhellernode is also required for some parts of shadow-cljs, so you'll definitely need node for some builds#2021-07-2711:22souenzzocan you provide an example?!#2021-07-2716:38thhelleranything using ESM code in node_modules. it'll run through babel#2021-07-2716:39thhellershould be plenty packages doing this nowadays but can't think of one right now#2021-07-2806:39borkdudeHow can I create a Node CLI tool that allows for optional modules, similar to the modules feature?#2021-07-2806:39borkdudeI’m not sure if modules are supported for this use case#2021-07-2806:40borkdudeEg I want to offer reagent support, but for those who don’t need it, it should not have to load reagent at startup #2021-07-2806:41borkdudeI’ve done something similar for scittle via modules but for a Node CLI, can that work as well?#2021-07-2806:52thhellerif you are asking about :node-script then no that cannot do :modules. there is no currently available target for node that would support this#2021-07-2806:54thhelleryou could write one but its never come up before so it doesn't exist, also much less relevant in node land given that you'll probably save 1ms or so on startup#2021-07-2807:08borkdudeDo you mean that loading reagent only takes one more ms?#2021-07-2807:12borkdudeI want to make a scripting tool for node and support a variety of libs. Would be very nice if modules worked, so it can be … modular.#2021-07-2807:13borkdudeSee borkdude/tbd #2021-07-2807:16thhellerwell did you try a benchmark of loading nothing vs everything? last time I tried it didn't make much of a difference#2021-07-2807:16thhellercertainly not seconds like it does in clojure#2021-07-2807:17thhellermodular is trivial from the build perspective though. nobody ever asked for it though so it doesn't yet exist#2021-07-2807:50borkdude@thheller I didn't benchmark yet, but can do later today. > modular is trivial from the build perspective though. that sounds cool. Does it work with :node-library already though? I assume it's not that hard to offer a library (which I want to do anyway) that exposes on CLI main namespaces as well#2021-07-2807:51borkdudeThe benchmark is a bit too early days though: adding just one lib might be ok, but dozens of them might impact startup time, which I want to avoid in the long run#2021-07-2815:17mauricio.szaboI'm trying to use :target :npm-module, but no matter what I do, I always get the error:
module.exports = goog.debug.Error;
                            ^
TypeError: Cannot read property 'Error' of undefined
Am I doing something wrong here?
#2021-07-2816:50thheller@mauricio.szabo :npm-module is pretty much dead. some recent updates to the closure-compiler,closure-library makes it pretty much a no-go#2021-07-2816:51thhellerbeen trying to come up with some ideas how to work arround that but so far no luck#2021-07-2816:53thheller@borkdude none of the node targets support modules currently. :target :esm does but that not yet fully working for node since the focus was the browser. also still not sure what the current state of ESM in node is. I think it works but interop with CommonJS is kinda weird#2021-07-2816:54borkdudeit's ok, we just need to have the module loaded and it will register itself through some side effect. beyond that we don't really need interop with the module#2021-07-2816:55thhellerthats not what I meant#2021-07-2816:56thheller:esm is currently sort of hard coded to bundle all dependencies. which typically isn't what you want for node builds#2021-07-2816:56thhellerI mean you can try it, maybe it just works for whatever you are trying to do#2021-07-2816:56thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-07-2816:58borkdudethanks. @mauricio.szabo is trying this :)#2021-07-2816:58borkdudeor is this something else than :npm-module? oh I see#2021-07-2816:59thheller:esm is the modern replacement of :npm-module basically yes#2021-07-2817:01borkdude@thheller what I want to do is basically the same as scittle (https://github.com/borkdude/scittle/blob/main/shadow-cljs.edn) but then for the nodeJS ecosystem. Just to give you some context. I understand that things may not be there yet. Will give :esm a go.#2021-07-2817:02borkdudescittle "plugins" are loaded just by including the source in a script tag#2021-07-2817:03thhellerI don't know what you mean by "for the nodeJS ecosystem". I don't even see the point of scittle to be honest so I'm unsure what problem you are actually trying to solve#2021-07-2817:04borkdudescittle is a way to make small CLJS apps by just including source in script tags. the use case is to get something going quickly. when the project becomes "too big" then you can migrate to a normal CLJS project.#2021-07-2817:05thhelleryeah but why not start a normal CLJS project directly. takes like 10 lines of setup 😛#2021-07-2817:05borkdudeI understand that you may not see the point, but trust me, some people do ;)#2021-07-2817:06thhelleryeah, I totally realize that I'm not the target audience for this 😛#2021-07-2817:06borkdudeI didn't expect you to be#2021-07-2817:07thhellerfor the esm target you can pretty much re-use your :modules from scittle#2021-07-2817:08thhellerhmm or maybe not. I think I made :exports a required thing#2021-07-2817:10borkdudeI noticed that when I tried something different before, I think it can just be an empty map#2021-07-2817:10thhellerno it calculates the :entries from :exports so its definitely needed#2021-07-2817:10thhellerotherwise it won't know which namespaces go where#2021-07-2817:11borkdudeI see#2021-07-2817:12thhellerthat should have been additive with :entries but currently isn't#2021-07-2817:13thhellerjust :init-fn would work though. so no :exports just :init-fn, at least judging by the code 😛#2021-07-2817:13thhellerits really not that much code in the targets https://github.com/thheller/shadow-cljs/blob/ef164e2c46dfe390a86c0f30206b938a08989702/src/main/shadow/build/targets/esm.clj#L118#2021-07-2817:14thhellerthat does a assoc :entries but later merges the :init-fn#2021-07-2817:14thhellerbut maybe you want :exports anyways, don't know exactly what you are planning for node#2021-07-2817:14thhellerI understand the script tags variant but how does it work in node?#2021-07-2817:15borkdudein node it would work similarly: you would always start with the tbd.core "module" and optionally you can then load tbd.reagent for example. on load, that module will register itself in some atom.#2021-07-2817:15borkdudetbd.reagent should be loaded through some js/require#2021-07-2817:16thhellerI get that but where does the user put the code?#2021-07-2817:17borkdudethe user code is a script which gets loaded from a .cljs file which is then interpreted#2021-07-2817:17borkdudethis is also the same with scittle#2021-07-2817:17thhellerhmm? scittle looks for <script type="application/x-scittle"> or did I miss something?#2021-07-2817:18borkdudeyes, tbd (name is subject to change) exposes one CLI main function which has one argument which is the input file#2021-07-2817:18borkdudeso if you run tbd foo.cljs it will run foo.cljs#2021-07-2817:18borkdude(https://github.com/borkdude/tbd)#2021-07-2817:19borkdudeand in foo.cljs you can call js/require again#2021-07-2817:19thhellerso lumo but sci instaed of self-hosted?#2021-07-2817:19borkdudeyes, kind of#2021-07-2817:19borkdudeslightly different I would say. not better, different ;)#2021-07-2817:20borkdudeso tbd can have multiple pre-compiled libs available that can be optionally loaded, aside from interpreted scripts and npm libs#2021-07-2819:04felipethomeHi! Is there a way to get all declared externs in the command line?#2021-07-2819:35mauricio.szabo@thheller so I was able to make something work with :npm-module, and now I'm migrating to :esm. It's giving me the following error:
file:///home/mauricio/projects/tbd/out/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
             ^

ReferenceError: WebSocket is not defined
    at shadow$cljs$devtools$client$websocket$start (file:///home/mauricio/projects/tbd/out/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14)
#2021-07-2819:37thheller@mauricio.szabo need to set :runtime :node in the build config, otherwise it assumes browser#2021-07-2819:39thheller:esm needs some work for node targets. I only tested browser and deno as described in the clojureverse post#2021-07-2819:43mauricio.szaboRight, ok. So far, it works-ish... release don't work (it fails with Error processing externs: JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10)
#2021-07-2819:57thhellerhmm odd, wonder what that line is? can you check the file in .shadow-cljs/builds/<build-id>/release?#2021-07-2820:36mauricio.szaboThis file doesn't even exist...
╰─>$ ls .shadow-cljs/builds/modules/
dev/
#2021-07-2820:37mauricio.szabo
╰─>$ npx shadow-cljs release modules --verbose
shadow-cljs - config: /home/mauricio/projects/tbd/shadow-cljs.edn
[:modules] Compiling ...
-> build target: :esm stage: :configure
<- build target: :esm stage: :configure (3 ms)
-> Resolving Module: :tbd.core
<- Resolving Module: :tbd.core (226 ms)
-> Resolving Module: :tbd.main
<- Resolving Module: :tbd.main (0 ms)
-> Resolving Module: :tbd.reagent
<- Resolving Module: :tbd.reagent (0 ms)
{:type :empty-module, :mod-id :tbd.main, :shadow.build.log/level :info}
{:type :empty-module, :mod-id :tbd.reagent, :shadow.build.log/level :info}
-> build target: :esm stage: :compile-prepare
<- build target: :esm stage: :compile-prepare (2 ms)
Error processing externs:
JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10
Don't know if it helps
#2021-07-2821:07mauricio.szaboAlso, if it helps, this is the code that's currently failing to compile: https://github.com/mauricioszabo/tbd/tree/migrating-to-esm#2021-07-2902:39tianshuI fond the release build doesn't ship some unicode character correctly, (e.g. "◆"). I'm not sure it's an problem in closure compiler or in shadow-cljs.#2021-07-2905:02sova-soars-the-sorao.o uh oh#2021-07-2905:26thheller@mauricio.szabo as I said :exports can't be empty. so you must either add :exports or :init-fn for each module. the clue is the :empty-module warning which should really be an error I guess#2021-07-2905:28thheller@doglooksgood neither. you probably just don't set the proper charset in your html. either your server can do so via Content-Type header or you can in your HTML directly via <meta charset="UTF-8">#2021-07-2905:32tianshu@thheller I have meta tag, and problem only exists with advanced build in my case. (both dev and release use the same web server, handler and template file)#2021-07-2905:32thhellerand you didn't manually override the encoding in the build config to something like ascii?#2021-07-2905:33thhellerit defaults to utf-8 so it should be fine#2021-07-2905:36thhellerwhat can cause issues if you don't have the proper file encoding on the JVM side. it defaults to your OS default but sometimes runs into issues when your files don't use that encoding. if you use only shadow-cljs.edn you can set :jvm-opts ["-Dfile.encoding=utf8"] to force it. delete .shadow-cljs and restart it after setting set#2021-07-2905:45tianshuLet me try more times, I'm not very clear yet. thanks for your explain!#2021-07-2905:46tianshuNow my build works correct, I have no idea yet.#2021-07-2912:49Otto Nascarellaprobably a stupid question…but here I go… anyone using :externs and :externs-file on their setup? how do you use it? any good docs I can refer to?#2021-07-2913:31borkdudeSo I tried continuing with @mauricio.szabo's work. I cloned shadow locally (and installed it using lein install) and added a prn around the module-externs. I get:
$ clojure -M -m shadow.cljs.devtools.cli release modules
[:modules] Compiling ...
"var ex_tbd.core_eval_code;\nvar shadow_esm_import;"
Error processing externs:
JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 10
#2021-07-2913:32borkdudeso it seems shadow isn't emitting some exported var correctly, perhaps?#2021-07-2913:35borkdude
(str "ex_" (cljs-comp/munge (name module-id)) "_" (name export-name))
#2021-07-2913:38borkdude(pushed my WIP here: https://github.com/borkdude/tbd/tree/migrating-to-esm)#2021-07-2914:04mauricio.szaboYes, having the same error even when adding :exports and/or :init-fn for everything...#2021-07-2914:05borkdudethe name is just mangled incorrectly, or perhaps it should create a nested object instead or so?#2021-07-2914:05mauricio.szaboI tried to simply add:
:modules
                    {
                     :tbd.core {:exports {:eval_code tbd.core/eval!}}}
As a debugging step - same error happens
#2021-07-2914:07sheluchinI'm getting this error when connecting my editor to the REPL and I have no idea where to start troubleshooting it. I'm not sure this is the right channel to ask, but can anyone point me in the right direction?#2021-07-2916:45thhellersorry this has nothing to do with shadow-cljs. I don't have a clue what is happening but it is something triggered by your REPL connection#2021-07-2916:45sheluchinty#2021-07-2916:47sheluchin@thheller BTW, I notice that the shadow-cljs docs don't include vim-iced in the Editor Integration section, but the iced docs do have something: https://liquidz.github.io/vim-iced/#clojurescript_shadow_cljs. Not sure if this info is of any use to you 🙂 but thought I'd point it out.#2021-07-2916:54thhellerI don't even know what vim-iced is 😛#2021-07-2916:56sheluchinIt's a vim plugin to let you interact with your clj/cljs environment. Similar to Fireplace and growing in popularity. Anyhow 🙂#2021-07-2915:37borkdudeI replaced the dot with a dollar. I wasn't sure if this was the right thing to do, but at least it compiles now#2021-07-2915:37borkdude(it doesn't run yet)#2021-07-2915:47borkdudeit seems the next obstacle is:
$ node out/tbd.main.js test.cljs
file:///private/tmp/tbd/out/tbd.core.js:1817
export { tbd$core as init-fn };
                         ^

SyntaxError: Unexpected token '-'
#2021-07-2915:56borkdudeafter manually "fixing" that, I stumble upon:
$APP.EB=this||self;
ReferenceError: self is not defined
#2021-07-2915:56borkdudeand after removing self I get: ReferenceError: require is not defined in ES module scope, you can use import instead#2021-07-2915:57borkdudeany pointers how to properly fix the above are welcome.#2021-07-2916:47thheller@borkdude yeah don't use dots in names that will be munged since dot is not munged#2021-07-2916:47thhelleras the error is telling you use import not require#2021-07-2916:47thhellersee the dynamic import thing I mentioned in the clojureverse post#2021-07-2916:48borkdude@thheller What else should one write here then? :init-fn tbd.core/eval_code#2021-07-2916:50thhellerwhats the context for that? where do you have that?#2021-07-2916:50thhellerif I look at the current config from the esm branch there is bunch of self-inflicted wounds 😛#2021-07-2916:51borkdudehttps://github.com/borkdude/tbd/blob/023e2f79565c76e6918e19a2b5edff2ed8fcc57f/shadow-cljs.edn#L15-L20#2021-07-2916:51thhellerthats not valid at all#2021-07-2916:51borkdudeok, thanks.#2021-07-2916:51borkdude:-|#2021-07-2916:52thheller
{:tbd.core {:exports {:eval_code tbd.core/eval-code}}
 :tbd.main {:init-fn tbd.main/init
            :depends-on #{:tbd.core}}
 :tbd.reagent {:init-fn tbd.reagent/init
               :depends-on #{:tbd.core}}}
#2021-07-2916:52thhellersomething like that maybe#2021-07-2916:52borkdudewasn't there a conflict between exports and init-fn?#2021-07-2916:53borkdudeI think the weird config may have been a result of that#2021-07-2916:53thhelleras I said yesterday you must have EITHER exports OR init-fn. not both. you had neither, there was an extra :main {:init-fn ...} that didn't belong there#2021-07-2916:54borkdudedo you mean per module or globally?#2021-07-2916:54thhellerper module#2021-07-2916:54borkdudek, lemme try...#2021-07-2916:57borkdude@thheller if I revert my "replace dot with dollar" workaround then I'm back at:
$ clojure -M -m shadow.cljs.devtools.cli release modules
[:modules] Compiling ...
:module-id "tbd.core"
"var tbd.core;\nvar shadow_esm_import;"
Error processing externs:
JSC_PARSE_ERROR. Parse error. Semi-colon expected at externs.modules.js line 1 : 7
Note that "var tbd.core;\nvar shadow_esm_import;" is the result of me printing bridge-name in esm.clj
#2021-07-2916:57borkdudeshould we use :tbd_core or so?#2021-07-2916:58thhellerjust do not use dots#2021-07-2916:58thhellerthey don't make sense in a node setting anyways 😛#2021-07-2916:59borkdude@thheller ok, I'm back at the next error now:
ReferenceError: self is not defined
    at file:///private/tmp/tbd/out/tbd.core.js:591:428
#2021-07-2917:00thhellerdon't even use the tbd prefix. this isn't the browser so if a user is gonna import stuff they are going to import tbd/thing. tbd/tbd.thing doesn't do anything#2021-07-2917:00thhellernot going to comment on anything until all dots are removed 😛#2021-07-2917:00borkdudewhat dots?#2021-07-2917:00thhellertbd.core.js#2021-07-2917:01borkdudeok, that was the old file :)#2021-07-2917:01borkdude
$ node out/tbd_main.js
file:///private/tmp/tbd/out/tbd_core.js:591
$APP.CB=function(a,b){return dh(Kq.i(a,xs.h(Yk,$APP.Bk.g(kp)),b))};$APP.N2=function(a){for(var b=Kc($APP.Pj(a,new $APP.H(null,1,5,$APP.I,[$APP.wq],null))),c=a;;){var d=$APP.w(c);if($APP.p(d)){var e=d;d=$APP.z.i(e,0,null);e=$APP.z.i(e,1,null);b=Si.i(b,d,$APP.xe(e)?e:new $APP.m(null,1,[$APP.oq,e],null));c=zd(c)}else return new $APP.m(null,2,[$APP.xq,$APP.xq.g(a),$APP.$p,Mc(b)],null)}};DB=function(){return null};$APP.EB=this||self;ba="closure_uid_"+(1E9*Math.random()>>>0);da=0;var Wm=String.prototype.trim?function(a){return a.trim()}:function(a){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(a)[1]};$APP.g=pa.prototype;$APP.g.dc="";$APP.g.set=function(a){this.dc=""+a};$APP.g.append=function(a,b,c){this.dc+=String(a);if(null!=b)for(let d=1;d<arguments.length;d++)this.dc+=arguments[d];return this};$APP.g.clear=function(){this.dc=""};$APP.g.getLength=function(){return this.dc.length};$APP.g.toString=function(){return this.dc};var eh,fh,gh,Ba,Aa,ua,Mk,ya,sk,vd,Em,FB,Zh,dy,ok,xk,iD;eh={};fh={};$APP.md={};Ba=null;Aa=!0;ua=!1;Mk=!1;ya=null;sk=null;vd="undefined"!==typeof Symbol&&"function"===$APP.aa(Symbol)?Symbol.iterator:"@@iterator";
                                                                                                                                                                                                                                                                                                                                                                                                                                           ^

ReferenceError: self is not defined
    at file:///private/tmp/tbd/out/tbd_core.js:591:428
#2021-07-2917:01borkdude(I will be back after dinner)#2021-07-2917:02thhellerI think that self is from the newer closure library. try replacing it manually with globalThis#2021-07-2918:08borkdude@thheller replacing self with globalThis got rid of the error. The next one is: > ReferenceError: require is not defined in ES module scope, you can use import instead I'm not sure where this comes from.#2021-07-2918:22thhellerdo you use js/require somewhere?#2021-07-2918:24thheller@borkdude shadow-cljs release modules --debug makes debugging much much easier#2021-07-2918:26thhellerdo not use that require override you have there. not needed, just include with a relative path#2021-07-2918:29borkdudethe require override exposes js/require to the script user#2021-07-2918:29borkdudeso if they have local node_modules the script loads it from there as well#2021-07-2918:29borkdudebut I don't think the compiled JS uses it anywhere#2021-07-2918:29borkdudeI'll remove it just to make sure this didn't trigger it#2021-07-2918:32borkdudeah, it came from the (js/require "fs")#2021-07-2918:34thhellerjust use ["fs" :as fs] in the ns require#2021-07-2918:34thhellerbut you may need to set :js-options {:keep-as-import #{"fs"}} in the build config#2021-07-2918:34thhellersince otherwise :esm will attempt to bundle it I think#2021-07-2918:37borkdude
(ns tbd.main
  (:require [tbd.core :as tbd]
            ["fs" :as fs]))
> The required JS dependency "fs" is not available, it was required by "tbd/main.cljs".
#2021-07-2918:47thhellerdid you set the keep-as-import?#2021-07-2918:48borkdudeyes also, tried it both without and with#2021-07-2918:52thhellerdid you set it correctly? I mean in the correct place? needs to be in :js-options?#2021-07-2918:52thhellerthe error you get suggests it wasn't properly set#2021-07-2918:53borkdudethat might very well be, this is the current one: https://github.com/borkdude/tbd/blob/c0eec75b654a852e21a02c9f10f492d71294cd57/shadow-cljs.edn#L11-L23#2021-07-2918:54borkdudeoh crap you're right, the wrong build facepalm#2021-07-2918:57borkdudelooks like this works now! so apart from the self -> globalThis:
$ cat test.cljs
(prn :foo)
$ node out/tbd_main.js test.cljs
:foo
#2021-07-2919:05borkdudeunfortunately the dynamic import is async, which makes it a bit more tedious to work with in scripts#2021-07-2919:05borkdudebut from the shadow-cljs side it seems this works now, many thanks#2021-07-2919:08thhellerbtw I have a "use local node_modules over global node_modules" thing in shadow-cljs https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/cli/runner.js#2021-07-2919:09borkdudeuseful, thanks#2021-07-3009:54borkdude@thheller this is not a shadow question per se, so I understand if you want me to ask this in #clojurescript instead, just let me know. This works:
node out/tbd_main.js test.cljs
with the :esm target. But when I install the project with npm install -g and call it from some other directory, then I get:
$ tbd test.cljs
/usr/local/bin/tbd: line 2: import: command not found
/usr/local/bin/tbd: line 3: syntax error near unexpected token `('
/usr/local/bin/tbd: line 3: `const shadow_esm_import = function(x) { return import(x) };'
Should I configure npm to make it work well with the ecmascript module stuff somehow?
#2021-07-3009:55borkdudeThe current state of the project: https://github.com/borkdude/tbd/tree/dynamic-import-esm#2021-07-3009:59borkdudeThis works fine:
$ node /usr/local/bin/tbd test.cljs
#2021-07-3010:01borkdudeI guess it needs a shebang or so and not doesn't automatically create this for you#2021-07-3010:03thheller@borkdude look up node and esm. this is a general JS question, nothing specific to CLJS or shadow-cljs. I can't remember the exact rules for node and esm#2021-07-3010:04thhellerI mean at this point it really doesn't seem worth the effort to use ESM at all, just more trouble than its worth#2021-07-3010:04borkdudeI think the only problem here is the shebang#2021-07-3010:04borkdudebut you may be right#2021-07-3010:04borkdudegoing to back to the :npm-module approach might be better#2021-07-3010:05thhellerno, it is not. it is complaining specifically about import. so maybe you need to pass an extra command line argument in the shebang#2021-07-3010:05thhellerit just might not default to esm. the problem is that it treats the code as commonjs which doesn't have import#2021-07-3010:06borkdudebash /usr/local/bin/tbd gives exactly the same errors, that's why I think it's a shebang problem#2021-07-3010:06thheller:npm-module is broken and pretty much unfixable in its current state. so don't build anything on top of that#2021-07-3010:07borkdudeAdding #!/usr/bin/env node fixed it, but I expect npm to do this for me so it becomes a cross-platform viable way of installing the tool#2021-07-3010:07borkdudeanyway, this isn't a shadow problem, I'll bug someone else with it :)#2021-07-3010:08borkdudeIf you have any other recommendations besides :epm and :npm-module, I'm all ears.#2021-07-3010:10thhelleras I said before from the build perspective this is all trivial. there just isn't a target that does this just yet for node. it could easily be built but for that I need more details about how you actually plan on doing any of this#2021-07-3010:10thhellermy suggestion is to build all of this completely on top of :node-library and then deal with the code splitting stuff later#2021-07-3010:11thhellerit is an optimization after all so you don't need it from the start. if you just keep namespaces separate it'll be trivial to split out later#2021-07-3010:12thhelleronce I can actually see what you are doing I can make a suggestion and maybe a custom target to do what you need#2021-07-3010:13borkdudegreat suggestion, I'll try :node-library and will see what needs to be done for code splitting.#2021-07-3010:13thhellerI really mean :node-library here as well, not :node-script#2021-07-3010:13thhelleruse a runner.js like the one I showed you in shadow-cljs#2021-07-3010:13thhellerwhich just locates the proper file and runs that#2021-07-3010:13thhellerdon't do that from within the CLJS code since it will break in :advanced#2021-07-3010:14borkdudeTo avoid reading through the wall of text below, I'll start a thread.#2021-07-3010:16borkdudeI'm not completely sure what you mean with runner.js, I will have to look into it. I'll try to break down the problems I encounter one by one and keep it focussed. The "hack" of require is done so the script user, who will call this hacked require, can load local npm modules.#2021-07-3010:17borkdude(I'm looking at : https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/cli/runner.js)#2021-07-3010:18thhellerin your package.json you'll specify a bin. that should be the runner. as seen here https://github.com/thheller/shadow-cljs/blob/master/packages/shadow-cljs/package.json#L21#2021-07-3010:18thhellerthat "runner" is then responsible for locating the correct .js file and "running" it#2021-07-3010:18thhellerlike my variant#2021-07-3010:19borkdudeok, cool#2021-07-3010:19thhellerthe hack then becomes irrelevant as far as I can tell?#2021-07-3010:20thhellerso when you run npx shadow-cljs it'll call the runner.js and that will either locate the local node_modules/shadow-cljs install and run that or if not found use a global install#2021-07-3010:20borkdudewell, SCI has access to the global object, so it can do interop on "everything" including require. So when someone writes js/require, we look up require from the global object and call it. This is why we need to put an override for require on the global object.#2021-07-3010:21borkdudeBut the hacked require can then contain similar logic as your runner#2021-07-3010:21thhellerI must be missing something because I don't know why you need to provide a custom require#2021-07-3010:22borkdudeI was surprised by this too, but this problem is explained here: https://swizec.com/blog/making-a-node-cli-both-global-and-local/#2021-07-3010:22borkdudethe problem is that node require doesn't look in the local node_modules when calling a globally installed CLI script#2021-07-3010:24thhellerI think we are talking past each other here#2021-07-3010:24thhellerthe runner.js in shadow-cljs takes care of running either the LOCAL install OR the global install if that is missing#2021-07-3010:25borkdudeyes, that is what the hack for require also does#2021-07-3010:25thhellerbah no it does not#2021-07-3010:25thhellerthat overrides that GLOBALLY and does it for every single require#2021-07-3010:25thhellerwhich is just not needed#2021-07-3010:26borkdudeit is needed for the js/require calls within the scripts that are interpreted#2021-07-3010:26borkdudeso people can install libs locally in their interpreted script dir#2021-07-3010:27borkdudeif I don't apply this hack, people will have to write (js/require "./node_modules/my_lib") or so#2021-07-3010:28borkdudebut this is just a detail, not the major problem I'm having with shadow-cljs#2021-07-3010:28thhelleryou are talking about node_modules which already has special rules so the user should NEVER type out node_modules in anything and instead they should be tying (js/require "my_lib")#2021-07-3010:28borkdudewe're on a tangent here#2021-07-3010:28thhellerwhich then resolves properly and doesn't require any overrides anywhere#2021-07-3010:28thhellerunless I'm completely missing the point on what you are trying to do here#2021-07-3010:28borkdudeyes, exactly! but this doesn't work for tbd, see the blog article :)#2021-07-3010:30thhellerthat blog post is not about the problem you are trying to solve#2021-07-3010:31thhellerlike I explained with the runner.js logic. it maintains which version of YOUR tool is loaded. either the local or the global. YOUR tool, so tbd. why would you want that for the code the USER is loading?#2021-07-3010:32thhellerthey can already load local versions by default and you specically do NOT want it to fall back to global versions#2021-07-3010:32borkdudelet me put it differently, to make you understand what is not working. and then you can decide if you would solve this different.#2021-07-3010:32borkdudebecause we are indeed talking past each other#2021-07-3010:32borkdudeI will make a branch without the hack#2021-07-3010:42thhellerI think what you are looking for is https://nodejs.org/api/module.html#module_module_createrequire_filename#2021-07-3010:43borkdudeI must have been confused before since it does work. You are right, once again :)#2021-07-3010:44thhellerthere are uses for a custom require but never ever mess with the "global" js/require. since that is not actually global but belong to the module you are currently in#2021-07-3010:45thhellerand you definitely do not want that to the the reference of all your future requires#2021-07-3010:46borkdudeyou are right#2021-07-3010:47thhellerso if you want to expose a require for sci use the module.createRequire based on the file it is currently eval'ing#2021-07-3010:47thhelleralso try node --input-type=module in the hashbang stuff#2021-07-3010:48borkdudethe hashbang worked just with node, it just didn't have any hashbang, was the problem. But this "missing hashbang" problem isn't present in my non-ESM branch#2021-07-3010:49thhellerwell yeah this is only for ESM. in case you ever want to "future proof" the thing#2021-07-3010:50thhellernever know if node people are actually going to remove support for commonjs at some point#2021-07-3010:50borkdudethat's kind of a conflict right: should I continue to work with the ESM stuff to make it "future proof" (with all kinds of async stuff around import) or continue with the :node-library approach#2021-07-3010:51borkdudeYou could also ask yourself: is node still around in 3 years or will people go all in on deno?#2021-07-3010:52borkdudeI'm not that familiar with the node ecosystem that much, it's an experiment for me at this point#2021-07-3010:52thhellerI doubt deno will replace node ever but that doesn't mean ESM won't become more adopted generally#2021-07-3010:53borkdudeI don't think the async import stuff is a dealbreaker, I can make similar restrictions to dynamic requires as CLJS does, just support one top level ns form or require form#2021-07-3010:53thhellercommonjs is certainly more convenient in some of these dynamic aspects but the focus has definitely shifted towards ESM#2021-07-3010:53thhellerjudging from all docs using ESM examples etc#2021-07-3016:08borkdude@thheller I've successfully got your shadow.esm/dynamic-import exposed to SCI so you can write:
(-> (js/import "csv-parse/lib/sync.js")
    (.then (fn [csv]
             (let [csv-parse (.-default csv)]
               (-> (csv-parse "foo,bar,baz\n1,2,3" #js {:columns true})
                   (js->clj :keywordize-keys true)
                   prn)))))
I think the (require '["csv-parse/lib/sync.js" :default csv-parse]) can be supported instead, but I wonder why I needed to write .js... any idea here? Should I wrap this function and automatically add this? That might be a bad idea. As (js/import "fs") works and (js/import "fs.js") for example doesn't.
#2021-07-3016:21borkdudeShould I just leave this alone in the ns or require form and just let the user figure it out?#2021-07-3018:36thhellerwhy not just (js/import "csv-parse")? specifying the extension when referencing a file is node stuff. I think thats a new requirement to esm, should have been that way always tbh#2021-07-3018:41borkdudedoes node support it like this, as in (esm/dynamic-import "cvs-parse") ?#2021-07-3018:43borkdudenode that this lib/sync is a module within that package#2021-07-3018:43thhellerI'd assume so? don't know the lib#2021-07-3018:43borkdudepart of their api#2021-07-3018:44thhellerah ok#2021-07-3018:54borkdude@thheller Now got this working as a "tbd" script:
(ns foo
  (:require ["fs" :as fs]
            ["csv-parse/lib/sync.js" :default csv-parse]
            [reagent.core :as r]
            #_[reagent.dom.server :as rds]))

(println (str (.readFileSync fs "test.cljs")))

(prn :hello-the-end)

(prn (csv-parse "foo,bar"))

#_(prn (rds/render-to-string [:div [:p "hello"]]))
#2021-07-3018:56borkdudenot loading reagent saves a bit of time, like 20ms or so. it's not a lot, but it shows that, architecturally, it's now possible to add more and more built-in libs, without impacting startup if you don't load all of those#2021-07-3019:49borkdudeNow I remember what the "hack" was for.#2021-07-3019:49borkdudeIf you have a local file relative to the script, e.g. foo.js and you try to load it with:
(ns script (:require ["./foo"]))
This doesn't work
#2021-07-3020:06thhelleragain DO NOT USE THAT HACK!#2021-07-3020:06thhelleruse the module.createRequire if you must have a custom require (pretty sure there is a import equivalent)#2021-07-3020:23borkdudeaha#2021-07-3020:26borkdudenote that this doesn't hack import globally though#2021-07-3020:26borkdudebut I'll look into it :)#2021-07-3110:23borkdude@thheller I'm trying to do the createRequire thing. For:
import { createRequire } from 'module';
I'm writing: (:require ["module" :refer [createRequire]]]) but then I get:
The required JS dependency "module" is not available, it was required by "nodashka/core.cljs".

Dependency Trace:
	nodashka/core.cljs
Not sure if this is a correct message, since module is built into nodeJS, I believe?
#2021-07-3110:23borkdudeWhen I try:
(def createRequire (.-createRequire js/module))
(def require* (createRequire js/module.meta.url))
I get:
ReferenceError: module is not defined in ES module scope
#2021-07-3111:04borkdudeI have removed the hack as you suggested, but when I install nodashka (current working name) globally using npm install -g nodashka and then have a local node_modules with e.g. the ink dependency, it can't find it. That is the problem I'm trying to solve.#2021-07-3111:09borkdudeWhen you npm install -g ink then it does work. Perhaps this should just be how it works...?#2021-07-3111:26borkdudeI guess this is perhaps just the way it should be. Mixing global deps from nodashka itself with local deps would perhaps be weird.#2021-07-3116:09thhellerif you are still using the esm target you need to add "module" to the :keep-as-import set in your build config#2021-07-3116:09thhellerotherwise it'll try to bundle it but since its a built-in node package it can't do that#2021-07-3116:10borkdudeah#2021-07-3116:11borkdudenow I remember from the fs thing, thank you#2021-07-3116:11borkdudeI think I'm able to get "require" back through this createRequire thing even in ESM. I thought ESM would prevent me from doing so and all requires are now async. But I could revert that.#2021-07-3116:11borkdudeOn the other hand, maybe for the future, one could require from some http address and then it would have be async anyway#2021-07-3116:13thhellerI'm not sure how this all looks for pure esm. the createRequire looks commonjs-ish#2021-07-3116:15borkdudeI'll give it a try. I'm still confused about having nbb (yes, changed the name) as a global tool from npm and using it with node_modules in a local script dir. Do you think this is possible, or should a global tool always use the global npm deps?#2021-07-3116:15thhellerhttps://nodejs.org/api/esm.html#esm_no_require_exports_or_module_exports#2021-07-3116:15thhellerguess its ok to use require that way?#2021-07-3116:15borkdudeyeah#2021-07-3116:26thhellerbtw you should maybe try to not use :default. use the official ["thing$default" :as x] instead of ["thing" :default x]#2021-07-3116:31borkdudeoh I didn't know about that#2021-07-3116:31borkdudeit does ring a bell, it was a recent addition right#2021-07-3116:32thhelleryes, https://clojurescript.org/news/2021-04-06-release#_library_property_namespaces#2021-07-3116:36thhellerquite useful addition. very handy if you have a lot of nested properties#2021-07-3118:22borkdudeHow do I write import.meta.url in CLJS/shadow?#2021-07-3118:23borkdudeI tried with (.. js/import -meta -url), and even js* but both fail#2021-07-3118:28thhellerfail how?#2021-07-3118:28thhellerfail in release you mean?#2021-07-3118:29borkdudeyes#2021-07-3118:29borkdudein non-release it did work#2021-07-3118:33thhelleryeah the closure-compiler wants to process it statically#2021-07-3118:33thhellerso using it dynamically requires some trickery, as seen in shadow.esm/dynamic-import#2021-07-3118:34thhellerso js/shadow_esm_import.meta.url should work#2021-07-3118:36borkdudehmm. TypeError: Cannot read property 'url' of undefined#2021-07-3118:37thhellercheck if js/shadow_esm_import is actually set#2021-07-3118:37thhellercan't remember how I did this exactly#2021-07-3118:37thhellerif all else fails (js/eval "import.meta.url")#2021-07-3118:37borkdudeIt looks like a function over here: https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/build/targets/esm.clj#L327#2021-07-3118:38borkdudeI think it's actually set, else meta would have been null already#2021-07-3118:38borkdudetrying eval now#2021-07-3118:38thhellermeta is undefined thats why you get url of undefined#2021-07-3118:39borkdudeyes, sorry, else I would have gotten an error about meta I mean: meta of undefined#2021-07-3118:39borkdudewith js/eval:
import.meta.url
       ^^^^

SyntaxError: Cannot use 'import.meta' outside a module
#2021-07-3118:40thhellerah right it wraps import since closure otherwise complains#2021-07-3118:40thhellerwell yes, as always import is only available in modules#2021-07-3118:40borkdudeperhaps you can put meta on that function as well? :-D#2021-07-3118:40thhellerthat wouldn't do anything to fix your problem. what are you trying to do exactly?#2021-07-3118:41borkdudeI was trying to follow your advice of using createRequire#2021-07-3118:41borkdude
(def require* (createRequire (js/eval "import.meta.url") #_(.. js/shadow_esm_import.meta.url -meta -url)))
#2021-07-3118:41thhellerehm thats wrong#2021-07-3118:41thhelleryou want to create a require that uses the source of the current file as a reference#2021-07-3118:42thhellerso not the file you are in but the file you are eval'ing#2021-07-3118:43borkdudeoh that you mean, so cwd() basically#2021-07-3118:43thhellerno#2021-07-3118:43thhellerthe file you are evaling#2021-07-3118:43thhellertbd some-script.cljs#2021-07-3118:43thhellerso some-script.cljs#2021-07-3118:44borkdudealright#2021-07-3118:44thhellerbut full path resolved using node path/resolve#2021-07-3118:44borkdudeok, this sounds promising... trying#2021-07-3118:45borkdudenow I finally get what you were getting at#2021-07-3118:46thhellerdont' forget to add "path" to :keep-as-import when you import it 😉#2021-07-3118:46borkdude:-D#2021-07-3118:46borkdudeI have much to learn in this node ecosystem, I'm glad you're patient ;)#2021-07-3118:47thhellerits not that complicated but helps to understand it. saves you from trying weird hacks 😉#2021-07-3118:47borkdudeabsolutely#2021-07-3118:51thhellerrequire in node always has a "context". ie. the module you are currently in so it knows how to follow relative paths#2021-07-3118:51thhellerand follow the node resolve rules of finding node_modules#2021-07-3118:53borkdudegreat, now my requires look like this again:
(ns script
  (:require
   ["csv-parse/lib/sync" :as csv-parse]
   ["fs" :as fs]
   ["shelljs" :as sh]))
Instead of (which was implemented via js/import):
(ns script
  (:require
   ["csv-parse/lib/sync.js" :default csv-parse]
   ["fs" :as fs]
   ["shelljs" :default sh]))
#2021-07-3118:57borkdudeI'll move everything back to require, much more node-ish#2021-07-3118:59thhellerwell maybe add ["csv-parse/lib/sync.js$default" :as csv-parse]#2021-07-3118:59thhellerhas the added benefit of csv-parse/foo working since its an alias#2021-07-3118:59borkdudeyeah, I will do that after I get this sorted#2021-07-3118:59thhellerprobably shouldn't adopt :default at this point since it was rejected from CLJS proper#2021-07-3119:00borkdudeyeah, it was my ignorance :)#2021-07-3119:00borkdudenow people can also just use js/require again like they are used to#2021-07-3119:04borkdudeI'll probably move this $ back to SCI proper so it can work for all CLJS applications using it#2021-07-3119:34borkdudeHmm, it seems I'm still stuck in the async import stuff. I did manage to create require which resolves according to the file but you cannot require an ES Module with require, so I'll have to keep doing that using dynamic import.#2021-07-3119:35borkdude(this is for the lazy loading of optional modules at runtime)#2021-07-3119:36borkdudeand I don't know if there is a createImport instead of createRequire#2021-07-3119:41borkdudeI found this issue about it: https://github.com/nodejs/node/issues/30645#2021-07-3119:43borkdudeIt seems for the import stuff to work, I need access to:
import.meta.resolve also accepts a second argument which is the parent module from which to resolve from:

await import.meta.resolve('./dep', import.meta.url);
#2021-07-3119:44borkdude(source: https://nodejs.org/api/esm.html#esm_import_meta_resolve_specifier_parent)#2021-07-3120:34borkdudeI tried to apply a similar trick to yours, but it didn't work.
"globalThis.shadow_esm_resolve = function(x,y) { return import.meta.resolve(x,y); }"
#2021-07-3120:34borkdude
TypeError: (intermediate value).resolve is not a function
#2021-07-3120:44borkdudeI admit fully that I didn't know what I was doing, but it was worth a shot ;)#2021-07-3121:22borkdudeBut I think, either the above import.meta.resolve should be used, or, I should try something else than these ESM modules, or I should write my own resolver...#2021-07-3121:24borkdudePerhaps continueing with :node-library and then making the code splitting work#2021-07-3121:53borkdudeSo, I've also created a branch node-library here: https://github.com/borkdude/nbb/tree/node-library The compilation works nicely. It's just that I want code splitting so I can load "splits" dynamically, as needed.#2021-07-3121:54borkdudeSo perhaps we can look into making this works. It seems a lot "easier" from the nodeJS side than this ESM stuff#2021-08-0109:38borkdude@thheller Good news. I was able to use the createRequire stuff while also loading my own ESM modules async. So now the programs look "node-ish" , while still leveraring your ESM target with module support.#2021-08-0109:38borkdudeOnce you support modules in the node-library target I'll likely move to that, but for now, we're good :-D#2021-08-0109:39borkdudeAlso the local npm library require stuff works as expected now.#2021-08-0109:40borkdudeI will keep an eye on shadow for that feature, but I'm out of the woods now for my own needs#2021-08-0110:16borkdude@thheller Btw, the way of resolving from the script file root got me thinking. I don't think the clojure CLI does this, does it.#2021-08-0110:17borkdudee.g. foo/deps.edn + foo/script.clj + clojure foo/script.clj will not use foo/deps.edn but only the local deps.edn#2021-08-0110:17borkdudeI think it could be useful for normal babashka if it did...#2021-07-3010:14iGELHello. I got one of these newbie questions: Want to run some cljs tests, but I guess my project layout is causing some problem:
/webapp/cljs/admin/shadow-cljs.edn
            /tools/src/money.cljs
                  /test/money_test.cljs
            /output/
            /customer ; Separate cljs project also using tools, but not build by this shadow-cljs process
Here the relevant parts of the shadow-cljs.edn
{:source-paths ["src"
                "../tools/src"
                "../tools/test"]
 :builds {:test {:target :node-test
                 :output-to "../output/node-tests.js"}}}
When I compile & run the tests (`pwd -> /webapp/cljs/admin`, I run node_modules/.bin/shadow-cljs compile test && node ../output/node-tests.js), I get this output:
shadow-cljs - config: /webapp/cljs/admin/shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
[:test] Compiling ...
[:test] Build completed. (51 files, 1 compiled, 0 warnings, 1.92s)
no "source-map-support" (run "npm install source-map-support --save-dev" to get it)
fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/webapp/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:343:35)
    at global.SHADOW_IMPORT (/webapp/cljs/output/node-tests.js:52:15)
    at /webapp/cljs/output/node-tests.js:1524:1
    at Object.<anonymous> (/webapp/cljs/output/node-tests.js:1575:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
The file exists, but in the wrong location:
ls /webapp/{,cljs/admin/}.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js
ls: cannot access '/webapp/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js': No such file or directory
/webapp/cljs/admin/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog.debug.error.js
My node version is v10.24.0 from the Debian Docker image I use and shadow-cljs is 2.15.2.
#2021-07-3010:15thheller@igel don't use ../ in :output-to. that is supposed to be a directory in the project.#2021-07-3010:16iGELok, I'll try. thx#2021-07-3010:16thhellerif you want it outside the project dir setting :output-dir "../output" in addition to :output-to might work#2021-07-3010:19iGELIt does. Thank you 👍#2021-07-3010:53kennytiltonWe are building on https://github.com/PEZ/rn-rf-shadow and have just added [cljsjs/mqtt "2.13.0-0"] as a dependency. In the code, we require [cljs.mqtt]. Problem: error from the shadow build app: "The required namespace "cljs.mqtt" is not available, it was required by "example/app.cljs"." This all works fine in a web app we have, so I am guessing this is something to do with RN. Will shifting to interop with an RN MQTT NPM package help? We are trying: https://www.npmjs.com/package/react-native-paho-mqtt in the meantime.#2021-07-3010:54thheller@hiskennyness shadow-cljs does not support CLJSJS packages, just use the npm package directly#2021-07-3010:55thhellerI'm guessing the webapp you have isn't built with shadow-cljs, otherwise you'd have the same issue there#2021-07-3010:56thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2021-07-3010:56kennytiltonDoh! Forgot to mention we are using figwheel on the web app.#2021-07-3012:41iGELI'm getting an error with a namespace in a test build, but not the browser build, and I don't understand why. Here the relevant parts I guess: /shadow-cljs.edn:
{:source-paths ["src" "test"]
 :builds {:credit-assessment {:target :browser ;; Works!
                              :modules {:credit-assessment {:entries [credit-assessment.core]}}
                              :output-dir "../output/"
                              :asset-path "/cljs/output"}
          :test {:target :node-test ;; Doesn't work :'(
                 :output-to "../output/node-tests.js"
                 :output-dir "../output"}}}
/src/credit_assessment/core.cljs (requires credit_assessment.criteria) /src/credit_assessment/criteria.cljs:
(ns credit-assessment.criteria)
/test/credit_assessment/criteria_test.cljs:
(ns credit-assessment.criteria-test
 (:require
  [clojure.test :refer [deftest testing is are]]
  [credit-assessment.criteria :as creteria]))
This works for the credit-assessment build, but for the test build, I get this:
[:test] Compiling ...
------ ERROR -------------------------------------------------------------------
 File: /test/credit_assessment/criteria_test.cljs:1:2
--------------------------------------------------------------------------------

   1 | (ns credit-assessment.criteria-test
--------^-----------------------------------------------------------------------
An error occurred while generating code for the form.
ExceptionInfo: no source by provide: credit-assessment.criteria
#2021-07-3012:43thhellerhmm not sure. FWIW you must not use the same :output-dir for multiple builds#2021-07-3012:43thhellerbut thats unlikely to affect this#2021-07-3012:43iGELI will try it anyway#2021-07-3012:46iGELAs you said, doesn't seems to be the issue#2021-07-3020:26jmckitrickHi all, I’m trying to build a shadow-cljs project in a luminus template, and then separate the build as I’ve been instructed here.#2021-07-3020:26jmckitrickHowever, here is what happens:#2021-07-3020:36jmckitrick#2021-07-3020:38thhellerget rid of the lein#2021-07-3020:42jmckitrickSo does this mean the luminus template has been updated to run shadow separately rather than as a lein task?#2021-07-3020:58thhellerI guess? I have never used that template so no clue what it looks like#2021-07-3100:41cjmurphy
--- SHADOW-CLJS FAILED TO LOAD! ----------------------

This is most commonly caused by a dependency conflict.
When using deps.edn or project.clj you must ensure that all
required dependencies are provided with the correct version.

You are using shadow-cljs version: 2.11.8

The important dependencies are:

  org.clojure/clojure "1.10.1"
  org.clojure/clojurescript "1.10.773"
  com.google.javascript/closure-compiler-unshaded "v20200830"
#2021-07-3100:46cjmurphyI'm getting this but only on a particular machine. Have tried different versions of shadow, deleting caches, not specifying clojurescript as a dependency, closure-compiler-unshaded in exclusions, not specifying clojure or clojurescript. Even including closure-compiler-unshaded in deps.edn. Is that a wrong version of closure-compiler-unshaded that is somehow being picked up? Any way to really start from scratch, as there's nothing actually wrong with this particular deps.edn/Fulcro project.
#2021-07-3106:20thhellerand what is the rest of the error you get? I mean why does it fail to load? it should have a nice long stacktrace?#2021-07-3106:49cjmurphyYes sure. This is it (I stripped some lines as it was too big for slack):
The error encountered was:

Syntax error macroexpanding at (closure.clj:70:5).
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at shadow.build.js_support$eval12458$loading__6721__auto____12459.invoke(js_support.clj:1)
        at shadow.build.js_support$eval12458.invokeStatic(js_support.clj:1)
        at shadow.build.js_support$eval12458.invoke(js_support.clj:1)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:703)
        at shadow.build.resolve$eval10708$loading__6721__auto____10709.invoke(resolve.clj:1)
        at shadow.build.resolve$eval10708.invokeStatic(resolve.clj:1)
        at shadow.build.resolve$eval10708.invoke(resolve.clj:1)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:2793)
        at shadow.build.api$eval10700$loading__6721__auto____10701.invoke(api.clj:1)
        at shadow.build.api$eval10700.invokeStatic(api.clj:1)
        at shadow.build.api$eval10700.invoke(api.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7177)
        at clojure.lang.Compiler.eval(Compiler.java:7166)
        at clojure.lang.Compiler.load(Compiler.java:7636)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:3204)
        at shadow.build$eval10694$loading__6721__auto____10695.invoke(build.clj:1)
        at shadow.build$eval10694.invokeStatic(build.clj:1)
        at shadow.build$eval10694.invoke(build.clj:1)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:3204)
        at shadow.cljs.devtools.api$eval2236$loading__6721__auto____2237.invoke(api.clj:1)
        at shadow.cljs.devtools.api$eval2236.invokeStatic(api.clj:1)
        at shadow.cljs.devtools.api$eval2236.invoke(api.clj:1)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:1289)
        at shadow.cljs.devtools.cli_actual$eval173$loading__6721__auto____174.invoke(cli_actual.clj:1)
        at shadow.cljs.devtools.cli_actual$eval173.invokeStatic(cli_actual.clj:1)
        at shadow.cljs.devtools.cli_actual$eval173.invoke(cli_actual.clj:1)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:459)
        at clojure.lang.RT.load(RT.java:424)
        at clojure.core$load$fn__6839.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6780.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:665)
        at clojure.core$serialized_require.invokeStatic(core.clj:6079)
        at clojure.core$requiring_resolve.invokeStatic(core.clj:6088)
        at clojure.core$requiring_resolve.invoke(core.clj:6082)
        at shadow.cljs.devtools.cli$_main$fn__166.invoke(cli.clj:70)
        at shadow.cljs.devtools.cli$_main.invokeStatic(cli.clj:69)
        at shadow.cljs.devtools.cli$_main.doInvoke(cli.clj:67)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.core$apply.invokeStatic(core.clj:665)
        at clojure.main$main_opt.invokeStatic(main.clj:514)
        at clojure.main$main_opt.invoke(main.clj:510)
        at clojure.main$main.invokeStatic(main.clj:664)
        at clojure.main$main.doInvoke(main.clj:616)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:40)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
        at com.google.javascript.rhino.IR.name(IR.java:407)
        at com.google.javascript.jscomp.VarCheck.<clinit>(VarCheck.java:97)
        at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:243)
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
        at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1733)
#2021-07-3106:50thhellerok thats a conflict on the guava dependency. frequently happens with datomic on the classpath#2021-07-3106:51thhellerideally move all your CLJ dependencies into a separate alias so its not active when compiling CLJS#2021-07-3106:51cjmurphyOr use exclusions?#2021-07-3106:52thhelleror manually fiddle with things till they fit but thats more effort#2021-07-3106:52thhellerno clue if things actually work with exclusions since both datomic and closure-compiler actually need and use guava. don't know if they like each others versions.#2021-07-3106:58cjmurphyRight thanks. I know I've excluded com.google.guava/guava from Datomic for other projects and it didn't seem to harm Datomic. But tried here and it didn't help. I just get this error when yarn shadow-cljs server . At least we have a solution.#2021-07-3107:00cjmurphyStill hard to explain why this deps.edn project works fine elsewhere, including on one of my other computers.#2021-07-3108:03cjmurphyTo try and fix the problem I edited deps.edn moving the com.datomic/datomic-pro map-entry from :deps to all the aliases that need datomic. So datomic should not be on the classpath that shadow-cljs.edn uses, as shadow-cljs.edn has :deps true , and thus doesn't use any of the aliases, just the default :deps. Did not help unfortunately 😞#2021-07-3116:30thhellerit might not be datomic. guava is a pretty common dependency. check with clj -Stree or so what your dependencies look like#2021-07-3123:32cjmurphyYes there was more: google-apps-clj was the remaining culprit. So problem fixed. Now I've got the much more minor problem of dependencies duplicated in 5 aliases. I'm not sure there's a way to tidy this up (merge maps) in deps.edn. But overall 😄.#2021-08-0106:23thhellerI always recommend just keeping you CLJS dependencies separate in shadow-cljs.edn. works perfectly fine unless you need git deps#2021-08-0106:57cjmurphyYou mean {:deps false} in shadow-cljs.edn ?#2021-08-0107:04thhelleryes, just :dependencies and :source-paths listed there. don't even set :deps#2021-08-0107:10cjmurphyGot it yeah. Also in your docs you mention going for :deps {:aliases [:cljs]}. That could be another alternative better setup than what I've got now. I'll try not using deps.edn at all first though.#2021-08-0107:12thhellerif you go with the alias you still need to move all your CLJ stuff out of the base and into its own alias#2021-08-0107:12thhellerotherwise you still have conflicts#2021-08-0110:11cjmurphyUsing shadow-cljs.edn :dependencies a good solution. I've removed cljs-only libs from deps.edn and the few that now exist in both config files are both clj and cljs anyway. So overall the whole thing makes sense. Works for development but I may have broken things for production - maybe an uberjar is created only from deps.edn artifacts and thus now won't include cljs-only libs.#2021-08-0114:55thhellerwhy would it include cljs-only libs. they shouldn't be in uberjars anyways 😛#2021-08-0123:43cjmurphyThere's something askew in my understanding then. If an uberjar is the only source of all code for the application then surely it must either include the compiled javascript or the cljs-only libs that can create the compiled javascript. Under :builds of the shadow-cljs.edn there is a :prod key. So I suppose it is used as part of creating the uberjar. So the uberjar will contain compiled javascript and no need for any cljs-only libs in the deps.edn.#2021-08-0205:48thhelleryes, uberjar should only contain the release version of a build. if you have a :prod build you are likely using shadow-cljs wrong since you should have the same build for development watch and production release#2021-08-0205:49thhellerbut no cljs-libs will be required in your CLJ runtime so they shouldn't be in the uberjar (all they do is increase the size so its not super critical though)#2021-07-3103:56pinkfrogHi. What does npx shadow-cljs run do?
npx shadow-cljs help run 
gives no helpful information
#2021-07-3114:56pinkfrogI am seeing this error
> (def a 3)


Execution error (TypeError) at (<cljs repl>:1).
undefined is not an object (evaluating 'cljs.user.a = (3)')
nil
cljs.user=>
What could be the potential cause?
#2021-07-3116:11thheller@i impossible to comment without more context. what did you run? which runtime is this?#2021-07-3116:39pinkfrogCouldn’t make a minimal example for my own code. But I found playing with https://github.com/PEZ/rn-rf-shadow also has the same issue.#2021-07-3116:40pinkfrog#2021-07-3116:40pinkfrogI am using the browser runtime.#2021-07-3116:41pinkfrogOnly happening for the cljs.user namespace#2021-07-3116:43thhellerin-ns does not create a namespace that doesn't exist. so if you have a custom :repl-init-ns then cljs.user does not exist#2021-07-3116:43thhellerso you need to create it first via (ns cljs.user)#2021-07-3116:48pinkfrogUsing (ns cljs.user) solves the problem.#2021-07-3116:49pinkfrogBut greping the code of rn-rf-shadow, I saw no use of a custom repl-init-ns#2021-07-3116:50thhellerthats a react native app? you said browser?#2021-07-3116:50pinkfrogrn-rf-shadow, but I run it in the browser with expo.#2021-07-3116:50thhellerhmm no clue, never tried that#2021-08-0115:53zendevil.ethI have the following function that had been working but suddenly gives an error. Don’t know what changed:
(defn navigate! [match _]
  (prn "match is " match)
  (e/common-navigate match))
Error:
app.js:1552 TypeError: Cannot read property 'common_navigate' of undefined
    at humboi$core$navigate_BANG_ (core.cljs:257)
    at reitit$frontend$easy$start_BANG__$_rfe_on_navigate (easy.cljs:39)
    at Object.eval [as reitit$frontend$history$History$_on_navigate$arity$2] (history.cljs:128)
    at Object.reitit$frontend$history$_on_navigate [as _on_navigate] (history.cljs:12)
    at Object.eval [as reitit$frontend$history$History$_init$arity$1] (history.cljs:125)
    at Object.reitit$frontend$history$_init [as _init] (history.cljs:10)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (history.cljs:170)
    at Object.reitit$frontend$easy$start_BANG_ [as start_BANG_] (easy.cljs:36)
    at Object.humboi$core$start_router_BANG_ [as start_router_BANG_] (core.cljs:487)
    at Object.humboi$core$init_BANG_ [as init_BANG_] (core.cljs:504)
the e/ namespace definitely exists.
#2021-08-0115:58zendevil.ethHere’s the namespace declaration of the file that navigate! is in:
1   (:require
    2    [day8.re-frame.http-fx]
    3    [reagent.dom :as rdom]
    4    [reagent.core :as r]
    5    [re-frame.core :as rf]
--  6    [goog.events :as events]
--  7    [goog.history.EventType :as HistoryEventType]
    8    [markdown.core :refer [md->html]]
    9    [humboi.ajax :as ajax]
   10    [reitit.core :as reitit]
   11    [reitit.frontend.easy :as rfe]
   12    [clojure.string :as string]
-- 13    ["@typeform/embed-react" :refer [PopupButton]]
-- 14    [cljs.core.async :refer [go]]
-- 15    [cljs.core.async.interop :refer-macros [<p!]]
   16    #_["use-magic-link" :as useMagicLink]
   17    #_[accountant.core :as accountant]
   18    [humboi.events :as e]
   19    [humboi.subs :as s]
-- 20    [react :refer [useEffect]]
   21    [react-calendar :default Calendar])
And this is the e/ namespace’s ns declaration:
#2021-08-0115:58zendevil.eth
1   (ns humboi.events
--  1   (:require-macros [humboi.macros :refer [db-event fx-event sub]]
    2                    [humboi.env :refer [endpoint blockchain-provider]])
    3   (:require
--  4    [re-frame.core :refer [reg-event-fx reg-fx] :as rf]
    5    [ajax.core :as ajax]
    6    [reitit.frontend.easy :as rfe]
    7    [reitit.frontend.controllers :as rfc]
    8    [cljs.core.async :refer [go]]
    9    [cljs.core.async.interop :refer-macros [<p!]]
   10    ["magic-sdk" :refer [Magic]]
   11    ["@magic-ext/oauth" :refer [OAuthExtension]]
-- 12    [humboi.macros :refer [deep-merge]]
-- 13    [humboi.subs :as s]
-- 14    [web3 :as Web3]
-- 15    ["@metamask/detect-provider" :as detectEthereumProvider]
   16    ["@alch/alchemy-web3" :refer [createAlchemyWeb3]]))
#2021-08-0117:26zendevil.etheven (find-ns 'humboi.events) gives nil in the first file#2021-08-0117:27thheller@ps were there any errors during load? if the file didn't load properly then the ns doesn't exist#2021-08-0117:28zendevil.ethyeah there’s this error: WebSocket connection to ‘<ws://localhost:9630/api/remote-relay?server-token=36e8c857-da4b-402d-a82e-e8ad3f2b895a>’ failed:#2021-08-0117:28thhellerthe error you posted could just be a symptom not the cause#2021-08-0117:29zendevil.ethalso:
shadow-cljs - remote-error Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}bubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}defaultPrevented: falseeventPhase: 0isTrusted: truepath: []returnValue: truesrcElement: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}target: WebSocket {url: "", readyState: 3, bufferedAmount: 0, onopen: null, onerror: null, …}timeStamp: 166289.09999990463type: "error"[[Prototype]]: Event
eval @ shared.cljs:305
shadow$cljs$devtools$client$shared$remote_error @ shared.cljs:18
eval @ websocket.cljs:29
error (async)
shadow$cljs$devtools$client$websocket$start @ websocket.cljs:26
eval @ shared.cljs:324
eval @ shared.cljs:345
setTimeout (async)
eval @ shared.cljs:341
eval @ shared.cljs:297
shadow$cljs$devtools$client$shared$remote_close @ shared.cljs:17
eval @ websocket.cljs:24
#2021-08-0117:33thhellerno clue. websocket should connect properly if everything is setup properly#2021-08-0117:33thhellerbut I don't know anything about your setup so can't comment much#2021-08-0117:35zendevil.eththere are 9 cannot infer target type warnings, including warnings from the file with ns humboi.events. Other than that it says build completed#2021-08-0117:36thhellereither fix them or turn them off. do not ignore warnings.#2021-08-0117:37zendevil.ethTried ^js tags everywhere but the warning didn’t go away. The warning points to go:
1       (go
    2         (let [web3 (createAlchemyWeb3 (blockchain-provider))]
    3             (js/console.log "deploying contract "
    4                            (.-issuer (-> db :user))
    5                            "."
    6                            "web3" web3
    7              (.then
    8                (.send
    9                    (.buy
   10                      (.-methods
   11                        (new (.. web3 -eth -Contract)
   12                             (:contract-json db)
   13                             (-> db :creation :creation/contract-address)))
   14                      ;; magic id
   15                      (.-issuer (-> db :user)))
   16                    (clj->js {:value (* (:creation-input-value db)
   17                                        1000000000000000000)
   18
   19                              :from (->
   20                                      (<p!
   21                                       (.request
   22                                        (:ethereum db) (clj->js {:method "eth_      requestAccounts"})))
   23                                      (get 0))})
   24                   (fn [err transaction-hash]
   25                     (prn "err is;; " err)
   26                     (prn "transaction has is " transaction-hash)))
   27               (fn [contract-instance]
   28                  (js/console.log "new contract instance is " contract-instanc      e))))))
#2021-08-0117:38zendevil.eth
Cannot infer target type in expression (. inst_62878 (buy inst_62880))
#2021-08-0117:38thheller^js tags don't work properly in go#2021-08-0117:39thhelleryou probably shouldn't mix .then and <p!, pick one and stay with it#2021-08-0117:40zendevil.ethso is there a way to fix the warning?#2021-08-0117:42thhellernot easily in go. you can (set! *warn-on-infer* false) directly after the ns to turn warnings off for that file#2021-08-0117:47zendevil.ethAdding that to humboi.events gives a new error:
browser.cljs:39 Failed to load humboi/events.cljs SyntaxError: Unexpected token '.'
    at eval (<anonymous>)
    at Object.goog.globalEval (app.js:486)
    at Object.shadow$cljs$devtools$client$browser$script_eval [as script_eval] (browser.cljs:24)
    at Object.shadow$cljs$devtools$client$browser$do_js_load [as do_js_load] (browser.cljs:36)
    at eval (browser.cljs:57)
    at eval (env.cljs:236)
    at Object.shadow$cljs$devtools$client$env$do_js_reload_STAR_ [as do_js_reload_STAR_] (env.cljs:208)
    at Function.eval [as cljs$core$IFn$_invoke$arity$4] (env.cljs:244)
    at Object.shadow$cljs$devtools$client$browser$do_js_reload [as do_js_reload] (browser.cljs:43)
    at eval (browser.cljs:93)
But it doesn’t say what line the . is on
#2021-08-0117:50zendevil.ethIf it knows that there’s this specific syntax error, shouldn’t it say what line it is on?#2021-08-0117:51zendevil.ethAnd the file is so large that I couldn’t really find it manually#2021-08-0120:26thhellersorry I don't know. I don't know what you are doing in the file. the snippet you posted has some weird things that look suspicious. what is {:method "eth_ requestAccounts"} or (js/console.log "new contract instance is " contract-instanc e)#2021-08-0120:26thhelleralso this is way too large number for safe JS math (* (:creation-input-value db) 1000000000000000000)#2021-08-0123:43Ella HoeppnerHi, I'm working on a shadow-cljs project that involves using a SharedArrayBuffer to communicate with a worklet. A few days ago the app stopped working properly, and after some research I've found out that SharedArrayBuffers no longer work by default in chrome as of version 92 without specifying certain HTTP headers. How would I go about doing this in shadow-cljs?#2021-08-0123:52Ella HoeppnerI see here https://shadow-cljs.github.io/docs/UsersGuide.html that you're supposed to be able to specify headers in shadow-cljs.edn with :push-state/headers , but that doesn't seem to be working. Not sure why. Here's the relevant snippet:
:dev-http {9500 {:root "public"
                  :push-state/headers {"content-type" "text/html"
                                       "Cross-Origin-Opener-Policy" "same-origin"
                                       "Cross-Origin-Embedder-Policy" "require-corp"}}}
#2021-08-0205:46thheller@ellahoeppner if you need custom headers you'll need a server anyways. so you should use the server you plan on using in production for development as well#2021-08-0219:23Ella HoeppnerFair enough. Though the project I'm working on is just kinda a personal/prototyping thing and I doubt there will ever be a "production" version, so I was hoping for a simpler solution. I'll either look into making my own server or just using some old version of a browser that will let me use SharedArrayBuffers without special headers#2021-08-0219:23Ella HoeppnerThanks for your help!#2021-08-0217:54mkarpHey there! I have a question regarding the dynamic configuration of the :dev-http property. Suppose I have two http handlers configured in shadow-cljs.edn. If I launch clj and then call (start-server!), everything works as expected — I get two http servers:
$ cat shadow-cljs.edn
$ head -n 5 shadow-cljs.edn
{:deps true
 :nrepl {:port 7888}
 :socket-repl {:port 9002}
 :dev-http {9666 {:handler dev.handler/handler}
            9667 {:handler dev.handler2/handler}}

$ clj
Clojure 1.10.3
user=> (do (require '[shadow.cljs.devtools.server :as shadow.server])
           (def config (shadow.server/load-config))
           (shadow.server/start! config))
...
shadow-cljs - HTTP server available at  # 1️⃣ First server
...
shadow-cljs - HTTP server available at  # 2️⃣ Second server
...
:shadow.cljs.devtools.server/started
user=> 
Now I would like to turn on the second http server using a CLI argument. I remove the second http server from shadow-cljs.edn and configure it during runtime. For the simplicity of the example, I don't do any CLI arguments parsing here, but instead just prepare the config on the fly:
$ head -n 5 shadow-cljs.edn
{:deps true
 :nrepl {:port 7888}
 :socket-repl {:port 9002}
 :dev-http {9666 {:handler dev.handler/handler}
            #_#_9667 {:handler dev.handler2/handler}}

$ clj
Clojure 1.10.3
user=> (do (require '[shadow.cljs.devtools.server :as shadow.server])
           (def config (shadow.server/load-config))
           (def config* (assoc-in config [:dev-http 9667] {:handler 'dev.handler2/handler}))
           (shadow.server/start! config*))
...
shadow-cljs - HTTP server available at  # 1️⃣ Only the first server
...
:shadow.cljs.devtools.server/started
user=>
Though the configs are seemingly the same during runtime, second server doesn't start anymore. I'd appreciate any pointers to the solution!
#2021-08-0218:48Ryan JerueWhen using the https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module target, is there a way to not have the output export certain definitions? Ideally ones that are marked as private?#2021-08-0218:50Ryan JerueIt looks possible ~:npm-library~ :node-library using https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_exports#2021-08-0219:03borkdudeDo you mean :node-library?#2021-08-0219:04Ryan JerueYes, :node-library . Should have copy/pasted 😅#2021-08-0219:18thheller:npm-module is pretty much dead anyways so prefer to use :node-library if you can#2021-08-0219:19thhellerbut :npm-module already only exports things marked with ^:export#2021-08-0219:28thheller@me1676 the dev-http stuff loads shadow-cljs.edn again and does not respect server/start! arguments. it loads the config itself since it automatically adjusts the servers if you change them while running#2021-08-0219:29thhellerwhats the point of starting it that way? my recommendation is always to use your own CLJ http server if you want anything beyond a basic static file server. even with just a :handler you should be using your own server. I even regret adding support for handler in the first place.#2021-08-0312:22mkarpThe point is convenience, I guess. Thank you for the answer! It's probably easier to start a separate server, yes#2021-08-0313:32zendevil.ethI’m facing this error upon compilation after I deleted node_modules and package-lock.json, and did npm i:#2021-08-0313:33zendevil.eth
Compilation failed!
The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".

Dependency Trace:
	humboi/app.cljs
	humboi/core.cljs
	humboi/events.cljs
	node_modules/@alch/alchemy-web3/dist/cjs/index.js
	node_modules/web3/lib/index.js
	node_modules/web3-eth/lib/index.js
	node_modules/web3-eth-accounts/lib/index.js
	node_modules/crypto-browserify/index.js
	node_modules/create-hash/browser.js
	node_modules/cipher-base/index.js
	node_modules/stream-browserify/index.js
#2021-08-0315:06Ryan JerueIf you look inside of your node_modules/readable-stream folder, can you find the writable.js in there? There may be a version mismatch between what stream-browserify expects and what you have installed.#2021-08-0313:33zendevil.ethI did do npm i -s readable-stream#2021-08-0313:36zendevil.ethAfter doing npm i stream-browserify:#2021-08-0313:37zendevil.ethhttps://gist.github.com/zendevil/1b3539ce5238cf2fa5e3ba212187abae#2021-08-0317:16thheller@ps install shadow-cljs in the project#2021-08-0317:17thhellerif you have that then the error is a dependency conflict somewhere#2021-08-0317:18zendevil.ethOkay it’s the latter I think #2021-08-0403:47zendevil.ethI guess it was because of stream-browserify dependency. After uninstalling it, this is what I get:
The required JS dependency "stream" is not available, it was required by "node_modules/cipher-base/index.js".

Dependency Trace:
	humboi/app.cljs
	humboi/core.cljs
	humboi/events.cljs
	node_modules/@alch/alchemy-web3/dist/cjs/index.js
	node_modules/web3/lib/index.js
	node_modules/web3-eth/lib/index.js
	node_modules/web3-eth-accounts/lib/index.js
	node_modules/crypto-browserify/index.js
	node_modules/create-hash/browser.js
	node_modules/cipher-base/index.js
#2021-08-0404:53zendevil.ethand npm i -s stream makes no difference#2021-08-0407:00thheller@ps again. do you have shadow-cljs installed in your project?#2021-08-0407:00thhellerplease verify by checking <project>/node_modules/shadow-cljs. this should also ensure that <project>/node_modules/node-libs-browser exists?#2021-08-0407:01thhellerstream is one of those built-in node packages that needs polyfills for browser builds which should be present if you have shadow-cljs installed in the project#2021-08-0407:07zendevil.ethyes it’s installed:#2021-08-0407:07zendevil.eth
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "0575776c6e766d6071766d647768644555776c6e766d60717628486466476a6a6e2855776a"}, :content ("[email protected]")}
#2021-08-0407:09thhellerthis is again related to the stream-browserify package. did you sort of the version conflict? or which version of shadow-cljs do you use?#2021-08-0407:17zendevil.ethI don’t know what the version conflict is if any#2021-08-0407:20zendevil.ethnevermind it started working after installing and uninstalling a bunch of packages#2021-08-0407:25thhellerthat usually indicates version conflicts#2021-08-0407:51borkdudeI am trying to make React optional for an :esm module, so that the npm installed one will be used instead of using a built-in version of React. I thought I could do this with:
{:deps true
 :builds {:modules {:js-options {:keep-as-import #{"fs" "module" "path"}
                                 :resolve {"react" {:target :global
                                                    :global "React"}
                                           "react-dom" {:target :global
                                                        :global "ReactDOM"}}}
                    :compiler-options {:infer-externs :auto}
                    :target :esm
                    :runtime :node
#2021-08-0407:52borkdudebut what I'm getting in this case is:
shadow-cljs - failed to load 0
ReferenceError: React is not defined
#2021-08-0407:55thhellercan't do that in node. there is no global React#2021-08-0407:55thhellerjust put it in :keep-as-import#2021-08-0407:55borkdudeaaaah#2021-08-0407:55thheller:keep-as-import just tells the compiler to not bundle a thing and instead let the runtime import sort it out (so node in your case)#2021-08-0407:55borkdudethat's excellent#2021-08-0407:56thhelleralthough that is pretty much going to be trouble in the ESM case#2021-08-0407:57thhellersince React only ships commonjs ["react" :as react] might not work, might need to be ["react$default" :as react]#2021-08-0407:57thhelleras long as shadow-cljs bundles the commonjs is not a big problem but once it doesn't it might be#2021-08-0407:57borkdudethat's fine. it seems it works as is, but I'm getting an advanced compile error.
^

TypeError: d.Sf is not a function
    at x8.$APP.g.flush_render (file:///private/tmp/tbd/out/nbb_reagent.js:44:344)
    at x8.$APP.g.flush_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:313)
    at x8.$APP.g.run_queues (file:///private/tmp/tbd/out/nbb_reagent.js:43:414)
    at Timeout.a [as _onTimeout] (file:///private/tmp/tbd/out/nbb_reagent.js:43:50)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
#2021-08-0407:58thhellerlooks like externs#2021-08-0407:58thhellertry shadow-cljs release thing --pseudo-names or --debug#2021-08-0407:58thhellerthat'll give you a more accurate names and the externs your are missing#2021-08-0407:58borkdude:thumbsup:#2021-08-0407:59thhellerwhen shadow-cljs doesn't bundle the JS dependencies the externs it usually infers from doing so are also missing#2021-08-0408:00thhellerso sometimes needs a hand. usually just a few words in https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs is enough#2021-08-0408:00borkdudewith --debug it started working ...#2021-08-0408:01borkdudeI'll try --pseudo-names as well#2021-08-0408:01thhellerdebug is just :pseudo-names true and :source-map true? that shouldn't affect externs related things#2021-08-0408:01borkdudealso works...#2021-08-0408:01borkdudecan't help it :)#2021-08-0408:01thhellerI mean it still renames stuff#2021-08-0408:02thhellerwell you'll still need to figure it out. don't shit pseudo-named output 😛#2021-08-0408:03borkdudeyes :)#2021-08-0408:06borkdudenot sure, but it could be from here: https://github.com/reagent-project/reagent/blob/c214466bbcf099eafdfe28ff7cb91f99670a8433/src/reagent/impl/batching.cljs#L85#2021-08-0408:09borkdudeThat does seem to have done the trick. I have put nbb/externs.txt with:
componentQueue
and now it works...
#2021-08-0408:22borkdudeWhat's the best practice on source maps? The source maps in my project are way bigger than the sources itself. I guess I should remove them when publishing the package?#2021-08-0408:44borkdudeI don't even know why these source maps are being created#2021-08-0409:02borkdudehmm, it seems when depending on a keep-as-import-ed "react", it won't use a local react. $ nbb ink-demo.cljs
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'react' imported from /usr/local/lib/node_modules/nbb/out/nbb_reagent.js
Perhaps I should just split out the reagent module into a separate npm package and just depend directly on react there, without keep-as-import.
#2021-08-0409:09borkdude(since the reagent module is 'required' using import, it doesn't use the createRequire-ed logic, and I haven't found out a way to fix this yet)#2021-08-0411:38borkdudeI tried dynamic importing react from the script-relative path before dynamic importing reagent itself, but it seems reagent still wants to load react from the nbb installed relative path#2021-08-0411:40borkdudeI think the user should be able to install react into the globally installed nbb node-modules, as a choice.#2021-08-0411:40borkdudePerhaps npm supports this#2021-08-0411:59borkdudeok, it seems this works. npm install -g nbb --no-optional now doesn't install react#2021-08-0411:59borkdudeit might be nicer if npm had a finer-grained way of saying: I want only optional dep this and that, but ok#2021-08-0418:49amarIs there a way to watch without live reloading? I'm trying out Pulumi for infrastructure as code and have been successful using compile but that's a longer feedback cycle. When using watch shadow is waiting to make a connection I think via a websocket when I run pulumi up. Looking for a way for watch to only compile the code, not reload.#2021-08-0419:41Ryan Jerue:devtools {:enabled false} on your build does this I think#2021-08-0506:10thhelleryeah, that'll disable hot reload and the REPL but still recompile on file change#2021-08-0513:52amarsweet. thanks!#2021-08-0514:33amari can confirm that works. Thanks @U01GNU0Q0MB and @U05224H0W#2021-08-0422:48Drew VerleeMy goal is to try devcards (or anything like it really), what is setting the compiler-options to devcards doing in this example from the docs?
;; Here is some dev-specific config
   :dev {:compiler-options {:devcards true}}
#2021-08-0910:58martinklepschYou can get a live devcards pretty easily with sci which is quite cool. Obviously misses lots of things but I think its promising https://martinklepsch.org/100/interactive-design-system-docs.html#2021-08-0422:51dpsuttondevcards stuff all uses a macro that if that compiler option is not set the macro expands to nothing. it's to ensure that your build isn't inflated for production#2021-08-0422:53dpsutton is the where the compiler env is checked and then is an example usage. there are 24 such checks in that file#2021-08-0506:15thheller@borkdude if you want react to be optional you'd need to use the same createRequire path you used for the intepreter#2021-08-0506:16borkdudeI tried this, but the builtin reagent doesn’t seem to be satisfied if I require react myself this way before loading reagent itself #2021-08-0506:18borkdudeI mean, it seems it still wants to load react relative to nbb itself instead of relative to the script #2021-08-0506:20thhelleryeah thats what I mean. if you require it from the ns it'll be relative to the source itself#2021-08-0506:20thhellerso the global install. if you instead require it dynamically via createRequire it should be fine#2021-08-0506:22thhellerIIRC there is also an enviroment variable NODE_PATH or NODE_INLUDE_PATH or something like that#2021-08-0506:22thhellermaybe you can find a way with that. needs to be set before starting node though so might be tricky#2021-08-0506:29borkdudeIf you require it from the ns… doesn’t Reagent itself require react from the ns? How can I make that use createRequire?#2021-08-0506:36thhelleroh right. forgot that you are not in control of that require#2021-08-0506:37thhellerdid you experiment with a simple node script that creates a secondary process actually running nbb? that way you can control the NODE_PATH env or whatever. assuming thats actually still a thing#2021-08-0506:42borkdudeI didn’t do that yet, but this may be the most flexible solution, if it works. I guess it could also just be a bash script #2021-08-0508:07borkdudeSo I guess I'll have to rename my bin to nbb-runner and expose an additional nbb script which is bash on linux/macOS and .cmd or so on Windows with:
#!/usr/bin/env bash

NODE_PATH=$NODE_PATH:$PWD/node_modules nbb-runner 
#2021-08-0508:08borkdudeor actually, not PWD, but the node_modules relative to the script rather#2021-08-0508:08thhellerpretty sure you must not specify the node_modules#2021-08-0508:08borkdudeI did have to do that#2021-08-0508:08thhellerdefault node resolve rules will append that anyways?#2021-08-0509:20borkdudeI've made some notes here: https://github.com/borkdude/nbb/issues/25#2021-08-0509:25borkdudeIt seems you can "hack" using module.constructor._initPaths which, if this isn't _too_ hacky, is my preferred solution as this makes deploying stuff much easier#2021-08-0509:26thhellerseems reasonable#2021-08-0509:30borkdudedo you mean the module.constructor hack?#2021-08-0511:18thhelleryeah#2021-08-0511:19borkdudeyeah, might work. I tried to incorporate this into nbb.main but it complained about module not being available in ESM module scope#2021-08-0511:21thhellerpretty sure thats the "module" require?#2021-08-0511:23borkdudeI just wrote (js/module.constructor._initPaths) etc#2021-08-0511:23borkdudeI didn't require "module" explicitly (but I think I have done this in the past and that failed as well)#2021-08-0511:25thhellerrequire('module').Module._initPaths()#2021-08-0511:26borkdudeyou mean via the createRequire?#2021-08-0511:26borkdudethere I think I need import.meta.url to pass it to the createRequire#2021-08-0511:26borkdudeand google closure won't allow this in advanced compilation :/#2021-08-0511:31thhelleryo do not need that#2021-08-0511:33thhelleryou can require that normally in your code#2021-08-0511:33borkdudebut require doesn't work in this ESM module#2021-08-0511:34borkdudeI can't write (js/require ...), that is not allowed#2021-08-0511:34thheller(:require ["module" :as m]) (m/_initPaths)#2021-08-0511:34borkdudelet me try that#2021-08-0511:35thhellerthe .Module seems to be a circular reference back to itself so you can skip that#2021-08-0511:36thhellerof course you need to add the path first#2021-08-0511:36thhellerjust calling init alone won't do anything#2021-08-0511:36borkdudeI understand#2021-08-0511:37borkdude
$ node out/nbb_main.js script.cljs
file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3
import$module._initPaths();
^

ReferenceError: import$module is not defined
#2021-08-0511:37borkdudethis might be because it's not a CommonJS module?#2021-08-0511:38thhellerhttps://github.com/nodejs/node/blob/master/lib/internal/modules/cjs/loader.js#L1227#2021-08-0511:39borkdudeI've found that function yes#2021-08-0511:39borkdudeit exists in the Node REPL etc#2021-08-0511:39thhellerwait WHERE did you require that#2021-08-0511:40borkdudein nbb.main#2021-08-0511:40thhellerin the script.cljs or in nbb code?#2021-08-0511:40thhellerand this was a regular compile not some REPL hot-reload or so?#2021-08-0511:40thhellershould be fine? don't see a reason why it wouldn't be#2021-08-0511:40borkdudeI've tried regular compile, advanced, both same error#2021-08-0511:41thhellerah hehehe#2021-08-0511:42thhellerhttps://github.com/thheller/shadow-cljs/blob/36b30359447391ac6fc360178ad5cd392aa1e1b2/src/main/shadow/build/js_support.clj#L134#2021-08-0511:42thhellerprobably running into that one 😛#2021-08-0511:43borkdudeshim on you#2021-08-0511:43thhellerhmm no wait that should be fine#2021-08-0511:43thhellerimport$module is the correct name. dunno why its not defined#2021-08-0511:44borkdudeI've seen errors like "module is not defined in import / ESM scope" before somewhere, can't recall exactly when#2021-08-0511:44borkdudeFWIW, pushed it here: https://github.com/borkdude/nbb/tree/init-paths#2021-08-0511:44thhellerthis is not that. you are importing it. so it is defined.#2021-08-0511:44borkdudeyeah ok. I could try JS interop directly after import#2021-08-0511:45thhellerthis is pointless
(when require
      (set! (.-require goog/global) require))
#2021-08-0511:45thhellerthere is no global require and there shouldn't be#2021-08-0511:45borkdudeit is not pointless since this makes (js/require "foo") work in the interpreted code#2021-08-0511:46thhellerI thought thats what https://github.com/borkdude/nbb/blob/init-paths/src/nbb/main.cljs#L20 is for#2021-08-0511:46borkdudeah gotcha. when using direct JS interop:
$ node out/nbb_main.js script.cljs
file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3
module["constructor"]._initPaths();
^

ReferenceError: module is not defined in ES module scope
#2021-08-0511:47borkdude@U05224H0W that :require require is passed to the namespace evaluation logic, but users can also do interop on the global object directly#2021-08-0511:47thhellerget rid of the constructor thats pointless#2021-08-0511:47thhellerand yes module without a require or import doesn't exist. that is expected.#2021-08-0511:47thhellerthats why you import it#2021-08-0511:47borkdude
$ node out/nbb_main.js script.cljs
file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3
module._initPaths();
^

ReferenceError: module is not defined in ES module scope
#2021-08-0511:48thhelleryou need to differentiate about what module you are talking about#2021-08-0511:48thhellerthe implicit module you get in commonjs code is different from the one you get via the "module" module#2021-08-0511:48thhellerso how you modify that is different depending on how you work with it#2021-08-0511:49thhellerso the implicit module you'd go via .constructor or .Module the others do not#2021-08-0511:49thhellerdon't have time now but maybe I can figure this out over the weekend#2021-08-0511:50thhellerthere have been a bunch of changes in the closure compiler regarding this as well so maybe the whole shadow.esm/dynamic-import stuff isn't necessary anymore#2021-08-0511:50borkdudecool#2021-08-0512:14borkdudeThis is the entire output btw:
$ node out/nbb_main.js script.cljs
file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3
cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([module], 0));
                                                                                                     ^

ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/borkdude/git/nbb/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/borkdude/git/nbb/out/cljs-runtime/nbb.core.js:3:102
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12)
(I just realized I left out the interesting bit perhaps)
#2021-08-0512:14borkdude(this is from (prn js/module))#2021-08-0512:15borkdudewhich is not right as I should be using m obviously#2021-08-0512:15thhelleryes, js/module is not supposed to exist#2021-08-0512:15borkdudeThis gives:
(prn m)
(prn (._initPaths m))
#object[Object]
nil
#2021-08-0512:15thhellerso it works fine?#2021-08-0512:16borkdudeno, the nil shows that _initPaths is not there#2021-08-0512:16borkdudeoops typo#2021-08-0512:16thhellerhmm yeah its calling the function and that returns nil? seems fine?#2021-08-0512:17borkdudeindeed, the function seems to exist...#2021-08-0512:17borkdudeok, I'm going to try some stuff now that this seems ok#2021-08-0512:25borkdudeseems to work :)#2021-08-0512:25thheller👍#2021-08-0512:31borkdudecrap, I think I was too early. it probably picked up a "react" from an earlier install in node_modules. it seems npm remove -g nbb doesn't clear that#2021-08-0512:31borkdudeit doesn't seem to work, alas#2021-08-0512:31borkdudeperhaps the dynamic import doesn't pick up on the NODE_PATH stuff#2021-08-0512:31borkdudeor the way how reagent requires react#2021-08-0512:33thhellerI thought for the interpreted code you are setting up the require via createRequire?#2021-08-0512:33thhellerI mean just don't use import in any interpreted code?#2021-08-0512:35borkdudeok, to tease things apart a bit: my nbb.core namespace is compiled as an ESM module my nbb.reagent namespace is compiled as an ESM module why? because code splitting only works with ESM modules currently nbb.core loads nbb.reagent on demand. the only way this works (I think) is via dynamic import (ESM modules) Then nbb.reagent loads a pre-compiled version of reagent. This doesn't run through the interpreter, it is pre-compiled. So that's just normal CLJS requires happening in reagent.#2021-08-0512:37thhellerah right. hmm yeah no idea about the ESM part#2021-08-0512:40borkdudeThe way it is solved currently is to just have an optional dependency on react#2021-08-0512:40borkdudeso when people load reagent, reagent loads the react dependency from nbb#2021-08-0512:44borkdudehttps://github.com/nodejs/modules/issues/534#issuecomment-661937336#2021-08-0506:16thhellerbut then you can't use the ns require for the parts shadow-cljs builds#2021-08-0511:38thhellerhttps://github.com/nodejs/node/blob/master/lib/internal/modules/cjs/loader.js#L1227#2021-08-0520:02borkdudelol:
$ npx shadow-cljs --force-spawn test modules
shadow-cljs - config: /Users/borkdude/git/nbb/shadow-cljs.edn
shadow-cljs - starting via "clojure"
TBD
I was wondering how to test my ;target :esm build.
#2021-08-0520:03borkdudeI could just compile it and then use another test runner (I've used cljs-test-runner before and that worked fine)#2021-08-0520:09thhellerjust use :target :node-test?#2021-08-0520:11borkdudewill this work together with :target :esm somehow? I don't know really where to start#2021-08-0520:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test#2021-08-0520:14borkdude
$ npx shadow-cljs compile test
shadow-cljs - config: /Users/borkdude/git/nbb/shadow-cljs.edn
shadow-cljs - starting via "clojure"
[:test] Compiling ...
========= Running Tests =======================
file:///Users/borkdude/git/nbb/target/test/test.js:5
var SHADOW_IMPORT_PATH = __dirname + '/../../.shadow-cljs/builds/test/dev/out/cljs-runtime';
                         ^

ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/borkdude/git/nbb/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/borkdude/git/nbb/target/test/test.js:5:26
    at file:///Users/borkdude/git/nbb/target/test/test.js:1571:3
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12)
#2021-08-0520:14borkdudeThat's what I was fearing#2021-08-0520:14thhellerI always recommend using a separate output directory per build. don't mix them#2021-08-0520:15thhellerso you output the esm stuff to packages/nbb with its own package.json in that dir#2021-08-0520:15thhellerand tests whereever but not in that dir#2021-08-0520:15thhellerthat way you also never have to worry about including files in the published package that shouldn't be there (eg. cljs sources)#2021-08-0520:16thhelleror create a test-out with its own package.json. really up to you#2021-08-0520:16thhelleror just output-to to a .cjs file like the error suggests. many possible solutions#2021-08-0520:17borkdudebut isn't the point of the tests that they can load my app code?#2021-08-0520:17borkdudetrying .cjs#2021-08-0520:17thhellerthe compiled version no, your namespaces sure#2021-08-0520:49borkdudeis it possible to add a src dir test only for the test build?#2021-08-0520:50borkdudeI am using :deps true#2021-08-0520:50borkdudesomething like :aliases [:test] on the level of the build for example which would pull in :extra-paths ["test"]#2021-08-0606:19thhellerhttps://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html#2021-08-0606:19thhellerjust put it always on. it doesn't affect your builds in any way.#2021-08-0607:50borkdudeI'm using :deps true but I'll use :deps {:aliases [:test]} then#2021-08-0520:12thhellertests are separate builds. there is no special test target for :esm#2021-08-0608:16Ar NazehI am trying to consume a library that is using the experimental classProperties
static ERROR = ERROR
Is there a way to configure Shadow to work with that?
#2021-08-0608:21thhellerconsume how? what is the problem?#2021-08-0608:30Ar NazehJust importing it in a build that targets the browser
(ns app.client.hyper
  (:require ["hyperspace" :refer [Client Server]]))
and this is the error
Failed to inspect file
  /media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/arpeecee/index.js

it was required from
  /media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/hrpc-runtime/rpc.js

Errors encountered while trying to parse file
  /media/arnazeh/two/code/synonym/haystack/demo_cljs/node_modules/arpeecee/index.js
  {:line 60, :column 15, :message "'(' expected"}
But I know from trying the same thing with a create-react-app project that the problem is the experimental classProperties, it suggested using a https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties and pointed out this https://github.com/mafintosh/arpeecee/blob/master/index.js#L60 as the reason of the error.
#2021-08-0608:33thhellerwhich shadow-cljs version is this?#2021-08-0608:33thhelleras far as I know the closure compiler added support for this#2021-08-0608:34thhellermaybe not though. if you are on the latest version probably not.#2021-08-0608:34thhellerthen there is nothing to do unfortunately#2021-08-0608:35Ar Nazeh2.15.2#2021-08-0608:36thhelleryeah no luck then#2021-08-0608:37Ar NazehThanks#2021-08-0608:41thhellerwell you can always use webpack as described here in option 2 https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-08-0609:03Ar NazehI will try that#2021-08-0618:37lispers-anonymousI just upgrade to the latest version of shadow-cljs and my build report now has some of the dependencies in red. I think this means that the red dependencies are duplicated across modules. Is that correct? Example picture is attached#2021-08-0620:03thhellerhmm I guess thats a bug. its supposed to be red for duplicated npm packages only#2021-08-0620:44lispers-anonymousIt did also show up for duplicate npm packages. Would you like me to file an issue on github about it?#2021-08-0712:55borkdudeI may have hit a bug in shadow-cljs, but not sure. When I require a node module ["fs" :as fs] from two different namespaces, say nbb.main and nbb.core, I get
ReferenceError: import$fs is not defined
    at C8 (file:///Users/borkdude/git/nbb/out/nbb_main.js:8:313)
after advanced compilation. After this workaround, I got it working again: https://github.com/borkdude/nbb/commit/df0edd3c2a560ea3954dc6943a228c3d49668e75
#2021-08-0717:37thhellerlooked into it a bit and figured out what is happening. will see if I can fix it soon#2021-08-0717:57borkdudeok, it's not blocking me currently as I have a workaround, but I'm glad you found the issue#2021-08-0817:54thhellershould be fixed in 2.15.3. I also added :compiler-options {:js-provider :import} so you don't have to list every single package in :keep-as-import, it'll just import everything#2021-08-0818:02borkdudeLike this right?#2021-08-0818:07borkdude
The required JS dependency "fs" is not available, it was required by "nbb/core.cljs".
#2021-08-0818:09borkdudeWhen I put :js-options {:js-provider :import} directly on the toplevel of the build, then I get a different error msg:
The required namespace "react" is not available, it was required by "reagent/core.cljs".
#2021-08-0818:09borkdudeI'll revert that config for now#2021-08-0818:22borkdudeThe other issue seems to be resolved, thanks!#2021-08-0906:20thhelleroh my bad. should have been :js-options {:js-provider :import}.#2021-08-0907:09borkdudeI also tried that one and got me a different error about react. I’ll try again when I’m at the computer #2021-08-0907:09borkdudeOh yes, that’s exactly what I already tried, see above.#2021-08-0715:08whackedanybody familiar with how (whether?) shadow-cljs caches macro output? I have a cljs file -- let's say myns.cljs -- which includes a macro defined in myns.clj. The clj file slurps a file and feeds it into cljs. When I change the slurped file, the cljs file does not get updated during watch. When I touch the clj file, then it does get updated. This is understandable. But I'm observing what looks like cached macro output when running release. What's the easiest way to force re-running all macros?#2021-08-0715:31whackedI have not yet played with :cache-blockers so I don't know if it's the same thing, but as a quick and dirty solution, it appears that rm -rf .shadow-cljs does cause a refresh. Since this works reliably in a toy example based off of shadow-cljs/quickstart-browser.git ~most likely~ my pipeline was messed up#2021-08-0722:47Parvesh MonuSubject: Use npm package with ES6 Syntax in shadow-cljs Hi everyone, I hope you all are doing great. I am very new to Clojure World. I am working on a ClojureScript, shadow-cljs project. I am trying to use an npm package in the project.I installed it using "yarn add react-native-swipe-list-view". On building it is showing Syntax Error: "Cannot use Import Statement outside a module" According to my research shadow-cljs implements a custom JS bundler and bundles node_modules into something that can be used with clojurescript. But that npm package uses ES6 Syntax and shadow-cljs having trouble bundling with that. I think I need to use babel to convert that into browser-friendly code first. I just need to figure out how to use babel to do that. It will be a big help if someone can point me to a resource to fix this issue. I posted other Info's like screenshots on this URL: https://github.com/status-im/status-react/pull/12432#issuecomment-894633595#2021-08-0806:35thhellershadow-cljs cannot bundle react-native stuff in general. it needs to go through metro or other react-native tools. building it directly is not supported.#2021-08-0807:58thhellerFWIW the problem here has nothing to do with shadow-cljs. you are using the :node-test target, which means that all JS requires are resolved by node. so your (:require ["react-native-swipe-list-view" :as swipe-list-view]) is just directly converted to a require("react-native-swipe-list-view") with no further processing by shadow-cljs for this#2021-08-0807:58thhellerthe error you get is then from node, since the file you required that way does an import#2021-08-0810:46Parvesh Monu@U05224H0W Thank you very much for your reply. You were right, problem was with :node-test. I was missing mock for package for testing and that's why it was crashing.
#2021-08-0801:20Drew VerleeWhat command are you running to get that error?#2021-08-0802:31Chris McCormickI wonder if I can solve the problem of "cljs project npm deps don't get picked up" by shipping my library on npm in the following way: • Build index.js with ^export s for JavaScript consumers. • Ship cljs source up to npm also. • cljs consumers can add node_modules/mylibrary/src to their :source-paths and add the library to package.json instead of using other deps mechanisms (as they do now with js deps). I wonder if it would be interesting/good if shadow-cljs automatically pickedup cljs sources from inside node_modules subdirs and added them to the cljs classpath so that this could become a standard practice for shipping cljs libs on npm? :thinking_face:#2021-08-0806:38thheller@chris358 what do you mean by "cljs project npm deps don't get picked up". shipping to npm will not solve anything and shadow-cljs will not pick up sources from node_modules ever. do not ship cljs libraries to npm. please describe the problem you are trying to solve more. is it just declaring npm dependencies so that projects depending on your CLJS lib can pick them up?#2021-08-0806:39thhellerif thats the case you can declare them in a deps.cljs file in the library containing {:npm-deps {"some-dep" "version"}}#2021-08-0806:40Chris McCormickThanks will try that.#2021-08-0912:40tianshuHow can I debug something like this, the error occurs when page hot-reload.
Uncaught ReferenceError: $map__115133 is not defined
    at Object.shadow$cljs$devtools$client$env$src_is_loaded_QMARK_ [as src_is_loaded_QMARK_] (env.cljs:257)
    at eval (env.cljs:279)
    at eval (core.cljs:5203)
    at eval (core.cljs:5203)
    at Object.eval [as sval] (core.cljs:3452)
    at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3509)
    at Object.cljs$core$seq [as seq] (core.cljs:1236)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2493)
    at Object.eval [as cljs$core$IReduce$_reduce$arity$3] (core.cljs:3519)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:2565)
Looks like something related to path? but the build succeed without errors, and page load with errors.
#2021-08-0912:44tianshuLooks like upgrade to latest shadow-cljs fix the problem.#2021-08-0912:50borkdude@doglooksgood Is this a node app?#2021-08-0912:50borkdudeYou might have to include something like:
:js-options {:keep-as-import #{"fs" "module" "path"
                                                   "react" "react-dom"}}
in your build. Wild guess.
#2021-08-0912:51tianshuNo, it's not a note app. I think there's something wrong in shadow-cljs 2.14.6.#2021-08-0912:51borkdudeok#2021-08-0912:51borkdudeFWIW 2.15.3 is already out#2021-08-0912:51tianshuI upgrade to 2.15.3, the problem is gone.#2021-08-0912:51tianshuyes#2021-08-0917:28Shantanu KumarI'm facing a weird error (Shadow-CLJS 2.15.3, re-frame 1.2.0 etc.) that happens only in the CI environment:
...
shadow-cljs - dependencies updated
[:webapp] Compiling ...
The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs".
#2021-08-0917:30Shantanu KumarThe same command (same Java and Node.js versions) works fine in my local. Any pointers would be helpful.#2021-08-0917:30thhellerdid you install the npm packages? edoes node_modules/react-dom exist?#2021-08-0917:33Shantanu KumarThe npm packages are automatically installed, but let me confirm that. Thanks!#2021-08-0917:48Shantanu KumarIt was npm package cache issue. Sorry about the noise.#2021-08-0920:47jmckitrickHi all, I’m deploying a luminus app with shadow-cljs to heroku. What’s the trick to getting the shadow part to find the dependencies it needs? I’m getting this:#2021-08-0920:48jmckitrickremote:    The required namespace "react" is not available, it was required by "reagent/core.cljs".#2021-08-0920:48jmckitrickLocally I just run npm install#2021-08-0921:47Ryan JerueWhat does your package.json look like?#2021-08-0921:47Ryan JerueIt could also be that npm install is not getting run as part of what is going to heroku#2021-08-0921:57jmckitrickThat’s where I’m stuck, after getting a bit farther.#2021-08-0921:57jmckitrickI’ve added this non-working step:#2021-08-0921:58jmckitrick["shell" "npm" "install"]#2021-08-0921:58jmckitrickin uberjars prep-tasks#2021-08-1010:50jmckitrickI needed to add a nodejs buildpack to my Heroku app config.#2021-08-1016:31rosadoI'm trying to build a react-native app for 3 targets: iOS, Android and web. So far I can only get those three targets when I have two separate projects, one including react-native, the other react-native-web as dependency (and some symlinking). Ideally I'd just have one project and one shadow-cljs.edn file but not sure how react-native and react-native-web can coexist in one project?#2021-08-1016:32rosadoI know about Expo, and we might end up using it, just wondering what do they do in there to achieve it#2021-08-1016:55thhellerjust create <project>/shadow-cljs.edn and <project>/rn and <project>/rn-web or whatever#2021-08-1016:55thhellerso you keep the outputs each in their own subdirectory, complete with their own package.json#2021-08-1016:56thhellerthen each build with :js-package-dirs accordingly https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules#2021-08-1016:56thhellerso :js-options {:js-package-dirs ["rn/node_modules"]}#2021-08-1016:58thhellersame way I setup the demo https://github.com/thheller/reagent-react-native#2021-08-1017:03rosadothanks, that's worth a try#2021-08-1118:51haywoodAnyone know why you can’t use an :advanced compiled :bootstrap host? I’m trying to figure out a work around but it’s not clear why it breaks down after advanced compilation.#2021-08-1118:52thhellersimply not possible. :advanced renames everything, deletes stuff that is unused, inlines stuff, etc#2021-08-1118:53thhellerso the code produced by the self-hosted compiler works against names that no longer exist#2021-08-1118:53haywoodcould I isolate the code that initializes the compiler and build it separately as a standalone js file and interact with it via interop?#2021-08-1118:54thhellerwhat would that do?#2021-08-1118:54thhellerI mean its not about the code that initializes the compiler, that part can be advanced compiled easily#2021-08-1118:55thhellerthe code produced by the self-host compiler requires that to be :simple though#2021-08-1118:55thhelleror do you mean your "host" build? meaning your regular app minus the compiler?#2021-08-1118:56haywoodwell, create like a mini host build that is essentially a couple of function to initialize and send strings to for evaluation#2021-08-1118:57thhellersure but again ... to be able to eval at all you need to have all code present?#2021-08-1118:57thhellerso the "mini" host build is not that mini#2021-08-1118:58haywoodit’s okay if it’s big, only some users will hit this part of the application, but right now the entire app is penalized#2021-08-1119:01thhellerself-host is a kind of difficult beast#2021-08-1119:02thhellerbut you can absolutely run a specialized self-host build in an iframe or so (different context is important)#2021-08-1119:02thhellerand the regular app stays small and :advanced#2021-08-1119:03haywoodinteresting, okay cool#2021-08-1119:03haywoodthanks for the info, really appreciate it. I’m gonna just hack my way into it and hope for the best 😅#2021-08-1119:04thhellerimportant aspect is that the host build using the self-host compiler + bootstrap are itself :simple#2021-08-1119:04thhellerwhich can run in an iframe or webworker or so#2021-08-1119:05haywoodI was thinking I could lazy load that separate host from advanced compilation when the route is initialized#2021-08-1119:06thhellerI'd strongly recommend not loading it into the same context#2021-08-1119:06thhellerthats basically asking for trouble#2021-08-1119:06thhellerits possible but easy to mess up#2021-08-1208:41borkdude@haywood depending on your needs, you could also use SCI to evaluate ClojureScript at runtime. It withstands advanced compilation.#2021-08-1214:07haywoodhuh, this looks worth evaluating, didn’t realize it existed, thanks!#2021-08-1214:07haywoodI have been hacking on paren-soup#2021-08-1214:08haywoodcompiler state is stored in my app db and is passed around to all the editor instances#2021-08-1214:09borkdudeI recommend looking at https://nextjournal.github.io/clojure-mode/. That demo also uses SCI#2021-08-1214:09borkdudethis website is also using SCI + clojure-mode: https://4clojure.oxal.org/#2021-08-1214:09haywoodyea it’s blowing my mind#2021-08-1214:10haywoodI have been running into perf problems with paren-soup… and this looks to be a huge improvement how did I miss this in my research 😭#2021-08-1614:29haywoodThis has been great and I’m almost done with the transition to SCI+clojure-mode, thank you so much for the library. dumb question and apologies for asking directly, but is there an easy way to evaluate strings in a specific namespace without prepending “in-ns” before the code I want to evaluate? I see some dynamic vars in the vars namespace but not sure I’m using it correctly.#2021-08-1614:39borkdudeYou can possible use sci/binding + sci/ns#2021-08-1614:39borkdudeEg check xterm-sci how to do this #2021-08-1614:48borkdude@haywood https://github.com/babashka/xterm-sci/blob/90393bdbcb6e27a0f12dff15d8ae98380dd67f20/src/xterm_sci/core.cljs#L56#2021-08-1614:49haywoodnice! will try this out, and thanks again#2021-08-1614:49borkdudeSure, let me know in #sci if you have any other issues#2021-08-1214:40victorbmight not be 100% the right channel, but I feel like the people lurking here is the right audience at least. I'm trying to consume a CLJS library from a JS project. I managed to get it to work mostly, but the library is using keywords for some arguments, and I'm lost trying to create CLJS keywords from JS-land. Anyone have any ideas?#2021-08-1214:41victorbgreat, just found my answer: https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js#2021-08-1215:43haywooddumb question, how can I specify a deps alias in a specific build? trying a bunch of options based on what’s in the docs#2021-08-1215:46borkdude@haywood shadow doesn't care about bringing in too many sources, like tests, so you can also just use all relevant aliases on the top level#2021-08-1215:46borkdudeunless you have some conflicting deps#2021-08-1215:51haywoodyea I’d like to keep the namespaces separate from another build, and I know I can pass -A:aliases when I build from the command line, but I’m compiling from the repl and not sure how to pass the aliases option#2021-08-1215:51haywoodbut perhaps you’re right and it doesn’t matter#2021-08-1216:42thheller@haywood alias per build is not supported and not required. just adding the dependency does not automatically include it in your build, so unless you build requires it directly via ns :require it won't be included#2021-08-1216:43haywoodgotcha, thanks for confirming! sorry for the noise#2021-08-1310:31alexdavisIs there a way I can build all cljs files in foo/*.cljs to an output-dir of bar/*.js? From reading the guide it looks like I have to explicitly specify every file/namespace symbol?#2021-08-1310:37borkdude@alex395 Perhaps using :modules / code splitting? E.g. for nbb I have:
{:deps {:aliases [:test]}
 :builds {:modules {:js-options {:keep-as-import #{"fs" "module" "path"
                                                   "react" "react-dom"}}
                    :compiler-options {:infer-externs :auto}
                    :target :esm
                    :runtime :node
                    :output-dir "out"
                    :modules
                    {:nbb_core {:init-fn nbb.core/init}
                     :nbb_main {:init-fn nbb.main/main
                                :depends-on #{:nbb_core}}
                     :nbb_reagent {:init-fn nbb.reagent/init
                                   :depends-on #{:nbb_core}}
                     :nbb_promesa {:init-fn nbb.promesa/init
                                   :depends-on #{:nbb_core}}}
                    :build-hooks [(shadow.cljs.build-report/hook
                                   {:output-to "report.html"})]}
          :test {:target :node-test
                 :ns-regexp "-test$"
                 :output-to "target/test/test.cjs"
                 :autorun true}}}
#2021-08-1310:38borkdudeand this outputs a nbb_reagent.js file and a nbb_promesa.js file#2021-08-1310:38alexdavisbut you have to specify the modules#2021-08-1310:38alexdavisI want to infer them from the files that exist in a given pathe#2021-08-1310:38borkdudewrite a script to generate the module configuration?#2021-08-1310:39alexdavisYeah... I was trying to avoid that 😄 I guess its fine though#2021-08-1310:39borkdudebut if you specify the main namespace of each directory which depends on the rest in that directory and nothing else depends on it, then it should work out with only specifying that one#2021-08-1310:47alexdavisHmm, just to be clear on what I'm trying to do, I have a nextjs project which transforms .js files that each have a default export function which gets turned into a lambda, and I want to write those .js files in cljs. So in my head I have a set of cljs/*.cljs files, and shadow will generate pages/api/*.js files for me, perhaps its not worth it and I should just learn javascript properly though...#2021-08-1310:48alexdavisI saw this build hook which is maybe an approach I can use, though it hardcodes the export (I guess thats fine though?) https://github.com/thheller/next-cljs/blob/master/src/main/shadow/next_js.clje#2021-08-1310:49alexdavisI guess the dream is for netlify/vercel etc to add support for bb/nbb 😄#2021-08-1312:16tbrookeI am trying to use a library that apparently has a dependency of js-dom - I get 88 errors with shadow-cljs as follows: node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js:13 constructor is missing a call to super() Has anyone run into this ? Or know of a fix?#2021-08-1316:37thhellerwhat are you building? which build :target? jsdom typically runs in node but the error you get is from the closure-compiler processing the code, which is only done for browser builds?#2021-08-1312:32Chris McCormick@tbrooke I have a library that depends on js-dom and it's successfully working with shadow-cljs, currently at version 16.4.0 of js-dom. What's the version there?#2021-08-1312:57tbrooke@chris358 Thank I checked and it was using 15.2.1 - trouble is that it ie buried in a slew of dependencies - I’ll try to upgrade it or get it upgraded#2022-05-2714:51emaunHi 👋 currently facing this same issue - did updating the js-dom version to the latest work for you or was there another solution you landed on? 🙂#2021-08-1313:10Chris McCormickIf it says ^15.2.1 then you should be able to npm i at the top level and it will use the updated version instead.#2021-08-1313:11Chris McCormickI'm not sure if that will help though.#2021-08-1315:09edoHey everyone, I’m learning Clojure(Script). Been doing a cljs frontend using jacekschae shadow-cljs-tailwindcss boilerplate https://github.com/jacekschae/shadow-cljs-tailwindcss. I’m confused on how to deploy it to heroku :thinking_face: On one hand package.json already contains the release script and I get everything I need to serve it inside the public folder. But in this case I’d serve a node.js app. On the other hand I think it would be more clean to create a jar and use heroku java buildpack. I can’t find any beginner resource that explains this clearly. Can someone provide some hints? TIA. ❤️#2021-08-1315:19lilactownnot v familiar with heroku, but i would imagine that if you don't have a backend that heroku has a way of deploying a static site#2021-08-1315:23edoYeah, I’ve been able to deploy the backend because with lein is much easier. My confusion comes from this mix with shadow-cljs but I see what you’re saying. I don’t need to make it dynamic, i.e., serve it with node or java.#2021-08-1315:24lilactownright. shadow-cljs is just a build tool that outputs JS files. you should be able to serve that via a static site w/o a backend#2021-08-1315:25lilactownFWIW I use netlify for my static sites, they're cheap (free) and easy to deploy via a public or private git repo similar to what I remember heroku doing#2021-08-1315:25lilactownif you're already invested in heroku that advice is probably not helpful tho 😄 sorry#2021-08-1315:25edoYeah I thought about that, but I already have a postgresql db and backend running on heroku :rolling_on_the_floor_laughing:#2021-08-1315:26edoSo I’d like to do this frontend deployment and as a next step deploy front+back together.#2021-08-1315:44Ryan JerueI’m not too familiar with heroku, but someone here did deploy something built with shadow to it recently https://clojurians.slack.com/archives/C6N245JGG/p1628542113248000 Vercel is also a pretty good (free!) tool to do this with. A now.json file like this was pretty useful https://github.com/rjerue/aoe2-facts/blob/release/resources/public/vercel.json#2021-08-1315:19lilactownI would look into that#2021-08-1405:58pezIn this talk, David Nolen demos using Krell to have two REPLs, running on separate devices, with separate state, using the same code base. https://youtu.be/3HxVMGaiZbc?t=2054 is something similar supported by shadow-cljs?#2021-08-1406:15thheller@pez what do you mean specifically? this is pretty much the default of how shadow-cljs works? only that you only need one process and not 2 separate ones?#2021-08-1406:15thhelleryou can connect as many devices as you want and/or run as many builds in parallel as you want (or your machine can tolerate)#2021-08-1406:16pezYes, I do that often. But can I control which REPL I am connected to?#2021-08-1406:17thhelleryeah thats a bit manual at the moment since no editor (wink, wink) has added support for manual selection yet#2021-08-1406:17thhellerquick overview you can check is http://localhost:9630/runtimes#2021-08-1406:18pezI’ll be happy to add it to Calva.#2021-08-1406:18thhellerit'll list all the runtimes and their id#2021-08-1406:18thhellerand when you can pick when when you start the repl via (shadow.cljs.devtools.api/repl :the-build-id {:runtime-id 123})#2021-08-1406:20thhellerthe id is also logged on startup by the runtime shadow-cljs: #4 ready!#2021-08-1406:20pezI’ve seen those. 😃#2021-08-1406:21thhellerthere is also (shadow.cljs.devtools.api/repl-runtimes :the-build-id) to get the data from the REPL without the UI#2021-08-1406:21thheller
[{:since #inst"2021-08-14T06:20:06.623-00:00",
  :proc-id "3133b4c9-82b9-4144-a0dc-68e8daddfdae",
  :connection-info {:remote true, :websocket true},
  :client-id 4,
  :user-agent "Chrome 537.36 [Win32]",
  :type :runtime,
  :lang :cljs,
  :build-id :browser,
  :host :browser,
  :dom true}
 {:since #inst"2021-08-14T06:20:07.205-00:00",
  :proc-id "3133b4c9-82b9-4144-a0dc-68e8daddfdae",
  :connection-info {:remote true, :websocket true},
  :client-id 5,
  :user-agent "Chrome 537.36 [Win32]",
  :type :runtime,
  :lang :cljs,
  :build-id :browser,
  :host :browser-worker,
  :dom false}]
#2021-08-1406:22thhellerfrom my test build that also has a webworker connected (which you can also REPL into)#2021-08-1406:22thhellerI renamed some stuff so its :client-id from that list#2021-08-1406:41pezThanks! I'll play some with this. Great stuff!#2021-08-1409:18pezI get a lot of #X ready! messages, with increasing id numbers. (And the id:s are bumped accordingly.) I’m using the :react-native target and have started a web and an iOS client. Looks like so after a while:
= web
#5 ready!
#7 ready!
#8 ready!
#10 ready!
#12 ready!
#14 ready!
#16 ready!
#17 ready!
#20 ready!

= iOS Simulator
#4 ready!
#6 ready!
#9 ready!
#11 ready!
#13 ready!
#15 ready!
What could be part of this is that I started the apps, then closed the lid on my laptop and made some breakfast to the family. Now opening the laptop again there is this. I think I just managed to reproduce the behaviour when closing and re-opening, but only in the web app. The runtime info looks like so:
[{:connection-info
  {:remote true,
   :websocket
   true},
  :since
  #inst "2021-08-14T08:45:55.502-00:00",
  :host
  :react-native,
  :type :runtime,
  :lang :cljs,
  :build-id :app,
  :proc-id
  "165ac90e-ac63-4516-9453-3c49e4f85815",
  :client-id 15}
 {:connection-info
  {:remote true,
   :websocket
   true},
  :since
  #inst "2021-08-14T08:53:30.446-00:00",
  :host
  :react-native,
  :type :runtime,
  :lang :cljs,
  :build-id :app,
  :proc-id
  "165ac90e-ac63-4516-9453-3c49e4f85815",
  :client-id 20}]
I can select the repl as per above, and evaluations happen in the right app.
#2021-08-1409:21thhellerthe ready message you get when the websocket connects. if that disconnects it'll attempt to reconnect, which gives you a new id#2021-08-1409:22thhellerdon't know why you'd get that many though. never seen that before. is it constantly reconnecting the websocket or does that actually have that many websockets open?#2021-08-1409:27thhellerthe only problem I remember was with android and react-native. that didn't disconnect the websocket when reloading the app. don't know if thats still a thing#2021-08-1409:59pezI can test that.#2021-08-1410:02pez> is it constantly reconnecting the websocket or does that actually have that many websockets open? Don’t know if this answers it, but if select an old id, I get no complaints, but when evaluating I get this message
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
#2021-08-1410:05pezIt seems that the :since doesn’t change. Can I rely on that, as long as the app is not reloaded?#2021-08-1410:05thhelleryeah, so the longer backstory to all of this: I built shadow.remote as the default remote mechanism for shadow-cljs. even the UI uses that to do everything it does. All REPLs use it. so ideally any editors would also directly connect to the shadow.remote endpoint. part of shadow.remote is a notification for when a runtime connects or disconnects#2021-08-1410:06thhellerthe editor would then be supposed to handle that and inform the user in some form of UI or auto select the next one etc#2021-08-1410:06thhellerthe regular REPL however is stuck in a block Read with no way to ask the user what they want to do#2021-08-1410:06pezCan I read about the remote API somewhere?#2021-08-1410:07thhellerso I had to compromise in picking the next one that arrives. however that logic doesn't apply if you specified one#2021-08-1410:07thhellercould be considered a bug I guess 😛#2021-08-1410:07thhellerhttps://github.com/thheller/shadow-cljs/blob/master/doc/remote.md docs are sparse at the moment#2021-08-1410:08thhellervery simple EDN (transit-encoded) messages over a websocket for now#2021-08-1410:09thhellertap> and the inspect UI runs over shadow.remote, so anything the UI displays you have access to as well#2021-08-1410:10pezUsing this I can solve the old issue with Calva not really knowing when the REPL is available.#2021-08-1410:10thhelleryes#2021-08-1410:11pezIt does make shadow-cljs very special from Calva’s POV, but may well be worth it to create a nice UI/Ux.#2021-08-1410:13thhellera shadow.remote over nrepl would be possible as well if that helps#2021-08-1410:15thhellerjust as a transport layer I mean. don't know how well that would integrate into your nREPL code though as the message flow is a bit different. usually nrepl doesn't push messages to the client without receiving a request first#2021-08-1410:15thhellerbut yeah all the extra ops you get are shadow-cljs specific#2021-08-1411:18pezI’d love me a shadow.remote over nrepl. Calva has ways to deal with “orphaned” incoming messages, so I should be able to weed out the ones from shadow/remote there.#2021-08-1411:24thhellerwell the messages you'd get are all marked as such, so "op" "shadow.remote" or so. haven't really looked into it too much yet#2021-08-1411:27thhellerthe thing I don't like about nrepl is that there is no explicit connection management. so you don't know when a connection starts or ends from the middleware perspective#2021-08-1411:27pezAs for the android react-native client. It doesn’t disconnect at app reload, as you remembered. It is cleaned away after a few seconds though. Both iOS and web disconnect immediately before reconnecting.#2021-08-1411:27thhelleryeah I added that cleanup specifically for android RN#2021-08-1414:15currentoorI’m trying to use react-bootstrap with shadow-cljs and I’m requiring like so
(:require ["react-bootstrap" :as bs])
But when I console.log bs roughly half the keys (component names) have no values
Image: {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, render: ƒ}
InputGroup: {$$typeof: Symbol(react.forward_ref), Text: {…}, render: ƒ, Radio: ƒ, Checkbox: ƒ, …}
ListGroup: {$$typeof: Symbol(react.forward_ref), Item: {…}, render: ƒ}
ListGroupItem: {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, render: ƒ}
Modal: undefined
ModalBody: undefined
ModalDialog: undefined
ModalFooter: undefined
Any idea why Modal and friends would not get imported?
#2021-08-1414:43currentoorI noticed this map also includes __esModule: true#2021-08-1414:43currentoornot sure if that that’s relevant#2021-08-1415:10currentoorI see a pattern, the components that are missing are all function components#2021-08-1415:10thhellernot sure. might be a version conflict?#2021-08-1415:11currentoorof what? react?#2021-08-1415:13currentoor(js/require "react-bootstrap/Tabs") does load the correct function component#2021-08-1415:13currentoorditto for (js/require "react-bootstrap")#2021-08-1415:14currentooralthough that might be something else?#2021-08-1415:16thhellerwhich :target is this?#2021-08-1415:17currentoor:browser but it’s an electron app with node integration in the renderer#2021-08-1415:21thhellerhmm might be the other problem again. try setting :js-options {:entry-keys ["browser" "main"]} in your build config#2021-08-1415:24currentooryup that worked!#2021-08-1415:25currentoorso getting rid of the default last "module" fixed it, that’s strange#2021-08-1415:26thhelleryeah, it has come up multiple times now#2021-08-1415:26currentoori see, well thank you so much for the help#2021-08-1417:28currentoorwith this setting, does that mean I cannot use some npm packages? i.e. do some packages require "module"?#2021-08-1420:34thhellerannoyingly some require that yes but after adding that more people reported problems than before#2021-08-1420:35thhelleroverall most packages seem to work either way#2021-08-1420:35currentoorthe weird and wonderful world of npm#2021-08-1420:39thhellerwell the transition to ESM away from CommonJS is going to bring many hurdles. this is one of them since commonjs<->ESM interop is tricky#2021-08-1420:40thhellerI would have expected this to go a little faster but so far it seems rather slow going#2021-08-1420:40thhellerno idea when it'll get better and how many weird patterns will emerge#2021-08-1420:41thhellerfrom a build tool perspective this is rather frustrating 😛#2021-08-1514:40currentooryeah i bet#2021-08-1417:48alexdavisIs there a way to output to the root directory? expo EAS requires the entry point to be a root level index.js file. I can make it work by copying shadows build/index.js to the root level and then doing a find/replace to fix the paths in the file, so is there a reason why shadow wouldn’t allow you to do this automatically?#2021-08-1420:33thheller@alex395 do this instead https://github.com/thheller/reagent-react-native/blob/master/react-native/index.js. :output-dir "." might also work but not recommended, no guarantee that shadow-cljs won't overwrite a file that you might need for something. preferable to have its own directory that you can delete at any point#2021-08-1420:42alexdavisThanks! I actually tried "." but it doesn’t generate the correct paths for the js/require calls, then I pretty much did what you’ve suggested there#2021-08-1420:36thheller:target :esm might also be an option. been a while since I looked at react-native stuff, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-08-1503:22Ronny LiHi everyone, I'm new to using the REPL so I just wanted to check if I'm doing everything correctly. I've got shadow-cljs and cursive so I followed https://gist.github.com/akovantsev/44e2a0e10908785d1f40d3d3bcfff574. I connect to the REPL just fine but it doesn't seem to be linked to my app. When I run (js/alert "foo") I don't see anything in the browser and doing @(rf/subscribe [:bar]) returns nil when I would expect it to contain values from the app-db. Any help would be appreciated!#2021-08-1506:00thheller@ronny463 check http://localhost:9630/runtimes. it should list your runtimes connected. there should be at least 2. how many do you have?#2021-08-1513:32Ronny LiHi Thomas, thanks for your help. I have 4 runtimes connected.#2021-08-1606:17thhellersorry so you have 2 runtimes for the :dev build. the REPL picks the one that connects first and evals there#2021-08-1606:18thhellerbtw :dev builds are an anti pattern in shadow-cljs. builds always represent the dev and release parts in one config#2021-08-1606:18thhellerdon't know why you have two runtimes though. do you load the code in an iframe or so?#2021-08-1700:41Ronny LiHi Thomas, thank you for your help. I had two windows open for localhost and my REPL was connected to the second one. Everything behaves as expected now 🙂#2021-08-1700:47Ronny LiAlso thank you for letting me know that the dev build is an anti-pattern. Going forward I'll rename :dev to :app#2021-08-1701:43nonrecursivehey y'all, i'm running into a strange issue. I'm using reagent and re-frame, and I have a component from namespace.a that includes a component from namespace.b. However, namespace.b/component is returning nil , which is very strange. namespace.b is requiring D3 with (:require ["d3" :as d3]) . D3 has been added to my package.json#2021-08-1701:43nonrecursiveif I take out the d3 require, then everything loads fine#2021-08-1701:45nonrecursiveAlso, this is only when the app initially loads. If I make a change and shadow reloads the page, then the namespace.b/component no longer evals to nil, and everything works ok#2021-08-1702:12nonrecursiveOK it looks like upgrading from shadow-cljs 2.8.something to 2.15.3 solved the problem 🎉#2021-08-1705:59thheller@nonrecursive always check the browser console. if the namespace fails to load for some reason it won't be available properly. browser console should tell you something at least#2021-08-1709:19Quentin Le GuennecHello, I have an issue with importing of a npm module in a cljc file in shadow-cljs:
------ ERROR -------------------------------------------------------------------
 File: /home/void/wp/crispeta/src/acme/web/ui/components.cljs
failed to require macro-ns "acme.web.utils.macros", it was required by "acme.web.ui.components"
Syntax error macroexpanding clojure.core/ns.
Call to clojure.core/ns did not conform to spec.
-- Syntax error -------------------

  (... (:require
        [camel-snake-kebab.core :as csk]
        ["semantic-ui-react" :as semantic-ui]))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input

-- Relevant specs -------

:clojure.core.specs.alpha/ns-form:
  (clojure.spec.alpha/cat
   :ns-name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :attr-map
   (clojure.spec.alpha/? clojure.core/map?)
   :ns-clauses
   :clojure.core.specs.alpha/ns-clauses)

-------------------------
Detected 1 error
#2021-08-1709:24thhelleryou can't do the string require in clojure#2021-08-1709:28Quentin Le GuennecOh I see.#2021-08-1709:28Quentin Le GuennecSo no macros using npm modules?#2021-08-1709:29thhellerdon't know what you mean by that#2021-08-1709:29thhellera macro runs in clojure so you cannot use them in the macro directly#2021-08-1709:29thhelleryou can however have the macro emit code that uses the npm module at runtime#2021-08-1709:29thhellerdon't know what your intent is#2021-08-1709:32Quentin Le Guennecoh I see#2021-08-1709:32Quentin Le GuennecI think that'll work, yes#2021-08-1819:22gregI'm experimenting with shadow-cljs run from clj, and I noticed I can't run pom action
$ clj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.15.4"}}}' -M -m shadow.cljs.devtools.cli pom
Unknown action.
compile watch work fine, but pom doesn't. Any idea what is wrong with this call?
#2021-08-1819:24gregThis is how the help looks like:
$ clj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.15.4"}}}' -M -m shadow.cljs.devtools.cli -h
Usage:
  shadow-cljs <action> <zero or more build ids>

Supported actions are:

     compile - ...
       watch - ...
       check - ...
     release - ...
   classpath - ...
   node-repl - ...
browser-repl - ...
   cljs-repl - ...
    clj-repl - ...
    clj-eval - ...
     clj-run - ...
         run - ...
        info - ...
         pom - ...
    npm-deps - ...
        test - ...
         aot - ...
        init - ...
        help - ...
      server - ...
       start - ...
        stop - ...
     restart - ...

Options:
-----
      --npm                internal, used by the shadow-cljs npm package
  -d, --dependency DEP     adds an additional dependency (eg. -d foo/bar:1.2.3 -d another/thing:4.0.0)
      --config-merge DATA  merges additional EDN data into the build config
  -A, --aliases ALIASES    adds aliases for use with clj, only effective when using deps.edn
      --source-maps        temporarily enable source-maps for release debugging
      --pseudo-names       temporarily enable pseudo-names for release debugging. DO NOT SHIP THIS CODE!
      --debug              enable source-maps + pseudo-names. DO NOT SHIP THIS CODE!
      --stdin              clj-eval from stdin
  -v, --verbose            verbose build log
      --force-spawn        spawn new process, do not connect to running server
      --cli-info           prints a bunch of information
      --via VIA            internal option, used by node script
  -h, --help
-----
So theoretically the pom is supported. but for some reason it doesn't work.
#2021-08-1906:20thhellerpom is done by the npm shadow-cljs script and only works when using shadow-cljs.edn. Otherwise there is no point and so the JVM code doesn't support it.#2021-08-2018:02gregI had shadow-cljs.edn in the project, and yes, using npm shadow-cljs pom worked fine for me. I've just thought there is a parity between js and jvm version#2021-08-2018:43thhelleryou seem to be misunderstanding something here. what do you mean by "js and jvm version"?#2021-09-0909:22gregBy "jvm version" I meant the thheller/shadow-cljs, the one distributed with maven, the one I could use with deps.tools#2021-08-1820:10gregIs there a cljs equivalent of clj' shadow.cljs.devtools.api? (I want to run #2021-08-1906:20thhellerno, thats not possible#2021-08-1913:13flowthing@thheller clojure-lsp feeds the result value of npx shadow-cljs classpath to clj-kondo. If shadow-cljs isn't installed locally, shadow-cljs prints a warning saying WARNING: shadow-cljs not installed in project. It prints it into stdout, which means it trickles all the way down to clj-kondo, which then proceeds to croak with an inscrutable error. Would it be possible to change the println calls here such that the warning is printed into stderr instead? https://github.com/thheller/shadow-cljs/blob/de52880090c7840ee30eb5369173c1bd7dd3055c/src/main/shadow/cljs/npm/cli.cljs#L783-L791 Looks like println -> log might do it?#2021-08-1914:02thhellersure, we can do that#2021-08-1914:07flowthingNice, thanks! I guess the main thing is that the stdout of npx shadow-cljs classpath never contains anything else than the classpath. 🙂#2021-08-1914:07flowthingI can make an issue later.#2021-08-1920:29dazldhey, is there any way to be able to watch a build, but not have live reload? I’m making a node script, and it’s being consumed by something that has its own watch semantics (mocha, in this case)#2021-08-1920:30thheller:devtools {:enabled false} in the build config#2021-08-1920:31dazldah hah! thank you, trying it out#2021-08-1920:31dazldI thought it was autoload false for some reason#2021-08-1920:35thhellerthat also works but that would still attempt to open the websocket and REPL connection#2021-08-1920:35thhellerwhich might be a problem depending on how the other things reloads stuff#2021-08-1920:36dazldit seems to work just fine, thank you#2021-08-1920:37dazldit was a problem in this case, had to completely disable devtools as you mention#2021-08-2018:10gregI noticed that when running shadow-cljs pom , it doesn't populate paths based on deps.edn. Is something wrong with this config? deps.edn:
{:paths
 ["src/main"]

 :aliases
 {:dev
  {:extra-paths ["src/dev"]
   :extra-deps {org.clojure/clojure       {:mvn/version "1.10.3"}
                org.clojure/clojurescript {:mvn/version "1.10.879"}
                thheller/shadow-cljs      {:mvn/version "2.15.4"}}}

  :test
  {:extra-paths ["src/test"]}}}
shadow-cljs.edn:
{:deps
 {:aliases [:dev :test]}

 :builds
 {:script {:target    :node-script
           :main      example.core/-main
           :output-to "lib/script.js"}}}
The pom command populates paths to pom.xml only if I add :source-paths to shadow-cljs.edn. Funny thing, because when I run watch command, there is a warning that these src paths are ignored, but for the generation of pom.xml it looks there is no other way but to duplicate these.
#2021-08-2018:41thheller@grzegorz.rynkowski pom is a command that only works when :source-paths and :dependencies are managed by shadow-cljs.edn ONLY. if you are using deps.edn use clj -Spom (with aliases if you need)#2021-08-2220:16Drew VerleeDoes shadow help/participate in resolving dependency conflicts or should i be looking to npm and package.json?#2021-08-2220:22Drew VerleeThe answer seems to be as i remembered it, i handle this at the npm layer.#2021-08-2305:09thhelleryeah, shadow only reads files from node_modules. it never modifies or puts any there#2021-08-2309:01dazldI have a slightly weird issue with shadow and node - I’m trying to require an npm lib, but it appears to be failing in an odd way. It works fine in a normal node repl. the values are behind proxy - could this be problematic in someway with shadow shims?#2021-08-2309:02dazldthe SHADOW import error looks suspicious too!#2021-08-2317:13thhellerthat error you get when you run code directly in the namespace like you do#2021-08-2317:14thhellersince it happens during loading of the file there is no better error to throw#2021-08-2317:14thhellerthe other no clue. remove the js-interop stuff, don't know what that does#2021-08-2317:14thhellerlog the return value of the parseHTML first, without all the get-in#2021-08-2313:24kardanHi, I’m might be confusing myself but I’m trying to Docker compose our dev environment and run shadow-cljs in a container. But starting to realise it will be difficult to get a browser repl up in this setup or can this be done? Sorry If I’m sounding confused, but that’s kinda what I am… 🙂#2021-08-2314:33eins78that should be entirely possible if you forward the right ports between the docker container and the host. if you’re playing around, some people have success this setup: VS Code with Remote Containers + Calva Extensions. this has all the parts you need (and more) and you can find more examples, e.g. https://stackoverflow.com/a/58064914 (once that is running it should be easier to make it work with plain docker)#2021-08-2314:41kardanThanks#2021-08-2321:20rbergerI am getting the following SLF4J errors if I use shadow-cljs 2.15.4 or 2.15.5 but not earlier versions:
[:app] Configuring build.
[:app] Compiling ...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
[:app] Build completed. (2733 files, 404 compiled, 0 warnings, 44.38s)
I have no idea how to figure out why. The code is using com.lambdaisland/glogi We were using version 1.0.116 and 1.0.128 (latest) Not sure what else would be interacting with shadow for log stuff like that. Any suggestions or known issues around this? Thanks
#2021-08-2405:10thheller@rberger this has nothing to do with shadow-cljs. it is code you are initializing during the build. assuming glogi, in a macro maybe. should go away if you add an actual slf4j impl to your classpath (logback, log4j, etc)#2021-08-2405:11thhellerI suspect the only change regarding this concerning shadow-cljs is that previously some output may have been directed to other places. so the warning was there it just didn't show up.#2021-08-2405:28rbergerBesides the warnings, It looks like none of the app logs are emitted when I am running shadow-cljs `2.15.4` or `2.15.5` , but runs fine with 2.15.3#2021-08-2405:29rbergerLet me confirm that#2021-08-2405:34rbergerI was incorrect. I still get logs, so its just the warnings then… Thanks#2021-08-2405:36thhellerI can assure you that nothing regarding this has changed in shadow-cljs for a very very long time. I setup jvm logging once and have not touched it since.#2021-08-2405:36thhellerthis is pretty much guaranteed to stem from glogi (or any other logging related thing you load)#2021-08-2405:37thhellerI looked at glogi and it appears to load pedestal log in a macro namespace#2021-08-2405:37thhellerthat in turn uses slf4j#2021-08-2405:38thhellerhttps://github.com/lambdaisland/glogi/blob/main/src/lambdaisland/glogc.cljc#2021-08-2405:38thhellerif you use that namespace that is the cause of the warnings#2021-08-2405:39rbergerRight, I assumed was some interaction between changes in shadow-cljs and glogi… I’ll ask the glogi folks if they know what’s up. At least I’m not blocked by it.#2021-08-2405:39thhellermight be fine to just add a logging lib to your dependencies#2021-08-2405:39thhelleror might require an actual logging config file#2021-08-2405:39rbergerHeh, whole point of using that library is to ignore all that stuff 😉#2021-08-2405:40rbergerPTSD from the logging wars#2021-08-2405:40thhelleryou can try shadow-cljs browser-repl#2021-08-2405:41thhellerand then (require 'lambdaisland.glogc) to see if the warnings show up#2021-08-2405:41thhelleralthough browser-repl might hide it somewhere#2021-08-2405:41thhellermaybe best shadow-cljs server and then separately shadow-cljs browser-repl#2021-08-2405:42thhellerglogi itself seems to be fine, just the glogc requires pedestal#2021-08-2405:42rbergerOk, appreciate the pointers!#2021-08-2410:37Pepijn de VosCan I do this with a shadow-cljs app? https://jupyterlab.readthedocs.io/en/1.2.x/developer/extension_dev.html#mime-renderer-extensions#2021-08-2415:20eins78i dont see why not – with the right config you can create a “npm/nodejs library” (as opposed to the browser-target bundle most projects use it for) • https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-modulehttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library#2021-08-2416:51thhellerthere is no such thing as a shadow-cljs app. but yes shadow-cljs can produce code that you can load this way. best option most likely is :target :esm. would help to have a plain JS example of an extension. then I could tell you exactly how it would look in shadow-cljs#2021-08-2416:52thhellerah this appears to be one https://github.com/jupyterlab/jupyterlab/tree/master/packages/pdf-extension#2021-08-2416:55thhelleras someone who has never done anything with jupyter: how easy is it to install? 😛#2021-08-2417:05thhellerconfig is straightforward
{:target :esm
 :output-dir "my-extension"
 :modules {:main {:exports {default my.extension/default}}}}


(ns my.extension)

(def default
  ;; a JS object similar to 
  #js {})
#2021-08-2417:06thhellerdon't know how exactly that default has to look for the extension to work but thats basic interop you definitely can express#2021-08-2417:07thhellerI'm unsure how the extension will resolve dependencies though. do they need to be bundled or is that handled by jupyter? if so you need this extra config
{:target :esm
 :output-dir "my-extension"
 :modules {:main {:exports {default my.extension/default}}}
 :js-options {:js-provider :import}}
#2021-08-2417:07thheller:js-provider tells shadow not to bundle anything and instead let the runtime provide it all (you need a very recent shadow-cljs version for all of this)#2021-08-2417:09thhellerthen in the :output-dir you need a package.json with "main":"./main.js"#2021-08-2417:10thhellerrelease builds will likely just work. compile and watch will likely require adjustments since I don't know what jupyter does to the code and how possible it is to get a REPL into whatever it produces#2021-08-2417:10thhellercompile may just work too though, really depends on what it does#2021-08-2417:25Pepijn de VosAh thanks. I'll meditate on that. I might need a slightly different type of extension, but probably will need to export an npm module either way. We'll see.#2021-08-2414:32borkdudeI'm trying to run tests for a :target :esm build using :target :node-test but it seems that compiles my tests not as an ecmascript module (which is not surprising) but how do I make that work together if I'm using esm features in the code which aren't available otherwise?#2021-08-2416:25thheller@borkdude doesn't exist currently. you could just make another :target :esm build and configure it manually without the conveniences you get from :node-test#2021-08-2417:16borkdude@thheller Ah right. What I did is make another module called :nbb_tests within the same build. And then just run that file with node manually which executes the tests via the init fn#2021-08-2417:16borkdudehttps://github.com/borkdude/nbb/blob/9b2ed912b6e8942dd599139e312ac3d4f0ba5b77/shadow-cljs.edn#L18#2021-08-2417:17thhellerdon't do that. make an extra build. you'll also need :compiler-options {:load-tests true}. otherwise release won't contain tests. might be what you want but I always recommend running tests in release mode to rule out :advanced causing issues 😛#2021-08-2417:21borkdudeyes, I noticed that, I do run tests after release but more like integration tests, invoking the main app with different use cases#2021-08-2417:22borkdudeso I should make an extra build but do I need to make a copy of the existing one and maintain everything in two places?#2021-08-2417:23thhellerthe problem with doing it in the main build is :advanced. the tests likely will keep code alive that would otherwise be removed. it'll also make the nbb package larger by however large your tests make everything. I doubt an end user will ever run them.#2021-08-2417:23thhellerif you don't care about any of that keep it in your main build. otherwise a separate config with a dedicated :output-dir would be best (IMHO)#2021-08-2417:36borkdudewill do that, but do I need to duplicate the config? this is no problem, just asking#2021-08-2417:36borkdudethanks a lot#2021-08-2417:37borkdudeI will make a Github Discussions topic for the ESM / CommonJS thing you reacted to on twitter, gotta run now#2021-08-2417:38thhellerI don't know what your tests will do so I cannot answer how much of the config you need to duplicate#2021-08-2417:38thhellerif the tests assume presence of certain module files then yes those you need to duplicate#2021-08-2420:07borkdudeyes, I want to test the modules exactly like in the production build#2021-08-2420:34borkdudeI think I've found a more workable solution:
--aliases :test --config-merge shadow-tests.edn
#2021-08-2516:00borkdudeThis turned out to work really well @thheller#2021-08-2516:03thhellernot what I would have done but sure that works 😛#2021-08-2516:05borkdudewhat would you have done, copy everything?#2021-08-2516:14thhellerhard to say since I don't know exactly what you are testing. likely I would just test namespaces directly without the whole modules business. but if thats exactly what you are testing I would have most likely copied the config yeah#2021-08-2516:15thhelleryou could go with :build-defaults {...} or :target-defaults {:esm {...}} too#2021-08-2516:17thhelleras a way to configure stuff for multiple builds#2021-08-2517:28borkdudenice, thanks#2021-08-2423:44lilactownI have a few namespaces that I only use from a REPL. if I change and save them, they get hot reloaded, and I can no longer reference them anymore from the REPL and have to restart my watch
#2021-08-2506:15thheller@lilactown see https://github.com/thheller/shadow-cljs/issues/905#2021-08-2514:59lilactownthat looks pretty much exactly what i'm running into#2021-08-2514:59lilactownI agree that I was surprised my file changes were causing a hot reload after requiring it from a REPL#2021-08-2519:12jimmySo I am in the unfortunate situation of having to include some pre-minified javascript into my project. I am using the node-library target and trying to export something that another javascript library can consume.
{:target :node-library
 :output-to "out/lib.js"
 :compiler-options {:infer-externs :auto}
 :exports {:hello react-cljs-poc.core/app}
I can run everything in dev fine, but when I go to do this build, closure is taking some of that already minified code and changing some keys in some objects. Those keys can't change sadly. The keys look something like this:
var Me = {
  day: {},
  week: {},
  month: {},
  year: {}
}
And after the closure compiler is done doing its magic it looks like this:
var Ij = {
  day: {},
  pd: {},
  month: {},
  year: {}
}
Short of turning off advanced compilation, is there anything I can do to make closure not do these sorts of transforms?
#2021-08-2519:20jimmyI'm guessing there is some manual externing I could try to do prevent this. But anytime I get this new minified code I'd have to redo that, which feels suboptimal#2021-08-2519:22thhellerhow do you create the object?#2021-08-2519:22thhellerif you create it via (js-obj "day" 123 "week" 123) it should be safe from renaming#2021-08-2519:22thheller:compiler-options {:infer-externs :auto} is the default, you don't need to configure that#2021-08-2519:23thhellerbasically the answer to your questions depends on what you do in the code#2021-08-2519:25thhellerhmm nevermind about js-obj, misremembered that#2021-08-2519:32jimmyNo, the object is in the pre-existing minified js#2021-08-2519:34jimmyI don't directly touch that object at all. The js exports a react component. I call that react component. Right now that is literally it. No props, no nothing.#2021-08-2520:48lilactownhow is the minified JS included in the project?#2021-08-2523:30jimmyI had just straight it as a file and required it. I’m beginning to feel like I should have put it in node_modules. Will work on it again tomorrow.#2021-08-2605:50thhellerwhat does "No, the object is in the pre-existing minified js" mean? how is it included in your build?#2021-08-2605:51thhellerif you include it via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js then it will end up going through advanced. so the only way to protect it there would be externs#2021-08-2613:23jimmyYeah, I was just straight up requiring a js file in the classpath. I moved it into node_modules and it worked. Figured that out after reading this > Resolves the JS via node_modules and includes a minified version of each referenced file in the build. It is the default for the :browser target. node_modules sources do not go through :advanced compilation. For me, I'd love to just be able to toggle that on a file level rather than having to put files in some particular location to get that behavior. But I get it and it is probably best that I go take this code and make it a package. (It is some propriety code that as shipped as a zip of poorly minified js. What I mean by the object being in the pre-existing minified js is that it is just an object literal in that js source file. I didn't realize requiring js files from node_modules vs requiring js files from elsewhere would have a behavior difference. I do admit I find that a bit strange.)#2021-08-2519:31wombawombaSo I'd like to get a basic in-browser REPL going. Is this something I could leverage shadow-cljs for?#2021-08-2520:46isakYea kind of. If you start the build, then go to the shadow-cljs dashboard (localhost:9630 for me), then you can go to the Inspect Latest tab and use the "Runtime Eval" box at the bottom.#2021-08-2521:09wombawombaHmm.. all I see there is No Taps yet. (tap> something) to see it here. Guess I'll try updating shadow-cljs and see if that helps (I'm on 2.12.4).#2021-08-2605:45thhellerwhat does "get a basic in-browser REPL going" mean? shadow-cljs browser-repl does that?#2021-08-2605:45thhelleror do you mean embedded in something?#2021-08-2605:46thhellerah .. in browser you mean. so from within your app?#2021-08-2605:46thhellerif its in development you can build on top of cljs-eval see https://clojureverse.org/t/status-update-inspect-cljs-eval/6074#2021-08-2605:48thhelleronly works while the watch is running though. but besides that you can build all UI you want yourself#2021-08-2609:30wombawombayeah exactly, in my app itself#2021-08-2609:30wombawombaI'll try building something on top of cljs-eval, thanks#2021-08-2609:34thhellerjust to be clear: this is for local development only. this can't be part of a "release" app as shadow-cljs should never run in any production environment#2021-08-2609:34wombawombaright, yeah#2021-08-2609:34thhellerbut if you just want something you can add via :preloads to aid local development that is totally fine#2021-08-2609:34wombawomba...on a related note, would it be possible to provide self-hosted CLJS (for eval) as a separate module, that can be loaded dynamically?#2021-08-2609:35wombawombaself-hosted is fine for now, but it sure would be useful to have something like this in production as well#2021-08-2609:35thhellerno, not possible per se. you could run it in an iframe or so separately but not part of the main app running in the same context#2021-08-2609:35wombawombaalright#2021-08-2609:36wombawombabecause of name mangling?#2021-08-2609:36thhelleryeah, if you want to run everything in :simple then it is possible#2021-08-2609:36wombawombaokay, shame#2021-08-2609:37wombawombain theory, would it be possible to "co-mangle" the names for self-hosted/non-self-hosted code so they'd be compatible?#2021-08-2609:38thhellerno. it is not just about mangling. :advanced does so much more. removing dead code, inlining, collapsing namespaces, etc#2021-08-2609:39wombawombaah okay#2021-08-2609:39thhellerbasically namespaces don't exist anymore with no way to restore them or map them back to anything meaningful#2021-08-2609:39wombawombagot it#2021-08-2609:40wombawomba...okay so how about this then#2021-08-2609:40wombawombacould I provide both simple and advanced builds?#2021-08-2609:41wombawombaso I'd default to advanced (for users) but somehow enable developers to run a (equivalent) self-hosted simple build#2021-08-2609:42thhellersure. don't know what problem that would solve though?#2021-08-2609:42wombawombadebugging in production#2021-08-2609:43wombawombaI use re-frame so if something is broken then I could just dump all my state and open it in the self-hosted build#2021-08-2609:43thhellerI have had "give me all the data" type of debug hooks in my apps#2021-08-2609:43thhellerso (defn ^:export debug-me [] (pr-str @re-frame.db/the-thing)) or so#2021-08-2609:44wombawombayeah exactly#2021-08-2609:44thhellerthen just import the data in a REPL locally and look at it#2021-08-2609:45wombawombaalthough I'm thinking I could use local storage to copy the state over to a new tab/window (that'd open something like .domain/$current_path) to make the whole process completely transparent#2021-08-2609:45wombawomba(debug.my.domain would serve the self-hosted build to IPs in my VPN)#2021-08-2609:45thhelleryeah but in my experience the problem isn't the data. the problem is "how did it get into this shape"#2021-08-2609:46wombawombayeah sure#2021-08-2609:46thhellerbut having some way to get the data is always useful#2021-08-2609:46wombawombaI'm already tracking and displaying re-frame state changes though so that's already solved#2021-08-2609:47wombawombaI'm embedding something similar to re-frame-10x in my app, so devs can see what's happening#2021-08-2609:47wombawombafor some situations though, I find it really useful to be able to manipulate data#2021-08-2609:48wombawombaso that's the main argument for having a REPL#2021-08-2609:48wombawomba(I mean, manipulate the data and have the changes reflected in the app)#2021-08-2609:49thhellersure, but just as the export you can also have a import thingy that just sets the new state#2021-08-2609:50thhellergoing full self-hosted means you are changing so much more about the structure of the code that you might not even run into the issues you are trying to debug in the first place#2021-08-2609:50thhellereg. if they are externs related#2021-08-2609:51thhellerand if you are able to replicate the problem after switching to self-hosted mode you should also be able to replicated in a local watch?#2021-08-2609:52wombawombayeah, but if I do it "in production" then it's trivial to reuse my session etc#2021-08-2609:53wombawombaI think replicating in a local watch would involve a lot of effort to work around stuff like my production CSP policy#2021-08-2609:54wombawombastill, if I had "dump/import data" buttons then I could support both those use-cases#2021-08-2609:54wombawombafor some problems access to the production backend probably isn't that important#2021-08-2609:54thhelleryeah no clue what your app looks like. I have done the export thingy in the past and it helped debugging for sure but much less than first expected 😉#2021-08-2609:56thhellerI was super excited at first and thought this is going to solve everything but ended up just being "hmm ok data is messed up but why?"#2021-08-2609:56thhellerthe data being corrupted I could already tell from the UI not rendering properly 😛#2021-08-2609:57thhellerbut I didn't have a track-all-changes thing so that would have helped a lot too I guess#2021-08-2609:57thhellerjust looking at a snapshot alone definitely is not all that useful#2021-08-2610:11wombawombaheh alright#2021-08-2610:11wombawombayeah I'm gonna go ahead and build this, and we'll see how useful it turns out to be 🙂#2021-08-2610:13thhellerlet me know how it turns out. I'm always interested in such things.#2021-08-2610:13wombawombawill do!#2021-08-2607:58mkvlris there a convention or existing solution to make :dev/after-load hooks not take effect when set in a library?#2021-08-2608:08mkvlrother than moving the function to it’s own ns that is#2021-08-2608:19thhellerhmm no not currently#2021-08-2608:25mkvlrmove it to another ns and on second thought think it’s fine#2021-08-2608:35thhelleris it used during dev of the lib or why does it even exist when it shouldn't run?#2021-08-2608:45mkvlr@thheller asked myself the same questions and came to the conclusion that it should not exists as part of the lib but in another dir like examples , outside of the lib classpath#2021-08-2608:49thhellerah ok#2021-08-2613:02tbrookeI am trying to use a javascript package (Accord Project Cicero and templatemark) that does not compile because of a pdfmake dependency - I checked and found pdfmake listed in clsjs so apparently that isn’t the problem — My error message in hopefully relevant part is: Caused by: RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. Invalid node in lhs: STRINGLIT / 15252:4 [length: 15] [source_file: node_modules/pdfmake/build/pdfmake.js] Node(GETPROP default): node_modules/pdfmake/build/pdfmake.js:15259:8 exports.default = void 0; Parent(ASSIGN): node_modules/pdfmake/build/pdfmake.js:15259:0 exports.default = void 0; I know this isn’t much information but I’m not a javascript guy any thoughts on this - I’ve googled without any luck#2021-08-2617:06thhellerthat is an error from the closure compiler trying to process the pdfmake sources#2021-08-2617:07thhellerI guess there is some code in there it doesn't like. can't do much about this from shadow, this is a closure-compiler problem#2021-08-2613:03SimonI keep getting a blank screen with Uncaught Error: Assert failed: Invalid Hiccup form: [nil] but the component is just this simple one
(defn heyson []
  [:div "heyson"])
i import it like this: [app.components.cashflows :refer [graph-fn heyson]] and it is used like this
[:<>
 [input-bar app-state]
 [heyson]
 [json-city-list @app-state
   (activate-modal app-state)]]
#2021-08-2613:03Simonwhen i comment out the component and refresh it works again
[:<>
 [input-bar app-state]
 ;[heyson]
 [json-city-list @app-state
   (activate-modal app-state)]]
#2021-08-2613:04Simonbut i need this simple component 🙂#2021-08-2613:09SimonIf i take the same component and input into another file it works fine. [app.components.cities.city-list :refer [json-city-list heyson]]#2021-08-2613:26SimonThe error is due to this import ["@ant-design/charts" :refer (Line)] inside the same file as the heyson component.#2021-08-2613:26Simonbut i can't just remove the import since its needed#2021-08-2614:03SimonThe issue had been solved! Just changed to a default import in the file where i couldn't import from. ["@ant-design/charts/es/plots/line" :default Line]#2021-08-2614:10SimonSo if you experience this error and you have found my post here do this: 1. Isolate the component that is causing the Uncaught Error: Assert failed: Invalid Hiccup form: [nil] error. 2. Go into the file where you imported this component from. Meaning the file in which you have defined the component that is causing the error. 3. Isolate which import/require is causing the trouble. 4. Try to replace it with a default import ["npmpackage/lib/component" :default Component] 5. Give this a thumbs up or down if it helped you. So that other people can now if it was useful, before they start reading 🙂 #2021-08-2613:05tbrookeAnother naive question I watched the recent David Nolan video where he talked about keeping javascript as javascript — I have some react components that contain the code I recently asked about that crashes - Can I compile the Component as javascript and not recompile it#2021-08-2617:48thhelleryour code doesn't cause the issue. the dependency does. you can use webpack or so to process the JS code after shadow-cljs is done with it.#2021-08-2617:48thhellerthat is what David is doing basically (just in a react-native context)#2021-08-2613:30borkdudeNol_e_n ;)#2021-08-2613:44borkdude@thheller I tried the suggestion from Twitter in a browser REPL:
(ns foo (:require ["goog$global.console" :refer [log]]))
That doesn't seem to work
#2021-08-2617:04thhellerwhoops I guess that could be considered a bug#2021-08-2617:04thhellerthats the special handling with strings in shadow-cljs#2021-08-2617:04thhellergoog$global.console does work#2021-08-2617:33borkdude@thheller perhaps a difference in REPL vs file?
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.866"}}}' -M -m cljs.main
ClojureScript 1.10.866
cljs.user=> (ns foo (:require [goog$global.console :refer [log]]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Unexpected error (ExceptionInfo) compiling at (REPL:1).
Invalid :refer, var goog$global.console/log does not exist in file <cljs repl>
foo=> (ns foo (:require [goog$global.console ]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:203).
goog$global.console does not exist
#2021-08-2617:36thhellernone of what regular CLJS does in this regard affects how shadow-cljs handles it. in shadow I have the extra restriction that strings are only allowed for JS dependencies#2021-08-2617:37thheller(:require ["clojure.string" :as str]) is valid in CLJS but not shadow-cljs#2021-08-2617:37thhellerI feel strongly about strings being only for not-regular-namespace JS code#2021-08-2617:37borkdudeI hadn't tried it with shadow.#2021-08-2617:38thhellerI'm surprised it doesn't work in CLJS though#2021-08-2617:38borkdude> not-regular-namespace JS Do you mean: always use strings for JS nss, or do you mean: there's also regular-namespace JS code?#2021-08-2617:38thhellerclosure-library is regular-namespace JS code technically (well at least some of it)#2021-08-2617:39borkdudebtw, this is the convention that clj-kondo has adopted as well: use strings for JS nss, then static analysis knows what's going on, so that's in line with shadow I guess. goog.* stuff is handled separately#2021-08-2617:39thhelleryou know goog.provide and goog.require etc#2021-08-2617:40thhelleryeah the issue I have with js-deps-via-symbol is that it relies on some wonky detection of whats present in the node_modules folder#2021-08-2617:40borkdudeI was about to support (:require [whateverjslib]) in nbb but perhaps I should not?#2021-08-2617:40thhellerie (:require [react]) is valid only if node_modules/react exists but not otherwise#2021-08-2617:40thhellerwith (:require ["react" :as react]) you at least tell the compiler that you intent to use JS code (and the :js-provider will know how to provide it)#2021-08-2617:41borkdudethat's also what nbb is currently suggesting#2021-08-2617:41thhellerbut js-provider is only a concept in shadow-cljs so I guess that is why I'm biased here#2021-08-2617:41borkdudethis makes it easier for nbb to know what to do#2021-08-2617:42thhellerthat being said .. I'm surprised goog$global.Thing doesn't work in regular CLJS. it should but there is an open ticket specifically about "globals" so maybe thats why it doesn't work#2021-08-2617:42borkdudeI'll stick to the string-subset of requires for JS libs for nbb, in line with shadow, which also works well for clj-kondo.#2021-08-2614:09Tiago Dall'OcaHello there#2021-08-2614:10Tiago Dall'OcaShould I add .shadow-cljs to my .gitignore?#2021-08-2615:42Ryan JerueI keep mine in there#2021-08-2617:05thhelleryes, absolutely. none of the files in there are meant to be version controlled#2021-08-2618:19jyriandHello, I'm trying out Expo with shadow-cljs I'm connecting to my iPhone device through the QR code. It was working ok until recently. Now I'm getting errors:
Error
21:09
shadow-cljs - remote-error, Event {
  "isTrusted": false,
  "message": "The operation couldn't be completed. Connection refused",
}

Stack trace:
   in registerError
   in errorImpl
   in console.error
   in error
   in shadow.cljs.devtools.client.shared.Runtime.prototype.shadow$cljs$devtools$client$shared$IRemote$remote_error$arity$2
   in shadow$cljs$devtools$client$shared$remote_error
   in shadow$cljs$devtools$client$websocket$start/socket.onerror
   in dispatchEvent
   in _registerEvents/this._subscriptions<
   in emit
   in __callFunction
   in callFunctionReturnFlushedQueue/<
   in __guard
   in callFunctionReturnFlushedQueue
   in parcelRequire<.sYUN</onmessage</<
  ...
Any ideas what be going on here? It was working and then, for no apparent reason, it stopped working.
#2021-08-2618:28thhellerguessing the app can't connect back to the shadow-cljs instance? maybe your network setup changed? wlan or something?#2021-08-2620:13jyriandDo I understand correctly that get-ws-relay-url should return url with the ip address not a "localhost" in case it's running in iOS?#2021-08-2620:13jyriandhttps://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/cljs/devtools/client/env.cljs#L98#2021-08-2620:21thhellerfor react-native builds server-host will be set https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/cljs/devtools/client/env.cljs#L83#2021-08-2620:21thhellerso its not using localhost since that won't work#2021-08-2620:22thhellerI'm assuming you are using :target :react-native in your build config#2021-08-2620:24jyriandYes#2021-08-2620:31thhelleryou can check the IP being used by running shadow-cljs clj-repl and then (shadow/get-server-addr)#2021-08-2620:32thhelleryou can override it should that not be correct#2021-08-2620:33jyriandOk. Thanks. It's 'localhost' for some reason#2021-08-2620:33thhellerdid you already configure it to be that?#2021-08-2620:34thheller:local-ip in shadow-cljs.edn or ~/.shadow-cljs/config.edn controls that#2021-08-2620:34thhellerneedless to say that localhost is an invalid value here 😛#2021-08-2621:25jyriandwas able to fix it with :local-ip "192.168.8.104"#2021-08-2618:36jyriandMight be, because it works if I open the app in the web#2021-08-2618:36jyriandThanks#2021-08-2620:23John PrestonIs anyone using shadow-cljs with Boot? I want to make an app with a frontend and backend but I'm struggling to get these two pieces to play together properly#2021-08-2620:43thhellerplay together in what way? I strongly recommend keeping them separate and letting each do their thing#2021-08-2620:43thhellerothers have done boot related things in the past but I can't remember any details#2021-08-2620:45andrzejsliwaHey I have problem with integrating firebase with shadow-cljs app:
shadow-cljs: #11 ready!
index.esm2017.js:985 Uncaught ReferenceError: regeneratorRuntime is not defined
    at PersistentConnection.value (index.esm2017.js:985)
    at eval (index.esm2017.js:979)
any ideas what could be missing
#2021-08-2620:47thhelleradd an extra (:require ["regenerator-runtime/runtime"]) somewhere in your project. ideally before JS deps are loaded#2021-08-2620:47thhellerseems like you have some polyfilled code#2021-08-2620:47thhelleror ideally bump :compiler-options {:output-feature-set :es8}#2021-08-2620:47thhellerdon't know what firebase supports#2021-08-2620:59andrzejsliwa
The required JS dependency "regenerator-runtime/runtime" is not available, it was required 
#2021-08-2621:03thhelleryeah you might need to install it first. just npm install regenerator-runtime. for reasons I don't understand babel rewrites some code to use that package without ever adding a proper require for it#2021-08-2621:04andrzejsliwabumping feature-set also did not help, i have tried everything above es8 (es2018, es-next, etc…)#2021-08-2621:06andrzejsliwaok, now its working after install regenerator-runtime#2021-08-2708:15valeraukoi was wondering if there's any chance of getting clojurescript compile to webassembly#2021-08-2708:51mkvlr@vale afaik not before webassembly supports gc https://github.com/WebAssembly/gc/blob/master/proposals/gc/Overview.md#2021-08-2708:57ribeloAt least for now webassembly is faster than jit in very few cases#2021-08-2708:57ribeloin many is also slower#2021-08-2708:58ribeloI don't suspect that compiling clj/cljs to wasm will ever be useful#2021-08-2714:05thhelleryeah I don't see the point either. maybe as a new dialect at some point but thats gonna have even more limitations than CLJS already has.#2021-08-2714:07William MizutaIs it possible to install dependencies from S3 like it is possible using https://github.com/s3-wagon-private/s3-wagon-private without using any other building tool (eg. leiningen)#2021-08-2714:08thhelleryes, that should just work. just specify :maven {:repositories ...} in shadow-cljs.edn#2021-08-2717:17hadilsGood morning! I have a an app which renders web pages from the server. I have some Clojurescript code running in the browser on startup — that is working. My question is, if I write Clojurescript code to be invoked from a web page, how do I set up the functions, so they can be referenced from inside the HTML?#2021-08-2717:19borkdude@hadilsabbagh18 This is what ^:export is for#2021-08-2717:20hadilsThank you @borkdude#2021-08-2717:20borkdudeIf you have namespace foo.bar with a function (defn ^:export foo []) then you can refer to it from the HTML like foo.bar.foo#2021-08-2723:08noonianHello, does anyone know if you can configure shadow-cljs to refresh npm dependencies when they change for local npm modules (not js files within my app)? My app depends on a JS component lib that I wan't to develop alongside my shadow-cljs app but shadow doesn't see changes without restarting the server#2021-08-2806:06thhellerthey should most definitely change after restarting the server. you can even skip restarting the server and just touch node_modules/your-lib/package.json#2021-08-2806:15thhellerFWIW the check whether a file was modified only uses the last modified timestamp, so make sure those actually change#2021-08-2812:44Jakub Holý (HolyJak)Hello! What do I need to override a dependency with a local one, and the changes visible in the UI (i.e. frontend code)? What I did is have, in my global ~/.clojure/deps.edn this alias:
:dev/fulcro-rad {:override-deps {com.fulcrologic/fulcro-rad {:local/root "/Users/me/Projects/external/fulcro-all/fulcro-rad"}}}
and then I simply added it to shadow-cljs.edn :
{:deps     {:aliases [:dev :test :sql :dev/fulcro-rad]}
I restarted npx shadow-cljs watch main but it seems that the modified code from the local override is not used there. So what else do I need to do? Remove some caches, ...? (The browser has dev tools open and "no cache if dev tools" enabled.) 🙏 Do I perhaps need to run frontend build in the dependency?
#2021-08-2818:39Yehonathan SharvitI have a Cljs library (klipse-clj) and I'd like to package it as an npm module to be consumed both in node and in the browser. I am using :target :node-library and shadow-cljs compile and it works perfectly for node. What am I supposed to do in order to bundle the lib as a single JavaScript file for the browser?#2021-08-2819:02thhellerwhat do you mean by "for the browser"? as is loaded direclty in the browser or after processing by some other bundler (eg. webpack)?#2021-08-2819:51Yehonathan SharvitLoaded directly in a <script> tag#2021-08-2907:43thheller@viebel how does it get there from npm? what does it do? I'm guessing when imported from npm someone calls a function? browser just a function call in a <script>? likely you want a secondary :browser build file. or you can put that file on a cdn/server somewhere and have people use that directly?#2021-08-2909:54Yehonathan SharvitI would like to have a single file to be loaded in as script tag. This file should expose a couple of global functions.#2021-08-2909:55Yehonathan SharvitShould I simply use npm release on the browser target and add {:export true} to the functions I'd like to expose?#2021-08-2910:11borkdude@viebel That's what I've done with scittle, I think the use case is similar#2021-08-2910:12borkdudeJust make .js files with exported functions and how you deploy these to npm or a CDN otherwise is up to you I guess#2021-08-2910:13Yehonathan SharvitThank you @borkdude. What's the best way to expose a JS bundle through npm?#2021-08-2910:14borkdudeFor scittle I've gone with jsdeliver + github branches, but probably npm is easier, so I might switch to that.#2021-08-2910:14borkdudeI haven't figured out exactly how that works, I think just place the .js file in a dist folder and then via jsdeliver you can refer to those files (it will download the package from npm and then cache the file forever I think)#2021-08-2910:15borkdudeI thought with KLIPSE you had already long figured this out. People can already use klipse via script tags, right?#2021-08-2910:25Yehonathan SharvitKlipse is a different use case as it is not aimed to be used as a npm library. I have a klipse.js bundle in a npm package. But here (klipse-clj) I need to make the code available in 2 flavours: 1. as a library (non-bundled) 2. as a standalone file It seems to me that it's not a good pattern to include both the code and the bundle generated from the code in npm. But I might be wrong!#2021-08-2910:26Yehonathan SharvitAlso, there is the question of the name of the global object: in node it should be global and for the the browser, it should be window!#2021-08-2910:26borkdudeThis is what goog.global is for#2021-08-2910:33thhelleryeah goog.global. the build targets assign that to whatever is correct for the platform#2021-08-2916:26Yehonathan Sharvitgoog.global is cool!#2021-08-2916:26Yehonathan SharvitWhat about my concern regarding having the code twice in a npm package @borkdude @thheller?#2021-08-2919:31thheller@viebel I really don't know enough about what you are trying to achieve. two builds in one package is fine. maybe create an extra package for the web stuff if its just going to come off a cdn or so anyways. lots of options, can't say more without knowing details of what people are going to do with this#2021-08-2919:47Yehonathan SharvitThank you @thheller. I think I have all the info I need#2021-08-3008:46danielnealheya has anyone been using shadow/expo/react native recently?#2021-08-3008:46danielnealI’ve been away from the area for a couple years#2021-08-3008:46danielnealand just going back to it for a hobby project#2021-08-3008:46danielnealeverything has moved on a bit and the new client doesn’t have the same ‘hot reload/fast reload’ it now has ‘fast refresh’#2021-08-3008:47danielnealI want to disable all that so can rely on shadows reloading, but I don’t seem to be able to switch off the reloading…I keep getting an error every time it reloads saying DevMenu not found#2021-08-3008:47danielnealI’m curious if anyone has any updates or tips since 2019#2021-08-3008:57borkdude@danieleneal fwiw since 2019 there's also krell, a tool that David Nolen built#2021-08-3008:58borkdudehttps://github.com/vouch-opensource/krell#2021-08-3008:58borkdudethere's also a #cljsrn channel about React native#2021-08-3009:04danielnealah yeah I did see the announcement but don’t know anything about krell. I guess that is separate from expo. I really like the expo client and convenience for sharing and building the project but maybe Krell is better#2021-08-3009:04danielnealthanks!#2021-08-3009:08Uken7@danieleneal Hi, I have been working with that stack, I'm pretty new on it, but I'm doing a hobby project with it. I found a repo that could help you: https://github.com/PEZ/rn-rf-shadow If you look at the commit history you'll find a commit that disables webpack's fast refresh. They say that it let's shadow's hot reload do all the work. I tried to do that and had no luck, it disabled both refreshes#2021-08-3009:09danielnealah yeah interesting. Thanks @u.sk8#2021-08-3009:09danielnealI think that commit is about disabling it for the web app rather than the rn app#2021-08-3009:09danielnealbut it does say maybe enabling and then disabling fast refresh might work#2021-08-3009:09danielnealI’ll try that#2021-08-3009:15Uken7I dont have problems to disable fast refresh in my rn app. I just shake my phone (or emulator) and disable from the dev menu. Maybe you need to update the libraries or put compatible versions. If you clone that repo it should work. The only problem I have with it is Expo warning me about a file that ends with .expo.js that Shadow (I think) produces and it will be no longer compatible with future expo versions.#2021-08-3009:31danielnealyeah I get that error, but also every time a reload happens I get some error about DevMenu.#2021-08-3009:31danielnealI’m on the latest version of expo and shadow, so possibly something changed#2021-08-3009:31danielnealI remember the ecosystem can be quite fragile#2021-08-3009:45Uken7As I said, I'm pretty newbie, so I would do the following: • Look at the versions of your npm libs and ensure are the same as the project from PEZ • Delete node_modules and any other output folder • npm i • Start shadow and then start expo I have noticed that not necessarily ultimate versions are the best, in fact, I found that using the lastest expo version didn't compile my project, so I used the PEZ' version. Also, deleting every output folder have solved me problems when I was updating my libs. Hope you can solve your problem :)#2021-08-3009:56alexdavisThe .expo.js error can be solved with an env var like this https://github.com/armincerf/kalm-mobile/blob/master/package.json though really I think that file should be renamed in shadow There is also a bug with expo where starting the expo go app with fast refresh disabled won't actually fully disable it, so you have to enable and disable it again for it to actually disable #2021-08-3009:57danielnealooh cool thanks @alex395#2021-08-3014:00SimonHey, how do i consume environment variables? I have defined one like this:
{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :target :browser
        :closure-defines {app.helpers.analytics/Greeting #shadow/env "HEY Simon"}
        :js-options {:ignore-asset-requires true}}
But then how do i get it so that i can do this:
(prn Greeting)
#2021-08-3014:02SimonI'm following this: https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2021-08-3015:31SimonFollowing this i need to use (goog-define variable-name "default value") But it only provides the default value and doesn't get overwritten#2021-08-3015:45SimonIt works with shadow-cljs release app -config-merge '{:closure-defines {app.envvars.core/APP_ENV :dev}}'#2021-08-3017:32thhellerapp.helpers.analytics/Greeting would be (goog-define Greeting ...) in (ns app.helpers.analytics) somewhere. should be fine.#2021-08-3114:13SimonYes thank you. Would be great with this example in the Shadow-cljs User Guide#2021-08-3116:38thhellerits in there https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2021-08-3014:21andrzejsliwaHey can you recommend any good template or blueprint for configuring pedestal together with shadow-cljs, I mean something which will handle full stack (clj, cljs, cljc)?#2021-08-3017:32thhellerpedestal doesn't care about shadow-cljs and shadow-cljs doesn't care about pedestal#2021-08-3017:33thhellerpretty much the only config you need to have in pedestal is that it serves the static .js files generated by shadow-cljs#2021-08-3017:33thhellercan't remember what that setting was. something ::http/file-root or so ::http/resource-root or so#2021-08-3017:48hadilsWhich closure complier should I be using with shadow-cljs 2.15.6?#2021-08-3017:52thhellerhttps://clojars.org/thheller/shadow-cljs lists it on the right side#2021-08-3017:52hadilsThanks.#2021-08-3017:52thhellercom.google.javascript/closure-compiler-unshaded v20210505#2021-08-3108:24FranklinHello 👋 , is there a way to get the shadow-cljs repl to indent output? or even add some coloring?
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1e7f6e7767715e7f6e776771334a767770754e7f7a"}, :content ("[email protected]")}
#2021-08-3108:25Franklinor, is there some kind of shell that would automatically indent edn that you know of?#2021-08-3110:25alexdavisyou could run your tests somewhere else, if you use emacs, cider has a good UI for test results https://docs.cider.mx/cider/testing/running_tests.html#2021-08-3116:38thhellerthis is cljs.test output. little shadow-cljs can do to influence that#2021-08-3114:59Daniel StrokovskyHi! What is the best / recommended way to wrap a library that uses a js library? Could it be used in a library built by figwheel? Some background: we want to create a common component library (built with shadow) but we are still using figwheel in one of our libraries so I was wondering if that would even work.#2021-08-3115:57lilactownif you're building a CLJS library your build tool shouldn't have much effect#2021-08-3115:57lilactownsince a CLJS app would include it as source, not as a built JS artifact#2021-08-3116:58thhelleryou might have some trouble with the js library though. out of the box figwheel doesn't provide those#2021-08-3116:58thhellerso you either need a cljsjs package alternative of the figwheel users need to use the new-ish :target :bundle from regular CLJS#2021-09-0108:08Yehonathan SharvitHow would it work if the app is built with shadow? I mean how will shadow know that a cljs lib A uses a JS lib B?#2021-09-0108:11thhellerin A you add a deps.cljs file with {:npm-deps {"lib-b" "version"}}#2021-09-0109:36Yehonathan SharvitDoes :npm-deps work only with shadow ?#2021-09-0109:37Yehonathan SharvitI am asking in two contexts: 1. Does lib A need to be built with shadow? 2. Does an app that consumes lib A need to be built with shadow?#2021-09-0109:43thhellerlibs are source only. they don't contain ANY compiled artifacts whatsoever. so no they have no reliance on shadow-cljs whatsoever#2021-09-0109:44thheller:npm-deps is a regular CLJS option, it is information only. acting on it may require calling a function. eg. cljs.main with --install-deps or so#2021-09-0109:46thhellerbut again ... the context here is a library doing something like (:require ["react" :as react])#2021-09-0109:46thhellersomething needs to provide react. shadow-cljs will just do so via npm. regular CLJS and figwheel will not#2021-09-0109:47thhellerso they either need cljsjs/react or using :target :bundle with webpack or so#2021-09-0109:47thheller(in both those cases :npm-deps are entirely irrelevant since the cljs compiler will not handle npm at all)#2021-09-0114:23Yehonathan SharvitThank you @U05224H0W for your explanation#2021-08-3118:54Jakub Holý (HolyJak)Is this the latest guide https://shadow-cljs.github.io/docs/UsersGuide.html? It reads > Version 1.0,Jan 10, 2018 > I suppose there have been changes since that?#2021-09-0105:38thhelleryeah I never update the date. date will be removed entirely soon ;)#2021-08-3118:59Jakub Holý (HolyJak)Also, did not shadow had a standalone web page? http://shadow-cljs.org/ points just back to the GH repo...#2021-08-3119:19Ryan JerueThere’s https://shadow-cljs.github.io/ It may be useful to update the url under About to one of those @U05224H0W#2021-08-3119:25Ryan JerueThat is the latest guide. I think the date is just wrong @U0522TWDA Source for the docs is here, I think https://github.com/shadow-cljs/shadow-cljs.org#2021-08-3119:26Ryan JerueCorrection … https://github.com/shadow-cljs/shadow-cljs.github.io#2021-09-0105:25thhellerwebpage is down currently. I'll work on restoring it soon#2021-08-3123:11Braden Shepherdsonis there a command I can send to my shadow-cljs session to kick all the connected tabs? I split my work between two computers, and while they both get code updates all the Fireplace.vim commands are going to only one of them.#2021-09-0105:24thhellerwhy kick? you can select which tab to talk to when starting the REPL. don't know how in fireplace though#2021-09-0108:45thhelleroh there is also :repl {:runtime-select :latest} (top-level shadow-cljs.edn) to always pick the last connected runtime for the REPL instead of the first#2021-09-0115:29Braden Shepherdsonooh! that sounds perfect. then I can just refresh when I switch machines.#2021-09-0115:31thhellerfwiw you can see the currently connected runtimes listed here http://localhost:9630/runtimes (or they log they id in the browser console on startup: shadow-cljs #4 ready! or so)#2021-09-0115:31thhelleryou can pick which runtime to talk to via (shadow.cljs.devtools.api/repl :the-build-id {:runtime-id 4})#2021-09-0115:31thhellerdon't know how fireplace does things so no clue how you'd tell it that#2021-09-0115:41Braden ShepherdsonI'd use :CljEval ...the above... to signal to the Clojure side of the REPL rather than the JS side.#2021-09-0115:55thhellerah so you can already supply the runtime id if you want to?#2021-09-0115:55thhellerthe automatic selection doesn't always give you what you want so having the option to pick is useful#2021-09-0103:03cjmurphyIs a :closure-defines value in shadow-cljs.edn able to be dynamic? By that I mean if I change it and force compile (or not) should the runtime pick up the change? I know these goog-define vars are compile time, but as there's continuous compilation with shadow-cljs I hoped I could change a value on the fly while developing (leaving it strictly at its default when not). I've got one that doesn't seem to be dynamic at the moment, but I'll try harder if I know they can be...#2021-09-0103:11cjmurphyIt is dynamic, but I have to refresh the page rather than force compile.#2021-09-0112:10javahippieWhen building my reagent-sources with shadow-cljs, I am seeing this warning that I don’t understand. r/atom is used in many places, but only this one occurrence is marked and I cannot get the warning to go away. Is this a bug or am I just not able to see the error?#2021-09-0113:37thheller@javahippie thats odd indeed. I assume you have proper (:require [reagent.core :as r]) in your ns?#2021-09-0113:38javahippieYes, that’s the whole :require#2021-09-0114:00thhellerthat is extremely odd indeed. especially given that it only warns after the third use#2021-09-0114:00thhellercan you check if there is maybe a hidden unicode character in the line?#2021-09-0114:00thhellersometimes they end up in there making an a not an actual a or so#2021-09-0114:01thhellertry typing that line again and just deleting the existing#2021-09-0114:06javahippieAh, that was exactly the issue, thanks a lot!#2021-09-0114:07thhellergotta love computers 😛#2021-09-0113:45martinklepschSince 2.15.5 the following command is producing an error
npx shadow-cljs -A:build:test compile test --config-merge '{:autorun false}'
Error building classpath. Specified aliases are undeclared: [:-A]
It doesn’t quite make sense to me since it looks like the aliases aren’t passed at all. Was there any change in shadow that could cause this?
#2021-09-0113:49thhellerare you sure you didn't upgrade clojure tools.deps recently?#2021-09-0113:49thhellerI mean that error is from clojure not shadow-cljs?#2021-09-0113:50thhellerwhats the full log?#2021-09-0113:50thhellerit should tell you which command it runs?#2021-09-0114:45martinklepschIt does appear to download a lot of dependencies but I’m not seeing a log that shows the clojure invocation#2021-09-0114:46martinklepschhttps://gist.github.com/martinklepsch/267d80cfd1070af99dffa8fd798974a2#2021-09-0114:52thhellerah thought it would log that. it'll run clojure -A:build:test -M -m shadow.cljs.devtools.cli watch app (for shadow-cljs watch app)#2021-09-0114:58thhellerdoes that work when you run it? unsure what else would be happening? there only was an unrelated change in the npm script recently?#2021-09-0117:51Drew Verleeimport LogRocket from 'logrocket'; would translate to (:require ["logrocket" :default LogRocket]) correct?#2021-09-0117:53borkdude@drewverlee nowadays you can also use ["logrocket$default" :as logrocket]#2021-09-0117:56thhellerwith the usual caveats https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports#2021-09-0117:56thhellerall depends on what the package is actually published as 😛#2021-09-0117:56Drew Verleereading and ty.#2021-09-0119:14currentoorHas anyone run into this error?
Must use import to load ES Module: /Users/toor/mutesync/shells/electron/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
#2021-09-0119:53borkdudeYes, that seems familiar (wink wink @dnolen @thheller )#2021-09-0119:58borkdude@currentoor This is how to do it with nbb:
npm install -g nbb
npm install node-fetch
fetch.cljs:
(ns fetch
  (:require ["node-fetch$default" :as fetch]))

(-> (fetch "")
    (.then #(.text %))
    (.then prn))
nbb fetch.cljs
And this should be similar when using shadow-cljs with :esm target
#2021-09-0119:59currentoorthank you @U04V15CAJ, what is nbb?#2021-09-0119:59borkdudehttps://github.com/borkdude/nbb#2021-09-0120:01currentoori don’t see this technique documented in the shadow-cljs dev guide#2021-09-0120:01currentooris it a temporary workaround or a standard API?
#2021-09-0120:01borkdudeThe :esm target is currently undocumented. This is how you can use it: https://gist.github.com/borkdude/7e548f06fbefeb210f3fcf14eef019e0#2021-09-0120:02borkdudeYou could also look at how nbb itself is built, it uses the same build target#2021-09-0120:05borkdudeThere is also this: https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-09-0120:07currentoorah i see#2021-09-0120:07currentoorthank you#2021-09-0209:31Franklinhello 👋 Do you think this error is caused by shadow-cljs or reagent?
react_devtools_backend.js:2850 Warning: Invalid attribute name: `cljs$lang$protocol_mask$partition0$`
    at div
    at eval ()
    at exports.CustomGallery ()
    at f ()
    at div
    at div
    at cmp ()
    at div
    at div
    at div
    at div
    at cmp ()
#2021-09-0209:32Franklinthe code
(ns quagga.components.dataview.photos.view
  (:require
   [reagent.core :as reagent]
   ["react-photoswipe-gallery" :refer (Gallery Item)]))

(defn photos-component
  []
  [:div.tab-page.photos-page {:style {:display "block", :overflow-x "scroll"}}
   [:div#tab-contentphotos.tab-content
    [:f> Gallery
    ;;  {:id "simple-gallery"}
     [:div
      {:style
       {:display "grid"
        :gridTemplateColumns "240px 171px 171px"
        :gridTemplateRows "114px 114px"
        :gridGap 12}}
      [:f> Item
       {:id "so-first"
        :title "Author: Folkert Gorter"
        :height "1600"
        :width "1600"
        :thumbnail
        ""
        :original
        ""}
       (fn [ref open]
         (reagent/as-element
          [:img
           {:src ""
            :ref ref
            :on-click open
            :style {:cursor "pointer"
                    :objectFit "cover"
                    :width "100%"
                    :maxHeight "100%"}}]))]]]]])
#2021-09-0209:48Franklingot an answer for this in #reagent#2021-09-0211:21borkdude@thheller Congrats on the CT funding for Q3!#2021-09-0215:18Karol WójcikWell deserved!#2021-09-0215:30thhellerthx#2021-09-0216:13martinklepsch
clojure -A:build:test -M -m shadow.cljs.devtools.cli watch app
@thheller this call seems to work but the issue also seems like potentially a different version issue in the CI env where it’s failing
#2021-09-0216:15thhellerthe -M might be a problem if your CI has an older tools.deps install?#2021-09-0216:16martinklepschYeah, I’ll check on that!#2021-09-0216:16martinklepschCan someone remind me how I can wipe state of the node-repl without restarting everything? There’s a way to restart the worker process for that but I can’t remember 😅#2021-09-0216:16thhellerthere is an open issue about netlify still using an old version#2021-09-0216:16thheller(shadow.cljs.devtools.api/stop-worker :node-repl) from the CLJ repl#2021-09-0217:09David PhamI had an issue today which was really odd: I was using this library for two components: https://github.com/khmelevskii/emotion-cljs . I was compiling with shadow-cljs in advacned mode several time a day without an issue, and then suddenly without changing the old code, the components started to crash. I know the problem is with emotion styled componenet as I debugged with the --debug flag.#2021-09-0217:10David PhamI tried to write externs, but my skillset is probably quite limited.#2021-09-0217:10David PhamDoes anyone know what could be the issue?#2021-09-0217:10David PhamI will try to set up a minimal example tomorrow if no one has an idea.#2021-09-0217:16thheller> the components started to crash#2021-09-0217:16thhellerwhat does that mean? what is the actual error?#2021-09-0217:34David PhamI believe "@emotion/styled" is undefined#2021-09-0217:34David Phamin advacned mode#2021-09-0217:35David PhamThe error says "call" from t.call is undefined#2021-09-0217:35David Phamwhere t is emotion/styled.#2021-09-0217:40thhellercan't say without seeing code. there is no difference in how JS code is provided in :advanced since those parts only ever use :simple#2021-09-0217:41David Phamt.call is not a function sorry#2021-09-0217:47David Pham
$emotion$core$create_styled$$ = function($display_name$jscomp$2_result$jscomp$144$$, $component$jscomp$30$$, $options$jscomp$119$$, $styles$$) {
        var $wrap$jscomp$2$$ = $APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$2$($options$jscomp$119$$, "wrap")
          , $camel_casing_props_QMARK_$$ = $APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($options$jscomp$119$$, "camelCasingProps?", !0)
          , $class_name_prop$jscomp$1$$ = $APP.$cljs$core$name$$($APP.$cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($options$jscomp$119$$, "classNameProp", "class-name"))
          , $wrapper_component$$ = $APP.$cljs$core$not$$($camel_casing_props_QMARK_$$) ? $component$jscomp$30$$ : null != $component$jscomp$30$$.__emotion_base ? $component$jscomp$30$$ : $APP.$cljs$core$_EQ_$$.$cljs$core$IFn$_invoke$arity$2$($APP.$cljs$core$type$$($component$jscomp$30$$), String) ? $emotion$core$create_forwarded_element$cljs$0core$0IFn$0_invoke$0arity$02$$($component$jscomp$30$$, $emotion$core$object__GT_camel_props$$) : $APP.$cljs$core$_EQ_$$.$cljs$core$IFn$_invoke$arity$2$($class_name_prop$jscomp$1$$, "className") ? $component$jscomp$30$$ : $emotion$core$create_forwarded_element$cljs$0core$0IFn$0_invoke$0arity$02$$($component$jscomp$30$$, function($p1__141952_SHARP_$$) {
            return $emotion$core$convert_class_name$$.$cljs$core$IFn$_invoke$arity$2$($p1__141952_SHARP_$$, $class_name_prop$jscomp$1$$);
        });
        $wrapper_component$$.displayName = $display_name$jscomp$2_result$jscomp$144$$;
        $display_name$jscomp$2_result$jscomp$144$$ = function() {
            function $G__141956$$($props$jscomp$26$$) {
                return $APP.$cljs_bean$core$__GT_js$$($styles$$).concat($props$jscomp$26$$.css);
            }
            var $fexpr__141955$$ = function() {
                var $G__141958$$ = $APP.$cljs_bean$core$__GT_js$$($options$jscomp$119$$);
                return $emotion$core$styled_component$$.$cljs$core$IFn$_invoke$arity$2$ ? $emotion$core$styled_component$$.$cljs$core$IFn$_invoke$arity$2$($wrapper_component$$, $G__141958$$) : $emotion$core$styled_component$$.call(null, $wrapper_component$$, $G__141958$$);
            }();
            return $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$ ? $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$($G__141956$$) : $fexpr__141955$$.call(null, $G__141956$$);
        }();
        return $APP.$cljs$core$truth_$$($wrap$jscomp$2$$) ? $wrap$jscomp$2$$.$cljs$core$IFn$_invoke$arity$1$ ? $wrap$jscomp$2$$.$cljs$core$IFn$_invoke$arity$1$($display_name$jscomp$2_result$jscomp$144$$) : $wrap$jscomp$2$$.call(null, $display_name$jscomp$2_result$jscomp$144$$) : $display_name$jscomp$2_result$jscomp$144$$;
    }
#2021-09-0217:47David PhamThat would be the function that breaks doown on advanced compliation#2021-09-0217:47David Phamin particular the expression#2021-09-0217:48David Pham
return $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$ ? $fexpr__141955$$.$cljs$core$IFn$_invoke$arity$1$($G__141956$$) : $fexpr__141955$$.call(null, $G__141956$$);
#2021-09-0217:48David Pham
$fexpr__141955$$.call
Is undefined
#2021-09-0217:49David PhamWhat I find odd is the component runs fine on debug mode, but not on advanced, and I don't know how I could solve this.#2021-09-0217:49David PhamThis would be clojurescript function https://github.com/khmelevskii/emotion-cljs/blob/master/src/emotion/core.cljs#L84#2021-09-0217:54thhelleronly guess is this https://github.com/khmelevskii/emotion-cljs/blob/master/src/emotion/core.cljs#L14#2021-09-0217:54thhellercan you show that in the --debug output? should be the assignment of $emotion$core$styled_component$$#2021-09-0218:06David Pham
$emotion$core$styled_component$$ = $module$node_modules$$emotion$styled$dist$emotion_styled_browser_cjs$$.default
#2021-09-0218:13thhellerdo you have all the correct npm package versions?#2021-09-0218:13thhellermaybe you have a newer/older one that doesn't have a default export?#2021-09-0218:17David PhamI took the latest version of both#2021-09-0218:17David Pham11.3.0#2021-09-0218:18David PhamIt is is really odd, because It was working this morning, I did not change anything, and then suddenly it stopped working.#2021-09-0218:18David PhamBut I will try to make a minimal example tomorrow.#2021-09-0218:18thhellerhad to change something. doesn't mysteriously change itself.#2021-09-0218:18David PhamI compile two versions#2021-09-0218:19thhellercan be a simple thing as running npm install and creating a dependency conflict that wasn't there before#2021-09-0218:19David Phamseparated by a few seconds#2021-09-0218:19David Phamand one of the output works and not the other xD#2021-09-0218:19David Phamoh well. Let's see.#2021-09-0218:26currentoorI’ve got a namespace that defines transit types for some defrecords and I need these types to be redefined on code reload. So I added the marker to always reload this NS
(ns ^:dev/always mutesync.background.transit-types
  (:require ...))
But this namespace is still not be reloaded when I update one of it’s children. Does :dev/always mean always reload this NS or something else?
#2021-09-0218:27thhellerIt does mean always reload or even recompile. meaning every recompile cycle will recompile and then reload it. you should see it in the browser console#2021-09-0218:29thhellernote that reloading defrecords will invalidate all active instances so that might present a problem?#2021-09-0218:29thhelleror not invalidate, just new types so not compatible with the previous ones if you ever to (instance? TheRecord ...)#2021-09-0218:30currentoorah you’re right it does, but my code is throwing an exception before reloading this namespace is possible, because defrecords are incompatible#2021-09-0218:31currentoorI’m wondering if I should just move away from defrecords for this reason#2021-09-0218:32currentoorprotocols are nice, but i’d rather have dev code reload be reliable#2021-09-0218:32thhellerI typically move the protocols to a namespace that is pretty much never reloaded#2021-09-0218:33thhellerlike a dedicated .protocols ns or so#2021-09-0218:33thhellerof course that only solves part of the problem. custom types aren't really hot-reload/REPL friendly too much#2021-09-0218:34currentoorso you define and implement your protocols in a separate namespace?#2021-09-0218:35currentoorthis is one of the reasons my friend @wilkerlucio says we should use maps with lambdas rather than defrecords#2021-09-0218:35thhellerhttps://github.com/thheller/shadow-experiments/blob/master/src/main/shadow/experiments/arborist/protocols.cljs#2021-09-0218:35currentoorwhat other issues are you aware of with custom types and hot-reload?#2021-09-0218:35thhelleryeah, ns just for protocols. no implementations#2021-09-0218:36currentooroh i see, it’s the protocol eval causing issues that you’re talking about#2021-09-0218:37thhellerdon't know what error you actually get but it does solve some issues yes#2021-09-0218:37currentoormy issues is i end up re-defining the defrecord and then i can no longer serialize it as transit without re-defining the transit writer#2021-09-0218:38currentoorthank you for the help#2021-09-0218:39thhelleryeah anything thats type based is an issue#2021-09-0218:47zhuxun2Does shadow-cljs respect :refer-clojure :exclude?
(ns user
  (:refer-clojure :exclude [compile])
  )

(defn compile [] 42)
$ npx shadow-cljs watch :main
shadow-cljs - config: .../shadow-cljs.edn
shadow-cljs - starting via "clojure"
WARNING: compile already refers to: #'clojure.core/compile in namespace: user, being replaced by: #'user/compile
#2021-09-0218:49zhuxun2
=== Version
jar:            2.15.5
cli:            2.15.5
deps:           1.3.2
config-version: 2.15.5
#2021-09-0219:10borkdude@zhuxun2 have you tested this without shadow?#2021-09-0219:19zhuxun2@borkdude Hmmm, clj -M --main cljs.main --compile user gives the same error, so it's not shadow-cljs#2021-09-0219:20borkdudeexactly#2021-09-0219:20borkdudeit seems to be clojure behavior#2021-09-0219:20borkdudenot sure why, but perhaps bring it up in #clojure#2021-09-0220:34Fredrik Anderssonhttps://clojureverse.org/t/how-are-you-styling-your-clojurescript-apps/7946/7 I'm trying to use this to compile my tailwindcss. However the hooks cannot find the babashka class path. I'm not entirely sure how to add dependencies to be used by clj hooks. I did try to find it in the documentation without success.#2021-09-0220:39borkdude@fredrik245 babashka.process is a library which you can probably add to deps.edn?#2021-09-0220:39borkdudehttps://github.com/babashka/process#2021-09-0220:41Fredrik Anderssonok, im using shadow-cljs#2021-09-0220:41Fredrik Anderssonshould I add a deps-file too?#2021-09-0220:41Fredrik Anderssonsorry I'm quite new to clojure and clojurescript#2021-09-0220:43borkdudeThat link writes about postcss.clj which is a Clojure (JVM) file#2021-09-0220:47borkdudeYou could add a deps.edn like this:
{:deps {babashka/process {:mvn/version "0.0.2"}}}
and in your shadow-cljs.edn write :deps true so it picks up on the deps.edn
#2021-09-0220:48borkdudeYou will also need the clojure CLI installed, see https://clojure.org/guides/getting_started#2021-09-0220:49borkdudeif you are using project.clj then just add the dep there#2021-09-0220:49borkdudeI think shadow also allows you to declare the deps inside its configuration#2021-09-0220:49borkdudeso any of those three options should work and align with what you are already doing#2021-09-0220:49Fredrik Anderssoni thought that i linked to a particular reply in the link. I successfully added the dependency in shadow-cljs.edn#2021-09-0220:50Fredrik Anderssonso it works now#2021-09-0220:50Fredrik Anderssonhowever it doesn't seem to write any output files. so i'm going to look closer at that#2021-09-0220:50Fredrik Anderssonbut thanks#2021-09-0220:51borkdudeI recommend using the :inherit true option in process#2021-09-0220:51borkdudethen you will see the output from those commands while they are running#2021-09-0220:52borkdudeand that may give some hints as to what's going wrong#2021-09-0220:54Fredrik Anderssonah, great#2021-09-0220:54Fredrik Anderssonthanks!#2021-09-0220:58Fredrik Anderssonhm, still nothing 😞#2021-09-0221:14borkdude@fredrik245 Could you post your code to a gist or some public repo?#2021-09-0221:17Fredrik Andersson@borkdude I'm going to bed now. I'll do it tomorrow if I can't find a solution in the morning.#2021-09-0221:17borkdudeyou can at least insert some printlns for debugging if those build functions are executed at all. ok goodnight!#2021-09-0221:18Fredrik Anderssonyes I did try that but they didn't execute#2021-09-0221:18borkdudeah ok, then perhaps the shadow config isn't properly set up or so#2021-09-0221:18Fredrik Anderssonyes probably, ill look into it tomorrow with a fresh head 😄#2021-09-0221:18Fredrik Anderssonthanks for the help#2021-09-0305:56thhellerFWIW I strongly recommend NOT running secondary tools in hooks. especially not something that starts processes that keep running#2021-09-0305:57thhellerprefer setups like this one https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/package.json#L8 using npm-run-all to run multiple things but in separate processes#2021-09-0305:58thhellerrunning separate processes is not what build-hooks are made for and should be avoided#2021-09-0307:32borkdudehmm, I see. this is actually what bb tasks is made for as well. (https://book.babashka.org/#tasks), similar to Make, Just, etc.#2021-09-0307:36borkdudeI'll leave your feedback on the ClojureVerse post as well.#2021-09-0307:42ingesolI’m seeing [BABEL] Note: The code generator has deoptimised the styling of mydev/node_modules/somelib.js as it exceeds the max of 500KB. in my builds recently. It is not always printed, but sometimes. Does not seem to affect my build times. Normally appears along with Browserslist: caniuse-lite is outdated. Please run next command npm update . Switching between shadow 2.12.x and 2.15.x seems to not make a difference. Is this something that needs configuration, or is it not a problem?#2021-09-0308:00kirill.salykinHi, morning is there a way to speed up compilation on ci by maybe reusing some caches from prev builds?#2021-09-0309:04Pepijn de VosHow do I install a local dependency?#2021-09-0309:07kirill.salykinis it clj dependency?#2021-09-0309:08Pepijn de Vosyea#2021-09-0309:08kirill.salykinprobably you need to use tools.deps machinery for this#2021-09-0309:09kirill.salykinhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-ednhttps://clojure.org/guides/deps_and_cli#_using_local_libraries#2021-09-0309:09kirill.salykindunno if there is shadow.edn support for this#2021-09-0309:36borkdude@pepijndevos with deps.edn you can just use :local/root#2021-09-0310:31Karol WójcikI'm trying to configure i18n with shadow-cljs. As a glue code I'm using the following js code:
import React from "react";
import ReactDOM from "react-dom";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { resources } from "./translations";

export function init({onMissingKey}) {
  i18n
  // passes i18n down to react-i18next
    .use(LanguageDetector)
    .use(initReactI18next)
    .on('missingKey', onMissingKey)
    .init({
      // order and from where user language should be detected
      order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'path', 'subdomain'],
      defaultNS: ['General'],
      // keys or params to lookup language from
      lookupQuerystring: 'lng',
      lookupCookie: 'i18next',
      lookupLocalStorage: 'i18nextLng',
      lookupSessionStorage: 'i18nextLng',
      lookupFromPathIndex: 0,
      lookupFromSubdomainIndex: 0,

      // cache user language on
      caches: ['localStorage', 'cookie'],
      excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)

      // optional expire and domain for set cookie
      cookieMinutes: 10,

      // optional htmlTag with lang attribute, the default is:
      htmlTag: document.documentElement,

      // optional set cookie options, reference:[MDN Set-Cookie docs]()
      cookieOptions: { path: '/', sameSite: 'strict' },
      // the translations
      // (tip move them in a JSON file and import them,
      // or even better, manage them via a UI: )
      saveMissing: true,
      resources,
      fallbackLng: "pl",
      interpolation: {
        // react already safes from xss => 
        escapeValue: false
      }
    });
}

export function refresh({ onSuccess, onFailure }) {
  return i18n.reloadResources().then(onSuccess).catch(onFailure);
}

export function language() {
  return i18n.language;
}

export function changeLanguage(lang, {onSuccess, onFailure} ) {
  return i18n.changeLanguage(lang).then(onSuccess).catch(onFailure);
}

export function t(key, opts) {
  return i18n.t(key, opts);
}
This works perfectly for optimizations: none. However with shadow-cljs release changeLanguage and reloadResources are removed from the prototype 😮 Any hints what potentially I'm doing wrong?
#2021-09-0310:43Karol WójcikThe first thing that comes to my mind is: externs?!#2021-09-0311:02Karol WójcikSuprisingly shadow renames the resources as well. 😮
const pl = {

};

const en = {

};

export const resources = {pl, en};
After advanced en becomes M1
#2021-09-0311:31Karol WójcikYep it's about externs. Thank you @U05224H0W for making shadow-cljs predictable! In other tools I would: 1. Don't know what is happening 2. Have trouble with creating the externs. Externs simple rocks#2021-09-0311:50Karol WójcikThis fixed the issue:
# -----------------------------------------------
# [start] i18n externs [start]
i18n.resources.en
i18n.resources.pl
i18n.changeLanguage
i18n.reloadResources
i18n.appendNamespaceToCIMode
i18n.appendNamespaceToMissingKey
i18n.htmlTag
i18n.excludeCacheFor
i18n.cookieOptions
i18n.cookieMinutes
i18n.lookupFromPathIndex
i18n.lookupFromSubdomainIndex
i18n.t
# [end] i18n externs [end]
# -----------------------------------------------
#2021-09-0314:53thhelleryeah there is no externs inference when using JS code (since the cljs compiler does that)#2021-09-0314:53thhellerso externs are required if you don't want things to be renamed#2021-09-0313:22huygnhi, how can I define a global js/ReactDOMServer variable? I'm trying to do
(:require ["react-dom/server" :as ReactDOMServer])

(set! js/ReactDOMServer ReactDOMServer)
I'm using esm target with Deno and above code throw this error:
error: Uncaught (in promise) ReferenceError: ReactDOMServer is not defined
(ReactDOMServer = module$node_modules$react_dom$server_browser);
the reason why I had to do this is because uix tries to use js/ReactDOMServer here: https://github.com/roman01la/uix/blob/0da33eef38a7122be226b9b9a8ae0b5431b6b5d3/dom/src/uix/dom/alpha.cljc#L69
#2021-09-0314:34Karol WójcikProbably better to path the library#2021-09-0314:34Karol WójcikBtw what is the output of (println ReactDOMServer)#2021-09-0314:55thheller(set! js/goog.global.ReactDOMServer ReactDOMServer) will make it global#2021-09-0315:05thheller(js/goog.exportSymbol "ReactDOMServer" ReactDOMServer) also works. might be safer if you are going for :advanced#2021-09-0316:04huygnworked, thanks!#2021-09-0400:19ChaseSo I compiled a release build using shadow-cljs release app and it builds fine but how do I actually run the release build? Everything I am trying is failing. shadow-cljs watch app still works for the dev build. But anything like shadow-cljs run app or shadow-cljs run core give me classpath errors#2021-09-0402:03javijust start a server in the public folder. the release files are just javascript. python -m http.server 8000 for example. Then point the browser to localhost:8000 and your app will load.#2021-09-0402:18Chaseyeah I tried that and it's trying to reconnect to shadow-cljs so I think that is still running the dev setup?#2021-09-0402:18ChaseA lot of console errors too#2021-09-0402:39javiyeah, it sounds like that could be the issue. try deleting your ‘js’ folder inside ‘public’ before running ‘release’. #2021-09-0403:01Chasethat seems to have been it. thanks!#2021-09-0405:07javi👍 #2021-09-0406:43thhellerrelease should override all the relevant files unless you have configured it not to#2021-09-0406:43thhellerdon't know your config#2021-09-0407:09thhellerah, if you just want the http server back you can run shadow-cljs server. as a bonus while that is running shadow-cljs release app is also much faster#2021-09-0412:21ChaseOk cool, I will switch to that workflow. Thanks!#2021-09-0412:28ChaseAs a side note, on a small Hello World Reagent app, running the release build with optimizations set to :advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?#2021-09-0418:13thhelleryou can create a build report to figure out what exactly is in your build and how large https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2021-09-0422:22ChaseAhh, cool! Yeah its 60% cljs/core.cljs which I guess is to be expected. I assume as I continue building out the app, the size will grow at a slower rate (if that makes any sense)#2021-09-0507:16thhelleryeah cljs.core is typically the largest one. some other exceptions but they are usually easily avoided (eg. cljs.pprint)#2021-09-0400:19ChaseI'm using the minimal reagent front end template if that matters#2021-09-0409:43zendevil.ethI installed the js sdk for browser client using npm i --save moralis, but I’m getting the following error:
The required JS dependency "json-rpc-engine/src/createAsyncMiddleware" is not available, it was required by "node_modules/eth-json-rpc-middleware/block-cache.js".


	node_modules/moralis/index.js
	node_modules/moralis/lib/browser/Parse.js
	node_modules/moralis/lib/browser/decode.js
	node_modules/moralis/lib/browser/ParseACL.js
	node_modules/moralis/lib/browser/ParseUser.js
	node_modules/moralis/lib/browser/MoralisWeb3.js
	node_modules/moralis/lib/browser/MoralisWalletConnectProvider.js
	node_modules/@walletconnect/web3-provider/dist/esm/index.js
	node_modules/web3-provider-engine/subproviders/cache.js
	node_modules/eth-json-rpc-middleware/block-cache.js
I tried removing node_modules and reinstalling using npm i. I also tried npm i --save json-rpc-engine but that still gives the error. I tried npm i --save json-rpc-engine/src/createAsyncMiddleware, but that npm package doesn’t exist. How to fix this?
#2021-09-0418:14thhellerlooks like the eth-json-rpc-middleware package maybe expects a different version of json-rpc-engine than you have installed#2021-09-0418:15thhellertypical dependency version conflict error#2021-09-0418:15thhellerusing a file that is only in a given version of the package#2021-09-0409:53huygnSo I just had a (naive) working template to run/deploy with Deno & shadow-cljs, used uix for render/hydrate a simple React app. Thanks @thheller for adding esm support! now I just wished watch mode would work for esm target too. deploy url: https://deno-cljs.deno.dev https://github.com/huygn/deno-cljs-template#2021-09-0410:02borkdude@gnhuy91 I am using watch for nbb which is esm as well#2021-09-0410:04huygnhmm my error being document was referenced in :server build, but compile/release mode works fine :thinking_face:
> deno run -A --unstable --watch src/index.ts

Check file:///Users/macair/src/github.com/huygn/my-project/src/index.ts
error: Uncaught ReferenceError: document is not defined
  return goog.dom.createElement_(document, name);
                                 ^
    at Object.goog.dom.createElement (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.dom.dom.js:288:34)
    at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.style.transition.js:39:21
    at Object.isSupported (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.functions.functions.js:142:15)
    at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/shadow.dom.js:3:99
#2021-09-0410:07huygnnot like it doesn't work (should have correct that), but in my case I have no clue what caused this#2021-09-0410:09borkdudeoh I am using shadow watch#2021-09-0410:09borkdudenot deno#2021-09-0410:09borkdudeto re-compile files using shadow#2021-09-0410:23huygnwhat I did was running shadow watch and then start deno#2021-09-0410:23borkdudeyes#2021-09-0410:23huygnso that error throw from deno yea#2021-09-0410:23huygnbut shadow compile doesnt have such error#2021-09-0411:53zendevil.ethNow I’m getting this error on auto-reload:
no source by provide: module
{:provide module}
ExceptionInfo: no source by provide: module
	shadow.build.data/get-source-id-by-provide (data.clj:186)
	shadow.build.data/get-source-id-by-provide (data.clj:183)
	shadow.build.data/get-source-by-provide (data.clj:189)
	shadow.build.data/get-source-by-provide (data.clj:188)
	shadow.build.js-support/shim-require-sugar-resource/fn--34338 (js_support.clj:107)
	shadow.build.data/get-source-code (data.clj:319)
	shadow.build.data/get-source-code (data.clj:306)
	shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189/fn--34190 (closure.clj:2187)
	shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189 (closure.clj:2186)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
	clojure.core/chunk-next (core.clj:710)
	clojure.core.protocols/fn--8176 (protocols.clj:137)
	clojure.core.protocols/fn--8176 (protocols.clj:124)
	clojure.core.protocols/fn--8136/G--8131--8145 (protocols.clj:19)
	clojure.core.protocols/seq-reduce (protocols.clj:31)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
	clojure.core/reduce (core.clj:6830)
	clojure.core/into (core.clj:6897)
	clojure.core/into (core.clj:6889)
	shadow.build.closure/convert-goog* (closure.clj:2190)
	shadow.build.closure/convert-goog* (closure.clj:2182)
	shadow.build.closure/convert-goog (closure.clj:2361)
	shadow.build.closure/convert-goog (closure.clj:2311)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
	shadow.build.compiler/compile-all (compiler.clj:1426)
	shadow.build.compiler/compile-all (compiler.clj:1307)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:442)
	shadow.build/compile (build.clj:432)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:531)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:486)
	shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230/fn--37238 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--37229 (util.clj:256)
	java.lang.Thread.run (Thread.java:748)
#2021-09-0412:03zendevil.ethI restarted shadow watch and it started working#2021-09-0412:28ChaseAs a side note, on a small Hello World Reagent app, running the release build with optimizations set to :advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?#2021-09-0510:21huygn
error: Uncaught ReferenceError: document is not defined
  return goog.dom.createElement_(document, name);
                                 ^
    at Object.goog.dom.createElement 
is there any ways to prevent this error during development with :esm target? I'm consuming the output in Deno.serveHttp so document isn't a thing there. compile/release works fine, I guess it's due to dev mode always has :none optimization hence dom methods still there
#2021-09-0510:22thheller@gnhuy91 you need to set :runtime :custom in your build config. otherwise defaults to :browser which will attempt to use the dom. not related to :none in any way#2021-09-0510:24huygnworks, thanks!#2021-09-0510:24ribelo@gnhuy91, why are you investing so much energy in a deno which doesn't work with cljs very well?#2021-09-0510:25huygnit's been working really well for me actually :thinking_face:#2021-09-0510:25ribeloor otherwise, what can deno give us that node doesn't? from a cljs perspective#2021-09-0510:25ribelodoes hot reload work? last time I tried it, I couldn't get it to work properly#2021-09-0510:26huygndeno only runs esm, and shadow can output esm which is the best match imo#2021-09-0510:30ribeloI'm generally rooting for deno, but rather because I like it conceptually, however, I currently can't find a reason to want to use it.#2021-09-0510:31huygnfor hot reload I don't use client-side build so I don't know, but deno does reload on file changes#2021-09-0510:31ribelorepl works normally?#2021-09-0510:31huygnyea correct, conceptually esm & deno will led the js platform toward a more stable future#2021-09-0510:32huygnI don't think so, repl doesn't trigger a file change, so deno won't reload#2021-09-0510:33ribelothe only language that has a certain future is JS 🙃#2021-09-0510:33huygnbut then you could write a small shim (maybe using :init-fn) to run stand-alone with shadow-cljs, then consume the exports in deno#2021-09-0510:33huygnwhat I've been doing is trying to use deno & deno deploy#2021-09-0510:35huygnjs ecosystem is slowly moving to esm format, which currently break a bunch of lib users, thus esm version is a major release for most#2021-09-0510:36ribeloThomas will probably create a solution in one weekend as soon as it is needed#2021-09-0510:36ribeloso far deno has no audience in our community#2021-09-0510:37borkdudeThe :esm target works for deno, this is why thheller specifically created it, but I'm also using it for #nbb (scripting on Node using SCI) to be able to import ES modules and this target also supports code splitting which allows nbb to lazily load code for better startup#2021-09-0510:37huygnnode can already consume esm imo, it's just I wanted to try deno deploy haha#2021-09-0510:38huygnand yea it's not really about deno, it's esm#2021-09-0510:39borkdudeI tried using nbb as a library from electron, I couldn't get this working, since electron is still all about commonJS and importing ES modules from commonJS isn't possible#2021-09-0510:39ribelodeno solves a lot of other problems that node has and esm isn't really one of them#2021-09-0510:59huygnyea the cjs & esm compat story is a joke imo#2021-09-0515:20thhellerwell its always difficult to move from a non-standard method to a standard one#2021-09-0515:22thhellerthey shouldn't have delayed this for so long in the way babel/webpack did. thats the real issue, we could have been done with this for years now 😛#2021-09-0515:44Vlad KryvokonievHi, I have problem adjusted to shadow-cljs env variables As the https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env "not clearly" says I can read a variable via `#shadow/env "TWITCH_AUTHORIZATION_TOKEN"` but instead i get an error `No reader function for tag shadow/env.` my version of shadow-cljs is "2.15.2" here is my shadow-cljs.edn:
{:source-paths
 ["src/main"]


 :dependencies
 [[reagent "1.1.0"]
  [cljs-ajax "0.8.4"]]

 :dev-http {8080 "public"}
 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn app/start}}
   :closure-defines {events.async/TWITCH_AUTHORIZATION_TOKEN #shadow/env "TWITCH_AUTHORIZATION_TOKEN"}}}} 
also my .env:
TWITCH_AUTHORIZATION_TOKEN="blalbbllba"
so my question is how to read a env variable then?
#2021-09-0611:29kirill.salykinhi is there a way to get output name with hash in the build hook (`on-flush` stage)?
(get-in build-state [:shadow.build.modules/modules module-id :output-name])
returns name w/o hash
#2021-09-0611:39thheller@kirill.salykin :shadow.build.closure/modules should have the hashes in :output-name#2021-09-0611:40kirill.salykinsuper! thanks you#2021-09-0611:40thhellerthere is a bit of duplication. shadow.build.modules is before optimizations and shadow.build.closure is after#2021-09-0611:40kirill.salykinroger#2021-09-0614:07Ryan JerueDoes something like https://www.npmjs.com/package/webpack-bundle-analyzer exist for things built on shadow using :target :node-library ?#2021-09-0614:18Ryan JerueFound! https://github.com/thheller/shadow-cljs/issues/881#2021-09-0614:38mkvlrdoes shadow also support pure js “modules”. Or would setting :prepend-js with a an empty module ns have the same effect?#2021-09-0614:41borkdudewhat is a pure js module? (just being curious, instead of helpful)#2021-09-0614:47thhelleryeah whats a pure js module? you mean only js sources? you can define :modules {:js-only {:entries ["/that/file.js"]}}#2021-09-0614:47mkvlryes, @U05224H0W that’s that I meant, thanks!#2021-09-0614:48thhellerI doubt anyone has ever done this though. not actually sure it works. should in theory though#2021-09-0614:48mkvlrok, will try & report back 😼#2021-09-0614:55mkvlrok, so works somewhat, ie it produces a file I can load, the downside is that it still bundles the whole cljs runtime so still produces a ~5mb js in dev even though I’m just loading a smallish npm lib#2021-09-0614:58thhellerif you set :devtools {:enabled false} that shouldn't happen#2021-09-0614:59thhellermaybe :console-support false also (also in :devtools)#2021-09-0615:00thhellerI specifically set it up to not include cljs.core if there are no sources requiring it. for watch the injected REPL/hot-reload code will however bring it in unless disabled#2021-09-0615:11mkvlrcool, that works, thanks!#2021-09-0709:02biscuitpantsis it safe to retain the .shadow-cljs directory between release builds of clojurescript? we previously have been deleting that folder before we run a release build, in fear of stale cache or dependencies. retaining it makes our build at least 1 minute faster, so we want to see if its safe to no longer delete it between release builds#2021-09-0716:04thhelleryes, safe. I never delete mine. no cache issues for a couple years now#2021-09-0808:23biscuitpantscool, thank you!#2021-09-0709:18huygnhi I'm using below build config and :module-hash-names doens't work, the output is still client.js file without any hash :thinking_face:
:client {:target :esm
           :runtime :browser
           :output-dir "dist/client"
           :modules {:client {:entries [app.client]
                              :exports {hydrate app.client/hydrate-app}}}
           :devtools {:before-load app.client/stop
                      :after-load app.client/start}
           :module-hash-names 8
           :build-options {:manifest-name "manifest.json"}}
#2021-09-0716:03thheller:module-hash-names currently is only supported for :browser builds#2021-09-0714:05jjttjjI've read https://widdindustries.com/cljs-npm-libraries/ but I'm still a bit confused on the best practice for packaging a cljs library that depends on a [single] js library. Currently the js and externs are included in the project. Should I just the stub namespace with js/goog.exportSymbol described in the shadow docs and add that stub to the library source code and call it a day? Specifically, I'm trying to address this issue in this project: https://github.com/funcool/decimal/issues/7#2021-09-0716:36thhelleryou can change this file#2021-09-0716:36thhellerhttps://github.com/funcool/decimal/blob/master/assets/deps.cljs#2021-09-0716:36thhellerto provide decimal.js instead of decimal.extern.decimaljs#2021-09-0716:37thhellerthen in the code actually (:require ["decimal.js" :as dec]) or so#2021-09-0716:37thhellerand then also add :npm-deps {"decimal.js" "version"} to the deps.cljs file#2021-09-0716:37thhellershadow-cljs will be happy with that#2021-09-0716:37thhellerand the others will just use the bundled foreign lib as before#2021-09-0716:39thhelleror need to hange the js/Decimal uses as well to use the alias. I'm not entirely sure what you need to add to deps.cljs for that to work though#2021-09-0716:39thhellersuggest looking at cljsjs/react or so, they do that#2021-09-0720:11jjttjjAwesome, thanks!#2021-09-0714:52kennytiltonUgh, back to EISDIR! All my RN experiments seem to end here. 😭 Any thoughts on how this suddenly arises? Thx! 🙏
Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (node:fs:626:3)
    at tryReadSync (node:fs:391:20)
    at Object.readFileSync (node:fs:428:19)
    at UnableToResolveError.buildCodeFrameMessage (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:304:17)
    at new UnableToResolveError (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:290:35)
    at ModuleResolver.resolveDependency (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:168:15)
    at DependencyGraph.resolveDependency (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/node-haste/DependencyGraph.js:353:43)
    at /Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/lib/transformHelpers.js:271:42
    at Server.<anonymous> (/Users/kennethtilton/dev/matrix/cljs/shadow/matrixrn/node_modules/metro/src/Server.js:842:41)
    at Generator.next (<anonymous>)
....etc etc
#2021-09-0715:28kennytiltonn.m. Looks like quite a mess overall.#2021-09-0716:03thhellerhmm odd. maybe there is a directory with the same name of a file or so?#2021-09-0816:53kennytiltonOMG. Happens only if (a) I have the dev console open (b) in the Expo debugger_ui, @U05224H0W. Then:
DevTools failed to load source map: Could not load content for : Fetch through target failed: Target not supported; Fallback: HTTP error: status code 500, net::ERR_HTTP_RESPONSE_CODE_FAILURE
sigh
#2021-09-0816:58thhellerdon't know what that means sorry. not a shadow-cljs error, proably RN#2021-09-0817:05kennytiltonOh, sorry, @U05224H0W. It means I can just ignore those. 🙂 Part of getting up to speed on a new stack and is figuring out which garbage coming out of our tools can be ignored. I prolly gave up on three efforts because sth was going wrong and then I noticed the EISDIRs and gave them the credit. It's a good thing I like this game! 🙂#2021-09-0817:06kennytiltonYes, Expo is blaming RN. https://github.com/facebook/react-native/issues/28844 I am always happy to see FB engineers dragged thru the mud. 🙂#2021-09-0718:45azHi all, I’m trying to use the https://ant.design/docs/react/use-with-create-react-app lib in a helix project and I’m struggling to get the css importing. I can load from CDN, but the css is larger and they recommend not to do this, but instead allow for webpack to tree shake the css. How would I convert an import statement like @import "antd/dist/antd.css"; listed in their docs which pulls from node_modules/antd to work with a shadow project?#2021-09-0719:14Ryan JerueI just have this stuck in the head of my index.html
<link rel="stylesheet" href="" integrity="sha512-Gfp2ZD1ULgfgThJArElWdfu/bPK67HVrx+rKfLfclPyRUlf68R7uHIy5zaPnZpv6ZuIX/ykmJCv3Q1bnfZngEg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
#2021-09-0719:16Ryan JerueMore versions and whatnot here https://cdnjs.com/libraries/antd#2021-09-0719:16azAny thoughts on size though? @U01GNU0Q0MB - I see they mention they strongly recommend not importing from Cdn#2021-09-0719:17azWhat do you think?#2021-09-0719:17azI guess it’s pretty well cached at this point #2021-09-0719:18Ryan JerueAs for size, this is just the CSS being loaded. If you were to do it using an import, it would import the same thing. Size argument comes into play with the actual js components#2021-09-0719:18Ryan JerueI’m not sure what optimizations shadow will do (if any) for tree shaking. Webpack will do a ton which is why they don’t suggest the cdn#2021-09-0719:18azI see ok great#2021-09-0719:19azGot it makes sense. #2021-09-0718:49azby the way I’m using postcss and tailwind jit and that is working well. Wondering if I should be plugging in antd css into that build pipeline somehow?#2021-09-0721:03Fredrik AnderssonI'm trying to use Firebase 9.0.1 web-api. Googles documentation names the version "Firebase Modular Web SDK v. 9.0" which I suppose means that it utilize es6 modules? I'm not well versed in es6 so I don't understand this very well. I just wan't to know how I would use them in clojurescript with shadow-cljs#2021-09-0801:26thheller@fredrik245 the same as any other npm package. npm install it and then require it properly. https://shadow-cljs.github.io/docs/UsersGuide.html#npm reference the translation table to translate JS examples to CLJS#2021-09-0807:05FranklinI'm having some trouble using clojure.spec on the repl
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[clojure.spec.gen.alpha :as gen])
nil
cljs.user=> (gen/generate (s/gen int?))

Execution error (Error) at (<cljs repl>:1).
Var clojure.test.check.generators/simple-type-printable does not exist, clojure.test.check.generators never required
:repl/exception!
#2021-09-0807:06FranklinI have added [org.clojure/test.check "1.1.0"] to the :dependencies vector. is there anything I'm missing?#2021-09-0807:06borkdudeDo what the error message tells you: require the namespace first #2021-09-0807:07Franklinthanks @borkdude 🙂#2021-09-0908:09FranklinI'm trying to run tests for a speced cljs function using karma... it seems trickier than I expected I'm getting an error that looks like this
--------------------------------------------------------------------------------
  23 | 
  24 | (defn ^:export run
  25 |   [karma]
  26 |   (-> (stest/enumerate-namespace 'quagga.utils.components.share-modal.events) stest/check)
---------^----------------------------------------------------------------------
Encountered error when macroexpanding cljs.spec.test.alpha/check.
Error in phase :compile-syntax-check
RuntimeException: No such namespace: stest
Here's how I'm running the test; not sure if its' the correct way to do it
(defn ^:export run
  [karma]
  (-> (stest/enumerate-namespace 'quagga.utils.components.share-modal.events) stest/check)
  (karma/run-tests karma
                   'quagga.utils.components.account-select.events-test
                   'quagga.components.dataview.table.events-test
                   'quagga.utils.components.share-modal.events-test))
#2021-09-0910:46FranklinI've also imported/required stest
[clojure.spec.test.alpha :as stest]
#2021-09-0920:21thhellershould be fine assuming thats actually in the ns :require of that file#2021-09-1008:03Franklinstill having trouble running spec tests. Do you have some/any pointers on how I can run generative tests? @U05224H0W#2021-09-1008:05thhelleras always can't provide much help without seeing code#2021-09-1008:06FranklinI have a test runner namespace that looks like this
(defn ^:export run
  [karma]
  (stest/abbrev-result (first (stest/check `ranged-rand)))
  (karma/run-tests karma
                   'quagga.utils-test
                   'quagga.utils.components.account-select.events-test
                   'quagga.components.dataview.table.events-test
                   'quagga.utils.components.share-modal.events-test
                   'quagga.components.organization.profile.events-test
                   'quagga.components.organization.user-management.events-test
                   'quagga.components.dataview.table.views-test
                   'quagga.components.dataview.table.utils-test
                   'quagga.components.dataview.table.subs-test
                   'quagga.utils.views.wrap-header-and-footer-test
                   'quagga.components.dataview.subs-test
                   'quagga.components.dataview.utils-test
                   'quagga.utils.views.walkthrough-test
                   'quagga.utils.components.share-modal.views-test
                   'quagga.utils.views.confirm-modal-test
                   'quagga.utils.components.new-project-modal.views-test
                   'quagga.components.dataview.charts.views-test))
#2021-09-1008:06Franklinall the tests run fine... no errors#2021-09-1008:06Franklinbut the (stest/abbrev-result (first (stest/check ranged-rand))) is set up, on purpose to fail#2021-09-1008:06thhellerdon't know what karma/run-tests is#2021-09-1008:07thhellerdon't know what build config you are using#2021-09-1008:07thhellerdon't know how you actually run the build output#2021-09-1008:08thhellerlooks to me like you are running the tests separate from the generative test?#2021-09-1008:08thhellerI mean why is this (stest/check ranged-rand)` in the run function and not some test?#2021-09-1008:09Franklinyes... but that's probably because I don't really know the right way to run the generative tests yet#2021-09-1008:09Franklinkarma/run-tests comes from [jx.reporter.karma :as karma :include-macros true]#2021-09-1008:09Franklinwhich is a dependency in my package.json as karma-junit-reporter#2021-09-1008:10Franklinon the console, running the generative test looks like this
> (stest/abbrev-result (first (stest/check `ranged-rand)))
{:spec (fspec :args (and (cat :start int? :end int?) (fn* [p1__34241#] (< (:start p1__34241#) (:end p1__34241#)))) :ret int? :fn (and (fn* [p1__34242#] (>= (:ret p1__34242#) (-> p1__34242# :args :start))) (fn* [p1__34243#] (< (:ret p1__34243#) (-> p1__34243# :args :end))))), :sym cljs.user/ranged-rand, :failure {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 4}, :ret -2}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 4}, :ret -2}, :cljs.spec.test.alpha/args (0 4), :cljs.spec.test.alpha/val {:args {:start 0, :end 4}, :ret -2}, :cljs.spec.alpha/failure :check-failed}}
#2021-09-1008:10Franklinso it fails ok/as expected#2021-09-1008:10thhellerdon't know what that is or does but the way I'd go about it is#2021-09-1008:10thheller
(deftest my-gen-test (stest/check `ranged-rand))
#2021-09-1008:11thhellerand do whatever you need to do to assert the result so the deftest actually fails#2021-09-1008:11Franklincool... I'll try this both in my tests and in the console and see how it goes#2021-09-1008:11Franklinthanks#2021-09-1008:15Franklinso, it seems the test is actually registered with cljs-test
> (deftest my-gen-test (stest/check `ranged-rand))
#'cljs.user/my-gen-test
cljs.user=> (require '[cljs.test :as test :refer-macros [run-tests] :refer [report]])
nil
cljs.user=> (run-tests)

Testing cljs.user

Ran 1 tests containing 0 assertions.
0 failures, 0 errors.
nil
> (deftest my-gen-test2 (stest/check `ranged-rand))
#'cljs.user/my-gen-test2
> (run-tests)

Testing cljs.user

Ran 2 tests containing 0 assertions.
0 failures, 0 errors.
nil
cljs.user=> 
#2021-09-1008:15Franklinbut the issue seems to be that there aren't any assertions in it#2021-09-1008:16FranklinI guess I can check the return value of (stest/check `ranged-rand) and if it's an empty vector then the test has passed#2021-09-1008:16Franklinso (is (= [] (stest/check `ranged-rand))#2021-09-1008:17Franklinok.. yeah 😃 :thumbsup: that works
FAIL in (my-gen-test2) (repl-input.cljs:1:27)
expected: (= [] (stest/check (quote cljs.user/ranged-rand)))
  actual: (not (= [] [{:spec #object[cljs.spec.alpha.t_cljs$spec$alpha38994], :clojure.spec.test.check/ret {:shrunk {:total-nodes-visited 5, :depth 4, :pass? false, :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}, :result-data {:clojure.test.check.properties/error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}}, :time-shrinking-ms 3, :smallest [(0 2)]}, :failed-after-ms 6, :num-tests 3, :seed 1631261832504, :fail [(9 13)], :result #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 9, :end 13}, :ret 6}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.test.alpha/args (9 13), :cljs.spec.test.alpha/val {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.alpha/failure :check-failed}}, :result-data {:clojure.test.check.properties/error #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 9, :end 13}, :ret 6}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.test.alpha/args (9 13), :cljs.spec.test.alpha/val {:args {:start 9, :end 13}, :ret 6}, :cljs.spec.alpha/failure :check-failed}}}, :failing-size 2, :pass? false}, :sym cljs.user/ranged-rand, :failure #error {:message "Specification-based check failed", :data {:cljs.spec.alpha/problems [{:path [:fn], :pred (cljs.core/fn [%] (cljs.core/>= (:ret %) (cljs.core/-> % :args :start))), :val {:args {:start 0, :end 2}, :ret -1}, :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha38456], :cljs.spec.alpha/value {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.test.alpha/args (0 2), :cljs.spec.test.alpha/val {:args {:start 0, :end 2}, :ret -1}, :cljs.spec.alpha/failure :check-failed}}}]))

Ran 2 tests containing 1 assertions.
1 fail
#2021-09-1008:17thhellerI guess the clojure.test.check.results/pass? is supposed to do this#2021-09-1008:20Franklindoesn't really seem to report failures if I don't check if result is = to [ ].... but I think I'll just work with this for now#2021-09-1008:20thheller
(deftest my-gen-test2
  (ctcr/pass? (stest/check `ranged-rand)))
#2021-09-1008:20thhelleror rather
(deftest my-gen-test2
  (is (ctcr/pass? (stest/check `ranged-rand))))
#2021-09-1008:22thhellerreally just need something that takes the actual result you get and gets the info you need out#2021-09-1008:22thhellereither can write that function yourself or use something from test.check#2021-09-1008:22thhellerI'm not sure what you are supposed to use#2021-09-1008:35FranklinI'll just write a custom function... I'm satisfied with what I have already 😄#2021-09-1008:39thhellerthere most likely is something to do this. just might need to dig through some test.check sources or api docs#2021-09-0908:09Franklinany clue as to how I can get it to work?#2021-09-0918:15ChaseI have a leiningen/shadow-cljs full stack app built from a luminus template. I am getting this shadow-cljs warning when doing a release build:
WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced.
remote:                 You should remove this library from non-dev builds completely because it impedes dead code elimination.
remote:                 The best way is to use :preloads compiler option: .
#2021-09-0918:46ChasePart of the project.clj file that luminus gave me is this:
:profiles                                                                                                               
  {:uberjar {:omit-source true                                                                                            
                                                                                                                          
             :prep-tasks ["compile" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]                              
             :aot :all                                                                                                    
             :uberjar-name "ai.jar"                                                                                       
             :source-paths ["env/prod/clj"  "env/prod/cljs"]                                                              
             :resource-paths ["env/prod/resources"]}                                                                      
                                                                                                                          
   :dev           [:project/dev :profiles/dev]                                                                            
   :test          [:project/dev :project/test :profiles/test]                                                             
                                                                                                                          
   :project/dev  {:jvm-opts ["-Dconf=dev-config.edn"]                                                                     
                  :dependencies [[binaryage/devtools "1.0.3"]                                                             
                                 [cider/piggieback "0.5.2"]                                                               
                                 [org.clojure/tools.namespace "1.1.0"]                                                    
                                 [pjstadig/humane-test-output "0.11.0"]                                                   
                                 [prone "2021-04-23"]                                                                     
                                 [re-frisk "1.5.1"]                                                                       
                                 [ring/ring-devel "1.9.4"]                                                                
                                 [ring/ring-mock "0.4.0"]]                                                                
                  :plugins      [[com.jakemccrary/lein-test-refresh "0.24.1"]                                             
                                 [jonase/eastwood "0.3.5"]                                                                
                                 [cider/cider-nrepl "0.26.0"]]                                                            
                                                                                                                          
                                                                                                                          
                  :source-paths ["env/dev/clj"  "env/dev/cljs" "test/cljs"]                                               
                  :resource-paths ["env/dev/resources"]                                                                   
                  :repl-options {:init-ns user                                                                            
                                 :timeout 120000}                                                                         
                  :injections [(require 'pjstadig.humane-test-output)                                                     
                               (pjstadig.humane-test-output/activate!)]} 
and the shadow-cljs.edn file has this:
:builds                                                                                                                  
        {:app                                                                                                             
               {:target     :browser                                                                                      
                :output-dir "target/cljsbuild/public/js"                                                                  
                :asset-path "/js"                                                                                         
                :modules    {:app {:entries []}}                                                                    
                :devtools   {:watch-dir "resources/public"                                                                
                             :preloads  [re-frisk.preload]}                                                               
                :dev        {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}                               
                :release    {:compiler-options {:optimimizations :advanced}}}                                             
         :test {:target  :node-test, :output-to "target/test/test.js"                                                     
                :autorun true}}                                                                                           
 :lein  {:profile "+dev"}} 
So my build process is running this: shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm release app which is the problem because calling on that lein +dev is including the stuff I don't want in release. The uberjar profile in the project.clj file is not telling it to add that +dev part in the :prep-tasks commands so how do I get that honored?
#2021-09-0920:19thhellerdependencies do not decide what ends up in your build#2021-09-0920:19thhellerthe config looks fine#2021-09-0920:19thhellerI'm guessing you are requiring something from devtools.* somerwhere in your code?#2021-09-0920:41ChaseYes, but it's in /env/dev/app.cljs which is a source path only called for in the lein :project/dev profile which is why I thought it was shadow-cljs pulling in when calling that lein +dev command#2021-09-0920:45thhellerif you need per build or per task profiles just use lein itself#2021-09-0920:46thhellerbut I consider it an anti-pattern to switch the source paths like that so I'd recommend setting things up properly so you don't have to do this
#2021-09-0920:48ChaseInteresting. This is just a standard luminus template build so unfortunately I'm not too familiar with it's approach yet but it's probably something that should be brought to their attention.#2021-09-0920:48ChaseI have to step away but I'll work on this more later. Thanks for the help!#2021-09-0920:52thhellerthis pattern of your "main" namespace in 2 variants depending on the env should be avoided#2021-09-0920:52thhellerjust have one variant used by dev and release and then setup the extra stuff you need in a namespace included via :preloads (or just including those things directly via preloads)#2021-09-0920:53thhellerhaven't looked at luminus in a long while.#2021-09-1011:37zendevil.ethI included this package in my project.clj and :lein is set to true in shadow-cljs.edn, so this package should be usable, but I get: “the required namespace “re-graph.core” is not available, it was required by …”#2021-09-1015:46thhellerdid you restart shadow-cljs after adding it?#2021-09-1107:11cjmurphyCan shadow-cljs.edn contain Clojure code? The reason I'm asking is we have different developers with different :preloads requirements and it would be handy to have an(other) edn file that could be read to determine whose machine the shadow-cljs.edn file is on. Any other way to achieve this? I was also thinking of taking it out of version control. But a configurable option would be ideal.#2021-09-1107:18thheller@cjmurphy well you can use the clojure API to customize just about everything but no the shadow-cljs.edn does not eval code. https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge might also work#2021-09-1107:19thhellera build hook could also work#2021-09-1307:10ingesolI currently get multi-project reloading by adding other project’s source folder into`:extra-paths` in deps.edn, But can shadow auto-reload :local/root deps? And does that make sense?#2021-09-1317:00thhellerit can and it should?#2021-09-1317:49martin hablakHello, I’m using shadow-cljs and have npm package with name which start with at character (@), how do I require such package#2021-09-1318:20borkdude@martin.hablak using a string "@foo/bar"#2021-09-1321:23ingesol@thheller ok, didn't work the first time I tried, will do another attempt tomorrow#2021-09-1400:05caleb.macdonaldblackDo preloads work in ~/.shadow-cljs/config.edn#2021-09-1404:55thhellerno, build configs are not supported there. what kind of preload do you have in mind?#2021-09-1523:47caleb.macdonaldblackA coworker is using reframe 10x but I dislike it because my app-db output in the chrome console is no longer sorted. A solution I’ve thought of is two seperate builds.#2021-09-1605:21thhellerone option would be shadow-cljs watch app --config-merge '{:devtools {:preloads [foo.bar]}}' or using the clojure API to start things#2021-09-1605:21thhellerthen you can modify everything to your liking#2021-09-2703:43caleb.macdonaldblack@U06077728#2021-09-1407:00ingesol@thheller Sorry for the confusion, turns out I was calling my build with the wrong alias, reloading on :local/root works great#2021-09-1409:01WestHow do I interpret this error?
Execution error (TypeError) at (<cljs repl>:1). shadow.js.shim.module$unified.unified is not a function
Here’s a sample of the source.
(ns app.org-parser
  (:require ["unified" :as unified]
            ["rehype-stringify" :as html]
            ["uniorg-parse" :as uniorg]
            ["uniorg-rehype" :as rehype]
            ["rehype-raw" :as raw]
            ["uniorg-extract-keywords" :refer [extractKeywords]]
            shadow.resource))

(def ^:private processor
  (.. (unified)
      (use uniorg)
      (use extractKeywords)
      (use rehype)
      (use raw)
      (use html)))
Is there something wrong with unified such that I can’t import it? I also tried using js/require but that didn’t work either.
require() of ES Module /Users/main/Code/clojure/mysite/node_modules/unified/index.js from /Users/main/Code/clojure/mysite/[stdin] not supported.
Instead change the require of index.js in /Users/main/Code/clojure/mysite/[stdin] to a dynamic import() which is available in all CommonJS modules.
#2021-09-1409:03borkdude@c.westrom If you want to use ES modules in your project, it might be best to compile your project itself as an ES module.#2021-09-1409:05borkdude@c.westrom I have an example of such a project here: https://github.com/borkdude/nbb/blob/main/shadow-cljs.edn#2021-09-1409:06borkdudeNote that you will likely also have to change your import to "unified$default" :as unified after switching#2021-09-1409:13borkdude@c.westrom There are currently no docs for the :esm target, but you can read about it here: https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-09-1409:15West@borkdude Ok, I'll try and see if it still works in the browser.#2021-09-1409:16borkdude@gnhuy91 also recently used it, perhaps he also has some pointers#2021-09-1409:17huygnyea it works on the browser if you use script type="module"#2021-09-1409:19huygnwhich is cool, then you can fully dance with the whole esm/deno ecosystem, downside is old browsers compat, but who cares 🤷 we had that curse for a decade already, time to get moving#2021-09-1409:20borkdudeI hope Github also moves to Node 14 or 16 for their action runners, then I can finally use nbb (ESM) for that#2021-09-1409:21huygnooh so esm is from node 14? I thought node 16#2021-09-1409:21borkdude12 already supports it but their action runner doesn't use the appropriate --experimental flag#2021-09-1409:25borkdude
$ nbb -e 'js/process.version'

"v12.22.6"
#2021-09-1409:28borkdudeso I'm actually not sure what the problem is with the Github action runner: I think they're using an even older 12 version#2021-09-1409:30WestWell, it seems like :target :esm as an option works in the browser just fine, I’m still getting the same errors when trying to use unified though.#2021-09-1409:30borkdude@c.westrom what error are you getting. Did you use script type="module" as well?#2021-09-1409:30borkdudeAlso "unified$default" :as unified#2021-09-1409:31WestAh, forgot about $default again, but after adding I get this now.
------ REPL Error while processing ---------------------------------------------
(cljs.core/load-file "/Users/main/Code/clojure/mysite/src/app/org_parser.cljs")
------ REPL Error while processing ---------------------------------------------
(ns app.org-parser
  (:require ["unified$default" :as unified]
            ["rehype-stringify" :as html]
            ["uniorg-parse" :as uniorg]
            ["uniorg-rehype" :as rehype]
            ["rehype-raw" :as raw]
            ["uniorg-extract-keywords" :refer [extractKeywords]]
            shadow.resource))
In :require [shadow.js.shim.module$unified$default :refer (unified)] already used by [shadow.js.shim.module$unified :refer (unified)]
#2021-09-1409:32WestI did update my index.html with type="module" in the script tag.#2021-09-1409:32borkdudeok, I think you're on the right track#2021-09-1409:33borkdudeperhaps just start with only that require#2021-09-1409:33borkdudeand then gradually add more#2021-09-1409:33borkdudeyou might have some stale cache or so#2021-09-1409:33borkdudeit seems#2021-09-1409:33borkduderestart your shadow process, clean .shadow-cljs#2021-09-1409:36borkdude@c.westrom I think you will also need to add $default to the other requires btw#2021-09-1409:42WestOk, heavily stripped it down
(ns app.org-parser
  (:require ["unified$default" :as unified]
            #_["uniorg-parse$default" :as uniorg]
            #_["uniorg-rehype$default" :as rehype]
            #_["rehype-stringify$default" :as html]
            #_["rehype-raw$default" :as raw]
            #_["uniorg-extract-keywords" :refer [extractKeywords]]
            ;;shadow.resource
            ))
Here’s the result.
Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$unified$default is not a function
Looking at the source for unified, it isn’t labeled as a default export, just an export.
export const unified = base().freeze()
#2021-09-1409:43borkdudeCan you try "unified$unified" ?#2021-09-1409:44West
------ REPL Error while processing ---------------------------------------------
(cljs.core/load-file "/Users/main/Code/clojure/mysite/src/app/org_parser.cljs")
------ REPL Error while processing ---------------------------------------------
(ns app.org-parser
  (:require ["unified$unified" :as unified]
            #_["uniorg-parse$default" :as uniorg]
            #_["uniorg-rehype$default" :as rehype]
            #_["rehype-stringify$default" :as html]
            #_["rehype-raw$default" :as raw]
            #_["uniorg-extract-keywords" :refer [extractKeywords]]
            #_shadow.resource
            ))
In :require [shadow.js.shim.module$unified$unified :refer (unified)] already used by [shadow.js.shim.module$unified$default :refer (unified)]
#2021-09-1409:44borkdudethis is a REPL error I think#2021-09-1409:44borkdudejust re-start the process#2021-09-1409:44Westrestarting…#2021-09-1409:45borkdudeI'll also try unified from nbb#2021-09-1409:46West
cljs.user> (ns app.org-parser
             (:require ["unified$unified" :as unified]
                       #_["uniorg-parse$default" :as uniorg]
                       #_["uniorg-rehype$default" :as rehype]
                       #_["rehype-stringify$default" :as html]
                       #_["rehype-raw$default" :as raw]
                       #_["uniorg-extract-keywords" :refer [extractKeywords]]
                       #_shadow.resource
                       ))
nil
Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$unified$unified is not a function
again
#2021-09-1409:47borkdude
$ nbb -e '(ns foo (:require ["unified$unified" :as u])) (.log js/console u)'
[Function: processor] {
  data: [Function: data],
  Parser: undefined,
  Compiler: undefined,
  freeze: [Function: freeze],
  attachers: [],
  use: [Function: use],
  parse: [Function: parse],
  stringify: [Function: stringify],
  run: [Function: run],
  runSync: [Function: runSync],
  process: [Function: process],
  processSync: [Function: processSync]
}
#2021-09-1409:48borkdudedid you npm install unified?#2021-09-1409:49Westyarn add but I think that’s effectively the same#2021-09-1409:50borkdudeis this really all the source you have or are you using unified somewhere?#2021-09-1409:50Westthe workaround I had to do before, was compile a separate program as a node script and then import the compiled script for my site#2021-09-1409:50borkdudethat workaround shouldn't be necessary for :esm#2021-09-1409:51borkdude@c.westrom Perhaps you can make a tiny repository on Github with this code#2021-09-1409:51borkdudefor us to try locally#2021-09-1409:52Westhttps://github.com/wildwestrom/mysite/tree/develop I was just thinking of that. I’ll make a minimal one though.#2021-09-1410:17West
Execution error (TypeError) at (<cljs repl>:1).
shadow.js.shim.module$unified$unified is not a function
Ok, minimal project here: https://github.com/wildwestrom/minimal-unified-troubleshooting
#2021-09-1410:22borkdude@c.westrom I am seeing: > Holy fuckeroni, is this working? I guess it is if you can see it.#2021-09-1410:23borkdudeafter: > npx shadow-cljs compile app and then serving the HTML in a local server#2021-09-1410:23Westyep, but in the repl is where I encounter problems#2021-09-1410:23borkdudehow do you start the REPL?#2021-09-1410:23Westcider-connect-cljs in emacs. I don’t know what the equivalent is in your editor.#2021-09-1410:24WestSo yarn start then cider-connect-cljs.#2021-09-1410:24borkdudeAh screw the cljs-repl, I'm just using npx shadow-cljs watch app#2021-09-1410:25borkdudeThe CLJS REPL is such a pain that I've stopped using it ages ago#2021-09-1410:25borkdudeunless I'm in node, then I use a very minimal (require 'foo :reload) workflow#2021-09-1410:25borkdudebut at this point, we've demonstrated that your ES module works. The rest is a tooling problem, either downstream or in shadow itself.#2021-09-1410:25borkdudeSo at this point, I would say: take it up with @thheller or otherwise#2021-09-1410:31WestAlright, imma update the example. Also, here’s the separate script I made as a workaround: https://github.com/wildwestrom/uniorg-util#2021-09-1410:38borkdude@c.westrom is this just for command line invocation?#2021-09-1410:38Westyes#2021-09-1410:39WestIt’s probably way more trouble than I needed to go through.#2021-09-1410:39borkdudecool. I think it would be a nice challenge to make this project work with #nbb as that is kind of the niche of what it's for: making scripts/CLIs with interop for node#2021-09-1410:40borkdudeI'll make an issue for that and see how far I'll get with that#2021-09-1410:40Westawesome! :thumbsup: and thanks for all the help so far @borkdude#2021-09-1411:09roman01la👋 is it technically possible to reduce code splitting setup to Webpack’s Dynamic Imports experience (https://webpack.js.org/guides/code-splitting/#dynamic-imports) i.e. import("./file.js")? Basically removing configuration step in build config. I was thinking about something like a macro that would inject modules configuration into shadow’s build state, not sure if it makes sense. cc @dazld#2021-09-1411:21huygnmaybe unrelated but I've recently tried import(..) within script type="module" to lazy-load a shadow-cljs module. (context is to load new react page component then render after url change) Currently hitting an issue where such import will download a shared module again, so if home & about module both depends on shared module then both imports will trigger shared module download. Which leads to duplicated cljs namespace error or even React error due to different React/ReactDOM instance kind of thing.#2021-09-1412:13huygnfor your idea, I'd love see it happens 🙏 having to explicitly specify split modules is quite verbose imo, (although I think it can somehow achievable with a script that pass merge option to shadow-clja cli)#2021-09-1412:55roman01laI think that effortless code splitting has an important side effect in developer engagement and reduced maintenance cost. If the tool encourages code splitting then it’s more likely that engineers would develop features in a way that defers code to later. An example would be not only splitting by route/page, but by particular component or feature that it not immediately accessible#2021-09-1412:58borkdude@U0FR82FU1 FWIW I've also adopted this approach in #nbb: I lazily load code-splitted modules on demand, e.g. when someone requires reagent.core I lazily load the reagent module using js/import. I don't understand what you need from shadow since this is already supported?#2021-09-1413:17huygnI think he means to perform code split without having to declare modules in shadow-cljs edn confile file#2021-09-1413:35roman01laCorrect ^#2021-09-1414:09thhellerthis is mostly a problem since the closure-compiler doesn't support it (yet)#2021-09-1414:09thhellerin theory this can work but I believe the result is always worse than properly setting up your modules manually#2021-09-1414:10thhellerits not that complicated and it won't just magically make an app work that isn't designed for it#2021-09-1414:11thhellerthere are limits to automatic splitting and you can often end up with many tiny modules which actually load slower due to the cascasding requests requiring to load them (a loads b loads c loads d etc)#2021-09-1414:14thhelleralso :advanced can do so much more with static information#2021-09-1414:25thhellerFWIW if you start with https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841 you can write your code as-if you had this magic import thing and then at a later point worry about organizing your modules and tweaking them until happy#2021-09-1414:25thhellersince that helper hides the actual module names and lets you focus on namespaces instead#2021-09-1414:26thhellertotally fine to start with one module and go from there (and adjust later)#2021-09-1412:43rosadoI have a react-native app and I'm trying to introduce dynamic module loading, but keep hitting "shadow.loader API was called before shadow.loader.init!" error. I tried calling init, but it didn't change anything. Is there a particular place the init should happen?#2021-09-1414:55thheller@rosado you cannot use the shadow.loader with react-native at all. metro needs to handle the loading#2021-09-1414:56thhellerso you use js/require to load modules#2021-09-1414:56thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/rn.cljs#L29 like that I guess#2021-09-1414:57thhellerwhereas the ./foo.js file is created by this chunk https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L492-L494#2021-09-1414:58thhellershadow.loader only works in a browser environment, not react-native#2021-09-1414:59thhellerI don't have a clue whether the js/require is actually dynamic though. I don't use react-native and don't know what the situation there is#2021-09-1415:32rosadothanks @thheller#2021-09-1419:09ChaseI want to have my public folder in a resources directory but whenever I make that switch my backend messes up. It says that foo is not defined in foo.core.main() portion of the js script in my index.html. What I changed in my shadow-cljs.edn file was the :output-dir to "resources/public/js" instead of "public/js" , the :asset-path to "/public/js" instead of "/js" and the :http-root to "resources/public" instead of "public" .#2021-09-1419:10Chaseshadow-cljs watch app still works as expected with those changes#2021-09-1419:11thhelleryour asset path needs to be "/js" since that is the path to access the actual files over http#2021-09-1419:12thhellersee https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-09-1421:17ChaseThanks!#2021-09-1419:10Fredrik AnderssonI'm trying to understand how I would :require npm package firebase: 9.0.1 in my code. I have tried multiple versions of "firebase/app" with :as :default and :refer. Compiler say [BABEL] Note: The code generator has deoptimised the styling of "node_modules/@firebase/firestore/dist/index.esm2017.js" as it exceeds the max of "500KB". And I get error in chrome saying shadow-cljs - failed to load module$node_modules$$firebase$app$dist$index_esm2017#2021-09-1419:13thheller@fredrik245 impossible to answer without more info#2021-09-1419:13Fredrik Anderssonwhat info do you need?#2021-09-1419:13thhellerlike what other errors do you get in the browser console?#2021-09-1419:14thhellerwhat is your build setup? why do you get a babel error?#2021-09-1419:14Fredrik Andersson#2021-09-1419:14Fredrik Andersson:client {:target :browser :output-dir "dist/client/js" :asset-path "js" :modules {:main {:entries [percap.client.core]}} :devtools {:before-load percap.client.core/stop :after-load percap.client.core/start :http-root "dist/client" :http-port 8022}}#2021-09-1419:14thhellerupgrade shadow-cljs to fix that one#2021-09-1419:15Fredrik Anderssonok! thanks!#2021-09-1419:24Fredrik Anderssonnow it works!#2021-09-1419:26thhellerjust for future reference the important errors here were the red actual errors. the yellow one is just a warning and useful for diagnosis but not the actual error 😛#2021-09-1421:10Fredrik Anderssonhowever the red errors didn't tell me much other then there is an error#2021-09-1421:11Fredrik Anderssonbut it works now. So I am happy 😃#2021-09-1512:30mccraigmccraig@thheller we (@rosado & i) did an experiment - we created an RN build with a chunk, and added logging to the chunk .js wrapper so that we could see when the file is loaded. we js/required the chunk on a click in the app, and confirmed that the chunk .js file was indeed loaded dynamically#2021-09-1515:49thheller@mccraigmccraig thanks for the feedback. good to know 🙂#2021-09-1515:57mccraigmccraigvery good for us - if we couldn't get a working cljs code-splitting story with react-native then we would have had to give up on cljs 🙀#2021-09-1516:01thhellerhow much impact does it have on load time? loading on demand vs loading everything?#2021-09-1516:08mccraigmccraigwe're porting our app from cordova to react-native now, and building code-splitting in from the beginning of the port. analysis we did on the cordova app suggested we could save about 60% of the js load time by loading on demand. it will not make that much difference for a user with an iphone 13 (time-to-interactive <2s), but will make a big difference to anyone on an underpowered android from a few years ago (time-to-interactive >10s)#2021-09-1516:26thhellerhm yeah. only other project I know using :chunks for RN is the status-im stuff. always good to have some more data on hand for this stuff 🙂#2021-09-1516:27thhellerguess it'll be about the same as browser builds on lower end devices#2021-09-1516:32mccraigmccraigRN is all quite new to me, but i had a look around the shadow source... it looks like :chunks is sugar over :modules - and the js/require stuff in RN itself is all pretty vanilla - so altogether there doesn't seem to be anything scary or magical about the splitting or loading mechanisms, which definitely gave me some comfort#2021-09-1516:34thhelleryeah. I only looked at the RN JS examples on how to do lazy loading. so I knew what kind of output it needs and just made shadow-cljs create that 😛#2021-09-1516:34thhellernever built an actual RN app myself but seemed straightforward enough to implement so I did#2021-09-1516:35thhellerbasically everything in shadow-cljs is based on :modules (or now called :chunks) so it was quite easy#2021-09-1516:36thhellerclosure compiler renamed everything from modules to chunks so I just started the RN stuff with :chunks directly#2021-09-1516:36mccraigmccraigahh, that's why :chunks - i did wonder#2021-09-1516:36thhelleryeah works in browser builds too. exactly the same thing as :modules, just a rename#2021-09-1516:37thhellerthe name makes more sense too. modules is quite overused and unclear what it actually means#2021-09-1516:40mccraigmccraigyeah, chunks is clearer#2021-09-1516:41mccraigmccraigRN has its own code-splitting mechanism called RAM Bundles (yet another word for it)... it did take me a while to realise that we could ignore that, because once the code-splitting is done, it's just js/require#2021-09-1516:41thhelleryeah I was never sure how to get the actual lazy loading part since js/require looks sync#2021-09-1516:42thhellerbut I guess it can be when its in memory just not initialized#2021-09-1516:45mccraigmccraigum i think js/require is sync - doesn't matter to me though - tiny (mostly not noticeable, unless you've got one of those underpowered old 'droids, in which case you are used to them) pauses throughout a session vs big pause at the start of a session#2021-09-1516:47mccraigmccraigif you want some additional docs on RN config for shadow, i'm happy to do a PR or whatever, once we're properly up and running#2021-09-1516:49thhelleralways welcome to get more docs on the topic. I don't use RN myself so I let a linger a little too much 😛#2021-09-1516:53lilactownI have a question that I probably know the answer to but curious to get others thoughts, related to code splitting: say I have a library where I want to dynamically load some code. e.g. something like re-frame-10x or another dev tool that is used to inspect the running state of the app. I'd like it to be available in production, but not affect the size of the main bundle of the app. could there be a way in the future to "provide a chunk" as a library? the alternative here of course is to instruct users how to configure the chunk themselves, which seems like a task many wouldn't want to bother with but obviously works today#2021-09-1516:58thhellerI'd say no. setting up a chunk is trivial so I don't see a reason why we would need any automation there#2021-09-1516:58thhellerand anything you add to your app in :advanced will affect the bundle size#2021-09-1516:59thhellerit rarely works to move 100% of the code into the lazy loaded chunk. a good percentage for sure but not everything#2021-09-1613:47alexdavisOn the topic of code splitting, I was wondering if there is a way to load chunks dynamically after a component has mounted. Say I have a login page and I know that a large amount of users will go onto the home page, at the moment I would have a sign-in and home module, and the home bundle would start downloading as soon as I click login. But it would make a lot more sense to say ‘after sign-in has mounted, start downloading the home module’. With webpack I could do this
function SignUp() {
  useEffect(() => {
    import('./home')
  }, []);
  ...
}
Is there a way of doing this with shadow?
#2021-09-1613:57thheller@alex395 see https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2021-09-1614:02alexdavisI have seen that, but doesn’t that just bundle multiple things together?#2021-09-1614:04alexdavisLike this creates a single ‘users’ bundle file that includes three pages
:users
    {:entries [demo.components.account-overview
               demo.components.sign-in
               demo.components.sign-up]
     :depends-on #{:main}}
But I wanted to know if you can have individual bundles, but pre download future bundles after a page has loaded and the component has mounted
#2021-09-1614:05thhellerI don't know what more to say that what isn't already in the post. the example you picked is a literal example trying to describe how different way of splitting may make sense in your app#2021-09-1614:06thhellersometimes grouping stuff is useful sometimes it may not be. all depends on what exactly your app does so I cannot answer that#2021-09-1614:06thhellersplitting/loading/preloading is all possible#2021-09-1614:07thhellerI mean (useEffect #(sl/load users-bundle) #js []) would be the preloading your mentioned#2021-09-1614:08thhellerwhat you don't get is a automatic splitting webpack does. you are required to define :modules yourself. I believe that to a better way to do stuff but it requires more thought#2021-09-1614:09thhellerfrom the code perspective it is pretty much identical though#2021-09-1614:11alexdavisOk yeah I’ve just looked at the actual code, I assumed the wrong thing about how lazy-component worked#2021-09-1614:11alexdavisThanks!#2021-09-1614:15thheller@alex395 also see https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2021-09-1614:16thhellerlazy-component was just a util to make the blogpost code less verbose#2021-09-1614:25alexdavisYeah its my fault for not reading carefully enough, but that thread also has some good information I didn’t know#2021-09-1715:16Michaël SalihiHello! Just to be sure before doing some tests, I would to know if I go in the right direction.#2021-09-1715:17Michaël SalihiThis is about :js-provider :external js-options.#2021-09-1715:18Michaël SalihiI can use the external-index file to do some tree shaking with for eg. webpack, right?#2021-09-1715:20thhellernot really#2021-09-1715:20thhelleror rather I don't know what webpack tree shaking looks like these days. I doubt it though.#2021-09-1715:22Michaël SalihiOK, so this is maybe not the solution for one project.#2021-09-1715:23thhellerwhat kind of shaking are you looking for? generally the best result you'll get is by using modular libs that allow you to access certain stuff directly#2021-09-1715:23thhellerwhether you use those with just shadow-cljs or together with webpack will then be a minor difference#2021-09-1715:24Michaël SalihiAfter checking the file, I understand that bundler cannot works on DCE because the require are "global" in compare in my CLJS code.
ALL["@ant-design/icons"] = require("@ant-design/icons");
 ALL["@ant-design/pro-layout"] = require("@ant-design/pro-layout");
 ALL["react-dom"] = require("react-dom");
#2021-09-1715:24Michaël SalihiVS#2021-09-1715:25Michaël Salihi
["antd/es/button" :default Button]
            ["@ant-design/pro-layout" :default ProLayout :refer [PageContainer]]
            ["@ant-design/icons" :refer [AppstoreOutlined FileTextOutlined LikeOutlined SettingOutlined AlipayCircleFilled]]
#2021-09-1715:26thhellergood example. instead of requiring the @ant-design/icons directly which itself imports thousands of other things you are unlikely to use#2021-09-1715:27thhellerjust require what you actually use directly, eg. (:require ["@ant-design/icons/FileTextOutlined" :as FileTextOutlined])#2021-09-1715:27borkdude(clj-kondo should be able to inform you what you're actually using or not)#2021-09-1715:27thhellerthat only loads what you actually need and eliminates the other thousands#2021-09-1715:29Michaël SalihiYes thank you. This is my first try but I go in direction to :js-provider :external because Ant design lib relies heavily on importing less css file for all his components#2021-09-1715:30Michaël Salihi
node_modules/antd/es/tag/style/index.js:import '../../style/index.less';
node_modules/antd/es/tag/style/index.js:import './index.less';
node_modules/antd/es/time-picker/style/index.js:import '../../style/index.less';
node_modules/antd/es/time-picker/style/index.js:import './index.less'; // style dependencies
#2021-09-1715:31Michaël SalihiSo it breaks Shadow-cljs build.#2021-09-1715:31Michaël SalihiI knwo I can avoid this error excluding assets with ignore-asset-requires true#2021-09-1715:32Michaël Salihibut after that the CSS styles are missing for these components.#2021-09-1715:33Michaël SalihiSo I try to find the best way to glue all of that.#2021-09-1715:33thhellernot a clue. antd has always been rather terrible from a package perspective. requiring custom webpack plugins and so on to work#2021-09-1715:33thhellerso using webpack seems like a good strategy#2021-09-1715:34Michaël SalihiPerfect, make sense. Thank you for the confirmation.#2021-09-1715:35Michaël SalihiSo if I want to use Shadow-CLJS + Webpack, :js-provider :external is the only solution, right?#2021-09-1715:35thhellernot the only but the recommended#2021-09-1715:36Michaël SalihiOK#2021-09-1715:36thhellerhttps://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-09-1715:38Michaël SalihiFor my project right now it works well, except my external-index file size is 1.8M 😕#2021-09-1715:38Michaël SalihiThis is the reason for my first question.#2021-09-1715:39thhellerthat should solve itself if you require icons directly#2021-09-1715:39thhellerinstead of relying on wonky tree shaking#2021-09-1715:40Michaël SalihiOK, I try that right now, thanks.#2021-09-1715:42Michaël SalihiMaybe this approach would be interesting in the CLJS world: https://github.com/ant-design/babel-plugin-import#example#2021-09-1715:42thhellerno, thats nonsense#2021-09-1715:42Michaël SalihiDon't know if it's doable#2021-09-1715:43thhellerwhy complicate your build setup 10x when you can just require the icon you want and write 3 lines more code?#2021-09-1715:46Michaël SalihiFor my part, it suits me very well to target imports. It was more of a suggestion / idea in order to avoid mistakes when working as a team.#2021-09-1715:46Michaël SalihiIn fact, it remains only good practices to be communicated at the team. 👍#2021-09-1715:48Michaël SalihiThank you for your precious help.#2021-09-1715:49thhellerantd is one of those libs that really really wants you to use webpack so definitely go with that#2021-09-1715:51thhellerI had some code to make the external-index generate actual import { Thing } from "thing" instead of require but that had all sorts of other issues#2021-09-1720:17Michaël SalihiInteresting. What kind of issues ? Specific for some config or globally very unstable ?#2021-09-1806:31thhellercommonjs <-> ESM interop issues mostly. say you have reagent using (:require ["react" :as react]) that would map to import * as react from "react" but given that react is shipped as commonjs only it must be imported via import react from "react"#2021-09-1806:32thhellerbut figuring this out at build time is hard when not actually building JS (since webpack will do it)#2021-09-1806:33thhellerso either it would requiring some sort of config you'd need to provide manually or some magic I don't like#2021-09-1806:33thhellercan't have reagent change the import since that would then break others not using ESM#2021-09-1806:54Michaël SalihiOK I understand. Being able to configure that would be great! Thank you for all these details.#2021-09-1806:56Michaël SalihiYour code to make external-index generate import is on testing branch?#2021-09-1806:57thhellerno, just commented out#2021-09-1806:58thhellerhttps://github.com/thheller/shadow-cljs/blob/60d593c1f599c5e6887c937e853ad1eaec39c76f/src/main/shadow/build/targets/external_index.clj#L70#2021-09-1806:58Michaël SalihiPerfect, I'll check.#2021-09-1806:58thhellerhttps://github.com/thheller/shadow-cljs/blob/60d593c1f599c5e6887c937e853ad1eaec39c76f/src/main/shadow/build/targets/external_index.clj#L107-L114#2021-09-1912:21Michaël SalihiHi, I come back to our exchange because I continued my tests and I am a little desperate and I will seek confirmation before abandoning the plan to use Ant design pro with ClojureScript.#2021-09-1912:26Michaël SalihiEven targeting components, icons directly, my external-index bundled by webpack weight more than 1,1Mb.#2021-09-1912:27Michaël Salihi
["@ant-design/pro-layout" :default ProLayout :refer [PageContainer]]
["@ant-design/icons/AppstoreOutlined" :default AppstoreOutlined]
["@ant-design/icons/FileTextOutlined" :default FileTextOutlined]
["@ant-design/icons/LikeOutlined" :default LikeOutlined]
["@ant-design/icons/SettingOutlined" :default SettingOutlined]
["@ant-design/icons/AlipayCircleFilled" :default AlipayCircleFilled]
#2021-09-1912:29Michaël SalihiAs the external-index file uses commonjs require then I can't do anything at webpack level, like eg tree shaking like with es import, right?#2021-09-1912:31Michaël SalihiHere is how Ant design pro exports its components: https://github.com/ant-design/pro-components/blob/master/packages/layout/src/index.tsx#L29-L59#2021-09-1912:33Michaël Salihi@thheller This is not a personal project but a professional request and your opinion will be very valuable in order to know if I can confirm that there is a solution or if I must give up. Thanks#2021-09-1914:41thhellerI would recommend writing a file like the external index by hand just using import#2021-09-1914:42thhellerand then actually running webpack and see what size you get vs require#2021-09-1914:43thhelleror even analyzing why things are that big#2021-09-1914:43thhellereg. shadow-cljs build report and webpack bundle analyzer#2021-09-1715:51thhellerso I went with require#2021-09-1715:51lispers-anonymousHello, if I have a namespace that looks like this
(ns foo.bar)
(def dog "doug")
and another namespace
(ns foo.bar.dog)
;; other stuff
I end up with a namespace clash
Namespace foo.bar.dog clashes with var foo.bar/dog
That makes sense, I understand why that happens. Is there a way to work around this without renaming namespaces or vars? I was thinking there would be some configuration for my :target :browser build where I could declare something the effect of "namespace foo.bar should be compiled to the name 'something_completely_different' on the output javascript object" It's not that big of a deal, I can always rename, but it would be nice to be able to keep the ones I have right now.
#2021-09-1715:56thheller@dannyfreeman that would need to be solved in the cljs compiler directly. not something shadow-cljs can change.#2021-09-1715:58lispers-anonymousGot it, thanks for the quick response. We'll just re-think our names, no big deal.#2021-09-1715:59thhelleryeah its unfortunate. I'd like to change it myself but that may break a lot of code out there#2021-09-1715:59thhellerso unlikely this is going to change anytime soon#2021-09-1716:01lispers-anonymousEverything has it's quirks, cljs is no different#2021-09-1716:38winsomeDoes the :browser target support the :exports option? I'm trying to build a browser package and a node package from the same source, but I'd like to exclude some node-specific functions from the browser build.#2021-09-1716:40thhellerno. use a separate build for node stuff#2021-09-1716:42winsomeI am setting it up as a separate build already, just they both use the same source. I guess I can move the node-specific stuff to another namespace and include it as a submodule#2021-09-1718:01borkdude@thheller hmm would the :esm build target be helpful there as well, since it basically generates the same source for browser and node?#2021-09-1720:03thhellerdont know enough to say. I would go with two builds given there is node-specific stuff#2021-09-1801:00johnI've been working on some stuff to do with parallelism with SAB's atomics and it's really hard to get a good demo site going on github pages, with the latest security header requirements for SABs. So I've been wanting to migrate my testing over to nodejs and flesh it over there, until browsers settle on a security model. But I'm not seeing a lot of prior art out there for using CLJS with worker_threads. If I end up working on building something out on nodejs, I'd probably want to bust the thing that wraps the worker_threads api out into its own lib. Things is, it's inherently a code deploy situation, where you're pushing some set of code into the worker. How you go about doing that depends on your build environment. When I build my tau.alpha framework for the browser, I kinda hardcoded into the code where to find the sources to inject into the worker based on figwheel's semantics, iirc. I'm wondering if I can come up with some strategy to inject code into the worker in a way that will be compatible with vanilla clojure, figwheel and shadow - a build-tool agnostic method by which I can easily push my build into nodejs webworkers#2021-09-1801:05johnIn the browser, I would just basically load the entire app in the worker. Then I would use conditional checks on whether I was in a worker or not to trigger certain behaviors on wokers vs main. Going that route, it's a little easier to perhaps engineer compatibility with vanilla, figwheel and shadow. However, thinking about selectively loading modules in particular workers, for instance, is a little less certain, wrt cross-build-tool compatibility#2021-09-1801:07johnSo for this nodejs impl, I'm thinking about getting a little more nuanced and allowing for selective loading of deps in workers, but I'm not sure what the lay of the land is, in terms of what strategies would be compatible with the most build tools#2021-09-1801:07john@thheller wondering if you have any opinions on this yet#2021-09-1801:14johnI mean, I know there's a webworker story already out there for the default cljs, figwheel and shadow, and things could maybe be patched up to work with worker_threads, in each case. But until that time comes, in a lib, I could just do the job of grabbing the sources and putting things where they belong myself. I'm just not sure if "grabbing the sources" is really a coherent story across all three build strategies#2021-09-1806:25thheller@john not sure what you are trying to do but given that node doesn't care much about build size I would go with two separate builds. two :target :node-script basically. one :main one :main your.worker/main. no clue what you mean by "selective loading of deps". if that refers to loading CLJS namespaces on demand then your only option is going self hosted#2021-09-1806:27thhellerworker_threads itself is pretty much the same setup as regular workers in a browser. you load a file designed for it and start listining for or posting messages back and forth#2021-09-1806:29thhellerI consider this isMainThread checking all over the place bad practice (just like regular web-workers) so I always go with writing your own entry namespace for the worker that is only ever loaded in the worker and as such never has to check what it is supposed to be#2021-09-1813:12arohnerI’m having trouble getting --config-merge to work: clojure -m shadow.cljs.devtools.cli --config-merge '{:js-options {:js-package-dirs ["external/frontend_npm/node_modules"]}}' release frontend returns: Searched for npm packages in: /Users/arohner/Programming/griffin/banksy/node_modules i.e. without updating the actual list of package-dirs. Is there a way to debug what the config looks like post merge?#2021-09-1815:01thheller@arohner I guess that is a bug. the config merge happens later, after :js-package-dirs is used#2021-09-1815:02thhelleryou can set :release {:js-options {:js-package-dirs ["external/frontend_npm/node_modules"]}} in your build config to make it only apply to release builds but not dev?#2021-09-1815:03thhelleralthough thinking about it that may have the same issue. how come you only want to set this conditionally?#2021-09-1818:03arohnerI’m in the middle of transitioning our build to bazel. Some users are still on lein, and official builds will be done via bazel soon#2021-09-1821:47thhellerbut why does that change which npm modules you include?#2021-09-1821:47thhellerfeel free to open an issue about this though. not intentional that this isn't config-merge-able#2021-09-1911:43arohnerIt’s more just to avoid repeating myself. Bazel is very opinionated in general, and has a strict separation of input and output files. In Bazel’s opinion, no new files should be created in the git repo when you do a build, which includes ./node_modules. So bazel runs everything in a separate dir, which changes the path of node modules. Bazel defines its own node_modules directory, so it’d be nice if I could pass that in directly, because it’s a small DRY violation to list it in shadow. But yeah, not the end of the world.#2021-09-1914:33thhellerI get that you put npm packages in a different dir. I do it myself and even recommend doing it. I just don't get why you don't do it always. Why are your "users are still on lein" not doing that also? independent of bazel? I mean this is not related to bazel in any way AFAICT?#2021-09-1914:33thhellerbut I'll fix that bug regardless#2021-09-1916:35thheller2.15.10 should allow you to config-merge js-package-dirs#2021-09-2009:03arohnerThanks!#2021-09-1816:05johnCool, thanks @thheller#2021-09-1819:54Takis_Hello, i am using shadow-cljs to make a node module my code works when  `:target :node-script` and it was working also before somedays with `:target :npm-module`  (i dont know what changed and now doesn't work) now i get `cljs$core$ExceptionInfo [Error]: Promise error`  `cause: MongoServerSelectionError: cljs is not defined`  when i try to use  `:target :npm-module`  anyone knows what might caused this `cljs is not defined` ?#2021-09-1820:03borkdudeI think I've heard thheller say that npm-module isn't very well maintained#2021-09-1820:03Takis_it was working before some days, i dont know what i might did#2021-09-1820:04borkdudeah ok#2021-09-1820:46Takis_borkdude i used :node-library and it is working fine, thank you for you help 🙂 i was stuck like 4 hours or more , we didnt find why it didn't work, but now all seem fine#2021-09-1820:48borkdude@takis_ nice! you can also use :target :esm for both browser and node now btw, but it's somewhat undocumented#2021-09-1820:48borkdudemore info on that here: https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-09-1820:50Takis_thank you i will read it : )#2021-09-1821:46thhellernpm-module is maintained just fine. it just has some fundamental issues that make it a bit hacky. cljs is not defined is not one of them but I can't say more without seeing actual code and config and how you use it. Don't know what the MongoServerSelectionError is about?#2021-09-1822:04Takis_i am so new in both cljs/node/shadow-cljs, but i will send you my code, dont know if it can help alot#2021-09-1822:04Takis_
(defn f1 []
  (go (let [mongodb (js/require "mongodb")
            MongoClient (.-MongoClient mongodb)
            _ (prn "Until here is ok")
            _ (prn MongoClient)
            client (<p! (.connect (MongoClient. "" (clj->js {"useUnifiedTopology" true}))))
            _ (prn "Will never be printed if :npm-library")

            ])))
(f1)
#2021-09-1822:05Takis_
Uncaught:
cljs$core$ExceptionInfo [Error]: Promise error
    at new cljs$core$ExceptionInfo (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.js:37699:10)
    at Function.cljs$core$IFn$_invoke$arity$3 (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.js:37760:9)
    at /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/queries/cljs.core.async.interop.js:32:84 {
  data: {
    meta: null,
    cnt: 1,
    arr: [ [Object], [Object] ],
    __hash: null,
    'cljs$lang$protocol_mask$partition0$': 16647951,
    'cljs$lang$protocol_mask$partition1$': 139268
  },
  cause: MongoServerSelectionError: cljs is not defined
      at Timeout._onTimeout (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/mongodb/lib/sdam/topology.js:310:38)
      at listOnTimeout (internal/timers.js:554:17)
      at processTimers (internal/timers.js:497:7) {
    reason: TopologyDescription {
      type: 'Unknown',
      servers: [Map],
      stale: false,
      compatible: true,
      heartbeatFrequencyMS: 10000,
      localThresholdMS: 15,
      logicalSessionTimeoutMinutes: undefined
    }
  },
  description: undefined,
  number: undefined,
  fileName: undefined,
  lineNumber: undefined,
  columnNumber: undefined
}
#2021-09-1822:05Takis_i sended here because it said as cause cljs is not defined#2021-09-1822:07Takis_before some days it worked with :npm-library now only works with :node-library and :node-script#2021-09-1822:08Takis_probably its my code or the way i did the compilation/used it from node, and its not related to cljs/shadow/mongo or the nodejs mongo driver#2021-09-1822:13Takis_
~/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp$ node
Welcome to Node.js v12.22.6.
Type ".help" for more information.
> var c=require("./queries/clojurescriptapp.core");
undefined
> "Until here is ok"
#object[MongoClient]
Uncaught:.....the above error........
#2021-09-1822:29thhellerwhy is this mongodb (js/require "mongodb") in a go block? none of this should be a in a go block#2021-09-1822:30Takis_i didnt had them there, i just moved them there after the problem#2021-09-1822:31thhellergo in general makes everything 1000x harder to debug, so avoid it if you can#2021-09-1822:32thhellerbut what is your intention with :npm-module in the first place? why do you want to use it?#2021-09-1822:32Takis_i just want a node-app to call my clojurescript code#2021-09-1822:33Takis_
:builds {:library {:target :npm-module
                    :output-dir "./queries"
                    :compiler-options {:infer-externs true}
                    :entries [clojurescriptapp.core]}
                    
          :library2 {:target :node-library
                     :output-to "dist/index.js"
                     :exports {:f1 clojurescriptapp.core/f1}}          
 
          :app {:target :node-script
                :output-to "target/main.js"
                :source-map true
                :main clojurescriptapp.core/main
                :compiler-options {:infer-externs true}
                
                :devtools {:repl-init-ns clojurescriptapp.core
                           :repl-pprint true}
                }}
#2021-09-1822:33thhellerfor that :node-library is recommended#2021-09-1822:34Takis_ok good, it works also, thank you for you time and shadow, i am so new but helped me already alot#2021-09-1822:34Takis_if i read more i will re-try it in the future#2021-09-1822:35thhellerwhich shadow-cljs version do you use? which clojurescript and closure-library versions? do you use deps.edn or project.clj or just plain shadow-cljs.edn with no extra tools?#2021-09-1822:35Takis_
{
  "name": "clojurescriptapp",
  "version": "0.1.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch": "shadow-cljs watch app",
    "compile": "shadow-cljs compile app",
    "build": "shadow-cljs release app"
  },
  "keywords": [],
  "author": "takis",
  "license": "MIT",
  "devDependencies": {
    "shadow-cljs": "^2.10.12",
    "source-map-support": "^0.5.19",
    "ws": "^7.3.0",
    "mongodb": "4.0.0"
  }
}
#2021-09-1822:36Takis_thats my package.json#2021-09-1822:36thhellerthat doesn't tell me which version you use. I mean its a version range but 2.10 is ancient history by now#2021-09-1822:37thhellerdo you have :deps or :lein in shadow-cljs.edn?#2021-09-1822:37Takis_shadow-cljs.edn only#2021-09-1822:37thhellershadow-cljs info will tell you the version#2021-09-1822:37Takis_
{:source-paths ["src"]
 :dependencies [[cmql "0.1.0-SNAPSHOT"]
                [cmql-js "0.1.0-SNAPSHOT"]]
 :builds {:library {:target :npm-module
                    :output-dir "./queries"
                    :compiler-options {:infer-externs true}
                    :entries [clojurescriptapp.core]}
                    
          :library2 {:target :node-library
                     :output-to "dist/index.js"
                     :exports {:f1 clojurescriptapp.core/f1}}          
 
          :app {:target :node-script
                :output-to "target/main.js"
                :source-map true
                :main clojurescriptapp.core/main
                :compiler-options {:infer-externs true}
                
                :devtools {:repl-init-ns clojurescriptapp.core
                           :repl-pprint true}
                }}}
#2021-09-1822:37Takis_this is all my shadow-cljs.edn#2021-09-1822:38Takis_
shadow-cljs info
shadow-cljs - config: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/shadow-cljs.edn
=== Version
jar:            2.15.9
cli:            2.15.9
deps:           1.3.2
config-version: 2.15.9

=== Paths
cli:     /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/shadow-cljs/cli/dist.js
config:  /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/shadow-cljs.edn
project: /home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp
cache:   .shadow-cljs
#2021-09-1822:38thhellerok thats all fine#2021-09-1822:40Takis_thank you for your time, i will update read more of the user-guide and i will retry it, probably i did something wrong, but node-library works and you said its the right way , so all works#2021-09-1822:40thhellerFWIW the code without go would be something like
(ns whatever
  (:require ["mongodb" :as mdb]))

(defn f1 []
  (-> (mdb/MongoClient. "" #js {:useUnifiedTopology true})
      (.connect)
      (.then (fn []
               (prn [:mongodb-connected])
               ))))
#2021-09-1822:41thhellerI don't know about the error otherwise#2021-09-1822:44Takis_
~/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp$ node
Welcome to Node.js v12.22.6.
Type ".help" for more information.
> var c=require("./queries/clojurescriptapp.core");
undefined
> c.f1();
Promise { <pending> }
> (node:8986) UnhandledPromiseRejectionWarning: MongoServerSelectionError: cljs is not defined
    at Timeout._onTimeout (/home/white/IdeaProjects/cmql-projects/nodeapp/clojurescriptapp/node_modules/mongodb/lib/sdam/topology.js:310:38)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
(node:8986) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 1)
(node:8986) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#2021-09-1822:46thhelleryeah no clue#2021-09-1822:47Takis_thank you for you time, because its possible that i done many things wrong, if i know more in the future i will re-try it#2021-09-1909:42huygnhttps://twitter.com/youyuxi/status/1439310638451466243?s=20 interesting, now we have choices between React Native & Flutter clojure-spin#2021-09-2008:39p-himikStarted experimenting with Material UI 5.0.0 because of https://clojurians.slack.com/archives/C0620C0C8/p1632106518085200 An obvious approach leads to errors like TypeError: _system.keyframes is not a function. The relevant file has var _system = require("@mui/system"); but _system itself is... 0. What would be the right way to fix it?#2021-09-2008:40p-himikOh, huh... Setting :output-feature-set :es5 works. But :output-feature-set :es6 doesn't.#2021-09-2021:36p-himikAnother user with what seems to be the same exact problem: https://clojurians.slack.com/archives/C03S1L9DN/p1632171762320700#2021-09-2100:16Oliver GeorgeNewbie question. I want to do some interactive development so I'm running shadow-cljs watch server app but I think I want to turn off hot reloading because I'm setting local vars to aid debugging and they are lost when the namespace reloads.#2021-09-2100:17Oliver George(I'm using comments in the namespace to prepare sexprs to send to the repl)#2021-09-2100:17Oliver GeorgeI can see that I could add metadata to the namespace to say "hands off" but is there a way to tell the file watcher to stop watching.#2021-09-2100:18Oliver GeorgeI tried shadow-cljs compile server app but it wasn't happy.#2021-09-2100:18Fredrik Anderssonput the local vars in a defonce atom#2021-09-2100:18Oliver GeorgeCan you stop the watcher?#2021-09-2100:18Fredrik Anderssonyou don't need to if you put the vars in a defonce#2021-09-2100:18Fredrik Anderssonin a atom#2021-09-2100:19Oliver GeorgeThat's not particuarly convienient for what I'm doing#2021-09-2100:19Fredrik Anderssonlike (defonce my-locals (atom { })#2021-09-2100:19Oliver Georgee.g. set db var then execute part of an existing fn which exects a local var#2021-09-2100:19Oliver GeorgeI see it would work as a workaround though. Thanks.#2021-09-2100:19Fredrik Anderssonim not sure why it's a work around#2021-09-2100:20Fredrik Anderssonthat IS the way as far as I understand#2021-09-2100:20Fredrik Anderssonso that you can keep the repl alive#2021-09-2100:21Oliver GeorgeOkay, thanks. I'll give that a try. (also ^:dev/once will get me where I want to go)#2021-09-2100:21Oliver GeorgeJust curious for the repl command. There was one for figwheel called stop-autobuild.#2021-09-2100:22Fredrik Anderssonyes, but why would you want to turn it off? thats basically clojure killer feature#2021-09-2100:22Fredrik Anderssonisolate your state to a an atom#2021-09-2100:22Oliver GeorgeOkay, thanks.#2021-09-2100:23Fredrik Anderssonnp, I'm new to clojure too#2021-09-2100:23Fredrik Anderssonjust created a simple textfile parser, no state 😄#2021-09-2100:24Fredrik Anderssonwonderful stuff#2021-09-2100:24Fredrik Anderssonoff to bed!#2021-09-2100:25Oliver George🙂#2021-09-2100:25Oliver Georgewait till you play with instaparse... you'll feel like a god!#2021-09-2105:42thheller@olivergeorge there is (shadow.cljs.devtools.api/watch-set-autobuild! :the-build-id false) to stop the automatic rebuild or you can set :devtools {:autoload false} in your build config to still run the automatic watch rebuild but not automatically load it#2021-09-2105:43thhelleryou can also start the watch from the CLJ REPL with (shadow.cljs.devtools.api/watch :the-build-id {:autobuild false})#2021-09-2106:13Oliver GeorgeThanks 🙂#2021-09-2120:17Michaël SalihiHi @thheller, I remember a discussion about a Shadow-cljs build-hook for parse/write in index.html I think. Can you refresh my memory about the name please?#2021-09-2120:18thhellerhttps://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L147-L149?#2021-09-2120:37Michaël SalihiGreat, thanks!#2021-09-2123:39BenjaminIs there anything special you need to do to get shadow-cljs to work with a https://stackoverflow.com/questions/14381898/local-dependency-in-package-json/14387210#14387210? I've checked the project directory after installing the local package, and it created a symlink under npm_modules to the local module on my disk.#2021-09-2123:40BenjaminBut when I try to require the file, it says the required JS dependency is not available .#2021-09-2200:10BenjaminI think I figured out what the problem was, seems that it was a monorepo on the top level and the package I had to link to was under a packages directory#2021-09-2208:33Michaël SalihiHi, when releasing an app using eternal-index js-options, I had this warning:
[:app] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: shadow.js.shim.module$react_dom.js:3:34
 variable shadow$bridge is undeclared
#2021-09-2208:34Michaël SalihiAny clue?#2021-09-2208:41thhellerhmm did I not add that to the externs? could have sworn I did. which version do you use?#2021-09-2208:44Michaël SalihiVersion 2.15.10#2021-09-2208:55thhellershould be fine. open an issue if you can reproduce it. can't check right now#2021-09-2209:13Michaël SalihiOK, I wiil. Thanks#2021-09-2215:26Raymond KoHas anyone gotten build reports to work recently? I'm trying but it's failing with:
failed to run function: shadow.cljs.build-report/-main
{:tag :shadow.cljs.devtools.cli-actual/clj-run, :main-sym shadow.cljs.build-report/-main}
ExceptionInfo: failed to run function: shadow.cljs.build-report/-main
        shadow.cljs.devtools.cli-actual/do-clj-run (cli_actual.clj:110)
        ...
Caused by:
Hook [0 shadow.cljs.build-report/hook] failed in stage :flush
NoSuchFileException: .shadow-cljs/release-snapshots/my-build/latest/main.js
I am not sure where main.js is coming from...
#2021-09-2215:56Raymond KoOkay, I figure it out. Build reports assumes the output file is named after the thing in :modulesbut if you use :output-to then it gets named something completely different.#2021-09-2215:57Raymond Koshadow-cljs can't find the output.#2021-09-2216:59thhellerbuild reports currently only support the :browser target#2021-09-2216:59thhellersize of node libraries usually isn't an issue#2021-09-2217:16Raymond KoThanks, I somehow got it to work by changing output to "main.js". I was using this for AWS Lambda and trying to figure out cold boot time, where size does have a impact.#2021-09-2215:29Raymond KoCould this be because I am trying to make a :node-library and it is missing :modules {:main {}} ?#2021-09-2215:34StuartHi, I'm trying to run shadow-cljs watch app . I'm using WSL on windows via VS Code. This project I'm trying to run works perfectly on my Ubuntu machine. But when I try to run watch app on WSL I'm getting the following error:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "502324253122242310287d3c31207d656662"}, :content ("[email protected]")}
Any ideas what I'm doing wrong. My shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
           ["src/dev"
            "src/main"
            "src/test"]

 :dependencies
           [[binaryage/devtools "0.9.10"]
            [reagent "1.0.0"]
            [re-frame "1.2.0"]
            [day8.re-frame/re-frame-10x "1.0.1"]
            [day8.re-frame/http-fx "0.2.3"]
            [bidi "2.1.6"]
            [cljs-ajax "0.8.1"]
            [com.andrewmcveigh/cljs-time "0.5.2"]
            [com.rpl/specter "1.1.3"]]

 :nrepl    {:port 3333}
 :dev-http {8080 "public"}
 :builds   {:app {:target           :browser
                  :output-dir       "public/js"
                  :modules          {:main {:init-fn }}
                  :compiler-options {:closure-defines {re-frame.trace/trace-enabled?        true
                                                       day8.re-frame.tracing/trace-enabled? true}}
                  :devtools {:http-root "public"
                             :http-port 3000
                             :preloads [day8.re-frame-10x.preload]}}}}
#2021-09-2215:35StuartIve installed node on wsl, it reports its version as
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "f88b8c8d998a8c8bb880d5949988d5cdceca"}, :content ("[email protected]")}
#2021-09-2215:39Raymond KoCould it as simple as missing the transit dependency?
[com.cognitect/transit-cljs "0.8.269"]
[com.cognitect/transit-clj "1.0.324"]
#2021-09-2215:42Stuartadd these to my shadow deps edn?#2021-09-2215:42Raymond KoWhat happens if you add the above two lines to :dependencies?#2021-09-2215:43StuartAdded those, saved the file, ran shadow-cljs watch app again and got same error
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "daa9aeafbba8aea99aa2f7b6bbaaf7efece8"}, :content ("[email protected]")}
#2021-09-2215:43Stuartit looks like its ignoring the lines I added ?#2021-09-2215:54Raymond KoHmm. I don't have any immediately ideas. • Maybe there is some global deps.edn modifying version. • Try npm install shadow-cljs and ./node_modules/bin/shadow-cljs to use latest version • Does moving the project into the Linux FS instead of /mnt/c work?#2021-09-2215:54StuartTHanks anyway for your help, its appreciated 🙂#2021-09-2215:55Raymond KoDoes shadow-cljs classpath show anything wrong?#2021-09-2215:56Stuartit doesnt generate any errors#2021-09-2215:57Stuarthttps://gist.github.com/stuartstein777/3855d08f91e9229f96d99c47028ee921#2021-09-2216:00Raymond KoThe next I would try is to upgrade shadow-cljs. According to the log, you are using version 2.11.22, which seems a bit old compared to current being https://clojars.org/thheller/shadow-cljs/versions/2.15.10#2021-09-2216:01Raymond KoLike personally I do what said above and use the one from npm install and node_modules to ensure that the tool is version controlled and always up to date when I use npm-check-upgrades#2021-09-2216:01Raymond KoI would uninstall the global one.#2021-09-2216:02Stuartah ok, I'll try that#2021-09-2216:04Stuartdo you mean install it like in here: https://shadow-cljs.github.io/docs/UsersGuide.html#_standalone_via_code_npm_code ?#2021-09-2216:09Raymond KoSomething like that yeah. 1. Create a package.json if you don't already have it npm init and put in whatever. 2. npm install --save-dev shadow-cljs 3. ./node_modules/.bin/shadow-cljs watch app#2021-09-2215:35dpsuttonwhat is the error in /tmp/clojure-11163815081130707132.edn?#2021-09-2215:38Stuarthttps://gist.github.com/stuarts-exmos/260f99151ea58fc4c4f837d8d9bfcbc6#2021-09-2215:38StuartI'm afraid I don't know what a lot of that means#2021-09-2215:37Stuartsticking it in a gist, 2 secs#2021-09-2215:39Apple
:clojure.error/class java.lang.NoClassDefFoundError,
  :clojure.error/line -2,
  :clojure.error/cause  "Could not initialize class cognitect.transit__init",
#2021-09-2215:41StuartI did npm install and it says its all up-to-date#2021-09-2215:41Stuart
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "84f7f0f1e5f6f0f7c4fca9e8e5f4a9b1b2b6"}, :content ("[email protected]")}
#2021-09-2218:07thheller@qmstuart I don't know why you'd get that error. can you try setting :aot false in your shadow-cljs.edn config? same level as :source-paths#2021-09-2308:40StuartWell, I have some progress. Ive reinstalled clojure, reinstalled node, reinstalled shadow-cljs, tried :aot false, but now I'm getting a different error.
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "d0a3a4a5b1a2a4a390a8fdbcb1a0fde5e6e2"}, :content ("[email protected]")}
#2021-09-2308:47kommenwhen watching a build using a :resolve with :target :file in the :js-options, the changes to the specified file doesn’t trigger a re-compile. is this expected?#2021-09-2316:08kommennevermind, using https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js now instead which does the trick#2021-09-2314:09Raymond Koextreme long shot, but what happens if the directories don't have underscores.#2021-09-2316:52Stuartthink im just going to accept i can't do cljs on this machine#2021-09-2316:52Stuarti can still regular clojure, start repls etc#2021-09-2317:02thheller@qmstuart how are you starting those? you can just use shadow-cljs with deps.edn or project.clj. Although I'd be interested in figuring out what the problem is. Don't have an immediate guess. I'm on Windows and WSL myself so I know it works just fine.#2021-09-2317:42StuartThank you so much! Deleting the repositories and rerunning seems to have fixed it. I think whats happened is my internet connection here is absymal (<100kbps) and maybe some stuff has failed to download initially!#2021-09-2317:45thhellerah yeah that can happen#2021-09-2317:06thhellertry wiping your ~/.m2/repositories dir. maybe there is something weird going on there. It'll just download all the files again#2021-09-2317:37sheluchin#2021-09-2317:37sheluchinI'm upgrading some of my deps, shadow-cljs included, and I'm getting some new errors when connecting my editor to the repl.#2021-09-2317:39thhelleryour editor seems to be sending something weird? "(in-ns ':repl/exception!)" that doesn't look right#2021-09-2317:51sheluchinI can't find where that's coming from, but after clearing some caches and restarting things, I can't seem to reproduce the error. Thanks for looking.#2021-09-2407:03Michaël SalihiBefore start to writing a script, is Shadow-cljs manage to clean up the output directory (remove all cljs-runtime, etc) after releasing an app?#2021-09-2407:17thhelleryou mean like rm -rf public/js? no it does not#2021-09-2407:34Michaël SalihiNot really. I mean when releasing process run, is there already an option to remove production useless files/directories like cljs-runtime before deploying. This dir size is over 60Mb for my project.#2021-09-2407:35Michaël SalihiIn public/js/cljs-runtime#2021-09-2407:35thhellerI just run rm and then shadow-cljs release app#2021-09-2407:35Michaël SalihiI think I saw a few things going on about this a while ago.#2021-09-2407:36thhellerrimraf from npm is also useful. shadow-cljs itself does not have anything to delete stuff#2021-09-2407:36thhellersure you can write a hook if you really must do that from within shadow-cljs but I don't see the point personally so there is nothing#2021-09-2407:37Michaël SalihiYeah write a hook would be overkill. 🙂 Thanks#2021-09-2409:35ishodgeis it possible to use d3-graphviz with shadow, and if so would that require any additional configuration for compiling wasm? i’m getting an error that localhost:8080/js/graphvizlib.wasm is not found, and further warnings that wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type 'text/plain' expected 'application/wasm' and falling back to ArrayBuffer instantiation .#2021-09-2414:40thhellershadow-cljs does not support compiling or bundling wasm. something its enough to manually copy the wasm file to some location though#2021-09-2414:40thhellercan't say for that lib. don't know what it looks like#2021-09-2414:52ishodgei see, thanks!#2021-09-2413:25metehanshadow-cljs can't find the namespace I put all info together. any idea what may cause the problem? (message was long moved to thread)#2021-09-2413:30metehan
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "4a380a3a253a672539"}, :content ("[email protected]")}
#2021-09-2414:05thhellerread https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2021-09-2414:05thhelleryour :source-paths needs to be adjusted#2021-09-2414:57metehanthank you it's solved#2021-09-2416:32myguidingstarany tips to migrate away from :libs (aka Google closure style ns) to shadow-cljs?#2021-09-2418:03thhellerjust put it into your classpath and use it?#2021-09-2418:04thhellerif you named everything correctly it just works without additional config#2021-09-2507:29myguidingstaroh really? thanks. Anyway, I wonder why clojurescript compiler has to create such :libs option#2021-09-2507:30thhellercan you give an example of :libs? I don't really know what that does?#2021-09-2507:31thhellerclosure style namespaces should just work with regular cljs too provided that the names match and stuff#2021-09-2507:31thhellermaybe libs allows files that don't match the expected names? don't know#2021-09-2706:47edbondI'm trying to use MUI (https://mui.com/getting-started/usage/) and reagent and getting error in browser console: shadow-cljs - failed to load – "module$node_modules$$mui$material$node$ButtonBase$TouchRipple"#2021-09-2706:49edbondHere are my files https://gist.github.com/edbond/50c3849320dc63c43ae7f6d68c0f1148#2021-09-2709:44Ben Haltonhave you tried setting your compiler options in shadow-cljs.edn to :compiler-options {:output-feature-set :es5}#2021-09-2709:44Ben Haltonthis sorted it for me#2021-09-2715:52edbond@U2BU6P81K Thank you Ben! Now I have a different errors. Will try to solve them 🙂#2021-09-2715:54edbondSolved. The require was wrong, correct is ["@mui/material/Button" :default Button] . Thanks again!#2021-09-2718:00Ben Halton:thumbsup::skin-tone-2:#2021-09-2708:48pezIs there a way I can configure deps.edn :main-opts such that it both calls a clj function in my project and start Shadow watching?#2021-09-2708:53pezContext: I am porting a rather fresh Luminus project from Leiningen to tools/deps. With the leiningen project this in at the top level of project.clj, started my apps web server, and shadow still started watching:
:main ^:skip-aot sandbox.flag-yard.core
I’m failing to replicate this behaviour using deps.edn.
#2021-09-2708:57pezWait, now I think I managed to do it. I put the :main-opts at the root level…#2021-09-2710:24pezIf I have a shadow-cljs project, A, that depends on another shadow-cljs project, B. Configured in Project A:s deps.edn like so:
:deps {b/b {:local/root "<path-to-b>"}
Where B has an npm dependency on something-something. How can I make shadow-cljs in project A look in project B for the dependency? Right now shadow complaints:
The required JS dependency "something-something" is not available, it was required by "B/some_file.cljs".
#2021-09-2711:28pezSolution:
:js-options {:js-package-dirs ["node_modules" "<path-to-b>/node_modules"]}
#2021-09-2717:15thhellernot the solution. your b should have a deps.cljs declaring :npm-deps#2021-09-2718:15pezThanks, I'll change. (Though my ”solution” works 😀)#2021-09-2806:24pezWill shadow download the dependency? Or should it go both in package.json and :npm-deps?#2021-09-2806:25thhellerdeps.cljs is the mechanism to have shadow-cljs automatically install missing packages#2021-09-2806:26thhellershadow-cljs never looks at the package.json of your project otherwise and absolutely never of your CLJS dependencies#2021-09-2806:27thhellerso to get your dependencies from B to A you need a deps.cljs with :npm-deps. nothing else is relevant for that#2021-09-2806:32pezIs this actually relevant regardless if I have an interproject dependency?#2021-09-2806:32thhellerrelevant for what?#2021-09-2806:33thhellerI'm assuming here that your that b/b has a npm dependency that your main project does not have#2021-09-2806:33thhellerso to get it from b/b to your main project you need deps.cljs#2021-09-2806:33thhellerOR use :js-package-dirs but that has other issues#2021-09-2806:34thhelleryour main project does not need a deps.cljs and should manage its dependencies directly via package.json#2021-09-2806:35pezYes, I mean if I have a project that is not dependent on some other shadow-cljs project. Just project A, if you like. Should project A declare its npm deps in shadow-cljs.end rather than … ah, now you beat me to it. Thanks!#2021-09-2806:41thhellerplease differentiate between project and library. any library, aka. used in other places must declare via deps.cljs#2021-09-2806:41thhellerany end product aka. project doesn't#2021-09-2807:08pezThanks for the clarifications! I think it is a bit extra messy in the codebase I’m dealing with right now, where some projects are used as libraries to other projects. We’re about to clean that up, and my project B in the thread start is a new library I’m building so I’m using :npm-deps there now.#2021-09-2807:15thhellerwell yeah any library can be a project too. I just mean that when you use something as a library you need deps.cljs#2021-09-2809:19pezSo, removing the :js-package-dirs from project A, and having this in b/deps.edn:
{:paths ["src"]
 :npm-deps {"something-something" "X.X.X"}}
Also removing package.json and node_modules from B. Then restart shadow, reload the app and try to evaluate a namespace that requires "something-something". I get that error back:
The required JS dependency "something-something" is not available, it was required by "B/some_file.cljs".
Either i have misconfigured something, or misunderstood something (or both).
#2021-09-2809:23pezAh, sorry. misconfigurations indeed. I should of course declare those in shadow’s config.. facepalm#2021-09-2809:49pezNo, I still can’t get it to work. I now have: a/deps.edn
{:deps {...
        b/b {:local/root "../projects/b"}
 ...}
b/deps.edn
{:paths ["src"]}
b/src/deps.cljs
{:npm-deps {"something-something" "X.X.X"}}
Still getting that error message when connecting to a’s REPL and loading a file that requires in the thing on b that needs the npm thing. Does shadow want something more? (There’s no shadow-cljs.edn in b, for example.)
#2021-09-2810:15pezHmmm, it seems to have to do with how project A is wired. It is not started using the shadow-cljs command, but like so:
:main-opts ["-m" "shadow.cljs.devtools.cli" "watch" "foo"]
When I started it using shadow-cljs the download of the npm thing happened. But a lot of other things do not happen, so I can’t really go this way. Is :js-package-dir what I should turn to anyway, you think?
#2021-09-2817:33thheller> But a lot of other things do not happen#2021-09-2817:33thhellerwhat does that mean? what else is there?#2021-09-2817:34thhellerusing :js-package-dirs is totally fine, just more prone to potential dependenciy version conflicts#2021-09-2817:35pezOh, (about the things that do not happen) just that the project so far depends on being started the way it is, so I can't really switch it to start using shadow directly. #2021-09-2817:37pezI might make another try with using npm-deps proper. There were a few variables I didn't keep fixed during my latest testing. #2021-09-2817:37thhellertotally fine to start shadow-cljs that way#2021-09-2817:38thhellerthe shadow-cljs npm command is just for convenience, it provides no other actual functionality#2021-09-2817:38thhellerpure deps.edn is fine#2021-09-2817:40pezI should be able to make it work, I take it. #2021-09-2817:41pezDoes npm-deps make shadow-cljs update project A's package-json?#2021-09-2817:41thhelleryes, well shadow-cljs runs npm install for those packages and that in turn modifies your package.json. shadow-cljs itself does not modify it directly#2021-09-2715:17Drew VerleeMy goal is to get a running repl on this project and so i added shadow-cljs 1. add shadow-cljs.edn
{:deps true
 :dev-http {8000 "public"}
 :builds {:app {:target :browser
                :output-dr "public/js"
                :asset-path "js"
                :modules {:main {:entries [re-frame-routing.core]}}}}}
and commented out clojurescrript in the deps (otherwise it through an error, but i'm not sure why). 2. added a public/index.html file 3. ran cider-jack-in-cljs shadow > :app (build) > start browser this starts a repl, but it doesn't seem to send expressions to it.
#2021-09-2715:25Drew Verleei probably need to watch the shadow files and run the compiled js files.#2021-09-2715:38Drew Verleenever mind, i seem to want to use the browser-repl.#2021-09-2717:15thhelleryeah browser-repl or node-repl depending on what you need#2021-09-2717:16thhellerbut app build should be fine too. no clue what commands cider-jack-in-cljs runs so I can only say that you do need a running watch fore the REPL to work#2021-09-2717:16thhellerwhat else cider does no clue#2021-09-2715:24piphello! i want to configure shadowcljs to use a webpack plugin to convert sass to less but i also currently have the lein-sass plugin installed. any thoughts on how these interact? sorry if this is a nooby question, just trying to understand how they would work together#2021-09-3013:47kennytilton"i want to configure shadowcljs to use a webpack plugin to convert sass to less but i also currently have the lein-sass plugin installed." Software development in the twenty-first century! 🤯 Anyone old enough to remember when we just wrote code, compiled, linked, and ran? sigh#2021-09-2717:17thheller@lpanda2014 shadow-cljs does not use webpack by default so there is no place to configure webpack plugins. what kind of setup do you have?#2021-09-2717:28pipwe are using babel and want to use antd but don’t want to use less — we have lein-sassc from using the luminus template#2021-09-2717:29thhellerthat still doesn't tell me anything about your setup#2021-09-2717:30thhellerwhat is your shadow-cljs build config?#2021-09-2719:43Joe DouglasHello, I'm writing some cljs tests targeting node and would like to have the tests run when I make changes to my files. I've tried the following:
:test
  {:target :node-test
   :output-to "target/node-test"
   :autorun true}
And then running shadow-cljs watch test , the build completes, but it doesn't seem to run the tests. Any tips?
#2021-09-2720:15Ryan Jeruehttps://shadow-cljs.github.io/docs/UsersGuide.html#_the_build specifically see the karma.conf.js and the attached screenshot#2021-09-2720:19Joe DouglasThanks for the reply! I'm not familiar with Karma, but it looks like a lot of setup for what I'm looking to do. I just want to speed up my local development loop running pure node.js tests, no browsers involved or anything.#2021-09-2720:49Ryan JerueIn that case:
node out/node-tests.js
#2021-09-2720:50Ryan Jeruenode-test should do that, sorry on the karma brainfart haha#2021-09-2805:47thheller@USRHVLXTQ it should run the tests but :output-to is supposed to be a file not a directory. so its missing the .js at least. it might fail to run because of that maybe?#2021-10-0408:20Joe DouglasAh ok, I'll check that out, thanks a million to you both for the assist!#2021-09-2721:37tianshuLooks like shadow-cljs can't infer target type with clojure.core.async.interop/<p!` and (.foo bar) . This will happen in code like this:
(defn run []
  (go
    (let [conn (Connection. host)
          market (<p! (.load Market conn market-addr #js {} serum-program-addr))
          bids (<p! (.loadBids market conn))
          asks (<p! (.loadAsks market conn))])))
#2021-09-2805:46thhellernot much I can do in shadow-cljs. core.async go loses all typehint info so the cljs.compiler cannot infer anything. I'd suggest keeping interop code out go loops entirely. can be a little bit annoying but (defn load-bids [^js market conn] (.loaderBids market conn)) and then just (<p! (load-bids market conn)) will not have any typehint issues#2021-09-2805:46thhelleror just don't use go in the first place 😛#2021-09-2814:23tianshuthank you, currently I'm using your suggestion, it works well.#2021-09-2721:38tianshuType hint won't work in this case, no matter wherever I add it.#2021-09-2721:42tianshuThe problem looks like I can't say what <p! returns is a javascript object by adding type hint.#2021-09-2802:15zhuxun2Is setting :compiler-options {:output-feature-set :es5} the only way to use MUI 5+? I need to use @mui/x-data-grid which when compiled to ES5, gives this error:
[:main] Build failure:
Closure compilation failed with 1 errors
--- node_modules/@mui/x-data-grid/index-cjs.js:3
Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.
#2021-09-2802:16zhuxun2However, setting :compiler-options {:output-feature-set :es2018} gives another error as @gingerwizard was talking about:
shadow-cljs - failed to load – "module$node_modules$$mui$material$node$ButtonBase$TouchRipple"
#2021-09-2802:32zhuxun2A few others seem to have run into the same problem @p-himik @luciano etc. Their only solution seem to be setting :output-feature-set :es5.#2021-09-2802:33zhuxun2Has anyone figured out the root cause for it? Why does setting :output-feature-set fix it?#2021-09-2803:35xlfeWhat's going on is mui-5 is now using esm modules I think - see https://github.com/MrEbbinghaus/mui5-shadow-cljs-issue-repro/issues/1#2021-09-2803:37xlfethe fix is to add the :js-options flag as suggested https://shadow-cljs.github.io/docs/UsersGuide.html#js-entry-keys#2021-09-2811:40FiVoIs there a way to load dependencies without restarting the repl? I am using deps.edn.#2021-09-2813:59arohnershadow.build.test-util/find-test-namespaces calls cp/find-cljs-namespaces-in-files. I’m trying to use shadow with bazel, which strongly prefers JVM code to be distributed as jars rather than files, so I would like that to search through the proper classpath, rather than directories. Would you accept a PR that switches that to use tools.namespace to search through files and jars?#2021-09-2904:33thheller@arohner it is not supposed to find tests in jar files. otherwise it'll also start testing code from libs that accidentally bundled their tests, not all too common but does happen. why does bazel all of the sudden need .jar files? the last time I talked to someone about bazel it needed files and even extracted regular .jar files?#2021-09-2904:34thhellerdefinitely no on the tools.namespace. you can always create a namespace that requires all your tests and use :entries [that.collect-ns] or just :entries [my.foo-test my.bar-test]#2021-09-2904:35thhelleror use a script or something to generate that.collect-ns for you. just needs to be (ns that.collect-ns (:require my.foo-test my.bar-test)) etc#2021-09-2904:54Chris McCormickIs there an equivalent of checkouts from lein when using shadow-cljs? My use case is that I am developing a library on my local that I will eventually put into clojars and I have a few projects that are consuming the same library. At the moment I am using symlinks from the src directory but I wonder if there is a better way?#2021-09-2904:55thhellerwith pure shadow-cljs.edn currently no. deps.edn or lein work as normal#2021-09-2905:07Chris McCormicki can make it work with a deps.edn in the lib and no lein?#2021-09-2905:12thhellerif you use deps.edn in your project too sure, just the normal :local/root setup#2021-09-2912:58Franklinhey @thheller I'm having trouble using an npm package#2021-09-2912:58Franklin
shared.js:1552 TypeError: Super expression must either be null or a function, not undefined
    at _inherits (control.js:26)
    at eval (control.js:50)
    at Object.shadow$provide.module$node_modules$react_leaflet_control$dist$control (control.js:49)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at eval (quagga.components.dataview.map.view.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (shared.js:486)
    at Object.env.evalLoad (shared.js:1549)
    at tabbed-dataview.js:250
#2021-09-2912:59Franklinthe require looks like this
["react-leaflet-control" :default Control]
#2021-09-2912:59Franklinthe package https://github.com/LiveBy/react-leaflet-control#2021-09-2912:59Franklinmy code looks something like this
[:<>
     [:> TileLayer {:url "https://{s}.}]
     [:> ZoomControl {:position "bottomleft"}]
     [:> Control [:button "click me"]]
     [:> FeatureGroup
      (map
        (fn [position] [:> Marker
                        {:position position,
                         :key position,
                         :eventHandlers {:click (fn [e]
                                                  (js/console.log
                                                    (-> e
                                                        .-target
                                                        .-_latlng)))}}])
        geopoint-positions)]]
#2021-09-2913:00FranklinI'm starting to think it's something that's wrong with the package that's the cause for this; maybe it's not compatible with shadow-cljs?#2021-09-2914:39Sainadh@USWTQB9RU I think the components TileLayer, ZoomControl etc need to be inside a Map component. For Example: This worked for me
(ns example.views
  (:require
   ["react-leaflet-control" :default Control]
   ["react-leaflet" :refer [Map TileLayer ZoomControl]]

(defn main-panel [style]
  [:div {:style style}
    [:> Map {:center [51.3 0.7] :zoom 10}
     [:> ZoomControl {:position "topright"}]
     [:> TileLayer {:url "http://{s}."
                    :maxZoom 18}]
     [:> Control {:position "topleft"}
       [:button "click me"]
       "Reset View"]]])
this is from https://www.npmjs.com/package/react-leaflet-control I ported the example to cljs
#2021-09-2914:54Franklinthanks @U02806HQX1C 🙂 . I actually did put them them inside a MapContainer component that wraps the component I pasted up here ☝️ . On the other hand, I later also found a workaround where I don't need to use this library. but I still am curious as to why I get the above error#2021-09-2915:09SainadhCool. I got similar error when I used the Control component in isolation. So, I thought that might be the issue.#2021-09-2914:21SainadhHi @thheller I am playing with the excellent rn-rf-shadow React Native project and facing issues with live reload The project structure is as below
;; app.cljs

(ns 
  (:require [example.events]
            [example.subs]
            [expo.root :as expo-root]
            ["react-native" :refer [View]]
            [example.screens.home :refer [home-screen]]))
  
(defn root []
  [:> View
   [home-screen]])

(defn start
  {:dev/after-load true}
  []
  (expo-root/render-root (r/as-element [root])))

 ...
;; screens/home.cljs
(ns example.screens.home
  (:require ["react-native" :refer [SafeAreaView Text]]
            [example.components.image :refer [image]]))            

(def clojure-image (js/require "../assets/images/clojure.png"))

(defn home-screen []
  [:> SafeAreaView
    [:> Text "Hello World"]
    [image clojure-image]
;; components/image.cljs
(ns example.components.image
  (:require ["react-native" :refer [Image View]]))

(defn image [user-image]
  [:> View {:style {:height 46
                    :width 46}
    [:> Image {:source user-image
               :style {:height 40
                       :width 40}}]])
Live reloading for any change I make in home.cljs or app.cljs is working perfectly fine. But isn’t working for changes in image.cljs I will have to do some dummy change in home.cljs everytime for the live reload to work. I see that this was already asked here https://github.com/thheller/shadow-cljs/issues/544, but the specified solution only works for children (imported) in app.cljs I tried ^:dev/always to app namespace like so (ns ^:dev/always ) and that doesn’t seem to work either. Is there any solution for this. Am I missing something ?
#2021-09-2915:36thhellerno clue what expo.root is so can't say#2021-09-2915:37SainadhIt would be this https://github.com/PEZ/rn-rf-shadow/blob/master/src/main/expo/root.cljs#2021-09-2915:43SainadhI’ve used [shadow.expo :as expo] from your reagent-expo example and the behaviour is same.
(ns 
  (:require [shadow.expo :as expo]
            [re-frame.core :as rf]
            ["react-native" :refer [View]]
            [reagent.core :as r]
            [example.screens.home :refer [home-screen]]))
  
(defn root []
  [:> View
   [home-screen]])

(defn start
  {:dev/after-load true}
  []
  (expo/render-root (r/as-element [root])))

(defn init []
  (rf/dispatch-sync [:initialize-db])
  (start))
#2021-09-2915:45SainadhSeems like an extension of this issue https://github.com/thheller/shadow-cljs/issues/544#issuecomment-521662073 Adding {:dev/after-load true} as suggested in the issue
;; app.cljs

(defn start
  {:dev/after-load true}
  []
  (expo/render-root (r/as-element [root {:x (js/Date.now)}]))) 
Only works for changes in imports (children) of app.cljs But don’t work for grandchildren. Strange that this doesn’t happen for web development and only for react-native
#2021-09-2915:58thhellerwell did you try the suggestion with using an extra variable?#2021-09-2915:58thhellerreact or reagent stop rendering if they encounter a component that hasn't changed#2021-09-2915:59thhelleryou can set :devtools {:reload-strategy :full} in your build config to reload many more files than it usually would#2021-09-2916:00thhellerslower overall but might fix you issue#2021-09-2916:00thhellerbut the issue is not with shadow-cljs. it is reagent/react deciding to stop to render#2021-09-2916:01thhellerie. when you only edit image.cljs then [root] didn't change. so reagent/react decide they can stop rendering completely and never get to the actual image which actually changed#2021-09-2916:10Sainadh> well did you try the suggestion with using an extra variable? You mean adding {:dev/after-load true} Yes I’ve tried this. Same behaviour.#2021-09-2916:10Sainadh> you can set `:devtools {:reload-strategy :full}` in your build config to reload many more files than it usually would This worked… 🙏#2021-09-2916:11thhellerI meant this [root {:x (js/Date.now)}]#2021-09-2916:11thhellerthe :dev/after-load just tells shadow-cljs which function to call after its done reloading code. you need that regardless#2021-09-2916:12thhellerthe :x would be the "hack" to force reagent/react to actually render the component and not skip it#2021-09-2916:15Sainadh> I meant this `[root {:x (js/Date.now)}]` Oh right. My bad, sorry :face_palm: This worked.#2021-09-2916:15Sainadhwithout the full reload strategy.#2021-09-2916:17SainadhThanks for your prompt response and for Shadow as well. 🙌#2021-09-2914:32Tiago Dall'Oca
➜  malli-ts git:(master) ✗ node 
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> let malli_ts = require('malli_ts.ts')
Uncaught TypeError: Cannot read property 'Error' of undefined
    at Object.<anonymous> (/home/tiago/Documents/side-projects/malli-ts/node_modules/goog.debug.error.js:38:29)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
#2021-09-2914:33Tiago Dall'OcaThe build config I'm using:
{:target :npm-module
 :output-dir "node_modules/"
 :entries [malli-ts.ts]}
#2021-09-2914:34Tiago Dall'OcaIt is compiling successfully but failing to import the module 😕#2021-09-2915:22winsomeI just spent some time tangling with cljs->node, you might try wrapping the output from the compiler in this UMD wrapper: https://groups.google.com/g/clojurescript/c/vNTGZht1XhE#2021-09-2915:23thheller@U4U6BDQTE which shadow-cljs version? this should be fixed in the latest?#2021-09-2915:24thheller@U028BUU1P3R that code is ancient history and not relevant anymore#2021-09-2915:24winsomegood to know 🙏#2021-09-2915:26thhellerFWIW prefer using :node-library over :npm-module when you can#2021-09-2915:28Tiago Dall'Ocaoh thanks!#2021-09-2915:28Tiago Dall'OcaI did switch to :node-library and it's working fine 🙂#2021-09-2922:30Ryan JerueIf I have npm modules that I am using via npm link is there any way to get shadow to hot reload them as the bundle for that linked package is updated?#2021-09-3005:09thhellershadow only watches package.json files for changes, so if you touch package.json it should update#2021-09-3015:59Ryan JerueThis worked, thank you so much! 🎉#2021-09-3004:42gdubsI'm stuck. I'm trying to bootstrap a little project and am having trouble in situations where my .cljs file requires a .js file which requires an npm module. See below for a ~10-line example.#2021-09-3004:43gdubsThe error says: Module not provided: shadow.js.shim.module$express, but I can confirm that that file is buried in my .shadow-cljs/... directory as I would expect.#2021-09-3005:12thhellerhmm which shadow-cljs version is this? something similar was fixed a rather long time ago?#2021-09-3005:12gdubsjust upgraded to the latest. Is the problem my use of require(...) as opposed to import?#2021-09-3005:16thhellerno, both should be ok#2021-09-3005:17thhellercan you open an issue about this? can't take a look right now#2021-09-3005:19gdubsyou bet#2021-09-3009:42Phillip Mateshi folks, I'm interested in doing a bit performance-related explorations of cljs code in various JS engines (V8, JSC, etc). The project I'd like to profile uses shadow-cljs. thus I'm wondering: Is there a way in shadow-cljs to compile to a single js file that doesn't make use of require, nor node.js-specific features like filesystem access? Such that I can run the code in the d8 or jsc javascript consoles?#2021-09-3009:44Phillip MatesI tried some of the different :target configurations with :optimizations set to simple but couldn't get anything rolling. I was able to find some benchmark code in the clojurescript repo that runs cljs stuff in d8 and jsc, so I know at some level this sort of thing is tenable#2021-09-3015:50thhellera :node-script release build should be ok in d8/jsc. either simple or advanced. watch or compile won't work#2021-09-3017:41Phillip MatesI'm giving it a shot now and getting > public/script.js:3420: ReferenceError: global is not defined and when I replace goog.global=global with goog.global=globalThis (not sure if that is correct though) then I get > public/script.js:4203: ReferenceError: require is not defined > ... > shadow.js.shim.module$react=require("react"); > ... I don't think d8 has require available 😕#2021-10-0117:56thhellerit does not but it'll also probably not have many other things if you plan on using react and stuff#2021-10-0117:56thhelleryou can set :js-options {:js-provider :shadow} in your build config. that'll make shadow-cljs bundle all dependencies so the result doesn't contain require anymore#2021-10-0117:56thhellermaybe thats enough#2021-10-0620:31Phillip MatesI gave it a try with a build entry like:
:alone
  {:target :browser
   :debug false
   :output-to "public/script.js"
   :main re-db.test/-main
   :js-options {:js-provider :shadow}
   :compiler-options {:optimizations :simple :pseudo-names true}
   :output-dir "public/bench/js"
   :modules {:bench {:entries [re-db.test]}}}
public/bench/js/bench.js:4428: TypeError: Cannot read properties of undefined (reading 'abs')
shadow.js.files[$i$jscomp$309_name$$],$moduleFn$$=shadow$provide[$i$jscomp$309_name$$];if(void 0===$module$$){if(void 0===$moduleFn$$)throw"Module not provided: "+$i$jscomp$309_name$$;$module$$={exports:{}};shadow.js.files[$i$jscomp$309_name$$]=$module$$}if($moduleFn$$){delete shadow$provide[$i$jscomp$309_name$$];try{$moduleFn$$.call($module$$,goog.global,shadow.js.jsRequire,$module$$,$module$$.exports)}catch($e$$){throw console.warn("shadow-cljs - failed to load",$i$jscomp$309_name$$),$e$$;}if($opts$$){var $globals$$=
                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
TypeError: Cannot read properties of undefined (reading 'abs')
    at Fa (public/bench/js/bench.js:208:349)
    at Object.<anonymous> (public/bench/js/bench.js:225:174)
    at Object.shadow$provide.<computed> (public/bench/js/bench.js:225:258)
    at Object.shadow.js.jsRequire (public/bench/js/bench.js:4428:332)
    at Object.shadow.js.require (public/bench/js/bench.js:4429:417)
    at public/bench/js/bench.js:10843:137
    at public/bench/js/bench.js:11772:4
#2021-09-3009:51simongrayWhen using a custom handler fn, is there any way to intercept and modify the request map being sent to the handler in the shadow-cljs.edn configuration?#2021-09-3015:52thhellerthat question doesn't compute. you said custom handler fn, you can do whatever you want in that? I assume that is what you configured in shadow-cljs.edn?#2021-09-3015:52thhellerbut as always I recommend using your own server if you need anything special from your server#2021-09-3015:52thhelleryou absolutely do not need to use the built-in shadow-cljs servers, they are purely for convenience. they are not required for hot-reload or repl to work#2021-10-0107:25simongraywhat I meant was, is there a way I can modify the contents of the request being sent to the handler, but never mind.#2021-10-0107:27simongrayIt’s because I needed to add some authorization-override data to it . I just use a separate handler for shadow-cljs now.#2021-09-3012:48Carloquestion: I started splitting the dependencies in a deps.edn file because I needed a dependency to be a local checkout (I followed https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn). But now, when I cider-jack-in-cljs, should I choose clojure-cli or shadow-cljs as the connection method? (before, I was choosing the latter). Both give me problems: • clojure-cli will give me:
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:11).
shadow-cljs has not been started yet!
In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it.
If you have a shadow-cljs server or watch running then you are not connected to that process.
shadow-cljs will give me:
[:app] Build failure:
The required namespace "minimal.core" is not available.
#2021-09-3012:55Carlosolved this particular problem, using shadow-cljs in the end (I was using a wrong path in paths)#2021-09-3017:25Joshua SmockHi 👋 new to the Slack group 🙂 We (Pitch) have been looking into using https://jestjs.io as a test runner for some of our code. We’ve gotten an initial prototype working by using the :browser-test target combined with enabling :devtools :loader-mode :script, as well as loading the individually compiled files using an approach similar to the :node-test target, using vm. It more or less works, but is a little hacky. Thinking about some improvements to this, one thing that looks interesting is Jest’s https://jestjs.io/docs/code-transformation capability, as it could theoretically allow us to “run” CLJS files directly rather than running Jest against the compiled target output. To do this we would need to be able to do two things: 1. Compile an arbitrary file, with goog.require statements that also handles node modules in a nice way, and 2. Generate the dependencies for that arbitrary file. I’m curious how feasible this would be, or if there would need to be work done to enable this. Any thoughts?#2021-10-0118:17thheller:npm-module is probably your best bet. I don't know how jest works internally though so no clue what it needs. the code transformation definitely won't work since that can't invoke JVM code#2021-10-0118:17thheller(or could but in a rather slow way, making it effectively unusable)#2021-10-0118:19Joshua SmockMy thinking for the transformation was to call out to some JVM process via a thread/process call, and then do some light transformation so that Jest can use it (unless :npm-module already handles the require calls correctly?)#2021-10-0118:20Joshua SmockJest caches the transformed code so speed is not too important, but if we needed it we could spin up some daemon when Jest starts so that the JVM is warm#2021-10-0118:20thhellerI don't know how jest operates or what it needs#2021-10-0118:21thheller:npm-module is just the most generic way to run CLJS code in JS based tools#2021-10-0118:21thhellerit is meant to just work and usually does#2021-10-0118:21thhellerbut again ... no clue how Jest operates 😛#2021-10-0118:25Joshua Smockit does take JS code 😄 It’s kind of hard to describe how Jest works succinctly, but it basically can take some JS code and use globals like describe and it to run tests. If it sees a require statement it does some additional stuff too. Would using :npm-module work well with :loader-mode :script ? Jest works best with individual files because it parallelizes the files it runs as well, so a single bundled file isn’t ideal#2021-10-0118:26thheller:loader-mode :script is an entirely different thing and doesn't apply#2021-10-0118:26thhellerjust try :npm-module. if jest really doesn't do anything special it'll just work#2021-10-0118:28Joshua SmockI’ll give it a try and let you know how it works! I’m not fully confident because Jest is a bit complex but maybe it does#2021-10-0118:29thhellerif :browser-test worked then it'll most definitely work#2021-10-0118:31Joshua Smockah, but I rely on ns-regexp, will this also work with :npm-module?#2021-10-0118:32Joshua SmockI can make a registry but prefer not to#2021-10-0118:32thhelleryes, :ns-regexp works#2021-10-0118:40Joshua SmockI’m having an issue with the build that seems related to ns-regexp. When it’s present, I get a stack trace:
[:jest] Configuring build.
[:jest] Compiling ...
[:jest] Build failure:
NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
    clojure.core/deref-future (core.clj:2304)
    clojure.core/deref (core.clj:2324)
    clojure.core/deref (core.clj:2310)
    shadow.build.classpath/get-classpath-entries (classpath.clj:808)
    shadow.build.classpath/get-classpath-entries (classpath.clj:807)
    shadow.build.classpath/find-cljs-namespaces-in-files (classpath.clj:1250)
    shadow.build.classpath/find-cljs-namespaces-in-files (classpath.clj:1247)
    shadow.build.test-util/find-test-namespaces (test_util.clj:16)
    shadow.build.test-util/find-test-namespaces (test_util.clj:7)
    shadow.build.targets.npm-module/resolve* (npm_module.clj:78)
    shadow.build.targets.npm-module/resolve* (npm_module.clj:67)
    clojure.core/apply (core.clj:669)
    clojure.core/update-in/up--6870 (core.clj:6174)
    clojure.core/update-in/up--6870 (core.clj:6173)
    clojure.core/update-in (core.clj:6175)
    clojure.core/update-in (core.clj:6161)
    shadow.build.targets.npm-module/resolve (npm_module.clj:102)
    shadow.build.targets.npm-module/resolve (npm_module.clj:100)
    shadow.build.targets.npm-module/process (npm_module.clj:112)
    shadow.build.targets.npm-module/process (npm_module.clj:105)
    clojure.lang.Var.invoke (Var.java:384)
    shadow.build/process-stage/fn--16319 (build.clj:160)
    shadow.build/process-stage (build.clj:157)
    shadow.build/process-stage (build.clj:149)
    shadow.build/resolve (build.clj:405)
    shadow.build/resolve (build.clj:401)
    shadow.build/compile (build.clj:439)
    shadow.build/compile (build.clj:432)
    shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
    shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
    shadow.cljs.devtools.server.worker.impl/eval17936/fn--17938 (impl.clj:439)
    clojure.lang.MultiFn.invoke (MultiFn.java:234)
    shadow.cljs.devtools.server.util/server-thread/fn--17698/fn--17699/fn--17707 (util.clj:284)
    shadow.cljs.devtools.server.util/server-thread/fn--17698/fn--17699 (util.clj:283)
    shadow.cljs.devtools.server.util/server-thread/fn--17698 (util.clj:256)
    java.lang.Thread.run (Thread.java:831)
if I remove :ns-regexp it goes further and produces an expected error rather than the stack trace
#2021-10-0118:41thhellerupgrade shadow-cljs. that should be fixed#2021-10-0119:01Joshua SmockIt works! and actually out of the box, without much extra work. I’m assuming it’s possible to do this programmatically (building a target on the fly rather than one from shadow-cljs.edn), so the only question remaining is if it’s possible to get a manifest.json file for the :npm-module build. I added :build-options :manifest-name "manifest.json" to my config but it didn’t seem to work#2021-10-0205:43thhellerwhat do you use manifest for? thats a feature specific to browser based builds and doesn't really make sense for npm-module?#2021-10-0411:50Joshua SmockThe manifest might not be the best tool for this but I would like to get an analysis of the dependencies (filenames, specifically) of a specific file. If I have that then I can give it to Jest and it can figure out which tests to run based on changed files#2021-10-0104:36mattlyI'm sorry if this is answered elsewhere but I really couldn't find it, but, if I'm targeting a node library for my shadow-cljs project, is there a way to tell the closure compiler that some of the dependencies are peer dependencies? Like, I'm making a React component that I want to be able to consume from regular JS, and I'd like for the consuming project to provide react#2021-10-0107:25borkdude@mattly Yes, this is possible.
:js-options
   {:resolve {"react" {:target :global
                       :global "React"}}}}
#2021-10-0117:59thhellerthat seems unrelated to the question is only really relevant for browser builds wanting to use stuff from a CDN or so. definitely not node librries#2021-10-0118:03borkdudeAh gotcha, I assumed browser#2021-10-0118:04mattlyWell, it’s going to end up in the browser#2021-10-0118:04mattlyI’m just thinking about how to reduce the asset sizes#2021-10-0107:25borkdudehttps://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2021-10-0115:37mattlyThanks#2021-10-0117:39cap10morganAnnoying question alert (b/c the fair answer is "just use shadow-cljs"): I'm trying to package my target-bundled CLJS into an ES module, but I keep running into ReferenceError: self is not defined from the very early assignment goog.global=this||self. I have "type": "module" in my package.json file and am trying to create an ES module package. Anyone have any pointers as to what is going on there?
#2021-10-0117:40cap10morganSince shadow-cljs has an ES module output feature, was just curious if anyone knew or could point me towards the basic stuff it was doing there#2021-10-0118:01thhellermost of the ESM related code is here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/esm.clj#2021-10-0118:02thhellerfor example for development builds it replaces that line#2021-10-0118:02thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/esm.clj#L323#2021-10-0118:03thhellerthere are a few more things going on though to get it all working properly#2021-10-0118:04borkdude@U06FS3DLH I have a working setup with :target :esm for node as well.#2021-10-0118:04cap10morganAwesome, thank you @U05224H0W!#2021-10-0118:05cap10morgan@U04V15CAJ oh? you mean w/ shadow-cljs or just tools.deps?#2021-10-0118:05borkdudeboth#2021-10-0118:06borkdudehttps://github.com/borkdude/nbb#2021-10-0118:06cap10morganinteresting. didn't know :target :esm was an option#2021-10-0118:06borkdudeMore details here: https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-10-0118:06borkdude(@U05224H0W helped me with this a lot, thanks again)#2021-10-0118:09cap10morganright, I saw it was an option in shadow-cljs. didn't think it was one w/ just tools.deps (or, I guess, just the plain cljs compiler in that context)#2021-10-0118:09thhellerit is shadow-cljs only at this time#2021-10-0117:58thheller@mattly I'm assuming by "node library" you mean actual :target :node-library published to npm? that by default doesn't bundle any dependencies so no further configuration is required. whether you declare your dependency on react as a regular dependency or node peerDependency is up to you and doesn't matter from the shadow-cljs perspective#2021-10-0118:03mattlyYes, though instead of publishing to npm I want to use it in a JS-based project locally#2021-10-0118:03mattlyThanks#2021-10-0211:09Chris McCormickI have a shadow-cljs setup working using deps.edn and :target :node-script. It is consuming a library via :local/root which I am developing locally and it also has a deps.edn with a :npm-deps in it. Is there something I should do to make those :npm-deps from the library get installed into the top level project?#2021-10-0214:36thheller:npm-deps don't belong and deps.edn and have no effect there for anything. they need to be declared in a deps.cljs file on the classpath. if your library does that then packages should be installed in the main project.#2021-10-0223:39Chris McCormickCool, thanks for the tip! Will investigate this.#2021-10-0300:09Chris McCormickWorks perfectly, thank you. I mis-read the "https://shadow-cljs.github.io/docs/UsersGuide.html#publish-deps-cljs" section in the user guide. Thanks for putting me straight.#2021-10-0219:52rafaeldelboniHey sorry if is a dumb question, but my Google Foo is failing me and I'm not being able to find how to do this, is possible to ask shadow-cljs to hot-reload when I change a markdown file in a specific folder?#2021-10-0305:27thhelleronly if you use https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745 to include it#2021-10-0305:28thhelleryou can also just trigger the build from the REPL or the UI, but if you included the file via another macro it might be cached and not recompiled unless the ns that did it is marked with ^:dev/always#2021-10-0318:29rafaeldelboniHey thanks, I will probably stick with the manual trigger.#2021-10-0318:29rafaeldelboniMaybe I can make a vim keymap for it#2021-10-0322:41Donnie WestAnyone using Preact and specifically using prefresh with shadow-cljs? Curious how difficult a setup it would be#2021-10-0323:12Donnie WestLooking into this deeper, shadow-cljs doesn't support it out of the box. Attempting to use it with preact-cli just makes local dev slow I've not looked too deep into the internals of shadow-cljs: how hard would it be to add support? I assume there's some sort of check for react to inject react-fast-refresh so I should just implement the same and shoot over a pr?#2021-10-0401:31huygnyou can check #helix 's fast refresh impl#2021-10-0404:52Donnie WestDuh, should've checked there first. Seems easy enough to translate to Preact. Thanks!#2021-10-0405:15flowthingI currently rely on shadow.cljs.devtools.server.repl-impl/do-repl in the (experimental) shadow-cljs support for an editor plugin I'm working on. I realize that it's not part of the stable API, though. Would it be possible to have it be a part of the API (e.g. in shadow.cljs.devtools.api)? I'd be perfectly happy with something that basically just defers to shadow.cljs.devtools.server.repl-impl/do-repl without doing anything else.#2021-10-0405:30thheller@flowthing what exactly are you doing with do-repl? I mean that is pretty REPL specific and most likely and editor should be talking directly to shadow.remote? That isn't documented much yet but the basic concept is explained here https://github.com/thheller/shadow-cljs/blob/master/doc/remote.md#2021-10-0405:41flowthingMy editor plugin connects to the shadow-cljs socket REPL and starts a slightly customized prepl-like REPL on top of it. It also opens a socked-based backchannel, which the editor plugin then connects to to send tooling messages back and forth. I'm aware of shadow.remote, but I only really want/need a REPL.#2021-10-0405:44thhellerbut if you connect to shadow.remote directly you get all of the REPL functionality + the potential of all other editor tooling over one connection#2021-10-0405:44thhellerI mean all the shadow-cljs REPLs are built on shadow.remote as well as everything the UI does#2021-10-0405:44thhellereventually everything that is not currently using it will be using it internally. eventually the intent is for all tools to use it too. I mean even do-repl uses it internally#2021-10-0405:46flowthingRight, but I want to retain the ability to start nested REPLs, for instance. Also, I specifically want to send evaluations and tooling-related messages over different channels.#2021-10-0405:46thhellerdo-repl will not become part of the public API but if you explain what exactly you need from it I can maybe adopt the shadow.cljs.devtools.api/cljs-repl?#2021-10-0405:47flowthing> I mean even do-repl uses it internally Hmm, so maybe I could reimplement something like do-repl over shadow.remote. :thinking_face:#2021-10-0405:47thhellerthere is no support for nested REPLs for any CLJS REPL or anything using do-repl?#2021-10-0405:48thhellerdo-repl is running over shadow.remote already so anything it does you can replicate#2021-10-0405:53flowthingOh, right! I've been away from the CLJS side of things for a while so I forgot about the nested REPLs. Anyway, reimplementing the relevant bits of do-repl over shadow.remote sounds like the way to go. Thanks! I might be back with possible questions regarding shadow.remote. 🙂#2021-10-0410:58Björn EbbinghausToday I noticed again, that shadow-cljs didn't stop compiling my project over and over again in the background, and I was not modifying any files (at least to my knowledge) I notice this from time to time, and a restart of the server is enough to solve the problem. Has anyone had similar experiences? It's not a big problem (when I notice it), and I can't rule out that it's not my IDE or some plugin that keeps changing things. Mostly I notice it when my Mac stops turning off the fan. 😕#2021-10-0415:32eins78we had such a case in our setup, maybe it happens in yours too: we were watching (JS inside the) the output-dir, leading to an endless compile-loop.#2021-10-0417:42thhelleryeah definitely keep the output-dir out of the source paths#2021-10-0417:42thhellerbut otherwise most of the time its some other tools touching files and kicking off compiles#2021-10-0417:43thhelleryou can set :log {:level :debug} in your shadow-cljs.edn and it'll log a little more including the namespaces/files that triggered a compile#2021-10-0503:56Oliver GeorgeHas anyone used @react-pdf/renderer with shadow-cljs?#2021-10-0503:57Oliver GeorgeI'm trying to decide if my errors are compatibility or a setup problem.#2021-10-0503:57Oliver GeorgedynCall is not a function#2021-10-0506:23thhellerhard to diagnose without more info. pdfjs is notorious for not working properly with bundlers so I made this example using the CDN version https://github.com/thheller/reagent-pdfjs#2021-10-0506:24thhellerreact-pdf seems to be using pdfkit. never tried that myself but maybe it has similar issues#2021-10-0508:32Oliver GeorgeThanks I’ll poke around a bit and see what sense I can make of it. #2021-10-0509:19Oliver GeorgeI think this counts as a minimal repro: https://github.com/olivergeorge/shadow-vs-rpdfr/#2021-10-0516:35thhellerthere is no shadow-cljs.edn?#2021-10-0517:28thhellerchecked it out. it appears that something in there requires some WASM code to be bundled. shadow-cljs currently can not do that#2021-10-0517:28thhelleryou can try https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external and just use webpack#2021-10-0519:50Oliver GeorgeThanks. Good to see there's an escape hatch. Was worries I would need to completely pull shadow out. #2021-10-0519:50Oliver GeorgeSorry from missing the shadow config in the repro. #2021-10-0509:19Oliver GeorgeStack trace shown in console is:
TypeError: dynCall is not a function
    at Function.eval [as bind_value] (eval at buildCallerFunction (nbind.js:1), <anonymous>:1:96)
    at _nbind_value (nbind.js:1041)
    at module.exports (entry-common.js:241)
    at Object.shadow$provide.module$node_modules$$react_pdf$yoga$src$dist$entry_browser (entry-browser.js:41)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$react_pdf$renderer$dist$react_pdf_browser_cjs (react-pdf.browser.cjs.js:22)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at eval (rpdf.ex2.js:2)
    at eval (<anonymous>)
#2021-10-0511:22myguidingstarhow can I specify lein profiles for each shadow build?#2021-10-0516:34thhellernot supported. if you really must you can just use lein via lein with-profiles +whatever run shadow.cljs.devtools.cli release your-build or so#2021-10-0517:18myguidingstarI see. Thanks#2021-10-0517:26myguidingstarif run from npx, shadow seems to ignore :lein {:profile "+cljs"}?#2021-10-0517:29thhellerif thats in your build config then yes, otherwise should be fine if at top level#2021-10-0513:41AspirationalHey! I am trying to publish a chrome extension but I get a rejection because of code obfuscation, they provide an example of obfuscated code: out/background.js:null:null: n(null, 1, [js, new n(null, 7, [Xh How can I disable code obfuscation?#2021-10-0514:12borkdude@dovganchin optimizations simple#2021-10-0516:32thheller@dovganchin better to try shadow-cljs release app --pseudo-names or shadow-cljs release app --debug#2021-10-0516:33thhellerthat'll still renamed and minify everything but give somewhat more usable names for stuff#2021-10-0516:33thhelleryou want to keep :advanced optimizations to keep the code small#2021-10-0518:20myguidingstaris there a :target for Chrome Extension? I see that mentioned in Basic Workflow but can't find a section for that#2021-10-0518:43ribelo
:chrome-extension
#2021-10-0518:46ribeloI just don't know if it is still supported and nothing has gone wrong in the meantime#2021-10-0518:57myguidingstarthere seems to be an example at https://github.com/binaryage/chromex/tree/master/examples/shadow Not sure if it still works...#2021-10-0518:58thhellerthe shadow-cljs part still works but I don't know what has changes regarding chrome extensions since then#2021-10-0518:58thhellerIIRC there is a new manifest format and stuff#2021-10-0518:59thhellerthis thread probably has the most info https://github.com/thheller/shadow-cljs/issues/279#2021-10-0523:12Chris McCormickWhat do these errors mean when compiling in :esm target?
[:server] Compiling ...
[2021-10-06 07:09:53.234 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/keyv/src/index.js", :requires [{:line 18, :column 14}]}
[2021-10-06 07:09:53.501 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/express/lib/view.js", :requires [{:line 81, :column 13}]}
My requires look like:
["keyv$default" :as Keyv]
["express$default" :as express]
#2021-10-0605:01thheller@chris358 that is not your requires, that is the require in those files. most likely they are doing some kind of dynamic require, eg. not require("some-string") but require(some_variable)#2021-10-0605:04thhellerfor :target :esm intended for node you want to set :js-options {:js-provider :import}. otherwise shadow-cljs will attempt to bundle everything which won't work for many node things#2021-10-0608:04Ben Haltonhi not sure if this is a shadow issue per se but since upgrading to react 17 we seem to have lost our code from the stack when getting errors in the console, so pre 17 we would get something like:
Warning: Failed prop type: The prop `open` is marked as required in `ForwardRef`, but its value is `null`.
    in ForwardRef (created by WithStyles(ForwardRef))
    in WithStyles(ForwardRef) (created by ui.views.reports.reports_dialog.render)
    in ui.views.reports.reports_dialog.render (created by ui.views.reports.reports_dialog.init)
    in ui.views.reports.reports_dialog.init (created by ui.views.meeting.home.render)
where ui.views.* is our code since upgrading we get:
Warning: Failed prop type: The prop `open` is marked as required in `ForwardRef`, but its value is `null`.
    at eval ()
    at eval ()
    at cmp ()
    at cmp ()
    at div
    at eval ()
    at cmp ()
so no pointer to our code at all which obviously makes it hard to work out what's up.
#2021-10-0608:08Ben HaltonI don't really have a good idea of what might cause this but I know react 17 made some changes to the way the code is organised#2021-10-0608:11thheller@gingerwizard I'm guessing this is react? I haven't used react in a long time. don't know what changed in 17. only thing it looks like it is missing source maps?#2021-10-0609:02Ben HaltonI think in 17 react shipped as modules in some way that I'm afraid I don't fully understand#2021-10-0609:03Ben HaltonI'm not much of a UI guy really - if we are missing react source maps could that lead to not having our app code in the stack ?#2021-10-0609:08Ben Haltonlooking at it in devtools I think I can see react source maps#2021-10-0610:13Ben Haltonfwiw I found a similar issue from a while back here that was closed without resolution, but shows at least it's unlikely to have anything to to with shadow https://github.com/mui-org/material-ui/issues/23600#2021-10-0610:19thheller@gingerwizard source maps map the JS location back to the original yes but you should be getting warnings in the browser console if source maps fail to load#2021-10-0610:19thhellerif you get those it typically means that your :asset-path in your build config is misconfigured. if you get no warnings I would assume they loaded correctly and the problem is elsewhere#2021-10-0610:21Ben Haltonyup agreed :thumbsup::skin-tone-2: there is a problem in there somewhere - I would assume if it was a generic react 17 / mui issue the internet would be full of people complaining so likely something specific to our setup#2021-10-0610:51Ben Haltonwell OK for anyone that reads this with a similar issue, I've been able to "resolve" it for now by rolling react back to 16.14.0. Unsatisfactory but seems to hang together for now#2021-10-0613:41David PhamHello 🙂 I am trying to use pnpm with shadow-cljs, and I appears that pnpm either does not install dependencies recursively, or that shadow-cljs does not work well with pnpm. Is there any shared experienced?#2021-10-0705:44thhellerif its all symlinks maybe try setting :js-options {:allow-nested-packages false} in your build config. it might get confused by all the links otherwise?#2021-10-0617:25thheller@neo2551 never tried pnpm so not sure what it does. all shadow-cljs cares about is a node_modules directory with all the packages. don't know what that looks like with pnpm#2021-10-0617:25thhellernpm and yarn work fine#2021-10-0619:05borkdude@thheller one difference might be that pnpm uses symbolic links instead of copying all the modules inside your node_modules dir, but like mvn it keeps each lib in a single place#2021-10-0702:02neuralhi everyone! it is possible to load an .js file direct with (:require ["../components/Button" :as btn]) ??? then got this error:
Compilation failed!

------ ERROR -------------------------------------------------------------------
 File: .../src/stories/components/Button.js:8:2
--------------------------------------------------------------------------------
   5 | const Button = (props) => {
   6 |     const { variant, children, size, fontw, color, ...rest} = props;
   7 |     return (
   8 | 	<button className={`button ${variant}`}
--------^-----------------------------------------------------------------------
primary expression expected
--------------------------------------------------------------------------------
   9 | 		style={{width: `${size}`,
  10 | 		        color: `${color}`,
  11 | 			fontWeight: `${fontw}`}}>
  12 | 	    {children.toUpperCase()}
--------------------------------------------------------------------------------
#2021-10-0702:02neural... src/stories is in the classpath#2021-10-0702:12bbss@neural.works.com :as aliased is for the namespace so you can refer to all the stuff in the ns with the aliased/thing, you probably want to use :default for the default export. The error might be about something else though, it seems the JSX is confusing the compilation.#2021-10-0702:14bbssYou'll need to pre-process that JS with something like babel. https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2021-10-0709:08myguidingstarI got an error "Cannot infer target type in expression" with this expression: (-> "" (goog.string.Const/from) (goog.html.TrustedResourceUrl/fromConstant) (.jsloader/safeLoad) (.addCallback some-callback-func))#2021-10-0709:09myguidingstarI thought functions from closure library will work out of the box?#2021-10-0709:10myguidingstar(`addCallback` is a method of the Deferred object returned by safeLoad)#2021-10-0715:25Ryan JerueOn shadowcljs 2.15.10 , getting an error in ie11 (I hate it too). I think this is because there is a single / for what looks like a regex. I have output set es5 … es6 is what should support the single / regex. This didn’t happen on the version I had previously, 2.11.23 . Is there another flag I need to set?#2021-10-0715:56Ryan JerueIt looks like its because something is translating this utility in corejs incorrectly#2021-10-0718:17Ryan JerueOlder version of shadow has it looking like shadow$provide[1694]=function(_c_,_a_,_e_,_b_){c=a(1556);b.UNSUPPORTED_Y=c(function(){var d=_RegExp_("a","y");d.lastIndex=2;return null!=d.exec("abcd")});b.BROKEN_CARET=c(function(){var d=_RegExp_("^r","gy");d.lastIndex=2;return null!=d.exec("str")})};#2021-10-0718:49Ryan Jeruecore-js issued that was fixed in https://github.com/zloirock/core-js/issues/972#2021-10-0715:56myguidingstarI got NullPointerException for a release build whenever :source-map true and :source-map-include-sources-contentboth set to true. It compiles when either set to false. Is it a bug?#2021-10-0715:58myguidingstarstacktrace: https://gist.github.com/myguidingstar/3c61e585746047853bff41975d73fe02#2021-10-0716:45thhellerhard to say without a repro. could be a problem in how shadow-cljs hands the data over to the closure compiler or just a bug in the closure compiler. can't say, never seen that before#2021-10-0817:01myguidingstarmy app stops working in :advanced mode after migrating to shadow - no error under browser console. Before that we had webpack + cljsjs for npm modules. We have no compilation warnings except some from libraries when set {:infer-externs :all}. There are lots of them, so I wonder there are a list of functions from popular libraries that are known to break :advance compilation.#2021-10-0817:05myguidingstarhere's the warnings, if anyone is interested https://gist.github.com/myguidingstar/5d6c828578bdc6a9413f4c80290f4977#2021-10-0817:25thhellerdon't use :all. none of them are relevant#2021-10-0817:25thhellerwhat does "stops working" mean? I mean there must be some kind of bad behavior?#2021-10-1008:18myguidingstarnever mind, I've pinpointed the problem with rigid logging.#2021-10-1008:19myguidingstarbut glad to know the libraries are not relevant. Thank you very much#2021-10-0817:30cap10morganWas playing around with this: https://github.com/thheller/netlify-cljs ...and after updating some deps, it seems to fail in netlify-lambda and netlify dev b/c __dirname is set to / so shadow's attempts to import things from __dirname + '/../.shadow-cljs/...' fail. Anyone know of a workaround there?#2021-10-0817:33thheller@cap10morgan are you publishing development code that way or is this during development? you should only actually use release code in a production environment which will never use __dirname?#2021-10-0817:36cap10morganStrictly local dev so far#2021-10-0817:35thhellerit has been 3 years since I touched netlify so no clue what changed on their side. you can set :output-dir "functions" in addition to :output-to "functions/api.js". then it won't use __dirname either#2021-10-0817:37cap10morganOK I'll give that a try thanks!#2021-10-0817:39cap10morganthat made it put a cljs-runtime dir in the functions dir and then it errors out with no such file or directory, open '/cljs-runtime/goog.debug.error.js'#2021-10-0817:41cap10morganone issue might be that netlify-lambda now errors out if netlify.toml is pointed at the same functions dir. they say to point it at e.g. functions-build and then it does some kind of build and copy of api.js over to that dir#2021-10-0817:41thhellerhmm yeah that doesn't work. the code expects to run in the place where it was created by the compiler#2021-10-0817:41thhelleronly release can run wherever it wants#2021-10-0817:43cap10morganok, yeah, it works w/ npx shadow-cljs release lambda#2021-10-0817:44thhellerI mean if you make it copy all the other files in cljs-runtime too then it should be fine#2021-10-0817:44thhellerbut just copying the :output-to won't work#2021-10-0817:45thhellereverything in :output-dir needs to be readable and should ideally not be further modified. otherwise it might mess with hot-reload and stuff#2021-10-0817:45cap10morganI tried symlinking cljs-runtime but that didn't work b/c it's still trying __dirname + /cljs-runtime so ends up w/ /cljs-runtime#2021-10-0817:46cap10morganbut I can probably get by w/ release for now#2021-10-0817:47thhellerdon't know why its messing with __dirname though? is this no longer following node rules?#2021-10-0817:56cap10morganI guess not 🤷 #2021-10-0820:39cap10morganIf I'm targeting the browser but building a library that I expect people to consume in a react app w/ webpack, etc., should I use :target :npm-module or :target :node-library instead of :target :browser?#2021-10-0820:53thheller:npm-module was made for that particular use case#2021-10-0820:54thheller:node-library makes a few too many assumptions about being for node so I wouldn't recommend that#2021-10-0821:27niveauverleihShadow-cljs tuning: Apart from :jvm-opts ["-Xmx512m"] are there any settings to limit the RAM and CPU consumption of shadow-cljs? Like reducing the number of files watched, disabling some services? I use a low end device to learn the basics of reagent.#2021-10-0822:51alexdavisYou might find this useful, you can learn the basics of clojurescript and reagent without needing to run anything except a browser https://borkdude.github.io/scittle/#2021-10-0822:52alexdavisAlternatively you could use a cloud vm service of some kind to run the shadow process #2021-10-0905:55niveauverleihThank you all!#2021-10-0821:29thhellernot really no#2021-10-0914:55pesterhazyHowdy, I'm trying to use Jest as a test runner in conjunction with shadow-cljs and I'm running into problems Here's a minimal repro https://github.com/pesterhazy/shadow-jest#2021-10-0914:55pesterhazyEssentially it bombs out with
ReferenceError: goog is not defined

      at call (../.shadow-cljs/builds/test/dev/out/cljs-runtime/goog/debug/error.js:15:1)
      at SHADOW_IMPORT (out.js:62:44)
      at Object.<anonymous> (out.js:1522:1)
#2021-10-0915:00pesterhazyNot knowing which target was appropriate, I picked :target :node-test because the tests are intended to run in node and jsdom (with Testing Library).#2021-10-0915:00pesterhazyAny help appreciated!#2021-10-0916:41thheller@pesterhazy for jest you likely want to use :target :npm-module instead. :node-test is pretty specific to run cljs.test in node. you can use :ns-regexp "-test$" to get similar behavior as :node-test with regards to which files are included#2021-10-0916:58pesterhazyah, cool - let me give that a try#2021-10-0917:01thheller
FAIL  dist-test/todomvc.app_spec.js
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at onResult (../node_modules/@jest/core/build/TestScheduler.js:175:18)
          at Array.map (<anonymous>)
#2021-10-0917:01thhellerchanged jest.config.js
testMatch: [
    "**/*_spec.js"
  ],
#2021-10-0917:01thhellerand using this build config
{:target :npm-module
  :ns-regexp "-spec$"
  :output-dir "dist-test"}
#2021-10-0917:01pesterhazyhehe I was just typing that....#2021-10-0917:02pesterhazyout of curiosity, have you tried jest with shadow before?#2021-10-0917:02thhellerno#2021-10-0917:03pesterhazywe're experimenting with it at Pitch, where we want to improve our frontend testing story#2021-10-0917:03thhellerseveral people have asked in the past but I never got around to it. thanks for the repo, made it really easy to try 🙂#2021-10-0917:03pesterhazywe got it to work with the :browser-test target but that felt hacky and I thought there must be a better way#2021-10-0917:04thheller:npm-module seems to work as far as I can tell#2021-10-0917:04thhellereven (jest) watch works#2021-10-0917:05pesterhazy
FAIL  dist-test/todomvc.app_spec.js
  ✕ arithmetic (5 ms)

  ● arithmetic

    expect(received).toBe(expected) //  equality

    Expected: 5
    Received: 4

      at Object.<anonymous> (todomvc/app_spec.cljs:9:27)
#2021-10-0917:05thhellereven release seems to work so seems all good#2021-10-0917:05pesterhazyawesome!#2021-10-0917:06thhellerit source maps. that is gonna help a lot. seems good.#2021-10-0917:06pesterhazyi'm going to hack on it some more#2021-10-0917:07thhellerI don't like the test syntax all that much but a few helper functions/macros might make that bearable#2021-10-0917:07pesterhazygoing to try to implement todomvc based on tdd using Jest + React Testing Library#2021-10-0917:07pesterhazyyeah, we already have a wip wrapper ns for jest assertions#2021-10-0917:08thhellerthere could totally be a :target :jest if needed but AFAICT :npm-module seems to do everything you'd need#2021-10-0917:09pesterhazywould you be open to a PR to the user guide once the dust settles?#2021-10-0917:09thhellersure#2021-10-0917:12pesterhazyit's quite fast on incremental builds in this minimal repo
PASS  dist-test/todomvc.app_spec.js
  ✓ arithmetic (2 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.578 s, estimated 1 s
Ran all test suites.
#2021-10-0917:13thhelleryeah first run seems slow but after that it appears to use some cache and only process actually changed files#2021-10-0917:16thhellerstill sometimes slow for me. dunno why#2021-10-0917:17pesterhazyI'm surprised all of this works with node's require() etc - the combination of node's require() and goog.provide etc is not something I can claim to understand#2021-10-0917:19thhellerwell :npm-module basically creates some glue code to pretend we still have everything in the same global scope but actually don't#2021-10-0917:20thhellerquite hacky but make CLJS/Closure output look like commonjs for the tools that need that#2021-10-0917:21thhellershould have named it :target :commonjs but oh well naming is hard 😛#2021-10-0917:25pesterhazybtw a mini bug report while i'm here steps • in the repo, run cp src/test/todomvc/app_spec.cljs src/test/todomvc/another_spec.cljs • in the shadow terminal Resource does not have expected namespace • compilation stops • ok fair enough, need to fix the ns decl • open that file in emacs and rename to (ns todomvc.another-spec) expected • now that I've fixed the ns decl, compilation works again actual • it doesn't compile, I need to ^C and restart • then it works#2021-10-0917:46pesterhazyBack to implementing TodoMVC using TDD!#2021-10-0917:47thhellerbtw you likely don't need to restart#2021-10-0917:47thhelleryou can force trigger a recompile from the REPL or the UI#2021-10-0917:48thheller(which of course shouldn't be necessary but still faster than a full restart)#2021-10-0917:51pesterhazydo you mean nREPL'ing into shadow?#2021-10-0917:51thhellerwell I'd assume you already have emacs connected?#2021-10-0917:52pesterhazyhehe, I'm lazy with REPLs, I'm a bad Clojurist, but using the UI will work nicely#2021-10-0917:52thhellerfrom the CLJ repl (shadow.cljs.devtools.api/watch-compile! :the-build)#2021-10-0917:52pesterhazyin CLJS I mostly rely on reloading, which often gives me 80% of what a REPL would#2021-10-0917:52thhelleryeah I barely use the CLJS REPL too. CLJ a lot though#2021-10-0917:53pesterhazyin Clojure I use (cider-eval-buffer) and that's it#2021-10-0917:53pesterhazybut I type a lot of stuff into the terminal repl, I'm weird that way#2021-10-0917:54thhelleryikes 😛#2021-10-0917:55thhellershadow-cljs clj-repl it is then 😉#2021-10-0917:56pesterhazy
$ shadow-cljs clj-repl
shadow-cljs - config: /Users/user/pitch/shadow-jest/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=>
#2021-10-0917:56pesterhazywhoa I had no idea!#2021-10-0917:56pesterhazyI'll use that a lot#2021-10-0917:56pesterhazyhow is this so fast?#2021-10-0917:56thhellershadow-cljs - connected to server#2021-10-0917:56pesterhazyit's like 10x faster than lein repl :client ....#2021-10-0917:57thhellerit is connected to the running watch you have I guess#2021-10-0917:57pesterhazyyeah it is, but using lein as a mere nrepl client is already slow as molasses#2021-10-0917:58thhellerwell yeah its not starting a new JVM. just the node script opening a tcp socket#2021-10-0917:59pesterhazyso it's not using nREPL then?#2021-10-0917:59thhellerno, just the socket REPL#2021-10-0917:59pesterhazyah, so much better#2021-10-0917:59pesterhazy(sometimes I wonder how much damage lein and nREPL, with their slowness and complexity, have done to Clojure)#2021-10-0918:00thhellerI like lein. nREPL not so much 😛#2021-10-0918:01pesterhazyomg I just added a watch for the app build via the socket repl#2021-10-0918:01pesterhazy
(shadow.cljs.devtools.api/watch :app)
[:app] Configuring build.
[:app] Compiling ...
#2021-10-0918:01pesterhazyshadow is so nicely decomplected!#2021-10-0918:01thheller(shadow/watch :app) from shadow.user 🙂#2021-10-0918:03thhellerI pretty much only run shadow-cljs server these days and do the rest over the UI#2021-10-0918:03thhellerguess I'm weird that way 😛#2021-10-1008:56borkdude@pesterhazy The slowness of lein just comes from loading many dependencies every time, I think. A comparable tools.build program with clj can be equally slow, if you're not mindful about which deps you are bringing in in your namespace form.#2021-10-1008:59thhellerI think most people complaining about slow startup of lein just have a user.clj sitting on the classpath that contributes most of the slowness. Otherwise IMHO its fine.#2021-10-1009:15pesterhazyWell, I think an argument can be made that lein tries to do too may things, so it ends up not doing any of these well. But of course I shouldn't have said "damage". We owe a lot to lein's original authors, and I'm in no position to complain, having written little in the way of OSS#2021-10-0917:55pesterhazyI think Stu Halloway has a talk out where he says "don't type stuff into the repl" - I beg to disagree#2021-10-0918:25martinklepschheresy#2021-10-1017:13Adam HelinsWhen async tests fail, testing messages are not printed. Is that expected, is there any solution? Unsure whether it is about shadow or CLJS itself.#2021-10-1017:22borkdudeit seems the testing stuff is done in a try/finally which kind of assumes sync testing probably#2021-10-1017:23thhellerno clue. if you setup an example showing it working with regular CLJS I will investigate 😛#2021-10-1017:23borkdudeinstead it could maybe done using the test blocks thing with functions that are picked up from the queue#2021-10-1017:23thhellerdon't think I ever used testing once 😛#2021-10-1017:29pesterhazyCljs.test generally has poor support for async#2021-10-1017:30pesterhazyWhich is unfortunate, given that almost everything interesting in JS is asynchronous#2021-10-1017:33Adam HelinsOh yeah, it seems to be implemented in a try-catch so it wouldn't work in an async setup. Which is a tad weird since async examples do use testing: https://clojurescript.org/tools/testing#2021-10-1017:34Adam HelinsThat's why I thought there might be something off with Shadow's test runner#2021-10-1017:45pesterhazyFWIW this is one reason why I'm switching to Jest (cljs.test has a weak design and is effectively maintained)#2021-10-1017:46pesterhazyI added selective test running once to cljs.test and it required monkey patching#2021-10-1017:48thhellerthat really has little to do with cljs.test. :node-test can do selective test runs just fine#2021-10-1017:48thhellerbeen meaning to implement it for :browser-test just never got around to it#2021-10-1017:49thhellercljs.test isn't great overall I'd agree on that but the basics are fine. All the macros really are the problem#2021-10-1017:52thhellershadow.test fixes that and beyond that there is just some UI that needs to be written to get the fancy stuff#2021-10-1017:57pesterhazyYes we're using shadow.test for that now, much better than my macguyver solution#2021-10-1018:06borkdudeI think the testing stuff can be made to work with async tests#2021-10-1018:06borkdudesomeone needs to make an issue about it, probably after chatting in #cljs-dev#2021-10-1018:44thhellerfirst actually verify. it might absolutely be shadow#2021-10-1020:46borkdudeok, I can see from the code already that this isn't going to work async, but here is a repro:
$ plk
ClojureScript 1.10.597
cljs.user=> (require '[clojure.test :as t])
nil
cljs.user=> (t/deftest foobar (t/async done (t/testing "dude" (js/setTimeout (fn [] (t/is (= 3 4)) (done)) 1000))))
#'cljs.user/foobar
cljs.user=> (foobar)
1

FAIL in (foobar) (:)
expected: (= 3 4)
  actual: (not (= 3 4))
cljs.user=> (t/deftest foobar (t/testing "dude" (t/is (= 3 4))))
#'cljs.user/foobar
cljs.user=> (foobar)

FAIL in (foobar) (file:44:173)
dude
expected: (= 3 4)
  actual: (not (= 3 4))
#2021-10-1020:46borkdudethe try/finally just isn't going to work with async, the finally block is of course executed too early#2021-10-1020:56Adam HelinsYep, same conclusion!#2021-10-1107:19borkdudeWhat you can of course do is move the testing into the callback, but then it won't nest properly#2021-10-1017:45sheluchinWhen using the Inspect Stream window, is there a way to get the path to the current object within its context?#2021-10-1019:38thheller@alex.sheluchin no, not that simple. it'll use datafy/nav so constructing a "path" may not always be that reliable. also the UI navigates by index so it never knows actual path values#2021-10-1020:16sheluchinThanks @U05224H0W. Not so complicated to figure out the path manually. Was just wondering if there was a shortcut.#2021-10-1020:01rafaeldelboniHey I tried to bump to version 2.15.11 from 2.15.10 and my project and tests started to throwing this https://github.com/rafaeldelboni/stasis/runs/3852914797?check_suite_focus=true:
Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$lib$react_markdown'

Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$index'

Chrome Headless 94.0.4606.0 (Linux x86_64) ERROR
  Uncaught ReferenceError: babelHelpers is not defined
  at ci.js:116796:9
  
  ReferenceError: babelHelpers is not defined
      at Object.shadow$provide.module$node_modules$react_markdown$lib$react_markdown (ci.js:188082:442)
      at shadow.js.jsRequire (ci.js:116793:18)
      at Object.shadow$provide.module$node_modules$react_markdown$index (ci.js:188088:300)
      at Object.shadow.js.jsRequire (ci.js:116793:18)
      at Object.shadow.js.require (ci.js:116818:20)
      at ci.js:188249:56 
Is there anything new I need to do in the new version? This only happens after I bump to the new version and delete the folder .shadow-cljs
#2021-10-1021:21thheller@rafaeldelboni oops, should be fixed in 2.15.12. there was some compiled code from a branch in that release that shouldn't have been.#2021-10-1021:23rafaeldelboniThanks for your fast reply! :)#2021-10-1021:43pesterhazycontinuous delivery ftw!#2021-10-1023:14Chris McCormickIs deps.edn the only way to pull in a dependency from a git repository when using shadow-cljs at the moment? Or is there a way to specify git deps in shadow-cljs.edn?#2021-10-1101:13Ryan JerueIf you're on lein, there's https://github.com/reifyhealth/lein-git-down I also don't think there's anything stopping sometime from putting it in a package json and adding it to to your paths. Not very elegant, but could work.#2021-10-1115:30thhellerdeps.edn only yes, shadow-cljs.edn doesn't support it currently#2021-10-1217:45Benjaminwhat is the equivalent of resources directory + io/resource of clojure in cljs shadow world?#2021-10-1219:29thhellerresources is added to the classpath by lein conventions. It is equivalent to either just putting the files into on of the classpath dirs you already have or adding resources to said classpath. :source-paths ["src/main" "resources"] or just putting the files from resources into src/main if you have :source-paths ["src/main"]#2021-10-1219:29thhellerthat being said there is no way to use io/resource directly in CLJS. you can only do so in a macro#2021-10-1307:09steveb8nQ: I’m getting OOM errors in CI release builds. anyone seen this before?
Execution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3332).
#2021-10-1307:53thheller@steveb8n fairly common in CI envs with limited memory yes. You can set :jvm-opts ["-Xmx512M"] or so to limit the memory or upgrade your JDK#2021-10-1307:54thhellermemory detection used to be wrong on older JVMs but I think thats fixed now and properly detects VMs and their memory config#2021-10-1307:54steveb8nthanks. I’m up to 3gb so I suspect something else. haven’t tried JDK version so that’s next#2021-10-1307:54steveb8nthx#2021-10-1307:54thhelleryou should never need 3 gigs for shadow-cljs unless you have like a billion lines of code 😛#2021-10-1307:55thhellerwhats the rest of the stacktrace though? curious where it fails#2021-10-1307:55steveb8nI agree. unzipped release js file is 5Mb so it’s pretty large#2021-10-1307:55steveb8njust ran build-report#2021-10-1307:56thhellerI've seen 12MB compile fine with 1gig ram so that doesn't mean much#2021-10-1307:56steveb8nlemme try and get that stacktrace for you#2021-10-1307:56steveb8ncan’t repro locally so it’ll take a few mins#2021-10-1308:29steveb8nbitbucket is difficult for catching files in /tmp. can’t get stack trace sorry#2021-10-1309:39Alexey Baryshnikov#2021-10-1316:55thhellerreact native expects that you register a root component with the proper name#2021-10-1316:56thhellerso https://github.com/thheller/reagent-react-native/blob/master/react-native/app.json#L2 needs to match the argument here https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L34#2021-10-1311:54pesterhazy@steveb8n finding a local repro case could help finding the cause#2021-10-1314:07mitchelkuijpersIs it possible to get a nodejs repl when using target:
:npm-module
#2021-10-1314:07mitchelkuijpersI need to use :npm-module because the tool I am trying to integrate with does not like the umd style exports which you get from :node-library#2021-10-1316:57thheller@mitchelkuijpers just node-repl is not enough? :npm-module works too but requires manual work. as in set :runtime :node in your build config and then from the JS that is consuming the compiled CLJS code somewhere you need to require("path-to-cljs/shadow.cljs.devtools.client.node")#2021-10-1316:58thhellerREPL should work after that but just node-repl is generally simpler and usually enough#2021-10-1318:46jthibaudeauQuestion for anyone who has been using shadow-cljs with electron. How did you go about compiling the preload.js? I have mine as a separate build from the main and the renderer, and shadow compiles it fine, but electron complains it can't load it properly. This is what I have in my shadow-cljs.edn builds:
:preload {:target :node-script
          :output-to "resources/preload.js"
          :main electron-app.preload.core/main}
This is the error showing up in the devtools
(function (exports, require, module, __filename, __dirname, process, global, Buffer) { return function (exports, require, module, __filename, __dirname) { #!/usr/bin/env node
                                                                                                                                                           ^

SyntaxError: Invalid or unexpected token
    at new Script (node:vm:100:7)
    at createScript (node:vm:257:10)
    at Object.runInThisContext (node:vm:305:10)
    at wrapSafe (node:internal/modules/cjs/loader:1021:15)
    at Module._compile (node:internal/modules/cjs/loader:1066:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1140:10)
    at Module.load (node:internal/modules/cjs/loader:982:32)
    at Module._load (node:internal/modules/cjs/loader:823:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
    at Function.o._load (node:electron/js2c/renderer_init:29:379)
#2021-10-1319:38pesterhazyWe just use js for preload#2021-10-1319:38pesterhazyI don't think you're meant to include a ton of code there#2021-10-1319:52jthibaudeauYeah I was able to workaround the compile issue by just using JS as well. Ideally I'd like to not have to write any JS 🙂 From what I've been reading about context isolation, preload seems to be where you can securely expose functionality to the renderer via contextBridge so there can potentially be a non trivial amount of code there#2021-10-1320:02thhelleryou can set :hashbang false in your build config to get rid of the #!/usr/bin/env node line#2021-10-1320:03thhellerit is my impression that you are supposed the bulk of your "node" interop code in the preload#2021-10-1320:03thhellerso should be fine to run a bunch of code there#2021-10-1320:11jthibaudeauOh that works, thanks so much!#2021-10-1319:10lispers-anonymousI have a large project using shadow-cljs. As part of our CI process, we create a production build pretty frequently. I have been looking at ways to speed up the build. Is it a bad idea to cache the .shadow-cljs directory on the build server? I think it could shave a couple minutes off our build time, but am worried about it making our builds unstable.#2021-10-1319:16nenadalmIt does save a lot of time and time to time it happens that deployed app doesn't render due to some issues ($jscomp something) - clearing the cache and rebuild helps. I am not working on the project - just helped to set it up, so I am not sure how often that happens. I just know it happened a few times in last year. In case you have some functional test, you should be able to catch it though (e.g. you could open homepage and check that at least something is rendered) before deploying to some env.#2021-10-1319:40lispers-anonymousThanks for sharing your experience. I'll probably talk this over with my team. We can run some experiments to see if the time saved is worth the hassle of having to clear the cache and re-build on occasion.#2021-10-1320:03thhellerI recommend caching the .shadow-cljs dir in CI envs yes#2021-10-1320:25lispers-anonymousThat's quite the endorsement, thanks for the response!#2021-10-1320:40javahippieWould it be a good idea to invalidate the cache on certain events, e.g. if dependencies are changed?#2021-10-1321:04lispers-anonymousWhile developing locally I update dependencies, both npm and clojure dependencies, without having to blow away my shadow-cljs cache and don't have issues. But the only thing it would hurt is your build times.#2021-10-1406:13thhellercaches invalidate themselves but most CI cache systems I have seen are too dumb to recognize changes and thus always restore old state. at which point it becomes useless so you do have to somewhat integrate it with your dependencies#2021-10-1406:19javahippieYeah, CircleCI won’t change a cache once it was created, so we create a file hash over package.json & project.clj. If this changes, the cache gets thrown out completely#2021-10-1406:24thhelleryeah exactly. unfortunately that blows away too much usually but still useful#2021-10-1406:29javahippieThanks for bringing the topic up, just tried it and it brought the uberjar build step in our pipeline down from 2:50min to 2:15min 👍#2021-10-1419:22lispers-anonymousI was able to shave about 1 minute off our (7 minute) build time by including .shadow-cljs in the build's cache. I think I'll get even better time savings by increasing the compute resources. Currently using a 3GB aws codebuild machine, which leaves a lot to be desired. Every second matters. Thanks again for the advice!#2021-10-1419:32thhellerdo you build more than one thing? you can save a lot of time by reducing the number of JVM startups#2021-10-1419:45lispers-anonymousI think we startup 3 jvms in this particular build • download npm dependencies • compile sass to css • compile and run tests, using a :node-test build target (jvm 1 + executing the test node script) • compile a shadow-cljs release build, a :browser build target (jvm 2) • build an uberjar with our clojure server code and the compiled js output (jvm 3) I don't think there is a way around these steps for us, which is okay. The benefits shadow-cljs has brought are well worth the tradeoffs in ci build time. Right now it's probably 2 minutes slower than when we used figwheel, and we weren't able to use advanced compilation with that.#2021-10-1420:24thhelleryou might gain a lot by compiling via a function run via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2021-10-1420:24thheller(shadow/release :build) there is identical to shadow release build from the CLI#2021-10-1420:25thhellerbesides that you probably want to shadow-cljs release build test and then node wherever/your-test.js to run the tests#2021-10-1420:25thheller(ie. compile using both builds using one JVM)
#2021-10-1420:26thhellerstartup time is rather significant on most CI systems so avoiding it can result in big improvements#2021-10-1420:30lispers-anonymousI've never poked around the clj-run part of the shadow docs. I'll experiment with that and combining the builds. Do some benchmarks. I suspect eliminating one jvm startup will have a big impact.#2021-10-1420:32thhellerif you just need to build two builds shadow-cljs release build-a build-b is fine#2021-10-1421:03lispers-anonymousUnfortunately our tests fail when compiling them with release, and that's not something I'm too keen on tackling right now. However, using clj-run with this
(defn release []
  (shadow/release :app)
  (shadow/compile :test))
Seems like an easy win so far. Shaved off another minute.
#2021-10-1421:04thhelleryou probably want to use the ! variants to release! and compile!. otherwise errors are just printed without "failing" (ie. process exit code)#2021-10-1421:09lispers-anonymousDone. I was wondering what those ! variants were for. Thanks again for the pro-tips#2021-10-1321:16tbrookeI have a project that has a dependency “@accordproject/markdown-transform”: “0.14.1" that crashes the closure compiler - not pdfmake itself but something related to pdfmake — I can get it to work with nbb — @borkdude mentioned that nbb wasn’t running it through the closure compiler and that there might be a way to webpack or some setting with shadow-cljs to run the dependency without going through closure. Anyone know how to do this?#2021-10-1406:15thhellersee https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external for how to use webpack#2021-10-1402:32Oliver GeorgeI'm looking for the shadow-cljs.edn equivalent of
^:dev/always
#2021-10-1402:33Oliver GeorgeSo that it's behaviour is controlled by the :builds selection#2021-10-1403:02Oliver GeorgePerhaps I'm unduely cautions. It doesn't seem to be used unless the NS is refrerenced. (I worried two conflicting ns would cause confuse)#2021-10-1403:06Appledev-http server has to be running or css reloading doesn't work for me. Just want to mention it.#2021-10-1406:16thhellerIt doesn't. You just need to set :watch-dir when using custom servers as described in the docs https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2021-10-1412:00AppleYeah I did exactly that last night and it didn't work. Somehow it's working this morning. :thinking_face:#2021-10-1404:36steveb8n@thheller I can confirm that upgrading the jdk version in CI fixed the OOM error. thanks again for the heads up#2021-10-1404:56zhuxun2After setting up a web worker per this tutorial (https://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers), I observed that the worker is making a waterfall of loads, each is a separate request to a namespace. Isn't this not ideal? Why couldn't it get these from the shared.js?#2021-10-1404:57zhuxun2#2021-10-1406:17thheller@zhuxun2 this is only during development. a release build will just load the shared file#2021-10-1411:31roman01laGiven the following modules config
{:shared {:entries []}
 :a {:entries [a.entry]
      :depends-on #{:shared}}
 :b {:entries [b.entry]
      :depends-on #{:shared}}}
What could be the cause of this build error?
Module Entry "b.entry" was moved out of module ":b".
It was moved to ":shared" and used by #{:shared :b}.
#2021-10-1412:19thheller@roman01la something in the :shared or :a module directly requiring the b.entry ns. can't have that without either removing that require or making b depend on a#2021-10-1412:32roman01lahmm, interesting, I don’t see any usage of b.entry apart from in modules config#2021-10-1412:33thhellerwell it doesn't have the to be the entry directly. can be a -> c -> b#2021-10-1412:39roman01lahm, are you saying that if the entry ns is app.b.entry (that is not required anywhere) then requiring app.b in :shared will cause app.b.entry to be moved into the shared module? Does that mean that NS names hierarchy can impact how code splitting works?#2021-10-1412:46thheller@roman01la no, not at all. the hierachy does not matter at all. only the literal ns. in general the entry namespaces should not be directly required anywhere#2021-10-1412:48thhelleruse something like https://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841 if you need to lazy reference code from the entry namespaces#2021-10-1412:48thhellerjust a direct require in ns is not allowed, indirect and lazy is fine#2021-10-1412:49thhellerby a -> c -> b I meant a.entry requires something.c which requires b.entry thus forcing b.entry to be moved since its supposed to be in :b but can't#2021-10-1412:50thhellerif it were allowed to be moved out then :b would end up empty and pointless#2021-10-1415:58achikinI’m trying to do a little demo showing shadow-cljs capabilities and as a part of a demo I’m installing an npm package, requiring it and rendering a view from it. Namely it’s react-calendar. But it seems like shadow does not pick up css automatically and I’m getting quite ugly calendar. Is there a way to solve that rather than including css directly to the index.html?#2021-10-1415:59thhellershadow-cljs does not support processing css#2021-10-1417:41achikin@thheller is there any preferred way to process css?#2021-10-1417:49thhellerthat is entirely subjective 😛 I use tailwind-css similar to this setup https://github.com/jacekschae/shadow-cljs-tailwindcss. some older projects of mine use node-sass#2021-10-1417:52thhelleror if you intend to use many packages that basically expect webpack (by directly using css) you can just use webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-10-1420:28Andrew LaiHi guys! I'm new to shadow-cljs, and working with shadow-cljs through a custom build pipeline in our monorepo. I'm getting an error when compiling, IOException: Cannot run program "node" I am still doing some research to figure out exactly how the build is being called and help refine this question, but do you have any suggestions for how to interpret this error? It seems like shadow expects to find a node executable somewhere, but it isn't finding the executable. Does node need to be in the same directory?#2021-10-1420:30thhelleryou need to have https://nodejs.org/en/ installed yes#2021-10-1420:31thhelleron the system path is enough, like any other executable. doesn't need to be in a special place#2021-10-1420:31Andrew LaiThank you! We are doing a special build process through Bazel, which may run in a sandboxed environment, so I think that's the next thing I'll check for. I'm wondering if Node isn't being installed properly in the sandboxed environment.#2021-10-1420:33thhellernever used bazel personally but other people have used it with shadow-cljs so it works in some way I guess :P#2021-10-1512:20AppleCan shadow-cljs also print out what the other two ports are for? nrepl/prepl/socket repl are they?
LISTEN 0    1000                      *:9630             *:*
LISTEN 0      50     [::ffff:127.0.0.1]:41491            *:*          
LISTEN 0      50     [::ffff:127.0.0.1]:46337            *:*          
LISTEN 0      50     [::ffff:127.0.0.1]:40289            *:*          
shadow-cljs - server version: 2.15.12 running at 
shadow-cljs - nREPL server started on port 46337
#2021-10-1515:17dvingothey are available in files in the .shadow-cljs dir
$ ls -1 .shadow-cljs/
babel-worker
builds
cli-repl.port
http.port
jar-manifest
nrepl.port
server.pid
server.token
socket-repl.port
#2021-10-1515:28AppleVery good.#2021-10-1602:34cjmurphyI'm getting the message SHADOW-CLJS FAILED TO LOAD! which goes on with "You are using shadow-cljs version: 2.11.4". The problem is that I shouldn't be on that version. These are the commands that let to the error:#2021-10-1602:34cjmurphy
yarn remove shadow-cljs
yarn add --dev 
Notice should be at 24 now, not 4.
#2021-10-1602:37cjmurphyMy problem is that the upgrade doesn't seem to be working. Could I have a global version of shadow that is overriding this? By the way going to the latest version (2.15.12) by leaving out the @ and what comes after gives the same result. I've even tried getting rid of cache directories, but after upgrading, no matter to which version, always get "You are using shadow-cljs version: 2.11.4".#2021-10-1602:48Applecould shadow have been installed globally?#2021-10-1602:48Applepreviously#2021-10-1602:49Applefind / 2>/dev/null | grep shadow#2021-10-1602:57cjmurphyEvery result from the command find / -name shadow-cljs 2>/dev/null ends up being under /home/chris. I'm not even sure what a global install of shadow would look like. I'll do some research in the docs, that will hopefully include how to get rid of the global install. (As it seems like the concept exists!).#2021-10-1602:59cjmurphyLooking promising. yarn global remove shadow-cljs said it worked.#2021-10-1603:02cjmurphyNope. Still says "You are using shadow-cljs version: 2.11.4", when I want it to say "You are using shadow-cljs version: 2.11.24". (I'm just moving the version on a little bit to diagnose the upgrading problem).#2021-10-1603:27Apple
$ ls -al /usr/bin/shadow-cljs 
lrwxrwxrwx 1 root root 45 Oct 15 22:43 /usr/bin/shadow-cljs -> ../lib/node_modules/shadow-cljs/cli/runner.js*
#2021-10-1603:27Apple-name shadow-cljs is probably fine to go through the system#2021-10-1603:29Appleecho $PATH what do you have#2021-10-1603:31cjmurphy
/home/chris/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/home/chris/.nvm/versions/node/v16.3.0/bin/
#2021-10-1604:35cjmurphyRunning yarn shadow-cljs info returns the correct version:
=== Version
jar:            2.11.24
cli:            2.11.24
deps:           1.3.2
config-version: 2.11.24
#2021-10-1604:59cjmurphyHmm - just noticed is in deps.edn as 2.11.4, so that's where it is picking up the wrong version.#2021-10-1605:10Applelol#2021-10-1605:16cjmurphyYeah :face_palm:. If it could just be defined in one place that would of course make it 'more full-proof'.#2021-10-1606:50thheller@U0D5RN0S1 yeah the package.json version is only used if you actually only use shadow-cljs.edn. if you use deps or lein the version needs to be managed there. that is quite intentional since "magic" injection doesn't work and only causes issues (eg. tools not recognizing it)#2021-10-1606:56cjmurphyOn another project you encouraged me to use shadow-cljs.edn for all cljs only deps, to get rid of a dependency conflict (something Datomic needed, forget what). So I might convert to that way here too. Then perhaps I can get rid of the shadow-cljs mention in deps.edn? If so then that's another win for only using shadow-cljs.edn.#2021-10-1606:58thhellerthat is entirely your choice. many people prefer to manage dependencies via deps.edn or project.clj#2021-10-1606:59thhellertools such as Cursive don't support shadow-cljs.edn so that is one reason for many to use deps.edn instead#2021-10-1607:00cjmurphyGood news. Seems like that's the best way. But I think the documentation does lead people towards using deps.edn, just by the order of explanations. I use Cursive but surely shadow-cljs.edn can just be a text file for me.#2021-10-1607:01thhellerits not about editing shadow-cljs.edn, that works fine but Cursive doesn't recognize dependencies in it#2021-10-1607:02thhellerso it won't find dependencies when you edit your code and display these red squigly lines for code it doesn't know about#2021-10-1607:04cjmurphyI see. I didn't notice the problem in the other project. ~I'll still convert and see how it works out.~ Thanks. I'll stick with shadow-cljs.edn till this gets answered: https://github.com/cursive-ide/cursive/issues/1804#issuecomment-314916994. Regardless the fix does seem a long way away.#2021-10-1614:01geraldodev@p-himik Hi, have you been able to solve the "`_system.keyframes is not a function" . I'm getting this too with material-ui 5 and don't know what is the root cause.`#2021-10-1614:09thhelleras a temporary workaround/fix try setting :js-options {:entry-keys ["module" "browser" "main"]} in your build config. otherwise the code doesn't seem to be rewritten properly due to a bug in GCC#2021-10-1617:02Benjaminin cider repl I get this
No available JS runtime.
See 
I also saw it working once though. What can go wrong? Cider also deosn't seem to connect my apps buffers with the repl
#2021-10-1618:19chaosHi, you most probably need to load your app on the browser for the REPL to connect to (via the shadow server). There should be an *nrepl-server xxx :localhost* buffer in emacs telling you the address of the development server to connect to in your browser for loading the js runtime. You should see something like shadow-cljs - server version: 2.15.12 running at if you are running the browser-repl special build or shadow-cljs - HTTP server available at if you have declared a :dev-http server in shadow-cljs.edn.#2021-10-1618:59thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2021-10-1707:49Benjamin
shadow-cljs - server version: 2.10.22 running at 
yea I opened this in the browser and now it works. Not sure if I also need to click compile there once? Either I was daft about it or the user guide could be more explicit about how to have the parts. (like with a warning > you should connect these 2 things or sth) shouldn't it say it here as well because I did the steps and then was stuck https://shadow-cljs.github.io/docs/UsersGuide.html#cider but yea thanks a lot 🙂 🎉
#2021-10-1707:59chaosDidn't cider prompt you to connect to that address with a Visit in a browser? (y or n) message?#2021-10-1808:30thhelleryou do not need to open the thing on 9630 for the REPL to work. just your code needs to be loaded somewhere. I don't know why cider is even offering to open that#2021-10-1811:00chaosIt appears that cider will prompt the user to open on the default browser the server configured in :dev-http or the url when no :dev-http entry is configured in shadow-cljs.edn; If the user selects to run the browser-repl, then cider will also open, without prompting, in the default browser. Thus cider will make an effort to open the user code/browser-repl on the default browser hence loading the "js runtime".#2021-10-2007:36rbergerI seem to no longer be able to get shadow-cljs to run with SSL on the Mac. I think Apple (and others?) no longer supports self-signed certificates. Or I’m just doing something stupidly wrong. But the same exact setup with the same keystore that worked in June is no longer working. I’ve tried to create a new keystore with a private CA and a server cert and that isn’t working ether. But I have no way to tell where the problem is. Shadow-cljs starts up fine saying
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.15.8 running at 
But the browsers won’t connect to ether saying
Safari can't open the page "" because Safari can't establish a secure connection to the server "discovery.local".
And Chrome says:
This site can't provide a secure connectiondiscovery.local sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
I suspect my problem may be how I’m setting up the certs and the keystore. I’ve tried a few different instructions and it all goes together without errors, but I don’t know how to confirm that the keystore or any of its inputs are actually correct. The link in the Shadow user guide for setting up the certs for the Mac is 404 https://certsimple.com/blog/localhost-ssl-fix My shadow-cljs.edn file:
{:deps  true
 :nrepl {:port 8777}
 :ssl {:keystore "ssl/keystore.jks"
       :password "super-secret}
 :dev-http {8020 {:root "resources/public"
                  :host "discovery.local"}}
 :http {:host "discovery.local"}

 :builds {:app {:target     :browser
                :output-dir "resources/public/js/compiled"
                :asset-path "/js/compiled"
                :modules    {:app {:init-fn visx.dashboard.core/init}}
                :js-options
                {:resolve
                 {"@daily-co/daily-js"
                  {:target :npm
                   :require "@daily-co/daily-js/dist/daily-iframe-esm.js"}}}
                :release {:output-dir "dist/js/compiled"
                          :compiler-options
                          {:infer-extern :auto
                           :closure-defines
                           {goog.debug.LOGGING_ENABLED           true
                            re_frame.trace.trace_enabled?        false
                            day8.re_frame.tracing.trace_enabled? false}}}}
          :test {:target    :node-test
                 :output-to "out/node-tests.js"
                 :ns-regexp "-test$"
                 :autorun   true}}}
I’m running shadow-cljs 2.15.8 Any suggestions on how to debug / make work, or some current known working guide to create certs and the keystore?
#2021-10-2007:39thhellergreat another 404 ... why can't people keep their pages online 😛#2021-10-2007:39thhellerthe problem isn't in the cert or the keystore. you need to configure your mac to accept that cert#2021-10-2007:40thhelleruse https://github.com/FiloSottile/mkcert to create the cert and register it maybe#2021-10-2007:41thhelleryou can register it manually in mac but I can't remember how exactly#2021-10-2007:44thhellerI don't think you should be setting :http {:host "discovery.local"} at all#2021-10-2007:45thhellerand likely :dev-http {8020 "resources/public"} should be fine too?#2021-10-2007:46thhellerI mean you are limiting the hosts it binds to by specifically setting :host. so it might be binding to the wrong network adapter or so#2021-10-2007:46thhellerjust leave it out and it'll bind to all. under which hostname you access it doesn't really matter#2021-10-2017:00rbergerSo if I leave out the host, it binds to 0.0.0.0 (ie all interfaces)? I think I tried that but it was late#2021-10-2017:09thhelleryes#2021-10-2106:12rbergerThe link to mkcert was a great help. I got it all to work. I wrote up a quick blog post that put it all together in one place https://dev.to/rberger/set-up-ssltls-for-shadow-cljs-https-server-2np7#2021-10-2111:29martinklepschHas anyone gone through the process of upgrading to the Firebase SDK v9? For a require like ["firebase/compat/auth"] I’m getting the following error. According to https://firebase.google.com/docs/web/modular-upgrade#update_imports_to_v9_compat it should be a drop in replacement.#2021-10-2504:48jacekschaeFor Firebase v9 1. Update shadow-cljs to at least 2.15.8 in package.json  “shadow-cljs”: “2.15.8" 2. Add :js-options in shadow-cljs.edn under :app (the same place where :target, :output-dir, :asset-path, :modules, and :devtools are)
{:source-paths ["src"]

 :dependencies [[binaryage/devtools "0.9.10"]
        [proto-repl "0.3.1"]
        [reagent "0.8.0"]]

 :nrepl    {:port 3333}

 :builds
 {:app {:target :browser
    :output-dir "public/js"
    :asset-path "/js"

    :modules
    {:main
     {:entries [giggin.core]}}

     :js-options {:babel-preset-config {:targets {"chrome" "80"}}}

    :devtools
    {:after-load giggin.core/main
     :http-root "public"
     :http-port 3000}}}}
I had to figure this out as Firebase is part of the Learn Reagent course
#2021-10-2709:46martinklepschThank you @U8A5NMMGD! #2021-10-2714:22martinklepschIs babel-preset-config documented anywhere? I can’t find it in the Shadow CLJS Guide#2021-10-2800:45jacekschaethere are a couple of these knobs that seem not to documented 😛#2021-10-2800:45jacekschaemaybe would be wort to put this in @U05224H0W ?#2021-10-2804:03thhellerthis shouldn't be required or do anything anymore? I bumped the default to be chrome 90 so I doubt this does anything?#2021-10-2804:03thheller:babel-preset-config is not documented since it is temporary and will be removed once I figure out how to remove babel completely#2021-10-2116:48thheller@martinklepsch that warning only tells you which files failed to load. the reason why is elsewhere. I can't diagnose anything based on that warning alone 😛#2021-10-2116:49thhellerI improved that error message a bit in 2.5.12#2021-10-2117:53raymcdermottI'm trying to use clojure.core.specs.alphabut am getting a runtime error ...#2021-10-2117:53raymcdermott
Uncaught Error: Unable to resolve spec: :cljs.core.specs.alpha/defn-args
#2021-10-2117:54raymcdermottdo I have to do something to make it available at runtime?#2021-10-2117:55raymcdermott
ls resources/public/js/cljs-runtime | grep core.specs
cljs.core.specs.alpha.js
cljs.core.specs.alpha.js.map
#2021-10-2117:56raymcdermottthe map shows
(:require-macros [cljs.core.specs.alpha]))
#2021-10-2118:07borkdude
ClojureScript 1.10.879
cljs.user=> (require 'cljs.core.specs.alpha)
nil
#2021-10-2118:10thheller@raymcdermott all specs in that ns only exist on the macro side so you can only use them in macros#2021-10-2118:36raymcdermotthow do you mean?#2021-10-2118:38borkdudedoes cljs re-use core.specs.alpha from the clojure side?#2021-10-2118:39borkdudei.e. there is no .cljs file with these specs.#2021-10-2118:39raymcdermottOh ... do I have to use them on the CLJ side via macros and then access those functions from CLJS?#2021-10-2118:41raymcdermott@borkdude it's a CLJC file and CLJS#2021-10-2118:43raymcdermotthttps://github.com/clojure/clojurescript/tree/aec9f0c576ac6b11d3e30e79553c8ebe67bf0f73/src/main/cljs/cljs/core/specs#2021-10-2118:47borkdude@raymcdermott as a workaround you could copy this file and rename the ns and then load it as .cljs. This works, I pasted it in the REPL ;)
cljs.core.specs.alpha=> (s/get-spec ::defn-args)
{:cljs.spec.alpha/op :cljs.spec.alpha/pcat,
#2021-10-2118:50thhelleryeah, just copy the contents of the cljc file into a namespace you control#2021-10-2118:51borkdudeappropriate name suggestion: core.specs2.alpha :P#2021-10-2119:17raymcdermottwhat a pair of hackers 🙂#2021-10-2119:36raymcdermottI'm gonna do that of course#2021-10-2216:15Drew Verleewhat does yellow mean, in a shadow cljs build 😆#2021-10-2216:29thhelleryellow?#2021-10-2217:56Drew Verlee#2021-10-2218:02thhellerclick it 😛 means the build had warnings#2021-10-2413:00ghaskinsHello…im trying to upgrade my app from @material-ui v4.x to @mui v5.x and getting an error that doesnt make sense to me#2021-10-2413:00ghaskinsA bunch of components throw this on start up#2021-10-2413:04ghaskinsAny hints appreciated#2021-10-2413:14thheller@ghaskins set :js-options {:entry-keys ["module" "browser" "main"]} in your build config. I haven't entirely figured out what causes this error#2021-10-2413:28ghaskins@thheller awesome, Ty. Will try shortly #2021-10-2413:38ghaskinsthat worked perfectly, ty!#2021-10-2506:28David Pham@ghaskins Does the text input component works in v5, or did the old v4 trick work? I want to make the migration as well, any hint would be welcomed!#2021-10-2510:01Ben HaltonIt doesn't work, and the old trick does not work, if by work you mean allows you to edit text without cursor jumping#2021-10-2510:03Ben HaltonI ended up crafting my own solution which seems to hang together#2021-10-2512:35David PhamCan you share your solution? :)#2021-11-0216:53Ben Haltonhi @neo2551 @ghaskins sorry I haven't been around much in the last week or so have extracted a very rough cut of what I have below#2021-11-0216:53Ben Halton
(defn controlled-text-field []
  (let [cursor-position (atom nil)]
    (reagent/create-class
     {:component-did-update (fn [this]
                              (let [dom-node (rdom/dom-node this)
                                    input (aget (.getElementsByTagName dom-node "input") 0)]
                                (.setSelectionRange input @cursor-position @cursor-position)))
      :reagent-render
      (fn []
        [:> TextField
         {:label "controlled text field"
          :type "text"
          :fullWidth true
          :size "small"
          :value
          (or
           @(re-frame/subscribe [::subs/my-sub])
           "")
          :onChange
          (fn [event]
            (reset! cursor-position (-> event .-target .-selectionStart))
            (re-frame/dispatch
             [::events/update-value (-> event .-target .-value)])
            )}])})))
#2021-11-0216:53Ben Haltonit seems to hang together#2021-11-0216:53Ben Haltonbut I make no real claims for reliability !#2021-11-0216:57ghaskinsThank you!#2021-10-2510:37kopioHey, I'm in the midst of migrating a cljs project to shadow-cljs. Everything is working fine, except that I am not able to run tests. The docs suggest that it is enough to add test namespaces with -test prefix but the following configuration does not seem to work when running npx shadow-cljs compile test . The build completes without errors but zero tests are run. Do I need to setup a custom test runner for this?#2021-10-2511:20thheller[cljs.test :refer :all] is not valid in CLJS so I suppose your compilation fails?#2021-10-2511:21thhellerotherwise should be fine#2021-10-2511:24thheller
[:test] Compiling ...
------ ERROR -------------------------------------------------------------------
 File: /mnt/c/Users/thheller/code/tmp/cljs-test/test/cljs/cljs_test/some_test.cljs:1:1
--------------------------------------------------------------------------------

   1 | (ns cljs-test.some-test
-------^------------------------------------------------------------------------
null
Invalid namespace declaration
-- Syntax error -------------------

  (... ... (:require [cljs.test :refer :all]))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

has extra input

-- Relevant specs -------

:shadow.build.ns-form/ns-form:
  (clojure.spec.alpha/cat
   :ns
   '#{clojure.core/ns}
   :name
   clojure.core/simple-symbol?
   :docstring
   (clojure.spec.alpha/? clojure.core/string?)
   :meta
   (clojure.spec.alpha/? clojure.core/map?)
   :clauses
   :shadow.build.ns-form/ns-clauses)

-------------------------
Detected 1 error

--------------------------------------------------------------------------------
   2 |   (:require [cljs.test :refer :all]))
   3 |
   4 | (deftest some-test
   5 |   (testing "that it is true"
--------------------------------------------------------------------------------

:error
#2021-10-2511:24thhellerthis is what I get#2021-10-2511:34kopioOh yeah, right, that was actually a change I made in the middle of debugging. The original require was [cljs.test :refer-macros [deftest is testing]] but changing that to [cljs.test :refer [deftest is testing]] fixed the issue, thanks for the help!#2021-10-2512:29ghaskins@neo2551 I havent tried beyond my simple login form, so far. That form in particular uses React setState for state management, and it seems that the textfields do work fine at least there. I havent tried my larger app that has r/atom based controlled inputs.#2021-10-2512:30ghaskins@gingerwizard id be interested in learning about your solution, if you are willing to share#2021-10-2512:40Ben Haltonhappy to, it's something I worked on a bit and seemed OK, but I've been away on holiday and just back so not tested thoroughly. AFK right now but will get a snippet together later#2021-10-2614:19Drew Verleewill shadow-cljs watch also install new deps added to a deps.edn file?#2021-10-2614:26Applei dont think shadow-cljs touches deps.edn#2021-10-2614:29Mateusz MazurczakIt won't#2021-10-2614:34Applepackage.json did you mean? i would think so.#2021-10-2615:34thhellershadow-cljs never installs anything automatically during watch, regardless of how the dependencies are managed. only on startup#2021-10-2620:07DiegoJust installed react-select in a project of mine,and getting this error when trying to require "react-select/creatable"
FileNotFoundException: .shadow-cljs/builds/browser/dev/shadow-js/module$node_modules$$emotion$react$isolated_hoist_non_react_statics_do_not_use_this_in_your_code$dist$emotion_react_isolated_hoist_non_react_statics_do_not_use_this_in_your_code_browser_cjs.js (File name too long)
Any idea how to solve this?
#2021-10-2620:11thhellerlol, hmm no immediate ideas other than using webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2021-10-2620:15DiegoI see, thanks#2021-10-2707:50thheller@diego.vid.eco I can't reproduce that problem? which OS is this? I'm on windows 10 and its working fine? supposedly you can increase the max filename length on windows? https://helpdeskgeek.com/how-to/how-to-fix-filename-is-too-long-issue-in-windows/#2021-10-2718:10DiegoI am on Linux Mint, I guess it may be possible#2021-10-2718:11DiegoDidn't try it as I wouldn't want to risk having problems when building somewhere else. In the end I opted for another library.#2021-10-2707:53thheller(I have not done this but maybe fixes your issue?)#2021-10-2708:35pmooserI have a question about the output of the :node-script option. I used it successfully, but in the mode that I had built things, the node script that was output still had some dependencies back into the build directory. Is that expected, or a characteristic somehow of the build that I specified? Do you know offhand?#2021-10-2708:41pmooser(I mean like SHADOW-IMPORT-PATH sorts of things)#2021-10-2708:51pmooserOk maybe this is just the difference between doing a compile vs release in this case.#2021-10-2708:58thheller@pmooser yes, compile is only meant to run in the place where it is created. release you can move around. it'll still require access to the npm modules you used though#2021-10-2709:01pmooserAh, interesting. So I guess that means ... you can't really move the result between machines unless your npms are installed globally (and presumably the versions match etc) ?#2021-10-2709:01thhellerno not at all#2021-10-2709:02thhellerjust need to consider how you move things arround#2021-10-2709:02thhellerif you want something that is completely self contained you can post process the output with something like https://github.com/vercel/ncc#2021-10-2709:03thhellerif you make it a npm package you just include a package.json and that'll take care of installing the dependencies for you#2021-10-2709:03thhellerand no never install any npm packages globally#2021-10-2709:03thhellerits pretty much the same in clojure with using a jar vs uberjar, if that means anything to you#2021-10-2709:04thhellerjar won't run without dependencies, uberjar will#2021-10-2709:04thhelleruberjar = post processed with ncc#2021-10-2709:04pmooserHmm, thanks very much for that link. I don't understand quite enough about npm to understand (yet) how to do it myself but that project looks like it might be the perfect thing. What I was experimenting with was using the node-script capability to be able to make some scripts that can do some batch processing on data that our app uses, but without involvement of our normal client/server ...#2021-10-2709:04pmooserIt's really a very nice capability!#2021-10-2709:04pmooserYeah, I understand jar vs uberjar.#2021-10-2709:06pmooserOne more (stupid) question - is it feasible to just install the npms myself in the directory where I run the script, as opposed to using a packaging utility like the one you linked?#2021-10-2709:06pmooserAlthough the thing you linked looks very easy to use.#2021-10-2709:07thhellercreate a directory. put a package.json into it. put the :node-script output into it. copy that directory to wherever, run npm install then you can run your script just fine#2021-10-2709:07thhellerjust declare the runtime dependencies of your script in the package.json and npm install will install them#2021-10-2709:08pmooserOk - thanks thheller!#2021-10-2713:41Mateusz MazurczakHi! I get an error after I updated libraries (it was a long time since they were updated)
Execution error (FileNotFoundException) at clojure.main/main (main.java:40). Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.                                                           
I have thheller/shadow-cljs in my deps.edn. The version in deps.edn and in yarn.lock is the same.
thheller/shadow-cljs {:mvn/version "2.15.12"}
Any ideas?
#2021-10-2713:42thhelleris deps.edn formatted correctly?#2021-10-2713:42thhellersometimes things slip into other maps and such#2021-10-2713:43Mateusz MazurczakYeap, no errors in intellij#2021-10-2713:43thheller
{:deps {some/thing {:mvn/version "1.2.3
            thheller/shadow-cljs {:mvn/version "4.5.6"}}}
#2021-10-2713:43thhellerthat would give no error but still be incorrect#2021-10-2713:44Mateusz Mazurczak
{:aliases
 {
  ;; start a modern nREPL server on port 4000:
  :nrepl {:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}}
          :main-opts ["-m" "nrepl.cmdline"
                      "--bind" "0.0.0.0"
                      "--port" "4000"]
          :jvm-opts ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5010"]}

  :cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.15.12"}
                      com.cognitect/transit-cljs {:mvn/version "0.8.256"}
                      reagent/reagent {:mvn/version "1.1.0"
                                       :exclusions [cljsjs/react cljsjs/react-dom]}
                      secretary/secretary {:mvn/version "1.2.3"}
                      hiccups/hiccups {:mvn/version "0.3.0"
                                       :exclusions [cljsjs/react cljsjs/react-dom]}
                      cljs-http/cljs-http {:mvn/version "0.1.45"}
                      bidi/bidi {:mvn/version "2.1.6"}
                      noencore/noencore {:mvn/version "0.3.4"}
                      medley/medley {:mvn/version "1.2.0"}
                      reagent-utils/reagent-utils {:mvn/version "0.3.4"
                                                   :exclusions [cljsjs/react cljsjs/react-dom]}
                      com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
                      org.clojure/core.match {:mvn/version "0.3.0-alpha5"}
                      garden/garden {:mvn/version "1.3.6"}
                      alandipert/storage-atom {:mvn/version "2.0.1"}
                      frankiesardo/linked {:mvn/version "1.3.0"}
                      markdown-clj/markdown-clj {:mvn/version "1.0.7"}

                      ;; [Devtools]()
                      ;; adds custom formatters support for ClojureScript to
                      ;; Chrome, so that ClojureScript data can be
                      ;; comfortably inspected in the Chrome Dev Tools
                      ;; Console. Shadow-CLJS automatically activates
                      ;; cljs-devtools for every dev build, when it is on
                      ;; the classpath, see:
                      binaryage/devtools {:mvn/version "0.9.10"}

                      cider/cider-nrepl {:mvn/version "0.26.0"}
                      }
         :extra-paths ["src/cljs"]}

  :pack {:extra-deps
         {pack/pack.alpha
          {:git/url ""
           :sha "511c32d4238afb860ad0b16c4827322d80c7d615"
           :exclusions [org.slf4j/slf4j-nop]}}
         :main-opts
         ["-m"]}
  }

 :jvm-opts [
            ;; added to prevent exceptions with no stacktraces, see:
            ;; 
            "-XX:-OmitStackTraceInFastThrow"
            ]

 :paths ["src/clj" "src/cljc" "src/cljs" "resources" "classes"]

 :mvn/repos {"" {:url ""}
             "central" {:url ""}
             "clojars" {:url ""}}

 :deps {org.clojure/clojure {:mvn/version "1.10.3"}
        org.clojure/core.cache {:mvn/version "1.0.217"}
        org.clojure/core.memoize {:mvn/version "1.0.250"}
        org.clojure/core.async {:mvn/version "1.3.622"}
        org.clojure/core.match {:mvn/version "1.0.0"}
        com.cognitect/transit-clj {:mvn/version "1.0.324"}
        com.cognitect/anomalies {:mvn/version "0.1.12"}

        nrepl/nrepl {:mvn/version "0.8.3"}

        expound/expound {:mvn/version "0.8.10"}
        ring/ring-core {:mvn/version "1.9.4"}
        ring/ring-servlet {:mvn/version "1.9.4"}
        ring/ring-ssl {:mvn/version "0.3.0"}
        javax.servlet/servlet-api {:mvn/version "2.5"}
        clj-time/clj-time {:mvn/version "0.15.2"}
        org.clojure/tools.namespace {:mvn/version "1.1.0"}
        medley/medley {:mvn/version "1.3.0"}
        io.sentry/sentry-clj {:mvn/version "5.2.158"}
        ring-middleware-format/ring-middleware-format {:mvn/version "0.7.4"}
        ring-partial-content/ring-partial-content {:mvn/version "2.0.1"}
        ring-cors/ring-cors {:mvn/version "0.1.13"}
        bk/ring-gzip {:mvn/version "0.3.0"}
        cheshire/cheshire {:mvn/version "5.10.1"}
        org.shredzone.acme4j/acme4j-client {:mvn/version "2.12"}
        org.shredzone.acme4j/acme4j-utils {:mvn/version "2.12"}
        noencore/noencore {:mvn/version "0.3.6"}
        environ/environ {:mvn/version "1.2.0"}
        sv/blob-storage {:mvn/version "0.1.0"}
        sv.blob-storage/file-blob-storage {:mvn/version "0.1.0"}
        sv.blob-storage/gcloud-storage {:mvn/version "0.1.2"}
        com.draines/postal {:mvn/version "2.0.4"}
        hiccup/hiccup {:mvn/version "1.0.5"}
        buddy/buddy-auth {:mvn/version "3.0.1"}
        me.raynes/fs {:mvn/version "1.4.6"}
        digest/digest {:mvn/version "1.4.10"}
        markdown-clj/markdown-clj {:mvn/version "1.10.6"}
        clj-http/clj-http {:mvn/version "3.12.3"}

        sv/system.core {:mvn/version "0.1.1"}
        sv/system.datomic {:mvn/version "0.1.0"
                           :exclusions [org.slf4j/log4j-over-slf4j
                                        com.datomic/datomic-free]}
        sv/system.main {:mvn/version "0.1.0"}
        sv/system.httpkit {:mvn/version "0.1.0"}

        ;; it is important to use a recent version of
        ;; http-kit since the older version 2.1.18 caused a
        ;; downtime of the leader server due to this issue:
        ;; 
        http-kit/http-kit {:mvn/version "2.5.3"}

        sv/system.ring {:mvn/version "0.1.0"}

        ;; logging:
        com.taoensso/timbre {:mvn/version "5.1.2"}
        sv/timbre.gcloud.logging {:mvn/version "0.1.4"}
        com.fzakaria/slf4j-timbre {:mvn/version "0.3.21"}
        org.slf4j/log4j-over-slf4j {:mvn/version "1.7.32"}
        org.slf4j/jul-to-slf4j {:mvn/version "1.7.32"}
        org.slf4j/jcl-over-slf4j {:mvn/version "1.7.32"}

        ;; using a newer version here, since it has a
        ;; better `DefaultCredentialProvider` that also
        ;; resolve the application-default-credentials inside
        ;; a docker container via Google Cloud's metadata
        ;; service ``
        com.google.api-client/google-api-client {:mvn/version "1.32.2"}

        sv/gcloud.client {:mvn/version "0.1.4"}
        com.google.guava/guava {:mvn/version "27.0.1-jre"}
        com.google.cloud/google-cloud-storage {:mvn/version "2.1.9"}
        etaoin/etaoin {:mvn/version "0.4.6"}
        clj-chrome-devtools/clj-chrome-devtools {:mvn/version "20200423"}
        com.datomic/datomic-pro {:mvn/version "0.9.5561"
                                 :exclusions [org.slf4j/log4j-over-slf4j
                                              org.slf4j/slf4j-nop]}

        ;; Datomic production storage backend:
        mysql/mysql-connector-java {:mvn/version "8.0.27"}
        ;; for the development environment:
        org.postgresql/postgresql {:mvn/version "42.3.0"}

        com.google.cloud.sql/mysql-socket-factory {:mvn/version "1.3.4"}

        ;; For  to verify webhook requests:
        com.xk72/paddle-webhook-verifier {:mvn/version "1.0"}

        io.grpc/grpc-core {:mvn/version "1.41.0"}
        org.clojure/data.csv {:mvn/version "1.0.0"}
        com.datomic/client-pro {:mvn/version "1.0.72"}
        com.datomic/client-cloud {:mvn/version "1.0.117"}
        danlentz/clj-uuid {:mvn/version "0.1.9"}
        fipp/fipp {:mvn/version "0.6.24"}
        borkdude/sci {:mvn/version "0.2.7"}
        diehard/diehard {:mvn/version "0.10.4"}

        sv/basis {:local/root "basis"}

        sv/message-emit {:git/url ""
                         :sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
                         :deps/root "message-emit"}

        sv/message-logging {:git/url ""
                            :sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
                            :deps/root "message-logging"}

        sv/memcached-auto-discovery {:git/url ""
                                     :sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
                                     :deps/root "memcached-auto-discovery"}

        sv/registry {:git/url ""
                     :sha "e2ad34537505cd7c9e015d88fc4db1da8a42a06f"
                     :deps/root "registry"}
        sv/peer-sci {:git/url ""
                     :sha "590932368d57d09fb475b946b5214996a9abb23f"
                     :exclusions [sv/slf4j-gke-logging]}
        }
 }
#2021-10-2713:46Mateusz MazurczakPreviously it was working and in the PR there is no changes that breaks formatting/typos etc#2021-10-2713:44thhellerdid you activate the alias?#2021-10-2713:50Mateusz Mazurczakwhat do you mean?#2021-10-2713:51thhellerhow did you launch shadow-cljs?#2021-10-2713:55Mateusz Mazurczakvia clojure#2021-10-2713:56thhellerwhat does that mean?#2021-10-2713:57thhellerthe error you get means that shadow-cljs is NOT on the classpath#2021-10-2713:57thhellerso whatever you launched did NOT add the :cljs :extra-deps#2021-10-2713:58thhellerdon't know what else to tell you. look at the command you run and see if that properly activates the :cljs alias#2021-10-2713:50thhellerwhen/how do you get the error? everything looks correct so far#2021-10-2713:51Mateusz MazurczakI get it while running yarn release#2021-10-2713:52thhellerwhat does that run?#2021-10-2714:00Mateusz Mazurczak
yarn install --frozen-lockfile && yarn gulp && yarn shadow-cljs release client --source-maps && yarn build-tailwind
#2021-10-2714:01Mateusz Mazurczakso I guess this is what you asked for yarn shadow-cljs release client --source-maps#2021-10-2714:01thhelleryes. so in shadow-cljs.edn do you have :deps {:aliases [:cljs]}?#2021-10-2714:01Mateusz Mazurczakyeap#2021-10-2714:02Mateusz Mazurczak
:deps {:aliases [:cljs]}
#2021-10-2714:04thhellerso what is the output of yarn shadow-cljs release client#2021-10-2714:05thhelleror just run yarn shadow-cljs clj-repl#2021-10-2714:11thhelleranything?#2021-10-2714:16Mateusz Mazurczaksorry for the delay#2021-10-2714:17thhellerand clj -A:cljs -M -m shadow.cljs.devtools.cli clj-repl?#2021-10-2714:35Mateusz Mazurczak
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "b7d3d2c1f7d5c2dedbd39a87"}, :content ("[email protected]")}
#2021-10-2714:37Karol Wójcik@U0281QDFE1X Stepped upon the same. Remove .cpcache & try clj -Sforce This might happen if you remove $HOME/.m2#2021-10-2714:48martinklepschI got back around to looking into the Firebase upgrade and we’re still seeing the “could not load” error when using the compat modules
shadow-cljs - failed to load module$node_modules$firebase$compat$auth$dist$index_esm
There is a file node_modules/firebase/compat/auth/dist/index.esm.js and we’re not seeing any errors pointing in that direction in the server logs.
#2021-10-2714:48thheller@martinklepsch again: this is NOT the error. this is a warning of the file that failed to load. the error is below or above depending on the shadow-cljs version you use#2021-10-2714:49thhellerso tell me the error and I can maybe help you, just this warning is not enough#2021-10-2714:49martinklepschOhhhh, duh, I’m so sorry, I assumed “elsewhere” meant outside the context of the browser#2021-10-2714:50thhellerno elsewhere in the console#2021-10-2714:50martinklepsch
TypeError: (0 , _app._registerComponent) is not a function
    at eval (index-f41a0691.js:11897)
    at Object.shadow$provide.module$node_modules$$firebase$auth$dist$esm2017$index_f41a0691 (index-f41a0691.js:12019)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$firebase$auth$dist$esm2017$internal (internal.js:556)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$$firebase$auth_compat$dist$index_esm2017 (index.esm2017.js:6)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.module$node_modules$firebase$compat$auth$dist$index_esm (index.esm.js:4)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
This is the error that follows the warning above
#2021-10-2714:50martinklepschSorry for my misunderstanding#2021-10-2714:51thhellerhmm yeah this appears to be a bug in the closure compiler#2021-10-2714:51thhellerbut we can't currently upgrade without a new cljs release#2021-10-2714:51martinklepschbtw I’ve also tried the approach https://clojurians.slack.com/archives/C6N245JGG/p1635137311018500?thread_ts=1634815794.002200&amp;cid=C6N245JGG (using :babel-preset-config {:targets {"chrome" "80"}})#2021-10-2714:52thhellerthat doesn't matter. typescript started rewriting some code to use the (0, whatever) trick#2021-10-2714:52martinklepsch(but doesn’t seem to affect this)#2021-10-2714:52thhellerbut closure doesn't like that and rewrites it in a weird broken way#2021-10-2714:54thhellermaybe setting :js-options {:entry-keys ["module" "browser" "main"]} in your build config can fix it#2021-10-2714:54thhellerbut that requires the package to actually publish non rewritten esm code#2021-10-2714:54thhellermaybe it does. not sure#2021-10-2715:01martinklepschShould "main" correspond to a module/entrypoint in our build or is this to be used as-is?#2021-10-2715:02thhelleras is. it only configures which key in package.json shadow-cljs uses when using npm packages#2021-10-2715:02thhellerhas nothing to do with your own code#2021-10-2715:02martinklepschOk. then it appears to cause the same error#2021-10-2715:11martinklepschI know there’s a CLJS release upcoming with a Closure upgrade, could it be worth to give that a try?#2021-10-2715:11thhellernot that simple unfortunately#2021-10-2715:11martinklepschWe’re not urgently looking for a solution but thought that maybe it’s nice to give feedback there#2021-10-2715:11martinklepschOk, then we’ll just wait a bit 🙂#2021-10-2715:11thhellerbecuase of many breaking changes in the closure compiler we need to upgrade GCC, CLJS and shadow-cljs at the same time#2021-10-2715:12thhellerI'm honestly beginning to regret using the closure compiler so much. it is getting tedious keeping up with their breakage#2021-10-2715:12thhellerso I might swap that out for another option at some point#2021-10-2715:20martinklepschThat sounds like a herculean effort to me but you probably have a much clearer picture of what that would look like 🙂#2021-10-2715:20martinklepschI’ll keep an eye on releases then, thanks for helping me understand what’s going wrong here 🙇#2021-10-2715:33thhellerI hope the issue is actually fixed in the newer closure compiler. currently hard to try but they fixed a bunch of problems related to the new TS and indirect calls#2021-10-2716:40Felipe Cortezwhat's the proper way to call a CSS watcher process when starting the shadow server? build hooks kind of work but don't detect changes to CSS files. more generally, what's the best of way of launching an "observer" process along shadow?#2021-10-2716:43thhellerI recommend a setup like this https://github.com/jacekschae/shadow-cljs-tailwindcss see the package.json using npm-run-all commands#2021-10-2716:44Felipe Cortezoh yeah, I think I saw a GitHub issue mentioning this! thanks!#2021-10-2808:26HukkaI can't figure that (0, whatever). Why does typescript do that, what's the trick?#2021-10-2809:17David VujicIs it the compiled/transpiled output to ES5? In that case, it might have to do with references, function calls and the this thing 😄#2021-10-2817:56thhellerhttps://stackoverflow.com/questions/5161502/indirect-function-call-in-javascript#2021-10-2817:56thhellerwhy they started doing this I don't know exactly#2021-10-2817:57thhellerI expect it has something to do with matching how ESM imported functions are called#2021-10-2809:30Franklinhello 👋 . I would appreciate your help here but I'm not certain if I have given enough info/context https://stackoverflow.com/questions/69751508/unclear-error-from-react-leaflet-with-shadow-cljs#2021-10-2810:11Franklinactually found a solution for this#2021-10-2818:33Otto Nascarellahi there sorry if I am asking something really stupid… when you configure your shadow-cljs project to run tests in the browser, it compiles all tests to a single file. are there intermediate steps for that compilation? I’ve been feeling that it is getting slower and slower as the project grows.#2021-10-2818:38thhellerI don't understand the question? I mean the more code you have the more time it is going to take to compile? do you use watch in which case it shouldn't matter much since its incremental and only recompiles what changes?#2021-10-2818:43thhellerbut I do agree that there needs to be a better test runner that doesn't always run all the tests. just need time to build it 😛#2021-10-2819:25Otto Nascarellayeah. compilation has watch. and we have some sort of way to choose the namespaces we wanna run tests on. but on each save, it takes quite a lot to change the interface…#2021-10-2819:25Otto Nascarellamy point was… ~the target folder you see each module from cljs-runtime in a separate js file. whereas the test files are all in one bundle.~#2021-10-2819:36Otto Nascarellain fact, it does have each module in a file (TIL)#2021-10-2819:49thhellerI don't understand why you want that though? it actually performs worse to load many files instead of one#2021-10-2819:52thhellerbut in watch is only hot-reloads the files that changes anyways so that is entirely different thing that is also much faster#2021-10-2821:33Brandon Olivierhas anybody used shadow-cljs much with electron?#2021-10-2821:33Brandon OlivierI’m having a lot of issues import ipcRenderer but, based on the electron docs themselves, I don’t understand why.,#2021-10-2823:18Brandon OlivierIn case anybody else has the same problem, I figured it out. You can no longer directly access ipcRenderer through electron in the renderer process. You have to access it in a “preload script” which you can access when you start the browser window. I just created a resources/preload.js file and added ipcRenderer to the window object. https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts#2021-10-2907:06thhellerare you sure you are "allowed" to do that? I mean that to me seems to represent the security issue that preload scripts are supposed to prevent?#2021-10-2907:08thhellerI haven't looked at electron stuff in a long time (long before preload scripts) but it might be feasible to create a special :target for this. too busy currently to figure it out though#2021-10-2909:37Andrew RudenkoHi! I have two compilation targets: :app (:react-native) :web (:browser) :app then goes to expo which compiles for ios, android and web Everything works like a charm. The problem is when I'm trying to use some components from an :app (react native components) in :web target, I'm getting errors like:
Errors encountered while trying to parse file
  node_modules/react-native/index.js
  {:line 14, :column 7, :message "cannot use keyword 'typeof' here."}
I do not quite understand what shadow-cljs target :react-native is doing, then what expo does to make it's working on the web, so it's hard for me to understand what I'm doing wrong. Did someone have a similar setup? Or maybe there are examples / blog posts about shadow-cljs/RN/web? Thank you
#2021-10-2916:15thheller@rudenkoco react-native packages are not directly usable in the browser so you cannot import those packages in a :browser build#2021-10-2916:16thhellernot sure what exactly expo does either but I guess it rewrites the react-native requires to something else#2021-10-3011:18Andrew Rudenko@thheller looks like it is all based on babel rewrites... awesome piece of technology... Ok, thank you.#2021-10-3112:36sheluchinI'm running into an error trying to use vega-lite. I am using the Portal project as an example. I have the same deps as here: https://github.com/djblue/portal/blob/master/package.json#L41-L43 And in my UI, I require ["vega-embed" :as vegaEmbed] as with here: https://github.com/djblue/portal/blob/master/src/portal/ui/viewer/vega.cljs#L3 I get this error after adding the require and building:
failed to resolve: ./iterator.js from prj/node_modules/vega-embed/build/vega-embed.js
{:require-from #object[java.io.File 0x28b055c "prj/node_modules/vega-embed/build/vega-embed.js"], :require "./iterator.js"}
ExceptionInfo: failed to resolve: ./iterator.js from prj/node_modules/vega-embed/build/vega-embed.js
	shadow.build.npm/find-file (npm.clj:464)
	shadow.build.npm/find-file (npm.clj:405)
	shadow.build.npm/find-resource (npm.clj:737)
	shadow.build.npm/find-resource (npm.clj:730)
	shadow.build.resolve/find-npm-resource (resolve.clj:122)
	shadow.build.resolve/find-npm-resource (resolve.clj:93)
	shadow.build.resolve/eval18692/fn--18695 (resolve.clj:262)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:80)
	shadow.build.resolve/find-resource-for-string (resolve.clj:69)
	shadow.build.resolve/resolve-string-require (resolve.clj:452)
	shadow.build.resolve/resolve-string-require (resolve.clj:435)
	shadow.build.resolve/resolve-require (resolve.clj:672)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:477)
	shadow.build.resolve/resolve-string-require (resolve.clj:435)
	shadow.build.resolve/resolve-require (resolve.clj:672)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:659)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:618)
	shadow.build.resolve/resolve-require (resolve.clj:669)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-deps/fn--18641 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:659)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:618)
	shadow.build.resolve/resolve-require (resolve.clj:669)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-entry (resolve.clj:679)
	shadow.build.resolve/resolve-entry (resolve.clj:678)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-entries (resolve.clj:693)
	shadow.build.resolve/resolve-entries (resolve.clj:684)
	shadow.build.modules/resolve-module/fn--19935 (modules.clj:252)
	shadow.build.modules/resolve-module (modules.clj:248)
	shadow.build.modules/resolve-module (modules.clj:238)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.build.modules/resolve-modules (modules.clj:258)
	shadow.build.modules/resolve-modules (modules.clj:257)
	shadow.build.modules/analyze (modules.clj:312)
	shadow.build.modules/analyze (modules.clj:303)
	shadow.build/resolve (build.clj:428)
	shadow.build/resolve (build.clj:422)
	shadow.build/compile (build.clj:460)
	shadow.build/compile (build.clj:453)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/eval21696/fn--21699 (impl.clj:457)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--21444/fn--21445/fn--21453 (util.clj:269)
	shadow.cljs.devtools.server.util/server-thread/fn--21444/fn--21445 (util.clj:268)
	shadow.cljs.devtools.server.util/server-thread/fn--21444 (util.clj:241)
Any idea what I'm doing wrong? I've deleted node_modules/ and reinstalled deps but it didn't help.
#2021-11-0102:17awb99Hi#2021-11-0102:17awb99I have the same issue.#2021-11-0102:17awb99And my source code DID NOT CHANGE#2021-11-0102:17awb99It was compiling before for YEARS.#2021-11-0101:52awb99I am getting a compile error of a project that was working. And I have no idea what it coudl be:#2021-11-0101:52awb99failed to resolve: ./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js {:require-from #object[java.io.File 0x41bf4c6e "/home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js"], :require "./iterator.js"} ExceptionInfo: failed to resolve: ./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js shadow.build.npm/find-file (npm.clj:464)#2021-11-0101:53awb99try { // add if support for Symbol.iterator is present require('./iterator.js')(Yallist$1); } catch (er) {}#2021-11-0101:53awb99the js code is from the module vega embed.js#2021-11-0101:53awb99I have no idea where iterator.js could come from. VEGA has 12 npm repos, and so many dependencies. typescript, etc.#2021-11-0101:53awb99I have no idea where to start.#2021-11-0107:03thheller@hoertlehner @alex.sheluchin that to me looks like a conditional require of some sort. shadow-cljs expects to find that file but doesn't. in fact nothing ever will find that so I don't know why that code is even in there. it appears to be new in the 6.20.0 release. 6.19.1 does not have it and likely compiles fine. or just create that file with just module.exports = function() {}; should be enough#2021-11-0107:14HukkaNot the first time something "unexpected" happens inside the Vega builds. I'll file an issue there about this too, but I don't have high hopes of getting it fixed unless someone understands their build system well enough and digs into it#2021-11-0107:17Hukkahttps://github.com/vega/vega-embed/issues/780 for those who are affected#2021-11-0107:20thhelleryeah, their entire build system seems rather messed up. no clue why this is in the released builds, it can't serve any purpose
var scripts$1 = {
    prebuild: "yarn clean && yarn build:style",
    build: "rollup -c",
    "build:style": "./build-style.sh",
    clean: "del-cli build build-es5 src/style.ts",
    prepublishOnly: "yarn clean && yarn build",
    preversion: "yarn lint && yarn test",
    serve: "browser-sync start --directory -s -f build *.html",
    start: "yarn build && concurrently --kill-others -n Server,Rollup 'yarn serve' 'rollup -c -w'",
    pretest: "yarn build:style",
    test: "beemo jest --stdio stream",
    "test:inspect": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
    prepare: "beemo create-config",
    prettierbase: "beemo prettier '*.{css,scss,html}'",
    eslintbase: "beemo eslint .",
    format: "yarn eslintbase --fix && yarn prettierbase --write",
    lint: "yarn eslintbase && yarn prettierbase --check",
    release: "auto shipit"
  };
#2021-11-0107:21thhellerseems to import the entire package.json just to get the version out#2021-11-0107:23HukkaThat indeed seemed to be the gist of their latest release#2021-11-0107:24HukkaI've gotten the feeling that perhaps build systems aren't their forte, but I don't know the background on how they then chose the tools they are using right now#2021-11-0107:25HukkaA shame, really. The library has/had great potential, but I guess is severly lacking just contributors/maintainers in general, or at least those well versed in JS tooling#2021-11-0111:59awb99Where do I have to crete this module.export ?#2021-11-0112:12sheluchin@hoertlehner you could just use "vega-embed": "6.19.1", in your package.json if you don't really need anything in the newest release. @U05224H0W and @U8ZQ1J1RR thanks for looking into this. Not the greatest start with vega, but it was recommended as a good starting point for charting, so I'm going to stick with it a while and see if issues like this are frequent.#2021-11-0112:18HukkaI rather see it as the end point, not the starting point. It's pretty heavy duty. But that's a discussion for another thread (and channel).#2021-11-0112:47awb99I fixed it by including this version. But I would like to know how I could fix it via the module.export.#2021-11-0112:47awb99I am using vega-embbed not directly, but I use react-vega#2021-11-0112:48awb99So I now have one additional dependency moure in my project.#2021-11-0112:48awb99So I would rather fix it with some kind of hack.#2021-11-0112:48awb99And who knows, it might be, that a new error appears in the future.#2021-11-0112:48awb99vega breaks OFTEN#2021-11-0112:50sheluchin@hoertlehner I think you can just include an iterator.js file with the contents module.exports = function() {};. https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries might be helpful.#2021-11-0113:07awb99thanks a lot @alex.sheluchin#2021-11-0117:00thhelleryeah you just put a iterator.js in the directory of the vega build file#2021-11-0117:00thheller./iterator.js from /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/vega-embed.js#2021-11-0117:01thhellermeans it was trying to find /home/florian/repo/gorilla/goldly/profiles/bundelci/node_modules/vega-embed/build/iterator.js but couldn't since it does not exist#2021-11-0120:31awb99but how can I add a directory to a npm temporary directory? I would need to first know when cljs watch has finihed getting the npm dependencies, so I could then manually add this file.#2021-11-0120:34sheluchinI think if you just put the file in a mirrored location somewhere on your classpath, it should get picked up correctly when building.#2021-11-0121:00thhellershadow-cljs watch doesn't get any npm dependencies ever
#2021-11-0121:00thhellerat most it is installed when you start shadow-cljs#2021-11-0121:01thhellerbut if you run npm install just before everything should already be ready and shadow-cljs won't install anything#2021-11-0121:01thhellerso you have the opportunity to modify whatever before shadow-cljs even runs#2021-11-0121:01thhellerbut ... best option to me seems to not use a broken release?#2021-11-0121:03sheluchinIt's not an extra dependency anyway if it's already a subdependency of something you use.#2021-11-0121:24awb99it would pick up a js file on the classpath?#2021-11-0121:36sheluchinAh, no, that's my mistake. You would need to put it next to the vega-embed.js file. But yeah, best option is to just roll back to a working release.#2021-11-0306:49HukkaComing back to this, would the module version of the vega-embed work better? That is, if you have :js-options {:entry-keys ["module" "browser" "main"]} in the build target.#2021-11-0306:50Hukkahttps://unpkg.com/browse/vega-embed@6.20.0/build/vega-embed.module.js seems to be packaged completely differently and doesn't seem to try to import the missing file#2021-11-0115:14Joshua SmockHi 👋 I have two targets that compile some of the same code, one :browser and one :npm-module. For some reason automatic externs inferring isn’t working in :npm-module (and adding a line like :compiler-options :externs ["externs.js"] doesn’t help either) and so I get warnings for the :npm-module target that don’t show up in the :browser target. The warnings seem to be coming from using imported Node modules (so they necessarily must be JS functions) Is there something that needs to be done additionally to get externs inferring to work for :npm-module?#2021-11-0117:03thheller@slack1338 for :browser shadow-cljs processes all JS and can infer a bunch of externs from that. for :npm-module that is not done since something else will provide the JS dependencies so you probably need a few more typehints#2021-11-0117:11Joshua SmockI’m guessing it’s not possible or simple to assume any node module is JS and automatically infer that anything imported from it is ^js?#2021-11-0117:27thhellerI cannot see your code so I don't know what you are talking about specifically#2021-11-0117:27thhellerfor npm imports this is already done yes#2021-11-0117:35Joshua SmockI’ll try to come up with a minimal reproduction case and post here when I do. In any case from what I can tell it seems that the same code, compiled using these different targets, leads to different inferences and at least in this case code that should be inferred at JS isn’t in the :npm-module target. I assume it’s because, as you mention, the :browser target processes the JS code while the :npm-module target doesn’t#2021-11-0117:57thhellerjust an example of the warning you get helps to infer what you are talking about#2021-11-0118:03thhellerI mean just adding the hints should solve it?#2021-11-0209:37Joshua SmockType hints would solve it but we don’t need them for our current app code (we don’t get warnings for the :browser compilation target) since the automatic externs inferring works in that case so it’s not a solution we would prefer to use if possible#2021-11-0217:39thhellerwhy not? they won't hurt the browser build and will in fact make it more reliable given that the compiler doesn't have to guess anymore.#2021-11-0310:31Joshua SmockWell, primarily because we don’t need them for the browser build. In any case I will make a minimal repro repo and share with you here later#2021-11-1119:43Joshua Smock@U05224H0W So we talked about adding type hints internally and are okay with it. I went ahead and tried to do it based on my understanding of how it should work and I think I uncovered a bug, but need more input - long story short in :target :npm-module target, if you use a JS function in a binding, and then later use that result in an anonymous function, it doesn’t seem to keep track of it even with a type hint and you’re forced to add a type hint in the anon function. https://github.com/jo-sm/shadow-externs-repro if you want to take a look, I tried to describe it as clearly as I can and am open to any ideas you have#2021-11-1120:08thhellerthis is somewhat expected. you are welcome to make a enhancement patch for CLJS but as of now externs inference is not that smart#2021-11-1120:13thhellerbut also kind of ambiguous. objects is a JS value as hinted (so probably an array) but you are map'ing over it and it does not automatically imply that each item in that array is also a JS value#2021-11-1120:14thhellercould be an array of CLJS maps, there is no way for the compiler to know this#2021-11-1120:35Joshua SmockSure, but the issue doesn’t appear with the :target :browser mode (even with externs inferring fully disabled), and it doesn’t get fixed with type hints as I understand them from the official reference. So I feel like something isn’t working as expected #2021-11-1121:01Joshua SmockAn alternative would be to just silence the warnings using :compiler-options {:warnings {:infer-warning false}} but I am also struggling to get that to work for :npm-module #2021-11-1214:40Joshua SmockAnyway, if you have any ideas how to get around this let me know. The simplest approach would be to just shut the warnings up but it doesn’t seem to work (if I’m misplacing or misspelling the option, let me know), but adding type hints is also viable, but it also seems to work in an unexpected way (if my repro and understanding are correct)#2021-11-1214:42thhellereverything is working as intended. you found the correct place to add the typehint. just do exactly that.#2021-11-1214:42thhellerexterns inference is never fully disabled#2021-11-1214:42thhelleryou are only disabling the warnings#2021-11-1214:42Joshua Smocksure, but disabling the warnings seems to do nothing#2021-11-1214:42thhellerand disabling the warnings will most likely lead to broken builds so just don't do it#2021-11-1214:42Joshua Smockthe warnings still appear in the terminal#2021-11-1214:43Joshua Smockin this specific case disabling the warnings is acceptable as this is for tests, not for the main build of our application#2021-11-1214:43thhellerimho you should still run your tests using :advanced release builds. still might catch issues in your main build#2021-11-1214:45Joshua SmockI’m a bit confused still - externs and :advanced aside, is it possible to disable warnings for :npm-module?#2021-11-1214:45thhelleryou can try setting :js-options {:generate-externs false} in your :browser build config#2021-11-1214:46thhellermaybe that gets you do the same place as :npm-module#2021-11-1214:46Joshua SmockI’m still missing the answer to my question 😅#2021-11-1214:46thheller:compiler-options {:infer-externs false} should turn off warnings#2021-11-1214:46Joshua Smockok#2021-11-1214:46Joshua Smocklet me try it#2021-11-1214:49thhelleryou can also set (set! *warn-on-infer* false) in a file after the ns or so to turn off all warnings in that file only#2021-11-1214:50thhellerbut I repeat that the warnings are there for a reason and you probably spent more time talking to me about that problem than adding a few ^js would take#2021-11-1214:50Joshua Smockah ok so :infer-externs false does indeed fix it. Does it work differently than just disabling the warning (or does disabling the warning not work as I expect, which is that it won’t output it if it encounters it)?#2021-11-1214:51thhelleryes it'll still do the exact same inference. just not warn about it.#2021-11-1214:51thhellerdisabling the warning likely just conflicts with the other setting defaulting to be enabled and overriding that setting#2021-11-1214:56Joshua SmockYeah it’s not that we are definitely going to disable the extern warnings - as you said they’re there for a reason - it’s more that we want to have the option to. In this specific case they’re being compiled for tests where we would expect the tests to fail for other reasons and this warning isn’t as relevant (unlike for the main build where it is more relevant). I was more trying to figure out why exactly the way that it seems like it should work according to the docs (adding :warnings {:infer-warning false} ) wasn’t#2021-11-0117:08thhellerand the warnings are not coming from import node modules. the warnings come from your cljs files#2021-11-0122:04cjmurphyyarn shadow-cljs server is supposed to open a process that runs forever, until Cntl C out of it. But this morning, after an (attempted) OS upgrade, this is what I'm getting:
[
The process terminates! Same with yarn shadow-cljs watch. Actually yarn shadow-cljs server works fine for another project, with these two lines popping up after the config line:
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.15.12 running at 
, and the process lasting forever as expected. There are no recently written log files to help diagnose, not in in the project root directory anyway.
#2021-11-0122:46cjmurphyFixed by first deleting the .shadow-cljs directory that must have become corrupted. Doubt it had anything to do with the OS upgrade.#2021-11-0206:52thhellershadow-cljs - connected to server is the hint. the server was already running#2021-11-0206:52thhellerby deleting .shadow-cljs you now likely have a zombie process thats no longer accessible. make sure to kill it manually.#2021-11-0207:24cjmurphyps -aux | grep shadow-cljs | less . Thanks.#2021-11-0316:19RyanHey all, not sure if this is right place to start for this, but how would I setup a user.cljs file for the shadow-cljs repl? I'm using intelliJ/Cursive.. would also be awesome if anyone had a tip for automagically running the (shadow/repl :app) on startup, just to save my colleagues from forgetting 🙂#2021-11-0317:08WestPersonally, I’ve never used a user.cljs and hot reloading worked fine for me. Also, I tend to run shadow-cljs watch [buildname] then connect to the repl that it runs.#2021-11-0319:25thhellera user.cljs can't do (shadow/repl :app)?#2021-11-0320:37RyanI bet it can 🙂 I'm not sure how to tell the repl to execute user.cljs#2021-11-0321:07thhelleryou can create a cljs/user.cljs on the classpath which the REPL include include automatically#2021-11-0321:08thhellerbut that still cannot execute (shadow/repl :app) so your intention of what this should be doing is unclear#2021-11-0414:15RyanI just couldn't figure out how to get the user.cljs to load at all, its not on the classpath tho so that explains it. I was also trying to figure out if user.cljs could do the init function, and failing that if there was any other way to achieve it I may not be thinking of, is all 🙂#2021-11-0410:06restenbany fix for OutOfMemoryError using shadow-cljs? I recently started encountering this, using shadow for our frontend build.#2021-11-0410:06restenb[2021-11-04 11:03:49.953 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}} OutOfMemoryError unable to create new native thread#2021-11-0410:55restenbok, figured it out I guess. should have checked java -version first. due to messed up system PATH issues, version 1.8 was being picked up instead of 1.11. shadow-cljs build fails on 1.8 I guess.#2021-11-0418:24thhellershadow-cljs works absolutely fine with 1.8. OutOfMemory means exactly that. Meaning your machine did not have enough available Memory to complete the operation. 1.11 got slightly better memory management so it might last a while longer but it'll not protect from it.#2021-11-0418:25thhellerregardless this has nothing to do with shadow-cljs per se. You can try to limit the amount of memory shadow-cljs gets via :jvm-opts ["-Xmx512M"] in shadow-cljs.edn but that can still OOM if your system is not able to provide 512mb of ram when needed#2021-11-0417:26lilactownwhen I reference a private var in another ns, I don't see any warnings like I would expect.#2021-11-0419:04thhellerplease check with the regular compiler. no clue if there is supposed to be a warning or if it needs to be enabled manually.#2021-11-0419:04thhellerprivate vars kinda suck so I never use them anyways 😛#2021-11-0420:06thhellereveryone running into issues with mui5 or other JS libs having weird TypeError: (0 , _app._registerComponent) is not a function like errors please try shadow-cljs 2.15.13#2021-11-0507:03HukkaThis has been quite elusive, and seems to go away when trying to pinpoint the root cause. But we have been seeing these a couple of times within the last month, so hopefully that's the end of it.#2021-11-0420:06thhellerthat bumps to the latest cljs release and more importantly the latest closure compiler release which seems to have fixed that issue as far as I can tell#2021-11-0420:06thheller^ @martinklepsch (should also fix that firebase issue)#2021-11-1118:19martinklepschI tried with 2.16.3 just now and am still seeing TypeError: (0 , _app._registerComponent) is not a function It does seem like the upgrade itself worked though as evident by some warnings related to use of unrequired namespaces#2021-11-1120:09thhellerhmm? I don't understand what you mean? what warnings about unrequired namespaces?#2021-11-1214:19martinklepschStuff similar to assuming goog.object already being loaded. It’s most likely not related to the issue we’re encountering, just mentioning as a signal that the update took effect #2021-11-1214:37thhellergoog.object would most likely be related to this https://clojurescript.org/news/2021-11-04-release#_google_closure_library_goog_module_global_access#2021-11-1214:37thhellerbasically if you have any direct use of goog.object (or a macro that generates that) it'll break now#2021-11-1214:38thhellerthe namespace using goog.object must have a require for it, which in case of macros most likely won't be the case#2021-11-1214:38thhellerbut none of this has anything to do with TypeError: (0 , _app._registerComponent) is not a function type errors#2021-11-1215:26martinklepschYes. The core of it is just that I’m still seeing this issue with the latest shadow cljs #2021-11-1118:19martinklepschI tried with 2.16.3 just now and am still seeing TypeError: (0 , _app._registerComponent) is not a function It does seem like the upgrade itself worked though as evident by some warnings related to use of unrequired namespaces#2021-11-0517:44RyanIs there a way to have release build to a different path than watch? I looked at documentation and it didn't jump out at me#2021-11-0517:53thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2021-11-0517:53thheller:release {:output-dir "foo"}#2021-11-0609:02borkdudeIs it possible to use shadow to invoke the google closure compiler with pure JS? The use case is yielding a smaller bundle size by cutting out CLJS since I only use it for small glue code. Say I would have a index.js instead of src/foobar/main.cljs , can I configure shadow to use this and bypass CLJS completely?#2021-11-0609:45borkdudeIt's probably a more normal idea to use closure directly, but using shadow makes moving between these approaches less effort#2021-11-0609:51thheller@borkdude shadow can compile JS just fine without any CLJS. instead of :entries [some.cljs.ns] just use :entries ["/some/files.js"]#2021-11-0609:52borkdudegoing to try!#2021-11-0609:53thheller:target :esm sort of doesn't support it though since there is no way to express the exports without namespaced vars 😛#2021-11-0609:53thhellerbut you can just create a CLJS file with no actual use of CLJS#2021-11-0609:53borkdudeI don't need this target, any browser target will do just fine#2021-11-0609:53thheller:advanced should take care of removing cljs.core and such#2021-11-0609:53thhellerah yeah for browser its fine#2021-11-0609:54thhellerI built an entire JS project a while ago as a proof of concept#2021-11-0609:54borkdudeRight now I have this config:
{:deps {:aliases [:dev :demo]}
 :dev-http {8002 "public"
            8001 "public/test"}
 :nrepl {:port 9000}
 :builds {:highlighter
          {:compiler-options {:output-feature-set :es8}
           :target :browser
           :output-dir "public"
           :modules {:clojure_highlighter {:init-fn clojure-highlighter.main/render}}
           :build-hooks [(shadow.cljs.build-report/hook
                          {:output-to "report.html"})]}}}
#2021-11-0609:54borkdudeHow do I specify the JS file instead of the CLJS init fn thing?#2021-11-0609:55thhellerjust remove :init-fn and add :entries ["/that/file.js"]#2021-11-0609:56thhellernote that the js needs to be on the classpath and will be treated as https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-11-0609:57borkdudeHow to deal with hyphens, do I need to write them as underscores if the dir has underscores?#2021-11-0609:58thhelleractual filename#2021-11-0609:59borkdudeI tried:
:entries ["clojure_highlighter/main.js"]
:entries ["src/..."]
:entries ["clojure-highlighter/main.js]
but for all of them I get:
The required JS dependency "clojure_highlighter/main.js" is not available.
#2021-11-0609:59thhellerI linked you the documentation 😛#2021-11-0609:59borkdude
$ ls src/clojure_highlighter/main.js
src/clojure_highlighter/main.js
#2021-11-0609:59thheller:entries ["/clojure_highlighter/main.js]#2021-11-0610:01borkdudeThat did work.#2021-11-0610:01borkdude
[:highlighter] Compiling ...
Wrote build report to: /Users/borkdude/Dropbox/dev/blog/report.html
[:highlighter] Build completed. (16 files, 0 compiled, 0 warnings, 2,42s)
0 compiled ;)
#2021-11-0610:01borkdudeyeah that is true, because there is no CLJS#2021-11-0610:02thhelleryeah that only counts compiled cljs files 😛#2021-11-0610:05borkdudeI tried rollup for tree-shaking, that yielded a bigger bundle size than with Closure + CLJS included ;)#2021-11-0610:05borkdude600kb vs 300kb. Doing this pure JS + Closure is going to yield me 200kb instead of 300kb.#2021-11-0610:05thhellerdid you minify properly? I mean that sounds unlikely?#2021-11-0610:06thhellergiven that there is absolutely no dead code removal or :advanced for npm packages?#2021-11-0610:06thhellerrollup even without tree shaking should be similar in size minus the CLJS parts?#2021-11-0610:06thhellerbut you need to setup terser or so#2021-11-0610:07borkdudedon't know.
$ node_modules/.bin/rollup src/clojure_highlighter/main.js -f iife -o public/js/editor.bundle.js -p @rollup/plugin-node-resolve

src/clojure_highlighter/main.js → public/js/editor.bundle.js...
created public/js/editor.bundle.js in 1.1s

$ ls -la public/js/editor.bundle.js
-rw-r--r--  1 borkdude  staff  603547 Nov  6 11:06 public/js/editor.bundle.js
#2021-11-0610:07thhelleryeah without a config that won't minify at all#2021-11-0610:07borkdudeI see#2021-11-0610:07borkdudeI did what codemirror suggested in their readme 🤷#2021-11-0610:08thhellerhttps://rollupjs.org/guide/en/#using-output-plugins#2021-11-0610:09thhellerthere is a bunch more you need to do to get an actual minified bundle with rollup#2021-11-0610:09thhellerlittle easier to do in webpack since that has a dedicated dev/production mode similar to shadow#2021-11-0610:10borkdudeI see#2021-11-0610:11borkdudeyeah with terser I now get 200kb#2021-11-0610:12borkdudeawesome, thanks for the tip#2021-11-0611:15WestThis actually makes me wonder, how do I simply transpile cljs to js? Like how is it done on http://app.klipse.tech/, where I can do (+ 2 2) and get ((2) + (2));?#2021-11-0614:37dpsutton
clojure -A:cljs -M -m cljs.main -re node -r
ClojureScript 1.10.773
cljs.user=> (set! *print-fn-bodies* true)
true
cljs.user=> (defn foo [x] (inc x))
#'cljs.user/foo
cljs.user=> foo
#object[cljs$user$foo "function cljs$user$foo(x){
return (x + (1));
}"]
cljs.user=>
#2021-11-0620:33Westawesomesauce @U11BV7MTK#2021-11-0612:00borkdude@c.westrom Hacky way, in a CLJS repl you can do:
cljs.user=> (str (fn [] (+ 1 2 3)))
"function (){\nreturn (((1) + (2)) + (3));\n}"
#2021-11-0612:04WestWoah! Potent stuff!#2021-11-0612:05WestI see so much potential just with this!#2021-11-0614:50thhellerthere is no potential in this at all. please don't use it. this is not suitable to do anything with as one isolated part of JS won't run anywhere without the rest of the runtime 🙂#2021-11-0617:49borkdudeit's useful to the extent that you can see what the compiler makes of it, but not for anything more than that#2021-11-0620:35WestHmmm, was thinking I could use the output if I wanted some dead simple scripts inside a <script> element in HTML.#2021-11-0707:47borkdudeIf you want something like this you should compile to a single script using optimizations simple or advanced. You can also check out scittle which is an interpreter which allows you to directly include CLJS in script tags.#2021-11-0623:16ghaskins@thheller ran into a problem with some code I had submitted previously. This fixes it#2021-11-0623:16ghaskinshttps://github.com/thheller/shadow-undertow/pull/1#2021-11-0623:17ghaskinsIm not sure if you want the PR to bump the version or if you have a different release mechanism, so happy to refactor however you’d like#2021-11-0623:18ghaskinsAs im sure you are aware, there arent unit-tests in that lib directly, but I did override the dep in my shadow-cljs project and verified it seems to work as advertised#2021-11-0700:27geraldodevI'm having internal compiler error with react-data-grid . It happens with last shadow-cljs and the previous one. unexpected variable layoutCssVars Node(NAME layoutCssVars): node_modules/react-data-grid/lib/bundle.js:550:4 layoutCssVars, Parent(STRING_KEY layoutCssVars): node_modules/react-data-grid/lib/bundle.js:550:4 layoutCssVars#2021-11-0707:43thheller@ghaskins how do you have multiple set-cookie headers in a :dev-http server? not against adding that change just curious how you even get there?#2021-11-0707:50thheller@geraldodev looks like either invalid code or a bug in the closure compiler. can't really say and unfortunately also can't do anything about it#2021-11-0707:54thhellerif you search the closure compiler repo for "Unexpected variable" you'll find a bunch of reports. doesn't seem to be a new issue#2021-11-0710:57geraldodev@thheller I took https://github.com/shadow-cljs/quickstart-browser added react and react-data-grid, changed the version of shadow in package.json to "shadow-cljs": "2.11.23" to pin the exact version, added (:require ["react-data-grid" :default DataGrid]) on the main file and it compiled. I did (js/console.log DataGrid) and it showed the js class on console. I've changed the version to "^2.16.0" and got the internal error message#2021-11-0714:04thhellerthat unfortunately doesn't help much. I guess you can continue using that older version but downgrading the closure compiler otherwise unfortunately isn't an option#2021-11-0716:11geraldodev@thheller I've told too early that I've tested on the last one and the previous one, although my 2.15.3 test was messed up by the global shadow-cljs that I had. Version 2.15.3 works, version 2.16.0 does not. I see that 2.15.3 version uses closure-compiler-unshaded v20210505 and 2.16.0 version uses v20211006 compiler#2021-11-0716:16geraldodevBtw, it's impressive that this project is typescript and babel dependent and I don't have to deal witha any of this, all taken care by shadow-cljs.#2021-11-0712:20ghaskins@thheller to be clear, the set-cookies are coming from the backend that the dev-http server is proxying. In that case, the backend may sometimes want to set more than one cookie, e.g. in some oauth flows where both OP and RP state is being maintained in cookies#2021-11-0712:20ghaskinsThe mistake I made in the original code was assuming there would only ever be one set-cookie header, but this breaks down in examples such as above#2021-11-0712:33ghaskinsThe reason for the above is that the cookies may have different configurations…for instance, one might be related to token-refresh and is scoped down to just Path=/oauth, whereas the other is related to the application session state and is more broadly used, e.g. Path=/#2021-11-0903:27bmaddyI'm trying to get https://github.com/fulcrologic/fulcro-rad-demo running and am having trouble getting the cljs repl working in emacs. I bumped the cljs version to 1.10.879 to match what I think shadow-cljs 2.15.12 wants but I'm still getting user-error: The shadow-cljs ClojureScript REPL is not available. When I look at *nrepl-messages* I see this:
(-->
  id         "8"
  op         "eval"
  session    "844724f8-aa75-4953-bd4e-6ed230a647bf"
  time-stamp "2021-11-08 20:48:50.415368000"
  code       "(require 'shadow.cljs.devtools.api)"
)
...
(<--
  id         "8"
  session    "844724f8-aa75-4953-bd4e-6ed230a647bf"
  time-stamp "2021-11-08 20:48:51.723743000"
  err        "Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
"
)
...
Does that error mean anything to anyone? Any idea where to look next?
#2021-11-0906:48thheller@bmaddy 2.15.13 or 2.26.0 want that cljs version. see https://clojars.org/thheller/shadow-cljs#2021-11-0906:49thhellerI don't use emacs though so I can't say anything other than what their docs already say#2021-11-0906:50thhellerif that require does anything though I guess you are not connected to the shadow-cljs nrepl? otherwise it should be loaded already#2021-11-0921:32bmaddyI was able to get yarn shadow-cljs cljs-repl :main to evaluate code once I had yarn shadow-cljs watch :main running somewhere else and my browser loaded. That sounds to me like the problem is firmly on the #cider side of things. Thanks for the thoughts here and for the excellent REPL troubleshooting documentation--that cleared some stuff up for me.#2021-11-0908:23StefanI think I’m experiencing this issue: https://github.com/thheller/shadow-cljs/issues/948. In development everything works fine, since I have the compiler option :output-feature-set :es8 active. But in release mode, I get the error described in the issue. I’m assuming I shouldn’t use that compiler option in release mode. Does anyone have a solution/work-around?#2021-11-0911:18StefanNot sure if this is the best solution, but we’re now using this in release mode:
:release {:compiler-options {:output-feature-set :es5}}
This fixes the issue for us.
#2021-11-1010:26thhellerthis should absolutely not be required. can you try if this is maybe related to incremental compiles?#2021-11-1010:27thhellerif you get the error on shadow-cljs release just wipe the .shadow-cljs/builds/<your-build-id>/release dir and try again#2021-11-1010:27thhellerif that works it appears to be related to incremental compiles#2021-11-1010:28thhellerI just fixed the other issue but your problem description seems different so I'm not sure they are actually related#2021-11-1010:28thhellerespecially since switching the :output-feature-set will cause a cache wipe anyways#2021-11-1108:02StefanThanks for your feedback @U05224H0W. Wiping out the .shadow-cljs folder unfortunately doesn’t fix it. And I do think it’s the same issue, because it’s also for me the Col element in react-bootstrap (now version 2.0.0, no longer rc). I just now updated shadow-cljs to 1.16.2. The steps that I’m doing: • rm -rf .shadow-cljs node_modules • npm i • npx shadow-cljs -A:my-client server • npx shadow-cljs -A:my-client release :my-client I then request my HTML page through the dev server and I get TypeError: $jscomp.makeIterator is not a function in the JS console. Leaving out the Col element makes the error disappear. I can try to make a small reproduction project if that helps.#2021-11-1108:06thhellerso as far as I can tell the problem seems to be that the closure compiler rewrites some code expecting some polyfills (eg. $jscomp.makeIterator) to be available. normally when it does such replacements it also ensures that the polyfills will be injected itself. somehow something in the Col file however only causes the rewrite without ensuring its actually present#2021-11-1108:06thhellerthe fix I made seemed to work around the problem somewhat reliably but I guess not for your case#2021-11-1108:06thhellerso a repro might help track it down further although I made a minimal case that ONLY included Col and that worked just fine#2021-11-1108:07thhellerso dunno how to make it more minimal 😛#2021-11-1108:07thhellerbut I have to ask since it is such a common mistake: when you updated shadow-cljs did you actually update it in deps.edn or only package.json?#2021-11-1108:13StefanI updated both 🙂#2021-11-1108:13StefanMaybe your reproduction scenario was too minimal then? 😛 I’ll try to setup something up later this morning!#2021-11-1112:25Stefan@U05224H0W I have created a small repo that reproduces the issue for me. I think for the error to occur, the Col must be inside a Row and/or Container; just the Col may not trigger that code path. https://github.com/svdo/shadow-cljs-948#2021-11-1120:20thhellerthis works fine for me?#2021-11-1207:10StefanReally? 🤯 I’ll have a coworker try as well and get back. Very strange. You did the steps exactly like I described in the README right?#2021-11-1207:23thhellernah nevermind got it reproduced#2021-11-1207:25thhellerhttps://github.com/google/closure-compiler/issues/3890#2021-11-1207:26thhellerI'll see about adding a workaround#2021-11-1207:45thhellerit should work in 2.16.4 if you add :js-options {:force-library-injection #{"es6/util/makeiterator"}} to your build config#2021-11-1209:49Stefan@U05224H0W Your skills never cease to amaze me, this is great Thomas!!!#2021-11-0909:45Rachel WestmacottMorning all! Enjoying shadow-cljs here! Unfortunately my search-fu it failing me and I can't find out if there's a way to make it automatically open a web page when compilation first completes. I'm sure that used to be a thing.#2021-11-0917:33thheller@peterwestmacott that was never an option. figwheel does this but shadow-cljs does not#2021-11-0917:34Rachel WestmacottAh, okay. Thanks for letting me know.#2021-11-0917:34Rachel WestmacottAwesome tool btw, love it!#2021-11-0917:35Rachel WestmacottWould you consider it a desirable feature? Or is it definitely out of scope?#2021-11-0917:38thhellerIt is not desirable for me personally but that doesn't mean I wouldn't allow adding an option for it. shadow-cljs already does open a browser for shadow-cljs browser-repl since for that it has all the info. for the other stuff you might need to add a config option for it to work.#2021-11-1017:47lilactownFYI emacs-cider does this automatically after jacking in#2021-11-1017:50Sam RitchieQuestion for y’all… I just did an OS X upgrade and I am now seeing, on shadow-cljs clj-repl,
Syntax error (UnsatisfiedLinkError) compiling at (/private/var/folders/xw/0lq56zhn4hb4lknppw_k086c0000gn/T/form-init9980842284905073960.clj:1:125).
#2021-11-1017:53Sam RitchieI am going to try and upgrade my jdk and see if that helps… but has anyone seen this#2021-11-1017:53Sam Ritchie?#2021-11-1017:57Sam Ritchieseems to be happening only when :lein true is set…#2021-11-1020:35thheller@sritchie09 never shorten stacktraces 😛#2021-11-1020:35thhellerI'm guessing you have some native dependency that no longer works with that macos version#2021-11-1020:35thhellerif you are on an older shadow-cljs version you should upgrade that#2021-11-1021:47Sam Ritchiefair enough, sorry! I am on the newest version of shadow-cljs and lein;#2021-11-1021:47Sam Ritchiehttps://gist.github.com/sritchie/5b99589747b1b289f8bcc3c0b41e4458#2021-11-1021:47Sam Ritchiehere is the full error and the contents of the referenced file#2021-11-1021:48Sam Ritchieadded shadow-cljs info output too#2021-11-1106:04thheller@sritchie09 that is a stacktrace that definitely NOT using the latest shadow-cljs version. remember when using :lein true in your shadow-cljs.edn that your project.clj determines the shadow-cljs version, not the npm package.#2021-11-1111:33Sam RitchieDoh… okay, thank you. I was assuming in retrospect that the command was modifying the dep, as I sometimes see, but it is clearly not. Thanks for the help!#2021-11-1108:16Nathan KHi all 🙂 I have a question (perhaps a silly question) 🧵#2021-11-1108:18Nathan KI’m following this tutorial: https://www.youtube.com/watch?v=yVb8PS6a4Mk&amp;t=79s In the video he starts shadow-cljs using calva. The command that gets run is: npx shadow-cljs -d cider/cider-nrepl:0.26.0 watch :app This is the same for me. In the video, JS dependencies are installed. For me, they’re not installed. Did he skip a step? I’m looking through the shadow-cljs docs and I can’t see a command that is meant to install dependencies. I could install them myself but I guess I’m just curious why it didn’t work the same way for me. 🙂
npx shadow-cljs -d cider/cider-nrepl:0.26.0 watch :app
npx: installed 97 in 6.588s
shadow-cljs - config: /Users/nathankramer/Projects/nathanKramer/reframe-example/shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.2 running at 
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "react" is not available, it was required by "day8/re_frame_10x/inlined_deps/reagent/v1v0v0/reagent/core.cljs".
#2021-11-1108:21Nathan KIn the meantime, I manually installed the dependencies, and the boots nicely, so no biggie#2021-11-1108:23thhellernpm install will install your JS dependencies assuming you have a package.json#2021-11-1108:24Nathan KYep, thanks. Do you happen to know if that was supposed to happen automatically? Is it usually managed by shadow-cljs? 🙂#2021-11-1108:25thhellerit should install automatically if not already installed#2021-11-1108:25thhellerthat however still requires a package.json being there#2021-11-1108:26Nathan KInteresting, wonder why it didn’t work for me. I do have a package.json, and it has react etc in it. Curious!#2021-11-1108:46thhellerif react is already in package.json then shadow-cljs will not trigger a install again#2021-11-1108:46thhellerso in that case you just need npm install to get it#2021-11-1108:47Nathan Kok, I thought maybe since I had never run the app it would fetch them, no worries 🙂#2021-11-1113:20pmooserAre the only valid values of :reader-features the values of :target ?#2021-11-1117:47thhellerno, it is not coupled to target at all#2021-11-1117:18currentoorAnyone try using shadow-cljs with nodegui? Seems like a descent more performant alternative to electron. https://react.nodegui.org/#2021-11-1118:10WestNever tried it. I’ve been playing around with Tauri though. https://github.com/tauri-apps/tauri#2021-11-1119:06dvingoI am using tools.build to create an uberjar for the backend portion of a web app. I would like to use shadow.cljs.devtools.api/release from this build script as well. It does work fine for a browser build, the issue is when compiling the cljs tests (`:node-test` target) - because tools.build places the entire project directory on the classpath the test discovery finds a file in the test directory and then expects the namespace to start with test/ :
:cause "Resource does not have expected namespace",
  :data
  {:tag :shadow.build.resolve/unexpected-ns,
   :resource
   "test/my-app/components/events_test.cljs",
   :expected-ns
   test.my-app.components.events-test,
   :actual-ns my-app.components.events-test}}}
I think the browser build works because the entry namespace is provided and discovered on the classpath in the correct spot. So I'm wondering if there are any creative solutions to this problem. The context is running a build in continuous integration where starting two JVM processes slows things down quite a bit.
#2021-11-1120:17thhellerhmm good question. I guess you could adjust your :ns-regexp to something like "^my-app\..*-test$", that should filter them out just by name?#2021-11-1120:18thhelleror whatever the regexp is for anything not starting with test 😛#2021-11-1202:19tony.kayI have badness for latest Shadow 2.16.3 on linux. Definitely breaks the build. Unfortunately it breaks at a macro and the error is very strange...going to try clearing all the caches#2021-11-1202:31tony.kayseems like 2.15.13 has the same problem#2021-11-1206:22thheller@tony.kay define badness? if its related to goog.object in any way its most likely this https://clojurescript.org/news/2021-11-04-release. can easily happen if the macro emits direct calls to anything goog.object#2021-11-1213:07tony.kaySo, I'm using goog.object in those nses, but I do require it. So I'm confused. It is a CLJC file, the CLJS side requires goog.object, and then the CLJS side of the macro emits goog.object/get. Is there some trick I'm not aware of?#2021-11-1213:08tony.kay(it never occurred to me to not require something I was using from goog)#2021-11-1213:11tony.kayThe line it is crapping out on looks like this in js:
var G__83387 = com.fulcrologic.rad.rendering.semantic_ui.report.goog$module$goog$object.get(props__55942__auto__,"fulcro$value");
#2021-11-1213:14tony.kayAh, so if I require goog.object in the ns that uses the macro it works...#2021-11-1213:14tony.kaybut that's a really crappy user experience for a library. My lib ns requires goog.object, but now the users of that ns have to require it too? That cannot be right#2021-11-1213:15tony.kaybut I sorta guess this would be a Clojurescript bug, and not a shadow-cljs one. Here's what I know so far if you want to look into it: Fulcro has a macro that emits goog.object calls. It is a CLJC ns, and goog.object is required in a reader conditional for the cljs side. When I use that from a CLJS file in a project it seems to work fine; however, when I use the base CLJC file in a dependent library that also defines things in CLJC, then the usage of that macro fails to see goog.object and it resolves to the wrong symbol (e.g. here is the line of js):
var G__83387 = com.fulcrologic.rad.rendering.semantic_ui.report.goog$module$goog$object.get(props__55942__auto__,"fulcro$value");
This is reproducible using this branch of the new fulcro-rad-template: https://github.com/fulcrologic/fulcro-rad-template/tree/latest-cljs Compile the main target and look at the js file com.fulcrologic.rad.rendering.semantic_ui.form.js or com.fulcrologic.rad.rendering.semantic_ui.report.js. They both have the problem. But I tried upgrading the compiler on Fulcro itself and running the simlple todomvc that exists in that project, and when used as cljs the macro seemed to work ok (in all cases the defsc macro from components is the one that is behaving strangely).
#2021-11-1213:33tony.kayShould I define my own CLJC function that calls goog.object/get, and not refer to it in the macro at all?#2021-11-1213:37tony.kayActually, that fixes it...so, macros just cannot ever safely emit calls to goog.object now, even if the ns the macro is in requires it?#2021-11-1213:48thhelleryeah its kind of annoying. I disagree with David's choice of adding the :global-goog-object&array compiler options to work around the issue but I guess we have to make this transition at some point so best to get it over with#2021-11-1213:49thhellerbasically you cannot generate any code in a macro directly accessing the closure library namespaces in a macro anymore#2021-11-1213:49thhelleralways need a helper function in a CLJS ns that calls them from now on basically#2021-11-1213:51thhelleryou can use unchecked-get and unchecked-set instead of goog.object/get&set#2021-11-1214:47tony.kayok, then my fix is the official fix. Thanks for the help!#2021-11-1206:25thhellerthe big thing was the cljs + closure compiler + closure library upgrade so sort of expected some breakage there#2021-11-1212:38tony.kayin fact it is....I'll read up o nthat, thanks#2021-11-1217:25FlavaDavehave a react-native project running with shadow and everything works except the server running on localhost. console says main.js:1 Uncaught SyntaxError: Identifier 'Ca' has already been declared#2021-11-1218:27Drew VerleeIs it possible to make changes to the shadow-cljs.edn without changing the file directly. E.g } want to add re-frame-10x to my personal workflow but not add it to the projects (commit it to github).#2021-11-1218:34localshredYou can use --config-merge EDN:#2021-11-1218:34localshred
$ shadow-cljs --help
...
      --config-merge DATA  merges additional EDN data into the build config
#2021-11-1219:45Drew Verleethat's perfect!#2021-11-1221:01localshredexcellent 🙂#2021-11-1416:44ghaskins@thheller im still trying to figure out whats going on, but upgrading from shadow v2.15.12 to both 2.15.13 or 2.16.4 results in errors related to goog.object#2021-11-1416:44ghaskinsdoes this sound familiar?#2021-11-1416:44ghaskinsgoog$module$goog$object is undefined#2021-11-1416:44ghaskins?#2021-11-1416:45ghaskinsThis is the minimal patch that is breaking me#2021-11-1416:45ghaskins
diff --git a/package.json b/package.json
index c689932..3425558 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,6 @@
     "uuid": "8.3.2"
   },
   "devDependencies": {
-    "shadow-cljs": "2.15.12"
+    "shadow-cljs": "2.15.13"
   }
 }
diff --git a/project.clj b/project.clj
index 3bd6378..1877575 100644
--- a/project.clj
+++ b/project.clj
@@ -8,13 +8,13 @@
                                   :username [:gpg :env/gitlab_token_type]
                                   :password [:gpg :env/gitlab_token_value]}]]
   :dependencies [[org.clojure/clojure "1.10.3"]
-                 [org.clojure/clojurescript "1.10.879"
+                 [org.clojure/clojurescript "1.10.891"
                   :exclusions [com.google.javascript/closure-compiler-unshaded
                                org.clojure/google-closure-library
                                org.clojure/google-closure-library-third-party]]
                  [org.clojure/core.async "1.3.622"]
                  [org.clojure/test.check "1.1.0"]
-                 [thheller/shadow-cljs "2.15.12"]
+                 [thheller/shadow-cljs "2.15.13"]
                  [reagent "1.1.0"]
                  [re-frame "1.2.0"]
                  [kee-frame "1.3.1"]
#2021-11-1417:10thheller@ghaskins see https://clojurescript.org/news/news#_google_closure_library_goog_module_global_access. easy to fix if its in your code. if its in a library not so much.#2021-11-1417:12thhellerjust make sure every namespace using goog.object also has a require for it. if some macro generates code accessing goog.object those need to be rewritten not to#2021-11-1417:18thheller(or if things get to complicated to fix just :compiler-options {:global-goog-object&array true})#2021-11-1417:29ghaskins@thheller ty, ill check it out#2021-11-1511:06pezIf I use [:js-options :js-package-dirs to tell shadow about an npm module that a sub project (a :local/root deps.edn dependency) needs. Do I risk to be using the wrong version of some subdependency that my main project and the subproject both bring in?#2021-11-1517:36thhellerkind of yes#2021-11-1517:53pezI am using yarn to initialize node_modules in all projects. Does that make a difference? Or rather, I should ask what makes this risky.#2021-11-1518:10thhellersay your main project uses dependency B which also uses X v1#2021-11-1518:11thhellerthen you have the sub project using dependency C which uses X v2#2021-11-1518:11thhellerbut since js-package-dirs resolves in order it'll get v1#2021-11-1518:11thhellerwhich may blow up#2021-11-1518:12thhellerbut why not have the sub project declare its :npm-deps and manage them in the main project as well#2021-11-1518:12thhellerthat at least makes the dependency conflicts visible#2021-11-1518:14pezYes, sound safest! Will that work with yarn as well?#2021-11-1518:14thhellersure#2021-11-1609:06pez> that at least makes the dependency conflicts visible Meaning, that I might still end up with my subproject using X v1?#2021-11-1618:42thhellerdepends on how yarn resolves or handles the conflicts#2021-11-1618:43thhellergonna have to ask yarn. shadow-cljs is only interested in what it finds in node_modules. it does not care how it got there#2021-11-1618:44thhellerdon't overthink it too much though. worst case either means your build breaks immediately or you end up including two version of the same dependency#2021-11-1618:44thhellerthe break you'll notice and the duplicates you can identify via build reports#2021-11-2213:23pezThanks so much for all this info, @thheller! It looks like we’re going with :npm-deps now. I notice that it just works with yarn. Is this something shadow-cljs does or is it the clojurescript compiler that does it? I wonder if I need to somehow make sure it is my yarn.lock file that is updated…#2021-11-2218:00thhellershadow-cljs will call yarn add <npm-dep>@<version> for declared :npm-deps if they are not already in package.json if a yarn.lock file is found#2021-11-2218:00thhellerotherwise it'll run npm install#2021-11-2218:40pezAwesome. Thanks again!#2021-11-1516:44roman01la@thheller is there a way to get deps graph from shadow build? I’ve seen some references to /api/graph endpoint in shadow’s server code, but couldn’t figure out if it’s something that actually works#2021-11-1517:39thheller@roman01la define deps graph? /api/graph is for EQL graph queries but its not used much. what specifically are you looking for and at which point? you could easily extract it from the build state via a build hook for example#2021-11-1608:59roman01laI see. I’m interested in getting dependency graph including application code, cljs deps and npm deps. For build hook: at which build stage the graph is available in the build state?#2021-11-1618:40thhellerI still don't know what you mean by "dependency graph". there is no graph of such kind. the information to construct it is there but shadow-cljs itself maintains no such graph.#2021-11-1618:40thheller:compile-start and everything after has all the info#2021-11-1618:47thhellerin the build state you'll find a :build-sources vector. those are resource-ids sorted in dependency order#2021-11-1618:47thhellereach id you can find in the :sources map#2021-11-1618:48thhellerthere each will have a :provides set or namespace symbols and a :deps vector#2021-11-1618:51thheller:provides is a set since closure lib sources can provide multiple things per file#2021-11-1618:52thhellerfor CLJS sources its just #{that.ns}#2021-11-1618:52thhelleryou can use
:build-hooks
   [(shadow.build/tap-hook)]
in your build config
#2021-11-1618:53thhellerit'll just tap> the build state on :flush so you can inspect it via the UI#2021-11-1618:58thhellerthere are other ways to get all this data so I don't know if a build hook is the best choice for whatever you intend to do#2021-11-1709:58roman01laI’ll give it a try, thanks! 🙏#2021-11-1621:26Drew Verleemaybe more of a cljs in general question, but if i want to tap out some information the middle of some logic like the (or x y) (cond-> (or x y) (something... ) Whats everyones favorite way of doing that? in clj i would use enlight mode to see the values. But thats not an option in cljs.#2021-11-1621:28Drew Verleesomething like the spy function in this lib https://github.com/lambdaisland/glogi#2021-11-1622:04lilactown(or (doto x tap>) y)#2021-11-1622:04lilactown☝️:skin-tone-2: @drewverlee#2021-11-1623:11ingesol@drewverlee https://github.com/weavejester/hashp#2021-11-1623:17Drew VerleeThanks. that looks perfect.#2021-11-1701:53Drew Verlee@U21QNFC5C is that working for you currently in shadow? I got an error about an attempt to call an unbound fn @'hashp.core/p*#2021-11-1709:09ingesolyes it’s working for me. did you include the preload in devtools?#2021-11-1715:35Drew Verleeyep via --config-merge#2021-11-1715:37Drew Verleebut ill try adding it to the preload to shadow to.#2021-11-1715:49Drew VerleeWIth the preload added to the shadow (as opposed to --config-merge) the app compiles but adding #p doesn't tap anything to the shadow cljs inspect stream tap history#2021-11-1715:51Drew Verleeah ok, its in the console log.#2021-11-1716:04ingesolRight, it’s not a tap#2021-11-1706:37RyanWHat's the right synax for requiring goog.object? is it
(:require     ["goog.object" :as goog.object]) ?
edit: it appears to be simply
(:require [goog.object])
#2021-11-1706:42thhellertechnically (:require [goog.object :as gobj]) as you should always be using aliases IMHO 😛#2021-11-1707:08RyanFair point!
#2021-11-1707:25RyanMight this error be related to the goog changes?:
TypeError: Cannot read properties of undefined (reading 'Level')
    at eval (logging.cljc:12)
    at eval (<anonymous>)
    at Object.goog.globalEval (pnx-web.js:488)
    at Object.env.evalLoad (pnx-web.js:1563)
#2021-11-1707:26thhellerlikely, just not the goog.object one but an older one#2021-11-1707:27thhellercan't remember what exactly but some class was renamed/moved goog.log.Level or so#2021-11-1715:31martinklepschWe’re still seeing TypeError: (0 , _app._registerComponent) is not a function errors when trying to use Firebase SDK v9 with shadow-cljs 2.16.3 . I think the new cljs compiler was meant to fix some of these issues but we haven’t been able to get things working.#2021-11-1716:35thheller@martinklepsch this is pretty much guaranteed to be a closure compiler issue. without a repro I can't tell. the new cljs release didn't do anything affecting this. the only thing it did was also upgrading the closure compiler version which sometimes fixes things and indeed seems to have fixed some (0, thing) related issues others had. this is not happening in code generated by CLJS, so it'll be guaranteed to be something badly rewritten by :simple in some npm code#2021-11-1717:14martinklepschOk, we’ll try to create a repro case then 🙂#2021-11-1717:55DharmendraHi, I am trying to resolve one issue which I am currently facing. I am following below steps 1. Created a project using lein new reframe appname +10x. Then I installed mui5(CSS framework) https://mui.com/getting-started/installation/ 2. Then I just modified views.cljs like below
(ns demo.views
  (:require
   ["@mui/material/styles" :refer [ThemeProvider, StyledEngineProvider]]
   ["@sphere/component-library" :refer [themeV2]]
   ["@sphere/component-library/build/components/v3/Dummy/Dummy" :default Dummy]
   ["@mui/material/Button" :default Button]
   ["@mui/material/CssBaseline" :default CssBaseline]))

(defn test-component []
  [:<>
   [:> Button {:variant "contained"} "MUI Button"]
   [:> Dummy]])
   

(defn main-panel []
  [:> StyledEngineProvider {:injectFirst true}
     [:> ThemeProvider {:theme themeV2}
      [:> CssBaseline]
      [test-component]]])
Note: Here ["@sphere/component-library/build/components/v3/Dummy/Dummy" :default Dummy] is a UI library written in JS react and https://mui.com/getting-started/installation/ only used there I am getting below error in screenshots:
#2021-11-1717:57DharmendraIf I do the same in create-react-app it works fine without any problem. Here is the code in screenshot:#2021-11-1717:58thhellerthats a #reagent question and has nothing to do with shadow-cljs#2021-11-1718:02DharmendraYeah, thanks I will ask in reagent channel.#2021-11-1722:12Joshua SmockIs it possible to use :ns-regexp with :target :esm? #2021-11-1806:32thheller@slack1338 no, that is only setup to require exports#2021-11-1811:19Joshua SmockTo give a little bit of context, I’m looking into other ways to combine CLJS and Jest. Jest supports ESM and has some nice advantages to using those files. As an alternative, would it be possible to configure the :js-options :js-provider for the :npm-module target? I tried to but it didn’t seem to work and I’d like to be able to set it to :import so that it uses import("./some-file") rather than require(…)#2021-11-1817:13thheller:npm-module only outputs commonjs so it cannot use import#2021-11-1810:47henryw374Hi, I have a vanilla browser-test setup working and I visit the browser-test page on localhost. When I remove the config from shadow-cljs.edn and invoke the api like this:
(shadow.cljs.devtools.api/watch
    {:build-id :test
     :target    :browser-test
     :test-dir  "target/public/js/test"
     :devtools  {:http-port          8021
                 :http-root          "target/public/js/test"}} 
    {:verbose false})
the watch appears to start normally, but there is no browser-test server started. is there something else I need to do when using the api to make this work?
#2021-11-1814:25henryw374I see it's getting the config from file, rather than using what was passed in to start shadow server https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/dev_http.clj#L380#2021-11-1814:54henryw374ended up alter-var-rooting the get-server-configs var in that ns. I think I can get by with just dev servers passed at top level, so if it used the server config passed in to start the shadow server, rather than reading from the file, that would work in that case at least#2021-11-1815:30henryw374pr https://github.com/thheller/shadow-cljs/pull/959#2021-11-1817:12thhellercan you explain a little bit what you are doing? http servers are not coupled to builds and all http related :devtools config is deprecated. I just still allow it to not break old templates and such#2021-11-1906:32henryw374sure. briefly, I am using shadow via api functions. my shadow-cljs.edn file is currently empty. I call the function to start the main server, then call things like watch that I posted an example of. this is because we have many builds across many projects and so benefit from sharing boilerplate via code. we could write out shadow-cljs.edn files and then invoke api calls with build ids and so on but since I can pass in config directly to the functions that seems preferable. the pr still means changes from shadow-cljs.edn are picked up as it is changed - everything still works. it just also means the config from the initial call to start the main server (whether passed as arg or got from shadow file) is used to start dev servers#2021-11-1906:36thheller:dev-http is nothing but a simple static webserver. when you start your "main server" I assume that already has a webserver? why not use that?#2021-11-1906:39henryw374by main server , I mean the shadow one, which has the dashboard ui. yes if I could get that to serve some resources of my choosing, that would work#2021-11-1906:40henryw374... while keeping the shadow dashboard working under / ofc#2021-11-1906:42thhellerno I meant something like jetty or whatever webserver you are using?#2021-11-1906:42thhellermost people that go with this type of total custom setup (ie. no shadow-cljs.edn) tend to use their own servers?#2021-11-1906:44henryw374oh I see. yeah that's a possibility. I'd rather configure it as per the shadow guide though. It makes it easier for others to follow#2021-11-1907:00henryw374to be clearer about what I mean about getting shadow to use the config passed in to the main server, I mean I want the args I pass to shadow.cljs.devtools.server/start! to make it through to the dev-http stuff. that's what the pr achieves, while keeping the watch on shadow-cljs.edn working#2021-11-1907:02thhelleryeah I get that, implemented in https://github.com/thheller/shadow-cljs/commit/378028ddb79913a5f8104306b0a9c8a691a2977c#2021-11-1907:02thhellerdecided to clean it up a little more than your pr did#2021-11-1907:03henryw374awesome :thumbsup: . thanks#2021-11-1907:13thhellerreleased in 2.16.5#2021-11-1907:21thhelleralso updated https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test to make it not use http-root given its deprecated status#2021-11-2119:07frozenlockHello, Is there a way to use shadow-cljs to automatically run tests when files are modified? It looks possible when the target is node , but I couldn't find anything for when the target is karma or the browser.#2021-11-2120:20thheller@frozenlock for :browser-test you just open the browser and tests run automatically. for karma you run karma, no idea how#2021-11-2120:29frozenlockBut then shadow-cljs isn't working anymore to compile new the modified cljs files, right? (Following this https://shadow-cljs.github.io/docs/UsersGuide.html#_the_build)#2021-11-2120:32thhelleryou just check the watch running?#2021-11-2120:33thhellerI don't really know karma, never used it#2021-11-2120:35frozenlockNeither did I. I'm just searching for a way to test cljs with CI 😅#2021-11-2122:02lilactownthe way I run our tests in ci:
shadow-cljs compile ci # compile the tests from CLJS to JS
npx karma start --single-run
this happens anytime a push to a branch occurs
#2021-11-2122:04lilactownif you're running them locally, you can run shadow-cljs watch ci and then tell karma to watch for file changes.#2021-11-2221:10frozenlockThank you very much!#2021-11-2217:04danielcomptonI’m trying to suppress a warning in a third-party file:
Resource: node_modules/<file>
 String continuations are not recommended. See 
This SO answer seems to suggest I can disable warnings for this one file with --hide_warnings_for=node_modules/somelibrary, but I’m not quite sure how to provide this argument in my shadow-cljs.edn ? https://stackoverflow.com/questions/47668995/google-closure-suppress-warning-messages-for-a-particular-file
#2021-11-2217:58thheller@danielcompton that option doesn't exist in shadow-cljs but I can add it. which npm file causes this?#2021-11-2218:04danielcomptonhttps://github.com/scijs/ndarray/blob/master/ndarray.js#2021-11-2218:05danielcomptonIt triggers the warning 25 times when compiling that one file. I looked at the code and using string continuations doesn’t really seem unreasonable given what they’re doing#2021-11-2218:06danielcomptonGoogle Closure does have a @suppress annotation but they don’t seem to allow you to suppress the string continuation warning#2021-11-2218:08thhelleryeah I can't find a way to turn it off either. not via the usual mechanism anyways#2021-11-2218:15thheller@danielcompton hmm why are you getting that message in the first place? it is only a debug log? are you running in verbose mode? or :log {:level :debug}?#2021-11-2218:21danielcomptonI’m in a brand new codebase so I’m a little unfamiliar, and this is my first time using Shadow CLJS on a major project but I don’t see any debug logs enabled or verbose#2021-11-2218:45thheller@danielcompton in 2.16.6 you can set :js-options {:hide-warnings-for #{"node_modules/ndarray/ndarray.js"}} in your build config to hide those warnings#2021-11-2220:28danielcomptonAwesome, thanks!#2021-11-2222:48danielcomptonYep, that worked#2021-11-2220:28dmegasI’m getting a similar error to this older issue https://github.com/thheller/shadow-cljs/issues/427. More specifically
errors in file: .../node_modules/lower-case/dist/index.js
{:js-str-offsets [], :js-esm false, :js-imports [], :js-invalid-requires [], :goog-provides [], :js-language "es3", :goog-module nil, :js-warnings [], :resource-name "node_modules/lower-case/dist/index.js", :js-requires [], :js-errors [{:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}], :goog-requires [], :tag :shadow.build.npm/errors, :uses-global-buffer false, :uses-global-process false}
ExceptionInfo: errors in file: .../node_modules/lower-case/dist/index.js
for the npm library lower-case. The offending line looks like
İ: "\u0069",
anyone faced anything similar?
#2021-11-2220:34dmegasAs in the linked issue, I (TokenStream/isJSIdentifier "İ") returns true#2021-11-2221:08dmegasMaybe it could be related to this open issue in google closure https://github.com/google/closure-compiler/pull/3647 :thinking_face:#2021-11-2305:35thhelleryeah this isn't something I can control or change from within shadow-cljs#2021-11-2307:27dmegasIs there any workaround, or are such libraries (and those that depend on them) completely unusable with cljs?#2021-11-2307:28thhelleryou can use webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2021-11-2307:28thhellerthat likely won't have that problem#2021-11-2307:30dmegasthank you! I’ll try that#2021-11-2221:36Stephen WisemanHas anyone experienced any issues with the guava library since upgrading shadow-cljs? It appears that Google moved to using Bazel builds for the closure-compiler. With that, they removed external maven dependencies (in “v20200927” I believe). As a result, lein deps no longer sees guava in the dependency tree as a dependency of shadow -> closure-compiler. On our project, this is causing lein to pick up a lower version (16.0.1) of guava much deeper in the dependency tree as part of an unrelated dependency. This can be confirmed through lein deps :why com.google.guava/guava Then, when doing a shadow build, the build fails as the closure compiler (i think!) tries to use the old version of guava (calling a method that doesn’t exist in guava 16.0.1):
Exception in thread "main" Syntax error macroexpanding at (closure.clj:77:5).
	at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1742)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3705)
	at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
	at clojure.lang.Compiler.eval(Compiler.java:7186)
	at clojure.lang.Compiler.load(Compiler.java:7640)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6856.invoke(core.clj:6115)
	at clojure.core$load.invokeStatic(core.clj:6114)
	at clojure.core$load.doInvoke(core.clj:6098)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5897)
	at clojure.core$load_one.invoke(core.clj:5892)
	at clojure.core$load_lib$fn__6796.invoke(core.clj:5937)
	at clojure.core$load_lib.invokeStatic(core.clj:5936)
	at clojure.core$load_lib.doInvoke(core.clj:5917)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:5974)
	at clojure.core$load_libs.doInvoke(core.clj:5958)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:5996)
	at clojure.core$require.doInvoke(core.clj:5996)
	at clojure.lang.RestFn.invoke(RestFn.java:551)
	at shadow.build.js_support$eval10779$loading__6737__auto____10780.invoke(js_support.clj:1)
	at shadow.build.js_support$eval10779.invokeStatic(js_support.clj:1)
	at shadow.build.js_support$eval10779.invoke(js_support.clj:1)
...
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(Ljava/util/Comparator;)Ljava/util/stream/Collector;
	at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:257)
	at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:147)
	at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:48)
	at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:139)
	at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:408)
	at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:182)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
	at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1735) 
One confirmed way around this is to set a new version of guava as a top level dependency in our app so it’s picked up in the dependency tree. This works, however, we’d then need to keep manually ensuring that the guava version we specify is compatible with whatever version of the closure-compiler that shadow uses. It’s doable, but it seems like there may be a better solution. Any ideas?
#2021-11-2305:22thheller@swiseman108 when using lein to manage dependencies you need to make sure you are using the correct versions of everything. so make sure you are using the proper versions for the shadow-cljs version you are using. I do not have any issues with the closure compiler and I don't have guava at all either#2021-11-2316:24Stephen WisemanI think part of what I’m trying to figure out is how we’d be able to know which dependencies to use. Previously I’d be able to see the dep tree of shadow. But since shadow moved to a newer version of the closure-compiler (that no longer lists external deps), it’s near impossible to figure out which deps may conflict with the closure-compiler (as we saw with guava).#2021-11-2316:33Stephen Wisemani.e a lein deps :tree now shows zero dependencies under closure-compiler-unshaded. However, the closure compiler code can and will still conflict with other dependencies in your project. Just as we saw by pulling in guava 16.#2021-11-2316:35Stephen WisemanI’m also somewhat new to this, so I could be misunderstanding something key here 🙂#2021-11-2318:12thhelleryeah the closure compiler is a bit weird in that area. their bundling methods sometimes look like they don't expect people to use the closure compiler like we do 😛#2021-11-2305:23thhellersee the dependencies listed here https://clojars.org/thheller/shadow-cljs#2021-11-2305:24thhelleror as I always recommend let shadow-cljs.edn manage your dependencies. you only gain headaches by mixing your CLJ dependencies with CLJS ones#2021-11-2305:26thheller(or use profiles/aliases for backend/frontend)#2021-11-2315:53Stephen WisemanThanks @thheller. Moving to shadow-cljs.edn for dep management is definitely in the plans. Separating out frontend and backend deps would also be a solution to this particular issue as the lower version of guava is only in the dependency tree of a backend dependency.#2021-11-2316:11zalkyHi there, running into an issue with cljs hot-reloading and trying to identify the point of failure using shadow's verbose output. I have three namespaces a > b > c, with a macro defined by b. So far hot reloading a seems to work though changing a does not seem to reload transitive dependency c (which seems odd, but maybe there's some optimized decisions or something). However, if I introduce an additional dependency between c and a , changing a reloads c before b, which is confusing to me: c relies on the macro in b, and results in an undefined var warning. Are my expectations about what gets reloaded and when, off? Let me know if it would help to post a simplified version the actual requires.#2021-11-2318:03thheller@zalky namespace reload always works by reloading the namespace that was modified plus all namespaces that have a direct require for it. nothing else by default.#2021-11-2318:06thhellerreload order should happen in dependency order but I don't quite follow your description. macros are kind of tricky since they can technically do everything, so without an actual example I can't say much#2021-11-2318:12zalky@thheller, thanks, I think I see. So a really simplified version of what it looks like is the following:
(ns p.a)
(defn f
  [])
(ns p.b) ; .clj
(defmacro macro
  []
  '(p.a/f))
(ns p.b ; .cljs
  (:require [p.a])
  (:require-macros [p.b]))
(ns p.c
  (:require [p.a]  ; <-- this line causes p.c to be compiled before p.b
            [p.b]))
(p.b/macro)
#2021-11-2318:15thhellerincorrect. that line causes p.c to be compiled at all when p.a is changed. without that it won't#2021-11-2318:16thhellerwhat causes it to compile c before b is whatever requires those#2021-11-2318:16zalkyYes, my mistake.#2021-11-2318:17thhellerbut why is that a problem in the first place? is the macro doing some side effecting stuff that is causing a problem?#2021-11-2318:17thhellerotherwise it really shouldn't matter at all?#2021-11-2318:18zalkyAre you asking in the sense of why do the undefined var errors matter?#2021-11-2318:18zalkyWarnings I should say.#2021-11-2318:18thhelleragain without an actual reproducible example I cannot comment#2021-11-2318:19thhellermacros can do too much stuff to know what exactly you are describing#2021-11-2318:23zalkyThat's fair, they can be. This particular macro just produces some runtime code inside component render functions. I don't think it does any compile time side-effects. Do you know what part of the system, shadow or the cljs compiler, that does the dependency graph resolution? ie: resolves the dependency order?#2021-11-2318:23thhellershadow#2021-11-2318:27thhellerfwiw I took your example code and things compile in the expected order (ie. modify a compiles a->b->c)#2021-11-2318:31thhellerthe only way I can see this not happening is p.c using p.b without requiring it#2021-11-2318:32thhellerin which case yes all bets are off on the order part#2021-11-2318:34zalkyOk, much appreciated, the actual code is part of a fairly large framework, and I wasn't immediately clear that only immediate dependents are recompiled. I think actual example has another namespace between p.a and p.b, and so p.b is not actually being reloaded in either case.#2021-11-2318:35zalkyp.c is indeed requiring p.b#2021-11-2318:36thhellerthe reasoning behind only recompiling direct dependents is that in theory thats the only namespaces that can "break". macros kinda break that assumption in certain cases so absolutely possible that things behave weirdly but most of the time that is due to macros doing some side-effecty stuff looking at analyzer data or so#2021-11-2318:39zalkyAh, hmm, the macros is indeed looking at &env to determine if a particular symbol is a bound local#2021-11-2318:42thhellerlocals should be fine?#2021-11-2318:42thhellerah if it calls resolve then that may trigger the warning, not the compile itself#2021-11-2318:43zalkyIt does not call resolve, it just looks up whether a symbol is locally defined, and if it is not, provides a default binding.#2021-11-2319:01zalkyCan I also ask, during the compilation, I'm seeing output like the following:
1:49:52 PM cljs.1 |  -> Compile CLJS: a.cljs
1:49:52 PM cljs.1 |  -> Compile CLJS: c.cljs
1:49:52 PM cljs.1 |  <- Compile CLJS: c.cljs
...
1:49:52 PM cljs.1 |  <- Compile CLJS: a.cljsi
Where c depends transitively on a. Does it mean these compilation steps are an asynchronous process? Are there any concurrency concerns here that might produce an undefined var error?
#2021-11-2319:04thhellerthere are multiple threads compiling yes. I still won't comment any further without an actual reproducible example. guessing here is really pointless.#2021-11-2319:07zalkyOk, understandable. I don't suppose there are any options in shadow to make that compilation synchronous? I didn't see anything in the docs, just thought I'd check.#2021-11-2319:08thhelleryou can set :compiler-options {:parallel-build false} in your build config#2021-11-2319:09zalkyOk, thanks, I'll see where I can get with that, maybe I can get a simple repro. Very much appreciate you taking the time to provide some pointers.#2021-11-2320:52zalky@thheller, I put together a small https://github.com/zalky/shadow-repro. As best I can tell, it seems to me like a concurrency issue when it comes to macro compilation and transitive dependencies between recompiled namespaces. Let me know if I may have missed anything or could provide anything else that might be useful.#2021-11-2321:15awb99I have a question on polylith builds (so multiple deps.edn projects with :local/root dependencies. Could it be that shadow-cljs does not pick up the deps.cljs of multiple projects in this case? So I have to create ONE big deps.cljs file. I assume that shadow-cljs is looking only into JARS, and since the local deps are FILES, it will not find them inside a jar. I have not noticed a similar behavior when using JAR dependencies on clojars for exampel.#2021-11-2321:17awb99This issue does not happen, when the deps.cljs are in an empty namespace, so say in "src" of each project.#2021-11-2321:17awb99However, in this case when multiple projects get ombined into a JAR, then of course the classpaths of that jars will conflict.#2021-11-2404:08mauricio.szaboHi - is there a way for shadow-cljs to produce import ... instead of require ... in the resulting JS? The reason for that is that I have to interface with some libs that only use import in node.js, and I would like to not have to use an external bundler (to not loose the power of the REPL for development, for example)#2021-11-2406:05thheller@mauricio.szabo :target :esm does that, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-11-2407:33thheller@hoertlehner deps.cljs files just need to be on the classpath, it doesn't matter whether thats in a jar or just a directory. combining them when building a jar is something you need to do as a jar can only contain one#2021-11-2409:51henryw374I'm trying to use https://github.com/JedWatson/react-select in a build and shadow is complaining that the required dependency "process" is not available There is no declared dependency on process but I can see in the code there is if (typeof process !== 'undefined' so it's basically doing a polyfill. I can see why shadow has flagged it, but is there any opt to get shadow to let this kind of thing through?#2021-11-2409:54thheller@henryw374 I'm guessing you don't have shadow-cljs npm package installed in the project. which means you are also missing the polyfills that provides. basically just npm install shadow-cljs#2021-11-2409:56henryw374I don't. will try adding that now.#2021-11-2410:38henryw374installing that worked, thanks @thheller. I can add shadow-cljs to my deps.cljs file, but that necessarily means putting the required shadow-cljs version there and also in deps.edn for the shadow-cljs maven lib.#2021-11-2416:52thhellerI don't understand. this is about polyfills so you should most definitely never add shadow-cljs to your deps.cljs file?#2021-11-2417:04henryw374to work around the original problem I needed the npm shadow-cljs package. currently my deps.edn file has shadow mvn dep in it, so then if I'm also adding npm shadow, I need to ensure its version matches the mvn version#2021-11-2417:06henryw374to get the shadow-cljs npm dep I add it to my project's deps.cljs file, but that's just my preference rather than just putting it in package.json#2021-11-2417:07thhelleryou MUST have it in package.json as well as you MUST keep your package-lock.json in version control. not doing this is NOT an option in the JS world, unless you like pain of course#2021-11-2417:08thhellerif you really must put this in deps.cljs then put node-libs-browser there, not shadow-cljs#2021-11-2417:09henryw374sure, it ends up in package.json anyway and they get committed. but at least in deps.cljs i can have comments etc. ok thanks i will try that lib instead#2021-11-2417:10thhelleryeah I'm just saying that due to the extensive use of version ranges in the npm world you really must keep a lock file and therefore maintain a package.json as well#2021-11-2417:10thhellerotherwise you basically get random results when installing stuff which is never good#2021-11-2417:11henryw374yeah I get it - we do check in lock file as well. thanks#2021-11-2417:11thhellerI know a few people that tried to use npm as if it didn't exist and ignored package.json and lockfiles and so on#2021-11-2417:11thhellerI don't know a single one that didn't end up regretting that 😛#2021-11-2417:12henryw374:thumbsup:#2021-11-2412:48roman01la👋 Is it possible to trigger shadow’s heads up view to display an error message thrown during macro expansion time?#2021-11-2416:37Stephen WisemanIt it possible to still use leiningen, but defer to shadow to manage cljs build + dependencies? Our current dev workflow is to start a repl using lein, then leverage component lifecycles to start/stop the different components of the app (both backend and frontend components). For the front-end component, we call the shadow api to start a shadow server and a shadow watch. The subsequent build always seems to use the lein dependencies. In contrast, if I test by simply starting a watch using the shadow cli, it will use the dependencies in shadow-cljs.edn, which is what I’m going for.#2021-11-2416:51thheller@roman01la I don't understand the question. they should already show up?#2021-11-2418:05roman01lahm, not really, for me assertion errors are not showing up, instead shadow’s hot reload icon keeps spinning in a browser, but the error is indeed printed in the terminal#2021-11-2418:05roman01laon the other hand NPEs are showing up#2021-11-2418:05roman01lacould be a bug?#2021-11-2419:56thhellerwhat kind of assertion errors? just assert?#2021-11-2419:59thhellershows up as expected for me#2021-11-2422:52roman01lahm, could be something with my setup then#2021-11-2416:54thheller@swiseman108 dependencies are managed when starting the JVM since they are JVM dependencies. so however you started the JVM will decide which dependencies shadow-cljs sees. so I guess the answer is no?#2021-11-2419:13Stephen WisemanThanks. I was thinking this was the case. Thanks again for bearing with me and my questions!#2021-11-2516:54erwinrooijakkersI want to have a folder “src” and a folder “test” and then run tests via karma. I have specified :source-paths ["src" "test"], but when I run the tests via npx shadow-cljs compile ci && npm run karma (using setup in https://shadow-cljs.github.io/docs/UsersGuide.html#_the_build) it says 0 tests are found. If I move my test file to the “src” folder and I run the command the tests are found. Is there a way to have a separate test folder from where tests are picked up?#2021-11-2516:57thhellerdo you actually use shadow-cljs.edn to manage your dependencies? or do you use deps.edn or project.clj?#2021-11-2516:57erwinrooijakkersI use shadow-cljs.edn#2021-11-2516:57thhellerand the files are properly namespaced and match the regexp? ie. default namespaces ending in -test#2021-11-2516:58erwinrooijakkersyes#2021-11-2516:59erwinrooijakkersthe namespace ends in -test, the file with _test#2021-11-2516:59thhellerand you did actually restart shadow-cljs after making that change?#2021-11-2516:59erwinrooijakkersI rerun npx shadow-cljs compile ci && npm run karma#2021-11-2516:59erwinrooijakkersmaybe I can do a deeper clean?#2021-11-2516:59thhellerthat doesn't imply restarting#2021-11-2516:59thhellerdoes it say "connected to server"?#2021-11-2516:59erwinrooijakkersyes#2021-11-2517:00thhellerthen you still have a server instance running with the old settings I guess#2021-11-2517:00erwinrooijakkersaha 🙂#2021-11-2517:00thhellerneed to restart that#2021-11-2517:00erwinrooijakkersI stopped the server#2021-11-2517:00erwinrooijakkersnow it works 🙂#2021-11-2517:00erwinrooijakkersokay thanks!! 😄#2021-11-2517:00erwinrooijakkersswift reply and happy it works#2021-11-2519:34Stephen WisemanReal quick question: The docs mention that you can set the compiler option :infer-externs to :auto , which will trigger the compiler to warn about possible extern issues. However, in the compiler options section of the docs, it says that infer-externs defaults to true, which also seems to generate warning about possible extern issues. What’s the difference between :auto and true?#2021-11-2519:36Stephen WisemanMy assumption is that :auto maybe does something extra to generate the appropriate externs (given a simple ^js typehint), and true does not. However, I can’t quite tell from the docs if this is a correct assumption.#2021-11-2606:00thheller@swiseman108 :auto is the default nowadays. The difference is that normally you need to (set! *warn-on-infer* true) in your files to enable the warnings. the externs inference is done regardless but you need to opt-in to get the warnings about it. :auto just sets that to true by default for your files (ie. not files from .jar files)#2021-11-2721:13wontheone1Hi When I added a dependency (https://github.com/alexanderjamesking/spy) to deps.edn. (It’s a shadow cljs project). This is my deps.edn (
{:paths ["src" "test"]

 :deps
 {...omitted dependencies...
  thheller/shadow-cljs {:mvn/version "2.8.58"}

  ;; TODO: separate dev dependencies
  tortue/spy {:mvn/version "2.9.0"}

  ;; Requires xmlhttprequest from NPM
  cljs-ajax {:mvn/version "0.7.5"}}}
When I run yarn shadow-cljs watch :dev , I get the following error.
Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).
com.google.javascript.jscomp.AnonymousFunctionNamingPolicy

Full report at:
/var/folders/nd/8wtw0fvj50g96ch7b_tphgym0000gn/T/clojure-2795789891682912303.edn
error Command failed with exit code 1.
info Visit  for documentation about this command.
#2021-11-2721:15wontheone1The spy library makes it clear it’s usable in CLJS too. And the Full report file contains the following.
{:clojure.main/message
 "Syntax error (ClassNotFoundException) compiling at (shadow/build/closure.clj:1:1).\ncom.google.javascript.jscomp.AnonymousFunctionNamingPolicy\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 1,
  :clojure.error/source "closure.clj",
  :clojure.error/path "shadow/build/closure.clj",
  :clojure.error/class java.lang.ClassNotFoundException,
  :clojure.error/cause
  "com.google.javascript.jscomp.AnonymousFunctionNamingPolicy"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (shadow/build/closure.clj:1:1).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 1,
     :clojure.error/source "shadow/build/closure.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7652]}
   {:type java.lang.ClassNotFoundException,
    :message
    "com.google.javascript.jscomp.AnonymousFunctionNamingPolicy",
    :at
    [java.net.URLClassLoader findClass "URLClassLoader.java" 382]}],
  :trace
  [[java.net.URLClassLoader findClass "URLClassLoader.java" 382]
   [clojure.lang.DynamicClassLoader
    findClass
    "DynamicClassLoader.java"
    69]
   [java.lang.ClassLoader loadClass "ClassLoader.java" 418]
   [clojure.lang.DynamicClassLoader
    loadClass
    "DynamicClassLoader.java"
    77]
   [java.lang.ClassLoader loadClass "ClassLoader.java" 351]
   [java.lang.Class forName0 "Class.java" -2]
   [java.lang.Class forName "Class.java" 348]
   [clojure.lang.RT classForName "RT.java" 2212]
   [clojure.lang.RT classForNameNonLoading "RT.java" 2225]
   [shadow.build.closure$eval11941$loading__6737__auto____11942
    invoke
    "closure.clj"
    1]
   [shadow.build.closure$eval11941 invokeStatic "closure.clj" 1]
   [shadow.build.closure$eval11941 invoke "closure.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 482]
   [shadow.build.js_support$eval11935$loading__6737__auto____11936
    invoke
    "js_support.clj"
    1]
   [shadow.build.js_support$eval11935 invokeStatic "js_support.clj" 1]
   [shadow.build.js_support$eval11935 invoke "js_support.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 619]
   [shadow.build.resolve$eval10432$loading__6737__auto____10433
    invoke
    "resolve.clj"
    1]
   [shadow.build.resolve$eval10432 invokeStatic "resolve.clj" 1]
   [shadow.build.resolve$eval10432 invoke "resolve.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 2793]
   [shadow.build.api$eval10424$loading__6737__auto____10425
    invoke
    "api.clj"
    1]
   [shadow.build.api$eval10424 invokeStatic "api.clj" 1]
   [shadow.build.api$eval10424 invoke "api.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 1789]
   [shadow.build$eval10418$loading__6737__auto____10419
    invoke
    "build.clj"
    1]
   [shadow.build$eval10418 invokeStatic "build.clj" 1]
   [shadow.build$eval10418 invoke "build.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 3894]
   [shadow.cljs.devtools.api$eval2025$loading__6737__auto____2026
    invoke
    "api.clj"
    1]
   [shadow.cljs.devtools.api$eval2025 invokeStatic "api.clj" 1]
   [shadow.cljs.devtools.api$eval2025 invoke "api.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.RT loadResourceScript "RT.java" 381]
   [clojure.lang.RT loadResourceScript "RT.java" 372]
   [clojure.lang.RT load "RT.java" 459]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6856 invoke "core.clj" 6115]
   [clojure.core$load invokeStatic "core.clj" 6114]
   [clojure.core$load doInvoke "core.clj" 6098]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5897]
   [clojure.core$load_one invoke "core.clj" 5892]
   [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
   [clojure.core$load_lib invokeStatic "core.clj" 5936]
   [clojure.core$load_lib doInvoke "core.clj" 5917]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 5974]
   [clojure.core$load_libs doInvoke "core.clj" 5958]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 5996]
   [clojure.core$require doInvoke "core.clj" 5996]
   [clojure.lang.RestFn invoke "RestFn.java" 1523]
   [shadow.cljs.devtools.cli$eval138$loading__6737__auto____139
    invoke
    "cli.clj"
    1]
   [shadow.cljs.devtools.cli$eval138 invokeStatic "cli.clj" 1]
   [shadow.cljs.devtools.cli$eval138 invoke "cli.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7170]
   [clojure.lang.Compiler load 

... Omit the rest ...
Does anyone know why this might be happening?
#2021-11-2721:18wontheone1Bumping shadow might fix this (I saw some old slack thread)#2021-11-2721:26wontheone1Bumped shadow-cljs version to
{:mvn/version "2.16.6"}
and seems like issue is fixed. Dealing with another issue though.
SHADOW import error /Users/w/flex-cli/.shadow-cljs/builds/test-once/dev/out/cljs-runtime/ajax.xml_http_request.js
#2021-11-2721:43wontheone1
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
Turns out I had to update cljs-ajax dependency too (from 0.7.5)
#2021-11-2813:26HagenekI am having some issues with shadowCljs and importing a compenent where I use ajax.core to fetch some data. When fire-ing up the REPL with Calva I get the following import error. Anyone encountered this?
========= Running Tests =======================
SHADOW import error /Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/todana.components.gigpage.api.js

/Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog/net/xmlhttp.js:173
    return new XMLHttpRequest();
    ^
ReferenceError: XMLHttpRequest is not defined
#2021-11-2906:21wontheone1I had a similar problem. How do we fix it?#2021-12-0122:04agilecreativityHere is how I solve this problem:
npm install xhr2
#2021-12-0122:05agilecreativityThen try
(:require ["xhr2" :as xhr2]
..)

(set! js/XMLHttpRequest xhr2)
#2021-12-0207:27wontheone1thx!#2021-11-2813:49thhellerlooks like you are in a node repl but using code meant for the browser#2021-11-2820:42polymerisIn the docs, section https://shadow-cljs.github.io/docs/UsersGuide.html#_project_clj_leiningen, it says "For example :lein {:profiles "+cljs"}". Should that be :profile?#2021-11-2906:16thheller@polymeris yes, fixed.#2021-11-2912:16romdoqThis may be a strange/silly question, but is there a way for the shadow-cljs dev server to share dependencies with a running webpack dev server? I have a re-frame project which is used as an :npm-module and included by our main web app. We also have some packages that are shared between the main app and the cljs project. Some of these shared packages require that only one instance be imported at once (singletons), for which we use peerDependencies. However, as best as I can tell, the shadow-cljs dev server imports a second instance of those packages in its output, so the browser hits their singleton guards and fails. 😕 I hope that was clear enough. 😅 Any suggestions?#2021-11-2916:47thhellerI do not understand the problem. peerDependencies does nothing regarding how a package is required/used at runtime#2021-11-2916:47thhellerif you use regular :npm-module build and let webpack post process the dependencies then there should be no issue since shadow-cljs will not be providing any JS deps#2021-11-2916:48thhellerif you however configured :js-provider or something then you'll get duplicates#2021-11-3013:14romdoqShould not providing the JS deps also be true of the shadow dev server, eg. shadow-cljs watch npm, when it is being yarn linked by the webpacked project? That's the situation we're having difficulty with Maybe there's some setting we've goofed. Though :js-provider certainly isn't being set explicitly. :thinking_face:#2021-11-3014:25romdoqOh! I think it's because webpack sees the node_modules in the linked package, and bundles those as the (duplicated) deps to use for the linked module. It seems like the problematic packages only need to be installed in the :npm-module's node_modules for the Karma test suite to run :thinking_face:#2021-11-2912:17Alexis SchadHi there, I have trouble with :shadow as a :js-provider targeting node:
The required JS dependency "crypto" is not available, it was required by "node_modules/seedrandom/seedrandom.js".

...

crypto is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.

        npm install --save-dev shadow-cljs

See: 
I do have shadow-cljs installed locally. Did I miss something? (crypto is used by mathjs, required in my project)
#2021-11-2912:58mauricio.szabo@U01V2D5ALKX, sometimes shadow-cljs can't find all libraries because there are a lot of libs that use some kind of require.resolving or other tricks to find out if their dependencies are available. Do you have crypto npm installed? If so, is it a pure JS library, or is it a native (C/C++) library?#2021-11-2912:59Alexis Schadcrypto is a native node js library (https://nodejs.org/api/crypto.html), it is polyfilled in node-libs-browser for browser target. Here I need to include mathjs in my node build, and mathjs requires the native crypto (that must not be included in the build).#2021-11-2913:04Alexis SchadI try to use a workaround
:resolve {"crypto" {:target :global                                           :global "crypto"}}
but it does not work.
#2021-11-2913:06Alexis SchadI guess it is supposed to work as crypto is listed here: https://github.com/thheller/shadow-cljs/blob/de52880090c7840ee30eb5369173c1bd7dd3055c/src/main/shadow/build/resolve.clj#L86#2021-11-2913:18Alexis Schad:resolve {"crypto" false} seems to work as a workaround#2021-11-2913:27mauricio.szaboYou can use :keep-as-requires, let me find it to you...#2021-11-2913:28mauricio.szaboHere's my config for Chlorine (it's a node-library that uses :shadow as :js-provider):
:js-options {:js-provider :shadow
                     :keep-native-requires true
                     :keep-as-require #{"atom"}}
#2021-11-2913:29mauricio.szaboYou can see if only adding :keep-native-requires true works. If it doesn't, change the :keep-as-require to #{"crypto"} and that should work 🙂#2021-11-2913:33Alexis SchadIt works! Thanks. I'll create a PR to add this into the user guide#2021-11-2916:45thhellernote that I do not recommend using :js-provider :shadow for node builds#2021-11-2916:45thhellerand therefore also not :keep-as-require or :keep-native-requires 😛#2021-11-2916:46thhellerbetter to do a regular build and post process with https://github.com/vercel/ncc if you must have a standalone file#2021-11-2917:26Alexis SchadI want the closest behaviour to the :browser target (that I use too). Unless there's an unworking library with this setup, is there a reason why not tu use :shadow for node builds?#2021-11-2917:48thheller:shadow is heavily optimized for the browser and usually not required for node#2021-11-2915:17orestisDoes shadow do something special to support (:require [goog]) , that the standalone CLJS compiler need configuration to support?#2021-11-2916:48thhellergoog is already an implicit dependency of every cljs namespace so you do not need it#2021-11-2918:18orestisYeah I didn't know that. Turns out there's some regression in CLJS: https://clojure.atlassian.net/browse/CLJS-3336#2021-11-2916:21Ovidiu StoicaHi there, I am trying to setup a aws-amplify-shadow-cljs project but I seem to have issues importing the amplify coding. Here are the issues: I seem to have similar issues to https://stackoverflow.com/questions/64461818/require-aws-amplify-v-3-amplify-and-auth-classes-in-clojurescript-reagent-shadow but even after I have done all those steps, it does not work. I will leave full error log in the comment to this post. Seems that from v4 of aws-amplify things don't work. shadow-cljs.edn:
{:source-paths ["src"]

 :dependencies [[proto-repl "0.3.1"]
                [binaryage/devtools "1.0.4"]
                [reagent "1.1.0"]
                [re-frame "1.2.0"]
                [day8.re-frame/re-frame-10x "1.1.13"]
                [bidi "2.1.5"]
                [kibu/pushy "0.3.8"]
                [com.andrewmcveigh/cljs-time "0.5.2"]]

 :nrepl        {:port 3333}

 :builds       {:app {:target           :browser
                      :output-dir       "public/js"
                      :asset-path       "/js"

                      :modules          {:main {:init-fn app.core/init}}
                      :js-options       {:provider   :closure
                                         :entry-keys ["main" "module" "browser"]}

                      :compiler-options {:output-feature-set :es6
                                         :closure-defines    {re-frame.trace/trace-enabled?        true
                                                              day8.re-frame.tracing/trace-enabled? true}}

                      :devtools         {:http-root "public"
                                         :http-port 3000
                                         :preloads  [day8.re-frame-10x.preload]}}}}
#2021-11-2916:22Ovidiu StoicaConsole errors about importing:
shadow.js.js:sourcemap:36 shadow-cljs - failed to load module$node_modules$aws_amplify$lib$index
shadow.js.jsRequire @ shadow.js.js:36
shadow.js.require @ shadow.js.js:59
eval @ app.core.js:2
goog.globalEval @ main.js:528
env.evalLoad @ main.js:1603
(anonymous) @ main.js:4961
main.js:1495 TypeError: util.inherits is not a function
    at Object.shadow$provide.module$node_modules$assert$assert (module$node_modules$assert$assert.js:12)
    at shadow.js.jsRequire (shadow.js.js:34)
    at Object.shadow$provide.module$node_modules$http2$lib$protocol$endpoint (module$node_modules$http2$lib$protocol$endpoint.js:2)
    at shadow.js.jsRequire (shadow.js.js:34)
    at Object.shadow$provide.module$node_modules$http2$lib$protocol$index (module$node_modules$http2$lib$protocol$index.js:1)
    at shadow.js.jsRequire (shadow.js.js:34)
    at Object.shadow$provide.module$node_modules$http2$lib$http (module$node_modules$http2$lib$http.js:9)
    at shadow.js.jsRequire (shadow.js.js:34)
    at Object.shadow$provide.module$node_modules$http2$lib$index (module$node_modules$http2$lib$index.js:1)
    at shadow.js.jsRequire (shadow.js.js:34)
reportError @ main.js:1495
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4961
main.js:1497 The above error occurred when loading "app.core.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.
reportError @ main.js:1497
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4961
shadow.module.main.append.js:4 An error occurred when calling (app.core/init)
eval @ shadow.module.main.append.js:4
goog.globalEval @ main.js:528
env.evalLoad @ main.js:1603
(anonymous) @ main.js:4962
main.js:1495 TypeError: app.core.init is not a function
    at eval (shadow.module.main.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:528)
    at Object.env.evalLoad (main.js:1603)
    at main.js:4962
reportError @ main.js:1495
env.evalLoad @ main.js:1605
(anonymous) @ main.js:4962
main.js:1497 The above error occurred when loading "shadow.module.main.append.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at other
#2021-11-2916:23Ovidiu StoicaCore file
(ns app.core
  (:require
    ["/aws-exports.js" :default aws-exports]
    ["aws-amplify" :default amplify]
    [reagent.core :as r]
    [reagent.dom :as dom]
    [re-frame.core :as rf]
    [app.db]
    [app.router :as router]
    [app.components.core :as c]))


(def functional-compiler (r/create-compiler {:function-components true}))
(r/set-default-compiler! functional-compiler)

(defn pages
  [page-name]
  (case page-name
    :inboxes [inboxes]
    :profile [profile]
    :become-a-chef [become-a-chef]
    :recipes [recipes-page]
    :recipe [recipe-page]
    :log-in [log-in]
    :sign-up [sign-up]
    [recipes-page]))


(defn app
  []
  (let [active-page @(rf/subscribe [:active-page])]
    [:<>
     [:div.bg-gray-100.w-screen.h-screen
      [:div.container.mx-auto
       [:div
        [nav]
        [pages active-page]]]]]))

(defn ^:dev/after-load start
  []
  (dom/render
    [app]
    (.getElementById js/document "app")))

(defn ^:export init
  []
  (.configure amplify aws-exports)
  (router/start!)
  (rf/dispatch-sync [:initialize-db])
  (start))
#2021-11-2916:24Ovidiu Stoicapackage.json:
{
  "name": "Cheffy",
  "version": "0.0.1",
  "description": "Cheffy - AirBnB for Chefs",
  "private": true,
  "repository": {
    "type": "git",
    "url": ""
  },
  "scripts": {
    "shadow:watch": "shadow-cljs watch app",
    "shadow:release": "shadow-cljs release app",
    "postcss:build": "cross-env TAILWIND_MODE=build postcss src/css/tailwind.css -o ./public/css/main.css --verbose",
    "postcss:watch": "cross-env TAILWIND_MODE=watch postcss src/css/tailwind.css -o ./public/css/main.css --verbose -w",
    "postcss:release": "cross-env NODE_ENV=production postcss src/css/tailwind.css -o ./public/css/main.css --verbose",
    "dev": "run-p -l *:watch",
    "release": "run-s *:release"
  },
  "devDependencies": {
    "autoprefixer": "^10.3.3",
    "cssnano": "^5.0.8",
    "npm-run-all": "^4.1.5",
    "postcss": "^8.3.5",
    "postcss-cli": "^8.3.1",
    "react-flip-move": "^3.0.2",
    "shadow-cljs": "^2.15.5",
    "tailwindcss": "^2.2.4"
  },
  "dependencies": {
    "@aws-amplify/ui-react": "^2.1.1",
    "@headlessui/react": "^1.4.2",
    "@heroicons/react": "^1.0.5",
    "@tailwindcss/forms": "^0.3.3",
    "aws-amplify": "^4.3.8",
    "aws-crt": "^1.10.2",
    "create-react-class": "15.7.0",
    "cross-env": "^7.0.3",
    "encoding": "^0.1.13",
    "highlight.js": "11.1.0",
    "http2": "^3.3.7",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  }
}
#2021-11-2916:29Ovidiu StoicaOther thing that is worth mentioning: The aws-amplify was requiring http2 module which (from what I remember) was built in with node js. I installed it with npm I http2 and there seem to be some errors related to this also#2021-11-2916:47David VujicThere might be some issues when using the Amplify UI components, but I’m not sure if that is the issue for you. I’m using AWS Amplify v4 and have solved by building my app in two steps: clojurescript + webpack. This blog post (with links to a fully working example repo) might help you: https://davidvujic.blogspot.com/2021/08/hey-webpack-hey-clojurescript.html#2021-11-2917:08Ovidiu StoicaHei @U018VMC8T0W! Yes, this is the problem, most likely! I will remake my repo after your demo! Thank you for the fast reply! #2021-11-2917:11David VujicGreat!#2021-12-0212:17Ovidiu StoicaDid you also have this error? Seems that it gets this error trying to access process.env.BROWSERLIST_DISABLE_CACHE and process is undefined. I saw you also tried to install process as an npm package (did this also but it does not fix the issue) UDPATE: Added this to the webpack config and it was fixed
plugins: [
        // fix "process is not defined" error:
        // (do "npm install process" before running the build)
        new webpack.ProvidePlugin({
            process: 'process/browser',
        }),
    ],
#2021-12-0212:50David VujicIn my case I added the process npm package, because there were conflicts with AWS Amplify and Storybook: both depending on Webpack, but with different versions. And Storybook used a feature that has been removed (process). So my workaround was to include it in the Storybook UI only. But I don’t think that package should be exposed in a web site (if I’m not mistaking).#2021-12-0212:54David VujicJust noticed your update: great!#2021-11-3017:16currentoorIs it possible to import local .mjs files when using shadow-cljs to make a node script? i.e. ECMAScript modules#2021-11-3017:17currentoorsomething like this https://github.com/clojure/clojurescript/commit/233b42338c182e72391466eba2d00bae34271e58#2021-11-3017:18thhellercan you define "import local .mjs files"?#2021-11-3017:18thhellerdo you want them as part of the build or dynamically at runtime?#2021-11-3017:22currentoori want to have .mjs files in my projects source, so dynamically at runtime#2021-11-3017:23currentoorbut if that’s not possible i’m guessing there’s probably a way to compile them to regular js files and consume those from shadow#2021-11-3017:23thhelleryou misunderstand my question I guess#2021-11-3017:23thhelleryou have a .mjs file (or many)#2021-11-3017:24thhellerdo you want them INCLUDED as part of the build by shadow-cljs#2021-11-3017:24thhelleror do you want to load them dynamically at runtime via js/import?#2021-11-3017:25thhelleryou can do this https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-11-3017:25thhellerjust put them on the classpath and (:require ["/some/place/file.mjs" :as x])#2021-11-3017:26thhellerthat would be included in the build just as any other CLJS source or so#2021-11-3017:26thhellerso the .mjs files don't need to be accessible after the build#2021-11-3017:26thhellerhowever the files will be part of :advanced optimizations so you might have to deal with externs#2021-11-3017:31thhellerto be clear I'm asking this because node is capable of loading .mjs files dynamically at runtime without shadow-cljs ever knowing about it (ie. (js/import "./that-file.mjs")#2021-11-3017:31thhellerincluding it as part of a build is entirely different but also works#2021-11-3017:53currentoorah got it, thanks!#2021-11-3017:53currentoor> I was thrown off by this bit in the docsFor string requires the extension `.js` will be added automatically but you can specify the extension if you prefer. Note that currently only `.js` is supported though.#2021-11-3017:53currentoorI thought that meant (:require ["/some/place/file.mjs" :as x]) won’t work#2021-11-3017:54currentoorgood to know i can use js/import as a fail safe#2021-11-3021:11currentoordoesn’t seem to work, js/import or shadow.esm/dynamic-import
(js/import "...")
=> ReferenceError: import$ is not defined

(shadow.esm/dynamic-import "...")
=> ReferenceError: shadow_esm_import is not defined
#2021-12-0101:17currentoorI was able to get it working by defining the dynamic require inside a .js file
module.exports = import('./index.mjs');
then using js/require to require this .js file
#2021-12-0106:40thhellerwell dynamic import should be your last option really#2021-12-0106:40thhellerbut yeah I forgot that it only works in target esm currently#2021-12-0118:50currentooris that target undocumented?#2021-12-0118:50currentoorthis dynamic import work in dev mode but breaks in production silently, looks like it’s failing to load#2021-12-0118:55thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-12-0118:56thhellerit would help a lot if you explained what that file is doing#2021-12-0118:56thhellerI'm almost positive that the dynamic import path is not something you should or want to be doing#2021-12-0118:57currentoori agree, i don’t want to use dynamic import#2021-12-0118:58currentoorso i’ve got a node script, using the :node-script target and it’s working well, but I need to add some .mjs source to the project#2021-12-0118:58thhellerso put it on the classpath and require it normally?#2021-12-0118:58currentoorbut it’s an .mjs file, will that work?#2021-12-0118:59thhelleryes, just add the extension when requiring it#2021-12-0118:59currentoorit’s also a sub module with it’s own package.json#2021-12-0118:59thhellerthats new information#2021-12-0118:59currentooryeah sorry#2021-12-0119:00thhellerso it is an actual package. not just a file you want to include?#2021-12-0119:00currentoorcorrect#2021-12-0119:00thhellersame deal really. require it like any other JS file, just add the extension#2021-12-0119:01currentooroh so using yarn i can just add it to the root package json? like so? "mutesync_engine_win32": "file:./mutesync_engine_win32",#2021-12-0119:01thhellerno#2021-12-0119:01thhelleror I mean sure you can do that but shadow-cljs doesn't care about this at all#2021-12-0119:01thhellerit only cares that something is in the node_modules folder#2021-12-0119:01thhellerhow it got there does not matter one bit#2021-12-0119:02thhellerso assuming you end up with a node_modules/mutesync_engine_win32 all is fine#2021-12-0119:03thhellerso you do (:require ["mutesync_engine_win32" :as x]) in your code#2021-12-0119:06currentoori tried that and get this error#2021-12-0119:06currentoor
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\19518\src\mutesync\shells\electron\node_modules\mutesync_engine\index.mjs
    at Module.load (internal/modules/cjs/loader.js:933:11)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at C:\Users\19518\src\mutesync\.shadow-cljs\builds\electron-main-dev\dev\out\cljs-runtime\shadow.js.shim.module$mutesync_engine.js:3:41
    at global.SHADOW_IMPORT (C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:64:44)
    at C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:1757:1
    at Object.<anonymous> (C:\Users\19518\src\mutesync\shells\electron\js\background\main.js:1786:3)
    at Module._compile (internal/modules/cjs/loader.js:1078:30)
#2021-12-0119:06currentoorthat is the right file though#2021-12-0119:07currentoorindex.mjs is an ES module#2021-12-0119:07thhellerah right#2021-12-0119:07thhelleryeah node cannot import ESM from commonjs#2021-12-0119:07thhellerI guess electron can't either then#2021-12-0119:07currentoorelectron is running node so yeah#2021-12-0119:08thhellerso one option is using :target :esm to turn the CLJS output into ESM#2021-12-0119:08currentoori can do that for a node script?#2021-12-0119:08currentoorare there any known incompatibilities?#2021-12-0119:09thhellera whole lot yeah 😉#2021-12-0119:09thhellercommonjs and ESM interop sucks#2021-12-0119:10currentoorlol so what are the options if i want to keep the node-script target?#2021-12-0119:10thhellerforget about the node-script part for a second, that really doesn't mean anything#2021-12-0119:11thhellerI'm assuming you want something that can function as a electron main script#2021-12-0119:11thhellerie. not actual node#2021-12-0119:11currentoorcorrect#2021-12-0119:12thheller:node-script and :esm should both be equivalent in that regard#2021-12-0119:12currentoorbut a temporary hack would work for now, anything frowned upon i can do with global variables and js*?#2021-12-0119:12thhelleronly that :esm is ESM and therefore will work with ESM packages#2021-12-0119:12thhellerbut may have issues with commonjs#2021-12-0119:12thhellerwhereas :node-script is commonjs and has issues with ESM 😛#2021-12-0119:13thhellerno, you really can't do that#2021-12-0119:13thhellerthe import issue is a closure compiler issue, so release will likely break#2021-12-0119:13currentooryeah my release build is broken#2021-12-0119:13thhelleryou can indeed work arround the CLJS compiler renaming to import$ thing but that still doesn't fix release#2021-12-0119:14currentooris there a way to include some extra JS source at the end after the cljs/closure compiler is done doing it’s thing?#2021-12-0119:15currentooror prefix source i suppose would be better#2021-12-0119:15thhellerthat is not the issue here at all#2021-12-0119:15thhellershadow-cljs is not including ANY node_modules packages in a :node-script build at all#2021-12-0119:16thhellerinstead electron will load them dynamically at runtime and fails#2021-12-0119:16currentoorright#2021-12-0119:16thhelleryou can make it part of the build, but for that the file needs to be on your classpath and not in node_modules#2021-12-0119:16currentoorhow’s that?#2021-12-0119:16thhelleras I linked yesterday https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-12-0119:17currentoorah right, so will the closure compiler touch those files?#2021-12-0119:18thhelleryes, it'll become part of the build and go through :advanced in release#2021-12-0103:04Drew Verlee@quoll ^ discuss here? if its a toy project can you share it on github? I'm sure someone can figure out whats not working correclty. If you added shadow to an existing project, then you likely need to change how your handling deps and building etc...#2021-12-0103:05quollsure. Let me put it up there#2021-12-0103:13quollOK, it’s at https://github.com/quoll/toy#2021-12-0103:14quollI mean… it’s basically nothing#2021-12-0103:18Drew VerleeI'm guessing we need to add a build.#2021-12-0103:18quollI’ll note that I can run shadow-cljs node-repl on the command line, and from there I can load toy.m2 and execute the function in there#2021-12-0103:23quollmaybe the paths aren’t set up? When I’m at the repl in cider, I tried this:
shadow.user> (require '[toy.m2])
Execution error (FileNotFoundException) at shadow.user/eval27877 (REPL:45).
Could not locate toy/m2__init.class, toy/m2.clj or toy/m2.cljc on classpath.
#2021-12-0103:23quollmeanwhile, at the command line:
cljs.user=> (require '[toy.m2])
nil
cljs.user=> (ns toy.m2)
nil
toy.m2=> f
#object[toy$m2$f]
toy.m2=> (f 2 3)
5
#2021-12-0103:25Drew Verleemy cider-jack-in-cljs seems to just hang. Which is a matter of some confusion for me.#2021-12-0103:25Drew Verleegoing to restart emacs...
#2021-12-0103:27Drew Verleeoh. i didn't install shadow globally#2021-12-0103:30Drew Verleeok. @quoll i can eval expressions in emacs for your toy project if i 1. npm install (which is what i was stalled on lol) 2. cider-jack-in-cljs (shadow > browser | node )#2021-12-0103:33quollI hadn’t run npm install now that I have, it’s asking me for a build :woman-shrugging:#2021-12-0103:33Drew Verleeisn't there a "browser-repl" or a "node" option?#2021-12-0103:34Drew VerleeIn the larger sense, what type of application/build are you planing on building?#2021-12-0103:34quolla clojurescript library#2021-12-0103:35quollno UI at all#2021-12-0103:37Drew VerleeI believe it makes the most sense for the target to be "browser" then even though you don't plan on actually rendering something a browser, thats the like... plateform.#2021-12-0103:38quolleh… when running this stuff I’m almost exclusively in node, though I know others will use browsers#2021-12-0103:39Drew VerleeYou can develop it using the node repl. As long as you don't call any node specific functionality it would be fine.#2021-12-0103:41Drew VerleeOr i suppose you can, but then you could use macros to tell which env your in and choose the correct code.#2021-12-0103:46quollIt’s really frustrating…. I am running shadow-cljs at the command line, and the repl there loads the namespace fine. I then try cider-connect to that same process, and it can’t find the namespace. It’s like the nREPL server is completely independent of the process that’s giving me the CLI repl#2021-12-0103:47Drew Verleeare you running cider-connect-cljs ?#2021-12-0103:47quollno#2021-12-0103:49quollI wasn’t aware that connect had that option. OK, I’m back to where I was a moment ago… it’s asking me for a build, and so far I have been unsuccessful at guessing what a “build” is#2021-12-0103:51Drew Verleewhen i use cider-jack-in-cljs it gives me a couple default "shadow builds" of node and repl. If you start from the command line i'm not sure they are there. looking at shadow docs#2021-12-0103:53Drew Verleerunning shadow-cljs browser-repl Then cider-connect-cljs -> browser-repl , would likely work except now i need to inject my nrepl deps.#2021-12-0103:53Drew Verleewhich is why i always use cider-jack-in-cljs because it injects them for me#2021-12-0103:53quollhuh… choosing a build of “node” didn’t give me an error of “build not found”. Instead I have a failed assertion#2021-12-0103:55Drew VerleeHere is a node repl
➜  toy git:(main) ✗ shadow-cljs node-repl
shadow-cljs - config: /home/drewverlee/Personal/toy/shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.6 running at 
shadow-cljs - nREPL server started on port 35837
#2021-12-0103:55quollOK. I get something similar#2021-12-0103:56Drew Verleethen i would do cider-connect-cljs > shadow > node-repl#2021-12-0103:57Drew Verleethen if i check my repl buffer in emacs illl get
;; Connected to nREPL server - 
;; CIDER 1.2.0snapshot (package: 20211123.1732), nREPL 0.8.3
;; Clojure 1.10.3, Java 11.0.11
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/node-repl))
;;
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will not be available without it! (More information)
To quit, type: :cljs/quit
[:selected :node-repl]WARNING: clj-refactor and refactor-nrepl are out of sync.
Their versions are 3.2.2 (package: 20211117.1008) and n/a, respectively.
You can mute this warning by changing cljr-suppress-middleware-warnings.shadow.user> 
cljs.user> 
#2021-12-0103:57quollnode-repl is something I haven’t tried. Let’s try that#2021-12-0103:57Drew VerleeYea, i think it's a bit confusing bc there is just a "node" option that's not nested under shadow. I'm guessing that works to ... somehow 😖... in a none shadow context.#2021-12-0104:00quollIt’s working! I can’t do things like C-c M-n M-n, but I can type at the repl in emacs!#2021-12-0104:01Drew Verleegreat. So likely you get the same warning i do in my repl buffer telling you that "cider requires cider-nrepl"?#2021-12-0104:03quollYes. I’ve had this warning ever since I first started using Cider (with Clojure) a few years ago. I can’t make it go away. But it has never interfered with Cider on Clojure, so I eventually stopped trying to fix it#2021-12-0104:01quollDrat. C-c C-k doesn’t work. 😞#2021-12-0104:02Drew VerleeI use space emacs, i'm not sure what that command does.#2021-12-0104:02quollload the namespace#2021-12-0104:04Drew VerleeThere are a couple ways to have the cider-nrepl dep be added so everything works. docs here https://shadow-cljs.github.io/docs/UsersGuide.html#user-config and here: https://docs.cider.mx/cider/cljs/shadow-cljs.html If your going to use "cider-connect-*" (as opposed to "cider-jack-in-cljs") then this note here is relevent https://docs.cider.mx/cider/cljs/shadow-cljs.html#using-cider-connect-cljs > > If cider-nrepl isn’t in your classpath you should make sure it’s there. You can do this by adding it to :dependencies in the shadow-cljs.edn configuration file residing in the root of your project. Alternatively you can set cider-repl-auto-detect-type to nil, as the auto-detection of REPL types doesn’t work without cider-nrepl. #2021-12-0104:06Drew Verleeerr. that note is correct, but that would mean you pakage up nrepl-cider with your package when you distribute it.#2021-12-0104:08Drew Verleei would put it in the project root /.shadow-cljs/config.edn or ~/.shadow/config.edn which are merged in but not added in prod builds.#2021-12-0104:10Drew Verlee@quoll ^ some more notes. I'll likely need to crash in a minute .You should definitely get cider working properly! I can help tomorrow if you have issues. Your talks on graph databases and rules engines are a joy to watch. I keep wanting to flirt with Asami to!#2021-12-0104:15quollThank you for the compliment 🙂#2021-12-0104:14quollTurns out that when I moved things into “toy” I left one terminal in the wrong directory (with identical contents). This has been causing me grief 😬 Sorry!!!!#2021-12-0104:17quollIt’s working! Whew! You may not see this until morning, but thank you for your patience!#2021-12-0106:47thhellerif this is not current anymore I'd appreciate an update https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2021-12-0106:47thhellerI don't use emacs so I have no clue how any of it works#2021-12-0107:07robert-stuttafordhttps://twitter.com/RobStuttaford/status/1465938201076457472#2021-12-0107:56David VujicPull request sent 😄 https://github.com/shadow-cljs/shadow-cljs.github.io/pull/73/files#2021-12-0108:12robert-stuttafordrockin!#2021-12-0121:09RyanI updated IntelliJ today to latest (2021.2) and now built apps are showing that a previously available node module is unavailable, among some other curious errors (like fn not existing).. any clues or reported troubles with IntelliJ 2021.2?#2021-12-0121:30RyanI restarted intelliJ to no avail, but a full computer restart prompted shadow-cljs to download a new version, rebuild and all is well! 🙂#2021-12-0200:14Drew Verleei'm able to eval expressions in one file but not another in the same project. my emacs buffers says its connected in one but not the other. I can't imagine how this could be.#2021-12-0205:28thhellersorry can't answer emacs questions at all#2021-12-0415:36Drew VerleeWhat editor do you use if i might ask?#2021-12-0415:51thhellerCursive#2021-12-0212:52zeitsteinMaybe I'm misunderstanding something, but here goes. I have :paths ["src/main" "resources"] in deps.edn and :dev-http {8000 "classpath:public"} in shadow-cljs.edn. The dev server serves index.html correctly from resources/public when requested from localhost:8000, but any other URL results in 404. From the https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http, I would expect that resources/public/index.html is served, rather than resulting in 404, correct? If I change to :dev-http {8000 "resources/public"} it works as expected. Wondering if its caused by something in shadow.http.push-state/handle.#2021-12-0219:22thhelleryes, that handler assumes files not resources#2021-12-0219:32thhellerfeel free to open an issue about this. can't get to it right now#2021-12-0216:21RyanOk, working today and suddenly I'm getting errors about a node package not being available, even though it was there the a second ago. I restarted the computer (it helped yesterday) and to no avail today. Error message is :
pnx-web.js:1455 Module not provided: module$node_modules$primereact$menu$menu_cjs
#2021-12-0216:29RyanUpdated all packages that had updates (re-frame-10x and shadow-cljs) .. compiler runs fine, imports are present.#2021-12-0216:36RyanIf I look at the included js in chrome, I can navigate through node modules to get to the offending module and it does appear to be there.
shadow$provide["module$node_modules$primereact$menu$menu_cjs"] = function(global,require,module,exports) ...
#2021-12-0216:41RyanOoh, It may have been an errant capital P in the import, but not sure yet.#2021-12-0216:57RyanNope, it does not seem to have been that.#2021-12-0217:13David VujicCould it be something with ES vs CommonJs imports? Maybe you have updated a dependency with breaking changes?#2021-12-0217:19RyanThats a good question. I'm using a great many prime react modules and the rest seem to work. The update I did that seemed to trigger this was updating IntelliJ, tho I can't clearly see what that would have impacted.#2021-12-0217:21RyanWhen I first did that (yesterday), the Button module wasn't working, but a reboot got everything going again and button has not been cranky since#2021-12-0217:36RyanOk so I think the errant capital P has lived on#2021-12-0217:37Ryan
SHADOW_ENV.evalLoad("module$node_modules$primereact$menu$menu_cjs.js", true, "shadow$provide.module$node_modules$Primereact$menu$menu_cjs\x3dfunction(global,require,module,exports) ...
#2021-12-0217:38RyanThere's def. no reference to PrimereactMenu in the requires anymore (there was 1) .. I nuked it from orbit, but it seems like something somewhere has cached it? The rest of the modules are lowercase as they should be.#2021-12-0217:42David VujicI guess you've already tried it, but if you haven't already: a rm -rf node_modules and an npm install usually does the trick 😄 #2021-12-0217:43Ryanhmm I tried npm ci but the shouldn't hurt!#2021-12-0217:43RyanI've tried so many things to get my project building in last 3 hours that I cant remember what I did when 😄#2021-12-0217:44David VujicAnother trick is to go back in git history step by step until things start working again 😄 #2021-12-0217:55RyanSo the compile process is generating references to Primereact still.. if I go into the compiled files and edit them all back to lowercase my project is back#2021-12-0218:03RyanThere is one that pops back into the compiled file every time, not sure where its getting it from#2021-12-0218:04RyanThe SHADOW_ENV stuff#2021-12-0218:06Ryan@U05224H0W any clues? I'm stumped at how to fix this. I checked the js module itself for references to Primereact instead or primereact and it does not appear to be causing the capital P to recur.#2021-12-0218:07thhellerdid you try wiping .shadow-cljs/builds and restarting shadow-cljs?#2021-12-0218:08thhellerI don't really know what you are doing but usually errors such as this are user errors#2021-12-0218:08thhellerie. did you modify your :modules config but did not adjust actually loading those modules in your HTML?#2021-12-0218:09thhellerdid you maybe change your :output-dir and just continue loading a mix of old and new files?#2021-12-0218:11RyanI am almost certain it is user error 🙂#2021-12-0218:12RyanI definitely had an errant require statement with a capital P, which I then eliminated but builds after kept going back to it regardless of npm ci / rebuild npm etc.#2021-12-0218:15RyanNuking the .shadow-cljs/builds folder fixed it!#2021-12-0218:16thhellerwhich shadow-cljs version do you use?#2021-12-0218:49Ryan2.16.6#2021-12-0311:41residentsummerHi! I was doing some setup for local development to minimize the chances of accidentally releasing a build with wrong configuration and encountered a strange behaviour. I've tried to override :closure-defines from my build hook with values it reads from local file, but updates were not propagating into the build. Here are the snippets: app/dev.clj
(defn load-dev-vars
  {:shadow.build/stage :configure}
  [{:keys [:shadow.build/mode] :as build-state} relative-path]
  (let [conf-path (File. (:project-dir build-state) relative-path)]
      (if (and (= :dev mode) (.exists conf-path))
        (let [overrides (edn/read-string (slurp conf-path))]
          (println "Applying vars override:" overrides)
          (update-in build-state [:shadow.build/config :closure-defines]
                     merge overrides))
        build-state)))
shadow-cljs.edn
{...
 :builds
 {:front
  {:target :browser
   :modules {:main {:init-fn app.system/go}}
   ;; Dev vs Prod build vars. Override via extra config.
   :build-hooks [(app.dev/load-dev-vars "local-defines.edn")]
   :closure-defines {app.config/api-root "/api"}}}}
Inspecting build-state showed that overrides were applied as expected, but build contained original values... Looking at the shadow-cljs source I found that at :configure stage defines are injected into other part of build-state - :complier-options. Changing the path from [:shadow.build/config :closure-defines] to [:compiler-options :closure-defines] indeed fixed the issue. Why not just add my defines into :dev :closure-defines in shadow-cljs.edn - I don't want to commit local configuration into version control and/or stash the changes on every pull. With an additional file, added into git and docker ignores, it's much easier to manage. My question: is it expected behavior or just code ordering issue in configure stage of shadow-cljs? Maybe it was not supposed that users would change build configuration in hooks?..
#2021-12-0315:37thhellerat the point the :configure hook runs the build config is already applied and as such modifying it has no effect#2021-12-0315:38thhelleryou can update [:compiler-options :closure-defines] directly instead#2021-12-0315:49residentsummerHello. Yeah, thanks, I've figured that out already 🙂#2021-12-0315:51residentsummerJust wondered if it's a bug or I was not supposed to change build config in hooks.#2021-12-0315:58thhellerI answered that. Intended to be like that#2021-12-0314:10FranklinHello I'm getting this error when I try to call postMessage on a web worker
subs.cljs:94 Uncaught ReferenceError: document is not defined
    at subs.cljs:94
    at worker.js:1457
    at Array.forEach (<anonymous>)
    at Object.env.load (worker.js:1453)
    at worker.js:1489
(anonymous) @ subs.cljs:94
(anonymous) @ worker.js:1457
env.load @ worker.js:1453
(anonymous) @ worker.js:1489
#2021-12-0314:11Franklinthe webworker itself looks as follows
(ns quagga.components.dataview.worker)

(defn init []
  (set!
   js/self.onmessage
   (fn [^js e]
     (js/console.log "message received" (.. e -data)))))
#2021-12-0314:11FranklinI've added it to the modules like this
:worker
          {:init-fn quagga.components.dataview.worker/init
           :depends-on #{:shared}
           :web-worker true}
#2021-12-0314:12FranklinI've also added it to the html with a script tag of type "text/js-worker"#2021-12-0314:12FranklinI'm calling postMessage as follows on the repl
(let [worker (js/Worker. "/js/quagga/worker.js")] (.. worker (postMessage "hello world")))
#2021-12-0314:31Franklinnot sure what I'm missing#2021-12-0314:45p-himikWhat comprises the module :shared? Given the stacktrace, there's some subs.cljs file in there that tries to reference js/document, which does not exist in web workers.#2021-12-0315:10Franklinshared actually has nothing, it's defined like this
:shared {:entries []},
#2021-12-0315:11FranklinI think it's because all my other modules depend on shared#2021-12-0315:14FranklinI tried to make the web worker module depend on :depends-on #{} but then it says
ExceptionInfo: two modules without deps, please specify which one is the default
#2021-12-0315:17p-himikOh, interesting. Maybe I misunderstand something then. Shadow-cljs docs say: > You can leave the `:entries` of the `:shared` module empty to let the compiler figure out which namespaces are shared between the other modules. But that subs.cljs still comes from somewhere even though your web worker ns clearly doesn't depend on it. @U05224H0W Could it be a bug?#2021-12-0315:33thhellerare there other modules that may cause stuff to be moved into :shared that the worker doesn't like?#2021-12-0315:34thhellercan't say without your full config#2021-12-0315:34Franklin
:devtools
         {:preloads [day8.re-frame-10x.preload],
          :watch-dir "resources/public/css/"},
       :modules
         {:home
            {:depends-on #{:shared}, :entries [quagga.components.home.init]},
          :organization
            {:depends-on #{:shared},
             :entries [quagga.components.organization.init]},
          :settings
            {:depends-on #{:shared},
             :entries [quagga.components.organization.settings.init]},
          :shared {:entries []},
          :tabbed-dataview
            {:depends-on #{:shared},
             :entries [quagga.components.dataview.init]},
          :user-management
            {:depends-on #{:shared},
             :entries [quagga.components.organization.users.init]}
          :worker
          {:init-fn quagga.components.dataview.worker/init
           :depends-on #{:shared}
           :web-worker true}},
       :output-dir "resources/public/js/quagga/",
#2021-12-0315:35Franklinthere probably are other modules bringing in code that's trying to use js/document#2021-12-0315:35thhelleryeah so so since you only have :shared anything that two of the other modules may use will get moved to :shared#2021-12-0315:35Franklinoh... ok#2021-12-0315:35thhellerend as such also end up getting loaded by the worker#2021-12-0315:35thhellermake an extra :base module or so#2021-12-0315:35Franklincool...#2021-12-0315:36thhellerthat the :shared and :worker depend on but have all the others only depend on :shared#2021-12-0315:36thhellerboth with :entries [] is fine#2021-12-0315:36Franklincool#2021-12-0315:36p-himikAh, I see. At least to me, the wording in the documentation made it seem like :shared has namespaces that are shared by all other modules that depend on :shared. Thanks!#2021-12-0316:57thhelleryeah a namespace can only ever be in one module so if say something from :home and :settings share a required namespace the only place it can go is :shared.#2021-12-0317:03p-himik> a namespace can only ever be in one module Now that you said it out loud, it became obvious to me as well. :)#2021-12-0318:33Franklinunfortunately, I'm still getting the same error with this setup
:modules
         {:home
            {:depends-on #{:shared}, :entries [quagga.components.home.init]},
          :organization
            {:depends-on #{:shared},
             :entries [quagga.components.organization.init]},
          :settings
            {:depends-on #{:shared},
             :entries [quagga.components.organization.settings.init]},
          :shared {:entries []
                   :depends-on #{:base}},
          :base {:entries []}
          :tabbed-dataview
            {:depends-on #{:shared},
             :entries [quagga.components.dataview.init]},
          :user-management
            {:depends-on #{:shared},
             :entries [quagga.components.organization.users.init]}
          :worker
          {:init-fn quagga.components.dataview.worker/init
           :depends-on #{:base}
           :web-worker true}}
#2021-12-0319:56thhellerare you sure none of the namespaces used by the quagga.components.dataview.worker ns end up including the problem ns?#2021-12-0319:57thhellergenerate a build report, it'll tell you why something is where it is on mouse over#2021-12-0505:38Franklinthere's a line in worker.js that looks like this
SHADOW_ENV.load({}, ["goog.debug.error.js",..."day8.re_frame_10x.inlined_deps.re_frame.v1v1v2.re_frame.subs.js","shadow.cljs.devtools.client.browser.js","shadow.module.base.append.js","quagga.components.dataview.worker.js","shadow.module.worker.append.js"]);
(I have eliminated some code) could this mean that re-frame-10x might be adding some undesired js to the worker.js somehow?
#2021-12-0505:44FranklinI also suspect that dev tools are excluded from the build report somehow#2021-12-0505:45Franklinso, I commented out :devtools from my app build
;;  :devtools
      ;;    {:preloads [day8.re-frame-10x.preload],
      ;;     :watch-dir "resources/public/css/"},
#2021-12-0505:45Franklinand that got rid of the error#2021-12-0505:48FranklinI wonder if there's a way to disable dev tools for specific modules#2021-12-0506:45thhellerah its is the preloads yeah. you can move the preloads to the :shared module. just :shared {:entries [] :depends-on #{:base} :preloads [day8.re-frame-10x.preload]}#2021-12-0316:25Adam HelinsAt work, we noticed that bumping Shadow to 2.16.6 resulted in a 50% increase in size of our advanced build. The increase seem to have been introduced with 2.15.13 which uses a newer version of the CLJS compiler with some various Closure updates. Did anyone notice an increase in size as well?#2021-12-0316:28thheller@adam678 what does the build report look like before/after?#2021-12-0316:40dergutemoritzI'm trying to build them but it fails like this:
Hook [0 shadow.cljs.build-report/hook] failed in stage :flush
NoSuchFileException: .shadow-cljs/builds/psap/release/out/main.js
Does that ring any bell?
#2021-12-0316:41dergutemoritz(also hi to my original hometown and thanks for making shadow-cljs 👋😄)#2021-12-0316:41dergutemoritzah lemme try the standalone build#2021-12-0316:43thhellernot a :browser build?#2021-12-0316:43thhellerbuild reports only work with :browser currently#2021-12-0316:43dergutemoritzyup, it's :node-library#2021-12-0316:43dergutemoritzah, too bad 😞#2021-12-0316:44dergutemoritzIndeed, the standalone run failed, as well#2021-12-0316:53dergutemoritzI think I was able to convert it into a :browser 💪 Still need to confirm whether the regression is reproducible this way, too. Stay tuned.#2021-12-0316:58thhellertry setting :js-options {:js-provider :require}. it won't actually run in the browser that way but the build report won't suddenly contain all the bundled npm depenendeices#2021-12-0317:03dergutemoritzOK nice, the size increase still reproduces that way#2021-12-0317:03dergutemoritzAnd we got some build reports now#2021-12-0317:03dergutemoritzLooks like the main culprit is the application code itself#2021-12-0317:03dergutemoritzIts build output pretty much doubled in size#2021-12-0317:04dergutemoritzMaybe more inlining going on or something like that? :thinking_face: Any ideas how to dig deeper?#2021-12-0317:05dergutemoritzMaybe of note that said code is all .cljc#2021-12-0317:06dergutemoritzAh but I can also see similar increases for the .cljs portions#2021-12-0317:07thhellerI don't have any guess for you since I don't have a clue what you are doing 😛#2021-12-0317:08thhellerthere shouldn't be any big increases and I haven't had any other reports like that#2021-12-0317:08thhellernor noticed any increases in my own builds#2021-12-0317:11dergutemoritzAlright, then it's probably related to something unusual we're doing 😉 I wasn't asking about guesses moreso than hints how to investigate this further. The build report is a great help already, thanks a lot!#2021-12-0317:12dergutemoritzI guess we'll revert the update for now and try to get to the bottom of this. If we do or are able to come up with an isolated repro, we'll get back to you!#2021-12-0317:19thhellerthe only thing I can think of is running the build with --pseudo-names and looking at the output trying to figure out where it increase is coming from#2021-12-0317:19thheller--pseudo-names will make it huge regardless but at least you can figure out what the code was before optimizations#2021-12-0317:43dergutemoritzGreat, thanks!#2021-12-0617:05borkdudeWhere should the opts go? Before or after the build ids?#2021-12-0617:05borkdudeI have this:
shadow-cljs --verbose --config-merge shadow-cljs-no-hash-names.edn ...
the no-hash-names tries to "undo" the module-hash-names from the normal shadow-cljs.edn
#2021-12-0617:06borkdudebut it seems it's not being overriden#2021-12-0617:07borkdudeso {:builds {:website {:module-hash-names true}}} merged with {:builds {:website {:module-hash-names false}}} should disable it#2021-12-0619:21thhellerconfig merge only merges the build config. so just the inner map#2021-12-0619:31borkdudeI see, so the second map should be just {:module-hash-names false}?#2021-12-0619:32borkdudewhen I try {:module-hash-names :duude}, then I don't get an error#2021-12-0619:35borkdudebut that does seem to work.#2021-12-0706:28thhellerI get
-> build target: :browser stage: :flush
invalid :module-hash-names value :duude
{:tag :shadow.build.targets.browser/module-hash-names, :module-hash-names :duude}
ExceptionInfo: invalid :module-hash-names value :duude
        shadow.build.targets.browser/hash-optimized-module (browser.clj:411)
        shadow.build.targets.browser/hash-optimized-module (browser.clj:389)
        shadow.build.targets.browser/hash-optimized-modules/fn--39881/fn--39882 (browser.clj:421)
?
#2021-12-0706:36thhelleralso for the cli arguments themselves order doesn't matter. they are all applied before the build is started.#2021-12-0713:17pezI’m making an internal library project in a monorepo. We’re using deps.edn for dependencies and the library is then a local dependency. When working on it I find it the most convenient to use it from an app, so I can end-to-end test manually as I work. Is there a way I can make shadow-cljs auto-run the tests for the library while working like this? It rebuilds the app as I change stuff in the library implementation, but I can’t figure out how to make the same thing happen with the library tests…#2021-12-0715:01thheller@pez I assume putting a shadow-cljs.edn into the lib and running the tests there is not the answer you are looking for?#2021-12-0715:31pezWell, that’s what I am doing now. It works. I was thinking it would be more convenient for my use case if the test-runner for the the “using” project would just pick up the tests of the library and run them as well. I might have misconfigured something when trying because only changes to the implementation of the library triggers shadow to rebuild, changes to the tests don’t…#2021-12-0715:32pez(The misconfiguration is about my attempts to get the tests to run unified in the using app. I have the library tests auto-loaded with the separate test watcher way of doing things.)#2021-12-0715:36thhellerwell are the tests on the classpath of the main project?#2021-12-0715:37thhellerif so they should be picked up when using :local/root?#2021-12-0715:45thhellerI assume you are talking about a regular :node-test or :browser-test setup in the main project running as a watch?#2021-12-0715:52pezYes, :node-test . I have this: main-project/shadow-cljs.edn:
{:builds
 {:app {,,,}
  :test {:target  :node-test, :output-to "target/test/test.js"
         :autorun true}}
 :deps {:aliases [:dev :test]}}
main-project/deps.edn:
:deps {,,,
        library/library {:local/root "../library"}
        ,,,}
library/deps.edn:
{:paths ["src"]
 :aliases {:test {:extra-paths ["test"]
                  :extra-deps {thheller/shadow-cljs {:mvn/version "2.16.7"}}}}}
(The extra-deps is for the separate test runner use case).
#2021-12-0715:54thhellerwell so the tests are not on the classpath?#2021-12-0715:55thhellersince they are in the test folder which is not on the classpath when loading in the main project since that doesn't activate the :test alias#2021-12-0715:56pezI though :deps {:aliases [:dev :test]} would activate that.#2021-12-0715:56thhellerI actually don't know for sure but I don't think so#2021-12-0715:57thhellerthis isn't something shadow-cljs can control or change its a tools.deps thing#2021-12-0715:57thhellerI would expect that it only activates those aliases for the project but not for any :local/root dependencies#2021-12-0715:59pezI have one more clue. In one of my “using” apps tests are in test/cljs and trying this from there gives me a ExceptionInfo: Resource does not have expected namespace error from shadow-cljs.#2021-12-0715:59thhellersame classpath issue if the paths don't match the expected names#2021-12-0716:02pezYes, but it seems that the alias is active, doesn’t it? I’ll ask in #tools-deps and see if someone have an idea. It’s not a big issue, running a separate test watcher works and has its advantages.#2021-12-0716:03thhellerjust open a REPL on the main project and run ( "one/of_your_tests.cljs")#2021-12-0716:04thhellerin general I'd recommend running tests in the library itself#2021-12-0716:05pezThanks. I’ll stick with that.#2021-12-0810:53martinklepschI have a script build with :js-options {:js-package-dirs ["functions/node_modules"]} but when I run the script it can’t find modules that only exist in functions/node_modules . I tried running the script from the functions directory and also tried compile and release (simple) builds.#2021-12-0811:13martinklepschThe directory structure looks like this • scripts/index.jsfunctions/node_modulesshadow-cljs.edn #2021-12-0816:06thhellerwell yeah the output should be functions/index.js#2021-12-0816:06thhellerI assume this is node in which case node resolve rules apply#2021-12-0816:31thhellerremember that node build targets by default do not bundle their dependencies. so they need to be available at runtime using node resolve rules. in short that is <script-dir>/node_modules and <script-dir>/../node_modules and so on going up#2021-12-0816:32thhellerif you want a fully self contained script that has no outside dependencies I recommend post processing with https://github.com/vercel/ncc#2021-12-0816:32thhellershadow-cljs can bundle deps too but all of it is optimized for the browser so ncc generally works better for node builds#2021-12-0816:34thhellerbut in general I would just recommend putting the :output-to into the dir that also has the node_modules dir#2021-12-0816:35martinklepschgotcha, yeah that makes sense then. I’ll try to just move the file into functions . I did play with ncc at some point which also worked pretty well but not really required in this case.#2021-12-0816:36martinklepschI somehow thought that the :js-package-dirs option would magically tell the compiled script where to find packages but I think it’s slightly different / only has that effect for browser builds#2021-12-0816:42thhelleryeah it only telle shadow-cljs where to find packages when bundling (which node targets don't do by default)#2021-12-0816:53martinklepschcool, it’s still used for node though is it? like for compile time warnings or stuff like that?#2021-12-0816:58thhelleronly for cases where you do (:require [react]) or any kind of symbol where shadow-cljs needs to verify you mean a npm package#2021-12-0816:58thhellerbut no it never looks at actual JS sources from node_modules for node builds#2021-12-0816:59thhellercan't look at stuff like fs and so on anyways given they are built-in#2021-12-0919:35metasoarousHi folks. Is it possible to use shadow-cljs as a library, to (e.g.) compile a cljs string into a js string? Thanks.#2021-12-0920:48thhellertechnically yes but no. depending on what you are doing you are likely better off using cljs.analyzer directly#2021-12-0921:54metasoarousWonderful! Thank you! Looks like cljs.build.api/build does most of what I want, as long as I don't want advanced optimizations. Would there be a way to have pieces of shadow assist with that?#2021-12-0921:55thhellerwithout knowing what you intend to do I can't answer that#2021-12-0921:56metasoarousThis is for #oz I want to allow users of oz to build snippets of cljs->javascript in with their notebooks/blog-posts/documentation.#2021-12-0921:58thhellerdefine "snippets"?#2021-12-0922:00metasoarousThere are two goals with respect to this: • Make it possible to inline reagent components in the context of a document (code block in a markdown file, for example) • Plug reagent components into a multimethod dispatch system, so that oz's live-view can be "extended"#2021-12-0922:01thhellerthat would require building the live-view code as part of the snippets?#2021-12-0922:01metasoarousYes, I believe so#2021-12-0922:01thheller(I'm assuming here you ship a pre-built .js file currently?)#2021-12-0922:02metasoarousYes, correct#2021-12-0922:03thhellerextending a :advanced build after the fact is pretty much impossible#2021-12-0922:03metasoarousGot it; That's sort of what I was afraid of.#2021-12-0922:03thhellerwell you can always just stick to basic JS types, that won't be a problem#2021-12-0922:04thhellerbut multi methods and general CLJS datatypes won't really work#2021-12-0922:06metasoarousOK; That makes sense.#2021-12-0922:10thhellermy general recommendation would be a take your snippets and somehow generate a regular .cljs file out of that#2021-12-0922:10thhellerthen compile that as a regular build via the CLJ API (same as a regular build config really)#2021-12-0922:11thhellerthat will ensure that you get a file you can actually load on your html page#2021-12-0922:11thhellerjust compiling snippets leaves a lot of manual stuff for you to do that are easy to mess up (eg. loading all sources in proper dependency order)#2021-12-0922:12thhellerbut yeah you probably need to compile some or all of your other live-view related code together with that#2021-12-0922:13metasoarousThat makes sense. Thank you!#2021-12-1001:47Lukas Domagala@metasoarous me and @djblue have been fighting with the same usecase for portal. his https://github.com/djblue/portal/pull/87, using sci, seems to work pretty well in my initial tests.#2021-12-1006:09metasoarous@domagala.lukas Yes; Thanks for the suggestion. SCI is at the very least my backup plan.#2021-12-1006:10metasoarousJust trying to get a sense of what's possible right now.#2021-12-1006:14metasoarousThe simplicity of SCI for this is very appealing, but there are potentially good reasons to want to use traditional cljs.#2021-12-1006:24metasoarousI was thinking about this though, and we're really just talking about the live-view here (Oz can both: a) compile md/clj/etc to static html files, b) send a live-view of these files to a browser pane as you edit, for a kind of static live code reloading). Since presumably the live-view will mostly be accessed from the same machine that is serving it, there may not be as much of a need for advanced compilation. So maybe it's fine to leave the live-view app target just whitespace optimized, so that we can more easily extend the base app?#2021-12-1006:29mkvlr@metasoarous one nice thing about sci is that it can extend an advanced compiled build. We're doing this in nextjournal and Clerk and it gets you both: best performance for the paths that are compiled with the ability to extend it and call into those compiled functions later.#2021-12-1006:30metasoarousWhat!? How does it do that?#2021-12-1006:31metasoarousOnce again, @borkdude is blowing my mind over here.#2021-12-1006:41thhellerthats not entirely accurate I would say. you still cannot extend SCI from a secondary build. you can only extend SCI from the build that includes SCI itself?#2021-12-1006:43thhellerplease note that when code size is not a concern at all going with :simple might be a viable option (or even :none)#2021-12-1006:45thhellerthere is no built-in way to make this work for now but there probably could be#2021-12-1006:47mkvlryes @thheller that's correct but you can put sci into a module and lazy load it only when you need it, then the bundle size effect should be negligible if you don't load it?#2021-12-1006:47mkvlr@metasoarous this works because sci is just a Clojure script program that can be advanced compiled with the rest of your code#2021-12-1007:39metasoarousI continue to realize things in relation to sci that astound me, yet which in retrospect are entirely obvious#2021-12-1006:48thhelleryeah of course. Just commenting with regards to the initial questions wanting snippets of code interacting with live-view after a separate compile#2021-12-1006:50thhellerthis is still somewhat of a holy grail I've been thinking about quite a lot but there is just no possible way to do this with :advanced#2021-12-1006:51thhellerbut I usually very much care about build size so :simple is usually out of the question. for oz/portal/clerk that might not be of such a high concern#2021-12-1006:51thhellerso there should be better possible ways for doing this 😛#2021-12-1007:38metasoarousThat makes; Thank you both!#2021-12-1007:39metasoarousI continue to realize things in relation to sci that astound me, yet which in retrospect are entirely obvious#2021-12-1011:31Lukas Domagalayeah being able to use cljs just like clj files would be great for library users and would make sharing a lot easier. sadly even a :none compilation makes it difficult. and even if you manage to get that running you still have to handle npm packages somehow, which would mean merging profiles which seems very brittle#2021-12-1016:00roklenarcicWhat could be the reason for npx shadow-cljs release :main producing a file that has 4096 lines instead of 1? The dev build is 13M, but release build is 2M so some optimization was done, but I expected all whitespace to be gone and the build being 1 liner.#2021-12-1016:30thhellerwhy does that matter?#2021-12-1016:41folconHow do you debug a build where the calling, npx shadow-cljs release appscript --debug fails but npx shadow-cljs compile appscript succeeds? More details in thread 😃... Any ideas on what to try next would be appreciated!#2021-12-1016:41folconHow do you debug a build where the calling:
npx shadow-cljs release appscript --debug
fails with:
[:appscript] Compiling ...
IllegalStateException:
        com.google.common.base.Preconditions.checkState (Preconditions.java:492)
        com.google.javascript.jscomp.OptimizeParameters.addVariableToFunction (OptimizeParameters.java:1025)
        com.google.javascript.jscomp.OptimizeParameters.optimizeFunctionDefinition (OptimizeParameters.java:933)
        com.google.javascript.jscomp.OptimizeParameters.tryEliminateConstantArgs (OptimizeParameters.java:644)
        com.google.javascript.jscomp.OptimizeParameters.process (OptimizeParameters.java:128)
        com.google.javascript.jscomp.OptimizeCalls.process (OptimizeCalls.java:125)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
        com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:462)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
        com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:905)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:568)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/compile-js-modules (closure.clj:1102)
        shadow.build.closure/compile-js-modules (closure.clj:1088)
        shadow.build.closure/optimize/fn--11127 (closure.clj:1297)
        shadow.build.closure/optimize (closure.clj:1283)
        shadow.build.closure/optimize (closure.clj:1274)
        shadow.build.api/optimize (api.clj:273)
        shadow.build.api/optimize (api.clj:267)
        shadow.build/optimize (build.clj:476)
        shadow.build/optimize (build.clj:468)
        shadow.cljs.devtools.api/release* (api.clj:339)
        shadow.cljs.devtools.api/release* (api.clj:324)
        shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
        shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
        shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
        shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
        shadow.cljs.devtools.cli-actual/main/body-fn--15307--auto----15979 (cli_actual.clj:166)
        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
        shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
        clojure.core/apply (core.clj:671)
        clojure.core/apply (core.clj:662)
        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
        shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:667)
        clojure.core/apply (core.clj:662)
        shadow.cljs.devtools.cli/-main (cli.clj:75)
        shadow.cljs.devtools.cli/-main (cli.clj:67)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.core/apply (core.clj:667)
        clojure.main/main-opt (main.clj:514)
        clojure.main/main-opt (main.clj:510)
        clojure.main/main (main.clj:664)
        clojure.main/main (main.clj:616)
        clojure.lang.Var.applyTo (Var.java:705)
        clojure.main.main (main.java:40)
But npx shadow-cljs compile appscript just succeeds?:
[:appscript] Compiling ...
[:appscript] Build completed. (43 files, 42 compiled, 0 warnings, 11.39s)
shadow-cljs.edn config:
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 [[applied-science/js-interop "0.3.1"]]

 :builds
 {:appscript {;:main example.core
              :target :node-library
              :output-to "shadow-Code.js"
              ;:optimizations :advanced
              :output-dir "target"
              ;:pretty-print false
              :externs ["resources/gas.ext.js"]
              :exports-var example.core/main}}}
#2021-12-1016:43folconI've tried running npx shadow-cljs check appscript, but I'm just getting some warnings, no errors. I'm running shadow-cljs version 2.16.8.#2021-12-1017:01thhellerwell release runs actual optimizations but compile does not#2021-12-1017:02thhellerso it seems to run into some kind of bug inside the closure compiler#2021-12-1017:03thhellerkinda tough to narrow it down I guess#2021-12-1017:04folconHmm, that's frustrating. So basically build a empty project and see if release works, slowly paste code back in until I can pin down the issue?#2021-12-1017:06thhellerhmm yeah. I've never seen this error before so no guesses as to what may be happening#2021-12-1017:06thhellermaybe try searching googe/closure-compiler github issues#2021-12-1017:08folconHmm, I might have found it#2021-12-1017:08folconCan you do multiple export?#2021-12-1017:09folconIE: (defn ^:export start []) and (defn ^:export main [])#2021-12-1017:09thheller^export has no effect at all for :node-library#2021-12-1017:10folconOk, well it seems to#2021-12-1017:10thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-node-library#2021-12-1017:10folconIf I have two functions with export it's failing with the error#2021-12-1017:10folconIf I have one it doesn't#2021-12-1017:10thheller:exports {:start foo.bar/start :main foo.bar/main}#2021-12-1017:10folconJust figured that out by commenting it out#2021-12-1017:11thhellerhmm ok. using ^:export in :node-library or :node-script builds is pointless anyways so don't use it at all 😛#2021-12-1017:11folconHmm, can I do the same with :exports-var?#2021-12-1017:11thhellerdid you read the docs?#2021-12-1017:11thhellerI mean it even has an example#2021-12-1017:12folconI mean I'm still figuring out how to use shadow-cljs to write appscripts 😃... So this stuff is weird.#2021-12-1017:13folconInteresting, so it doesn't work for :exports-var#2021-12-1017:14thhellerwhat doesn't work?#2021-12-1017:14folcon
:exports-var {:main example.core/main, :start example.core/start},
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   :build-id ...}

should satisfy

  unquoted-qualified-symbol?
#2021-12-1017:14thhellerits :exports then#2021-12-1017:15thheller:exports-var is for a single var pointing to a JS object#2021-12-1017:15thhellerits all in the docs#2021-12-1017:16folconYep, makes sense#2021-12-1017:16folconJust checking it works#2021-12-1017:18folconNope, now just back at illegal state exception#2021-12-1017:19folconHmm, it's weirdly happy with one export, but not two#2021-12-1017:20thhellerwhat are you exporting? regular defn I assume?#2021-12-1017:20folconYep#2021-12-1017:23thhelleryeah dunno. can't say much without seeing the code/config#2021-12-1017:24folconThat's fair#2021-12-1017:25folconI'll dig into this some more and see if I can pin down a minimal case 😃#2021-12-1017:26folconThanks for the help!#2021-12-1116:56deasHi! Is there a way to make shadow-cljs emit the equivalent of export default function(data) { /* */} for target :node-library?#2021-12-1119:24jcoyleHi! Does anyone know if there is a top-level config for controlling the log-level (meaning logs from shadow-cljs) in the browser console? For example in Figwheel there is :client-log-level which can be set to: :severe `:warning` `:info` `:config` `:fine` `:finer` `:finest` . I would like to temporarily disable “info” level warnings such as “shadow-cljs: call app.core/start” that come from shadow.#2021-12-1119:41thheller@deas just :exports {:default some.ns/foo} where foo is a regular defn. assuming commonjs is ok, otherwise you need to go with :target :esm#2021-12-1119:43thheller@jcoyle :devtools {:log false} in your build config#2021-12-1119:55jcoyle@thheller thank you very much!#2021-12-1120:19deas@thheller Need ESM (https://k6.io/docs/using-k6/http-requests/). Not quite there, but I guess you brought me a lot closer. Thanks!#2021-12-1308:00deas@thheller Turned out there is no selfor navigatorproperty in k6. I Guess that rules out :esmfor the moment? However, on the positive side of things, I got it working as :node-librarybuild hack.js
import hack from "./dist/hack.js";

export default hack.default$;
#2021-12-1308:47thhellerI don't know what you mean by "Turned out there is no selfor navigatorproperty in k6"#2021-12-1308:47thhellernothing in shadow-cljs uses those so it must be your code or code you are using#2021-12-1308:48thhellerI don't know a single thing about k6 so I can't really comment much on what you need or what works#2021-12-1309:13deasThe code emitted using :target :esmrefers to selfand window.navigator. Guess it is the Closure Compiler introducing them. Both exist in the browser and also in deno. Don't see a way to polyfill them atm.#2021-12-1309:44thhellerah I guess you are talking aout dev builds? so watch/compile, yeah those might reference those. release however should not#2021-12-1309:49deasNo, the releasebuilds have these references.#2021-12-1309:51thhellerhmm ok#2021-12-1309:52deasIf you have a quick idea how to get rid of them or polyfill, it would be nice if you could let me know. ;)#2021-12-1309:56thhellerself is probably from goog/base.js so thats not easily replaced. the navigator I don't know#2021-12-1309:56thhellerbut if your hack is working then use that for now#2021-12-1309:57thhellerdon't have time currently to look into what runtime k6 uses#2021-12-1309:58deasAll good. Completely understand you may have other things to do. 😉#2021-12-1120:20thhellersee https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2021-12-1307:51tianshuI try to release a node-script , it works fine if I run node target/main.js. However, it seems to depend on node_modules . If I move target/main.js to somewhere else, it can't find required module anymore. Is it expected? How can I have a single file bundle?#2021-12-1308:46thheller@doglooksgood yes, that is intended. if you must have a fully standalone build I recommend post-processing the output with something like https://github.com/vercel/ncc
#2021-12-1308:46tianshuthank you, I'll check ncc.#2021-12-1309:21tianshuI have two apps, the smaller one can be bundled by ncc, the larger one can not. The error is Error: Cannot find module 'qs', looks like it still looking for something in node_modules. I tried to (js/require "qs"), but it seems doesn't work. Any suggestion on what should I do for further debugging?#2021-12-1309:45thhellernpm install qs?#2021-12-1309:45thhellercan't say more without more info#2021-12-1310:25tianshuIt's weird to because I can found qs in node_modules, I can even run target/main.js without any problems. So I have no idea which side cause the problem. Is the generated target/main.js has a statement that ncc can not recognize? or I just ran into a bug of ncc.#2021-12-1314:13Daniel StephensHi all, I'm trying to use d3 in a cljs project. I'm working with shadow-cljs and I'm pretty new to both shadow-cljs and d3 so expecting this might be a stupid mistake. I did a yarn add d3 which seems to have done what I expected and added a bunch of d3 modules into node_modules/ I'm requiring d3 like so:
(ns browser
  (:require ["d3" :as d3]
            ["d3-scale" :refer [scaleLinear]]
            ["d3-shape" :refer [line]]))
and some of it appears to work, as I can run these refers in my REPL, and the interop functions as I'd expect
(-> (scaleLinear)
    (.domain #js [1 2]))
=> #object[scale]
However I can't seem to get any 'select' type functions to work, I tried using interop:
(.select d3 "#app")

Execution error (TypeError) at (<cljs repl>:1).
module$node_modules$d3$src$index.select is not a function
I've also tried following the refering format but had no luck with that either:
["d3-selection" :refer [select]]

(select)

Execution error (TypeError) at (<cljs repl>:1).
_select is undefined
Does anyone know how I'm meant to access the select function? I'm vaguely trying to achieve what they're doing here https://github.com/scotthaleen/cljs-d3-force-direct-graph/blob/master/src/haleen/fd/graph/core.cljs#L17 except they use the global context for d3 which doesn't work either for me, and from what I've read, shouldn't really be done. Thanks for any help!
#2021-12-1406:07metasoarousHope I'm not derailing too extensively here, but have you looked at Vega or Vega-Lite for data visualizations? Vega-Lite is a bit higher level, but also quite a bit higher leverage. If you need to do something very precise or custom, Vega is extremely capable (e.g. someone once literally built pacman in Vega). Both are very well supported by a number of Clojure tools/wrappers, including https://github.com/metasoarous/oz (which I maintain), Hanami, darkstar, notespace, clerk, etc. As data APIs complete with a dataflow model for dynamic computations and interaction, they're also extremely declarative, and mesh very well with the Clojure philosophy. Obviously, if you want/need to use d3 for some very specific reason, then go right ahead. But if you just need to get some shit done, you may have an easier time using one of these libraries.#2021-12-1515:51Daniel StephensHi @U05100J3V, appreciate the information, I hadn't heard of Vega and am new to the ecosystem as a whole so no real need to use d3, my main requirement currently is for a force-directed graph which looks supported so I will take a look, thanks!#2021-12-1316:29kennyIs there a way to hide deprecated var use warnings for a particular set of vars while still showing for vars not in that set?#2021-12-1317:12thheller@dstephens do you get any errors during loading? see the browser console? I would expect things to exist but maybe something failed to load properly?#2021-12-1317:12thheller@kenny no#2021-12-1317:31Daniel Stephens@thheller Yes, I have found some errors!
shadow-cljs - failed to load module$node_modules$d3_array$src$number js.js:74:16
shadow-cljs - failed to load module$node_modules$d3_array$src$bisect js.js:74:16
shadow-cljs - failed to load module$node_modules$d3_array$src$index js.js:74:16
shadow-cljs - failed to load module$node_modules$d3$src$index js.js:74:16
An error occurred when loading abc.js main.js:1672:15
I've looked in the generated numbers.js and it seems to failing on this:
regeneratorRuntime.mark(numbers)
Tried googling about regeneratorRuntime undefined and found https://stackoverflow.com/questions/53558916/babel-7-referenceerror-regeneratorruntime-is-not-defined I can try this but I'm not really sure what it's doing
yarn add core-js
yarn add regenerator-runtime
#2021-12-1317:33thhellerlooks like you are using an older shadow-cljs verison as well?#2021-12-1317:34thhellerthe regenerator thing you maybe can fix by doing a (:require ["regenerator-runtime/runtime"]) before your d3 or other js requires#2021-12-1317:37Daniel Stephens> older shadow-cljs verison Very likely, I was just trying to add a few things into a previously working (to the best of my limited knowledge) play project I had. Thanks, I'll try updating and adding that and see how it goes!#2021-12-1317:45Daniel StephensThank you @thheller! 🎉
(.select d3 "#app")
=> #object[Selection [object Object]]
#2021-12-1404:03JaceCould anyone help me out with these errors I'm getting when I run npx shadow-cljs watch :app ? I don't know what they mean or how to fix them.
shadow-cljs - config: C:\Users\JaceMaverick\Downloads\quickstart-browser-master\quickstart-browser-master\shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.8 running at 
shadow-cljs - nREPL server started on port 55621
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (277 files, 0 compiled, 0 warnings, 4.96s)
Dec 13, 2021 10:00:47 PM io.undertow.server.Connectors executeRootHandler
ERROR: UT005071: Undertow request failed HttpServerExchange{ GET /}
Unexpected error macroexpanding go at (com/wsscode/pathom/connect.cljc:1177:8).
        at clojure.lang.Compiler.macroexpand1(Compiler.java:7023)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7097)
        at clojure.lang.Compiler.analyze(Compiler.java:6793)
        at clojure.lang.Compiler.analyze(Compiler.java:6749)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6122)
        at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6440)
...
#2021-12-1406:19thheller@jacemaverick5 I'm guessing you have a conflicting core.async version in your :dependencies? Just remove it shadow-cljs already provides one#2021-12-1406:19thhellerotherwise make sure you use the version listed here or newer https://clojars.org/thheller/shadow-cljs#2021-12-1409:50Pepijn de VosOhno... what is the proper way to have multiple pages? I've added multiple entries to my script but this seems to break code reload because it calls init on both namespaces#2021-12-1410:00Pepijn de VosMaybe the proper way is a client side router... I was just trying to have actual separate HTML pages.#2021-12-1410:05kardan@pepijndevos can’t you do multiple builds?#2021-12-1410:05Pepijn de VosBut then I'd have to run multiple watches to develop the app#2021-12-1410:07kardanYes, that would be required#2021-12-1410:08Pepijn de VosAh you can actually just pass multiple builds#2021-12-1410:16Pepijn de VosIt seems like you could also have multiple modules to a build, but this is... confusing#2021-12-1410:28Pepijn de Vosah I think I figured it out!#2021-12-1410:28Pepijn de Vosftr https://shadow-cljs.github.io/docs/UsersGuide.html#CodeSplitting#2021-12-1417:00thhelleralso see https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2021-12-1412:50Jakub Holý (HolyJak)Is there a command I can run so that all dependencies needed for npx shadow-cljs watch <something> will be downloaded and when I actually run watch, I won't need internet access? 🙏#2021-12-1417:00thhellerpretty much all commands will accomplish this assuming you are not using any shapshot dependencies or so#2021-12-1417:00thhellershadow-cljs classpath is probably the "quickest"#2021-12-1417:01thhelleralso assuming your are using only shadow-cljs.edn and not project.clj/deps.edn#2021-12-1418:54Jakub Holý (HolyJak)Thank you!#2021-12-1418:55Jakub Holý (HolyJak)But does classpath download also the dev - only dependencies such as Ring?#2021-12-1418:57thhellerI don't understand. shadow-cljs has no "dev only" concept at all regarding dependencies?#2021-12-1418:57thhellerclasspath downloads everything watch or server or anything else would download#2021-12-1414:01Jack ArringtonHi all, I'm a little confused on how shadow-cljs prints certain exceptions. For example, if I evaluate this snippet at the REPL:
(defn greeting-for
   [name]
   {:pre [(string? name)]}
   (str "Hello " name))
(greeting-for 123)
The assert will of course fail, but the only output I get back from the REPL is:
#object[Error Error: Assert failed: (string? name)]
No stack trace, no mention of which function's assert failed. Is there some way to get it to actually display the details of the Error thrown, instead of just its message field?
#2021-12-1416:39Jack ArringtonI should mention as well, I'm not sure if this is a shadow-cljs-specific issue or just a ClojureScript issue. I can ask in #clojurescript if it's not shadow-cljs related#2021-12-1419:15thhellershowing a proper stacktrace is kinda difficult for REPL eval'd code. it should be much better for code loaded from actual files#2021-12-1420:05Jack ArringtonI get that the line numbers would be messed up, but is there no way to even show the function names called?#2021-12-1420:07Jack ArringtonThat alone would be tremendously helpful. Even if it just showed the mangled js-generated function names, that would probably be enough for me to tell where the error is coming from#2021-12-1420:12thhelleryou can do (js/console.log *e) I guess#2021-12-1420:13thhelleror (.-stack *e)#2021-12-1420:13thhellernot ideal in either case though#2021-12-1420:15thhellerjust noticed that (pst) is broken. that is what I'd be using normally#2021-12-1420:16thhellereg.
$ clj
Clojure 1.10.1
(defn greeting-for
   [name]
   {:pre [(string? name)]}
   (str "Hello " name))
#'user/greeting-for
user=> (greeting-for 123)
Execution error (AssertionError) at user/greeting-for (REPL:1).
Assert failed: (string? name)
user=> (pst)
AssertionError Assert failed: (string? name)
        user/greeting-for (NO_SOURCE_FILE:1)
        user/greeting-for (NO_SOURCE_FILE:1)
        user/eval148 (NO_SOURCE_FILE:1)
        user/eval148 (NO_SOURCE_FILE:1)
        clojure.lang.Compiler.eval (Compiler.java:7177)
        clojure.lang.Compiler.eval (Compiler.java:7132)
        clojure.core/eval (core.clj:3214)
        clojure.core/eval (core.clj:3210)
        clojure.main/repl/read-eval-print--9086/fn--9089 (main.clj:437)
        clojure.main/repl/read-eval-print--9086 (main.clj:437)
        clojure.main/repl/fn--9095 (main.clj:458)
        clojure.main/repl (main.clj:458)
nil
user=>
#2021-12-1501:12Jack ArringtonThat is a shame about (pst) being broken, but good tips, thanks!#2021-12-1417:01Jakub Holý (HolyJak)Hi again! I am running npx shadow-cljs watch main and it does compile and prints watching build :main yet the browser says > Stale output! Your loaded JS was not produced by the running shadow-cljs instance. How do I troubleshoot this? (I load the app via the backend server, not shadow dev server) I even deleted the main.js before restarting shadow to make sure that it is built by shadow. Solved: I was starting shadow in the wrong project 😅#2021-12-1417:03thhellercould be cache? eg. overeager service worker?#2021-12-1417:04thhelleralso make sure you are actually loading the file you think you are loading. often people change :output-dir but forget to adjust paths in HTML or so#2021-12-1417:05thhellerdelete the file shadow-cljs is producing and load your page. if you get something then thats not the file you are loading :P#2021-12-1417:05Jakub Holý (HolyJak)Yeah, st. is fishy, when I rm the file and stop shadow, the file does not exist but the server still happily serves it...#2021-12-1508:33Jakub Holý (HolyJak)Would it be possible to make the websocket client URL configurable? According to https://github.com/thheller/shadow-cljs/blob/69abb8e088cce7db7a901d9371225a0b98aa424b/src/main/shadow/cljs/devtools/client/env.cljs#L98-L111 it is derived from the app's URL in a fixed way. But I need a different protocol (wss), host, and port (443) to make it usable with GitPod.#2021-12-1508:35Jakub Holý (HolyJak)Some details about GitPod and ports: https://github.com/gitpod-io/gitpod/issues/3282 In essence every port is exposed at a different host, as https://<port>-<unique host>:443 (I believe WS works over https so the https proxy between the app and the browser is hopefully ok...)#2021-12-1508:39thhellerIt is already configurable via :devtools {:devtools-url ...}#2021-12-1508:42thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2021-12-1508:48Jakub Holý (HolyJak)Awesome, thank you very much! So if my app is exposed at https://8181-myhost/ and the nrepl port at port 9630 is exposed via https://9630-myhost/ then I set :devtools-url , right?#2021-12-1509:18Jakub Holý (HolyJak)it works! thanks a lot!#2021-12-1516:09aeskilsonI’ve got a shadow-cljs project that builds a single page app using Reagent/Kee-frame. I’ve also got shadow-cljs config that compiles stories namespaces for use in Storybook.js. Since adding Kee-frame, I get this error when attempting to run build-storybook,
info => Using default Webpack5 setup
ERR! => Failed to build the preview
ERR! Module not found: Error: Can't resolve 'xmlhttprequest' in '/Users/me/app-frontend/public/js/stories'
64% building 14/14 entries 5634/5692 dependencies 987/1313 modulesERR! ModuleNotFoundError: Module not found: Error: Can't resolve 'xmlhttprequest' in '/Users/me/app-frontend/public/js/stories'
I’m assuming this is because Kee-frame depends on some packages that support both browser & server-side routing (Reitit by default I think), but I don’t think my base shadow-cljs build is going to pull the server-side dependencies in, given it targets the browser. Here’s my shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/stories"
  "src/test"]

 :dependencies
 [[reagent "1.1.0"]
  [kee-frame "1.3.2"]
  [arttuka/reagent-material-ui "5.0.0-0"]
  [garden "1.3.10"]]

 :dev-http {8080 "public"}
 :builds {:app {:target     :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules    {:main {:init-fn app.frontend.core/render!}}}
          :stories {:target     :npm-module
                    :runtime    :browser
                    :ns-regexp  "-stories$"
                    :output-dir "public/js/stories"}}}
#2021-12-1516:10aeskilsonIf I npm install xmlhttprequest , then I get other “Module not found” errors, with fs and child_process#2021-12-1516:12aeskilsonMy Stories are pure component tests. They don’t depend on Kee-frame in any way. I suppose I’m wondering if there’s a way to exclude certain packages from the stories build? Maybe that’d be a hack though to some preferable way to handle what seems to be a pulling of server-side flavors dependencies.#2021-12-1516:13ingesol@bdrillard Quick check, did you run npm install in your project before starting shadow and storybook?#2021-12-1516:15aeskilsonYep, I cleared out my node_modules, did an npm install, shadow-cljs release app stories and then tried to run storybook.#2021-12-1516:31aeskilsonI was able to figure it out. I got my storybook build to succeed by including the following in my package.json,
... 
  "browser": {
    "xmlhttprequest": false
  },
  ...
Had to https://github.com/defunctzombie/package-browser-field-spec what the browser configuration does. Seems like directly excluding what is known to be a server-side module from codepaths that can be assumed to execute purely client-side can be considered a bit heavy-handed, but it worked.
#2021-12-1517:57Michael Stokleyhow can i pass in an arbitrary alias when starting up shadow-cljs?#2021-12-1518:04thhellernot supported. but you can instead just call clj directly with whatever alias you like. clj -M:whatever:foo -m shadow.cljs.devtools.cli watch app would be equiv to shadow-cljs watch app#2021-12-1518:04thheller(assuming you are talking about deps.edn aliases of course)#2021-12-1518:08Michael Stokleyi could also define the alias in ~/.shadow-cljs/config.edn and my project specific .shadow-cljs.edn would see the alias, is that correct?#2021-12-1518:09thhellerno#2021-12-1518:10thhelleroh wait. didn't I add something like :deps-aliases in ~/.shadow-cljs/config.edn?#2021-12-1518:10thhellerlet me check the code, can't remember 😛#2021-12-1518:11thhellerindeed I did I guess. {:deps-aliases [:foo]} in ~/.shadow-cljs/config.edn#2021-12-1518:14Michael Stokleythank you!#2021-12-1518:26Lukas Domagalanot sure if this is a shadow or cljs compiler question: i’m writing lots of cljs macros lately and they are a pain to debug, mostly because it seems there is no way to get any insights into the macro. is there any way to get println to work during the macro expansion phase? or is there some better way to see whats happening on the clojure side of things?#2021-12-1519:54thhellerprintln works just fine during macro expansion. I typically recommend building macros in a CLJ REPL#2021-12-1519:59thhellerI typically have a comment block such as this and eval it in the REPL until the output of the macroexpands looks like what I want#2021-12-1519:59thhellerhttps://github.com/thheller/shadow-experiments/blob/master/src/main/shadow/experiments/grove/components.clj#L466#2021-12-1519:59thhelleruntil it does I won't even have it used in a build. that comes after#2021-12-1520:02thhellerremember that macros are pure CLJ code so shadow-cljs doesn't even need to be present to work on these#2021-12-1520:03thhellerhttps://github.com/thheller/shadow-experiments/blob/master/src/main/shadow/experiments/arborist/fragments.cljc#L522 this also works great#2021-12-1520:03thhellerie. a regular function you can call with a quoted form just like the macro would#2021-12-1520:09Lukas Domagalaah, so it’s just my repl env that “eats” the println? I’ve got calva starting shadow and don’t see the macro println when I run it as a cljs eval. I can’t usually just run it from clojure, since I’m accessing the cljs analyzer env and need access to the other cljs namespaces, but your make-fragments function does look interesting! and it does make sense to only switch to cljs macros once I really really do need access to the other cljs analyzer stuff, thank you for that idea as well!#2021-12-1520:10thhelleryeah it won't show up as part of cljs eval since the println happens during compilation#2021-12-1520:11thhellerbut it should arrive somewhere, maybe just the console where shadow-cljs was started#2021-12-1520:17Lukas Domagalai thought so too, but it’s not there either. i’ll try starting it by hand and connecting then. i’ve been using line defs as println replacement, but that does take longer. but thanks a lot for making me think about my dev style again, cljs macros have been frustrating to work with, but it’s partly just shooting myself in the foot by switching env’s to early.#2021-12-1622:47mauricio.szaboHi there! I'm having trouble with react-native (not really a Shadow-CLJS problem but maybe someone here can help me somehow): I really wish to understand better what Jest does before running tests, because I can't make tests run in "pure ClojureScript" in any way. At the beginning, I had some success by using dl-react-native-mock-render/mock but then I've added a React Native dependency and everything broke again. So, does anyone have any tips on how to run react-native without Jest, using just :node-test or `:node- target or anything like that?#2021-12-1706:04thhelleryou can't run react-native in node, so node targets won't work. I believe what jest does is replace any react-native require with something else but not sure#2021-12-1706:05thhellerI'd assume jest somehow hooks itself into require to do this. dunno how though. maybe its just a build tool, as in it preprocesses the code before running it#2021-12-1706:11thhellereg you could try running :node-test with :js-options {:js-provider :shadow :keep-native-requires true :resolve {"react-native" {:target :npm :require "some-replacement"}}} etc#2021-12-1706:11thhellernot really recommended to do this but might be enough if you don't have too many other react-native dependencies#2021-12-1713:42mauricio.szaboYeah, that's what I tried and it didn't work. As soon as I add another react-native dependency, it fails with some cryptic errors like: Module not provided: @babel/runtime/helpers/interopRequireDefault#2021-12-1723:44Drew VerleeIs there a way to just do a recursive merge on the config? I want to add re-frame-10x by having a local config file and merging it via:
--config-merge re-frame-10x.edn

re-frame-10x.edn
{:builds
 {:dev
  {:devtools
   {:preloads [day8.re-frame-10x.preload]}
   :dev
   {:compiler-options
    {:closure-defines
     {re-frame.trace.trace-enabled?        true
      day8.re-frame.tracing.trace-enabled? true}}}
   :release
   {:build-options
    {:ns-aliases
     {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}}}
But that doesn't work, i believe it inserts into the build level, but when i do that, my app doesn't start. so i assume it overwrites.
#2021-12-1806:37nbdamHi. Is there a way to pause/resume hot reloading during REPL use?#2021-12-1806:48thheller@nbdam from a clojure REPL you can call (shadow.cljs.devtools.api/watch-set-autobuild! :the-build-id false) to disable and true to enable again#2021-12-1807:56nbdamexcelent, thanks!#2021-12-1816:59haywoodam i correct in thinking I can’t use (cljs.analyzer/analyze in a non-bootstrapped build target? I’m “just” looking to get the AST structure for some code at runtime#2021-12-1817:06thhellerdepends. you can use analyzer without but you won't get very far without at least the analyzer data for cljs.core. which in turn means self-hosted#2021-12-1817:02SchmohoHi! I am trying to get a minimal thing with OpenLayers to work, referring to this: https://stackoverflow.com/questions/10349168/clojurescript-openlayers and this: https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html Problem is, if I use the (js/OpenLayers.Map. "map") syntax, shadow-cljs complanis OpenLayers is not defined, if I use (:require ["ol" :as ol]) I can define a map like (def mapp (ol/Map. "map")) but I don't know how to use constructors like (js/OpenLayers.Layer.OSM. "Simple OSM Map"). Also, using this require, I cannot send the namespace expression via the nREPL connection in Clojure-Kit from IntelliJ, because the ns macro is considered invalid (shadow-cljs compiles fine however ...). So, what is the correct way to do stuff like this in CLJS with shadow? Is requiring a library like this something very shadow-specific? I guess it might be possible to require the library via the html (then the js/OpenLayers.Map. thing should work, right?) but I kind of feel like this should not be the way#2021-12-1817:04thheller@d.eltzner don't use anything from that SO question#2021-12-1817:04thheller> Asked 9 years, 7 months ago#2021-12-1817:04thhellernone of that is relevant today I guess#2021-12-1817:04thhellerol is basically OpenLayers so use that as a regular alias#2021-12-1817:04thhellerjs/OpenLayers.Map. would become ol/Map.#2021-12-1817:05Schmohoyeah so much I got alright, but I'm wondering about the Layer.OSM. part ...#2021-12-1817:05thheller(js/OpenLayers.Layer.OSM. "Simple OSM Map") would become (ol/Layer.OSM. "Simple OSM Map")#2021-12-1817:05Schmohoah okay#2021-12-1817:05thhellerswap any js/OpenLayers with ol/#2021-12-1817:05Schmohothen it's really just that OpenLayers API probably has changed#2021-12-1817:06thhelleryeah that too maybe#2021-12-1817:06Schmohothe other thing, any idea why I'd get an error trying to send a ns declaration using this require via Clojure-Kit? it's the usual invalid macro syntax thingie when there's invalid stuff in a namespace delcaration#2021-12-1817:07SchmohoSyntax error macroexpanding clojure.core/ns at (src/myproject/core.cljs:1:1). ((:require [reagent.core :as r] [reagent.dom :as d] ["ol" :as ol])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form#2021-12-1817:09thhellerI don't know what Clojure-Kit is but I guess it doesn't understand the string require syntax. or you are eval'ing in a clojure repl. clojure doesn't support it#2021-12-1817:12Schmohoit's a free-to-use intellij plugin ... doesn't seem like a good idea using that actually, I just realized there are actually free licenses for cursive#2021-12-1817:13SchmohoI'll see if the problem remains then. Thanks very much for claring the require thingie up for me!#2021-12-2015:01Pepijn de VosI'm having a problem where advanced compilation and code splitting don't work together. I split my code in a common module and two page-specific ones, but one of the page-specific ones gives an error that $APP.qr is undefined. If I switch to simple compilation it works fine, if I compile everything into a single file it also works fine, but with advanced compilation and multiple modules it breaks. So for now I've just switched to using one single file, but if anyone has any clue what's going on it'd be appreciated This is the commit that works around it, in case you want to explore the code before/after: https://github.com/NyanCAD/Mosaic/commit/b1f484942e89509246c88b3ad12ad53c445088da#2021-12-2015:49RyanHey all, awhile back I was having trouble with node modules not getting compiled in, seemingly at random. The frequency this is occuring has increased, leading me to need to remove my .shadow-cljs/builds directory frequently to prevent broken builds. Any clues as to what could cause something like this? or perhaps a clue as to where to start looking? 🙂 Thanks#2021-12-2017:27thheller@pepijndevos run the build with shadow-cljs release frontend --pseudo-names to get an idea what $APP.qr might be#2021-12-2017:41Pepijn de Vos$APP.$cljs$spec$alpha$t_cljs$0spec$0alpha11756$$ color me somewhat surprised#2021-12-2017:43thhellerah so yeah thats a known issue#2021-12-2017:44thhellerlet me find the ticket for that#2021-12-2017:45thhellerhttps://clojure.atlassian.net/browse/CLJS-3207#2021-12-2017:45thhellerso basically use spec assert once in a namespace that ends up in :common#2021-12-2017:49Pepijn de VosAh! Glad to hear it's a known issue. At the moment my app is relatively small so it's fine to just compile everything in a single module rather than have weird hacks, but as the app grows it's great to know I have that escape hatch available. Thanks!#2021-12-2017:28thheller@rdonahue define "node modules not getting compiled in"?#2021-12-2018:25RyanThe app won't load at all, and the js console will show an error like: "Module not provided: Button" .. the last module it displayed that error with was '18', so not sure what that means. It was in production, so didn't have time to really capture much else, had to wipe the builds folder and re-build.#2021-12-2018:41thhellerare you maybe caching or mixing builds?#2021-12-2018:42thhellerno one else has ever reported issues such as this so I really don't know what this might be about#2021-12-2018:42thhellermixing as in loading the output of two different builds on the same page?#2021-12-2018:42thhellermaybe of the same build but compiled at different times?#2021-12-2018:43thhelleror partially caching some (eg. multiple modules but having a stale older version in cache)?#2021-12-2019:21RyanI don't think so, at least not on purpose.#2021-12-2019:22RyanI have the local-dev resource root, and a production root, which gets rebuilt from the local-dev one on each build, then a fresh prod build is built into that resource root#2021-12-2019:23Ryancompiles via
npx  shadow-cljs release app
and the config is setup to use the production root
#2021-12-2019:24Ryan
{:app {:target :browser
        :output-dir "local-dev/public/js/compiled"
        :asset-path "/js/compiled"
        :module-hash-names true
        :modules {:pnx-web {:init-fn pnx-web.core/init}}
        :devtools {:preloads [day8.re-frame-10x.preload]}
        :dev {:compiler-options
         {:closure-defines
          {re-frame.trace.trace-enabled? true
           day8.re-frame.tracing.trace-enabled? true}}}
        :release {:output-dir "release/public/js/compiled"}
        :build-options {:ns-aliases {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
is app definition
#2021-12-2106:08thhellerthat all looks fine#2021-12-2106:11thhellerare there any other errors BEFORE you get the module not provided error that would just cause this as a secondary effect?#2021-12-2022:29ChaseI'm trying to use an environment variable and could use some help. I have the variable saved in my .bashrc as OPEN_WEATHER and in my shadow-cljs.edn I have: :closure-defines {API-KEY #shadow/env "OPEN_WEATHER"} but when I try to use it in my app by referring to API-KEY I get an undeclared var error.#2021-12-2022:34ChaseHere is the documentation: https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2021-12-2022:35dpsuttonthe var seems to need to be fully namespace qualified from the examples#2021-12-2022:36ChaseI was just trying that after looking back over that documentation.#2021-12-2022:36dpsutton
(ns )

(goog-define VERBOSE false)
and in shdaow-cljs.edn
:dev {:closure-defines { true}}
   ;; to enable always
   :closure-defines { true}
#2021-12-2022:36ChaseWaiting for the compile now#2021-12-2022:41Chasehmmm, I changed it to ...{weather.core/API-KEY #shadow/env... and still getting the undeclared variable error...#2021-12-2022:41dpsuttonin (ns weather.core ...) do you have (good-define API-KEY "dev") or something similar?#2021-12-2022:42Chaseoh nope. I was just trying to call it like it was an already declared variable#2021-12-2022:42dpsuttonthe documentation shows how to use it#2021-12-2022:43ChaseI'm not seeing that#2021-12-2022:44dpsutton#2021-12-2022:47ChaseOk, I have to step away but I'll return back. it's confusing me.#2021-12-2022:48ChaseSo in my clj file I put something like (goog-define API-KEY "") and then that gets overridden by the shadow-cljs compiler?#2021-12-2022:49dpsuttonthat’s correct#2021-12-2022:49dpsuttoni’d put “dummy” or “closure-define” or something like that but yeah#2021-12-2023:06ChaseAwesome. Makes sense. Thanks so much#2021-12-2119:02Pavel KlavíkHi, I have a problem which only occurs in Safari in advanced compilation, happening somewhere when executing Re-frame code. It is possible to somehow build source maps, so I can find what line it corresponds in dev version?#2021-12-2122:31furkan3ayraktarhttps://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options There are three supported source-map related options under compiler options. These two should be enough: > :source-map (Boolean) defaults to `true` during development, `false` for `release`. > :source-map-detail-level `:all` or `:symbols` (`:symbols` reduces overall size a bit but also a bit less accurate) #2021-12-2206:06thhellershadow-cljs release app --source-maps or shadow-cljs release app --debug will also enable them temporarily#2021-12-2121:35jhacksIs it possible to specify the hostname for source maps? I’m getting errors like the following:
DevTools failed to load source map: Could not load content for : Connection error: net::ERR_CONNECTION_CLOSED
My shadow-cljs build is loaded from an iframe in a Google Sheets sidebar. I would like to replace with .
#2021-12-2206:07thheller@jhacks :asset-path controls that. you can set it to a full domain. there is also :compiler-options {:source-map-inline true}, so they'll become part of the file itself with no extra request. makes the files rather huge though.#2021-12-2209:32rbergerI am importing some javascript ui-component code (`CardACollection.js`) that was generated from Amplify Studio (it was actually JSX code that was processed by babel into JS code) and it has this import:
import React from "react";
import { Rental } from "../models";
I set things up as per https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects with this layout:
.
├── package.json
├── shadow-cljs.edn
└── src
    └── main
        └── amplify_rental_reagent_app
                                     └── core.cljs
    └── js
        ├── .babelrc
        └── ui-components
                        └── CardACollection.jsx
    └── gen
        ├── models
                 └── index.js
                 └── index.d.ts
        └── ui-components
                        └── CardACollection.js
Also have set up to use the webpack build as described in https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
:js-options {:js-provider    :external
                :external-index "target/index.js"}
The problem is that the import statement in the ui-component code is causing shadow-cljs to error out with:
[:app] Build failure:
FileNotFoundException: /Users/rberger/work/aws/amplify-rental-reagent-app/src/gen/models (Is a directory)
Is there a way to make that not happen? This JSX/JS code is all being generated by Amplify Studio and would prefer not to have to manually change that code… The repo with all this is at https://github.com/rberger/amplify-rental-reagent-app
#2021-12-2210:02thheller@rberger including classpath JS is much stricter than regular npm resolve so you'd need to rewrite import { Rental } from "../models"; to import { Rental } from "../models/index.js";#2021-12-2322:16rberger@thheller That works (though it will be painful to do, since the JS code is auto-generated from an upstream process not under my control, but I’ll deal with that for now). But that seemed to just lead to another issue: It looks like this code which, is pulled in as JS files in the CLJS repo, needs to be part of the :js-provider :js-external mechanism. Is there a way to tell shadow-cljs to include a tree of JS code in the :externa-index in addition to the npm modules to be processed by the external webpack process? At least I think that is what would fix it. The actual issue is that import { Rental } from "../models/index.js"; has the file parsed, but Rental is not set properly. I logged when Rental is set in `models/index.js
const { Rental } = initSchema(schema);
console.log("index.js Rental: ", Rental);
export { Rental };
and after the import in CardACollection.js
import { Rental } from "../models/index.js";
console.log("Rental: ", Rental);
And I see in the console:
index.js Rental:  ƒ Model(init) {
            var instance = (0,immer__WEBPACK_IMPORTED_MODULE_1__.produce)(this, function (draft) {
                initializeInstance(init, modelDefinition, draft);
                var …
main.js:1455 ReferenceError: Rental$$module$models$index is not defined
    at eval (CardACollection.js:27)
    at eval (<anonymous>)
    at Object.goog.globalEval (main.js:488)
    at Object.env.evalLoad (main.js:1563)
    at main.js:1744
#2021-12-2323:32rbergerIts also possible I’m not doing the JSX -> JS conversion right to generate this JS code. I am following the procedure in https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects. Might there be more configuration I should do to the .babelrc to make this work better?#2021-12-2323:34rbergerOnly the ui-components are being processed by babel. The models code is vanilla from what is pulled in with amplify pull#2021-12-2404:57rbergerI think what I need to do is actually learn how to use webpack, add another entry to have it put the models stuff into the bundle.js#2021-12-2405:40thhellerall classpath js will be processed by shadow-cljs regardless of :js-provider since no other JS tool will have access to your classpath https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2021-12-2405:40thhellerhowever if you create a custom npm package and require it like that from CLJS you can setup webpack to do whatever you need#2021-12-2405:41thhellerie. (:require ["my-models" :as foo]) will end up emitting require("my-models") in the JS file processed by webpack#2021-12-2405:41rbergerYeah, I’m thinking that, but don’t know off hand how to create a npm package from a couple of trees of javascript code. Was starting to look into that#2021-12-2405:41thhellerin webpack you can then configure my-models to resolve wherever you put it. eg. via alias https://webpack.js.org/configuration/resolve/#resolvealias#2021-12-2405:42thhelleryou can also probably skip the jsx conversion then and let webpack do it#2021-12-2405:42rbergerRight, is there a way to do do the webpack and not create an npm package, if I just put the jsx/js code in a tree outside of the classpath?#2021-12-2405:43rbergerThe webpack docs seemed to imply there was a way to use a path instead of a module#2021-12-2406:04thhellerI linked it. alias does that. basically alias: { "my-models":the-path-to-that }#2021-12-2406:06thheller"package` basically only means directory. nothing more. it doesn't need to be published to npm or whatever#2021-12-2406:06rbergerOk, I didn’t realize that is what you meant. Checking that and also potentially found a way to make a tree into a local npm module https://dev.to/tomiiide/import-subfolder-modules-in-javascript-like-a-boss-15f7#2021-12-2406:15thhelleryeah basically the resolve rules of "npm" (including shadow-cljs or webpack) are that anything starting with a ./ or ../ is looked up on the "filesystem" (classpath in shadow-cljs)#2021-12-2406:16thhellerany other require looks ups folders in node_modules, or gets redirect via alias#2021-12-2407:13rbergerThanks, the resolve alias (with a few other tweaks) got it to basically work! It also means I can have the Amplify studio generated code flow in with no changes. Now I just have to figure out how to have webpack do the babel JSX->JS instead of me doing that manually with babel.#2021-12-2210:26Pavel KlavíkIs it possible to merge shadow-cljs.edn with config defined in another edn file? I would like to have some local config which can override stuff in shadow-cljs.edn which is not commited into git.#2021-12-2210:27Pavel KlavíkIn particular, we have :ssl defined in shadow-cljs and I want to turn it off for testing on mobile.#2021-12-2217:11thhellerUnfortunately no. :ssl cannot be overwritten easily since it is only setup when shadow-cljs is started#2021-12-2220:34Pavel KlavíkIs it possible to override it on the start. That would not be a problem for us.#2021-12-2221:23Pavel KlavíkFor instance for lein, we have project.clj shared in Git and individual profiles.clj which can be used to locally modify settings in project.clj#2021-12-2221:36Pavel KlavíkOk, this is actually addressed in Shadow-cljs user guide: https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2021-12-2221:49Pavel KlavíkBut it just allows to override individual builds, not the entire configuration.#2021-12-2305:37thhelleras I said there is no way to do this via any command line flags or config files#2021-12-2305:37thhellerwhat you could do is create a custom main function and call that via lein or clj#2021-12-2305:37thheller(shadow.cljs.devtools.server/start! the-config)#2021-12-2305:39thheller(-> (shadow.cljs.devtools.config/load-cljs-edn) (dissoc :ssl) (shadow.cljs.devtools.server/start!))#2021-12-2305:39thhelleror so#2021-12-2305:40thhellerof course properly required and aliased but start! with no args will just load shadow-cljs.edn and call the 1-arity start!. so you could load the config yourself and modify it however you want#2021-12-2216:29borkdudeIs it possible in some build hook to correct the output of js/import.meta.url from import$.meta.url to import.meta.url?#2021-12-2216:38thhellerimport.meta.url is not supported by the closure compiler so it won't work either way#2021-12-2216:39borkdudeif I correct it in the outputted JS, it does work?#2021-12-2216:39thhellerotherwise use (js* "import.meta.url") but don't tell anyone I said that 😉#2021-12-2216:39thhellerrelease builds don't work?#2021-12-2216:39borkdudeof course I already tried js* but that ends up as the same#2021-12-2216:39thhellerdev builds don't run through gcc so they work yes 😛#2021-12-2216:40borkdudemaybe this is a case of an X-Y problem. I would like to print the version of the package.json of my library when people call it with nbb --version. of course I could keep the version in some different file/namespace#2021-12-2216:40borkdudebut getting info from package.json might be nice#2021-12-2216:41borkdudeso I need something like __dirname but then in the ES6-style#2021-12-2216:47borkdudebut if it's not supported, I'll just keep the stuff in some namespace#2021-12-2216:47borkdudeor I could perhaps use a clojure macro to capture the info at compile time#2021-12-2217:01thhellercan you import .json files directly? I can't remember#2021-12-2217:02thhellerotherwise just (:require ["esm:../package.json" :as pkg-json]) might work?#2021-12-2217:05borkdudeI solved it with a macro. That seems the most robust solution, just do it at compile time without any doubts.
(ns nbb.macros
  (:require [clojure.data.json :as json]))

(defmacro get-in-package-json [k]
  (get (json/read-str (slurp "package.json") :key-fn keyword) k))
(ns nbb.core (:require-macros [nbb.macros :as macros]))
(defn version [] (macros/get-in-package-json :version))
#2021-12-2219:06JonRHi all. Curious if anyone has experience using the latest @mui/material lib with shadow. I can install and import components individually but what I would like to do is use the index import for all components (`(:require ["@mui/material" :as mui])`). When I try this though I get an error: Cannot redefine property: unstable_ClassNameGenerator. This comes from the index.js where it seems to be doing some treeshaking, importing, stuff. (I say stuff cause I'm not super familar with all the different approaches to this in JS world).#2021-12-2220:14David VujicI would suggest to check out the reagent-mui library, a Reagent wrapper for Material UI. For me, it has simplified things a lot, when dealing with the JavaScript/React specific features: https://github.com/arttuka/reagent-material-ui#2021-12-2220:33JonRNice, thanks for sharing! We're using helix so I won't be able to use that directly but will check for solution ideas. Thanks again#2021-12-2220:57jhacks@thheller Thank you for your help! I didn’t realize :asset-path could be set to a full domain. That fixed my problem.#2021-12-2318:410x7642Hi all, I'm a bit puzzled on dependency resolution. The compile error I get is:
> npx shadow-cljs compile app
...
shadow-cljs - dependencies updated
[:app] Compiling ...
The required namespace "cljsjs.react-bootstrap" is not available, it was required by ...
however, package cljsjs.react-bootstrap is in shadow-cljs.edn (also added to package.json in case there were hidden js dependencies). npm install and npx shadow-cljs classpath don't show anything amiss. how can I check what's going on? 🙂 shadow-cljs --verbose compile shows the same error, but nothing more
#2021-12-2320:33thheller@chr.andreetta shadow-cljs does not support cljsjs packages. use the npm packages directly instead.#2021-12-2413:290x7642@thheller thank you. fun fact, thanks to this I've discovered that if a file has ns with a require entry, not used anywhere (old codebase needing some ~archaeology~ cleaning), the compiler may return "required namespace ... is not available" too#2022-12-2718:58tungstenIs anyone familiar with the following error in the browser console:
[Error] ReferenceError: Can't find variable: j
	reportError (main.js:1455)
	(anonymous function) (main.js:1565)
	Global Code (main.js:1633)
[Warning] The above error occurred when loading "cljs.pprint.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others. (main.js, line 1457)
#2022-12-2718:59tungstenNo idea what could cause this, it seems like hot code reloading doesn't work either. First time using shadow-cljs#2022-12-2719:52thheller@bfast never seen that before. what kind of a build is this? :target :browser I assume?#2022-12-2722:17tungstenYes, that is correct#2022-12-2805:43thhellerand which browser is this?#2022-12-2813:01SimonCould shadow-cljs increase its speed with esbuild?#2022-12-2813:38thhellerno#2022-12-2814:07FranklinError messages in clojurescript, when compiled with the prod build don't look so good#2022-12-2814:08Franklinis there a way to make them clear when you want to log to something like sentry?#2022-12-2814:29Franklinthis was already answered https://clojurians.slack.com/archives/C03S1L9DN/p1640700515298700 but feel free to add anything 🙂#2022-12-2823:47Kurt HarrigerHey all, I created a project that demonstrates how to add clojurescript to a typescript project created with parcel bundler…. https://github.com/kurtharriger/parcel-cljs-demo I can see this being useful for few scenarios: 1. easier migration path from ts to cljs 2. you want to use react “natively” using react hooks and styled components, but still use clojurescript to implement algorithms, business logic, data fetching etc 3. or bootstrap the application with typescript where you can trivially import static assets like css and then mount a clojurescript ui to do everything else This is mostly just bringing together various pieces of the puzzle such as esm support and parcel externals to allow parcel bundler to find the clojurescript module built with shadow-cljs… currently this project requires that you run shadow-cljs before and addition to the parcel bundler and than create an alias that imports the bundled javascript.. I suppose that a parcel resolver plugin can be created to auto configure and run shadow-cljs with some sort of default configuration for a simple single bundle app. I also tried to create another multi-module branch where I experimented with possibility of creating a shared module then separate modules for each cljs file such that one could potentially directly reference a cljs file in a script tag and a parcel transformer plugin could then create a shadow-cljs module per file along with shared module which might make cljs code artifacts in parcel feel more natural. This doesn’t work well for creating libraries but perhaps in the context of parcel web app bundle it could work. I was also able to import ts file form cljs using the (:require ["esm:/src/ts/util.ts" :as ts]) syntax (on multi-module branch) however I found I needed to use an “absolute” path as it was relative to the target file rather than src file which sorta sucks but probably a way to add some sort of resolver extension to shadow-cljs to make that work better.#2022-12-2906:35thhellerhey, I took a quick look. here are some problems I see: • in your build config you should set :js-options {:js-provider :import}. otherwise shadow-cljs will bundle react and such and parcel will bundle it again for the TS parts. • parcel HMR should be disabled for the cljs sources if you can. the "already declared" errors are not safe to ignore#2022-12-2906:43thhellerI assume parcel knows how to bundle commonjs in that case I would probably recommend sticking with :target :npm-module for such deep interop things for now#2022-12-2906:46thhellerand yes paths are alrways relative to the output not the input. also not something you'd need to configure in shadow-cljs as it just takes esm: as a literal and doesn't do anything with it. I suppose you could add an alias for parcel so esm:ts/util.ts or so works#2022-12-2906:47thheller:npm-module is basically your desired multi-module#2022-12-2915:04Kurt HarrigerGreat feedback gratitude-thank-you#2022-12-2919:40Kurt HarrigerSo I attempted to make these changes and I do see that the resulting target structure using npm-module is a bit different and possibly more suitable for creating parcel resolver based on a file name or namespace, but I found I was unable to import the typescript file anymore… (screenshot below and code on npm-moule branch)#2022-12-2919:50Kurt HarrigerI wasn’t sure about the duplication of dependencies and realized ATM I wasn’t requiring any npm modules from cljs code other than reagent which although used react didn’t seem to be included in bundle… so I added a couple more dependencies and I do see that these dependencies seem to be bundled eg including lodash creates a target/cljs-runtime/module$node_modules$lodash$lodash.js for use in cljs I then tried to add the :js-options {:js-provider :import} but keep the :target :esm and found it started complaining about not finding react dependency… So… ATM :`target :npm-module` works for cljs and npm dependencies from cljs but cannot import other local ts files. :target :esm can do all the things but any external libraries used in cljs and ts would be duplicated#2022-12-2920:08Kurt HarrigerIt also occurred to me to just drop the esm: prefix but this results in a different error during cljs build#2022-12-2920:10Kurt Harrigerperhaps there is a straighforward way to resolve the above in shadow-cljs config?#2022-12-2920:14thhellerno. this is intentional. any relative path is resolved using classpath rules and will be attempted to be included by the compiler. this is very different from esm: which actively tells the compile to do nothing and emit the import as is#2022-12-2920:14thhellerthere is no way and will never be a way to turn this behavior off 😛#2022-12-2920:16Kurt Harrigerhmm but it seems that using esm:./src/ts/util.js passes that to parcel as is includeing the esm and then parcel can’t find file named esm:…#2022-12-2920:18Kurt HarrigerI might be able to create a simple parcel resolver plugin that would drop the esm bit maybe but I would think maybe shadow-cljs shouldn’t emit the esm prefix in the js requires#2022-12-2920:21thhelleras I said esm: is a signal to the compiler to leave that import as is and NOT touch it at all#2022-12-2920:21thhellerwhereas "./src/ts/util.ts" tells the compiler to looks for that file and include it as part of the build just as any other CLJS or JS file#2022-12-2920:22thhellersince esm: leaves it as is parcel will find it and process it#2022-12-2920:28Kurt HarrigerI want it to emit require('./src/ts/util.ts') not require('esm:./src/ts/util.ts') as parcel doesn’t know what to do with the esm prefix… so I think the esm prefix should signal to shadow-cljs to not do anything with the file but I don’t see how it is useful to emit require('esm:./src/ts/util.ts') since the esm prefix is only meaninful to shadow-cljs#2022-12-2920:30Kurt Harrigerunless you think other tools should recognize and support esm: as a standard loader prefix of some sort but its not clear to me what its meaning would be for something like parcel or webpack other than to strip it and resolve the name#2022-12-2920:51thhelleresm: is only valid in :target :esm builds#2022-12-2920:51thhellerfor :npm-module you should go back to creating an alias for parcel. something I'd honestly always do for JS projects#2022-12-2920:51Kurt Harrigerhow do I specify an appropriate alias?#2022-12-2920:52thhellersame way you did for cljs stuff just the reverse#2022-12-2920:52thhellerlets say you create "my-project":"./src/ts" or so#2022-12-2920:52Kurt Harrigerin shadow-cljs.edn? or for parcel#2022-12-2920:52thhellerthen in CLJS just (:require ["my-project/util.ts"])#2022-12-2920:53thhellerand in TS the same for that matter ...#2022-12-2920:55Kurt Harrigerhmm in parcel you typically require the src file and it resolves and bundles it so I’m not sure what to use for “my-project” for local resources#2022-12-2920:55Kurt Harrigerso “my-project” doesn’t exist yet from which to require#2022-12-2920:55thhellerliterally a name you pick. your own choice. I've seen people use @project or LOCAL or whatever else fits your style#2022-12-2920:56thhellerYOU are creating it by setting that alias#2022-12-2920:56Kurt Harrigerbut maybe i can still create a alias that points to src folder#2022-12-2920:56Kurt Harrigerah okay let me try it#2022-12-2920:57thhelleralso remove the externals. I'm not sure why you are setting them?#2022-12-2921:02Kurt HarrigerI think this is what your ar sayng https://github.com/kurtharriger/parcel-cljs-demo/commit/cbd988791011524d7fcfea3b6e6d509bb8aca263#2022-12-2921:03Kurt Harrigerbut I still get issue …#2022-12-2921:06thhellerwhy would that work? think about it for one second#2022-12-2921:06thhelleryour require is "@project/src/ts/util.ts"#2022-12-2921:06Kurt Harrigeralthough I’m not sure why it wouldn’t work in this case since it works for cljs-main it seems the same thing#2022-12-2921:06thhelleryour alias is "@project": "./src/"#2022-12-2921:06thhellerthe logic is literally replace the alias with the replacement#2022-12-2921:07Kurt HarrigerI just ried it without the @ symbol but maybe it happens later in lifecycle#2022-12-2921:07thhellerso you end up with "./src/src/ts/util.ts"#2022-12-2921:07thhellerspot the error?#2022-12-2921:07Kurt Harrigeroh I see#2022-12-2921:07Kurt HarrigerIT WORK!!#2022-12-2921:08Kurt Harriger@U05224H0W +++++ gratitude-thank-you#2022-12-2921:12Kurt HarrigerIt imports it fine and if I move (ts/sayHi) out of main! it works but just noticing that main! isn’t being called when I load the page#2022-12-2921:13Kurt Harrigerits specified as init-fn in shadow-cljs.edn#2022-12-2921:13Kurt Harrigerperhaps not much of an issue just seems curious#2022-12-2921:14thhelleryour config is basically invalid now#2022-12-2921:14thheller:target :esm config is entirely different than :target :npm-module. so :modules for examples does nothing#2022-12-2921:14thheller:init-fn is also not supported by :npm-module#2022-12-2921:15thheller{:output-dir "target/" :target :npm-module} thats basically the relevant part of the build config right now#2022-12-2921:15Kurt Harrigeroh okay I guess that isn’t really needed here anyway#2022-12-2921:16thhellerthe point of :npm-module is intergrating with other JS tools such as parcel#2022-12-2921:16thhellerso the output acts more like a regular JS file would#2022-12-2921:16Kurt HarrigerI still want :js-options {:js-provider :import} though to prevent bundling npm deps right?#2022-12-2921:16thhellerno#2022-12-2921:17thheller:npm-module never does that anyways#2022-12-2921:17Kurt Harrigeroh okay so thats for esm only and no longer relevant#2022-12-2921:18thheller:js-provider is an option but it defaults to :require which is what you want#2022-12-2921:18thheller:import is indeed :esm only#2022-12-2921:21Kurt Harrigerso that app seems to work fine but no cljs repl support#2022-12-2921:23thhelleryou can get that by setting :runtime :browser in the build config#2022-12-2921:23thhellerand including the proper namespace from your JS somewhere#2022-12-2921:24thhellerif (process.env.NODE_ENV === 'development') { require("../path-to-output-dir/shadow.cljs.devtools.client.browser.js") }#2022-12-2921:24thhellerthats what you'd be doing in webpack#2022-12-2921:24thhellerno clue if parcel has something like NODE_ENV and conditional require support#2022-12-2921:25Kurt Harrigeryeah I think it does#2022-12-2921:25Kurt Harrigerperhaps can also do that from cljs file also#2022-12-2921:25thhelleryou cannot#2022-12-2921:25Kurt Harrigerpreloads mabye?#2022-12-2921:25Kurt Harrigerno okay#2022-12-2921:25thhellerentirely on purpose#2022-12-2921:25thheller:preloads is also not a thing for :npm-module
#2022-12-2921:26thhellerI mean it is a thing but the entire purpose is interfacing with JS tools and there is no way to tell JS tools "please load this other file before you load this one" cleanly#2022-12-2921:28thhellerit basically sacrifices a lot of CLJS convenience stuff for better compat with JS tools#2022-12-2921:28Kurt Harrigergot it, the above from tsx file seems to work and I’m sure that this could also be injected by parcel plugin as well#2022-12-2921:28thhelleralso note that the REPL is fairly limited and might not work in some cases since the REPL wants to load files directly#2022-12-2921:28thhellerand there is no way to know what parcel does with the files#2022-12-2921:31Kurt HarrigerI think this does everything I was hoping for…#2022-12-2921:31Kurt Harrigerthanks again!#2022-12-2921:33Kurt HarrigerIs this the preferred way to buy you a beer/coffee/etc https://github.com/sponsors/thheller#2022-12-2921:35thhelleryep 🙂#2022-12-2906:07Franklinit seems when I create a release build, source maps are not generated#2022-12-2906:07Franklinis there a way(perhaps a flag I could pass) to get shadow-cljs to generate source maps?#2022-12-2906:08Franklinactually, I see something in the user guide I could try#2022-12-2906:11Franklinsweet! I have source maps 🙂#2022-12-3013:58borkdudehow can I watch a release build, or put another way: can I watch a build with optimizations simple?#2022-12-3017:15thhellernot supported since it would usually be impractical. takes too long to build. just have shadow-cljs server running and then run shadow-cljs release app whenever you need it (or have another watch trigger it if you must)#2022-12-3018:50borkdudecljs.main does support it#2022-12-3018:51borkdudeI'll use the server approach#2022-12-3106:59thhellercljs.main makes no distinction between dev and release builds. in my experience release builds just take too long so that you often end up needlessly queuing builds by making edits while its still compiling#2022-12-3110:46metehanI needed to turn off {:infer-externs :auto} so I wrote {:infer-externs false} worked as I wanted but then I searched on github what are the valid values for :infer-externs` on documentation only refers to :all` and :auto so I tried random values like :none , :hello , true all worked same as false so what is the correct value to turn off#2022-12-3111:41borkdude@thheller I have used cljs.main + advanced build + watch several times to detect problems with advanced builds, it can be quite convenient in that situation#2022-12-3116:53thheller@m373h4n doesn't matter, just go with false.#2022-01-0415:05witekHello and a happy new year! Is there a way to query the shadow-cljs build id or the build target inside of (defmacro ...)? I have two different builds (one for browser and one for node) and I would like to generate different code from the macro.#2022-01-0416:14thhellerno, the build id is not directly accessible in macros.#2022-01-0416:15thhellerI guess you can get the compiler env and the set something in :compiler-options similar to how cljs-devtools does#2022-01-0422:10Alys BrooksI'm getting intermittent errors about jscomp.inherit , which has come up on this channel before and apparently it's an issue with correct polyfill loading. I don't know if there's helpful information I can report?#2022-01-0506:02thhelleryeah unfortunately this issue is proving very hard to reproduce but reports have been very silent for newer shadow-cljs version. which version do you use?#2022-01-0521:16Alys BrooksI just upgraded to the latest, 2.16.12 in an attempt to fix another issue.#2022-01-0522:22Alys BrooksThe release build doesn't seem to have this issue. I don't know if that's a coincidence or if release builds don't have this issue? The project I'm working on is for an event, so ideally release builds would be as low risk as possible in case we have to do a hotfix.#2022-01-0522:51Alys BrooksThis probably doesn't help very much but the specific module is goog.iter.es6.js.#2022-01-0605:56thhellerwhich :output-feature-set do you use? ideally you set :compiler-options {:output-feature-set :es8} (or higher if you can). then this error should disappear completely.#2022-01-0605:56thhellerif you have a repo to reproduce it that would help a lot in maybe tracking it down#2022-01-1920:54Alys BrooksSorry for not responding sooner. I'm not sure I can share the repository because it's for a client of ours. Is there a way I can find the code that caused the polyfill to be used? The source mapping doesn't seem to work (although maybe I should try Chrome).#2022-01-0422:12Alys BrooksUnfortunately I cannot simply link to the code, as it isn't open source.#2022-01-0500:39kennytiltonI am trying to figure out why a dependency did not get pulled into a shadow build. I am weak on CLJS builds I will confess. FWIW, I started from the coolio Helix todo-mvc project: https://github.com/lilactown/helix-todo-mvc, That just does npm i and npm start to get things running: { "private": true, "scripts": { "start": "npx shadow-cljs watch app" <===================== }, "dependencies": { "react": "^16.13.1", "react-dom": "^16.13.1", "react-refresh": "^0.8.1", "react-router-dom": "^5.1.2", "react-slider": "^1.3.1", "shadow-cljs": "^2.8.94", "todomvc-app-css": "^2.4.1", "todomvc-common": "^1.0.5" } } My deps.edn is
{:paths ["src" "src/demo" "src/mxreact"]
 :deps {lilactown/helix {:mvn/version "0.1.1"}
        binaryage/devtools {:mvn/version "0.9.7"}
        thheller/shadow-cljs {:mvn/version "2.15.1"}
        tiltontec/matrix {:mvn/version "4.1.7-SNAPSHOT"}
        cljs-http/cljs-http {:mvn/version "0.1.46"}}}
The dependency not retrieved by the build is Matrix. The build then complains about a Matrix namespace not being found. Inspection of .m2 confirms the deficit. If I execute clojure -P the dependency is pulled from Clojars and the build succeeds. Yay. My shadow-cljs.edn is :
;; shadow-cljs configuration
{:deps true
 :builds
 {:app {:target :browser
        :output-dir "js"
        :asset-path "/js"
        :modules {:app {:entries [app.core]}}
        :devtools {:http-root    "."
                   :http-port    8888
                   :reload-strategy :full
                   :preloads     [devtools.preload
                                  demo.dev]}}}}
My app.core NS is:
(ns app.core
  (:require
    [tiltontec.model.core :as md]
    [react]
    [mxreact.mxreact :as mxr]
    ["react-dom" :as rdom]
    [demo.demo :as dmo]
    ["react-slider" :default ReactSlider]
    [tutorial.x100-hello-world.lesson :as app]
    ))
Can anyone see why clojure -P was needed to get the dependency downloaded? Or is that just part of the drill when new dependencies are added? Thx! 🙏
#2022-01-0506:01thheller@hiskennyness shadow-cljs does not control what clojure does. if you set :deps true when running shadow-cljs watch app it will call clojure -M -m shadow.cljs.devtools.cli watch app and let clojure handle all dependency resolution and classpath creation. shadow-cljs will not attempt to download anything itself in that case. I do not know why it may not download something. In general I'd stay very far away from SNAPSHOT dependencies and instead use :local/root or :git/url if you can#2022-01-0506:36thhellerdid you maybe not restart shadow-cljs after adding the dependency? modifying deps.edn does require a shadow-cljs restart. just leaving the watch running won't work.#2022-01-0507:11coetryGood morning folks, I'm looking to set up a workflow where i have a shadow-cljs build running on a remote server and I connect to it from my local Emacs + Cider. Has anyone tried this?#2022-01-0509:35Franklinhello 👋 I'm getting this error while trying to import an npm package
shared.js:1552 TypeError: Super expression must either be null or a function, not undefined
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
    at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:44)
    at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
    at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:32)
    at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:1)
    at Object.shadow$provide.module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
Here's how the import statement looks like ["react-leaflet-vectorgrid" :default VectorGrid]
#2022-01-0509:36Franklinhere's how it's imported in JS `
import VectorGrid from 'react-leaflet-vectorgrid';
https://www.npmjs.com/package/react-leaflet-vectorgrid
#2022-01-0509:37thhellerwhich react version do you use?#2022-01-0509:37Franklin"react": "^17.0.2"#2022-01-0509:39thhellersorry. dunno never seen that error before. might be something to do with transpilation/polyfills#2022-01-0509:39Franklincool, thanks#2022-01-0509:39thhellertry :compiler-options {:output-feature-set :es-next} in your build config#2022-01-0509:40thhellermight also be a dependency version conflict on something#2022-01-0509:40thhellerif you setup a reproducible repo I can take a look#2022-01-0510:37witekHello. How do I access a custom value provided in :compiler-options inside of (defmacro ...)? Say, I have {:compiler-options {:xyz "23"}}. What is the path to "23" in &env?#2022-01-0510:42thhellersee https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/prefs.clj#L8-L12#2022-01-0510:42thheller@cljs.env/*compiler* :options is basically :compiler-options from your build config#2022-01-0510:46kennytiltonNo, @thheller, I did not have a watch running. The npm start command indirectly starts a watch, but I control-c'ed it each time, once it announced the missing dependency. Yes, I have :deps true in my shadow-cljs.edn, I am surprised to hear SNAPSHOT is a bad idea. Is that not a standard part of the ecosystem? I have noticed they do not work as dynamically as is really needed for iterative devlopment.This could be a breakthru! 🙂 I never heard of :local/root or :git/url options. To what are those options? I'll look around. I will also see what the clojure CLI crew has to say about dependency resolution. Thx!#2022-01-0510:48thhellerboth :local/root and :git/url are tools.deps options#2022-01-0510:48thhellernote that running npm start does not imply that there is not a previous running server#2022-01-0510:48thhellereg. having it running twice in separate terminals for examples#2022-01-0513:29kennytiltonYeah, I am always careful to run just one (and check there is just one if things seem broken). Thank god for terminal (on OS X anyway) putting a bullet next to any terminals with a running process.#2022-01-0510:48thhellerso make sure that on startup it doesn't say "connected to server"#2022-01-0510:49thhellerif it does that you do have an active server running#2022-01-0521:38ChaseI am getting a "required namespace is not available error" when starting up shadow-cljs. I created a project with a hyphen in it's name but then my main function is contact-book.core/main which I can't call in my index.html script because js does not allow hyphens. Am I understanding that correctly? Wherever my main function is should not have a hyphenated namespace or am I doing something else wrong?#2022-01-0605:52thhellercontact-book.core/main will become contact_book.core.main in JS#2022-01-0605:53thhellerdefine "required namespace is not available error". if you follow the rules everything should be fine. see https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2022-01-0521:57Ben HammondCan 'dev-http' start up an https server? https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http seems to imply that it is, but when I try
:dev-http {8081 "resources/public"
            8444 {:root "resources/public"
                  :ssl true}}
I just get two http endpoints I would expect to have to supply a jks keystore too...
#2022-01-0521:57Ben HammondI would like a dev https server to get my head around some secure cookie stuff#2022-01-0522:12Ben Hammond
:dev-http {8081 {:root "resources/public"
                  :ssl-port 8444
                  :ssl true}}
doesn't seem to work either
#2022-01-0522:29Ben HammondI am running
npx shadow-cljs watch foo
perhaps watch is not leveraging dev-http...?
#2022-01-0523:16lilactownit looks like you're missing the :ssl config in the top level? https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl#2022-01-0523:17lilactown:ssl true I don't see that documented anywhere in the user guide#2022-01-0605:53thhellerto get ssl you need to setup ssl globally as linked above#2022-01-0605:54thhellerthere is really only :ssl false for :dev-http where you can opt out of ssl for specific servers#2022-01-0611:08borkdudeFor people who have been wanting to watch a release build which isn't supported by shadow out of the box, I have a script here: https://github.com/babashka/obb/blob/main/bb/watch.clj#2022-01-0723:29ccannI’m trying to create externs for a https://github.com/authts/oidc-client-ts to use as a dependency from CLJS. Does anyone know how to do this? Seems like tools that generate externs do so from javascript files not typescript. (should I ask elsewhere?)#2022-01-0723:34ccanninteresting, looks like I can maybe use https://jmmk.github.io/javascript-externs-generator/ in combination with https://unpkg.com/oidc-client-ts@2.0.0-rc.3/dist/browser/oidc-client-ts.js but the generator asks for Enter the JavaScript object you want to extern: and I don’t really know what that question means#2022-01-0800:05ccannsomeone beat me to it https://clojurians.slack.com/archives/C03S1L9DN/p1641599186018800?thread_ts=1641402526.447600&amp;cid=C03S1L9DN#2022-01-1005:53rbergerhttps://clojurians.slack.com/archives/C03S1L9DN/p1641794005040100#2022-01-1006:12thhellercan you explain the troubleshooting section? why does commenting out :js-options fix it or what error did it reveal? where is the rest of the stacktrace?
AssertionError Assert failed: (map? rc)
...
#2022-01-1006:12thhellerthis error obviously shouldn't occur#2022-01-1323:19rbergerI’ll generate a full stack trace as soon as I get a chance. I don’t know why it was doing this. But it was a blocker to me until I figured out that was masking the real error.#2022-01-1009:27martinklepsch
(defn node-repl
  []
  (shadow/node-repl {:config-merge [{:js-options {:js-package-dirs ["functions/node_modules"]}
                                     ,,,}]}))
Is this a valid thing to specify with node-repl? We’ve split our package.json between frontend/backend recently and it looks like the node REPL isn’t able to find packages that only exist in the backend node_modules.
#2022-01-1010:15martinklepschActually it looks like other parts of the build are also broken with a similar error 😅#2022-01-1016:12thheller(shadow/node-repl {:pwd "functions"}) so it runs the node repl process in the functions dir#2022-01-1016:13thhellerotherwise it runs in the project dir and since no node builds bundle any dependencies directly node won't find them at runtime#2022-01-1016:30martinklepschohh, that sounds like exactly what’s needed!#2022-01-1016:30thhellerI'm not sure anyone has ever used that option so I don't even know if it works 😛#2022-01-1016:43martinklepschShould I keep the js-options one around too? just with :pwd I’m getting the same “cannot find module” errors as before#2022-01-1016:43martinklepschMaybe :pwd isn’t working 😄#2022-01-1016:52thhellerplease be more precise with the error report 😛#2022-01-1016:52thhellershadow-cljs can't find it or node cannot find it? two very different things with very different solutions#2022-01-1016:53thhelleralso note that if you had already startet a node-repl that may still be running and running node-repl again may just have reused that process?#2022-01-1016:54thheller(js/process.cwd) should tell you if :pwd worked#2022-01-1016:55thheller:js-options you need to keep if you have any (:require [a-symbol-pointing-to-npm-package ...])#2022-01-1016:55thhellereg. (:require [react])#2022-01-1016:55thhellerto know that react is actually meant to be a npm require if needs to check the package dirs#2022-01-1016:55thheller(:require ["react"]) does not need that check since it knows that string requires are not valid for CLJS namespaces#2022-01-1016:56thhelleralso check js/process.env.PWD#2022-01-1018:40martinklepschactually it is working! I accidentally passed it inside the config-merge option instead of to shadow/node-repl directly#2022-01-1014:07ingesolI’m trying to control the logging of shadow-cljs by doing
--config-merge '{:closure-defines {shadow.cljs.devtools.client.env/log false}}'
I was expecting shadow-cljs: load JS something/something.cljs logging to go away after looking at what seems to be relevant source code, but it’s still there. Am I supposed to be able to control this?
#2022-01-1014:24ingesolContext: It’s a big app where many of the changes I make trigger very many such lines, and I’m mostly not interested in that info.#2022-01-1014:25ingesolI suppose a nice alternative would be an option for compacting that info to something like “15 JS files loaded”.#2022-01-1016:10thheller:devtools {:log false} in your build config (or merged)#2022-01-1108:49ingesolawesome, thanks!#2022-01-1109:41zeitsteinThinking through using local state in grove conditionally. Something like this:
(defc ui-node [local?]
  (bind {:keys [id data] :as props} (get-in @state-atom [:id 1]))

  (bind local-data (when local? (atom data)))

  (bind data (if local?
               (g/watch local-data)
               data))
  ...)
would get me in trouble, https://github.com/thheller/shadow-experiments/blob/master/doc/components.md the hook type changes if local? changes. What I'm trying to achieve: if local?, work with local state (initialized to the value of global state), else work with global state.
#2022-01-1114:03thhelleryes this would not work. bind has pretty much the same rules as react hooks or the svelte stuff#2022-01-1114:03thhellerno conditions, no loops#2022-01-1114:04thheller(bind {:keys [id data] :as props} (get-in @state-atom [:id 1])) this should also never be done. that will only ever deref once so it'll never updates if you change the value in state-atom#2022-01-1114:08thhellerlocal state is also discouraged so in practice this will never come up 😉#2022-01-1117:15zeitstein
(bind {:keys [id data] :as props} (get-in @state-atom [:id 1]))
was a stand-in for a Fulcro hook. If I do a watch on state-atom then I'll chain two AtomWatches, which is a no-no 🙂 So, I can move my conditionals to render, though this means that
(bind local-data (atom data))
  (bind local-data-watch (g/watch local-data))
will initialize needlessly in instances where local state is not needed. I would also need to do
(bind local-data (atom (get-in @state-atom [:id 1 :data])))
to avoid the AtomWatch chaining, but that is what I want: I want to read this only on initialization of the instance. It seems to me like local state is the right 'pattern' for what I need (state per component instance). Storing it in a central atom/db for each instance seems like overkill (would also have to handle component lifecycle). This is how I had it set up in Fulcro with initLocalState. Happy to hear suggestions on how to handle it differently 🙂
#2022-01-1117:34thhelleras I said local state is not recommended. neither in fulcro nor in grove. first maybe explain WHY you want local state?#2022-01-1117:37thheller> Storing it in a central atom/db for each instance seems like overkill#2022-01-1117:38thhellerit costs pretty much as much as storing it in a local atom, so it is definitely not overkill#2022-01-1117:39thhellerbut without knowing what exactly you are trying to do its hard to make comparisons#2022-01-1117:43thhellerif this is about handlings forms I have a lot of plans for that but nothing implemented yet 😛#2022-01-1117:47zeitstein> it costs pretty much as much as storing it in a local atom, so it is definitely not overkill I agree, but would also have to handle component lifecycle (add/remove it on component mount/unmount). The use case is: the :data attribute is stored in a central db. Depending on some conditions, instances of a component using this attribute should either: 1. share this value in the central db (i.e. read current value from and update it in central db) 2. or read and store the value only on component instance initialization, then only update the value tied to that instance. Remove the value (wherever it is stored) once the component instance is destroyed.#2022-01-1118:46thhellerok as a general rule of thumb. grove is very much about the concept of "your view is a function of your data". therefore your data drives your components/views. your components should NEVER create data on mount or destroy it on unmount.#2022-01-1118:46thhellerinstead some part of your data should cause the mount of a component and removing such data should cause your component to unmount#2022-01-1118:47thhellerthat entire concept somehow got lost in react along the way but it was the promise at the start#2022-01-1118:50thhellerit does require rewiring your thinking a little bit but I find it immensly useful personally#2022-01-1118:50thhellerof course there is some state that is derived out of your view such as the height of a div or the mouse position or whatever. those are exceptions and bind and local state work for those#2022-01-1118:51thhellereverything else should be part of your normalized state#2022-01-1118:52thhellerfulcro is very similar in that regard. giving you even more tools to do this such as the forms and uism support#2022-01-1119:13zeitsteinIt's currently very difficult to imagine how this would be a practical approach in this case, but I'll try 🙂 Thank you!#2022-01-1119:14thhellerI mean the same stuff still happens. its just not your component mount triggering it.#2022-01-1119:15thhelleryou still haven't provided much info on "in this case". would help if you have some sample code. in fulcro is fine or JS or whatever is fine#2022-01-1119:18zeitsteinRight, sorry, thought I was being clear. You know the 'case': deep recursive trees and toggling. Now, in certain contexts, toggle state should be shared globally between component instances, in other contexts the toggle state should purely be local and transient. Every component shares the same data/state on initialization (and most of the data is 'global'), but there are slight deviations in behaviour depending on context.#2022-01-1119:19thheller:expanded-in-foo-context true :expanded-in-bar-context false#2022-01-1119:19thhellerwith your component querying whichever context it represents#2022-01-1119:20thheller:expanded-in-contexts #{:foo :bar} :expanded-for #{[:some/ident 1] [:other/ident 2]}#2022-01-1119:20thhellerthere is ALWAYS a way to express all of this as data#2022-01-1119:22thhellerthe goal is that if you have all your data at hand you know exactly what your view/ui looks like. no guessing.#2022-01-1119:22thhellerwith local state that pretty much becomes exponentially harder#2022-01-1119:24zeitsteinYeah, I understand that and working with Fulcro was so nice because of that. I'm sure there's a way to represent it as data, but it is much simpler (easier? :)) to use local state (in this case). And, in Fulcro, I can always look at the value of that state as well 🙂 The examples you've provided don't work, unless the idents identify the actual component instances. I.e. I have to track :expanded for every component instance. There is absolutely no sharing (in certain contexts). The context simply defines whether the state should be shared globally, not what it should be.#2022-01-1119:28zeitsteinSo, the way I see it, representing it as data would be, in some global atom, {id-of-component-instance {:expanded true}}.#2022-01-1119:28thhelleragain .. flip your thinking and stop thinking about components for a second#2022-01-1119:29thhellerthere is no such thing as id-of-component-instance. there is id-your-created-in-data-somewhere that is passed to your defc component as a prop#2022-01-1119:29thhellerthe bind queries something using that id, it gets data back and renders it#2022-01-1119:30thhellerin your data you remove that id you created and the component also unmounts#2022-01-1119:30thhellerbut really this would be much more practical to talk about with some code at hand#2022-01-1119:31zeitsteinThanks for your effort, truly 🙂 I'll prepare some code ASAP.#2022-01-1119:32thhellerI always design data first. meaning I create some EDN data until its in a shape I'm happy with. then I create something that renders it, maybe tweak it again until everything looks good 🙂#2022-01-1109:56rickmoynihanForgive my ignorance on cljs issues… but how does one fix warnings like this:
"5.1.0" was required by jar:file:/Users/rick/.m2/repository/com/kiranshila/cybermonday/0.3.139/cybermonday-0.3.139.jar!/deps.cljs
NPM dependency "remark-parse" has installed version "9.0.0"
I confess the relationship between npm/yarn/shadow-cljs/clojurescript and clojurescript deps from mvn etc isn’t exactly clear to me
#2022-01-1110:19zeitsteinDoes this help? https://shadow-cljs.github.io/docs/UsersGuide.html#_missing_js_dependency#2022-01-1110:26rickmoynihanI don’t know; it looks to me like that’s a different problem. Mine appears to be saying that there is a version mismatch; not that the dependency is missing.#2022-01-1110:26rickmoynihanI have a bunch of other similar warnings to do with different deps#2022-01-1111:32ingesolNot sure there’s an easy fix. If you are on tools.deps build, you can fork cybermonday and update its deps, and depend on it as a git coord.#2022-01-1111:42rickmoynihanOk I think I see what the issue is… looks like someone on my project added the transitive npm deps directly to our package.json#2022-01-1114:14thhelleryou can also upgrade shadow-cljs. that check has been removed for a while now 😛#2022-01-1115:38rickmoynihan😆 It’s funny you should say that; In parallel I’ve been trying to upgrade shadow-cljs; but I can’t move beyond 2.15.12 without getting test failures. I’m not sure what happened in 2.15.13 that is causing them but I’m assuming it’s somehow related to the closure/clojurescript version bump and perhaps I need to do something with the flag :global-goog-object&array :thinking_face:#2022-01-1115:39rickmoynihanGood to know if I upgrade they’ll vanish though :thumbsup:#2022-01-1109:57rickmoynihanNot to mention all the different javascript module systems etc#2022-01-1117:43orestisIs there a way to stop shadow from starting socket REPL and nrepl when in embedded mode?#2022-01-1117:44orestisI'm trying to figure how to have a plain Clojure environment that uses shadow as a library #2022-01-1117:44thheller:nrepl false and :socket-repl false in your shadow-cljs.edn config?#2022-01-1117:45orestisAh right. I guess I can pass those as args to start! somehow?#2022-01-1117:47thheller(start! {:nrepl false :socket-repl false}) yes but note that pretty much all in shadow-cljs assumes the presence of a shadow-cljs.edn. so if you attempt to make that not a thing you will lose features 🙂#2022-01-1117:47orestisOr probably since the server start! doesn't need the builds, I can pass it explicitly in. #2022-01-1117:48orestisOh we have a shadow-cljs.edn file with our builds defined, nothing else (apart from the deps which is what I want to take over)#2022-01-1117:48thheller
(-> (config/load-cljs-edn)
    (assoc :socket-repl false :nrepl false)
    (server/start!))
#2022-01-1117:49thhellerthat also works, config being shadow.cljs.devtools.config#2022-01-1117:49thhellerits what gets called if you call (start!) without args#2022-01-1117:49orestisYep makes sense. Is there a map with the other defaults ?#2022-01-1117:50thheller(config/load-cljs-edn) has those defaults merged in#2022-01-1117:50thhellergotta go, be back in a bit#2022-01-1117:50orestisGreat thanks. For context this is to assist also with Calva Jack in. #2022-01-1117:51orestisNo worries I have what I need, thanks!#2022-01-1119:26orestisAh, turns out you need to let shadow start nrepl because it injects its own middleware into things. I don't suppose that you can do that outside the context of a shadow build, right? Or to phrase it differently, can I pass in command line arguments to nrepl.cmdline such as that would make connecting to a CLJS REPL work?#2022-01-1119:33dpsuttonmiddleware are always added. CIDER adds its own. Here’s how you can start up an nrepl server with cider and shadow middleware:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} cider/cider-nrepl {:mvn/version "0.24.0"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl", "shadow.cljs.devtools.server.nrepl/middleware"]'
#2022-01-1119:34dpsuttonmore details at https://github.com/clojure-emacs/cider/issues/2812 if you want more#2022-01-1119:34thhelleryeah something like that. .nrepl.edn also works I believe. just need to add the shadow.cljs.devtools.server.nrepl/middleware middleware ns somehow#2022-01-1209:41Elsois there a way to configure shadow to write arbitrary keys to the generated package.json, or at least the engine key?#2022-01-1216:09thheller@d.eltzner012 shadow-cljs does not generate a package.json ever?#2022-01-1708:40ElsoI just checked, I removed both package.json and package-lock.json, ran npx shadow-cljs compile app and there was a package.json generated?!#2022-01-1717:50thhellerah. technically that is npm generating that. it is created by running npm install <packages> where packages comes from your dependencies declaring :npm-deps.#2022-01-1717:50thhelleryou should keep this file and the associated package-lock.json in version control#2022-01-1717:51thhellerthen you can add whatever you like to package.json yourself.#2022-01-1717:51thhellerand to answer your initial question: no, there is no way to have shadow-cljs add extra stuff#2022-01-1217:49zendevil.ethI’m running npx shadow-cljs watch app , but I want to run it in the background. How do I do that?#2022-01-1217:54dpsuttonin general you add an & at the end of the command. But in practice i like having it in the foreground so i can easily stop, see compiler output, etc. so i prefer to just use a dedicated terminal tab for it#2022-01-1218:54agoldAlso asked in #calva but no answer yet.#2022-01-1218:57dpsuttonthis is most likely 100% an nrepl / calva issue. If you just do npx shadow-cljs node-repl and eval that presumably the output will show up in the terminal?#2022-01-1218:59dpsutton
❯ npx shadow-cljs node-repl
shadow-cljs - config: /Users/dan/projects/work/metabase/shadow-cljs.edn
shadow-cljs - connected to server

cljs.user=> shadow-cljs - #5 ready!

cljs.user=> (let [tn (js/setTimeout #(println "hello") 1000)]
    (println tn))
#object[Timeout 52]
nil
cljs.user=> hello
#2022-01-1219:13agoldThanks, yes, that works for me too.#2022-01-1300:07tony.kayAny idea what this means?
Multiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "dataico/model/bank.cljc"] still waiting for #{dataico.model.payment}
I’m getting these in my CI system, but the compile is fine locally. No other info. The exception does not show a cause.
#2022-01-1300:07tony.kayI’m guessing perhaps RAM?#2022-01-1306:19thheller@tony.kay compilation aborts if no progress is made for 60 seconds. par-compile is the parallel compile and threads wait if dependencies they need are still compiling. after 60sec they abort since that usually means something went wrong and compilation cannot finish. is there something in dataico.model.payment that might cause a huge wait time? eg. some macro expanding into something gigantic or just taking very long?#2022-01-1306:20thhelleryou can set :build-options {:par-timeout 120000} to increase the timeout to 2min (its msec) but unlikely that changes much unless you CI system is running on a toaster 😉#2022-01-1316:44tony.kayI run parallel builds and tests on a 16GB/4CPU node, but in docker containers. Was using 2G/4G ram/swap limits on those nodes, so it is possible that was just too little ram to allocate to the build for CLJS. I upped it some, and we’ll see how it goes.#2022-01-1316:45tony.kayThanks a lot for the response. Now that I understand what the error means I can handle it 😄#2022-01-1306:30tony.kayIt's a large build, and the runner is a bit taxed. 60s seems like a long time with no progress. It fails often, but not always. I'll try the larger timeout.#2022-01-1306:37thhellernote that "progress" is counted based on top-level forms processed. so there must be a single form taking more than 60seconds to compile?#2022-01-1316:39tony.kayWow…that’s kind of hard to believe. Wonder if I’m thrashing the CI node#2022-01-1314:55simongraytrying to set up shadow-cljs for an existing project and I keep getting this error when starting the watch process:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/rqf595/.m2/repository/thheller/shadow-cljs/2.16.12/shadow-cljs-2.16.12.jar!/shadow/remote/runtime/obj_support.cljc:1:1
--------------------------------------------------------------------------------

   1 | (ns shadow.remote.runtime.obj-support
-------^------------------------------------------------------------------------
Invalid :refer, var cljs.repl/error->str does not exist
--------------------------------------------------------------------------------
   2 |   (:require
   3 |     [clojure.datafy :as d]
   4 |     [clojure.pprint :refer (pprint)]
   5 |     [clojure.spec.alpha :as spec]
--------------------------------------------------------------------------------
#2022-01-1314:56simongray#2022-01-1314:58simongrayOtherwise no other errors reported. The only other annoyance is about a novel’s worth of text in my terminal telling me [2022-01-13 15:53:12.679 - INFO] duplicate resource goog/....#2022-01-1318:24thhellerthis is coming from one of you dependencies I guess. since you truncated the error message I cannot say more about that#2022-01-1318:25thhellerrun shadow-cljs clj-repl and ( "cljs/repl.cljs"). I'm guessing that is not yielding the expected clojurescript jar#2022-01-1408:32simongrayThat gives me
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.12 running at 
shadow-cljs - nREPL server started on port 57233
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=> ( "cljs/repl.cljs")
#object[java.net.URL 0x418341f9 "jar:file:/Users/rqf595/.m2/repository/com/owoga/tightly-packed-trie/0.2.3/tightly-packed-trie-0.2.3.jar!/cljs/repl.cljs"]
shadow.user=> 
#2022-01-1408:33simongrayAnd a novel’s worth of
[2022-01-14 09:31:54.403 - INFO] duplicate resource goog/mochikit/async/deferred.js on classpath, using jar:file:/Users/rqf595/.m2/repository/com/owoga/tightly-packed-trie/0.2.3/tightly-packed-trie-0.2.3.jar!/goog/mochikit/async/deferred.js over jar:file:/Users/rqf595/.m2/repository/org/clojure/google-closure-library-third-party/0.0-20211011-0726fdeb/google-closure-library-third-party-0.0-20211011-0726fdeb.jar!/goog/mochikit/async/deferred.js
and similar messages before it.
#2022-01-1408:36simongraySo I wonder if this means that tightly-packed-trie is overruling my ClojureScript version? Shouldn’t it be using the most recent version when there’s a conflict…?#2022-01-1411:54thhellerall this means is that tightly-packed-trie is actually itself containing the cljs sources and others it shouldn't contain#2022-01-1411:55thhellerdoesn't matter what other cljs version you specify. classpath only picks the first one#2022-01-1411:56thhellerthis also has nothing to do with dependency resolution or conflicts. the jar contains files it should not contain that is all.#2022-01-1411:56simongrayWell, that’s annoying :S#2022-01-1411:57simongraythanks a lot for clearing that up for me. You don’t happen to know if there’s a way to exclude those CLJS sources?#2022-01-1411:57simongraylike you think I could use this? https://simonrobson.net/2019/04/16/clojure-deps-with-exclusions.html#2022-01-1411:58thhellerthis also has nothing to do with exclusions. this can only be fixed by the library itself cleaning up the release#2022-01-1411:59thhellerwho knows what else it contains#2022-01-1411:59simongraydamnit. I’ll work around it then, gotta find some other trie implementation.#2022-01-1412:00simongrayThanks a lot, Thomas. I really appreciate it.#2022-01-1412:01thhellerwhy are you activating the :backend alias in your shadow-cljs.edn? :deps {:aliases [:frontend :backend :test]}?#2022-01-1412:01thhellerif you remove that the lib won't be on the classpath so the problem will be gone?#2022-01-1412:02simongrayI have a custom handler#2022-01-1412:02simongraylocated in the backend code#2022-01-1412:04thhellerwhy not run the backend separately? thats what I typically recommend because of issues such as this#2022-01-1412:06simongrayI want to make a progressive app, so the integration is sort of the point.#2022-01-1412:07simongrayI’ll work around it, doesn’t have to be that trie implementation. 🙂 I can use some other or make my own.#2022-01-1412:16thhellerhttps://github.com/eihli/clj-tightly-packed-trie/issues/1#2022-01-1412:28simongrayNice! Well, hopefully they fix it and I can proceed as before. I just commented out the trie code for now and everything’s working fine!#2022-01-1314:58simongrayNot really sure where to go from here since the error is reported to originate from within shadow-cljs itself :S#2022-01-1315:12Aronwhich version?#2022-01-1315:13simongray
2.16.12
#2022-01-1315:18Aronweird, I saw something similar long time ago, but I don't remember what did I wrong#2022-01-1315:23simongrayyeah, also pretty much at a loss here… basically just copied in my shadow-cljs setup from a different project, trying to hook up the paths with new namespaces…#2022-01-1315:33Kurt SysTranslating fs.readFile to cljs seems to be not as straight forward (I think I'm missing something):
(ns ...
  (:require ...
            ["fs" :as fs]))

(fs/readFile ...)
doesn't seem to work: react-dom.development.js:11341 Uncaught TypeError: shadow$empty.readFile is not a function What am I missing? (I'm using shadow-cljs, obviously and I'm using cljs with a browser target)
#2022-01-1315:44Aronbrowser doesn't have fs, that's nodejs api#2022-01-1315:45Kurt Sysok, thx.#2022-01-1315:47Aronhttps://github.com/jvilk/BrowserFS 😄#2022-01-1317:11Kurt SysI'm trying to translate this to cljs (https://github.com/alonrbar/easy-template-x#template-handler-options )
import { TemplateHandler } from 'easy-template-x';

const response = await fetch('');
const templateFile = await response.blob();

const data = {
    posts: [
        { author: 'Alon Bar', text: 'Very important\ntext here!' },
        { author: 'Alon Bar', text: 'Forgot to mention that...' }
    ]
};

const handler = new TemplateHandler();
const doc = await handler.process(templateFile, data);
Somehow, whenever I fetch a docx template, it seems it's not valid docx.
(-> (fetch/get filePath {:headers {:accept "application/vnd.openxmlformats-officedocument.wordprocessingml.template"} })
        (.then (fn [response] (:body response)))
        (.then (fn [template]
                (.process templateHandler template #js{}) ))
results in: Uncaught (in promise) Error: Malformed file detected. Make sure the file is a valid docx file. It's a fresh docx file. I suppose there's something wrong with fetching and reading it. It doesn't matter how, but did anyone ever generate a docx in-browser (from a template)?
#2022-01-1317:22Aronhave you tried debugging? like you can just step through the code in the browser and see what the problem is#2022-01-1317:26Kurt Syswell, the blob is not recognized as a valid zip file. The Zip.load line fails. It fails when I fetch it first, so there must be something in making the response a valid zip.
async loadDocx(file) {
    // load the zip file
    let zip;

    try {
      zip = await Zip.load(file);
    } catch (_unused) {
      throw new MalformedFileError('docx');
    } // load the docx file
#2022-01-1317:49Kurt Syswell, solved it by just using js/fetch:
(-> (js/fetch filePath)
        (.then (fn [response]
                 (.blob response)))
#2022-01-1317:52thheller@kurt.sys you need to use JS interop for many things. (.then (fn [response] (:body response))) this doesn't work because response is a JS object and keyword looks only work for clojure maps#2022-01-1317:54Kurt SysYeah, well, the (:body response) returned something, but not something valid 🙂 . Just plain js interop seems to work fine.#2022-01-1317:54DerekAre you using lambdaisland’s fetch there?#2022-01-1317:56Kurt SysYeah, I was, but I removed it and just use plain js/fetch#2022-01-1317:56thhellerah that was a library. though it was just fetch. then I don't know what response is#2022-01-1317:57DerekSame, but it explains why :body returned something#2022-01-1317:58Kurt SysWell, plain js/fetch works, with the lib, the body doesn't seem to have a valid response, and .blob doesn't exist in the library.#2022-01-1405:34joshuamzmHi. I created a minimal shadow project configured with :external JS provider and configured Webpack for the final bundle phase. I have one dependency that relies on React and ReactDOM (both v16.x) among others. However, when I release the build with shadow-cljs, I get the following warning:
> shadow-cljs release web
(...)
[:web] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: shadow.js.shim.module$react_dom.js:3:34
 variable shadow$bridge is undeclared
--------------------------------------------------------------------------------
nil
[:web] Build completed. (...)
Am I missing something in this configuration? I'm using shadow-cljs v2.16.12. You can get more details from this Github issue: https://github.com/thheller/shadow-cljs/issues/978 Looking up in this channel, I found someone that got the same warning https://clojurians.slack.com/archives/C6N245JGG/p1632299596117200, but I couldn't find any more references on this matter. Thanks for your time reading this report.
#2022-01-1411:49restenbis there a way to tell the shadow-cljscli to write the output of shadow-cljs pomto a different file than pom.xml?#2022-01-1411:58thheller@restenb there is not no. if you already have a pom.xml it is likely you shouldn't be calling that task?#2022-01-1412:00restenbi have a leiningen project.clj backend with shadow-cljs.end used for frontend deps only. it was added late in the project to get node support#2022-01-1412:01restenbbut the pipeline generates with lein pom and uses that for certain things. so it'd be nice to output the shadow deps somewhere else#2022-01-1412:02thhellerI don't understand the problem then? neither project.clj nor shadow-cljs.edn use pom.xml for anything?#2022-01-1412:06restenbthe build pipeline does, so pom.xml gets overwritten there since both shadow-cljs pom and lein pom have to be run. it's not a huge problem, just curious#2022-01-1412:07restenblein pom doesn't support changing the output name either, so here we are 😛#2022-01-1413:36restenbwhere does shadow-cljs get the artifactId and groupId it generates from? right now it's groupId=artifactId=directoryName it seems? can this be changed?#2022-01-1414:07restenbyep, hardcoded to path it seems. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/cli.cljs#L658#2022-01-1415:54David PhamHello everyone, did anyone see the same error in advanced compilation?
NullPointerException: NAME module$contents$goog$testing$storage$FakeMechanism_FakeMechanism 94:10  [length: 13] [source_file: goog/testing/storage/fakemechanism.js] [original_name: FakeMechanism]
#2022-01-1415:56David PhamShadow-cljs version 2.16.12#2022-01-1415:59thhellerwhats the rest of the stacktrace?#2022-01-1415:59David Pham
NullPointerException: NAME module$contents$goog$testing$storage$FakeMechanism_FakeMechanism 94:10  [length: 13] [source_file: goog/testing/storage/fakemechanism.js] [original_name: FakeMechanism]
	com.google.common.base.Preconditions.checkNotNull (Preconditions.java:897)
	com.google.javascript.jscomp.RemoveUnusedCode.getVarForNameNode (RemoveUnusedCode.java:895)
	com.google.javascript.jscomp.RemoveUnusedCode.traverseNameNode (RemoveUnusedCode.java:751)
	com.google.javascript.jscomp.RemoveUnusedCode.traverseNode (RemoveUnusedCode.java:571)
	com.google.javascript.jscomp.RemoveUnusedCode.traverseChildren (RemoveUnusedCode.java:1305)
	com.google.javascript.jscomp.RemoveUnusedCode.traverseNode (RemoveUnusedCode.java:581)
	com.google.javascript.jscomp.RemoveUnusedCode.access$1200 (RemoveUnusedCode.java:83)
	com.google.javascript.jscomp.RemoveUnusedCode$Continuation.apply (RemoveUnusedCode.java:1829)
	com.google.javascript.jscomp.RemoveUnusedCode.traverseAndRemoveUnusedReferences (RemoveUnusedCode.java:412)
	com.google.javascript.jscomp.RemoveUnusedCode.process (RemoveUnusedCode.java:386)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
	com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:462)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
	com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
	com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
	com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:905)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:564)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/compile-js-modules (closure.clj:1102)
	shadow.build.closure/compile-js-modules (closure.clj:1088)
	shadow.build.closure/optimize/fn--12464 (closure.clj:1297)
	shadow.build.closure/optimize (closure.clj:1283)
	shadow.build.closure/optimize (closure.clj:1274)
	shadow.build.api/optimize (api.clj:273)
	shadow.build.api/optimize (api.clj:267)
	shadow.build/optimize (build.clj:476)
	shadow.build/optimize (build.clj:468)
	shadow.cljs.devtools.api/release* (api.clj:339)
	shadow.cljs.devtools.api/release* (api.clj:324)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--17177--auto----17893 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)§
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
#2022-01-1416:16thheller@neo2551 are you sure you are on 2.16.12? I have seen this stacktrace before but that was fixed a while ago? might be something unrelated of course, just checking#2022-01-1416:32David PhamYes I am sure. I can just try again. I used 2.15.2 and it was working. #2022-01-1416:39thhellerwell that bump would include a closure compiler version bump. it had a bunch of other issues so no surprise there#2022-01-1416:41David PhamIt magically works now 😕#2022-01-1416:43David PhamYep, it works now 😕 I am sorry, for the disturbance...#2022-01-1416:44thhellerit might be an issue with incremental compilation. there have been a few of those. if it happens again try wiping .shadow-cljs/builds/<your-build-id> and recompile. please let me know if that fixes it#2022-01-1416:44David PhamThanks!#2022-01-1503:48mindbenderWhere can I see all the available configuration options for shadow-cljs.edn?#2022-01-1505:54thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html but what are you looking for?#2022-01-1511:40mindbenderI can't get documentation for some options I see used elsewhere like [:devtools :http-resource-root] among others#2022-01-1512:21thhellerbecause that is deprecated and shouldn't be used anymore. see :dev-http instead#2022-01-1703:56mindbenderIs it safe to say that all available configuration options were exhausted in the [UsersGuide](https://shadow-cljs.github.io/docs/UsersGuide.html) ?#2022-01-1511:40Ben HammondI have a page with a js/WebSocket on it every time shadow-clj recompiles and reloads the page, my WebSocket gets closed Is there any way to mitigate this? (I definitely dont want to disable the hot-compile-and-reload )#2022-01-1512:18thheller@ben.hammond can't really say without knowing what you are doing in the code. the lifecycle callbacks are meant to let you manage your lifecycle and if you do that properly the websocket doesnt disconnect#2022-01-1512:18thhellerif you just do (def x (js/WebSocket. ..) then yes that'll disconnect by design, defonce might help#2022-01-1512:19Ben HammondYes of course#2022-01-1512:19Ben HammondThank you very much#2022-01-1603:20Christopher GenoveseI've been working on a project with shadow-cljs for the past month or two, without much issue besides occasional mysterious hangs. I did notice, however, that the watch was not recompiling on all changes (or even most). Still, it worked fine. Then this afternoon I made one change in my shadow-cljs.edn, changing the name of the exported symbol and that's it, with no other changes in the code. After that, recompiles occured on every change, as would be expected, but after every recompile things go catastrophically wrong. Sometimes all my namespaces become inaccessible at the repl, sometimes all previously defined symbols have disappeared, sometimes it's weirder -- a type that implements IFn (and gives ifn? true) has the right value but doesn't call -invoke and gives an error when used as a function, though only a moment before (pre-re-compile, with an unrelated change) it was fine. No errors are displayed at compile or in the log. I can't change anything without needing to restart. I've mostly worked in CIDER but I've tried it with the straight shadow-cljs repl too, same thing. I have no idea what's going on or why this single change to the shadow-cljs (with no other change to the code) would precipitate the problem. I've eliminated the builds and started again but after a few minutes, the problem happens again. I'm assuming that it's something else besides the config file but don't see any information pointing the right way. Perhaps I'm missing something obvious, but I'm not seeing it. Any ideas as to how to proceed would be most welcome! I can't get anything done as it is now, which is frustrating. My config is below. Let me know if there's something else I should show. Thanks for any help you can offer.
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[better-cond             "2.1.0"]
  [binaryage/oops          "0.7.0"]
  [camel-snake-kebab       "0.4.2"]
  [data.deque              "0.1.0"]
  [instaparse              "1.4.10"]
  [metosin/potpuri         "0.5.3"]
  [com.rpl/specter         "1.1.3"]
  [net.cgrand/xforms       "0.19.2"]
  [org.clojure/algo.monads "0.1.6"]
  [org.clojure/core.match  "1.0.0"]
  [org.clojure/test.check  "1.1.1"]]

 :builds
 {:main {:target :node-library
         :output-to "out/yadayada.js"
         :exports {:createParser yadayada.core/create-parser}}
  :test {:target    :node-test
         :output-to "out/node-tests.js"
         :ns-regexp "-test$"
         :autorun   false}}

 :nrepl {:port 8777}

 :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}
#2022-01-1606:53thheller@genovese do you have an actual error or so? this is all a bit abstract. config looks fine. I wrote https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html describing how hot-reload works. maybe you are doing something listed in the "things to avoid"?#2022-01-1615:51Christopher GenoveseThanks for the reply. I realize it's abstract and seems vague. The thing is there are no specific error messages. I believe I am following all the provisos you mention in your blog post. This is a computational library so there's no persistent state, except for a debug atom I use with tap> from time to time. Here's a typical example of how things proceed: cljs.user> (nw/number-lookahead "one") "one" cljs.user> (nw/parse frame) ; unexpected result, make minor change ; like adding a tap> call [:main] Compiling ... [:main] Build completed. (82 files, 2 compiled, 0 warnings, 2.19s) cljs.user> (nw/number-lookahead "one") Execution error (TypeError) at (<cljs repl>:1). yadayada.number-words/number-lookahead is not a function At that point, everything is messed up. In this example number-lookahead is an IFn. I can see it's value but it no longer produces invoke just an error when used as a fn. Some functions or constants are seemingly inaccessible. Often, after the compile, nothing works, but it varies. I have noticed that the watch is not recompiling most of the time. The problems start when it does, but it seems odd in retrospect that the recompiles are so inconsistent. I'll grab a shot of everything that happens next time, though I'm not sure it will be much more. I'm monitoring the nrepl messages to see if something shows up there. I can work for a random stretch making changes without any recompiles and then suddenly it happens. There's a loose association with adding in tap> calls, but that neither makes sense as an explanation nor is definitive. I'm really not sure how to get a lead here. Again, I really appreciate the help and reply. Thanks. Let me know how I can further clarify. Sorry it's so vague...#2022-01-1616:01thhelleras a general tip maybe: I recommend sticking with a generic node-repl or browser-repl when doing mostly REPL driven stuff. the hot-reload tends to get in the way and is sort of at odds with the REPL#2022-01-1616:01thhellerare you changing the defn to a def with IFn maybe?#2022-01-1616:02thhelleralso which shadow-cljs version is this? a few REPL bugs where fixed a while ago so older releases might still have some issues#2022-01-1617:20Christopher GenoveseVersion 2.6.12. Not sure what you mean about def; it's a record that has -invoke methods on the IFn protocol. Generally works just fine then treating the object as a function, which I need in some contexts. So no defn or def in that case. On the repl type, that makes sense. The reason I've avoided it so far is that when I make changes in the code it becomes a pain to get the code up to date. If I do require :reload at the repl (or :reload-all), it often doesn't work. And I can't get namespace aliases to stick. (This seems to have something with the missing ns variable that is not defined at the repl but used in require, import, require-macros functions.) I suppose I can just reload my user.cljs. I'll try that to see if that is a workable workflow. I feel I'm doing something not quite right to have that problem.#2022-01-1606:54thheller> Sometimes all my namespaces become inaccessible at the repl#2022-01-1606:55thhellerwhat does this mean?#2022-01-1606:55thheller> sometimes all previously defined symbols have disappeared#2022-01-1606:55thhellerhot reload is expected to lose all symbols defined only in the REPL?#2022-01-1615:53Christopher Genovese@thheller In the reply just how, I tried to clarify. Not repl-defined values but constants and functions defined in the namespace are no longer recognized at the repl. Some are, some not. Sometimes I can see them but they are not treated normally, like the IFn example I gave in reply.#2022-01-1703:57Kurt HarrigerIf your browser window reloads you will loose all your state are you sure something is not causing the window to reload#2022-01-1706:57thheller@U02RP8DDFLH the question was about a :node-library build so no browser#2022-01-1716:37Kurt HarrigerOh I see… strangely enough I just noticed this issue this morning working on a node app for my logseq things3 plugin. Things 3 stores tasks in a local sqlite database and I wanted to query it to sync logbook to logseq, Logseq is an electron app, but plugins are sandboxed so I created this app allow me to query the database via http api instead of reading file from logseq. When I save the file, shadow-cljs recompiles and reloads the app. I need to eval the buffer again which isn’t that big a deal but my defonce vars are lost and so I need to reload the db. I cheat a bit my having a comment at the end of the code that I change from comment to do while developing which works reasonably find for me but seems is same problem. I’ve published the code at https://github.com/kurtharriger/logseq-things3-query-proxy not entirely sure how useful it is for reproducing the issue if your not using things 3 or a mac, but maybe its helpful#2022-01-1717:48thhellerits missing instructions or so? don't know what to do with this or what it is supposed to show?#2022-01-1615:57Christopher GenoveseSorry and to clarify the first point. Namespace aliases are also all gone and often when I try to get a value in a require'd namespace it says it cannot find the namespace. (I require several namespaces with consistent aliases in my user.cljs function, which I manually load.) Those might go away on a hot reload, but when I reload the file, they are not restored. (Consistently, require at the repl also does not seem to properly define aliases, which is why I put them in user.cljs.) Does that make more sense?#2022-01-1615:57Christopher Genovesejust how -> just now#2022-01-1703:15Kurt Harrigerquestion: when using shadow-cljs repl and I often want to print result of an async function, but since js is non-blocking I need to do something like (go (pprint (<! (get-some-data))). This will print the result to the js/console but in the repl I only see #object[cljs.core.async.impl.channels.ManyToManyChannel] and thus I need to tab back and forth from browser… In js console I can use await when calling async functions but I think thats a browser console specific thing. Any chance there is a way to have to repl subscribe to a promise and print the result when its available#2022-01-1706:56thhellernot that simple unfortunately. I thought about adding a REPL primitive to wait for an async result but since you can't block that might "deadlock" the entire REPL. I'd recommend tap> and Inspect instead if pprint so that doesn't have that issue?#2022-01-1716:49Kurt HarrigerThanks. I’m not as familiar with tap> from docs it seems like add-tap allows you to register multiple callbacks such as println or some other behavior, eg inspect? what do you mean by inspect. Do you mean (.dir js/console object) ? I do get messages in the js console just not the repl, so trying to see if there is some method to send a message to the repl when its completed. I don’t necessarily think the repl needs to block, I think it would be fine if you see a prompt and then when data is ready its pushed to the repl… but i’m not sure if there is anyway for the app to push anything to the repl after the command is completed. I assume it waits until the command completes and then stops listening to the out stream so probably not possible but thought it worth asking to see if its feasible#2022-01-1717:45thhelleryou just (tap> value) and it'll show up in the inspect ui, usually available at http://localhost:9630/inspect#2022-01-1717:47thhellerthe issue is much more in nrepl than it is in shadow-cljs. nrepl isn't expected to receive two return values for one eval so it'll either just discard the second or freak out. depends on your editor#2022-01-1713:43simongrayIs there any way my code can know whether it’s running as a release build or as a regular dev build (through watch)?#2022-01-1714:02simongrayCurrently, I do it this way, but it feels like a hack:
(def main-js
  "When making a release, the filename will be appended with a hash;
  that is not the case when running the regular shadow-cljs watch process.

  Relies on the :module-hash-names being set to true in shadow-cljs.edn."
  (if-let [url (io/resource "public/js/compiled/manifest.edn")]
    (-> url slurp edn/read-string first :output-name)
    "main.js"))

(def development?
  "Source of truth for whether this is a development build or not. "
  (= main-js "main.js"))
#2022-01-1715:58lispers-anonymousCan you check goog/DEBUG?#2022-01-1715:58lispers-anonymousYou are in clojure, not clojurescript. That won't work. Nevermind me#2022-01-1716:52Kurt HarrigerI assume your build process could define some environment as part of the different build configurations and you could check that?#2022-01-1717:43thheller> my code can know whether it’s running as a release build or as a regular dev build#2022-01-1717:43thhellerdefine "my code"? the snippet you posted is clojure? do you want to know in CLJS or CLJ?#2022-01-1717:44thhellerfor CLJS the answer would be closure defines and setting a different value for :release. see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2022-01-1718:20simongrayRight, the reason I do it in Clojure is because I’m generating the html page dynamically using Clojure and then I pass that on to CLJS. I need to know in both 🙂#2022-01-1805:56thhelleron the CLJ side just always use the manifest. dev builds also generate it. dunno why you'd need to know if its a dev build though. for CLJS see :closure-defines above#2022-01-1807:07simongrayOn the CLJ side I do it to disable CORS/authz and on the CLJS side I mostly use it as way to indicate that those things are disabled.#2022-01-1807:09thhellerIMHO that should be a setting on the CLJ side and not be derived from what CLJS you are using
#2022-01-1807:20simongrayIt is a setting (I mean, I can always just hardcode the boolean to some value), but it’s nice that it’s working automatically in 99% of cases ;-)#2022-01-1822:29cjsauerCan I set JVM system properties from the command line with shadow?#2022-01-1822:29cjsauerSomething like this:
npx shadow-cljs clj-repl --config-merge '{:jvm-opts ["-Duser.home=blah"]}'
#2022-01-1822:29cjsauerThat doesn’t seem to be sticking tho#2022-01-1823:09berkeleytrueIn a shadow-cljs project, when my cljs dependency has npm depencies (macchiato has a :npm key in project.clj and a package.json) how do I get shadow to install those npm modules? Do I have to manually install them in my projects package json?#2022-01-1823:11berkeleytrueThe project has npm declared in their project.clj file. https://github.com/macchiato-framework/macchiato-core/blob/master/project.clj#L19#2022-01-1906:55thhellerin general project.clj is not part of a distributed package. it is only used to generate pom.xml which actually drives the maven distribution. so the :npm key does absolutely nothing since it is not transfered to pom.xml#2022-01-1906:56thhellerCLJS packages can include a deps.cljs file with {:npm-deps {"foo" "1.2.3"}} which would make shadow-cljs run npm install on compile#2022-01-1906:57thhellerif the package does not include that file then shadow-cljs doesn't have any info on missing npm packages and can't install them#2022-01-1917:13berkeleytrue@U05224H0W thanks for the info! I ended up just coping the npm deps manually.#2022-01-1906:54thheller@cjsauer no, that is not supported. it is only meant to merge build specific stuff.#2022-01-1921:14hadilsHi1 Dumb question. I have this code:
(let [p          ^js (<p! (current-authenticated-user))
              email      (.. p -attributes -email)
              first-name (.. p -attributes -given_name)
              last-name  (.. p -attributes -family_name)]
          (log/debug "werker-session" email first-name last-name)
          {:werker-session
           {:werker/id         tid
            :werker/email      email
            :werker/first-name first-name
            :werker/last-name  last-name
            :werker/status     :signed-in}})
Which generates these errors:
Cannot infer target type in expression (. inst_60203 -given_name)
Cannot infer target type in expression (. inst_60205 -family_name)
The code works just fine. I tried everything I read on Google, to no avail. Any suggestions? Thanks in advance! Actually here’s the body of the code:
(go
    (let [tid (tempid/tempid)]
      (try
        (let [p          ^js (<p! (current-authenticated-user))
              email      (.. p -attributes -email)
              first-name (.. p -attributes -given_name)
              last-name  (.. p -attributes -family_name)]
          (log/debug "werker-session" email first-name last-name)
          {:werker-session
           {:werker/id         tid
            :werker/email      email
            :werker/first-name first-name
            :werker/last-name  last-name
            :werker/status     :signed-in}})
        (catch js/Error err
          (log/error "init-werker-session error" err)
          {:werker-session
           {:werker/id         tid
            :werker/email      ""
            :werker/first-name ""
            :werker/last-name  ""
            :werker/status     :not-signed-in}}))))
#2022-01-1921:17hadilsThe error is indicated on the go function.#2022-01-2004:08lilactownthe issue is ^js inside of go#2022-01-2008:25thhelleryeah, in general keep as much code as possible out of go. ^js hints are lost in most places and generates a lot more code than it would outside go#2022-01-2012:27hadilsThanks, gentlemen. Most of the code inside go can’t be moved outside thought.#2022-01-2012:53hadilsThanks again @lilactown @thheller. Getting rid of the ^js did the trick.#2022-01-2017:50sbHello, I require [“fs” :as fs] the Node FS module and I would like to use as (fs/readFileSync file-with-location) but I get: shadow$empty.readFileSync is not a function what is this error message?#2022-01-2018:05dpsuttonquick sanity check, are you running a browser or node repl?#2022-01-2018:05sbI use IntelliJ with cljs repl via
(shadow.cljs.devtools.api/repl :app)
#2022-01-2018:06dpsuttonand what is the :target for :app in your shadow-cljs.edn?#2022-01-2018:07sbYes, other libs loaded .. like jsonwebtoken npm lib#2022-01-2018:07sbSorry true, target browser#2022-01-2018:08dpsuttonthen you cannot use the fs node module. It is only available in node and you are running in a browser#2022-01-2018:09sbOk, thanks the info! I don’t know that#2022-01-2018:09sbI read now the documentation#2022-01-2117:11Kurt HarrigerHi I’m trying to run https://github.com/ahonn/shadow-electron-starter. If I clone repo and use npm install with its current package-lock.json file using shadow-cljs ^2.8.110 it works. If I then run npm install shadow-cljs (updating to version ^2.16.12) run npm run dev and electron . it fails to start with
SHADOW import error /Users/kurt.harriger/projects/Logseq-Things-3-Plugin/shadow-electron-starter/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
App threw an error during load
/Users/kurt.harriger/projects/Logseq-Things-3-Plugin/shadow-electron-starter/node_modules/ws/lib/websocket.js:414
      ...options
      ^^^
SyntaxError: Unexpected token ...
It appears that the ws module in previous version was 3.3.3 and is now updated to 7.5.6 and this new version seems to use es6 spread syntax that the old version did not. Oddly if I run npm run build and then electron . it still works but seems dev build doesn’t work. Any ideas? I guess I could fork ws and add a bunder step to ensure it exports es5 but I’m confused why upgrading shadow-cljs would pull in new ws version if shadow-cljs didn’t support it and why a release bulid works but dev build does not? maybe there is an option that needs added to the config?
#2022-01-2117:14thhellerdid you also update electron? I mean the current version there seams to be 16.0.7? in the repo is 8 so probably ancient history by now?#2022-01-2117:17thhellermaybe you also have a really old node version? this isn't an error from anything shadow-cljs is doing. the error is outside of the code it controls#2022-01-2117:18Kurt HarrigerInitially i tried using yarn and things blew up because it downloaded newer versions not using package.lock and tried to revert and use npm then upgrade 1 at a time to isolate I suppose maybe it only upgraded the minor version or soemthing. Let me give it another try#2022-01-2117:20thhelleryeah lock files in demo repos are problematic if the demo isn't constantly maintained. can't assume that something that was written 4 years ago still works#2022-01-2117:21thhellerFWIW you don't see the error in the release build since the release build probably doesn't use the ws package. that is only used for the hot-reload/repl websocket#2022-01-2117:23Kurt Harrigeroh that makes sense why it only shows up in dev build. But yeah issue still shows up after upgrading to electron 16#2022-01-2117:24thhellernode -v?#2022-01-2117:24Kurt Harrigerupdated all the deps:
"dependencies": {
    "electron": "^16.0.7",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "shadow-cljs": "^2.16.12"
  }
node version v16.13.0
#2022-01-2117:25Kurt Harrigerelectron -v v1.4.13#2022-01-2117:26Kurt Harrigerhmm npm WARN deprecated /cdn-cgi/l/email-protection: electron-prebuilt has been renamed to electron. For more details, see https://electron.atom.io/blog/2016/08/16/npm-install-electron#2022-01-2117:26Kurt Harrigerthere we go that was the issue#2022-01-2117:26thhelleruhm where did that version come from? v1.4.13#2022-01-2117:27Kurt Harrigerfollowed the instructions to npm install -g electron-prebuilt but appears thats where the problem was#2022-01-2117:27thhellerlooks like you have a really really old global install?#2022-01-2117:27thhellerah#2022-01-2117:27Kurt HarrigerI’ll send him a PR to update the example#2022-01-2117:27Kurt Harrigerthanks!#2022-01-2117:28thheller
npm install electron-prebuilt -g
npm install shadow-cljs -g
#2022-01-2117:28thhellerjust skip these two completely and just use npx electron and npx shadow-cljs. that'll use the version installed in the project and not some global#2022-01-2117:29Kurt Harrigeryeah thats sounds best. thanks#2022-01-2211:20davidstIs there a way to get a REPL for a build with target :esm and runtime :node? The build configuration:
{:target           :esm
   :js-options       {:js-provider :import}
   :runtime          :node
   :output-dir       "out/esm"
   :modules
   {:script {:entries [my.script.core]
             :exports {init my.script.core/init}}}}
The output produced by npx shadow-cljs watch ... for this build seems to not connect to the server and node out/esm/script.js exists immediately. I have tried to make it connect to the server by requiring the namespace shadow.cljs.devtools.client.node in my.script.core . But then running the output with node ... reports the following error:
var socket = (new shadow.esm.esm_import$ws(ws_url,({"rejectUnauthorized": false})));
              ^

TypeError: shadow.esm.esm_import$ws is not a constructor
    at shadow$cljs$devtools$client$node$start (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.node.js:122:15)
    at Object.attempt_connect_BANG_ (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
    at file:///.../out/esm/cljs-runtime/shadow.cljs.devtools.client.node.js:431:36
#2022-01-2211:31davidstI also tried to use node-script as a target but that doesn't seem to be an option with some npm packages that are ESM only (e.g., the latest version of chalk).#2022-01-2215:06thheller@davidst I didn't try to get the node repl running with :esm yet. you can try setting :runtime :custom :devtools {:client-ns some.ns} where some.ns is just a copy of https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs with the ["ws" :as ws] changed to ["ws$default" :as ws]. maybe thats enough?#2022-01-2215:06thhellerI suspect there might be more changes necessary though#2022-01-2223:28davidstThank you. Following your suggestion I was able to connect to the repl. Unfortunately, when evaluating anything, I was getting errors about undefined SHADOW_IMPORTED and SHADOW_IMPORT. It looks like these are defined in node_bootstrap.txt for node targets. It seems shadow/boot/esm.js is supposed to replace (some of) that. I have tried to fix these errors. It seems to work alright so far but it is clearly a nasty hack:
;; these implementations replace the first three functions in shadow.cljs.devtools.client.node

(defn node-eval [{:keys [js source-map-json] :as msg}]
  (let [result (js* "(0,eval)(~{});" js)]
    result))

(defn is-loaded? [src]
  (true? (js/SHADOW_ENV.setLoaded src)))

(defn closure-import [src]
  {:pre [(string? src)]}
  (js/console.log src)
  (when-not (= src "goog.base.js")
    ;; goog base doesn't work with this kind of import?
    (js/globalThis.shadow_esm_import (str "./cljs-runtime/" src)))
  (js/SHADOW_ENV.setLoaded src))

;; this interface implementation replaces the current one for the type cljs-shared/Runtime
api/IEvalJS
(-js-eval [this code]
  (js* "(0,eval)(~{});" code))
#2022-01-2306:41thhellerthis probably needs many more adjustments. the regular node impl assumes it can do sync imports but the shadow_esm_import is async so all of the code needs to be adjusted to not assume sync#2022-01-2306:54thhellermight need to go with loading the file from disk using fs/readFileSync and then eval'ing#2022-01-2306:57thhellerhaven't spend much time on node with esm so not sure what kind of restrictions exist. might even require modifying the source get get rid of import statements. I opened https://github.com/thheller/shadow-cljs/issues/979#2022-01-2306:57thhellernot sure when I can get to it though. pretty busy currently.#2022-01-2223:38davidstThe hack to prepend "./cljs-runtime" to src seems especially fragile. Is there a better way to do that?#2022-01-2223:48Will NewellComplete newbie using the default shadow-cljs setup in luminus. App loads fine but test throws a fit. Is this a 'need to be using :broswer-test instead of :node-test' type issue? I'm struggling to figure out where to even look to troubleshoot what wrong beyond an import expects the browser 'window' object to exist. Its one test file for a re-frame subscription if that helps at all
ReferenceError: window is not defined
    at [path]/.shadow-cljs/builds/test/dev/out/cljs-runtime/accountant/core.cljs:21:35
    at [path]/.shadow-cljs/builds/test/dev/out/cljs-runtime/accountant.core.js:16:3
    at global.SHADOW_IMPORT ([path]/target/test/test.js:64:44)
    at [path]/target/test/test.js:1701:1
    at Object.<anonymous> ([path]/target/test/test.js:1781:3)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
===============================================
#2022-01-2301:23Appleperhaps more of an interop issue. window or js/window?#2022-01-2302:40Will NewellI'm not calling window anywhere but I suppose one of the libraries I'm using must be. I swapped to :browser and am at least past ^ error message. I was hoping to avoid having to set up Karma and a browser-driven test suite for now by just testing my re-frame logic with :node-test but its been more of a hassle to troubleshoot than it is to just launch Karma. Anyways, thanks for taking a look!#2022-01-2306:33thhellerhttps://github.com/venantius/accountant/blob/48ad34296724bacba710fd3a25a968cc9bd3a2df/src/accountant/core.cljs#L21#2022-01-2306:34thhellerthis library is using js/window. so it just isn't compatible with anything that doesn't have that. from the looks of it there are many other things that expect a full browser#2022-01-2306:35thhellerif you can move the require for that lib to some other place yuo might be able to run it in node. can't say without seeing code.#2022-01-2307:48Will Newellahhh thanks thheller, I mistakenly assumed 'accountant' was some shadow-cljs interal, but its an internal dependency of my routing lib. Sorry haha I'm still struggling with the normal clj stacktraces so I kinda just assumed this was another opaque one 😅. I'll deps :tree next time#2022-01-2323:57steveb8nQ: is it possible to pause the shadow :cljs-watch without disconnecting hot-reloading clients? @thheller#2022-01-2323:58steveb8nI have a code generator which touches a lot of source files and I want to pause the watch during generation.#2022-01-2323:58steveb8nif I use start/stop the the clients lose hot reload#2022-01-2400:10steveb8nfound a solution. shadow/watch-set-autobuild! works. unless there is a better option?#2022-01-2406:20thhellerwhat better option would there be? doesn't this do exactly what you want?#2022-01-2411:20steveb8nCorrect. This does what I need. Was just checking I'm using it correctly. Thanks.#2022-01-2407:33superstructorAnyone familiar with these kind of compilation errors in the three.js ecosystem ? Simply just installing and trying to require @react-three/fibre or @react-three/drei is enough to get this error.
Closure compilation failed with 2 errors
--- node_modules/three-stdlib/index.cjs.js:2
Illegal variable reference before declaration: i
--- node_modules/three-stdlib/index.cjs.js:2
Illegal variable reference before declaration: t
#2022-01-2417:02thhelleryeah I'm not sure if this is a bug in the closure compiler or an actual bug in the lib#2022-01-2417:03thhellerthe closure compiler checks might be too strict but I really can't say#2022-01-2417:04thhellermight be this one https://github.com/google/closure-compiler/issues/2723#2022-02-0111:02bbss@U0G75S29H I ran into it, currently running versions "@react-three/drei": "^7.5.0", "@react-three/fiber": "6.1.1", And have in my shadow-cljs.edn module:
:js-options {                        :resolve {"three-stdlib" {:target :file :file "node_modules/three-stdlib/index.js"}
                                  "@react-three/drei" {:target :file :file "node_modules/@react-three/drei/index.js"}
                                  "@react-three/fiber" {:target :file :file "node_modules/@react-three/fiber/dist/react-three-fiber.esm.js"}}}
#2022-01-2411:53achikin@thheller I just found out that there is a new :preprocess option for foreign libs in clojurescript compiler. Are there any plans to leverage that for npm libs in shadow-cljs?#2022-01-2417:01thhellershadow-cljs doesn't support foreign-libs at all, so no preprocess either. what problem are you trying to solve?#2022-01-2511:53achikinStill trying to get jsx/css preprocessors without webpack etc.#2022-01-2516:40thhellera JSX example setup is described here https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2022-01-2516:40thhellerfor css just use postcss or something#2022-01-2516:41thhellerthere is an example setup using tailwind here https://github.com/jacekschae/shadow-cljs-tailwindcss#2022-01-2516:41thhellerI use a very similar setup#2022-01-2513:13ribeloI have a problem to make electron work with lmdb#2022-01-2513:14ribeloI suspect it's not a problem with shadow-cljs, but maybe...#2022-01-2513:14ribelo#2022-01-2513:15ribelotheoretically, according to the creator, it should work#2022-01-2513:15ribelo#2022-01-2516:42thhellerlooks like you might be trying to run this in the renderer process when it is only available in the main node part?#2022-01-2516:42thhellerits been years since I looked at electron so can't comment much#2022-01-2519:05ribelousing require in electron is always an ordeal#2022-01-2519:06ribeloYou are right the problem is with the renderer process, because the require in main main process worsk, but theoretically, thanks to nodeIntegratrion it should work also on the renderer process#2022-01-2519:06ribelobut thanks for your suggestions, I know where and what to look for#2022-01-2615:25andrea.crottiwe use ag-grid, and specifically this function https://github.com/ag-grid/ag-grid/blob/f1504fe5adb0a91f4658658bdd6aa591ed2f1864/community-modules/core/src/ts/utils/dom.ts#L239 which recently moved from one namespace to the other#2022-01-2615:26andrea.crottiI tried all the possible ways I could think of to require it but I can't seem to crack the enigma, any idea? The function itself is also available directly in the node_modules/ag-grid-enterprise/ag-grid.js for example, but either that or trying to use the full path doesn't work#2022-01-2617:17thheller@andrea.crotti do you have an example of JS using this? regarding locating exported functions never look at the source on github. that is the raw source and usually has very little to do with the final bundled result.#2022-01-2619:39andrea.crottiYeah I figured that it's pointless to look at the source#2022-01-2619:39andrea.crottiI'll see if I find an example of js using it#2022-01-2711:13thhellerhow did you use it before? I mean it should be possible to reconstruct it based on where it moved from and what it was called before#2022-01-2813:33andrea.crottiin the end I just rewrote that function in cljs#2022-01-2813:33andrea.crottisince it was literally 3 lines of code#2022-01-2813:33andrea.crottiso it doesn't break again next time ag-grid move it again#2022-01-2622:23Ben HammondI have two browsers loading my shadow-cljs managed webpage I am using npx shadow-cljs cljs-repl foo` to connect to one of them. Is there an easy way to swith to a repl on the other browser?#2022-01-2706:56thheller@ben.hammond shadow-cljs clj-repl and then (shadow/repl :foo {:runtime-id 123}) where the runtime id is either listed here http://localhost:9630/runtimes or in the browser console on start shadow-cljs: #3 ready!#2022-01-2708:59thheller:cljs/quit drops you back down to the clj repl. so you can switch between the runtimes if needed#2022-01-2717:27Nom Nom MousseWhat might the error messages above indicate? I've tried googling.#2022-01-2717:28Nom Nom MousseEasier to read.#2022-01-2717:29Nom Nom MousseThese errors happened after I did git clean -fdx and reinstalled d3 through npm.#2022-01-2717:30thhellerfrom your messages in #clojurescript I assume you figured it out?#2022-01-2717:37Nom Nom MousseI was able to lein shadow watch app but I still get errors in the console. Anyways, if this is unrelated to shadow-cljs I'll try to google more myself 🙂#2022-01-2717:38thhellerthe regenerator thing is a npm problem. you basically need to (:require ["regenerator-runtime/runtime"]) somewhere before you require the npm lib causing the problem#2022-01-2717:39thhelleror upgrade shadow-cljs in case you are on a really old version#2022-01-2717:51Nom Nom MousseI guess it was really old 😄#2022-01-2717:52Nom Nom MousseThanks for your help#2022-01-2717:40Nom Nom MousseMy version 2.12.1 seems to be from April last year. I'll try upgrading.#2022-01-2717:50neilyioI’m trying to run shadow-cljs in embedded mode from a build.clj. Here’s what I’m running, I arrived at this by digging around the https://shadow-cljs.github.io/docs/UsersGuide.html#embedded of the docs, as well as https://github.com/thheller/shadow-cljs/issues/490.
(shadow.cljs.devtools.server/start!)

(shadow.cljs.devtools.api/compile*
 {:target     :browser
  :output-dir "public/js"
  :output-to  "public/js/main.js"
  :asset-path "js"
  :main       "hello-world.core"}
 {})
…Running clj -M build.clj, I get a error:
Jan 27, 2022 9:45:35 AM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
Jan 27, 2022 9:45:35 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.8.0.Final
Jan 27, 2022 9:45:35 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.0.Final
Jan 27, 2022 9:45:35 AM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.1.0.Final
shadow-cljs - server version: 2.16.12 running at 
shadow-cljs - nREPL server started on port 54818
[null] Compiling ...
Syntax error (AssertionError) compiling at (build.clj:28:1).
Assert failed: (keyword? build-id)
I’d really like to be able to pass the build configuration right in my build.clj. Does anyone see what I’m doing wrong?
#2022-01-2717:51thheller:build-id :app or something needs to be in that map#2022-01-2717:52thhellernote that this is an invalid build config for :target :browser. :main does not apply there.#2022-01-2717:54thhelleryou maybe want to configure your logging so that the undertow/xnio stuff goes away#2022-01-2717:55neilyioAgreed that’s a little too verbose#2022-01-2717:55neilyioI switched the call to this:
(shadow.cljs.devtools.api/compile*
 {:build-id   :app
  :target     :browser
  :output-dir "public/js"
  :output-to  "public/js/main.js"
  :asset-path "js"}
 {})
#2022-01-2717:55thhellerstill invalid. missing :modules#2022-01-2717:55neilyioAha#2022-01-2717:56thheller:output-to also does nothing. :modules {:main {:entries [hello-world.core]}} will create a main.js in :output-dir#2022-01-2717:57thhellerI strongly recommend keeping the build config in shadow-cljs.edn though. you lose a bunch of features if you don't#2022-01-2717:58neilyioThanks for working through this with me, it’s compiling now! I’m noticing that it outputs a main.js in my :ouput-dir. Is that default/fixed behavior?#2022-01-2717:58neilyio(As I’ve omiitted the :output-to, as you mentioned)#2022-01-2717:58thhelleryou should probably refer to the docs for questions as that https://shadow-cljs.github.io/docs/UsersGuide.html#2022-01-2717:58thhellerthe :main module produces main.js in :output-dir#2022-01-2717:59neilyioYep I see that now#2022-01-2717:59thhellerrename it and you get a different file. all coming from your config, no default 😛#2022-01-2717:59neilyioThat’s great, really appreciate your quick response @thheller, as usual.#2022-01-2718:00thhellerwhy compile though? watch and release are the common ones, compile is kinda rare?#2022-01-2718:01neilyioI’m kind of just messing around now, compile caught my eye first. What’s the different from release?#2022-01-2718:02thhellerrelease creates a optimized release build. compile creates an unoptimized development build, same as watch just without the watch parts (no hot-reload, REPL, etc)#2022-01-2718:03neilyioAh okay, that was my guess. I’m toying around with my own REPL/reload setup for some custom pREPL tooling in Emacs. So I’m looking for a development build, but starting my own REPL server etc.#2022-01-2718:04neilyioI’ll pass it along if I get something cool!#2022-01-2718:04thhellershadow-cljs has built in prepl support in case you didn't know#2022-01-2718:04thhellerprepl sucks so I wouldn't recommend it though 😉#2022-01-2718:05thhellerbut for any kind of repl tooling regardless you must use watch. compile is not designed for it and will not work.#2022-01-2718:05neilyioThis is such great info, thank you!#2022-01-2718:10thheller"will not work" is not exactly right. with your own REPL server it might work, it'll just be rather slow. compile has to load all caches from disk with each compile#2022-01-2718:10thhellerwatch just loads it once and keeps it in memory making incremental compiles rather fast#2022-01-2718:28neilyioHmm yeah I’ve got a error when I connect to my REPL and try to evaluate:
:type java.lang.AssertionError,
:message \"Assert failed: (set? ns-roots)\", :at [shadow.build.cljs_hacks$shadow_find_ns_starts_with invokeStatic \"cljs_hacks.cljc\" 645]}],
#2022-01-2718:30neilyioHere’s my whole setup if you’re curious. I know this is unconventional and all this functionality is in shadow-cljs… I’m just toying around and trying to replace the functionality with other standard Clojure tools for learning purposes.
(clojure.core.server/start-server
 {:accept        'cljs.core.server/io-prepl
  :address       "127.0.0.1"
  :port          6776
  :name          "build"
  :args          [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
  :server-daemon false})

(org.httpkit.server/run-server
 (compojure.core/routes
  (compojure.route/files "/" {:root "public"}))
 {:port 8000})

(cljs.build.api/build ;; or watch with path
 {:output-dir   "public/js"
  :output-to    "public/js/main.js"
  :asset-path   "js"
  :main         "hello-world.core"})

(println "Now connect through inf-clojure to port 6776.")
(println "Then, refresh the web page.")
#2022-01-2718:30thhelleruhm you are trying to use weasel with shadow-cljs? that'll not work#2022-01-2718:31neilyioYeah, unconventional, like I said! I was just trying to replicate a really minimal ClojureScript compilation setup. This was working well with the code below:
(clojure.core.server/start-server
 {:accept        'cljs.core.server/io-prepl
  :address       "127.0.0.1"
  :port          6776
  :name          "build"
  :args          [:repl-env (weasel.repl.websocket/repl-env :ip "0.0.0.0" :port 9001)]
  :server-daemon false})

(org.httpkit.server/run-server
 (compojure.core/routes
  (compojure.route/files "/" {:root "public"}))
 {:port 8000})

(cljs.build.api/build ;; or watch with path
 {:output-dir   "public/js"
  :output-to    "public/js/main.js"
  :asset-path   "js"
  :main         "hello-world.core"})
#2022-01-2718:32thhellerwhat is your intended end goal here?#2022-01-2718:32neilyio…but I can’t for the life of me properly get cljs.build.api/build to find my npm dependencies. shadow-cljs is so, so good at that, I was hoping there’d be an easy way to just “swap out” those compile calls.#2022-01-2718:32thhelleryou can just set :prepl {12345 :app} and that will give a a prepl on port 12345 for build :app (all in shadow-cljs.edn of course)#2022-01-2718:34neilyioYeah, that’s a great feature. I’m really just experimenting, but I would say my goal is to see how I can leverage popular Clojure tools (httpkit, clojure.core.server, cljs.build.api) to “mix and match” the behavior of my development experience.#2022-01-2718:35thhellerwell then shadow-cljs is probably not the right choice for you. it is a build tool already, not a toolkit to build a build tool.#2022-01-2718:36thhellerit replaces basically all of the default build tooling, so anything trying to use that won't work either#2022-01-2718:49neilyioYeah I understand, I appreciate you being straightforward with me. I really admire the experience you’ve built with shadow-cljs, and I’m sure I’ll end up using it as you’ve intended for a real project!#2022-01-2718:50neilyioIf only :npm-deps on the ClojureScript compiler would work properly…#2022-01-2718:50thhellerif you explain what you are trying to do I can maybe provide some pointers. shadow-cljs is pretty flexible, so it should be possible to just disable the parts you don't want to use but keep the rest#2022-01-2718:51thhellerbut that being said it is built to do exactly what it does. everything else is asking for trouble 😉#2022-01-2901:24Justin RocheIs there a way using a shadow-cljs build to get dependencies output as .cljs? I have a need for getting the original .cljs files but everything seems bundled in the app.js. My own project files are easy enough to find, but dependencies seem to live in the .jar files on the classpath.#2022-01-2907:38tianshuI found it very common to run into issues when start a development REPL after a release build, or bulid a browser target after a node target. Deleting .shadow-cljs always solve the problem. Should the caches from different build be separated?#2022-01-2908:05thheller@doglooksgood I have never deleted .shadow-cljs and I don't hear much of others doing that. what issues are you running into? deleting the caches should absolutely not be happening and caches are already separated, so they cannot affect each other.#2022-01-2908:10thheller@jproche5 what do you need those files for? yes, dependencies live in .jar files. there is no direct way of having shadow-cljs output them for you. you can always get them yourself at any time if you need to#2022-01-2908:12tianshu@thheller Errors in build, like $arr is not definded, $cljs is not defined.#2022-01-2908:13thhellerplease do not shorten errors. stacktraces are extremely important.#2022-01-2908:13thhellernever seen those errors and no immediate idea what would cause them#2022-01-2908:13tianshuLet me try reproduce#2022-01-2908:14thhellerare you outputting into different directories? each build should live in its own directory (eg. :output-dir). outputting into the same directory may cause files to be overridden and as such cause issues#2022-01-2908:20tianshuYes, I have different output directories, like resources/public/js and resources/public/js/workspaces.#2022-01-2908:21tianshuHave I stop REPL when doing a release building?#2022-01-2908:24thhellerwhen the release build is outputting to the same directory yes, they will otherwise overwrite the watch files and watch may overwrite the release files#2022-01-2908:25thhelleryou can output to separate dirs via https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2022-01-2908:25thhellerreleasing a separate build while another build watch is running doesn't matter#2022-01-2908:25thhelleronly shadow-cljs watch app and then shadow-cljs release app may interfere with each other#2022-01-2908:26thhellerbut none of this would break the caches either so deleting .shadow-cljs would not do anything other than cause a rebuild#2022-01-2908:27tianshuI do not know how to reproduce yet, I'll bring the stacktrace when I ran into the issue again. Maybe it's caused by releasing and watching at the same time.#2022-01-2908:28tianshuThanks for explanation in details.#2022-01-2909:25Justin Roche@thheller I need them for displaying stack traces in https://sentry.io. cljs isn’t well supported in it’s source-map upload system. If I turn source maps on, and turn off any source map includes, and the source code is in a separate file, it can show them correctly. But to do that for libraries I have to hard code a path to .m2, and then extract from the .jar file, and it’s a pain.#2022-01-2909:27thhelleruhm the source maps should contain all you need? they do include the sources if you create them for a release build?#2022-01-2909:28thhellerwhy not include the sources in the source map itself?#2022-01-2909:29thhellerI don't know what special handling sentry needs but it works fine in the browser so I'd assume it is fine in sentry too?#2022-01-2909:29Justin Rocheone would think so, but sentry won’t match them properly#2022-01-2909:29thhellerwhat does that mean?#2022-01-2909:30Justin Rocheit just shows the minified js in the stack trace#2022-01-2909:31thhellerand you uploaded the source maps properly?#2022-01-2909:32Justin RocheYeah I think so#2022-01-2909:32thhellerI have never used sentry so I really don't know much but you can easily look at the generated source maps#2022-01-2909:33thhellerit does include all sources and sourcesContent so it should be all fine assuming all the paths map and such#2022-01-2909:34thhelleralso the paths shadow-cljs includes in the source map never refer to any file in .m2, so I don't know where that info would come from#2022-01-2909:34thhellerwell unless you explicitely set the :source-map-use-fs-paths true, which you definitely should not be setting for browser builds#2022-01-2909:35thhellerpaths are only refered to by their classpath resource name, never the actual file of the local disk#2022-01-2909:42Justin RocheI will keep at it. with sourcesContent it works in the browser fine.#2022-01-2913:00barrellHey #shadow-cljs! I’ve set up a custom build script and added a build to my module. I’d like to see all the files available on the classpath (trying to find any .css files). Is there a way to access this information from a build hook - either from the build state or the general clojure environment? Or do I need to get the src dirs and read them myself? EDIT I sole and adopted a function from shadow.build.classpath which seems to do exactly what I want. Let me know if there is a better way out there thought!
(defn classpath-files
  "searches classpath source source files"
  [build]
  (let [cp (:classpath build)]
    (for [^File cp-entry (classpath/get-classpath-entries cp)
          :when (and (.isDirectory cp-entry)
                     (not (classpath/is-gitlib-file? cp-entry)))
          :let [root-path (.toPath cp-entry)]
          ^File file (file-seq cp-entry)
          :when (not (.isHidden file)
          :let [file-path (.toPath file)
                resource-name (-> (.relativize root-path file-path)
                                  (.toString)
                                  (rc/normalize-name))]
          :when (not (classpath/should-ignore-resource? cp resource-name))]
      resource-name)))
#2022-01-2918:58Timofey SitnikovHello all! I am running https://github.com/fulcrologic/fulcro-template and when reload the web application, it takes a long time for the page to reload. Specifically, it looks like the remote-relay?.... What can I do to make it quicker? Here is my network:#2022-01-2919:00thhellerremote-relay a websocket. it stays open. it does not affect the speed of your page load?#2022-01-2919:01thhellerwhat does "reload the web application" mean?#2022-01-2919:03Timofey SitnikovWhen I press this button:#2022-01-2919:03thhelleryou are loading 13.9mb of JS so is that maybe the cause of the slow speeds? what kind of computer do you use?#2022-01-2919:04Timofey Sitnikov2019 Macbook Pro#2022-01-2919:04thhellerhmm that should definitely handle that fine. assuming it has memory left and isn't swapping?#2022-01-2919:06thhellercould also be browser extensions slowing everything down. can't really say, this has very little to do with shadow-cljs#2022-01-2919:07Timofey Sitnikov#2022-01-2919:08Timofey Sitnikov@thheller, OK, I will keep digging.#2022-01-2919:11thhellercould also be the JS doing a lot of stuff on load that everything else has to wait for#2022-01-2923:34Rodrigo ManticaCan I customize how shadow resolves javascript files to support the module require syntax path/to/dir and have it load the index.js file at that path? In other words, I’m trying to override what happens when shadow detects a directory path? It currently fails and throws FileNotFoundException with a note that it’s a directory. I’m trying to compile an existing js project, but webpack handles that situation by default so I need a way to replicate that behavior#2022-01-3007:02thhellerif you are talking about https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js then no, there is no way to make that happen#2022-01-3007:02thhellerfor regular npm node_modules requires that is already the default and should be fine#2022-01-3004:25Christopher Genovese@thheller I just wanted to circle back on that weird problem I was having a couple weeks back with the odd changes in repl state because after quite a bit of detective work I've tracked down the cause. It turns out that, without my being aware of it, the clj-refactor bindings in emacs were inserting require cljs libspecs in the ns form whenever I hit / with an "new" namespace. Unfortunately, it put those in the :require-macros section rather than the :require section as it should (presumably because it was first). There were a couple of these, and when I removed them the problem went away. When I put them back, the problem returned. I don't understand why that would produce the problems I saw, but the causality seems pretty clear. Thanks again for all your help; I very much appreciate it!#2022-01-3011:10barrellI’m starting my app by launching a repl clj -M:shadow-cljs clj-repl then running (shadow/watch :app). I like having that repl there. What is the best way to go about adding functions to this namespace? Can I somehow provide my own namespace and just require the functions that shadow.user does and add my own?#2022-01-3011:23barrellI’ve tried adding :nrepl {:init-ns phrasing.user} to my shadow-cljs.edn and tried adding {:repl-init-ns phrasing.user} to :builds :app :devtools#2022-01-3011:28barrellAlso tried :repl {:init-ns phrasing.user} as well#2022-01-3012:16thhellerthat is not configurable but you are free to just use clj directly#2022-01-3012:17thhelleror just (require 'phrasing.user) (in-ns 'phrasing.user)#2022-01-3012:17thhellermost people use nrepl though which does support this#2022-01-3013:09barrellI tried that with the following clojure tools alias:
:nrepl
  {:extra-deps {nrepl/nrepl {:mvn/version "0.9.0"}}
   :main-opts ["-m" "nrepl.cmdline"
               "--connect"]}}}
which loads in the user namesapce. I tried lein repl :connect and that seems to have worked! So thank you!! Do you happen to know why the clojure.tools version isn’t working?
#2022-01-3013:13thhellerit would work just fine, it just isn't supported because nobody has asked for this before#2022-01-3013:13thhellermost people use an editor connected REPL and most editors use nrepl for this, so that is the default that has the most features#2022-01-3013:22barrellahhh when it connects it prints user> as the prompt. After the first command it prints my designated namespace#2022-01-3013:22barrellthat only costed me 3 hours 😂#2022-01-3013:22barrellthanks so much for the help!#2022-01-3108:39barrellI’m trying to add entries to a module from a build hook (currently :compile-prepare). I update [shadow.build/config :modules :main :entries] and add the clojure namespaces there. I can confirm they are both on my build path and in the build config. However, when I make changes to these files, shadow-cljs does not recompile. 1. Is there something I need to do to add them to the watch? 2. The eventual goal is to set up different modules, but I was going for MVP by adding them to entries. Would it be possible to dynamically load different modules from a build hook? For context, I’m trying to set up something similar to next.js with directory based routing. So as I add more files, I read the classpath, build all the route into, then add files to the build. Modules would be great for code-splitting in the future but not needed for now#2022-01-3116:39thhellersounds like what you are trying to do would require a custom :target. build hooks are definitely not meant to do any additional compilation and are not setup to do so#2022-02-0108:23barrellInteresting. I guess I could spit to the shadow-cljs.edn file and run the watch command with nodemon - sounds like that might be the fastest solution? In the meantime do you have any info on writing a custom :target? I assume you mean a build would have :target :custom-browser ?#2022-02-0108:33thhellerno info other than the implementation of the default targets https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2022-02-0108:34thhellerbut since you picked :browser you also picked the most complex one 😛#2022-02-0108:34thheller:node-script is much simpler#2022-02-0109:02barrellcopies…. pastes 😂#2022-02-0109:03barrellI will go through this in detail later this week but do you have something in mind you can point me towards? function or variable name that dictates what is rebuild for example 😄#2022-02-0109:04thhellertargets don't control rebuilds#2022-02-0109:04thhellerbasically this function is called over and over again#2022-02-0109:04thhellerhttps://github.com/thheller/shadow-cljs/blob/8b7f3964e732bc13a9981ba390908dd90f70f2e0/src/main/shadow/build/targets/node_script.clj#L67#2022-02-0109:05thhellerwith a different :shadow.build/stage where the target impl can decide what it needs to do#2022-02-0109:06thhellerfor example :node-library generates a source and adds it to the build https://github.com/thheller/shadow-cljs/blob/8b7f3964e732bc13a9981ba390908dd90f70f2e0/src/main/shadow/build/targets/node_library.clj#L88-L103#2022-02-0109:06thhellerdefinitely very advanced stuff that is not documented anywhere#2022-02-0109:07thhelleryou could write a target that just delegates everything to the browser impl#2022-02-0109:08thhellerbut lets the user not write :modules at all and instead generate it#2022-02-0109:08thhellerI do not recommend doing so but it is possible#2022-02-0109:09barrell> targets don’t control rebuilds I’m confused - I just want to inject some namespaces into the entries and rebuild the module when those files change. That sounds like a custom target would be best?#2022-02-0109:14barrellI think for my purposes it will just make better sense to write directly to the shadow-cljs.edn file and rebuild when that changes. It will only need to restart the process when a new file is added. If I need something more integrated it’s good to know where this is, thanks Quick question though - is it possible to specify a path to a shadow-cljs.edn file ? Or does it have to be in the dir that the command is run from#2022-02-0109:22thhellermust be at the root of the project#2022-02-0109:24thhellersorry, not enough time to walk through a basic custom target right now#2022-02-0109:24thhellerit sounds to me like you want to generate a .cljs file instead?#2022-02-0109:24thhellerie. you create a build {:target :browser :modules {:main {:init-fn }}} and then you generate either or some file it includes#2022-02-0109:24thhellerand just put it on the classpath#2022-02-0109:25thhellerthat way the build automatically retriggers if you regenerate the file or make and other changes#2022-02-0109:25thhellerand you don't need to adjust the build config in any way#2022-02-0109:25thhellerimho maybe you just need a macro? never look at how js tools do something and replicate that#2022-02-0109:26thhellerimho you can do so much more in better ways with just macros sometimes#2022-02-0109:27thhellerI'm not sure I would actually recommend doing this but as an experiment for the shadow-cljs UI I did this#2022-02-0109:27thhellercreate a regular defn and put some metadata on it#2022-02-0109:27thhellerhttps://github.com/thheller/shadow-cljs/blob/1259a026b0c9a310fd6b78d991b68afea9ba0e3f/src/main/shadow/cljs/ui/db/inspect.cljs#L119#2022-02-0109:27thhellerthen have a separate macro that collects all of the functions with such metadata and generate some code arround it#2022-02-0109:28thhellersounds maybe like something you are trying to do?#2022-02-0109:29thhellerthat would be the macro finding all the defn's with the metadata#2022-02-0109:29thhellerhttps://github.com/thheller/shadow-experiments/blob/master/src/main/shadow/experiments/grove/events.clj#L60-L69#2022-02-0109:29thhellerimho nothing should ever be done based on a filename or its location#2022-02-0109:30thhellermetadata allows so much more control and is so much more flexible#2022-02-0109:30thhellerthe ns itself could also have metadata if needed#2022-02-0109:30thhellerall of it is accessible in a macro#2022-02-0109:31thhellerfrom the build side it is just a regular :browser build, nothing is ever generated elsewhere#2022-02-0109:31thhellerthe macro is a little more complicated since I wanted it to be aware of :modules but it doesn't need to be#2022-02-0109:42barrellI have cljs files on the classpath, they are not retriggering a build. Presumably because they are not part of the module. Metadata or filepath work fine for me, just need to get the code in those cljs files into the build without an explicit require#2022-02-0109:45thhellerwell it needs to be part of the build. then it'll trigger a rebuild. it doesn't need to be directly part of the build config#2022-02-0109:45thhelleryou need an explicit require. that is sort of the point of require 😛#2022-02-0109:46thhellerie. only include what you actually need and nothing else#2022-02-0109:46thhellerif just everything was included because it was there that would create a big mess#2022-02-0109:47thhellerback to the macro example I still have my main ns require all the namespaces that have that metadata#2022-02-0109:47thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#L16-L19#2022-02-0109:47barrellI guess I should say user-written require 😅 maybe the best way would be to just write to a manifest.cljs with a bunch of require statements#2022-02-0109:47thhellerI think this is totally fine and I wouldn't want it any other way#2022-02-0109:47thhellerits just a require, it is easily added or removed or renamed#2022-02-0109:48thhellersomething like [shadow.cljs.ui.db.*] would make me feel extremely dirty 😛#2022-02-0109:49thhellerin your main app (:require [my.app.routes]) and then you generate (ns my.app.routes (:require [my.app.route-a] [my.app.route-b])) with some tool?#2022-02-0109:49barrellthis is a helper package to teach my friends how to code (starting with clojurescript). The time to first render is quite important for me - goal is to have a command to install then write a file and see it on the screen. Plenty of time to get to requires and metadata later 😄#2022-02-0109:50barrell> in your main app `(:require [my.app.routes])` and then you generate `(ns my.app.routes (:require [my.app.route-a] [my.app.route-b]))` with some tool? this seems like the best way to do it!#2022-02-0109:50barrellin the future if I wanted to support code splitting, could I add new modules to the build with a build hook, or would I need to adjust the shadow-cljs.edn file and restart the server?#2022-02-0109:50thhellerI'd argue that generation stuff is more complicated than writing it by hand#2022-02-0109:50thhellerbut YMMV 😉#2022-02-0109:51thhellermodifications to the build config do not require restarts, they are just picked up and recompiled#2022-02-0109:51barrellI don’t mind complicated, that’s why I’m trying to take on the brunt of it 🙂#2022-02-0109:51thhellerbut I also wouldn't recommend modifying shadow-cljs.edn with tools#2022-02-0109:51thhellerno I'm saying that it makes things more complicated for everyone. the beginners too#2022-02-0109:52barrellso I could see a file exists, add a module (with entries) to the build config in the pre-compile stage, and it would generate that new file?#2022-02-0109:52thheller"you create a namespace and then require it". simple and straightforward#2022-02-0109:52thheller"you create a file and then you run this other tool and wait for this other tool to pick it up" is that not simple in my view 🙂#2022-02-0109:54barrellI’ve got ideas 😎 I appreciate the feedback but I’m building out a very specific curriculum. I know it’s not the way of the clojure world but I think it has value#2022-02-0109:56barrell
npm install captain-cljs
npx captain-cljs start
mkdir -p src/pages
echo "(ns pages.index) (defn +render [] [:div :hello-world])" > src/pages/index.cljs
#2022-02-0109:58barrellgoal is to get that to load the component, and a css file alongside it to load locally scoped css module. They can start building in clojurescript while I teach them html, css, clojurescript, and eventually namespaces and requires, servers, shadow-cljs, etc#2022-02-0109:59barrellI expect most people to graduate beyond the library but I’m trying to build as big of training wheel as possible for when they start so they can see something load from the get-go#2022-02-0110:00thhellergood luck 😉 just don't go too far off road with this. hiding important implementation details for too long will actually just create more problems in the long run IMHO#2022-02-0110:01thhellerI have talked to many create-react-app users that came to CLJS and didn't have a single clue how react actually works#2022-02-0110:01barrellthanks, and thanks for all the support so far. I’ll try not to get too carried away but sometime I just like to make programming problems for myself 🤪#2022-02-0110:01thhellerI don't think that is a good thing 😉#2022-02-0110:02barrellI’ll try to have an “offboarding” curriculum, would be interesting if one could gradually take off the training wheels. But make it work first and I’ll iterate! 😄#2022-02-0110:03thhellerI'm very interested to see what you come up with#2022-02-0110:03thhellermost people end up using a template that generates far too many files and never knowing what these files actually do#2022-02-0110:03thhellerso different approaches are definitely needed#2022-02-0110:04barrellme too 😂 unless someone swoops in keep an eye out captain-cljs, I’m sure I’ll post here with questions and updates#2022-02-0110:04barrellI’ll try not to use up more of your time than I have already 😂#2022-02-0110:06thhellerits fine. always happy to talk about cljs stuff 😉#2022-02-0110:11barrellwell if all goes well I’ll be funneling lots of members into the community to pester you with questions like “why do I have to require things?!”#2022-02-0110:11barrell😜#2022-02-0110:11barrell(first part was serious, second part was a joke 👼 )
#2022-02-0110:13thhellerpicard-facepalm#2022-01-3110:28StefanHi all, a few days ago we updated tools.deps.alhpa to the latest version (from 0.12.1109 to 0.12.1120). Now when I try to use shadow.cljs.devtools in my code (to start a shadow-cljs server and watch a target), I get errors like these:
; Syntax error compiling at (shadow/build/js_support.clj:1:1).
; namespace 'shadow.build.closure' not found
and:
; Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
; Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
Does this sound familiar to anyone?
#2022-01-3116:38thhellerlooks like a dependency conflict to me? this error you usually get when using an incorrect closure compiler version#2022-01-3116:39thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load#2022-01-3120:28StefanI haven’t done lots of dependency debugging before, but I can’t find the issue. The tools.deps.alpha dependency update was the only thing that changed. When comparing the deps tree with the old and new version of tools.deps.alpha, this is the change set:#2022-01-3120:28StefanThat doesn’t seem to point to anything related to closure / jscomp. The dependencies that you explicitly mention in the manual are identical.#2022-01-3120:31thhellerclosure compiler uses guava so that might be the cause?#2022-01-3120:31thhellerthis diff doesn't seem useful to me#2022-01-3120:32thhellerit might just be that the newer tools.deps version sorted things in a different order for some reason#2022-01-3120:32thhellerthat already may cause issues#2022-01-3120:32thhellerwhat is the full stacktrace of the Could not initialize class com.google.javascript.jscomp.DiagnosticGroups exception#2022-01-3120:34thhellerguava is a common cause of issues and the closure compiler generally doesn't like having it on the classpath with any other version that it expects#2022-01-3120:34thhellerI also see a bunch of dependencies that you definitely don't need for a CLJS build, those should not be on the classpath while building CLJS#2022-01-3120:34thhellerthats why I generally recommend keeping CLJS stuff in shadow-cljs.edn#2022-01-3120:35thhelleror you can keep it in deps.edn but keep a CLJS and a separate CLJ alias#2022-01-3120:35thheller:frontend and :backend or whatever#2022-01-3120:35thhellerputting all :backend deps in the root :deps and then adding CLJS stuff via alias is bad#2022-01-3120:40StefanHmm maybe I’ll have to rethink my dev setup. I’m using polylith, which also adds some restrictions. But what I’m doing at the moment is that I start one single REPL running all backend servers and the (shadow-cljs-based) frontend. So basically something like:
(defn run-in-repl []
    (server1/start)
    (server2/start)
    (shadow.cljs.devtools.server/start!)
    (shadow-watch :frontend)
    :ready)
#2022-01-3120:41thhelleryou can do this but you have to deal with stuff like this conflict. its definitely fixable but you have to figure out where the problem comes from.#2022-01-3120:41StefanThat requires having the jvm all dependencies at once if I understand things correctly, so that will then always (be likely to) cause such issues?#2022-01-3120:41thhellergenerally it is a dependency conflict. if you give me the full stacktrace of the exception I can confirm that.#2022-01-3120:42thhellerI always recommend running CLJS stuff separately. you gain absolutely nothing by running it in the same JVM#2022-01-3120:42StefanOh right sorry. I found the button in Calva to give it to me:
clojure.lang.Compiler/analyze (Compiler.java:6812)
clojure.lang.Compiler$InvokeExpr/parse (Compiler.java:3824)
clojure.lang.Compiler/analyzeSeq (Compiler.java:7113)
clojure.lang.Compiler/analyze (Compiler.java:6793)
clojure.lang.Compiler$BodyExpr$Parser/parse (Compiler.java:6124)
clojure.lang.Compiler$FnMethod/parse (Compiler.java:5471)
clojure.lang.Compiler$FnExpr/parse (Compiler.java:4033)
clojure.lang.Compiler/analyzeSeq (Compiler.java:7109)
clojure.lang.Compiler/analyze (Compiler.java:6793)
clojure.lang.Compiler/eval (Compiler.java:7178)
clojure.core/eval (core.clj:3202)
clojure.core/eval (core.clj:3198)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.core/apply (core.clj:667)
clojure.core/with-bindings* (core.clj:1977)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:87)
clojure.main/repl (main.clj:437)
clojure.main/repl (main.clj:458)
clojure.main/repl (main.clj:368)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:84)
nrepl.middleware.interruptible-eval/evaluate (interruptible_eval.clj:56)
nrepl.middleware.interruptible-eval/interruptible-eval (interruptible_eval.clj:152)
nrepl.middleware.session/session-exec (session.clj:218)
nrepl.middleware.session/session-exec (session.clj:217)
java.lang.Thread/run (Thread.java:833)
#2022-01-3120:42thhellerplz do it without calva#2022-01-3120:42thhellerjust run clj with whatever aliases you have#2022-01-3120:43thhellerthen (require 'shadow.cljs.devtools.api)#2022-01-3120:43thhellerthat should already trigger the exception#2022-01-3120:43thhellerthat exception trace has too much nrepl in it to be useful#2022-01-3120:44Stefan
user=> (require 'shadow.cljs.devtools.api)
Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
user=>
#2022-01-3120:44thheller*e#2022-01-3120:45Stefan
#error {
 :cause "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error macroexpanding at (closure.clj:77:5)."
   :data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
   :at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
  {:type java.lang.NoClassDefFoundError
   :message "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
   :at [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]}]
 :trace
 [[jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
  [jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
  [jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
  [java.lang.reflect.Method invoke "Method.java" 568]
  [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
  [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
  [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
  [clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
  [clojure.lang.Compiler eval "Compiler.java" 7186]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 551]
  [shadow.build.js_support$eval15994$loading__6737__auto____15995 invoke "js_support.clj" 1]
  [shadow.build.js_support$eval15994 invokeStatic "js_support.clj" 1]
  [shadow.build.js_support$eval15994 invoke "js_support.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 619]
  [shadow.build.resolve$eval14164$loading__6737__auto____14165 invoke "resolve.clj" 1]
  [shadow.build.resolve$eval14164 invokeStatic "resolve.clj" 1]
  [shadow.build.resolve$eval14164 invoke "resolve.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 2793]
  [shadow.build.api$eval14156$loading__6737__auto____14157 invoke "api.clj" 1]
  [shadow.build.api$eval14156 invokeStatic "api.clj" 1]
  [shadow.build.api$eval14156 invoke "api.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 2793]
  [shadow.build$eval13806$loading__6737__auto____13807 invoke "build.clj" 1]
  [shadow.build$eval13806 invokeStatic "build.clj" 1]
  [shadow.build$eval13806 invoke "build.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 3204]
  [shadow.cljs.devtools.api$eval5278$loading__6737__auto____5279 invoke "api.clj" 1]
  [shadow.cljs.devtools.api$eval5278 invokeStatic "api.clj" 1]
  [shadow.cljs.devtools.api$eval5278 invoke "api.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [user$eval5274 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval5274 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7136]
  [clojure.core$eval invokeStatic "core.clj" 3202]
  [clojure.core$eval invoke "core.clj" 3198]
  [nrepl.middleware.interruptible_eval$evaluate$fn__976$fn__977 invoke "interruptible_eval.clj" 87]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.AFn applyTo "AFn.java" 144]
  [clojure.core$apply invokeStatic "core.clj" 667]
  [clojure.core$with_bindings_STAR_ invokeStatic "core.clj" 1977]
  [clojure.core$with_bindings_STAR_ doInvoke "core.clj" 1977]
  [clojure.lang.RestFn invoke "RestFn.java" 425]
  [nrepl.middleware.interruptible_eval$evaluate$fn__976 invoke "interruptible_eval.clj" 87]
  [clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
  [clojure.main$repl$fn__9119 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl doInvoke "main.clj" 368]
  [clojure.lang.RestFn invoke "RestFn.java" 1523]
  [nrepl.middleware.interruptible_eval$evaluate invokeStatic "interruptible_eval.clj" 84]
  [nrepl.middleware.interruptible_eval$evaluate invoke "interruptible_eval.clj" 56]
  [nrepl.middleware.interruptible_eval$interruptible_eval$fn__1007$fn__1011 invoke "interruptible_eval.clj" 152]
  [clojure.lang.AFn run "AFn.java" 22]
  [nrepl.middleware.session$session_exec$main_loop__1075$fn__1079 invoke "session.clj" 202]
  [nrepl.middleware.session$session_exec$main_loop__1075 invoke "session.clj" 201]
  [clojure.lang.AFn run "AFn.java" 22]
  [java.lang.Thread run "Thread.java" 833]]}
user=>
#2022-01-3120:45thhellerI absolutely hate that they stopped printing the stacktrace by default 😛#2022-01-3120:45StefanYeah I get your point 🙂#2022-01-3120:46thhellertry ( "com/google/javascript/jscomp/DiagnosticGroups.class")#2022-01-3120:47Stefan
#object[java.net.URL 0x736dd229 "jar:file:/Users/stefanmm/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20211006/closure-compiler-unshaded-v20211006.jar!/com/google/javascript/jscomp/DiagnosticGroups.class"]
#2022-01-3120:48StefanThat seems right to me…#2022-01-3120:48thhellerand ( "shadow/build.clj")#2022-01-3120:48Stefan
#object[java.net.URL 0x60101212 "jar:file:/Users/stefanmm/.m2/repository/thheller/shadow-cljs/2.16.12/shadow-cljs-2.16.12.jar!/shadow/build.clj"]
#2022-01-3120:49thhelleruhm wait#2022-01-3120:49thhellerhow does this exception trace still have nrepl in it?#2022-01-3120:49thhellerclj should not be using nrepl#2022-01-3120:49thhellerI really need you to type this all out into a regular CLJ. no calva, no editor, nothing extra, just the command line stuff#2022-01-3120:50StefanOh sorry that’s indeed when I run outside of vscode but with the ability to jack-in, sorry#2022-01-3120:50StefanI’ll try again#2022-01-3120:50thhellerit seems to loose the cause exception#2022-01-3120:51Stefan
Clojure 1.10.3
user=> (require 'shadow.cljs.devtools.api)
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.deps.ModuleLoader/createRootPaths (ModuleLoader.java:257).
'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
user=> *e
#error {
 :cause "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error macroexpanding at (closure.clj:77:5)."
   :data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"}
   :at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1742]}
  {:type java.lang.NoSuchMethodError
   :message "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'"
   :at [com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]}]
 :trace
 [[com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]
  [com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 147]
  [com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 48]
  [com.google.javascript.jscomp.deps.ModuleLoader$Builder build "ModuleLoader.java" 139]
  [com.google.javascript.jscomp.deps.ModuleLoader <clinit> "ModuleLoader.java" 408]
  [com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 182]
  [jdk.internal.reflect.NativeMethodAccessorImpl invoke0 "NativeMethodAccessorImpl.java" -2]
  [jdk.internal.reflect.NativeMethodAccessorImpl invoke "NativeMethodAccessorImpl.java" 77]
  [jdk.internal.reflect.DelegatingMethodAccessorImpl invoke "DelegatingMethodAccessorImpl.java" 43]
  [java.lang.reflect.Method invoke "Method.java" 568]
  [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
  [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1735]
  [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3705]
  [clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
  [clojure.lang.Compiler eval "Compiler.java" 7186]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 551]
  [shadow.build.js_support$eval10891$loading__6737__auto____10892 invoke "js_support.clj" 1]
  [shadow.build.js_support$eval10891 invokeStatic "js_support.clj" 1]
  [shadow.build.js_support$eval10891 invoke "js_support.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 619]
  [shadow.build.resolve$eval9061$loading__6737__auto____9062 invoke "resolve.clj" 1]
  [shadow.build.resolve$eval9061 invokeStatic "resolve.clj" 1]
  [shadow.build.resolve$eval9061 invoke "resolve.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 2793]
  [shadow.build.api$eval9053$loading__6737__auto____9054 invoke "api.clj" 1]
  [shadow.build.api$eval9053 invokeStatic "api.clj" 1]
  [shadow.build.api$eval9053 invoke "api.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 2793]
  [shadow.build$eval8682$loading__6737__auto____8683 invoke "build.clj" 1]
  [shadow.build$eval8682 invokeStatic "build.clj" 1]
  [shadow.build$eval8682 invoke "build.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 3204]
  [shadow.cljs.devtools.api$eval153$loading__6737__auto____154 invoke "api.clj" 1]
  [shadow.cljs.devtools.api$eval153 invokeStatic "api.clj" 1]
  [shadow.cljs.devtools.api$eval153 invoke "api.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7170]
  [clojure.lang.Compiler load "Compiler.java" 7640]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6856 invoke "core.clj" 6115]
  [clojure.core$load invokeStatic "core.clj" 6114]
  [clojure.core$load doInvoke "core.clj" 6098]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5897]
  [clojure.core$load_one invoke "core.clj" 5892]
  [clojure.core$load_lib$fn__6796 invoke "core.clj" 5937]
  [clojure.core$load_lib invokeStatic "core.clj" 5936]
  [clojure.core$load_lib doInvoke "core.clj" 5917]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 5974]
  [clojure.core$load_libs doInvoke "core.clj" 5958]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 5996]
  [clojure.core$require doInvoke "core.clj" 5996]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [user$eval149 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval149 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7181]
  [clojure.lang.Compiler eval "Compiler.java" 7136]
  [clojure.core$eval invokeStatic "core.clj" 3202]
  [clojure.core$eval invoke "core.clj" 3198]
  [clojure.main$repl$read_eval_print__9110$fn__9113 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9110 invoke "main.clj" 437]
  [clojure.main$repl$fn__9119 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl_opt invokeStatic "main.clj" 522]
  [clojure.main$main invokeStatic "main.clj" 667]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}
#2022-01-3120:52thhelleryes, that confirms guava as the cause#2022-01-3120:52StefanBecause com.google.common.collect is in guava I assume?#2022-01-3120:52thhelleryes#2022-01-3120:53thhellernot actually sure which version you need since the closure compiler changed something in the way they bundle stuff#2022-01-3120:53thhellernot easy to tell anymore. its best to have none at all#2022-01-3120:55StefanI’ll try some combinations of excluding/overriding it then. Pfff. Complicated stuff. Huge thanks for helping me out Thomas!!#2022-01-3120:58StefanFYI: excluding guava in the tools.deps.alpha dependency seems to fix this issue. Not sure what other issues that’ll cause, but we’ll see…#2022-01-3117:31Rodrigo ManticaHello. I’m running a next.js development server and a shadow-cljs watch on an :npm-module target build. I’m able to use my cljs output in my next.js files. However, as I am developing, the hot-module reload seems to pick up the cljs source files twice:
Error: Namespace "goog.debug.Error" already declared.
    at Object.goog.module (webpack-internal:///./cljs/cljs_env.js:163:13)
    at eval (webpack-internal:///./cljs/cljs_env.js:1891:8)
    at Object.goog.loadModule (webpack-internal:///./cljs/cljs_env.js:404:27)
    at eval (webpack-internal:///./cljs/cljs_env.js:1888:6)
I’ve seen similar issues other people have posted about and they all seem related to producing two cljs builds. This is not my current scenario, but rather using it in a js ecosystem with React Fast Refresh. Any tips on how to fix or debug here?
#2022-08-0308:40NathanHey @U02V40G5P9C 👋 Did you manage to find a solution for this error? I'm experimenting a bit with shadow and next.js and I'm stuck on the same scenario: the first load works well, but as soon as I change some code and save the file fast refresh comes into play and I get the error you described.#2022-08-0319:34Rodrigo ManticaI didn’t @U01CKU3HHFA#2022-08-0406:59Nathan😕 ok, thanks, Rodrigo. I am still struggling with the same issue.#2022-01-3117:35thhellerI actually don't know if this can work at all. I think the fast refresh refreshes too much all the time which basically breaks all your code#2022-01-3117:36thhellerie. it should never attempt to load goog.debug.Error twice since that definitely never changes between compiles#2022-01-3117:37thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/env.cljs#L154-L163#2022-08-0312:46Nathan@U05224H0W do you know, by any chance, a workaround for this error? I tried to use your suggestion above, but still couldn't get it to work. I followed your proof of concept https://github.com/thheller/next-cljs and I can make shadow compile the pages as Next wants and works fine, but as soon as I change any CLJS I get the error Namespace "goog.debug.Error" already declared, same error happens if there is more than one page and in that case, it happens during the compilation already.#2022-08-0313:24thhellerin what context? I mean the error you fix by overriding what goog.provide does as shown in the link above?#2022-08-0313:42NathanI'm not sure exactly how/where to override goog.provide as you mentioned. I tried to use the snippet you shared in the entry point of the application/where pages are generated, but couldn't make the error go still.#2022-08-0313:44NathanI think my question is more: do you think it is possible to handle this error and get next.js working with shadow at the current version? Reading your past messages I understood that you were not sure if it would be possible to get by. I also checked with Next.js to see if it would be possible to turn off their fast refresh as you suggested, but apparently, it's not possible. PS: I'm able to generate the pages from CLJS as Next expects, etc. the integration works well, I'm just stuck with the error above being thrown on hot reload.#2022-08-0315:36thhelleryes, I think it is possible to get this working. shouldn't be much different from before#2022-08-0315:36thhellerbut without more context I really cannot give any suggestions for what you might need to do#2022-08-0317:17NathanThe context is that I'm trying to do is to run your proof of concept next.js repo here https://github.com/thheller/next-cljs It works fine without the error if I keep shadow CLJS in the version that is locked in the repo: 2.6.10, but as soon as I update the version, I'm using 2.19.8 now, I start to get the error above.#2022-08-0317:22thhellerthat never had a working REPL as far as I can remember#2022-08-0317:22thhellerso I guess you are not talking about shadow-cljs doing the hot-reloading but webpack/next doing it?#2022-08-0317:22thhellerin that case you have to manually install the patch somewhere#2022-08-0406:58NathanYes, the error starts when Next detects changes in the files generated by the hot reload from shadow-cljs. I'm unsure where/how I should install this patch. I tried to call this function in one of the entries of the application, but it doesn't seem to have any effect. Could you please elaborate where/how you imagine this patch is installed?#2022-08-0407:07thhellershadow-cljs does no hot-reload in the next-cljs example repo you linked above. none. it will trigger a re-compile and I suspect that next is doing the hot-reload?#2022-08-0407:07thhellerI cannot tell you how to install or handle the patch since I don't know what you are building#2022-08-0407:07thhellersomewhere in the code that is getting executed you do that#2022-08-0407:08thhellerthat could be from the code you generate in the hook, or in the CLJS code#2022-08-0407:08thhellerI haven't looked at next.js since I made that example#2022-08-0407:10thhellerif you share the repo that has the stuff that didn't work I can maybe tell you why it didn't work#2022-08-0407:33NathanI'm working exactly with your repo. The only difference is that I updated shadow-cljs, other than that it's the same repo.#2022-08-0407:34NathanLet me create a fork with the updated version.#2022-08-0407:37thhelleryou probably also use a newer next.js? I mean otherwise the error should also happen with the older version?#2022-08-0407:41NathanYes, I'm using a new version (12.2.3), the error doesn't happen with the version you used in the proof of concept (7.0.0).#2022-08-0407:42thhellerthe older version just didn't have any hot-reload I think#2022-08-0407:43NathanYou're right, they introduced what they call https://nextjs.org/docs/basic-features/fast-refresh as of version 9.4#2022-08-0407:57NathanHere's a fork with next and shadow-cljs versions updated: https://github.com/nathanqueija/next-cljs I updated the readme with instructions to run both shadow and next. What I'm doing to reproduce the error: • Start shadow build • Start next build • When all builds are ready and I go to localhost:3000 everything works fine • Change anything in the component, can be just a string that is being rendered • I assume that's when next hot reload comes into play and the error is thrown#2022-08-0407:58thhellerok, so you made no attempt of adding the patch?#2022-08-0407:59NathanI did, I added a new entry and called the function you shared there, but no luck. Also tried to call directly in the page component, but still no luck.#2022-08-0407:59NathanJust didn't commit it because couldn't make it work.#2022-08-0408:00thhellerwell, please add it#2022-08-0408:02thhellerone option would be to add import "../src/cljs/shadow.cljs.devtools.client.browser.js") here https://github.com/nathanqueija/next-cljs/blob/master/src/main/shadow/next_js.clj#L30#2022-08-0408:02thhellerbut only do that for development builds#2022-08-0408:02thhellerhowever that means that shadow-cljs will also start hot-reloading#2022-08-0408:02thhellerhaving two separate hot-reloads is not a good thing and they will interfere with each other#2022-08-0408:04thhellerif there is a way to disable the hot-reload from next.js you should probably do that#2022-08-0408:56NathanI pushed a commit adding the patch in one of the entries and also adding the import you suggested in one of the pages but still got the error. From next perspective, it seems there is https://github.com/vercel/next.js/discussions/25712 to https://github.com/vercel/next.js/issues/13268#issuecomment-992463977.#2022-08-0409:03thheller
error - src/cljs/shadow.cljs.devtools.client.websocket.js (26:14) @ shadow$cljs$devtools$client$websocket$start
error - ReferenceError: WebSocket is not defined
    at shadow$cljs$devtools$client$websocket$start (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.websocket.js:25:18)
    at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:549:135)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.shared.js:1117:20)
    at eval (webpack-internal:///./src/cljs/shadow.cljs.devtools.client.browser.js:1358:40)
    at ./src/cljs/shadow.cljs.devtools.client.browser.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:725:1)
    at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///./pages/index.js:5:106)
    at ./pages/index.js (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:198:1)
    at __webpack_require__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/webpack-runtime.js:33:42)
    at __webpack_exec__ (/mnt/c/Users/thheller/code/tmp/next-cljs/site/.next/server/pages/index.js:1268:39) {
  page: '/'
}
  24 | shadow.cljs.devtools.client.websocket.start = (function shadow$cljs$devtools$client$websocket$start(runtime){
  25 | var ws_url = shadow.cljs.devtools.client.env.get_ws_relay_url();
> 26 | var socket = (new WebSocket(ws_url));
     |              ^
  27 | (socket.onmessage = (function (e){
  28 | return shadow.cljs.devtools.client.shared.remote_msg(runtime,e.data);
  29 | }));
#2022-08-0409:04thhellerso the regular shadow-cljs devtools probably won't work due to it running in node and the browser I guess?#2022-08-0409:06Nathanyes, if any browser APIs are used in the pages exported that wouldn't work because they go first through the server to be rendered by Next before being returned to the client.#2022-08-0409:08thhelleryeah sorry this is not an easy fix#2022-08-0409:08thhellerwell, I guess you can hack it#2022-08-0409:09thhellercreate a cljs ns with the patch call#2022-08-0409:09thhellerand import instead of the shadow.cljs.devtools.client ns in the hook output#2022-08-0409:09thhellerbut getting websocket/repl to work is much more work#2022-08-0409:21NathanTried to add the hack as you suggested but I guess the problem persists because any file exported has this statement in the first line var $CLJS = require("./cljs_env"); and it's exactly this file that throws the error online 1448 in this statement goog.module("goog.debug.Error"); . So as soon as the file with the patch is loaded the error will be thrown before any of the actual code from the pages being executed.#2022-08-0409:29thhelleryeah sorry I don't have time to look into this#2022-08-0409:29thhellernext seems to be doing a lot more than it previously did#2022-08-0409:29thhellerand I longer have the slightest clue what it is doing#2022-08-0409:29thhellerjust gotta keep digging. I mean you can just modify the emitted cljs_env.js but not sure that changes anything#2022-01-3117:37thhellerthats the code you need to patch away that exception basically#2022-01-3117:38thhellermaybe its enough if you somehow do the same set! replacements somewhere but I don't know#2022-01-3117:38thhellertypically I'd say to just let shadow-cljs handle the reloading and have next ignore your CLJS output#2022-01-3117:38thhellerbut dunno if thats even possible anymore#2022-01-3118:03Rodrigo ManticaOk I’ll have to figure out how react fast refresh works. Thanks for the insight.#2022-01-3121:05zimablueI'm having an interesting problem where I get a stack overflow in shadow.umd_helper.js#2022-01-3121:06zimablueat Object.get [as test_query] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:11:16)#2022-01-3121:06zimabluedon't know why it is, I was trying to stably depend upon a local typescript project using "yarn link", that's the last thing I did so I think it's somehow related#2022-01-3121:07zimabluejust putting here in case it's obvious that it can only be one thing, or for the posterity of this slack once I work it out#2022-01-3123:57olafI’m having a problem with circular reference defining variables at compile time. I’m doing
:dev {:closure-defines {foo.core/DEV true}}
and inside src/cljs/foo/core.cljs
(ns foo.core)

(goog-define DEV false)

(def dev? (true? DEV))
Is working correctly but I cannot use dev? inside components. Since the application is loaded from that calls foo.core/init! and inside foo.core all the rest of the reagent components are loaded sequentially, if I (:require [foo.core :refer [dev?]]) inside a component is doing a circular reference. So the question is, how can I define variables at compile time that I can use inside components without creating a circular reference?
#2022-02-0107:24thheller@eliascotto94 move it to a foo.config namespace that you can reference everywhere. the problem is having this in foo.core so just move it out. I personally have a my.app.env namespace in every app for such purposes#2022-02-0107:25thhellerotherwise a circular reference is not allowed#2022-02-0108:17shivekkhuranahey guys, I have run into a really weird issue, and am not able to figure out the root cause. In my setup, I'm importing a js source file (compiled to commonjs), directly inside my CLJS source. Th error is that a required module is not defined:
var s = _interopRequireWildcard(require("@solana/web3.js"));
^ this line is from a compiled file. This compiled file is from a package that the js code depends on. Somewhere deeper in the file when this function is used, I get an error saying that s is not defined. Has anyone faced this before? I've been stuck on it for the past 2 days. I have made sure that the module is present. I have also manually imported this module in my core file. Its present there (I'm able to console.log), but it isn't available for a js package that relies on it.
#2022-02-0108:21thhellerso you mean you have this fine on the classpath imported via (:require ["/some/thing.js" :as x])? ie. not a file in node_modules#2022-02-0108:21shivekkhuranaYes. This works fine in my app/core.cljs#2022-02-0108:22thhellerfiles on the classpath are meant to be ESM. it should not contain babel-rewritten commonjs#2022-02-0108:22thhellerstandard ESM is fine#2022-02-0108:22shivekkhuranaI can convert the commonjs stuff to esm#2022-02-0108:24thhellerwhat is it converted from in the first place?#2022-02-0108:25shivekkhuranaits standard es6 with some JSX stuff#2022-02-0108:26shivekkhuranaso I use SWC to convert it to Commonjs#2022-02-0108:26shivekkhuranaand then use that source inside a CLJS app#2022-02-0108:26thhellerwell commonjs should be fine in theory#2022-02-0108:28shivekkhuranaThe problem is that the dep is available in cljs source (node module k can be required in cljs), but not available when js source (`(:require ["/some/thing.js" :as x])`) requires it. Ie thing.js requires it (ie node module k is not available in thing.js).#2022-02-0108:29thhellerthat should be fine but I can't comment much without more info#2022-02-0108:29thheller(:require ["@solana/web3.js" :as sol]) what is (js/console.log sol)?#2022-02-0108:29shivekkhuranaThe console log si the package contents#2022-02-0108:31thhellerthen it should be fine in the JS result#2022-02-0108:34shivekkhuranaOkay, thanks for the quick response.#2022-02-0108:34shivekkhuranaI'll checkout whats up.#2022-02-0108:35thhellernote that you can just output the JS source to packages/that-stuff and use :js-package-dirs ["packages" "node_modules"] in your build config#2022-02-0108:35thhellerthen that-stuff can pretend to be a full npm package#2022-02-0108:35thhellerand you can (:require ["that-stuff"])#2022-02-0108:36thhellerit doesn't need to be on the classpath for that#2022-02-0108:37shivekkhuranaokay, this is news. I'll try this out.#2022-02-0108:38shivekkhuranathere is no docs on js-package-dirs ?#2022-02-0108:38thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules#2022-02-0110:32shivekkhuranaI removed my custom js code, required the npm deps directly. The same problem occured in the dist file of the package. Then I used the same package in nextjs, it worked fine there 😭#2022-02-0112:57shivekkhuranaI finally forked the problematic package. It was using rollup under the hood to create a browser build. The terser plugin in rollup minified in a way that was incorrect for CLJS (and Dart). For some reason, it works fine for Nextjs based projects.#2022-02-0108:27zimabluere the problem I had yesterday, I tested more and got EXTREMELY confusing results, they seem to imply the existence of shadow-cljs (or connected js tooling) global state outside of "yarn link" elements (which are in ~/.config/yarn/link/...). The only global state I can think of are global shadow-cljs installs and globally installed NPM modules but maybe there is more?#2022-02-0108:30shivekkhuranain my case, I'm being naughty and sym linked a js package source to my project root. and then started requiring it in my cljs source 🤐#2022-02-0108:30thhellershadow-cljs doesn't use globally installed npm modules. it just uses whatever is in node_modules in your project#2022-02-0108:30thhellerif yarn puts something global in there it is no longer global#2022-02-0108:34zimabluejar: 2.16.12 cli: 2.16.12 deps: 1.3.2 config-version: 2.16.12 Does the "deps" here refer to the version specified in "deps.edn"?#2022-02-0108:34thhellerno#2022-02-0108:34thhellerwhen using deps.edn nothing in info matters basically#2022-02-0108:34thhellerdeps.edn overrides all of it#2022-02-0108:35zimablueshadow-cljs doesn't use globally installed npm modules you say, is there still a "global" state in terms of whether shadow-cljs is "globally" installed#2022-02-0108:36thhellerno, no global state ever#2022-02-0108:37thhellerthe global shadow-cljs install is just the actual shadow-cljs CLI tool. you can just remove it, it won't affect compilation in any way#2022-02-0108:37thhelleronly trouble it can cause is using a global install that is out of sync with the local install too much#2022-02-0108:37thhellerie. global install v1 but project install v2#2022-02-0108:39thhellerbasically I recommend to not use the global install but I do so myself because of the convenience 😉#2022-02-0108:39zimabluehahaha I respect that#2022-02-0108:40zimabluethe reason I started thinking "global state" was because two disconnected projects both failled and then succeed simultaneously when only one of them was having commands run/being modified#2022-02-0108:41thhellerdefine failed?#2022-02-0108:42zimabluestrange errors, the one I got above where I got a stack overflow in shadow.umd_helper.js was the initial problem, then after hacking away there was a point where compile was succeeding but the exports when "required" through vanilla nodejs cli were undefined#2022-02-0108:42zimabluethen after much hacking away config and dependencies to try and find the problem, it started working, but extremely weirdly the original project (I'd made a copy) also started working#2022-02-0108:43thheller> I got a stack overflow in shadow.umd_helper.js#2022-02-0108:43thhellergot a stack overflow where? in what context? part of the compilation? part of running shadow-cljs?#2022-02-0108:44zimablueI used yarn link which I thought was the problem but I purged all traces of it and got the same error later, unless it had snuck state into something, AFAIK the only shadow-cljs "state" is .shadow-cljs and .cpcache#2022-02-0108:44thhellershadow-cljs only .shadow-cljs yes#2022-02-0108:44zimabluewhen importing the node-library build using javascript in a node repl, when accessing a property of the defined module, got a stack overflow#2022-02-0108:44zimablueso compile etc worked#2022-02-0108:44thheller.cpcache is not something shadow-cljs ever looks at or uses#2022-02-0108:45thhellerit really is much easier if you give me stack traces and full errors#2022-02-0108:46thhellerie. in the node-repl no JS is compiled by shadow-cljs and it just emits require("whatever") if you use a node library#2022-02-0108:46zimablueand where, that's the name of some file that shadow-cljs generated, which seems to play a part in exports when making a node-library, full name is shadow.umd_helper.js, location in ($out_dir/cljs-runtime)#2022-02-0108:46thhellerso was that a node stack overflow?#2022-02-0108:46zimabluenode library, not node repl#2022-02-0108:47thhellerthe node part implies the same, unless you override :js-provider#2022-02-0108:47zimablueit was a node stack overflow when importing the file generated by shadow-cljs compile and then attempting to access one of the exported functions#2022-02-0108:47thhelleryeah sorry I can't help with this without more accurate errors#2022-02-0108:47thhellerhappy to look at traces and stuff but this is going nowhere 😛#2022-02-0108:48zimabluesorry for my poor communication, the error itself has mysteriously disappeared#2022-02-0108:48zimablueprobably I will accidentally summon it in a minute#2022-02-0108:48thhellerprojects don't share any state ever. excepts maybe if you link the same npm dependency in the local node_modules#2022-02-0108:49thhellerthen they share that npm dependency and if you modify that then all bets are off#2022-02-0108:49thhellerbut they still won't share caches or whatever but if that package is doing something crazy then both projects will be affected by it#2022-02-0108:50thhellerumd_helper is just the wrapper for the :node-library output, so it'll be on the stacktrace but itself it doesn't do anything that matters#2022-02-0108:57zimabluethe stacktrace was all umd_helper though, whatever I'd done, there was some sort of circular reference being created inside it, otherwise how can you get a stacktrace like:
backend.test_file_store
Thrown:
RangeError: Maximum call stack size exceeded
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:5:16)
    at Object.get [as test_file_store] (/home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js:4:114)
#2022-02-0108:57zimablue(found it)#2022-02-0108:59thhellerand what is in /home/zimablue/projects/kangrok-ui/.shadow-cljs/builds/node/dev/out/cljs-runtime/shadow.umd_helper.js?#2022-02-0108:59thhellerthat should be an extremely simple file. I don't see how this could possible generate a stackoverflow?#2022-02-0109:00thhelleroh are you maybe trying to setup some :exports that exports itself?#2022-02-0109:00thhellerlike setup npm packages in a way where (:require ["something"]) would be referring to itself?#2022-02-0109:02zimabluethat's not what I was trying to do, I was just trying to make a cljs with exports, the reason this all gets funky is that there's a stack of typescript depending on clojurescript depending on typescript#2022-02-0109:02zimabluewhich is why I was trying to use "yarn link" in the first place, to eliminate some shell scripting parts of the build#2022-02-0109:03thhellerif you want deep integration use :npm-module#2022-02-0109:03thheller:node-library is really meant to create a standalone actual node library#2022-02-0109:03thhellerif you setup circular stuff then there is nothing to prevent that#2022-02-0118:29p-himikStumbled upon https://github.com/funcool/promesa/issues/86 and decided to investigate for a bit. Could reproduce it only with shadow-cljs (at least on 2.16.12). This is enough to trigger the error:
(defprotocol P
  (a [_]))

(a (throw ""))
which results in:
------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /home/p-himik/tmp/cljs-compiler-bug/src/a/b.cljs:6:1
--------------------------------------------------------------------------------
   3 | (defprotocol P
   4 |   (a [_]))
   5 | 
   6 | (a (throw ""))
-------^------------------------------------------------------------------------
 Use of undeclared Var a.b/ignore
--------------------------------------------------------------------------------
Maybe this line https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/cljs_hacks.cljc#L823 is simply missing the symbol ignore?
#2022-02-0118:30thhellerteh fuck is that? 😛#2022-02-0118:30thhellerwhy would the symbol ignore be in that set?#2022-02-0118:31thhellerI don't have a clue where that ignore is coming from?#2022-02-0118:36thhellercan you share the repro? I'm curious#2022-02-0118:38p-himikignore is defined here: https://github.com/clojure/clojurescript/blob/a4673b880756531ac5690f7b4721ad76c0810327/src/main/clojure/cljs/analyzer/impl.cljc#L29 And it ends up being as a tag because of this, I think: https://github.com/clojure/clojurescript/blob/5e7fd72f7fa25e10241f229998e5620d79bc0aad/src/main/clojure/cljs/analyzer.cljc#L1537 The repro is literally those 3 lines that I posted, and a bare-bones shadow-cljs.edn. But I can create a repo with the repro if you want.#2022-02-0118:39thhellerstill faster to just run npm install and not create all the other stuff 😛#2022-02-0118:42thhellerI've literally never seen the ignore stuff before when looking through analyzer code 😛#2022-02-0118:42thhelleryou might be right though#2022-02-0118:43p-himikHere you go: https://github.com/p-himik/shadow-cljs-ignore-bug#2022-02-0118:43p-himikAnd, of course, npm i && npx shadow-cljs watch main.#2022-02-0213:32mauricio.szaboI can't believe that we're finally finding the source of that error! 🎉#2022-02-0213:32mauricio.szaboI was already considering "one of the ClojureScript weird things that happen from time to time" and living up with it 😄#2022-02-0213:34p-himikJust @ me when you find the next unexplainable thing. :D#2022-02-0120:09Mitchell HarrisI’m getting an error running npx shadow-cljs release app
The required JS dependency "buffer" is not available, it was required by "node_modules/amplitude-js/amplitude.umd.js".

Dependency Trace:
	viderahealth/events/common_test.cljs
	viderahealth/events/common.cljs
	viderahealth/amplitude.cljs
	node_modules/amplitude-js/amplitude.umd.js

Searched for npm packages in:
	/Users/mitchellharris/src/patient-fe/node_modules

See: 
We do have shadow-cljs listed in our package.json, so It isn’t likely to be https://clojurians-log.clojureverse.org/shadow-cljs/2020-05-27 Any ideas?
#2022-02-0120:31thhellernpm install buffer? it should already be installed but I guess its not?#2022-02-0120:57Mitchell HarrisOh. I thought that was a node.js only package. That does work. 🤷 I was under the impression that was bundled with shadow-cljs so it wasn’t necessary. Sorry to bug you with such a trivial thing. Thank you.#2022-02-0121:51thhellerits not bundled with shadow-cljs but installing shadow-cljs in the project brings in node-libs-browser which does have buffer as a dependency. so it should be there. dunno why it isn't there#2022-02-0121:16skeltershould I expect using a string with a absolute path in a :require (edited) to work? Assert failed: (symbol? sym)#2022-02-0121:50thheller@skelter in shadow-cljs yes. everywhere else no. also assuming by absolute path you mean this https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js#2022-02-0122:05skelter@U05224H0W Yes, re 12.2.1 . Ok...so it should work. So something is weird with my use of it. Maybe the underscores in the filename. I'll start peeling away at it. Thanks.#2022-02-0122:31skelterthe simplest emptiest "/acme/myproto/a.js" worked. I think problem is something in my .js file#2022-02-0207:53thhellerwhat kind of js file is it? ESM works best. if it is closure JS (ie. goog.provide or goog.module) you must refer to it via a symbol as any other regular CLJS/Closure ns. (ie. (:require [acme.myproto.a])) matching whatever name is in goog.provide or goog.module#2022-02-0121:57alexHi there, I'm attempting to do some code splitting, but it seems like the loader is trying to load a module that I didn't specify. I have a configuration and source files similar to the below:
;; shadow-cljs.edn
{:builds {:client {:target     :browser
                   :module-loader true
                   :modules    {:client {:entries [my-app.client]}
                                :room {:entries [my-app.components.room]
                                       :depends-on #{:client}}}}}}

;; my-app.client
(require-lazy '[my-app.components.room :refer [Room])
client and room modules are generated in my output-dir and the module mapping file When I navigate to the page that loads the room module, I get a runtime exception from failing to load the module. However, it's not failing because it can't load room; rather it seems like shadow attempts to load a module with components moduleID when that module doesn't exist Is that because I have a namespace defined at my-app.components.room, and it expects the existence of a parent components module? I don't have a my_app/components.cljs file
#2022-02-0121:59agwhat's the best way of feeding custom options (declared in shadow-cljs.edn) into the app, that can be read using cljs.env - https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/env.cljc#2022-02-0122:00thheller@rahx1t namespace names don't matter to modules, so no there is no such thing as a parent components module. I don't know what require-lazy is though? if that is emitting a module load for components then that is out of shadow-cljs control#2022-02-0122:04alexawesome, thanks for confirming in that case, require-lazy might be the source of the bug and is extracting the wrong module name. it's from the Rum library: https://github.com/tonsky/rum/blob/9feb2a1781e3ef716361f9788150a01ea7f791b6/src/rum/lazy_loader.cljc#L31-L52#2022-02-0122:06thhelleryeah thats it#2022-02-0122:07alexthanks! i don't have much experience with writing macros, but since i know the expected output, i'll try to figure the bug and patch it. appreciate your help!#2022-02-0122:08thhellerdoesn't look like a bug to me. looks quite intentional#2022-02-0122:09thhellerjust seems to assume that your namespace structure actually matches your module structure#2022-02-0122:20alexAh interesting. In your experience, would you suggest I add a my-app.components namespace that re-exports all of the components from my-app.components.*? Then create an associate :components module?#2022-02-0122:22thhellerno. that doesn't make sense to me at all but I didn't write that macro#2022-02-0122:23thhellerdunno if you saw https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2022-02-0122:23thhellerbut that also has a helper macro#2022-02-0217:22alexthanks for pointing me to that!#2022-02-0217:22alexI appreciate not having to call (set-loaded! :module-id) if I use the macro you shared#2022-02-0122:02thheller@ag I don't know what you mean by that. if you are building a self-hosted build then there is no way to feed anything from shadow-cljs.edn into that. what are you trying to get there?#2022-02-0122:04agI just need some custom config options things like :base-api-root, etc. I'm not sure what's the best way of doing something like this.#2022-02-0122:06agNevermind. I think I've found "Using Environment Variables" in the documentation. Will try that#2022-02-0122:07thhellerits unclear why you are referring to cljs.env. that is something from the compiler. you wouldn't use it in a regular build#2022-02-0122:07thhellerits not about environment variables at all#2022-02-0122:10agyeah, sorry about the confusion. I thought that's one of the ways how it can be done. I initially found this gist: https://gist.github.com/metametadata/bb00917e09463f6ce04f0e50ccc0740a#2022-02-0122:19thhellerah ok. yeah that works too but only in macros#2022-02-0122:20thheller:closure-defines and environment variables are probably easier#2022-02-0122:30agI'm still confused. How do I access those vars from the app?#2022-02-0122:31thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2022-02-0122:32thheller(ns some.ns) (goog-define FOO "default-value")#2022-02-0122:32thhellerthink of goog-define as def so (def FOO "default-value")#2022-02-0122:32thhelleryou use it like any other def#2022-02-0122:32thhellerbut you can set the value from the build config#2022-02-0122:37agI still can't seem to get it right. I set in shadow-cljs.edn: [:builds :app :closure-defines] to something like this: {:base-api-root #shadow/env ""} Now what should I do?#2022-02-0122:38ag(goog-define) is in Clojurescript file? It's not working for me in Cljs repl#2022-02-0122:39thhelleryes, it should be in a file#2022-02-0122:40thheller{:base-api-root #shadow/env ""} this is not quite right. this will look up the environment variable called ""#2022-02-0122:40thhellerand the key must be a namespaced symbol#2022-02-0122:40thhellerso my example from above some.ns/FOO#2022-02-0122:50agYay, it worked. Thank you Thomas!#2022-02-0214:50Gokul SyamHi @thheller, can you tell me where I’m supposed to be setting closure-defines option at?#2022-02-0214:50thhellerin the build config? https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2022-02-0214:53Gokul SyamHere it’s not wrapped inside compiler-options, is that not necessary?#2022-02-0214:53thhellersee sentence below this thread#2022-02-0214:51thhellercan be directly in the build config or :compiler-options {:closure-defines ...}. both work#2022-02-0214:52Gokul SyamI followed this - https://github.com/thheller/shadow-cljs/issues/217, and my config looks similar to it#2022-02-0214:52Gokul SyamBut CLOSURE_DEFINES is still coming up as undefined#2022-02-0214:53thhellerCLOSURE_DEFINES should be of no concern to you. if you are trying to use it you are doing something incorrectly.#2022-02-0214:53thhellerwhat is your :target build?#2022-02-0214:53Gokul Syambrowser#2022-02-0214:54thhellerand you have a namespace with a goog-define?#2022-02-0214:56Gokul Syamoh, I don’t#2022-02-0215:01Gokul SyamBut if I’m setting something from the Closure library, I don’t need to explicitly define that right?#2022-02-0215:01Gokul Syam:closure-defines {goog.json.USE_NATIVE_JSON true}#2022-02-0215:01thhelleryeah thats fine#2022-02-0215:03thhellerlooks fine to me#2022-02-0215:03Gokul SyamWeird, I’ve added it inside builds and even in every individual profile, still no luck#2022-02-0215:05thhellerprofile?#2022-02-0215:05thhellershould be in {:builds {:build-id {:target :browser :closure-defines {goog.json.USE_NATIVE_JSON true}}} in shadow-cljs.edn#2022-02-0215:11Gokul SyamYep, just checked, I’m able to find it there#2022-02-0215:11Gokul SyamJust to confirm, I’m checking for CLOSURE_DEFINES in the browser, if it’s undefined then that means it was not configured properly right?#2022-02-0215:12thhelleragain CLOSURE_DEFINES is of no concern. it is an implementation detail. forget it exists.#2022-02-0215:12thhellerplease instead describe what you are actually doing#2022-02-0215:12thhelleryou have a :target :browser build#2022-02-0215:12thhelleryou are loading in a HTML page somewhere?#2022-02-0215:13thhelleryou have a REPL into that page for the build?#2022-02-0215:13thhellerit is running in an actual browser. directly without any other build tools post processing it in any way? meaning you are loading the output actually produced by shadow-cljs, not something else.#2022-02-0215:17Gokul SyamThe way that it’s configured is using lein with shadow-cljs#2022-02-0215:17Gokul SyamI’m actually very new to Clojure and especially the tooling so my apologies if that’s not what you were asking for#2022-02-0215:20Gokul SyamI’m building an uberjar with lein uberjar-app#2022-02-0215:20Gokul Syam
:uberjar-app {:prep-tasks [["shadow" "release" "app"]
                                "compile"]}
#2022-02-0215:21Gokul Syam“app” is the build-id#2022-02-0215:21thhellerok that does a release of the app build#2022-02-0215:21thhellerexactly. I assume that is a standard :advanced build. this will be optimized and no traces of the CLOSURE_DEFINES will be left. so you definitely cannot look that up there#2022-02-0215:22thheller(assuming you actually set it for the release build and not just dev)#2022-02-0215:22thhellerbut point is looking it up manually via CLOSURE_DEFINES in release builds is not possible#2022-02-0215:22Gokul Syamoh okay#2022-02-0215:23thhelleryou can do in watch or compile but not release#2022-02-0215:23Gokul SyamI was able to see it in dev so I figured the same would be possible in release as well#2022-02-0215:23Gokul Syamokay got it, but yea I’m setting it in release as well#2022-02-0215:23thhellerthe closure compiler will inline the value you set and then optimized#2022-02-0215:24thhellerso looking up the result is kinda difficult 😛#2022-02-0215:24thhellerwhy do you think it isn't working?#2022-02-0215:24Gokul Syamthe whole purpose is to prevent closure compiler from using eval methods
#2022-02-0215:24Gokul Syamcause I have a content-security-policy configured to block all eval methods#2022-02-0215:25Gokul SyamI found out online that this is the flag that actually prevents it from using eval#2022-02-0215:25thhellerit should already use JSON.parse if thats available? so it won't use eval if that is available?#2022-02-0215:26Gokul SyamHmm doesnt seem to be the case, CSP is still flagging methods for using eval in the compiled script#2022-02-0215:27thhelleryou can compile shadow release app --debug. that'll give you source maps and use pseudo names#2022-02-0215:27thhellerthat should make it much easier to find out where exactly eval is used#2022-02-0215:27Gokul Syamoh awesome, i’ll try that#2022-02-0215:28Gokul Syambeen banging my head at this for hours, thank you for some direction#2022-02-0215:30thheller(it should also allow verifying the closure define actually did something#2022-02-0215:30thhellerpseudo names renames stuff#2022-02-0215:30thhellerso goog.json should be $goog$json#2022-02-0215:30thhellerjust look for that in the source code#2022-02-0316:27tianshu@thheller I ran into the error I talked before, that I have to delete .shadow-cljs to make it works again. I have the error stack, I'm not sure whether it will help or not, the build target is node-script.#2022-02-0316:28tianshu#2022-02-0316:30thhellergod damn slack. where is the download button for this?#2022-02-0316:30tianshuClick the three dots, then View file details?#2022-02-0316:31thhellerjust wanted to download a .txt file or something 😛#2022-02-0316:31thhellerguess I'll copy and paste#2022-02-0316:31tianshuI'll upload a file#2022-02-0316:31tianshu#2022-02-0316:32tianshuemmmm...#2022-02-0316:32thhellerthx#2022-02-0316:33thhellerhmm yeah can't make much of that either. dunno why it would be looking for something $cljs.#2022-02-0316:33thhellerthis is actually node right?#2022-02-0316:33tianshuYes, it's node.#2022-02-0316:34thhellerand just restarting shadow-cljs was not enough?#2022-02-0316:34tianshuyes, restarting is not enough. I'm sure the process is stopped#2022-02-0316:35tianshuwhen it happens, there will be some random compile error, usually occurs to somewhere unchanged#2022-02-0316:35thhellerthat usually points to 2 shadow-cljs versions running competing with each other#2022-02-0316:35tianshuoh, two versions of shadow-cljs?#2022-02-0316:36thhellerwell not versions. instances. like launching shadow-cljs twice in the same project#2022-02-0316:36tianshuyou mean in the same project?#2022-02-0316:36thhellerboth compiling at the same time and overwriting each others files#2022-02-0316:37tianshuthe "instance" is the one I start with npx shadow-cljs ... ?#2022-02-0316:37tianshuor some internal process?#2022-02-0316:39thhellerdon't know how you are running things#2022-02-0316:40thhellernpx shadow-cljs watch app and emacs cider jack-in or something#2022-02-0316:40thhellertwo separate jvm instances created somehow#2022-02-0316:41thhellerI guess just twice npx shadow-cljs watch app would cause this two if executed fast enough. meaning before one becomes "ready" and thus the second thinking it was first and starting as normal#2022-02-0316:42tianshuI use cider, and cider use npx shadow-cljs server. But I don't think I started it twice.#2022-02-0316:43tianshuOh#2022-02-0316:43tianshuwill it matter if I have a test build?#2022-02-0316:43thhelleronly if that instance also starts compiling the app build as well#2022-02-0316:44thhellerI typically recommend running npx shadow-cljs server manually yourself#2022-02-0316:44thhellerand then use cider connect instead of the jack-in stuff#2022-02-0316:44thhellerbut I don't use cider so no clue if that is actually possible 😛#2022-02-0316:47tianshuFor the code files required in both builds(app, test). There will be only 1 version of cache in .shadow-cljs?#2022-02-0316:48tianshuOkay, since more information is required. Probably I can figure how to reproduce for the next time.#2022-02-0316:48tianshu😎#2022-02-0316:48thhellerthere will be one .shadow-cljs/builds/app/... and one .shadow-cljs/builds/test/...#2022-02-0316:49thhellerbut if you have two processes compiling the app build they will both write to .shadow-cljs/builds/app/...#2022-02-0316:49thhellerthere is only supposed to be one process compiling a build not two#2022-02-0316:50tianshugot it#2022-02-0316:50thhellerthe next time this happens don't do anything. leave everything running. type jps. that should list all running java processes#2022-02-0316:51thhelleryou can get further details on what these processes actually are via jinfo <pid> from jps#2022-02-0316:52thhelleror use something like jvisualvm. listing all jvm processses. or just ps I guess if you are on a mac/linux#2022-02-0316:52tianshuokay#2022-02-0316:53tianshuI'll confirm whether there are more than one shadow instance#2022-02-0316:55tianshuBTW, is there a change log for shadow-cljs?#2022-02-0316:56thhellerhttps://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#2022-02-0316:56tianshu❤️#2022-02-0401:24SimonError when running shadow-cljs release app:
Closure compilation failed with 1 errors
--- app/components/user/payment.js:2
Cannot import Closure files by path. Use either import goog:namespace or goog.require(namespace)
payment.js
import { firebaseapp } from 'goog:app.helpers.firebase';
import firebase from 'firebase/compat/app'; <--- error here
import 'firebase/compat/functions';
(...)
(ns app.components.user.index
  (:require
   ["antd" :refer (Avatar Button Dropdown Menu Skeleton Spin)]
   ["@ant-design/icons" :refer (LoadingOutlined)]
   [reagent.core :as r]
   ["firebase/compat/app" :default firebase]
   [app.helpers.macros :refer [if-let-n]]
   ["./payment" :refer (onAuth openCheckout openCustomerPortal onActiveSubscription)] <---- imports
   [re-frame.core :as rf]
   [cljs.core.match :refer [match]]))
Stuck on debugging this. I hope someone can help 🙂
#2022-02-0406:44thhellerimport { firebaseapp } from 'goog:app.helpers.firebase'; should be import firebaseapp from 'goog:app.helpers.firebase';#2022-02-0406:45thhelleror probably import firebase_helper from 'goog:app.helpers.firebase'; firebase_helper.firebaseapp assuming thats a def in the ns?#2022-02-0412:22SimonDoesn't work. Same error message. payment.js
import firebase_helper from 'goog:app.helpers.firebase';
import firebase from 'firebase/compat/app'; <-- error points to this line
import 'firebase/compat/functions';

const { firebaseapp } = firebase_helper;
(...)
app.helpers.firebase.cljs
(ns app.helpers.firebase
  (:require ["firebase/compat/app" :default firebase]
            ["firebase/compat/auth"]
            ["firebase/compat/firestore"]
            [app.envvars.core :refer [APP_ENV]]))

(...)


(def ^:export firebaseapp (.initializeApp firebase (if (= APP_ENV "production") firebase-prod-config firebase-dev-config)))
#2022-02-0412:24Simonshadow-cljs watch app still works though.#2022-02-0412:24Simonjust not able to compile release version#2022-02-0412:45thhellerI'm unsure what this might be. what happens if you remove that line?#2022-02-0815:22SimonThat worked:white_check_mark: Hehe i don’t know why i included this line. But weird that it fails compilation with it.#2022-02-0414:26MariusHi all! I just setup TailwindCSS, which is parsing the ShadowCLJS’s app.js to figure out which CSS classes have been used, but can not extract some class names because instead of quotes the app.js contains escaped unicode characters `\x22`  like this: `\x22flex justify-between items-center border-b-2 border-gray-100 py-6 md:justify-start md:space-x-10\x22` . Did anyone experience the same issue?#2022-02-0414:42MariusI found a workaround: Adding an empty space at beginning and end of the class string did the trick. Before: [:nav {:class "hidden md:flex space-x-10"} After: [:nav {:class " hidden md:flex space-x-10 "} @thheller I wonder if there is some setting which would make class names automatically recognizable?#2022-02-0415:15thhellerI've never seen that? which is the JS like this?#2022-02-0415:15thhelleroh wait you are talking about a development watch build I assume?#2022-02-0419:15Mariusyes, exactly#2022-02-0419:16Mariusthe file is ./target/cljsbuild/public/js/app.js#2022-02-0421:55thhellerfor development builds the code uses eval to load the sources. thats why you see the \x22#2022-02-0421:56thhellerfor development you should be pointing tailwind at the cljs-runtime dir. those are normal files with the proper strings#2022-02-0421:56thhellertarget/cljsbuild/public/js/cljs-runtime that is#2022-02-0421:56thhellerfor release builds you can point it at just the app.js#2022-02-0422:01thhellerhttps://github.com/jacekschae/shadow-cljs-tailwindcss you can follow this setup#2022-02-0423:22isakIn our setup we just create the whitelist manually, because last time I checked tailwind / purgeCSS doesn't know about the reagent class syntax. If you use reagent, you'll need to change some values for that to work out too, e.g., w-1.5 -> w-1*5#2022-02-0505:26thhellerw-1.5 is not a valid classname. I generally just keep everything in :class "..." and don't use :div.class at all#2022-02-0520:27Mariuscool, thanks @thheller for the quick support!#2022-02-0715:36isakw-1.5 is a valid classname, it is just that div.w-1.5 is not valid reagent syntax (that is why we changed it). See the docs here to see w-1.5: https://tailwindcss.com/docs/width#2022-02-0716:54thhelleroh 😛#2022-02-0418:58LeifI'm debugging an issue related to :optimize-constants that I think I've bisected down to 2.15.13 (`2.15.12` and before seem to work fine, 2.15.13 and after seem to have the issue). In particular, after 2.15.13, many keyword constants in the code seem to not be assigned. Some keywords (like var cljs$cst$keyword$shouldComponentUpdate=new cljs$core$Keyword(null,"shouldComponentUpdate", "shouldComponentUpdate",1795750960)) are properly created once and all callsites properly reference this global cljs$cst$keyword$XXXXXXXX var, others (like new cljs$core$Keyword(null,"body","body",-2049205669)) are created new every time. Has anyone observed anything similar to this before? Appreciate any help.#2022-02-0419:00thheller@leiferiksonventures is :body maybe only used in one place? maybe the closure compiler is trying to be too smart for its own good?#2022-02-0419:01thhellerclosure compiler as an optimization might inline the new call to safe the var. that would be my only guess?#2022-02-0419:02Leif@thheller In this case, :body is used 36 times. My most extreme example is :recur (due to plenty of cljs.core.async), which is allocated at 3560 callsites as new cljs$core$Keyword(null,"recur","recur",-437573268).#2022-02-0419:03thhellerit should inline all of them but :optimize-constants is not a thing in shadow-cljs so maybe something else is going on?#2022-02-0419:04thhellerconstants are optimized as a compiler pass during optimizations. not by the cljs compiler#2022-02-0419:04thhelleryou may also try :compiler-options {:shadow-keywords true}. that optimizes them a little more#2022-02-0419:09LeifJust checked :shadow-keywords and still have the same issue (some keywords are fine, others are repeatedly reallocated). I did see that 2.15.13 bumped the cljs / closure compiler versions (https://github.com/thheller/shadow-cljs/commit/7fefe5b3f604ff11d33539e4899e160dd1ff6eb0) -- maybe that's where the issue lies.#2022-02-0504:52thhellerhmm indeed. I also see this now. I'll look into it#2022-02-0504:55thhellerhttps://github.com/thheller/shadow-cljs/issues/982#2022-02-0609:02thhellershould be fixed in 2.17.0. thanks for the report. there really should be a test for this. went unnoticed for too long.#2022-02-0609:02thhellerfun thing was that the replacement was working totally fine except that some keywords have a precomputed numeric negative hash#2022-02-0609:02thhellerand the compiler pass was only looking for numbers#2022-02-0609:03thhellerand some time ago the closure compiler changed how they represent negative numbers in the AST#2022-02-0609:03thhellerso some keywords/symbols would still be replaced while others were not#2022-04-1317:05LeifWow -- excellent. Thank you for the update. Nice find. Tricky bug too.#2022-04-1317:37LeifI also see that the latest version of shadow-cljs fixes the issues I was having with Material UI (that was keeping me on ES5 output v.s. ES6 output). Thank you! Very awesome.#2022-02-0419:20jimmySo, I am looking at including some cljs in a js web app. I looked at various targets most importantly :npm-module, and :esm. I read a bunch of issues about various tradeoffs. Was unsure what to pick. But a coworker of mine just tried target :browser and loading that into webpack works perfectly fine. Maybe I'm missing it, but it seems like from the documentation that isn't what I'd expect. It seems like those other targets are there to make it work with existing js apps. Now there was one limitation, I couldn't control exports at a fine-grained level, just exporting whole namespaces. Adding a simple little js with some imports and re-exports fixed that all though. So I guess my question is, am I missing something? Is there a reason I shouldn't use target browser + a shim to do this? Is this something that just happens to work but might break in the future? Could target :browser add an exports like esm and make it work with existing js stuff without the nested namespace object?#2022-02-0419:32dpsuttonwe use :npm-module for metabase. • shadow-cljs.edn: • exported var: • imported into js: • webpack: and #2022-02-0419:36jimmyYeah, ran into issues with "goog.promise" is not found that I never dug into on :npm-module. Also the talk of deprecation made me a bit hesitant. Thanks for the links though 🙂#2022-02-0419:37dpsuttonyeah i don’t have much more on tradeoffs but if you want to consult how it works for us its all open#2022-02-0504:49thheller:npm-module is best for integration with other tools currently. :browser by default will bundle all JS dependencies on its own in a way that webpack can't see. so you'll end up with duplicated ones such as react for example#2022-02-0504:50thhelleralthough I regret some of the :npm-module design it'll likely stay as is#2022-02-0505:19jimmyAhh, got ya. I will definitely try to figure out the issues we were having with :npm-module. Right now, that limitation isn’t too big of a deal for us though, we don’t have dependencies in common with the js project. But that will probably change over time. Glad to hear that :npm-module will stay put. Makes me feel better about using it.#2022-02-0422:08Aleedwhy do browser builds take so much longer to compile compared to react-native builds? At first thought it was standard cljs->js compilation but if the native builds are much faster for same app must be other reasons#2022-02-0504:51thhellerdefine "so much longer"? browser builds bundle JS so if you include 5000 npm deps that'll take a while. react-native does not bundle since metro will be doing that, so technically you have to add the metro time.#2022-02-0514:12AleedOh ok that makes sense. Since react native libraries ship their JS already transpiled. Does shadow cache npm dep bundling or is there concerns against that? #2022-02-0515:15thhellerits cached yes#2022-02-0517:24Aleedhm to be clear - i meant on initial build, is the cache used or are packages compiled just incase?#2022-02-0518:13thhellernot sure which cache you are refering to. there is none on initial build.#2022-02-0518:13thhelleryou have given me no data to comment or know what you are talking about#2022-02-0518:13thhellerso please provide more data if you have more questions#2022-02-0518:14thhellerlike actual build time, files in build, etc#2022-02-0518:24AleedIm not diagnosing a specific issue, was asking a general question. My main q was answered above so thanks, and will follow up w more data if I notice anything that can be fixed #2022-02-0518:26thhelleryes, I'd like to answer. but you haven't given me any details on how your build actually takes and if by react-native you mean :target :react-native in shadow-cljs or react-native alone#2022-02-0518:26thhelleralso you have not defined "so much longer"? what does that mean? for some people 1sec is "so much longer". for some it is 30sec. I don't know and can't answer.#2022-02-0518:29AleedYes sorry about ambiguity as I know you're always assisting with questions and lack of context doesn't help. Next time I give my project a run (on mobile now) I'll check and see if anything's worth reporting #2022-02-0518:32Aleed(For above I meant target :react-native versus :browser, yes. Can't remember build times but it was fresh project)#2022-02-0422:16Aronit's javascript#2022-02-0513:45shivekkhuranaI'm trying to patch a js dependency in node_modules folder. Is it possible to make shadow-cljs reload when changes are made to dist files of a package in node_modules ?#2022-02-0515:13thheller@shivekkhurana you can touch node_modules/that-package/package.json to make shadow-cljs reload it#2022-02-0515:22shivekkhuranaI found this solution in the history. Someone asked this question on 2019.#2022-02-0515:22shivekkhuranaThanks !#2022-02-0604:10shivekkhuranaI found a hacky way to live reload node_modules folder on change. I have added the package path to :paths in config. And instead of using it as @pkg/name is use it as /@pkg/name . This forces shadow to treat it as source code and perform HMR on change.#2022-02-0606:53thhellerthat is a terrible idea. do not do that 😛#2022-02-0713:13shivekkhuranalol I just do that in dev mode, and then turn it back to @pkg/name (drop the /).#2022-02-0609:35ribelo
require() of ES Module /home/ribelo/code/alzey/node_modules/node-fetch/src/index.js from /home/ribelo/code/alzey/build/alzey.js not supported.
this is the first time I have encountered such a problem
#2022-02-0609:35thhellerthats a node error, not a shadow-cljs error#2022-02-0609:35ribeloah#2022-02-0609:35ribelosry#2022-02-0609:36thhelleryeah, it'll become more frequent as more node packages move over to ES. kinda annoying.#2022-02-0609:37ribeloany quick workaround?#2022-02-0609:37thheller"quick" would be changing the node-fetch version to one that has the commonjs files#2022-02-0609:38thhellerotherwise there is no "quick" solution, as moving to :target :esm may have all sorts of other challenges 😉#2022-02-0609:39ribeloas usual there's a catch, damn it, I could have been a carpenter#2022-02-0612:56Aronor gardener, that's what I would like to be, I could blame the weather for everything#2022-02-0614:30AleedSo latest version of react navigation (for react native) checks whether a component’s fn name is capitalized. The issue is that even if I capitalize the component, the namespace name is being appended. e.g. Home becomes myapp.Home Can anyone think of a workaround for this? Not sure if shadow-cljs or clojurescript handles this, and if proper avenue would be to find a solution in cljs or open up issue / fork library#2022-02-0614:31Aleedfor clarity, the problem is that if a component’s name is capitalized, device gets lots of warnings about improper naming#2022-02-0617:14thhellersounds like a question for reagent or whatever other react wrapper you are using#2022-02-0617:14thhellernot sure how react-navigation is checking the names. functions don't have names usually.#2022-02-0617:16AleedI'm using my own wrapper so I have full control. They're checking via fn.name, which is read only, unfortunately. (I'm setting the fn.displayName appropriately) #2022-02-0617:17thhellerfn.name won't even exist in release builds so I don't know what this check is supposed to do#2022-02-0617:18Aleedit’s a built-in property https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#2022-02-0617:19AleedI may open an issue in react navigation to request they check the displayName and fallback to the function name#2022-02-0617:20thhellerI know it is a built-in property. Just saying that the closure compiler will optimize that name away. so turns function whatever() to function () if the name is never directly used#2022-02-0617:20thhellersince it can't see what react-navigation is using it most likely will optimize it away#2022-02-0617:21thhellerchecking whether a function name is capitalized sounds absolutely silly to me. can't you just turn off that check? whatever it is meant to do?#2022-02-0617:21Aleedfor context. in development this is an example error I see
Got a component with the name 'app$client$mobile$app$register_screen' for the screen 'Register'. React Components must start with an uppercase letter. If you're passing a regular function and not a component, pass it as children to 'Screen' instead. Otherwise capitalize your component's name.
#2022-02-0617:21Aleedbut yes i agree it’s silly and fix should be with library#2022-02-0617:24thhellerand what is that message supposed to tell me?#2022-02-0617:33Aleedoops, it got trimmed. fixed above. they use the check to ensure that a prop is indeed a component, as that is the convention used in js land. the outputted name is akin to the way cljs compiler outputs variables so I know that’s being done somewhere in build process. I was looking to see if there was any hacks to work around this, but i’m going to open issue w react navigation for a proper fix#2022-02-0619:34thhelleryeah that seems like an annoying warning. can't think of anything to change this on the CLJS side#2022-04-2801:18bringeI ran into this today too. In case anyone else has this issue and finds this, I did this to remove the warnings:
(set! js/console.warn
      (fn [message]
        (when-not (str/includes? message "React Components must start with an uppercase letter.")
          (js/console.warn message))))
#2022-04-2805:04thhellerehm doesn't that end in a infinite loop? calling itself all over again? should save a reference to the old js/console.warn somewhere?#2022-02-0712:07djanushey! is there a way to specify different :compiler-options (specifically :closure-defines) for dev vs release builds?#2022-02-0712:16Ryan JerueCan’t you just have different entries under :builds in shadow-cljs.edn?#2022-02-0712:34djanusI could, but then one would be dev-only and the other release-only, and it’d be great to prevent mixing them wrongly#2022-02-0716:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2022-02-0721:35djanusglorious! thank you so much Thomas, I don’t know how I overlooked it 🙂#2022-02-0809:37byrongibbyHi. I am trying to use d3.js, but I can't seem to import it correctly
(ns tech.coderaanalytics.d3test.views
  (:require ["d3" :as d3]))
Returns the following in the browser console
#2022-02-0809:39thhellerwhat is the rest of the error?#2022-02-0809:39thheller(chrome displays these errors better than safari/firefox)#2022-02-0809:45byrongibbyFrom Chromium:#2022-02-0809:47byrongibbyOn refresh:#2022-02-0809:59thhellerok the regeneator stuff is the cause#2022-02-0810:00thhelleryou need to add a "regenerator-runtime/runtime" to your ns :require just before requiring the d3 stuff#2022-02-0810:00thheller
(ns tech.coderaanalytics.d3test.views
  (:require ["regenerator-runtime/runtime"]
            ["d3" :as d3]))
#2022-02-0810:01thhellermaybe npm install regenerator-runtime#2022-02-0810:26byrongibbyWill try]#2022-02-0810:29byrongibbyYep that solved it! Thank you very much for your time, shadow-cljs is awesome#2022-02-0809:40byrongibby#2022-02-0809:42thhellerhmm thats werid. which shadow-cljs version is this?#2022-02-0809:43byrongibby/cdn-cgi/l/email-protection#2022-02-0809:46thhellerhmm yeah upgrade that. that error message should be better, or just go away 😉#2022-02-0809:47byrongibbyWill try this, thanks!#2022-02-0809:51byrongibbySame error with {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "ee9d868f8a8199c38d82849daedcc0dfd9c0de"}, :content ("[email protected]")} I am going to try create a new project from scratch and see if I can reproduce this problem.#2022-02-0809:58thhellerthe error didn't get better?#2022-02-0809:58thhellerthe error message at least should have changed?#2022-02-0809:59thhellernvm, other thread#2022-02-0810:25byrongibbyNo change as far as I can see#2022-02-0810:30byrongibby#2022-02-0810:30byrongibbySolved the problem#2022-02-0810:30byrongibby😁#2022-02-0813:11wombawombaIs there a way to output multiple builds with different conditionals/reader features to the same directory?#2022-02-0813:14wombawombaAFAICT it's not possible to specify per-module compiler options, nor to specify a specific output path for a module without renaming it.#2022-02-0813:15wombawombaThe only option I can think of would be to have duplicate build targets where the module names are different; but that'd mean I'd have to duplicate all (non-module) config, which seems a bit ugly (and also I'd run into problems with the different targets overwriting one anothers' manifest.edn files).#2022-02-0814:17staskHi Trying to use :karma target and getting Uncaught ReferenceError: global is not defined if i use npx shadow-cljs compile test && npx karma start --single-run works fine if i use release: npx shadow-cljs release test && npx karma start --single-run Am i missing anything? The relevant part of shadow-cljs.edn is :
:test    {:target           :karma
            :output-to        "out/karma-test.js"
            :compiler-options {:source-map true}
            :autorun          true}}
Thanks
#2022-02-0818:32thhellerdepends on where the global access is coming from. if code you use uses global then you need to change that I guess#2022-02-0821:17staskthanks @U05224H0W any idea how to debug it? the full error i’m getting if i use npx shadow-cljs compile test is
❯ npx karma start --single-run
08 02 2022 23:13:39.899:INFO [karma-server]: Karma v6.3.15 server started at 
08 02 2022 23:13:39.902:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
08 02 2022 23:13:39.906:INFO [launcher]: Starting browser ChromeHeadless
08 02 2022 23:13:41.448:INFO [Chrome Headless 98.0.4758.80 (Mac OS 10.15.7)]: Connected on socket 63bK4JwP5wscOyTgAAAB with id 826372
Chrome Headless 98.0.4758.80 (Mac OS 10.15.7) ERROR
  Uncaught ReferenceError: global is not defined
  at karma-test.js:8:15

  ReferenceError: global is not defined
      at karma-test.js:8:15
So it happens in the very beginning of the karma-test.js, the relevant part is:
1   │ var shadow$provide = {};
   2   │ var $jscomp = {};
   3   │ var CLOSURE_NO_DEPS = true;
   4   │ var CLOSURE_BASE_PATH = 'js/cljs-runtime/';
   5   │ var CLOSURE_DEFINES = {"goog.DEBUG":true,"goog.LOCALE":"en","goog.TRANSPILE":"never","goog.ENABLE_DEBUG_LOADER":false};
   6   │ var COMPILED = false;
   7   │ var goog = goog || {};
   8 * │ goog.global = global;
   9   │ goog.global.CLOSURE_UNCOMPILED_DEFINES;
  10   │ goog.global.CLOSURE_DEFINES;
Basically before it gets to my code
#2022-02-0821:46thhellerhmm odd. haven't looked at karma in years. maybe it used to have global but no longer?#2022-02-0907:30staskWill try to debug it, thanks What framework would you recommend for CI tests nowadays? Something that works well with shadow-cljs?#2022-02-0907:31thhellerpersonally I run tests in node. but I don't do any tests for frontend ui code#2022-02-1212:27staskJust to close the loop: Setting :output-feature-set to :es6 helps:
{:target           :karma
 :output-to        "out/karma-test.js"
 :compiler-options {:source-map         true
                    :output-feature-set :es6}
 :autorun          true}
#2022-02-1215:09thhellerthat is the default nowadays? which shadow-cljs version do you use?#2022-02-1315:19staskJudging by the code in shadow.build.targets.karma/configure it’s set to :es8 unless explicitly specified. So, i just specified :es6 in my config and it worked.#2022-02-1315:21thhellerdid you try again without setting that? I don't see how that has any effect on what global is?#2022-02-1315:30staskNot sure what was going on there. Removed the :output-feature-set key and it still works, Line 8 looks different from the time when it didn’t work
1   │ var shadow$provide = {};
   2   │ var $jscomp = {};
   3   │ var CLOSURE_NO_DEPS = true;
   4   │ var CLOSURE_BASE_PATH = 'js/cljs-runtime/';
   5   │ var CLOSURE_DEFINES = {"goog.DEBUG":true,"goog.LOCALE":"en","goog.TRANSPILE":"never","goog.ENABLE_DEBUG_LOADER":false};
   6   │ var COMPILED = false;
   7   │ var goog = goog || {};
   8 * │ goog.global = this || self;
   9   │ goog.global.CLOSURE_UNCOMPILED_DEFINES;
  10   │ goog.global.CLOSURE_DEFINES;
#2022-02-1315:31staskAnyway, sorry for false alarm#2022-02-0815:24SimonShadow-cljs optimizes the keys from this object. So that when i send this object to the backend it has key names like “Pq” instead of “success_url”#2022-02-0815:25Simonpayment.js
const docRef = await db
    .collection('customers')
    .doc(firebaseapp.auth().currentUser.uid)
    .collection('checkout_sessions')
    .add({
      price: 'price_XXXXXXX',
      success_url: window.location.origin,
      cancel_url:
        window.location.origin + '/logout',
    });
#2022-02-0815:27SimonI include the JS file like this: index.cljs
(ns app.components.user.index
  (:require
   ["antd" :refer (Avatar Button Dropdown Menu Skeleton Spin)]
   ["@ant-design/icons" :refer (LoadingOutlined)]
   [reagent.core :as r]
   ["firebase/compat/app" :default firebase]
   [app.helpers.macros :refer [if-let-n]]
   ["./payment" :refer (onAuth openCheckout openCustomerPortal onActiveSubscription)] <---- imports
   [re-frame.core :as rf]
   [cljs.core.match :refer [match]]))
#2022-02-0815:28SimonOptions: 1. don’t do optimizations on the payment.js file. How? 2. don’t do optimizations on the keys of this specific object. How?#2022-02-0815:41Simon Problem solved: Use string keys, since they don’t get optimized. payment.js
const docRef = await db
    .collection('customers')
    .doc(firebaseapp.auth().currentUser.uid)
    .collection('checkout_sessions')
    .add({
      "price": 'price_XXXXXXX',
      "success_url": window.location.origin,
      "cancel_url":
        window.location.origin + '/logout',
    });
#2022-02-0818:32thhelleryeah, string keys or externs#2022-02-0912:34SimonI am having more problems with this file getting minified renaming things. Defining externs doesn’t help. I tried :infer-externs and :externs:
:builds
 {:app {:target :browser
        :asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :devtools {:http-root   "public"
                   :http-port   3001
                   :preloads    [day8.re-frame-10x.preload]}
        :compiler-options {:externs ["/app/components/user/payment.js"]
                           :infer-externs :auto}
        :dev
        {:compiler-options
         {:closure-defines
          {re-frame.trace.trace-enabled?        true
           day8.re-frame.tracing.trace-enabled? true}}}
        :release
        {:build-options
         {:ns-aliases
          {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
        :js-options {:ignore-asset-requires true}}
#2022-02-0819:24agI need to contain all the front-end dependencies inside shadow-cljs.edn (to separate them from other lein deps), but I still want to call shadow.cljs.devtools.server and shadow.cljs.devtools.api from Clojure REPL. I tried leaving all the front-end deps in shadow-cljs.edn, and added only thheller/shadow-cljs to project.clj. But it doesn't compile my stuff. It keeps complaining about missing dependencies. What I am missing?#2022-02-0819:33agIt works when I do it outside of REPL i.e., npx shadow-cljs compile :app, but when I do it from within the REPL, like so:
(require '[shadow.cljs.devtools.api :as shadow])
(require '[shadow.cljs.devtools.server :as server])
(server/start!)
(shadow/compile :app)
it fails to find required namespaces
#2022-02-0819:38thhellerdependencies are managed in the process you are launching shadow-cljs in#2022-02-0819:39thhellerso if you use lein to start you REPL then your dependencies are managed there#2022-02-0819:39thhellershadow-cljs.edn dependencies don't apply then#2022-02-0820:38agYah, this makes sense now. I guess I'm gonna have to start cljs REPL in a separate process now#2022-02-0912:34SimonI am having more problems with this file getting minified renaming things. Defining externs doesn’t help. I tried :infer-externs and :externs:
:builds
 {:app {:target :browser
        :asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :devtools {:http-root   "public"
                   :http-port   3001
                   :preloads    [day8.re-frame-10x.preload]}
        :compiler-options {:externs ["/app/components/user/payment.js"]
                           :infer-externs :auto}
        :dev
        {:compiler-options
         {:closure-defines
          {re-frame.trace.trace-enabled?        true
           day8.re-frame.tracing.trace-enabled? true}}}
        :release
        {:build-options
         {:ns-aliases
          {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}
        :js-options {:ignore-asset-requires true}}
#2022-02-0904:50berkeleytrueIs anyone using shadow-cljs with some sort of task runner? I was hoping to use one command to run the build/watch and then run my nodescript outputted by shadow-cljs. I'd normally do this with GulpJS. Are people using tools.deps to do this?#2022-02-0904:52berkeleytrueI have a two part project (server and cli), it would be cool to run the build for both in parallel and start cli/server files so I can connect to their js runtimes for repl use.#2022-02-0907:07thhellernpm-run-all as setup in this project is what I usually use https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/package.json#2022-02-0907:08thhellerhttps://www.npmjs.com/package/npm-run-all#2022-02-0916:45berkeleytrueThanks. I haven't heard of it. Seems like I wouldn't be able to get the outcome I wanted for target node-scripts since I need to wait until the build completes before running the script. That is a good workflow for a browser app, though.#2022-02-0909:55p-himikWhat could be the cause of a situation where shadow-cljs does not complain about a missing ^js but that tag not being present still results in an incorrectly minified name? My guess is that name was used in e.g. Closure library. Are there any other potential causes?#2022-02-0909:56thhellerdon't know. what kind of form is it?#2022-02-0909:57thheller(set! *warn-on-infer* false) turns everything off, just in case that is in the file?#2022-02-0909:59p-himikNo, I never use that set!. Here's the code, with some crud removed:
(defn replace-track-source! [^js playlist track-name src]
  (loop [tracks (.-tracks playlist)]
    (when-first [track tracks]
      (if (= (.-name track) track-name)
        (do
          (-> (to-audio-buffer src playlist)
              (.then (fn [audio-buffer]
                       (set! track -src audio-buffer)
                       (.setBuffer track audio-buffer)))))
        (recur (next tracks))))))
:advanced renamed .setBuffer.
#2022-02-0910:04thhellerhmm dunno. it doesn't warn about anything that already has externs, setBuffer seems like it may exist#2022-02-0910:04thhelleryou sure its actually that thing getting renamed? I mean actually confirmed with :pseudo-names?#2022-02-0910:05p-himikYep, did a release build with --debug - it became .$setBuffer$. Adding ^js in front of track in the when-first form fixes that.#2022-02-0910:06p-himikCan you give me some pointers on how I should debug this in shadow-cljs?#2022-02-0910:07thhellerin the .shadow-cljs/builds/app/release dir should be a externs txt file#2022-02-0910:07thhellerthat includes all the externs generated for the build#2022-02-0910:08thhellerfirst confirm setBuffer is actually not in there#2022-02-0910:08thhellerthen you can use
:build-hooks
   [(shadow.build/tap-hook)]
in your build config
#2022-02-0910:08thhellerthat will only send a tap to the inspect UI#2022-02-0910:09thhellerthat'll be the entire build-state, so you can check the externs there too#2022-02-0910:11thheller:compiler-env -> :cljs.analyzer/namespaces -> your.ns -> :shadow/js-* should contain it#2022-02-0910:19thhellerexterns inference happens mostly in the cljs compiler. so maybe try with the regular CLJS compiler too#2022-02-0910:24p-himikYep, it's neither in the externs file nor in the inspect UI. Some other fields are also not in the inspect UI - I suspect because they were first picked up in some other ns? E.g. .then is not there, even though it definitely works, but .resolve is there.#2022-02-0910:34thhellerthere are other places where externs are stored#2022-02-0910:35thheller.then is definitely in the default externs#2022-02-0910:36p-himikBut not .resolve? Huh.#2022-02-0910:37thhellerresolve is usually Promise.resolve so why would there be a generic .resolve?#2022-02-0910:38thhellerat least I can't think of a generic .resolve?#2022-02-0910:38thhellerif closure knows the type of something then is can be more specific with externs#2022-02-0910:41p-himikMy understanding of externs is very limited indeed. :) I see. Anyway, I'll try to stumble around with a proper debugger and see what I can find.#2022-02-0912:31p-himikSeems like indeed a CLJS issue - the tags returned for track by the analyzer are any and clj-nil.#2022-02-0912:40p-himikAh, crap. Pretty sure I figured it out. Notice that when-first - it gets expanded into essentially (let [track (first (seq tracks))] ...). And seems like that seq makes CLJS analyzer forget about the ^js tag.#2022-02-0913:14SimonWhen setting :compiler-options {:externs ["/app/components/user/payment.js"] i get this:
[:app] Compiling ...
[BABEL] Note: The code generator has deoptimised the styling of /Users/simonchristensen/Documents/Developer/movenation/calculator/node_modules/@firebase/firestore/dist/index.esm2017.js as it exceeds the max of 500KB.
{:type :missing-externs, :extern "/app/components/user/payment.js", :shadow.build.log/level :warn}
{:type :missing-externs, :extern "/app/components/user/payment.js", :shadow.build.log/level :warn}
[:app] Build completed. (3727 files, 3616 compiled, 0 warnings, 95.37s)
#2022-02-0913:40Simonfixed by removing / prefix: :compiler-options {:externs ["app/components/user/payment.js"]#2022-02-0913:40SimonBut now this file is not supported since, the js version used is too new:
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 1 : 0
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 2 : 0
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 5 : 0
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: object destructuring. at EXTERNS:app/components/user/payment.js line 5 : 6
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 6 : 0
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: const declaration. at EXTERNS:app/components/user/payment.js line 7 : 0
JSC_LANGUAGE_FEATURE. This language feature is only supported for ECMASCRIPT_2015 mode or better: modules. at EXTERNS:app/components/user/payment.js line 9 : 0
#2022-02-0916:05thhellerwhat does that mean js version used is too new? there is no point in using new features in externs?#2022-02-0916:05thhelleryou can't just feed it the normal code? that is not what externs are.#2022-02-0918:22isakFor the :browser-test target, is there any way to influence the path it uses in the index.html file? <script src="/js/test.js"> (I mean the /js/test.js there, I'd like to change that path) I tried setting :asset-path, like one would for the :browser target, but that was ignored.#2022-02-0918:24thhellershould be fine? I mean changing it in the html + asset-path?#2022-02-0918:58Christopher GenoveseI've got a library with the :node-library target that has one basic interface point between the clojurescript and javascript worlds. I use a deftype with Object methods to provide the javascript-side interface, e.g.,
(deftype Mediator
  Object
  (opA [this] ...)
  (opB [this in] ...)
  ...)
When done this way, I get the Cannot infer target type warnings on the deftype expression. I set :infer-externs :auto in compiler options, which does not fix the warnings. The warnings do go away when instead when I do deftype ^js Mediator, but that turns the Mediator type into a POJO requiring js-style operations on the object inside the methods (e.g., set! works but not assoc). This is fine, and I can live with it. I am curious, however, about best practices for this use case. What is the best way to create a javascript object interface to clojurescript code with shadow-cljs? Will the javascript methods (e.g., opA and opB ) be externed properly this way under advanced compilation? And is it necessary to make the mediating type a mutable POJO or is it possible to have clojurescript data that is treated as an opaque object on the javascript side? I'd appreciate hearing what other people do in this situation. Thanks!
#2022-02-0919:00thhellerthis really is hard to answer if you take out the part generating inference warnings?#2022-02-0919:00thhellerthe above snippet should be fine?#2022-02-0919:05Christopher Genovese@thheller (assuming you are answering me, please disregard if not) Do you mean that the first deftype (without ^js) should not generate inference warnings?#2022-02-0919:08Christopher GenoveseI would add that the inference warnings are still emitted even if I treat the this as a POJO in the methods.#2022-02-0919:10isak@thheller oh, I thought it would get overwritten constantly. Sounds good.#2022-02-0920:19thheller@genovese you have given only partial of the code and the error message so I do not know what you are talking about. you get an inference warning on what exactly?#2022-02-0920:19thhellerwhat does "deftype ^js Mediator, but that turns the Mediator type into a POJO requiring js-style operations on the object" mean? I do not understand what that means?#2022-02-0920:20thhellerdo you mean deftype vs defrecord?#2022-02-0920:25thhellerdeftype with Object methods are completely fine but without knowing more about what exactly you are doing its hard to give a accurate answer#2022-02-0920:32Christopher GenoveseSorry. First, here's an example of the message:
26 | (deftype Mediator [frame options env]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. MathLingo -prototype) -render)
--------------------------------------------------------------------------------
  27 |   Object
  28 |   (render [this]
  29 |     (str "TBD" (process frame))))
With ^js, there inference error goes away. On the second point, you're right, my mistake. I did a deftype here, not a defrecord. I had done it earlier with defrecord and then changed it with the type hint but foolishly ignored that (even as I typed it), so of course assoc no longer worked. Apologies. The remaining questions are why is the ^js needed, and is there a better way to achieve this goal than what I'm doing here. Thanks!
#2022-02-0920:33thhelleruhm I'm confused. deftype Mediator but (. MathLingo -prototype)?#2022-02-0920:34Christopher GenoveseSorry, name changed. Should be (. Mediator -prototype). Not really on my game today 🙂#2022-02-0920:35thhellermaybe you are on an old shadow-cljs or clojurescript version?#2022-02-0920:37Christopher GenoveseHmm...not sure what to make of that. Here's my config
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[better-cond             "2.1.0"]
  [binaryage/oops          "0.7.0"]
  [camel-snake-kebab       "0.4.2"]
  [data.deque              "0.1.0"]
  [instaparse              "1.4.10"]
  [metosin/potpuri         "0.5.3"]
  [com.rpl/specter         "1.1.3"]
  [net.cgrand/xforms       "0.19.2"]
  [org.clojure/algo.monads "0.1.6"]
  [org.clojure/core.match  "1.0.0"]
  [org.clojure/test.check  "1.1.1"]]

 :builds
 {:main {:target :node-library
         :output-to "out/mathlingo.js"
         :exports {:createParser mathlingo.core/create-parser}
         :compiler-options {:infer-externs :auto}
         :devtools {:repl-pprint true}}
  :test {:target    :node-test
         :output-to "out/node-tests.js"
         :ns-regexp "-test$"
         :autorun   false}}

 :nrepl {:port 8777}

 :open-file-command ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}
#2022-02-0920:37thheller
(deftype Mediator [frame options env]
  Object
  (render [this]
    "TBD"))
#2022-02-0920:37thhellerthis is fine and produces no warnings for me#2022-02-0920:38Christopher GenoveseIt does not produce warnings for me at the repl, but when it compiles it does.#2022-02-0920:38thhellerI didn't try at the REPL#2022-02-0920:38thhellerwhich version of shadow-cljs? see npx shadow-cljs info#2022-02-0920:39Christopher Genovese2.6.12 What could I be doing differently? I can try it in a raw project, but I don't see what I can tweak otherwise.#2022-02-0920:40Christopher Genovese
=== Version
jar:            2.16.12
cli:            2.16.12
deps:           1.3.2
config-version: 2.16.12

=== Paths
cli:     /.../node_modules/shadow-cljs/cli/dist.js
config:  /.../shadow-cljs.edn
project: /...
cache:   .shadow-cljs

=== Java
openjdk version "15.0.1" 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
#2022-02-0920:40thhellerI don't know either. there is nothing to tweak. If you have a reproducible case I'm happy to take a look but so far this all looks fine#2022-02-0920:41Christopher GenoveseOK, thanks. I'll clear the cache and start again. And I'll assume all is ok. I appreciate the help.#2022-02-0920:42thhelleryou can always turn off inference warnings by (set! *warn-on-infer* false) before the deftype or so and turn it back on again after#2022-02-0920:42thhellerI do remember that I had a case where I had to do that myself#2022-02-0920:42thhellerbut I can't remember any details#2022-02-0920:45Christopher GenoveseGreat, that will be more pleasant if it continues.#2022-02-1014:25agoldI am trying to use instaparse in a shadow-cljs project. I have the following in shadow-cljs.edn: :dependencies  [[instaparse "1.4.10"]] The instaparse-1.4.10.jar is present in the appropriate .m2 repository. But shadow-cljs is not finding it. What am I doing wrong?#2022-02-1014:35jkxyzCan you share the error that you're seeing?#2022-02-1015:38agoldI found the problem, thanks.#2022-02-1015:41dpsuttonit is not. cider-jack-in-clj&cljs attempts to use the same process to start two separate repls. This was possible with figwheel. Shadow is a separate process so you cannot start a single lein and then create two repls from it, one clj and one cljs#2022-02-1016:47mamapitufohello, I'm relatively new to ClojureScript and I'm trying to set up tests for a ns that has a couple of functions. I'm using the recommended cljs.test setup from https://clojurescript.org/tools/testing and I can run my tests fine from the REPL using cljs.test/run-tests. I also followed the instructions in https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test but when I run shadow-cljs compile test on my terminal I get this exception:
shadow-cljs - connected to server
[:test] Compiling ...
NullPointerException: 
        shadow.build.node/configure (node.clj:59)
        shadow.build.node/configure (node.clj:45)
        shadow.build.targets.node-script/configure (node_script.clj:37)
#2022-02-1017:52thhellerlooks like you don't have a :output-to configured in your build config?#2022-02-1017:06p-himikThe article at https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html links to https://github.com/mhuebert/shadow-bootstrap-example for a standalone example. But building the :bootstrap build with shadow-cljs 2.17.0 (where originally it was 2.11.7) fails with:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/p-himik/.m2/repository/org/clojure/clojurescript/1.10.914/clojurescript-1.10.914.jar!/cljs/js.cljs:9:1
--------------------------------------------------------------------------------
   6 | ;   the terms of this license.
   7 | ;   You must not remove this notice, or any other, from this software.
   8 | 
   9 | (ns cljs.js
-------^------------------------------------------------------------------------
null
The alias env is already used for namespace cljs.env.macros
--------------------------------------------------------------------------------
  10 |   (:refer-clojure :exclude [require eval])
  11 |   (:require-macros [cljs.js :refer [dump-core]]
  12 |                    [cljs.env.macros :as env])
  13 |   (:require [clojure.string :as string]
--------------------------------------------------------------------------------
Presumably because cljs/js.cljs has both [cljs.env.macros :as env] in its :require-macros and [cljs.env :as env] in its :require. Is there a way to fix this?
#2022-02-1017:16p-himikHuh, it actually works with 2.16.12 but breaks with 2.17.0.#2022-02-1017:50thhelleruh yeah thats a bug#2022-02-1017:50thhellerI changed something in alias checks because of :as-alias#2022-02-1018:14Joseph WinstonThanks for verifying the bug. I was chasing the same issue earlier.#2022-02-1018:24thhellerhmm my check seems to be doing exactly what it is supposed to be doing? how is this ns form valid? it has env as alias for two different namespaces 😛#2022-02-1018:24thhellerguess I have to relax that check a bit ...#2022-02-1018:37thhellershould be fine in 2.17.1 again#2022-02-1018:40Joseph WinstonThank you.#2022-02-1020:54mauricio.szaboHi, any tips to debug this error?
shadow-cljs: reloading code but no :after-load hooks are configured! 
#2022-02-1020:54mauricio.szaboI do have the :after-load hook configured, and I can evaluate the function of the hook, but somehow nothing happens when I save a file. It's a :browser target, but with an Electron host
#2022-02-1106:24thhellerthis is a warning not an error and you fix it exactly as linked above#2022-02-1106:24thhellerwhere do you have :after-load configured? it is much easier to have ^:dev/after-load in the metadata of your code#2022-02-1106:25thhellercode that needs to be included in the build naturally. so if you put it in some namespace that is not part of the build it won't trigger#2022-02-1116:35mauricio.szaboI have in both metadata and in :devtools option. None worked#2022-02-1116:38thhelleronly one is needed#2022-02-1116:38thhellerbut as I said if the ns isn't included in the build they don't have any effect#2022-02-1116:38thhelleris it included in the build?#2022-02-1116:38thhellerneeds to be required by something in the build (or added via :preloads)#2022-02-1116:39mauricio.szaboThis is the config:
{:target :browser
                 :output-dir "static"
                 :asset-path "."
                 :modules {:main {:init-fn cljs.atom.view/start!}}
                 :js-options {
                              :keep-native-requires true}
                              ;:js-provider :require}
                 :devtools {:before-load cljs.atom.view/start
                            :after-load cljs.atom.view/after-load}}
#2022-02-1116:41mauricio.szabocljs.atom.view is in the config, and when I save the file, I see on Electron's console:
shadow-cljs: reloading code but no :after-load hooks are configured! 
browser.cljs:20 shadow-cljs: load JS cljs/atom/view.cljs
#2022-02-1116:41mauricio.szaboBoth hooks point only to a (println "testing") for now...#2022-02-1116:42thhellerthey appear to be in the wrong order?#2022-02-1116:43thhellerI mean it doesn't make sense to me triggering a start before loading new code?#2022-02-1116:43thhellerhelps if you show me the code?#2022-02-1116:43thhelleroh wait ...#2022-02-1116:44thhellercljs.* is reserved. no hooks in those are discovered or used#2022-02-1116:45mauricio.szaboAaaahhhh, ok!#2022-02-1116:45mauricio.szabofacepalm#2022-02-1116:49mauricio.szaboYep, that was it! Thanks again, as always! I'm doing something incredibly bizarre with ClojureScript, so I though it was something way more complicated than just the namespace name 😄#2022-02-1021:49agHow do you deal with other watchers, doing some work outside of shadow-cljs? For example, I'm using postcss, and I have an npm script task to compile/watch. I can run it in another shell session, not a problem. But that has a minor annoyance - whenever I make style-related changes, they do not reflect in the browser without a manual refresh. And I think what's happening is that shadow-cljs picks up changes first (when .cljs files with hiccup modified), and npm script process always lagging behind. I thought about maybe using ^:dev/before-load-async, but that's in a file on the browser side. Can I have something similar but in clj, not cljs?#2022-02-1106:25thhellerI use a setup using npm-run-all. as for example in this repo using postcss+tailwind#2022-02-1106:25thhellerhttps://github.com/thheller/shadow-cljs/blob/master/package.json#L4-L9#2022-02-1106:26thhelleralthough I only use it to run postcss itself. I run shadow-cljs separately but you could easily run it there too#2022-02-1106:26thhelleras for style related changes I added a new hook for that recently that is not in the docs yet#2022-02-1106:27thhellerhttps://github.com/thheller/shadow-cljs/commit/e9093aed586d5fb49efd94555787f0bef08fb164#2022-02-1106:28thhelleryou may just be missing some watch related config if you just have css that isn't getting reloaded in the first place yet#2022-02-1106:28thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2022-02-1115:58rende11@U05224H0W Hello Tomas, it works not only for css files, right? (I try to reload frontend after changes in .edn resources)#2022-02-1116:00thhellerno, thats not supported#2022-02-1210:00rende11@U05224H0W But why? It's not possible in current implementation or needless feature or no time to implement this functionality?#2022-02-1215:12thhellermostly because there are limits to what shadow-cljs can reasonably do. There is no easy way to tell which files you are going to access and tracking all of them might get expensive. dunno what you are doing this code .edn files but maybe this already solves whatever it is https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-02-1217:21rende11@U05224H0W Thanks for the answer. I use .edn files for translations (i18n) that's why I wanna reload frontend after some changes in them. I think it's a popular case. Isn't it? So you haven't any plans to extend this tracking?#2022-02-1218:18thhellerI have no plans but if you setup a demo repo I might consider it#2022-02-1218:18thhellernobody else ever asked for this. so can't be that popular#2022-02-1021:53agReading through the docs, perhaps I should look into the "build hooks"?#2022-02-1022:03agYup, it does look exactly what I'm looking for. I apologize for the noise.#2022-02-1116:29jplazaHi everyone! I’m trying to use aws-sdk-js-v3 but it seems to try to use nodejs modules. I’m currently getting:
The required JS dependency "http2" is not available, it was required by "node_modules/@aws-sdk/node-http-handler/dist-cjs/node-http2-handler.js".
#2022-02-1116:38thhellerwhy is it trying to use a node-http-handler?#2022-02-1117:00jplazaI noticed that, I was playing with these options to try to make aws-sdk to use the browser libs
:compiler-options {:infer-externs :auto
                      :output-feature-set :es6}
   :js-options {:provider :closure
                :entry-keys ["main" "module" "browser"]}}
#2022-02-1117:12ChaseIf I have a full stack app setup like `project/src/frontend/app/` and `project/src/backend/app` do I tell shadow-cljs that the src is in `src/frontend` and then leave `frontend` out of my namespaces like: `ns app.core` vs `ns frontend.app.core`? Or do you recommend still just declaring in my `shadow-cljs.edn` that `:source-paths ["src"]` ?#2022-02-1117:31thheller@jplaza you can set :js-options {:resolve {"http2" false}} in your build config. that will disabled that require. I'm guessing that'll just break stuff though. it shouldn't be using a node-http-handler for a browser build#2022-02-1117:32thheller@chase-lambert :source-paths ["src/frontend"], maybe this helps https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2022-02-1117:34jplaza@thheller thank you! I was able to build with that setting. Let me test things out now#2022-02-1117:58cjsauerHey all, I'm trying to use the :dev-http server with classpath:public to serve my SPA. The documentation reads: > By default these will serve all static files from the configured paths, and fall back to `index.html` when a resource is not found Everything is working fine when I just load the root of the site, but when I try any other path, eg /foo/bar I get a 404 with text Not found. Missing index.html. I do indeed have an index.html file in that public folder, and as I've said it works fine at the root address...#2022-02-1118:00cjsauerHm, changing my config to resources/public fixed it#2022-02-1118:00thhellerthat fallback only works for files, not the classpath#2022-02-1118:01cjsauerAh okay yep, just changed that and it works now#2022-02-1118:01cjsauerThanks#2022-02-1118:01thhellerI guess that could be fixed but currently it expects files#2022-02-1118:01cjsauerYea no worries. The file config works fine.#2022-02-1118:38AleedAre we able to define and consume macros in the same cljc file? For some reason my build was only compiling properly when the cljs macros were defined and used in separate files. So single file macro usage was failing:
;; myapp/ui.cljc
(ns myapp.ui
  #?(:cljs (:require-macros [myapp.ui])))

#?(:clj (defmacro defc []))


#?(:cljs (defc component []))
But splitting up the definitions and consumption got it working:
;; myapp/ui-macros.cljc
(ns myapp.ui-macros
  #?(:cljs (:require-macros [myapp.ui-macros])))

#?(:clj (defmacro defc []))

;; myapp/ui.cljs 
(ns myapp.ui
  (:require [my-app.ui-macros :refer [defc])

(defc component [])
Is this expected? Or could there be something wrong with my application code that may be worth trying to reproduce minimal example?
#2022-02-1119:34Braden ShepherdsonCLJS doesn't support macros. they need to be defined in a .clj file (or :clj slice in a .cljc file) since they are Clojure code that runs at compile time.#2022-02-1119:34Braden Shepherdsongenerally, put your macros into a separate .clj file and require it from your clj{s,c} file.#2022-02-1120:25thheller@alidcastano your cljc example looks fine. should work like that but writing .cljc is much harder and much easier to make mistakes. generally easier to have two files#2022-02-1210:21Lucy WangThe latest 2.17.1 throws me an error when I have a namespace aliased as foo and also refers to a foo symbol
(ns myapp.my-ns
  (:require [myapp.ns1 :as foo]
            [myapp.ns2 :refer [foo]]))

;; how i use them:
foo/var1 ;; resolves to myapp.ns1/var1
foo ;; resolves to myapp.ns2/foo
"Error: The alias foo is already used for namespace myapp.ns1" Reverting to 2.16.12 has no such issue.
#2022-02-1215:32thhelleroops, fixed in 2.17.2#2022-02-1501:15Lucy WangThanks Thomas!#2022-02-1211:44pezI need help figuring out how to configure dependencies when having three direct dependencies that all want different version of a transitive dependency. Specifically they all depend on different version of rewrite-clj. I naively thought this would just work, but it seems the three dependencies get to share the same version of rewrite-clj.#2022-02-1213:22pezI can almost get it to work by reordering the dependencies. But one of them is extra tricky. It doesn't even need rewrite-clj, because I am only really using rewrite-cljs ... Trying this, but it doesn't work:
[pez/cljfmt "0.0.5-SNAPSHOT" :exclusions [rewrite-clj]]
#2022-02-1215:05pezWait, I'm thinking about it in the wrong way, right? It is not so much the library name that clashes, it's the top namespace. Hmmm. Is a solution to let Leiningen handle deps and use mranderson?#2022-02-1215:08thhellereasiest way is to just configure the rewrite-clj version you need in your dependencies#2022-02-1215:09thhellerthat'll always win, no need to mess with exclusions and such then#2022-02-1215:41pezThe dependencies need different rewrite-clj implementations...#2022-02-1216:54pezI solved it by copying rewrite-cljs into my project and renaming the top-level ns. 😃#2022-02-1219:17AronDoesn't sound like a solution I would like to resort to.#2022-02-1219:19pezIt’s a special situation. rewrite-cljs is a frozen/archived library. #2022-02-1219:22AronBut how can it happen that the versions are so incompatible that different dependencies conflict because of it? I don't understand.#2022-02-1219:26pezIt’s a long story. #2022-02-1302:45alexHi there - I'm looking to implement server-side rendering and running into an issue because one of my NPM dependencies, firebaseui, utilizes the browser window object. When I require the dependency e.g. (:require ["firebaseui" :as firebaseui]) , shadow is unable to compile the build. Is there a way around this? Should I try to lazy-load the dependency so that I can check for js/window before bringing the dependency into the build? If so, is there a way to lazy-load the NPM module directly, or do I need to create a standalone module my-app.firebaseui that imports firebaseui , then lazily load my-app.firebaseui into the rest of my app? I'm going to try ^ and report back on how it goes#2022-02-1303:09alexIt seems like even if I add a check for js/window , then try to lazy-load a separate my-app.firebase module containing the firebaseui import, shadow-cljs is still unable to compile. I could definitely be doing something wrong here - would appreciate your input. Here's a simplified example of what I have:
;; shadow-cljs.edn

{:builds {:client {:module-loader true
                   :modules {:client {:entries [my-app.client]}
                             :firebaseui {:entries [my-app.firebaseui]
                                          :depends-on #{:client}}}}}

;;

(ns my-app.firebaseui
  (:require ["firebaseui" :as firebaseui])

(defn init-firebaseui [] ...)

;; 

(ns my-app.sign-in
  (:require [shadow.lazy :as lazy])

(when js/window 
  (lazy (lazy/loadable my-app.firebaseui/init-firebaseui) 
        (fn [init-firebaseui] (init-firebaseui))))
#2022-02-1308:06thhellerI made an example a while ago how you could move host specific requires to a namespace that is dedicated to a specific host (eg. browser and then one for node)#2022-02-1308:06thhellerhttps://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2022-02-1308:06thhellerthen you can have that require in the browser version but not the node#2022-02-1308:07thhellerso you'll need a second build regardless. :target :browser isn't meant to run on node#2022-02-1317:43alexInteresting, thanks! I'll give that a go#2022-02-1422:38alexIf I have some lazy-loaded modules in the :target :browser build, my Node build doesn't know that those modules exist. However, the Clojurescript compiler is still going to build the dependency tree and attempt to load those (undefined in Node) modules. As a result, my :node build is failing to compile due to an error with macroexpanding shadow.lazy/loadable on namespaces that don't have a module mapping. I believe the :modules config is specific to :browser builds and isn't supported for :node builds, so this seems to be expected behavior How should I approach making those modules compatible / ignoring those modules for the Node build? Is that something I should also handle via host-specific namespaces?#2022-02-1507:05thhellerThis is kinda hard to answer without knowing exactly how you are using all this and how you intend to do the server side render. You could use custom reader conditionals to eliminate any calls for shadow.lazy for example. https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2022-02-1515:46alexThanks for pointing me to that! I was hoping something like that was supported but apparently didn't search the docs extensively enough#2022-02-1401:57steveb8nexcluding tests using :ns-regexp is driving me crazy. I presume this is a jvm regex but I’m terrible at regex. how do I run all tests except those with the word “render” in the name? e.g. don’t include big-render-test#2022-02-1401:58steveb8nI’ve been trying it in the repl and I can make it work there using
(re-find #"^\b([a-z\-]+)\b(?<!render|ignoreme)-test" "first-render-test")
#2022-02-1401:58steveb8nbut that doesn’t work inside the shadow file#2022-02-1401:59steveb8nis there a recommended way to test these expressions in the REPL that will also work in shadow edn file?#2022-02-1403:02steveb8nfwiw. not complaining about shadow. just having a hard time testing regexes and then using them in CI#2022-02-1404:29Drew Verleeedit: nevermind it found it just found. If i add a dep to the devDependencies of package.json how do i declare i want that included in my shadow-cljs build? I have only ever used all dev deps.#2022-02-1405:37UlisesMACHi there! :) I want to get the logs from shadow-cljs that are showed in CLI when the compilation fails. Anyone knows if there is a var to get it? I tried to get them from the compiler state using build-hooks but I hadn't luck. I want to report them in the UI when using react-native.#2022-02-1406:52thhellersomeone built something like that before. can't remember who though. its all available via :devtools {:build-notify } whereas that points to a regular defn receiving on argument which is a map which is the same as this msg https://github.com/thheller/shadow-cljs/blob/8ef958f332c0e0648fd84eb2a3d5205602487f6b/src/main/shadow/cljs/devtools/client/hud.cljs#L263#2022-02-1407:11UlisesMACThanks!#2022-02-1406:53thhellermaybe you can figure out what you need out of that#2022-02-1409:10tianshuSometimes I ran into this error when compile
------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/tianshu/.m2/repository/org/clojure/core.async/1.3.618/core.async-1.3.618.jar!/cljs/core/async/impl/channels.cljs:23:3
--------------------------------------------------------------------------------
  20 | (deftype PutBox [handler val])
  21 | 
  22 | (defn put-active? [box]
  23 |   (impl/active? (.-handler box)))
---------^----------------------------------------------------------------------
null
ClassCastException: clojure.lang.KeywordLookupSite$1 incompatible with clojure.lang.Named
I'm sure I have only one jvm running. Everytime the error is different, but I've seen clojure.lang.KeywordLookupSite multiple times
#2022-02-1417:14thheller@doglooksgood that is the wrong core.async version. make sure you are using the version shadow-cljs is expecting. don't know which shadow-cljs version you are using but should likely be [org.clojure/core.async "1.4.627"]#2022-02-1417:26bringeHello. I want to share this message I posted in #cljsrn here to see if someone here might be able to share some knowledge about the issue. Thanks!#2022-02-1417:27bringeThere’s a video of the issue in that thread, and version details.#2022-02-1417:35Clement SanHello, i'm trying to integrate reagent-material-ui 5.2.4-0 with an app created with luminus (https://github.com/clementlefevre/luminus_reagent_material_ui) Seems that the @mui/x-data-grid": "5.2.0" does not load as expected : compilation with shadow-cljs watch app` runs fine, but when loading the page http://localhost:3000/#/about i get the following error :
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$material$node$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs @ index-cjs.js:3
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2782
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$x_data_grid$index_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2782
app.js:1455 TypeError: Cannot redefine property: ModalManager
    at Function.defineProperty (<anonymous>)
    at eval (index.js:2038:10)
    at Array.forEach (<anonymous>)
    at Object.shadow$provide.module$node_modules$$mui$material$node$index (index.js:2034:21)
    at shadow.js.jsRequire (js.js:66:18)
    at Object.shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs (index-cjs.js:3:118)
    at Object.shadow.js.jsRequire (js.js:66:18)
    at Object.shadow.js.require (js.js:113:20)
    at eval (reagent_mui.x.data_grid.js:2:62)
    at eval (<anonymous>)
reportError @ app.js:1455
env.evalLoad @ app.js:1565
(anonymous) @ app.js:2782
app.js:1457 The above error occurred when loading "reagent_mui.x.data_grid.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.
p-himik already provided a lot of https://clojurians.slack.com/team/U2FRKM4TW, unfortunately the error does still persist. any help would be helpful, as the perspective to switch back to bare javascript does not trigger any joy. Thanks a lot for your time ! Cheers, clement.
#2022-02-1417:39thheller@clement.san my guess would be that you are using the wrong version mix. ie. @mui/x-data-grid expecting a difference @mui/material version?#2022-02-1417:40thheller
"@material-ui/core": "4.11.3",
    "@mui/material": "5.2.4",
    "@mui/x-data-grid": "5.2.0",
#2022-02-1417:40thhellerisnt @mui/material the new "@material-ui/core"? why do you have both?#2022-02-1417:53Clement San@thheller Hallo Thomas, thanks for the feedback#2022-02-1417:55Clement SanI did adjust the package.json accordingly :
"dependencies": {
    "@emotion/react": "11.0.0",
    "@emotion/styled": "11.0.0",
    "@mui/material": "5.2.4",
    "@mui/x-data-grid": "5.2.4",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
and then npm install & shadow-cljs watch app leider still getting the same error in the dev tools :
shadow-cljs - failed to load module$node_modules$$mui$material$node$index
shadow.js.jsRequire @ js.js:74
shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs @ index-cjs.js:3
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2779
js.js:74 shadow-cljs - failed to load module$node_modules$$mui$x_data_grid$index_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ reagent_mui.x.data_grid.js:2
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2779
app.js:1455 TypeError: Cannot redefine property: ModalManager
    at Function.defineProperty (<anonymous>)
    at eval (index.js:2038:10)
    at Array.forEach (<anonymous>)
    at Object.shadow$provide.module$node_modules$$mui$material$node$index (index.js:2034:21)
    at shadow.js.jsRequire (js.js:66:18)
    at Object.shadow$provide.module$node_modules$$mui$x_data_grid$index_cjs (index-cjs.js:3:118)
    at Object.shadow.js.jsRequire (js.js:66:18)
    at Object.shadow.js.require (js.js:113:20)
    at eval (reagent_mui.x.data_grid.js:2:62)
    at eval (<anonymous>)
reportError @ app.js:1455
env.evalLoad @ app.js:1565
(anonymous) @ app.js:2779
app.js:1457 The above error occurred when loading "reagent_mui.x.data_grid.js". Any additional errors after that one may be the result of that failure. In general your code cannot be trusted to execute properly after such a failure. Make sure to fix the first one before looking at others.
#2022-02-1417:56thhellertry :js-options {:entry-keys ["module" "browser" "main"]}} in your build config#2022-02-1417:58Clement SanCompiling ...#2022-02-1418:05Clement SanOK, no error on loading page the now, thanks, that means the [reagent-mui.x.data-grid :refer [data-grid]] require is now working ! but when using the data-grid component in the hiccup i now get the following error :
index-esm.js:6943 Uncaught TypeError: Cannot read properties of undefined (reading 'useRef')
    at eval (index-esm.js:6943:25)
    at Xi (index-esm.js:6942:12)
    at Ss (index-esm.js:8390:3)
    at eval (index-esm.js:9742:10)
    at renderWithHooks (react-dom.development.js:14986:18)
    at updateForwardRef (react-dom.development.js:17045:20)
    at beginWork (react-dom.development.js:19099:16)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3946:14)
    at Object.invokeGuardedCallbackImpl (react-dom.development.js:3995:16)
    at invokeGuardedCallback (react-dom.development.js:4057:31)
eval @ index-esm.js:6943
Xi @ index-esm.js:6942
Ss @ index-esm.js:8390
eval @ index-esm.js:9742
renderWithHooks @ react-dom.development.js:14986
updateForwardRef @ react-dom.development.js:17045
beginWork @ react-dom.development.js:19099
callCallback @ react-dom.development.js:3946
invokeGuardedCallbackImpl @ react-dom.development.js:3995
invokeGuardedCallback @ react-dom.development.js:4057
beginWork$1 @ react-dom.development.js:23965
performUnitOfWork @ react-dom.development.js:22780
workLoopSync @ react-dom.development.js:22708
renderRootSync @ react-dom.development.js:22671
performSyncWorkOnRoot @ react-dom.development.js:22294
eval @ react-dom.development.js:11328
exports.unstable_runWithPriority @ scheduler.development.js:469
runWithPriority$1 @ react-dom.development.js:11277
flushSyncCallbackQueueImpl @ react-dom.development.js:11323
flushSyncCallbackQueue @ react-dom.development.js:11310
scheduleUpdateOnFiber @ react-dom.development.js:21894
updateContainer @ react-dom.development.js:25483
legacyRenderSubtreeIntoContainer @ react-dom.development.js:26038
exports.render @ react-dom.development.js:26104
reagent$dom$render_comp @ dom.cljs:18
eval @ dom.cljs:48
eval @ dom.cljs:38
luminus_reagent_material_ui$core$mount_components @ core.cljs:132
eval @ env.cljs:211
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:220
G__58170 @ env.cljs:220
eval @ env.cljs:249
shadow$cljs$devtools$client$env$do_js_reload_STAR_ @ env.cljs:220
eval @ env.cljs:256
shadow$cljs$devtools$client$browser$do_js_reload @ browser.cljs:43
eval @ browser.cljs:93
eval @ shared.cljs:32
shadow$remote$runtime$shared$process @ shared.cljc:164
eval @ shared.cljs:289
shadow$cljs$devtools$client$shared$remote_msg @ shared.cljs:16
eval @ websocket.cljs:16
Show 11 more frames
react-dom.development.js:20086 The above error occurred in the <ForwardRef> component:

    at eval ()
    at cmp ()
    at div
    at cmp ()
    at div
    at div
    at section
    at cmp ()
    at cmp ()

Consider adding an error boundary to your tree to customize error handling behavior.
Visit  to learn more about error boundaries.
#2022-02-1418:08thhellerthat I can't tell you. my guess would be that this is wrong https://github.com/arttuka/reagent-material-ui/blob/master/src/x/reagent_mui/x/data_grid.cljs#2022-02-1418:09thhellerreally tough too say. too many things in this example. trim down some of the dependency and just use mui directly#2022-02-1418:09thhellerthat would at least make it debuggable#2022-02-1418:15thhellerwhen switching to ESM modules (which you did via the :entry-keys) sometimes some requires change#2022-02-1418:15thheller:as becomes :default or so#2022-02-1507:33barrellHey, I’m getting a weird error when adding a dependency to a project with custom [:js-optons :js-package-dirs]. I’m providing absolute paths to files that exist, but for some reason I am getting the follow error on every build ~ even though it immediately succeeds afterwards. I’ve tried trashing .shadow-cljs and emptying the trash but that doesn’t seem to fix it
[CLJ] [:browser] Build failure:
[CLJ] The required JS dependency "faunadb/dist/faunadb" is not available, it was required by "routes/index.cljs".
[CLJ]
[CLJ] Dependency Trace:
[CLJ]   captain/loader/index.cljs
[CLJ]   captain/loader/router.cljs
[CLJ]   captain/manifest.cljs
[CLJ]   routes/index.cljs
[CLJ]
[CLJ] Searched for npm packages in:
[CLJ]   /Users/barrell/.Trash/.captain 17-47-55-522/node_modules
[CLJ]
[CLJ] See: 
[CLJ]
[CSS] Done in 47ms.
[CLJ] [:browser] Build completed. (217 files, 2 compiled, 0 warnings, 0,20s)
#2022-02-1507:34barrelland idea why it’s looking in my .Trash?#2022-02-1507:43thhellerwhat :js-package-dirs did you set? maybe there is a symlink or so?#2022-02-1507:46thhellermaybe you deleted the dir while shadow-cljs was running? no clue otherwise#2022-02-1508:03barrellahhhh yes one of them is probably symlinked#2022-02-1508:03barrellstrange that it failes then succeeds everytime though?#2022-02-1517:55thhelleryeah dunno. I don't have a clue how you end up loading things from .Trash#2022-02-1515:14niwinzHello @thheller, I have observed that in some shadow-cljs version (some time ago), the development build started generating a single file per module that makes the deveploment build load much faster on browser than previous approach (loading each file). But I have noticed that webworker module still uses the old approach, loading each file separatelly. Is it intentionally? In any case, thank you very much for all your work in shadow-cljs.#2022-02-1517:35thhellerI can't remember details but I believe I did some tests with webworkers and the performance didn't differ that much. since it doesn't block the main thread it didn't seem important to use the new method there too#2022-02-1517:35thhellerbut it could certainly be added there as well#2022-02-1519:30niwinzHmm, in big projects, the performance is very noticeable. On https://penpot.app project, webworker loads at least 900 files and loading that files takes 12s, of total 15.66s and it is pretty noticeable on first load or forced refresh. I think that having the same approach on webworker will make a difference also. Additionally as context info, we try to make some tests using cypress, but loading a page that loads the webworker module almost always takes too much time that timeouts (with already increased timeout, the things in cypress looks like takes longer to finish all the requests, for now we using advanced build for passing tests but it is very painful on modify->run test iteration because of expected long compile times).#2022-02-1519:54thhellerfeel free to open an issue about this. maybe I can take a look over the weekend#2022-02-1522:12niwinzthanks, opened: https://github.com/thheller/shadow-cljs/issues/989#2022-02-1616:22jimmySo I'm trying to use :npm-module and running into this issue https://github.com/thheller/shadow-cljs/issues/908 Except mine is
internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/promise/promise.js"]
{:dep [:shadow.build.classpath/resource "goog/promise/promise.js"]}
ExceptionInfo: internal module error, no mod for dep:[:shadow.build.classpath/resource "goog/promise/promise.js"]
Happy to try to work on a reproducing case. Just wanted to see given its similarity to the existing issue if there is anything I should be looking at or could possibly do to fix the issue. (Sadly :node-library is not an option and one of my deps doesn't play well with :esm.)
#2022-02-1618:27thheller@jimmy which shadow-cljs version is this? this shouldn't be an issue with any not super old version?#2022-02-1618:27thhellerthe issue you linked has the fix?#2022-02-1618:51jimmySorry for the bother. I had checked I was on the latest version. But did not notice that someone was overriding the version in the alias I was using to build this. Works fine on the latest version. Thanks#2022-02-1622:44mauricio.szaboHi, @thheller. I'm trying to use defclass from your shadow.cljs.modern namespace, but I keep getting errors like "cannot infer target on expression". For example, at this code:
(modern/defclass TextEditor
  (constructor [this params])
  Object
  (sommething [this]))
#2022-02-1622:45mauricio.szaboI get:
Cannot infer target type in expression (. (. TextEditor -prototype) -sommething)
#2022-02-1705:31thhelleryeah, still need to sort out some edge cases. you can just (set! *warn-on-infer* false) before the defclass and back to true after#2022-02-1706:30wodin@thheller Hi. I submitted a PR for reagent-expo yesterday to upgrade it to work with Expo SDK 44 and EAS Build. I also added a way to block Expo Web’s fast refresh and removed that section from the README. If you have a chance to check it, please let me know if I need to change anything 🙂 https://github.com/thheller/reagent-expo/pull/10#2022-02-1706:32thhellerwhat is a EAS build?#2022-02-1706:33wodinIt’s Expo’s new way of building which allows you to incorporate custom native code. The old way of building is currently still supported, but will be going away at some point. EAS Build allows you to continue using the Expo Managed workflow, and still install dependencies that you would previously have had to eject for. You can also build plain React Native apps using EAS Build.#2022-02-1706:34wodinEAS == Expo Application Services#2022-02-1706:35wodinhttps://docs.expo.dev/eas/#2022-02-1706:37thhellerah ok#2022-02-1706:38thhellerI don't follow Expo at all so I don't have any way of checking your PR. I'm fine with merging it if you accept that I direct people asking questions your way 😉#2022-02-1706:40wodinhehe 🙂 you can point them at https://forums.expo.dev and there’s a good chance I will see there question and answer them there.#2022-02-1706:50wodinI understand if you don’t want to bother, but it’s really easy to try it out: • Create an Expo account (I think you might have done this in the past) • npm i -g expo-cli eas-cli # there’s a weird yarn bug that sometimes happens when installing these globally with yarn • clone the reagent-expo repo • run yarn to install the dependencies The development instructions are unchanged. The instructions for building a standalone app that you can submit to the App/Play stores is now just basically “run eas build ...” because npx shadow-cljs release app is run as part of the build. So for example you can run: eas build --platform=android --profile=preview which will build a .apk that you can install on an Android device. The first time you do this it will ask for the Android package (which is normally something like io.github.shadowcljs.reagentexpo (Android doesn’t like dashes there for some reason)). If you build for iOS then it will ask for a bundleIdentifier which is basically the same thing for iOS (but dashes are allowed there.) It will also generate a default eas.json config file.#2022-02-1706:53thhelleryeah sorry I'm not gonna do any of that. way too swamped already and no time to look into what looks like an entire new ecosystem#2022-02-1706:54wodinNo problem#2022-02-1706:54thhelleras far as I can tell from your PR nothing on the shadow-cljs changed at all#2022-02-1706:54thhellerI can't possibly keep up with all the platform changes happening elsewhere#2022-02-1706:57wodinI understand. Yes, I did not change anything about shadow-cljs (except upgrading the version). The changes were just Expo-related and documentation. I think my PR is useful for people following the link from the Expo section of the Shadow CLJS docs. I’ve pretended that the “classic” build system doesn’t exist for two reasons: 1. The original reagent-expo README basically said :man-shrugging: 2. The classic build system will be going away at some point I will attempt to answer questions people have if you direct them to the Expo forums Thanks for your time and for Shadow CLJS 🙂#2022-02-1708:08orestisIs it possible to control the :asset-path dynamically? Via e.g. setting a top-level JS var on window ? I'm dealing with a convoluted setup that must have the asset path being an absolute URL, even in development, e.g. doing :asset-path "", which works fine, but then I'd like to also test on my phone which means that localhost won't do.#2022-02-1708:14thhellernot really no#2022-02-1708:16thhellerdid you maybe try using the proxy support? https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy#2022-02-1708:16thhellerso that you can use one url but that one talks to other servers?#2022-02-1708:21orestisWhat about calling manually shadow.loader.init ? It seems to be working in my setup. My generated HTML file is doing roughly
<script src={base-module}>
<script src={main-module}>
<script>shadow.loader.init("")</script>
#2022-02-1708:24orestis(with :module-loader-init set to false)#2022-02-1708:25orestisIt seems to be working but ideally I should probably put shadow.loader.init after the base module? As, at the time main-module gets loaded, React begins to render so it may trigger asynchronous loading...#2022-02-1708:30thhellerwell yes that affects the loader but that is not the only use of asset-path#2022-02-1708:30thhellerat least not during development#2022-02-1708:30thhellerinit must be called before and use of the loader#2022-02-1708:30thhellerso best in a init method as described here https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-02-1708:35orestisThe issue with the init method is that it doesn't accept any arguments, so I have to append an extra script tag in my index.html to do this kind of dynamic thing.#2022-02-1708:37thhellerwell it is not supposed to accept arguments#2022-02-1708:37thhellerbut you can look at your environment just fine#2022-02-1708:37orestisI could bypass the init-fn entirely and just call my init-fn after I setup the shadow.loader#2022-02-1708:37thhellerso for example you can include a <meta name="my-base-path" value="whatever"> in your html#2022-02-1708:38thhellerthen in init (js/document.querySelector "meta[my-base-path]") to get it out#2022-02-1708:38thhelleror <script>_BASE_PATH = "whatever"</script> before the other script takes#2022-02-1708:38thhellerand just js/MY_BASE_PATH in the init fn#2022-02-1708:38orestisRight, I can figure that out in multiple ways - I was wondering about that you said about asset-path being used in other places too though?#2022-02-1708:38thhellersource maps mostly. if you don't get any warnings/errors regarding those it most likely is fine#2022-02-1708:39orestisAh right, that's a production concern. In production I hardcode an absolute path for the asset-path. It's only in dev mode that I need to have it dynamic.#2022-02-1708:41thhellerdunno what you are doing so can't comment much. normally proxies make all uses of weird server setups unnecessary#2022-02-1708:42thheller(your server may also opt to do the proxying)#2022-02-1708:42thhelleralso the files generates by shadow-cljs are just static files#2022-02-1708:43thhellerso any webserver can serve them. no need to have any built-in shadow-cljs server serve them#2022-02-1708:43orestisWhat about double proxies? 🙂#2022-02-1708:43orestisBut yes, we have a weird setup. Not using shadow-cljs server to serve anything.#2022-02-1708:44orestisIt's the module loader that is out of my control, otherwise loading the base files works just fine.#2022-02-1708:44orestis(But it turns out I can init the module loader just fine, so I'm happy. Problem solved 🙂#2022-02-1713:48mauricio.szaboHi @thheller, I'm having to work with a native, buggy Javascript code (again!) and somehow Shadow/CLJS is behaving strangely. From what I could get, some namespaces simply change to undefined and I can't call function on them anymore - I start the "watch" process, connect my Javascript app, but as soon as it tries to run anything that's on the ClojureScript side, it simply fails with TypeError: Cannot read property 'after_load' of undefined for example (`after-load` is a function defined on CLJS side). I found out that if, just after I connect to the JS app, I reload a specific namespace (by saving the file) then things work. Is there a way to either debug this issue, or force-reload of this namespace all the time?#2022-02-1714:00mauricio.szaboOn this example above, the error was triggered from:
(defn ^:dev/after-load after-load []
  (println "Reloaded!"))

(defn start []
  ;; ..setup here..
 (p/do! ;; promesa
          (p/delay 2000) ;;  wait 2s
          (after-load)))
#2022-02-1714:58thhellerimpossible to say without more detail#2022-02-1714:59thhellercould be that the JS is just replacing objects you are working with#2022-02-1714:59thhellersay you have (ns lib.foo) and the (defn after-load []) in that#2022-02-1714:59thhellerif say the JS code does var lib = {}; the ns will be gone#2022-02-1721:42mauricio.szaboRIGHT you are again! I just searched for the old codebase, and it indeed replaces LOTs of global objects - one with the same exact name as my namespace. Thanks again!#2022-02-1714:00eccentric JReading the docs but did not find any hints: Is it possible to swap out the version of clojurescript shadow uses? There's some 1.11 features I would like to try#2022-02-1714:57thhellerwhat are you looking for in particular. As far as I know there have been zero changes in 1.11.4 that affect shadow-cljs#2022-02-1714:57thhellerthats why I didn't bump yet#2022-02-1718:06eccentric Jhttps://clojure.atlassian.net/browse/CLJ-2603 the feature that applies the last map in function calls to keyword args caught my eye. Checked out the shadow-cljs repo and seems it's pinned to 1.10?#2022-02-1718:22thhellerpretty sure this was after 1.11.4?#2022-02-1718:23thhelleranyways. if you are using deps.edn or project.clj you can use any cljs release you want#2022-02-1718:23thhellerI can bump it too I guess. was just waiting for a newer release.#2022-02-1718:24thhellerhttps://github.com/clojure/clojurescript/commit/c260cea7b03b223d6262ddd6e8c1f7346b92e965#2022-02-1718:24thhelleryeah this was after 1.11.4, so not in any release yet#2022-02-1718:25thhelleryou can use the git version of course with deps.edn#2022-02-1719:24eccentric J> anyways. if you are using deps.edn or project.clj you can use any cljs release you want That's what I was looking for. Thanks once again! Would you be open to a PR against the docs to mention that?#2022-02-1719:25thhellerwell "any cljs release" is not quite correct#2022-02-1719:26thhellerthere are certain version requirements to keep in mind so I'd rather not mention it#2022-02-1719:26thhellerI have pretty much always stayed with the very latest CLJS release anyways#2022-02-1719:27thhellerjust didn't this time since there have been no changes in the 1.11.4 release that added any new features or did anything else that would affect shadow-cljs users#2022-02-1719:27thhellerall the new stuff is still pending a release#2022-02-1719:28eccentric JFair enough. May not be worth mentioning then, though I guess it comes down to what you find more annoying: Questions like this or people reporting issues using an incompatible version of cljs 😆#2022-02-1719:29thhellerthe latter for sure. you are the first to ask this, so it doesn't come up often#2022-02-1719:30thhellerdependency conflicts however are common, since I can't prevent them when deps.edn or project.clj are used#2022-02-1719:31thhellerat least with shadow-cljs.edn I can keep them under control#2022-02-1719:39eccentric JHah that's probably the right call then#2022-02-1804:07Oliver GeorgeBased on https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external I'm switching to :js-provider :external because @react-pdf/renderer is incompatible (wasm) with the standard bunding approach. That means an extra step to run webpack after shadow-cljs compile to build a single js file. Wondering what the best way to handle the dev time case. Should I use :build-hooks to trigger the webpack after each build?#2022-02-1804:33Oliver GeorgeHuh, got the PDF viewer working but broke everything else!
Module not provided: shadow.js.shim.module$react
#2022-02-1806:15thhellercheck the :internal-index generated by shadow-cljs. it should contain require("react")#2022-02-1806:15thhellerI strongly recommend NOT coupling anything webpack to your shadow-cljs build#2022-02-1806:16thhellerjust run it separately#2022-02-1806:16thhellerif you don't change npm dependencies often you can usually just run it by hand#2022-02-1806:16thhellerit only needs to run if you actually change npm requires, it does not need to run when you only work on cljs sources#2022-02-1807:05thhelleroh I just noticed "to build a single js file"#2022-02-1807:05thhellerthis is intended as two separate files and must be used as such#2022-02-1807:06thhellerone for the webpack output and one for the shadow-cljs output#2022-02-1807:06thhellerwebpack must never process the regular output of shadow-cljs, only the :external-index#2022-02-1808:07Oliver GeorgeAh, "one single file" was confusing. Was aiming at a lib.js and an app.js.#2022-02-1808:08Oliver GeorgeThanks.#2022-02-1808:08thhellerah ok. single file would cause errors like yours so that got me confused 🙂#2022-02-1808:09Oliver GeorgeI'll do a simple repro and try and get a handle on it. It'd be lovely to keep shadow-cljs... this react-pdf lib just keeps sneaking in as a requirement (enterprise clients)#2022-02-1808:13thhellerI setup this repo a while ago showing how to use a cdn version of pdfjs#2022-02-1808:13thhellerhttps://github.com/thheller/reagent-pdfjs#2022-02-1808:14thhellermaybe something similar works for you? all these pdf libs are kinda heavy#2022-02-1808:14thhellerdunno how much react-pdf actually wraps#2022-02-1808:27Oliver GeorgeThanks but no CDN for this one I know of#2022-02-1808:50Oliver GeorgeBasics work :-)#2022-02-1808:50Oliver Georgehttps://github.com/olivergeorge/shadow-vs-rpdfr#2022-02-1808:50Oliver GeorgeWill look into my other issue#2022-02-1808:50Oliver GeorgeHopefully unrelated#2022-02-1901:09TreyI'm having a problem with a compile using the wrong version of a dependency (using the project’s version project/node_modules instead of the local module's project/module/node_modules). Is there a way to enable verbose logging to get more details on the situation?#2022-02-1901:13TreyI've tried to isolate the issue by constructing a simple version of the problem but I wasn't able to reproduce it. It's probably an edge case or something specific to my setup. #2022-02-1906:31thhellerif its a browser build you get generate a build report. that lists everything that was used and why https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2022-02-2119:05TreyI was able to resolve my issue by using clojure -M:shadow-cljs compile ... rather than npx shadow-cljs compile ...#2022-02-2119:05TreyI'll try to put together a repro of the issue. Thanks for your help!#2022-02-2200:17TreyI know a bit more now: this seems to have been caused by an old version of shadow-cljs being specified in deps.edn. A newer version was used in package.json but it seems shadow-cljs will prefer using the clojure-cli one?#2022-02-2206:02thhellerit is not about preferring. when using deps.edn that is the only version that matters. package.json only controls the version if using shadow-cljs.edn only#2022-02-2421:19Trey:thumbsup: that aspect of it surprised me, I'm sure people using deps.edn usually know what they're doing. Thanks for answering my questions!#2022-02-2002:04mhuebertI’ve run into a bug (quite some months back) with macros in self-host where syntax-quoted symbols aren’t always expanded. Found some time today… I came across this bit here where we build up an alias-map and bind that to reader/**alias-map*,* but then override `reader/resolve-symbol` to which doesn’t appear to have access to those aliases directly (though the analyzer is building up aliases in its own way, i presume) https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/compiler.clj#L312#2022-02-2002:18mhuebertthere is a repro here: https://github.com/mhuebert/shadow-bootstrap-example/blob/shadow-syntax-quote/src/shadow_eval/core.cljs#L16#2022-02-2002:21mhuebertthe symbol that doesn’t expand is sub/wrap#2022-02-2002:25mhuebertnow, weirdly, this only happens if there is both a macros.cljs and macros.cljc file. if I delete the .cljs file and use only .cljc with the self-require there, the symbol expands as expected.#2022-02-2002:28mhuebertmaybe it’s because with the cljs file present, in the first “pass” there are no :require’s found by the analyzer#2022-02-2002:29mhuebertwhereas with a self-requiring cljc file, it finds the sub-macros namespace on the first (non-macros) pass#2022-02-2002:31mhuebertso I guess that is my theory, that the read-loop in shadow’s compiler builds up an alias map which is not visible to the analyzer namespace, but is required for syntax-quote expansion. however sometimes it “works anyway” if the analyzer has already “seen” the same namespace in a prior pass, and the namespace-alias was also visible to that pass.#2022-02-2005:54thhellerisn't this a known problem? macro namespaces can't have dependencies?#2022-02-2005:55thhellerbecause it is undefined which namespace it should include?#2022-02-2005:55thhellerie. https://github.com/mhuebert/shadow-bootstrap-example/blob/shadow-syntax-quote/src/bootstrap_test/macros.cljc#L2#2022-02-2005:56thhellerdoes this include the .cljs file or the .cljc file? it is technically speaking in a :cljs branch of the .cljc file but loading in CLJ mode since it is a macro#2022-02-2008:43mhuebertIf it's not behind a reader conditional then I'd expect it to load / be a available in all passes#2022-02-2008:43mhuebertThis is a macro using another macro #2022-02-2008:45mhuebertSomething related to this behaviour changed several months ago (or more) and I haven't been able to update Maria.cloud’s dependencies since then because it breaks a lot of macros #2022-02-2008:48mhuebertEg Reagent.core/with-let used to work but doesn't anymore because it uses an ns alias in a macro to delegate to a macro in another namespace #2022-02-2008:49mhuebertIn this case I know that shadows compile loop is aware of the alias from logging at that point #2022-02-2008:55mhuebertThe code is compiled and available, it's just the syntax quote expansion that doesn't work#2022-02-2008:55mhuebertIf I replace the use of the alias with the fully qualified symbol it works #2022-02-2009:44thhelleras far as I can tell you are in undefined territory and macros cannot be included this way#2022-02-2009:46thhellerthis might be fine in .clj files and just .cljc being the problem?#2022-02-2010:02thhellerso if I diagnose this correctly the problem is that requires in CLJ files are not followed#2022-02-2010:02thheller(that includes requires in the CLJ path of the CLJC files)#2022-02-2010:03thhellerso as far as the compiler is concerned nothing ever requires the sub-macros#2022-02-2010:03thhellerif you instead however properly expose that require it all works out#2022-02-2010:03thhellerie. add
(ns bootstrap-test.macros
  (:require-macros bootstrap-test.macros)
  (:require [bootstrap-test.sub-macros]))
#2022-02-2010:04thhellerself-host is mind bending enough already, if you add CLJC to the mix it all becomes even worse#2022-02-2010:05thhellerdunno if that actually fixes anything though. just a theoretical observation#2022-02-2010:15mhuebertBut isn't it the case that these requires are being followed? Because it works if I change the symbol to be fully qualified. It is only the read phase where the syntax quote doesn't work #2022-02-2010:18mhuebertAnd it seems weird to be building up a map of ns-aliases but then overriding resolve-sym so that it can't see them #2022-02-2010:19thhellerwhat makes you say that it can't see them?#2022-02-2010:19thhellerana/resolve-symbol is the only thing that can see them?#2022-02-2010:24mhuebertThey are bound in the reader ns, not ana?Ana is only seeing stuff from previous passes? If I log the ns-aliases I see one for sub but that's not being seen or used by ana/resolve-symbol#2022-02-2010:25mhuebertWhen I'm back at my computer I can point to the line#2022-02-2010:27thhellerana/resolve-symbol sees things in the analyzer data. any ns data is added to that#2022-02-2010:28mhuebertLine 311 of shadow.build.compiler#2022-02-2010:29mhuebertI can log there that we encounter a syntax quote sub/wrap symbol, sub is found in ns-aliases but resolve-symbol doesn't find it#2022-02-2010:32mhuebertbootstrap-test.macros does a self :require-macros but in a cljs file separate from the cljc file #2022-02-2010:34thhellerbut isn't this because it is self-host compiling with this reference context.
(ns bootstrap-test.macros
  (:require-macros bootstrap-test.macros))
so there is no sub alias?
#2022-02-2010:35thhellershouldn't it work if you add it here?#2022-02-2010:35thhellerI'm kinda lost with self-hosted and cljc to be honest#2022-02-2010:35thhellernever makes sense to me#2022-02-2010:36mhuebertMe too#2022-02-2010:38mhuebertBut shouldn't aliases work when read in the same pass?#2022-02-2010:42mhueberthttps://github.com/reagent-project/reagent/blob/master/src/reagent/core.clj#2022-02-2010:42mhuebertThis is also broken (ra alias not resolving)#2022-02-2010:43mhuebertThough I haven’t had time to verify it's exactly the same cause#2022-02-2010:48mhuebertIIRC I thought these issues were shadow specific, couldn't repro in the cljs test suite #2022-02-2010:48mhuebertBut I checked that a few months ago#2022-02-2010:49mhuebertBut that's what also makes me think it could be a quirk in shadow.build.compiler #2022-02-2011:08mhuebertyeah, so it’s not related to cljc - if i rename that to clj, same error https://github.com/mhuebert/shadow-bootstrap-example/commit/6ec1810758357011acf85b59750fc682d1a03825#2022-02-2011:08mhuebertso it’s the same reason why i can’t compile reagent’s macros#2022-02-2011:09mhuebertthe macro pass’s syntax-quote can’t read its ns-aliases#2022-02-2011:12thhellerI mean it is absolutely possible this is a problem in shadow-cljs code somewhere#2022-02-2011:13thhellerbut to me this all looks like it is working as intended? this issue with using fully qualified names for macros has been there since forever (and even exists in non-self-hosted code)#2022-02-2011:18mhuebertsomething definitely changed with this several months ago though because this broke a bunch of things with Maria#2022-02-2011:19thhellerthat is possible since I added support for :as-alias a couple months ago. maybe that messed something up?#2022-02-2011:20mhuebertit was earlier than that#2022-02-2011:20mhuebertit was already broken in november 2020#2022-02-2011:21mhuebertmaria is still on shadow-cljs 2.8.36#2022-02-2011:21mhueberti git bisected it a long time ago but can’t find the result#2022-02-2011:21mhueberti’m just trying to “unfreeze” maria now so i can work on it again#2022-02-2011:21thhellerhmm yeah would help to know the version number it breaks#2022-02-2011:22mhuebertthere were 2 bugs in ClojureScript that had to be fixed first#2022-02-2011:22mhuebertbut those are all taken care of now#2022-02-2011:23mhueberti know there are many cases where one needs to use fully qualified symbols in macros but this I think is different - these are symbols for macros, from macro namespaces that are required by a macro namespace. eg https://github.com/reagent-project/reagent/blob/master/src/reagent/core.clj#L10 this works as expected#2022-02-2011:24mhuebert(but is broken for me)#2022-02-2011:24mhuebertof course one has always had to use fully qualified namespaces for stuff that is calling at runtime#2022-02-2011:25mhuebertbut this makes me think, maybe im wrong about the main issue being syntax quote expansion#2022-02-2011:26mhueberthmm#2022-02-2011:26mhuebertis this do-analyze-cljs-string supposed to expand macros https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/compiler.clj#L278
#2022-02-2011:27mhuebert(i wouldn’t think so)#2022-02-2011:27thhelleras far as I can tell the same problem exists in 2.8.36?#2022-02-2011:27thhellerwhat do you mean supposed to extend macros?#2022-02-2011:28thhellerthis is expanding macros https://github.com/thheller/shadow-cljs/blob/9b1f5295db8458d5d06890b4761e1ecf71c3a7a0/src/main/shadow/build/compiler.clj#L264#2022-02-2011:28thhellersorry, gotta go. bbl#2022-02-2011:30mhuebertach now i remember how hard it was to bisect this, i can’t even run the old version anymore because of java incompatibilities#2022-02-2011:33mhuebert
[:failed-to-compare "^1.2.0" "1.2.2" #error {
 :cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
 :via
 [{:type java.lang.NullPointerException
   :message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
   :at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
#2022-02-2013:45mhuebertwell, looks like reagent has other reasons why its not selfhost-compatible so that’s not a good goal. I will see again how many macros broke that we were actually using in maria#2022-02-2014:38thhellerthose errors you can ignore. they don't affect compilation#2022-02-2014:45thhellerso as far as I can tell your repro also breaks in 2.8.36, so this issue isn't the one affecting maria I guess?#2022-02-2023:23mhuebertwell I apologize for this rabbit trail. When I made those original repro’s I think I assumed that since shadow and cljs appeared to diverge here it was also a bug that was probably contributing. However, I’ve finally fixed all the other things that had broken in the meantime and all our curriculum runs fine without any changes needed to this macro-syntax-quote stuff.#2022-02-2023:24mhuebertI think I have still run into this issue elsewhere when trying to write selfhost-compatible macros. But I’ve mostly given up on that because it’s so hard.#2022-02-2023:26mhuebertI did verify that a :refer in a .cljs file makes an alias available during the macro pass of a .cljc file - as you described above#2022-02-2005:54thhellerisn't this a known problem? macro namespaces can't have dependencies?#2022-02-2006:52Jacob EmckenI found requiring Hero Icons like this also includes the Hero icons not referred:
(:require ["@heroicons/react/solid" :refer [CheckIcon ChatIcon]])
While the following does not:
(:require ["@heroicons/react/solid/CheckIcon" :as CheckIcon]
          ["@heroicons/react/solid/ChatIcon" :as ChatIcon])
Is there any way to require without repeating "@heroicons/react/solid" over and over? I tried with:
(:require ["@heroicons/react/solid" ["CheckIcon" :as CheckIcon]
                                    ["ChatIcon" :as ChatIcon]])
Which causes: Invalid namespace declaration
#2022-02-2006:53thhellerno, that is not supported#2022-02-2006:55Jacob EmckenIs it something that is impossible to do with how such things work or is it just something not important enough to get any attention?#2022-02-2007:10thhellerchanging :require to allow the nested stuff is not an option since that would break compatibility with standard CLJS#2022-02-2007:10thhellerchanging that :refer only actually imports what was referred is a substantial amount of work, which I simply don't have time for currently. it is also non-standard behavior and basically something webpack invented.#2022-02-2007:11Jacob EmckenThanks for the insight. I'm just curious 😄#2022-02-2007:14Jacob EmckenJS tooling is something I've successfully managed to dodge for a very long time... exactly because examples like "non-standard behavior and basically something webpack invented".#2022-02-2007:15thhelleryeah its annoying#2022-02-2009:19barrellHey thheller - general question for you. Is it possible to read the metadata for clojurescript functions from build hooks (which are in clojure)? Or is it generally possible to parse the namespace and get publics ~ trying to figure out the best way to inspect a clojurescript file from the build and determine some general information about it#2022-02-2009:20thhellersure, all analyzer data is available#2022-02-2009:20thheller[:compiler-env :cljs.analyzer/namespaces 'your.ns :defs 'foo :meta] in the build state#2022-02-2009:28barrellthis is amazing. you’re the best.#2022-02-2010:55Quentin Le GuennecHello, I'm getting an error in a release build (works in dev mode): $.clearTimeout is not a function the corresponding call is here:
goog.functions.debounce = function(f, interval, opt_scope) {
  'use strict';
  let timeout = 0;
  return /** @type {function(...?)} */ (function(var_args) {
    'use strict';
    goog.global.clearTimeout(timeout);
    const args = arguments;
    timeout = goog.global.setTimeout(function() {
      'use strict';
      f.apply(opt_scope, args);
    }, interval);
  });
}; 
#2022-02-2011:00thhellerwhich :target is this and what is it actually running in?#2022-02-2011:03Quentin Le GuennecI'm using npx shadow-cljs release main --debug for :target = :browser#2022-02-2011:04thhellerand the output is running in an actual brower?#2022-02-2011:04Quentin Le Guennecyes#2022-02-2011:04Quentin Le Guennecmy deps.edn is:
{:paths ["src/main" "resources"]
 :deps  {org.clojure/clojure    {:mvn/version "1.10.3"}
         com.fulcrologic/fulcro {:mvn/version "3.5.9"}}

 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps  {org.clojure/clojurescript {:mvn/version "1.10.914"}
                               thheller/shadow-cljs      {:mvn/version "2.16.9"}
                               binaryage/devtools        {:mvn/version "1.0.4"}
                               cider/cider-nrepl         {:mvn/version "0.27.4"}}}}}
#2022-02-2011:04Quentin Le GuennecI pulled it from the fulcro guide#2022-02-2011:04thhellerwith that being the only JS on the page?#2022-02-2011:05Quentin Le Guennecyes#2022-02-2011:05Quentin Le Guennecit's webpack-ed though#2022-02-2011:05thhellerwell ... that is the problem then#2022-02-2011:05Quentin Le GuennecI'll try to release a version without webpack#2022-02-2011:05thhellerthe output of :browser is not supposed to be bundled by webpack again?#2022-02-2011:05thhellerand why would you do that?#2022-02-2011:06Quentin Le Guennecisn't it a good practive?#2022-02-2011:07thhellerno?#2022-02-2011:07thhellerI don't know what you are trying to accomplish by doing so?#2022-02-2011:07thhellerI mean does it have a reason you are doing it? is there something missing otherwise?#2022-02-2011:07Quentin Le GuennecI thought it would reduce the loading times#2022-02-2011:08thhellerno, it will in fact make it worse#2022-02-2011:08Quentin Le Guennecoh#2022-02-2011:08Quentin Le GuennecI need the bundle at least for css files though, is that fine?#2022-02-2011:08thhellerno#2022-02-2011:08Quentin Le Guennecwhy not?#2022-02-2011:08thhellerI mean you can run webpack separately. that is fine as long as it doesn't try to process the shadow-cljs output#2022-02-2011:09Quentin Le Guennecyeah, it should be fine just for css then#2022-02-2011:09Quentin Le GuennecI'd like to avoid having to manually add copy css files from node_modules/ to my public directory]#2022-02-2015:04mauricio.szaboHi there! I'm trying to import a npm dependency, and I'm getting the error IllegalArgumentException No matching field found: getAbsolutePath for class clojure.lang.PersistentHashMap. I know it's probably an error with the way I'm importing the lib, but is there something else I can do to debug this issue?#2022-02-2017:40thheller@mauricio.szabo which npm dependency would this be? you can also provide the full stacktrace and shadow-cljs version please. that would already telling me about 95% of what I need to know#2022-02-2017:43mauricio.szaboIt's the monaco-editor, the full require is ["monaco-editor/esm/vs/editor/editor.api" :as monaco]. This is the stacktrace on the shadow-cljs console:
IllegalArgumentException No matching field found: getAbsolutePath for class clojure.lang.PersistentHashMap
        clojure.lang.Reflector.getInstanceField (Reflector.java:397)
        clojure.lang.Reflector.invokeNoArgInstanceMember (Reflector.java:440)
        shadow.cljs.devtools.errors/fn--13467 (errors.clj:228)
        shadow.cljs.devtools.errors/fn--13467 (errors.clj:222)
        clojure.lang.MultiFn.invoke (MultiFn.java:239)
        shadow.cljs.devtools.errors/error-format (errors.clj:449)
        shadow.cljs.devtools.errors/error-format (errors.clj:440)
        shadow.cljs.devtools.errors/error-format (errors.clj:443)
        shadow.cljs.devtools.errors/error-format (errors.clj:440)
        shadow.cljs.devtools.server.worker.impl/build-failure/fn--14276 (impl.clj:133)
        shadow.cljs.devtools.server.worker.impl/build-failure (impl.clj:132)
        shadow.cljs.devtools.server.worker.impl/build-failure (impl.clj:128)
#2022-02-2017:48thhellerthanks. yeah thats a bug, fix incoming#2022-02-2017:48thhellermy guess its trying to include .css files#2022-02-2017:49thhellerfixed in 2.17.4#2022-02-2018:15mauricio.szaboIs an import from a css file even valid? Why does Monaco is trying to import it? facepalm#2022-02-2018:18mauricio.szabo@U05224H0W is there a way to ignore these CSS files when I compile my code with Shadow-CLJS?#2022-02-2018:38thheller:js-options {:ignore-asset-requires true}#2022-02-2018:38thhellerbut usually packages that have these expect to be bundled by webpack#2022-02-2018:39thhellerso other stuff might break too#2022-02-2021:17Quentin Le Guennecwhat's the best way to import css files from node_modules into the shadow-cljs build in the browser? I tried webpack but it's not working#2022-02-2100:08aghave you looked into postcss? I'm currently using tailwind with postcss, and importing tailiwind CSS modules directly from node_modules.#2022-02-2109:15Quentin Le GuennecThanks for your answer. Does it also import other assets (like fonts) like react does natively?#2022-02-2110:26agIt's been a while since I touched anything front-end related, and I've never before worked with Tailwind. Also, it's been a long time since I used postcss. I'm sorry I can't give you a detailed answer. afaik tailwind has its own way of dealing with fonts. https://tailwindcss.com/docs/font-family and postcss has plugins https://www.postcss.parts/tag/fonts?searchTerm=font#2022-02-2102:05eplokoHey all, I get an error I seemingly can't resolve...
Failed to inspect file
  app/node_modules/fsevents/fsevents.node

it was required from
  app/node_modules/fsevents/fsevents.js

Errors encountered while trying to parse file
  app/node_modules/fsevents/fsevents.node
  {:line 1, :column 0, :message "Character '�' (U+FFFD) is not a valid identifier start char"}
#2022-02-2102:06eplokoI build with :target :esm as some of the npm packages I use are esm-only.#2022-02-2102:07eplokoThe full build config is:
{:target :esm
   :output-dir "resources/js/compiled/backend"
   :output-to "resources/js/compiled/backend/main.mjs"
   :modules {:main {:init-fn app.backend/main}}}
#2022-02-2102:08eplokoThe error comes from fsevents doing require('./fsevents.node') which fails as the thing is a native module...#2022-02-2102:09eplokoIt there any way to tell shadow-clsj (or... who's actually implementing that require fn here?) to not parse *.node as potential js files?#2022-02-2102:14eplokoHm, I was banging my head against this for a couple of days and, as soon as I posted the question here, I seemingly have found a solution: just saying adding :js-options {:js-provider :require} seems to resolve the issue. Hm...#2022-02-2103:00eplokoWell, no... it now fails trying to access WebSocket:
file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
             ^

ReferenceError: WebSocket is not defined
    at shadow$cljs$devtools$client$websocket$start (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14)
    at Object.attempt_connect_BANG_ (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
    at file:///...app/resources/js/compiled/backend/cljs-runtime/shadow.cljs.devtools.client.browser.js:1230:36
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)
#2022-02-2105:07thhellerif you intend this to run in node you should set :js-options {:js-provider :import} in your build config#2022-02-2105:07thhellerand also :runtime :node (not in :js-options)#2022-02-2105:07thhellerotherwise defaults to :browser and trying to bundle everything (which is not required for node)#2022-02-2200:59eplokoWhoa, thanks for the heads-up 🙂 I was not aware of the :js-provider :import variant.#2022-02-2121:19roklenarcicI’ve noticed that there are options in :devtools key in builds that are not in the user manual…
{:http-port          8022
                                          :http-resource-root "public"
                                          :http-root          "resources/public/js/test"}
is there additional documentation where it’s described how these work?
#2022-02-2206:03thheller@roklenarcic they are old and deprecated. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http should be used instead.#2022-02-2216:48orestisI seem to have trouble loading shadow-cljs 2.17.x - it complains at load time and points to potential dependency clashes, but I can't see anything out of the ordinary. #2022-02-2216:50thhellerwell what happens?#2022-02-2216:50orestis#2022-02-2216:51thhellerthat is indeed a dependency conflict#2022-02-2216:51thhellerguava to be exact#2022-02-2216:51orestishrumph#2022-02-2217:00orestisIs shadow-cljs using guava then? Clojure -Stree doesn't think so...#2022-02-2217:42thhellershadow-cljs is not. the closure compiler is.#2022-02-2217:42thhellerthey changed how they bundle stuff so the closure compiler doesn't declare the guava dependency correctly anymore or something#2022-02-2217:42thhellerbut it is still used and required#2022-02-2217:43thhellerI generally strongly recommend keeping your CLJS and CLJ dependencies separate for this reason#2022-02-2217:43orestisBah. We depend on having them together. #2022-02-2217:47thhellerthere is an open issue about this https://github.com/google/closure-compiler/issues/3896#2022-02-2217:47thhellerI don't even know which guava version it wants anymore#2022-02-2217:48orestisIn the sense that some of our cljs macros depend on our Clojure code. So naturally we had everything under one JVM. Would you suggest to use two different JVMs for this? Then I guess we could at least minimize the blast radius. #2022-02-2217:49thhellerone jvm is fine if you are willing to sort out your dependency conflicts#2022-02-2217:49thhellertwo usually avoids them completely and is easier to maintain in some sense#2022-02-2217:51thhellerits usually not that hard to sort out the conflicts. just an exclude or two#2022-02-2217:51thhelleror just manually depend on whatever the current guava version is#2022-02-2217:52thhellerdatomic or whatever is using guava is usually fine with a newer version#2022-02-2217:52thhellerthe closure compiler just isn't fine with an old version#2022-02-2217:53orestisHm I will use https://github.com/google/closure-compiler#guava-libraries as a reference version and report back. #2022-02-2217:54orestisThey say 31.0.1#2022-02-2305:29orestisPinning 31.0.1 at the top level works. I was using 30.0 brought by some dependency. Annoying. #2022-02-2221:03alexWe have an app that uses lazy module-loading, deployed to users for the very first time this past Friday w/ shadow-cljs 2.17.2 (thanks thheller for the help and documentation!). Deploy went well and without issue! Today we deployed a new version of the app, which included an upgrade to shadow-cljs 2.17.4 . Otherwise we made no changes to the build/compilation process. After the deploy, some users experienced the app crashing; in most scenarios, refreshing the app in-browser fixed things. In looking through our logs, it seemed like some of bundled modules were unable to be loaded. Multiple errors with
Error loading <module>: Consecutive load failures
Looking at the recent commits on https://github.com/thheller/shadow-cljs/commits/master, it seems there were some changes to the Google Module loader. Would those changes have potentially caused breakage for modules built on 2.17.2 vs. modules built on 2.17.4 ? Also Clojars has 2.17.4, but that version isn't reflected anywhere in the Github repo. Curious to know what's the best way to compare 2 versions via Github to check the diff of commits. Thanks!
#2022-02-2305:47thheller@rahx1t just forgot to git push. updated now. I did bump the closure compiler version in 2.17.4 but I'm not aware of any problems related to that. I do use module lazy loading myself and have no issues?#2022-02-2305:48thhellerhow do you load the modules? is this maybe a cache issue? ie. having modules from different builds loaded? you cannot mix modules from different builds or different versions of builds. this can happen easily if your cache settings are not set properly and the browser caches too much by default. if you are not using :module-hash-names that is. works fine without too, just requires telling the server to send proper headers so cache is validated properly#2022-02-2316:14alexI'm loading the modules via a combination of shadow.lazy and shadow.loadable and specifying the modules in shadow-cljs.edn Our main client.js bundle is cachebusted via appending a client.js?<GIT_SHA>, but the lazy-loaded modules are referenced by only their <module_name>.cljs without a hash. Based on what you described above, the issue could've been a result of the updated client.cljs?<GIT_SHA> bundle loading cached, out-of-date modules (due to browser cache). Is that right? I don't think we're currently setting any cache-related headers. Sounds like we can either modify those or utilize :module-hash-names . Thanks!#2022-02-2317:17thheller:module-hash-names is the safest option yeah. you should look into setting proper headers as well though. never hurts, especially with :module-hash-names you only get the full benefit with proper headers#2022-03-1015:45alexSay a client has loaded version A of the app, and we deploy/release version B. We replace the module hash names on the server with those from version B. We prompt the user to update their version of the app by refreshing the page -- however, they sometimes ignore this If they continue browsing with version A of the app, version A continues to attempt to load A-bundled modules. Since we've replaced those files in the server, would you expect requests for version A hashed modules to fail? Since the hashes are contained in the file names themselves, rather than appended as a query string parameter, those resources for A need to exist, otherwise those requests will fail. Am I understanding that right? How do folks usually work around this? Do they keep older deployed versions of files on the server? Am I missing something fundamental about caching?#2022-03-1015:49thhellerI have 5 years or so of :module-hash-names builds still live on my server#2022-03-1015:49thhellerI'm not deleting them ever basically#2022-03-1015:51thhellerthis is much better than the alternative of ending up with 2 separate versions of builds loaded at the same time. there is a very slim chance they are actually compatible#2022-03-1015:51alexGreat, thanks so much for confirming that piece. Makes sense!#2022-03-1015:55alexIs there an option that tells shadow-cljs to append module-hash-names builds but not delete them? I recall the build process replacing the files each time, but I will double-check this#2022-03-1015:57alexProbably it'll have to replace the manifest each time but want to keep keep the module-hash-names files themselves#2022-03-1015:59thhellerit doesn't delete or replace the hashed files if the hash changed#2022-03-1016:00thhellerit'll replace the manifest yes but thats what you want#2022-02-2307:26orestisWe recently started seeing this error on our console:
react_devtools_backend.js:4061 shadow-cljs - failed to load module$node_modules$react_popper$lib$cjs$index
<snip>
react_devtools_backend.js:4061 TypeError: Cannot redefine property: Popper
    at Function.defineProperty (<anonymous>)
    at Object.shadow$provide.module$node_modules$react_popper$lib$cjs$index (VM20697 module$node_modules$react_popper$lib$cjs$index.js:1:165)
    at Object.shadow.js.jsRequire (js.js:66:18)
    at Object.shadow.js.require (js.js:113:20)
    at eval (VM20698 nosco.ui.popup.js:7:62)
    at eval (<anonymous>)
    at Object.goog.globalEval (base.js:503:11)
    at Object.env.evalLoad (base.js:1564:12)
    at eval (VM20252 main.js:45:12)
    at eval (<anonymous>)
It was working but we changed the order of some imports and now we're seeing this. We unfortunately have two version of Popper in our node_modules (v1, v2), they use a different npm artifact. But it seems that if you load them in one order, they work, but not in another order. Other than scouring our deps and removing the old version, could there be any other way to troubleshoot/fix this?
#2022-02-2307:31thhellerhmm not sure. reproducible example would help. don't have enough information otherwise. dunno why it would be redefining the property. this is only in watch I assume? not release#2022-02-2307:33orestisI haven't seen it on release yet, no.#2022-02-2307:33orestisI'm scouring our generated code and I see a reference to global.Popper and also a reference to Object.defineProperty(exports, "Popper", function()...)#2022-02-2307:34thhellerits only defining the property on exports which is never global#2022-02-2307:44Karol WójcikThis looks like internal shadow-cljs error:
[2022-02-23 08:42:12.108 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (clojure/tools/reader/edn.clj:75:9). #:clojure.error{:phase :compile-syntax-check, :line 75, :column 9, :source "clojure/tools/reader/edn.clj"}
	clojure.lang.Compiler.analyze (Compiler.java:6812)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
	clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3824)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7113)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
	clojure.lang.Compiler$IfExpr$Parser.parse (Compiler.java:2841)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
	clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6124)
	clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6440)
Caused by:
RuntimeException No such var: err/throw-no-dispatch
	clojure.lang.Util.runtimeException (Util.java:221)
	clojure.lang.Compiler.resolveIn (Compiler.java:7392)
	clojure.lang.Compiler.resolve (Compiler.java:7362)
	clojure.lang.Compiler.analyzeSymbol (Compiler.java:7323)
	clojure.lang.Compiler.analyze (Compiler.java:6772)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
08:42:18.498 [main] INFO io.undertow - starting server: Undertow - 2.2.4.Final
#2022-02-2307:44Karol WójcikShadow-Cljs 2.17.4#2022-02-2307:49thhellerit is not. probably just a version conflict on tools.reader#2022-02-2307:51thhellershould be [org.clojure/tools.reader "1.3.6"]#2022-02-2308:15Karol WójcikYeah, as always you're right.#2022-02-2308:31CrispinHi. Trying to update an old figwheel/lein project to shadow. What could be the reason for shadow working from the npx command line fine, but not from inside lein run?#2022-02-2308:32Crispin
$ lein run -m shadow.cljs.devtools.cli compile app
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean?
2022-02-23 16:28:48,959 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 
[:app] Compiling ...
The required namespace "project.core" is not available.
"project/core.clj" was found on the classpath. Should this be a .cljs file?
#2022-02-2308:33Crispinbut from command line:
$ npx shadow-cljs compile app
shadow-cljs - config: /path/to/project/shadow-cljs.edn
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean?
16:20:38.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
[:app] Compiling ...
[:app] Build completed. (340 files, 6 compiled, 13 warnings, 6.31s)
#2022-02-2308:34CrispinIm not using any lein-shadow, Im just trying to run it as a lein target (so I can hook it into the uberjar build)#2022-02-2308:35thhellerif you use lein project.clj then :source-paths or :dependencies in shadow-cljs.edn do not apply#2022-02-2308:35thhellerso they need to be configured in project.clj. likely your :source-paths are just incorrect or missing#2022-02-2308:35Crispinright, so its equivalent to doing :lein thing in your shadow cljs?#2022-02-2308:35thhelleryes#2022-02-2308:36Crispinsource-paths for cljs is added in old cljsbuild section#2022-02-2308:36CrispinI will add it to main source-paths#2022-02-2308:37thhellerI recommend a :cljs profile in project.clj, but top level is fine too#2022-02-2308:37Crispinyep. profile it I will.#2022-02-2308:39Crispinworks great. Thanks.#2022-02-2316:16teawaterwirehi, i have this build that's working properly in dev mode and then when i build it for release, when the compiled js is loaded i get a console error:
Uncaught SyntaxError: Unexpected identifier
i've tried a simple or whitespace compilation, i've tried to release with -debug, i've tried to check externs... but i'm really stuck now and don't know where to look... what can i do to get more info about this error?
#2022-02-2316:53alex~Do you have ~ ~{:tag :a, :attrs {:href "https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options"}, :content ("https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options")}~ Ah actually that shouldn't be an issue if you're only using whitespace and simple optimization#2022-02-2316:59teawaterwirei tried source map but that doesn't point me to soemthing useful#2022-02-2317:00teawaterwirejust to be sure the whitespace optim, i add the :release {:compiler-options {:optimizations :whitespace}} right?#2022-02-2317:06thhellerUnexpected identifier is not a externs issue. seems like there is something wrong with the output#2022-02-2317:07thhellerare you sure compilation completed successfully? sometimes some CI systems kill the shadow-cljs JVM during :advanced for using too much memory or so#2022-02-2317:07thhellercould end up with half written files#2022-02-2317:07teawaterwire[:app] Build completed. (1896 files, 0 compiled, 0 warnings, 11.17s) i'm getting that at the end#2022-02-2317:08thhellerand what is the full error trace?#2022-02-2317:08thhellerI'm assuming this is a :browser build? are you maybe testing in a really old browser?#2022-02-2317:08thhelleror something that is not actually a browser?#2022-02-2317:08alexThinking back on this... I've intermittently seen this issue altho not in a while (would sometimes occur after installing an npm dep). Back then, I would rm -rf .shadow-cljs , then run the build again to get an entirely fresh build#2022-02-2317:09teawaterwirethat's the full error trace, i'm on latest chrome macOS#2022-02-2317:09thhellerthats literally the same excerpt. I mean the full trace 😛#2022-02-2317:10thhellerit should point to a location#2022-02-2317:10thhelleron the right? there is no reference to a location?#2022-02-2317:10thhellerwhy does it fail to load the source map?#2022-02-2317:10thhellerare you maybe not actually loading the JS? just some webserver serving something else? like html?#2022-02-2317:11thhellercheck the network tab to see what you actually get#2022-02-2317:11teawaterwireyes there is but it's a long line ... source map not giving anything#2022-02-2317:12thhellerwhich shadow-cljs version is this? did you set a custom :output-feature-set? it doesn't seem to like the yield#2022-02-2317:12thhellerwhich should be find in modern browsers?#2022-02-2317:13teawaterwireyeah i though it could be yield but it should be supported everywhere, and the dev build is not giving an error#2022-02-2317:13teawaterwirecan i add you to the repo maybe?#2022-02-2317:14thhellercould be the closure compiler transpiling away the function* which would make yield invalid#2022-02-2317:14teawaterwireah i see#2022-02-2317:14teawaterwireso should i set a :output-feature-set?#2022-02-2317:15thhellernormally not no#2022-02-2317:15thhellerI mean assuming the default is good enough for you#2022-02-2317:15thhellerbut you can try :compiler-options {:output-feature-set :es-next} in the build config#2022-02-2317:16thheller(that basically disables all polyfilling, just to rule that out)#2022-02-2317:16teawaterwireok#2022-02-2317:16teawaterwirei do it#2022-02-2317:18teawaterwireOh!#2022-02-2317:18teawaterwireseems to be working now :shocked_face_with_exploding_head:#2022-02-2317:19teawaterwireissue now that some browser might not like it...#2022-02-2317:19thhelleryou can then try to go down until it doesn't work anymore#2022-02-2317:19thheller:es2021 :es2020 etc#2022-02-2317:20teawaterwirei see -- so the issue was the transpiling for yield not giving correct js?#2022-02-2317:20thhellerand upgrade shadow-cljs if it isn't the latest (2.17.4)#2022-02-2317:20thhellerthat includes the latest closure compiler#2022-02-2317:20teawaterwire(thanks a lot for that faster-than-typing live debugging!!)#2022-02-2317:20thhellerthat is my guess yes#2022-02-2317:21teawaterwireok i had 2.12.5#2022-02-2317:21teawaterwirei'll bump up and then try without the es-next#2022-02-2317:27teawaterwireshadow updated but still need a output-feature-set#2022-02-2317:28teawaterwirees2020 is fine#2022-02-2317:28teawaterwirei wouldn't be surprised that one of this library is just using weirdly generators, so that's tricking the compiler...#2022-02-2317:29teawaterwiredefault output-set is which one?#2022-02-2317:32thheller:es6#2022-02-2317:33teawaterwire:thumbsup:#2022-02-2316:29isakDoes the error only appear with :advanced? Try turning setting :pseudo-names true in the compiler options, that may help locate the problem. @teawaterwire#2022-02-2317:01teawaterwireit appears with advanced yes, i tried with simple and whitespace and it appeared as well... which is weird so i'm questioning if i was actually setting properly the optimization#2022-02-2319:06Sam Ritchiehello! Is there a way to disable what are, I presume, shadow-specific compiler errors? Here is what I’m seeing:
cljs.user=> (require '[sicmutils.env :refer [+ ->infix]])
nil
cljs.user=> (let [f +] (->infix (f 'x 'x)))
"x + x"
cljs.user=> (->infix (+ 'x 'x))
------ WARNING - :invalid-arithmetic -------------------------------------------
 Resource: <eval>:1:10
 cljs.core/+, all arguments must be numbers, got [cljs.core/Symbol cljs.core/Symbol] instead
--------------------------------------------------------------------------------
#2022-02-2405:46thheller@sritchie09 what makes you think this is shadow-specific? this is a standard cljs compiler warning#2022-02-2418:04Sam RitchieOf course you're right. I bumped shadow and that bumped cljs too, plus tests hang in CI for an hour - off to debug!#2022-02-2418:06Sam RitchieThough it is a problem I guess in this case, since I am explicitly overriding + and don't need the validation anymore. Maybe if I exclude I can kill it #2022-02-2418:06Sam RitchieVs just replacing the var #2022-02-2418:10thhellera quick look suggests that you are missing a :require-macros in this ns#2022-02-2418:10thhellerhttps://github.com/sicmutils/sicmutils/blob/main/src/sicmutils/env.cljc#2022-02-2418:10thhellerso macros are only regcognized if this ns is loaded by other means, which may be unpredicatable#2022-02-2418:11thhellerI'd assume the infix thing is a macro so for CLJS this needs a self-require (:require-macros [sicmutils.env])#2022-02-2418:11Sam RitchieNope, just a function #2022-02-2418:11Sam RitchieThe example is the same without the ->infix, that was just for printing a string #2022-02-2418:12Sam RitchieNo macros at all in the example, just a function + from my namespace #2022-02-2418:13thhellerah ok. then I guess I don't get what the point of that is#2022-02-2418:13Sam RitchieOh, it's an extensible + that is adding symbols in this case, but can do numbers, vectors, functions, and anything you extend it to #2022-02-2418:14Sam RitchieImagine from clojure.algo.generic #2022-02-2418:14thhellerall this potemkin import-vars stuff probably doesn't work for cljs#2022-02-2418:14Sam RitchieIt totally does#2022-02-2418:14Sam RitchieIt works great in the REPL usually and in all tests, etc and has for a year #2022-02-2418:14Sam RitchieAnd works in the example where I bind the + to f as an example #2022-02-2418:15Sam RitchieThis is the reader making an incorrect assumption about what the symbol + means #2022-02-2418:15thhellerlast time I checked it was purely CLJ so I can't really see how it works?#2022-02-2418:15Sam RitchieThe sicmutils library? All cljc #2022-02-2418:16Sam RitchieIt seems like it is just a problem with the REPL launched like in my example , not shadow's test runner or the cider repl #2022-02-2418:16Sam RitchieFor cljs #2022-02-2418:16Sam RitchieI can prove it when I'm at a computer, I'll put this together for the cljs folks and see if this changed with the recent version or it's been this way #2022-02-2418:53thhelleroh I didn't see the :refer. that was just about regular +#2022-02-2418:53thhelleryeah that doesn't seem right#2022-02-2418:54thhellerbut fwiw potemkin import-def is absolutely not ideal for CLJS#2022-02-2418:55Sam RitchieYup, I wrote my own lighter weight one for cljs vs using Potemkin… it doesn't pull any metadata over etc which is not ideal #2022-02-2418:56Sam Ritchiehttps://github.com/sicmutils/sicmutils/blob/45e251d70b7199a33de8774eec3dde0a1639c3f1/src/sicmutils/util/def.cljc#L91#2022-02-2418:56Sam RitchieNot ideal but works for now #2022-02-2419:21thhellerdid you try this with regular CLJS? as far as I can tell shadow-cljs is doing everything it is supposed to#2022-02-2419:24thhellerhmm yeah I can reproduce this with just cljs.main#2022-02-2419:24thhellernot sure what is happening#2022-02-2419:24thhellerguessing something with the inference stuff around those functions#2022-02-2419:30thhellerrepro reported in #cljs-dev maybe someone has an idea. not sure if this is a known issue.#2022-02-2421:34Sam RitchieThank you for the repro!#2022-02-2405:46thheller
$ clj -M -m cljs.main
Failed to launch a browser:

No X11 DISPLAY variable was set,
but this program performed an operation which requires it.

You can instead launch a non-browser REPL (Node or Nashorn).

You can disable automatic browser launch with this REPL option
  :launch-browser false
and you can specify the listen IP address with this REPL option
  :host "127.0.0.1"

Waiting for browser to connect to  ...
ClojureScript 1.10.866

(+ 'x 'x)
WARNING: cljs.core/+, all arguments must be numbers, got [cljs.core/Symbol cljs.core/Symbol] instead at line 1 <cljs repl>
"xx"
#2022-02-2502:41hoppylatest shadow, latest spacemacs, attempting to jack in a node repl:#2022-02-2502:41hoppy#2022-02-2502:41hoppyany ideas?#2022-02-2505:43thheller@hoppy spacemacs trying to initialize the REPL wrong. dunno what it is sending but looks like a regular piggiback init with an invalid argument#2022-02-2511:16SimonCould it be possible to increase compilation speed by using nextjs’ Rust compiler? https://nextjs.org/blog/next-12#2022-02-2515:09pezI'm getting compilation errors on inline defs. foo at line X is being replaced if foo is defed elsewhere. Is there a way I can stop that? The project is using shadow-cljs version 2.16.7.#2022-02-2517:07thheller@pez you stop that by doing that? the warning is there for a reason? I'm assuming here you mean (def foo 1) and then (def foo 2) later?#2022-02-2517:11thheller@simon.el.nahas no#2022-02-2517:58pez@thheller yes, like that. However, they are both inline, and in different functions. I'd like to have some way to say that I am allowing myself to do it. 😃#2022-02-2519:08thhellerI don't know what you are doing but def is top level only and shouldn't be used anywhere#2022-02-2622:14pezWhile developing I am often doings stuff like
(defn hello [x]
  (def x x)
  (str "Hello " x))
Then after I call (hello "foo") i can evaluate (str "Hello " x) to inspect how my function works.
#2022-02-2706:12thhellerah. much easier to understand what you are talking about with an actual code sample#2022-02-2706:13thhelleryou can set :compiler-options {:warnings {:redef-in-file false}} to disable this particular warning. although I don't recommend doing so since this is a useful warning to warn that you left some debug code which may have unintended side effects for :advanced or so#2022-02-2707:26pezYes, I like the warnings, it’s the error that is causing me troubles. #2022-02-2707:30pezI get neither warnings nor errors when I only have one such inline def for a given symbol, btw. It’s when I have more than one for the same symbol that things blow up. #2022-02-2519:08thhellerif you are trying to explicitely override the value of a def you can use (set! that-def "later")#2022-02-2519:09thhellera def can't be defined first inline either. that is not how the compiler works.#2022-02-2519:33UlisesMACHi all! I've seen a strange error while trying to use JSX code. I'm requiring and using a Card component written in JSX into ClojureScript, the component itself works well in a ReactJS project. The problem raises when this JSX component uses the  moment library, using moment() (without params) just works, but when passing any kind of parameter (e.g. date or string) to the same function, Shadow-cljs raises an exception. I've already tried importing and using moment from cljs and it works well with & without params, so this problem is only present when using it in JSX code and importing it to cljs. Someone have had this problem or know any solution? Thanks! Here's the stack trace when calling it as moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString() (calling it as moment().toString() doesn't give any problem)
[:app] Compiling ...
[:app] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.classpath/resource "components/common/components/Button/Button.js"] [:shadow.build.classpath/resource "components/common/components/Tag/Tag.js"] [:shadow.build.classpath/resource "components/common/components/Card/hooks/useCard.js"] [:shadow.build.classpath/resource "components/common/components/Card/Card.js"]]}
ExceptionInfo: failed to convert sources
        shadow.build.closure/convert-sources*/fn--12611 (closure.clj:1540)
        shadow.build.closure/convert-sources* (closure.clj:1534)
        shadow.build.closure/convert-sources* (closure.clj:1419)
        shadow.build.closure/convert-sources (closure.clj:1759)
        shadow.build.closure/convert-sources (closure.clj:1691)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1454)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:463)
        shadow.build/compile (build.clj:453)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:540)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:495)
        shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942/fn--15950 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--15941 (util.clj:241)
        java.lang.Thread.run (Thread.java:829)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(CALL): components/common/components/Card/Card.js:56:6
      moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString()
  Parent(GETPROP toString): components/common/components/Card/Card.js:56:74
      moment("Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)").toString()

        com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2907)
        com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
        com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
        com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
        com.google.javascript.jscomp.ConstParamCheck.process (ConstParamCheck.java:63)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
        com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:566)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/convert-sources*/fn--12611/fn--12612 (closure.clj:1538)
        shadow.build.closure/convert-sources*/fn--12611 (closure.clj:1535)
        shadow.build.closure/convert-sources* (closure.clj:1534)
        shadow.build.closure/convert-sources* (closure.clj:1419)
        shadow.build.closure/convert-sources (closure.clj:1759)
        shadow.build.closure/convert-sources (closure.clj:1691)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1454)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:463)
        shadow.build/compile (build.clj:453)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:540)
        shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:495)
        shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942/fn--15950 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--15941/fn--15942 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--15941 (util.clj:241)
        java.lang.Thread.run (Thread.java:829)
Caused by:
NullPointerException: 
#2022-02-2519:37UlisesMACAlso using moment(new Date()).toString() raises the same exception.#2022-02-2519:38thhellerwhat is moment though? I mean how was it imported?#2022-02-2519:39UlisesMACIt is
import moment from 'moment';
and in package.json is
"moment": "^2.29.1",
(here's the library URL https://momentjs.com/)
#2022-02-2519:40thhellerhmm yeah seems fine. no clue whats up with that#2022-02-2519:40UlisesMACIf I use it in cljs as: ["moment" :as moment] when using the REPL, it just works:
(.toString (moment "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)"))
=> "Fri Feb 25 2022 12:40:18 GMT-0600"
#2022-02-2519:42UlisesMACI can still pass that date from cljs as a parameter to that JSX component, but it was strange.#2022-02-2519:42UlisesMACThanks @thheller!#2022-02-2519:43thhellerwhich shadow-cljs version? maybe try the latest? also has latest closure compiler verison#2022-02-2519:47UlisesMACI'm using "2.16.12", I'll update it and try again#2022-02-2519:59UlisesMACThe error persists. If I find a solution I'll post it here.#2022-02-2613:37David VujicI have an idea about what may cause it: just experimented with importing a JavaScript file, that imports the moment library, and could reproduce it when using “modern js” syntax. When using the CommonJS syntax all went as expected. Could it be that the jsx component need to go through a Babel parser before requiring it to your clojurescript namespace?#2022-02-2613:42David VujicSo, this will work:
const moment = require("moment");

function getFriday() {
    const d = "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)";
    return moment(d);
}

module.exports = {
    getFriday,
};
By replacing the import to
import moment from "moment";
will output the error.
#2022-02-2615:19thhellerinteresting. that should be easy to reproduce then#2022-02-2616:22David VujicI think that moment might be the reason. Could it be some CommonJS vs ES support thing in the package? :thinking_face: Tried out date-fns, using the ES syntax import { formatISO } from "date-fns" and also exporting the function using export default myFunction and that works fine when importing into ClojureScript.#2022-02-2519:37thhellerweird. that is a closure compiler error. dunno what the problem is though#2022-02-2519:40UlisesMACIf I use it in cljs as: ["moment" :as moment] when using the REPL, it just works:
(.toString (moment "Fri Feb 25 2022 12:40:18 GMT-0600 (Central Standard Time)"))
=> "Fri Feb 25 2022 12:40:18 GMT-0600"
#2022-02-2614:04orestisHow do people run clojure.test tests that need the context of a real browser? The guide mentions Karma plus a couple of plugins... is that still the recommended approach? In my case I'd probably use the karma playwright launcher but I was wondering about the approach in general.#2022-02-2614:12Braden Shepherdsonthere's some interesting work happening with kaocha-cljs2, but I don't think it's fully ready to go yet.#2022-02-2614:15orestisI saw that but it didn't inspire a lot of confidence - but it would be nice to also run tests from the REPL. Not sure how that works, I need to setup of PoC...#2022-02-2616:02lilactownwe've been using the same karma setup for a couple years now. work well#2022-02-2616:02lilactownthere's also the in-browser test runner when developing locally#2022-02-2616:03lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test#2022-02-2616:03lilactownit uses https://github.com/Olical/cljs-test-runner to show your tests in the browser#2022-02-2616:05lilactownyou can also, in your running app, evaluate a ns with tests in it and then call cljs.test/run-tests#2022-02-2616:05lilactownif you'd like the REPL#2022-02-2616:19thhellerit doesn't use that at all?#2022-02-2619:44lilactownI thought shadow-cljs did include that by default? maybe I'm totally misremembering lol#2022-02-2619:45thhellermaybe you mean https://github.com/bhauman/cljs-test-display?#2022-02-2619:58lilactownthat is what I'm thinking of, yep#2022-02-2806:53jumarI'm getting the following error when running cider-jack-in-cljs in emacs ,the selecting shadow as the repl type
;; ClojureScript REPL type: shadow
;;
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
The required namespace "react" is not available, it was required by "reagent/core.cljs".

To quit, type: :cljs/quit
[:selected :app]
It appears to work when I run it from cli:
npm run dev
...
shadow-cljs - server version: 2.11.23 running at 
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (165 files, 164 compiled, 0 warnings, 17.84s)
What could be a reason for that? It worked fine the last week
#2022-02-2806:54jumarHere's the shadow-cljs.edn file: https://github.com/jumarko/learn-reagent/blob/develop/increments/complete/shadow-cljs.edn#L1#2022-02-2806:55jumarNevermind, I found the problem - I was using a wrong shadow-cljs.edn file. The correct one is https://github.com/jumarko/learn-reagent/blob/develop/giggin/shadow-cljs.edn#L1#2022-02-2813:31orestis@lilactown indeed karma works nicely. I am using playwright instead to run against three browsers at a time which is nice. Haven't tried it on CI yet but on Mac it works nicely. #2022-02-2816:38orestis^ also works fine on Travis after a few back-and-forth sessions.#2022-02-2819:18MarconiHi, I'm developing a web app and source maps work fine on desktop, but not on chrome for android (using the PC's devtools). The message (loads of other files) is: DevTools failed to load source map: Could not load content for http*/cljs-runtime/*.js.map: Fetch through target failed: Target not supported; Fallback: Unknown error Already checked that the URL is accessible in the mobile browser. Any ideas why? And is it possible to get it working? Thanks.#2022-02-2819:21thhellerwell if you truncate the error message it is really hard to tell what is going on#2022-02-2819:22thhellerwhat Target is it trying to get? like what is the full url of the .map?#2022-02-2819:24thheller"Target" being the host address I'd presume?#2022-02-2819:24thhellermaybe try setting :devtools {:loader-mode :script} in your build config#2022-02-2819:32MarconiSorry, thought it would be irrelevant, since the map file URL opens in the mobile browser successfully. The full path of one of the errors is https://host/cljs-runtime/goog.events.eventid.js.map.#2022-02-2819:34thhelleris it a literal host? I mean this is the root of your problem. it doesn't help if you change it 😛#2022-02-2819:35thhellerif you are trying to hide a IP then check if its the actual IP reachable by both the host PC and the Android device#2022-02-2819:35MarconiTrying not to expose private info X). It's a FQDN, where the app is running. Like http://myapp.me.com#2022-02-2819:35thhellerand that domain AND port is reachable by both?#2022-02-2819:37MarconiYes. It is the same base address in the browser's address bar. It's being served by an nginx proxying to shadow-cljs.#2022-02-2819:38MarconiI've set :devtools-url in shadow-cljs.edn for it to work through https. In the repl I get to access the mobile browser's runtime#2022-02-2819:38thhellerI assume this is using https? is the cert also valid on both devices?#2022-02-2819:39thhellerI mean I don't know who is actually trying to get the source maps#2022-02-2819:39thhellersounds like the PC stuff is trying to get it over the android device
#2022-02-2819:39thhellerdunno what "Unknown error" means. doesn't seem like something shadow-cljs is involved in at all#2022-02-2819:39MarconiYes. Self signed, but I added it to both browsers and the app works fine, including the https exclusive stuff#2022-02-2819:40thhellerhmm yeah but self-signed is always a problem. it might not be trusted by the devtools so thats why it might fail#2022-02-2819:40thhellerget a letsencrypt cert. less hassle 😛#2022-02-2819:42MarconiGood idea. Will get that and investigate devtools. Thank you for your help and for shadow-cljs!#2022-02-2823:27MarconiI tested first without https, nginx, etc to see if I could reproduce the error. And it still happens: (this time verbatim) DevTools failed to load source map: Could not load content for http://192.168.10.100:5000/cljs-runtime/clojure.string.js.map: Fetch through target failed: Target not supported; Fallback: Unknown error DevTools failed to load source map: Could not load content for http://192.168.10.100:5000/cljs-runtime/shadow.remote.runtime.obj_support.js.map: Fetch through target failed: Target not supported; Fallback: Unknown error Just two examples. There are hundreds of lines like these. What I could identify is that the only file specific to my app is a web worker. My related :modules: :shared {:entries []} :main {:entries [main] :depends-on #{:shared} :preloads [dev-preload]} :worker-pricemeter {:init-fn workers.pricemeter/init :depends-on #{:shared} :web-worker true} Any ideas?#2022-02-2823:30MarconiI also tried :loader-mode :script to no success#2022-03-0104:56thheller@marconirivello did you try it within :devtools? it won't apply anywhere else. I don't know what "Unknown error" is so I don't have any guesses what it could be#2022-03-0110:59Quentin Le GuennecDo unused node_modules dependencies get removed from a :target :browser shadow build?#2022-03-0116:33thhellerdefine "unused". if you don't require it then it will not be included in the first place, so no need to remove it. just the presence in node_modules does not mean it is included in the build.#2022-03-0210:45Quentin Le GuennecGot it, thank you!#2022-03-0214:27folconI'm trying to port an existing cljsbuild to shadow-cljs, the reason I used cljsbuild in the first place was that I couldn't work out how to get shadow to use my externs and local javascript files, I'm trying to require my files and so far I'm not having any luck in getting shadow to detect them... Is there a specific file layout that I should be using? Also is it possible for all of the functions in the javascript files to included verbatim, jsdoc's and all? Basically I'd like to compile the clojurescript code with :advanced optimisations, but include some js in the source that's not been modified at all... By include I mean inline. ===== EDIT ===== Ok, I've managed to get it to build, but not sure how to get the js code to inline in correctly? (I'm also wondering is the appropriate thing to do is to just cat <path to js files> >> shadow-generated.js or is there something better? I'd like to do everything cljs land, but at the moment generating the correct structures is not going well...#2022-03-0217:09thheller@folcon what kind of code are you trying to append? does it not make more sense to keep as a separate file?#2022-03-0217:13folconI'm building a google app script project. I have clojurescript that wraps the google externs and then some javascript for writing the functions that can be read by the google environment. Google's engine only accepts certain forms: https://developers.google.com/apps-script/guides/v8-runtime And if you want to use custom functions (which we do) then we also have to emit jsdoc's of the correct format, which we've not worked out how to do yet... So for the moment, we hand write that and append it on...#2022-03-0217:13folconI've gotten this working with cljsbuild But I'd like to use shadow so I can start pulling in npm modules. It would be useful if I can just output a single file which we can then trigger an upload on. Though failing that I can do some bash magic to get the output#2022-03-0217:14thhelleryou can do this fine in just CLJS?#2022-03-0217:14folconYes, with cljsbuild#2022-03-0217:14thhellerno, just plain CLJS. no .js file#2022-03-0217:15thhelleror I'm missing something. do you have an example of the .js file you are appending?#2022-03-0217:16folconThe environment doesn't understand cljs itself, so not sure what you mean there? They have a format called .gs which is broadly v8 compatible which is what the target is#2022-03-0217:16folconSure, let me grab an example#2022-03-0217:16folconLambda island did a short writeup if that's helpful as well: https://lambdaisland.com/blog/2016-10-01-clojurescript-and-google-apps-script#2022-03-0217:18thhellerah. I remember something like this#2022-03-0217:19thhellerI'd just (js* "onOpen(e) { attendomat.core.create_menu(); }") in my .cljs ns instead of appending it 😛#2022-03-0217:19folcon
/**
 * Returns the domain for a given name
 * @param {"Apple"} name The value or range of cells
 *     to lookup the domain for.
 * @return The domain of the website
 * @customfunction
 */
function WEBSITE_LOOKUP(name) {
 Array.isArray(name) ?
        name.map(row => row.map(cell => fetch_sitedata(cell, 'domain'))) :
        fetch_sitedata(name, 'domain');
}

function test_WEBSITE_LOOKUP() {
    Logger.log(String(WEBSITE_LOOKUP("Google")));
}
#2022-03-0217:19folconDoes that work for stuff like the above?#2022-03-0217:20folconIf the jsdoc comment is not correctly written out it barfs#2022-03-0217:21thhellerhmm yeah for jsdoc it is best to just append manually#2022-03-0217:21thheller:advanced will otherwise kill it#2022-03-0217:21thhellerso yeah appending might be best#2022-03-0217:21thhelleryou could do that in a build hook I guess#2022-03-0217:21folconI'm trying to work out how to structure this#2022-03-0217:23folcon
{:source-paths
 ["src/dev"
  "src/main"
  "src/js"
  "src/test"]

 :dependencies
 [[applied-science/js-interop "0.3.1"]]

 :builds
 {:appscript {:output-to "Code.js"
              :output-dir "target"
              :compiler-options {:externs ["resources/gas.ext.js"]}
              :exports-fn humble-app-script.core/generate-exports
              :js-options {:js-provider :shadow}
              :release {:compiler-options {;:optimizations :whitespace
              																													:pretty-print true}}
														:target :npm-module
														:entries [example.core]}}}
#2022-03-0217:23folconis it :npm-module or :node-library or :browser?#2022-03-0217:24thhellerneither 😛#2022-03-0217:24folconSo what should my target be 😃#2022-03-0217:25thhellertechnically it would be :target :google-appscript or something#2022-03-0217:25thhellerthat just doesn't exist yet 😛#2022-03-0217:26thhellerbut that what :target is for. this is neither a browser nor node so none of the above fit.#2022-03-0217:26folconAh, so it doesn't call any special functionality based on the target name#2022-03-0217:26folcon
Target ":appscript" for build :appscript was not found. The built-in targets are:
  - :browser
  - :browser-test
  - :node-script
  - :node-library
  - :npm-module
  - :karma
  - :bootstrap
#2022-03-0217:26thhellertargets assume the presence of certain functionality.#2022-03-0217:27thhellerwell yes. as I said this doesn't exist. someone would need to implement it#2022-03-0217:27folconRight, what would that require? Or should I just use an existing target?#2022-03-0217:28thhelleryou can use an existing target but as I you have encountered that will always be a hack and require certain manual tweaks#2022-03-0217:29thhellerI don't expect you to implement a custom target but thats what I would do if I had time and actual use for it 😛#2022-03-0217:30folconOk, well at the moment I'm trying to generate functions that fulfil this format:
function normalFunction() {}
      async function asyncFunction() {}
      function* generatorFunction() {}

      var varFunction = function() {}
      let letFunction = function() {}
      const constFunction = function() {}

      var namedVarFunction = function alternateNameVarFunction() {}
      let namedLetFunction = function alternateNameLetFunction() {}
      const namedConstFunction = function alternateNameConstFunction() {}

      var varAsyncFunction = async function() {}
      let letAsyncFunction = async function() {}
      const constAsyncFunction = async function() {}

      var namedVarAsyncFunction = async function alternateNameVarAsyncFunction() {}
      let namedLetAsyncFunction = async function alternateNameLetAsyncFunction() {}
      const namedConstAsyncFunction = async function alternateNameConstAsyncFunction() {}

      var varGeneratorFunction = function*() {}
      let letGeneratorFunction = function*() {}
      const constGeneratorFunction = function*() {}

      var namedVarGeneratorFunction = function* alternateNameVarGeneratorFunction() {}
      let namedLetGeneratorFunction = function* alternateNameLetGeneratorFunction() {}
      const namedConstGeneratorFunction = function* alternateNameConstGeneratorFunction() {}

      var varLambda = () => {}
      let letLambda = () => {}
      const constLambda = () => {}

      var varAsyncLambda = async () => {}
      let letAsyncLambda = async () => {}
      const constAsyncLambda = async () => {}
Or that are a custom function in the form I gave earlier
#2022-03-0217:30thhellerall existing targets are here https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2022-03-0217:31thhelleryeah I do remember that this was a problem#2022-03-0217:31thhellergiven that the CLJS compiler can't emit that#2022-03-0217:32thhellerand (defn ^{:export "onOpen"} my-on-open [e] ...)#2022-03-0217:32folconWhat's the best way to proceed, I'd just want to sort of get started, I've got a bunch of js code and a bit of cljs code and I'm slowly porting the js bits over which can be ported...#2022-03-0217:32thhellerends up as a goog.exportSymbol("onOpen", function(e) { ... }) which is not recognized#2022-03-0217:33thhellerjust append the file seems best to me#2022-03-0217:33folconOk, well is there a way to do that internally? I'm currently just using bash to cat and >>#2022-03-0217:34thhellerI'd be using cat and >> too#2022-03-0217:34folconI also need to make sure the output doesn't produce calls to global#2022-03-0217:35thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2022-03-0217:36thheller
(defn hook
  {:shadow.build/stage :flush}
  [build-state & args]
  (spit
    (io/file "regular" "out.js")
    (slurp (io/file "file-to-append.js"))
    :append true)
  build-state)
#2022-03-0217:38folconI'm trying to use :target :node-library and it doesn't like this:
'use strict';
var b, a = global;
error:
ReferenceError: global is not defined
(anonymous)	@ 
(anonymous)	@ 
(anonymous)	@ 
#2022-03-0217:39folconlooking at the hooks docs you linked#2022-03-0217:39thhelleras I said .. :node-library the target EXPECTS a node runtime#2022-03-0217:39thhelleryou cannot make that go away. this is hardcoded into the target as the name implies#2022-03-0217:40thhelleryou best bet might be :browser but then disable everything browser related#2022-03-0217:40thhellerso :devtools {:enabled false} in the build config#2022-03-0217:43folconIs that going to have an effect when I'm trying to get a repl working for dev?#2022-03-0217:44thhelleryes. no REPL support then#2022-03-0217:44thhellermeaning to REPL into the google appscript#2022-03-0217:44thhellerbut doesn't sound like that would work anyways?#2022-03-0217:44thhelleryou can open a browser-repl or node-repl anytime. that is not affected in any way#2022-03-0217:46folconNo, but it would be useful to be able to have a local repl#2022-03-0217:47folconI can then mock some of the environment and then do repl based development, but still compile out a release that goes to the google appscript#2022-03-0217:47thhelleryes, that is what I described#2022-03-0217:48folconOk, that's good 😃#2022-03-0217:48thhelleryou can npx shadow-cljs browser-repl anytime. requires no build config or so#2022-03-0217:48folconJust testing this out#2022-03-0217:49folconBtw, does the args in the hook you gave contain the final build path?#2022-03-0217:49folconI'd prefer not to hardcode it like:
(io/file "regular" "out.js")
#2022-03-0217:50folconOr should I check out the build/targets directory on github for how to navigate that 😃#2022-03-0217:58folconHmm, not sure why, but it's not generating the export. I've got an included js script file that I'm importing using your example:
(:require ["./entry_points" :as entry-points])

(defn generate-exports []
  #js {:fetch_sitedata entry-points/fetch_sitedata})
I've got this in shadow-cljs.edn:
:output-to "Code.js"
:exports-fn example/generate-exports
So when I look inside the target/main.js there is no fetch_sitedata function defined, I've been grepping for the name and it's not there... Also not sure why it's ignoring my :output-to instruction and is just generating the file main.js inside target dir...
#2022-03-0218:08thhellerplease consult the actual shadow-cljs documentation for the chosen :target#2022-03-0218:08thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#2022-03-0218:08thhellerie. :target :browser does not have a :output-to option and neither does it have a :exports-fn option#2022-03-0218:08folconAh cool, thanks#2022-03-0218:08folconI'll do that#2022-03-0218:09thhellerand be requiring the entry_points.js you are adding it to your build#2022-03-0218:09thhellerwhich means it'll go through :advanced. which I thought you were trying to avoid?#2022-03-0218:11folconThere's two js files, entry_points.js which has some wrapper code which I'm slowly going to be getting rid of, but probably should go through the pipeline and custom_functions.js which I'm appending#2022-03-0218:13folconI'll stick js in the appropriate file, but some functions in the entry_points.js need to be called in my clojurescript and for some reason though they're in my :exports-fn example/generate-exports in shadow-cljs.edn, it's not appearing inside the final main.js#2022-03-0218:14thhellerI don't know what you are expecting to appear#2022-03-0218:15thhellerbut :target :node-library recognizes :exports-fn. no other target does, so it will do nothing for those. and the only thing that will appear for :node-library is module.exports = your.ns.generate_exports();#2022-03-0218:15thhellerwhereas the your.ns.generate_exports() part may be renamed and shortened by :advanced#2022-03-0218:19folconAh, sorry, yep that makes sense. I'm mixing up target instructions. Basically my goal is to take some of the functions defined inside entry_points.js and export them so they're available in the final output. Should I just create something like this:
(ns example
  (:require [clojure.string :as str]
            [applied-science.js-interop :as j]
            ["./entry_points" :as entry-points]))

(def ^:export fetch_sitedata entry-points/fetch_sitedata)

;; OR
(defn ^:export fetch_sitedata [] (entry-points/fetch_sitedata))
#2022-03-0218:21thhellerthis is not how this works at all#2022-03-0218:21thhellerand not solving your problem in any way either#2022-03-0218:21folconFair 😃#2022-03-0218:21thhellerby including entry_points like above you are including it as part of the build#2022-03-0218:22thhellermeaning it will be fully processed, minimized and everything#2022-03-0218:22thhellerso whatever you did there to be app-script specific will be gone#2022-03-0218:23thhelleror I'm missing something here#2022-03-0218:23thhellerit would make this really much much easier to talk about if you create a repo with some code#2022-03-0218:23thhellerstandalone partial snippets are just not enough#2022-03-0218:24folconYep, just saw this:
n("example.fetch_sitedata", vf.fetch_sitedata);

}).call(this);
The definition of fetch_sitedata is missing... vf is probably some import, but one that doesn't seem to contain any of the original fetch_sitedata definition
#2022-03-0218:25folconHmm ok let me put together an example case after dinner and poke you in this thread? Would that work?#2022-03-0218:25thhelleryes that is the export problem I was referring to above#2022-03-0218:25thhellersure#2022-03-0218:25folconThanks#2022-03-0219:10folconHow does this look? I tried to make a minimal example https://github.com/Folcon/example-appscript#2022-03-0219:14thhellerjust a tip#2022-03-0219:15thhellerinstead of (println (keys build-state)) in the build hook#2022-03-0219:15thhellertry (tap> build-state) and then look at it in #2022-03-0219:15folconYea, still not used to tap> in cljs projects#2022-03-0219:16thhellerthis is clojure code 😉#2022-03-0219:16folconThis is why I want to get shadow working 😃#2022-03-0219:18thhellerwhat are you using to edit code? you should really run a formatter. the shadow-cljs.edn is a complete mess :P#2022-03-0219:18thheller:output-to "Code.js" has no effect for :browser#2022-03-0219:19folconNormally cursive, but currently sublime as I'm throwing a minimal example together 😃#2022-03-0219:19folconYep, I need to generate a single file output, similar to webpack#2022-03-0219:20folconWhich contains a mixture of advanced compilation code + appended js code#2022-03-0219:20thhellerthis build config will generate this as target/main.js#2022-03-0219:20thheller:output-dir + the keys in the :modules map#2022-03-0219:21folconRight, so I should use a Makefile or another hook, to copy it to the correct location and append the other file?#2022-03-0219:21thheller
{:source-paths
 ["src/dev"
  "src/main"
  "src/js"
  "src/test"]

 :dependencies
 [[applied-science/js-interop "0.3.1"]]

 :builds
 {:appscript
  {:target :browser
   :output-dir "target"
   :modules {:main {:entries [app-script.core]}}
   :devtools {:enabled false}
   :build-hooks [(app-script.hooks/build-hook)]
   :compiler-options {:externs ["resources/gas.ext.js"]}}}
#2022-03-0219:22thhellerthe hook you have now does nothing since it doesn't use the target/main.js file?#2022-03-0219:22folconBut yea, not sure why the function inside the entry_points.js isn't getting exported#2022-03-0219:22thhellerbtw npx shadow-cljs pom then import pom.xml in cursive as a project#2022-03-0219:23thhelleras I keep trying to tell you ... you are importing it into the build. IT WILL BE PROCESSED!#2022-03-0219:23thhellerthat means that the function it has will be DELETED since it is not referenced anywhere#2022-03-0219:24thhelleryou can actually export it by writing proper ESM code#2022-03-0219:24thhellerso instead of
function mult_vals(a, b) {
  return a * b;
}
#2022-03-0219:24thheller
export function mult_vals(a, b) {
  return a * b;
}
#2022-03-0219:24folconAh ok#2022-03-0219:24folconSo just add an export directive in the js will work?#2022-03-0219:24folconGreat#2022-03-0219:25thhellerthen mult_vals is accessible via entry-points/mult_vals#2022-03-0219:25thhellerBUT that still doesn't make :exports do what you want and it never will#2022-03-0219:25thhellerthis is not how the code is constructed#2022-03-0219:26thheller
(def ^:export mult_vals [a b]
  (* a b))
#2022-03-0219:26thhelleris identical as far as the generated code is concerned. the entire entry_points.js indirection does absolutely nothing#2022-03-0219:27thhellercan you explain what exactly you are trying to achieve via that entry_points stuff? like what does the final generated JS need to look like#2022-03-0219:27folconSure give me a sec to write it up#2022-03-0219:33folconSo the entry_points.js contains effectively working code that is broadly legacy. When I was porting it to cljs I realised that because app-script has it's own weird formats and rules I'd have to feed it javascript to be able to work around some behaviours. So I split it up into custom_functions.js and the original entry_points.js. The idea was that anything we couldn't just port over that was externally facing could live inside custom_functions.js. Any legacy stuff that was still in the process of being ported over that was internal behaviour could live in entry_points.js which could be called and wrapped by clojurescript code. So we have functions like mult_vals which need to be called by functions in the clojurescript code or by functions in custom_functions.js. But are not by themselves public. I'd prefer to run as much as possible through the closure compiler to minimise / remove stuff we don't need. But in the worst case we can just use simple optimisations for now.#2022-03-0219:42thhellerok so then prepend or append BOTH entry_points.js and custom_functions.js to the output#2022-03-0219:42thhellerinstead of requiring it just use js/mult_vals or whatever in the CLJS code#2022-03-0219:43thhellersince they are global functions that is fine#2022-03-0219:43thhellerif you want to include it in the build then you can require it like you did#2022-03-0219:44thhellerbut it will require adding export in the .js and re-exporting it so app-script can find it WILL NOT WORK!#2022-03-0219:44thhellerthis is just a limitation in the way the closure compiler treats exported things and there is no way to change that#2022-03-0219:45thhellerso you can only :export them and refer to them by the full name via the JS that is not going through the closure compiler#2022-03-0219:46folconOk, fair enough does that also work if I'm using them at the repl?#2022-03-0219:46folconAs in if I append / prepend with the hook?#2022-03-0219:46thhellerthey'll not be available in the REPL in any way#2022-03-0219:48folconOk#2022-03-0219:49thhellerwell you can sort of make them available I guess#2022-03-0219:49thhellercreate a public folder and put the entry_points.js there#2022-03-0219:50thhellerthen create a index.html that loads them via <script src="/entry_points.js"> and <script src="/js/main.js">#2022-03-0219:50thhellerthen in the shadow-cljs.edn add :dev-http {3000 "public"} and set :output-dir "public/js"#2022-03-0219:50folconSure#2022-03-0219:51folconOk, that makes sense#2022-03-0219:51thhellerand will access to the functions via js/mult_vals or whatever#2022-03-0219:51thhellerjust like the appscript would#2022-03-0219:51folconThanks a lot, I'll see if I can use that to fix my project#2022-03-0217:10thhellerthere are :prepend and :append options in :modules but they only take strings. so doesn't make sense if its too long#2022-03-0217:10thheller:modules {:main {:init-fn :append "\n// yo\n"}}}#2022-03-0218:08socksyI'm having a weird issue where I can't seem to run all the tests in my project with a node-test target. Using shadow 2.17.5, and with a basic target like this:
:test {:target :node-test
                 :output-to "target/test.js"
                 :ns-regexp "-test$"}
I can get it to work if I pass in the NS directly with like node target/test.js --test=foo.foo-test. It successfully finds 4 -test$ NS's, but no others... I tried using ".*" as the regex also to no avail. I can also confirm that the namespaces are correctly built and are loaded (by chucking a console.log into the built namespace in .shadow-cljs/builds/tests/dev/out/cljs-runtime/foo.foo_test.js). Any ideas?
#2022-03-0218:12thhellerhow are the tests written? should be fine without any --test option#2022-03-0218:25socksytests are written the same way as the working namespaces – using cljs.test , deftest, and the async macro#2022-03-0218:26thhellerand what happens if you just run node target/test.js?#2022-03-0218:26thhellerI mean all --test does is filter out tests that don't match#2022-03-0218:26thhellerthe default is to run all. so something must be off? --test does not affect compilation in any way.#2022-03-0218:26socksyit runs the tests in the 4 namespaces I mentioned#2022-03-0218:27socksycompilation is not seemingly affected in anyway, no – it's all there#2022-03-0218:29socksyis there some way to step through and see the logic?#2022-03-0218:35socksyah! I think I solved it! One of the tests in the last NS found used (async done blah) but didn't call (done) and so stopped the rest of the tests running. But weird that the test completed at all#2022-03-0218:40thhellerits node so it'll exit when there are no more pending callbacks or whatever. it just assumes the program ended properly.#2022-03-0219:25Alexis SchadHi there! I'm having a dependencies issue that I can't reproduce in pure JS, so I think it is shadow-cljs related. I want to use a library that uses multiple versions of the same dependency, it looks like this folder tree: node_modules -- dep A ---- node_modules ------ dep B v2 -- dep B v1 => It is always the dep B v1 that is used, even in the dep A code. The dep A code uses common JS API (`require`). I can't find in the guide how I can make this work as expected. (The library I try to use is @uiw/react-textarea-code-editor )#2022-03-0219:28thhellerwhich shadow-cljs version do you use? this was not supported until rather recently#2022-03-0219:46Alexis SchadThe last one: 2.17.5 (I double checked with shadow-cljs info)#2022-03-0219:47thhellerdo you use project.clj or deps.edn? if so the version listed by info does not apply#2022-03-0219:56Alexis Schadhmm, I don't know. It is installed by npm#2022-03-0219:57thhellerthat version should support the nested packages. unless you disabled that in the build config#2022-03-0220:02Alexis SchadI don't think so
{:asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :target :browser}
I can create a minimal projet if you want
#2022-03-0220:02thhellerthat always helps#2022-03-0221:17Alexis SchadHere it is: https://github.com/schadocalex/shadow-cljs-deps-issue Actually it uses the wrong version of a sub sub dependency, not directly a sub dependency#2022-03-0221:22Alexis Schadit works for the first sub dependency#2022-03-0221:26Alexis Schadrelated issue with more details : https://github.com/thheller/shadow-cljs/issues/995#2022-03-0221:39Michael MossinsohnMy boss would like my JS output to make life as easy as possible for JS programmers to both interact with and possibly even to 'take over' in case I leave the project. I use Reagent to create a React based app and use Shadow-cljs for compilation. How can I get my code and/or my config to be as JS friendly as possible (when compiled for development)?#2022-03-0222:01Alexis SchadYou can't, you can only set up your project to be used as a black box library#2022-03-0222:28Michael MossinsohnOhh, I see. Thanks for clarifying this up for me.#2022-03-0301:05bbssWell, you can export. https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper https://shadow-cljs.github.io/docs/UsersGuide.html#_multiple_static_named_exports#2022-03-0306:21steveb8nQ: is there a way to use shadow deps (not deps.edn deps) but using a git repo instead of a maven/clojars dep?#2022-03-0306:21steveb8ni.e.
{:git/url    ""
                                 :sha        "36894d9fd348576e265a6c129664fba159c4b319"
                                 :exclusions [thheller/shadow-cljs]}
but in the shadow-cljs.edn
#2022-03-0306:22steveb8nmight seem a bit odd but I have a situation where I have code that I need to load in a local repl but ignored by shadow. I have a second source path called “generated” and that’s the only place I want shadow to find source files#2022-03-0306:23steveb8nnormally I would do this by letting shadow control the source paths i.e. :deps false#2022-03-0306:23steveb8nbut I am using the git dep above so I need deps.edn to load it. so now I’m stuck between 2 goals#2022-03-0306:24steveb8nI can’t figure out a good directory layout to get around this#2022-03-0306:25steveb8nanother option would be to load using deps.edn but then use the shadow api to remove the “src” path before it is started#2022-03-0306:44thhellershadow-cljs.edn does not support git deps#2022-03-0306:45thhellerbut doesn't sound like you actually need that?#2022-03-0306:45thhellerI mean just create a local checkout with whatever version you want#2022-03-0306:45thhellerand add :source-paths ["src/main" "../that-checkout/src/generated"] or so?#2022-03-0306:45thhelleryou can still add the regular dependency as well but it will pick source files from the source path over the files in the jar#2022-03-0306:48thhellerthat lib doesn't have a generated dir though? not sure I get what you are after 😛#2022-03-0306:49steveb8nyeah I was just looking a docs and the use case is similar to https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2022-03-0306:49thhellerbut that lib is cljs?#2022-03-0306:50steveb8nthat’s an interesting idea. just checkout the git lib locally and then use shadow for deps, pointing at that dir#2022-03-0306:50steveb8nit’s https://github.com/ribelo/doxa but I’m using a non-master branch#2022-03-0306:52steveb8nok. I’ll try a local checkout. that would be a simple/easy fix until doxa gets a clojars release#2022-03-0306:52steveb8nthanks! I’ll report back here#2022-03-0400:06steveb8n@U05224H0W I found a better solution. as long as none of the source files in “src” are required, they are ignored by shadow compile. in this way I can use deps :true and include both source paths without cljs complaining#2022-03-0405:22thhellerwell, yes shadow only ever compiles files that are actually :require'd somewhere#2022-03-0314:25mkvlrif an expected change has an effect on one machine but not on another, what are places we can clear fix it? We’ve cleared .shadow-cljs & node_modules/ anything else? (Also tried other places like ~/.cljs which I’m pretty sure shadow doesn’t use)#2022-03-0315:03mkvlrlooks like a clojure upgrade fixed it#2022-03-0320:41DerekLooks like the npm package for shadow-cljs is a patch version behind (2.17.6 in Clojars, 2.17.5 on npm)#2022-03-0405:21thheller@dpassen1 oops, forgot to publish. fixed.#2022-03-0413:30emilaasaThis is a sort-of newbie question, forgive me if it's obvious. I have an existing javascript project using webpack, and I've managed to add some cljs code to the project using a simple config like this from the README:
{:source-paths ["src/cljs"]
 :builds {:code
          {:target :npm-module
           :output-dir "node_modules/shadow-cljs"
           :entries [foo]}}}
Seems to work great, I can use it from the js code and it works. Yay!! I'd now like to make it run seamlessly for everyone using the project (they only use JS). For me, seamlessly would imply no one else has to run anything else than npm ci , npm test and npm start The two options I'm looking at are: • a separate project that would produce a separate npm module and importing that • hacking it into some sort of public/js build folder and checking in the compiled js files Is there a recommended way to do this?
#2022-03-0413:34thhellera npm module seems best? assuming the JS people are always going to run webpack anyways?#2022-03-0413:38thhelleralso depends if you are accessing some of the JS code from CLJS#2022-03-0413:41emilaasaYeah I'm leaning towards that. A main purpose of having cljs at all is to share some functions between the frontend and backend (and getting to implement them in Clojure!). I wonder if I could somehow add this to our build from the backend modules and just output an npm module? :thinking_face:#2022-03-0413:43thhellerI assume you are now using require("shadow-cljs/some.ns") from the JS#2022-03-0413:44emilaasaYeah#2022-03-0413:44thhelleryou can just output to node_modules/whatever instead of use whatever/some.ns#2022-03-0413:44thhelleror you can output to a different dir and use webpack config resolve alias#2022-03-0413:44thhellerhard to say without knowing your JS setup#2022-03-0413:49emilaasaYep! It's semantically a structure like:
monorepo/
  backend1/
  backend2/
  common-stuff/
  ui/
ui is a webpack project, and common-stuff is a clojure project used by both backends. The idea would be to have parts of that be also accessible to the ui project.
#2022-03-0413:49emilaasaSome people mostly work within the ui project and those are the users I'd like to spare knowing about clj at all.#2022-03-0417:07emilaasaSeems like it wasn't that hard to publish an internal npm package to github and making it available thru that either.#2022-03-0518:07lilactownhow would I customize the way that :browser-repl resolves an npm dep?#2022-03-0518:08lilactownrelated, I don't know if this is something that shadow-cljs can fix but when trying to use https://github.com/solidjs/solid in a browser context it loads the server bundle. I think it's due to some "clever" routing they're doing in their package.json#2022-03-0518:18lilactownhttps://github.com/solidjs/solid/blob/5635480c4ebd804122cf5bc8f8a013a8a4806a41/packages/solid/web/package.json#L3-L8#2022-03-0518:22lilactowne.g. when I require
(ns town.lilac.solid.web
  (:require
   ["solid-js/web/dist/web.cjs" :as web]
   ["solid-js/h" :as h]))
this will pull in both web/dist/web.cjs from the explicit require, and web/dist/server.cjs as a transitive dependency of solid-js/h
#2022-03-0518:23lilactownwhich ends up breaking stuff#2022-03-0518:38thhellerhmm it should be picking that on its own#2022-03-0518:38thhellerwhich shadow-cljs version do you use?#2022-03-0518:46lilactownlatest#2022-03-0518:47lilactown^2.17.6#2022-03-0518:47lilactownI can create an repo in a bit#2022-03-0519:50lilactownhttps://github.com/lilactown/solid#2022-03-0519:50thhelleryeah I think I know what happens#2022-03-0519:51thhellerfor now you can just override via resolve#2022-03-0519:51thhellerhmm no actually not#2022-03-0519:51thhellersame problem.#2022-03-0519:52thhellerit is picking the solid-js/package.json instead of the solid-js/web/package.json I believe#2022-03-0519:52thhellercan't check right now. too tired#2022-03-0519:53lilactownno worries, I'm just messing around. thanks for looking into it for a bit#2022-03-0520:04lilactown
:js-options {:resolve
                        {"solid-js/web"
                         {:target :npm
                          :require "solid-js/web/dist/web.cjs"}}}
☝️:skin-tone-2: using that in my :app build config fixed it. might help for anyone else who runs across this and for figuring it out later
#2022-03-0607:30thheller@lilactown should be fine in 1.17.7, it did in fact use the incorrect package.json for "browser" overrides#2022-03-0616:41lilactownthanks @U05224H0W. appreciate it#2022-03-0614:50jaimeHi, I've seen some cljs ns with {:skip-goog-provide true} https://github.com/thheller/shadow-cljsjs/blob/master/src/main/firebase/app.cljs. Is it specific to shadow-cljs only?
(ns 
  {:skip-goog-provide true}
  (:require ["@firebase/app" :refer (firebase)]))
#2022-03-0614:52thhelleryes#2022-03-0614:56jaimeThanks. Looks like the goog.provide overwrites the firebase object here causing undefined initializeApp
// Input 293
var firebase = {app:{}}; <------------------------------------------------------------- goog.provide?????
firebase.app.node$module$_CIRCA_firebase$app = __webpack_require__(5752);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d firebase \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d (.-initializeApp firebase) \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app.initializeApp);
console.log("\x3d\x3d\x3d JAIME \x3d\x3d\x3d firebase.initializeApp \x3d\x3d\x3d ", firebase.app.node$module$_CIRCA_firebase$app.initializeApp);
goog.exportSymbol("firebase", firebase.app.node$module$_CIRCA_firebase$app);
// Input 294
com.degel = {};
com.degel.re_frame_firebase = {};
com.degel.re_frame_firebase.core = {};
if ("undefined" === typeof com || "undefined" === typeof com.degel || "undefined" === typeof com.degel.re_frame_firebase || "undefined" === typeof com.degel.re_frame_firebase.core || "undefined" === typeof com.degel.re_frame_firebase.core.firebase_state) {
  com.degel.re_frame_firebase.core.firebase_state = cljs.core.atom.call(null, cljs.core.PersistentArrayMap.EMPTY);
}
com.degel.re_frame_firebase.core.set_firebase_state = function($var_args$$) {
  for (var $args__4824__auto__$jscomp$316_argseq__4825__auto__$$ = [], $len__4818__auto___51875$$ = arguments.length, $i__4819__auto___51876$$ = 0;;) {
    if ($i__4819__auto___51876$$ < $len__4818__auto___51875$$) {
      $args__4824__auto__$jscomp$316_argseq__4825__auto__$$.push(arguments[$i__4819__auto___51876$$]), $i__4819__auto___51876$$ += 1;
    } else {
      break;
    }
  }
  $args__4824__auto__$jscomp$316_argseq__4825__auto__$$ = 0 < $args__4824__auto__$jscomp$316_argseq__4825__auto__$$.length ? new cljs.core.IndexedSeq($args__4824__auto__$jscomp$316_argseq__4825__auto__$$.slice(0), 0, null) : null;
  return com.degel.re_frame_firebase.core.set_firebase_state.cljs$core$IFn$_invoke$arity$variadic($args__4824__auto__$jscomp$316_argseq__4825__auto__$$);
};
com.degel.re_frame_firebase.core.set_firebase_state.cljs$core$IFn$_invoke$arity$variadic = function($JSCompiler_temp_const$jscomp$9$$) {
  $JSCompiler_temp_const$jscomp$9$$ = cljs.core.__destructure_map.call(null, $JSCompiler_temp_const$jscomp$9$$);
  var $JSCompiler_temp_const$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "get-user-sub", "get-user-sub", 1337447940)), $JSCompiler_temp_const$jscomp$0$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "set-user-event", "set-user-event", -2139443858)), $JSCompiler_inline_result$$ = cljs.core.get.call(null, $JSCompiler_temp_const$jscomp$9$$, new cljs.core.Keyword(null, "default-error-handler", "default-error-handler", 
  2070828115));
  $JSCompiler_temp_const$jscomp$9$$ = cljs.core.swap_BANG_;
  var $JSCompiler_temp_const$jscomp$1$$ = $JSCompiler_temp_const$jscomp$9$$.call, $JSCompiler_temp_const$jscomp$2$$ = com.degel.re_frame_firebase.core.firebase_state, $JSCompiler_temp_const$jscomp$3$$ = cljs.core.assoc, $JSCompiler_temp_const$jscomp$4$$ = new cljs.core.Keyword(null, "set-user-fn", "set-user-fn", -1107518278);
  $JSCompiler_temp_const$jscomp$0$$ = iron.re_utils.event__GT_fn.call(null, $JSCompiler_temp_const$jscomp$0$$);
  var $JSCompiler_temp_const$jscomp$5$$ = new cljs.core.Keyword(null, "get-user-fn", "get-user-fn", -1714413522);
  $JSCompiler_temp_const$$ = iron.re_utils.sub__GT_fn.call(null, $JSCompiler_temp_const$$);
  var $JSCompiler_temp_const$jscomp$6$$ = new cljs.core.Keyword(null, "default-error-handler", "default-error-handler", 2070828115), $JSCompiler_temp_const$jscomp$7$$ = iron.re_utils.event__GT_fn, $JSCompiler_temp_const$jscomp$8$$ = $JSCompiler_temp_const$jscomp$7$$.call;
  $JSCompiler_inline_result$$ = cljs.core.truth_($JSCompiler_inline_result$$) ? $JSCompiler_inline_result$$ : alert;
  return $JSCompiler_temp_const$jscomp$1$$.call($JSCompiler_temp_const$jscomp$9$$, null, $JSCompiler_temp_const$jscomp$2$$, $JSCompiler_temp_const$jscomp$3$$, $JSCompiler_temp_const$jscomp$4$$, $JSCompiler_temp_const$jscomp$0$$, $JSCompiler_temp_const$jscomp$5$$, $JSCompiler_temp_const$$, $JSCompiler_temp_const$jscomp$6$$, $JSCompiler_temp_const$jscomp$8$$.call($JSCompiler_temp_const$jscomp$7$$, null, $JSCompiler_inline_result$$));
};
com.degel.re_frame_firebase.core.set_firebase_state.cljs$lang$maxFixedArity = 0;
com.degel.re_frame_firebase.core.set_firebase_state.cljs$lang$applyTo = function($seq51872$$) {
  return this.cljs$core$IFn$_invoke$arity$variadic(cljs.core.seq.call(null, $seq51872$$));
};
com.degel.re_frame_firebase.core.initialize_app = function($firebase_app_info$$) {
  return firebase.initializeApp(cljs.core.clj__GT_js.call(null, $firebase_app_info$$)); <--------------------------- initializeApp is not a function
};
#2022-03-0614:58thhelleryes, that is what that meant to fix#2022-03-0614:59jaimeThanks for confirming. I think I'll just have to write script to delete that line for now 😅#2022-03-0615:01thhellerhmm? does it not work anymore?#2022-03-0615:01thhelleroh I guess you are not using shadow-cljs?#2022-03-0618:58jaimeYes. Right now, just trying to make it work with figwheel-main.#2022-03-0619:10thhellerthen you probably should not be using shadow-cljsjs. instead just exclude the cljsjs/firebase and provide your own proper :foreign-libs definition. figwheel supports those, so in theory you don't need the shadow-cljsjs hack#2022-03-0619:20jaimeOh, should it look like this?
:foreign-libs
 [{:file "node_modules/@firebase/app/dist/index.cjs.js"
   :provides ["@firebase/app"]
   :module-type :commonjs}]
Think I need to do this for other @firebase/* (database, firestore). Can I assume CLJS compiler can infer the externs?
#2022-03-0706:08thhellersorry, don't know how you do this exactly. should be something using :target :bundle but how you mock away cljsjs deps I don't know#2022-03-0706:41thhellerif you are actually using (:require ["@firebase/app"]) directly in your code and not the cljsjs/firebase namespaces then you don't need any of this :foreign-libs stuff#2022-03-0708:17jaimeSorry, I did not provide more context. You're right I'm using :target :bundle and using (:require ["@firebase/app" :as firebase]) seems to work, instead of using js/firebase. Foreign-libs is not need. Thanks#2022-03-0708:10StefanGood morning all! This morning I updated shadow-cljs to 2.17.7 and then I got this build error:
$ npx shadow-cljs -A:app release :app
[:app] Compiling ...
relative require ./getComputedStyle from /Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js outside package /Users/redacted/my-project/node_modules/dom-helpers/css
{:package-dir #object[java.io.File 0x7ce3710f "/Users/redacted/my-project/node_modules/dom-helpers/css"], :file #object[java.io.File 0x20ce9d1c "/Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js"], :require "./getComputedStyle"}
ExceptionInfo: relative require ./getComputedStyle from /Users/redacted/my-project/node_modules/dom-helpers/cjs/css.js outside package /Users/redacted/my-project/node_modules/dom-helpers/css
	shadow.build.npm/resolve-rel-require (npm.clj:579)
	shadow.build.npm/resolve-rel-require (npm.clj:570)
	shadow.build.npm/find-resource (npm.clj:783)
	shadow.build.npm/find-resource (npm.clj:751)
	shadow.build.resolve/find-npm-resource (resolve.clj:122)
	shadow.build.resolve/find-npm-resource (resolve.clj:93)
	shadow.build.resolve/eval13299/fn--13302 (resolve.clj:262)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:80)
	shadow.build.resolve/find-resource-for-string (resolve.clj:69)
	shadow.build.resolve/resolve-string-require (resolve.clj:453)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:673)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-deps/fn--13248 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6829)
	clojure.core/reduce (core.clj:6812)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
Does this ring any bells? I downgraded shadow-cljs for now and that’s working, so it’s not urgent :)
#2022-03-0708:28thhellerlooks like a regression of some kind. I'll check#2022-03-0709:09thhellershould be fixed in 2.17.8#2022-03-0709:11StefanYes it is 🎉#2022-03-0709:11StefanThank you!!#2022-03-0715:11mhuebertquestion about overriding the devtools host - we are using a custom domain instead of localhost, but if we use :devtools-url we have to hard-code the port which breaks when the default port (9630) is unavailable. The workaround I found is to add
;; toplevel
:devtools {:use-document-host false}
;; in the build
:closure-defines {shadow.cljs.devtools.client.env.server_host ""}
…which works, but feels like a hack b/c if I put the closure-define as a normal var rather than “munged” (`shadow.cljs.devtools.client.env/server-host`) then it gets overridden somewhere.
#2022-03-0717:40thheller@mhuebert I assume the host isn't the host serving the initial page? there currently is no option to just override the host. although you can configure :http {:host "whatever"} and that will be used#2022-03-0819:18avi👋 Hi there, I’m an experienced Clojure dev and I’m working on my first CLJS project, which is sort-of a CLI tool that runs on/in Node. Sorry if this is a FAQ or a silly question, but is there a way to use shadow to run a CLJS project with node, recompiling if necessary, as opposed to just (re)compiling the project? My goal is to ensure that people can check out the repo hosting this tool and run it immediately in a single step, and also that if they make changes to the code and then run the tool again, the changes will be picked up. If the answer is just, write a script that first (re)compiles the program and then runs the program, that’s fine. I’m only asking because I’m used to the model provided by Clojure CLI tools (i.e. the clojure script) wherein I can use it to run my project, compiling it on the fly every time I run it; and I find that convenient. Thanks!#2022-03-0902:46lilactownoutside of shadow-cljs, you can use a self hosted version of cljs like lumo, although I fear it has fallen into an unmaintained state#2022-03-0902:47lilactownyou could check out #nbb, which isn't quite CLJS but might do what you want#2022-03-0902:47lilactownboth of these would allow someone to clone your repo and run the script in a single command#2022-03-0902:48lilactownsince they will at runtime interpret the code, rather than compiling it to JS#2022-03-0902:49lilactownif you'd rather stick with compiled CLJS, then having a build script that compiles and runs it#2022-03-0905:19thhellerI strongly recommend using a compiled script distributed to npm. instead of compiling from source on the end users machine.#2022-03-0905:20thhellerotherwise you have to pay the startup cost of the JVM every time which will make the CLI tool unusably slow (if you care about startup time)#2022-03-0905:21thhellerchecking out the source and compiling it can still be done, just shouldn't be the default#2022-03-0916:07aviThank you so much!#2022-03-0916:08aviI’m leaning towards a script that looks sort of like shadow-cljs start && shadow-cljs compile <build> && node path/to/compiled/script.js#2022-03-0916:08avithat way if it’s run multiple times it’ll be fast because the server is running in the background#2022-03-0916:09aviI’ve been using a script that does something similar during development and it’s been working well for me#2022-03-0916:09aviI was just wondering if shadow had some built-in command for this.#2022-03-0916:09aviSounds like it doesn’t, which is totally fine.#2022-03-0916:09aviJust curious though… should it, maybe? Or would that be scope creep?#2022-03-0916:10aviAh also WRT this: > …using a compiled script distributed to npm. I don’t think I can do this in this case because this is a private, proprietary, internal tool.#2022-03-0918:54thhellerdoesn't need to be the public npm registry then. could be a github repo und zip file#2022-03-1000:01aviAh right, sure. I’ll consider that. Thank you!#2022-03-1000:01avi(In this particular case, this tool will probably be used only infrequently, and all its users are developers, so it might be OK if they have to run it using a script in a clone of the repo.)#2022-03-0903:49Christopher GenoveseI have a clojurescript library using shadow-cljs with the :node-library target that I would like to use both within node/commonJS and from ES6/import style js code (e.g., react). I'm producing a release js file with shadow-cljs using :advanced optimizations. While I'm clear on how to load js code of different types into clojurescript, I'm less clear from the users guide what if anything is required to go the other way. Is it usable as is with both commonJS and ES6 imports? Or is a further transpiling step needed? And if so, what is the best practice for doing that transformation? Thanks#2022-03-0905:23thheller@genovese that entirely depends on what the JS side is using to build. both commonjs and es6 are fine usually with webpack and don't make much of a difference either way. note though that :node-library is meant to run in node as the name implies. so if this is a library intended to run in the browser :target :esm might be better#2022-03-0905:56Christopher GenoveseI'd like to use it in a create-react-app app, which uses webpack, and I'm also using the library in a node application, and in that situation with straight js code, webpack seems to allow both uses without much trouble. It makes sense to use two different builds for these purposes. I've had some trouble with the esm build for this, but I'll give it another go before troubling you further. Thanks for your help.#2022-03-0906:10thheller:npm-module is another option#2022-03-0906:11thheller:node-library is fine too as long as you don't use node specific things too much#2022-03-0906:11thheller:esm is probably the trickiest of the bunch, so maybe avoid that one#2022-03-0906:11Christopher GenoveseI use no node-specific things at all. I do use a few of the es2018 regexp features.#2022-03-0906:11Christopher GenoveseYes, esm hangs for me when I try to import it in react.#2022-03-0906:12Christopher GenoveseI set :output-feature-set to :es2018 which might be an issue?#2022-03-0906:14thhellerhangs?#2022-03-0906:14Christopher GenoveseYes, just hangs on Starting development server... seemingly forever#2022-03-0906:14thhellerfor target esm you need to set :js-options {:js-provider :import}
#2022-03-0906:14thhellerotherwise it'll bundle react and webpack will again#2022-03-0906:15thhellerwhat is Starting development server? thats not a shadow-cljs message#2022-03-0906:15Christopher GenoveseAh, thanks, I missed that. The library does not use react.#2022-03-0906:15Christopher GenoveseI know. That's when I import it in to CRA#2022-03-0906:15Christopher GenoveseThe library is purely computationoal.#2022-03-0906:15Christopher GenoveseI just want to use it in teh react app#2022-03-0906:16Christopher Genovese(I'm doing the CRA in development mode at the moment which is why that message.)#2022-03-0906:16Christopher GenoveseThe library works fine in node.#2022-03-0906:18thhellerhmm yeah dunno why that would hang#2022-03-0906:18thhellermight just be taking a long time. it is a known issue that webpack can take its time processing cljs output + source maps#2022-03-0906:19thhelleralthough it should eventually finish#2022-03-0906:24Christopher GenoveseOK, I'll wait longer then. The only message I get is (node:33893) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. when I do npm start in the CRA directory. If this doesn't work, do you have any other suggestions? Thanks again!#2022-03-0906:25thhellerif :esm doesn't work then don't use :esm 😉#2022-03-0906:28thheller:npm-module was meant for node/webpack integration, so depending on what you need that may fit best#2022-03-0906:28Christopher Genovese🙂 I suppose I can use :umd and attach it to the window object, but that's less than ideal. :node-library with conversion is not working. I can try :node-module I suppose. If :esm doesn't work...my list of options grows thin. I had guessed that others have used cljs libraries in a js/react codebase...right?#2022-03-0906:29Christopher GenoveseOK. The docs seem to warn away from that so I discounted it a bit. For instance, I really want to get advanced optimization... But I'll try#2022-03-0906:29thhelleradvanced works fine, just need to remember to ^:export what the JS stuff wants to access#2022-03-0906:29Christopher GenoveseOk, that's good#2022-03-0906:30thhellerin :node-library this is done via build config. in :npm-module that is done via metadata in the namespaces#2022-03-0906:31Christopher GenoveseRight, with :export metadata. That should be fine.#2022-03-0906:44Christopher GenoveseWith :npm-module, does the :entries config require all namespaces to be compiled or only the top-level (export-containing) namespaces?#2022-03-0906:46thhellershould contain all namespaces that you want the JS code to be able to access *directly*#2022-03-0906:46thhellerso if thats just one then just that one. eg. the export containing one#2022-03-0906:55Christopher GenoveseGreat, that's what I tried. Thanks. Just to make sure I'm clear: I put the files from the :npm-module build into a`local` directory within the react app project and did import { foo } from './local/main.namespace.js'; where foo is the name of one of several exported symbols. Does that seem right? Webpack is taking a go at it. It's been about 10 minutes so far and it's still working.#2022-03-0906:55thhellerhmm yeah thats right but it should definitely not take that long#2022-03-0906:56thhellerstick a .babelrc into the local dir#2022-03-0906:56thhellerwith just
{
    "ignore": ["*.js"]
}
#2022-03-0906:56Christopher GenoveseI was afraid of that. Ok, great idea!#2022-03-0907:01Christopher GenoveseSadly, it seems to be doing the same thing. I'll give it a while longer but I am at a loss. I think I will try making a trivial shadow-cljs project and see that I can get that to import; maybe that will reveal something?? I'd welcome any ideas you have. And in any case, as always, I really appreciate your help and time on this!#2022-03-0907:02thhellerI don't know about the current state of CRA. there might be other ways to tell it to ignore processing certain files#2022-03-0907:02thhellerit used to work via .babelrc but that may have changed#2022-03-0907:03Christopher GenoveseGood point. I'll check into that.#2022-03-0914:32Christopher Genovese@thheller OK, I think I got it working by doing the :esm target for the library, creating a "fake" npm project with the shadow-cljs output file as the index.js, and pointing the "browser" tag in package.json to that file. I then did a local install of the fake npm project. And apparent success.... phew. (I was pretty worried there.) I'm assuming that would then work if packaged to npm as well. Would it mess up shadow-cljs at all if I put an analogous package.json entry (i.e., using the "browser" tag) in my shadow-cljs project? That would make it pretty straightforward to use this way. Thanks again#2022-03-0916:09hoppyNoticing some sort of friction between cider and shadow-cljs using a node repl. I noticed this issue start a couple of weeks back, but was busy and had to keep moving (aka switched back to calva for a while). Shadow nodejs project. It can be pulled from: /cdn-cgi/l/email-protection:/Gnurdle/aoc2019.git using 2.17.5 of shadow cider version is 1.3.0-snapshot (few days old now?) spacemacs - develop pulled last night, nothing bizzare in config so, pretty current/mainline stuff. This is from a jack-in-cljs, selecting node repl: [nREPL] Starting server via /home/chopper/.nvm/versions/node/v14.17.6/bin/npx shadow-cljs -d nrepl/nrepl:0.9.0 -d cider/cider-nrepl:0.28.3 -d cider/piggieback:0.5.2 server [nREPL] server started on 40693 Get this traceback: 1. Unhandled java.lang.AssertionError Assert failed: (keyword? repl-env) nrepl.clj: 30 shadow.cljs.devtools.server.nrepl/shadow-cljs-repl nrepl.clj: 30 shadow.cljs.devtools.server.nrepl/shadow-cljs-repl RestFn.java: 410 clojure.lang.RestFn/invoke REPL: 1 shadow.user/eval28143 REPL: 1 shadow.user/eval28143 Compiler.java: 7181 clojure.lang.Compiler/eval Compiler.java: 7171 clojure.lang.Compiler/eval Compiler.java: 7136 clojure.lang.Compiler/eval core.clj: 3202 clojure.core/eval core.clj: 3198 clojure.core/eval interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn AFn.java: 152 clojure.lang.AFn/applyToHelper AFn.java: 144 clojure.lang.AFn/applyTo core.clj: 667 clojure.core/apply core.clj: 1977 clojure.core/with-bindings* core.clj: 1977 clojure.core/with-bindings* RestFn.java: 425 clojure.lang.RestFn/invoke interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn main.clj: 437 clojure.main/repl/read-eval-print/fn main.clj: 437 clojure.main/repl/read-eval-print main.clj: 458 clojure.main/repl/fn main.clj: 458 clojure.main/repl main.clj: 368 clojure.main/repl RestFn.java: 1523 clojure.lang.RestFn/invoke interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn AFn.java: 22 clojure.lang.AFn/run session.clj: 218 nrepl.middleware.session/session-exec/main-loop/fn session.clj: 217 nrepl.middleware.session/session-exec/main-loop AFn.java: 22 clojure.lang.AFn/run Thread.java: 829 java.lang.Thread/run ===== repl seems to be connected, but can't do much. This project works flawlessly with calva, so maybe not a shadow issue. Happy to help debugging, if I knew what to do first...#2022-03-0917:59Christopher GenoveseDid cider display the ClojureScript REPL init form? And if so, what was it?#2022-03-0918:00hoppywhere would I find that?#2022-03-0918:51Christopher GenoveseIf it got you to the repl, it usually prints it as part of the introductory banner text, labeld as ClojureScript REPL init (at least in 1.2)#2022-03-0918:58thhellerthat error happens when you try to initialize the CLJS REPL incorrectly. I don't know what it is sending but maybe this helps https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2022-03-0918:58thhellerno clue if that is still accurate. don't use emacs myself#2022-03-0919:12Christopher GenoveseThe problem appears to be happening in the pre-condition assertion of shadow-cljs-repl and this gets its value directly from cider's init form. Cider gets a list of builds, converts to keywords, and passes that directly to shadow/nrep-select. I'm thinking that maybe in 1.3 (or for some other reason like local context), the build is not getting set properly when the init form in CIDER is created. Just a hypothesis, but there's not much other action between that and the assertion failure.#2022-03-0919:13thhellerI suspect its just trying to use the default regular cljs repl init form. which doesn't work with shadow-cljs. a keyword is expected but its not given.#2022-03-0919:35Christopher GenoveseAgreed that the regular default makes sense. But CIDER normalizes that build string to turn it into a keyword if it's not already, so that should be ok. Whether the new version changes something (intentionally or not) remains to be seen#2022-03-0919:36thhellerI doubt very much that its just a build string conversion issue#2022-03-0919:37thhellerit likely sends something like (cljs.repl.node/repl-env) or whatever the exact form is to init a default CLJS repl#2022-03-0919:37thhellerbut regardless. it is a config setting you must change. if you do not the default will not work.#2022-03-0919:38Christopher GenoveseI asked him to see the build string to check what it passes. I'm running CIDER 1.2 and am using that to compare with what he is seeing and#2022-03-0919:40thhellerI guess that error message could be improved though https://github.com/thheller/shadow-cljs/issues/997#2022-03-0919:41Christopher Genoveseit looks like that repl-env does not change from the init form issued by cider to when it hits shadow-cljs-repl. I could be mistaken and I juust took a quick look in response to @U19EVCEBV's query, but that's how it appears. I think this is more likely a CIDER issue. Maybe config if the cider build variable is set strangely...#2022-03-0920:53hoppy(--> id "1" op "clone" time-stamp "2022-03-09 14:22:43.411305273" ) (<-- id "1" session "f0e132e6-371a-4e83-b3c6-4ab586343a01" time-stamp "2022-03-09 14:22:43.419432571" new-session "9d6616e6-135f-4081-8795-ec3021192007" status ("done") ) (--> id "2" op "clone" time-stamp "2022-03-09 14:22:43.443379704" ) (<-- id "2" session "70ab6175-207a-4c2b-b6ca-06eee7a483e1" time-stamp "2022-03-09 14:22:43.445479986" new-session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" status ("done") ) (--> id "3" op "describe" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.463869510" ) (<-- id "3" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.495298617" aux (dict ...) ops (dict ...) status ("done") versions (dict ...) ) (--> id "4" op "eval" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.518527675" code "(clojure.core/apply clojure.core/require clojure.main/repl-requires)" column 1 file "cider-repl cms-aero/cms-wave:localhost:36541(pending-cljs)" inhibit-cider-middleware "true" line 47 nrepl.middleware.print/buffer-size 4096 nrepl.middleware.print/options (dict ...) nrepl.middleware.print/print "cider.nrepl.pprint/pprint" nrepl.middleware.print/quota 1048576 nrepl.middleware.print/stream? "1" ) (<-- id "4" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.544699094" value "nil" ) (<-- id "4" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.545315091" ns "shadow.user" ) (<-- id "4" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.545483854" status ("done") ) (--> id "5" op "out-subscribe" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.545928236" ) (--> id "6" op "init-debugger" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.546291705" nrepl.middleware.print/buffer-size 4096 nrepl.middleware.print/options (dict ...) nrepl.middleware.print/print "cider.nrepl.pprint/pprint" nrepl.middleware.print/quota 1048576 nrepl.middleware.print/stream? "1" ) (--> id "7" op "eval" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:43.546956467" code "(require 'cljs.core)" ) (<-- id "5" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:43.608404490" out-subscribe "9d6616e6-135f-4081-8795-ec3021192007" status ("done") ) (<-- id "7" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.789805407" ns "shadow.user" value "nil" ) (<-- id "7" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.790105861" status ("done") ) (--> id "8" op "eval" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.805745358" code "(require 'cider.piggieback)" ) (<-- id "7" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.826579764" changed-namespaces (dict ...) repl-type "clj" status ("state") ) (<-- id "8" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.826837261" ns "shadow.user" value "nil" ) (<-- id "8" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.826950218" status ("done") ) (<-- id "8" session "b6c2b018-8bbb-467f-82e3-d2b0499ca16e" time-stamp "2022-03-09 14:22:44.827251572" changed-namespaces (dict) repl-type "clj" status ("state") ) (--> id "9" op "eval" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:44.837460053" code "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))" ns "shadow.user" ) (<-- id "9" session "9d6616e6-135f-4081-8795-ec3021192007" time-stamp "2022-03-09 14:22:44.877871371" err "Execution error (AssertionError) at shadow.cljs.devtools.server.nrepl/shadow-cljs-repl (nrepl.clj:30). Assert failed: (keyword? repl-env) "#2022-03-0920:53hoppythe nrepl log from cider (sorry slack wouldn't take a snippet in a thread for some reason)#2022-03-0920:56hoppynot sure if it helps, but here is the nrepl log from cider#2022-03-0920:57hoppydunno if it helps, but this is the nrepl log from cider#2022-03-0921:04Christopher GenoveseHmm... Does the repl start and show you the welcome banner or message? If so, I'd like to see the last non-trivial comment line. Do you have any non-default cider config set? I tried to trace backward from the one spot that can be causing the error, and it would be good to know what that repl-env value is. We could see the input in the banner message. Now as @thheller says, it could be something else entirely... If you could try it with cider 1.2.x, it would distinguish some possibilities. I'd also suggest putting this on the cider slack channel as it looks more a CIDER-related issue than a shadow-cljs one. (It's often hard to separate those, though; I've had that experience too.)#2022-03-0922:48hoppyI don't believe it got around to making a repl buffer to display anything in#2022-03-0922:52hoppywill bring this up in cider though, since calva is working in this situation#2022-03-1001:21hoppythey busted me being tricked by a bitey-dog. I was selecting 'node-repl' but what I needed to be doing was first selecting shadow and then node-repl. The ergonomics of this a bit distressing IMHO & 2c worth.#2022-03-1004:03Christopher GenoveseAh, that can happen. Glad you figured it out. In case you weren't aware of it, you can set dir-local vars in a project so you don't have to answer that every time. Good luck!#2022-03-1005:55thheller> code "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))"#2022-03-1005:56thhellerthat is the part that is incorrect. as I said this is trying to initialize a regular node cljs REPL, which is not what shadow-cljs expects#2022-03-1005:57thhellerit should be something like (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/repl :your-build-id))#2022-03-0922:52hoppywill bring this up in cider though, since calva is working in this situation#2022-03-1012:35Pepijn de VosIf I add https://www.npmjs.com/package/bootstrap-icons as a dependency, how can I actually reference the svg files?#2022-03-1012:38thhellerit is not javascript. so not with shadow-cljs.#2022-03-1012:39Pepijn de VosOk, I'll just copy the SVGs, yolo#2022-03-1013:12rkiouakI am trying to build a cljs project into an npm module for import into a js project, I understand that using the :node-library may lead more fine grained control, but I haven't been able to get past the roadblock of the output of shadow for this project including e.g. var js = FS.readFileSync(filePath);. Am I missing some obvious control on how I would tell the compile job to output a node-library suitable for a browser env?#2022-03-1013:14thhelleras the name should imply :node-library is intended to run in node#2022-03-1013:15thhelleruse :target :npm-module if you want to include in a webpack build or something like that#2022-03-1013:15rkiouakam I misinterpreting this guidance: > If you plan to distribute code on NPM, then you may want to use the :node-libraryhttps://shadow-cljs.github.io/docs/UsersGuide.html#NodeLibrary instead since it allows for a finer level of control over exports and optimization. ?#2022-03-1013:17thhellerwell, technically speaking :node-library works too. just assumes the presence of node for compile and watch builds. release build will also work in the browser#2022-03-1013:17thhellerbut :target :npm-module with :runtime :browser will work more reliable and also with compile/watch#2022-03-1013:18thhellerregardless of target. only release builds should actually be published#2022-03-1015:23rkiouakthanks @thheller. Is it possible to do a release build of either node-library or npm-module without minified function fields? I'm not publishing to npm now, i'm taking a very legacy cljs app and working on getting it behaving correctly in a js project, and as it is not yet behaving well, the console errors are difficult to debug with the minifed output.#2022-03-1015:31thhelleryou can use shadow-cljs release the-build --pseudo-names to make it easier#2022-03-1015:32thhelleryou can set :compiler-options {:optimizations :simple} but that'll make the build much much larger#2022-03-1015:32rkiouakyeah, unfortunately the webpack dev build of the js app was OOMing with non release optimizations#2022-03-1015:32rkiouaktrying --pseudo-neames now#2022-03-1015:37thhellerwhat kind of JS integration are you looking for? CLJS using JS code, JS code using CLJS or both?#2022-03-1015:40rkiouakJs using cljs#2022-03-1015:42thhellerhmm yeah then npm-module is best I'd say#2022-03-1015:42thhelleryou can also go with option #2 here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2022-03-1015:42thhellerjust include the external index in the webpack build (won't slow it down as much)#2022-03-1015:43thhellerand then in the JS access the CLJS code via export'd globals#2022-03-1015:43thhellerso (defn ^:export foo [] ...) is that.ns.foo() in JS#2022-03-1015:44thhellerthat way webpack doesn't touch the CLJS code at all though which might be good#2022-03-1017:28Sam Ritchiedoes anyone have any clue why this is occurring for me, with a threejs load?#2022-03-1017:29Sam RitchieI am working on a better repro… basically I have some code that absolutely works with shadow-cljs: https://github.com/sicmutils/mathbox-clj/blob/main/src/main/mathbox_clj/demo.cljs But then I try and use the code from a different project with more npm deps and I get this error. Those files definitely exist Vector3, Matrix4 , but something is weird about the way they’re written. what is causing the module$node_modules etc output?#2022-03-1017:31Sam Ritchie#2022-03-1017:31Sam Ritchiein fact it seems like shadow loads it fine… there is just this error below#2022-03-1017:31Sam Ritchieexpanded#2022-03-1017:31Sam Ritchie#2022-03-1017:33Sam Ritchiemight have solved it from a SLACK search… gotta get used to that still…#2022-03-1018:11Sam Ritchiemismatched shadow version caused it all 🙂#2022-03-1219:12p-himikJust updated shadow-cljs to the latest and started getting this warning:
[To redirect Truffle log output to a file use one of the following options:
* '--log.file=<path>' if the option is passed using a guest language launcher.
* '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
* Configure logging using the polyglot embedding API.]
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
The guest application code will therefore be executed in interpreted mode only.
Execution only in interpreted mode will strongly impact the guest application performance.
For more information on using GraalVM see .
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
Adding -Dpolyglot.engine.WarnInterpreterOnly=false does remove it in its entirety. But that's only possible because I use deps.edn. Would people using shadow-cljs.edn for their dependencies also be able to suppress the warning? Maybe this warning something that shadow-cljs can suppress itself?
#2022-03-1219:21thhellerno clue what that warning is. never seen it before.#2022-03-1219:21thhellermaybe you have a different graaljs engine in deps.edn? do you actually use graalvm maybe?#2022-03-1220:39p-himikNope. This is enough to trigger the warning:
{:paths ["src"]
 :deps  {thheller/shadow-cljs       {:mvn/version "2.17.8"}
         superstructor/re-highlight {:mvn/version "1.1.0"}}}
Removing superstructor/re-highlight removes the warning. That dependency doesn't have any CLJS dependencies - only deps.cljs that has this:
{:npm-deps     {"highlight.js"          "11.1.0"}
 :npm-dev-deps {"react"                 "17.0.2"
                "react-dom"             "17.0.2"
                "shadow-cljs"           "2.15.1"
                "karma"                 "6.3.4"
                "karma-chrome-launcher" "3.1.0"
                "karma-cljs-test"       "0.1.0"
                "karma-junit-reporter"  "2.0.1"}}
#2022-03-1220:40thhellerthe warning is triggered by the graaljs engine. which I guess works differently when used on actual graalvm#2022-03-1220:41thhellerthe graaljs engine is used when comparing :npm-deps versions in deps.cljs files#2022-03-1220:41thhellerso I guess the re-highlight has one and removing that will not cause that part of the code to run#2022-03-1220:41thhellerI may just remove that check altogether or make a manual command to run#2022-03-1220:42thhellerits usefulness is rather limited anyways#2022-03-1220:42p-himikIs the version comparison there only to warn people about inconsistent versions?#2022-03-1220:42thhellerits used to warn about conflicts in deps.cljs files#2022-03-1220:43thhellerie. reagent wanting react v16 but something else wanting react v17 or whatever#2022-03-1220:43thhellersetting :npm-deps {:install false} in shadow-cljs.edn should also get rid of the warnings#2022-03-1220:44p-himikBut why is evaluating JS needed for that? Because of JS-based SemVer functionality?#2022-03-1220:44thhelleralso won't isntall any js deps though ;)#2022-03-1220:46thhelleryes#2022-03-1220:47p-himikA-ha, found semver.js. If I, say, rewrote that in CLJ, would you use that instead of evaluating semver.js on GraalJS?#2022-03-1220:47thhellerwould be best to just implement that in clojure but npm versions are a complete mess and I really can't be bothered to figure out how it works 😛#2022-03-1220:47thhelleryes, absolutely. please do 🙂#2022-03-1220:47p-himikHeh, will try.#2022-03-1220:48p-himikOne caveat - it will be harder to update once SemVer inevitably becomes 3.0.0 or even 2.0.1.#2022-03-1220:49thhellerI could just remove it entirely or just bail on conflict#2022-03-1220:50thhellerpretty sure everyone just ignores the warning anyway 😉#2022-03-1220:50p-himikBut you can't figure out whether there truly is a conflict without doing all that crap, can you? You can only check for not=.#2022-03-1220:50p-himikNaah, I check those warnings. :)#2022-03-1220:52thhellerdon't know. there are definitely deps.cljs with version ranges out there#2022-03-1220:53p-himikRight.#2022-03-1222:29p-himikGod damn. That code is a complete mess, its semantics notwithstanding.#2022-03-1222:59p-himikActually, this raises a question - why didn't you use https://github.com/vdurmont/semver4j or https://github.com/zafarkhaja/jsemver?#2022-03-1305:44thhellerhmm guess I didn't know those exist?#2022-03-1305:45thhellerchanging to those immediately 😛#2022-03-1306:02thhellerhmm neither has the necessary function for checking two ranges against each other#2022-03-1308:29p-himikYeah, but that function is just every? within some within every? within some. :)#2022-03-1308:53p-himikOn the other hand, neither of those two libraries seem to be well maintained, and there are some bad looking outstanding issues. But then again, node-semver seems to be in exactly the same boat... As an alternative, seems that you can use npm exec to run packages without having to install them - they will be fetched to an internal npm cache that won't interfere with anything, or at least it seems that way. The current CLI of node-semver doesn't allow for range intersection, but maybe it can be extended. At least this works:
npm exec --package=semver -- semver -r '1.0.0 - 2.1.0' 1.5.0
#2022-03-1308:54thhellerthis really doesn't seem worth the trouble overall#2022-03-1308:54thhellerI'll just remove it and pick the first one that is found#2022-03-1308:54thhellerand just warn about others in case of duplicates#2022-03-1308:55thhellerits not like thats any worse than what you currently get#2022-03-1308:56p-himikOne final alternative - you can use node to evaluate semver.js. If npm is installed, then node is installed, and I think it's possible to get its path reliably.#2022-03-1308:56thhellerforking a node process has other issues though. thats why I didn't do that to begin with#2022-03-1308:57thhelleragain .. this is all not worth it. especially since it cannot be reconciled anyways in case of a real conflict#2022-03-1308:57p-himikAh, huh, alright. Is there a write-up of the issues somewhere, or maybe you could describe them in a sentence?#2022-03-1308:57thhellercan't do anything anyways if something wants react v16 when something else wants react v17 but react v18 is already installed#2022-03-1308:58p-himikYeah, but if there is no conflict but multiple ranges and you get rid of semver.js, you can't do anything but keep on warning, right? Even if the ranges are perfectly fine.#2022-03-1308:58thhellerthere might be multiple :npm-deps declared dependencies that overlap or conflict. can only install one. which one do you pick?#2022-03-1308:58thhellerthats the problem#2022-03-1309:00thhellercould just trim down the version to something sane and compare that#2022-03-1309:00p-himikWhat I mean is that one might require 1.0.0 - 2.0.0 and the other 1.1.0 - 1.9.0 while the installed version is 1.5.0. There's nothing to warn about, it's all consistent. But how can you check for it without semver.js?#2022-03-1309:00thhellerignore versions altogether and just pick the higher one#2022-03-1309:00thheller1.0.0 - 2.0.0 is not version range ever used in npm#2022-03-1309:00thhellerso ^17.0.0 or whatever#2022-03-1309:01thhellerjust take out the ^ and compare against the other#2022-03-1309:01thhellerif higher install that however it was originally#2022-03-1309:01thhellerit never checks against an installed version#2022-03-1309:01thhellerit really is just about the automated npm install for :npm-deps found in deps.cljs files#2022-03-1309:02thhellerif its already installed nothing happens, regardless of version. that check was removed ages ago since it was never correct (ie. broken builds didn't warn, completely fine builds did)#2022-03-1309:03thhellerthe problem wouldn't exist if nobody used version ranges in :npm-deps but some do#2022-03-1309:03thhelleractually some "did". haven't looked in many years what it looks like nowadays#2022-03-1309:03p-himikHow come npm does not use ranges, but :npm-deps allows it?#2022-03-1309:04thhellerwhat do you mean? npm uses ranges by default all over the place?#2022-03-1309:04p-himik> 1.0.0 - 2.0.0 is not version range ever used in npm #2022-03-1309:04thhellerexpressed in that format I mean#2022-03-1309:05thhellerits always some shit like ^2.0.1 or ~2.0.1. I don't even know what these all mean and really don't care enough to figure that out#2022-03-1309:06thhellerbut there are more complex ones out there and those are the real problem#2022-03-1309:07thhellerbest option is probably to make this an interactive command#2022-03-1309:07thhellerie. shadow-cljs install-npm-deps or something#2022-03-1309:08p-himikAh, well - then my point still stands. :) Surely some JS packages use explicit ranges with both bounds. So if I understand you correctly, there are 3 approaches: • Keep parsing and comparing ranges, via semver.js or whatever else • Just install the highest version and hope for the best (but how will you know which one is the highest without parsing the ranges?) • Install something according to one found version range and warn if there are other version ranges that aren't byte-for-byte the same #2022-03-1309:08thhellerthat on conflicts presents all options and asks for answer#2022-03-1309:09thhelleryes, plus what I just said#2022-03-1309:09p-himikIn the case of an interactive command, it would put an extra onus on the user - and probably 90% of all users don't even need to run it, and another 90% won't even know about the command.#2022-03-1309:10thhellerwell it could just warn on startup if things are missing#2022-03-1309:10thheller"react was found as a declared dependency but is not install. please run npx shadow-cljs install-npm-deps." seems fine to me#2022-03-1309:11p-himikAlright. Suppose I run that command and now nothing is missing. But then I add a new package that requires a completely different versions of already installed packages. You won't be able to warn about it, and I won't be able to realize that everything is broken.#2022-03-1309:11thhellerthat is fine. there is no check for this now. installed packages always win.#2022-03-1309:12p-himikOh...#2022-03-1309:12thhellercan't change this behavior either because thats the way you resolve conflicts#2022-03-1309:13thhelleryou install one that should win#2022-03-1309:13thhellercan't just keep installing a newer version that the user may not want#2022-03-1309:14thhellerthere could also be a npx shadow-cljs audit-npm-deps#2022-03-1309:14thhellerthe problem really is just in trying to automate all this stuff too much#2022-03-1309:14thhellerconflict resolution just needs input from the user to be resolved#2022-03-1309:15thhellerthe only feedback I ever got on this feature is "how do I turn off this warning"#2022-03-1309:15p-himik> can't just keep installing a newer version that the user may not want Right, but could keep at least warn the user. It's an interesting difference in approaches, unless my knowledge is incorrect. npm just won't let you install something that doesn't satisfy the ranges unless you --force it. Maven/`deps.edn` will just resolve everything and use whatever's available, without complaining. The user will have to explicitly run a command to check if there are any conflicts.#2022-03-1309:15thhellernpm install will install anything without any checks#2022-03-1309:16thhellerif it runs into a conflict on transitive deps it will install them in nested folders#2022-03-1309:16thhellernot resolving them at all#2022-03-1309:17p-himikEh, feedback is lopsided. Of course nobody will tell you "this warning is helpful, thanks for adding it". > npm install will install anything without any checks Uhm... Just a couple of weeks ago I couldn't install MUIv5 because of a conflict. I think it was requiring React 17 but some other lib really needed 16.#2022-03-1309:17thhellerwell maybe nowadays there are warnings. can't say. I don't use many npm dependencies anymore (really just one)#2022-03-1309:17thhellerhmm yeah dunno. never saw that myself#2022-03-1309:18thhellergotta go. feel free to open an issue about this if you have suggestions or want to implement semver.js 😉#2022-03-1309:20p-himik> I don't use many npm dependencies anymore Heh, kinda ironic. But also enviable in a way. Yeah, will think a bit more about it first.#2022-03-1309:49p-himikOh, there might be a very simple and easy solution. You can concatenate versions with spaces, it won't break anything since there's only one binary operation, ||, and it has the highest precedence - the spaces are implied as &&. So something like >1 <8 >2 >3 || <1 is a valid version string. So: 1. Gather all :npm-deps 2. merge-with them with concatenating the version strings with spaces (replace empty versions with "*") 3. Add to those the contents of package.json, but only for dependencies that were in :npm-deps 4. Run npm install for every accumulated dependency with an explicit version If there are conflicts, npm will loudly fail. If there are no conflicts, the required dependencies will be installed, if they haven't been installed before.#2022-03-1312:58p-himikCreated an issue: https://github.com/thheller/shadow-cljs/issues/998#2022-03-1219:34mkvlrthe warning is there when running on graal. @p-himik can also be set programmatically https://github.com/nextjournal/viewers/blob/main/modules/markdown/src/nextjournal/markdown.clj#L22#2022-03-1219:35mkvlrthough one issue is that older graal versions don't support the flag and will crash even if you bring in the script engine as a dependency and that would support this flag, been meaning to file an issue about this#2022-03-1219:49agoldWhy am I not able to load source map?
DevTools failed to load source map: Could not load content for : HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
#2022-03-1219:55thhellerstatus code 404 suggests that your :asset-path is likely wrong#2022-03-1219:55thhelleroh wait. that is not a file from a shadow-cljs build?#2022-03-1219:56thhellerso I guess the file is just missing?#2022-03-1221:28agoldThe :asset-path is correct. The file is clearly missing, but I have no idea what is attempting to load it. What is supposed to generate that .map file?#2022-03-1221:30thhellerI don't know. might be your html? might be something else you are including? this is not a file from a shadow-cljs build and as such shadow-cljs also wouldn't generate a .map file for it#2022-03-1222:05agoldOK, thanks.#2022-03-1222:48ribelohas anyone encountered a similar warning?
Receiver reference in function ribelo.fatum.Fail changes meaning when namespace is collapsed.
Consider annotating @nocollapse; however, other properties on the receiver may still be collapsed.
#2022-03-1305:43thhellerin what context do you get that? never seen that before#2022-03-1313:33ribelo
(defn Fail
     [msg data]
     (this-as this
       (set! (.-message ^js this) msg)
       this))
#2022-03-1313:34ribeloit is basically a copy of this https://github.com/clojure/clojurescript/blob/r1.11.4/src/main/cljs/cljs/core.cljs#L11479-L11495#2022-03-1316:10thhellerthen you likely just miss the ^{:jsdoc ["@constructor"]}. thats actually important#2022-03-1314:24Quentin Le GuennecOut of curiosity, is there a way with cider+shadow-cljs to live debug a library defined in deps.edn ?#2022-03-1317:42agoldAny idea what could be causing this?
shadow-cljs - remote-error Event {isTrusted: true, type: 'error', target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
eval @ shared.cljs:305
shadow$cljs$devtools$client$shared$remote_error @ shared.cljs:18
eval @ websocket.cljs:29
error (async)
shadow$cljs$devtools$client$websocket$start @ websocket.cljs:26
eval @ shared.cljs:324
shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shared.cljs:509
eval @ browser.cljs:337
goog.globalEval @ app.js:488
env.evalLoad @ app.js:1563
(anonymous) @ app.js:2245
#2022-03-1318:17thhellerlook in the devtools network tab. that usually tells you whats up.#2022-03-1318:48agoldAnother question: I'm getting this in the output from npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :app:
Mar 13, 2022 2:23:42 PM io.undertow.server.handlers.proxy.ProxyHandler$ProxyClientHandler cancel
ERROR: UT005027: Timing out request to /vis-network.min.js.map
What is the undertow server for? How can I stop this error?
#2022-03-1318:55thhellerundertow is the http server#2022-03-1318:55thhellerlooks like you are using a proxy that doesn't reply in time?#2022-03-1411:05murtaza52I have a cljs project (`first project`) with the following shadow-cljs.edn -
{:source-paths
 ["src"]

 :dependencies
 [[re-frame "1.3.0-rc3"]
  [com.degel/iron "0.4.0"]]

 :builds
 {:library
  {:target :node-library
   :output-to "out/re_frame_firebase.js"
   :exports {:initializeApp com.degel.re-frame-firebase.core/initialize-app}}}}
This project is imported as an npm dependency in another project's (`second project`) package.json. On npm install the first project's npm module gets installed successfully. When I run the second project with shadow-cljs watch app this is the error I get -
[:app] Build failure:
The required JS dependency "re-frame-firebase/out" is not available, it was required by "app/fb/init.cljs".
I have checked the the npm_modules of the second project -
$ ls node_modules/re-frame-firebase/out
re_frame_firebase.js
Why cant the second project find the above dependency, what am I doing wrong ?
#2022-03-1413:46wombawomba~How can I call a function in a dynamically loaded module?~ Edit: nevermind; resolve did the trick#2022-03-1413:59thheller@murtaza52 you absolutely should not be including a compiled CLJS build in another CLJS build. just include the sources directly instead#2022-03-1413:59thheller@wombawomba how are you loading the module? avoid resolve if you can, it is not ideal.#2022-03-1414:00thhellerhttps://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2022-03-1414:00wombawomba@thheller I'm using shadow.loader/load#2022-03-1414:03wombawombashadow.lazy looks really useful — thanks!#2022-03-1414:04wombawombayou should include it in the user's guide#2022-03-1414:07thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html is also an option#2022-03-1414:07thhellerlazy-component helper based on shadow.lazy#2022-03-1414:08thheller(if you are using react)#2022-03-1414:09murtaza52@thheller this is a third party library (`re-frame-firebase`), that we are using in a project. We had to fork it make changes to it. (we converted it to a shadow-cljs project) Now I am having trouble using it in my project ? As you suggested include the sources, you mean just copy all the sources in the project, or is there a better way ? (bcoz that will defeat the purpose behind having libraries)#2022-03-1414:10thhelleryou can package it as your own library#2022-03-1414:10thhelleror include it from a local directory#2022-03-1414:10thhelleror use deps.edn and use a git dependency#2022-03-1414:10thhellermany options, dunno what exactly you need but I including a compiled version is definitely the last thing you should be doing#2022-03-1414:12thhellerif the changes you made are only done for your second project it is fine to include the sources directly too. no point in writing libraries with exactly one consumer 😉#2022-03-1414:17murtaza52@thheller thanks that is what we were trying to do - include it from a local directory#2022-03-1414:18murtaza52this is the dep entry in package.json for the second project "re-frame-firebase": "file:../re-frame-firebase",#2022-03-1414:18murtaza52and npm install includes the compiled version along with sources under the node_modules#2022-03-1414:18thhellerno, that is not what you are doing. I mean yes, but you are trying to include the wrong thing#2022-03-1414:19thhellerCLJS libraries are never compiled, they are included from source only#2022-03-1414:19thhellerso you should do the same. include the source#2022-03-1414:20thhelleryou can do so via shadow-cljs.edn by adding :source-paths ["src" "../that-library/src"]#2022-03-1414:20wombawomba@thheller thanks for that blog post. It's pretty much exactly what I was trying to build :)#2022-03-1414:20thhelleror publishing that modified lib to clojars (pretty easy if it is already using leiningen)#2022-03-1414:20thhellerand then just adding it as a regular dependency#2022-03-1414:24murtaza52aah so I should never use it via package.json through npmjs . But why at the end its a regular js file, how does it matter if I distribute it via clojars (jar) or npmjs (node module) ?#2022-03-1414:24thhellerthe compiled version will include its own version of firebase, reframe, cljs.core and whatever else it is using. it will not be compatible with the one you are using in your project.#2022-03-1414:26murtaza52ok thanks. so If I do a lein install on the re-frame-firbase (first project), the jar will just include the sources, and then the shadow-cljs in the second-project will compile it to js ?#2022-03-1414:27thhelleryes#2022-03-1414:27murtaza52great, thanks, let me try it out#2022-03-1417:24djanusheya! is there a way to write a macro that will expand to a (def ^:export ...) ?#2022-03-1417:26djanusI’ve tried this:
(defmacro defoo [name]
  `(def ^:export ~name 42))
but inspecting the output (I’m targeting :npm-module) the resulting def doesn’t appear to be exported:
(defoo bar)
compiles to
myns.bar = (42);
Object.defineProperty(module.exports, "bar", { enumerable: false, get: function() { return myns.bar; } });
#2022-03-1417:28djanuslooking at the shadow-cljs code, it should be enumerable: true if the def is exported#2022-03-1417:36djanusI’ll answer myself – this works:
(defmacro defoo [name]
  `(def ~(with-meta name {:export true}) 42))
#2022-03-1510:51pmooserIs it possible to write a macro that will emit code (or not emit code) based on the value of a goog-define ? I'm trying to figure out whether I can have a debug macro that basically disappears in production builds.#2022-03-1516:50dpsuttondevcards from bruce work in this fashion: • the check: https://github.com/bhauman/devcards/blob/master/src/devcards/util/utils.clj#L4 • usage in a macro: https://github.com/bhauman/devcards/blob/master/src/devcards/core.clj#L127#2022-03-1513:01Louixssover sle#2022-03-1516:40wombawombaI'm trying to use :reader-features to conditionally execute some top-level code (basically #?(:my-feature (reset! my-atom :my-value))) at the start of a namespace in a library I'm including my build (in order to control how a few macros work), but this code doesn't seem to actually get executed at compile time. Is this intended, and if so, is there some other way to get build-specific compile-time configuration into a library?#2022-03-1516:47thheller@pmooser @wombawomba you can write macros that access the cljs.env/*compiler* atom. that has an :options key which is :compiler-options from the build config. so you can set stuff there and do conditional stuff in the macro#2022-03-1516:48thheller@wombawomba yes, as the :reader-features name implies it happens at read time. so emitting them in a macro is not possible#2022-03-1516:48wombawombaGot it, thanks!#2022-03-1516:51wombawombaTo clarify, though, I'm not trying to use reader conditionals to emit anything in a macro — rather I'm trying to conditionally set some state before defining my macros.#2022-03-1516:53wombawomba...the problem with my approach, though, is that the code is getting loaded in clojure, so only :clj reader conditionals end up getting evaluated.#2022-03-1516:58wombawombaActually, I think the easiest way to handle this for me would be to use Java properties (I'm already using these to do something similar when building the same library via GraalVM).#2022-03-1516:59thhellerthat also works but be aware that caching will not recognize these#2022-03-1516:59thhellerso you must disable caching for the namespace using this#2022-03-1516:59wombawombaGood to know.#2022-03-1517:00thheller:compiler-options will invalidate so it sort of works with caching#2022-03-1517:05wombawombaSo I tried this out (I'm using shadow-cljs with leiningen, so I just set :jvm-opts in my project.clj) and it seems to work — just one problem: I only want this behavior sometimes. Is is possible to control whether the property is set or not from the command line?#2022-03-1517:06wombawomba(It seems I can set a leiningen profile in my shadow-cljs.edn, but I can't see how to control which profile gets applied when invoking shadow-cljs)#2022-03-1517:18wombawombaTo answer my own question: I was able to make it work by setting JAVA_OPTS. (It initially seemed like it wasn't being picked up by leiningen, but that was because I'd made a mistake).#2022-03-1604:09ahungryI'm trying to follow set up guides for both fulcro and re-frame, and I'm hitting a dead-end in both scenarios when it comes to "Having no JS environment" (even if I ensure I visit something like localhost:8200 before trying repl buffer evaluation, in fact, i visited 3 localhost domains trying fulcro that were output in terminal). If I change from build-id :main or :app to browser, I can get a successful repl call to something like (js/alert 1) to work, but can't load any files from my project template (cljs) in repl. I thought my issue may have been emacs/cider specific, but even following the guide on shadow-cljs and said binary to make a client connection presented the same failure - I tried going through the shadow-cljs documentation for that section to no avail - any idea what I may be messing up?#2022-03-1607:23thheller@m131 sorry, don't know anything about emacs/cider. I can tell you how it works with the command line and maybe you can reconstruct what to do from there.#2022-03-1607:24thhellerwhen you visit the browser page that has your compiled JS loaded you should be getting a shadow-cljs ready log in the browser console#2022-03-1607:24thhellerassuming for all of this that your shadow-cljs watch the-build-id process is running#2022-03-1609:48AspirationalHi! I am using only whitespace :optimasations and continue to recieve warnings from chrome web store about code obfuscation. Can we somehow deel with such code obfuscation? out/background.js:null:null: var cljs$cst$symbol$response = new cljs.core.Symbol(null, "response", "response", 572107335, null);...............#2022-03-1612:06wombawombaSo the shadow-cljs build reports are fantastic, but is there a way to get even more detailed info? Specifically, I'd like to know which vars are getting pulled in from a specific namespace, and what code is pulling them in.#2022-03-1616:46thheller@dovganchin sorry, don't know what that error message means. definitely do not use :whitespace regardless though. at the very least :simple better :advanced. I doubt that is responsible for any issue you might see#2022-03-1616:49thheller@wombawomba that info does not exist. if you want that kind of detail you can use shadow-cljs release app --pseudo-names and go browsing through the code. through pseudo names you can sort of tell where code comes from and how it got there#2022-03-1616:50wombawombaalright, yeah, that's what I'm trying to do currently#2022-03-1616:55Aspirational@thheller earlier I have used --pseudo-names, and it were ok, but now apparently the requirements for code readability (for chrome extension) have increased and even using :simple does not work. It looks like we can no longer use clojuresctipt in chrome extension development.#2022-03-1616:57thhellerthat sounds highly unlikely. I don't know how they define readable but every build tool I know of minimizes the code in some way#2022-03-1616:58thhellerI know they banned certain things such as eval and dynamic script loading. never head of a "readability" check#2022-03-1616:59dpsuttonhttps://blog.chromium.org/2018/10/trustworthy-chrome-extensions-by-default.html has a heading New code readability requirements#2022-03-1617:00dpsutton“Starting today, Chrome Web Store will no longer allow extensions with obfuscated code.” and later “Thus, minification will still be allowed, including the following techniques:”#2022-03-1617:01thhellerhaha thats ridicilous. but according to their description :simple should be fine#2022-03-1617:02thhelleras if a human would read that code ...#2022-03-1617:02thhellerespecially whats wrong with var cljs$cst$symbol$response = new cljs.core.Symbol(null, "response", "response", 572107335, null);#2022-03-1617:03thhellertoo many $ in the variable name or what? 😛#2022-03-1617:08thhelleryou can try :compiler-options {:shadow-keywords true} in the build config. maybe its happy with that? somehow doubt that change anything but it will change that code a little bit#2022-03-1810:04Pepijn de VosHrm not sure why but Firefox debugger is showing "this page has no source" with 2.17.8 which worked in 2.13.0#2022-03-1810:06Pepijn de VosAlso, a warning that wasn't there before:
[To redirect Truffle log output to a file use one of the following options:
* '--log.file=<path>' if the option is passed using a guest language launcher.
* '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
* Configure logging using the polyglot embedding API.]
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
The guest application code will therefore be executed in interpreted mode only.
Execution only in interpreted mode will strongly impact the guest application performance.
For more information on using GraalVM see .
#2022-03-1812:13pinkfrogWhen running shadow watch, I saw this:#2022-03-1812:14pinkfrogWhy shadow install this?#2022-03-1815:31Pepijn de VosLooks like it's reagent that requires it, no?#2022-03-1815:48pinkfrogI remember that shadow will ignore those requirements from deps.cljs#2022-03-1818:23thhellershadow will install dependencies declared in deps.cljs files#2022-03-1815:04wombawombaHow does shadow-cljs decide which code goes in which module? I have a situation where I have a main module and several 'per-view' modules (let's say view-a, view-b, ...). All these modules, including main import a specific ns (let's call it my-ns), but only some of the modules actually use it. Still, almost all the code from my-ns ends up in main.js. Is there a way to 'move' this code out of main, so that it doesn't get loaded except in the views that use it?#2022-03-1815:36Pepijn de VosI assume you have seen https://shadow-cljs.github.io/docs/UsersGuide.html#CodeSplitting ?#2022-03-1815:44wombawombaYeah, that's what I'm using. My question is about how to move code from a 'base' module (`shared` in that example) into the modules that actually use it.#2022-03-1816:30Pepijn de VosI guess maybe try to make more granular shared modules but tbh I'm not sure. I tried code splitting and ran into weird bugs with React or something.#2022-03-1818:24thheller@U15RYEQPJ namespaces are moved as far to the other edges as possible. if many namespaces depend on a thing it'll be moved to the outermost common module#2022-03-1818:25thhellerso if all modules just depend on main that is the only place it can go. you can introduce another empty module with just :entries [] and have the mods depends on that too. that gives it a chance to move more maybe#2022-03-1818:26thhellerbut if main also requires the namespace you want move it will not be moving#2022-03-1818:27thheller:advanced can split but the code in namespaces but only if actually used in certain places. if 2 or more places use a thing it can't move#2022-03-1818:29wombawombaYeah I noticed that part of the code from this is gets moved to where I want it to be.#2022-03-1818:29wombawombaNs*#2022-03-1818:31wombawombaIf two modules that aren't main use the code, shouldn't it be possible to set up an 'intermediate' ns between those modules and main and have the code go there?#2022-03-1818:31thhellerin theory yes but it doesn't work that way#2022-03-1818:33thhellerit can't introduce new modules so it can only stay in main. this is by design. you can achieve the exact splits you want via tuning :modules#2022-03-1818:40wombawomba@U05224H0W are you saying that if i introduce the appropriate 'intermediate' modules myself, the code would get pulled up into them automatically?#2022-03-1818:41wombawombaIf so, that's definitely good enough for me :)#2022-03-1818:41thhellerwell all depends on what kind of code it is. not everything is moved by closure
#2022-03-1818:42thhellerreally hard to make generic statements about this stuff#2022-03-1820:22wombawombaAlright, thanks#2022-03-1815:39Pepijn de VosHow can I use inline to load some resource from the public folder? Or... what is a better place to store resources?
864 | (def resistor-icon (rc/inline "public/css/icons/resistor.svg"))
--------------------------^-----------------------------------------------------
Encountered error when macroexpanding shadow.resource/inline.
Resource not found: public/css/icons/resistor.svg at line 864 nyancad/mosaic/editor.cljs
#2022-03-1816:55Pepijn de VosI added "public" to :source-paths and that solved it#2022-03-1818:22thhellerdon't do that. move the file onto the classpath instead#2022-03-1819:18rende11Can someone help? How I can fix it?
:shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@monaco-editor/loader/lib/cjs/loader/index.js", :requires [{:line 135, :column 2}]}
At line 135:
require(['vs/editor/editor.main'], function (monaco) {
    storeMonacoInstance(monaco);
    state.resolve(monaco);
  }, function (error) {
    state.reject(error);
  });
#2022-03-1819:24thhellercan't. this is not supported by shadow-cljs. you can use webpack instead as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2022-03-1819:27thhellermonaco is pretty bundler unfriendly#2022-03-1819:27thhellerI believe it even requires a plugin when using webpack. at least it used to#2022-03-1819:30rende11Do you have some examples with it?#2022-03-1819:43thhellerno but I'm sure the official docs have a section about building#2022-03-2102:30Yosevu KilonzoIs there a better way to import and use an ESM only npm package like rehype-react than accessing the default property:
(ns uniorg-test.core
  (:require
   ["unified" :refer [unified]]
   ["uniorg-parse" :as uniorg-parse]
   ["uniorg-rehype" :as uniorg-rehype]
   ["uniorg-extract-keywords" :as extract-keywords]
   ["rehype-react" :as rehype-react]
   ["react" :refer [createElement]]))

(def processor (-> (unified)
                   (.use uniorg-parse)
                   (.use extract-keywords)
                   (.use uniorg-rehype)
                   (.use (.-default rehype-react) #js {:createElement createElement})))

(.then (.process processor "* hello org-mode") #(.log js/console %))))
#2022-03-2105:59thheller@yosevuk see the translation examples here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-03-2113:54Yosevu KilonzoAh, thanks! I take a look at that.#2022-03-2105:59thhellerso ["rehype-react$default" :as rehype-react]#2022-03-2115:11ingesolI bumped some JS dependencies, and I’m now seeing an error I haven’t seen before:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/me/project/node_modules/refractor/index.js from  /Users/me/project/app.js not supported.
Instead change the require of index.js in  /Users/me/project/app.js to a dynamic import() which is available in all CommonJS modules.
This was after bumping refractor from 3.3.1 to 4.2.2 . The app.js is built as target :node-library. Is this a known issue with a known fix? I see they converted the refractor code to ESM between those versions, so it now requires import x from y, but app.js contains require("x")
#2022-03-2117:51thhellerhmm yeah that is a node issue#2022-03-2117:51thhellershadow-cljs :node-library generates commonjs code and that is not allowed to require ESM code. so it fails with that error.#2022-03-2208:18ingesol@thheller Right, thanks. I was just surprised that this was such an uncommon problem in the Node CLJS world. But I realized just now that we are probably requiring JS libraries that are mostly used in the browser, and that’s the bit that is uncommon.#2022-03-2208:21thhellerwell it'll become more common once more packages are published as ESM only#2022-03-2208:21thhelleryou can use :target :esm to generate ESM output which can consume those libs just fine#2022-03-2208:22thhellerbut it may have other issues with commonjs in exchange 😛#2022-03-2208:41pezWhen upgrading to latest shadow (from http://2.15.in a project, I get:
Syntax error compiling at (shadow/build/cljs_hacks.cljc:101:27).
No such var: ana/munge-goog-module-lib
What could be the culprit here? Even trying with 2.16.4 I get the same error.
#2022-03-2209:09pezA too old ClojureScript seems to have been the problem. This was then obscured by some of our sub projects depending on old versions of shadow-cljs. When I comment away those transitive deps, shadow suggested the ClojureScript dependency as a source of the problem. Which it was.#2022-03-2209:12pezNow, I somehow suspect that the problem I was chasing (a lot of cider-nrepl ops unavailable) could have been caused by the transitive shadow-cljs dependencies. What's the recommended setup there? We have a lot of sub projects where we use shadow-cljs. Would excluding shadow-cljs when declaring the subproject dependencies in the main project help?#2022-03-2210:41thhellerthe main project needs to declare its shadow-cljs dependency. that is pretty much the only thing you need.#2022-03-2210:42thhellerwhether or not the sub projects do too should not matter then#2022-03-2210:42thhellerthe project deps always win over any other#2022-03-2210:44thhellerjust need to avoid the situation where you only have shadow-cljs declared but not clojurescript#2022-03-2210:45thhellerthat way it can pick the new shadow-cljs but some old clojurescript somewhere out of the transitive deps if it doesn't find the one declared by shadow-cljs "first"#2022-03-2211:05pezThe main project is declaring its shadow-cljs dependency. Yet had a situation when a version from some sub project was used. Probably a misconfiguration, right?#2022-03-2211:07pezWith the original config it behaves like you say, main project wins. It was while fiddling around trying to understand that compile error that all of a sudden I saw yet another shadow version being used.#2022-03-2217:37thhellerhard to comment without knowing your particular setup. you can make pretty much everything happen if you want 😛#2022-03-2220:32pezYeah, sorry for rambling. I'm trying to digest the info you provided. 😃#2022-03-2212:34chromalchemyI am having trouble getting cljs-devtools loading on a :target npm-module build. I tried different flavors of manual install, but nothing working. Any tips?
{:source-paths ["src"]
 :dependencies
   [[binaryage/devtools "1.0.5"]]

 :builds
   {:code
    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]}}}
(ns gbo.mycljs
  (:require [devtools.core :as devtools])

(defn installCljsDevtools []
  (devtools/install!))
app.js
var clj = require("shadow-cljs/gbo.mycljs");
clj.installCljsDevtools();
I tried calling the devtools/install! from the html in a different script tag, but was unable to call it as a second namespace, exposed in the global html context. The resulting js is run through (an older) webpack build, could that be the issue? My dev server has to run on node 12.6. But i compile shadow-cljs with latest node, and other functions seem to run ok.
#2022-03-2213:13chromalchemyI reset my devtools to defualts, and now something is showing up. I am getting this even if I try to run with :optimizations :none
:builds
   {:code
    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]
     :compiler-options {:optimizations :whitespace}}}
#2022-03-2213:24chromalchemyMaybe I need an explict :devtools config with things like
:watch-dir
:watch-path 
:before-load-async 
:after-load
#2022-03-2213:25chromalchemyI am not using the shadow-cljs server. I am running of a webpack build/reload codepase and using :npm-module to integrate cljs. But i am open to other suggestions. (Like is it easier to just use another build target?) I prefer to not disrupt the existing js codebase, just add some functions to it.#2022-03-2217:39thhelleryou don't need any additional config for cljs-devtools but its kinda hard to tell what might be wrong without seeing the JS side of things#2022-03-2217:40thhellerwebpack might be doing all sorts of stuff to the code#2022-03-2217:40thhellermaybe try including shadow-cljs watch or compile output. not release output?#2022-03-2219:48Dmytro BuninI am not sure if this question should go here or clojurescript but oh well. I have code like this
(fn [row-data]
  (. row-data -field))
And this function something on dev build but returns undefined in the release build. My guess is there is something going on in the optimization (obviously). I am curious why it breaks and how to make sure that it works consistently?
#2022-03-2219:49thhellerdo you not get inference warnings for this?#2022-03-2219:49thhellerbut yes. this is an externs issue. can be fixed by using (fn [^js row-data] ...)#2022-03-2219:50thhelleryou really should be getting a warning for this. unless you are on a really really old shadow-cljs version, or decided to ignore the warnings or turn them off 😛#2022-03-2219:50thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#externs#2022-03-2219:55Dmytro BuninOh, right, thanks!#2022-03-2219:57Dmytro Bunininteresting why I’m not getting a warning :thinking_face:#2022-03-2219:58thhellerwhich shadow-cljs version do you use? in older versions this wasn't enabled be default#2022-03-2220:00Dmytro Buninthheller/shadow-cljs {:mvn/version "2.9.10"}#2022-03-2220:01thhelleryeah thats really old. wasn't enabled be default back then#2022-03-2220:01Dmytro BuninI will consider updating then 🙂 Thank you#2022-03-2220:02thhelleryou can just enabled it. the link above tells you how#2022-03-2220:02thhellerbut yeah upgrade works too 😉#2022-03-2220:11raymcdermottjust checking something ... I'm trying to load my app using shadow and tools.deps - but I only seem to ever get the dashboard#2022-03-2220:13raymcdermottI read that clj does not support server-mode - so does that mean that I can't have the app served by shadow in this configuration?#2022-03-2220:13raymcdermottfrom the local file system I mean#2022-03-2220:14thhelleruhm the dashboard is served on its own server that has nothing to do with your apps code. that is a separate thing.#2022-03-2220:14thhellerhas nothing to do with deps.edn or clj#2022-03-2220:15thhellerthe dashboard runs on :9630 by default. for your app you can use :dev-http or any other webserver you want. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2022-03-2220:16raymcdermottI tried the :dev-http but didn't get anywhere ... I'll RTFM again 🙂#2022-03-2220:18raymcdermottAh - it's a top level keyword ... I had it in the :build#2022-03-2220:18thhelleryes#2022-03-2220:19raymcdermottthanks#2022-03-2222:25scarytomI have symlinked my node_modules directory somewhere outside my project (so that i can cache between runs in CI) and whilst npm is fine with this, shadow-cljs appears unhappy. I get
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'readline-sync'
is that a known issue?
#2022-03-2305:29thhellerthat is an error from node. not shadow-cljs.#2022-03-2315:52scarytomfair point. I guess I have jumped to conclusions, but I was under the impression that npm was fine with a symlinked node_modules dir#2022-03-2300:14wevremShould the newly available :as-alias in Clojure 1.11.0 work with Clojurescript in a shadow-cljs setup? And if it isn’t working for me, is it because shadow-cljs is using an older version of Clojure?#2022-03-2305:30thhellerit works regardless of clojure version. if it isn't working you are likely on an old version of shadow-cljs.#2022-03-2315:39wevremWell I’m using /cdn-cgi/l/email-protection installed via npm, but none of the dependencies in shadow-cljs.edn say anything about which version of Clojure to use. Do I need to explicitly add Clojure as a dependency there?#2022-03-2315:43wevremNope, that doesn’t work, the message says it is ignored and default version is used to ensure compatibility.#2022-03-2317:47thhellershadow-cljs supports this on its own. neither the clojure nor clojurescript version matters. just use it.#2022-04-0210:21ÆlfsygSorry to necropost, but from my investigations this morning it seems that shadow-cljs supports :as-alias within ns but not within a free-standing (require '[foo.bar :as-alias bar]).#2022-04-0214:28thheller
cljs.user=> (require '[foo.bar :as-alias x])
nil
cljs.user=> ::x/foo
:foo.bar/foo
#2022-04-0214:28thhellerworks fine for me#2022-04-0312:22ÆlfsygCould this be caused by something else?
> shadow-cljs info
shadow-cljs - config: /home/ae/src/ablution/cljs/ablu.ui/shadow-cljs.edn
=== Version
jar:            2.17.8
cli:            2.17.8
deps:           1.3.2
config-version: 2.17.8
> shadow-cljs watch app
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.17.8 running at 
shadow-cljs - nREPL server started on port 3333
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /home/ae/src/ablution/cljs/ablu.ui/src/ae/ablution/ui/core.cljs:11:1
--------------------------------------------------------------------------------
   8 |             [ae.ablution.address.interface.spec :as a.spec]
   9 |             [ae.ablution.ui.views :as views]))
  10 |
  11 | (require '[foo.bar :as-alias bar])
-------^------------------------------------------------------------------------
null
Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: [foo.bar :as-alias bar] at line 11 ae/ablution/ui/core.cljs
--------------------------------------------------------------------------------
  12 |
  13 | (defn ^:export init
  14 |   []
  15 |   (router/start!)
--------------------------------------------------------------------------------
#2022-04-0312:54thhelleryou cannot use require there. that needs to be part of the ns :require#2022-04-0312:54thhellerrequire otherwise only works in the REPL#2022-04-0313:32ÆlfsygDo you mean for Clojure in general, Clojurescript, or Shadow-CLJS?#2022-04-0313:52ÆlfsygSupport require outside of ns: https://clojure.atlassian.net/browse/CLJS-1346?oldIssueView=true#2022-04-0316:04thhellerthat doesn't do what you think it does and has been shown to create many more problems than it solves#2022-04-0316:04thhellerjust do (ns foo.bar (:require [other.foo :as x] [other.bar :as-alias y])) and done#2022-04-0316:05thhellerdon't try to get creative with require ouside ns that ultimately doesn't end up working#2022-04-0317:14ÆlfsygFair. Thank you for your work!#2022-03-2308:57bbssThank you for defclass ! I had been struggling with js/Reflect.construct gobj/extend js/Object.create js/Object.assign (.call Class this props) and nothing seemed to go the way I wanted. At first defclass also seemed to not work but figured it out just fine eventually!#2022-03-2311:22wombawombaSo I'm using an NPM module — https://github.com/react-syntax-highlighter/react-syntax-highlighter — for syntax highlighting, which has built-in support for two different syntax highlighters (Prism.js and Highlight.js). Taken together, these highlighter packages together with all their supported languages are quite weighty — over 1MB of built code. To avoid pulling in stuff I'm not using, I'm using PrismLight (as described under "Light Build": https://github.com/react-syntax-highlighter/react-syntax-highlighter#light-build), which is meant to only pull in Prism.js itself plus languages that are explicitly specified. Yet, both Prism.js and Highlight.js, together with all the supported languages are included in my shadow-cljs build output. What can I do to avoid this?#2022-03-2319:34thhellerthis is all relying on non-standard features specific to webpack#2022-03-2319:34thhellerso it will only work properly when using that#2022-03-2320:08wombawomba@U05224H0W any advice on how to use webpack to sort this out? I tried using option #2 at https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html, but this still seems to cause the entire package to be included (I believe the relevant line in the output target/index.js is ALL["react-syntax-highlighter"] = require("react-syntax-highlighter");)#2022-03-2320:09thhellernot supported#2022-03-2320:09wombawombasorry, what is not supported? 🙂#2022-03-2320:10wombawombausing webpack to fix this?#2022-03-2320:10thhelleryes#2022-03-2320:11wombawomba😞#2022-03-2320:11thhelleryou can try requiring whatever you need directly#2022-03-2320:11thhellerlook at the files in node_modules/react-syntax-highlighter#2022-03-2320:11thhellerit likely is just a bunch of files with re-exports#2022-03-2320:11wombawombayeah I'm actually doing that now#2022-03-2320:12thheller(:require ["react-syntax-highlighter/dist/cjs/prism-light.js"]) or so#2022-03-2320:12thhellerdunno about the rest though#2022-03-2320:14thhellerhttps://github.com/react-syntax-highlighter/react-syntax-highlighter#light-build#2022-03-2320:14thhellerthis is fully supported (loading the specific languages I mean)#2022-03-2320:15thhellerjust never require the full react-syntax-highlighter package#2022-03-2320:23wombawombacool#2022-03-2320:30wombawombahey that worked, thanks!#2022-03-2320:31wombawomba@U05224H0W while I have your attention, do you think it would be possible to use the "Async Build" option described at https://github.com/react-syntax-highlighter/react-syntax-highlighter#async-build with shadow-cljs, or do something similar?#2022-03-2320:31thhellerdo something similar yes#2022-03-2320:31wombawombahow?#2022-03-2320:31thhellerregular code splitting and loading the languages you need in the extra modules#2022-03-2320:32thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html.#2022-03-2320:32wombawombaaw#2022-03-2320:33wombawombaI mean, I am using code splitting and it's great, but... wouldn't I have to manually create a module for each language?#2022-03-2320:33wombawombabecause there are a lot of them: https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD#2022-03-2320:33thhellerdo you need all of them?#2022-03-2320:33wombawombaideally yes#2022-03-2320:33thhellerautomatic splits are not supported#2022-03-2320:34thhellerI guess you could write something to generate a build config for you or a custom :target#2022-03-2320:34wombawombausers should ideally be able to highlight any code they want#2022-03-2320:35wombawombaokay, let's say I wanted to create one module per language—could I do that in shadow-cljs.edn only, or would I create a cljs file for each separate language?#2022-03-2320:36thhellercan't say#2022-03-2320:36thhellerdo the languages register themselves on load or do you need to call something?#2022-03-2320:37thhellerlooks like you need to call something in the example?#2022-03-2320:37thhellerif the direct require works you might be able to go with webpack#2022-03-2320:38thheller(:require ["react-syntax-highlighter/dist/cjs/prism-async.js"]) or so#2022-03-2320:41wombawombaAFAICT it should just 'magically' work — somehow it loads languages lazily when you create corresponding reagent components#2022-03-2320:41wombawombathis is kind of over my head though, so I'm not sure from looking at the code how exactly it works#2022-03-2320:42wombawombayou mean I'd use that import with method #2 from your blog post?#2022-03-2321:07wombawombaalright, I tried that and it doesn't seem like webpack does any code splitting automatically#2022-03-2321:07wombawombaI'm trying to see if there's something I need to configure in webpack...#2022-03-2321:18wombawombathe problem seems to be that the prism-async thing doesn't actually load languages async#2022-03-2321:19wombawombaanyway, I think I might try using shadow-cljs to split the languages out as modules myself#2022-03-2321:19wombawombaseems like a fun exercise#2022-03-2321:21wombawomba@U05224H0W is there any support for writing code to generate a shadow-cljs config? or to merge config from multiple files? (so I don't have to clutter up my current shadow-cljs file)#2022-03-2400:20wombawombaeh nevermind, I typed it out and it wasn't too bad#2022-03-2406:09thhelleryes, webpack also needs to be setup to code split. and the async loading can only work if the bundler (ie. webpack) bundled the code accordingly. in webpack this is done via dynamic import in the code. in the closure compiler things are configured via :modules statically.#2022-03-2406:10thhellerno you cannot generate the config with the default targets. but you could create a "wrapper" target that generates config in CLJ code and then just delegates to the regular :browser target or so. this is non-trivial and will require digging fairly deep into the internals of shadow-cljs though 😛#2022-03-2417:33wombawombagot it#2022-03-2417:34wombawombafwiw setting up dynamic language loading with shadow-cljs was pretty straightforward#2022-03-2417:34wombawombashadow.lazy helped a bunch#2022-03-2417:35wombawombathe only annoying part was that some of the language packs turned out to depend on other language packs (so I had to set up dependencies between modules accordingly)#2022-03-2311:25wombawomba...also, would it be possible to use the "Async Build" (https://github.com/react-syntax-highlighter/react-syntax-highlighter#async-build) with shadow-cljs?#2022-03-2311:53emil0rDoes anyone have problems with tick for release compilation? With :simple optimizations I get
java.time.OffsetDateTime = java.time.goog$module$goog$object.get(module$node_modules$$js_joda$core$dist$js_joda, "OffsetDateTime");
java.time.OffsetTime = java.time.goog$module$goog$object.get(module$node_modules$$js_joda$core$dist$js_joda, "OffsetTime");
module$node_modules$$js_joda$core$dist$js_joda lacks both OffsetDateTime and OffsetTime. Currently running on 5.2.0 for @js-joda/core , and they should be there from what I can tell. All other modules are existing
#2022-03-2312:20emil0rI suppose this speaks volumes about how much I trust shadow-cljs o_O. rm -rf node_modules && npm i solved the problem#2022-03-2314:40kennytiltonDoes shadow have the equivalent of the leiningen checkouts folder usage? ie, some way I can edit a library and have the changes picked up on the next build without installing? Working on my mxWeb Trainer app I am coming up with tweaks for Matrix and mxWeb often enough that that would grease the skids a bit. Not that a local deploy install is the end of the world. (They are leiningen projects.)#2022-03-2316:30Pepijn de VosOhh how does your local deploy solution work? I am also developing a library in parallel to my app, and so far I'm just doing extensive testsing and Clojars releases. Would be nice to short circuit that a bit.#2022-03-2319:32thhellershadow-cljs.edn alone does not have checkouts support no#2022-03-2319:32thhellerbut if you use lein to manage dependencies then checkouts works just fine#2022-03-2319:32thhellersame with deps.edn#2022-03-2319:49kennytiltonBig caveat @UPHKPR2A3: I know little about CLJ tooling! Anyway... My two changing dependencies are lein projects, so I can do lein install and have either refreshed in a few seconds. The bad news is, I still have to reboot the shadow watch and server to pick up the changed jar. Unless I am missing something. And I do not know if you can take advantage of lein install, or if shadow has the equivalent. This, however, looks encouraging: https://shadow-cljs.github.io/docs/UsersGuide.html#publish-lein And there may well be a simpler shadow command the cognoscenti can provide.#2022-03-2319:54thhelleragain .. just use lein. with all the features it provides.#2022-03-2321:47kennytilton"just use lein" Sounds like heaven. I did not realize that would work. To me the build process is a mystery, esp. because I did not come from a Java/JAR/Maven background. I just find "starter" projects for a given build tool, or for leiningen do lein new app, and get on with my coding with my fingers crossed. Does "just use lein" mean: • create a minimalist project.clj as documented in https://shadow-cljs.github.io/docs/UsersGuide.html#publish-lein • then lein deps will Do the Right Thing? Including maintaining, pom.xml, I see? • or is it just for lein deploy clojars? • will checkouts work automagically as long as I run lein deps after a change to the contents of checkouts? Thx!#2022-03-2406:11thhelleryou use lein as you normally do. so you put your :dependencies and :source-paths in project.clj. then add the checkouts you want to that project. then you also add the thheller/shadow-cljs dependency to that project.clj.#2022-03-2406:12thhellerin shadow-cljs.edn you set :lein true or :lein {:profile "+cljs"} (if you use a leinigen profile)#2022-03-2406:13thhellerthat will make shadow-cljs use lein to create the classpath and launch the JVM. so since lein is in charge checkouts just work#2022-03-2406:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_build_tool_integration#2022-03-2406:14thhellerthis is not a about publishing so you are looking at the wrong piece of the docs#2022-03-2414:37kennytiltonYeah I was in the wrong section, and now that I see it don't know how I missed it! Thx for your patience!#2022-03-2315:09RyanHow does one upgrade shadow-cljs to use clojurescript 1.11.4? Dying to use the :as-alias in requires#2022-03-2315:09RyanI don't seem to have an explicit dependency in shadow-cljs.edn#2022-03-2315:33RyanIs it that you wait until there's a shadow-cljs version built with 1.11.4 and it handles itself?#2022-03-2319:36thhellerit has been available for months in shadow-cljs#2022-03-2319:36thhelleryou need no new clojurescript or clojure version for this#2022-03-2319:36thhellerjust a relatively recent shadow-cljs version#2022-03-2319:37thhelleralso note that there is no cljs release with :as-alias support yet. 1.11.4 is not it.#2022-03-2319:37thhellerbut as I said .. not required. it just works already.#2022-03-2401:47wevrem@U020G0VEL75 I was having some trouble with this same thing earlier, and it turned out that even though I had the latest version of shadow-cljs installed locally in my project, I was invoking the global install of shadow-cljs at the command line, and that global install was quite old. I updated the global install, and also changed my habits to invoke the local install going forward.#2022-03-2318:36danielcomptonIs there a way to create a “vendor” module which includes all 3rd party dependencies? Would be helpful in reducing load times for very large CLJS apps. Like https://blog.jakoblind.no/code-split-vendors-with-webpack-for-faster-load-speed/#2022-03-2318:39thhellerpossible yes, helpful unlikely. better to properly split your code so parts no used initially aren't loaded in the initial download#2022-03-2318:40thhellersplitting all 3rd party libs likely won't help since it'll still load all of them together anyways then#2022-03-2318:40thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html has some suggestions that might help#2022-03-2318:51danielcomptonWas that sample project published anywhere? I can’t see the source to lazy-component ?#2022-03-2318:58thhellerlink is in the intro yes#2022-03-2318:58thhellerhttps://github.com/thheller/code-splitting-clojurescript#2022-03-2318:48danielcomptonWould be helpful in the sense that the vendored bundle will not get cache-busted as often as the app#2022-03-2318:57thhellerdue to how :advanced works that very rarely works#2022-03-2318:59thhelleryou can go with option #2 described here and actually use webpack https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2022-03-2318:59thhellerthat effectively is a vendor bundle all on its own#2022-03-2318:59thhellerstill has the problem of loading all npm dependencies at once which is rarely what you want#2022-03-2400:50Oliver GeorgeFunny that should be the topic right now. I'm here to ask if there's a recommendation for how to break up that vendor bundle because the page is taking 5s to load!#2022-03-2400:51Oliver GeorgeIn my case there's a dependency needed for generating PDFs which isn't needed immediately. That adds something like 2.5mb to the js. (https://react-pdf.org/)#2022-03-2406:16thheller@olivergeorge the setup described here https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2022-03-2406:17thhellerand then the modules however make sense for your project#2022-03-2406:17thhellerone example I have from the shadow-cljs UI is https://github.com/thheller/shadow-cljs/blob/051b5ecc7d701ef45b3bbc839685ac6ea03d4ad7/shadow-cljs.edn#L87-L96#2022-03-2406:18thhellerthere I have codemirror which is also a pretty large dependency. I delay loading it until it is actually used.#2022-03-2407:59Oliver GeorgeThank you#2022-03-2408:30Oliver GeorgeSeems like :js-provider :external might complicate this #2022-03-2408:31Oliver GeorgeBut that's speculation. I’ll give it a go. #2022-03-2408:31thhellerthat is correct yes. :external will move all JS deps into one single file.#2022-03-2408:32thhellerthe way webpack handles code splitting is entirely different than the closure compiler. so the two don't really get along.#2022-03-2408:33thhellerin theory it should be possible to combine the two somehow. just haven't figured out how that would need to look on the webpack side or how you'd even configure that#2022-03-2408:34thhellerif some webpack export wants to help out I'd be happy to write the cljs side of things 😛#2022-03-2408:34Oliver GeorgeThanks. Yep. All a bit messy. #2022-03-2408:36Oliver GeorgeI would happily ditch webpack but the pesky WASM dependency gets in the way. #2022-03-2408:37thhellersome wasm deps allow you to control how the wasm is actually loaded#2022-03-2408:37thhellerin that case it can be easily integrated but it all depends on how that wasm glue code came about#2022-03-2408:38thhellerI did some stuff a while ago, maybe that is still accurate in some way https://github.com/thheller/wasm-pack-cljs#2022-03-2408:39Oliver GeorgeThanks again. I'm really not across the wasm details. This react-pdf dep is wrapping pdfkit which is probably quite professional I guess. #2022-03-2408:40thhellerI also created this a while ago https://github.com/thheller/reagent-pdfjs#2022-03-2408:40thhellerpretty sure pdfkit also offers a CDN version. so that may also work#2022-03-2408:41thhellerwith https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve you can make just about anything happen#2022-03-2408:41thhellerso even just moving out pdfkit can work#2022-03-2408:45Oliver GeorgeI’ll look into that - thanks again#2022-03-2409:20wombawomba@thheller UX suggestion: the "dependency trace" tooltip in the build report tends to go off-screen (and thus become unreadable) when there are lots of modules. It'd be better to use an expand/collapse toggle like what you already have for the "groups".#2022-03-2412:21barrellI’m trying to set up a web worker, but I keep getting the error worker.js:67 Uncaught Error: Namespace "goog.dispose" already declared.. Does anyone know why this is? shadow-cljs config:
:worker {:init-fn my.app.worker/load!
         :depends-on #{:shared}
         :web-worker true}}
my.app.worker:
(ns my.app.worker)

(js/console.log "worker/read!")

(defn load! []
  (js/console.log "worker/load!"))
https://my.app:
(defn init []
  (let [worker (js/Worker. "/js/worker.js")]
    (.addEventListener worker "message" notify-worker-message)))
#2022-03-2418:20barrell^ solution: needed to update shadow-cljs. Was the first thing I tried, but my globally installed version of node_modules was using 2.16.12. Updated it to the latest and everything worked like a charm 🙂#2022-03-2519:49Eva OI'm trying to run npx shadow-cljs server but I'm running into an error:
shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

Full report at:
/var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-15894664129410946386.edn
#2022-03-2519:51Eva OThe full report:
{:clojure.main/message
 "Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line 40,
  :clojure.error/cause
  "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
  :clojure.error/symbol clojure.main/main,
  :clojure.error/source "main.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message
    "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.",
    :at [clojure.lang.RT load "RT.java" 462]}],
  :trace
  [[clojure.lang.RT load "RT.java" 462]
   [clojure.lang.RT load "RT.java" 424]
   [clojure.core$load$fn__6908 invoke "core.clj" 6161]
   [clojure.core$load invokeStatic "core.clj" 6160]
   [clojure.core$load doInvoke "core.clj" 6144]
   [clojure.lang.RestFn invoke "RestFn.java" 408]
   [clojure.core$load_one invokeStatic "core.clj" 5933]
   [clojure.core$load_one invoke "core.clj" 5928]
   [clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
   [clojure.core$load_lib invokeStatic "core.clj" 5974]
   [clojure.core$load_lib doInvoke "core.clj" 5953]
   [clojure.lang.RestFn applyTo "RestFn.java" 142]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$load_libs invokeStatic "core.clj" 6016]
   [clojure.core$load_libs doInvoke "core.clj" 6000]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.core$apply invokeStatic "core.clj" 669]
   [clojure.core$require invokeStatic "core.clj" 6038]
   [clojure.main$main_opt invokeStatic "main.clj" 514]
   [clojure.main$main_opt invoke "main.clj" 510]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause
  "Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath."}}
I'm using version 2.17.8 for both JS and Clojure. My deps.edn:
{:paths ["src/main", "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.11.0"}
        com.fulcrologic/fulcro {:mvn/version "3.5.15"}
        com.taoensso/timbre {:mvn/version "5.2.1"}}
 
 :aliases {:dev {:extra-paths ["src/dev"]
                 :extra-deps {org.clojure/clojurescript {:mvn/version "1.11.4"}
                              binaryage/devtools {:mvn/version "1.0.5"}
                              cider/cider-nrepl {:mvn/version "0.28.3"}
                              thheller/shadow-cljs {:mvn/version "2.17.8"}}}}}
My shadow-cljs.edn:
{:deps {:aliases [:dev]}
 :dev-http {8000 "classpath:public"}
 :builds {:main {:target :browser
                 :output-dir "resources/public/js/main"
                 :asset-path "/js/main"
                 :modules {:main {:init-fn quizlet.client/init
                                  :entries [quizlet.client]}}
                 :devtools {:after-load quizlet.client/refresh
                            :preloads [com.fulcrologic.fulcro.inspect.preload
                                       com.fulcrologic.fulcro.inspect.dom-picker-preload
                                       quizlet.development-preload]}}}}
#2022-03-2519:51thhellerthat error you get when shadow-cljs is not on the classpath#2022-03-2519:51Eva OHow do I add it to the classpath?#2022-03-2519:51thhellermight be some bad cache or maybe the jar download was aborted and is incomplete?#2022-03-2519:52thhellertry deleting your .cpcache folder#2022-03-2519:52thhellerwhen that doesn't work delete ~/.m2/repository/thheller/shadow-cljs#2022-03-2519:53thhellerotherwise looks fine#2022-03-2519:54Eva OSame error except it also includes WARNING: Specified aliases are undeclared: [:-A]#2022-03-2519:55thhellerhmm weird. which OS is this?#2022-03-2519:56thhellerthis is a regular tools.deps install I assume? maybe thats outdated or broken somehow?#2022-03-2519:57Eva OMacOS 12.2.1#2022-03-2519:57thhellervia :deps you are telling shadow-cljs to run tools.deps clojure command. that should be fine but may break if thats not the standard thing#2022-03-2519:57Eva OWhat is tools.deps?#2022-03-2519:57thhelleryou can try clojure -A:dev -M -m shadow.cljs.devtools.cli server#2022-03-2519:57thhellerdeps.edn#2022-03-2519:58Eva OSame error#2022-03-2519:58thhellerwhat is clojure?#2022-03-2519:58Eva OWdym?#2022-03-2519:59thhellerwhat is the clojure command for you?#2022-03-2519:59thhellerit should be this right https://clojure.org/guides/deps_and_cli#2022-03-2519:59thhellerhttps://clojure.org/guides/getting_started#2022-03-2519:59thhellerdunno how you installed it#2022-03-2520:00Eva OBoth clojure and clj give the same output#2022-03-2520:00Eva OThe weird thing is that it works in other projects. It's just this new one that's breaking#2022-03-2520:00thhellerclj -version?#2022-03-2520:02thhellerwhat I have seen before is some not-visible unicode char as the first char in deps.edn#2022-03-2520:02thhelleror somewhere else? forgot how to figure that out though#2022-03-2520:02Eva O
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
-version (No such file or directory)

Full report at:
/var/folders/kh/tgss0d8s04v0xh2mtztlfw2r0000gn/T/clojure-9249228989860048614.edn
#2022-03-2520:03Eva OThat's what I get when I run clj -version#2022-03-2520:03thhellerhmm there is definitely something weird then? might just be super old? I get
$ clj -version
Clojure CLI version 1.10.3.855
#2022-03-2520:04thhellermaybe clj -Sdescribe?#2022-03-2520:04Eva OMy version is 1.11.0. I checked by just running clj#2022-03-2520:04thhellerno, that is the clojure version. not the version of the clj tool itself#2022-03-2520:04Eva O
clj -Sdescribe
{:version "1.10.1.561"
 :config-files ["/usr/local/Cellar/clojure/1.10.1.561/deps.edn" "/Users/eoogbe/.clojure/deps.edn" "deps.edn" ]
 :config-user "/Users/eoogbe/.clojure/deps.edn"
 :config-project "deps.edn"
 :install-dir "/usr/local/Cellar/clojure/1.10.1.561"
 :config-dir "/Users/eoogbe/.clojure"
 :cache-dir ".cpcache"
 :force false
 :repro false
 :resolve-aliases ""
 :classpath-aliases ""
 :jvm-aliases ""
 :main-aliases ""
 :all-aliases ""}
#2022-03-2520:05thhellerhmm yeah that is kinda old#2022-03-2520:05thhellermaybe try upgrading that#2022-03-2520:07Eva OI don't remember how I initially installed clojure since it was a long time ago. Since I'm using a Mac, I would assume I did it through brew. However brew upgrade clojure/tools/clojure doesn't work. I'm going to try to reinstall with brew. Hopefully it doesn't clobber it#2022-03-2520:08thhellerI'm not sure why it wouldn't work either. maybe try asking in #tools-deps. that error about missing alias is definitely weird#2022-03-2520:08thhellerseems declared fine to me but thats the root of the problem it seems#2022-03-2520:30agDoes anyone know, when used with github actions, shadow-cljs doesn't cache jars that shadow uses, and they keep getting re-downloaded each time. Has anyone dealt with this?#2022-03-2605:49thhelleryou need to setup caching yourself. I don't have a guide for that but I'm sure there is one. regular maven caching will do#2022-03-2523:02FlavaDavetrying to use amazon-cognito-identity-js and per the the table here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages I wrote
(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js" :refer (CognitoUserPool)]))
but whenever i try to use CognitoUserPool it says its an undeclared var
#2022-03-2523:03FlavaDaveI also tried
(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js$default" :as CognitoUserPool]))
but that didnt work either
#2022-03-2602:35Drew VerleeCan you share the js equivalent your working from? I always have to just pattern match from what I'm given to what's on that table.#2022-03-2620:00FlavaDavehttps://gist.github.com/gabeweaver/d1be9f0d41069437f576c375c30e134c#2022-03-2620:02FlavaDaveand here is where all the exports are in the cognito lib https://github.com/aws-amplify/amplify-js/blob/main/packages/amazon-cognito-identity-js/src/index.js#2022-03-2621:20thhellerlikely is
(ns presentation.cognito.auth
  (:require ["amazon-cognito-identity-js$default" :refer (CognitoUserPool)]))
#2022-03-2621:20thhellernote not :as since CognitoUserPool is not the default export#2022-03-2621:21thhellernote that the docs have a section on how to figure this out just below the examples#2022-03-2621:22thhellerthat should probably be more prominent but just at the end of that section#2022-03-2621:22thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-03-2621:26FlavaDavehmmm i changed it to your suggestion and get
:shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(ns presentation.cognito.auth\n  (:require [\"amazon-cognito-identity-js$default\" :refer (CognitoUserPool) ]))", :ns presentation.cognito.auth, :repl true}, :include-init false, :call-id 7, :from 10}}
StackOverflowError 
        shadow.build.npm/find-resource (npm.clj:726)
when i try to evaluate the namespace
#2022-03-2621:27FlavaDavei’ll read those docs more and try an figure it out#2022-03-2621:27FlavaDavethank you#2022-03-2705:43kardanI have this in a toy project (but, should work) (ns … (:require [“amazon-cognito-identity-js” :refer [AuthenticationDetails CognitoUserPool CognitoUserAttribute CognitoUser]] ))#2022-03-2706:59thheller@UF41YH1CM which shadow-cljs version do you use? the stackoverflow was a bug in 2.17.0 so upgrade if you use that#2022-03-2720:48FlavaDaveahh yes i made the switch to 2.17.8 and it works perfectly now!#2022-03-2720:48FlavaDavethanks!#2022-03-2619:08barrellIf I have an atom in a web worker namespace, is there any way to inspect this value via the REPL? I’m assuming the repl is connected to the main thread as when I try to execute anything the values are all empty#2022-03-2619:12barrellOr is there some integration with insepct/tap that I can load an atom into it and inspect it at any time?#2022-03-2619:14barrellOh my god. I can just open up all the defined atoms in a namespace? Consider my mind blown.#2022-03-2619:18barrellIf there is anyway to cycle the JS runtime you connect to though, I’d still be keen to know#2022-03-2619:25barrellOr looking through the source code it looks like maybe there is some way to delegate tasks to the worker thread? :thinking_face:#2022-03-2619:45barrellI’m getting close with something like:
(->> (shadow.cljs.devtools.api/repl-runtimes :browser)
     (last)
     :proc-id
     (hash-map :proc-id)
     (shadow.cljs.devtools.api/repl :browser))
This successfully connects to a repl and I can execute arbitrary code (i.e. (+ 1 1)) but I still can’t access any context
#2022-03-2619:45barrell(not sure if it’s a red herring though)#2022-03-2619:53barrellHmm it seems proc-id is actually the same for both repl-runtimes so I’m connecting to the same instance. Can’t figure out how to print the runtime-id (it is not returned from repl-runtimes)#2022-03-2619:56barrellahaaa so client-id is the runtime-id (small numeric number). Was able to get it working with:
(->> (shadow.cljs.devtools.api/repl-runtimes :browser)
       (last)
       :client-id
       (hash-map :runtime-id)
       (shadow.cljs.devtools.api/repl :browser)))
With this and inspect shadow-cljs is unstoppable!
#2022-03-2620:36thhellerhehe yeah this API went through some unfortunate renaming cycles since I couldn't settle on a name#2022-03-2620:37thhellerthus the mix of :client-id and :runtime-id#2022-03-2706:56barrellNo worries, I figured I’d share my findings as I went along so this thread would have all the keywords I ran across 😂#2022-03-2700:11olafI’m getting this error when I add :deps {:aliases [:dev]} to my shadow conf. Running clj -M:dev has no error
Execution error (ClassCastException) at clojure.tools.cli/tokenize-args (cli.cljc:34).
class clojure.lang.ArraySeq cannot be cast to class java.lang.CharSequence (clojure.lang.ArraySeq is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')
#2022-03-2700:26olafP.S. I ported project.clj to deps.edn so maybe I missed something#2022-03-2702:27Drew VerleeWhat do you expect to happen? Do you want to point shadow at a deps file?#2022-03-2706:56thhellerwhat does your deps.edn look like? the error is in there#2022-03-2707:31olaf@U0DJ4T5U1 yes, to get path and deps here is my deps.edn
{:paths ["src/clj" "src/cljc" "src/cljs" "resources"]

 :deps
 {buddy/buddy-auth {:mvn/version "3.0.323"}
  buddy/buddy-core {:mvn/version "1.10.413"}
  buddy/buddy-hashers {:mvn/version "1.8.158"}
  buddy/buddy-sign {:mvn/version "3.4.333"}
  ch.qos.logback/logback-classic {:mvn/version "1.2.10"}
  cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
  clojure.java-time/clojure.java-time {:mvn/version "0.3.3"}
  com.cognitect/transit-clj {:mvn/version "1.0.329"}
  com.cognitect/transit-cljs {:mvn/version "0.8.269"}
  conman/conman {:mvn/version "0.9.3"}
  cprop/cprop {:mvn/version "0.1.19"}
  day8.re-frame/http-fx {:mvn/version "0.2.4"}
  expound/expound {:mvn/version "0.9.0"}
  funcool/struct {:mvn/version "1.4.0"}
  haslett/haslett {:mvn/version "0.1.7"}
  json-html/json-html {:mvn/version "0.4.7"}
  luminus-http-kit/luminus-http-kit {:mvn/version "0.1.9"}
  luminus-migrations/luminus-migrations {:mvn/version "0.7.1"}
  luminus-transit/luminus-transit {:mvn/version "0.1.5"}
  luminus/ring-ttl-session {:mvn/version "0.3.3"}
  markdown-clj/markdown-clj {:mvn/version "1.10.8"}
  metosin/muuntaja {:mvn/version "0.6.8"}
  metosin/reitit {:mvn/version "0.5.15"}
  metosin/ring-http-response {:mvn/version "0.9.3"}
  mount/mount {:mvn/version "0.1.16"}
  nrepl/nrepl {:mvn/version "0.9.0"}
  org.babashka/sci {:mvn/version "0.3.3"}
  org.clojure/clojure {:mvn/version "1.10.3"}
  org.clojure/clojurescript {:mvn/version "1.11.4"}
  org.clojure/core.async {:mvn/version "1.5.648"}
  org.clojure/tools.cli {:mvn/version "1.0.206"}
  org.clojure/tools.logging {:mvn/version "1.2.4"}
  org.postgresql/postgresql {:mvn/version "42.3.2"}
  org.webjars.npm/bulma {:mvn/version "0.9.3"}
  org.webjars.npm/material-icons {:mvn/version "1.0.0"}
  org.webjars/webjars-locator {:mvn/version "0.42"}
  re-frame/re-frame {:mvn/version "1.2.0"}
  reagent/reagent {:mvn/version "1.1.0"}
  ring-webjars/ring-webjars {:mvn/version "0.2.0"}
  ring/ring-core {:mvn/version "1.9.5"}
  ring/ring-defaults {:mvn/version "0.3.3"}
  selmer/selmer {:mvn/version "1.12.50"}
  thheller/shadow-cljs {:mvn/version "2.17.8"}}

 :aliases
 {:dev
  {:jvm-opts ["-Dconf=dev-config.edn"]
   :extra-paths ["env/dev/clj" "env/dev/cljs" "env/dev/resources" "test/cljs"]
   :extra-deps {binaryage/devtools {:mvn/version "1.0.5"}
                cider/piggieback {:mvn/version "0.5.3"}
                org.clojure/tools.namespace {:mvn/version "1.2.0"}
                prone/prone {:mvn/version "2021-04-23"}
                re-frisk-remote/re-frisk-remote {:mvn/version "1.5.2"}
                ring/ring-devel {:mvn/version "1.9.5"}
                ring/ring-mock {:mvn/version "0.4.0"}}
   :main-opts ["-m" "user"]}

  :test
  {:jvm-opts ["-Dconf=test-config.edn"]
   :extra-paths ["test"]
   :extra-deps {pjstadig/humane-test-output {:mvn/version "0.11.0"}}}

   ;; Linter
  :eastwood
  {:main-opts ["-m" "eastwood.lint"
                 ;; Any Eastwood options can be passed here as edn:
               {}]
   :extra-deps {jonase/eastwood {:mvn/version "1.2.3"}}}}}
#2022-03-2710:23thhellernot sure. this is a problem with the tools.deps setup and not related to shadow-cljs. maybe try updating tools.deps or so.#2022-03-2710:24thhellerI'm guessing the problem is within the :dev alias having :main-opts#2022-03-2710:24thhellersince shadow-cljs will append its own arguments there it likely just conflicts#2022-03-2710:24thhellermight be fine if you remove that#2022-03-2710:59olafyes, was :main-opts , removed and is working fine, but I cannot load the clojure user namespace anymore. do you have any idea how to specify it into deps or shadow-dev?#2022-03-2711:02thhellerwhat does load the clojure user namespace mean to you? it'll always be "loaded" when it is on the classpath#2022-03-2711:02thhellerbut the -main function doesn't run if you mean that#2022-03-2711:03thhelleryou can just run clj -M:dev and run shadow-cljs in embedded mode from that https://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2022-03-2711:04thhelleror you create a separate alias to launch your backend server and run shadow-cljs separately (which I recommend)#2022-03-2711:05olafokay, another alias. thanks for your help!#2022-03-2719:55barrellI upgraded to the latest cljs and added a web worker over the weekend. Now when I open a release build, I’m getting an error that it cannot connect to ws://<domain>:9630. I’m tried deleting the build directory and re-releasing without running the watch command but I’m still getting ws/REPL/UI code. Is this a known issue? The only references I have to any shadow modules in my codebase are shadow.loader to load static files, those calls have not changed Full error: websocket.cljs:12 Mixed Content: The page at 'https://<domain>/pixi' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://<domain>:9630/api/remote-relay?server-token=c17d72ac-00fb-482a-8eb5-3ac7c88e9fba'. This request has been blocked; this endpoint must be available over WSS.#2022-03-2719:56thhellera release build will never connect to :9630? are you maybe loading an outdated file?#2022-03-2719:57barrellI removed the entire build directory and recreated it with release#2022-03-2719:57thhellerthat doesn't necessarily mean anything#2022-03-2719:57thhelleryou could have a bad cache#2022-03-2719:57thhellera bad service worker#2022-03-2719:57thhelleror something along those lines#2022-03-2719:58thhellerdon't know anything about what you are building but the ws connection to :9630 is for the development websocket#2022-03-2719:58thhellerit is not part of a release build unless you manually made it so?
#2022-03-2719:59barrellhm I can remove the shadow-cljs cache, what do you mean a bad service worker though?#2022-03-2719:59thhellerdo you have a service worker?#2022-03-2720:00barrellyes, I just added one so it sounds topical 😂#2022-03-2720:00thhellerservice worker#2022-03-2720:00thhellernot web worker#2022-03-2720:00thhellersignificant difference and totally different#2022-03-2720:00thhellerif you don't know what a service worker is you probably do not have one?#2022-03-2720:01barrellhaha probably not#2022-03-2720:01thhellerthe thing you start with (js/Worker. ...) is webworker. that is fine and not related.#2022-03-2720:01barrellI have always known web workers as service workers I guess#2022-03-2720:02barrellbut no I don’t have two different worker types#2022-03-2720:02thhellerdo you manually require any of the shadow.cljs.devtools namespaces in your code somewhere? or in your build config?#2022-03-2720:02barrellnope, that was one of the firs tthings I checked#2022-03-2720:02thhellerok then it shouldn't try to connect anywhere#2022-03-2720:02thhellerthen just make sure you are actually loading the files you think you are loading#2022-03-2720:02barrellI am deploying a new build after removing the cache#2022-03-2720:02barrellsorry I did not think to check that#2022-03-2720:02thhellerits common that people don't notice they still load files from an old directory or something#2022-03-2720:04thhellereasy test is actually deleting all the files and not rebuilding it#2022-03-2720:04thhellerif you still get JS errors you have some old files somewhere 😛#2022-03-2720:05barrellstill having JS errors#2022-03-2720:05barrellstrange#2022-03-2720:06barrellI will hunt them down I guess ¯\(ツ)/¯#2022-03-2720:06barrellno idea where to start but I’ll make do haha (other than all the places I’ve already destroyed)#2022-03-2720:06barrellthanks for the responses#2022-03-2813:31raymcdermott
DOMException: The operation is insecure.
The above error occurred when loading "shadow.cljs.devtools.client.browser.js". 
#2022-03-2813:32raymcdermottThis message is from an app in the browser built with release app#2022-03-2813:34raymcdermottAny idea why this is being included in the build?#2022-03-2816:06thheller@raymcdermott unless you are including it manually somehow this should not be part of a release build. neither should a file of that name? you sure you are loading the release build files?#2022-03-2908:45raymcdermottIt was a caching problem. Sorry.#2022-03-2816:07thhellerrelease builds only have one file per module, not one file per namespace. unless this is a :npm-module build?#2022-03-2816:25Pavel KlavíkHi, I am trying to get my project working on MacOS and I have discovered the following strange behaviour. When I connect to Shadow-cljs nREPL and switch to the browser target, I can run (js/console.log "Test") fine, but when running (js/alert "Test"), I get the following error: Execution error (ReferenceError) at (<cljs repl>:1). alert is not defined => :repl/exception! Similarly for js/document and others.#2022-03-2816:27thhellerdo you use a web worker? you might be connected to the worker in that case?#2022-03-2816:29Pavel Klavíkyes, I am running some web workers#2022-03-2816:30thhelleryou can see the runtime ids listed at http://localhost:9630/runtimes#2022-03-2816:31thhellerand pick which one to connect to via (shadow/repl :the-build-id {:runtime-id that-id-number})#2022-03-2816:33Pavel Klavíkyes, this works fine#2022-03-2816:33Pavel Klavíkany way to set up the default runtime-id?#2022-03-2816:34thhellerno, other than either picking the first or last connected#2022-03-2816:34thhellerdefaults to picking the first one connected and staying with that#2022-03-2816:34Pavel Klavíkcan I list all build ids in REPL?#2022-03-2816:35Pavel Klavíkruntime-ids#2022-03-2816:35thheller(shadow/repl-runtimes :the-build-id)#2022-03-2816:36Pavel Klavíkok, cool, I can write some wrapper for that which will connect me to the correct REPL#2022-03-2816:36Pavel Klavíkplus it is useful to be able to search this when running in multiple browsers, etc.#2022-03-2816:36Pavel Klavíkthanks#2022-03-2819:12borkdudeWhat target is recommended when you want to build a chrome extension? I'm trying with browser but I got:
if (!doc) {
    throw new Error("browser bootstrap used in incorrect target");
  }
#2022-03-2819:13thheller:target :chrome-extension I guess#2022-03-2819:13thhelleror maybe nowadays :target :esm is better#2022-03-2819:13thhellerhaven't looked at browser extensions for many years now. dunno what that looks like now#2022-03-2819:15borkdudeI have tried both already. :esm gives me "cannot import module" or something and :chrome-extension gives me a "Cannot find manifest.edn" stacktrace in the console.#2022-03-2819:16thhellerthat is not enough information to figure out the context of those errors#2022-03-2819:16borkdudeagreed#2022-03-2819:17borkdudeThe ESM route I've already read some things about, it consists of workarounds, but I think that because the compiled .js loads other .js files makes it more complicated. I could just work with optimizations simple maybe. The other one, I'll reproduce now.#2022-03-2819:18borkdude(here is some background on the ESM stuff: https://medium.com/front-end-weekly/es6-modules-in-chrome-extensions-an-introduction-313b3fce955b)#2022-03-2819:19borkdudeI'll post a stacktrace of :chrome-extension in a thread here.#2022-03-2819:19borkdude
[:modules] Configuring build.
[:modules] Build failure:
FileNotFoundException: manifest.edn (No such file or directory)
	java.io.FileInputStream.open0 (FileInputStream.java:-2)
	java.io.FileInputStream.open (FileInputStream.java:219)
	java.io.FileInputStream.<init> (FileInputStream.java:157)
	 (io.clj:229)
	 (io.clj:229)
	 (io.clj:69)
	 (io.clj:165)
	 (io.clj:165)
	 (io.clj:69)
	 (io.clj:102)
	 (io.clj:86)
	clojure.core/apply (core.clj:669)
	clojure.core/slurp (core.clj:7009)
	clojure.core/slurp (core.clj:7009)
	shadow.build.targets.chrome-extension/configure (chrome_extension.clj:59)
	shadow.build.targets.chrome-extension/configure (chrome_extension.clj:48)
	shadow.build.targets.chrome-extension/process (chrome_extension.clj:310)
	shadow.build.targets.chrome-extension/process (chrome_extension.clj:305)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--14625 (build.clj:161)
	shadow.build/process-stage (build.clj:158)
	shadow.build/process-stage (build.clj:150)
	shadow.build/configure (build.clj:389)
	shadow.build/configure (build.clj:274)
	shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:205)
	shadow.cljs.devtools.server.worker.impl/build-configure (impl.clj:156)
	shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:571)
	shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:565)
	shadow.cljs.devtools.server.util/server-thread/fn--15932/fn--15933/fn--15941 (util.clj:269)
	shadow.cljs.devtools.server.util/server-thread/fn--15932/fn--15933 (util.clj:268)
	shadow.cljs.devtools.server.util/server-thread/fn--15932 (util.clj:241)
	java.lang.Thread.run (Thread.java:829)
#2022-03-2819:19borkdudeConfiguration:#2022-03-2819:19borkdude
{:deps true
 :dev-http {7778 ["classpath:public"]}
 :builds
 {:modules
  {:js-options {;; don't bundle any npm libs
                :js-provider :import}
   :compiler-options {:infer-externs :auto}
   :target :chrome-extension
   :output-dir "resources/public/js"
   :modules
   {:nrepl_extension {:init-fn nrepl-extension.core/init}
    }
   :build-hooks [(shadow.cljs.build-report/hook
                  {:output-to "report.html"})
                 ]}}}
#2022-03-2819:22thhelleruhm that looks like you took a :esm config and just changed :target#2022-03-2819:22thhellerthats not how that works#2022-03-2819:22thhellerhttps://github.com/thheller/shadow-cljs/issues/279#2022-03-2819:22thhellerthere are no docs but that issue has all the info you should need#2022-03-2819:23thhellerthere is also a sample manifest.edn it is looking for#2022-03-2819:24borkdude> thats not how that works Oops sorry, I kind of relied on the spec checking that shadow-cljs does in various other places :)#2022-03-2819:24thhellerbtw :compiler-options {:infer-externs :auto} has been the default for quite some time now. you never need to set it.#2022-03-2819:25thhelleralso the build-report hook won't work either#2022-03-2819:25borkdudethat's all fine with me, I just started with an ESM build I already had#2022-03-2819:25thhellerhttps://github.com/thheller/shadow-cljs/blob/051b5ecc7d701ef45b3bbc839685ac6ea03d4ad7/shadow-cljs.edn#L117-L125#2022-03-2819:26thhellerhttps://github.com/thheller/shadow-cljs/tree/master/packages/chrome-ext#2022-03-2819:26thheller4 years ago .. so I don't expect chrome to still accept this at all#2022-03-2819:26borkdude:)#2022-03-2819:26borkdudethanks, I'll check it out#2022-03-2819:27borkdudehere seems to be a newer example: https://github.com/binaryage/chromex/blob/master/examples/shadow/shadow-cljs.edn#2022-03-2819:29borkdudewhich is a sign that apparently it still worked in 2020 I mean :)#2022-03-2819:30thhellerwell the shadow-cljs side didn't change, so that'll work 😉#2022-03-2819:30thhellerbut I believe chrome has a new manifest version that is apparantly different but I didn't look at that at all yet#2022-03-2819:30borkdudeyes, they have v3 now :/#2022-03-2819:31borkdudeI'll try optimizations simple with esm first...#2022-03-2819:31thhellerhttps://github.com/thheller/shadow-cljs/issues/902#2022-03-2819:31borkdudesince I already noticed some deprecation warnings with a v2 extension I wrote in JS once :(#2022-03-2819:32borkdudeI can live with no REPL to get this bootstrapped. I'm developing an nREPL server in the browser...#2022-03-2819:32thhellernrepl server in the browser?#2022-03-2819:34borkdudeyeah, it's an experiment for now#2022-03-2819:35borkdudeso I need to open a tcp port in the browser and the only way seems to make an extension#2022-03-2905:38thhellerI just looked over some of the docs of the chrome extension stuff#2022-03-2905:39thheller:target :esm is absolutely the way to go now and is fully supported. just may need to set "type":"module" in some places apparently#2022-03-2905:40thhellerthe article you linked is from Dec 27, 2017 so not accurate anymore#2022-03-2905:41thhellerit should also properly support modules loading other modules so all the extra hacks :chrome-extension did to sometimes create standalone files should not be needed anymore#2022-03-2905:42thhellerjust content-scripts still seem to be a bit more limited, although might just work too#2022-03-2906:32thhellertcp server support however seems to be deprecated and removed soon#2022-03-2910:01borkdude@U05224H0W I will try to get back on the ESM track, but I haven't seen an up to date example with a service_worker .js script that directly works as an ES6 module. Have you?#2022-03-2910:01borkdude"type": "module" isn't supported as part of the v3 manifest, it says unknown key#2022-03-2910:03borkdudeAh:
"background": { "service_worker": "bg.js", "type": "module" },
#2022-03-2911:15borkdudeGot a basic setup working now#2022-03-2911:16borkdudeThey have a tcpserver example here: https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/apps/samples/tcpserver#2022-03-2911:17borkdudestill manifest v2, so yes, this might soon disappear :/#2022-03-2917:53thhellerhttps://developer.chrome.com/docs/extensions/reference/sockets_tcpServer/#2022-03-2917:53thheller> This API is part of the deprecated Chrome Apps platform. Learn more about migrating your app.#2022-03-2919:50borkdudeYes, I've already abandoned the whole idea#2022-03-2919:50borkdudeThanks#2022-05-2013:28pinkfrogYup. Looks like the case:#2022-05-2013:29pinkfrogChrome web store does not allow publish manifest v2 extension from early this year.#2022-05-2013:29pinkfrog@U04V15CAJ How’s your progress on your chrome extension?#2022-05-2013:29borkdude@UGC0NEP4Y I stepped away from that since extensions do not allow you to open TCP ports. I solved my problem in a different way that doesn't require an extension#2022-03-2908:50Gleb PosobinIs there a way to make :advanced release mode deterministic? Mozilla's extension store is asking for a source that produces the minified build that I have supplied, but I can't provide it as the output of the release :advanced build is different on every run (without changing the source code). Even putting it in a docker container hasn't helped.#2022-03-2917:50thhellerunfortunately not possible. builds in general are not deterministic#2022-03-2917:56thhellerI guess a simple build could be somewhat deterministic if you remove all threading and always start with a fresh JVM#2022-03-2923:02Gleb PosobinSad. Just curious: what's the source of nondeterminism here? Does it help in some way somewhere?#2022-03-3004:50Gleb PosobinApparently closure compiler was striving to be deterministic in 2010: https://groups.google.com/g/closure-compiler-discuss/c/9pJ-tuGtnvM Though I guess now it is not. I wonder what has changed.#2022-03-3006:06thhellerhmm maybe the closure compiler is? haven't tried in a long time. the cljs compiler isn't though#2022-03-3006:06thhellerit uses (gensym) from clojure a whole lot. which uses an increasing integer to make the symbols unique. so some# becomes some_1234 or so#2022-03-3006:07thhellerwhen you add threads to the mix the way this increases is not determinisitic#2022-03-3006:08thhelleryou can set :compiler-options {:parallel-build false} in your build config to turn off multithread during compilation#2022-03-3006:09thhellermaybe if you run everything in a container then the setup is similar enough to be deterministic?#2022-03-2913:04Ted CiafardiniAnyone know how to properly get rid of this error message? I’ve tried a few things, like setting jvm-opts to ["--engine.WarnInterpreterOnly=false"] in my shadow-cljs.edn
shadow-cljs - config: /Users/esciaf/Projects/full-stack/shadow-cljs.edn
[To redirect Truffle log output to a file use one of the following options:
* '--log.file=<path>' if the option is passed using a guest language launcher.
* '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
* Configure logging using the polyglot embedding API.]
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
The guest application code will therefore be executed in interpreted mode only.
Execution only in interpreted mode will strongly impact the guest application performance.
For more information on using GraalVM see .
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
#2022-03-2913:11Ted CiafardiniRealizing maybe I didn’t give the full context of this stituation…. This happens when I run shadow-cljs watch blogg and my shadow-cljs.edn looks like this:
{:source-paths ["src/cljs"]
 :nrepl {:port 9888}
 :dependencies [[cider/cider-nrepl "0.21.0"]
                [cljs-ajax "0.8.0"]
                [reagent "1.0.0-alpha2"]
                [re-frame "1.3.0-rc3"]
                [binaryage/devtools "1.0.4"]]
 :builds {:blogg {:target :browser
                  :compiler-options {:output-feature-set :es6}
                  :output-dir "resources/public/js"
                  :asset-path "/js"
                  :modules {:main {:init-fn blogg.core/init}}
                  :devtools {:http-root "resources/public"
                             :http-port 4888}}}}
#2022-03-2913:29Karol WójcikCan confirm the same issue.#2022-03-2917:49thheller["--engine.WarnInterpreterOnly=false"] should be `["-Dpolyglot.engine.WarnInterpreterOnly =false"]`#2022-03-2917:49thheller-D sets properties#2022-03-2917:49thhelleryou can just ignore this though. it'll be gone soon#2022-03-2917:50Ted Ciafardinithanks!#2022-03-2916:59lambdamHello everyone, Is there something similar to deps.edn extra-paths for shadow-cljs.edn's :build field. (I wish to separate some paths for Node.js back and browser front)#2022-03-2917:29neuralAs far i know dependencies goes only in :source-paths. Check section 5.2 of shadow manual! https://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies#2022-03-2917:48thheller@dam just keep all source-paths all the time. sources that are not required in a build are not included, so it doesn't hurt to have them all available#2022-03-2917:49lambdam@thheller wonderful. Thanks.#2022-03-2922:05mauricio.szaboAnybody using the react-native target of Shadow-CLJS? I'm seeing no filename or row at any stacktrace when it gets printed at the bundler. Is it normal? All is see is something like:
ERROR  Warning: blahblahblah for example
    in Pressable
    in Button (created by example.code/SomeElement)
    in RCTView (at View.js:32)
    in View (created by example.code/SomeElement)
    in RCTView (at View.js:32)
   ...
#2022-03-2922:36lambdamAnother question. I try to configure the hot code reload on Node.js, but the behavior seems weird : • When launching the project, none of my functions seems to be executed on the REPL. • After configuring the project following the documentation (https://shadow-cljs.github.io/docs/UsersGuide.html#NodeHotCodeReload) the hooks do not seem to be called on file saving and new definitions of vars aren't considered when executing them. Did I miss something? Thanks#2022-03-3006:04thheller@dam which :target?#2022-03-3006:44lambdamNode.js. My intent is to set up a reloaded workflow, as I would with integrant or juxt/clip on the JVM. Is it common to use those libraries on Node.js/shadow-cljs projects ? By the way, we're aiming using a Lambda service (Scaleway for the time being) with Node.js runtime.#2022-03-3007:26thheller@dam which shadow-cljs :target in your build config https://shadow-cljs.github.io/docs/UsersGuide.html#target-node :node-script or :node-library?#2022-03-3007:27lambdamAh sorry. :node-script#2022-03-3007:29thhellerthen the REPL should work fine. the docs have an example for hot-reload#2022-03-3007:54lambdamYes. I copied/pasted it and it doesn't reload the code. I'm using Calva on VSCode. I declared the build like so :
{...
 :builds
 {:back-dev {:target :node-script
             :main myproject.back.core/back-main
             :output-dir "build/back"
             :output-to "build/back/main.js"}
  ...}}
Then I run the jack-in command which runs npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :back-dev Then I'm asked to choose a "Project type" (all :builds entries are present). I select shadow-cljs. Then I'm asked to "select builds to start". I choose only :back-dev Then I'm asked to "select which build to connect to". I have all builds as options plus node-repl and browser-repl. When I select :back-dev, I get a No available JS runtime. When I select node-repl, I can evaluate my code but the hot reloading as describe in the documentation doesn't work. I tried all options : inline ^:dev/before-load and ns ^:dev/always or in the config file. with :autoload set to true. I can't see any callbacks executed nor new définitions containing new values. Do you think that it might be a Calva problem or a shadow configuration problem on my side? Thanks a lot.
#2022-03-3009:03thhellerif you pick node-repl that is a purely standalone REPL. it does not do hot reloading and is not coupled to your build#2022-03-3009:03thhellerif you pick :back-dev that is your project. you just actually need to run it to get a REPL#2022-03-3009:03thhellerso node build/back/main.js in another terminal or so#2022-03-3013:41lambdamAll riiight. Thanks a lot. I found the entry in the documentation that refers to this. https://shadow-cljs.github.io/docs/UsersGuide.html#_start_the_repl Adding the information that you gave me to point #2 would help I think. I didn't find any repo for the documentation. I can take time to contribute with a PR if there is any.#2022-03-3013:42lambdamThanks again !#2022-03-3007:32thhellerreloaded workflow in general is a bit trickier since everything is async. but should be fine. don't think its common to use integrant for CLJS, don't think I know anyone that does#2022-03-3007:33thhellermost people tend to use clojure on the server side#2022-03-3007:44olafHow I can resolve a npm library inside a macro? I’m writing a macro like this one inside a .cljc file
(ns kol.macros
  #?(:cljs
     (:require-macros [kol.macros :refer [deftheme]])
     (:require ["@codemirror/view" :refer [EditorView]])))

(defmacro deftheme [name theme]
  #?(:cljs
     `(def ~name
        (.theme EditorView (clj->js ~theme)))
     :clj nil))

(comment
  (macroexpand
   '(deftheme darko {:.cm-content {:caret-color "cursor"}}))
and is expanded like this
(def darko (.theme kol.macros/EditorView (kol.macros/clj->js {:.cm-content {:caret-color "cursor"}})))
but instead of resolving EditorView as kol.macros/EditorView I need to point to the npm library
#2022-03-3008:00lambdam@U01UYD2CL10 macros are never executed on cljs side so the conditional inside doesn't make sense (as far as I know) You could try to include the symbol as is. Try this:
#?(:clj
   (defmacro deftheme [name theme]
     `(def ~name
        (.theme ~'EditorView (clj->js ~theme))))
#2022-03-3008:28olafThanks @dam but is not working as expected#2022-03-3009:05thhelleryou could just make this a function
(def darko (theme {:.cm-content {:caret-color "cursor"}}))
#2022-03-3009:06thhellera macro can't access JS deps directly but you can make a helper function in the kol.macros ns that does the above basically. ie. create a helper function that calls the npm dep#2022-03-3009:06thhelleryou can also reach into the analyzer to get the JS dep alias but that is not recommended#2022-03-3009:32olafI made a simple function create-theme , thanks!#2022-03-3007:59dergutemoritzHi! Is there a way to pass args to the main of a :node-test build (which has :autorun true) when watching it? What I would like to do is run only a subset of the tests on rebuild which would be possible by passing a --test option to the default main. Alternative solutions welcome, too, of course 🙏#2022-03-3009:07thheller@dergutemoritz that is not supported no. you can always run the tests in the REPL#2022-03-3107:04dergutemoritzThanks! What would be the recommended way of doing that? It seems like :node-test doesn't support connecting a REPL so I would have to have an equivalent :node-library build for that purpose, right? If so, what's the recommended way of running tests from the REPL then? Just invoke shadow.test.node/main like the :node-test runner does?#2022-03-3107:18thhellernpx shadow-cljs node-repl#2022-03-3107:18thheller
cljs.user=> (require 'cljs.test)
nil
cljs.user=> (require 'test.js-interop-test)
nil
> (cljs.test/run-tests 'test.js-interop-test)

Testing test.js-interop-test

Ran 2 tests containing 9 assertions.
0 failures, 0 errors.
nil
cljs.user=>
#2022-03-3107:26dergutemoritzHmm right, the only drawback being that it can't focus on just a single test. I know I can invoke test vars directly for this (unless fixtures are involved which isn't the case here), but that rids me of the nice test summary 😢 But oh well, never mind, good enough. Thanks#2022-03-3107:31thhellereverything is possible. just might require writing the function to do what you want. nothing special about any of this.#2022-03-3107:47dergutemoritzoh yes, I just looked at the implementation of shadow.test.node/main and found shadow.test/run-test-vars which does the trick but weirdly the REPL process terminates after invoking it#2022-03-3107:47dergutemoritzwait now it doesn't happen anymore#2022-03-3107:47dergutemoritzmaybe it was borked somehow#2022-03-3107:48dergutemoritzexcellent, thanks for the encouragement 😄#2022-03-3107:51thhellerdon't load shadow.test.node. shadow.test is fine but the shadow.test.node is for the test runner which will exit after running#2022-03-3108:05dergutemoritzAh right, I had that loaded before. Thanks for clearing up that mystery, too 🙂#2022-04-0102:27mauricio.szaboI honestly just preload the test namespace (using the :preloads key under :devtools) and write/run my tests under the same target of my app :D#2022-03-3021:03David PhamDumb question, but is it possible to create modules from webpack while we use the :js-options {:js-provider :external} options?#2022-03-3021:05thhellerdefine "create modules from webpack". you mean code-split the dependencies? then the answer is no. :modules you can use just fine#2022-03-3021:09David PhamThanks a lot for the swift answer. exactly code split deps 🙂 The reason I am asking this is because the @react-pdf/render package requires some wasm code and it makes my whole nice code splitting useless since I am forced to use webpack xD#2022-03-3021:09David PhamI guess it is what they call a trade-off decision 🙂#2022-03-3021:13thhellerI have some ideas on how to make this work but they are all theoretical and I don't have enough time currently to figure it out#2022-03-3021:13thhellermaybe someday 😛#2022-03-3107:04dergutemoritzThanks! What would be the recommended way of doing that? It seems like :node-test doesn't support connecting a REPL so I would have to have an equivalent :node-library build for that purpose, right? If so, what's the recommended way of running tests from the REPL then? Just invoke shadow.test.node/main like the :node-test runner does?#2022-03-3104:51arohnerIs detecting and hot reloading node_modules supported? If not, is there a way to trigger a reload if I can tell shadow that a node_module changed?#2022-03-3105:10thheller@arohner touch node_modules/that-package/package.json will trigger a reload of that-package. well at least a recompile, hot reload is not really supported given how commonjs works#2022-03-3113:04pez@thheller shadow-cljs does not recompile macros in required files when loading .cljs files. Is this on purpose or to be considered a bug?#2022-03-3115:23thhellermacro reloading works just fine. if you have a reproducible example of unexpected behavior I'm happy to take a look#2022-03-3115:24pezHere's a repo that a colleague of mine created: https://github.com/sam-pitch/macro_example#2022-03-3115:25pezI first thought it was a Calva issue, but then I can repro it using shadow only. https://github.com/sam-pitch/macro_example/issues/1#2022-03-3115:25thhellerthat is what this is for https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-03-3115:26thhellerif you just slurp some stuff shadow-cljs can't know that this file is part of compilation#2022-03-3115:26thhelleras such it doesn't invalidate the cache and keeps using the old value#2022-03-3115:26thhelleryou can either use the method described above#2022-03-3115:26thhelleror turn off caching#2022-03-3115:27pezThanks. I'll forward the solution you provided. Sounds like exactly what he wants.#2022-03-3115:29pezDo you know why loading the example.cljc file in the ClojureScript REPL bypasses the cache?#2022-03-3115:29pez(Only out of my curiosity)#2022-03-3115:45thhellerload-file does exactly what it says. it loads the file, without considering any cache.#2022-03-3115:47pezMakes sense. Thanks!#2022-03-3118:11isakIs there a way to get Cursive to send forms to a node-repl? I'm getting the "Cannot load ClojureScript form into Clojure REPL" if I connect with the Clojure REPL setup.#2022-03-3118:17isakOh, I think I found it: https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive#2022-03-3118:30thhelleryeah, just run (shadow/node-repl) in the Cursive CLJ REPL#2022-03-3122:25isakWhat does the word optimized mean here in the build-report?#2022-04-0105:52thhellersize of the source file after optimizations. ie. how much is left over.#2022-04-0105:53thhellercan't show gzipped size since its not easy to tell how much a thing contributes to overall gzip size#2022-04-0105:53thhellerbut yes, raw bytes before gzip#2022-04-0114:25isakok makes sense, thanks#2022-03-3122:25isakDCE'ed, but before gzip?#2022-04-0101:36chromalchemyCan I run a cljs repl on target :npm-module ? Also, If I run shadow-cljs watch :code, get server + nrepl port, connect to it (in cursive, ,via port), run (shadow/repl :code) I get No available JS runtime. Any not sure how to procede. Here is my shadow-cljs.end
{:source-paths ["src"]
 :dependencies
   [[binaryage/devtools "1.0.5"]]

 :builds
   {:code
    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]}}}
#2022-04-0105:54thheller:npm-module can in theory have a REPL but it depends on how and where you are including the code. if another tools processes it too much it won't work. eg. webpack can work but also can break horribly 😛#2022-04-0105:55thhellerfor it to load you need to set a proper :runtime :browser or :runtime :node in the build config#2022-04-0105:55thhellerand then include the devtools client ns from JS so if (process.env.NODE_ENV === "development") { require("shadow-cljs/shadow.cljs.devtools.client.browser") } or so#2022-04-0102:30mauricio.szabo@thheller any tips on hacking shadow-cljs? I'm feeling bad only asking/reporting issues and I want to know how could I try to fix them too 🙂#2022-04-0105:56thhellerthats kind of too general. what do you intend to work on? its just a clojure project like any other clojure project 😛#2022-04-0106:02thhellerI usually add the shadow-cljs src/main path to a project I'm working on. ie. keep the regular dependency and then just override it with local sources. then just poke at it from the REPL.#2022-04-0106:03thhellersimilar to working on shadow-cljs directly#2022-04-0121:26mauricio.szaboYes, I think the idea of adding src/main path could work 🙂. My problem is with react-native builds, somehow I see no stacktrace at all (only the munged function name). I was thinking if I could debug it and at least know what's wrong#2022-04-0121:28thhellerdefine no stacktrace at all. like what is the error?#2022-04-0200:22mauricio.szaboIt's this error: https://clojurians.slack.com/archives/C6N245JGG/p1648591534372839#2022-04-0200:22mauricio.szaboThe stacktrace appears, but no file (not even the JS one) or line number#2022-04-0206:01thhellerthis is not an error from shadow-cljs and nothing you do to shadow-cljs will change this error message?#2022-04-0217:55mauricio.szaboIt's not an error from shadow-cljs - it's just that when I use shadow-cljs with react native, and an error occurs on my code, I don't see the ClojureScript nor the Javascript (compiled) file, regardless of source-maps is disabled or enabled...#2022-04-0217:56mauricio.szaboSo I've been thinking if I could debug this issue somehow#2022-04-0218:15thhellerhmm yeah dunno what your plan is. so can't provide tips. but there is nothing in shadow-cljs producing this stacktrace format. that is all in react-native/metro#2022-04-0218:15thhellermaybe you can just try/catch this error in your code somewhere so you can get to it before metro mangles it?#2022-04-0315:35mauricio.szaboYeah, that's what I did: I did a (try (my-code) (catch :default e) (println (-stack e)), and indeed the filename and row are missing#2022-04-0406:19thhelleroh well I just remembered that metro didn't support merging input source maps a very long time ago. maybe it still doesn't? I don't really keep up to date with what react-native is doing. maybe something in that changed so that you now get no trace at all rather than a trace back to the JS?#2022-04-0110:49Joshua SmockIs there a way to get the current build state from a channel or some other async mechanism when running a build using (devtools.api/watch target {:autobuild false}) and (devtools.api/watch-compile! target)? At the moment I’m using the build history coming from the server instance ref (`(get @(:state-ref (:build-history @devtools.server.runtime/instance-ref)) target)`) but if it’s possible to get it via a channel that would be nicer. I tried to use the :channels :output channel coming from the worker state ref but subscribing to that seemed to cause some issues#2022-04-0115:56thhellerwhat do you intend to do with this state? makes it easier to give suggestions on how to get it 😛#2022-04-0413:24Joshua SmockI need to know what the latest status that isn’t :compiling is so I can see if the build succeeded or failed programmatically#2022-04-0416:06thhellersee where?#2022-04-0418:20Joshua SmockI want to know if a build has succeeded or failed when run in watch mode, and I need to query for the status programmatically. The way described at the start works but I saw there are also async channels, so I wonder if I should use the method described there or if there is another way#2022-04-0418:21thhellerit would really help to know WHERE you want to know it? like what kind of tool? the info is all available but without knowing a WHERE I cannot give a suggestions of which method to use#2022-04-0418:21thhellerdo you want to know it on the client side? do you want to know it in the JVM running shadow-cljs? do you want to know it over nrepl?#2022-04-0418:22Joshua SmockIn the JVM, with a running server using the devtools server #2022-04-0418:23thhellerso you are running it in embedded mode? via a user.clj or so? or is that one started just via shadow-cljs server or shadow-cljs watch ..?#2022-04-0418:25Joshua SmockI guess so, I'm running it by calling devtools.server/start! and then api/watch :target-name#2022-04-0418:29thhellerok, (sys-bus/sub (:system-bus @shadow.cljs.devtools.server.runtime/instance-ref) :shadow.cljs.model/worker-broadcast your-channel)#2022-04-0418:29thhellersys-bus being shadow.cljs.devtools.server.system-bus#2022-04-0418:29thhelleryour-channel being a core.async channel you create and read from. or close when done#2022-04-0418:30thheller:shadow.cljs.model/worker-broadcast listens to all build workers#2022-04-0418:30thheller[:shadow.cljs.model/worker-output build-id] instead would just be the output for the specified build#2022-04-0418:30thhellermessages are the same#2022-04-0418:32Joshua SmockGreat, thanks! #2022-04-0520:19Norman KabirI'd like to include non-cljs files in my project (e.g. markdown (.md) and data (.dat)) that are copied as is from src. I found this but the files themselves are not copied into the target folder. Is it possible to configure non-cljs files to be watched and copied as raw text? https://clojureverse.org/t/best-practices-for-importing-raw-text-files-into-clojurescript-projects/2569#2022-04-0520:39isakI think I know what Thomas will say since I've asked a similar question: No, and that is probably out of scope for shadow-cljs. But if you need to do this, you can accomplish it by just creating a script that manually starts the builds, and then also does the other file watching you require. You can do this by creating a script like: dev.clj:
(ns dev
  (:require
   [shadow.cljs.devtools.api :as shadow]))

(defn setup
  {:shadow/requires-server true}
  []
  ;; Start your other watchers here, using libraries like juxt dirwatch
  (shadow/watch :front))
Then just run
yarn shadow-cljs run dev/setup
Instead of shadow-cljs watch.
#2022-04-0521:22Norman KabirI thought I was missing something because copying html is supported (on a file-by-file basis). Thank you for your suggestion! I cobbled together a package.json solution using • https://www.npmjs.com/package/copy-and-watchhttps://www.npmjs.com/package/concurrently#2022-04-0521:28isakOk 👍. I did it the script way because I didn't want to inflict more process starting on my co-workers.#2022-04-0616:43Norman KabirYour solution is definitely more elegant.#2022-04-0523:13Richard BowenHey is there a specific way to pull in this function as shown in the example: https://www.npmjs.com/package/copy-to-clipboard. I've tried ["copy-to-clipboard" :refer [copy]] but I get the following error:
Uncaught TypeError: module$node_modules$copy_to_clipboard$index.copy is not a function
    at eval (effects.cljs:66:5)
    at re_frame$fx$do_fx_after (fx.cljc:59:23)
    at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:70:6)
    at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:108:24)
    at Object.re_frame$interceptor$execute [as execute] (interceptor.cljc:201:8)
    at Object.re_frame$events$handle [as handle] (events.cljc:65:14)
    at Object.eval [as re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1] (router.cljc:179:10)
    at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198:44)
    at eval (router.cljc:146:64)
    at Object.eval [as re_frame$router$IEventQueue$_fsm_trigger$arity$3]
I've also tried ["copy-to-clipboard" :as copy] which seems more like what is shown in the example. But it doesn't seem to work and returns no errors.
#2022-04-0523:16Richard BowenOk, :as does the trick.#2022-04-0611:21oddsorHello! I’ve been testing shadow-cljs and bumped into a similar issue reported by others with not being able to import css-modules (npm-libraries that basically just wrap css-files). To work around the issue I went with a solution suggested in this thread with creating a separate js-bundle that only contains the module containing css which is then prebuilt with webpack: https://clojurians.slack.com/archives/C6N245JGG/p1603638343132300 Is creating a separate bundle still close to the “best practise” for getting around this problem?#2022-04-0611:23thhellerhard to say. some css-modules are precompiled so the code has foo.css require but also a foo.css.js file exists. those should work fine#2022-04-0611:23thhellerif the .js files don't exist you only option is going with webpack yes#2022-04-0611:51oddsorCool, thanks! I was testing a design system that had react components and styles as separate libraries, so the css-one seems to only contain styles. So I went the “dual bundle”-route 😊#2022-04-0611:52thhellerI hope you mean the optjon #2 described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#2022-04-0612:09oddsorSort of! Since I’m only hacking to improve my Clojurescripting at the moment I just used Webpack to build a js-file with only one import (the css) and reference that in index.html. I guess you could call it a bastardized version of option 2 🙈#2022-04-0612:10thhelleras long as it only is css thats fine#2022-04-0612:11thhellerif you add js you may end up duplicating stuff though#2022-04-0612:14oddsorRight, I’ll go with option 2 for real if I get beyond the hacking stage with this. Thanks for the info!#2022-04-0617:46oddsorWhelp, I couldn’t stop thinking about this so I ended up doing it the “correct way” and it worked surprisingly well! Now I have shadow-cljs watching with
npx shadow-cljs watch app
and webpack watching with
npx webpack watch
Very cool! :thumbsup: One thing I did try to probe the limitations is to comment out and re-add a js-library, which rebuilds the target js-file and in turn causes webpack to rebuild the “lib-file”. I get the impression hot reloading doesn’t work in that case? Or is there some magic that can be applied to fix even that scenario?
#2022-04-0617:57oddsorOh well, I’m mostly wondering for sake of curiosity, but since the js-libraries won’t change often this works damn great 👏#2022-04-0618:14thhelleryeah, cannot hot reload the webpack output#2022-04-0612:39wombawombaI'm using lazy loading for Reagent components as described in https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html, and for some reason it works in Firefox but not in Chromium. My code is as follows:
(ns website.my-component)

(defn <my-component>
  []
  [:div "Hello world!"])

(ns website.core
  (:require ["react" :as react]
            [shadow.lazy :as lazy]
            [reagent.core]
            [reagent.dom]))

(def *<my-component>
  (lazy/loadable website.my-component/<my-component>))

(defn <app-root>
  []
  [:> react/Suspense {:fallback (reagent.core/as-element [:div "Loading..."])}
   [:>
    (if (lazy/ready? *<my-component>)
      (reagent.core/reactify-component (fn [& _] [@*<my-component>]))
      (react/lazy
       #(do (prn "loading step 1")
            (-> (lazy/load *<my-component>)
                (.then (fn [_<elem>]
                         (prn "loading step 2")
                         #js {:default (reagent.core/as-element
                                        (fn [& _]
                                          (prn "loading step 3")
                                          [@*<my-component>]))}))))))]])
(defn init-app!
  []
  (reagent.dom/render [<app-root>] (.getElementById js/document "app")))
Firefox prints both "loading step n" statements, whereas Chromium only prints "loading step 1". No errors are logged to the console in either case. Any idea what's wrong?
#2022-04-0612:41thhellermuch easier to answer with the full code#2022-04-0612:48wombawomba@thheller I edited the code. Does that help?#2022-04-0612:48thhellers/def?#2022-04-0612:48wombawombadef* 😉#2022-04-0612:49thhellerwhy not use the full setup from my example? actually using React.lazy I mean?#2022-04-0612:50wombawombahmm.. not sure I follow#2022-04-0612:50wombawombaI am using react/lazy just like in https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs#L16 if that's what you mean#2022-04-0612:51thhellernot quite#2022-04-0612:51thhellerthat needs to be a def. not something you recall on every render#2022-04-0612:51thhelleruse this part I mean https://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/util.cljs#L15#2022-04-0612:52thhellerpulling it into the render function doesn't work since that recreates it every time never allowing react.lazy to do what it does#2022-04-0612:52wombawombaah okay#2022-04-0612:53wombawombaperhaps it's getting garbage-collected in Chrome then?#2022-04-0612:53thhellerdunno. :default (reagent.core/as-element this also seems wrong#2022-04-0612:53thhellerdid you check the browser console for errors?#2022-04-0612:54wombawombayeah like I wrote, no errors#2022-04-0612:55wombawombaI'll try defing the react/lazy call and see if that resolves it#2022-04-0613:08wombawomba@thheller I changed the code to the following, but it didn't help:
(ns website.my-component)

(defn <my-component>
  []
  [:div "Hello world!"])

(ns website.core
  (:require ["react" :as react]
            [shadow.lazy :as lazy]
            [reagent.core]
            [reagent.dom]))

(def *<my-component>
  (lazy/loadable website.my-component/<my-component>))

(def lazy-component
  (react/lazy
   #(do (prn "loading step 1")
        (-> (lazy/load *<my-component>)
            (.then (fn [_]
                     (prn "loading step 2")
                     #js {:default (reagent.core/reactify-component
                                    (fn [& _]
                                      (prn "loading step 3")
                                      [:div "hello"]))}))))))

(defn <app-root>
  []
  [:> react/Suspense {:fallback (reagent.core/as-element [:div "Loading..."])}
   [:> lazy-component]])

(defn init-app!
  []
  (reagent.dom/render [<app-root>] (.getElementById js/document "app")))
#2022-04-0613:09wombawombaIt seems to me that the problem isn't really in this code, but somewhere else. In Firefox, the module JS gets loaded after the "loading step 1" printout, but in Chrome it's not loaded at all.#2022-04-0613:10thhellerwhy do you introduce all the extra stuff?#2022-04-0613:10wombawombasorry, what extra stuff?#2022-04-0613:10thheller(lazy/ready? *<my-component>)?#2022-04-0613:10thhellershould be just [:> lazy-component] nothing else#2022-04-0613:11wombawombaokay yeah sure#2022-04-0613:11wombawombathe point of that was to avoid calling react/lazy on every render#2022-04-0613:12wombawombanow that I moved react/lazy to a def I forgot to get rid of it#2022-04-0613:12thhellerthe entire point of react/lazy is to call it on every render#2022-04-0613:12wombawombaeither way, I got rid of it now and it didn't make a difference#2022-04-0613:12thhellerit handles the if stuff for you. so you are just repeating it, which is redundant#2022-04-0613:13wombawombaneat#2022-04-0613:13thhellertry to not use prn when debugging stuff#2022-04-0613:13thhellerjust use (js/console.log ...) instead. async printing is icky if you expect output to show up in the REPL#2022-04-0613:14wombawombaokay, sure#2022-04-0613:14wombawombathat doesn't make a difference in this case though#2022-04-0613:14thhellerthis is also not just using [:div "hello"] instead of the actual lazy component?#2022-04-0613:15wombawombayeah#2022-04-0613:15wombawombaI figured I'd eliminate the possibility that there was something wrong when the code was being rendered#2022-04-0613:17wombawombato be clear, this shows up as an empty single-page div with "Loading..." in Chrome, and "hello" in Firefox#2022-04-0613:19thhellerbut does it load the extra module with the component?#2022-04-0613:19wombawombait does not in Chrome#2022-04-0613:20wombawombain Firefox, it does#2022-04-0613:20thhellerdunno. if you want to setup a repo so I can check it out I can take a look#2022-04-0613:21wombawombasure#2022-04-0613:28pinkfrogOut of a sudden I am seeing this error, what does it mean?
error: Error: Unable to resolve module  from /Users/matthew/Drive/dev/mobile2/target/app/index.js:  could not be found within the project or in these directories:
  node_modules
> 1 | var $CLJS = global;
    |                    ^
  2 | var shadow$start = new Date().getTime();
  3 | var shadow$provide = global.shadow$provide = {};
  4 | var goog = global.goog = {};
#2022-04-0613:29thhellerthat is not a shadow-cljs error? where/when do you get that?#2022-04-0613:33pinkfroginside metro#2022-04-0613:33pinkfrogI am developing with react native.#2022-04-0613:33pinkfrogWhat does the error say? Is the global object missing or what else?#2022-04-0613:34thhellerI don't know. as I said this is not a shadow-cljs error. without more context I cannot guess further.#2022-04-0613:34pinkfrogIt’s a react-native project. The output is from metro bundler
#2022-04-0613:36thhelleryes, but under what circumstances? like what is the full log? what command did you run? what was the state of cljs compiliation at the time of that error#2022-04-0613:36thhellerthe source code it shows looks weird since there is no module lookup happening#2022-04-0613:36thhellerwhat is the build config?#2022-04-0613:37thhellermaybe just try restarting metro. I really don't know. I don't use react-native so my guesses are very limited.#2022-04-0613:42pinkfrogyeah. Thanks. I am gonna recreate the react project.#2022-04-0614:00wombawomba@thheller FYI I managed to get it working by restarting my computer, cleaning my browser cache, and deleting .shadow-cljs and all build files#2022-04-0614:00wombawombanot sure which one of those fixed it 🙂#2022-04-0614:00wombawombaapologies for wasting your time#2022-04-0614:02wombawomba(my hunch is that Chromium had somehow cached an old JS build file, that it wasn't letting go despite me hard refreshing the page)#2022-04-0614:03thhellerif you use the :dev-http server that can't happen since it sets the proper cache headers#2022-04-0614:03thhellerif you use any other webserver then sure that can happen (or a service worker)#2022-04-0614:05wombawombayeah, that's probably it#2022-04-0614:05wombawombaI'll double check my cache headers#2022-04-0614:46pinkfrogEvery time if a namespace mismatches, shadow will get stuck and stops compiling even if after I fixed the naming issue:#2022-04-0614:47pinkfrogI waited some more time and the build begins again.#2022-04-0614:47pinkfrogCan I tune the waiting time?#2022-04-0614:49thhellerwhich shadow-cljs version? that issue should have been fixed like 2 years ago#2022-04-0614:55pinkfrog{thheller/shadow-cljs$aot {:mvn/version “2.17.8”}#2022-04-0615:57thhellerthat should be fine. it should recompile fine when you just fix the error?#2022-04-0616:18pinkfrogWhat does SHADOW_ENV.evalLoad do?#2022-04-0616:18pinkfrogAlso, what does this line mean?
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
#2022-04-0616:20pinkfrogReason I asked this is, in my source code, if I replace the line
(defonce landing-bg (js/require (config/asset-path "landing-bg.jpg")))
with
(defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg"))
Then the
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
will be gone. In my code, config/asset-path is a macro. The output of (config/asset-path "landing-bg.jpg") is exactly “../../resources/assets/landing-bg.jpg”.
#2022-04-0616:23pinkfrogFurther more background on this, the react native require only supports literal strings and dynamic variables are not supported, (see https://reactnative.dev/docs/images#:~:text=In%20order%20for%20this%20to%20work%2C%20the%20image%20name%20in%20require%20has%20to%20be%20known%20statically). So I think I might go with macro so that it will be expanded to literal strings.#2022-04-0616:24pinkfrogHowever, the generated file missies the $CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); }; line compared to the case of a vanilla (defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg")) .#2022-04-0617:38thhellerjs/require must be a single simple string. macros are not supported there.#2022-04-0900:38pinkfrogSounds like a great feature to support macros.#2022-04-0900:39pinkfrogShadow is already expanding the macro, for example,
(defonce landing-bg (js/require (config/asset-path "landing-bg.jpg")))
gets converted to
(defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg"))
It’s just this piece is missing
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
#2022-04-0905:55thhellerI think (defasset landing-bg "landing-bg.jpg") is a macro you could write instead that just emits the (defonce landing-bg (js/require "../../resources/assets/landing-bg.jpg")) for you#2022-04-0905:55thhellerthat should work I think#2022-04-0906:41pinkfrog
(defonce landing-bg (js/require (my-macro "landing-bg.jpg")))
#2022-04-0906:41pinkfrogWhat full support of the above?#2022-04-0906:47thhelleras I said this is not currently supported#2022-04-0906:48thhellerthe compiler is looking for a call to js/require with a string argument. nothing else#2022-04-0906:48thhelleryou have a js/require with a macro argument (this is before expansion)#2022-04-0906:48thhellerso thats why it doesn't currently work#2022-04-0906:48thhellerin theory it could be made to work but currently it doesnt#2022-04-0906:49pinkfrogBy compiler, what do you mean? Are you referring to shadow, or metro?#2022-04-0906:49thhellerthe cljs compiler, with an extension part of shadow-cljs#2022-04-0906:50pinkfrogI see, so you were saying the extra creation of this line
$CLJS.shadow$js["../../resources/assets/landing-bg.jpg"] = function() { return require("../../resources/assets/landing-bg.jpg"); };
is not possible in the current cljs/shadow compiler.
#2022-04-0906:50pinkfrogWhich indeed is the case.#2022-04-0906:51thheller...#2022-04-0906:51thhellerthe compiler is looking for EXACTLY a call to js/require with a string argument#2022-04-0906:51thhellernot possible currently yes. could be made to work yes.#2022-04-0906:51pinkfrogThen what about the defasset macro?#2022-04-0906:52thhellerin theory that should be fine. can't guarantee and don't have time to try#2022-04-0906:52thhellerbut that expands to a js/require call with a string argument#2022-04-0906:52thhellerso in theory that should work#2022-04-0906:52pinkfrogI will have a try now.#2022-04-0907:28pinkfrogThat works. Thanks.#2022-04-0623:54agwhere can I find an offline version of the User Guide?#2022-04-0623:54thhellercurl -O #2022-04-0623:58agoh come on... you know what I meant.. 🙂 alright, I'll convert it myself#2022-04-0623:59thhelleryou can just clone this too https://github.com/shadow-cljs/shadow-cljs.github.io#2022-04-0700:00thhellerdocs/UsersGuide.html is the file#2022-04-0700:00agOh wait a minute, there's shadow-cljs GH org? I did not know that#2022-04-0700:01agwhoa, there's so much good stuff in there too#2022-04-0700:07avi👋 Does shadow require that “clojure tools” (i.e. the clojure script) be installed?#2022-04-0700:08aviAsking because I don’t see it listed in the docs, but…#2022-04-0700:08thhelleronly if you intend on using them. by default no.#2022-04-0700:08aviWhen I uninstall clojure tools and then try to compile my project with shadow, I get an error#2022-04-0700:08aviIs it maybe because my project is using deps.edn ?#2022-04-0700:09aviThe error:
throw er; // Unhandled 'error' event
      ^

Error: spawn clojure ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn clojure',
  path: 'clojure',
  spawnargs: [ '-M', '-m', 'shadow.cljs.devtools.cli', '--npm', 'server' ]
}

Node.js v17.8.0
#2022-04-0700:09thhellerif you set :deps in shadow-cljs.edn that tells shadow-cljs to use the clojure tool and deps.edn yes#2022-04-0700:09aviI see, ok, thanks!#2022-04-0700:09aviMaybe that should be added to the docs under the installation section which lists prerequisites?#2022-04-0700:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2022-04-0700:11thhellerit is listed in the docs. you chose to use it. nothing in shadow-cljs requires you to use it.#2022-04-0700:11aviAh I see that in there now#2022-04-0700:11aviYeah that’s good#2022-04-0700:11aviIt’s just… I didn’t realize this.#2022-04-0700:11aviPeople don’t always read the docs in a linear fashion#2022-04-0700:12aviIn my case I thought “I wonder if I can omit the installation of Clojure Tools in my CI/CD environment” — so I checked the prerequisites at the top of the docs in the installation section and it wasn’t listed there, so I figured it was safe to omit it.#2022-04-0700:12aviI’d be happy to submit a PR if you’d like#2022-04-0700:13thhelleragain .. not a prerequisite unless you specifically configure it to use those tools#2022-04-0700:13thhellerso listing it there would be wrong#2022-04-0700:14aviwell, ok, I would have listed it with a note that it’s only required if you’re using deps.edn, but ok, no worries, thank you!#2022-04-0708:18Fahd El MazouniHi ! is there a way to explicitly ignore specific warnings for specific namespaces without using warnings-as-errors?#2022-04-0714:52pinkfrogSuddenly I am seeing errors from shadow:
[2022-04-07 22:51:42.126 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(clojure.core/refer-clojure)", :ns app.wallet, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns app.wallet, :form (clojure.core/refer-clojure), :source "(clojure.core/refer-clojure)", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:502)
        shadow.cljs.repl/process-read-result (repl.clj:476)
        shadow.cljs.repl/process-input (repl.clj:661)
        shadow.cljs.repl/process-input (repl.clj:639)
        shadow.cljs.devtools.server.worker.impl/fn--14599 (impl.clj:698)
        shadow.cljs.devtools.server.worker.impl/fn--14599 (impl.clj:688)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--14273/fn--14274/fn--14282 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--14273/fn--14274 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--14273 (util.clj:241)
        java.lang.Thread.run (Thread.java:829)
Caused by:
ExceptionInfo ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form) {:rename-macros nil, :renames {}, :use-macros nil, :excludes #{}, :name app.wallet, :op :ns*, :env {:fn-scope [], :locals {}, :js-globals {console {:op :js-var, :name console, :ns js}, location {:op :js-var, :name location, :ns js}, escape {:op :js-var, :name escape, :ns js}, screen {:op :js-var, :name screen, :ns js}, global {:op :js-var, :name global, :ns js}, process {:op :js-var, :name process, :ns js}, require {:op :js-var, :name require, :ns js}, alert {:op :js-var, :name alert, :ns js}, history {:op :js-var, :name history, :ns js}, window {:op :js-var, :name window, :ns js}, module {:op :js-var, :name module, :ns js}, exports {:op :js-var, :name exports, :ns js}, document {:op :js-var, :name document, :ns js}, navigator {:op :js-var, :name navigator, :ns js}, unescape {:op :js-var, :name unescape, :ns js}}, :ns {:rename-macros nil, :renames {}, :meta {:file "app/wallet.cljs", :line 1, :column 5, :end-line 1, :end-column 15}, :ns-aliases {cljs.loader shadow.loader, react shadow.js.shim.module$react, clojure.pprint cljs.pprint, clojure.spec.alpha cljs.spec.alpha}, :use-macros nil, :excludes #{}, :shadow/js-access-properties #{"Text"}, :name app.wallet, :reader-aliases {}, :js-aliases {"react-native" shadow.js.shim.module$react_native}, :imports nil, :requires {cljs.core cljs.core, goog goog, shadow.js.shim.module$react_native shadow.js.shim.module$react_native, rn shadow.js.shim.module$react_native}, :seen #{:require}, :uses nil, :defs {wallet-tab {:protocol-inline nil, :meta {:file "app/wallet.cljs", :line 5, :column 7, :end-line 5, :end-column 17, :arglists (quote ([]))}, :name app.wallet/wallet-tab, :file "app/wallet.cljs", :end-column 17, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :variadic? false, :line 5, :ret-tag cljs.core/IVector, :end-line 5, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}}, :require-macros {cljs.core cljs.core}, :cljs.analyzer/constants {:seen #{:>}, :order [:>]}, :flags {:require #{}}, :js-deps {"react-native" {:as rn}}, :deps [goog cljs.core shadow.js.shim.module$react_native]}, :def-emits-var true, :shadow.build/mode :dev, :column 1, :shadow.build/tweaks false, :line 1, :shadow.build.compiler/repl-context true, :context :expr}, :imports nil, :requires nil, :uses nil, :reload {:use nil, :require nil, :use-macros nil, :require-macros nil}, :require-macros nil, :form (ns* (:refer-clojure)), :reloads {}, :deps []}
        shadow.build.compiler/post-analyze (compiler.clj:94)
        shadow.build.compiler/post-analyze (compiler.clj:89)
        shadow.build.compiler/analyze/fn--12392 (compiler.clj:265)
        shadow.build.compiler/analyze (compiler.clj:252)
        shadow.build.compiler/analyze (compiler.clj:211)
        shadow.cljs.repl/repl-compile/fn--14080/fn--14081 (repl.clj:441)
        shadow.cljs.repl/repl-compile/fn--14080 (repl.clj:414)
        shadow.cljs.repl/repl-compile (repl.clj:412)
        shadow.cljs.repl/repl-compile (repl.clj:409)
        shadow.cljs.repl/process-read-result (repl.clj:500)
        shadow.cljs.repl/process-read-result (repl.clj:476)
#2022-04-0714:53pinkfrogThe error is caused by eval a whole namespace in the cljs repl.#2022-04-0714:53pinkfrogI’d like to know what exactly the error is complaining about?#2022-04-0714:53pinkfrogThe relevant code is:
(ns app.wallet
  (:require
   ["react-native" :as rn]))

(defn wallet-tab
  []
  [:> rn/Text
   "Wallet"])

(comment
  (js/console.log "dasdf"))
#2022-04-0714:55pinkfrogI switched to another namespace, even eval a simple a namespace such as
(ns app.event)

(def initialize-app ::initialize-app)
(def set-active-view ::set-active-view)
will also result in the shadow error.
#2022-04-0715:39pinkfrogI asked in the #calva channel and turns out it is a regression of calva.#2022-04-0715:50pezEvaluating (refer-clojure) throws an error in shadow-cljs and also prints a huge map
{:rename-macros nil, :renames {}, :use-macros nil, :excludes #{}, :name calva.fmt.formatter, :op :ns*, :env {:fn-scope [], :locals {}, :js-globals {console {...
Is this a bug? It's fine evaluating that in a vanilla ClojureScript REPL.
#2022-04-0716:22pezHere's a full output log.#2022-04-0717:15thhelleryeah, its just not implemented yet#2022-04-0717:15thhellerto be perfectly honest I don't even know what refer-clojure is supposed to do 😛#2022-04-0717:39pezI was unaware of it until recently. Turns out that a lot of errors that we instruct Calva users to fix by loading the file is because we just do (in-ns …) and that switches to the namespace, but doesn't make Clojure core available. Then some while ago I read the in-ns info on this page a bit more carefully: https://clojure.org/guides/repl/navigating_namespaces#_switching_to_an_existing_namespace_with_in_ns#2022-04-0717:51thhellerwell thats specific to CLJ. CLJS works a bit different there#2022-04-0717:51thhellerin CLJ refere-clojure is just a function. in CLJS it technically doesn't even exist since it can't do what it does in CLJ#2022-04-0717:52thhellerso it is implemented as sort of a hack via a macro#2022-04-0718:08pezI actually don't know if the problem it solves for clj is there for cljs. I can test that. Hopefully I can skip calling it for cljs. But if not, it would be good to not have to check if it’s shadow-cljs or vanilla cljs. #2022-04-0719:11pezOK. So just confirmed what you probably knew, @U05224H0W: (refer-clojure) isn't needed in ClojureScript REPLs. So then I'll mainly skip that for cljs sessions and am good with that.#2022-04-0719:12thhellerwell technically it is still invalid to call in-ns before the ns exists. even in cljs#2022-04-0720:42pezIt doesn't seem to cause problems in practice, though? And that guide seems to be cool with it as long as we call refer-clojure.#2022-04-0720:50pezThat said. Maybe it is better to do something like (if (find-ns 'foo) (in-ns 'foo) (ns foo))?#2022-04-0717:34pesterhazyQuestion about reloading and component-local state. I've set up Shadow to reload my code using https://github.com/pesterhazy/shadow-jest/blob/tictactoe/src/main/tdd/main.cljs#L5, which works fine. However, I'm seeing that component-local state gets lost. My code uses React's useState (here's a https://github.com/pesterhazy/shadow-jest/blob/tictactoe/src/main/tdd/domain/board.cljs#L9 to the code). From reagent I'm used to defonce'd state atoms, which would preserve inputs. This is very useful because while debugging/applying styles I don't need to manually recreate state every time I change a file. Now after moving to modern React and useState, is there a way to both • rerender the components after reload to let the new code take effect and • preserve the component-local state?#2022-04-0717:49thhellerthis is not something shadow-cljs is involved in really. it is either react or reagent. they manage the state, shadow-cljs just calls a function#2022-04-0717:49thhellergenerally I would say that local state is always lost#2022-04-0717:50thhellerI don't know how react-refresh handles preserving useState but it seemed quite involved and required support from the compiler#2022-04-0717:58pesterhazyI didn't know about react-refresh, that's an interesting pointer, thanks!#2022-04-0718:06pesterhazyOh, as you say React Fast Refresh seems incredibly complicated, at least compared to what CLJS has had, basically, forever#2022-04-0718:06pesterhazyThe https://github.com/pmmmwh/react-refresh-webpack-plugin is still experimental#2022-04-0718:00pesterhazyI knew that my question wasn't strictly about shadow-cljs, but given that it does reloading so well this channel felt like a good place to ask#2022-04-0718:50thhellerwell yeah if you wanted something like react-refresh then shadow-cljs would need to get more involved. I can't really figure out what it would need to do though. likely some compiler modifications that would get icky 😛#2022-04-0804:01jimmyHelix already has support for react refresh. I've used it a lot and never had any troubles. https://github.com/lilactown/helix/blob/master/docs/experiments.md#fast-refresh#2022-04-0720:48pesterhazyI used another approach for now. I created a "playground" part of the app, which has data pre-filled in. So I can use that to edit styles#2022-04-0720:49pesterhazyThis kind of stuff mostly just worked with reagent/re-frame's global state atom. I didn't realize this was such a big advantage of the (otherwise icky) global var#2022-04-0720:50dpsuttonNot sure if you’ve looked into devcards. My favorite dev experience was using bruce’s test runner in one tab, the devcards in another tab, and the “real” tab in a third. Multiple entries on a build to enable all of this was a really great experience#2022-04-0720:52pesterhazyYeah, really love devcards as well. For now, I'm keeping it simple with a https://github.com/pesterhazy/shadow-jest/blob/tictactoe/src/main/tdd/main.cljs#L12#2022-04-0720:54pesterhazyWhile writing this I discovered that shadow-cljs's dev webserver uses a trick to serve index.html back to arbitrary urls but only when used as the entry point - not for images, css etc. I was confused as to how this could possibly work. Turns out it checks if "text/html" is https://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/main/shadow/http/push_state.clj#L12. Ingenious approach that I haven't seen elsewhere#2022-04-0720:55pesterhazyThe benefit is that you still get nice 404 if you mistype a jpg url in your code (whereas other popular ad-hoc webservers just blindly serve you index.html for any route that's not found)#2022-04-0804:01jimmyHelix already has support for react refresh. I've used it a lot and never had any troubles. https://github.com/lilactown/helix/blob/master/docs/experiments.md#fast-refresh#2022-04-0812:10pinkfrogIn the manual on compilation cache: https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache, it is said Namespaces that are known to include side-effecting macros can be blocked from caching. What is side-effecting macro and what bad outcome will happen if the namespace containing it is cached?#2022-04-0814:26thheller@i side-effect is everything where the macro generates different code for the same form depending on other factors. eg. touching files on disk, manually editing analyzer data, etc#2022-04-0814:27thhellerbad outcome is that you see stale compilation output. ie. not what you expecting, since it is caching data and not updating "properly" since it doesn't know about the external stuff#2022-04-0820:55rgmwe're developing a typescript+hooks component and planning to use it from cljs. Is there an example around of how to have typescript code participating in shadow's hot-reload? Right now we have /ts-dir and /cljs-dir. The /ts-dir is a webpack project that produces its js via npm run build. The /cljs-dir has a reference in its package.json dependencies as "my-ts-code": "../ts-dir". I'm re-building the typescript with a simple find src | entr npm run build in a separate terminal window. As it stands, I seem to have to restart shadow to get it to notice the new bundled JS from /ts-dir.#2022-04-0820:56thhellertouch can touch node_modules/my-ts-code/package.json to make shadow-cljs recompile it. hot-reload is very unlikely to work in that kind of setup though#2022-04-0821:01rgmthanks ... I'll give that a go and report back#2022-04-0821:02thhellernote that npm might make a copy of your code in node_modules instead of symlinking it#2022-04-0821:03rgmok ... I'll just figure out which thing I need to poke with touch#2022-04-0821:08rgmI can just touch another cljs component ns, and I'm not super concerned with "proper" hot reload (meaning browser app state is preserved) ... reloading everything would be fine since even that's an improvement over restarting the shadow watch process.#2022-04-0821:28rgmhm, nope, at least not on a Mac. npm i (with npm 8.5.0) in /cljs-dir just symlinks /ts-dir -> /cljs-dir/node_modules/my-ts-code and it doesn't look like shadow watching crosses the symlink. I tried manually setting up a copy in /cljs-dir/node_modules/my-ts-code and rsyncing but that seems to yank something important out from under shadow. Shadow notices, but I get a "can't find module" message. (I can do it again to get the exact phrasing ... forgot to copy it).#2022-04-0821:28thhellerinvidivual files in node_modules are not watched at all. only the package.json is checked. so thats why you touch it#2022-04-0821:29rgmright ... it just doesn't seem shadow notices a touch on the package.json on the far side of the symlink#2022-04-0821:30thhellerdo you judge that by checking a rebuild actually happens or whether the reload is working?#2022-04-0821:30thhellerit should trigger a compilation#2022-04-0821:31rgmoh wait it did trigger ... my mistake... but I got this#2022-04-0821:32rgmso to be clear: yes, shadow notices the touch through the symlink, but it gets confused#2022-04-0821:32thhellerhmm dunno that usually signals an internal error#2022-04-0821:32thhellerbut dunno what module is there?#2022-04-0821:32rgmmaybe I'll try a minimal repro#2022-04-0821:33rgmmight be something I'm doing wrong in code splitting, but other than this it seems to be working OK#2022-04-0900:45pinkfrogWhat’s the recommended way for default import? I remember previously there is a sync
(require [xxx :default foobar])
but looking at the manual again, it now becomes
(require ["xxx$default" :as foobar])
#2022-04-0905:51thheller$default is the recommended. :default was a shadow-cljs only addition that was not compatible with regular CLJS. the $default also works in regular CLJS#2022-04-1000:31pinkfrogIs the following foo and foo2 the same?
(ns app.style
  (:require
   ["twrnc" :rename {default foo}]
   ["twrnc$default" :as foo2]))
I tested they are the same, but not sure under what circumstance they will become different.
#2022-04-1005:48thhellerthey are the same yes#2022-04-1005:48thhelleralways#2022-04-0913:01pinkfrogHow shall I import this package? The runtime is react native. My code is
(ns app.style
  (:require
   ["twrnc" :as twrnc]
   ["twrnc$default" :as tw]))
Either twrnc or tw is nil.
#2022-04-0913:29pinkfrogTurns out the package app.style is not imported by other namespaces. And in turn, it is now bundled by metro.#2022-04-1002:38chromalchemyWhen I require clojure.string my bundle size my bundle size jumps up 2mb. Is that normal? ( :target :npm-module ,release build, then bundled w webpack 1.15.0 ) And the bundle.js is no longer minified.#2022-04-1003:27chromalchemyMy build report says the cljs should only be about 1mb I think something in cljs is tripping up the webpack build so it ceases to minify results? I do get a smaller bundle and minified bundle.js with only a few cljs test fns. Currently I am not requiring any cljs libs (only some js ones that reside in node_modules folder). And still getting large bundle.#2022-04-1005:51thheller@chromalchemy do you use the default :advanced optimizations or did you change it to :simple? do you do an actual shadow-cljs release build or just a webpack release build? did you configure webpack to inline source maps? many factors can lead to large builds, need more info to comment further.#2022-04-1013:41chromalchemyI tried turning off source maps by removing devtool: 'source-map' in webpack.conf.js. Also tried devtool: 'hidden-source-map'``. I am doing a shadow-cljs release code, then run the webpack release build. The cljs is compiled/minified. But something is keeping the webpack build from finishishing it’s process I think. Maybe too old a version of weback. But I have been reluctant to upgrade in fear of breaking legacy js code.#2022-04-1013:43chromalchemyShould i use :`:optimizations :advanced` explicitly?#2022-04-1013:44thhellerno, thats the default#2022-04-1013:46chromalchemyGoogling around I saw a hint that maybe ESLint errors are influencing webpack process… will have to test that.#2022-04-1013:47thhellerI really cannot comment on any of the webpack bits. you can easily check the size of the generated shadow-cljs output via the :output-dir. just make sure you ignore .map files#2022-04-1013:47thhellershould be reasonable and clojure.string definitely won't be contributing much overall#2022-04-1013:55chromalchemyIgnoring the cljs-runtime and node modules folders in output?#2022-04-1013:55thhelleruhm what are you outputting to?#2022-04-1013:56thhelleryou said this is a :npm-module build? it shouldn't have any of thsoe?#2022-04-1013:56chromalchemy:output-dir "node_modules/shadow-cljs"#2022-04-1013:57thhellerwell just temporarily change that to an empty folder#2022-04-1013:57thhellermakes it easier#2022-04-1013:57chromalchemyok#2022-04-1014:01chromalchemyMy code is only 120k! But what to the shims represent in terms of final bundle?#2022-04-1014:02thhellerbasically require("bigcommerce/stencil_utils")#2022-04-1014:02thhellerand require("jquery")#2022-04-1014:03thhellerie. your inclusion of the npm packages that webpack will provide#2022-04-1014:05chromalchemyinstead of ?
(:require
    ["@bigcommerce/stencil-utils" :as utils]
    ["jquery" :as jq]
    [clojure.string :as string])
#2022-04-1014:06thhellerwhat do you mean instead of?#2022-04-1014:06thhellerthose are responsible for creating the shims yes#2022-04-1014:06thhellerfor :npm-module builds shadow-cljs doesn't bundle any npm dependencies at all#2022-04-1014:06thhellerwebpack will do so when you run it through webpack#2022-04-1014:07thhellerotherwise you'd end up with them duplicated#2022-04-1014:08chromalchemyOk I think thats what I was trying to clarify. These js deps will not be included in the shadow-cljs output (just the shim reference)#2022-04-1014:08thhelleryes#2022-04-1014:09chromalchemyand I shouldnt need to do any $default stuff in the require?#2022-04-1014:09chromalchemyrelated, maybe.. Is this still the best way to require cljs code from js?
var clj = require("shadow-cljs/gbo.mycljs");
#2022-04-1014:10thhellerI don't understand what you are asking anymore. in the beginning this was about build size. now you are asking about the require?#2022-04-1014:10thhelleryes, this is the way you include this code in a webpack build.#2022-04-1014:11thhelleryou have the size of the CLJS code you include. if the webpack output is much larger then that is coming from your JS code and the included dependencies#2022-04-1014:11chromalchemySorry, you have helped me confirm that my shadow-cljs build size is indeed very reasonable.#2022-04-1014:13chromalchemyThanks! Just wanted to make sure I was calling it correctly.. one last question. I also have this in my js file, not sure where it came from. Do you recognize it? import { clj__GT_js } from 'shadow-cljs/cljs.core';#2022-04-1014:18chromalchemyAnd thank you for your help (and shadow-cljs). It’s pretty cool that I am able to surgically refactor functions into cljs inside this older theme code and it’s particular stack#2022-04-1014:21thhellerI don't know where it came from. I didn't write your JS code 😉#2022-04-1014:26chromalchemyTrue, must have been when I was trying to get cljs-devtools loading. (..never did get it working, but was able to get along pretty well with pprint)#2022-04-1014:27thhellerjust if (process.env.NODE_ENV === "development") { require("shadow-cljs/devtools.preload"); } in your JS might work#2022-04-1015:42Ho0manHi everyone, I wanted to use separate base_url addresses during dev and release. Is there any best practice to do that ? I found something https://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env but could not figure out how to access the set variable in the code Thanks a lot#2022-04-1015:42thhellerwhat is a base_url?#2022-04-1015:43Ho0manThe url that all the calls to the web API should be directed at, for instance.#2022-04-1015:44Ho0manin dev its "localhost:8280" or something but when releasing this should be ""#2022-04-1015:48thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2022-04-1015:48thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2022-04-1015:48thhellerthose are the relevant sections I guess#2022-04-1015:51thhelleror if you generate your HTML in some way just put the urls to use in there and get it at init time in your code#2022-04-1016:19Ho0manThanks @thheller#2022-04-1114:10pinkfrogI am running with the aot version, specifically
{thheller/shadow-cljs$aot {:mvn/version "2.18.0"}}
There is a warning: WARNING: shadow-cljs not installed in project.
#2022-04-1114:10pinkfrogHow can I disable it?#2022-04-1114:10pinkfrogThe command is npx shadow-cljs -d cider/cider-nrepl:0.27.4 watch :app #2022-04-1116:42thheller@i that warning is about the npm shadow-cljs package not being installed in the project. which you should definitely do when using npx. so just npm install shadow-cljs. not related to the aot version in any way.#2022-04-1210:44pinkfrog> which you should definitely do when using npx Why is it a necessity? The reason I use npx is that I do not need to install shadow.#2022-04-1210:44pinkfrogThe command works fine except the warning.#2022-04-1218:56thheller> The reason I use npx is that I do not need to install shadow#2022-04-1218:57thhellerthat makes no sense. if you use a tool you should install it. it also brings with it depenendencies that may be necessary. eg. for node-repl source maps and other stuff#2022-04-1604:45pinkfrogI did a fresh install on a debian system, and just run npx shadow-cljs. The prompted as in the first picture. I then checked the directory _npx, i found the source-map and other dependencies are all installed.#2022-04-1605:31thhelleryes, in a place where shadow-cljs will not find it.#2022-04-1605:37pinkfrogNot sure on the ‘will not found it’ part. Perform the following actions resulting the same directory layout.
mkdir -p test && cd test
npm install -D shadow-cljs
#2022-04-1605:38thhelleryes, not how that node_modules/shadow-cljs dir is part of your project test dir. and the above in somewhere outside the project dir#2022-04-1605:56pinkfrogNot sure what you are referring to. For the npx approach, it installs all the dependency. The only difference is, for the npx one, the shadow-cljs package is put in some-where/npx/modules, while the other approach installs shadow in $PROJ/nodemodules. Indeed the _npx/modules are outside the project path, but if it poses a problem, then its some erroneous logic of the library itself. For me, running npx shadow-cljs is all fine, except the shadow-cljs not installed in the project warning.#2022-04-1605:58thhellerok simple test. create a :node-script build to output to the out directory in the project directory. run node out/whatever.js#2022-04-1605:58thhellerit'll fail because it also cannot find files in .npx, just as shadow-cljs does not look in ~/.npx when compiling#2022-04-1605:59thhelleryes running via npx works. but this is not at all what this warning is about. it is about compilation and running outputs. NOT about running shadow-cljs itself#2022-04-1606:00thhellerif you don't like it or want to ignore me just bypass running shadow-cljs completely#2022-04-1606:01thhellerclj -A:dev -M -m shadow.cljs.devtools.cli watch app is similar to npx shadow-cljs watch app. only server mode is not supported. as described https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2022-04-1606:02thhellerthat way you won't get the warning#2022-04-1606:02thhellerof course your build outputs will still fail to run without the missing dependencies#2022-04-1117:49hairfireNoob question. Has anyone used sync-fetch from npm in a node.js app?#2022-04-1206:31orestisSince we finally dropped support for IE11, I updated our shadow-cljs output from :es5 to :es2018 -- I saw a very small change in the bundle size, I'm not sure why but I was expecting a bit more. Like, in our base bundle, we went from 279kb to 276kb gzip. Perhaps a total of another 5kb gzip across everything else. Not complaining, just curious if this is to be expected.#2022-04-1206:32thhellerthat entirely depends on how many polyfills you previously relied on. CLJS itself doesn't need any so nothing to save there. only affects npm packages basically and those can vary greatly#2022-04-1206:33thhellerbut yeah I'd say thats expected#2022-04-1206:33orestisYeah, of course we have removed our entire 50kb worth of polyfills, that was outside the CLJS bundle. I guess I thought that the output would use newer syntax which would be more compact.#2022-04-1206:33orestisIt's annoying that many npm modules do their own polyfills (it's visible even in the advanced optimisations).#2022-04-1206:35thhelleryep, can't do anything about those#2022-04-1210:05Franklinhey thheller 👋 I'm getting an error when I try to update shadow-cljs dependency in my project to v2.18.0 and to v2.17.0 and also to v2.16.0 in my project v2.15.0 seems to work ok. the error message is a bit verbose but I'll just paste it here#2022-04-1210:06Franklin
ExceptionInfo: failed to convert sources
	shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1953)
	shadow.build.closure/convert-sources-simple* (closure.clj:1940)
	shadow.build.closure/convert-sources-simple* (closure.clj:1818)
	shadow.build.closure/convert-sources-simple (closure.clj:2112)
	shadow.build.closure/convert-sources-simple (closure.clj:2064)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
	shadow.build.compiler/compile-all (compiler.clj:1463)
	shadow.build.compiler/compile-all (compiler.clj:1330)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:463)
	shadow.build/compile (build.clj:453)
	shadow.cljs.devtools.api/compile* (api.clj:296)
	shadow.cljs.devtools.api/compile* (api.clj:292)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

Unexpected variable layoutCssVars
  Node(NAME layoutCssVars): node_modules/react-data-grid/lib/bundle.js:652:4
    layoutCssVars,
  Parent(STRING_KEY layoutCssVars): node_modules/react-data-grid/lib/bundle.js:652:4
    layoutCssVars,

	com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2907)
	com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
	com.google.javascript.jscomp.NodeTraversal.traverseRoots (NodeTraversal.java:486)
	com.google.javascript.jscomp.NodeTraversal.access$400 (NodeTraversal.java:38)
	com.google.javascript.jscomp.NodeTraversal$Builder.traverseRoots (NodeTraversal.java:406)
	com.google.javascript.jscomp.VarCheck.process (VarCheck.java:154)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
	com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
	com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
	com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/convert-sources-simple*/fn--11356/fn--11357 (closure.clj:1943)
	shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1941)
	shadow.build.closure/convert-sources-simple* (closure.clj:1940)
	shadow.build.closure/convert-sources-simple* (closure.clj:1818)
	shadow.build.closure/convert-sources-simple (closure.clj:2112)
	shadow.build.closure/convert-sources-simple (closure.clj:2064)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
	shadow.build.compiler/compile-all (compiler.clj:1463)
	shadow.build.compiler/compile-all (compiler.clj:1330)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:463)
	shadow.build/compile (build.clj:453)
	shadow.cljs.devtools.api/compile* (api.clj:296)
	shadow.cljs.devtools.api/compile* (api.clj:292)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
Caused by:
IllegalStateException: Unexpected variable layoutCssVars
	com.google.javascript.jscomp.VarCheck.handleUndeclaredVariableRef (VarCheck.java:291)
	com.google.javascript.jscomp.VarCheck.checkName (VarCheck.java:213)
	com.google.javascript.jscomp.VarCheck.visit (VarCheck.java:173)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:856)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
	com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
	com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:984)
	com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:748)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:800)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
	com.google.javascript.jscomp.NodeTraversal.traverseRoots (NodeTraversal.java:482)
	com.google.javascript.jscomp.NodeTraversal.access$400 (NodeTraversal.java:38)
	com.google.javascript.jscomp.NodeTraversal$Builder.traverseRoots (NodeTraversal.java:406)
	com.google.javascript.jscomp.VarCheck.process (VarCheck.java:154)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:317)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:232)
	com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2592)
	com.google.javascript.jscomp.Compiler.lambda$stage2Passes$8 (Compiler.java:966)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:1014)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:963)
	com.google.javascript.jscomp.Compiler.compile (Compiler.java:846)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/convert-sources-simple*/fn--11356/fn--11357 (closure.clj:1943)
	shadow.build.closure/convert-sources-simple*/fn--11356 (closure.clj:1941)
	shadow.build.closure/convert-sources-simple* (closure.clj:1940)
	shadow.build.closure/convert-sources-simple* (closure.clj:1818)
	shadow.build.closure/convert-sources-simple (closure.clj:2112)
	shadow.build.closure/convert-sources-simple (closure.clj:2064)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
	shadow.build.compiler/compile-all (compiler.clj:1463)
	shadow.build.compiler/compile-all (compiler.clj:1330)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:463)
	shadow.build/compile (build.clj:453)
	shadow.cljs.devtools.api/compile* (api.clj:296)
	shadow.cljs.devtools.api/compile* (api.clj:292)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--15294--auto----15967 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)

error Command failed with exit code 1.
info Visit  for documentation about this command.
error Command failed with exit code 1.
info Visit  for documentation about this command.
#2022-04-1210:09FranklinI can share the contents of node_modules/react-data-grid/lib/bundle.js too if that's needed#2022-04-1211:01FranklinI'm using java 8#2022-04-1218:51thhellerthis is an error from the google closure compiler#2022-04-1218:52thhellerunfortunately nothing I can do to fix that#2022-04-1210:06Franklindo you know what the cause of the issue might be?#2022-04-1218:20LeifProbably a dumb question -- is there a way to recover after I type something syntactically invalid in a shadow-cljs REPL?
> (324234  ]
Failed to read: clojure.lang.ExceptionInfo: dummy.cljs [line 1, col 11] Unmatched delimiter ]. {:type :reader-exception, :ex-kind :reader-error, :file "dummy.cljs", :line 1, :col 11}
Whenever I mistype something, the REPL becomes unresponsive and I have to quit and restart it to continue.
#2022-04-1218:54thheller@leiferiksonventures looks like a bug. if you want you can open a github issue for this. can't promise I'll get to it before forgetting about it otherwise 😛#2022-04-1220:40tomc@thheller Are you aware of any reason the approach you used here: https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html would no longer work? I'm trying to figure out why lazy loading is not working for me.#2022-04-1302:52alexWe recently implemented lazy-loading using this as a resource - what issues are you experiencing with this approach?#2022-04-1304:04thhellerthis works just fine still? what is the problem you see?#2022-04-1314:04tomcThanks for the replies - the issue was on my end. I had mismatched versions of react and react-dom. d'oh#2022-04-1310:59olyHi is there a way to make shadow watch certain folders, I am finding the hot reload works for some files but not others, I am using local/repo in my deps files which may be related which uses relative paths. so my classpath looks like this ["src" "resources" "../../components/web-ui"] shadow does not detect changes in /web-ui with out a f5 refresh relativly new to shadow so this may be a simple answer 🙂#2022-04-1311:06olyOn save I do get the reload icon it seems like its just not rebuilding the files in web-ui folder#2022-04-1311:18olynever mind I forgot the ^:dev/after-load on the render call 😕#2022-04-1315:12Ted Ciafardinibeen there:sunflower:#2022-04-1320:10FlavaDaveI have an electron app built with shadow based on https://github.com/BTowersCoding/electron and can only seem to import modules from electron in my main process and not my renderer. in main i have ["electron" :refer (app BrowserWindow crashReporter dialog)] and everything in there works fine. But when I import in the renderer like ["electron" :refer (remote)] it always breaks. I tried looking at a bunch of different electron examples because i originally thought I was (and perhaps still am) miss-using the electron library but now I’m starting to wonder if my shadow configuration is messed up.#2022-04-1320:12FlavaDaveI referenced here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages and tried a few different ways of importing but was not successful#2022-04-1320:14FlavaDave
{:source-paths
 ["src"]

 :dev-http {8080 "resources/public/"}

 :dependencies
 [[reagent "1.1.0"]
  [re-frisk "1.5.2"]
  [re-frame "1.2.0"]
  [thheller/shadow-cljs "2.17.8"]]

 :builds {:main {:target    :node-script
                 :output-to "resources/main.js"
                 :main      app.main.core/main}

          :renderer {:target     :browser
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :devtools   {:watch-dir "resources/public"
                                  :preloads  [re-frisk.preload]}
                     :modules    {:renderer {:init-fn app.renderer.core/start!}}}}}
#2022-04-1405:03Fahd El MazouniHi ! This is an electron thing, you need to configure your window ( getting spawned in the main process ) to expose the node stuff, sorry I don't remember exactly what it was. I do remember that remote is deprecated though, so maybe try to use exposeinmainworld https://www.electronjs.org/docs/latest/api/context-bridge#2022-04-1405:50thhelleryeah, electron has changed a lot and most templates that exist have not been updated to how you are supposed to do things nowadays#2022-04-1417:24FlavaDaveThanks yall!#2022-04-1403:39orestisI've made a CLJS library that I distribute via deps.edn, and I now need to add a JS dependency to it. That is, you can't use the library unless you have in your local package.json a specific package. Is there any way to do that automatically, or do I just have to document it?#2022-04-1403:57Aronseems like you need to distribute package.json as well, why is that an issue?#2022-04-1404:03orestisThere is a package json in the library but it's not being picked up by the consuming project. #2022-04-1404:03orestisThe consuming project uses deps.edn + git sha, so that may be the issue. #2022-04-1404:06AronI am sorry, I got very confused now. Library needs js dependency but it's not being picked up by the consuming project?#2022-04-1404:06Aronmaybe more specifics would help:)#2022-04-1405:48thheller@orestis you can put a deps.cljs with {:npm-deps {"that-package" "version"}} on the classpath of the lib. that'll tell CLJS about the npm dependency and install it#2022-04-1406:09orestisHehe fair enough @Aron - reseda used to be pure CLJS, depending on React only but since any user of Reseda already has react there was no point in trying to install it. I've updated Reseda to be React 17/18 compatible and now it needs use-sync-external-store from npm. I will try what @thheller suggested and report back #2022-04-1417:21tughWe've just migrated our project from figwheel-main to shadow-cljs. We were using :css-dirs setting of figwheel-main for CSS hot reload but we don't have CSS hot reload with shadow-cljs now, probably due to incorrect config. We're not using the dev http server of shadow-cljs. We're serving our HTML/CSS/JS with the CLJ application. We get the updated css with page refresh but it doesn't hot reload. Below is our shadow-cljs config(truncated):
{:builds {:app {:target :browser
                :output-dir "frontend/public/js"
                :asset-path "/js"
                :devtools {:watch-dir "frontend/public"}}}}
And here is the directory structure of our codebase(truncated):
frontend/
└── public
 ├── css
 │ ├── main.css
 │ └── main.css.map
 └── js
 ├── app.js
 ├── app.js.map
 ├── cljs-runtime
 └── manifest.edn
resources/public/
├── css
│ ├── animations.less
│ ├── mixins.less
│ ├── variables.less
│ └── etc...
├── extra
├── fonts
├── img
└── js
frontend and resources dirs lives under the app dir on the same level and both of them are in the classpath. Another process automatically compiles less files under resources/public/css and outputs to frontend/public/css/main.css. Can you point out what is wrong with my config?
#2022-04-1417:33tughBTW, path to CSS file in link tag is absolute:
<link href="/css/main.css" rel="stylesheet preload" type="text/css"  as="style" />
#2022-04-1417:40thhellerlooks fine. note that :watch-dir currently only applies when the watch is started. so if you made adjustments while it was running they might not be active#2022-04-1417:40thhelleroh wait#2022-04-1417:41thhellerit needs to be rel="stylesheet". preload should be a separate tag? didn't even know you are allowed to combine them?#2022-04-1417:48tughOh, thank you! Removing preload fixed it. I'd never thought this was the problem#2022-04-1417:49tughI don't know if it is valid too. This code is older than me in the company and I don't know the reason why it is there#2022-04-1417:50thhelleryeah seems kinda redundant. I mean by the time the parser finds the tag it can load the css file directly. no need to first preload it?#2022-04-1418:12tughDecided to remove preload. Really appreciate the help! ✌️#2022-04-1421:51niquolaHi, i have multiple apps in project - can i compile them in parallel?#2022-04-1504:56thhelleryou can have multiple builds running at the same time yes. shadow-cljs watch app1 app2 app3 same for all other commands#2022-04-1504:57thhellerrelease will not be parallel, watch will be#2022-04-1505:52niquolaI mean releases - we have 6 apps from same source, it takes 10 min to build - want to speedup it#2022-04-1505:58thhellerI made the default sequential since parallel was overloading some systems#2022-04-1505:58thhelleryou can make your own release function and run them in parallel#2022-04-1505:58thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2022-04-1505:59thhellerso just a function (defn release [& args] (shadow/release! :foo) (shadow/release! :bar) ...)#2022-04-1505:59thhellerthat would be sequential#2022-04-1505:59thhelleryou can use (future (shadow/release ...)) to start it in a thread#2022-04-1505:59thhelleror use a thread pool#2022-04-1522:38niquolaThank you!#2022-04-1422:14Jorge BarretoAs a proof of concept, I'm trying to import a CLJS component into a CRA React app. My shadow-cljs config:
{:source-paths ["src"]
 :dependencies []
 :builds {:code {:target :npm-module
                 :output-dir "node_modules/shadow-cljs"
                 :entries [app]}}}
src/app.cljs:
(ns app)
(defn ^:export hello [] "Hello World!")
src/App.js:
import { hello } from "shadow-cljs/app";
but i get the following error: Uncaught ReferenceError: process is not defined the culprit appears to be the compiled cljs_env.js:
var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;
any insight into what i might be missing here?
#2022-04-1422:22rayatInteresting! As a hack, you could use one those CRA-patching libs to add a Define plugin to webpack, with process defined with whatever you need it to be, this will at least let it compile Though I'm very curious as to why it's not already defined and what that means for the evaluation of cljs_env.js#2022-04-1422:35Jorge BarretoI could probably use craco to accomplish something like that, but I assume shadow-cljs needs values that are populated in there? It looks to be defined in cljs.core.async.js:
var process = (function (p__14390){...
#2022-04-1422:35Jorge BarretoI agree, it's curious that it's not already defined#2022-04-1500:07rayatYes, craco was what I was referring to. This is most certainly not at all a fix, but perhaps an unblocker to investigate or debugger further, apologize if I implied otherwise, and also apologies if this was a useless suggestion! Please do update this with anything you find, would love to know wtf is going on. Is that cljs_env.js file imported or loaded in particular way? I am not sure how it is able to depend on a global reference that is undefined at runtime. I have not personally looked at shadow's source code. However, I wonder if: 1. This has something to do closure compiler/libs bespoke module loading system interacting weirdly with cra/webpack 2. This has something to do with your setup in particular. Is the example code you've posted actually the minimum reproducible source code - ie, what you've seen this issue come up in?#2022-04-1501:58Jorge BarretoI can try craco next -- I'm certainly at a wall otherwise. But no apologies needed! 🙂 I'm very happy to receive all the help I can get. I have been suspecting that the interaction with webpack is somehow to blame here.. As far as the code, the only thing I haven't shared is the results of yarn create react-app. I can put together a small minimal reproduction and commit it somewhere if it would be of interest. To answer your first question, I have been going on https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module. In part they read: > If you use the default :output-dir of "node_modules/shadow-cljs" you can access the declared namespaces by using require("shadow-cljs/demo.foo") in JS. I'm not quite doing that, as I have import statements instead. Doing import { hello } from "shadow-cljs/app" leads to the error because the compiled app file has a require('cljs_env.js')#2022-04-1501:58Jorge BarretoFrankly, I can tell I'm going about this all wrong but I'm not yet sure on how to right it#2022-04-1504:54thheller:target :npm-module by default assumes a node runtime. so add :runtime :browser to the build config. that should remove that reference to process#2022-04-1512:47Jorge BarretoI tried that as well, unfortunately the reference to process is still there#2022-04-1512:58Jorge BarretoI have a minimal reproduction here: https://github.com/jorge-barreto/cljs-in-cra.git The build config now reads:
;; ;; shadow-cljs configuration
{:source-paths ["src"]
 :dependencies []
 :builds {:code {:target :npm-module
                 :runtime :browser
                 :output-dir "node_modules/shadow-cljs"
                 :entries []}}}
If there is any further insight on what is going on here, I'd really appreciate it 🙃
#2022-04-1514:34thhellerFWIW :target :esm is probably a better choice these days regarding interop. https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-04-1514:35thhellerI'll check your repro later though#2022-04-1514:35thhellerif you are integrating with CRA add :js-options {:js-provider :import} to the build config#2022-04-1515:16Jorge BarretoThere's no rush! I really appreciate the time. I tried adding the :js-provider to no avail. I'll try :target :esm next#2022-04-1515:20thheller:js-provider was meant for :target :esm sorry#2022-04-1516:40Jorge BarretoOk, I can confirm that :target :esm works, but only when run as shadow-cljs release . build and watch produce many build errors for webpack. I'll push soon to a branch on the repo#2022-04-1516:40thhellerwhat kind of error?#2022-04-1516:42Jorge Barretocouple thousand lines across many files, looking like this:
src/generated/cljs-runtime/cljs.core.async.impl.buffers.js
  Line 2:1:      'goog' is not defined  no-undef
  Line 3:1:      'cljs' is not defined  no-undef
#2022-04-1516:44thhellerhmm odd. I'll take a look if you push that to the repo#2022-04-1516:50Jorge Barretoyou can take a look in the target-esm-dev branch: git clone -b target-esm-dev #2022-04-1516:50thhellerugh just checked. guess webpack got a lot stricter since the last time I tested this#2022-04-1516:51thhellerit doesn't recognize that these are things on globalThis and actually do exist#2022-04-1516:51thhellerthis looks like a linter error though. maybe that can be turned off?#2022-04-1516:51thhellerthe code is actually fine#2022-04-1516:58Jorge Barretoyes! nice catch -- that works#2022-04-1517:00Jorge Barretoi updated the repo w/ the working code. i really appreciate the help with this!#2022-06-3017:42jdfhi. I’m following along on this thread since I’m trying to embed an existing cljs app into a react container. I’m successful in releasing the app with :target :esm but I get errors when I try to import it in the react app. I’ve tried including :js-options {:js-provider :import} but the compilation process fails when I do claiming the namespace react is not available when required by reagent/core.cljs. Have any of you encountered a similar error by any chance?#2022-04-1603:18pinkfrogI am following the tutorial here: https://clojurescript.org/guides/promise-interop#using-promises-with-core-async. Failed with
TypeError: undefined is not an object (evaluating 'cljs.core.async.interop._LT_p_BANG_')
Example code:
(ns simple.example
  (:require
   [cljs.core.async :refer [go]]
   [cljs.core.async.interop :refer [<p!]]))

(go
  (println (<p! (js/Promise.resolve 42))))
#2022-04-1605:29thheller@i can't say anything without more context. what build :target is this? any compilation errors? any console warnings/errors besides that one?#2022-04-1605:32pinkfrogdeps.edn: https://bpa.st/FNZA shadowcljs.edn: https://bpa.st/NNSA the target is react-native#2022-04-1605:33pinkfrogcljs -Stree output: https://bpa.st/GOWQ#2022-04-1605:40thhellerlooks fine as far as I can tell so far#2022-04-1605:43thhellerthe error is saying that it tried to call <p! as a function. but it is a macro, so that does not work. dunno why. need more info and reproducible example would help
#2022-04-1605:44pinkfrogI am going to make one.#2022-04-1606:20pinkfrogHere is the mininal example:https://github.com/introom/rn-example/blob/main/readme.md#2022-04-1606:20pinkfrogbulk of the code is from the react-native template#2022-04-1606:31thheller> in the repl, load the app.example namespace#2022-04-1606:32thhellerthe react-native is rather limited in what it can do#2022-04-1606:32thhellerjust require the namespace properly in your build?#2022-04-1606:34pinkfrog> just require the namespace properly in your build? What do you mean?#2022-04-1606:34thhellerapp.example is not required anywhere, so it is not part of the build#2022-04-1606:34thhellerrequire it in app.main and it will be compiled properly#2022-04-1606:35pinkfrogGood point! Let me try.#2022-04-1606:38pinkfrogThat works!#2022-04-1606:38pinkfrogTrapped by this several times (in similar issues).#2022-04-1606:38pinkfrogPackages are bundled as they are needed.#2022-04-1606:38pinkfrog@U2FRKM4TW FYI, the issue was the interop package not bundled.#2022-04-1606:39thhellerthats because all code compiled needs to go shadow-cljs -> metro -> runtime. in case of the REPL it directly goes shadow-cljs -> runtime since there is no way to tell metro to compile a small piece of code#2022-04-1606:40thhellerso it fails quite often. although technically this should work in this case given that no new npm dependencies are involved#2022-04-1606:40thhellerbut still the code transformations metro does will be missing so there is no way to tell how these variants of code interact#2022-04-1606:41thhellerif someone wants to dig into this feel free to ask questions. I already fail at getting react-native running on windows and I don't have any interest to waste any more time on this#2022-04-1605:29thhellerdo you use deps.edn or project.clj? which core.async version?#2022-04-1606:09Chris McCormickIn nbb I have to require es6 modules like this: ["passport$default" :as passport] and in shadow-cljs i have to require them like this: ["passport" :as passport] - I am employing https://github.com/chr15m/sitefox/blob/main/src/sitefox/deps.cljc to make my library work under both nbb and shadow-cljs. Is there no way that I can reconcile these with a single require syntax? Is there any chance shadow-cljs would support "passport$default" in the future?#2022-04-1606:11thhellerthis is strictly speaking not related to shadow-cljs, it is related to what kind of output you use. if you use :target :esm the $default will just work (as that is also what nbb is using)#2022-04-1606:12thhellerif you however use :node-script or :node-library or :npm-module those all output commonjs, where require is just different#2022-04-1606:12thhelleroh and you need to run node in module mode too of course when using :esm#2022-04-1606:12Chris McCormickah ok. i remember now you told me this already. i don't really want to force :target :esm on consumers of the library so i'm at a bit of a loss what to do.#2022-04-1606:13thhellerthats not something shadow-cljs can do anything about. it is unfortunately not a clean transition but that is node for ya 😉#2022-04-1606:16Chris McCormickcoming from php and (even worse) python, node is suprisingly smooth 😁 - python is the absolute worst for jarring incompatible language changes.#2022-04-1606:21Chris McCormickcan i just clarify from what you wrote above that :target :node-script can't use the $default syntax and :target :esm has to be used instead if i want that?#2022-04-1606:24Chris McCormicki'm just thinking if i should just switch to :esm and change my npm create projects to run the server in esm mode instead. :thinking_face:#2022-04-1606:26thheller$default is not related to esm or build target in any way. it is syntax sugar, nothing else. think of foo$default translating to require("foo").default or in the case of ESM and using import it translates directly to import default from "foo"#2022-04-1606:27thhellerESM has this special case for default imports that commonjs didn't have. that is the crux of the problem. something new introduced and used by ESM packages#2022-04-1606:28Chris McCormickunderstood. so theoretically would it be possible for the cljs compiler to ignore $default - i.e. replace it with whitespace, when used in commonjs mode? or is that just a terrible idea?#2022-04-1606:31thhellersounds like a bad idea to me#2022-04-1720:09lilactownis there a way to add custom CSS to the browser REPL and have it hot reload?#2022-04-1720:11victorbThe browser devtools should reload it for you automagically when it changes on disk, if you use the built-in server and whatnot#2022-04-1720:11victorbhttps://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading#2022-04-1720:32lilactownI'm asking about using the browser REPL, rather than configuring a build#2022-04-1720:32lilactownhttps://shadow-cljs.github.io/docs/UsersGuide.html#browser-repl#2022-04-1720:33lilactownI know how to configure a build with my own index.html that includes my CSS. I would like to avoid that for a simple project, and just include the CSS in the default browser REPL page#2022-04-1720:34victorbI see. Seemingly, it won't know if files on disk has changed unless you have some devtool connection between the browser and the clojure process that shadow-cljs runs its builds from. Would be a lot of additional setup to get that running.#2022-04-1720:34victorbYou could manually remove/add link tags in your DOM I guess and point it to the CSS file on disk, trigger that action on change somehow#2022-04-1720:35victorbI don't think you need any fancy "hot reload" but can simply reload the entire file at once without any concern#2022-04-1800:14lilactownI wonder how shadow-cljs reloads the CSS. is it just adding/removing the link tags?#2022-04-1805:32thhelleryes, looking for link tags and replacing them https://github.com/thheller/shadow-cljs/blob/e9093aed586d5fb49efd94555787f0bef08fb164/src/main/shadow/cljs/devtools/client/browser.cljs#L119-L147#2022-04-1805:37thhellerbrowser-repl doesn't allow custom css currently#2022-04-1805:38thhellerbut browser-repl is nothing but a regular :browser build so technically it would be easy to add. there just aren't any options for it#2022-04-1805:38thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/web.clj#L116-L152#2022-04-1805:38thhellerthats the html being served#2022-04-1805:38thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/api.clj#L474-L488#2022-04-1805:38thhellerthats the build config used#2022-04-1816:40lilactownthanks! this doesn't directly solve my problem, but I've been thinking about how to build better tools for doing REPL driven UI development and this gives me more to chew on (how to add & dynamically reload CSS)#2022-04-1720:12victorbCan I change the location of shadow-cljs.edn somehow? Search around both in the docs, on the web and in the code base for any parameter/environment variable that allows me to point it to a different one#2022-04-1805:31thhellerno, not supported.#2022-04-1808:47AronConfig can be overridden though#2022-04-1809:21victorb@thheller would you accept a PR adding support for it via a environment variable?#2022-04-1809:27thhellerif you explain the reasoning for that requirement? as far as I know neiter lein or deps.edn or any other tool I'm aware of supports this?#2022-04-1809:37victorb@thheller sure. Being able to clean up root directory from any configuration files would be the first point. Secondly would be to be able to offer a zero-config quickstart template for users who don't necessarily care about the details of the build system. Think create-react-app but with shadow-cljs. I took a quick look at the shadow-cljs codebase and seems I could implement the feature with relatively little change to existing code, so impact wouldn't be too big. I'm unsure if lein or clojure-deps support this, although I think both can read config from stdin so indirectly they would support this (but I might remember wrong). I know for sure a bunch of JS tooling do allow this, most famous example would be webpack I guess#2022-04-1809:42victorbclojure-deps allows setting the full (deps.edn) config via the cli arguments for example, you can run it without any files on disk (so indirectly, can load deps.edn from anywhere as well). shadow-cljs almost have this already with the config-merge argument, but that option only works if you have a file on disk already. If you have nothing, shadow-cljs exits as there is no "root" shadow-cljs.edn file to merge into.#2022-04-1809:47thhellerthe reason I generally say no to this is simply because it makes my life harder#2022-04-1809:47thhellerand anyone trying to help debug problems#2022-04-1809:47thhellerright now when someone has any kind of trouble I have to ask if they are using shadow-cljs.edn only or together with project.clj/deps.edn#2022-04-1809:48thhellerif you add another mechanism where stuff might be that adds another question#2022-04-1809:48thhellerthat is also the reason I was strongly against lein-shadow from the start#2022-04-1809:49thhellersuddenly you make all the documentation not apply for that user and everything has to be qualified and limited#2022-04-1809:49thhellerso I'm gonna say no here too#2022-04-1809:50thhelleralso I'd argue having to set a environment variable first before you can run your program also kinda negates all possible benefit#2022-04-1809:51thhellersince you have to have some kind of dynamic management for this as well, otherwise what happens if you have 2 projects using shadow-cljs.edn. one regular. one with custom path?#2022-04-1809:51thhellernote that you can drive shadow-cljs completely without a config file#2022-04-1809:51thhelleralthough I do not recommend doing so, it is possible#2022-04-1809:53thhellerjust as a reference: the question if deps.edn or project.clj is the most common question I have to ask and the most common source of problem for any kind of dependency related issues as well#2022-04-1809:53thhellerso I'm not talking about a once a year kinda thing#2022-04-1809:53victorbI think it'd be fair to assume 99% of everyone would just use default settings (shadow-cljs.edn in root directory) and it would be unnecessary to ask. But, I absolutely hear your points in general and it does make sense. Reason for having the feature would not be to ask people to add the environment variable, but I want to provide a npm package that ships with a shadow-cljs config + npm script so users could run npx whatever-build-cmd without any shadow-cljs config and that build command can set the environment variable to point shadow-cljs to ./node_modules/whatever-npm-package/shadow-cljs.edn . But again, definitively hear your arguments against it, I don't want to add any more maintainer burden to you#2022-04-1810:21Aronso, how would this work? wrap a live java dev env inside a node dev env seamlessly?#2022-04-1810:55victorbno, npm scripts can be whatever, as long as it's executable. Right now I'm using a bash script that calls SHADOW_CLJS_CONFIG=../path/to/config.edn npx shadow-cljs release build-id so users install my npm package, then run npx whatever-build-cmd which transparently calls the right shadow-cljs commands#2022-04-1811:25AronI am sorry, still very confused, if you are calling shadow-cljs commands, aren't you using a jvm dev env? shadow-cljs needs the jvm afaik#2022-04-1811:58thhelleryeah, shadow-cljs is implemented in CLJ. so a JVM is required.#2022-04-1812:14victorb@U0VQ4N5EE yeah, a JVM is used of course, but I'm not starting shadow-cljs differently than just using shadow-cljs like you normally do#2022-04-1812:16AronWhat I am confused about is that a dependency relies on a dev environment. If I install a node package, I don't expect to have to rely on the jvm also. I know some npm packages do this, so it's not unheard of, but always seemed to cause more issues when trying to use the package in another distribution, now I rely on someone else installing shadow-cljs just so they can use my package that uses your package?#2022-04-1812:16AronI am still half convinced I got it wrong, pls do correct me in that case.#2022-04-1812:17victorb@U0VQ4N5EE no one will "use my package" and ship their own library based on it. I'm basically building a installable development environment for users to build figma plugins.#2022-04-1812:18victorbjust like shadow-cljs has a installable npm cli command that you can run via npm, my "build tool" will have a installable cli command that you can install and run via npm. That anything using ClojureScript comes with the runtime requirement of a JVM shouldn't be a surprise to anyone#2022-04-1812:19thheller@UEJ5FMR6K note that it might be more relevant to create a custom :target instead of a whole build tool#2022-04-1812:19thhellerI mean just leave shadow-cljs.edn as it is and in the build config create the absolute minimum you need to build your tool. could just wrap the :browser target with some defaults#2022-04-1812:19victorb@thheller I'm aiming to ship a "zero-config" build tool, and I'm not seeing how providing a custom :target can enable me to offer that, users would have to add a shadow-cljs.edn to their project in that case#2022-04-1812:20victorbI'm just hacking around trying to find the right way of building all of this, so nothing is written in stone obviously, I'm happy to receive any ideas on how to make it simpler 🙂#2022-04-1812:20thhellerzero config is a pipe dream. there is no such thing as zero config. it doesn't exist. at some point you WILL require a config#2022-04-1812:20thhellerI mean how else do you add CLJS dependencies?#2022-04-1812:21Aron@UEJ5FMR6K you did say your users will use your package and I couldn't imagine why your users need to have have this complicated way of getting shadow-cljs pre-bundled for them, why not just distribute a config file?#2022-04-1812:21thhellerthe shadow-cljs.edn config is already the bare minimum, you can possibly make the build config smaller by making something figma specific#2022-04-1812:21victorbyeah, I mean the experience of it. Obviously if people want a more customized setup they are welcome to do just that by setting up their own configuration, overwriting the one provided. But it would work for basic use cases. The config-merge option helps users to add specific parts if they want to (like additional runtime dependencies)#2022-04-1812:22thhellercan't add runtime dependencies view config-merge#2022-04-1812:22victorb@U0VQ4N5EE people would be able to use their own config if they want to. Out-of-the-box experience won't require it though#2022-04-1812:22victorb@thheller ah, I see, then I'll find another way 🙂#2022-04-1812:23victorbI'm happy to share my approach to the whole thing when it's published and usable#2022-04-1812:24Arongood luck, not saying I would do the same way, but all the more I wish that you succeed. I just hope it's not going to be something like cra 😄#2022-04-1812:27victorb@U0VQ4N5EE not a problem, we're lucky not everyone implements things the same way, would be a boring (and probably inefficient) world then 🙂#2022-04-1812:28victorb@U0VQ4N5EE just for curiosity's sake, what problems do you see with the create-react-app approach?#2022-04-1813:05AronI don't think I can say anything new about the matter. Maybe most of the reasons are just all the hours spent on IRC helping people who followed some tutorial with cra and then ended up installing bunch of stuff they didn't need. But much more generally, I see tools that are good abstractions, you use them, and you forget about them... these don't get too popular ever, because you don't see them popping up in search results or on stackoverflow, because people don't talk about them, because these are good tools and you read the docs and don't need to write a blogpost about doing something trivial .... and then there are tools where anything simple is so overcomplicated that you are dancing between several compilers and plugins and hoping that you have used the transforms in the right order.#2022-04-1816:57lilactownthe problem I've seen with CRA is that it doesn't compose well. so you end up with continual creep of features, plugins, etc. that people want "zero-config" for and the alternative is to tell them to eject, which means that the user goes from "zero config that I haven't had to learn" to learning how to configure webpack/babel/etc.#2022-04-1816:58lilactowni think if your problem is well scoped, it can work. but trying to ship a zero config solution for all web dev is a pipe dream, as thheller said#2022-04-1817:01lilactownI'm slightly bullish on things like config generators a la phoenix, that allow you to have explicit config so you can observe what it is and tweak it without a huge wall between you and the tools, but make things easier for the usual cases#2022-04-1817:02thhellermy next goal is to actually use metadata in clojure and the power it brings#2022-04-1817:02thhellerthat'll make most of the required config even shorter#2022-04-1817:02thhellersimilar to the ^:dev/after-load stuff moving the "config" closer to the actual code#2022-04-1817:03lilactownthat would be cool!#2022-04-1817:03thhellerjust need to figure out how to do it properly in CLJS given the macro requirement. totally easy in CLJ.#2022-04-1817:05thhelleralready did some of it for my UI thing and I like it quite a bit#2022-04-1817:05thhellerjust declare some metadata on a regular defn and have some other place to collect them all https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/db/generic.cljs#L11#2022-04-1817:06thhellerbasically this equates to re-frame (reg-event ::m/init! (fn ...))#2022-04-1817:06thhellerlater then could use the same metadata to generate documentation and stuff#2022-04-1817:07thhellerkeeping code stuff in code and out of config#2022-04-1817:07lilactownso ::ev/handle would implicitly register itself with some global registry?#2022-04-1817:08thhellernot global no. this is a macro that collects them all and registers them with rt-ref https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/main.cljs#L149#2022-04-1817:08lilactownaha#2022-04-1817:10thhellersimilar thing for the backend generating a reitit router table out of https://github.com/thheller/shadow-experiments/blob/master/src/dev/dummy/website.clj#L12#2022-04-1817:11thhellermetadata is underused for framework type stuff 😛#2022-04-1817:11lilactownagreed#2022-04-1817:13thhelleralso as far as this discussion is concerned. don't forget that shadow-cljs can run any clojure code for you. https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run#2022-04-1817:14thhellerso if you just make a function that tells shadow-cljs what to do that might solve all your issues you might have with a build config#2022-04-1817:15thhellereg. your own browser-repl 😉#2022-04-1817:44lilactownthe browser-repl ask in the channel was just me being lazy and not wanting to copy + paste the same index.html and build config i carry around with me 😛#2022-04-1817:45lilactownfor a library project#2022-04-1809:54victorb> note that you can drive shadow-cljs completely without a config file How would one go about to do this? I tried looking at the "library" usage instead of cli usage of shadow-cljs but I didn't find any documentation about it so not sure if it was possible or not#2022-04-1809:55thhellerwell driving a build you can do entirely without any config via the CLJ api#2022-04-1809:55thhellerif you need something to start the actual JVM without any other tool then you kinda need the config to declare dependencies and so on#2022-04-1809:55victorb> although I do not recommend doing so, it is possible Because of churn in the API interface or for some other reason? I'm thinking if it's easier for me to just maintain my own shadow-cljs fork at that point rather than using the library, since adding support for loading config from env var would just be ~5 lines of code#2022-04-1809:56victorb> well driving a build you can do entirely without any config via the CLJ api Right, I'll take a look at that. Thanks!#2022-04-1809:56thhellershadow.cljs.devtools.api/release or compile or watch all take a build-id argument#2022-04-1809:56thhellerwhich can just take a map defining the build directly, so it won't look it up in the config instead#2022-04-1809:58victorbah, that should be good enough for what I'm doing. Thanks a lot for taking the time to explain and help out 🙂#2022-04-1810:02thhellerthe reason the config should generally have the build config is because some features are tied to it. (eg. the UI)#2022-04-1810:03thhelleralso easier to debug if something doesn't work as expected. eg. a user build failing because of an error. if there is no visible build config that is much harder to debug#2022-04-1810:21Aronso, how would this work? wrap a live java dev env inside a node dev env seamlessly?#2022-04-1816:38isakIn the build report, for the "Generated Files" section, I think it would be helpful to extract everything that starts with "node_modules/" to be top level entries (grouped by package or folder) similar to how CLJS dependencies like reagent would appear. Thoughts?#2022-04-1816:38thheller@isak upgrade shadow-cljs. that was a bug for a couple versions#2022-04-1816:38isakAhh ok#2022-04-1821:42zhuxun2Is there a way to retrieve the entry point of a compiled web worker based on its module key? Currently, I have to do (js/Worker. "/...<path-to-web-worker>.js"). Sometimes I changed the assay path and forgot to update this line as well.#2022-04-1822:21zhuxun2Another question: Is goog.DEBUG the best way to separate the dev build from release build? Will it be compiled away?#2022-04-1904:47thheller@zhuxun2 the asset path is not currently available in the code. goog.DEBUG depends on what you do, in theory it can allow to remove some code yes#2022-04-1907:21pmooserWhen I am using shadow-cljs with some arbitrary npm, I often struggle a bit to try to figure out the right way to refer to elements in the javascript package. Once I do a basic require of something, is there any way to introspect or look inside it to see what it provides?#2022-04-1907:21pmooserI often spend a fair bit of time fumbling around in the dark before I figure it out.#2022-04-1907:21pmooserFor example, I just installed an npm called rc-slider, and in their example, they do this (in js):#2022-04-1907:22pmooser
const Slider = require('rc-slider');
const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);
#2022-04-1907:22pmooserI thought that would map to something like:#2022-04-1907:22pmooser
(require '["rc-slider" :as rcs])
(rcs/createSliderWithTooltip rcs/Range)
#2022-04-1907:23pmooserBut rcs/createSliderWithTooltip is just nil, so I'm clearly reading this wrong.#2022-04-1907:23pmooserAny tips?#2022-04-1907:29pmooserOh jeez, this looks like a bug with this stupid library.#2022-04-1913:23pmooserI'm trying to use this reagent library reagent-mui, and when I import a specific namespace, I see some load failures from shadow-cljs in my console:
shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$ThemeProvider
shadow-cljs - failed to load module$node_modules$$mui$material$node$styles$index
I looked at the related stack traces, and they mention the bootstrap build, so I tried to exclude the ns I imported from the bootstrap build, but with no effect.
#2022-04-1913:23pmooserAny suggestions?#2022-04-1917:37thheller@pmooser if you are on an old shadow-cljs version you should upgrade. that error message should be clearer now. you are pasting irrelevant parts#2022-04-2008:16pmooserOk, I've updated to 2.18.0, and now here's a more complete error message: (It won't let me copy/paste the exception info as text, so here's an image)#2022-04-2008:16pmooserThere is a bit more to the exception as well ...#2022-04-2008:17pmooser@U05224H0W Here is the rest of that stack trace from above:#2022-04-2008:50pmooserSince updating, I'm also seeing this exception:#2022-04-2008:50pmooser#2022-04-2008:57pmooserThat occurs upon reloading CSS.#2022-04-2009:09thhelleryou are still looking at the wrong error#2022-04-2009:09thhellerlook for something red, yellow are warnings. ignore those.#2022-04-2009:09thhellershould be above the failed to load warnings#2022-04-2009:18pmooserThe load warnings occur before the errors.#2022-04-2009:18pmooserHere are the errors:#2022-04-2009:18pmooser#2022-04-2009:19pmooser@U05224H0W I see bootstrap again in those stack traces, but I haven't succeed so far at excluding things and making the error go away.#2022-04-2009:20thhellerwhat do you mean?#2022-04-2009:20pmooserI mean the stack trace contains a line like this, that makes me wonder if the bootstrap build is implicated in causing this problem:#2022-04-2009:20pmooserat Object.shadow$cljs$bootstrap$browser$script_eval [as script_eval] (browser.cljs:38:4)#2022-04-2009:20pmooserAnyway, I can just not import this namespace. It's not vital, but it's just odd to have an import of a namespace break things.#2022-04-2009:21pmooserIf I can't figure out what is making it emit errors on every CSS reload, I'll probably have to revert to an older shadow-cljs too.#2022-04-2009:21thhellerI really cannot offer any comments without more information#2022-04-2009:21thhellerI don't know what you are doing so just looking at a trace doesn't tell me enough#2022-04-2009:22thhellermight be bootstrap related, might not be. I cannot tell#2022-04-2009:22thhellermaybe you are trying to hot-reload boostrap code?#2022-04-2009:22thhellerthat doesn't work#2022-04-2009:27pmooser@U05224H0W I know that hot-reloading bootstrap code doesn't work. I have a couple builds, one of which is a bootstrap build, but it's just for an embedded repl that I use in my application. What information would be useful, if the stack traces are all not sufficiently informative to figure out what the bugs are? I don't really need the bootstrap build to be compiling anything in my app that is related to the UI, so strictly speaking the namespace that is even loading this code isn't relevant at all to bootstrap.#2022-04-2009:28thhelleryou mean you have 3 builds in your page? your regular app, your embedded REPL and the boostrap?#2022-04-2009:28thhelleror is the embedded REPL part of the regular app?#2022-04-2009:29pmooserThe embedded repl is part of my normal app. For development purposes, I have either 2 or 3 builds running. The simpler case is something like: shadow-cljs watch app-simple bootstrap#2022-04-2009:29pmooserWhere app-simple is a normal build, bootstrap is a bootstrap build.#2022-04-2009:30thhellercan you be more specific about the embedded REPL thing? self-hosted interacting with a regular watch is pretty much guaranteed trouble#2022-04-2009:30thhellerspecifically why do you go full self-hosted?#2022-04-2009:31pmooserI feel like every time there's an issue with bootstrap and I ask a question, it turns out that bootstrap is the source of all problems in the world.#2022-04-2009:31pmooserSorry to exaggerate, but it's extremely aggravating.#2022-04-2009:31pmooserI think I'll just do the work to switch over to sci instead of using the bootstrap build,#2022-04-2009:31pmooserand then hopefully this will become more reliable.#2022-04-2009:32thhellerjust take 5 seconds to explain what you are trying to do#2022-04-2009:32thhellerself-host is just the most complicated thing you can do. so it is easy to make mistakes and screw something up#2022-04-2009:32thhellerif you just want a eval for development purposes you can use https://clojureverse.org/t/status-update-inspect-cljs-eval/6074#cljs_eval-2#2022-04-2009:33thhellerno need for sci either#2022-04-2009:33pmooserI have an application - a fairly normal reagent-based cljs application. As part of that application, I have a window that will evaluate code that I type. This is not the core of the application, but it's an extremely useful capability in the app, for a variety of reasons. I use the bootstrap build because to my knowledge that's the way to support that.#2022-04-2009:33pmooserThis also happens to run in production, so I'm not sure that will work either.#2022-04-2009:33pmooserBut I haven't fully digested the link you just sent me ...#2022-04-2009:33thhellerok cljs-eval will not be available in production#2022-04-2009:35pmooserYeah. So I think due I guess to the unfortunate nature of bootstrap, the best thing for me (and for you, so I stop bugging you with questions about a part of the cljs ecosystem that I suppose just doesn't work very well) is probably to migrate to sci. That way, there's no mysterious build happening anymore, which I imagine will eliminate most of these issues.#2022-04-2009:35pmooserAny insight on what might be causing that error on CSS reload in shadow-cljs 2.18.0 that I mentioned above?#2022-04-2009:35thhellerit works just fine. just easy to make mistakes and use incorrectly. thats the nature of the system, if you use it correctly it works fine.#2022-04-2009:36thhellerno since I still don't have a clue what you are doing#2022-04-2009:36pmooserWell, I've been using bootstrap like this for ... 2 years now? Generally it works. It's just that when it doesn't, it's not clear how to fix it.#2022-04-2009:36thhelleryou might have the bootstrap parts load some code that is already loaded and overriding important parts#2022-04-2009:36pmooserI have some things exluded from the build, but I don't even see :exclude mentioned in the docs anymore (?)#2022-04-2009:37pmooserI don't understand what you mean that you have no idea what I'm doing.#2022-04-2009:37pmooserLike, what I'm doing isn't that weird.#2022-04-2009:37pmooserI've been using shadow-cljs like this for literally years.#2022-04-2009:37pmooserNow I've upgraded, and there's a new error.#2022-04-2009:37thhellerI'm not saying that. I just don't know WHAT you are doing#2022-04-2009:37thhellerso I cannot just guess a random solution out of a hat#2022-04-2009:37thhellerit might be something extremely trivial#2022-04-2009:37thhellerit might be an actual bug#2022-04-2009:37thhelleror something inbetween#2022-04-2009:37thhellerI cannot say#2022-04-2009:38pmooserI feel like I'm wasting your time.#2022-04-2009:38pmooserI'll go ahead and revert to the old version and just forget about it.#2022-04-2009:39thhellerhappy to look at some code to make better guesses#2022-04-2012:56pmooser@U05224H0W So when I try to revert to the previous shadow-cljs version I get some errors, so I'm once again trying to fix this CSS reloading error I'm seeing with 2.18.0. You said before you didn't know "what I was doing", but I have a basic reagent application. I'm doing a shadow-cljs watch my-build bootstrap and basically if I modify my site.css file, I get a shadow-cljs exception in my console when it reloads my site.css file. It also doesn't overwrite or update an existing style, but seems to load/create duplicate styles (if I'm looking at elements in a chrome inspector). What kind of information could I provide that would help to debug this?#2022-04-2012:56pmooserI will try to migrate away from the bootstrap build but that takes a little bit of work for me also.#2022-04-2013:03thhellermost likely you are trying to diagnose the wrong thing#2022-04-2013:04thhellerthe css thing failing is most likely just a symptom of something else going wrong before that#2022-04-2013:05pmooserHow would you track it down, since there are no other errors or warnings appearing in the console, and the only place I've noticed a side effect of this error is in the element inspector in chrome (where it is visible that it is failing to replace styles) ?#2022-04-2013:05pmooserThere is also no error (css-related or otherwise) upon first page load.#2022-04-2013:06thhelleragain, very likely not css related at all#2022-04-2013:06thhellermy guess is on the bootstrap stuff being loaded out of order or replacing the bootstrap compiled ns with one compiled by shadow-cljs#2022-04-2013:06pmooserIf the software fails silently, I have no idea what to do.#2022-04-2013:07pmooserI guess I'll proceed along the path of trying to remove the bootstrap build and see if that helps anything.#2022-04-2013:07thhellerif the problem goes away if you just don't init the bootstrap stuff that should provide good information#2022-04-2013:08thhellernote that it could also be the bootstrap build completely replacing cljs.core#2022-04-2013:08thhellerlots of possible causes here. very hard to debug remotely without any code#2022-04-2013:09pmooserThank you, and understood. It sounds like this path isn't a bad idea regardless, and I'll be sure to update you if the problem disappears after removing bootstrap.#2022-04-2013:09thhellerI can't tell from the error excerpt you posted but is this log showing up just before the css is failing?#2022-04-2013:09thheller(devtools-msg (str "call " fn-sym))#2022-04-2013:09thhelleror asked different do you have a :dev/asset-load hook anywhere in your code?#2022-04-2013:10thhellerif not it shouldn't even get to that line#2022-04-2013:10thhelleralso are you sure you upgraded shadow-cljs properly and restarted it after? too often people just update the npm package while still having an old version in deps.edn/project.clj#2022-04-2013:11pmooser• I'm not using :dev/asset-load anywhere in the code at all. • I'm sorry but I don't understand the question about the log showing up - at this point, the only error occurring is when I save my CSS file, and shadow-cljs reloads it - that's when these log messages show up, and there are no other errors or warnings before or after. Please help me understand what I'm failing to explain here. • Where should I put that (devtools-msg ... line?#2022-04-2013:12thhelleryou should not put that anywhere. in your stacktrace of the css error it is pointing to browser.cljs line 141#2022-04-2013:12pmooserI just forcibly removed the bootstrap build/etc and for now it appears the error may be gone.#2022-04-2013:12pmooser(at least it doesn't occur immediately after reloading my page)#2022-04-2013:13thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L141#2022-04-2013:13thhellerthat would be that line, which immediately before that has the log line that should show up in the console#2022-04-2013:14thhellerbut that piece of code should only even be called when you have a :dev/asset-load hook#2022-04-2013:14thhellersince you don't I'm assuming you are not actually on 2.18.0#2022-04-2013:14thhelleror just something else is mucking arround#2022-04-2013:14pmooser
:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.18.0"}}
                         :main-opts ["-m" "shadow.cljs.devtools.cli"]}
#2022-04-2013:14pmooserThat's my alias I'm using to launch shadow-cljs - I don't see how that could not be 2.18.0 but I'm not super expert at deps.edn so maybe there's some way.#2022-04-2013:15pmooserI didn't know that :dev/asset-load exists, so it definitely isn't in my code, and I've verified this by grepping everything in the project.#2022-04-2013:16pmooserGiven that the issue seems to be gone with the bootstrap build excised from this entire thing, maybe it's not something you have to worry about. Or, if you think the info could be of value to you, I could restore the bootstrap build to try to get some diagnostic information.#2022-04-2013:16thhellerassuming that alias is actually activated that should be fine then#2022-04-2013:19pmooserI mean that's how I launch the build ...#2022-04-1917:38thhellercan't say whats wrong with the proper info#2022-04-1917:38thhelleralso can't say whats wrong with rc-slider. translation looks correct.#2022-04-1920:04ribelois it possible to use shadow-cljs with deno and working repl?#2022-04-1920:07ribeloshadow-cljs compile returns code that works#2022-04-1920:07ribelobut shadow-cljs watch is already crashing#2022-04-1920:08ribelo#2022-04-1920:10ribelonever mind, i found the answer#2022-04-1920:10ribelohttps://clojureverse.org/t/generating-es-modules-browser-deno/6116?page=2#2022-04-2010:47pinkfrogI got a hotloading issue. I am on react native, but that should not matter much as regard to react on web. The problem is, the main screen is A. Starting from A, I navigated to B, and then C. Now I edit the code related to C. Shadowcljs happily reloaded the code of C. But how do I re-render C and show it? Currently I added a dev/after-load on the starting-screen A, which is the entry point. But that makes the screen to show A instead of C everytime I change code.#2022-04-2010:56thhellerthat it entirely out of the control of shadow-cljs. it just calls a function. what that renders is up to you.#2022-04-2011:25pinkfrogI take my words back. seems adding the ^dev/after-load at register-component indeed calls that function, but some other mechanism is needed to trick RN to rerender all the app
(defn register-component {:dev/after-load true}
  []
  (.registerComponent ^js (.-AppRegistry rn)
                      "myapp"
                      ;; wrap in :>f to make a functional component
                      #(r/reactify-component (constantly [:f> app]))))
#2022-04-2012:07thhelleryou should use this approach for hot-reloading https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L34#2022-04-2012:07thhelleryour version does not work propery with hot-reload#2022-04-2012:07thhellerI created the render-root helper for this purpose#2022-04-2012:27pinkfrogYup. I was searching for the forceUpdate method, but seems the result from r/reactify-component does not contain such field.#2022-04-2012:29thhelleryou are free to copy this but all the steps it does are necessary. so be careful if you try to build your own. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/react_native.cljs#2022-04-2012:29thhellerits not just .forceUpdate#2022-04-2013:16pinkfrogyup. first step you have to get the instance of a component: https://github.com/thheller/shadow-cljs/blob/650d78f2a7d81f33cb2590e142ddcbcbd756d781/src/main/shadow/react_native.cljs#L47#2022-04-2014:36pinkfrogNow I doubt this works. The method only updates the root component, but cannot recursively updating child components.#2022-04-2014:45pinkfrogJust tested. Only the root component is foreced to be updated.#2022-04-2015:10thhellerthen one of your components decides to skip rendering. see the gotchas described here https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-04-2103:51bbss@lilactown your example for storybook was useful in getting it working for me, thank you. But I'm currently gravitating back to workspaces because I can't get the repl to work with storybook. Is that something you just live without, or did you find a way to load it with storybook?#2022-04-2114:56lilactownyeah we live without a REPL in our storybook build#2022-04-2114:58lilactownit seems like something that others may have figured out, what with people using target :bundle in vanilla CLJS with a REPL#2022-04-2205:51bbssCool, thanks for the suggestion. I think I'll mix workspaces and storybook until I make up my mind 😅#2022-04-2111:05thheller@oliver I don't use any formatters. well Cursive format code but that is much less aggressive than most formatters. which issues are you looking at? most of them are not that trivial#2022-04-2114:58lilactownit seems like something that others may have figured out, what with people using target :bundle in vanilla CLJS with a REPL#2022-04-2116:13DerekAt one point, a project I worked on would end up with a single, large source map to go with app.js. I’m seeing smaller, namespace-specific source maps on a current project. Am I misremembering? Is there a setting somewhere?#2022-04-2117:02thheller@dpassen1 release builds have one large map, compile/watch dev builds have one per namespace (in the cljs-runtime dir, which not required for release builds)#2022-04-2117:37DerekThat makes sense. I’ll figure out what we’re doing wrong. Thank you#2022-04-2117:51DerekThat was it. source-maps were on in dev, not for release. Thanks as always#2022-04-2200:37neilyioI’m trying to follow the shadow-cljs instructions for https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js. I have :require form that looks like this:
(ns cljs.user
  (:require ["lodash"]
            ["/common/relay/relay-env"]))
…where my config has :source-paths ["src"] and my file system has src/common/relay/relay-env.js. When I evaluate the above form, shadow-cljs seems to find relay-env.js just fine, but trips up on the first line of relay-env.js:
import ajaxPath from "common/api/ajaxPath";
…where src/common/api/ajaxPath.js is also on my file system. I get the error:
The required JS dependency "common/api/ajaxPath" is not available, it was required by "common/relay/relay-env.js
…but it works if I manually change the import statement (note the leading /)
import ajaxPath from "/common/api/ajaxPath";
I’m getting the impression that when shadow-cljs resolves the imports inside of .js files, it follows the same convention as resolving .js files in ClojureScript :require forms. That’s to say, it requires the leading / if it’s going to look on the local file system, otherwise it checks node_modules. Is there a way I can get around this without manually changing all my .js import statements? I’m trying to work with a large codebase of existing .js files that all use this relative import style.
#2022-04-2202:53eplokoI have a :target :node-script build in which I try to dynamically load an ESM module with (js/import "module-name-here"), which gives me ReferenceError: import$ is not defined. Is there a work around to this? Is there a way to consume an ESM module dynamically?#2022-04-2203:03eplokoAs a more generic question, is there a way to consume ESM-only npm packages in :node-script and :browser builds?#2022-04-2203:59thheller:browser will most likely just work if you just require it normally. dynamic import will not work unless you use :target :esm instead#2022-04-2204:00thhellersame for :node-script really. if you plan on using lots of ESM it is best to use ESM yourself#2022-04-2204:00thhellerhttps://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-04-2204:42eplokothe :esm target doesn't seem to resolve any of the node native modules though...
The required namespace "child_process" is not available, it was required by "blah-blah".
#2022-04-2204:43thhellerfor node targets you should set :js-options {:js-provider :import} in your build config#2022-04-2204:43thhellerotherwise it'll try to bundle everything which can't work for the node packages#2022-04-2205:10eplokohm... child_process is now seemingly imported fine, but the very next import of electron fails: The required namespace "electron" is not available, it was required by "blah-blah". I made sure electron is in the dependencies in package.json, cleaned everything up, re-installed with npm i, the result is the same. any hints?#2022-04-2205:12thhellerlooks like you are trying to use (:require [electron ...])? A symbol? should be (:require ["electron" ...]) isntead?#2022-04-2205:13eplokoNope, it's
(:require
   ["child_process" :as cp]
   ["electron"] ...
#2022-04-2205:14eplokoI was happy in the cjs world until I stumbled upon an esm-only package I struggle with consuming now 🙂#2022-04-2205:14thhellerhmm what is your build config?#2022-04-2205:15thhellerand this is all installed in the correct folder? happens quite frequently that people look in the wrong folder#2022-04-2205:15eploko
{:target :esm
   :output-dir "resources/js/compiled/main"
   :modules {:main {:entries [app.main]}}
   :devtools {:repl-pprint true}
   :compiler-options {:output-feature-set :es-next}
   :js-options {:js-package-dirs ["node_modules"]
                :js-provider :import}
   :main app.main/main
   :dev {:closure-defines
         {app.config/DEV true}}}
#2022-04-2205:16thheller:main app.main/main has no effect in :esm but otherwise looks fine#2022-04-2205:17thhellerso you can confirm there is node_modules/electron/package.json?#2022-04-2205:17eplokooh, hold on pls#2022-04-2205:18eplokoyep, the npm module is installed correctly.#2022-04-2205:19eplokoI figured out the reason though: there was another file with similar name that tried to require electron as a symbol...#2022-04-2205:19thhellerthat should still be ok though if the packages exist#2022-04-2205:20thhellerbut always safer to use a string
#2022-04-2205:22eplokoyep, checked all the code, that was a single occurance of that.#2022-04-2205:23eplokoeven though it compiles now, it fails to run under electron with:
Error: ENOENT: no such file or directory, open '...app/.shadow-cljs/builds/main/dev/out/cljs-runtime/goog.debug.error.js'
#2022-04-2205:23eplokoany other things I've missing in the build config potentially?#2022-04-2205:24thhellerthat doesn't look an esm build?#2022-04-2205:24eplokohm... let me clean and rebuild....#2022-04-2205:24thhellermaybe still using the old output file?#2022-04-2205:27eplokoyou're absolutely right. I should take a break probably... 😅#2022-04-2205:31eplokoWell, in the end it hits the wall in that electron tries to load the entrypoint with a require itself, which being an esm module, fails...
App threw an error during load
Error [ERR_REQUIRE_ESM]: require() of ES Module ...app/resources/js/compiled/main/main.js from ...app/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js not supported.
Instead change the require of ...app/resources/js/compiled/main/main.js in ...app/node_modules/electron/dist/Electron.app/Contents/Resources/default_app.asar/main.js to a dynamic import() which is available in all CommonJS modules.
#2022-04-2205:32thhellerhmm I guess then esm isn't supported#2022-04-2205:33thhelleryou can make dynamic import work but the trouble is the closure compiler may break it when optimizing#2022-04-2205:33eplokoit basically requires the entrypoint to be a cjs module. I can potentially just have that as plain .cjs file and then dynamically import the result of the build from there.... at least i hope it'll work then.#2022-04-2205:33thhellerat least the last time I checked it did#2022-04-2205:34thhellerjs/import getting renamed to import$ is just the compiler being annoying. you can use (js* "import(\"whatever\)") to not have it do that#2022-04-2205:34thhellerbut that may only work in development#2022-04-2205:35eplokohm... let me play with this a bit further... i'll try all of the above perhaps, and will also check the esm build works in the browser...#2022-04-2205:35eplokothanks for your help, really appreciated 🙂#2022-04-2502:26eplokoWell, continuing on the same journey of enabling esm in an electron app built with shadow-cljs... The build config is now this:
{:main
  {:target :esm
   :output-dir "resources/js/compiled/main"
   :modules {:main {:entries [relm.main]}}
   :devtools {:console-support false
              :hud false
              :repl-pprint true}
   :compiler-options {:output-feature-set :es-next}
   :js-options {:entry-keys ["module" "browser" "main"]
                :js-package-dirs ["node_modules"]
                :js-provider :import}
   :dev {:closure-defines
         {relm.config/DEV true}}}}
#2022-04-2502:26eplokoIt all compiles alright:
[:main] Build completed. (144 files, 2 compiled, 0 warnings, 0.18s)
#2022-04-2502:28eplokoThere's also a esm-enabler entry point .cjs script to make it possible to load everything in electron:
global.__relm__dirname = __dirname;
global.Electron = require("electron");
global.WebSocket = require("isomorphic-ws");
import("./compiled/main/main.js");
#2022-04-2502:29eplokoIf I try to load it as-is, the following happens:
(node:28006) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `Electron --trace-warnings ...` to show where the warning was created)
(node:28006) UnhandledPromiseRejectionWarning: ...app/resources/js/compiled/main/main.js:3
import "./cljs-runtime/shadow.module.main.prepend.js";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1038:15)
    at Module._compile (node:internal/modules/cjs/loader:1072:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
(node:28006) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 1)
^C...app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINT
#2022-04-2502:31eplokoTo mitigate this I've put a bare package.json with { "type": "module" } in resources/js, so electron treats everything under that folder as being esm by default.#2022-04-2502:33eplokoIt all works alright until I try to require a node js package that happens to require another package...
(node:27663) UnhandledPromiseRejectionWarning: ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '...app/resources/js/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file://...app/resources/js/compiled/main/cljs-runtime/cljs.nodejs.js:3:23
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
(Use `Electron --trace-warnings ...` to show where the warning was created)
(node:27663) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see ). (rejection id: 2)
^C...app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGINT
#2022-04-2502:35eploko@U05224H0W should cljs-runtime/cljs.nodejs.js maybe be using esm-style imports under the hood when compiled with :target :esm?#2022-04-2502:44eplokoIt all bails out when I try to use the macchiato.server ns from the macchiato/core package. Looking at its source, I guess the problem is caused by lines like this one: https://github.com/macchiato-framework/macchiato-core/blob/85c5e3b0b55095565543a3dc876849f71df354d4/src/macchiato/server.cljs#L16#2022-04-2502:45eplokoWhere node stands for:
(ns macchiato.server
  (:require
    [cljs.nodejs :as node]
...
#2022-04-2502:46eplokoI'm kind of lost. Does the above mean the macchiato library is only meant to be used as a part of a normal node script, and will not work in an esm environment ever?#2022-04-2502:55eplokoI've also just realised that cljs.nodejs is not a shadow-cljs wrapper, but a part of the cljs runtime: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/nodejs.cljs#2022-04-2502:56eplokoSo, there's no way I can prevent macchiato from using the node's require I guess...#2022-04-2502:59eplokoWill try to see if I can replace it by the regular express from npm#2022-04-2504:46thhellerhmm yeah should definitely not be using the cljs.nodejs ns at all#2022-04-2504:47thhellerguess you are stuck with commonjs then#2022-04-2504:48thhellerdid you try the import hack instead of going full esm?#2022-04-2523:29eplokoYeah, I did. There was something not working with the approach as well. Though I don't remember details by now. 🙂 Anyway, I ditched macchiato and switched to express. Everything else seems to work fine under esm.#2022-04-2523:34eplokoOne thing I noticed though, when building with :target :esm the resulting code insists on using the global WebSocket object. That works in a browser, but is not available by default in node. That's why I have the following bit in the loader file:
global.WebSocket = require("isomorphic-ws");
#2022-04-2603:54thheller:target :esm defaults to assuming a browser runtime. thus it injects some code for the REPL which uses the websocket so hot-reload and stuff work#2022-04-2603:55thhellerusing it for two different runtimes is currently not officially supported but I guess you can hack it like you did#2022-04-2203:57thheller@neil.hansen.31 those rules are pretty much the same as in webpack. as in webpack would also look for common/api/ajaxPath in node_modules. unless you explicitely configure it not to. there is no matching option for this currently though.#2022-04-2211:51Patrick BrownHas anyone run into this error while trying to use workspaces with fulcro3? My other builds work, just not the workspaces one. The shadow build settings are near identical, so I’m lost. I don’t think this is shadow related, probably a Fulcro3 versus 2 deps thing, but here seemed like the place to find an answer. The required namespace "goog.debug.Logger.Level" is not available, it was required by "fulcro/logging.cljc"#2022-04-2212:28thheller@pat561 yes, most likely a dependency version problem. lots of stuff changed in the closure library and you likely are just using some incompatible versions#2022-04-2213:40timoI am currently migrating away a project from lein-figwheel to shadow-cljs and I am having a problem of understanding. I was used to have my app started when I started my cljs-repl. It was both running on the same port so I had no problem. Now I am starting shadow-cljs first as clojure-repl starting my app on port 3001 usually and then starting my frontend repl which then runs on 3000. Now my frontend-app tries to reach the backend-app on 3000 but backend is running on 3001. Do you run your frontend and backend on different ports? Do you then configure that somewhere?#2022-04-2214:02timothe docs talk about lifecycle but it seems to be cljs only#2022-04-2214:02thheller@timok would help if you share the configs. I'm not sure I understand that you are describing. as far as shadow-cljs is concerned everything can serve the file .js files it produces. so you should just have your backend serve them as regular files#2022-04-2214:03timoMy clj-backend has lifecycle methods with component. the server is started with it https://figwheel.org/docs/ring-handler.html#2022-04-2214:04timoNow I need a way to do it with shadow-cljs so that my frontend is served on the same port as my backend runs on.#2022-04-2214:04thhellerok shadow-cljs doesn't support this since you won't be using it in production and I'm a firm believer your backend should match the production setup as closely as possible#2022-04-2214:04thhelleryou can just run a regular ring setup with that handler though#2022-04-2214:04thhellernothing special to do#2022-04-2214:08thhellerbut I'm guessing you already did that part? since you have something on 3000 running?#2022-04-2214:08timoyou mean I can run the shadow-cljs lifecycle-hooks with a clj-function?#2022-04-2214:08thhellerno, you misunderstand the setup#2022-04-2214:09timoright, I am starting shadow-cljs, then starting my lifecycle-components from the clj-repl serving on 3001, and then starting the cljs-repl that serves the frontend on 3000#2022-04-2214:09thhellershadow-cljs does nothing for your backend. that should run separately on its own using nothing from shadow-cljs (since you don't want to have that either in production)#2022-04-2214:10timook, that means I need to run my cljs-app so that it can point to another endpoint as it was served from?#2022-04-2214:10thhellerwhat do you mean by "cljs-repl that serves the frontend on 3000"?#2022-04-2214:11timo
{:deps {:aliases [:dev :cljs]}
 :builds {:app {:target :browser
                :output-dir "dev-resources/public/js"
                :asset-path "/public/js"
                :modules {:main {:init-fn com.aareon.dp.monitor.core/run}}}}
 :dev-http {3000 ["dev-resources/public" "dev-resources/public/js"]}}
#2022-04-2214:11thhellerno. As I said the .js files shadow-cljs produces can be served by any server. if you have a backend you do not need to use :dev-http at all. just remove it#2022-04-2214:11timoah ok#2022-04-2214:11timothat's probably it...#2022-04-2214:11thhellerthis is also not related to the REPL in any way#2022-04-2214:12timoalright, I get it#2022-04-2214:12timoI will try that#2022-04-2214:12timothanks#2022-04-2214:13thhellerjust make sure your backend server serves the dev-resources/public as files via either the ring-resource middleware (probably just public then, assuming dev-resources is part of the classpath) or the ring-file middleware#2022-04-2214:14timook, very helpful. thanks a lot#2022-04-2410:14p-himikWhat would be the right way to get a build config that has either :dev or :release value merged into it correctly? It's needed to make things use proper shadow-cljs values when using clj-run. Currently, I have this abomination:
(defn- get-config [build-id mode]
  (let [init (shadow.build.api/init)
        build-config (shadow/get-build-config build-id)
        build-state (shadow.build/configure init mode build-config)]
    (:shadow.build/config build-state)))
#2022-04-2410:21thhelleruhm there is no dedicated helper function for this, well except maybe for this https://github.com/thheller/shadow-cljs/blob/1708acb21bcdae244b50293d17633ce35a78a467/src/main/shadow/build.clj#L169?#2022-04-2410:23thhellerI guess maybe this could be its own function? https://github.com/thheller/shadow-cljs/blob/1708acb21bcdae244b50293d17633ce35a78a467/src/main/shadow/build.clj#L289-L293#2022-04-2410:24thhellerwhat do you intend to do with that though?#2022-04-2410:30p-himikTwo things: • Let sass know where to put the resulting CSS files (I'm really averse to hard-coding the values everywhere but the config) • Automatically open a browser tab with the URL that matches a :dev-http entry for a specific build#2022-04-2509:34Piotr RoterskiHello everyone! 👋 shadow-cljs outputs source-maps in “sections” format but Sentry (error tracking SaaS) fails to parse it. The “sections” format looks like:
{
    version : 3,
    file: "app.js",
    sections: [
     { offset: {line:0, column:0}, url: "url_for_part1.map" }
     { offset: {line:100, column:10}, map:
       {
         version : 3,
         file: "section.js",
         sources: ["foo.js", "bar.js"],
         names: ["src", "maps", "are", "fun"],
         mappings: "AAAA,E;;ABCDE;"
       }
     }
    ],
}
While a more traditional “section-less” format, that works with Sentry, looks like:
{
"version" : 3,
"file": "out.js",
"sourceRoot": "",
"sources": ["foo.js", "bar.js"],
"sourcesContent": [null, null],
"names": ["src", "maps", "are", "fun"],
"mappings": "A,AAAB;;ABCDE;"
}
(some info on source-maps formats I found https://sourcemaps.info/spec.html) I went through the shadow-cljs code (https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/output.clj#L355-L375) but I didn’t find any option to output source-maps in “section-less” format so I tried to convert it in {:shadow.build/stage :flush} build hook. However, the naive merging sections back to the top-level map didn’t work - it went past initial sentry’s parsing error "Sourcemap was invalid or not parseable" but then it hit errors like "Invalid location in sourcemap: (37101, 117)". my naive (not working) attempt:
(defn flatten-source-map [path]
  (let [source-map (-> (io/file path)
                       slurp
                       ch/decode)
        sections (get source-map "sections")]
    (->> sections
         (reduce (fn [acc section]
                   (-> acc
                       (update-in ["names"] (fnil into []) (get-in section ["map" "names"]))
                       (update-in ["mappings"] #(if (not-empty %)
                                                  (str % ";" (get-in section ["map" "mappings"]))
                                                  (get-in section ["map" "mappings"])))
                       (update-in ["sources"] (fnil into []) (get-in section ["map" "sources"]))
                       (update-in ["sourcesContent"] (fnil into []) (get-in section ["map" "sourcesContent"]))))
                 (dissoc source-map "sections"))
         ch/encode
         (spit path))))

(defn shadow-cljs-after-build-hook
  {:shadow.build/stage :flush}
  [build-state]
  (let [{:shadow.build/keys [config mode]
         :shadow.build.modules/keys [module-order]} build-state
        {:keys [output-dir]} config
        filename (-> module-order
                     first
                     name
                     (str ".js.map"))
        path (str output-dir "/" filename)]
    (when (= :release mode)
      (println "shadow-cljs-after-build-hook running (flatten-source-map " path ")")
      (flatten-source-map path)))
  build-state)
I was wondering whether I should try to facilitate some functions from https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/source_map.clj or try to tweak shadow-cljs config but that appears to be a deep hole to dig in, and I feel kinda out of my depth. I would much appreciate any help/hints on what direction to pursue so shadow-cljs’s source-maps can work on Sentry. Thank you! clojure-spin
#2022-04-2510:12thheller@pt.roterski the source map mappings encode in them line number information. so basically each section acts as an offset for that line information. as such without the offset and just concatenating the mappings does not work. you could rewrite source maps by adjusting those mappings accordingly in theory but I have never attempted to do so#2022-04-2510:13thhellerwhat issue exactly does sentry have with this? I mean sections aren't exactly new and as far as I can tell all browsers support them? even common JS libs like source-map do?#2022-04-2510:27Piotr RoterskiThanks for the swift response @thheller! I understand that sections are widely supported (and they work for this code in my browser) but not by Sentry apparently and their error output is really poor (literally just those two strings "Sourcemap was invalid or not parseable" and then "Invalid location in sourcemap: (37101, 117)") which makes debugging it difficult. I’ve also tried their validation tool https://docs.sentry.io/platforms/javascript/sourcemaps/validating/ but it also just fails with no descriptive stacktrace so my guess is that “sections” format is just not supported by them and I need to convert the source-maps to “section-less” format (because the same codebase’s source-maps used to work there before the transition from lein+figwheel to shadow-cljs build). Thank you for the hint, I’ll try to improve my flatten-source-map function based on that.#2022-04-2510:29thhellerdo yourself a favor and don't do it as a hook though#2022-04-2510:30thhellerjust write a function that takes an already generated .map file and spits out a new one#2022-04-2511:04Piotr RoterskiI guess that's the thing I already try to do in this hook, and the :flush hook seemed just like a convenient place to do it but I guess it could be called from different place as well#2022-04-2511:06thhellerI'd recommend calling it from the REPL while developing#2022-04-2510:30thhellerthis doesn't need to happen during a shadow-cljs build#2022-04-2510:31thhellerif you get to a working solution and wish to share it we can talk about having shadow-cljs spit this out directly#2022-04-2510:31thhellera build hook just isn't the place to do this#2022-04-2510:38thhellerhmm yeah that website for validating is useless. just threw the shadow-cljs UI map at it and just gave me
Errors 1
InvalidSourceMapFormatError
Invalid SourceMap format: "." is not in the SourceMap.
#2022-04-2510:38thhellerno clue where it gets "." from. no complaints about sections though?#2022-04-2510:40thhellerpretty sure this is just the source-map npm package wrapped in a bad website#2022-04-2510:53thhellerwhat leads you do believe this is about sections?#2022-04-2511:01Piotr RoterskiThe previous lein+figwheel build had "section-less" source-map format and it worked, the shadow-cljs's source-maps use sections format so I assumed that's the cause but of course I might be wrong about it and it could be something else :thinking_face:#2022-04-2511:03thhellerthe lein+figwheel likely also had much smaller source map due to all cljsjs packages being unmapped#2022-04-2511:05thhellerI mean you can just trim down the source map by removing all except the last sections entry#2022-04-2511:05thhellerthe early sections are all for npm packages so maybe the error also goes away if you remove them?#2022-04-2511:05Piotr RoterskiI can try doing that#2022-04-2511:14thhellerjust checked https://github.com/getsentry/sourcemaps.io/blob/master/server/package.json#2022-04-2511:14thhellerand it is indeed just using the source-map npm package for the validation. source-map definitely supports sections just fine, so must be something else#2022-04-2511:20thhellerthis entire website seems completely useless, just check one of their own examples#2022-04-2511:20thhellerhttps://sourcemaps.io/report/1650885603858_https%3A%2F%2Fcdn.ravenjs.com%2F3.17.0%2Fraven.min.js#2022-04-2511:20thhellerwho is supposed to make sense of these errors 😉#2022-04-2511:23Piotr Roterskiyeah, it’s a bit of a hit-or-miss debugging game 🐛 🔨 more than anything#2022-04-2513:51pinkfrogHi. Is it possible to specify the autobuild part in shadowcljs.edn file
(shadow.cljs.devtools.api/watch :app {:autobuild false})
#2022-04-2618:52thhelleractually I forgot. you can set :devtools {:autobuild false} in your build config and that would be same as above#2022-04-2622:16pinkfrogi’d believe that’s not documented in the manual.#2022-04-2514:09thhelleryou mean disable it? no.#2022-04-2516:58cldwalkerHi. Is it possible to run shadow-cljs compilation using a shadow-cljs.edn from another directory? I tried passing it to --config-merge but the builds aren't recognized and I get an error like
{:build-id :modules, :known-builds #{}}
ExceptionInfo: no build with id: :modules
#2022-04-2517:01thhellerI guess the answer is no? can give a better answer if you provide more details about what you are trying to do specifically#2022-04-2517:04cldwalkerSure. I'm building a bb lib which will allow users to build custom versions of https://github.com/babashka/nbb. The users of this lib will be running shadow-cljs from their own project but will want to pull in https://github.com/babashka/nbb/blob/main/shadow-cljs.edn as their initial config#2022-04-2517:06cldwalkerI can workaround this by copying the shadow-cljs.edn before compilation and deleting after but it would be nice if there was a way to just point shadow to use the config from the lib directory#2022-04-2517:07thhelleryou cannot do with any default build commands#2022-04-2517:07thhellerbut you can manually call all the API build functions with a build config map you created yourself by any means#2022-04-2517:08thhellernot sure what problem this is supposed to solve though. what is the point of a custom nbb version?#2022-04-2517:09cldwalkerOk. No worries. I'll probably rely on my suggested workaround for now#2022-04-2517:11cldwalkerShip versions of nbb with X number of features/libraries enabled on the classpath. There are a large number of cljs libraries that aren't sci compatible yet#2022-04-2517:14cldwalkerWill be pretty neat when nbb has this ability as users will be able to put preconfigured features/libraries on the classpath like https://github.com/babashka/nbb/tree/main/features and build a version of nbb that just works with those libraries#2022-04-2517:17thhelleryeah, sorry I still don't get why anyone wouldn't just do a regular build (eg. with shadow-cljs) and then use the generated output#2022-04-2517:17thhellerwhich will no longer depend on the build tool used, or incur any cost regarding to that on startup and such#2022-04-2517:18thhellerI get the ad-hoc scripting part being nice and fast feedback#2022-04-2517:18thhellerI don't get it at all for any kind of deployment or published library#2022-04-2517:34cldwalker> yeah, sorry I still don't get why anyone wouldn't just do a regular build (eg. with shadow-cljs) and then use the generated output This probably comes down to the type of users you're thinking of. In my case I'm largely focused on supporting cljs beginners who will only write a couple small ad-hoc scripts and nothing else#2022-04-2517:36cldwalkerA lot of their scripts will use datascript which has a much better cljs api than js one so just giving them a batteries-included approach to write their scripts saves them time#2022-04-2517:40thhellerwouldn't a REPL make more sense for teaching purposes?#2022-04-2517:40thhellerI mean you have a plan so go build it. I'm by no means the target audience so I don't have to get it 😉#2022-04-2517:58cldwalkerHehe. Happy to explain, especially to someone like you who's been so key in making cljs and nodejs work so smoothly together. We're a cljs editor, https://github.com/logseq/logseq and almost all our users are only familiar with nodejs. Distributing a nbb-like lib will allow them to not only run adhoc scripts with a larger part of the datascript API but also let them do useful things like run CI jobs, without having to think of compilation#2022-04-2609:12Franklinhello 👋 how can I use dependencies in local lein projects? something similar to https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies#2022-04-2611:56tughI think you can use shadow-cljs + deps for this. https://github.com/thheller/shadow-cljs/issues/711#2022-04-2613:55Franklinthanks!#2022-04-2617:17thhellerjust use lein checkouts if you use lein#2022-04-2709:14pmooserI've got a hot code reloading question. I'm still in the process of trying to completely move away from the bootstrap build in shadow-cljs since it seems to create problems. I'm trying to integrate with borkdude's sci, which thus far seems relatively straightforward. I'm building a cljs repl using sci inside my application, which requires me to use a :dev/after-load hook to update sci's namespaces when I make an edit to my local cljs code while developing. The issue that I am having is, if I add a var to one of my normal cljs namespaces, when I tell sci to rebuild its namespace from the cljs one, it doesn't see the new var, unless some other one of my cljs namespaces makes an explicit reference to var. I imagine you don't necessarily know anything about sci, but can you tell me if there is anything unusual with hot code reloading related to creating a new var and having it be visible in a namespace?#2022-04-2709:33pmooserThat newly-created var is accessible from the js console directly. I'm having trouble figuring out how to re-require a namespace (since require can only be called at the top-level) to have the new var appear in my cljs namespaces.#2022-04-2712:51Jakub Holý (HolyJak)Hello! Is there docs for shadow's api somewhere? I remember there was some function to load resources? I guess I was looking. for https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/resource.clj#L53#2022-04-2714:45sansaripNot sure about API docs but hopefully you’ll find this info helpful 👇 I actually had to use this last night from a CLJS namespace in order to inform shadow to watch some markdown files:
(shadow.resource/inline "./relative/path/to/file.md")
It’s important to note that inline resolves the file relative to the file holding the namespace that’s calling inline - if that makes sense. Also, the argument to inline must be a string literal. If you need to load file paths dynamically, then you’ll need to create a macro like so:
(defmacro watch-corpus-files
     "Emits code that informs shadow-cljs to watch the corpus files for changes"
     []
     (let [file-paths (corpus-file-paths)]
       `(do 
#2022-04-2715:01Jakub Holý (HolyJak)Thank you!#2022-04-2716:11thhellerhttps://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-04-2716:15thheller@U022T96EFV3 if you don't actually need the inline, you can maybe do what I described in the post above. just the metadata is enough, inline itself is not important#2022-04-2716:19sansaripAhhh, very true! The metadata approach is perfect for me :thumbsup:#2022-04-2717:12Jakub Holý (HolyJak)@thheller thank you for the link! Is this information also somewhere in the Developer Manual (where I was looking for it, but without knowing the right keywords to search for)?#2022-04-2717:36thhellerit is not no. I guess I never officially made a feature#2022-04-2717:21pmooser@thheller I see there's a way to tag a namespace as always to be reloaded, but is there a way to do the same thing at the function level?#2022-04-2717:34thheller@pmooser no, only namespaces. I have indeed be thinking about something more fine grained but its a fairly complicated change to all caching code which I'd like to avoid for now#2022-04-2718:16sheluchinI have a user namespace that I use in development, activated with :init-ns user at the top level. I'm trying to make my first release build, so in the :main build I reset the REPL ns with :devtools {:repl-init-ns shadow.user, but it's still loading my user namespace for some reason. I use this same command to trigger the release build: https://github.com/fulcrologic/fulcro-rad-demo/blob/develop/Makefile#L8= Any idea why it's still starting with user? I have dev tools required in there that I don't want in a release.#2022-04-2718:24thheller@alex.sheluchin I don't know what "starting with user" means. what is you build config?#2022-04-2718:38sheluchinBy that I mean that it loads the user namespace. I expect that if :repl-init-ns sets some other ns, user doesn't get loaded. But ofc that's not a valid expectation if repl-init-ns isn't relevant in release builds.
:builds   {:main     {:target     :browser
                       :output-dir "resources/public/js/main"
                       :asset-path "/js/main"
                       :dev        {:compiler-options {:external-config {:guardrails {:emit-spec? true :throw? false}}}}
                       :modules    {:main {:init-fn com.example.client/init}}
                       :js-options {:resolve
                                     "@js-joda/timezone"
                                     {:target  :npm
                                      :require "@js-joda/timezone/dist/js-joda-timezone-10-year-range.min.js"}}
                       :devtools {:repl-init-ns shadow.user
                                  :preloads   [com.fulcrologic.fulcro.inspect.preload
                                               com.fulcrologic.fulcro.inspect.dom-picker-preload]
                                  :after-load com.example.client/refresh
                                  :repl-pprint true}}
#2022-04-2718:39thhellerYou mean the clojure user namespace I assume. that is always loaded by clojure, not controllable by shadow-cljs or anything else#2022-04-2718:39sheluchinYes, that is what I mean.#2022-04-2718:40sheluchinHmm, I thought it could be changed through the repl-init-ns setting. Guess I'm missing something foundational.#2022-04-2718:42thhelleras I said. clojure will load this unconditionally, before shadow-cljs even gets a chance to do anything#2022-04-2718:42thhellerthe common strategy is to not have a user.clj on the classpath for CLJ projects#2022-04-2718:42thhellerbut since you asked about a CLJS release build I'm not sure how any of this is relevant?#2022-04-2718:46sheluchinSorry, I think I'm a little mixed up about what shadow does exactly. It uses the JVM and the main part is built in Clojure, but it only produces CLJS builds? Is that correct?#2022-04-2718:47thhelleryes, it is a build tool for CLJS#2022-04-2718:51sheluchinlol I know it's in the name and all 🙂 but I think all of the JVM-specific references in the docs made me confused about the boundaries of the tooling. When the docs are talking about using Clojure CLI to manage :source-paths and :dependencies (when using deps.edn), that is talking about CLJ only, not CLJS?#2022-04-2718:52thhellermaybe this helps https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2022-04-2718:53thheller:source-paths and :dependencies apply to CLJS in exactly the same way as CLJ#2022-04-2718:58sheluchinOkay, thanks for the link and tips. I'll have a good read through that after some lunch and try making a build again.#2022-04-2718:24thhellerrepl-init-ns irrelevant for release builds#2022-04-2719:41fullNameHereHey yall, I followed these steps lein new reagent-frontend myproject +shadow-cljs cd myproject npm install npx shadow-cljs watch app and everything works, repl starts and compiles with no errors. Exept when I try and evaluate the ns. (ns rdomissue.core (:require [reagent.dom :as d])) Only reagent.dom gives me an error ; Could not locate reagent/dom__init.class, reagent/dom.clj or reagent/dom.cljc on classpath. Anyone know how to fix this? github repo: https://github.com/SantoHerrera/issueswithrepl#2022-04-2804:56thheller@santosx99xx that is a Clojure error. So you are connected to a clojure REPL. you first need to switch to the CLJS REPL from that CLJ REPL. dunno what editor you use https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration#2022-04-2805:40fullNameHereI'm using vs code and calva#2022-04-2813:29wombawombaSo I've built a nice little in-browser REPL using cljs_eval for my app, and I'm trying to add autocompletion to it. Is there a way to get a list of loaded namespaces, either via the standard library (I tried https://cljs.github.io/api/cljs.analyzer.api/all-ns but it doesn't seem to work) or shadow-cljs?#2022-04-2907:09thhellercan't really do this on top of cljs-eval. really need access to the compiler env which is on the clojure side.#2022-04-2907:10wombawombaThere's no way to smuggle in a clojure command from the browser?#2022-04-2907:11wombawombaI'm okay with finding a hacky approach to this; doesn't need to go through cljs_eval#2022-04-2908:14thhellerwell the common tools people use for autocomplete and such all run over nrepl#2022-04-2908:14thhellerthere is no direct way to gain access to nrepl from the browser though#2022-04-2908:14wombawombaMaybe there should be? ;)#2022-04-2908:16thhellerI don't like nrepl at all so I would be building this kind of thing over shadow.remote#2022-04-2908:16wombawombaYou've been working on some really cool browser-based stuff with the shadow-cljs UI. It seems to me like you could come up with a lot of use-cases for something like that#2022-04-2908:17thhelleryeah, I do have plans for all of that. just no time to do it all 😛#2022-04-2908:17wombawombaHaha I can imagine#2022-04-2908:17thhellerthe UI also uses shadow.remote for everything, everything it uses you also have access to#2022-04-2908:18thhellerbut yeah totally undocumented and might be changing a lot still 😛#2022-04-2908:19wombawombaCool! Just read the rationale for shadow.remote and I think it sounds great#2022-04-2908:19wombawombaI don't really care if it's undocumented/alpha#2022-04-2908:20wombawombaIf i wanted to use it to do stuff like this, how would I get started? :)#2022-04-2908:20thhellerhttps://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L430#2022-04-2908:20thhellerso cljs-eval already uses it too 😉#2022-04-2908:23thhellerso you would add a namespace to you build loaded via :preloads#2022-04-2908:23thhellerthat would need to call this fn https://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L67#2022-04-2908:24thhellerso (add-plugin! ::foo #{} init-fn stop-fn)#2022-04-2908:25thhellerinit-fn gets one parameter being the environment, including the runtime and all the dependencies#2022-04-2908:25thhellerthe runtime you can use to receive and send messages#2022-04-2908:27thhellerI mean it gets very involved very quickly but the REPL is implemented on top of all of this#2022-04-2908:27thhellerhttps://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/remote/runtime/eval_support.cljs#2022-04-2908:27thhellerhttps://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L383-L386#2022-04-2908:28thhellerbasically you add the plugin, it on init then registers extensions#2022-04-2908:28thhellerand then they talk over the shadow.remote socket#2022-04-2908:29wombawombaalright#2022-04-2908:29thhellerthe entire UI inspect and tap thing are also just plugins https://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L374-L381#2022-04-2908:29thhellerbut yeah not documented anything here and the CLJ side is currently not using this plugin mechanism#2022-04-2908:29thhellerso extending that side is harder#2022-04-2908:30wombawombagot it#2022-04-2908:30wombawombaso if I wanted to add a plugin that (as a first step) lets me list all loaded namespaces, how would I set it up?#2022-04-2908:30thhellerthe worker side on the server implements everything using a multi method#2022-04-2908:30thhellerhttps://github.com/thheller/shadow-cljs/blob/e9093aed586d5fb49efd94555787f0bef08fb164/src/main/shadow/cljs/devtools/server/worker/impl.clj#L688#2022-04-2908:31wombawombafrom what you wrote earlier I assume it has to deal with clj?#2022-04-2908:31thhellerand the worker you'd need to talk to to get autocomplete and stuff#2022-04-2908:31wombawombaalright#2022-04-2908:31thhellerso the clients sends this https://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L248 and the worker handles it in the multi-method above#2022-04-2908:32wombawombadoes all the cljs code you linked run in the browser? or is there a cljs part on the backend too?#2022-04-2908:32thhellerthere is no cljs part in the backend no#2022-04-2908:33wombawombaokay, great#2022-04-2908:33wombawombaI think this should be enough to get me started#2022-04-2908:33wombawombaare there any specs or similar that describe the messages being passed around here?#2022-04-2908:34thhelleryou probably shouldn't use any of the existing messages so no#2022-04-2908:34thhellerbasically you would (defmethod impl/do-relay-msg ::my-auto-complete [worker-state msg] ...) somewhere in your code on the CLJ side#2022-04-2908:34wombawombaalright, so my messages can be arbitrary data?#2022-04-2908:35thhelleryes, just clojure maps#2022-04-2908:35thhellerthe two mandatory fields you need are these#2022-04-2908:35thhellerhttps://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/cljs/devtools/client/shared.cljs#L248-L249#2022-04-2908:35wombawombawhat about e.g. the stuff that gets passed to the add-plugin fns?#2022-04-2908:35thhellerso an :op you choose and the :to#2022-04-2908:35wombawombaany specs for that?#2022-04-2908:35wombawombagot it#2022-04-2908:36thheller:to tells it to direct the messages to the worker, which can then answer via the multi-method#2022-04-2908:37thhellerthe multi-method must return the worker-state it gets. in the worker-state there is a :build-state which has :compiler-env#2022-04-2908:37thhellerwhich has the :cljs.analyzer/namespaces you'd want to look at for autocomplete#2022-04-2908:39wombawombaokay#2022-04-2908:40wombawombahey also, do you think it would be possible to use this approach to get require working from my browser-based repl?#2022-04-2908:42thheller
(add-plugin! ::plugin #{}
  (fn [{:keys [runtime] :as env}]
    (api/add-extension runtime ::auto-complete {})

    (shared/call runtime
      {:op ::complete-me
       :to env/worker-client-id
       :foo "bar"}
      
      {::complete-result
       (fn [msg]
         (js/console.log "result from worker" msg))})

    env)

  (fn [{:keys [runtime]}]
    (api/del-extension runtime ::auto-complete)))
#2022-04-2908:42thhellerbasic could look something like this on the client side#2022-04-2908:43wombawombaalright, thanks#2022-04-2908:43wombawombaseems straightforward enough 🙂#2022-04-2908:43thheller
(defmethod impl/do-relay-msg ::complete-me
  [worker-state {:keys [foo] :as msg}]
  
  (impl/relay-msg worker-state msg
    {:op :complete-result
     :yo []})

  worker-state)
#2022-04-2908:43thhellerserver side#2022-04-2908:44thhellernote that you need to add the multi-method implementations before starting the worker#2022-04-2908:44thhellerotherwise it may not pick them up properly#2022-04-2908:44thhellerwhat do you mean get require working? cljs-eval can require just fine?#2022-04-2908:45thhellerbut yeah, given that the entire REPL is based on this you can do whatever too#2022-04-2908:45wombawombahmm okay#2022-04-2908:45wombawombaI had some problems with require earlier, but it might just have been an error on my part#2022-04-2908:45wombawombaI'll take a closer look at it#2022-04-2908:46wombawombaanyway thanks; looking forward to testing this out 🙂#2022-04-2814:24pinkfrogI develop in calva, and the jack in command of calva with launch shadow with the command like this
npx shadow watch :app
The issue is, whenever I run the vscommand Developer reload window. And after the new vscode window show up, and then if I perform a jack in, it will say
shadow port already taken
I suspect this might be related to the shadow server mode. In all, is it possible to tell shadow to quite when vscode quits (to be exact, window reloads) ?
#2022-04-2815:01pezI think these are Calva issues. Please feel invited to post in #calva about it.#2022-04-2815:03pezOh, the reason I don't just help you here is that I am short on time. But hopefully in the #calva channel someone else can help.#2022-04-2815:06pinkfrogThanks. I will repost this in #calva.#2022-04-2815:33sheluchinI don't understand it, but as long as I have :extra-paths ["src/dev"], and there's an empty (ns user) in there, it builds. Otherwise it gives me an exception.
:shadow-cli {:extra-paths ["src/dev" "resources"]
                        :extra-deps
                        {thheller/shadow-cljs {:mvn/version "2.16.12"}
                         binaryage/devtools {:mvn/version "1.0.0"}}
                        :main-opts ["-m" "shadow.cljs.devtools.cli"]},
$ tree src/dev/
src/dev/
└── user.clj

0 directories, 1 file

$ cat src/dev/user.clj
(ns user)
I don't want dev on my classpath at all for release, so I shouldn't need it as an :extra-path.
#2022-04-2817:10thheller@alex.sheluchin what exception would that be? I assume you just have another user.clj on some other :paths. by just adding src/dev you are effectively overwriting that one#2022-04-2817:11sheluchinhttps://clojurians.slack.com/files/UPWHQK562/F03CX51NS8P/untitled.cpp It's the only user.clj I have actually.#2022-04-2817:13sheluchin
$ find . -iname "user.clj"
./src/dev/user.clj
#2022-04-2817:30thhellerthe find doesn't mean anything since I don't know your full classpath setup#2022-04-2817:31thhellerbut none of the above is related to shadow-cljs in any way#2022-04-2817:31thhellerjust try running clj -A:shadow-cljs#2022-04-2817:31thhellerI assume that gives you the same errors?#2022-04-2817:33thhellerif you try (enumeration-seq (.getResources (.getContextClassLoader (Thread/currentThread)) "user.clj"))#2022-04-2817:33sheluchinI assume you mean clj -A:shadow-cli because that's the name of the alias I have. Nope, it doesn't give me errors.#2022-04-2817:35sheluchin
(#object[java.net.URL 0x2e01e8ae "file:/home/alex/repos/personal-projects/example/src/dev/user.clj"])
#2022-04-2817:42thhellerand without this file?#2022-04-2817:42thhelleror just without src/dev declared?#2022-04-2817:43sheluchinIf I don't include :extra-paths ["src/dev"], that's when I get the above exception.#2022-04-2817:44thhellerand you are running this all directly from the command line directly AND manually#2022-04-2817:44thhellerno editor involved of any kind? or any other tool supposed to "help out"#2022-04-2817:45thhellerI mean something must trigger the loading of all that stuff in the exception.#2022-04-2817:45thhellerthere seems to be a socket server involved in some way?#2022-04-2817:48sheluchinI am running it from my command line, no editor. When you gave me that snippet to look for user.clj, I used clj -A:shadow-cli clj-repl to evaluate it.#2022-04-2817:50thhellerthat already does too much#2022-04-2817:50thhellerI meant literally clj -A:shadow-cljs#2022-04-2817:50thhellermaybe need to comment out the :main-opts in deps.edn#2022-04-2817:50thhellerjust trying to narrow down on when and how the error happens#2022-04-2817:51thhellermight also be related to core.async in some way. or some AOT classes you have somewhere#2022-04-2817:51sheluchinYou do mean :shadow-cli as I have it in my shadow-cljs.edn, yeah?#2022-04-2817:51thhellerI'm only guessing since I can't see your full setup#2022-04-2817:52thhellerI assume you mean deps.edn. yes, that one#2022-04-2817:52thhellerI mean you can just go with clj. that should be fine as well#2022-04-2817:52thhellertrying to get you to a blank clojure REPL that doesn't crash on startup somehow#2022-04-2817:52thhellerdo you have other :main-opts or :jvm-opts configured in your deps.edn?#2022-04-2817:54sheluchinNot at the top level, only under aliases that I'm not activating.#2022-04-2817:56sheluchin#2022-04-2817:58sheluchin#2022-04-2817:58thhellerso what happens with just clj or clj -A:dev#2022-04-2817:59sheluchinSame exception. Unless I add src/dev.#2022-04-2817:59sheluchinShould I take this to #clojure instead? I guess this rules out shadow.#2022-04-2818:00thhellerdo you have anything in ~/.clojure/deps.edn?#2022-04-2818:01thhelleror I guess you can try clj -Srepro -A:dev to rule that out?#2022-04-2818:02thhellerI mean your entire setup is full of red flags for me but should still be possible to figure out exactly what is causing your issues#2022-04-2818:03sheluchinI've been making do with it for local dev, but now that I'm looking at deployment stuff is indeed screaming at me.#2022-04-2818:04sheluchinYes, I do have some stuff in my global deps:
{:aliases
 {:cider-clj
  {:extra-deps {org.clojure/clojure {:mvn/version "1.10.1"}
                cider/cider-nrepl {:mvn/version "0.21.1"}}
                ; fipp {:mvn/version "0.6.23"}}
   :main-opts ["-m" "nrepl.cmdline"
               "--middleware" "[cider.nrepl/cider-middleware]"]}
  :cljs
  {:extra-deps {nrepl/nrepl {:mvn/version "0.7.0"}
                cider/piggieback {:mvn/version "0.4.1"}}}
                ; fipp {:mvn/version "0.6.23"}}}
  :nREPL
  {:extra-deps {nrepl/nrepl {:mvn/version "0.8.1"}}}
  :repl/reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.3.270"}
                             lambdaisland/deep-diff2 {:mvn/version "2.0.108"}}
                :ns-default vlaaad.reveal
                ;; note Fira Code is a ligature font so it's not supported in Reveal, whjch only uses monospaced
                :jvm-opts   ["-Dvlaaad.reveal.prefs={:theme,:light,:font-family,\"Fira Code\",:font-size,8}"]
                :repl-options {:nrepl-middleware [vlaaad.reveal.nrepl/middleware]}
                :exec-fn repl}}}
#2022-04-2818:04thhelleras long as its still is aliases that aren't activated that is fine#2022-04-2818:05thhellerdid you at some point experiments with AOT maybe? are there a lot of .class files in your project somewhere?#2022-04-2818:09sheluchinNot that I am aware of. I can't find any .class files from my root and I haven't knowingly used any AOT stuff. Should I try just blowing away my .m2 and pulling everything anew?#2022-04-2818:09thhellercheck which core.async` version you end up with just in case#2022-04-2818:10thhellerclj -A:dev -Stree or so#2022-04-2818:12thhellernevermind I'm seeing things. those are spec issues not core.async#2022-04-2818:13thhellerI mean yeah killing your .m2 might help in some way#2022-04-2818:14sheluchinI have a largely unfounded suspicion this is somehow related to https://github.com/fulcrologic/guardrails, but don't really have any evidence to back up the hunch.#2022-04-2818:16thhellercould be, but finding how it gets loaded would help#2022-04-2818:17sheluchinLet me kill .m2.#2022-04-2818:19sheluchinSorry for the noob troubles being so time consuming here @U05224H0W. Thank you for helping out.#2022-04-2818:23sheluchinI think it worked...#2022-04-2818:26sheluchinI have no idea how I could have broken anything in the Maven cache. I guess I'll just get in the habit it nuking it when things stop working smoothly.#2022-04-2818:28sheluchinIs there some way I could verify the output to make sure it built correctly?#2022-04-2820:08p-himikHuh. Moved some JS files from <script>s in index.html inside the compiled bundle, and now I can't build my project on Heroku where there's a restriction on memory. The stack trace doesn't mention shadow-cljs, it even looks like it's been trimmed for some reason because the entry point doesn't make sense.#2022-04-2820:08p-himik
{:clojure.main/message
 "Execution error (OutOfMemoryError) at java.util.Arrays/copyOf (Arrays.java:3537).\nJava heap space\n",
 :clojure.main/triage
 {:clojure.error/class java.lang.OutOfMemoryError,
  :clojure.error/line 3537,
  :clojure.error/cause "Java heap space",
  :clojure.error/symbol java.util.Arrays/copyOf,
  :clojure.error/source "Arrays.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.OutOfMemoryError,
    :message "Java heap space",
    :at [java.util.Arrays copyOf "Arrays.java" 3537]}],
  :trace
  [[java.util.Arrays copyOf "Arrays.java" 3537]
   [java.lang.AbstractStringBuilder ensureCapacityInternal "AbstractStringBuilder.java" 228]
   [java.lang.AbstractStringBuilder append "AbstractStringBuilder.java" 682]
   [java.lang.StringBuffer append "StringBuffer.java" 393]
   [java.io.StringWriter write "StringWriter.java" 122]
   [java.io.PrintWriter write "PrintWriter.java" 541]
   [java.io.PrintWriter write "PrintWriter.java" 558]
   [java.io.PrintWriter print "PrintWriter.java" 685]
   [clojure.data.json$write_string invokeStatic "json.clj" 317]
   [clojure.data.json$write_string invoke "json.clj" 290]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write_array invokeStatic "json.clj" 348]
   [clojure.data.json$write_array invoke "json.clj" 342]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write_object invokeStatic "json.clj" 335]
   [clojure.data.json$write_object invoke "json.clj" 319]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write_object invokeStatic "json.clj" 335]
   [clojure.data.json$write_object invoke "json.clj" 319]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write_array invokeStatic "json.clj" 348]
   [clojure.data.json$write_array invoke "json.clj" 342]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write_object invokeStatic "json.clj" 335]
   [clojure.data.json$write_object invoke "json.clj" 319]
   [clojure.data.json$fn__262$G__257__269 invoke "json.clj" 286]
   [clojure.data.json$write invokeStatic "json.clj" 475]
   [clojure.data.json$write doInvoke "json.clj" 424]
   [clojure.lang.RestFn invoke "RestFn.java" 425]
   [clojure.lang.AFn applyToHelper "AFn.java" 156]
   [clojure.lang.RestFn applyTo "RestFn.java" 132]
   [clojure.core$apply invokeStatic "core.clj" 671]],
  :cause "Java heap space"}}
#2022-04-2820:11p-himikThere are some places in shadow-cljs where JSON writing could easily be made more memory efficient, like e.g. in this code:
(spit target
  (json/write-str sm-index))
But given the stacktrace, it's completely unclear where exactly the right place for an improvement would be...
#2022-04-2905:40thhellerjust set something like :jvm-opts ["-Xmx2G"] when building#2022-04-2905:40thhellerwhich java version is this using? older JVM versions didn't detect container memory correctly, so they used the actual machine memory as a reference#2022-04-2905:41thhellerwhich often ends up consuming way more than allocated to the container image#2022-04-2905:41thhellerif you use a newer jvm version that usually sorts itself out too, older require manual settings#2022-04-2905:42thhellerfine to leave this in always, shadow-cljs doesn't really need that much memory. the default jvm settings are a bit greedy#2022-04-2905:42p-himikYeah, that would require doubling my client's spending on Heroku because AFAIC you can't get a separate build dyno - it all runs with the same limits and the current RAM limit is 1 GB, which is plenty for the app itself. JDK 17#2022-04-2905:43thhellerhmm then maybe your build is actually too large an breaks the build 😉#2022-04-2905:43p-himikI'll probably switch to building an uberjar or a full-on container locally. It's been a long time coming.#2022-04-2905:43thhellernever ever inline json files by the way if they are above 20 bytes or something#2022-04-2905:43thhelleroh nvm it was the source map generation#2022-04-2905:43p-himikWell, I do inline KBs worth of static data in other projects - where it really makes sense. :) But not here.
#2022-04-2905:45thhelleryeah dunno. I've seen it do big builds with just one gig allocated#2022-04-2905:47p-himikFWIW the resulting release bundle is 5 MB and the source map is 29 MB. No clue where it's at on the "big builds" scale.#2022-04-2906:15thhelleryeah release source maps can get a bit out of hand#2022-04-2908:57pmooser@thheller If there are multiple functions in a namespace with :dev/after-load on them, is there any way to control the order of those calls? Or is it just top to bottom? Or some random order?#2022-04-2908:58thhellersimply don't have multiple of them?#2022-04-2908:58thheller
(defn ^:dev/after-load a [])
(defn ^:dev/after-load b [])

;; instead

(defn ^:dev/after-load reload []
  (b)
  (a))
#2022-04-2908:59thhellerlike so?#2022-04-2908:59pmooserOk, nice idea - thanks. That's definitely something I can work with.#2022-04-2909:00thhellerotherwise the order is undefined, given that it is constructed from analyzer data which is an unordered map#2022-04-2912:01roman01laIs it expected that a custom warning is not picked up by analyzer in release build? While it's working as expected in dev build. Not sure if it's cljs compiler itself or something is shadow-cljs. It's not clear why it's different from dev to release builds. I guess normally one should put custom warning names into compiler options.#2022-04-2912:07roman01laNevermind, works fine :thumbsup:#2022-04-2912:07roman01laNevermind, works fine :thumbsup:#2022-04-2917:20colinkahnCurious if the next release of shadow-cljs will be on 1.11 (Clojure)?#2022-04-3004:48thheller@colinkahn why does it matter? shadow-cljs s=hould run with pretty much any clojure version and I will not begin to use 1.11 features anytime soon since I don't want to force people to upgrade#2022-04-3021:51colinkahnI ran into the case where I have .cljc files where I want to use :as-alias , which appear to get loaded in the Clojure runtime (not sure the right word) and so they fail before ClojureScript is ever compiled.#2022-04-3021:53colinkahnMaybe some explicit flag to disable stopping usage of different Clojure versions with shadow? Like dangerously-allow-clojure-override or something?#2022-04-3022:01colinkahn> shadow-cljs should run with pretty much any clojure version > So I believe, to my comment above, there is a check within shadow to prevent overriding with a different Clojure version @U05224H0W#2022-05-0104:26thhellerI'll just upgrade the clojure version. doesn't really matter for shadow-cljs but will help with your :as-alias#2022-05-0116:41colinkahnThank you!#2022-04-3012:26USPROHi, I created a re-frame app with
lein new re-frame deneme +cider
npm install
but when I try to build it without any changes (npx shadow-cljs watch app) it doesn't compile and gives https://bin.gy/rateersari error Anyone know how to fix this?
#2022-04-3013:04thheller@uspro looks like your download of the closure compiler got corrupted somehow. try deleting the ~/.m2/repository/com/google/javascript directory#2022-04-3013:16USPROstill the same error after deleting it and re-running npx shadow-cljs watch app#2022-04-3013:24thhellerhmm odd. works fine for me#2022-04-3014:41thhellerwhat is the exact size of your ~/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220301/closure-compiler-unshaded-v20220301.jar?#2022-04-3014:42thhellershould be 13062504 or shasum 050e125feb326b6c7638e4c970bdd1ecd64a4b5e#2022-05-0109:44p-himikOh wow I just had an issue that made me think I was going insane. Trying to migrate my release build process so it uses Docker containers. Ran podman build ..., got an image, but... the build artifacts aren't there. So RUN npm run buid-ui works just fine but RUN ls target/prod shows no files. As you can probably guess, the build-ui NPM script relies on shadow-cljs run. Turns out, running shadow-cljs run within a container actually uses a shadow-cljs server instance outside the container, if there's one running.#2022-05-0109:48thhellerhmm did you mount the .shadow-cljs dir in the container? otherwise it shouln't be able to find or use the outside server?#2022-05-0109:59p-himikNo mounts at all, only COPY statements and .shadow-cljs is ignored. I'll have to debug it a bit further before understanding why it works that way. Maybe it's intentional, or maybe there's something wrong with podman build.#2022-05-0110:00thhellerhttps://github.com/thheller/shadow-cljs/blob/60d071ad968465ad69c2bef3ba64ff056ce09850/src/main/shadow/cljs/npm/cli.cljs#L858-L866#2022-05-0110:00thhellerthats the only thing that is checked whether or not a server is used#2022-05-0110:00thhellerif they don't exist then it doesn't go out looking for a server at all#2022-05-0110:04p-himikThanks. Hmm, seems like "`.shadow-cljs` is ignored" statement is incorrect... The way I was reading docs and discussions about .containerignore, all dot files are ignored by default. But apparently that's not the case, so I gotta fix that.#2022-05-0117:57p-himikAn unrelated issue - after upgrading to 2.18.0 (I think), I started getting this warning about at least once a day, regardless of whether I actually follow the recommendation in it:
Browserslist: caniuse-lite is outdated. Please run:
  npx 
No clue whether it's something on the shadow-cljs' side at all.
#2022-05-0118:35thhellerfixed recently. will be gone with next release#2022-05-0206:10huygnI'm picking up next-cljs repo 👀 , fun stuff!#2022-05-0206:35thhellermeh, that is severly outdated by now. would probably be best served by a custom :target build on top of :target :esm or so https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-05-0206:42huygnoh, how would I be able to export my pages fn without having to specify all of them in :exports config? :thinking_face:#2022-05-0206:47thhellercan't say. custom :target could maybe generate it somehow. haven't looked at next.js since making that repo. no clue what it looks like nowadays#2022-05-0206:53huygnIs there a doc for using custom :target? 🙏 also I'm targeting Remix not Next.js but both are file-based routing & expect some default exports per page file#2022-05-0207:00thhellerno docs no. only reference is all the default targets https://github.com/thheller/shadow-cljs/tree/master/src/main/shadow/build/targets#2022-05-0207:09huygnI'll give that a try 👌#2022-05-0207:06promesantehi guys, I'm trying to start a little project with shadow-clj / re-frame / emacs / cider with the re-frame template, https://github.com/day8/re-frame-template with lein. Opening the repl from within Emacs (C-c M-j) works ok, but when invoking any function, in different namespaces, I keep getting the same error reported:
Syntax error compiling at (*cider-repl flexiana/scrambler-fe:localhost:8777(clj)*:50:20).
Unable to resolve symbol: init in this context
and no Clojure / REPL related Emacs shortcut works, i.e. C-c C-k to compile and load current buffer, or C-c C-z to jump straight into REPL.
#2022-05-0207:07promesanteI tried the same with the front-end / SPA module of the following little Clojure fullstack project I've taking as reference: https://github.com/lagenorhynque/clj-rest-api-and-cljs-spa-example, SPA: https://github.com/lagenorhynque/clj-rest-api-and-cljs-spa-example/tree/master/todo-app, but in that other context, I keep getting exactly the same issues described above.#2022-05-0207:08promesanteFuthermore, as I start up the SPA from CLI as explained in its README:
$ npm install
$ npx shadow-cljs watch app
the SPA works well, but when started up by starting up the REPL from Emacs (C-c M-j), the SPA runs, but reporting the following warning:
shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-clj instance. Is the watch for this build running?
#2022-05-0207:25thhellerthe stale error you likely get because you have 2 separate shadow-cljs instances running for the project at the same time. interfering with each other. when you have the watch running separately you need to "connect" in cider, not "jack-in".#2022-05-0207:07thheller@lmrosso you are in the Clojure REPL. that needs to be switched to CLJS first. can't say how to do that in emacs. don't know how current this is https://shadow-cljs.github.io/docs/UsersGuide.html#cider#2022-05-0207:10promesantehi @U05224H0W, thanks for such a quick reply, let me take a look...#2022-05-0215:50promesantehi @U05224H0W, yes, that was one of the very few docs I was able to find out and, as far as I understand, I've taken into account in this config#2022-05-0215:52thhellerI cannot comment on any cider related issues. I don't use emacs so I really do not know. all I can see from the screenshots is that you are in a Clojure REPL#2022-05-0215:53thhelleras far as shadow-cljs is concerned you switch that via evaling (shadow/repl :your-build-id-here)#2022-05-0215:53thhellerI don't know if cider expects or needs anything on its end#2022-05-0218:07promesanteasking in cider channel as well, but no reply there yet, thanks !#2022-05-0219:06thhellerdid you check https://docs.cider.mx/cider/cljs/shadow-cljs.html#starting-a-shadow-cljs-repl?#2022-05-0219:06thhellerI mean connecting vs jack-in? you didn't describe what you do on the emacs side so maybe there is just something missing there?#2022-05-0313:19pinkfrogQuestion on npm package import. Specifically for this package: https://www.npmjs.com/package/react-deep-force-update. I imported it with:
(ns app.util.dev
  (:require
   [reagent.core :as r]
   ["react-deep-force-update" :as deep]
   ,,,))
I checked the js-keys in deep, but found nothing. How could this happen?
#2022-05-0314:00thheller@i why do you expected keys? maybe you just do (deep)? maybe deep is just a function? or maybe see the usage examples here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-05-0314:03pinkfrogIsn’t (.-default deep) equal to "react-deep-force-update$default ?#2022-05-0314:05thhellerin theory yes. but the package may not be published as actual esm. in which case it might not have default export#2022-05-0314:06thhellerbut for those kinds of packages often react-deep-force-update$default and react-deep-force-update yield the same thing#2022-05-0314:09pinkfrogIt is: https://github.com/gaearon/react-deep-force-update/blob/843afa2c7fcc820c079144c3948bed2784b36f12/src/index.js#L56. My fundamental question is how to invoke the deepForceUpdate function. react-deep-force-update$default gives a nil.#2022-05-0314:12thhellerdon't ever look at the source of a npm package to make guess how about how it is actually published#2022-05-0314:13thhellermy guess is as I said (:require ["react-deep-force-update" :as deep]) and then just (deep) somewhere#2022-05-0314:13thhellerthis is the content of the actual npm package https://unpkg.com/react-deep-force-update@2.1.3/lib/index.js#2022-05-0314:13thhelleresm nowhere to be found, published as commonjs as expected#2022-05-0314:16thhellerit seems to expect an argument. dunno what that is or how you get it though#2022-05-0421:28witekHello. Material UI suggests installing the Roboto font via npm install @fontsource/roboto`` and then importing it via import '@fontsource/roboto/300.css';. What is shadow-cljs equivalent for this? I have tried (:require ["@fontsource/roboto/300.css"]), but this fails to compile:
[:spa] Build failure:
Failed to inspect file
  /p/kunagi-secrets/node_modules/@fontsource/roboto/300.css

Errors encountered while trying to parse file
  /p/kunagi-secrets/node_modules/@fontsource/roboto/300.css
  {:line 2, :column 0, :message "Character '@' (U+0040) is not a valid identifier start char"}
#2022-05-0505:45thheller@witek that is a webpack specific feature. shadow-cljs does not support processing css files like that. you can setup something like postcss to get the font#2022-05-0606:49David VujicOne simplistic approach is to have a command basically copying the css (probably in a “dist” folder within the package in node_modules), and add it as an html tag in your html template. If you don't want to set up a postcss/webpack flow. Something like this in package.json: `"scripts": { "copy-css": "cp ./node_modules/@mylib-xxxx/dist/the-css….css ./public/css/the-css”`#2022-05-0609:25mkvlrhey, 👋 there's no hook for the first initial compile, correct?#2022-05-0610:48Carlohttps://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks comes to mind, but I'm not sure what you're searching for#2022-05-0612:06mkvlryeah, I mean only for the first compile, ie when the app is ready, but I can do it with a compile hook that only does something the first time it's called#2022-05-0615:21thhelleryeah, just put something in the build state so you know it ran already#2022-05-0616:02mkvlris there also an easy way to pass state to https://github.com/nextjournal/clerk/commit/c3b7e36dbd22b823a30159248d293ccb2536fdaf#diff-0715252f101f7970d11ac0d8396c68d292b1f376ad23cffffe7db2fcfa6843bcR15 ?#2022-05-0616:03mkvlrto shadow.cljs.devtools.cli-actual/main I mean or should i be using a different entrypoint?#2022-05-0618:48thhellerwhy are you calling that at all? that is only the entry point for the command line tools. what is the goal there?#2022-05-0618:49thhellermaybe looking for https://shadow-cljs.github.io/docs/UsersGuide.html#embedded?#2022-05-0711:46mkvlrthanks, yeah that’s better. I thought it would be much more work to get the same thing but turns out it’s only two lines 🙃#2022-05-0711:46mkvlronly difference to my invocation via main is that I’m seeing a few extranous log lines
May 07, 2022 1:43:39 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
May 07, 2022 1:43:39 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.8.0.Final
May 07, 2022 1:43:39 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.8.0.Final
May 07, 2022 1:43:39 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.1.0.Final
May 07, 2022 1:43:40 PM io.undertow.Undertow start
INFO: starting server: Undertow - 2.2.4.Final
shadow-cljs - HTTP server available at 
#2022-05-0711:47mkvlrdo you do something in shadow to silence those that I can copy?#2022-05-0713:07thhellerdo you use jvm logging in any way? log4j, logback etc?#2022-05-0713:09mkvlrnot to my knowledge#2022-05-0713:09thhellerthen you can just require this https://github.com/thheller/shadow-cljs/blob/20c75b6b11a64a6910a4f95f4dcae195f76d0562/src/main/shadow/cljs/silence_default_loggers.clj#L1#2022-05-0713:10mkvlrthanks!#2022-05-0713:11thhellerbtw if you drive all this from the clojure api#2022-05-0713:11thhelleryou could get more access to stuff without need a build hook#2022-05-0713:12mkvlrlike a different kind of callback you mean?#2022-05-0713:13mkvlrhave a pointer for this?#2022-05-0713:15thhellerwell. what are you looking to do?#2022-05-0713:16mkvlrdo something after the first flush#2022-05-0713:17thhellerwell shadow.cljs.devtools.api/watch returns when the build finishes. that might be enough?#2022-05-0713:18mkvlroh yes, perfect#2022-05-0713:18thhellerso just (shadow/watch :the-build) (do-stuff) sequentially should be fine#2022-05-0713:18mkvlrshould simplify things a bit, thanks you!#2022-05-0715:40mkvlrmuch nicer: https://github.com/nextjournal/clerk/commit/de32491b390c43e8a66340447a983b888b7e289f Thanks again!#2022-05-0716:01thhellerwhy are you starting 2 nrepl servers? 😛#2022-05-0716:02thhellershadow-cljs starts one. might be useful since that one also supports cljs while the other one does not?#2022-05-0716:31mkvlrdisabled the shadow one and starting it myself in order to start it earlier#2022-05-0716:31mkvlrbut haven't benchmarked the difference yet#2022-05-0716:38mkvlrI've given up on cljs repls#2022-05-0718:40mkvlrbooting only nrepl takes 4-5s on my machine, and nrepl via shadow adds another ~3 seconds…#2022-05-0718:41mkvlranother small things why I’m starting nrepl manually: then the same port file is written regardless of when I use jack-in (for clj-only dev) vs starting only shadow#2022-05-0718:42mkvlrunsure if it might make sense for shadow to delete .nrepl-port when it boots. Maybe after checking that there’s nothing listening on the port but might also be too much magic…#2022-05-0718:56thhellerno, shadow won't delete that file as that would interfere with stuff it doesn't control. it writes its own .shadow-cljs/nrepl.port file#2022-05-0718:57mkvlryeah, but when I kill the process that’s writing .nrepl-port and start shadow afterwards I manually need to delete it#2022-05-0718:58mkvlrno big deal and probably not a common problem#2022-05-0718:59thhellerI don't understand the issue sorry 😛#2022-05-0719:07mkvlrwhen working on clerk, I sometimes do clj-only dev, and jack-in using cider, so shadow isn’t even on the classpath. This writes a .nrepl-port file. When I kill that process or it dies, the .nrepl-port sticks around, and when I launch nrepl via shadow next time, cider doesn’t consider shadow’s shadow-cljs/nrepl.port file, because the other one takes precedence and I need to manually delete it so I can connect again.#2022-05-0719:08mkvlrlike I said, I believe it’s a pretty rare edge case.#2022-05-0805:21thhellerseems like something cider should handle on its own? I mean it knows if the connect succeeded or not?#2022-05-0614:26Yuhri Graziano BernardesHi everyone. Hope you are all doing well! What docker image do you use to run shadow-clj apps? I found these two, but they seem kinda unmaintained#2022-05-0616:52mauricio.szaboDo you mean, to compile the code? I usually use a node docker image with Alpine and just install OpenJDK on it#2022-05-0622:17Yuhri Graziano BernardesI mean use as runtime (for dev and prod)#2022-05-0704:32mauricio.szaboI have no idea what you mean then... Shadow-cljs is only to compile ClojureScript into Javascript, the resulting code is pure JS and you only need to run on a webserver (for browser targets), or on node (for node library and script targets), or at Android and iOS (for react-native). In that sense, maybe you need to look for a apache or nginx docker, or a node docker to run your compiled code?#2022-05-0616:57mauricio.szaboIs there any way to use def but alter the :arglists meta? I tried the suggested solutions but they all failed to update :arglists (tried with alter-meta!, that didn't change any metadata at all, tried with (declare ^{:arglists '([a b])} my-fun)`, that also didn't work)#2022-05-0617:44dpsuttonI've reported a similar problem in cljs itself. Might not be shadows bug#2022-05-0619:11thhellervar metadata doesn't exist at runtime in cljs. if only lives in the analyzer data on the compiler CLJ side. as such any var based meta programming is severly limited and imho should not be considered at all. just treat it as if vars don't exist. what is your goal with modifying :arglists?#2022-05-0704:36mauricio.szaboI was trying to make a "Prismatic Schema" defn for malli. In the end, I was able to modify arglists by emitting a defn with an empty body and then rewrite it with set!#2022-05-0800:38Patrick BrownThe documentation for Shadow is so good I'm having trouble finding something simple 👍. Where can I find the keys for the opts map that shadow.cljs.devtools. server/start!, api/watch, and repl? Also if anyone has any reason why I shouldn't launch them from integrant repl, let me know.#2022-05-0803:17neilyioI’m noticing a weird edge case with shadow-cljs compilation. When a (ns…) form is wrapped in a (do..) block, compilation fails with odd errors. Here’s a minimal example:
(do
  (ns cljs.user
   (:require [cljs.core.async :refer [chan <! go-loop]])))

(def wait-chan (chan 1))

(go-loop []
  (<! wait-chan)
  (recur))
…results in this error:
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/neilhansen/Documents/quickstart-browser/src/cljs/user.cljs:9:3
--------------------------------------------------------------------------------
   6 | 
   7 | (go-loop []
   8 |   (<! wait-chan)
   9 |   (recur))
---------^----------------------------------------------------------------------
null
Can't recur here at line 9 cljs/user.cljs
--------------------------------------------------------------------------------
  10 | 
--------------------------------------------------------------------------------
…why am I doing this in the first place? I was working on some custom editor tooling that involved evaluating the whole buffer. I thought I would be clever and wrap the buffer string in a (do…) block. Ran into this issue, so thought I’d ask about it!
#2022-05-0805:23thheller@neil.hansen.31 don't wrap ns in a do. that is not supported. ns is a special form that needs to be the first form in the file. this isn't supported in regular CLJS either.#2022-05-0810:32p-himikJust out of interest - shadow.cljs.devtools.server.config-watch doesn't use shadow.cljs.devtools.server.fs-watch but instead busy-loops with (Thread/sleep 1000). Is it just a historical artifact or is there some deliberate decision behind this?#2022-05-0815:25thhellerfs-watch only watches directories recursively. overkill for a single file.#2022-05-0817:10zimabluedoes shadow-cljs do any hashing or comparison of modification times on files or pure file-event-watching? Skimming the code it looks like the latter, was wondering whether hashing files or storing last-modification dates was considered/done in an extension or something#2022-05-0817:43thhellerthe 3rd implies the 2nd so I'm not sure what you are asking? what is the problem or concern?#2022-05-0817:44zimabluenot problem or concern, design question#2022-05-0817:44zimabluein theory one can use hashes of files to work out what needs to be recompiled and what doesn't one AFAIK could also use file modification times or filesystem events, but that's not persistent across "watch" sessions#2022-05-0817:45thhellercache takes care of that, which indeed does a md5 hash of the file#2022-05-0817:45zimabluechecking that shadow-cljs doesn't do the first and wondering why that choice was made as considering writing a tool for a different purpose that does do that#2022-05-0817:45zimabluehow does cache know when it's invalidated?#2022-05-0817:45zimablueah ok#2022-05-0817:45zimabluethx#2022-05-0817:46zimablueis this the "hash-optimized-module" code?#2022-05-0817:47thhellerno, not related in any way#2022-05-0817:47zimabluesorry, I am just searching for md5 in the source code#2022-05-0817:49thhelleroh sorry. not md5. sha1. https://github.com/thheller/shadow-cljs/blob/ed908d820f5571ec5544f15aabd622cfca5b4f4e/src/main/shadow/build/classpath.clj#L769#2022-05-0817:52zimabluethanks!#2022-05-0901:26xfyreI’m not sure if this is some common question, but I searched the channel and wasn’t able to find anything. I’m using nREPL with IntelliJ IDEA, and every time after I connect to the nREPL instance I have to manually execute:
(shadow/repl :dev-android)
(ns cljs.user)
I’m wondering if this can be automated somehow?
#2022-05-0905:11thhellerit cannot. well I suppose you can create a keybinding for it via custom repl commands#2022-05-0905:48thhellerthe (ns cljs.user) you don't really need though?#2022-05-0920:07xfyrewithout this one, I can’t execute things like (def some-binding "some stuff") - REPL assumes cljs.user namespace which doesn’t exist#2022-05-0920:08thhellercljs.user always exists by default?#2022-05-0920:08xfyrewell, somehow - in this particular case - it doesn’t#2022-05-0920:09thhellerdid you set :repl-init-ns in your build config?#2022-05-0920:09thhelleralso which shadow-cljs version? there were a few where this didn't exist until a user connected, maybe you are on one of those?#2022-05-0920:11xfyrenope, let me try that. 2.18.0#2022-05-0920:17xfyre
Connecting to remote nREPL server...
Clojure 1.10.3
(shadow/repl :dev-android)
To quit, type: :cljs/quit
=> [:selected :dev-android]
(def test-var "something")

Execution error (TypeError) at (<cljs repl>:1).
undefined is not an object (evaluating 'cljs.user.test_var = "something"')
=> :repl/exception!
(ns cljs.user)
=> nil
(def test-var "something")
=> #'cljs.user/test-var
That didn’t help. Anyway - that’s not a big deal, just a minor inconvenience, probably related to my setup.
#2022-05-0920:18thhellerah react-native. yeah some people have reported strange behavior there. can't verify since I can't get react-native running anymore#2022-05-0920:20xfyreyeah, RN setup. ok, I’ll just keep typing stuff and probably assign shortcuts 🙂#2022-05-0913:29pinkfrogNot sure if it could be solved with shadow. How can I retain the line number where the error occurs?#2022-05-0915:11thhellerthats react-native. it is displaying this stacktrace. dunno why the tracktrace is incomplete#2022-05-0916:09danbuneaHi, I am trying to understand some behaviour. If I refer: ["mui-address-autocomplete" :default AddressAutocomplete] the build takes 5-8s [:web] Build completed. (12803 files, 2 compiled, 0 warnings, 7.42s) Removing the refer: [:web] Build completed. (1684 files, 2 compiled, 0 warnings, 0.90s) The lib is: "mui-address-autocomplete": "^2.0.4". Any hints?#2022-05-0917:09thheller@danbunea 12803 files vs 1684 files explains the time difference? recompile will be faster. the files are included because I guess thats all the transitive deps of the mui-address-complete?#2022-05-0920:01p-himikIf I use --config-merge {:cache-root ".some-other-location"} and .some-other-location does not exist yet, a new shadow-cljs server instance will be started, right? Is there a better way to make sure that it's a new server instance and not an existing one? Just encountered an issue where modifying a CLJ file haven't changed the code that shadow-cljs run executes. Took me a while to realize that I had a watch running.#2022-05-0920:01thhellerconfig merge only merges build configs. cache root is not a build setting and as such does not have any effect#2022-05-0920:02p-himikAh, right. But is there a way to always start a new server for some particular command?#2022-05-0920:06thhellerjust don't run it via shadow-cljs for one#2022-05-0920:06thhelleror use the --force-spawn there#2022-05-0920:07thhellercan't think of a reason why you'd do any that though?#2022-05-0920:09p-himikHaving a single server instance per project limits your development capabilities because you have to think whether you need to reload something via shadow-cljs' REPL or restart the server or whether just running it will be enough. I'd much rather have each separate CLI command just do its own thing, in isolation, without touching any global runtime.#2022-05-0920:10p-himik> just don't run it via shadow-cljs for one Well, I use shadow.cljs.devtools.api in that script, and sounds like running it via just clj would make it more work for me, with manual start of a server instance.#2022-05-0920:12thheller> whether you need to reload something via shadow-cljs' REPL or restart the server #2022-05-0920:12thhelleroh wait you were building a thing that was embedding shadow-cljs for something right?#2022-05-0920:16p-himikSo, I have a watch running somewhere in the background, and the same command has started a shadow-cljs server instance. Now that instance has loaded all the relevant CLJ files and all the dependencies. Fast forward a few hours, I'm about to cut a new release of the app. It requires a bunch of things and I run them all via a single call to shadow-cljs run. But my previous work has changed the release script a bit, and has added a new dependency specifically for that part. So, not thinking about it, I execute shadow-cljs run and... bad stuff happens. Old behavior, before the changes above. It was rather tedious to debug because I started to think that I had maybe a compiled and outdated class somewhere, or a copy of the script somehow. Took me a bit to realize that shadow-cljs server was running in the background.#2022-05-0920:17p-himik> oh wait you were building a thing that was embedding shadow-cljs for something right? Not anymore, no. Well, apart from that piece of code that creates shadow-cljs config so I can figure out some run time parameters to feed them to other scripts.#2022-05-0920:19p-himikSounds like --force-spawn is just what I need though, as I could use it just for that release script. Still, makes me think that I myself would probably prefer an explicit flag that did the reverse. I.e. the default behavior for shadow-cljs would be to start a new server instance each time, and some flag would make it reuse some specific instance. But that's just me - I barely use that "connect to existing instance" feature.#2022-05-0920:20thhellerI mean I would probably recommend just using clj or lein for stuff like this?#2022-05-0920:21thhellerunless this "release" task is really only doing CLJS related things#2022-05-0920:21thhellerif it does something else too a more generic runner might make sense#2022-05-0920:22p-himikBut that would make me have to explicitly start shadow-cljs server, no? Given that I use shadow.cljs.devtools.api/release in that very script or watch in other places of that script.#2022-05-0920:23p-himikYeah, release/watch/test - they all have a bunch of non-CLJS steps that are nonetheless tied to either CLJS or something shadow-cljs-related. To be specific, I need to generate some JS code from ANTLR4 grammar before running shadow-cljs. And I need to run sass there as well, and some other CSS-related things.#2022-05-0920:26thhellerrelease doesn't require a server instance and doesn't start one#2022-05-0920:28p-himikBut it definitely uses an existing one! :)#2022-05-0920:29thhelleryes#2022-05-0920:29thheller> But that would make me have to explicitly start shadow-cljs server, no?#2022-05-0920:29thhellerno#2022-05-0920:30thhelleror I'm confused what you are talking about. server is only a thing because of watch basically. if that didn't exist there would be no server mode.#2022-05-0920:30p-himikRight, then it would mean that for watch I'd have to use shadow-cljs run and for release I'd have to use clj. Ehh, I'd rather just pass --force-spawn to the release CLI command.#2022-05-0920:30thhellerit is still useful for most other tasks but still#2022-05-0920:31thhellerthat is fine. just saying that you shouldn't start another server if a server is already running#2022-05-0920:31thhellerso whatever you do in the run don't start a server if you use --force-spawn#2022-05-0920:32p-himikRight, makes sense. I'm not starting a server manually anywhere. There's {:shadow/requires-server true} in a couple of places, but not around the release-related code.#2022-05-0920:32thhellerwell that would start a server if you run that via run#2022-05-0920:33thhellerhow are you running sass?#2022-05-0920:34thhellerhave you tried a setup using npm-run-all?#2022-05-0920:34thhellerI'm finding that very convenient#2022-05-0920:34thhellerhttps://github.com/thheller/shadow-cljs/blob/50e0a31e1f328d6d9e728dce5c39f20a30202b1d/package.json#L9#2022-05-0920:35thhellerpretty much my standard setup these days#2022-05-0920:37p-himikAs I mentioned - I have a lot of things other than just sass, and I can't run them all independently via npm run. There's a dependency graph, and right now it's expressed explicitly in the code:
(do-the-first-step)
(do-the-second-step)
(shadow/watch)
(do-some-css-shenanigans)
(compile-sass)
#2022-05-0920:40p-himikBut starting another server is not that huge of a deal, right? It seems to take roughly 4 seconds on my end - I don't care about that amount of extra time when it's just for cutting a release.#2022-05-0920:42thhelleryou are confusing me by saying server#2022-05-0920:42thhellercall it a JVM#2022-05-0920:43thhellerif you only run release related tasks then you only start a new JVM#2022-05-0920:44thhellerstarting a new JVM takes time yes#2022-05-0920:44p-himikOh, so if I run shadow-cljs without --force-spawn where there's another instance running somewhere, it will skip starting not just a shadow-cljs server instance specifically, but a whole JVM?#2022-05-0920:45thhelleryes, thats the whole point#2022-05-0920:45thhellerstarting shadow-cljs itself is cheap and fast. getting the JVM up and running is the slow part#2022-05-0920:45thhellerlike 90% of the time is spent loading namespaces and stuff#2022-05-0920:46p-himikIn that case, I had a wrong mental picture. I thought it was slow to start the shadow-cljs server instance for some reason, and that two JVM instances would communicate with each other to reuse a single running shadow-cljs server instance.#2022-05-0920:47thhellerno. the shadow-cljs CLI script is written in CLJS and only runs node. that part talks to the server instance over tcp when present#2022-05-0920:47thhelleror starts a JVM if not#2022-05-0920:48p-himikYeah, now the whole thing is getting much clearer. :) I used to be confused about a few things in shadow-cljs code base, specifically the CLI part being written in CLJS. Thanks!#2022-05-1006:13danbuneaI saw the difference in files but cannot understand why 11k more. At the end of the day I guess I'll rewrite it with a mui aucomplete and I'll make the call to Google maps http api myself. #2022-05-1006:33thhellerwell yeah, some JS libs are crazy. some are also expecting webpack which can eliminate some of it but that is webpack specific which shadow-cljs does not support#2022-05-1007:31danbuneathank you#2022-05-1016:36Cora (she/her)#2022-05-1016:36Cora (she/her)@danbunea ^^ js libs can be absolutely astonishing :shocked_face_with_exploding_head:#2022-05-1019:14danbuneaYes, I wanted to put this specific example of a library because it is really strange. In the meanwhile after an afternoon of work I rewrote the address autocomplete properly and got rid of it. #2022-05-1017:25borkdudeIs it possible to test out a certain clojurescript commit with shadow-cljs? https://github.com/clojure/clojurescript/commit/8b3ce24a6e7e1863802b09618985a0f3a604a0c9#2022-05-1017:26borkdudeI tried adding:
org.clojure/clojurescript {:git/url ""
                                   :git/sha "91c597d99b3480c0463b3648016e4f27b0b0b018"}
in my deps, but that crashed
#2022-05-1018:44thheller@borkdude define "that crashed"? should be fine normally but something cljs introduces new bindings or some other change that I need to add to shadow-cljs for compatiblity#2022-05-1020:07borkdude
Caused by: java.lang.RuntimeException: Unable to find static field: ECMASCRIPT_NEXT_IN in class com.google.javascript.jscomp.CompilerOptions$LanguageMode
	at clojure.lang.Util.runtimeException(Util.java:221)
	at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7328)
	at clojure.lang.Compiler.analyze(Compiler.java:6785)
	... 235 more
#2022-05-1020:08thhellerthat is with a wrong closure compiler version#2022-05-1020:11thhellerv20220301 should be ok, didn't test newer ones yet#2022-05-1020:14borkdudeis that referring to this coordinate?
com.google.javascript/closure-compiler-unshaded {:mvn/version "v20220202"}
#2022-05-1020:15thhelleryes#2022-05-1018:44thhelleras far as I can remember none of those were added though#2022-05-1101:12bmaddyIs there some kind of clean step or way to force recompiling the classpath (like -Sforce for tools.deps) in shadow-cljs? I didn't see one in the docs. I ask because I'm sometimes compiling my code in a docker container and sometimes locally. I end up getting errors like this when compiling in the container: > $ yarn shadow-cljs release main > ... > shadow-cljs - starting via "clojure" > Error: Could not find or load main class clojure.main > Caused by: java.lang.ClassNotFoundException: clojure.main > error Command failed with exit code 1. Deleting the .cpcache directory fixes it, but I'm wondering if there is other stuff I should be deleting.#2022-05-1106:20thheller@bmaddy you can just use the clojure/clj commands directly. shadow-cljs release app is identical to clj <aliases+whatever> -M -m shadow.cljs.devtools.cli release app#2022-05-1106:23thhellerotherwise no, deleting .cpcache is enough#2022-05-1116:52bmaddyGreat, thank you!#2022-05-1106:53pezI'm trying to use the npm module fast-glob, but am failing to import it properly. Trying this:
(:require ["fast-glob" :as fast-glob :default fg :refer [sync]] ...)
I get module$node_modules$fast_glob$out$index is not defined whichever of those symbols (`fast-glob`, fg, sync) I try to evaluate, and also if I try to call any of them. I do see that this file has been produced:
out/js/cljs-runtime/module$node_modules$fast_glob$out$index.js
I've tried restarting the watcher, and even wiped .shadow-cljs/ and out/ to no avail.
#2022-05-1106:55pezIdeally I want to use the Async API of fast-glob: https://github.com/mrmlnc/fast-glob#asynchronous
const fg = require('fast-glob');

const entries = await fg(['.editorconfig', '**/index.js'], { dot: true });

// ['.editorconfig', 'services/index.js']
But that's a luxury problem right now. 😃
#2022-05-1106:54thhellersounds like a node only package maybe? not going to work in a browser setting?#2022-05-1106:56pezOh, sorry, forgot. It's an electron project, #joyride to be precise. My config looks like so:
{:deps true
 :builds
 {:extension {:target :node-library
              :js-options {:js-provider :shadow
                           :keep-native-requires true
                           :keep-as-require #{"vscode"}}
              :compiler-options {:infer-externs :auto}
              :output-dir "out/js"
              :output-to "out/joyride.js"
              :exports {:activate joyride.extension/activate}
              :devtools {:before-load-async joyride.extension/before
                         :after-load joyride.extension/after}}}}
#2022-05-1106:57thheller:keep-as-require #{"vscode" "fast-glob"}#2022-05-1106:58thhellercan't look into why it doesn't work right now. but node only packages pretty commonly do node specific stuff that shadow-cljs doesn't support.#2022-05-1107:01pezAdding it to :keep-as-require worked. Thanks! ❤️ shadow even hot-reloaded the config. 🤯#2022-05-1113:49pezRunning into troubles with the packaged extension now instead, @thheller:
mainThreadExtensionService.ts:111 Activating extension 'betterthantomorrow.joyride' failed: Cannot find module 'fast-glob'
Require stack:
- /Users/pez/.vscode/extensions/betterthantomorrow.joyride-0.0.9-52-get-started-content-6099ecbf/out/joyride.js
- /Users/pez/.vscode/extensions/betterthantomorrow.joyride-0.0.9-52-get-started-content-6099ecbf/extension.js
- /Applications/Visual Studio 
- /Applications/Visual Studio 
- /Applications/Visual Studio .
$onExtensionActivationError @ mainThreadExtensionService.ts:111
Is there a way I can make shadow bundle it into the release build?
#2022-05-1116:15pezI got around this by using fdir instead of fast-glob. That one doesn't need to be included in the :keep-as-require set.#2022-05-1118:15thhelleris there a way for me to easily test this?#2022-05-1118:16thhellerfast-glob would need to be bundled. I assumed that would be handled in some way already by electron.#2022-05-1118:57pezWith Calva we use webpack to bundle things together. We might need to go there with #joyride too. But for now shadow does all the work.#2022-05-1118:59pezElectron is maybe the wrong way to describe the project. It's a VS Code extension, and VS Code is Electron.#2022-05-1119:02thhelleryeah, just would assume that the default tooling for this would include npm packages in some way#2022-05-1119:09pezI should be able to create a small example with fast-glob.#2022-05-1115:50danierouxChecking understanding. shadow-cljs supports:
["semantic-ui-react$Confirm" :as Confirm]
It does not support:
[semantic-ui-react$Confirm :as Confirm]
#2022-05-1115:50danierouxI am not missing anything?#2022-05-1118:14thheller@danie both should be fine?#2022-05-1118:20danierouxHuh. Sorry, I slipped up somewhere. It now indeed works, as one presumes it did all along!#2022-05-1118:33danierouxOk, got it broken again for me. This branch passes: https://github.com/danieroux/semantic-ui-wrapper/tree/cljs [:workspaces] Build completed. (1105 files, 0 compiled, 0 warnings, 14.66s) This one does not: https://github.com/danieroux/semantic-ui-wrapper/tree/shadow-cljs-build-issues
[:workspaces] Build failure:
Multiple files failed to compile.
aborted par-compile, [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"] still waiting for #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}
{:aborted [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"], :pending #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}}
ExceptionInfo: aborted par-compile, [:shadow.build.classpath/resource "fulcrologic/semantic_ui/workspaces/dropdown.cljs"] still waiting for #{com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-item com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-divider com.fulcrologic.semantic-ui.elements.icon.ui-icon com.fulcrologic.semantic-ui.modules.dropdown.ui-dropdown-menu}
#2022-05-1118:33danierouxThe difference is how those requires gets generated.#2022-05-1118:38thhellerwell the string is absolutely preferred yes. can't say why it fails, will try with a smaller example 😉#2022-05-1118:43danierouxAs long as you get the same error, and I don't have local gremlins 😊#2022-05-1607:30thhellershould be fixed in 2.19.0#2022-05-1118:44NundrumI'm getting errors when starting npx shadow-cljs server
[2022-05-11 14:22:58.929 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym cider.nrepl/cider-middleware}
Note: The following stack trace applies to the reader or compiler, your code was not executed. 
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
I didn't think cider was built in. But there it is. I'll put my shadow-cljs config in the thread. My ~/.clojure/deps.edn is empty. There isn't a config in ~/.cljs or ~/.nrepl. What else could I be missing?
#2022-05-1118:45Nundrumshadow-cljs.edn:
{:builds
 {:app {:asset-path "/js"
        :modules {:main {:init-fn app.core/main}}
        :output-dir "public/js"
        :target :browser}
  :cards {:asset-path "/js"
          :modules {:main {:init-fn app.cards/main}}
          :compiler-options {:devcards true}
          :output-dir "public/js"
          :target :browser}
  :test {:ns-regexp "app.cards"
         :output-to "out/test.js"
         :target :node-test}
  :e2e {:ns-regexp "e2e.*"
        :output-to "out/e2e.js"
        :target :node-test}}
 :dependencies [[reagent "0.8.1"]
                [devcards "0.2.6"]
                [cljs-http "0.1.46"]
               ; [cider/cider-nrepl "0.28.3"]
                ]
 :dev-http {3000 "public"}
 :nrepl {:port 3333}
 :source-paths ["src"]}
#2022-05-1119:01thhellerwhat is the full error? and which shadow-cljs version?#2022-05-1119:03Nundrum
[2022-05-11 14:22:58.929 - WARNING] :shadow.cljs.devtools.server.nrepl/middleware-fail - {:sym cider.nrepl/cider-middleware}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (cider/nrepl.clj:1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "cider/nrepl.clj"}
        clojure.lang.Compiler.load (Compiler.java:7648)
        clojure.lang.RT.loadResourceScript (RT.java:381)
        clojure.lang.RT.loadResourceScript (RT.java:372)
        clojure.lang.RT.load (RT.java:459)
        clojure.lang.RT.load (RT.java:424)
        clojure.core/load/fn--6839 (core.clj:6126)
        clojure.core/load (core.clj:6125)
        clojure.core/load (core.clj:6109)
        clojure.core/load-one (core.clj:5908)
        clojure.core/load-one (core.clj:5903)
        clojure.core/load-lib/fn--6780 (core.clj:5948)
        clojure.core/load-lib (core.clj:5947)
Caused by:
IllegalAccessError with-session-classloader does not exist
        clojure.core/refer (core.clj:4249)
        clojure.core/refer (core.clj:4217)
        clojure.core/apply (core.clj:667)
        clojure.core/load-lib (core.clj:5966)
        clojure.core/load-lib (core.clj:5928)
        clojure.core/apply (core.clj:667)
        clojure.core/load-libs (core.clj:5985)
        clojure.core/load-libs (core.clj:5969)
        clojure.core/apply (core.clj:667)
        clojure.core/require (core.clj:6007)
        clojure.core/require (core.clj:6007)
        cider.nrepl/eval7083/loading--6721--auto----7084 (nrepl.clj:1)
[2022-05-11 14:22:59.291 - WARNING] TCP Port 3000 in use.
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.10.22 running at 
shadow-cljs - nREPL server started on port 3333
#2022-05-1119:03NundrumSo looks like 2.10.22#2022-05-1119:05thhellertry upgrading. that is rather old.#2022-05-1119:05NundrumHuh. I just npm installed it a few days ago.#2022-05-1119:06thhellerjust check the version in package.json?#2022-05-1119:06thhellerdo you use npx shadow-cljs to run?#2022-05-1119:07thhelleryou might just have a global install that is out of date?#2022-05-1119:10NundrumHrrrm an npm update fix it! Good catch.#2022-05-1119:10NundrumI had used npx create-cljs-app to create the project#2022-05-1119:14thhellerhmm maybe that is hardcoded to the really old version? can't say#2022-05-1119:34thhelleryeah, it is hardcoded to a really old verison. I opened an issue, hope they fix it#2022-05-1120:10NundrumThanks. I was trying to figure out how it worked, but you beat me to it.#2022-05-1311:28rosadoWhat's the state of code splitting/dynamic code loading for shadow-cljs + expo targeting the browser? Is it just not possible at the moment?#2022-05-1314:27thhellerno clue what it looks like on the expo side. if it works like in regular react-native than it might work just fine#2022-05-1314:27thhelleryou can specfiy extra :chunks in the build config like so https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L500-L505#2022-05-1314:28thhellerwhich you then require via js/require as in here https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/rn.cljs#L29#2022-05-1314:28thhellerno clue if this works any different in expo#2022-05-1315:07rosado@thheller chunks do work under expo but only when targeting a device. On the browser, js/require doesn't work, hence my question. We may end up not doing code splitting at all for browsers (not our main target platform anyways)#2022-05-1316:23thhellerdo you have an example of how its done in expo with js#2022-05-1415:18aratare@thheller I was looking into how to use shadow-cljs for creating chrome extension and came across this https://github.com/thheller/shadow-cljs/issues/279. It seems to have been inactive since 2020. Has there been any new update since then?#2022-05-1415:33thhellernowadays likely :target :esm is the better fit https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-05-1415:33thhellerI just haven't had time to test arround#2022-05-1415:34thhellersupposedly eval is now forbidden so hot-reload and REPL no longer work#2022-05-1416:01aratareI found this https://github.com/binaryage/chromex/tree/master/examples/shadow and it's looking pretty good actually.#2022-05-1416:02aratareMay be what I'm looking for since I'm not too well-versed when it comes to JS#2022-05-1418:31Kovas PalunasHey I'm working on a strange project that is targeting google apps script. I started out with this template: https://github.com/chrisfarnham/cljs_clamp, but struggled a lot with getting a proper nrepl working with just lein and piggieback. I've since tried moving the project over to shadow-cljs, with pretty good success. Currently I can run a node repl successfully for development, but I'm still running into a couple problems: 1. When I try to push my Code.js file built with shadow-cljs to google apps script, it complains about a bunch of missing names that I think node provides to its scripts. Is there any way to tell shadow-cljs to build my script for node when i'm developing, and without these names when I'm deploying to google apps script (like lein cljsbuild once does in the linked repo)? I can just use lein cljsbuild once for deployment, but it feels weird to depend on two build tools like that. Maybe there's a simple solution? 2. Google Apps Script provides some names that are only available when running in Google Apps Script (not node). An example would be js/SpreadsheetApp (https://github.com/kovasap/autojournal-on-gas/blob/cbfa522932d3b60d3a915dd8e6ff7505935ee26b/src/autojournal/sheets.cljs#L6). When I try to run with these names uncommented in my shadow-cljs node environment I (rightly) get an error. What I would like to do is to have some kind of "if" branch in my code that uses e.g. js/SpreadsheetApp when running in google apps script, but a mock or fake that I define when running in node. Any tips for how to accomplish this? In other languages I feel like compiler macros would be the solution.#2022-05-1419:26thheller@kovas.palunas sorry but I know absolutely nothing about google apps script and the environment it runs in. :target :node-script assumes to be running in node, so that might explain errors. which errors would that be though? you didn't say.#2022-05-1419:49Kovas PalunasThe first part of the shadow-cljs generated code (for node) looks like this:
#!/usr/bin/env node
(function(){
var shadow$provide = {};

var SHADOW_IMPORT_PATH = __dirname + '/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime';
if (__dirname == '.') { SHADOW_IMPORT_PATH = "/home/kovas/cljs_clamp/.shadow-cljs/builds/autojournal/dev/out/cljs-runtime"; }
global.$CLJS = global;
global.shadow$provide = {};
try {require('source-map-support').install();} catch (e) {console.warn('no "source-map-support" (run "npm install source-map-support --save-dev" to get it)');}

global.CLOSURE_NO_DEPS = true;
apps script complains when I try to run it because __dirname and global are not defined in it's environment
#2022-05-1419:51Kovas Palunaswhen i build with lein cljsbuild once, my file does not have those names referenced#2022-05-1419:52Kovas Palunasshadow-cljs: https://github.com/kovasap/autojournal-on-gas/blob/main/dev-Code.js cljsbuild: https://github.com/kovasap/autojournal-on-gas/blob/main/Code.js#2022-05-1419:53Kovas Palunasi guess what i'm really looking for is a way to use shadow-cljs to build my final js file in the same way that cljsbuild does it#2022-05-1419:54Kovas Palunasso i don't have parallel dependency files#2022-05-1419:56Kovas PalunasBTW, my question 2 was answered in another channel, the solution I have is at https://github.com/kovasap/autojournal-on-gas/blob/main/src/autojournal/env_switching.cljc. I still am looking for a way to reference an env var or something in this macro that would let me know that shadow-cljs is building my code (vs lein, or shadow-cljs with different parameters if I find a solution to my question 1)#2022-05-1420:06Kovas PalunasMaybe another way to phrase the question is: can shadow-cljs make a :target :browser build where all the code is in one self-contained file?#2022-05-1506:00thheller@kovas.palunas I don't expect a development build to work. as I said it expects not and as such uses node features. shadow-cljs release app might.#2022-05-1506:00thhellerregarding q2 I made this gist a long time ago https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3#2022-05-1506:01thhellerinstead of resolve use exists? js/SpreadsheetApp#2022-05-1506:01thhellercan you point me to some documentation about apps scripts? do they support ES modules? ie. import/export?#2022-05-1506:02thhellerthe whole point of the shadow-cljs :target abstraction is to make target specific builds. there could absolutely be a :target :google-apps-script. I just have never used that so I don't know how it needs to be bundled#2022-05-1517:27Kovas Palunasthanks for the gist link! i ended up solving that problem with a simple defn that takes in anonymous functions to execute: https://github.com/kovasap/autojournal-on-gas/blob/fe8e80c358f0dce2e9852f8d2f6f7813b23008be/src/autojournal/env_switching.cljs#L3. the resolve call i'm using now works well - is exists? just a better name for the same functionality?#2022-05-1517:28Kovas Palunasapps script is interesting in that it's a (AFAIK) totally self contained development environment: https://developers.google.com/apps-script/overview?hl=en#2022-05-1517:29Kovas Palunasusually you would write code in their browser editor and run it. it interacts with various google products via its own special API#2022-05-1517:30Kovas Palunasit has a CLI utility for local development (not in their browser editor) https://github.com/google/clasp#2022-05-1517:31Kovas Palunasmy understanding is that apps script code should be bundled as just one big flat js file with everything in it#2022-05-1517:32Kovas Palunasand no undefined names (that would otherwise be defined in other places)#2022-05-1517:32Kovas PalunasAFAIK apps script does not support js dependencies of any kind (although if they were inlined in the bit flat file that would work)#2022-05-1517:36Kovas Palunasone interesting quirk of apps script also is that it doesn't like namespaced names. https://lambdaisland.com/blog/2016-10-01-clojurescript-and-google-apps-script describes a workaround. i'm currently just appending some non-namespaced functions that call my core functionality to my big js file in a bash script#2022-05-1519:01Kovas Palunasbtw it looks like shadow-cljs release app does not work due to google apps script seeing a syntax error in the generated js file. perhaps this is because of subtle differences between javascript and google apps script#2022-05-1519:04Kovas Palunasstrangely, the lein cljsbuild once command's output is interpreted just fine. i think this has to do with the clojurescript version. I'm using "1.10.439" in my project.clj and saw that using "1.10.773" led to this syntax error#2022-05-1519:04thhellerdefine syntax error#2022-05-1519:04Kovas Palunasi should probably try using this older version in my shadow-cljs#2022-05-1519:04thhellerit really is much easier to answer question if you provide the actual errors#2022-05-1519:04thhellerno just say that there is an error 😛
#2022-05-1519:05Kovas Palunasyeah i know, one sec#2022-05-1519:05Kovas Palunasthe message is 'Syntax error: Missing ; before statement. line: 24 file: Code',, let me get a link to the file#2022-05-1519:06thhellertry with shadow-cljs release app --pseudo-names or --debug#2022-05-1519:06thhelleralso whats in line 24?#2022-05-1519:08Kovas Palunasgetting it, one sec#2022-05-1519:10thhelleralso try :compiler-options {:output-feature-set :es5} in your build config. maybe it doesn't like newer syntax#2022-05-1519:11thhellerhttps://github.com/kovasap/autojournal-on-gas/blob/main/shadow-cljs.edn#L10-L11#2022-05-1519:11thhellerthis also only applies to dev builds. release will be a single file#2022-05-1519:23Kovas Palunasi just tried a release build here, but got the same syntax errors#2022-05-1519:15Kovas Palunas
errors: [
    {
      message: 'Syntax error: Missing ) after formal parameters. line: 1420 file: Code',
      domain: 'global',
      reason: 'badRequest'
    }
  ]
#2022-05-1519:16Kovas Palunashttps://github.com/kovasap/autojournal-on-gas/blob/5b07d2ea8a8eb0909638eab0a8f73130ebdebc68/Code.js#2022-05-1519:17Kovas Palunas
goog.loadModule(function(exports) {
  "use strict";
  goog.module("goog.debug.Error");
  goog.module.declareLegacyNamespace();
  function DebugError(msg = undefined, cause = undefined) {  // <- 1420
    if (Error.captureStackTrace) {
      Error.captureStackTrace(this, DebugError);
    } else {
      const stack = (new Error()).stack;
      if (stack) {
        this.stack = stack;
      }
    }
 
#2022-05-1519:17Kovas Palunasthe :es5 option didn't work#2022-05-1519:17Kovas Palunasbut i feel like that might be the right idea#2022-05-1519:18Kovas Palunasit would make sense that apps script is equivalent to a certain version of javascript that is not the latest one#2022-05-1519:19Kovas Palunas--pseudo-names didn't work either#2022-05-1519:30Kovas Palunasi figured out that I can set the javascript version used by apps script to use Chrome V8 instead of rhino, which makes the syntax errors go away!#2022-05-1519:31Kovas Palunasnow i'm simply getting ErrorReferenceError: global is not defined when i try to run my code#2022-05-1519:35Kovas Palunasusing :target :browser gives
12:35:01 PM	Error	Cannot use default debug loader outside of HTML documents.
12:35:01 PM	Error	Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true.
12:35:01 PM	Error	
TypeError: Cannot set property 'NodeType' of undefined
#2022-05-1519:36Kovas Palunasso yeah i think the syntax error problem is solved, but there is still an issue with shadow-cljs output expecting names that are not provided by the apps script environment (the global name at least)#2022-05-1519:40thhellerthis is with a release build?#2022-05-1519:40thhellerwatch/compile assumes browser environment. so not expected to work.#2022-05-1519:41thhellerglobal comes from the assumption of running in node#2022-05-1519:42Kovas Palunasyes this is a release build#2022-05-1519:42Kovas Palunasthat makes sense#2022-05-1519:42Kovas Palunasif i add var global = {}; to the top i get another error:
goog.dom.NodeType = {ELEMENT:1, ATTRIBUTE:2, TEXT:3, CDATA_SECTION:4, ENTITY_REFERENCE:5, ENTITY:6, PROCESSING_INSTRUCTION:7, COMMENT:8, DOCUMENT:9, DOCUMENT_TYPE:10, DOCUMENT_FRAGMENT:11, NOTATION:12};
#2022-05-1519:42Kovas Palunas
TypeError: Cannot set property 'NodeType' of undefined
#2022-05-1519:43Kovas Palunasbecause i think
var goog = goog || {};
goog.global = global;
#2022-05-1519:45thhellerthere is no more goog.module or goog.provide in the file right?#2022-05-1519:47thheller> the javascript version used by apps script to use Chrome V8 #2022-05-1519:47Kovas Palunasthere are#2022-05-1519:47Kovas Palunas
goog.module.get = function(name) {
  return goog.module.getInternal_(name);
};
#2022-05-1519:47thhellerare there docs on this? I mean what the runtime is capable of?#2022-05-1519:47Kovas Palunashttps://github.com/kovasap/autojournal-on-gas/blob/347a4578351fdce53f52bf9cb05a1e3a0a256450/Code.js#2022-05-1519:47thhellerI mean goog.module(...) calls#2022-05-1519:47Kovas Palunasyes those lines exist goog.module("goog.debug.Error");#2022-05-1519:48Kovas Palunasshould they not exist in a release build?#2022-05-1519:48thhellerthis is not a release build no?#2022-05-1519:48Kovas Palunasit is#2022-05-1519:48Kovas Palunasi'm calling (run "npx" "shadow-cljs" "release" "autojournal")#2022-05-1519:48thhellerwelll :optimizations :whitespace#2022-05-1519:48thhellerdon't do that#2022-05-1519:48Kovas Palunasoh ok#2022-05-1519:48thhellerat least :simple#2022-05-1519:50Kovas Palunasi still have the missing global problem without :optimizations :whitespace#2022-05-1519:50thhellerjust add the var global = {} again?#2022-05-1519:51Kovas Palunasi tried that#2022-05-1519:51Kovas Palunashttps://v8.dev/docs#2022-05-1519:51Kovas Palunasi get ErrorReferenceError: process is not defined#2022-05-1519:51Kovas Palunashere
;af(function() {
  return dt();
}, process.argv.slice(2));
#2022-05-1519:52Kovas Palunasthis is the very last bit of code in the file!#2022-05-1519:55thhelleragain. :node-script assumes node. try :browser#2022-05-1519:56thhellerI'm not asking about v8 in general. I need to know in the context of google apps script what features it supports#2022-05-1519:56thhellernode is also v8 and that has global and process just fine#2022-05-1519:56thhellerso, are there any docs specifically about what the google apps script runtime is capable of?#2022-05-1519:57Kovas Palunasi haven't found them yet#2022-05-1519:59thhellerI would write a custom :target for this that handles all the appscript specific stuff. I just don't have time to look into that currently#2022-05-1520:00thhelleryou can try :target :esm instead of browser as well https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-05-1520:01thhellermaybe the v8 supports import, then dev builds might work. otherwise release only again#2022-05-1520:01thhellerbut that should not have any process or global references#2022-05-1520:01thhelleralthough it may have globalThis. which may or may not be present in that v8 variant#2022-05-1520:03Kovas Palunasno dice on the :esm yet: message: "Syntax error: SyntaxError: Unexpected token 'export' line: 14202 file: ",#2022-05-1520:03Kovas Palunasno worries!! I'm super grateful for all the tips so far!#2022-05-1520:10thhellerif you remove that export line? should be like the last one#2022-05-1520:10thhellerI believe you can also just leave out exports in the build config and just use :entries [your.ns]#2022-05-1520:18Kovas Palunasok i got something working#2022-05-1520:19Kovas Palunasi needed to add "var global = {}; var process = {\"argv\": [\"one\", \"two\"]};" to the top of my file#2022-05-1520:20Kovas Palunasand i needed to remove the (function(){ ... })();#2022-05-1520:20Kovas Palunaswrapping the entire file#2022-05-1520:20Kovas Palunashacky but it seems to work#2022-05-1520:27Kovas Palunashaha this is kinda silly but i'm glad the problem is solved. i'll make a note to myself to write this up somewhere. or would you take this hack as a contribution for :target :apps-script#2022-05-1520:27Kovas Palunas?#2022-05-1520:28thhellerwell with a custom target it would be less hacky#2022-05-1520:28thhellerbecause the process thing is added by :node-script#2022-05-1520:28thhelleras well as all the other stuff pretty much#2022-05-1520:28Kovas Palunasok that makes sense#2022-05-1520:29thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/node_script.clj#2022-05-1520:29thhelleryou can try to create your own impl. can be in your repo. doesn't need to be part of shadow-cljs itself. no fork or so needed#2022-05-1520:30Kovas Palunashow can i reference my own impl from my shadow-cljs.edn?#2022-05-1520:31thhellerif you create a shadow.build.targets.google-apps-script ns or so#2022-05-1520:31thhellerjust :target :google-apps-script#2022-05-1520:32thhelleror :target your.ns with (ns your.ns)#2022-05-1520:32thhellerit looks for a process fn just like in the :node-script impl#2022-05-1520:32Kovas Palunasthis namespace is in a clj file that I reference with shadow-cljs?#2022-05-1520:33Kovas Palunasor in a fork of shadow-cljs i make?#2022-05-1520:33thhellerit is just a clj file in your repo#2022-05-1520:33thhelleras I said no fork or anything#2022-05-1520:33thhellerjust copy the node-script file from above and rename it#2022-05-1520:33thhellerthen start hacking 😉#2022-05-1520:33thhellerrun a shadow-cljs clj-repl or work on it from your editor#2022-05-1520:34Kovas Palunasright i guess when you say "your repo" do you mean my own copy of the shadow-cljs repo, or my project repo?#2022-05-1520:34thhellerproject repo#2022-05-1520:34Kovas Palunasoh ok#2022-05-1520:34thhellerjust needs to be on the classpath. no modification in shadow-cljs required whatsoever#2022-05-1520:34Kovas Palunascan i specify the classpath in shadow-cljs.edn?#2022-05-1520:35Kovas Palunas(i've not worked with clj much, only cljs)#2022-05-1520:36thhellerhttps://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html#2022-05-1520:36thhelleryou already do. :source-paths ["src"] so just src/shadow/build/targets/google_apps_script.clj or whatever name you want#2022-05-1520:37Kovas Palunasah ok cool!#2022-05-1520:37Kovas Palunasthanks!!#2022-05-1520:40Kovas Palunasdo you know if the function that wraps everything is described in https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/node_script.clj ?#2022-05-1520:41thhellersorry way too late to walk you through this. that part happens in the flush call, so the node/flush-optimized#2022-05-1520:42Kovas Palunasno worries!#2022-05-1612:08Filipe Silva@thheller I think 2.19.0 wasn’t pushed to npm#2022-05-1612:08Filipe Silva
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "7117181d18011402181d0710313c1012331e1e1a5c21031e"}, :content ("[email protected]")}
#2022-05-1618:14thheller@filipematossilva oops, forgot to publish that. fixed now. thanks.#2022-05-1708:31pezAt my day job we have mostly ClojureScript projects, but one project is being ported to NextJS. This is a browser project. We have some libraries written in ClojureScript that we want to consume from the NextJS project. What are our options if we do not want to load several instances of the ClojureScript runtime? Since it is only one JS project maybe it would work to build one browser module with one endpoint per CLJS library? Any new JS projects would do something similar.#2022-05-1709:11thheller@pez https://clojureverse.org/t/generating-es-modules-browser-deno/6116 or the older :target :npm-module#2022-05-1710:51henryw374hi @thheller. since the last cljs release, data_readers.cljc containing reader conditionals works. for example:
#?(:clj {}
   :cljs {foo/bar my.project.foo/bar})
but this does not work in shadow. It looks like `
(cljs.analyzer/load-data-readers)
is not getting called as it does when invoking cljs.build.api/build
#2022-05-1711:16thhellerthey are opt-in in shadow-cljs. you need to set :compiler-options {:data-readers true} in the build config#2022-05-1711:18thhellerno clue if it works then though. I don't think data readers should ever be used for anything directly in source code#2022-05-1711:45henryw374also, tags from data_readers.cljc files are used when reading data with cljs.reader fns#2022-05-1711:55thhelleryeah, and I don't ever want those to leak into my build just because they are on the classpath#2022-05-1711:56thhellerit also creates certain "undefined load order" issues since things break if you don't actually ever require the namespaces uses in those directly#2022-05-1712:45henryw374all true.#2022-05-1711:18thhellerif you do all bets are off regarding caching and build reliability. so use with care.#2022-05-1711:19henryw374thanks I'll try that. I use them at the repl#2022-05-1711:43henryw374it's not working. in shadow I see
;; taken from cljs.closure since its private there ...
(defn load-data-reader-file [mappings ^java.net.URL url]
in shadow.build.classpath . the load-.. fn has moved to cljs.analyzer and is still private. although e.g.
(cljs.analyzer/load-data-readers)
is public, with memoized and unmemoized versions
#2022-05-1712:05thhellerplease create an issue for this. can't get to it right now#2022-05-1712:44timoHi, I am getting
Execution error (AWTError) at sun.awt.X11GraphicsEnvironment/initDisplay (X11GraphicsEnvironment.java:-2).
Can't connect to X11 window server using '172.18.32.204
when running npx shadow-cljs browser-repl . I am inside a VM without X-server. Anyone has an idea?
#2022-05-1712:51timook got it, sorry#2022-05-1715:16Samuel McHughSeeing
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:476).
com.google.javascript.jscomp.JSModule
Unfortunately haven't been able to reproduce this issue in a simple project. Using
org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/clojurescript {:mvn/version "1.11.51"}
thheller/shadow-cljs {:mvn/version "2.19.0"}
I'll include the full stacktrace in this thread.
#2022-05-1715:18Samuel McHugh#2022-05-1715:17thhellervery likely to be a dependency conflict. make sure you have the appropriate closure-compiler and cljs versions (guessing you are using project.clj or deps.edn to manage dependencies)#2022-05-1715:19thhellercheck which closure-compiler version oyu are getting via clj -A:your-aliases -Stree or so#2022-05-1715:20Samuel McHugh
org.clojure/clojurescript 1.11.51
  . com.google.javascript/closure-compiler-unshaded v20220502 :newer-version
This?
#2022-05-1715:21thhellerseems correct#2022-05-1715:22thhellerrun clj -A:your-aliases and then (require ')#2022-05-1715:23thheller( "com/google/javascript/jscomp/JSModule.class")#2022-05-1715:24Samuel McHughreturns nil#2022-05-1715:25thhellerseems like your dependencies got messed up somehow#2022-05-1715:26thhellerhmm wait#2022-05-1715:26thhellerthis file isn't supposed to exist#2022-05-1715:27thhelleryou do actually use deps.edn to manage dependencies correct? there is a :deps true or :deps {:aliases ...} in your shadow-cljs.edn?#2022-05-1715:27thhelleryou seem to have a old shadow-cljs version? JSModule has been gone for a while now#2022-05-1715:28thhellercheck ( "shadow/build/closure.clj")#2022-05-1715:28Samuel McHugh
#object[java.net.URL 0x7af707e0 "jar:file:/home/foobar/.m2/repository/thheller/shadow-cljs/2.19.0/shadow-cljs-2.19.0.jar!/shadow/build/closure.clj"
#2022-05-1715:30Samuel McHughBut fair enough. I'm working in a mono repo with lots of projects, most of which are on old versions of shadow. I'd expect -Stree to have revealed that the old shadow is being used but maybe there is something else funky going on.#2022-05-1715:30thhellerhmm yeah dunno. that file is definitely not trying to load JSModule anywhere#2022-05-1715:31thheller(it was renamed to JSChunk a while ago in the closure-compiler)#2022-05-1715:31thhellermy guess is an incompatible mix of shadow-cljs, cljs and closure-compiler somewhere#2022-05-1715:32thhellerclosure compiler version you can check via ( "com/google/javascript/jscomp/JSChunk.class")#2022-05-1715:32thhellerI'd assume that exists#2022-05-1715:32thhellermaybe some bad leftover AOT code? so try ( "shadow/build/closure__init.class")#2022-05-1715:35Samuel McHugh
#object[java.net.URL 0x7da10b5b "jar:file:/home/foobar/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/JSChunk.class"]
and
nil
respectively
#2022-05-1715:37thhellerthat all looks fine. assuming that is what the classpath actually is when shadow-cljs runs#2022-05-1715:37thhellerI mean you can just (require 'shadow.build.closure) in the REPL#2022-05-1715:38thhellerthat should be fine then#2022-05-1715:51Samuel McHughFound the issue... 🤯 There are actually 2 shadow builds that run in parallel when I call a script and so the error messaging was coming from that second build which I never pay attention to. Oops. And ofcourse it has its own deps.edn and so I was checking in the repl sourcing the wrong deps.edn. TLDR: running stuff in parallel makes logs confusing 🙂#2022-05-1716:01Samuel McHughThanks for your help. Much appreciated#2022-05-1720:10yura parenyukHello everyone! I am in need of help with installation of shadow-cljs. I'm trying to add syncfusion dependency, but it's giving error: The required JS dependency "@syncfusion/ej2-react-layout" is not available, it was required by "poc/core.cljs".#2022-05-1720:34thhellerdid you install it via npm install @syncfusion/ej2-react-layout in the project dir?#2022-05-1720:35yura parenyukIt's in package.json, and I have it installed too.#2022-05-1720:35thhellerquick google suggest the package name is actually @syncfusion/ej2-react-layouts. so you are missing an s?#2022-05-1720:37yura parenyukOh... my ... :man-facepalming:#2022-05-1722:05yura parenyukHi @thheller, I have coded the the components, it's compiling successfully, but output is not showing.#2022-05-1722:05yura parenyukIt means I've coded the components, but there's something wrong with Interop. Right?#2022-05-1722:07thhellerdon't have a clue. I know neither the library you are using nor the interop lib. I also haven't used react in many years. ask in the appropriate channel.#2022-05-1722:45yura parenyukThanks#2022-05-1810:06timoAnyone knows a template to produce a fresh project with clj-tools and shadow-cljs?#2022-05-1810:07timoI need a proper uber-build process for my project.#2022-05-1811:05Samuel McHughHi, I'm trying to find the source of the following issue.
Failed to inspect file
  /home/foo/qux/node_modules/highlight.js/lib/languages/isbl.js

it was required from
  /home/foo/qux/node_modules/highlight.js/lib/index.js

Errors encountered while trying to parse file
  /home/foo/qux/node_modules/highlight.js/lib/languages/isbl.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}
I have two projects A and B. A experiences the issue above. I have tried to trim away as much superfluous code as possible. B is created from scratch to match A as closely as possible. Notably • both projects have the exact same -Stree output. • Both have the exact same package.json and produced package-lock.json I have seen though that A produces one extra dir though. .shadow-cljs/builds/foo/dev/shadow-js . B does not have this directory. What could cause A to produce this?
#2022-05-1811:16Samuel McHughAlso the compile is non deterministic. Sometimes it fails, sometimes it doesn't. My suspicion is that the https://github.com/bhauman/devcards/issues/168 no longer works with 2.19.0
(ns frontend.highlight
  (:require ["highlight.js" :as hljs]))

(js/goog.exportSymbol "hljs" hljs)
(js/goog.exportSymbol "DevcardsSyntaxHighlighter" hljs)

;;;

{:ns-aliases {devcards-syntax-highlighter frontend.highlight}
#2022-05-1816:42thhellerwell what does /home/sam/Code/pitch-app/platform/node_modules/highlight.js/lib/languages/isbl.js look like?#2022-05-1816:44thhelleras to shadow-js missing. that is only created for :js-provider :shadow (eg. :target :browser) builds that use actual npm dependencies. other targets such as :npm-module or the :node-* variants won't produce this#2022-05-1816:45thhellercould just be a somehow corrupted js file?#2022-05-1906:57danielstocktonGetting something fairly similar when updating to 2.19.0
Failed to inspect file                                                                                  
  /home/dan/code/story-builder/node_modules/highlight.js/lib/languages/gml.js                                                                                                                                       
                                                                                                                                                                                                                    
it was required from                                                                                    
  /home/dan/code/story-builder/node_modules/highlight.js/lib/index.js                                                                                                                                               
                                                                                                          
Errors encountered while trying to parse file                                        
  /home/dan/code/story-builder/node_modules/highlight.js/lib/languages/gml.js                                                                                                                                       
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}     @
#2022-05-1906:57danielstocktonThe gml.js doesn't look corrupted#2022-05-1907:24thhelleris that the full error? there should be more?#2022-05-1907:27thhellerI can't reproduce this locally#2022-05-1907:28thhellerwhat is your build :target? any specific :compiler-options? you sure you have the matching shadow-cljs, cljs, closure-compiler versions?#2022-05-1907:28Samuel McHughTry running your compile a few times just to be sure. Like I said it was non-deterministic for me.#2022-05-1907:28Samuel McHugh:target :karma#2022-05-1907:30thhellerwas that the full error for you? the error should be longer showing the actual cause?#2022-05-1907:30Samuel McHugh#2022-05-1907:32thhellerlooks fine#2022-05-1907:34thheller
Closure compilation failed with 1 errors
--- node_modules/highlight_DOT_js/lib/languages/python.js:11
Cannot convert ECMASCRIPT_2018 feature "RegExp unicode property escape" to targeted output language.
#2022-05-1907:34thhellerthis error I can reproduce but just requires setting :output-feature-set :es8#2022-05-1907:34thheller(which is the default for :karma so not needed to set it)#2022-05-1907:35Samuel McHugh#2022-05-1907:35thhellerah there you have it#2022-05-1907:35thhellerthat is a closure compiler error#2022-05-1907:40thhellerweird since that should be totally reproducible#2022-05-1907:40thhellerunless you have manually reduced the stack size or something?#2022-05-1907:41Samuel McHughIf you're curious about the file. Only special thing I can see about it is it has some funky unicode chars#2022-05-1907:41thhellerhttps://github.com/google/closure-compiler/issues/1661#2022-05-1907:42thhellerthat appears to match the source and error trace#2022-05-1907:42thhellerbut supposedly was fixed a long time ago 😛#2022-05-1907:42thheller
There are two workarounds for this issue that I have found:

Break the string concatenation up into multiple statements
Increase JVM stack size, e.g. -Xss8M
#2022-05-1907:43thhellerdunno why that would break randomly though. stack size is fixed by default IIRC#2022-05-1907:44thhellerwhy are you including this in the first place? do you really need syntax highlighting for isbl? whatever that is 😛#2022-05-1907:45thhellerthere is also an older https://github.com/thheller/shadow-cljs/issues/780#2022-05-1907:46thhellerso looks like this isn't the first time this has come up#2022-05-1907:46Cal HerriesThe error is deterministic for me. It happens every time#2022-05-1907:46thhellercan you try setting :jvm-opts ["-Xss8M"] in shadow-cljs.edn (if you are not using deps.edn or project.clj, otherwise needs to be set there)#2022-05-1907:47thhellerjust to see if that removes it?#2022-05-1907:51Samuel McHughyup, increasing the stack size looks like it fixes it.#2022-05-1907:53Samuel McHughso in conclusion the new closure compiler version can't handle large strings in the stack as well as the previous version?#2022-05-1907:58thhellercan't say. the error has come up before#2022-05-1908:00thhellercan't think of anything else to address this either#2022-05-1908:12Samuel McHughhttps://github.com/google/closure-compiler/issues/3945#2022-05-1908:13Samuel McHughFeel free to add any extra info. Maybe someone will notice a regression introduced in the later version which blows up the stack in some edge cases.#2022-05-1908:13Samuel McHughThanks for the help!#2022-05-2010:49thhellerwhich java versions do you use? how much RAM do you have? I can't reproduce this locally in any way but my guess is that java17 with 32gb of ram sort of influences this?#2022-05-2010:50thhellerI'd like to avoid a route where I bump the default stack size for every compile thread just because (like the closure compiler is doing)#2022-05-2011:09thhellerjust to confirm: this is due to you using re-frame-10x right? or do you use highlight.js in any other context?#2022-05-2011:10thhellerthe easiest fix for all of this is just not loading these highlight.js languages in the first place?#2022-05-2011:11Samuel McHughI'm on openJDK 11.0.15, 32GB of ram#2022-05-2011:11Samuel McHughI'm just working on a bit of an old app which uses devcards and devcards need to require highlight.js to work with shadow I suppose.#2022-05-2011:12thheller:js-options {:package-overrides {"highlight.js" {"./lib/languages/isbl.js" false}}} would also work to just manually disable that one#2022-05-2011:12Samuel McHughI agree this work isn't worth doing just for that, but if more people start reporting problems for other npm libraries, now we know#2022-05-2011:13thhellerhaven't tested this so it might blow up#2022-05-2011:13thhellerbut it'll make shadow-cljs just not bundle that file#2022-05-2011:14thhelleryou could also fix it manually by overriding the cljsjs require and only including the languages you want#2022-05-1819:20jpmonettashi everybody! When working on a shadow-cljs browser-repl, Is there a way of reloading .clj files (for macros) when they change without restarting the repl?#2022-05-1819:22thhellerjust work on them from the clojure repl? I typically work on macros from the clojure REPL only. often without even a CLJS build running#2022-05-1819:24jpmonettashmm not sure I follow, I'm tweaking some macros while trying them from cljs repl#2022-05-1819:26jpmonettasso just running shadow-cljs browser-repl which starts just a cljs-repl#2022-05-1819:28thhellerfor example a macro I just wrote#2022-05-1819:28thhellerhttps://github.com/thheller/shadow-cljs/blob/05f2cd1c525fea02781eef4329d5d7823be7f8a0/src/main/shadow/cljs/modern.cljc#L311-L342#2022-05-1819:28thhellershadow-cljs clj-repl (or my editor in this case)#2022-05-1819:29thhellermove cursor to one of the things in the comment form and eval that#2022-05-1819:29thhellerI mean sure if you macros get more complex that might become harder#2022-05-1819:29thhellerdunno what you are doing#2022-05-1819:30thhelleryou can also just run shadow-cljs clj-repl while the browser repl is running#2022-05-1819:30thhellerthey'll run in the same process#2022-05-1819:31jpmonettasit is not easy for me to try them on the clj repl because the macro walks over cljs macroexpanded code, like (instrument (macroexpand (defmethod foo []...))), can't try them on clojure side since defmethod macroexpands to something different#2022-05-1819:31jpmonettasok, I guess if I'm running a shadow-cljs clj-repl I can do a (require '[ns] :reload)#2022-05-1819:36jpmonettasyeah, it does the trick, thanks @thheller!#2022-05-1916:25Tiago Dall'Ocaany examples on how to use https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks? I'm getting build hook: my.util/hook failed to load and will not be used#2022-05-1916:52thheller@mrdalloca start a clojure repl and load the namespace. eg. shadow-cljs clj-repl then (require 'my.util). that apparently fails?#2022-05-1916:54thhellerI'm assuming here you actually changed the namespace and didn't use my.util?#2022-05-1916:54Tiago Dall'Ocaaah now I see!#2022-05-1916:55Tiago Dall'Ocait has to be a .clj file#2022-05-1916:55Tiago Dall'Ocais there any way to interact with the cljs runtime during compilation?#2022-05-1917:02thhellerduring compilation there is no cljs runtime. the runtime will only load the final result#2022-05-1917:02thhellerwhat do you want to do?#2022-05-1917:04Tiago Dall'Ocaa very specific use case haha#2022-05-1917:05Tiago Dall'OcaI want to be able to load malli schemas and spit out a file containing said schemas (simplifying)#2022-05-1917:05Tiago Dall'Ocathose schemas are defined in my cljs code#2022-05-1917:05thhellernot possible in a hook#2022-05-1917:06thhelleryou can move the schemas to .cljc files though#2022-05-1917:36Tiago Dall'Ocayess#2022-05-1917:36Tiago Dall'Ocathat's what I thought#2022-05-1917:36Tiago Dall'OcaI'm doing some porting to test this#2022-05-1917:46jcoyleJust wondering if anyone has used this recently? https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/10#2022-05-1917:47jcoyleI just tried it but I’m getting:
shadow.user=> (shadow/release-snapshot :app {})
Syntax error compiling at (REPL:1:1).
No such var: shadow/release-snapshot
#2022-05-1917:47thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2022-05-1917:47thhellerthat post is super old and build reports are the current thing#2022-05-1917:49jcoyleaaahhh sorry about that - I did first try searching the user guide for release-snapshot but didn’t see anything. Thanks again for all your hard work on shadow - such a great tool!#2022-05-1918:40Tiago Dall'Oca@thheller if I'm using snapshot dependencies, how to download them again?#2022-05-1918:45thhellerno clue. I have never used a snapshot dependency 😛#2022-05-1918:46thhellerdeleting .shadow-cljs/classpath.edn maybe?#2022-05-1918:46thhellerdon't actually know what makes them update#2022-05-1919:09Tiago Dall'OcaI'm just deleting the dependencies from disk 😛#2022-05-1919:09Tiago Dall'Ocaworking for now but not ergonomic haha#2022-05-1919:09Tiago Dall'OcaI won't need this specifically often I think#2022-05-2009:34motformIs there a gotcha for using npm modules that call into wasm? I have added https://github.com/drbh/wasm-flate as a dependency and I can :require it, but the namespace just returns an empty js obj (ie #js {}), which predictably results in no actual functions to call. The https://drbh.github.io/wasm-flate/ mention the use of wasm bindgen to create the JS files needed, but it seems like that is also unnecessary when using the npm version`?#2022-05-2009:35motformI guess either this is a specific problem with flate and you can disregard it or there is something I'm missing about working with wasm in shadow#2022-05-2009:38thhellershadow-cljs does not support bundling wasm files#2022-05-2009:40thhellerdepending on how the lib is used you may however just copy the wasm file manually and load it#2022-05-2009:41thhellersome js libs support this. can't say anything about this one in particular#2022-05-2010:10motformOK, thanks! I'll see if I can do it manually then, or just use some pure js-equivalent.#2022-05-2016:54p-himikDo you have any clue on what this warning means?
14 | (defn app-view []
------------^-------------------------------------------------------------------
 Receiver reference in function app.core.app_view changes meaning when namespace is collapsed.
 Consider annotating @nocollapse; however, other properties on the receiver may still be collapsed.
--------------------------------------------------------------------------------
#2022-05-2017:01thheller@p-himik hmm no clue. maybe you have app defined in externs somehow?#2022-05-2017:11p-himikOh, seems like just this is enough to reproduce it.
(defn f []
  (this-as this))
#2022-05-2017:15p-himikGonna speculate a bit since I have no idea what's going on. GCC sees this ("receiver reference") while f belongs to app.core - it thinks that the value of this is expected to be an instance of app.core#2022-05-2017:17thhellerthats not valid. this would be undefined here?#2022-05-2017:18thhellerbut yes that is the problem. can't use this-as on namespaced "vars"#2022-05-2017:21p-himik> this would be undefined here? Not if you use .bind. :)#2022-05-2017:25thhellerhmm there is an annotation for this I believe (not @nocollapse though)#2022-05-2017:29thhellerwhat are you binding this to though?#2022-05-2017:31p-himikIt's just a random observation that I got curious about - not a serious attempt at something. E.g. adding this still results in the same warning:
((.bind f #js {}))
#2022-05-2110:05lepistaneI am trying to make clojure script toolbox (think of it as util functions) for a Vue.js project. I've used https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module to successfully require that module from Vue.js and be able to use it. My only question is do i have to have ^:export before vars in order for their names to remain after compilation? I am assuming yes but just want to confirm Btw thanks a lot for shadow-cljs every time i use it my mind gets blown and my appetite for more grows gratitude#2022-05-2117:45lepistaneTo continue on the topic... I have Vue.js project and in root folder i have /cljs folder with shadow-cljs template. So vue-project | package.json | src ... |cljs (shadow-cljs template) At the moment i am doing
.../vue-project/cljs/

npm run module

which is

"shadow-cljs release code;"
for the config
{:target :npm-module
         :output-dir "../node_modules/cljs"
         :entries [cljs-helper.util]}
After that i do
cd ..

.../vue-project/

npm run serve (which runs Vue cli "vue-cli-service serve")
Its quite annoying to have to manually to the 're-release' if i make changes in cljs Is there a chance for me to run watch along side vue "vue-cli-service serve" ? What i tried: I basically added to vue-project/package.json new script "cljs": "cd cljs-helper && npm run watch-helper", and when i run it in terminal alongside another terminal with "vue-cli-service serve" i get this in the browser:
app.js:846 Uncaught ReferenceError: process is not defined
    at eval (cljs_env.js?e979:2:1)
    at Object../node_modules/cljs/cljs_env.js (chunk-vendors.js:467:1)
    at __webpack_require__ (app.js:843:33)
    at fn (app.js:1077:21)
    at eval (cljs_helper.util.js?a539:1:1)
    at Object../node_modules/cljs/cljs_helper.util.js (chunk-vendors.js:477:1)
    at __webpack_require__ (app.js:843:33)
    at fn (app.js:1077:21)
    at eval (Schedule.vue?5f81:283:1)
    at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Schedule.vue?vue&type=script&lang=js& (app.js:530:1)
1. is there anything that can be done to run this? 2. http://2.am i missing something in order to have these things work together? 3. Is it even possible?
#2022-05-2119:08thhellerhmm check the ../node_modules/cljs/cljs_env.js file#2022-05-2119:08thhellerdunno why it would be using process. might be something in your code?#2022-05-2119:09thheller../node_modules/cljs/cljs_helper.util.js#2022-05-2119:09thhellermaybe you are using process?#2022-05-2119:10thhellerprocess no longer is available by default in newer build systems#2022-05-2119:10thheller(eg. webpack)#2022-05-2119:11thhellermaybe you are trying to use js/process?#2022-05-2119:36lepistaneno process in my code this is basically the whole namespace
(ns cljs-helper.util
  (:require [cljs.pprint :as p]
            [cljs.reader :as r]))



(defn pprint [edn]
  (try
    (prn "pprinting edn...")
    (with-out-str (p/pprint (r/read-string edn)))
    (catch :default e
      (prn "Invalid EDN error pprint-ing" edn))))

#_ (pprint (str {:a {:b {:c {:d {:e 5 :ff {:f 6}}}}}}))

(defn ^:export pprintEdnString [ednString]
  (pprint ednString))

(prn "AAA")

(defn add-matches [fixtures id matches]
  (prn "fixtures: " fixtures)
  (prn "fixture-id: " id)
  (prn "list-of-matches: "  matches)
  (try
    (prn "adding-matches-to-fixture")
    (let [edn (r/read-string fixtures)]
      (assoc-in edn [id :matches] (set matches)))
    (catch :default e
      (prn "Invalid args in add-matches" fixtures id matches))))


(defn ^:export addMatches [fixtures fixture-id list-of-matches]
  (pprint (str (add-matches fixtures fixture-id list-of-matches))))
#2022-05-2119:40thhellerjust grep for process in the ../node_modules/cljs folder#2022-05-2119:40thhellersomething must be using it#2022-05-2119:49lepistaneSorry fro the wall of text
grep -rl "process" .
./package-lock.json
./.shadow-cljs/jar-manifest/clojurescript-1.11.51.jar.014c7fc361a498bc927c698e92b5b44761937348.manifest
./.shadow-cljs/jar-manifest/transit-js-0.8.874.jar.f8b4f570ca4d41649190efecac27a5932cc11429.manifest
./.shadow-cljs/jar-manifest/google-closure-library-0.0-20211011-0726fdeb.jar.e7c400433b3c1fadb574d4cc5a65cddccff5500f.manifest
./.shadow-cljs/jar-manifest/shadow-cljs-2.19.0-aot.jar.76fd0a8d13332a12d7ac3ea86931188b3dd03e59.manifest
./.shadow-cljs/jar-manifest/google-closure-library-third-party-0.0-20211011-0726fdeb.jar.7f1939dd0c9908d9314dd0ca4f4b89fd0ca783b8.manifest
./.shadow-cljs/builds/code/dev/ana/devtools/util.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/devtools/munging.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/devtools/hints.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/devtools/formatters/printing.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/devtools/formatters/core.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/shadow/cljs/devtools/client/shared.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/shadow/remote/runtime/shared.cljc.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/pprint.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/core/async/impl/dispatch.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/core/async.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/stacktrace.cljc.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/core.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/ana/cljs/tools/reader.cljs.cache.transit.json
./.shadow-cljs/builds/code/dev/goog-js/goog.events.event.js
./.shadow-cljs/builds/code/dev/goog-js/goog.uri.uri.js
./.shadow-cljs/builds/code/dev/goog-js/goog.uri.utils.js
./.shadow-cljs/builds/code/dev/goog-js/goog.base.js
./.shadow-cljs/builds/code/dev/goog-js/goog.html.trustedresourceurl.js
./.shadow-cljs/builds/code/dev/goog-js/goog.math.long.js
./.shadow-cljs/builds/code/dev/goog-js/goog.i18n.bidi.js
./.shadow-cljs/builds/code/dev/goog-js/goog.html.safehtml.js
./.shadow-cljs/builds/code/release/ana/cljs/pprint.cljs.cache.transit.json
./.shadow-cljs/builds/code/release/ana/cljs/core.cljs.cache.transit.json
./.shadow-cljs/builds/code/release/ana/cljs/tools/reader.cljs.cache.transit.json
./.shadow-cljs/builds/code/release/ana/reagent/core.cljs.cache.transit.json
./.shadow-cljs/builds/code/release/closure.variable.map
./node_modules/url/node_modules/punycode/punycode.js
./node_modules/shadow-cljs/cli/dist.js
./node_modules/shadow-cljs/cli/runner.js
./node_modules/safe-buffer/README.md
./node_modules/ws/lib/permessage-deflate.js
./node_modules/ws/lib/websocket.js
./node_modules/ws/lib/websocket-server.js
./node_modules/ws/lib/stream.js
./node_modules/ws/README.md
./node_modules/prop-types/checkPropTypes.js
./node_modules/prop-types/index.js
./node_modules/prop-types/factoryWithTypeCheckers.js
./node_modules/prop-types/prop-types.js
./node_modules/react/jsx-runtime.js
./node_modules/react/cjs/react-jsx-runtime.development.js
./node_modules/react/cjs/react.development.js
./node_modules/react/cjs/react-jsx-dev-runtime.development.js
./node_modules/react/index.js
./node_modules/react/umd/react.development.js
./node_modules/react/jsx-dev-runtime.js
./node_modules/timers-browserify/CHANGELOG.md
./node_modules/assert/test.js
./node_modules/assert/node_modules/util/test/node/log.js
./node_modules/assert/node_modules/util/test/node/debug.js
./node_modules/assert/node_modules/util/util.js
./node_modules/shadow-cljs-jar/bin/shadow-cljs.jar
./node_modules/constants-browserify/test.js
./node_modules/node-libs-browser/index.js
./node_modules/node-libs-browser/package.json
./node_modules/node-libs-browser/README.md
./node_modules/safer-buffer/Readme.md
./node_modules/safer-buffer/Porting-Buffer.md
./node_modules/safer-buffer/safer.js
./node_modules/pbkdf2/lib/async.js
./node_modules/pbkdf2/lib/default-encoding.js
./node_modules/setimmediate/setImmediate.js
./node_modules/punycode/punycode.js
./node_modules/source-map-support/source-map-support.js
./node_modules/source-map-support/README.md
./node_modules/source-map-support/browser-source-map-support.js
./node_modules/scheduler/tracing.js
./node_modules/scheduler/cjs/scheduler-unstable_mock.development.js
./node_modules/scheduler/cjs/scheduler-tracing.development.js
./node_modules/scheduler/cjs/scheduler.development.js
./node_modules/scheduler/index.js
./node_modules/scheduler/unstable_mock.js
./node_modules/scheduler/tracing-profiling.js
./node_modules/sha.js/test/vectors.js
./node_modules/sha.js/bin.js
./node_modules/process-nextick-args/index.js
./node_modules/process-nextick-args/package.json
./node_modules/process-nextick-args/readme.md
./node_modules/process/index.js
./node_modules/process/package.json
./node_modules/process/README.md
./node_modules/process/test.js
./node_modules/process/browser.js
./node_modules/stream-http/lib/response.js
./node_modules/stream-http/lib/request.js
./node_modules/stream-http/README.md
./node_modules/stream-http/test/server/index.js
./node_modules/stream-http/test/browser/abort.js
./node_modules/readline-sync/lib/readline-sync.js
./node_modules/readline-sync/lib/encrypt.js
./node_modules/readline-sync/README.md
./node_modules/react-dom/cjs/react-dom-unstable-fizz.node.development.js
./node_modules/react-dom/cjs/react-dom-test-utils.development.js
./node_modules/react-dom/cjs/react-dom.development.js
./node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.development.js
./node_modules/react-dom/cjs/react-dom-server.node.development.js
./node_modules/react-dom/cjs/react-dom-server.browser.development.js
./node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.development.js
./node_modules/react-dom/index.js
./node_modules/react-dom/unstable-native-dependencies.js
./node_modules/react-dom/test-utils.js
./node_modules/react-dom/umd/react-dom.development.js
./node_modules/react-dom/umd/react-dom-server.browser.development.js
./node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js
./node_modules/react-dom/unstable-fizz.browser.js
./node_modules/react-dom/server.browser.js
./node_modules/react-dom/unstable-fizz.node.js
./node_modules/react-dom/profiling.js
./node_modules/react-dom/server.node.js
./node_modules/pako/lib/zlib/trees.js
./node_modules/pako/lib/zlib/inftrees.js
./node_modules/pako/lib/zlib/inflate.js
./node_modules/pako/lib/utils/strings.js
./node_modules/pako/lib/inflate.js
./node_modules/pako/dist/pako_inflate.js
./node_modules/pako/dist/pako.js
./node_modules/pako/dist/pako_deflate.js
./node_modules/buffer/test/write.js
./node_modules/buffer/test/from-string.js
./node_modules/buffer/test/is-buffer.js
./node_modules/buffer/test/to-string.js
./node_modules/buffer/test/methods.js
./node_modules/buffer/test/write_infinity.js
./node_modules/buffer/test/base64.js
./node_modules/buffer/test/constructor.js
./node_modules/buffer/test/basic.js
./node_modules/buffer/test/slice.js
./node_modules/buffer/test/compare.js
./node_modules/buffer/test/static.js
./node_modules/buffer/bin/download-node-tests.js
./node_modules/buffer/bin/test.js
./node_modules/react-is/cjs/react-is.development.js
./node_modules/react-is/index.js
./node_modules/builtin-status-codes/browser.js
./node_modules/crypto-browserify/test/index.js
./node_modules/crypto-browserify/example/bundle.js
./node_modules/readable-stream/writable.js
./node_modules/readable-stream/package.json
./node_modules/readable-stream/lib/_stream_readable.js
./node_modules/readable-stream/lib/internal/streams/destroy.js
./node_modules/readable-stream/lib/_stream_transform.js
./node_modules/readable-stream/lib/_stream_duplex.js
./node_modules/readable-stream/lib/_stream_writable.js
./node_modules/readable-stream/node_modules/safe-buffer/README.md
./node_modules/readable-stream/GOVERNANCE.md
./node_modules/readable-stream/readable.js
./node_modules/source-map/lib/source-node.js
./node_modules/source-map/CHANGELOG.md
./node_modules/source-map/dist/source-map.debug.js
./node_modules/source-map/dist/source-map.js
./node_modules/source-map/dist/source-map.min.js.map
./node_modules/miller-rabin/bin/miller-rabin
./node_modules/path-browserify/index.js
./node_modules/path-browserify/test/test-path.js
./node_modules/util/util.js
./node_modules/which/bin/which
./node_modules/which/which.js
./node_modules/randombytes/browser.js
./node_modules/isexe/index.js
./node_modules/isexe/test/basic.js
./node_modules/isexe/windows.js
./node_modules/isexe/mode.js
./node_modules/browserify-zlib/yarn.lock
./node_modules/browserify-zlib/karma.conf.js
./node_modules/browserify-zlib/lib/index.js
./node_modules/browserify-zlib/lib/binding.js
./node_modules/browserify-zlib/src/index.js
./node_modules/browserify-zlib/src/binding.js
./node_modules/create-react-class/factory.js
./node_modules/create-react-class/create-react-class.js
./node_modules/loose-envify/cli.js
./node_modules/loose-envify/index.js
./node_modules/loose-envify/package.json
./node_modules/loose-envify/README.md
./node_modules/loose-envify/replace.js
./node_modules/loose-envify/loose-envify.js
./node_modules/browserify-sign/node_modules/readable-stream/experimentalWarning.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_readable.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/async_iterator.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/internal/streams/destroy.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_transform.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_duplex.js
./node_modules/browserify-sign/node_modules/readable-stream/lib/_stream_writable.js
./node_modules/browserify-sign/node_modules/readable-stream/GOVERNANCE.md
./node_modules/browserify-sign/node_modules/readable-stream/readable.js
./node_modules/events/tests/special-event-names.js
./node_modules/events/tests/events-once.js
./node_modules/events/tests/check-listener-leaks.js
./node_modules/hash-base/node_modules/readable-stream/experimentalWarning.js
./node_modules/hash-base/node_modules/readable-stream/lib/_stream_readable.js
./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/async_iterator.js
./node_modules/hash-base/node_modules/readable-stream/lib/internal/streams/destroy.js
./node_modules/hash-base/node_modules/readable-stream/lib/_stream_transform.js
./node_modules/hash-base/node_modules/readable-stream/lib/_stream_duplex.js
./node_modules/hash-base/node_modules/readable-stream/lib/_stream_writable.js
./node_modules/hash-base/node_modules/readable-stream/GOVERNANCE.md
./node_modules/hash-base/node_modules/readable-stream/readable.js
./node_modules/randomfill/browser.js
#2022-05-2119:50thhelleronly the node_modules/cljs/*.js folder. not everything#2022-05-2119:52lepistane
node_modules/cljs$ grep -rl "process"
devtools.formatters.printing.js
cljs.core.js
cljs.pprint.js
cljs.core.async.impl.dispatch.js.map
devtools.util.js
devtools.hints.js
devtools.hints.js.map
cljs.stacktrace.js
cljs.tools.reader.js.map
cljs-runtime/cljs.core.js
cljs-runtime/goog.i18n.bidi.js.map
cljs-runtime/goog.html.safehtml.js.map
cljs-runtime/goog.html.trustedresourceurl.js.map
cljs-runtime/goog.uri.utils.js.map
cljs-runtime/goog.base.js
cljs-runtime/goog.uri.uri.js.map
cljs-runtime/cljs.core.js.map
cljs-runtime/goog.base.js.map
cljs-runtime/goog.math.long.js.map
cljs.core.async.js
devtools.munging.js.map
devtools.formatters.core.js
shadow.cljs.devtools.client.shared.js.map
cljs.core.async.impl.dispatch.js
devtools.formatters.core.js.map
devtools.util.js.map
devtools.formatters.printing.js.map
cljs.pprint.js.map
devtools.munging.js
shadow.remote.runtime.shared.js.map
cljs.core.async.js.map
cljs.stacktrace.js.map
cljs.core.js.map
shadow.cljs.devtools.client.shared.js
shadow.remote.runtime.shared.js
cljs_env.js
cljs.tools.reader.js
#2022-05-2119:54thhellerwell I guess process is a little too generic#2022-05-2119:54thhellermaybe process.#2022-05-2119:54lepistaneidentical output#2022-05-2119:55thhellerprocess\. I guess?#2022-05-2119:56lepistane
grep -rl "process\."
cljs.core.js
cljs-runtime/cljs.core.js
cljs-runtime/goog.i18n.bidi.js.map
cljs-runtime/goog.uri.utils.js.map
cljs_env.js
#2022-05-2119:56thhellerwhat is using process in cljs_env.js?#2022-05-2119:57lepistanefirst 3 lines
1 var $CLJS = {};
2 var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;
3 var CLOSURE_DEFINES = CLJS_GLOBAL.CLOSURE_DEFINES = $CLJS.CLOSURE_DEFINES = ....
#2022-05-2119:58thhelleroh doh. forgot that exists 😛#2022-05-2119:59thhellerhttps://stackoverflow.com/questions/41359504/webpack-bundle-js-uncaught-referenceerror-process-is-not-defined#2022-05-2119:59thhellermaybe that works as a workaround?#2022-05-2119:59lepistanechecking#2022-05-2119:59thhellerI guess I can add a check there if process is actually defined first
#2022-05-2120:01lepistanei apologize but i don't have webpack config in root vue project or in cljs one#2022-05-2120:02thhellerhttps://cli.vuejs.org/guide/webpack.html#2022-05-2120:03lepistane👀#2022-05-2120:41lepistanevue.config.js
// webpack needs to be explicitly required
const webpack = require('webpack')

module.exports = {
    css: {
        sourceMap: true
    },
    productionSourceMap: false,
    publicPath:  '/',


    configureWebpack: {
	plugins: [
	    // fix "process is not defined" error:
	    // (do "npm install process" before running the build)
	    new webpack.ProvidePlugin({
		process: 'process/browser',
	    }),
	]
    }

};
i ran
npm install process
npm run serve

> 
#2022-05-2120:46lepistaneScratch that... I should pay more attention#2022-05-2120:47lepistaneFirst i need to run
npm run cljs

AKA
  "cljs": "cd cljs-helper && npm run watch-helper",
AKA
	"watch-helper": "shadow-cljs watch code;",
first and then
npm run serve

AKA
"serve": "vue-cli-service serve",
[solved] :thumbsup: @thheller thanks a lot!!!
#2022-05-2113:20thheller@lepistane yes, :npm-module requires ^:export since it can't know what you are going to use otherwise#2022-05-2113:21thhelleryou could also the newer :target :esm which lets you control this via build config instead https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-05-2117:45lepistaneTo continue on the topic... I have Vue.js project and in root folder i have /cljs folder with shadow-cljs template. So vue-project | package.json | src ... |cljs (shadow-cljs template) At the moment i am doing
.../vue-project/cljs/

npm run module

which is

"shadow-cljs release code;"
for the config
{:target :npm-module
         :output-dir "../node_modules/cljs"
         :entries [cljs-helper.util]}
After that i do
cd ..

.../vue-project/

npm run serve (which runs Vue cli "vue-cli-service serve")
Its quite annoying to have to manually to the 're-release' if i make changes in cljs Is there a chance for me to run watch along side vue "vue-cli-service serve" ? What i tried: I basically added to vue-project/package.json new script "cljs": "cd cljs-helper && npm run watch-helper", and when i run it in terminal alongside another terminal with "vue-cli-service serve" i get this in the browser:
app.js:846 Uncaught ReferenceError: process is not defined
    at eval (cljs_env.js?e979:2:1)
    at Object../node_modules/cljs/cljs_env.js (chunk-vendors.js:467:1)
    at __webpack_require__ (app.js:843:33)
    at fn (app.js:1077:21)
    at eval (cljs_helper.util.js?a539:1:1)
    at Object../node_modules/cljs/cljs_helper.util.js (chunk-vendors.js:477:1)
    at __webpack_require__ (app.js:843:33)
    at fn (app.js:1077:21)
    at eval (Schedule.vue?5f81:283:1)
    at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Schedule.vue?vue&type=script&lang=js& (app.js:530:1)
1. is there anything that can be done to run this? 2. http://2.am i missing something in order to have these things work together? 3. Is it even possible?
#2022-05-2120:47lepistaneFirst i need to run
npm run cljs

AKA
  "cljs": "cd cljs-helper && npm run watch-helper",
AKA
	"watch-helper": "shadow-cljs watch code;",
first and then
npm run serve

AKA
"serve": "vue-cli-service serve",
[solved] :thumbsup: @thheller thanks a lot!!!
#2022-05-2123:47nivekuilis there a shadow+clojure tools docker image somewhere? want to set up a reproducible cljc dev environment#2022-05-2202:22nivekuil:main-opts ["-m" "shadow.cljs.devtools.cli" "server"] with the tools-deps image seems to be the way#2022-05-2216:30raymcdermottI have an integration in my SPA with a 3rd party security provider (OKTA) which makes a callback on localhost:8000/login/callback?blah=blahdeblah#2022-05-2216:31raymcdermotthow does shadow resolve this? It does and it's very nice, just interested in the mechanisms for how to set up my actual server 🙂#2022-05-2218:04thhellerthe server just needs to send the regular "index.html" content you'd get on localhost:8000. I assume you have the CLJS routing setup to handle the rest?#2022-05-2218:05thhellerthis handles it in shadow-cljs specifically https://github.com/thheller/shadow-cljs/blob/bd16408a7a60f75aaa14f1be576d38d536ebd639/src/main/shadow/http/push_state.clj#L10#2022-05-2218:20raymcdermottyes, I have the CLJS routing set up to work#2022-05-2218:37raymcdermottIt's what I understood and I'm failing to get it set up on an S3 bucket behind cloudfront so probably just some more JSON somewhere 🤞:skin-tone-3: #2022-05-2218:37raymcdermottThey do support redirects but tracing the behaviour is “fun”#2022-05-2219:25raymcdermottturns out that cloudfront allows me to return index.html for 403 errors and change the code to 200. So it's all working.#2022-05-2403:04cbci got that "Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running?" message that seems to be quite common among beginners...#2022-05-2403:05cbcthings were working properly for me, and then suddenly i started getting this error message#2022-05-2403:06cbci didn't know what i changed to cause it, i tried reloading the page, restarting browser, restarting repl, restarting shadow-cljs, restarting my machine#2022-05-2403:06cbcnothing seemed to work#2022-05-2403:07cbci also tried clearing cookies/localstorage for localhost#2022-05-2403:07cbcone clue was that a private tab DID work#2022-05-2403:07cbc(i'm using brave)#2022-05-2403:07cbcfinally i tried deleting the compiled app.js#2022-05-2403:08cbcverified that i got a 404 when i loaded the page#2022-05-2403:08cbcthen got shadow-cljs to rebuild it#2022-05-2403:08cbcand now...it works again#2022-05-2403:08cbcanybody have any idea what the problem might have been?#2022-05-2403:33cbcthe behavior seems possibly consistent with the page being cached in the browser (and private tabs ignoring the cache?), but i'm still not sure why things were working for several days before i hit this issue#2022-05-2403:33cbca friend suggested disabling the cache in the developer console:#2022-05-2403:33cbc#2022-05-2405:50thhellerdo you use the built-in :dev-http server or some other http server?#2022-05-2405:50thhellerthe built-in sets the proper cache headers so this doesn't happen. otherwise it might be cache related#2022-05-2405:50thhelleror you might have a service worker#2022-05-2405:51thhellerdon't know enough about your setup to say more#2022-05-2405:51thhellerthe problem could also be caused by having shadow-cljs running twice in the same project#2022-05-2405:51thhellerbasically interfering with each other#2022-05-2406:36cbci'm using kit, which bundles undertow#2022-05-2406:37cbcnow that i think about it, does my caching explanation even make sense? why would deleting app.js even cause a 404 in the console if it was cached?#2022-05-2406:37cbci don't know what a service worker is#2022-05-2406:38cbci did check for multiple shadow-cljs since you mentioned that to other people...restarting my machine and starting everything fresh should rule that possibility out#2022-05-2406:42thhellerif you don't set your caching headers I don't think any are set by default. which will not be ideal with regards to caching#2022-05-2406:43thhellerbut the network log should show whether it used a cached version or not#2022-05-2406:44thhellermaybe brave does some weird caching on its own. can't really say.#2022-05-2406:45cbci'm new to all this so i don't know how to check the caching headers in the response, but i'm very curious myself#2022-05-2406:45cbcpresumably there's some debug option i can set to get kit/undertow to print the response somewhere? (i will look into this more myself when i get a chance)#2022-05-2406:46cbcthe network log is a good idea, i'll check that next time i hit this problem#2022-05-2406:50thhellerjust check the network tab for the request for your .js file#2022-05-2406:51thhellerif served via :dev-http it has the Cache-Control: private, no-cache header#2022-05-2406:52thhellerand the response will either be a 200 or a 304 not modified#2022-05-2406:52thhellerno need to check kit/undertow. the browser network thing will tell you everything you need to know#2022-05-2407:17cbcahhh, very handy!!#2022-05-2407:17cbcthe response doesn't have any cache control headers#2022-05-2407:17cbc#2022-05-2407:24cbcbtw is it normal to see two of these "remote-relay" requests?#2022-05-2407:24cbc#2022-05-2407:31thhelleryes, thats the websocket connection for hot-reload/repl#2022-05-2407:36thhellerdunno why there is two but one is done so maybe it got reconnected? maybe computer sleep?#2022-05-2407:42cbcok, i only mentioned it in case it might be related to the issue was having, sounds like it's fine#2022-05-2410:10mjmeintjesI'm getting "No available JS runtime." while developing a file using an :npm-module based build target. The npm module is running in the browser - what is the best way to connect the repl when using :npm-module?#2022-05-2410:43mjmeintjesI think I figured it out, was missing the following:
window["$CLJS"] = require("./npm-module/cljs_env");
require("./npm-module/shadow.cljs.devtools.client.browser");
#2022-05-2419:21thhellerwindow["$CLJS"] = require("./npm-module/cljs_env"); this you shouldn't do. it won't work in a release build in case you use it for anything#2022-05-2418:46lambdamHello. I just bumped shadow version from 2.16.6 to 2.19.0 (latest) and get the following error : Caused by: java.lang.NoSuchMethodError: 'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()' I looked for it on Google but didn't get anything interesting. Does someone has a clue ? Thanks a lot.#2022-05-2419:21thhellerthis is caused by a dependency conflict on the guava dependency. the closure-compiler doesn't properly declare it so it gets messed up#2022-05-2419:36lambdamOh thanks. I forced guava to the latest version (`31.1-jre`) and it worked. > the closure-compiler doesn't properly declare it so it gets messed up Indeed, I couldn't find guava as a dependency of shadow using clj -X:deps tree | less#2022-05-2419:40thhelleryeah, fix is in process https://github.com/google/closure-compiler/pull/3935#2022-05-2723:54Dustin Getz@U3ZG4CAF8#2022-05-2723:58Dustin GetzAll, fix is to explicitly add
com.google.guava/guava {:mvn/version "31.1-jre"}
#2022-05-2501:14pinkfrogI’ve multiple node scripts file. Is it possible to define one build target instead for all of them? https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-script#2022-05-2501:25pinkfrogMy use case I don’t care about the final output of the script files. I just want to play with the scripts in a repl. And I’d like to define only one build target for all of the scripts.#2022-05-2501:33sansaripHmm :thinking_face: unless I’m misunderstanding, does specifying multiple build profiles to shadow-cljs not work for you? e.g. npx shadow-cljs watch :lib/dev :test 👆 this allows me to connect to a repl that allows me to play around in namespaces in both builds Though, my builds are of node-library targets and I’m using Calva to automate the repl-jack-in process https://github.com/sansarip/owlbear/blob/main/shadow-cljs.edn#2022-05-2501:34sansaripAre you just trying to avoid specifying multiple builds?#2022-05-2501:38pinkfrog> Are you just trying to avoid specifying multiple builds? Yes.#2022-05-2501:38pinkfrogI have several cljs files, and I just want to play with it.#2022-05-2501:38pinkfrogI don’t care about the generated js files.#2022-05-2501:38pinkfrogWhat’s the most suitable node target?#2022-05-2501:41pinkfrogIt would be desired that I am able to not specify the cljs file names in the build target.#2022-05-2501:48sansaripJust specify your :source-paths e.g. ["dev" "src/cljc" "src/cljs"] and then you should be able to just specify a build with either :node-library or :node-script as the target. Doesn’t really matter, because you don’t care about the output file. Then, npx shadow-cljs watch :<your build name> which will start an nrepl you’ll be able to remotely connect to. Once your cljs files have finished compiling, you’ll also [probably need] to run node -e "require('<path to your output file>')" which will give your repl a Node environment to execute in#2022-05-2503:30pinkfrogFor example, for taget :node-script, I have to specify the :main key, which points to a single script. Thus, for every script, I have to have a build target separately.#2022-05-2503:38pinkfrogI feel like nbb might be more suitable here.#2022-05-2505:39pinkfrogHi @U022T96EFV3 Where you are developing your vscode extension, do you get any code completion support (assume you are using calva)?#2022-05-2506:15thheller@UGC0NEP4Y npx shadow-cljs node-repl just gives you a node REPL. not tied to any build, you can load any namespace you want in there?#2022-05-2512:47sansarip> Hi @U022T96EFV3 Where you are developing your vscode extension, do you get any code completion support (assume you are using calva)? Yup, I do get code completion support from Calva!#2022-05-2512:48pinkfrogCompletion with node_module code or cljs code?#2022-05-2512:49sansaripOh! As far as I know, just cljs#2022-05-2512:35zonotopeHi. I'm trying to build a cljs app targeting expo wrapped react-native with shadow-cljs. I was able to follow the instructions in the guide to stand up an app scaffold that renders a basic view on the phone using cljs and the Rum react wrapper, but I'm having trouble accessing some js dependencies I have installed. I added the "react-native-vision-camera" library with the expo install react-native-vision-camera command, and I've verified that the library was both added to the package.json and yarn.lock, and that there is a directory corresponding to that library within node_modules. I can't seem to require this library at all from cljs land though. I get null pointer errors during app startup when I try to add the dependency to the ns :require clause. When I also try to require it from the repl like this (require '["react-native-vision-camera" :as vision]), the vision object is nil always. I have also tried to install another dependency, "react-native-gifted-chat", in the same way to verify it wasn't something wrong with that particular dependency, and that also doesn't seem to work. I can require dependencies that were already in package.json after generating the app scaffold like "react" and "react-native" however, so I can load things in node_modules; it just doesn't seem like shadow has access to js/expo dependencies I have added after the fact. There must be something I'm missing about the dependency install process, and that there's more to do besides expo install react-native-vision-camera or yarn add react-native-vision-camera from the shell, but I can't seem to pinpoint what I've done wrong or what I'm missing from the guides. Does anyone have any hints on how to add an external js/react-native/expo dependency to a shadow app targeting react-native so that it can be accessed from cljs code?#2022-05-2515:41thheller@zonotope JS dependencies in a react-native REPL cannot be required dynamically in the REPL if they haven't been included in the build otherwise before. JS dependencies are processed by metro which only sees the regular build output not the REPL.#2022-05-2814:21zonotopeThanks for your help, and sorry for the late reply, but I was focused on my day job for a bit there 😉. I think this has something to do with errors from the camera library that prevented the rest of the app from loading. Those errors are because this library must be natively built.#2022-05-2814:26zonotopeIt looks like the only native compilation option here is expo's eas build tool. I'm running into another configuration issue there because eas generates an android working directory to compile for that platform with gradle, and it isn't copying over my app directory or app/index js where it should be relative to the android working directory.#2022-05-2814:27zonotope
error The resource `/tmp/zonotope/eas-build-local-nodejs/5e63e06b-13cb-49a3-a597-aa44d97d5090/build/android/app/index.js` was not found.
`
#2022-05-2814:45zonotopeand i think i figured out that error at least. my app/ directory was in my .gitignore, and eas doesn't transfer any files in .gitignore. i'll bet there's a build hook i can add in to eas to generate the app directory with shadow instead of copying it, but i'll figure that out later since this works for now.#2022-05-2515:41thhelleras part of the regular build it should be fine though#2022-05-2515:41thhellerhow did you require it in your code? and do you have an example of how you are supposed to include it in JS?#2022-05-2516:07Tiago Dall'Oca
------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See 

------------------------------------------------------------------------------
any way to get rid of this warning?
#2022-05-2516:08thhellernpm install shadow-cljs?#2022-05-2516:12Tiago Dall'Ocano no#2022-05-2516:12Tiago Dall'Ocahaha#2022-05-2516:12Tiago Dall'OcaI just want the warning to go away#2022-05-2516:12Tiago Dall'Ocathere's really no need in my use case#2022-05-2516:13Tiago Dall'Oca(multiple projects in a mono-repo with pnpm)#2022-05-2516:13thhellerwhat do you mean? if you are using it it should be installed in the project?#2022-05-2516:13thhellernot sure how that changes anything?#2022-05-2516:14Tiago Dall'Ocabecause shadow-cljs is installed in the parent project#2022-05-2516:14Tiago Dall'Ocadoesn't need to be installed in the sub-project#2022-05-2516:14Tiago Dall'Ocapnpm works differently#2022-05-2516:14Tiago Dall'Ocait reuses node_module#2022-05-2516:15thhellernot sure how that works#2022-05-2516:16thhellerthe reason it is warning is that the shadow-cljs dependency also brings in other stay that may be required. eg. for node builds ws or for browser build node-libs-browser#2022-05-2516:16thhellerso if its not installed wherever it is running those may not be found#2022-05-2516:17Tiago Dall'Ocaanyhow#2022-05-2516:17Tiago Dall'Ocais there a way to shut the warning?#2022-05-2516:18thhellernot currently#2022-05-2516:18thhellertoo many people didn't install it in the project and kept asking questions why things fail 😛#2022-05-2516:19Tiago Dall'Ocaok haha#2022-05-2516:20Tiago Dall'Ocait's not a problem per se, just a bit annoying in my case#2022-05-2516:22thhellerstill don't understand what your setup is though. where do you control which shadow-cljs version is used?#2022-05-2516:22thhellerI hope you are not relying on a global install?#2022-05-2516:23thhellerall it is looking for is shadow-cljs installed in the package.json in the dir shadow-cljs is run in#2022-05-2516:24thhellerit doesn't care at all about node_modules or pnpm?#2022-05-2517:16Tiago Dall'Ocayeah#2022-05-2517:16Tiago Dall'OcaI installed it in the sub-project too#2022-05-2517:16Tiago Dall'Ocano more warning 🙂#2022-05-2517:16Tiago Dall'Ocathanks for your generosity#2022-05-2516:51BenjaminI pulled the example todo https://github.com/markokocic/rn-native-base-example-todo and have the shadow dev build running. It seems currently like I make changes, shadow updates it instant and then react native automatically refresh the app afterwards - and this auto refreshing I want to disable obviously#2022-05-2517:09thhellersorry I don't use react-native. don't know how you turn it off, but it needs to be turned off on the react-native/metro side. nothing in shadow-cljs can control this.#2022-05-2517:09thhellerhttps://github.com/markokocic/rn-native-base-example-todo#enable-shadow-cljs-reloading#2022-05-2517:33Benjaminyea I'm sure there is a setting :thumbsup:#2022-05-2600:08Luis Cerritos👋 Hello, guys! Greeting from Mexico. My name is Luis, I am new, working with shadow-cljs and lein-shadow 😛#2022-05-2600:10Luis Cerritosi am having an issue with docker, very very strange.. https://ibb.co/9Hp1ZZN I am getting stucked the container randomly on this step 😕 I deleted the container, the volumen, etc… but always I am having the same 😕#2022-05-2600:10Luis CerritosSomebody experimented something similar?#2022-05-2600:13Luis CerritosThanks for the help in advance!#2022-05-2606:30thhellerI strongly recommend not using lein-shadow. Besides that I don't know. I never use docker.#2022-05-2615:13Luis CerritosWhich is your recommendation to use instead it?#2022-05-2617:02thhellerjust plain shadow-cljs. with a without lein doesn't matter. just lein-shadow I don't recommend#2022-05-2612:11Karol WójcikIs it possible to enable REPL for :npm-module target on browser environment?#2022-05-2617:02thhelleryes, just need to manually require("./path-to-output/shadow.cljs.devtools.client.browser") in the JS somewhere#2022-05-2617:53Karol WójcikThank you! This works!!#2022-05-2615:24emauncurrently upgrading shadow-cljs from 2.15.2 (worked fine) to 2.19.0 and facing a macroexpanding error. It warns of not having the right dependency versions for clojure, clojurescript, and the compiler (i've updated those to the required versions). My build fails and this is the main error that pops up. Any thoughts on what's going on or how to fix?
Caused by: java.lang.NoSuchMethodError: 'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
#2022-05-2617:36sansaripFor more info, see this thread 👉 https://clojurians.slack.com/archives/C6N245JGG/p1653418014869959 🔍#2022-05-2620:54emaunthank you @U022T96EFV3!#2022-05-2723:53Dustin Getz@U3ZG4CAF8#2022-05-2617:01thheller@emaun that is a dependency conflict on the guava version. make sure you have the latest. the closure compiler doesn't properly declare it but fails with older ones#2022-05-2718:32rayatHow can I get a REPL JS Runtime connection if my stack looks like ( ➡️ `webpack` ➡️ `storybook web app` ) ?#2022-05-2718:36thhellerjust need to manually require("./path-to-output/shadow.cljs.devtools.client.browser") in the JS somewhere#2022-05-2718:36thhellerassuming you are using :target :npm-module#2022-05-2718:36thhellerno guarantee the REPL works at all though, better just use shadow-cljs browser-repl without webpack or storybook#2022-05-2718:42rayat1. Thanks so much for the rapid response, let alone for like single-handedly making shadow-cljs lol. 2. Going to try your first option, as it is :npm-module. 3. I apologize, but I am unsure what your suggestion means with "better just use ... without webpack or storybook", could you clarify? #2022-05-2718:47thhellerdo you specifically need a repl into the storybook? or do you just want a repl?#2022-05-2718:48rayatI suspect the latter, I think? Still new to clj/s, but I mainly want REPL-powered IDE language features#2022-05-2718:49thhellerthen browser-repl is enough#2022-05-2718:51lilactownbasically when you jack in, you'll pick the browser REPL option which will open a new window that all your REPLing will run in#2022-05-2718:52lilactownoutside of the built storybook site#2022-05-2718:52lilactownthe downside is you might not have all of the namespaces loaded that are in the storybook build by default, but you can eval them manually to get your tooling to pick it up#2022-05-3121:10rayatReporting that I got it working via both the browser REPL + "with storybook", in the sense that for the latter: 1. It doesn't "connect" to the browser devtools console, all eval results print to the storybook watcher Thanks so much, you two. Now ( maybe related? ) would you have any tips, @U05224H0W for getting binaryage/cljs-devtools (or similar) custom formatting working within the storybook page/console? I tried reading around the shadow docs, and I don't know the difference between binaryage's cljs-devtools / devtools libs nor if the references to them matter for the shadow -> webpack -> storybook flow. I imagine it'd be a similar task to above, where I'd have to require the right module?#2022-05-3121:39thhellerthe problem is that :npm-module builds don't have a clear entry point. so there is no place for shadow-cljs to enforce loading of certain namespaces#2022-05-3121:39thhellerso somewhere on the JS side of things you need to require the proper namespaces#2022-05-3121:40thhellerso somewhere require("./path-to-cljs-output/devtools.preload.js")#2022-05-3121:41thhellerand if you want to try a REPL require("./path-to-cljs-output/shadow.cljs.devtools.client.browser.js")#2022-05-3121:41thhellerwhere I cannot tell you#2022-05-3121:41thhellerI believe there are config files in storybook you can use for that#2022-05-3121:44rayatAh, I think we have good entry points for that. So, it's the preload file you listed, and not something like the binaryage/cljs-devtools https://github.com/binaryage/cljs-devtools/blob/master/docs/installation.md#install-it-manually? And this is to get custom formatting working, right?#2022-05-3121:44rayatThanks again for the quick response#2022-05-3121:52rayatTrying my listed approach I get NOT installing CLJS DevTools 1.0.6 under advanced build. See . But I'm running shadow-cljs watch :stories, with these shadow configs:
:stories {:compiler-options {:optimizations :simple}
                    :devtools   {:console-support true
                                 :enabled  true
                                 :preloads [binaryage/cljs-devtools]}
                    :entries    [amperity.storybook.core]
                    :output-dir "out"
                    :target     :npm-module}
#2022-05-3121:58thhellerit may not be detecting the storybook output#2022-05-3121:58thhelleryou can try to require(".../shadow.cljs.devtools.client.console") instead#2022-05-3121:59thhellersort of my own trimmed down version of cljs-devtools. thats too noisy for me so I made something less invasive 😉#2022-05-3122:23rayatHm... any clue why it thinks it's in advanced mode?#2022-06-0105:54thhellerno idea sorry#2022-05-2808:05Karol WójcikIs it possible to inline all source-map during development?#2022-05-2808:15thhellernot when using :loader-mode :eval (the default)#2022-05-2808:17Karol WójcikHow can i change that?#2022-05-2808:18thhellerwhy do you want to? I mean the alternative is much slower#2022-05-2808:18thhellerassuming a browser build here#2022-05-2808:18thheller:devtools {:loader-mode :script} in the build config#2022-05-2808:18thhellerbut you are trading loading separate source maps but one source file#2022-05-2808:18thhellerto separate source files with potentially the source maps inlined#2022-05-2808:19thhellerso you in my view you are not gaining anything#2022-05-2808:19Karol WójcikThe reason i need inline source maps is because the ionic capacitor is unable to load the source maps from the URL. I'm receiving these kind of errors#2022-05-2808:19Karol Wójcik#2022-05-2808:19thhellerwhat happens if you click the url? I mean what do you get?#2022-05-2808:20Karol WójcikIt opens the source map correctly#2022-05-2808:20Karol WójcikI get the source map 🙂#2022-05-2808:20thhellerno more info on the unknown error?#2022-05-2808:20thhellercould be a restricted CSP?#2022-05-2808:20Karol WójcikNo more info.#2022-05-2808:22Karol WójcikHow can I know that?#2022-05-2808:23thhellerhttps://capacitorjs.com/docs/guides/security#web-view-security#2022-05-2808:24Karol WójcikI didn't have CSP enabled .#2022-05-2808:24thhellerthen it might be using a default which is too restrictive. don't know. never used this#2022-05-2808:25thhelleryou can maybe debug it by opening the devtools on the devtools#2022-05-2808:25thhellerthat sometimes gives more errors than the log line or at least lets you debug it further#2022-05-2808:26thhellerhttps://stackoverflow.com/questions/70874359/ionic-capacitor-devtools-failed-to-load-sourcemap-could-not-load-content-for#2022-05-2808:27Karol WójcikYeah. In my case shadow-cljs is serving all the files.#2022-05-2808:30thhellerI mean try it :compiler-options {:source-map-inline true} and :devtools {:loader-mode :script}#2022-05-2808:30thhellermaybe it works or reveals more info about the error#2022-05-2808:33Karol Wójcikdebugging..#2022-05-2808:43Karol WójcikInline source maps work. I will probably leave it for now and optimize later 🙂#2022-05-2808:43Karol WójcikThank you so much @U05224H0W!#2022-05-2816:59sbI have a “maybe” the same problem, is that resolved? When I run (ns-tools/refresh :after 'mount-components-reset), I got error message.. didn’t find namespace.. at clj part (I use pedestal, and something looks like “locked(?)” ).
;; this somehow breaks reloading
  ;; the usual :reloading message tells me that is namespace is being reloaded
  ;; but when the new instance is launched it is still using the old one
  ;; i cannot figure out why
  ;; (ns-tools/refresh :after 'repl/start)
#2022-05-2817:02sbhttps://github.com/thheller/shadow-cljs/blob/ba0a02aec050c6bc8db1932916009400f99d3cce/src/dev/repl.clj (comment from here)#2022-05-2817:38sbps I read here in the community try delete .m2 > juxt folder.. and now not freeze out, but don’t update the backend content [UPDATE: works fine].#2022-05-2817:54sbEverything fine: rm -rf ~/.m2/repository/juxt after this command.. :man-shrugging: I don’t understand fully. Sorry for this spam, if you would like I will delete this thread.#2022-05-2823:08Patrick BrownCan anyone post a link to a good article on how to minimize release build file size? My optimizations none is 16MB and my advanced is 4MB, This is my release section in my shadow-cljs.edn :release {:compiler-options {:optimizations :advanced} :js-options {:minimize-require true}} I can't help but think... I'm doing something majorly wrong. I'm using Fulcro and MUI, so I was imagining something pretty big, but 4MB seems like an 'it's my fault' size. CHEERS!#2022-05-2823:10nivekuilwhat's your build report look like? npx shadow-cljs run shadow.cljs.build-report [build-id] report.html#2022-05-2823:24Patrick BrownThanks for the reply. I didn't know that trick. That was very instructive. I've got 1MB for apache ECharts, 1MB for MUI. And 2MB scattered. It definitely is a 'me using too much cool stuff' problem. Looks like I'll have to go the multiple modules route.#2022-05-2823:28Patrick Brown@U797MAJ8M That really was a good tip. Thanks again! Now that I can see where the problem is, there are some solutions out there.#2022-05-2823:35nivekuilglad I could help!#2022-05-2906:19thheller@U036UJBDM5G you don't need to set any of those :release options. they are the default already. setting them again does nothing.#2022-05-3020:21Luis CerritosHello guys! I am using this package.json for my shadow-cljs and running my project with npm run watch, but if my node modules is deleted… It is always asking me for react, I need to run separately npm install react Anybody has an idea why if I have react in the package json it is still asking for it?#2022-05-3020:22thhellerhaving it in package.json does not mean they are installed. if you delete node_modules you need to run npm install to install all the packages listed in package.json.#2022-05-3114:48Luis CerritosYeah, added the step to my pipeline (`npm install`) and fixed the issue. Thanks @U05224H0W#2022-05-3020:23thhellerits not like clojure where they are downloaded automatically#2022-05-3113:37dvingoHi Thomas, in the context of Malli function instrumentation. I'm wondering if there is a way to tell the compiler, not only to always recompile a namespace (with {:dev/always true}), but also to instruct the compiler to do so after all other namespaces - without needing a solution like you mentioned here https://clojureverse.org/t/problem-using-malli-clojurescript-instrumentation-and-shadow-cljs/8612/2 of explicitly including every namespace that you want to compile before the entry one (or preload). The dream setup would be adding one piece of metadata to the entry namespace (for a webapp) and then getting repl friendly instrumentation. Not sure if this is possible, so wanted your opinion on the matter. Thanks.#2022-05-3113:39thhellerdefine "repl friendly instrumentation"? the hot-reload cycle is entirely independent of the REPL so that confuses me?#2022-05-3113:48dvingoAh you're right - it's really just hot-reload - making sure the changes in leaf namespaces (changing the malli schema used by a function) is picked up in the entry namespace. Here's the setup for instrumenting with fn metadata: 1. in your entry namespace in your after-load callback the user invokes a macro () this scans all namespaces and collects any functions that have :malli/schema metadata 2. In your leaf namespace like my.app.utils you have a function like:
(defn minus-small-int
  {:malli/schema [:=> [:cat :int] small-int]
   :malli/scope  #{:input :output}}
  [x] (dec x))
3. I'm dev'ing this function and changing the schema and the implementation The workflow I want is to just edit the leaf namespace and have the () call get macro-expanded and compiled + eval'd again with this new schema. I'm also open to other suggestions about how to achieve this - maybe an editor command to submit that macro call? then your workflow is: save file. invoke editor command. ?
#2022-05-3113:50thhellerwhat you can do if abuse the after-load hook a little bit#2022-05-3113:51thheller
(defn ^:dev/after-load malli-instrument []
  (js/cljs-eval "(malli.dev/start!)"))
#2022-05-3113:52thhellerthat basically just evals () after every hot-reload#2022-05-3113:52thhellerno clue how that behaves if it gets called after every compile though#2022-05-3113:52thhellermight not like getting started several times#2022-05-3113:52thhelleror might just do a lot of work that is unnecessary and as such slow everything else down#2022-05-3113:54dvingooh very cool! Well at least it pushes the problem from a staleness one to a perf one. Is there a way in a macro to determine which namespaces have changed (provided by some compiler data?) that way I don't have to scan every ns#2022-05-3113:56thhellerin a macro not really no#2022-05-3113:56thhellerI mean strictly speaking yes but that would be shadow-cljs only and even then not guaranteed to be reliable#2022-05-3113:57thhellerhas to account for cache and stuff#2022-05-3113:58dvingogot it - would it be really bad to use the ns to lookup its file modified time ? that way I could store some state to keep track which ns's changed#2022-05-3113:59dvingoor maybe hash the namespace object?#2022-05-3113:59thhellersure thats one option#2022-05-3114:00dvingook great! thanks so much for the help#2022-05-3115:17isaackarthI've gotten curious about the current best way to do documentation generation. Many of the previous ways to do this (Marginalia, Codox, Dynadoc) seem to mostly be via lein plugins (or deps.edn). What's the best way to generate docs with Shadow? (Or is everyone just using cljdoc?)#2022-05-3115:59thhelleranything that works with deps.edn should also work with shadow#2022-05-3116:00thhelleror just use lein with the plugins. they are all seperate tools that don't require shadow-cljs in any way to work#2022-05-3117:25Emile SnyderHi all, I'm new here. I've got a question about problems compiling with shadow-cljs for a project using Fabric.js. We're currently trying to upgrade a bunch of packages; we are building ok pre-upgrade. As I understand it, fabric is using jsdom. On lein shadow compile app we're seeing a whole bunch of errors like:
[:app] Compiling ...
Closure compilation failed with 20 errors
--- node_modules/jsdom/lib/jsdom/living/generated/AbortSignal.js:95
constructor is missing a call to super()
--- node_modules/jsdom/lib/jsdom/living/generated/Attr.js:96
constructor is missing a call to super()
--- node_modules/jsdom/lib/jsdom/living/generated/CDATASection.js:94
constructor is missing a call to super() 
Googling I see this one question/answer in 2019 (https://clojurians-log.clojureverse.org/shadow-cljs/2021-08-13) to a similar constructor is missing a call to super() error, but I'm not sure where to go from here. Any advice welcome!
#2022-05-3117:38thheller@emile what are you building? looks like it might be a browser build? jsdom is intended for node envs? what is your build :target?#2022-05-3117:40thhellerjsdom shouldn't be included for browser builds?#2022-05-3117:42Emile Snyder@thheller yes, :target is :browser. We have a clojurescript reframe component that uses Fabric.js and canvas element to let you draw various regions on top of an image, then turn what you've drawn into svg. Fabric is apparently using jsdom. Are you saying this should never have worked? 🙂#2022-05-3117:42thhellerno, I'm saying jsdom shouldn't be included#2022-05-3117:43thhellerit appears to be an optional dependency. so something you have done must lead to its inclusion. not sure what#2022-05-3117:43thhellerwhat shadow-cljs version do you use?#2022-05-3117:43thhelleranything special in your build config?#2022-05-3117:43thhellerdo you directly require jsdom somewhere?#2022-05-3117:47Emile SnyderYou'll have to forgive me, my grasp of dealing with dependency stuff is not strong. We are trying to upgrade a bunch of stuff, including shadow-cljs to 2.19.0 from 2.11.18. I'm trying to figure out what's pulling in jsdom now...#2022-05-3118:00thhellermaybe that update is enough#2022-05-3118:02thhellerhmm I can reproduce this. let me look#2022-05-3118:06Emile Snyder@thheller re: jsdom as optional dependency of fabric... our team is confused 🙂 We can't find anything explicit in our dependencies for jsdom. When we remove package-lock.json , run npm install --no-optional and then lein shadow compile app we see:
[:app] Compiling ...
The required JS dependency "jsdom" is not available, it was required by "node_modules/fabric/dist/fabric.js".

Dependency Trace:
	mobot_web/app.cljs
	mobot_web/core.cljs
	mobot_web/admin/views/core.cljs
	mobot_web/admin/views/test_plan_runner.cljs
	mobot_web/admin/views/components/assessment_region_editor.cljs
	node_modules/fabric/dist/fabric.js

Searched for npm packages in:
	/home/emile/dev/mobot-doc-change/mobot-web/node_modules

See: 
#2022-05-3118:07thhellerthe problem is in fabric, not your code#2022-05-3118:08thhellerit is trying to include jsdom conditionally in a way that shadow-cljs does not recognize properly. so it ends up trying to include it fully#2022-05-3118:08thhellerI'm checking why#2022-05-3118:10Emile SnyderAh, thanks!#2022-05-3118:11thhelleryou can set this is :js-options in your build config
:resolve {"jsdom" false
              "jsdom/lib/jsdom/living/generated/utils" false
              "jsdom/lib/jsdom/utils" false}
#2022-05-3118:11thhellerthat'll fix it for now#2022-05-3118:13Emile SnyderMuch appreciated!#2022-05-3118:24dpsuttonWe lightly use shadow-cljs at work but this interaction here is an example of exactly why I keep my sponsorship of @thheller on github. Incredible#2022-06-0107:26thheller@emile I just released version 2.19.1 which fixes your issue. so you could bump and remove the :resolve fix, or just keep it. end result is the same.#2022-06-0107:58thhellera new thing I also added in 2.19.1 is js-await. Maybe that is useful for someone else, wrote about it here https://clojureverse.org/t/promise-handling-in-cljs-using-js-await/8998#2022-06-0114:08Emile Snyder@thheller thank you!#2022-06-0210:32barrellI started using meta data to flag some functions in different namespaces. I wrote a shadow-cljs hook that compiles a manifest based off of the metadata of functions in different file. This worked great for development. However, no matter the optimization level I choose, when I go to do a release the value of (get-in build [:compiler-env :cljs.analyzer/namespaces]) is nil. Is this sort of data located somewhere else for release builds? If not, is there a recommended approach for providing such data to a release build? edit: actually the :compiler-env key is not present at all 😞#2022-06-0210:36thhellerthat info is unaffected by the optimizations and should always be available#2022-06-0210:36thhellerwhich stage are you using it in?#2022-06-0210:36thheller:compiler-env is also present always? otherwise pretty much everything would fail 😛#2022-06-0210:38barrellThis is the printed value from (pprint (sort (keys build))) :thinking_face:#2022-06-0210:39barrellthe hook runs in :configure and :compile-prepare#2022-06-0210:39thhellerat neither of those stages has any CLJS been compiled so :cljs.analyzer/namepaces will indeed be missing or empty?#2022-06-0210:40thhellerI guess during development you are relying on caching or watch re-entering the :compile-prepare with data from the previous compile?#2022-06-0210:40barrellhaha probably#2022-06-0210:41barrellmy hooks currently cause it to always rebuild twice (haven’t looked into that yet) that’s probably what was saving me#2022-06-0210:41thhellerare you creating files in that hook that will then be used in the compilation? if so don't 😉#2022-06-0210:41barrellaccidental driven development#2022-06-0210:41barrellIt generates a routing manifest that’s used by the router 😭#2022-06-0210:42barrellso I can mark which functions are routes for which url#2022-06-0210:42thhellerjust use a macro?#2022-06-0210:42barrellall of the routes are code split#2022-06-0210:42thhellerjust use a macro in each split? 😛#2022-06-0210:42barrellthen there is a base app that loads the files and renders the route#2022-06-0210:43barrellhow would the app know which routes are availble from a macro?#2022-06-0210:43barrellsince that macro would only effect the code in the respective split#2022-06-0210:43thhellerwell what you could do in the hook is generate is manifest that you actually load dynamically at runtime#2022-06-0210:44thhellerlike .json file or something#2022-06-0210:44barrellI can just only spit the file when :compiler-env is present, and rely on an outdated version for now#2022-06-0210:44barrellhmmm#2022-06-0210:44barrellactually yeah that could work - I guess I could load that from the index.html#2022-06-0210:45thhellerI've been thinking about how to do compile-on-demand in hooks#2022-06-0210:45thhellerbut still no clue how to get that all working properly with caching and hot-reload and everything else 😛#2022-06-0210:45barrellwould like to avoid a index.html loading app loading manifest loading split loading component situation 😅#2022-06-0210:45barrell> but still no clue how to get that all working properly with caching and hot-reload and everything else you and me both! 😉#2022-06-0210:45thhellerif you generate the .json in a hook#2022-06-0210:46thhelleryou could inline that json in your HTML#2022-06-0210:46thhellersaves that extra load you are worried about 😉#2022-06-0210:46barrellwell good thing I also have a hook for inlining build data into hiccup files to build my html awesome#2022-06-0210:46barrellI will do what you said#2022-06-0210:46barrellty for the quick response#2022-06-0214:49p-himikThis looks wild, and awesome.#2022-06-0216:00gravWhat's the source?#2022-06-0216:07p-himikhttps://clojure.org/news/2022/06/02/state-of-clojure-2022#2022-06-0315:23geraldodevDaylight testimony that in shadow we trust 🙂#2022-06-0222:55SturmIf I want to include re-frame10x as a dependency, am I safe to include it under the top-level :dependencies and rely on it being dead-code-eliminated when it's not loaded in a production build? Or is there a better place to specify it as a dependency?
#2022-06-0300:42thhelleronly an actual require in your ns causes a dependency to be included. just having it in :dependencies does not affect the build in any way#2022-06-0300:43thhelleryou can and should verify what is included via builds reports https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2022-06-0301:04Sturmthanks @thheller!#2022-06-0301:55Sturmomg, those build reports are brilliant!#2022-06-0312:26geraldodevif we use internal http server, is there a way turn the dev-http one off ?#2022-06-0319:41thhellerjust don't configure it? If you don't use it you dont have to configure any :dev-http#2022-06-0400:56geraldodevI'm wondering :dev-http starts and watches for public files. I'm using my own server and configured :devtools {:watch-dir "resources/public"}. From time to time when I'm using shadow my computer hangs on a long running task to the point I loose control of the gui. At work and at home, same cpu 12 core linux ubuntu focal fossa. I just wanted to make things lighter hopefully getting rid of this behaviour, that I cant confirm that is caused by shadow. But It just happen when I'm using it.#2022-06-0407:09thhellerhmm no clue sorry. watching files isn't that resource consuming since it uses the OS for that on linux#2022-06-0407:09thhellerI mean create a jstack dump or something when it happens. should be possible to identify what is causing it (if it is shadow)#2022-06-0316:05Quentin Le GuennecHello, I can't connect to a node-script javascript runtime anymore since I updated to the latest version of shadow-cljs. I use shadow-cljs watch app then cider-connect-cljs then node app.js . Then I try to evaluate a form in app.cljs and I get "No available JS runtime". I'm not getting any shadow-cljs message in the node process.#2022-06-0317:30Quentin Le GuennecOk I fixed it. Turned out my program was generating some kind of infinite loop before shadow instanciated the websocket#2022-06-0408:53Benjamin
no source by id: [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]
{:id [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]}
ExceptionInfo: no source by id: [:shadow.build.classpath/resource "benjamin/lawnmower/core.cljs"]
	shadow.build.data/get-source-by-id (data.clj:172)
	shadow.build.data/get-source-by-id (data.clj:169)
	shadow.build.compiler/remove-dead-js-deps/remove-fn--15466/fn--15467 (compiler.clj:1225)
	clojure.core/complement/fn--5737 (core.clj:1455)
	clojure.core/filter/fn--5962 (core.clj:2834)
yo I don't get why I get this error
#2022-06-0409:32Benjaminah maybe this happens when there is a read error in the file#2022-06-0416:02thhellerno, it should never get to that point even with errors in any file#2022-06-0416:02thhellerdunno why you'd get that though#2022-06-0416:02thhellermaybe you are doing something weird in a macro or build hook or so?#2022-06-0714:19Benjaminwierd. It seemed to go there when there where read errors#2022-06-0716:55thhellerthis is long after compilation so read errors would have shown up way earlier?#2022-06-0717:23BenjaminHm. It did happen when i did cider-eval irrc#2022-06-0717:31thhellerwhat did you eval though? REPL evals don't go through remove-dead-js-deps? so dunno why that would show up there?#2022-06-0717:31thhelleror did you eval something like (shadow/compile :app) in a CLJ REPL?#2022-06-0717:31thhellermeaning not a CLJS REPL?#2022-06-0717:32BenjaminNot sure tbh. I used cider jack in clj + cljs#2022-06-0717:33BenjaminI think it connects to the cljs repl by default#2022-06-0717:34thhellerwell you should know what you eval'd no?#2022-06-0717:34thhellerif it was CLJS code or CLJ code I mean#2022-06-0717:35BenjaminCLJS#2022-06-0717:36thhellerstill no clue how you'd get that error in the REPL. if you run into it again let me know though.#2022-06-0717:37BenjaminI can try to make a repro#2022-06-0717:39thhellerthat would help#2022-06-0717:40thhellerwhich version do you use? if its something super old I can see this happening. with the latest not so much.#2022-06-0717:41Benjaminshould be "2.19.1"#2022-06-0717:41Benjaminbut you know what Stew said about debugging "everybody lies"#2022-06-0717:43Benjamin(I mean maybe I'm wrong)#2022-06-0717:44thhellerwell do you use only shadow-cljs.edn or do you use deps.edn/project.clj to manage dependencies?#2022-06-0717:44thhellerI mean shadow-cljs also tells you which version is running on startup#2022-06-0717:45thhellerdunno where emacs hides that though when using jack-in#2022-06-0717:45Benjaminye your're right#2022-06-0717:46Benjamindeps.edn#2022-06-0717:46BenjaminI'll try to repro and send the repo#2022-06-0408:56vlad_pohdoes shadow-cljs have a lein-ancient equivalent? i.e checking dependency versions for newer versions#2022-06-0414:04danielnealjust starting a new shadow project and can’t seem to get off the ground#2022-06-0414:05danielnealcan anyone spot what is wrong with this picture?#2022-06-0414:05danielnealit’s saying my namespace is not available#2022-06-0414:21danielnealnot trying to do anything complicated#2022-06-0415:06danielnealah it was a directory structure issue#2022-06-0415:06danielnealall sorted#2022-06-0416:12vlad_pohNew to clojurescript and shadow-cljs getting the following warnings when i run the following
npx shadow-cljs watch frontend
and not sure how to troubleshoot. App compiles and runs.
------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: cljs/analyzer.cljc:4403:12
--------------------------------------------------------------------------------
4400 |   []
4401 |   (try
4402 |     @(ns-resolve 'clojure.tools.reader '*alias-map*)
4403 |     (catch Throwable t
------------------^-------------------------------------------------------------
 Use of undeclared Var cljs.analyzer/Throwable
--------------------------------------------------------------------------------
4404 |       nil)))
4405 | 
4406 | #?(:clj
4407 |    (defn forms-seq*
--------------------------------------------------------------------------------

------ WARNING #2 - :undeclared-var --------------------------------------------
 Resource: cljs/analyzer.cljc:4402:7
--------------------------------------------------------------------------------
4399 |   "Returns clojure.tools.reader/*alias-map* for bridging"
4400 |   []
4401 |   (try
4402 |     @(ns-resolve 'clojure.tools.reader '*alias-map*)
-------------^------------------------------------------------------------------
 Use of undeclared Var cljs.analyzer/ns-resolve
--------------------------------------------------------------------------------
4403 |     (catch Throwable t
4404 |       nil)))
4405 | 
4406 | #?(:clj
--------------------------------------------------------------------------------
#2022-06-0416:14thheller@kbosompem this is a bug in the latest clojurescript release. it is fixed in master but no new release available yet. if you use deps.edn to manage dependencies you can use a git dependency to get it#2022-06-0416:14thhellerare you trying a self-hosted build? otherwise you shouldn't be including cljs.analyzer anyways?#2022-06-0416:33vlad_poh@thheller thanks for the quick reply. I'm trying to follow the examples here https://github.com/metosin/reitit/blob/master/examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs this is what my shadow-cljs.edn file looks like
;; shadow-cljs configuration
{:source-paths
 ["src/cljs"]

 :dependencies
 [[reagent "1.1.1"]
  [cljs-ajax "0.8.4"]
  [re-frame "0.10.6"]
  [metosin/reitit "0.5.11"]]

 :builds
 {:frontend {:target :browser
             :output-dir "resources/public/js"
             :asset-path "/js"
             :release {:compiler-options {:optimizations :simple}}
             :modules {:main {:init-fn spcmig.core/run}}}}}
#2022-06-0416:36thhellerlooks fine but I'm not sure if any of those may be including cljs.analyzer? seems like it shouldn't but I don't know#2022-06-1110:50Vincent Cantin[reitit.coercion.spec :as rss] does require cljs.analyzer, that's why I reported the issue a few minutes ago 🙂#2022-06-1110:51thhellerwell you probably wouldn't want to use that if you care about build size at all#2022-06-0416:38thhelleryou can just downgrade shadow-cljs to 2.18.0. that'll have the older clojurescript version as well, so the warnings will be gone until the next release#2022-06-0518:47ribelosomewhere I can read what vars are automatically poisoned and/or where I don't have to put ^js before variables?#2022-06-0519:38thhelleranything you don't get an externs inference warning for 😉#2022-06-0519:58ribeloit often happens to me that the only warning I have is a fuckup on runetime 😞#2022-06-0606:22thhellerdo you have examples of where you had to add them? maybe its for cases not covered by externs inference properly. or you are doing something incorrectly?#2022-06-0607:04ribeloUnfortunately I have nothing currently prepared to show you, but I will undoubtedly be back with a ready-made example sooner rather than later.#2022-06-0612:33heliosHey, I've bumped shadow in our project from 2.16.12 to the latest one 2.19.1 and, leaving everything else the same, running into this:
Syntax error compiling at (shadow/build/js_support.clj:1:1).
namespace 'shadow.build.closure' not found
#2022-06-0612:33heliosthis is the complete error message#2022-06-0612:34heliosFor the record, we're using the shadow api as follows:
(ns ductile.bootstrap.shadow-cljs
  (:require [integrant.core :as ig]
            [shadow.cljs.devtools.api :as shadow]
            [shadow.cljs.devtools.server :as server]))

(defmethod ig/init-key :ductile.bootstrap/shadow-cljs [_ {:keys [config] :as context}]
  (when (seq context)
    (server/start!)
    (let [{:keys [builds watch-opts]} (get config :shadow-cljs)]
      (doseq [build builds]
        (shadow/watch build watch-opts))))
  context)
#2022-06-0612:44heliosIt looks like we get this even by just bumping {org.clojure/clojurescript 1.11.51} with the existing shadow version#2022-06-0612:57mkvlrbumping clojurescript without shadow isn’t supported afaik#2022-06-0612:59helioswell, bumping shadow (and thus cljs) is enough to show the issue then 🙂#2022-06-0615:28thhelleryes, this is most likely caused by a dependency conflict. make sure you have the matching shadow-cljs, clojurescript and closure-compiler versions. if they get out of sync things break#2022-06-0615:31heliosthe issue i posted above is with the matching versions: (generated with clj -X:deps list :aliases "[:dev,:cljs]"thheller/shadow-cljs 2.19.1org.clojure/clojurescript 1.11.51com.google.javascript/closure-compiler-unshaded v20220502 Still getting
Syntax error compiling at (shadow/build/js_support.clj:1:1).
namespace 'shadow.build.closure' not found
#2022-06-0615:35heliosit looks like shadow-cljs 2.19.1 is bringing in . com.google.javascript/closure-compiler-unshaded v20220502 but here it seems you changed deps.edn to an older version :thinking_face: https://github.com/thheller/shadow-cljs/commit/3af216620ad31320b1b6e6b6d053a161e535a9b7 what am i doing wrong?#2022-06-0615:36heliosnote that i'm just bumping shadow to 2.19.1, the other stuff is brought in by that#2022-06-0615:50thhellersorry I don't know what clj -X:deps list is#2022-06-0615:51thhellerhere you can find the versions you need to be using https://clojars.org/thheller/shadow-cljs#2022-06-0615:51thhellerso looks like it should be fine. assuming you actually get those versions#2022-06-0615:51thhellerthis is easy to test#2022-06-0615:52thhellerjust run clj -A:dev:cljs#2022-06-0615:52thhellerthen (require 'shadow.build.closure)#2022-06-0615:52thhellershadow-cljs doesn't actually use deps.edn for anything. so it might be totally out of date or broken.#2022-06-0615:53thhelleryou just have to find the reason why the namespace doesn't load. 99.9% of the time this is a dependency conflict#2022-06-0616:23mkvlr
clj -A:dev:cljs                                                                                                                                                                            ✘ 130 
Clojure 1.11.0
user=> (require 'shadow.build.closure)
nil
user=> (user/go)
2022-06-06 18:22:42.970 INFO  ductile.nrepl - {:nrepl/stopping "Stopping nREPL server", :port 64874, :line 31}
2022-06-06 18:22:43.002 INFO  ductile.nrepl - {:started "nREPL server started on port 64959 on host localhost - ", :uptime 39794, :line 21}
Syntax error compiling at (shadow/build/js_support.clj:1:1).
namespace 'shadow.build.closure' not found
#2022-06-0616:25mkvlrI don’t understand this:
user=> (require 'shadow.build.closure)
nil
user=> (require 'shadow.build.js-support)
Syntax error compiling at (shadow/build/js_support.clj:1:1).
namespace 'shadow.build.closure' not found
user=> 
#2022-06-0616:32mkvlrrunning the individual forms in shadow.build.js-support , this is the first failure:
shadow.build.closure=> (def warning-types
  (reduce
    (fn [warnings [registered-name group]]
      (let [kw (-> registered-name
                   (str/replace #"[A-Z]" #(str "-" (str/lower-case %)))
                   keyword)]
        (assoc warnings kw group)))
    {}
    (DiagnosticGroups/getRegisteredGroups)))
Execution error (NoClassDefFoundError) at jdk.internal.reflect.NativeMethodAccessorImpl/invoke0 (NativeMethodAccessorImpl.java:-2).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
#2022-06-0616:35mkvlrwe’re also not finding a dependency conflict, the versions seem to match what shadow is expecting#2022-06-0617:37thhellerthis is definitely a dependencny conflict#2022-06-0617:37thhellervery easy to verify also#2022-06-0617:37thhellerfrom the initial repl#2022-06-0617:37thheller(require ')#2022-06-0617:37thheller( "com/google/javascript/jscomp/Compiler.class")#2022-06-0617:38thhellermight be a problem if you are on jdk8 also? the closure compiler recently bumped the minimum to jdk11.#2022-06-0617:38thhellerdunno if that would fail in this way though#2022-06-0617:41thhelleralso where are the stacktraces? your error reports are way too short#2022-06-0617:42thhellermuch easier to figure things out with traces#2022-06-0617:47mkvlron jdk 17 here#2022-06-0617:48mkvlr
clojure -A:dev:cljs
Clojure 1.11.0
user=> (require ')
nil
user=> ( "com/google/javascript/jscomp/Compiler.class")
#object[java.net.URL 0x10187078 "jar:file:/Users/mk/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/Compiler.class"]
#2022-06-0617:48thhellerand the trace when you require the ns?#2022-06-0617:49mkvlrnot getting one#2022-06-0617:49thheller*e#2022-06-0617:49mkvlrah, yes, sorry#2022-06-0617:49mkvlr
user=> *e
#error {
 :cause "namespace 'shadow.build.closure' not found"
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error compiling at (shadow/build/js_support.clj:1:1)."
   :data #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "shadow/build/js_support.clj"}
   :at [clojure.core$throw_if invokeStatic "core.clj" 5892]}
  {:type java.lang.Exception
   :message "namespace 'shadow.build.closure' not found"
   :at [clojure.core$apply invokeStatic "core.clj" 669]}]
 :trace
 [[clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 6016]
  [clojure.core$load_libs doInvoke "core.clj" 6000]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 6038]
  [clojure.core$require doInvoke "core.clj" 6038]
  [clojure.lang.RestFn invoke "RestFn.java" 551]
  [shadow.build.js_support$eval46986$loading__6789__auto____46987 invoke "js_support.clj" 1]
  [shadow.build.js_support$eval46986 invokeStatic "js_support.clj" 1]
  [shadow.build.js_support$eval46986 invoke "js_support.clj" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7194]
  [clojure.lang.Compiler eval "Compiler.java" 7183]
  [clojure.lang.Compiler load "Compiler.java" 7653]
  [clojure.lang.RT loadResourceScript "RT.java" 381]
  [clojure.lang.RT loadResourceScript "RT.java" 372]
  [clojure.lang.RT load "RT.java" 459]
  [clojure.lang.RT load "RT.java" 424]
  [clojure.core$load$fn__6908 invoke "core.clj" 6161]
  [clojure.core$load invokeStatic "core.clj" 6160]
  [clojure.core$load doInvoke "core.clj" 6144]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [clojure.core$load_one invokeStatic "core.clj" 5933]
  [clojure.core$load_one invoke "core.clj" 5928]
  [clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
  [clojure.core$load_lib invokeStatic "core.clj" 5974]
  [clojure.core$load_lib doInvoke "core.clj" 5953]
  [clojure.lang.RestFn applyTo "RestFn.java" 142]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$load_libs invokeStatic "core.clj" 6016]
  [clojure.core$load_libs doInvoke "core.clj" 6000]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 669]
  [clojure.core$require invokeStatic "core.clj" 6038]
  [clojure.core$require doInvoke "core.clj" 6038]
  [clojure.lang.RestFn invoke "RestFn.java" 408]
  [user$eval46982 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval46982 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7194]
  [clojure.lang.Compiler eval "Compiler.java" 7149]
  [clojure.core$eval invokeStatic "core.clj" 3215]
  [clojure.core$eval invoke "core.clj" 3211]
  [clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
  [clojure.main$repl$fn__9215 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl_opt invokeStatic "main.clj" 522]
  [clojure.main$main invokeStatic "main.clj" 667]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}
#2022-06-0617:49thheller( "shadow/build/closure.clj")?#2022-06-0617:50thhellerstill missing the cause for some reason?#2022-06-0617:50thheller( "shadow/build/js_support.clj")#2022-06-0617:51thhellerthe files should exist just fine. maybe the maven download got screwed or something?#2022-06-0617:51mkvlr
user=> ( "shadow/build/closure.clj")
#object[java.net.URL 0x3316d545 "jar:file:/Users/mk/.m2/repository/thheller/shadow-cljs/2.19.1/shadow-cljs-2.19.1.jar!/shadow/build/closure.clj"]
#2022-06-0617:52mkvlrthe files are all there#2022-06-0617:52mkvlr
user=> (DiagnosticGroups/getRegisteredGroups)
Execution error (NoClassDefFoundError) at user/eval46996 (REPL:1).
Could not initialize class com.google.javascript.jscomp.DiagnosticGroups
user=> *e
#error {
 :cause "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
 :via
 [{:type java.lang.NoClassDefFoundError
   :message "Could not initialize class com.google.javascript.jscomp.DiagnosticGroups"
   :at [user$eval46996 invokeStatic "NO_SOURCE_FILE" 1]}]
 :trace
 [[user$eval46996 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval46996 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7194]
  [clojure.lang.Compiler eval "Compiler.java" 7149]
  [clojure.core$eval invokeStatic "core.clj" 3215]
  [clojure.core$eval invoke "core.clj" 3211]
  [clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
  [clojure.main$repl$fn__9215 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl_opt invokeStatic "main.clj" 522]
  [clojure.main$main invokeStatic "main.clj" 667]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}
#2022-06-0617:52mkvlrthis seems to be the culprit#2022-06-0617:52thheller( "com/google/javascript/jscomp/DiagnosticGroups.class")#2022-06-0617:52mkvlrbut this isn’t a very helpful stack trace, or does this tell you anything?#2022-06-0617:53mkvlr
user=> ( "com/google/javascript/jscomp/DiagnosticGroups.class")
#object[java.net.URL 0x197af6a7 "jar:file:/Users/mk/.m2/repository/com/google/javascript/closure-compiler-unshaded/v20220502/closure-compiler-unshaded-v20220502.jar!/com/google/javascript/jscomp/DiagnosticGroups.class"]
#2022-06-0617:54thhellerhmm this is a plain REPL right? nothing in user.clj loaded or cider middleware messing with classloaders?#2022-06-0617:54thhellertools.namespace or the like#2022-06-0617:55thhellerI'm out of ideas otherwise#2022-06-0617:55thhellerI have seen plenty of errors with DiagnosticsGroups but they were dependency conflicts always#2022-06-0617:55thhellerbut your dependencies seem correct indeed#2022-06-0617:56thhellermaybe just try wiping your .m2 downloads and have them download again#2022-06-0617:56thhellermaybe just something got messed up#2022-06-0617:56mkvlrhm, unlikely since we ran into this on different machines but will try#2022-06-0617:56mkvlrI'll also try reducing the deps#2022-06-0617:57mkvlrthanks for your help so far, will keep you posted once we know more#2022-06-0619:10mkvlrtried a JDK 11 & reducing deps but that didn’t help. Do you see anything more here:
clojure -A:cljs
Clojure 1.11.0
user=> 
user=> (import 'com.google.javascript.jscomp.DiagnosticGroups)
com.google.javascript.jscomp.DiagnosticGroups
user=> 
user=>  (DiagnosticGroups/getRegisteredGroups)
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.RhinoErrorReporter/<clinit> (RhinoErrorReporter.java:169).
'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'
user=> *e
#error {
 :cause "'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'"
 :via
 [{:type java.lang.NoSuchMethodError
   :message "'com.google.common.collect.ImmutableMap com.google.common.collect.ImmutableMap$Builder.buildOrThrow()'"
   :at [com.google.javascript.jscomp.RhinoErrorReporter <clinit> "RhinoErrorReporter.java" 169]}]
 :trace
 [[com.google.javascript.jscomp.RhinoErrorReporter <clinit> "RhinoErrorReporter.java" 169]
  [com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 228]
  [user$eval138 invokeStatic "NO_SOURCE_FILE" 1]
  [user$eval138 invoke "NO_SOURCE_FILE" 1]
  [clojure.lang.Compiler eval "Compiler.java" 7194]
  [clojure.lang.Compiler eval "Compiler.java" 7149]
  [clojure.core$eval invokeStatic "core.clj" 3215]
  [clojure.core$eval invoke "core.clj" 3211]
  [clojure.main$repl$read_eval_print__9206$fn__9209 invoke "main.clj" 437]
  [clojure.main$repl$read_eval_print__9206 invoke "main.clj" 437]
  [clojure.main$repl$fn__9215 invoke "main.clj" 458]
  [clojure.main$repl invokeStatic "main.clj" 458]
  [clojure.main$repl_opt invokeStatic "main.clj" 522]
  [clojure.main$main invokeStatic "main.clj" 667]
  [clojure.main$main doInvoke "main.clj" 616]
  [clojure.lang.RestFn invoke "RestFn.java" 397]
  [clojure.lang.AFn applyToHelper "AFn.java" 152]
  [clojure.lang.RestFn applyTo "RestFn.java" 132]
  [clojure.lang.Var applyTo "Var.java" 705]
  [clojure.main main "main.java" 40]]}
#2022-06-0619:12thhellerthat would be guava#2022-06-0619:12thhellerhmm yeah should have thought of that#2022-06-0619:12thhellersince the last couple versions the closure compiler changed how they bundle stuff#2022-06-0619:13thhellerso they don't properly declare the guava version they need#2022-06-0619:13thhellerso if you get an older one things break as above#2022-06-0619:13thhellerhttps://github.com/google/closure-compiler/issues/3896#2022-06-0619:14thhellerforgot which version that actuall is though, probably just latest version#2022-06-0619:18thhellercheck which guava version you are getting and where from#2022-06-0619:30mkvlr
com.google.guava/guava 30.1-jre
#2022-06-0619:30mkvlrvia com.datomic/datomic-pro 1.0.6269 if I’m reading this right#2022-06-0619:36mkvlrexplicitly requiring the latest version doesn’t help either, I’ll continue tomorrow#2022-06-0619:49thhelleryeah not sure which version is actually required. I don't understand their bazel setup at all, so no idea where the version is#2022-06-0708:24mkvlrso there's no dep on guava in shadow-cljs set at all, correct?
clj -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.19.1"}}}' -Stree
org.clojure/clojure 1.11.1
  . org.clojure/spec.alpha 0.3.218
  . org.clojure/core.specs.alpha 0.2.62
thheller/shadow-cljs 2.19.1
  . org.clojure/data.json 2.4.0
  . org.clojure/tools.cli 1.0.206
  . org.clojure/tools.reader 1.3.6
  . nrepl/nrepl 0.9.0
  . cider/piggieback 0.5.3
  . com.cognitect/transit-clj 1.0.329
    . com.cognitect/transit-java 1.0.362
      . com.fasterxml.jackson.core/jackson-core 2.8.7
      . org.msgpack/msgpack 0.6.12
        . com.googlecode.json-simple/json-simple 1.1.1
        . org.javassist/javassist 3.18.1-GA
      . javax.xml.bind/jaxb-api 2.3.0
  . com.cognitect/transit-cljs 0.8.269
    . com.cognitect/transit-js 0.8.874
  . org.clojure/core.async 1.5.648
    . org.clojure/tools.analyzer.jvm 1.2.2
      . org.clojure/tools.analyzer 1.1.0
      . org.clojure/core.memoize 1.0.253
        . org.clojure/core.cache 1.0.225
          . org.clojure/data.priority-map 1.1.0
      . org.ow2.asm/asm 9.2
      . org.clojure/tools.reader 1.3.6
  . org.clojure/clojurescript 1.11.51
    . org.clojure/tools.reader 1.3.6
    . com.cognitect/transit-java 1.0.362
  . com.google.javascript/closure-compiler-unshaded v20220502
  . org.clojure/google-closure-library 0.0-20211011-0726fdeb
    . org.clojure/google-closure-library-third-party 0.0-20211011-0726fdeb
  . org.clojure/google-closure-library-third-party 0.0-20211011-0726fdeb
  . thheller/shadow-util 0.7.0
    . hiccup/hiccup 1.0.5
  . thheller/shadow-client 1.3.3
    X org.clojure/core.async 0.3.443 :older-version
    . hiccup/hiccup 1.0.5
  . thheller/shadow-undertow 0.2.1
    X org.clojure/core.async 1.3.610 :older-version
    . io.undertow/undertow-core 2.2.4.Final
      . org.jboss.logging/jboss-logging 3.4.1.Final
      . org.jboss.xnio/xnio-api 3.8.0.Final
        . org.wildfly.common/wildfly-common 1.5.2.Final
        . org.wildfly.client/wildfly-client-config 1.0.1.Final
          X org.jboss.logging/jboss-logging 3.3.1.Final :older-version
          X org.wildfly.common/wildfly-common 1.2.0.Final :older-version
      . org.jboss.xnio/xnio-nio 3.8.0.Final
        . org.jboss.xnio/xnio-api 3.8.0.Final
          X org.jboss.threads/jboss-threads 2.3.3.Final :older-version
      . org.jboss.threads/jboss-threads 3.1.0.Final
        . org.jboss.logging/jboss-logging 3.4.1.Final
  . thheller/shadow-cljsjs 0.0.22
  . hiccup/hiccup 1.0.5
  . ring/ring-core 1.9.5
    . ring/ring-codec 1.1.3
      . commons-codec/commons-codec 1.15
    . commons-io/commons-io 2.10.0
    . commons-fileupload/commons-fileupload 1.4
      X commons-io/commons-io 2.2 :older-version
    . crypto-random/crypto-random 1.2.1
      . commons-codec/commons-codec 1.15
    . crypto-equality/crypto-equality 1.0.0
  . io.methvin/directory-watcher 0.15.1
    . net.java.dev.jna/jna 5.7.0
    . org.slf4j/slf4j-api 1.7.30
  . expound/expound 0.9.0
  . fipp/fipp 0.6.26
    . org.clojure/core.rrb-vector 0.1.2
  . com.bhauman/cljs-test-display 0.1.1
#2022-06-0708:33thhelleryes, the closure compiler normally would but doesn't currently#2022-06-0708:33thhellerjust bundles it as part of its own jar. sort of uberjar#2022-06-0708:34mkvlrok, so doing a similar thing like cljs used to do#2022-06-0708:38thhelleryeah, I have a hard time finding which version it actually uses#2022-06-0708:39thhellermaybe I'll just declare that as a dependency of shadow-cljs until this is sorted#2022-06-0708:39thhellerwell my usual recommendation is not running shadow-cljs embedded and keeping clj dependencies out of it. precisely because of issues like this 😛#2022-06-0708:41thhellerclj -Sdeps '{:deps {com.google.javascript/closure-compiler-unshaded {:mvn/version "v20200920"}}}' -Stree#2022-06-0708:42thhellerthis appears to be the last version properly declaring its dependencies#2022-06-0708:42thhellercom.google.guava/guava 25.1-jre dunno if thats still the version is actually wants though#2022-06-0708:45thhellerah. found it. must be guva 31.0.1-jre#2022-06-0709:26mkvlrdoesn’t work with either#2022-06-0709:30mkvlrthink we’ll go to running not embedded until we figure this out#2022-06-0709:45thhellerwell the issue with this is that with deps.edn you can't control the "order" of dependencies#2022-06-0709:46thhellerso if your specified guava version is added to the classpath after the closure-compiler it'll still end up using the one from the closure-compiler (and the reverse of course)#2022-06-0709:46thhellerso same with datomic. did you try exluding guava from datomic?#2022-06-0709:46mkvlrnot yet#2022-06-0709:47mkvlrhave a bunch of deps with a dep on guava though#2022-06-0709:47thhellerwell, you'll still be getting one regardless#2022-06-0709:48thhelleryou can verify which verison you are getting via the usual ( "com/google/common/collect/ImmutableMap.class")#2022-06-0709:48thhellerthat'll either point to the proper jar or the closure-compiler jar#2022-06-0709:49thhellerdunno if there is any way to force deps.edn to put your declared guava dependency first to ensure nothing comes in the way#2022-06-0709:49thhelleror the closure-compiler last would probably be good#2022-06-0709:51mkvlrnevermind, it does work with guava 31.0-jre, I made a mistake when I tried this earlier#2022-06-0709:51mkvlrthank you!#2022-06-0709:51thheller👍#2022-06-0615:30dumratHi, I am in corp net. I have a bunch of repos specified in my ~\.lein\.profiles.clj Can I point shadow-cljs to read repos from here or any way I can specify repos for shadow-cljs?#2022-06-0615:53thhellerjust use leiningen to manage dependencies https://shadow-cljs.github.io/docs/UsersGuide.html#Leiningen#2022-06-0618:30ag• I have shadow-cljs.edn with :deps true • and :paths in deps.edn is set to ["src"] I need to compile both "src" and "test" files with shadow, but it doesn't let me set explicit additional path in shadow-cljs build (I have :test build in shadow-cljs.edn). How do I compile things that are not in global :source-paths? I don't want to add "test" to global :paths in deps.edn (then I'd have to deal with removing tests from the .jar, yada-yada). I do have an alias though in deps.edn with :extra-paths, but how do I make shadow to use it (instead or in addition to the global paths)?#2022-06-0619:15thheller@ag see :aliases https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2022-06-0621:18agPerfect. This is exactly what I needed. Thank you Thomas. Darn it, even though I feel like I scrolled through the guide hundred times, I still know nothing.#2022-06-0709:22dumratshadow-cljs does not update page when my public/index.html is changed. Do I need to do something to get it to hot reload?#2022-06-0709:23thhellerhtml is not looked at or reloaded. you have to do that yourself. as in press f5 😉#2022-06-0709:24dumratoh ok. Got it.#2022-06-0714:15pinkfrogShadow automatically installs these packages. what’s the potential cause?#2022-06-0716:52thheller@i your CLJS dependencies declaring them as dependencies via :npm-deps in deps.cljs files. you can skip the installation by setting :npm-deps {:install false} in shadow-cljs.edn#2022-06-0723:23pinkfrogPossible to pinpint which library has such deps?#2022-06-0809:55thhellerwell something using markdown I guess. in shadow-cljs clj-repl you can call (shadow.cljs.devtools.server.npm-deps/get-deps-from-classpath). that should tell you where it comes from#2022-06-0722:54agcan someone help me figure out this thing? I have some cljs tests :target :karma. They are running fine locally, but for whatever reason npx shadow-cljs compile :test failing on GitHub Actions. Here's some log output:
##[group]Run npx shadow-cljs compile :test
 shell: /usr/bin/bash -e {0}
 env:
   JAVA_HOME: /opt/hostedtoolcache/Java_Adopt_jdk/18.0.1-10/x64
   CLOJURE_INSTALL_DIR: /opt/hostedtoolcache/ClojureToolsDeps/latest.0.0-3-6/x64/lib/clojure
 ##[endgroup]
 shadow-cljs - config: /home/runner/work/iroh-front-end/iroh-front-end/shadow-cljs.edn
 shadow-cljs - starting via "clojure"
 WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
 Unknown option: "-m"
 Unknown option: "--npm"
 
 USAGE:
 
 clj -m cognitect.test-runner <options>
 
   -d, --dir DIRNAME            Name of the directory containing tests. Defaults to "test".
   -n, --namespace SYMBOL       Symbol indicating a specific namespace to test.
   -r, --namespace-regex REGEX  Regex for namespaces to test.
   -v, --var SYMBOL             Symbol indicating the fully qualified name of a specific test.
   -i, --include KEYWORD        Run only tests that have this metadata keyword.
   -e, --exclude KEYWORD        Exclude tests with this metadata keyword.
   -H, --test-help              Display this help message
Clojure version is the same (via DeLaGuardo/); shadow-cljs version is the same (`2.19.1`) - both in deps.edn and in package.json. jdk version is the same; node version is the same. Why is it failing?
#2022-06-0800:55agI think I solved it. I moved shadow-cljs dependency to an alias, as described here: https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2022-06-0806:43thhellerlooks like :test has something like :main-opts ["cognitect.test-runner"] so can't use that with shadow-cljs and needs its own alias yes#2022-06-0806:44thhelleralso should probably upgrade the tools.deps version. seems rather out of date.#2022-06-0810:55wombawombaI've noticed that using modules seems to increase build times. Is there a clean way to disable modules in certain circumstances (preferably via the command line)?#2022-06-0811:10thhellerthat seems unlikely? I mean if you can prove it I'd be interested but I very much doubt :modules have any impact at all#2022-06-0811:10thhellera few milliseconds at worst#2022-06-0811:11thhellerunless you are talking release builds? can't say how much more that side costs on the closure compiler side. wouldn't expect too much here either though#2022-06-0811:12thhellerjust try the same build with one :modules but all the :entries it would otherwise have. and then one with regular multiple :modules?#2022-06-0812:01wombawomba@thheller so I just performed this experiment, and what takes ~3.5s with a single module (re-building a single ns) takes ~25s with multiple modules#2022-06-0812:04thheller@wombawomba please verify with --verbose where the actual time is spent?#2022-06-0812:04thhellerand please report the final Build Complete message? I mean if it ends up including thousands more files this is expected?#2022-06-0812:05wombawombasure#2022-06-0812:06wombawombaFWIW the build messages without --verbose were:
[:app] Build completed. (1098 files, 1 compiled, 0 warnings, 2.80s)
and
[:app] Build completed. (1410 files, 1 compiled, 0 warnings, 22.36s)
#2022-06-0812:06wombawombaso it seems I missed a few files when joining everything together#2022-06-0812:07wombawombastill, the time difference is disproportionate#2022-06-0812:15wombawombaokay, so here's the verbose report with a single module:
[:app] Compiling ...
-> Resolving Module: :main
<- Resolving Module: :main (1386 ms)
-> build target: :browser stage: :compile-prepare
<- build target: :browser stage: :compile-prepare (0 ms)
-> Compile CLJS: my-app/views/site_home.cljs
<- Compile CLJS: my-app/views/site_home.cljs (743 ms)
-> Cache write: my-app/views/site_home.cljs
<- Cache write: my-app/views/site_home.cljs (92 ms)
-> build target: :browser stage: :compile-finish
-> build target: :browser stage: :flush
-> Flush: my-app/views/site_home.cljs
-> Flushing unoptimized modules
-> Flush: shadow/module/main/append.js
<- Flush: shadow/module/main/append.js (0 ms)
<- Flush: my-app/views/site_home.cljs (12 ms)
<- Flushing unoptimized modules (330 ms)
<- build target: :browser stage: :flush (350 ms)
<- build hook: [0 shadow.cljs.build-report/hook] stage: :flush (0 ms)
[:app] Build completed. (1098 files, 1 compiled, 0 warnings, 2.75s)
#2022-06-0812:16wombawomba...and here's the one with multiple modules:#2022-06-0812:17wombawomba#2022-06-0812:18wombawomba(FWIW disabling the build-report hook doesn't seem to make a difference)#2022-06-0812:33wombawomba...interesting how "Resolving Module" is either instantaneous or takes hundreds of ms. A bug perhaps?#2022-06-0812:45thhellerwhat the heck? how many modules does this have?#2022-06-0812:50thhellerI'm guessing that the fast ones require fewer namespaces and it doesn't go chasing down 1000+ files#2022-06-0812:50thhellerwhich shadow-cljs version is this with?#2022-06-0812:58wombawomba~150 modules, of which ~100 just require a single js file from an NPM package#2022-06-0812:58wombawombathere seems to be no correlation between module size and the time a module takes to build#2022-06-0812:59thhellerhow the hell do you get to 150 modules?#2022-06-0812:59wombawombaah no, wait, there is a correlation - my bad#2022-06-0813:00wombawombaWe've actually talked about this before 🙂 I'm packaging react-syntax-highlighter syntax files as separate modules#2022-06-0813:01wombawombaregardless, those modules seem to be pretty quick to load#2022-06-0813:01wombawombathere's also one module per view in the app, and it seems to be those that are taking a long time to resolve#2022-06-0813:03wombawombashadow-cljs 2.18.0#2022-06-0813:03thhellerwhat does the build report look like for this? 149 tiny modules and 1 huge chunky main module?#2022-06-0813:03wombawombano, it's fairly well distributed#2022-06-0813:08thhellerhmm I guess this is running into an unoptimized case an extreme amount of times#2022-06-0813:09thhellerguess that could be optimized a little bit#2022-06-0813:10wombawombacool#2022-06-0813:11wombawombain the meantime, is there something I can do to disable the modules from the command line when developing?#2022-06-0813:12thhellerno. I'd recommend just making two builds. one with modules one without#2022-06-0813:12wombawombaalright#2022-06-0813:35wombawomba@thheller any idea when/if this code might be optimized? Ideally I'd use modules for development as well, and I'm curious as to when I might be able to do so#2022-06-0813:38thhellerwell you case seems rather extreme so I have no way to reproduce that#2022-06-0813:38thhellermaybe I can come up with a simple reproduction case#2022-06-0813:39wombawombamakes sense#2022-06-0813:40wombawombaif possible, something like "only resolve modules when involved files change" seems like it would take care of the problem#2022-06-0813:40thhellerthats not the issue. at least I don't think it is ... just guessing still at this point#2022-06-0813:41wombawombaoh? looking at the build output, all the extra build time seems to come from "Resolving Module" steps#2022-06-0813:41wombawombathe actual compilation doesn't seem to be affected#2022-06-0813:41thhelleryes, it is the resolve part#2022-06-0813:41thhellerjust not the "when involved files change" part#2022-06-0813:42thhellerit needs to resolve modules and it does so by following the requires#2022-06-0813:42thhellerthe issue (I'm guessing) is that that repeatedly for each module since it is touching the disk#2022-06-0813:42thhellerand not using info it may already have#2022-06-0813:43wombawombayeah, that's what I figure too#2022-06-0813:43thhellerand it is not using that info because node resolve rules are weird and requiring one thing from one place#2022-06-0813:43thhellermay yield a different result than requiring the same thing from a different place#2022-06-0813:44wombawombaI have no idea how this works under the hood, but it seems like you should be able to keep a record of all files involved when resolving each given module, and re-resolve only when those files are touched#2022-06-0813:44thhelleryes if you scratch the "touched" part again. caching is not the issue here and is covered elsewhere.#2022-06-0813:45thhellerI'll figure something out when I have some time#2022-06-0813:45wombawombaawesome, thanks#2022-06-0814:33thheller@wombawomba I cannot reproduce things resolving slowly multiple times. so might be something you are doing in your setup I'm missing#2022-06-0814:33thhellerof course I'm testing with a reasonable number of modules so can't really say if that is a factor#2022-06-0814:34thhellerno more time. feel free to open an issue. a reproducible case would help though#2022-06-0815:10p-himikAn interesting issue. Not sure whether a genuine issue or a peculiarity. I'm vendoring in a library called waveform-playlist and in one of its files it has this:
import stateClasses from "./track/states";
Shadow-cljs complains:
FileNotFoundException: /home/p-himik/dev/git/ensemble/src/waveform-playlist/track/states (Is a directory)
This is, there's both a track/states directory and a track/states.js file. When using IDEA to navigate to the source of the "./track/states" import, it correctly goes to states.js.
#2022-06-0817:33thhellerby "vendoring" I assume you mean putting it on the classpath? In general you should refer to exact files with extensions there.#2022-06-0817:34thhellerthis doesn't follow the node resolve rules and to avoid ambiguities like that you should be using exact file names#2022-06-0817:34thhelleryes, they are optional in some places#2022-06-0817:34thhellerbut that is a decision I already regret#2022-06-0817:36p-himikI see, that's what I ended up doing. Thanks!#2022-06-0815:43scarytomshadow-cljs watch seems to affect other commands run in separate terminals. I run my unit tests by first running shadow-cljs -A:test compile unit-tests, which has a target of :node-test and produces a unit-tests.js file that can then be executed via node. This all works fine unless I happen to be running shadow-cljs watch app in another terminal at the same time. In this case, the compile step still produces a unit-tests.js file, but it is missing a bunch of the imports and executing it runs 0 tests. Any ideas on this?#2022-06-0816:13thheller@t.denley yes, the shadow-cljs command will re-use a running shadow-cljs instance if running. I recommend keeping you classpath the same all the time to avoid issues such as this. I assume you are adding extra-paths in the test aliases. there is no downside in always having them. you can run with --force-spawn to always get a new instance#2022-06-0816:55scarytomThanks, that's a big help#2022-06-0817:35p-himikHow should I actually vendor a JS library that consists of multiple files? The section at https://shadow-cljs.github.io/docs/UsersGuide.html#_language_support makes it seem pretty straightforward. So I have /waveform-playlist/track/loader/LoaderFactory.js on classpath with (abridged)
import BlobLoader from "./BlobLoader";
import IdentityLoader from "./IdentityLoader.js";
import XHRLoader from "./XHRLoader";
And I have /waveform-playlist/track/loader/IdentityLoader.js on classpath with
import Loader from "./Loader";

export default class IdentityLoader extends Loader {
  load() {
    return Promise.resolve(this.src);
  }
}
But in the browser, I get:
ReferenceError: IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader is not defined
    at eval (LoaderFactory.js:5:19)
    at eval (<anonymous>)
    at goog.globalEval (main.js:472:11)
    at env.evalLoad (main.js:1534:12)
    at main.js:2705:12
And the loaded LoaderFactory.js now looks like this:
import BlobLoader from "/waveform-playlist/track/loader/BlobLoader.js";
import IdentityLoader from "/waveform-playlist/track/loader/IdentityLoader.js";
import XHRLoader from "/waveform-playlist/track/loader/XHRLoader.js";
What should I do here?
#2022-06-0817:36thheller@p-himik js files on the classpath get different treatment than the regular node_modules files. this code gets rewritten by the closure compiler. there may be issues with that since not many people do this#2022-06-0817:37thhellerI can't say what exactly is the problem here but I recommend looking at the generated code#2022-06-0817:37thhellermy guess is just that it is a scoping issue#2022-06-0817:38thhellerI wish this worked more reliably but what the closure compiler is doing here is somewhat arbitrary and changes constantly#2022-06-0817:39thhellerits also not really meant to be used the way I'm using it. it is usually only use in the context of a whole program optimization pass where everything is in the same scope#2022-06-0817:39thhellerthe way the dev builds are loaded might break that#2022-06-0817:40p-himikOh. So it sounds like something might work in prod but be broken in dev? And maybe vice versa?#2022-06-0817:42thhelleryes#2022-06-0817:42p-himikCrap.#2022-06-0817:42thhellerI haven't looked at this code in years#2022-06-0817:42thhellerdunno what the closure compiler generates these days#2022-06-0817:42p-himikThe compiled output has no import statements of any kind BTW. It's as if they don't exist at all.#2022-06-0817:42thhelleryes, they need to be removed. otherwise they'd break completely since you can't use import outside modules#2022-06-0817:43p-himikAh, right. But all usages of IdentityLoader become IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader. No clue how that's supposed to work.#2022-06-0817:44thhelleras I said. look at the generated code#2022-06-0817:44thhellerits the same rewriting it does for all the other code during advanced#2022-06-0817:44thhellermeaning it rewrites everything with the assumption everything is in the global scope#2022-06-0817:44thhellerno separate files#2022-06-0817:44thhellerso it just scopes all variables accordingly which is what that long name is#2022-06-0817:45thhellerbasically just the IdentityLoader in the file named by that munged name#2022-06-0817:45thheller$waveform_playlist$track$loader$IdentityLoader basically /waveform_playlist/track/loader/IdentityLoader#2022-06-0817:46p-himikI am looking at the generated code. :) I'm not sure what exactly I should be looking for though. So I have target/dev/cljs-runtime/module$waveform_playlist$track$loader$LoaderFactory.js and in it I have console.log("IL", IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader); as the very first line.#2022-06-0817:46thhelleryes, and where is the line declaring that#2022-06-0817:46p-himikIt does not exist.#2022-06-0817:46thhellernot in that file. because it is not declared there#2022-06-0817:47thheller/waveform_playlist/track/loader/IdentityLoader this file#2022-06-0817:47thhellerwhere the class is from#2022-06-0817:47thhellertarget/dev/cljs-runtime/module$waveform_playlist$track$loader$IdentityLoader.js#2022-06-0817:48p-himikAh, right. In target/dev/cljs-runtime/module$waveform_playlist$track$loader$IdentityLoader.js I have:
class IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader extends $jscompDefaultExport$$module$waveform_playlist$track$loader$Loader {
  load() {
    return Promise.resolve(this.src);
  }
}
/** @const */ 
var module$waveform_playlist$track$loader$IdentityLoader = {};
/** @const */ 
module$waveform_playlist$track$loader$IdentityLoader.default = IdentityLoader$$module$waveform_playlist$track$loader$IdentityLoader;

$CLJS.module$waveform_playlist$track$loader$IdentityLoader=module$waveform_playlist$track$loader$IdentityLoader;
//# sourceMappingURL=module$waveform_playlist$track$loader$IdentityLoader.js.map
#2022-06-0817:49thhellerok there is the issue#2022-06-0817:49thhellerit is preserving class which is supposed to create this variable globally#2022-06-0817:49thhellerbut doesn't due to being loaded via eval#2022-06-0817:50thhellerit might work if you switch to :devtools {:loader-mode :script}?#2022-06-0817:50p-himikBut also, seems like it could've been using $CLJS.module$waveform_playlist$track$loader$IdentityLoader.default where that class is supposed to be used.#2022-06-0817:50p-himikOh, about a year ago or so {:loader-mode :script} made a dev page reload insanely slow. I'd rather search for a different solution.#2022-06-0817:51thhellerwell its the only suggestion I have#2022-06-0817:51p-himikIt's not possible to tell GCC to use that $CLJS.[...] instead of the name of a class, right?#2022-06-0817:51thhellerchanging what the code references where is not exactly easy#2022-06-0817:58thhellerI have some code that is supposed to find global references and export them#2022-06-0817:58thhellermaybe that just doesn't find class? not exactly sure#2022-06-0818:00thhellerhmm yeah https://github.com/thheller/shadow-cljs/issues/894#2022-06-0818:00thhellerdoesn't find class I guess#2022-06-0818:00thhellercan't check what the ast looks like for this now#2022-06-0818:00thhellerhttps://github.com/thheller/shadow-cljs/blob/7bc7677a88d3068fd22258bc42c41444e89f215d/src/main/shadow/build/closure/GlobalVars.java#L39#2022-06-0818:00thhellerbut thats likely the place it would need to find it#2022-06-0818:08p-himikOut of hopeful curiosity - why exactly is eval needed? Why can't the initial code loading just load a single giant file without any eval statements and any further code reloads append new <script> tags?#2022-06-0819:37thhellersource maps basically#2022-06-0819:38thhellerand some other reason I can't remember right now#2022-06-0819:42p-himikMy level of expertise is dangerously close to 0 here, but I think at least on the initial load you can provide a single mangled JS file plus a single sourcemap file, and let it be mapped to multiple original CLJS sources. Right? If so - maybe there's a way to patch a source map without having to re-download it? Of course, even if all that is correct, it still doesn't address that other reason...#2022-06-0819:51thhellerthats what this is basically. it just uses eval to load the files to match the behavior of hot-reloaded files#2022-06-0819:51thhellerbut that wasn't the reason. really can't remember but I spent a substantial amount of time on this so please assume that this is done for a reason#2022-06-0819:52thhellerfeel free to try alternatives if you want to investigate a new loader-mode#2022-06-0819:52thhellerI don't have time to currently#2022-06-0819:52p-himikRight. I myself am currently rewriting the vendored library to use goog.module. :D#2022-06-0819:55p-himikA related question - how would I use an NPM dep inside a goog module?#2022-06-0819:57thhellernot supported (because the closure compiler doesn't know how to process it)#2022-06-0819:58p-himikAh. Crap x 2.
#2022-06-0819:58thhellerbut you can just write it as commonjs isntead#2022-06-0819:58thhellerno point in goog.module really#2022-06-0819:58thhellerjust require/exports#2022-06-0819:58thhellerso no import or export#2022-06-0819:59thhellercommonjs gets the exact same treatment as npm libs#2022-06-0819:59p-himikThanks, will check out how it's done. Have never bothered with all JS :poop: ways of module management.#2022-06-0819:59thhellerjust skip goog.module#2022-06-0819:59thhellerand use require instead of goog.require#2022-06-0819:59p-himikAlright!#2022-06-0819:59thhellerexports.x can stay the same as in goog.module#2022-06-0820:19p-himikOh bloody hell... So if I have exports = {Playlist}; it doesn't work because Suspicious re-assignment of "exports" variable. Did you actually intend to export something? And if I have exports.Playlist = Playlist; or module.exports = {Playlist};, it doesn't work because
ExceptionInfo: failed to convert sources
[...]
Caused by:
NullPointerException: NAME h 11:8  [length: 1] [source_file: waveform-playlist/Playlist.js] [original_name: h]
And h there is just import {h, diff, patch} from "virtual-dom";.
#2022-06-0820:20thhellerand why is there an import? that makes it ESM and breaks everything#2022-06-0820:21p-himikAh, of course. Brain refused to see it because it's not importing the vendored stuff.#2022-06-0820:35thhellerhttps://github.com/thheller/shadow-cljs/commit/1b459145974b1f9566a14c3b87e1f70b3b288738#2022-06-0820:36thhellerdunno if this would fix your issue. too tired to test right now.#2022-06-0820:36thhellerin theory it should though#2022-06-0820:37p-himikImmaculate timing - just as I finished rewriting it into CommonJS! :D Thanks for all the guidance BTW. But good to know either way, I'll test it a bit later and let you know.#2022-06-0823:36pinkfrogI see many resource not found errors, how’s the path determined?#2022-06-0823:39thheller:asset-path in your build config. defaults to "/js"#2022-06-0823:39thhellerfor the websocket error you probably need to set :devtools {:devtools-url ""}#2022-06-0823:43pinkfrogIf I do not specify devtools-url, how is it determined? The oh….pa part is weird#2022-06-0823:48thhellerby default it uses the document.location of the html document loading the JS#2022-06-0823:49thhellerthats just this weird thing in chrome extensions#2022-06-0823:49thheller:devtools {:use-document-host false} also works#2022-06-0823:50pinkfrogAlso it sounds I have to put the :devtools under the build section. Putting it under top level is ignored.#2022-06-0823:53thhelleryes, part of the build config always#2022-06-0907:47barrellI’m running into an issue with lazily-loaded code-split modules. If I try to load an asset from a nested url (`/foo/bar`) it tries to fetch /foo/<asset-path>/<module>. I have the :asset-path set to "/js" which should solve this. Is there any other reason this may be cropping up?#2022-06-0907:52barrell~woah weird. All my config option got put into ~ nevermind, it’s still early and I apparently can’t read edn. :asset-path is in the right place but still not working#2022-06-0908:01thhellerasset-path is the correct option#2022-06-0908:01thhellerbut how do you load the modules?#2022-06-0909:27barrellshadow.lazy/loadable#2022-06-0909:28barrellthen shadow.lazy/load#2022-06-0909:41thhellershould be fine. you sure it doesn't actually tries /js and then gets redirect server side or something?#2022-06-0910:04barrell#2022-06-0910:05thhelleryeah dunno sorry. you can look at the source code to see which path is actually written in the file#2022-06-0910:05thhellerjust look for js/phrasing. it'll be there in a string#2022-06-0910:05thhellerif that is not /js/phrasing somehow the :asset-path isn't applied#2022-06-0908:45mkvlr@thheller thanks for the shadow release with the explicit guava dep! 🙏#2022-06-0909:40thhellerhope that helps a little bit#2022-06-1013:27johndoeDoes clojurescript compile modules independent from each other? I couldn't resolve qualified symbol inside my macros - it's constantly nil. (All modules are cljc). Unqualified symbols are resolve properly. Although namespace of that symbol is mentioned in require section of namespace from which I call macros.#2022-06-1013:36johndoeShort snippet for context
(ns cxa.core
  (:require [cx.backend.web :as cx]
            [cxa.todomvc]
            [cxa.counters]))

(defonce root (atom nil))

(cx/def<> app #{example}
  [:div
   [:div
    [cx/for [[key title] [[:counters "counters"]
                          [:todomvc "todomvc"]]]
     [:label
      [:input {:name "example"
               :type "radio"
               :value key
               :on/change #(cx/!! (fn [{:keys [key]}]
                                    {:example key}))}]
      title]]]
   [cx/case example
    :counters [cxa.counters/app]
    :todomvc  [cxa.todomvc/app]
    "nothing selected"]])

(defn rebind [old]
  (when old (doto old (cx/detach) (cx/dispose)))
  (doto (cx/create app)
    (cx/attach (.-body js/document) nil)))

(defn main []
  (swap! root rebind))
I couldn't resolve particularly cxa.counters/app and cxa.todomvc/app inside cx/def<> macro. Everything works correct only if move all stuff to single namespace.
#2022-06-1016:10thhellerwhat do you mean by resolve? I mean what does your macro look like?#2022-06-1016:20johndoeBy resolve i mean literally (clojure.core/resolve sym) call. My macro is a compiler of hiccup-like trees doing same stuff as svelte. I keep a bit of compile-time information about generated components for some checks to ensure they correctly used.#2022-06-1016:21johndoeI know that clojure and cljs namespaces are completely isolated, so keep compile-time info in clojure namespace with same names and vars with same symbols as in cljs.#2022-06-1016:22johndoeBy the way I think problem is not where I thought.#2022-06-1016:22johndoeSeems like a tree-shaking eliminates my namespaces for some reason and I even can't stable reproduce it. Issue with unresolvable symbols arises randomly between restarts of cljs watch.#2022-06-1016:29johndoeHave no idea how to debug this 😞#2022-06-1016:44johndoeSuccessful build after restart, have added empty lines (!) in one of namespaces, and it blow up. And it could vise versa.
shadow-cljs - config: /mnt/dataf/projects/stuff/shadow-cljs.edn
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.16.7 running at 
shadow-cljs - nREPL server started on port 42155
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (142 files, 0 compiled, 0 warnings, 2.12s)
[:app] Compiling ...
[:app] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /mnt/dataf/projects/stuff/src/cxa/core.cljc:9:1
--------------------------------------------------------------------------------
   6 |
   7 | (defonce root (atom nil))
   8 |
   9 | (cx/def<> app #{example}
-------^------------------------------------------------------------------------
An error occurred while generating code for the form.
ExceptionInfo: failed compiling constant: 
#2022-06-1017:21johndoeI keep a comp-time info in atom and have changed def to defonce and a problem have gone :thinking_face: It's strange because this namespace clj-only (not cljc) and I have not expect it would suddenly reload (with erase of previously accumulated info in the atom) without obvious reason like changed code inside of it. In the same time cljs watch doesn't look into required namespaces that haven't change and there is no chances to re-accumulate info again.#2022-06-1017:23johndoecljs macros is a mess#2022-06-1017:55thhellercljs macros are not a mess#2022-06-1017:55thhellerusing them incorrectly creates a mess#2022-06-1017:56thhellerwithout knowing what you are doing I can't give advice on what might be wrong#2022-06-1017:56thheller> Seems like a tree-shaking eliminates my namespaces#2022-06-1017:56thhellerwatch does no tree-shaking whatsoever. not even attempts to.#2022-06-1017:57thheller> cx.trees.specials.core$reify__28843 is not a valid ClojureScript constant #2022-06-1017:57thhellermeans that you can't use the result of a CLJ (reify ..) call and expect that to produce JS#2022-06-1017:57thhellerso likely you are missing a quote or so#2022-06-1017:58thheller> I keep a comp-time info in atom and have changed def to defonce and a problem have gon#2022-06-1017:58thhellerdon't do this#2022-06-1017:59thhellerif you want to you must disable all caching, as otherwise compilation results may be cached#2022-06-1017:59thhellerand that wouldn't re-populate whatever extra atom you have#2022-06-1017:59thhelleralso clojure.core/resolve only knows how to resolve CLJ vars#2022-06-1017:59thhellerit has no knowledge or concept of CLJS vars, so it can never resolve them#2022-06-1018:00thhellerfor that there is cljs.analyzer/resolve-var#2022-06-1018:29johndoe> don't do this But this works somehow :thinking_face: Is this wrong assumption that defonce atom inside clojure namespace (not cljs namespace) will be preserved during cljs compilation (and cljs watch lifetime)? > cljs.analyzer/resolve-var I use this one too for translate cljs symbols into qualified ones and using them resurrect a comp-time info generated by my macro.#2022-06-1018:36thhelleras I said. you must disable caching if you do this. the cache will not restore whatever is in your atom#2022-06-1018:36thhellerso if you stop a watch and start a new one things will be missing#2022-06-1018:36thhellerduring a watch it stays available yes#2022-06-1018:52johndoequickly looked at documentation and it's surprising but this caching issue mentioned there and even with library example - clara-rules. thank you#2022-06-1018:53thhellerwhat are you storing in the atom? maybe you don't actually need the atom and can just look stuff up in the analyzer data?#2022-06-1018:57johndoea set of slots (https://svelte.dev/tutorial/slots) which component accepts for every previously compiled component. so it's a mapping {ns/sym -> #{slots}}#2022-06-1019:02thhellerif its just data you can get it from the analyzer data#2022-06-1019:02thhellerand get it into there via metadata on the created var#2022-06-1019:05johndoemetadata will be erased in resulted js? I need this info only for compile time#2022-06-1019:06johndoealso slots set is result of hiccup analyzing#2022-06-1019:09thhelleryes, metadata does not make it into the JS#2022-06-1019:09thhellerI assume you create some (def ~name-of-something ...)#2022-06-1019:10thhelleryou can (var-meta name-of-something assoc :slots the-hiccup-data)#2022-06-1019:10thhellerand then get it from the compiler env in [:cljs.analyzer/namespaces that.ns :defs name-of-something :meta]#2022-06-1019:10thhellerthat data would be safe in cache#2022-06-1019:11johndoewow. i'll try. thank you very much!#2022-06-1015:50salamis there a way to override a configuration item in shadow-cljs.edn (e.g., nrepl: false) with a command line argument to shadow.cljs.devtools.cli?#2022-06-1016:12thheller@abdusalam no, not currently. there is --config-merge for overriding build config stuff but not global options like nrepl#2022-06-1019:11salamok. thanks, Thomas. #2022-06-1110:14Vincent CantinIn version 2.19.1 , shadow-cljs emits warning about a few things which are running at macro time. For example, this:
;; source code at 

------ WARNING #1 - :undeclared-var --------------------------------------------
 Resource: cljs/analyzer.cljc:4403:12
--------------------------------------------------------------------------------
4400 |   []
4401 |   (try
4402 |     @(ns-resolve 'clojure.tools.reader '*alias-map*)
4403 |     (catch Throwable t
------------------^-------------------------------------------------------------
 Use of undeclared Var cljs.analyzer/Throwable
--------------------------------------------------------------------------------
4404 |       nil)))
4405 | 
4406 | #?(:clj
4407 |    (defn forms-seq*
--------------------------------------------------------------------------------
#2022-06-1110:15thheller@vincent.cantin this is a bug in CLJS itself. it has been fixed in master but there has been no release for that yet.#2022-06-1110:15Vincent Cantinoh, ok. Thanks#2022-06-1110:16thhellerhttps://github.com/clojure/clojurescript/commit/c0d305274d7813e22cd2753d247a02e9dd95ddee#2022-06-1110:17Vincent CantinI see. It makes sense 🙂#2022-06-1110:30Vincent CantinAnother (small) issue I found using shadow-cljs 2.19.1. The macro-expension doesn't recognize the edn alias :
------ ERROR -------------------------------------------------------------------
 File: [redacted]/config.cljc:5:1
--------------------------------------------------------------------------------
   2 |   (:require [ :as mio]
   3 |             #?(:clj [clojure.edn :as edn])))
   4 | 
   5 | (mio/inline-resource "endpoints.edn" edn/read-string)
-------^------------------------------------------------------------------------
Encountered error when macroexpanding .
Error in phase :compile-syntax-check
RuntimeException: No such namespace: edn
        clojure.lang.Util.runtimeException (Util.java:221)
        clojure.lang.Compiler.resolveIn (Compiler.java:7401)
        clojure.lang.Compiler.resolve (Compiler.java:7375)
        clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
        clojure.lang.Compiler.analyze (Compiler.java:6785)
        clojure.lang.Compiler.analyze (Compiler.java:6762)
        clojure.lang.Compiler.eval (Compiler.java:7198)
        clojure.lang.Compiler.eval (Compiler.java:7149)
        clojure.core/eval (core.clj:3215)
        clojure.core/eval (core.clj:3211)
         (io.cljc:51)
         (io.cljc:42)
        clojure.core/apply (core.clj:671)
        clojure.core/apply (core.clj:662)
        cljs.analyzer/macroexpand-1*/fn--3702 (analyzer.cljc:4014)
mio/inline-resource is defined at https://github.com/green-coder/mate/blob/7107664b5e95521e8755e13b0f9cf19227408e24/src/mate/io.cljc#L51
#2022-06-1110:31Vincent CantinA workaround is simply to write the fully qualified name clojure.edn/read-string.#2022-06-1110:31thhellersorry thats just wrong 😛#2022-06-1110:32Vincent Cantinah 😅 I still don't understand the detail which I missed.#2022-06-1110:32thhellerwell CLJC can be tricky that way#2022-06-1110:33thhelleryou are basically writing two namespaces in one file#2022-06-1110:33Vincent Cantinoh ... so you mean that the calling side of the macro is in the .cljs namespace ?#2022-06-1110:33thhellerand you are using eval which is extra tricky 😛#2022-06-1110:35thhelleralso probably better to just inline the string and read it client side#2022-06-1110:35thhellercertainly much smaller code size#2022-06-1110:36Vincent CantinI wasn't sure if my code was correct, but it does pass the tests with the same pattern via kaocha https://github.com/green-coder/mate/blob/made-in-taiwan/test/mate/io_test.cljc#L22#2022-06-1110:36thhellerI honestly don't know what the exact problem is. I think eval is just probably running in the wrong namespace context. meaning *ns* is not the one that has the edn alias#2022-06-1110:37Vincent CantinThanks for your feedback. I will try to investigate.#2022-06-1111:08Vincent CantinI think/guess that the problem is simply that the symbol resolution is happening in the cljs namespace, way before the macro and its eval are called.#2022-06-1111:11thhellerno, the stacktrace is clojure only#2022-06-1111:12thhellerjust log *ns* somewhere and see#2022-06-1111:12thheller(tap> *ns*) or so#2022-06-1111:14Vincent CantinFull stacktrace:
2 |   (:require [ :as mio]
   3 |             #?(:clj [clojure.edn :as edn])))
   4 | 
   5 | (mio/inline-resource "endpoints.edn" edn/read-string)
-------^------------------------------------------------------------------------
Encountered error when macroexpanding .
Error in phase :compile-syntax-check
RuntimeException: No such namespace: edn
        clojure.lang.Util.runtimeException (Util.java:221)
        clojure.lang.Compiler.resolveIn (Compiler.java:7401)
        clojure.lang.Compiler.resolve (Compiler.java:7375)
        clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
        clojure.lang.Compiler.analyze (Compiler.java:6785)
        clojure.lang.Compiler.analyze (Compiler.java:6762)
        clojure.lang.Compiler.eval (Compiler.java:7198)
        clojure.lang.Compiler.eval (Compiler.java:7149)
        clojure.core/eval (core.clj:3215)
        clojure.core/eval (core.clj:3211)
         (io.cljc:51)
         (io.cljc:42)
        clojure.core/apply (core.clj:671)
        clojure.core/apply (core.clj:662)
        cljs.analyzer/macroexpand-1*/fn--3702 (analyzer.cljc:4014)
        cljs.analyzer/macroexpand-1* (analyzer.cljc:4012)
        cljs.analyzer/macroexpand-1* (analyzer.cljc:3999)
        cljs.analyzer/macroexpand-1 (analyzer.cljc:4063)
        cljs.analyzer/macroexpand-1 (analyzer.cljc:4059)
        cljs.analyzer/analyze-seq (analyzer.cljc:4096)
        cljs.analyzer/analyze-seq (analyzer.cljc:4076)
        cljs.analyzer/analyze-form (analyzer.cljc:4285)
        cljs.analyzer/analyze-form (analyzer.cljc:4282)
        cljs.analyzer/analyze* (analyzer.cljc:4338)
        cljs.analyzer/analyze* (analyzer.cljc:4330)
        shadow.build.compiler/analyze/fn--15107 (compiler.clj:264)
        shadow.build.compiler/analyze (compiler.clj:252)
        shadow.build.compiler/analyze (compiler.clj:211)
        shadow.build.compiler/analyze (compiler.clj:213)
        shadow.build.compiler/analyze (compiler.clj:211)
        shadow.build.compiler/default-analyze-cljs (compiler.clj:408)
        shadow.build.compiler/default-analyze-cljs (compiler.clj:397)
        clojure.core/partial/fn--5908 (core.clj:2642)
        shadow.build.compiler/do-analyze-cljs-string (compiler.clj:318)
        shadow.build.compiler/do-analyze-cljs-string (compiler.clj:278)
        shadow.build.compiler/analyze-cljs-string/fn--15201 (compiler.clj:511)
        shadow.build.compiler/analyze-cljs-string (compiler.clj:510)
        shadow.build.compiler/analyze-cljs-string (compiler.clj:508)
        shadow.build.compiler/do-compile-cljs-resource/fn--15229 (compiler.clj:626)
        shadow.build.compiler/do-compile-cljs-resource (compiler.clj:607)
        shadow.build.compiler/do-compile-cljs-resource (compiler.clj:565)
        shadow.build.compiler/maybe-compile-cljs/fn--15332 (compiler.clj:958)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:957)
        shadow.build.compiler/maybe-compile-cljs (compiler.clj:933)
        shadow.build.compiler/par-compile-one (compiler.clj:1066)
        shadow.build.compiler/par-compile-one (compiler.clj:1021)
        shadow.build.compiler/par-compile-cljs-sources/fn--15368/iter--15390--15394/fn--15395/fn--15396/fn--15397 (compiler.clj:1139)
        clojure.core/apply (core.clj:667)
        clojure.core/with-bindings* (core.clj:1990)
        clojure.core/with-bindings* (core.clj:1990)
        clojure.core/apply (core.clj:671)
        clojure.core/bound-fn*/fn--5818 (core.clj:2020)
        java.util.concurrent.FutureTask.run (FutureTask.java:264)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
        java.lang.Thread.run (Thread.java:833)
#2022-06-1111:16thheller
RuntimeException: No such namespace: edn
        clojure.lang.Util.runtimeException (Util.java:221)
        clojure.lang.Compiler.resolveIn (Compiler.java:7401)
        clojure.lang.Compiler.resolve (Compiler.java:7375)
        clojure.lang.Compiler.analyzeSymbol (Compiler.java:7336)
        clojure.lang.Compiler.analyze (Compiler.java:6785)
        clojure.lang.Compiler.analyze (Compiler.java:6762)
        clojure.lang.Compiler.eval (Compiler.java:7198)
        clojure.lang.Compiler.eval (Compiler.java:7149)
        clojure.core/eval (core.clj:3215)
        clojure.core/eval (core.clj:3211)
         (io.cljc:51)
#2022-06-1111:16thhellerthis is the relevant part though#2022-06-1111:17thhellerthe rest is just regular CLJS compilation stuff#2022-06-1111:28Vincent Cantin(tap> *ns*) gives me the namespace where the macro is called, but I don't know how to differentiate between the clj and the cljs ones#2022-06-1111:29Vincent Cantinits :imports contains a lot of Java classes, however#2022-06-1111:32thhellerdunno what you mean. this is a clojure namespace yes. just need to check the name#2022-06-1111:32thhelleris it the one that has the alias or not?#2022-06-1111:32Vincent Cantinthe name is the namespace where the macro is called#2022-06-1111:32Vincent Cantinyes, the one with the alias#2022-06-1111:33thhellerI guess I don't know how eval resolves symbols then#2022-06-1111:53Vincent CantinIt seems that this is the namespace used by resolveIn , I don't know if it is the same as *ns* https://github.com/clojure/clojure/blob/35bd89f05f8dc4aec47001ca10fe9163abc02ea6/src/jvm/clojure/lang/Compiler.java#L7535-L7537#2022-06-1111:55thhellerhttps://github.com/clojure/clojure/blob/35bd89f05f8dc4aec47001ca10fe9163abc02ea6/src/jvm/clojure/lang/RT.java#L223#2022-06-1111:55thhellerit is yeah#2022-06-1113:29thhellerthe analyzer warning should be fixed in 2.19.3#2022-06-1110:54tianshuHow should I understand this error, I'm trying to use the worker threads in nodejs target
SHADOW import error /home/tianshu/workspace/race-poker/racepoker-transactor/.shadow-cljs/builds/worker/dev/out/cljs-runtime/shadow.module.main.append.js
#2022-06-1110:55thhellerI don't know. where is the rest of it? I mean that message is just telling you what failed to load. *why* should be below it?#2022-06-1111:06tianshuHmm, there's no more information. Probably because it happens in a worker thread. I think it's some error, maybe. I'm struggling with how to async/await in clojurescript. Because I have to let a script keep running, and receive messages.#2022-06-1111:07tianshuI saw in JavaScript, they do
async function() {
    await new Promise(resolve => setTimeout(resolve, 1000);
}
#2022-06-1112:14chrisbroomeJust to be clear, you’d want to return that promise in JavaScript in order to await on it:
async function delayOneSecond() {
    return await new Promise(resolve => setTimeout(resolve, 1000);
}
or via arrow notation which is more idiomatic now, automatically returns if it’s just 1 statement, and has the benefit that it can’t be called as a JS constructor (i.e. it has no this binding):
const delayOneSecond = async () => await new Promise(resolve => setTimeout(resolve, 1000))
Interestingly enough in JS because of the way promises chain you don’t need to explicitly await a promise if it’s the return value of the async function - they are automatically unwrapped, so the following code is equivalent:
const delayOneSecond = async() => new Promise(resolve => setTimeout(resolve, 1000))
#2022-06-1111:08thhellerthere should be more information? I mean the above is just log output. there will be an actual exception thrown which should be available somewhere?#2022-06-1111:09thhellerin node script should remain running if its waiting for network input or something?#2022-06-1111:09thhellerI mean the above you can just write without promise or await#2022-06-1111:10thheller(defn wait-forever [] (js/setTimeout wait-forever 1000)) and then calling (wait-forever) once somewhere#2022-06-1111:10thhelleryou probably want some kind of wait to stop that waiting though 😉#2022-06-1111:12tianshuI don't know why I can't reproduce this problem now. When it happens, there's no more information, only this line.#2022-06-1111:13thhellerthen whatever you are using to run this is catching and discarding exceptions#2022-06-1111:13thhellerwhich seems like a bad idea. or you are just missing an arguments or so that would handle this#2022-06-1111:15thhellergiven that its node maybe an (.on worker "error" (fn [e] ...)) or so#2022-06-1111:15tianshuYeah, you're right. Just have one timeout, will prevent from exit.#2022-06-1111:16tianshuI want to run something represent a game room, and receive / send events. Main thread is used for websocket connection, and the game logic is running inside workers.#2022-06-1111:18tianshuYeah, it exits because I have some error.#2022-06-1111:18tianshuIt's a bit confusing when somewhere has an error, because if you don't catch it, it has no information at all.#2022-06-1111:19thhellerdo you have an (.on worker "error" (fn [e] ...))?#2022-06-1111:19thhellerI mean it should end up there?#2022-06-1111:19thhellernever used workers in node so can't really say but that would be my expectation#2022-06-1111:24tianshuYep, I have one#2022-06-1111:25tianshuMaybe it's my case, I've tried browser-repl build a few days ago, when I execute code with an error, the repl will tell :repl/exception . But nowhere I can see the error, unless I wrap it with a try/catch#2022-06-1111:25thhelleris that with emacs? if so maybe try without? the :repl/exception should always be coming together with the actual error. emacs maybe hiding that part somewhere#2022-06-1111:26tianshuUnfortunately, yes#2022-06-1111:27tianshuI still didn't get used to other editor#2022-06-1111:27tianshuYep, it could be.#2022-06-1111:27thhellerfine to use that editor. just maybe try just shadow-cljs browser-repl and evaling whatever to find the actual problem#2022-06-1111:28tianshuBut if that error happen in browser. Will it be caught, so I couldn't see it inside browser console?#2022-06-1111:28tianshuI will do that after my work#2022-06-1111:28thhellerno. meaning the exception is caught if you eval at the REPL because thats always in a try/catch and it'll return that to the REPL. emacs just seems to maybe hide it. dunno, should be printed to stderr. wherever that ends up in emacs#2022-06-1111:43tianshuYeah, will try it again#2022-06-1205:18Karan AhlawatHello, I'm trying to create a shadow-cljs project with it's dependencies listed in deps.edn. The problem I'm running into is that shadow-cljs does not find react and react-dom as deps for reagent, if I specify them in the deps.edn file. It only works if I have them installed into a node_modules folder. Ideally I'd just like to eliminate the usage of npm, and have all my deps specified in deps.edn.#2022-06-1205:49thheller@ahlawatkaran14 JS dependencies cannot be specified in deps.edn and you need npm for them.#2022-06-1205:49Karan AhlawatSo there's no way at all? Unfortunate, but that's life I suppose#2022-06-1205:50thhelleryou don't even specify JS dependencies in shadow-cljs.edn when using only that. they always go in package.json and are managed by npm or yarn#2022-06-1205:51Karan AhlawatAh, okay. I read on the reagent website that you could specify cljsjs/react and react-dom, so I thought it was possible. Maybe that was for other options than shadow-cljs#2022-06-1205:52thhellershadow-cljs does not support cljsjs packages so those don't work#2022-06-1205:53Karan AhlawatAha! Fair enough. Thanks for replying, I was really stumped. Now to figure out a good REPL workflow.#2022-06-1312:23Tiago Dall'Oca
.../dist/cljs_env.js:748
                return evalCheck('let r;try{r\x3d", "}catch{};r'););
                                                                  ^

    SyntaxError: Unexpected token ')'

    > 1 | var $CLJS = require("./cljs_env");
        |             ^
      2 | var $jscomp = $CLJS.$jscomp;
      3 | var COMPILED = false;
      4 | require("./cljs.core.js");

      at Runtime.createScriptFromCode (../../node_modules/.pnpm/
#2022-06-1312:24Tiago Dall'Ocadisclaimer: omitted some of the sensible dirs#2022-06-1312:24Tiago Dall'Ocawhen trying to run a compiled cljs with :target :npm-module on jest, I get this#2022-06-1312:25Tiago Dall'Ocathe same thing happens if run with :target :node-library#2022-06-1312:52Tiago Dall'Ocaoh, and it works with node
Welcome to Node.js v14.19.3.
Type ".help" for more information.
> const { typeSchemas, validate, explain } = require('./dist/mn.flow.ibanxs_data.js')
undefined
> validate(typeSchemas.Country, { id: "BR", name: "Brazil" })
true
> validate(typeSchemas.Country, { id: "BR", name: 123 })
false
#2022-06-1314:41Tiago Dall'Ocafound it!#2022-06-1314:41Tiago Dall'Ocanot really related to shadow-cljs, but with jest#2022-06-1314:42Tiago Dall'Ocaneeded to use transformIgnorePatterns option on jest's config to ignore compiled cljs files#2022-06-1312:24Tiago Dall'Ocawhen trying to run a compiled cljs with :target :npm-module on jest, I get this#2022-06-1314:42Tiago Dall'Ocaneeded to use transformIgnorePatterns option on jest's config to ignore compiled cljs files#2022-06-1319:31Tiago Dall'Ocawhen attempting to load two different :npm-modules in the same js file, I get this
Namespace "goog.debug.Error" already declared.

      107 |   if (!COMPILED) {
      108 |     if (goog.isProvided_(name)) {
    > 109 |       throw new Error('Namespace "' + name + '" already declared.');
          |             ^
      110 |     }
      111 |     delete goog.implicitNamespaces_[name];
      112 |   }
#2022-06-1319:32Tiago Dall'Ocait seems that runtime dependencies to run cljs is getting loaded twice#2022-06-1319:47thhellerdefine two different :npm-module. you mean actual builds or separate namespaces?#2022-06-1319:47thhelleras far as builds are concerned you should not do that and it is not supported#2022-06-1319:47Tiago Dall'Ocathey are two different "libraries"#2022-06-1319:47thhellermakes no sense to do that really#2022-06-1319:47thhellerthats fine. just have one build thats includes the two#2022-06-1319:48Tiago Dall'Ocadefined in two different shadow-cljs.edn#2022-06-1319:48Tiago Dall'Ocathe idea would be to have reusable npm-like libraries#2022-06-1319:48Tiago Dall'Ocathat could be required as needed#2022-06-1319:49Tiago Dall'Ocado you know what I mean?#2022-06-1319:49thhelleryes, that is not a good idea and should not be done#2022-06-1319:50thhellereach library will have its own cljs.core variant and they will not be compatible with each other#2022-06-1319:50Tiago Dall'OcaI see#2022-06-1319:50thhellernot to forget the extra build size you get by having cljs.core twice#2022-06-1319:50Tiago Dall'Ocayes#2022-06-1319:50Tiago Dall'OcaI thought about it#2022-06-1319:50Tiago Dall'Ocais there a way to have cljs runtime dependencies loaded just once?#2022-06-1319:51thhellernot in an :advanced optimized build (which is what you should aim for)#2022-06-1319:51Tiago Dall'Ocaand btw, does this limits me to only being able to use monolith cljs libraries with node?#2022-06-1319:51thhellerno you are missing what I'm saying#2022-06-1319:52thhelleryou can have ONE build that includes the whole universe of CLJS libraries. all of them for all I care.#2022-06-1319:52thhellervia that one build you basically expose all of them to JS#2022-06-1319:52thhellerthe point is having one build so you only have each namespace once#2022-06-1319:53Tiago Dall'Ocaright#2022-06-1319:53thhellerthe trouble only starts when you want to build pre-compiled libraries to be included in JS separately#2022-06-1319:53Tiago Dall'Ocalet me see if I understood#2022-06-1319:53thhellerthat is just not something that is feasible in CLJS#2022-06-1319:54Tiago Dall'Ocahaving multiple cljs libs defined each with their own shadow-cljs.edn is a bad idea?#2022-06-1319:54Tiago Dall'Ocanot feasible?#2022-06-1319:54thhellerplease expand on what you are actually trying to do#2022-06-1319:55thhellermaybe I can explain it better in that context#2022-06-1319:55Tiago Dall'Ocaright#2022-06-1319:55Tiago Dall'OcaI'm trying to integrate cljs in js#2022-06-1319:55Tiago Dall'Ocalegacy ts code that is#2022-06-1319:56thhellerok#2022-06-1319:56Tiago Dall'Ocawe work with multiple packages#2022-06-1319:56thhellerso you have two separate CLJS libraries#2022-06-1319:56Tiago Dall'Ocaeach package acting as its own standalone lib#2022-06-1319:56thhellerthat you want to include in that ts code#2022-06-1319:56Tiago Dall'Oca> so you have two separate CLJS libraries#2022-06-1319:56Tiago Dall'Ocayes#2022-06-1319:56thhellerok. so you make a third "inclusion" library#2022-06-1319:57thhellerthat lib is actually compiled and includes both other libs#2022-06-1319:57Tiago Dall'Ocaok, right#2022-06-1319:57thhellerthey don't need to compiled at all on their own#2022-06-1319:57thhelleryou are doing that to avoid the duplication of cljs.core and other namespaces#2022-06-1319:58Tiago Dall'Ocabut what if they those other 2 libs are defined in separate shadow-cljs.edn?#2022-06-1319:58thhellerand to ensure the CLJS parts of the code are actually compatible with each other#2022-06-1319:58thhellerthey can have them. that is fine. that really doesn't matter here#2022-06-1319:58thhelleryou created a third lib that combines them#2022-06-1319:59Tiago Dall'Ocagood#2022-06-1319:59thhellerthat lib you consume in the TS code#2022-06-1319:59thhellerthat is the only way to properly bridge CLJS code into JS/TS code#2022-06-1319:59Tiago Dall'Ocathis third lib must have access to the cljs source of the original 2 libs, right?#2022-06-1319:59thhelleryes, they are actual CLJS libraries#2022-06-1319:59Tiago Dall'Ocauhum#2022-06-1320:00Tiago Dall'OcaI think I got it now#2022-06-1320:00thhellerif you use deps.edn you can just use :local/root or git urls#2022-06-1320:00Tiago Dall'Ocadoes deps.edn play well with shadow-cljs?#2022-06-1320:01thhellersure#2022-06-1320:03thhellerjust manages dependencies. does not affect compilation in any way if you use deps.edn or project.clj or just shadow-cljs.edn#2022-06-1320:06Tiago Dall'Ocaok#2022-06-1320:06Tiago Dall'Ocathanks a lot!#2022-06-1412:17Tiago Dall'Ocahey @U05224H0W, just confirm, if I'm using deps to manage my dependencies, do I have to use clj to compile or it still works running shadow-cljs?#2022-06-1412:28Tiago Dall'Ocaalso, server doesn't work with deps, right?#2022-06-1417:45thhellerno, you are treating this wrong#2022-06-1417:45thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2022-06-1417:46thhelleryou literally only move the :dependencies and :source-paths from shadow-cljs.edn to deps.edn (with :deps and :paths there) and add the thheller/shadow-cljs dependency which is automatically included in shadow-cljs.edn but not in deps.edn#2022-06-1417:46thhellereverything else stays the same. you use the tool in the exact same way as before#2022-06-1417:47thhelleryou have the option of just using clj yes, but you do not need to#2022-06-1417:48Tiago Dall'Oca> you literally only move I understood that#2022-06-1417:48Tiago Dall'Ocajust wasn't sure if server worked#2022-06-1417:48Tiago Dall'Ocawith deps#2022-06-1417:49thhelleragain. it is just managing dependencies. the shadow-cljs CLI tool continues with the same functionality and nothing else changes#2022-06-1417:49thhellerif you use clj instead of the shadow-cljs command then yes, server mode is limited#2022-06-1417:49thhellerit still works but not in the same way as the shadow-cljs command#2022-06-1417:50thhellerunless I'm misunderstanding by what you mean by "if server worked"#2022-06-1417:50Tiago Dall'Ocashadow-cljs start when :deps true#2022-06-1417:52thhelleryes, that should work fine. never actually tried that myself though.#2022-06-1417:52thhellerI only use shadow-cljs server. ie. start but keep running in foreground rather than background#2022-06-1418:05Tiago Dall'Oca
shadow-cljs - config: .../shadow-cljs.edn
shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
#2022-06-1418:08Tiago Dall'Ocaafter running shadow-cljs start#2022-06-1418:10Tiago Dall'Ocaeven though I added shadow-cljs as :extra-deps#2022-06-1418:16thhellerwell did you set that alias in shadow-cljs.edn?#2022-06-1418:16thhellerthe above error you get when shadow-cljs is not on the classpath#2022-06-1418:17thhellerso I assume you added it to some alias but did not set :deps {:aliases [:foo :bar]} accordingly#2022-06-1412:00hanDerPederI’m trying to set up a UI library using React+Typescript+Storybook+MaterialUI and consume it as a library in clojurescript. I’ve been able to export a commonjs file and require it from my reagent app, but the styles are not applied. Seems material ui uses css-in-js which I’m not familiar with. Grepping the dist file the styles seem to be present. Any idea how to debug this?#2022-06-1412:12hanDerPederchanging from commonjs output to esm seems to have worked. only snag is I have to edit the output file and replace import * as React from "react"; with import React from "react";#2022-06-1412:14hanDerPederthe user guide says: > Due to strict checking of the Closure Compiler it is not possible to use the import * as X from "npm"; syntax when requiring CLJS or npm code. It is fine to use when requiring other JS files. I output an es module into a file foo.js and require it like: (ns my.ns (:require ["/foo" :as foo])) . From the text quoted above shouldn’t this be fine?#2022-06-1418:31thhellerI do not recommend including regular typescript code this way#2022-06-1418:32thhellerand what do you mean by storybook? doesn't that have its own tooling and would require integrating the CLJS code in the JS code#2022-06-1418:32thhellerrather than the JS code in the CLJS?#2022-06-1418:32hanDerPederyes, storybook is not relevant here.#2022-06-1418:33hanDerPederi’m currently attempting to create a bundle using esbuild and including that. inspired by your usage of babel here: https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects#2022-06-1418:34hanDerPedernot sure if this is fruitful or not, any suggestions would be greatly appreciated.#2022-06-1418:36hanDerPedermy goal is to have a setup inspired by nolan’s talk ClojureScript in the Age of TypeScript. I.e. frontend guys writes react components in typescript on storybook which they enjoy because of intelli-sense. and us few that swear to clojure can tie it all together in a small reagent app#2022-06-1418:39thhellerok then I suggest the following route. you build all your TS/JS whatever code into a folder#2022-06-1418:39thhellersay packages/your-js-stuff#2022-06-1418:39thhellerthen in the shadow-cljs build config you set :js-options {:js-package-dirs ["packages" "node_modules"]}#2022-06-1418:40thhellerthen you just include (:require ["your-js-stuff" ...]) like any other npm package#2022-06-1418:40thhellerthe packages/your-js-stuff dir ideally also has a proper package.json#2022-06-1418:41thhellerbasically you build the JS stuff as an npm package, without actually needing to publish it to npm#2022-06-1418:42thhellerincluding it directly from the classpath I don't recommend since that gets different treatment and likely won't work without specific care#2022-06-1418:42hanDerPederthat sounds great, could you give me some pointers regarding build all your js code ? Could this be: 1. define an entrypoint 2. run it through esbuild?#2022-06-1418:43thhellerI don't know if it needs any building. you mentioned esbuild so I thought you had the JS build part figured out#2022-06-1418:44thhellershadow-cljs will minify it anyways so you don't need to actually build anything as long as its JS code#2022-06-1418:44hanDerPederfar from it 🙂 learning though, but it’s a steep climb#2022-06-1418:44thhellerts/jsx/etc you however need to build first#2022-06-1418:44hanDerPederok, so a .jsx file would be fine?#2022-06-1418:44thhellerno, see my sentence above 😛#2022-06-1418:45thhellersee the babel section in the docs. it used jsx as an example#2022-06-1418:46hanDerPeder:thumbsup: thanks, I’ll give it a stab#2022-06-1419:16hanDerPederprobably unsurprising to you, but this worked with a trivial react component. thanks a lot!#2022-06-1415:57henryw374hello. an FYI for ppl using devcards. I found that upgrading shadow to 2.19.3 my previously working devcards setup had a couple of problems. I have some initial workarounds I wrote up here: https://github.com/jacekschae/shadow-cljs-devcards/issues/1#2022-06-1418:05yedianyone using jspdf with shadow-cljs? I’m seeing this build failure after npm installing it. Seems that the closure compiler isn’t a fan of jsPDF’s minifier?
[:app] Build failure:
Closure compilation failed with 1 errors
--- node_modules/jsPDF/dist/jspdf.es.min.js:10686
Block-scoped variable Vt declared more than once. First occurrence: node_modules/jsPDF/dist/jspdf.es.min.js:9530:13
#2022-06-1418:19thhellerhmm yeah I've seen those errors on occasion#2022-06-1418:20thhellernever can tell if they are actual legit errors or the closure compiler just parsing things wrong#2022-06-1418:20thhellerunfortunately nothing I can do from the shadow-cljs side of things#2022-06-1418:21thhelleryou can try the non-minified version by requiring "jspdf/dist/jspdf.es.js" instead of just jspdf#2022-06-1418:22thhellershadow-cljs will minify it anyways so nothing lost#2022-06-1418:25yediseems like the issue is with how jspdf packages itself and not just its minifier
[BABEL] Note: The code generator has deoptimised the styling of /Users/yedi/Documents/workspace/mobot/mobot-web/node_modules/jspdf/dist/jspdf.es.js as it exceeds the max of 500KB.
[:app] Build failure:
Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.es.js:3834
Block-scoped variable ga declared more than once. First occurrence: node_modules/jspdf/dist/jspdf.es.js:3834:4095
#2022-06-1418:28yedii wonder if it makes sense to use the cljsjs jspdf artifact if requiring it through npm doesn’t work… though i can’t imagine noone is using jspdf with shadow-cljs#2022-06-1418:28thhelleryou can also try the jspdf.umd.js file#2022-06-1418:29thhelleryou can use the cdn artifact#2022-06-1418:29thhellercljsjs is not supported so that won't work#2022-06-1418:34yedihm new build failure with umd
[:app] Compiling ...
[2022-06-14 14:33:09.670 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/jspdf/dist/jspdf.umd.js", :requires [{:line 15743, :column 14} {:line 15777, :column 14} {:line 25168, :column 14}]}
[:app] Build failure:
The required JS dependency "worker_threads" is not available, it was required by "node_modules/jspdf/dist/jspdf.umd.js".
#2022-06-1418:41thhellerhmm yeah thats not any better. you can set :js-options {:resolve {"worker_threads" false}} in your build config#2022-06-1420:30yedino luck, we’re back to the ga issue
[2022-06-14 15:36:04.439 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/jspdf/dist/jspdf.umd.js", :requires [{:line 15743, :column 14} {:line 15777, :column 14} {:line 25168, :column 14}]}
[:app] Build failure:
Closure compilation failed with 1 errors
--- node_modules/jspdf/dist/jspdf.umd.js:23062
Block-scoped variable ga declared more than once. First occurrence: node_modules/jspdf/dist/jspdf.umd.js:21353:15
#2022-06-1418:41thhellermaybe that helps#2022-06-1420:00hanDerPedernot sure if this is relevant to shadow but I’m trying to require a module i’ve created:
// src/stack.jsx
import * as React from "react";
import Button from "@mui/material/Button";
function stack_default() {
  return /* @__PURE__ */ React.createElement(Button, {
    variant: "contained"
  }, "Hello World");
}
export {
  stack_default as stack
};
and render it using reagent:
(ns 
  (:require
   [reagent.core :as r]
   [reagent.dom :as rdom]
   ["components" :as c]))

(let [elem (.getElementById js/document "app")]
    (rdom/render [:f> c/stack] elem))
it compiles fine but blows up with a lot of errors, notably: • Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. • Uncaught TypeError: dispatcher is null • The above error occurred in the <ForwardRef> component: anybody seem something similar to this?
#2022-06-1420:05hanDerPederthis works though, which I don’t understand:
(ns 
  (:require
   [reagent.core :as r]
   [reagent.dom :as rdom]
   ["@mui/material" :as mui]))
(let [elem (.getElementById js/document "app")]
  (rdom/render [:> mui/Button {:variant "contained"} "Hello World"] elem))
#2022-06-1420:16hanDerPederadding :entry-keys ["module" "browser" "main"] seems to have fixed it :thumbsup:#2022-06-1420:29hanDerPederno, still issues 😕 I have the following layout:
src/ <- on classpath
packages/foo <- a npm package
packages/foo/dist/index.js <- file I want
packages/foo/node_modules <- foo's dependencies
foo’s package.json has:
{
  ...
  "module": "dist/index.js",
  ...
}
shadow-cljs.edn:
{:dependencies
 [[reagent "1.1.1"]]

 :source-paths
 ["src"]

 :dev-http {8080 {:root "public"}},
 :builds
 {:app {:target :browser
        :output-dir "public/js"
        :asset-path "/js"
        :js-options {:js-package-dirs ["packages" "node_modules"]
                     :entry-keys ["module" "browser" "main"]}
        :modules {:main {:entries []}}}}}
seems shadow runs code from foo/node_modules. what i’m trying to say is: 1. look in packages before node_modules, and 2. try to import as es module first anybody know how to achieve this?
#2022-06-1420:48hanDerPederI think there’s an issue with js-package-dirs being searched recursively, so my js module gets react from packages/foo/node_modules while reagent gets it from node_modules#2022-06-1423:44lilactownwhy do you have nested node_modules?#2022-06-1506:12hanDerPederpackages/foo is a react components library written in typescript, developed with storybook.#2022-06-1506:46thhellerit shouldn't have any node_modules at all though. it should just be the output files of your JS build and a package.json#2022-06-1506:46thhellernothing else#2022-06-1506:46thhellercause yes, otherwise it'll follow the node resolve rules and use nested packages if present#2022-06-1506:51hanDerPederUnderstood. Was hoping to be able to develop in packages/foo. What if the resolver excluded peer and dev dependencies found? Think that would work for this case.#2022-06-1506:52thhelleryou can develop whereever you want#2022-06-1506:53thhellerthe point is having the build output go into a dedicated directory#2022-06-1506:53thhellerand no I'm not changing the resolver rules in any way#2022-06-1506:54hanDerPeder😁 worth a shot. thanks for your input on this.#2022-06-1506:54thhellerjust have the package build into packages/foo/out/foo/index.js or something#2022-06-1506:55thhellerand then use packages/foo/out#2022-06-1506:55thhelleror just symlink it#2022-06-1506:55thhellerthere is also :js-options {:allow-nested-packages false} but I strongly recommend not setting it#2022-06-1506:56thhellerit is very likely that you actually want nested packages#2022-06-1506:57thhellerin your main project you can also just npm install ./packages/foo I believe. which would take care of copying stuff over to the local node_modules. no need to :js-package-dirs then#2022-06-1506:57hanDerPederNo. At least by default it symlinks, so same problem.#2022-06-1506:58thhellerthen in the package you can npm package or whatever the command is and get a .tgz file which you can then install#2022-06-1506:58hanDerPederBut your former suggestion sounds good. Do i need to generate a package.json in out/foo?#2022-06-1506:59thhelleryou don't need it at all if you just generate a out/foo/index.js#2022-06-1506:59thhellerbut I still recommend creating one. "how" is up to you.#2022-06-1506:59thhellercould just always have it there manually written and generate into a dist folder like you had#2022-06-1507:00hanDerPederOk, why?#2022-06-1507:01hanDerPederAsking because im sure ill get the question 😄#2022-06-1507:04thhellerwhy what?#2022-06-1507:06hanDerPederInclude a package.json file in out/foo. Seems it's not needed. Future proofing?#2022-06-1507:08thhellerit is used for stuff like build reports#2022-06-1507:09thhellerbasically it is looked for first#2022-06-1507:09thhellersince npm packages are supposed to have it#2022-06-1507:09thhellerso without it resolve is missing an important piece and falling back to index.js is just the last looked at option#2022-06-1507:18hanDerPederMakes sense. Again, thank you for the guidance.#2022-06-1508:43pezIs there a way to configure shadow-cljs so that I can use deps.edn with different aliases depending on build? I want to include a :dev alias only in development, and not when building a release build.#2022-06-1517:25thhellerthis is not necessary. having extra stuff on the classpath doesn't matter. the build decides what is used, not the classpath#2022-06-1517:25thhellerso unless you specifically require something it won't be included in the build#2022-06-1517:25thhellerand no, there is no support for build specific aliases because of that#2022-06-1517:29pezSounds great. Thanks!#2022-06-1517:30thhelleras always you should verify what ends up in your builds with a build report 😉#2022-06-1511:23JenHi, I'm a beginner and I'm trying to use react-spline (https://github.com/splinetool/react-spline) in a new Reagent app. But when I import it like this: ["@splinetool/react-spline" :as Spline] I get the attached error. Any ideas what causes this?#2022-06-1517:22thheller@dev900 dunno what that is. I can reproduce it though. It is an error in the Closure Compiler though, so not much I can do about that from the shadow-cljs side of things#2022-06-1517:24thhellerseems like it might be this https://github.com/google/closure-compiler/issues/3593#2022-06-1517:42Jen@thheller thanks so much for checking 🙂 That's unfortunate. I guess I'm going back to Nextjs for this project 😢#2022-06-1517:44thhelleryou can use webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-06-1517:44thhellerthat probably doesn't have that issue#2022-06-1603:39shaunlebronCan I get help importing react-virtualized-auto-sizer? https://github.com/bvaughn/react-virtualized-auto-sizer AutoSizer is null when importing with: ["react-virtualized-auto-sizer$default" :as AutoSizer]#2022-06-1606:20thheller@shaunlebron from the example import {AutoSizer, List} from 'react-virtualized'; and see translation listing here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-06-1606:29thhelleror as usual try without the $default, also see my answer here on how to figure this out https://stackoverflow.com/a/72196457/8009006#2022-06-1614:18shaunlebronThanks! leaving out the $default returned what I needed I think since it evaluated to a function when logging it, but I gave up on getting it working in reagent#2022-06-1614:59Drew VerleeGiven shadow-cljsjs has a exportSybmol for Raven why would my shadow-cljs watch not be able to find it? The error i see
[:app] Build failure:
The required JS dependency "raven-js" is not available, it was required by "cljsjs/raven.cljs".
#2022-06-1615:00Drew Verleedo I also need to install raven-js via npm?#2022-06-1615:07Drew Verleeadding raven via yarn add raven-js causes the build not to fail because it's missing the js dep raven.#2022-06-1615:16Drew VerleeIf i add the library via yarn and it's declared in my shadow-cljs.edn file as cljsjs/somelib <some-version> how does the app know which version to use the package.json or the shadow-cljs.edn one? I feel like adding them to both must not be the correct way to handle this.#2022-06-1615:18Derekhttps://clojurians.slack.com/archives/C6N245JGG/p1655231359089449#2022-06-1615:26Drew Verlee@UPEKQ7589 https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2022-06-1615:27DerekAh my mistake shadow-cljsjs#2022-06-1615:53Drew VerleeIn a shadow project how would i go about resolving these requires?
[cljsjs.codemirror]
            [cljsjs.codemirror.mode.clojure]
            [cljsjs.codemirror.addon.edit.closebrackets]
            [cljsjs.codemirror.addon.edit.matchbrackets]
The first would be
(ns cljsjs.codemirror
  (:require ["codemirror" :as cm]))

(js/goog.exportSymbol "CodeMirror" cm)
Is the next one then
(ns cljsjs.codemirror.mode.clojure
  (:require ["codemirror/mode/clojure" :as cm]))

;; what would go here?
(js/goog.exportSymbol "CodeMirror" cm)
It's not clear to me in the namespace that uses the functionality how things are used there is just one js/CodeMirror so i assume my guess above is wrong and i'm supposed to somehow shove all the functions into that symbol. Maybe through js/goog.object.set ?
#2022-06-1615:55Drew Verleeerr maybe i can just create a deps file with this boot task? https://github.com/cljsjs/packages/blob/master/codemirror/build.boot#2022-06-1615:56dpsuttoni’ve got a demo repo using codemirror and shadow-cljs if that is helpful to you: https://github.com/dpsutton/field-editor#2022-06-1615:57Drew Verleei get a 404 with that link#2022-06-1615:58dpsuttonit was private. try now#2022-06-1615:59Drew Verleetyty#2022-06-1615:59dpsuttonclone it and i’m gonna set it private again#2022-06-1616:00Drew Verleedone#2022-06-1618:17thhellerI'm also using codemirror here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/components/code_editor.cljs#L3-L5#2022-06-1618:47Drew VerleeThanks I'll take a look!#2022-06-1616:50thheller@drewverlee if you are controlling the requires you should just include npm packages directly and not use the cljsjs "bridges". they are really only provided for cases where you can't change them because some library uses them#2022-06-1715:47Drew Verleethanks. that makes sense.#2022-06-1715:51Drew Verleeif there is a clj reader conditional on the path will shadow evaluate it? it seems like the answer is yes. e.g some .cljc file with (defn foo [] #?(:clj .... shadow watch is going to read the :clj text.#2022-06-1715:52thheller@drewverlee I don't understand the question? of course it is going to read it. it won't use it though unless in macro context?#2022-06-1715:57Drew Verleewhat's happening is that the :clj reader conditional requires a dependency that's only used for clj. So the shadow-cljs.edn file has to accumulate these clj deps or throw an error if i forgot to include it. The clj deps won't effect the build javascript target, but i'm contemplating if i should structure the dependencies differently. I'll have to move the cljc dependencies to their own project outside shadow so they can be used by the server. At the moment i just copied the logic over. I'm trying to convert a boot project to shadow and it has a large .cljc util namespace.#2022-06-1715:58thhellerI assume you are referring to the alias missing? so it fails to read? otherwise the lack of dependencies shouldn't matter at all? unless you :require-macros that namespace it won't actually be loaded or evaluated?#2022-06-1715:59thhellerbut if you have (:require [some.thing :as x]) in the :clj branch#2022-06-1715:59thhellerand then later x/whatever in the :clj branch again that can't be read by the reader if that alias doesn't exist in cljs too#2022-06-1716:00thhellerotherwise I'm not sure what the problem is?#2022-06-1716:01Drew VerleeThe cljs code pulls in functions via :require-macros, then as i understand it, it goes to read the :clj branch as well and is like "you don't have that dependency" because i didn't port the clj library because it felt weird (i didn't realize i had to) to move that into a shadow project. Something like org.clojure/data.csv.#2022-06-1716:01thhellerthe cljs code can't pull in functions via :require-macros. only macros?#2022-06-1716:02thhellerbut yes, :require-macros will cause the namespace to be evaluated by clojure. and complain about missing dependencies.#2022-06-1716:02thhellerand it is loaded as a regular clojure namespace, nothing shadow related at all in that case#2022-06-1716:05Drew VerleeThat makes sense. I'll think about this a minute and see if i can come up with something or a better question 🙂#2022-06-1802:20Alys BrooksWorking on adding shadow-cljs to a project, and when I open a REPL after adding shadow-cljs to the deps, it's complaining about not being able to find cider/piggieback, (a requirement of our REPL entry point function). shadow-cljs also has a dependency on cider/piggieback, but it's the same version, so I can't see why that would make a difference.#2022-06-1802:20Alys BrooksMaybe this is a question for #clojure though?#2022-06-1802:20pinkfrogFor hot loading on reloading dependent namespaces: https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#:~:text=If%20example.app%20wasn%E2%80%99t%20automatically%20recompiled%20together%20with%20example.util%20you%20would%20not%20get%20a%20proper%20warning%20that%20example.util/foo%20no%20longer%20exist. It seems in either the case the warning will not show because the way namespace reloading does not remove existing definitions.#2022-06-1802:26Alys BrooksSorry, was that in response to me? I don't think that's related because it's not a ClojureScript REPL where I'm encountering the issue.#2022-06-1806:00pinkfrogSorry that was another question. Glad you solved your problem.#2022-06-1802:52Alys BrooksAnyway, fixed my issue by increasing the ClojureScript version.#2022-06-1806:52thheller@i the blog post is referring to the compiler warning get. the runtime environment is irrelevant for that, but yes existing definitions in the runtime are not removed. the next sentence even mentions that?#2022-06-1809:24pinkfrogSo what’s the purpose of loading dependent namespaces. Solely for that warning?#2022-06-1809:32thhellerloading has nothing to do with it? I'm not sure what you are actually asking?#2022-06-1809:32thhellerit recompiles the dependent namespaces for the potential warnings yes. as explained in the blog post#2022-06-1809:37pinkfrogI was saying the only benefit of loading dependent namespace is for the warning. I cannot see other benefits.#2022-06-1809:38thhellerplease be precise with the words you are using.#2022-06-1809:38thhellercompiling dependent namespaces. not loading.#2022-06-1809:39thhellerand yes, that is only done for the warnings. no other reason. but compiling produces the warnings. not loading them.#2022-06-1809:41pinkfrogAh. I didn’t know it. Turns out only the modified namespace will be loaded. Extra question, since the dependent namespace is not changed. So when compiling again on it, how will do with the compiled output, just ignore it?#2022-06-1809:41pinkfrogcompiled output js file#2022-06-1809:43thheller"not changed" is a kind of difficult subject to figure out. so it is loaded along with the modified namespace#2022-06-1809:45pinkfrog> compiling dependent namespaces. not loading. So the dependent namespace was loaded eventually? I thought you were saying its only compiled but not loaded (evaluated) at all.#2022-06-1809:47thhellerno, you asked about warnings. I was emphasizing that loading does not produce the warnings, compilation does. after compilation they are loaded yes#2022-06-1809:50pinkfrogRight. That makes sense.#2022-06-1907:54tianshuI think I run into an issue that :node reader condition doesn't work.#2022-06-1907:55tianshuThe code is quite simple
#?(:node
   (println "node")
   :cljs
   (println "cljs"))
Even with :node-script target, it still printed "cljs".
#2022-06-1907:56tianshuSorry, I guess I missed the
{:reader-features #{:node}}
#2022-06-2018:20isakI've been using a flush hook like this:
(defn flush-hook
  {:shadow.build/stage :flush}
  [build-state & args]
  (when (= :release (:shadow.build/mode build-state))
    ;; My logic
    )
  build-state)
Lately I see that it is getting called both with my normal build names (:shadow.build/build-id build-state), and with '-release-snapshot' appended to them. Is that new? What is that for?
#2022-06-2019:19hanDerPederwhen building release artifacts on something like github actions. is it a good idea to cache .shadow-cljs? or will that just bite me in the ass at some point?#2022-06-2019:21thheller@isak hmm I guess I didn't consider that. build reports just re-use the original build configs. I guess it should unset the build-hooks#2022-06-2019:22thheller@peder.refsnes the intention is to maintain the cache (ie. .shadow-cljs) yes. it invalidates itself if something changes#2022-06-2020:57CarnunMPHellooo, Happy Monday! Ever since switching to a branch with some version bumps (`deps.edn` and package.json) I've been getting a bizarre build error running shadow-cljs ... watch app—or shadow-cljs ... server then :Connecting (with https://github.com/tpope/vim-fireplace/blob/b6bef833b56632df917bcf33bc50b8a5d1e26139/doc/fireplace.txt#L19) and :CljEvaling (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :app) (shadow/nrepl-select :app)): see below ⬇️ I've tried a https://stackoverflow.com/a/70490790 of https://docs.npmjs.com/cli/v8/commands/npm-ci, up to and including updating my global shadow-cljs to the latest version, and using npx shadow-cljs... and fiddling with the :output-feature-set compiler option... and https://github.com/angular/clutz/issues/490#issuecomment-292236507 😅 ... and still nada. Seems like people have https://clojurians-log.clojureverse.org/shadow-cljs/2020-06-02 about similar https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-25 before... and it was some kinda problem in/with the closure compiler? :thinking_face: Fwiw, this is the thing called in the last (i.e. most recent) line of the stacktrace below, afaict: https://github.com/google/closure-compiler/blob/dfa3226ec7b5197b2a1c11b4f0f4a3ee147919f4/src/com/google/javascript/jscomp/parsing/ParserRunner.java#L118 And this is the file where the stack-blowing is happening: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/IRFactory.java The error:
$ shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d com.billpiel/sayid:0.1.0 -d refactor-nrepl:3.0.0 -d cider/cider-nrepl:0.27.2 watch app
shadow-cljs - config: /home/carnun/Documents/Nette/nette/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.19.3 running at 
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
  /home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js

it was required from
  /home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/index.js

Errors encountered while trying to parse file
  /home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}

RuntimeException: Exception parsing "/home/carnun/Documents/Nette/nette/node_modules/highlight.js/lib/languages/gml.js"
	com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:148)
	com.google.javascript.jscomp.JsAst.parse (JsAst.java:156)
	com.google.javascript.jscomp.JsAst.getAstRoot (JsAst.java:62)
	shadow.build.closure.JsInspector.getFileInfo (JsInspector.java:180)
	shadow.build.closure.JsInspector.getFileInfoMap (JsInspector.java:194)
	shadow.build.npm/get-file-info*/fn--12316 (npm.clj:452)
	shadow.build.npm/get-file-info* (npm.clj:451)
	shadow.build.npm/get-file-info* (npm.clj:401)
	shadow.build.npm/get-file-info (npm.clj:512)
	shadow.build.npm/get-file-info (npm.clj:509)
	shadow.build.npm/find-resource-in-package (npm.clj:726)
	shadow.build.npm/find-resource-in-package (npm.clj:686)
	shadow.build.npm/find-resource (npm.clj:776)
	shadow.build.npm/find-resource (npm.clj:739)
	shadow.build.resolve/find-npm-resource (resolve.clj:122)
	shadow.build.resolve/find-npm-resource (resolve.clj:93)
	shadow.build.resolve/eval14445/fn--14448 (resolve.clj:262)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:80)
	shadow.build.resolve/find-resource-for-string (resolve.clj:69)
	shadow.build.resolve/resolve-string-require (resolve.clj:453)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:669)
	shadow.build.resolve/resolve-require (resolve.clj:662)
	shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-require (resolve.clj:662)
	shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-require (resolve.clj:662)
	shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-require (resolve.clj:662)
	shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:656)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
	shadow.build.resolve/resolve-require (resolve.clj:666)
	shadow.build.resolve/resolve-require (resolve.clj:662)
	shadow.build.resolve/resolve-deps/fn--14394 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:45)
	shadow.cljs.util/reduce-> (util.clj:44)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
Caused by:
StackOverflowError: 
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1743)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:2780)
	com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:737)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1748)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process (IRFactory.java:2780)
	com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:737)
	...
Any pointers would be much appreciated! 😄
#2022-06-2020:59thhellersee https://github.com/google/closure-compiler/issues/3945#issuecomment-1132625831#2022-06-2021:00thhellerdunno how you are using highlight.js. if its via re-frame-10x you should upgrade that#2022-06-2021:00thhelleralso https://github.com/thheller/shadow-cljs/issues/1015#2022-06-2021:01CarnunMPOh wow... so throwing (even) more stack at it really is the answer? 🙃#2022-06-2021:02thhellerwell imho the answer is not including these files in the first place. I doubt very much you need gml support? whatever that even is 😛#2022-06-2021:03CarnunMPre-frame-10x aye... and lowlight, via https://tiptap.dev iirc#2022-06-2021:04CarnunMPGameMaker Language 😛 just one of many that highlight.js ships with in its node_modules#2022-06-2021:05thhellerwell its fine to include it if you actually need it#2022-06-2021:05thhellerincluding it when you don't need it just makes everything larger and slower (to build, load, etc)#2022-06-2021:06CarnunMPagreed! but it's very likely a keeper (unfortunately?)#2022-06-2021:06thhellerhmm?#2022-06-2021:06CarnunMPI just mean I agree in general that larger and slower is worse 😛#2022-06-2021:09thhellerI mean another option is just editing this file in your node_modules folder#2022-06-2021:09thhellerhttps://unpkg.com/highlight.js@11.5.1/lib/index.js#2022-06-2021:09thhellerjust remove all the registerLanguage calls you don't need#2022-06-2021:09thhellerbit manual but might be worth#2022-06-2021:14CarnunMPThrowing more more stack at it seemed to do the trick. Thanks @thheller! :))#2022-06-2021:18CarnunMP> I mean another option is just editing this file in your node_modules folder Hmm... would this mean checking that into source control? deep_thinking#2022-06-2021:20thhellerwell I would just automate the edit in some way so it always runs after the package is installed#2022-06-2021:21thhellerI mean all of this only applies if you don't control how highlight.js is used yourself#2022-06-2021:21thhellerbut I assume that is the case here#2022-06-2021:21thhelleryou can also use :js-options {:resolve {"highlight.js" {:target :npm :require "highlight.js/core"}}#2022-06-2021:22thhellerthat would only give you the basic highlight.js#2022-06-2021:22thhelleryou can then add all the languages you actually need manually in your code somewhere#2022-06-2021:22thhelleror just live with the high stack size#2022-06-2021:24CarnunMPReally appreciate these ideas. I'll have to chew them over tomorrow. Thanks again!#2022-06-2021:34Tiago Dall'Ocapossible bug report (more in the thread)#2022-06-2021:34Tiago Dall'Ocadeps.edn
{:paths ["src" "tests"]
 :deps {
        ;; ...
 }
 :aliases
 {:shadow-cljs
  {:extra-deps {thheller/shadow-cljs {:mvn/version "2.19.3"}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
#2022-06-2021:36Tiago Dall'Ocashadow-cljs.edn
{:deps true

 :builds
 {;; ...

  :prod
  {:target :npm-module
   :output-dir "dist"
   ;; ...
   }}}
#2022-06-2021:36Tiago Dall'Ocarunning clj -M:shadow-cljs compile prod works as expected#2022-06-2021:37Tiago Dall'Ocashadow-cljs compile prod, on the other hand, outputs
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

Full report at:
/tmp/clojure-15396811791392763534.edn
#2022-06-2021:38Tiago Dall'OcaAdding thheller/shadow-cljs {:mvn/version "2.19.3"} to :deps solves it#2022-06-2021:38thhellernot a bug. working as expected.#2022-06-2021:38Tiago Dall'OcaIt seems to me that shadow-cljs is not calling clj with the right alias#2022-06-2021:39thhellerwith :deps true you tell shadow-cljs to use no aliases#2022-06-2021:39thhellerso it won't have shadow-cljs available when starting#2022-06-2021:39thhellerso you use :deps {:aliases [:shadow-cljs]} instead to activate it#2022-06-2021:39Tiago Dall'Ocaaaaaah#2022-06-2021:39Tiago Dall'Ocagreat!#2022-06-2021:39thhellerbut need to take out :main-opts since that is redundant#2022-06-2021:39Tiago Dall'OcaI must have missed it in the user guide#2022-06-2021:40Tiago Dall'Ocathanks!#2022-06-2023:54Drew Verleewill shadow use a cljsjs dependency? [edit] nope. clearly not. e.g :dependencies [[cljsjs/something "xyz version" ]] or is it ignored and i need to use npm install something and create a cljsjs shim as per the migration docs. I'm asking because i got errors about missing libs unless i did an npm install but my worry is that the cljsjs wrapper for some libs is doing more then a 1 to 1 translation to cljs. I don't have a specific example of this happening but it would be nice to be aware i need to tackle it.#2022-06-2101:22sansaripshadow-cljs does not support cljsjs packages 🙅 src: https://clojurians.slack.com/archives/C6N245JGG/p1655013153124169#2022-06-2102:52Drew Verleeso yea, it just ignores them. That's reasonable, i just had magically hoping that the migration strategy was accounting for them somehow. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2022-06-2105:33thhelleras I said before. if you are the one requiring cljsjs packages you should change that to use npm packages directly.#2022-06-2105:34thhellermost popular libraries that use cljsjs packages have been updated to also declare :npm-deps so the npm packages should be isntalled and used automatically#2022-06-2105:34thhellersome are not so you need to install manually#2022-06-2105:39thhellernote that using npm packages directly is also what you need to be doing for :target :bundle and most cljsjs packages have also been updated to support that.#2022-06-2110:22Drew VerleeThanks theller.#2022-06-2109:41simongrayquick question about inferring externs. The documentation says: > No hint required, externs inferred automatically >
(js/Some.Thing.coolFunction)
but does this also extend to objects create via js/f calls? e.g. in (let [d (js/Date. x)] (.toLocaleDateString d)) would d be correctly inferred to be a js object in the let clause?
#2022-06-2109:48thhelleryes, but only in the scope of the let#2022-06-2109:51simongraythank you!#2022-06-2109:57simongrayany more general advice on how to find places where externs are needed? :S the advanced compilation output is difficult to get information out of#2022-06-2110:00simongrayI’m making externs for manually added files, this stuff doesn’t exist on NPM#2022-06-2110:02thhellerwell, thats what externs inference warnings are for?#2022-06-2110:02thhelleralso what does "manually added files" mean? dunno what npm has to do with this?#2022-06-2110:06simongrayno warnings#2022-06-2110:06simongrayI have a bunch of JS files from an ancient JS lib and I have a Clojure namespace that is wrapping parts of them#2022-06-2110:08simongrayI get runtime errors such as
main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:145 TypeError: f.Sf is not a function
    at c.<anonymous> (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:2192:336)
    at c.componentDidMount (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:1647:332)
    at uj (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:147:464)
    at Ej (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:183:21)
    at ea.unstable_runWithPriority (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:27:21)
    at Ac (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:80:117)
    at bd (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:176:83)
    at Fg (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:168:106)
    at main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:80:407
    at ea.unstable_runWithPriority (main.0943529B7909B0E1E5BADC7C3B265449.js?-2052149777:27:21)
so I get the general area and I have tried annotating js/BlabBla where needed, but to no avail.
#2022-06-2110:11simongrayI guess I’m just gonna keep trying things out, but it’s a shame that this externs inference step seems to revert my workflow to “fix bugs, recompile, repeat ad infinitum” like in the old days :P#2022-06-2110:12thhellerto debug this use shadow-cljs release app --pseudo-names#2022-06-2110:12thhellerthat will at least make this more debuggable TypeError: f.Sf is not a function#2022-06-2110:13thhellerI'd be curios to see the code snippet causing this#2022-06-2110:13thhellermaybe its just a case missed by externs inference#2022-06-2110:14thhellerbut you didn't really answer my question. "I have a bunch of JS files from an ancient JS lib". how are you including them?#2022-06-2110:14thhellerjust entirely separately outside of the shadow-cljs build? or included in the build somehow? depending on how they are included affects how and what externs are needed#2022-06-2110:20simongraythe only way I know how: using <script> in <head>#2022-06-2110:21thhellerok, thats fine. so all access is via js/...#2022-06-2110:21simongrayyes#2022-06-2110:21simongrayand (.methodName …)#2022-06-2110:22thhellerthose should be covered by externs inference#2022-06-2110:23simongrayI guess, but I guess some are missed, likely by my own efforts. Gonna try your suggestion and add pseduo-names#2022-06-2110:25thhellershould be easy to identify with pseudo names enabled. it'll just rename .methodName properties to .$methodName$ or so#2022-06-2110:26thhellerstill renaming it, but with a recognizable name#2022-06-2110:27simongrayyes, it’s already helping me locate the issues. Thanks a lot!#2022-06-2110:27simongrayJS is confusing…#2022-06-2111:20simongraycan I annotate using ^js/Timeline._Impl (Timeline._Impl.prototype is where the troublesome methods are defined in the JS files) or do I need to use ^js only like is used in the shadow-cljs documentation?#2022-06-2112:00thheller@simongray you can annotate like that but the end result is exactly the same as just ^js. nothing else is gained. it doesn't magically gain knowledge of more properties or something#2022-06-2112:01thhellerdo you have examples of where you need to add typehints but don't get warnings?#2022-06-2112:06simongrayhttps://github.com/kuhumcst/glossematics/blob/master/src/dk/cst/glossematics/frontend/timeline_widget.cljs#L241-L255#2022-06-2112:06simongraythis namespace#2022-06-2112:06simongrayI’ve tried adding ^js everywhere it makes sense, but it doesn’t seem to do anything#2022-06-2112:07simongrayin this case#2022-06-2112:13thhellerI personally prefer adding the ^js hint on declaration#2022-06-2112:13thhellerbut you should be getting inference warnings for all of those cases?#2022-06-2112:13thhellerwhich shadow-cljs version do you use? or did you explicitly turn it off?#2022-06-2112:14thhellermeaning tl (draw-timeline! new-state) becomes ^js tl (draw-timeline! new-state)#2022-06-2112:14thheller(when-let [tl* (and tl @tl)] (when-let [^js tl* (and tl @tl)]#2022-06-2112:14thhellerand so on#2022-06-2112:22simongrayI don’t think I’ve turned it off. I do get a warning for something in tick-rc6, but that doesn’t seem to affect the project.#2022-06-2112:23thhellerhmm yeah I just checked#2022-06-2112:23thhellerthere should definitely be warnings but they are missing somehow#2022-06-2112:23simongrayodd#2022-06-2112:25thhellerand even though you are adding js hints the externs are still missing#2022-06-2112:29simongrayyup#2022-06-2112:30simongraytried pretty much adding every type of extern everywhere I could#2022-06-2112:46thhellerhmm yeah something is definitely off in this project. If I just add
(defn yo [x]
  (.whyUNOINFER x))
anywhere I don't get any inference warnings. on all my other projects I do
#2022-06-2112:46thhellerso not sure what is going on 😛#2022-06-2112:47thhellerhmm removing :compiler-options {:data-readers true} turns them back on#2022-06-2112:47thhellernot sure why though#2022-06-2112:50simongrayaha#2022-06-2112:51simongraywell, the issue surfaced when I recently updated the deps and I think I had to add that line due to some conflict between shadow-cljs and the latest version of tick#2022-06-2112:52thhellerI don't get why that even affects inference in any way. its not even remotely close code wise#2022-06-2112:52thhellermust be something weird or obvious 😉#2022-06-2112:52simongrayhah, yeah that does seem quite strange#2022-06-2112:55simongraywell, it’s only weird until it’s completely obvious 😛#2022-06-2113:00thhellerdoh, yeah found it#2022-06-2113:03simongrayAre you saying that for once it wasn’t myself who fucked up, but it was actually a bug in shadow-cljs??#2022-06-2113:03thhelleryep#2022-06-2113:03simongrayThat is a first. Well, glad to be of service :P#2022-06-2113:21thheller@simongray try 2.19.4. at the very least you should be getting inference warnings again. and the tags should be respected and actually generate externs.#2022-06-2113:30simongrayI think that did the trick.#2022-06-2113:30simongrayThank you!#2022-06-2118:05Alys BrooksWhen the manual says shadow-cljs doesn't support CLJSJS "at all", does that mean it doesn't support dependencies that themselves rely on CLJSJS? Or does shadow-cljsjs take care of that?#2022-06-2118:09Alys BrooksNever mind, reading the section again, it appears shadow-cljsjs does take care of that.#2022-06-2118:15thhelleryes, that is the intent#2022-06-2118:31Alys BrooksThanks!#2022-06-2118:35Alys BrooksIf I want to add a file to shadow-cljsjs, is adding a dependency to a local copy and an exclusion enough or does shadow-cljsjs do something special to pull in shadow-cljsjs?
thheller/shadow-cljsjs {:local/root "../../../shadow-cljsjs"} 
thheller/shadow-cljs {:mvn/version "2.11.23" :exclusions [thheller/shadow-cljsjs]  }
(Eventually I'll submit a PR but I want to get it working first)
#2022-06-2118:40Alys BrooksOkay, it appears that does work, I just forgot to replace the hyphen in my new file's name with an underscore.#2022-06-2119:32thheller@actuallyalys_slack you don't need to add files to shadow-cljsjs. just add the file to your own classpath (ie. one of your :paths)#2022-06-2121:24Drew Verleeif my shadow project has a .cljc file on the path that contains the expression (println "x") should i expect to see "x" my terminal when i watch the build?#2022-06-2121:25Drew VerleeI feel like the answer is defiantly yes, yet i feel like that more or less what i'm not seeing in my current project so i'm trying to sanity check some concepts....#2022-06-2121:29Drew Verleeif i put a clj or cljc file on shadows path, it reads it because it's compiling the cljs to js using clj (correct me if i'm wrong). So it should absolutely see that file, and execute any expressions in it.#2022-06-2121:55isakI think you'd need to require the namespace somewhere for that to be true, no?#2022-06-2121:57Drew VerleeIt is required. But yea, i assume so to.#2022-06-2121:58isakAh ok. Have you tried changing it to spit out a file or something instead? It could be something with the out being redirected or something. I would test something that won't be affected by that.#2022-06-2121:58thheller@U0DJ4T5U1 .cljc means nothing. the question you need to answer in which context the thing is eval'd#2022-06-2121:59thhellerwhen it is compiled as CLJS you will see the println when it is loaded in the JS runtime (eg. browser)#2022-06-2121:59thhellerwhen it is compiled in CLJ you will see it during compilation (although where is not entirely clear since it goes to *out*, which may not be where you are looking)#2022-06-2122:00thhellerit is only loaded in CLJ when required as a macro namespace, ie :require-macros#2022-06-2122:02Drew VerleeI'll check again, i don't see it in either context so i must have a path issue. I'll check what *out* is bound to. Thanks I'll check how it's loaded again to.#2022-06-2122:04thhellerI'd say your assumption of "definitely yes" seems wrong#2022-06-2122:04thhellersince regular CLJS compilation will not actually eval any CLJS code, it is just translated to JS#2022-06-2122:08thhelleras for *out* it defaults to wherever shadow-cljs was started. dunno how you are starting it#2022-06-2122:16Drew VerleeIt runs via my terminal with the cmd line shadow-cljs watch app. When it compiles (println "hello") into js won't that run when the browser gets the .js file and interprets it?#2022-06-2122:20thhelleryes it will. but those prints end up in the browser console not the terminal#2022-06-2122:31Drew VerleeYep, that's what i understand happens as well. Ty. In the morning this will all seem as clear as day I'm sure#2022-06-2212:50martinklepschWhen working with the node repl I occasionally get these logs from the server output. I think I’m evaluating something that fails but I’m not sure how to investigate, it just seems to kill the node repl process:
:shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1}
Looking for pointers to debug this 🙂
#2022-06-2213:39martinklepschSomehow this seems to vaguely correlate with warnings in the shadow compilation process :thinking_face:#2022-06-2213:41martinklepschAnd then it also seems as if — after the first REPL session crashes — the next one is started with slightly different settings, i.e. I’m getting an error (deep in library code) that I believe is linked to env vars that I’m not getting in the first REPL session#2022-06-2213:43martinklepschThis warning is also confusing me… there is a type hint but it seems like its not picked up?
40 |     (.. ^js client -tags (tagContact (clj->js {:contactId contact-id
-----------^--------------------------------------------------------------------
 Cannot infer target type in expression (. (. client -tags) (tagContact (clj->js {:contactId contact-id, :tagId (:id matching-tag)})))
#2022-06-2213:45martinklepschI now tried commenting out this line but the REPL still seems to pick up the old state of the file somehow#2022-06-2213:45martinklepschSorry for this very chaotic report to anyone who tries to follow along 😅#2022-06-2215:05martinklepschFound https://github.com/thheller/shadow-cljs/blob/b1d564f2987ee5ff281f8114f22644a2ab5f770e/src/main/shadow/cljs/devtools/server/repl_impl.clj#L451-L454 where ::node-repl-exit is used — would there be any way to log more information about the error? I’m just seeing the node repl process crash again and again and can’t really tell why…#2022-06-2217:32thhellerthere is no more info available. it just quits with exit code 1. I'm guessing you just have an uncaught exception? which in node means the process dies.#2022-06-2217:32thhellersee https://nodejs.org/api/process.html#event-uncaughtexception#2022-06-2217:33thhellerabout the typehint I believe .. looses typehints. I only use -> nowadays#2022-06-2217:42martinklepschcould shadow set up an exception handler for this type of thing (but still kill the process) so that some more info can be reported?#2022-06-2218:11thhellerwell for that I'd need to know what you are doing exactly#2022-06-2218:11thheller
cljs.user=> (js/setTimeout boom! 1)

C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623
  (let [e (js/Error. message)]
          ^
Error: boom
    at new cljs$core$ExceptionInfo (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623:11)
    at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
    at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11653:16)
    at cljs$core$ex_info (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
    at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
cljs.user=> shadow-cljs - #13 ready!
#2022-06-2218:11thhellerthis is an async uncaught exception in a regular shadow-cljs node-repl#2022-06-2218:11thhellerso every is reported and the runtime is restarted normally#2022-06-2218:11martinklepschah - i'm connected via nrepl and conjure (vim)#2022-06-2218:12thheller
(defn boom! [] (throw (ex-info "boom" {})))
=> #'cljs.user/boom!
(js/setTimeout boom! 1)

C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623
  (let [e (js/Error. message)]
          ^
Error: boom
    at new cljs$core$ExceptionInfo (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11623:11)
    at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
    at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11653:16)
    at cljs$core$ex_info (C:\Users\thheller\code\shadow-cljs\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\cljs\core.cljs:11650:1)
    at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
The previously used runtime disappeared. Will attempt to pick a new one when available but your state might be gone.
#2022-06-2218:12thhellerthats cursive nrepl#2022-06-2218:13thhellermaybe conjure is redirecting the output someplace or drops it or something?#2022-06-2218:14martinklepschand i have a slightly custom way of starting shadows node repl as well #2022-06-2218:15thhellerI don't think there is any setting that would control how this works so that shouldn't matter#2022-06-2218:15martinklepschyeah i guess it's maybe something between conjure and shadow#2022-06-2522:47OlicalHmm I'm not sure about the issue right now but might need an issue raise on conjure with as much context as you can so I can reproduce it and dig into it. I'm guessing there's either an uncaught error or I'm catching it and not responding in a good way (i.e. it looks like a fatal thing to me but I shouldn't treat it that way)#2022-06-2606:35thhellerFWIW shadow-cljs is sending the messages as :err. eg.
;; ----------------------------------------
;; -- FROM  :client
;; ----------------------------------------
{:code "(js/setTimeout boom! 1)",
 :id "93653b42-8d31-464a-894d-9083ec171c61",
 :op "eval",
 :session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}

;; ----------------------------------------
;; -- FROM  :target
;; ----------------------------------------
{:err "\n",
 :id "93653b42-8d31-464a-894d-9083ec171c61",
 :session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}

;; ----------------------------------------
;; -- FROM  :target
;; ----------------------------------------
{:err
 "C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11623\n  (let [e (js/Error. message)]\n          ^\n",
 :id "93653b42-8d31-464a-894d-9083ec171c61",
 :session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}

;; ----------------------------------------
;; -- FROM  :target
;; ----------------------------------------
{:err
 "Error: boom!\n    at new cljs$core$ExceptionInfo (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11623:11)\n    at Function.cljs.core.ex_info [as cljs$core$IFn$_invoke$arity$3] (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11650:1)\n    at Function.cljs.core/ex-info [as cljs$core$IFn$_invoke$arity$2] (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11653:16)\n    at cljs$core$ex_info (C:\\Users\\thheller\\code\\shadow-cljs\\.shadow-cljs\\builds\\node-repl\\dev\\out\\cljs-runtime\\cljs\\core.cljs:11650:1)\n    at Timeout.cljs$user$boom_BANG_ [as _onTimeout] (<eval>:3:25)\n    at listOnTimeout (internal/timers.js:554:17)\n    at processTimers (internal/timers.js:497:7)\n",
 :id "93653b42-8d31-464a-894d-9083ec171c61",
 :session "1b5a65b8-737e-4114-8f17-cd6c8c0bf121"}
#2022-06-2911:21martinklepschHm. So I tried playing around with this with a plain shadow node-repl and Conjure and that seems to work just fine. Unfortunately I’m not sure how to trigger the same error as before.#2022-06-2217:06Chris Ghello folks, question 🧵#2022-06-2217:07Chris Gmy team is attempting to leverage shadow-cljs to utilizing some npm packages from an internal resource, our app is compiling fine, but when i attempt to pull in the packaged lib as a dependency in a namespace i get an error:
Closure compilation failed with 8 errors
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: a
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: b
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: e
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: h
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: i
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: r
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: t
--- node_modules/@guaranteed-rate/shared-gr-react-components/dist/index.js:66
Illegal variable reference before declaration: w
im unsure if there's something wrong with the way we are attempting to call the package or if there is something wrong in the package itself
#2022-06-2217:08Chris Ghere's how im requiring the package
["@guaranteed-rate/shared-gr-react-components" :as shared-gr-react-components]
#2022-06-2217:35thhellerthis is a problem in the JS code. the closure compiler is sometimes a little picky about some code#2022-06-2217:35thhellermight be this https://github.com/google/closure-compiler/issues/2723#2022-06-2217:35thhellerunfortunately not much you can do except use webpack as described in this post https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-06-2217:40Chris Gokay so it seems to be in reference to this?
#2022-06-2218:07thhellerno, not at all#2022-06-2218:07thhellerthat is very much different#2022-06-2218:07thhellerI mean if you control the JS code you can try to identify what exactly it has issues with and avoid that pattern#2022-06-2218:08thhellermust be something uncommon anyways since this error is quite rare#2022-06-2218:08thhellerunfortunately it is deeply in the closure compiler internals, so I cannot do anything about it from the shadow-cljs side of things#2022-06-2218:08Chris Gi see okay, thanks for you input 🙂#2022-06-2312:46JAtkinsAny idea why the shadow status pages would be broken? I’ve seen Unknown, waiting for recompile. on the /build/xxx pages for the shadow server since at least release 2.15.2. I just tried upgrading to 2.19.4 today and still see the same page even if I cause the build to recompile by updating a watched file.#2022-06-2315:00thheller@jatkin the "unknown" state is shown when the UI is loaded after the build finished compiling. since it wasn't around to receive the build result. the next compilation should show the result. dunno why you have no buttons though?#2022-06-2413:50JAtkinsLike this#2022-06-2413:52JAtkinsYou can see in the middle a compiler error appear. But the shadow build page doesn’t react. It could be down to how I’m starting the server.
(shadow.cljs.devtools.server/start!)
(shadow.cljs.devtools.api/watch build-id)
(shadow.cljs.devtools.api/nrepl-select build-id)
(shadow.cljs.devtools.api/repl build-id)
#2022-06-2416:51thheller@jatkin this is an ancient version of shadow-cljs. the UI looks very different nowadays, so can't say what is going on. definitely try upgrading first. the starting is fine although api/nrepl-select and api/repl do the same thing. so calling both seems like a mistake.#2022-06-2315:00thhellerthere should be a force compile option#2022-06-2315:01thheller" still see the same page". that screenshot is not from the latest version?#2022-06-2315:30winsomeI'm trying to build a library that will be used from node, is there a way to include static assets in the library? I've currently got a (fs.readFileSync (str "resources/" filename)) call, but it's looking at the "resources" directory of the project where it's used, as opposed to the "resources" directory in the library itself.#2022-06-2315:30winsomeIs there a sort of io/resource equivalent in cljs land?#2022-06-2317:26thheller@winsome there is no io/resource equivalent since node doesn't have a classpath. but you control the library and the files that come with it. you can use the special js/__dirname to get the directory of the executing file. so just (path/resolve js/__dirname "foo.txt") would give you the full path in your library which you can then read#2022-06-2317:37thhellerhttps://github.com/thheller/shadow-cljs/blob/60d071ad968465ad69c2bef3ba64ff056ce09850/src/main/shadow/cljs/npm/cli.cljs#L118#2022-06-2317:38thhellerthis is the package https://github.com/thheller/shadow-cljs/tree/60d071ad968465ad69c2bef3ba64ff056ce09850/packages/shadow-cljs and this is the file it reads https://github.com/thheller/shadow-cljs/blob/60d071ad968465ad69c2bef3ba64ff056ce09850/packages/shadow-cljs/cli/default-config.edn
#2022-06-2317:38thhellerthe .js file is also in the cli folder. you can look at the node_modules/shadow-cljs package#2022-06-2318:23winsomeThanks, that's a promising approach. When I run (path/resolve js/__dirname) from the repl in my.namespace I get "/absolute/path/to/my/proj/root". However, when I wrap it in a function:
(defn read-resource [filename]
  (println (path/resolve js/__dirname)))
I get "/abolute/path/to/my/proj/root/.cljs_node_repl/.cljs_node_repl/my/namespace".
#2022-06-2318:34thhellerI guess you are not using shadow-cljs? js/__dirname yields the wrong folder given how the regular CLJS repls handle file loading#2022-06-2318:38winsomehmm, no, not for the library. I might re-evaluate that decision though if it enables this.#2022-06-2408:15AthanHi, I am a newcomer to Clojure ecosystem and this seems to be a favorite frustrating issue among users when someone tries to compile and run projects with shadow-cljs ======================================================= BTW: kudos to all contributors of the project, hot-reloading feature in development is really awesome ======================================================= shadow-cljs - Stale Output! Your loaded JS was not produced by the running shadow-cljs instance. Is the watch for this build running I am sharing some feedback on how you can reproduce this issue, download https://github.com/fulcrologic/fulcro.git repository, then make tests make dev shadow-cljs watch workspaces It compiled and ran the module (workspaces) successfully at http://localhost:9002 Then I stopped the worker, (worker shutdown) and I tried to compile and run another module shadow-cljs watch todomvc I got the same port 9002 for the web app, it started watching build :todomvc and the build completed successfully but When I tried to access the web URL, I got the previous project running and the red warning message informing me that this is a shadow-cljs - Stale Output! (see image attached) I tried to refresh the page on the browser, clear the browser cache, remove folder (`.shadow-cljs`) none of these worked as a solution. Therefore it seems there is a problem with the way things are configured and/or how shadow-cljs loads the generated JS code for the right module. This is tree structure under the js folder js ├── test ├── todomvc │ └── cljs-runtime └── workspaces └── cljs-runtime Each module generates a separate folder for JS, nevertheless with this https://gist.github.com/athanhat/ceaf406565013bd308395a5feea51c92#file-fulcro-shadow-cljs-edn it fails to redirect to the correct web app. I had also a look at shadow-cljs server, it displays two active http servers at 9001 and 9002, but none of these redirects to the active build todomvc the web page displays the workspaces cards app with the infamous red warning message Finally as a last resort I removed folder resources/public/js and I executed again shadow-cljs watch todomvc`` . That worked although I got an empty web page for this module (probably I have to run some other server... don't know...) OK I also had a quick look at your CLJS user guide, it seems that issue is not met anywhere in the manual. Perhaps it will help a lot if you add a section that explains how to avoid problems of this kind. It will also be good to suggest a better configuration, don't know, for fulcro project or projects with several modules in general.#2022-06-2409:13pieterbreed> Then I stopped the worker, (worker shutdown) ☝️ this With shadow-cljs watch ... the browser app only works while the worker is running.#2022-06-2409:16AthanYes I know, then I started again the worker with a different module, problem is that the worker doesn't clean previous state or redirect to the correct module.#2022-06-2409:26pieterbreedIn this case, I think it's because the resources/public/index.html only loads workspaces. https://github.com/fulcrologic/fulcro/blob/91fe23917d48eb7bfbe480eef2ed02ede3a4389b/resources/public/index.html#L17#2022-06-2409:29pieterbreedIf I'm not mistaken, regardless of which module you are watching, that is the index.html sent to the browser.#2022-06-2410:09AthanNice catch, thanks Pieter, that certainly helps. So is it the case that someone has to change JS script address inside index.htmlmanually to run a different module in the project ? Is there configuration options for multiple index.html files or a variable for the JS location ?#2022-06-2410:16pieterbreedSorry to be typical, but it depends. Eg Many deployed apps serve their index.html dynamically and know which js to include with backend logic. In this case, that specific index.html is loaded from the browser. For developer in dev environment doing watch this is probably ok(?) Also read about release build in the manual.#2022-06-2410:21AthanI see thanks...#2022-06-2519:26lilactown@U03ET6PDHCK I think you're supposed to go to the html for the build you're running#2022-06-2519:27lilactownyou can see how in the public folder, there is a todo.html which has a script tag for the todomvc/main.js file built by the :todomvc build#2022-06-2519:27lilactownso if you go to localhost:9002/todo.html you should see whatever output of the todo build is#2022-06-2519:29lilactownall of this is very project specific config, the way that fulcro has it setup here isn't really typical, but also isn't strange. it just requires knowledge that isn't documented in the repo#2022-06-2911:41AthanOh that is marvelous, thanks @U4YGF4NGM every little piece of information helps. I am bewildered with all these different project configurations in clojure(script) ecosystem.#2022-06-2912:01AthanIn the same project/module (todomvc) another challenge is how to start the server src/todomvc/fulcro_todomvc/server.clj . If I am right, I have to start a local clojure REPL (I am using IntelliJ IDE), load the server code and do
(http-server)
(web/start @server)
But I am getting this error cannot load server.clj file into the active REPL. It is not in scope for the module used to start the REPL I guess this has to do with REPL configuration inside IntelliJ IDE, any suggestions to move on ? BTW: Shouldn't server configured to start automatically with shadow-cljs, is there a way to do this ? Any relevant section in configuration files deps, shadow-cljs etc ?
#2022-06-2912:54AthanAh, I think I found how to sort this out, in IntelliJ REPL Server configuration I chose to run with Deps and I also selected Clojure Deps Projects (dev, workspaces). So it seems server started but I cannot add item in the list. Failed to add item to server!#2022-06-2410:08Joshua SmockIs there something equivalent to closure-defines for .clj namespaces? I’d like to have a value that is configurable in shadow-cljs.edn that is accessible in macro namespaces at compile time, but I don’t see anything in the documentation#2022-06-2416:43thhellerthere is no equiv to :closure-defines in that regard. what do you intend to do?#2022-06-2416:45thhelleryou can do (get-in @cljs.env/*compiler* [:options :external-config :your-key]) which would give you the value of :compiler-options {:external-config {:your-key "foo"}} from the build config#2022-06-2416:07rgmI've recently been switching projects over from figwheel, which has generally been going great. There was one convention it used that was helpful to me: dev builds would build to /target and prod builds would build to /resources/public. (Of course /target/ needed to be on the class path for dev builds, but I had a :dev alias anyway so no big deal). This was helpful because in the case of building a docker container on my local machine, it was easy to not end up with dev code in the container ... just don't copy it into the container. It seems :output-dir in a shadow-cljs.edn build config controls both the build/watch and the release destination. Is there a way to segregate these? (It's not the biggest issue; it just means I need to add an rm -rf to my bash docker build script. It's just slightly tedious since it pulls the dev JS out from any watch process I might have left running).#2022-06-2416:43thheller@rgm see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration. :output-dir "target" :release {:output-dir "resources/public"}#2022-06-2416:45rgmthank you! <makes mental note to make a carafe of coffee and spend the rest of the morning reading every word of the very good manual>#2022-06-2502:59pinkfrogI have a program that constantly watches changing js files (aka the output of shadow) and produces corresponding artifact out. What’s the recommended way to run it alongside with shadow? Should I run it and shadow in parallel, or let shadow invoke it whenever some cljs file is updated?#2022-06-2506:22thheller@i that is entirely up to you and your personal preference. I personally don't like combining stuff and just let each tool do its thing independently. for releases I typically do npx shadow-cljs release app && other stuff#2022-06-2523:45samedhiIs there any file that is always generated in the out/public once the compilation has finished (while using shadow-cljs watch app)? I am looking for a file that I can watch for a different (Python) integration test watcher?#2022-06-2606:02thhellerrunning integration tests against a watch? doesn't sound like a good idea to me?#2022-06-2606:02thhellerthe output files of your build are always generated though? or the manifest.edn is too?#2022-06-2603:41geraldodevhi folks, i'm trying to use /cdn-cgi/l/email-protection which is a typescript package, i'm getting . {:tag :shadow.build.npm/missing-entries, :entries ["./main.js" "./index.js"], :package-dir #object[java.io.File 0x2be31a66 "/home/geraldo/projetos/crudis/node_modules/react-router-dom"]} ExceptionInfo: package in /home/geraldo/projetos/crudis/node_modules/react-router-dom specified entries but they were all missing, These are the files at the root of node-modules#2022-06-2604:24geraldodevshadow does not compiles typescript right ? I've asked on react-router forum and they told me it was an oversight. They instructed me to use "react-router-dom": "6.4.0-pre.2" which is js.#2022-06-2606:04thheller@geraldodev the package is just broken. in package.json it referneces these files
"main": "./main.js",
  "module": "./index.js",
but they are not included in the package. it will not work in any bundler and has nothing to do with typescript or shadow-cljs. someone just forgot to put the files in the package when publishing
#2022-06-2613:39pinkfrogWhy babel is run when shadow is compiling cljs to js?#2022-06-2706:15thhellerbabel is sometimes used when compiling node_modules esm code#2022-06-2718:29ccannapologies if this is a very stupid question… I have added :module-hash-names true and understand the contents of manifest.edn but where / how can I go about specifying the correct file name in index.html (the script src)?#2022-06-2718:35thhellerdo you have an actual static index.html? most setups use some sort of server to generate html?#2022-06-2718:39ccannit’s a single page app, so I have a static index.html#2022-06-2718:36thhellerif you have an actual index.html you can use this hook https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L154-L156#2022-06-2718:36thhellerbasically just copies the first argument to the second argument location#2022-06-2718:53ccannMaybe I’m doing something incorrectly here:
:target            :browser
   :compiler-options  {:externs ["resources/lib/ext/oidc-client-ts.ext.js"]}
   :module-hash-names true
   :output-dir        "resources/public/js"
   :asset-path        "/js"
   :build-hooks       [(shadow.html/copy-file
                        "resources/index.src.html"
                        "resources/public/index.html")]
   :modules           {:main {:init-fn co.flair.fleet.core/init}}
I put my static index file in resources/index.src.html and it has the tag <script src="/js/app.js"></script> but when I run shadow-cljs release app it copies the index file to resources/public/index.html but it doesn’t rewrite the script tag
#2022-06-2718:54thhelleryou have :modules {:main so the src should be /js/main.js#2022-06-2718:55ccannsorry about that facepalm thanks very much for the help#2022-06-2718:36thhellerwhile also rewriting script tags#2022-06-2912:42sheluchinI'm running into an issue with UUIDs generated with (random-uuid), conditional upon requiring meander. Details in thread...#2022-06-2912:43sheluchinThis works fine:
$ clj -Sdeps '{:deps {meander/epsilon {:mvn/version "0.0.650"}}}'
Clojure 1.10.3
(require '[meander.epsilon :as m])
Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved.
nil
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
But when using shadow:
shadow-cljs - starting via "clojure"
shadow-cljs - server version: 2.19.5 running at 
shadow-cljs - nREPL server started on port 9000
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
shadow.user=> (require '[meander.epsilon :as m])
Reflection warning, meander/util/epsilon.cljc:758:24 - reference to field val can't be resolved.
nil
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36582/<clinit> (REPL:3).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
#2022-06-2912:45sheluchinAnd strangely enough, this works:
shadow.user=> (do #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#2022-06-2912:56roltwhat's the value of cljs.reader/*tag-table* ?#2022-06-2912:58sheluchinSorry, I should have mentioned that it's a clj-repl started with:
npx shadow-cljs clj-repl -A:shadow-cljs
#2022-06-2913:02sheluchin
shadow.user=> cljs.reader/*tag-table*
Syntax error (ClassNotFoundException) compiling at (REPL:0:0).
cljs.reader
I'm not sure if it worked..? Looks like it produced a syntax error and a value?
#2022-06-2913:06rolti though it was cljs, in that case that would be default-data-readers and *data-readers*#2022-06-2913:07rolti tried to reproduce but couldn't, it works for me even after requiring meander :/#2022-06-2913:08sheluchin
shadow.user=> *data-readers*
{dbg #'cider.nrepl.middleware.debug/debug-reader, break #'cider.nrepl.middleware.debug/breakpoint-reader, light #'cider.nrepl.middleware.enlighten/light-reader, meander.epsilon/fail #'meand
er.strategy.epsilon/*fail*, meander.epsilon/pass #'meander.strategy.epsilon/*pass*}
#2022-06-2914:25sheluchinhttps://github.com/sheluchin/invalid-number-uuid-repro#2022-06-2914:46roltcan't reproduce either, what's the java version ?#2022-06-2914:57sheluchin@U02F0C62TC1
$ java --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.21.10.1, mixed mode, sharing)
#2022-06-2915:02rolti'm using the same... sorry i'm at loss#2022-06-2915:02sheluchinNo worries, thanks for checking it out!#2022-06-2917:47thhellerhmm this is odd. will look into it. thanks for the repro#2022-06-2917:52thhellerhmm unfortunately I cannot repro it either. works as expected.#2022-06-2917:53thhellercan you run a *e eval after the error? maybe the stacktrace can provide some clues#2022-06-2917:55sheluchin#2022-06-2917:57thhellerand just #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978" without the (identity) works?#2022-06-2917:58sheluchin
shadow.user=> #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
shadow.user=> (identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36931/<clinit> (REPL:5).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=> (prn #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval36933/<clinit> (REPL:6).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=> 
Yep.
#2022-06-2917:59sheluchinPerhaps there's something extra running I'm not aware of? Is there some way to get more diagnostics or make it run with a bare config?#2022-06-2917:59thhellerthat is very odd. don't have a guess what that might be really#2022-06-2918:01thhellerjava.lang.ExceptionInInitializerError is always responsible for some very weird errors#2022-06-2918:02thhellernormally the trace has a clue though#2022-06-2918:03thhellerdoes this happen if you do it over nrepl?#2022-06-2918:03thhelleror just the clj-repl directly?#2022-06-2918:07thhelleralso do you have something in your ~/.clojure/deps.edn or wherever that file is? maybe there is something in there contributing to this? no idea what but maybe?#2022-06-2918:13thhelleralso you can set {:deps {:aliases [:shadow-cljs]}} in shadow-cljs edn so you don't have the pass the -A:shadow-cljs in case you didn't know that#2022-06-2918:14sheluchin~/.clojure/deps.edn has some aliases, but I'm not activating them here.#2022-06-2918:15sheluchin/usr/local/lib/clojure/deps.edn is commented out.#2022-06-2918:19sheluchinAnd yes, happens over nrepl too:
+14:16 $ clj -A:repl/cider
WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
nREPL 0.9.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 11.0.15+10-Ubuntu-0ubuntu0.21.10.1
Interrupt: Control+C
Exit:      Control+D or (exit) or (quit)
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
#uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978"
(identity #uuid "0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978")
Execution error (NumberFormatException) at shadow.user$eval40895/<clinit> (REPL:1).
Invalid number: 0eb537e1-72bc-4d1a-89e0-8e3c2a7f8978
shadow.user=>
#2022-06-2918:31sheluchinI guess I could ask in #meander? It does seem related, since the identity call works before requiring it. Otherwise I too have no ideas. It's strange that it works with some forms, like do, and, or, but not most others. I guess those working ones don't evaluate it or something.#2022-06-2919:18sheluchinI'm sorry, this is very frustrating because it has happened to me in the past. Somehow after deleting my .m2 folder and reinstalling Clojure, the problem is gone. I have no idea how my .m2 is getting screwed up or how I can detect that it's in a broken state to avoid another goose chase like this. I don't interact with that folder manually.#2022-06-2919:31thhellermaybe your PC is broken in same way? bad ssd, bad ram?#2022-06-3020:53sheluchin@U05224H0W guess I can't rule it out completely. There was a lengthy https://clojurians.slack.com/archives/C053AK3F9/p1656530805008529 about this in #beginners. Unfortunately, didn't really come to a resolution because I deleted the evidence (~/.m2 folder), but there are some good guesses in there. Leaving it here for reference.#2022-06-2920:33Franco Gasperinogood afternoon. i'm experimenting w/ code splitting.#2022-06-2920:37Franco Gasperino
{:builds                                                                                                                                                                                                                                      
  {:dev                                                                                                                                                                                                                                        
   {:target :node-script                                                                                                                                                                                                                       
    :main shadowtest.core/main                                                                                                                                                                                                                 
    :output-to "build/shadowtest/app.js"                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    :module-loader true                                                                                                                                                                                                                        
    :modules                                                                                                                                                                                                                                   
    {:hotload                                                                                                                                                                                                                                  
     {:entries [shadowtest.hotload]}}}
(ns shadowtest.core                                                                                                                                                                                                                           
  (:require                                                                                                                                                                                                                                   
   [shadow.loader :as loader]))                                                                                                                                                                                                               
                                                                                                                                                                                                                                              
(defn do-load!                                                                                                                                                                                                                                
  [n]                                                                                                                                                                                                                                         
  (println "Loading module '" n "'.")                                                                                                                                                                                                         
  (-> (loader/load n)                                                                                                                                                                                                                         
      (.then identity))) 
attempting to drive it in the repl:
(do-load! "hotload")
emits:
Execution error (Error) at (<cljs repl>:1).                                                                                                                                                                                                   
shadow.loader API was called before shadow.loader.init!                                                                                                                                                                                       
You are probably calling module loader too early before shadow-cljs got fully initialized.
#2022-06-2920:37Franco Gasperinowas there a step i missed when attempting this?#2022-06-2920:40thhelleryou are using :target :node-script but you want :target :browser I guess?#2022-06-2920:40Franco Gasperinono, im hoping to run this via nodejs#2022-06-2920:40thhellercode splitting isn't supported by :node-script. neither is it very useful?#2022-06-2920:41Franco Gasperinogotcha. i have a case for it, but that answer satisfies the question#2022-06-2920:42Franco Gasperinoi would like to have a similar effect of requiring-resolve on cljs on node (at the compile step)#2022-06-2920:43thhellerthen you maybe want :npm-module?#2022-06-2920:44thhellerbut really you can't have something like requiring-resolve#2022-06-2920:44Franco Gasperinoperhaps. will read up on it#2022-06-2920:46Franco Gasperinoideally would like to have a generated shadow-cljs.edn file, which uses :modules and :entities like interfaces inside the application. user can swap out implementations at compile time w/o fooling with the cljs code#2022-06-2920:47thhellerbut you are starting with optimizing load time?#2022-06-2920:47thhellerI mean just having all the code loaded and then using your own mechanism to switch between different impls would be easy#2022-06-2920:47thhellerand would not require require or resolve#2022-06-2920:48Franco Gasperinoi dont have any pre-sight into the actual namespace names#2022-06-2920:48Franco Gasperinowas hoping :modules would abstract it#2022-06-2920:49Franco Gasperinoi don't see that i can require up-front#2022-06-2920:49thhellermodules only abstract the splitting of one output file into many. the inputs are the same.#2022-06-2920:49Franco Gasperinogot it#2022-06-2920:50thhellerso if I understand correctly the user will say "I want feature X, Y, Z" somehow#2022-06-2920:50thhellerand you want to generate a build out of that?#2022-06-2920:53Franco Gasperinoassume i'm going to take string messages from an ingress source. this may be kafka, jms, http, or other. these are expected to have a common entry point fn with the same signature (arity, etc). these may be in their own namespaces. I was originally thinking i could use :modules to identify "ingress" with :entities [the.actual.namespace], and shadow.loader/load "ingress" I can construct the shadow-cljs.edn file programically.#2022-06-2920:54Franco Gasperinoon the jvm i can do this w/ requiring-resolve#2022-06-2920:55thhellerwhat is :entities? do you mean :entries?#2022-06-2920:55Franco Gasperinosorry yes, my mistake#2022-06-2920:56thhellerso you are triggering a shadow-cljs build dynamically and then somehow run the generated output?#2022-06-2920:56thhellerI mean there are several steps before shadow.loader/load even applies?#2022-06-2920:56Franco Gasperinoyes#2022-06-2920:57Franco Gasperinoassume that each change or difference would involve a whole build step#2022-06-2920:57thhellerand it launches an entierely new process? you are not trying to load it some running script?#2022-06-2920:57Franco Gasperinoi don't expect it to happen at run time#2022-06-2920:58Franco Gasperinothe real target is to avoid (require '[some.namespace.i.dont.know :as ingress])#2022-06-2920:58Franco Gasperinothats the whole task#2022-06-2920:58thhellerthat the part I'm asking#2022-06-2920:59thhelleryou have a running node application#2022-06-2920:59thhellerthat in clojure would do ((requiring-resolve 'some/thing) :foo :bar) but can't in CLJS#2022-06-2920:59Franco Gasperinoit wont change after compile. assume that each customer that may change implementation has their own compilation, process, etc#2022-06-2920:59thhellerthe "running node application" is the key question here#2022-06-2921:00thhellerif you just create a build and launch a new process things become simpler?#2022-06-2921:01Franco Gasperinothat is what will occur, yes. the selection of implementation, and therefore the generation of shadow-cljs.edn, will happen during a docker image build#2022-06-2921:01thhellerI mean instead of generating a build config you can just as well generate a namespace#2022-06-2921:01Franco Gasperinoi could, yea#2022-06-2921:01thhellerso hardcode a build config with {:target :node-script :main some.thing/main}#2022-06-2921:01thhellerand then generate (ns some.thing (:require [whatever.you.need])) (defn main [] ...) dynamically#2022-06-2921:01Franco Gasperinothats not a bad idea..#2022-06-2921:02Franco Gasperinolet me consider that. thanks for the idea#2022-06-2921:03Franco Gasperinoand it'll be more explicit, too#2022-06-2921:08thhellerplease be aware that shadow-cljs is a development tool. it is not meant to ever run in any kind of production environment.#2022-06-2921:08thhellerit will expose several sockets for nrepl, its own websocket server and so on which may compromise production envs#2022-06-2921:08thhellerso whereever you do this make sure its safe 😉#2022-06-2921:09Franco Gasperinounderstood#2022-06-2921:09Franco Gasperinoand thanks for your work on the project#2022-06-3003:14pinkfrogHow can I disable server mode when using watch ?#2022-06-3005:47thhellerwhat do you mean by that? server mode is kinda required for watch since that is was running the threads for the watch#2022-06-3013:50Stijn AlbertGetting this error after upgrading shadow to 2.19.3
shadow-cljs - starting via "clojure"
Missing required argument for "-M ALIASES"
Any ideas on how to fix this?
#2022-06-3013:52Stijn AlbertThis happens when I try to create a release build#2022-06-3013:54thhellerwhat command did you run? this is an error message from the clojure tool#2022-06-3013:57Stijn Albertshadow-cljs release app#2022-06-3013:59thhelleris giving npx shadow-cljs release app the same error?#2022-06-3014:00thhellerwhich clojure cli tool version do you have?#2022-06-3014:01thhellerI mean it should be running clojure -M -m shadow.cljs.devtools.cli release app#2022-06-3014:01thhellerif you have aliases enabled that would be clojure -A:alias -M -m shadow.cljs.devtools.cli release app#2022-06-3014:02thhellerjust try running those and see if you get the same error?#2022-06-3014:02Stijn AlbertI'll try those :thumbsup:#2022-06-3014:08thhellerlikely just need to update the clojure tools#2022-07-0108:47Stijn Albertclojure version is 1.10.1#2022-07-0108:47Stijn AlbertI'm getting the same error when I run clojure -M -m shadow.cljs.devtools.cli release app#2022-07-0108:50Stijn Albert@U05224H0W which clojure version do I need?#2022-07-0109:17Stijn AlbertI updated to 1.11.1, but now I'm getting this gnarly error:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
java.util.Optional.isEmpty()Z
  Node(SUPER): goog/iter/es6.js:147:4
    super();
  Parent(CALL): goog/iter/es6.js:147:4
    super();
	com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2884)
	com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:445)
	com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:465)
	com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:39)
	com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:401)
	com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:471)
	com.google.javascript.jscomp.StaticSuperPropReplacer.replaceAll (StaticSuperPropReplacer.java:63)
	com.google.javascript.jscomp.InlineAndCollapseProperties$AggressiveInlineAliases.process (InlineAndCollapseProperties.java:268)
	com.google.javascript.jscomp.InlineAndCollapseProperties.performAggressiveInliningAndCollapsing (InlineAndCollapseProperties.java:229)
	com.google.javascript.jscomp.InlineAndCollapseProperties.process (InlineAndCollapseProperties.java:203)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:240)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:179)
	com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2574)
	com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:933)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:981)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:930)
	com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:872)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/compile-js-modules (closure.clj:1112)
	shadow.build.closure/compile-js-modules (closure.clj:1098)
	shadow.build.closure/optimize/fn--13728 (closure.clj:1307)
	shadow.build.closure/optimize (closure.clj:1293)
	shadow.build.closure/optimize (closure.clj:1284)
	shadow.build.api/optimize (api.clj:273)
	shadow.build.api/optimize (api.clj:267)
	shadow.build/optimize (build.clj:525)
	shadow.build/optimize (build.clj:517)
	shadow.cljs.devtools.api/release* (api.clj:339)
	shadow.cljs.devtools.api/release* (api.clj:324)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--18450--auto----19158 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
Caused by:
NoSuchMethodError: java.util.Optional.isEmpty()Z
	com.google.javascript.jscomp.StaticSuperPropReplacer.tryReplaceSuper (StaticSuperPropReplacer.java:102)
	com.google.javascript.jscomp.StaticSuperPropReplacer.visit (StaticSuperPropReplacer.java:92)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:859)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
	com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:898)
	com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:763)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:806)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
	com.google.javascript.jscomp.NodeTraversal.handleClassMembers (NodeTraversal.java:973)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:815)
	com.google.javascript.jscomp.NodeTraversal.handleClass (NodeTraversal.java:948)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:812)
	com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:987)
	com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:751)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
	com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:850)
	com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
	com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:39)
	com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:401)
	com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:471)
	com.google.javascript.jscomp.StaticSuperPropReplacer.replaceAll (StaticSuperPropReplacer.java:63)
	com.google.javascript.jscomp.InlineAndCollapseProperties$AggressiveInlineAliases.process (InlineAndCollapseProperties.java:268)
	com.google.javascript.jscomp.InlineAndCollapseProperties.performAggressiveInliningAndCollapsing (InlineAndCollapseProperties.java:229)
	com.google.javascript.jscomp.InlineAndCollapseProperties.process (InlineAndCollapseProperties.java:203)
	com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:240)
	com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:179)
	com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2574)
	com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:933)
	com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
	com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:981)
	com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:930)
	com.google.javascript.jscomp.Compiler.compileModules (Compiler.java:872)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/compile-js-modules (closure.clj:1112)
	shadow.build.closure/compile-js-modules (closure.clj:1098)
	shadow.build.closure/optimize/fn--13728 (closure.clj:1307)
	shadow.build.closure/optimize (closure.clj:1293)
	shadow.build.closure/optimize (closure.clj:1284)
	shadow.build.api/optimize (api.clj:273)
	shadow.build.api/optimize (api.clj:267)
	shadow.build/optimize (build.clj:525)
	shadow.build/optimize (build.clj:517)
	shadow.cljs.devtools.api/release* (api.clj:339)
	shadow.cljs.devtools.api/release* (api.clj:324)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:28)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--18450--auto----19158 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.main/main-opt (main.clj:514)
	clojure.main/main-opt (main.clj:510)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
#2022-07-0119:56thhellerwhich java version do you use? seems like its maybe too old? should be java11+#2022-07-0509:27Stijn Albert~Tried with Java 8 and Java 17, and both yield the same error.~ 😞#2022-07-0513:22Stijn AlbertUpgraded from java 8 to 11, works again now! Thanks a lot @U05224H0W#2022-06-3014:51Ted CiafardiniAfter running npx shadow-cljs watch app after the build completes, I open my browser and see the following in terminal:
2022-06-30 10:46:46,627 [XNIO-1 I/O-3] DEBUG io.undertow.websockets.core.request - Attempting websocket handshake with 
and then this message on repeat until it times out:
2022-06-30 10:47:11,865 [XNIO-1 I/O-3] DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1
Any clues? I’ve triple checked my configuration and I’m stuck 😬 thanks for reading
#2022-06-3015:04thheller@edward.ciafardini thats just debug logs? you need to adjust your logging config to not show these unless you are actually trying to debug undertow?#2022-06-3015:17Ted CiafardiniThe instructions I was working through said I would see a “Web Socket connected!” message but I didn’t…. So I thought something was wrong Connecting to the Shadow Cljs build with a REPL is working and sending js/alerts, so I guess nothing is wrong. False alarm, thanks#2022-06-3015:19thhellerthere is no web socket connected message anymore. that is rather old news. now just says shadow: #<some-number> ready!#2022-06-3015:28Ted CiafardiniCool - I am reading “Web Development In Clojure 3rd Edition”, and some things have been slightly inaccurate (the nature of things). Thanks for the quick response#2022-07-0107:23AndrewHey all. I was wondering if it is possible to use https://github.com/bensu/doo together with shadow-cljs? I'm getting errors running lein doo about React components from node_modules being not found, so I'm suspecting it's not#2022-07-0107:28thhellerno, its a leiningen plugin that directly uses the cljs compiler#2022-07-0107:30AndrewOkay, thanks!#2022-07-0107:30AndrewIs there some kind of lein plugin that'll make the whole testing thing - build the JS and run it with pre-configured runner? So that one does not have to run bunch of npx commands (well, actually 2, but still 😅 )#2022-07-0107:31thhellerwell there is :target :karma that a few people use#2022-07-0107:34AndrewI'm using karma as well, but to run tests I've made shell script which does
npx shadow-cljs compile test
npx karma start --single-run
Is there a way to achieve similar outcome from within lein ?..
#2022-07-0107:34AndrewSorry for such noobish questions 😅#2022-07-0107:41AndrewWhat I mean is it'd be great to have a single entrypoint (a single command) to kick off the test run#2022-07-0107:50thhellerI mean there are gazillion tools to solve that issue? Just a Makefile or npm "scripts" or whatever#2022-07-0107:50thhelleror even just lein#2022-07-0107:51thhelleror even just npx shadow-cljs compile test && npx karma start --single-run#2022-07-0108:02AndrewRight. I ended up writing bb.edn to solve it with babashka 😊 Thanks for the pointers!#2022-07-0112:16roman01lagetting the following error in 2.19.5, is that known?
Syntax error compiling at (shadow/build/data.clj:360:5).
No such var: ana/get-data-readers
#2022-07-0114:21eggsyntaxSame here.#2022-07-0114:24eggsyntaxHmm, also on 2.19.4.#2022-07-0114:29eggsyntaxIncluding [org.clojure/tools.analyzer "1.1.0"] on the clojure side of deps (in project.clj) solves it for me.#2022-07-0119:27thhellerI'm guessing you are using deps.edn or project.clj? make sure you have the proper matching clojurescript versions?#2022-07-0119:27thhellershould be 1.11.60#2022-07-0119:28thhellerana is cljs.analyzer. dujnno why adding tools.analyzer would do anything#2022-07-0121:23eggsyntaxOhhh, huh. Wild.#2022-07-0121:24eggsyntaxAnd on Clojurescript it's https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer.cljc, right, not a separate lib?#2022-07-0205:42thhelleryes#2022-07-0113:02ilevdI run shadow-cljs watch app --debug and get runtime error in console without lineNumber and filename, is it possible to configure shadow-cljs to see it?#2022-07-0113:04ilevdAdded some compiler options, but it doesn't help
:dev        {:closure-defines  {"re_frame.trace.trace_enabled_QMARK_" true}
                             :compiler-options {:source-map   true
                                                :pseudo-names true
                                                :pretty-print true}
                             }
#2022-07-0119:29thhellerexpand the arrow before "Uncaught" not the one before cljs$core$ExceptionInfo#2022-07-0119:29thhellerthat should have the proper stacktrace?#2022-07-0119:30thhellerpseudo-names and --debug only applies to release builds, does nothing for watch#2022-07-0407:37ilevdIt seems that there is only reitit router#2022-07-0407:47thhellertypically that error suggests that you are either not passing an argument you are supposed to pass#2022-07-0407:47thhelleror the wrong type#2022-07-0407:47thhellers.chatAt suggests it expects a string somewhere#2022-07-0407:47thhellerbut you are maybe passing something else or just nil. looking at the code may suggest what might be wrong#2022-07-0410:32ilevdI found the error in re-frame event handler, but I want to configure error message, if it possible, to easy find such errors#2022-07-0415:57thhellerwell there is no config for error messages. this is all there is.#2022-07-0114:30Patrick BrownAccidentally posted this in CLJS, but it belongs here. Sorry for the xpost. Howdy! Is there a simple way to do conditional code evaluation based on build id and not target? I’d like to evaluate code differently for different builds that have the same target… Something like. (:require #?(:build-1 [my.app.molecules.build-1] :other-build [my.app.molecules.other])) Where both namespaces contain the same vars, but different logic, yet both are for the same target env. It’s not the end of the world if I can’t, just curious.#2022-07-0119:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2022-07-0120:00Patrick BrownOh, I get it! reader-features is open to anything. Cool feature!#2022-07-0114:41wilkerluciohello, I have a project that is a library, I would like to make sure all the cljs and cljc files compile file, using the :target :browser I have to use the :entries to find the namespaces, but I would like for shadow to find all cljs and cljc files and try to compile all of then, what kind of build setup I can use to make this?#2022-07-0120:01thhellerI guess if you only want to compile all and don't actually care about the output :npm-module is best? you can set a :ns-regexp "your.library" or whatever which will end up including all namespaces matching that?#2022-07-0120:02thhellerthe test targets can also do that#2022-07-0116:39Patrick BrownFIX: Not a shadow issue. This error is caused by running ‘amplify pull’ using AWS Amplify. Check your includes, make sure you’ve pulled and that the pulled file is in the correct location in relation to your require. I’m having issues with my shadow config. I’m using version “2.19.5” with all the important deps matching clojars as outlined in https://shadow-cljs.github.io/docs/UsersGuide.html#failed-to-load I’m getting this error while running release. [:main] Compiling ... Execution error (AssertionError) at shadow.build.resolve/maybe-babel-rewrite (resolve.clj:205). Assert failed: (map? rc) My instincts tell me it has something to do with webpack. But I’m lost. I remember having the same error once before and the solve being super simple, small, and dumb. But for the life of me I can’t remember what it was. Any help is BIG THANKS! CHEERS!#2022-07-0119:58thhellersorry, can't remember ever seeing this before#2022-07-0217:26johnI'm exploring making a library that allows you to programmatically spawn webworkers in CLJS. To do this, I need to craft a JS script to inject into the worker that will correctly import/require things in a way that works within webworkers. I'm focusing on non-advanced compile mode right now. I've got a thing that works with cljs.main cli and figwheel, but I haven't got it to work yet in shadow:
(defn create-worker-body [require-ns afn value tid]
  (println :require-ns require-ns)
  (let [pre-loads
        (str "var CLOSURE_UNCOMPILED_DEFINES = {\"cljs.core._STAR_target_STAR_\":\"webworker\"};"
             "var quarkpreload = {};\n"
             "quarkpreload.fn = `" afn "`;\n"
             "quarkpreload.args = `" value "`;\n"
             "quarkpreload.tid = `" tid "`;\n")]
    (if (empty? goog/basePath)
      (str pre-loads
           "importScripts('" (last (scripts-src)) "');\n")
      (str pre-loads
           "CLOSURE_BASE_PATH = '" goog/basePath "';\n"
           "this.CLOSURE_IMPORT_SCRIPT = (function(global) {\n"
           "    return function(src) {\n"
           "        global['importScripts'](src);\n"
           "        return true;\n"
           "    };\n"
           "})(this);\n"
           "if(typeof goog == 'undefined') importScripts(CLOSURE_BASE_PATH + 'base.js');\n"
           "importScripts(CLOSURE_BASE_PATH + 'deps.js');\n"
           "importScripts(CLOSURE_BASE_PATH + '../cljs_deps.js');\n"
           "goog.require('process.env');\n"
           "goog.require('" require-ns "');\n"))))
In shadow, I get Error: browser bootstrap used in incorrect target because goog.global.document isn't available:
var doc = goog.global.document;

  if (!doc) {
    throw new Error("browser bootstrap used in incorrect target");
  }
Any pointers here?
#2022-07-0217:27johnI'm trying to make a minimal script that will work across shadow, figwheel and cljs.main#2022-07-0217:28johnIf I need a special version for shadow, I could potentially make a thing to detect which build environment I'm in, and spit out the correct one#2022-07-0217:35johnIn the long run, maybe it'd be good for cljs.main/figwheel/shadow to all expose a out/webworker.js file that CLJS users can know they can always pass to new Worker(... and know that the given build system will handle setup the way it wants to.#2022-07-0217:42johnNevermind I just followed the directions!!!#2022-07-0217:42johnlol, and it worked... :web-worker true#2022-07-0217:43johnlots of sourcemap errors, with my script#2022-07-0217:44johnunsupported protocol for sourcemap request blob:.... But this is sweet progress#2022-07-0217:55souenzzoIs possible to define ^:export 'ed functions at shadow-cljs.edn? I have two builds and I want to export a different set of functions in the same ns#2022-07-0217:59thheller@john the web-worker output is supposed to be loaded as a regular file (ie. new Worker("/js/worker.js")) not as a blob. then source maps will also work#2022-07-0217:59thheller@souenzzo no, but you can skip export completely and instead create 2 different entry namespace#2022-07-0218:00thhellerso (ns your.build.a) and (ns your.build.b) (each with the appropriate requires of course)#2022-07-0218:00thhellerthey can each call (js/goog.exportSymbol "whatever.name.you.like" the-cljs/def)#2022-07-0218:01thhellerall ^:export does is adding that exportSymbol call basically#2022-07-0218:01thhellerbut you can do it manually with more control#2022-07-0310:32prncHello 👋 Is there a way to set the ‘config map’ options of binaryage/cljs-devtools in shadow-cljs (edn config file)? This sections describes it for e.g. lein based projects: https://github.com/binaryage/cljs-devtools/blob/master/docs/configuration.md#configuration-via-compiler-options#2022-07-0310:36prncI’m very interested to learn how to do it for it’s own merit, but in the spirit of XY problem, one level up the stack is the issues of trying to suppress the some custom formatters were not rendered. message with :dont-detect-custom-formatters true following: https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#why-some-custom-formatters-were-not-rendered I get the warning, yet formatters seem to work just fine (so wanted to get rid of the warn for the time being — chrome 103.0.5060.53)#2022-07-0313:43thhelleryes, just put it in :compiler-options in the build config#2022-07-0314:56prncAwesome, thanks!#2022-07-0315:54geraldodev@U7MHWDLD8 Have you succeeded with the msg removal ?#2022-07-0320:17prnc@U0516053R thanks for checking in — I’m no seeing the message anymore 🙂#2022-07-0321:22geraldodev@U7MHWDLD8 can you describe what you did ?#2022-07-0409:03prncNot sure it’s the only thing I did (since I’ve been messing with the app quite a bit), but maybe try something along the lines of
{..
 :builds {:app {:compiler-options {:external-config {:devtools/config {:features-to-install           [:formatters :hints]
                                                                       :dont-detect-custom-formatters true}}}}}}
in the shadow-cljs.edn
#2022-07-0314:17pinkfrogI cannot get pretty print working with the :repl-pprint on, what can I check? https://shadow-cljs.github.io/docs/UsersGuide.html#_repl_3#2022-07-0314:17thhellerwhich REPL client do you use?#2022-07-0401:09pinkfrogFYI, this is the relevant issue on Calva. As for me, I am using Calva with pprint functionality. It doesn’t work. I then switched to the calva engine, it now works. See https://calva.io/pprint/#pprint-is-not-working-for-clojurescript:~:text=Comments-,calva,-client#2022-07-0401:23pinkfrogHow can I variable names in comment around? I often do some quick experimentation and define variables in comments to hold some results. However, due to the hot load mechanism, these variables will disappear. For example
(ns foo)

(comment 
  (def *a (result-of-some-http-req)) 
*a will disappear after add some change in other parts of the file. How can I disable this behavior? I verified, js/foo.STARa_ still exist. It’s just the access of foo/*a gives the undeclared var error
#2022-07-0401:23pinkfrogI can change above to#2022-07-0401:24pinkfrog
(ns foo)
(declare *a)
(coment
  (def *a (....))
and it works. But I ’d rather move anything about *a to be inside the comment.
#2022-07-0404:26thhellerwell hot reload and REPL are somewhat at odds with each other sometimes#2022-07-0404:26thhellersuppose you have
(defn a [])

(defn b []
  (a))
#2022-07-0404:27thhellerregularly in a file and rename (defn a []) to (defn x []) without changing b#2022-07-0404:27thhellerI want to get a warning for that immediately and not at some arbritrary time later when I restart the build or something#2022-07-0404:28pinkfrogBut consider my use case, it is possible to tell shadow to not erase the declaration for vars beginning with a * ?#2022-07-0404:28thhellerthere is no setting to disable the namespace "reset" for hot-reload#2022-07-0404:28thhellerno there is not#2022-07-0404:29pinkfrogThen what’s your workflow regarding this? Hotload is great, but on the other hand, it breaks the interactive testing loop cycle.#2022-07-0404:30thhellerI never have these kinds of defs#2022-07-0404:31thheller
(comment
  (tap> (result-of-some-http-req)))
#2022-07-0404:31thhelleris what I would have#2022-07-0404:31thhellerbut honestly given hot-reload I barely use the REPL for CLJS#2022-07-0404:32thhellerI mean if you reload the file via the REPL in the first place#2022-07-0404:32pinkfrogAfter the tap, what’s the next step? How can you look into some nested data fields of the result? Some tools like portal?#2022-07-0404:32thhellereg. load-file it will not be reset#2022-07-0404:32thhellerthe shadow-cljs inspect UI#2022-07-0404:32thhellerhttp://localhost:9630/inspect-latest#2022-07-0404:33pinkfrogOne thing to mention, it does not has much to do with the REPL. I mostly perform evaluation in the comment block with the repl panel closed. It’s just things def-ed in the comment block are resetted.#2022-07-0404:36thhellerthats a weird statement. I mean what do you care about it getting reset if you don't look at it anyways?#2022-07-0404:37thhellerI mean you can always move things to a namespace not part of the actual build#2022-07-0404:37thhellerthose won't get reset or touched in any way#2022-07-0404:37pinkfrog
(comment
  (def *a (some-stuff))
  (def *b (:key *a))
  )
I do look at it. But it’s the inline result not from repl.
#2022-07-0404:38pinkfrogI considered (def x/a (some-stuff) but it’s definitely results in syntax error.#2022-07-0404:41thhellerwell, not removing the analyzer data hides all sorts of issues#2022-07-0404:41thhellerI can add a flag to not do the reset, thats not a big deal#2022-07-0404:42pinkfrogAwesome. One more thing, what part does the magic? I am interested.#2022-07-0404:43thhellerhttps://github.com/thheller/shadow-cljs/blob/22d875f9b0a8a9cd5f07ee8fad590eb0fd511558/src/main/shadow/build/data.clj#L240#2022-07-0404:44thhellerplease open an issue for this. can't get to it today and might forget otherwise#2022-07-0404:46pinkfroghttps://github.com/thheller/shadow-cljs/issues/1025#2022-07-0404:47pinkfrogBtw, will the previously required names, e.g., (require ’[foo :refer [bar]), will the bar be kept around after a reload?#2022-07-0404:55thhellerno, the entire analyzer data is reset for that namespace#2022-07-0405:37pinkfrogJust wanna make sure after the new flag, the above bar is also kept.#2022-07-0409:24ingesolWe are looking for ways to speed up the advanced compilation of our large CLJS codebase. I thought code splitting might help, so I tried it out by putting a couple of namespaces into my-module. My example setup is main + my-module that depends on main. My expectation was that modifying a file within my-module would only rebuild the my-module.js file, but compile times were the same both for modifying files on main and my-module. My question is: Does shadow skip advanced compilation for modules with no changes on the file system?#2022-07-0416:00thheller:advanced is whole program optimization. :modules just splits the final output into multiple files. it still needs to compile everything all at once.#2022-07-0416:00thhellerno, this also cannot be done incrementally in any way#2022-07-0417:05ingesolOk, thanks for clarifying#2022-07-0412:35wilkerluciohello, on Shadow I'm seeing a lot of reflection warnings when compiling, not sure the cause:#2022-07-0412:35wilkerlucio#2022-07-0415:58thhellerI guess you are running shadow-cljs in an embedded/repl context somehow that binds *warn-on-reflection* to true globally? normally you shouldn't see those?#2022-07-0519:15wilkerluciomakes sense, gonna dig in, thanks!#2022-07-0413:08souenzzoHello. I'm using :target :graaljs and getting this error message, while trying to load the cljs into polyglot context:
shadow-cljs - failed to load module$node_modules$react_dom$cjs$react_dom_server_browser_development
shadow-cljs - failed to load module$node_modules$react_dom$server_browser
{:clojure.main/message
 "Execution error (PolyglotException) at <js>/:anonymous (ssr.js:47696).\nReferenceError: TextEncoder is not defined\n",
 :clojure.main/triage
 {:clojure.error/cause "ReferenceError: TextEncoder is not defined",
  :clojure.error/symbol <js>/:anonymous,
  :clojure.error/source "ssr.js",
  :clojure.error/phase :execution},
...
Steps to reproduce: git clone --branch graaljs-ssr ; cd atemoia; npm install && clj -A:dev -X atemoia.server/dev-main
#2022-07-0413:09souenzzoSeems that it only occurs in React18. React17 works.#2022-07-0415:58thhellergraaljs is rather limited and does not have the common browser features#2022-07-0415:59thhellerI guess react just assumes TextEncoder is present and wants to use it?#2022-07-0415:59thhellernothing to do from the shadow-cljs side. this is just graaljs being very limited and honestly I would strongly recommend to just use node instead#2022-07-0416:00souenzzoYes. I will try to polyfill. I'm just having fun and learning about graaljs#2022-07-0416:01souenzzobtw, graaljs is undocumented because it is unstable/unsupported?#2022-07-0416:01thhellerwell, I consider it incomplete since you really can't do much with it#2022-07-0416:02thhellerbut thats really a graaljs problem not a shadow-cljs problem#2022-07-0416:02thhellerno async support, no common APIs, pretty much nothing#2022-07-0416:03souenzzoThat limitations are by design (the don't want to implement it) or it just incomplete because it is in development?#2022-07-0416:11souenzzoseems that /cdn-cgi/l/email-protection has TextEncoder. Anyway thanks thheller. Now I know what to do https://github.com/oracle/graaljs/blob/f13548b2536971b58c185ba37dc50e6cc29fe968/graal-nodejs/test/parallel/test-whatwg-encoding-custom-interop.js#2022-07-0416:20thhellerI haven't figured out how you can run the scriptengine with node mode enabled. so far it just seems to be available as a node executable replacement#2022-07-0416:20thhellerI don't follow graaljs much. so no clue what their plans are regarding more features#2022-07-0416:42souenzzo(.eval "js" "TextEncoder = class { encode() {} }") is enough 🙈#2022-07-0519:06souenzzoBTW, I just leaned about https://blog.cloudflare.com/introducing-the-wintercg/ Seems that a cool project could be WinterGC compliance to graaljs. It may turn graaljs into a nicer target for shadow-cljs 👀#2022-07-0613:32souenzzo@U05224H0W do you have a list of API's that shadow-cljs need to be able to have a REPL inside graaljs?#2022-07-0616:13thhellerthat entirely depends on how you use it. it is somewhat possible if you control the JVM side graal context and can just use the java side to eval stuff and so on#2022-07-0616:14thhellerthe JS side doesn't have any IO built-in so the REPL is pretty much a no-go purely from the JS side#2022-07-0617:28souenzzoI'm working on add fetch/websocket/other missing api's into graaljs 🙂 https://github.com/souenzzo/inverno/blob/fetch/src/test/br/dev/zz/inverno_test.clj#L27#2022-07-0617:31souenzzoStill learning A LOT about polyglot/graaljs, but seems to be "just" hard-working#2022-07-0617:32souenzzoMost of the API's, like textencoder is already present at JDK stdlib.#2022-07-0418:20Karan AhlawatHey guys, whenever I setup a new shadow-cljs project, and I try to run the repl/watch the build, it gives me errors about transitive dependencies of the JS packages I have in my package.json. And it does not stop until I manually install them. Today it went as far as making me install packages like base64-js and the like manually. I think this should not be the case, so I'm most likely doing something wrong. Could anyone point me to what though? TLDR; shadow-cljs makes me add transitive deps manually, and I don't think that's the intended behavior.#2022-07-0418:25thheller@ahlawatkaran14 if you have packages in pacakge.json you need to run npm install without specifying a package to install them all. otherwise it only ends up installing whatever package you specified#2022-07-0418:25thhellerit should never be necessary to install every single package#2022-07-0418:25thhellerunless you mess with npm in some way#2022-07-0418:26Karan AhlawatI use pnpm, but I don't think that should have any effect?#2022-07-0418:26Karan Ahlawatsince pnpm supports the same node_modules resolution to be npm compatible#2022-07-0418:27thhellersorry I haven't tried pnpm so dunno what that looks like#2022-07-0418:27Karan Ahlawatit looks pretty similar tbh. Thanks though, will report back#2022-07-0510:52blogscotI’ve had a similar experience using pnpm, in that not all the dependant libraries get installed as happens with npm. Without fully understanding what the issue is, I found that running pnpm i --shamefully-hoist usually fixes this type of issue. The https://pnpm.io/npmrc:
shamefully-hoist
Default: false
Type: Boolean
By default, pnpm creates a semistrict node_modules, meaning dependencies have access to undeclared dependencies but modules outside of node_modules do not. With this layout, most of the packages in the ecosystem work with no issues. However, if some tooling only works when the hoisted dependencies are in the root of node_modules, you can set this to true to hoist them for you.
#2022-07-0516:35Karan AhlawatThat did help, thanks 😄
#2022-07-0418:28Karan AhlawatThis is what I'm talking about#2022-07-0516:14thhellercan't say., which shadow-cljs version do you use? older versions didn't properly support symlinks and the node resolve rules fully. current version does but I never tried pnpm so no clue what else might be going on#2022-07-0516:36Karan AhlawatThe latest one that is on the npm registry, so 2.19.5#2022-07-0418:30Karan Ahlawathm, using npm works just fine though. So I suppose it's a pnpm thing then#2022-07-0423:26johnSo I have this new webworker library I'm working on. It's basically the connection/communication/mesh logic ripped out of tau.alpha, so as to have a lower level lib to build a new version of tau (and other things) on top of. Figwheel uses different build IDs for each build, while Shadow uses modules. So, with Calva and Figwheel, I'm able to focus the repl on a particular set of repl clients, using the option "Select CLJS Build Connection." With Shadow I only have the one build, which is defaulting to the main/screen thread:#2022-07-0423:27johnIs there any way to force Shadow to focus on a given module, with its respective clients, in Calva or otherwise?#2022-07-0423:30johnI see the docs mention:
(shadow/watch :the-build)
(shadow/repl :the-build)
#2022-07-0423:31johnAnd I see the docs reference https://shadow-cljs.github.io/docs/UsersGuide.html#_connecting_calva_to_the_build but not modules#2022-07-0423:32johnMaybe I can still use separate builds, instead of modules? I'd just loose code sharing?#2022-07-0423:34johnI'll try to get a repo up tonight so folks can try it. I'm trying to make a lib that normalizes some of the differences across build tools to make working with webworkers easier#2022-07-0500:46johnOkay, here's an early crack at it: https://github.com/johnmn3/in.mesh#2022-07-0502:44johnAdded an intro on Clojureverse here: https://clojureverse.org/t/in-mesh-one-step-closer-to-threads-on-the-web/9069#2022-07-0509:42stagmoosein https://cljs.github.io/api/syntax/dot says (js/console.log "HELLO") and (.log js/console "HELLO") are equivalent. Can this also be applied to module imported with shadow? I have ["slate-react" :refer (ReactEditor Slate Editable withReact)] under my namespace, and: • (ReactEditor.focus editor) didn't work. • (.focus ReactEditor editor) works. Is this the difference I need to notice between normal cljs and shadow?#2022-07-0516:12thheller@s0930161 my own personal rule for this is to only use the . when using namespace qualified symbols. which also happens to play nice with my other rule of barely ever :refer. so I would to ["slate-react" :as sr] then (sr/ReactEditor.focus)#2022-07-0600:51stagmooseI see. thanks for the help!#2022-07-0516:12thhelleror you can also so ["slate-react$ReactEditor" :as sre] and (sre/focus)#2022-07-0516:13thhellerno intended difference between cljs and shadow in this. should all behave the same.#2022-07-0516:19thheller@john nothing stops you from doing a separate build for the worker in shadow-cljs. the final result is larger than it needs to be so I don't recommend it but you can. as for the REPL the editors just don't support picking the runtime. you can REPL into the workers just fine. has nothing to do with modules though. (shadow/repl-runtimes :the-build) then (shadow/repl :the-build {:runtime-id 123}) using the :client-id listed in the previous command. (unfortunate renaming incident left in those thats why the names differ)#2022-07-0519:01johnOkay, that's pretty awesome#2022-07-0519:09johnI'm trying to imagine what it would look like to reduce friction as much as possible wrt letting users spawn webworkers, without having to necessarily deal with build configs. But, in the default quickstart scenarios that may be easy, but when a user is preferring to use multiple build ids and/or multiple modules, then we don't know where to target that webworker spawn fn without more input from the user, right? Two questions: 1. Would it be possible, from within the lib, to issue a request to spawn a webworker build for an existing build, if one doesn't already exist? (say, in the default quickstart scenario) So that in simple cases users don't have to change build configs? and 2. For more complex scenarios, would it be possible to let user's pass build id and/or module id in on the spawn fn to allow them to generate a new build or module (not yet existing in the build config) based on whatever is passed in?#2022-07-0519:23johnLike, does shadow expose a programmatic API such that a lib that one brings in could optionally extend their current build configuration? And how hairy would that be?#2022-07-0520:11superstructor@john I think you could do that with a build hook - https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2022-07-0520:19johnHmm, that requires changing one's build config though... My feeling is that, in the default situation, users shouldn't have to make augmentations to their build config in order to use webworkers in clojurescript. I feel like spawning workers should be a supported use case after completing any of the quick start directions for raw cljs, shadow or figwheel.#2022-07-0520:23johnHaving a lib that provides it's own worker script with importScripts that pulls down things in the correct way would be fine, but IDK how much other stuff shadow and figwheel are doing throughout the rest of the build to accommodate workers, so I wouldn't want to break the build tool's expectations#2022-07-0520:27johnOption 1: depend on the build tool's worker-import-script for pulling down dependencies, potentially requiring the user to make build config changes, Option 2: provide a default worker-import-script that tries to do the right thing for all the different build tools, independent from their own configs#2022-07-0520:30johnIf worker-import-script is mostly just a small thing, and most of the build is the same, why don't we just always ship a worker-import-script for every build? As long as it can reuse all the existing code in the non-worker build artifact, it's just an extra KB or two#2022-07-0520:35johnAnd if the user wants to learn how to go through adding more build ids or modules to their build config, then they can easily just pass the same IDs to their spawn fn, like (spawn {:build-id ..., or module id. Currently, there's really no way to ship libs that provide web worker capabilities without forcing their users to learn advanced build ceremony, which is different for every build tool#2022-07-0520:44johnIn an ideal world, CLJS could have some worker fn in core, and the different build tools could fulfill some contract that makes it work. Few other languages impose this much ceremony to achieve programmatically spawning parallelism#2022-07-0520:45johnBut short of that, maybe we can provide that via a lib, so that's what I'm exploring now#2022-07-0520:57johnHmm, I see theres https://cljdoc.org/d/thheller/shadow-cljs/2.4.2/api/shadow.cljs.devtools.api#2022-07-0522:33johnI see I can get shadow/active-builds and then shadow/get-build-config for the active builds. But can I then update those build configs at runtime?#2022-07-0522:36johnI'd potentially want to duplicate existing modules with sister worker module configs, just adding :web-worker true, allowing you to connect to them via a worker optionally#2022-07-0522:37johnWith maybe a shared module between them, so the worker is just adding the shim code#2022-07-0522:39johnOr maybe I can just have the worker :depend on the non-worker one#2022-07-0605:02thheller@john none of what you are asking is possible with :advanced builds. and shadow-cljs is not meant to run in any kind of production environment, so what you are attempting is not a supported use case of shadow-cljs (and neither figwheel I'd say)#2022-07-0605:03thhellerbuilding workers on demand is really not all that useful if you ask me but I'm also not really sure which problem you are actually trying to solve#2022-07-0605:04thhellerI mean you could just create a simple mechanism that loads the same file that the initial page loaded#2022-07-0605:05thhellerbut then have it do different things depending on if its on a worker context or not#2022-07-0605:21johnYeah, a shim for the :advanced mode case is pretty easy#2022-07-0605:23johnWell, except with separate builds or modules, then you still need correlate each of the names#2022-07-0605:24johnOptimizations :none is the hardest for me to wrap my head around#2022-07-0605:26thheller
(defn ^:export some-worker-fn [maybe args]
  (do-whatever))


(defn spawn [target & args]
  (let [fn-name (munge target)
        worker (js/Worker. (str script-base "?" fn-name))]
    (.postMessage worker (pr-str args))))


(spawn `some-worker-fn :foo :bar)


(defn init-browser-side [])

(defn init-worker-side []
  (let [target (subs 1 js/location.search)
        target-fn (js/goog.getObjectByName target)]
    (js/self.addEventListener "message"
      (fn [e]
        (let [args (reader/read-string (.-data e))]
          (apply target-fn args)
          )))
    ))

(defn init []
  (if (exists? js/document)
    (init-browser-side)
    (init-worker-side)))
#2022-07-0605:26thhellersomething like that maybe#2022-07-0605:27thhelleranything that requires thinking about :none will probably break in :advanced, so you probably should not be doing it#2022-07-0605:34johnThat's helpful to think about, thanks for putting that script together#2022-07-0605:39thhelleryou probably want to add a lot of stuff for better message passing and proper worker termination though 😉#2022-07-0605:40johnYeah, I've already got a lot of the machinery built out in in.mesh. You can see it working here: https://github.com/johnmn3/in.mesh/blob/master/figwheel/src/in_mesh/figwheel/root.cljs#2022-07-0605:41johnHaven't tested it in advanced yet, but the prior work on tau.alpha worked in advanced mode as well#2022-07-0605:42johnI was using an importScripts shim with tau though. With this I'm trying to lean into the build tool's webworker facilities#2022-07-0605:45johnThe other major piece I'm working on is getting blocking semantics in web workers by calling sync-xhr on a service worker 🙂 similar to this hack https://sleep-sw.glitch.me/#2022-07-0605:46johnIt works on a main thread window page but I can't get the worker's xhr to be caught by the service worker atm#2022-07-0605:46thhellerwhy though? I mean you still absolutely need to go async at some point. so why not just build for async in the first place?#2022-07-0605:50johnJust a simpler programming model - the illusion of locality. None of it's actually local - stuff is spread out all across the circuit board, but languages give us the illusion of locality because the UX of async everything sucks#2022-07-0605:51johncore.async is part of the way there, but you always end up bifurcating your code into what's inside/outside a go block, or async/await#2022-07-0605:51thhellerits still an illusion though? you are just trading one set of trade-offs for another?#2022-07-0605:52johnI mean, if it's on the same computer, among workers in the same memory, I don't see the point of giving up the illusion#2022-07-0605:52johnAcross a network, sure#2022-07-0605:52johnBut event then...#2022-07-0605:52thhellerwell same memory is the key here right? that part seems more relevant than all the worker coordination and stuff? I'm not convinced that one can actually build such a thing on SABs#2022-07-0605:53thhellerespecially since you need to start locking and stuff which sort of defeats the purpose of all the CLJ(S) datastructures in the first place?#2022-07-0605:54johnSAB backed persistent datastructures can work just as well as they do on the JVM. There's nothing in principle different, save for the garbage collection you'd have to handle#2022-07-0605:55thhellerI'd like to be proven wrong on that but I have my doubts#2022-07-0605:56johnBut that's not what in.mesh is about. in.mesh is just trying to be the underlying coordination mechanism that tries to make workers feel like threads#2022-07-0605:57thhellerbut I haven't seen any threaded code like you example from above#2022-07-0605:59johnBy threading I just mean spawn thing then do work on thing like you would a thread. Similar to what you showed above, but with more binding conveyance... And once there's blocking semantics in there, it'll be even more like threads#2022-07-0605:59thhellerbut blocking is the thing you can't do? or don't want to do?#2022-07-0606:01johnI do want to. Got it working in tau years ago but then moved on to sabs, which make it easy to just do js/Atomics.wait#2022-07-0606:02johnbut sabs are restricted in ways that make deployment hard, so I'm trying to get the old way working, with sync-xhr and a service worker#2022-07-0606:02johnYou basically proxy calls through the service worker and the service worker just hangs the response until another work response with the result#2022-07-0606:03johnOld example from tau:
tau.alpha.ex=> (let [res (xget "")
          #_=>       iss (-> @res js/JSON.parse (js->clj :keywordize-keys true))
          #_=>       loc (:iss_position iss)]
          #_=>   (println "International Space Station, Current Location:" loc))
International Space Station, Current Location: {:longitude -175.7632, :latitude -10.2605}
nil
#2022-07-0606:04johnxget is impled with a yield and there's no async rewriting. It's top level blocking#2022-07-0606:05thhellerok, now this request takes 10 seconds for some reason. and you are blocking the main thread for the entire time?#2022-07-0606:05johnno, just a worker in a pool#2022-07-0606:06thhellerso, there is still one async invocation somewhere that doesn't block?#2022-07-0606:07johnNot in the core.async sense of rewriting code. Calling deref just parks the worker until the response is in, then it gets woken up#2022-07-0606:09john
(defn handle-response [event]
  (let [xhr (.-target event)]
    (if (= (.-readyState xhr) 4)
      (if (= (.-status xhr) 200)
        (let [res (.-responseText xhr)]
          (when res
            (yield res)))
        (yield (.-statusText xhr))))))

(defn xget [url]
  (later [url]
    (let [axhr (js/XMLHttpRequest.)]
      (.open axhr "GET" url)
      (set! (.-onreadystatechange axhr) handle-response)
      (.send axhr nil))))
later sends the work to a worker on the pool. yield puts the result in a place. Derefing the later blocks until the message is done
#2022-07-0606:10johnSo you can convert async stuff back into sync#2022-07-0606:10johnOnly works in workers, not the main thread#2022-07-0606:11johnBut that's all using atomics and wait. I had it working with the service worker hack first, but I forgot how to do it 😆#2022-07-0606:12johnThis glitch has the service worker hack, but I can't get it to work in the manner I'm spawning these threads in in.mesh https://sleep-sw.glitch.me/#2022-07-0606:12johnThey also use the hack to do this: https://github.com/BuilderIO/partytown#2022-07-0606:12thhelleryes, I'm aware of that hack. its neat but unusable in practice#2022-07-0606:13johnDepends on the use case. Def slower than native threads, obviously#2022-07-0606:13thhelleralso I don't think you are making things any easier by trying to make things look sync when they aren't#2022-07-0606:14johnAll sync just looks sync#2022-07-0606:14johnIt's about usability#2022-07-0606:15thhellerwell, yes. but for that you kinda need to write your own VM. if that is your intent thats fine and interesting. faking it into something that wasn't designed for it later is where I have my doubts#2022-07-0606:16thhellerbut again the interesting part is the shared memory, so the SABs. solving the coordination is less interesting (to me, personally)#2022-07-0606:18johnAgreed. I'm going for an on-ramp. Where you can get the semantics out of the box, but if you want higher performance, you have to enable SABs, which requires COOP/COEP... and there's issues with using that from 3rd party libs#2022-07-0606:19johnNot too familiar with all that minutia, but SABs are kinda hamstrung right now#2022-07-0606:19johnIt'll probably smooth over, after some years#2022-07-0606:20johnIf you're delivering the application and can control the headers, and can control for some other gotchas, you can ship with SABs#2022-07-0606:22johnAnyway, I appreciate your thoughts (and challenge ;))... Willing to pay a bounty though to get sync-xhr from workers to service workers working in in.mesh though, if anybody is interested 🙂#2022-07-0606:26johnthe code is essentially:
(defn- fetch-event [resolve]
  (js/console.log "[ServiceWorker] Fetch")
  (js/setTimeout
   resolve 1000
   (js/Response. "<h1>Hello, world!</h1>"
                 #js {"headers"
                      #js {"content-type" "text/html; charset=utf-8"
                           "Cache-Control" "max-age=31556952,immutable"}})))
(.addEventListener js/self "install" #(js/self.skipWaiting))
(.addEventListener js/self "activate" #(.waitUntil % (js/self.clients.claim)))
(.addEventListener js/self "fetch" #(.respondWith % (js/Promise. fetch-event)))
And that'll work when you hit a page scoped to the service worker from a browser tab. But when I hit it from a worker, it's just returning immediately, with the actual resource
#2022-07-0606:27johnSo, instead of a timeout, you'd just park the promise, and when the response is ready, the other worker working on it posts up the response and then sw then resolves the promise#2022-07-0606:31johnAnd of course you want the sw to be fully async and never do long running operations on there#2022-07-0606:31johnAnyway, thanks for the advice. I'll let you know if I make any progress#2022-07-0606:32thhellerthat js/setTimeout call seems wrong?#2022-07-0606:35johnmmm, I might have messed it up when I cleaned it up to copy and paste#2022-07-0606:36johnYeah, the resolve is supposed to be outside the setTimeout#2022-07-0606:40johnMaybe more like:
(defn- fetch-event [resolve]
  (js/console.log "[ServiceWorker] Fetch")
  (js/setTimeout
   #(resolve
     (js/Response. "<h1>Hello, world!</h1>"
                   #js {"headers"
                        #js {"content-type" "text/html; charset=utf-8"
                             "Cache-Control" "max-age=31556952,immutable"}})) 
   1000))
#2022-07-0606:55johnHere we go... I accidentally deleted the .then chaining:
(defn- fetch-event []
  (js/console.log "[ServiceWorker] Fetch")
  (-> (js/Promise. #(js/setTimeout % 1000))
      (.then #(js/Response.
               "<h1>Hello, world!</h1>"
               #js {"headers"
                    #js {"content-type" "text/html; charset=utf-8"
                         "Cache-Control" "max-age=31556952,immutable"}}))))
(.addEventListener js/self "install" #(js/self.skipWaiting))
(.addEventListener js/self "activate" #(.waitUntil % (js/self.clients.claim)))
(.addEventListener js/self "fetch" #(.respondWith % (fetch-event)))
#2022-07-0606:57johnBut it's still broken from the worker - somehow the worker isn't eligible as client to the service worker, in how I'm instantiating them#2022-07-0607:46thhellerI mean do you ensure its installed and ready before the worker actually runs?#2022-07-0614:09johnyeah, tried that#2022-07-0620:06Patrick BrownIf I wanted to develop remotely using shadow/watch is it possible. I’ve got a http-kit server on the same ec2 I’m running shadow watch, it’s serving my shadow js files through an nginx reverse proxy. Everything is working well enough, except the watch part. I’m imagining this is the root cause error, because it’s repeated frequently. ReferenceError: shadow$bridge is not defined at eval (shadow.js.shim.module$aws_amplify.js? [sm]:3:11) at eval (<anonymous>) at goog.globalEval (live.js:472:11) at env.evalLoad (live.js:1533:12) at live.js:1834:12 reportError @ live.js:1425 env.evalLoad @ live.js:1535 (anonymous) @ live.js:1834 Any ideas would be cool. If it’s not possible, that’s cool too. I’d appreciate a heads up on the not possible part, so I don’t waste a bunch of time. CHEERS and CLJS! Edit: After a little bit of time, I get a connection error. I’ve got a 404 on bundle.js.#2022-07-0704:22johnGot the sync xhr working from the webworker! 🎉#2022-07-0704:23johnJust a basic (sleep 100) but it's a start#2022-07-0704:26johnNow I just gotta sort out routing other worker results through the sw response#2022-07-0705:09thheller@pat561 looks like you are using :js-provider :external. must make sure that the :external-index file is loaded before the CLJS output, it provides the shadow$bridge function#2022-07-0710:49Patrick Brown@U05224H0W BIG LOVE for the help! It wasn’t a shadow problem. It was a webpack thing. I was looking in the wrong place until you straightened me out. So thanks!👍#2022-07-0711:02Patrick BrownPerhaps a bit soon… I still get the websocket connection error. WebSocket connection to ‘<ws://example.com:9630/api/remote-relay?server-token=e0a23750-25c2-4870-900f-12345678>’ failed: shadow$cljs$devtools$client$websocket$start @ websocket.cljs:12 eval @ shared.cljs:324 shadow$cljs$devtools$client$shared$init_runtime_BANG_ @ shared.cljs:509 eval @ browser.cljs:337 goog.globalEval @ live.js:472 env.evalLoad @ live.js:1533 (anonymous) @ live.js:1777 I start getting errors after all data has finished loading. It’s refresh to load at this point. EDIT 1: I had a nice walk and it came to me… I’ve got to allow websocket traffic on 9630. I’m not sure how to do this, but at this point it’s most def not your problem. Cheers! EDIT 2: That was crazy easy! I’m super impressed with how well designed this tool is.#2022-07-0715:22thhelleryou can also set :devtools-url "" (or whereever shadow-cljs actually runs) if you don't want to proxy 9630 https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2022-07-0801:37Christopher GenoveseSudden "Critical Dependency" warning. I've been running a React app to test and develop a CLJS library built with shadow-cljs for months now with out any real issues. Throughout that time when I would compile with npx shadow-cljs compile react it would take 8-10 seconds. (Relevant shadow-cljs.edn part below). Suddenly, after a seemingly insignificant change, the compile time dropped to consistently under a second, I started seeing the following warning when running the React app in dev mode:
WARNING in ../Zephyr/zephyr/dist/cljs-runtime/cljs_env.js 1822:9-49
Critical dependency: the request of a dependency is an expression
 @ ../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23
 @ ../Zephyr/zephyr/dist/zephyr.js 3:0-59
 @ ./src/components/ZephyrStaticInline.js 7:0-40 33:29-40
 @ ./src/App.js 7:0-71 69:133-154
 @ ./src/index.js 11:0-24 18:35-38
There's nothing remarkable in the code at those points that I could see, and I did not change any dependencies or even any requires. Has anyone seen this warning before or such an order of magnitude drop in compile times? (I'm not sure how the file size changed.) I'd appreciate any pointers you have. The relevant part of the shadow-cljs.edn file is
:react {:target :esm
          :output-dir "dist"
          :modules {:zephyr
                    {:exports {:math        zephyr.core/math
                               :equation    zephyr.core/equation
                               :inline      zephyr.core/inline
                               :align       zephyr.core/align
                               :staticLaTeX zephyr.core/staticLaTeX}}}
          :js-options {:js-provider :import}
          :compiler-options {:infer-externs :auto
                             :output-feature-set :es2018
                             :optimizations :advanced}}
Again this has worked flawlessly for quite a while. Thanks for your help!
#2022-07-0802:13Christopher GenoveseP.S. As a follow up, I checked out old branches going back well before the warning first appeared. The compile times and warning remain, which is rather surprising. An external/implicit/automatic change in dependencies? Not sure how to explain this. Thanks.#2022-07-0814:43roltif you have version ranges for some packages that might explain it#2022-07-0804:21thheller@genovese I don't know what that error means either. it is not from shadow-cljs or any code it generates. it seems to be from whatever you are using to post process the output. google suggests this https://stackoverflow.com/questions/42908116/webpack-critical-dependency-the-request-of-a-dependency-is-an-expression#2022-07-0804:23thhellerand many others but the cause consistently seems to come from one of the included npm dependencies#2022-07-0812:52Christopher GenoveseThanks @thheller. Webpack is definitely generating the warning, but the npm deps on the react side did not change. Since the message pointed to the cljs runtime and the shadow-cljs compile time changed so noticeably pre and post warning, I thought it might be something in the shadow-cljs generated code. I'm glad to hear that that's not the case, though. A bit of a mystery still, but... Appreciate your help.#2022-07-0812:55thhellerdid you check what is at ../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23 that location in the file?#2022-07-1920:41Christopher GenoveseSo sorry I missed this. Yes I had, and it's just an import
import "./cljs_env.js";
#2022-07-1119:43lilactowni'm curious: why does shadow-grove's db structure use {[key id] entity} as its format instead of {key {id entity}}?#2022-07-1119:43lilactown(at least, that's how the examples are written - haven't tried it yet)#2022-07-1119:44thhellerIMHO easier to work with and closer to a true key/value store but also for efficiency reasons. much much easier to track which keys where modified in a flat map that in 2 nested maps#2022-07-1119:46thhellerI really do not like (assoc-in db (conj some-ident :some-key) 1), so (assoc-in db [some-ident :some-key] 1) looks many times cleaner to me#2022-07-1119:47dpsuttonthe latter should be assoc not assoc-in?#2022-07-1119:48thhellerno. some-ident is the ident of an entity and this presents adding a {:some-key 1} to it#2022-07-1119:48thhellerI mean you could also write it as (update db some-ident assoc :some-key 1)#2022-07-1119:49lilactownmakes sense. i think i normally use (update-in db some-ident assoc :some-key 1) but i've seen people go a little cross eyed when first encountering that type of thing#2022-07-1119:50thhellernote that idents being a vector might actually go away entirely. it is actually a bit annoying, so a custom type for that would be better#2022-07-1119:51lilactownyeah i've thought about changing pyramid so that idents that appear in data are actually their own type#2022-07-1119:51lilactownand it does complicate the whole "everything is just a get-in away" sales pitch 😂#2022-07-1119:52thhellerthe annoying part is properly identifying them at runtime since you can't just do a (instance? Ident thing)#2022-07-1119:53thhellerand checking if its a vector with two elements and the first one being a keyword fails for [:foo :bar] type things#2022-07-1119:53lilactownyup#2022-07-1119:53thhellerI mean it still makes sense as a query language feature but not for actually storing in the db#2022-07-1119:53lilactownyeah#2022-07-1119:55lilactownthe things i think i would lose by moving to a perfectly flat db structure like shadow-grove is 1. retrieving all entities of a "type" requires a full scan of all keys 2. map performance degrades with number of keys IIRC but would have to actually benchmark to see if it makes a difference#2022-07-1119:56thheller1) incorrect. the db actually keeps track of them, so there is a (db/all-idents-of db :some-type) or (db/all-of db :some-type)#2022-07-1119:56thheller2) also incorrect. map performance is pretty much constant time. also actually pretty much always faster than the nested approach since that always modifies two maps#2022-07-1119:58lilactownsounds like shadow-grove specifically keeps an index of the type -> ident relationship? i suppose that would solve all my problems then#2022-07-1119:58thhellerI actually did benchmarks to verify this https://github.com/thheller/shadow-grove/blob/master/src/test/shadow/experiments/grove/bench_db.cljs#2022-07-1119:59thhelleryes, when you (assoc db some-ident some-data) the some-ident is added to a special [:shadow.grove.db/all ident-type] set#2022-07-1119:59thhellersame when you dissoc it#2022-07-1120:00thhellerdescribed why and how more here https://github.com/thheller/shadow-grove/blob/master/doc/what-the-heck-just-happened.md#2022-07-1120:03lilactownthat's awesome#2022-07-1120:03lilactowni'm glad i asked this. super interesting#2022-07-1120:03lilactownthanks!#2022-07-1120:03thhellerits not much code really https://github.com/thheller/shadow-grove/blob/master/src/main/shadow/grove/db.cljc#2022-07-1207:02thhellerFWIW I changed it so idents are their own type. wanted to do that for a while, so I guess it was time before people actually start using this 😉#2022-07-1209:06borkdudeIt's probably not supported right now, but could it theoretically be supported that the build report shows the function size too, so I know where to look if I want to optimize something for size?#2022-07-1209:13thhellerfunction size?#2022-07-1209:15thhellerthe way I typically look for thing for optimize is running a release build with --pseudo-names and then going over the generating sources. it is fairly easy to identify large chunks and associating them with their respective sources#2022-07-1209:15thhellertakes a bit of practice#2022-07-1209:16thhellera test build with :modules may also help. so :modules {:code {:entries [cljs.core]} :target {:entries [the.namespace] :depends-on #{:core}}#2022-07-1209:16thhellerso target.js will only contain code from the namespaces I'm trying to tweak#2022-07-1209:17borkdudeMy issue is that in SCI I'm re-implementing macros as normal functions: e.g.:
(defn foo [_ _ body] `(do 
Contrived example: ^ But the backtick generates a lot of code that could be more optimal/smaller. So I'm going through various macros now to manually rewrite it to get rid of the backtick. This is where my question comes from. Yeah, inspecting the generated code already helps, this is how I first learned about this bloat :)
#2022-07-1209:17thhellerwell backtick itself doesn't generate a lot of code#2022-07-1209:18thhellerthe unintepreted datastructures do#2022-07-1209:18thhellerso new cljs.core.List([new cljs.core.Symbol("do", ... and so on#2022-07-1209:18thhellerdunno how you'd shrink that#2022-07-1209:19borkdudeThis is what you see in the outputted JS:
user=> '`(do 
(the JS equivalent of those) Manually writing that as:
user=> '(list* 'do body)
(list* (quote do) body)
yields smaller code. I notice this by re-running the build report.
#2022-07-1209:21thhellerhmm but those are not equivalent?#2022-07-1209:21thhellerI mean yes, the concat/seq stuff is not ideal but in the end that is only a small part no?#2022-07-1209:22borkdudeIt gets way worse when your macro isn't trivial like the above#2022-07-1209:22borkdudeNormally in CLJS this isn't a problem, since the JVM deals with this boilerplate at compile time - only if you pull the macro to runtime#2022-07-1209:22thhellerI mean yeah I get that. constructing big nested datastructures yields a lot of code#2022-07-1209:24thhellerhmm dunno how you'd optimize that#2022-07-1308:09borkdudeI have an awkward macro in SCI that attempts to do the following: When the macro is used from ClojureScript, it should load the cljs.analyzer.api and populate a var, so that I can use the var in another namespace (to resolve metadata about vars in CLJS). When the macro is used from outside of ClojureScript, it's a no-op. This approach works well, but has a problem with the analysis cache of CLJS. So when I change a dependency or so and restart the compiler/watch process, it crashes, unless I remove this cache, in shadow's case, the .shadow-cljs directory. What's the story with macro calls from .cljs namespaces - are these cached somehow?#2022-07-1308:09borkdudeThe gnarly piece of code is here: https://github.com/babashka/sci/blob/26553568f3b7f0f07795d99f00f13368fb936606/src/sci/impl/cljs.cljc#L20#2022-07-1308:13borkdudeWhen I put a logging statement in the macro which runs in the JVM:
(binding [*out* *err*] (println "Requiring cljs.analyzer.api!"))
I see the output on the first invocation of shadow-cljs, but not in the second one.
#2022-07-1308:14thhelleryes, there code is compiled once and then cached#2022-07-1308:15thhellerI'm unsure that this is supposed to be doing though? looks like it tries to do a dynamic require?#2022-07-1308:15borkdudeIt is doing it dynamically so CLJS doesn't become a dependency of SCI#2022-07-1308:16thhellerbut wouldn't it be easier to make that sci.impl.cljs entirely unconditional and make it do whatever it needs to do for CLJS#2022-07-1308:17thhellerand then just conditionally load that namespace when building for CLJS?#2022-07-1308:17thhelleror I'm missing what this is supposed to be doing?#2022-07-1308:18thhellerI mean you can exclude this ns from the cache so your described problem goes away#2022-07-1308:18thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2022-07-1308:19borkdudeYes, if I could change things, I might have made a separate CLJS API namespace, but this would be kind of breaking. So I'm trying to solve the problem without doing this first. Thanks for the hints!#2022-07-1308:20thhellerthere is also the :dev/always hook https://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2022-07-1308:23thhellerbtw that could would be much less gnarly if it wasn't .cljc 😉#2022-07-1308:25borkdudeI know right 😂#2022-07-1308:25borkdudeso what I'm trying now is on the first def, I have this:
#?(:clj (def cljs-ns-publics (resolve 'cljs.analyzer.api/ns-publics)))
#2022-07-1308:26borkdudeThis sometimes works and also after recompilation it works. But it hasn't always worked, probably due to the order of dependency loading: SCI first or CLJS first#2022-07-1308:26thhellerthinking about .cljc makes my head hurt. why do you do it as .cljc? it really doesn't need to me as far as I can tell?#2022-07-1308:27borkdudeI agree that it would be simpler. I think I've tried that before but I ran into different issues, possibly with self-hosted or so#2022-07-1308:29thheller> so that I can use the var in another namespace (to resolve metadata about vars in CLJS).#2022-07-1308:29thhellerwhich ns would that be?#2022-07-1308:29borkdudesci.core and sci.impl.namespaces#2022-07-1308:31borkdudeNote: I want to avoid a non-top level require#2022-07-1308:32borkdudeThat doesn't play well with graalvm#2022-07-1308:33thhellerok may I make the following suggestion. create or use a namespace that everything can import. sci.impl.env or so, which just has a (def resolve nil) which you'll call whenever you need to resolve something.#2022-07-1308:33thhellerin sci.core as your first require you do a conditional so #?(:cljs [sci.impl.cljs] :cljs [sci.impl.cli])#2022-07-1308:33thheller(thats the only place loading these namespace)#2022-07-1308:34thhellerthe cljs variants is just a regular CLJS requiring cljs.anylzer and whatever else it may need#2022-07-1308:34thhellerand then (set! env/resolve cljs.analyzer.api/resolve)#2022-07-1308:34thhellerthe CLJ variant does the same but via (alter-var-root! ...) or so#2022-07-1308:35thheller(all other requires for sci.impl.cljs need to go away of course)#2022-07-1308:35thhellerby doing it first in sci.core remove all other conditionals you may otherwise have#2022-07-1308:35thhellerany by putting it in a well known var that always exists things become much cleaner no?#2022-07-1308:36thhellerCLJ code never loads the sci.impl.sci so no graalvm issues should exist?#2022-07-1308:36borkdudethe well known var that always exists is inside sci.impl.cljs , it's called cljs-ns-publics#2022-07-1308:37borkdudeThat is already the ns that everyone can import - trying to understand how your approach might work better#2022-07-1308:37thhellerbut it exists in CLJ?#2022-07-1308:37borkdudeyes#2022-07-1308:37thhellerwhy?#2022-07-1308:37borkdudebecause I need to inspect information about CLJS vars in the JVM#2022-07-1308:38thhellerI assume that means you need it during macro expansion? or actually at JVM runtime, meaning in the final created binary?#2022-07-1308:38borkdudeyes, during macro-expansion#2022-07-1308:38thhellerok then you don't need it to be a var at all#2022-07-1308:41thhellerhang on, checking how you use cljs-ns-publics#2022-07-1308:41borkdude😅#2022-07-1308:42borkdudebtw, the workaround I pushed a minute ago, seems to work reliably after stopping and starting the compiler now...#2022-07-1308:49thhelleras far as I can tell my suggestion would remove a whole lot of conditional code and work in all environments. albeit being a little unclean when loading the sci.impl.cljs cljs/clj macro combi in CLJ environment#2022-07-1308:50thhellerbut as far as I can tell that shouldn't happen. I mean you could even control via build config#2022-07-1308:51thhellerand consumers of sci as a lib probably never use sci.impl.* namespaces anyways right? only sci.core?#2022-07-1308:51borkdudeExactly, impl means "internal, don't touch"#2022-07-1308:51thhellerbut if your problem is solved then rewriting a bunch of stuff might not be necessary 😉#2022-07-1308:51thheller(as the caching problem will stay exactly the same)#2022-07-1308:52borkdudeI'll revisit this when the issue persists with your remarks in mind. Thanks a lot :)#2022-07-1308:52borkdudeIf people can ensure the loading order CLJS and then SCI, then the issue won't happen anymore. But this order of loading isn't always guaranteed I think#2022-07-1310:14Filipe SilvaIs there a way to ignore :redef warnings from some namespaces? After cljs 1.11 I get a few of them on every rebuild:
[1] [:app] Build completed. (1684 files, 469 compiled, 5 warnings, 15.44s)
[1]
[1] ------ WARNING #1 - :redef -----------------------------------------------------
[1]  Resource: day8/re_frame_10x/inlined_deps/garden/v1v3v10/garden/color.cljc:390:1
[1]  abs already refers to: cljs.core/abs being replaced by: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #2 - :redef -----------------------------------------------------
[1]  Resource: zprint/range.cljc:81:1
[1]  abs already refers to: cljs.core/abs being replaced by: zprint.range/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #3 - :redef -----------------------------------------------------
[1]  Resource: cljc/java_time/duration.cljc:33:1
[1]  abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #4 - :redef -----------------------------------------------------
[1]  Resource: no/en/core.cljc:131:1
[1]  parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long
[1] --------------------------------------------------------------------------------
[1]
[1] ------ WARNING #5 - :redef -----------------------------------------------------
[1]  Resource: no/en/core.cljc:136:1
[1]  parse-double already refers to: cljs.core/parse-double being replaced by: no.en.core/parse-double
I get that they are a real thing and due to the new cljs fns, but I don’t control these files, nor am I changing them. I know I can set :warnings {:redef false}} on compiler options, but then I don’t get other real redef issues.
#2022-07-1310:17thhellerI would assume that all these libs probably have new versions to address this for 1.11?#2022-07-1310:17thhellerbut otherwise no there is no way to ignore these other than disabling them globally#2022-07-1310:18Filipe Silvasome might, some might not, but it only takes one of these warnings to make rebuilds very noisy, and updating them is a bit of a crapshoot (maybe new errors, maybe new api, etc)#2022-07-1310:19Filipe SilvaI think I’ll just remove the redef warning completely then#2022-07-1310:19Filipe Silvathank you for taking a look#2022-07-1310:54thhellerbut didn't I change it so warnings in files you don't control only appear once on the initial build for watch but not on recompile?#2022-07-1310:55thhellercan't actually remember 😛#2022-07-1311:01Filipe Silvayou know, that’s actually weird: two of these appear on startup, the rest appear on every reload#2022-07-1311:02Filipe Silvathey also show up differently#2022-07-1311:02Filipe Silvastartup
[1] [:renderer] Configuring build.
[1] [:app] Configuring build.
[1] [:main] Configuring build.
[1] [:main] Compiling ...
[1] [:renderer] Compiling ...
[1] [:app] Compiling ...
[1] [:main] Build completed. (86 files, 85 compiled, 0 warnings, 4.00s)
[1] WARNING: abs already refers to: #'clojure.core/abs in namespace: day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color, being replaced by: #'day8.re-frame-10x.inlined-deps.garden.v1v3v10.garden.color/abs
[1] WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs
[1] [:renderer] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.24s)
[1] [:app] Build completed. (1684 files, 1683 compiled, 0 warnings, 33.35s)
[1] [:app] Configuring build.
[1] [:renderer] Configuring build.
#2022-07-1311:02Filipe Silvathen on any file save, I get the previous set of warnings#2022-07-1311:14thhellerhmm maybe something is messed up and it logs the "noisy" warnings when it shouldn't?#2022-07-1311:15thhellerI don't use libs that produce warnings so not something I would never notice myself 😛#2022-07-1311:15Filipe Silvalemme make a repro then, should be able to isolate it#2022-07-1311:38Filipe Silvahere it is#2022-07-1311:38Filipe Silvahttps://github.com/filipesilva/repro-shadow-cljs-warnings#2022-07-1311:39Filipe Silva
npm install
npm start
#2022-07-1311:39Filipe Silvaon startup it shows#2022-07-1311:39Filipe Silva
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "bcdad5d0d5ccd9cfd5d0caddfcf1dddffed3d3d791ecced3"}, :content ("[email protected]")}
#2022-07-1311:40Filipe Silvaif you edit src/main/app.cljs, you get the warning#2022-07-1311:40Filipe Silva
------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.05s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
[:app] Compiling ...
[:app] Build completed. (163 files, 1 compiled, 1 warnings, 0.04s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: cljc/java_time/duration.cljs:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
#2022-07-1311:41thhellerhmm well yeah that does that is should be doing I guess#2022-07-1311:41thhellerit only shows the verbose warning once, after that it is shortened and doesn't show the code excerpt#2022-07-1311:41thhelleractually unsure where WARNING: abs already refers to: #'clojure.core/abs in namespace: cljc.java-time.duration, being replaced by: #'cljc.java-time.duration/abs that is coming from#2022-07-1311:41thhellerits not shadow-cljs generating that#2022-07-1311:42thhelleroh nevermind. thats clojure#2022-07-1311:42thhellerbut instead of just shortening it could maybe just not show the warnings at all#2022-07-1311:44Filipe Silvahmm also noticed that it’s slightly different on a cljc file, which is what I’m using in the real code#2022-07-1311:44Filipe Silvagonna update it#2022-07-1311:45thhellerwell in case of a CLJC file it'll also be reloading the CLJ portion. can't do much about warnings coming from there I guess#2022-07-1311:46Filipe Silvaah no, I don’t think the difference is between cljs and cljc, I think it might be due to using deps or something… I don’t get the full verbose on startup on my real code#2022-07-1311:47Filipe Silvabut it’s not important#2022-07-1313:03roman01laInteresting case with error and code location reporting. If I have :warnings-as-errors true set and a custom analyzer warning that is being emitted during macro expansion time, then code excerpt in the reported warning (as error) will be pointing at macro call site (which is expected given that the warning was thrown), but instead what I want is to point the code excerpt at the location that was provided to ana/warning. Not sure if that's also the default behaviour in cljs compiler itself, but I'm curious if there's something can be done to achieve desired behaviour#2022-07-1313:04thhellerthe location is derived from the metadata on the emitted form most of the time. so you can influence what the error actually says#2022-07-1313:05thhellerI do this all over the place for example with this helper fn https://github.com/thheller/shadow-grove/blob/master/src/main/shadow/arborist/fragments.cljc#L85-L91#2022-07-1313:05thhellerlook for with-loc uses in that file. of course if you manually call ana/warning it comes solely from the env arg passed to it, which you can also modify prior to calling#2022-07-1313:07roman01lathat's exactly what I'm doing, passing env with desired location to ana/warning, but the thrown warning during macroexpansion still points at the macro call site rather than a form within an expression that I'm interested in
(my-macro ... (inc) ...) ;; should report at `(inc)` location
#2022-07-1313:08thhellerbut works correctly when emitted as a regular warning? or is also wrong then?#2022-07-1313:09roman01layep, works correctly as a warning. I guess ex-info on a thrown error is not picked up#2022-07-1313:11thhellerdo you have a repro for that? glancing at the code it should pickup the location properly from the warning? https://github.com/thheller/shadow-cljs/blob/f66ab9bb3945b75ee06f8397d14e5787ff045574/src/main/shadow/build/compiler.clj#L486-L490#2022-07-1313:12roman01lalet me put up a quick one#2022-07-1313:15thhellerhmm just tried locally with the fragments macro. error message is the same#2022-07-1313:15thheller
------ ERROR -------------------------------------------------------------------
 File: C:\Users\thheller\code\shadow-cljs\src\main\shadow\cljs\ui\components\inspect.cljs:310:13
--------------------------------------------------------------------------------
 307 |                  (when label
 308 |                    (str " - " label)))]
 309 |            [:div.truncate
 310 |             (foo.bar)
-------------------^------------------------------------------------------------
null
Use of undeclared Var shadow.cljs.ui.components.inspect/foo
{:warning :undeclared-var, :line 310, :column 14, :msg "Use of undeclared Var shadow.cljs.ui.components.inspect/foo"}
ExceptionInfo: Use of undeclared Var shadow.cljs.ui.components.inspect/foo
	shadow.build.compiler/warning-collector (compiler.clj:493)
#2022-07-1313:16thhellerbut this is not calling ana/warning directly so I guess that isn't really comparable#2022-07-1313:22roman01la#2022-07-1313:23roman01lanot sure if the problem is the fact that I'm not passing entire env, but only location data, but that's enough for the warning to be printed correctly#2022-07-1313:24roman01lahow did you get correct location printing? I'd use it for now#2022-07-1313:24thhellerthe with-loc function I linked above#2022-07-1313:25roman01laPerhaps I misunderstood this > but this is not calling ana/warning directly so I guess that isn't really comparable#2022-07-1313:29thhellerah well, you are trying to get metadata from a number which doesn't have metadata 😛#2022-07-1313:29roman01lawell that's fair 😄 but it doesn't work with IMeta's as well#2022-07-1313:30thhellereh, keyword I mean#2022-07-1313:30roman01lathe actual app code that I'm testing takes location from meta in a hashmap#2022-07-1313:31roman01lahere's the same warning with and w/o :warnings-as-errors true#2022-07-1313:35roman01laMaybe in your example with undeclared var it works fine because the erroring location matches analyzed location. In my case with the macro, analyzed location is the callsite of a macro.#2022-07-1313:35thhellerhmm yeah I can reproduce it. checking#2022-07-1313:48thhellerhmm so I guess this happens due to the cljs.analyzer macroexpansion code try/catching the error and throwing a new one with its own location data added. which it takes from the source form.#2022-07-1313:49roman01lamakes sense#2022-07-1313:49thhellerdunno if I can get to the info easily without breaking other errors#2022-07-1313:50roman01laI guess I can include my own excerpt into the error message then#2022-07-1313:52thhellernah, I think I can address this#2022-07-1313:53roman01laCool! I wonder if cljs analyzer itself could use thing change, unless it breaks other errors#2022-07-1313:57roman01laAre you gonna read location from the re-thrown error e? (throw (ex-info nil (error-data env :macroexpansion (var->sym mac-var)) e))#2022-07-1313:59thhellerthinking about it yeah. the relevant code starts here https://github.com/thheller/shadow-cljs/blob/f66ab9bb3945b75ee06f8397d14e5787ff045574/src/main/shadow/build/compiler.clj#L962#2022-07-1313:59thhellerso that could check the data if its a macroexpansion error and then get the data from the (.getCause e) instead#2022-07-1313:59thhellerbut I'm unsure that this will always be correct. meaning pointing to the correct location if it has line/column.#2022-07-1314:01thhellerthere might be cases where that location is actually worse than showing the location of the macro#2022-07-1314:01roman01lado you have an example?#2022-07-1314:02thhellerno, just thinking about it#2022-07-1314:03roman01laI'll have to patch shadow on my side to have meaningful error messages in the meantime, but that's a good point.#2022-07-1314:03thhellerI mean this only happens because of :warnings-as-errors so it is isolated to shadow-cljs. so I guess I could add a marker of sorts#2022-07-1314:19thhellerhttps://github.com/thheller/shadow-cljs/commit/732577ea5257f6418d4926d10f5c0e3261303e8b#2022-07-1314:19thhellerneeds some more testing before I make a release but seems to be ok for your repro#2022-07-1314:20roman01lanice!#2022-07-1314:20thheller(although modified your repro since keywords can't take meta and won't have location data)#2022-07-1314:48roman01laOn that note: I think shadow's ERROR reporting browser UI could use more love, the warning reporting screen is much easier to read because of formatting (bold text, marings, etc)#2022-07-1315:33thhelleryeah but its a lot of work since errors are captured as text for the terminal. wiring the whole error reporting again to capture html is meh
#2022-07-1315:34roman01laI just made it nice looking with a bunch of regexes 😄#2022-07-1315:35thhellerhehe I guess that works too 😛#2022-07-1811:37roman01la@U05224H0W Just noticed that code location pointing is also wrong for "undeclared var" warnings with :warnings-as-errors true#2022-07-1811:44thhellerhmm, probably the exception being wrapped multiple times. feel free to open issue, can't look into it currently#2022-07-1811:50roman01laDone https://github.com/thheller/shadow-cljs/issues/1033#2022-07-1317:03richiardiandreaHi there, I am trying to get a runtime against wrangler (Cloudflare worker) up However, when I start it I get:
[mf:err] Error: Failed to construct 'WebSocket': the constructor is not implemented.
    at Object.construct (/home/cokap/git/arudik-website/cloudflare-workers/backblaze-download-token-to-secrets/node_modules/@miniflare/web-sockets/src/plugin.ts:37:19)
    at shadow$cljs$devtools$client$websocket$start (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/websocket.cljs:12:16)
    at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:324:25)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/shared.cljs:509:24)
    at ../.cljs/cljs-runtime/shadow.cljs.devtools.client.browser.js (/home/cokap/git/arudik-website/cloudflare-workers/.cljs/cljs-runtime/shadow/cljs/devtools/client/browser.cljs:337:3)
Is there a way to avoid compiling the browser dev tools in a module?
#2022-07-1317:04richiardiandrea
import "./cljs-runtime/shadow.cljs.devtools.client.browser.js";
SHADOW_ENV.setLoaded("shadow.cljs.devtools.client.browser.js");
If I remove the two lines up it seems to work
#2022-07-1317:04thheller:devtools {:enabled false} in the build config#2022-07-1317:05richiardiandrea@U05224H0W oh thanks you, will try that out#2022-07-1317:39richiardiandreaI am experimenting with the new js-await macro I did this
(ns cloudflare.workers
  (:require [shadow.cljs.modern :refer (js-await)]))

(defn backblaze-download-token-to-secrets
  [controller env ctx]
  (js-await [result (js/Promise.resolve #js {"foo" "bar"})]
   (js/console.log "environment" env)
   #js {:response "response"}))
but I don't see any compiled file...the module contains only
import "./cljs_env.js";
#2022-07-1317:40thhellerhmm? what does one have to do with the other?#2022-07-1317:40thhellerwhat is your build config? which file did you look at?#2022-07-1317:40richiardiandrea
{:target :esm
            :output-to "target/cloudflare-workers.js"
            :output-dir ".cljs"
            :modules {:backblaze-download-token-to-secrets
                      {:exports {default cloudflare.workers/backblaze-download-token-to-secrets}}}
            :compiler-options {:output-feature-set :es-next}
            :js-options {:entry-keys ["module" "browser" "main"]}
            :devtools {:enabled false}
            :release {:compiler-options {:source-map true}}}
#2022-07-1317:41richiardiandreaI am looking at both this two guys
$ cat .cljs/cljs-runtime/shadow.module.backblaze-download-token-to-secrets.
shadow.module.backblaze-download-token-to-secrets.append.js
shadow.module.backblaze-download-token-to-secrets.prepend.js
#2022-07-1317:41thhellerthats not the correct file to be looking at#2022-07-1317:42thheller.cljs/cljs-runtime/cloudflare.workers.js will have the source from cloudflare.workers ns#2022-07-1317:42richiardiandreaoh ok#2022-07-1317:43richiardiandreayeah that contains the right code..sorry for the newbie question, but would that match the expected format here? https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/#syntax-module-worker ?#2022-07-1317:44richiardiandreabasically I am not sure I am producing the expected async scheduled function#2022-07-1317:46thhellerwhich part? I mean your code is doing something else entirely?#2022-07-1317:46thhellerthe export default would be correct yes#2022-07-1317:48richiardiandreawell yeah, I am trying stuff 😄 basically I need to export this
export default {
  async scheduled(event, env, ctx) {

  },
};
an export list with scheduled in it
#2022-07-1317:48thhellerhehe I'm blind. didn't even see the extra object#2022-07-1317:49thheller
(def thing
  #js {:scheduled
       (fn [event env ctx]
         ...)})
#2022-07-1317:49richiardiandreaoh I think I just saw how to do that sorry
(def exports #js {:g f
                  ...})
#2022-07-1317:49richiardiandrearight#2022-07-1317:49thhellerthing being the thing referenced in the build config#2022-07-1317:49richiardiandreathank you Thomas#2022-07-1318:01thhellerdoes that runtime just accept the watch output as is or do only release builds work?#2022-07-1318:02richiardiandreaI am still trying to get the watch - haven't tried release yet#2022-07-1318:02richiardiandreabut I might cause I get this error now
[mf:err] TypeError: Cannot read properties of undefined (reading 'module_loaded')
    at /home/cokap/git/arudik-website/cloudflare-workers/.cljs/backblaze-download-token-to-secrets.js:92:33
as shadow.cljs.devtools.client.env is undefined
#2022-07-1318:03richiardiandreatrying :console-support false`#2022-07-1318:03thhellertry a release build#2022-07-1318:03richiardiandreayeah#2022-07-1318:04thheller:console-support has nothing to do with the module stuff#2022-07-1318:04richiardiandreaok#2022-07-1318:04thhellerI'm guessing that it doesn't actually support the globalThis hacks the watch/compile builds do#2022-07-1318:04thhellerrelease might work though#2022-07-1318:04richiardiandreaoki, trying that as we speak#2022-07-1318:05richiardiandreaseems good apart from one little warning
npx wrangler dev --local
 ⛅️ wrangler 2.0.17 (update available 2.0.19)
-------------------------------------------------------
Your worker has access to the following bindings:
- Vars:
  - B2_APPLICATION_KEY_ID: "foo"
  - B2_APPLICATION_KEY: "bar"
╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit         │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
▲ [WARNING] Source maps with "sections" are not supported [sections-in-source-map]

    ../.cljs/backblaze-download-token-to-secrets.js.map:1:61:
⎔ Starting a local server...
╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit         │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[mf:inf] Worker reloaded! (0.54KiB)
[mf:inf] Listening on localhost:43843
[mf:inf] - 
[mf:inf] Updated `` object cache!
SCHD /cdn-cgi/mf/scheduled 200 OK (0.75ms)
#2022-07-1318:06thhellerpff who doesn't support sections these days#2022-07-1318:06thhellerall browsers do so they should too 😉#2022-07-1318:07richiardiandreayeah#2022-07-1318:07richiardiandreait is weird though, I am calling the code but nothing is printed out, I will debug further#2022-07-1318:24richiardiandrea@U05224H0W can I watch a release configuration?#2022-07-1318:25thhellerno#2022-07-1321:26richiardiandreaSorry to come back on this, but is shadow.cljs.devtools.client.env/ globalThis an issue can be solved with an additional bundler? Working against the release code is a bit slow (7s every run before I can try new code)#2022-07-1321:28richiardiandreaif I comment out // shadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets"); Things seem to work - having a REPL is nice maybe I'll just go with that 😄#2022-07-1321:32richiardiandreaWell ok, the JS runtime also needs to be hooked up here and I see 🐉s there as well#2022-07-1321:43richiardiandreaOk I guess I read this document and now at least I know more about the problem(s) https://github.com/thheller/shadow-cljs/blob/master/doc/esm.md#2022-07-1405:28thhellerwell as always. I cannot comment much without seeing actual code and actual errors. slack descriptions do not have enough information to make accurate guesses#2022-07-1405:29thhellerI would assume watch is possible, but I'm unsure about what the actual issue is#2022-07-1405:29thhellershadow.cljs.devtools.client.env.module_loaded("backblaze-download-token-to-secrets"); should be find and I'm unsure why it wouldn't be#2022-07-1405:29thhellerfeel free to setup a repro and I can probably tell you more#2022-07-1416:30richiardiandreaok I'll create a repo with some code#2022-07-1416:56richiardiandrea@U05224H0W here it is, I hope things are going to work there, let me know if you find any issue https://github.com/arichiardi/cloudflare-workers#2022-07-1416:57richiardiandreait's working with a bundler now and it all seems good, I could go for one module per worker and get rid of main.js but I am in the middle of something else now#2022-07-1418:23thhellerI guess I'm missing what I'm supposed to do once wrangler is running?#2022-07-1418:23thhellerafter adjusting your config to eliminate all the esbuild etc stuff#2022-07-1418:24thhellerI can run wrangler dev --local#2022-07-1418:24thheller
backblaze-download-token-to-secrets$ wrangler dev --local
 :partly_sunny:️ wrangler 2.0.21
--------------------
Your worker has access to the following bindings:
- Vars:
  - B2_APPLICATION_KEY_ID: "foo"
  - B2_APPLICATION_KEY: "bar"
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
▲ [WARNING] Using direct eval with a bundler is not recommended and may cause problems [direct-eval]

    out/cljs-runtime/cljs.core.js:37984:63:
      37984 │ return cljs.core.find_ns_obj_STAR_((function (){try{var ctxt = eval(cljs.core.first(segs));
            ╵                                                                ~~~~
⎔ Starting a local server...
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                                                                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Debugger listening on 
For help, see: 
Debugger attached.
[mf:inf] Worker reloaded! (2.40MiB)
[mf:wrn] Worker's uncompressed size exceeds the 1MiB limit! Note that your worker will be compressed during upload so you may still be able to deploy it.
[mf:inf] Listening on localhost:8787
#2022-07-1418:24thhellerso so me this looks like its working but no clue whats next#2022-07-1418:26thhellerI mean is supposed to show something? all I get is a white page?#2022-07-1418:29thheller
(ns cloudflare.workers
  (:require [cloudflare.workers.backblaze :as backblaze]))

(def exports
  #js {:fetch (fn [request]
                (js/Promise.resolve (js/Response. "Hello World.")))
       :scheduled backblaze/upload-download-token-to-secrets})
#2022-07-1418:30thhellerI get the expected Hello World. on http://localhost:8787/#2022-07-1418:32thhellerdunno why you are doing all the esbuild stuff. I'm not gonna look at that#2022-07-1418:32thheller
;; shadow-cljs configuration
{:source-paths
 ["src"]

 :dependencies
 []

 :builds
 {:workers {:target :esm
            :output-dir "backblaze-download-token-to-secrets/out"
            :modules {:main
                      {:preloads [shadow.cljs.devtools.client.env]
                       :exports {default cloudflare.workers/exports}}}
            :compiler-options {:output-feature-set :es-next}
            :js-options {:entry-keys ["main" "module"]}
            :devtools {:enabled false}
            :release {:compiler-options {:source-map true}}}}}
#2022-07-1418:33thhellerthats the build config. I guess the :preloads is needed because of a bug#2022-07-1418:33thheller(which would be the module_loaded being emitted when it shouldn't be, due to :enabled false)#2022-07-1418:34thhellerwatch and release both work just fine then#2022-07-1419:01richiardiandreaOk cool, don't worry about the esbuild stuff, it was there because I was fiddling with cljs.main as well#2022-07-1419:02richiardiandreaI think what I was missing was the :preloads then#2022-07-1419:02thhellerwell thats not required if you have :runtime :node but effectively that also does nothing#2022-07-1419:02thhellerit just happens to include the env namespace but nothing else#2022-07-1419:03thhellerREPL however I didn't get working#2022-07-1419:03richiardiandreahttps://clojurians.slack.com/archives/C6N245JGG/p1657823184135329?thread_ts=1657734026.412249&amp;cid=C6N245JGG About this, if you curlthat endpoint, some traces are written in the wrangler terminal#2022-07-1419:05richiardiandreaOk I am fine with watch only for now, thanks for your help, if you want me to try any build to get the REPL working I can also definitely do that#2022-07-1419:06richiardiandreawith cljs.main too there was no way to get the REPL running and I was only getting watch working with -O advanced#2022-07-1419:06thhellerI have the wrangler thing working. just too tired to dive deeper into the REPL support now#2022-07-1419:06thhellerbut the wrangler command also always seems to restart everything when you make a change#2022-07-1419:06thhellerso REPL doesn't really seem necessary or useful#2022-07-1419:07thhellerI mean could always just run a browser-repl or node-repl I guess#2022-07-1419:17richiardiandrea> I have the wrangler thing working. just too tired to dive deeper into the REPL support now Of course no worries > I mean could always just run a browser-repl or node-repl I guess right, that probably would suffice, I'll try to see if it "sees" the wrangler runtime, probably now that will work#2022-07-1419:23thhellerwho sees what?#2022-07-1419:23richiardiandreaah I see what you mean now, the node-repl would not need wrangler at all#2022-07-1419:23richiardiandrea(sorry it's been a while since I last used shadow-cljs)#2022-07-1319:38NickNameWhen I quit from npx shadow-cljs browser-repl, I get this really long error report:
Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
…
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Worker shutdown.
I'm wondering if there is something wrong with my setup. Or is it possible to disable this output? It is not critical, just annoying that terminal gets spammed with 50+ lines.
#2022-07-1407:26thhellerhow did you quit it? which OS is this? which shadow-cljs version? which java version? I've never seen this so dunno what would be causing it#2022-07-1412:06NickNameSorry for not providing all the info from the beginning. > how did you quit it? Ctrl + C > which OS is this? macOS Big Sur 11.6.1 > which shadow-cljs version? 2.19.6 > which java version? openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-39) OpenJDK 64-Bit Server VM (build 17.0.1+12-39, mixed mode, sharing)#2022-07-1416:44thhellerhmm yeah dunno. I dont have a mac available with that version. versions all seem fine. I have no guesses as to what that may be#2022-07-1416:45thhellerdoes it also happen if you exit with CTRL+D?#2022-07-1419:36NickNameIt doesn't happend with CTRL+D, though CTRL+D in itself works somewhat strange — I have to press them a few times to exit (no reaction on single pressing)#2022-07-1419:42NickNameAnother thing I noticed — this behavior is only produced when I start shadow server from scratch i.e. when there is no running server at the time I do shadow-cljs watch … In such a case it is not so annoying as I think I’m going to keep the server always on.#2022-07-1402:05steveb8nQ: I upgraded to latest shadow and I’m getting a new release build error: Invalid Regular Expression. Anyone seen/fixed this? more in thread….#2022-07-1402:05steveb8nit’s because of this line/lib https://github.com/mesqueeb/case-anything/blob/production/src/utils.ts#L7#2022-07-1402:06steveb8nES6 does support unicode regexes so I’m trying to figure out the correct shadow config to support this for advanced compile#2022-07-1402:06steveb8nworks fine in dev builds#2022-07-1402:08steveb8nusing :output-feature-set :es-next doesn’t seem to help as I hoped#2022-07-1402:13steveb8nthis seems to suggest that only /u style regexes are supported in ES6 https://stackoverflow.com/questions/280712/how-can-i-use-unicode-aware-regular-expressions-in-javascript#2022-07-1402:13steveb8nbut I don’t understand how that lib could be generally used in that case#2022-07-1402:18steveb8nI’m not actually using that lib (it’s a transitive npm dep) so I could trying excluding it as a fix#2022-07-1402:32steveb8nor is there a way to exclude an npm source file (since I don’t need it)?#2022-07-1402:49steveb8nworst case I have to fork/override the lib but I’d prefer not to do that#2022-07-1403:04steveb8nhmm, case-anything is a dep of remirror which is the lib I need. I could also try excluding it there#2022-07-1404:24steveb8n@U0509NKGK something to watch out for if you are using remirror#2022-07-1405:40robert-stuttafordthanks Steve! we've ended up going full tiptap 🙂#2022-07-1406:21steveb8nAh yes, makes sense for a rum app#2022-07-1407:27thhellerdo you have the actual full error including stacktrace/location info?#2022-07-1407:28thhellerthe closure compiler is sometimes a little overeager when it comes to validating code#2022-07-1407:28thhellerand sometimes complains about stuff that is actually perfectly valid#2022-07-1407:29thhellerthere don't seem to be any open issues currently https://github.com/google/closure-compiler/issues?q=is%3Aissue+is%3Aopen+Invalid+Regular+Expression#2022-07-1407:29thhellerbut that doesn't mean its not a bug#2022-07-1408:05steveb8nI’ll generate a full error now…..#2022-07-1408:06steveb8nUncaught SyntaxError: Invalid regular expression: /^[a-zà -öø-ÿ]+|[A-ZÀ-ÖØ-ß][a-zà -öø-ÿ]+|[a-zà -öø-ÿ]+|[0-9]+|[A-ZÀ-ÖØ-ß]+(?![a-zà -öø-ÿ])/: Range out of order in character class (at main.js:3287:266)#2022-07-1408:07steveb8nwhen I look at that line in the generated js, it seems to be from the case-anything transitive npm dep#2022-07-1408:08thhellerthats not a compiler error thats a runtime error#2022-07-1408:08steveb8nmy suspicion in Google Closure as you say#2022-07-1408:08thhellerwhich may just mean that its an encoding issue#2022-07-1408:08thhellerdo you set you page encoding properly?#2022-07-1408:08steveb8ntrue enough#2022-07-1408:08thheller<meta charset="utf-8"> in the head?#2022-07-1408:08steveb8nno I didn’t check that. will do now#2022-07-1408:09steveb8nthx#2022-07-1408:10steveb8nboom! that fixes it. once again you are a legend#2022-07-1408:10steveb8nmuch appreciated. I’m glad I only spent 3 hours before I decided to wait to ask you 🙂#2022-07-1408:11thheller😛#2022-07-1406:54p-himikWhen working with JS files within a CLJS project, I find that changing those JS files results in shadow-cljs reloading them, along with the CLJS files that use them. However: • Still the old code is used - so I have to refresh the page to make it take the changes into account • Other JS files that use the changed JS files don't seem to be reloaded (according to what I've seen in the shadow-cljs' WebSocket packets), so I assume even if the previous item is fixed, it still won't work correctly in some cases Is it possible to fix the above?#2022-07-1407:30thheller@p-himik define JS file. reloading should only sort of work for ESM code. commonjs code can't really be reloaded#2022-07-1407:31thhellernot a whole lot of people use many JS files directly (me included), so there might be bugs or problems#2022-07-1407:32thhellerand as always its directly exposed to and relying on the closure compiler. they frequently change how they rewrite stuff and I might miss those changes if they need adjustment on the shadow-cljs side#2022-07-1407:33p-himik> define JS file I'm still a bit hazy on this I'm afraid. Ones that use const {x} = require('/something'); - you recommended this approach to me some time ago.#2022-07-1407:36thhellerthats commonjs. its treated like node_modules files so less reliant on closure compiler rewriting#2022-07-1407:37thhellerbut also less friendly to reloading and stuff#2022-07-1407:37thhellerI mean you are aware of how much more complicated hot-reload is in the JS world#2022-07-1407:39p-himikOnly superficially, and the most recent piece of knowledge that I have is that people from the React ecosystem have apparently figured out how to reload Reacts apps properly, without even losing any state. But that's probably not relevant here at all.#2022-07-1407:40thhellerwell, yes its possible. but it is much more complicated than just "eval this new code over the old one"#2022-07-1407:41thhellerbut yeah, shadow-cljs doesn't support reloading commonjs code at this time#2022-07-1407:41thhellerI mean it attempts to but it is fairly limited#2022-07-1407:42p-himikRight... Shame, page refreshing it is then. Thanks!#2022-07-1414:14bbss@p-himik fwiw, I also started playing with react fast-refresh. I :require some JS here and there and sometimes it reloads sometimes it doesn't haven't really dug into that too deep. It's cool to re-eval a react component from the repl and have only the relevant components reload. To get used to fast-refresh I even turned off file-save and only used eval from my ide to change components, it's quite instant, whereas file save reload can start adding up when the files get bigger. Although forgetting to save a file when you inevitably refresh your browser/state sucks, so I'd say having both is nice 🙂#2022-07-1414:15bbssExtended the hx defnc macro as explained here: https://github.com/lilactown/helix/blob/master/docs/experiments.md#fast-refresh.#2022-07-1417:12mkvlrI’m trying to use a js lib that uses wasm: https://github.com/lekoala/barcode-detector-zbar and getting:
Failed to inspect file
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin

it was required from
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/load-browser.js

Errors encountered while trying to parse file
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin
  {:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}
I’ve read https://github.com/thheller/wasm-pack-cljs but failing to understand how to adjust it for this use case. Any pointers would be appreciated. 🙏
#2022-07-1418:39thhellershadow-cljs doesn't support bundling wasm files which this appears to require#2022-07-1418:41thhellerhttps://unpkg.com/browse/zbar.wasm@2.1.1/dist/load-browser.js even specifically mentions webpack in the comment#2022-07-1419:40mkvlralright, will load it via a script tag for now, thanks.#2022-07-1419:44thhelleryeah still need to investigate how webpack wasm bundling actually works. it just seems to do something but I couldn't find docs on this. should be easy enough to support but given the non-standard nature I was going to wait for a more proper standard#2022-07-1520:01kennyHi. I'm experimenting with react-table and am curious if there's a way to get exceptions thrown using non-minified library code. For example, when doing something wrong, I receive an exception like this:
index.production.js:22 Uncaught Error
    at s$jscomp$0 (index.production.js:22:1173)
    at eval (index.production.js:22:4096)
    at Array.map (<anonymous>)
    at t (index.production.js:22:4096)
    at W.e$jscomp$2.getAllColumns.a$jscomp$2.key (index.production.js:22:4096)
    at Object.eval [as getAllColumns] (index.production.js:22:477)
    at eval (index.production.js:22:2390)
    at Object.eval [as getHeaderGroups] (index.production.js:22:365)
    at Function.compute$ui$components$rtable$Table_STAR_ (rtable.cljs:28:27)
    at Function.eval [as cljs$core$IFn$_invoke$arity$3] (core.cljs:3935:15)
The stacktrace points to lines in the depths of a minified line in the file /node_modules/@tanstack/react-table/build/umd/index.production.js. The process of debugging is a game of guess and check since it's non-obvious what code is failing there. In that same /node_modules/@tanstack/react-table/build/umd directory, I see an index.development.js, and I'm wondering if I could tell shadow to switch to that in hopes the stacktrace becomes usable during development.
#2022-07-1520:11thhelleryou can use :resolve to control what gets included https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2022-07-1520:12thhellerso :js-options {:resolve {"@tanstack/react-table" {:target :npm :require "@tanstack/react-table/build/umd/index.development.js"}}}#2022-07-1520:13winsomeI'm trying to convert a project over to use shadow-cljs, but the compilation process blows up when it tries to load babashka.sci. In order to narrow down the problem, I've got it down to this repro:
npx shadow-cljs browser-repl
# wait for the repl to come up
(require '[sci.core :as sci])
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (require (quote [sci.core :as sci])), :source "(require '[sci.core :as sci])", :tag :shadow.cljs.repl/process-ex}
        shadow.cljs.repl/process-read-result (repl.clj:504)
        shadow.cljs.repl/process-read-result (repl.clj:478)
        shadow.cljs.repl/process-input (repl.clj:641)
        shadow.cljs.repl/process-input (repl.clj:619)
        shadow.cljs.devtools.server.worker.impl/eval82029/fn--82032 (impl.clj:698)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--81669/fn--81670/fn--81678 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--81669/fn--81670 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--81669 (util.clj:241)
        java.lang.Thread.run (Thread.java:829)
#2022-07-1520:13thhellerdoesn't it tell you what that uncaught error was?#2022-07-1520:14winsomeThere's a long stacktrace, which points to a null pointer while trying to compile sci.#2022-07-1520:14winsomeI'm not sure the best place to ask, here or sci, so I thought I'd start here with the repl command error#2022-07-1520:14borkdude👋#2022-07-1520:15borkdudeA repro would be most helpful, in the form of a repository that we can clone locally#2022-07-1520:15borkdudeThis will automatically answer questions like: which version of SCI, etc, etc are you using#2022-07-1520:16winsome:thumbsup: , I'm on the latest version of sci and shadow, but I'll try to put together a repro repo#2022-07-1520:20borkdudeyou could also try wiping your .shadow-cljs and see if this helps. If that does help, then use the latest SCI commit on master#2022-07-1520:21winsomeI have done the .shadow-cljs wipe, that didn't fix it, but I can try with master SCI#2022-07-1520:21thhellerhmm does this problem go away if you (require 'cljs.analyzer.api) first before sci?#2022-07-1520:22borkdudeif wiping .shadow-cljs does not help, then it's probably not the problem we discussed recently#2022-07-1520:22thhellerwell if sci never properly declares a dependency on the analyzer stuff there is no guarantee it'll be compiled "before" sci#2022-07-1520:23winsomeAlright, my minimal repro isn't reproing, so that's useful to know#2022-07-1520:23thhellerso it may still be compiling given that :parallel-build defaults to true and another thread might still be working on it#2022-07-1520:23borkdudeok, could be#2022-07-1520:24thhelleralthough you are not compiling the self host version by default? the CLJ parts should all be loaded given that shadow-cljs uses them#2022-07-1520:24thhellerbut dunno what copy-var does exactly#2022-07-1520:25borkdudeah wait, an NPE in copy-var? yeah, that sounds familiar#2022-07-1520:25winsomerequiring cljs.analyzer.api before sci produces the same error as before#2022-07-1520:25borkdudetry bisecting on which copy-var call it fails#2022-07-1520:26borkdudeand then post a SCI issue#2022-07-1520:30winsomeOh wait, my code doesn't use copy-var at all, just create-ns new-var init parse-string eval-string* and eval-form. The NPE happens when trying to compile SCI. Also, it does compile just using the cljs compiler. Could you clarify what I should bisect through?#2022-07-1520:44borkdudeThis doesn't ring a bell. Repro would still be good.#2022-08-0321:37winsomeI've picked up this problem again, and unfortunately I can't reproduce it in a basic shadow-cljs project with just the sci library. So, my question is: what sort of reasons would make this nondeterministic? Given my naive reproduction isn't reproducing it, but it stubbornly persists in the actual project.#2022-08-0321:39borkdudeI don't think it's non-deterministic necessarily, you should just keep working on a repro#2022-08-0321:40borkdudee.g. take your existing project and remove things from it#2022-08-0321:40borkdudeuntil the error disappear and then start adding things back, this might give you some clues#2022-08-0321:40winsomeI've sliced and diced my project and it just tosses the NPE as soon as I add the sci.core require. I've removed every use of sci, and it's the require that causes the NPE.#2022-08-0321:41winsomeI'm not sure where to go from there - it's literally the same jar from my .m2 cache, same version of shadow-cljs, same version of clojure and clojurescript#2022-08-0321:42borkdudewhich sci version is this?#2022-08-0321:42winsome0.3.32#2022-08-0321:42borkdudecan you try the latest SHA from SCI master?#2022-08-0321:44borkdudeif your project is public, I could take a look#2022-08-0321:45borkdudeif the code is private, you could add me temporarily as a contributor. else I wouldn't know how to help you further.#2022-08-0321:45winsomeIt still tosses the NPE with SCI master.#2022-08-0321:46winsomeThe repo is public, let me add some local work to the branch and push it so you can see.#2022-08-0321:52winsomeAlright, check out the feature/shadow-cljs branch if you can spare the time: https://github.com/dpetran/db#2022-08-0321:53winsomeThe use of SCI is in fluree.db.dbfunctions.core.#2022-08-0321:56borkdude@winsome what build should I start?#2022-08-0321:57winsomeI've been working with the :browser build, but they all exhibit the same problem.#2022-08-0321:57borkdudeso npx shadow-cljs build browser right?#2022-08-0321:57borkdudes/build/compile#2022-08-0321:58winsomeyup! I've been using npx shadow-cljs server so I can mash recompile on demand#2022-08-0322:01borkdude@winsome I'm getting:
[:browser] Compiling ...
The required JS dependency "process" is not available, it was required by "node_modules/js-sha3/src/sha3.js".
#2022-08-0322:02borkdudewith npx shadow-cljs compile browser#2022-08-0322:03thhellernpm install shadow-cljs in the project is missing#2022-08-0322:04winsomeThat's not the error I get when I run npx shadow-cljs compile browser.#2022-08-0322:05winsomeI have shadow npm installed as a devDependency. FWIW, I have seen that error before, but not currently. Maybe I need to clear my caches.#2022-08-0322:05borkdudeI did npm install before, but npm install shadow-cljs helped#2022-08-0322:05thhellerhttps://github.com/dpetran/db/blob/feature/shadow-cljs/package.json#2022-08-0322:06thhellerthis has no shadow-cljs?#2022-08-0322:06borkdudeshadow-cljs wasn't in your package.json#2022-08-0322:06winsomeAre you looking at the feature/shadow-cljs branch? 506fdac#2022-08-0322:06borkdudeyes#2022-08-0322:06borkdude506fdac32041863dfc782fee0164bace49ac5399#2022-08-0322:07borkdudeanyway, now I could repro#2022-08-0322:18borkdude@winsome It seems to be something in 0.3.32 and/or with CLJS newest - it works with 0.3.31.#2022-08-0322:20borkdudeAlthough outside your project this works fine:
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.11.60"} org.babashka/sci {:mvn/version "0.3.32" }}}' -M:dev -m cljs.main -re node
cljs.user=> (require '[sci.core])
nil
#2022-08-0322:21borkdudeInside your project the above works with 0.3.31 but not with 0.3.32. Not sure why, perhaps an interaction with shadow or so#2022-08-0322:22borkdudeAh, if I remove the specific clojurescript version from your project, then 0.3.32 also works#2022-08-0322:22winsomeThanks for investigating! I'll downgrade for now - does 0.3.32 have anything critical?#2022-08-0322:22winsomeOh, nice!#2022-08-0322:23borkdudePerhaps it's something with shadow + a specific clojurescript version that pulls in some conflicting things. @U05224H0W might know#2022-08-0322:23borkdudeI can look into the specific NPE problem tomorrow, getting late here#2022-08-0322:24winsomeI think I'm happy to depend on shadow to do things unless I hear otherwise. Thank you for your time and problem solving!#2022-07-1520:14thheller@winsome need the full stacktrace. otherwise can't tell you anything#2022-07-1520:15winsome#2022-07-1520:18kennyAh that did it. Thank you Thomas!!#2022-08-0321:37winsomeI've picked up this problem again, and unfortunately I can't reproduce it in a basic shadow-cljs project with just the sci library. So, my question is: what sort of reasons would make this nondeterministic? Given my naive reproduction isn't reproducing it, but it stubbornly persists in the actual project.#2022-07-1622:28john@thheller So with the Service Worker hack I got blocking semantics working and added a derefable future and ported injest's auto-parallelizing =>> thread last macro to it and I'm seeing between 2 to 5 times performance increases over a single thread for heavy work loads, even while serializing the work across all the workers. Got a new update showing the latest https://clojureverse.org/t/in-mesh-one-step-closer-to-threads-on-the-web/9069/2?u=john_newman. You might also like the yield thing.#2022-07-1807:30roklenarcicI’ve got a question: is it normal that namespace reloading on changes stop working if you’ve got a Warning. Whenever I save a file the code automatically compiles and the browser starts running the new code immediately. But if I’ve got a warning then only the compile happens, the browser still runs the old code. The warning I don’t really know how to get rid of:
59 |                   (if (satisfies? obj IWithMeta)
-----------------------------^--------------------------------------------------
Cannot infer target type in expression (. IWithMeta -org$clojars$roklenarcic$indexed-db$store$obj$)
#2022-07-1807:32thhellerwrong argument order. should be (satisfies? IWithMeta obj), with the other order this will always end up as false, so probably not what you intended 😉#2022-07-1807:40roklenarcicthanks#2022-07-1807:42thhellerbut to answer your actual question. yes, warnings stop the reload because they should be fixed. you may however set :devtools {:ignore-warnings true} if you'd still rather want the reload. this can of course result it actual errors during load so it is not recommended.#2022-07-1807:43roklenarcicOk, thank you for the explanation. I don’t intend to turn the mechanism off, I was just surprised by it#2022-07-1807:44roklenarcicPerhaps the warning blurb could contain some text to explain that namespace wasn’t reloaded#2022-07-1816:28DiegoHello, I have a project on typescript that is used as node_module in shadow-cljs project. Is there a way that I can make shadow-clj pick up the changes that I do on the typescript project after every time I compile the typescript project? Currently it seems like I have to restart the repl every time.#2022-07-1816:44thhelleryou can touch node_modules/your-package/package.json to invalidate the cache shadow-cljs keeps for node_modules#2022-07-1817:25Diegoah got it, thanks#2022-07-1822:29DiegoActually it doesn’t seem to be working, I am also trying to touch the built files, with no luck#2022-07-1823:10steveb8n@diego.vid.eco I have a similar setup. in my case, webpack converts the typescript into a module that can be used by the shadow project. when I make a change in typescript, the javascript artifact produced by webpack is updated and shadow automatically sees that it has changed because the artifact is in its source path(s). is that true for yours? i.e. is the javascript artifact from the typescript project being regenerated into a location that shadow knows about?#2022-07-1823:11Diegonot at the moment, but it could#2022-07-1909:32bitbltHello there! Just started my first clojurescript project! I see that for js npm dependencies the usage is pretty straightforward (just a require in the ns), but what about asset related dependencies like normalize.css? How do I link it in my index.html? Is there any kind of preprocessor?#2022-07-1912:10thhellershadow-cljs does not (yet) support any CSS processing so you need to use external tools (eg. postcss) for that#2022-07-1915:17AspirationalHi. I have some issues with hot reloading. Tested it with custom var e.g. js/Date.now. When I change some text in my reagent component, shadow recompiles but I do not see my changed text within the component, but the component is re-rendered and the timestamp changes. Please look at the screenshot#2022-07-1915:37thhellercan't see how you are using this so can't help much. maybe this helps https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html, lists a few common gotchas#2022-07-1915:37thhellerwhere and how is home-panel used is the question?#2022-07-1917:40AspirationalI have read "list with few common gotchas" and tried them. But I still can't figure it out. I have attached my app lifecycle. It's simple but I can't make hot reloading work fully. reagent triggers rerender. timestamp is changing but other component text changes only after full page reload#2022-07-1917:41thhellerso since you are deref'ing the current route there I assume that the function is in there#2022-07-1917:42thhellerand that is the problem. you put the function in the atom in some place, which remains the function it was when it was put in#2022-07-1917:42thhellersince only the namespace reference is updated#2022-07-1917:42thhellerthat would be the Holding Code references in State described in the blog post#2022-07-1916:10Mitul ShahDoes anyone use phosphor-react with shadow-cljs? We use it, but since there’s no tree-shaking in shadow, the package gets fully imported#2022-07-1916:16Mitul Shahi’ve tried phosphor-react/icons/IconName :default IconName but no luck#2022-07-1916:26thhellerno luck means?#2022-07-1916:31Mitul Shahget error that file couldnt be found#2022-07-1916:33Mitul Shahi scanned through similar questions in the slack and the packages have alias (@) imports, wonder if that makes a difference #2022-07-1916:35thhellerlooks over the actual file structure of the package#2022-07-1916:35thhellereither in your node_modules/phosphor-react folder or online via https://unpkg.com/browse/phosphor-react@1.4.1/ for example#2022-07-1916:35thhellerdon't look at the source, look at the actual published package#2022-07-1916:36thhellerI see some files in dist/icons? so that would be phosphor-react/dist/icons/...#2022-07-1916:55Mitul Shah
The required JS dependency "phosphor-react/dist/icons/Info" is not available,
same error
#2022-07-1916:56thhellerbecause thats not the filename#2022-07-1916:56thhellerjust put in the entire filename including the extension(s). thats all it is, looking for a file in the package#2022-07-1916:58Mitul Shahwooo, phosphor-react/dist/icons/Info.esm.js works thank you#2022-07-1917:34Andrew LaiHi Shadow channel! We’re building a re-frame app with Shadow and wanted to add an image to a React component. In JS-land, I believe you can directly import the image, using, for example:
import logo from '../logo.svg';
https://stackoverflow.com/a/47487760 I found this thread, mentioning that this can be done with Shadow in React Native. Should we expect this solution to also work with React/JS? Is there any other preferred method for including an image? (js/require "./../../resources/img.png") https://clojurians.slack.com/archives/C6N245JGG/p1571922982374700
#2022-07-1917:34thhellerno, that is specific for react-native#2022-07-1917:35thhellerI generally just put images and stuff into my public folder and reference them by name, so just [:img {:src "/path/to/file.png"}] or whatever. no require or anything else to find the image.#2022-07-1917:38Andrew LaiCool! Will that include the images at build time, or do they need to be served from a Backend to be accessible?#2022-07-1917:39thhellerno, images are never included in a build. that would make it absurdely large#2022-07-1917:42Andrew LaiGotcha. I’m definitely not an expert in JS/React land. When someone does this statement in JS from a create-react-app project, import logo from '../logo.svg';, does that not bundle the image into the build? I don’t have a strong enough mental model of how the image asset gets included, and I’m not sure where to look to build that model. I’m reading https://create-react-app.dev/docs/adding-images-fonts-and-files/ for trying to build my mental model. What I understood was that Images do get directly included into the build. But is that just unique to how create-react-app works (and shadow works differently)?#2022-07-1917:44thhellerin case of svc it might get inlined but most of the time this just gives you a path where to find that logo#2022-07-1917:44Andrew LaiGotcha#2022-07-1917:44thhellercreate-react-app (webpack) then moves the file to that place#2022-07-1917:48thhellerfor your own code it works just as well to just keep the file in that place from the start 😉#2022-07-1917:50Andrew LaiGotcha. So what I’m taking away is that being able to import non-SVG image assets directly is a feature of how Webpack bundles Javascript modules, and it relocates them after bundling. In contrast, importing svgs may just directly inline the image, and that’s also a Webpack feature.#2022-07-1917:55thhellerI don't actually know if it ever inlines svgs, just saying its possible#2022-07-1917:55thhellerbut yes, its a webpack feature#2022-07-2000:53lsenjovWhat does check actually do? ie shadow-cljs check app There's an example in the docs, but doesn't actually say what it does#2022-07-2004:57thheller@lsenjov it runs the closure compiler type checker over the code. unfortunately that is very noisy and produces very many false positives, so I never made it an official documented feature#2022-07-2004:57thhellerexterns inference does a better job most of the time#2022-07-2009:03ullrichHello friends 👋 We’ve recently updated a project from ClojureScript 1.10.879 to 1.11.60 and from ShadowCLJS 2.15.12 to 2.19.6. Since the upgrade we’re seeing a new runtime issue though: Property '$jscomp' doesn't exist The project is a React-Native app, using the Hermes JS engine. Unfortunately https://hermesengine.dev/docs/language-features/ so we need to target ES5, but so far we could live with that. As far as I understand $jscomp points to an issue with polyfills not working correctly. Not sure which one specifically though. That $jscomp error goes away when targeting ES6, but is replaced with other ES6 issues, in particular Property 'Long' doesn't exist. I was wondering if there’s a way to pull in polyfills explicitly using force-library-injection, but I don’t know which polyfill would bring Long and did not find any in https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/js/polyfills.txt inside the Closure project. Any suggestions how to dig deeper into the issue? I’ve already tried cleaning .shadow-cljs . Thanks 🙌#2022-07-2009:07thhellercan't say without more context. $jscomp for polyfills or other compiler generated code that is correct.#2022-07-2009:08thhellerProperty '$jscomp' doesn't exist when does it say that? did you check the generated source if its actually defined? just search for $jscomp= or $jscomp =? maybe it is defined just not in a way that hermes find it?#2022-07-2009:09thhellersince you are using react-native doesn't metro perform the polyfilling for you? why have the CLJS do it?#2022-07-2009:11thhellerLong isn't a polyfill? its just a regular closure library class so I'm not sure how this relates?#2022-07-2013:04ullrichI’ve done some more digging, here’s some more info and what I’ve found so far: • The error at app runtime, even before a debugger can attach. There’s no stacktrace, just a oneline log in metro • I compared the shadow output before and after the update and did some divide and conquer and found that after the update there’s a new SHADOW_ENV.evalLoad("goog.iter.es6.js"... that wasn’t present before. Inside of it there’s a call to $jscomp.inherits(...) which seems to be the one that triggers the error in metro (confirmed by changing the code, renaming $jscomp to something else which changes the error output)#2022-07-2013:11ullrichIt seems that the es6 iter is required from various collection types now, i.e. from goog.structs.map which in the updated version has two new requires: goog.iter.es6 and goog.collections.iters#2022-07-2013:21thhelleryes, a variety of things in the closure library got modernized and use es6 features#2022-07-2013:22thhellerbut $jscomp should be defined regardless. did you check if it is ever assigned anywhere?#2022-07-2013:22thhellerI maybe assumed that react-native is just capable of es6+ and polyfilling isn't necessary and never handled $jscomp setup because of that#2022-07-2013:23thhellerbut in the other targets this is automated so should be for react-native too#2022-07-2013:23thhellermight be enough to try to prepend global.$jscomp = {} to the generated output as a test#2022-07-2013:24thhellermy guess is the assignment actually exists but is not exported as a global#2022-07-2013:24thhellerand as such the code cannot find it#2022-07-2013:26ullrichgoog.base contains this
var jscomp = goog.global["$jscomp"];
  if (!jscomp) {
    goog.global["$jscomp"] = jscomp = {};
  }
but it’s part of the goog.transpile_()
#2022-07-2013:27thhellerno, thats not it#2022-07-2013:29ullrichAdding global.$jscomp = goog did the trick.#2022-07-2013:30thhellerthats not correct, it is not goog. should be {}#2022-07-2013:30ullrich^^ but that would not help when the code is calling $jscomp.inherits(...)#2022-07-2013:31thhellerwell, I'm assuming that the polyfills are actually added to the code somewhere#2022-07-2013:31thhellergoog.inherits is not what $jscomp.inherits normally would be#2022-07-2013:32thhellerand most certainly goog does not contain any of the other polyfills you might need#2022-07-2013:32thhellerif they aren't added anywhere else either then polyfill output is just ignored#2022-07-2013:32thhellerjust search for $jscomp. uses in the code. it should include some assignments not just uses#2022-07-2013:33thhellerfeel free to open an issue about this, cannot look into it right now myself#2022-07-2013:34ullrichThis is the compiled goog.iter.es6 -> https://gist.github.com/stigi/2ac4488602b52552998fbaf74f92d28f As far as I can tell the $jscomp.inherits call is part of the extend from the https://github.com/google/closure-library/blob/99a2e56fd143a71ad16381c12017e53989e84b28/closure/goog/iter/es6.js#L116.#2022-07-2013:34ullrichThanks for your help already @U05224H0W. I’ll dig some more.#2022-07-2014:05ullrichIt seems to occur everywhere where a ES6 class is with extend is compiled with ES5 output format. Trying to come up with a small repro.#2022-07-2014:10thhellerI think you can stop your investigation. I think I just assumed that react-native was capable of es6+ and never bothered to include any polyfill code at all
#2022-07-2014:11thhellerbusy with other stuff so can't look at it right now#2022-07-2014:11ullrich@U05224H0W it actually reproduces in browser trargets as well. Trying shadow vs standard CLJS compiler now and will provide a small repro.#2022-07-2014:38ullrichReproduced the issue with standard clojurescript compiler in node env. Here’s a tiny repo with a demo https://github.com/stigi/clojurescript-es5-issue#2022-07-2014:39thhellerthis doesn't mean anything for shadow-cljs though#2022-07-2014:39thhellerit handles all of this on its own and doesn't use anything from the regular CLJS tools#2022-07-2015:04ullrichUpdated the repo with shadow reproduction steps. Not sure on which project to open an issue now. My guess would be https://github.com/google/closure-compiler then.#2022-07-2015:05thhellerwell for shadow-cljs in the shadow-cljs repo#2022-07-2015:06thhellerit might be an issue in the closure compiler but I'd want to confirm that on the shadow-cljs side first#2022-07-2015:07thhellerthere was a closure compiler issue before where it didn't properly keep track of which polyfills were added and rewrote but didn't add polyfills#2022-07-2015:07ullrichWe also stumbled across this https://github.com/google/closure-compiler/issues/3879#issuecomment-948583193 that I’m working my way through right now.#2022-07-2015:08thhellerhttps://github.com/google/closure-compiler/issues/3890#2022-07-2019:54ullrichFYI: compiler option :force-library-injection #{"es6/util/inherits"} did the trick.#2022-07-2019:55ullrichShall I open a PR adding that one to the list of existing polyfills here? https://github.com/thheller/shadow-cljs/blob/d6e14905022b719d2e240646417f53d9ee452e4d/src/main/shadow/build/closure.clj#L2568-L2585#2022-07-2022:14ullrichPut up a https://github.com/thheller/shadow-cljs/pull/1035 that fixes one more issue in the react-native target that did not yet make $jscomp available on the global scope (node target already did so though).#2022-07-2022:14ullrichPut up a https://github.com/thheller/shadow-cljs/pull/1035 that fixes one more issue in the react-native target that did not yet make $jscomp available on the global scope (node target already did so though).#2022-07-2120:56dpsuttonIs there a way to verify the running version of shadow from shadow.user? Ideally shadow/version or something similar?#2022-07-2204:11thhellerthere is (shadow.cljs.devtools.server.util/find-version) but no "official" API method for that or so#2022-07-2202:16johnSo for this webworker library, inmesh, I'm working on building a re-frame dashboard with the app logic moved into a webworker (similar to your split-todomvc, @thheller) - and the compile mode :none is working, but with :advanced release, I get a cryptic error. I made a repro branch in the inmesh repo here: https://github.com/johnmn3/in.mesh/tree/shadow-dashboard-repro/shadow_dashboard#2022-07-2202:22johnwhen I run npx shadow-cljs release core --debug and then npx shadow-cljs server I get this cryptic error:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
    at alpha.cljs:430:5
    at screen.js:10293:4
#2022-07-2202:24johnAnd that screen.js reference is just the last line of the file:
}
;
}).call(this); <- here
//# sourceMappingURL=screen.js.map
So I'm not sure which piece of code is calling spec erroneously in advanced mode
#2022-07-2202:26johnThat branch also has the latest future and =>> macros if anybody wants to play with them#2022-07-2202:26johnBut I'm guessing my advanced build issue has to do with the npm additions rather than the webworker stuff#2022-07-2202:27johnHaven't really tried the advanced compile stuff until this real-world example#2022-07-2202:33johnI went with mui v5 for the interface for now just for iterating rapidly with a pre-existing set of components#2022-07-2202:34johnBut I'm excited to try it out with shadow-grove soon, as I think grove's render architecture probably makes the most sense when pushing updates from a worker#2022-07-2204:15thheller@john can't say much about this error. first guess is always externs. Cannot read properties of undefined (reading 'prototype') could just mean that somewhere you handed something a reference which is undefined, which could be due to trying to access (.foo thing) and that foo getting renamed making it (.aB thing) or something, thus accessing an undefined field and failing#2022-07-2204:17thhellerI don't know much interop you do or generate so can't say#2022-07-2204:17thheller> But I'm guessing my advanced build issue has to do with the npm additions rather than the webworker stuff#2022-07-2204:17thhellerI'd say that is unlikely but certainly possible. Most of the time its interop in your code.#2022-07-2204:34johnEven with --debug ? It the trace seems to end in the reify call of spec.alpha's map-spec-impl#2022-07-2204:34thhellerone thing that pops out by glancing at the code is this#2022-07-2204:34thhellerhttps://github.com/johnmn3/in.mesh/blob/shadow-dashboard-repro/src/inmesh/core.cljs#L84-L88#2022-07-2204:35thhellershadow will be undefined in :advanced so shadow.cljs would give you the Cannot read properties of undefined (although not the prototype). just giving an example of how :advanced changes the layout of the code#2022-07-2204:35johnYeah, that makes sense#2022-07-2204:36thhellerand namespaces don't really exist anymore in :advanced#2022-07-2204:36johnah right#2022-07-2204:37johnyeah, realized those those calls were failing when I tried advanced compile, so I just defaulted to the shadow configs for this test#2022-07-2204:38thhellershadow-cljs defaults to not showing you inference warnings for library code#2022-07-2204:38thhellerso in the dashboard project you won't see inference warnings for inmesh#2022-07-2204:38johnI'll dig through and try to clean up the attr accesses#2022-07-2204:38johnah okay#2022-07-2204:38thhelleryou can set (set! *warn-on-infer* true) in the namespaces that do interop to always see them#2022-07-2204:39thhelleror just compile inmesh on its own via a test target or something#2022-07-2204:40thhellerhttps://github.com/johnmn3/in.mesh/blob/shadow-dashboard-repro/src/inmesh/core.clj#L49#2022-07-2204:41thhellerthat also looks like something that is very unlikely to work in advanced. assuming this is turning a function into a string?#2022-07-2204:41johnYeah#2022-07-2204:42johnI've had a similar thing working in advanced mode in the past, as long as the same advanced compiled artifacts exist on both sides of the io#2022-07-2204:42thhelleryou can try setting :compiler-options {:output-wrapper false} in the build config#2022-07-2204:43thhellerthat isolates the code a little less and creates thousands of globals instead of locals#2022-07-2204:43thheller(which may be necessary for the turn function into string thing)#2022-07-2204:44johnK, I'll try that#2022-07-2204:44johnAppreciate the pointers#2022-07-2205:09johnYeah, the webworkers are setting up and talking to each other. It's something on the main thread, wrt the compile configurations. I think a combination of configs that are just super uncommon, with enabling webworkers#2022-07-2205:11johnI think it's the reitit router brings in spec-tools at runtime#2022-07-2205:12johnreitit is doing coercions at runtime#2022-07-2205:18johnYeah, that was it#2022-07-2205:18johnMight try to use secretary instead#2022-07-2205:33johnNah, just getting rid of the coercions was enough. And I had to ^:export the fns in the inmesh.re-frame ns to get things working#2022-07-2205:33johnbut wow is it snappy in :advanced compile mode 😍 like you're not even using workers!#2022-07-2205:34johnShipping minified code over the wire is basically like bytecode. Super lightweight#2022-07-2205:44johnThanks for your help @thheller. Hoping to get this working on fig and plain cljs one day, but this is good enough to get stuff done with shadow for now. Big thanks for shadow!#2022-07-2206:37johnViewable here! https://johnmn3.github.io/in.mesh/#2022-07-2206:38johnUnfortunately I haven't figured out how to get the service worker to work outside of the root folder, which you can't serve on with github project pages (has to be on /in.mesh/) but I don't need it for this demo#2022-07-2206:57johnWell, the sw is loading, but I don't think it can do intercepts#2022-07-2207:29thheller@john it might break your setup but I'd generally recommend keeping service workers as their own build. seems better since it has its own lifecycle and should be independent of the page code itself only acting as a message passing relay of sorts#2022-07-2210:45PaulHey @thheller. I encountered the following issue and was wondering if it was a shadow-cljs issue or more of an cljs-itself issue and hence where to open up a ticket. Problem The “unreachable code” error message showed up when I didn’t put in the (catch ...) statement for the (try) block. Yet, it pointed to the line of the (go) statement which wrapped the try/catch block. Only prints the error when executing npx shadow-cljs release app, not with watch app. Example code which resulted in the error > unreachable code
(defn foo []
  (go ;; <-- loc which error points to
    (let [res (<p! awaited-promise)]
      (try
         (do-stuff)))))
Fixed
(defn foo []
  (go 
    (let [res (<p! awaited-promise)]
      (try
         (do-stuff)
         (catch ...)))) ;; <-- no error
#2022-07-2210:57thheller@paul.hempel that error is coming from the closure compiler optimizations, which are only done for release builds. the unreachable part is probably due to the go macro generating something unreachable in case of try without catch? so core.async would be the place to report it?#2022-07-2210:59PaulGood point. I’ll ask over there. Thanks 🙂#2022-07-2210:59thhellerif you get the unreachable code outside of go as well it would be a CLJS issue I guess#2022-07-2211:01PaulI’ll test that.#2022-07-2211:03PaulTested it, worked like a charm without the go and the catch.#2022-07-2211:04thhelleryeah the go macro does some wild rewriting so its probably just a case thats not covered#2022-07-2214:41Nikolas PafitisHello I'm migrating a project from using shadow-cljs.edn for specifying deps to deps.edn and I'm getting this issue:
[2022-07-22 17:17:08.779 - WARNING] :shadow.build/hook-config-ex - {:hook-idx 0, :hook-sym build-css/start-watch-hook, :build-id :app}
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling . at (cheshire/core.clj:170:6). {:clojure.error/phase :compile-syntax-check, :clojure.error/line 170, :clojure.error/column 6, :clojure.error/source "cheshire/core.clj", :clojure.error/symbol .}
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7119)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7099)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
	clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6122)
	clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6440)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7099)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
	clojure.lang.Compiler.analyze (Compiler.java:6749)
Caused by:
NoClassDefFoundError com/fasterxml/jackson/core/util/JacksonFeatureSet
	java.lang.Class.getDeclaredMethods0 (Class.java:-2)
	java.lang.Class.privateGetDeclaredMethods (Class.java:3166)
	java.lang.Class.privateGetPublicMethods (Class.java:3191)
	java.lang.Class.getMethods (Class.java:1904)
	clojure.lang.Reflector.getMethods (Reflector.java:498)
	clojure.lang.Compiler$HostExpr$Parser.parse (Compiler.java:996)
	clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
	clojure.lang.Compiler.analyze (Compiler.java:6793)
Caused by:
ClassNotFoundException com.fasterxml.jackson.core.util.JacksonFeatureSet
	jdk.internal.loader.BuiltinClassLoader.loadClass (BuiltinClassLoader.java:581)
	jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass (ClassLoaders.java:178)
	java.lang.ClassLoader.loadClass (ClassLoader.java:522)
	java.lang.Class.getDeclaredMethods0 (Class.java:-2)
	java.lang.Class.privateGetDeclaredMethods (Class.java:3166)
I don't have cheshire as an explicit dependency. I tried this on shadow-cljs v2.17.2 and v2.17.8. I also tried to add cheshire as an explicit dependency on it's latest version and the same thing happens. My builds build correctly though.
#2022-07-2214:48thhellerif you use deps.edn to manage your dependencies then thats a deps.edn question and the shadow-cljs version doesn't matter#2022-07-2214:49thhellermake sure your :paths and aliases match what your shadow-cljs.edn setup was before#2022-07-2214:50thhellerlooks like a build hook you are using wants to use cheshire?#2022-07-2214:53Nikolas PafitisI'm still using shadow-cljs.edn with :deps true option#2022-07-2214:54Nikolas PafitisIn my deps.edn file i just specify deps and paths which are identical. I did this because Cursive cannot index libraries and deps from shadow-cljs.edn#2022-07-2214:54thhelleryes, but that means that all dependencies are managed by deps.edn and this is an error you get for a missing dependency#2022-07-2214:56thhellercan't guess whats in your deps.edn or if cheshire maybe needs something else in there#2022-07-2214:57thhellerthere have been cases in the past where deps.edn didn't pick up something that lein/shadow-cljs did. can't remember details though.#2022-07-2215:01Nikolas PafitisI see, I've fixed it by using clj -X:deps tree and looked for the mismatches there. There were :exclusions that had to be added.#2022-07-2215:07borkdudeDoes shadow-cljs allow to write an equivalent of this with target esm?
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};
#2022-07-2215:07borkdudeI'm looking for prior art in this area#2022-07-2215:08thhellersure. thats nothing special at all#2022-07-2215:08borkdudehow?#2022-07-2215:08thheller(def that-thing #js {:port 3000 :fetch (fn fetch [request] ...)})#2022-07-2215:08thheller:exports {default your.ns/that-thing} in build config#2022-07-2215:09borkdudehmm right#2022-07-2215:09borkdudebut not in code itself right#2022-07-2215:09thhellerhmm?#2022-07-2215:09borkdudenot something like:
(defn ^:export default ...)
#2022-07-2215:10thhellerno, exports are configured via build config#2022-07-2215:10thhellerkinda has to be since it has to map the closure/cljs namespace system to ESM exports somehow#2022-07-2215:11borkdudeyeah no problem, just was wondering if something like this existed#2022-07-2215:12borkdudeI'm playing around with something that transpiles .cljs directly to .mjs and it automatically exports public vars. But default isn't a valid name for a var.#2022-07-2215:13borkdudeI could just go with:
(js/export ...)
#2022-07-2215:14thhellernot really since its not a function call#2022-07-2215:14borkdudeyeah with some special treatment#2022-07-2215:15thheller(def default "whatever") is perfectly valid though#2022-07-2215:15thhellerso just need to account for it getting munged to export$?#2022-07-2215:27borkdudeyou're right#2022-07-2215:27borkdudethat's a cleaner solution#2022-07-2215:53borkdudeHere it is in action ;) https://twitter.com/borkdude/status/1550508930438242304#2022-07-2220:04jcoyleSo glad you are making a lightweight cljs transpiler! Can’t wait to try it out#2022-07-2411:55geraldodevany user of react-query 4 series ? I'm having hard time trying to make ReactQueryDevtools to work. it has a condition depending on NODE_ENV to include component https://github.com/TanStack/query/blob/e9d62f4e125a9773559e5ed82f32fec5bd48a15e/packages/react-query-devtools/src/index.ts#L4 Even with export NODE_ENV=development at desktop level It does not work. Do you have any clue about this ? I'm asking here because I'm compiling with shadow. Can it be closure compiler ?#2022-07-2412:10thheller@geraldodev never look at the source code of a library to diagnose errors. this is typescript, so the actual code you are consuming is different#2022-07-2412:10thhellerwhat is the problem you are seeing?#2022-07-2412:20geraldodevthey say this conditional is for the devtools not to be included in the production version. What I'm seeing is a null function even with NODE_ENV = development on my .zshenv . When I invoke it returns null#2022-07-2412:23thhellersorry I'm missing context. what are you doing exactly? you are seeing a null function where?#2022-07-2412:23thhellerenv variables don't matter if you compile stuff for the browser for example#2022-07-2412:26geraldodevThe context is (:require ["@tanstack/react-query-devtools" :refer [ReactQueryDevtools]] .... (js/console.log "devtools function" (ReactQueryDevtools))#2022-07-2412:26thhellerah, I guess you are trying this https://tanstack.com/query/v4/docs/devtools?#2022-07-2412:26geraldodevyes 4.0.10 version#2022-07-2412:27thhellerbut you are calling it as a function when it is not a function? it is a react component?#2022-07-2412:27geraldodevjust to prove that it s returning nothing.#2022-07-2412:28geraldodevhttps://github.com/TanStack/query/blob/e9d62f4e125a9773559e5ed82f32fec5bd48a15e/packages/react-query-devtools/src/index.ts#L6 like in this variant#2022-07-2412:28thheller(ReactQueryDevtools) this is invalid, you cannot call this as a function#2022-07-2412:28geraldodevI did that after ($ ReactQueryDevtools) render nothing. $ is helix React.createElement#2022-07-2412:29thhellerok but you are diagnosing the wrong problem 🙂#2022-07-2412:29thhellerif you look at the contents of the actual package you are consuming#2022-07-2412:29thhellerhttps://unpkg.com/browse/@tanstack/react-query-devtools@4.0.10/#2022-07-2412:30thhellerif has a "browser": "build/umd/index.production.js", in its package.json, which tells shadow-cljs to include that file#2022-07-2412:30thhellerand https://unpkg.com/browse/@tanstack/react-query-devtools@4.0.10/build/umd/index.production.js just returns null always#2022-07-2412:31thhellerno NODE_ENV involved anymore since their build already stripped it#2022-07-2412:32thhellerwhat you can do is :dev {:js-options {:resolve {"@tanstack/react-query-devtools" {:target :npm :require "@tanstack/react-query-devtools/dist/umd/index.development.js"}}} in your build config#2022-07-2412:32thhellerthat'll include the development file for dev builds (watch/compile) but not release#2022-07-2412:33geraldodevThat'll do it. Thank's a lot. This little tool is invaluable to see what queries are in the cache.#2022-07-2412:42geraldodevIt says ExceptionInfo: :resolve override for "@tanstack/react-query-devtools" to "@tanstack//cdn-cgi/l/email-protection/build/dist/umd/index.development.js" which does not exist . In that case shadow try to fetch itself ?#2022-07-2412:46thhelleruhm that path is incorrect#2022-07-2412:46thhellernotice the @4.0.10, that needs to go, all it does it get node_modules/@tanstack/react-query-devtools/dist/umd/index.development.js#2022-07-2412:46geraldodevI did without it before#2022-07-2412:47thhellerI mean check what your node_modules folder looks like#2022-07-2412:47thhellermaybe its different for the version you have. my example should work otherwise?#2022-07-2412:48geraldodevoh i see.. it goes for the already fetched package on node modules directory#2022-07-2412:49geraldodevgrep devtools yarn.lock "@tanstack//cdn-cgi/l/email-protection^4.0.10": resolved "https://registry.yarnpkg.com/@tanstack/react-query-devtools/-/react-query-devtools-4.0.10.tgz#d1b3e5b1917f1c22bcee5830ef7af1ccfc4879f4"#2022-07-2412:50thhellerliterally just go in the folder#2022-07-2412:50thhellercd node_modules/@tanstack/react-query-devtools and check whats in it#2022-07-2412:51thhellerwhat error do you get if you use my example above?#2022-07-2412:52geraldodevresolve override for "@tanstack/react-query-devtools" to "@tanstack/react-query-devtools/dist/umd/index.development.js" which does not exist {:tag :shadow.build.resolve/invalid-override, :require-from nil, :require "@tanstack/react-query-devtools", :other "@tanstack/react-query-devtools/dist/umd/index.development.js"} ExceptionInfo: :resolve override for "@tanstack/react-query-devtools" to "@tanstack/react-query-devtools/dist/umd/index.development.js" which does not exist#2022-07-2412:52thhellerok, and then check what the folder looks like#2022-07-2412:53thhellerand check you are in the correct folder if you use :js-package-dirs in the build config as well?#2022-07-2412:53thhellerall this is trying to do is find a file on disk, should be easy to find#2022-07-2412:54geraldodevits @tanstack/react-query-devtools/build/umd/index.development.js#2022-07-2412:54thhellerand you are in the correct folder? I mean the directory that the shadow-cljs.edn file is in and then node_modules/@tanstack/react-query-devtools/dist/umd/index.development.js from there?#2022-07-2412:55thheller(and you are using a somewhat recent version of shadow-cljs?)#2022-07-2412:55thhellerI don't see anything wrong with it but check typos and such#2022-07-2413:00geraldodevNow it's not complaining anymore. But I'm seeing a pattern: Its looks like its the package 🙂 (as always)#2022-07-2413:01geraldodevBecause the development version returns null. umd/index.development.js#2022-07-2413:01thhellerhaha I didn't even look at the file#2022-07-2413:01thhelleryeah that makes no sense 😛#2022-07-2413:02thhellerI guess you can change it to node_modules/@tanstack/react-query-devtools/dist/esm/index.js#2022-07-2413:02thhellerthat at least has some code in it#2022-07-2413:04geraldodevthey declare a bunch of unicode chars on that file#2022-07-2413:04geraldodevErrors encountered while trying to parse file /home/geraldo/projetos/crudis/node_modules/@tanstack/react-query-devtools/build/esm/index.js {:line 158, :column 3, :message "Character '̆' (U+0306) is not a valid identifier start char"}#2022-07-2413:06geraldodevBut now I know the root cause, I'll ask them to fix the umd file. Thank you @thheller#2022-07-2413:33thhellerwell that won't change that particular error probably#2022-07-2413:33thhellerthe closure compiler doesn't like js objects with unicode keys such as Ã: 'A',#2022-07-2413:33thheller"Ã": 'A', would be fine#2022-07-2413:34thhellerhttps://github.com/google/closure-compiler/issues/3639 old issue unfortunately#2022-07-2413:49geraldodevhttps://codesandbox.io/s/intelligent-heisenberg-srmx02 if I try a code sandbox to repro and open the issue it does not happen 🙂 I guess it's operating at typescript level.#2022-07-2413:53thhellerno, as I said its closure compiler issue#2022-07-2413:54thhelleryou can just use webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-07-2413:54thhellerthat likely won't have those headaches#2022-07-2413:55geraldodevI was talking about the null component file. That does not happen on the codesandbox.#2022-07-2413:56thhelleryes, because webpack is likely inclusing the esm file by default#2022-07-2414:02geraldodevthey appear to be using rollup#2022-07-2414:03thhellersame#2022-07-2414:04thhelleryou can configure shadow-cljs to use the esm file by default too via :js-options {:entry-keys ["module" "browser" "main"]}. won't change the parser error though#2022-07-2512:39Samuel McHugh👋 Hello. Does shadow do some kind of caching on required npm modules per build? When I update some code in the node_modules (via npm link and a local project) I need to restart my build to see the changes.#2022-07-2512:41thhelleryes, it does. you can touch package.json in the node_modules package to make it reload#2022-07-2512:43Samuel McHughthanks, will check it out#2022-07-2513:01Samuel McHugh🤷 doesn;t seem to work for us. Maybe some added caveats because of the symlinking we're doing. Or some repl stickyness#2022-07-2520:07hjrnunesHi! I'm trying to load up apache-arrow 8.0.0 and shadow-cljs complains about the following:
Caused by:
IllegalStateException: Expected a property access: OBJECT_PATTERN 120:25  [length: 13] [source_file: node_modules/apache-arrow/io/adapters.js]
    STRING_KEY cmd 120:27  [length: 3] [source_file: node_modules/apache-arrow/io/adapters.js] [is_shorthand_property: 1]
        NAME cmd$jscomp$1 120:27  [length: 3] [source_file: node_modules/apache-arrow/io/adapters.js] [original_name: cmd]
    STRING_KEY size 120:32  [length: 4] [source_file: node_modules/apache-arrow/io/adapters.js] [is_shorthand_property: 1]
        NAME size$jscomp$23 120:32  [length: 4] [source_file: node_modules/apache-arrow/io/adapters.js] [original_name: size]
Is this a JS "target" issue e.g. es2015 vs esnext or something? I see there are multiple target packages published in https://www.npmjs.com/package/apache-arrow but I'm unsure which one I'd want... I have my shadow-cljs build configured with :output-feature-set :es6 Thanks!
#2022-07-2520:11thheller@hjrnunes that is an error from the closure compiler. can't say anything more about that either. maybe it is something it doesn't like. isn't this meant for node? are you trying to use it in a browser build?#2022-07-2520:12thhellerwhats the full error?#2022-07-2520:14thhellerseems to be polyfill related, so :compiler-options {:output-feature-set :es-next} should maybe make it go away?#2022-07-2520:15thhellerthe code is using generator functions. could be a problem in how closure rewrites those#2022-07-2520:28hjrnunes@thheller Yes, it's a browser build. I was under the impression this should support the browser too, but I'll double check. I'll update the compiler too, just in case. Thanks!#2022-07-2520:42thhellerunfortunately if the language level doesn't fix it the only option is going with webpack instead as desribed here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-07-2520:43thhellermaking repros with only the closure compiler is kinda tough#2022-07-2521:37hjrnunesOK, many thanks#2022-07-2609:24Samuel McHughHi, I'm trying to require a shadow-cljs project A into another shadow-cljs project B. Project A has an npm dependency on a git repo as described https://stackoverflow.com/questions/14187956/npm-install-from-git-in-a-specific-version. Project B doesn't seem to download this dependency when built. I also tried using the :npm-deps approach but it doesn't make a difference. I know I can just add the dependency manually to B but it increases the likelihood I update the npm package in one project but not the other. I was wondering if this is a known issue. Maybe it's a specific to this git approach of declaring an npm dependency.#2022-07-2609:28thhellerwhere did you put :npm-deps? likely just in the wrong place?#2022-07-2609:48Samuel McHughI put in my src folder in a file called deps.cljs#2022-07-2609:53thhellerand the src folder is actually the classpath root? not something like src/main?#2022-07-2609:54thhellerI never tested git dependencies myself so no clue if there is some special care that needs to be taken regarding those#2022-07-2611:54Samuel McHughWhen in the course of building project B does shadow prompt an npm install my-package given that a required library A, requires some package my-package?#2022-07-2612:10thhellernot "in the source of building project B" no. when starting shadow-cljs in project B is collects all deps.cljs files on the classpaths and then runs npm install for the packages found there, unless they are already declared as dependencies in the project B package.json#2022-07-2616:23thhellerhttps://code.thheller.com/shadow-grove-playground/0.3.0/ now with CSS support#2022-07-2618:14oliver markscan shadow support more complicated layouts where shadow.edn is not in the root and some of the sources are located relative to its location, think polylith where you would have shadow-cljs.edn in the project folder but the src's will be located in component or bases folder so this type of layout https://polylith.gitbook.io/poly/architecture/workspace#2022-07-2618:17thhellershadow-cljs.edn needs to be in the place where you run it. it doesn't care how you construct your classpath otherwise if you use deps.edn, so it doesn't matter at all where the sources are#2022-07-2618:19thhellerI don't know polylith otherwise to answer more specifically but looks to me like shadow-cljs.edn should be next to the workspace.edn? or whereever you run your project normally#2022-07-2618:22oliver marksgiven the architecture you could have multiple seperate shadow projects so you would create a project for each and include the components you want to share, so i believe project would be the correct place then to add ../../bases/base1/ and ../../components/ perhaps to the :source path key in shadow ?#2022-07-2618:23oliver markscurrently my project works but I don't get the hot reloading on any components, only on code inside the base#2022-07-2618:24thhelleryeah sorry I do not understand what you are saying because I'm not familiar with the polylith terms#2022-07-2618:25thhellerI would assume that you just use deps.edn to manage dependencies and only control builds in shadow-cljs.edn#2022-07-2618:26oliver marksperhaps the issue is that you have multiple deps.edn files, so a project has a deps.edn which includes the bases and components it uses, bases and components can also have there own separate deps.edn#2022-07-2618:27oliver marksso the projects deps.edn does not specify the src in :paths key its specified in the bases and components deps.edn files if that makes sense#2022-07-2618:28thhellerI assume the deps.edn you are references has a bunch of :deps that use :local/root?#2022-07-2618:28oliver marksyes correct so entries like this poly/web-ui {:local/root "../../components/web-ui"}#2022-07-2618:29thhellerok, and that deps.edn file is in the same dir as the shadow-cljs.edn file and you also run shadow-cljs in that dir?#2022-07-2618:29thhellerand you have :deps {:aliases [:whatever :aliases :you :need]} in said shadow-cljs.edn#2022-07-2618:29oliver marksyeah well i actually have it in bases as wel but thats from trying to make it work how I expect 🙂#2022-07-2618:30thhellersorry don't know what bases is#2022-07-2618:30oliver marksso a project has no code its just build files, bases is more like the curated app code built from components#2022-07-2618:33oliver marksor another way of thinking about it is the project pulls together the src from the base and components into a buildable artifact,#2022-07-2618:33oliver marksI may not be explaing this overly well 😕#2022-07-2618:38oliver markspart of the reason I have a shadow-cljs.edn file is actually for jack-in because when you jackin to a src file it search up the tree, there may be a better way than this though I would be happy to use the shadow file from a base anyway, its more about how I can make the code reload work on components#2022-07-2618:39oliver marksI was hoping some one had walked this path previously 😕#2022-07-2619:35thheller@olymk2 shadow-cljs is only interested in the classpath. and it should reload all files from the classpath, excluding all .jar files or git deps. so it should just work#2022-07-2619:35thhellerbut I cannot piece together how you actual setup looks so can't say#2022-07-2619:37FlavaDaveI’m having a hard time getting a repl going in a pulumi project. shadow-cljs watch works and I can connect to it. But am having difficulty getting a runtime for it. I have tried https://stackoverflow.com/questions/58060822/how-to-connect-a-clojurescript-node-repl-to-my-node-library-shadow-cljs-project but it then tells me that i need to run it with pulumi then when I run pulumi watch I get the error pulumi watch is not currently supported on darwin/arm64 . Can anyone think of a way around this?#2022-07-2619:49oliver marksokay thanks I will play around a bit more see where I get to, could be something I have done#2022-07-2619:53thhellerif a base looks something like this then it doesn't seem like something runnable? https://github.com/seancorfield/usermanager-example/tree/polylith/bases/web#2022-07-2619:53thhellerso I guess a project looks like something thats actually runnable? https://github.com/seancorfield/usermanager-example/blob/polylith/projects/usermanager/deps.edn#2022-07-2619:54thhellerso I guess thats where shadow-cljs.edn would be?#2022-07-2619:54thhellerI'm really not a fan of this entire setup so can't say for sure#2022-07-2705:58oliver marksyeah exactly that, it seems like the shadow-cljs.edn should sit in project, I know it has been gaining some traction of late as a way of organizing code but the cljs version is not as smooth as the clj code from my own experience, especially when it comes to things like jacking in to a cljs project, I know calva got support for polylith so that could be a cider issue#2022-07-2619:57thheller@dgonsalves22 sorry, I don't even know what pulumi is. could be that it just runs the code in such a containerized way that the actual runtime isn't able to connect back to shadow-cljs, which is required for the REPL to work#2022-07-2620:51FlavaDaveall good, If i figure out a solution i’ll post it in a thread of my original question#2022-07-2621:49Nikolas PafitisI'm getting this weird error for any shadow-cljs version >= 2.17.8 and it happens on two different projects as well.
➜  domo git:(develop) ✗ npm run shadow:watch:app

> 
From what I understand re-frame-10x depends on re-highlight which in turn depends on highlight.js. I tried with multiple versions of highlight in my package.json as well but with no success.
#2022-07-2621:56thheller@silencioseu its not the highlight.js version you need to change. its the re-frame-10x or re-highlight version#2022-07-2621:56thhellersee https://github.com/thheller/shadow-cljs/issues/1015 https://github.com/thheller/shadow-cljs/issues/1031#2022-07-2622:01Nikolas Pafitis@thheller You were right, I've fixed this by bumping both re-frame-10x and re-highlight version to their latest versions (re-highlight was a transitive dependency now I have it explicitly)#2022-07-2622:02Nikolas Pafitis@thheller When i tried to bump on re-frame-10x only it didn't work.#2022-07-2622:02Nikolas PafitisNvm it looks like it still happens#2022-07-2622:04thhelleryou can just bump the default stack size#2022-07-2622:05thhellerif you use shadow-cljs.edn to run things :jvm-opts ["-Xss16m"] at the root#2022-07-2622:05thhellerif you use deps.edn/project.clj you'll need to set it there somewhere#2022-07-2622:08Nikolas Pafitis@thheller Yep bumping the stack size in my deps.edn seems to have done the trick#2022-07-2622:12thhellerits probably still worth investigating what is including that file, best via a build report https://shadow-cljs.github.io/docs/UsersGuide.html#build-report. if its actually still in the release build that is.#2022-07-2622:13thhellerit includes a few huge files by default that you most likely don't need#2022-07-2622:13Nikolas PafitisWhy would that be a non issue with older shadow versions though?#2022-07-2622:14thhellerits not an issue with shadow#2022-07-2622:15thhellerits an issue with the closure compiler. dunno what change there caused this problem to happen, but can't go back to older versions of it since we want some of the newer fixes fixing other problems 😛#2022-07-2622:15thhellertechnically yes, I could be fixing it on the shadow-cljs side#2022-07-2622:16thhellerbut I had hoped that just not include the file in the first place would be a better fix#2022-07-2622:16thhellerturns out that it comes up much more often than anticipated. so I might have to work around it after all#2022-07-2622:16thhellerbut not tonight. gn8 🙂#2022-07-2622:17Nikolas PafitisGoodnight, fix 8s good enough for me#2022-07-2622:17Nikolas PafitisI don't know how to exclude files from highlight js, even though I'm probably using only one of them#2022-07-2707:49mkvlrwhen requring a https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js file, it doesn’t trigger a rebuild when I change it or detect changes to this file when I trigger a recompile by changing the requiring cljs file. Is this expected and is there a workaround?#2022-07-2707:50thhellerit should? works for me#2022-07-2707:52thhelleralthough it doesn't work for commonjs files probably? do you use ES modules (import/export) or commonjs?#2022-07-2707:53thhellerhmm nope also works for commonjs, although somewhat limited by design given its commonjs#2022-07-2707:53thhellerbut it definitely watchs and triggers recompiles#2022-07-2707:54mkvlrtrying to turn it on & off again…#2022-07-2707:55thhellerwhich version do you use? I tried with master, can't remember if there was something broken related to this in earlier versions maybe?#2022-07-2707:56mkvlr2.19.2#2022-07-2707:57thhellerhmm yeah that should be fine. definitely didn't change anything recently#2022-07-2707:57mkvlrshould I try a bump anyway?#2022-07-2707:57mkvlrI’ll also try a minimal repro#2022-07-2707:58thheller> it doesn’t trigger a rebuild when I change it or detect changes to this file when I trigger a recompile by changing the requiring cljs file.#2022-07-2707:58thhellerthe first part I checked#2022-07-2707:59thhellerthe second part confuses me? changing the requiring cljs file will recompile the js file?#2022-07-2707:59thhelleror do you mean a CLJS file required by the JS? I did not test that#2022-07-2708:00mkvlrno, I mean that when I trigger a recompile of the file requiring my js file (the file that has (:require ["/barcode-detector-zbar/BarcodeDetector.js$default" :as barcode-detector-polyfill]) in it, I don’t see changes to the js file#2022-07-2708:01thhellerI'm confused. what changes would you see in the JS file if you modify the CLJS file?#2022-07-2708:03mkvlrI modify both#2022-07-2708:03mkvlrso when I just modify the js, nothing happens#2022-07-2708:03thhellerok, thats the relevant bit. it should reload just fine, regardless of what you do to the CLJS file#2022-07-2708:04mkvlrk#2022-07-2708:04thhellerand changing the CLJS file should have no effect on what the JS files does whatsoever, so that is working as expected I guess#2022-07-2708:04thhellerI just tried by adding a console.log to the JS file and changing that log. works fine. but I dunno what else you might be doing?#2022-07-2708:07mkvlraha, I now moved my js from resources to src and now it works#2022-07-2708:07mkvlrusing :deps with shadow, but resources in on the classpath brought in by the root deps declaration#2022-07-2708:08thhelleroh yeah, resources are filtered out because many people put their outputs into resources/public and watching the resources folder thus becomes very noisy and expensive#2022-07-2708:10mkvlrah I see#2022-07-2708:10mkvlrgood to know, thanks!#2022-07-2709:06mkvlrnow running into Uncaught TypeError: gaa.default.setupPolyfill is not a function in advanced. Externs should be inferred automatically with :compiler-options {:infer-externs :auto}, is that correct?#2022-07-2709:10borkdudeI've posted a question/issue about target esm https://github.com/borkdude/cherry/issues/24 but feel free to discuss it here as well 🧵#2022-07-2709:12borkdudeThe context:
cherry-cljs/cljs.core.js
is a target esm-built .js file with core functions. It has e.g. js-keys which AFAIK doesn't depend on any other core function, so when only importing that, I'd expect that the tree-shaken build of a JS file, would be rather small.
#2022-07-2709:49thhellerwhat do you mean by "only importing"? shadow-cljs can only see what you configured and keeps all that stuff alive#2022-07-2709:49thhellerwhat you import the closure compiler cannot see?#2022-07-2709:50thhelleroh nvm. didn't see the link. answering there#2022-07-2710:08borkdudeThanks for your comment. I suspected something like that#2022-07-2709:14bbssI've just posted a question/issue about an as of yet non-existing :target :jupyter https://github.com/thheller/shadow-cljs/issues/1039. But am also on slack 👋#2022-07-2709:15bbssAs said there perhaps :esm would also be helpful for me 🙂#2022-07-2709:21borkdudeTarget :esm solves everything :) - Have you tried it @bbss?#2022-07-2709:23bbssYes, I've tried it but ran into some issues with it sadly. The target that got me furthest so far is :npm-module, but that doesn't seem to inject the repl, unacceptable!#2022-07-2709:23bbsshttps://twitter.com/lambduhh/status/1548064443564560386?t=Dvf-_w4d9xMDYdMFvAWjNA&amp;s=09#2022-07-2709:32mkvlrhttps://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs is the name / location fixed and I can’t put it elsewhere and reference it via :compiler-options :externs?#2022-07-2709:46thheller@mkvlr externs inference only covers CLJS files, no inference is done for JS files. yes, there are no options to configure the simplified externs#2022-07-2709:46thheller@bbss to get a REPL for :npm-module builds you just need to require the REPL client ns *from* javascript somewhere. so something like if (process.env.NODE_ENV === "development") { require("./path-to-cljs/shadow.cljs.devtools.client.browser"); } or so#2022-07-2709:50bbssOkay, good to know that should work! I think I am probably a special case for npm-module though, since eventually jupyter notebook extensions run in the browser anyway..#2022-07-2709:51thhellerthats no problem. the issue is just that the :npm-module build doesn't have a clearly defined "entry" point#2022-07-2709:51thheller:browser and the others do so shadow-cljs can ensure that the devtools client is loaded before those#2022-07-2709:51thhellerfor npm-module that is not the case because it can't tell which file you are going to access from JS#2022-07-2710:12bbssCould that also be why I ran into ReferenceError: shadow$provide is not defined#2022-07-2710:13thheller:npm-module doesn't use shadow$provide unless you specifically configure it? or was that :target :browser?#2022-07-2710:13thhellerI'll answer your issue in more detail later#2022-07-2710:14bbssThat was with :npm-module iirc :thinking_face: #2022-07-2710:14bbssOkay, thanks!#2022-07-2710:16thheller@bbss what would help if you setup a repo with stuff that does not work! much easier to look at an actual failing thing than just guessing#2022-07-2710:16thhellerI have never used jupyter so I'm not sure I can even get that running#2022-07-2710:17thhellerthis repo would just need to require added here somewhere https://github.com/jelmerderonde/jupyter-lab-parinfer/blob/master/index.js#2022-07-2710:17thhellerso just if (process.env.NODE_ENV === "development") { require("./lib/shadow.cljs.devtools.client.browser"); }#2022-07-2710:18thhellerbut yeah it would probably be easier with :target :esm#2022-07-2710:18thhellerI'll answer more later. gotta go 🙂
#2022-07-2710:20bbssOkay, will make a repro case for the failing import, thank you.#2022-07-2718:26agIs there a way to run shadow-cljs clj-repl and immediately execute some code in it? Right now, I'm having to do: clojure -M:dev:shadow-cljs clj-repl, and then inside the repl I have to type (integrant.repl/go). Can I do it in a single line? I've been trying to combine clj-eval and clj-repl options, but that doesn't seem to work.#2022-07-2719:16thhellerdo you actually intend to use the REPL provided by clj-repl or do you just leave that running and connect via nrepl or so?#2022-07-2719:34agHmmm. I haven't thought about it. What would be the difference? Would there be something blocking?#2022-07-2719:35thhellerno the answer just becomes more complicated 😉#2022-07-2719:35thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_calling_watch_via_clj_run#2022-07-2719:36thhellerbasically you create a (defn start {:shadow/requires-server true} [] (integrant.repl/go)) and shadow-cljs run that.ns/start#2022-07-2719:36thhellerwith a proper ns form with requires of course#2022-07-2719:41agOh, that's interesting. Let me try it out. I feel I'd have to come back with some more questions. Thank you Thomas.#2022-07-2719:03Drew Verleedoes shadow only consider the deps in the aliases passed to shadow-cljs.edn's :dep's key? e.g will i get foo and bar in this setup or just bar?
shadow-cljs.edn
:deps ["cljs"]


and my deps files

:deps {foo ...} :aliases {:cljs {:extra-deps {bar ....}
#2022-07-2719:10thheller:deps ["cljs"] does not activate any aliases :deps {:aliases [:cljs]} does#2022-07-2719:11Drew VerleeAgreed.#2022-07-2719:13Drew Verleeare the extra-deps in the aliases in addition to the ones in the deps :deps key?#2022-07-2719:14thhelleryes#2022-07-2719:14Drew Verleety ty. I was just setting up a project to test it. 🙂#2022-07-2719:38agwhat's the current stable version of shadow-cljs? I just tried upgrading to 2.19.8, but I'm getting Exception in thread "main" Syntax error compiling at (shadow/build/data.clj:362:5)... something that seems to be related to clojure.lang.Compiler.analyze. Do I miss an exclusion?#2022-07-2719:47thhellerwhats the full error? 2.19.8 is the latest yes#2022-07-2719:50agthis is the content of deps.edn, maybe you can spot something I don't.
{:paths ["src" "resources"]
 :deps
 {org.clojure/clojure        {:mvn/version "1.11.1"}
  integrant/integrant        {:mvn/version "0.8.0"}
  ring/ring-core             {:mvn/version "1.9.5"}
  ring/ring-jetty-adapter    {:mvn/version "1.9.5"}
  metosin/reitit             {:mvn/version "0.5.17"}
  hiccup/hiccup              {:mvn/version "2.0.0-alpha2"}
  org.clojure/tools.logging  {:mvn/version "1.2.4"}
  org.slf4j/log4j-over-slf4j {:mvn/version "2.0.0-alpha7"}
  org.slf4j/slf4j-jdk14      {:mvn/version "2.0.0-alpha7"}
  org.clojure/tools.cli      {:mvn/version "1.0.206"}

  ;; front-end
  org.clojure/clojurescript     {:mvn/version "1.11.4"}
  reagent/reagent               {:mvn/version "1.1.1"}
  re-frame/re-frame             {:mvn/version "1.3.0-rc3"}
  cljs-bean/cljs-bean           {:mvn/version "1.8.0"}
  day8.re-frame/http-fx         {:mvn/version "0.2.4"
                                 :exclusions  [commons-logging/commons-logging]}
  day8.re-frame/test            {:mvn/version "0.1.5"}
  hickory/hickory               {:mvn/version "0.7.1"}
  metosin/reitit-frontend       {:mvn/version "0.5.17"}
  metosin/reitit-schema         {:mvn/version "0.5.17"}
  re-frame-utils/re-frame-utils {:mvn/version "0.1.0"}
  inflections/inflections       {:mvn/version "0.13.2"}}

 :aliases
 {:shadow-cljs
  {:extra-paths ["test"]
   :extra-deps {thheller/shadow-cljs {:mvn/version "2.19.8"}}
   :main-opts ["-m" "shadow.cljs.devtools.cli"]}

  :dev
  {:extra-paths ["dev"]
   :extra-deps
   {integrant/repl {:mvn/version "0.3.2"}}}

  :test
  {:extra-paths ["test"]
   :extra-deps {io.github.cognitect-labs/test-runner
                {:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
   :main-opts ["-m" "cognitect.test-runner"]
   :exec-fn cognitect.test-runner.api/test}

  :build
  {:extra-paths ["src"]
   :extra-deps {io.github.clojure/tools.build
                {:git/tag "v0.8.1" :git/sha "7d40500"}}
   :ns-default build}

  :cider-cljs {:main-opts
               ["-m" "nrepl.cmdline" "--middleware"
                "[cider.nrepl/cider-middleware,cider.piggieback/wrap-cljs-repl]"]}}}
#2022-07-2719:50agI'm reinstalling npm packages and trying 2.19.8, again#2022-07-2719:50thhellerdefinitely remove clojurescript or bump it to 1.11.60#2022-07-2719:51thhellerotherwise looks fine#2022-07-2719:52agyeah, I think that was it. OMG, thank you so much.#2022-07-2719:49thhellerthat line is using commons-codec? I guess you maybe have that excluded somewhere when it shouldn't be?#2022-07-2719:50thhellerit has also been there for years 😉#2022-07-2719:58agI'm sorry, I have yet another one: when I'm in the repl and I run shadow.cljs.devtools.api/nrepl-select:app`, it complains :missing-nrepl-middleware. Do I need to add piggieback? I thought you don't have to when using deps.edn with shadow-cljs, no?#2022-07-2719:59thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2022-07-2720:00thhellerif you run your own nrepl server you need to add the proper nrepl middleware#2022-07-2720:00thhellerI guess in your :cider-cljs alias?#2022-07-2720:00thhelleror just use the nrepl server provided by shadow-cljs and don't launch your own 😉#2022-07-2720:09agI have added :repl-options {:init-ns user into :shadow-cljs alias, now when I run clojure -M:dev:shadow-cljs clj-repl, should I expect it to land me in user ns? Because it doesn't. It still starts in shadow.user#2022-07-2720:09thhellerno, that does nothing. nrepl doesn't look there. that was a lein specific config option#2022-07-2720:13thhelleryou can set :repl {:init-ns user} in shadow-cljs.edn at the top level. but that again would only affect the nrepl server started by shadow-cljs? which I guess you don't actually use?#2022-07-2720:13thhellerI'm a bit confused by your setup 😉#2022-07-2720:39agYes, it looks like I don't need :cider-cljs alias. with that :repl-options config you mentioned earlier.#2022-07-2720:14agOn slightly unrelated note, I'm getting these, btw:
------ WARNING #1 - :redef -----------------------------------------------------
 Resource: no/en/core.cljc:137:1
--------------------------------------------------------------------------------
 134 |   [s]
 135 |   (parse-number s #(#?(:clj Integer/parseInt :cljs js/parseInt) %1)))
 136 | 
 137 | (defn parse-long
-------^------------------------------------------------------------------------
 parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long
--------------------------------------------------------------------------------
...
#2022-07-2720:16thhellerupgrade noencore#2022-07-2720:18agyes, it seems from inflections. Sorry. I thought it's somehow related to me bumping Cljs. Apologies for the noise.#2022-07-2720:21agright, bumping it fixed it. I blame my OCD. I should learn to be more patient and learn how to read the error messages.#2022-07-2721:17mkvlrI put up a https://github.com/mk/shadow-barcode-wasm#attempt-to-use-barcode-detector-zbar-with-shadow-cljs. Would appreciate any pointers of other things I could try to get this working.#2022-07-2721:18thhellerdo you have this file not-minified?#2022-07-2721:18thhellerreally no point in using the minified file here, shadow-cljs will minify it anyways#2022-07-2721:18mkvlryes, but I can’t use it because it loads a wasm dep using webpack magic#2022-07-2721:19thhellerhmm?#2022-07-2721:19mkvlrhttps://github.com/lekoala/barcode-detector-zbar/blob/master/BarcodeDetectorPolyfill.js#L1#2022-07-2721:20mkvlrshadow will complain that it can’t load wasm, sec grabbing the error#2022-07-2721:21mkvlr
Failed to inspect file
  /Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin

it was required from
  /Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/load-browser.js

Errors encountered while trying to parse file
  /Users/mk/dev/shadow-barcode/node_modules/zbar.wasm/dist/zbar.wasm.bin
  {:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}
#2022-07-2721:22mkvlrthis would be https://www.npmjs.com/package/zbar.wasm#2022-07-2721:22thhelleryeah, I was just confused why the minified file doesn't do that#2022-07-2721:22thhellerbut I guess thats a file built by webpack already#2022-07-2721:22mkvlrI think this is webpack load-file rewriting it#2022-07-2721:23thhellerok yeah this will be no fun. you'll basically need to add a gazillion externs#2022-07-2721:23mkvlroh, against everything in this minified file?#2022-07-2721:24thhellerwell, against all the imports the JS passes to the wasm#2022-07-2721:24thhellerand the exports it gets from the wasm#2022-07-2721:25thhellerI cannot even guess what those are given the minified nature of the file#2022-07-2721:25thhelleryou can try :simple I guess?#2022-07-2721:25mkvlrhmm, is there another way if I write code directly against zbar.wasm?#2022-07-2721:25thhellerhttps://github.com/thheller/wasm-pack-cljs#2022-07-2721:26mkvlrbecause this wrapper lib isn’t a lot of code#2022-07-2721:26thhellerhttps://github.com/thheller/wasm-pack-cljs/blob/master/src/gen/demo/without_a_bundler.js#L113-L176#2022-07-2721:27thhellerthose are the imports passed to the wasm file. :advanced was renaming all of them, so I changed imports.wbg.* to imports["wbg"]["..."] instead#2022-07-2721:27thhellerwhich protects it from renaming#2022-07-2721:27mkvlrre simple: I guess if there’d be a way to only use simple for this js module, the bundle size impact would be basically zero#2022-07-2721:27thhellerI cannot tell what the min file is doing, but it must construct such an object somewhere#2022-07-2721:28thhellerI mean just include the file separately? why does it need to be part of your build?#2022-07-2721:30mkvlrhmm, I started with that, why the hell did I go so off the rails 🙈#2022-07-2721:31mkvlrso load it via a script tag?#2022-07-2721:32thhellerwell if you use :target :esm you can also load it via (:require ["esm:./BarcodeDetectorPolyfill.min.js$default" :as barcode-detector-polyfill])#2022-07-2721:33thhellerand putting the file into the same folder as the shadow-cljs output#2022-07-2721:33thhellerso it just does a runtime import since it already is a ES module#2022-07-2721:34mkvlrhuh, that sounds nice, then I have more control over the loading#2022-07-2721:34thhelleresm: just tells shadow-cljs to do a runtime import instead of a build time import#2022-07-2721:34mkvlrso you recommend esm these days for cases like this or do you still expect rough edges?#2022-07-2721:34thhellerdynamic-import also works, see https://clojureverse.org/t/generating-es-modules-browser-deno/6116#2022-07-2721:35thheller(that might also work with :target :browser I guess)#2022-07-2721:35thhellerI haven't worked on :esm much but there isn't much to work on. it seems to work fine.#2022-07-2721:36thhelleronly recommending it because of ESM interop with ESM works well#2022-07-2721:36thhellernon-ESM with ESM not so much, although dynamic import may just work#2022-07-2721:37thhellerhmm no it won't I guess#2022-07-2721:38thheller(due to closure compiler rewriting import() still I think, something regarding that broke)#2022-07-2721:38thhellerhttps://github.com/google/closure-compiler/issues/3941#2022-07-2721:38mkvlryeah, getting main.js:1425 ReferenceError: shadow_esm_import is not defined with dyanamic import#2022-07-2721:39mkvlrtrying esm now#2022-07-2721:39thhellerset :prepend "function shadow_esm_import(name) { return import(name) }" to your build :modules config#2022-07-2721:40thhellerso next to :entries#2022-07-2721:42thhelleror just a <script> tag in the page also works#2022-07-2721:50mkvlrah nice, so I can load it now, now last thing I need is get to the $default thing#2022-07-2721:56thhellerjust (.-default mod)?#2022-07-2722:06mkvlryeah, that works for getting functions, to create an instance I’m doing (.construct js/Reflect (.-default polyfill-module) #js []) or is there an easier way?#2022-07-2722:06mkvlrbut everything is working now, this is great, thanks so much for your help#2022-07-2722:09thhellerwhy reflect?#2022-07-2722:09thheller(new (.-default polyfill-module))?#2022-07-2722:10mkvlrbecause I didn’t know this was a thing, doh#2022-07-2722:12mkvlrwell this is nice & compact now, thanks again
(-> (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")
    (.then (fn [^js mod]
             (let [$default (.-default mod)]
               (js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
               (.setupPolyfill $default)
               (doto (new $default)
                 (js/console.log))))))
#2022-07-2722:13mkvlrcool, can confirm advanced is now working too#2022-07-2722:15thheller
(js-await [^js mod (dynamic-import "/barcode-detector-zbar/BarcodeDetectorPolyfill.min.js")]
  (let [$default (.-default mod)]
    (js/console.log "native api support:" (.checkBarcodeDetectorSupport $default))
    (.setupPolyfill $default)
    (doto (new $default)
      (js/console.log))))
#2022-07-2722:15thheller😉#2022-07-2722:20mkvlrwhere is that defined?#2022-07-2722:20mkvlrah I see [shadow.cljs.modern :refer (js-await)]#2022-07-2723:55colliderwriteris there an approved way to get out-of-tree source files into shadow-cljs :paths ? i have some cljc i need to share between front and back ends. I get a warning when i try
:paths ["../../components" "src"]
#2022-07-2805:29thheller@colliderwriter :paths is deps.edn and therefore the rules of tools.deps apply. basically you need to use :local/root if you want to get outside the project#2022-07-2806:44bbssIn my trying to make the smallest reproduction I figured out a rather stupid mistake: had up-to-date shadow-cljs in my clj deps, but in my devDependencies of node it was still on 2.17.4 facepalm#2022-07-2806:44bbssGetting further now with thes :esm build but hitting:
[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/Users/baruchberger/opt/anaconda3/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'
#2022-07-2806:52bbssand with :npm-module watch build I'm hitting:
Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault
with :npm-module release build I'm hitting:
ReferenceError: shadow$provide is not defined
#2022-07-2808:31thheller@bbss I really cannot comment on any of that without seeing configs/code#2022-07-2808:32bbssOkay, I've added a comment to the issue https://github.com/thheller/shadow-cljs/issues/1039 with a repo#2022-07-2808:32thhellerthanks. I'll look at that#2022-07-2808:32bbssthank you very much 🙂#2022-07-2808:33bbssI think the :esm release build is very close. It might be some node dependency of the babel-transpiled library I'm importing?#2022-07-2808:33thhellerhow do I run jupyter?#2022-07-2808:33bbss
tldr: If you have conda installed: conda install -c conda-forge jupyterlab or pip install jupyterlab If you are using a macOS version that comes with Python 2, run pip3 instead of pip.
#2022-07-2808:33thhellerI don't have conda#2022-07-2808:34bbssthen pip3 install jupyterlab should work#2022-07-2808:34thhelleror pip3 😛#2022-07-2808:34bbssOh.. Uhm.#2022-07-2808:34thhelleror pip I guess#2022-07-2808:34thhellerits debian? so just apt-get install python maybe?#2022-07-2808:34bbssdocker?#2022-07-2808:34bbssYes, might need to apt-get pip too#2022-07-2808:41thhellerstill installing I guess#2022-07-2808:41thhellertry this build config
{:target :esm
 :output-dir "lib"
 :modules {:notebookesm {:exports-var notebook/extension}}
 :runtime :browser
 :js-options {:js-provider :import}}
#2022-07-2808:46thheller
$ jupyter lab --watch
[I 2022-07-28 10:45:12.917 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-07-28 10:45:12.927 ServerApp] nbclassic | extension was successfully linked.
[I 2022-07-28 10:45:12.930 ServerApp] Writing Jupyter server cookie secret to /home/thheller/.local/share/jupyter/runtime/jupyter_cookie_secret
[I 2022-07-28 10:45:13.458 ServerApp] notebook_shim | extension was successfully linked.
[I 2022-07-28 10:45:13.600 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-07-28 10:45:13.601 LabApp] JupyterLab extension loaded from /home/thheller/.local/lib/python3.9/site-packages/jupyterlab
[I 2022-07-28 10:45:13.601 LabApp] JupyterLab application directory is /home/thheller/.local/share/jupyter/lab
[I 2022-07-28 10:45:13.602 LabApp] Starting JupyterLab watch mode...
-
#2022-07-2808:46thhelleris this supposed to show something more? it just keeps spinning?#2022-07-2808:46thhellerno idea what I'm supposed to expect here 😛#2022-07-2808:46thhellerI did the link and started that thing#2022-07-2808:46thhellerdunno whats next#2022-07-2808:46bbssIt compiled the watch build with that, but again hit the shadow.module.notebookesm.prepend.js issue. After I pressed stop to try the release build I got a
[2022-07-28 17:20:57.673 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@jupyterlab/codemirror/lib/mode.js", :requires [{:line 38, :column 20}]}
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/h3-js/dist/browser/h3-js.js:674:2
 @suppress annotation not allowed here. See 
--------------------------------------------------------------------------------
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x00000001042039c4, pid=28319, tid=47875
#
# JRE version: OpenJDK Runtime Environment Homebrew (11.0.12) (build 11.0.12+0)
# Java VM: OpenJDK 64-Bit Server VM Homebrew (11.0.12+0, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# V  [libjvm.dylib+0x5279c4]  _ZN15PcDescContainer21find_pc_desc_internalEPhbRK12PcDescSearch+0xf4
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/baruchberger/jupyter-compilation-target/hs_err_pid28319.log
Compiled method (c2) 1469217 22524   !   4       clojure.core.async$mult$fn__9046$state_machine__7801__auto____9059$fn__9064::invoke (5095 bytes)
 total in heap  [0x00000001158cc590,0x00000001158e4620] = 98448
#2022-07-2808:47bbssOkay, it should open the notebook in your browser#2022-07-2808:47bbsshttp://localhost:8888/lab#2022-07-2808:47thhellerit probably can't because its running in wsl#2022-07-2808:47thhellerThis site can’t be reached#2022-07-2808:48bbssHmm, the watch tends to take some time usually but that's probably not it :thinking_face:#2022-07-2808:48thhellerthe error you just posted cannot happen with the config I just gave you#2022-07-2808:48thhellerso maybe thats still the npm-module build or something?#2022-07-2808:48thhellerwell it has been going for several minutes now?#2022-07-2808:48bbssyeah, not that long 🙂#2022-07-2808:48thhellerbut its also the first time starting so no clue#2022-07-2808:49thhellerthe link seems fine though#2022-07-2808:49bbss
X Compilation failed.
NullPointerException: 
	clojure.string/index-of (string.clj:327)
	clojure.string/index-of (string.clj:319)
	shadow.build.targets.esm/replace-goog-global* (esm.clj:334)
	shadow.build.targets.esm/replace-goog-global* (esm.clj:328)
	clojure.core/apply (core.clj:669)
	clojure.core/update-in/up--6922 (core.clj:6220)
	clojure.core/update-in/up--6922 (core.clj:6219)
	clojure.core/update-in/up--6922 (core.clj:6219)
	clojure.core/update-in (core.clj:6221)
	clojure.core/update-in (core.clj:6207)
	shadow.build.targets.esm/replace-goog-global (esm.clj:362)
	shadow.build.targets.esm/replace-goog-global (esm.clj:350)
	shadow.build.targets.esm/process (esm.clj:473)
	shadow.build.targets.esm/process (esm.clj:465)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--15861 (build.clj:163)
	shadow.build/process-stage (build.clj:160)
	shadow.build/process-stage (build.clj:152)
	shadow.build/compile (build.clj:511)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.server.remote-ext/do-build/fn--20767 (remote_ext.clj:104)
	clojure.core/binding-conveyor-fn/fn--5823 (core.clj:2047)
	java.util.concurrent.FutureTask.run (FutureTask.java:264)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
	java.lang.Thread.run (Thread.java:829)
#2022-07-2808:49bbssthe link went through building a couple of times as well?#2022-07-2808:49thhelleris this in your actual project or in the repro?#2022-07-2808:49bbssrepro#2022-07-2808:50thhellerthat compiles just fine for me#2022-07-2808:50thheller
{:deps {:aliases [:dev]}
 :nrepl {:port 12000}
 :builds {:notebook-esm
          {:target :esm
           :output-dir "lib"
           :modules {:notebookesm {:exports-var notebook/extension}}
           :runtime :browser
           :js-options {:js-provider :import}}}}
#2022-07-2808:50thhellerand changing index.js to include the notebookesm.js#2022-07-2808:50thhelleroh something happening#2022-07-2808:51thhellerok jupyter running#2022-07-2808:51thhellerhow do I see if the extension did anything?#2022-07-2808:52bbssit should print the extension and "extension in index.js"#2022-07-2808:52thhellerprint it where?#2022-07-2808:52bbssI can build it with watch, but release gives that nullpointer#2022-07-2808:52bbssin the devtools console#2022-07-2808:53thhellerit doesn't#2022-07-2808:53bbssAnd you don't have any errors?#2022-07-2808:54thhellerOh I guess link had errors#2022-07-2808:54thheller
ValueError:
"
#2022-07-2808:54bbssHmm okay, my jupyterlab is a bit older.#2022-07-2808:55bbssI guess those npm deps need to be bumped#2022-07-2808:56thhellerthere are a few, which one?#2022-07-2808:59thhellerbumped it all to 3.4.4#2022-07-2808:59thhellerwhich at least gets further than it did before. doing the spinning thing again.#2022-07-2808:59bbssRight.. 🤞:skin-tone-2: #2022-07-2809:02thhellerok getting the
[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/home/thheller/.local/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'
#2022-07-2809:02thhellerI don't know why its looking in that directory though?#2022-07-2809:03thhellerI'm guessing it didn't copy some files?#2022-07-2809:03thhellerdo oyu need to configure which files a package has somewhere?#2022-07-2809:03thheller
"files": [
    "index.js",
    "lib/*.{js,js.map}"
  ],
#2022-07-2809:04thhellerare you sure thats valid?#2022-07-2809:04bbssThat should be included in the files prop of package.json.#2022-07-2809:04bbssI think so because I’ve had it run files from there :thinking_face: #2022-07-2809:04thhellerah I guess it just doesn't include the cljs-runtime dir?#2022-07-2809:04bbssAhhh#2022-07-2809:05bbssThat makes sense#2022-07-2809:05thhellerbut yeah I have very little hope of watch and REPL working here 😛#2022-07-2809:05thhellerstarting ...#2022-07-2809:06bbssIt actually did watch properly with the tip you gave#2022-07-2809:06bbssJust without the third party JS#2022-07-2809:06bbssWatch and even hot reload#2022-07-2809:06thhellerwell I'll be damned#2022-07-2809:06thhellershadow-cljs: #5 ready!#2022-07-2809:06bbss🎉#2022-07-2809:06thhellerundefined 'extension in index.js'#2022-07-2809:07thhellerhello world from the REPL#2022-07-2809:07thhellerwell that was easy 😉#2022-07-2809:07bbssYeah should have :default probaly :as doesn't work#2022-07-2809:09bbssI don't have time to test right now but a little later I’ll see where I get with this new info. Hopefully this also solves the third party js issue. Thank you so much 😊 #2022-07-2809:09thhellerI guess you meant
{:deps {:aliases [:dev]}
 :nrepl {:port 12000}
 :builds {:notebook-esm
          {:target :esm
           :output-dir "lib"
           :modules {:notebookesm {:exports {extension notebook/extension}}}
           :runtime :browser
           :js-options {:js-provider :import}}}}
?
#2022-07-2809:10thhellerwhat is viv.es.js and why is it on the classpath?#2022-07-2809:10thhelleris it not a npm lib?#2022-07-2809:12bbssIt's not, made some adjustments to that codebase. Although we are in the process of adding this as an npm package.#2022-07-2809:13thhellerwell it shouldn't be part of the build I guess#2022-07-2809:14thhelleris this link really necessary always?#2022-07-2809:14thhellertakes forever#2022-07-2809:14bbssIt works for our normal web-app. It’s compiled with babel.#2022-07-2809:14bbssI think it actually links to the directory for watch builds, so maybe not?#2022-07-2809:15thhellerwell its not actually a ES file so the viv.es.js is confusing#2022-07-2809:16thhellerand since its commonjs it doesn't play too well with the ESM build#2022-07-2809:16thhellerbut it shouldn't be part of the build in the first place#2022-07-2809:16thhellerit should just be a npm package#2022-07-2809:20thhellerthis experience is frustratingly slow 😛#2022-07-2809:21thhellerbut yeah the problem is the viv file#2022-07-2809:24thhellerok, just removed the viv thing and now everthing appears to log what it should#2022-07-2809:24thheller{id: 'jupyter-compilation-target.notebook', autoStart: true, optional: Array(1), requires: Array(2), activate: ƒ} 'extension in index.js'#2022-07-2809:24thhelleractivate W {_started: true, _pluginMap: {…}, _serviceMap: Map(60), _delegate: e, commands: e, …} _e {_currentChanged: e, _isDisposed: false, _widgetAdded: e, _widgetUpdated: e, _focusTracker: e, …}#2022-07-2811:14flowthingNoticed that v2.19.7 and newer seem to ship a version of the Closure Compiler that's not compatible with Java 8:
λ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)
λ clj -Srepro -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.19.7"}}}' -M -m shadow.cljs.devtools.cli browser-repl
...
Caused by: java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CompilerOptions has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
...
From the Closure Compiler release notes (https://github.com/google/closure-compiler/wiki/Releases#june-1st-2022-v20220601): > Java 11 or newer is now required to run Closure Compiler. Just a heads up. Guess there's little to be done about that.
#2022-07-2811:15flowthing(The Closure Compiler that comes with v2.19.6 works fine with Java 8.)#2022-07-2815:04thhelleryeah, can't do anything about that.#2022-07-2816:48Drew VerleeIn the error messsage below, it seems like the shadow server is trying to call a method that doesn't exist. I assume this is because that method's library is set to a version that doesn't have it due to another project dependency. But i can't figure out where, is there a way to get more information? "com.google.javascript" or ".protobuf" doesn't appear in my package-json.lock or my deps file. For java based builds i can use clj -Stree what is the equivalent for shadow projects?
[:app] Compiling ...
[2022-07-28 11:42:00.658 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoSuchMethodError com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()Lcom/google/protobuf/Internal$IntList;
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24)
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2379)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)
#2022-07-2816:53Drew Verleei'm going to bumb shadow to the latest to start...#2022-07-2817:21thhellerwhats the full stacktrace?#2022-07-2817:22thhellerthis is most likely a dependency conflict ys, no clue which one though#2022-07-2817:22thhellercom.google.javascript is the closure-compiler#2022-07-2817:22Drew Verleethat's all that i see in my terminal.#2022-07-2817:23thhelleropen a REPL and run (shadow.cljs.devtools.api/compile! :app) I guess#2022-09-0216:59Stef Coetzee@U0DJ4T5U1: did you manage to resolve this error?#2022-09-0217:54thhellermost likely a dependency conflict on protobuf?#2022-09-0220:02Drew Verlee@U03CPPKDXBL i was, though i can't recall at this point what I did specifically. Probably just updated a dependency.#2022-09-0304:57Stef CoetzeeGlad to hear it, thanks @U0DJ4T5U1. Good call, @U05224H0W. In my case, it was mysql/mysql-connector-java 8.0.19 that depended on com.google.protobuf/protobuf-java 3.6.1 . Upgraded to mysql/mysql-connector-java 8.0.30 , which seems to have done the trick.#2022-09-0305:49Stef Coetzee@U05224H0W, thanks for putting together the guide. The https://shadow-cljs.github.io/docs/UsersGuide.html#_troubleshooting's recommendation to list all active dependencies using clj -A:dev:cljs -Stree was really helpful! I'm starting to appreciate your recommendation to manage all CLJS dependencies exclusively with Shadow CLJS. For others interested, learn more here: https://github.com/thheller/shadow-cljs/issues/983#issuecomment-1041190965#2022-10-0712:38Eric DvorsakI am going to hijack this thread and add my stackstrace for future lost souls, I had:
NoSuchMethodError 'com.google.protobuf.Internal$IntList com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()'
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24)
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2391)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424)
and it was caused by an older version of the mysql-connector as well, upgrading to mysql/mysql-connector-java 8.0.30 fixed it I would have never suspected this one
#2022-07-2912:40Daniel GersonFirstly thanks for a great product! So I wanted to experiment with adding NPM lib react-native-logs to my react-native shadow-cljs project, so I yarn'd it, created a new namespace and added ["react-native-logs" :refer [logger]] but nothing I did could get logger to appear in the REPL (loading file or namespace) in a way that made sense. I thought maybe it was an ecma issue and tried react-native-logs$default, tried :as instead, but nothing worked. I got AssertionError Assert failed: (rc/valid-resource? rc)errors in the shadow-cljs console :thinking_face:. However it all worked perfectly if I used it from within the :app main namespace, or even required the new namespace from a linked one Obviously very unlike a Clojure REPL experience. I was wondering if it would be possible to give a hint in this scenarios so others don't suffer the hours it took me 😅#2022-07-2912:41thhellerdependencies cannot be added solely from the REPL in react-native#2022-07-2912:41thhellerthat is because the code needs to be processed by the react-native metro build tool and it cannot see what you do at the REPL#2022-07-2912:43Daniel GersonCan shadow not see this attempt and warn the user?#2022-07-2912:44thhellerI thought it did https://github.com/thheller/shadow-cljs/blob/fd7360dd334119283242eb85340ed04aa16310ac/src/main/shadow/boot/react-native.js#L40#2022-07-2912:44thhellerbut I don't use react-native myself so maybe that check just does nothing and it blows up in other ways#2022-07-2912:45thhellerI mean what is AssertionError Assert failed: (rc/valid-resource? rc) and in which context did you get it?#2022-07-2912:46thhellerso far nobody has opened an issue about this so I assume everything is fine in react-native land 😉#2022-07-2912:47Daniel Gerson
[2022-07-29 13:08:26.165 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-compile, :input {:code "(cljs.core/load-file \"/Users/dmg46664/projects/samson/src/main/dimigi/network.cljs\")", :ns user, :repl true}, :include-init false, :call-id 5, :from 3}}
AssertionError Assert failed: (rc/valid-resource? rc)
	shadow.build.data/add-source (data.clj:220)
	shadow.build.data/add-source (data.clj:220)
	shadow.cljs.repl/repl-ns (repl.clj:325)
	shadow.cljs.repl/repl-ns (repl.clj:319)
	shadow.cljs.repl/process-read-result (repl.clj:504)
	shadow.cljs.repl/process-read-result (repl.clj:484)
	shadow.cljs.repl/process-input (repl.clj:647)
	shadow.cljs.repl/process-input (repl.clj:625)
	shadow.cljs.repl/repl-load-file* (repl.clj:281)
	shadow.cljs.repl/repl-load-file* (repl.clj:259)
	shadow.cljs.repl/repl-load-file (repl.clj:317)
	shadow.cljs.repl/repl-load-file (repl.clj:315)
#2022-07-2912:48thhellerhmm didn't I fix that one? which version do you use? (its printed on startup)#2022-07-2912:50Daniel GersonDamn, I just realised I upgrade recently by changing the shadow dependency and not yarning the shadow upgrade 😬#2022-07-2912:51thhelleryou can also set :version "2.19.8" in shadow-cljs edn if you want to be less reliant on npm/yarn stuff#2022-07-2912:51thheller(only works if you don't use deps.edn/project.clj of course)#2022-07-2912:51Daniel GersonOh, that's what I did, but in the edn file.#2022-07-2912:51Daniel Gersondeps.edn#2022-07-2912:52Daniel Gerson
shadow-cljs - server version: 2.19.8 running at 
#2022-07-2912:53thhellerwell, yes with deps.edn the version is managed in deps.edn and package.json version doesn't really matter for compilation#2022-07-2912:53thhellerso you get that error with that version?#2022-07-2912:55Daniel Gerson😅 yes get that error in that version... but before upgrading from 2.11.7 I got a little more out of the stacktrace:
"react-native-logs" - failed: simple-symbol? in: [:requires 3] at: [:requires] spec: :shadow.build.resource/require
#2022-07-2912:56thhellerinfo from 2.11.7 doesn't help and just confuses the issue#2022-07-2912:57thhellerplease open an issue with the above stacktrace and some info on how you got it#2022-07-2912:57thhellerI'll see about fixing that#2022-07-2912:57Daniel GersonCool, I thought best here before opening an issue.#2022-07-2913:00Daniel GersonOh, is it relevant that I'm using cider-nrepl as well?#2022-07-2913:01thhellermight be yes#2022-07-2913:37tianshu
Errors encountered while trying to parse file
  /home/tianshu/workspace/race-poker/racepoker-dapp/node_modules/lower-case/dist/index.js
  {:line 13, :column 13, :message "Character '̇' (U+0307) is not a valid identifier start char"}
Got some errors, the JS file is
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lowerCase = exports.localeLowerCase = void 0;
/**
 * Source: 
 */
var SUPPORTED_LOCALE = {
    tr: {
        regexp: /\u0130|\u0049|\u0049\u0307/g,
        map: {
            İ: "\u0069",
            I: "\u0131",
            İ: "\u0069",
        },
    },
...
The reason could be shadow-cljs has its own identifier rules?
#2022-07-2913:38thhellerno, that is a known error in the closure compiler. unfortunately nothing I can do about it#2022-07-2913:38thhellerhttps://github.com/google/closure-compiler/issues/3639#2022-07-2913:54tianshuAh, I see.#2022-07-2913:54tianshuCan I patch this some how, I mean provide another file to overwrite this js#2022-07-2914:02tianshuI changed the file in node_modules, then it goes to an infinite compiling status.#2022-07-2914:03thhellerdon't know what that means. be careful when changing that file. you might leave invalid characters due to the non-visible unicode stuff#2022-07-2914:10tianshuI just commented them. When the compiling can't complete, how can I investigate what's going on?#2022-07-2914:11thhellerwhat do you mean by "can't complete"? I can't see your screen so I cannot guess what you are doing#2022-07-2914:11thhellerany error during compilation should be logged somewhere#2022-07-2914:12thhellerif you use something like cider the error might be in some other hidden buffer or something#2022-07-2914:12thhellerI recommend running shadow-cljs in the terminal somewhere to ensure you see all output#2022-07-2914:23tianshuLet me try it without cider#2022-07-2914:23tianshuYou are right#2022-07-2914:24tianshuNow I see the errors#2022-07-2914:25thhelleryeah someone else reported a similar situation#2022-07-2914:25thhellerhttps://github.com/thheller/shadow-cljs/issues/1029#2022-07-2914:25tianshuDoes it mean there's some malformed require#2022-07-2914:26thhellermaybe a have a similar cause? ie. changing the package folder name but not the package.json name?#2022-07-2914:27tianshuTrying to understand the solution mentioned in this issue#2022-07-2914:28thhellerwell if you answer my question that is also the solution 😛#2022-07-2914:28thhellersuppose you created a node_modules/my-lower-case and just copied the original package.json file there#2022-07-2914:29thhellerwithout updating the name field inside it#2022-07-2914:29tianshuHmm, nope. I just comment the content of that object definiation.#2022-07-2914:29tianshuI didn't change anything else, on my refresh new installed node_modules#2022-07-2914:30tianshuI'm sure it's caused by some packages, but I don't know which one it is. Because I introduce one package which bring me a lot dependencies#2022-07-2914:30thhellerhttps://github.com/thheller/shadow-cljs/issues/1029#issuecomment-1183296479#2022-07-2914:30thhellerdo this then#2022-07-2914:31tianshuLet me try#2022-07-2914:36tianshuI can understand this code here, but it doesn't give me anything in the inspector. Nor it does with print instead of tap>.#2022-07-2914:37tianshu
shadow.user=> (alter-var-root #'shadow.build.npm/find-resource-in-package
  (fn [orig]
    (fn [npm package require-from rel-require]
      (try
        (orig npm package require-from rel-require)
        (catch Exception e
          (tap> [:what rel-require package require-from])
          (throw e))))))
#object[shadow.user$eval25371$fn__25372$fn__25373 0xead9010e "
#2022-07-2914:38tianshuI think I did it the right way.#2022-07-2914:39thhellerhmm odd. looks correct.#2022-07-2914:39thhellerbut again ... when in cider it is undefined where println goes#2022-07-2914:40thhellerwhen you run shadow-cljs clj-repl did it start a new instance#2022-07-2914:40thhelleror did it say "connected to server"#2022-07-2914:40tianshuNow I'm using command line#2022-07-2914:40tianshuYep, it said "starting via clojure"#2022-07-2914:40thhellerhmm weird#2022-07-2914:41tianshuThanks anyway, I think I got the idea. I can test more with this method#2022-07-2914:41thhellerwhich version do you use?#2022-07-2914:41tianshu2.19.1#2022-07-2914:44thhellerhmm line number seems to match with the current. not sure why this wouldn't work#2022-07-2914:44thhellerI mean you can just (throw (ex-info "a more helpful error" {:package package}) e))#2022-07-2914:44thhellerinstead of (throw e)#2022-07-2914:45thhellerbut I mean println or tap should both be fine too#2022-07-2914:45thhellerI'll probably just add something like that given how unhelpful assert errors are#2022-07-2914:49tianshuHmm, I got some progress#2022-07-2914:50tianshuI print the package before call the orig . But it shows me a package I used to have it in my project.#2022-07-2914:50tianshuIt's parrerell?#2022-07-2914:55tianshuHm, yes, it's a package which I had before. The rel-require here is
.-v2
#2022-07-2914:55tianshuIt doesn't look like a require at all#2022-07-2915:01tianshu😂So, there's one package call spl-token, and now there's a package called spl-token-v2. JS is Amazing#2022-07-2916:16thhellerhmm yeah I need to rewrite that code I guess 😛#2022-07-2916:17thhellerI just assumed that npm actually checks the name and stuff but I guess it doesn't
#2022-07-3009:06tianshu
ExceptionInfo: failed to convert sources
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1993)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
        shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SHEQ): node_modules/noble-ed25519/index.js:292:23
        const isXOdd = (x & 1n) === 1n;
  Parent(SHNE): node_modules/noble-ed25519/index.js:293:12
        if (isLastByteOdd !== isXOdd) {

        com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2882)
        com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
        com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
        com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
        com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
        com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
        com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
        com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
        com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:566)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
        shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)
Caused by:
NullPointerException:
        com.google.javascript.jscomp.PeepholeFoldConstants.tryStrictEqualityComparison (PeepholeFoldConstants.java:1387)
        com.google.javascript.jscomp.PeepholeFoldConstants.evaluateComparison (PeepholeFoldConstants.java:1416)
        com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldComparison (PeepholeFoldConstants.java:1160)
        com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldBinaryOperator (PeepholeFoldConstants.java:188)
        com.google.javascript.jscomp.PeepholeFoldConstants.optimizeSubtree (PeepholeFoldConstants.java:104)
        com.google.javascript.jscomp.PeepholeOptimizationsPass$PeepCallback.visit (PeepholeOptimizationsPass.java:82)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:856)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
        com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.handleClassMembers (NodeTraversal.java:970)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:812)
        com.google.javascript.jscomp.NodeTraversal.handleClass (NodeTraversal.java:945)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:809)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
        com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:984)
        com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:748)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:800)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:459)
        com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
        com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
        com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
        com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
        com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
        com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
        com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:566)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
        shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
        shadow.cljs.devtools.server.worker.impl/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)
#2022-07-3009:08tianshuI think it can be reproduced by this dependency: https://www.npmjs.com/package/@metaplex-foundation/js#2022-07-3009:12thheller@doglooksgood again unfortunately an error in the closure compiler I cannot do anything about#2022-07-3009:12tianshuAh, I see#2022-07-3009:12tianshuSo the best idea here would be avoid these things going to the closure compiler?#2022-07-3009:13thhellerits also this npm package node_modules/noble-ed25519 not the one you linked#2022-07-3009:14thhellerwell the closure compiler is sometimes picky about certain code. sometimes its a bug sometimes its intended#2022-07-3009:14tianshuMaybe I should start a side javascript project, to deal with these dependencies?#2022-07-3009:15thhelleryou can just use webpack or whatever as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-07-3009:15thhelleror as far as I can tell these packages seem to be intended for node? the error above you only get for build where shadow-cljs tries to package everything (ie. browser)#2022-07-3009:16thhellerfor node it doesn't need to do that so the error would just disappear on its own#2022-07-3009:22tianshuBut those are libraries for browser, I guess it's not well-written.#2022-07-3009:22tianshuSo with js-provider, I should bundle the dependencies with webpack?#2022-07-3009:23thhelleror any other JS bundler you want#2022-07-3009:23thhellerrollup, esbuild, all the same really#2022-07-3009:26tianshu
(ns 
  (:require ["react" :as react]))
So I can have this in my CLJS codes, if I bundle the react in a lib.js? But what code I should provide in that target/index.js?
#2022-07-3009:26tianshuOh, it's generated#2022-07-3009:28thhelleryes, you feed the generated :external-index file to webpack or whatever#2022-07-3009:29thhellerand then load the output that generates in your HTML, before the output of shadow-cljs#2022-07-3009:39tianshuAhhh, webpack5 changed their api again.#2022-07-3009:39tianshu--output no longer available#2022-07-3009:44tianshushadow-cljs is so flexible, feel super nice about it#2022-07-3016:02alexDoes shadow-cljs support specifying a remote sourcemap location e.g. ... rather than at the :asset-path relative to the origin? We store our compiled JS files & sourcemap files on a cloud storage bucket#2022-07-3016:09alexAh great, looks like I might be able to just use :source-map-asset-path or :source-map-path. https://clojurescript.org/reference/compiler-options Not entirely sure of the difference between those two quite yet...#2022-07-3016:18alexHmm though the shadow-cljs user guide says this is an unsupported option. Should I explore a different path?#2022-07-3020:01thhellerasset-path is just prepended, so just put the full url in it#2022-07-3020:01thhelleralthough I don't understand the question. why are the maps not just in the same folder als the js?#2022-07-3020:06alexThe maps are in the same folder as the compiled JS files - both sets are uploaded to GCS after compilation.#2022-07-3020:19thhellerok, then everything should be good by default? it uses a relative path by default?#2022-07-3020:20thhellerno need to configure anything?#2022-07-3123:05alexConfirmed that the sourceMappingUrl is a relative path. However, when I open up dev tools, I'm seeing some "Devtools failed to load source map. Could not parse content for <some-url>.js.map", with that url being the page origin rather than the Google Cloud Storage url. It seems like the sourceMappingUrl relative path is being appended to the page origin rather than the GCS origin#2022-08-0107:00thhellerhmm that is odd? the spec says the url is relative to the .js file not the document?#2022-08-0107:01thhellerhow are you loading the scripts?#2022-08-0113:40alexI'm loading the initial bundle via
<script src=""></script>
The other modules are then lazy-loaded as users interact with the app (those are also requested and served from the Google cloud storage bucket) Interestingly, for the initial client.js bundle, I don't see a "Devtools failed to load source map" warning, perhaps suggesting that the initial one is loaded correctly? For all of the subsequent lazy-loaded modules, I see a corresponding warning about not being able to load that module's source map
#2022-08-0117:01thhellerhmm yeah the lazy loading might be the issue. I think then it uses the document location as a reference#2022-08-0117:12alexAh that's interesting and good to know. In that case, would you suggest using one of the compiler options to set an absolute path pointing to the GCS origin?#2022-08-0117:20thhellerthere is no setting for this currently since it normally isn't needed#2022-08-0117:21thhellerhow are you lazy loading the sources?#2022-08-0118:04alexImplemented a version of https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html but using Rum#2022-08-0118:35thhellerhmm but using exactly that loading mechanism?#2022-08-0118:36thhellerit is supposed to inject the source url, so the browser knows how to resolve the relative path for the source map#2022-08-0118:36thhellerthat is done here https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/loader.js#L17#2022-08-0118:36thhellerif you use a different loading mechanism that might not be done#2022-08-0118:37thhellerwhich :asset-path do you use?#2022-08-0118:45alexYep, using the loading mechanism from your article i.e. lazy-component , shadow.lazy, etc
:asset-path "/js/compiled"
#2022-08-0118:46thhellerbut how is that loading the JS then? I mean that is pointing to the wrong location?#2022-08-0118:46thhelleror is the HTML also coming from that location?#2022-08-0118:47thhellernote that :asset-path is a little misleading in the name. should be :asset-prefix or something. you can put an entire URL in there#2022-08-0118:47thhellerbut this should all be working by default and not require any other special settings#2022-08-0118:48thhellerunless you are manually fiddling with things in other ways of course#2022-08-0119:18alex> but how is that loading the JS then? I mean that is pointing to the wrong location? Ah! Looks like our main GCS-hosted client.js bundle is lazy-loading the other modules from a relative path appended to our document location. This isn't erroring because those relative paths resolve to actual files that are hosted on the server (during the switchover from Firebase hosting to GCS, we continued to upload the compiled JS files to both locations). However, we are not uploading the source maps to Firebase hosting, which explains the initial "Devtools failed to load source map." issue from the lazy-loaded modules User error on my part - thanks for patiently helping me work through the issue. To resolve this, sounds like I'd want to update the :asset-path to the GCS asset path#2022-07-3116:12thhellershadow-css now has a README and jar on clojars, I guess that could be considered the first official release https://github.com/thheller/shadow-css#2022-08-0114:00blackawaHi, I am constructing development environment with VSCode and https://github.com/microsoft/vscode-dev-containers/blob/main/containers/clojure/README.md. However, shadow-cljs watch does not publish any messages on file changes. I found https://github.com/thheller/shadow-cljs/issues/210 but it does not work (maybe too old). This does not appear to be a network problem, as a websocket connection is established and ping/pong messages are sent. Does anyone know any hints? Thanks#2022-08-0117:07thhellerhmm yeah this option doesn't exist anymore and I thought the issue was gone too to be honest#2022-08-0117:08thhellerI don't use containers so I don't test that#2022-08-0117:08thhellerwhich shadow-cljs version and which jvm version is this?#2022-08-0212:25blackawa@thheller Thank you for reply. > the issue was gone too to be honest I read https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/fs_watch.clj & https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/util/FileWatcher.java, and I thought so too. My environment is below: • Java: openjdk 17.0.3 2022-04-19 LTS • shadow-cljs: 2.19.6 • Node.js: v16.16.0 • VSCode: 1.69.2 • Docker: 20.10.17, build 100c701 • Docker Desktop for Windows: 4.10.1 • Windows: 10(19044, 1826) You can use https://github.com/blackawa/isomorphic-clojure-webapp to reproduce an issue. I tried on 2 Windows machine, and trying on my Mac machine tonight.#2022-08-0213:20thhellerwell its a known issue that file watchers have trouble working in containers. not really specific to shadow-cljs at all. I don't know how devcontainers work exactly so I don't have any guesses#2022-08-0214:13Michaël SalihiDoes :target :browser support js/require?#2022-08-0214:24thhellerdoes your browser support require(...)? 😛 no, it doesn't.#2022-08-0215:19Michaël SalihiWell OK, I thought maybe there was some machinery at the bundle level because I saw on some React/Reagent projects (def sym (js/require...) but I'm sure now that is the case for :target :react-native for eg. https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L11 Thanks for the confirmation. 😉#2022-08-0215:20thhelleryes, this is react-native specific#2022-08-0215:25Michaël SalihiAnd in this snippet (coming from React Inertia.js doc https://inertiajs.com/client-side-setup), it's managed by the bundler I guess.
createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props }) {
    render(<App {...props} />, el)
  },
})
#2022-08-0215:29thhelleryes, handled by webpack#2022-08-0215:29thhellerin that case js/require would be supported, assuming the shadow-cljs is run through the webpack build as well#2022-08-0215:40Michaël Salihiinteresting...yes with using Shadow-CLJS :js-provider :externaloption for example. I'm thinking about using your Next-cljs hook trick https://github.com/thheller/next-cljs/blob/master/shadow-cljs.edn#L13 to generate pages to require it automatically like the above Inertia example.#2022-08-0215:41thhellerno :external would not work for this. the CLJS output doesn't go through webpack in that case#2022-08-0215:42Michaël SalihiThis in order to avoid to manage manually theses pages like I do for now https://github.com/prestancedesign/pingcrm-clojure/blob/main/src/cljs/pingcrm/app.cljs#L18-L34#2022-08-0215:47Michaël Salihi> no :external would not work for this Ha ok. so what the solution? Continue to use :target :browserand pass the generated JS bundled file through Webpack directly?#2022-08-0216:00thhellersorry I don't know inertia so I don't know what any of this is supposed to do#2022-08-0218:03Michaël SalihiIn few words, Inertia backend adapter add a data-page attribute containing a stringify JSON obj. Eg:
<div id="app" data-page="{component: \"homepage\", props:{}">
#2022-08-0218:07Michaël SalihiOn the front end, Inertia reads this pageobject to get props and the current component name (here homepage).
createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props }) {
    render(<App {...props} />, el)
  },
})
#2022-08-0218:10Michaël SalihiSo the require line automatically import ./Pages/homepage.js component.#2022-08-0218:20Michaël Salihiin CLJS, I think we can't rely on file-based routing or easily use the require like in JS so for now I manually "link" the component name with cljs symbols like here: https://github.com/prestancedesign/pingcrm-clojure/blob/main/src/cljs/pingcrm/app.cljs#L18-L34#2022-08-0218:22Michaël SalihiIdeally, what I want to accomplish is to be able to make this dynamic. Perhaps an automatic import of namespaces via a macro would also be a solution. I will continue to search. Thanks for your time and help.#2022-08-0219:06thhellerthe struggle with integration in some other JS build systems is that they almost always rely on filesystem structure#2022-08-0219:07thhellersince they don't have a proper namespacing system that is the somewhat obvious thing to do of course#2022-08-0219:07thhellerbut it doesn't really fit with how CLJS sees the world#2022-08-0219:07thhellerso there are rough edges when it comes to this kind of stuff#2022-08-0219:07thheller:npm-module sort of is the most granular#2022-08-0219:07thhellerand if you generate some additional glue code with a hook that should work best#2022-08-0219:08thhellerI mean that why I structured my stuff the way I did#2022-08-0219:08thhellerjust sometimes means that some stuff needs to maybe stay in actual JS files#2022-08-0219:08thheller(generated or not)#2022-08-0219:25Michaël SalihiThanks for your insights, it's always very helpful!#2022-08-0216:00thheller:browser output is not meant to go through another build tool#2022-08-0216:01thhelleryou should use :npm-module or :esm for that#2022-08-0217:56Michaël SalihiThank you very much for these precisions. I'm going to test different solution to see what's the best one.#2022-08-0306:21Alex Warrenhi hi, I am looking for a little help, I have a build with :target :node-library and I want to use js/performance.now which is a browser global, available with const { performance } = require('perf_hooks'); on node. see this https://stackoverflow.com/questions/23003252/window-performance-now-equivalent-in-nodejs ... Is there an easy way to get this work, I am hacking with someone elses code, so I am mostly in the dark with clojure tbh. I tried (:require ["perf_hooks" :refer (performance)] ) but that was giving me "Use of undeclared Var performance/now" I am stuck :|#2022-08-0307:05thheller@exrhizo with :refer you'd do (.now performance), :refer does not set up a namespace alias so performance/ doesn't work. you can do (:require ["perf_hooks$performance" :as perf]) and then (perf/now).#2022-08-0314:45zakkorWhen I eval something in the REPL, I get an error that looks like this:
:repl/exception!
; 
; Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of null (reading 'cljs$core$IFn$_invoke$arity$1')
I can't figure out what's going wrong using just this info, is there any way to get more detailed traces?
#2022-08-0315:37thhellerthis usually means you are doing something like (foo 1 2 3) when foo is nil#2022-08-0315:49zakkoryeah, but is there any way of figuring out which "foo" it is? 😄#2022-08-0316:03thhellerwell you are calling the code?#2022-08-0316:12zakkor
(defn calls-nil [f] (f 1 2 3 4 5))
(calls-nil nil)
Eval in REPL using standard Calva shortcut gets me:
:repl/exception!
; 
; Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of null (reading 'call')
#2022-08-0316:16thhellerwell that is sort of an artifact of how the code is generated differently when eval'd in the REPL.#2022-08-0316:16thhellerit is the basically same error though#2022-08-0316:16thhellerif this is in Calva it might also be dropping some additional information#2022-08-0316:17thhelleremacs also seems to be doing that#2022-08-0316:18thheller(not on this example, but make sure to look at the server log in case there is any)#2022-08-0316:26zakkorif, for example, I set the :init-fn to calls-nil, I get proper traces in the browser console:#2022-08-0316:26zakkorbut if I eval from Calva, nothing gets printed to the browser console#2022-08-0316:27zakkornothing in the shadow-cljs terminal log either :thinking_face:#2022-08-0316:27thhellerwell you can get that via (.-stack *e) after the errors#2022-08-0316:28thheller(js/console.log *e) would give you the above too I guess#2022-08-0316:28zakkornice, thanks! the second one is great, the first one isn't sourcemapped#2022-08-0316:29thhelleryeah source mapping is the problem. didn't write that yet for the errors#2022-08-0316:29zakkoris this something that could be fixed on Calva's side?#2022-08-0316:29thhellerno#2022-08-0316:38zakkor@thheller hmm, any other way of getting the sourcemapped trace from *e , or is it only possible by js/console.log ing it?#2022-08-0316:39zakkorwould have been cool to be able to see/click the sourcemapped error without needing to switch to the browser window#2022-08-0316:39thhellerwell you can implement it 😉#2022-08-0316:40thhellerin case of console.log the browser does it for us#2022-08-0316:40thhellerI haven't found a way to make it do that in userland code#2022-08-0316:41zakkorI'll give it a shot and report findings if I manage to do anything 😄 Thanks for shadow-cljs by the way, it's a great project#2022-08-0316:45thhellerhttps://github.com/thheller/shadow-cljs/blob/b8466f176b6e8f6bf61cd70fbfbaf4762c581eb1/src/main/shadow/remote/runtime/obj_support.cljc#L100#2022-08-0316:45thhellerthats where the string for the error is generated#2022-08-0316:45thhellerthat is just calling https://github.com/clojure/clojurescript/blob/95c5cf384a128503b072b7b1916af1a1d5c8871c/src/main/cljs/cljs/repl.cljs#L229#2022-08-0316:46thhellerby all means feel free to change either place and make it better 😉#2022-08-0316:49zakkorawesome, thanks!#2022-08-0402:31steveb8nQ: I’m running node tests using the instructions here: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test when run via the node process they return a non-zero exit code as expected on my laptop. When I run in CI (bitbucket) i.e. docker, the same command returns zero even when the tests report failures. Has anyone seen this before?#2022-08-0421:46steveb8nHere’s the CLI command….
npx shadow-cljs -A:cljs:git-deps:test compile test-ci && node cljs-out/test-ci/node-tests.js
#2022-08-0421:47steveb8nand the config
{:target           :node-test
                                :compiler-options {:optimizations :whitespace}
                                :output-to        "cljs-out/test-ci/node-tests.js"
                                ;:ns-regexp        "^\b([a-z\\-]+)\b(?<!render|ignoreme)-test"
                                ; cannot use autorun if return code is needed. see shadow docs link above
                                :autorun          true}
#2022-08-0421:47steveb8nI’ve tried this without autorun as well but same problem#2022-08-0421:49steveb8n@thheller if there’s nothing obvious then I’ll try a local docker repro next. I’d guess its a docker env problem. CI is often painful#2022-08-0506:17thhelleragain. in what context is the CLI command called?#2022-08-0506:18thhellerthis is relevant since that dictates how the error code is handled#2022-08-0506:18thhellerI'm also not a docker expert or any container expert. so no idea what the rules of those even are and if they even check error codes#2022-08-1722:23steveb8n@thheller I got to the bottom of this one. I was using node fs/mkdirSync and that was failing in CI (not on localhost). If an fs/foo call throws an exception, the return code from the tests is zero. once I fixed the fs call, the tests properly returned non-zero for actual test fails#2022-08-1722:23steveb8nis this interesting enough for an issue?#2022-08-1806:33thhellernode -e "require('fs').mkdirSync(null)" echo $! does not have a 0 exit code?#2022-08-1806:33thhellerdo you have an "uncaughtException" handler that prevents the actual exit?#2022-08-1809:55steveb8nI’m running a chain of promises and the fs fail is in the last one. maybe that’s the key? I’m using promesa for the chain#2022-08-1809:56steveb8nif you want a repro I can add a sample test to an issue#2022-08-0405:44thhellerdepends on how you run then in CI I guess#2022-08-0406:40steveb8nSame exact cli command. Since ci is Docker I will try local docker to try and reproduce#2022-08-0407:05thhellerwell but how does your CI run it? Is it run in a bash file or so?#2022-08-0409:20steveb8nI'll put the invocations in a thread tomorrow for you to verify. A bit late here now#2022-08-0421:07johnFunny story... I keep raving about how excited I am at work about Shadow Grove. So a colleague mailed me a Shadow Grove T-Shirt. Apparently it's a brewery near him! Gotta get you one of these, @thheller#2022-08-0422:59Drew VerleeI would totally buy a shadow cljs shirt.#2022-08-0506:15thhellerhehe nice#2022-08-0422:58Drew VerleeIf you had to generate an index.html before starting your shadow app is there some configuration for that or do i just just run that logic then shadow server functions like (server/start!). I have to imagine it's the latter.#2022-08-0506:16thhelleryou could generate it in a build hook I guess?#2022-08-0607:57SchpaaHow can I trigger compilation by changing a file that is not a sourcefile? (it’s a css file I include for lambdaislands ornament, which is included in the :flush stage triggered by a hook in shadow-cljs.edn)#2022-08-0608:08thhellernot supported as I strongly recommend not doing anything like this in build hooks#2022-08-0608:09Schpaaoh#2022-08-0608:09thhellerhow is that css file relevant to the build?#2022-08-0608:10SchpaaThat css contains color-variables that are included in the file that is built with ornament#2022-08-0608:11thhellerah I guess something like this https://github.com/lambdaisland/ornament#shadow-cljs-build-hook-example?#2022-08-0608:12thhellerwell yeah, thats a prime example of why I strongly discourage using build hooks for this#2022-08-0608:12thhelleryou constrain yourself to only being able to generate CSS by running a shadow-cljs build#2022-08-0608:12Schpaathats kind of the point#2022-08-0608:13Schpaaornament picks up styles I’ve defined in cljs and builds the css#2022-08-0608:13SchpaaIt’s fantastic to work with#2022-08-0608:14thhellerhmm ok. I guess what you can do is what this macro does https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-08-0608:15thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/resource.clj#L49#2022-08-0608:16thhellerin a build hook this would be (assoc-in build-state [:compiler-env :cljs.analyzer/namespaces your.ns :shadow.resource/resource-refs "some/path.css"] last-mod)#2022-08-0608:16thhellerbut it needs to be on the classpath for this to work#2022-08-0608:17thhellerso I guess "resources/public/styles.css" becomes "public/styles.css"#2022-08-0608:18Schpaaok, I’ll do some research, thanks for the pointers#2022-08-0608:22thheller(need to do this before compilation though, flush is too later)#2022-08-0608:23thhelleror I guess in the :compiler-finish stage would do it#2022-08-0608:25thhellerhmm yeah this is not the best idea#2022-08-0608:25thhellerI think the best option is to handle it outside#2022-08-0608:25SchpaaI think I solved it (for my use-case) by adding the file to the classpath and using a simple (inline …) in one of the sources#2022-08-0608:25thhellerjust touch a-source-file.cljs to trigger a recompilation after editing the css#2022-08-0608:26thhellersure that works too#2022-08-0608:29SchpaaThe thing is, this is just for my convenience, saving the css triggers the recompilation and I dont have to go back and forth saving a cljs file to rebuild the css. Now it works just as I wanted, super!#2022-08-0608:34thhellerhmm yeah I guess this needs to stay a build hook since it looks at a runtime atom#2022-08-0706:38blackawaI avoided this problem by opening devcontainer from WSL2. As @thheller said to me, this seems to be file watching specification through mounted volume. Thank you for support.#2022-08-0819:49Nikolas PafitisWhy do I need to have shadow-cljs dependency when building for release? Is this intended? I am using deps.edn and shadow, and I didn't include the shadow-cljs in my release alias, and it failed to build.#2022-08-0819:52thhellerthat is a weird question? not sure I understand what you mean? yes, you do need shadow-cljs to build a release build, it is building that build after all?#2022-08-0819:54thhellerah I guess the npm shadow-cljs package confused you. that is in fact only doing the CLI things. the actual building is done by the thheller/shadow-cljs dependency you have in deps.edn#2022-08-0819:54thhellerthe npm package does no building at all#2022-08-0819:55thhelleryou also don't really need to make a release alias for dependencies for a CLJS build#2022-08-0900:27ChaseSo on deployment sites like and other heroku alternatives, they offer a free static site deployment. So what I was doing is compiling my shadow-cljs project in release mode on my computer and then pushing that whole project to github where it automatically gets deployed for me. So now I get to use their free deployment tier with no "sleep" mode like I have when deploying my full stack apps. Since I'm not including a Dockerfile to install java and compile it on their machines they are counting it as just a "static site." Does that sound reasonable or am I missing some obvious downside here?#2022-08-0903:09souenzzoSee https://github.com/souenzzo/atemoia#2022-08-0916:38ChaseThanks for sharing. I do a similar set up for my full stack apps: https://github.com/Chase-Lambert/clojure-app-template but in this case, I don't want the deployment steps to include java/Docker at all so that I can take advantage of these heroku style static site free deployments (with no "sleep" downtime). It seems to be working great after a couple of tweaks.#2022-08-0916:42souenzzoI didn't know about this "static site" thing seems that PHP has this advantage. I will try to use this some day#2022-08-0916:43souenzzoanyway, this is seems to be the path: • create the js bundle • create the index.html • pretend to use PHP#2022-08-0900:30Chase2nd question, when looking at the network tab of my deployed pages/apps I'm noticing that it is downloading the main.js file as I expected but it's also downloading a react_devtools_backend.js file that is 578 kb. Is that too be expected (I'm thinking that's react itself so required) or is that an artifact from my development builds? If the latter, how do I remove that before uploading to github in the method I mentioned in my first question?#2022-08-0900:32ChaseIs that something that would be included in this cljs-runtime folder I'm seeing in resources/public/js and can I throw that in my .gitignore file when pushing to github? I'll try that and see what happens.#2022-08-0900:42ChaseWell I removed the cljs-runtime folder in the release deployment and it still works so I assume it's not needed. But it's still downloading the react_devtools_backend.js file which is killing my lighthouse performance score (getting a 62 with a simple "Hello World") but I hear that might be an overrated benchmark anyways I guess.#2022-08-0901:29alexI believe React devtools will load up react_devtools_backend.js i.e. it only gets loaded when you open up devtools + have React devtools installed#2022-08-0901:34ChaseYou nailed it. I forgot about that and it turns out I had turned it on for incognito mode too which I used to not have just for this reason. The performance score shot up to a 99 as I expected. Thank you!#2022-08-0906:12thhelleryes, the cljs-runtime dir is not needed for release builds.#2022-08-0906:12thhellerreact_devtools_backend.js is indeed from the chrome extension and not something shadow-cljs bundles/produces#2022-08-0907:41thhelleralso don't forget to create a build report to see what is in your main.js https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2022-08-0916:36ChaseThanks for the clarifications. I will check that out.#2022-08-0916:27lilactowndoes shadow-cljs support java 1.8?#2022-08-0918:16thheller@lilactown no, not anymore. technically it does but the closure compiler recently moved to java 11 so shadow-cljs inherits that#2022-08-0918:28lilactownyeah noticing that. ok thanks#2022-08-1019:11Jack ArringtonBit of an odd question: can I silence compiler warnings from a dependency (not from my own source code)? I upgraded from an older version of shadow and now get this warning:
------ WARNING #1 - :redef -----------------------------------------------------
  Resource: garden/color.cljc:390:1
 --------------------------------------------------------------------------------
  387 |      (let [d (util/clip 1 179 distance-from-complement)]
  388 |          (hue-rotations color 0 d (- d)))))
  389 |
  390 | (defn- abs
 -------^------------------------------------------------------------------------
  abs already refers to: cljs.core/abs being replaced by: garden.color/abs
 --------------------------------------------------------------------------------
  391 |   [x]
  392 |   (if (neg? x) (- x) x))
  393 |
  394 | (defn tetrad
 --------------------------------------------------------------------------------
I will probably submit a PR to the Garden project on GH, but it would be kind of nice to not have that warning in the meantime. It's not affecting me anyway.
#2022-08-1019:12Jack ArringtonAnd to clarify—I don't want to disable all warnings, just the one#2022-08-1019:35Jack ArringtonAlso, on a little further investigation, I'm not sure why this warning is even happening anyway. There isa (:refer-clojure :exclude [abs complement]) in the NS form of the relevant garden/color.cljc file. Not sure if that has anything to do with shadow-cljs though, or is an issue with the CLJS compiler#2022-08-1019:49thhellerhttps://github.com/noprompt/garden/commit/7a47503d0481382f85b643ae431cefb2ad88ee4c#2022-08-1019:49thhellerI'm guessing you just have an older garden version? or maybe that change is not in a release yet?#2022-08-1019:51thhellerand no there is no setting to disable specific warnings#2022-08-1020:01Jack ArringtonMy garden version is the latest at 1.3.10, and it looks like that version release was made after the commit you linked above, so it'd be odd for it not to be included in the release#2022-08-1020:03thhelleryou can easily check. open up a REPL and ( "garden/color.cljc") and just look at it#2022-08-1020:05thhellerbut just judging from the commit history the last release is much older than that commit#2022-08-1020:05thhellerhttps://github.com/noprompt/garden/commits/master#2022-08-1020:06thhellerhttps://github.com/noprompt/garden/commit/16a390186fea989e8049c00cd57f9bdd82a22fd3#2022-08-1020:06thhellerover 2 years older actually#2022-08-1020:07Jack ArringtonAh, I had misread the year there 🙂#2022-08-1020:07Jack ArringtonI can nudge the repo owner to create a new release. Thanks for the help#2022-08-1120:08muje hoxerunning shadow with react native, but it requires rebuild to reload on device, is that the default or is there a problem, because i saw krell updating when code is run on the repl#2022-08-1120:09muje hoxeis this feature only available with krell?#2022-08-1120:35thhellerhot reload is fully supported. It does however using the proper annotation and render function#2022-08-1120:35thhellersee https://github.com/PEZ/rn-rf-shadow#2022-08-1120:36thhelleror https://github.com/thheller/reagent-react-native#2022-08-1120:37thhellerthe key piece is this https://github.com/thheller/reagent-react-native/blob/master/src/main/test/app.cljs#L31-L34#2022-08-1120:39muje hoxeyes i started from this template, should i re evaluate that piece each time i load or change a function?#2022-08-1120:40thhellerno, should all work on its own. but it requires that your running app was able to connect back to the shadow-cljs instance#2022-08-1120:40thhellermaybe the websocket connect fails?#2022-08-1120:40thhellercheck the react-native logs#2022-08-1120:41thheller(I don't use react-native myself, so the help I can offer is limited)#2022-08-1120:41thhellerit might be picking the wrong IP to connect to#2022-08-1120:48muje hoxepretty much connected, using calva#2022-08-1120:48thhellerdon't know what you mean by that#2022-08-1120:48muje hoxenpx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :app shadow-cljs - config: /home/o/Documents/clj/repos/shadow-cljs.edn shadow-cljs - server version: 2.19.8 running at http://localhost:9630 shadow-cljs - nREPL server started on port 46535 shadow-cljs - watching build :app [:app] Configuring build. [:app] Compiling ... [:app] Build completed. (93 files, 0 compiled, 0 warnings, 9.23s) [:app] Compiling ... [:app] Build completed. (93 files, 1 compiled, 0 warnings, 0.48s)#2022-08-1120:48muje hoxehere is the output#2022-08-1120:49thhelleryes, that looks fine#2022-08-1120:49thhellercheck http://localhost:9630/runtimes#2022-08-1120:49muje hoxeit refreshes only when i save the file#2022-08-1120:49thhellerif your react-native app is properly connected it should list it there#2022-08-1120:50muje hoxe#1 JVM Clojure Runtime Connected 45 minutes ago #12 - build: app react-native - Connected 1 minute ago#2022-08-1120:50thhellerok then it seems connected fine#2022-08-1120:50thhellerthe metro log should tell you what shadow-cljs is doing#2022-08-1120:51muje hoxeinfo Reloading app... BUNDLE ./index.js LOG Running "AwesomeProject" with {"rootTag":61} ERROR TypeError: undefined is not an object (evaluating 'device.id') This error is located at: in Camera (created by repos.app.cam) in repos.app.cam in RCTView (created by View) in View (created by repos.app.root) in repos.app.root in Unknown in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in AwesomeProject(RootComponent) ERROR TypeError: undefined is not an object (evaluating 'device.id') This error is located at: in Camera (created by repos.app.cam) in repos.app.cam in RCTView (created by View) in View (created by repos.app.root) in repos.app.root in Unknown in RCTView (created by View) in View (created by AppContainer) in RCTView (created by View) in View (created by AppContainer) in AppContainer in AwesomeProject(RootComponent) LOG shadow-cljs #14 ready!#2022-08-1120:52muje hoxei am suspecting that these errs is related to the application#2022-08-1120:52muje hoxeare*#2022-08-1120:52thhellerlooks like it#2022-08-1120:53muje hoxethey repeat twice, why is that?#2022-08-1120:53thhellernot a clue#2022-08-1120:53thhellercan't see your code and don't know much about react-native to begin with#2022-08-1120:53muje hoxeyeah when i comment the responsible line it works fine#2022-08-1120:54muje hoxeso it is related to the code not the connection#2022-08-1120:56muje hoxewell thanks anyway#2022-08-1121:47muje hoxei think there is a problem with the repl#2022-08-1121:47muje hoxenil ; No available JS runtime. ; See https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2022-08-1121:48muje hoxei tried to eval (some? nil)#2022-08-1121:48thhellerwell, I guess it is not connected properly#2022-08-1121:48thhellercheck the runtimes page again#2022-08-1121:54muje hoxenever mind just syntax err prevented exe now its working but reloading is still missing without saving and rebuild, sorry kind of noob here#2022-08-1121:55thhelleragain .. the log will tell you what shadow-cljs is doing#2022-08-1121:55thhellerand maybe this helps explanining what hot-reload does https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-08-1122:14SriI was upgrading to latest {:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "dca8b5bfb79cecf2e9f2ec"}, :content ("[email protected]")}. I changed my code to point to tick.core instead of tick.alpha.api. Running release locally I have no issues, but running on CI (github action) gives me the following error. I have removed all references to tick.alpha.api in my code. Any help in pinpointing what the issue could be?
Run shadow-cljs -v release app
  shadow-cljs -v release app
  shell: /usr/bin/bash -e {0}
  env:
    SSH_AUTH_SOCK: /tmp/ssh-puo472pwx35q/agent.1748
    SSH_AGENT_PID: 1749
    JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.16-8/x64
shadow-cljs - config: /home/runner/work/innsmouth/innsmouth/shadow-cljs.edn
shadow-cljs - starting via "clojure"
DEPRECATED: Libs must be qualified, change figwheel-sidecar => figwheel-sidecar/figwheel-sidecar (deps.edn)
DEPRECATED: Libs must be qualified, change hashp => hashp/hashp (deps.edn)
[2022-08-11 22:00:26.689 - WARNING] :shadow.build.classpath/bad-jar-contents - {:jar-file "/home/runner/.m2/repository/re-frame-utils/re-frame-utils/0.1.0/re-frame-utils-0.1.0.jar", :bad-prefix "out", :bad-count 67}
[:app] Compiling ...
-> build target: :browser stage: :configure
<- build target: :browser stage: :configure (5 ms)
-> Resolving Module: :app
The required namespace "tick.alpha.api" is not available, it was required by "innsmouth/controller/accounts.cljs".
#2022-08-1122:15thheller> The required namespace "tick.alpha.api" is not available, it was required by "innsmouth/controller/accounts.cljs". #2022-08-1122:16thhellerthe error seems pretty clear? I cannot see your code so dunno what else might be up#2022-08-1122:16SriThe problem is I tick.alpha.api does not seem to be referenced directly. I already did a search.#2022-08-1122:17thhellerthen check if the innsmouth/controller/accounts.cljs file actually is what you think it is#2022-08-1122:17thhellerI don't know what you have in your deps.edn so maybe you are loading that from a library or something#2022-08-1222:47jon rostranis it possible to import cljs in a clj build hook file ?#2022-08-1222:49thhellersorry I don't understand the question#2022-08-1222:49thhellerwhat do you mean by "import cljs"#2022-08-1222:50jon rostrana build hook file importing a function in the cljs source-paths and invoking it#2022-08-1222:50jon rostranrequiring#2022-08-1222:50thhellerwhat does that mean?#2022-08-1222:51thhellerCLJ only runs the JVM code, it cannot invoke CLJS/JS code no#2022-08-1222:51jon rostranI have a function written in a cljs file with the cljs file ext. the hook file is written in cljc ext and I need to grab a function in the cljs file to use in the cljc hook file#2022-08-1222:52jon rostranI was looking at reader conditionals https://clojure.org/guides/reader_conditionals#2022-08-1222:52thhellerdon't know why your hook is cljc but it sound like you are trying to do something that is not possible?#2022-08-1222:52thhellermaybe try to describe what you are trying to do more?#2022-08-1222:53thhellerwhat does this function do?#2022-08-1222:53jon rostranI have a hooks.main file#2022-08-1222:53jon rostranand it calls hiccup html, I need to grab a component in the cljs side and call it inside hiccups html#2022-08-1222:55thhellerwhat do you mean by "call it inside". this is CLJS code, so it is meant to run in the browser?#2022-08-1222:55thhellerif you are trying to use hooks to do some kind of server side rendering stop, they are not meant to do that and can't do that#2022-08-1222:55jon rostranI need to call the function that wraps the component inside hiccup’s html form#2022-08-1222:55jon rostranso that it returns a string for example#2022-08-1222:56jon rostranit’s means to compile to an index.html file#2022-08-1222:56jon rostranit’s meant*#2022-08-1222:56jon rostranbut I need to insert a component when the index.html builds#2022-08-1222:56jon rostransince I already have it written somewhere else#2022-08-1222:57thhellerwhat do you mean by "insert a component"?#2022-08-1222:57thhellerI mean a component is a dynamic thing that runs in the browser (I assume)#2022-08-1222:57thhellerbut again .. this sounds like you are trying to do server-side rendering#2022-08-1222:57thhellerwhich hooks shouldn't do and really cannot do properly#2022-08-1222:58thhelleror I just fundamentally do not understand what you are asking 😛#2022-08-1222:58jon rostranI mean that when the hook runs and invokes hiccups html, I want to write a symbol that references a reagent component definition written in cljs, then I want that fn call to return inside the html hiccup form, I want to eval it and return when the build calls html#2022-08-1222:59jon rostransaid component is just hiccup markup doesn’t have anything fancy#2022-08-1222:59thhellerso you want to take the html this component generates and dump it statically into a .html file#2022-08-1222:59jon rostranexactly#2022-08-1222:59thhellerthis is generally called server-side rendering. this is not supported and build hooks cannot do that and really absolutely should not do that#2022-08-1223:00jon rostranthe build hook outputs a static index.html file, in that file I want to include that component written in cljs/reagent#2022-08-1223:00thhelleryes, you keep saying that but it doesn't make sense 😛#2022-08-1223:00jon rostranI think what u said earlier is what I’m trying to do#2022-08-1223:01jon rostrananyway, is this possible? tried requiring the cljs with reader conditional#2022-08-1223:01jon rostranbut doesn’t work#2022-08-1223:02thhellerno, fundamentally not possible with reader conditionals#2022-08-1223:02thhellerand also not possible in build hooks#2022-08-1223:02jon rostranok#2022-08-1223:03thhellerI mean everything is possible but this is not what build hooks are designed to do#2022-08-1223:03thhellerso you are better off doing is elsewhere#2022-08-1223:03jon rostranok, I guess my build hook will be used strictly to prepare a static index.html to then mount the app#2022-08-1223:04thhellerI mean you can make a :node-script build that takes your CLJS code and uses react-based server side rendering to create that index.html#2022-08-1223:04thhellerthat is totally doable#2022-08-1223:05thhellerbut combining this with build hooks doesn't make sense and shouldn't be done#2022-08-1306:40colinkahnTrying to compile a file with the following results in Cannot infer target type in expression (. (. Foo -prototype) -bar)
(deftype Foo []
  Object
  (bar [this] nil))
Tried this using cljs.main and didn't see any such warnings. Seems like it was addressed awhile ago in this ticket - https://clojure.atlassian.net/browse/CLJS-2862, and I'm using the latest shadow-cljs / clojurescript version
#2022-08-1306:50thheller@colinkahn I get no such warning. you sure you are on the latest versions? people often forget that the package.json version doesn't matter when using deps.edn/project.clj?#2022-08-1306:52colinkahnI was double checking using --cli-info, which gives me:
=== Version
jar:            2.19.8
cli:            2.19.8
deps:           1.3.2
config-version: 2.19.8
#2022-08-1306:53thhellerstill doesn't tell you anything#2022-08-1306:53thhellerthat only tells you about the shadow-cljs command itself#2022-08-1306:53thhellerdo you use deps.edn or project.clj?#2022-08-1306:53thhellerthe version you need is printed on startup#2022-08-1306:54thhellerI guess I should add a proper command for this#2022-08-1306:55colinkahnI was compiling using npx , but I can setup a deps.edn file#2022-08-1306:55thhellerno, you do not need that.#2022-08-1306:56thhellerI'm just asking IF you use it#2022-08-1306:56thhellerie. do you have a :deps or :lein key in shadow-cljs.edn?#2022-08-1306:56colinkahnah, no I do not#2022-08-1306:57thhellerok then you are indeed on the latest version I guess#2022-08-1306:57thhellerin what context do you get that error?#2022-08-1306:57thhellerI just pasted that code into a file and get no errors/warnings#2022-08-1306:57colinkahnI can get it from running npx shadow-cljs compile :app with a shadow-cljs.edn that looks like:
;; shadow-cljs configuration
{:source-paths ["src" "test"]

 :dependencies
 []

 :builds
 {:app {:target :browser
        :output-dir "public/js"
        :asset-path "/js"
        :modules
        {:main {:init-fn example.browser/init}}}}}
#2022-08-1306:59thhellerand what is in example.browser?#2022-08-1307:01colinkahn
(ns example.browser)

(deftype Foo []
  Object
  (bar [this] nil))

(defn init []
  (js/console.log (Foo.)))
#2022-08-1307:02thhellerhmm weird. I can reproduce it. checking#2022-08-1307:54thhellerhmm weird it appears to have something to do with AOT#2022-08-1307:54thhellerif you set :aot false in shadow-cljs.edn it goes away#2022-08-1307:54thhellernot sure why#2022-08-1309:26thhellerfixed in master, warning will be gone in next release#2022-08-1313:45colinkahnThanks!#2022-08-1317:33zimablueHi, using shadow-cljs with a dependency on a library called membrane with this in the deps.edn:
:deps/prep-lib {:alias :build
                 :fn compile
                 :ensure "target/classes"}
and get this error:
Error building classpath. The following libs must be prepared before use: [com.phronemophobic/membrane]
cannot work out how to resolve it, clojure -X:deps prep doesn't appear to be doing anything
#2022-08-1317:39dpsuttoncan you share your deps.edn?#2022-08-1317:41dpsuttonI have a deps.edn like:
{:deps {io.github.phronmophobic/membrane {:git/sha "75d38cca6973a4cdd073d3c0a41cb7fb3f48ad77"}}}
and then the following terminal session:
❯ clj
Error building classpath. The following libs must be prepared before use: [io.github.phronmophobic/membrane]


/tmp/prep
❯ clj -X:deps prep
Prepping io.github.phronmophobic/membrane in /Users/dan/.gitlibs/libs/io.github.phronmophobic/membrane/75d38cca6973a4cdd073d3c0a41cb7fb3f48ad77
WARNING: compile already refers to: #'clojure.core/compile in namespace: build, being replaced by: #'build/compile
warning: [options] bootstrap class path not set in conjunction with -source 8


/tmp/prep
❯ clj
Clojure 1.11.1
user=> (doto 'counter require in-ns)
counter
counter=> (java2d/run #(counter @counter-state))
#:membrane.java2d{:repaint #object[membrane.java2d$run$fn__3719 0x38cf3ae1 "
#2022-08-1317:53zimabluejust looking at what commit you're pointing at#2022-08-1317:54dpsuttonWhat do you mean?#2022-08-1317:55zimabluewas looking for that membrane git commit hash and it's ahead of the latest one I've pulled#2022-08-1317:55zimablueI'll try with that version in a blank project#2022-08-1319:34johnTrying to test out SABs with shadow. I need to enable COOP/COEP for crossOriginIsolated and I've added this to my config:
:dev-http
 {8280 {:root "resources/public"
        :push-state/headers {"content-type" "text/html; charset=utf-8"
                             "Cross-Origin-Opener-Policy" "same-origin"
                             "Cross-Origin-Embedder-Policy" "require-corp"}}}
But js/crossOriginIsolated is still false. Is the only way to get this working by setting up https or am I missing something? I think I had it working in figwheel and I don't recall setting up any https certs.
#2022-08-1319:35thhellerdid you check if the headers are set?#2022-08-1319:40johnI'm not seeing those particular ones in there#2022-08-1319:41john#2022-08-1319:42johnDoes it matter it's a 304?#2022-08-1319:43thhellerah, no I think there is an open ticket about this#2022-08-1319:43thhellerthe push-state headers are never used when index.html exists#2022-08-1319:44johnah#2022-08-1319:44thhellerbut I recommend using your own server anyways as soon as you need it to do any kind of custom stuff#2022-08-1407:50thheller@john 2.19.9 should respect the push-state headers properly#2022-08-1422:17tianshuDoes this work with tree-shaking? Is there a chance that some functions are used, but not seen by webpack?#2022-08-1422:17tianshuSince it only provides a require statement.#2022-08-1422:19thhellernot currently no#2022-08-1422:20thhellerin theory its possible to generate precise import that should be tree-shakable but its a lot of work#2022-08-1422:21tianshuSo this ALL will refer everything#2022-08-1422:22thhellerALL is just a variable name and means nothing#2022-08-1422:22thhellerwebpack tree-shaking just works off import and not require#2022-08-1422:23tianshuIf some libraries are designed with tree-shaking, parts of code will be missed with this method?#2022-08-1422:25thhellertree-shaking will not work at all, nothing will be eliminated. webpack just can't#2022-08-1422:28tianshuHmmm#2022-08-1422:28tianshuDoes shadow-cljs handle the polyfills? like buffer in browser#2022-08-1422:29thhellershadow-cljs also doesn't tree-shake any npm dependencies, so the end result is the same regardless of what you use#2022-08-1422:29thhellerit does polyfill when it processes npm packages yes, not when using :js-provider :external#2022-08-1422:32tianshuAh, I see. What does the pollyfill actually do? Let's say I need buffer in browser, without :js-provider :external, it works with buffer in dependencies. But when I switch to :js-provider :external, Buffer is not defined.#2022-08-1422:32tianshuSo I have to do something?#2022-08-1422:32thheller:external means shadow-cljs doesn't process ANY npm packages. whatever you use to process the :external-index (eg. webpack) will do that instead#2022-08-1422:33thhellerand newer webpack no longer provides those polyfills by default#2022-08-1422:33thhellerso you need to configure webpack to provide it#2022-08-1422:33tianshuyep, I knew webpack5 doesn't provide it#2022-08-1422:33tianshuOh, I see#2022-08-1422:35tianshuThank you!#2022-08-1422:49tianshuNow, it works to me#2022-08-1422:49tianshuJavaScript is so complex#2022-08-1519:58winsomeI'm using a cljc crytography library that depends on an npm library (sjcl) for the cljs implementation. It specifies this in a src/deps.cljs file as {:npm-deps {"@fluree/sjcl" "1.0.8-3"}}.#2022-08-1519:58winsomeWhen I fire up the shadow-cljs server, it runs running: npm install --save --save-exact @fluree/, and installs the dependency as I expect. I can see the dependency in my node modules.#2022-08-1519:59winsomeHowever, when I build it warns that sjcl is not defined.#2022-08-1520:00winsomeWhere does it go? I've got author rights to the cljc crypto library, is there a different way I should package js dependencies?#2022-08-1520:00thhellerwhat is the actual error?#2022-08-1520:01winsomeEvery usage of sjcl in the crytography library generates a Use of undeclared Var warning.#2022-08-1520:01winsomeAnd all of it fails at runtime because none of those vars are there.#2022-08-1520:02thhellerbe more specific please. Otherwise I have to guess too much about what you are describing#2022-08-1520:03winsomeLet me put together a small reproduction, it may be easier to show.#2022-08-1520:03thhellerjust the errors might be enough. don't expect me to run anything before seeing those#2022-08-1520:06winsomeAlright, here's one, there are 36 total, all in the same form:
Warning :undeclared-var in fluree/crypto/scrypt.cljc at 40:29
Use of undeclared Var fluree.crypto.scrypt/sjcl

  37 |    (encrypt raw salt n r p 32))
  38 |   ([raw salt n r p dk-len]
  39 |    #?(:clj  (SCrypt/scrypt raw salt n r p dk-len)
  40 |       :cljs (let [rawBits  (sjcl.codec.bytes.toBits raw)
  41 |                   saltBits (sjcl.codec.bytes.toBits salt)
  42 |                   length (* 8 dk-len)
  43 |                   res (sjcl.crypt.scrypt. rawBits saltBits n r p length)]
  44 |               (sjcl.codec.bytes.fromBits res)))))
#2022-08-1520:07thhelleryeah thats just invalid code#2022-08-1520:08winsomeIn what way? Because it works (or has worked) in the browser before.#2022-08-1520:08thhellerit has ["@fluree/sjcl" :as sjcl]#2022-08-1520:09thheller:as sets up a namespace alias so sjcl.codec.bytes.toBits should be sjcl/codec.bytes.toBits#2022-08-1520:10thhellerthis also isn't a warning from shadow-cljs?#2022-08-1520:12winsomeThat's my bad then, I've been trying to convert the build process over to shadow-cljs and assumed that this was new. Now I'm confused as to how this worked before#2022-08-1520:13thhelleras far as I'm concerned this is invalid code. it might happen to work accidentally due to some legacy stufff#2022-08-1520:14winsomeAlright, so the proper way to do it is to use the sjcl namespace. Thanks for the insight#2022-08-1520:04thhellerUse of undeclared Var is not related to npm in any way and those would not generate this error#2022-08-1521:15winsomeI'm building a browser package and a node package from the same cljs codebase and I have one namespace that depends on node's fs module. When I build my browser package I get a The required JS dependency "fs" is not available error. There's a helpful note: "fs is part of the node-libs-browser polyfill package to provide node-native package support for none-node builds. You should install shadow-cljs in your project to provide that dependency." Which I have done but I still see the error. Is there another way to fix this error? I'd rather just only try to require the fs module in the node build.#2022-08-1605:29thhelleryou can set :js-options {:resolve {"fs" false}} in the build config. if the lib however actually tries to use anything from fs that will cause an error#2022-08-1521:35alexDoes shadow-cljs expose a mechanism for attaching additional headers to the HTTP GET requests for lazy-loaded modules? In our case, we host our code-split JS files on a Google Cloud Storage bucket (with Google Cloud CDN + caching). Because the lazy-loaded modules are a CORS request from browser -> GCS, we want to send along some additional headers to manage CORS#2022-08-1605:43thhellercommon misconception but CORS headers need to be sent by the server. not the client.#2022-08-1613:23alexYep I configured the server to send back the access-control-allow-origin CORS header The reason I want to configure the client request is that I'm hoping to send a custom header from the client that can be used by the Cloud CDN as part of the cache key. By default, Cloud CDN ignores the origin request header (because theoretically there can be an unbounded number of origins, in which case the cache is very inefficient). As a result, Cloud CDN is caching headers/responses from one subdomain and sending it back to another requesting subdomain, causing CORS issues (since the access-control-allow-origin header doesn't match the requesting origin) One fix is to set access-control-allow-origin: * on the server side, but I also wanted to explore passing a custom header up that cloud CDN can use as part of the cache key#2022-08-1614:16thhellerfor caching you generally do this https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output#2022-08-1614:17thhellernever heard of anyone using headers to control caching since that at least requires sending the request to verify the cache?#2022-08-1614:17thhellerthere is also no way to set any headers using the default loader mechanism. you can of course just build your own#2022-08-1617:47alex> for caching you generally do this https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output Yep, we've implemented the module hashes > never heard of anyone using headers to control caching since that at least requires sending the request to verify the cache? For API requests, client passing If-Modified-Since header is a common mechanism. The server checks if the resource has been modified since that datetime -- if so, returns 200 with the response; if not, returns a 304 > there is also no way to set any headers using the default loader mechanism. you can of course just build your own Got it, thank you#2022-08-1617:53thhellerif you have the module hashes why bother with any other caching? the purpose of the hashes is that the files can be cached indefinitely and never need to be checked. changing any code will end up changing the hash.#2022-08-1617:55thhellerby headers I meant custom headers. if-modified-since and stuff is already handled by the browser and you don't set anything for those yourself.#2022-08-1522:16alexI almost always have a running shadow-cljs watch process on a browser build. I load the app in the browser and connect to the nREPL via CIDER. Occasionally when I try to eval code in my source code buffer or REPL buffer, I get an error that "No JS runtime is available". I then reload the browser, thinking that might make the runtime available again; if that doesn't work, I disconnect from the nREPL server, then reconnect. Recently this hasn't been working for me So today I navigated to Shadow's http server at localhost:9630 to see if it knew about the browser runtime. According to the dashboard, it did not (1st screenshot). I then restarted the shadow-cljs watch process, loaded the app up again in the browser, and verified that the browser runtime was available (2nd screenshot) Do you know what might cause the shadow-cljs process to not recognize the browser runtime? Are there any additional debugging steps I should take?#2022-08-1605:43thhellercheck the browser console logs#2022-08-1613:32alexI'm not running into the issue right at the moment, but when I do, should I be looking for errors in the console logs?#2022-08-1614:13thhelleryou should always look in the browser console first yes#2022-08-1615:17sirwobinWhat does "Cannot set property 'returnExports' of undefined" mean? I've created a node-library target in shadow-cljs, zipped the resulting js file and uploaded it as function code for an AWS lambda. When I call the lambda I get this error.#2022-08-1615:23sirwobinI export one function called 'handler' in js and I'm confident that it is being called correctly. Some environment checking code was throwing exceptions correctly, I fixed the env and then got this error.#2022-08-1615:28thhelleris this script maybe trying to be loaded as a module? ESM?#2022-08-1615:28thhellerwhat is the full error? what is the build config?#2022-08-1615:28thhellerdid you include the node_modules when bundling? assuming you use any npm packages?#2022-08-1615:29thhelleris there more than one error and maybe this one a symptom of the other?#2022-08-1617:01sirwobinI haven't included the node_modules. I thought the closure compiler included necessary dependencies. While I haven't added any node_modules, shadow-cljs has quite a few. Should I include all node_modules?#2022-08-1617:03thhellerno, you only need to include the packages you actually use. you can also post-process the release build with something like https://github.com/vercel/ncc to bundle all npm dependencies#2022-08-1617:04thhellershadow-cljs does not do that by default since generally it is not required or desirable for regular node builds#2022-08-1706:40sirwobinThank you for the help btw. 🙂 Very much appreciated. Shadow is #2022-08-1706:41sirwobinMy build config looks like this:
:builds
 {:lambda {:target :node-library
           :exports {:handler com.pds.external-api.core/handler}
           :output-to "target/lambda.mjs"
           :compiler-options {:output-feature-set :es2020}}}
#2022-08-1706:41sirwobinDoes something not look right?#2022-08-1706:52thhellerwell the hint seems to be that you have :output-to "target/lambda.mjs" meaning its expected to be a ES module?#2022-08-1706:52thheller:node-library outputs commonjs so that won't work#2022-08-1706:53thhellerif it must be a module use :target :esm https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm#2022-08-1706:54thhelleror just :output-to "target/lambda.js" and just run without modules?#2022-08-1709:49sirwobinchanging the build target to .js worked perfectly. Thank you! I copied that entry from an example without understanding the significance.#2022-08-1709:53sirwobinSo when I package the zip file, I should take care to include my own node_modules and their deps? Can shadow help me determine those deps or should I figure them out via dep trees and select what to zip?#2022-08-1712:00sirwobinor should I just take everything in node_modules?#2022-08-1714:51sirwobinFYI: transitive dependencies for any top level node package can be listed with npm ls -a --json | jq --arg v 'shadow-cljs' '[ .dependencies | .[$v] | .dependencies | .. | .dependencies? | objects | to_entries[] | .key ] | sort | unique' and changing the value of --arg v#2022-08-1715:09thhellerme recommendation is either post processing with ncc to get a completely standalone .js file#2022-08-1715:09thhelleror creating a dedicated directory that has its own package.json and only includes the packages you actually need in production#2022-08-1715:10thhellerand the build output going into that dir and then just zipping that entire dir#2022-08-1715:38sirwobinThat's great advice. Thank you#2022-08-1810:32ilevdWhy does shadow-cljs sometimes get stuck with > sign?
lein clean && shadow-cljs watch app
shadow-cljs - config: /media/ssd//my-project/shadow-cljs.edn
shadow-cljs - connected to server
> 
#2022-08-1818:11thheller@ilevd not sure. I've never seen that#2022-08-1823:57johnis that path legit? /media/ssd//my-project/shadow-cljs.edn#2022-08-1901:54skylizeWould there be straightforward way to automate an edit to package.json for specific build(s)?#2022-08-1901:56skylizeCase is a generic template for development of VS Code extensions using a repl. An extension must be "activated" to create the environment the repl should run in. Code lazily activates extensions, and only under specified conditions, such as for a certain language or after User runs a command provided by the extension. The author must whitelist events to trigger activation in package.json. There is a * option, which tells Code to just activate after any possible activation event, which roughly translates to ASAP. An extension only needed in limited cases should avoid using *, because that slows startup for no reason. However while developing in cljs, it would usually be the best option, to ensure the js repl is available straight away, without awkward steps between building and repl-ing. So it would be great to be able to declare * activation event only for a particular dev build, while still using the rest of package.json as written, and still allow writing more specific activation events that would apply otherwise.#2022-08-1906:21thhellerI'd say to build this yourself. Just make a command in the REPL that edits package.json the way you want. or create it as part of however you launch the watch. so maybe npm run dev or whatever and the proper "scripts"#2022-08-1906:21thhellerthere is nothing in shadow-cljs to do this and I can't think of anything that would be easier to do than just doing it yourself#2022-08-1913:56mccraigmccraigi'm having an issue with an expo/react-native app compiled with shadow-cljs atm ... production builds are working fine, but watch builds are failing on the device with an error like: Error: Unable to resolve module ./app/goog.math.long from /Users/mccraig/dev/employeerepublic/repos/yapster/yapster-app/app/.: interestingly, i note that we had to use: "entryPoint": "./index.js" in our expo app.json, instead of the "entryPoint": "./app/index.js" suggested by the shadow-cljs user guide and i'm wondering if these things are connected has anyone seen anything similar ?#2022-08-1916:04thheller@mccraigmccraig are you sure that device has the same output? I mean could just be an easy path mixup? in the above error it is trying to find /Users/mccraig/dev/employeerepublic/repos/yapster/yapster-app/app/app/goog/match.long.js? seems to have a duplicated app?#2022-08-1916:43mccraigmccraigi'm not sure where the app in app/goog.math.long is coming from actually... and we have a yarn workspace setup which might be messing things up too... the error messages from expo/metro are often not very informative, so i'm going to strip things back to a basic setup which works and move forward from there#2022-08-1917:54thhellerwell just grepping for app/goog.math.long in your project should tell you where its coming from#2022-08-1918:49mccraigmccraigapp/goog.math.long doesn't appear in any of the source...#2022-08-1918:49mccraigmccraigbut it turns out that it's hermes related - disabling hermes makes the watch builds work fine again#2022-08-1918:50mccraigmccraigthe release builds are fine with hermes (which does make a massive cold-boot time-saving)#2022-08-1918:51mccraigmccraigthere's definitely something about our packaging which is triggering the issue though - 'cos enabling hermes on the expo-reagent-demo does not seem to break watch builds#2022-08-1918:17alexWould you suggest this approach for breaking out browser vs. node code? This is related to having host-specific impls for SSR https://gist.github.com/thheller/fa044450a6470fdd1afdbcf3f37a65e3 For browser, I'll have something like
:modules {:browser {:entries [components.host-specific.browser]
                                              :init-fn components.host-specific.browser/init
                                              :depends-on #{:shared}} 
Is it possible to get something up like this for the node-library target? I want to have the Node side call a similar node-specific init fn
#2022-08-1918:20thhellerfor :node-library you can do it via :exports-var I guess#2022-08-1918:21thheller(def my-exports (do (whatever-init-you-want) #js {:foo "bar"}) and :exports-var that.ns/my-exports#2022-08-1918:30alexAt the moment we have that exports-var set to export an object of Firebase cloud functions. Is there a nice way to merge exports? Are :exports-var , :exports-fn and :exports mutually exclusive, or can they be used together?#2022-08-1918:32thhellerdon't really need any of the others if you have :exports-var since that can do everything you could possibly need?#2022-08-1918:33thhellerjust move whatever you have in the config to that var#2022-08-1919:03alexThanks!#2022-08-1919:14alexSeems to be working like a charm! Wish I had gone with this approach earlier 🙂 Feels a lot more manageable than the .cljc files and browser/node reader conditionals I originally went with#2022-08-1920:35winsomeI've connected my editor to a :node-library build and I'm getting a No available JS runtime. error. The troubleshooting docs have a section on the :node-script and :node-library targets, but I'm not sure what it means to "run" a library in a node process.#2022-08-2007:56thheller@winsome you probably just want to run node-repl and use that. that has a manged node process started for you. otherwise it just means that you run whatever code that would have included your library code#2022-08-2015:12aibaIs it possible to access the current build-id or build-mode at compile-time (during macroexpansion)?#2022-08-2016:10thhellerno for build-id, yes for build-mode. :shadow.build/mode in the macro &env#2022-08-2118:21aibaThat's helpful, thank you. And it seems (:shadow.build/mode &env) is nil when shadow is watching a build and hot reloading a namespace, is that expected?#2022-08-2118:57aibaActually i'm sometimes getting nil values for (:shadow.build/mode &env) inside macros, even when doing a release build. it's almost like there is some kind of compliation pass that happens which causes macroexpansion before the build environment is set. I also noticed that there are some macroexpansions that happen before the :configure stage of hooks are called.#2022-08-2119:09thhellerthere can be no macro expansions before :configure. well unless those macros are in .cljc and you do anything in CLJ?#2022-08-2119:10thhellerneedless to say it is only set for CLJS compilation. otherwise it won't be present, but it should always be present for CLJS code?#2022-08-2119:32aibaYeah it is in a cljc file, and i have some toplevel constants that are set to like (def foo (my-macro)). in those cases, could my-macro be being called with nil build-mode and before the :configure stage?#2022-08-2119:47thhellerthere is absolutely no CLJS compilation happening before :configure so no#2022-08-2303:54Drew VerleeReally quick 🔥 take. 1. The GitHub readme doesn't need to say wip next to the link to the user docs, they are amazing and more mature than I am. 2. I would put the doc link at the top of the readme or something as i think it's too easy to scroll past. I have no strong feelings about this, it just occurred to me while skimming the readme for like the 50th time.#2022-08-2308:58danbuneawith-meta, when targeting node for the compilation results in a is not a function TypeError. Context: I am trying to use spy (https://github.com/alexanderjamesking/spy) for mocking in some tests, and it seems in cljs it doesn't work when targeting node. To reproduce the issue, run: npm run test on https://github.com/DanBunea/spy-test#2022-08-2309:33thhellerwith-redefs requires using :compiler-options {:static-fns false} in your build config#2022-08-2309:33thheller(which I think is what spy needs too)#2022-08-2309:58danbuneaThank you @U05224H0W All works now 🙂#2022-08-2309:59danbuneaI also updated the github project for the others to see how this problem is solved#2022-08-2309:19mrchanceHi! I upgraded some npm module versions to the latest, and after the upgrade, I'm getting
shadow.module.app.append.js:4 An error occurred when calling (<my-stuff>/init)
An error occurred when loading shadow.module.app.append.js
router.cljc:204 Uncaught ReferenceError: regeneratorRuntime is not defined
...
    at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198:44)
    at eval (router.cljc:146:64)
I saw there was some discussion in the channel before ( https://clojurians.slack.com/archives/C6N245JGG/p1644314413332399?thread_ts=1644313184.796159&amp;cid=C6N245JGG ) and the recommendation was to install regenerator-runtime, but the problem seems to be coming from re-frame, it worked before, so I wanted to ask more about what's going on there
#2022-08-2309:21mrchance(Update: Doing that fix worked, just had to require it once in my main namespace)#2022-08-2410:07sirwobinI've just received an error trying to attach metadata to a keyword. I'm targeting nodejs. Is that expected?#2022-08-2410:42bgin Clojure Keywords can’t contain metadata. They don’t implement the IObj interface. CLJS shouldn’t be too different.#2022-08-2416:51thhellercorrect, keywords can't have metadata#2022-08-2413:25Yehonathan SharvitCan we load a local json file in node.js as part of the ns form?#2022-08-2416:54thhellerno, the ns form loads code.#2022-08-2417:31Yehonathan SharvitDoes it mean the only way to do so is through the async fs API?#2022-08-2417:32thhellerno? what are you trying to do exactly and in what context?#2022-08-2417:33thhellerI mean technically in node targets you can load .json files via the ns require but I don't think you should 😛#2022-08-2417:33thheller(def json (js/require "./that.json")) works too#2022-08-2417:43Yehonathan SharvitI am building a cljs app that reads it's config from a JSON file#2022-08-2417:46thhellerat which point? on program startup?#2022-08-2418:27Yehonathan SharvitYes. On program startup#2022-08-2508:04Yehonathan SharvitWhat’s the folders where js/require looks for the file?#2022-08-2508:28thhellerdepends on where it is used#2022-08-2508:28thhelleryou can also just use (fs/readFileSync "./that.json"), just need to also (js/JSON.parse ...) it#2022-08-2508:29Yehonathan Sharvit> depends on where it is used What do you mean?#2022-08-2508:29thhellerwell in which context do you use it? is it a :node-script build?#2022-08-2508:30thhellerthen it is relative to the :output-to file#2022-08-2508:30Yehonathan SharvitYes#2022-08-2508:30Yehonathan SharvitLet me try it#2022-08-2508:30thhellerthe fs/readFileSync would be relative to where the node process was started#2022-08-2508:31thhellerso usually that is the better option if you want to make it runnable as a package but use a file from outside the package#2022-08-2510:31Yehonathan SharvitOK. fs/readFileSync is appropriate for me#2022-08-2415:25sirwobinHow should one require the nodejs path module? According to https://nodejs.org/api/path.html it's require('node:path'); so I tried (:require ["node:path" :as path]) following along from https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html. That doesn't work. Neither does (:require [path :as path])#2022-08-2416:51thheller@sirwobin which build :target do you use? just (:require ["path" :as path]) should be fine (this might be dependent on which node version you use though)#2022-08-2416:54thheller(:require ["node:path" :as path]) should be fine too, but this is all dependent on which :target you use#2022-08-2419:59sirwobinI use :target :node-library with node 18.7.0, and shadow-cljs 2.19.9. Thanks so very much for taking the time to make great software and answer questions. Will have a look at patreon shortly.#2022-08-2420:03sirwobinWhen I eval my file through a cljs repl I see this error:
Syntax error macroexpanding clojure.core/ns at (src/main/com/pds/external_api/storage.cljs:1:1).
((:require [fs :as fs] ["node:path" :as path] [cljs-bean.core :refer [->clj ->js]] [promesa.core :as p] [com.pds.external-api.config :as config])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
Syntax error compiling at (src/main/com/pds/external_api/storage.cljs:9:4).
etc...
#2022-08-2420:04thhellerthat is not a cljs repl. that is a clj repl#2022-08-2420:04sirwobinThis only happened when I added "node:path" :as path]#2022-08-2420:05thhellerSyntax error macroexpanding clojure.core/ns this is an error from the clojure REPL#2022-08-2420:05sirwobinHmm, the node client did die a few times... I assumed the repl session would be automatically resumed when it connected to the watch server.#2022-08-2420:06thhellerthis is not a CLJS error so you are not in a CLJS REPL at all#2022-08-2420:06thhelleryou can just use shadow-cljs node-repl (or whatever the equiv is for your editor)#2022-08-2420:06sirwobinEach time the node repl provider dies I should send (shadow/repl :lambda)#2022-08-2420:07sirwobinfrom my nrepl client.#2022-08-2420:07sirwobinto restart the cljs repl session..#2022-08-2420:07thhellerI assume you use emacs so I can't really answer any questions regarding that#2022-08-2420:07thhellerbut no you should never need to restart the REPL ever#2022-08-2420:07sirwobinI think I have enough clues, thank you and sorry to disburb#2022-08-2420:07sirwobinI hadn't realised those were clj repl errors#2022-08-2420:09sirwobinI'm using nvim and conjure. While making node fs functions, the node repl provider would crash if ever my functions returned a js/Error instead of throwing it. Node would just quit. Returning a map with namespaced key seemed a sensible replacement and it works. But discovering that meant restarting the node repl provider quite a few times.#2022-08-2420:10sirwobinEach time I evaled the buffer to reload a namespace, it seemed to resume the repl session very easily#2022-08-2420:10sirwobinand remain in a cljs repl when reconnected.#2022-08-2420:11sirwobinBut maybe this hasn't happened always?#2022-08-2420:12sirwobinJust reissued the (shadow/repl :lambda) from my repl and it's resumed the cljs session, Seems I might need to reissue it from time to time.#2022-08-2420:12sirwobinif the node repl provider dies#2022-08-2420:15thhellerwhat is a node repl provider? what do you mean by that?#2022-08-2508:31sirwobinIn your notes somewhere you mention to run a watcher process to provide the clj repl and to run node target.js in addition to a watcher to provide a cljs repl that one can access with (shadow/repl :target) So I think of the node process as the repl provider.#2022-08-2508:31thhellerok. I call those the runtime#2022-08-2508:32thhellerso the runtime may crash and in case of :node-library you need to manually start it again. that is correct.#2022-08-2508:32sirwobinGot it. How can I recognise clj repl errors apart from cljs repl errors?#2022-08-2508:32thhelleryou do however not need to run (shadow/repl :target) again normally. the shadow-cljs watch will automatically pick the new runtime when it is started#2022-08-2508:32thhellerno clue. I don't use nvim/conjure#2022-08-2508:33sirwobin😄#2022-08-2508:33sirwobinSpoken like an emacser.#2022-08-2508:33thhellernot an emacser either#2022-08-2508:33thhellerI use Cursive 😛#2022-08-2508:33sirwobinmy mistake 😉#2022-08-2508:34sirwobinOnce again, great software 🙂#2022-08-2417:41sbSorry could you help me, how could I “translate” this to Clojurescript?
const editor = Jodit.make('#editor', {
	buttons: [
		...Jodit.defaultOptions.buttons,
		{
			name: 'insertDate',
			tooltip: 'Insert current Date',
			exec: (editor) => {
				editor.s.insertHTML(new Date().toDateString());
			}
		}
	]
});
Main question is the …Jodit.defaultOptions.buttons part.
#2022-08-2417:44Yehonathan SharvitUse assoc-in or merge#2022-08-2417:50winsome{:buttons (into Jodit.defaultOptions.buttons {:name "my-custom-button" ,,,})} could work as well.#2022-08-2417:51sbthanks!!#2022-08-2417:53winsomeWait, js arrays don't implement ICollection, so that won't work#2022-08-2417:55winsome{:buttons (into (vec Jodit.defaultOptions.buttons) [my custom buttons])}#2022-08-2419:08sb
:extraButtons
tag was the key.. I found in the Stackoverflow..
#2022-08-2417:55winsomecall vec on it first#2022-08-2417:55sbI check it, thank you very much! 🙂#2022-08-2508:39g7sI am starting shadow in embedded mode and when I start a repl I get a weird Stdin: prompt in the Emacs minibuffer instead of using the in-buffer one. Versions shadow-cljs - 2.11.23 cider - 1.5.0 I have used the same setup in the past and didn’t have this issue. Does anyone have any idea what’s going on? Couldn’t find anything around and I’m not sure if it’s cider or shadow related#2022-08-2508:40thhellerlooks like the nrepl middleware is not loaded? https://shadow-cljs.github.io/docs/UsersGuide.html#_embedded_nrepl_server#2022-08-2508:44g7s:face_palm: looks like it.. I somehow missed that I had to include the shadow nrepl middleware, I’ll try this thanks @thheller#2022-08-2514:40pezHello. When setting up a minimal project I started to wonder about the dev web server. Some questions: • In some projects out there there is :http-server and :http-port config under :build {:my-build {:devtools { .... I can't find this mentioned in the user guide. Are these deprecated, or does this have some other functionality that the :dev-http config does not give me? • The user guide says that :dev-http is not needed for code hot reloading, but will configure hot-reload of CSS automatically. If I understand things correctly. So if I want to use my own web server, I can skip configuring a :dev-http and have code hot reload, but if I want to have CSS hot reload I should configure :watch-dir. Am I understanding this correctly?#2022-08-2514:42thhellercorrect. :dev-http replaces the config in :devtools, and not using :dev-http requires setting :watch-dir for CSS reloads#2022-08-2514:46pezI also wonder about :modules {:entries [...]. Here I have trouble formulating a question, actually. 😃 The guide says that it is: > The namespaces that serve as the root nodes of the dependency graph for the output code of this module. I don't quite understand what this means. Can it be elaborated on a bit? When does this get important? I'm looking at a sample project I once created and it doesn't have any :entries configured. Only :init-fn.#2022-08-2514:47pez@U02KYBC5WJY and I are planning a video about Calva and shadow-cljs and will demo setting up a minimal project. I'd like to not spread too much misinformation in this video. 😃#2022-08-2514:47thheller:init-fn foo.bar/init desugars to :entries [foo.bar] plus calling (foo.bar/init) when the module is loaded#2022-08-2514:48thheller:entries just gives you extra ways to add code to a module. you don't need to set it if you don't need extra namespaces#2022-08-2514:49thhellerit becomes relevant when you have namespaces that aren't otherwise required but should still be included in the build#2022-08-2514:49thheller(in code splitting scenarios mostly)#2022-08-2514:50pezAwesome, thanks! We will not enter into code splitting territory in this video, but super good to know.#2022-08-2514:50thhelleryeah then just stick with :init-fn. usually there is no need for :entries without code-splitting#2022-08-2521:41vlad_pohHi getting this error and not sure how to troubleshoot. Any tips?
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
shadow-cljs watch frontend generates a js file with 41 warnings.
#2022-08-2521:46thhellergetting this error when? this would happen way before watch would ever build anything?#2022-08-2521:46thhellerI'm guessing you are using deps.edn to manage dependencies and either don't have shadow-cljs in there at all or on an alias that isn't activated?#2022-08-2521:51vlad_pohtrying to use shadow-cljs only#2022-08-2521:51vlad_pohdo i need to use deps?#2022-08-2521:52thhellerno, just shadow-cljs.edn is fine#2022-08-2521:52vlad_pohoh and the error happens when i try to jack-in calva leiningen+shadow-cljs#2022-08-2521:52thhellerwell. then you are not using shadow-cljs only are you? then you are using leiningen.#2022-08-2521:53thhellerif you jack-in with leiningen then leiningen is in control of your dependencies#2022-08-2521:53thhellerso you need to add thheller/shadow-cljs to project.clj#2022-08-2521:53vlad_pohah!#2022-08-2521:53winsomeDoes :web-worker true work in modules defined in :target :esm?#2022-08-2521:54thheller@winsome it does not, but also shouldn't be necessary#2022-08-2521:54winsomeAlright, I'll give it a swing :thumbsup:#2022-08-2521:56winsomeIs it possible to generate a "default" export using :target :esm? Right now I've got a (def exports #js {:all all :my my :fns fns}), which works, but I'd like to just export the whole ns.#2022-08-2521:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_module_default_exports#2022-08-2522:00vlad_poh@thheller I added the following to the leiningen profile
:profiles
  {:cljs
   {:source-paths ["src/cljs"]
    :dependencies [[thheller/shadow-cljs "2.19.9"]
                   [reagent "0.9.1"]]}}
and got the same error trying to jack in
Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
Socket closed
Socket closed
Socket closed
Socket closed
do i need to make changes in the shadow-cljs.edn file?
#2022-08-2522:01thheller@kbosompem when you use leiningen to manage dependencies then you need to use leiningen properly. did you enable the :cljs alias when you jack-in?#2022-08-2522:02thhellerthis is entirely emacs -> leiningen#2022-08-2522:03vlad_pohyes i check of :cljs and click ok#2022-08-2522:03thhellerdon't know what you mean by that? since when can you click anything in emacs?#2022-08-2522:03vlad_pohno i’m in calva#2022-08-2522:04thhellerso which command does it run when you jack-in?#2022-08-2522:05vlad_poh
; Jacking in...
; Starting Jack-in Terminal: lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +cljs repl :headless
; nREPL Connection was closed
; Hooking up nREPL sessions...
; Connected session: clj
; TIPS:
;   - You can edit the contents here. Use it as a REPL if you like.
;   - `alt+enter` evaluates the current top level form.
;   - `ctrl+enter` evaluates the current form.
;   - `alt+up` and `alt+down` traverse up and down the REPL command history
;      when the cursor is after the last contents at the prompt
;   - Clojure lines in stack traces are peekable and clickable.
clj꞉vgs.core꞉> 
; Creating cljs repl session...
; Connecting cljs repl: Leiningen + shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Failed starting cljs repl for build: :frontend. Is the build running and connected?
   See the Output channel "Calva Connection Log" for any hints on what went wrong.
; Jack-in done.
clj꞉vgs.core꞉> 
#2022-08-2522:05thhellerok that looks fine. what do you do next?#2022-08-2522:05vlad_pohthat’s as far as i get#2022-08-2522:06vlad_pohbackend runs but no js generated#2022-08-2522:06thhellersorry but I don't have a clue what you are doing there. I don't see a command to run a backend or any output related to that?#2022-08-2522:07thhellerI don't have a clue what calva does#2022-08-2522:07thhellerwhat is in this Calva Connection Log? any more info on what it tried to do?#2022-08-2522:07vlad_pohonly the following
Execution error (FileNotFoundException) at user/eval8784 (form-init8455403758683339037.clj:1).
Could not locate shadow/cljs/devtools/api__init.class, shadow/cljs/devtools/api.clj or shadow/cljs/devtools/api.cljc on classpath.
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed
Socket closed
#2022-08-2522:08thhellerdid you place the profile correctly?#2022-08-2522:08thhellernot nested in some other map or so?#2022-08-2522:08thhellerthat error is basically just telling you that the dependency was not loaded#2022-08-2522:09vlad_pohhttps://shadow-cljs.github.io/docs/UsersGuide.html#:~:text=...%7D%7D-,Sample%20project.clj,-(defproject%20my%2Dawesome#2022-08-2522:10thhellerthat doesn't tell me anything about what is in your actual project.clj 😉#2022-08-2522:10vlad_pohi think i’m missing the clojure and clojurescript dependency#2022-08-2522:11thhellerno, you are definitely missing the shadow-cljs dependency#2022-08-2522:11thhellerI mean to make things easier just move shadow-cljs to your main dependencies#2022-08-2600:51folconIs there an alternative way to recursively convert js objects to cljs ones? I've been spotting some odd behaviour where js->clj doesn't actually convert anything and I'm unsure why. This is post advanced compilation if that makes any difference? Not super confident if this is due to shadow specifically, I'll try and make a minimal reproducible case later. Hmm, it's an :type #object[Array], but it's failing (array? x) Ok, no idea why, but these predicates fails:
(identical? (type x) js/Object)
(identical? (type x) js/Array)
whereas these succeed:
(= (str (type x)) (str js/Object))
(= (str (type x)) (str js/Array))
No idea what's causing it...
#2022-08-2606:13thhellerdunno what you are doing so can't say much. there are some known issues with js->clj and :advanced. mostly related to very short property names clashing with protocols, this can be solved by externs.#2022-08-2606:14thhelleryou can use https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/json.cljs#L4 which doesn't have that particular issue. don't know if its in any way related to what you are doing though.#2022-08-2613:44folconThanks, to be honest I'm super surprised this doesn't work? Surely this is a bug? Also any idea if this a clojurescript issue or a shadow one? (I'm assuming clojurescript at the moment)#2022-08-2614:17thhellerI don't know what you are working with so hard to say. I'm tempted to say that its neither a bug in shadow-cljs nor cljs but instead something weird you are doing in your code#2022-08-2614:18folconI mean I'm calling js->clj on a js object and then just doing a console log into chrome.#2022-08-2614:19folconIt's very literally a stack of console.log's which I'm checking... I pulled the cond predicates from js->clj and printed them as a sanity check to see which branch it goes down... The answer is none of them, which is why it doesn't convert...
(println :satisfies? (satisfies? IEncodeClojure x))
             (println :seq? (seq? x))
             (println :map-entry? (map-entry? x))
             (println :coll? (coll? x))
             (println :array? (array? x))
             (println :object (object? x))
             (println :identical? (identical? (type x) js/Object))
             (println :type (type x))
             (println :type js/Object (identical? (type x) js/Object) (= (str (type x)) (str js/Object)) js/Array (identical? (type x) js/Array) (= (str (type x)) (str js/Array)))
#2022-08-2614:21thhellerand what does the js object look like?#2022-08-2614:21thhellerdoes the problem go away if you run with shadow-cljs release app --pseudo-names?#2022-08-2614:23folconElided example:
[
    {
        "limit": 30,
        "label": "Export ...",
        "fn_name": "get_...",
        "search_query": "...",
        "task-id": "...",
        "container_id": "214319799975"
    },
    {
        "limit": 20,
        "label": "Run ...",
        "fn_name": "run_...",
        "search_query": "...",
        "task-id": "...",
        "container_id": "799975628099"
    }
]
#2022-08-2614:24thhellerthat should be fine#2022-08-2614:24folconYea, it's really bugging me...#2022-08-2614:26thheller> does the problem go away if you run with shadow-cljs release app --pseudo-names?#2022-08-2614:26thhellerjust trying to rule out externs issues#2022-08-2614:27folconJust tried that, the only true is on the string check ones, ie: (println :type js/Object (identical? (type x) js/Object) (= (str (type x)) (str js/Object)) js/Array (identical? (type x) js/Array) (= (str (type x)) (str js/Array))):
:satisfies? false
:seq? false
:map-entry? false
:coll? false
:array? false
:object false
:identical? false
:type #object[Array]
:type #object[Object] false false #object[Array] false true
:satisfies? false
:seq? false
:map-entry? false
:coll? false
:array? false
:object false
:identical? false
:type #object[Object]
:type #object[Object] false true #object[Array] false false
#2022-08-2614:29thhellerwhere do you get this object from? that looks like it might be coming from a different context? eg. iframe?#2022-08-2614:29folconI mean I have a work around using a custom version of js->clj which uses string checks, though I can probably also use your to-clj, but it would be good to figure out how to fix it#2022-08-2614:31folconSo it's in an iframe within the browser.#2022-08-2614:31thhellerok thats the issue then#2022-08-2614:31folconNot sure why being in an iframe should break it though?#2022-08-2614:32thhellerthat is an isolated context. you don't actually have the real objects then, just proxies to it#2022-08-2614:32folconThe entire app resides and runs within the iframe#2022-08-2614:32folconAh, so this is a case of don't expect core stuff to work properly? So this is expected behaviour and thus not a bug?#2022-08-2614:33thhelleryes, this is not expected to work. you must properly "transfer" the object to the correct context before working on them#2022-08-2614:37folconHmm, how does one do that? Or is that not possible in this case as the app sits in an iframe? Happy to read it up if you can point to a resource or tell me what to google 😃...#2022-08-2614:37thhellerusually postMessage to send the message between the contexts#2022-08-2614:40folconHmm, ok so I think postmessage is being called on my behalf, but as the app is residing in the iframe I suppose I'll still have to deal with proxies for the moment... Ok. thanks @thheller 😃... Appreciate the help!#2022-08-2614:41thhellera slightly worse version can just JSON.stringify and JSON.parse the object 😉#2022-08-2614:41folconHmm, to be honest the hit is probably not that high as the objects are small, I'll give that a go, if it works, then great!#2022-08-2614:47folconOk, that works 😃... Not the fastest, but good enough:tm:...#2022-08-2606:18pez@kbosompem did you get it to work? Looking at the user guide link you provided, it is talking about the option to use shadow-cljs from npm and letting it start Leiningen. With that setup; in Calva, you should use the shadow-cljs project type, not ~{:tag :b, :attrs nil, :content ("Leiningen + shadow-cljs")}~ when jacking in. You also should have :lein {:profile "+cljs"} in your shadow-cljs.edn. (Or simplify things for yourself and skip the :cljs alias, like @thheller mentioned. If you do that, then use :lein true, in the shadow config.)#2022-08-2619:54vlad_poh@pez I am able to work by keeping them separate. i.e do shadow-cljs watch frontend first then jack in with leiningen only. Only drawback is calva treats the cljs files differently. I can’t jump to definitions etc Tried the :lein true option but the build kept failing with “The required namespaces is not available”#2022-08-2620:11thheller> “The required namespaces is not available”#2022-08-2620:11thhellerlikely means that your :source-paths from shadow-cljs.edn weren't in project.clj. they no longer apply from shadow-cljs.edn when using lein.#2022-08-2622:04pezYes, once you've moved dependencies and source-paths over to Leiningen, it should totally work. (I'm working on getting Calva to work using lein directly and start and hook up shadow via the nrepl middleware, but I'm stumbling a bit.)#2022-08-2811:57pez@kbosompem The latest release of Calva should give you some more options for jack-in/connect. It fixes some missing pieces for the Leiningen + shadow-cljs project type. Note, however, that starting the REPL using the shadow-cljs npm executable is often still better with Calva, because it will keep shadow-cljs stdout and stderr output mostly in the jack-in terminal (or wherever you start the REPL). https://clojurians.slack.com/archives/CBE668G4R/p1661687545337289#2022-08-2606:19thheller@pez it should be fine to just start with leiningen? especially if the backend should also run in that process. it should not be required to run via shadow-cljs to get a working cljs setup?#2022-08-2606:21thhelleror does it start shadow-cljs AND leiningen?#2022-08-2606:24pezI think Calva might do things wrong/in a way that prevents that from working. Or that something more is needed in project.clj or the lein command line. When using shadow to start things, it starts Leiningen, and then things work. If you have some time, I'd be happy to discuss this with you in some depth, because this is a very common Ux trap in Calva.#2022-08-2606:26pezWe have the same situation with deps.edn, btw. Starting with shadow-cljs is pretty easy to get working. Starting it with clojure is hella difficult#2022-08-2606:27thhellerhow so?#2022-08-2606:27thhelleryou basically only need to do two things: (require 'shadow.cljs.devtools.server) and (shadow.cljs.devtools.server/start!)#2022-08-2606:28thhellerthat will start the embedded server and get everything ready#2022-08-2606:28thhellerthen starting a watch or repl is done via the shadow.cljs.devtools.api namespace#2022-08-2606:29thhellerso (shadow.cljs.devtools.api/watch :the-buid) and (shadow.cljs.devtools.api/repl :the-build) to get the REPL#2022-08-2606:30thhelleras for the clojure command thats just the usual clojure -A:whatever:aliases, nothing special in startup required there.#2022-08-2606:30thhellerI'm assuming you are starting via some kind of nrepl mechanism though? so you need to add the middleware for shadow-cljs there.#2022-08-2606:31thhellerI went over this with @kbosompem yesterday via DMs and the command calva issued was
lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '["cider.nrepl/cider-middleware"]' -- with-profile +cljs repl :headless
#2022-08-2606:31thhellerwhich would just need the shadow.cljs.devtools.server.nrepl/middleware added to the middleware injection, or hardcoded manually in the project.clj#2022-08-2606:32thhellerbut this appeared to work fine when run via the command line#2022-08-2606:32thhellerbut calva still wouldn't find the dependency when run via calva. not sure why#2022-08-2606:41pezSo, for Leiningen, what seems to be missing in Calva is the shadow.cljs.devtools.server steps and the middleware injection. I'll experiment a bit with it and see if I get it working and can fix Calva's support for this.#2022-08-2606:42thhellerif you point me to the places that actually run all this I can maybe help out#2022-08-2606:44thhellerif calva is able to handle 2 separate processes for the REPL it might also be an option to just run shadow-cljs separately and talk to that to handle CLJS things#2022-08-2606:48pezCalva can't do this, though. But using shadow-cljs to start Leiningen things works.#2022-08-2606:50pezThe CLJS repls are created here in Calva: https://github.com/BetterThanTomorrow/calva/blob/dev/src/nrepl/connectSequence.ts#L212-L272 A thing to not is that the Figwheel config has startCode, but the shadow-cljs one hasn't.#2022-08-2606:51pezThe user can create custom start/connect sequences: https://calva.io/connect-sequences/#2022-08-2606:54pez> but calva still wouldn't find the dependency when run via calva. not sure why This is strange and something I need to figure out...#2022-08-2606:57pez> as for the clojure command thats just the usual clojure -A:whatever:aliases, nothing special in startup required there. Again, this is very tricky to get to actually work for Calva users. So there is something I need to fix, somewhere. Maybe it is the shadow.cljs.devtools.server stuff that's missing.#2022-08-2608:01pezI created this issue and will spend some time today with trying to figure it out and maybe even fix it. https://github.com/BetterThanTomorrow/calva/issues/1842#2022-08-2613:50pezI'm not having huge success here, but at least some. I get :missing-nrepl-middleware when selecting the build. I am injecting it, though. Starting the project like so:
lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headless
This is what I try with:
clj꞉shadow-lein.server꞉> 
(do (require (quote shadow.cljs.devtools.server)) (shadow.cljs.devtools.server/start!) (require (quote shadow.cljs.devtools.api)) (shadow.cljs.devtools.api/watch :app))
shadow-cljs - server version: 2.19.9 running at 
shadow-cljs - nREPL server started on port 54224
:watching
; shadow-cljs - HTTP server available at 
; [:app] Configuring build.
; [:app] Compiling ...
; [:app] Build completed. (170 files, 0 compiled, 0 warnings, 1.24s)
clj꞉shadow-lein.server꞉> 
(do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/nrepl-select :app))
:missing-nrepl-middleware
#2022-08-2614:00pezIt's a bit unfortunate that shadow starts an nREPL server here, btw. Can I prevent that somehow?#2022-08-2614:13thhellerhmm dunno why the middleware would be missing there? injection looks correct#2022-08-2614:14thhelleryou can just ignore the nrepl server started by shadow-cljs#2022-08-2614:14thhelleror set :nrepl false in shadow-cljs.edn#2022-08-2614:21pezI can ignore it. It's that it could confuse the Calva user. I'll probably strip that message away.#2022-08-2614:43pezHere's the project I am trying with: https://github.com/PEZ/shadow-w-backend#2022-08-2614:45thhellerlooks fine. well kind of ancient style config but still ok#2022-08-2614:45pezRepeating the start command used:
lein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headless
Removing Calva from the picture, here's a lein-only repro:
% lein repl :connect
Connecting to nREPL at 127.0.0.1:51722
REPL-y 0.5.1, nREPL 1.0.0
Clojure 1.11.1
OpenJDK 64-Bit Server VM 18.0.1+10
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

shadow-lein.server=> (do (require (quote shadow.cljs.devtools.server)) (shadow.cljs.devtools.server/start!) (require (quote shadow.cljs.devtools.api)) (shadow.cljs.devtools.api/watch :app))
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.19.9 running at 
shadow-cljs - nREPL server started on port 51913
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (170 files, 169 compiled, 0 warnings, 7.05s)
:watching
shadow-lein.server=> (do (require 'shadow.cljs.devtools.api) (shadow.cljs.devtools.api/nrepl-select :app))
:missing-nrepl-middleware
shadow-lein.server=> 
I'm pretty sure I've done something wrong in some config...
#2022-08-2614:46pez> kind of ancient style config I'm all ears! 😃#2022-08-2614:46thheller
{:lein true
 :dev-http {8700 "public"}
 :builds
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"
        :modules {:main {:init-fn shadow-lein.core/init}}}}}
#2022-08-2614:46thhellerin index.html remove <script>shadow_lein.core.init();</script>#2022-08-2614:47thhellerchange https://github.com/PEZ/shadow-w-backend/blob/master/src/shadow_lein/core.cljs#L12 and add ^:dev/after-load metadata hint#2022-08-2614:49pezThanks. I considered something like that, but started wondering about the production case. Maybe that'll be a separate index.html?#2022-08-2614:50thhellerno? nothing changes for release#2022-08-2614:56pezI’ll fix. #2022-08-2614:58pezBut my real problem is still to try support starting shadow projects with lein and deps. I think I'm close on the Calva side, but I’m not sure#2022-08-2619:18pezI've updated the project config to be more modern now. 😃#2022-08-2622:08pez@kbosompem, that ^ tiny example project works with Calva jack-in if you choose the shadow-cljs project type.#2022-08-2707:35pezIf I use clojure to start the project, it works:
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}'  -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]"
I've updated the sample project repo with a deps.edn file.
#2022-08-2707:48pezI’m afk and can't check. But it struck me that maybe I have a bad lein version…!#2022-08-2708:58pez
% lein --version
Leiningen 2.9.8 on Java 18.0.1 OpenJDK 64-Bit Server V
#2022-08-2709:00pezI get the same :missing-middleware` result with Leiningen 2.9.10.#2022-08-2709:12pezIf I add this to project.clj it starts working.
:repl-options {:nrepl-middleware [shadow.cljs.devtools.server.nrepl/middleware]}
Seems command-line injection takes a backseat...
#2022-08-2709:38thhellerinjection works fine for me when working from the terminal though? and it if didn't work wouldn't the cider.nrepl middleware also be missing?#2022-08-2709:40pezDo you get different results than I do with my repro above? #2022-08-2709:42pezI get errors adding cider middleware in the project file, actually. It’s all very strange. #2022-08-2709:47thhellerI just tried running the command in the terminal directly and the middleware is added fine#2022-08-2709:47thhellerlein update-in :dependencies conj '[nrepl,"1.0.0"]' -- update-in :dependencies conj '[cider/cider-nrepl,"0.28.5"]' -- update-in :plugins conj '[cider/cider-nrepl,"0.28.5"]' -- update-in '[:repl-options,:nrepl-middleware]' conj '[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware]' -- repl :headless#2022-08-2709:47thhellerso maybe has something to do with the way you invoke this? maybe some quoting issue or so? how do you actually start the process?#2022-08-2709:57pezI run it from the terminal. Then in another terminal I use lein to connect to the nrepl server. #2022-08-2710:04thhelleryour repro works fine for me?#2022-08-2710:06thhellerI mean manually in the terminal. I do not have vscode or calva installed#2022-08-2710:06thheller
d$ lein --version
Leiningen 2.9.4 on Java 17.0.3 OpenJDK 64-Bit Server VM
#2022-08-2710:08pezCalva is not involved in my repro. I’ll try with lein 2.9.4 later today. #2022-08-2710:08thhellerdo you maybe have something on your machine that breaks it? like ~/.lein/profiles.clj or so?#2022-08-2710:11pezI’ll check that as well. Afk now, but I just might have something there. #2022-08-2715:47pezI don't have a ~/.lein/profiles.clj#2022-08-2716:19pezI get the same :missing-middleware result using lein 2.9.4 and 2.9.1. And also the same on another machine I have.#2022-08-2716:31pezI'm baffled this works on your machine, @thheller! Very strange issue.#2022-08-2718:34thhellerhmm now it doesn't work anymore#2022-08-2718:35thhellerI think I might have started the lein repl :connect in the wrong dir :P#2022-08-2718:35thheller(and just connecting to my regular project)#2022-08-2718:58pez😃 Well, then maybe I should now file an issue on Leiningen.#2022-08-2608:52pezWhen setting up a minimal shadow-cljs project with binaryage/devtools 1.0.6, I get tons of warnings such as this in the console:
DevTools failed to load source map: Could not load content for : Load canceled due to load timeout
Afaikt the source maps are created in the place the warning is talking about. Anyone recognize this situation?
#2022-08-2609:09thhelleris this with a custom server or :dev-http?#2022-08-2609:10thheller> Load canceled due to load timeout#2022-08-2609:10thhellersuggests the server is overloaded and doesn't reply properly?#2022-08-2609:21pezYes, overload could be it. I had a js linter running on a parent dir and it couldn't cope with the main.js produced by shadow and went into a spin.#2022-08-2609:21pez(So it was my machine that was overloaded maybe)#2022-08-2811:57pez@kbosompem The latest release of Calva should give you some more options for jack-in/connect. It fixes some missing pieces for the Leiningen + shadow-cljs project type. Note, however, that starting the REPL using the shadow-cljs npm executable is often still better with Calva, because it will keep shadow-cljs stdout and stderr output mostly in the jack-in terminal (or wherever you start the REPL). https://clojurians.slack.com/archives/CBE668G4R/p1661687545337289#2022-08-2819:43KlayHello. I’m trying to integrate Datalevin into a Fulcro app and keep getting a compilation error when requiring it. My shadow-cljs.edn:
{:source-paths ["src/main" "resources"]
 :dependencies [[com.fulcrologic/fulcro "3.5.24"]
                [com.fulcrologic/fulcro-rad "1.2.7"]
                [com.wsscode/pathom "2.4.0"]
                [datalevin "0.6.16"] ; <---
                [mount "0.1.16"]
                [ring/ring-core "1.9.5"]
                [ring/ring-jetty-adapter "1.9.5"]]
 :jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
            "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"] ; <---
 :dev-http {8000 "resources/public"}
 :builds {:app {:target :browser
                :output-dir "resources/public/assets/app/js/compiled"
                :asset-path "/assets/app/js/compiled"
                :modules {:main {:init-fn com.kyleerhabor.hue.client/init
                                 :entries [com.kyleerhabor.hue.client]}}
                :devtools {:after-load com.kyleerhabor.hue.client/refresh
                           :preloads [com.fulcrologic.fulcro.inspect.preload
                                      com.fulcrologic.fulcro.inspect.dom-picker-preload]}}}}
The file (`src/main/com/kyleerhabor/hue/db.clj`):
(ns com.kyleerhabor.hue.db
  (:require [datalevin.core :as d]))
The error:
; Evaluating file: db.clj
; Syntax error compiling at (taoensso/nippy/crypto.clj:14:79).
; No such var: enc/secure-rng
; Evaluation of file db.clj failed: class clojure.lang.Compiler$CompilerException
I’m able to compile my server.clj file just fine, which makes this confusing.
#2022-08-2820:07thhellerthis just doesn't seem to support CLJS at all?#2022-08-2820:08thhellerI mean just the jvm opts alone suggest this is meant for CLJ only#2022-08-2820:18KlayIs :jvm-opts only for configuring shadow and not other parts of an app? I’ve been able to run a Ring server in the project just fine.#2022-08-2820:25KlayAlbeit I load it in my editor (Calva) separately to get it running#2022-08-2821:25thhellerwell, you can do that yes#2022-08-2900:04KlayI was able to fix my issue by declaring the dependencies Datalevin wanted, though I don’t know what exactly caused it.#2022-08-2916:02dvingoHi - is there anywhere in the compiler state that records a timestamp or datetime of when a namespace was last loaded? Or similarly - any info about which namespaces are stale when a code change is noticed (before a hot-reload)? The use-case is for malli function instrumentation and wanting to only instrument stale namespaces instead of doing a full ns scan on each hot reload.#2022-08-2916:19thhellerit does but not in a way that would be accessible to malli? which I assume uses a macro to do this?#2022-08-2916:19thhellerit is stored in the build state but not in the analyzer data#2022-08-2916:56dvingoah ok - Yea I was thinking the macro could make that data visible to the cljs runtime which would then be able to filter on it#2022-08-2916:58dvingois it infeasible to access the build state in a macro then?#2022-08-2917:11thhelleryeah, currently you can't#2022-08-2917:12isakMaybe you can use a build hook @danvingo? https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks#2022-08-2917:16isakFor example, in our build we look at some data in the compiler-env and throw an exception sometimes in the {:shadow.build/stage :compile-finish} stage, which shadow-cljs displays in the browser#2022-08-2917:18dvingothanks for the suggestion! I will play around with it, might be able to hack something (like writing to a file with generated code) idk#2022-08-2917:26isakHere an example of updating the compiler env in a macro, then using that in a build hook (translation use-case): https://www.isaksky.com/posts/macro-assisted-translations-in-clojurescript/#2022-08-2917:46dvingoamazing, thank you!#2022-08-2917:47thhellerFWIW I have been thinking of introducing a formal API that is called after compilation and basically lets you generate extra code. sort of like looking at metadata and generating code for it. in clojure you can just do that at runtime dynamically but CLJS you can't. so that might bridge that a little.#2022-08-3002:53superstructorwould this enable tracing use cases ?#2022-08-3006:33thhellerI don't know? haven't thought about tracing in a long long time so not sure what that needs?#2022-08-3006:54superstructorI imagine the ability to walk/inspect the tree of code and inject custom tracing code at many points (e.g. every fn call)#2022-08-3006:59thhellerthat would not be possible with what I had in mind#2022-08-3006:59thhellerthe idea was just to generate extra code based on metadata#2022-08-3006:59thhellernot affect all other code that is generated#2022-08-3007:00thhellerI mean that could be done elsewhere. if you have a formal definition of what would be needed I could certainly add that#2022-08-3007:08superstructorI'm not sure if this API would be the best place to serve that requirement or not ?#2022-08-3007:22thhellerno, this one doesn't seem to be. the idea is that for example I have metadata in my projects which "tags" certain functions as event handlers#2022-08-3007:22thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/ui/db/inspect.cljs#L126#2022-08-3007:23thhellerI then have a macro that collects all these and hooks them up properly#2022-08-3007:23thhellerthink of it as (rf/reg-event ::m/tap-clear! (fn [...] ...))#2022-08-3007:23thhelleronly that its a regular defn and not an anonymous function#2022-08-3007:24thhellerso basically the macro generates (rf/reg-event ::m/tap-clear! that.ns/var) (none of this actually uses re-frame, but it is very similar in concept)#2022-08-3007:24thhellermakes it easier to test functions from the REPL and stuff#2022-08-3007:24thhellerand imho makes for cleaner looking code#2022-08-3007:24thhellerbut the macro has the problem that it needs to run after all other compilation is completed#2022-08-3007:25thhellerand needs to run after every compilation#2022-08-3007:25thhellerwhich is sort of weird for a macro and busts all caching and stuff#2022-08-3007:26thhellerso I want to move that to some API that just runs after all compilation and can collect all the necessary stuff from the analyzer data and generate some extra code#2022-08-3007:26thhellersame goes for instrumentation I think#2022-08-3007:26thhellerbut tracing requires rewriting the actual code that is already generated#2022-08-3007:26thhellerso that doesn't fit this stuff#2022-08-3014:58isakThat sounds really nice!#2022-08-2917:49dvingonice! that would be very useful#2022-08-3014:43pmooserI see an error in the console every time I save my CSS file - CSS reloading used to work for me, so I'm not quite sure what this means. I'm using shadow-cljs version 2.19.9, and the error I get any time I save my CSS file is:#2022-08-3014:51pmooserI don't know much about debugging in shadow-cljs but I'm not really able to get a breakpoint to stop there ...#2022-08-3014:57pmooserOk - I fixed it by removing: :preloads [shadow.remote.runtime.cljs.browser] from :devtools which I believe was given as a workaround for some other issue at some point in the distant past.#2022-08-3015:38thhelleryes, that is long dead#2022-08-3015:39thhellerhttps://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/remote/runtime/cljs/browser.cljs#2022-08-3015:39thhelleralthough it still exists as an empty namespace. so not sure how that would be causing any issues?#2022-08-3016:00zimablueis this the best wild effort at demunging for shadow-cljs? https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/munging.cljs#2022-08-3016:01thhellerwhat is that supposed to do? I mean are you trying to do that would require demunging?#2022-08-3016:03zimabluein development I'm trying to reconstruct partial function call stacks so that I can trace a complex library that I'm struggling to understand#2022-08-3016:03thhellerdon't source map handle that?#2022-08-3016:04zimablueso (.-callee (js-arguments)) is cool but it would be cooler if I could demunge the names#2022-08-3016:04thhellerah#2022-08-3016:04zimabluemaybe, I don't really understand source maps, are they accessible/useful outside of chrome devtools? where should I read#2022-08-3016:04thhelleryeah, no clue. source maps won't help there#2022-08-3016:04zimabluewhy not?#2022-08-3016:05zimabluedoes source map have (clojure symbol from) (javascript symbol to) correspondences in a format I can digest in the REPL?#2022-08-3016:06zimabluesorry I come from python/c# not web tech so my understanding of all this has some gaps#2022-08-3016:18zimabluethat might have been a stupid question, the answer I'm pretty sure is "yes", a better question might be if there's a useful example or library in clojurescript for parseing these .map files?#2022-08-3016:24zimablueand I maybe answered that one, cljs.source-map seems to be what I'm looking for#2022-08-3018:01jpmonettas> in development I'm trying to reconstruct partial function call stacks so that I can trace a complex library that I'm struggling to understand @zimablue maybe https://github.com/jpmonettas/flow-storm-debugger can help you there, you will have to add #trace tags to every form you are interested in but then you can use all the debuggers functionality, specially https://jpmonettas.github.io/flow-storm-debugger/user_guide.html#_call_stack_tree_tool#2022-08-3018:03zimablueI'm not trying to step through it though, more like run an extended test with specific functions decorated and then poke around the generated data#2022-08-3018:04zimablueI don't find debuggers super useful beyond a certain level of "lost" because there's just too much to step through and eg. you're only interested in the 58th function call, which is obvious to identify from the data but hard to specify as a condi breakpoint#2022-08-3018:04zimabluemaybe I just need to get better at debugging#2022-08-3018:07zimabluewould flow storm debugger help with that sort of workflow?#2022-08-3100:10zhuxun2How viable is it to use shadow's clojure APIs directly as opposed to using npx shadow-cljs ? Does the NodeJS API do a lot of magic (middleware, etc.) in addition to calling (server/start!)?#2022-08-3100:11zhuxun2What's the minimum Clojure code to replicate the exact behavior of npx shadow-cljs server?#2022-08-3106:23thheller@zhuxun2 https://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2022-08-3106:24thhellerto get the exact behavious of server you just have (server/start!). thats all as far as the shadow-cljs build server is concerned#2022-08-3106:24thhellerhowever the "connect to server" part of the node shadow-cljs command cannot really be replicated#2022-08-3106:25thhellerso you probably want to do all other stuff over the REPL or UI and now use further CLI command to start a watch for example#2022-08-3111:56just.sultanovHello, @thheller. Could you help me, please. I’m working on migrating from figwheel-main to shadow-cljs and unfortunately I can’t change the structure of the project. I have a backend module that serves my static files via /static route, and I have a frontend module that compiles js to the backend resource directory backend/resources/public/frontend2/assets/js. I don’t have a file index.html - the server generates it itself. JS files are reloaded correctly, but I have some problems with reloading resources (CSS). Any changes to CSS files are not handled. I have a webpack configuration that compiles less files to the backend resources directory /backend/resources/public/frontend2/assets/bundle.css I added the parameters :watch-dir and :watch-path, but it didn’t help.
[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
:app  {:target     :browser
       :output-dir "../backend/resources/public/frontend2/assets/js"
       :asset-path "static/frontend2/assets/js"
       :modules    {:app {:init-fn frontend.core/-main}}

       :devtools   {:preloads  [devtools.preload]
                    :watch-dir "../backend/resources/public/frontend2/assets"
                    :watch-path "static/frontend2"}
Thank you!
#2022-08-3112:13thheller@just.sultanov what is the path you include to css in the html?#2022-08-3112:14thhellerhttps://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html might help#2022-08-3112:14thhellerI'm guessing its :watch-dir "../backend/resources/public" but can't say exactly without known the paths#2022-08-3112:15thheller(meaning why is the path in that html relative? what is the path of the page you are calling?)#2022-08-3112:15thheller[:link {:rel "stylesheet", :href "/static/frontend2/assets/bundle.css", :type "text/css"}]?#2022-08-3112:16just.sultanovBackend generates the following paths:
[:link {:rel "stylesheet", :href "static/frontend2/assets/bundle.css", :type "text/css"}]
[:script {:src "static/frontend2/assets/js/app.js", :type "text/javascript"}]
#2022-08-3112:16thhellerthen its :watch-dir "../backend/resources/public/frontend2" and :watch-path "static/frontend2"#2022-08-3112:16thhelleror :watch-dir "../backend/resources/public" and :watch-path "static"#2022-08-3112:16thhellerthe blog post explains this I hope#2022-08-3112:18just.sultanovYes, the path to static files is relative. This is provided by the compojure context. Well, thank you. I will try to use absolute paths#2022-08-3112:19thhellerthats fine, just makes it harder to answer the question without knowing the full exact paths 😉#2022-08-3118:44vienzerHi, new to shadow-cljs and CLJS in general. I've tried out both figwheel-main and shadow-cljs in some learning projects with basic configurations, and I've noticed that when using figwheel, I can get completions for goog.dom functions in a CIDER REPL by simply typing "goog.dom/...", while I don't get auto-completion in shadow-cljs builds for vars in that namespace. Is this related to this issue https://github.com/thheller/shadow-cljs/issues/834 ?#2022-08-3118:48thhellernot a clue how cider autocomplete works so can't say#2022-08-3119:09mkvlris there an alternative to nuking .shadow-cljs when a https://github.com/babashka/sci/blob/133a7565749ac6cd5a8308182f0b1c7fc47e8a3d/src/sci/impl/namespaces.cljc#L53-L64 depending on the contents of an env var? Maybe a way to whitelist env vars that shadow can take into account for caching?#2022-08-3119:10mkvlror is there a way to rewrite this macro so it plays well with shadows caching?#2022-08-3119:10borkdudewhat I do in one of my projects is https://github.com/clavascript/clavascript/blob/a5a63bf19025f8535a5a3f3f4ef8c1dde2d4786c/bb/tasks.clj#L61#2022-08-3119:10borkdudeso, delete the cache file for that macro-related ns#2022-08-3119:12thhellerhttps://github.com/thheller/shadow-cljs/blob/732577ea5257f6418d4926d10f5c0e3261303e8b/src/main/shadow/build/compiler.clj#L742-L746#2022-08-3119:13thhellercould store it there and get it out of the (get-in @cljs.env/*compiler* [:options :external-config :whatever-you-added]) during compilation#2022-08-3119:13mkvlrah nice.#2022-08-3119:15mkvlrshadow does a lot better in cache invalidation regarding macros than the regular cljs compiler, correct? But reading from the env will fail bust its caching strategy?#2022-08-3119:15thhelleryes, it does not check the env#2022-08-3119:16thhellerbasically it checks all the options above + the files involved in the compilation#2022-08-3119:16thhellerthats all it looks at#2022-08-3119:17mkvlrok, have you considered being able to signal (maybe via metadata) on a macro var that it should not be cached or does that not make sense?#2022-08-3119:18thhellerwell to know if it can use the cache it must be able to derive it from only the file and compare before compilation#2022-08-3119:18thhellerI guess there could be some way for a macro to signal "hey, please don't cache this file"#2022-08-3119:19thhellerif cache is never written it can never be read#2022-08-3119:19mkvlrah so the cache is on a file level, not on the level of vars?#2022-08-3119:21isak@mkvlr have you considered the :cache-blockers config here? https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2022-09-0110:54Dustin Getzalso :dev/always iiuc https://shadow-cljs.github.io/docs/UsersGuide.html#_metadata @mkvlr#2022-08-3119:22mkvlr@isak nope, wasn’t aware of this, thanks!#2022-08-3119:25thhellerthat also works yes#2022-09-0111:00roman01laCan :js-options :resolve be used only to re-route requires from cljs code or the config will also affect JS require/import declared in required NPM modules? My use case is the following: NPM package X depends on Y, but I have replaced Y with a local custom build. This works fine as long as NPM stuff is built by Webpack that also has resolve config. Now that I want to require X directly in CLJS namespace and let Shadow bundle it, I also want to make sure that given resolve config in shadow-cljs.edn Shadow will take care of resolving local Y for NPM package X.#2022-09-0117:02thhelleryes, it applies everywhere not just cljs#2022-09-0119:14roman01lanice!#2022-09-0111:03James PrattOops, should have probably posted this in this thread to start with.#2022-09-0119:02RyanHmm I'm trying to update noencore, but I can't figure out how.. it doesn't appear to be listed in my package.json or shadow-cljs.edn files#2022-09-0119:09RyanI added [noencore/noencore "0.3.7"] to shadow-cljs.edn and it updated.. not sure what caused it to be required in first place tho#2022-09-0119:13thhellerone of your other dependencies probably. shadow-cljs does not require it#2022-09-0219:34Ivan FedorovGuten abend, Thomas! Having some source map issues, keeps taking me to the wrong places. Trying to map a release build to sources
:app
{:target     :browser
 :output-dir "resources/public/js/compiled"
 :asset-path "/js/compiled"
 :compiler-options {:optimizations :advanced}
 :dev {:compiler-options {:optimizations :advanced}}
 :modules    {:app {:init-fn flow-ui.dev/init}}
 :release
 {:compiler-options
  {:source-map true
   :source-map-detail-level :all}}

  :build-options
  {:ns-aliases
   {day8.re-frame.tracing day8.re-frame.tracing-stubs}}}}}}
#2022-09-0219:42Ivan FedorovTried a couple of optimization options. Takes me to places that don’t exist#2022-09-0219:44Ivan FedorovUpdated shadow-cljs, forgot to remove .shadow-cljs dir and relaunch server, currently doing this#2022-09-0219:47Ivan FedorovRelaunched, re-released, same error ^^ just with different paths On 2.20.1 cc @U05224H0W#2022-09-0219:49thhellerdunno what would be causing this. not aware of any source map issues in particular#2022-09-0219:49thhellerdoes it map correctly in dev?#2022-09-0220:00Ivan Fedorovcan I force :optimizations :advanced in dev? in dev I don’t have the error in the first place#2022-09-0220:01Ivan Fedorovwhop, my bad#2022-09-0220:01Ivan Fedorovmanaged to see this in dev, yes#2022-09-0220:03thhellerdev doesn't do any optimizations ever#2022-09-0220:03Ivan Fedorovit was a different Error in dev#2022-09-0220:07Ivan Fedorovok, then about the root problem that I want to find with source maps. It smells like another missing ^js or aget usage from my side. Can I somehow diable optimization for my JS files? Is that the place where I need externs? I also use d3, but the way I use it feels shaky#2022-09-0220:08Ivan FedorovBut dev seems to map to source well, yes#2022-09-0220:10Ivan FedorovMaybe it’s that time when I need to go through https://shadow-cljs.github.io/docs/UsersGuide.html#externs section#2022-09-0220:19thhelleryes, the error is typical for externs issue#2022-09-0219:41thhellerlooks fine?#2022-09-0418:16Logan Powell@thheller such a long time since we've chatted. You may not even remember me. Of course, like a bad relative, I'm here because I need your help#2022-09-0418:19Logan PowellI'm trying to use https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading as part of my Calva/vscode setup and have a couple questions: 1. do these conditionals work when deploying a library that should work in both node and the browser (i.e., runtime) or are they a compiled feature? 2. do they work when using them w/a REPL (mine currently = vscode + calva) without setting anything in the config?#2022-09-0418:21thhellerhey, they are a reader feature. so they'll work as long as the source code is read somewhere, but only during reading. as such without config they'll not trigger if you add custom conditionals?#2022-09-0418:22thhelleryou also likely shouldn't be using them in the first place 😉#2022-09-0418:27Logan Powellunderstood. I'll find another way. Good to hear from you again old friend#2022-09-0419:21pezWhy shouldn't we be using them?#2022-09-0419:23Logan Powellprobably because since it's not officially supported#2022-09-0506:49thhellercorrect. they do work just fine but they must have a reason for rejecting them from official support 😛#2022-09-0419:35Fredrik Anderssonare there any build constants that could be used for conditional build?#2022-09-0419:54Fredrik Anderssoni found :closure-defines#2022-09-0502:05surferHalo> Typically all JS Dependencies are foreign and won’t be passed through :advanced and thus require Externs. > from https://shadow-cljs.github.io/docs/UsersGuide.html#externs Does that mean Closure Compiler not doing dead code elimination on the dependency library?#2022-09-0506:44thhelleryes, if by dependency library you mean npm JS dependency.#2022-09-0508:31bbssI've been updating dependencies in a project and running into Module not provided: @babel/runtime/helpers/interopRequireDefault often. Tricky that it doesn't list which npm package / file is to blame. I think it has to do with using either @babel/runtime @babel/preset-react @babel/preset-env to pre-compile. Is it perhaps because I didn't configure .babelrc properly? I do have a babel.config.json that I think shadow-cljs uses.#2022-09-0508:35thheller@bbss kinda hard to say. why do you configure babel at all?#2022-09-0508:36bbssI've needed it several times when shadow couldn't compile when requiring an npm dep.#2022-09-0508:37bbssIn this case it couldn't compile: https://github.com/dmonad/isomorphic.js/blob/main/browser.mjs#2022-09-0508:37thhellerwhy not?#2022-09-0508:37bbssEOF when reading it IIRC#2022-09-0508:38bbss
[2022-09-05 17:14:53.607 - WARNING] :shadow.build.babel/babel-transform-ex - {:code "/* eslint-env browser */\nexport const performance = typeof window === 'undefined' ? null : (typeof window.performance !== 'undefined' && window.performance) || null\n\nconst isoCrypto = typeof crypto === 'undefined' ? null : crypto\n\n/**\n * @type {function(number):ArrayBuffer}\n */\nexport const cryptoRandomBuffer = isoCrypto !== null\n  ? len => {\n    // browser\n    const buf = new ArrayBuffer(len)\n    const arr = new Uint8Array(buf)\n    isoCrypto.getRandomValues(arr)\n    return buf\n  }\n  : len => {\n    // polyfill\n    const buf = new ArrayBuffer(len)\n    const arr = new Uint8Array(buf)\n    for (let i = 0; i < len; i++) {\n      arr[i] = Math.ceil((Math.random() * 0xFFFFFFFF) >>> 0)\n    }\n    return buf\n  }\n", :file "/Users/baruchberger/nexus-core/node_modules/isomorphic.js/browser.mjs", :preset-config {:targets {"chrome" "90"}}, :shadow.build.babel/reply-to #object[clojure.core.async.impl.channels.ManyToManyChannel 0x2d46eb58 "
#2022-09-0508:39thhellerweird#2022-09-0508:40bbssI've also hit it on @material-ui v4#2022-09-0508:40bbssthis isomorphic.js thing is a dependency of y-webrtc which is you'd use with yjs a pretty cool lookin' crdt lib.#2022-09-0508:41thhellerinstead of messing with babel you should probably just be using webpack instead#2022-09-0508:41thhelleras described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-09-0508:41bbssokay, cool didn't consider that. I'll check it out! Thanks 🙂#2022-09-0508:41thhellerdunno what this error is. just seems to be missing a } at the end?#2022-09-0508:42thhellerhmm no wait it doesn't#2022-09-0508:43thhelleryou definitely shouldn't have a babel config or manually call babel on the output or input. that is not expected to work#2022-09-0508:45thhellerit also compiles fine on my machine#2022-09-0508:45thhellerso maybe the babel config is causing it in the first place?#2022-09-0508:45bbssokay, that's a bit confusing to me in how far shadow-cljs will go there, there is some mention of manually passing things through babel, and that has worked out for me in the past. So just a .babelrc is supported, and I should get rid of the babel.config.json in my root?#2022-09-0508:46bbssPerhaps, let me check.#2022-09-0508:46thhellerI don't know. what do you use them for? shadow-cljs ONLY uses babel to transform npm ESM code to commonjs. nothing else, not for polyfilling or whatever else#2022-09-0508:46thhellerso if you make it do more you will essentially brick it#2022-09-0508:47thhellerI wouldn't use babel for this at all but unfortunately the closure compiler is rather picky about its input, so I kinda have to#2022-09-0508:47bbssI use them because I thought it was needed to get some npm deps to work, here and there I've run into these babel-transform-ex.#2022-09-0508:47thhellerno, you should not have any babel config whatsoever. unless you actually use babel manually anywhere I guess#2022-09-0508:48thhellerbut not for the babel used by shadow-cljs#2022-09-0508:49bbssGreat, the babel.config.json seemed to be the problem, code now runs. Thank you very much!#2022-09-0515:40Filipe SilvaOn the topic of the babel config and closure compiler, I’m running into an ES6 transpilation of 'Public class fields' is not yet implemented. from the closure compiler and was trying to get shadow’s babel config to use include @babel/plugin-proposal-class-properties, but it doesn’t seem to. Is this a bad idea?#2022-09-0516:32thhelleryes, that is bad. it is not a supported use case. basically if you need to use code that the closure compiler doesn't support you are better off using webpack#2022-09-0517:13Ivan FedorovHey! Anyone seen any videos or “for-dummies” material on externs?#2022-09-0517:18thhellerdo you not get any inference warnings?#2022-09-0518:16Ivan FedorovI get them, yeah. 188 about core.cljs, one about garden color, two about reader_types#2022-09-0518:17Ivan FedorovHave you seen any shadow-cljs projects using d3 v7? Maybe I could dig that#2022-09-0518:21Ivan FedorovOr may I buy 30-60 minutes of your time for a zoom session, if you’re open to that. I promise to release a guide for shadow-cljs <-> d3 if that’ll be fruitful.#2022-09-0518:24Ivan FedorovSourcemapping with simple optimizations is wrong too#2022-09-0518:26Ivan FedorovI also have warnings about param names (based on function doc comment) Like
Resource: flow_ui/views/graph-tree-v2.js:809:19
 Parse error. invalid param name "optContextPatch.changedNodeId"
#2022-09-0519:39thheller> I get them, yeah. 188 about core.cljs, one about garden color, two about reader_types#2022-09-0519:39thhellerwhat do you mean? those are probably not inference warnings?#2022-09-0519:39thhellerI'm talking about warnings you get when you compile your build#2022-09-0519:40thhellerso shadow-cljs release app or shadow-cljs watch app or shadow-cljs compile app#2022-09-0519:40thhellerif you meant setting :infer-externs :all then you should not be doing that#2022-09-0519:46Ivan Fedorovyes, I got that long list on :infer-externs :all retrying on :auto#2022-09-0519:50thhellerthe most direct way to debug externs issues is via shadow-cljs release app --pseudo-names#2022-09-0519:50thhellertakes a bit of practice though#2022-09-0519:50thhellerpseudo-names names variables in a way that lets you recognize what they were originally#2022-09-0519:50thhellerbut requires stepping through a bit of generated JS maybe#2022-09-0519:51Ivan Fedorovretried. Got 29 regular warnings about param names#2022-09-0519:51thhellerand what would be the source for that JS parse error?#2022-09-0519:52Ivan Fedorovyeah, pseudo-names may help indeed, thanks!#2022-09-0519:52thhelleroh nvm#2022-09-0519:52thhellerI assume you are using the JS code directly?#2022-09-0519:53thhellerno externs inference is done for JS code, so only pseudo names will help there#2022-09-0519:54Ivan Fedorovabout these 29 warnings – yeah, my guess is that my doc param naming doesn’t match the Closure scheme#2022-09-0519:55thhelleryes, including JS that way only really works if you follow the closure compiler style#2022-09-0519:56thhellerotherwise it'll get confused and produce various issues#2022-09-0519:59Ivan Fedorovon js usage – using it from a CLJS wrapper. Had some issues with d3 modules system, ended up with a crutch (pic). At the time I felt like d3 is written to be compiled by babel or something.#2022-09-0520:00thhellernot sure why you are doing this#2022-09-0520:01thhellerbut if the graph-tree-v2.js file does any interop with d3 then that is likely the source of your externs issues#2022-09-0520:01thhelleragain no inference is done for those, so externs need to be added manually there#2022-09-0520:01Ivan Fedorov> follow the closure compiler style will try, thanks!#2022-09-0520:02Ivan Fedorovshadow-cljs release app --pseudo-names produces good source mapping
#2022-09-0520:03Ivan FedorovI guess I’ll prioritise fixing annotations to exclude their influence. Thanks for the tips!#2022-09-0520:17thhellerthey don't really fix and externs issues but yes, getting rid of warnings should always be the goal#2022-09-0715:55Ivan FedorovExterns solved it! Is there a way to generate externs automatically? I need to scan a couple of JS files and dump field names from every constructor in those.#2022-09-0715:55Ivan FedorovExterns solved it! Is there a way to generate externs automatically? I need to scan a couple of JS files and dump field names from every constructor in those.#2022-09-0616:46naxelsCould someone tell me how I can find out in which env I am working from within the browser target?#2022-09-0616:46naxelsI’m trying to set an external API url in Dev that is different in Production#2022-09-0616:47naxelsin the docs I can’t really find what I’m looking for, except set additional environment variables, which I don’t think I need since the browser can tell i’m in Dev mode#2022-09-0616:47naxels(as in, it’s acting differently when I’m in dev mode vs accessing the site in production)#2022-09-0617:21thheller@patrick.glind see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration and https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2022-09-0617:31naxelsThanks @thheller , i was actually looking at those, but don't understand why I need to declare additional data#2022-09-0617:31naxelsIsn't there some data point i can request that tells me which env is loaded?#2022-09-0617:32naxelsLike in Rails, all you do is type Rails.env and you get a string with the env back#2022-09-0617:33naxelsGiven that the :dev env is loaded through VSCode Calva, I was wondering if I can get that as a datapoint?#2022-09-0617:40thhellerthere is nothing like that in cljs.core by default#2022-09-0617:40thhellerwell I guess there is goog.DEBUG which is true for dev builds#2022-09-0617:40naxelsthat would be useful, thanks!#2022-09-0617:41naxelsyeah, that works 🙂#2022-09-0711:09hanDerPedercan I reload my npm dependencies without restarting the repl?#2022-09-0715:39DerekI believe you can just touch package.json#2022-09-0716:40thhellerthe answer is pretty much no. npm dependencies are not built with hot-reload in mind, so it very very rarely works and more often just messes things up#2022-09-0715:38hlshipIs there documentation about the ["npm-lib" :as alias] :require form? AFAIK it's specific to shadow-cljs? I've been up and down the docs and there's only a sideways reference to it.#2022-09-0715:39Derekhttps://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-09-0715:41hlship🍳 I just found that too, don't know how I missed it. Thanks!#2022-09-0715:42hlshipIs that doc out of date? I picked up this form
["react-flow-renderer" :as rfr :default ReactFlow]
from another answer elsewhere and it looks like the :default part is related to the $default suffix in some examples in the users guide.
#2022-09-0715:46DerekI think :default was shadow specific. ClojureScript proper added “$default”#2022-09-0715:46DerekI could be wrong there#2022-09-0716:38thheller:default was shadow-cljs only yes, the $default is the official way. and the string require syntax otherwise is exactly the same as in CLJS, not shadow-cljs specific in any way. never was, except for the :default addition.#2022-09-0719:55hlshipThanks; I couldn't find any documentation for this pattern in shadow-cljs or clojurescript.#2022-09-0720:00thhellernot much to it really. just using a string instead of a symbol since some npm packages can contain chars that would make for invalid symbols#2022-09-0720:00thheller"@mui/core" etc#2022-09-0814:10hlshipRight, it was just the :default keyword that doesn't appear in documentation.#2022-09-0817:07thhelleryeah, I should have probably left a mention. I removed it when the official $default stuff was added to CLJS to not confuse users#2022-09-0716:44dabrazheWould it be possible to migrate an app running on Clojurescript—Figwheel—Electron to run on shadow-cljs - browser combination? I am not familiar with Figwheel, but used to run shadow-cljs previously.#2022-09-0717:07thhellersure. electron works just fine, just as in figwheel.#2022-09-0808:12Lidor Cohenis there an :autorun equivalent for :node-script? I want that in development, executing shadow-cljs watch :some-build will automatically execute the resulting node script for the REPL runtime#2022-09-0808:13thhellerthere is not but can trivially achieve that with other tools, eg. https://www.npmjs.com/package/chokidar-cli#2022-09-0808:32Lidor Cohennot sure this tool is what I was looking for, I'm using vscode calva to execute and connect the shadow-cljs. So I need some kind of hook to execute the output at the end of the first build. I think I can use https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks, the question was mostly to make sure I'm not missing some built-in functionality like :autorun...#2022-09-0808:33thhellerthere is no functionality for this. there are simply too many ways you might want to run a :node-script#2022-09-0808:33thhellerthe intent is you opening a second terminal and running it yourself#2022-09-0808:33thhelleryou may after all also want access to stdin/stderr in the app#2022-09-0808:34Lidor Cohenyeah I totally understand the underling design, that's what I do today. Just trying to smooth things up for our team. I'll just hack my way through it 🙂#2022-09-0808:14thhellerbut very likely that you do not want :node-script for the REPL at all#2022-09-0808:14thhellerjust use shadow-cljs node-repl instead. that just gives you the REPL without any build config or so#2022-09-0808:17Lidor CohenI don't want just the REPL, I work on a project and want the project's runtime. I might misunderstand how the REPL work, but iiuc in order to work in my files, ns, functions and data I need to build, run and then connect to the script's\lib runtime, correct?#2022-09-0808:18thhellerno#2022-09-0808:19thheller:node-script builds your entire project and produces a "executable" which you can then run via node#2022-09-0808:19thhellernode-repl just gives you a REPL, in which you can (require 'your.code) and run it, with no executable or other "output" apart from the REPL#2022-09-0808:21Lidor CohenSo executing the output code is not necessary at all for dev? Mostly I just want node\browser repl and start hacking? I'm guessing a real browser is required only for experimenting with real application...#2022-09-0808:22thhellerwell that all depends on what you are building#2022-09-0808:22thhellerfor example with :node-script you might be doing something that takes command line arguments, executes and exits#2022-09-0808:22thhellerhaving a REPL here would keep the process alive and would actually hinder the development#2022-09-0808:23thhellerso you'd maybe have the :node-script in addition to the node-repl#2022-09-0808:23thhellerfor browsers you might want to have actual HTML you generate yourself#2022-09-0808:23thhelleror embed in other ways in the HTML#2022-09-0808:23thhellerbrowser-repl only gives you a very basic HTML, that for example you can't include CSS into#2022-09-0808:24thhelleryes, you can just use browser/node-repl to start hacking. whether or not that makes sense depends on what you are building#2022-09-0808:24thhellerREPLs also don't automatically hot-reload and only builds do that#2022-09-0808:26Lidor CohenYes, I just noticed that and started looking for a solution, I love the hot-reload 🙂#2022-09-0815:10witekHallo. I am trying to use the npm package https://www.npmjs.com/package/leader-line. It just defines the constructor LeaderLine. The source for leader-line.min.js looks like this: var LeaderLine=function(){...}(); But how do I use it in my ClojureScript code? (:require ["leader-line" :as leader-line]) gives me a JavaScript object, but it is no function and it has no .-LeaderLine property.#2022-09-0817:06thheller@witek can't say. what does the object look like?#2022-09-0817:13witekJavaScript Console shows:
{}
[[Prototype]]: Object
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
propertyIsEnumerable: ƒ propertyIsEnumerable()
toLocaleString: ƒ toLocaleString()
toString: ƒ toString()
valueOf: ƒ valueOf()
__defineGetter__: ƒ __defineGetter__()
__defineSetter__: ƒ __defineSetter__()
__lookupGetter__: ƒ __lookupGetter__()
__lookupSetter__: ƒ __lookupSetter__()
__proto__: (...)
get __proto__: ƒ __proto__()
set __proto__: ƒ __proto__()
When I include the library via <script src="..."> I can call (js/LeaderLine e1 e2). But js/LeaderLine does not exist when I just (:require ["leader-line"])
#2022-09-0817:15thhellerso it has a constructor#2022-09-0817:16thhellerso probably just (:require ["leader-line" :as leader-line]) and (leader-line.), ie. constructing a new instance?#2022-09-0818:03witekThis fails with Uncaught TypeError: module$node_modules$leader_line$leader_line_min is not a constructor#2022-09-0818:07thhellermaybe its only intended to be used via a script tag#2022-09-0818:07thhellerdoesn't appear to be a proper npm package otherwise#2022-09-0906:17witekOk. I expected every npm package to be usable with shadow-cljs. Thank you for your help!#2022-09-0906:17thhellerwell, my guess is this one isn't even compatible with webpack#2022-09-0906:17thhellersome just use npm as a delivery mechanism without any expectation of actually being bundle-able#2022-09-0906:34thhelleryou could add the line module.exports = LeaderLine; as the last line in its sources to make it an actual npm package with an export#2022-09-0906:35thhellerbut yeah otherwise its not exporting anything#2022-09-0909:53MariusI’ve upgraded shadow-cljs from 2.19.0 to 2.20.1 (among other things) and now the compilation fails with the following exception:
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
IllegalArgumentException: No matching method setOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/set-options (closure.clj:166)
	shadow.build.closure/set-options (closure.clj:122)
	shadow.build.closure/convert-goog* (closure.clj:2290)
	shadow.build.closure/convert-goog* (closure.clj:2255)
	shadow.build.closure/convert-goog (closure.clj:2434)
	shadow.build.closure/convert-goog (closure.clj:2384)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1233)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1226)
	shadow.build.compiler/compile-all (compiler.clj:1468)
	shadow.build.compiler/compile-all (compiler.clj:1345)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:512)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
	shadow.cljs.devtools.server.worker.impl/eval28465/fn--28467 (impl.clj:448)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--28223/fn--28224/fn--28232 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--28223/fn--28224 (util.clj:282)
	shadow.cljs.devtools.server.util/server-thread/fn--28223 (util.clj:255)
	java.lang.Thread.run (Thread.java:833)
Has anyone seen this before? I could not find anything neither in the web nor here….
#2022-09-0911:16MariusI’ve figured it out, the following dependency caused the exception: [com.google.javascript/closure-compiler-unshaded "v20220905"] Reverting to [com.google.javascript/closure-compiler-unshaded "v20220502"] solved the issue.#2022-09-1005:33thhelleractually it should be [com.google.javascript/closure-compiler-unshaded "v20220803"] for 2.20.1#2022-09-1005:33thhellerunfortunately the closure compiler frequently introduces breaking changes to their API#2022-09-1005:33thhellerso have to stay with matching versions#2022-09-1011:27Mariusok, thanks, will fix it!#2022-09-0920:38Ivan FedorovHi Thomas! I got further with my externs hunt, fixed many issues. One that still bugs me is that Closure seems to rename usage of properties of some browser APIs, notably the SVG elements properties. Do you have an idea of how to provide all externs for SVGElement? Other than just copying its API from MDN. ––––––––––––––– Update: yea, seems like Closure actually may not support SVG out of the box! https://github.com/google/closure-compiler/wiki/Externs-For-Common-Libraries#svg#2022-09-1005:34thhellerthese are the default svg externs that are included https://github.com/google/closure-compiler/blob/master/externs/browser/svg.js#2022-09-0920:56ChicãoHi, I'm trying to export some components from an application that uses React + NextJS + Tailwind to import in a clojurescript app with helix an shadow-cljs, so does anyone knows how can I do this? I was trying to install my app on package json but had some problems I will send on the 🧵#2022-09-0921:00Chicãowhen I installed my components into my cljs app here is the components into node modules#2022-09-0921:00ChicãoI tried to import and I got this#2022-09-0921:31Chicãothis is an exemple https://github.com/moclojer/try-import-components-lib-into-cljs-app#2022-09-0921:31Chicãothis is the components that I want import https://github.com/moclojer/try-import-components-lib-into-cljs-app/blob/main/lib/index.jsx#2022-09-0921:32Chicãothis is how I tried to use https://github.com/moclojer/try-import-components-lib-into-cljs-app/blob/main/src/cljs/app/core.cljs#L6#2022-09-0922:22alexNot sure if this is the only issue but you might have a misspelling in your cljs import. Should it say "moclojer-components" (you're missing the "r")#2022-09-1002:22Chicãoyep I fix it but still have the same problem#2022-09-1005:38thhellerthe components use next.js? normally next.js is the app and is not used to create libraries?#2022-09-1011:42ChicãoOh it uses but I can remove if next is the problem. But not sure what I did is right. The component are jsx should I have to transpile to js?#2022-09-1013:07thhelleryes, they need to plain js#2022-09-1013:07thhellerand it needs to be a proper npm package#2022-09-1022:18Chicãohi @U05224H0W, @UMMMKKADU open a PR https://github.com/moclojer/try-import-components-lib-into-cljs-app/pull/1 to help me, this was what I try to do. I’m sending here to share if someone wants do the same thing.. Thanks#2022-09-1118:50borkdudeDoes target esm support a node REPL?#2022-09-1120:14thhellernot currently#2022-09-1205:07robert-stuttafordis there documentation focused on build performance, specifically, on how to maximise it? parallelism, caching setup, etc#2022-09-1205:19robert-stuttafordone specific question i have is, can i build multiple targets in parallel, given that they all share a common base module? ideally it'd compile the base first and then compile all the targets in parallel afterwards#2022-09-1205:44thheller@robert-stuttaford build performance is pretty much optimized by default and there are no settings to make it faster, only to disable threads etc which makes it slower#2022-09-1205:45thhellerbuilds are always isolated and they share nothing. each has its own cache.#2022-09-1205:46thhellercompiling multiple builds in parallel is possible but experience has shown that it is in fact pretty much identical in speed in doing them sequentially#2022-09-1205:46thhellerthat is because the build already uses a maxed out threadpool, so other builds spent most times waiting#2022-09-1205:58robert-stuttafordok, interesting, thank you @thheller!#2022-09-1205:59robert-stuttafordso given that, the most ideal build set up to take advantage of that is one build with several modules, as that way there'll only be a single cache?#2022-09-1206:00thhellerdepends on what kind of performance you are talking about#2022-09-1206:00thhellerit makes no sense to pull stuff into a build that doesn't belong in it#2022-09-1206:01robert-stuttafordof course#2022-09-1206:01thhellerand multiple builds usually is no problem once their cache is hot#2022-09-1206:01thhellersince they'll only compile the minimal set afterwards#2022-09-1206:02robert-stuttafordyeah caching is difficult because we use buildkite which uses multiple agents on multiple hosts, so right now we effectively run clean every time. we're going to look into ways to ensure a stable caching setup#2022-09-1216:23thhellerone thing I just assumed you are doing which you might not actually be doing is running multiple builds in one command#2022-09-1216:23thhellershadow-cljs release build1 build2 is much faster than shadow-cljs release build1 && shadow-cljs release build2 since only one shadow-cljs instance is started#2022-09-1306:15robert-stuttafordyes we're already doing one command!#2022-09-1206:03thhelleryes, a proper cache is the most important thing for performance#2022-09-1206:03robert-stuttafordo7 thank you for responding so quick, have an awesome day sir!#2022-09-1212:29Daniel GersonHello. Does shadow-cljs support subpath imports in the context of :esm target? Or am I doing something wrong? https://github.com/dmg46664/problems/tree/main/02_shadow-subpath-imports#2022-09-1215:52thhellerthis is not supported but if you are building for node anyways it doesn't need to be supported#2022-09-1215:53thhelleryou can set :js-options {:js-provider :import} in the build config as described here https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration#2022-09-1216:04Daniel Gerson@thheller Thanks.#2022-09-1216:42juhoteperiI'm trying to configure server addr for RN app with :local-ip option, looks like option from command shadow-cljs watch android --verbose --config-merge '{:local-ip "127.0.0.1"}' isn't picked up but adding it to ~/.shadow-cljs/config.edn does work. Docs mention that --verbose output should display the used IP(s) but I'm not seeing those messages (https://github.com/thheller/shadow-cljs/blob/846446eb49e51daf9c25b6016603afe38b6d4768/src/main/shadow/cljs/devtools/api.clj#L604 https://github.com/thheller/shadow-cljs/blob/846446eb49e51daf9c25b6016603afe38b6d4768/src/main/shadow/cljs/devtools/api.clj#L604)#2022-09-1216:42juhoteperiThis is with 2.20.1#2022-09-1216:42juhoteperiLooks like the ::multiple-ips log call is inside comment form now.#2022-09-1216:42juhoteperiAnd there isn't any ::server-addr log calls#2022-09-1216:43juhoteperihttps://github.com/thheller/shadow-cljs/commit/02ece2f93aa9954e6483faf12019cdf4d1388e0c ::server-addr log call was removed here#2022-09-1216:44juhoteperiBut I don't understand why the option isn't picked up from CLI arguments etc.#2022-09-1216:45thhellerthis shouldn't be necessary anymore at all? I changed it so it tries all local ips until it finds one that works#2022-09-1216:46thhellerno more reports of failed connections ever since I added that#2022-09-1216:47juhoteperiWell, my WIFI or firewall is probably blocking all incoming connections, I could figure that out, but I've usually just used adb reverse to tunnel traffic, in that case the phone needs to access localhost which isn't included in the list.#2022-09-1216:50thhellerhmm I don't do any RN development so no clue how adb works#2022-09-1216:51thhellerI guess I could add support for :local-ip per build back in (since config-merge only applies to the build config)#2022-09-1216:51juhoteperiThe docs mention --config-merge example: https://shadow-cljs.github.io/docs/UsersGuide.html#repl-trouble-react-native#2022-09-1216:52thhellerhmm ok thats outdated and doesn't work anymopre#2022-09-1216:52juhoteperiLooks like the localhost version isn't going to work as RN/JS forbids access to localhost#2022-09-1216:53juhoteperiWhich is interesting because RN packager is connected through localhost... But I'll just figure out why the phone can't connect to Shadow-Cljs with the LAN IP#2022-09-1216:53juhoteperiShould the multiple-ips log call here be enabled: https://github.com/thheller/shadow-cljs/blob/846446eb49e51daf9c25b6016603afe38b6d4768/src/main/shadow/cljs/devtools/api.clj#L628 ?#2022-09-1219:33thhellernah, that entire function is dead and no longer used#2022-09-1219:33thhellerjust leaving it in case anyone is using it#2022-09-1217:33GHvWI'm trying to use "preact/hooks" in a cljs app, but every time I try to use one of the hooks, I get an error like this: Cannot read properties of undefined (reading '__H') it happens in the repl and when running the app. the require looks roughly like this in the app: (:require ["preact/hooks" :refer [useState]]) anyone happen to know why I might be getting that error and/or what I'm missing?#2022-09-1220:18Ivan FedorovHi Thomas, thanks for all the support! Regarding externs again – they are all summed up before being fed to Closure, right? Let’s say we have: • simplified externs/app.txt • and externs/app.js They both will be fed to Closure compiler, right? Or are these mutually exclusive?#2022-09-1220:20thhellercorrect, they are all added#2022-09-1313:32Chris McCormickHello, does anybody have a good example of a GitHub action that runs tests in a shadow-cljs project? I have a :target like this:
{:target :node-test
 :output-to "tests.js"
 :ns-regexp "sitefox.*$"
 :autorun true}
And an npm script that looks like this for running it:
shadow-cljs compile test && node tests.js
I'd like to be able to do this on each push/PR on Linux and Mac.
#2022-09-1402:38Chris McCormickhttps://clojurians.slack.com/archives/C03S1L9DN/p1663123080639379?thread_ts=1663117770.993159&amp;cid=C03S1L9DN#2022-09-1402:38Chris McCormick(got it working)#2022-09-1314:40zimablueis there a macro-accessible variable or anything to know from the macro-expand-time/runtime whether the build was produced by "compile" vs "release"?#2022-09-1315:23thheller@zimablue (:shadow.build/mode &env) in the macro. :release for release builds, otherwise :dev#2022-09-1315:26zimablueThanks#2022-09-1320:04Ivan FedorovHi Thomas, just notifying you, that Closure seems to also not support ResizeObserver API. Added a couple more externs manually. Which leads me to think, what other APIs aren’t supported.#2022-09-1320:05thhellerthere is like 3 functions in that API? what would be missing?#2022-09-1320:06thhellerhttps://github.com/google/closure-compiler/blob/master/externs/browser/wicg_resizeobserver.js#2022-09-1320:08thheller(included by default)#2022-09-1320:42Ivan FedorovHmmm, should I somehow notify Closure that I’m using this API in my JS file?#2022-09-1320:43thhellernope, should just work out of the box#2022-09-1320:44Ivan FedorovThis is my js file head#2022-09-1320:45thhellerbe careful with type info, if its incorrect that may lead to bugs#2022-09-1320:47Ivan FedorovIt’s part of the library. Then I lein install this lib, and use it in a different project. The latter project only started to work properly after I supplied borderBoxSize, inlineSize, blockSize to its externs/app.txt#2022-09-1320:47Ivan Fedorovmaybe an old shadow-cljs / clojurescript version?#2022-09-1320:48thhelleryou tell me? 😛 the resizeobserver externs are fairly new#2022-09-1320:48Ivan Fedorovshadow version 2.15.3#2022-09-1320:49thheller2.15.3 - 2021-08-08#2022-09-1320:49thhellerno idea when the externs where added#2022-09-1320:50Ivan Fedorovok, thanks! will check hmm, but the same thing was with SVG#2022-09-1320:51Ivan Fedorovmaybe I should try removing all type annotations#2022-09-1320:52thhellerwell, does it work with the newer version?#2022-09-1321:15Ivan Fedorovhmm, yes, seems to#2022-09-1413:31Ferdinand BeyerHas anyone successfully built a VS-Code Web Extension with shadow-cljs? I need to target the browser, but cannot use any kind of library loading, and need to export functions to the exports symbol. It seems that when using the :export metadata on a function shadow emits a goog.exportSymbol call, but this one is not picked up by VS-Code. I think it "exports" to goog.global, which is this || self, but not exports. I can set the JavaScript properties to js/exports manually and it seems to work, but this seems like a hack?#2022-09-1413:39thheller@fb do you have a link to some docs? does it support ESM?#2022-09-1413:40Ferdinand BeyerI think it does not. I tried using the :esm target but this threw errors that export was not defined https://code.visualstudio.com/api/extension-guides/web-extensions#2022-09-1413:41thhellerjs/exports is a hack and should not be done#2022-09-1413:43thhellerhmm yeah seems like ESM is not supported#2022-09-1413:43thhellerso you can use the :node-library target#2022-09-1413:43thhellerbut watch/compile likely won't work (they assume a node env) and only release might#2022-09-1413:44Ferdinand BeyerSimilarly, I need to keep using require for "vscode", but not for others. I am using this in my build config:
:js-options {:js-provider :shadow
                :keep-native-requires true
                :keep-as-require #{"vscode"}}
This seems to work; however, for some reason my compile output now also wants to require("path") which does not exist, when I (:require ["vscode-languageclient/browser" :as browser]). The browser lib is specifically for this purpose and should not use "path"...
#2022-09-1413:44Ferdinand BeyerI tried :node-library but get errors about global being undefined. I figured this is just for node, not for browsers#2022-09-1415:44pezInteresting. We're using :node-library in both Calva and Joyride. Maybe that closes the door for enabling them for the Web version of VS Code...#2022-09-1415:46Ferdinand BeyerProbably. Meanwhile I am following Thomas' hints and build :npm-modules and process them with webpack. I hope I never have to step through the resulting JavaScript by hand 😄#2022-09-1416:33pezWe're also using Webpack. Very happy there are these tools like shadow and webpack and such!#2022-09-1416:38Ferdinand BeyerBut they make me dizzy 🙂#2022-09-1416:38Ferdinand BeyerClojureScript, Closure Compiler, Shadow, Webpack -> Who is contributing what? 😄#2022-09-1416:39Ferdinand Beyer#2022-09-1417:12pezThrow Tailwind CSS into the mix, with it's PostCSS pipeline, while at it. 😃#2022-09-1413:45thhellercorrect, it assumes node#2022-09-1413:46thhelleryour best bet is probably using :target :npm-module and using their webpack example config#2022-09-1413:46thhellerREPL and hot-reload probably won't work though#2022-09-1413:48Ferdinand BeyerYeah, I figured that much, as I need "all in one JS file"#2022-09-1414:43Ferdinand BeyerTrying this path... I now get "`process` is not defined", and indeed the beginning of cljs_env.js reads:
var $CLJS = {};
var CLJS_GLOBAL = process.browser ? (typeof(window) != 'undefined' ? window : self) : global;
Looks like this, too, is targeting node?
#2022-09-1415:07Ferdinand BeyerOh, nevermind, I think I am entering the dark realms of polyfills 😕#2022-09-1416:07thhellernot polyfills but yeah. the targets are all designed to make specific assumptions about their environment#2022-09-1416:07thhellerso your web extensions is just another very locked down target with very specific kind of expectations#2022-09-1416:08thhellerso this would be a custom :target that just emits exactly what the web extensions expects#2022-09-1416:08thhellerthere just isn't one like that currently 😛#2022-09-1416:11Ferdinand BeyerMaybe I can help one day, currently I am not too deep into the muddy waters of JavaScript builds 🙂 I said polyfills because I needed to configure webpack to provide polyfills for process (among others), and then it worked. Even though I am probably pulling in a process implementation just for the process.browser flag 😄#2022-09-1416:18thhelleryeah webpack v4 always provided this but v5 no longer does#2022-09-1416:18Ferdinand BeyerTIL!#2022-09-1416:18thhellerI should just get rid of it entirely but don't want to break stuff for people that may rely on it 😛#2022-09-1416:19Ferdinand BeyerGet rid of what?#2022-09-1416:20thhellerthe process.browser check#2022-09-1416:21Ferdinand BeyerAh, I was not even aware that this is yours 😄#2022-09-1416:21thhelleryeah :npm-module adds it so it works in node and the browser#2022-09-1416:21Ferdinand BeyerIs there a way to do !process || process.browser?#2022-09-1416:21thhellerthat would still make webpack v5 unhappy because process is undefined#2022-09-1416:22Ferdinand Beyertypeof(process) === undefined?#2022-09-1416:22thhellerhttps://github.com/thheller/shadow-cljs/blob/51d21f5b325d8cb18cd670a3edfab7063e91d477/src/main/shadow/build/output.clj#L490-L496#2022-09-1416:23thhellerdid you set :runtime :browser in the build config?#2022-09-1416:23thhellerthat would also get rid of it 😉#2022-09-1416:23thhellerforgot to mention this#2022-09-1416:23Ferdinand BeyerHa!#2022-09-1416:23thhelleralthough it might also not like the globalThis#2022-09-1416:23thhellerdunno enough about the web extension context runtime#2022-09-1416:23Ferdinand BeyerLet's see!#2022-09-1416:23Ferdinand BeyerIn the end it will run in a browser#2022-09-1416:24Ferdinand BeyerAnd for testing they have some kind of fake for that#2022-09-1416:30Ferdinand BeyerHm, does not seem to make a difference. But I also don't see the process.browser bit anymore in the output files. Will keep an eye on it#2022-09-1415:37pezMaybe of particular interest to shadow-cljs users (at least the ones also using #calva). @danielamber2 and I have made a video about using Calva with shadow-cljs, where we also try to reveal some of the details and how things are composed to make it all work. Some of it applies generally to nREPL tooling, so CIDER (and other nREPL clients) users might also enjoy. I do hope I am not misinforming too much about things there, please let me know if you spot any such. https://www.youtube.com/watch?v=islMjv55cN8 I have also written an article about the same subject. https://blog.agical.se/en/posts/shadow-cljs-clojure-cljurescript-calva-nrepl-basics/ Pick whichever way you fancy. I think they go great together. 😃#2022-09-1511:19eccentric JWorking on a small greenfield project for work. Mostly a static pricing application. I would like to hash various assets like images and css files but I'm not sure on the best way to accomplish that with shadow. Was thinking a build hook might be interesting, or compiling to esm and using esbuild to bundle but not sure shadow will like importing image files, perhaps best to have an nbb script run before each build to generate a bundled edn file that points the common name to an asset version path? Any better ideas or examples out there?#2022-09-1511:22eccentric Jhttps://github.com/ljpengelen/shadow-cljs-hash-assets-hook found that which might work but not sure that solves the problem for assets that need to be dynamically rendered from React#2022-09-1605:13thhellerIMHO shadow-cljs doesn't need to know about any of this and shouldn't be involved at all#2022-09-1605:13thhelleryou build your CLJS normally and feed the asset data into it at runtime#2022-09-1605:14thhellereither via the HTML or by having your output load a .json file or so#2022-09-1905:41eccentric JI see. That's the strategy I was leaning towards, generating an edn file included with the build to point to assets but after exploring frameworks like remix, directly importing assets is nice because it only needs to generate hashes\optimize resources referenced vs generating a manifest by hashing all asset files. Alternatively, might be able to reach a reasonable middleground by scanning the cljs code for refs to asset paths and only generating assets for those, somewhat inspired by how tailwind figures out what classnames to define in the compiled css file.#2022-09-1512:49valeraukoafter a few beers i accidentally accessed the nrepl port (localhost:8777) in a browser, which resulted in an arithmetic exception (long overflow). just thought i'd let you know#2022-12-1010:52Lucio AssisSo today I learned that you get the same exception if you're in Cursive and mistakenly connect to shadow's nrepl but the cursive repl config says Connection Type = Socket REPL Just leaving this here in case someone comes across long overflow trying to start a cljs repl via Cursive.#2022-09-1519:15wilkerluciohello, what config can I set so shadow-cljs stop preventing reload on deprecate warnings?#2022-09-1519:26wilkerlucioa bit more info: I'm adding cljs tests to a library, the tests do call deprecated functions, but that's an OK situation here, we want the fn to be deprecated, and still want to test it, is there a way to ignore all deprecation calls? or tune the tests namespaces to ignore them?#2022-09-1520:49rolt:warnings-as-errors search for it in the user guide there is a link to the list of possible values#2022-09-1520:50wilkerluciobut I guess that's to do the opposite of what I want no? this seem to be a way to raise the warning and behave as an error, I want to ignore instead#2022-09-1520:50roltset it to false#2022-09-1520:54roltactually my bad, i have :ignore-warnings true instead in the :devtools section so that's probably this one#2022-09-1520:55roltnot sure how to ignore for a single warning type though#2022-09-1605:12thheller:compiler-options {:fn-deprecated false} to get rid of them#2022-09-1605:12thheller:devtools {:ignore-warnings true} to ignore them for hot-reload purposes#2022-09-1619:37wilkerluciojust an errata for anyone looking at that in the future, to disable the deprecate warning, this is the config:
:compiler-options {:warnings {:fn-deprecated false}}
#2022-09-1619:37thhelleroh right#2022-09-1619:39wilkerluciocomplete ref: https://clojurescript.org/reference/compiler-options#warnings#2022-09-1622:23Ben Liebermanwhy might it be that when I re-evaluate forms that I've changed I can see shadow-cljs is recompiling the JS in the browser but nothing about my app state actually changes#2022-09-1705:20thhellersee https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-09-1713:39puchaczhi, I connected cider-cljs and I have REPL, but my source buffer says cider[not connected], and I cannot use commands like M-. (jump to definition) or C-z (go to REPL). the REPL works all right though. and the sesman-browsser shows my session with suspicious message (pending-cljs):#2022-09-1713:39puchacz1: projects5/bubrary-gui:localhost:9000 linked-to: proj(~/projects5/bubrary-gui/) objects: cider-repl %s(pending-cljs)#2022-09-1713:40puchacz(trying my luck with the same issue in cider)#2022-09-1713:59Fredrik AnderssonI'm trying to make the dev-http serv index-files from subdirectories for instance where /index.html would serve / and /app/index.html would serve /app#2022-09-1713:59Fredrik Anderssonis there any configuration that I am missing?#2022-09-1714:00thhellerno, it just assumes push-state routing. meaning your client doing the route logic with a base index.html#2022-09-1714:02Fredrik Anderssonyes, I read that in the docs - i wish to have a static landing page on the root and the SPA in /app is it possible to configure this scenario?#2022-09-1714:03thheller/app/might work?#2022-09-1714:03Fredrik Anderssonno it still renders /index.html#2022-09-1714:07thhellerthere is no setting for this. you can however just use any webserver that exists#2022-09-1714:08thhellerall they need to do is serve the static files#2022-09-1714:08Fredrik Andersson:thumbsup:#2022-09-1721:38Ted CiafardiniTrying to get rid of a warning when I deploy my app:
:WARNING: You required cljs-devtools library in a project which is currently compiled with :optimizations :advanced.
remote:                 You should remove this library from non-dev builds completely because it impedes dead code elimination.
remote:                 The best way is to use :preloads compiler option: .
remote:                 To silence this warning please set :silence-optimizations-warning config key to true.
remote:                 More details: .
My shadow-cljs config is:
{:nrepl {:port 7772}
 :builds {:app {:target :browser
                :output-dir "target/cljsbuild/public/js"
                :asset-path "/js"
                :modules {:app {:entries []}}}
          :dev {:target :browser
                :output-dir "target/cljsbuild/public/js"
                :asset-path "/js"
                :modules {:app {:entries []}}
                :devtools {:preloads [day8.re-frame-10x.preload]
                           :watch-dir "resources/public"}
                :dev {:closure-defines
                      {re-frame.trace.trace-enabled?        true
                       day8.re-frame.tracing.trace-enabled? true}}}
          :test {:target :node-test, :output-to "target/test/test.js"
                 :autorun true}}
 :lein true}
I thought taking the dev tools out of the ‘app’ build (used for deployment) would resolve the issue - any help appreciated
#2022-09-1721:40Ted Ciafardiniat deployment this script is run:
#!/usr/bin/env bash
npx shadow-cljs release app
lein uberjar
#2022-09-1804:51thhellerI'm guessing that somewhere in your code you directly require something from devtools.*?#2022-09-1804:51thhellerdevtools.core or devtools.preload or something#2022-09-1804:52thhellersplitting into a :dev build is not idiomatic. you can configure dev/release specific things in the main config. see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2022-09-1817:48dvingohi - I'm working on malli cljs instrumentation. I am trying to get the updated namespaces during development/reload cycle is there a way to get the list of namespaces/files that triggered the fs watch? in the :compile-prepare hook
(:compiled (:shadow.build/build-info build-state)
is empty (obviously), is there an equivalent way to get the updated files in prepare stage? The goal is to reset! state used by a macro in order to communicate to the macro which namespaces need to be re-instrumented, which needs to be updated before compilation
#2022-09-1818:08Joseph DumontHi, I have the following error when releasing an app:
shadow-cljs - connected to server
[:app] Compiling ...
Closure compilation failed with 1 errors
--- externs.shadow.js:8
Parse error. 'identifier' expected   
I went through suggested solutions here https://clojurians.slack.com/archives/C6N245JGG/p1612542030435100 and added the following variations of build-hooks as suggested in that thread, but didn't turn up a comparable solution. I'm wondering if there's another strategy to take to find whats causing this. I also went through and removed any unicode symbols and non-english characters in case that was the issue, but still have 1 error somewhere.
;; ;; This didn't find any empty ""
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [build-state]

  (prn (shadow.build.closure/extern-props-from-cljs build-state))

  build-state)
;; [:app] Compiling ...
;; #{"useLayoutEffect" "useRef" "useCallback" "useImperativeHandle" "$$Signature$$"
;;  "getElementById" "removeEventListener" "createRoot" "createElement" "flushSync"
;;  "Fragment" "PersistentVector" "useDebugValue" "$$Register$$" "DateTimeFormat"
;;  "useMemo" "hasNext" "forwardRef" "createContext" "PersistentArrayMap"
;;  "Suspense" "useReducer" "Component" "useEffect" "now" "useState" "useContext"
;;  "addEventListener" "Element" "core" "memo" "equiv"}

;; Closure compilation failed with 1 errors --- externs.shadow.js:8 Parse error.
;; 'identifier' expected
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (doseq [{:keys [resource-id properties]} (vals output)
          prop properties
          :when (< (count prop) 2)]
    (prn [:prop resource-id prop]))

  build-state)
;; this one didn't log anything at all
;; beyond initial error
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [{:keys [output] :as build-state}]

  (->> (vals output)
       (filter #(contains? (:properties %) ""))
       (map :resource-id)
       (prn))

  build-state)
;; [:app] Compiling ...
;; ()
;; Closure compilation failed with 1 errors
;; --- externs.shadow.js:8
;; Parse error. 'identifier' expected
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-properties]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-properties "")]
    (prn [:found ns js-access-properties]))

  state)
;; [:app] Compiling ...
;; Closure compilation failed with 1 errors
;; --- externs.shadow.js:8
;; Parse error. 'identifier' expected
#2022-09-1819:11thhellerthis doesn't necessarily have to be an empty string#2022-09-1819:11thhellercould be anything that is not a valid JS identifier#2022-09-1819:12thhellercan't think of anything quick to figure this out. let me think about it tomorrow#2022-09-1819:12Joseph DumontThank so much.#2022-09-1819:15thhellerI mean even these "_peek-at" looks suspicious#2022-09-1819:15thhellerbecause they are not valid identifiers#2022-09-1819:15thhellercan you check where that is from? with the find-it helper but looking for that not the empty string?#2022-09-1819:18thheller"Children.toArray" is also incorrect#2022-09-1819:18Joseph DumontAh "_peek-at" was from the old thread, I don't have any of that in my output.#2022-09-1819:18thhellerso not sure where all of these are coming from#2022-09-1819:18thhelleroh#2022-09-1819:19thhellerthe externs file is created in .shadow-cljs/builds/<the-id>/release/externs.shadow.js#2022-09-1819:19Joseph DumontI only get
shadow-cljs - connected to server
[:app] Compiling ...
Closure compilation failed with 1 errors
--- externs.shadow.js:8
Parse error. 'identifier' expected
#2022-09-1819:19thhellerlook in line 8 😉#2022-09-1819:21Joseph DumontAha! I was searching for that... I think I was trying to throw a js error improperly ╰─$ cat .shadow-cljs/builds/app/release/externs.shadow.js
/** @const {ShadowJS} */ var Intl;
/** @const {ShadowJS} */ var Promise;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var clearInterval;
/** @const {ShadowJS} */ var clearTimeout;
/** @const {ShadowJS} */ var module;
/** @const {ShadowJS} */ var setInterval;
/** @const {ShadowJS} */ var throw;
/** @const {ShadowJS} */ var undefined;
#2022-09-1819:31thhellerhmm where is that undefined coming from 😛#2022-09-1819:33Joseph DumontI'll look for that as well. Removing a couple of (js/throw ...) now has it compiling without error though.#2022-09-1819:34thhellerjust (throw ...) is fine. no need for the js/#2022-09-1819:38Joseph DumontAha. Even with it compiling without error now, I still see the undefined var. If I did want to locate where that's coming from, do you have a suggestion?
/** @const {ShadowJS} */ var Intl;
/** @const {ShadowJS} */ var Promise;
/** @const {ShadowJS} */ var React;
/** @const {ShadowJS} */ var clearInterval;
/** @const {ShadowJS} */ var clearTimeout;
/** @const {ShadowJS} */ var module;
/** @const {ShadowJS} */ var setInterval;
/** @const {ShadowJS} */ var undefined;
#2022-09-1819:38thhellerwell the find-it helper fn#2022-09-1819:39thhellerbut not looking for properties#2022-09-1819:40thhellerextern-globals-from-cljs instead of the extern-properties-from-cljs#2022-09-1819:44Joseph DumontLike so?
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [build-state]

  (prn (shadow.build.closure/extern-globals-from-cljs build-state))

  build-state)
[:app] Compiling ...
#{"window" "Symbol" "Promise" "Date" "document" "Intl" "clearTimeout" "React" "JSON" "clearInterval" "RegExp" "undefined" "Error" "setTimeout" "setInterval"}
[:app] Build completed. (72 files, 0 compiled, 0 warnings, 11.43s)
#2022-09-1819:45thheller
(doseq [src-id (:build-sources state)
        :let [{:keys [ns file] :as src}
              (get-in state [:sources src-id])
              {:shadow/keys [js-access-properties]}
              (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
        :when (contains? js-access-properties "undefined")]
  (prn [:found ns js-access-properties]))
#2022-09-1819:46thhellerthe find-it hook#2022-09-1819:46thhellerjust looking for undefined not the empty string#2022-09-1819:51thhellersorry, like this. looking for globals not properties
(doseq [src-id (:build-sources state)
        :let [{:keys [ns file] :as src}
              (get-in state [:sources src-id])
              {:shadow/keys [js-access-global]}
              (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
        :when (contains? js-access-global "undefined")]
  (prn [:found ns js-access-global]))
#2022-09-1819:51thhelleror rather the full hook
(defn find-it
  {:shadow.build/stage :optimize-prepare}
  [state]

  (doseq [src-id (:build-sources state)
          :let [{:keys [ns file] :as src}
                (get-in state [:sources src-id])
                {:shadow/keys [js-access-global]}
                (get-in state [:compiler-env :cljs.analyzer/namespaces ns])]
          :when (contains? js-access-global "undefined")]
    (prn [:found ns js-access-global]))
  
  state)
#2022-09-1819:53Joseph Dumont
[:app] Compiling ...
[:found helix.impl.props #{"RegExp" "undefined" "Error"}]
[:found helix.core #{"window" "Symbol" "undefined" "Error"}]
[:found helix.hooks #{"undefined" "Error"}]
[:app] Build completed. (72 files, 0 compiled, 0 warnings, 11.77s)
#2022-09-1819:57thhellerhmm weird#2022-09-1819:59thhellerhmm I guess it collects that for js/undefined#2022-09-1819:59thhellerprobably shouldn't but seems like it doesn't hurt anything#2022-09-1820:00Joseph DumontThank you for all your time and help!#2022-09-1911:59valeraukohey @thheller , i was hoping to give shadow-css a try, but i can't seem to get it to work as expected based on the readme. i use the development watching build described in the readme. it does output the "base" ui.css, but none of the (css) from cljs files seems to make it into the .css file. am i missing something? are there some undocumented expectations about file naming? does it need something extra be put in the index.html or something?#2022-09-1912:04valeraukonever mind, figured it out. i didn't notice the * filter in the generate-css function. once i adjusted that it now works as a wonder.#2022-09-1912:06valeraukoare there any plans for making the build process smoother (and maybe integrated seamlessly with shadow-cljs)? i'd be happy to help if hands are needed#2022-09-1916:05thhellerdon't have time to think about making builds smoother or integrated currently#2022-09-1912:51Fredrik Anderssonanybody know why I get this#2022-09-1912:52Fredrik AnderssonIs it because of the URL http://localhost:8020/app/index.html ?#2022-09-1913:09valeraukoi suspect something is serving a html 404 page and it doesn't know about your map files#2022-09-1914:11Fredrik Anderssonahh I see now that the mapping is under /app/ but i suspect that it should be above it#2022-09-1914:13Fredrik Anderssonyeah the correct path is http://localhost:8020/app-js/cljs-runtime/cljs.analyzer.impl.namespaces.js.map#2022-09-1914:13Fredrik Anderssonfor instance#2022-09-1914:14Fredrik AnderssonI needed to set :asset-path "/app-js"#2022-09-1920:05Fredrik AnderssonI must say that I love shadow-cljs! Thanks thheller!#2022-09-1922:57dehliHello, I'm trying to reduce a shadow bundle size when using shadow-cljs release with advanced compilation and a browser target. One library that's contributing quite a bit seems to be https://www.npmjs.com/package/@aws-amplify/ui-react. When I remove the library from the codebase, ~7M is saved. I was able to slightly reduce its footprint by directly referencing the classes we're using (ex ~700Kb). Any tips to further investigate or different directions I should go? I could permanently use webpack along with shadow if that's the recommended way to go but wanted to check if I can get it working w/ just shadow. Thanks in advance!#2022-09-2004:35thhellercreate a build report https://shadow-cljs.github.io/docs/UsersGuide.html#build-report#2022-09-2004:36thhellerif you use many libs that sort of expect webpack (eg. aws-amplify) then you might be better off letting webpack bundle those deps
#2022-09-2011:19dehlithanks so much! the build report surfaced that more aws libraries are being pulled in with the shadow build so I'm going to go down the webpack approach. appreciate all your help!#2022-09-2012:42dvingoreplying to: https://clojurians.slack.com/archives/C6N245JGG/p1663523285825599 I have found a solution using a build-hook to gather edited namespaces before compilation runs using this technique: https://github.com/metosin/malli/blob/d04fa68d16df383ce8632840241257b3daf7da17/src/malli/dev/shadow_cljs_instrument_hooks.clj (part of this PR https://github.com/metosin/malli/pull/754) I'm wondering if there is a better solution by directly accessing the build-state in a :compile-prepare hook though. I didn't see a way to get that information in the prepare stage, is there one?#2022-09-2015:18thheller@danvingo lets discuss further on the PR#2022-09-2018:57torgeirHey folks! Say I would do something like (ns server.main (:require ["fs" :as fs])) and evaluate it in a node-repl, then type (fs/rea|), (pretend the cursor is at |) Should I be expecting an autocomplete in emacs with clojure-lsp and/or cider? Or is there something wrong with my setup#2022-09-2019:09thhelleryou should ask emacs or clojure-lsp. it is not something shadow-cljs is involved in. I'm guessing no but I don't have a clue what either do#2022-09-2019:24torgeirThanks, will do#2022-09-2022:05Logan Powell👋 Hey everybody! Does anyone know if :target :esm is still https://clojureverse.org/t/generating-es-modules-browser-deno/6116/21?#2022-09-2022:05Logan PowellI'm having some issues using the library I created with a bundler called Vite#2022-09-2022:06Logan Powellwhich uses ESM#2022-09-2102:18Logan PowellI read the https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration section in the docs and know that one of my deps (`cljs-ajax`) is doing a dynamic js/require as a https://github.com/JulianBirch/cljs-ajax/blob/master/src/ajax/xml_http_request.cljs#L35, so I'm at a loss for how I should handle this with ESM... any pointers would be appreciated 🙏#2022-09-2102:19Logan PowellMy compiled code throws an error here:
ajax.xml_http_request.xmlhttprequest="undefined"!==typeof goog&&"undefined"!==typeof goog.global&&"undefined"!==typeof goog.global.XMLHttpRequest?goog.global.XMLHttpRequest:"undefined"!==typeof require?function(){var a=require;return(a.cljs$core$IFn$_invoke$arity$1?a.cljs$core$IFn$_invoke$arity$1("xmlhttprequest"):a.call(null,"xmlhttprequest")).XMLHttpRequest}():null;ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxImpl$=cljs.core.PROTOCOL_SENTINEL;
ajax.xml_http_request.xmlhttprequest.prototype. <<-- "Cannot read properties of null (reading 'prototype')
#2022-09-2105:44thheller@loganpowell require doesn't exist in ESM so the conditional shouldn't do anything? and yes :target :esm is an official target now#2022-09-2111:40Logan PowellHi @U05224H0W good to hear from you. It looks like it might be skipping the require and just returning the string for the requirement:
ajax.xml_http_request.xmlhttprequest="undefined"
#2022-09-2111:54Logan Powellactually, sorry, it looks like it's resolving to null#2022-09-2111:54Logan Powelllet me see if I can shim it#2022-09-2112:35Logan Powellcould you use something like https://github.com/ts-smith/browserify-shim-cljs/blob/master/src/leiningen/browserify_shim.clj in shadow to change (js/require) statements to (js/import)s?#2022-09-2112:36Logan Powellfor the :esm https://antfu.me/posts/publish-esm-and-cjs#2022-09-2116:01thhellersorry I don't know what you are doing so I cannot provide any tips#2022-09-2116:01thhelleryou definitely cannot change any js/require into import. that just doesn't work, they do entirely different things#2022-09-2116:58Logan PowellI'm trying to do something like this guy: https://gist.github.com/borkdude/7e548f06fbefeb210f3fcf14eef019e0#2022-09-2116:58Logan Powellbut I'm getting an error
; SHADOW import error D:\projects\census\census-geojson\.shadow-cljs\builds\node-repl\dev\out\cljs-runtime\shadow.js.shim.module$node_fetch.js
; 
; Execution error (Error) at (<cljs repl>:1).
require() of ES Module D:\projects\census\census-geojson\node_modules\node-fetch\src\index.js from D:\projects\census\census-geojson\[stdin] not supported.
Instead change the require of index.js in D:\projects\census\census-geojson\[stdin] to a dynamic import() which is available in all CommonJS modules.
:repl/exception!
#2022-09-2117:00thhelleryes, that is node telling you that you cannot require ESM packages#2022-09-2117:01thhellermaybe its enough to change your node-fetch version? older versions did ship CJS code#2022-09-2117:04Logan Powelltrue, but would that work with the :esm target?#2022-09-2117:05thheller:esm can import ESM code yes#2022-09-2117:06Logan Powellthat's the target I'm using...#2022-09-2117:06Logan Powelllet me write up a gist#2022-09-2117:18Logan Powellhere's my setup#2022-09-2117:18Logan Powellhttps://gist.github.com/loganpowell/579edc529f2e6b3cdcb1f796bdab7dd1#2022-09-2117:19thheller> ; Connected session: cljs, repl: node-repl#2022-09-2117:19thhellerand ESM doesn't support a REPL in node currently#2022-09-2117:20thhellerso you are not using the :esm build at all#2022-09-2117:21Logan Powellwhen I do:
clj꞉shadow.user꞉> 
; Creating cljs repl session...
; Connecting cljs repl: shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Connected session: cljs, repl: :lib
; TIPS: You can choose which REPL to use (clj or cljs):
;    *Calva: Toggle REPL connection*
;    (There is a button in the status bar for this)
; Evaluating file: tests.cljs
; No available JS runtime.
; See 
nil
cljs꞉cljs.user꞉> 
#2022-09-2117:21Logan PowellI get No available JS runtime#2022-09-2117:22thhelleryes, because you need to run the generated JS#2022-09-2117:22thhellerbut as I just said. ESM does not support a node REPL#2022-09-2117:22thhellerso you won't get a runtime no matter what#2022-09-2117:23Logan Powellhmm...#2022-09-2117:23Logan Powellso I can't REPL with :esm?#2022-09-2117:24thhellerno, since you are supposed to use node-repl for that. ESM just gets in the way#2022-09-2117:24thhellerI don't have a solution for that currently#2022-09-2117:25Logan Powellgotcha. so, no ESM while REPL'ng#2022-09-2117:26thhellerwell the ESM browser has a REPL#2022-09-2117:26Logan Powell:browser target?#2022-09-2117:26thhellernode just isn't implemented#2022-09-2117:26thhellerno :esm loaded in the browser, not node#2022-09-2117:26Logan Powelloh man 😄#2022-09-2117:27Logan Powelllet me try to find an older version of node-fetch 😄#2022-09-2117:28Logan Powellfound https://www.npmjs.com/package/node-fetch-commonjs.#2022-09-2117:35Logan Powellseems like a good hack: use a commonjs version of the lib during development ("devDependencies") and then swap it out for esm for the :esm build#2022-09-2201:29Logan PowellOk, I think I'm almost there! I have a solution that should work in Node and the browser using lambdaisland.fetch and the following conditional :
(when isNode (set! js/fetch node-fetch))
This works in the node-repl but when I release it (`:esm` target), I get
fetch is not defined 
in the bundled code, it looks like:
// looks like it's referencing the lib:
Mi(In,rn,function(a,b,c){try{return Km(Pm(b.text.call(b),function(d){var e=Rs.h(c,C(Mt)).read(d);if(null!=e?e.v&262144||D===e.Lf||(e.v?0:y(Ib,e)):y(Ib,e)){var f=qd(e);d=Hf.j?Hf.j(f,Ps,d):Hf.call(null,f,Ps,d);e=pd(e,d)}return e}))}catch(d){return Nm(d)}});Mi(In,Wl,function(a,b){return b.json.call(b)});var Nt=esm_import$node_fetch <<------- :)

// ... but further down
Gh("ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž","aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz");var Tt="undefined"!==typeof process&&"undefined"!==typeof process&&"undefined"!==typeof process.versions&&"undefined"!==typeof process&&"undefined"!==typeof process.versions&&"undefined"!==typeof process.versions.node,fq=Tt?"":"",dq=Error;Tt&&(fetch=Nt) <<------- why?
Is it because I set the global variable shim in Node wrong?
#2022-09-2201:30Logan PowellHere's my shadow-cls.edn build setup:
:builds       {:lib {:target           :esm
                      :output-dir       "public/census"
                      :modules {:census {:exports {default census.core/census}}}
                      :js-options {:js-provider :import}
                      :compiler-options {:optimizations :advanced}}
#2022-09-2108:07Fredrik AnderssonDoes anybody know of a hiccup -> html build hook for static pages?#2022-09-2117:59Dustin GetzHow do I hook shadow watch (before and after compiliation) to run some code? And is there a document somewhere that I've missed that simply lists the config options?#2022-09-2121:35steveb8nhttps://shadow-cljs.github.io/docs/UsersGuide.html#compile-stages#2022-09-2203:09Drew VerleeGiven a shadow-cljs.edn with :deps set to true, and a deps.edn with an :aliases of :shadow-cljs with the :extra dep of shadow and the main opt set to ["-m" "shadow.cljs.devtools.cli"] i would expect running the command line script clj -M:shadow-cljs pom to produce a pom (or do anything) instead i get "Unknown action" which is also what i get if i replace "pom" with "help" or "info", meanwhile "watch app" seems to work.#2022-09-2203:10Drew Verleei wonder if my shadow version is somehow ancient...#2022-09-2203:15Drew Verleenope its fairly recent 2.19.4.#2022-09-2203:21Drew Verleei would also be fine creating a release build another way, maybe i should just use the clojure shadow library directly?#2022-09-2206:05thhellercan you explain your intent? pom is a task by the shadow-cljs cli command, which you do not use? however you can ask clj to generate a pom file for you, since it is in charge of generating the classpath? -Spom I believe?#2022-09-2206:05thhellerI don't get what creating a pom has to do with creating a release build though?#2022-09-2206:06thhellerhelp, info are all things provided by the shadow-cljs command, which runs in node and doesn't execute java for those#2022-09-2206:06thhellerrelease watch compile are all done by the clojure parts#2022-09-2206:15thhellernote that you can just continue using the shadow-cljs command? it'll just call clj for you. you only lose features by going with clj#2022-09-2215:20Drew Verlee@U05224H0W thanks thheller. I'm following the instructions as outlined here in the user guide. https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn > Example shadow-cljs.edn with :cljs alias >
{:deps {:aliases [:cljs]}
>  :builds ...}
> Example deps.edn >
{:paths [...]
>  :deps {...}
>  :aliases
>  {:cljs
>   {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}}}
> Running with clj directly. >
{:paths [...]
>  :deps {...}
>  :aliases
>  {:shadow-cljs
>   {:extra-deps {thheller/shadow-cljs {:mvn/version <latest>}}
>    :main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
> clj -A:shadow-cljs watch app
a pom has nothing to do with creating a release build, i didn't mean to imply it did. Build the following command fails: >
clj -A:shadow-cljs pom
And reports Unknown action As where >
clj -A:shadow-cljs watch app
Correctly watches the app. Similarly, >
clj -A:shadow-cljs release app
fails with "unknown action" just like pom, which is why i pointed out that more "actions" then the one i wanted to run were failing. The readme implies this should work. If i just use shadow-cljs i get a very different complaint about missing devtools:
shadow-cljs release app
shadow-cljs - config: /home/drewverlee/Centriq/centriq-web/frontend/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

Full report at:
/tmp/clojure-5691110849954872601.edn
My best guess this is because shadow doesn't know about binaryage/devtools because it's a hidden behind a deps.edn aliase as an extra dep. But that guess doesn't seem great because the path is shadow/cljs/devtools/cli and nothing about binaryage. My only other thought is that my package.json has shadow as a devDependency as well, though thats what i feel i have done in all my projects and i don't recall running into this.
#2022-09-2215:22Drew VerleeYea, if i add shadow-cljs as a dep (not behind an alias) to my deps.edn then i can run shadow-cljs release#2022-09-2215:24thhelleryou add :deps {:aliases [:cljs]} to shadow-cljs.edn#2022-09-2215:24thhellerand add the thheller/shadow-cljs dependency to your deps.edn :cljs alias (or :shadow-cljs, or whatever alias you want)#2022-09-2215:24thhelleryou do NOT add the main opts#2022-09-2215:25thhellerthose you only add if you do NOT use the shadow-cljs command#2022-09-2215:25thhellerif you do not use the shadow-cljs command I think you must use clj -M:shadow-cljs release app?#2022-09-2215:26thhellerpackage.json is not relevant in this stage#2022-09-2215:27thheller> My best guess this is because shadow doesn't know about binaryage/devtools because it's a hidden behind a deps.edn aliase as an extra dep.#2022-09-2215:27thhellerI don't follow#2022-09-2215:27thhellercreate one alias for CLJS and use that#2022-09-2215:27thhelleror is your intent really to run everything via clj and no longer use the shadow-cljs command#2022-09-2215:27thhellerthe setups are different. what do you want?#2022-09-2215:29Drew Verleei'm running some different combinations to see if i can answer my own question...#2022-09-2215:36Drew VerleeI understand now, the shadow-cljs.edn :deps :aliases are picked up when you run shadow-cljs at the command line, and so the deps.edn aliases by the same name as the one i gave shadow-cljs.edn shouldn't have a main-opt that calls out to shadow command line as well. That makes sense.#2022-09-2216:44Drew Verlee@U05224H0W For my own education, i wrote up a short explanation of how i understand the topic now that i have had a chance to review it. If you like, i can try to clean it up more and and it could be used in the docs, or not 🙂 The following is pulled from a markdown file, so the formatting is a tad off: # 3.2.2. integration with deps.edn and clj tool Shadow can pull dependencies from deps.edn and Shadow can be called from the clj tool. In the section below will break down both. ## Integration with deps.edn In order to tell Shadow that you want to use a deps.edn you have to add the :deps key to your shadow-cljs.edn. The :deps value is going to Shadow where to look for the theller/shadow-cljs dependency in your deps.edn. If you want to place that in your deps.edn :deps directly then set your shadow-cljs.edn :deps to true Which looks like this: shadow-cljs.edn
{:deps true}
deps.edn
{:deps {theller/shadow-cljs ...}}
Now when you run bash
shadow-cljs some-shadow-action
the command line tool will find theller/shadow-cljs in the deps.edn through the shadow-cljs.edn file. If you want to move the shadow depency under a deps.edn :aliases, then you will have to tell shadow about that aliase (or aliases) that you want to use when the shadow is invoked. You do this by changing the deps.edn :deps value to a list of keywords that shadow will use to look up in the deps.edn and use there extra-deps from. for example shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}} }
Here shadow finds theller/shadow-cljs through the :shadow-cljs keyword, but you can use any :keyword as long as it matches. ## Having the clj command line call through to Shadow If for some reason you want to use the clj command line tool to call out to Shadow, you will need to tell the clj command line how to do that by updating your deps.edn to have an alias with a :main-opts and a value of exactly ["--main" "shadow.cljs.devtools.cli"]. "--main" is a function that takes the string representation of the clojure namespace that has a -main function that you want to pass arguments from the command line to. A full example might look like this: shadow-cljs.edn
{:deps {:aliases [:shadow-cljs]} }
deps.edn
{:aliases {:shadow-cljs {:extra-deps {theller/shadow-cljs ...}
                         :main-opts ["--main" "shadow.cljs.devtools.cli"]}}
bash
clj -M:shadow-cljs pom
Of course, clj -M can pass through arguments to any namespace with a main function. Shadow isn't special in this regard.
#2022-09-2216:55thhellerclj -M:shadow-cljs pom this won't work so doesn't make for a good example in the last section#2022-09-2216:55thhellerotherwise seems accurate#2022-09-2216:55thheller> the command line tool will find theller/shadow-cljs in the deps.edn through the shadow-cljs.edn file.#2022-09-2216:56thhellerthis isn't entirely accurate. it won't find anything. the clj tool constructs the classpath with shadow-cljs in it, when the process it started it can then be loaded#2022-09-2217:44Drew Verlee> clj -M:shadow-cljs pom this won't work so doesn't make for a good example in the last section Oh you right (big surprise 🙂 ) Why does clj -M:shadow-cljs watch app work then? I guess the main function of shadow-cljs.devtools.cli doesn't take the same arguments as the command line then? as shadow-cljs pom would work right?#2022-09-2219:36thhellerno, this is not true for all command#2022-09-2219:36thhelleras I said yesterday. some commands are provided by the shadow-cljs node script and never execute any java to do that#2022-09-2219:37thhellerpom just generates a xml file, it doesn't need java for that#2022-09-2219:37thhellerall build related commands require clojure, so they launch java and are available via shadow.cljs.devtools.cli#2022-09-2215:17Logan PowellI'm back, with hopefully just one more question and I'll be out of your hair. Currently, Shadow is importing a dep (using :esm target) like this:
import * as esm_import$node_fetch from "node-fetch";
How can I get it to do
import esm_import$node_fetch from "node-fetch";
#2022-09-2215:18thheller(:require ["node-fetch$default" :as node-fetch]), see translation table provided here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-09-2215:21Logan PowellThank you! Sorry for not seeing that!#2022-09-2319:00Mario TrostHi there 👋 We set up a reverse proxy for development and I added an entry to my hostfile to develop on a "real", non-localhost URL and proxy /api/ path to a deployed server. Unfortunately hot-reloading ist not working and I noticed that the websocket connection to localhost:9630 is not established. Is there a way to enable it?#2022-09-2319:02Mario Trost(as an aside: while researching in the documentation I found the reverse-proxy ability of shadow itself 😄 still wondering if it's possible to have hot-reload with my initial setup)#2022-09-2319:16thhellerif you use a different server that doesn't use localhost then you might need to set https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2022-09-2319:16thhelleror :devtools {:use-document-host false}#2022-09-2319:17thhellersince it defaults to trying to connect to the host you loaded the page from#2022-09-2319:17thhellerthe browser console should tell you whats up?#2022-09-2319:17thhellerthe http server you use is not relevant to hot-reloading since it is all done over the websocket to 9630#2022-09-2319:18thhellerif that connect fails however there can be no hot-reload#2022-09-2319:18thhellerso a) you configure it where to connect to or b) have your proxy server also proxy the websocket connection#2022-09-2319:42Mario TrostThanks, :devtools {:use-document-host false} worked :thumbsup:#2022-09-2319:43Mario Trost> the browser console should tell you whats up? It didn't really tell me that much: But that's my first Clojure(-script) work, so that doesn't mean much 😄#2022-09-2319:44thhellerwell what I meant that it should tell you if it fails to connect, and what it was trying to connect to#2022-09-2320:47Mario TrostThat it didn't do :thinking_face:#2022-09-2402:48lilactownis there a way for me to add custom compile warnings if a var is used that is annotated with certain metadata?#2022-09-2402:48lilactownI want to add something like ^:deprecated, but it only warns on new usages#2022-09-2406:21thhellernot really no#2022-09-2612:12sheluchinI'm having some trouble requiring code. I'll put the details in the thread.#2022-09-2612:13sheluchinHere is the code I'm trying to translate:
import Prism from "prism-react-renderer/prism";

(typeof global !== "undefined" ? global : window).Prism = Prism;

require("prismjs/components/prism-clojure");
#2022-09-2612:14sheluchinI am trying to do it like this:
(ns ui-cards
  (:require
   [com.fulcrologic.fulcro.algorithms.react-interop :as interop]
   [com.fulcrologic.fulcro.dom :as dom]
   [nubank.workspaces.card-types.react :as ct.react]
   [nubank.workspaces.core :as ws]
   [nubank.workspaces.model :as wsm]
   ["prism-react-renderer" :default Highlight :refer [defaultProps]]
   ["prism-react-renderer/themes/github" :default _ :as theme]
   ["prism-react-renderer/prism" :as Prism]
   ["prismjs/components/prism-clojure" :as Clojure]))

(set! (. (if (exists? global)
           js/global
           js/window)
         -Prism) Prism))
#2022-09-2612:17sheluchinThe resulting error:
main.js:1426 ReferenceError: Prism is not defined
    at shadow$provide.module$node_modules$prismjs$components$prism_clojure (prism-clojure.js:3:1)
    at shadow.js.jsRequire (js.js:66:18)
    at shadow.js.require (js.js:113:20)
    at eval (ui_cards.js:5:68)
    at eval (<anonymous>)
    at goog.globalEval (main.js:472:11)
    at env.evalLoad (main.js:1534:12)
    at main.js:1889:12
#2022-09-2612:23sheluchinI can't use a require call - it gives an error stating that the require must be part of the ns form: ns* not supported (require, require-macros, import, import-macros, ... must be part of your ns form)#2022-09-2612:29sheluchinThe confusing thing is I can make it "work" by commenting out ["prismjs/components/prism-clojure" :as Clojure], building, and then uncommenting it and building again. It just doesn't survive a page refresh. Any tip for how to get this working? Please excuse me if I'm missing this in the docs.#2022-09-2613:43thhellerfirst of all you should question what this code is even supposed to be doing#2022-09-2613:44thhellerwhy is it using import AND require? usually you use either one of them, never both#2022-09-2613:44thhellerand why export to global? what shouldn't be necessary?#2022-09-2613:45thhellerand finally see the translation examples provided here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-09-2613:45sheluchinIt is from the documentation here https://github.com/FormidableLabs/prism-react-renderer#user-content-faq (adding a language)#2022-09-2613:48thhelleraha so its a garbage package. thats fun. ...#2022-09-2613:49sheluchinI don't really understand why it's exporting to global. Garbage package? lol#2022-09-2613:50thhellerso the "extra languages" just access a global Prism object#2022-09-2613:50thhellerhttps://unpkg.com/browse/prismjs@1.29.0/components/prism-clojure.js#2022-09-2613:50thhellerthat isn't how JS is done for like 15 years now#2022-09-2613:53thhellerif that is the only language you need I'd recommend just writing that part in pure CLJS#2022-09-2613:53thhellerinstead of mucking with the global nonsense#2022-09-2613:54sheluchinYou mean just translate the language definition file you linked to CLJS?#2022-09-2613:54thhelleryes#2022-09-2613:56sheluchinI don't have a very good grasp on interop. Writing the definition is trivial, but how would I apply it so that Prism uses it?#2022-09-2613:57thhellernot a clue but the prism-clojure.js files just assigs a property, so thats probably enough#2022-09-2613:58sheluchinAlright, I can try that. Strange that such a popular library is written in this way.#2022-09-2614:00thhellersad state of the JS world. lots of bad/half-maintained code#2022-09-2614:03sheluchinIndeed. The mess we're in :man-shrugging: Thanks for the advice, @U05224H0W 🙏#2022-09-2710:40wombawombaI'm trying to require a lib (xterm.js) that the Clojure compiler refuses to compile (similar to https://github.com/thheller/shadow-cljs/issues/971). If I include the built library as a script directly in my HTML, everything works. However, I'd like to load the library dynamically, and am using require.js for this. The library loads fine and require.js gives me a handle to it, but the CLJS compiler is giving me "Cannot infer target type in expression" when I try to call functions in the library (e.g. (js/require ["xterm"] #(.Terminal %))). What's the recommended/proper way to solve this? Do I need to manually write an externs file?#2022-09-2710:52thheller@wombawomba please include the actual error you get, otherwise I can't comment at all#2022-09-2710:53thhelleralso no clue what (js/require ["xterm"] #(.Terminal %)) this is supposed to be? ah I guess require.js#2022-09-2710:58wombawombayeah that's require.js#2022-09-2710:59thhellerI have used xterm in the past without issues, so what is the actual problem?#2022-09-2710:59wombawombathe literal error for the snippet I posted is Cannot infer target type in expression (. p1__240117# Terminal)#2022-09-2711:00thhellerthe not-require.js version#2022-09-2711:00thhellerthe above is an externs inference warning. see https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs#2022-09-2711:00wombawombayeah, on it#2022-09-2711:02wombawombaputting [xterm :refer [Terminal]] in my (:require ...) statement gives the following error (for xterm 5.0.0, which is the latest version):
Closure compilation failed with 1 errors
--- node_modules/xterm/lib/xterm.js:2
Illegal variable reference before declaration: e
#2022-09-2711:06thhellerhmm yeah they seem to have changed their bundle method#2022-09-2711:06wombawombaPerhaps this is because it's picking up the built and minified xterm.js at xterm/lib/xterm.js, and I should be requiring something else?#2022-09-2711:06thhellercan reproduce it locally#2022-09-2711:06thhellerno, there is only that version in the package#2022-09-2711:06thhellerapart from some .ts sources#2022-09-2711:07wombawombaright, okay#2022-09-2711:12wombawombaso anyway, do you have a recommended course of action here?#2022-09-2711:13wombawombaIs there a way to force cljs to make the .Terminal call verbatim without bothering with externs, or do I need to add an externs file?#2022-09-2711:16thhellerthats what externs inference is for. you just help it with a ^js tag#2022-09-2711:16thheller(js/require ["xterm"] #(.Terminal ^js %)) should be enough#2022-09-2711:17wombawombayeah that did the trick#2022-09-2711:17wombawombathanks!#2022-09-2711:18wombawombawait, crap, that gives me an error at runtime: Class constructors cannot be invoked without 'new'#2022-09-2711:22wombawombaHow do I combine new with this type hint/tag? (new Terminal. ^js %) gives me Use of undeclared Var my.ns/Terminal#2022-09-2711:29wombawombaalright, I have no idea why, but doing (let [ctor (.-Terminal ^js %)] (new ctor)) works 😅#2022-09-2711:30thhellermaybe elimanate the #() function to make this more understandable?#2022-09-2711:31wombawombayeah, I actually already moved the constructor call out of the require.js callback#2022-09-2711:31thheller(new Terminal. ^js %) is just invalid code and not related to ^js in any way 😛#2022-09-2711:31wombawombaright yeah, but what threw me off is that (new (.-Terminal ^js %)) also doesn't work#2022-09-2711:32wombawombafor whatever reason I had to bring the (.- Terminal ^js %) call out into a binding#2022-09-2713:25jpmonettasis there a way of printing the dependency tree for shadow-cljs.edn dependencies? (like with clj -Stree)#2022-09-2713:55thhellershadow-cljs info prints a basic info#2022-09-2713:55thhelleronly if you use shadow-cljs.edn to manage deps though. if you use lein or deps.edn use those commands#2022-09-2715:55jpmonettasoh nice, thanks @U05224H0W!#2022-09-2902:28jon rostranhow come https://shadow-cljs.github.io/docs/UsersGuide.html#target-npm-module has :output-dir entry as optional but in the latest shadow-cljs version if :output-dir is omitted it throws#2022-09-2902:28jon rostran
Invalid configuration
-- Spec failed --------------------

  {:target :npm-module, :entries [main], :build-id :app}

should contain key: :output-dir

| key         | spec                                          |
|=============+===============================================|
| :output-dir | shadow.build.targets.shared/non-empty-string? |
#2022-09-2905:20thhellerout of date docs I guess. it needs to know where to write the files so it is required#2022-09-2913:38sheluchinI would like to install some deps as local source so I can add some logging/debug statements. I know one way to do it is as described in https://shadow-cljs.github.io/docs/UsersGuide.html#_patching_libraries. Is it not also possible to install the libraries using deps.edn git coordinates and then edit the source in .gitlibs? When I try this, the changes don't seem to survive a page refresh.#2022-09-2914:58jon rostranwhat is the equivalent to export default in shadow ? i’d like to import Function from 'shadow-cljs/demo.foo from within JS#2022-09-2915:29thheller@alex.sheluchin .gitlibs are immutable and should not be edited. use :local/root instead.#2022-09-2915:30thheller@jon.rostran for ESM code you should use :target :esm? https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm#2022-09-3008:54andrzejsliwahttps://clojurians.slack.com/archives/C7YF1SBT3/p1664445640683959#2022-09-3014:39thhellersee https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-09-3014:41andrzejsliwaI did, but this is not explaining the interactions between reitit and reloading.#2022-09-3015:09thhellerit probably is. see the gotchas?#2022-09-3015:10thhellermost likely you are keeping some reitit state in your app db. ie. a render function, this function is not updated on hot-reload and as such you don't see any changes?#2022-09-3015:10thhellerif you want to share some code I can probably point you to it#2022-09-3015:10thhellerotherwise I'm just guessing#2022-09-3018:33andrzejsliwahere is my example:#2022-09-3018:33andrzejsliwahttps://github.com/andrzejsliwa/shadow-cljs-tailwind/blob/main/src/main/app/routes.cljs#2022-09-3018:34andrzejsliwano matter if I define match state as defonce or def#2022-09-3018:34andrzejsliwawhere I’m changing some style in “interactive” view, changes are not reloaded, until I refresh browser manually#2022-09-3018:36andrzejsliwafor example in this line https://github.com/andrzejsliwa/shadow-cljs-tailwind/blob/d516487b5c3b152fbef4e929a231b7d960e65c10/src/main/app/tailwind.cljs#L331#2022-09-3018:36andrzejsliwayou can change class of color#2022-09-3018:37andrzejsliwawhen I’m rendering interactive component as root, everything working like expected, but when router is involved it’s not refreshing#2022-09-3018:39andrzejsliwayou can also change the text in href or header#2022-09-3018:46andrzejsliwaok, I found it, the problem was that (router-start!) was in
(defn ^:export init
  []
  (router-start!)
  (start))
#2022-09-3018:46andrzejsliwawhen I move it to
(defn ^:dev/after-load start
  []
  (router-start!)
  (d/render
   [current-page]
   (.getElementById js/document "app")))
#2022-09-3018:46andrzejsliwathen it’s working#2022-09-3018:54andrzejsliwathx @U05224H0W for pushing me in a good direction.#2022-09-3019:04thhellerthat is precisely the mentioned "Holding Code references in State" gotcha#2022-09-3019:05thhelleryou are putting function into a map, those functions are not updated by hot-reload#2022-09-3019:05thhellerso you see old code, unless you re-create this map (which I assume the router-start! does#2022-09-3008:57andrzejsliwaI wonder if anyone here had a similar issue and knows how to force the update of react component rendered behind routing. (on changing file via shadow watch)#2022-10-0418:57barrellI’m using shadow.lazy/loadable to lazily load some modules. If I naviagte to the page localhost:4000/utils, it will properly load localhost:4000/js/routes.utils.js. If I navigate to localhost:4000/utils/example, it is failing to load because it’s looking for the file at localhost:4000/utils/js/routes.utils.js. I have asset path configured to /js - how do I configure the equivalent for lazily loaded modules?#2022-10-0418:58thhelleryou sure you haven't configured it to js? it should be using the :asset-path "/js" if actually set like that#2022-10-0418:59barrell#2022-10-0419:00thhellershould be fine#2022-10-0419:01thhellerhow are you using the loader?#2022-10-0419:02barrell
(defn component [loadable]
  (let [lazy (react/lazy 
               #(-> (lazy/load loadable)
                    (.then (partial to-hot-react-component loadable))))]
    (fn [& props]
      (react/createElement lazy #js {:props props}))))

(defn get-lazy [namespace]
  `(captain.util.lazy/component (shadow.lazy/loadable ~namespace))))
#2022-10-0419:03thhellerdo you manually touch something from the shadow.loader ns somewhere?#2022-10-0419:04barrellno - the only instance of loader in my codebase is :module-loader true in the config#2022-10-0419:05thhellerthen I don't know. the behavior you described points to :asset-path "js", "/js" shouldn't do this#2022-10-0419:06thhellermaybe you have a service worker? or some bad cache?#2022-10-0419:08barrellNo service workers on this project yet, I reset shadow-cljs and ran it in a different browser and it’s the same problem#2022-10-0419:09barrellDo you know which module builds the path from the module name? I’ll take a look but that could save some time hehe#2022-10-0419:11thhelleryou can just look at the generated source and look for shadow$modules#2022-10-0419:11thhellerfrom your main module#2022-10-0419:17barrellvery weird. In my build directory, there is the expected structure. My console is somehow showing a bunch of sources available under /utils :thinking_face:#2022-10-0419:22barrell
$ tree build

build
├── 1664911033746
│   ├── captain.css
│   └── js
│       ├── captain.docs.routes.about.js
│       ├── captain.docs.routes.about.me.js
│       ├── captain.docs.routes.index.js
│       ├── captain.docs.routes.utils.$util.js
│       ├── captain.docs.routes.utils.index.js
│       ├── captain.docs.routes.utils.js
│       ├── captain.js
│       ├── cljs-runtime
│       │   ├── applied_science.js_interop.impl.js
│       │   ├── applied_science.js_interop.impl.js.map
│       │   ├── applied_science.js_interop.js
│       │   ├── applied_science.js_interop.js.map
│       │   ├── captain.app.js
│       │   ├── captain.app.js.map
..................................
│       │   ├── shadow.util.js
│       │   └── shadow.util.js.map
│       ├── manifest.edn
│       ├── module-loader.edn
│       ├── module-loader.json
│       ├── quartermaster.js
│       └── shared.js
├── index.html
└── index.html.clj

3 directories, 859 files
#2022-10-0419:22barrelldoes that make any sense to you? haha#2022-10-0419:26barrellOh. I think I know what I may have done. The asset path might be being overrun somewhere in the versioning pipeline facepalm#2022-10-0419:28barrellFixed! Thanks for asserting it was from asset-path, I would have been chasing ghosts for hours 😂 Still no idea how the browser was loading those files though? :thinking_face: but not important, it’s working!#2022-10-0612:16HukkaHmh. Seems like shadow 2.19.9 (i.e. 2.19.8 still works) stopped redirecting to index.html when going to localhost:8000, as configured for the dev server, if proxy-url is also configured. Nothing jumps to my eyes from the changelog, but have to bisect the commits then.#2022-10-0612:23HukkaI suppose the bump to undertow could do it? But I can't even see version 0.3.0 at https://github.com/thheller/shadow-undertow#2022-10-0617:39thhellerit has never redirect anywhere?#2022-10-0617:40thheller:proxy-url always tries to load from proxies for files that don't exist?#2022-10-0619:50HukkaThe special case of checking for index.html when client is getting just the directory is still working, as long as proxy-url isn't defined and up to 2.19.8, even when it is#2022-10-0619:52thhellerah hmm, yeah thats probably this one https://github.com/thheller/shadow-undertow/commit/a64b4afa1ab39931b17742492f06480c38e5911f#2022-10-0619:52thheller(forgot to push the changes to the github repo)#2022-10-0619:54thhellerso :use-index-files true should work, :dev-http {3000 {:root "public" :use-index-files true :proxy-url ...}} that is#2022-10-0619:56HukkaHm, no difference with 2.19.9#2022-10-0613:38Chris McCormickHello, I am seeing an error when trying to consume https://ffmpegwasm.netlify.app/ in a front-end build:
Closure compilation failed with 4 errors
--- node_modules/@ffmpeg/ffmpeg/src/browser/defaultOptions.js:17
This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support.
--- node_modules/@ffmpeg/ffmpeg/src/browser/fetchFile.js:43
This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support.
--- node_modules/@ffmpeg/ffmpeg/src/browser/getCreateFFmpegCore.js:44
This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support.
--- node_modules/@ffmpeg/ffmpeg/src/browser/getCreateFFmpegCore.js:80
This code cannot be transpiled. import.meta. Use --chunk_output_type=ES_MODULES to allow passthrough support.
I tried tinkering with :output-feature-set but it doesn't seem to help.
#2022-10-0613:41Chris McCormickIs there a way to set the chunk_output_type flag on the Closure pass?#2022-10-0614:10Chris McCormickI have managed to get around this issue by using the pre-compiled dist artifact instead:
["@ffmpeg/ffmpeg/dist/ffmpeg.min" :refer [createFFmpeg fetchFile]]
#2022-10-0616:05thhellerthere is no setting that would influence this currently. the error message only refers to the google-closure-compiler npm package option, it is not an option in shadow-cljs#2022-10-0616:07Ben LiebermanI have this ["react-bootstrap/Card$default" :as card] in my require form and I see the modules being loaded in the console but I can't figure out how to use it correctly. When I call it like a function I get a use of undeclared var warning and nothing else#2022-10-0616:09thhellerwell you typically don't call a react component as a function?#2022-10-0616:09Ben LiebermanRight, but how does that translation to CLJS get made?#2022-10-0616:09thhellersee my answer here https://stackoverflow.com/a/72196457/8009006#2022-10-0616:35Ben LiebermanI tried this out and I see this logged in the console:
Card {$$typeof: Symbol(react.forward_ref), defaultProps: {…}, Img: {…}, Title: {…}, render: ƒ, …}$$typeof: Symbol(react.forward_ref)Body: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Footer: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Header: {$$typeof: Symbol(react.forward_ref), render: ƒ}Img: {$$typeof: Symbol(react.forward_ref), render: ƒ}ImgOverlay: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Link: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Subtitle: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Text: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}Title: {$$typeof: Symbol(react.forward_ref), defaultProps: undefined, render: ƒ}defaultProps: {body: false}render: ({bsPrefix,className,bg,text,border, body,children,as:Component="div",...props},ref)=> {…}displayName: (...)get displayName: ƒ ()arguments: nullcaller: nulllength: 0name: "get"prototype: {constructor: ƒ}[[FunctionLocation]]: react.development.js:1497[[Prototype]]: ƒ ()[[Scopes]]: Scopes[4]set displayName: ƒ (name)[[Prototype]]: Object
so it seems to be imported correctly but I still get those undefined var warnings on invocation.
#2022-10-0616:36thhellerthis is a react component, you do not call it#2022-10-0616:36thhellerwhat do you use? reagent/re-frame? how did you require it now?#2022-10-0616:38Ben LiebermanReagent. Should I use their create-react-class function here? I tried what the original SO thread showed, i.e.
[:div
[:> Card
[:> Card.Body]]]
etc, but I suspect that's also wrong
#2022-10-0616:38Ben Lieberman["react-bootstrap/Card" :as Card]#2022-10-0616:39thhellerthat should be fine#2022-10-0616:39thhellerwait no? what did you do for the log above?#2022-10-0616:40Ben Lieberman
(js/console.log "Card" Card)
#2022-10-0616:40thhellershould be fine then#2022-10-0616:09thhellermight be the same issue#2022-10-0704:20valeraukois it possible to "include" files at compile-time? i'd want to read my i18n dictionary YAML files into a tongue dictionary. is this possible?#2022-10-0705:31thheller@vale see https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-10-0706:15valeraukoawesome, thanks!#2022-10-0708:48Yab MasIs is save to assume there are no issues with https://shadow-cljs.github.io/docs/UsersGuide.html#infer-externs when there are no compiler warnings? For example in the following situation I'll get a compiler warning:
(defn some-interop-fn [obj]
  (.interopCall2 (.interopCall1 obj)))
If I typehint the obj the compiler warning disappears, does the compiler not need a typehint on the result of the first call?
#2022-10-0709:03thhellershadow-cljs "poisons" the return type to some extent, so its also assumed ^js#2022-10-0711:13delimberHi, all The question is about https://clojureverse.org/t/modern-js-with-cljs-class-and-template-literals/7450 macro. Is there a way to imitate a js behavior for empty constructor in the derived class? i.e. if there is an empty constructor then
constructor(...args){
super(...args)
}
will be generated.
#2022-10-0711:21delimberAt the moment macro throws on the missing constructor and I can't use
[this & args]
and can't apply a super macro clause, something like this
(constructor [this & args]
(apply super args))
#2022-10-0711:23delimberDon't know is it worth an issue 🙂 As it seems like not a 1st tier feature for shadow#2022-10-0717:03thhellerCLJS doesn't support the rest/spread JS operators, so this isn't currently possible to support no#2022-10-0717:04thhellerapply wouldn't work here since super is not a function#2022-10-0717:16thhellerbut given that JS doesn't really use variadic things very much. are you sure this isn't just a lazy way to write constructur(a,b,c) { super(a,b,c) }?#2022-10-0719:44delimberOn regard of vararg have took this from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor#description, but haven't notice large note right below the default constructor description about that there is no argument spreading. Same https://tc39.es/ecma262/multipage/ecmascript-language-functions-and-classes.html#sec-runtime-semantics-classdefinitionevaluation (point 14.a.iv). So, you are totally right here. Anyway, I can't write proper constructor with a macro without a knowledge of super class constructor args number, right?#2022-10-0719:52delimberThere is only one arg on super class in my case actually. So, just
(constructor [this arg]
  (super arg)) 
works like a charm.
#2022-10-0719:56delimberBTW, let me take this opportunity to give huge respect for this beast (shadow I mean)#2022-10-0713:31valerauko@thheller do you accept contributions to shadow-css?#2022-10-0717:03thhellerdepends on what it is I guess. generally yes, but best ask before sitting down to write a bunch of code 😛#2022-10-0717:22valeraukojust wanna improve the readme's instructions on how to run/watch/build#2022-10-0717:25thhellerchange how? I mean the first sentence is "All of this is subject to change.", this is not meant to be final in any way and is just an example#2022-10-0717:32valerauko• add an example of using that css start alongside shadow/watch build watches • add (binding [*out* (io/writer (System/out))]) around the prn calls because if it's run separately (with a shadow-cljs run for example) and it jacks in to an already-running server it loses its original stdout and crashes#2022-10-0717:34thhellerhmm? I never had a crash with this? and its running for days 😛#2022-10-0717:38valeraukoif you start shadow with yarn shadow-cljs watch app for example, then in a separate terminal you start the css watch with yarn shadow-cljs run dev.css/start, after which if you save a cljs file in a "bad" state (some typo, missing : in a css map or something) it'll try to prn to stdout but it doesn't have its own anymore resulting in a closed stream exception#2022-10-0717:38valeraukoit's not a problem obv if you start them all from the same repl#2022-10-0717:40thhellerhmm yeah well the intent with this is for a typical REPL driven workflow#2022-10-0717:41thhellerAdding an example of how to watch a build is fine#2022-10-0717:41thhellerI don't want the binding thing since that wouldn't work with my setup 😛#2022-10-0815:57pezWhat could I be doing wrong?
(require '[goog.object :as gobj]) => nil
gobj => Use of undeclared Var calva.read-config/gobj
Putting the require in a :require in the ns form gives the same result. I can use goog.object this way: (js/goog.object.set o k v), but I would prefer to use :require...
#2022-10-0817:05thheller@pez gobj is just a namespace binding? so you'd use gobj/get?#2022-10-0818:49pezYes, that's how I tried to use it, but got Cannot read properties of undefined (reading 'set').#2022-10-0818:54thhellerdunno the full context, so can't say much. (:require [goog.object :as gobj]) and (gobj/set x "thing" 1) definitely works#2022-10-0818:54thhellerbut goog.object is one of those new goog.module. so there are caveats to using it now. for example in code generated by macros#2022-10-0818:55pezThe longer story is that I wanted to make my own version of cljs.core/clj->js, so I copied it https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L11031-L11056 and also copied how goog.obj was required. Then when trying my local version of clj->js, I got that ^ error.#2022-10-0818:55thhelleryou can just use unchecked-get and unchecked-set from cljs.core instead. works the same#2022-10-0818:55thhellerthat is definitely fine to use#2022-10-0818:57pezunchecked-set works great. Thanks!#2022-10-0818:58pezI'm still confused about why what I did didn't work, though.#2022-10-0819:00thhellerI don't know what you did so no clue either 😛#2022-10-0819:02thhellerhttps://github.com/thheller/shadow-grove/blob/f65cd8cd3335301f4f8c6ead10a48ce83362413c/src/main/shadow/arborist/attributes.cljs#L170-L180#2022-10-0819:02thhellerI'm using it frequently in plenty of places, so I'm sure it works#2022-10-0819:06pezWhat I did: 1. Copied clj->js from core.cljs and pasted it in my file as my-clj->js. 2. Copied [goog.object :as gobject] from the ns form of core.cljs and pasted it in my ns from. 3. Evaluated (my-clj->js {:foo 1}) => BOOM Cannot read properties of undefined (reading 'set').#2022-10-0819:07thhelleryeah but evaluation order and build order and stuff matters here#2022-10-0819:07thhellerso the REPL just might have been in a weird state#2022-10-0819:07pezI actually tried to restart the REPL. Let me try that again...#2022-10-0819:17pezSame with a fresh REPL...#2022-10-0819:18thhellerhmm indeed. I can reproduce in the REPL, just not in a regular build#2022-10-0819:23pezI like unchecked-set so I am fine. And I'm not confused any longer. 😃 Even if it would have been better that I had done something weird rather than there being this REPL mystery.#2022-10-0819:23thhellerhttps://github.com/thheller/shadow-cljs/issues/1052#2022-10-0819:24thhellerI started using unchecked-set in my own code. no longer worth the trouble with goog.object since the weird goog.module changes#2022-10-0819:30pezAh, so you have already figured out what causes it. Nice mini-repro!
(gobj/set #js {} "x" 1)
I get a bit surprised that it evaluates to 1. Never thought about the return value of these before. I notice that also:
(set! (.-x #js {}) "y") => "y"
#2022-10-0819:35thhellerthats just how JS works foo["x"] = 1; returns 1#2022-10-0819:36pezThanks! Didn't know that either. Very good to know.#2022-10-0817:05thhellerusing the :as as a variable only works for npm JS requires, not for CLJS or closure namespaces#2022-10-0818:22peterdeeCan an error configuring logging cause shadow to not provide a JS runtime. I get ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...#2022-10-0818:23thhellerno, this is unrelated. usually caused by you having additional logging related dependency on the classpath#2022-10-0818:23peterdeeThanks!#2022-10-0818:24thheller(or setting up logging incorrectly in some way). if you start shadow-cljs embedded it'll inherit the JVM logging you configured#2022-10-0818:24thhellerabout runtime related things see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting#2022-10-0819:23oskarkvDon't know if this is Shadow-CLJS's fault, but I'm getting this error when trying to use garden.
app.css> (g/css)

Execution error (ReferenceError) at (<cljs repl>:1).
Can't find variable: garden
:repl/exception!
I'm using deps.edn where I have added garden, and my ns declaration looks like this:
(ns app.css
  (:require
   [garden.core :as g]
   [garden.stylesheet :as gs]
   [re-frame.core :as rf]))
I don't get any error when using re-frame, only with garden. Any ideas of what's wrong?
#2022-10-0819:26thhellernot enough context to comment. how did you require things? were there any warnings? errors during load?#2022-10-0819:26thhellerI've never used garden, so no clue what it does on load. might be doing something in macros. no clue.#2022-10-0819:28oskarkvThere was one warning:
------ WARNING - :redef --------------------------------------------------------
 Resource: <eval>:390:1
 abs already refers to: cljs.core/abs being replaced by: garden.color/abs
--------------------------------------------------------------------------------
As for how I required things, I required it with the ns macro, as I showed.
#2022-10-0819:30thhellerwell by default the REPL doesn't load any code when there are warnings#2022-10-0819:30thhellerso that would prevent it from loading anything#2022-10-0819:31oskarkvIs there a workaround? Or can't I use garden just because it had a warning?#2022-10-0819:31thhelleryou can set :devtools {:ignore-warnings true} in the build config#2022-10-0819:31oskarkvOK, thanks!#2022-10-0819:31thhellerI think you can update garden? I believe this has been fixed#2022-10-0819:32oskarkvThis looked like the latest version, according to Clojars and github.#2022-10-0819:33thhellerhttps://github.com/noprompt/garden/pull/195#2022-10-0819:33thhellerlooks fixed. maybe there was no release after that? dunno#2022-10-0819:33oskarkvThanks again!#2022-10-1007:27Ferdinand BeyerI feel I am missing something. On the command line, I can start the server and a watch worker using:
shadow-cljs watch my-build
This will stay in the foreground, I can cancel with ctrl+c. I can also start a server without watchers using:
shadow-cljs start
...and then start (background) watches using the UI at . After starting the server in the background, can I also start a watcher in the background, using the CLI?
#2022-10-1014:07valeraukoif you have a function in the user(.clj) ns like
(defn watch-foo
  {:shadow/requires-server true}
  []
  (shadow.cljs.devtools.api/watch :foo))
you can then run it either from the repl or with shadow-cljs run user/watch-foo
#2022-10-1014:17lilactownyou can also send processes to the background using good ol' terminal commands https://linuxhandbook.com/run-process-background/#2022-10-1014:18lilactownthe shadow-cljs start command is nice because you can stop a watch without stopping the server, meaning starting other watches is fast#2022-10-1015:35Ferdinand BeyerExactly, this is why I'd like to start the server independent from starting/stopping watches. Since I want to integrate that with other tooling, running watch in the background is not feasible I fear. @UAEH11THP - this looks interesting, will have a look#2022-10-1015:41lilactown@U922FGW59 I'm not sure what you mean "running watch in the background is not feasible I fear."#2022-10-1015:41Ferdinand BeyerI meant:
shadow-cljs watch my-build &
#2022-10-1015:42lilactownright, why can't that work?#2022-10-1015:42lilactownif you start the server first, your watch will connect to the server and when you stop the watch it will not stop the server#2022-10-1015:42Ferdinand BeyerFor example, if you want to run this from a babashka script#2022-10-1015:45lilactownI don't understand what you mean by "running in the background at the CLI" then#2022-10-1015:47Ferdinand BeyerWhen I start a server with shadow-cljs start, it starts in the background. I can then go to the UI and start a watch, without having to keep a terminal open for the watcher. I'd like to have the same behaviour at the CLI: To start/stop a watcher without binding the watch to my terminal#2022-10-1015:59lilactownidk i'm clearly missing something.#2022-10-1016:01lilactownif you're running shadow-cljs watch my-build directly from your terminal, then adding & at the end will start it in the background. if you're using babashka to run it, then you should be able to start the babashka process in the background. but i don't really understand what you mean at this point, so i'll let others try and help#2022-10-1016:05valeraukoeven if you & a process if you close the terminal doesn't it get killed? when you shadow-cljs run a function that :shadow/requires-server, the server will process it and your cli command (the shadow-cljs run) will exit almost immediately#2022-10-1016:16Ferdinand Beyer~Hm, weirdly this custom script solution does not work for me either. It compiles, but does not start a watcher?!~ n/m looked at the wrong place#2022-10-1020:01lilactownis there a way for me to ignore different warnings in different ns' when compiling with warnings-as-errors?#2022-10-1106:11thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#warnigs-as-errors ?#2022-10-1114:55lilactownThe docs show how to ignore certain ns, and what warnings to ignore#2022-10-1114:57lilactownBut there’s no way to specify “in this ns, only ignore this warning. In this other ns, only ignore this other warning”#2022-10-1114:57lilactownUnless i am misunderstanding the docs#2022-10-1116:23thhellerright, no thats not supported.#2022-10-1116:23thhellerwarnings are also supposed to be fixed, not ignored 😛#2022-10-1118:03lilactownMarking a fn as deprecated is a different level of warning than using an unbound var#2022-10-1118:03lilactownOr a lib shadowing a new var in clojure.core#2022-10-1114:15RyanWhen there are multiple tabs open for a locally served page, how does shadow-cljs pick which it attaches the REPL to?#2022-10-1116:23thhellerit'll pick the first connection. you can also manually select which one you talk to if desired.#2022-10-1118:49Sam Ritchiehey all… I have what is probably a javascript question, but wanted to ask it here since maybe there will be a clue as to why this is not working here. I am trying to use the https://github.com/jsxgraph/jsxgraph library from Clojurescript. When I include it in any file compiled by shadow with
(ns demo.jsxgraph
  (:require ["jsxgraph" :as jsx]))
I see this:
failed to resolve: ../build/core.deps.js from /Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js
{:require-from #object[java.io.File 0x6560d23a "/Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js"], :require "../build/core.deps.js"}
ExceptionInfo: failed to resolve: ../build/core.deps.js from /Users/sritchie/code/clj/sicmutils-clerk/node_modules/jsxgraph/distrib/jsxgraphcore.js
which makes sense, since the NPM package doesn’t ship its build directory. the last line of the https://raw.githubusercontent.com/jsxgraph/jsxgraph/master/distrib/jsxgraphsrc.js is
return require('../build/core.deps.js');
my question is… how can this ever work in Javascript land, since build is not available??
#2022-10-1118:50Sam RitchieI am prepared to fork jsxgraph and make my own build… I am thinking maybe there is some issue with the jsxgraph build where it is not properly bundling this file? Would love any clues.#2022-10-1118:58mhuebertWhat about downloading the file from a CDN and including it in the class path? Shadow can require it then using a relative or absolute path#2022-10-1118:59Sam Ritchiethis library seems to include jsxgraph just fine: https://github.com/sytabaresa/jsxgraph-react-js here: https://github.com/sytabaresa/jsxgraph-react-js/blob/master/src/index.js#L6 digging in now to how this build works…#2022-10-1118:59Sam Ritchie@U050RLRRQ it’s a good idea. I actually tried this and moved the build folder into node_modules'/jsxgraph just to see what would happen if I made the file available#2022-10-1119:00Sam Ritchiehttps://github.com/jsxgraph/jsxgraph/pull/456#issuecomment-1255555018#2022-10-1119:00Sam Ritchiewhen I do that, the problem is that that file is not a module, according to shadow#2022-10-1119:00Sam Ritchieie the build works but at runtime I see this error on the page#2022-10-1119:01Sam Ritchiehttps://github.com/jsxgraph/jsxgraph/blob/master/build/core.deps.js#2022-10-1119:01Sam Ritchiethis is the file it is trying to require#2022-10-1119:29mhuebertwhen I copy jsxgraphcore.js into the classpath and require it via
["/jsxgraphcore.js" :as JSX]
I get a different error (missing node-libs-browser), so I installed node-libs-browser, and then I get another error about canvas.
#2022-10-1119:30mhuebertit “works” if I put the script in the html page (global variable JXG present) but that’s the least desirable path..#2022-10-1119:24Sam Ritchie@thheller is there perhaps some way to mark a file as an AMD module? I see https://github.com/clojure/clojurescript/commit/87f39511a54d7b91ae86f581fda90f280f985816, but I also see some notes that :foreign-libs is not supported by shadow, is that right?#2022-10-1119:28thhellernot sure what you are asking. the code you linked is about consuming AMD modules, not producing them?#2022-10-1119:28thheller:node-library is UMD, which is AMD compatible as far as I remember#2022-10-1119:29thhellerthought AMD is dead?#2022-10-1119:32Sam Ritchieit might be, I wouldn’t be surprised if this project is using some old stuff#2022-10-1119:32Sam Ritchie@thheller it looks like jsxgraph is producing and shipping an AMD module which my shadow-cljs build will not consume#2022-10-1119:33Sam Ritchiethe Q at the top of this thread came from me hoping I could somehow consume it anyway by marking it as AMD#2022-10-1119:39Sam Ritchie@thheller maybe a tighter Q is: is it possible to compile an AMD library with shadow-cljs?#2022-10-1119:39thhellerno#2022-10-1119:40thhellerbest bet is probably going with https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-10-1119:40thhellerold libs such as this often rely on very old outdated hacky ways to include stuff#2022-10-1119:41thhelleror are never meant to actually be used in a 3rd party build system#2022-10-1119:42Sam Ritchiehaha, yes, I think the latter is right, the developers just didn’t think of this case. that said there are a couple of libraries that DO wrap jsxgraph https://github.com/sytabaresa/jsxgraph-react-js#2022-10-1119:42thhellermaybe even webpack doesn't support it#2022-10-1119:43Sam Ritchie@thheller it feels like this imposes a big cost on anyone else consuming the library (I am trying to make a cljs wrapper for it). so maybe a better bet is to find a way to convert the code to commonjs? there must be some post-processor? worst case I can go convert the library to ES6 modules…#2022-10-1119:56thhellerI'm not even sure what the problem with this lib is#2022-10-1119:56thhellerit compiles fine but throws a runtime error for me#2022-10-1119:57Sam Ritchiewhich version?#2022-10-1119:57thhellerno clue#2022-10-1119:57thhellerthe version npm install jsxgraph gets you#2022-10-1119:57thhellerlatest shadow-cljs#2022-10-1119:58Sam RitchieI was seeing a runtime error on versions before 1.1.0, then a build error on versions after that up until 1.1.0 I saw the same thing, but it looks like they removed the#2022-10-1119:59thheller1.4.6. I guess#2022-10-1119:59thhellerbut yeah, it appears to be using a rather old AMD mechanism that shadow-cljs doesn't support#2022-10-1120:01Sam Ritchieyou think there is any hope in trying to run the minified file through something like browserify?#2022-10-1120:02Sam Ritchieto try and turn it into a commonjs module?#2022-10-1120:02Sam Ritchieor something like that#2022-10-1120:03thhellerno clue to be honest. looking at the file I don't even recognize the mechanism they use. not something I have ever seen before. seems to be some hacked version of requirejs#2022-10-1120:04Sam RitchieI think it’s called “almond”#2022-10-1120:04Sam Ritchiehttps://github.com/requirejs/almond#2022-10-1120:07thhelleryeah dunno. not even close to any common npm module standards#2022-10-1120:12Sam Ritchieokay, I think I found a tool that I can use to convert this to es6. biting the bullet!#2022-10-1120:12Sam Ritchiethanks for your help#2022-10-1120:12Sam RitchieI remain traumatized every time I touch js build tooling#2022-10-1120:27Sam Ritchie@thheller I think I have it working (will need to tidy and confirm) via a nuclear option… I found a project that rewrites AMD files as ES6 modules, and I now am successfully compiling with no runtime errors. BOOM!#2022-10-1121:45Sam Ritchietotally rewriting everything as ES6 modules did the trick 🙂#2022-10-1207:49wombawombaIs there a way to get shadow-cljs to never give up on reconnecting the websocket? It's annoying to have to refresh the page every time I'm disconnected from the backend for more than a few minutes.#2022-10-1208:09thhellerthere is no such option no. how long are you talking?#2022-10-1209:19wombawombawell, anywhere between a few minutes to hours#2022-10-1209:20wombawombait happens when: • I'm running locally and my laptop goes to sleep. • I'm running against a remote host and my SSH session dies.#2022-10-1209:22wombawombaI see the point in theory (i.e. in production scenarios) of giving up on the websocket, but in practice it only happens during development, and I don't think people would mind if shadow-cljs kept retrying to connect forever when they're developing#2022-10-1209:35thhellerit does recover from sleep for me, regardless on how long the sleep was?#2022-10-1209:36thhellerI mean I guess it could try to connect forever#2022-10-1209:37wombawombayeah it doesn't always happen when sleeping#2022-10-1210:15mhuebertWhen requiring a js namespace with a string require (eg. ["complex.js" as Complex]), using the alias as a type hint (eg (defn angle [^Complex a] (.arg a))) doesn’t have the same effect as eg. ^js and breaks in advanced. Would it make sense to handle it like ^js, since (I believe) Complex would otherwise be treated as something from javascript-land?#2022-10-1211:16thhellerit should be ^js not Complex#2022-10-1211:16thhellerthere is very little logic in the type stuff and even less for :as since that usually means namespace alias#2022-10-1211:17mhuebertok thanks!#2022-10-1211:17thhellerI mean technically I guess it could be changed but I think that change would need to be in cljs.analyzer#2022-10-1213:33Sam RitchieI was hoping that ^Complex would work since it would have saved me the cljc fork inside the code#2022-10-1213:34Sam Ritchie@U05224H0W is there some way to have a warning emit for spots where inference fails? it does seem that SOME of the non-`^js` tagged spots are fine under advanced compilation#2022-10-1215:26thhellerI'm not aware of any "spots where inference fails", besides a couple places in core.async#2022-10-1215:27thhellerthings that are already part of known externs won't warn. many "common" things are already covered, eg. all DOM things like clientX and whatever#2022-10-1216:42Sam RitchieI guess I mean spots where not including the js hint causes a breakage #2022-10-1316:36Sam Ritchie
(defmethod g/magnitude [::complex] [a]
  #?(:clj (.abs ^Complex a)
     :cljs (.abs ^js a)))
so it sounds like this is what’s required, @U05224H0W, for a cljc file?
#2022-10-1316:36Sam Ritchieit’s “coincidence” that both js and jvm share the .abs name so I guess it was cheating to try and share them before 🙂#2022-10-1409:35thhellerI checked why the code didn't already handle this. turns out it was just because of a too specific assumption#2022-10-1409:36thhellerso (:require ["some-npm" :as x]) and ^x/Complex worked but not ^x. should be fine as of 2.20.5. should be fine with clojure style annotations assuming they can all be resolved the same#2022-10-1416:18Sam Ritchieokay, I took a pass and just made it totally clear by adding ^js all over#2022-10-1210:36wombawombaShould lazy/loadable be called at namespaces' top level, or is it fine to call it when it's used, e.g. in a Reagent component?#2022-10-1211:18thhellershould be called in a scope that remembers its state, best is top-level#2022-10-1211:19thhellerI mean its not the end of the world to always re-create it#2022-10-1211:20thhellerit is safe to pass around as props and stuff but it doesn't have equality semantics#2022-10-1211:30wombawombaalright, thanks#2022-10-1309:29borkdudeUpgrading shadow makes my advanced #C029PTWD3HR build fail: https://app.circleci.com/pipelines/github/babashka/nbb/927/workflows/6eea853f-8a23-42ef-a52f-1a7674332379/jobs/833 Are there any known issues around this?#2022-10-1309:31borkdudeIt seems to fail around here:
test/nbb/main_test.cljs
3:   ["module" :refer [createRequire]]
31:(reset! nbb/ctx {:require (createRequire (path/resolve "script.cljs"))})
#2022-10-1309:44borkdude2.19.4 still works. I'm going to bisect#2022-10-1309:45borkdude2.19.6 worked#2022-10-1309:47borkdude@U05224H0W 2.19.9 is the first version that stopped working for me https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#2199---2022-08-14#2022-10-1316:57thhelleruhm I can't quite tell how the nbb_tests.js is generated?#2022-10-1317:32borkdudeRunning this should be sufficient: https://github.com/babashka/nbb/blob/f876bef6bb8170cdf7b8ce47a1f861c0308abf53/bb.edn#L87
bb ci:test
#2022-10-1320:36thhellershould be fixed in 2.20.4#2022-10-1320:36borkdudethank you, going to try now#2022-10-1320:39borkdudeConfirmed, thanks again#2022-10-1311:19James PrattI wanted to get a clojurescript library that is set up to work with legacy figwheel and cljsjs to work with shadow-cljs but am running into an issue since the requires in the library are assuming the use of cljsjs:
(ns  aerial.hanami.core
  (:require
   [cljs.core.async
    :as async
    :refer (<! >! put! chan)
    :refer-macros [go go-loop]]

   [clojure.string :as cljstr]

   [com.rpl.specter :as sp]

   [aerial.hanasu.client :as cli]
   [aerial.hanasu.common :as com]

   [aerial.hanami.md2hiccup :as m2h]
   [aerial.hanami.common :as hc]
   [aerial.hanami.templates :as ht]

   ;; Vega & Vega-Lite
   [cljsjs.vega]
   [cljsjs.vega-lite]
   [cljsjs.vega-embed]
   [cljsjs.vega-tooltip] .....
I was wondering is there some recommended way to have the library require the code from the npm dependency instead if it is present? So the last few requires would change to:
[vega]
   [vega-lite]
   [vega-embed]
   [vega-tooltip]
I tried changing everything over to use cljsjs, because I presumed that cljsjs dependencies still work with shadow-cljs: https://github.com/jointprob/hanami-shadow-cljs/commit/ddf3bfe3aa99992ea8305f8a3d8100c2d89a74c0 But now get an error about react-dom being missing thought it is included as as cljsjs dependency: [:hanami] Build failure: The required namespace "react-dom" is not available, it was required by "reagent/dom.cljs".
#2022-10-1311:54James PrattIf I fetch the dependencies using both cljsjs and npm: https://github.com/jointprob/hanami-shadow-cljs/commit/c85482079cb596d803531773295f0f04fb7d8244 Then I get the error: react-dom.development.js:22840 Uncaught ReferenceError: vegaLite is not defined Which is getting called from here: https://github.com/jsa-aerial/hanami/blob/master/src/cljs/aerial/hanami/core.cljs#L379#2022-10-1320:07thhellershadow-cljs does not support legacy cljsjs dependencies#2022-10-1320:07thhellerthe migration path is described here https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2022-10-1320:08thhellerfor modern cljsjs libs this is not necessary since they also map to their npm counterparts properly#2022-10-1406:33Mario Trost👋 Does anyone know of or has implemented a Github Action diffing bundle sizes between branches using shadow-cljs build reports?#2022-10-1411:41valeraukoI'd be up to building that next week#2022-10-1413:46Mario TrostNice! I had an itch to build that for the last couple of days but so far only googled for possible solutions. One of the first things found was a well-documented example for nextjs: https://jeffchen.dev/posts/Measuring-Bundle-Sizes-With-Next-js-And-Github-Actions/ I'd try something similar, perhaps tomorrow, but only if the weather allows it. Do you have it firmly planned for next week?#2022-10-1408:11alekszelarkHi! If I use lein to manage dependencies and paths, is it possible to set a dedicated lein profile only for one specific build but not for others? I know that I can do :lein {:profile "+cljs"} , but this applies for all the builds.#2022-10-1408:28thhellerno, this is not supported and generally also not useful. why do you want that?#2022-10-1408:56alekszelarkI think it could be useful when you want to include some source paths in one case but not in another. What I wanted to do is to change project.clj default behaviour, but with a profile in global lein config.#2022-10-1408:57alekszelarkAnyway thanks. I’ll try to find another way to solve my problem.#2022-10-1409:08thheller@zelark it is fine to always keep everything on the classpath, files that aren't required aren't included. if your intent is to override certain namespaces there are better options to do that#2022-10-1409:08thhellerif you describe what you intend to do I can give you suggestions#2022-10-1411:24alekszelarkI have a project.clj that I cannot change. shadow-cljs depends on it. When I run shadow-cljs some code evaluation (it takes ~30 secs) happen, but it’s not relevant to a shadow-cljs build at all. So I’d like to override this behaviour with a separate profile which I described in ./lein/profiles.clj.#2022-10-1411:26alekszelarkInitially I thought that --config-merge can help, but it affects only a build config.#2022-10-1412:50thhellerhmm I don't get it? how is that specific to one build?#2022-10-1412:52thhellerI mean by all means do all that but why is this behavior different between builds?#2022-10-1412:52thhelleryou can just use multiple lein profiles and run shadow-cljs via lein directly#2022-10-1412:53thhellerlein with-profiles +foo run -m shadow.cljs.devtools.cli watch the-build#2022-10-1413:23alekszelarkActually this behaviour should be applied to all builds, but now I cannot change neither project.clj nor shadow-cljs.edn.#2022-10-1413:25alekszelarkrunning shadow-cljs via lein directly is what I need, I just didn’t realized that I could do that.#2022-10-1418:30Lone RangerIt's unclear to me in the manual where the :nrepl stuff goes. This does not seem to be correct:
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]
 :dependencies
 []
 :dev-http {8080 "public"}
 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn }}
   :devtools {:repl-init-ns 
              :repl-pprint true
              :nrepl {:port 9000
                      :middleware []
                      :init-ns }}}}}
Can anyone point out my mistake?
#2022-10-1418:32thhellertop level. its not build related#2022-10-1418:33Lone Rangergot it, thank you#2022-10-1418:42Lone Rangerwhhaaaat#2022-10-1418:44Lone Ranger#2022-10-1419:59jpmonettasAny ideas why I could be seeing TypeError: tick.core.goog$module$goog$object is undefined ? Shadow compiles without errors but when loading my file I see that error message and everything else after that fails#2022-10-1420:00jpmonettasthe project was working fine, I just moved it to a different box and started seeing that error :thinking_face:#2022-10-1420:00thhellerprobably related to this? https://clojurescript.org/news/2021-11-04-release#_google_closure_library_goog_module_global_access#2022-10-1420:01thhelleror in case you are running in the REPL maybe an older version than this https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#2203---2022-10-09#2022-10-1420:04jpmonettasI'm using the latest shadow-cljs#2022-10-1420:04jpmonettasmaybe a dependency doesn't work anymore with the new stuff :thinking_face:#2022-10-1420:05thhellerif the dependency is old then it probably doesn't use goog.object correctly (maybe has a macro emitting access, or tried global access?)#2022-10-1420:06jpmonettasmaybe, weird the stacktrace doesn't mention anything, so no idea what lib can be causing that#2022-10-1420:06thhellerwell it is this namespace tick.core#2022-10-1420:07jpmonettasoh, yeah, there is a tick library, first time I see it since it is not my project#2022-10-1420:15jpmonettasthat was it! damn breaking changes. Thanks @U05224H0W!#2022-10-1510:52sheluchinInstalling https://fomantic-ui.com/introduction/getting-started.html#installing-via-npm using NPM, it ends up with the pre-compiled css and js files inside node_modules/fomantic-ui/dist/. If I want to include them in my html, what is the right way to refer to their location?#2022-10-1810:27sheluchinI suppose I can just move the files to some location in my path like "resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.#2022-10-1813:26Lone RangerI would write a JavaScript file that imports and requires the compiled CSS and then include that in your code#2022-10-1813:54sheluchin@U3BALC2HH so I install with NPM and the compiled CSS+JS files end up in node_modules/.... My public HTML files do not have access to the files in node_modules (I think..?)... sorry, I'm confused, could you elaborate please?#2022-10-1814:13Lone Rangernope! Here's an example:
// <projectRoot>/src/js/index.js

import 'draft-js/dist/Draft.css';
(ns myproject.core
  (:require "/src/js/index.js"))
#2022-10-1814:13Lone Rangerso in your case it would probably be something like fomantic-ui/dist/something.css#2022-10-1814:14Lone Ranger(keep in mind this won't work well if you are trying to distribute the code as a library, but it would work if you're making an npm module or some kind of app with no downstream consumers)#2022-10-1913:01sheluchin@U3BALC2HH thank you for the example. I will try that out. Is there any advantage to doing this instead of just moving the dist files after installing?#2022-10-1511:47pezI just made a testing project where I only use the browser-repl and node-repl, so no builds. shadow-cljs.edn looks like so
{}
Starting this with
npx shadow-cljs browser-repl
works fine. But with
npx shadow-cljs node-repl
I get:
% npx shadow-cljs node-repl    
------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See 

------------------------------------------------------------------------------
shadow-cljs - config: /Users/pez/.config/joyride/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[2022-10-15 13:43:16.382 - WARNING] TCP Port 9630 in use.
[2022-10-15 13:43:16.385 - WARNING] TCP Port 9631 in use.
shadow-cljs - server version: 2.20.5 running at 
shadow-cljs - nREPL server started on port 57047
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
    throw e;
    ^

Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
    at global.SHADOW_IMPORT ([stdin]:63:44)
    at [stdin]:1535:1
    at [stdin]:1579:3
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
[2022-10-15 13:43:18.498 - INFO] :shadow.cljs.devtools.server.repl-impl/node-repl-exit - {:code 1}
SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
[stdin]:66
    throw e;
    ^
And a lot of those. Then a lot of:
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> SHADOW import error /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js
Failed to read: java.io.IOException: Input/output error
cljs.user=> [stdin]:66
    throw e;
    ^

Error: Cannot find module 'ws'
Require stack:
- /Users/pez/.config/joyride/[stdin]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at /Users/pez/.config/joyride/.shadow-cljs/builds/node-repl/dev/out/cljs-runtime/shadow.js.shim.module$ws.js:3:28
    at global.SHADOW_IMPORT ([stdin]:63:44)
    at [stdin]:1535:1
    at [stdin]:1579:3
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
cljs.user=> Failed to read: java.io.IOException: Input/output error
Am I missing some minimal config for this to work with node-repl?
#2022-10-1512:03pezAdding shadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version...#2022-10-1516:12thhellernpx otherwise runs a globally installed version. you need to project install, so it provides the ws dependency among others. thats why there is the WARNING: shadow-cljs not installed in project. warning#2022-10-1516:22pezThanks! I have for very long wondered about that warning. 😃 Never run into problems skipping it. Most often I have not skipped it, though, so maybe that has to do with it. It was the warning that got me to try to fix my problem with the install, though, so it did its work. Maybe add problems might ensue to the message for thick-heads like me.#2022-10-1512:03pezAdding shadow-cljs to my node project fixed this. Don't know if it was because npx otherwise runs some old version...#2022-10-1810:27sheluchinI suppose I can just move the files to some location in my path like "resources/public/fomantic-ui/", but if anyone knows of a better way to make these files accessible please let me know.#2022-10-1714:09Lone Ranger@thheller question if this blasphemy is possible -- I want to use some typescript source code in my clojurescript project. I see that it is possible to https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js ... 1. is it possible to use clojurescript from javascript and include that javscript into the project in a single compilation step, or are multiple compilation steps required? a. Will multiple copies of cljs.core be created, or just 1? 2. If it can be done in a single step, can I do the following: a. cljs.core -> javascript -> project cljs files -> other local javascript -> other local source files?#2022-10-1714:13Lone RangerMy usecase for this heresy: I'm trying to practice some so-called "Domain Oriented Design" where the business logic closely matches the common sense notions of the business rules. I'm trying to make it open for extension but closes for modification, so I want the code to be polymorphic and compile-time extensible. I can do this with defprotocol/defrecord but it's too slow and there's too much code duplication, so I'm dipping into typescript. However -- I want to use all the cljs functions. Then I want to use those datatypes in my clojurescript library code. Then I want to use the clojurescript library code in the javascript functions to make more sophisticated datatypes. Then I want to use THOSE more advanced datatypes in the clojurescript app code.#2022-10-1714:29Lone RangerMore detailed notes:
// baseData.ts

    get: () => any
}

interface ISettable<out T> {
    set(x: any): T;
}

export interface IGetSet<out T> extends ISettable<T>, IGettable {

}

type MapType = cljs.core.PeristentHashMap | cljs.core.PersistentArrayMap;

export class MyData implements IGetSet<MyData> {
    cljsData: MapType


    constructor(data: MapType) {
        this.cljsData = data;
    }

    get(): any {
        cljs.core.get(this.cljsData, cljs.keyword("data"))
    }

    set(x: any): MyData {
        let existingData = this.cljsData;
        let path = cljs.keyword("data");
        let newData = cljs.core.assoc(existingData, path, x);
        return new MyData(newData)
    }
}
(ns somens.core
  (:require ["./path/to/src/gen/baseData.js" :as my-data]))


(defn ^:export fancy-cljs-fn [my-data]
  (.set my-data 42))
// fancyData.ts
import {fancy_cljs_fn} from "???"; // help needed
import {IGetSet, MyData} from "./baseData";

class FancyData implements IGetSet<FancyData> {
    mydata: MyData;

    constructor(data: MyData) {
        this.mydata = fancy_cljs_fn(data);
    }

    get(): any {
        return this.mydata.get();
    }

    set(x: any): FancyData {
        let newData = this.mydata.set(x);
        return new FancyData(newData);
    }

}
(ns fancyns.core
  (:require ["./path/to/src/gen/fancyData.js" :as fancy]))

(defn ^:export super-fancy [fancy-data]
  "yay")
#2022-10-1714:32Alexis Schadwtf xD for requiring cljs in JS, there's the doc : https://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js import {fancy_cljs_fn} from "goog:somens.core" Did you already try it?#2022-10-1714:33Lone RangerOhhh ok I thought that "goog:cljs.core" was a hardcoded constant or something, didn't realize that was extensible#2022-10-1714:34Lone RangerOk there's no way this is possible in the same compiler pass.#2022-10-1714:34Lone RangerOr is it :thinking_face:#2022-10-1714:34Alexis SchadDon't know but I want to know 😅#2022-10-1714:37Alexis SchadThe JS file is not processed by shadow, it is used directly as it is, so I think it should work. With a parallel TS watcher of course.#2022-10-1714:40Lone Rangerthis will be wild#2022-10-1715:00Lone RangerI think it's gonna work but ran out of time#2022-10-1715:00Lone Rangerwill try again soon#2022-10-1716:31Lone Rangerdamn it actually works#2022-10-1716:31Lone RangerI can't even believe this works 😮#2022-10-1716:31Lone RangerI think this must be what Voldemort felt like when he got into the blood magic section of the library#2022-10-1720:28Alexis Schadnice, hope your new weird stack will fit your needs#2022-10-1720:36Lone RangerIt will I think as soon as I get hot reloading to work!#2022-10-1716:21Lone RangerIs there a way to hot reload userland javascript?#2022-10-1716:27Lone RangerOkay at the bottom of https://shadow-cljs.github.io/docs/UsersGuide.html#_javascript_dialects it mentions this:#2022-10-1716:27Lone Rangerbut I'm not observing this behavior#2022-10-1716:34roltare you sure your js files are in your source paths ? hot reload works for me#2022-10-1716:44Lone Rangerok, probably on my end then#2022-10-1716:51Lone Rangerdoes it watch subdirectories, too? so for instance if I have src/gen in :source-paths, will it watch src/gen/sub, or do I need to mention that explicitly?#2022-10-1717:51Lone RangerYeah if anyone has any more suggestions I'd be appreciative. The change is not being recompiled to js/cljs-runtime.
{:source-paths
 ["src/cljs"
  "src/gen"]
 :deps true
 :dev-http {8080 "public"}
 :nrepl    {:port       9000
            :middleware [cider.piggieback/wrap-cljs-repl]}
 :builds
 {:frontend
  {:target  :browser
   :modules {:main {:init-fn cljstable.core/init}}
   :devtools {:repl-init-ns cljstable.sidecar
              :repl-pprint  true}}}}
Here's the compilation results and relevant directory structure. Am I doing something wrong here? Invoked via cider with:
;;  Startup: /home/jay/.nvm/versions/node/v16.14.0/bin/npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d refactor-nrepl/refactor-nrepl:2.5.1 -d cider/cider-nrepl:0.26.0 server
;;
;; ClojureScript REPL type: shadow
;; ClojureScript REPL init form: (do (require '[shadow.cljs.devtools.api :as shadow]) (shadow/watch :frontend) (shadow/nrepl-select :frontend))
#2022-10-1717:52Lone RangerEven when I delete the js/cljs-runtime/module$cljstable$baseData.js, it gets rebuild with the unchanged code#2022-10-1722:13roltthis makes no sense, unless you have a second js source file with the old code. Or could it have cached the old result somehow ? I don't see why#2022-10-1722:30Lone Rangeryeah, ripping my hair out about it#2022-10-1722:30Lone Rangerwill try to start with a fresh project 😞#2022-10-1722:48Lone Rangeruuugh yeah with a fresh project it works. there's some garbage artifacts somewhere. good call @U02F0C62TC1#2022-10-1723:16vemvtangential, but your cider-nrepl (and most notably refactor-nrepl) are outdated :)#2022-10-1723:23Lone RangerYeah not sure how to fix that when doing cider-connect-cljs#2022-10-1723:23Lone RangerOk I FINALLY figured out what it was... sort of#2022-10-1723:25Lone Rangerworking:#2022-10-1723:26Lone Rangernot working:#2022-10-1723:26Lone Rangerso it seems that I need to reference at least one of the js file in the :init-fn namespace in order for shadow-cljs to recognize a recompile#2022-10-1723:28vemv> Yeah not sure how to fix that when doing cider-connect-cljs You'd have to have a look at whatever is your nrepl server (maybe some webapp?)#2022-10-1723:31Lone Rangeryarn shadow-cljs watch frontend then whatever cider does when connecting#2022-10-1723:34Lone Rangeryeah, confirmed, there needs to be some kind of reference to the javascript file in the :init-fn namespace in order to recompile... phew... thank god... can move on with my life now...#2022-10-1723:45vemvtaking a quick look at the docs, looks like shadow-cljs picks up whatever cider-nrepl version is defined in either your project.clj or deps.edn. The docs also reference a ~/.shadow-cljs/config.edn file, although it looks like it's not much advised#2022-10-1808:22thheller@U3BALC2HH as a general rule: shadow-cljs only compiles files that are actually required in a build. so :init-fn is following all :require in the namespaces (or import in JS files) and compiles those. a file that is not required is not compiled, as you learned 😉#2022-10-1808:23thhelleralso when using :deps true the :source-paths config in shadow-cljs.edn has no effect. you should be warned about that on startup, but depending on how you start things that may not be visible (eg. emacs hiding it in some buffer)#2022-10-1808:23thheller:middleware [cider.piggieback/wrap-cljs-repl] this you don't need at all#2022-10-1808:25thhelleras a general warning the JS support is not widely used and can cause issues with externs in release builds. since there is no externs inference those might be hard to debug later#2022-10-1813:15Lone RangerMakes a ton of sense when you put it like that. There were so many moving parts with that typescript debauchery that I got lost in the sauce#2022-10-2619:47Lone RangerOk I'm assuming the answer is "because of idiots like me" but I'm really confused why this is not part of standard clojurescript: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2022-10-2620:06thhellerdunno, nobody ever attempted to get it there?#2022-10-2619:47Lone RangerOk I'm assuming the answer is "because of idiots like me" but I'm really confused why this is not part of standard clojurescript: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2022-10-1815:10Lone RangerHey @thheller, hat's off to some solid engineering 🎩. I seriously doubt you had in mind this insane usecase but it works flawlessly.#2022-10-1816:25thhellerwell the JS interop was the plan. Just TS wasn't part of my plans, but I guess anything that compiles to JS works#2022-10-1907:26mkvlrI'm running into ExceptionInfo: no goog/base.js with target :graaljs , full error in 🧵#2022-10-1907:26mkvlr
no goog/base.js
{}
ExceptionInfo: no goog/base.js
	shadow.build.output/closure-defines-and-base (output.clj:58)
	shadow.build.output/closure-defines-and-base (output.clj:53)
	shadow.build.targets.graaljs/flush-dev (graaljs.clj:127)
	shadow.build.targets.graaljs/flush-dev (graaljs.clj:111)
	shadow.build.targets.graaljs/process (graaljs.clj:168)
	shadow.build.targets.graaljs/process (graaljs.clj:160)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--26795 (build.clj:161)
	shadow.build/process-stage (build.clj:158)
	shadow.build/process-stage (build.clj:150)
	shadow.build/flush (build.clj:494)
	shadow.build/flush (build.clj:488)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:364)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:563)
	shadow.cljs.devtools.server.worker.impl/do-config-watch (impl.clj:556)
	shadow.cljs.devtools.server.util/server-thread/fn--28186/fn--28187/fn--28195 (util.clj:269)
	shadow.cljs.devtools.server.util/server-thread/fn--28186/fn--28187 (util.clj:268)
	shadow.cljs.devtools.server.util/server-thread/fn--28186 (util.clj:241)
	java.lang.Thread.run (Thread.java:833)
#2022-10-1907:26mkvlrlet me know if you want an issue or a minimal repro#2022-10-1907:28thhellerin what context? just a regular watch?#2022-10-1907:33thhellerany custom build-hooks by chance? IIRC this could happen if a build hook doesn't return the proper build state?#2022-10-1907:34mkvlryes regular watch, I do have a build hook, let me see…#2022-10-1907:35mkvlractually, no, I had one but dropped it a while back#2022-10-1907:36thhellerdunno what else then. this is fairly standard code touched by multiple targets (and working fine for me locally)#2022-10-1907:37mkvlranything else look wrong in the config?
{:deps {:aliases [:sci]}
 :dev-http {7778 {:roots ["public" "classpath:public"]}}
 :nrepl false
 :builds {:browser {:target :graaljs
                    :output-to "public/js/viewer.js"
                    :output-dir "public/js"
                    :build-options {:ns-aliases {nextjournal.devcards nextjournal.devcards-noop}}
                    :modules {:viewer {:entries [nextjournal.clerk.sci-viewer
                                                 nextjournal.clerk.static-app]}}

                    :dev {:compiler-options {:optimizations :simple}}
                    :release {:output-dir "build/"
                              :compiler-options {:source-map true}}

                    :js-options {:output-feature-set :es8}}}}
#2022-10-1907:37thhellerseems fine#2022-10-1907:38thheller:dev {:compiler-options {:optimizations :simple}} does absolutely nothing since dev never does any optimizations at all#2022-10-1907:38thhellerbut also won't affect this issue in any way#2022-10-1907:38mkvlrah yeah, just added this, I meant release 🙃#2022-10-1907:38thhellersince optimizations are not applied in dev regardless of what you set, you can just put it in normally#2022-10-1907:39thhellerso just :compiler-options {:optimizations :simple} without nesting in :dev/`:release`#2022-10-1907:40thhellernot really sure what could cause your issue besides a bad build hook#2022-10-1907:40thhellerwhich shadow-cljs version? haven't really touched any of this in years though#2022-10-1907:40mkvlr2.16.7#2022-10-1907:40mkvlrlet me try the very latest#2022-10-1907:41thhelleruhm hang on#2022-10-1907:41thheller:target :graaljs didn't support :modules?#2022-10-1907:41thhellerdidn't it just have :entries [...]?#2022-10-1907:42mkvlrtrying…#2022-10-1907:42mkvlrYES, thank you!#2022-10-1907:44mkvlrtiny thing I noticed, should :graaljs be added to this list?
Target ":node" for build :browser was not found. The built-in targets are:
  - :browser
  - :browser-test
  - :node-script
  - :node-library
  - :npm-module
  - :karma
  - :bootstrap
#2022-10-1907:47thhellerwell I don't know of anyone using it besides you 😛#2022-10-1907:47mkvlrhehe#2022-10-1907:47thhellernever made it an official target since its somewhat sketchy 😉#2022-10-1907:47thhellerIMHO graal isn't a viable JS runtime at this time#2022-10-1907:48thhellerwell viable but rather limited#2022-10-1908:01mkvlrhow so? Think its quite powerful with the polyglot stuff#2022-10-1908:02thhellerbut the data transfer is so limited (eg. no passing a CLJ map to CLJS or back)#2022-10-1908:02thhellerso might as well just use a regular remote RPC mechanism and launch a node process#2022-10-1908:03mkvlrthings can access the same memory, so pretty sure passing a map can be implemented if you'd like to avoid going through json#2022-10-1908:03thhelleryou really can't, since CLJS calls entirely different functions on maps than CLJ#2022-10-1908:04mkvlrcan't you implement the map interfaces like ILookup etc on both sides?#2022-10-1908:05thhellerthen you end up with "proxies" and not real maps. at which point it would be better to serialize transit back/forth to get actual real maps#2022-10-1908:05mkvlrthese are indistinguishable from real maps#2022-10-1908:06mkvlrand if one performs better than the other depends on if you'll need all data in the map or just parts#2022-10-1908:06thhellernot really, can't assoc for example#2022-10-1908:07thhelleralso last time I checked graaljs was horribly slow compared to node#2022-10-1908:07thhellerso even if you did all that the node solution with serialization is faster#2022-10-1908:07mkvlrafter jit warmup the difference to node becomes less#2022-10-1908:08mkvlrsame ballpark last time we checked#2022-10-1908:09thhellertrue but even the startup time is enough for me to now want to use it 😛#2022-10-1911:19sirwobinI'm creating a node-library target with two build targets, one for app and one for test. Test target has :autorun true set and has worked well when I execute npx shadow-cljs compile test the tests run fine. Some new code I'm testing relies heavily on promises and I'm using https://github.com/funcool/promesa in my library and test code. Test assertions inside a promesa.core/let aren't run. I tried moving the deftest inside a promesa.core/let but that hasn't worked either and the test count went down, leading me to believe that the test runner has completely lost sight of the suite. Have I missed something or should tests with promises be conducted in a special way?#2022-10-1911:29sirwobinIn the shadow-cljs user guide promises are only mentioned twice. Nothing in connection with testing.#2022-10-1911:50thhellerdo you use clojure.test/async correctly? async tests need to be marked as such. otherwise the runner won't know about them and won't wait for their completion#2022-10-1911:51sirwobinah, pretty sure I'm not since I haven't met clojure.test/async. Going to investigate now.#2022-10-1912:06sirwobinMade the necessary changes and my assertions are running. Thanks for the pointer! 🙂#2022-10-1920:31Lone RangerTwo questions about module splitting / dynamic loading: 1. Is this sort of the intended usage for shadow.loader?
(ns example.core
  (:require [shadow.loader :as loader]))

(defn load-ui! []
  (-> (loader/load "ui")
      (.then #(example.other/mount-root))))

(defn ^:export ^:dev/after-load init []
  (load-ui!))
where I'm using example.other/mount-root as it I had :required it at the top level? It seems to work, just making sure that's the intention. (and if so -- any editor sympathetic tips for autocomplete, etc?) 2. I'm trying to figure out what the hell an ESM environment is, e.g., https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm, so that I can use this sweet trick: https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import. But when I do
(shadow.esm/dynamic-import anything)
I get shadow_esm_import is not defined
#2022-10-1920:32thheller1) no this is not the intended use case. loading a module directly on startup is worse than having the code part of the "base" module directly#2022-10-1920:35Lone Rangeryeah I get that. I meant syntactically/mechanically -- once the .then in the promise triggers, the namespace is now available to be used as if it were :required? I agree it's not the smartest way to split code.#2022-10-1920:36thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2022-10-1920:37thhellerhttps://clojureverse.org/t/shadow-lazy-convenience-wrapper-for-shadow-loader-cljs-loader/3841#2022-10-1920:37thhellermakes things a little more usable#2022-10-1920:38thhelleralso covers how to use stuff after its loaded#2022-10-1920:38thheller#(example.other/mount-root) technically works but not great#2022-10-1920:39Lone RangerInteresting. You're not using shadow.loader at all in that example#2022-10-1920:40thhellerbecause its API is annoying to use and just a direct mirror of cljs.loader for compatibility reasons#2022-10-1920:41Lone RangerI thought it was pretty good!!#2022-10-1920:32thheller2) ESM is ecmascript modules, a modern variant of JS. shadow.esm only works in :target :esm builds, not in :target :browser#2022-10-1920:35thhellerhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#2022-10-1920:48Lone RangerOkay #3: When splitting code across modules, any insight into how state is shared? For instance, let's imagine
(ns example.db 
   (:require [reagent.core :as reagent]))
(defonce app-db (reagent/atom {:data 0}))
(ns example.a 
  (:require shadow.loader))

(-> (shadow.loader/load "db") (.then #(swap! example.db/app-db update :data inc)))
(ns example.b 
  (:require shadow.loader))

(-> (shadow.loader/load "db") (.then #(swap! example.db/app-db update :data inc)))
(ns example.ui
  (:require [example.db :as db]
            reagent.ratom))

(defn show-me []
  (let [number (reagent.ratom/make-reaction #(get @db/app-db :data))]
     (fn [] 
       [:div (str "Your number is: " @number)])))
I'm trying to imagine if show-me, when rendered, would show 0, 1, or 2 as the number
#2022-10-1920:49Lone Rangerassuming that a and b were loaded and run#2022-10-1920:50thhellerdb would not be its own module, so a+b would directly depend on it#2022-10-1920:50thhellerand somewhere you'd trigger the load of a/b which would then increment the number#2022-10-1920:51Lone RangerOk. So if I'm not mistaken that implies that that modules do not share state, and that state would need to be communicated through modules via some other method, almost as if there were independent workers#2022-10-1920:51thhellerno?#2022-10-1920:52thhellereverything runs in the same "scope". so they share all memory and are NOT independent such as workers#2022-10-1920:53thhellerin your example the example.db would be part of the base module#2022-10-1920:53thhellera/b would be independent modules, loaded on demand when needed#2022-10-1920:54thheller
(ns example.a
  (:require
    [example.db :as db]))

(swap! db/app-db update :data inc)
#2022-10-1920:54thhelleror whatever#2022-10-1920:54thhellerand something would load this via loader or shadow.lazy#2022-10-1920:56Lone RangerOk. I guess I'm trying to figure out a pattern for making things such as a reagent/atom app-db and possible derived reagent.ratom/make-reactions separate from things like the UI and application logic. And I'm struggling to understand how, for instance, if the DB, the make-reactions, the UI, and the domain logic were all in separate modules, how could an on-click on one of the UI components update the app-db state if it were in a separate module -- and then how would the make-reactions pick up the reactive changes from the app-db, and then how would that get communicated back to the UI components. Maybe tl;dr I'm trying to figure out what sort of things MUST be directly coupled and which things can be indirect.#2022-10-1920:57thhellerI really cannot explain or add to what I linked in https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2022-10-2011:29kennytiltonWow, that is a real eye-opener. I am always late to the party, in this case thinking only about massive CPUs and GPUs running Web browsers vs mobile. When mobile is taking over the world! Plz help a dummy: is this another argument for the Flutter/Dart platform, because it eschews JS? Or should those apps likewise sweat over chopping up functionality so it loads JIT? :thinking_face:#2022-10-2017:37thhellerapps don't really have the issue of trying to keep code size small, so its entirely different area#2022-10-1920:57Lone RangerHaha ok my bad, I'll just go off of that#2022-10-1920:57Lone RangerSorry for all the q's, just really excited about all the new possibilities#2022-10-1920:57Lone RangerI've been writing massive monolithic apps forever#2022-10-1920:57thhellerthe reagent atom parts do not change at all and won't be aware of module loading in any way#2022-10-1920:58thhellerthe only part that changes is that something triggers the lazy load of some code on click or whatever#2022-10-1920:59thhellerthere is only ONE app-db in the end, not one per module or whatever#2022-10-1920:59Lone Rangercool, yeah that makes sense (and keeps things easy)#2022-10-1921:01thhellerhttps://github.com/thheller/code-splitting-clojurescript/blob/master/src/main/demo/env.cljs#L4#2022-10-1921:01thhellerin the example code that would be your app-db#2022-10-1921:05Lone RangerOh nice!!#2022-10-1922:05jplazaHi everyone! I’m getting this error trying to use heroicons v2
Dependency: @heroicons/react/24/outline not provided by external JS. Do you maybe need a recompile?
Any ideas?
#2022-10-1922:06thhellerlooks like you are using :js-provider :external. did you recompile the :external-index file with whatever tool you use? (webpack?)#2022-10-1922:06thhellerand reloaded the page after doing so? that content is not hot-loaded in any way#2022-10-1922:07Fredrik Anderssondid you add the dependency to package.json? and installed it..#2022-10-1922:10jplazaThanks a lot for the help @thheller I’ve been banging my head with this for at least 45 minutes 😅 I didn’t setup this project and I’m not that familiar with shadow yet#2022-10-2013:44rschmuklerI am working with a react application and am noticing an interesting bug w/ shadow + uix (v1) and live-reload with a :after-load a/render in my build config. If I have
;; a.cljs
(ns a
  (:require [b])

(defn app []
  [b/render])

(defn render []
  (uix.dom/render [app] (js/document.getElementById "app")))

;; b.cljs

(ns b)

(defn render []
  [:p "Hello world"])
Everything works fine (ie. it will update if I modify b/render and save the file If I have:
;; a.cljs
(ns a
  (:require [b]))

(defn app []
  [b/render])

(defn render []
  (uix.dom/render [app] (js/document.getElementById "app")))

;; b.cljs

(ns b
  (:require [c]))

(defn render []
  [c/render])

;; c.cljs

(ns c)

(defn render []
  [:p "Hello world"])
It will not reload if I modify c/render until I also re-save b.cljs. If I add c as a require to a then it will work properly. I suspect it has to do with caching intermediates, but I would expect this to work… Is this expected?
#2022-10-2013:56Lone RangerAre you sure c isn’t reloading? Throw in some printlns to rule out that this isn’t a dataflow issue. #2022-10-2013:57Lone RangerMeaning, c/render doesn’t take any arguments here and there is no internal hooks so it has no reason to know to rerender (even if the code has changed and reloaded)#2022-10-2013:57Lone RangerSame thing with b/render #2022-10-2014:01rschmuklerSo adding printlns confirms that the files are reloaded correctly on save (ie. modifying c.cljs will cause c and b to be reloaded#2022-10-2014:01rschmuklerand it also confirms that the render functions are not fired#2022-10-2014:02rschmuklerBut, when requiring c from a then the render function is fired… Which is what I am having trouble understanding#2022-10-2014:02rschmuklerie. I could understand it one way or the other, but why does re-requiring c from a cause it to work?#2022-10-2015:18Lone Rangerbeen there, partner haha#2022-10-2015:19Lone RangerThe order of requires is probably important there too.
(ns a
  (:require b c))
is probably not going to be the same as
(ns a 
  (:require c b))
#2022-10-2015:20Lone RangerI'm guessing that c/render needs to be redefined first, then b/render, then a/render for hot reload path to function correctly#2022-10-2015:20Lone Rangerdue to potential for eager binding in scope capture#2022-10-2015:29roltdo you by any chance use react 18 ? i remember seeing an issue on live reload with 3 namespaces#2022-10-2015:46rolthttps://github.com/reagent-project/reagent/issues/579#2022-10-2016:00rschmuklerI’m actually using react 16 I believe#2022-10-2017:33thhelleras far as I can tell this is all working as intented#2022-10-2017:33thhellersee the recompile logic & gotchas described here https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-10-2018:00Lone RangerAgreed, I think this is more of a reactive coding / framework nuance issue and shadow is working as expected #2022-10-2112:54rschmuklerYeah I think it has to do with react memoization inside uix v1#2022-10-2112:55rschmuklerThe dummy prop is a cute trick though, hadn’t thought of that.#2022-10-2114:37Lone RangerI've been called worse 😉#2022-10-2016:22shaunlebronI noticed that in dev builds, source files and source maps (in a base64 url) are embedded in an eval statement. I’m suspecting that react-native doesn’t support source maps on eval’d code. Is there a workaround for this?#2022-10-2017:34thhellersince it doesn't support source maps at all there really isn't anything to do#2022-10-2017:38shaunlebronit looks like react native supports source maps yeah? https://reactnative.dev/docs/next/sourcemaps#2022-10-2017:38thhelleryes, for the sources it processes itself#2022-10-2017:38thhellerbut not input source maps#2022-10-2017:39shaunlebroninput source maps are an issue with Metro that I’ve been looking at for a couple weeks now yeah#2022-10-2017:40thhellerthe eval js maps are only emitted so source maps at least work when using the run in chrome thing#2022-10-2017:40shaunlebronoh, so these “embedded” source maps produced by shadow dev builds never have to be processed as input source maps if they’re evaluated at runtime right?#2022-10-2017:40thhellernot sure thats even still a thing though. been a couple of years since I looked at react native stuff#2022-10-2017:40thhellerthey aren't meant to be processed by metro no#2022-10-2017:42shaunlebroni guess the important question here is if shadow can be configured to create a dev build without the embedded source maps#2022-10-2017:42thhelleryou can use :target :npm-module for that#2022-10-2017:42thhellerthat loads just fine in react-native IIRC, may require some boilerplate though#2022-10-2017:43thhellerbut that target does no eval and has regular source maps#2022-10-2017:45shaunlebronhmm okay, i'm surprised no one else has asked for this. I’m pretty sure the embedded source maps are responsible for nonsensical stack traces inside Expo: https://docs.expo.dev/get-started/errors/#redbox-errors-and-stack-traces#2022-10-2017:45thhellerbut IIRC it had the issue that metro will try to process everything. and it used to take a lllooooooooooong time to process cljs.core#2022-10-2017:45thhellerI spent a lot of time trying to get source maps to work#2022-10-2017:46thhellerand it just wasn't possible back then#2022-10-2017:46thhellerI doubt much has changed but haven't checked in a long time#2022-10-2017:46thhellerif you get it to work with :target :npm-module I'll happily change :target :react-native#2022-10-2017:46shaunlebronmetro issue #104 has been open for five years, yeah I saw your post on it there all those years ago, I took a stab at it, still trying#2022-10-2017:47thhellerbut there is no option to turn of the eval mode for :react-native. it is there for good reasons#2022-10-2017:48shaunlebronim new to react-native which is part of the problem here, but what are the reasons for the eval? was it specifically for testing react-native somehow in chrome?#2022-10-2017:48thhellerspeed is biggest reason#2022-10-2017:48thhellerif you expose sources to metro it'll process all of them#2022-10-2017:49thhellerand takes like 30sec or so for cljs.core alone, so things just get annoyingly slow#2022-10-2017:49shaunlebronoooh, that explains why I have not seen a speed issue#2022-10-2017:49thheller(it used to anyways, not sure its still an issue)#2022-10-2017:49shaunlebroni saw the re-natal-husk solution in the cljsrn wiki talking about the slowness with that#2022-10-2017:50thhellerbut also this was the only way to get source maps to work reliably in the chrome devtools runtime thingy#2022-10-2017:50thhelleryes, just run with :target :npm-module and you'll see if its still slow#2022-10-2017:51shaunlebroni suppose most people are just developing on chrome, then for prod they’re manually mapping error locations in the sentry logs to cljs sources using their own manual tooling#2022-10-2017:52thhellerno clue what people do. I have never done any actual react-native dev myself#2022-10-2017:54shaunlebroni got a stack trace trying to load an npm-module build into Expo Go#2022-10-2017:54shaunlebronmight be a path issue#2022-10-2017:54shaunlebroni'll go down this rabbit hole another time, but thanks for the context here.#2022-10-2018:12Lone RangerThis is kind of a bit off topic for shadow but @thheller I'm kind of curious if you've done any devlogs or podcasts where you talk about how you can stay so motivated on an open source project for so long. It's really impressive.#2022-10-2018:15thhellerwell, I built it for my own work projects in the first place. and still use it for that, so sort of just solving my own problems that others also happen to have 😉#2022-10-2018:18Lone Rangernah come on haha#2022-10-2018:27Lone Rangerwell where it comes from, good stuff, and thanks 😄#2022-10-2106:56mkvlrwhen implementing server-side-rendering, I'm thinking about switching to :target :esm so I'm able to keep a single bundle that I can run in the browser and in node (or graal). Are there any reasons I'm missing why this would be a bad idea?#2022-10-2106:57thhellerwell for node you usually wouldn't bundle all the dependencies and let node load them#2022-10-2106:57thhellerfor graal/browser you'd need to#2022-10-2106:57thhellerbut I guess for node it doesn't matter too much if you just bundle it#2022-10-2106:57thhellergraal IIRC doesn't support ESM, so only single module release builds would work#2022-10-2106:59mkvlrright, I think you convinced me regarding getting things working in node vs in graal first.#2022-10-2107:00thhellerI'd recommend :node-script, it just is the most straightforward way for node#2022-10-2107:00thhellerESM is a little bit of a journey given the state of ESM in node#2022-10-2107:01mkvlroh, there's still issues with it? Ok, will try :node-script on the first glitch I run into#2022-10-2107:03mkvlror actually, trying :node-script first, thanks for the rec!#2022-10-2107:05thhellerESM needs to be opt-in for node. only ESM code can include ESM packages thought, so depending on what you want to use that may be required#2022-10-2107:11mkvlrand for the browser do you recommend :esm these days or also sticking with :browser?#2022-10-2107:12thheller:browser, unless you want to load ESM code dynamically via import#2022-10-2107:14mkvlrok, so I actually do load esm modules in node now, so trying :esm instead of :node-script#2022-10-2107:39mkvlrrunning into ReferenceError: WebSocket is not defined at shadow$cljs$devtools$client$websocket$start (full error in 🧵 ) with target :esm and trying to run it via node .#2022-10-2107:39mkvlr
node public/js/viewer.js
Installing CLJS DevTools 1.0.3 and enabling features :formatters :hints :async
file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5
var socket = (new WebSocket(ws_url));
             ^

ReferenceError: WebSocket is not defined
    at shadow$cljs$devtools$client$websocket$start (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.websocket.js:5:14)
    at Object.attempt_connect_BANG_ (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.shared.js:482:128)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.shared.js:970:16)
    at file:///Users/mk/dev/clerk/public/js/cljs-runtime/shadow.cljs.devtools.client.browser.js:957:36
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Node.js v18.7.0
#2022-10-2107:39thhellercurrently :target :esm presumes browser runtime as the default#2022-10-2107:39thheller(and has no implemented support for node repls)#2022-10-2107:40thhellerset :runtime :custom in the build config#2022-10-2107:41mkvlrnice, no more error!#2022-10-2108:07mkvlrso I have a module in public/js/viewer.js that I can load without errors in node but am too stupid to write another script that imports and uses it 🙈 The js ecosystem often makes me feel this way…#2022-10-2108:08thhellerhmm?#2022-10-2108:09thhellerfirst of all drop the notion of public for node. to me that look like it would end up as a public script in http sense, which I assume what you are not building here#2022-10-2108:09thheller> write another script that imports #2022-10-2108:09thhelleryou mean other .js script?#2022-10-2108:10mkvlrmy module has this at the end shadow.cljs.devtools.client.env.module_loaded("viewer");#2022-10-2108:10thhellernot sure what you mean by that#2022-10-2108:10mkvlrtried various ways to import (also moving it to the ./ path but didn't figure out how to make it work#2022-10-2108:10thhellerthis is something shadow-cljs internal, it is not relevant for anything besides that#2022-10-2108:10thhelleryou mean importing from a .js file?#2022-10-2108:11mkvlryes#2022-10-2108:11mkvlrshould I be able to import "viewer.js"?#2022-10-2108:11thhellerimport { somethingYouExported } from "./public/js/viewer.js"#2022-10-2108:11thhellerpath depends on where the .js file lives relative to the viewer.js#2022-10-2108:12thhellerimport "viewer.js" is viewed by node a npm package and it'll try to load an npm package#2022-10-2108:12mkvlrdoh, I could swear I tried this but it seems like not#2022-10-2108:12mkvlrand your thing above does work, thank you!#2022-10-2108:12thhellerso always use a relative path of some kind#2022-10-2108:12thhellerso, starting with ./ or ../#2022-10-2108:13mkvlrah, I tried public/js/viewer.js and /public/js/viewer.js but not ./public/js/viewer.js#2022-10-2108:13thheller/ would be an absolute path, so absolute on your filesystem#2022-10-2108:13thhellerpublic/js/viewer again would look for the public npm package#2022-10-2110:41HankstenbergIs there any guide that says something about how to use the output of the "release" target? I see various files lying around in ".shadow-cljs/builds/app/release", but.. what do I do with them?#2022-10-2110:42thhelleryou don't do anything with those, you only use the actual configured output files. ie. :output-dir in a browser build#2022-10-2110:43thhellerthe files in .shadow-cljs are build supporting files (eg. caches). they are build internal and aren't used anywhere besides that#2022-10-2111:23HankstenbergAh, I see thanks. 🙂 Okay, now I need to find out why the release build doesn't work.#2022-10-2111:26thhellerwhats the problem?#2022-10-2111:28Hankstenberg"Error: No item 1 in vector of length 0"#2022-10-2111:29HankstenbergThere's some of my own log messages in the console before the error, so I guess I need to see where it crashes by putting in more console logs.. or is there a better way?#2022-10-2111:30thhellerthats the error message you'd get for (nth [] 1)#2022-10-2111:30thhellerI recommend using npx shadow-cljs release app --debug to debug issues#2022-10-2111:31thhelleror npx shadow-cljs release app --pseudo-names but that doesn't have source maps, so a little lower level and may require looking over some JS code#2022-10-2111:31thhellergenerally --debug is best#2022-10-2111:32HankstenbergDamn, I actually have a single stupid "nth" in my code. I'll check that right away. Thanks so much!#2022-10-2112:00HankstenbergGot it working. Awesome!#2022-10-2112:01mkvlrnow running into https://clojurians.slack.com/archives/C6N245JGG/p1627574180362500 with the advanced build. @borkdude you wrote you replaced this, is there a way to let shadow fix this now?#2022-10-2112:03borkdudeCheck nbb's build, I don't remember, it's been a while :)#2022-10-2112:04borkdudestuff is here: https://github.com/babashka/nbb/blob/main/build/src/nbb/build.clj#2022-10-2112:05mkvlroh yeah#2022-10-2112:05mkvlr
(spit "lib/nbb_core.js"
        (str/replace (slurp "lib/nbb_core.js") (re-pattern "self") "globalThis"))
#2022-10-2112:05mkvlrthanks!#2022-10-2113:46thhelleruhm this should not exist?#2022-10-2113:46thhellerhow did you build it?#2022-10-2113:51mkvlrshadow release, nothing else#2022-10-2113:53mkvlrhttps://github.com/nextjournal/clerk/blob/d84badfae668cf0753dd5b8a61f8621afdef0865/shadow-cljs.edn is the config, bb release:js if you want to reproduce it#2022-10-2114:08thheller
clerk$ npx shadow-cljs release viewer --pseudo-names
shadow-cljs - config: /mnt/c/Users/thheller/code/oss/clerk/shadow-cljs.edn
shadow-cljs - starting via "clojure"
Execution error (FileNotFoundException) at clojure.main/main (main.java:40).
Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.

Full report at:
/tmp/clojure-13405443538645289994.edn
#2022-10-2114:08thhellerhow do you compile?#2022-10-2114:10mkvlrhttps://github.com/nextjournal/clerk/blob/82c35e2fc23a492ad1dd4ff201b39ed141098a1f/bb.edn#L27#2022-10-2114:11mkvlrclojure -M:sci:demo:dev release viewer#2022-10-2114:13thhelleryeah upgrade#2022-10-2114:14thhellerthat shadow-cljs version didn't handle esm properly#2022-10-2114:15borkdudeso I can perhaps also remove that workaround then#2022-10-2114:16mkvlr@U05224H0W will do, thanks so much for all your support, greatly appreciated! 🙏#2022-10-2114:25borkdudeGood riddance: https://github.com/babashka/nbb/commit/bff81f8c9d66a69dfbbf5aeeea42649eb451e09b#2022-10-2114:30mkvlr@borkdude a careful removal, are you afraid it’s coming back?#2022-10-2114:30borkdudeno, it was more a lazy removal ::P#2022-10-2114:43thheller😛#2022-10-2115:59Lone RangerWant to confirm there's no shadow-cljs easy pathway for this kind of js:
import 'draft-js/dist/Draft.css';
The only way to get that to work is to webpack compile it then require the webpack compiled javascript with shadow via the normal js interop routes? aka
// ./src/js/project/css.js
import 'draft-js/dist/Draft.css';
(defn project.css
  (:require "/project/css"))  ;; <-- Invalid namespace declaration    
etc?
#2022-10-2116:19thhellercorrect, shadow-cljs does not support css. use a tool that actually only handles css and don't try to turn css into js#2022-10-2116:19thhellerjust postcss or so is fine#2022-10-2116:20thhellerand absolutely never even try to include some webpack output in a shadow-cljs build just to get css. thats madness 😛#2022-10-2116:53hlshipSo, I have an idea that I'm working on, and I'm trying to figure out how to proceed. In essence, I want a command line tool that executes, reads some data from the local directory, and then launches a browser to interactively show the results. I'm just trying to find my way around all the browser UI stuff I've ignored for about 10 years, and wrap my head around shadow-cljs concepts. First off, is this a normal use-case?#2022-10-2116:54hlshipAs in, I would want my browser FE on launch to chat with a local server, passing EDN or Transit or JSON back and forth.#2022-10-2117:11thhelleryes, you can use shadow-cljs to build the cljs code that ends up running in the browser#2022-10-2117:12thhellerand the node script in case you want to run node for the command line parts#2022-10-2117:15thheller(or use CLJ for the command line parts)#2022-10-2117:21hlshipRight, so a Clojure CLI command that, at launch, starts up a web server, serves up the previously compiled JS & assets plus additional routes specific to the tool, and opens a browser to the URL?#2022-10-2117:21thhelleryes, that would be one way#2022-10-2117:22hlshipIs that a well trodden path, or do I have some bad preconceptions?#2022-10-2117:23thhellerwell running it locally is probably not done too often. but any CLJ website works that way, so yes very good path#2022-10-2117:25thhellerits basically what shadow-cljs does during development ;)#2022-10-2117:26thhellerie shadow-cljs server and open (its UI)#2022-10-2117:27thhellerserves the precompiled JS code and talks to the CLJ process via websocket#2022-10-2117:31hlshipI'm a little lost into how I can add my own routes to http://localhost:8080 when running shadow-cljs watch frontend#2022-10-2117:32thhellerwell that should be the server you intend to run for "production", which shadow-cljs should not be a part of#2022-10-2117:33thhellerdunno what you use for :8080 now? :dev-http?#2022-10-2117:33thhellerit should be your own server. ring, pedestal, whatever you like#2022-10-2117:47hlshipSo far, no server support. I guess we would set up :8080 for JS and other assets, and another port, say :8081, for data?#2022-10-2117:47thhellerno, just one server. as far as JS and other assets are concerned, it just needs to serve the static files. any webserver can do that#2022-10-2117:49hlshipSo far, all I have is this:
;; shadow-cljs configuration
{:deps true

 :dependencies
 []

 :dev-http {8080 "public"}

 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn }}}}}
Ah, ok. I need to specify a :handler for my non-static assets.
#2022-10-2117:50thhellerno#2022-10-2117:50thhelleryou create a server to run your CLJ code. the one you intend to use for your command line tool#2022-10-2117:50thhellershadow-cljs is not involved in that in any way#2022-10-2117:50thhelleryou build it like you would for a regular website#2022-10-2117:50thhellereg. pedestal. no knowledge of shadow-cljs whatsoever. separate worlds.#2022-10-2117:51hlshipRight, that's what I was thinking when I said "data on port 8081".#2022-10-2117:51thhelleryeah, just remove :dev-http {8080 "public"} then#2022-10-2117:51thhellerits not needed if you have your own server#2022-10-2117:52thhellerjust make that server serve the files in the public dir#2022-10-2117:53hlshipSo I want all the live reloading goodness when developing, but then I want to package it all up and serve static assets off the classpath; so it feels like you are telling me about the second part of the story (one production server to handle static and dynamic) but I'm not quite sure what it looks like during development (where I want all the shadow-cljs live reloading goodness, at least for client components).#2022-10-2117:53thhellerall REPL and hot-reloading is handled independently of the :dev-http server. it is not involved in that#2022-10-2117:54thhellerthat is handled by the main shadow-cljs server running on :9630, which also serves the UI parts#2022-10-2117:54thhellerthe server serving the JS doesn't need to do anything special, just static files. it'll work with any server and needs no knowledge of shadow-cljs#2022-10-2117:56hlshipOh, it's coming into focus for me; so the shadow-cljs code is doing its thing and it's writing stuff intoo my public/js folder and using websockets to force the client to reload, but the server on :8080 is vanilla, and I can just replace that with my own app-specific server that servers assets from public but also hands the routes I need.#2022-10-2117:56thhelleryep#2022-10-2117:57hlshipMaybe I can do a documentation PR that lays some of this out?#2022-10-2117:57thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2022-10-2117:58thheller> IMPORTANT These are just generic web servers that server static files. They are not required for any live-reload or REPL logic. Any webserver will do, these are just provided for convenience.#2022-10-2117:58thhellerits sort of there already?#2022-10-2117:59hlshipYes, I'd love to expand on this a bit: "As you develop your client side application, you will reach the point where it needs to communicate with a backend; at that point, you should remove :dev-http and provide your own server, that serves the assets in public but also provides the additional routes your frontend requires." Something like that.#2022-10-2119:15lilactownyou might not. we use a reverse proxy to route our requests to either our local UI, local APIs or dev env APIs#2022-10-2119:16lilactownwe continue to use shadow's dev-http server with that setup#2022-10-2119:50thhellerthere are just too many possible setups to cover everything I'd say#2022-10-2121:31Lone RangerOk I am trying to figure out how this sorcery works:
import cljs from "goog:cljs.core";
Is this a shadow thing or a Google Closure Compiler thing?
#2022-10-2121:32thhellerclosure compiler#2022-10-2121:47Lone Rangersorcery#2022-10-2213:04janezjIn my app deployed in prod I have a special url which serves index.html pointing to main.js on localhost. <div id="app"></div><script src=""></script> This is great way to try a new frontend in a production. And even fulcro inspect is working. Connecting shadow-cljs server is solved by changing devtools-url. (when *localjs* [:script "shadow.cljs.devtools.client.env.devtools_url=':' + shadow.cljs.devtools.client.env.server_port"])]])) But there are still hundreds 404s when loading *.maps https://production.example.com/js/main/cljs-runtime/com.fulcrologic.rad.rendering.semantic_ui.semantic_ui_controls.js.map So is there a similar way to load *.map files from localhost?#2022-10-2216:42thheller:asset-path controls this, it is badly named so it isn't obvious but it accepts a full url#2022-10-2216:43thhelleranother option may be using https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http-proxy#2022-10-2216:43thhellerso you access localhost but proxy to your production server for any request that isn't available locally (ie. all non-local files/routes)#2022-10-2216:44thhellerthat way local JS is typically used basically "overriding" the remote JS#2022-10-2216:44thhelleryou also don't need to set the devtools url via some :script#2022-10-2216:44thhellerthere is a config option for that https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2022-10-2308:55janezjThanks, I will try to set it with bb and --config-merge#2022-10-2216:04oskarkvI'm not sure if this is the right channel, but when I get errors I see a JS stack trace, like in the screen shot. Is there a way to get that as a cljs stack trace, with line numbers from my cljs files?#2022-10-2216:40thhellerdunno. which browser is this? source maps are provided, whether your browser makes use of them shadow-cljs has no influence over#2022-10-2217:42oskarkvIt's a Tauri app.#2022-10-2217:43thhellerno clue how that handles source maps#2022-10-2217:48oskarkvHm, only Firefox seems to use them (not Brave or Chrome). Thanks! I'll try to find out more.#2022-10-2218:28oskarkvNo, they work in Chrome and Brave. And setting :loader-mode to :script makes them work in Tauri too.#2022-10-2216:41thhellerthe error above is basically (assoc 26 :whatever "invalid")#2022-10-2216:41thhellerin app.screens somewhere#2022-10-2414:23dvingoI have some metadata I include on some function Vars that is only used for development-time tooling. I am wondering if there is a solution to remove this metadata for release builds - would this be possible with a build hook? I was thinking to walk all the namespaces in the build and update the var metadata before compilation. Does this make sense or is there a better strategy?#2022-10-2414:33dvingoanswering my own question - unless you explicitly call (meta (var my.ns/a-fun)) the function metadata does not appear to be included in the release builds by default! great!#2022-10-2416:11thhellerits not even included in a dev build 😉#2022-10-2418:15Lone RangerSorry to keep on with this I'm just trying to figure out how to get my intellisense working -- does anyone have any documentation on the import cljs from "goog:cljs.core" style statement? I cannot find anything on this anywhere. Is the goog: part a shadow convention or is that a google closure compiler convention?#2022-10-2418:18Alexis Schadhttps://shadow-cljs.github.io/docs/UsersGuide.html#_access_cljs_from_js#2022-10-2418:19Lone RangerI understand that -- I'm looking for a layer deeper because I'm trying to get the intellisense in my javascript IDE to pick up (compiled) ClojureScript code#2022-10-2418:20Lone Rangerthere's no intellisense on cljs when I do import cljs from "goog:cljs.core"; but if I write some "resolve as" code it will work -- just need a few more clues about how it works under thehood#2022-10-2418:29Alexis SchadIn the begin of each file there's a call to goog.provide https://google.github.io/closure-library/api/goog.html#provide to create the namespace (with the google closure api)#2022-10-2418:30Alexis Schadhttps://github.com/thheller/shadow-cljs/blob/0421c93732669a3cab4397dedb90e1ce149a8f2f/src/main/shadow/build/js_support.clj#L53#2022-10-2418:31Lone Rangerwow, dang#2022-10-2418:34Lone Rangerhang on -- I think this is talking about something else. I would expect that to be goog.require#2022-10-2418:35Alexis SchadI've just exposed the shadowcljs side#2022-10-2418:35Alexis SchadThe goog: part is from google closure api#2022-10-2418:36Lone RangerI've heard that but I can't find any docs on it#2022-10-2418:38Lone Rangerhttps://developers.google.com/s/results/closure/library?q=goog%3A&amp;text=import%20%22goog%3A%22 , but nothing there really#2022-10-2517:12thhellerthe goog: part is some obscure and mostly undocumented feature in the closure compiler#2022-10-2517:12thhellerso I wouldn't expect any tools to support it, neither would I know how to make them#2022-10-2517:13thhellerimport is ESM and CLJS and the Closure Library use ClojureJS module format#2022-10-2517:13thhellerimport with goog: is just the way to bridge the two, nothing else#2022-10-2517:14thhellerunfortunately its also sort of the only way to bridge it#2022-10-2418:15Lone RangerI'm assuming it is referencing code the in cljs-runtime directory but it's not obvious to me how#2022-10-2517:15thhellernot quite#2022-10-2517:16thhellerwhen the closure compiler compiles ESM import files it just rewrites them to remove import and export and instead replaces everything with global references#2022-10-2517:16thhellerso cljs-runtime doesn't play a role in this in any way, apart from that being the location where the files end up 😉#2022-10-2522:26Lone RangerOhhhh clever #2022-10-2418:23MegaMattI upgraded a project from 2.11.23 to 2.20.5. previously index files in sub directories were respected and after upgrade only the top level index is respected.
public
  index.html
  sub-app
    index.html
any ideas to serve sub-app/index.html when localhost:8280/sub-app url is hit (other than downgrading)?
#2022-10-2418:38MegaMatti initially upgraded because binaryage/oops was complaining about js-fn? not existing. It looks like if i jump to 2.12.7 i fix the binaryage/oops error and still get the same index serving pattern.#2022-10-2517:10thhellerI assume you use :dev-http where you can set :use-index-files true to get back the old behavior#2022-10-2517:10thhellerso :dev-http {8000 {:root "public" :use-index-files true}}#2022-10-2517:11MegaMatt
:builds {:app {:devtools
 {:http-root "public"
                   :http-port 8280
                   :preloads [devtools.preload day8.re-frame-10x.preload portal.preload]}
#2022-10-2517:14thhelleryeah thats old and deprecated for several years now#2022-10-2517:15thheller:dev-http {8280 {:root "public" :use-index-files true}} at the top level instead#2022-10-2517:15MegaMattthank you#2022-10-2517:15thhellerand remove :http-root :http-port from the build config#2022-10-2522:26Lone RangerOhhhh clever #2022-10-2510:38Eric DvorsakI declare my deps in deps.edn and I am trying to build with tools.build, when I call (shadow/release :main) in my build.clj I get "The required namespace is not available...", the being the first dependency required by my code, defined in the :deps key of my deps.edn. When I copy paste that dependency under :replace-deps of the :shadow-cljs alias then I get the same error with the next one (meaning that dependency is now visible to shadow/release). My question would be if that is expected? Is there a way to tell shadow-cljs to use the deps from deps.edn :deps key like it does during development?#2022-10-2510:47Ferdinand Beyer> My question would be if that is expected? Yes. You are using tools.build with :replace-deps, so the Clojure CLI will build a classpath with only the defined deps, and then you use Shadow’s API within the same JVM, so Shadow will have the same classpath. You probably need to adjust your classpath and make sure that all ClojureScript deps are on the classpath as well, or spawn a sub-process from your build.clj to call Shadow with its own classpath.#2022-10-2510:48Eric DvorsakInitially I was not using :replace-deps I just added it to test if it will find the dependency that way#2022-10-2510:48Eric Dvorsak
:shadow-cljs
           {:paths ["src/main"]
            :extra-deps {thheller/shadow-cljs {:mvn/version "2.20.2"}}
            :main-opts ["-m" "shadow.cljs.devtools.cli"]}
#2022-10-2510:48Eric Dvorsakall the deps are in the :deps key#2022-10-2510:48Ferdinand BeyerHow are you using build.clj? Using clojure -T:build?#2022-10-2510:49Eric Dvorsakclojure -T:shadow-cljs:build#2022-10-2510:49Ferdinand BeyerHow is your :build alias defined?#2022-10-2510:49Eric Dvorsak
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.8.3" :git/sha "0d20256"}}
                   :ns-default build}
#2022-10-2510:52Ferdinand BeyerNot sure if -T will ignore the root-level :deps. In general, you should not use :deps in your aliases, but :extra-deps or :replace-deps. Normally, tools are meant to run in a classpath that is different from your project’s, so they use :replace-deps. In your case, can you try using :extra-deps in both your :build and :shadow-cljs aliases?#2022-10-2510:53Ferdinand BeyerI see you have that in :shadow-cljs already#2022-10-2510:54Ferdinand BeyerSee the docs for -T: https://clojure.org/reference/deps_and_cli#_running_a_tool > When running a tool, the project’s :deps and :paths are not used.#2022-10-2510:54Eric Dvorsakyeah will try, I didn't think too much about this one in :build, I took inspiration from https://github.com/metosin/packaging-clojure-examples/blob/master/deps-uberjar/deps.edn#L17#2022-10-2510:57Ferdinand BeyerI think in your case you don’t want to use -T, as this is meant for standalone tools with their own classpath. Instead, if you use :extra-deps in the :build alias, you should be able to use the -X switch to run your build functions, with a classpath built from your project’s :deps and all extra deps from additional aliases.#2022-10-2510:59Ferdinand BeyerYou might need to add :extra-paths ["."] so that your build.clj in on the classpath. Note that: > Tools declared with an alias can also be executed with -T, just as they can be executed with -X. The only difference is that -T implies {:replace-deps {}, :replace-paths ["."]}, so the project deps/paths will not be included, by default.#2022-10-2511:04Eric Dvorsakyep thanks#2022-10-2511:04Eric Dvorsakrunning with -X solved my issue#2022-10-2511:06Eric DvorsakSo I assume what's missing is the possibility to pass a basis to shadow/release#2022-10-2511:07Ferdinand BeyerI understand it this way: The shadow-API is meant to be used on a preconfigured classpath, and the standalone version will follow shadow-cljs.edn to deps.edn (when configured) and builds the basis#2022-10-2517:04thhelleryeah, tools.build doesn't use the project classpath but CLJS compilation (and therefore shadow-cljs) require access to the full project classpath#2022-10-2523:20superstructorIs there a way to disable shadow-cljs automatically calling 'npm install...' commands if one does not want that behaviour ?#2022-10-2605:12thheller:npm-deps {:install false} top level in shadow-cljs.edn#2022-10-2605:36superstructorThanks @U05224H0W 👍 🙂#2022-10-2604:17Rambabu PatinaHi Team, I need help with shadow-cljs. I want to exclude particular library while building. The shadow-cljs.edn looks such as
:app {:target :browser
   ....
   :modules {:shared {:entries []}
             :other {:entries ..}
   ...
My assumption is if the entries is empty (i.e []) then bundling all dependencies in public/shared.js file. I want to exclude a library which is not required at client side. I appreciate your time. Thanks
#2022-10-2605:14thhellershadow-cljs includes everything you :require in the ns forms, thus you need to remove the require to get rid of it?#2022-10-2605:18Rambabu PatinaThanks @U05224H0W for your quick response. I cannot remove that because it is required for one of the backend service#2022-10-2605:19Rambabu PatinaAnd I want to exclude it in shared.js, because it is not needed in client side#2022-10-2605:20thhellerthen you may need to split a namespace that contains the backend code into one that is one included on the backend and one that contains the client side#2022-10-2605:21thhellerif the code is not needed it should not be required#2022-10-2605:21thhelleror are you asking about a specific npm library?#2022-10-2605:23Rambabu PatinaI was facing issues with https://www.npmjs.com/package/aws4-axios. I too have other npm modules such as axios, Luxon etc, there are fine.#2022-10-2605:24Rambabu PatinaFYI, I have separate name space for UI and Server#2022-10-2605:25thhellerin general server side code should just not be included in a client side build. your namespaces should be structured accordingly#2022-10-2605:26thhellerand only your namespace :require controls what is included, so thats what you need to work out. can't give many tips besides that#2022-10-2605:27thhelleryou can disable the inclusion of certain npm packages via :js-options {:resolve {"package-you-dont-want" false}} but that won't affect the CLJS code getting included#2022-10-2605:28thhellerso best option is clearly structuring namespaces so certain stuff just isn't required in the first place#2022-10-2605:31Rambabu PatinaSure I will re-check the structure#2022-10-2606:39thhellerjust to confirm: you are not using :modules and a single build to compile client and server code together? so you don't have a :shared module and then a :client and :server?#2022-10-2607:30Rambabu Patina#2022-10-2607:31Rambabu PatinaI do have :shared module for client. For server we have separate build. Please find the shadow-cljs.edn file#2022-10-2607:33thhellerok, that should be fine
#2022-10-2607:34thhellerFYI you do not need :entries [our-app.ui.pages.getting-started] if :init-fn is the same namespace. :init-fn desugars to that :entries, so specifying it again is redundant. just :init-fn is fine.#2022-10-2809:52Rambabu PatinaGreat @U05224H0W. It worked. I appreciate your help. Thanks#2022-10-2613:08simongrayIs it true that I can't have local dependencies in my shadow-cljs.edn? When I Google it, people say to use deps.edn as a fallback, but then I won't be able to use NPM packages. I feel stuck between a rock and a hard place.#2022-10-2613:08thhellerusing deps.edn has no impact on the ability to use npm packages. that continues to work just fine#2022-10-2613:09simongrayReally?#2022-10-2613:09thhellerby "local dependencies" I assume you mean :local/root from deps.edn?#2022-10-2613:09simongrayyeah#2022-10-2613:09thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn#2022-10-2613:09thhelleryou are just moving your CLJ/CLJS dependencies to deps.edn and thats it#2022-10-2613:10thhellernpm stuff just stays as it is#2022-10-2613:10simongrayI see#2022-10-2613:10simongrayThank you!#2022-10-2613:21RichieI'm trying to follow the electron instructions for https://www.electronjs.org/docs/latest/tutorial/ipc and I added a build for the preload.js file.
{:builds {:preload {:target :node-script
                    :output-to "resources/preload.js"
                    :main app.preload.core/main
                    :hashbang false}
          ...}
 ...}
Now, I'm getting tons of warnings like DevTools failed to load source map: Could not parse content for file:///C:/Users/richie/Documents/org/projects/electric-clj-play/resources/public/goog.debug.error.js.map: Unexpected end of JSON input It's not at resources/public/goog.debug.error.js.map , it's at resources/public/js/cljs-runtime/goog.debug.error.js.map. How can I fix this? Thanks!
#2022-10-2613:35thhelleras far as I know the preload script is not actually node? its been many years since I even looked at electron so I'm not actually sure what this needs#2022-10-2613:57RichieI think you're right. It was described as being the same as the "renderer" but runs with more permissions. I first tried :target :browser but had some trouble and then found https://clojurians.slack.com/archives/C6N245JGG/p1634150800435700 thread. I'll try :target :browser again since now I don't remember what the problem was.#2022-10-2614:06thhelleryeah :node-script really assumes node and at least watch/compile builds will probably only run in actual node#2022-10-2614:06thheller:target :esm might also be an option. last time I looked at electron it didn't support ESM but its been a while#2022-10-2614:58RichieI don't get results in https://grep.app/search?q=exposeInMainWorld&amp;filter[lang][0]=Clojure and I haven't found examples e.g. https://github.com/logseq/logseq/blob/master/resources/js/preload.js just does it in javascript. I tried adding a new browser target
:preload {:target :browser
                    :devtools {:watch-dir "resources/public"}
                    :output-dir "resources/public/js/preload"
                    :asset-path "js/preload"
                    :modules {:preload {:entries [app.preload.core]
                                        :init-fn app.preload.core/main}}}

          :renderer {:target :browser
                     :devtools {:watch-dir "resources/public"}
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:entries [user]
                                          :init-fn app.renderer.core/start!}}}
which gives me a bunch of errors like ReferenceError: goog is not defined and I tried not adding a browser target for preload and instead just adding a module
:renderer {:target :browser
                     :devtools {:watch-dir "resources/public"}
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:shared {:entries []}
                               :renderer {:entries [user]
                                          :init-fn app.renderer.core/start!
                                          :depends-on #{:shared}}
                               :preload {:entries [app.preload.core]
                                         :init-fn app.preload.core/main
                                         :depends-on #{:shared}}}}}
but that gives me
Unable to load preload script: C:\Users\richie\Documents\org\projects\electric-clj-play\resources\public\js\preload.js
ReferenceError: SHADOW_ENV is not defined
Uncaught ReferenceError: SHADOW_ENV is not defined
#2022-10-2615:00Richie:target :esm didn't work right away although now I can't remember what was wrong... shoot.#2022-10-2701:51RichieAww man. When I started out, it was working but had warnings. Now, it's broken and I can't make it work at all. I'm sad. I think I'm going to give up on electron.#2022-10-2704:46thhellerif you want to setup a repo with the failing setup I can probably tell you where the error is#2022-10-2712:26RichieI tried to get everything back to where I think it was when I started. The time where I was just complaining about warnings. Now I have ReferenceError: __dirname is not defined coming from the preload.js file. https://github.com/rgkirch/electron-help Thanks a million! My goal was to add a second electron window to help debug things. I have some tracing in my main app that I wanted to send over. Initially I assumed they'd share my global state but it looks like I have to use ipc.#2022-10-2713:35RichieAlright. I must have had nodeIntegration enabled. e.g. :webPreferences {:nodeIntegration true I'm back to just having the warnings. That means I just don't know the "right" way to do this since I'm override the default behavior and what I'm doing here is discouraged for security reasons.#2022-10-2713:36RichieI feel a little better though.#2022-10-2713:43RichieAfter I got discouraged I started reading the docs on cljfx but I might keep trucking with this for a bit. Since :target shouldn't be a :node-script, do you have any suggestions on how to make it work as :esm or :browser? Thanks again!#2022-10-2714:11RichieI tried :esm https://github.com/rgkirch/electron-help/compare/master...target-esm. I get SyntaxError: Cannot use import statement outside a module.#2022-10-2717:20thhellerhttps://github.com/thheller/electron-cljs#2022-10-2717:20thhellerI setup a full repo with a working setup#2022-10-2717:21thhelleryours had a little too much extra chaos in it 😉#2022-10-2613:38thheller:target :browser might be a better fit, but running with :js-options {:js-provider :require} so it doesn't attempt to bundle stuff#2022-10-2617:46RichieI misunderstood this comment. I read it as suggesting either :target :browser or :target :node-script with :js-options {:js-provider :require} I tried
:preload {:target :browser
                    :devtools {:watch-dir "resources/public"}
                    :output-dir "resources/public/js"
                    :asset-path "js"
                    :modules {:preload {:entries [app.preload.core]
                                        :init-fn app.preload.core/main}}
                    :js-options {:js-provider :require}}

          :renderer {:target :browser
                     :devtools {:watch-dir "resources/public"}
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:entries [user]
                                          :init-fn app.renderer.core/start!}}}
but get ReferenceError: goog is not defined
#2022-10-2619:48Lone RangerIs there a "cannonical" alternative...?#2022-10-2620:07thhellerto do what exactly?#2022-10-2621:22Lone Ranger(:require ["/my/awesome/stuff" :as awesome-stuff]) Previously I'd been using figwheel with webpack to make an index.bundle.js and then
(:require awesome-stuff)
with
// index.js
awesomeStuff = require('src/js/my/awesome/stuff.js')
window.awesomeStuff = awesomeStuff
then yarn webpack etc
#2022-10-2621:23Lone Rangerthis is way better#2022-10-2704:42thhellerwell, they are not really solving the same problem#2022-10-2621:49Lone RangerOk I have a flagrantly stupid question but if anyone is up for a little typescript/javascript/clojurescript/shadow-cljs to challenge themselves, here goes... one of my javascript imports is not being resolved.
import {Config} from "../config";  // this explodes in the browser
Ironically, if I do this:
(ns app.lib.ext.config
  (:require ["/app/config" :as app-config]))

(def ^:export Config app-config/Config)
and then in my javascript I do
import config from "goog:app.lib.ext.config";
const Config = config.Config; 
it works great
#2022-10-2622:44Lone RangerOk I think this question resolves to “how does goog.require work “#2022-10-2704:40thhelleryour description is somewhat hard to understand#2022-10-2704:40thheller> import {Config} from "../config"; // this explodes in the browser #2022-10-2704:40thhellerwhat does "explodes in the browser" mean?#2022-10-2704:41thhellerif shadow-cljs compiles this code it'll never get to the browser in that shape?#2022-10-2704:41thheller(def ^:export Config app-config/Config) why is there an ^:export?#2022-10-2704:42thhellerimport config from "goog:app.lib.ext.config"; why is this importing the CLJS ns instead of just the config directly?#2022-10-2704:42thhellerwhy is config JS in the first place?#2022-10-2704:42thhellerso many questions 😛#2022-10-2704:44thhellergoog.require is no-op and does nothing at runtime. it merely serves as static information for the compiler so it can sort sources in the proper order#2022-10-2704:45thhellerit serves no other purpose in shadow-cljs. in regular CLJS it is used by the debug loader and actually does something, in shadow-cljs it does not since it uses its own loader.#2022-10-2712:51Lone RangerSorry, yeah I know it’s confusing I wasn’t sure how much info to include #2022-10-2712:52Lone RangerIn the browser that JavaScript expands to ”/app/config”#2022-10-2712:52Lone Rangerthe import statement #2022-10-2713:24Lone Rangerhere's what the error looks like, expanded:#2022-10-2713:25Lone RangerUncaught (in promise) ReferenceError: Config$$module$app$config is not defined#2022-10-2713:28Lone RangerI should also add this is executing in a webworker context#2022-10-2713:30Lone Rangerwhen I set a break point it still comes up as undefined which is odd considering the import seems to be working#2022-10-2713:36Lone RangerI'm wondering, should
"/app/config.js"
expand to
"/js/compiled/cljs-runtime/app/config.js"
instead?
#2022-10-2716:35thhellerI don't know what this output is. it is not output of a shadow-cljs build#2022-10-2716:36thhellerand no, it should not expand that "/js/compiled/cljs-runtime/app/config.js"#2022-10-2716:37thhellerin fact there should not be any import anymore whatsoever#2022-10-2716:37thhellerso I'm not entirely sure what you are doing but the code you showed is not generated by shadow-cljs#2022-10-2718:13Lone RangerIf you don't think this is insanity I can DM you some more detailed code, it's company code so I can't really put in public chat. But here's the setup: • shadow-clj project • three typescript files, (config module config and module that calls a webworker, thread-utils) and (webworker worker) ◦ thread-utils depends on config (this is where the error is happening) • tsconfig file that compiles the typescript into a location in src/gen • shadow project builds :main, :base, and :worker • clojurescript code from :main calls thread-utils from src/gen • crash #2022-10-2718:15Lone Rangerso you are right that shadow-cljs is not generating the javascript#2022-10-2718:16Lone Rangerthe generated javascript from the tsconfig is being called with
(:require ["/classpath/to/thread-utils" :as thread-utils])

(thread-utils/testAdd)
#2022-10-2718:18Lone RangerI realize this is insanity, yes.#2022-10-2718:39Lone Rangermostly I'm trying to localize if this is a google-closure-compiler issue, a misconfigured typescript issue, or a misconfigured shadow-cljs issue#2022-10-2719:16thhellerso what does the JS file header look like after ts is done with it? just the import statements is fine#2022-10-2719:16thhellerso the actual file shadow-cljs is importing in src/gen I guess#2022-10-2719:17thhellerTS might not like the absolute includes, so instead try relative ones. so just ./config.js if they are all in the same dir#2022-10-2719:22thhellerI'm really only guessing here. I do not understand your setup, so my guesses will not be very accurate or helpful#2022-10-2813:01Lone Rangerok just to close the loop, the error was very strange#2022-10-2813:04Lone Ranger
// case1.js
export class Config {}
Config.fooPath = Paths.foo
Config.barPath = Paths.bar
vs
// case2.js
export class Config {
   fooPath = Paths.foo
   barPath = Paths.bar
}
the top one does not work with
import {Config} from "/path/to/config";
while the bottom on does. I have no idea why this is the case. But this is the result of:
// case1.tsx
export class Config {
   static readonly fooPath = Paths.foo
   static readonly barPath = Paths.bar
}
// case2.tsx
export class Config {
   fooPath = Paths.foo
   barPath = Paths.bar
}
#2022-10-2813:05Lone RangerThe only thing I can think of here is that since the export is declared in the generated code before the static methods are added, the static methods are not exported#2022-10-2813:05Lone Rangerso it wasn't a config error at all, just a masking bug#2022-10-2622:44zhuxun2How would you debug when your project runs fine in development mode but when in release mode, the compiled js code crashes with a Error: xx is not a function?#2022-10-2622:45zhuxun2For me the difficulty is the code has already been minified and it's hard for me to find out what xx originally was in the source code#2022-10-2622:51zhuxun2Is there a way to turn off minification in release mode?#2022-10-2622:58dpsutton> :pretty-print and :pseudo-names default to false. You can use shadow-cljs release app --debug to enable both temporarily without touching your config. This is very useful when running into problem with release builds from the https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options Information about https://clojurescript.org/reference/compiler-options#pseudo-names#2022-10-2704:36thhellerthere is also shadow-cljs release app --pseudo-names, which is without source maps. sometimes some optimizations make the source maps inaccurate and confusing. then its just better to decipher the generated JS, which pseudo names make possible somewhat#2022-10-2705:03dpsuttonI thought i remembered that being an option but didn't see it in the users guide. The only mention of pseudo names was what i found unless i missed a reference#2022-10-2715:11Mario Trost👋 shadow-css doesn't support Tailwind's JIT compiler right now, does it?#2022-10-2715:39winsomeI've used this and it works just fine: https://github.com/teknql/shadow-cljs-tailwind-jit#2022-10-2715:49thhellershadow-css doesn't use tailwind in any way for anything, it only borrows the naming scheme. the css generation is entirely independent#2022-10-2715:51thhellertailwind needs a jit because otherwise the css is huge#2022-10-2715:51thhellershadow-css only generates whats needed anyways, so basically is jit anyways#2022-10-2805:03Mario TrostI was asking myself if I e.g. could do padding-[50px] like I could with Tailwind but yeah, I could get the same result with {:padding "50px"}#2022-10-2806:32thhelleryeah :padding-[50px] is not a valid keyword, so can't do that#2022-10-2721:52fabraowhat is the security issues pointed from nvd-clojure that shadow-cljs has I should care?#2022-10-2800:55vemvcould you post them? but in general I'd doubt that they matter. in general dev/test/build time tooling cannot be exploited in the wild Relatedly, it's a good idea to only pass nvd-clojure a classpath that accurately represents your production classpath. This project tries to be as pedantic about this as possible (internally and in its README) but there's still room for human mistakes :)#2022-10-2805:28thhelleryeah what would they be? nothing from shadow-cljs, except the final release outputs, should be anywhere near a production environments, so it really shouldn't matter#2022-10-2805:28thhellerI'd still be curious to know what they are 🙂#2022-10-2810:58fabraoHello, I'd appreciate your time. The security problem and the library#2022-10-2812:10vemvlooks like both are dev-time servers. If you don't run such servers in production you're on the safe side#2022-10-2815:49thhelleryeah, since you hopefully don't use shadow-cljs as your production webserver this really doesn't matter#2022-10-2815:50fabraoyes, I wont#2022-10-2815:51thhellerthe CVE are also about the AJP adapter which shadow-cljs doesn't use#2022-10-2815:52fabraowhat is that shadow-undertow?#2022-10-2815:53thhellerhttps://github.com/thheller/shadow-undertow#2022-10-2815:53fabraooh, it's a webserver#2022-10-2815:53thhellerCLJ wrapper for the undertow http server#2022-10-2815:54thhellerused for the websockets, dev-http etc#2022-10-2815:55fabraoyes, the websockets lib I use is fixed in my deps, thank you#2022-10-2800:01Shako FarhadIs it possible to import custom code from typescript files like this in shadow-cljs?
(def component (js/require "./typescript/component.tsx"))
#2022-10-2802:51Lone RangerNo, you need to compile them to JavaScript first #2022-10-2804:35eccentric JDoes shadow support bundling json files?
(ns my-project.my-ns
  (:require ["./assets.json" :as assets]))
or
(def assets (js/require "./assets.json"))
#2022-10-2805:26thhellersee https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-10-2805:26thhellernot via require, but a macro#2022-10-2806:06eccentric JThat's fantastic. Thanks a ton!#2022-10-2806:40eccentric JHaving trouble getting it working though. I'm putting the code in a cljc file wrapped in a conditional as I need to target nbb and shadow-cljs#2022-10-2806:41eccentric J
#?(:org.babashka/nbb
   (do
     (ns crunchy.assets)
     
     (def assets (js/require "./assets.json")))
   :cljs
   (do
     (ns crunchy.assets
       (:require
         [shadow.resource :refer [inline]]))

     (def assets (inline "./assets.json"))))
       
(defn asset
  [rel-path]
  (let [actual-path (aget assets rel-path)]
    (when-not actual-path
      (throw (js/Error. (str "Could not lookup asset " rel-path))))
    actual-path))

Error:
[:app] Compiling ...
Closure compilation failed with 1 errors
--- crunchy/assets.cljc:8
Required namespace "shadow.resource" never defined.
#2022-10-2806:46thhelleryou cannot have do to define ns. ns must be its own top level form#2022-10-2806:48thheller
(ns crunchy.assets
  (:require
    #
#2022-10-2806:48thhellersomething like that I guess#2022-10-2806:53eccentric JWill try#2022-10-2806:57thhellerbut note that inline just gives the the JSON string, not the object. so you'd need to parse that first#2022-10-2807:02eccentric JOh right, good catch#2022-10-2807:25eccentric JThat definitely works, thanks again!#2022-10-2806:03JHi guys! Do you have an idea how resolve this mistake:#2022-10-2806:09thhellerhmm no idea. never seen that. must be something npm related. definitely nothing from shadow-cljs.#2022-10-2806:09thhellermaybe you have a .npmrc or something setting some invalid config?#2022-10-2806:17JYou have right! There was a bad config in my npmrc.#2022-10-2806:10JThanks @thheller. I will check that.#2022-10-2806:40eccentric JHaving trouble getting it working though. I'm putting the code in a cljc file wrapped in a conditional as I need to target nbb and shadow-cljs#2022-10-2810:12juhoteperihttps://gist.github.com/Deraen/a699de28866c117566e7d0d3f9088440 Any idea if these infer-warnings on Reagent test suite are real problems, and if there is way to clear up the warnings? All seem to be from deftype declaration, not even about calling those methods. Maybe the problem is that these "private" methods are just extending Object and they aren't declared on any protocols?#2022-10-2815:45thhellerwhich shadow-cljs/cljs version do you use? looks like warnings on an older version that should be fixed?#2022-10-2815:52thhelleryou can also just set (set! *warn-on-infer* false) in the file to get rid of the warnings#2022-10-2815:34erwinrooijakkersI have a shadow-cljs.edn config that moves a folder using a build-hook as follows:
:prod {:target :browser
       :output-dir "resources/public/js/compiled"
       :asset-path "/js/compiled"
       :build-hooks
       [(build/move-directory
         "node_modules/@fortawesome/fontawesome-pro/webfonts"
         "resources/public/webfonts")]
        ...}}}
and same for dev. When using shadow-cljs release prod this build hook does not seem to move the files… Should it?
#2022-10-2815:34erwinrooijakkerssame hook does work for dev build via shadow-cljs compile dev#2022-10-2815:46thheller@erwinrooijakkers why is this a build hook in the first place? wouldn't a simple cp node_modules/@fortawesome/fontawesome-pro/webfonts resources/public/webfonts solve the same problem in a much simpler way?#2022-12-0917:05erwinrooijakkersit would. the reason it didn’t work was because the function was called copy-directory , not move. i do think it’s more logical to move this specific build step into a Makefile or so. thanks#2022-10-2815:47thhellerI can't see the implementation of your hook, I guess you are doing some dev filtering? shadow-cljs will call it for release the same way as dev#2022-10-2815:47thhellershadow-cljs compile dev the build is called prod? which is not a recommended build separation. dev/prod should be the same build#2022-10-2819:44Shako FarhadIs there any way to make shadow-cljs watch for file changes in a specific directory and have it call :after-load function? I tried this
:devtools {:watch-dir "public" :watch-path "/foo"}
But unfortunatly nothing happens. I have a folder with javascript files, and I am using (js/require "...") to require it in my react native project. I would like a change in the folder to trigger my :after-load function so that the changes become visible without having to reload the app.
#2022-10-2819:48thheller@shakof91 shadow only watches files relevant to the build. JS files provided by metro it doesn't watch and there is no way to make it watch that. there is also sort of no way to make it reload those unless you still have react-native hot-reload still active? which will interfere with shadow-cljs hot-reload, so kinda a tricky topic#2022-10-2819:52Shako FarhadThat is understandable. I will just activate "Fast refresh" when I am working in javascript world and disable it when I am in cljs world. This works, so not a blocker at all! 😄 Thank you for the quick answer!#2022-10-2821:35Lone Rangeris there a way to connect the browser repl to an existing build (for use with nREPL)? stupid console.log isn't playing well with my nREPL, seeing if shadow does better for me#2022-10-2904:51thhellerI do not understand the question. yes, nrepl is supported. not a clue what you mean by console.log isn't playing with nrepl? the two are in no way related?#2022-10-2904:52thhellernpx shadow-cljs cljs-repl the-build or if you are connected to a CLJ nrepl already (shadow.cljs.devtools.api/repl :the-build)#2022-10-2906:15thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#build-repl#2022-10-3020:38shawnhello. Is there a way to apply a babel transform plugin directly to shadow-cljs rather than trying to solve it by applying it post-js compilation? The one I had in mind is https://www.npmjs.com/package/babel-plugin-relay . I've seen a few ways that this had been used for vite and esbuild as well. Thank you#2022-10-3020:44thhellerno, since shadow-cljs doesn't use babel for most code#2022-10-3020:51shawnthank you. would a good option be to work with https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external and then use the build tool of choice to complete the process? If so, would there be a way to feed it back into shadow-cljs such that it can be served through clojure instead of a js-server?#2022-10-3020:54thhellerthat depends on the build tool you use#2022-10-3020:54thhellerif it outputs a regular .js file then yes#2022-10-3020:54thhellerif it requires running the server during dev (eg. vite) then it won't#2022-10-3020:57shawnwonderful. thank you very much for shadow-cljs and for your help! I'll try this out now#2022-10-3022:18shawnhi again. I tried the following and seem to be stuck with trying to split up the build process between shadow-cljs and babel. The following is the cleanest path I could think of: 1. run shadow-cljs compile app using this edn:
{:lein         {:profile "+shadow-cljs"}
 :builds       {:app {:target     :browser
                      :output-dir "resources/public/js"
                      :asset-path "/js"
                      :modules    {:app {:init-fn reagent-project.core/init!}}
                      :js-options
                      {:js-provider :external
                       :external-index "target/index.js"}}}
 :dev-http     {3000 {:root    "resources/public"
                      :handler reagent-project.handler/app}}}
2. run babel target/index.js --out-file resources/public/js/libs.js 3. run shadow-cljs watch app I noticed that the intermediate compiled file at target/index.js is as shown:
// WARNING: DO NOT EDIT!
// THIS FILE WAS GENERATED BY SHADOW-CLJS AND WILL BE OVERWRITTEN!

var ALL = {};
ALL["relay-runtime"] = require("relay-runtime");
ALL["react-dom/client"] = require("react-dom/client");
ALL["react-relay"] = require("react-relay");
ALL["react"] = require("react");
global.shadow$bridge = function shadow$bridge(name) {
  var ret = ALL[name];

  if (ret === undefined) {
     throw new Error("Dependency: " + name + " not provided by external JS. Do you maybe need a recompile?");
  }

  return ret;
};

shadow$bridge.ALL = ALL;
and as such, the final build file /resources/public/js/libs.js shows the same. I was wondering if there's an obvious or few obvious things that I'm missing from this. I also tried to follow the guidance on https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external , but realized that I don't have an index.html file. I'm not exactly sure what the entry point is for an app. I apologize for the noob-ness of this question as I'm new to ClojureScript. Thank you!
#2022-10-3102:38shawnI tried creating a simpler project to get this working instead of the reagent template:
{:deps {:aliases [:cljs]}
 :builds {:app {:target :esm :output-dir "resources/public/assets/js"
                :modules {:main {:init-fn app.core/init}}}}
 :dev-http {3000 "resources/public"}}
and then tried to complete the build by running it through vite with the babel plugin wrapped in vite-plugin-relay, but am still seeing an error which I'm reading to mean that the plugin had not been applied, although I've been able to get it to work for projects outside of clojurescript
#2022-10-3105:32shawnI'm seeing that when running standard jsx, I'm able to track the transformation. I wasn't sure if shadow-cljs can be configured such that it outputs code that reads similarly. vite code:
import _AppQuery from "./__generated__/AppQuery.graphql";
import React from "react";
import { graphql, useLazyLoadQuery } from "react-relay";
export default function App() {
  const data = useLazyLoadQuery((_AppQuery.hash && _AppQuery.hash !== "fe6589af5b8bfbe9722d3b296cc93444" && console.error("The definition of 'AppQuery' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _AppQuery), {});
  return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement("h1", null, /* @__PURE__ */React.createElement("a", {
    href: "",
    target: "_blank"
  }, "SpaceX"), " ", "Data Viewer"), /* @__PURE__ */React.createElement("h2", {
    id: "ships-heading"
  }, "Ships"), /* @__PURE__ */React.createElement("ul", {
    "aria-labelledby": "ships-heading"
  }, data.ships?.map(ship => /* @__PURE__ */React.createElement("li", {
    key: ship?.id
  }, ship?.name))));
}
shadoww-cljs compiled js:
import "./cljs_env.js";
goog.provide('app.core');
var module$node_modules$react_dom$client=shadow.js.require("module$node_modules$react_dom$client", {});
var module$node_modules$react_relay$index=shadow.js.require("module$node_modules$react_relay$index", {});
app.core.query = module$node_modules$react_relay$index.graphql`
query app_pages_homeQuery {
                            rates(currency: "USD") {
                              currency
                              rate
                            }
                           }
`;

/**
 * testing
 */
app.core.gql = (function (){var G__32142 = (function app$core$gql_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32143 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);

var map__32146 = (app.core.query.cljs$core$IFn$_invoke$arity$1 ? app.core.query.cljs$core$IFn$_invoke$arity$1(module$node_modules$react_relay$index.useLazyLoadQuery) : app.core.query.call(null,module$node_modules$react_relay$index.useLazyLoadQuery));
var map__32146__$1 = cljs.core.__destructure_map(map__32146);
var rates = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32146__$1,new cljs.core.Keyword(null,"rates","rates",-990130920));
var map__32147 = rates;
var map__32147__$1 = cljs.core.__destructure_map(map__32147);
var currency = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32147__$1,new cljs.core.Keyword(null,"currency","currency",-898327568));
var rate = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32147__$1,new cljs.core.Keyword(null,"rate","rate",-1428659698));
return helix.core.get_react().createElement("div",(function (){var obj32149 = ({"key":currency});
return obj32149;
})(),helix.core.get_react().createElement("p",null,currency,": ",rate));
});
if(goog.DEBUG === true){
var G__32150 = G__32142;
(G__32150.displayName = "app.core/gql");

return G__32150;
} else {
return G__32142;
}
})();




/**
 * A component which greets a user.
 */
app.core.greeting = (function (){var G__32152 = (function app$core$greeting_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32153 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);
var map__32156 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32153,(0),null);
var map__32156__$1 = cljs.core.__destructure_map(map__32156);
var name = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__32156__$1,new cljs.core.Keyword(null,"name","name",1843675177));

return helix.core.get_react().createElement("div",null,"Hello, ",helix.core.get_react().createElement("strong",null,name),"!");
});
if(goog.DEBUG === true){
var G__32157 = G__32152;
(G__32157.displayName = "app.core/greeting");

return G__32157;
} else {
return G__32152;
}
})();




 = (function (){var G__32160 = (function app$core$app_render(props__31358__auto__,maybe_ref__31359__auto__){
var vec__32161 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [helix.core.extract_cljs_props(props__31358__auto__),maybe_ref__31359__auto__], null);

var vec__32164 = helix.hooks.use_state(new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"name","name",1843675177),"Helix User"], null));
var state = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32164,(0),null);
var set_state = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32164,(1),null);
return helix.core.get_react().createElement(module$node_modules$react_relay$index.RelayEnvironmentProvider,(function (){var obj32168 = ({"environment":app.core.environment});
return obj32168;
})(),helix.core.get_react().createElement("div",null,helix.core.get_react().createElement("h1",null,"Welcome!"),helix.core.get_react().createElement(helix.core.Suspense,(function (){var obj32170 = ({"fallback":"loading..."});
return obj32170;
})(),helix.core.get_react().createElement(app.core.gql,null))),helix.core.get_react().createElement(app.core.greeting,(function (){var obj32172 = ({"name":new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(state)});
return obj32172;
})()),helix.core.get_react().createElement("input",(function (){var obj32174 = ({"value":helix.impl.props.or_undefined(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(state)),"onChange":(function (p1__32158_SHARP_){
var G__32175 = cljs.core.assoc;
var G__32176 = new cljs.core.Keyword(null,"name","name",1843675177);
var G__32177 = p1__32158_SHARP_.target.value;
return (set_state.cljs$core$IFn$_invoke$arity$3 ? set_state.cljs$core$IFn$_invoke$arity$3(G__32175,G__32176,G__32177) : set_state.call(null,G__32175,G__32176,G__32177));
})});
return obj32174;
})()));
});
if(goog.DEBUG === true){
var G__32178 = G__32160;
(G__32178.displayName = "app.core/app");

return G__32178;
} else {
return G__32160;
}
})();



app.core.init = (function app$core$init(){
if((typeof app !== 'undefined') && (typeof app.core !== 'undefined') && (typeof app.core.root !== 'undefined')){
} else {
app.core.root = module$node_modules$react_dom$client.createRoot(document.getElementById("root"));
}

return app.core.root.render(helix.core.get_react().createElement(,null));
});
goog.exportSymbol('app.core.init', app.core.init);

//# sourceMappingURL=app.core.js.map
#2022-10-3106:08thheller@concentric12_clojuria I do not know what kind of code the babel plugin expects. it might just not recognize the CLJS code, which seems likely.#2022-10-3112:32orestisHello! I'm using the functionality of importing literal js files, which makes my life easier on some fronts. But it seems that they get fed through Google Closure Advanced compilations which, given they don't have externs, screws things up by renaming stuff. What's the best way forward for me? So far I've gone to string-based properties but it's tedious.#2022-10-3112:37Lone Rangerprobably should just write the externs, makes the code a lot cleaner.#2022-10-3112:38Lone RangerYou can write your own externs, I don't know if you knew that. It's not that hard, although figuring out the tooling takes a few hours#2022-10-3112:39Lone Rangerhere's an example of an externs file I wrote four PouchDB
var pouchdb = function() {};
pouchdb.plugin = function() {};
pouchdb.plugin().auth = {};


var auth = {};
auth.default = {};

var perms = {};
var pfind = {};
pfind.default = {};

var pmemory = {};
pmemory.default = {};

pouchdb.logIn = function() {};
pouchdb.changes = function() {};
pouchdb.changes().on = function() {};
pouchdb.createIndex = function() {};
pouchdb.get = function() {};
pouchdb.put = function() {};
 = function() {};
pouchdb.remove = function() {};
pouchdb.allDocs = function() {};
pouchdb.find = function() {};
pouchdb.sync = function() {};
pouchdb.sync().on = function() {};
pouchdb.destroy = function() {};
pouchdb.bulkDocs = function() {};
pouchdb.getAttachment = function() {};
#2022-10-3112:39Lone Rangeralthough strangely enough, I haven't had to write externs like that since I started using shadow-cljs according to the guide. But that's what I used when I did figwheel#2022-10-3112:40Lone Ranger@U7PBP4UVA is this how you are importing your javascript? https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js#2022-10-3112:41orestisYes, requiring js files. For anything else I have :infern-externs :auto and just annotate with ^js as prompted. But for literal js files I get no warning, only runtime errors.#2022-10-3112:41Lone Rangerare those 3rd party libs or your libs?#2022-10-3112:42Lone RangerI'm just curious b/c I haven't had that issue for some reason and I use external js extensively#2022-10-3112:42orestisThe JS files are utility code that invokes ProseMirror stuff.#2022-10-3112:42orestise.g.
if (parent && parent.type.allowsMarkType(type)) {
here, the allowsMarkType gets renamed
#2022-10-3112:43Lone Rangerhmmmmm#2022-10-3112:43Lone Rangermaybe try turning off :inter-externs#2022-10-3112:43Lone Rangerb/c that shouldn't be renamed, or if it is renamed, it should be globally renamed#2022-10-3112:45orestisIt can't be globally renamed, since it's using an npm dependency#2022-10-3112:45Lone Rangerdo you have a precompilation step like webpack?#2022-10-3112:46orestisNo, just shadow cljs#2022-10-3112:46Lone Rangerotherwise it seems to just paste all the code into one file then aggressively rename stuff, so I wouldn't see why it wouldn't be globally renamed#2022-10-3112:46Lone Rangerwell one way you can check is to turn off renaming#2022-10-3112:46Lone Ranger:pretty-print true#2022-10-3112:46Lone Rangersomewhere#2022-10-3112:47orestisYep, it's on my list, I'm trying to reproduce the exact reported bug right now 🙂#2022-10-3112:47Lone Rangerlol I love telling people things they already know, it's so much easier than doing my own work 😅#2022-10-3112:47Lone Rangerhttps://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options#2022-10-3112:47thhellerthere is no externs inference for JS files. so it is expected that allowsMarkType would be renamed#2022-10-3112:48thhelleryou can sort of figure out what the original name is by using shadow-cljs release app --pseudo-names#2022-10-3112:48orestisI use --debug#2022-10-3112:48thhelleryeah, that works too#2022-10-3112:49thhelleran alternate is to not feed the JS files through :advanced. you do that by changing them to commonjs#2022-10-3112:49thhellermeaning require/module.exports instead of import/export#2022-10-3112:50thhelleronly ESM JS files go through advanced, regular commonjs is processed like all other npm files (ie. only simple)#2022-10-3112:55orestisAh, using common.js is easier than trying to write externs, thanks @U05224H0W - why should ESM files be advanced though? Is there the expectation that an npm library that produces ESM will also get renamed?#2022-10-3112:55thhellerwell you lose some stuff by going to commonjs. the files can no longer import CLJS code directly#2022-10-3112:56thhellerso ESM is preferred and recommended#2022-10-3112:56thhellerwriting externs also takes like 5min https://shadow-cljs.github.io/docs/UsersGuide.html#_simplified_externs#2022-10-3112:56thhellerwell I guess that depends on how it takes for you to find them 😉#2022-10-3112:57orestisProseMirror actually has a well-defined Typescript API, not sure if that's consumable somehow#2022-10-3112:57orestisBut the actual use case I have for JS files is mainly copied code that is too cumbersome to rewrite to CLJS 😄#2022-10-3112:57thhellerthere is not no#2022-10-3112:59thhellerI mean there could be a tool that collects all property names in JS files and just adds them to externs#2022-10-3113:00thhellerwouldn't be totally accurate since not everything needs externs but could be useful#2022-10-3113:00thhellerturning of all renaming unfortunately makes the build rather large, since CLJS generates rather long property names for stuff#2022-10-3113:01Lone Rangerhttp://www.dotnetwise.com/Code/Externs/ https://www.npmjs.com/package/tsd2cce FYI#2022-10-3113:02thhelleroh the second might be useful but be sure to check the build size after#2022-10-3113:04thhellergenerating too many unneeded externs can have negative effects if you care about build size at all#2022-10-3113:06orestisThanks @U3BALC2HH @U05224H0W - for now I'm just converting my handful of JS files to common.js, ProseMirror has a large enough API surface to make writing externs for it a nuisance. Most of our code is using it from CLJS anyway, the JS files are mostly utilities.#2022-10-3116:18jpmonettashi everybody. Let's say there is a instance of shadow watching some :app build id, and I connect to the shadow nrepl server, is there a way of compiling and evaluating a form under some namespace for my :app build id ? I know I can convert the repl to a cljs one, and then eval there, but I want to know if it is currently possible to do it from the clojure repl.#2022-10-3116:19jpmonettassomething like retrieving the repl environment by build id#2022-10-3116:23thheller(shadow.cljs.devtools.api/cljs-eval :app "(js/console.log ::foo)" {:ns 'foo.bar})#2022-10-3116:23jpmonettasnice! thanks!#2022-10-3118:49jpmonettas@U05224H0W is there an easy way of getting that build-id env? so I can call things like cljs.analyzer.api/resolve, which requires the env#2022-10-3120:36thheller(shadow.cljs.devtools.api/compiler-env :app) but its not the env required for resolve, its the compiler env usually bound to cljs.env/*compiler* atom#2022-10-3120:36thhellerI think there is a cljs.analyzer.api/with-compiler-env macro or so where this would go#2022-10-3120:38jpmonettasthanks a lot! will try to experiment with that#2022-10-3121:24dehliHi, we're using shadow-cljs + esm for our front end and just upgraded to 2.20.7. Wanted to share that it shaved off ~25% from our bundle size w/o any changes needed. Awesome work and thanks!#2022-11-0104:27alexThat's great! Would love to hear a bit more about what changes you made in your config as well as any shadow-cljs changes you're aware of that contributed to the dramatic decrease in bundle size#2022-11-0106:03thhellerprobably only this change https://github.com/thheller/shadow-cljs/commit/723fbf0075c8a06ba452104b61fb97ca6609f573#2022-11-0106:04thhellerwith using :js-provider :import (ie. shadow-cljs not in charge of bundle npm dependencies)#2022-11-0106:04thhellerJS tools have better tree-shaking for npm deps than shadow-cljs currently#2022-11-0111:55dehliYep! We're using :js-provider :import along w/ webpack and the commit above made our webpack bundle much smaller 🎉#2022-11-0115:44alexAwesome! As an aside, we are currently lazy-loading modules in our app. Do you think a similar change would benefit us? It's been a while since I revisited this, but if I recall correctly, :js-provider :import bundles all npm deps into a single file to be fed into the external JS bundler. Since modules are loaded all or nothing, would this mean all our deps would be loaded as soon as our first "app" module required a dep? in a lazy-loaded/code-split environment, the benefit is not as clear-cut right? maybe it's still worth the reduced bundle size -- i might have to experiment 🙂#2022-11-0116:07dehliFrom my understanding, :js-provider :import doesn't do any bundling of the JavaScript dependencies and instead leaves that to some other tool (in our case webpack).#2022-11-0116:23alexAh yes, sorry I used "bundle" incorrectly. I meant to communicate that shadow-cljs puts all of the JS require calls (dependencies) into a separate file, then lets the external tool do the bundling/tree-shaking#2022-11-0116:30dehliAhhh, we're not doing code splitting yet so I'm not sure how it would work w/ that. If you do end up experimenting some, would be interested in your findings!#2022-11-0118:12thheller@UGGU8TSMC you are thinking of :js-provider :external. thats different. :js-provider :import fully supports code splitting as well, :external puts all JS deps in one file and is not splittable#2022-11-0118:12thhellerwhether or not you'd benefit by :import depends on the npm deps you use. not all are tree shakeable#2022-11-0119:25alexAh thank you for clearing that up!#2022-11-0211:57tggSorry for the obtuse question but how would I get started using :js-provider :import over :js-provider :external would I just need to hand roll a js file for the requires? I’m not sure how they’d be exposed to shadow-cljs. I’ve got a 1mb production artifact I’m convinced could be split down some.#2022-11-0213:21dehliThe way I did it was I created a webpack config with the entrypoint being a javascript file looking like this. main corresponds to the module that I have defined in my shadow-cljs.edn file.
if (process.env.NODE_ENV !== "production") {
  require("./.shadow-cljs/cljs-runtime/shadow.cljs.devtools.client.browser.js");
}
import init from "./.shadow-cljs/main.js";
init();
#2022-11-0216:11tggI don’t suppose you have anything on github I can look at? 😄 Does this mean that the requires within the shadow-cljs app are picked up by whatever js build tool? That’s nice. That’s very nice.#2022-11-0216:40dehliI actually wrote a note to put together a blog post with what I did since it's not part of an open-source project so will tag you when that gets done 👍 what I ended up doing was disabling webpack hot-reloading and I let shadow-cljs do all the reloading.#2022-11-0216:42tggAwesome, if I wrap my head around it fully I’d write something myself. I do find some of the latter esm stuff a bit hard to understand at times 😅#2022-11-0216:42thheller@U2U78HT5G if all you need is to run init you can just use :init-fn in the build config. no need for exports then. also the extra conditional require shouldn't be required at all. you can just point webpack directly at the shadow-cljs output#2022-11-0216:44dehliThanks! I'll make those changes to clean up the code a bit 🙂#2022-11-0413:57dehliHi again, I just wrapped up the blog post this morning. I think I included all the changes I made as part of the migration but if anything doesn't make sense feel free to reach out! https://deh.li/2022/11/04/shadow-cljs-webpack.html#2022-11-0417:18thheller@U2U78HT5G please note that it is not necessary to have two builds like this. splitting dev/advanced build is already handled by the watch/release commands. the config can be the same for both builds#2022-11-0417:19thhellerso in your case just
;; shadow-cljs.edn
{:builds
 {:web
  {:target :esm
   :output-dir ".shadow-cljs"
   :devtools {:watch-dir "resources/public"}
   :js-options {:js-provider :import}
   :modules {:main {:init-fn com.vistaly.web.core/init!}}}
  }}
is all you need
#2022-11-0417:20thhelleron a second note though please consider using another :output-dir. the .shadow-cljs dir is for shadow-cljs internal runtime files and caches. at some point this may create conflicts and either create problems in your builds or shadow-cljs internally#2022-11-0417:20thhellerrelease also sets goog.DEBUG false, so no need to specify it. it also defaults to :optimizations :advanced#2022-11-0417:28dehlithanks for your feedback! i will update the post. in actuality my output-dir is nested in another directory which is why I hadn't gotten any issues but I will make changes so people don't mistakenly clobber their internal runtime files#2022-11-0417:31dehlidid you purposefully exclude :infer-externs :auto ?#2022-11-0417:32thhellerits also the default#2022-11-0417:32dehliawesome 🙂#2022-11-0509:30tgg0.81MB compressed is so nice for an app that complex, congrats 🎉 is this having our cake and eating it too?#2022-11-0114:15pezWhat am I missing here? I have a file util.cljc :
(ns util
  #?(:clj (:refer-clojure :exclude [slurp]))
  #?(:cljs (:require-macros [util])))

#?(:clj
   (defmacro slurp [file]
     (clojure.core/slurp file)))
And a file parse.cljs:
(ns parse
  (:require [util :refer [slurp]]))

(comment
  (slurp "shadow-cljs.edn")
  )
Then I need to load parse.cljs twice to use the macro:
% npx shadow-cljs node-repl
shadow-cljs - config: /Users/pez/Projects/sass2garden/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
[2022-11-01 15:10:18.802 - WARNING] TCP Port 9630 in use.
[2022-11-01 15:10:18.805 - WARNING] TCP Port 9631 in use.
shadow-cljs - server version: 2.20.7 running at 
shadow-cljs - nREPL server started on port 54616
cljs.user=> shadow-cljs - #4 ready!
(load-file "src/main/parse.cljs")
[]
cljs.user=> (in-ns 'parse) 
nil
parse=> (slurp "shadow-cljs.edn")

Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of undefined (reading 'call')
:repl/exception!
parse=> (load-file "src/main/parse.cljs")
[]
parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n  \"src/main\"\n  \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"
parse=> 
#2022-11-0116:23localshredIn clojurescript you have to require macros separately using :require-macros in the ns form https://clojurescript.org/guides/ns-forms#_macros#2022-11-0116:24localshredYou're using :require-macros in util ns but not in the parse ns. My guess is you just need to tweak that to use your slurp macro#2022-11-0116:52pezHmmm, since I am using :require-macros from util.cljc, things should be good, right? It's equivalent to, util.cljs:
(ns parse
  (:require [util :refer [slurp]]))

(comment
  (slurp "shadow-cljs.edn"))
+ util.clj:
(ns util
  (:refer-clojure :exclude [slurp]))

(defmacro slurp [file]
  (clojure.core/slurp file))
And I get the same strange behaviour if I do it like that. Loading parse.cljs twice makes it work.
#2022-11-0117:56thhellermight be a bug. does (require 'parse) (parse/slurp ...) work?#2022-11-0117:57thhellermaybe you want to use this instead? https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2022-11-0119:45pezI'll try the shadow.resource way. Doesn't matter much for my current use case, but seems like something that I should be using generally.#2022-11-0119:46pezAs for the macro problem. It is quite strange. I get different results with require, but it doesn't quite work as I expect.
cljs.user=> shadow-cljs - #4 ready!
(require 'parse) 
nil
cljs.user=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------

cljs.user=> (in-ns 'parse)
nil
parse=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------

parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n  \"src/main\"\n  \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"
#2022-11-0119:50pezAnd trying with both qualified and non-qualified with load-file:
cljs.user=> shadow-cljs - #4 ready!
(load-file "src/main/parse.cljs")
[]
cljs.user=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------

cljs.user=> (in-ns 'parse)
nil
parse=> (parse/slurp "shadow-cljs.edn")
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:2
 Use of undeclared Var parse/slurp
--------------------------------------------------------------------------------

parse=> (slurp "shadow-cljs.edn")

Execution error (TypeError) at (<cljs repl>:1).
Cannot read properties of undefined (reading 'call')
:repl/exception!
parse=> (load-file "src/main/parse.cljs")
[]
parse=> (slurp "shadow-cljs.edn")
";; shadow-cljs configuration\n{:source-paths\n [\"src/dev\"\n  \"src/main\"\n  \"src/test\"]\n\n :dependencies\n []\n\n :builds\n {}}\n"
#2022-11-0120:10thhellercould be that the REPL just forgets to load the macros#2022-11-0120:11thhellertoo tired to check now. feel free to open an issue, so I don't forget to check#2022-11-0120:21pez👍#2022-11-0122:59pezWhen writing the issue and trying to minimize it further, I notice that my repro with require was crap. It does work with require, it is with load-file it doesn't work. I also found out another interesting detail <- click-bait https://github.com/thheller/shadow-cljs/issues/1059#2022-11-0118:17Raymond KoIf you are targeting a :node-library and have to use :js-provider :require (for mariadb since it has syntax the Closure compiler does not understand right now), is there anyway to get shadow-cljs to import a ESM module? I tried the "https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import" section in the User Guide, but I got ReferenceError: shadow_esm_import is not defined#2022-11-0118:21thhellerCurrently only :target :esm adds the proper code to make that work#2022-11-0118:22thhellermaybe you can use :target :esm instead?#2022-11-0118:24thhellerI guess you can also sort of make it work by adding :prepend "global.shadow_esm_import = function(s) { return import(s); };" to your build config#2022-11-0118:25Raymond KoI tried it, but I would have to change a quite a few things since it is a big project and I'm doing non-standard things. Many errors.#2022-11-0118:25Raymond KoI'll try your suggestion#2022-11-0120:12Raymond KoThat worked. I added it to :target-defaults :node-library :prepend . Thank you for your help.#2022-11-0121:06alexJust upgraded to shadow-cljs 2.20.7 in both deps.edn and package.json. Tried to run a build report via
npx shadow-cljs run shadow.cljs.build-report client js-provider-import-report.html
and ran into the following error
File: /Users/alex/code/icebreaker/src/icebreaker/config.cljc
failed to require macro-ns "icebreaker.macros", it was required by "icebreaker.config"
Error in phase :execution

FileNotFoundException: Could not locate digest__init.class, digest.clj or digest.cljc on classpath.
#2022-11-0207:33thhellerso it can't find the digest ns. This is a CLJ error, it is not from shadow-cljs. So I'm guessing you maybe don't have a deps.edn alias activated or something like that#2022-11-0207:51thhelleralso note that :js-provider :import will cause shadow-cljs to not bundle any npm dependencies. so your build report will shrink, depending on how many you used. it'll only contain cljs code after that. don't get mislead by that. the build will only work if something else provides those dependencies, so be sure to compare the final size. not the build reports.#2022-11-0214:40alexThanks, I'll look into the alias stuff. Our aliases haven't changed recently so I wonder if there was an underlying CLJ change that is now incompatible with our current setup Also appreciate the tip with :js-provider :import - that makes sense#2022-11-0123:34Drew VerleeI have cljs devtools installed with my shadow build > Installing CLJS DevTools 1.0.6 and enabling features :formatters :hints :async > But I still dont get the cljs encoded/formatted structures when i do console log. Any idea's on what i can try to get it to work?#2022-11-0215:57MegaMatthave you enabled this?#2022-11-0205:48thheller@drewverlee you mean you don't get the formatted structures? I have never used cljs-devtools, so I don't know about its options#2022-11-0211:19Drew VerleeCorrect, i don't get the formated structures.#2022-11-0211:20Drew VerleeUgh, thanks for understanding my meaning, looks like I dropped the word " don't". It's been a long couple of days...#2022-11-0216:14alexDrew, have you enabled "Enable Custom Formatters" in the Chrome Devtools Settings?#2022-11-0216:15alex#2022-11-0216:16alex(I'm assuming that you're logging to the browser, but that might be an incorrect assumption)#2022-11-0216:55Drew VerleeI'll check that i have them enabled, maybe they got turned off at some point.#2022-11-0218:06Drew Verleethat was the issue. 👍#2022-11-0217:11Sam Ritchiehey all, this might be obvious through trial but I can’t seem to get my head clear from the docs. I want to specify different sets of aliases for idfferent builds in my shadow-cljs.edn file. I know I can do this at the top level:
:deps {:aliases [:dev :storybook]}
but can I alternatively set different aliases for different builds?
#2022-11-0217:11thhellernot supported. why?#2022-11-0217:12Sam Ritchie@thheller as I am asking I am realizing that because this is just for DEVELOPMENT… I should just stuff everything in that I need for all builds (since this is just to get more dependencies)#2022-11-0217:12Sam Ritchie@thheller sorry… I was still in my head in library mode, thinking I didn’t want to ship extra dependencies#2022-11-0217:13thhellerindeed, extra dependencies don't hurt if you don't actually require them in code#2022-11-0217:13thhellerso just go wild and add everything#2022-11-0217:14Sam Ritchiethank you!#2022-11-0220:11Sam Ritchiehttps://www.npmjs.com/package/npm-all-packages#2022-11-0220:12Sam Ritchie@thheller every possible battery included#2022-11-0220:15thhellerhehe nice#2022-11-0302:40Chris McCormickDoes anybody know if there is a way to get Vim + Fireplace to default to a particular build instead of typing :CljEval (shadow/repl :app)? Would be cool if I could specify this in shadow-cljs.edn or similar.#2022-11-0305:48thhelleryour client has to initiate the switch to a specific build, so no there is no option for this in shadow-cljs#2022-11-0306:00eccentric JWhat's the best way to inline the value of a build-time env var like NODE_ENV?#2022-11-0306:01thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2022-11-0306:01eccentric JThank you! Should have looked there first#2022-11-0306:02thhellerwell I strongly recommend never using environment variables but people generally don't listen to me 😛#2022-11-0306:03eccentric JOh! What would you suggest instead? Or should I get that from the docs?#2022-11-0306:03eccentric JOhhh --config merge cmd#2022-11-0306:07eccentric JI'll use that instead#2022-11-0306:11thhellerdo you want to set an actual compile time constant? or is it actual runtime configuration, like actual env variables would be?#2022-11-0317:19eccentric JIt was an actual compile time constant#2022-11-0318:58eccentric JIs goog-define already defined or do I need to import the goog library?#2022-11-0319:03eccentric JNevermind, got it working was using it incorrectly#2022-11-0315:49brunex
[:app] Build failure:
Closure compilation failed with 5 errors
--- node_modules/@chakra-ui/descendant/dist/index.cjs.js:69
Transpilation of 'Not a class declaration' is not yet implemented.
--- node_modules/@chakra-ui/modal/dist/index.cjs.js:85
Transpilation of 'Not a class declaration' is not yet implemented.
--- node_modules/@chakra-ui/react-use-pan-event/dist/index.cjs.js:39
Transpilation of 'Not a class declaration' is not yet implemented.
--- node_modules/@chakra-ui/react/node_modules/@chakra-ui/utils/dist/index.cjs.js:999
Transpilation of 'Not a class declaration' is not yet implemented.
--- node_modules/@chakra-ui/system/node_modules/@chakra-ui/utils/dist/index.cjs.js:999
Transpilation of 'Not a class declaration' is not yet implemented.
Hi guys, getting these errors with shadow-cljs latest versions, any help ^^
#2022-11-0317:36eccentric JBy chance do you have the code anywhere? Or could you make a repo with the minimal reproduction case?#2022-11-0318:10thhellerthese are errors from the closure compiler. looks like the code is using features it doesn't support#2022-11-0318:10thhellercan't do much about that from the shadow-cljs side unfortunately#2022-11-0318:10thhelleronly option is using a secondary bundler as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-11-0318:11thhelleror here https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm#2022-11-0811:39brunex@U05224H0W when trying to use
:js-options
{:js-provider :external}
it throws a this error regarding react object? but the object shadow.js.shim.module$react is available … weird 😕
#2022-11-0818:05thhelleruhm :js-provider :external doesn't use this? did you maybe load the wrong code or some bad cache?#2022-11-0318:13Lone RangerIs there some equivalent of :figwheel-always for shadow-cljs? Specifically in relation to reloading javascript changes for things that aren't directly in the path of the init-fn ? I'm trying to use some sidecar files to not clutter up the program while I'm experimenting#2022-11-0318:13thhellernot sure I understand. what does "some sidecar files" mean?
#2022-11-0318:14Lone Rangersome scratch files#2022-11-0318:14thhellerah, so files not part of the regular build?#2022-11-0318:14Lone Rangerinstead of an inline comment block. Yeah exactly#2022-11-0318:14Lone RangerI guess a second build would do the trick?#2022-11-0318:14thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_lifecycle_hooks#2022-11-0318:14Lone Ranger:thinking_face:#2022-11-0318:14thhellerthere is :dev/always but that won't magically include the files in the build#2022-11-0318:15thhelleryou can use :preloads to add them though#2022-11-0318:15Lone Rangerwhoaaa, outstanding#2022-11-0318:18Lone Rangeryessss that was exactly it 👏 👏 👏#2022-11-0415:08prncHello 👋 I’m trying to use react-pdf-viewer w/ pdfjs and seeing this compilation error:
Failed to inspect file
  <elided>/node_modules/pdfjs-dist/build/pdf.js

it was required from
  <elided>/node_modules/@react-pdf-viewer/core/lib/cjs/core.min.js

Errors encountered while trying to parse file
  <elided>/node_modules/pdfjs-dist/build/pdf.js
  {:line 2118, :column 9, :message "Semi-colon expected"}
Might just be an actual problem with this version of pdfjs, but posting here in case it has something to do with compilation iteself --- has anyone seen this type of error during compilation? Thank you 🙏
#2022-11-0417:31thheller@prnc unfortunately this is an error in the closure compiler. usually code it doesn't support. nothing I can do on the shadow-cljs side about it. only option is using a different bundler for JS as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-11-0417:45prncNo worries @thheller — I was afraid that was the case, thank you so much for confirming!#2022-11-0419:10zalkyHi all: I'm trying to figure out how to use a custom middleware list with a shadow-cljs nREPL (cljs). The default cider stack contains one piece of middleware, wrap-out that redirects all std out to the cider REPL, which I personally find a bit of a pain to work with. Normally I would just remove it from the stack, but I haven't been able to figure out how to provide shadow with a custom middleware list. I've tried both ~/.nrepl/nrepl.edn and using the .shadow-cljs.edn {:nrepl {:middleware ...} option, which the docs say are supported, but neither seems to have the desired effect. In fact, the shadow nREPL server does not seem to want to recognize "ls-middleware" operation so I can verify what middleware is being loaded:
({:id "1a43aa3c-2865-4513-9a2b-51c1166e2e40",
  :op "ls-middleware",
  :session "8dc66073-fd36-4cf1-a6b0-936d59c1993b",
  :status ["done" "unknown-op" "error"]})
When I start up the same version of nREPL server and Cider outside of shadow, the above :op return the full list of middleware being loaded by the server, as expected. Am I doing something wrong? Any suggestions where I can go from here?
#2022-11-0419:21dpsuttonI believe you can tell cider to just not subscribe to out#2022-11-0419:23dpsuttonI’m about to get on a plane so can’t find it but there’s a way to not invoke that middle ware#2022-11-0419:24dpsuttonYou don’t need to exclude it from your middleware stack. Just not call the op “subscribe-out”#2022-11-0419:26zalkyOk, much appreciated! I'm myself just about to get in a car, but that sounds like a promising alternative to the workflow I've been using all this time (custom middleware list with just that one missing). I'll give it a shot next week.#2022-11-0419:11thhellerjust use your own nrepl server and add the shadow-cljs middleware#2022-11-0419:12thheller:nrepl {:middleware ...} should be fine but it is only additive. it'll not override or remove defaults#2022-11-0419:13zalkyAh, I see, that's why it was having no effect.#2022-11-0419:15zalkyThanks for the quick response! I'll try your suggestion.#2022-11-0421:21Sam Ritchiedouble checking my understanding here.. I am depending on an NPM library called “mathlive”. is it therefore not possible to use mathlive in my clojure namespace paths? I have a namespace mathlive.core , which compiles great. But if I do this:
(ns mathlive.core
  (:require ["mathlive" :as ml]))

(defn Mathfield [!state] [:div "testing"])
then I see this error:
TypeError: Cannot set properties of undefined (setting 'Mathfield')
triggered from this compiled js:
mathlive.core.Mathfield = (function mathlive$core$Mathfield(_BANG_state){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1057191632),"test"], null);
});
of course this restriction would make sense, for some reason I thought when this came up for the “mathbox” library I had decided that I WAS able to use namespaces like mathbox.core etc
#2022-11-0421:47Sam Ritchieit doesn’t seem to be a problem for a few of my namespaces to be mathlive.something; just this one, maybe since it is the first namespace to require the js “mathlive” dependency?#2022-11-0503:29thhellernot sure why this wouldn't work? should be fine#2022-11-0504:36Sam RitchieMathlive.Core is null, very weird. I will see if I can repro it with a smaller build #2022-11-0504:38thhellerdoes this lib maybe forcefully export a global mathlive JS variable? that would indeed clash with and destroy the CLJS namespace#2022-11-0504:38thhellersome js libs just set window.mathlive = whatever; or global.mathlive = whatever.#2022-11-0504:45Sam Ritchiedigging a bit, that makes sense#2022-11-0504:46Sam Ritchiehttps://github.com/arnog/mathlive/blob/ca7ed3001a14507961f12e8757254995c1931e7f/src/mathlive.ts#L102 this lives all around the codebase, he’s got it in a few spots#2022-11-0504:47Sam Ritchiehttps://github.com/arnog/mathlive/blob/f103f9c1e37f3804686565a76bf888e44abb0113/src/public/mathfield-element.ts#L1690-L1694#2022-11-0504:47Sam Ritchie@thheller probably out of luck here, yeah?#2022-11-0507:05thhelleryeah#2022-11-0421:21Sam Ritchieshould I be calling the library something like mathlive-cljs to fix this?#2022-11-0423:35eccentric JJust released my first production cljs frontend app https://www.crunchydata.com/pricing/calculator#2022-11-0423:51Lone RangerThat’s great! The calculator part or the whole site?#2022-11-0423:52eccentric JJust the calculator part. Rest of site is remix + TS for now #2022-11-0423:55Lone RangerWill be interested in hearing your thoughts on it if you ever have time, not sure the size of it but with larger more complex cljs apps I’m starting to struggle a little. Of course never done anything big in TS so maybe the browser is just a tough environment #2022-11-0423:58eccentric JThe web is vast and nebulous for sure. What parts are you struggling with?#2022-11-0500:01Lone RangerKeeping the code base understandable and maintainable with runtime sprawl #2022-11-0500:02Lone Rangerwebworkers, service workers, web workers and service workers but user disallows cookies, no web workers or service workers allowed but still need to run with gracefully degraded performance, etc. #2022-11-0500:03Lone Rangernot to mention cloud functions, nodejs, blah blah #2022-11-0500:04Lone Rangerand of course I’m trying to be a good dev and not write if statements everywhere, trying to write exstensible data types underlying a core layer of business logic that should remain essentially unchanged regardless of runtime #2022-11-0500:05Lone RangerAnd I never thought I’d ever say this but lack of inheritance is kind of becoming a problem #2022-11-0500:06Lone RangerAnd I know the answer is “just use maps”… and that’s how it started of course #2022-11-0500:07Lone Rangerbut the browser is too permissive, it doesn’t crash, errors just start to accumulate and it’s not obvious at first #2022-11-0500:08Lone Rangernils being both logically false AND the default return value of a function that crashes AND a missing key is kind of a rough overlap #2022-11-0500:10Lone RangerAnyway all these things have answers and those answers are called macros but as a result my code base is starting to look less and less like recognizable earthling cljs and more Martian #2022-11-0500:12Lone RangerShadow cljs has been pretty clutch tho, thanks @thheller , super grateful #2022-11-0500:32eccentric JI think it comes down to two key things: Either coming up with an architecture that can be adapted to as many use cases as possible, where you can model most if not all problems in a similar way. My goto is using event-streams with Bacon.js and reagent atoms. Alternatively, it's ok to start out rough and refine as you go along. The first version of the price calc I had implemented almost all in one file, then when I got inspiration for a better design and architecture that fit my needs, I refactored. Because I started loose, I also had early progress to show stakeholders.#2022-11-0500:34eccentric Jnil doesn't have to be the missing key return. When I need distinction I use (get a-map :my-key ::not-found) or (:my-key a-map ::not-found)#2022-11-0500:36Lone Rangerthat’s true, but ::not-found is logically true except by convention. And then you’ve started on the slippery slope. Because then you need a class of predicates that treats ::not-found as false. And the long tail of that is a cascade of issues. However I do think that what you said about showing early rapid progress to stakeholders is incredibly important #2022-11-0500:37Lone RangerI’ve found the sweet spot for cljs in one-off internal tools that need to be made quickly and high quality but don’t need a lot of coordination to make #2022-11-0500:39eccentric JI haven't ran into that with my medium sized internal prototypes or the side projects I've taken on. The only time I find myself having to use conditionals is when I am trying to express behavioral optionality, have not had to use them for safety#2022-11-0500:56eccentric Jhttps://gist.github.com/eccentric-j/6c19f2b57513c90ddde4b37c992746d1 here's a sample of the app#2022-11-0500:57eccentric JIt does the calculations reactively and if something results in nil it doesn't break anything#2022-11-0500:59eccentric JAdded more of the UI#2022-11-0501:09Lone RangerAwesome! Thank you for sharing. And great work. I think cljs is very challenging and a lot of respect for anyone that does it commercially #2022-11-0501:19eccentric JIt can be, it did take me about 3 attempts to learn clojure before it clicked, but once I spent a year learning functional programming in js, clojure really clicked and have been really enjoying it ever since but I think it depends on the team. For example, the backend team wrote an article on why they chose Ruby in 2022. It's because it was familiar, they liked the repl experience for dealing with production issues, the team had experience with it, and they were interested in learning how to make the most of it warts and all. https://www.crunchydata.com/blog/crunchy-bridges-ruby-backend-sorbet-tapioca-and-parlour-generated-type-stubs#2022-11-0604:25wevremIs there a restriction on using namespace app? I was trying to make a very minimal example and my :init-fn is app/init and I get errors stating “Error: Namespace ‘app’ already declared” and “An error occurred when calling (app/init)” “TypeError: app.init is not a function”. That’s on the first load of the page. If I save a file in the project, shadow recompiles and reloads the browser and I don’t get the errors. But on a fresh reload I get the errors back again. If I change my namespace to something else, like myapp, no errors. If I move the file down into a subdirectory, so the namespace is , no errors. But I can’t seem to use just plain app directly under my ‘src’ directory as my main entry point.#2022-11-0605:32thhellershould be fine, but be aware that it easily clashes with other variables you might have in your JS. maybe you have a app variable like var app or from somewhere else?#2022-11-0605:33thhellerbut there was another issue with single segment namespaces. maybe thats related somehow, didn't look into it yet. https://github.com/thheller/shadow-cljs/issues/1059#2022-11-0615:51wevremI did some more testing and it turns out I can’t use the same name for both (1) the namespace hosting the module’s :init-fn and (2) the id of the DOM element that reagent will render into. I’m not expert enough to understand why that is the case, but I’ve isolated the collision to those two places.#2022-11-0721:05pezI'm using the :node-library target for reaching a ClojureScript library from a JS script. It works fine except that when I watch my build, and then run my JS script, it never exits. If I don't watch the build, then things are all fine. Is there something I can do to be able to watch the build and be able to call functions in the library that don't keep my calling script hanging?#2022-11-0721:50thheller@pez :devtools {:enabled false} in the build config#2022-11-0810:12Harel LidarHey, when trying to import a javascript library I get the following error: Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/harellidar/Documents/Work/product-and-marketing/delivery-page/node_modules/capture-website/index.js from /Users/harellidar/Documents/Work/product-and-marketing/delivery-page/dist/spiritt/delivery-page.cjs not supported. Instead change the require of index.js in /Users/harellidar/Documents/Work/product-and-marketing/delivery-page/dist/spiritt/delivery-page.cjs to a dynamic import() which is available in all CommonJS modules. Does anyone know how to solve this issue?#2022-11-0810:20thhellersorry, on my way out. easy error to google. basically node cannot import ES module code from commonjs. you can maybe switch your build to use :target :esm, see docs.#2022-11-0810:29Harel LidarTried changing target to esm and runtime to node and now im getting: The required JS dependency "node:process" is not available Any help with this?#2022-11-0818:01thhellerfor node you want to set this https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration#2022-11-0818:01thheller:js-options {:js-provider :import}#2022-11-0810:20thhellerback in a couple hours#2022-11-0909:57bitbltHello! I'm using tailwindcss in a shadow-cljs (re-frame) project. When making release builds (using npm run release ) I notice that various css classes that use the data variants (https://tailwindcss.com/blog/tailwindcss-v3-2#data-attribute-variants) like data-[enabled=true]:bg-red-800 are not included in the generated css file. I suppose it is some kind of obfuscation problem where shadow-cljs obfuscates the class names in the output code and tailwindcss cannot properly detect in the optimized output that they are used? Anybody encountered this?#2022-11-0909:58thhellershadow-cljs never touches or optimizes raw strings, so this shouldn't affect anything#2022-11-0910:01thhellerwhat do you use as the inputs for tailwind jit?#2022-11-0910:01thhellerthe release output files or the sources?#2022-11-0910:01bitbltWell I for example I can see in the generated css output this: Using rm -rf resources/public/{js,css}; npx shadow-cljs compile app; NODE_ENV="production" TAILWIND_MODE="build" ./node_modules/.bin/tailwindcss -i tailwind.css --config tailwind.config.js -o resources/public/css/site.css
.group[data-edit=false] .group-data-\[edit\=false\]\:hidden {
  display: none;
}

.group[data-edit=true] .group-data-\[edit\=true\]\:hidden {
  display: none;
}
While using rm -rf resources/public/{js,css}; npx shadow-cljs release app; NODE_ENV="production" TAILWIND_MODE="build" ./node_modules/.bin/tailwindcss -i tailwind.css --config tailwind.config.js -o resources/public/css/site.css (with only difference being npx shadow-cljs release instead of compile)
.group[data-edit\x3dfalse] .group-data-\[edit\\x3dfalse\]\:hidden {
  display: none;
}

.group[data-edit\x3dtrue] .group-data-\[edit\\x3dtrue\]\:hidden {
  display: none;
}
#2022-11-0910:04thhellerhmm where do those \x3d come from?#2022-11-0910:04thhellerare they in the JS or does tailwind generate them for some reason?#2022-11-0910:04bitblt@thheller I'm using tailwindcss jit with
"resources/public//**/*.js",
    "resources/public//**/*.html"
as the sources btw
#2022-11-0910:05bitblt@thheller I don't know, I made two identical builds with the commands showed above, took the css files from both builds into nvim -d to diff them and saw this#2022-11-0910:05thhellerhmm this seems to be the closure compiler#2022-11-0910:06bitbltI tried searching/reading the obfuscated js output but it is damn impossible#2022-11-0910:07thhellerok, the closure compiler does this for safety. escaping everything that may lead to XSS attacks#2022-11-0910:07thhellerso <>= etc#2022-11-0910:08thhellertailwind just doesn't translate it "back" when generating css#2022-11-0910:08thhellerI can add a config flag to disable this, so the closure compiler leaves everything as is#2022-11-0910:08thhellerbut the default actually makes things safer, so ideally this would be fixed in tailwind?#2022-11-0910:09thhellermaybe you can just search and replace \x3d with =?#2022-11-0910:11bitbltI'm using tailwind using this build hook https://github.com/teknql/shadow-cljs-tailwind-jit and I do not track the generated outputs in order to fix them.. I just ended up with the poc above trying to find the problem#2022-11-0910:12bitbltI also see that tailwind generates some classes that include \x3d in the non release builds#2022-11-0910:13bitbltI suppose that a fix in tailwind would be the correct solution, I just don't know how to express it#2022-11-0910:14bitbltAlso I'm starting to doubt if I should use sources or the generated clojurescript output as inputs#2022-11-0910:14thhellerwell I absolutely do not recommend the hook approach this lib uses#2022-11-0910:14thhellerbut that is irrelevant to this particular problem#2022-11-0910:14thhellerand I recommend running over the output not the sources#2022-11-0910:15bitbltI do run tailwind over the output, mind explaining the reason? I suppose for the pruned/optimized outputs?#2022-11-0910:18thhellerwell, :advanced may have removed some tailwind string that you didn't use but still have in the sources#2022-11-0910:18thhellerif you run over the sources they'll end up in your css#2022-11-0910:18thhellerif you run over the output they'll be gone completely#2022-11-0910:19bitbltYeah makes sense#2022-11-0910:20bitbltCould you mind explaining how the = \x3d replacement works in clojurescript compiler in order to report it upstream in tailwindcss?#2022-11-0910:22thhellerit has a "trusted strings" option, which defaults to false. ie. it doesn't trust strings in the source, and to be safe escapes certain characters (eg. <>=) with \x3d etc#2022-11-0910:22thhellerI'm not entirely sure how you'd attack such a thing with your own sources, but I guess its there for good reason#2022-11-0910:23thhellerhttps://github.com/thheller/shadow-cljs/commit/5cf0ea00a08e4de75d30465a9d84b8ad6846e2f8#2022-11-0910:23thhellerI just added the option to disable this, if you want I can make a release for that#2022-11-0910:24thhellerI generally do not like turn off safety things by default, so this is opt-in but would fix your problem probably#2022-11-0910:24bitbltYes, thank you this would be awesome!#2022-11-0910:27thheller2.20.8 and :compiler-options {:trusted-strings true} in your build config#2022-11-0910:41bitbltIt works, thank you#2022-11-0910:41bitbltIt is probably one of the fastest upstream releases I've ever seen#2022-11-0910:42thhellerI'm sitting here waiting for a delivery. so basically idle anyways 😛#2022-11-0910:43bitbltShould we report this to tailwind?#2022-11-0910:43thheller"we" won't, but you can 😉 too busy to follow this through on the tailwind side myself. also don't use tailwind anymore 😉#2022-11-0911:01bitblthttps://github.com/tailwindlabs/tailwindcss/issues/9779#2022-11-0911:01bitbltAnything to add?#2022-11-0911:28thhellerwell you could make a repro with just a dummy script and showing what the output is#2022-11-0911:28thhellerand then just that the closure compiler generates such sources, doesn't really need to be involved in the repro#2022-11-1012:26jpmonettashi everybody! I'm connecting to a shadow-cljs nrepl server (clojure side) and trying to get a cljs fn source like (cljs.repl/source-fn env 'cljs.core/first) but I don't have an environment. I know I can get the compiler environment for a build-id with shadow.cljs.devtools.api/compiler-env but most functions I want to use require the analysis env instead. Is there a way of calling this functions? I know how to call them with macros at macroexpansion time by using the analysis environment provided as &env but I would like to do it from the clojure repl.#2022-11-1017:15thhellercould you explain what you are trying to do exactly? I mean macros are macros and calling them as functions doesn't work#2022-11-1017:17thhelleroh nvm. source-fn is not a macro#2022-11-1017:18thhelleryou can get a env via (cljs.analyzer/empty-env). it expects *cljs-ns* to be bound for the current ns though#2022-11-1017:19thhelleror I guess the default cljs.user also works depending on what you are trying to do?#2022-11-1018:13jpmonettasnice, the empty-env did the trick. I also need to bind the cljs.env/compiler like this :
(binding [cljs.analyzer/*cljs-ns* 'cljs.user
          cljs.env/*compiler* (atom (shadow.cljs.devtools.api/compiler-env build-id))]
  (repl/source-fn (ana/empty-env) symb))
#2022-11-1018:13jpmonettasthanks @U05224H0W!#2022-11-1020:17Lone Rangeris it possible to recover from a build failure without restarting the process?#2022-11-1021:25dehliif you go to localhost:9630 I think you can recompile from there#2022-11-1023:56Lone Ranger(⌐■_■) ( •_•)>⌐■-■ (o_O) what is this magical place!#2022-11-1105:43thhellerwatch will just recompile if you change something?#2022-11-1122:05Lone Rangerbut if it never connected to the repl in the first place, how will it know if I change something?#2022-11-1122:05Lone Rangeroh, it just does, that's how#2022-11-1122:05Lone Rangerniiiiiice#2022-11-1114:29Ferdinand BeyerI see a really strange behaviour in my shadow-clhs build. I’m using the :npm-module target and the default :advanced optimizations in a Release build. The module output for clojure.string.js changes depending on whether I use remove-watch in my code or not. Without, everything works fine, and the file’s second line starts like this:
'use strict';var Sl,Ul;$CLJS.Fh=function(a,b){return $};Sl=function(a,b){var c=Array(a.length-2);$CLJS.fc...
When I refer to remove-watch, then this line looks like this, skipping the creation of the Fh function:
'use strict';var Sl,Ul;Sl=function(a,b){var c=Array(a.length-2);$CLJS.fc(a,0,c,0,2*b);$CLJS.fc....
But $CLJS.Fh is later used in the same file, e.g.:
$CLJS.ae.prototype.nd=$CLJS.Fh(27,function(a,b,c)...
And I get a JavaScript error that $CLJS.Fh is not defined. Took my a lot of time and frustration to narrow it down to remove-watch… What’s special about that var? Any ideas?
#2022-11-1114:55Ferdinand BeyerI noticed that the Fh definition is moved to taoensso.encore.js when I use remove-watch, but this file is not required by clojure.string of course#2022-11-1115:47Lone RangerWhy not pretty print it ?#2022-11-1115:48Lone RangerCan’t remember the exact settings but configure it to not shorten the names, use the originals to get better insight #2022-11-1117:16thheller@U922FGW59 compile with npx shadow-cljs release <your-build> --pseudo-names#2022-11-1117:17thhellerto see what this actually is#2022-11-1117:17thhellerstuff moving around files is expected, thats what the closure compiler does#2022-11-1117:42Ferdinand BeyerOK, will try that, thanks. Was confused that things are moved to modules with the wrong dependency relationship, as encore depends on clojure.string and not vice versa#2022-11-1118:06thhelleralways verify. there is no guarantee that Fh of one build is Fh in another build#2022-11-1118:06thhellerif a function is only used once somewhere the closure compiler will either inline it entirely or move it to the module it was used in#2022-11-1118:21thhelleryou might be chasing down the wrong problems. advanced can be very misleading that way 😛#2022-11-1119:28Ferdinand BeyerIt might, but the Fh definition is exactly the same. And anyway, I do get the problem that clojure.string uses this but does not have it#2022-11-1119:30thhelleruses what?#2022-11-1119:31Ferdinand BeyerThe function Fh is this:
$CLJS.$JSCompiler_unstubMethod$$ = function($JSCompiler_unstubMethod_id$$, $JSCompiler_unstubMethod_body$$) {
  return $CLJS.$JSCompiler_stubMap$$[$JSCompiler_unstubMethod_id$$] = $JSCompiler_unstubMethod_body$$;
};
#2022-11-1119:31thhellerah. yeah thats a nasty one#2022-11-1119:31Ferdinand BeyerWhat is it? 🙂#2022-11-1119:32thhellerhttps://clojure.atlassian.net/browse/CLJS-3207#2022-11-1119:32thhellerset :compiler-options {:cross-chunk-method-motion false} in your build config#2022-11-1119:33thhellerhaven't seen that problem in a long time though. not sure how clojure.string would be involved either#2022-11-1119:33thhellercould totally be something else but the stub thing looks familiar#2022-11-1119:33Ferdinand BeyerAh, I had that in a different project once, I remember…#2022-11-1119:34Ferdinand BeyerDo you know what unstubMethod does?#2022-11-1119:34thhellermoves methods cross chunks 😛#2022-11-1119:35Ferdinand BeyerIn my case probably totally useless, as I later use webpack to glue it all together#2022-11-1119:35thhellerwell, it means that if you have a type/class, with methods on it#2022-11-1119:35thhellerclass Thing { foo() { ... } } or so#2022-11-1119:36Ferdinand BeyerYeah, I do use shadow.modern/defclass#2022-11-1119:36thhellerand foo is only used on one module but Thing in multiple. it may move the definition of foo elsewhere#2022-11-1119:36thhellernot specific to defclass#2022-11-1119:36thhellerany deftype defrecord and or JS type really, even reify.#2022-11-1119:37Ferdinand BeyerOK#2022-11-1119:38thhellerif you run webpack anyways you should probably consider using :target :esm with :js-provider :import#2022-11-1119:38thhellerit addresses some of the weirdness in :npm-module#2022-11-1119:39Ferdinand BeyerNot sure if I can. You might not remember, but you were helping me back in the day with my setup to build VS-Code Web Extensions#2022-11-1119:40thhellerah right. it didn't like modules right?#2022-11-1119:40Ferdinand BeyerWhere I need a special web-worker build that uses require and module exports#2022-11-1119:40Ferdinand BeyerYep, needs all in one file#2022-11-1119:40Ferdinand BeyerUnfortunately I cannot keep the differences between ESM/whatever other JS module version in my head 🙂#2022-11-1119:40Lone RangerOk dam if there was an award for rapid esoteric knowledge and response this would be it #2022-11-1119:41Lone RangerI’d probably have to tell my boss this is a research project and I’ll see you in a few months #2022-11-1119:41Ferdinand BeyerYes, thanks Thomas, your help is highly appreciated!#2022-11-1119:42Ferdinand BeyerFun fact: I actually worked around not needing remove-watch in the end and came up with a better design anyway#2022-11-1119:44Ferdinand Beyer:cross-chunk-method-motion false seems to indeed solve this! 🎉#2022-11-1119:46Ferdinand BeyerThanks again!#2022-11-1123:23zaneIt seems like passing the NPM package mermaid through shadow-cljs might corrupt it somehow. The DOM elements added by mermaid after it has been passed through shadow-cljs come out malformed compared to the elements that come out when you add mermaid to the page directly via a script tag. Here’s https://github.com/zane/shadow-cljs-mermaid-repro.#2022-11-1207:12thheller@zane if I change the require to "mermaid/dist/mermaid.core.mjs" it seems to work fine. can't tell if the commonjs variant you get via "mermaid" is busted itself, or if the closure compiler rewriting it messes it up#2022-11-1305:41thhellerI tried "mermaid/dist/mermaid.core.mjs" and it worked.#2022-11-1305:42thhelleryes, the closure compiler is used to process all JS code. just not for full :advanced optimizations#2022-11-1305:52zaneGot it. I’ll try to reproduce with just cljsbuild then. #2022-11-1305:53zaneYes, saw that core works, but that bundle is significantly smaller so presumably it’s missing some stuff. #2022-11-1305:56zaneDo you want an issue against shadow for tracking purposes?#2022-11-1305:57thhellersure, but if the issue is truly in the closure compiler (which I'm 99% certain of) I can't do anything#2022-11-1305:58zaneNo problem whatsoever. I appreciate you having a look! And thanks for shadow-cljs!#2022-11-1420:46roklenarcicI’ve got a bit of a problem operating the CLJS REPL via remote nREPL. When I connect with remote REPL I select the build repl:
Connecting to remote nREPL server...
Clojure 1.11.1
(shadow/nrepl-select :main)
To quit, type: :cljs/quit
=> [:selected :main]
And in this namespace I have imports:
(ns dev-test
  (:require [com.fulcrologic.fulcro.data-fetch :as df]
            )
But it seems that the requires just don’t work. They work in the app, just not in the REPL:
df/load!
------ WARNING - :undeclared-ns ------------------------------------------------
 Resource: <eval>:1:1
 No such namespace: df, could not locate df.cljs, df.cljc, or JavaScript source providing "df"
--------------------------------------------------------------------------------

------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:1
 Use of undeclared Var df/load!
--------------------------------------------------------------------------------

=> nil
::df/id
[line 1, col 8] Invalid keyword: ::df/id.

=> nil
It does work if I write this:
(require '[com.fulcrologic.fulcro.data-fetch :as df])
=> nil
df/load!
=> #object[com$fulcrologic$fulcro$data_fetch$load_BANG_]
What gives?
#2022-11-1420:49roklenarcicHm I think it might be the namespace is never loaded#2022-11-1420:57thhellerthis is the normal expected behavior yes#2022-11-1420:58thhelleryou must load a namespace and switch to it manually#2022-11-1420:58thhellerby default when starting a REPL you start in the cljs.user namespace#2022-11-1420:59thhellerdepending on which commands you use loading and switching may be separate commands#2022-11-1420:59roklenarcicI’ve tried to load the namespace manually but that didn’t work#2022-11-1420:59thhellerloaded how and what didn't work?#2022-11-1420:59roklenarcicbut that might be a problem with Cursive#2022-11-1421:00thhellerunlikely. I use Cursive myself and never had any issues with the REPL#2022-11-1421:00roklenarcicBasically to fix it I had to include the NS in require statement of the root app ns#2022-11-1421:00thhellerthis doesn't tell me anything#2022-11-1421:01roklenarcicI’ll test this again I think, there might be some other issue at play#2022-11-1421:02thheller> And in this namespace I have imports:#2022-11-1421:02thhellerwhy did you list this ns specifically? what did you do with it?#2022-11-1421:02thhellerthe mere presence of it does nothing on its own#2022-11-1421:09roklenarcicI think the problem was that the folder was not part of the CLJS build#2022-11-1421:10thhellerif its a REPL only ns it probably shouldn't be#2022-11-1421:21roklenarcicGoes like this:
Connecting to remote nREPL server...
Clojure 1.11.1
(shadow/nrepl-select :main)
To quit, type: :cljs/quit
=> [:selected :main]
(in-ns 'roklenarcic.cookery.dev-cli)
=> nil
Loading src/main/roklenarcic/cookery/ui/category.cljs... 
------ WARNING - :redef --------------------------------------------------------
 Resource: <eval>:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------


config
------ WARNING - :undeclared-var -----------------------------------------------
 Resource: <eval>:1:1
 Use of undeclared Var /config
--------------------------------------------------------------------------------

=> nil
#2022-11-1421:21roklenarcicso in cursive I’ve changed the NS and then loaded the NS#2022-11-1421:21thheller(in-ns 'roklenarcic.cookery.dev-cli) doesnt' load the ns, it only switches to it#2022-11-1421:21roklenarcicright but the next command loaded it#2022-11-1421:22thhellerand if you reverse the order of those commands?#2022-11-1421:22thhelleror wait#2022-11-1421:22thhellerit says Loading src/main/roklenarcic/cookery/ui/category.cljs...#2022-11-1421:22thhellerthat is not roklenarcic.cookery.dev-cli#2022-11-1421:22roklenarcicah the warning stops the load?#2022-11-1421:22roklenarcicthe redef warning#2022-11-1421:23thhellerI'm unsure what you are asking now#2022-11-1421:23roklenarcicI am triggering the load with CMD+Shift+L in roklenarcic.cookery.dev-cli#2022-11-1421:23thheller(in-ns 'roklenarcic.cookery.dev-cli) this is likely the first problem#2022-11-1421:23thhellerfix that#2022-11-1421:23roklenarcicbut it says
Loading src/main/roklenarcic/cookery/ui/category.cljs... 
------ WARNING - :redef --------------------------------------------------------
#2022-11-1421:23thhellerI don't know what that keybinding is#2022-11-1421:23thhellerwhich cursive command does it execute?#2022-11-1421:23roklenarcicit’s cursive for load NS of current file#2022-11-1421:24thhelleragain. can we please start at step 1?#2022-11-1421:24roklenarcicso the category.cljs is required from this one so I am assuming that warning prevent compilation#2022-11-1421:24thhellerotherwise you might be starting out at some weird broken state that causes all other weird stuff#2022-11-1421:25thhellerI cannot see your code so I don't know what these namespaces are doing. so for me there is a lot of guessing involved which makes every step harder to debug 😛#2022-11-1421:26roklenarcicdev-cli is an empty ns with multiple requires to other namespaces, nothing else at this point#2022-11-1421:26thhellerthen it is NOT empty#2022-11-1421:27thhellerbut to be extra clear hear: if you issue an in-ns WITHOUT the namespace being already loaded that is an ERROR#2022-11-1421:27thhellerso, either load that namespace first properly#2022-11-1421:27thhelleror don't issue that command at all#2022-11-1421:29thhellerwarnings will also stop the load of the namespace#2022-11-1421:29roklenarcicI think the main problem is that namespace that is required that produces a warning, if I comment that one out then things work as expected#2022-11-1421:29roklenarcicNow I just need to fix
------ WARNING - :redef --------------------------------------------------------
 Resource: <eval>:33:1
 abs already refers to: cljs.core/abs being replaced by: cljc.java-time.duration/abs
--------------------------------------------------------------------------------
somehow
#2022-11-1421:30roklenarcicthat’s in a library I use somewhere so I cannot affect the code directly#2022-11-1421:30thhellerlikely just need to update that library?#2022-11-1421:31roklenarciclet’s hope so… thanks#2022-11-1421:31thhellerjust for correctness sake#2022-11-1421:31thhellerbefore in-ns you should do (require 'roklenarcic.cookery.dev-cli)#2022-11-1421:32thhellerotherwise in-ns will just issue a blank (ns roklenarcic.cookery.dev-cli) which means your require aliases won't be available#2022-11-1516:26mkvlr@thheller hey Thomas, when using shadow with target :esm trying to load the js built by shadow from another port it fails because browsers are more strict about module includes, requiring a Access-Control-Allow-Origin` header set. I tried using my own http-handler but that only gets called when a file doesn't exist. Wondering if you'd be open to adding that header with a * value?#2022-11-1517:19thhellerwouldn't it be easier to have your server serve the JS files?#2022-11-1517:20thhellerthats my general suggestion for anything that requires a custom header?#2022-11-1517:29mkvlreasier no, in this case the other server is clerk and I’d prefer to have the config related to serving of js files in a single place in shadow-cljs.edn#2022-11-1517:29thhellerit requires no config? its just static files? which I assume clerk can already do?#2022-11-1517:30thhellerthe websocket :9630 server already sets all the proper headers and is not affected by which server you use#2022-11-1517:31mkvlrit would require setting the root#2022-11-1517:39mkvlrso with clerk I also don’t want to be in the business of serving other content 🙃#2022-11-1517:40mkvlrwould love to offload this to shadow for the use case for when folks want to take over the js build for clerk#2022-11-1517:40thhellerbut what is this script you are building? is this not part of clerk?#2022-11-1517:40mkvlrit’s a custom js bundle for clerk, with more deps in it#2022-11-1517:41mkvlrclerks customization point is specifying a different url to load the js bundle from#2022-11-1517:41mkvlrbut since switching to ESM this broke#2022-11-1517:42thhellerwouldn't that be the same as specifying a folder where to find the JS?#2022-11-1517:42mkvlrsimilar but not quite#2022-11-1517:42mkvlranything against setting the header?#2022-11-1517:43mkvlrwouldn’t this also be a problem for mobile esm builds where you run shadow on your PC and access it via the your phone?#2022-11-1517:46thhellerdepends on which server you use. I have never used a separate webserver just for serving the JS files#2022-11-1517:46thhellerbut I guess adding the header doesn't hurt anybody#2022-11-1517:47mkvlrcool, I’ll do a PR tomorrow, ok?#2022-11-1520:41thhellershould be fixed in 2.20.11#2022-11-1522:05mkvlroh thank you!#2022-11-1516:28mkvlrI can make sure my custom http hander is being called by not setting any :roots but defaulting to the header set might be simpler?#2022-11-1520:38martinklepsch
fs is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.

	npm install --save-dev shadow-cljs
I’m getting this message despite shadow cljs being installed in package.json. version is 2.20.10
#2022-11-1520:40thhellerdo you use custom :js-package-dirs?#2022-11-1520:42martinklepschno#2022-11-1520:43martinklepschI use one node_modules for client and server code though and above this message I’m seeing my client build fail because I’m requiring fs — which I guess kind of makes sense but worked with 2.15.10#2022-11-1520:44thhellershould be fine and nothing of the behaviour went through any intended change#2022-11-1520:46martinklepschworks again after downgrading to 2.15.10#2022-11-1608:29thheller@martinklepsch you said "no" to my question about :js-package-dirs, but then basically confirmed that you do in the next sentence? I'm confused by what you mean there. If you have :js-package-dirs ["client/node_modules"] or something then the node-libs-browser or shadow-cljs package needs to be installed in that node_modules folder?#2022-11-1608:32thhelleroh wait I guess I just read that wrong. you use one for everything, with only one package.json total?#2022-11-1608:57Quentin Le GuennecCan I specity per-build deps.edn aliases?#2022-11-1608:59thhellerno. why would you want to?#2022-11-1609:00Quentin Le GuennecBecause I got two app.client in different paths for two different builds. In src/website and src/launcher#2022-11-1609:03Quentin Le GuennecI would like to have the :website deps.edn alias (with extra path src/website associated with the :website shadow.cljs build, then same with the :launcher build#2022-11-1609:04thhellerI would very very strongly suggest to keep everything on one source path and instead have separate app.website and app.launcher or whatever namespaces that do distinctive things#2022-11-1609:05thhellerthen use separate builds to have control over what gets compiled#2022-11-1609:05Quentin Le GuennecI kinda don’t want that#2022-11-1609:05Quentin Le Guennecbut I could#2022-11-1609:05thhellerthen your only option is to drop the shadow-cljs command and run via clj directly#2022-11-1609:06Quentin Le Guennecyeah#2022-11-1609:06thhellershadow-cljs watch website is the same as clj -A:whatever:aliases -M -m shadow.cljs.devtools.cli watch website#2022-11-1609:06thhellerbut be aware that this comes with a long list of caveats and problems#2022-11-1609:06thhellerso I strongly recommend not doing this#2022-11-1609:07Quentin Le GuennecAre those problems documented somewhere?#2022-11-1609:07thhellereach build needs to be launched separately that way#2022-11-1609:07thhelleraliases control the classpath. the JVM can only have one classpath. so any changes to the classpath require starting a new jvm#2022-11-1609:08thhellerthus you will have 2 independent instances if you want two builds to run and the same time#2022-11-1609:08thhellerthey are going to compete and interfere with each other since shadow-cljs is not designed for this#2022-11-1609:08Quentin Le Guennecok, I see#2022-11-1609:16Quentin Le GuennecI will follow your initial suggestion, then#2022-11-1609:19thhellerif you ask me having 2 definitions for the same namespace is horrible and makes even using my editor annoying, not even accounting for build issues#2022-11-1609:19thhelleryou can still easily move the stuff that those namespaces share into a shared namespace and keep the relevant specific parts in each#2022-11-1609:36Quentin Le GuennecYeah, I guess that works as well#2022-11-1620:53colinkahnAre there any known issues with the Inspect feature of shadow-cljs UI not datafying?#2022-11-1620:54colinkahnI am trying:
(comment
 (require '[clojure.core.protocols :as p])

 (extend-type js/HTMLDivElement
   p/Datafiable
  (datafy [o]
    (.-outerHTML o)))

 (def div (doto (js/document.createElement "div")
            (.appendChild (js/document.createTextNode "Hello World"))))

 (p/datafy div) ;; "<div>Hello World</div>"

 (tap> div) ;; [object HTMLDivElement]]

 (def m (with-meta {} {`p/datafy (fn [_] :map)}))

 (p/datafy m) ;; :map

 (tap> m) ;; {}
 )
Which the tapped versions in the UI don't datafy when they're in the "viewer" (after clicking on them).
#2022-11-1620:56thhellernothing I'm aware of. I'd sort of expect this to now work for the div. protocols on native types like that can be icky#2022-11-1620:57colinkahnCalling (p/datafy ...) directly does, so that's why it's odd to me#2022-11-1621:00colinkahnOh interesting,
(satisfies? p/Datafiable (js/Error. "oops")) ;; true

 (tap> (js/Error. "oops"))
This does work, so it is datafying somethings
#2022-11-1621:03colinkahnah and this works too:
(deftype Foo [x])

 (extend-type Foo
   p/Datafiable
   (datafy [this]
     {:x (.-x this)}))

 (tap> (Foo. :a))
So it's something w/ native types and then also metadata protocols?
#2022-11-1621:06thhellerthere was a problem around metadata protocols, I'm not actually sure the fix for this is in yet#2022-11-1621:07thhellerhttps://clojure.atlassian.net/browse/CLJS-3313
#2022-11-1621:07thhellerhmm yeah seems to be in#2022-11-1621:08colinkahnWell, both of those examples at the top work in the REPL w/ direct calls to p/datafy, just something about the Inspect UI not recognizing them to datafy#2022-11-1621:08thhellerhmm yeah I'm not entirely sure#2022-11-1621:09thhellertoo tired to check. IIRC everything gets datafied as the very first step, but maybe I misremember#2022-11-1621:10colinkahnNo worries. I can make an issue for it. It'd be nice to have parity with tools like REBL.#2022-11-1701:12peterdeeI loaded an npm module that I made myself today (I'm not a javascript programmer) and shadow didn't complain. But when I try to call one of its functions (nb/base64encode "abc"), from a REPL I get module$node_modules$nata_borrowed$nataBorrowed.base64encode is not a function I'm really impressed that I got that far on the first shot! It knows where to find the function, but it says it isn't a function. Maybe this is a clojurescript question. How do I call a function? I see lots of example of calling methods.#2022-11-1706:26thheller@peterd how did you write the JS? did you export the function properly? if its just a named function in the JS file that is not enough, it needs to be exported#2022-11-1716:04peterdee@thheller: I put the code in a function that does as shown below (The code can be found here https://github.com/pdenno/nata-borrowed/blob/main/src/nataBorrowed.js) Thanks for the pointer on native encode/decode. There are more functions that I'll need so I'll need to know how to do this anyway. //Top of the file looks like this var utils = require('./utils'); var dateTime = require('./datetime'); const nataBorrowed = (() => { 'use strict'; // Then the function definition // Bottom of file... return { base64encode }; })(); module.exports = nataBorrowed;#2022-11-1717:22peterdeeHere is a simpler example. Following https://www.sitepoint.com/understanding-module-exports-exports-node-js/, I created const getName = () => { 'use strict'; // Linting wanted this line. return 'Jim'; }; exports.getName = getName; Then I did npm publish --dry-run and copied the results and package.json into a directory that I placed in my program's node_modules directory. It contained: -rw-rw-r-- 1 pdenno pdenno 2009 Nov 17 11:51 package.json -rw-rw-r-- 1 pdenno pdenno 1005 Nov 17 11:55 smallExample-es5.js -rw-rw-r-- 1 pdenno pdenno 829 Nov 17 11:55 smallExample-es5.min.js -rw-rw-r-- 1 pdenno pdenno 0 Nov 17 11:55 smallExample.js -rw-rw-r-- 1 pdenno pdenno 527 Nov 17 11:55 smallExample.min.js I added smallexample 1.0.0 to my program's package.json and fired up shadow. npx shadow-cljs -d nrepl/nrepl:1.0.0 -d cider/piggieback:0.5.3 -d cider/cider-nrepl:0.28.5 watch kaocha-test Connecting with cider-connect-cljs, in the REPL: (se/getName) Execution error (TypeError) at (<cljs repl>:1). module$node_modules$smallexample$smallExample.getName is not a function I suspect that I just don't know how to call the function.#2022-11-1717:57thhellerso how do you actually require and call the functions?#2022-11-1717:58thhellerand which shadow-cljs version do you use? if you do all this from the REPL there were some issues a while ago#2022-11-1721:48peterdee(ns rad-mapper.builtin (:require ... #?(:cljs ["smallexample" :as se]))) Then I'm just calling it with (se/getName) for example. I am using shadow-cljs 2.20.5. It could be something really stupid. This is all pretty new to me.#2022-11-1804:45thhellerthat would be fine#2022-11-1804:45thhellerbut there is so much more that could be wrong#2022-11-1804:46thhellerlike what is your build config? how are you running all this?#2022-11-1804:46thhellerwhy are you making it a npm package in the first place?#2022-11-1817:36peterdeeTo your last two questions: 1. My build config is the :kaocha-test target in this https://github.com/pdenno/RADmapper/blob/main/shadow-cljs.edn 2. I thought that npm would be the natural choice for shadow-cljs, and also the code I'm integrating, from a tool called JSONata, is provided as an npm package. (I have tried loading the entire JSONata npm package, but get the same results.) #2022-11-1907:28thhellerso I compiled your project and just added a require for ["jsonata" :as ja] and then added (js/console.log "ja" ja) and it appears to be all fine? I can't test your other package locally? or is it somewhere in that repo?#2022-11-1919:14peterdeeWell, I think I did warn you that it might be something stupid! My build process created the files shown in the message above, which, as shown, included -rw-rw-r-- 1 pdenno pdenno 0 Nov 17 11:55 smallExample.js which I did not notice is a file of size of 0 bytes. For anyone reading this thread, there were a few useful thing I learned in the process: Most significantly, I didn't realize that, for example, (require '["jsonata" :as ja]) binds ja to the object that you export from the npm module. You can just evaluate ja in the REPL and see the object. The object bound to the empty npm module smallExample.js is #js {}. That's good to know for debugging. Secondly, you might have to explicitly do the require in the REPL. Just being in a namespace that requires it might not be enough. (Or perhaps I have another bug to chase down.) Thanks for the help! Sorry for the noise. shadow-cljs is a great tool.#2022-11-1920:00thhellerif you just (in-ns 'your.ns) in the REPL before having loaded it the namespace will indeed be empty and contain no requires#2022-11-1920:00thhellerto load it properly you must (require 'your.ns) first#2022-11-1920:00thhelleror eval the whole ns form in the REPL#2022-11-1920:01thhellerjust switching is not enough. common mistake.#2022-11-1920:01peterdeeThanks!#2022-11-1706:28thhelleralso note that there are base64 related functions available in the closure library. (:require [goog.crypt.base64 :as b64]) then (b64/decodeString ...)#2022-11-1717:40peterdeeThanks! That works!#2022-11-1708:03mokrHi, with shadow-cljs v2.20.11 I still see the recent core.async java.lang.NoSuchFieldError: __thunk__0__ issue commented on in commit https://github.com/thheller/shadow-cljs/commit/b034b24d8d20e538afe31b6a19087f021d0813e2 After quite a bit of fault searching and trial-and-error. I’ve come to the point where a suggestion or two would be nice. Some details: • My project is based on the https://luminusweb.com. • All was good until shadow-cljs started using core.async v1.6.673 • The issue goes away if I downgrade to core.async v1.5.648 • My dependencies list all versions of clojure, clojurescript, clojurescript, closure-compiler-unshaded and core.async that shadow-cljs requires according to clojars and error message. I also tried moving all of them to :managed-dependencies in project.clj, without noticeable effect. • As a test I started out with a clean lein new luminus myproject +shadow-cljs and bumped shadow-cljs to v2.20.11 and all mentioned libs to the versions shadow requires, it still worked. I then started adding other libs my project uses and error reappeared when I added [com.wsscode/pathom3 "2022.10.19-alpha"] as a dependency and required it as [com.wsscode.pathom3.connect.operation :as pco] in myproject/core.clj. I noticed that Pathom3 also uses shadow-cljs. It’s honestly not that clear to me which library is to “blame” here. Seems like a snowballing effects starting with a change to core.async, but this is all a bit deeper than where I usually spend my time. Staying at core.async v1.5.648 might be a workaround for now, but does not seem like a good option in the long run. Other suggestions would be very much appreciated.#2022-11-1708:05thhellerhmm yeah thats not great. for me it seemed fixed after that commit#2022-11-1708:06thhellerdo you do any AOT yourself?#2022-11-1708:06thhellerpathom using shadow-cljs doesn't matter. since that is not part of the deployed jar#2022-11-1708:08thhellerthe blame is core.async I guess, not exactly sure why this is all even a problem but AOT is weird that way#2022-11-1708:20shawnis there a way to be less aggressive about compiling this:
(def query (js-template graphql "
query reagentProject_pages_homeQuery {
                            rates(currency: \"USD\") {
                              currency
                              rate
                            }
                           }
"))
...
  (let [{:keys [rates]} (-> useLazyLoadQuery query)]
such that instead of getting this:
reagent_project.pages.home.query = module$node_modules$react_relay$index.graphql`
query reagentProject_pages_homeQuery {
                            rates(currency: "USD") {
                              currency
                              rate
                            }
                           }
`;
var map__42409 = (reagent_project.pages.home.query.cljs$core$IFn$_invoke$arity$1 ? reagent_project.pages.home.query.cljs$core$IFn$_invoke$arity$1(module$node_modules$react_relay$index.useLazyLoadQuery) : reagent_project.pages.home.query.call(null,module$node_modules$react_relay$index.useLazyLoadQuery));
I can get this:
var query = graphql`
query reagentProject_pages_homeQuery {
                            rates(currency: "USD") {
                              currency
                              rate
                            }
                           }
`;
var data = useLazyLoadQuery(query, {});
I had tried to update my shadow-cljs.edn like so:
:builds       {:app {:target     :esm
                      :compiler-options {:optimizations :simple}
                      :output-dir "resources/public/js"
                      :asset-path "/js"
                      :modules    {:app {:init-fn reagent-project.core/init!}}}}
 :dev-http     {3000 {:root    "resources/public"
                      :handler reagent-project.handler/app}}}
#2022-11-1708:24thhellerwhere does useLazyLoadQuery come from?#2022-11-1708:25thheller(-> useLazyLoadQuery query) why the ->?#2022-11-1708:25thhellerjust (useLazyLoadQuery query) should generate the proper code?#2022-11-1708:25shawnit comes from https://www.npmjs.com/package/react-relay#2022-11-1708:25thhellerbut all depends on what useLazyLoadQuery is#2022-11-1708:25thhellerthats not what I meant. where does it come from in your code#2022-11-1708:26thhelleris it a :refer or how did you declare it?#2022-11-1708:26shawnthe complete component is:
(defnc home []
  (let [{:keys [rates]} (-> useLazyLoadQuery query)]
    (let [{:keys [currency rate]} rates]
      (d/div {:key currency}
             (d/p currency ": " rate)))))
    ;; (d/span {:class "main"}
    ;;  (d/h1 "Welcome to reagent-project")
    ;;  (d/ul
    ;;   (d/li (d/a {:href (path-for :items)} "Items of reagent-project"))
    ;;   (d/li (d/a {:href "/broken/link"} "Broken link"))))
  ;; )

(defn home-page []
  (helix.core/suspense
   {:fallback "loading..."}
   ($ home)))
#2022-11-1708:26thhellerI need to see the definition of useLazyLoadQuery#2022-11-1708:27shawnsorry#2022-11-1708:27thhellerwhat is that? is it from a :require in your ns? is it a local def?#2022-11-1708:27shawn
(ns reagent-project.pages.home
  (:require
   [reagent-project.utils.path-for :refer [path-for]]
   ["react-relay" :refer [useLazyLoadQuery graphql]]
   [helix.core :refer [defnc $]]
   [shadow.cljs.modern :refer [js-template]]
   [helix.dom :as d]
   [reagent.core :as reagent :refer [atom]]))

(def query (js-template graphql "
query reagentProject_pages_homeQuery {
                            rates(currency: \"USD\") {
                              currency
                              rate
                            }
                           }
"))


(defnc home []
  (let [{:keys [rates]} (-> useLazyLoadQuery query)]
    (let [{:keys [currency rate]} rates]
      (d/div {:key currency}
             (d/p currency ": " rate)))))

(defn home-page []
  (helix.core/suspense
   {:fallback "loading..."}
   ($ home)))
#2022-11-1708:27thhellerok then remove the ->?#2022-11-1708:28thhellerwhy does it matter though?#2022-11-1708:28thhellerI mean the likelyhood of some other compiler recognizing the CLJS output is very slim#2022-11-1708:31shawnah, I see. I was considering using a vite transform plugin with this. but I think I'll use the babel one instead to complete the transform#2022-11-1708:32thhellerso part of the weird code you are seeing is the destructure#2022-11-1708:33thheller
(defnc home []
  (let [result (useLazyLoadQuery query)
        {:keys [rates]} result
        {:keys [currency rate]} rates]
    (d/div {:key currency}
      (d/p currency ": " rate))))
#2022-11-1708:33thhellermight generate code that babel may "accept"#2022-11-1708:33thhellerbut I wouldn't hold my breath to be honest 😛#2022-11-1708:44shawnnice. thanks again! I'll try that out.#2022-11-1708:21mokr@thheller Honestly AOT is not something I think about. Luminus comes with :main ^:skip-aot myproject.core, but I do not active use AOT myself.#2022-11-1708:23thhellerI just release 2.20.12 with the downgraded core.async#2022-11-1708:24mokrIn addition the :uberjar profile in project.clj has :aot :all#2022-11-1708:24mokrThanks, I’ll upgrade shadow-clj#2022-11-1805:49Apple2.20.12 is not working here. going back to 2.20.10 openjdk version "19.0.1" 2022-10-18#2022-11-1805:49Apple
Exception in thread "main" Syntax error macroexpanding at (closure.clj:77:5).
	at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1750)
	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3713)
	at clojure.lang.Compiler$DefExpr.eval(Compiler.java:457)
	at clojure.lang.Compiler.eval(Compiler.java:7199)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:551)
	at shadow.build.js_support$eval18536$loading__6789__auto____18537.invoke(js_support.clj:1)
	at shadow.build.js_support$eval18536.invokeStatic(js_support.clj:1)
	at shadow.build.js_support$eval18536.invoke(js_support.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:619)
	at shadow.build.resolve$eval16456$loading__6789__auto____16457.invoke(resolve.clj:1)
	at shadow.build.resolve$eval16456.invokeStatic(resolve.clj:1)
	at shadow.build.resolve$eval16456.invoke(resolve.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:2793)
	at shadow.build.api$eval16448$loading__6789__auto____16449.invoke(api.clj:1)
	at shadow.build.api$eval16448.invokeStatic(api.clj:1)
	at shadow.build.api$eval16448.invoke(api.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:3659)
	at shadow.build$eval16080$loading__6789__auto____16081.invoke(build.clj:1)
	at shadow.build$eval16080.invokeStatic(build.clj:1)
	at shadow.build$eval16080.invoke(build.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:3204)
	at shadow.cljs.devtools.api$eval7525$loading__6789__auto____7526.invoke(api.clj:1)
	at shadow.cljs.devtools.api$eval7525.invokeStatic(api.clj:1)
	at shadow.cljs.devtools.api$eval7525.invoke(api.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:459)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.core$load$fn__6908.invoke(core.clj:6161)
	at clojure.core$load.invokeStatic(core.clj:6160)
	at clojure.core$load.doInvoke(core.clj:6144)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5933)
	at clojure.core$load_one.invoke(core.clj:5928)
	at clojure.core$load_lib$fn__6850.invoke(core.clj:5975)
	at clojure.core$load_lib.invokeStatic(core.clj:5974)
	at clojure.core$load_lib.doInvoke(core.clj:5953)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$load_libs.invokeStatic(core.clj:6016)
	at clojure.core$load_libs.doInvoke(core.clj:6000)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:669)
	at clojure.core$require.invokeStatic(core.clj:6038)
	at clojure.core$require.doInvoke(core.clj:6038)
	at clojure.lang.RestFn.invoke(RestFn.java:1289)
	at user$eval140$loading__6789__auto____141.invoke(user.clj:1)
	at user$eval140.invokeStatic(user.clj:1)
	at user$eval140.invoke(user.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7194)
	at clojure.lang.Compiler.eval(Compiler.java:7183)
	at clojure.lang.Compiler.load(Compiler.java:7653)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:368)
	at clojure.lang.RT.maybeLoadResourceScript(RT.java:364)
	at clojure.lang.RT.doInit(RT.java:486)
	at clojure.lang.RT.init(RT.java:467)
	at clojure.main.main(main.java:38)
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Streams
	at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:259)
	at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:154)
	at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:146)
	at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:414)
	at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:178)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
	at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
	at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newMethodAccessor(MethodHandleAccessorFactory.java:71)
	at java.base/jdk.internal.reflect.ReflectionFactory.newMethodAccessor(ReflectionFactory.java:159)
	at java.base/java.lang.reflect.Method.acquireMethodAccessor(Method.java:720)
	at java.base/java.lang.reflect.Method.invoke(Method.java:575)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
	at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1743)
	... 178 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Streams
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 192 more
#2022-11-1805:50thhellercheck your dependencies? looks like guava is missing? maybe you excluded it manually?#2022-11-1806:07Applediff of clj -Stree#2022-11-1806:07thhellerso it is manually excluded?#2022-11-1806:08thhellerwhy is there an X and :superseded, shadow-cljs is not doing this. so it must be your deps.edn file#2022-11-1806:09thhellermaybe that was to work arround earlier problems where the closure compiler didn't declare dependencies properly?#2022-11-1806:10thhellerit now does#2022-11-1806:10Applei have com.lambdaisland/classpath 0.4.44, which depends on
. com.google.guava/guava 31.1-android :newer-version
`
#2022-11-1806:10Appleno exclusion that i can see except
luminus-transit/luminus-transit    {:mvn/version "0.1.5" :exclusions [com.cognitect/transit-clj]}
#2022-11-1806:11thhellermaybe that version is incompatible with the closure compiler. no clue what the -android qualifier does#2022-11-1806:11Appleno problem.#2022-11-1806:12Appledoes this css reload config look alright?#2022-11-1806:12Apple
:devtools   {:after-load kit.net.core/mount-root
                     :devtools {:watch-dir "resources/public"
                                :watch-path "/"}}
#2022-11-1806:13thhellerno?#2022-11-1806:13thhellerdevtools nested in devtools?#2022-11-1806:14thheller
:devtools {:after-load kit.net.core/mount-root
           :watch-dir "resources/public"}
#2022-11-1806:14thhellershould be fine#2022-11-1806:15Appleim so sorry.... what an idiot#2022-11-1808:13AbhinavHey, is it possible to add :injections in ~/.shadow-cljs/config.edn like we can do in ~/lein/profiles.clj?#2022-11-1808:28thhellerto do what? :injections is a leiningen thing, so it is not supported no. you can of course just use leiningen, and use all the features it has#2022-11-1808:38Abhinavwith :injections i can require a namespace in leiningen. I wanted to replicate that in shadow-cljs.#2022-11-1808:39thhellerwhat does requiring a namespace do to leiningen? and what would it do for shadow-cljs?#2022-11-1808:40thhellerI have no clue what :injections even does, so please explain. I only know that it exists#2022-11-1808:44AbhinavI may be abusing injections, but requiring a namespace in the injections will require it inside the namespace defined in :init-ns 😅#2022-11-1808:44thhellerwhy not just require it in :init-ns?#2022-11-1808:45thhelleris this for a CLJS build or for the CLJ parts?#2022-11-1808:45thhellerI'm still nowhere near understanding what it is your are trying to do#2022-11-1808:49Abhinavokay, I’ll try to explain. sorry. I have a repl-based tool -https://github.com/AbhinavOmprakash/snitch that I add to profiles.clj and config.edn files. In my library I intern the macros to clojure.core so the macros are available in all namespaces in whichever project I’m in.
#?(:clj (do (intern 'clojure.core (with-meta 'defn* (meta #'defn*)) #'defn*)
            (intern 'clojure.core (with-meta '*fn (meta #'*fn)) #'*fn)
            (intern 'clojure.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
            (intern 'clojure.core (with-meta '*let (meta #'*let)) #'*let)
            (try
              (intern 'cljs.core (with-meta 'defn* (meta #'defn*)) #'defn*)
              (intern 'cljs.core (with-meta '*fn (meta #'*fn)) #'*fn)
              (intern 'cljs.core (with-meta 'defmethod* (meta #'defmethod*)) #'defmethod*)
              (intern 'cljs.core (with-meta '*let (meta #'*let)) #'*let)
              (catch Exception _))))
if I require it in the :injections of profiles.clj the macros get interned when lein starts up. I wanted to do something similar with shadow-cljs.
#2022-11-1808:51thhellerwhy use injections at all? wouldn't a user.clj work as well? that gets loaded unconditionally in CLJ on startup?#2022-11-1808:55Abhinavhmm. I’m not familiar with that setup 😅 how would I support it in cljs?#2022-11-1808:58thhellerthis is purely macro side from what I can tell?#2022-11-1808:58thhellerso you create a user.clj as a classpath root#2022-11-1808:58thhellerif you use the default setup that would be src/dev/user.clj#2022-11-1808:58thhellerin it (ns user ...) with whatever require you want#2022-11-1808:59thhellerthat namespace is loaded when shadow-cljs starts#2022-11-1808:59thhelleror anything else#2022-11-1808:59thhellerit is ALWAYS loaded, unconditionally#2022-11-1808:59thhellerbut it must be in the project, so it cannot be controlled via ~/.shadow-cljs/config.edn#2022-11-1809:00thhellerand no, there is no equiv functionality to do something like that in shadow-cljs#2022-11-1809:00thhellerbut as I said before you can just use lein. assuming this is all in CLJ anyways there is nothing shadow-cljs needs to do#2022-11-1809:08AbhinavOh I see. I’ll give this a shot. I think this is what I need. Thanks so much for your help#2022-11-1912:29p-himikFound a weird thing - something is getting compiled by CLJS itself but fails with shadow-cljs: https://github.com/p-himik/ptaoussanis-encore-issues-64#2022-11-2004:59valeraukois there a way to require namespace a.b.c.d and alias it as c.d? i'd like to have something like
(:require [a.b
           [c.d]
           [e.f]])
#2022-11-2005:34thhellerprefix lists are not supported in CLJS#2022-11-2006:02valeraukothat's too bad 😞#2022-11-2007:17thhellerIMHO prefix lists are horrible and I don't like them at all 😉#2022-11-2007:17thhellerbut I don't want to break compatibility with regular CLJS, so I won't add them until they do#2022-11-2007:56valeraukowould you be okay with adding a warning in shadow-css if it runs into :content "" ? this will emit css content: ; which seems to be invalid. the "correct" way to write it in shadow-css would be :content "\"\"" but this is too easy to forget.#2022-11-2007:57thhellersure, makes sense everywhere not just content#2022-11-2008:01valeraukoshould that be in the spec or a check in add-map?#2022-11-2008:03thhellerhttps://github.com/thheller/shadow-css/commit/a46daf723b0ad7960c407e7af8261fb9c0bf352e#2022-11-2008:05valeraukoblazing fast #2022-11-2008:06thhellerneed a release or do you use deps.edn anyways?#2022-11-2008:06valeraukowould be lovely to have a release ~#2022-11-2008:07thheller0.4.2 done#2022-11-2008:08valeraukothanks a lot!#2022-11-2104:08coltnzHi, I'm requiring a node lib in package.json thusly:
"dependencies": {
  "pgsql-parser": "^13.4.0",
requiring it:
(:require
  ["pgsql-parser" :as pgsql]
but when I go to build my own node lib I get:
Uncaught Error: Cannot find module 'pgsql_parser'
#2022-11-2104:09coltnzLooking at the shim generated I see:
goog.provide("shadow.js.shim.module$pgsql_parser");
goog.provide("module$shadow_js_shim_module$pgsql_parser");
shadow.js.shim.module$pgsql_parser = require("pgsql_parser");
module$shadow_js_shim_module$pgsql_parser.default = shadow.js.shim.module$pgsql_parser;
#2022-11-2104:09coltnzIf I edit to :
shadow.js.shim.module$pgsql_parser = require("pgsql-parser");
#2022-11-2104:11coltnzAll is well. I assume this a bug to raise, but thought I'd check if anyone has an insight because this confuses me. The Shadow code calls Closure libs to generate names.#2022-11-2106:51thheller@coltnz I don't know how that would happen? there is never any translation or conversion of - to _ for JS packages. I cannot reproduce it locally either? which shadow-cljs version do you use?#2022-11-2106:54coltnz• shadow-cljs - server version: 2.20.10 #2022-11-2106:54coltnzIt really is weird, I tried react-dom package and it is fine#2022-11-2106:56thhellerdo you maybe have a [pgsql_parser :as pgsql] or [pgsql-parser :as pgsql] require somewhere else in your code?#2022-11-2106:56thhellersymbols might get translated, so use strings always for npm packages#2022-11-2107:05coltnzNope only the require as above. My build target is a node lib btw.#2022-11-2107:07thhellerbuild target shouldn't matter for this. just tried with :node-script and :node-library. both totally fine#2022-11-2109:36qqqfor shadow-cljs, for (shadow/watch :app-id), is it possible to say: you don't have to do highest level optimization, but please do a quick tree shake and output a .js that I can copy/paste elsewhere? [I'm working on a project involving both cljs and non-cljs js partts, and I'd like to copy/paste the generate .js file elsewhere]#2022-11-2119:04thheller:advanced is the only thing doing the DCE, so no there is no alternative#2022-11-2109:36qqq(shadow/release :app-id) takes ~20 seconds#2022-11-2110:29qqqI have a file src/foo.js . Is there a way to tell shadow-cljs, even in optimizations:advanced, to not rewrite file src/foo.js ?#2022-11-2119:05thhellerno. why would that matter? if you want to prevent renaming of certain stuff add externs#2022-11-2111:36henryw374I am setting a variable like this (set! js/Foo bar) and getting a warning `
constant Foo assigned a value more than once.
Original definition at externs.shadow.js:4
` what's the right thing to do here?
#2022-11-2119:03thhellerwhat exactly are you trying to do there? you shouldn't really use set! if you want to export a global? use (js/goog.exportSymbol "Foo" bar) instead#2022-11-2203:18qqqWhy does shadow-cljs ignore :foreign-libs . See "unsupported" under section https://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options#2022-11-2206:40thhellerbecause its not needed or useful https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs#2022-11-2210:33Anders EknertHey 🙂 After bumping shadow-cljs from 2.20.10 to 2.20.11 or 2.20.12, I get an error when building (via lein):
IllegalArgumentException: No matching method legacySetOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/set-options (closure.clj:166)
	shadow.build.closure/set-options (closure.clj:122)
	shadow.build.closure/convert-goog* (closure.clj:2295)
	shadow.build.closure/convert-goog* (closure.clj:2260)
	shadow.build.closure/convert-goog (closure.clj:2439)
	shadow.build.closure/convert-goog (closure.clj:2389)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1237)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1230)
	shadow.build.compiler/compile-all (compiler.clj:1472)
	shadow.build.compiler/compile-all (compiler.clj:1349)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:512)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.api/compile* (api.clj:296)
	shadow.cljs.devtools.api/compile* (api.clj:292)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:34)
	shadow.cljs.devtools.cli-actual/do-build-command (cli_actual.clj:25)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:49)
	shadow.cljs.devtools.cli-actual/do-build-commands (cli_actual.clj:38)
	shadow.cljs.devtools.cli-actual/main/body-fn--17900--auto----18609 (cli_actual.clj:166)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:165)
	shadow.cljs.devtools.cli-actual/main (cli_actual.clj:132)
	clojure.core/apply (core.clj:671)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:219)
	shadow.cljs.devtools.cli-actual/-main (cli_actual.clj:217)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.core/apply (core.clj:667)
	clojure.core/apply (core.clj:662)
	shadow.cljs.devtools.cli/-main (cli.clj:75)
	shadow.cljs.devtools.cli/-main (cli.clj:67)
	clojure.lang.Var.invoke (Var.java:388)
	user/eval140 (form-init17017545089428182543.clj:1)
	user/eval140 (form-init17017545089428182543.clj:1)
	clojure.lang.Compiler.eval (Compiler.java:7194)
	clojure.lang.Compiler.eval (Compiler.java:7184)
	clojure.lang.Compiler.load (Compiler.java:7653)
	clojure.lang.Compiler.loadFile (Compiler.java:7591)
	clojure.main/load-script (main.clj:475)
	clojure.main/init-opt (main.clj:477)
	clojure.main/init-opt (main.clj:477)
	clojure.main/initialize (main.clj:508)
	clojure.main/null-opt (main.clj:542)
	clojure.main/null-opt (main.clj:539)
	clojure.main/main (main.clj:664)
	clojure.main/main (main.clj:616)
	clojure.lang.Var.applyTo (Var.java:705)
	clojure.main.main (main.java:40)
no other changes made, and reverting “fixes” the issue… I tried searching here but didn’t see any mention of this
#2022-11-2210:39thheller@anders982 you probably have a pinned closure-compiler version. so a dependency conflict. needs the newest version#2022-11-2210:40Anders EknertHmm, not to my knowledge, but maybe something else is pulling it in. I’ll take a look, thanks!#2022-11-2212:08Anders Eknertah, in clojurescript itself 🙂 thanks again 👍#2022-11-2213:28Quentin Le GuennecCan I specify the shadow-cljs build with the command clojure -X shadow-cljs/release ?#2022-11-2213:30thhellerno, but you can run clj -M -m shadow.cljs.devtools.cli release app#2022-11-2213:31Quentin Le GuennecPerfect, thank you for the quick answer#2022-11-2221:13gravHow come :release doesn't support {:optimizations :none}? In case of node-script, I imagine it might make sense to avoid any code size optimization (ie skip the Closure compiler), but still strip out all the development related code.#2022-11-2221:24thhellerthats what :compile is#2022-11-2221:24thhellerotherwise use :simple#2022-11-2221:25thheller:compile still has all the debug loader mechanisms and stuff and just is not a release build by any means#2022-11-2307:29gravSo there isn't any way to avoid running the closure compiler, but still strip out development related code?#2022-11-2307:30thhellerdefine what you mean by "development related code"?#2022-11-2307:30thhellerthe whole emitted code could be considered development related code unless it runs through the closure compiler#2022-11-2307:36grav> development related code Yeah, that's a good question. Honestly I just took that phrasing from the docs: https://shadow-cljs.github.io/docs/UsersGuide.html#_release_mode#2022-11-2307:36gravYou alkso mention "debug loader mechanisms", I guess that's part of it?#2022-11-2307:37thhellerok, I define development related code as: code injected by shadow-cljs that is not otherwise specified by your build config. ie. the websocket connection for repl/hot-reload#2022-11-2307:37thhellerwatch injects those#2022-11-2307:37thhellercompile does not#2022-11-2307:37thhellerthen further "development code" is the goog.require and goog.provide calls#2022-11-2307:37thhellerwhich both of these contain#2022-11-2307:38thhellerrelease will remove those and also collapse the many input files into the configured output file(s)#2022-11-2307:38thhellerso, watch/compile are forced to be :none as it never runs the closure optimizations#2022-11-2307:38thhellerrelease will ALWAYS optimize, therefore it makes no sense to allow :none here#2022-11-2307:39thhellerwatch/compile code is also meant to never run anywhere else than the location output by shadow-cljs#2022-11-2307:39thhellerso its not guranteed to work when copied or integrated into other things#2022-11-2307:41gravOkay, I think I follow, apart from the last two comments. Say I want to run a nodejs app in a lambda or similar. If I wanted the "cleanest" code, eg for understanding a stack trace in production, wouldn't it make sense to use the output from compile?#2022-11-2307:44thhelleruse source maps?#2022-11-2307:45thhellerI don't think understanding a stacktrace of none compiled code is very easy. source maps make that easy#2022-11-2307:46thhelleryou can also sort of use --pseudo-names I guess. that gives sort of legible names for :advanced output, but still source maps are the solution here#2022-11-2307:48gravYeah, sounds about right. In the browser I'm used to the browser magically doing all the source mapping for me. In the context of lambdas, I'm usually trying to infer stuff from small snippets of stack traces in cloud watch logs - which is definitely not the way to go.#2022-11-2307:48gravDo you have any pointers on how a workflow with sourcemaps outside the browser would look?#2022-11-2307:48thhellerbut besides all that :simple is just as readable as :none is#2022-11-2307:49thheller:compiler-options {:source-map true}#2022-11-2307:49thhellerthe rest all depends on what kind a runtime you use#2022-11-2307:49thhellersome pick up the maps automatically#2022-11-2307:49thhellersome might need to be coerced#2022-11-2307:49thhellersome will not support it at all#2022-11-2307:50gravAlright - I guess minified javascript is not unusual in a Lambda. I'll see what I tooling can dig up. Thanks a lot for the pointers!#2022-11-2307:54thhellerminified code should indeed be the norm#2022-11-2221:29qqqdoes compiler warnings prevent the the hot reloading of ^:dev/after-load fns ?#2022-11-2221:31thhelleryes. you can set :devtools {:ignore-warnings true} in the build config, but fixing warnings should be the first choice#2022-11-2223:24colinkahnAre these equivalent ways to pass in additional config for release:
lein shadow release app --config-merge '{my.ns/HOST ""}'

 (shadow/release :app {:closure-defines {'my.ns/HOST ""}})
I'm seeing the first one work, but the second doesn't.
#2022-11-2223:57colinkahnFigured it out (shadow/release :app {:config-merge [{:closure-defines {'my.ns/HOST ""}}]})#2022-11-2308:08mhuebert> It is strongly recommended to use the standalone shadow-cljs version. The command does a lot of things to optimize the user experience (e.g. faster startup) which are not done by other tools. You’ll also save yourself a lot of headaches dealing with dependency conflicts and other related errors. is this still strong advice? just curious because I use deps.edn for almost everything these days and am wondering what I am missing out on. (I guess mainly fast startup? I haven’t experienced much in the way of dependency conflicts)#2022-11-2308:09thhellerthis is talking about the shadow-cljs command specifically#2022-11-2308:10thhellerusing deps.edn to manage dependencies but still running everything through the shadow-cljs command is fine#2022-11-2308:10thhellerso shadow-cljs watch app vs clj -M -m shadow.cljs.devtools.cli watch app#2022-11-2308:10thhellerthe first is recommended, the second is not#2022-11-2308:11thhellerfaster startup you only get by default when using shadow-cljs.edn as it defaults to using the AOT package by default#2022-11-2308:11thhellerdeps.edn you can swtich thheller/shadow-cljs to thheller/shadow-cljs$aot to get the same#2022-11-2308:12thhellerdependency conflicts are more likely when using deps.edn but you can deal with that#2022-11-2308:12thhellerhttps://code.thheller.com/blog/shadow-cljs/2017/11/18/the-many-ways-to-use-shadow-cljs.html#2022-11-2308:12thhellernot quite accurate anymore since it doesn't AOT compile on demand but the reasons still apply#2022-11-2308:13mhuebertah ok that makes sense. thank you!#2022-11-2308:17Leonid RiznykHello, I currently learning ClojureScript with Reagent and tailwind, and hot reload doesn't work. I run
npx shadow-cljs watch frontend
And when I save a file(views/app), changes don't affect the web page on reload And every time when I change something I need to restart the server to see the changes Here's my core.cljs
(ns frontend.core
  (:require [reagent.core :as r]
            [reagent.dom :as rdom]
            [frontend.views :as views]))

(defn ^:dev/after-load start
  []
  (rdom/render [views/app]
                      (.getElementById js/document "app")))

(defn ^:export main
  []
  (start))
How can I fix it?
#2022-11-2308:17thhellerwhat does the browser console say?#2022-11-2403:53Leonid Riznyk@U05224H0W Sorry for the such long response So, when I boot up shadow-cljs and open localhost in the web console writes this: shadow-cljs: #3 ready! and with every page reload number increases. And when I change anything in the code, nothing new happens#2022-11-2406:45thhellerthen it doesn't seem to detect the file change properly?#2022-11-2406:45thhellerare you running in a container or something like that?#2022-11-2406:49Leonid RiznykNo, I think not, sorry I am a complete noob in Clojure. I have just a simple shadow-cljs, reagent, and tailwind app without any additions#2022-11-2406:50thhellernot a clojure question. how do you run shadow-cljs? in docker or something like that? or the cloud? or just normally local in a terminal?#2022-11-2406:51Leonid RiznykNo just local in terminal#2022-11-2406:51thhellerdoes it trigger a compilation message in the terminal?#2022-11-2406:53Leonid RiznykThis is what terminal outputs:#2022-11-2406:59thhellerand nothing after changing and saving the file?#2022-11-2407:01Leonid RiznykNo, nothing changes in terminal when i change a file#2022-11-2407:01Leonid Riznyk*and save it#2022-11-2407:04thhellerhmm yeah then it doesn't detect the file changes#2022-11-2407:04thhellernot sure why it wouldn't though. everything seems to look correct. you sure you are editing the correct file?#2022-11-2407:05thhellernot a copy left in some wrong location or so?#2022-11-2407:07Leonid RiznykNo, i'm edditing correct one, I even tried to edit same file where i have render function. (here, I editing "ui" component and rendering it, but nothing changes)#2022-11-2407:08thhellerhmm so the only explanation I have is that the file watcher doesn't work. which happens when running in containers such as docker. what kind of computer/os do you use?#2022-11-2407:09Leonid RiznykI using windows, and for terminal linux/oh-my-zsh#2022-11-2407:10Leonid Riznykmay it can be because of IDE? I using intellij idea with Cursive#2022-11-2407:10thhellerdo you run with wsl2? but access a file on the windows fs?#2022-11-2407:11Leonid Riznykyes as you said#2022-11-2407:11thhellerok then thats the problem#2022-11-2407:11thhellerI use windows with wsl1 too#2022-11-2407:11thhellerI would recommend running shadow-cljs in windows then#2022-11-2407:12thhellerotherwise it only works if you run in wsl and also edit the files in wsl, ie. directly in /home/wherever#2022-11-2407:12thhellernot via /mnt/c/...#2022-11-2407:12Leonid RiznykOh, i'll try that#2022-11-2407:13thhelleryeah file watchers in general don't work when using wsl1 but editing files from windows directly. nothing I can do about that unfortunately#2022-11-2407:24Leonid RiznykYep, now everything is working, Thank you so much!#2022-11-2407:25Leonid Riznykdidn't even thought that problem can be this)#2022-11-2407:25thhelleryeah wsl has some quirks#2022-11-2315:03danielstocktonDoes anyone have any general tips for ensuring things that aren't needed are eliminated from the final compiled build? I'm looking at a build report and some of the things e.g. npm libraries are included when not needed (I have a couple of builds with different entry points, one needs these libraries and the other doesn't).#2022-11-2315:30danielstocktonFor example, is it OK to 'exclude' npm libs using :js-options {:resolve when i know they're not needed by the build? Since the closure compiler/shadow doesn't exclude them via DCE#2022-11-2315:39dvingoa common solution is using ns-aliases e.g. https://github.com/dvingo/fulcro-release-build-incl-pprint/blob/main/shadow-cljs.edn#2022-11-2315:40dvingothe other is putting those libs needed for dev in :preloads#2022-11-2315:42danielstocktonAha, thanks @U051V5LLP very helpful#2022-11-2316:08danielstocktonStill seems like the easiest thing is (if i know they will never be caled) is:
:js-options      {:resolve {"slate"         {:target :global :global "window"}
                               "slate-react"   {:target :global :global "window"}
                               "slate-history" {:target :global :global "window"}}}
With ns-aliases, I still have to define things within the noop ns
#2022-11-2316:09danielstockton"window" because target is browser and it won't error#2022-11-2316:31dvingoaha, so you include these with <script> tags?#2022-11-2316:32danielstocktonThat's what this resolve option is intended for, but in my case I know these dependencies are not needed by this build so I'm not including anything.#2022-11-2316:33dvingoah interesting#2022-11-2316:33danielstocktonThe compiler can't deduce that they aren't needed, since they're npm libraries.#2022-11-2316:34dvingoI guess the usual solution is to not include the namespaces in the release build somehow (preloads are one way) but I don't know the requirements/constraints of your app, so this seems like a good solution#2022-11-2316:35dvingothe other way I've gone about this is having a dev namespace for a file and a release version still using ns-aliases e.g. https://github.com/matterandvoid-space/todomvc-fulcro-subscriptions/blob/766d27be316c3f2ab6a23bd8db30932ec0601a4f/shadow-cljs.edn#L11#2022-11-2316:36dvingoin the release file you would not include those npm modules in the :ns form#2022-11-2316:36dvingobut your version seems like less busy work#2022-11-2316:38danielstocktonRight yeah, it's probably also the case that my namespaces could be better organized to make some of this easier.#2022-11-2316:39danielstocktoni.e. i am using parts of this namespace, but not others. Maybe i can better separate them by build.#2022-11-2316:40dvingoah gotcha. yea probably sounds like it. But if it works, then oh well 🙂 thanks for sharing the solution btw - learned a new trick#2022-11-2321:16thheller@U0DHDNZR9 you can just :resolve {"slate" false} to not include it at all, but yeah its better to organize the namespaces in a way they don't get included in the first place#2022-11-2322:08danielstocktonEven better, thanks!#2022-11-2411:14Yab MasIs it possible to solve infer-warnings by placing the ^js type-hint on a function or its return value in some way? I tried a few things but nothing seems to work. For example: This will give me an infer-warning on the .-js-attr call.
(defn interop-wrapper-fn [^js js-obj] (.interopCall js-obj))

  (defn some-fn [^js js-obj] (.-js-attr (interop-wrapper-fn js-obj)))
I would kind of expect that placing a type-hint on the return value of the interop-wrapper-fn as below would solve the issue, but it doesn't.
(defn interop-wrapper-fn ^js [^js js-obj] (.interopCall js-obj))
Ofcourse placing the typehint in the some-fn as below does work but it would be great to solve this centrally. Besides i'm curious about the reason why the method above doesn't work?
(defn some-fn [^js js-obj] (.-js-attr ^js (interop-wrapper-fn js-obj)))
#2022-11-2418:16thhellerthe return value hint should work?#2022-11-3013:01Yab MasOk... It really doesn't seem to work for me, so Im probably doing something else wrong. The issue has been sufficiently solved in a different way though. Will look at this later. Thanks for the reply.#2022-11-2413:53mkvlrSince migrating to React 18 & using hooks through reagent I noticed that remounting the app doesn't trigger a re-render of the whole component tree. If I read things correctly react-refresh is a solution to this problem, anybody manage to use with shadow-cljs? I've only found old stuff e.g. https://github.com/facebook/react/issues/17281 from @lilactown but no solution. Appreciate any pointers.#2022-11-2418:16thhellerI haven't looked at react-refresh at all#2022-11-2418:16thhellerhttps://github.com/lilactown/helix/blob/master/docs/experiments.md#fast-refresh#2022-11-2418:16thhellernot sure what the state of all that is#2022-11-2420:57mkvlrthanks for the link#2022-11-2615:11Dustin GetzOn Apple Silicon i've kernel panic'd twice now over a couple months, i think it may be related to shadow picking up fs changes. Both times it happened a bit after saving buffers to file system in Cursive with shadow watch active. Just mentioning here for future searches#2022-11-2615:26thheller@dustingetz which version do you use? I upgraded the fs watcher used on mac in the last version, maybe that helps#2022-11-2716:52fabraoHello all, I don't know why but starting from 2.20.11 of shadow-cljs , I'm having problems to use build.clj and uber .#2022-11-2716:53thhellerwhy is shadow-cljs a part of that at all? none of shadow-cljs should end up in the uberjar?#2022-11-2716:57fabraoI downgrade to 2.20.10 and the problem gone.#2022-11-2716:58thhellerthat doesn't answer my question 😛#2022-11-2716:58thhellerwhat error do you get though?#2022-11-2716:59fabraosorry :rolling_on_the_floor_laughing:#2022-11-2717:01fabraoI'm getting this error
Execution error (IllegalArgumentException) at clojure.tools.build.tasks.uber/explode (uber.clj:152).
/ is not a relative path
#2022-11-2717:02fabrao
(b/uber {:class-dir class-dir
           :uber-file uber-file
           :basis     basis
           :exclude   ["LICENSE"]
           :main      'backend.application
           :manifest  {"Git-Revision" (str/trim-newline (:out (shell/sh "git" "rev-parse" "HEAD")))
                       "Git-Tags"     (->> (:out (shell/sh "git" "tag" "--points-at" "HEAD"))
                                           (str/split-lines)
                                           (str/join " "))
                       "Build-Time"   (.format (java.time.ZonedDateTime/now) (java.time.format.DateTimeFormatter/ISO_DATE_TIME))}})
#2022-11-2717:03fabrao
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file "target/app.jar")
#2022-11-2717:05fabraoI don't see anything related to shadow-cljs , but when I use 2.20.11it gives that error#2022-11-2717:06thhellerno clue what that means. might also be one of the deps I bumped in 2.20.11#2022-11-2717:07thhellerbut I ask again. why is shadow-cljs involved in a uberjar creation? it absolutely under no circumstance should be in any uberjar ever#2022-11-2717:23fabraoSorry @thheller if I was not clear. As I referenced before, it does not have any reference to the uberjar process, I'm only referencing that in version 2.20.11 the problem shows up and I'm posting here the problem. When I use version 2.20.10 the problem is not happening.#2022-11-2717:24thhellerwhat I mean is: you seem to have shadow-cljs in deps.edn either directly or in an alias ACTIVE while building the uberjar#2022-11-2717:24thhellerthat SHOULD NOT be done. put it into a cljs alias or whatever that is not active when building the uberjar#2022-11-2717:25thhellerbut regardless I don't have a clue what the error means, or what to do about it#2022-11-2717:25Applehttps://clojurians.slack.com/archives/C6N245JGG/p1668750585171269 I had similar issue with .12 and .10 works. not necessarily an issue with shadow but one of those situation that java libs have conflict. the workaround for me is to use .10#2022-11-2717:27fabraoThank you Apple, I think it should be similar to my case too.#2022-11-2717:28thhellerthose appear to be two entirely different errors though?#2022-11-2717:30fabraoabout the errors yes, but it's relate to using version 2.20.11-12#2022-11-2717:32AppleI would just stick to .10 and feel that this is not worth looking into for now. It'll go away I believe.#2022-11-2717:34thhellerI doubt that. I mean your issue was a guava version conflict. that is not going to solve itself#2022-11-2717:38Applehttps://github.com/thheller/shadow-cljs/commit/2b143d0ce5046fb1af81bb9ea368cb4eb4ece5a6 this? remove guava dep
only added since the closure-compiler didn't properly declare
it itself. this is now fixed, so this is no longer needed.
#2022-11-2717:54thhellerno, in your project. there is a guava conflict off some kind#2022-11-2717:55thhellerthe closure-compiler has always depended on guava. but for a while it didn't declare it properly and just included it in its own jar#2022-11-2717:55thhellerno it is properly declared again and coming as an extra dep#2022-11-2717:56thhellershadow-cljs only declared it temporarily, so it at least showed up in the dependency tree as a potential cause#2022-11-2717:56thhelleryou may just add [com.google.guava/guava "31.0.1-jre"] to your own deps if that fixes anything#2022-11-2717:56thhelleror resolve the conflict, wherever your version came from#2022-11-2718:47Appleyou nailed it. adding com.google.guava/guava {:mvn/version "31.1-jre"} to deps.edn and how 2.20.12 works.#2022-11-2718:49fabrao@zengxh 😀, I'm trying this now, because the 31.0.1-jre did not work to me#2022-11-2718:50thheller@fabrao IMHO the only thing you should be looking for is REMOVING shadow-cljs from the dependencies that run when you build an uberjar#2022-11-2718:50thhellerI cannot emphasize this enough. you DO NOT WANT shadow-cljs in your uberjar#2022-11-2718:51thhellerso remove that. literally nothing else is relevant. if I could make it blow up every uberjar build that includes it I would. it just should not make it into any uberjar.#2022-11-2718:51thhellerand as a side effect it'll also fix your issue most likely#2022-11-2718:51thhellershadow-cljs is a development tool#2022-11-2718:51thhellerit has no place in an uberjar#2022-11-2718:52fabraoremove from where? I have this in my shadow-clj.edn -> :deps true#2022-11-2718:52thhellerand where do you have it in deps.edn#2022-11-2718:52thhellerI mean from that I can already tell#2022-11-2718:52thhellerand thats what I mean#2022-11-2718:53thhellerchange your shadow-cljs.edn to be :deps {:aliases [:cljs]}#2022-11-2718:53thhellerthen move the thheller/shadow-cljs dependency from the main deps to a :cljs alias#2022-11-2718:53thheller(you may also move all other CLJS dependencies, since none of them are relevant in an uberjar either)#2022-11-2718:54fabraooh, right, I see the point#2022-11-2718:54Applei use shadow api to do compile/release so it's part of my deps.edn shadow itself will not be in the final uber so it's ok#2022-11-2718:55Applejust want to save on jvm instances#2022-11-2718:55thhelleras long as its in an alias everything is fine#2022-11-2718:55thhellertop level is not recommended
#2022-11-2718:56Appleyep#2022-11-2718:58Applein my build i have 3 jars built: 1. java/clj lib 2. cljs 3. compiled clj sources written by me most of the time i only need to update part2, and sometimes part3 part1 only when i update lib deps.#2022-11-2719:22fabrao@thheller removing it from main deps and using it in :alias worked. Thank you#2022-11-2913:30Joni~Hey I’m having a weird issue running karma tests with a shadow-cljs project in github actions and wondering if anyone here has ran in to the same issue. Currently if I initialise my app locally from scratch and run ~ turns out we had used require-macros instead of :require for cljs.test in the test namespace. This was just a really weird interaction that took way too long to debug 😄#2022-11-2921:06p-himikSeeing some very interesting behavior with shadow-cljs 2.20.12 and @material-ui/. Both of these items work just fine in :require:
["@material-ui/core/Button" :default Button]
["@material-ui/core/Button$default" :as Button]
But if I replace Button with Box, only the first import will work. Or rather, the component itself will work. The second import will produce cljs.core/Box instead of that MUI Box.
#2022-11-2921:07thhellerhmm?#2022-11-2921:09p-himikIf I import ["@material-ui/core/Box" :default Box] then Box becomes what I expect it to be. If I import ["@material-ui/core/Box$default" :as Box] then Box is cljs.core/Box.#2022-11-2921:11p-himikAdding Box to :refer-clojure :exclude seems to fix it. But there's also no warning about Box shadowing if I don't do that.#2022-11-2921:11p-himikSo it's as if ["@material-ui/core/Box$default" :as Box] is completely ignored because there's already cljs.core/Box. Still weird though that there's no warning for ["@material-ui/core/Box" :default Box] even though it properly shadows cljs.core/Box.#2022-11-2921:15thhellerah hmm. might be a ordering issue where :as alias are checked "too late"#2022-11-2921:15thhellersince they are normally not callable#2022-11-3008:26HankstenbergHi guys, what's the best way to run two shadow-cljs-builds side by side with different ports? I tried to just change the ports in shadow-cljs.edn, but it says "already running".#2022-11-3008:26thhellera build doesn't have a port at all? which port do you mean?#2022-11-3008:26thhelleras for running two builds npx shadow-cljs watch build-a build-b#2022-11-3008:33HankstenbergAh, thank you!#2022-11-3008:34thhelleryou can also just run npx shadow-cljs server and then control/toggle the builds via the http://localhost:9630 web ui#2022-11-3008:34thhelleror from the REPL 😉#2022-12-0100:42seepelI have a shadow-cljs project and I’d like to write a large portion of it using Typescript/React. What is a good way to setup my project?#2022-12-0107:02thhellerprobably best to use https://shadow-cljs.github.io/docs/UsersGuide.html#target-esm with https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration#2022-12-0107:02thhellerand then use whatever else for typescript, as shadow-cljs doesn't support that at all#2022-12-0108:00niwinzhello @thheller I found a strange case that is happening in a while on our project. We have the following release config:
:compiler-options
   {:output-feature-set :es2020
    :output-wrapper false
    :warnings {:fn-deprecated false}}

   :release
   {:closure-defines {goog.DEBUG false
                      goog.debug.LOGGING_ENABLED true}
    :compiler-options
    {:fn-invoke-direct true
     :optimizations #shadow/env ["PENPOT_BUILD_OPTIMIZATIONS" :as :keyword :default :advanced]
     :source-map true
     :elide-asserts true
     :anon-fn-naming-policy :off
     :source-map-detail-level :all}}}
but the *assert* is still true (we have released some "in development" code (new features) to production build because of this hehehe)
#2022-12-0108:00niwinzdo you have any hints why this can happen?#2022-12-0108:01thhellerwhat is *assert*?#2022-12-0108:01niwinzassert is a dynamic variable set on compile time, by the :elide-asserts true#2022-12-0108:01thhelleryes, but when are you "testing" it?#2022-12-0108:02niwinzon release build#2022-12-0108:02thhellerit is a runtime binding, so it is only bound to false while compiling?#2022-12-0108:02thhellerit already defaults to eliding asserts in release builds, dunno why you are setting it?#2022-12-0108:03niwinzjust for explicitnes#2022-12-0108:03thhellerI still don't know what problem you are describing though#2022-12-0108:03thhellerhow or where does this problem manifest?#2022-12-0108:04thhellerassserts are removed in release builds, so what does *assert* mean to you?#2022-12-0108:04niwinzI expect *assert* value to be false on production builds, and I think it worked in this manner for some time#2022-12-0108:06niwinzwe have our own assets macro helpers, and also we used this for exclude code from production builds, and it worked when we started to using it, but now is no longer working (and I don't know really when it happened)#2022-12-0108:06thhelleragain I ask: WHEN should it be false? in what context? when and where are you looking at it?#2022-12-0108:06thhellerit is bound to false, via binding. so it really really depends on when and where you are looking at it#2022-12-0108:07niwinzhttps://github.com/penpot/penpot/blob/develop/frontend/src/app/main/features.cljs#L65#2022-12-0108:07thhellerhttps://github.com/thheller/shadow-cljs/blob/e53240007b45ab891f23edcb96b2ed377fafc471/src/main/shadow/build/compiler.clj#L605-L606#2022-12-0108:08niwinzthis is one use case, it worked in the past, right now, is obviously does not work, because the *assert* has value true on release builds#2022-12-0108:08thhellerthat is CLJS code#2022-12-0108:08thheller*assert* is a CLJ runtime binding, so it only works in macros#2022-12-0108:09niwinzyep, ok, I understand it, I just asked for a hint, because in the past is also worked outside macros because the value of this var was set to false on release builds, thats it#2022-12-0108:10thhellerthat might be true for regular cljs maybe? I have never modified how this worked in shadow-cljs#2022-12-0108:11thhellermaybe you tested with the self-hosted compiled?#2022-12-0108:11niwinzin any case, thanks for your time, I expect this value to be true right now independentry of :elide-asserts on cljs code#2022-12-0108:11thhellerI can find any reference on this ever getting bound during normal cljs compilation#2022-12-0108:12thhellerhttps://github.com/clojure/clojurescript/blob/961807166c8cf4d45a225d63416f06464fb27eaf/src/main/cljs/cljs/core.cljs#L67-L69#2022-12-0108:12thhelleryes, it is always true#2022-12-0108:13thhelleryou could just change the (when *assert* to (when ^boolean js/goog.DEBUG#2022-12-0108:13thhellerto achieve the same but get rid of the *assert* assumption#2022-12-0108:13thhelleryou could also introduce your own goog-define#2022-12-0108:14niwinzyep, is what I going to do, We clearly used incorrectly the *assert*, It just worried me a bit because when we writted this code and other similar one, because it worked on first time, but I don't know why. In any case it is not shadow fault#2022-12-0108:23niwinzin any case, thanks for your time#2022-12-0122:11kokonutI am using shadow-cljs and once I included cljs-http I am getting this message about dependency conflict. Is there any way to resolve them? I used to handle this type of conflict in lein on backend but I am still a newbie on frontend (shadow).
[:frontend] Build completed. (232 files, 133 compiled, 2 warnings, 0.84s)

------ WARNING #1 - :redef -----------------------------------------------------
 Resource: no/en/core.cljc:131:1
 parse-long already refers to: cljs.core/parse-long being replaced by: no.en.core/parse-long
--------------------------------------------------------------------------------

------ WARNING #2 - :redef -----------------------------------------------------
 Resource: no/en/core.cljc:136:1
 parse-double already refers to: cljs.core/parse-double being replaced by: no.en.core/parse-double
--------------------------------------------------------------------------------
#2022-12-0122:16kokonutIt seems the same topic was already discussed. https://clojurians.slack.com/archives/C6N245JGG/p1657707256386529 But it also looks like there is no way to resolve or oppress the warning.#2022-12-0122:17kokonutMy case is worse because when I see this message my cljs repl on cider doesn't work properly. I may have to avoid using cljs-http and use cljs-ajax instead.#2022-12-0123:10dpsuttonwhy doesn’t your repl work properly?#2022-12-0123:11dpsuttonthe solution is to have the dep that defines parse-long and parse-double to exclude those with (:refer-clojure :exclude [parse-long parse-double])#2022-12-0123:11kokonutI honestly don't know. Once I included this lib in shadow-cljs, I get this error.
No available JS runtime.
See 
#2022-12-0123:12dpsuttonand that error goes away if you exclude the cljs-http dep?#2022-12-0123:12kokonutyes, exactly.#2022-12-0123:12dpsuttonraise an issue with CIDER. that is bizarre and unexpected#2022-12-0123:13dpsuttonif you can get a minimal repro that would be handy. Do you perhaps have a setting to fail builds on warnigns?#2022-12-0123:13dpsuttonbecause those are otherwise benign#2022-12-0123:14kokonutYep, sounds like plan. I will raise an issue.#2022-12-0123:01Sam Ritchieis it possible to use goog-define to conditionally require or not require some npm dep?#2022-12-0123:03Sam RitchieI would like to strip this:
["@cortex-js/compute-engine" :refer [ComputeEngine]]
from require… and then ALSO strip the code in the namespace that uses ComputeEngine… should I remove it from the namespace block and do a manual require?
#2022-12-0123:07Sam RitchieIf I do
(when COMPUTE_ENGINE
  (require '["@cortex-js/compute-engine" :refer [ComputeEngine]]))
Then this later fails:
(when COMPUTE_ENGINE
  (def engine
    (ComputeEngine.)))
[:clerk] Build failure:
------ ERROR -------------------------------------------------------------------
 File: /Users/sritchie/code/clj/mathlive.cljs/src/mathlive/core.cljs:95:5
--------------------------------------------------------------------------------
  92 |
  93 | (when COMPUTE_ENGINE
  94 |   (def engine
  95 |     (ComputeEngine.)))
-----------^--------------------------------------------------------------------
null
AssertionError: Assert failed: (symbol? module)
#2022-12-0123:07Sam RitchieI guess predictably, I am just not sure how to use this feature to strip out this stuff#2022-12-0123:09Sam Ritchieah, found it https://shadow-cljs.github.io/docs/UsersGuide.html#_conditional_reading#2022-12-0206:34thhellerconditional requires don't really work#2022-12-0206:35thhellerI suggest organizing the code differently so that the "optional" code is in a separate namespace that the user can require if needed#2022-12-0202:16CrispinHi everyone. I'm trying to load a shadow build code module (code splitting) at run time into the browser and when I do the shadow.loader/load I get shadow.loader API was called before shadow.loader.init! You are probably calling module loader too early before shadow-cljs got fully initialized.#2022-12-0202:16Crispinshadow-cljs.edn build looks like:#2022-12-0202:17Crispin
:builds
 {:main
  {:target :browser
   :output-dir "resources/public/cljs-out"
   :asset-path "/app"
   :build-hooks
   [(shadow.cljs.build-report/hook
      {:output-to "builds/report.html"})]
   :modules
   {:base {:entries []}
    :main {:entries [myproject.web-app.main]
           :depends-on #{:base}}
    :pdf-viewer {:entries [myproject.web-app.pdf-viewer]
                 :depends-on #{:base}}}
   }}}
#2022-12-0202:19Crispin:main is all loaded, and then when I do any load, for example (shadow.loader/with-module "pdf-viewer" #(js/alert "LOADED")) I get the:
shadow.loader API was called before shadow.loader.init!
You are probably calling module loader too early before shadow-cljs got fully initialized.
#2022-12-0202:20CrispinCalling init myself does nothing. Because it's not initialising. I think.#2022-12-0202:22Crispindigging in, I notice here: https://github.com/thheller/shadow-cljs/blob/7fefe5b3f604ff11d33539e4899e160dd1ff6eb0/src/main/shadow/loader.js#L42 that init is only done if goog.global.shadow$modules is defined. In my browser session it is not defined#2022-12-0202:22Crispin
>> goog.global.shadow$modules
undefined
#2022-12-0206:36thheller@U1QQJJK89 if you intend to use the loader you must set :module-loader true in the build config#2022-12-0206:41CrispinThat worked. Now going back to the docs I can see that written clearly, but somehow I just didn't see that at the time. facepalm#2022-12-0206:41CrispinThankyou for an awesome tool#2022-12-0310:11yiorgosHi guys, is there a way to hot reload when I do changes in the “index.html” file? atm hot reloading works only when I edit/save cljs files. Thanks!#2022-12-0513:23JoniWith version 2.20.12 the basic http server doesn’t serve the index.html from /resources/public when given :root "resources/public" but the version 2.19.2 does. Is there some known configuration change that’s happened or is this a regression?#2022-12-0707:09HukkaAre you also using shadow's proxy? I encountered a problem in 2.19.9 https://clojurians.slack.com/archives/C6N245JGG/p1665086160661559?thread_ts=1665058569.004029&amp;cid=C6N245JGG#2022-12-0707:24JoniDidn’t get to testing that as I had to rollback the version#2022-12-0710:24JoniOkey yea this is an issue with the proxy-url#2022-12-0710:25JoniIf the proxy-url option is given the re-direct to index.html stops working with the latest version. But if no proxy-url option is given it works. Also it everything works as expected with the version 2.19.2#2022-12-0710:35Jonihttps://github.com/thheller/shadow-cljs/issues/1071 created an issue for this#2022-12-0517:50thhelleryou mean you open :<the-port> and it doesn't serve resources/public/index.html?#2022-12-0519:00JoniYes exactly this#2022-12-0517:50thhellerthat should definitely still work#2022-12-0517:51thhellerwhat may have changed is that if you have your own :handler as well. since that didn't previously get called for those files, but now is#2022-12-0519:45byrongibbyHi. How do I override the location of my local maven repository in shadow-cljs.edn? Thanks#2022-12-0520:35thheller:maven {:local-repo "foo"}#2022-12-0605:14byrongibbyThanks a lot!#2022-12-0710:35Jonihttps://github.com/thheller/shadow-cljs/issues/1071 created an issue for this#2022-12-0609:33wcalderipeHey folks, I'm wondering how I can debug the input and output of the nREPL?#2022-12-0609:34thhellerthere is a little helper I wrote for that#2022-12-0609:35thhellernpx shadow-cljs run shadow.nrepl-debug 6001 6000#2022-12-0609:35wcalderipeThanks a lot#2022-12-0609:35thhellerthis forwards all traffic from tcp port 6001 to 6000#2022-12-0609:35thhellerso assuming your regular nrepl server is running on 6000#2022-12-0609:35thhelleryou connect your client to 6001 instead#2022-12-0609:36thhellerwrites all sent packets to target/nrepl-debug dir#2022-12-0609:36thhellerjust a log file of edn packets#2022-12-0609:36thhellerdepending on the chattiness of your client that can get pretty large#2022-12-0609:37thhelleryou can also run it with leiningen or clj#2022-12-0609:37thhellerclj -M -m shadow.nrepl-debug 6001 600 (with shadow-cljs as added dependency)#2022-12-0609:38thhellerlein run -m shadow.nrepl-debug ... (same)#2022-12-0609:38thhellera dumb little helper to just get some log of what actually went over the wire#2022-12-0609:44wcalderipeIt'll do the job. Thanks again!#2022-12-0612:55Valentin MouretHello 🙂 I am facing a weird situation and I can only pinpoint it to the shadow/re-frame interaction. The same application works fine in dev, but it looks like subs are broken on production (`release`). Is there something I am missing like a require somewhere? Edit: solved Problem between the keyboard and the chair.#2022-12-0612:56Valentin Mouretdev/release difference sounds like the closure compiler doing something funky, but event/subs are only about emitting namespaced keywords, so I don’t know what could be wrong here. My view is essentially receiving nil from a sub in release, but it works fine in watch mode.#2022-12-0612:57Valentin MouretEvents look alright.#2022-12-0716:18juhoteperiI'm seeing a regression between 2.20.10 and 2.20.11 in build report output and used npm files. With 2.20.11+ I'm only seeing the JS files that are directly required from Cljs code.#2022-12-0717:41thhellerhmm weird, didn't knowingly change anything#2022-12-0808:16juhoteperiMight be just the Closure update? I'm not sure how directly the report uses Closure information?#2022-12-0809:01juhoteperiStrange, I'm seeing the same extract-report-data build-sources data for a JS file that isn't visible on 2.20.11 report for both versions.#2022-12-0809:15juhoteperiThe difference is in build-modules source-bytes data#2022-12-0809:19thhellerhmm yeah the problem seems to be in the generated source maps#2022-12-0809:19thhellersomehow a bunch of stuff is missing#2022-12-0809:22juhoteperihttps://github.com/google/closure-compiler/commit/c14448355609eb52a933f2cd0c201533506c71bc#diff-0ff91976a315270f18cbe5e684cd54217218c4d8ea3182b7632d20a55d92b485 this is probably the biggest change in Closure between the releases#2022-12-0809:40thhellerhttps://github.com/thheller/shadow-cljs/blob/581c2829e4c09f9328c6866d3fa6aa22b9c4b63f/src/main/shadow/build/closure.clj#L2062-L2068#2022-12-0809:40thhellersomething here seems to be wrong now. the source maps generated here are all empty#2022-12-0809:40thhellerwhen they didn't use to be#2022-12-0809:51thhellerfound it https://github.com/thheller/shadow-cljs/commit/42a98e12059826724eb5c2d83571ba9bd9f3c6d4#diff-19933da1441dc0cbae79c8b0786f6e739c85394439c54d15411e6852080b7f73L40#2022-12-0810:07thhellershould be fixed in 2.20.14. very obvious mistake in hindsight 😛#2022-12-0810:08juhoteperiGreat!#2022-12-0722:03Drew VerleeI get an error when i start my app i'm hoping someone can give me some insight into. The error doesn't seem to effect anything as far as i can tell though.
shadow.module.main.append.js:4 An error occurred when calling (centriq-web.main/init!)
eval	@	shadow.module.main.append.js:4
goog.globalEval	@	main.js:472
env.evalLoad	@	main.js:1534
(anonymous)	@	main.js:2253
and the ns in question looks like this:
(ns centriq-web.main
  (:require [centriq-web.admin :refer [admin-component]]
            [reagent.dom :as dom]))

(defn init! []
  (dom/render [admin-component] (.getElementById js/document "app")))
And as you might imagine the shadow cljs uses that init! function to as the init-fn
:builds
 {:app {:target :browser
        :compiler-options {:externs ["datascript/externs.js"]}
        :modules {:main {:init-fn centriq-web.main/init!}}}}
The if i follow the error to the shadow.module.main.append file i don't learn much. MY two theories are that 1. this error comes from my not properly configuring shadow. e.g i forgot to add some build configuration or maybe a hook or annoate the init! function with some meta data. 2. this error is a catch all and the real issue is surfaced else where in the console log.
#2022-12-0722:51Drew Verleeit was the later.#2022-12-0810:20juhoteperiAnother thing on the build-report, some JS files aren't grouped under the npm package. For some reason the :npm-info has a funny :package-id and empty :package-name and :version for some files.#2022-12-0810:29juhoteperi@mui/x-data-grid contains separate package.json under components/ folder so I think that will be picked up by read-package-json#2022-12-0810:29juhoteperiBut some files under components/ are still grouped under the real npm package#2022-12-0810:32juhoteperi
{:npm-info {:package-id "/home/juho/Work/foo/bar/frontend/node_modules/@mui/x-data-grid/
#2022-12-0810:58thhellerhmm yeah weird package.json contents confuse the system a little bit#2022-12-0811:00thhellerI guess it should keep looking up for "name" if there isn't one#2022-12-1209:31juhoteperihttps://github.com/thheller/shadow-cljs/issues/1074#2022-12-1209:33juhoteperiI did look at shadow.build.npm but as far as I understand, it is finding the closest package.json on purpose, so it doesn't seem to be trivial to change this. Perhaps there should be separate info for "real" package.json for the files that are under these nearly empty package.json files, and then build report could use that information.#2022-12-1209:48thhelleryeah the name and version fields are only used for the build report. the other stuff is more important for the actual build#2022-12-1209:48thhellershould still work properly though, I'll check it out#2022-12-0815:32Derek2.20.14 made it to Clojars but not to npm#2022-12-0815:33thhelleroops, fixed#2022-12-0815:33Derekty#2022-12-0917:14Sam Ritchiehey all - for some reason I am not seeing a manifest.edn in my output directory. is there some way to ensure that it’s produced?#2022-12-0917:17Sam Ritchiewith this shadow-cljs.edn https://github.com/mentat-collective/jsxgraph.cljs/blob/sritchie/new_clerk/shadow-cljs.edn#2022-12-0917:29thhelleronly :target :browser generates the manifest. the other targets don't need it#2022-12-0918:30zalkyHi all, I'm trying to use code splitting to load debugging code wtihout having the production app burdened with the debug code. The way it is now, the debug module needs to be called after the re-frame subscription cache is cleared, but before the app is rendered to the dom.
(defn init!
  []
  (f/clear-subscription-cache!)
  (shadow.loader/load "debug")          ; Must happen here
  (some->> "container"
           (.getElementById js/document)
           (dom/render [ui/app])))
However, it seems that with the code above the debug module is actually being executed after the dom/render. I have the following in my shadow config:
{:module-loader true
 :modules       {:main  {:init-fn app/init!}
                 :debug {:depends-on #{:main}
                 :entries    [app.debug.loader]}}}
Are my expectations wrong that the module would be loaded synchronously at (shadow.loader/load "debug")?
#2022-12-0918:38thhelleryes, it requires IO. so it can only load async.#2022-12-0918:38thhelleralso don't do this#2022-12-0918:39thhellermake a second build with all the debug stuff included. that just loads everything#2022-12-0918:40thhellersomething like
{:module-loader true
 :modules       {:main  {:entries [app.debug.loader]
                         :init-fn app/init!}}}
#2022-12-0918:40thhellerdon't ever use code-splitting to "remove" debug code#2022-12-0918:41thhellerjust the presence of the debug code in the build will hinder :advanced and likely make your build much larger even in the :main module#2022-12-0918:47zalkyThanks for the response! Hmm... at that point do I even need the module-loader? It would seems that there's no dynamic module loading with that approach?#2022-12-0918:50thhellercorrect. not needed#2022-12-0918:51zalkyOk, and just to be clear, you're suggesting I should duplicate app/init! one with the debug line and one without?#2022-12-0918:53thheller
{:modules {:main {:init-fn app/init!}}
 :dev {:modules {:main {:entries [app.debug.loader]}}}}
#2022-12-0918:53thhelleryou can also do this with just one build#2022-12-0919:27zalkyApologies, I'm not sure I immediately parse the above map. Is it missing an :app build? How do you mean "one build". A little more detail on what I'm trying accomplish: I'm putting together a little OSS lib that has both domain features and debug features. In an ideal world, a user would use the domain features as normal, and where necessary include a preloads namespace for the debug module. However, the use of re-frame f/clear-subscription-cache! introduces imperative logic around instantiated subscriptions in the debug module. I can't just dump the debug module in a preload namespace because the debug module has to be loaded after the (f/clear-subscription-cache!), but ideally before the render. I'm not really sure I see how to accomplish this imperatively without dynamic module loading. I guess a solution where the user defines two builds, with duplicated init methods one with and without the debug loading could work. But I've been trying to identify the approach that would be easiest to use as a library, and I'm not sure I've found it yet.#2022-12-0918:41folconHas something changed about how shadow-cljs works? I've got it setup in my user.clj to require shadow in the form of [shadow.cljs.devtools.api :as shadow] so I can then call (shadow/watch :app) and (shadow/browser-repl). However just trying to start the repl blows up. Commenting out the require seems to work and then sending the form to my repl does this:
Connecting to local nREPL server...
Clojure 1.11.1
nREPL server started on port 63444 on host 127.0.0.1 - 
(ns user
  (:require [shadow.cljs.devtools.api :as shadow]))
Execution error (NoSuchMethodError) at com.google.javascript.jscomp.deps.ModuleLoader/createRootPaths (ModuleLoader.java:257).
'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'
I'm using [thheller/shadow-cljs "2.20.13"] via lein.
#2022-12-0918:42thhellernothing has changed, except that you introduce a dependency conflict. likely on guava#2022-12-0918:42folconTo add more detail:
*e
=>
#error{:cause "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'",
       :via [{:type clojure.lang.Compiler$CompilerException,
              :message "Syntax error macroexpanding at (closure.clj:77:5).",
              :data #:clojure.error{:phase :execution, :line 77, :column 5, :source "closure.clj"},
              :at [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1750]}
             {:type java.lang.NoSuchMethodError,
              :message "'java.util.stream.Collector com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet(java.util.Comparator)'",
              :at [com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]}],
       :trace [[com.google.javascript.jscomp.deps.ModuleLoader createRootPaths "ModuleLoader.java" 257]
               [com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 147]
               [com.google.javascript.jscomp.deps.ModuleLoader <init> "ModuleLoader.java" 48]
               [com.google.javascript.jscomp.deps.ModuleLoader$Builder build "ModuleLoader.java" 139]
               [com.google.javascript.jscomp.deps.ModuleLoader <clinit> "ModuleLoader.java" 408]
               [com.google.javascript.jscomp.DiagnosticGroups <clinit> "DiagnosticGroups.java" 182]
               [jdk.internal.misc.Unsafe ensureClassInitialized0 "Unsafe.java" -2]
               [jdk.internal.misc.Unsafe ensureClassInitialized "Unsafe.java" 1160]
               [jdk.internal.reflect.MethodHandleAccessorFactory
                ensureClassInitialized
                "MethodHandleAccessorFactory.java"
                300]
               [jdk.internal.reflect.MethodHandleAccessorFactory
                newMethodAccessor
                "MethodHandleAccessorFactory.java"
                71]
               [jdk.internal.reflect.ReflectionFactory newMethodAccessor "ReflectionFactory.java" 159]
               [java.lang.reflect.Method acquireMethodAccessor "Method.java" 720]
               [java.lang.reflect.Method invoke "Method.java" 575]
               [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
               [clojure.lang.Compiler$StaticMethodExpr eval "Compiler.java" 1743]
               [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3713]
               [clojure.lang.Compiler$DefExpr eval "Compiler.java" 457]
               [clojure.lang.Compiler eval "Compiler.java" 7199]
               [clojure.lang.Compiler load "Compiler.java" 7653]
               [clojure.lang.RT loadResourceScript "RT.java" 381]
               [clojure.lang.RT loadResourceScript "RT.java" 372]
               [clojure.lang.RT load "RT.java" 459]
               [clojure.lang.RT load "RT.java" 424]
               [clojure.core$load$fn__6908 invoke "core.clj" 6161]
               [clojure.core$load invokeStatic "core.clj" 6160]
               [clojure.core$load doInvoke "core.clj" 6144]
               [clojure.lang.RestFn invoke "RestFn.java" 408]
               [clojure.core$load_one invokeStatic "core.clj" 5933]
               [clojure.core$load_one invoke "core.clj" 5928]
               [clojure.core$load_lib$fn__6850 invoke "core.clj" 5975]
               [clojure.core$load_lib invokeStatic "core.clj" 5974]
               [clojure.core$load_lib doInvoke "core.clj" 5953]
               [clojure.lang.RestFn applyTo "RestFn.java" 142]
               [clojure.core$apply invokeStatic "core.clj" 669]
               [clojure.core$load_libs invokeStatic "core.clj" 6016]
               [clojure.core$load_libs doInvoke "core.clj" 6000]
               [clojure.lang.RestFn applyTo "RestFn.java" 137]
               [clojure.core$apply invokeStatic "core.clj" 669]
               [clojure.core$require invokeStatic "core.clj" 6038]
               [shadow.build.js_support$eval5552$loading__6789__auto____5553 invoke "js_support.clj" 1]
               [shadow.build.js_support$eval5552 invokeStatic "js_support.clj" 1]
               [shadow.build.js_support$eval5552 invoke "js_support.clj" 1]
#2022-12-0918:43folconOh? I'm not requiring guava myself, so there's a deps mismatch that I need to resolve?#2022-12-0918:43folconSo I'll just deps tree and require the latest version? Or does shadow-cljs need a specific older version?#2022-12-0918:44thhellershadow-cljs doesn't use it at all. the closure compiler does#2022-12-0918:44thhellerthe most common problem is having datomic on the classpath as well#2022-12-0918:45thhellerwhich brings in an older incompatible version#2022-12-0918:45thhellercheck the lein deps :tree output#2022-12-0918:45thhellersomewhere it'll tell you about a guava conflict#2022-12-0918:45folconAh cool, ok it seems metosin is requiring [com.google.guava/guava "16.0.1"]#2022-12-0918:45thhelleruhm yeah that is waaay too old 😛#2022-12-0918:45thheller31 something I think is the needed version#2022-12-0918:47folconYep, trying [com.google.guava/guava "31.1-jre"]#2022-12-0918:50folconThis is the one thing I do wish was a bit better, you can have stuff working perfectly well which then blows up when you're doing a deps build on a clean repo and you have no idea what's causing the failure...#2022-12-0918:51folconOk, this is weird, now shadow is complaining that shadow-cljs has not been started yet?
(shadow/watch :app)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.runtime/get-instance! (runtime.clj:10).
shadow-cljs has not been started yet!
In embedded mode you need to call (shadow.cljs.devtools.server/start!) to start it.
If you have a shadow-cljs server or watch running then you are not connected to that process.
But I have it running in a separate terminal.
#2022-12-0918:51folconSame folder#2022-12-0918:51folconSo it should be working off the same .shadow-cljs folder#2022-12-0918:52thhellerI dont understand the question#2022-12-0918:54folconSorry, I'm calling (shadow.cljs.devtools.api/watch :app) Which normally just says the watch is running. So I can confirm that the server REPL is seeing the same stuff that the watch command I'm running via npx shadow-cljs watch app is seeing.#2022-12-0918:54thhellerthe problem is self inflicted by mixing in your CLJ dependencies#2022-12-0918:54thhellerif you just use shadow-cljs.edn with only your CLJS deps this won't happen#2022-12-0918:54thhelleryes, I understand the watch part#2022-12-0918:54thhellerbut if you get shadow-cljs has not been started yet! you are not connected to a running shadow-cljs#2022-12-0918:55thhellerso maybe you started a lein REPL#2022-12-0918:55thhellerin which case you need to start shadow-cljs in that REPL first#2022-12-0918:55thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2022-12-0918:57folconSo my process, which I normally use is based on: 1. Run npx shadow-cljs watch app 2. Start the lein repl via cursive and require [shadow.cljs.devtools.api :as shadow] 3. Confirm the connection via (shadow/watch :app) 4. Start a browser repl with (shadow/browser-repl) The problem is that if I don't do it this way, I don't get clojurescript symbol import. Checking the embedded link you shared#2022-12-0918:58thhellerok, so you start two separate JVMs#2022-12-0918:58thhellerjust skip the npx shadow-cljs watch app#2022-12-0918:58thhellerand run the start! described in the docs#2022-12-0918:58folconYep, which has worked, as it keeps clojurescript errors contained in one location (the terminal)#2022-12-0918:59folconOk, so that's the way to do this now?#2022-12-0918:59thhellerthere are a million ways to do this and none of this has changed since it was released#2022-12-0918:59thhellerit is all up to you and how you want to use it#2022-12-0919:01folconThat's fair, I suppose I'm trying to work out why this is no longer able to detect the running shadow-cljs instance whereas previously it could.#2022-12-0919:01thhellerif you run npx shadow-cljs watch app you don't need an extra (shadow/watch :app) since that is redundant#2022-12-0919:01folconOh sure, but in this case it confirms that the clojure server can also see the same watcher.#2022-12-0919:02thhellerit all depends on which JVM you are connected to#2022-12-0919:02folconAs I think it emits an already-started keyword or something#2022-12-0919:02thhellerif you connect to the actual shadow-cljs instance everything is fine#2022-12-0919:02thhellerif you start a new JVM with a new REPL you get the not started error#2022-12-0919:03folconThat's fair, I'll try a remote connect#2022-12-0919:06folconHuh, that's interesting:
(require '[shadow.cljs.devtools.server])
=> nil
(shadow.cljs.devtools.server/start!)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server/check-for-other-instance! (server.clj:412).
shadow-cljs already running in project on . Use or terminate it before starting another one.
So it can detect it, but not connect to it?
#2022-12-0919:14folconHmm, ok, running it directly in the repl doesn't quite work:
=> :shadow.cljs.devtools.server/started
(shadow/watch :app)
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
IllegalArgumentException: No matching method legacySetOutputFeatureSet found taking 1 args for class com.google.javascript.jscomp.CompilerOptions
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:127)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	shadow.build.closure/set-options (closure.clj:166)
	shadow.build.closure/convert-goog* (closure.clj:2298)
	shadow.build.closure/convert-goog (closure.clj:2445)
	shadow.build.closure/convert-goog (closure.clj:2396)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1241)
	shadow.build.compiler/compile-all (compiler.clj:1475)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:360)
	shadow.cljs.devtools.server.worker.impl/eval16926/fn--16928 (impl.clj:445)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--16684/fn--16685/fn--16693 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--16684/fn--16685 (util.clj:282)
	shadow.cljs.devtools.server.util/server-thread/fn--16684 (util.clj:255)
	java.lang.Thread.run (Thread.java:1589)
Thanks for your help =)... I'll try and see if I can re-engineer this to work again, the split workflow was helpful as I could keep the client-side / server side deps separate, whereas now I would need to co-mingle them. The biggest issue is no longer having easy access to the browser repl, though I can just use a remote repl connection to use that, so perhaps it's fine 😃...
#2022-12-0919:28thhellerthis again is a dependency conflict#2022-12-0919:28thhellerthis time on the closure compiler itself#2022-12-0919:28thhellerthe CLJ parts never try to connect to another server#2022-12-0919:29thhellerthe shadow-cljs command does#2022-12-0919:29thhellerthat "shadow-cljs already running in project" is an error I added recently because people often unknowingly started two shadow-cljs instances which compete with each other#2022-12-0919:30folconAh ok, it appears I had some working frankenbuild 😃...#2022-12-0921:18hifumi123Is it possible to have dependencies specific to a build in a pure shadow-cljs project? For context on my problem: the dev builds of my app make use of two devtools preloads. One depends on highlight.js and has it added as a normal dependency in my package.json file, instead of as a dev dependency. I want to avoid unnecessarily packing libraries into production builds#2022-12-0921:53thheller@hifumi123 not required, if you don't require it it won't be included in the build. extra dependencies otherwise have no impact.#2022-12-0921:56hifumi123Awesome. One more question, is it possible to get autocomplete for node modules?#2022-12-0921:56hifumi123I'm able to get autocomplete for e.g js/document and of course ClojureScript libraries, but not node modules#2022-12-0921:56thhellernot something shadow-cljs provides generally. your editor would do that#2022-12-0921:57hifumi123Hmm... I guess I will have to figure out how to get this set up with CIDER then. Thanks anyway!#2022-12-1108:52zeitsteinI'm trying out using https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js. This compiles and works:
export class Test {
  static foo = "bar";

  static staticMethod() {
    alert(this === Test);
  }
}
But I'm wondering why because > The Closure Compiler is used for processing all JavaScript found on the classpath using its ECMASCRIPT_NEXT language setting. and the https://github.com/google/closure-compiler/issues/2731? I just want to make sure I'll not encounter issues if I go down this path.
#2022-12-1109:03thhellerjust make sure to test with advanced and stuff#2022-12-1109:03thhellerno guarantee this works#2022-12-1109:05zeitsteinThanks. Related, your modern/defclass macro doesn't support static fields as well, correct? So would use something like (set! (.-foo Class) "bar")?#2022-12-1109:07thhellerI guess yeah#2022-12-1109:29zeitsteinshadow-cljs release compiles this without warnings
/**
 * @nocollapse
 */
export class Test {
  static foo = "bar";

  static staticMethod() {
    alert(this === Test);
  }

  baz = "blah";
}
And this works
(js/console.log
  (.staticMethod Test)
  (.-foo Test)
  (.-baz (new Test)))
Is that a sufficient test? I still think this must be wrong somehow 🙂
#2022-12-1109:31thhellerI would add a second class with the same setup#2022-12-1109:31thhellerand see if it survives and handles correctly#2022-12-1109:31thhelleralso this will likely and up being completely eliminated and inlined by :advanced#2022-12-1109:32thhellerso make sure to create something that is not as inlineable#2022-12-1109:32thhellera second class will help with that#2022-12-1109:32thhellerdunno how much @nocollapse helps against entire removal#2022-12-1109:32zeitstein@nocollapse was to remove a warning. Actually, without it there was an error at runtime.#2022-12-1109:38zeitsteinCopy pasted same class in same file, still works :man-shrugging:#2022-12-1110:06zeitsteinI have a TS file with a class (with static props and methods) which extends from an npm package. I converted that file into JS, compiled with release and it still seems to work. I guess I'll proceed 🙂#2022-12-1119:22HendrikI tried to add chakra-ui to my cljs (based on fulcro template) project. However, I get the following error:
Errors encountered while trying to parse file
  /Users/abcd/projects/abcd/editor/node_modules/@chakra-ui/utils/dist/index.cjs.js
  {:line 999, :column 10, :message "'(' expected"}
When I inspect the mentioned file I see a normal JS class:
// src/pan-event.ts
var PanSession = class {
  history = [];    // this is line 999 <------------------------------------
  startEvent = null;
  lastEvent = null;
  lastEventInfo = null;
  handlers = {};
  removeListeners = noop;
  threshold = 3;
  win;
  constructor(event, handlers, threshold) {
    this.win = getEventWindow(event);
    if (isMultiTouchEvent(event))
I don’t know why this is not compiling. Is this not supported or do I missed some configuration?
#2022-12-1119:27thhellercan't say. the closure compiler is sometimes a bit picky.#2022-12-1119:28thhellerfor such huge UI libs its usually best to stay with webpack as described in this post https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2022-12-1119:58HendrikThanks. One further question. If I provide the chakra js via cdn, then I could configure shadow-cljs to resolve to this like this?
:js-options
   {:resolve {"@chakra-ui/react" {:target :global
                       :global "what-to-add-here"}}}
What would I provide for the :global value?
#2022-12-1119:59thhellerwhatever global the lib provides?#2022-12-1120:08HendrikAh of course. It is too late in the evening for me. Thanks for your help 🙂#2022-12-1220:38indyIs there way to use npm git deps that has jsx code which gets automatically processed during import?#2022-12-1221:55indyNever mind, my goal was for the most efficient way to import a UI component lib into my cljs app locally for dev. I read the docs and seems it isn’t possible. I’ll need to somehow manually process the files via babel (which I already do for some local jsx).#2022-12-1221:55indyNever mind, my goal was for the most efficient way to import a UI component lib into my cljs app locally for dev. I read the docs and seems it isn’t possible. I’ll need to somehow manually process the files via babel (which I already do for some local jsx).#2022-12-1221:57indyDoes shadow-cljs cache files inside node_modules? I’m watching a build on a js lib that updates the package but the changes aren’t reflected on the cljs app. The js package is npm linked to the cljs app.#2022-12-1221:58indyThe changes are reflected when I restart shadow. Recompiling also doesn’t work.#2022-12-1222:00indyI’m on the latest shadow 2.20.14#2022-12-1222:05indyTried adding to the build config but no luck.
:build-options
   {:cache-level :off}
#2022-12-1222:26fabraoHello all, I'm trying to import like this
import Split from '@uiw/react-split'; -> ["@uiw/react-split$default" :as Split] ?
but this Splitis returning nil.
#2022-12-1305:42thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages#2022-12-1305:42thheller> This table only applies if the code you are consuming is packaged as actual ES6+ code. If the code is packaged as CommonJS instead the $default may not apply. See the section below for more info.#2022-12-1305:42thhellermay just be ["@uiw/react-split" :as Split]#2022-12-1223:13Aleedis it possible to specify not to parse deps when using :esm target with runtime :react-native ? My understanding was that traditional :react-native target would let metro process deps, but seems that the runtime does not behave that way I was seeing if it was possible to use shadow-cljs with expo-router, which requires integrating cljs into file-system routing which is why I’m using esm target#2022-12-1305:43thhellerI didn't try but see https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration#2022-12-1305:43thhellerbut esm can't output files into different dirs, so this likely won't work for what you are trying to do#2022-12-1306:19Aleedi was going to manually import them from the generated shadow-cljs files#2022-12-1306:21thhellerhmm maybe that works yeah#2022-12-1317:07Aleedso using js-provider does work, resolving dependency issue but now when using import I’m seeing dist/cljs-runtime/cljs_env.js: dist/cljs-runtime/cljs_env.js:Invalid call at line 1394: import(x.startsWith("./") ? "." + x : x) full line referenced above
globalThis.shadow_esm_import = function(x) { return import(x.startsWith("./") ? "." + x : x); }
not sure why it’s an invalid call
#2022-12-1317:13Aleedi think you’ve said in past that shadow-cljs does not play well with nextjs-like FS routing. but it does seem to be way JS is headed, as expo’s new router uses FS as well. with esm target do you think it’s more feasible? I was excited about Cherry providing better interop with JS ecosystem, but also recently learned about esm target in shadow-cljs, which servers similar purpose. One distinction may be that in Cherry cljs logic is imported in shared in npm package, but other than I imagine behavior is similar#2022-12-1317:47thhellersorry I haven't looked at next or any other JS platforms in many years#2022-12-1317:47thhellerso I don't know what things look like nowadays#2022-12-1317:48thhellernot sure why the import fails, looks fine to me#2022-12-1317:49thhelleresm could be adjusted to generate all kinds of files in theory#2022-12-1317:49thhellerbut as I said before the fs based routing thing just doesn't map to CLJS well at all#2022-12-1317:50thhellerso you are probably better off writing the "route" files yourself in JS, and then just importing the CLJS code from there#2022-12-1318:02AleedYeah that’s what I intended to do, at least to start i guess you mean it’s not an ideal experience, not that it’s not tenable #2022-12-1318:23Aleedah ok, regarding import issue dynamic es6 imports are not supported in metro https://github.com/facebook/metro/issues/52#2022-12-1318:23Aleedah ok, regarding import issue dynamic es6 imports are not supported in metro https://github.com/facebook/metro/issues/52#2022-12-1312:59Ian FernandezI'm having this error today with the latest shadow-cljs#2022-12-1312:59Ian FernandezThe required namespace "goog.debug.Logger" is not available, it was required by "closure-libs/field.js".#2022-12-1313:09thhelleris that one of your files? never seen that filename before#2022-12-1313:10thhellerthe goog.debug.Logger namespace was moved a long time ago in the closure library#2022-12-1313:10thhellerso I guess your code is old? or you were on a really old version?#2022-12-1313:11Ian Fernandezmy code is reaaaally old#2022-12-1313:11thhelleryeah ok. the clsoure library moved that namespace. I don't remember what the new name is though#2022-12-1313:31Ian Fernandezhow can I handle this? import?#2022-12-1313:36thhelleryou find the new location and change the code 😛#2022-12-1312:59Ian Fernandez
thheller/shadow-cljs                            {:mvn/version "2.20.14"}
#2022-12-1408:24pezI'm trying to figure out how to setup a project where deps.edn is used for dependencies and add nrepl middleware (#portal in this case). Failing so far, with a message nREPL middleware: shadow.cljs.devtools.cli has no namespace. Details in 🧵#2022-12-1408:27pezMy deps.edn looks like so:
{:paths ["src" "test" "env/dev"]
 :deps {binaryage/devtools {:mvn/version "1.0.6"}
        djblue/portal {:mvn/version "0.35.0"}
        org.clojure/clojure {:mvn/version "1.11.1"}
        org.clojure/clojurescript {:mvn/version "1.11.60"}
        reagent/reagent {:mvn/version "1.1.1"}
        thheller/shadow-cljs {:mvn/version "2.20.14"}}
 :aliases {:portal {:extra-deps
                    {djblue/portal     {:mvn/version "0.35.0"}}
                    :main-opts ["-m" "nrepl.cmdline"
                                "--middleware"
                                "[cider.nrepl/cider-middleware,shadow.cljs.devtools.server.nrepl/middleware,portal.nrepl/wrap-portal]"]}}}
And shadow-cljs.edn:
{:deps {:aliases [:portal]}
 :dev-http
 {8020 "public"}
 :builds
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"
        :modules {:main {:init-fn main.core/init}}
        :build-hooks [(portal.shadow.remote/hook)]
        :devtools {:preloads [devtools.preload
                              portal.setup]}}
  :test {:target :node-test
         :autorun true
         :output-to "target/node-test/tests.js"
         :ns-regexp ".*-test$"
         :build-hooks [(portal.shadow.remote/hook)]
         :devtools {:preloads [devtools.preload
                               portal.setup]}}}}
Running this:
$ npx shadow-cljs -d cider/cider-nrepl:0.28.5 watch :app :test
shadow-cljs - config: /Users/pez/Projects/shadow-portal/shadow-cljs.edn
shadow-cljs - starting via "clojure"
nREPL middleware: shadow.cljs.devtools.cli has no namespace
Jack-in process exited. Status: 2
#2022-12-1409:37thheller@U0ETXRFEW you cant set :main-opts in an alias used by shadow-cljs#2022-12-1409:37thhelleryou just start via clj normally#2022-12-1409:38thhellerso I guess just clj -A:portal#2022-12-1409:38thhellerand in that REPL you start the shadow-cljs embedded server#2022-12-1409:38thhellerOR#2022-12-1409:38thhelleryou just add the portal dependency as normal#2022-12-1409:38thhellerand configure the middleware in shadow-cljs.edn#2022-12-1409:39thhellervia :nrepl {:middleware [portal.nrepl/wrap-portal]}#2022-12-1409:39thhellertop level, not build level#2022-12-1409:41pezThanks. I'll poke around some with this. The last option I think I can't use because I'm not connecting to that nREPL server, but to the one started by clojure.#2022-12-1409:59thhelleryeah but you need to understand that the alias option with main-opts it starting its own new nrepl server#2022-12-1410:00thhellerin addition to the one start by npx shadow-cljs ...#2022-12-1410:00thhellerso pick one#2022-12-1410:00thhelleryou should only need one nrepl server#2022-12-1410:00thhellerit doesn't make sense to start multiple, so just use the one provided by shadow-cljs#2022-12-1410:00thhellerand add the portal middleware to that one#2022-12-1410:00thhellerand that should be all there is to it#2022-12-1410:27pezThere are some constraints here imposed by assumptions that Calva makes. And by how output is routed for the different repls. To start with the latter. If I start the REPK with clojure and then start the shadow watchers and cljs-REPL from that REPL, then stdout is routed to the REPL and gets mixed up with REPL output. I prefer to have this output in the terminal where I start the REPL. This happens if I start shadow-cljs and let it start the REPL using clojure. I don't know why this works differently, just that it does. As for the assumptions. Calva does actually connect to the nREPL server started by shadow-cljs if I choose the shadow-cljs jack-in option. (I don't know why I thought differently.) So, in summary. Moving the portal nrepl middleware config to shadow-cljs.edn made things work exactly as I want them to. With the test runner output in the terminal and all. 🎉 Thanks again! I'll try to encode these learnings in an example project. And I will update the Calva docs. I would have had helped from that this time. 😃#2022-12-1410:40thhellerwhat you described doesn't make sense? you are starting via clojure but then don't use it?#2022-12-1410:42thhellerI guess I'm confused 😛#2022-12-1411:15pezIf I manage dependencies using tools-deps, then shadow-cljs starts the REPL using clojure. And also will make it start an nREPL server. I can't use that one with Portal nREPL middleware for reasons you have helped me understand here. But that's fine, since Calva will connect to the nREPL server started by shadow-cljs. Does this make sense?#2022-12-1411:22pezHere's a template/example project wired to use start and use Portal for taps and evaluation results from both Clojure and ClojureScript REPLs. https://github.com/PEZ/shadow-portal#2022-12-1412:31thhellerthe reason the tests taps don't show is because the test runtime doesn't connect to the REPL at all
#2022-12-1412:31thhellerit just runs tests and exits#2022-12-1412:32thhellerif you run the tests from a regular node-repl instead they'd show up#2022-12-1410:00Ertugrul CetinHi, I'm getting this error after updating shadow-cljs. Any ideas?
Exception in thread "main" Syntax error compiling at (shadow/build/closure.clj:80:3).
Caused by: java.lang.RuntimeException: Unable to find static field: ECMASCRIPT_NEXT_IN in class com.google.javascript.jscomp.CompilerOptions$LanguageMode
Here is my setup;
....
[thheller/shadow-cljs "2.20.14" :exclusions [nrepl commons-codec com.cognitect/transit-clj org.clojure/tools.reader]]
[com.google.javascript/closure-compiler-unshaded "v20221102"]
[org.clojure/clojurescript "1.11.60" :exclusions [org.clojure/tools.reader]]
....
#2022-12-1410:01thhellerversion conflict on the closure compiler version#2022-12-1410:02thhelleralthough that is the version it should be using the error indicate that this is not the version you are getting#2022-12-1410:02Ertugrul CetinThe interesting part is, it works for my co-workers. I've also deleted .m2/repository/com/google/javascript/closure-compiler-unshaded to avoid conflict#2022-12-1410:03thhellercould be that you are getting the file from someplace else on the classpath#2022-12-1410:06Ertugrul Cetinany possible solutions that you could have?#2022-12-1410:09thhelleropen a plain REPL, then (:require ') and ( "com/google/javascript/jscomp/CompilerOptions.class")#2022-12-1410:09thhellersee where that is coming from#2022-12-1410:09thhellershould be the closure-compiler jar with the above version#2022-12-1410:09thhellerif not figure out where that came from 😛#2022-12-1410:10Ertugrul CetinWill do thanks 🙂#2022-12-1410:28Ertugrul CetinThis did the trick#2022-12-1411:22pezHere's a template/example project wired to use start and use Portal for taps and evaluation results from both Clojure and ClojureScript REPLs. https://github.com/PEZ/shadow-portal#2022-12-1411:52pezWhat can I do to start a JS runtime for a :test build? In ^ that ^ project tests are set to :auto-run and that works great. But I can't reach the build via the REPL.#2022-12-1412:34thhelleryou can't and you are not supposed to#2022-12-1412:34thhellerjust use a node repl#2022-12-1412:35thhellerthe test targets are for automated testing (ie. CI) and you dont want to keep those processing running due to some connected websocket#2022-12-1413:39pez:auto-run isn't for CI, is it?#2022-12-1413:41pezIf I can I make a node repl autrun the tests for me, that would work for me. I'll see if I can make that happen.#2022-12-1418:03thhellercan you bind the run-tests function to a key and run them yourself?#2022-12-1418:03thhellerI mean I find running all tests after every change a little frustrating myself but do what you want#2022-12-1413:49pezSo, what I actually want to achieve here is to have taps happening from :auto-run tests to end up in Portal. I don't strictly need a REPL for that, but that would make it easier to examine the environment. So, then my next question is, can I hope to ba able to add a tap to these test runs?#2022-12-1418:03thhellerI don't know how portal works so I can't tell you#2022-12-1418:04thhellerif it wants to keep the node process running I can't stop it from doing so#2022-12-1418:04thhellerthat would break autorun though#2022-12-1418:04thhellerthe tap is in full control over what it does#2022-12-1419:51pez@U1G869VNV knows this better than me, but as I understand it, Portal listens to a port and then the user registers a tap that submits to this port. https://github.com/djblue/portal/tree/master/src/portal/shadow When I do that from the browser app the tap reaches portal, but from the :node-test target this doesn't happen, even though it uses the same port. This is where I lose track of it and was thinking a REPL might help me.#2022-12-1419:51thhellerI don't believe it uses the REPL or any connection provided by shadow-cljs#2022-12-1419:51thhellerso its entirely on portal and its tap#2022-12-1419:52thhellerbut again .. I would strongly encourage to use a REPL and runs the tests from there#2022-12-1419:52thhellerthe tests targets are supposed to exit when they are done and not linger arround#2022-12-1419:53djblueThe transient node process should still be able to tap via the remote client since it's just making http post requests to the jvm process hosting the portal api#2022-12-1419:53pezI do that already. I'm very attached to workflow of seeing shadow run my tests in a terminal pane while I work, though.#2022-12-1511:48Mikko HarjuHi all! Has someone come across resolving errors re: goog packages in React Native lately? I'm currently upgrading an application to 0.70.6 and was hit with an error metro trying to resolve ./app/goog.math.long.js – I got around this by patching metro's resolver and made it ./out/goog.math.long.js – but it seems that something is wrong still since it still complains about
ReferenceError: Property 'Long' doesn't exist, js engine: hermes
. I'm figuring this out myself but wanted to ask if someone has already been seeing this 🙂
#2022-12-1511:51Mikko HarjuIt seems that it is not loading the goog.math.long.js currently. That's probably causing the error.#2022-12-1511:59Mikko HarjuOK. Something is expecting the output to be in directory "app" – but it is written to "out".#2022-12-1512:00Mikko Harju=> using output-dir "app" gives a new error 🙂#2022-12-1512:00Mikko HarjuNow it's concatenating an absolute path with a URL. Maybe this is configuration related.#2022-12-1512:05Mikko HarjuThat error has to do with symbolication. The actual error is still
ERROR  ReferenceError: Property 'Long' doesn't exist, js engine: hermes
#2022-12-1512:08Mikko HarjuOK. It's the Long.fromBits in goog.math.long.js that is causing the issue. Maybe Hermes does not have that.#2022-12-1512:13thhelleras far as I remember this is due to hermes not suporting es6 features like const#2022-12-1512:14thhellerthat file just hpappens to be the first file trying to use them#2022-12-1512:14thhellerset :compiler-options {:output-feature-set :es5} in your build config#2022-12-1512:17Mikko HarjuOK - thanks! any ideas on the output dir? We had out previously and it has worked earlier but now it does not.#2022-12-1512:18thhellerwhats in your build config?#2022-12-1512:18thheller:output-dir#2022-12-1512:18Mikko HarjuPreviously I had :output-dir "out" – now I have :output-dir "app"#2022-12-1512:18Mikko HarjuIf I have output-dir "out" I get an error when it tries to resolve goog.math.long.js#2022-12-1512:18thhellerand did you update the .js file including them?#2022-12-1512:19Mikko HarjuYeah, using "app" metro works#2022-12-1512:19Mikko Harju(I updated refs to out => app from relevant places)#2022-12-1512:19Mikko HarjuI don't mind having the output in app so it's not a big deal, just threw me off since this had worked before.#2022-12-1512:20thhellershadow-cljs doesn't care where you put it#2022-12-1512:20thhellerit just writes to whatever :output-dir you tell it#2022-12-1512:20thhellerabout special meanings in react-native I have no clue, so can't comment on that#2022-12-1512:21Mikko HarjuYes, the output gets written to out as before, but for some reason metro gets "app" from out of nowhere and tries to resolve from it#2022-12-1512:22Mikko Harju=> switching shadow-cljs to output to "app" makes it all work again#2022-12-1512:23Mikko Harju@U05224H0W switching to es5 did not work – it still fails on
ERROR  ReferenceError: Property 'Long' doesn't exist, js engine: hermes
#2022-12-1512:23thhellershadow-cljs doesn't write any output to out if you don't configure it#2022-12-1512:23Mikko HarjuYes, i know 🙂#2022-12-1512:23thhellerif there are files getting created there it is not shadow-cljs#2022-12-1512:24Mikko HarjuNo, there was nothing like that happening#2022-12-1512:24thhellerthen I don't know. never used react-native or hermes#2022-12-1512:24Mikko HarjuYes, it seems that Hermes is missing something essential that goog.math.long expects to have#2022-12-1512:25Mikko HarjuI can just opt out from Hermes for the time being, that is not a problem#2022-12-1512:26Mikko HarjuSo, the only question remains to be solved is that why does react native expect to have stuff written in "app" when we have been using "out" for many years without issues. This is not a shadow-cljs issue probably and I can live with just changing the output dir 😄#2022-12-1512:26Mikko HarjuThanks for your work on shadow-cljs. It's such a great tool 🙂#2022-12-1512:46OmarI had same issue awhile back and what Thomas advised for you helped me https://clojurians.slack.com/archives/C0E1SN0NM/p1665753992908259?thread_ts=1665725322.539589&amp;cid=C0E1SN0NM#2022-12-1512:47Omarmaybe something is cached for you?#2022-12-1515:38Mikko HarjuI did reset caches et al, and switching back made it work again. I can live without Hermes for the time being. Thanks for the info though!#2022-12-1513:26HukkaHm. Seems like requiring ["@mui/material/Box" :default Box] works as expected, but ["@mui/material/Box$default" :as Box] doesn't as any use of Box later will refer to https://cljs.github.io/api/cljs.core/Box#2022-12-1513:28HukkaNo idea if this is happening in shadow or cljs compiler#2022-12-1513:28thhellersomeone mentioned this a few days ago but didn't open an issue I think#2022-12-1513:29thhellerthis is indeed a bug yeah#2022-12-1513:29HukkaI can. Should it go to shadow-cljs issue tracker? And is that enough of a description, or should I make a minimal repo that shows the problem with package.json and everything?#2022-12-1513:36HukkaAlso noticed than in working cases too the resulting JS code is a bit different. The old style creating shadow.js.require() calls and then referring to objects with names like modules$node_modules$$DefaultExport$index.default, while the new one will skip the require and refer to shadow.js.shim.module$$DefaultExport$default. I tried looking at the issues around the time this changed in the docs (Feb 20), but didn't find anything, so I wonder what the implications are. At first I thought that both styles would result in identical code, so I guess the translation is happening at a different place?#2022-12-1513:39thhellershould be easy to reproduce. I think I already know the problem so just an issue as a reminder is enough#2022-12-1513:39HukkaGot it, filing#2022-12-1513:43Hukkahttps://github.com/thheller/shadow-cljs/issues/1075. Thanks for the quick confirmation#2022-12-1621:18Ben HammondHi. I am playing with webworkers for the first time: I can successfully call into the webworker module, but I quickly see a console error
worker.js:1453 failed to load shadow.module.gamelogic.append.js ReferenceError: shadow is not defined
    at eval (shadow.module.gamelogic.append.js:2:1)
    at eval (<anonymous>)
    at goog.globalEval (robot.js:497:11)
    at env.evalLoad (robot.js:1451:12)
    at worker.js:1506:12
worker.js is my worker module gamelogic is a shared module that it depends upo; presumably Ihave forgotton to import something..?
#2022-12-1705:40thhellerdid you set :web-worker true in the build config for the worker module?#2022-12-1705:41thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_web_workers#2022-12-1710:53Ben Hammondyes, I did#2022-12-1710:53Ben Hammond
:robot {:entries [foo.robot]
            :depends-on #{:gamelogic}
            :web-worker true}
    }
#2022-12-1710:54thhellerand what is this file trying to call? just look at the source in the cljs-runtime dir#2022-12-1710:54Ben Hammondcould the gamelogic module be inadequate?
:gamelogic {:entries [foo.encode-board
                          foo.calc-moves]}
#2022-12-1710:54thhellerfirst should figure out what it is actually trying to call#2022-12-1711:06Ben Hammondso the action line that triggers the error is on the first line of shadow.module.gamelogic.append.js
shadow.cljs.devtools.client.env.module_loaded('gamelogic');
#2022-12-1711:08thhellerand the worker script is itself loading the gamelogic module properly?#2022-12-1711:08thhellerthere should be a importScripts at the top somewhere#2022-12-1711:08thhellerjust to verify: this is a :target :browser build?#2022-12-1711:09Ben Hammondyes is it#2022-12-1711:09Ben Hammondit is#2022-12-1711:09thhellerand no other errors happens during load prior to this one?#2022-12-1711:09thhellerany exception could break the loading process and lead to this one#2022-12-1711:12Ben Hammondyes this is the first error upon a reload]#2022-12-1711:14thhellernot asking about first#2022-12-1711:14thhellerasking about other errors#2022-12-1711:15thhellerordering is something weird like that#2022-12-1711:16Ben HammondSo I do have other CORS errors, because this is a dev experiment and it is trying to connect to public facing website was hoping that would not be relevant#2022-12-1711:16thhellercan't rule that out unfortunately#2022-12-1711:16Ben Hammondah okay#2022-12-1711:16Ben Hammondso I have to set things up properly adn then try again#2022-12-1711:16thhellerwell, you can by just commenting it out and seeing if the other error goes away 😉#2022-12-1711:17thhellerFWIW never ever ever run anything directly on load#2022-12-1711:17thhelleruse :init-fn to let shadow-cljs call a init function for you#2022-12-1711:17thhellerdo not run anything before that to removing likelyhood of such errors#2022-12-1711:18thhellerso you (defn init [] (do-stuff)) and shadow-cljs call it, instead of just (do-stuff) in an ns somewhere#2022-12-1711:19thhellerfollowing the init/start/stop logic as desribed in https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html#2022-12-1711:19Ben Hammondah okay; was following the code pattern in https://github.com/thheller/shadow-cljs/issues/655#2022-12-1711:20thhelleryou were not. that example also uses :init-fn 😛#2022-12-1711:22Ben Hammondperhaps I don't understand. Am attaching event listener globally like
(js/self.addEventListener "message"
                          (fn [^js evt]
and you are saying that this should be done within an init function?
#2022-12-1711:23Ben HammondInterestingly, the web worker is behaving as expected; this error message is just creating console noise#2022-12-1711:23Ben HammondI'll tidy up my stuff and then try again#2022-12-1711:23Ben Hammondthanks for the help#2022-12-1712:00thhelleryes, this should be in the init-fn#2022-12-1712:01thhellerotherwise if the code hot-reloads it is called again#2022-12-1712:01thhellerthus adding the event listener again#2022-12-1712:01thhellerwhile the old one it still attached#2022-12-1916:49Ben Hammond💡#2022-12-1916:49Ben Hammondthe error is not in the web worker; the error is in the main module#2022-12-1916:50Ben HammondWhen attempting to set up module dependencies, I set a :default true like this
:main {:entries [foo.main]
           :init-fn foo.main/main
           :depends-on #{:gamelogic}
           :default true}
and clearly it does no do what I expected it to do
#2022-12-1916:52Ben HammondI was originally hoping to avoid specifying dependencies but shadow-cljs told me that it could not figure out the hierarchy so I set the :default flag, and that error seemed to go away#2022-12-1916:53Ben Hammondbut I got got the subsequent
gamelogic.js:1451 ReferenceError: shadow is not defined
    at eval (shadow.module.gamelogic.append.js:2:1)
    at eval (<anonymous>)
    at goog.globalEval (gamelogic.js:497:11)
    at env.evalLoad (gamelogic.js:1559:12)
    at gamelogic.js:1615:12
#2022-12-1916:53Ben Hammonddo I have to use module dependencies?#2022-12-1916:55Ben Hammondso this is the error I get with no dependencies
[:foo] Build failure:
two modules without deps, please specify which one is the default
{:a :main, :b :robot}
ExceptionInfo: two modules without deps, please specify which one is the default
        shadow.build.targets.browser/pick-default-module-from-config/fn--25576 (browser.clj:174)
 
#2022-12-1916:57Ben Hammondif I set the problematic :default true in the main module then I get a different error
[:foo] Build failure:
no common dependency found for src
{:src [:shadow.build.classpath/resource "goog/base.js"], :deps #{:main :robot}}
ExceptionInfo: no common dependency found for src
        shadow.build.modules/compact-build-modules/find-closest-common-dependency--15601
#2022-12-1916:58Ben Hammondwhat does that :default flag really do?#2022-12-1918:38thhelleryou are not supposed to ever set it. you are supposed to define one module that has no :depends-on. the rest must have it#2022-12-1918:38thhellerand yes, you must specify all proper dependencies so a proper graph can be built out of it#2022-12-1805:59hifumi123What's the standard way people include svg assets with shadow-cljs? It seems that :asset-path is mostly intended for loading JS modules rather than other assets. My project separates cljs source and svg assets in separate folders (src and assets), respectively. Is there some shadow-cljs command to symlink the folder to my asset-path or is there a much better way to do this? EDIT: For additional context, I am using the default server provided by shadow-cljs. I suppose it wont hurt to finally have a proper server in the front-end#2022-12-1806:10thhellernothing is provided to handle any kind of assets. usually you just put them in the public folder and access them by path#2022-12-1806:10thhellerso public/img/foo.svg and [:img {:src "/img/foo.svg"}]#2022-12-1806:14hifumi123Right. I wanted to avoid that since public typically contained compiled cljs artifacts. But I suppose I can also restructure my project so that I always have a public folder with my assets, then I can simply add public/js to my .gitignore#2022-12-1806:16thhelleryes, thats what I do#2022-12-1806:17thhellerpublic/js is gitignored as well as public/css. the rest is tracked in git#2022-12-1815:45Joshua SmockIs there a way I denote that a namespace should require every Google source, regardless of if it imported it or not? I’d like to make sure that when a specific namespace is compiled that cljs_env.js has all the Google classes and sources#2022-12-1815:46thhellerall? why would you want that? that is a lot. but the answer is no#2022-12-1815:47Joshua SmockI guess the alternative is to just manually add all of the possible Google namespaces as imports?#2022-12-1815:48thhellerthe question is again for why you'd want to do that? what are you trying to do? some namespaces are goog.module's they only work in the namespace they were required in#2022-12-1815:51Joshua SmockIt’s mainly to simplify some compilation step I need to perform for a project I’m working on. I’ll keep brainstorming ways to approach it, thanks!#2022-12-1815:51thhellerquick check gives me 1587 google closure source files#2022-12-1815:51thhellerso, thats a lot#2022-12-1815:53thhelleri doubt anyone has used 1400 of those ever ;)#2022-12-1918:44fabraoHello all, how do I use this
garden/garden {:git/url ""
                 :sha "7a47503d0481382f85b643ae431cefb2ad88ee4c"}
in shadow-cljs.edn dependencies?
#2022-12-1918:45thhelleryou can't. need to use deps.edn for that#2022-12-1918:46fabrao😥 Thank you#2022-12-2015:17gravdeps.edn aint half bad with shadow#2022-12-2009:51Jakub Holý (HolyJak)Hello! If I want to implement a custom :js-provider (for pnpm) and thus extend the s.b.resolve/find-resource-for-string* multimethod, https://github.com/thheller/shadow-cljs/issues/670#issuecomment-732788677, how do I do that? Can it be in my own code or do I need to clone shadow-cljs and then somehow use the local, extended version of it? (I guess via direct invocation with clj it would be possible.) Thank you!#2022-12-2011:21thhellerI'd start with just a function that does the pnp-resolve, as I wrote in that comment#2022-12-2011:21thhellerafter that if you are working in the REPL you can just load your namespace with the defmethod#2022-12-2011:22thhellerand it'll just be available for the build to use#2022-12-2011:22Jakub Holý (HolyJak)Yes but I somehow need to get shadow to call the function,no?#2022-12-2011:22thhelleryes, as described in the comment above you take the impl for the defmethod for :shadow#2022-12-2011:22thhellerand modify it to use pnp-resolve instead of the built-in npm resolve#2022-12-2011:24Jakub Holý (HolyJak)So my initial understanding that I defmethod s.b.resolve/find-resource-for-string* that calls my own resolve-pnpm was correct, and the way to go about it is to use REPL and run shadow build from there.#2022-12-2011:25thhellerwell the build you can trigger from whereever#2022-12-2011:25thhellerjust need to load your namespace with the defmethod in some way#2022-12-2011:25thhellerand the easiest way for that is the repl#2022-12-2011:25Jakub Holý (HolyJak)thank you!#2022-12-2118:08bitbltHello! I want to do a quick poll: On your fullstack (frontend + backend) projects where frontend is a spa built with shadow-cljs, do you create: a) a repo for each project (like project-web, project-service) b) a repo with a subdirectory for each project (like project/{web,service}) c) a repo for both projecs on the same structure, with backend and frontend code coexisting under same src/ (maybe with/in different namespaces) If the answer is (c) how do you do this? Also, how do you share common cljc code between the frontend and the backend? Foremost and most important, how do you make a project that has both a normal deps.edn project for backend and a shadow-cljs.edn project for frontend?#2022-12-2118:38MacrozI do both b) and c), but in c) I use Leiningen and not deps.edn. The CLJC is shared. Both project.clj and shadow-cljs.edn reside in the root directory, each with the correct src settings. The settings don't overlap much.#2022-12-2118:39MacrozWhere do you run into a problem?#2022-12-2118:42bitbltI haven't (yet) because I so far used option (b). I'm just making a poll to see what most people use, and to gain ideas whether it is possible to fire a single repl to host both the frontend and the backend somehow for option (c) 🙂#2022-12-2118:43MacrozYou would have two REPLs, one for CLJ and one for CLJS.#2022-12-2118:44bitbltYes I suppose that part is inevitable, given where each part runs#2022-12-2118:45MacrozI just switched to this setup. Previously I could launch both together in Emacs/CIDER with Leiningen & Figwheel classic, but I haven't gotten the setup to work with Leiningen and Shadow-CLJS so I start one in terminal and other in Emacs/CIDER.#2022-12-2118:45bitbltI'm just trying to establish a workflow where I won't need multiple editors open#2022-12-2118:46MacrozYou can have each build tool usually in watch mode in a terminal somewhere and use one editor. In case of Emacs/CIDER you should be able to have both in one editor. And Emacs can of course have terminals in it too. The advantage of the "proper support" is that you can use all the bells and whistles so jump to source (without LSP etc.)#2022-12-2118:46MacrozBut YMMV depending on the editor.#2022-12-2118:47bitbltI'm using neovim + olical/conjure for repl + clojure-lsp for lsp#2022-12-2118:47MacrozI think this channel is perhaps wrong for this question, it is not at all related to Shadow-CLJS.#2022-12-2118:48bitbltYeah I posted it here because I believe that the biggest challenge is having shadow-cljs play along inside a normal clj repl somehow#2022-12-2118:49Macrozhttps://shadow-cljs.github.io/docs/UsersGuide.html#embedded#2022-12-2118:50MacrozI tend to start Shadow-CLJS either from terminal or a dedicated REPL for it.#2022-12-2118:51bitbltdamn that section opens up a LOT of possibilities#2022-12-2118:51bitbltActually this gives me a direction on how I could make (c) viable#2022-12-2118:52MacrozSince the code I run in the Shadow-CLJS REPL is intended for the browser, I would anyway want it to be separate.#2022-12-2118:52MacrozDepending on the source file (CLJ or CLJS), CIDER knows to pick the correct open REPL#2022-12-2118:52bitbltYes that is exactly how I wanna configure mine#2022-12-2118:52bitbltaccording to the currently focused window#2022-12-2118:54MacrozThis is with the disclaimer that I mentioned previously that my setup worked better with Leiningen+Figwheel and now something prevents me from launching Leiningen+Shadow-CLJS at the same time, but haven't had time to investigate really. I hardly ever use the browser REPL, I often rather print to the browser.#2022-12-2118:54MacrozSomething related to CIDER though, not Shadow-CLJS issue.#2022-12-2119:25HukkaWe have frontend in one folder, on the same level as many folders for the backend code in polylith. I run neovim and conjure, but many instances. I don't even use buffers, but every file is managed by wm. The editor knows what repl to pick up by traversing the tree up, looking for the .nrepl, which hits the frontend shadow-cljs repl before it goes up the the repository root, where the clj repl port is written to#2022-12-2119:28bitbltExcuse my ignorance, what do you mean by 'wm'?#2022-12-2119:28HukkaWindow manager#2022-12-2119:28bitbltAs in linux window manager?#2022-12-2119:29HukkaYes, I use the tiling i3, which is much like you would have with split view of vim buffers, but works then for everything#2022-12-2119:29bitbltAh, I use bspwm myself, but I still prefer managing my project's files inside vim panes#2022-12-2214:24Jonihttps://github.com/thheller/shadow-cljs/issues/1071 I updated this issue with a small repo that can reproduce the bug. If you install version 2.19.2 the redirect works as expected, but with the newest version it doesn’t#2022-12-2216:00HankstenbergHi guys, I need some help. I'm scratching my head over an error I have with a released bundle. The webapp runs fine in dev mode, but when loading the released bunde statically, it crashes with an "a is null" error. There is no obvious case of "nth" somewhere. --debug doesn't tell me anything. The error even appears if I don't even mount the react stuff. Once I comment that out, basically nothing should happen. I checked all explicit "def"s that could get statically loaded - nothing. Does anybody have an idea what I can do to figure out what's wrong? What I'd need is a version of the compiled code without method/variable "obfuscation". Is that possible?#2022-12-2216:03thhellernpx shadow-cljs release app --pseudo-names#2022-12-2216:03thhellerwill be still obfuscated but in a way that lets you figure out what the original was#2022-12-2216:08HankstenbergI knew there was an arcane option! Thank you very much! 🙂#2022-12-2219:29KlayWhat’s the difference between the run and clj-run commands?#2022-12-2219:32thhellerno difference, same command.#2022-12-2221:09borkdudeI want to ensure cljs.pprint is only used from a certain module, but stating this in shadow-cljs.edn gives me:
[:main] Build failure:
Module Entry "cljs.pprint" was moved out of module ":scittle.pprint".
It was moved to ":scittle" and used by #{:scittle.pprint :scittle}.
^C%
since shadow itself presumably uses this for dev tooling. It works in the production build though. Any way around this?
#2022-12-2305:43thhellerin 2.20.16 I just removed the require since it is unused anyways#2022-12-2305:43thhellerbut yeah its a problem with no fix available currently otherwise#2022-12-2317:36William MizutaI am trying to configure shadow-cljs.edn to use AWS codeartifact as a repository source. I ran the AWS codeartifact to update my ~/.m2/settings.xml with the tokens to authorize me to Download from codeartifact, but I am getting the error
DependencyResolutionException Failed to collect dependencies at xxx:xxx:jar:a.b.c
	org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:351)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:566)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:806)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:707)
	clojure.core/apply (core.clj:665)
	clojure.core/apply (core.clj:660)
	cemerick.pomegranate.aether/resolve-dependencies (aether.clj:815)
Caused by:
DependencyCollectionException Failed to collect dependencies at xxx:xxx:jar:a.b.c
	org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies (DefaultDependencyCollector.java:293)
	org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:307)
	jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)

...

AuthorizationException Not authorized , ReasonPhrase:Unauthorized.
	org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:1021)
	org.apache.maven.wagon.shared.http.AbstractHttpClientWagon.fillInputData (AbstractHttpClientWagon.java:976)
	org.apache.maven.wagon.StreamWagon.getInputStream (StreamWagon.java:126)
But the same works when I use leiningen to download the same dependency from AWS codeartifact.
#2022-12-2321:27William MizutaIt works when I explicit copy the username and password from ~/.m2/settings.xml that codeartificat generated#2022-12-2406:09thhellerhmm this is the same library that leiningen uses to resolve dependencies#2022-12-2406:09thhellerso I'm not sure what works differently#2022-12-2600:02DrLjótssonI want to run my tests in node.js, but there are a couple of namespaces that include libraries that are not available in node.js. Can I create new namespaces that "shadow" these namespaces and are only included in the :target :node-js build? I tried adding the :deps {:aliases [ ... ]} key for that build only, with a deps alias that includes a path with those namespaces but :deps only seems to work on the global level. Any other suggestions?#2022-12-2606:21thhellerthe best option is to remove those namespaces from the build entirely. there are ways to do this usually, without any config and other hacks. just moving some code around and only requiring them when actually needed but not in tests#2022-12-2606:22thhellerotherwise there is the option to :build-options {:ns-aliases {the.ns.you.dont.want the.replacement}} in the build config#2022-12-2619:26DrLjótssonThanks @thheller ! I have actually started to move the code around as you suggested. But thanks for the :ns-aliases tip, could come in handy in the future. #2022-12-2616:38pezHello, I'm trying to use https://github.com/microsoft/vscode-test to e2e test a VS Code extension built with shadow-cljs. vscode-test exposes a runTests function that launches VS Code. To runTests I provide an argument pointing at a module exporting a run function that is responsible for running the actual tests. I'm using the :node-script target to build a script that both calls runTest and exports a run function from where I am calling cljs.test/run-all-tests. I run into a strange error when the extension has started complaining about swap! not being defined for cljs.core/Atom. Adding the log to a reply....#2022-12-2616:44pez
npm run integration-test                 

> 
So, right before the SHADOW import error I see println messages from my extension and from shadow, indicating that it starts OK. It all works fine if starting VS Code with this extension installed. I don't understand why this way of starting things would trigger this particular error...
#2022-12-2616:45pezNot expecting anyone else to understand it either, mainly looking for ideas on what to try to isolate things a bit.#2022-12-2616:53pezcc: @U04V15CAJ who at least has some context. 😃#2022-12-2617:08thhellermy guess is that the extension is loaded twice. or rather cljs.core being loaded twice#2022-12-2617:09thheller[main 2022-12-26T15:54:04.111Z] UtilityProcess<1>: Creating new... don't know what it is creating but the error happens when cljs.core is loaded twice, because the protocol is redefined and then things go weird#2022-12-2617:14pezThanks. Maybe it's because I have the testrunner run function in the same module that starts VS Code. I'll try to avoid that and see if it gets me to a new place.#2022-12-2618:04pezHmmm, no, it seems to be that the tests themselves are written in cljs and I am trying to run shadow twice or something. If I compile the tests using release I get rid of the error. Which is fine. However, it doesn't actually run the tests. There is only one in this test run, a failing one, yet:
% npx shadow-cljs release :integration-tests && npm run integration-test
shadow-cljs - config: /Users/pez/Projects/joyride/shadow-cljs.edn
shadow-cljs - connected to server
[:integration-tests] Compiling ...
[:integration-tests] Build completed. (53 files, 1 compiled, 0 warnings, 2.65s)



> 
#2022-12-2706:07thhellerare the tests loaded while also loading a debug version of the extension itself?#2022-12-2706:07thhellerif they run the same context that won't work#2022-12-2706:07thhellercan't have two debug builds running at the same time#2022-12-2708:33pezIn that last attempt I loaded the tests in a release build, and the extension itself was a debug build. I now tried starting from clean and release compiling both targets before running the tests. Still no test results. Interestingly if I use cljs.test/run-all-tests it reports Testing tests for promesa and all other libraries used which has tests, including my failing test. And still reports that 0 tests and assertions are run. I'll keep digging...#2022-12-2710:57thhellerif they are async tests do you use async correctly? otherwise the test runner will just exit since it doesn't know that tests are still running#2022-12-2711:03thhellerbut again the most likely problem here is loading two builds into one environment. regardless of combination this just won't work if these are not isolated contexts#2022-12-2711:04thhellerbut I do not know enough about either vscode and vscode-test to make any meaningful suggestions#2022-12-2711:11pezYou have made amazingly meaningful suggestions so far. 😃 But, indeed, lots of moving parts here. I'm trying to do this with Joyride itself now instead. That's also gets a bit of a mind-fuck, but I can run the tests on the debug build (with the the debug build) so much faster feedback.#2022-12-2620:11denik@thheller happy holidays! I have a very macro-heavy project. Essentially there’s a whole other compiler running inside macros rewriting code. This seems to lead to shadow-cljs to recompile all code regardless of whether the code inside the macro has changed (output likely changes on each eval because of gensyms etc) leading to excessive compilation times (> 10 secs for about ~1000 LoC of code). Is there a way to tell shadow to use cached output for macros as long as the body of the macro expression has not changed?#2022-12-2706:05thhellerthat is the default, unless you manually turned off caching or so#2022-12-2706:05thhellersee https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2022-12-2706:05thhelleror using :dev/always true in the ns meta will have the same effect#2022-12-2706:06thhelleror the macro having side effect and writing files the compiler sees#2022-12-2706:06thhellerotherwise it only considers files that are relevant to the compiled file (ie. its requires)#2022-12-3021:38denik Okay thanks for the context #2022-12-2722:40mbertheauI want to use the self-hosted clojurescript compiler in the browser to compile code that uses com.rpl.specter. It says com.rpl.specter/select is an undeclared var. A JS symbol com.rpl.specter.select indeed doesn't appear in any of the js/com.rpl.specter* files in the output of the :bootstrap build. In the source select's a macro https://github.com/redplanetlabs/specter/blob/67e86806020b9d02fbca8cdb1efad3002fc81a32/src/clj/com/rpl/specter.cljc#L347-L351 My :bootstrap build config is:
{:target           :bootstrap
   :output-dir       "public/bootstrap"
   :compiler-options {:warnings {:infer false}}
   :exclude          #{cljs.js}
   :entries          [cljs.js com.rpl.specter]}
I copied {:warnings {:infer false}} from other examples of self-hosted cljs, without knowing what it does and whether it's necessary. I didn't find statements that self-hosted cljs doesn't support macros. Should this work? What am I missing? Thanks! Addendum: It seems that certain macro syntax isn't supported by the self-hosted clojurescript clojurescript compiler. There's a PR in specter that seems to address this partly. I'll see if that gets me further. https://github.com/redplanetlabs/specter/pull/299
#2022-12-2800:28mbertheauI wonder if separating the cljc files into clj and cljs might help.#2022-12-2806:29thhelleryeah, lots of lib written in cljc do not account for self-hosted. can't comment on what exactly the problem is though#2022-12-2806:30thhellermacros do work just fine but still need to be used correctly, as in the regular CLJS version#2022-12-2806:32thhellerquick glance suggests that at least there is a macros.cljs, or it written as .cljc with the proper :require-macros for itself#2022-12-2809:48mbertheau@U05224H0W When it works, the com.rpl.specter/select macro should appear as com.rpl.specter$macros.select in the JS source, right? Also, when you say that macros need to be used correctly, one of the things you mean in particular is that wrapping macro definitions in #?(:clj ..)would be wrong. While that works for Clojure and Clojure-hosted ClojureScript, it doesn't work for self-hosted Clojurescript.#2022-12-2809:56thhelleryes, :clj branches are ignored#2022-12-2809:56thhellerand yes, macros are in special $macros namespaces. that separation is what I mean by using it correctly. can't put macros in the com.rpl.specter ns directly even though it might appear so#2022-12-2810:55mbertheauWith macros in Clojure, you just use defmacro and that's it. With macros in Clojure-hosted ClojureScript, you describe the problems in https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html With macros in self-hosted ClojureScript, assuming that that's the only target you intend to support, would it be enough to just use defmacro in the .cljs file, similar to the Clojure case, where you just use defmacro in the .clj file, and that's it? Are all the shenanigans that net.cgrand.macrovich deals with and reader conditionals and so forth only necessary to support the mixed ClojureScript on Clojure target?#2022-12-2815:10thhellermacros are NOT supported in .cljs files no#2022-12-2815:10thhellerhas to be clj or cljc#2022-12-2818:28mbertheau@U05224H0W Can this work with shadow-cljs's bootstrapped self-hosted cljs compiler? https://github.com/cgrand/macrovich/blob/e80fb37cb795201821d0e75f73119802227e9620/src/net/cgrand/macrovich.cljc#L11 In my experiments *ns* is always null.#2022-12-2818:32thhellerthats fine. *ns* is always bound to the current ns when macroexpanding, but not otherwise#2022-12-2804:51hifumi123How would I make the :asset-path "absolute"? My frontend app works fine with routes like /login, but assets immediately fail to load when I navigate to a route like /app/panel, since the rendered views will look for assets in /app/assets/... instead of /assets/...#2022-12-2806:26thheller:asset-path is only used in a few places for JS files, you just specify an absolute path, so :asset-path "/js" or so#2022-12-2806:27thhellerany other "assets" you control yourself via HTML or code, so just emit absolute paths there#2022-12-2806:38hifumi123I guess my question is then "is there a natural way to communicate server URL from shadow-cljs.edn to my frontend code?"#2022-12-2806:40thhellerwhy would it need to? are your assets served by a separate server?#2022-12-2806:40thhellerotherwise just use an absolute path, ie. starting with a /#2022-12-2806:41hifumi123Sorry. I just fixed the issue by doing exactly what you suggested. Thanks for the help!#2022-12-2812:25mbertheauIf I have to delete .shadow-cljs to get a compilation working, that's a bug, right?
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "83eee2f1e8f6f0c3f6e1f6edf7f6b1b1b3b7"}, :content ("[email protected]")}
#2022-12-2815:22thhelleryes, that would be a bug#2022-12-2815:23thhellernot sure what is happening there though#2022-12-2909:43mbertheau@U05224H0W related, but not necessarily the same issue: I suspect that at least cljc files on the source path that are intended to and also practically only used for self-hosted CLJS (i.e. :target :bootstrap) are run through the Clojure compiler during reload when a watch is active for the normal ClojureScript build (`:target :browser`), and then complain about, for example, no such namespace: js. These files work as intended in the self-hosted environment. Is this intended to work differently? Can I have self-hosted CLJS-only files in my sources that can assume to be run only in a CLJS context?#2022-12-2911:51thhellerone build never affects another#2022-12-2911:52thhellerthe browser build will only compile files it required itself. note that it is extremely easy to make mistakes with .cljc files, thus I rarely recommend using them#2022-12-2911:52thhellerbootstrap will also compile more files than other builds do, so it might be deep in some macro files that otherwise are never compiled#2022-12-2912:02thhellermy guess is that a macro file somehow fails to load but the error is lost somewhere#2022-12-2912:02thhellermaybe because of some ns form that is not valid in clj#2022-12-2912:02thhellerand then the macro ns is not defined and leading to the above error#2022-12-2912:33mbertheauI'm still at a stage where I want to make specter work in an self-hosted environment. For that I'm trying to understand how macros work in the self-host environment provided by shadow-cljs :bootstrap. For that I'd like to step through the code and look at stuff. Not sure how to do that though. I'm on emacs and use cider.#2022-12-2913:23thhellerthere is nothing special to macro compilation. the ns is just compiled as normal, using :cljs branches in .cljc files#2022-12-2914:42mbertheauI believe you, but that doesn't yet match the mental model I have built based on my observations so far 🙂 Something must be different though because js/some.name.space.js and js/some.name.space$macros.js are different#2022-12-2914:43thhellerI don't know what you mean by that. you should under no circumstance ever refer to any CLJS namespace via js/#2022-12-2914:45thhellerif you mean the output files then yes, there are 2. can't write two namespaces into one file#2022-12-2914:46thhellerthe way you should approach this is that it is basically two entirely separate namespaces, that just happen to have the same name from the code side (so same ns) but different internally#2022-12-2915:05mbertheauI mean the output files, yes. The two are different, but they are produced from the same file. So something must be different about the compilation process.#2022-12-2915:09mbertheauAnother way to state the problem is that (macrovich/deftime (defmacro ...)) macros don't make it to the $macros output file for the namespace in my situation currently. Also I read that defmacro is ignored – or produces no output – when compiled in CLJS, maybe that's one difference?#2022-12-2915:18mbertheauMore close to my original problem, which is that select is undefined in CLJS in a self-hosted environment, I seems clear now why the upstream version behaves like this - it has (defmacro select ...) in #?(:clj. A PR/fork/branch that was reportedly working better has it in (macrovich/deftime ...) instead. However, select still didn't appear in the ...$macro.js output file. I assumed that that must be correct, but maybe it isn't. Reading https://cljs.github.io/api/cljs.core/defmacro now, that looks helpful.#2022-12-2915:22mbertheauHmm, when the cljs js compiler asks for the source of a namespace as a non-macro namespace, shadow-cljs effectively (modulo analyze caching and so on) offers output generated form .cljs or .cljc files, and when asked for a macro namespace, it offers .cljc or .clj, is that accurate? Does that effectively mean that for bootstrapped / self-hosted cljs we can put CLJS code in .clj files?#2022-12-2916:02mbertheauAlso, if I have code that should run at compile-time, and that code is different for cljs jvm (clj compiles macro ns) and cljs js (cljs compiles macro ns) and I want separate files for macro ns from non-macro ns, I end up with a .clj file with #?(:cljs reader conditionals, correct?#2022-12-2916:14thhellercan you point me to the actual sources?#2022-12-2916:19mbertheauThe original specter source code for the select macro: https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter.cljc#L347 And the PR: https://github.com/jeff303/specter/blob/bootstrap/src/clj/com/rpl/specter.cljc#L359#2022-12-2916:20mbertheauIn the PR the effective change was replacing #?(:clj with (macrovich/deftime.#2022-12-2916:21mbertheauI have a local repo that shows that defmacros in macrovich/deftime in cljc files don't end up in the compiled js and are thus not available for source code to be compiled by the self-hosted compiler.#2022-12-2916:21mbertheauBased on quickstart-browser, which I was about to push to github#2022-12-2916:44thhellerdeftime seems useless to me here, as is the conditional. just remove it entirely, so the code is always loaded#2022-12-2916:45thhellerI mean I can't tell if there is any actual java interop in there, but otherwise if its just clojure code just keep it always active#2022-12-2916:46thhellerthe defmacroalias is also a problem#2022-12-2916:46thhellercan't alias vars like that for cljs#2022-12-2916:46mbertheauYeah, there's a separate solution for that in the PR that I'll take.#2022-12-2916:47mbertheauThanks, I'll try that. I still need to understand it though 🙂 So defmacros` in macrovich/deftime aren't supposed to end up in the JS output?#2022-12-2916:47thhellernot a clue. I've never used macrovich, don't know what it means#2022-12-2916:50thhellerthe problem is that #(:clj ..) hides it from the CLJS macro compilation which will take the :cljs branch. so thats why select is missing, it is never there in the first place#2022-12-2916:50thheller(defmacroalias richnav macros/richnav) don't know why this is there#2022-12-2916:51thhellerwhy not just have the macros directly use macros/richnav. I never get these aliasing things, so not sure why it has to be in this ns#2022-12-2916:55mbertheaudeftime is just 1 line:
(defmacro deftime
  "This block will only be evaluated at the correct time for macro definition, at other times its content
   are removed.
   For Clojure it always behaves like a `do` block.
   For Clojurescript/JVM the block is only visible to Clojure.
   For self-hosted Clojurescript the block is only visible when defining macros in the pseudo-namespace."
  [& body]
  (when #?(:clj (not (:ns &env)) :cljs (re-matches #".*\$macros" (name (ns-name *ns*))))
    `(do 
#2022-12-2916:58thhellerthat sounds like it should be what you want#2022-12-2916:59mbertheauI thought so, but defmacro s defined in a macrovich/deftime don't appear in JS output produced by a shadow-cljs :bootstrap build.#2022-12-2917:00mbertheauAh, I may have to put the namespace in :macros in the config.#2022-12-2917:04thhelleragain, this does not seem like its needed to me#2022-12-2917:05thhellershadow-cljs already ignores defmacro in .cljc files unless compiling macros, so having them there doesn't do anything "extra"#2022-12-2917:09mbertheauI understand that I don't need deftime here, but I'd like to understand why it doesn't match my mental model. You said before that deftime sounds like it should be what I want. But nothing that's inside deftime ends up in the JS output. Is that expected, given its definition above?#2022-12-2917:09thhellerI cannot say without seeing the full actual code#2022-12-2917:10thhellerthe defmacro should definitely be in the generated $macros.js file, but not in the regular ns .js file#2022-12-2917:10mbertheauAlright, let me push something to github to show you#2022-12-2917:27mbertheau@U05224H0W https://github.com/shadow-cljs/quickstart-browser/compare/master...mbertheau:quickstart-browser:master#2022-12-2917:29mbertheauI just noticed a possible misunderstanding. I didn't mean that the deftime macro itself doesn't end up in the JS, but that what's inside a call to the deftime macro doesn't end up in the $macros.js file.
#2022-12-2917:35thheller
goog.provide('friday.myns$macros');
console.log("hello from toplevel");
friday.myns$macros.toplevelfunction = (function friday$myns$macros$toplevelfunction(){
return console.log("hello from toplevel function");
});
var ret__5824__auto___14156 = friday.myns$macros.toplevelmacro = (function friday$myns$macros$toplevelmacro(_AMPERSAND_form,_AMPERSAND_env){
console.log("hello from toplevelmacro expansion");

return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("js","console.log","js/console.log",-2005248266,null),null,(1),null)),(new cljs.core.List(null,"hello from toplevelmacro result evaluation",null,(1),null)))));
});
(friday.myns$macros.toplevelmacro.cljs$lang$macro = true);

console.log("hello from usetime");

friday.myns$macros.usetimefunction = (function friday$myns$macros$usetimefunction(){
return console.log("hello from usetimefunction");
});

var ret__5824__auto___14160 = friday.myns$macros.usetimemacro = (function friday$myns$macros$usetimemacro(_AMPERSAND_form,_AMPERSAND_env){
console.log("hello from usetimemacro expansion");

return cljs.core.sequence.cljs$core$IFn$_invoke$arity$1(cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2((new cljs.core.List(null,new cljs.core.Symbol("js","console.log","js/console.log",-2005248266,null),null,(1),null)),(new cljs.core.List(null,"hello from usetimemacro result evaluation",null,(1),null)))));
});
(friday.myns$macros.usetimemacro.cljs$lang$macro = true);


//# sourceMappingURL=friday.myns$macros.js.map
#2022-12-2917:35thhellerseems to be all there for me?#2022-12-2917:40mbertheauNot deftimemacro though#2022-12-2917:46thhelleroh what is usetime then? confusing names 😛#2022-12-2917:46thhellerjust saw some time stuff and thought thats it 😛#2022-12-2917:54thhellercould be that *ns* isn't actually bound to the $macros ns? never checked#2022-12-2917:59mbertheauIs that a peculiarity of shadow-cljs bootstrapped cljs? shadow-cljs does compile the cljs to js outside the browser. Is that different in this regard compared to compiling all the namespaces in the browser?#2022-12-2918:01thhellerthe macro compilation is not done for regular builds, so this is different#2022-12-2918:05mbertheauI pushed a commit that logs (ns-name *ns*) in all the places and only ever get null or markus.pumpkin, never markus.pumpkin$macros.#2022-12-3006:26thheller*ns* is definitely bound to the correct value. most of your additions were incorrect though. I don't understand the problem with deftime either, but I do not see the point anyways so just do not use it#2022-12-2813:16niwinzHello, I think I found a bug. For now I don't have an isolated reproducible setup, but I consistently trigger it on penpot project compilation. In summary: when module split + function tht uses reify. The result is: there are a function1 that uses reify, which will define the class once the function1 is used (defined in module shared.js); and for some reason a one method impl is splitted to the main.js module where the prototype is extended with the missing method, but the object is obviously does not exists until the function1 is called. Code sample from shared.js:
function $promesa$exec$scheduled_executor$cljs$0core$0IFn$0_invoke$0arity$0variadic$$($p__32931$$) {
    var $map__32932__$1$$ = $cljs$core$__destructure_map$$($p__32931$$)
      , $parallelism$$ = $cljs$core$get$$.$cljs$core$IFn$_invoke$arity$3$($map__32932__$1$$, $cljs$cst$172$parallelism$$, 1)
      , $factory$jscomp$2$$ = $cljs$core$get$$.$cljs$core$IFn$_invoke$arity$2$($map__32932__$1$$, $cljs$cst$173$factory$$);
    if ("undefined" === typeof $promesa$$ || "undefined" === typeof $promesa$exec$$ || "undefined" === typeof $promesa$exec$t_promesa$0exec32933$$) {
        $promesa$exec$t_promesa$0exec32933$$ = function($p__32931$jscomp$1$$, $map__32932$jscomp$1$$, $parallelism$jscomp$1$$, $factory$jscomp$3$$, $meta32934$$) {
            this.$p__32931$ = $p__32931$jscomp$1$$;
            this.$map__32932$ = $map__32932$jscomp$1$$;
            this.$parallelism$ = $parallelism$jscomp$1$$;
            this.$factory$ = $factory$jscomp$3$$;
            this.$meta32934$ = $meta32934$$;
            this.$cljs$lang$protocol_mask$partition0$$ = 393216;
            this.$cljs$lang$protocol_mask$partition1$$ = 0;
        }
        ,
        $promesa$exec$t_promesa$0exec32933$$.prototype.$cljs$core$IWithMeta$_with_meta$arity$2$ = function($_32935$$, $meta32934__$1$$) {
            return new $promesa$exec$t_promesa$0exec32933$$(this.$p__32931$,this.$map__32932$,this.$parallelism$,this.$factory$,$meta32934__$1$$);
        }
        ,
        $promesa$exec$t_promesa$0exec32933$$.prototype.$cljs$core$IMeta$_meta$arity$1$ = function() {
            return this.$meta32934$;
        }
        ,
        $promesa$exec$t_promesa$0exec32933$$.prototype.$promesa$protocols$IScheduler$_schedule_BANG_$arity$3$ = $JSCompiler_stubMethod$$(0),
        $promesa$exec$t_promesa$0exec32933$$.$cljs$lang$type$ = !0,
        $promesa$exec$t_promesa$0exec32933$$.$cljs$lang$ctorStr$ = "promesa.exec/t_promesa$exec32933",
        $promesa$exec$t_promesa$0exec32933$$.$cljs$lang$ctorPrWriter$ = function($writer__5331__auto__$jscomp$87$$) {
            return $cljs$core$_write$$($writer__5331__auto__$jscomp$87$$, "promesa.exec/t_promesa$exec32933");
        }
        ;
    }
    return new $promesa$exec$t_promesa$0exec32933$$($p__32931$$,$map__32932__$1$$,$parallelism$$,$factory$jscomp$2$$,$cljs$core$PersistentArrayMap$EMPTY$$);
}
And a code sample form main.js
$promesa$exec$ScheduledTask$$.prototype.$promesa$protocols$ICancellable$_cancel_BANG_$arity$1$ = $JSCompiler_unstubMethod$$(1, function() {
    // ...
});
$promesa$exec$t_promesa$0exec32933$$.prototype.$promesa$protocols$IScheduler$_schedule_BANG_$arity$3$ = $JSCompiler_unstubMethod$$(0, function($G__32936__$jscomp$255$$, $ms$jscomp$4$$, $f$jscomp$369$$) {
    var $done$$ = $cljs$core$volatile_BANG_$$(!1)
      , $tid$$ = setTimeout(function() {
        try {
            return $f$jscomp$369$$.$cljs$core$IFn$_invoke$arity$0$ ? $f$jscomp$369$$.$cljs$core$IFn$_invoke$arity$0$() : $f$jscomp$369$$();
        } finally {
            $cljs$core$_vreset_BANG_$$($done$$, !0);
        }
    }, $ms$jscomp$4$$);
    $G__32936__$jscomp$255$$ = {
        done: $done$$,
        cancelled: !1,
        "cancel-fn": function() {
            return clearTimeout($tid$$);
        }
    };
    return $promesa$exec$__GT_ScheduledTask$$.$cljs$core$IFn$_invoke$arity$1$ ? $promesa$exec$__GT_ScheduledTask$$.$cljs$core$IFn$_invoke$arity$1$($G__32936__$jscomp$255$$) : $promesa$exec$__GT_ScheduledTask$$($G__32936__$jscomp$255$$);
});
function $cljs$core$persistent_BANG_$$($tcoll$jscomp$14$$) {
   /...
where you can see that $promesa$exec$t_promesa$0exec32933$$ is used in main.js, but this one will only be defined if the $promesa$exec$scheduled_executor$cljs$0core$0IFn$0_invoke$0arity$0variadic$$ called. And this function is not called until long after the first browser load+eval Is this make sense?
#2022-12-2813:21niwinzI guess I can workaround it by not using reify on promesa library and replace it with a deftype, but still is very strange that a method definition of some reify object (that is conditionally initialized on first call) is relocated to other module and called on module load+eval time#2022-12-2815:23thhellerknown problem#2022-12-2815:23thhellerhttps://clojure.atlassian.net/browse/CLJS-3207#2022-12-2815:24thhellerwork arround is to set :compiler-options {:cross-chunk-method-motion false} in the build config#2022-12-2908:28niwinzthanks! \o/#2022-12-2921:08mbertheau@thheller Why would a :target :bootstrap build error out with ClassNotFoundException: com.rpl.specter.Util? Isn't all compilation done by the JS/CLJS implementation of the CLJS compiler?#2022-12-2921:09mbertheauThis is the full backtrace:
{:tag :a, :attrs {:href "/cdn-cgi/l/email-protection", :class "__cf_email__", :data-cfemail "1f727e6d746a6c5f6a7d6a716b6a2d2d2f2b"}, :content ("[email protected]")}
#2022-12-2921:10mbertheauThis is the configuration for the :bootstrap target:
:bootstrap
  {:target     :bootstrap
   :output-dir "public/bootstrap"
   :exclude    #{cljs.js}
   :entries    [cljs.js com.rpl.specter]}
#2022-12-2921:14mbertheauUnless I'm reading the source incorrectly, all usages of the Util class are inside a #?(:clj reader conditional: https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/impl.cljc#L22 and https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/impl.cljc#L91#2022-12-2921:15mbertheauI was under the impression that for the bootstrap build only #?(:cljs branches are taken.#2022-12-3005:59thhellerbootstrap compiles cljc files twice. one for cljs, once for macros#2022-12-3005:59thhellerthis appears to be a java helper classes, so you need to write an equiv for JS#2023-01-0121:29mbertheau@thheller Ok, but both are compiled to JS by CLJS, and they take #?(:cljs branches, correct? All mentions of the helper class are in #?(:clj branches.#2023-01-0207:20thhelleryes, it takes the :cljs branch when compiling for macros. when compiling normally it is taking for :clj branch for the macros, since that runs in clj#2023-01-0208:00thhellerso I looked into self-hosted macros compilation and why deftime doesn't work#2023-01-0208:00thhellerfound this commit https://github.com/thheller/shadow-cljs/commit/ab82092788fac5f6fd4aece75663166eedeb73b6#diff-6fa7ba019eb2696a1633a048a1f9248d19c07e6c2f42d7cbfc7a3c2e75b1375eR154#2023-01-0208:00thhellerwhich explains it. but it has been like this for 5 years. so either nobody ever used deftime with shadow-cljs#2023-01-0208:00thhelleror nobody complained#2023-01-0208:01thhellerI'm sort of hesitant to change it, since I'm not sure who'd be affected#2023-01-0208:42mbertheauI don't yet follow. What is going on that the :bootstrap target can complain about Java things if it should take only #?(:cljs branches? Is this an issue that's separate from the deftime question? About changing or not changing *ns*: "`macros/deftime` and macros/usetime to clearly demarcate regions of code that should be run in the macro-definition stage or in the macro-usage stage. (In Clojure there's no distinction; in pure Clojurescript it's easy: just wrap the first stage in #?(:clj ...) and the latter one in #?(:cljs ...); in self-hosted Clojurescript it's messy or everything gets evaluated twice; supporting the three at the same time is Macrovich's .)" (from https://github.com/cgrand/macrovich#usage) I take this to mean that in other self-hosted environments deftime works, so maybe it's a good idea for shadow-cljs to be compatible in that regard to these other self-hosted environments.#2023-01-0208:44thheller:bootstrap must compile the namespace twice. the first time it is compiled like regular CLJS, just the normal namespace using CLJ for macro expansion. this will end up loading all the related Java code. on the second pass it is compiled again in macro mode, which is purely CLJS.#2023-01-0208:46thhellerthe entirely separate issue of deftime is related to the *ns* binding, which I guess macrovich expects to be bound to the $macros variant, which is not the case in shadow-cljs and never has been#2023-01-0208:47thhellerit is not the case because otherwise namespaced keywords such as ::foo would have unexpected results#2023-01-0208:47thhellerI have never verified what regular CLJS does in these cases since I frankly don't know how to do macro compilation for regular CLJS#2023-01-0208:48thhellerbut as I said many times before. just remove deftime. it is not needed and doesn't do anything useful here.#2023-01-0208:48mbertheauPart of my quest is to solve the problem, the other is to gain understanding 🙂#2023-01-0208:48thhellerif you want to setup a reproduction with regular CLJS that proves the differences I'm happy to adjust#2023-01-0208:49thhellerbut without that I'm not changing something nobody had an issue with for 5 years#2023-01-0208:50thhelleryou seem to have a good understanding of stuff. just the wrong expectation of what deftime does. at its current stage it is broken with regards to how shadow-cljs handles it. so its either broken in shadow-cljs or macrovich#2023-01-0208:51mbertheauJust one more question now, of what use is a ClojureScript JVM compilation of a cljs namespace, that is, one using CLJ for macro expansion, in the context of the :bootstrap build, which is producing artifacts that should be consumed by self-hosted ClojureScript?#2023-01-0208:51thhellerthe entire point of :bootstrap is to *pre-compile* namespaces. this is not something regular CLJS self-hosted does#2023-01-0208:52mbertheauI'll see if I can set up a show case how stuff behaves differently in shadow-cljs self-hosted vs other environments.#2023-01-0208:54mbertheauYeah ok, but isn't that slightly incorrect, given that without shadow-cljs's caching/pre-compiling, the self-hosted CLJS compiler would request the CLJS source for the namespaces, both :macro false and :macro true , and read both without taking any CLJ branches? That must result in different analysis results than doing it on the server side with CLJ-hosted CLJS.#2023-01-0208:55mbertheauIs it a trade-off, where the difference is just in uncommon edge-cases that haven't come up in five years, or is there something else that I'm missing that resolves these differences?#2023-01-0208:58mbertheauHere's an example of macro compilation in self-hosted cljs http://nbeloglazov.com/2016/03/07/getting-started-with-self-hosted-cljs-part-2.html#2023-01-0209:11mbertheauTo do everything "correctly" (in my current understanding of what that is), you'd have to use the self-hosted CLJS compiler for the pre-compilation as well. Not sure how practical that is. Maybe a way forward would be to have the pre-compilation be optional and just have shadow-cljs provide or prepare the file system / class path for loading CLJS sources to be used by the self-hosted CLJS compiler.#2023-01-0209:14thhellerI'm still missing why having Util is a problem suddenly? if its only in :clj branches everything is fine and I don't understand the context of the problem#2023-01-0209:15thhellerpre-compilation is already optional. just don't use it if you don't need it#2023-01-0209:15thhellerthe entire :bootstrap target is fine with just compiling cljs.core. there is no need to precompile anything else#2023-01-0209:16thhellerit is just there to things like maria.cloud (which is what I wrote all this for) load faster. it saves a couple seconds of initialization time to not have the client compile everything on page load#2023-01-0209:16thhellerlike 10sec+, which was a significant speedup#2023-01-0209:17thhellerI do not use self-hosted much myself, so I'm not very clear on any of the details myself. I know it works and that a few people use it as is#2023-01-0209:17thhellerI don't know anything using macrovich though#2023-01-0209:30mbertheauOh, I can switch it off? I'll try that then and see how that behaves differently apart from the performance aspect.#2023-01-0209:31thhellerwell, you have to supply the compilation parts then on the client#2023-01-0209:32mbertheauSo that's just self-hosted cljs without :bootstrap at all then? The part I'd like to use, that :bootstrap provides, is making the source for namespaces available. Just without the precompilation.#2023-01-0209:33thhellerif you want custom compilation you write the code for that custom compilation#2023-01-0209:33thhellerbootstrap does exactly what it does and not more#2023-01-0209:33mbertheauWell, not so much custom, just that it should all be self-hosted CLJS 🙂#2023-01-0209:34thhellerthat is custom#2023-01-0209:34thhellerthe specify :entries [cljs.core] in :bootstrap and do the rest yourself#2023-01-0209:34thhellerthere is no need to specify anything else. it is just there as a convenience.#2023-01-0209:34thhellerself-hosted is a very complex topic and it is impossible to cover all aspects simply#2023-01-0209:35thhellerthings are going to vary greatly depending what you are building this for#2023-01-0209:35thhellerie. running node means the sources and code are loaded entirely differently than in the browser#2023-01-0209:35thhellerpre-compilation is provided as a convenient but OPTIONAL "service"#2023-01-0209:38thhellerthere are some other things that pre-dated :target :bootstrap that tried to do the same thing#2023-01-0209:38thhellerhttps://github.com/braintripping/cljs-live#2023-01-0209:38thhellerand some others I can't remember the names of#2023-01-0209:39thhellermaybe they can provide some useful background#2023-01-0209:46mbertheauAlright, I learned a lot, thanks! This is my take-away: :bootstrap compiles namespaces in normal mode (i.e. :macro false) with the CLJ ClojureScript compiler. It'll correspondingly compile any required macro namespaces with Clojure and use these to expand macros. It'll also compile any required namespaces in macro mode with the CLJ ClojureScript compiler, producing JS output. (Here there's no difference between using the CLJ ClojureScript compiler or a JS-hosted CLJS ClojureScript compiler.) Effectively, if a namespace is required as both a normal and a macro namespace, it'll be compiled three times: • a) once explicitly by :bootstrap with the CLJ ClojureScript compiler in non-macro mode as ClojureScript to produce output JS and analysis for the browser-side CLJS compiler • b) once somewhat implicitly by the CLJ ClojureScript compiler with the Clojure compiler in macro mode as Clojure, to do macro expansion for a) • c) once explicitly by :bootstrap with the CLJ ClojureScript compiler in macro-mode as ClojureScript to produce output JS and analysis for the browser-side CLJS compiler Is this correct?#2023-01-0209:46thheller> It'll correspondingly compile any required macro namespaces #2023-01-0209:47thhellerno. it'll not compile them at all. it'll (require 'that.ns) in CLJ only. the compiler never looks at them.#2023-01-0209:49thhellerand we need to be explicit about .cljc in this case. cljc is always multiple files in one, which makes it more difficult to understand#2023-01-0209:49thhellerlets takes a regular .cljs file with macros in .clj#2023-01-0209:49thhellerfor self hosted/boostrap the cljs file is compiled once and the clj file is compiled once. for normal compilation only the cljs file is looked at and compiled by the cljs compiler. the clj file is loaded by clojure and a black box as far as the cljs compiler is concerned#2023-01-0209:50thhellerthe same is true for cljc just that there is only one file#2023-01-0209:50mbertheauOK, let me type that out to account for that.#2023-01-0210:18mbertheauWith the following :bootstrap configuration
{:entries [cljs.js my.separate]
 :macros  [my.separate]}
and a file my/separate.cljs:
(ns my.separate
  (:require-macros [my.separate]))

;; main code omitted
and a file my/separate.clj:
(ns my.separate)

;; macro implementations and supporting code omitted
we're asking the :bootstrap build to prepare everything so that I can require my.separate:
(ns ...
  (:require [my.separate]))
and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate namespace in non-macro mode. This uses the my/separate.cljs file, taking #?(:cljs branches. It produces JS output suitable for execution in a JS runtime. 2. During this process, the CLJ ClojureScript compiler requests the my.separate namespace in macro mode. The file my/separate.clj is provided to it. It is compiled as Clojure, taking #?(:clj branches. The result is used for macro expansion in step 1. 3. Step 1 finishes and produces JS output as well as analysis results. 4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate namespace in macro mode. This uses the my/separate.clj file. It is compiled as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for the macro expansion phase of the self-hosted ClojureScript compiler. my/separate.clj was compiled twice: once as Clojure in macro-mode, and once as ClojureScript, also in macro-mode. Here is what happens when combining the non-macro and macro namespaces in one .cljc-file: With the following :bootstrap configuration
{:entries [cljs.js my.combined]
 :macros  [my.combined]}
and a file my/combined.cljc:
(ns my.combined
  #?(:cljs (:require-macros [my.combined])))

;; macro implementations and supporting code omitted
;; main code omitted
we're asking the :bootstrap build to prepare everything so that I can require my.combined:
(ns ...
  (:require [my.combined]))
and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined namespace in non-macro mode. This uses the my/combined.cljc file, taking #?(:cljs branches. It produces JS output suitable for execution in a JS runtime. 2. During this process, the CLJ ClojureScript compiler requests the my.combined namespace in macro mode. The file my/combined.cljc is provided to it. It is compiled as Clojure, taking #?(:clj branches. The result is used for macro expansion in step 1. 3. Step 1 finishes and produces JS output as well as analysis results. 4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined namespace in macro mode. This uses the my/combined.cljc file. It is compiled as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for the macro expansion phase of the self-hosted ClojureScript compiler. my/combined.cljc was compiled three times: once as ClojureScript in non-macro mode, once as Clojure in macro-mode, and once as ClojureScript in macro-mode. @thheller, is that accurate?
#2023-01-0213:40thhellerno#2023-01-0213:41thheller> 2. During this process, the CLJ ClojureScript compiler requests ...#2023-01-0213:41thhellerno, as I explained above ... the clojurescript compiler does absolutely nothing with those files#2023-01-0213:41thhellerexcept require them.#2023-01-0213:41thhelleralso cljs/clj files don't take any #? branches. thats CLJC only#2023-01-0213:42thhelleralso the macro compilation happens after all cljs compilation is completed#2023-01-0213:43thheller> my/combined.cljc was compiled three times: once as ClojureScript in non-macro mode, once as Clojure in macro-mode, and once as ClojureScript in macro-mode.#2023-01-0213:43thhelleragain .. 2 times by the cljs compiler#2023-01-0213:44thhellerthe third time it is loaded by clojure as a regular clojure file. it is not touched or compiled in any way by the cljs compiler#2023-01-0213:44thhellerthis is true for cljs and cljc files#2023-01-0618:57mbertheauAlright, thanks! Back from holidays now, continuing this inquiry 🙂 Here's the corrected text: With the following :bootstrap configuration
{:entries [cljs.js my.separate]
 :macros  [my.separate]}
and a file my/separate.cljs:
(ns my.separate
  (:require-macros [my.separate])

;; main code omitted
and a file my/separate.clj:
(ns my.separate)

;; macro implementations and supporting code omitted
we're asking the :bootstrap build to prepare everything so that I can require my.separate:
(ns ...
  (:require [my.separate]))
and get access to both macros and normal functions in it. Effectively, the following things will happen during the :bootstrap build with regards to the my.separate namespace: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate namespace in non-macro mode. This uses the my/separate.cljs file. It produces JS output suitable for execution in a JS runtime. 2. During this process, the CLJ ClojureScript compiler requires the my.separate namespace. The file my/separate.clj is used. It is compiled as Clojure. The result is used for macro expansion in step 1. 3. Step 1 finishes and produces JS output as well as analysis results. 4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.separate namespace in macro mode. This uses the my/separate.clj file. It is compiled as ClojureScript. It produces JS output suitable for the macro expansion phase of the self-hosted ClojureScript compiler. my/separate.clj was compiled twice: once as Clojure (implicitly by requiring it during CLJS compilation), and once as ClojureScript in macro-mode. Here is what happens when combining the non-macro and macro namespaces in one .cljc-file: With the following :bootstrap configuration:
{:entries [cljs.js my.combined]
 :macros  [my.combined]}
and a file my/combined.cljc:
(ns my.combined
  #?(:cljs (:require-macros [my.combined])))

;; macro implementations and supporting code omitted
;; main code omitted
we're asking the :bootstrap build to prepare everything so that I can require my.combined:
(ns ...
  (:require [my.combined]))
Effectively, the following things will happen during the :bootstrap build with regards to the my.combined namespace: 1. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined namespace in non-macro mode. This uses the my/combined.cljc file, taking #?(:cljs branches. It produces JS output suitable for execution in a JS runtime. 2. During this process, the CLJ ClojureScript compiler requires the my.combined namespace. The file my/combined.cljc is used. It is compiled as Clojure, taking #?(:clj branches. The result is used for macro expansion in step 1. 3. Step 1 finishes and produces JS output as well as analysis results. 4. :bootstrap uses the CLJ ClojureScript compiler to compile the my.combined namespace in macro mode. This uses the my/combined.cljc file. It is compiled as ClojureScript, taking #?(:cljs branches. It produces JS output suitable for the macro expansion phase of the self-hosted ClojureScript compiler. my/combined.cljc was compiled three times: once as ClojureScript in non-macro mode, once as Clojure (again, implicitly by requiring it during CLJS compilation), and once as ClojureScript in macro-mode. And two observations: • if you need differing macro implementations for CLJ and CLJS, there's no way around .cljc files, correct? • In the first situation, a .clj file is compiled as a ClojureScript file, producing JS output, correct? @thheller, is that all accurate?
#2023-01-0619:49thhellerin all this summary I'd remove "It is compiled as Clojure." as it just confuses what is going on IMHO#2023-01-0619:49thhellerno and yes to the last two questions#2023-01-0619:50thhelleryes, the .clj file is compiled to produce JS output#2023-01-0619:51thhellerthe macro can emit what it wants in case of .clj too. Using reader conditionals for that is not the only way#2023-01-0619:54thhellerand FWIW you do not need :macros [my.combined] in the build config. it is infered that this is require'd via the :require-macros. It is only needed for namespaces that are not otherwise required#2023-01-0620:17mbertheauAlright, thanks!#2022-12-3014:24michihuberI'm currently migrating to shadow-cljs (from using cljsbuild directly for prod, lein-figwheel for dev) and have some issues with promises that I handle through <p!. I require core.async like this:
[cljs.core.async :as async :refer [go >! <!]]
            [cljs.core.async.interop :refer [<p!]]
and work with promises like this (heavily abridged)
(let [p+ (.readFile ^js (.-promises ^js FS) dict-path)]
  (try (go (let [p (<!p p+)] ...))
       (catch default e (println e)))
which prints the error
TypeError: aa.setTimeout is not a function
so it feels like I'm missing externs for core.async? any ideas? /cc @thheller
#2022-12-3016:11thhellerhard to say. core.async does not require externs. what is the full stacktrace? not sure where setTimeout is used? and which build :target is this?#2022-12-3016:57michihuberbuild target is browser, though that could be it - this is the main process script for an electron app#2022-12-3016:57michihuberwould nodejs be more suitable?#2022-12-3017:07thhellerI don't know. electron has a bunch of different contexts. not all have the regular JS primitives like setTimeout available#2022-12-3017:07thhelleris this a release build or a watch/compile dev build?#2022-12-3017:16michihuberthis is a release build. it used to run with a vanilla cljs.build build, so I feel browser should work as a target?#2022-12-3017:18thhellertry running the build with npx shadow-cljs release app --pseudo-names to figure out what the aa is supposed to be#2022-12-3017:18thhellerfor the regular electron "renderer" process a :browser build is fine#2022-12-3017:19michihuberah, scratch that, we used :target :nodejs#2022-12-3017:19michihubershould this be :node-script then?#2022-12-3017:19thhelleryeah, that won't work for the renderer#2022-12-3017:19michihuberno, this is for the main process, not renderer#2022-12-3017:19thheller:target :nodejs doesn't exist in shadow-cljs#2022-12-3017:19thhellerthat should be :node-script yes#2022-12-3017:19michihuberok, will try that#2022-12-3017:30michihuberI think it worked 🎉 thanks so much#2022-12-3017:31michihuberone more thing (well, I'm sure there will be more)... some externs aren't inferred, but also don't complain on compilation#2022-12-3017:31michihuberwhat could cause that?#2022-12-3017:32thhellerI can't say. not enough info#2022-12-3017:33michihuberwe often pass in js objs (e.g. node Path) as args, could this be the culprit?#2022-12-3017:33thhellerI can't say. need actual code examples. there are a billion things you could be doing#2022-12-3017:34michihuber
(defmethod integrant/init-key :app.system/x [_ system]
  (let [{:keys [App]} system]
    (.setAsDefaultProtocolClient App "foo")
#2022-12-3017:34michihubere.g. this did not warn about App#2022-12-3017:35thhellerseems like it should#2022-12-3017:35michihuberok, will dig deeper#2022-12-3017:35michihubernext year 🙂 guten rutsch!!#2022-12-3016:21mkvlrwhat’s the simplest way to compile some cljs snippet from the clojure repl? Or asked differently, could I call cljs.analyzer.api/emit and cljs.analyzer.api/analyze and with what state/env args so it knows symbols from my running shadow build?#2022-12-3016:22thhellercompile or eval?#2022-12-3016:23mkvlronly compile#2022-12-3016:23mkvlr(I’ve used shadow.cljs.devtools.api/cljs-eval but I only want the js code, not the result)#2022-12-3016:24thhellerbest open is probably using the shadow.build api directly#2022-12-3016:25thhellerhttps://github.com/thheller/shadow-cljs/blob/e53240007b45ab891f23edcb96b2ed377fafc471/src/repl/shadow/cljs/repl_test.clj#L188-L191#2022-12-3016:25thhellerand https://github.com/thheller/shadow-cljs/blob/e53240007b45ab891f23edcb96b2ed377fafc471/src/repl/shadow/cljs/repl_test.clj#L11-L32#2022-12-3016:25thhellerafter that there is a :repl-state key in the build state, which contains a bunch of :repl-actions#2022-12-3016:26thhellerbasically all of those need to happen before the last repl/process-input can be eval'd#2022-12-3016:26thhellerbut its all just compiled, no eval JS env required#2022-12-3016:27thhellervery low level though#2022-12-3016:27mkvlrcan I also use the running shadow watch and compile a string as if came in the end of my file?#2022-12-3016:27thhellerbut there aren't many repl-actions and they are sort of self explanatory#2022-12-3016:27thhellerno#2022-12-3016:28thhellerI mean in theory yes, but none of the targets have the necessary hooks or functionality to do that#2022-12-3016:29mkvlrand there’s no cljs.analyzer.api/analyze compatible state/env available either with shadow, is that right?#2022-12-3016:30thhellerwell the context matters here#2022-12-3016:30thhelleryou cannot just mess with a watch and expect it to work#2022-12-3016:30thhellerwatch after all manages a build-state in a very specific way#2022-12-3016:30thhellerif you just take it out and mess with it there is no way to "put it back"#2022-12-3016:31thhellerbut yes, you can take it out and mess with it#2022-12-3016:31mkvlrso for Clerk’s render functions are currently quoted form that are evaluated through sci#2022-12-3016:31mkvlrlike https://github.com/nextjournal/clerk/blob/626ea1e8c07359c3996d63cfd5fff6e34dc0989b/src/nextjournal/clerk/viewer.cljc#L703 or sometimes just symbols like https://github.com/nextjournal/clerk/blob/626ea1e8c07359c3996d63cfd5fff6e34dc0989b/src/nextjournal/clerk/viewer.cljc#L714#2022-12-3016:32mkvlrnow trying to figure out if I can alternatively support proper compiled cljs#2022-12-3016:33mkvlrwhich means I need to compile some of those quoted forms…#2022-12-3016:33thhellerwell you can do anything with the shadow.build api, its just not documented much#2022-12-3016:34borkdude@mkvlr if the quoted form is known at compile time, why do you even quote it and not just compile it as regular cljs?#2022-12-3016:35mkvlr@borkdude that’s all I’m trying to do in a first step#2022-12-3016:39mpisankoseems like that's a recurring problem, but.. trying to use @openfin/excel - and getting the following problem:
WARN:
shadow-cljs - failed to load module$node_modules$$openfin$excel$openfin_excel
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
eval @ app.excel.js:2
goog.globalEval @ main.js:566
env.evalLoad @ main.js:1659
(anonymous) @ main.js:2574

main.js:1661 An error occurred when loading app.excel.js
env.evalLoad @ main.js:1661
(anonymous) @ main.js:2574

ReferenceError: fin is not defined
    at shadow$provide.module$node_modules$$openfin$excel$openfin_excel (:3900/js/cljs-runtime/module$node_modules$$openfin$excel$openfin_excel.js:17:34)
    at shadow.js.jsRequire (:3900/js/cljs-runtime/shadow.js.js:34:18)
    at shadow.js.require (:3900/js/cljs-runtime/shadow.js.js:59:20)
    at eval (:3900/js/cljs-runtime/app.excel.js:2:64)
    at eval (<anonymous>)
    at goog.globalEval (main.js:566:21)
    at env.evalLoad (main.js:1659:12)
    at main.js:2574:12
using shadow-cljs 2.11.5 tried changing https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider and https://shadow-cljs.github.io/docs/UsersGuide.html#alt-node-modules any ideas?
#2022-12-3016:43thhellersorry never used that lib. don't know what fin is supposed to be. looks to be expecting to be running in excel? but looks like you are running this in a browser?#2023-01-0208:15mpisankoit's excel adapter - translating JS to some .net API i think. it's present when you run with the openfin container - but this happens when loading code that simply requires the dependency (invocation is wrapped in an (exists? js/fin) check - so it never gets called).#2023-01-0215:10mpisankosolved the issue by splitting modules (so i can isolate those dependencies which require special runtime) - and including that from a HTML script element - when needed. potentially could have done shadow-cljs https://shadow-cljs.github.io/docs/UsersGuide.html#_dynamic_module_import? but using target :browser so will just stick with this approach. cheers!#2022-12-3017:18Sean HagstromI have a question about avoiding these kind of errors: throw new Error('Namespace "' + name + '" already declared.'); I'm basically trying to use ViteJS and ShadowCLJS together but the hot reloading of Vite wants to recall goog.provide for everything when my ShadowCLJS ESM modules changes. I found an https://github.com/minimal-xyz/minimal-shadow-cljs-webpack/blob/master/lib/page.js#L1-L5 that might workaround the issue, but I wanted to check with anyone if that seems correct, or if there is a better way to avoid calling all of the goog.provide functions again. Thanks in advance 🙏#2022-12-3017:23thhellerI don't recommend using the vite reloading together with shadow-cljs. it is very likely to break everything. why not just let shadow-cljs reload its code?#2022-12-3017:25thhellerthe already declared exception you can get rid of by basically replacing goog.provide as done here https://github.com/thheller/shadow-cljs/blob/0275661910fd356ae3312e834ef76546a42777d6/src/main/shadow/cljs/devtools/client/env.cljs#L152-L161#2022-12-3017:30Sean HagstromWell I'm trying to hot reload custom JS components with Vite but ignore the Shadow-CLJS ESM module somehow and just let Shadow handle that. But that's tricky because Vite sees the shadow module changing and triggers a recall of those provide functions. Is there a reason to not always override goog.provide?#2022-12-3017:34thhellershould be fine for dev but might mess up release builds#2022-12-3017:35Sean HagstromOkay sounds good, would I patch goog in my main entry point for CLJS?#2022-12-3017:38thhelleranywhere before the first vite reload kicks in is fine#2022-12-3017:41Sean Hagstromokay sounds good! thank you for helping#2022-12-3108:39Sean HagstromHey do you mind if I clarify something about how to patch goog?#2022-12-3112:57thhelleryou just put the code I linked in a file and call it#2022-12-3017:53zalkyHey there, I have two builds, each with an http dev server defined. But they both appear to launch, even when I'm only launching one build:
{:test {:target   :browser-test
        ...
        :devtools {:http-port 8021 ...}}
 :dev  {:target   :browser
        ...
        :devtools {:http-port 8022 ...}}}
Only launching :dev:
$ clojure -M:cljs/dev:cljs/client watch dev
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.20.2 running at 
shadow-cljs - nREPL server started on port 60050
shadow-cljs - watching build :dev
[:dev] Configuring build.
[:dev] Compiling ...
[:dev] Build completed. (512 files, 0 compiled, 0 warnings, 4.21s)
Am I doing something wrong?
#2022-12-3017:54thhellerhttp servers are not build related and the config in the build config has been deprecated for 5+ years now. use https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http instead#2022-12-3017:55thhellerthey are meant to always run, so you can use them for release or compile builds as well as watch#2022-12-3018:10zalkyGotcha, thanks for the clarification.#2023-01-0210:24michihuberHappy New Year! 🎆 I'm seeing an issue where I've meta'd all the externs inference warnings, but the build is broken because of un-externed names. Any input on how I can debug this?#2023-01-0210:24michihuberPreviously, we've used lein extern to generate them, and if I run that and include those externs in the build, its all fine.#2023-01-0210:28michihuberOtherwise I get "Uncaught Module not provided: 10"#2023-01-0210:33michihuber(I now always get that error, can't get the app to launch anymore.)#2023-01-0213:45thhelleryou can create a release build with npx shadow-cljs release app --pseudo-names. that usually makes it easy to track what was renamed and which externs you would need.#2023-01-0213:46thhellerdon't know what you are doing exactly so can't provide more tips#2023-01-0213:46thhellerthe module not provided I'm guessing you get from either some bad cache or trying to mix files from different builds?#2023-01-0213:47thhelleror are there maybe other errors, before or after which may lead to this one?#2023-01-0214:58michihuberhm, so building with --pseudo-names fixes it#2023-01-0214:59michihuberany idea how to proceed from there?#2023-01-0215:02thhellerdo you use clj->js or js->clj alot?#2023-01-0215:03thhellerpseuo-names really shouldn't fix anything. if it does it likely means that the conflict is on a very short property name#2023-01-0215:03thhellerthe closure compiler shortens things to .a .b etc frequently#2023-01-0215:03thhellerwith pseudo-names that becomes .$whateverItWasBefore$#2023-01-0215:03thhellerwhich is less likely to cause conflicts#2023-01-0215:04thhellerthe only known issue I'm aware of regarding this is with js->clj#2023-01-0215:08thhellerwhat kind of externs did you have before? I don't know that lein extern is so dunno what that generaetd#2023-01-0215:12michihuberI do use clj->js and vice versa, not sure if a lot, but I think not#2023-01-0215:12michihuberwhen does this become an issue?#2023-01-0215:13michihuberone issue I just saw:
(.on win "close" #(do
                            (.set Settings "winBounds" (.getBounds win))
                            (when-not (contains? @!can-close window-id)
                              (.preventDefault %)
                              (async/put! event-queue
                                          {:window-id window-id
                                           :payload [:window/close-requested]}))))
this is code from an integrant init-key defmethod and doesn't produce any warnings about inferences
#2023-01-0215:14michihuberbut it does crash and can be fixed by ^js'ing win and Settings (maybe either is sufficient, have only tested both)#2023-01-0215:23thhellerthis should definitely give you externs warnings?#2023-01-0215:24thhellerdid you set :infer-externs in your build config somewhere?#2023-01-0215:24thhelleror are you using some ultra ancient shadow-cljs version?#2023-01-0216:41michihuberI did get a lot of warnings without setting any :infer-externs option – after silencing all warnings, this one remained (I saw that the default was what I wanted)#2023-01-0216:41michihuber2.20.16#2023-01-0216:44michihuberI just recompiled with explicit :infer-externs :auto and still no warnings#2023-01-0216:45thhellerwhat are win and sSettings in the above?#2023-01-0216:45michihuber(I mean no extra warnings)#2023-01-0216:46thhellerwhat does "extra" mean?#2023-01-0216:46michihuberwhen I ran the build the first time I did get a lot of warnings that I silenced#2023-01-0216:46michihuber
... source code ...
#2023-01-0216:47michihuberhm, it seems the win is tagged as js in the let, but that doesn't carry through to the closure?#2023-01-0216:49thhellerwin isn't tagged at all#2023-01-0216:50thhellershould be ^js win (BrowserWindow. (clj->js opts))#2023-01-0216:50thhellerand you are tagging a bunch of stuff that doesn't need tags at all#2023-01-0216:51michihuberyeah, I was tagging lots of stuff to debug this#2023-01-0216:52michihuberbut where do I trip up the warnings?#2023-01-0216:52thhellerwhich warnings?#2023-01-0216:52michihubershouldn't it give me a warning that I'm not tagging win?#2023-01-0216:52thhellerI'm still guessing mostly in the dark about what you are asking me#2023-01-0216:52thhellerso please be specific 😛#2023-01-0216:53thhellerno, you should get warnings about locations where it cannot infer externs#2023-01-0216:53thhellertagging win once in the start should pretty much be enough for most things I see there#2023-01-0216:54thhellerits always best to tag the name symbol, not the form that creates it#2023-01-0216:54michihubergot it#2023-01-0216:54thhellerwin ^js (BrowserWindow. (clj->js opts)) is not ideal since there are a few places in the compiler that lose type hints. I'm not sure this is one but to be sure just move it to the left#2023-01-0216:55thheller> when I ran the build the first time I did get a lot of warnings that I silenced#2023-01-0216:55thhellerwhat do you mean by silencing?#2023-01-0216:55michihuberI mean I tagged the locations it gave me#2023-01-0216:56thhellerok#2023-01-0216:57michihubershould I try reverting the tagging, go through the inference warnings again, but tag the symbols, not the expressions and see if that fixes it? or is that not the cause?#2023-01-0216:59thhellerI don't know the cause. I haven't seen the exact error. I'm guessing in the dark#2023-01-0217:25michihuberok, I'll try that#2023-01-0217:25michihuberand report back#2023-01-0217:26michihuber(at this point, just getting runtime errors related to non-externed symbols, fwiw)#2023-01-0217:26michihuberbut without getting non-inferrable externs warnings for those symbols#2023-01-0217:26michihuberno compile errors etc.#2023-01-0414:33michihuberupdate: I diligently fixed inference warnings the errors by tagging the named symbol where it appears first. this fixed the build 🎉 (I was led astray originally because of broken builds due to caching)#2023-01-0414:34michihuberthat said: I get a lot of runtime errors due to missing externs#2023-01-0414:34michihuberthere definitely is some kind of issue with inference of JS objects that get passed into a function through a clj map#2023-01-0414:37michihubere.g.
(defn do-stuff [system]
  (let [{:keys [Dialog]} system]
    (.doSomething Dialog "foo")))
we do this kind of stuff a lot. system is a booted integrant system, Dialog is (.-dialog Electron) no warning about Dialog at build time, but xy is not a function during runtime
#2023-01-0414:37thhellerthis should absolute 100% generate a warning#2023-01-0414:37michihuberany way I can debug this?#2023-01-0414:37thhellerdo you mistakenly set :infer-externs true in your build config?#2023-01-0414:38thhelleror somewhere else mess with *warn-on-infer*?#2023-01-0414:38michihuber
{:editor {:target :browser
           :output-dir "resources/public/js/compiled/"
           :modules {:editor {:entries [editor.core]}}
           :externs [
                     "resources/externs/react.ext.js"
                     "resources/externs/react-dom.ext.js"]}
  :analyzer {:target :browser
             :output-dir "resources/public/js/compiled/"
             :modules {:analyzer {:entries [analyzer.core]
                                  :web-worker true}}}
  :app {:target :node-script
        :main app.core/main
        :output-to "resources/public/app.js"}
  }
#2023-01-0414:38michihuberthis is our :builds key – we only h ave source-paths and dependencies set otherwise#2023-01-0414:39michihuberjust grepped for warn-on-infer and nothing came up#2023-01-0414:40thhellerhmm wtf#2023-01-0414:40thhellerI just took your code and code no warning either#2023-01-0414:41thhellerlet me check#2023-01-0415:08thhellerhmm this indeed seems to be a pattern that never produces any inference warnings#2023-01-0415:08thhellerso dot-interop on anything destructured in a let binding#2023-01-0415:17michihuberanything I can do to help with that? or would you recommend tagging manually for now as a fix is not straightforward?#2023-01-0415:34thhelleryou can upgrade to 2.20.17. that should give you warnings for this pattern#2023-01-0415:39michihuberdamn#2023-01-0415:39michihuber🙌🙌🙌#2023-01-0415:53michihubergot lots of new warnings, thanks! fyi, injecting symbols like Path or Url using this pattern does still not trigger warnings, though. (but e.g. FS App Dialog do trigger warnings)#2023-01-0415:55michihuberand it seems it sometimes only triggers one (local) occurrence, though not for later injections in different defn's further down the file#2023-01-0416:00thhellernot everything requires externs so that might be alright#2023-01-0303:05CrispinI am using an npm module that has another npm dependency (Im not requiring this second one directly myself). In this transitory dep, the main entry in the package.json of this module does not properly export the names, but the module entry does. I would like to use this referred file in the build, but I'm wary of converting the entire build to :entry-keys ["module" "browser" "main"]. Is there a way to overide the entry key for one particular module? What is the best approach in a situation like this? Can I tell shadow somehow to use this specific entry point for that package?#2023-01-0306:44thhellerdid you try building with module first? I mean if it works then that is the best path#2023-01-0306:44Crispinyes it works with module first#2023-01-0306:44thhellerotherwise you can use https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve#2023-01-0306:45Crispinin an ideal world, would module be first (and it's just not first by default because of legacy npm modules?)#2023-01-0306:46Crispin> otherwise you can use https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve Ah fantastic. I hoped there would be some kind of hook like this.#2023-01-0315:08Ted Ciafardini$ shadow-cljs watch app
com/google/javascript/jscomp/CompilerOptions has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Getting this error when following the quickstart for shadow-cljs projects. $ java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
The shadow-cljs docs specify version 8 of java, I believe
#2023-01-0315:15thhellerit used to be java8 but is java11 these days#2023-01-0315:16thhellertechnically shadow-cljs would still be fine with java8, but the closure compiler started requiring java11 so we inherit that.#2023-01-0315:17thhellerbut I'd recommend upgrading to the latest java LTS release (17) directly#2023-01-0315:25Ted CiafardiniThanks for the quick response#2023-01-0315:59orestisEvery now and then, I encounter this error in our CLJS CI tests (in github actions):
File: /home/runner/work/nosco-gamma/nosco-gamma/cljs/nosco/ui/animations.cljs
invalid cljs source type
{:resource-id [:shadow.build.classpath/resource "nosco/ui/animations.cljs"], :resource-name "nosco/ui/animations.cljs", :source #object["[B" 0x27e3b83f "[
It is always with this file, and it is intermittent (a re-run will proceed normally). Is there anywhere I could look to stop it?
#2023-01-0316:07thhellerweird. not sure how it would get a byte array there. :source is supposed to be a string#2023-01-0316:09thhellerits all slurp or restored from transit json cache. so dunno how you make it return a byte array instead#2023-01-0316:10thhellerdo you have a user.clj that modifies some stuff in weird ways? or other code that modifies something related to slurp or transit?#2023-01-0318:13orestisHm, this is on CI, perhaps some weird caching issue might be in play.#2023-01-0318:13orestisThanks on the slurp/transit pointers, I will have a look.#2023-01-0414:50chrisnI have a mixed js,cljs https://github.com/cnuernber/ham-scripted written js I would like to consume from another project. What is the recommended way of doing this? Is there an example of a mixed js,cljs npm module I can reference?#2023-01-0414:55thhellerits only those files I assume? no actual npm dependency?#2023-01-0414:56thhellerassuming the only target audience is cljs users? not actual npm JS consumers?#2023-01-0418:50chrisnPotentially both pure js users and cljs but probably not initially. There are two js files that probably should be in a subdir and two cljs files at the moment#2023-01-0418:51chrisnFirst will be upgrading tmdjs to use hashmap from bimaptrie.js#2023-01-0419:23chrisnOnly cljs for now#2023-01-0420:15thhellerif you are ok with cljs only consumers for now you should just put the files on the classpath#2023-01-0420:15thhellerso src/ham_fisted/BitmapTrie.js#2023-01-0420:16thhellerthem slap a goog.module("ham_fisted.BitmapTrie"); goog.module.declareLegacyNamespace(); in the first two lines#2023-01-0420:16thhellerand change your module.exports.x assignments to just exports.x assignments#2023-01-0420:16thhellerthan you can require and use this like any other ClojureJS namespace from cljs#2023-01-0420:17thhellerso just (:require [ham-fisted.BitmapTrie :as bm]) with the usual bm/stuff access#2023-01-0420:17thhellerit might be picky about the _ vs - situation. never tried a goog.module namespace with a - but should be fine#2023-01-0420:18thhellerall the manual node require hacks you are doing you remove of course#2023-01-0420:19thhellerall the aget stuff to get the exports obviously isn't needed anymore either#2023-01-0420:41chrisnWow gotcha will try and get back to you.#2023-01-0513:13chrisnThe manual hacks are there to get hot reloading - I imagine there are similar hacks to get hot reloading of the goog module pathway.#2023-01-0514:18chrisnThat definitely worked - but it is really difficult to work with. The cljs file can't be recompiled without restarting the emacs cider connection and the js file cannot be recompiled without killing the repl process itself and restarting it.#2023-01-0514:18chrisnI have noticed that so far that files with extend-type in them can often get into states where they will fail to recompile after the first compilation.#2023-01-0514:19chrisnregardless, this is at least a way forward now that the systems have been at least partially debugged.#2023-01-0501:28Lucio AssisI'm using shadow.resource/inline so that I have access to the contents of a resource (a plain text file) in a browser setting. That means I had to https://github.com/luciolucio/holi/blob/99d59621d52b4a1193949143ab43dfb7cbf2adda/deps.edn#L6, i.e., it's now a runtime dependency for anyone that wants to use my library, which seems odd to me. Is this the way inline is supposed to be used?#2023-01-0501:57Chris McCormickIf you just want this one piece of functionality you could write a small macro that uses slurp like this: https://gist.github.com/noprompt/9086232#2023-01-0503:09skylizeThe dependency issue should be mostly harmless. Shadow is written in JVM Clojure. and no CLJS build tool would try to stuff your whole Java dependency tree into a JavaScript bundle. The code in resource/internal does essentially the same thing as Chris McCormick's gist above, but adds logging to and lookup from a registry, to enable Shadow to cache those resources properly.#2023-01-0503:18skylizeIf you wanted to remove the Shadow dep from release, while still benefiting from Shadow's caching behavior: You could add a build step for release that either swaps in your own version of the macro or fully inlines the contents of the resource files.#2023-01-0506:21thheller@UUSQUGUF3 the point of s.r/inline is that shadow-cljs is aware of it and can trigger recompiles if the resource changes https://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2023-01-0506:21thhellerbut yes otherwise just using slurp is the same#2023-01-0506:22thheller@U028ZNM1S13 I could technically split out shadow.resource into its own separate lib but haven't done so yet. if you are worried about the extra dep you can put the code from it into one of your own namespaces and just use it that way.#2023-01-0506:23thhellerjust take https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/resource.cljs and https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/resource.clj and give them another name#2023-01-0507:59Chris McCormick@U05224H0W every now and then I think about a PR for adding rc/inline to the Shadow user guide but then I get hung up figuring out where it would go. Maybe in "Usage" after "Running Clojure Code"?#2023-01-0508:14thhellerwell as I said it would be fine as a separate lib. I just don't want to maintain 15 different one ns libs 😛#2023-01-0508:15thhellerprobably a new "Utilities" section or so would be good#2023-01-0508:16thhellerthere is also the whole shadow.cljs.modern stuff https://clojureverse.org/t/promise-handling-in-cljs-using-js-await/8998 https://clojureverse.org/t/modern-js-with-cljs-class-and-template-literals/7450
#2023-01-0508:16thhellerposted those so you can at least google stuff 😛#2023-01-0502:40fabraoHello all, I'm getting this error
; The result object failed to print. It is available via *1 if you want to interact with it.
; 
; The exception was: 
; 
; #error {:message "The limit of 1048576 bytes was reached while printing.", :data {:tag :shadow.remote.runtime.writer/limit-reached, :limit 1048576}}
What is it means?
#2023-01-0502:56wevremIt looks like whatever the result of the last expression evaluated, it was something rather large, too large to print.#2023-01-0505:41FranklinHello 👋 I've been able to run my tests in the cljs repl before with shadow-cljs but recently(after updating to shadow-cljs version 2.20.15), I'm getting the following error when I try to call (run-tests) from the cljs.test ns. I wonder if I'm missing something
;  Execution error (TypeError) at (<cljs repl>:1).
; Cannot read properties of undefined (reading 'run_block')
#2023-01-0506:08Franklinhere's how the tests I'm trying to run look like
(comment
  (deftest test-smart-search-form-fields
    (testing "If other fields list is truthy(not nil) then show dropdown"
      (re-frame-test/run-test-sync
       (js/console.log "does this work?")
       (let [other-field-temp (reagent/atom "")
             other-fields-focus (reagent/atom false)
             other-fields ["one" "two" "three" "four"]]
         (with-mounted-component
           [smart-search-form-fields other-field-temp other-fields-focus other-fields]
           (fn [_component]
             (js/console.log (.-innerText (js/document.querySelector
                                           "#smart-search-component")))))))))
  (run-tests))
#2023-01-0506:26thhellerhard to say from that snippet alone. looks fine and should work. I didn't make any changes to how testing works. did you maybe upgrade shadow-cljs but not cljs or so?#2023-01-0514:26jewietHello there, i have two builds. I am watching for the test and frontend build in one server. If I kill the watch that was started first, it kills the whole server.
{:dev-http {3449 "public"}
 :builds
 {:frontend
  {:target            :browser
   :output-dir        "public/js"
   :module-hash-names true
   :modules           {:main {:init-fn app.core/init}}
   :devtools          {:preloads [day8.re-frame-10x.preload]}
   :dev               {:compiler-options
                       {:closure-defines
                        {re-frame.trace.trace-enabled?        true
                         day8.re-frame.tracing.trace-enabled? true}}}}

  :test
  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-test$"
   :autorun   true}}}
Is there a way to watch for the test and frontend build in separate servers?
#2023-01-0514:27dpsuttoni suspect you should just start the server in its own process so that killing either watch doesn’t kill the server#2023-01-0514:27dpsutton> Commands that do long-running things implicitly start a server instance (eg. watch) but it is often advisable to have a dedicated server process running.#2023-01-0514:27dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#server-mode#2023-01-0514:34jewietThanks a lot.#2023-01-0606:38thhelleryeah just npx shadow-cljs server and then you can toggle all builds via other commands or the UI at http://localhost:9630#2023-01-0609:19Quentin Le GuennecHello. I need to have a config.edn that will work both for backend and for frontend compile constants. What’s the ideal way to achieve this with shadow-cljs?#2023-01-0609:27thhellerdefine "compile constants" and why they have to be in a config.edn?#2023-01-0609:30Quentin Le GuennecFor example: • wether the app is compiled in debug mode or not • the links the app will point too (different across dev/prod environments) They need to be in a config.edn because both the backend and frontend need to access them, and different environment have different config files.#2023-01-0610:00thhellerok, but for the backend these are not compile constants#2023-01-0610:00thhellerthey are runtime configuration#2023-01-0610:01thhellerarguably for the frontend they are also runtime configuration#2023-01-0610:01thhellerwhether its compiled in debug mode or not I'd say is a different problem#2023-01-0610:02thhellerwhat backend to talk to I personally configure at runtime not compile time#2023-01-0610:03thhellerand usually that is something my backend sends to my frontend, usually directly with the initial HTML#2023-01-0610:04Quentin Le GuennecYeah you’re right, for the backend it’s runtime configuration#2023-01-0610:04Quentin Le GuennecI guess I could send it to the frontend, yes#2023-01-0610:05thhellerI mean you can also all make these compile time constants if you really wanted#2023-01-0610:05Quentin Le Guennecbut it’d be more practical having it directly compiled into the js file imo.#2023-01-0610:06thhellerfor that you just need to build your own solution. since there is nothing provided out of the box for that#2023-01-0610:06Quentin Le GuennecOkay#2023-01-0610:06thhellerI mean if they have to be in config.edn.#2023-01-0610:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines#2023-01-0610:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#shadow-env#2023-01-0610:06Quentin Le GuennecI guess I could have shadow cljs to read the config.edn file and then generate closure defines according to it#2023-01-0610:06thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2023-01-0610:06thhellerare your options otherwise#2023-01-0610:07Quentin Le GuennecThank you!#2023-01-0610:07thhellerI'd say its easier and more flexible by other means. for example not having the recompile the entire CLJS code if your backend url changes. or using the same frontend build for prod and testing#2023-01-0610:08thhellerIMHO runtime configuration should not be compile contstants#2023-01-0610:08Quentin Le GuennecI see.#2023-01-0611:26bedersHappy new Year! Patreon is being funny:#2023-01-0615:41Tomáš BaránekHi, I’m a beginner in shadow-cljs and when it comes to familiarity with clojure and clojurescript, basically too. So please be patient :) I have successfully launched a small one-page interactive application on shadow-cljs/reagent/firebase as a sort of proof-of-concept. So I am not completely stupid. But now I’m stuck. I’m trying to figure out how to get the server (localhost for now) to simply take the address URI (e.g. the “a” part from localhost:8600/a) that user entered into the browser + just dump it to my console (e.g. directly via handler function). The next step will be that I will generate additional URIs (subaddresses) based on the app’s interaction with the user etc. For now console reaction would be great. But I just get 200 OK response when entering localhost:8600/a into browser (or when contacting server via GET API) – still without any reaction from handler function. The app is barebones, it compiles, the server runs, the page renders and is displayed. But when I specify e.g. localhost:8600/a, I am unable to get the server to get the handler react. I run it using shadow-cljs watch app. Here is my shadow-cljs.edn setup:
;; shadow-cljs configuration

{:source-paths
 ["src"]

 :dependencies [[binaryage/devtools "1.0.6"]
                [reagent "0.8.0-alpha2"]
                [ring "1.9.6"]]

 :nrepl        {:port 8777}

 :builds
 
 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"
        
        :modules
        {:main
         {:entries [when.core]}}

        :devtools
        ;; before live-reloading any code call this function
        {:before-load when.core/stop
         ;; after live-reloading finishes call this function
         :after-load when.core/start
         ;; serve the public directory over http at port 8700
         :http-root    "public"
         :http-port    8600
         :ring-handler when.helpers/handler
         :preloads     [devtools.preload]}}}}
What I am doing wrong here? Thank you very much!
#2023-01-0615:52thhellershadow-cljs is a CLJS development tool. ring is CLJ server side, which I always recommend doing without shadow-cljs#2023-01-0615:53thhellersince you won't be using shadow-cljs in production either. it is best to just setup your own CLJ server. the CLJS setup doesn't change#2023-01-0616:00thhellerif you really want to use shadow-cljs for this then you need to use the correct http config. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http#2023-01-0616:01thhellerso just :dev-http {8600 {:root "public" :handler when.helpers/handler}} at the top level. not inside the build config, and removing the http related things from there#2023-01-0616:07Tomáš BaránekOh, now I understand. Thank you very much, Thomas and thank you for your great tool.#2023-01-0617:15Tomáš BaránekI updated the .edn to
;; shadow-cljs configuration

{:source-paths
 ["src"]

 :dependencies [[binaryage/devtools "1.0.6"]
                [reagent "0.8.0-alpha2"]]

 :nrepl        {:port 8777}

 :dev-http {8600
            {:root "public"
             :handler when.helpers/handler}}

 :builds

 {:app {:target :browser
        :output-dir "public/js/compiled"
        :asset-path "/js/compiled"

        :modules
        {:main
         {:entries [when.core]}}

        :devtools
        {:before-load when.core/stop
         :after-load when.core/start
         :preloads     [devtools.preload]}}}}
and I get:
:shadow.cljs.devtools.server.dev-http/handler-load-ex - {:http-handler when.helpers/handler}
FileNotFoundException Could not locate when/helpers__init.class, when/helpers.clj or when/helpers.cljc on classpath.

...

[:app] Build failure:
The required namespace "when.helpers" is not available, it was required by "when/core.cljs".
"when/helpers.clj" was found on the classpath. Should this be a .cljs file?
during compilation.
#2023-01-0617:17Tomáš BaránekAnd here is my when.helpers file:#2023-01-0617:58thhelleras I said. server side ring handlers are running in CLJ thus this needs to be a .clj file not .cljs#2023-01-0622:30kwladykaWhat make less issues for Cursive in practice? shadow-cljs pom vs deps.edn? Including running REPL with Crusive in Intellij.#2023-01-0622:35thhellerI never had an issue with either but deps.edn gives you more flexibility due do better :local/root support#2023-01-0714:21michihuberwe're running electron with a custom protocol, serving assets via app://-/path/to/file so that we can use absolute paths like in the browser app. this makes shadow-cljs connect to ws://-:9630/... , which causes a websocket connection error. any way we can point shadow towards localhost?#2023-01-0715:48thheller:devtools {:use-document-host false} in the build config#2023-01-0715:48thhelleror https://shadow-cljs.github.io/docs/UsersGuide.html#proxy-support#2023-01-0715:54michihuber🙏#2023-01-0715:54michihuberwagmi#2023-01-0804:00Joshua Gelbardone character typo found, I think? looks like the vreset! in https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server.clj#L567 is meant to be a reset!, since instance-ref is an atom.#2023-01-0804:01Joshua GelbardI could make a PR 😛 (seems like overkill)#2023-01-0804:02Joshua Gelbard
; eval (current-form): (reload!)
; (err) Execution error (ClassCastException) at shadow.cljs.devtools.server/reload! (repl_fast.clj:526).
; (err) class clojure.lang.Atom cannot be cast to class clojure.lang.Volatile (clojure.lang.Atom and clojure.lang.Volatile are in unnamed module of loader 'app')
#2023-01-0806:35thhellerhmm right. it used to be a volatile but isn't used anywhere. so I guess nobody ever used it in 2 years or however long ago that change was#2023-01-0806:36thhellerfixed#2023-01-0813:35michihuberWe want to call shadow.cljs.devtools.api/release to build our production asset, but we need to inject closure-defines into the config. is there are way to do this currently? are we holding it wrong/shouldn't have to do this? if not, would you accept a PR to either accept :closure-defines inside the opts or to accept the build-config instead of a build id as the first arg? (so then we can fetch the config via s.c.d.config/get-build , override the closure-defines and pass it to release). could also go via release*, but then you have to set up the env etc. and from my current POV this could be a useful feature. (this is not about injecting a define that differs between envs – think e.g. hosted client vs on-prem client, where we need to configure different backends)#2023-01-0815:15thhellerits fine to call the release* function directly. just need to setup the runtime once. which is just (api/with-runtime ...) just like here https://github.com/thheller/shadow-cljs/blob/653dfa0cea96c496acc9a204ce644de284d69c50/src/main/shadow/cljs/devtools/api.clj#L343-L349#2023-01-0815:16thhelleras Martin suggested config-merge is also an option. it can be passed in opts via {:config-merge [{:clojure-defines {'foo.bar 1}}]}. note the extra vector though.#2023-01-0815:17thhellerusually easier to just get the build config directly and modify it however you want#2023-01-0815:17thhellerif you run via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run the runtime is already created, so you could skip the with-runtime#2023-01-0814:18mkvlr@michihuber see https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2023-01-0908:22nivekuilshadow.loader/load is working in dev, but not in release. The error is CustomError: Error loading <module>: Consecutive load failures and the stacktrace is just as cryptic.. any troubleshooting ideas? The xhr to get the .js file does succeed but it's fetched 3 times and fails after the 3rd.#2023-01-0909:29thhelleris your server sending the correct response? usually the only happens when the server doesn't send the proper .js file?#2023-01-0909:29thhellercheck the browser devtools which file it is requesting and what its contents are#2023-01-0909:30thhellersuccessful request unfortunately doesn't mean it contained the proper JS. could be sending some HTML instead#2023-01-0909:40nivekuilyeah, looks like a bunch of JS, starting with SHADOW_ENV.evalLoad("shadow.modul...#2023-01-0909:41thhellerthat is not a release file#2023-01-0909:41nivekuiloops, you're right. one sec#2023-01-0909:41nivekuil
(function(){
shadow$provide[390]=function(ya,Ba,Ja,Ra){var qa=Ba(156);Ja.exports=function(){return qa.Date.now()}};
shadow$provide
#2023-01-0909:44nivekuillooks like it waits 5, then 20 secs between retries, then errors.. you'd think there would be some logging#2023-01-0909:45thhelleryeah the closure loader is not great when it comes to errors. usually there shouldn't be any though#2023-01-0909:45thhellercould be an error during load. try loading the files directly from the html if you can#2023-01-0909:45thhellerso just a html file that has the script tags for all the files in the correct order#2023-01-0909:49nivekuilgood call, making progress.
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
looks like there's a mistake in my routing+loading system somewhere as the error points to this line
$APP.$reitit$core$t_reitit$0core609782$$.prototype.$reitit$core$Router$routes$arity$1$ = $JSCompiler_unstubMethod$$(5, function() {
  return this.$routes$;
});
#2023-01-0909:50thhelleryuck not this again ...#2023-01-0909:50thhellerthis is getting annoying 😉#2023-01-0909:50thhellerset :compiler-options {:cross-chunk-method-motion false} in your build config#2023-01-0909:51nivekuilnice, you just saved me about three months of sleuthing#2023-01-0909:51nivekuilso.. what is that?#2023-01-0909:53thhellera very annoying issue related to reify in CLJS. https://clojure.atlassian.net/browse/CLJS-3207#2023-01-0914:50simonHi all, newbie here.. I'm getting following error when compiling with target :node-library, and just wanted to ask here in case it's due to a simple oversight on my part.. it seems that async_hooks is a node-core-module, do I have to treat core-modules in a special way to make them available?
The required JS dependency "async_hooks" is not available, it was required by "node_modules/raw-body/index.js"
#2023-01-0914:52thhelleruhm that error doesn't make sense. is this one of your files node_modules/raw-body/index.js? node-library doesn't process npm packages, so this weird#2023-01-0914:53thhelleror did you configure it specifically to bundle npm packages?#2023-01-0914:53thhellerand how did you require it? should be (:require ["async_hooks" :as x]), not (:require [async_hooks :as x]). ie a string not a symbol#2023-01-0915:06simonthanks for the quick response! I love shadow-cljs, awesome user experience!! 🔥 node_modules/raw-body/index.js is not one of my files, probably pulled in in my import of express (:require ["express" :as express])
The required JS dependency "async_hooks" is not available, it was required by "node_modules/raw-body/index.js".

Dependency Trace:
	shadow/umd_helper.cljs
	test/lambdas/checkout.cljs
	node_modules/express/index.js
	node_modules/express/lib/express.js
	node_modules/body-parser/index.js
	node_modules/body-parser/lib/types/json.js
	node_modules/body-parser/lib/read.js
	node_modules/raw-body/index.js

Searched for npm packages in:
	/Users/user/dev/checkout/node_modules
#2023-01-0915:12simoncould be a misunderstanding on my side how npm and node work, or shadow.. I think I've configured it based on your example of deploying a function to netlify
:stripe-checkout {:target :node-library
                    :output-to "landing/functions/checkout.js"
                    :exports {:handler test.lambdas.checkout/handler}
                    :js-options
                    {:js-provider :shadow
                     :keep-native-requires true}
                    :devtools
                    {:enabled false}}
#2023-01-0915:12thhellerwell yes, that configure it to make shadow-cljs bundle npm dependencies#2023-01-0915:13thhellerin that case you can add :keep-as-require #{"async_hooks"} to the :js-options map#2023-01-0915:14thhellernot you need to bundle everything in your case though#2023-01-0915:14thhellerits best if its not needed at all#2023-01-0915:16simonwoooow, thanks a lot, error is gone.. :star-struck:#2023-01-0915:16simonwhat is best if it's not needed at all? the bundling?#2023-01-0915:17thhellerdepends on the deployment. best to just let node load the dependencies, and just have shadow-cljs build the CLJS#2023-01-0915:17thhellerbut that requires that the runtime can load npm packages. some can, some can't. not sure what you are deploying to#2023-01-0915:20simonso you mean don't bundle any npm packages, because node will load them from node_modules? if I understood it right, that should work, because I'm deploying to netlify functions, and in the deployment it will install packages.json.#2023-01-0915:20thhelleryeah if the runtime can install npm packages its best to just remove :js-options from the config above#2023-01-0915:21thhellerbut also fine to leave it when it works. 😉#2023-01-0915:23simonhehehe, yeah, my usual approach.. I'll try it out though, makes sense#2023-01-0915:26simonthanks a lot for your help! 😌 brings a bit more light into the shadow 😄#2023-01-0916:44Sean HagstromIs it possible to create a release build for a npm-module target? I’m running into some issues when bundling the output with many errors like:
cljs-dist/cljs_env.js does not export 'Nf'
  > 1 | var window=global;var $CLJS=require("./cljs_env");require("./cljs_env.js");
  > 2 | 'use strict';$=require("react");module.exports=$;
  >   | 
And when I look at the cljs_env.js file, none of those fields exist. I’m using :advanced optimizations as well. Do I need to create some kind of externs file or something? It seems like the optimizations are removing those fields, but I’m not sure. Any ideas?
#2023-01-0917:05thhellerwhat does cljs-dist/cljs_env.js does not export 'Nf' mean? its not supposed to be exported? what is generating this error?#2023-01-0917:06thhellerin fact what is generating this source at all? this doesn't look like npm-module output?#2023-01-0917:06thhellerrequire("./cljs_env");require("./cljs_env.js"); why is that duplicated?#2023-01-0917:09Sean HagstromThat’s generated by running the release command with shadow using this config:
{:source-paths ["src"]
 :dependencies [[reagent "1.1.1"]]
 :builds {:app {:output-dir "./cljs-dist"
                :target :npm-module
                :entries [app.main]
                :release {:compiler-options {:optimizations :advanced}}}}}
#2023-01-0917:09Sean HagstromWhen I use :simple optimizations that duplication does not happen.#2023-01-0917:10Sean Hagstromcljs-dist/cljs_env.js does not export 'Nf' refers to some mangled name that is supposed to be exported on the global $CLJS object / module#2023-01-0917:11Sean HagstromBut for some reason those fields are removed after the release build finishes. And when I try to use a tool like Webpack (in this case Parcel), the JS bundler reports that error#2023-01-0918:34thhellerand what do you do in your code?#2023-01-0918:35thhellerremoving stuff is normal and expected. $=require("react"); $CLJS is the global object#2023-01-0918:35thhellerso that looks all exactly like its supposed to#2023-01-0918:35thhellerI'm missing what the actual problem is here?#2023-01-0918:35thhellerbesides an error message I do not recognize and must be coming from other 3rd party tools#2023-01-0918:38thhellermight just be a linter trying to lint :advanced optimized output?#2023-01-0918:38thhellerso the question is: what is generating cljs-dist/cljs_env.js does not export 'Nf'? the error message I mean. the code is fine from what I can tell?#2023-01-0918:51thhellerhmm nvm. the code is broken. cljs-dist/cljs_env.js requiring cljs_env is indeed a bug, that should not be#2023-01-0919:32thhellerapologies. that error message really confused me. should be fixed as of 2.20.18, a bad cljs_env.js file was indeed being generated.#2023-01-0919:32thhellernot sure that error message if fixed now though 😛#2023-01-0919:33Sean HagstromHaha no worries, I’m going to double check that the JS bundler is not doing something weird. If I keep running into the issue I’ll create a reproducible example to debug with you. Thank you for the help!#2023-01-1012:22StefanHi all, the latest release of shadow-cljs seems trigger some issue in our code base. We have a test target that is an npm-module with compiler options :compiler-options {:external-config {:guardrails {}} :closure-defines {goog.DEBUG true}}}. We use the target to run jest tests. Starting the latest release of shadow-cljs, when we run jest we get this error:
● Test suite failed to run

    Unable to resolve spec: :expound.spec/specs

      at Object.cljs$spec$alpha$the_spec [as the_spec] (test-out/cljs/spec/alpha.cljs:121:18)
      at Function.cljs.spec.alpha.spec_impl [as cljs$core$IFn$_invoke$arity$5] (test-out/cljs/spec/alpha.cljs:518:28)
      at Function.cljs.spec.alpha.spec_impl [as cljs$core$IFn$_invoke$arity$4] (test-out/cljs/spec/alpha.cljs:513:28)
      at Object.<anonymous> (test-out/expound/alpha.cljc:119:1)
      at Object.<anonymous> (test-out/com.fulcrologic.guardrails.core.js:10:1)
I noticed that there were changes in the last shadow-cljs release to the npm-module target, but I have no idea if this is a regression or us doing something wrong, and I'm not sure where to start looking... Any hints on getting to the bottom of this maybe?
#2023-01-1012:24thhellerhmm try :compiler-options {:cross-chunk-method-motion false} in the build config?#2023-01-1012:24thhellerwhich version did you use before?#2023-01-1012:24StefanTrying... (we're always on the latest, so it was 2.20.17 before)#2023-01-1012:25thhellerhmm but :target :npm-module was entirely broken for release builds for the last few versions?#2023-01-1012:26StefanWe're only using that target for our unit tests, so not in release mode I think.#2023-01-1012:27Stefan(We run shadow-cljs compile ... on that target)#2023-01-1012:28thhellerah ok#2023-01-1012:29StefanThat compiler option does not seem to fix the issue.#2023-01-1012:30thhellerhmm yeah I can reproduce the error. let me check whats going on#2023-01-1012:31StefanGreat, thank you Thomas!#2023-01-1012:53thhellershould be fixed in 2.20.19#2023-01-1012:54thhellernote that I also did a closure-compiler version bump in that release. in case you have pinned older version#2023-01-1012:54StefanWow, that's fast, thanks a lot; very grateful to you once again!#2023-01-1013:01thhellerweird that my test didn't catch this. was a pretty big issue what should have affected everything. guess I need to widen my test coverage 😉#2023-01-1013:02StefanI saw the delta of the commit that fixed it. I sometimes wonder how anyone can read clojure macros with all their quoting and unquoting. 🙂#2023-01-1013:03thhellerwell especially if you hack macros from other namespaces 😛#2023-01-1117:32pezCan I configure the nrepl server to bind to 0.0.0.0?#2023-01-1117:43dpsuttonhttps://shadow-cljs.github.io/docs/UsersGuide.html#http this seems to indicate you can use a host?#2023-01-1117:54pezThat's for the http server, right? Maybe ”indicate” is the key word there. 😃 Also, I added it to the :nrepl map and I think it works, because now I can connect! (I'm running the nrepl server in a docker container.)#2023-01-1117:54dpsuttonah right. but glad to hear its working out#2023-01-1120:26thhelleryes, :nrepl {:host "0.0.0.0"}#2023-01-1121:33eighttrigramshi, can anyone tell me if it is possible to change the default websocket port to 9631? cannot find anything to that effect.#2023-01-1121:42eighttrigramswant to be able to develop multiple instances of shadow-cljs apps at the same time on the same machine (more specifically inside the same docker-compose setup)#2023-01-1206:01thheller:http {:port 9631} in shadow-cljs.edn top level#2023-01-1221:30eighttrigramsPerfect, thanks @U05224H0W. I saw that setting somewhere but didn't realize that it was what i was looking for#2023-01-1305:44thhelleryeah, https://shadow-cljs.github.io/docs/UsersGuide.html#http#2023-01-1216:59pbailleHello everyone, I'm trying to execute some code in a build-hook (:compile-prepare stage) that need to know which namespaces will be recompiled, or at least which namespace has triggered the hot-reloading. I cannot find this information in the build-state that my hook receives. Does anyone has an idea ? thank you.#2023-01-1217:31thhellerdefine "execute some code"?#2023-01-1217:32pbailleI have to tweak expansion time state for some macros#2023-01-1217:33thhellerthat doesn't sound like a good idea?#2023-01-1217:35thhellerthe set of sources that will be recompiled you can get by inspecting :build-sources, which is a vector of resource-ids. if there is a corresponding (get-in build-state [:output resource-id]) it won't be recompiled. otherwise it will be#2023-01-1217:35pbaillemaybe 🙂 but I cannot think of an alternative, I've got an atom that hold some kind of environment to be used in expansions depending on the targetting platform.#2023-01-1217:35thhellerthat sound really bad 😛#2023-01-1217:35pbaillehaha but really fun#2023-01-1217:35thhellerif you want to expand on what you trying to do I can maybe make suggestions#2023-01-1217:36thhelleran atom is not tracked or restored with caching in mind#2023-01-1217:36thhellerso builds may become unpredictable with the state of the atom and cache in mind. unless of course you disable all caching, which again is really bad 😉#2023-01-1217:38pbailleYes disable caching entirely sound like a bad idea on the long run#2023-01-1217:38thhelleroh and you can get more information about the source that is getting recompiled via (get-in build-state [:sources resource-id])#2023-01-1217:38thhellerbut I repeat that any side-effected state during compilation is not a good idea 😉#2023-01-1217:39pbailleThe issue is on hot-reloading only#2023-01-1217:40pbailleYes but I cannot find a better way to do what I want for now. I will try to explain what I'm trying to achieve better in order for you to be able to do wise suggestions 🙂#2023-01-1217:47pbailleIt is a library that aims to let me define and implement protocols in a cross-platform way (clj and cljs) without reader conditionals. For being able to do this I need to keep track of which type implements which methods and things like this. It is clearly a bad idea but its almost done and I would like to fix this hot-reloading issue (on the first compilation everything works) .#2023-01-1217:49thhellerhmm but how do you track protocol implementations? I mean how would you "find" reify?#2023-01-1217:57pbailleI'm not tracking reified things and do not intend to do so, I do not track already existing protocols neither. When a new method is defined using one of my macro, I capture all informations in my expansion-time state. In addition to that, I store all "prototypes" in a runtime atom, that can be used to share method implementations. Its kind of baroque I agree but I works like I want for now.#2023-01-1218:04pbailleI think that the information that you gave to me will allow me do what I need, so thank you a lot !#2023-01-1220:30Sam Ritchiequestion - I’m writing a cljs macro and want to be able to reference something from box given
(:require ["mathbox-react" :as box]
            [reagent.core :as r])
#2023-01-1220:30Sam Ritchieis there a way to make a “fully qualified” symbol with a string namespace? I am not sure how to get the alias to resolve, since the macro is expanded on the clojure side#2023-01-1220:34thhellerits best to just make a wrapper function and call that from the macro. So in the CLJS part (defn get-me-the-thing [] box/foo) or whatever.#2023-01-1220:53Sam RitchieI am trying to build the core there from a symbol, like Group ; (def Group (reagent.core/adapt-react-class box/Group) , basically#2023-01-1220:54Sam Ritchieso I can write (defprim Group <some-map-that-I-will-turn-into-a-docstring>)#2023-01-1221:02Sam Ritchieoh, it’s easier to go the other way… (defprim box/Group ) and then strip off the namespace for the symbol I feed to def#2023-01-1301:49John GorskiHey all, would anyone know how to point shadow-cljs at a custom Maven Central endpoint? It https://github.com/thheller/shadow-cljs/commit/60d071ad968465ad69c2bef3ba64ff056ce09850#diff-98a9e994fbe4d455a070fa49c353effc038ec85f8647d32825e817e2f6004cc2R709 like it could be as easy as adding a config key to shadow-cljs.edn, but it doesn’t seem to be spelled out in the https://shadow-cljs.github.io/docs/UsersGuide.html.#2023-01-1305:43thhelleryeah, its the same config as in leiningen. :maven {:repositories {"foo" {:id "foo" :url ...}}}#2023-01-1322:09John GorskiMany many thanks, @U05224H0W. My local repository is not secured with TLS (it’s on a sandboxed build fleet), so cemeric.pomegranate.aether is rejecting it as both a Maven Central override and as a mirror. The https://github.com/technomancy/leiningen/blob/master/doc/FAQ.md has a “never-use” escape hatch for allowing non-TLS-protected repos/mirrors. Is this currently available via shadow-cljs?#2023-01-1512:01Itay DreyfusPerhaps an obvious question - I’m using the mapbox npm package, however on saving the page doesn’t render my component only when I evaluate it on the REPL, what’s the issue here?#2023-01-1512:20thheller"saving the page" I assume you mean saving the file?#2023-01-1512:20thhellerhttps://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html is the only thing I can link you to in general#2023-01-1512:20thhellerotherwise need more specific code examples. don't know what you are doing, so can't give specific answers#2023-01-1513:06Itay DreyfusSorry for being non informative enough 😉 Basically I render a map. When saving, hot reloading shows blank page, but evaluate the code on the REPL automatically renders the map on the page. My intializers are:
(defn home-page []
  [:<>
   [items-list]
   [map-container]])

;; -------------------------
;; Initialize app

(defn mount-root []
  (d/render [home-page] (.getElementById js/document "app")))

(defn ^:export init! []
  (mount-root))
#2023-01-1513:08Itay Dreyfusthe map components look like this:
(ns coffee-tlv.components.map-container
  (:require ["mapbox-gl" :as mapbox]))


(defn map-container []
  [:div#map])


(set!
  (.-accessToken mapbox)
  "pk.eyJ1IjoiaXRheWRyZSIsImEiOiJja2RlczU5bmIwcDlzMnducmVuMDQ4cWlyIn0.BSyB9nVoIsnazX2PeUyPyg")

(def tlv-map
  (new
    (.-Map mapbox)
    #js
    {:container "map",
     :style "",
     :center #js [34.79 32.07],
     :zoom 15}))
#2023-01-1517:31thhellerthis is not how you use non-react things with react/reagent#2023-01-1517:32thhellerlook up the docs for refs#2023-01-1517:33thhellerI created this example for pdfjs a while ago https://github.com/thheller/reagent-pdfjs#2023-01-1517:33thhellerits pretty much the same for mapbox#2023-01-1517:33thhellerthis being the important parts https://github.com/thheller/reagent-pdfjs/blob/master/src/main/demo/app.cljs#L19-L22#2023-01-1517:34thhelleralso see https://docs.mapbox.com/help/tutorials/use-mapbox-gl-js-with-react/#2023-01-1518:10Itay DreyfusTaking a look, thanks a lot!#2023-01-1517:16valtteriTrying to use the latest https://github.com/openlayers/openlayers from npm and getting many this kind of warnings with realease builds: > Resource: node_modules/ol/layer/Layer.js:111:20 > Parse error. name not recognized due to syntax error. .. and the release builds are thus broken. In dev-mode all is working well. I guess the error is coming from Closure and it has hard time processing OpenLayers javascript..? My shadow-cljs.edn looks like this:
{:lein     true
 :dev-http {3449 "resources/public"}
 :builds
 {:app
  {:target     :browser
   :asset-path "js/compiled"
   :output-dir "resources/public/js/compiled"
   :compiler-options
   {:infer-externs :auto}
   :dev
   {:closure-defines
    {re-frame.trace.trace-enabled? true}}
   :modules
   {:app
    {:init-fn lipas.ui.core/init}}
   :devtools
   {:after-load lipas.ui.core/mount-root
    :preloads   [devtools.preload
                 day8.re-frame-10x.preload]}}}}
#2023-01-1517:20valtteriJust tried :output-feature-set :es8 and that seems to get rid of the warnings. :thinking_face:#2023-01-1517:24valtteri..but bundle size is now 29MB 😄 It should be ~4-5MB#2023-01-1517:38valtteriArgh. After manually deleting all cached files and previously generated output I still get these warnings with output-feature-set :es8 . Does someone have advice what to try next?#2023-01-1517:50valtteriHa! Among the aforementioned warnings there was also a single extern problem that caused the release build to blow up. I guess those errors from Closure don’t matter 🤷#2023-01-1518:11valtteriOk, I did more methodological tests and following seems to be the case • “Parse error. name not recognized due to syntax error.” happens when outputting < :es8 • With :es8 I don’t see the errors and my build & app works ◦ I had an unrelated extern problem which I was able to fix Last question is that are there any known problems with es8 as output feature set? I mean other than “doesn’t work with IE11". 😉#2023-01-1518:13valtteriI checked from analytics and during past 3 months we’ve had one (1) IE11 visitor. Maybe the World is ready for es8..?#2023-01-1518:15valtteriAlso, thanks for shadow Thomas! I just migrated my main project from good old lein-figwheel + webpack and it’s been a joy to work with shadow. 🙏#2023-01-1518:22thhellernot sure what would cause this error but in the past the closure compiler had issues processing some @ directives in comment blocks. the files from OL seem to be full of them. I'm guessing it has some issues with this
/***
     * @type {LayerOnSignature<import("../events").EventsKey>}
     */
#2023-01-1518:23thhellerunsure how es8 is related to any of this though#2023-01-1518:24valtteriOh, interesting. Could be that my testing wasn’t methodological enough. 😅 I’ll try one more time with default :output-feature-set#2023-01-1518:25thhellerthe default is :es2020, so dunno why downgrading fixes anything 😛#2023-01-1518:26thhellerbut maybe it does something "more" that it otherwise doesn't#2023-01-1518:26valtteriAh 😄 Ok I had completely wrong assumption#2023-01-1518:26valtteriI thought it was ES5 or something#2023-01-1518:26valtteriBut I’m probably remembering how CLJS is complied through Closure#2023-01-1518:26thhelleres5 is the default in regular CLJS, not in shadow-cljs#2023-01-1518:27thhellerdoesn't feel right so use es5 in 2023 😛#2023-01-1518:27valtteriI see. 😄 I should maybe just RTFM#2023-01-1518:30thhellereverything compiles just fine for me importing ol/layer/Layer#2023-01-1518:30valtteriIn the docs there’s > By default the generated JS output will be compatible with ES6 and all “newer” features will be transpiled to compatible code using polyfills. probably outdated?#2023-01-1518:30thhelleryeah outdated#2023-01-1518:33valtteriI also upgraded shadow from 2.20.15 => 2.20.20 in the process. Dunno if this could explain some of the wierdness#2023-01-1518:33thhellerpossible. that included a new closure compiler version.#2023-01-1518:34valtteriAnyway, now it’s working and my code is running happily in production. 🙂 Thanks!#2023-01-1517:20valtteriJust tried :output-feature-set :es8 and that seems to get rid of the warnings. :thinking_face:#2023-01-1601:51fabraoHello, when I configure
:dev-http
 {8280 "resources/public"}
I have to use http://localhost:8280. Is there any way to configure the response with http://localhost:8280/somethig ?
#2023-01-1607:49thhellerwhat would it respond with? I mean it'll respond with the index.html contents by default?#2023-01-1610:41fabraoHello, I'd like to use something like http:://localhost:8280/app because I have all the time changing my index.html for local dev to <base href="/"> and for production <base href="/app/">#2023-01-1612:17thhellersorry I really do not understand what you are asking?#2023-01-1612:17thhellerjust create a resource/public/app/index.html if you want other html?#2023-01-1612:17thhelleror use your own server?#2023-01-1612:59fabraoI want to use shadow-cljs server but with different base path like http://localhost:8280/app and not http://localhost:8280/#2023-01-1613:01thhellerand I don't understand what the problem is? like what is not working now? what is stopping you from opening this url?#2023-01-1613:08fabraoI don't have problem, I just wondering if I could configure shadow-cljs like that.#2023-01-1614:35thhellerconfigure what?#2023-01-1614:35fabraoto shadow-cljs serve with this path -> http://localhost:8280/app#2023-01-1614:35thhellerI'm still completely lost and do not understand your question? the config you have above is fine. Just open http://localhost:8280/app? I don't get it#2023-01-1614:35thhellerIT ALREADY DOES!#2023-01-1614:36thhelleror what am I missing here?#2023-01-1614:36fabraooh, now I understand what you mean, but I don't want to create the resource/public/app folder#2023-01-1614:38thhellerok, I'm entirely lost. open http://localhost:8280/app with the config above. what do you get? what else do you expect?#2023-01-1614:39fabraolike this
:dev-http
 {8280 {:root "resources/public" :path "/app"}}
#2023-01-1614:39thhellerthat doesn't help me understand what problem you are trying to solve here#2023-01-1614:39thhellerI do not understand the question, so please help me understand what is currently not working#2023-01-1614:40fabrao:rolling_on_the_floor_laughing:, sorry about that#2023-01-1614:40thhellerYOU control the URL you open in the browser. so just open http://localhost:8280/app and be done with it? what is the thing I'm missing here?#2023-01-1614:46fabraoSorry about my "miss" explaining. In production enviroment is in reverse proxy with this this path . So, I have to use in index.html <base href="/app/"> to all the links works. Ok until now?#2023-01-1614:47thhellerso you are not actually asking about index.html. you are asking about additional assets like the .js files or images?#2023-01-1614:48thhelleror what does "all the links works" mean?#2023-01-1614:48fabraobut when I'm in local enviroment, I have to use index.html <base href="/">, to use with this config :dev-http {8280 "resource/public"}.#2023-01-1614:48thhellerso you are asking about assets. not the html?#2023-01-1614:49fabraolink work with <link rel="stylesheet" href="css/default.css" />#2023-01-1614:50thhellerok now we are getting somewhere. no this is not supported#2023-01-1614:50thhellerI thought you were asking about the html only, and didn't understand the problem.#2023-01-1614:52fabraono, with all assets. If shadow-cljs could serve the files with any path, I don't have to change the <base href="/app">#2023-01-1614:52thhellerbut it should be fine if you just create a symlink in resources/public#2023-01-1614:52thhellerso just ln -s resources/public/app resources/public?#2023-01-1614:53fabraoI can try to see if it will work#2023-01-1614:53fabraomany sorry taking your time like that, thank you#2023-01-1614:55fabraodidn't work#2023-01-1614:56thhellerhow are you deploying to production?#2023-01-1614:57fabraoonly change it to <base href="/app/"> and it works#2023-01-1614:57thhellernot what I asked#2023-01-1614:57thhellerhow do you actually deploy. do you build an uberjar? do you copy files?#2023-01-1614:57fabraocopy the files#2023-01-1614:58thhellerso why don't you just copy the files to the proper location?#2023-01-1614:58fabraoyes, I'll do it#2023-01-1713:22simonHi all, has anybody seen an error like that before?
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
java.util.Optional.isEmpty()Z
....
Caused by:NoSuchMethodError: java.util.Optional.isEmpty()Z
 	com.google.javascript.jscomp.StaticSuperPropReplacer.tryReplaceSuper (StaticSuperPropReplacer.java:102)
My first guess is that it's due to an incompatible java version. I remember I had a problem with the java version before, that's why I stick with 2.19.6 of shadow-cljs. Unfortunately this happens during the build on netlify, and before trying to reproduce or look further into it, I wanted to check if it's a known error.
#2023-01-1715:19thhellerhmm never seen that one before, but my guess is also java version#2023-01-1715:19thhellerneeds to be java11+#2023-01-1719:20simonOk, thank you! I’ll try to move the build to github actions then#2023-01-1719:38fabraoI don't know if I changed something in my project but , I could not see the source code of clojurescript in sources of browser#2023-01-1719:39fabraowhat parameter from compiler generate that?
:dev
   {:compiler-options
    {:output-feature-set :es2018
     :source-map         true
     :closure-defines    {goog.DEBUG true}}}
#2023-01-1719:39fabraosource-map?#2023-01-1719:54thhelleryes, source maps. but more likely if you messed with paths is that its now trying to load them from the incorrect path#2023-01-1719:55thhellerany errors/warnings in the browser console?#2023-01-1722:56fabraoYes, many#2023-01-1719:55thhelleryou don't need any of the compiler options above. those are all the defaults and repeating them does nothing#2023-01-1721:22wcalderipeI updated my CIDER version to 1.6.0, and since then, my REPL has stopped work with the following message:
WARNING: CIDER requires cider-nrepl to be fully functional. Some features will only be available with it! (More information)
I have cider-nrepl in my ~/.shadow-cljs/config.edn, and I can see it when I run $ yarn shadow-cljs classpath.
{:dependencies [[cider/cider-nrepl "0.29.0"]
                [refactor-nrepl "3.6.0"]
                [cider/piggieback "0.5.2"]]}
I've also tried downgrading CIDER from 1.6.0 to 1.5.0, 1.4.0, and 1.3.0, but none worked. Have anyone passed a similar situation?
#2023-01-1813:24thhellerI don't use cider so I can't give you any specific answers. But how did you start the JVM? Maybe it wasn't started by the shadow-cljs command? nothing else will read ~/.shadow-cljs/config.edn, so it may just be started differently.#2023-01-1909:39wcalderipeI'll narrow down the problem using shadow's quickstart template today and will come back with a solution. Thanks for the answer @U05224H0W#2023-01-2109:10wcalderipeJust sharing a solution after narrowing down the issue this week. For some reason, the cider-connect-clj&cljs stopped working after I bumped CIDER's version. The Emacs weren't sending commands to the REPL anymore, probably because of the warning below.
WARNING: CIDER 1.6.0 requires cider-nrepl 0.29.0, but you're currently using cider-nrepl 0.25.3. The version mismatch might break some functionality! (More information)
The project I'm working on was using yarn shadow-cljs watch :webapp :api to start the watchers, and everything worked fine before the bump. But now I have to explicitly say to shadow-cljs to inject CIDER's dependencies (like done under the hood by cider-jack-in-clj&-cljs.
yarn shadow-cljs \
         -d nrepl/nrepl:1.0.0 \
         -d cider/cider-nrepl:0.29.0 \
         -d refactor-nrepl/refactor-nrepl:3.6.0 \
         -d cider/piggieback:0.5.2 \
         watch :webapp :api
I'm happy it's working now, but I wonder what changed to force me to run watch with the dependencies. I thought that if I defined those packages in my ~/.shadow-cljs/config.edn, shadow-cljs would inject them automatically.
#2023-01-2109:42thhellerthey should be injected, but as I said only the shadow-cljs command will read that config file. so if you are using project.clj or deps.edn they won't be injected. you never shared your project config, so don't know if you are doing that#2023-01-2109:45wcalderipeWe're using shadow-cljs.edn. Here's the project and environment configuration files if you want to take a look https://gist.github.com/wcalderipe/f2279335bbcb3a8ad63cdd13e397cd67#2023-01-2109:47thhellerthat is fine. only other thing I can think of is the location of the config.edn file#2023-01-2109:47thhellerI added support for XDG_CONFIG_HOME, so if you have another shadow-cljs/config.edn file sitting there that is empty#2023-01-2109:47thhellerthen ~/.shadow-cljs/config.edn won't be used#2023-01-2109:48thhelleror LOCALAPPDATA in case your on windows#2023-01-2109:50wcalderipeThe config.edn is the only file in the direction. Also, the XDG_CONFIG_HOME variable is empty.
~/.shadow-cljs❯ pwd
/Users/wcalderipe/.shadow-cljs
~/.shadow-cljs❯ ls -la
total 8
drwxr-xr-x    3 wcalderipe  staff    96 May 10  2021 .
drwxr-xr-x+ 120 wcalderipe  staff  3840 Jan 21 10:48 ..
-rw-r--r--    1 wcalderipe  staff   131 Jan 19 19:03 config.edn
~/.shadow-cljs❯ echo $XDG_CONFIG_HOME
I can't find docs for XDG_CONFIG_HOME. Should I use it alongside the watch command like XDG_CONFIG_HOME=/another/config.edn yarn shadow-cljs watch :webapp?
#2023-01-2109:51thhellerhttps://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#2023-01-2109:51thhellerif its not set then ~/.shadow-cljs/config.edn should be the only file read#2023-01-2109:51thhelleryou should not set it manually no#2023-01-1821:29scarytomis there a reason why no compiler warnings are printed when I run npx shadow-cljs release app but plenty are when I run npx shadow-cljs compile app?#2023-01-1905:58thhellerdo you have an example? compile includes preloads and other development stuff, release does not. so if the warnings are in dev-only files they wouldn't show up in release.#2023-01-1908:51scarytomThe warnings are all of the WARNING #1 - :infer-warning type, and started showing up as a result of https://github.com/thheller/shadow-cljs/blob/master/CHANGELOG.md#22017---2023-01-04 to shadow-cljs. We have :compiler-options {:warnings-as-errors true} set on our :release but our CI system didn't fail as expected because the warnings are only showing up locally when we run shadow-cljs compile or watch#2023-01-1910:11thhellerhmm not sure why they wouldn't show up for release. there is no difference in how that is handled. what happens if you run release locally?#2023-01-1914:33thhellerdo you have examples for me? maybe the recent changes I did now show some invalid warnings?#2023-01-1916:14scarytomIf I run the release locally they do not show up either. I'm not sure how easily I can create a reproducible example of this... I'll try some things#2023-01-1916:25thhellercan you give an example of a warning? did you maybe just disable the warnings for release builds?#2023-01-1916:55scarytomthey are all :infer-warning from reagent/with-let as per https://github.com/reagent-project/reagent/issues/585#2023-01-1916:59thhellerah#2023-01-1917:04scarytomI have reproduced it with a vanilla sandpit shadow-cljs app now, so not to do with our setup.#2023-01-1917:04scarytomwould it be handy if i shared the git repo for the example?#2023-01-1917:04thhelleryes#2023-01-1917:04scarytomone sec whilst I commit and push it#2023-01-1917:11scarytomhttps://github.com/scarytom/shadow-sandpit#2023-01-1917:11scarytomthere you go. README demonstrates the issue#2023-01-1920:27thhellerthanks. figured out why it doesn't show for release. https://github.com/reagent-project/reagent/blob/master/src/reagent/ratom.clj#L59
#2023-01-1920:27thhellerin release builds *assert* is bound to false, so the code with the problem is never used#2023-01-1920:28thheller:compiler-options {:elide-asserts false} makes it show up, but you don't really want asserts in release build#2023-01-1920:37scarytomThat's a satisfying conclusion. Thanks for investigating.#2023-01-1920:39scarytomdo you have a feeling for the best way to get this issue with reagent fixed? I saw your comments on the GitHub issue, and I've volunteered to do a pull request... all these compiler warnings are irksome.#2023-01-1920:41thhellerwell I could revert the change I did which made them show up in the first place#2023-01-1920:41thhellerbut that would hide legit externs problems again#2023-01-1920:41thhellerunfortunately there is no easy way to detect "this was expanded by a library macro," type of thing I could use to disable the warning#2023-01-1920:42scarytomI don't think you should revert your change, it seems legitimate.#2023-01-1920:44scarytomover our entire codebase it is only this one reagent macro that causes an issue. There are bound to be some other similar problems elsewhere too, but they will all get fixed upstream eventually.#2023-01-1911:29andrewzhurovWhile watching compiler returns :infer-warning errors, I would assume setting :compiler-options {:warnings {:infer-warning false}} would communicate that these warnings are not to be shown, but, to my frustration, it doesn't work this way. :thinking_face: Is there a way to hide :infer-warnings? (Aside from fixing them 😄 They happen to be quite some) The build description is
:test {:target          :node-test
         :output-to       "static/tests.js"
         :closure-defines {frontend.util/NODETEST true}
         :devtools        {:enabled false :preloads [hashp.core]}
         ;; disable :static-fns to allow for with-redefs and repl development
         :compiler-options {:static-fns false
                            :warnings {:fn-deprecated false
                                       :redef false
                                       :infer-warning false}}
         :main            frontend.test.frontend-node-test-runner/main}
#2023-01-1913:48thhellerwell the ideal thing is to fix them#2023-01-1913:50thhelleryou can disable them via :compiler-options {:infer-externs false}, not inside :warnings. true also disables them. I know its weird. if you are sure you don't need any externs in an ns you can also do (set! *warn-on-infer* false) in the file after the ns#2023-01-1914:33thhellerdo you have some examples for me? maybe the recent changes I did now show too many warnings?#2023-01-2007:44andrewzhurovThank you for getting me a helping hand so quickly. 🙂 Disabling them via :compiler-options {:infer-externs false} works like a charm! Now when no infer warnings are shown it'll be super comfy to notice other kind of warnings (like :undeclared-var etc.) ^.^ (which show up before :infer-warnings), previously you'd need to scroll up through those 28 infer warns to get to them, which, interestingly, you get used to after a while and stop to notice 😄, but still I've been getting infer warnings while watching :testhttps://github.com/logseq/logseq/blob/9f18a707aa2f4704f7ab126e9a9c49ba9bc20ff6/shadow-cljs.edn#L70, via clj -M:test watch test, as suggested in https://github.com/logseq/logseq/blob/master/docs/dev-practices.md#focus-tests. Log's attached. Hope this can be of help. 🙂 And thanks again for the tip! A solid bump to devUX (Btw, I think it's a good thing that compiler thoroughly warns about infers, these warns are there for a reason, fixing them would be nice indeed)#2023-01-2007:46thhellerthose all look like legit warnings to me that should be properly fixed#2023-01-2007:46thhellerignoring them will inevitably lead to problems if you ever do a :advanced build#2023-01-2007:47thheller(fn [a b] (.multipliedBy a b)) just becomes (fn [^js a b] (.multipliedBy a b)) and the warning is gone#2023-01-2008:19andrewzhurovAh, and building without infers lead to a broken build (although I thought it would only break with :advanced, and here we've got :none , it seems, huh)
ReferenceError: js is not defined
    at /home/user1/gits/logseq/logseq/.shadow-cljs/builds/test/dev/out/cljs-runtime/malli.util.js:1834:1
    at global.SHADOW_IMPORT (/home/user1/gits/logseq/logseq/static/tests.js:64:44)
    at /home/user1/gits/logseq/logseq/static/tests.js:1764:1
    at Object.<anonymous> (/home/user1/gits/logseq/logseq/static/tests.js:2134:3)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Function.Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47
#2023-01-2008:51thhellerI very much doubt this has anything to do with externs inference#2023-01-2008:52thhellerdefinitely not for :none, as no externs are ever needed#2023-01-2008:52thhelleryou can set :infer-externs true, which will still do externs inference but never warn#2023-01-2018:39andrewzhurovthat makes sense, likely I messed up something in code, sorry for the confusion, compiling now with both :infer-externs set to true and false yields no warns and the build works alright#2023-01-2018:42andrewzhurovthanks for introducing to what :infer-externs true does, logic behind true false keywords clicked 🙂#2023-01-1915:35michihuberI can't seem to type-hint externs properly inside of go-blocks, in some cases. any idea?#2023-01-1915:35michihuber
------ WARNING #3 - :infer-warning ---------------------------------------------
 File: /Users/m/code/arcstudiopro/src/app/system/spellcheck.cljs:180:3
--------------------------------------------------------------------------------
 177 | ;;       (outbox [[:spellcheck/learned params]]))))
 178 | ;;
 179 | (defn learn [{:keys [!dict ^js FS] :as system} params outbox]
 180 |   (go
---------^----------------------------------------------------------------------
 Cannot infer target type in expression (. inst_10004 (appendFile inst_10024 inst_10025))
--------------------------------------------------------------------------------
 181 |     (let [^js FS+ (.-promises FS)
 182 |           ^js dict @!dict
 183 |           word (:word params)]
 184 |       (<p! (.add dict word))
--------------------------------------------------------------------------------
#2023-01-1915:36michihuber
(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
  (go
    (let [^js FS+ (.-promises FS)
          ^js dict @!dict
          word (:word params)]
      (<p! (.add dict word))
      (<p! (.appendFile FS+ (user-dic-path system) (str word "\n")))
      (outbox [[:spellcheck/learned params]]))))
#2023-01-1915:37michihuberoddly, dict can be inferred as externable, but FS+ can't? or am I misreading the situation?#2023-01-1915:38michihuberI tried moving the system destructuring inside the go-block, which didn't help#2023-01-1915:47thhellerhmm yeah typehints in go are dropped by go unfortunately#2023-01-1915:48thhellermay I suggest not using go in the above example at all? if all you do is await a promise then it is absolute overkill to do so#2023-01-1915:49thheller
(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
  (let [^js FS+ (.-promises FS)
        ^js dict @!dict
        word (:word params)]
    (-> (.add dict word)
        (.then #(.appendFile FS+ (user-dic-path system) (str word "\n")))
        (.then #(outbox [[:spellcheck/learned params]])))))
#2023-01-1915:49thhellerit'll also be like 1/100th of the generated code size 😉#2023-01-1915:50thheller.add just doesn't require externs while .appendFile does#2023-01-1916:29michihuberyeah, makes sense. I do have one other situation where awaits are chained, though. any workaround for go blocks in such situations, or just deal nested thens?#2023-01-1917:00thhellerI'd use https://clojureverse.org/t/promise-handling-in-cljs-using-js-await/8998 personally 😉#2023-01-1917:01thheller
(defn learn [{:keys [!dict ^js FS] :as system} params outbox]
  (let [^js FS+ (.-promises FS)
        ^js dict @!dict
        word (:word params)]
    (js-await [_ (.add dict word)]
      (js-await [_ (.appendFile FS+ (user-dic-path system) (str word "\n"))]
        (outbox [[:spellcheck/learned params]])))))
#2023-01-1917:02thhellernote that they are already chained above with .then, so not sure what you mean#2023-01-1919:18michihuberthanks!#2023-01-1919:51skylize> or just deal nested thens I think it might help to see Promises at work from the JavaScript side of things. Not totally clear if the phrase "nested then" even has any real meaning in JavaScript.
myPromise.then(x =>
  x.then(y =>
    y.then(z =>
      f(z))))
is fully equivalent to
myPromise.then(f)
because, as each intermediate Promise resolves, the result is automatically unfolded into any Promise that contains it. For the more complicated case, where additional work is done at each step, you still do not need to actively handle nesting levels.
myPromise.then(x =>
  transformX(x)
    .then(y =>
      transformY(y)
        .then(z =>
          transformZ(z))))
can be collapsed to the flatter and simpler
myPromise
  .then(transformX)
  .then(transformY)
  .then(transformZ)
without changing the behavior. With this flattened version, you could choose to replace any or all of the transform functions with a function returning a simple value instead of a Promise, with no notable impact. await is just syntactic sugar for forcefully sequential (i.e. not concurrent with other Promises in the same block) .then calls.
async function () {
  const x = await promise1
  const y = await promise2
  const z = await promise3
  return {x, y, z}
}
is strictly equivalent to
promise1.then(x =>
  promise2.then(y =>
    promise3.then(z =>
      {x, y, z})))
The nesting here comes from using closures as a simple way to capture values, because a Promise handler function only takes a single input. We could flatten out of the nesting by jumping through some hoops to pass each partial result through or around the next promise. If being less strict about sequential processing is okay, then this can also be considered equivalent to the await example,
Promise.all([promise1, promise2, promise3])
  .then(
    ([x, y, z]) => {x, y, z})
with probable improved performance due to letting the 3 input promises resolve concurrently (but still synchronizing the time factor before passing the combined result on to the next consumer).
#2023-01-1922:21rschmuklerIs there any way to overwrite arglists in a macro that produces a variadic function? Eg.
(defmacro my-defn
  [name bindings & body]
  `(defn ~name
     {:arglists '([~'z])}
     ~bindings
     
In Cljs:
(my-defn foo [x]
  (+ x x))
(:arglists (meta #'foo))
;; => '([z]) - works as expected

(my-defn foo-variadic [& xs]
  (apply + xs))
(:arglists (meta #'foo-variadic))
;; => '([& xs]) - incorrect!
#2023-01-1922:32rschmuklerLooks like https://clojure.atlassian.net/browse/CLJS-2351 might encompass it as well as the subsequent discussion in https://ask.clojure.org/index.php/6265/setting-arglists-metadata-when-vararg-is-present To answer @U05224H0W's question as to why it is useful... I have an https://github.com/teknql/plasma which exposes a macro that functions as a custom defn (`defhandler`). In clojure land it is basically just defn but in the front-end it packages up all the arguments into a vector and sends them to an API endpoint that calls the function on the backend and returns the results and wraps it in a JS promise. The function generated on the clojurescript side is variadic (easier to package up in the vector that performs the RPC) but since tooling (cider in this case) uses the :arglists for auto-completion / docs I would like to be able to keep the original version. I hadn't found the thread before I asked here so I'll look into a non-variadic way#2023-01-2004:56p-himikPlease don't cross-post. When you aren't sure where to post something, choose the most specific channel first. Given that you've provided more details in this particular thread and seem to have found a way forward, I'm removing your message in #C03S1L9DN.#2023-01-2007:50thheller#C07UQ678E would be the proper channel for this. this is not something I can do anything about from the shadow-cljs side, needs to be done in the CLJS compiler itself.#2023-01-2121:09Sam Ritchiehmm, this seems like a bug…
cljs.user> (sort [1  (js/BigInt. 2)])
Execution error (IllegalArgumentException) at shadow.build.cljs-hacks/eval117228$fn (cljs_hacks.cljc:981).
No matching clause: 
#2023-01-2200:58hifumi123js/BigInt isnt a constructor, try removing the dot. This will fail anyway since you can't compare BigInts to regular numbers#2023-01-2200:59hifumi123With shadow-cljs 2.20.20 and node.js 18.12.1:
cljs.user> (sort (vector 1 (js/BigInt 2)))

Execution error (Error) at (<cljs repl>:1).
Cannot compare 2 to 1
:repl/exception!
#2023-01-2201:05Sam RitchieYeah I was trying for the failure, so I could implement a better compare. It does work as a constructor by the way!#2023-01-2201:06Sam RitchieI’ve upgraded shadow… what was happening was my repl would break with that error and then never recover. So odd.#2023-01-2201:06Sam RitchieThanks for looking at it too!#2023-01-2121:10Sam Ritchiewith 2.17.4#2023-01-2212:01hifumi123Would it be possible to integrate something like webpack's style-loader into shadow-cljs or am I better served with using something like Garden? I ask because I'm dealing with a pesky React component that unfortunately wants to be passed an embedded stylesheet. For now my best guess would be to define a macro that simply slurps an external CSS file and I mimic the import "stylesheet.css" syntax by naming my macro something like import-css#2023-01-2212:19thhellerthere is no built-in support for this. and it is not possible to use style-loader directly, other than actually using webpack#2023-01-2212:21hifumi123Makes sense. For now I'm just going to stick with my macro idea. Hopefully React components dont mind being fed a gigantic CSS string 😄#2023-01-2212:51thhellerstyle-loader creates a JS object with classnames IIRC, so a string won't do#2023-01-2213:16hifumi123Oh yeah, React isn't happy with my provided styles being strings. Looks like I have to figure out something different... In any case, thanks for the help#2023-01-2213:58AkizHi, i am trying to run shadow-cljs via deps.edn 1. it means i dont have it install via npm, right? 2. i am getting this error when cider-jack-in-cljs
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: ------------------------------------------------------------------------------

   WARNING: shadow-cljs not installed in project.
   See 

------------------------------------------------------------------------------
shadow-cljs - config: /Users/akiz/Code/Clojure/hh/shadow-cljs.edn
shadow-cljs - starting via "clojure"
--- SHADOW-CLJS FAILED TO LOAD! ----------------------
#2023-01-2213:59AkizI made sure that i have got the exact version of dependencies from here: https://clojars.org/thheller/shadow-cljs This is the cause:
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Streams
	at com.google.javascript.jscomp.deps.ModuleLoader.createRootPaths(ModuleLoader.java:259)
	at com.google.javascript.jscomp.deps.ModuleLoader.<init>(ModuleLoader.java:154)
	at com.google.javascript.jscomp.deps.ModuleLoader$Builder.build(ModuleLoader.java:146)
	at com.google.javascript.jscomp.deps.ModuleLoader.<clinit>(ModuleLoader.java:414)
	at com.google.javascript.jscomp.DiagnosticGroups.<clinit>(DiagnosticGroups.java:178)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:167)
	at clojure.lang.Compiler$StaticMethodExpr.eval(Compiler.java:1743)
	... 211 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Streams
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 222 more
#2023-01-2214:02AkizI solved it by adding com.google.guava/guava {:mvn/version "31.1-jre"} to deps.edn#2023-01-2220:34thhellerit is still strongly recommended to install the npm package#2023-01-2222:11hifumi123Seconded. I've used shadow-cljs with leiningen in the past, but it was mostly to integrate existing projects tied together with lein-parent or lein-monolith. For standalone CLJS projects, using the NPM package saves you from tons of pain. There's absolutely no need for deps.edn or leiningen unless it's to integrate with an existing project of yours imo#2023-01-2306:51thhellerthat is not the reason to install the npm package and is not related to deps.edn or lein at all#2023-01-2306:51thhellerthe reason is just that the npm shadow-cljs package also brings in some other relavant npm packages you may need when using shadow-cljs builds#2023-01-2306:52thhellereg. the ws package when using node targets#2023-01-2306:53thhellerotherwise using shadow-cljs.edn to manage cljs dependencies, or deps.edn/project.clj doesn't really matter. other than sometimes having manual dependency conflicts#2023-01-2309:17AkizThanks. I can’t remember why I chose deps.edn this time. Does it have any advantage over using npm (except that I manage dependencies in one file)?#2023-01-2313:24thhellerit is absolutely fine to use deps.edn. the only difference is that you need to take care of dependency conflicts yourself. with shadow-cljs.edn the shadow-cljs tool can prevent some conflicts, so that is the advantage#2023-01-2313:25thhellerbut again this has absolutely nothing to do with the npm installed shadow-cljs package. that is a separate tool that I made the unfortunate choice to give it the same name#2023-01-2313:26thhellerconsider the npm shadow-cljs package toa ctually be shadow-cljs-cli. it only handles the shadow-cljs command line tool and nothing else. not related to CLJS compilation in any way#2023-01-2313:26thhellerdeps.edn has the advantage of supporting :local/root and :git/url dependencies, as well as being sort of the new standard#2023-01-2304:10hifumi123I'm trying to use webpack to handle dynamic imports, following https://github.com/aratare-jp/shadow-cljs-require/tree/solution But I'm getting this in my console
Uncaught TypeError: shadow.js.shim.module$create_react_class is not a function
Relevant parts of the shadow-cljs config:
{:target :browser
 :compiler-options {:output-feature-set :es6}
 :output-dir "public/js"
 :asset-path "js"
 ...
 :js-options {:js-provider    :external
              :external-index "target/index.js"}}
Then I invoke webpack with the following command:
npx webpack --entry ./target/index.js --output-path ./public/js --output-filename libs.js
My index.html has script tags ordered like so
<script src="/js/libs.js"></script>
<script src="/js/main.js"></script>
<script>shadow_cljs_require.core.init();</script>
Yet I get the TypeError above. Why?
#2023-01-2306:48hifumi123after closer inspection, it looks like my :asset-path is problematic and I wont be able to do much as a consequence of relative paths from URLs being unsupported#2023-01-2306:50thhellerwhat do you mean unsupported? they work just fine and would not cause the error above?#2023-01-2306:50thhellerare you sure main.js is the correct file? you elided the :modules? could be some old file sitting arround?#2023-01-2306:51hifumi123What I mean by relative to the URL is here https://github.com/thheller/shadow-cljs/blob/22c3f41f86a5ba4754eb774da9c03ec91043d897/src/main/shadow/boot/browser.js#L16#2023-01-2307:09hifumi123This is the structure dev tools in firefox are able to see. And nothing seems wrong with my HTML file. Interestingly, another webpack sample project that uses :target :npm-module works flawlessly on my machine, but using :js-provider :external hasnt been able to work#2023-01-2307:22thhellershadow.js.shim.module$create_react_class is not a function this error is NOT from the :js-provider :external build#2023-01-2307:23thhellerthats why I said you might have some old files around#2023-01-2307:23thhelleror maybe some bad cache#2023-01-2307:24hifumi123I see. I've just deleted all build artifacts and the .shadow-cljs folder. Hopefully this works#2023-01-2307:26thhellerI meant bad browser cache#2023-01-2307:30hifumi123Testing in a fresh copy of Chromium. Looks like Firefox does not provide this information whatsoever. This seems to point out the problem#2023-01-2307:33hifumi123Looking at the chunks webpack placed into public/js, I indeed don't see React anywhere in there. That probably explains my issue -- need to make webpack aware of the transitive React dependency (which I find strange because it's in my package-lock.json and node_modules folder)#2023-01-2307:43hifumi123Ok yeah it's definitely me not adding the necessary require() statements. I had to include e.g. (:require ["react" :as react]) in my core.cljs file so that the following can be emitted
ALL["create-react-class"] = require("create-react-class");
ALL["react"] = require("react");
ALL["react-dom"] = require("react-dom");
then running webpack once more produces a libs.js that contains everything core.cljs wants I would've never figured this out if you didn't tell me to ensure browser cache wasn't messing with my build 🙂
#2023-01-2309:04thhelleryou shouldn't need to add any requires? I mean if you use reagent or whatever it would already provide the react require?#2023-01-2309:23hifumi123Well, the version of reagent in the project I cloned is pretty outdated (0.8.0-rc1), and that version seems to want to use CLJSJS React instead of an NPM React#2023-01-2309:24hifumi123https://github.com/reagent-project/reagent/blob/v0.8.0-rc1/project.clj#L11-L12#2023-01-2309:54thhellerthat shouldn't matter#2023-01-2311:28pezI'm trying to use my webserver over SSL, which works, except that shadow does not want to connect. I've created a keystore and am adding this to the shadow-cljs command line --config-merge '{:ssl "docker/keystore.jks" :password "shadow"}', but it still fails and I get this error in the js console:
WebSocket connection to '' failed:
I'm guessing that it should be wss, but don't understand how to make it so. I note that the config merge seems to do something because when I add it, I get automatically redirected to https, from http, which does not happen without the merged config.
#2023-01-2314:21pezChanging the devtools-url to use https like so "https://localhost:9630", changes the error message to say that wss://, but there's no info about how it fails. Can I enable some verbosity somehow?#2023-01-2315:47pezSo, config-merge map is now {:ssl {:keystore "<path-to-keystore>" :password "shadow"}}, :face_palm: , but I still don't get it to work...#2023-01-2316:53pezOK. So it seems I can't add this via config-merge like that. If I move it to the shadow-cljs.edn file, it works.#2023-01-2317:28thhellercorrect, you cannot supply a :ssl config via config-merge.#2023-01-2317:29thhellerconfig-merge only merges into the build config, not global config#2023-01-2319:21pezI'd like to not enforce ssl on other devs on the project. Is there some other way I can achieve that?#2023-01-2319:36thhellernot currently no#2023-01-2410:03pezIt works fine accessing things without https still, I now notice. It was when I was using the config merge that it started redirecting me to https, :ssl <something> means something else in the build config.#2023-01-2410:17thheller:ssl has no meaning in --config-merge.#2023-01-2410:18thhellerif :devtools-url is set that is used. as-is. if not it tries to figure out which url to use from document.location in the client. it only uses ssl if ssl is configured in shadow-cljs#2023-01-2410:55pezYes, I meant that when I had misunderstood config merge, I tried to provide the ssl params that way, and it caused the browser to redirect http->https. So it means something, it seems.#2023-01-2412:38thhellerI very confident that :ssl has no effect in the build config, regardless of if coming from config direct or config-merge. but if you want to setup a repro I'll take a look.#2023-01-2413:06pezI'm pretty sure I was at that point a while, but I don't know how to repro it now.#2023-01-2317:01pezNext question. 😃 I'm accessing the app using my iPhone pointed at the network name for my machine. The app loads and works, but shadow tries to connect to localhost. How can I make it connect to the network name instead?#2023-01-2317:30thhellerby default shadow-cljs will try to connect to the document.location.host, so if it connects to localhost you either have configured it to do so via :devtools-url or :use-document-host false in the buidl config#2023-01-2317:30thhelleror you are not using :target :browser in the first place?#2023-01-2319:20pezYes! I had :devtools-url configured. Removing that fixes the issue. Thanks! 🙏#2023-01-2414:35rafaeldelboniHey hello, I'm trying to use a wasm compiled lib called https://github.com/jedisct1/libsodium.js and when compiling with shadow-cljs I'm getting this error in the thread. Here is the sample repo for reproduction: https://github.com/rafaeldelboni/libsodium-playground/ Does anybody has experience integrating with this lib?#2023-01-2414:36rafaeldelboniYou can see the full error log here: https://github.com/rafaeldelboni/libsodium-playground/actions/runs/3997095063/jobs/6857970174#2023-01-2414:37rafaeldelboniInteresting bits:
ExceptionInfo: failed to convert sources
...
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
...
Caused by:
StackOverflowError: 
	com.google.javascript.jscomp.DeadAssignmentsElimination.tryRemoveAssignment (DeadAssignmentsElimination.java:219)
#2023-01-2414:38thhellertry upgrading shadow-cljs, which also gives you a more current closure-compiler version#2023-01-2414:39thhellerthat could be enough#2023-01-2414:39rafaeldelboniI'm using "shadow-cljs": "2.20.20"#2023-01-2414:40rafaeldelboniYou can see in this run https://github.com/rafaeldelboni/libsodium-playground/actions/runs/3997255290/jobs/6858343826#2023-01-2414:44thhellerok, the task from above was 2.19.1#2023-01-2414:45rafaeldelboniYeah sorry I though updating shadow in a commit after I posted here.#2023-01-2414:53thhellerhmm I'm guessing it's related to the stack size again#2023-01-2414:54thhellersee https://github.com/thheller/shadow-cljs/issues/1015#2023-01-2414:55thhellertry :jvm-opts ["-Xss16m"] in shadow-cljs.edn#2023-01-2414:55thhelleror maybe more#2023-01-2414:58rafaeldelboniwoah that did the trick in my machine#2023-01-2414:58rafaeldelbonigonna commit to check in CI#2023-01-2415:06rafaeldelboniYeap is working now, thanks I would never thing about the stack size.#2023-01-2415:09thhellerits a weird and very rare error#2023-01-2415:09thhellerwas just a guess after running the libsodium.js file through the closure-compiler directly and that working 😛#2023-01-2414:39Rodrigo ManticaHello channel, I have a :node-test build which I run with shadow-cljs release. Sometimes I get an exit code 1 if an error occurs within the test source. However, when an async test times out or does not pass an assertion, the process exits gracefully. I would like to have a failure in these instances in order to stop my deployment process in CI. Any advice on how to achieve this?#2023-01-2415:08thhellerdo you properly handle async tests? easy to mess up async tests, so hard to give specific advice#2023-01-2415:13Rodrigo Mantica@U05224H0W I’m using react testing library which sometimes fails to find a dom node and thus times out. Not sure how to properly handle this situation with clojure test library :man-shrugging:#2023-01-2415:20thhellernot sure what you mean. do you call the async done callback when this timeout occurs?#2023-01-2415:32Rodrigo ManticaWell I wouldn’t want to do that. I want the process to exit with a failure in that scenario#2023-01-2415:32Rodrigo ManticaI’ll need to look into this a little closer and come back with more testing#2023-01-2417:20thhellerI'd need to see some code to give any more specifics#2023-01-2421:28ingesolHi! I have a build :app with :target :browser. It has an alternate module directory called lib in addition to node_modules , configured like
:js-package-dirs ["node_modules"
                   "lib"]
Now I added a new build with :target :npm-module. I added the same js-package-dirs config there. This build will not compile because it cannot find the modules inside lib. Is this supposed to work with npm-module target?
#2023-01-2421:32thhellerwhat does "will not compile" mean? npm-module normally doesn't bundle JS dependencies so it shouldn't even matter#2023-01-2421:33ingesolHuh, sorry I think I may be barking up the wrong tree here. This is part of a Storybook setup, and the error message I’m seeing could be from some of the JS build parts. They obviously don’t know about my lib folder. I picked up some advice you gave elsewhere about just npm install the modules I need from my lib folder, that actually worked.#2023-01-2421:54hifumi123how do I set up SSL with dev-http? I'm trying a map like
:dev-http
{8080 {:host ""
       :ssl-port 8081}}
but it's not working. I'm using shadow-cljs' default SSL config, and the shadow-cljs server listening on port 9630 is using HTTPS. So I know it's not an SSL error
#2023-01-2421:54thhellerthat config is missing a :root, and with :ssl properly configured just :dev-http {8080 "public"} should use ssl#2023-01-2422:47hifumi123Thanks! That fixed my problems#2023-01-2611:42hifumi123Is there something like shadow.html/copy-file that supports binary files? Learned the hard way that PNGs can't be copied this way 😄#2023-01-2612:08thhellerno, why would there be? just put it into the proper place from the start#2023-01-2613:35hifumi123my specific cases involves an isolated project with a very rigid structure (and location of build artifacts) due to a tool im using making lots of strong assumptions on project layout in order to work#2023-01-2613:36hifumi123while I usually keep files in their final place in e.g. public, in this case they'd have to be in a build folder, so in the end i used webpack plugins#2023-01-2700:52dvingoHi, I have a bit of an out there request/idea.. So malli supports emitting clj-kondo configs for function schemas (https://github.com/metosin/malli#clj-kondo) which will write the config to the proper kondo location on the filesystem. I would like to get this to work for clojurescript function schemas as well. The issue is that the schemas can include Vars which must be resolved at runtime by a JS vm, which also means we don't (directly) have access to the filesystem (this is for browser targets). Right now the not so good solution is to just give the user a console.log of the kondo config and ask them to paste the contents into the kondo config file. So... I'm wondering if there is a way to use the shadow.cljs.devtools.client API (or another, I'm not sure) in the browser combined with a custom websocket event handler that will pass the kondo config, which is just data, to the shadow clojure process which can then write it to the filesystem. The goal would be to include this as an optional addon for malli users so they can get kondo static analysis in clojurescript files. Thanks!#2023-01-2707:42thhelleryou can technically use shadow.remote to talk to the runtime directly#2023-01-2707:42thhellerso you could create an external tool that also connects to shadow.remote and then gets the data#2023-01-2707:43thhellerhttps://github.com/thheller/shadow-cljs/blob/master/doc/remote.md#2023-01-2707:43thhellernot many docs on this subject though#2023-01-2707:43thhellerright now only websocket is supported#2023-01-2707:44thhellerbut every remote interaction shadow-cljs does is done over shadow.remote and its all accessible to anyone, this includes REPL, hot-reload, etc#2023-01-2716:39dvingovery nice, thanks for the info. I'll try to figure out how to go about it based on the shadow codebase.#2023-01-2717:17thhellerI added an example client in CLJ https://github.com/thheller/shadow-cljs/blob/master/src/dev/shadow/remote_example_ws.clj#2023-01-2717:18thhellerjust like :clj-eval there is :cljs-eval, just need to find the correct :to via :request-clients https://github.com/thheller/shadow-cljs/blob/master/src/dev/shadow/remote_example_ws.clj#L155#2023-01-2717:18thhellerso you could either do it on top of eval#2023-01-2717:19thhelleror implement some client side code, but given that it'll be mostly macro driven I guess eval is required either way#2023-01-2717:41thhellerif you know the runtime id you can also just use shadow.cljs.devtools.api/cljs-eval#2023-01-2717:53dvingoamazing, thanks for the example - I was going down the route of trying to use runtime.shared/add-extension with a new op like :write-malli-config. I don't think there's any macros involved. After your suggestion to do instrumentation at runtime I refactored it to do so https://github.com/metosin/malli/blob/master/src/malli/instrument.cljs . so at runtime all the schema data is available and a simple data transform is run on it and then printed: https://github.com/metosin/malli/blob/master/src/malli/clj_kondo.cljc#L208 So my hope was I could do something like
(shadow.remote.runtime.shared/call @runtime-ref 
  {:op :write-malli-config :data kondo-config})
and then have a listener on the clj side to simply write to file
#2023-01-2718:46dvingook so I have it working with the method I was thinking, I just guessed at a few pieces, but the communication is happening clj side, loaded by including this ns in a shadow build hook:
(defmethod worker/do-relay-msg ::write-kondo-config
  [worker-state msg]
  (println "Got kondo config" msg)
  worker-state)
cljs side:
(shared/call
    (deref client-shared/runtime-ref)
    {:op ::write-kondo-config
     :to env/worker-client-id
     :data (get-kondo-config)}
    {})
#2023-01-2719:01thheller(shadow.cljs.devtools.api/cljs-eval :the-build "(whatever.ns/get-kondo-config)") and then write the result to disk?#2023-01-2719:20dvingooh man, that's so cool, ha - yea that's perfect! I can put that in a compile finish hook and I think that's it! Thanks Thomas#2023-01-2721:18dvingoit's working fairly well, but there is an off-by-one problem/non-determinism at play with hot-reload. The hook I have runs on :flush and then invokes cljs-eval but sometimes the data returned contains the old values from the previous compilation. So I think the cljs-eval is happening before the latest code is loaded. Ideally I wouldn't have to update the cljs side of things and could do this all from the build hook, so was wondering if there is a way to determine if the latest code was loaded in the client and not only written to disk.#2023-01-2909:18thhellerwell the server side implementation does not synchronize with the client side. it just sends messages#2023-01-2919:48dvingogot it, I just used a simple counter on the client side and busy loop until it gets increment on the jvm side to know when the code is loaded. Thanks again for the help!#2023-01-2920:25thhellerI'm still not sure what you are doing, do you have code to share?#2023-01-2920:59dvingooh haha, yea this is what I got working: https://github.com/metosin/malli/pull/829#2023-01-3016:42dvingoMalli has a feature that takes a function schema and converts it to equivalent clj-kondo config and writes that to the kondo config directory. We want the same capability in cljs but the constraints are: • we need to evaluate the cljs code because the schemas may contains Vars which can only be resolved at runtime • once we have the output of the schemas-> clj-kondo config we need to persist it to the filesystem so given those constraints I realized that shadow-cljs is already doing this communication and can we utilize that somehow? and that's how I landed on this solution Hope that helps clarify what the goal is.#2023-01-3017:02thhellerand where or how do you generate it for CLJ?#2023-01-3017:58dvingoin CLJ: • all schemas are collected and then transformed to kondo config and then saved to disk that happens here: https://github.com/metosin/malli/blob/cfbc8eaa05bedb1e7e7b132d52bbf2e61b143f92/src/malli/dev.clj#L35#2023-01-3018:01thhellerso this is done once on start?#2023-01-3018:02dvingoand then again via that watch on the https://github.com/metosin/malli/blob/cfbc8eaa05bedb1e7e7b132d52bbf2e61b143f92/src/malli/dev.clj#L32 so as you dev and change any function schemas the new kondo config is output#2023-01-3018:08thhelleras far I can tell you already have the preload ns calling instrument! right?#2023-01-3018:09thhellerthen your previous attempt might be better?#2023-01-3018:09thhellerie. the (defmethod worker/do-relay-msg ::write-kondo-config [worker-state msg]... )#2023-01-3018:10thhellerand in the preload ns (defn ^:dev/after-load kondo-transfer! [] (whatever-to-send-message-to-relay))#2023-01-3018:10thhellerthen you don't need a hook at all#2023-01-3018:11dvingoand that do-relay-msg would be in the malli clojure codebase?#2023-01-3018:12thhellercould be yeah. in the preload ns you could ensure its loaded via :require-macros [malli.shadow-helper]#2023-01-3018:14dvingoI see - I think that would work! from the user's perspective they would then only need to add the preload. And users not using shadow, would be unaffected by this#2023-01-3018:16thhelleryep#2023-01-3018:16thhelleror could just remove that part of the code#2023-01-3018:17thhellerI also have a late-cljs feature in a branch for a couple months now#2023-01-3018:17thhellerwhich basically just lets you annotate a ns to be compiled last#2023-01-3018:17thhellerwhich would be perfect for this 😛#2023-01-3018:17thhellersince you could just make the preload part of mall, without needing to add all the requires#2023-01-3018:18dvingoyesss! that was my next question - how to make this a library only concern and not need the user to deal with it#2023-01-3018:19dvingoif (defn ^:dev/after-load kondo-transfer! [] (whatever-to-send-message-to-relay)) this lives in the library in a ns that cannot include the user's code, will it always run after the user's code?#2023-01-3018:21thhellerwell it runs after all code is loaded which is enough right?#2023-01-3018:22thhellerbut not sure if the instrument! call is relevant?#2023-01-3018:22thhellernvm. that also executes before after-load#2023-01-3018:25dvingofrom a user's point of view they're using ! in an after-load hook and that is where the latest schemas are picked up after hot reload. So this kondo preload would have to run after that, which I'm not sure about the order of multiple after-load hooks#2023-01-3018:25thhellerI thought they are using the preload ns only?#2023-01-3018:26thhellerthe order is somewhat unreliable, it should be in dependency order but isn't guaranteed to be#2023-01-3018:26dvingo"the preload ns only" meaning the one in the library?#2023-01-3018:26dvingoand not their own?#2023-01-3018:27thhellerwhy is (md/start!) not in the preload?#2023-01-3018:27dvingothe idea is that a user will call ! however they like - could be in a preload but doesn't have to be - it also takes an options map which we want to make visible to the user#2023-01-3018:27thhellerI don't really know how any of this works, so I'm just guessing what parts do#2023-01-3018:29thhellerI assume the goal should be to keep malli.dev.cljs out of the build entirely for release#2023-01-3018:29thhellerso best way to achieve that would be the preload?#2023-01-3018:30thheller
(ns com.my-org.client.preload
  {:dev/always true}
  (:require
    [] ;; must require all namespace here that potentially get instrumented
    [my.app.util]
    [malli.dev.cljs :as md]
    [malli.dev.shadow-hooks]
    [malli.instrument :as mi]))

(mi/instrument!)
(md/start!)
#2023-01-3018:30thhellersomething like that?#2023-01-3018:30dvingoyea agreed there - I think we're saying there is a preload ns the library provides which will deal with the kondo transmission, but the user will have to provide their own separate preload to include the namespaces in their app to ensure the preload runs last#2023-01-3018:31thhelleryes, right now#2023-01-3018:31dvingojust need the start:
(ns com.my-org.client.preload
  {:dev/always true}
  (:require
    [] ;; must require all namespace here that potentially get instrumented
    [my.app.util]
    [malli.dev.cljs :as md]
    [malli.dev.shadow-hooks]
    [malli.instrument :as mi]))

(defn {:dev/after-load} dev []
   (md/start!))
#2023-01-3018:31thheller
(ns malli.dev.shadow-instrument
  {:shadow.build/late-cljs true
   :dev/always true}
  (:require
    [malli.dev.cljs :as md]
    [malli.dev.shadow-hooks]
    [malli.instrument :as mi]))

(mi/instrument!)
(md/start!)
#2023-01-3018:31thhellerif I ever add the late-cljs part 😉#2023-01-3018:32thhelleralthough for your case that isn't even relevant much#2023-01-3018:32dvingobut looking at this I think another option is to tell the user to just invoke this call:
(ns com.my-org.client.preload
  {:dev/always true}
  (:require
    [] ;; must require all namespace here that potentially get instrumented
    [my.app.util]
    [malli.dev.cljs :as md]
    [malli.dev.shadow-hooks]
    [malli.instrument :as mi]))

(defn {:dev/after-load} dev []
    (md/start!)
    (malli.shadow-kondo/emit!))
#2023-01-3018:32thhellersince you don't do stuff in macros anymore right?#2023-01-3018:33dvingothe schema collection is still in a macro#2023-01-3018:33dvingowhich does need to get the latest code#2023-01-3018:33thhellerok so the instrument! is the macro?#2023-01-3018:34dvingoemits something like:
(malli/collect [long list of all namespaces])
(malli/instrument!)
#2023-01-3018:34dvingothe instrument is all in js#2023-01-3018:34thhellerthat is confusing. what emits the collect?#2023-01-3018:35dvingohttps://github.com/metosin/malli/blob/cfbc8eaa05bedb1e7e7b132d52bbf2e61b143f92/src/malli/dev/cljs.cljc#L35#2023-01-3018:35dvingoso the user-facing api is just !#2023-01-3018:36thhellerso the start is the macro#2023-01-3018:36thhellerwhy is the instrument! call in the preload then?#2023-01-3018:36dvingoyea#2023-01-3018:36thhelleror is that just old docs?#2023-01-3018:37dvingoprobably old docs - is that in their now?#2023-01-3018:37thhellerI looked at the PR link you sent#2023-01-3018:37dvingohmm, let me double check#2023-01-3018:38dvingoooh yea sorry I overlooked that, that is incorrect#2023-01-3018:39thhelleryeah, I'd recommend to move the start! into the preload#2023-01-3018:39dvingoright that's what that should say#2023-01-3018:39dvingoand inside a function with dev/ater-load right?#2023-01-3018:39thheller
(ns user.app.shadow-instrument-preload
  {:dev/always true}
  (:require
    []
    [malli.dev.cljs :as md]
    [malli.dev.shadow-hooks]
    ))

(md/start!)
#2023-01-3018:39thhellerno#2023-01-3018:39thhellerlike that#2023-01-3018:40thhellerthe :dev/after-load hook lives in .shadow-hooks#2023-01-3018:40thhellernot required for the user to define it#2023-01-3018:40thhelleruser code otherwise doesn't contain anything#2023-01-3018:40dvingoi see#2023-01-3018:40thhellerunless I'm missing something that should be enough#2023-01-3018:41dvingoi think so - if this runs after their latest code changes that should work#2023-01-3018:42thhellerthats what the [] will ensure#2023-01-3018:43thhellerif thats the :init-fn ns it will ensure that the preload is actually compiled after those#2023-01-3018:43thhellerpreload is a bad name, doesn't mean its actually preloaded just injected into the build#2023-01-3018:43thhellerhttps://github.com/metosin/malli/blob/master/docs/clojurescript-function-instrumentation.md#releaes-builds#2023-01-3018:44thhelleralso none of this is needed then#2023-01-3018:44dvingogot it - ok yea that should work then. and then the malli side can be a preload like you suggested#2023-01-3018:44dvingoyea I updated the docs with that PR to suggest the preload strategy first#2023-01-3018:44thhellerand fwiw could have shortened without all the CLJ code#2023-01-3018:45dvingoyea, if you know a way around that that'd be awesome to know#2023-01-3018:45thheller
{:main
 {:target :browser
  :output-dir "resources/public/js/main"
  :asset-path "js/main"
  :dev {:modules {:main {:init-fn com.my-org.client.entry/init}}}
  :release {:modules {:main {:init-fn com.my-org.client.release-entry/init}}
            :build-options {:ns-aliases
                            {malli.dev.cljs malli.dev.cljs-noop
                             com.my-org.client.malli-registry com.my-org.client.malli-registry-release}}}
  :closure-defines {malli.registry/type "custom"}
 ,,,
#2023-01-3018:45dvingonice!#2023-01-3018:45dvingodidn't know you can change the init-fn for release#2023-01-3018:46thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration#2023-01-3018:46thhellercan override anything, only trouble is vectors since they just append not replace#2023-01-3018:46thhellerbut init-fn just replaces#2023-01-3018:47thhellerbut this entire switching becomes unnecessary with the preload calling start#2023-01-3018:47thhellersince none of the dev code is included by the user code, only the build config#2023-01-3018:47dvingoexactly - thanks for the info on that#2023-01-3018:49dvingothis is really helpful. I'll try out the setup you suggested using the multi-method and clean up those docs. I really appreciate the help on this.#2023-01-2719:19Sam Ritchieis there a way to trigger an npm install for cljs dependencies from shadow.cljs.devtools.api/watch? or maybe from (shadow.cljs.devtools.server/start!)?#2023-01-2721:29Sam Ritchie
(npm-deps/main {} {})
got the job done!
#2023-01-2814:15Clojuri0an(def root (. js/document -getElementById "root"))#2023-01-2814:16Clojuri0anTypeError: fexpr__12271 is undefined#2023-01-2814:16Clojuri0anHALP#2023-01-2814:18Clojuri0anaa#2023-01-2814:18Clojuri0an;#2023-01-2814:18Clojuri0an;#2023-01-2814:26thhellercontext? version? build config? repl?#2023-01-2814:39Clojuri0annot relevant#2023-01-2814:39Clojuri0anbut figured out issue#2023-01-2814:39Clojuri0anwrong syntax should have been (def root-div (.getElementById js/document "root"))#2023-01-2814:44Clojuri0anhow to pass multiple parameters#2023-01-2814:44Clojuri0an(.render mithril/m root-div "hi")#2023-01-2814:44Clojuri0anoriginal is
m.render(root-div, "Hello world")
#2023-01-2814:44thhellerthat would be correct#2023-01-2814:45thhellerassuming m is equal to mithril/m#2023-01-2814:45thhellerlooks a bit suspicious#2023-01-2814:46Clojuri0anye#2023-01-2814:46Clojuri0anthat's mistaken should not have both#2023-01-2814:46Clojuri0anm is just mithril should be mithril/render#2023-01-2814:48Clojuri0anw00t#2023-01-2814:48Clojuri0angot it running#2023-01-2814:48Clojuri0anmithril with clojurescript is kino#2023-01-2815:27Clojuri0anHow to call m("h1", "header")?#2023-01-2815:27Clojuri0anm("h1" "header") doesn't seem to work#2023-01-2815:27thheller(m "h1" "header")#2023-01-2815:28Clojuri0anw00t ty#2023-01-2815:35Clojuri0an(m/render (.body js/document) (m "h1" "my epic win") (m "h2" "test") (m "button" "an epic button")))#2023-01-2815:35Clojuri0anwhycome TypeError: document.body is not a function#2023-01-2815:37Clojuri0anI understand conceptually that I'm calling function instead of getting object but idk how to get object#2023-01-2815:38Clojuri0anI don't think aget is what supposed to use#2023-01-2815:43Clojuri0an(. js/document -body) return nil#2023-01-2815:46Clojuri0anDOM element being rendered to does not exist.#2023-01-2816:00Clojuri0anw00ty#2023-01-2816:00Clojuri0anfigured it out I think desu#2023-01-2816:00Clojuri0anone moment plz#2023-01-2816:08Clojuri0anWriting a hook(?) works DOM needs to load first Not sure if this is a bloated solution?
(ns 
  (:require [mithril :as m]))



(defn render-content []
  (println "test rendering")
  (println(. js/document -body))
  (m/render (. js/document -body)
            (m "h1" "my epic header")))


(defn init []
  ;; tests
  (println "hello world")
  ;; renders
  (.addEventListener js/document "DOMContentLoaded" render-content))
#2023-01-2816:10Clojuri0anHow to represent something of the form
m("main", [
    m("h1", {class: "title"}, "My first app"),
    m("button", "A button"),
])
(array []?)
#2023-01-2816:16Clojuri0anhmm something of the form
(defn render-content []
  (println "test rendering")
  (println(. js/document -body))
  (m/render (. js/document -body) (m "h1" "test"
            (m "h1" "my epic header")
            (m "h2" "my epic subheader"))))
works but idk why
#2023-01-2816:28Clojuri0an(m "h1" #js {:class "test"} "my epic header") and #js needed to communicate its json object and not a map (just in case this helps anyone ^^#2023-01-2902:21Sam Ritchie@thheller any thoughts on including the shadow-cljs npm dependency under src/deps.cljs in the clojure library version of shadow? I noticed when I ran (npm-deps/main {} {}) that it complained that I didn’t have shadow’s npm dep installed…#2023-01-2908:04thhellerI consider the deps.cljs method to be full of flaws#2023-01-2908:05thhelleruhm and what "complaint" are you talking about?#2023-01-2908:06thhellerthe "not installed in project" warning only exists when running via the shadow-cljs command?#2023-01-2914:52Sam RitchieI’ll get more info for you once family settles down, but @thheller I’m working on a namespace that will let users trigger a shadow build, and dependency download, without a shadow-cljs.edn or package.json . This is for Clerk, if someone wants to use a cljs library they need to rebuild the JS that Clerk uses, and I want that (for new users) to happen transparently; so new JS gets built behind the scenes and swapped into Clerk’s html#2023-01-2908:16Clojuri0anAnyone know why I can't get this to render?
[12:15 AM] (let my-pictures #js {:view (fn [] (        
       (m "main" #js {:class "container"}
         (m "article"
            (m "h1" #js {:role "button"} "My Name")
            (m "h2" "My Pictures")))))})
                             

(defn render-content []
  (println "test rendering")
  (println my-pictures)
  (println(. js/document -body))
  (m/mount (. js/document -body) my-pictures))


(defn init []
  (.addEventListener js/document "DOMContentLoaded" render-content))
[12:16 AM] TypeError: fexpr__12320.call is not a function at line
(let my-pictures #js {:view (fn [] (
Seems I'm calling the function incorrectly
#2023-01-2908:27thhellerplease avoid cross posting multiple channels#2023-01-2908:31Clojuri0anok#2023-01-3002:13Drew VerleeWill a app re-compile rerun any clj macros that were used to build the intial app state? I'm running into a sitution where i have values that from a previous state that i'm trying to understand.#2023-01-3006:27thhellernot if its cached. if you have macros that have side effects you might need to disable cache completely. macros are not supposed to have side effects. https://shadow-cljs.github.io/docs/UsersGuide.html#_compiler_cache#2023-01-3017:51Drew VerleeThanks heller. Those docs help, and yes, i assume we have macros with side effects.#2023-01-3005:22hifumi123I would say it depends on what files actually changed. If you have a bunch of macros in a util namespace and never change that namespace, then it wont be refreshed. So in that case I can understand the previous state you’re speaking of. If I wanted to make namespaces forcibly refresh every time, I would add the ^:dev/always metadata to them#2023-01-3012:51AndreaHello shadowians, I’m trying to compile a project which has https://www.npmjs.com/package/squint-cljs as an NPM dependency, and I’m getting the following error when starting the dev build
shadow-cljs - watching build :viewer
[:viewer] Configuring build.
-> build target: :esm stage: :configure
<- build target: :esm stage: :configure (2 ms)
[:viewer] Compiling ...
-> Resolving Module: :viewer
<- Resolving Module: :viewer (1293 ms)
-> build target: :esm stage: :compile-prepare
<- build target: :esm stage: :compile-prepare (5 ms)
-> Closure JS Cache read: 101 JS files
<- Closure JS Cache read: 101 JS files (21 ms)
-> Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js 
<- Babel transform: /Users/amantini/dev/clerk-blank/node_modules/squint-cljs/core.js  (394 ms)
-> Shadow JS converting 1 JS sources
<- Shadow JS converting 1 JS sources (551 ms)
[:viewer] Build failure:
Closure compilation failed with 1 errors
--- node_modules/squint-cljs/core.js:625
Transpilation of 'Computed fields' is not yet implemented.
The offending code seems indeed to be:
export const IIterable = Symbol('Iterable');
...
class LazyIterable {
  constructor(gen) {
    this.gen = gen;
  }
  [IIterable] = true;
  [Symbol.iterator]() {
    return this.gen();
  }
}
https://github.com/squint-cljs/squint/blob/c50c4c2582aeda9e874a867e19a2bfcfc9e4caab/core.js#L452-L460 Does anyone have also encountered this issue before? Couldn’t find much around closure compiler and computed fields or properties. Both targets :browser and :esm produce the same issue, changing :output-feature-set to different ES levels also has no effect
#2023-01-3012:51Andreacc @U04V15CAJ#2023-01-3012:52borkdudeWhy does closure need to transpile anything if it's already es6?#2023-01-3012:53Andreayeah, that’s also a good question#2023-01-3012:53thhelleruhm do not do this?#2023-01-3012:54thhelleroh nvm. thought for a sec it was trying to compile the squint cljs output#2023-01-3012:54thhellerupdate shadow-cljs I guess?#2023-01-3012:54AndreaI’m on 2.20.20#2023-01-3012:55thhellerhmm ok. then I guess it doesn't work#2023-01-3012:57Andrea> to compile the squint cljs output yeah, that is what I origninally tried to do, and the squint output has imports to squint-cljs/core.js which produces the error above#2023-01-3012:57thhellerdo not ever include the output of a compiled CLJS lib via JS#2023-01-3012:58thhellerthat will only bring trouble and nightmares#2023-01-3012:58borkdudesquint produces normal JS, not CLJS#2023-01-3012:58borkdudeeverything is "just es6" - imo closure should be able to handle this#2023-01-3012:59thhellerbut the squint-cljs lib contains compiled CLJS code#2023-01-3012:59Andreaalso, why is babel transform pass kicking in, also for the :esm target? What is the transformation doing?#2023-01-3012:59borkdude@U05224H0W That is true, but squint-cljs/core.js is pure es6#2023-01-3013:00thhellerok#2023-01-3013:00thhellerwell the error is pretty clear. it uses code the closure compiler doesn't support#2023-01-3013:01thhellerso there is nothing to do, except NOT having it process this code#2023-01-3013:01thhellerwhich you do via :js-provider :import for :esm builds#2023-01-3013:07Andreaah ok, @U04V15CAJ I see you do that as well here: https://github.com/squint-cljs/squint/blob/c50c4c2582aeda9e874a867e19a2bfcfc9e4caab/shadow-cljs.edn#L4-L5 how would I make squint core functions available to the browser? According to: https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration I need some extra tool to process shadow output#2023-01-3013:08borkdude@U9EQP1K0X You could use another bundler on the final output, e.g. esbuild or so#2023-01-3013:09borkdude
npx esbuild public/main.js --bundle --minify --platform=browser --outfile=public/main2.js --format=esm
#2023-01-3013:09borkdudesomething like this#2023-01-3013:11borkdudeor for dev builds, include squint-cljs core.js yourself in the HTML#2023-01-3013:11borkdudeHere is a playground which also does that: https://squint-cljs.github.io/squint/#2023-01-3013:11borkdude
<script async src=""></script>
    <script type="importmap">
      {
        "imports": {
          "squint-cljs": "",
          "squint-cljs/core.js": "",
          "squint-cljs/string.js": ""
        }
      }
    </script>
#2023-01-3013:13Andreacool thanks, now I’m using shadow to compile other NPM dependencies together with real cljs sources in the same project, how can I make :js-provider selective to just squint-cljs/core? Is that :resolve https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve?#2023-01-3013:14borkdudeIf I remember correctly, you can also use:
:js-options {:keep-as-import #{"fs"}}
#2023-01-3013:15borkdude(replace fs with squint-cljs/core.js)#2023-01-3013:15Andreaah cool#2023-01-3013:15borkdudeor perhaps this is deprecated @U05224H0W? I don't see this option mentioned in the README#2023-01-3013:21thhellerstill exists yeah#2023-01-3013:26Andreaehm, with
:keep-as-import #{"squint-cljs/core.js"}
in :js-options I still get the transpile error
#2023-01-3013:34thhellerare you importing that file specifically?#2023-01-3013:34thhellerit is really difficult to make any kind of suggestions without seeing any code#2023-01-3013:35thheller:keep-as-import #{"squint-cljs"}#2023-01-3013:35thhelleror whatever you are requiring in your code#2023-01-3013:35borkdude@U9EQP1K0X Perhaps you can make a tiny repro repository#2023-01-3013:35thhellerlike the exact name#2023-01-3013:36Andreayeah, I think I can go a bit further, and produce a repro repo if I am still stuck. Thanks a lot @U05224H0W @U04V15CAJ !#2023-01-3016:51borkdude@U05224H0W Is there a way to run a tool like webpack or esbuild after shadow is done compiling in watch mode, to resolve the "keep-as-import" imports? Because the browser still needs to have those files. We could use import-maps for those and then serve those files manually, but that's also a bit tedious#2023-01-3016:56thhellerno, that is not supported#2023-01-3019:02borkdude@U9EQP1K0X figured it out by calling esbuild in a build hook#2023-01-3016:46martinklepschIs there a way to insert a “preamble” of sorts into node REPL sessions? I find it quite interruptive to have the node-repl die just because of an unhandledRejection and usually run a snippet like the one below to avoid this. Is there a way to configure this at a project level?
(js/process.on "unhandledRejection"
                 (fn [err]
                   (js/console.log "unhandledRejection" err)
                   (tap> {:unhandledRejection err})))
#2023-01-3016:56thhellerif its a build repl you can just put it into a ns an :preloads it?#2023-01-3017:50martinklepschAh yes, that works perfectly. I somehow assumed preloads wouldn’t be a thing with node but I’m realizing I didn’t think about that very much otherwise I would have realized they probably work just the same 🙂#2023-01-3017:52martinklepschI find this unhandledRejection stuff sufficiently annoying that I’d love for it to be part of the shadow node repl by default somehow. I think it might also be quite confusing for newcomers because some REPL clients don’t report it very well when the underlying node process dies.#2023-01-3017:56thhellerthe trouble with this is that is can happen anywhere#2023-01-3017:57thhellerso also in REPL internals, which may end up causing a infinite exception loop and burn your CPU to death 😛#2023-01-3017:57thhellerso I'd rather not#2023-01-3017:58martinklepschAh I see#2023-01-3017:58martinklepschCould the REPL catch errors of any promises that are coming through? (i.e. more explicit)#2023-01-3017:59thhellernot sure. having looked at many node internals for many years#2023-01-3017:59thhellerthere might be better hooks nowadays#2023-01-3018:00martinklepschI mean more like it looks at whatever the user’s expression returns and adds a .catch -- probably I’m thinking too simplistic here 🙂#2023-01-3018:02thhellernot sure thats a good idea#2023-01-3115:38skylize> not sure thats a good idea Assuming the mechanics are viable and the exception is still reported, I'm not sure how this could be super-harmful. It could be on-by-default in dev mode, with a preamble to the reported error that "if this was production mode, your Node process would crash here." Using tap> seems a bit iffy though, since then the problem goes unreported if there is no tap reporter is set up. Maybe default to just print, but allow switching to tap> in the config?#2023-01-3115:39martinklepschyeah totally, tap> is specific to my setup #2023-01-3108:13HankstenbergGood morning, does anybody know how shadow-cljs figures out which JDK to use? It's pointing to an no longer existing version on my disk and it doesn't seem to be the alias or JAVA_HOME.#2023-01-3108:15thhellerit doesn't figure anything. it executes java, whereever that leads is up to your system#2023-01-3108:16HankstenbergAh you're right... it must be vscode then.#2023-01-3108:17thhellerI guess you can check via node -e "require('which').sync('java')" in the project dir#2023-01-3108:17thhellershould be equiv to which java or whereis java or whatever OS command you ahve#2023-01-3108:19HankstenbergGot it, thank you 🙂#2023-01-3109:25pezI always start VS Code from a terminal where the environment is what I want it to be. Starting apps from the GUI has a tendency to start them in some weird environment.#2023-01-3113:43pmooserWhat does this mean - does it indicate a syntax error, or a missing resource?
[2023-01-31 14:41:59.327 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@automerge/automerge-wasm/nodejs/automerge_wasm.js", :requires [{:line 4, :column 37}]}
#2023-01-3114:01pmooserI'm trying to read this to understand a little better: https://github.com/thheller/wasm-pack-cljs#2023-01-3114:25pmooserWhat I'm trying to do is migrate to the new automerge 2.0 project: https://automerge.org/blog/automerge-2/#2023-01-3116:43thhellerfor some reason they use
const { TextDecoder, TextEncoder } = require(`util`);
#2023-01-3116:43thhellerso backtick instead of quote#2023-01-3116:43thhellerthis is not currently supported I guess#2023-01-3116:44thhelleryou can open a ticket for what, that is fixable#2023-01-3116:44thhellerhowever I'm less optimistic about the wasm working 😉#2023-01-3116:45thheller
const path = require('path').join(__dirname, 'automerge_wasm_bg.wasm');
#2023-01-3116:45thhellerwill definitely 100% not work in the browser#2023-01-3116:46thhellerI give that package a 0% chance of working with shadow-cljs 😉#2023-01-3116:46thhellermaybe if you go through webpack via https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2023-01-3117:23pmooser@thheller Thank you so much for your detailed response! I will take a look at that webpack thing ... is it possible to use it just for one library?#2023-01-3117:32thhellernope, all or nothing#2023-01-3117:32pmooserOk, that is indeed how it appeared from the web page.#2023-02-0111:33pmooser@thheller So if we use the :external js provider like that, is it still possible somehow to use shadow-cljs for interactive development (like with hot reloading and stuff)? Because if I understand the order of operations correctly, first we invoke shadow-cljs, which generates a js file, which then we feed into webpack, and then we have our index.html load both files ...#2023-02-0111:33pmooserIs the idea that if I don't change the js requirements often, we don't actually have to do the webpack step very often, and we can just sort of use shadow-cljs like normal?#2023-02-0111:34thhelleryes, the only part that changes is that you can't dynamically change JS dependencies#2023-02-0111:35thhellerotherwise hot-reload works as before#2023-02-0111:36pmooserOk. I'm learning this stuff very slowly and I will give it a try. Is there any hope for more seamless support for WASM eventually, or is that really just dependent on the dust settling in the WASM ecosystem?#2023-02-0111:37thhellereventually when there is a standard for this yes#2023-02-0111:37thhellerright now every wasm lib seems to do its own weird non-standard stuff#2023-02-0111:37thhellermost are specifically tailored for webpack#2023-02-0111:37pmooserOk, that seems very reasonable.#2023-02-0111:37pmooserThank you!#2023-02-0112:24pmooser@thheller I sort of got it working (the build with webpack), but even after getting it to load the wasm and stuff, I seemingly can't resolve anything in the automerge package itself. Any further suggestions for debugging?#2023-02-0112:36pmooserI suppose the concrete issues I'm seeing are not being able to use anything from automerge (like calling Automerge/init doesn't work - it can't find it), but also I think something about the build related to my inclusion of io.github.nextjournal/markdown didn't work, because I get this error upon loading:#2023-02-0112:54thhellerthis is not an error you would get from a :js-provider :external build#2023-02-0112:55thhellerso I suspect you might be loading some outdated files. might be cache, might just be outdated files when you changed filenames or something#2023-02-0116:45pmooserOk, thanks - I will try clearing out everything and seeing if that helps.#2023-02-0116:49pmooserNo, I get exactly the same issue and error. I'm wondering if maybe some js or something is bundled in the nextjournal markdown project which is then somehow not visible to webpack.#2023-02-0116:49pmooserAll I am doing in terms of procedure is a shadow-cljs compile of my build, and then npx webpack (with a suitable config just telling it what to read from and where to write to) ...#2023-02-0116:53thhellerwithout seeing configs/code I cannot say much#2023-02-0116:54pmooserYeah. I am going to try to see if I can make it work with bare cljs, just to have some info from that perspective, with a new barebones project that just pulls in Automerge 2. If I manage to make THAT work, maybe I'll bug you about shadow-cljs.#2023-02-0116:56thhellerI'm happy to take a look at a repro that is failing, just need something to look at :P#2023-02-0116:56pmooserThank you very much for that - my company won't let me share what I am doing directly, but maybe I can make a simple repro case.#2023-01-3117:50souenzzoI'm using shadow-cljs with :js-options :resolve:
"user-gql-query" {:target :global :global "UserGqlQuery"}
"all-gql-queries" {:target :file
                   :file   "dist/all_gql_queries_bundle.js"}
My all_gql_queries_bundle is generated from a JS file that does import * as UserGqlQuery "user.gql" window.UserGqlQuery = UserGqlQuery and uses webpack to "compile" gql files into js files. my cljs namespace imports both "all-gql-queries" and "user-gql-query" when the namespace tries to load, it fails with shadow-cljs - failed to load module$users_gql_queries Inspecting the browser, I am able to access window.UserGqlQuery without issues (it returns the value that I expect) but shadow$provide returns an empty object. then shadow$provide.module$users_gql_queries returns undefined.
#2023-01-3119:30thheller:target :file is really not recommended. neither is the :resolve config#2023-01-3119:30thhellerbetter to use :js-package-dirs ["node-modules" "your-modules"] in the build config#2023-01-3119:31thhellerthen have your webpack output go to your-modules/all-gql-queries/index.js#2023-01-3119:31thhellerbut be careful with running secondary bundlers, it may lead to duplicated packages#2023-01-3119:32thhellerI don't know why you have the global stuff#2023-01-3119:33thhellerjust use js/UserGqlQuery?#2023-01-3121:01souenzzo> but be careful with running secondary bundlers, it may lead to duplicated packages this is just for import .gql files directly into JS bundle Tomorrow I will try to access the globals directly. Maybe even add the external script src= and leave the cljs build way cleaner.#2023-01-3121:06thhellerI don't know what .gql files are, but webpack in the process of bundling them might include npm dependencies#2023-01-3121:06thhellerthat shadow-cljs may not see and maybe import again#2023-01-3121:22souenzzoGraphQL query files#2023-01-3121:23thhellerI guessed as much#2023-01-3120:05Sam Ritchie@thheller any thoughts on checking peerDependencies in addition to the other two here? https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/npm_deps.clj#L157-L159#2023-01-3120:14Sam RitchieI had a project where I included something from src/deps.cljs in peerDependencies, and found that shadow would try to install it every time. The problem was that the npm install call that shadow issued would destroy any npm link calls I had run, to get npm to look at local versions of one of the dependencies I was working on#2023-01-3120:25thhelleruhm aren't peerdependencies only relevant in libraries?#2023-01-3120:25thhellerI don't even know what npm link is, so no idea about that#2023-01-3120:25Sam Ritchiesame with devDependencies, right?#2023-01-3120:25thhellerI'm not really understanding your question I guess#2023-01-3120:26Sam Ritchie@thheller you use npm link when you have an npm dependency like mathbox, and you want to develop against local copy of it#2023-01-3120:26Sam RitchieI was working a library that declared mathbox as a peerDependency#2023-01-3120:27thhellerdoesn't peer dependency just mean "don't install it" when you run npm install?#2023-01-3120:27Sam Ritchieit means “required but you bring your own version”#2023-01-3120:27Sam Ritchieit actually DOES install by default#2023-01-3120:27Sam Ritchiewait, sorry, let me be clear#2023-01-3120:28Sam Ritchieif I declare a peerDependency in my own project, it is definitely installed. if someone then depends on me, npm install actually WILL install my declared peerDependencies; but usually it’s like a JVM “provided” dependency. It means “consumers have to have SOME version of this but I want to force you to declare it on your own”#2023-01-3120:29Sam Ritchie“npm link” replaces the node_modules entry of a library with a symlink to a local path. the problem is that shadow-cljs is calling npm install inappopriately, since its is-installed? filter is not catching things I have in peerDependencies; and that npm install call blows away my npm link symlinks#2023-01-3120:31thhellerso why do any of this at all?#2023-01-3120:31Sam Ritchie?#2023-01-3120:31Sam Ritchiesay more#2023-01-3120:31thhellerI'm still seriously considering removing npm-deps install thing entirely#2023-01-3120:31thhellerit has been nothing but trouble 😛#2023-01-3120:31thhelleryou can set :npm-deps {:install false} in shadow-cljs.edn#2023-01-3120:31Sam Ritchiethen how do I ship libraries like https://mafs.mentat.org/, https://jsxgraph.mentat.org/ etc…#2023-01-3120:32thhellerthen it won't do anything 😛#2023-01-3120:32Sam RitchieI want it to install dependencies!#2023-01-3120:32Sam RitchieI just want it to realize that I’ve already installed stuff in peerDependencies#2023-01-3120:33Sam Ritchieit’s great, I think it would be a sad experience to have to tell users to manually install the npm deps my libraries are building on, especially multiple levels deep; users shouldn’t be manually resolving dependency trees#2023-01-3120:33thhellerbut shipping libraries is entirely different from developing libraries#2023-01-3120:33Sam RitchieI develop, then I ship…#2023-01-3120:33thhellerso you during development can skip the automated install entirely, especially if you are doing npm link and whatever#2023-01-3120:33thhellerthe end user can still install everything normally, without any of your custom things going on?#2023-01-3120:33Sam Ritchieah, I see what you’re saying#2023-01-3120:34thhellerI mean I'm fine with adding peerDependencies in the lookup stuff#2023-01-3120:35thhellerbut doesn't seem like that would totally prevent this from accidentally nuking your custom setups#2023-01-3120:35Sam Ritchieyeah, you’re right that it would still nuke them the first time, until the deps.cljs entries had made it into package.json#2023-01-3120:35Sam Ritchieso this is good to know for sure#2023-01-3120:36thhellerbut you are a developer of a library, should not be dependent of transfering your OWN npm dependencies out of deps.cljs if you ask me#2023-01-3120:36thhelleryou should manage and maintain your own package.json#2023-01-3120:36thhellerand more importantly your own lock files#2023-01-3120:36thhellerincluding keeping them in git#2023-01-3120:36thhellerwhat the end user gets is entirely different story if you ask me#2023-01-3120:37thhellerI even go so far as having an entirely separate package.json file for published packages#2023-01-3120:39Sam Ritchie> but you are a developer of a library, should not be dependent of transfering your OWN npm dependencies out of deps.cljs if you ask me I agree but this happens automatically if you include a src/deps.cljs in your classpath#2023-01-3120:39thhellerthen don't include it 😛#2023-01-3120:39Sam Ritchiehttps://github.com/mentat-collective/JSXGraph.cljs/blob/main/shadow-cljs.edn#L1#2023-01-3120:39Sam Ritchieit comes in via my :deps dependencies#2023-01-3120:41Sam RitchieI’m not sure what problem I solve by excluding it? I basically don’t want to care at all about npm after declaring the dep, so it actually feels like the right thing to do to get my deps in via deps.cljs#2023-01-3120:41Sam Ritchiewhat if I forget to add something new to it, or update a version#2023-01-3120:43Sam RitchieI mean I totally trust you that deps.cljs is causing trouble, you’re the expert here… maybe I’m too used to the status quo to imagine other solutions#2023-01-3120:47thhellerdoes this work with regular cljs?#2023-01-3120:47thhellerhttps://github.com/mentat-collective/Mafs.cljs/blob/main/src/mafs.cljs#L1-L3#2023-01-3120:47thhellerie. having a cljs namespace including a npm package of the same name?#2023-01-3120:47thhellerit doesn't right?#2023-01-3120:47thhellershadow-cljs has a special case where a string always only refers to JS requires#2023-01-3120:48thhellerin regular CLJS (:require ["clojure.string" :as x]) is valid, which I consider a bug#2023-01-3120:51thhellerbut I'd assume that the ["mafs" :as m] is treated as a self-require and would error out?#2023-01-3120:55thhelleralso single segment namespaces in cljs are kind of problematic, so not recommended#2023-01-3120:59Sam Ritchiesorry looking now#2023-01-3120:59Sam Ritchie@thheller I had asked here a while ago and it sounded like it was supported; `“mafs” here is an npm dependency#2023-01-3120:59Sam Ritchie@thheller I should probably rename the cljs namespace mafs.core#2023-01-3121:00Sam Ritchie> but I’d assume that the ["mafs" :as m] is treated as a self-require and would error out? I have only tried it with shadow, where it works fine… I should get a proper vanilla build going#2023-01-3121:01thhellerI mean if you are care just mafs is fine#2023-01-3121:01thhellerbut I don't think the regular CLJS build process will like that#2023-01-3121:02Sam Ritchieyeah, you’re probably right. I should change it and folks can always alias#2023-02-0209:23LycheeseIn my init-fn I try to disable logging like this:
(ns app.entry
  (:require
   [app.core :as core]))

(defn init []
  (js/console.log "Initializing app!")

  ;; (when-not ^boolean js/goog.DEBUG)
  (set! *print-fn* (fn [& _]))

  (js/console.log "This shouldn't appear.")

  ,,,,)
But it never works. It does if I eval the set! call manually though. Any ideas on what might be causing this?
#2023-02-0209:26thhellerjs/console.log is not related to printing in any way. that is a browser feature.#2023-02-0209:27thhellerthat is to say js/console.log is not affected by *print-fn*, prn or others use *print-fn* which defaults to using js/console.log#2023-02-0209:27thheller(js/console.log "This shouldn't appear.") so this will always appear#2023-02-0209:27thheller(println "This shouldn't appear.") won't#2023-02-0209:29LycheeseOoooooh. That makes sense. So I should replace every call to js/console.log with println?#2023-02-0209:30Lycheese~Wait but then that doesn't appear in the browser console. Hmmm.~ Not println but prn facepalm Ah. (set! js/console.log (fn [& _])) does the trick#2023-02-0209:32LycheeseThanks 🙂#2023-02-0218:12Drew VerleeMy goal is to have the same level of stack trace information in shadow development mode locally as i get from the logrocket (a screen capture service). I uploaded my source maps to them, and it now i'm getting almost the ideal set of information. See in LR, the stacktrace tells me the file where the issue happened (see screenshot): js/cljs-runtime/centriq_web.admin.js:428 but in my local browser i get the location in the cljs file, which is way better. e.g (admin.cljs:579:36). Is there a way in general to do this? My understanding is that we compile cljs to js to minified js, the source map is for the second compile step. Are people able to trace it all the way back to the first one?#2023-02-0218:19thhellerI'm not sure I understand your question?#2023-02-0218:19thhellersource maps map JS code back to CLJS, that is correct#2023-02-0218:19thhellerthey are generated during compilation#2023-02-0218:20thhellerby default they are disabled for release builds, you can enable them by setting :compiler-options {:source-map true}#2023-02-0218:20thhellerI'm not quite sure what the point of logrocket for development is?#2023-02-0218:22Drew Verleelogrocket is pointless for local development on my computer. It captures user sessions in production. If the encounter a js error, without further information (source maps) for us, the error it gives us is compressed js. I attempted to give LR source maps according to there instructions, and now it tells me the JS file where the error happened, but i'm hoping i can get it to tell me the cljs file and line number.#2023-02-0218:23thhellerwhich source map did you give them? since the above is at most from a development build?#2023-02-0218:23thhellerit is not from a release build. I assume you are not serving your users development builds?#2023-02-0218:24Drew Verlee> it is not from a release build. I assume you are not serving your users development builds? I'm not. I did a release then uploaded that source map. then i started my shadow server locally and LR is tracking that session. Likely i need to do a release, upload that, then run that release locally.#2023-02-0218:25thhellerI'm still lost how this all fits together#2023-02-0218:25thheller> then i started my shadow server locally and LR is tracking that session.#2023-02-0218:25thhellerhmm?#2023-02-0218:25thhellerwhy is LR involved in development?#2023-02-0218:26thhelleryou generate a release build. it generates a matching .map file, that ONLY matches that JS output.#2023-02-0218:26thhellerif you run any other JS, it won't match and give you now proper results#2023-02-0218:26thhellerso then running the dev build locally against those maps is pointless#2023-02-0218:26thhellerso I'm still unsure what you are trying to do exactly#2023-02-0218:32Drew VerleeThanks for the help. This largely isn't a shadow question. I was more asking if people using error reporting tools for production apps were able to get those tools to report the exact line the error happened at in the original cljs file. If everyone said no then i would assume there was some huge obstacle there. What i want is to log into logrocket, view a production user session, and if they had a js error, have log rocket tell me where in the cljs file the issue happened. If you don't upload sourcemaps, what it tells you is the location in the js minified file, because thats all it has. In my attempt to develop on this feature, i'm trying to use a locally running version of the app on my computer. LR has no probably tracking that session, just like i can track any session. I think my mistake is thinking the release build would be identical to what the shadow server build was producing. I should just run the release locally and see if its working as expected. The alternative is that i configure LR, upload the assets, and wait for a staging build. That has like a 15 minute turn around time. so if for some reason the configuration is wrong, it takes a long time to adjust.#2023-02-0218:33thhellerwhat you can and should do is version your javascript#2023-02-0218:33thhelleryou have several option to do that https://shadow-cljs.github.io/docs/UsersGuide.html#_cacheable_output#2023-02-0218:34thhellerand you need the EXACT output of the exact build, not a different build. the same map and matching JS file#2023-02-0218:34thhelleryes, you cannot just run release locally again. that will give you a different build#2023-02-0218:34thhellerif you version it from the beginning you'll have an easier time figuring out which JS caused the problem#2023-02-0218:34thhellerand then just download it yourself and use it#2023-02-0218:35thhellerdo not do a rebuild#2023-02-0218:36thhellerso you'll have a + #2023-02-0218:37thhellerif the files match you should get proper traces#2023-02-0218:40Drew Verleethat makes sense, I think your right that would be necessary for this to work properly. If done correct, is it possible to get the same error report we get locally from an error that happened to a user using the minified release?#2023-02-0218:42thhellerI don't know what you mean by that#2023-02-0218:42thhellerif you use the same files you get the same error#2023-02-0218:42thhellerif you figure out what it was in the first place 😛#2023-02-0218:45Drew VerleeLet me try to explain again, this is useful for me because its possible i'm barking up the wrong tree. Logrocket downloads the js file from a user session that we have allowed it to track, If an js error happened in that session, LR will show where in the js file it downloaded that error was. In a minified file that looks like this:
adow$provide[0]=function(T,I,ia,ha){var E=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;ia.exports=function(){try{if(!Object.assign)return!1;var h=new String("abc");h[5]="de";if("5"===Object.getOwnPropertyNames(h)[0])return!1;var k=
#2023-02-0218:50Drew Verleethe line number in the minified file, and the accompanying text (above) isn't useful for debugging the issue. So i need to unminify it, and then map it back to the cljs. I assume that's possible, but i haven't read a tutorial on it, i haven't seen it done, and yet it would seem like an obvious thing to want. If this works out, maybe ill write the tutorial, then discover there are like 10 of them already, i just failed to find them.#2023-02-0218:50thhellerok stop#2023-02-0218:50thhellerthere is your mistake#2023-02-0218:50thhelleryou don't do any of thjat#2023-02-0218:51thhellerassuming the code above sits in a app.v1.js file and you have uploaded a app.v1.js.map file to LR, you should get proper stacktraces already#2023-02-0218:51thhellerthats it. nothing else to do#2023-02-0218:51thheller> So i need to unminify it, and then map it back to the cljs.#2023-02-0218:51thhellerthat is literally what the source map is for#2023-02-0218:52thhelleryou don't do anything, it just works#2023-02-0218:52thhelleronly problem is if files don't match#2023-02-0218:52thhelleror you try a development build and somehow map that to a release build#2023-02-0218:52thhellerthat will never work#2023-02-0218:53Drew VerleeI agree. My hope was that the only thing i had to do was upload the source maps. Thanks a ton, i'm pretty confident on what i have to do now.#2023-02-0218:53thhellerthe screenshot you posted above was some development build#2023-02-0218:53Drew Verleeyeah#2023-02-0218:53thhellersince a release build doesn't contain any cljs-runtime/ code#2023-02-0218:54thhellerthe reason you need versioning is to ensure the files match#2023-02-0218:54thhellerif you run a shadow-cljs release app and produce just a app.js#2023-02-0218:54thhellerand then do that again, there is no way to map anything#2023-02-0218:54thhellersince it won't be clear what code was used#2023-02-0218:58Drew Verleeyep, total makes sense. 🙂 Thanks for your patience and support.#2023-02-0309:57roman01laHas anyone came up with a decent setup for CSS modules and shadow-cljs? From developer experience side of things Webpack's loaders model is really nice, but I don't want to go that route.#2023-02-0309:59roman01laConsuming transformed CSS in cljs is not an issue, but I haven't figured yet how to make it work in dev, in watch mode. Where a change to CSS file should trigger recompilation of respective cljs ns. Perhaps emitting JS modules from CSS files is the way to go :thinking_face:#2023-02-0310:00roman01laOn the other hand (:require ["styles.js"]) is kind of confusing#2023-02-0310:00thhellerwhat would you want instead?#2023-02-0310:01roman01laeven (my-require "styles.css") would be fine, as long as the reference is straightforward#2023-02-0310:01thhellerplease explain what is not straightforward about (:require ["styles.js"])#2023-02-0310:02thhellernot sure which problem you are trying to solve here, so please clarify#2023-02-0310:02roman01lathere's no 1to1 mapping if I edit CSS file and require JS file#2023-02-0310:02roman01la> not sure which problem you are trying to solve here, so please clarify To make the setup less confusing for devs#2023-02-0310:02thhellerplease give a code example of how to perfect setup would look in your view#2023-02-0310:03thhellerI have never used css modules, since I personally fine them very clunky and annoying. so I might be biased and not seeing what a good solution might look like#2023-02-0310:03thhellerthis is my take on what css should look like https://github.com/thheller/shadow-css#2023-02-0310:04thhellerso I need a code example of what another setup would look like#2023-02-0310:04thheller
(ns 
  (:require [shadow.css :refer (css)]))

(defn hiccup-example []
  [:div {:class (css :px-4 :shadow {:color "green"})}
   "Hello World"])
#2023-02-0310:04thhellerhow would that look ideally with css modules?#2023-02-0310:07thhellerI'm asking about the code side first since that decides how things are implemented and built#2023-02-0310:08roman01lasure! Will get back in ~30 minutes, after a meeting#2023-02-0310:49roman01laso ideally it would be the following
(def styles (css "./button.css"))

[:div {:class (:base styles)} ...]
[:div {:class (:warn styles)} ...]
#2023-02-0310:50roman01lamaybe (css "./button.js") is fine as a starting point#2023-02-0310:50roman01laI mean (:require ["button.js"])#2023-02-0312:25hifumi123I’ve tried convincing myself to use garden and inline styling in reagent, but in the end I found all of these “CSS in Clojure” things to be lacking and often requiring me to write literal CSS inside strings, and extensions to garden ultimately felt like I was re-inventing features I took for granted in Sass in a worse way. So in the end I just use Sass for styling and keep a watch running for recompiling Sass assets into CSS (which shadow-cljs transparently hot reloads)#2023-02-0312:28hifumi123As long as you can get a single CSS file outputted by sassc into your public folder, then shadow-cljs takes care of the hot reloading and it works out very nicely in practice. As a benefit you get mixins, color blending functions, scoping, and so on. I cannot see myself ever going back to pure CSS or even what feels like the CLJS equivalent of CSS-in-JSX#2023-02-0312:29hifumi123With that said, if you must use a React library that insists on importing CSS modules, then you have practically no other choice but to set up Webpack (see option #2 https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html)#2023-02-0312:31roman01laThat's what we currently have (a background process smashing all Stylus files together). The main problem is global class names. Which is the only thing really that we want from CSS modules (basically hash + a readable class name).#2023-02-0313:40thhellerif you want to do it via a css macro you can do so. but you have to build it yourself. you can inform shadow-cljs that it needs to watch the css files as described here#2023-02-0313:40thhellerhttps://clojureverse.org/t/using-none-code-resources-in-cljs-builds/3745#2023-02-0313:40thhellerthe important bit being the extra analyazer data https://github.com/thheller/shadow-cljs/blob/483a25b522895225b63321e39bbc081dfba8c58b/src/main/shadow/resource.clj#L47-L49#2023-02-0313:41thhellerif you want (:require ["./button.css" :as x]) to work you can also get that#2023-02-0313:41thhellerassuming you have a tool that already translates CSS to plain JS#2023-02-0313:42thhellerin that case you should add an extra :source-paths entry, something like src/gen#2023-02-0313:42thhellerthen have your external tool just output the JS files into that folder, while presering namespace structure#2023-02-0313:43thhellerso src/main/your/app.css goes to src/gen/your/app.css.js#2023-02-0313:43thhellerthen as far as shadow-cljs is concerned it is just loading JS files and watch already watches them#2023-02-0313:45thhellerbonus points if you can control what kind of JS this outputs, but ESM or CommonJS work. CommonJS just won't hot-reload#2023-02-0313:45thhellerESM is best#2023-02-0309:59thhellerI doubt many CLJS people use or even tried css modules. I don't know if there are any tools that just generate the js files directly#2023-02-0518:54fabraoAnyone using devcards yet? Is it still usable with latest version of shadow-cljs?#2023-02-0519:04ZedI'm currently on shadow-cljs 2.20.7 and have it working with devcards. This https://github.com/bhauman/devcards/issues/168#issuecomment-640257949 has a little bit of boilerplate code that you need to make devcards' dependencies work with shadow-cljs.#2023-02-0616:14Lidor CohenHi All! Does anyone know how to list all licenses under a certain shadow-cljs project?#2023-02-0616:49thhellernot sure there are 3rd party tools for this. shadow-cljs doesn't have anything built-in#2023-02-0711:33Shuai LinHey @thheller for :target :esm can we output each entry as a separate ESM file, much similar to :npm-modules?
:app-esm {:target :esm
          :modules {:main {:entries [app.mod1 app.mod2]}}}
#2023-02-0711:37thhellerif you must have one module per namespace then :npm-module is the way to go#2023-02-0711:37thheller:esm also really expects exports, otherwise its pretty useless in an interop scenario#2023-02-0711:37thhellerbut you'd do it like this
{:target :esm
 :modules {:base {:entries []}
           :app.mod1 {:entries [app.mod1] :depends-on #{:base}}
           :app.mod2 {:entries [app.mod2] :depends-on #{:base}}}}
#2023-02-0711:38thhellerso all the shared stuff goes into :base#2023-02-0711:38Shuai Linah#2023-02-0711:38Shuai LinGuess I could hack a bit with the build hooks to scan the -test$ namespaces, then rewrite the :modules config to the above format#2023-02-0711:39thhelleras I said. if you must have one namespace per file#2023-02-0711:39thhellerthen you should really only consider :npm-module#2023-02-0711:39thhellerit is possible :esm. but far too much trouble doing everything manually#2023-02-0711:40thhellerI have some time in a bit, so I can see if I can figure out your :npm-module problem#2023-02-0711:40Shuai LinThx! I'll try with npm-module for now.#2023-02-0711:55Shuai Linbtw :npm-module doesn't support browser runtimes, right?#2023-02-0711:56Shuai LinI inspected the :worker-info key, and it's nil https://github.com/thheller/shadow-cljs/blob/756d3fc/src/main/shadow/build/targets/npm_module.clj#L69-L70#2023-02-0711:57thhellermaybe you should start explaining what you are trying to do exactly?
#2023-02-0711:58thheller:npm-module supports browsers, but only with more processing by third party tools as browser can't load commonjs files otherwise#2023-02-0711:59Shuai Linthere was a typo, I wanted to say "not support browser runtimes"#2023-02-0711:59Shuai LinSo I uses the :npm-module to output things like app.foo-test.cljs to app.foo-test.js and cypress test running would load it and execute it in the browser#2023-02-0712:00thhellerok#2023-02-0712:01thhellerand why are you looking into worker-info?#2023-02-0712:01Shuai LinI'm following the logic of the code to check why the browser page doesn't connect back to shadow-cljs as a runtime, maybe I'm looking at the wrong places#2023-02-0712:02Shuai Linbtw the :preloads is also not picked up in npm-modules#2023-02-0712:02thhellerwhy do you want the runtime to connect back? tests and repls usually don't play well with each other#2023-02-0712:02thhellerI also do not know how cypress handles runtimes and re-running tests#2023-02-0712:03thhellerso, if you just want a REPL but let the tests run on their own I recommend running a separate shadow-cljs browser-repl or so#2023-02-0712:04Shuai Lin> tests and repls usually don't play well with each other yeah most time they don't, but in my case it's a pretty good match. With the :esm target I can use shadow-cljs's reload for fast test-rerunning#2023-02-0712:04Shuai Line.g. in ^:dev/after-load to kick a re-run#2023-02-0712:05thhellerpreloads and runtimes are a bit more complicated with :npm-module since there is no controlled entry point#2023-02-0712:05thhellersince you can just load any namespace via JS#2023-02-0712:05Shuai Linwhich is much faster than the builtin liveReload of cypress (which comes from webpack)#2023-02-0712:05thhellerso you'd have something like require("./cljs-out/your.preload") in some prepended configuration or so#2023-02-0712:06thhellerrequire("./cljs-out/shadow.cljs.devtools.client.browser") is the ns for the REPL/hot-reload runtime#2023-02-0712:07Shuai Lin:thinking_face:#2023-02-0712:09Shuai LinThanks for the tips, I'll think about it. Maybe I'll simply go the way of using hooks to crunch the esm modules config like the one you mentioned above
{:target :esm
 :modules {:base {:entries []}
           :app.mod1 {:entries [app.mod1] :depends-on #{:base}}
           :app.mod2 {:entries [app.mod2] :depends-on #{:base}}}}
#2023-02-0712:12thhellerhooks can't do that#2023-02-0712:13thhellermaybe :browser-test works with cypress? I really never looked into cypress much#2023-02-0712:14Shuai Linprobably not, cypress has its own tests runner (one based on mocha) so tests have to be defined with mocha's primitives#2023-02-0712:14thhellerwell you can define your own runner with :browser-test. doesn't have to be cljs.test#2023-02-0712:16Shuai Linbut there would be a bunch of other stuff to wire up together, assertions, matchers, etc. so that's an another rabbit hole. Beside cypress is really a totally different beast in conducting the tests, so I'd rather avoid it.#2023-02-0712:16thhellerI really know very little about cypress and how it loads things, so really can't comment much from the cypress side#2023-02-0712:16thhellerthats not really what I'm talking about there#2023-02-0712:17thheller:browser-test just generates JS, with the assumption that it is executed in a browser environment#2023-02-0712:17thhellerit makes no further assumptions whatsoever#2023-02-0712:17thhellerhowever you use cypress now you'd use it then?#2023-02-0712:17thhellerI assume there is some kind of npm package you import?#2023-02-0712:17Shuai Linah right#2023-02-0712:18Shuai Linno npm package, all stuff is injected into the window object by cypress#2023-02-0712:18Shuai LinI'll definitely try that#2023-02-0712:19thhellerdo you have an example cypress setup?#2023-02-0712:19thhellerlike with :npm-module?#2023-02-0712:19Shuai LinI'll create a repro today#2023-02-0712:20thhellerI do remember trying something with cypress, but can't remember how far I got#2023-02-0712:23Shuai LinIt's pretty fascinating for doing react component testing. Otherwiser shadow's builtin browser-test is great enough for normal frontend unit tests#2023-02-0712:24Shuai LinBeing a js land tool it's by nature not a native fit for cljs, e.g. assert matchers for cljs data structures has to be custom registered#2023-02-0712:25Shuai Linbut once these rough egdes are smoothed it would be like a dream land for component based TDD#2023-02-0712:26thhelleroh right it was one of those things that expects files in certain locations and so on#2023-02-0713:37Shuai Linhttps://clojurians.slack.com/archives/C012GLC2SAZ/p1675775943518429?thread_ts=1675503454.655369&amp;cid=C012GLC2SAZ#2023-02-0713:38Shuai LinThis is what I'm using cypress for, i.e. component testing#2023-02-0714:05thhellercan't see what you are pressing. do you just save the file and cypress triggers running it or how does cypress get the new results?#2023-02-0714:05thhelleror is cypress not watching at all and it just runs via js/it ...?#2023-02-0714:07thhellerI can see shadow-cljs reloading something, but can't tell if cypress does anything 😛#2023-02-0714:08Shuai LinWell it's a "customized" version of cypress. The official cypress would actually reload the page completely each time the test ns is rebuilt.#2023-02-0714:10thhellerah#2023-02-0714:11thhelleris that configurable or actually hacking the npm package?#2023-02-0714:12Shuai Linnot configurable at all, but hacking the bundled js file in cypress electron app#2023-02-0714:13thhellerhehe#2023-02-0806:59thhellerI now remember why I abandoned looking into cypress more#2023-02-0807:00thhellerthe bundler configuration seems hardcoded to webpack/vite and can't be extended/replaced#2023-02-0807:33Shuai Linit does supports custom devserver, but the protocol is not publicly documented#2023-02-0807:33Shuai Linhttps://docs.cypress.io/guides/component-testing/component-framework-configuration#Custom-Dev-Server#2023-02-0807:49thhellerah, maybe that can be used for something#2023-02-0808:49thhellerdo you maybe have a clue what JS provides the describe it etc functions?#2023-02-0808:50thhellerI have something running but I don't know where to get those from 😛#2023-02-0809:06thhelleralright, found them#2023-02-0809:06thhellernow we are getting somewhere 😉#2023-02-0809:35Shuai Linits mocha#2023-02-0810:51thheller
(def cy js/parent.Cypress)
(.onSpecWindow cy js/window #js [])
(.action cy "app:window:before:load" js/window)
#2023-02-0810:52thhellerseems to make everything work, but I can do better I think#2023-02-0810:52thhellerI got it running completely with hot-reload and without vite/webpack#2023-02-0810:52thhelleror any other hacks to the electron app#2023-02-0810:52thhellerwill try some more later but looks promising now. no more hacks 😉#2023-02-0907:16Shuai Lin👏#2023-02-0907:33Shuai LinJust to confirm, you are playing with cypress component test, not e2e test, right?#2023-02-0907:34thhelleryes, I played with component tests but abandoned it after discovering that the same trick cannot be done for e2e#2023-02-0907:34thhellerand I couldn't figure out how to tell cypress to re-run the test after a hot-reload. since there is no documentation for any of this, at least nothing I could find#2023-02-0907:35thhellergot tired of reverse engineering the webpack integration#2023-02-0907:36thhellerI'm sure its just a dumb function call somewhere but I couldn't find it#2023-02-0908:28Shuai LinFor e2e it's simple
(defn ^:dev/before-load click-cypress-ui-restart-button
  []
  (when-not (= js/window.parent js/window)
    (-> (js/window.parent.document.querySelector "button.restart")
        .click)))
IMHO it's okay for the app iframe to do a full reload in e2e tests, since most of the e2e tests takes much longer and the benefit of hot-reloading over full page reload is dwarfed.
#2023-02-0908:35Shuai Linemm, on a second thought I agree it might have greater benefit than I have estimated if we have hot reloading in e2e tests, e.g. we can skip lots of time consuming fixtures like logins, cleanups etc. :thinking_face:#2023-02-0908:35thhellere2e can't replace the bundler though#2023-02-0908:35thhellerthere is no devServer option equivalent as far as I can tell#2023-02-0908:36thhellerso it always uses webpack no matter what#2023-02-0908:37Shuai Linyeah it would be more complex than CT. In CT there are two windows: top (cypress UI) & specWindow (where it/describe etc. and app code runs)#2023-02-0908:37Shuai LinIn e2e there are 3: top (cypress UI), specWindow (where it/describe etc. runs), and the app iframe#2023-02-0711:34Shuai Linand I'd like to have app.mod1.js and app.mod2.js under <output-dir>#2023-02-0711:34Shuai Linright now if I specify two modules it asks me to specify the deps between them
:app-esm {:target :esm
          :modules {:app.mod1 {:entries [app.mod1]}
                    :app.mod2 {:entries [app.mod2]}}}
#2023-02-0803:48hifumi123Is there a way to make changes in environment variables invalidate shadow-cljs cache? At the moment I am resorting to adding a namespace to my :cache-blockers , but I’m wondering if there is a more elegant way to handle this. In short, my configuration has a few :closure-defines like so
:closure-defines
{foo.bar/const #shadow/env ["FOO_BAR" "BAZ"]}
I’ve noticed that running npx shadow-cljs release target once then running FOO_BAR=QUUX npx shadow-cljs release target will give me a bundle with the older environment variable set, unless I delete cache in between builds. Maybe finding a way to set :cache-level to :off in release builds is what I want?
#2023-02-0806:06thhellerare you running the release when a previous server is already running?#2023-02-0806:06thhellerenv vars are only picked up if a new process is started#2023-02-0806:06thhellerso either make sure the server is stopped before that#2023-02-0806:06thhelleror use FOO_BAR=QUUX npx shadow-cljs release target --force-spawn#2023-02-0806:15hifumi123There wasn’t a server running beforehand, but invalidating caches would ensure changes would be reflected in the compiled bundle. The problem appeared when I would run npx shadow-cljs compile target multiple times, yet I didn’t see :closure-defines update in the app. Then out of sheer luck I tried a release build and everything worked; then I suspected my compilation caches were messing with things#2023-02-0806:21thhellerenv variables are used from the started server, so if you don't restart that they are not picked up#2023-02-0806:21thheller:closure-defines are also not cached, so nuking the cache doesn't have any effect#2023-02-0806:21thhellerif you want to be sure don't use env variables at all#2023-02-0806:22thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2023-02-0806:22thhellerlets you set whatever directly without the env indirection#2023-02-0806:02Shuai Lin@thheller another ESM related issue: when I 1) use :js-provider :import and 2) have a classpath ESM that makes uses of a npm ESM pkg (`promsemirror-state` in the repro below) then advanced compilation would fail with Required namespace "esm_import$prosemirror_state" never defined. Repro is here https://github.com/lins05/my-repros/tree/master/repro-shadow-cljs-advanced-using-npm-esm#2023-02-0806:07thhellermight be the same issue as :npm-module, I'll check it out#2023-02-0806:08Shuai LinThx! To be accurate, npm-module is only warning, but this completely fails the release build#2023-02-0814:35alexdavisI want to be able to build several versions of my app, each with different :closure-defines values. At the moment I am duplicating everything for each build, so
:builds {:env1 {:target :browser
                 :compiler-options {:output-feature-set :es-next
                                    :closure-defines {app.foo/BAR "baz1"}}
                 :modules {:main {:init-fn app.core/init}}
                 :output-dir "public/js"
                 :asset-path "/js"
                 :dev {:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}
                 :devtools {:http-root "public"
                            :http-port 3900
                            :preloads [devtools.preload
                                       shadow.remote.runtime.cljs.browser]}}
          :env2 {:target :browser
                 :compiler-options {:output-feature-set :es-next
                                    :closure-defines {app.foo/BAR "baz2"}}
                 :modules {:main {:init-fn app.core/init}}
                 ...
Is there a way to share things between these different builds? or maybe a better way to inject variables for different builds?
#2023-02-0814:44Mario TrostThere is --config-merge to use from the command line https://shadow-cljs.github.io/docs/UsersGuide.html#config-merge (edit: wrong link)#2023-02-0814:44thhellerhttps://shadow-cljs.github.io/docs/UsersGuide.html#config-merge#2023-02-0814:44Mario TrostOr defaults: https://shadow-cljs.github.io/docs/UsersGuide.html#build-target-defaults#2023-02-0814:45alexdavisah thank you! I thought I'd read the guide but obviously not carefully enough 😞#2023-02-0816:27thhellerany cypress testing enthusiasts arround?#2023-02-0818:48lilactownwe use cypress at work with shadow.#2023-02-0818:48lilactownI've written my share of cypress tests as well#2023-02-0819:01thhellertests are written in CLJS? do you use component testing or e2e?#2023-02-0819:01thhellerdo you use macros to make syntax nicer or just plain JS interop?#2023-02-0819:02lilactowntests are written in CLJS#2023-02-0819:02lilactownwe use a mix of interop and helper functions, no macros#2023-02-0819:03lilactownah we do use mocha-latte for writing tests https://github.com/contentjon/mocha-latte#2023-02-0819:31lilactownwe only do e2e testing. for component tests, we use react-testing-library. again just with helper functions and interop#2023-02-0820:21thhellerso I assume its done via :npm-module build and running through the built-in webpack?#2023-02-0820:26lilactownthat's right#2023-02-0820:30lilactownthe way we do it is a bit strange, I didn't set it up, but it works. we write the CLJS output to a dir in node_modules, and then we have a JS file for each test ns that requires it. e.g. we have a namespace amperity.cypress.integration.databases and then a cypress/integration/databases.spec.js which contains a require
require("amperity-cypress/amperity.cypress.integration.databases");
and cypress watches that dir and rebuilds when the node_module/amperity-cypress code changes
#2023-02-0820:32thhellerinteresting#2023-02-0909:03dazldin react native, should shadow be refreshing code, or metro?#2023-02-0909:04dazldit’s been a while since I’ve done any RN - last time was re-natal#2023-02-0909:04thhellershadow#2023-02-0909:11dazldIt’s doing this, and recreating shadow on every reload, it seems:
LOG  Running "Harvey" with {"rootTag":131,"initialProps":{}}
 LOG  shadow-cljs #77 ready!
 BUNDLE  ./index.js

 LOG  Running "Harvey" with {"rootTag":141,"initialProps":{}}
 LOG  shadow-cljs #78 ready!
 BUNDLE  ./index.js

 LOG  Running "Harvey" with {"rootTag":151,"initialProps":{}}
 LOG  shadow-cljs #79 ready!
 BUNDLE  ./index.js

 LOG  Running "Harvey" with {"rootTag":161,"initialProps":{}}
 LOG  shadow-cljs #80 ready!
 BUNDLE  ./index.js

 LOG  Running "Harvey" with {"rootTag":171,"initialProps":{}}
 LOG  shadow-cljs #81 ready!
 BUNDLE  ./index.js

 LOG  Running "Harvey" with {"rootTag":181,"initialProps":{}}
 LOG  shadow-cljs #82 ready!
#2023-02-0909:12dazldI tried disabling “fast refresh” in the debug menu, but seems like that turned everything off.#2023-02-0909:12dazldperhaps this is a better question for #C0E1SN0NM too..#2023-02-0909:21thhelleryou need to turn off any other reloading yes#2023-02-0909:21thheller> but seems like that turned everything off#2023-02-0909:21thhellershouldn't affect what shadow does whatsoever?#2023-02-0909:38roman01laHey Dan 👋 Perhaps @UQP60F2B1 could help you 🙂#2023-02-0909:40dazldthat’d be awesome, and hey 👋 back!#2023-02-0909:40dazldthe metro refresh clobbers all state in the app, so it’s pretty annoying. glad that this isn’t the intended experience.#2023-02-0911:19dazld@U05224H0W perhaps the shadow live reloading isn’t working? could you suggest a way to debug that?#2023-02-0911:20dazldI see the compilation success messages, and when metro has refreshed, the changes are visible. however, when “fast refresh” is disabled in RN, I don’t see any subsequent changes.#2023-02-0911:20dazldrepl connects fine too :I#2023-02-0911:22thhellerwithout knowing anything about what you are doing I can't really comment#2023-02-0911:22thhellerare you following https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html?#2023-02-0911:22dazldfair enough.#2023-02-0911:22thhellerie. do you have the hooks configured? are you triggering your render properly?#2023-02-0911:22thhellershadow just reloads your code. rendering it is up to you.#2023-02-0911:23dazldyep, the hooks are there#2023-02-0912:01dazldit’s definitely reloading, perhaps shadow.react-native/render-root isnt compatible with 0.71?#2023-02-0912:01dazldI can see the modules being loaded, and can observe atoms changing in the namespace, but then nothing happens in the render#2023-02-0912:20dazld@U05224H0W just a heads up, that there is indeed something not right with the render-root function, sadly - swapping to use the reload-comp strategy in https://github.com/flexsurfer/rn-shadow-steroid is working fine.#2023-02-0912:20dazldif I get a chance later on, i’ll try and lock that down further.#2023-02-0913:44thhellernot aware of any issues, but I also don't use react-native so totally possible something doesn't work#2023-02-0913:45dazldsorry for noise, appreciate the support. I’ll open an issue if i can get a reliable description of why the out of the box render fn wasn’t working here.#2023-02-1013:36Ben Liebermanhi, I'm working with shadow-css and re-frame. I started adding some clj files to my project so I added a deps.edn and I am now using that to connect to a REPL. When I was still using shadow-cljs.edn I followed the recommended steps for developing with shadow-css at the REPL. Now that I'm using deps.edn, though, I'm having issues. When I connect with npx shadow-cljs clj repl and try to load the repl ns, it either cannot find shadow.css.build or the symbol update-vals from build.cljc is unresolved.#2023-02-1019:00thhellerthe shadow-css dependency needs to be available and it requires clojure 1.11.1, you maybe have 1.10?#2023-02-1019:37Ben Liebermanah, yeah it is the version... :face_palm::skin-tone-2: thanks @U05224H0W!#2023-02-1014:35borkdudeDoes :target :node-library support code-splitting / modules?#2023-02-1014:35borkdudeCurrently #C03DPCLCV9N uses this setting and we want to make some libraries available lazily using modules. cc @U0ETXRFEW#2023-02-1014:37borkdudeI suspect that this is not supported, glancing over the UsersGuide#2023-02-1014:40pezI don't quite understand these things. I know there is also :npm-module, but I think that might be a rather unsupported target, and I have no clue if it supports code splitting anyway.#2023-02-1014:42pezCan we get away with using multiple :node-library targets?#2023-02-1014:43pezOr does that pack the whole cljs runtime in each, maybe...#2023-02-1014:44borkdudeI think it does yes. Also we can't use es6: https://github.com/electron/electron/issues/21457#2023-02-1014:45borkdude@U0ETXRFEW Well, maybe we should add rewrite-clj and just hope for the best then#2023-02-1014:46pezNon-lazily?#2023-02-1014:47borkdudeyes?#2023-02-1014:47borkdudeI see no other option#2023-02-1014:48pezI don't think it will add much startup time. We can measure it.#2023-02-1014:50borkdudeI am working on a PR, let's continue the conversation elsewhere to not bug the people here#2023-02-1018:55thheller:node-library does not support splitting, :npm-module is an option#2023-02-1019:01borkdudeok, I'll try that#2023-02-1019:04borkdudeit's not clear to me how to declare the modules in npm-module. I tried :modules but that seems to be ignored#2023-02-1019:08borkdudeI wish I could just use target esm everywhere, but alas, electron won't let you#2023-02-1019:14thhellerquite sad they still don't support esm#2023-02-1015:32fabraoHello all, is that possible to do in Clojurescript something like plug-in that it can be load after, as a selectable module into frontend?#2023-02-1018:56thhelleryou mean code splitting in general? https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html#2023-02-1018:56thhellera generic plugin system is not possible with :advanced builds no#2023-02-1019:09fabraoHello @U05224H0W, thank you for your time. Plugin system I mean if I want to provide some new feature as dynamic module, like new option in system.#2023-02-1019:15thhellerif these features are known at compile time then code splitting#2023-02-1019:15thhellerif they are completely independent then no, there is no good way to do that#2023-02-1019:23fabraobut can I provide another .js from other project to be load after and be included ?#2023-02-1019:24thhellerif that other js is not cljs output then yes#2023-02-1019:24fabraoit should be other re-frame project too#2023-02-1019:25thhellerthen it will have its own re-frame/reagent/react/etc version that will likely conflict and not be compatible with your own#2023-02-1019:25fabraohummm, understood#2023-02-1019:25fabraothank you#2023-02-1019:26thhellerif you don't care for :advanced optimization and :simple is good enough then this is doable, but still tricky and not supported out of the box#2023-02-1016:44Braden ShepherdsonI'm getting
[:app] Compiling ...
Closure compilation failed with 1 errors
--- metabase/domain_entities/queries/util.cljc:13
and it's not clear from that line what the issue is. is there a flag to set or a hidden folder where I see the intermediate JS? (or the macroexpanded CLJS code?) there's a new, complex macro in play here, but it seems to be correct from playing around with macroexpand.
#2023-02-1018:56thhellerhmm doesn't it tell you the actual error?#2023-02-1018:57Braden Shepherdsonnot the way I was running it. running npx shadow-cljs release app directly showed me the error. but it was just "missing semicolon" which didn't help much.#2023-02-1018:57Braden ShepherdsonI fixed the issue eventually by binary-searching the contents of my macro.#2023-02-1018:57thhellerthat is often an indicator of invalid generated JS#2023-02-1018:58Braden Shepherdsonthe trouble seems to have been generating (let [defn# (defn ...)] (other things) defn#)#2023-02-1018:58thhelleryou can find the generated JS in the .shadow-cljs/builds/release/<the-build-id> folders#2023-02-1016:58borkdudeI'm trying to run the build report hook in joyride but it fails with:
NoSuchFileException: out/js/main.js
When I change :output-to to "out/js/main.js" it does work. Perhaps it's hardcoded?
#2023-02-1018:59thhellerbuild reports are only currently support for :browser builds#2023-02-1019:00borkdude@U05224H0W I did manage to get it work though with very useful output:#2023-02-1019:02thhellerah#2023-02-1019:03borkdudeI'm also using the build report with target esm in nbb btw#2023-02-1021:52Greg JeanmartWhat would be the best way to use a web library that performs https://github.com/WalletConnect/web3modal/blob/V2/packages/html/src/client.ts#L25? Right now, when instantiating this lib, I'm getting Uncaught (in promise) Module not provided: @web3modal/ui Thanks for your help 🙏#2023-02-1109:00thhelleruse webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external#2023-02-1109:01thhelleror vite also is capable of this I think#2023-02-1112:51Greg JeanmartThanks a lot @U05224H0W. I'll give it a try 😉#2023-02-1119:48borkdudeIs there a way with target esm to emit .mjs files rather than .js files? I have a project which requires the entry point to be a cjs .js file#2023-02-1119:55thhellernot currently no#2023-02-1120:28borkdudewe almost got the electron thing working with target esm, but the entrypoint file must be a cjs file with the .js extension#2023-02-1120:32thhellerits ok to write some boilerplate JS code if needed 😉#2023-02-1120:32borkdude?#2023-02-1120:34thhellerI guess I'm confused by your statement. I mean it might be ok to write that cjs file yourself in JS and just call out to the ESM code?#2023-02-1120:34borkdudeyes, believe me, I've written some boilerplate. but the entrypoint must be a file which cannot end with .cjs#2023-02-1120:35borkdudeand because of target esm we must state "type": "module", which means every .js file is an esm file#2023-02-1120:37thhellerdoes the trick work to put the ESM output into its own folder with its own package.json type module#2023-02-1120:37thhellerbut at the root just a regular package.json without?#2023-02-1120:37thhelleror you just rename the .js files to .mjs 😉#2023-02-1120:38borkdudeWe're basically running into this issue: https://github.com/microsoft/vscode-vsce/issues/824#2023-02-1120:40thhellerdid you try the separate folder trick? I'm not sure how type:module is handled for sub dirs, or if its only recognized at the root#2023-02-1120:41borkdudedo you mean, put a package.json in the out directory?#2023-02-1120:41thhelleryes#2023-02-1120:41borkdudetrying...#2023-02-1120:43borkdudethat seemed to work!#2023-02-1121:35borkdudeIf I define a global like:
globalThis.joyride_vscode = require("vscode");
(for reasons...) and refer to it from CLJS as:
(def vscode js/joyride_vscode)
and then do:
(vscode.window.showInputBox ...)
how can I prevent advanced renaming these usages
#2023-02-1121:35borkdudeI tried an externs file like:
global:joyride_vscode
window
showInputBox
createOutputChannel
showInformationMessage
but this gets a bit tedious
#2023-02-1121:36thhellerthis vscode.window.showInputBox may just loose the necessary type info, did you try with proper interop?#2023-02-1121:37thhelleror maybe (def ^js vscode js/joyride_vscode), although that should be inferred#2023-02-1121:37borkdudetrying the latter now#2023-02-1121:38thheller(.. vscode -window (showInputBox ...)) might work, although I remember something about .. not preserving typehints#2023-02-1121:39thhellerthe whole symbol with dot handling is a bit hacky in many places#2023-02-1121:39borkdudemaybe it also helps to define a .js file and then import vscode from that .js file which retrieves the global?#2023-02-1121:40thhellerhmm?#2023-02-1121:41borkdudeIt did work before with (:require ["vscode" :as vscode]) with the same interop#2023-02-1121:41thhellerwhy are doing this in the first place? (:require ["vscode" :as x]) x/window.showInputBox should properly infer#2023-02-1121:42borkdudebecause the cjs + esm hack we're now in, gave us "cannot find module vscode" errors, I think because in vscode, that module is implicit#2023-02-1121:43thhellerwho cannot find it? shadow-cljs or vscode?#2023-02-1121:43borkdudelet me get back to you later, I need to go for a moment#2023-02-1122:05borkdude@U05224H0W It seems vscode itself has problems with it:#2023-02-1122:06thhellerhmm yeah. no clue#2023-02-1122:15borkdudeSo this as workaround helps, I think: src/joyride/vscode.js
module.exports = globalThis.joyride_vscode;
and then:
["/joyride/vscode.js" :as vscode]
#2023-02-1210:17borkdudeDo you happen to know where this error might be coming from in watch mode?
Activating extension 'betterthantomorrow.joyride' failed: WebSocket is not defined.
My workaround for this is:
globalThis.WebSocket = require("ws");
in the main wrapper, but I wonder if there's a better solution
#2023-02-1210:22borkdudeI made it conditional like this now:
ws_file = require.resolve("ws");
if (ws_file != null) {
  globalThis.WebSocket = require(ws_file);
}
#2023-02-1210:29thheller:target :esm assumes that it is executed in the browser runtime by default#2023-02-1210:29thhellerhaven't written the node runtime yet#2023-02-1210:29thhellerso it would be :runtime :node in the build config, but thats not implemented#2023-02-1210:29borkdudeIt does work well with the ws library though, hot reloading in the electron extension "just works" :)#2023-02-1210:30thhellergood to know#2023-02-1210:31borkdudeIn fact, the only places where I've used target esm was in Node.js so far#2023-02-1310:11thheller@borkdude what happened to this highlighting thing? code link is dead https://blog.michielborkent.nl/writing-clojure-highlighter.html#2023-02-1310:12borkdudeI ended up using a .js highlighter since this simplified building the blog a little bit, but I can dig up the code if you want to look at it, from the git history#2023-02-1310:12thhellerso you wouldn't recommend doing the server side thing? or any other issues?#2023-02-1310:13thhellerI can dig out the code myself, just thought I ask why its gone 😛#2023-02-1310:14borkdudeThis is the server side solution: https://github.com/borkdude/blog/blob/293b8883ad96d9dd4a4c14b21aec381b2785b73a/highlighter.clj If you're on the JVM you can use clj-kondo directly rather than the pod. Or leave it out: it only improves the situation for coloring locals that have the same name as clojure vars, for example.#2023-02-1310:15thhellerthanks#2023-02-1310:16borkdude> so you wouldn't recommend doing the server side thing? It depends: this code is for generating static assets and in the end I went with prism.js which I found not perfect, but good enough, and relatively small#2023-02-1310:16thhellerI'm parsing some code in CLJ and just want basic highlighting when dumping it out into html#2023-02-1310:17borkdudefeel free to re-use that code, I think it makes sense#2023-02-1310:17thhellerthanks, I'll think I go with something like this#2023-02-1310:17thhellerI want to make stuff clickable so it takes you to the source location#2023-02-1310:18thhellerso can't just use a pure JS highlighter anyways#2023-02-1310:18thhellerI think this looks like a good base#2023-02-1310:18thhellerI'll tinker and let you know#2023-02-1310:19borkdudeI also have a documentation solution which analyzes vars (statically) and adds source links: https://github.com/borkdude/quickdoc Also based on clj-kondo#2023-02-1310:19borkdudebut I guess in shadow-cljs you know the source locations at runtime#2023-02-1310:20thhellerits for a thing I'm building, similar to clerk in some ways. don't just want to display the code, want to make it clickable so it takes you to the source#2023-02-1310:22borkdudenice